From d1117f30f553ef4ab3d505a9065cf1b0ceb1ecea Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 3 Jun 2021 21:54:09 +0000 Subject: [PATCH] Update LKG. --- lib/cs/diagnosticMessages.generated.json | 14 +- lib/de/diagnosticMessages.generated.json | 14 +- lib/es/diagnosticMessages.generated.json | 14 +- lib/fr/diagnosticMessages.generated.json | 12 +- lib/it/diagnosticMessages.generated.json | 14 +- lib/ja/diagnosticMessages.generated.json | 14 +- lib/ko/diagnosticMessages.generated.json | 14 +- lib/lib.dom.d.ts | 911 +- lib/lib.dom.iterable.d.ts | 6 +- lib/lib.es2015.core.d.ts | 16 +- lib/lib.es2015.iterable.d.ts | 4 +- lib/lib.es2015.symbol.wellknown.d.ts | 26 +- lib/lib.es2018.asynciterable.d.ts | 2 +- lib/lib.es2020.bigint.d.ts | 6 +- lib/lib.es2020.intl.d.ts | 250 +- lib/lib.es2020.symbol.wellknown.d.ts | 2 +- lib/lib.es2021.d.ts | 24 + lib/lib.es2021.full.d.ts | 25 + lib/lib.es2021.promise.d.ts | 43 + lib/lib.es2021.string.d.ts | 35 + lib/lib.es2021.weakref.d.ts | 75 + lib/lib.es5.d.ts | 40 +- lib/lib.esnext.d.ts | 5 +- lib/lib.esnext.intl.d.ts | 2 +- lib/lib.webworker.d.ts | 251 +- lib/lib.webworker.iterable.d.ts | 2 +- lib/pl/diagnosticMessages.generated.json | 14 +- lib/protocol.d.ts | 155 +- lib/pt-br/diagnosticMessages.generated.json | 24 +- lib/ru/diagnosticMessages.generated.json | 14 +- lib/tr/diagnosticMessages.generated.json | 12 +- lib/tsc.js | 20760 ++++++----- lib/tsserver.js | 32514 ++++++++++-------- lib/tsserverlibrary.d.ts | 1316 +- lib/tsserverlibrary.js | 32397 +++++++++-------- lib/typescript.d.ts | 1137 +- lib/typescript.js | 31245 ++++++++++------- lib/typescriptServices.d.ts | 1137 +- lib/typescriptServices.js | 31245 ++++++++++------- lib/typingsInstaller.js | 23335 +++++++------ lib/zh-cn/diagnosticMessages.generated.json | 12 +- lib/zh-tw/diagnosticMessages.generated.json | 14 +- 42 files changed, 103026 insertions(+), 74126 deletions(-) create mode 100644 lib/lib.es2021.d.ts create mode 100644 lib/lib.es2021.full.d.ts create mode 100644 lib/lib.es2021.promise.d.ts create mode 100644 lib/lib.es2021.string.d.ts create mode 100644 lib/lib.es2021.weakref.d.ts diff --git a/lib/cs/diagnosticMessages.generated.json b/lib/cs/diagnosticMessages.generated.json index 3e78bf65c43c3..b30f628f70987 100644 --- a/lib/cs/diagnosticMessages.generated.json +++ b/lib/cs/diagnosticMessages.generated.json @@ -199,6 +199,7 @@ "An_implementation_cannot_be_declared_in_ambient_contexts_1183": "Implementace se nedá deklarovat v ambientních kontextech.", "An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type_1379": "Alias importu se nemůže odkazovat na deklaraci, která se exportovala pomocí export type.", "An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type_1380": "Alias importu se nemůže odkazovat na deklaraci, která se importovala pomocí import type.", + "An_import_alias_cannot_use_import_type_1392": "Alias importu nemůže používat import type.", "An_import_declaration_can_only_be_used_in_a_namespace_or_module_1232": "Deklarace importu jde použít jenom v oboru názvů nebo modulu.", "An_import_declaration_cannot_have_modifiers_1191": "Deklarace importu nemůže mít modifikátory.", "An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead_2691": "Cesta pro import nemůže končit příponou {0}. Zvažte možnost importovat místo toho {1}.", @@ -443,6 +444,7 @@ "Default_export_of_the_module_has_or_is_using_private_name_0_4082": "Výchozí export modulu má nebo používá privátní název {0}.", "Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0_6200": "Definice následujících identifikátorů je v konfliktu s definicemi v jiném souboru: {0}", "Delete_all_unused_declarations_95024": "Odstranit všechny nepoužívané deklarace", + "Delete_all_unused_imports_95147": "Odstranit všechny nepoužívané importy", "Delete_the_outputs_of_all_projects_6365": "Odstranit výstupy všech projektů", "Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react__6084": "[Zastaralé] Použijte místo toho --jsxFactory. Určí objekt vyvolaný pro createElement při cílení na generování JSX react.", "Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file_6170": "[Zastaralé] Použijte místo toho --outFile. Zřetězí a vygeneruje výstup do jednoho souboru.", @@ -668,6 +670,7 @@ "Index_signatures_are_incompatible_2330": "Signatury indexu jsou nekompatibilní.", "Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local_2395": "Jednotlivé deklarace ve sloučené deklaraci {0} musí být všechny exportované nebo všechny místní.", "Infer_all_types_from_usage_95023": "Odvodit všechny typy z použití", + "Infer_function_return_type_95148": "Odvodit návratový typ funkce", "Infer_parameter_types_from_usage_95012": "Odvodit typy parametrů z využití", "Infer_this_type_of_0_from_usage_95080": "Vyvodit typ this pro {0} z použití", "Infer_type_of_0_from_usage_95011": "Odvodit typ {0} z využití", @@ -814,7 +817,6 @@ "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018": "Osmičkové literály nejsou povolené v inicializátoru členů výčtů. Použijte syntaxi {0}.", "Octal_literals_are_not_allowed_in_strict_mode_1121": "Osmičkové literály nejsou ve striktním režimu povolené.", "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085": "Osmičkové literály nejsou dostupné při cílení na ECMAScript 5 a vyšší. Použijte syntaxi {0}.", - "Only_ECMAScript_imports_may_use_import_type_1370": "import type můžou používat jen importy ECMAScript.", "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091": "V příkazu for...in se povoluje deklarovat jenom jednu proměnnou.", "Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement_1188": "V příkazu for...of se povoluje deklarovat jenom jednu proměnnou.", "Only_a_void_function_can_be_called_with_the_new_keyword_2350": "Klíčovým slovem new se dá volat jenom funkce void.", @@ -920,9 +922,11 @@ "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202": "Odkazy projektu nemůžou tvořit cyklický graf. Zjistil se cyklus: {0}", "Projects_in_this_build_Colon_0_6355": "Projekty v tomto sestavení: {0}", "Projects_to_reference_6300": "Projekty, které se mají odkazovat", + "Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0_4111": "Vlastnost {0} pochází ze signatury indexu, proto je zapotřebí k ní přistupovat pomocí ['{0}'].", "Property_0_does_not_exist_on_const_enum_1_2479": "Vlastnost {0} ve výčtu const {1} neexistuje.", "Property_0_does_not_exist_on_type_1_2339": "Vlastnost {0} v typu {1} neexistuje.", "Property_0_does_not_exist_on_type_1_Did_you_mean_2_2551": "Vlastnost {0} v typu {1} neexistuje. Měli jste na mysli {2}?", + "Property_0_does_not_exist_on_type_1_Did_you_mean_to_access_the_static_member_2_instead_2576": "Vlastnost {0} v typu {1} neexistuje. Chtěli jste místo toho přistoupit ke statickému členu {2}?", "Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_c_2550": "Vlastnost {0} neexistuje u typu {1}. Potřebujete změnit cílovou knihovnu? Zkuste změnit možnost kompilátoru lib na {2} nebo novější.", "Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor_2564": "Vlastnost {0} nemá žádný inicializátor a není jednoznačně přiřazena v konstruktoru.", "Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation_7033": "Vlastnost {0} má implicitně typ any, protože její přistupující objekt get nemá anotaci návratového typu.", @@ -932,7 +936,6 @@ "Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2_2416": "Vlastnost {0} v typu {1} nejde přiřadit ke stejné vlastnosti v základním typu {2}.", "Property_0_in_type_1_is_not_assignable_to_type_2_2603": "Vlastnost {0} v typu {1} nejde přiřadit typu {2}.", "Property_0_in_type_1_refers_to_a_different_member_that_cannot_be_accessed_from_within_type_2_18015": "Vlastnost {0} v typu {1} odkazuje na jiného člena, ke kterému není možné získat přístup z typu {2}.", - "Property_0_is_a_static_member_of_type_1_2576": "Vlastnost {0} není statický člen typu {1}.", "Property_0_is_declared_but_its_value_is_never_read_6138": "Deklaruje se vlastnost {0}, ale její hodnota se vůbec nečte.", "Property_0_is_incompatible_with_index_signature_2530": "Vlastnost {0} není kompatibilní se signaturou indexu.", "Property_0_is_incompatible_with_rest_element_type_2573": "Vlastnost {0} není kompatibilní s typem elementu rest.", @@ -1007,6 +1010,7 @@ "Report_errors_in_js_files_8019": "Ohlásit chyby v souborech .js", "Report_errors_on_unused_locals_6134": "Umožňuje nahlásit chyby u nevyužitých místních hodnot.", "Report_errors_on_unused_parameters_6135": "Umožňuje nahlásit chyby u nevyužitých parametrů.", + "Require_undeclared_properties_from_index_signatures_to_use_element_accesses_6803": "Vyžadovat, aby nedeklarované vlastnosti ze signatur indexů používaly přístupy k elementům", "Required_type_parameters_may_not_follow_optional_type_parameters_2706": "Požadované parametry typu nemůžou být až za volitelnými parametry typu.", "Resolution_for_module_0_was_found_in_cache_from_location_1_6147": "Překlad pro modul {0} se našel v mezipaměti umístění {1}.", "Resolve_keyof_to_string_valued_property_names_only_no_numbers_or_symbols_6195": "keyof překládejte jen na názvy vlastností s hodnotami typu string (ne čísla ani symboly).", @@ -1146,7 +1150,7 @@ "The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback_1060": "První parametr metody then příslibu musí být zpětné volání.", "The_global_type_JSX_0_may_not_have_more_than_one_property_2608": "Globální typ JSX.{0} by neměl mít více než jednu vlastnost.", "The_implementation_signature_is_declared_here_2750": "Signatura implementace se deklarovala tady.", - "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system_1343": "Metavlastnost import.meta se povoluje jen v případě, že možnost --module je nastavená na esnext nebo system.", + "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_esnext_or_system_1343": "Metavlastnost import.meta se povoluje jen v případě, že možnost --module je nastavená na es2020, esnext nebo system.", "The_inferred_type_of_0_cannot_be_named_without_a_reference_to_1_This_is_likely_not_portable_A_type_a_2742": "Odvozený typ {0} se nedá pojmenovat bez odkazu na {1}. Pravděpodobně to nebude přenosné. Vyžaduje se anotace typu.", "The_inferred_type_of_0_references_a_type_with_a_cyclic_structure_which_cannot_be_trivially_serialize_5088": "Odvozený typ {0} se odkazuje na typ s cyklickou strukturou, která se nedá triviálně serializovat. Musí se použít anotace typu.", "The_inferred_type_of_0_references_an_inaccessible_1_type_A_type_annotation_is_necessary_2527": "Odvozený typ {0} odkazuje na nepřístupný typ {1}. Musí se použít anotace typu.", @@ -1216,7 +1220,7 @@ "This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without_6234": "Tento výraz se nedá volat, protože je to přístupový objekt get. Nechtěli jste ho použít bez ()?", "This_expression_is_not_constructable_2351": "Tento výraz se nedá vytvořit.", "This_file_already_has_a_default_export_95130": "Tento soubor už má výchozí export.", - "This_import_is_never_used_as_a_value_and_must_use_import_type_because_the_importsNotUsedAsValues_is__1371": "Tento import se nikdy nepoužívá jako hodnota a musí používat import type, protože importsNotUsedAsValues je nastavené na error.", + "This_import_is_never_used_as_a_value_and_must_use_import_type_because_importsNotUsedAsValues_is_set__1371": "Tento import se nikdy nepoužívá jako hodnota a musí používat import type, protože importsNotUsedAsValues je nastavené na error.", "This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_fil_6233": "Toto je deklarace, která se rozšiřuje. Zvažte možnost přesunout rozšiřující deklaraci do stejného souboru.", "This_may_be_converted_to_an_async_function_80006": "Toto je možné převést na asynchronní funkci.", "This_module_can_only_be_referenced_with_ECMAScript_imports_Slashexports_by_turning_on_the_0_flag_and_2497": "Na tento modul je možné se pomocí importů nebo exportů ECMAScript odkazovat jen tak, že se zapne příznak {0} a odkáže se na výchozí export.", @@ -1342,6 +1346,8 @@ "Updating_output_of_project_0_6373": "Aktualizuje se výstup projektu {0}...", "Updating_output_timestamps_of_project_0_6359": "Aktualizují se výstupní časová razítka projektu {0}...", "Updating_unchanged_output_timestamps_of_project_0_6371": "Aktualizují se nezměněná výstupní časová razítka projektu {0}...", + "Use_element_access_for_0_95145": "Použít přístup k elementům pro {0}", + "Use_element_access_for_all_undeclared_properties_95146": "Použít přístup k elementům pro všechny nedeklarované vlastnosti", "Use_synthetic_default_member_95016": "Použije syntetického výchozího člena.", "Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher_2494": "Použití řetězce v příkazu for...of se podporuje jenom v ECMAScript 5 nebo vyšší verzi.", "Using_compiler_options_of_project_reference_redirect_0_6215": "Using compiler options of project reference redirect '{0}'.", diff --git a/lib/de/diagnosticMessages.generated.json b/lib/de/diagnosticMessages.generated.json index dc1fb7e93ff6d..fd5b94c64271a 100644 --- a/lib/de/diagnosticMessages.generated.json +++ b/lib/de/diagnosticMessages.generated.json @@ -199,6 +199,7 @@ "An_implementation_cannot_be_declared_in_ambient_contexts_1183": "Eine Implementierung darf nicht in Umgebungskontexten deklariert werden.", "An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type_1379": "Ein Importalias kann nicht auf eine Deklaration verweisen, die mithilfe von \"export type\" exportiert wurde.", "An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type_1380": "Ein Importalias kann nicht auf eine Deklaration verweisen, die mithilfe von \"import type\" importiert wurde.", + "An_import_alias_cannot_use_import_type_1392": "Ein Importalias kann \"import type\" nicht verwenden.", "An_import_declaration_can_only_be_used_in_a_namespace_or_module_1232": "Eine Importdeklaration darf nur in einem Namespace oder Modul verwendet werden.", "An_import_declaration_cannot_have_modifiers_1191": "Eine Importdeklaration darf keine Modifizierer besitzen.", "An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead_2691": "Ein Importpfad darf nicht mit einer Erweiterung \"{0}\" enden. Importieren Sie ggf. stattdessen \"{1}\".", @@ -443,6 +444,7 @@ "Default_export_of_the_module_has_or_is_using_private_name_0_4082": "Der Standardexport des Moduls besitzt oder verwendet den privaten Namen \"{0}\".", "Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0_6200": "Definitionen der folgenden Bezeichner stehen in Konflikt mit denen in einer anderen Datei: {0}", "Delete_all_unused_declarations_95024": "Alle nicht verwendeten Deklarationen löschen", + "Delete_all_unused_imports_95147": "Alle nicht verwendeten Importe löschen", "Delete_the_outputs_of_all_projects_6365": "Ausgaben aller Projekte löschen", "Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react__6084": "[Veraltet] Verwenden Sie stattdessen \"--jsxFactory\". Geben Sie das Objekt an, das für \"createElement\" aufgerufen wurde, wenn das Ziel die JSX-Ausgabe \"react\" ist.", "Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file_6170": "[Veraltet] Verwenden Sie stattdessen \"--outFile\". Verketten und Ausgeben in eine einzige Datei", @@ -668,6 +670,7 @@ "Index_signatures_are_incompatible_2330": "Die Indexsignaturen sind nicht kompatibel.", "Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local_2395": "Einzelne Deklarationen in der gemergten Deklaration \"{0}\" müssen alle exportiert oder alle lokal sein.", "Infer_all_types_from_usage_95023": "Alle Typen aus der Syntax ableiten", + "Infer_function_return_type_95148": "Funktionsrückgabetyp ableiten", "Infer_parameter_types_from_usage_95012": "Parametertypen aus der Nutzung ableiten", "Infer_this_type_of_0_from_usage_95080": "Typ \"this\" von \"{0}\" aus Syntax ableiten", "Infer_type_of_0_from_usage_95011": "Typ von \"{0}\" aus der Nutzung ableiten", @@ -814,7 +817,6 @@ "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018": "Oktalliterale sind in einem Mitgliederenumerationsinitialisierer nicht zulässig. Verwenden Sie die Syntax \"{0}\".", "Octal_literals_are_not_allowed_in_strict_mode_1121": "Oktalliterale sind im Strict-Modus unzulässig.", "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085": "Oktalliterale sind bei der Zielgruppenadressierung von ECMAScript 5 und höher nicht verfügbar. Verwenden Sie die Syntax \"{0}\".", - "Only_ECMAScript_imports_may_use_import_type_1370": "Nur ECMAScript-Importe können \"import type\" verwenden.", "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091": "In einer for...in-Anweisung ist nur eine einzige Variablendeklaration zulässig.", "Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement_1188": "In einer for...of-Anweisung ist nur eine einzige Variablendeklaration zulässig.", "Only_a_void_function_can_be_called_with_the_new_keyword_2350": "Nur eine void-Funktion kann mit dem Schlüsselwort \"new\" aufgerufen werden.", @@ -920,9 +922,11 @@ "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202": "Projektverweise dürfen keinen kreisförmigen Graphen bilden. Zyklus erkannt: {0}", "Projects_in_this_build_Colon_0_6355": "Projekte in diesem Build: {0}", "Projects_to_reference_6300": "Zu referenzierende Projekte", + "Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0_4111": "Die Eigenschaft \"{0}\" stammt aus einer Indexsignatur. Der Zugriff muss daher mit [\"{0}\"] erfolgen.", "Property_0_does_not_exist_on_const_enum_1_2479": "Die Eigenschaft \"{0}\" ist für die const-Enumeration \"{1}\" nicht vorhanden.", "Property_0_does_not_exist_on_type_1_2339": "Die Eigenschaft \"{0}\" ist für den Typ \"{1}\" nicht vorhanden.", "Property_0_does_not_exist_on_type_1_Did_you_mean_2_2551": "Die Eigenschaft \"{0}\" existiert nicht für Typ \"{1}\". Meinten Sie \"{2}\"?", + "Property_0_does_not_exist_on_type_1_Did_you_mean_to_access_the_static_member_2_instead_2576": "Die Eigenschaft \"{0}\" ist für den Typ \"{1}\" nicht vorhanden. Möchten Sie stattdessen auf den statischen Member \"{2}\" zugreifen?", "Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_c_2550": "Die Eigenschaft \"{0}\" ist für den Typ \"{1}\" nicht vorhanden. Müssen Sie Ihre Zielbibliothek ändern? Ändern Sie die Compileroption \"lib\" in \"{2}\" oder höher.", "Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor_2564": "Die Eigenschaft \"{0}\" weist keinen Initialisierer auf und ist im Konstruktor nicht definitiv zugewiesen.", "Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation_7033": "Die Eigenschaft \"{0}\" weist implizit den Typ \"any\" auf, weil ihrem get-Accessor eine Parametertypanmerkung fehlt.", @@ -932,7 +936,6 @@ "Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2_2416": "Die Eigenschaft \"{0}\" im Typ \"{1}\" kann nicht der gleichen Eigenschaft in Basistyp \"{2}\" zugewiesen werden.", "Property_0_in_type_1_is_not_assignable_to_type_2_2603": "Die Eigenschaft \"{0}\" im Typ \"{1}\" kann dem Typ \"{2}\" nicht zugewiesen werden.", "Property_0_in_type_1_refers_to_a_different_member_that_cannot_be_accessed_from_within_type_2_18015": "Die Eigenschaft \"{0}\" im Typ \"{1}\" verweist auf einen anderen Member, auf den nicht aus Typ \"{2}\" zugegriffen werden kann.", - "Property_0_is_a_static_member_of_type_1_2576": "Die Eigenschaft \"{0}\" ist ein statischer Member vom Typ \"{1}\".", "Property_0_is_declared_but_its_value_is_never_read_6138": "Die Eigenschaft \"{0}\" ist deklariert, aber ihr Wert wird nie gelesen.", "Property_0_is_incompatible_with_index_signature_2530": "Die Eigenschaft \"{0}\" ist nicht mit der Indexsignatur kompatibel.", "Property_0_is_incompatible_with_rest_element_type_2573": "Die Eigenschaft \"{0}\" ist nicht mit dem rest-Elementtyp kompatibel.", @@ -1007,6 +1010,7 @@ "Report_errors_in_js_files_8019": "Fehler in .js-Dateien melden.", "Report_errors_on_unused_locals_6134": "Fehler für nicht verwendete lokale Variablen melden.", "Report_errors_on_unused_parameters_6135": "Fehler für nicht verwendete Parameter melden.", + "Require_undeclared_properties_from_index_signatures_to_use_element_accesses_6803": "Nicht deklarierte Eigenschaften aus Indexsignaturen müssen Elementzugriffe verwenden.", "Required_type_parameters_may_not_follow_optional_type_parameters_2706": "Erforderliche Typparameter dürfen nicht auf optionale Typparameter folgen.", "Resolution_for_module_0_was_found_in_cache_from_location_1_6147": "Die Auflösung für das Modul \"{0}\" wurde im Cache des Standorts \"{1}\" gefunden.", "Resolve_keyof_to_string_valued_property_names_only_no_numbers_or_symbols_6195": "\"keyof\" darf nur in Eigenschaftennamen mit Zeichenfolgenwert aufgelöst werden (keine Ziffern oder Symbole).", @@ -1146,7 +1150,7 @@ "The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback_1060": "Der erste Parameter der \"then\"-Methode einer Zusage muss ein Rückruf sein.", "The_global_type_JSX_0_may_not_have_more_than_one_property_2608": "Der globale Typ \"JSX.{0}\" darf nur eine Eigenschaft aufweisen.", "The_implementation_signature_is_declared_here_2750": "Die Implementierungssignatur wird hier deklariert.", - "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system_1343": "Die Metaeigenschaft \"import.meta\" ist nur zulässig, wenn die Option \"--module\" den Wert \"esnext\" oder \"system\" aufweist.", + "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_esnext_or_system_1343": "Die Metaeigenschaft \"import.meta\" ist nur zulässig, wenn die Option \"--module\" den Wert \"es2020\", \"esnext\" oder \"system\" aufweist.", "The_inferred_type_of_0_cannot_be_named_without_a_reference_to_1_This_is_likely_not_portable_A_type_a_2742": "Der abgeleitete Typ von \"{0}\" kann nicht ohne einen Verweis auf \"{1}\" benannt werden. Eine Portierung ist wahrscheinlich nicht möglich. Eine Typanmerkung ist erforderlich.", "The_inferred_type_of_0_references_a_type_with_a_cyclic_structure_which_cannot_be_trivially_serialize_5088": "Der abgeleitete Typ von \"{0}\" verweist auf einen Typ mit zyklischer Struktur, die nicht trivial serialisiert werden kann. Es ist eine Typanmerkung erforderlich.", "The_inferred_type_of_0_references_an_inaccessible_1_type_A_type_annotation_is_necessary_2527": "Der abgeleitete Typ von \"{0}\" verweist auf einen Typ \"{1}\", auf den nicht zugegriffen werden kann. Eine Typanmerkung ist erforderlich.", @@ -1216,7 +1220,7 @@ "This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without_6234": "Dieser Ausdruck kann nicht aufgerufen werden, weil es sich um eine get-Zugriffsmethode handelt. Möchten Sie den Wert ohne \"()\" verwenden?", "This_expression_is_not_constructable_2351": "Dieser Ausdruck kann nicht erstellt werden.", "This_file_already_has_a_default_export_95130": "Diese Datei weist bereits einen Standardexport auf.", - "This_import_is_never_used_as_a_value_and_must_use_import_type_because_the_importsNotUsedAsValues_is__1371": "Dieser Import wird nie als Wert verwendet und muss \"import type\" verwenden, weil \"importsNotUsedAsValues\" auf \"error\" festgelegt ist.", + "This_import_is_never_used_as_a_value_and_must_use_import_type_because_importsNotUsedAsValues_is_set__1371": "Dieser Import wird nie als Wert verwendet und muss \"import type\" verwenden, weil \"importsNotUsedAsValues\" auf \"error\" festgelegt ist.", "This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_fil_6233": "Dies ist die erweiterte Deklaration. Die erweiternde Deklaration sollte in dieselbe Datei verschoben werden.", "This_may_be_converted_to_an_async_function_80006": "Es kann eine Konvertierung in ein asynchrone Funktion durchgeführt werden.", "This_module_can_only_be_referenced_with_ECMAScript_imports_Slashexports_by_turning_on_the_0_flag_and_2497": "Auf dieses Modul kann nur mit ECMAScript-Importen/-Exporten verwiesen werden, indem das Flag \"{0}\" aktiviert und auf den Standardexport verwiesen wird.", @@ -1342,6 +1346,8 @@ "Updating_output_of_project_0_6373": "Ausgabe von Projekt \"{0}\" wird aktualisiert...", "Updating_output_timestamps_of_project_0_6359": "Ausgabezeitstempel von Projekt \"{0}\" werden aktualisiert...", "Updating_unchanged_output_timestamps_of_project_0_6371": "Unveränderte Ausgabezeitstempel von Projekt \"{0}\" werden aktualisiert...", + "Use_element_access_for_0_95145": "Elementzugriff für \"{0}\" verwenden", + "Use_element_access_for_all_undeclared_properties_95146": "Elementzugriff für alle nicht deklarierten Eigenschaften verwenden", "Use_synthetic_default_member_95016": "Verwenden Sie den synthetischen Member \"default\".", "Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher_2494": "Das Verwenden einer Zeichenfolge in einer for...of-Anweisung wird nur in ECMAScript 5 oder höher unterstützt.", "Using_compiler_options_of_project_reference_redirect_0_6215": "Compileroptionen der Projektverweisumleitung \"{0}\" werden verwendet.", diff --git a/lib/es/diagnosticMessages.generated.json b/lib/es/diagnosticMessages.generated.json index 469d98901aa1a..3915265e39646 100644 --- a/lib/es/diagnosticMessages.generated.json +++ b/lib/es/diagnosticMessages.generated.json @@ -199,6 +199,7 @@ "An_implementation_cannot_be_declared_in_ambient_contexts_1183": "Una implementación no se puede declarar en contextos de ambiente.", "An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type_1379": "Un alias de importación no puede hacer referencia a una declaración que se exportó mediante \"export type\".", "An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type_1380": "Un alias de importación no puede hacer referencia a una declaración que se importó mediante \"import type\".", + "An_import_alias_cannot_use_import_type_1392": "Un alias de importación no puede usar \"import type\"", "An_import_declaration_can_only_be_used_in_a_namespace_or_module_1232": "Una declaración de importación solo se puede usar en un espacio de nombres o un módulo.", "An_import_declaration_cannot_have_modifiers_1191": "Una declaración de importación no puede tener modificadores.", "An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead_2691": "Una ruta de acceso de importación no puede terminar con una extensión '{0}'. Puede importar '{1}' en su lugar.", @@ -443,6 +444,7 @@ "Default_export_of_the_module_has_or_is_using_private_name_0_4082": "La exportación predeterminada del módulo tiene o usa el nombre privado '{0}'.", "Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0_6200": "Las definiciones de los identificadores siguientes entran en conflicto con las de otro archivo: {0}", "Delete_all_unused_declarations_95024": "Eliminar todas las declaraciones sin usar", + "Delete_all_unused_imports_95147": "Eliminar todas las importaciones sin usar", "Delete_the_outputs_of_all_projects_6365": "Eliminar las salidas de todos los proyectos", "Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react__6084": "[En desuso] Use \"--jsxFactory\" en su lugar. Especifique el objeto invocado para createElement cuando el destino sea la emisión de JSX \"react\"", "Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file_6170": "[En desuso] Use \"--outFile\" en su lugar. Concatena y emite la salida en un solo archivo.", @@ -668,6 +670,7 @@ "Index_signatures_are_incompatible_2330": "Las signaturas de índice no son compatibles.", "Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local_2395": "Las declaraciones individuales de la declaración '{0}' combinada deben ser todas exportadas o todas locales.", "Infer_all_types_from_usage_95023": "Deducir todos los tipos del uso", + "Infer_function_return_type_95148": "Deducir el tipo de valor devuelto de función", "Infer_parameter_types_from_usage_95012": "Deducir los tipos de parámetro del uso", "Infer_this_type_of_0_from_usage_95080": "Inferir el tipo \"this\" de \"{0}\" a partir del uso", "Infer_type_of_0_from_usage_95011": "Deducir el tipo de \"{0}\" del uso", @@ -814,7 +817,6 @@ "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018": "No se permiten literales octales en el inicializador de miembros de enumeraciones. Use la sintaxis \"{0}\".", "Octal_literals_are_not_allowed_in_strict_mode_1121": "Los literales octales no se permiten en modo strict.", "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085": "Los literales octales no están disponibles cuando el destino es ECMAScript 5 y superior. Use la sintaxis \"{0}\".", - "Only_ECMAScript_imports_may_use_import_type_1370": "Solo las importaciones de ECMAScript pueden usar \"import type\".", "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091": "Solo se permite una declaración de variable en una instrucción \"for...in\".", "Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement_1188": "Solo se permite una declaración de variable en una instrucción \"for...of\".", "Only_a_void_function_can_be_called_with_the_new_keyword_2350": "Solo se puede llamar a una función void con la palabra clave \"new\".", @@ -920,9 +922,11 @@ "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202": "Las referencias del proyecto no pueden formar un gráfico circular. Ciclo detectado: {0}", "Projects_in_this_build_Colon_0_6355": "Proyectos de esta compilación: {0}", "Projects_to_reference_6300": "Proyectos a los que se hará referencia", + "Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0_4111": "La propiedad \"{0}\" procede de una signatura de índice, por lo que debe accederse a ella con [\"{0}\"].", "Property_0_does_not_exist_on_const_enum_1_2479": "La propiedad '{0}' no existe en la enumeración 'const' '{1}'.", "Property_0_does_not_exist_on_type_1_2339": "La propiedad '{0}' no existe en el tipo '{1}'.", "Property_0_does_not_exist_on_type_1_Did_you_mean_2_2551": "La propiedad \"{0}\" no existe en el tipo \"{1}\". ¿Quería decir \"{2}\"?", + "Property_0_does_not_exist_on_type_1_Did_you_mean_to_access_the_static_member_2_instead_2576": "La propiedad \"{0}\" no existe en el tipo \"{1}\". ¿Pretendía acceder al miembro estático \"{2}\"?", "Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_c_2550": "No existe la propiedad \"{0}\" en el tipo \"{1}\". ¿Necesita cambiar la biblioteca de destino? Pruebe a cambiar la opción del compilador \"lib\" a \"{2}\" o posterior.", "Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor_2564": "La propiedad \"{0}\" no tiene inicializador y no está asignada de forma definitiva en el constructor.", "Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation_7033": "La propiedad '{0}' tiene el tipo 'any' de forma implícita, porque a su descriptor de acceso get le falta una anotación de tipo de valor devuelto.", @@ -932,7 +936,6 @@ "Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2_2416": "La propiedad \"{0}\" del tipo \"{1}\" no se puede asignar a la misma propiedad del tipo base \"{2}\".", "Property_0_in_type_1_is_not_assignable_to_type_2_2603": "La propiedad \"{0}\" del tipo \"{1}\" no se puede asignar al tipo \"{2}\".", "Property_0_in_type_1_refers_to_a_different_member_that_cannot_be_accessed_from_within_type_2_18015": "La propiedad \"{0}\" del tipo \"{1}\" hace referencia a un miembro distinto al que no se puede acceder desde el tipo \"{2}\".", - "Property_0_is_a_static_member_of_type_1_2576": "La propiedad \"{0}\" es un miembro estático del tipo \"{1}\".", "Property_0_is_declared_but_its_value_is_never_read_6138": "La propiedad \"{0}\" se declara, pero su valor no se lee nunca.", "Property_0_is_incompatible_with_index_signature_2530": "La propiedad '{0}' es incompatible con la signatura de índice.", "Property_0_is_incompatible_with_rest_element_type_2573": "La propiedad \"{0}\" es incompatible con el tipo de elemento rest.", @@ -1007,6 +1010,7 @@ "Report_errors_in_js_files_8019": "Notifique los errores de los archivos .js.", "Report_errors_on_unused_locals_6134": "Informe de errores sobre variables locales no usadas.", "Report_errors_on_unused_parameters_6135": "Informe de errores sobre parámetros no usados.", + "Require_undeclared_properties_from_index_signatures_to_use_element_accesses_6803": "Se requieren propiedades no declaradas de las signaturas de índice para usar los accesos de elemento.", "Required_type_parameters_may_not_follow_optional_type_parameters_2706": "Los parámetros de tipo requeridos pueden no seguir parámetros de tipo opcionales.", "Resolution_for_module_0_was_found_in_cache_from_location_1_6147": "La resolución del módulo \"{0}\" se encontró en la memoria caché de la ubicación \"{1}\".", "Resolve_keyof_to_string_valued_property_names_only_no_numbers_or_symbols_6195": "Resolver \"keyof\" exclusivamente como nombres de propiedad con valores de cadena (sin números ni símbolos).", @@ -1146,7 +1150,7 @@ "The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback_1060": "El primer parámetro del método \"then\" de una promesa debe ser una devolución de llamada.", "The_global_type_JSX_0_may_not_have_more_than_one_property_2608": "El tipo \"JSX.{0}\" global no puede tener más de una propiedad.", "The_implementation_signature_is_declared_here_2750": "La signatura de implementación se declara aquí.", - "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system_1343": "La propiedad Meta \"import.meta\" solo se permite cuando la opción \"--module\" es \"esnext\" o \"system\".", + "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_esnext_or_system_1343": "La propiedad Meta \"import.meta\" solo se permite cuando la opción \"--module\" es \"es2020\", \"esnext\" o \"system\".", "The_inferred_type_of_0_cannot_be_named_without_a_reference_to_1_This_is_likely_not_portable_A_type_a_2742": "No se puede asignar un nombre al tipo inferido de \"{0}\" sin una referencia a \"{1}\". Es probable que no sea portable. Se requiere una anotación de tipo.", "The_inferred_type_of_0_references_a_type_with_a_cyclic_structure_which_cannot_be_trivially_serialize_5088": "El tipo deducido de \"{0}\" hace referencia a un tipo con una estructura cíclica que no se puede serializar trivialmente. Es necesaria una anotación de tipo.", "The_inferred_type_of_0_references_an_inaccessible_1_type_A_type_annotation_is_necessary_2527": "El tipo inferido de \"{0}\" hace referencia a un tipo \"{1}\" no accesible. Se requiere una anotación de tipo.", @@ -1216,7 +1220,7 @@ "This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without_6234": "No se puede llamar a esta expresión porque es un descriptor de acceso \"get\". ¿Pretendía usarlo sin \"()\"?", "This_expression_is_not_constructable_2351": "No se puede construir esta expresión.", "This_file_already_has_a_default_export_95130": "Este archivo ya tiene una exportación predeterminada", - "This_import_is_never_used_as_a_value_and_must_use_import_type_because_the_importsNotUsedAsValues_is__1371": "Esta importación nunca se usa como valor y debe utilizar \"import type\" porque el valor \"importsNotUsedAsValues\" está establecido en \"error\".", + "This_import_is_never_used_as_a_value_and_must_use_import_type_because_importsNotUsedAsValues_is_set__1371": "Esta importación nunca se usa como valor y debe utilizar \"import type\" porque \"importsNotUsedAsValues\" está establecido en \"error\".", "This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_fil_6233": "Esta es la declaración que se está aumentando. Considere la posibilidad de mover la declaración en aumento al mismo archivo.", "This_may_be_converted_to_an_async_function_80006": "Puede convertirse en una función asincrónica.", "This_module_can_only_be_referenced_with_ECMAScript_imports_Slashexports_by_turning_on_the_0_flag_and_2497": "Solo se puede hacer referencia a este módulo con las importaciones o exportaciones de ECMAScript mediante la activación de la marca \"{0}\" y la referencia a su exportación predeterminada.", @@ -1342,6 +1346,8 @@ "Updating_output_of_project_0_6373": "Actualizando la salida del proyecto \"{0}\"...", "Updating_output_timestamps_of_project_0_6359": "Actualizando las marcas de hora de salida del proyecto \"{0}\"...", "Updating_unchanged_output_timestamps_of_project_0_6371": "Actualizando las marcas de hora de salida no modificadas del proyecto \"{0}\"...", + "Use_element_access_for_0_95145": "Usar acceso de elemento para \"{0}\"", + "Use_element_access_for_all_undeclared_properties_95146": "Use el acceso de elemento para todas las propiedades no declaradas.", "Use_synthetic_default_member_95016": "Use el miembro sintético \"default\".", "Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher_2494": "El uso de una cadena en una instrucción \"for...of\" solo se admite en ECMAScript 5 y versiones posteriores.", "Using_compiler_options_of_project_reference_redirect_0_6215": "Uso de las opciones del compilador de redireccionamiento de la referencia del proyecto \"{0}\".", diff --git a/lib/fr/diagnosticMessages.generated.json b/lib/fr/diagnosticMessages.generated.json index 77604a61dba6c..6536e5a33285a 100644 --- a/lib/fr/diagnosticMessages.generated.json +++ b/lib/fr/diagnosticMessages.generated.json @@ -199,6 +199,7 @@ "An_implementation_cannot_be_declared_in_ambient_contexts_1183": "Impossible de déclarer une implémentation dans des contextes ambiants.", "An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type_1379": "Un alias d'importation ne peut pas référencer une déclaration exportée à l'aide de 'export type'.", "An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type_1380": "Un alias d'importation ne peut pas référencer une déclaration importée à l'aide de 'import type'.", + "An_import_alias_cannot_use_import_type_1392": "Un alias d'importation ne peut pas utiliser 'import type'", "An_import_declaration_can_only_be_used_in_a_namespace_or_module_1232": "Une déclaration d'importation peut uniquement être utilisée dans un espace de noms ou un module.", "An_import_declaration_cannot_have_modifiers_1191": "Une déclaration d'importation ne peut pas avoir de modificateurs.", "An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead_2691": "Un chemin d'importation ne peut pas finir par une extension '{0}'. Importez '{1}' à la place.", @@ -443,6 +444,7 @@ "Default_export_of_the_module_has_or_is_using_private_name_0_4082": "L'exportation par défaut du module a utilisé ou utilise le nom privé '{0}'.", "Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0_6200": "Les définitions des identificateurs suivants sont en conflit avec celles d'un autre fichier : {0}", "Delete_all_unused_declarations_95024": "Supprimer toutes les déclarations inutilisées", + "Delete_all_unused_imports_95147": "Supprimer toutes les importations inutilisées", "Delete_the_outputs_of_all_projects_6365": "Supprimer les sorties de tous les projets", "Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react__6084": "[Déconseillé] Utilisez '--jsxFactory' à la place. Permet de spécifier l'objet appelé pour createElement durant le ciblage de 'react' pour l'émission JSX", "Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file_6170": "[Déconseillé] Utilisez '--outFile' à la place. Permet de concaténer et d'émettre la sortie vers un seul fichier", @@ -668,6 +670,7 @@ "Index_signatures_are_incompatible_2330": "Les signatures d'index sont incompatibles.", "Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local_2395": "Les déclarations individuelles de la déclaration fusionnée '{0}' doivent toutes être exportées ou locales.", "Infer_all_types_from_usage_95023": "Déduire tous les types de l'utilisation", + "Infer_function_return_type_95148": "Déduire le type de retour de la fonction", "Infer_parameter_types_from_usage_95012": "Déduire les types des paramètres à partir de l'utilisation", "Infer_this_type_of_0_from_usage_95080": "Déduire le type 'this' de '{0}' à partir de l'utilisation", "Infer_type_of_0_from_usage_95011": "Déduire le type de '{0}' à partir de l'utilisation", @@ -814,7 +817,6 @@ "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018": "Les littéraux octaux ne sont pas autorisés dans l'initialiseur des membres d'enums. Utilisez la syntaxe '{0}'.", "Octal_literals_are_not_allowed_in_strict_mode_1121": "Les littéraux octaux ne sont pas autorisés en mode strict.", "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085": "Les littéraux octaux ne sont pas disponibles lorsque vous ciblez ECMAScript 5 et ultérieur. Utilisez la syntaxe '{0}'.", - "Only_ECMAScript_imports_may_use_import_type_1370": "Seules les importations ECMAScript peuvent utiliser 'import type'.", "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091": "Une seule déclaration de variable est autorisée dans une instruction 'for...in'.", "Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement_1188": "Seule une déclaration de variable unique est autorisée dans une instruction 'for...of'.", "Only_a_void_function_can_be_called_with_the_new_keyword_2350": "Seule une fonction void peut être appelée avec le mot clé 'new'.", @@ -920,9 +922,11 @@ "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202": "Les références de projet ne peuvent pas former un graphe circulaire. Cycle détecté : {0}", "Projects_in_this_build_Colon_0_6355": "Projets dans cette build : {0}", "Projects_to_reference_6300": "Projets à référencer", + "Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0_4111": "La propriété '{0}' est issue d'une signature d'index, elle doit donc faire l'objet d'un accès avec ['{0}'].", "Property_0_does_not_exist_on_const_enum_1_2479": "La propriété '{0}' n'existe pas sur l'enum 'const' '{1}'.", "Property_0_does_not_exist_on_type_1_2339": "La propriété '{0}' n'existe pas sur le type '{1}'.", "Property_0_does_not_exist_on_type_1_Did_you_mean_2_2551": "La propriété '{0}' n'existe pas sur le type '{1}'. Est-ce qu'il ne s'agit pas plutôt de '{2}' ?", + "Property_0_does_not_exist_on_type_1_Did_you_mean_to_access_the_static_member_2_instead_2576": "La propriété '{0}' n'existe pas sur le type '{1}'. Ne vouliez-vous pas plutôt accéder au membre statique '{2}' ?", "Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_c_2550": "La propriété '{0}' n'existe pas sur le type '{1}'. Devez-vous changer votre bibliothèque cible ? Essayez de changer l'option de compilateur 'lib' en '{2}' ou une version ultérieure.", "Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor_2564": "La propriété '{0}' n'a aucun initialiseur et n'est pas définitivement assignée dans le constructeur.", "Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation_7033": "La propriété '{0}' a implicitement le type 'any', car son accesseur get ne dispose pas d'une annotation de type de retour.", @@ -932,7 +936,6 @@ "Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2_2416": "Impossible d'assigner la propriété '{0}' du type '{1}' à la même propriété du type de base '{2}'.", "Property_0_in_type_1_is_not_assignable_to_type_2_2603": "La propriété '{0}' du type '{1}' ne peut pas être assignée au type '{2}'.", "Property_0_in_type_1_refers_to_a_different_member_that_cannot_be_accessed_from_within_type_2_18015": "La propriété '{0}' du type '{1}' fait référence à un membre distinct, qui n'est pas accessible à partir du type '{2}'.", - "Property_0_is_a_static_member_of_type_1_2576": "La propriété '{0}' est un membre statique de type '{1}'.", "Property_0_is_declared_but_its_value_is_never_read_6138": "La propriété '{0}' est déclarée mais sa valeur n'est jamais lue.", "Property_0_is_incompatible_with_index_signature_2530": "La propriété '{0}' est incompatible avec la signature d'index.", "Property_0_is_incompatible_with_rest_element_type_2573": "La propriété '{0}' est incompatible avec le type d'élément rest.", @@ -1007,6 +1010,7 @@ "Report_errors_in_js_files_8019": "Signalez les erreurs dans les fichiers .js.", "Report_errors_on_unused_locals_6134": "Signaler les erreurs sur les variables locales inutilisées.", "Report_errors_on_unused_parameters_6135": "Signaler les erreurs sur les paramètres inutilisés.", + "Require_undeclared_properties_from_index_signatures_to_use_element_accesses_6803": "Les propriétés non déclarées sont imposées à partir des signatures d'index pour permettre l'utilisation des accès aux éléments.", "Required_type_parameters_may_not_follow_optional_type_parameters_2706": "Les paramètres de type obligatoires ne peuvent pas être placés à la suite des paramètres de type optionnels.", "Resolution_for_module_0_was_found_in_cache_from_location_1_6147": "La résolution du module '{0}' a été trouvée dans le cache à l'emplacement '{1}'.", "Resolve_keyof_to_string_valued_property_names_only_no_numbers_or_symbols_6195": "Résoudre 'keyof' en noms de propriétés de valeur chaîne uniquement (aucun nombre ou symbole).", @@ -1216,7 +1220,7 @@ "This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without_6234": "Impossible d'appeler cette expression, car il s'agit d'un accesseur 'get'. Voulez-vous vraiment l'utiliser sans '()' ?", "This_expression_is_not_constructable_2351": "Impossible de construire cette expression.", "This_file_already_has_a_default_export_95130": "Ce fichier a déjà une exportation par défaut", - "This_import_is_never_used_as_a_value_and_must_use_import_type_because_the_importsNotUsedAsValues_is__1371": "Cette importation n'est jamais utilisée en tant que valeur. Elle doit utiliser 'import type', car 'importsNotUsedAsValues' a la valeur 'error'.", + "This_import_is_never_used_as_a_value_and_must_use_import_type_because_importsNotUsedAsValues_is_set__1371": "Cette importation n'est jamais utilisée en tant que valeur. Elle doit utiliser 'import type', car 'importsNotUsedAsValues' a la valeur 'error'.", "This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_fil_6233": "Ceci est la déclaration augmentée. Pensez à déplacer la déclaration d'augmentation dans le même fichier.", "This_may_be_converted_to_an_async_function_80006": "Ceci peut être converti en fonction asynchrone.", "This_module_can_only_be_referenced_with_ECMAScript_imports_Slashexports_by_turning_on_the_0_flag_and_2497": "Vous pouvez référencer ce module uniquement avec les importations/exportations ECMAScript en activant l'indicateur '{0}' et en référençant son exportation par défaut.", @@ -1342,6 +1346,8 @@ "Updating_output_of_project_0_6373": "Mise à jour de la sortie du projet '{0}'...", "Updating_output_timestamps_of_project_0_6359": "Mise à jour des horodatages de sortie du projet '{0}'...", "Updating_unchanged_output_timestamps_of_project_0_6371": "Mise à jour des horodatages de sortie inchangés du projet '{0}'...", + "Use_element_access_for_0_95145": "Utiliser l'accès à l'élément pour '{0}'", + "Use_element_access_for_all_undeclared_properties_95146": "L'accès à l'élément est utilisé pour toutes les propriétés non déclarées.", "Use_synthetic_default_member_95016": "Utilisez un membre 'default' synthétique.", "Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher_2494": "L'utilisation d'une chaîne dans une instruction 'for...of' est prise en charge uniquement dans ECMAScript 5 et version supérieure.", "Using_compiler_options_of_project_reference_redirect_0_6215": "Utilisation des options de compilateur de la redirection de référence de projet : '{0}'.", diff --git a/lib/it/diagnosticMessages.generated.json b/lib/it/diagnosticMessages.generated.json index 4b2f431dca499..89f966406732e 100644 --- a/lib/it/diagnosticMessages.generated.json +++ b/lib/it/diagnosticMessages.generated.json @@ -199,6 +199,7 @@ "An_implementation_cannot_be_declared_in_ambient_contexts_1183": "Non è possibile dichiarare un'implementazione in contesti di ambiente.", "An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type_1379": "Un alias di importazione non può fare riferimento a una dichiarazione esportata con 'export type'.", "An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type_1380": "Un alias di importazione non può fare riferimento a una dichiarazione importata con 'import type'.", + "An_import_alias_cannot_use_import_type_1392": "Un alias di importazione non può usare 'import type'", "An_import_declaration_can_only_be_used_in_a_namespace_or_module_1232": "È possibile usare una dichiarazione di importazione solo in uno spazio dei nomi o in un modulo.", "An_import_declaration_cannot_have_modifiers_1191": "Una dichiarazione di importazione non può contenere modificatori.", "An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead_2691": "Un percorso di importazione non può terminare con l'estensione '{0}'. In alternativa, provare a importare '{1}'.", @@ -443,6 +444,7 @@ "Default_export_of_the_module_has_or_is_using_private_name_0_4082": "L'esportazione predefinita del modulo contiene o usa il nome privato '{0}'.", "Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0_6200": "Le definizioni degli identificatori seguenti sono in conflitto con quelle di un altro file: {0}", "Delete_all_unused_declarations_95024": "Eliminare tutte le dichiarazioni non usate", + "Delete_all_unused_imports_95147": "Eliminare tutte le direttive import non usate", "Delete_the_outputs_of_all_projects_6365": "Eliminare gli output di tutti i progetti", "Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react__6084": "[Deprecata] In alternativa, usare '--jsxFactory'. Specifica l'oggetto richiamato per createElement quando la destinazione è la creazione JSX 'react'", "Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file_6170": "[Deprecata] In alternativa, usare '--outFile'. Concatena e crea l'output in un singolo file", @@ -668,6 +670,7 @@ "Index_signatures_are_incompatible_2330": "Le firme dell'indice sono incompatibili.", "Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local_2395": "Le singole dichiarazioni della dichiarazione sottoposta a merge '{0}' devono essere tutte esportate o tutte locali.", "Infer_all_types_from_usage_95023": "Derivare tutti i tipi dall'utilizzo", + "Infer_function_return_type_95148": "Dedurre il tipo restituito della funzione", "Infer_parameter_types_from_usage_95012": "Derivare i tipi di parametro dall'utilizzo", "Infer_this_type_of_0_from_usage_95080": "Derivare il tipo 'this' di '{0}' dall'utilizzo", "Infer_type_of_0_from_usage_95011": "Derivare il tipo di '{0}' dall'utilizzo", @@ -814,7 +817,6 @@ "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018": "I valori letterali ottali non sono consentiti nell'inizializzatore di membri di enumerazioni. Usare la sintassi '{0}'.", "Octal_literals_are_not_allowed_in_strict_mode_1121": "I valori letterali ottali non sono consentiti in modalità strict.", "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085": "I valori letterali ottali non sono disponibili quando la destinazione è ECMAScript 5 e versioni successive. Usare la sintassi '{0}'.", - "Only_ECMAScript_imports_may_use_import_type_1370": "Solo le importazioni ECMAScript possono usare 'import type'.", "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091": "In un'istruzione 'for...in' è consentita solo una singola dichiarazione di variabile.", "Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement_1188": "In un'istruzione 'for...of' è consentita solo una singola dichiarazione di variabile.", "Only_a_void_function_can_be_called_with_the_new_keyword_2350": "Con la parola chiave 'new' può essere chiamata solo una funzione void.", @@ -920,9 +922,11 @@ "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202": "I riferimenti al progetto non possono formare un grafico circolare. Ciclo rilevato: {0}", "Projects_in_this_build_Colon_0_6355": "Progetti in questa compilazione: {0}", "Projects_to_reference_6300": "Progetti cui fare riferimento", + "Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0_4111": "La proprietà '{0}' deriva da una firma dell'indice, quindi è necessario accedervi con ['{0}'].", "Property_0_does_not_exist_on_const_enum_1_2479": "La proprietà '{0}' non esiste nell'enumerazione 'const' '{1}'.", "Property_0_does_not_exist_on_type_1_2339": "La proprietà '{0}' non esiste nel tipo '{1}'.", "Property_0_does_not_exist_on_type_1_Did_you_mean_2_2551": "La proprietà '{0}' non esiste nel tipo '{1}'. Si intendeva '{2}'?", + "Property_0_does_not_exist_on_type_1_Did_you_mean_to_access_the_static_member_2_instead_2576": "La proprietà '{0}' non esiste nel tipo '{1}'. Si intendeva accedere al membro statico '{2}'?", "Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_c_2550": "La proprietà '{0}' non esiste nel tipo '{1}'. È necessario modificare la libreria di destinazione? Provare a impostare l'opzione `lib` del compilatore su '{2}' o versioni successive.", "Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor_2564": "La proprietà '{0}' non include alcun inizializzatore e non viene assolutamente assegnata nel costruttore.", "Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation_7033": "La proprietà '{0}' contiene implicitamente il tipo 'any', perché nella relativa funzione di accesso get manca un'annotazione di tipo restituito.", @@ -932,7 +936,6 @@ "Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2_2416": "La proprietà '{0}' nel tipo '{1}' non è assegnabile alla stessa proprietà nel tipo di base '{2}'.", "Property_0_in_type_1_is_not_assignable_to_type_2_2603": "La proprietà '{0}' nel tipo '{1}' non è assegnabile al tipo '{2}'.", "Property_0_in_type_1_refers_to_a_different_member_that_cannot_be_accessed_from_within_type_2_18015": "La proprietà '{0}' nel tipo '{1}' fa riferimento a un membro diverso a cui non è possibile accedere dall'interno del tipo '{2}'.", - "Property_0_is_a_static_member_of_type_1_2576": "La proprietà '{0}' è un membro statico di tipo '{1}'.", "Property_0_is_declared_but_its_value_is_never_read_6138": "La proprietà '{0}' è dichiarata, ma il suo valore non viene mai letto.", "Property_0_is_incompatible_with_index_signature_2530": "La proprietà '{0}' non è compatibile con la firma dell'indice.", "Property_0_is_incompatible_with_rest_element_type_2573": "La proprietà '{0}' non è compatibile con il tipo di elemento rest.", @@ -1007,6 +1010,7 @@ "Report_errors_in_js_files_8019": "Segnala gli errori presenti nei file con estensione js.", "Report_errors_on_unused_locals_6134": "Segnala errori relativi a variabili locali non usate.", "Report_errors_on_unused_parameters_6135": "Segnala errori relativi a parametri non usati.", + "Require_undeclared_properties_from_index_signatures_to_use_element_accesses_6803": "Richiedere alle proprietà non dichiarate da firme dell'indice di usare gli accessi agli elementi.", "Required_type_parameters_may_not_follow_optional_type_parameters_2706": "I parametri di tipo obbligatori potrebbero non seguire i parametri di tipo facoltativi.", "Resolution_for_module_0_was_found_in_cache_from_location_1_6147": "La risoluzione per il modulo '{0}' è stata trovata nella cache dal percorso '{1}'.", "Resolve_keyof_to_string_valued_property_names_only_no_numbers_or_symbols_6195": "Risolvere 'keyof' solo in nomi di proprietà con valori stringa (senza numeri o simboli).", @@ -1146,7 +1150,7 @@ "The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback_1060": "Il primo parametro del metodo 'then' di una promessa deve essere un callback.", "The_global_type_JSX_0_may_not_have_more_than_one_property_2608": "Il tipo globale 'JSX.{0}' non può contenere più di una proprietà.", "The_implementation_signature_is_declared_here_2750": "In questo punto viene dichiarata la firma di implementazione.", - "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system_1343": "La metaproprietà 'import.meta' è consentita solo se l'opzione '--module' è impostata su 'esnext' o 'system'.", + "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_esnext_or_system_1343": "La metaproprietà 'import.meta' è consentita solo se l'opzione '--module' è impostata su 'es2020', 'esnext' o 'system'.", "The_inferred_type_of_0_cannot_be_named_without_a_reference_to_1_This_is_likely_not_portable_A_type_a_2742": "Non è possibile assegnare un nome al tipo derivato di '{0}' senza un riferimento a '{1}'. È probabile che non sia portabile. È necessaria un'annotazione di tipo.", "The_inferred_type_of_0_references_a_type_with_a_cyclic_structure_which_cannot_be_trivially_serialize_5088": "Il tipo dedotto di '{0}' fa riferimento a un tipo con una struttura ciclica che non può essere facilmente serializzata. È necessaria un'annotazione di tipo.", "The_inferred_type_of_0_references_an_inaccessible_1_type_A_type_annotation_is_necessary_2527": "Il tipo dedotto di '{0}' fa riferimento a un tipo '{1}' non accessibile. È necessaria un'annotazione di tipo.", @@ -1216,7 +1220,7 @@ "This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without_6234": "Non è possibile chiamare questa espressione perché è una funzione di accesso 'get'. Si intendeva usarla senza '()'?", "This_expression_is_not_constructable_2351": "Questa espressione non può essere costruita.", "This_file_already_has_a_default_export_95130": "Per questo file esiste già un'esportazione predefinita", - "This_import_is_never_used_as_a_value_and_must_use_import_type_because_the_importsNotUsedAsValues_is__1371": "Questa importazione non viene mai usata come valore e deve usare 'import type' perché 'importsNotUsedAsValues' è impostato su 'error'.", + "This_import_is_never_used_as_a_value_and_must_use_import_type_because_importsNotUsedAsValues_is_set__1371": "Questa importazione non viene mai usata come valore e deve usare 'import type' perché 'importsNotUsedAsValues' è impostato su 'error'.", "This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_fil_6233": "Questa è la dichiarazione che verrà aumentata. Provare a spostare la dichiarazione che causa l'aumento nello stesso file.", "This_may_be_converted_to_an_async_function_80006": "Può essere convertita in una funzione asincrona.", "This_module_can_only_be_referenced_with_ECMAScript_imports_Slashexports_by_turning_on_the_0_flag_and_2497": "È possibile fare riferimento a questo modulo solo con importazioni/esportazioni ECMAScript attivando il flag '{0}' e facendo riferimento alla relativa esportazione predefinita.", @@ -1342,6 +1346,8 @@ "Updating_output_of_project_0_6373": "Aggiornamento dell'output del progetto '{0}'...", "Updating_output_timestamps_of_project_0_6359": "Aggiornamento dei timestamp di output del progetto '{0}'...", "Updating_unchanged_output_timestamps_of_project_0_6371": "Aggiornamento dei timestamp di output non modificati del progetto '{0}'...", + "Use_element_access_for_0_95145": "Usare l'accesso agli elementi per '{0}'", + "Use_element_access_for_all_undeclared_properties_95146": "Usare l'accesso agli elementi per tutte le proprietà non dichiarate.", "Use_synthetic_default_member_95016": "Usare il membro 'default' sintetico.", "Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher_2494": "L'uso di una stringa in un'istruzione 'for...of' è supportato solo in ECMAScript 5 e versioni successive.", "Using_compiler_options_of_project_reference_redirect_0_6215": "Using compiler options of project reference redirect '{0}'.", diff --git a/lib/ja/diagnosticMessages.generated.json b/lib/ja/diagnosticMessages.generated.json index 9298ae520578a..d000046af107e 100644 --- a/lib/ja/diagnosticMessages.generated.json +++ b/lib/ja/diagnosticMessages.generated.json @@ -199,6 +199,7 @@ "An_implementation_cannot_be_declared_in_ambient_contexts_1183": "実装は環境コンテキストでは宣言できません。", "An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type_1379": "インポート エイリアスは、'export type' を使用してエクスポートされた宣言を参照できません。", "An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type_1380": "インポート エイリアスは、'import type' を使用してインポートされた宣言を参照できません。", + "An_import_alias_cannot_use_import_type_1392": "インポート エイリアスで 'import type' を使用することはできません", "An_import_declaration_can_only_be_used_in_a_namespace_or_module_1232": "インポート宣言は名前空間またはモジュールでのみ使用可能です。", "An_import_declaration_cannot_have_modifiers_1191": "インポート宣言に修飾子を指定することはできません。", "An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead_2691": "インポート パスの末尾を拡張子 '{0}' にすることはできません。代わりに '{1}' のインポートをご検討ください。", @@ -443,6 +444,7 @@ "Default_export_of_the_module_has_or_is_using_private_name_0_4082": "モジュールの既定エクスポートがプライベート名 '{0}' を持っているか、使用しています。", "Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0_6200": "次の識別子の定義が、別のファイル内の定義と競合しています: {0}", "Delete_all_unused_declarations_95024": "未使用の宣言をすべて削除します", + "Delete_all_unused_imports_95147": "未使用の import をすべて削除します", "Delete_the_outputs_of_all_projects_6365": "すべてのプロジェクトの出力を削除します", "Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react__6084": "[非推奨] 代わりに '--jsxFactory' を使います。'react' JSX 発行を対象とするときに、createElement に対して呼び出されたオブジェクトを指定します", "Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file_6170": "[非推奨] 代わりに '--outFile' を使います。出力を連結して 1 つのファイルを生成します", @@ -668,6 +670,7 @@ "Index_signatures_are_incompatible_2330": "インデックスの署名に互換性がありません。", "Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local_2395": "マージされた宣言 '{0}' の個々の宣言はすべてエクスポートされるか、すべてローカルであるかのどちらかである必要があります。", "Infer_all_types_from_usage_95023": "使用法からすべての型を推論します", + "Infer_function_return_type_95148": "関数の戻り値の型を推論します", "Infer_parameter_types_from_usage_95012": "使用状況からパラメーターの型を推論する", "Infer_this_type_of_0_from_usage_95080": "使い方から '{0}' の 'this' 型を推論する", "Infer_type_of_0_from_usage_95011": "使用状況から '{0}' の型を推論する", @@ -814,7 +817,6 @@ "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018": "8 進数のリテラルは、列挙型メンバーの初期化子では許可されていません。構文 '{0}' を使用してください。", "Octal_literals_are_not_allowed_in_strict_mode_1121": "厳格モードでは Octal リテラルは使用できません。", "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085": "ECMAScript 5 以降を対象にする場合、8 進数のリテラルは使用できません。構文 '{0}' を使用してください。", - "Only_ECMAScript_imports_may_use_import_type_1370": "'import type' を使用できるのは、ECMAScript のインポートのみです。", "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091": "'for...in' ステートメントで使用できる変数宣言は 1 つのみです。", "Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement_1188": "'for...of' ステートメントで使用できる変数宣言は 1 つのみです。", "Only_a_void_function_can_be_called_with_the_new_keyword_2350": "'new' キーワードを指定して呼び出せるのは void 関数のみです。", @@ -920,9 +922,11 @@ "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202": "プロジェクト参照が円グラフを形成できません。循環が検出されました: {0}", "Projects_in_this_build_Colon_0_6355": "このビルドのプロジェクト: {0}", "Projects_to_reference_6300": "参照するプロジェクト", + "Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0_4111": "プロパティ '{0}' はインデックス シグネチャに基づいているため、['{0}'] を使用してアクセスする必要があります。", "Property_0_does_not_exist_on_const_enum_1_2479": "プロパティ '{0}' が 'const' 列挙型 '{1}' に存在しません。", "Property_0_does_not_exist_on_type_1_2339": "プロパティ '{0}' は型 '{1}' に存在しません。", "Property_0_does_not_exist_on_type_1_Did_you_mean_2_2551": "プロパティ '{0}' は型 '{1}' に存在していません。'{2}' ですか?", + "Property_0_does_not_exist_on_type_1_Did_you_mean_to_access_the_static_member_2_instead_2576": "プロパティ '{0}' は型 '{1}' には存在しません。代わりに静的メンバー '{2}' にアクセスしようとしていましたか?", "Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_c_2550": "プロパティ '{0}' が型 '{1}' に存在しません。ターゲット ライブラリを変更する必要がありますか? 'lib' コンパイラ オプションを '{2}' 以降に変更してみてください。", "Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor_2564": "プロパティ '{0}' に初期化子がなく、コンストラクターで明確に割り当てられていません。", "Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation_7033": "プロパティ '{0}' には型 'any' が暗黙的に設定されています。get アクセサーには戻り値の型の注釈がないためです。", @@ -932,7 +936,6 @@ "Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2_2416": "型 '{1}' のプロパティ '{0}' を基本データ型 '{2}' の同じプロパティに割り当てることはできません。", "Property_0_in_type_1_is_not_assignable_to_type_2_2603": "型 '{1}' のプロパティ '{0}' を型 '{2}' に割り当てることはできません。", "Property_0_in_type_1_refers_to_a_different_member_that_cannot_be_accessed_from_within_type_2_18015": "型 '{1}' のプロパティ '{0}' は、型 '{2}' 内からアクセスできない別のメンバーを参照しています。", - "Property_0_is_a_static_member_of_type_1_2576": "プロパティ '{0}' は型 '{1}' の静的メンバーです。", "Property_0_is_declared_but_its_value_is_never_read_6138": "プロパティ '{0}' が宣言されていますが、その値が読み取られることはありません。", "Property_0_is_incompatible_with_index_signature_2530": "プロパティ '{0}' はインデックス シグネチャと互換性がありません。", "Property_0_is_incompatible_with_rest_element_type_2573": "プロパティ '{0}' は rest 要素の型と互換性がありません。", @@ -1007,6 +1010,7 @@ "Report_errors_in_js_files_8019": ".js ファイルのエラーを報告します。", "Report_errors_on_unused_locals_6134": "使用されていないローカルに関するエラーを報告します。", "Report_errors_on_unused_parameters_6135": "使用されていないパラメーターに関するエラーを報告します。", + "Require_undeclared_properties_from_index_signatures_to_use_element_accesses_6803": "要素アクセスを使用するには、インデックス シグネチャからの宣言されていないプロパティが必要です。", "Required_type_parameters_may_not_follow_optional_type_parameters_2706": "必須の型パラメーターの後に、オプションの型パラメーターを続けることはできません。", "Resolution_for_module_0_was_found_in_cache_from_location_1_6147": "モジュール '{0}' の解決が場所 '{1}' のキャッシュに見つかりました。", "Resolve_keyof_to_string_valued_property_names_only_no_numbers_or_symbols_6195": "'keyof' を文字列値のプロパティ名のみに解決します (数字または記号なし)。", @@ -1146,7 +1150,7 @@ "The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback_1060": "Promise では、'then' メソッドの最初のパラメーターはコールバックでなければなりません。", "The_global_type_JSX_0_may_not_have_more_than_one_property_2608": "グローバル型 'JSX.{0}' には複数のプロパティが含まれていない可能性があります。", "The_implementation_signature_is_declared_here_2750": "実装シグネチャはここで宣言されています。", - "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system_1343": "'import.meta' メタプロパティは、'--module' オプションが 'esnext' または 'system' の場合にのみ許可されます。", + "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_esnext_or_system_1343": "'import.meta' メタプロパティは、'--module' オプションが 'es2020'、'esnext'、または 'system' の場合にのみ許可されます。", "The_inferred_type_of_0_cannot_be_named_without_a_reference_to_1_This_is_likely_not_portable_A_type_a_2742": "'{0}' の推論された型には、'{1}' への参照なしで名前を付けることはできません。これは、移植性がない可能性があります。型の注釈が必要です。", "The_inferred_type_of_0_references_a_type_with_a_cyclic_structure_which_cannot_be_trivially_serialize_5088": "'{0}' の推論された型は、循環構造を持つ型を参照しています。この型のシリアル化は自明ではありません。型の注釈が必要です。", "The_inferred_type_of_0_references_an_inaccessible_1_type_A_type_annotation_is_necessary_2527": "'{0}' の推定型はアクセス不可能な '{1}' 型を参照します。型の注釈が必要です。", @@ -1216,7 +1220,7 @@ "This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without_6234": "この式は 'get' アクセサーであるため、呼び出すことができません。'()' なしで使用しますか?", "This_expression_is_not_constructable_2351": "この式はコンストラクト可能ではありません。", "This_file_already_has_a_default_export_95130": "このファイルには、既に既定のエクスポートがあります", - "This_import_is_never_used_as_a_value_and_must_use_import_type_because_the_importsNotUsedAsValues_is__1371": "このインポートは値として使用されることはありません。'importsNotUsedAsValues' が 'error' に設定されているため、'import type' を使用する必要があります。", + "This_import_is_never_used_as_a_value_and_must_use_import_type_because_importsNotUsedAsValues_is_set__1371": "このインポートは値として使用されることはありません。'importsNotUsedAsValues' が 'error' に設定されているため、'import type' を使用する必要があります。", "This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_fil_6233": "これは拡張される宣言です。拡張する側の宣言を同じファイルに移動することを検討してください。", "This_may_be_converted_to_an_async_function_80006": "これは非同期関数に変換できます。", "This_module_can_only_be_referenced_with_ECMAScript_imports_Slashexports_by_turning_on_the_0_flag_and_2497": "このモジュールは、'{0}' フラグをオンにして既定のエクスポートを参照することにより、ECMAScript のインポートまたはエクスポートのみを使用して参照できます。", @@ -1342,6 +1346,8 @@ "Updating_output_of_project_0_6373": "プロジェクト '{0}' の出力を更新しています...", "Updating_output_timestamps_of_project_0_6359": "プロジェクト '{0}' の出力タイムスタンプを更新しています...", "Updating_unchanged_output_timestamps_of_project_0_6371": "プロジェクト '{0}' の変更されていない出力タイムスタンプを更新しています...", + "Use_element_access_for_0_95145": "'{0}' に要素アクセスを使用する", + "Use_element_access_for_all_undeclared_properties_95146": "宣言されていないすべてのプロパティに対して要素アクセスを使用します。", "Use_synthetic_default_member_95016": "合成 'default' メンバーを使用します。", "Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher_2494": "'for...of' ステートメントでの文字列の使用は ECMAScript 5 以上でのみサポートされています。", "Using_compiler_options_of_project_reference_redirect_0_6215": "Using compiler options of project reference redirect '{0}'.", diff --git a/lib/ko/diagnosticMessages.generated.json b/lib/ko/diagnosticMessages.generated.json index afb5401daf690..6012dd7d2dc87 100644 --- a/lib/ko/diagnosticMessages.generated.json +++ b/lib/ko/diagnosticMessages.generated.json @@ -199,6 +199,7 @@ "An_implementation_cannot_be_declared_in_ambient_contexts_1183": "앰비언트 컨텍스트에서는 구현을 선언할 수 없습니다.", "An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type_1379": "가져오기 별칭은 '내보내기 형식'을 사용하여 내보낸 선언을 참조할 수 없습니다.", "An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type_1380": "가져오기 별칭은 '가져오기 형식'을 사용하여 가져온 선언을 참조할 수 없습니다.", + "An_import_alias_cannot_use_import_type_1392": "가져오기 별칭은 'import type'을 사용할 수 없습니다.", "An_import_declaration_can_only_be_used_in_a_namespace_or_module_1232": "내보내기 선언은 네임스페이스 또는 모듈에서만 사용할 수 있습니다.", "An_import_declaration_cannot_have_modifiers_1191": "가져오기 선언에는 한정자를 사용할 수 없습니다.", "An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead_2691": "가져오기 경로는 '{0}' 확장으로 끝날 수 없습니다. 대신 '{1}' 가져오기를 고려하세요.", @@ -443,6 +444,7 @@ "Default_export_of_the_module_has_or_is_using_private_name_0_4082": "모듈의 기본 내보내기에서 프라이빗 이름 '{0}'을(를) 가지고 있거나 사용 중입니다.", "Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0_6200": "{0} 식별자의 정의가 다른 파일의 정의와 충돌합니다.", "Delete_all_unused_declarations_95024": "사용하지 않는 선언 모두 삭제", + "Delete_all_unused_imports_95147": "사용하지 않는 가져오기 모두 삭제", "Delete_the_outputs_of_all_projects_6365": "모든 프로젝트의 출력 삭제", "Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react__6084": "[사용되지 않음] 대신 '--jsxFactory'를 사용합니다. 'react' JSX 내보내기를 대상으로 할 경우 createElement에 대해 호출되는 개체를 지정합니다.", "Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file_6170": "[사용되지 않음] 대신 '--outFile'을 사용합니다. 출력을 연결하고 단일 파일로 내보냅니다.", @@ -668,6 +670,7 @@ "Index_signatures_are_incompatible_2330": "인덱스 시그니처가 호환되지 않습니다.", "Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local_2395": "병합된 선언 '{0}'의 개별 선언은 모두 내보내 졌거나 모두 로컬이어야 합니다.", "Infer_all_types_from_usage_95023": "사용량에서 모든 형식 유추", + "Infer_function_return_type_95148": "함수 반환 형식 유추", "Infer_parameter_types_from_usage_95012": "사용량에서 매개 변수 형식 유추", "Infer_this_type_of_0_from_usage_95080": "사용량에서 '{0}'의 'this' 형식 유추", "Infer_type_of_0_from_usage_95011": "사용량에서 '{0}'의 형식 유추", @@ -814,7 +817,6 @@ "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018": "8진수 리터럴은 열거형 멤버 이니셜라이저에서 사용할 수 없습니다. '{0}' 구문을 사용하세요.", "Octal_literals_are_not_allowed_in_strict_mode_1121": "strict 모드에서는 8진수 리터럴이 허용되지 않습니다.", "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085": "ECMAScript 5 이상을 대상으로 하는 경우 8진수 리터럴을 사용할 수 없습니다. '{0}' 구문을 사용하세요.", - "Only_ECMAScript_imports_may_use_import_type_1370": "ECMAScript 가져오기만 'import type'을 사용할 수 있습니다.", "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091": "'for...in' 문에는 단일 변수 선언만 허용됩니다.", "Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement_1188": "'for...of' 문에는 단일 변수 선언만 허용됩니다.", "Only_a_void_function_can_be_called_with_the_new_keyword_2350": "void 함수만 'new' 키워드로 호출할 수 있습니다.", @@ -920,9 +922,11 @@ "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202": "프로젝트 참조는 순환 그래프를 형성할 수 없습니다. 순환이 발견되었습니다. {0}", "Projects_in_this_build_Colon_0_6355": "이 빌드의 프로젝트: {0}", "Projects_to_reference_6300": "참조할 프로젝트", + "Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0_4111": "'{0}' 속성은 인덱스 시그니처에서 가져오는 것이므로 ['{0}']을(를) 사용하여 액세스해야 합니다.", "Property_0_does_not_exist_on_const_enum_1_2479": "'const' 열거형 '{1}'에 '{0}' 속성이 없습니다.", "Property_0_does_not_exist_on_type_1_2339": "'{1}' 형식에 '{0}' 속성이 없습니다.", "Property_0_does_not_exist_on_type_1_Did_you_mean_2_2551": "'{0}' 속성이 '{1}' 형식에 없습니다. '{2}'을(를) 사용하시겠습니까?", + "Property_0_does_not_exist_on_type_1_Did_you_mean_to_access_the_static_member_2_instead_2576": "'{0}' 속성이 '{1}' 형식에 없습니다. 대신 정적 멤버 '{2}'에 액세스하려고 하셨습니까?", "Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_c_2550": "'{0}' 속성이 '{1}' 형식에 없습니다. 대상 라이브러리를 변경해야 하는 경우 'lib' 컴파일러 옵션을 '{2}' 이상으로 변경해 보세요.", "Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor_2564": "속성 '{0}'은(는) 이니셜라이저가 없고 생성자에 할당되어 있지 않습니다.", "Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation_7033": "'{0}' 속성에는 해당 get 접근자에 반환 형식 주석이 없으므로 암시적으로 'any' 형식이 포함됩니다.", @@ -932,7 +936,6 @@ "Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2_2416": "'{1}' 형식의 '{0}' 속성을 기본 형식 '{2}'의 동일한 속성에 할당할 수 없습니다.", "Property_0_in_type_1_is_not_assignable_to_type_2_2603": "'{1}' 형식의 '{0}' 속성을 '{2}' 형식에 할당할 수 없습니다.", "Property_0_in_type_1_refers_to_a_different_member_that_cannot_be_accessed_from_within_type_2_18015": "'{1}' 형식의 '{0}' 속성이 '{2}' 형식 내에서 액세스할 수 없는 다른 멤버를 참조합니다.", - "Property_0_is_a_static_member_of_type_1_2576": "'{0}' 속성이 '{1}' 형식의 정적 멤버가 아닙니다.", "Property_0_is_declared_but_its_value_is_never_read_6138": "속성 '{0}'이(가) 선언은 되었지만 해당 값이 읽히지는 않았습니다.", "Property_0_is_incompatible_with_index_signature_2530": "'{0}' 속성이 인덱스 시그니처와 호환되지 않습니다.", "Property_0_is_incompatible_with_rest_element_type_2573": "'{0}' 속성이 rest 요소 형식과 호환되지 않습니다.", @@ -1007,6 +1010,7 @@ "Report_errors_in_js_files_8019": ".js 파일의 오류를 보고합니다.", "Report_errors_on_unused_locals_6134": "사용되지 않은 로컬 항목에 대한 오류를 보고합니다.", "Report_errors_on_unused_parameters_6135": "사용되지 않은 매개 변수에 대한 오류를 보고합니다.", + "Require_undeclared_properties_from_index_signatures_to_use_element_accesses_6803": "요소 액세스를 사용하려면 인덱스 시그니처의 선언되지 않은 속성이 필요합니다.", "Required_type_parameters_may_not_follow_optional_type_parameters_2706": "필수 형식 매개 변수는 선택적 형식 매개 변수 다음에 올 수 없습니다.", "Resolution_for_module_0_was_found_in_cache_from_location_1_6147": "'{0}' 모듈에 대한 해결을 '{1}' 위치의 캐시에서 찾았습니다.", "Resolve_keyof_to_string_valued_property_names_only_no_numbers_or_symbols_6195": "문자열 값 속성 이름에 대해서만 'keyof'를 확인합니다(숫자나 기호 아님).", @@ -1146,7 +1150,7 @@ "The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback_1060": "프라미스에서 'then' 메서드의 첫 번째 매개 변수는 콜백이어야 합니다.", "The_global_type_JSX_0_may_not_have_more_than_one_property_2608": "전역 형식 'JSX.{0}'에 속성이 둘 이상 있을 수 없습니다.", "The_implementation_signature_is_declared_here_2750": "여기에서는 구현 시그니처가 선언됩니다.", - "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system_1343": "'import.meta' 메타 속성은 '--module' 옵션이 'esnext' 또는 'system'인 경우에만 사용할 수 있습니다.", + "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_esnext_or_system_1343": "'import.meta' 메타 속성은 '--module' 옵션이 'es2020', 'esnext' 또는 'system'인 경우에만 허용됩니다.", "The_inferred_type_of_0_cannot_be_named_without_a_reference_to_1_This_is_likely_not_portable_A_type_a_2742": "'{0}'의 유추된 형식 이름을 지정하려면 '{1}'에 대한 참조가 있어야 합니다. 이식하지 못할 수 있습니다. 형식 주석이 필요합니다.", "The_inferred_type_of_0_references_a_type_with_a_cyclic_structure_which_cannot_be_trivially_serialize_5088": "'{0}'의 유추된 형식이 일반적으로 직렬화될 수 없는 순환 구조가 있는 형식을 참조합니다. 형식 주석이 필요합니다.", "The_inferred_type_of_0_references_an_inaccessible_1_type_A_type_annotation_is_necessary_2527": "'{0}'의 유추 형식이 액세스할 수 없는 '{1}' 형식을 참조합니다. 형식 주석이 필요합니다.", @@ -1216,7 +1220,7 @@ "This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without_6234": "이 식은 'get' 접근자이므로 호출할 수 없습니다. '()' 없이 사용하시겠습니까?", "This_expression_is_not_constructable_2351": "이 식은 생성할 수 없습니다.", "This_file_already_has_a_default_export_95130": "이 파일에 이미 기본 내보내기가 있습니다.", - "This_import_is_never_used_as_a_value_and_must_use_import_type_because_the_importsNotUsedAsValues_is__1371": "이 가져오기는 값으로 사용되지 않아야 하며 'importsNotUsedAsValues'가 'error'로 설정되어 있기 때문에 'import type'을 사용해야 합니다.", + "This_import_is_never_used_as_a_value_and_must_use_import_type_because_importsNotUsedAsValues_is_set__1371": "이 가져오기는 값으로 사용되지 않으며 'importsNotUsedAsValues'가 'error'로 설정되어 있기 때문에 'import type'을 사용해야 합니다.", "This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_fil_6233": "확대되는 선언입니다. 확대하는 선언을 같은 파일로 이동하는 것이 좋습니다.", "This_may_be_converted_to_an_async_function_80006": "비동기 함수로 변환될 수 있습니다.", "This_module_can_only_be_referenced_with_ECMAScript_imports_Slashexports_by_turning_on_the_0_flag_and_2497": "이 모듈은 '{0}' 플래그를 켜고 기본 내보내기를 참조하여 ECMAScript 가져오기/내보내기를 통해서만 참조할 수 있습니다.", @@ -1342,6 +1346,8 @@ "Updating_output_of_project_0_6373": "'{0}' 프로젝트의 출력을 업데이트하는 중...", "Updating_output_timestamps_of_project_0_6359": "'{0}' 프로젝트의 출력 타임스탬프를 업데이트하는 중...", "Updating_unchanged_output_timestamps_of_project_0_6371": "'{0}' 프로젝트의 변경되지 않은 출력 타임스탬프를 업데이트하는 중...", + "Use_element_access_for_0_95145": "'{0}'에 요소 액세스 사용", + "Use_element_access_for_all_undeclared_properties_95146": "선언되지 않은 모든 속성에 요소 액세스를 사용합니다.", "Use_synthetic_default_member_95016": "가상 '기본' 멤버를 사용합니다.", "Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher_2494": "ECMAScript 5 이상에서만 'for...of' 문에서 문자열을 사용할 수 있습니다.", "Using_compiler_options_of_project_reference_redirect_0_6215": "프로젝트 참조 리디렉션 '{0}'의 컴파일러 옵션을 사용 중입니다.", diff --git a/lib/lib.dom.d.ts b/lib/lib.dom.d.ts index 960a6800eaeb4..c5cd8c3897aa2 100644 --- a/lib/lib.dom.d.ts +++ b/lib/lib.dom.d.ts @@ -22,19 +22,24 @@ and limitations under the License. /// DOM APIs ///////////////////////////// -interface Account { - displayName: string; - id: string; - imageURL?: string; - name?: string; - rpDisplayName: string; -} - interface AddEventListenerOptions extends EventListenerOptions { once?: boolean; passive?: boolean; } +interface AddressErrors { + addressLine?: string; + city?: string; + country?: string; + dependentLocality?: string; + organization?: string; + phone?: string; + postalCode?: string; + recipient?: string; + region?: string; + sortingCode?: string; +} + interface AesCbcParams extends Algorithm { iv: Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array | DataView | ArrayBuffer; } @@ -84,13 +89,6 @@ interface AnimationPlaybackEventInit extends EventInit { timelineTime?: number | null; } -interface AssertionOptions { - allowList?: ScopedCredentialDescriptor[]; - extensions?: WebAuthnExtensions; - rpId?: string; - timeoutSeconds?: number; -} - interface AssignedNodesOptions { flatten?: boolean; } @@ -209,15 +207,6 @@ interface ChannelSplitterOptions extends AudioNodeOptions { numberOfOutputs?: number; } -interface ClientData { - challenge: string; - extensions?: WebAuthnExtensions; - hashAlg: string | Algorithm; - origin: string; - rpId: string; - tokenBinding?: string; -} - interface ClientQueryOptions { includeUncontrolled?: boolean; type?: ClientTypes; @@ -365,10 +354,6 @@ interface DelayOptions extends AudioNodeOptions { maxDelayTime?: number; } -interface DeviceLightEventInit extends EventInit { - value?: number; -} - interface DeviceMotionEventAccelerationInit { x?: number | null; y?: number | null; @@ -966,9 +951,14 @@ interface PannerOptions extends AudioNodeOptions { rolloffFactor?: number; } +interface PayerErrors { + email?: string; + name?: string; + phone?: string; +} + interface PaymentCurrencyAmount { currency: string; - currencySystem?: string; value: string; } @@ -992,6 +982,9 @@ interface PaymentDetailsModifier { interface PaymentDetailsUpdate extends PaymentDetailsBase { error?: string; + payerErrors?: PayerErrors; + paymentMethodErrors?: any; + shippingAddressErrors?: AddressErrors; total?: PaymentItem; } @@ -1001,17 +994,23 @@ interface PaymentItem { pending?: boolean; } +interface PaymentMethodChangeEventInit extends PaymentRequestUpdateEventInit { + methodDetails?: any; + methodName?: string; +} + interface PaymentMethodData { data?: any; supportedMethods: string | string[]; } interface PaymentOptions { + requestBillingAddress?: boolean; requestPayerEmail?: boolean; requestPayerName?: boolean; requestPayerPhone?: boolean; requestShipping?: boolean; - shippingType?: string; + shippingType?: PaymentShippingType; } interface PaymentRequestUpdateEventInit extends EventInit { @@ -1024,6 +1023,13 @@ interface PaymentShippingOption { selected?: boolean; } +interface PaymentValidationErrors { + error?: string; + payer?: PayerErrors; + paymentMethod?: any; + shippingAddress?: AddressErrors; +} + interface Pbkdf2Params extends Algorithm { hash: HashAlgorithmIdentifier; iterations: number; @@ -1165,7 +1171,7 @@ interface QueuingStrategy { interface QueuingStrategyInit { /** * Creates a new ByteLengthQueuingStrategy with the provided high water mark. - * + * * Note that the provided high water mark will not be validated ahead of time. Instead, if it is negative, NaN, or not a number, the resulting ByteLengthQueuingStrategy will cause the corresponding stream constructor to throw. */ highWaterMark: number; @@ -1184,12 +1190,11 @@ interface RTCConfiguration { iceCandidatePoolSize?: number; iceServers?: RTCIceServer[]; iceTransportPolicy?: RTCIceTransportPolicy; - peerIdentity?: string; rtcpMuxPolicy?: RTCRtcpMuxPolicy; } interface RTCDTMFToneChangeEventInit extends EventInit { - tone: string; + tone?: string; } interface RTCDataChannelEventInit extends EventInit { @@ -1202,7 +1207,6 @@ interface RTCDataChannelInit { maxRetransmits?: number; negotiated?: boolean; ordered?: boolean; - priority?: RTCPriorityType; protocol?: string; } @@ -1222,7 +1226,6 @@ interface RTCErrorEventInit extends EventInit { interface RTCErrorInit { errorDetail: RTCErrorDetailType; - httpRequestStatusCode?: number; receivedAlert?: number; sctpCauseCode?: number; sdpLineNumber?: number; @@ -1312,7 +1315,7 @@ interface RTCIceParameters { } interface RTCIceServer { - credential?: string | RTCOAuthCredential; + credential?: string; credentialType?: RTCIceCredentialType; urls: string | string[]; username?: string; @@ -1332,6 +1335,11 @@ interface RTCInboundRTPStreamStats extends RTCRTPStreamStats { packetsReceived?: number; } +interface RTCLocalSessionDescriptionInit { + sdp?: string; + type?: RTCSdpType; +} + interface RTCMediaStreamTrackStats extends RTCStats { audioLevel?: number; echoReturnLoss?: number; @@ -1349,13 +1357,7 @@ interface RTCMediaStreamTrackStats extends RTCStats { trackIdentifier?: string; } -interface RTCOAuthCredential { - accessToken: string; - macKey: string; -} - interface RTCOfferAnswerOptions { - voiceActivityDetection?: boolean; } interface RTCOfferOptions extends RTCOfferAnswerOptions { @@ -1372,8 +1374,9 @@ interface RTCOutboundRTPStreamStats extends RTCRTPStreamStats { } interface RTCPeerConnectionIceErrorEventInit extends EventInit { + address?: string | null; errorCode: number; - hostCandidate?: string; + port?: number | null; statusText?: string; url?: string; } @@ -1438,16 +1441,9 @@ interface RTCRtpContributingSource { timestamp: number; } -interface RTCRtpDecodingParameters extends RTCRtpCodingParameters { -} - interface RTCRtpEncodingParameters extends RTCRtpCodingParameters { active?: boolean; - codecPayloadType?: number; - dtx?: RTCDtxStatus; maxBitrate?: number; - maxFramerate?: number; - ptime?: number; scaleResolutionDownBy?: number; } @@ -1480,7 +1476,6 @@ interface RTCRtpParameters { } interface RTCRtpReceiveParameters extends RTCRtpParameters { - encodings: RTCRtpDecodingParameters[]; } interface RTCRtpRtxParameters { @@ -1488,9 +1483,7 @@ interface RTCRtpRtxParameters { } interface RTCRtpSendParameters extends RTCRtpParameters { - degradationPreference?: RTCDegradationPreference; encodings: RTCRtpEncodingParameters[]; - priority?: RTCPriorityType; transactionId: string; } @@ -1512,7 +1505,7 @@ interface RTCRtpUnhandled { interface RTCSessionDescriptionInit { sdp?: string; - type?: RTCSdpType; + type: RTCSdpType; } interface RTCSrtpKeyParam { @@ -1541,10 +1534,6 @@ interface RTCStats { type?: RTCStatsType; } -interface RTCStatsEventInit extends EventInit { - report: RTCStatsReport; -} - interface RTCStatsReport { } @@ -1587,7 +1576,7 @@ interface ReadableWritablePair { readable: ReadableStream; /** * Provides a convenient, chainable way of piping this readable stream through a transform stream (or any other { writable, readable } pair). It simply pipes the stream into the writable side of the supplied pair, and returns the readable side for further use. - * + * * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader. */ writable: WritableStream; @@ -1707,24 +1696,6 @@ interface SVGBoundingBoxOptions { stroke?: boolean; } -interface ScopedCredentialDescriptor { - id: Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array | DataView | ArrayBuffer | null; - transports?: Transport[]; - type: ScopedCredentialType; -} - -interface ScopedCredentialOptions { - excludeList?: ScopedCredentialDescriptor[]; - extensions?: WebAuthnExtensions; - rpId?: string; - timeoutSeconds?: number; -} - -interface ScopedCredentialParameters { - algorithm: string | Algorithm; - type: ScopedCredentialType; -} - interface ScrollIntoViewOptions extends ScrollOptions { block?: ScrollLogicalPosition; inline?: ScrollLogicalPosition; @@ -1752,14 +1723,6 @@ interface SecurityPolicyViolationEventInit extends EventInit { violatedDirective?: string; } -interface ServiceWorkerMessageEventInit extends EventInit { - data?: any; - lastEventId?: string; - origin?: string; - ports?: MessagePort[] | null; - source?: ServiceWorker | MessagePort | null; -} - interface ShadowRootInit { delegatesFocus?: boolean; mode: ShadowRootMode; @@ -1832,19 +1795,19 @@ interface StreamPipeOptions { preventCancel?: boolean; /** * Pipes this readable stream to a given writable stream destination. The way in which the piping process behaves under various error conditions can be customized with a number of passed options. It returns a promise that fulfills when the piping process completes successfully, or rejects if any errors were encountered. - * + * * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader. - * + * * Errors and closures of the source and destination streams propagate as follows: - * + * * An error in this source readable stream will abort destination, unless preventAbort is truthy. The returned promise will be rejected with the source's error, or with any error that occurs during aborting the destination. - * + * * An error in destination will cancel this source readable stream, unless preventCancel is truthy. The returned promise will be rejected with the destination's error, or with any error that occurs during canceling the source. - * + * * When this source readable stream closes, destination will be closed, unless preventClose is truthy. The returned promise will be fulfilled once this process completes, unless an error is encountered while closing the destination, in which case it will be rejected with that error. - * + * * If destination starts out closed or closing, this source readable stream will be canceled, unless preventCancel is true. The returned promise will be rejected with an error indicating piping to a closed stream failed, or with any error that occurs during canceling the source. - * + * * The signal option can be set to an AbortSignal to allow aborting an ongoing pipe operation via the corresponding AbortController. In this case, this source readable stream will be canceled, and destination aborted, unless the respective options preventCancel or preventAbort are set. */ preventClose?: boolean; @@ -1954,9 +1917,6 @@ interface WaveShaperOptions extends AudioNodeOptions { oversample?: OverSampleType; } -interface WebAuthnExtensions { -} - interface WebGLContextAttributes { alpha?: boolean; antialias?: boolean; @@ -3404,7 +3364,7 @@ interface CanvasFilters { interface CanvasGradient { /** * Adds a color stop with the given color to the gradient at the given offset. 0.0 is the offset at one end of the gradient, 1.0 is the offset at the other end. - * + * * Throws an "IndexSizeError" DOMException if the offset is out of range. Throws a "SyntaxError" DOMException if the color cannot be parsed. */ addColorStop(offset: number, color: string): void; @@ -3571,13 +3531,13 @@ declare var CharacterData: { interface ChildNode extends Node { /** * Inserts nodes just after node, while replacing strings in nodes with equivalent Text nodes. - * + * * Throws a "HierarchyRequestError" DOMException if the constraints of the node tree are violated. */ after(...nodes: (Node | string)[]): void; /** * Inserts nodes just before node, while replacing strings in nodes with equivalent Text nodes. - * + * * Throws a "HierarchyRequestError" DOMException if the constraints of the node tree are violated. */ before(...nodes: (Node | string)[]): void; @@ -3587,7 +3547,7 @@ interface ChildNode extends Node { remove(): void; /** * Replaces node with nodes, while replacing strings in nodes with equivalent Text nodes. - * + * * Throws a "HierarchyRequestError" DOMException if the constraints of the node tree are violated. */ replaceWith(...nodes: (Node | string)[]): void; @@ -3891,10 +3851,6 @@ declare var DOMImplementation: { new(): DOMImplementation; }; -interface DOML2DeprecatedColorProperty { - color: string; -} - interface DOMMatrix extends DOMMatrixReadOnly { a: number; b: number; @@ -4005,11 +3961,11 @@ declare var DOMMatrixReadOnly: { interface DOMParser { /** * Parses string using either the HTML or XML parser, according to type, and returns the resulting Document. type can be "text/html" (which will invoke the HTML parser), or any of "text/xml", "application/xml", "application/xhtml+xml", or "image/svg+xml" (which will invoke the XML parser). - * + * * For the XML parser, if string cannot be parsed, then the returned Document will contain elements describing the resulting error. - * + * * Note that script elements are not evaluated during parsing, and the resulting document's encoding will always be UTF-8. - * + * * Values other than the above for type will cause a TypeError exception to be thrown. */ parseFromString(string: string, type: DOMParserSupportedType): Document; @@ -4161,16 +4117,16 @@ interface DOMTokenList { readonly length: number; /** * Returns the associated set as string. - * + * * Can be set, to change the associated attribute. */ value: string; toString(): string; /** * Adds all arguments passed, except those already present. - * + * * Throws a "SyntaxError" DOMException if one of the arguments is the empty string. - * + * * Throws an "InvalidCharacterError" DOMException if one of the arguments contains any ASCII whitespace. */ add(...tokens: string[]): void; @@ -4184,35 +4140,35 @@ interface DOMTokenList { item(index: number): string | null; /** * Removes arguments passed, if they are present. - * + * * Throws a "SyntaxError" DOMException if one of the arguments is the empty string. - * + * * Throws an "InvalidCharacterError" DOMException if one of the arguments contains any ASCII whitespace. */ remove(...tokens: string[]): void; /** * Replaces token with newToken. - * + * * Returns true if token was replaced with newToken, and false otherwise. - * + * * Throws a "SyntaxError" DOMException if one of the arguments is the empty string. - * + * * Throws an "InvalidCharacterError" DOMException if one of the arguments contains any ASCII whitespace. */ replace(oldToken: string, newToken: string): void; /** * Returns true if token is in the associated attribute's supported tokens. Returns false otherwise. - * + * * Throws a TypeError if the associated attribute has no supported tokens defined. */ supports(token: string): boolean; /** * If force is not given, "toggles" token, removing it if it's present and adding it if it's not present. If force is true, adds token (same as add()). If force is false, removes token (same as remove()). - * + * * Returns true if token is now present, and false otherwise. - * + * * Throws a "SyntaxError" DOMException if token is empty. - * + * * Throws an "InvalidCharacterError" DOMException if token contains any spaces. */ toggle(token: string, force?: boolean): boolean; @@ -4242,17 +4198,17 @@ declare var DataCue: { interface DataTransfer { /** * Returns the kind of operation that is currently selected. If the kind of operation isn't one of those that is allowed by the effectAllowed attribute, then the operation will fail. - * + * * Can be set, to change the selected operation. - * + * * The possible values are "none", "copy", "link", and "move". */ dropEffect: "none" | "copy" | "link" | "move"; /** * Returns the kinds of operations that are to be allowed. - * + * * Can be set (during the dragstart event), to change the allowed operations. - * + * * The possible values are "none", "copy", "copyLink", "copyMove", "link", "linkMove", "move", "all", and "uninitialized", */ effectAllowed: "none" | "copy" | "copyLink" | "copyMove" | "link" | "linkMove" | "move" | "all" | "uninitialized"; @@ -4380,16 +4336,6 @@ declare var DeviceAcceleration: { new(): DeviceAcceleration; }; -/** The DeviceLightEvent provides web developers with information from photo sensors or similiar detectors about ambient light levels near the device. For example this may be useful to adjust the screen's brightness based on the current ambient light level in order to save energy or provide better readability. */ -interface DeviceLightEvent extends Event { - readonly value: number; -} - -declare var DeviceLightEvent: { - prototype: DeviceLightEvent; - new(typeArg: string, eventInitDict?: DeviceLightEventInit): DeviceLightEvent; -}; - /** The DeviceMotionEvent provides web developers with information about the speed of changes for the device's position and orientation. */ interface DeviceMotionEvent extends Event { readonly acceleration: DeviceMotionEventAcceleration | null; @@ -4523,15 +4469,15 @@ interface Document extends Node, DocumentAndElementEventHandlers, DocumentOrShad readonly contentType: string; /** * Returns the HTTP cookies that apply to the Document. If there are no cookies or cookies can't be applied to this resource, the empty string will be returned. - * + * * Can be set, to add a new cookie to the element's set of HTTP cookies. - * + * * If the contents are sandboxed into a unique origin (e.g. in an iframe with the sandbox attribute), a "SecurityError" DOMException will be thrown on getting and setting. */ cookie: string; /** * Returns the script element, or the SVG script element, that is currently executing, as long as the element represents a classic script. In the case of reentrant script execution, returns the one that most recently started executing amongst those that have not yet finished executing. - * + * * Returns null if the Document is not currently executing a script or SVG script element (e.g., because the running script is an event handler, or a timeout), or if the currently executing script or SVG script element represents a module script. */ readonly currentScript: HTMLOrSVGScriptElement | null; @@ -4654,7 +4600,7 @@ interface Document extends Node, DocumentAndElementEventHandlers, DocumentOrShad vlinkColor: string; /** * Moves node from another document and returns it. - * + * * If node is a document, throws a "NotSupportedError" DOMException or, if node is a shadow root, throws a "HierarchyRequestError" DOMException. */ adoptNode(source: T): T; @@ -4698,17 +4644,17 @@ interface Document extends Node, DocumentAndElementEventHandlers, DocumentOrShad createElement(tagName: string, options?: ElementCreationOptions): HTMLElement; /** * Returns an element with namespace namespace. Its namespace prefix will be everything before ":" (U+003E) in qualifiedName or null. Its local name will be everything after ":" (U+003E) in qualifiedName or qualifiedName. - * + * * If localName does not match the Name production an "InvalidCharacterError" DOMException will be thrown. - * + * * If one of the following conditions is true a "NamespaceError" DOMException will be thrown: - * + * * localName does not match the QName production. * Namespace prefix is not null and namespace is the empty string. * Namespace prefix is "xml" and namespace is not the XML namespace. * qualifiedName or namespace prefix is "xmlns" and namespace is not the XMLNS namespace. * namespace is the XMLNS namespace and neither qualifiedName nor namespace prefix is "xmlns". - * + * * When supplied, options's is can be used to create a customized built-in element. */ createElementNS(namespaceURI: "http://www.w3.org/1999/xhtml", qualifiedName: string): HTMLElement; @@ -4724,7 +4670,6 @@ interface Document extends Node, DocumentAndElementEventHandlers, DocumentOrShad createEvent(eventInterface: "CloseEvent"): CloseEvent; createEvent(eventInterface: "CompositionEvent"): CompositionEvent; createEvent(eventInterface: "CustomEvent"): CustomEvent; - createEvent(eventInterface: "DeviceLightEvent"): DeviceLightEvent; createEvent(eventInterface: "DeviceMotionEvent"): DeviceMotionEvent; createEvent(eventInterface: "DeviceOrientationEvent"): DeviceOrientationEvent; createEvent(eventInterface: "DragEvent"): DragEvent; @@ -4739,10 +4684,6 @@ interface Document extends Node, DocumentAndElementEventHandlers, DocumentOrShad createEvent(eventInterface: "InputEvent"): InputEvent; createEvent(eventInterface: "KeyboardEvent"): KeyboardEvent; createEvent(eventInterface: "ListeningStateChangedEvent"): ListeningStateChangedEvent; - createEvent(eventInterface: "MSGestureEvent"): MSGestureEvent; - createEvent(eventInterface: "MSMediaKeyMessageEvent"): MSMediaKeyMessageEvent; - createEvent(eventInterface: "MSMediaKeyNeededEvent"): MSMediaKeyNeededEvent; - createEvent(eventInterface: "MSPointerEvent"): MSPointerEvent; createEvent(eventInterface: "MediaEncryptedEvent"): MediaEncryptedEvent; createEvent(eventInterface: "MediaKeyMessageEvent"): MediaKeyMessageEvent; createEvent(eventInterface: "MediaQueryListEvent"): MediaQueryListEvent; @@ -4757,6 +4698,7 @@ interface Document extends Node, DocumentAndElementEventHandlers, DocumentOrShad createEvent(eventInterface: "OfflineAudioCompletionEvent"): OfflineAudioCompletionEvent; createEvent(eventInterface: "OverflowEvent"): OverflowEvent; createEvent(eventInterface: "PageTransitionEvent"): PageTransitionEvent; + createEvent(eventInterface: "PaymentMethodChangeEvent"): PaymentMethodChangeEvent; createEvent(eventInterface: "PaymentRequestUpdateEvent"): PaymentRequestUpdateEvent; createEvent(eventInterface: "PermissionRequestedEvent"): PermissionRequestedEvent; createEvent(eventInterface: "PointerEvent"): PointerEvent; @@ -4773,12 +4715,10 @@ interface Document extends Node, DocumentAndElementEventHandlers, DocumentOrShad createEvent(eventInterface: "RTCPeerConnectionIceErrorEvent"): RTCPeerConnectionIceErrorEvent; createEvent(eventInterface: "RTCPeerConnectionIceEvent"): RTCPeerConnectionIceEvent; createEvent(eventInterface: "RTCSsrcConflictEvent"): RTCSsrcConflictEvent; - createEvent(eventInterface: "RTCStatsEvent"): RTCStatsEvent; createEvent(eventInterface: "RTCTrackEvent"): RTCTrackEvent; createEvent(eventInterface: "SVGZoomEvent"): SVGZoomEvent; createEvent(eventInterface: "SVGZoomEvents"): SVGZoomEvent; createEvent(eventInterface: "SecurityPolicyViolationEvent"): SecurityPolicyViolationEvent; - createEvent(eventInterface: "ServiceWorkerMessageEvent"): ServiceWorkerMessageEvent; createEvent(eventInterface: "SpeechRecognitionErrorEvent"): SpeechRecognitionErrorEvent; createEvent(eventInterface: "SpeechRecognitionEvent"): SpeechRecognitionEvent; createEvent(eventInterface: "SpeechSynthesisErrorEvent"): SpeechSynthesisErrorEvent; @@ -4869,11 +4809,11 @@ interface Document extends Node, DocumentAndElementEventHandlers, DocumentOrShad getElementsByTagName(qualifiedName: string): HTMLCollectionOf; /** * If namespace and localName are "*" returns a HTMLCollection of all descendant elements. - * + * * If only namespace is "*" returns a HTMLCollection of all descendant elements whose local name is localName. - * + * * If only localName is "*" returns a HTMLCollection of all descendant elements whose namespace is namespace. - * + * * Otherwise, returns a HTMLCollection of all descendant elements whose namespace is namespace and local name is localName. */ getElementsByTagNameNS(namespaceURI: "http://www.w3.org/1999/xhtml", localName: string): HTMLCollectionOf; @@ -4889,7 +4829,7 @@ interface Document extends Node, DocumentAndElementEventHandlers, DocumentOrShad hasFocus(): boolean; /** * Returns a copy of node. If deep is true, the copy also includes the node's descendants. - * + * * If node is a document or a shadow root, throws a "NotSupportedError" DOMException. */ importNode(importedNode: T, deep: boolean): T; @@ -4974,7 +4914,6 @@ interface DocumentEvent { createEvent(eventInterface: "CloseEvent"): CloseEvent; createEvent(eventInterface: "CompositionEvent"): CompositionEvent; createEvent(eventInterface: "CustomEvent"): CustomEvent; - createEvent(eventInterface: "DeviceLightEvent"): DeviceLightEvent; createEvent(eventInterface: "DeviceMotionEvent"): DeviceMotionEvent; createEvent(eventInterface: "DeviceOrientationEvent"): DeviceOrientationEvent; createEvent(eventInterface: "DragEvent"): DragEvent; @@ -4989,10 +4928,6 @@ interface DocumentEvent { createEvent(eventInterface: "InputEvent"): InputEvent; createEvent(eventInterface: "KeyboardEvent"): KeyboardEvent; createEvent(eventInterface: "ListeningStateChangedEvent"): ListeningStateChangedEvent; - createEvent(eventInterface: "MSGestureEvent"): MSGestureEvent; - createEvent(eventInterface: "MSMediaKeyMessageEvent"): MSMediaKeyMessageEvent; - createEvent(eventInterface: "MSMediaKeyNeededEvent"): MSMediaKeyNeededEvent; - createEvent(eventInterface: "MSPointerEvent"): MSPointerEvent; createEvent(eventInterface: "MediaEncryptedEvent"): MediaEncryptedEvent; createEvent(eventInterface: "MediaKeyMessageEvent"): MediaKeyMessageEvent; createEvent(eventInterface: "MediaQueryListEvent"): MediaQueryListEvent; @@ -5007,6 +4942,7 @@ interface DocumentEvent { createEvent(eventInterface: "OfflineAudioCompletionEvent"): OfflineAudioCompletionEvent; createEvent(eventInterface: "OverflowEvent"): OverflowEvent; createEvent(eventInterface: "PageTransitionEvent"): PageTransitionEvent; + createEvent(eventInterface: "PaymentMethodChangeEvent"): PaymentMethodChangeEvent; createEvent(eventInterface: "PaymentRequestUpdateEvent"): PaymentRequestUpdateEvent; createEvent(eventInterface: "PermissionRequestedEvent"): PermissionRequestedEvent; createEvent(eventInterface: "PointerEvent"): PointerEvent; @@ -5023,12 +4959,10 @@ interface DocumentEvent { createEvent(eventInterface: "RTCPeerConnectionIceErrorEvent"): RTCPeerConnectionIceErrorEvent; createEvent(eventInterface: "RTCPeerConnectionIceEvent"): RTCPeerConnectionIceEvent; createEvent(eventInterface: "RTCSsrcConflictEvent"): RTCSsrcConflictEvent; - createEvent(eventInterface: "RTCStatsEvent"): RTCStatsEvent; createEvent(eventInterface: "RTCTrackEvent"): RTCTrackEvent; createEvent(eventInterface: "SVGZoomEvent"): SVGZoomEvent; createEvent(eventInterface: "SVGZoomEvents"): SVGZoomEvent; createEvent(eventInterface: "SecurityPolicyViolationEvent"): SecurityPolicyViolationEvent; - createEvent(eventInterface: "ServiceWorkerMessageEvent"): ServiceWorkerMessageEvent; createEvent(eventInterface: "SpeechRecognitionErrorEvent"): SpeechRecognitionErrorEvent; createEvent(eventInterface: "SpeechRecognitionEvent"): SpeechRecognitionEvent; createEvent(eventInterface: "SpeechSynthesisErrorEvent"): SpeechSynthesisErrorEvent; @@ -5276,7 +5210,7 @@ interface Element extends Node, Animatable, ChildNode, InnerHTML, NonDocumentTyp removeAttributeNode(attr: Attr): Attr; /** * Displays element fullscreen and resolves promise when done. - * + * * When supplied, options's navigationUI member indicates whether showing navigation UI while in fullscreen is preferred or not. If set to "show", navigation simplicity is preferred over screen space, and if set to "hide", more screen space is preferred. User agents are always free to honor user preference over the application's. The default value "auto" indicates no application preference. */ requestFullscreen(options?: FullscreenOptions): Promise; @@ -5301,7 +5235,7 @@ interface Element extends Node, Animatable, ChildNode, InnerHTML, NonDocumentTyp setPointerCapture(pointerId: number): void; /** * If force is not given, "toggles" qualifiedName, removing it if it is present and adding it if it is not present. If force is true, adds qualifiedName. If force is false, removes qualifiedName. - * + * * Returns true if qualifiedName is now present, and false otherwise. */ toggleAttribute(qualifiedName: string, force?: boolean): boolean; @@ -5471,15 +5405,15 @@ declare var EventSource: { interface EventTarget { /** * Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched. - * + * * The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture. - * + * * When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET. - * + * * When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners. - * + * * When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed. - * + * * The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture. */ addEventListener(type: string, listener: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions): void; @@ -6146,9 +6080,9 @@ interface HTMLAllCollection { item(nameOrIndex?: string): HTMLCollection | Element | null; /** * Returns the item with ID or name name from the collection. - * + * * If there are multiple matching items, then an HTMLCollection object containing all those elements is returned. - * + * * Only button, form, iframe, input, map, meta, object, select, and textarea elements can have a name for the purpose of this method; their name is given by the value of their name attribute. */ namedItem(name: string): HTMLCollection | Element | null; @@ -6360,29 +6294,6 @@ declare var HTMLBaseElement: { new(): HTMLBaseElement; }; -/** Provides special properties (beyond the regular HTMLElement interface it also has available to it by inheritance) for manipulating elements. */ -interface HTMLBaseFontElement extends HTMLElement, DOML2DeprecatedColorProperty { - /** - * Sets or retrieves the current typeface family. - */ - /** @deprecated */ - face: string; - /** - * Sets or retrieves the font size of the object. - */ - /** @deprecated */ - size: number; - addEventListener(type: K, listener: (this: HTMLBaseFontElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; - removeEventListener(type: K, listener: (this: HTMLBaseFontElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; -} - -declare var HTMLBaseFontElement: { - prototype: HTMLBaseFontElement; - new(): HTMLBaseFontElement; -}; - interface HTMLBodyElementEventMap extends HTMLElementEventMap, WindowEventHandlersEventMap { "orientationchange": Event; } @@ -6809,7 +6720,7 @@ declare var HTMLFontElement: { interface HTMLFormControlsCollection extends HTMLCollectionBase { /** * Returns the item with ID or name name from the collection. - * + * * If there are multiple matching items, then a RadioNodeList object containing all those elements is returned. */ namedItem(name: string): RadioNodeList | Element | null; @@ -8058,25 +7969,25 @@ declare var HTMLOptionElement: { interface HTMLOptionsCollection extends HTMLCollectionOf { /** * Returns the number of elements in the collection. - * + * * When set to a smaller number, truncates the number of option elements in the corresponding container. - * + * * When set to a greater number, adds new blank option elements to that container. */ length: number; /** * Returns the index of the first selected item, if any, or −1 if there is no selected item. - * + * * Can be set, to change the selection. */ selectedIndex: number; /** * Inserts element before the node given by before. - * + * * The before argument can be a number, in which case element is inserted before the item with that number, or an element from the collection, in which case element is inserted before that element. - * + * * If before is omitted, null, or a number out of range, then element will be added at the end of the list. - * + * * This method will throw a "HierarchyRequestError" DOMException if element is an ancestor of the element into which it is to be inserted. */ add(element: HTMLOptionElement | HTMLOptGroupElement, before?: HTMLElement | number | null): void; @@ -9155,15 +9066,15 @@ interface IDBCursor { continuePrimaryKey(key: IDBValidKey, primaryKey: IDBValidKey): void; /** * Delete the record pointed at by the cursor with a new value. - * + * * If successful, request's result will be undefined. */ delete(): IDBRequest; /** * Updated the record pointed at by the cursor with a new value. - * + * * Throws a "DataError" DOMException if the effective object store uses in-line keys and the key would have changed. - * + * * If successful, request's result will be the record's key. */ update(value: any): IDBRequest; @@ -9218,13 +9129,13 @@ interface IDBDatabase extends EventTarget { close(): void; /** * Creates a new object store with the given name and options and returns a new IDBObjectStore. - * + * * Throws a "InvalidStateError" DOMException if not called within an upgrade transaction. */ createObjectStore(name: string, options?: IDBObjectStoreParameters): IDBObjectStore; /** * Deletes the object store with the given name. - * + * * Throws a "InvalidStateError" DOMException if not called within an upgrade transaction. */ deleteObjectStore(name: string): void; @@ -9247,7 +9158,7 @@ declare var IDBDatabase: { interface IDBFactory { /** * Compares two values as keys. Returns -1 if key1 precedes key2, 1 if key2 precedes key1, and 0 if the keys are equal. - * + * * Throws a "DataError" DOMException if either input is not a valid key. */ cmp(first: any, second: any): number; @@ -9281,43 +9192,43 @@ interface IDBIndex { readonly unique: boolean; /** * Retrieves the number of records matching the given key or key range in query. - * + * * If successful, request's result will be the count. */ count(key?: IDBValidKey | IDBKeyRange): IDBRequest; /** * Retrieves the value of the first record matching the given key or key range in query. - * + * * If successful, request's result will be the value, or undefined if there was no matching record. */ get(key: IDBValidKey | IDBKeyRange): IDBRequest; /** * Retrieves the values of the records matching the given key or key range in query (up to count if given). - * + * * If successful, request's result will be an Array of the values. */ getAll(query?: IDBValidKey | IDBKeyRange | null, count?: number): IDBRequest; /** * Retrieves the keys of records matching the given key or key range in query (up to count if given). - * + * * If successful, request's result will be an Array of the keys. */ getAllKeys(query?: IDBValidKey | IDBKeyRange | null, count?: number): IDBRequest; /** * Retrieves the key of the first record matching the given key or key range in query. - * + * * If successful, request's result will be the key, or undefined if there was no matching record. */ getKey(key: IDBValidKey | IDBKeyRange): IDBRequest; /** * Opens a cursor over the records matching query, ordered by direction. If query is null, all records in index are matched. - * + * * If successful, request's result will be an IDBCursorWithValue, or null if there were no matching records. */ openCursor(query?: IDBValidKey | IDBKeyRange | null, direction?: IDBCursorDirection): IDBRequest; /** * Opens a cursor with key only flag set over the records matching query, ordered by direction. If query is null, all records in index are matched. - * + * * If successful, request's result will be an IDBCursor, or null if there were no matching records. */ openKeyCursor(query?: IDBValidKey | IDBKeyRange | null, direction?: IDBCursorDirection): IDBRequest; @@ -9397,88 +9308,88 @@ interface IDBObjectStore { readonly transaction: IDBTransaction; /** * Adds or updates a record in store with the given value and key. - * + * * If the store uses in-line keys and key is specified a "DataError" DOMException will be thrown. - * + * * If put() is used, any existing record with the key will be replaced. If add() is used, and if a record with the key already exists the request will fail, with request's error set to a "ConstraintError" DOMException. - * + * * If successful, request's result will be the record's key. */ add(value: any, key?: IDBValidKey): IDBRequest; /** * Deletes all records in store. - * + * * If successful, request's result will be undefined. */ clear(): IDBRequest; /** * Retrieves the number of records matching the given key or key range in query. - * + * * If successful, request's result will be the count. */ count(key?: IDBValidKey | IDBKeyRange): IDBRequest; /** * Creates a new index in store with the given name, keyPath and options and returns a new IDBIndex. If the keyPath and options define constraints that cannot be satisfied with the data already in store the upgrade transaction will abort with a "ConstraintError" DOMException. - * + * * Throws an "InvalidStateError" DOMException if not called within an upgrade transaction. */ createIndex(name: string, keyPath: string | string[], options?: IDBIndexParameters): IDBIndex; /** * Deletes records in store with the given key or in the given key range in query. - * + * * If successful, request's result will be undefined. */ delete(key: IDBValidKey | IDBKeyRange): IDBRequest; /** * Deletes the index in store with the given name. - * + * * Throws an "InvalidStateError" DOMException if not called within an upgrade transaction. */ deleteIndex(name: string): void; /** * Retrieves the value of the first record matching the given key or key range in query. - * + * * If successful, request's result will be the value, or undefined if there was no matching record. */ get(query: IDBValidKey | IDBKeyRange): IDBRequest; /** * Retrieves the values of the records matching the given key or key range in query (up to count if given). - * + * * If successful, request's result will be an Array of the values. */ getAll(query?: IDBValidKey | IDBKeyRange | null, count?: number): IDBRequest; /** * Retrieves the keys of records matching the given key or key range in query (up to count if given). - * + * * If successful, request's result will be an Array of the keys. */ getAllKeys(query?: IDBValidKey | IDBKeyRange | null, count?: number): IDBRequest; /** * Retrieves the key of the first record matching the given key or key range in query. - * + * * If successful, request's result will be the key, or undefined if there was no matching record. */ getKey(query: IDBValidKey | IDBKeyRange): IDBRequest; index(name: string): IDBIndex; /** * Opens a cursor over the records matching query, ordered by direction. If query is null, all records in store are matched. - * + * * If successful, request's result will be an IDBCursorWithValue pointing at the first matching record, or null if there were no matching records. */ openCursor(query?: IDBValidKey | IDBKeyRange | null, direction?: IDBCursorDirection): IDBRequest; /** * Opens a cursor with key only flag set over the records matching query, ordered by direction. If query is null, all records in store are matched. - * + * * If successful, request's result will be an IDBCursor pointing at the first matching record, or null if there were no matching records. */ openKeyCursor(query?: IDBValidKey | IDBKeyRange | null, direction?: IDBCursorDirection): IDBRequest; /** * Adds or updates a record in store with the given value and key. - * + * * If the store uses in-line keys and key is specified a "DataError" DOMException will be thrown. - * + * * If put() is used, any existing record with the key will be replaced. If add() is used, and if a record with the key already exists the request will fail, with request's error set to a "ConstraintError" DOMException. - * + * * If successful, request's result will be the record's key. */ put(value: any, key?: IDBValidKey): IDBRequest; @@ -9798,25 +9709,25 @@ interface Location { readonly ancestorOrigins: DOMStringList; /** * Returns the Location object's URL's fragment (includes leading "#" if non-empty). - * + * * Can be set, to navigate to the same URL with a changed fragment (ignores leading "#"). */ hash: string; /** * Returns the Location object's URL's host and port (if different from the default port for the scheme). - * + * * Can be set, to navigate to the same URL with a changed host and port. */ host: string; /** * Returns the Location object's URL's host. - * + * * Can be set, to navigate to the same URL with a changed host. */ hostname: string; /** * Returns the Location object's URL. - * + * * Can be set, to navigate to the given URL. */ href: string; @@ -9827,25 +9738,25 @@ interface Location { readonly origin: string; /** * Returns the Location object's URL's path. - * + * * Can be set, to navigate to the same URL with a changed path. */ pathname: string; /** * Returns the Location object's URL's port. - * + * * Can be set, to navigate to the same URL with a changed port. */ port: string; /** * Returns the Location object's URL's scheme. - * + * * Can be set, to navigate to the same URL with a changed scheme. */ protocol: string; /** * Returns the Location object's URL's query (includes leading "?" if non-empty). - * + * * Can be set, to navigate to the same URL with a changed query (ignores leading "?"). */ search: string; @@ -9938,43 +9849,6 @@ declare var MSGesture: { new(): MSGesture; }; -/** The MSGestureEvent is a proprietary interface specific to Internet Explorer and Microsoft Edge which represents events that occur due to touch gestures. Events using this interface include MSGestureStart, MSGestureEnd, MSGestureTap, MSGestureHold, MSGestureChange, and MSInertiaStart. */ -interface MSGestureEvent extends UIEvent { - readonly clientX: number; - readonly clientY: number; - readonly expansion: number; - readonly gestureObject: any; - readonly hwTimestamp: number; - readonly offsetX: number; - readonly offsetY: number; - readonly rotation: number; - readonly scale: number; - readonly screenX: number; - readonly screenY: number; - readonly translationX: number; - readonly translationY: number; - readonly velocityAngular: number; - readonly velocityExpansion: number; - readonly velocityX: number; - readonly velocityY: number; - initGestureEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, offsetXArg: number, offsetYArg: number, translationXArg: number, translationYArg: number, scaleArg: number, expansionArg: number, rotationArg: number, velocityXArg: number, velocityYArg: number, velocityExpansionArg: number, velocityAngularArg: number, hwTimestampArg: number): void; - readonly MSGESTURE_FLAG_BEGIN: number; - readonly MSGESTURE_FLAG_CANCEL: number; - readonly MSGESTURE_FLAG_END: number; - readonly MSGESTURE_FLAG_INERTIA: number; - readonly MSGESTURE_FLAG_NONE: number; -} - -declare var MSGestureEvent: { - prototype: MSGestureEvent; - new(): MSGestureEvent; - readonly MSGESTURE_FLAG_BEGIN: number; - readonly MSGESTURE_FLAG_CANCEL: number; - readonly MSGESTURE_FLAG_END: number; - readonly MSGESTURE_FLAG_INERTIA: number; - readonly MSGESTURE_FLAG_NONE: number; -}; - /** The msGraphicsTrust() constructor returns an object that provides properties for info on protected video playback. */ interface MSGraphicsTrust { readonly constrictionActive: boolean; @@ -10036,25 +9910,6 @@ declare var MSMediaKeyError: { readonly MS_MEDIA_KEYERR_UNKNOWN: number; }; -interface MSMediaKeyMessageEvent extends Event { - readonly destinationURL: string | null; - readonly message: Uint8Array; -} - -declare var MSMediaKeyMessageEvent: { - prototype: MSMediaKeyMessageEvent; - new(): MSMediaKeyMessageEvent; -}; - -interface MSMediaKeyNeededEvent extends Event { - readonly initData: Uint8Array | null; -} - -declare var MSMediaKeyNeededEvent: { - prototype: MSMediaKeyNeededEvent; - new(): MSMediaKeyNeededEvent; -}; - interface MSMediaKeySession extends EventTarget { readonly error: MSMediaKeyError | null; readonly keySystem: string; @@ -10089,29 +9944,6 @@ interface MSNavigatorDoNotTrack { storeWebWideTrackingException(args: StoreExceptionsInformation): void; } -interface MSPointerEvent extends MouseEvent { - readonly currentPoint: any; - readonly height: number; - readonly hwTimestamp: number; - readonly intermediatePoints: any; - readonly isPrimary: boolean; - readonly pointerId: number; - readonly pointerType: any; - readonly pressure: number; - readonly rotation: number; - readonly tiltX: number; - readonly tiltY: number; - readonly width: number; - getCurrentPoint(element: Element): void; - getIntermediatePoints(element: Element): void; - initPointerEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, ctrlKeyArg: boolean, altKeyArg: boolean, shiftKeyArg: boolean, metaKeyArg: boolean, buttonArg: number, relatedTargetArg: EventTarget, offsetXArg: number, offsetYArg: number, widthArg: number, heightArg: number, pressure: number, rotation: number, tiltX: number, tiltY: number, pointerIdArg: number, pointerType: any, hwTimestampArg: number, isPrimary: boolean): void; -} - -declare var MSPointerEvent: { - prototype: MSPointerEvent; - new(typeArg: string, eventInitDict?: PointerEventInit): MSPointerEvent; -}; - interface MSStream { readonly type: string; msClose(): void; @@ -10436,7 +10268,6 @@ declare var MediaStreamEvent: { interface MediaStreamTrackEventMap { "ended": Event; - "isolationchange": Event; "mute": Event; "unmute": Event; } @@ -10445,12 +10276,10 @@ interface MediaStreamTrackEventMap { interface MediaStreamTrack extends EventTarget { enabled: boolean; readonly id: string; - readonly isolated: boolean; readonly kind: string; readonly label: string; readonly muted: boolean; onended: ((this: MediaStreamTrack, ev: Event) => any) | null; - onisolationchange: ((this: MediaStreamTrack, ev: Event) => any) | null; onmute: ((this: MediaStreamTrack, ev: Event) => any) | null; onunmute: ((this: MediaStreamTrack, ev: Event) => any) | null; readonly readyState: MediaStreamTrackState; @@ -10550,7 +10379,7 @@ interface MessagePort extends EventTarget { close(): void; /** * Posts a message through the channel. Objects listed in transfer are transferred, not just cloned, meaning that they are no longer usable on the sending side. - * + * * Throws a "DataCloneError" DOMException if transfer contains duplicate objects or port, or if message could not be cloned. */ postMessage(message: any, transfer: Transferable[]): void; @@ -10668,7 +10497,7 @@ interface MutationObserver { disconnect(): void; /** * Instructs the user agent to observe a given target (a node) and report any mutations based on the criteria given by options (an object). - * + * * The options argument allows for setting mutation observation options via object members. */ observe(target: Node, options?: MutationObserverInit): void; @@ -11258,27 +11087,27 @@ declare var OfflineAudioContext: { interface OffscreenCanvas extends EventTarget { /** * These attributes return the dimensions of the OffscreenCanvas object's bitmap. - * + * * They can be set, to replace the bitmap with a new, transparent black bitmap of the specified dimensions (effectively resizing it). */ height: number; /** * These attributes return the dimensions of the OffscreenCanvas object's bitmap. - * + * * They can be set, to replace the bitmap with a new, transparent black bitmap of the specified dimensions (effectively resizing it). */ width: number; /** * Returns a promise that will fulfill with a new Blob object representing a file containing the image in the OffscreenCanvas object. - * + * * The argument, if provided, is a dictionary that controls the encoding options of the image file to be created. The type field specifies the file format and has a default value of "image/png"; that type is also used if the requested type isn't supported. If the image format supports variable quality (such as "image/jpeg"), then the quality field is a number in the range 0.0 to 1.0 inclusive indicating the desired quality level for the resulting image. */ convertToBlob(options?: ImageEncodeOptions): Promise; /** * Returns an object that exposes an API for drawing on the OffscreenCanvas object. contextId specifies the desired API: "2d", "bitmaprenderer", "webgl", or "webgl2". options is handled by that API. - * + * * This specification defines the "2d" context below, which is similar but distinct from the "2d" context that is created from a canvas element. The WebGL specifications define the "webgl" and "webgl2" contexts. [WEBGL] - * + * * Returns null if the canvas has already been initialized with another context type (e.g., trying to get a "2d" context after getting a "webgl" context). */ getContext(contextId: "2d", options?: CanvasRenderingContext2DSettings): OffscreenCanvasRenderingContext2D | null; @@ -11354,11 +11183,11 @@ declare var OverflowEvent: { interface PageTransitionEvent extends Event { /** * For the pageshow event, returns false if the page is newly being loaded (and the load event will fire). Otherwise, returns true. - * + * * For the pagehide event, returns false if the page is going away for the last time. Otherwise, returns true, meaning that (if nothing conspires to make the page unsalvageable) the page might be reused if the user navigates back to this page. - * + * * Things that can cause the page to be unsalvageable include: - * + * * Listening for beforeunload events * Listening for unload events * Having iframes that are not salvageable @@ -11416,13 +11245,13 @@ interface ParentNode { readonly lastElementChild: Element | null; /** * Inserts nodes after the last child of node, while replacing strings in nodes with equivalent Text nodes. - * + * * Throws a "HierarchyRequestError" DOMException if the constraints of the node tree are violated. */ append(...nodes: (Node | string)[]): void; /** * Inserts nodes before the first child of node, while replacing strings in nodes with equivalent Text nodes. - * + * * Throws a "HierarchyRequestError" DOMException if the constraints of the node tree are violated. */ prepend(...nodes: (Node | string)[]): void; @@ -11455,11 +11284,10 @@ declare var Path2D: { /** This Payment Request API interface is used to store shipping or payment address information. */ interface PaymentAddress { - readonly addressLine: string[]; + readonly addressLine: ReadonlyArray; readonly city: string; readonly country: string; readonly dependentLocality: string; - readonly languageCode: string; readonly organization: string; readonly phone: string; readonly postalCode: string; @@ -11474,7 +11302,18 @@ declare var PaymentAddress: { new(): PaymentAddress; }; +interface PaymentMethodChangeEvent extends PaymentRequestUpdateEvent { + readonly methodDetails: any; + readonly methodName: string; +} + +declare var PaymentMethodChangeEvent: { + prototype: PaymentMethodChangeEvent; + new(type: string, eventInitDict?: PaymentMethodChangeEventInit): PaymentMethodChangeEvent; +}; + interface PaymentRequestEventMap { + "paymentmethodchange": Event; "shippingaddresschange": Event; "shippingoptionchange": Event; } @@ -11482,6 +11321,7 @@ interface PaymentRequestEventMap { /** This Payment Request API interface is the primary access point into the API, and lets web content and apps accept payments from the end user. */ interface PaymentRequest extends EventTarget { readonly id: string; + onpaymentmethodchange: ((this: PaymentRequest, ev: Event) => any) | null; onshippingaddresschange: ((this: PaymentRequest, ev: Event) => any) | null; onshippingoptionchange: ((this: PaymentRequest, ev: Event) => any) | null; readonly shippingAddress: PaymentAddress | null; @@ -11489,7 +11329,7 @@ interface PaymentRequest extends EventTarget { readonly shippingType: PaymentShippingType | null; abort(): Promise; canMakePayment(): Promise; - show(): Promise; + show(detailsPromise: PaymentDetailsUpdate | Promise): Promise; addEventListener(type: K, listener: (this: PaymentRequest, ev: PaymentRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: PaymentRequest, ev: PaymentRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void; @@ -11511,10 +11351,15 @@ declare var PaymentRequestUpdateEvent: { new(type: string, eventInitDict?: PaymentRequestUpdateEventInit): PaymentRequestUpdateEvent; }; +interface PaymentResponseEventMap { + "payerdetailchange": Event; +} + /** This Payment Request API interface is returned after a user selects a payment method and approves a payment request. */ -interface PaymentResponse { +interface PaymentResponse extends EventTarget { readonly details: any; readonly methodName: string; + onpayerdetailchange: ((this: PaymentResponse, ev: Event) => any) | null; readonly payerEmail: string | null; readonly payerName: string | null; readonly payerPhone: string | null; @@ -11522,7 +11367,12 @@ interface PaymentResponse { readonly shippingAddress: PaymentAddress | null; readonly shippingOption: string | null; complete(result?: PaymentComplete): Promise; + retry(errorFields?: PaymentValidationErrors): Promise; toJSON(): any; + addEventListener(type: K, listener: (this: PaymentResponse, ev: PaymentResponseEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + removeEventListener(type: K, listener: (this: PaymentResponse, ev: PaymentResponseEventMap[K]) => any, options?: boolean | EventListenerOptions): void; + removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; } declare var PaymentResponse: { @@ -11976,7 +11826,6 @@ interface RTCCertificate { declare var RTCCertificate: { prototype: RTCCertificate; new(): RTCCertificate; - getSupportedAlgorithms(): AlgorithmIdentifier[]; }; interface RTCDTMFSenderEventMap { @@ -12006,7 +11855,7 @@ interface RTCDTMFToneChangeEvent extends Event { declare var RTCDTMFToneChangeEvent: { prototype: RTCDTMFToneChangeEvent; - new(type: string, eventInitDict: RTCDTMFToneChangeEventInit): RTCDTMFToneChangeEvent; + new(type: string, eventInitDict?: RTCDTMFToneChangeEventInit): RTCDTMFToneChangeEvent; }; interface RTCDataChannelEventMap { @@ -12018,7 +11867,7 @@ interface RTCDataChannelEventMap { } interface RTCDataChannel extends EventTarget { - binaryType: string; + binaryType: BinaryType; readonly bufferedAmount: number; bufferedAmountLowThreshold: number; readonly id: number | null; @@ -12032,7 +11881,6 @@ interface RTCDataChannel extends EventTarget { onmessage: ((this: RTCDataChannel, ev: MessageEvent) => any) | null; onopen: ((this: RTCDataChannel, ev: Event) => any) | null; readonly ordered: boolean; - readonly priority: RTCPriorityType; readonly protocol: string; readonly readyState: RTCDataChannelState; close(): void; @@ -12116,7 +11964,6 @@ declare var RTCDtmfSender: { interface RTCError extends DOMException { readonly errorDetail: RTCErrorDetailType; - readonly httpRequestStatusCode: number | null; readonly receivedAlert: number | null; readonly sctpCauseCode: number | null; readonly sdpLineNumber: number | null; @@ -12209,7 +12056,6 @@ interface RTCIceTransportEventMap { /** Provides access to information about the ICE transport layer over which the data is being sent and received. */ interface RTCIceTransport extends EventTarget { - readonly component: RTCIceComponent; readonly gatheringState: RTCIceGathererState; ongatheringstatechange: ((this: RTCIceTransport, ev: Event) => any) | null; onselectedcandidatepairchange: ((this: RTCIceTransport, ev: Event) => any) | null; @@ -12260,7 +12106,6 @@ interface RTCPeerConnectionEventMap { "icegatheringstatechange": Event; "negotiationneeded": Event; "signalingstatechange": Event; - "statsended": RTCStatsEvent; "track": RTCTrackEvent; } @@ -12283,7 +12128,6 @@ interface RTCPeerConnection extends EventTarget { onicegatheringstatechange: ((this: RTCPeerConnection, ev: Event) => any) | null; onnegotiationneeded: ((this: RTCPeerConnection, ev: Event) => any) | null; onsignalingstatechange: ((this: RTCPeerConnection, ev: Event) => any) | null; - onstatsended: ((this: RTCPeerConnection, ev: RTCStatsEvent) => any) | null; ontrack: ((this: RTCPeerConnection, ev: RTCTrackEvent) => any) | null; readonly peerIdentity: Promise; readonly pendingLocalDescription: RTCSessionDescription | null; @@ -12305,9 +12149,10 @@ interface RTCPeerConnection extends EventTarget { getStats(selector?: MediaStreamTrack | null): Promise; getTransceivers(): RTCRtpTransceiver[]; removeTrack(sender: RTCRtpSender): void; - setConfiguration(configuration: RTCConfiguration): void; + restartIce(): void; + setConfiguration(configuration?: RTCConfiguration): void; setIdentityProvider(provider: string, options?: RTCIdentityProviderOptions): void; - setLocalDescription(description: RTCSessionDescriptionInit): Promise; + setLocalDescription(description?: RTCSessionDescriptionInit): Promise; setRemoteDescription(description: RTCSessionDescriptionInit): Promise; addEventListener(type: K, listener: (this: RTCPeerConnection, ev: RTCPeerConnectionEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; @@ -12319,13 +12164,13 @@ declare var RTCPeerConnection: { prototype: RTCPeerConnection; new(configuration?: RTCConfiguration): RTCPeerConnection; generateCertificate(keygenAlgorithm: AlgorithmIdentifier): Promise; - getDefaultIceServers(): RTCIceServer[]; }; interface RTCPeerConnectionIceErrorEvent extends Event { + readonly address: string | null; readonly errorCode: number; readonly errorText: string; - readonly hostCandidate: string; + readonly port: number | null; readonly url: string; } @@ -12337,7 +12182,6 @@ declare var RTCPeerConnectionIceErrorEvent: { /** Events that occurs in relation to ICE candidates with the target, usually an RTCPeerConnection. Only one event is of this type: icecandidate. */ interface RTCPeerConnectionIceEvent extends Event { readonly candidate: RTCIceCandidate | null; - readonly url: string | null; } declare var RTCPeerConnectionIceEvent: { @@ -12347,7 +12191,6 @@ declare var RTCPeerConnectionIceEvent: { /** This WebRTC API interface manages the reception and decoding of data for a MediaStreamTrack on an RTCPeerConnection. */ interface RTCRtpReceiver { - readonly rtcpTransport: RTCDtlsTransport | null; readonly track: MediaStreamTrack; readonly transport: RTCDtlsTransport | null; getContributingSources(): RTCRtpContributingSource[]; @@ -12365,7 +12208,6 @@ declare var RTCRtpReceiver: { /** Provides the ability to control and obtain details about how a particular MediaStreamTrack is encoded and sent to a remote peer. */ interface RTCRtpSender { readonly dtmf: RTCDTMFSender | null; - readonly rtcpTransport: RTCDtlsTransport | null; readonly track: MediaStreamTrack | null; readonly transport: RTCDtlsTransport | null; getParameters(): RTCRtpSendParameters; @@ -12426,7 +12268,7 @@ interface RTCSessionDescription { declare var RTCSessionDescription: { prototype: RTCSessionDescription; - new(descriptionInitDict?: RTCSessionDescriptionInit): RTCSessionDescription; + new(descriptionInitDict: RTCSessionDescriptionInit): RTCSessionDescription; }; interface RTCSrtpSdesTransportEventMap { @@ -12457,15 +12299,6 @@ declare var RTCSsrcConflictEvent: { new(): RTCSsrcConflictEvent; }; -interface RTCStatsEvent extends Event { - readonly report: RTCStatsReport; -} - -declare var RTCStatsEvent: { - prototype: RTCStatsEvent; - new(type: string, eventInitDict: RTCStatsEventInit): RTCStatsEvent; -}; - interface RTCStatsProvider extends EventTarget { getStats(): Promise; msGetStats(): Promise; @@ -13947,46 +13780,6 @@ declare var SVGNumberList: { interface SVGPathElement extends SVGGraphicsElement { /** @deprecated */ readonly pathSegList: SVGPathSegList; - /** @deprecated */ - createSVGPathSegArcAbs(x: number, y: number, r1: number, r2: number, angle: number, largeArcFlag: boolean, sweepFlag: boolean): SVGPathSegArcAbs; - /** @deprecated */ - createSVGPathSegArcRel(x: number, y: number, r1: number, r2: number, angle: number, largeArcFlag: boolean, sweepFlag: boolean): SVGPathSegArcRel; - /** @deprecated */ - createSVGPathSegClosePath(): SVGPathSegClosePath; - /** @deprecated */ - createSVGPathSegCurvetoCubicAbs(x: number, y: number, x1: number, y1: number, x2: number, y2: number): SVGPathSegCurvetoCubicAbs; - /** @deprecated */ - createSVGPathSegCurvetoCubicRel(x: number, y: number, x1: number, y1: number, x2: number, y2: number): SVGPathSegCurvetoCubicRel; - /** @deprecated */ - createSVGPathSegCurvetoCubicSmoothAbs(x: number, y: number, x2: number, y2: number): SVGPathSegCurvetoCubicSmoothAbs; - /** @deprecated */ - createSVGPathSegCurvetoCubicSmoothRel(x: number, y: number, x2: number, y2: number): SVGPathSegCurvetoCubicSmoothRel; - /** @deprecated */ - createSVGPathSegCurvetoQuadraticAbs(x: number, y: number, x1: number, y1: number): SVGPathSegCurvetoQuadraticAbs; - /** @deprecated */ - createSVGPathSegCurvetoQuadraticRel(x: number, y: number, x1: number, y1: number): SVGPathSegCurvetoQuadraticRel; - /** @deprecated */ - createSVGPathSegCurvetoQuadraticSmoothAbs(x: number, y: number): SVGPathSegCurvetoQuadraticSmoothAbs; - /** @deprecated */ - createSVGPathSegCurvetoQuadraticSmoothRel(x: number, y: number): SVGPathSegCurvetoQuadraticSmoothRel; - /** @deprecated */ - createSVGPathSegLinetoAbs(x: number, y: number): SVGPathSegLinetoAbs; - /** @deprecated */ - createSVGPathSegLinetoHorizontalAbs(x: number): SVGPathSegLinetoHorizontalAbs; - /** @deprecated */ - createSVGPathSegLinetoHorizontalRel(x: number): SVGPathSegLinetoHorizontalRel; - /** @deprecated */ - createSVGPathSegLinetoRel(x: number, y: number): SVGPathSegLinetoRel; - /** @deprecated */ - createSVGPathSegLinetoVerticalAbs(y: number): SVGPathSegLinetoVerticalAbs; - /** @deprecated */ - createSVGPathSegLinetoVerticalRel(y: number): SVGPathSegLinetoVerticalRel; - /** @deprecated */ - createSVGPathSegMovetoAbs(x: number, y: number): SVGPathSegMovetoAbs; - /** @deprecated */ - createSVGPathSegMovetoRel(x: number, y: number): SVGPathSegMovetoRel; - /** @deprecated */ - getPathSegAtLength(distance: number): number; getPointAtLength(distance: number): SVGPoint; getTotalLength(): number; addEventListener(type: K, listener: (this: SVGPathElement, ev: SVGElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; @@ -14424,25 +14217,11 @@ interface SVGSVGElementEventMap extends SVGElementEventMap { /** Provides access to the properties of elements, as well as methods to manipulate them. This interface contains also various miscellaneous commonly-used utility methods, such as matrix operations and the ability to control the time of redraw on visual rendering devices. */ interface SVGSVGElement extends SVGGraphicsElement, DocumentEvent, SVGFitToViewBox, SVGZoomAndPan { - /** @deprecated */ - contentScriptType: string; - /** @deprecated */ - contentStyleType: string; currentScale: number; readonly currentTranslate: SVGPoint; readonly height: SVGAnimatedLength; onunload: ((this: SVGSVGElement, ev: Event) => any) | null; onzoom: ((this: SVGSVGElement, ev: SVGZoomEvent) => any) | null; - /** @deprecated */ - readonly pixelUnitToMillimeterX: number; - /** @deprecated */ - readonly pixelUnitToMillimeterY: number; - /** @deprecated */ - readonly screenPixelToMillimeterX: number; - /** @deprecated */ - readonly screenPixelToMillimeterY: number; - /** @deprecated */ - readonly viewport: SVGRect; readonly width: SVGAnimatedLength; readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; @@ -14770,9 +14549,7 @@ declare var SVGUnitTypes: { /** Corresponds to the element. */ interface SVGUseElement extends SVGGraphicsElement, SVGURIReference { - readonly animatedInstanceRoot: SVGElementInstance | null; readonly height: SVGAnimatedLength; - readonly instanceRoot: SVGElementInstance | null; readonly width: SVGAnimatedLength; readonly x: SVGAnimatedLength; readonly y: SVGAnimatedLength; @@ -14805,16 +14582,12 @@ declare var SVGViewElement: { readonly SVG_ZOOMANDPAN_UNKNOWN: number; }; -/** Used to reflect the zoomAndPan attribute, and is mixed in to other interfaces for elements that support this attribute. */ interface SVGZoomAndPan { - readonly zoomAndPan: number; -} - -declare var SVGZoomAndPan: { + zoomAndPan: number; readonly SVG_ZOOMANDPAN_DISABLE: number; readonly SVG_ZOOMANDPAN_MAGNIFY: number; readonly SVG_ZOOMANDPAN_UNKNOWN: number; -}; +} interface SVGZoomEvent extends UIEvent { readonly newScale: number; @@ -14829,26 +14602,6 @@ declare var SVGZoomEvent: { new(): SVGZoomEvent; }; -interface ScopedCredential { - readonly id: ArrayBuffer; - readonly type: ScopedCredentialType; -} - -declare var ScopedCredential: { - prototype: ScopedCredential; - new(): ScopedCredential; -}; - -interface ScopedCredentialInfo { - readonly credential: ScopedCredential; - readonly publicKey: CryptoKey; -} - -declare var ScopedCredentialInfo: { - prototype: ScopedCredentialInfo; - new(): ScopedCredentialInfo; -}; - /** A screen, usually the one on which the current window is being rendered, and is obtained using window.screen. */ interface Screen { readonly availHeight: number; @@ -15016,22 +14769,6 @@ declare var ServiceWorkerContainer: { new(): ServiceWorkerContainer; }; -/** This ServiceWorker API interface contains information about an event sent to a ServiceWorkerContainer target. This extends the default message event to allow setting a ServiceWorker object as the source of a message. The event object is accessed via the handler function of a message event, when fired by a message received from a service worker. - * @deprecated In modern browsers, this interface has been deprecated. Service worker messages will now use the MessageEvent interface, for consistency with other web messaging features. - */ -interface ServiceWorkerMessageEvent extends Event { - readonly data: any; - readonly lastEventId: string; - readonly origin: string; - readonly ports: ReadonlyArray | null; - readonly source: ServiceWorker | MessagePort | null; -} - -declare var ServiceWorkerMessageEvent: { - prototype: ServiceWorkerMessageEvent; - new(type: string, eventInitDict?: ServiceWorkerMessageEventInit): ServiceWorkerMessageEvent; -}; - interface ServiceWorkerRegistrationEventMap { "updatefound": Event; } @@ -15414,7 +15151,7 @@ interface Storage { removeItem(key: string): void; /** * Sets the value of the pair identified by key to value, creating a new key/value pair if none existed for key previously. - * + * * Throws a "QuotaExceededError" DOMException exception if the new value couldn't be set. (Setting could fail if, e.g., the user has disabled storage for the site, or if the quota has been exceeded.) */ setItem(key: string, value: string): void; @@ -15564,7 +15301,7 @@ declare var Text: { interface TextDecoder extends TextDecoderCommon { /** * Returns the result of running encoding's decoder. The method can be invoked zero or more times with options's stream set to true, and then once without options's stream (or set to false), to process a fragmented input. If the invocation without options's stream (or set to false) has no input, it's clearest to omit both arguments. - * + * * ``` * var string = "", decoder = new TextDecoder(encoding), buffer; * while(buffer = next_chunk()) { @@ -15572,7 +15309,7 @@ interface TextDecoder extends TextDecoderCommon { * } * string += decoder.decode(); // end-of-queue * ``` - * + * * If the error mode is "fatal" and encoding's decoder returns error, throws a TypeError. */ decode(input?: BufferSource, options?: TextDecodeOptions): string; @@ -15690,34 +15427,6 @@ interface TextMetrics { * Returns the measurement described below. */ readonly actualBoundingBoxRight: number; - /** - * Returns the measurement described below. - */ - readonly alphabeticBaseline: number; - /** - * Returns the measurement described below. - */ - readonly emHeightAscent: number; - /** - * Returns the measurement described below. - */ - readonly emHeightDescent: number; - /** - * Returns the measurement described below. - */ - readonly fontBoundingBoxAscent: number; - /** - * Returns the measurement described below. - */ - readonly fontBoundingBoxDescent: number; - /** - * Returns the measurement described below. - */ - readonly hangingBaseline: number; - /** - * Returns the measurement described below. - */ - readonly ideographicBaseline: number; /** * Returns the measurement described below. */ @@ -15745,9 +15454,9 @@ interface TextTrack extends EventTarget { readonly cues: TextTrackCueList | null; /** * Returns the ID of the given track. - * + * * For in-band tracks, this is the ID that can be used with a fragment if the format supports media fragment syntax, and that can be used with the getTrackById() method. - * + * * For TextTrack objects corresponding to track elements, this is the ID of the track element. */ readonly id: string; @@ -15769,12 +15478,11 @@ interface TextTrack extends EventTarget { readonly language: string; /** * Returns the text track mode, represented by a string from the following list: - * + * * Can be set, to change the mode. */ mode: TextTrackMode; oncuechange: ((this: TextTrack, ev: Event) => any) | null; - readonly sourceBuffer: SourceBuffer | null; /** * Adds the given cue to textTrack's text track list of cues. */ @@ -15803,13 +15511,13 @@ interface TextTrackCueEventMap { interface TextTrackCue extends EventTarget { /** * Returns the text track cue end time, in seconds. - * + * * Can be set. */ endTime: number; /** * Returns the text track cue identifier. - * + * * Can be set. */ id: string; @@ -15817,13 +15525,13 @@ interface TextTrackCue extends EventTarget { onexit: ((this: TextTrackCue, ev: Event) => any) | null; /** * Returns true if the text track cue pause-on-exit flag is set, false otherwise. - * + * * Can be set. */ pauseOnExit: boolean; /** * Returns the text track cue start time, in seconds. - * + * * Can be set. */ startTime: number; @@ -15849,7 +15557,7 @@ interface TextTrackCueList { readonly length: number; /** * Returns the first text track cue (in text track cue order) with text track cue identifier id. - * + * * Returns null if none of the cues have the given identifier or if the argument is the empty string. */ getCueById(id: string): TextTrackCue | null; @@ -15893,13 +15601,13 @@ interface TimeRanges { readonly length: number; /** * Returns the time for the end of the range with the given index. - * + * * Throws an "IndexSizeError" DOMException if the index is out of range. */ end(index: number): number; /** * Returns the time for the start of the range with the given index. - * + * * Throws an "IndexSizeError" DOMException if the index is out of range. */ start(index: number): number; @@ -16212,7 +15920,6 @@ interface VRPose { readonly linearVelocity: Float32Array | null; readonly orientation: Float32Array | null; readonly position: Float32Array | null; - readonly timestamp: number; } declare var VRPose: { @@ -16439,28 +16146,6 @@ declare var WaveShaperNode: { new(context: BaseAudioContext, options?: WaveShaperOptions): WaveShaperNode; }; -interface WebAuthentication { - getAssertion(assertionChallenge: Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array | DataView | ArrayBuffer | null, options?: AssertionOptions): Promise; - makeCredential(accountInformation: Account, cryptoParameters: ScopedCredentialParameters[], attestationChallenge: Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array | DataView | ArrayBuffer | null, options?: ScopedCredentialOptions): Promise; -} - -declare var WebAuthentication: { - prototype: WebAuthentication; - new(): WebAuthentication; -}; - -interface WebAuthnAssertion { - readonly authenticatorData: ArrayBuffer; - readonly clientData: ArrayBuffer; - readonly credential: ScopedCredential; - readonly signature: ArrayBuffer; -} - -declare var WebAuthnAssertion: { - prototype: WebAuthnAssertion; - new(): WebAuthnAssertion; -}; - interface WebGL2RenderingContext extends WebGL2RenderingContextBase, WebGL2RenderingContextOverloads, WebGLRenderingContextBase { } @@ -17438,7 +17123,7 @@ declare var WebGLActiveInfo: { }; /** Part of the WebGL API and represents an opaque buffer object storing data such as vertices or colors. */ -interface WebGLBuffer extends WebGLObject { +interface WebGLBuffer { } declare var WebGLBuffer: { @@ -17457,7 +17142,7 @@ declare var WebGLContextEvent: { }; /** Part of the WebGL API and represents a collection of buffers that serve as a rendering destination. */ -interface WebGLFramebuffer extends WebGLObject { +interface WebGLFramebuffer { } declare var WebGLFramebuffer: { @@ -17465,16 +17150,8 @@ declare var WebGLFramebuffer: { new(): WebGLFramebuffer; }; -interface WebGLObject { -} - -declare var WebGLObject: { - prototype: WebGLObject; - new(): WebGLObject; -}; - /** The WebGLProgram is part of the WebGL API and is a combination of two compiled WebGLShaders consisting of a vertex shader and a fragment shader (both written in GLSL). */ -interface WebGLProgram extends WebGLObject { +interface WebGLProgram { } declare var WebGLProgram: { @@ -17482,7 +17159,7 @@ declare var WebGLProgram: { new(): WebGLProgram; }; -interface WebGLQuery extends WebGLObject { +interface WebGLQuery { } declare var WebGLQuery: { @@ -17491,7 +17168,7 @@ declare var WebGLQuery: { }; /** Part of the WebGL API and represents a buffer that can contain an image, or can be source or target of an rendering operation. */ -interface WebGLRenderbuffer extends WebGLObject { +interface WebGLRenderbuffer { } declare var WebGLRenderbuffer: { @@ -18270,7 +17947,7 @@ interface WebGLRenderingContextOverloads { uniformMatrix4fv(location: WebGLUniformLocation | null, transpose: GLboolean, value: Float32List): void; } -interface WebGLSampler extends WebGLObject { +interface WebGLSampler { } declare var WebGLSampler: { @@ -18279,7 +17956,7 @@ declare var WebGLSampler: { }; /** The WebGLShader is part of the WebGL API and can either be a vertex or a fragment shader. A WebGLProgram requires both types of shaders. */ -interface WebGLShader extends WebGLObject { +interface WebGLShader { } declare var WebGLShader: { @@ -18299,7 +17976,7 @@ declare var WebGLShaderPrecisionFormat: { new(): WebGLShaderPrecisionFormat; }; -interface WebGLSync extends WebGLObject { +interface WebGLSync { } declare var WebGLSync: { @@ -18308,7 +17985,7 @@ declare var WebGLSync: { }; /** Part of the WebGL API and represents an opaque texture object providing storage and state for texturing operations. */ -interface WebGLTexture extends WebGLObject { +interface WebGLTexture { } declare var WebGLTexture: { @@ -18316,7 +17993,7 @@ declare var WebGLTexture: { new(): WebGLTexture; }; -interface WebGLTransformFeedback extends WebGLObject { +interface WebGLTransformFeedback { } declare var WebGLTransformFeedback: { @@ -18333,7 +18010,7 @@ declare var WebGLUniformLocation: { new(): WebGLUniformLocation; }; -interface WebGLVertexArrayObject extends WebGLObject { +interface WebGLVertexArrayObject { } declare var WebGLVertexArrayObject: { @@ -18341,7 +18018,7 @@ declare var WebGLVertexArrayObject: { new(): WebGLVertexArrayObject; }; -interface WebGLVertexArrayObjectOES extends WebGLObject { +interface WebGLVertexArrayObjectOES { } interface WebKitPoint { @@ -18365,13 +18042,13 @@ interface WebSocketEventMap { interface WebSocket extends EventTarget { /** * Returns a string that indicates how binary data from the WebSocket object is exposed to scripts: - * + * * Can be set, to change how binary data is returned. The default is "blob". */ binaryType: BinaryType; /** * Returns the number of bytes of application data (UTF-8 text and binary data) that have been queued using send() but not yet been transmitted to the network. - * + * * If the WebSocket connection is closed, this attribute's value will only increase with each call to the send() method. (The number does not reset to zero once the connection closes.) */ readonly bufferedAmount: number; @@ -18454,7 +18131,6 @@ interface WindowEventMap extends GlobalEventHandlersEventMap, WindowEventHandler "compassneedscalibration": Event; "contextmenu": MouseEvent; "dblclick": MouseEvent; - "devicelight": DeviceLightEvent; "devicemotion": DeviceMotionEvent; "deviceorientation": DeviceOrientationEvent; "deviceorientationabsolute": DeviceOrientationEvent; @@ -18491,21 +18167,6 @@ interface WindowEventMap extends GlobalEventHandlersEventMap, WindowEventHandler "mouseover": MouseEvent; "mouseup": MouseEvent; "mousewheel": Event; - "MSGestureChange": Event; - "MSGestureDoubleTap": Event; - "MSGestureEnd": Event; - "MSGestureHold": Event; - "MSGestureStart": Event; - "MSGestureTap": Event; - "MSInertiaStart": Event; - "MSPointerCancel": Event; - "MSPointerDown": Event; - "MSPointerEnter": Event; - "MSPointerLeave": Event; - "MSPointerMove": Event; - "MSPointerOut": Event; - "MSPointerOver": Event; - "MSPointerUp": Event; "offline": Event; "online": Event; "orientationchange": Event; @@ -18536,9 +18197,6 @@ interface WindowEventMap extends GlobalEventHandlersEventMap, WindowEventHandler "vrdisplayconnect": Event; "vrdisplaydeactivate": Event; "vrdisplaydisconnect": Event; - "vrdisplayfocus": Event; - "vrdisplaypointerrestricted": Event; - "vrdisplaypointerunrestricted": Event; "vrdisplaypresentchange": Event; "waiting": Event; } @@ -18571,28 +18229,12 @@ interface Window extends EventTarget, AnimationFrameProvider, GlobalEventHandler readonly navigator: Navigator; offscreenBuffering: string | boolean; oncompassneedscalibration: ((this: Window, ev: Event) => any) | null; - ondevicelight: ((this: Window, ev: DeviceLightEvent) => any) | null; ondevicemotion: ((this: Window, ev: DeviceMotionEvent) => any) | null; ondeviceorientation: ((this: Window, ev: DeviceOrientationEvent) => any) | null; ondeviceorientationabsolute: ((this: Window, ev: DeviceOrientationEvent) => any) | null; ongamepadconnected: ((this: Window, ev: GamepadEvent) => any) | null; ongamepaddisconnected: ((this: Window, ev: GamepadEvent) => any) | null; onmousewheel: ((this: Window, ev: Event) => any) | null; - onmsgesturechange: ((this: Window, ev: Event) => any) | null; - onmsgesturedoubletap: ((this: Window, ev: Event) => any) | null; - onmsgestureend: ((this: Window, ev: Event) => any) | null; - onmsgesturehold: ((this: Window, ev: Event) => any) | null; - onmsgesturestart: ((this: Window, ev: Event) => any) | null; - onmsgesturetap: ((this: Window, ev: Event) => any) | null; - onmsinertiastart: ((this: Window, ev: Event) => any) | null; - onmspointercancel: ((this: Window, ev: Event) => any) | null; - onmspointerdown: ((this: Window, ev: Event) => any) | null; - onmspointerenter: ((this: Window, ev: Event) => any) | null; - onmspointerleave: ((this: Window, ev: Event) => any) | null; - onmspointermove: ((this: Window, ev: Event) => any) | null; - onmspointerout: ((this: Window, ev: Event) => any) | null; - onmspointerover: ((this: Window, ev: Event) => any) | null; - onmspointerup: ((this: Window, ev: Event) => any) | null; /** @deprecated */ onorientationchange: ((this: Window, ev: Event) => any) | null; onreadystatechange: ((this: Window, ev: ProgressEvent) => any) | null; @@ -18601,11 +18243,8 @@ interface Window extends EventTarget, AnimationFrameProvider, GlobalEventHandler onvrdisplayconnect: ((this: Window, ev: Event) => any) | null; onvrdisplaydeactivate: ((this: Window, ev: Event) => any) | null; onvrdisplaydisconnect: ((this: Window, ev: Event) => any) | null; - onvrdisplayfocus: ((this: Window, ev: Event) => any) | null; - onvrdisplaypointerrestricted: ((this: Window, ev: Event) => any) | null; - onvrdisplaypointerunrestricted: ((this: Window, ev: Event) => any) | null; onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null; - opener: any; + opener: WindowProxy | null; /** @deprecated */ readonly orientation: string | number; readonly outerHeight: number; @@ -18852,26 +18491,26 @@ interface XMLHttpRequest extends XMLHttpRequestEventTarget { readonly response: any; /** * Returns the text response. - * + * * Throws an "InvalidStateError" DOMException if responseType is not the empty string or "text". */ readonly responseText: string; /** * Returns the response type. - * + * * Can be set to change the response type. Values are: the empty string (default), "arraybuffer", "blob", "document", "json", and "text". - * + * * When set: setting to "document" is ignored if current global object is not a Window object. - * + * * When set: throws an "InvalidStateError" DOMException if state is loading or done. - * + * * When set: throws an "InvalidAccessError" DOMException if the synchronous flag is set and current global object is a Window object. */ responseType: XMLHttpRequestResponseType; readonly responseURL: string; /** * Returns the document response. - * + * * Throws an "InvalidStateError" DOMException if responseType is not the empty string or "document". */ readonly responseXML: Document | null; @@ -18879,7 +18518,7 @@ interface XMLHttpRequest extends XMLHttpRequestEventTarget { readonly statusText: string; /** * Can be set to a time in milliseconds. When set to a non-zero value will cause fetching to terminate after the given time has passed. When the time has passed, the request has not yet completed, and the synchronous flag is unset, a timeout event will then be dispatched, or a "TimeoutError" DOMException will be thrown otherwise (for the send() method). - * + * * When set: throws an "InvalidAccessError" DOMException if the synchronous flag is set and current global object is a Window object. */ timeout: number; @@ -18889,7 +18528,7 @@ interface XMLHttpRequest extends XMLHttpRequestEventTarget { readonly upload: XMLHttpRequestUpload; /** * True when credentials are to be included in a cross-origin request. False when they are to be excluded in a cross-origin request and when cookies are to be ignored in its response. Initially false. - * + * * When set: throws an "InvalidStateError" DOMException if state is not unsent or opened, or if the send() flag is set. */ withCredentials: boolean; @@ -18901,32 +18540,32 @@ interface XMLHttpRequest extends XMLHttpRequestEventTarget { getResponseHeader(name: string): string | null; /** * Sets the request method, request URL, and synchronous flag. - * + * * Throws a "SyntaxError" DOMException if either method is not a valid HTTP method or url cannot be parsed. - * + * * Throws a "SecurityError" DOMException if method is a case-insensitive match for `CONNECT`, `TRACE`, or `TRACK`. - * + * * Throws an "InvalidAccessError" DOMException if async is false, current global object is a Window object, and the timeout attribute is not zero or the responseType attribute is not the empty string. */ open(method: string, url: string): void; open(method: string, url: string, async: boolean, username?: string | null, password?: string | null): void; /** * Acts as if the `Content-Type` header value for response is mime. (It does not actually change the header though.) - * + * * Throws an "InvalidStateError" DOMException if state is loading or done. */ overrideMimeType(mime: string): void; /** * Initiates the request. The body argument provides the request body, if any, and is ignored if the request method is GET or HEAD. - * + * * Throws an "InvalidStateError" DOMException if either state is not opened or the send() flag is set. */ send(body?: Document | BodyInit | null): void; /** * Combines a header in author request headers. - * + * * Throws an "InvalidStateError" DOMException if either state is not opened or the send() flag is set. - * + * * Throws a "SyntaxError" DOMException if name is not a header name or if value is not a header value. */ setRequestHeader(name: string, value: string): void; @@ -19133,52 +18772,52 @@ declare namespace CSS { declare namespace WebAssembly { interface CompileError { } - + var CompileError: { prototype: CompileError; new(): CompileError; }; - + interface Global { value: any; valueOf(): any; } - + var Global: { prototype: Global; new(descriptor: GlobalDescriptor, v?: any): Global; }; - + interface Instance { readonly exports: Exports; } - + var Instance: { prototype: Instance; new(module: Module, importObject?: Imports): Instance; }; - + interface LinkError { } - + var LinkError: { prototype: LinkError; new(): LinkError; }; - + interface Memory { readonly buffer: ArrayBuffer; grow(delta: number): number; } - + var Memory: { prototype: Memory; new(descriptor: MemoryDescriptor): Memory; }; - + interface Module { } - + var Module: { prototype: Module; new(bytes: BufferSource): Module; @@ -19186,59 +18825,60 @@ declare namespace WebAssembly { exports(moduleObject: Module): ModuleExportDescriptor[]; imports(moduleObject: Module): ModuleImportDescriptor[]; }; - + interface RuntimeError { } - + var RuntimeError: { prototype: RuntimeError; new(): RuntimeError; }; - + interface Table { readonly length: number; get(index: number): Function | null; grow(delta: number): number; set(index: number, value: Function | null): void; } - + var Table: { prototype: Table; new(descriptor: TableDescriptor): Table; }; - + interface GlobalDescriptor { mutable?: boolean; value: ValueType; } - + interface MemoryDescriptor { initial: number; maximum?: number; + shared?: boolean; } - + interface ModuleExportDescriptor { kind: ImportExportKind; name: string; } - + interface ModuleImportDescriptor { kind: ImportExportKind; module: string; name: string; } - + interface TableDescriptor { element: TableKind; initial: number; maximum?: number; } - + interface WebAssemblyInstantiatedSource { instance: Instance; module: Module; } - + type ImportExportKind = "function" | "global" | "memory" | "table"; type TableKind = "anyfunc"; type ValueType = "f32" | "f64" | "i32" | "i64"; @@ -19406,7 +19046,6 @@ interface HTMLElementTagNameMap { "audio": HTMLAudioElement; "b": HTMLElement; "base": HTMLBaseElement; - "basefont": HTMLBaseFontElement; "bdi": HTMLElement; "bdo": HTMLElement; "blockquote": HTMLQuoteElement; @@ -19621,28 +19260,12 @@ declare const name: void; declare var navigator: Navigator; declare var offscreenBuffering: string | boolean; declare var oncompassneedscalibration: ((this: Window, ev: Event) => any) | null; -declare var ondevicelight: ((this: Window, ev: DeviceLightEvent) => any) | null; declare var ondevicemotion: ((this: Window, ev: DeviceMotionEvent) => any) | null; declare var ondeviceorientation: ((this: Window, ev: DeviceOrientationEvent) => any) | null; declare var ondeviceorientationabsolute: ((this: Window, ev: DeviceOrientationEvent) => any) | null; declare var ongamepadconnected: ((this: Window, ev: GamepadEvent) => any) | null; declare var ongamepaddisconnected: ((this: Window, ev: GamepadEvent) => any) | null; declare var onmousewheel: ((this: Window, ev: Event) => any) | null; -declare var onmsgesturechange: ((this: Window, ev: Event) => any) | null; -declare var onmsgesturedoubletap: ((this: Window, ev: Event) => any) | null; -declare var onmsgestureend: ((this: Window, ev: Event) => any) | null; -declare var onmsgesturehold: ((this: Window, ev: Event) => any) | null; -declare var onmsgesturestart: ((this: Window, ev: Event) => any) | null; -declare var onmsgesturetap: ((this: Window, ev: Event) => any) | null; -declare var onmsinertiastart: ((this: Window, ev: Event) => any) | null; -declare var onmspointercancel: ((this: Window, ev: Event) => any) | null; -declare var onmspointerdown: ((this: Window, ev: Event) => any) | null; -declare var onmspointerenter: ((this: Window, ev: Event) => any) | null; -declare var onmspointerleave: ((this: Window, ev: Event) => any) | null; -declare var onmspointermove: ((this: Window, ev: Event) => any) | null; -declare var onmspointerout: ((this: Window, ev: Event) => any) | null; -declare var onmspointerover: ((this: Window, ev: Event) => any) | null; -declare var onmspointerup: ((this: Window, ev: Event) => any) | null; /** @deprecated */ declare var onorientationchange: ((this: Window, ev: Event) => any) | null; declare var onreadystatechange: ((this: Window, ev: ProgressEvent) => any) | null; @@ -19651,11 +19274,8 @@ declare var onvrdisplayblur: ((this: Window, ev: Event) => any) | null; declare var onvrdisplayconnect: ((this: Window, ev: Event) => any) | null; declare var onvrdisplaydeactivate: ((this: Window, ev: Event) => any) | null; declare var onvrdisplaydisconnect: ((this: Window, ev: Event) => any) | null; -declare var onvrdisplayfocus: ((this: Window, ev: Event) => any) | null; -declare var onvrdisplaypointerrestricted: ((this: Window, ev: Event) => any) | null; -declare var onvrdisplaypointerunrestricted: ((this: Window, ev: Event) => any) | null; declare var onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null; -declare var opener: any; +declare var opener: WindowProxy | null; /** @deprecated */ declare var orientation: string | number; declare var outerHeight: number; @@ -20168,15 +19788,13 @@ type PushEncryptionKeyName = "auth" | "p256dh"; type PushPermissionState = "denied" | "granted" | "prompt"; type RTCBundlePolicy = "balanced" | "max-bundle" | "max-compat"; type RTCDataChannelState = "closed" | "closing" | "connecting" | "open"; -type RTCDegradationPreference = "balanced" | "maintain-framerate" | "maintain-resolution"; type RTCDtlsRole = "auto" | "client" | "server"; type RTCDtlsTransportState = "closed" | "connected" | "connecting" | "failed" | "new"; -type RTCDtxStatus = "disabled" | "enabled"; -type RTCErrorDetailType = "data-channel-failure" | "dtls-failure" | "fingerprint-failure" | "hardware-encoder-error" | "hardware-encoder-not-available" | "idp-bad-script-failure" | "idp-execution-failure" | "idp-load-failure" | "idp-need-login" | "idp-timeout" | "idp-tls-failure" | "idp-token-expired" | "idp-token-invalid" | "sctp-failure" | "sdp-syntax-error"; +type RTCErrorDetailType = "data-channel-failure" | "dtls-failure" | "fingerprint-failure" | "hardware-encoder-error" | "hardware-encoder-not-available" | "sctp-failure" | "sdp-syntax-error"; type RTCIceCandidateType = "host" | "prflx" | "relay" | "srflx"; type RTCIceComponent = "rtcp" | "rtp"; type RTCIceConnectionState = "checking" | "closed" | "completed" | "connected" | "disconnected" | "failed" | "new"; -type RTCIceCredentialType = "oauth" | "password"; +type RTCIceCredentialType = "password"; type RTCIceGatherPolicy = "all" | "nohost" | "relay"; type RTCIceGathererState = "complete" | "gathering" | "new"; type RTCIceGatheringState = "complete" | "gathering" | "new"; @@ -20186,8 +19804,7 @@ type RTCIceTcpCandidateType = "active" | "passive" | "so"; type RTCIceTransportPolicy = "all" | "relay"; type RTCIceTransportState = "checking" | "closed" | "completed" | "connected" | "disconnected" | "failed" | "new"; type RTCPeerConnectionState = "closed" | "connected" | "connecting" | "disconnected" | "failed" | "new"; -type RTCPriorityType = "high" | "low" | "medium" | "very-low"; -type RTCRtcpMuxPolicy = "negotiate" | "require"; +type RTCRtcpMuxPolicy = "require"; type RTCRtpTransceiverDirection = "inactive" | "recvonly" | "sendonly" | "sendrecv" | "stopped"; type RTCSctpTransportState = "closed" | "connected" | "connecting"; type RTCSdpType = "answer" | "offer" | "pranswer" | "rollback"; @@ -20206,7 +19823,6 @@ type ResidentKeyRequirement = "discouraged" | "preferred" | "required"; type ResizeObserverBoxOptions = "border-box" | "content-box" | "device-pixel-content-box"; type ResizeQuality = "high" | "low" | "medium" | "pixelated"; type ResponseType = "basic" | "cors" | "default" | "error" | "opaque" | "opaqueredirect"; -type ScopedCredentialType = "ScopedCred"; type ScrollBehavior = "auto" | "smooth"; type ScrollLogicalPosition = "center" | "end" | "nearest" | "start"; type ScrollRestoration = "auto" | "manual"; @@ -20220,7 +19836,6 @@ type SpeechSynthesisErrorCode = "audio-busy" | "audio-hardware" | "canceled" | " type TextTrackKind = "captions" | "chapters" | "descriptions" | "metadata" | "subtitles"; type TextTrackMode = "disabled" | "hidden" | "showing"; type TouchType = "direct" | "stylus"; -type Transport = "ble" | "nfc" | "usb"; type UserVerificationRequirement = "discouraged" | "preferred" | "required"; type VRDisplayEventReason = "mounted" | "navigation" | "requested" | "unmounted"; type VideoFacingModeEnum = "environment" | "left" | "right" | "user"; diff --git a/lib/lib.dom.iterable.d.ts b/lib/lib.dom.iterable.d.ts index ebd56d76790a8..7e86bc19b28f7 100644 --- a/lib/lib.dom.iterable.d.ts +++ b/lib/lib.dom.iterable.d.ts @@ -139,7 +139,7 @@ interface IDBDatabase { interface IDBObjectStore { /** * Creates a new index in store with the given name, keyPath and options and returns a new IDBIndex. If the keyPath and options define constraints that cannot be satisfied with the data already in store the upgrade transaction will abort with a "ConstraintError" DOMException. - * + * * Throws an "InvalidStateError" DOMException if not called within an upgrade transaction. */ createIndex(name: string, keyPath: string | Iterable, options?: IDBIndexParameters): IDBIndex; @@ -287,10 +287,6 @@ interface WEBGL_draw_buffers { drawBuffersWEBGL(buffers: Iterable): void; } -interface WebAuthentication { - makeCredential(accountInformation: Account, cryptoParameters: Iterable, attestationChallenge: Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array | DataView | ArrayBuffer | null, options?: ScopedCredentialOptions): Promise; -} - interface WebGL2RenderingContextBase { clearBufferfv(buffer: GLenum, drawbuffer: GLint, values: Iterable, srcOffset?: GLuint): void; clearBufferiv(buffer: GLenum, drawbuffer: GLint, values: Iterable, srcOffset?: GLuint): void; diff --git a/lib/lib.es2015.core.d.ts b/lib/lib.es2015.core.d.ts index f33038d6df6d0..79901dfe96b56 100644 --- a/lib/lib.es2015.core.d.ts +++ b/lib/lib.es2015.core.d.ts @@ -43,7 +43,7 @@ interface Array { findIndex(predicate: (value: T, index: number, obj: T[]) => unknown, thisArg?: any): number; /** - * Returns the this object after filling the section identified by start and end with value + * Changes all array elements from `start` to `end` index to a static `value` and returns the modified array * @param value value to fill array section with * @param start index to start filling the array at. If start is negative, it is treated as * length+start where length is the length of the array. @@ -268,8 +268,8 @@ interface NumberConstructor { /** * Converts A string to an integer. - * @param s A string to convert into a number. - * @param radix A value between 2 and 36 that specifies the base of the number in numString. + * @param string A string to convert into a number. + * @param radix A value between 2 and 36 that specifies the base of the number in `string`. * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. * All other strings are considered decimal. */ @@ -507,11 +507,13 @@ interface StringConstructor { fromCodePoint(...codePoints: number[]): string; /** - * String.raw is intended for use as a tag function of a Tagged Template String. When called - * as such the first argument will be a well formed template call site object and the rest - * parameter will contain the substitution values. + * String.raw is usually used as a tag function of a Tagged Template String. When called as + * such, the first argument will be a well formed template call site object and the rest + * parameter will contain the substitution values. It can also be called directly, for example, + * to interleave strings and values from your own tag function, and in this case the only thing + * it needs from the first argument is the raw property. * @param template A well-formed template string call site representation. * @param substitutions A set of substitution values. */ - raw(template: TemplateStringsArray, ...substitutions: any[]): string; + raw(template: { raw: readonly string[] | ArrayLike}, ...substitutions: any[]): string; } diff --git a/lib/lib.es2015.iterable.d.ts b/lib/lib.es2015.iterable.d.ts index 0dcbcfab26c83..dc93e76234ea3 100644 --- a/lib/lib.es2015.iterable.d.ts +++ b/lib/lib.es2015.iterable.d.ts @@ -25,7 +25,7 @@ interface SymbolConstructor { * A method that returns the default iterator for an object. Called by the semantics of the * for-of statement. */ - readonly iterator: symbol; + readonly iterator: unique symbol; } interface IteratorYieldResult { @@ -163,7 +163,7 @@ interface MapConstructor { interface WeakMap { } interface WeakMapConstructor { - new (iterable: Iterable<[K, V]>): WeakMap; + new (iterable: Iterable): WeakMap; } interface Set { diff --git a/lib/lib.es2015.symbol.wellknown.d.ts b/lib/lib.es2015.symbol.wellknown.d.ts index b2831957a1aaa..b1e3264368821 100644 --- a/lib/lib.es2015.symbol.wellknown.d.ts +++ b/lib/lib.es2015.symbol.wellknown.d.ts @@ -25,61 +25,61 @@ interface SymbolConstructor { * A method that determines if a constructor object recognizes an object as one of the * constructor’s instances. Called by the semantics of the instanceof operator. */ - readonly hasInstance: symbol; + readonly hasInstance: unique symbol; /** * A Boolean value that if true indicates that an object should flatten to its array elements * by Array.prototype.concat. */ - readonly isConcatSpreadable: symbol; + readonly isConcatSpreadable: unique symbol; /** * A regular expression method that matches the regular expression against a string. Called * by the String.prototype.match method. */ - readonly match: symbol; + readonly match: unique symbol; /** * A regular expression method that replaces matched substrings of a string. Called by the * String.prototype.replace method. */ - readonly replace: symbol; + readonly replace: unique symbol; /** * A regular expression method that returns the index within a string that matches the * regular expression. Called by the String.prototype.search method. */ - readonly search: symbol; + readonly search: unique symbol; /** * A function valued property that is the constructor function that is used to create * derived objects. */ - readonly species: symbol; + readonly species: unique symbol; /** * A regular expression method that splits a string at the indices that match the regular * expression. Called by the String.prototype.split method. */ - readonly split: symbol; + readonly split: unique symbol; /** * A method that converts an object to a corresponding primitive value. * Called by the ToPrimitive abstract operation. */ - readonly toPrimitive: symbol; + readonly toPrimitive: unique symbol; /** * A String value that is used in the creation of the default string description of an object. * Called by the built-in method Object.prototype.toString. */ - readonly toStringTag: symbol; + readonly toStringTag: unique symbol; /** * An Object whose own property names are property names that are excluded from the 'with' * environment bindings of the associated objects. */ - readonly unscopables: symbol; + readonly unscopables: unique symbol; } interface Symbol { @@ -239,9 +239,9 @@ interface String { match(matcher: { [Symbol.match](string: string): RegExpMatchArray | null; }): RegExpMatchArray | null; /** - * Replaces text in a string, using an object that supports replacement within a string. - * @param searchValue A object can search for and replace matches within a string. - * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. + * Replaces first match with string or all matches with RegExp. + * @param searchValue A string or RegExp search value. + * @param replaceValue A string containing the text to replace for match. */ replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string; diff --git a/lib/lib.es2018.asynciterable.d.ts b/lib/lib.es2018.asynciterable.d.ts index 2c3a970854e5d..88f9d8fbab16e 100644 --- a/lib/lib.es2018.asynciterable.d.ts +++ b/lib/lib.es2018.asynciterable.d.ts @@ -26,7 +26,7 @@ interface SymbolConstructor { * A method that returns the default async iterator for an object. Called by the semantics of * the for-await-of statement. */ - readonly asyncIterator: symbol; + readonly asyncIterator: unique symbol; } interface AsyncIterator { diff --git a/lib/lib.es2020.bigint.d.ts b/lib/lib.es2020.bigint.d.ts index 6dc8b25acf2e7..4d2cc2ad1a331 100644 --- a/lib/lib.es2020.bigint.d.ts +++ b/lib/lib.es2020.bigint.d.ts @@ -121,7 +121,7 @@ interface BigInt { } interface BigIntConstructor { - (value?: any): bigint; + (value: bigint | boolean | number | string): bigint; readonly prototype: BigInt; /** @@ -184,7 +184,7 @@ interface BigInt64Array { every(predicate: (value: bigint, index: number, array: BigInt64Array) => boolean, thisArg?: any): boolean; /** - * Returns the this object after filling the section identified by start and end with value + * Changes all array elements from `start` to `end` index to a static `value` and returns the modified array * @param value value to fill array section with * @param start index to start filling the array at. If start is negative, it is treated as * length+start where length is the length of the array. @@ -456,7 +456,7 @@ interface BigUint64Array { every(predicate: (value: bigint, index: number, array: BigUint64Array) => boolean, thisArg?: any): boolean; /** - * Returns the this object after filling the section identified by start and end with value + * Changes all array elements from `start` to `end` index to a static `value` and returns the modified array * @param value value to fill array section with * @param start index to start filling the array at. If start is negative, it is treated as * length+start where length is the length of the array. diff --git a/lib/lib.es2020.intl.d.ts b/lib/lib.es2020.intl.d.ts index 25c6aa1b8f272..2470d08b6fefc 100644 --- a/lib/lib.es2020.intl.d.ts +++ b/lib/lib.es2020.intl.d.ts @@ -21,13 +21,12 @@ and limitations under the License. declare namespace Intl { /** - * [BCP 47 language tag](http://tools.ietf.org/html/rfc5646) definition. + * [Unicode BCP 47 Locale Identifiers](https://unicode.org/reports/tr35/#Unicode_Language_and_Locale_Identifiers) definition. * * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#locales_argument). * - * [Wikipedia](https://en.wikipedia.org/wiki/IETF_language_tag). */ - type BCP47LanguageTag = string; + type UnicodeBCP47LocaleIdentifier = string; /** * Unit to use in the relative time internationalized message. @@ -74,239 +73,6 @@ declare namespace Intl { */ type RelativeTimeFormatStyle = "long" | "short" | "narrow"; - /** - * Unicode Calendar Identifier - * - * [Reference](http://unicode.org/reports/tr35/#UnicodeCalendarIdentifier) - * - * [Source](https://github.com/unicode-org/cldr/blob/b805d0b/common/bcp47/calendar.xml) - */ - type Calendar = - // Thai Buddhist calendar - | "buddhist" - // Traditional Chinese calendar - | "chinese" - // Coptic calendar - | "coptic" - // Traditional Korean calendar - | "dangi" - // Ethiopic calendar, Amete Alem (epoch approx. 5493 B.C.E) - | "ethiopic-amete-alem" | "ethioaa" - // Ethiopic calendar, Amete Mihret (epoch approx, 8 C.E.) - | "ethiopic" - // Gregorian calendar - | "gregorian" - // Gregorian calendar (alias) - | "gregory" - // Traditional Hebrew calendar - | "hebrew" - // Indian calendar - | "indian" - // Islamic calendar - | "islamic" - // Islamic calendar, Umm al-Qura - | "islamic-umalqura" - // Islamic calendar, tabular (intercalary years [2,5,7,10,13,16,18,21,24,26,29] - astronomical epoch) - | "islamic-tbla" - // Islamic calendar, tabular (intercalary years [2,5,7,10,13,16,18,21,24,26,29] - civil epoch) - | "islamic-civil" - | "islamicc" // Deprecated alias - // Islamic calendar, Saudi Arabia sighting - | "islamic-rgsa" - // ISO calendar (Gregorian calendar using the ISO 8601 calendar week rules) - | "iso8601" - // Japanese Imperial calendar - | "japanese" - // Persian calendar - | "persian" - // Republic of China calendar - | "roc" - ; - - /** - * Unicode Number System Identifier - * - * [Reference](http://unicode.org/reports/tr35/#UnicodeNumberSystemIdentifier) - * - * [Source](https://github.com/unicode-org/cldr/blob/be7a953/common/bcp47/number.xml) - */ - type NumberingSystem = - // Adlam digits - | "adlm" - // Ahom digits - | "ahom" - // Arabic-Indic digits - | "arab" - // Extended Arabic-Indic digits - | "arabext" - // Armenian upper case numerals — algorithmic - | "armn" - // Armenian lower case numerals — algorithmic - | "armnlow" - // Balinese digits - | "bali" - // Bengali digits - | "beng" - // Bhaiksuki digits - | "bhks" - // Brahmi digits - | "brah" - // Chakma digits - | "cakm" - // Cham digits - | "cham" - // Cyrillic numerals — algorithmic - | "cyrl" - // Devanagari digits - | "deva" - // Dives Akuru digits - | "diak" - // Ethiopic numerals — algorithmic - | "ethi" - // Financial numerals — may be algorithmic - | "finance" - // Full width digits - | "fullwide" - // Georgian numerals — algorithmic - | "geor" - // Gunjala Gondi digits - | "gong" - // Masaram Gondi digits - | "gonm" - // Greek upper case numerals — algorithmic - | "grek" - // Greek lower case numerals — algorithmic - | "greklow" - // Gujarati digits - | "gujr" - // Gurmukhi digits - | "guru" - // Han-character day-of-month numbering for lunar/other traditional calendars" - | "hanidays" - // Positional decimal system using Chinese number ideographs as digits - | "hanidec" - // Simplified Chinese numerals — algorithmic - | "hans" - // Simplified Chinese financial numerals — algorithmic - | "hansfin" - // Traditional Chinese numerals — algorithmic - | "hant" - // Traditional Chinese financial numerals — algorithmic - | "hantfin" - // Hebrew numerals — algorithmic - | "hebr" - // Pahawh Hmong digits - | "hmng" - // Nyiakeng Puachue Hmong digits - | "hmnp" - // Javanese digits - | "java" - // Japanese numerals — algorithmic - | "jpan" - // Japanese financial numerals — algorithmic - | "jpanfin" - // Japanese first-year Gannen numbering for Japanese calendar - | "jpanyear" - // Kayah Li digits - | "kali" - // Khmer digits - | "khmr" - // Kannada digits - | "knda" - // Tai Tham Hora (secular) digits - | "lana" - // Tai Tham Tham (ecclesiastical) digits - | "lanatham" - // Lao digits - | "laoo" - // Latin digits - | "latn" - // Lepcha digits - | "lepc" - // Limbu digits - | "limb" - // Mathematical bold digits - | "mathbold" - // Mathematical double-struck digits - | "mathdbl" - // Mathematical monospace digits - | "mathmono" - // Mathematical sans-serif bold digits - | "mathsanb" - // Mathematical sans-serif digits - | "mathsans" - // Malayalam digits - | "mlym" - // Modi digits - | "modi" - // Mongolian digits - | "mong" - // Mro digits - | "mroo" - // Meetei Mayek digits - | "mtei" - // Myanmar digits - | "mymr" - // Myanmar Shan digits - | "mymrshan" - // Myanmar Tai Laing digits - | "mymrtlng" - // Native digits - | "native" - // Newa digits - | "newa" - // N'Ko digits - | "nkoo" - // Ol Chiki digits - | "olck" - // Oriya digits - | "orya" - // Osmanya digits - | "osma" - // Hanifi Rohingya digits - | "rohg" - // Roman upper case numerals — algorithmic - | "roman" - // Roman lowercase numerals — algorithmic - | "romanlow" - // Saurashtra digits - | "saur" - // Sharada digits - | "shrd" - // Khudawadi digits - | "sind" - // Sinhala Lith digits - | "sinh" - // Sora_Sompeng digits - | "sora" - // Sundanese digits - | "sund" - // Takri digits - | "takr" - // New Tai Lue digits - | "talu" - // Tamil numerals — algorithmic - | "taml" - // Modern Tamil decimal digits - | "tamldec" - // Telugu digits - | "telu" - // Thai digits - | "thai" - // Tirhuta digits - | "tirh" - // Tibetan digits - | "tibt" - // Traditional numerals — may be algorithmic - | "traditional" | "traditio" - // Vai digits - | "vaii" - // Warang Citi digits - | "wara" - // Wancho digits - | "wcho" - ; - /** * An object with some or all of properties of `options` parameter * of `Intl.RelativeTimeFormat` constructor. @@ -331,7 +97,7 @@ declare namespace Intl { * [Specification](https://tc39.es/ecma402/#table-relativetimeformat-resolvedoptions-properties) */ interface ResolvedRelativeTimeFormatOptions { - locale: BCP47LanguageTag; + locale: UnicodeBCP47LocaleIdentifier; style: RelativeTimeFormatStyle; numeric: RelativeTimeFormatNumeric; numberingSystem: string; @@ -474,7 +240,7 @@ declare namespace Intl { * [Specification](https://tc39.es/ecma402/#sec-intl-relativetimeformat-constructor). */ new( - locales?: BCP47LanguageTag | BCP47LanguageTag[], + locales?: UnicodeBCP47LocaleIdentifier | UnicodeBCP47LocaleIdentifier[], options?: RelativeTimeFormatOptions, ): RelativeTimeFormat; @@ -510,9 +276,9 @@ declare namespace Intl { * [Specification](https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat.supportedLocalesOf). */ supportedLocalesOf( - locales: BCP47LanguageTag | BCP47LanguageTag[], + locales?: UnicodeBCP47LocaleIdentifier | UnicodeBCP47LocaleIdentifier[], options?: RelativeTimeFormatOptions, - ): BCP47LanguageTag[]; + ): UnicodeBCP47LocaleIdentifier[]; }; interface NumberFormatOptions { @@ -534,9 +300,9 @@ declare namespace Intl { interface DateTimeFormatOptions { dateStyle?: "full" | "long" | "medium" | "short"; timeStyle?: "full" | "long" | "medium" | "short"; - calendar?: Calendar; + calendar?: string; dayPeriod?: "narrow" | "short" | "long"; - numberingSystem?: NumberingSystem; + numberingSystem?: string; hourCycle?: "h11" | "h12" | "h23" | "h24"; fractionalSecondDigits?: 0 | 1 | 2 | 3; } diff --git a/lib/lib.es2020.symbol.wellknown.d.ts b/lib/lib.es2020.symbol.wellknown.d.ts index 4bac52fecd3d6..7df0a2f45774a 100644 --- a/lib/lib.es2020.symbol.wellknown.d.ts +++ b/lib/lib.es2020.symbol.wellknown.d.ts @@ -26,7 +26,7 @@ interface SymbolConstructor { * A regular expression method that matches the regular expression against a string. Called * by the String.prototype.matchAll method. */ - readonly matchAll: symbol; + readonly matchAll: unique symbol; } interface RegExp { diff --git a/lib/lib.es2021.d.ts b/lib/lib.es2021.d.ts new file mode 100644 index 0000000000000..1cb1e732ad858 --- /dev/null +++ b/lib/lib.es2021.d.ts @@ -0,0 +1,24 @@ +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + + + +/// + + +/// +/// +/// +/// diff --git a/lib/lib.es2021.full.d.ts b/lib/lib.es2021.full.d.ts new file mode 100644 index 0000000000000..53488737712c8 --- /dev/null +++ b/lib/lib.es2021.full.d.ts @@ -0,0 +1,25 @@ +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + + + +/// + + +/// +/// +/// +/// +/// diff --git a/lib/lib.es2021.promise.d.ts b/lib/lib.es2021.promise.d.ts new file mode 100644 index 0000000000000..6a56c55128861 --- /dev/null +++ b/lib/lib.es2021.promise.d.ts @@ -0,0 +1,43 @@ +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + + + +/// + + +interface AggregateError extends Error { + errors: any[] +} + +interface AggregateErrorConstructor { + new(errors: Iterable, message?: string): AggregateError; + (errors: Iterable, message?: string): AggregateError; + readonly prototype: AggregateError; +} + +declare var AggregateError: AggregateErrorConstructor; + +/** + * Represents the completion of an asynchronous operation + */ +interface PromiseConstructor { + /** + * The any function returns a promise that is fulfilled by the first given promise to be fulfilled, or rejected with an AggregateError containing an array of rejection reasons if all of the given promises are rejected. It resolves all elements of the passed iterable to promises as it runs this algorithm. + * @param values An array or iterable of Promises. + * @returns A new Promise. + */ + any(values: (T | PromiseLike)[] | Iterable>): Promise +} diff --git a/lib/lib.es2021.string.d.ts b/lib/lib.es2021.string.d.ts new file mode 100644 index 0000000000000..89b27e2fe9094 --- /dev/null +++ b/lib/lib.es2021.string.d.ts @@ -0,0 +1,35 @@ +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + + + +/// + + +interface String { + /** + * Replace all instances of a substring in a string, using a regular expression or search string. + * @param searchValue A string to search for. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. + */ + replaceAll(searchValue: string | RegExp, replaceValue: string): string; + + /** + * Replace all instances of a substring in a string, using a regular expression or search string. + * @param searchValue A string to search for. + * @param replacer A function that returns the replacement text. + */ + replaceAll(searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; +} diff --git a/lib/lib.es2021.weakref.d.ts b/lib/lib.es2021.weakref.d.ts new file mode 100644 index 0000000000000..eb7764242d7b9 --- /dev/null +++ b/lib/lib.es2021.weakref.d.ts @@ -0,0 +1,75 @@ +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + + + +/// + + +interface WeakRef { + readonly [Symbol.toStringTag]: "WeakRef"; + + /** + * Returns the WeakRef instance's target object, or undefined if the target object has been + * reclaimed. + */ + deref(): T | undefined; +} + +interface WeakRefConstructor { + readonly prototype: WeakRef; + + /** + * Creates a WeakRef instance for the given target object. + * @param target The target object for the WeakRef instance. + */ + new(target: T): WeakRef; +} + +declare var WeakRef: WeakRefConstructor; + +interface FinalizationRegistry { + readonly [Symbol.toStringTag]: "FinalizationRegistry"; + + /** + * Registers an object with the registry. + * @param target The target object to register. + * @param heldValue The value to pass to the finalizer for this object. This cannot be the + * target object. + * @param unregisterToken The token to pass to the unregister method to unregister the target + * object. If provided (and not undefined), this must be an object. If not provided, the target + * cannot be unregistered. + */ + register(target: object, heldValue: T, unregisterToken?: object): void; + + /** + * Unregisters an object from the registry. + * @param unregisterToken The token that was used as the unregisterToken argument when calling + * register to register the target object. + */ + unregister(unregisterToken: object): void; +} + +interface FinalizationRegistryConstructor { + readonly prototype: FinalizationRegistry; + + /** + * Creates a finalization registry with an associated cleanup callback + * @param cleanupCallback The callback to call after an object in the registry has been reclaimed. + */ + new(cleanupCallback: (heldValue: T) => void): FinalizationRegistry; +} + +declare var FinalizationRegistry: FinalizationRegistryConstructor; diff --git a/lib/lib.es5.d.ts b/lib/lib.es5.d.ts index 221882e80f6d5..2a70d1d889bd9 100644 --- a/lib/lib.es5.d.ts +++ b/lib/lib.es5.d.ts @@ -33,12 +33,12 @@ declare function eval(x: string): any; /** * Converts a string to an integer. - * @param s A string to convert into a number. - * @param radix A value between 2 and 36 that specifies the base of the number in numString. + * @param string A string to convert into a number. + * @param radix A value between 2 and 36 that specifies the base of the number in `string`. * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. * All other strings are considered decimal. */ -declare function parseInt(s: string, radix?: number): number; +declare function parseInt(string: string, radix?: number): number; /** * Converts a string to a floating-point number. @@ -197,14 +197,14 @@ interface ObjectConstructor { * @param p The property name. * @param attributes Descriptor for the property. It can be for a data property or an accessor property. */ - defineProperty(o: any, p: PropertyKey, attributes: PropertyDescriptor & ThisType): any; + defineProperty(o: T, p: PropertyKey, attributes: PropertyDescriptor & ThisType): T; /** * Adds one or more properties to an object, and/or modifies attributes of existing properties. * @param o Object on which to add or modify the properties. This can be a native JavaScript object or a DOM object. * @param properties JavaScript object that contains one or more descriptor objects. Each descriptor object describes a data property or an accessor property. */ - defineProperties(o: any, properties: PropertyDescriptorMap & ThisType): any; + defineProperties(o: T, properties: PropertyDescriptorMap & ThisType): T; /** * Prevents the modification of attributes of existing properties, and prevents the addition of new properties. @@ -1093,7 +1093,7 @@ interface ReadonlyArray { */ toString(): string; /** - * Returns a string representation of an array. The elements are converted to string using their toLocalString methods. + * Returns a string representation of an array. The elements are converted to string using their toLocaleString methods. */ toLocaleString(): string; /** @@ -1227,7 +1227,7 @@ interface Array { */ toString(): string; /** - * Returns a string representation of an array. The elements are converted to string using their toLocalString methods. + * Returns a string representation of an array. The elements are converted to string using their toLocaleString methods. */ toLocaleString(): string; /** @@ -1528,7 +1528,7 @@ type Parameters any> = T extends (...args: infer P) /** * Obtain the parameters of a constructor function type in a tuple */ -type ConstructorParameters any> = T extends new (...args: infer P) => any ? P : never; +type ConstructorParameters any> = T extends abstract new (...args: infer P) => any ? P : never; /** * Obtain the return type of a function type @@ -1538,7 +1538,7 @@ type ReturnType any> = T extends (...args: any) => i /** * Obtain the return type of a constructor function type */ -type InstanceType any> = T extends new (...args: any) => infer R ? R : any; +type InstanceType any> = T extends abstract new (...args: any) => infer R ? R : any; /** * Convert string literal type to uppercase @@ -1796,7 +1796,7 @@ interface Int8Array { every(predicate: (value: number, index: number, array: Int8Array) => unknown, thisArg?: any): boolean; /** - * Returns the this object after filling the section identified by start and end with value + * Changes all array elements from `start` to `end` index to a static `value` and returns the modified array * @param value value to fill array section with * @param start index to start filling the array at. If start is negative, it is treated as * length+start where length is the length of the array. @@ -2078,7 +2078,7 @@ interface Uint8Array { every(predicate: (value: number, index: number, array: Uint8Array) => unknown, thisArg?: any): boolean; /** - * Returns the this object after filling the section identified by start and end with value + * Changes all array elements from `start` to `end` index to a static `value` and returns the modified array * @param value value to fill array section with * @param start index to start filling the array at. If start is negative, it is treated as * length+start where length is the length of the array. @@ -2360,7 +2360,7 @@ interface Uint8ClampedArray { every(predicate: (value: number, index: number, array: Uint8ClampedArray) => unknown, thisArg?: any): boolean; /** - * Returns the this object after filling the section identified by start and end with value + * Changes all array elements from `start` to `end` index to a static `value` and returns the modified array * @param value value to fill array section with * @param start index to start filling the array at. If start is negative, it is treated as * length+start where length is the length of the array. @@ -2641,7 +2641,7 @@ interface Int16Array { every(predicate: (value: number, index: number, array: Int16Array) => unknown, thisArg?: any): boolean; /** - * Returns the this object after filling the section identified by start and end with value + * Changes all array elements from `start` to `end` index to a static `value` and returns the modified array * @param value value to fill array section with * @param start index to start filling the array at. If start is negative, it is treated as * length+start where length is the length of the array. @@ -2923,7 +2923,7 @@ interface Uint16Array { every(predicate: (value: number, index: number, array: Uint16Array) => unknown, thisArg?: any): boolean; /** - * Returns the this object after filling the section identified by start and end with value + * Changes all array elements from `start` to `end` index to a static `value` and returns the modified array * @param value value to fill array section with * @param start index to start filling the array at. If start is negative, it is treated as * length+start where length is the length of the array. @@ -3205,7 +3205,7 @@ interface Int32Array { every(predicate: (value: number, index: number, array: Int32Array) => unknown, thisArg?: any): boolean; /** - * Returns the this object after filling the section identified by start and end with value + * Changes all array elements from `start` to `end` index to a static `value` and returns the modified array * @param value value to fill array section with * @param start index to start filling the array at. If start is negative, it is treated as * length+start where length is the length of the array. @@ -3487,7 +3487,7 @@ interface Uint32Array { every(predicate: (value: number, index: number, array: Uint32Array) => unknown, thisArg?: any): boolean; /** - * Returns the this object after filling the section identified by start and end with value + * Changes all array elements from `start` to `end` index to a static `value` and returns the modified array * @param value value to fill array section with * @param start index to start filling the array at. If start is negative, it is treated as * length+start where length is the length of the array. @@ -3768,7 +3768,7 @@ interface Float32Array { every(predicate: (value: number, index: number, array: Float32Array) => unknown, thisArg?: any): boolean; /** - * Returns the this object after filling the section identified by start and end with value + * Changes all array elements from `start` to `end` index to a static `value` and returns the modified array * @param value value to fill array section with * @param start index to start filling the array at. If start is negative, it is treated as * length+start where length is the length of the array. @@ -4051,7 +4051,7 @@ interface Float64Array { every(predicate: (value: number, index: number, array: Float64Array) => unknown, thisArg?: any): boolean; /** - * Returns the this object after filling the section identified by start and end with value + * Changes all array elements from `start` to `end` index to a static `value` and returns the modified array * @param value value to fill array section with * @param start index to start filling the array at. If start is negative, it is treated as * length+start where length is the length of the array. @@ -4351,8 +4351,8 @@ declare namespace Intl { interface DateTimeFormatOptions { localeMatcher?: "best fit" | "lookup"; - weekday?: "long" | "short" | "narrow"; - era?: "long" | "short" | "narrow"; + weekday?: "long" | "short" | "narrow"; + era?: "long" | "short" | "narrow"; year?: "numeric" | "2-digit"; month?: "numeric" | "2-digit" | "long" | "short" | "narrow"; day?: "numeric" | "2-digit"; diff --git a/lib/lib.esnext.d.ts b/lib/lib.esnext.d.ts index ae7aaecd7ae7a..f1a4c7e1404d8 100644 --- a/lib/lib.esnext.d.ts +++ b/lib/lib.esnext.d.ts @@ -18,8 +18,5 @@ and limitations under the License. /// -/// +/// /// -/// -/// -/// diff --git a/lib/lib.esnext.intl.d.ts b/lib/lib.esnext.intl.d.ts index 165fcf7b3f79e..175ef85de7e58 100644 --- a/lib/lib.esnext.intl.d.ts +++ b/lib/lib.esnext.intl.d.ts @@ -27,6 +27,6 @@ declare namespace Intl { } interface NumberFormat { - formatToParts(number?: number): NumberFormatPart[]; + formatToParts(number?: number | bigint): NumberFormatPart[]; } } diff --git a/lib/lib.webworker.d.ts b/lib/lib.webworker.d.ts index 1e0472624ae41..528778ffdbebe 100644 --- a/lib/lib.webworker.d.ts +++ b/lib/lib.webworker.d.ts @@ -382,11 +382,6 @@ interface PushPermissionDescriptor extends PermissionDescriptor { userVisibleOnly?: boolean; } -interface PushSubscriptionChangeEventInit extends ExtendableEventInit { - newSubscription?: PushSubscription; - oldSubscription?: PushSubscription; -} - interface PushSubscriptionJSON { endpoint?: string; expirationTime?: number | null; @@ -406,7 +401,7 @@ interface QueuingStrategy { interface QueuingStrategyInit { /** * Creates a new ByteLengthQueuingStrategy with the provided high water mark. - * + * * Note that the provided high water mark will not be validated ahead of time. Instead, if it is negative, NaN, or not a number, the resulting ByteLengthQueuingStrategy will cause the corresponding stream constructor to throw. */ highWaterMark: number; @@ -426,7 +421,7 @@ interface ReadableWritablePair { readable: ReadableStream; /** * Provides a convenient, chainable way of piping this readable stream through a transform stream (or any other { writable, readable } pair). It simply pipes the stream into the writable side of the supplied pair, and returns the readable side for further use. - * + * * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader. */ writable: WritableStream; @@ -536,19 +531,19 @@ interface StreamPipeOptions { preventCancel?: boolean; /** * Pipes this readable stream to a given writable stream destination. The way in which the piping process behaves under various error conditions can be customized with a number of passed options. It returns a promise that fulfills when the piping process completes successfully, or rejects if any errors were encountered. - * + * * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader. - * + * * Errors and closures of the source and destination streams propagate as follows: - * + * * An error in this source readable stream will abort destination, unless preventAbort is truthy. The returned promise will be rejected with the source's error, or with any error that occurs during aborting the destination. - * + * * An error in destination will cancel this source readable stream, unless preventCancel is truthy. The returned promise will be rejected with the destination's error, or with any error that occurs during canceling the source. - * + * * When this source readable stream closes, destination will be closed, unless preventClose is truthy. The returned promise will be fulfilled once this process completes, unless an error is encountered while closing the destination, in which case it will be rejected with that error. - * + * * If destination starts out closed or closing, this source readable stream will be canceled, unless preventCancel is true. The returned promise will be rejected with an error indicating piping to a closed stream failed, or with any error that occurs during canceling the source. - * + * * The signal option can be set to an AbortSignal to allow aborting an ongoing pipe operation via the corresponding AbortController. In this case, this source readable stream will be canceled, and destination aborted, unless the respective options preventCancel or preventAbort are set. */ preventClose?: boolean; @@ -833,7 +828,7 @@ interface CanvasFilters { interface CanvasGradient { /** * Adds a color stop with the given color to the gradient at the given offset. 0.0 is the offset at one end of the gradient, 1.0 is the offset at the other end. - * + * * Throws an "IndexSizeError" DOMException if the offset is out of range. Throws a "SyntaxError" DOMException if the color cannot be parsed. */ addColorStop(offset: number, color: string): void; @@ -1515,15 +1510,15 @@ declare var EventSource: { interface EventTarget { /** * Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched. - * + * * The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture. - * + * * When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET. - * + * * When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners. - * + * * When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed. - * + * * The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture. */ addEventListener(type: string, listener: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions): void; @@ -1570,7 +1565,6 @@ declare var ExtendableMessageEvent: { interface FetchEvent extends ExtendableEvent { readonly clientId: string; readonly preloadResponse: Promise; - readonly replacesClientId: string; readonly request: Request; readonly resultingClientId: string; respondWith(r: Response | Promise): void; @@ -1730,15 +1724,15 @@ interface IDBCursor { continuePrimaryKey(key: IDBValidKey, primaryKey: IDBValidKey): void; /** * Delete the record pointed at by the cursor with a new value. - * + * * If successful, request's result will be undefined. */ delete(): IDBRequest; /** * Updated the record pointed at by the cursor with a new value. - * + * * Throws a "DataError" DOMException if the effective object store uses in-line keys and the key would have changed. - * + * * If successful, request's result will be the record's key. */ update(value: any): IDBRequest; @@ -1793,13 +1787,13 @@ interface IDBDatabase extends EventTarget { close(): void; /** * Creates a new object store with the given name and options and returns a new IDBObjectStore. - * + * * Throws a "InvalidStateError" DOMException if not called within an upgrade transaction. */ createObjectStore(name: string, options?: IDBObjectStoreParameters): IDBObjectStore; /** * Deletes the object store with the given name. - * + * * Throws a "InvalidStateError" DOMException if not called within an upgrade transaction. */ deleteObjectStore(name: string): void; @@ -1822,7 +1816,7 @@ declare var IDBDatabase: { interface IDBFactory { /** * Compares two values as keys. Returns -1 if key1 precedes key2, 1 if key2 precedes key1, and 0 if the keys are equal. - * + * * Throws a "DataError" DOMException if either input is not a valid key. */ cmp(first: any, second: any): number; @@ -1856,43 +1850,43 @@ interface IDBIndex { readonly unique: boolean; /** * Retrieves the number of records matching the given key or key range in query. - * + * * If successful, request's result will be the count. */ count(key?: IDBValidKey | IDBKeyRange): IDBRequest; /** * Retrieves the value of the first record matching the given key or key range in query. - * + * * If successful, request's result will be the value, or undefined if there was no matching record. */ get(key: IDBValidKey | IDBKeyRange): IDBRequest; /** * Retrieves the values of the records matching the given key or key range in query (up to count if given). - * + * * If successful, request's result will be an Array of the values. */ getAll(query?: IDBValidKey | IDBKeyRange | null, count?: number): IDBRequest; /** * Retrieves the keys of records matching the given key or key range in query (up to count if given). - * + * * If successful, request's result will be an Array of the keys. */ getAllKeys(query?: IDBValidKey | IDBKeyRange | null, count?: number): IDBRequest; /** * Retrieves the key of the first record matching the given key or key range in query. - * + * * If successful, request's result will be the key, or undefined if there was no matching record. */ getKey(key: IDBValidKey | IDBKeyRange): IDBRequest; /** * Opens a cursor over the records matching query, ordered by direction. If query is null, all records in index are matched. - * + * * If successful, request's result will be an IDBCursorWithValue, or null if there were no matching records. */ openCursor(query?: IDBValidKey | IDBKeyRange | null, direction?: IDBCursorDirection): IDBRequest; /** * Opens a cursor with key only flag set over the records matching query, ordered by direction. If query is null, all records in index are matched. - * + * * If successful, request's result will be an IDBCursor, or null if there were no matching records. */ openKeyCursor(query?: IDBValidKey | IDBKeyRange | null, direction?: IDBCursorDirection): IDBRequest; @@ -1972,88 +1966,88 @@ interface IDBObjectStore { readonly transaction: IDBTransaction; /** * Adds or updates a record in store with the given value and key. - * + * * If the store uses in-line keys and key is specified a "DataError" DOMException will be thrown. - * + * * If put() is used, any existing record with the key will be replaced. If add() is used, and if a record with the key already exists the request will fail, with request's error set to a "ConstraintError" DOMException. - * + * * If successful, request's result will be the record's key. */ add(value: any, key?: IDBValidKey): IDBRequest; /** * Deletes all records in store. - * + * * If successful, request's result will be undefined. */ clear(): IDBRequest; /** * Retrieves the number of records matching the given key or key range in query. - * + * * If successful, request's result will be the count. */ count(key?: IDBValidKey | IDBKeyRange): IDBRequest; /** * Creates a new index in store with the given name, keyPath and options and returns a new IDBIndex. If the keyPath and options define constraints that cannot be satisfied with the data already in store the upgrade transaction will abort with a "ConstraintError" DOMException. - * + * * Throws an "InvalidStateError" DOMException if not called within an upgrade transaction. */ createIndex(name: string, keyPath: string | string[], options?: IDBIndexParameters): IDBIndex; /** * Deletes records in store with the given key or in the given key range in query. - * + * * If successful, request's result will be undefined. */ delete(key: IDBValidKey | IDBKeyRange): IDBRequest; /** * Deletes the index in store with the given name. - * + * * Throws an "InvalidStateError" DOMException if not called within an upgrade transaction. */ deleteIndex(name: string): void; /** * Retrieves the value of the first record matching the given key or key range in query. - * + * * If successful, request's result will be the value, or undefined if there was no matching record. */ get(query: IDBValidKey | IDBKeyRange): IDBRequest; /** * Retrieves the values of the records matching the given key or key range in query (up to count if given). - * + * * If successful, request's result will be an Array of the values. */ getAll(query?: IDBValidKey | IDBKeyRange | null, count?: number): IDBRequest; /** * Retrieves the keys of records matching the given key or key range in query (up to count if given). - * + * * If successful, request's result will be an Array of the keys. */ getAllKeys(query?: IDBValidKey | IDBKeyRange | null, count?: number): IDBRequest; /** * Retrieves the key of the first record matching the given key or key range in query. - * + * * If successful, request's result will be the key, or undefined if there was no matching record. */ getKey(query: IDBValidKey | IDBKeyRange): IDBRequest; index(name: string): IDBIndex; /** * Opens a cursor over the records matching query, ordered by direction. If query is null, all records in store are matched. - * + * * If successful, request's result will be an IDBCursorWithValue pointing at the first matching record, or null if there were no matching records. */ openCursor(query?: IDBValidKey | IDBKeyRange | null, direction?: IDBCursorDirection): IDBRequest; /** * Opens a cursor with key only flag set over the records matching query, ordered by direction. If query is null, all records in store are matched. - * + * * If successful, request's result will be an IDBCursor pointing at the first matching record, or null if there were no matching records. */ openKeyCursor(query?: IDBValidKey | IDBKeyRange | null, direction?: IDBCursorDirection): IDBRequest; /** * Adds or updates a record in store with the given value and key. - * + * * If the store uses in-line keys and key is specified a "DataError" DOMException will be thrown. - * + * * If put() is used, any existing record with the key will be replaced. If add() is used, and if a record with the key already exists the request will fail, with request's error set to a "ConstraintError" DOMException. - * + * * If successful, request's result will be the record's key. */ put(value: any, key?: IDBValidKey): IDBRequest; @@ -2299,7 +2293,7 @@ interface MessagePort extends EventTarget { close(): void; /** * Posts a message through the channel. Objects listed in transfer are transferred, not just cloned, meaning that they are no longer usable on the sending side. - * + * * Throws a "DataCloneError" DOMException if transfer contains duplicate objects or port, or if message could not be cloned. */ postMessage(message: any, transfer: Transferable[]): void; @@ -2447,27 +2441,27 @@ interface OES_vertex_array_object { interface OffscreenCanvas extends EventTarget { /** * These attributes return the dimensions of the OffscreenCanvas object's bitmap. - * + * * They can be set, to replace the bitmap with a new, transparent black bitmap of the specified dimensions (effectively resizing it). */ height: number; /** * These attributes return the dimensions of the OffscreenCanvas object's bitmap. - * + * * They can be set, to replace the bitmap with a new, transparent black bitmap of the specified dimensions (effectively resizing it). */ width: number; /** * Returns a promise that will fulfill with a new Blob object representing a file containing the image in the OffscreenCanvas object. - * + * * The argument, if provided, is a dictionary that controls the encoding options of the image file to be created. The type field specifies the file format and has a default value of "image/png"; that type is also used if the requested type isn't supported. If the image format supports variable quality (such as "image/jpeg"), then the quality field is a number in the range 0.0 to 1.0 inclusive indicating the desired quality level for the resulting image. */ convertToBlob(options?: ImageEncodeOptions): Promise; /** * Returns an object that exposes an API for drawing on the OffscreenCanvas object. contextId specifies the desired API: "2d", "bitmaprenderer", "webgl", or "webgl2". options is handled by that API. - * + * * This specification defines the "2d" context below, which is similar but distinct from the "2d" context that is created from a canvas element. The WebGL specifications define the "webgl" and "webgl2" contexts. [WEBGL] - * + * * Returns null if the canvas has already been initialized with another context type (e.g., trying to get a "2d" context after getting a "webgl" context). */ getContext(contextId: "2d", options?: CanvasRenderingContext2DSettings): OffscreenCanvasRenderingContext2D | null; @@ -2722,16 +2716,6 @@ declare var PushSubscription: { new(): PushSubscription; }; -interface PushSubscriptionChangeEvent extends ExtendableEvent { - readonly newSubscription: PushSubscription | null; - readonly oldSubscription: PushSubscription | null; -} - -declare var PushSubscriptionChangeEvent: { - prototype: PushSubscriptionChangeEvent; - new(type: string, eventInitDict?: PushSubscriptionChangeEventInit): PushSubscriptionChangeEvent; -}; - interface PushSubscriptionOptions { readonly applicationServerKey: ArrayBuffer | null; readonly userVisibleOnly: boolean; @@ -2933,7 +2917,6 @@ interface ServiceWorkerGlobalScopeEventMap extends WorkerGlobalScopeEventMap { "notificationclick": NotificationEvent; "notificationclose": NotificationEvent; "push": PushEvent; - "pushsubscriptionchange": PushSubscriptionChangeEvent; "sync": SyncEvent; } @@ -2948,7 +2931,6 @@ interface ServiceWorkerGlobalScope extends WorkerGlobalScope { onnotificationclick: ((this: ServiceWorkerGlobalScope, ev: NotificationEvent) => any) | null; onnotificationclose: ((this: ServiceWorkerGlobalScope, ev: NotificationEvent) => any) | null; onpush: ((this: ServiceWorkerGlobalScope, ev: PushEvent) => any) | null; - onpushsubscriptionchange: ((this: ServiceWorkerGlobalScope, ev: PushSubscriptionChangeEvent) => any) | null; onsync: ((this: ServiceWorkerGlobalScope, ev: SyncEvent) => any) | null; readonly registration: ServiceWorkerRegistration; readonly serviceWorker: ServiceWorker; @@ -3098,7 +3080,7 @@ declare var SyncManager: { interface TextDecoder extends TextDecoderCommon { /** * Returns the result of running encoding's decoder. The method can be invoked zero or more times with options's stream set to true, and then once without options's stream (or set to false), to process a fragmented input. If the invocation without options's stream (or set to false) has no input, it's clearest to omit both arguments. - * + * * ``` * var string = "", decoder = new TextDecoder(encoding), buffer; * while(buffer = next_chunk()) { @@ -3106,7 +3088,7 @@ interface TextDecoder extends TextDecoderCommon { * } * string += decoder.decode(); // end-of-queue * ``` - * + * * If the error mode is "fatal" and encoding's decoder returns error, throws a TypeError. */ decode(input?: BufferSource, options?: TextDecodeOptions): string; @@ -3194,34 +3176,6 @@ interface TextMetrics { * Returns the measurement described below. */ readonly actualBoundingBoxRight: number; - /** - * Returns the measurement described below. - */ - readonly alphabeticBaseline: number; - /** - * Returns the measurement described below. - */ - readonly emHeightAscent: number; - /** - * Returns the measurement described below. - */ - readonly emHeightDescent: number; - /** - * Returns the measurement described below. - */ - readonly fontBoundingBoxAscent: number; - /** - * Returns the measurement described below. - */ - readonly fontBoundingBoxDescent: number; - /** - * Returns the measurement described below. - */ - readonly hangingBaseline: number; - /** - * Returns the measurement described below. - */ - readonly ideographicBaseline: number; /** * Returns the measurement described below. */ @@ -4407,7 +4361,7 @@ declare var WebGLActiveInfo: { }; /** Part of the WebGL API and represents an opaque buffer object storing data such as vertices or colors. */ -interface WebGLBuffer extends WebGLObject { +interface WebGLBuffer { } declare var WebGLBuffer: { @@ -4426,7 +4380,7 @@ declare var WebGLContextEvent: { }; /** Part of the WebGL API and represents a collection of buffers that serve as a rendering destination. */ -interface WebGLFramebuffer extends WebGLObject { +interface WebGLFramebuffer { } declare var WebGLFramebuffer: { @@ -4434,16 +4388,8 @@ declare var WebGLFramebuffer: { new(): WebGLFramebuffer; }; -interface WebGLObject { -} - -declare var WebGLObject: { - prototype: WebGLObject; - new(): WebGLObject; -}; - /** The WebGLProgram is part of the WebGL API and is a combination of two compiled WebGLShaders consisting of a vertex shader and a fragment shader (both written in GLSL). */ -interface WebGLProgram extends WebGLObject { +interface WebGLProgram { } declare var WebGLProgram: { @@ -4451,7 +4397,7 @@ declare var WebGLProgram: { new(): WebGLProgram; }; -interface WebGLQuery extends WebGLObject { +interface WebGLQuery { } declare var WebGLQuery: { @@ -4460,7 +4406,7 @@ declare var WebGLQuery: { }; /** Part of the WebGL API and represents a buffer that can contain an image, or can be source or target of an rendering operation. */ -interface WebGLRenderbuffer extends WebGLObject { +interface WebGLRenderbuffer { } declare var WebGLRenderbuffer: { @@ -5239,7 +5185,7 @@ interface WebGLRenderingContextOverloads { uniformMatrix4fv(location: WebGLUniformLocation | null, transpose: GLboolean, value: Float32List): void; } -interface WebGLSampler extends WebGLObject { +interface WebGLSampler { } declare var WebGLSampler: { @@ -5248,7 +5194,7 @@ declare var WebGLSampler: { }; /** The WebGLShader is part of the WebGL API and can either be a vertex or a fragment shader. A WebGLProgram requires both types of shaders. */ -interface WebGLShader extends WebGLObject { +interface WebGLShader { } declare var WebGLShader: { @@ -5268,7 +5214,7 @@ declare var WebGLShaderPrecisionFormat: { new(): WebGLShaderPrecisionFormat; }; -interface WebGLSync extends WebGLObject { +interface WebGLSync { } declare var WebGLSync: { @@ -5277,7 +5223,7 @@ declare var WebGLSync: { }; /** Part of the WebGL API and represents an opaque texture object providing storage and state for texturing operations. */ -interface WebGLTexture extends WebGLObject { +interface WebGLTexture { } declare var WebGLTexture: { @@ -5285,7 +5231,7 @@ declare var WebGLTexture: { new(): WebGLTexture; }; -interface WebGLTransformFeedback extends WebGLObject { +interface WebGLTransformFeedback { } declare var WebGLTransformFeedback: { @@ -5302,7 +5248,7 @@ declare var WebGLUniformLocation: { new(): WebGLUniformLocation; }; -interface WebGLVertexArrayObject extends WebGLObject { +interface WebGLVertexArrayObject { } declare var WebGLVertexArrayObject: { @@ -5310,7 +5256,7 @@ declare var WebGLVertexArrayObject: { new(): WebGLVertexArrayObject; }; -interface WebGLVertexArrayObjectOES extends WebGLObject { +interface WebGLVertexArrayObjectOES { } interface WebSocketEventMap { @@ -5324,13 +5270,13 @@ interface WebSocketEventMap { interface WebSocket extends EventTarget { /** * Returns a string that indicates how binary data from the WebSocket object is exposed to scripts: - * + * * Can be set, to change how binary data is returned. The default is "blob". */ binaryType: BinaryType; /** * Returns the number of bytes of application data (UTF-8 text and binary data) that have been queued using send() but not yet been transmitted to the network. - * + * * If the WebSocket connection is closed, this attribute's value will only increase with each call to the send() method. (The number does not reset to zero once the connection closes.) */ readonly bufferedAmount: number; @@ -5383,7 +5329,6 @@ declare var WebSocket: { /** This ServiceWorker API interface represents the scope of a service worker client that is a document in a browser context, controlled by an active worker. The service worker client independently selects and uses a service worker for its own loading and sub-resources. */ interface WindowClient extends Client { - readonly ancestorOrigins: ReadonlyArray; readonly focused: boolean; readonly visibilityState: VisibilityState; focus(): Promise; @@ -5506,7 +5451,6 @@ declare var WorkerLocation: { /** A subset of the Navigator interface allowed to be accessed from a Worker. Such an object is initialized for each worker and is available via the WorkerGlobalScope.navigator property obtained by calling window.self.navigator. */ interface WorkerNavigator extends NavigatorConcurrentHardware, NavigatorID, NavigatorLanguage, NavigatorOnLine, NavigatorStorage { readonly permissions: Permissions; - readonly serviceWorker: ServiceWorkerContainer; } declare var WorkerNavigator: { @@ -5569,19 +5513,19 @@ interface XMLHttpRequest extends XMLHttpRequestEventTarget { readonly response: any; /** * Returns the text response. - * + * * Throws an "InvalidStateError" DOMException if responseType is not the empty string or "text". */ readonly responseText: string; /** * Returns the response type. - * + * * Can be set to change the response type. Values are: the empty string (default), "arraybuffer", "blob", "document", "json", and "text". - * + * * When set: setting to "document" is ignored if current global object is not a Window object. - * + * * When set: throws an "InvalidStateError" DOMException if state is loading or done. - * + * * When set: throws an "InvalidAccessError" DOMException if the synchronous flag is set and current global object is a Window object. */ responseType: XMLHttpRequestResponseType; @@ -5590,7 +5534,7 @@ interface XMLHttpRequest extends XMLHttpRequestEventTarget { readonly statusText: string; /** * Can be set to a time in milliseconds. When set to a non-zero value will cause fetching to terminate after the given time has passed. When the time has passed, the request has not yet completed, and the synchronous flag is unset, a timeout event will then be dispatched, or a "TimeoutError" DOMException will be thrown otherwise (for the send() method). - * + * * When set: throws an "InvalidAccessError" DOMException if the synchronous flag is set and current global object is a Window object. */ timeout: number; @@ -5600,7 +5544,7 @@ interface XMLHttpRequest extends XMLHttpRequestEventTarget { readonly upload: XMLHttpRequestUpload; /** * True when credentials are to be included in a cross-origin request. False when they are to be excluded in a cross-origin request and when cookies are to be ignored in its response. Initially false. - * + * * When set: throws an "InvalidStateError" DOMException if state is not unsent or opened, or if the send() flag is set. */ withCredentials: boolean; @@ -5612,32 +5556,32 @@ interface XMLHttpRequest extends XMLHttpRequestEventTarget { getResponseHeader(name: string): string | null; /** * Sets the request method, request URL, and synchronous flag. - * + * * Throws a "SyntaxError" DOMException if either method is not a valid HTTP method or url cannot be parsed. - * + * * Throws a "SecurityError" DOMException if method is a case-insensitive match for `CONNECT`, `TRACE`, or `TRACK`. - * + * * Throws an "InvalidAccessError" DOMException if async is false, current global object is a Window object, and the timeout attribute is not zero or the responseType attribute is not the empty string. */ open(method: string, url: string): void; open(method: string, url: string, async: boolean, username?: string | null, password?: string | null): void; /** * Acts as if the `Content-Type` header value for response is mime. (It does not actually change the header though.) - * + * * Throws an "InvalidStateError" DOMException if state is loading or done. */ overrideMimeType(mime: string): void; /** * Initiates the request. The body argument provides the request body, if any, and is ignored if the request method is GET or HEAD. - * + * * Throws an "InvalidStateError" DOMException if either state is not opened or the send() flag is set. */ send(body?: BodyInit | null): void; /** * Combines a header in author request headers. - * + * * Throws an "InvalidStateError" DOMException if either state is not opened or the send() flag is set. - * + * * Throws a "SyntaxError" DOMException if name is not a header name or if value is not a header value. */ setRequestHeader(name: string, value: string): void; @@ -5737,34 +5681,34 @@ declare namespace WebAssembly { value: any; valueOf(): any; } - + var Global: { prototype: Global; new(descriptor: GlobalDescriptor, v?: any): Global; }; - + interface Instance { readonly exports: Exports; } - + var Instance: { prototype: Instance; new(module: Module, importObject?: Imports): Instance; }; - + interface Memory { readonly buffer: ArrayBuffer; grow(delta: number): number; } - + var Memory: { prototype: Memory; new(descriptor: MemoryDescriptor): Memory; }; - + interface Module { } - + var Module: { prototype: Module; new(bytes: BufferSource): Module; @@ -5772,51 +5716,52 @@ declare namespace WebAssembly { exports(moduleObject: Module): ModuleExportDescriptor[]; imports(moduleObject: Module): ModuleImportDescriptor[]; }; - + interface Table { readonly length: number; get(index: number): Function | null; grow(delta: number): number; set(index: number, value: Function | null): void; } - + var Table: { prototype: Table; new(descriptor: TableDescriptor): Table; }; - + interface GlobalDescriptor { mutable?: boolean; value: ValueType; } - + interface MemoryDescriptor { initial: number; maximum?: number; + shared?: boolean; } - + interface ModuleExportDescriptor { kind: ImportExportKind; name: string; } - + interface ModuleImportDescriptor { kind: ImportExportKind; module: string; name: string; } - + interface TableDescriptor { element: TableKind; initial: number; maximum?: number; } - + interface WebAssemblyInstantiatedSource { instance: Instance; module: Module; } - + type ImportExportKind = "function" | "global" | "memory" | "table"; type TableKind = "anyfunc"; type ValueType = "f32" | "f64" | "i32" | "i64"; diff --git a/lib/lib.webworker.iterable.d.ts b/lib/lib.webworker.iterable.d.ts index cef75d9e6d28f..2f3bdc9361fbf 100644 --- a/lib/lib.webworker.iterable.d.ts +++ b/lib/lib.webworker.iterable.d.ts @@ -80,7 +80,7 @@ interface IDBDatabase { interface IDBObjectStore { /** * Creates a new index in store with the given name, keyPath and options and returns a new IDBIndex. If the keyPath and options define constraints that cannot be satisfied with the data already in store the upgrade transaction will abort with a "ConstraintError" DOMException. - * + * * Throws an "InvalidStateError" DOMException if not called within an upgrade transaction. */ createIndex(name: string, keyPath: string | Iterable, options?: IDBIndexParameters): IDBIndex; diff --git a/lib/pl/diagnosticMessages.generated.json b/lib/pl/diagnosticMessages.generated.json index fb5cc54f24f1b..ee8ffaafcb15e 100644 --- a/lib/pl/diagnosticMessages.generated.json +++ b/lib/pl/diagnosticMessages.generated.json @@ -199,6 +199,7 @@ "An_implementation_cannot_be_declared_in_ambient_contexts_1183": "Implementacja nie może być zadeklarowana w otaczających kontekstach.", "An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type_1379": "Alias importu nie może odwoływać się do deklaracji, która została wyeksportowana przy użyciu elementu „export type”.", "An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type_1380": "Alias importu nie może odwoływać się do deklaracji, która została zaimportowana przy użyciu elementu „import type”.", + "An_import_alias_cannot_use_import_type_1392": "Alias importu nie może używać właściwości „import type”", "An_import_declaration_can_only_be_used_in_a_namespace_or_module_1232": "Deklaracja importu może być używana tylko w przestrzeni nazw lub module.", "An_import_declaration_cannot_have_modifiers_1191": "Deklaracja importu nie może mieć modyfikatorów.", "An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead_2691": "Ścieżka importu nie może kończyć się rozszerzeniem „{0}”. Rozważ zaimportowanie „{1}”.", @@ -443,6 +444,7 @@ "Default_export_of_the_module_has_or_is_using_private_name_0_4082": "Domyślny eksport modułu ma nazwę prywatną „{0}” lub używa tej nazwy.", "Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0_6200": "Definicje następujących identyfikatorów powodują konflikt z tymi w innym pliku: {0}", "Delete_all_unused_declarations_95024": "Usuń wszystkie nieużywane deklaracje", + "Delete_all_unused_imports_95147": "Usuń wszystkie nieużywane importy", "Delete_the_outputs_of_all_projects_6365": "Usuń dane wyjściowe wszystkich projektów", "Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react__6084": "[Przestarzałe] Użyj w zastępstwie opcji „--jsxFactory”. Określ obiekt wywoływany dla elementu createElement przy określaniu jako celu emisji JSX „react”", "Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file_6170": "[Przestarzałe] Użyj w zastępstwie opcji „--outFile”. Połącz dane wyjściowe i wyemituj jako jeden plik", @@ -668,6 +670,7 @@ "Index_signatures_are_incompatible_2330": "Sygnatury indeksów są niezgodne.", "Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local_2395": "Wszystkie poszczególne deklaracje w scalonej deklaracji „{0}” muszą być wyeksportowane lub lokalne.", "Infer_all_types_from_usage_95023": "Wywnioskuj wszystkie typy na podstawie użycia", + "Infer_function_return_type_95148": "Wnioskuj zwracany typ funkcji", "Infer_parameter_types_from_usage_95012": "Wnioskuj typy parametrów na podstawie użycia", "Infer_this_type_of_0_from_usage_95080": "Wnioskuj typ „this” elementu „{0}” na podstawie użycia", "Infer_type_of_0_from_usage_95011": "Wnioskuj typ elementu „{0}” na podstawie użycia", @@ -814,7 +817,6 @@ "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018": "Literały ósemkowe są niedozwolone w inicjatorze składowych wyliczeń. Użyj składni „{0}”.", "Octal_literals_are_not_allowed_in_strict_mode_1121": "Literały ósemkowe są niedozwolone w trybie z ograniczeniami.", "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085": "Literały ósemkowe są niedostępne, jeśli językiem docelowym jest ECMAScript 5 lub nowszy. Użyj składni „{0}”.", - "Only_ECMAScript_imports_may_use_import_type_1370": "Tylko importy modułów języka ECMAScript mogą używać aliasu „typ importu”.", "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091": "W instrukcji „for...in” jest dozwolona tylko pojedyncza deklaracja zmiennej.", "Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement_1188": "W instrukcji „for...of” jest dozwolona tylko pojedyncza deklaracja zmiennej.", "Only_a_void_function_can_be_called_with_the_new_keyword_2350": "Tylko funkcja typu void może być wywoływana za pomocą słowa kluczowego „new”.", @@ -920,9 +922,11 @@ "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202": "Odwołania do projektu nie mogą tworzyć grafu kołowego. Wykryto cykl: {0}", "Projects_in_this_build_Colon_0_6355": "Projekty w tej kompilacji: {0}", "Projects_to_reference_6300": "Projekty do przywołania", + "Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0_4111": "Właściwość „{0}” pochodzi z sygnatury indeksu, dlatego należy uzyskiwać do niej dostęp za pomocą elementu [„{0}”].", "Property_0_does_not_exist_on_const_enum_1_2479": "Właściwość „{0}” nie istnieje w wyliczeniu ze specyfikatorem „const” „{1}”.", "Property_0_does_not_exist_on_type_1_2339": "Właściwość „{0}” nie istnieje w typie „{1}”.", "Property_0_does_not_exist_on_type_1_Did_you_mean_2_2551": "Właściwość „{0}” nie istnieje w typie „{1}”. Czy chodziło Ci o „{2}”?", + "Property_0_does_not_exist_on_type_1_Did_you_mean_to_access_the_static_member_2_instead_2576": "Właściwość „{0}” nie istnieje w typie „{1}”. Czy chodziło o uzyskanie dostępu do statycznego elementu członkowskiego „{2}”?", "Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_c_2550": "Właściwość „{0}” nie istnieje w typie „{1}”. Czy chcesz zmienić bibliotekę docelową? Spróbuj zmienić opcję kompilatora `lib` na „{2}” lub nowszą.", "Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor_2564": "Właściwość „{0}” nie ma inicjatora i nie jest na pewno przypisana w konstruktorze.", "Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation_7033": "Dla właściwości „{0}” niejawnie określono typ „any”, ponieważ jego metoda dostępu „get” nie ma adnotacji zwracanego typu.", @@ -932,7 +936,6 @@ "Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2_2416": "Właściwości „{0}” w typie „{1}” nie można przypisać do tej samej właściwości w typie podstawowym „{2}”.", "Property_0_in_type_1_is_not_assignable_to_type_2_2603": "Właściwości „{0}” w typie „{1}” nie można przypisać do typu „{2}”.", "Property_0_in_type_1_refers_to_a_different_member_that_cannot_be_accessed_from_within_type_2_18015": "Właściwość „{0}” w typie „{1}” odwołuje się do innego elementu członkowskiego, do którego nie można uzyskać dostępu z typu „{2}”.", - "Property_0_is_a_static_member_of_type_1_2576": "Właściwość „{0}” jest statyczną składową typu „{1}”.", "Property_0_is_declared_but_its_value_is_never_read_6138": "Właściwość „{0}” jest zadeklarowana, ale jej wartość nie jest nigdy odczytywana.", "Property_0_is_incompatible_with_index_signature_2530": "Właściwość „{0}” jest niezgodna z sygnaturą indeksu.", "Property_0_is_incompatible_with_rest_element_type_2573": "Właściwość „{0}” jest niezgodna z typem elementu rest.", @@ -1007,6 +1010,7 @@ "Report_errors_in_js_files_8019": "Zgłaszaj błędy w plikach js.", "Report_errors_on_unused_locals_6134": "Raportuj błędy dla nieużywanych elementów lokalnych.", "Report_errors_on_unused_parameters_6135": "Raportuj błędy dla nieużywanych parametrów.", + "Require_undeclared_properties_from_index_signatures_to_use_element_accesses_6803": "Wymagaj, aby niezadeklarowane właściwości z sygnatur indeksów korzystały z dostępów do elementów.", "Required_type_parameters_may_not_follow_optional_type_parameters_2706": "Wymagane parametry typu mogą nie być zgodne z opcjonalnymi parametrami typu.", "Resolution_for_module_0_was_found_in_cache_from_location_1_6147": "Znaleziono rozwiązanie dla modułu „{0}” w pamięci podręcznej z lokalizacji „{1}”.", "Resolve_keyof_to_string_valued_property_names_only_no_numbers_or_symbols_6195": "Rozwiązuj elementy „keyof” tylko do nazw właściwości mających jako wartość ciągi (nie liczby czy symbole).", @@ -1146,7 +1150,7 @@ "The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback_1060": "Pierwszym parametrem metody „then” obietnicy musi być wywołanie zwrotne.", "The_global_type_JSX_0_may_not_have_more_than_one_property_2608": "Dla typu globalnego „JSX.{0}” nie można określić więcej niż jednej właściwości.", "The_implementation_signature_is_declared_here_2750": "Sygnatura implementacji jest zadeklarowana tutaj.", - "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system_1343": "Metawłaściwość „import.meta” jest dozwolona tylko wtedy, gdy opcja „--module” ma wartość „esnext” lub „system”.", + "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_esnext_or_system_1343": "Metawłaściwość „import.meta” jest dozwolona tylko wtedy, gdy opcja „--module” ma wartość „es2020”, „esnext” lub „system”.", "The_inferred_type_of_0_cannot_be_named_without_a_reference_to_1_This_is_likely_not_portable_A_type_a_2742": "Wywnioskowany typ „{0}” nie może być nazwany bez odwołania do elementu „{1}”. Prawdopodobnie nie jest to przenośne. Konieczna jest adnotacja typu.", "The_inferred_type_of_0_references_a_type_with_a_cyclic_structure_which_cannot_be_trivially_serialize_5088": "Wywnioskowany typ elementu „{0}” odwołuje się do typu ze strukturą cykliczną, którego nie można serializować w prosty sposób. Wymagana jest adnotacja typu.", "The_inferred_type_of_0_references_an_inaccessible_1_type_A_type_annotation_is_necessary_2527": "Wnioskowany typ „{0}” przywołuje niedostępny typ „{1}”. Adnotacja typu jest konieczna.", @@ -1216,7 +1220,7 @@ "This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without_6234": "Tego wyrażenia nie można wywoływać, ponieważ jest to metoda dostępu „get”. Czy chodziło Ci o użycie go bez znaków „()”?", "This_expression_is_not_constructable_2351": "Tego wyrażenia nie można skonstruować.", "This_file_already_has_a_default_export_95130": "Ten plik ma już domyślny eksport", - "This_import_is_never_used_as_a_value_and_must_use_import_type_because_the_importsNotUsedAsValues_is__1371": "Ten import nigdy nie jest używany jako wartość i musi używać aliasu „import type”, ponieważ opcja „importsNotUsedAsValues” jest ustawiona na wartość „error”.", + "This_import_is_never_used_as_a_value_and_must_use_import_type_because_importsNotUsedAsValues_is_set__1371": "Ten import nigdy nie jest używany jako wartość i musi używać aliasu „import type”, ponieważ opcja „importsNotUsedAsValues” jest ustawiona na wartość „error”.", "This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_fil_6233": "To jest rozszerzana deklaracja. Rozważ przeniesienie deklaracji rozszerzenia do tego samego pliku.", "This_may_be_converted_to_an_async_function_80006": "To można przekonwertować na funkcję asynchroniczną.", "This_module_can_only_be_referenced_with_ECMAScript_imports_Slashexports_by_turning_on_the_0_flag_and_2497": "Do tego modułu można odwoływać się tylko za pomocą importów/eksportów języka ECMAScript, włączając flagę „{0}” i odwołując się do jego eksportu domyślnego.", @@ -1342,6 +1346,8 @@ "Updating_output_of_project_0_6373": "Trwa aktualizowanie danych wyjściowych projektu „{0}”...", "Updating_output_timestamps_of_project_0_6359": "Trwa aktualizowanie sygnatury czasowej danych wyjściowych projektu „{0}”...", "Updating_unchanged_output_timestamps_of_project_0_6371": "Trwa aktualizowanie niezmienionych sygnatur czasowych danych wyjściowych projektu „{0}”...", + "Use_element_access_for_0_95145": "Użyj dostępu do elementu w przypadku elementu „{0}”", + "Use_element_access_for_all_undeclared_properties_95146": "Użyj dostępu do elementu w przypadku wszystkich niezadeklarowanych właściwości.", "Use_synthetic_default_member_95016": "Użyj syntetycznej składowej „default”.", "Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher_2494": "Używanie ciągu w instrukcji „for...of” jest obsługiwane tylko w języku ECMAScript 5 lub nowszym.", "Using_compiler_options_of_project_reference_redirect_0_6215": "Using compiler options of project reference redirect '{0}'.", diff --git a/lib/protocol.d.ts b/lib/protocol.d.ts index 22e0d7f857e8c..d8faa2a20130d 100644 --- a/lib/protocol.d.ts +++ b/lib/protocol.d.ts @@ -501,6 +501,7 @@ declare namespace ts.server.protocol { type OrganizeImportsScope = GetCombinedCodeFixScope; interface OrganizeImportsRequestArgs { scope: OrganizeImportsScope; + skipDestructiveCodeActions?: boolean; } interface OrganizeImportsResponse extends Response { body: readonly FileCodeEdits[]; @@ -603,6 +604,41 @@ declare namespace ts.server.protocol { */ body?: string[]; } + /** + * A request to get encoded semantic classifications for a span in the file + */ + interface EncodedSemanticClassificationsRequest extends FileRequest { + arguments: EncodedSemanticClassificationsRequestArgs; + } + /** + * Arguments for EncodedSemanticClassificationsRequest request. + */ + interface EncodedSemanticClassificationsRequestArgs extends FileRequestArgs { + /** + * Start position of the span. + */ + start: number; + /** + * Length of the span. + */ + length: number; + /** + * Optional parameter for the semantic highlighting response, if absent it + * defaults to "original". + */ + format?: "original" | "2020"; + } + /** The response for a EncodedSemanticClassificationsRequest */ + interface EncodedSemanticClassificationsResponse extends Response { + body?: EncodedSemanticClassificationsResponseBody; + } + /** + * Implementation response message. Gives series of text spans depending on the format ar. + */ + interface EncodedSemanticClassificationsResponseBody { + endOfLineState: EndOfLineState; + spans: number[]; + } /** * Arguments in document highlight request; include: filesToSearch, file, * line, offset. @@ -672,21 +708,36 @@ declare namespace ts.server.protocol { */ file: string; } + interface JSDocTagInfo { + /** Name of the JSDoc tag */ + name: string; + /** + * Comment text after the JSDoc tag -- the text after the tag name until the next tag or end of comment + * Display parts when UserPreferences.displayPartsForJSDoc is true, flattened to string otherwise. + */ + text?: string | SymbolDisplayPart[]; + } interface TextSpanWithContext extends TextSpan { contextStart?: Location; contextEnd?: Location; } interface FileSpanWithContext extends FileSpan, TextSpanWithContext { } + interface DefinitionInfo extends FileSpanWithContext { + /** + * When true, the file may or may not exist. + */ + unverified?: boolean; + } interface DefinitionInfoAndBoundSpan { - definitions: readonly FileSpanWithContext[]; + definitions: readonly DefinitionInfo[]; textSpan: TextSpan; } /** * Definition response message. Gives text range for definition. */ interface DefinitionResponse extends Response { - body?: FileSpanWithContext[]; + body?: DefinitionInfo[]; } interface DefinitionInfoAndBoundSpanResponse extends Response { body?: DefinitionInfoAndBoundSpan; @@ -1070,18 +1121,21 @@ declare namespace ts.server.protocol { FixedPollingInterval = "FixedPollingInterval", PriorityPollingInterval = "PriorityPollingInterval", DynamicPriorityPolling = "DynamicPriorityPolling", + FixedChunkSizePolling = "FixedChunkSizePolling", UseFsEvents = "UseFsEvents", UseFsEventsOnParentDirectory = "UseFsEventsOnParentDirectory" } const enum WatchDirectoryKind { UseFsEvents = "UseFsEvents", FixedPollingInterval = "FixedPollingInterval", - DynamicPriorityPolling = "DynamicPriorityPolling" + DynamicPriorityPolling = "DynamicPriorityPolling", + FixedChunkSizePolling = "FixedChunkSizePolling" } const enum PollingWatchKind { FixedInterval = "FixedInterval", PriorityInterval = "PriorityInterval", - DynamicPriority = "DynamicPriority" + DynamicPriority = "DynamicPriority", + FixedChunkSize = "FixedChunkSize" } interface WatchOptions { watchFile?: WatchFileKind | ts.WatchFileKind; @@ -1383,6 +1437,7 @@ declare namespace ts.server.protocol { */ interface QuickInfoRequest extends FileLocationRequest { command: CommandTypes.Quickinfo; + arguments: FileLocationRequestArgs; } /** * Body of QuickInfoResponse. @@ -1410,8 +1465,9 @@ declare namespace ts.server.protocol { displayString: string; /** * Documentation associated with symbol. + * Display parts when UserPreferences.displayPartsForJSDoc is true, flattened to string otherwise. */ - documentation: string; + documentation: string | SymbolDisplayPart[]; /** * JSDoc tags associated with symbol. */ @@ -1532,7 +1588,7 @@ declare namespace ts.server.protocol { command: CommandTypes.Formatonkey; arguments: FormatOnKeyRequestArgs; } - type CompletionsTriggerCharacter = "." | '"' | "'" | "`" | "/" | "@" | "<" | "#"; + type CompletionsTriggerCharacter = "." | '"' | "'" | "`" | "/" | "@" | "<" | "#" | " "; /** * Arguments for completions messages. */ @@ -1577,6 +1633,7 @@ declare namespace ts.server.protocol { interface CompletionEntryIdentifier { name: string; source?: string; + data?: unknown; } /** * Completion entry details request; value of command field is @@ -1601,6 +1658,11 @@ declare namespace ts.server.protocol { */ kind: string; } + /** A part of a symbol description that links from a jsdoc @link tag to a declaration */ + interface JSDocLinkDisplayPart extends SymbolDisplayPart { + /** The location of the declaration that the @link tag links to. */ + target: FileSpan; + } /** * An item found in a completion response. */ @@ -1628,6 +1690,10 @@ declare namespace ts.server.protocol { * coupled with `replacementSpan` to replace a dotted access with a bracket access. */ insertText?: string; + /** + * `insertText` should be interpreted as a snippet if true. + */ + isSnippet?: true; /** * An optional span that indicates the text to be replaced by this completion item. * If present, this span should be used instead of the default one. @@ -1643,6 +1709,10 @@ declare namespace ts.server.protocol { * Identifier (not necessarily human-readable) identifying where this completion came from. */ source?: string; + /** + * Human-readable description of the `source`. + */ + sourceDisplay?: SymbolDisplayPart[]; /** * If true, this completion should be highlighted as recommended. There will only be one of these. * This will be set when we know the user should write an expression with a certain type and that type is an enum or constructable class. @@ -1656,9 +1726,20 @@ declare namespace ts.server.protocol { isFromUncheckedFile?: true; /** * If true, this completion was for an auto-import of a module not yet in the program, but listed - * in the project package.json. + * in the project package.json. Used for telemetry reporting. */ isPackageJsonImport?: true; + /** + * If true, this completion was an auto-import-style completion of an import statement (i.e., the + * module specifier was inserted along with the imported identifier). Used for telemetry reporting. + */ + isImportStatementCompletion?: true; + /** + * A property to be sent back to TS Server in the CompletionDetailsRequest, along with `name`, + * that allows TS Server to look up the symbol represented by the completion item, disambiguating + * items with the same name. + */ + data?: unknown; } /** * Additional completion entry details, available on demand @@ -1693,9 +1774,13 @@ declare namespace ts.server.protocol { */ codeActions?: CodeAction[]; /** - * Human-readable description of the `source` from the CompletionEntry. + * @deprecated Use `sourceDisplay` instead. */ source?: SymbolDisplayPart[]; + /** + * Human-readable description of the `source` from the CompletionEntry. + */ + sourceDisplay?: SymbolDisplayPart[]; } /** @deprecated Prefer CompletionInfoResponse, which supports several top-level fields in addition to the array of entries. */ interface CompletionsResponse extends Response { @@ -1714,6 +1799,7 @@ declare namespace ts.server.protocol { * must be used to commit that completion entry. */ readonly optionalReplacementSpan?: TextSpan; + readonly isIncomplete?: boolean; readonly entries: readonly CompletionEntry[]; } interface CompletionDetailsResponse extends Response { @@ -2496,6 +2582,15 @@ declare namespace ts.server.protocol { * This affects lone identifier completions but not completions on the right hand side of `obj.`. */ readonly includeCompletionsForModuleExports?: boolean; + /** + * Enables auto-import-style completions on partially-typed import statements. E.g., allows + * `import write|` to be completed to `import { writeFile } from "fs"`. + */ + readonly includeCompletionsForImportStatements?: boolean; + /** + * Allows completions to be formatted with snippet text, indicated by `CompletionItem["isSnippet"]`. + */ + readonly includeCompletionsWithSnippetText?: boolean; /** * If enabled, the completion list will include completions with invalid identifier names. * For those entries, The `insertText` and `replacementSpan` properties will be set to change from `.x` property access to `["x"]`. @@ -2516,6 +2611,8 @@ declare namespace ts.server.protocol { readonly provideRefactorNotApplicableReason?: boolean; readonly allowRenameOfImportPath?: boolean; readonly includePackageJsonAutoImports?: "auto" | "on" | "off"; + readonly displayPartsForJSDoc?: boolean; + readonly generateReturnInDocTemplate?: boolean; } interface CompilerOptions { allowJs?: boolean; @@ -2623,8 +2720,36 @@ declare namespace ts.server.protocol { ES2018 = "ES2018", ES2019 = "ES2019", ES2020 = "ES2020", + ES2021 = "ES2021", ESNext = "ESNext" } + const enum ClassificationType { + comment = 1, + identifier = 2, + keyword = 3, + numericLiteral = 4, + operator = 5, + stringLiteral = 6, + regularExpressionLiteral = 7, + whiteSpace = 8, + text = 9, + punctuation = 10, + className = 11, + enumName = 12, + interfaceName = 13, + moduleName = 14, + typeParameterName = 15, + typeAliasName = 16, + parameterName = 17, + docCommentTagName = 18, + jsxOpenTagName = 19, + jsxCloseTagName = 20, + jsxSelfClosingTagName = 21, + jsxAttribute = 22, + jsxText = 23, + jsxAttributeStringLiteralValue = 24, + bigintLiteral = 25 + } } declare namespace ts.server.protocol { @@ -2730,7 +2855,13 @@ declare namespace ts.server.protocol { */ jsxAttribute = "JSX attribute", /** String literal */ - string = "string" + string = "string", + /** Jsdoc @link: in `{@link C link text}`, the before and after text "{@link " and "}" */ + link = "link", + /** Jsdoc @link: in `{@link C link text}`, the entity name "C" */ + linkName = "link name", + /** Jsdoc @link: in `{@link C link text}`, the link text "link text" */ + linkText = "link text" } export interface TypeAcquisition { @@ -2754,11 +2885,6 @@ declare namespace ts.server.protocol { scriptKind?: ScriptKind; } - interface JSDocTagInfo { - name: string; - text?: string; - } - /** * Type of objects whose values are all of the same type. * The `in` and `for-in` operators can *not* be safely used, @@ -2785,6 +2911,7 @@ declare namespace ts.server.protocol { } declare namespace ts { // these types are empty stubs for types from services and should not be used directly + export type EndOfLineState = never; export type ScriptKind = never; export type WatchFileKind = never; export type WatchDirectoryKind = never; diff --git a/lib/pt-br/diagnosticMessages.generated.json b/lib/pt-br/diagnosticMessages.generated.json index adeb412ef0c4f..80ce2712e3eb0 100644 --- a/lib/pt-br/diagnosticMessages.generated.json +++ b/lib/pt-br/diagnosticMessages.generated.json @@ -151,8 +151,8 @@ "Add_undefined_type_to_property_0_95018": "Adicionar tipo 'indefinido' à propriedade '{0}'", "Add_unknown_conversion_for_non_overlapping_types_95069": "Adicionar conversão 'unknown' para tipos sem sobreposição", "Add_unknown_to_all_conversions_of_non_overlapping_types_95070": "Adicionar 'unknown' a todas as conversões de tipos sem sobreposição", - "Add_void_to_Promise_resolved_without_a_value_95143": "Adicionar 'void' à Promessa resolvida sem um valor", - "Add_void_to_all_Promises_resolved_without_a_value_95144": "Adicionar 'void' a todas as Promessas resolvidas sem um valor", + "Add_void_to_Promise_resolved_without_a_value_95143": "Adicionar 'void' ao Promise resolvido sem um valor", + "Add_void_to_all_Promises_resolved_without_a_value_95144": "Adicionar 'void' a todos os Promises resolvidos sem um valor", "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__5068": "Adicionar um arquivo tsconfig.json ajudará a organizar projetos que contêm arquivos TypeScript e JavaScript. Saiba mais em https://aka.ms/tsconfig.", "Additional_Checks_6176": "Verificações Adicionais", "Advanced_Options_6178": "Opções Avançadas", @@ -199,6 +199,7 @@ "An_implementation_cannot_be_declared_in_ambient_contexts_1183": "Uma implementação não pode ser declarada em contextos de ambiente.", "An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type_1379": "Um alias de importação não pode fazer referência a uma declaração que foi exportada usando 'tipo de exportação'.", "An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type_1380": "Um alias de importação não pode fazer referência a uma declaração que foi importada usando 'tipo de importação'.", + "An_import_alias_cannot_use_import_type_1392": "Um alias de importação não pode usar um 'tipo de importação'", "An_import_declaration_can_only_be_used_in_a_namespace_or_module_1232": "Uma declaração de importação só pode ser usada em um namespace ou módulo.", "An_import_declaration_cannot_have_modifiers_1191": "Uma declaração de importação não pode ter modificadores.", "An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead_2691": "Um caminho de importação não pode terminar com uma extensão '{0}'. Considere importar '{1}'.", @@ -443,6 +444,7 @@ "Default_export_of_the_module_has_or_is_using_private_name_0_4082": "A exportação padrão do módulo tem ou está usando o nome particular '{0}'.", "Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0_6200": "As definições dos seguintes identificadores estão em conflito com as de outro arquivo: {0}", "Delete_all_unused_declarations_95024": "Excluir todas as declarações não usadas", + "Delete_all_unused_imports_95147": "Excluir todas as importações não usadas", "Delete_the_outputs_of_all_projects_6365": "Excluir as saídas de todos os projetos", "Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react__6084": "[Preterido] Use '--jsxFactory' no lugar. Especifique o objeto invocado para createElement ao direcionar uma emissão de JSX 'react'", "Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file_6170": "[Preterido] Use '--outFile' no lugar. Concatene e emita uma saída para um arquivo único", @@ -668,6 +670,7 @@ "Index_signatures_are_incompatible_2330": "As assinaturas de índice são incompatíveis.", "Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local_2395": "Todas as declarações individuais na declaração mesclada '{0}' devem ser exportadas ou ficar no local.", "Infer_all_types_from_usage_95023": "Inferir todos os tipos de uso", + "Infer_function_return_type_95148": "Inferir o tipo de retorno da função", "Infer_parameter_types_from_usage_95012": "Inferir tipos de parâmetro pelo uso", "Infer_this_type_of_0_from_usage_95080": "Inferir tipo 'this' de '{0}' do uso", "Infer_type_of_0_from_usage_95011": "Inferir tipo de '{0}' pelo uso", @@ -814,7 +817,6 @@ "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018": "Literais octais não são permitidos em inicializador de membros de enumerações. Use a sintaxe '{0}'.", "Octal_literals_are_not_allowed_in_strict_mode_1121": "Literais octais não são permitidos no modo estrito.", "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085": "Literais octais não estão disponíveis quando se tem como destino ECMAScript 5 e superiores. Use a sintaxe '{0}'.", - "Only_ECMAScript_imports_may_use_import_type_1370": "Somente importações ECMAScript podem usar 'import type'.", "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091": "É permitida apenas uma única declaração de variável em uma instrução 'for...in'.", "Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement_1188": "É permitida apenas uma única declaração de variável em uma instrução 'for...of'.", "Only_a_void_function_can_be_called_with_the_new_keyword_2350": "Apenas uma função void pode ser chamada com a palavra-chave 'new'.", @@ -920,9 +922,11 @@ "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202": "Referências de projeto não podem formar um gráfico circular. Ciclo detectado: {0}", "Projects_in_this_build_Colon_0_6355": "Projetos neste build: {0}", "Projects_to_reference_6300": "Projetos a serem referenciados", + "Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0_4111": "A propriedade '{0}' vem de uma assinatura de índice, portanto, ela precisa ser acessada com ['{0}'].", "Property_0_does_not_exist_on_const_enum_1_2479": "A propriedade '{0}' não existe na enumeração 'const' '{1}'.", "Property_0_does_not_exist_on_type_1_2339": "A propriedade '{0}' não existe no tipo '{1}'.", "Property_0_does_not_exist_on_type_1_Did_you_mean_2_2551": "A propriedade '{0}' não existe no tipo '{1}'. Você quis dizer '{2}'?", + "Property_0_does_not_exist_on_type_1_Did_you_mean_to_access_the_static_member_2_instead_2576": "A propriedade '{0}' não existe no tipo '{1}'. Você queria acessar o membro estático '{2}'?", "Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_c_2550": "A propriedade '{0}' não existe no tipo '{1}'. Você precisa alterar sua biblioteca de destino? Tente alterar a opção `lib` do compilador para '{2}' ou posterior.", "Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor_2564": "A propriedade '{0}' não tem nenhum inicializador e não está definitivamente atribuída no construtor.", "Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation_7033": "A propriedade '{0}' tem implicitamente o tipo 'any' porque o acessador get não tem uma anotação de tipo de retorno.", @@ -932,7 +936,6 @@ "Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2_2416": "A propriedade '{0}' no tipo '{1}' não pode ser atribuída à mesma propriedade no tipo base '{2}'.", "Property_0_in_type_1_is_not_assignable_to_type_2_2603": "A propriedade '{0}' no tipo '{1}' não pode ser atribuída ao tipo '{2}'.", "Property_0_in_type_1_refers_to_a_different_member_that_cannot_be_accessed_from_within_type_2_18015": "A propriedade '{0}' no tipo '{1}' se refere a um membro diferente que não pode ser acessado por meio do tipo '{2}'.", - "Property_0_is_a_static_member_of_type_1_2576": "A propriedade '{0}' é um membro estático do tipo '{1}'.", "Property_0_is_declared_but_its_value_is_never_read_6138": "A propriedade '{0}' é declarada, mas seu valor nunca é lido.", "Property_0_is_incompatible_with_index_signature_2530": "A propriedade '{0}' é incompatível com a assinatura de índice.", "Property_0_is_incompatible_with_rest_element_type_2573": "A propriedade '{0}' é incompatível com o tipo de elemento REST.", @@ -994,8 +997,8 @@ "Remove_unnecessary_await_95086": "Remover 'await' desnecessário", "Remove_unreachable_code_95050": "Remover código inacessível", "Remove_unused_declaration_for_Colon_0_90004": "Remover declaração não usada para: '{0}'", - "Remove_unused_declarations_for_Colon_0_90041": "Remover a declaração não usada de: '{0}'", - "Remove_unused_destructuring_declaration_90039": "Remover a declaração de desestruturação não usada", + "Remove_unused_declarations_for_Colon_0_90041": "Remova as declarações não usadas de: '{0}'", + "Remove_unused_destructuring_declaration_90039": "Remova a declaração de desestruturação não usada", "Remove_unused_label_95053": "Remover rótulo não utilizado", "Remove_variable_statement_90010": "Remover instrução de variável", "Replace_0_with_Promise_1_90036": "Substituir '{0}' por 'Promise<{1}>'", @@ -1007,6 +1010,7 @@ "Report_errors_in_js_files_8019": "Relatar erros em arquivos .js.", "Report_errors_on_unused_locals_6134": "Relatar erros nos locais não utilizados.", "Report_errors_on_unused_parameters_6135": "Relatar erros nos parâmetros não utilizados.", + "Require_undeclared_properties_from_index_signatures_to_use_element_accesses_6803": "Exigir que as propriedades não declaradas de assinaturas de índice usem acessos de elemento.", "Required_type_parameters_may_not_follow_optional_type_parameters_2706": "Os parâmetros de tipo necessários podem não seguir os parâmetros de tipo opcionais.", "Resolution_for_module_0_was_found_in_cache_from_location_1_6147": "A resolução para o módulo '{0}' foi encontrada no cache do local '{1}'.", "Resolve_keyof_to_string_valued_property_names_only_no_numbers_or_symbols_6195": "Resolva 'keyof' somente para nomes de propriedades com valores de cadeia de caracteres (sem números nem símbolos).", @@ -1113,7 +1117,7 @@ "Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors_2337": "As chamadas super não são permitidas fora dos construtores ou em funções aninhadas dentro dos construtores.", "Suppress_excess_property_checks_for_object_literals_6072": "Verificações de propriedade de excesso de compactação para literais de objeto.", "Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures_6055": "Suprimir erros de noImplicitAny para objetos de indexação sem assinaturas de índice.", - "Switch_each_misused_0_to_1_95138": "Mudar cada '{0}' usado incorretamente para '{1}'", + "Switch_each_misused_0_to_1_95138": "Mude cada '{0}' usado incorretamente para '{1}'", "Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object_2470": "A referência 'symbol' não se refere ao objeto global do construtor Symbol.", "Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_supp_6228": "Chame sincronicamente retornos de chamadas e atualize o estado de observadores de diretório em plataformas que não têm suporte à observação recursiva nativamente.", "Syntax_Colon_0_6023": "Sintaxe: {0}", @@ -1146,7 +1150,7 @@ "The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback_1060": "O primeiro parâmetro do método 'then' de uma promessa deve ser um retorno de chamada.", "The_global_type_JSX_0_may_not_have_more_than_one_property_2608": "O tipo global 'JSX.{0}' não pode ter mais de uma propriedade.", "The_implementation_signature_is_declared_here_2750": "A assinatura de implementação é declarada aqui.", - "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system_1343": "A metapropriedade 'import.meta' só é permitida quando a opção '--module' é 'esnext' ou 'system'.", + "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_esnext_or_system_1343": "A metapropriedade 'import.meta' só é permitida quando a opção '--module' é 'es2020', 'esnext' ou 'system'.", "The_inferred_type_of_0_cannot_be_named_without_a_reference_to_1_This_is_likely_not_portable_A_type_a_2742": "O tipo inferido de '{0}' não pode ser nomeado sem uma referência a '{1}'. Isso provavelmente não é portátil. Uma anotação de tipo é necessária.", "The_inferred_type_of_0_references_a_type_with_a_cyclic_structure_which_cannot_be_trivially_serialize_5088": "O tipo inferido '{0}' faz referência a um tipo com uma estrutura cíclica que não pode ser serializada trivialmente. Uma anotação de tipo é necessária.", "The_inferred_type_of_0_references_an_inaccessible_1_type_A_type_annotation_is_necessary_2527": "O tipo inferido de '{0}' faz referência a um tipo '{1}' inacessível. Uma anotação de tipo é necessária.", @@ -1216,7 +1220,7 @@ "This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without_6234": "Esta expressão não pode ser chamada porque é um acessador 'get'. Você quis usá-la sem '()'?", "This_expression_is_not_constructable_2351": "Essa expressão não pode ser construída.", "This_file_already_has_a_default_export_95130": "Este arquivo já tem uma exportação padrão", - "This_import_is_never_used_as_a_value_and_must_use_import_type_because_the_importsNotUsedAsValues_is__1371": "Essa importação nunca é usada como um valor e deve usar 'tipo de importação' porque 'importsNotUsedAsValues' está definido como 'erro'.", + "This_import_is_never_used_as_a_value_and_must_use_import_type_because_importsNotUsedAsValues_is_set__1371": "Esta importação nunca é usada como um valor e precisa usar um 'tipo de importação' porque 'importsNotUsedAsValues' está definido como 'erro'.", "This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_fil_6233": "Esta é a declaração que está sendo aumentada. Considere mover a declaração em aumento para o mesmo arquivo.", "This_may_be_converted_to_an_async_function_80006": "Isso pode ser convertido em uma função assíncrona.", "This_module_can_only_be_referenced_with_ECMAScript_imports_Slashexports_by_turning_on_the_0_flag_and_2497": "Esse módulo só pode ser referenciado com importações/exportações de ECMAScript ligando o sinalizador '{0}' e referenciando sua exportação padrão.", @@ -1342,6 +1346,8 @@ "Updating_output_of_project_0_6373": "Atualizando a saída do projeto '{0}'...", "Updating_output_timestamps_of_project_0_6359": "Atualizando os carimbos de data/hora de saída do projeto '{0}'...", "Updating_unchanged_output_timestamps_of_project_0_6371": "Atualizando os carimbos de data/hora de saída inalterados do projeto '{0}'...", + "Use_element_access_for_0_95145": "Usar o acesso de elemento para '{0}'", + "Use_element_access_for_all_undeclared_properties_95146": "Usar o acesso de elemento para todas as propriedades não declaradas.", "Use_synthetic_default_member_95016": "Use o membro sintético 'padrão'.", "Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher_2494": "Há suporte para o uso de uma cadeia de caracteres em uma instrução 'for...of' somente no ECMAScript 5 e superior.", "Using_compiler_options_of_project_reference_redirect_0_6215": "Usando as opções do compilador de redirecionamento de referência do projeto '{0}'.", diff --git a/lib/ru/diagnosticMessages.generated.json b/lib/ru/diagnosticMessages.generated.json index f946a660bd6ab..438b21a22360f 100644 --- a/lib/ru/diagnosticMessages.generated.json +++ b/lib/ru/diagnosticMessages.generated.json @@ -199,6 +199,7 @@ "An_implementation_cannot_be_declared_in_ambient_contexts_1183": "Реализацию невозможно объявить в окружающих контекстах.", "An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type_1379": "Псевдоним импорта не может ссылаться на объявление, экспортированное с помощью \"export type\".", "An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type_1380": "Псевдоним импорта не может ссылаться на объявление, импортированное с помощью \"import type\".", + "An_import_alias_cannot_use_import_type_1392": "Псевдоним импорта не может использовать \"import type\".", "An_import_declaration_can_only_be_used_in_a_namespace_or_module_1232": "Объявление импорта может быть использовано только в пространстве имен или модуле.", "An_import_declaration_cannot_have_modifiers_1191": "Объявление импорта не может иметь модификаторы.", "An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead_2691": "Путь импорта не может заканчиваться расширением \"{0}\". Попробуйте импортировать \"{1}\".", @@ -443,6 +444,7 @@ "Default_export_of_the_module_has_or_is_using_private_name_0_4082": "Экспорт модуля по умолчанию использует или имеет закрытое имя \"{0}\".", "Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0_6200": "Определения следующих идентификаторов конфликтуют с определениями в другом файле: {0}", "Delete_all_unused_declarations_95024": "Удалить все неиспользуемые объявления", + "Delete_all_unused_imports_95147": "Удаление всех неиспользуемых импортов", "Delete_the_outputs_of_all_projects_6365": "Удалить выходные данные всех проектов", "Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react__6084": "[Устарело.] Используйте --jsxFactory. Укажите объект, вызываемый для createElement при целевом порождении JSX react", "Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file_6170": "[Устарело.] Используйте --outFile. Сцепление и порождение выходных данных в одном файле", @@ -668,6 +670,7 @@ "Index_signatures_are_incompatible_2330": "Сигнатуры индекса несовместимы.", "Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local_2395": "Все отдельные объявления в объединенном объявлении \"{0}\" должны быть экспортированными или локальными.", "Infer_all_types_from_usage_95023": "Вывести все типы исходя из использования", + "Infer_function_return_type_95148": "Вывод типа возвращаемого значения функции", "Infer_parameter_types_from_usage_95012": "Выведите типы параметров на основании их использования", "Infer_this_type_of_0_from_usage_95080": "Определить тип \"this\" для \"{0}\" из использования", "Infer_type_of_0_from_usage_95011": "Выведите тип \"{0}\" на основании его использования", @@ -814,7 +817,6 @@ "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018": "Восьмеричные литералы запрещены в инициализаторах членов перечисления. Используйте синтаксис \"{0}\".", "Octal_literals_are_not_allowed_in_strict_mode_1121": "Восьмеричные литералы запрещено использовать в строгом режиме.", "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085": "Восьмеричные литералы недоступны при выборе целевой платформы ECMAScript 5 и более поздних. Используйте синтаксис \"{0}\".", - "Only_ECMAScript_imports_may_use_import_type_1370": "Только импорты ECMAScript могут использовать \"import type\".", "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091": "В операторе for...in разрешено только одно объявление переменной.", "Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement_1188": "В операторе for...of разрешено только одно объявление переменной.", "Only_a_void_function_can_be_called_with_the_new_keyword_2350": "С помощью ключевого слова new можно вызвать только функцию void.", @@ -920,9 +922,11 @@ "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202": "Ссылки на проект не могут формировать циклический граф. Обнаружен цикл: {0}", "Projects_in_this_build_Colon_0_6355": "Проекты в этой сборке: {0}", "Projects_to_reference_6300": "Проекты для ссылки", + "Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0_4111": "Свойство \"{0}\" поступает из сигнатуры индекса, поэтому доступ к нему должен осуществляться с помощью [\"{0}\"].", "Property_0_does_not_exist_on_const_enum_1_2479": "Свойство \"{0}\" не существует в перечислении const \"{1}\".", "Property_0_does_not_exist_on_type_1_2339": "Свойство \"{0}\" не существует в типе \"{1}\".", "Property_0_does_not_exist_on_type_1_Did_you_mean_2_2551": "Свойство \"{0}\" не существует в типе \"{1}\". Вы имели в виду \"{2}\"?", + "Property_0_does_not_exist_on_type_1_Did_you_mean_to_access_the_static_member_2_instead_2576": "Свойство \"{0}\" отсутствует в типе \"{1}\". Вы хотели обратиться к статическому элементу \"{2}\"?", "Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_c_2550": "Свойство \"{0}\" не существует в типе \"{1}\". Вы хотите изменить целевую библиотеку? Попробуйте изменить параметр компилятора \"lib\" на \"{2}\" или более поздней версии.", "Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor_2564": "Свойство \"{0}\" не имеет инициализатора, и ему не гарантировано присваивание в конструкторе.", "Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation_7033": "Свойство \"{0}\" неявно имеет тип \"все\", так как для его метода доступа get не задана заметка с типом возвращаемого значения.", @@ -932,7 +936,6 @@ "Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2_2416": "Свойство \"{0}\" в типе \"{1}\" невозможно присвоить тому же свойству в базовом типе \"{2}\".", "Property_0_in_type_1_is_not_assignable_to_type_2_2603": "Свойство \"{0}\" в типе \"{1}\" не может быть присвоено типу \"{2}\".", "Property_0_in_type_1_refers_to_a_different_member_that_cannot_be_accessed_from_within_type_2_18015": "Свойство \"{0}\" в типе \"{1}\" ссылается на другой член, к которому невозможно обратиться из типа \"{2}\".", - "Property_0_is_a_static_member_of_type_1_2576": "Свойство \"{0}\" является статическим элементом типа \"{1}\".", "Property_0_is_declared_but_its_value_is_never_read_6138": "Свойство \"{0}\" объявлено, но его значение не было прочитано.", "Property_0_is_incompatible_with_index_signature_2530": "Свойство \"{0}\" несовместимо с сигнатурой индекса.", "Property_0_is_incompatible_with_rest_element_type_2573": "Свойство \"{0}\" несовместимо с типом элементов rest.", @@ -1007,6 +1010,7 @@ "Report_errors_in_js_files_8019": "Сообщать об ошибках в JS-файлах.", "Report_errors_on_unused_locals_6134": "Сообщать об ошибках в неиспользованных локальных переменных.", "Report_errors_on_unused_parameters_6135": "Сообщать об ошибках в неиспользованных параметрах.", + "Require_undeclared_properties_from_index_signatures_to_use_element_accesses_6803": "Требовать необъявленные свойства из сигнатур индекса для использования доступа к элементам.", "Required_type_parameters_may_not_follow_optional_type_parameters_2706": "Обязательные параметры типа не могут следовать за необязательными параметрами типа.", "Resolution_for_module_0_was_found_in_cache_from_location_1_6147": "Разрешение для модуля \"{0}\" найдено в кэше из расположения \"{1}\".", "Resolve_keyof_to_string_valued_property_names_only_no_numbers_or_symbols_6195": "Разрешать \"keyof\" только в имена свойств со строковым значением (не числа и не символы).", @@ -1146,7 +1150,7 @@ "The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback_1060": "Первым параметром метода then класса promise должен быть обратный вызов.", "The_global_type_JSX_0_may_not_have_more_than_one_property_2608": "Глобальный тип \"JSX.{0}\" не может иметь больше одного свойства.", "The_implementation_signature_is_declared_here_2750": "Здесь объявлена сигнатура реализации.", - "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system_1343": "Метасвойство \"import.meta\" разрешено, только если параметр \"--module\" имеет значение \"esnext\" или \"system\".", + "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_esnext_or_system_1343": "Метасвойство \"import.meta\" разрешено, только если параметр \"--module\" имеет значение \"es2020\", \"esnext\" или \"system\".", "The_inferred_type_of_0_cannot_be_named_without_a_reference_to_1_This_is_likely_not_portable_A_type_a_2742": "Выводимому типу \"{0}\" невозможно присвоить имя без ссылки на \"{1}\". Вероятно, оно не является переносимым. Требуется заметка с типом.", "The_inferred_type_of_0_references_a_type_with_a_cyclic_structure_which_cannot_be_trivially_serialize_5088": "Выводимый тип \"{0}\" ссылается на тип с циклической структурой, которая не может быть элементарно сериализована. Требуется заметка с типом.", "The_inferred_type_of_0_references_an_inaccessible_1_type_A_type_annotation_is_necessary_2527": "Выведенный тип \"{0}\" ссылается на недоступный тип \"{1}\". Требуется аннотация типа.", @@ -1216,7 +1220,7 @@ "This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without_6234": "Это выражение не может быть вызвано, так как оно является методом доступа get. Вы хотели использовать его без \"()\"?", "This_expression_is_not_constructable_2351": "Это выражение не может быть построено.", "This_file_already_has_a_default_export_95130": "Этот файл уже имеет экспорт по умолчанию.", - "This_import_is_never_used_as_a_value_and_must_use_import_type_because_the_importsNotUsedAsValues_is__1371": "Этот импорт никогда не используется в качестве значения и должен использовать \"import type\", так как для \"importsNotUsedAsValues\" задано значение \"error\".", + "This_import_is_never_used_as_a_value_and_must_use_import_type_because_importsNotUsedAsValues_is_set__1371": "Этот импорт никогда не используется в качестве значения и должен использовать \"import type\", так как для \"importsNotUsedAsValues\" задано значение \"error\".", "This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_fil_6233": "Это объявление дополняется другим объявлением. Попробуйте переместить дополняющее объявление в тот же файл.", "This_may_be_converted_to_an_async_function_80006": "Это можно преобразовать в асинхронную функцию.", "This_module_can_only_be_referenced_with_ECMAScript_imports_Slashexports_by_turning_on_the_0_flag_and_2497": "На этот модуль можно ссылаться только с помощью импортов/экспортов ECMAScript, включив флаг \"{0}\" и сославшись на его экспорт по умолчанию.", @@ -1342,6 +1346,8 @@ "Updating_output_of_project_0_6373": "Обновление выходных данных проекта \"{0}\"...", "Updating_output_timestamps_of_project_0_6359": "Обновление меток времени в выходных данных проекта \"{0}\"...", "Updating_unchanged_output_timestamps_of_project_0_6371": "Обновление меток времени в неизменившихся выходных данных проекта \"{0}\"...", + "Use_element_access_for_0_95145": "Использовать доступ к элементам для \"{0}\".", + "Use_element_access_for_all_undeclared_properties_95146": "Использовать доступ к элементам для всех необъявленных свойств.", "Use_synthetic_default_member_95016": "Используйте искусственный элемент \"default\".", "Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher_2494": "Использование строки для оператора for...of поддерживается только в ECMAScript 5 и более поздних версиях.", "Using_compiler_options_of_project_reference_redirect_0_6215": "Использование параметров компилятора для перенаправления ссылки на проект \"{0}\".", diff --git a/lib/tr/diagnosticMessages.generated.json b/lib/tr/diagnosticMessages.generated.json index 2b206ac61e70a..fdc2cd6fd8f9c 100644 --- a/lib/tr/diagnosticMessages.generated.json +++ b/lib/tr/diagnosticMessages.generated.json @@ -199,6 +199,7 @@ "An_implementation_cannot_be_declared_in_ambient_contexts_1183": "Uygulama, çevresel bağlamda bildirilemez.", "An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type_1379": "İçeri aktarma diğer adı, 'export type' kullanılarak dışarı aktarılan bir bildirime başvuramaz.", "An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type_1380": "İçeri aktarma diğer adı, 'import type' kullanılarak içeri aktarılan bir bildirime başvuramaz.", + "An_import_alias_cannot_use_import_type_1392": "İçeri aktarma diğer adı, 'import type' kullanamaz", "An_import_declaration_can_only_be_used_in_a_namespace_or_module_1232": "İçeri aktarma bildirimi yalnızca bir ad alanında veya modülde kullanılabilir.", "An_import_declaration_cannot_have_modifiers_1191": "İçeri aktarma bildirimi, değiştiricilere sahip olamaz.", "An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead_2691": "İçeri aktarma yolu '{0}' uzantısıyla bitemez. Bunun yerine '{1}' öğesini içeri aktarmayı deneyin.", @@ -443,6 +444,7 @@ "Default_export_of_the_module_has_or_is_using_private_name_0_4082": "Modülün varsayılan dışarı aktarımı '{0}' özel adına sahip veya bu adı kullanıyor.", "Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0_6200": "Şu tanımlayıcıların tanımları başka bir dosyadaki tanımlarla çakışıyor: {0}", "Delete_all_unused_declarations_95024": "Kullanılmayan tüm bildirimleri sil", + "Delete_all_unused_imports_95147": "Kullanılmayan tüm içeri aktarmaları sil", "Delete_the_outputs_of_all_projects_6365": "Tüm projelerin çıkışlarını sil", "Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react__6084": "[Kullanım Dışı] Bunun yerine '--jsxFactory' kullanın. 'react' JSX gösterimi hedefleniyorsa, createElement için çağrılan nesneyi belirtin", "Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file_6170": "[Kullanım Dışı] Bunun yerine '--outFile' kullanın. Çıkışı tek bir dosya olarak birleştirin ve gösterin", @@ -668,6 +670,7 @@ "Index_signatures_are_incompatible_2330": "Dizin imzaları uyumsuz.", "Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local_2395": "'{0}' birleştirilmiş bildirimindeki bildirimlerin tümü dışarı aktarılmış veya yerel olmalıdır.", "Infer_all_types_from_usage_95023": "Tüm türleri kullanımdan çıkar", + "Infer_function_return_type_95148": "İşlev dönüş türünü çıkarsa", "Infer_parameter_types_from_usage_95012": "Parametre türleri için kullanımdan çıkarım yap", "Infer_this_type_of_0_from_usage_95080": "Kullanımdan '{0}' öğesinin 'this' türünü çıkarsa", "Infer_type_of_0_from_usage_95011": "'{0}' türü için kullanımdan çıkarım yap", @@ -814,7 +817,6 @@ "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018": "Sabit listesi üyelerinin başlatıcısında sekizlik sabit değerlere izin verilmez. '{0}' söz dizimini kullanın.", "Octal_literals_are_not_allowed_in_strict_mode_1121": "Katı modda sekizlik sabit değerlere izin verilmez.", "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085": "ECMAScript 5 ve üzeri hedeflenirken sekizlik sabit değerler kullanılamaz. '{0}' söz dizimini kullanın.", - "Only_ECMAScript_imports_may_use_import_type_1370": "Yalnızca ECMAScript içeri aktarma işlemleri 'import type' kullanabilir.", "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091": "'for...in' deyiminde yalnızca tek bir değişken bildirimine izin verilir.", "Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement_1188": "'for...of' deyiminde yalnızca tek bir değişken bildirimine izin verilir.", "Only_a_void_function_can_be_called_with_the_new_keyword_2350": "'new' anahtar sözcüğüyle yalnızca void işlevi çağrılabilir.", @@ -920,9 +922,11 @@ "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202": "Proje başvuruları döngüsel bir grafik formu oluşturamaz. Döngü tespit edildi: {0}", "Projects_in_this_build_Colon_0_6355": "Bu derlemedeki projeler: {0}", "Projects_to_reference_6300": "Başvurulacak projeler", + "Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0_4111": "'{0}' özelliği bir dizin imzasından geldiğinden ['{0}'] ile erişilmelidir.", "Property_0_does_not_exist_on_const_enum_1_2479": "'{0}' özelliği, '{1}' 'const' sabit listesi üzerinde değil.", "Property_0_does_not_exist_on_type_1_2339": "'{0}' özelliği, '{1}' türünde değil.", "Property_0_does_not_exist_on_type_1_Did_you_mean_2_2551": "'{0}' özelliği '{1}' türünde yok. Bunu mu demek istediniz: '{2}'?", + "Property_0_does_not_exist_on_type_1_Did_you_mean_to_access_the_static_member_2_instead_2576": "'{0}' özelliği '{1}' türünde yok. Bunun yerine '{2}' statik üyesine erişmek mi istediniz?", "Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_c_2550": "'{0}' özelliği '{1}' türünde yok. Hedef kitaplığınızı değiştirmeniz mi gerekiyor? `lib` derleyici seçeneğini '{2}' veya üzeri olarak değiştirmeyi deneyin.", "Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor_2564": "'{0}' özelliği başlatıcı içermiyor ve oluşturucuda kesin olarak atanmamış.", "Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation_7033": "'{0}' özelliği, get erişimcisinin dönüş türü ek açıklaması olmadığı için örtük olarak 'any' türü içeriyor.", @@ -932,7 +936,6 @@ "Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2_2416": "'{1}' türündeki '{0}' özelliği, '{2}' temel türündeki aynı özelliğe atanamaz.", "Property_0_in_type_1_is_not_assignable_to_type_2_2603": "'{1}' türündeki '{0}' özelliği, '{2}' türüne atanamaz.", "Property_0_in_type_1_refers_to_a_different_member_that_cannot_be_accessed_from_within_type_2_18015": "'{1}' türündeki '{0}' özelliği, '{2}' türünün içinden erişilemeyen farklı bir üyeye başvuruyor.", - "Property_0_is_a_static_member_of_type_1_2576": "'{0}' özelliği, '{1}' türünde statik bir üye.", "Property_0_is_declared_but_its_value_is_never_read_6138": "'{0}' özelliği bildirildi ancak değeri hiç okunmadı.", "Property_0_is_incompatible_with_index_signature_2530": "'{0}' özelliği, dizin imzasıyla uyumsuz.", "Property_0_is_incompatible_with_rest_element_type_2573": "'{0}' özelliği REST öğesi türüyle uyumsuz.", @@ -1007,6 +1010,7 @@ "Report_errors_in_js_files_8019": ".js dosyalarındaki hataları bildirin.", "Report_errors_on_unused_locals_6134": "Kullanılmayan yerel öğelerdeki hataları bildirin.", "Report_errors_on_unused_parameters_6135": "Kullanılmayan parametrelerdeki hataları bildirin.", + "Require_undeclared_properties_from_index_signatures_to_use_element_accesses_6803": "Öğe erişimlerini kullanmak için dizin imzalarından bildirilmemiş özellikler gerektirin.", "Required_type_parameters_may_not_follow_optional_type_parameters_2706": "Gerekli tür parametreleri, isteğe bağlı tür parametrelerini takip edemez.", "Resolution_for_module_0_was_found_in_cache_from_location_1_6147": "'{0}' modülünün çözümü '{1}' konumundaki önbellekte bulundu.", "Resolve_keyof_to_string_valued_property_names_only_no_numbers_or_symbols_6195": "'Keyof' değerini yalnızca dize değerli özellik adlarına (sayılar veya simgeler olmadan) çözümleyin.", @@ -1216,7 +1220,7 @@ "This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without_6234": "Bu ifade 'get' erişimcisi olduğundan çağrılamaz. Bunu '()' olmadan mı kullanmak istiyorsunuz?", "This_expression_is_not_constructable_2351": "Bu ifade oluşturulabilir değil.", "This_file_already_has_a_default_export_95130": "Bu dosyanın zaten varsayılan bir dışarı aktarması var", - "This_import_is_never_used_as_a_value_and_must_use_import_type_because_the_importsNotUsedAsValues_is__1371": "'importsNotUsedAsValues', 'error' olarak ayarlandığından bu içeri aktarma hiçbir zaman bir değer olarak kullanılmaz ve 'import type' kullanmalıdır.", + "This_import_is_never_used_as_a_value_and_must_use_import_type_because_importsNotUsedAsValues_is_set__1371": "'importsNotUsedAsValues' 'error' olarak ayarlandığından, bu içeri aktarma hiçbir zaman değer olarak kullanılmaz ve 'import type' kullanmalıdır.", "This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_fil_6233": "Bu, genişletilmekte olan bildirimdir. Genişleten bildirimi aynı dosyaya taşımayı düşünün.", "This_may_be_converted_to_an_async_function_80006": "Bu, asenkron bir işleve dönüştürülebilir.", "This_module_can_only_be_referenced_with_ECMAScript_imports_Slashexports_by_turning_on_the_0_flag_and_2497": "Bu modüle yalnızca '{0}' bayrağını açıp modülün varsayılan dışarı aktarma işlemine başvurarak ECMAScript içeri/dışarı aktarma işlemleri ile başvurulabilir.", @@ -1342,6 +1346,8 @@ "Updating_output_of_project_0_6373": "'{0}' projesinin çıkışı güncelleştiriliyor...", "Updating_output_timestamps_of_project_0_6359": "'{0}' projesinin çıkış zaman damgaları güncelleştiriliyor...", "Updating_unchanged_output_timestamps_of_project_0_6371": "'{0}' projesinin değiştirilmemiş çıkış zaman damgaları güncelleştiriliyor...", + "Use_element_access_for_0_95145": "'{0}' için öğe erişimi kullan", + "Use_element_access_for_all_undeclared_properties_95146": "Tüm bildirilmemiş özellikler için öğe erişimi kullanın.", "Use_synthetic_default_member_95016": "Yapay 'default' üyesini kullanın.", "Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher_2494": "'for...of' deyiminde dize kullanma yalnızca ECMAScript 5 veya üzerinde desteklenir.", "Using_compiler_options_of_project_reference_redirect_0_6215": "'{0}' proje başvurusu yeniden yönlendirmesinin derleyici seçenekleri kullanılıyor.", diff --git a/lib/tsc.js b/lib/tsc.js index f32c6225a899a..698e98d85100b 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -64,7 +64,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { }; var ts; (function (ts) { - ts.versionMajorMinor = "4.2"; + ts.versionMajorMinor = "4.4"; ts.version = ts.versionMajorMinor + ".0-dev"; var NativeCollections; (function (NativeCollections) { @@ -1590,8 +1590,38 @@ var ts; } ts.stringContains = stringContains; function removeMinAndVersionNumbers(fileName) { - var trailingMinOrVersion = /[.-]((min)|(\d+(\.\d+)*))$/; - return fileName.replace(trailingMinOrVersion, "").replace(trailingMinOrVersion, ""); + var end = fileName.length; + for (var pos = end - 1; pos > 0; pos--) { + var ch = fileName.charCodeAt(pos); + if (ch >= 48 && ch <= 57) { + do { + --pos; + ch = fileName.charCodeAt(pos); + } while (pos > 0 && ch >= 48 && ch <= 57); + } + else if (pos > 4 && (ch === 110 || ch === 78)) { + --pos; + ch = fileName.charCodeAt(pos); + if (ch !== 105 && ch !== 73) { + break; + } + --pos; + ch = fileName.charCodeAt(pos); + if (ch !== 109 && ch !== 77) { + break; + } + --pos; + ch = fileName.charCodeAt(pos); + } + else { + break; + } + if (ch !== 45 && ch !== 46) { + break; + } + end = pos; + } + return end === fileName.length ? fileName : fileName.slice(0, end); } ts.removeMinAndVersionNumbers = removeMinAndVersionNumbers; function orderedRemoveItem(array, item) { @@ -1806,6 +1836,18 @@ var ts; return array.slice(0, index); } ts.takeWhile = takeWhile; + ts.trimString = !!String.prototype.trim ? (function (s) { return s.trim(); }) : function (s) { return ts.trimStringEnd(ts.trimStringStart(s)); }; + ts.trimStringEnd = !!String.prototype.trimEnd ? (function (s) { return s.trimEnd(); }) : trimEndImpl; + ts.trimStringStart = !!String.prototype.trimStart ? (function (s) { return s.trimStart(); }) : function (s) { return s.replace(/^\s+/g, ""); }; + function trimEndImpl(s) { + var end = s.length - 1; + while (end >= 0) { + if (!ts.isWhiteSpaceLike(s.charCodeAt(end))) + break; + end--; + } + return s.slice(0, end + 1); + } })(ts || (ts = {})); var ts; (function (ts) { @@ -2005,6 +2047,8 @@ var ts; } } Debug.assertMissingNode = assertMissingNode; + function type(_value) { } + Debug.type = type; function getFunctionName(func) { if (typeof func !== "function") { return ""; @@ -2246,11 +2290,11 @@ var ts; this.objectFlags & 8 ? "TupleType" : this.objectFlags & 16 ? "AnonymousType" : this.objectFlags & 32 ? "MappedType" : - this.objectFlags & 2048 ? "ReverseMappedType" : + this.objectFlags & 1024 ? "ReverseMappedType" : this.objectFlags & 256 ? "EvolvingArrayType" : "ObjectType" : "Type"; - var remainingObjectFlags = this.flags & 524288 ? this.objectFlags & ~2367 : 0; + var remainingObjectFlags = this.flags & 524288 ? this.objectFlags & ~1343 : 0; return "" + typeHeader + (this.symbol ? " '" + ts.symbolName(this.symbol) + "'" : "") + (remainingObjectFlags ? " (" + formatObjectFlags(remainingObjectFlags) + ")" : ""); } }, @@ -2547,18 +2591,19 @@ var ts; return VersionRange; }()); ts.VersionRange = VersionRange; - var logicalOrRegExp = /\s*\|\|\s*/g; + var logicalOrRegExp = /\|\|/g; var whitespaceRegExp = /\s+/g; var partialRegExp = /^([xX*0]|[1-9]\d*)(?:\.([xX*0]|[1-9]\d*)(?:\.([xX*0]|[1-9]\d*)(?:-([a-z0-9-.]+))?(?:\+([a-z0-9-.]+))?)?)?$/i; var hyphenRegExp = /^\s*([a-z0-9-+.*]+)\s+-\s+([a-z0-9-+.*]+)\s*$/i; - var rangeRegExp = /^\s*(~|\^|<|<=|>|>=|=)?\s*([a-z0-9-+.*]+)$/i; + var rangeRegExp = /^(~|\^|<|<=|>|>=|=)?\s*([a-z0-9-+.*]+)$/i; function parseRange(text) { var alternatives = []; - for (var _i = 0, _a = text.trim().split(logicalOrRegExp); _i < _a.length; _i++) { + for (var _i = 0, _a = ts.trimString(text).split(logicalOrRegExp); _i < _a.length; _i++) { var range = _a[_i]; if (!range) continue; var comparators = []; + range = ts.trimString(range); var match = hyphenRegExp.exec(range); if (match) { if (!parseHyphen(match[1], match[2], comparators)) @@ -2567,7 +2612,7 @@ var ts; else { for (var _b = 0, _c = range.split(whitespaceRegExp); _b < _c.length; _b++) { var simple = _c[_b]; - var match_1 = rangeRegExp.exec(simple); + var match_1 = rangeRegExp.exec(ts.trimString(simple)); if (!match_1 || !parseComparator(match_1[1], match_1[2], comparators)) return undefined; } @@ -2708,40 +2753,41 @@ var ts; typeof PerformanceObserver === "function" && hasRequiredAPI(performance, PerformanceObserver)) { return { + shouldWriteNativeEvents: true, performance: performance, PerformanceObserver: PerformanceObserver }; } } function tryGetNodePerformanceHooks() { - if (typeof module === "object" && typeof require === "function") { + if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof module === "object" && typeof require === "function") { try { - var _a = require("perf_hooks"), performance_1 = _a.performance, PerformanceObserver_1 = _a.PerformanceObserver; - if (hasRequiredAPI(performance_1, PerformanceObserver_1)) { + var performance_1; + var _a = require("perf_hooks"), nodePerformance_1 = _a.performance, PerformanceObserver_1 = _a.PerformanceObserver; + if (hasRequiredAPI(nodePerformance_1, PerformanceObserver_1)) { + performance_1 = nodePerformance_1; var version_1 = new ts.Version(process.versions.node); var range = new ts.VersionRange("<12.16.3 || 13 <13.13"); if (range.test(version_1)) { - return { - performance: { - get timeOrigin() { return performance_1.timeOrigin; }, - now: function () { return performance_1.now(); }, - mark: function (name) { return performance_1.mark(name); }, - measure: function (name, start, end) { - if (start === void 0) { start = "nodeStart"; } - if (end === undefined) { - end = "__performance.measure-fix__"; - performance_1.mark(end); - } - performance_1.measure(name, start, end); - if (end === "__performance.measure-fix__") { - performance_1.clearMarks("__performance.measure-fix__"); - } + performance_1 = { + get timeOrigin() { return nodePerformance_1.timeOrigin; }, + now: function () { return nodePerformance_1.now(); }, + mark: function (name) { return nodePerformance_1.mark(name); }, + measure: function (name, start, end) { + if (start === void 0) { start = "nodeStart"; } + if (end === undefined) { + end = "__performance.measure-fix__"; + nodePerformance_1.mark(end); + } + nodePerformance_1.measure(name, start, end); + if (end === "__performance.measure-fix__") { + nodePerformance_1.clearMarks("__performance.measure-fix__"); } - }, - PerformanceObserver: PerformanceObserver_1 + } }; } return { + shouldWriteNativeEvents: false, performance: performance_1, PerformanceObserver: PerformanceObserver_1 }; @@ -2766,7 +2812,6 @@ var ts; var performance; (function (performance) { var perfHooks; - var perfObserver; var performanceImpl; function createTimerIf(condition, measureName, startMarkName, endMarkName) { return condition ? createTimer(measureName, startMarkName, endMarkName) : performance.nullTimer; @@ -2795,14 +2840,30 @@ var ts; } performance.createTimer = createTimer; performance.nullTimer = { enter: ts.noop, exit: ts.noop }; + var enabled = false; + var timeorigin = ts.timestamp(); + var marks = new ts.Map(); var counts = new ts.Map(); var durations = new ts.Map(); function mark(markName) { - performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.mark(markName); + var _a; + if (enabled) { + var count = (_a = counts.get(markName)) !== null && _a !== void 0 ? _a : 0; + counts.set(markName, count + 1); + marks.set(markName, ts.timestamp()); + performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.mark(markName); + } } performance.mark = mark; function measure(measureName, startMarkName, endMarkName) { - performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.measure(measureName, startMarkName, endMarkName); + var _a, _b; + if (enabled) { + var end = (_a = (endMarkName !== undefined ? marks.get(endMarkName) : undefined)) !== null && _a !== void 0 ? _a : ts.timestamp(); + var start = (_b = (startMarkName !== undefined ? marks.get(startMarkName) : undefined)) !== null && _b !== void 0 ? _b : timeorigin; + var previousDuration = durations.get(measureName) || 0; + durations.set(measureName, previousDuration + (end - start)); + performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.measure(measureName, startMarkName, endMarkName); + } } performance.measure = measure; function getCount(markName) { @@ -2818,38 +2879,35 @@ var ts; } performance.forEachMeasure = forEachMeasure; function isEnabled() { - return !!performanceImpl; + return enabled; } performance.isEnabled = isEnabled; - function enable() { - if (!performanceImpl) { + function enable(system) { + var _a; + if (system === void 0) { system = ts.sys; } + if (!enabled) { + enabled = true; perfHooks || (perfHooks = ts.tryGetNativePerformanceHooks()); - if (!perfHooks) - return false; - perfObserver || (perfObserver = new perfHooks.PerformanceObserver(updateStatisticsFromList)); - perfObserver.observe({ entryTypes: ["mark", "measure"] }); - performanceImpl = perfHooks.performance; + if (perfHooks) { + timeorigin = perfHooks.performance.timeOrigin; + if (perfHooks.shouldWriteNativeEvents || ((_a = system === null || system === void 0 ? void 0 : system.cpuProfilingEnabled) === null || _a === void 0 ? void 0 : _a.call(system)) || (system === null || system === void 0 ? void 0 : system.debugMode)) { + performanceImpl = perfHooks.performance; + } + } } return true; } performance.enable = enable; function disable() { - perfObserver === null || perfObserver === void 0 ? void 0 : perfObserver.disconnect(); - performanceImpl = undefined; - counts.clear(); - durations.clear(); - } - performance.disable = disable; - function updateStatisticsFromList(list) { - for (var _i = 0, _a = list.getEntriesByType("mark"); _i < _a.length; _i++) { - var mark_1 = _a[_i]; - counts.set(mark_1.name, (counts.get(mark_1.name) || 0) + 1); - } - for (var _b = 0, _c = list.getEntriesByType("measure"); _b < _c.length; _b++) { - var measure_1 = _c[_b]; - durations.set(measure_1.name, (durations.get(measure_1.name) || 0) + measure_1.duration); + if (enabled) { + marks.clear(); + counts.clear(); + durations.clear(); + performanceImpl = undefined; + enabled = false; } } + performance.disable = disable; })(performance = ts.performance || (ts.performance = {})); })(ts || (ts = {})); var ts; @@ -2889,38 +2947,37 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var tracing; - (function (tracing) { + var tracingEnabled; + (function (tracingEnabled) { var fs; var traceCount = 0; - var traceFd; + var traceFd = 0; var mode; + var typeCatalog = []; var legendPath; var legend = []; ; function startTracing(tracingMode, traceDir, configFilePath) { - ts.Debug.assert(!traceFd, "Tracing already started"); + ts.Debug.assert(!ts.tracing, "Tracing already started"); if (fs === undefined) { try { fs = require("fs"); } - catch (_a) { - fs = false; + catch (e) { + throw new Error("tracing requires having fs\n(original error: " + (e.message || e) + ")"); } } - if (!fs) { - return; - } mode = tracingMode; + typeCatalog.length = 0; if (legendPath === undefined) { legendPath = ts.combinePaths(traceDir, "legend.json"); } if (!fs.existsSync(traceDir)) { fs.mkdirSync(traceDir, { recursive: true }); } - var countPart = mode === 1 ? "." + process.pid + "-" + ++traceCount : - mode === 2 ? "." + process.pid : - ""; + var countPart = mode === "build" ? "." + process.pid + "-" + ++traceCount + : mode === "server" ? "." + process.pid + : ""; var tracePath = ts.combinePaths(traceDir, "trace" + countPart + ".json"); var typesPath = ts.combinePaths(traceDir, "types" + countPart + ".json"); legend.push({ @@ -2929,83 +2986,73 @@ var ts; typesPath: typesPath, }); traceFd = fs.openSync(tracePath, "w"); + ts.tracing = tracingEnabled; var meta = { cat: "__metadata", ph: "M", ts: 1000 * ts.timestamp(), pid: 1, tid: 1 }; fs.writeSync(traceFd, "[\n" + [__assign({ name: "process_name", args: { name: "tsc" } }, meta), __assign({ name: "thread_name", args: { name: "Main" } }, meta), __assign(__assign({ name: "TracingStartedInBrowser" }, meta), { cat: "disabled-by-default-devtools.timeline" })] .map(function (v) { return JSON.stringify(v); }).join(",\n")); } - tracing.startTracing = startTracing; - function stopTracing(typeCatalog) { - if (!traceFd) { - ts.Debug.assert(!fs, "Tracing is not in progress"); - return; - } - ts.Debug.assert(fs); - ts.Debug.assert(!!typeCatalog === (mode !== 2)); + tracingEnabled.startTracing = startTracing; + function stopTracing() { + ts.Debug.assert(ts.tracing, "Tracing is not in progress"); + ts.Debug.assert(!!typeCatalog.length === (mode !== "server")); fs.writeSync(traceFd, "\n]\n"); fs.closeSync(traceFd); - traceFd = undefined; - if (typeCatalog) { + ts.tracing = undefined; + if (typeCatalog.length) { dumpTypes(typeCatalog); } else { legend[legend.length - 1].typesPath = undefined; } } - tracing.stopTracing = stopTracing; - function isTracing() { - return !!traceFd; + tracingEnabled.stopTracing = stopTracing; + function recordType(type) { + if (mode !== "server") { + typeCatalog.push(type); + } } - tracing.isTracing = isTracing; + tracingEnabled.recordType = recordType; function instant(phase, name, args) { - if (!traceFd) - return; writeEvent("I", phase, name, args, "\"s\":\"g\""); } - tracing.instant = instant; + tracingEnabled.instant = instant; var eventStack = []; function push(phase, name, args, separateBeginAndEnd) { if (separateBeginAndEnd === void 0) { separateBeginAndEnd = false; } - if (!traceFd) - return; if (separateBeginAndEnd) { writeEvent("B", phase, name, args); } eventStack.push({ phase: phase, name: name, args: args, time: 1000 * ts.timestamp(), separateBeginAndEnd: separateBeginAndEnd }); } - tracing.push = push; + tracingEnabled.push = push; function pop() { - if (!traceFd) - return; ts.Debug.assert(eventStack.length > 0); writeStackEvent(eventStack.length - 1, 1000 * ts.timestamp()); eventStack.length--; } - tracing.pop = pop; + tracingEnabled.pop = pop; function popAll() { - if (!traceFd) - return; var endTime = 1000 * ts.timestamp(); for (var i = eventStack.length - 1; i >= 0; i--) { writeStackEvent(i, endTime); } eventStack.length = 0; } - tracing.popAll = popAll; + tracingEnabled.popAll = popAll; + var sampleInterval = 1000 * 10; function writeStackEvent(index, endTime) { var _a = eventStack[index], phase = _a.phase, name = _a.name, args = _a.args, time = _a.time, separateBeginAndEnd = _a.separateBeginAndEnd; if (separateBeginAndEnd) { writeEvent("E", phase, name, args, undefined, endTime); } - else { + else if (sampleInterval - (time % sampleInterval) <= endTime - time) { writeEvent("X", phase, name, args, "\"dur\":" + (endTime - time), time); } } function writeEvent(eventType, phase, name, args, extras, time) { if (time === void 0) { time = 1000 * ts.timestamp(); } - ts.Debug.assert(traceFd); - ts.Debug.assert(fs); - if (mode === 2 && phase === "checkTypes") + 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 + "\""); @@ -3017,15 +3064,24 @@ var ts; ts.performance.mark("endTracing"); ts.performance.measure("Tracing", "beginTracing", "endTracing"); } - function indexFromOne(lc) { - return { - line: lc.line + 1, - character: lc.character + 1, - }; + function getLocation(node) { + var file = ts.getSourceFileOfNode(node); + return !file + ? undefined + : { + path: file.path, + start: indexFromOne(ts.getLineAndCharacterOfPosition(file, node.pos)), + end: indexFromOne(ts.getLineAndCharacterOfPosition(file, node.end)), + }; + function indexFromOne(lc) { + return { + line: lc.line + 1, + character: lc.character + 1, + }; + } } function dumpTypes(types) { - var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r; - ts.Debug.assert(fs); + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x; ts.performance.mark("beginDumpTypes"); var typesPath = legend[legend.length - 1].typesPath; var typesFd = fs.openSync(typesPath, "w"); @@ -3036,14 +3092,12 @@ var ts; var type = types[i]; var objectFlags = type.objectFlags; var symbol = (_a = type.aliasSymbol) !== null && _a !== void 0 ? _a : type.symbol; - var firstDeclaration = (_b = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _b === void 0 ? void 0 : _b[0]; - var firstFile = firstDeclaration && ts.getSourceFileOfNode(firstDeclaration); var display = void 0; if ((objectFlags & 16) | (type.flags & 2944)) { try { - display = (_c = type.checker) === null || _c === void 0 ? void 0 : _c.typeToString(type); + display = (_b = type.checker) === null || _b === void 0 ? void 0 : _b.typeToString(type); } - catch (_s) { + catch (_y) { display = undefined; } } @@ -3051,26 +3105,52 @@ var ts; if (type.flags & 8388608) { var indexedAccessType = type; indexedAccessProperties = { - indexedAccessObjectType: (_d = indexedAccessType.objectType) === null || _d === void 0 ? void 0 : _d.id, - indexedAccessIndexType: (_e = indexedAccessType.indexType) === null || _e === void 0 ? void 0 : _e.id, + indexedAccessObjectType: (_c = indexedAccessType.objectType) === null || _c === void 0 ? void 0 : _c.id, + indexedAccessIndexType: (_d = indexedAccessType.indexType) === null || _d === void 0 ? void 0 : _d.id, }; } var referenceProperties = {}; if (objectFlags & 4) { var referenceType = type; referenceProperties = { - instantiatedType: (_f = referenceType.target) === null || _f === void 0 ? void 0 : _f.id, - typeArguments: (_g = referenceType.resolvedTypeArguments) === null || _g === void 0 ? void 0 : _g.map(function (t) { return t.id; }), + instantiatedType: (_e = referenceType.target) === null || _e === void 0 ? void 0 : _e.id, + typeArguments: (_f = referenceType.resolvedTypeArguments) === null || _f === void 0 ? void 0 : _f.map(function (t) { return t.id; }), + referenceLocation: getLocation(referenceType.node), }; } var conditionalProperties = {}; if (type.flags & 16777216) { var conditionalType = type; conditionalProperties = { - conditionalCheckType: (_h = conditionalType.checkType) === null || _h === void 0 ? void 0 : _h.id, - conditionalExtendsType: (_j = conditionalType.extendsType) === null || _j === void 0 ? void 0 : _j.id, - conditionalTrueType: (_l = (_k = conditionalType.resolvedTrueType) === null || _k === void 0 ? void 0 : _k.id) !== null && _l !== void 0 ? _l : -1, - conditionalFalseType: (_o = (_m = conditionalType.resolvedFalseType) === null || _m === void 0 ? void 0 : _m.id) !== null && _o !== void 0 ? _o : -1, + conditionalCheckType: (_g = conditionalType.checkType) === null || _g === void 0 ? void 0 : _g.id, + conditionalExtendsType: (_h = conditionalType.extendsType) === null || _h === void 0 ? void 0 : _h.id, + conditionalTrueType: (_k = (_j = conditionalType.resolvedTrueType) === null || _j === void 0 ? void 0 : _j.id) !== null && _k !== void 0 ? _k : -1, + conditionalFalseType: (_m = (_l = conditionalType.resolvedFalseType) === null || _l === void 0 ? void 0 : _l.id) !== null && _m !== void 0 ? _m : -1, + }; + } + var substitutionProperties = {}; + if (type.flags & 33554432) { + var substitutionType = type; + substitutionProperties = { + substitutionBaseType: (_o = substitutionType.baseType) === null || _o === void 0 ? void 0 : _o.id, + substituteType: (_p = substitutionType.substitute) === null || _p === void 0 ? void 0 : _p.id, + }; + } + var reverseMappedProperties = {}; + if (objectFlags & 1024) { + var reverseMappedType = type; + reverseMappedProperties = { + reverseMappedSourceType: (_q = reverseMappedType.source) === null || _q === void 0 ? void 0 : _q.id, + reverseMappedMappedType: (_r = reverseMappedType.mappedType) === null || _r === void 0 ? void 0 : _r.id, + reverseMappedConstraintType: (_s = reverseMappedType.constraintType) === null || _s === void 0 ? void 0 : _s.id, + }; + } + var evolvingArrayProperties = {}; + if (objectFlags & 256) { + var evolvingArrayType = type; + evolvingArrayProperties = { + evolvingArrayElementType: evolvingArrayType.elementType.id, + evolvingArrayFinalType: (_t = evolvingArrayType.finalArrayType) === null || _t === void 0 ? void 0 : _t.id, }; } var recursionToken = void 0; @@ -3082,11 +3162,7 @@ var ts; recursionIdentityMap.set(recursionIdentity, recursionToken); } } - var descriptor = __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, unionTypes: (type.flags & 1048576) ? (_p = type.types) === null || _p === void 0 ? void 0 : _p.map(function (t) { return t.id; }) : undefined, intersectionTypes: (type.flags & 2097152) ? type.types.map(function (t) { return t.id; }) : undefined, aliasTypeArguments: (_q = type.aliasTypeArguments) === null || _q === void 0 ? void 0 : _q.map(function (t) { return t.id; }), keyofType: (type.flags & 4194304) ? (_r = type.type) === null || _r === void 0 ? void 0 : _r.id : undefined }, indexedAccessProperties), referenceProperties), conditionalProperties), { firstDeclaration: firstDeclaration && { - path: firstFile.path, - start: indexFromOne(ts.getLineAndCharacterOfPosition(firstFile, firstDeclaration.pos)), - end: indexFromOne(ts.getLineAndCharacterOfPosition(ts.getSourceFileOfNode(firstDeclaration), firstDeclaration.end)), - }, 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 ? true : undefined, unionTypes: (type.flags & 1048576) ? (_u = type.types) === null || _u === void 0 ? void 0 : _u.map(function (t) { return t.id; }) : undefined, intersectionTypes: (type.flags & 2097152) ? 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) ? (_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"); @@ -3101,11 +3177,12 @@ var ts; if (!legendPath) { return; } - ts.Debug.assert(fs); fs.writeFileSync(legendPath, JSON.stringify(legend)); } - tracing.dumpLegend = dumpLegend; - })(tracing = ts.tracing || (ts.tracing = {})); + tracingEnabled.dumpLegend = dumpLegend; + })(tracingEnabled || (tracingEnabled = {})); + ts.startTracing = tracingEnabled.startTracing; + ts.dumpTracingLegend = tracingEnabled.dumpLegend; })(ts || (ts = {})); var ts; (function (ts) { @@ -3174,20 +3251,23 @@ var ts; WatchFileKind[WatchFileKind["FixedPollingInterval"] = 0] = "FixedPollingInterval"; WatchFileKind[WatchFileKind["PriorityPollingInterval"] = 1] = "PriorityPollingInterval"; WatchFileKind[WatchFileKind["DynamicPriorityPolling"] = 2] = "DynamicPriorityPolling"; - WatchFileKind[WatchFileKind["UseFsEvents"] = 3] = "UseFsEvents"; - WatchFileKind[WatchFileKind["UseFsEventsOnParentDirectory"] = 4] = "UseFsEventsOnParentDirectory"; + WatchFileKind[WatchFileKind["FixedChunkSizePolling"] = 3] = "FixedChunkSizePolling"; + WatchFileKind[WatchFileKind["UseFsEvents"] = 4] = "UseFsEvents"; + WatchFileKind[WatchFileKind["UseFsEventsOnParentDirectory"] = 5] = "UseFsEventsOnParentDirectory"; })(WatchFileKind = ts.WatchFileKind || (ts.WatchFileKind = {})); var WatchDirectoryKind; (function (WatchDirectoryKind) { WatchDirectoryKind[WatchDirectoryKind["UseFsEvents"] = 0] = "UseFsEvents"; WatchDirectoryKind[WatchDirectoryKind["FixedPollingInterval"] = 1] = "FixedPollingInterval"; WatchDirectoryKind[WatchDirectoryKind["DynamicPriorityPolling"] = 2] = "DynamicPriorityPolling"; + WatchDirectoryKind[WatchDirectoryKind["FixedChunkSizePolling"] = 3] = "FixedChunkSizePolling"; })(WatchDirectoryKind = ts.WatchDirectoryKind || (ts.WatchDirectoryKind = {})); var PollingWatchKind; (function (PollingWatchKind) { PollingWatchKind[PollingWatchKind["FixedInterval"] = 0] = "FixedInterval"; PollingWatchKind[PollingWatchKind["PriorityInterval"] = 1] = "PriorityInterval"; PollingWatchKind[PollingWatchKind["DynamicPriority"] = 2] = "DynamicPriority"; + PollingWatchKind[PollingWatchKind["FixedChunkSize"] = 3] = "FixedChunkSize"; })(PollingWatchKind = ts.PollingWatchKind || (ts.PollingWatchKind = {})); var ModuleKind; (function (ModuleKind) { @@ -3438,6 +3518,11 @@ var ts; } ts.getPathFromPathComponents = getPathFromPathComponents; function normalizeSlashes(path) { + var index = path.indexOf("\\"); + if (index === -1) { + return path; + } + backslashRegExp.lastIndex = index; return path.replace(backslashRegExp, ts.directorySeparator); } ts.normalizeSlashes = normalizeSlashes; @@ -3506,6 +3591,16 @@ var ts; ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath; function normalizePath(path) { path = normalizeSlashes(path); + if (!relativePathSegmentRegExp.test(path)) { + return path; + } + var simplified = path.replace(/\/\.\//g, "/").replace(/^\.\//, ""); + if (simplified !== path) { + path = simplified; + if (!relativePathSegmentRegExp.test(path)) { + return path; + } + } var normalized = getPathFromPathComponents(reducePathComponents(getPathComponents(path))); return normalized && hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalized) : normalized; } @@ -3561,7 +3656,7 @@ var ts; return pathext ? path.slice(0, path.length - pathext.length) + (ts.startsWith(ext, ".") ? ext : "." + ext) : path; } ts.changeAnyExtension = changeAnyExtension; - var relativePathSegmentRegExp = /(^|\/)\.{0,2}($|\/)/; + var relativePathSegmentRegExp = /(?:\/\/)|(?:^|\/)\.\.?(?:$|\/)/; function comparePathsWorker(a, b, componentComparer) { if (a === b) return 0; @@ -3741,6 +3836,10 @@ var ts; PollingInterval[PollingInterval["Low"] = 250] = "Low"; })(PollingInterval = ts.PollingInterval || (ts.PollingInterval = {})); ts.missingFileModifiedTime = new Date(0); + function getModifiedTime(host, fileName) { + return host.getModifiedTime(fileName) || ts.missingFileModifiedTime; + } + ts.getModifiedTime = getModifiedTime; function createPollingIntervalBasedLevels(levels) { var _a; return _a = {}, @@ -3795,6 +3894,44 @@ var ts; } } ts.setCustomPollingValues = setCustomPollingValues; + function pollWatchedFileQueue(host, queue, pollIndex, chunkSize, callbackOnWatchFileStat) { + var definedValueCopyToIndex = pollIndex; + for (var canVisit = queue.length; chunkSize && canVisit; nextPollIndex(), canVisit--) { + var watchedFile = queue[pollIndex]; + if (!watchedFile) { + continue; + } + else if (watchedFile.isClosed) { + queue[pollIndex] = undefined; + continue; + } + chunkSize--; + var fileChanged = onWatchedFileStat(watchedFile, getModifiedTime(host, watchedFile.fileName)); + if (watchedFile.isClosed) { + queue[pollIndex] = undefined; + continue; + } + callbackOnWatchFileStat === null || callbackOnWatchFileStat === void 0 ? void 0 : callbackOnWatchFileStat(watchedFile, pollIndex, fileChanged); + if (queue[pollIndex]) { + if (definedValueCopyToIndex < pollIndex) { + queue[definedValueCopyToIndex] = watchedFile; + queue[pollIndex] = undefined; + } + definedValueCopyToIndex++; + } + } + return pollIndex; + function nextPollIndex() { + pollIndex++; + if (pollIndex === queue.length) { + if (definedValueCopyToIndex < pollIndex) { + queue.length = definedValueCopyToIndex; + } + pollIndex = 0; + definedValueCopyToIndex = 0; + } + } + } function createDynamicPriorityPollingWatchFile(host) { var watchedFiles = []; var changedFilesInLastPoll = []; @@ -3807,7 +3944,7 @@ var ts; fileName: fileName, callback: callback, unchangedPolls: 0, - mtime: getModifiedTime(fileName) + mtime: getModifiedTime(host, fileName) }; watchedFiles.push(file); addToPollingIntervalQueue(file, defaultPollingInterval); @@ -3843,23 +3980,9 @@ var ts; } } function pollQueue(queue, pollingInterval, pollIndex, chunkSize) { - var needsVisit = queue.length; - var definedValueCopyToIndex = pollIndex; - for (var polled = 0; polled < chunkSize && needsVisit > 0; nextPollIndex(), needsVisit--) { - var watchedFile = queue[pollIndex]; - if (!watchedFile) { - continue; - } - else if (watchedFile.isClosed) { - queue[pollIndex] = undefined; - continue; - } - polled++; - var fileChanged = onWatchedFileStat(watchedFile, getModifiedTime(watchedFile.fileName)); - if (watchedFile.isClosed) { - queue[pollIndex] = undefined; - } - else if (fileChanged) { + return pollWatchedFileQueue(host, queue, pollIndex, chunkSize, onWatchFileStat); + function onWatchFileStat(watchedFile, pollIndex, fileChanged) { + if (fileChanged) { watchedFile.unchangedPolls = 0; if (queue !== changedFilesInLastPoll) { queue[pollIndex] = undefined; @@ -3879,24 +4002,6 @@ var ts; queue[pollIndex] = undefined; addToPollingIntervalQueue(watchedFile, pollingInterval === PollingInterval.Low ? PollingInterval.Medium : PollingInterval.High); } - if (queue[pollIndex]) { - if (definedValueCopyToIndex < pollIndex) { - queue[definedValueCopyToIndex] = watchedFile; - queue[pollIndex] = undefined; - } - definedValueCopyToIndex++; - } - } - return pollIndex; - function nextPollIndex() { - pollIndex++; - if (pollIndex === queue.length) { - if (definedValueCopyToIndex < pollIndex) { - queue.length = definedValueCopyToIndex; - } - pollIndex = 0; - definedValueCopyToIndex = 0; - } } } function pollingIntervalQueue(pollingInterval) { @@ -3925,9 +4030,6 @@ var ts; function scheduleNextPoll(pollingInterval) { pollingIntervalQueue(pollingInterval).pollScheduled = host.setTimeout(pollingInterval === PollingInterval.Low ? pollLowPollingIntervalQueue : pollPollingIntervalQueue, pollingInterval, pollingIntervalQueue(pollingInterval)); } - function getModifiedTime(fileName) { - return host.getModifiedTime(fileName) || ts.missingFileModifiedTime; - } } ts.createDynamicPriorityPollingWatchFile = createDynamicPriorityPollingWatchFile; function createUseFsEventsOnParentDirectoryWatchFile(fsWatch, useCaseSensitiveFileNames) { @@ -3974,6 +4076,37 @@ var ts; return watcher; } } + function createFixedChunkSizePollingWatchFile(host) { + var watchedFiles = []; + var pollIndex = 0; + var pollScheduled; + return watchFile; + function watchFile(fileName, callback) { + var file = { + fileName: fileName, + callback: callback, + mtime: getModifiedTime(host, fileName) + }; + watchedFiles.push(file); + scheduleNextPoll(); + return { + close: function () { + file.isClosed = true; + ts.unorderedRemoveItem(watchedFiles, file); + } + }; + } + function pollQueue() { + pollScheduled = undefined; + pollIndex = pollWatchedFileQueue(host, watchedFiles, pollIndex, pollingChunkSize[PollingInterval.Low]); + scheduleNextPoll(); + } + function scheduleNextPoll() { + if (!watchedFiles.length || pollScheduled) + return; + pollScheduled = host.setTimeout(pollQueue, PollingInterval.High); + } + } function createSingleFileWatcherPerName(watchFile, useCaseSensitiveFileNames) { var cache = new ts.Map(); var callbacksCache = ts.createMultiMap(); @@ -4248,8 +4381,9 @@ var ts; }; } function createSystemWatchFunctions(_a) { - var pollingWatchFile = _a.pollingWatchFile, getModifiedTime = _a.getModifiedTime, setTimeout = _a.setTimeout, clearTimeout = _a.clearTimeout, fsWatch = _a.fsWatch, fileExists = _a.fileExists, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, getCurrentDirectory = _a.getCurrentDirectory, fsSupportsRecursiveFsWatch = _a.fsSupportsRecursiveFsWatch, directoryExists = _a.directoryExists, getAccessibleSortedChildDirectories = _a.getAccessibleSortedChildDirectories, realpath = _a.realpath, tscWatchFile = _a.tscWatchFile, useNonPollingWatchers = _a.useNonPollingWatchers, tscWatchDirectory = _a.tscWatchDirectory; + var pollingWatchFile = _a.pollingWatchFile, getModifiedTime = _a.getModifiedTime, setTimeout = _a.setTimeout, clearTimeout = _a.clearTimeout, fsWatch = _a.fsWatch, fileExists = _a.fileExists, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, getCurrentDirectory = _a.getCurrentDirectory, fsSupportsRecursiveFsWatch = _a.fsSupportsRecursiveFsWatch, directoryExists = _a.directoryExists, getAccessibleSortedChildDirectories = _a.getAccessibleSortedChildDirectories, realpath = _a.realpath, tscWatchFile = _a.tscWatchFile, useNonPollingWatchers = _a.useNonPollingWatchers, tscWatchDirectory = _a.tscWatchDirectory, defaultWatchFileKind = _a.defaultWatchFileKind; var dynamicPollingWatchFile; + var fixedChunkSizePollingWatchFile; var nonPollingWatchFile; var hostRecursiveDirectoryWatcher; return { @@ -4266,6 +4400,8 @@ var ts; return pollingWatchFile(fileName, callback, pollingInterval, undefined); case ts.WatchFileKind.DynamicPriorityPolling: return ensureDynamicPollingWatchFile()(fileName, callback, pollingInterval, undefined); + case ts.WatchFileKind.FixedChunkSizePolling: + return ensureFixedChunkSizePollingWatchFile()(fileName, callback, undefined, undefined); case ts.WatchFileKind.UseFsEvents: return fsWatch(fileName, 0, createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists), false, pollingInterval, ts.getFallbackOptions(options)); case ts.WatchFileKind.UseFsEventsOnParentDirectory: @@ -4278,8 +4414,10 @@ var ts; } } function ensureDynamicPollingWatchFile() { - return dynamicPollingWatchFile || - (dynamicPollingWatchFile = createDynamicPriorityPollingWatchFile({ getModifiedTime: getModifiedTime, setTimeout: setTimeout })); + return dynamicPollingWatchFile || (dynamicPollingWatchFile = createDynamicPriorityPollingWatchFile({ getModifiedTime: getModifiedTime, setTimeout: setTimeout })); + } + function ensureFixedChunkSizePollingWatchFile() { + return fixedChunkSizePollingWatchFile || (fixedChunkSizePollingWatchFile = createFixedChunkSizePollingWatchFile({ getModifiedTime: getModifiedTime, setTimeout: setTimeout })); } function updateOptionsForWatchFile(options, useNonPollingWatchers) { if (options && options.watchFile !== undefined) @@ -4298,7 +4436,7 @@ var ts; default: return useNonPollingWatchers ? generateWatchFileOptions(ts.WatchFileKind.UseFsEventsOnParentDirectory, ts.PollingWatchKind.PriorityInterval, options) : - { watchFile: ts.WatchFileKind.FixedPollingInterval }; + { watchFile: (defaultWatchFileKind === null || defaultWatchFileKind === void 0 ? void 0 : defaultWatchFileKind()) || ts.WatchFileKind.FixedPollingInterval }; } } function generateWatchFileOptions(watchFile, fallbackPolling, options) { @@ -4337,6 +4475,8 @@ var ts; return pollingWatchFile(directoryName, function () { return callback(directoryName); }, PollingInterval.Medium, undefined); case ts.WatchDirectoryKind.DynamicPriorityPolling: return ensureDynamicPollingWatchFile()(directoryName, function () { return callback(directoryName); }, PollingInterval.Medium, undefined); + case ts.WatchDirectoryKind.FixedChunkSizePolling: + return ensureFixedChunkSizePollingWatchFile()(directoryName, function () { return callback(directoryName); }, undefined, undefined); case ts.WatchDirectoryKind.UseFsEvents: return fsWatch(directoryName, 1, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(watchDirectoryOptions)); default: @@ -4402,13 +4542,13 @@ var ts; } var activeSession; var profilePath = "./profile.cpuprofile"; - var realpathSync = (_a = _fs.realpathSync.native) !== null && _a !== void 0 ? _a : _fs.realpathSync; var Buffer = require("buffer").Buffer; var nodeVersion = getNodeMajorVersion(); var isNode4OrLater = nodeVersion >= 4; var isLinuxOrMacOs = process.platform === "linux" || process.platform === "darwin"; var platform = _os.platform(); var useCaseSensitiveFileNames = isFileSystemCaseSensitive(); + var realpathSync = useCaseSensitiveFileNames ? ((_a = _fs.realpathSync.native) !== null && _a !== void 0 ? _a : _fs.realpathSync) : _fs.realpathSync; var fsSupportsRecursiveFsWatch = isNode4OrLater && (process.platform === "win32" || process.platform === "darwin"); var getCurrentDirectory = ts.memoize(function () { return process.cwd(); }); var _c = createSystemWatchFunctions({ @@ -4427,6 +4567,7 @@ var ts; tscWatchFile: process.env.TSC_WATCHFILE, useNonPollingWatchers: process.env.TSC_NONPOLLING_WATCHER, tscWatchDirectory: process.env.TSC_WATCHDIRECTORY, + defaultWatchFileKind: function () { var _a, _b; return (_b = (_a = sys).defaultWatchFileKind) === null || _b === void 0 ? void 0 : _b.call(_a); }, }), watchFile = _c.watchFile, watchDirectory = _c.watchDirectory; var nodeSystem = { args: process.argv.slice(2), @@ -4492,6 +4633,7 @@ var ts; }, enableCPUProfiler: enableCPUProfiler, disableCPUProfiler: disableCPUProfiler, + cpuProfilingEnabled: function () { return !!activeSession || ts.contains(process.execArgv, "--cpu-prof") || ts.contains(process.execArgv, "--prof"); }, realpath: realpath, debugMode: !!process.env.NODE_INSPECTOR_IPC || !!process.env.VSCODE_INSPECTOR_OPTIONS || ts.some(process.execArgv, function (arg) { return /^--(inspect|debug)(-brk)?(=\d+)?$/i.test(arg); }), tryEnableSourceMapsForHost: function () { @@ -4694,7 +4836,7 @@ var ts; return event === "rename" && (!relativeName || relativeName === lastDirectoryPart || - relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length) && + (relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) !== -1 && relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length)) && !fileSystemEntryExists(fileOrDirectory, entryKind) ? invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry) : callback(event, relativeName); @@ -4976,9 +5118,10 @@ var ts; Invalid_use_of_0_in_strict_mode: diag(1100, ts.DiagnosticCategory.Error, "Invalid_use_of_0_in_strict_mode_1100", "Invalid use of '{0}' in strict mode."), with_statements_are_not_allowed_in_strict_mode: diag(1101, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_strict_mode_1101", "'with' statements are not allowed in strict mode."), delete_cannot_be_called_on_an_identifier_in_strict_mode: diag(1102, ts.DiagnosticCategory.Error, "delete_cannot_be_called_on_an_identifier_in_strict_mode_1102", "'delete' cannot be called on an identifier in strict mode."), - A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator: diag(1103, ts.DiagnosticCategory.Error, "A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator_1103", "A 'for-await-of' statement is only allowed within an async function or async generator."), + for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1103, ts.DiagnosticCategory.Error, "for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1103", "'for await' loops are only allowed within async functions and at the top levels of modules."), A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: diag(1104, ts.DiagnosticCategory.Error, "A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement_1104", "A 'continue' statement can only be used within an enclosing iteration statement."), A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: diag(1105, ts.DiagnosticCategory.Error, "A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement_1105", "A 'break' statement can only be used within an enclosing iteration or switch statement."), + The_left_hand_side_of_a_for_of_statement_may_not_be_async: diag(1106, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_of_statement_may_not_be_async_1106", "The left-hand side of a 'for...of' statement may not be 'async'."), Jump_target_cannot_cross_function_boundary: diag(1107, ts.DiagnosticCategory.Error, "Jump_target_cannot_cross_function_boundary_1107", "Jump target cannot cross function boundary."), A_return_statement_can_only_be_used_within_a_function_body: diag(1108, ts.DiagnosticCategory.Error, "A_return_statement_can_only_be_used_within_a_function_body_1108", "A 'return' statement can only be used within a function body."), Expression_expected: diag(1109, ts.DiagnosticCategory.Error, "Expression_expected_1109", "Expression expected."), @@ -5025,7 +5168,7 @@ var ts; A_yield_expression_is_only_allowed_in_a_generator_body: diag(1163, ts.DiagnosticCategory.Error, "A_yield_expression_is_only_allowed_in_a_generator_body_1163", "A 'yield' expression is only allowed in a generator body."), Computed_property_names_are_not_allowed_in_enums: diag(1164, ts.DiagnosticCategory.Error, "Computed_property_names_are_not_allowed_in_enums_1164", "Computed property names are not allowed in enums."), A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1165, ts.DiagnosticCategory.Error, "A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_t_1165", "A computed property name in an ambient context must refer to an expression whose type is a literal type or a 'unique symbol' type."), - A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1166, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_1166", "A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type."), + A_computed_property_name_in_a_class_property_declaration_must_have_a_simple_literal_type_or_a_unique_symbol_type: diag(1166, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_class_property_declaration_must_have_a_simple_literal_type_or_a_unique_1166", "A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type."), A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1168, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_ty_1168", "A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type."), A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1169, ts.DiagnosticCategory.Error, "A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_1169", "A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type."), A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1170, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type__1170", "A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type."), @@ -5085,7 +5228,7 @@ var ts; A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: diag(1228, ts.DiagnosticCategory.Error, "A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods_1228", "A type predicate is only allowed in return type position for functions and methods."), A_type_predicate_cannot_reference_a_rest_parameter: diag(1229, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_a_rest_parameter_1229", "A type predicate cannot reference a rest parameter."), A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: diag(1230, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_element_0_in_a_binding_pattern_1230", "A type predicate cannot reference element '{0}' in a binding pattern."), - An_export_assignment_can_only_be_used_in_a_module: diag(1231, ts.DiagnosticCategory.Error, "An_export_assignment_can_only_be_used_in_a_module_1231", "An export assignment can only be used in a module."), + An_export_assignment_must_be_at_the_top_level_of_a_file_or_module_declaration: diag(1231, ts.DiagnosticCategory.Error, "An_export_assignment_must_be_at_the_top_level_of_a_file_or_module_declaration_1231", "An export assignment must be at the top level of a file or module declaration."), An_import_declaration_can_only_be_used_in_a_namespace_or_module: diag(1232, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_in_a_namespace_or_module_1232", "An import declaration can only be used in a namespace or module."), An_export_declaration_can_only_be_used_in_a_module: diag(1233, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_in_a_module_1233", "An export declaration can only be used in a module."), An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: diag(1234, ts.DiagnosticCategory.Error, "An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file_1234", "An ambient module declaration is only allowed at the top level in a file."), @@ -5111,6 +5254,7 @@ var ts; A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_reference: diag(1254, ts.DiagnosticCategory.Error, "A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_refere_1254", "A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference."), A_definite_assignment_assertion_is_not_permitted_in_this_context: diag(1255, ts.DiagnosticCategory.Error, "A_definite_assignment_assertion_is_not_permitted_in_this_context_1255", "A definite assignment assertion '!' is not permitted in this context."), A_required_element_cannot_follow_an_optional_element: diag(1257, ts.DiagnosticCategory.Error, "A_required_element_cannot_follow_an_optional_element_1257", "A required element cannot follow an optional element."), + A_default_export_must_be_at_the_top_level_of_a_file_or_module_declaration: diag(1258, ts.DiagnosticCategory.Error, "A_default_export_must_be_at_the_top_level_of_a_file_or_module_declaration_1258", "A default export must be at the top level of a file or module declaration."), Module_0_can_only_be_default_imported_using_the_1_flag: diag(1259, ts.DiagnosticCategory.Error, "Module_0_can_only_be_default_imported_using_the_1_flag_1259", "Module '{0}' can only be default-imported using the '{1}' flag"), Keywords_cannot_contain_escape_characters: diag(1260, ts.DiagnosticCategory.Error, "Keywords_cannot_contain_escape_characters_1260", "Keywords cannot contain escape characters."), Already_included_file_name_0_differs_from_file_name_1_only_in_casing: diag(1261, ts.DiagnosticCategory.Error, "Already_included_file_name_0_differs_from_file_name_1_only_in_casing_1261", "Already included file name '{0}' differs from file name '{1}' only in casing."), @@ -5119,6 +5263,7 @@ var ts; Declarations_with_definite_assignment_assertions_must_also_have_type_annotations: diag(1264, ts.DiagnosticCategory.Error, "Declarations_with_definite_assignment_assertions_must_also_have_type_annotations_1264", "Declarations with definite assignment assertions must also have type annotations."), A_rest_element_cannot_follow_another_rest_element: diag(1265, ts.DiagnosticCategory.Error, "A_rest_element_cannot_follow_another_rest_element_1265", "A rest element cannot follow another rest element."), An_optional_element_cannot_follow_a_rest_element: diag(1266, ts.DiagnosticCategory.Error, "An_optional_element_cannot_follow_a_rest_element_1266", "An optional element cannot follow a rest element."), + Property_0_cannot_have_an_initializer_because_it_is_marked_abstract: diag(1267, ts.DiagnosticCategory.Error, "Property_0_cannot_have_an_initializer_because_it_is_marked_abstract_1267", "Property '{0}' cannot have an initializer because it is marked abstract."), with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1308, ts.DiagnosticCategory.Error, "await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1308", "'await' expressions are only allowed within async functions and at the top levels of modules."), 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: diag(1312, ts.DiagnosticCategory.Error, "Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_1312", "Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern."), @@ -5197,7 +5342,7 @@ var ts; Constructor_type_notation_must_be_parenthesized_when_used_in_an_intersection_type: diag(1388, ts.DiagnosticCategory.Error, "Constructor_type_notation_must_be_parenthesized_when_used_in_an_intersection_type_1388", "Constructor type notation must be parenthesized when used in an intersection type."), _0_is_not_allowed_as_a_variable_declaration_name: diag(1389, ts.DiagnosticCategory.Error, "_0_is_not_allowed_as_a_variable_declaration_name_1389", "'{0}' is not allowed as a variable declaration name."), Provides_a_root_package_name_when_using_outFile_with_declarations: diag(1390, ts.DiagnosticCategory.Message, "Provides_a_root_package_name_when_using_outFile_with_declarations_1390", "Provides a root package name when using outFile with declarations."), - The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_declaration_emit: diag(1391, ts.DiagnosticCategory.Error, "The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_de_1391", "The `bundledPackageName` option must be provided when using outFile and node module resolution with declaration emit."), + The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_declaration_emit: diag(1391, ts.DiagnosticCategory.Error, "The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_de_1391", "The 'bundledPackageName' option must be provided when using outFile and node module resolution with declaration emit."), An_import_alias_cannot_use_import_type: diag(1392, ts.DiagnosticCategory.Error, "An_import_alias_cannot_use_import_type_1392", "An import alias cannot use 'import type'"), Imported_via_0_from_file_1: diag(1393, ts.DiagnosticCategory.Message, "Imported_via_0_from_file_1_1393", "Imported via {0} from file '{1}'"), Imported_via_0_from_file_1_with_packageId_2: diag(1394, ts.DiagnosticCategory.Message, "Imported_via_0_from_file_1_with_packageId_2_1394", "Imported via {0} from file '{1}' with packageId '{2}'"), @@ -5237,6 +5382,9 @@ var ts; File_is_output_of_project_reference_source_0: diag(1428, ts.DiagnosticCategory.Message, "File_is_output_of_project_reference_source_0_1428", "File is output of project reference source '{0}'"), File_redirects_to_file_0: diag(1429, ts.DiagnosticCategory.Message, "File_redirects_to_file_0_1429", "File redirects to file '{0}'"), The_file_is_in_the_program_because_Colon: diag(1430, ts.DiagnosticCategory.Message, "The_file_is_in_the_program_because_Colon_1430", "The file is in the program because:"), + for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module: diag(1431, ts.DiagnosticCategory.Error, "for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_1431", "'for await' loops are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module."), + Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher: diag(1432, ts.DiagnosticCategory.Error, "Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_1432", "Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher."), + Decorators_may_not_be_applied_to_this_parameters: diag(1433, ts.DiagnosticCategory.Error, "Decorators_may_not_be_applied_to_this_parameters_1433", "Decorators may not be applied to 'this' parameters."), 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), @@ -5304,7 +5452,7 @@ var ts; The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2358, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter."), The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: diag(2359, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type."), The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: diag(2360, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol_2360", "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'."), - The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2361, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter_2361", "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter."), + The_right_hand_side_of_an_in_expression_must_not_be_a_primitive: diag(2361, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_in_expression_must_not_be_a_primitive_2361", "The right-hand side of an 'in' expression must not be a primitive."), The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2362, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2362", "The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."), The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2363, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2363", "The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."), The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: diag(2364, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", "The left-hand side of an assignment expression must be a variable or a property access."), @@ -5322,8 +5470,7 @@ var ts; A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_parameter_properties_or_private_identifiers: diag(2376, ts.DiagnosticCategory.Error, "A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_proper_2376", "A 'super' call must be the first statement in the constructor when a class contains initialized properties, parameter properties, or private identifiers."), Constructors_for_derived_classes_must_contain_a_super_call: diag(2377, ts.DiagnosticCategory.Error, "Constructors_for_derived_classes_must_contain_a_super_call_2377", "Constructors for derived classes must contain a 'super' call."), A_get_accessor_must_return_a_value: diag(2378, ts.DiagnosticCategory.Error, "A_get_accessor_must_return_a_value_2378", "A 'get' accessor must return a value."), - Getter_and_setter_accessors_do_not_agree_in_visibility: diag(2379, ts.DiagnosticCategory.Error, "Getter_and_setter_accessors_do_not_agree_in_visibility_2379", "Getter and setter accessors do not agree in visibility."), - get_and_set_accessor_must_have_the_same_type: diag(2380, ts.DiagnosticCategory.Error, "get_and_set_accessor_must_have_the_same_type_2380", "'get' and 'set' accessor must have the same type."), + The_return_type_of_a_get_accessor_must_be_assignable_to_its_set_accessor_type: diag(2380, ts.DiagnosticCategory.Error, "The_return_type_of_a_get_accessor_must_be_assignable_to_its_set_accessor_type_2380", "The return type of a 'get' accessor must be assignable to its 'set' accessor type"), A_signature_with_an_implementation_cannot_use_a_string_literal_type: diag(2381, ts.DiagnosticCategory.Error, "A_signature_with_an_implementation_cannot_use_a_string_literal_type_2381", "A signature with an implementation cannot use a string literal type."), Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: diag(2382, ts.DiagnosticCategory.Error, "Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature_2382", "Specialized overload signature is not assignable to any non-specialized signature."), Overload_signatures_must_all_be_exported_or_non_exported: diag(2383, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_exported_or_non_exported_2383", "Overload signatures must all be exported or non-exported."), @@ -5386,7 +5533,7 @@ var ts; Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2: diag(2443, ts.DiagnosticCategory.Error, "Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2_2443", "Property '{0}' is protected but type '{1}' is not a class derived from '{2}'."), Property_0_is_protected_in_type_1_but_public_in_type_2: diag(2444, ts.DiagnosticCategory.Error, "Property_0_is_protected_in_type_1_but_public_in_type_2_2444", "Property '{0}' is protected in type '{1}' but public in type '{2}'."), Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses: diag(2445, ts.DiagnosticCategory.Error, "Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses_2445", "Property '{0}' is protected and only accessible within class '{1}' and its subclasses."), - Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: diag(2446, ts.DiagnosticCategory.Error, "Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_2446", "Property '{0}' is protected and only accessible through an instance of class '{1}'."), + Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_This_is_an_instance_of_class_2: diag(2446, ts.DiagnosticCategory.Error, "Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_This_is_an_instance_of_cl_2446", "Property '{0}' is protected and only accessible through an instance of class '{1}'. This is an instance of class '{2}'."), The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: diag(2447, ts.DiagnosticCategory.Error, "The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead_2447", "The '{0}' operator is not allowed for boolean types. Consider using '{1}' instead."), Block_scoped_variable_0_used_before_its_declaration: diag(2448, ts.DiagnosticCategory.Error, "Block_scoped_variable_0_used_before_its_declaration_2448", "Block-scoped variable '{0}' used before its declaration."), Class_0_used_before_its_declaration: diag(2449, ts.DiagnosticCategory.Error, "Class_0_used_before_its_declaration_2449", "Class '{0}' used before its declaration."), @@ -5486,14 +5633,13 @@ var ts; The_type_returned_by_the_0_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_property: diag(2547, ts.DiagnosticCategory.Error, "The_type_returned_by_the_0_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_pro_2547", "The type returned by the '{0}()' method of an async iterator must be a promise for a type with a 'value' property."), Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator: diag(2548, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator_2548", "Type '{0}' is not an array type or does not have a '[Symbol.iterator]()' method that returns an iterator."), Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator: diag(2549, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns__2549", "Type '{0}' is not an array type or a string type or does not have a '[Symbol.iterator]()' method that returns an iterator."), - Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2_or_later: diag(2550, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_c_2550", "Property '{0}' does not exist on type '{1}'. Do you need to change your target library? Try changing the `lib` compiler option to '{2}' or later."), + Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2_or_later: diag(2550, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_c_2550", "Property '{0}' does not exist on type '{1}'. Do you need to change your target library? Try changing the 'lib' compiler option to '{2}' or later."), Property_0_does_not_exist_on_type_1_Did_you_mean_2: diag(2551, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Did_you_mean_2_2551", "Property '{0}' does not exist on type '{1}'. Did you mean '{2}'?"), Cannot_find_name_0_Did_you_mean_1: diag(2552, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Did_you_mean_1_2552", "Cannot find name '{0}'. Did you mean '{1}'?"), Computed_values_are_not_permitted_in_an_enum_with_string_valued_members: diag(2553, ts.DiagnosticCategory.Error, "Computed_values_are_not_permitted_in_an_enum_with_string_valued_members_2553", "Computed values are not permitted in an enum with string valued members."), Expected_0_arguments_but_got_1: diag(2554, ts.DiagnosticCategory.Error, "Expected_0_arguments_but_got_1_2554", "Expected {0} arguments, but got {1}."), Expected_at_least_0_arguments_but_got_1: diag(2555, ts.DiagnosticCategory.Error, "Expected_at_least_0_arguments_but_got_1_2555", "Expected at least {0} arguments, but got {1}."), - Expected_0_arguments_but_got_1_or_more: diag(2556, ts.DiagnosticCategory.Error, "Expected_0_arguments_but_got_1_or_more_2556", "Expected {0} arguments, but got {1} or more."), - Expected_at_least_0_arguments_but_got_1_or_more: diag(2557, ts.DiagnosticCategory.Error, "Expected_at_least_0_arguments_but_got_1_or_more_2557", "Expected at least {0} arguments, but got {1} or more."), + A_spread_argument_must_either_have_a_tuple_type_or_be_passed_to_a_rest_parameter: diag(2556, ts.DiagnosticCategory.Error, "A_spread_argument_must_either_have_a_tuple_type_or_be_passed_to_a_rest_parameter_2556", "A spread argument must either have a tuple type or be passed to a rest parameter."), Expected_0_type_arguments_but_got_1: diag(2558, ts.DiagnosticCategory.Error, "Expected_0_type_arguments_but_got_1_2558", "Expected {0} type arguments, but got {1}."), Type_0_has_no_properties_in_common_with_type_1: diag(2559, ts.DiagnosticCategory.Error, "Type_0_has_no_properties_in_common_with_type_1_2559", "Type '{0}' has no properties in common with type '{1}'."), Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it: diag(2560, ts.DiagnosticCategory.Error, "Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it_2560", "Value of type '{0}' has no properties in common with type '{1}'. Did you mean to call it?"), @@ -5516,17 +5662,17 @@ var ts; Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode: diag(2580, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashno_2580", "Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`."), Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery: diag(2581, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slash_2581", "Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i --save-dev @types/jquery`."), Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_types_Slashjest_or_npm_i_save_dev_types_Slashmocha: diag(2582, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_type_2582", "Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`."), - Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_1_or_later: diag(2583, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2583", "Cannot find name '{0}'. Do you need to change your target library? Try changing the `lib` compiler option to '{1}' or later."), - Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_include_dom: diag(2584, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2584", "Cannot find name '{0}'. Do you need to change your target library? Try changing the `lib` compiler option to include 'dom'."), - _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: diag(2585, ts.DiagnosticCategory.Error, "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_2585", "'{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."), + Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_1_or_later: diag(2583, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2583", "Cannot find name '{0}'. Do you need to change your target library? Try changing the 'lib' compiler option to '{1}' or later."), + Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_include_dom: diag(2584, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2584", "Cannot find name '{0}'. Do you need to change your target library? Try changing the 'lib' compiler option to include 'dom'."), + _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: diag(2585, ts.DiagnosticCategory.Error, "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_2585", "'{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."), Enum_type_0_circularly_references_itself: diag(2586, ts.DiagnosticCategory.Error, "Enum_type_0_circularly_references_itself_2586", "Enum type '{0}' circularly references itself."), JSDoc_type_0_circularly_references_itself: diag(2587, ts.DiagnosticCategory.Error, "JSDoc_type_0_circularly_references_itself_2587", "JSDoc type '{0}' circularly references itself."), Cannot_assign_to_0_because_it_is_a_constant: diag(2588, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_a_constant_2588", "Cannot assign to '{0}' because it is a constant."), Type_instantiation_is_excessively_deep_and_possibly_infinite: diag(2589, ts.DiagnosticCategory.Error, "Type_instantiation_is_excessively_deep_and_possibly_infinite_2589", "Type instantiation is excessively deep and possibly infinite."), Expression_produces_a_union_type_that_is_too_complex_to_represent: diag(2590, ts.DiagnosticCategory.Error, "Expression_produces_a_union_type_that_is_too_complex_to_represent_2590", "Expression produces a union type that is too complex to represent."), - Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode_and_then_add_node_to_the_types_field_in_your_tsconfig: diag(2591, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashno_2591", "Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node` and then add `node` to the types field in your tsconfig."), - Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery_and_then_add_jquery_to_the_types_field_in_your_tsconfig: diag(2592, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slash_2592", "Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i --save-dev @types/jquery` and then add `jquery` to the types field in your tsconfig."), - Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_types_Slashjest_or_npm_i_save_dev_types_Slashmocha_and_then_add_jest_or_mocha_to_the_types_field_in_your_tsconfig: diag(2593, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_type_2593", "Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode_and_then_add_node_to_the_types_field_in_your_tsconfig: diag(2591, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashno_2591", "Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node` and then add 'node' to the types field in your tsconfig."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery_and_then_add_jquery_to_the_types_field_in_your_tsconfig: diag(2592, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slash_2592", "Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i --save-dev @types/jquery` and then add 'jquery' to the types field in your tsconfig."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_types_Slashjest_or_npm_i_save_dev_types_Slashmocha_and_then_add_jest_or_mocha_to_the_types_field_in_your_tsconfig: diag(2593, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_type_2593", "Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig."), This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag: diag(2594, ts.DiagnosticCategory.Error, "This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the__2594", "This module is declared with using 'export =', and can only be used with a default import when using the '{0}' flag."), _0_can_only_be_imported_by_using_a_default_import: diag(2595, ts.DiagnosticCategory.Error, "_0_can_only_be_imported_by_using_a_default_import_2595", "'{0}' can only be imported by using a default import."), _0_can_only_be_imported_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import: diag(2596, ts.DiagnosticCategory.Error, "_0_can_only_be_imported_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import_2596", "'{0}' can only be imported by turning on the 'esModuleInterop' flag and using a default import."), @@ -5559,6 +5705,12 @@ var ts; Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target: diag(2625, ts.DiagnosticCategory.Error, "Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target_2625", "Variadic element at position {0} in source does not match element at position {1} in target."), Type_at_position_0_in_source_is_not_compatible_with_type_at_position_1_in_target: diag(2626, ts.DiagnosticCategory.Error, "Type_at_position_0_in_source_is_not_compatible_with_type_at_position_1_in_target_2626", "Type at position {0} in source is not compatible with type at position {1} in target."), Type_at_positions_0_through_1_in_source_is_not_compatible_with_type_at_position_2_in_target: diag(2627, ts.DiagnosticCategory.Error, "Type_at_positions_0_through_1_in_source_is_not_compatible_with_type_at_position_2_in_target_2627", "Type at positions {0} through {1} in source is not compatible with type at position {2} in target."), + Cannot_assign_to_0_because_it_is_an_enum: diag(2628, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_an_enum_2628", "Cannot assign to '{0}' because it is an enum."), + Cannot_assign_to_0_because_it_is_a_class: diag(2629, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_a_class_2629", "Cannot assign to '{0}' because it is a class."), + Cannot_assign_to_0_because_it_is_a_function: diag(2630, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_a_function_2630", "Cannot assign to '{0}' because it is a function."), + Cannot_assign_to_0_because_it_is_a_namespace: diag(2631, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_a_namespace_2631", "Cannot assign to '{0}' because it is a namespace."), + Cannot_assign_to_0_because_it_is_an_import: diag(2632, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_an_import_2632", "Cannot assign to '{0}' because it is an import."), + JSX_property_access_expressions_cannot_include_JSX_namespace_names: diag(2633, ts.DiagnosticCategory.Error, "JSX_property_access_expressions_cannot_include_JSX_namespace_names_2633", "JSX property access expressions cannot include JSX namespace names"), Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: diag(2649, ts.DiagnosticCategory.Error, "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", "Cannot augment module '{0}' with value exports because it resolves to a non-module entity."), A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: diag(2651, ts.DiagnosticCategory.Error, "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums."), Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: diag(2652, ts.DiagnosticCategory.Error, "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead."), @@ -5605,7 +5757,7 @@ var ts; Namespace_0_has_no_exported_member_1: diag(2694, ts.DiagnosticCategory.Error, "Namespace_0_has_no_exported_member_1_2694", "Namespace '{0}' has no exported member '{1}'."), Left_side_of_comma_operator_is_unused_and_has_no_side_effects: diag(2695, ts.DiagnosticCategory.Error, "Left_side_of_comma_operator_is_unused_and_has_no_side_effects_2695", "Left side of comma operator is unused and has no side effects.", true), The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead: diag(2696, ts.DiagnosticCategory.Error, "The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead_2696", "The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?"), - An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: diag(2697, ts.DiagnosticCategory.Error, "An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_in_2697", "An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option."), + An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: diag(2697, ts.DiagnosticCategory.Error, "An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_in_2697", "An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your '--lib' option."), Spread_types_may_only_be_created_from_object_types: diag(2698, ts.DiagnosticCategory.Error, "Spread_types_may_only_be_created_from_object_types_2698", "Spread types may only be created from object types."), Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1: diag(2699, ts.DiagnosticCategory.Error, "Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1_2699", "Static property '{0}' conflicts with built-in property 'Function.{0}' of constructor function '{1}'."), Rest_types_may_only_be_created_from_object_types: diag(2700, ts.DiagnosticCategory.Error, "Rest_types_may_only_be_created_from_object_types_2700", "Rest types may only be created from object types."), @@ -5613,14 +5765,14 @@ var ts; _0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here: diag(2702, ts.DiagnosticCategory.Error, "_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here_2702", "'{0}' only refers to a type, but is being used as a namespace here."), The_operand_of_a_delete_operator_must_be_a_property_reference: diag(2703, ts.DiagnosticCategory.Error, "The_operand_of_a_delete_operator_must_be_a_property_reference_2703", "The operand of a 'delete' operator must be a property reference."), The_operand_of_a_delete_operator_cannot_be_a_read_only_property: diag(2704, ts.DiagnosticCategory.Error, "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704", "The operand of a 'delete' operator cannot be a read-only property."), - 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: diag(2705, ts.DiagnosticCategory.Error, "An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_de_2705", "An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option."), + 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: diag(2705, ts.DiagnosticCategory.Error, "An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_de_2705", "An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option."), Required_type_parameters_may_not_follow_optional_type_parameters: diag(2706, ts.DiagnosticCategory.Error, "Required_type_parameters_may_not_follow_optional_type_parameters_2706", "Required type parameters may not follow optional type parameters."), Generic_type_0_requires_between_1_and_2_type_arguments: diag(2707, ts.DiagnosticCategory.Error, "Generic_type_0_requires_between_1_and_2_type_arguments_2707", "Generic type '{0}' requires between {1} and {2} type arguments."), Cannot_use_namespace_0_as_a_value: diag(2708, ts.DiagnosticCategory.Error, "Cannot_use_namespace_0_as_a_value_2708", "Cannot use namespace '{0}' as a value."), Cannot_use_namespace_0_as_a_type: diag(2709, ts.DiagnosticCategory.Error, "Cannot_use_namespace_0_as_a_type_2709", "Cannot use namespace '{0}' as a type."), _0_are_specified_twice_The_attribute_named_0_will_be_overwritten: diag(2710, ts.DiagnosticCategory.Error, "_0_are_specified_twice_The_attribute_named_0_will_be_overwritten_2710", "'{0}' are specified twice. The attribute named '{0}' will be overwritten."), - A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: diag(2711, ts.DiagnosticCategory.Error, "A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES20_2711", "A dynamic import call returns a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option."), - A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option: diag(2712, ts.DiagnosticCategory.Error, "A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declarat_2712", "A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option."), + A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: diag(2711, ts.DiagnosticCategory.Error, "A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES20_2711", "A dynamic import call returns a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your '--lib' option."), + A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option: diag(2712, ts.DiagnosticCategory.Error, "A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declarat_2712", "A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option."), 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: diag(2713, ts.DiagnosticCategory.Error, "Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_p_2713", "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}\"]'?"), The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context: diag(2714, ts.DiagnosticCategory.Error, "The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context_2714", "The expression of an export assignment must be an identifier or qualified name in an ambient context."), Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor: diag(2715, ts.DiagnosticCategory.Error, "Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor_2715", "Abstract property '{0}' in class '{1}' cannot be accessed in the constructor."), @@ -5682,7 +5834,7 @@ var ts; The_last_overload_is_declared_here: diag(2771, ts.DiagnosticCategory.Error, "The_last_overload_is_declared_here_2771", "The last overload is declared here."), Overload_0_of_1_2_gave_the_following_error: diag(2772, ts.DiagnosticCategory.Error, "Overload_0_of_1_2_gave_the_following_error_2772", "Overload {0} of {1}, '{2}', gave the following error."), Did_you_forget_to_use_await: diag(2773, ts.DiagnosticCategory.Error, "Did_you_forget_to_use_await_2773", "Did you forget to use 'await'?"), - This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead: diag(2774, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it__2774", "This condition will always return true since the function is always defined. Did you mean to call it instead?"), + This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_instead: diag(2774, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_2774", "This condition will always return true since this function is always defined. Did you mean to call it instead?"), Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation: diag(2775, ts.DiagnosticCategory.Error, "Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation_2775", "Assertions require every name in the call target to be declared with an explicit type annotation."), Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name: diag(2776, ts.DiagnosticCategory.Error, "Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name_2776", "Assertions require the call target to be an identifier or qualified name."), The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access: diag(2777, ts.DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access_2777", "The operand of an increment or decrement operator may not be an optional property access."), @@ -5706,6 +5858,23 @@ var ts; The_intrinsic_keyword_can_only_be_used_to_declare_compiler_provided_intrinsic_types: diag(2795, ts.DiagnosticCategory.Error, "The_intrinsic_keyword_can_only_be_used_to_declare_compiler_provided_intrinsic_types_2795", "The 'intrinsic' keyword can only be used to declare compiler provided intrinsic types."), It_is_likely_that_you_are_missing_a_comma_to_separate_these_two_template_expressions_They_form_a_tagged_template_expression_which_cannot_be_invoked: diag(2796, ts.DiagnosticCategory.Error, "It_is_likely_that_you_are_missing_a_comma_to_separate_these_two_template_expressions_They_form_a_tag_2796", "It is likely that you are missing a comma to separate these two template expressions. They form a tagged template expression which cannot be invoked."), A_mixin_class_that_extends_from_a_type_variable_containing_an_abstract_construct_signature_must_also_be_declared_abstract: diag(2797, ts.DiagnosticCategory.Error, "A_mixin_class_that_extends_from_a_type_variable_containing_an_abstract_construct_signature_must_also_2797", "A mixin class that extends from a type variable containing an abstract construct signature must also be declared 'abstract'."), + The_declaration_was_marked_as_deprecated_here: diag(2798, ts.DiagnosticCategory.Error, "The_declaration_was_marked_as_deprecated_here_2798", "The declaration was marked as deprecated here."), + Type_produces_a_tuple_type_that_is_too_large_to_represent: diag(2799, ts.DiagnosticCategory.Error, "Type_produces_a_tuple_type_that_is_too_large_to_represent_2799", "Type produces a tuple type that is too large to represent."), + Expression_produces_a_tuple_type_that_is_too_large_to_represent: diag(2800, ts.DiagnosticCategory.Error, "Expression_produces_a_tuple_type_that_is_too_large_to_represent_2800", "Expression produces a tuple type that is too large to represent."), + This_condition_will_always_return_true_since_this_0_is_always_defined: diag(2801, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_this_0_is_always_defined_2801", "This condition will always return true since this '{0}' is always defined."), + Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher: diag(2802, ts.DiagnosticCategory.Error, "Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es201_2802", "Type '{0}' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher."), + Cannot_assign_to_private_method_0_Private_methods_are_not_writable: diag(2803, ts.DiagnosticCategory.Error, "Cannot_assign_to_private_method_0_Private_methods_are_not_writable_2803", "Cannot assign to private method '{0}'. Private methods are not writable."), + Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name: diag(2804, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name_2804", "Duplicate identifier '{0}'. Static and instance elements cannot share the same private name."), + Static_fields_with_private_names_can_t_have_initializers_when_the_useDefineForClassFields_flag_is_not_specified_with_a_target_of_esnext_Consider_adding_the_useDefineForClassFields_flag: diag(2805, ts.DiagnosticCategory.Error, "Static_fields_with_private_names_can_t_have_initializers_when_the_useDefineForClassFields_flag_is_no_2805", "Static fields with private names can't have initializers when the '--useDefineForClassFields' flag is not specified with a '--target' of 'esnext'. Consider adding the '--useDefineForClassFields' flag."), + Private_accessor_was_defined_without_a_getter: diag(2806, ts.DiagnosticCategory.Error, "Private_accessor_was_defined_without_a_getter_2806", "Private accessor was defined without a getter."), + 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: diag(2807, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807", "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}'."), + A_get_accessor_must_be_at_least_as_accessible_as_the_setter: diag(2808, ts.DiagnosticCategory.Error, "A_get_accessor_must_be_at_least_as_accessible_as_the_setter_2808", "A get accessor must be at least as accessible as the setter"), + 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: diag(2809, ts.DiagnosticCategory.Error, "Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_d_2809", "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."), + Property_0_may_not_be_used_in_a_static_property_s_initializer_in_the_same_class_when_target_is_esnext_and_useDefineForClassFields_is_false: diag(2810, ts.DiagnosticCategory.Error, "Property_0_may_not_be_used_in_a_static_property_s_initializer_in_the_same_class_when_target_is_esnex_2810", "Property '{0}' may not be used in a static property's initializer in the same class when 'target' is 'esnext' and 'useDefineForClassFields' is 'false'."), + Initializer_for_property_0: diag(2811, ts.DiagnosticCategory.Error, "Initializer_for_property_0_2811", "Initializer for property '{0}'"), + Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom: diag(2812, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom_2812", "Property '{0}' does not exist on type '{1}'. Try changing the 'lib' compiler option to include 'dom'."), + Class_declaration_cannot_implement_overload_list_for_0: diag(2813, ts.DiagnosticCategory.Error, "Class_declaration_cannot_implement_overload_list_for_0_2813", "Class declaration cannot implement overload list for '{0}'."), + Function_with_bodies_can_only_merge_with_classes_that_are_ambient: diag(2814, ts.DiagnosticCategory.Error, "Function_with_bodies_can_only_merge_with_classes_that_are_ambient_2814", "Function with bodies can only merge with classes that are ambient."), 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}'."), @@ -5778,6 +5947,7 @@ var ts; Exported_type_alias_0_has_or_is_using_private_name_1: diag(4081, ts.DiagnosticCategory.Error, "Exported_type_alias_0_has_or_is_using_private_name_1_4081", "Exported type alias '{0}' has or is using private name '{1}'."), Default_export_of_the_module_has_or_is_using_private_name_0: diag(4082, ts.DiagnosticCategory.Error, "Default_export_of_the_module_has_or_is_using_private_name_0_4082", "Default export of the module has or is using private name '{0}'."), Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1: diag(4083, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1_4083", "Type parameter '{0}' of exported type alias has or is using private name '{1}'."), + Exported_type_alias_0_has_or_is_using_private_name_1_from_module_2: diag(4084, ts.DiagnosticCategory.Error, "Exported_type_alias_0_has_or_is_using_private_name_1_from_module_2_4084", "Exported type alias '{0}' has or is using private name '{1}' from module {2}."), Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict: diag(4090, ts.DiagnosticCategory.Error, "Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_librar_4090", "Conflicting definitions for '{0}' found at '{1}' and '{2}'. Consider installing a specific version of this library to resolve the conflict."), Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: diag(4091, ts.DiagnosticCategory.Error, "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4091", "Parameter '{0}' of index signature from exported interface has or is using name '{1}' from private module '{2}'."), Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1: diag(4092, ts.DiagnosticCategory.Error, "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1_4092", "Parameter '{0}' of index signature from exported interface has or is using private name '{1}'."), @@ -5799,6 +5969,12 @@ var ts; Type_arguments_for_0_circularly_reference_themselves: diag(4109, ts.DiagnosticCategory.Error, "Type_arguments_for_0_circularly_reference_themselves_4109", "Type arguments for '{0}' circularly reference themselves."), Tuple_type_arguments_circularly_reference_themselves: diag(4110, ts.DiagnosticCategory.Error, "Tuple_type_arguments_circularly_reference_themselves_4110", "Tuple type arguments circularly reference themselves."), Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0: diag(4111, ts.DiagnosticCategory.Error, "Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0_4111", "Property '{0}' comes from an index signature, so it must be accessed with ['{0}']."), + This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class: diag(4112, ts.DiagnosticCategory.Error, "This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another__4112", "This member cannot have an 'override' modifier because its containing class '{0}' does not extend another class."), + This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0: diag(4113, ts.DiagnosticCategory.Error, "This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0_4113", "This member cannot have an 'override' modifier because it is not declared in the base class '{0}'."), + This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0: diag(4114, ts.DiagnosticCategory.Error, "This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0_4114", "This member must have an 'override' modifier because it overrides a member in the base class '{0}'."), + This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0: diag(4115, ts.DiagnosticCategory.Error, "This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0_4115", "This parameter property must have an 'override' modifier because it overrides a member in base class '{0}'."), + This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0: diag(4116, ts.DiagnosticCategory.Error, "This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared__4116", "This member must have an 'override' modifier because it overrides an abstract method that is declared in the base class '{0}'."), + This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1: diag(4117, ts.DiagnosticCategory.Error, "This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0_Did_you__4117", "This member cannot have an 'override' modifier because it is not declared in the base class '{0}'. Did you mean '{1}'?"), The_current_host_does_not_support_the_0_option: diag(5001, ts.DiagnosticCategory.Error, "The_current_host_does_not_support_the_0_option_5001", "The current host does not support the '{0}' option."), Cannot_find_the_common_subdirectory_path_for_the_input_files: diag(5009, ts.DiagnosticCategory.Error, "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", "Cannot find the common subdirectory path for the input files."), File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5010, ts.DiagnosticCategory.Error, "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", "File specification cannot end in a recursive directory wildcard ('**'): '{0}'."), @@ -5833,7 +6009,7 @@ var ts; Option_resolveJsonModule_can_only_be_specified_when_module_code_generation_is_commonjs_amd_es2015_or_esNext: diag(5071, ts.DiagnosticCategory.Error, "Option_resolveJsonModule_can_only_be_specified_when_module_code_generation_is_commonjs_amd_es2015_or_5071", "Option '--resolveJsonModule' can only be specified when module code generation is 'commonjs', 'amd', 'es2015' or 'esNext'."), Unknown_build_option_0: diag(5072, ts.DiagnosticCategory.Error, "Unknown_build_option_0_5072", "Unknown build option '{0}'."), Build_option_0_requires_a_value_of_type_1: diag(5073, ts.DiagnosticCategory.Error, "Build_option_0_requires_a_value_of_type_1_5073", "Build option '{0}' requires a value of type {1}."), - Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified: diag(5074, ts.DiagnosticCategory.Error, "Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBui_5074", "Option '--incremental' can only be specified using tsconfig, emitting to single file or when option `--tsBuildInfoFile` is specified."), + Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified: diag(5074, ts.DiagnosticCategory.Error, "Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBui_5074", "Option '--incremental' can only be specified using tsconfig, emitting to single file or when option '--tsBuildInfoFile' is specified."), _0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2: diag(5075, ts.DiagnosticCategory.Error, "_0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_5075", "'{0}' is assignable to the constraint of type '{1}', but '{1}' could be instantiated with a different subtype of constraint '{2}'."), _0_and_1_operations_cannot_be_mixed_without_parentheses: diag(5076, ts.DiagnosticCategory.Error, "_0_and_1_operations_cannot_be_mixed_without_parentheses_5076", "'{0}' and '{1}' operations cannot be mixed without parentheses."), Unknown_build_option_0_Did_you_mean_1: diag(5077, ts.DiagnosticCategory.Error, "Unknown_build_option_0_Did_you_mean_1_5077", "Unknown build option '{0}'. Did you mean '{1}'?"), @@ -5846,10 +6022,14 @@ var ts; Tuple_members_must_all_have_names_or_all_not_have_names: diag(5084, ts.DiagnosticCategory.Error, "Tuple_members_must_all_have_names_or_all_not_have_names_5084", "Tuple members must all have names or all not have names."), A_tuple_member_cannot_be_both_optional_and_rest: diag(5085, ts.DiagnosticCategory.Error, "A_tuple_member_cannot_be_both_optional_and_rest_5085", "A tuple member cannot be both optional and rest."), A_labeled_tuple_element_is_declared_as_optional_with_a_question_mark_after_the_name_and_before_the_colon_rather_than_after_the_type: diag(5086, ts.DiagnosticCategory.Error, "A_labeled_tuple_element_is_declared_as_optional_with_a_question_mark_after_the_name_and_before_the_c_5086", "A labeled tuple element is declared as optional with a question mark after the name and before the colon, rather than after the type."), - A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type: diag(5087, ts.DiagnosticCategory.Error, "A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type_5087", "A labeled tuple element is declared as rest with a `...` before the name, rather than before the type."), + A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type: diag(5087, ts.DiagnosticCategory.Error, "A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type_5087", "A labeled tuple element is declared as rest with a '...' before the name, rather than before the type."), The_inferred_type_of_0_references_a_type_with_a_cyclic_structure_which_cannot_be_trivially_serialized_A_type_annotation_is_necessary: diag(5088, ts.DiagnosticCategory.Error, "The_inferred_type_of_0_references_a_type_with_a_cyclic_structure_which_cannot_be_trivially_serialize_5088", "The inferred type of '{0}' references a type with a cyclic structure which cannot be trivially serialized. A type annotation is necessary."), Option_0_cannot_be_specified_when_option_jsx_is_1: diag(5089, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_when_option_jsx_is_1_5089", "Option '{0}' cannot be specified when option 'jsx' is '{1}'."), Non_relative_paths_are_not_allowed_when_baseUrl_is_not_set_Did_you_forget_a_leading_Slash: diag(5090, ts.DiagnosticCategory.Error, "Non_relative_paths_are_not_allowed_when_baseUrl_is_not_set_Did_you_forget_a_leading_Slash_5090", "Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?"), + Option_preserveConstEnums_cannot_be_disabled_when_isolatedModules_is_enabled: diag(5091, ts.DiagnosticCategory.Error, "Option_preserveConstEnums_cannot_be_disabled_when_isolatedModules_is_enabled_5091", "Option 'preserveConstEnums' cannot be disabled when 'isolatedModules' is enabled."), + The_root_value_of_a_0_file_must_be_an_object: diag(5092, ts.DiagnosticCategory.Error, "The_root_value_of_a_0_file_must_be_an_object_5092", "The root value of a '{0}' file must be an object."), + Compiler_option_0_may_only_be_used_with_build: diag(5093, ts.DiagnosticCategory.Error, "Compiler_option_0_may_only_be_used_with_build_5093", "Compiler option '--{0}' may only be used with '--build'."), + Compiler_option_0_may_not_be_used_with_build: diag(5094, ts.DiagnosticCategory.Error, "Compiler_option_0_may_not_be_used_with_build_5094", "Compiler option '--{0}' may not be used with '--build'."), Generates_a_sourcemap_for_each_corresponding_d_ts_file: diag(6000, ts.DiagnosticCategory.Message, "Generates_a_sourcemap_for_each_corresponding_d_ts_file_6000", "Generates a sourcemap for each corresponding '.d.ts' file."), Concatenate_and_emit_output_to_single_file: diag(6001, ts.DiagnosticCategory.Message, "Concatenate_and_emit_output_to_single_file_6001", "Concatenate and emit output to single file."), Generates_corresponding_d_ts_file: diag(6002, ts.DiagnosticCategory.Message, "Generates_corresponding_d_ts_file_6002", "Generates corresponding '.d.ts' file."), @@ -5865,7 +6045,7 @@ var ts; Skip_type_checking_of_declaration_files: diag(6012, ts.DiagnosticCategory.Message, "Skip_type_checking_of_declaration_files_6012", "Skip type checking of declaration files."), Do_not_resolve_the_real_path_of_symlinks: diag(6013, ts.DiagnosticCategory.Message, "Do_not_resolve_the_real_path_of_symlinks_6013", "Do not resolve the real path of symlinks."), Only_emit_d_ts_declaration_files: diag(6014, ts.DiagnosticCategory.Message, "Only_emit_d_ts_declaration_files_6014", "Only emit '.d.ts' declaration files."), - Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_or_ESNEXT: diag(6015, ts.DiagnosticCategory.Message, "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_or_6015", "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'."), + Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_ES2021_or_ESNEXT: diag(6015, ts.DiagnosticCategory.Message, "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_ES_6015", "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'."), Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_es2020_or_ESNext: diag(6016, ts.DiagnosticCategory.Message, "Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_es2020_or_ESNext_6016", "Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'."), Print_this_message: diag(6017, ts.DiagnosticCategory.Message, "Print_this_message_6017", "Print this message."), Print_the_compiler_s_version: diag(6019, ts.DiagnosticCategory.Message, "Print_the_compiler_s_version_6019", "Print the compiler's version."), @@ -6008,19 +6188,12 @@ var ts; Show_all_compiler_options: diag(6169, ts.DiagnosticCategory.Message, "Show_all_compiler_options_6169", "Show all compiler options."), Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file: diag(6170, ts.DiagnosticCategory.Message, "Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file_6170", "[Deprecated] Use '--outFile' instead. Concatenate and emit output to single file"), Command_line_Options: diag(6171, ts.DiagnosticCategory.Message, "Command_line_Options_6171", "Command-line Options"), - Basic_Options: diag(6172, ts.DiagnosticCategory.Message, "Basic_Options_6172", "Basic Options"), - Strict_Type_Checking_Options: diag(6173, ts.DiagnosticCategory.Message, "Strict_Type_Checking_Options_6173", "Strict Type-Checking Options"), - Module_Resolution_Options: diag(6174, ts.DiagnosticCategory.Message, "Module_Resolution_Options_6174", "Module Resolution Options"), - Source_Map_Options: diag(6175, ts.DiagnosticCategory.Message, "Source_Map_Options_6175", "Source Map Options"), - Additional_Checks: diag(6176, ts.DiagnosticCategory.Message, "Additional_Checks_6176", "Additional Checks"), - Experimental_Options: diag(6177, ts.DiagnosticCategory.Message, "Experimental_Options_6177", "Experimental Options"), - Advanced_Options: diag(6178, ts.DiagnosticCategory.Message, "Advanced_Options_6178", "Advanced Options"), Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3: diag(6179, ts.DiagnosticCategory.Message, "Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3_6179", "Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'."), Enable_all_strict_type_checking_options: diag(6180, ts.DiagnosticCategory.Message, "Enable_all_strict_type_checking_options_6180", "Enable all strict type-checking options."), List_of_language_service_plugins: diag(6181, ts.DiagnosticCategory.Message, "List_of_language_service_plugins_6181", "List of language service plugins."), Scoped_package_detected_looking_in_0: diag(6182, ts.DiagnosticCategory.Message, "Scoped_package_detected_looking_in_0_6182", "Scoped package detected, looking in '{0}'"), - Reusing_resolution_of_module_0_to_file_1_from_old_program: diag(6183, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_to_file_1_from_old_program_6183", "Reusing resolution of module '{0}' to file '{1}' from old program."), - Reusing_module_resolutions_originating_in_0_since_resolutions_are_unchanged_from_old_program: diag(6184, ts.DiagnosticCategory.Message, "Reusing_module_resolutions_originating_in_0_since_resolutions_are_unchanged_from_old_program_6184", "Reusing module resolutions originating in '{0}' since resolutions are unchanged from old program."), + Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2: diag(6183, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_6183", "Reusing resolution of module '{0}' from '{1}' of old program, it was successfully resolved to '{2}'."), + Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3: diag(6184, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package__6184", "Reusing resolution of module '{0}' from '{1}' of old program, it was successfully resolved to '{2}' with Package ID '{3}'."), Disable_strict_checking_of_generic_signatures_in_function_types: diag(6185, ts.DiagnosticCategory.Message, "Disable_strict_checking_of_generic_signatures_in_function_types_6185", "Disable strict checking of generic signatures in function types."), Enable_strict_checking_of_function_types: diag(6186, ts.DiagnosticCategory.Message, "Enable_strict_checking_of_function_types_6186", "Enable strict checking of function types."), Enable_strict_checking_of_property_initialization_in_classes: diag(6187, ts.DiagnosticCategory.Message, "Enable_strict_checking_of_property_initialization_in_classes_6187", "Enable strict checking of property initialization in classes."), @@ -6060,9 +6233,9 @@ var ts; Emit_class_fields_with_Define_instead_of_Set: diag(6222, ts.DiagnosticCategory.Message, "Emit_class_fields_with_Define_instead_of_Set_6222", "Emit class fields with Define instead of Set."), Generates_a_CPU_profile: diag(6223, ts.DiagnosticCategory.Message, "Generates_a_CPU_profile_6223", "Generates a CPU profile."), Disable_solution_searching_for_this_project: diag(6224, ts.DiagnosticCategory.Message, "Disable_solution_searching_for_this_project_6224", "Disable solution searching for this project."), - Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_DynamicPriorityPolling_UseFsEvents_UseFsEventsOnParentDirectory: diag(6225, ts.DiagnosticCategory.Message, "Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_Dynami_6225", "Specify strategy for watching file: 'FixedPollingInterval' (default), 'PriorityPollingInterval', 'DynamicPriorityPolling', 'UseFsEvents', 'UseFsEventsOnParentDirectory'."), - Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling: diag(6226, ts.DiagnosticCategory.Message, "Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively__6226", "Specify strategy for watching directory on platforms that don't support recursive watching natively: 'UseFsEvents' (default), 'FixedPollingInterval', 'DynamicPriorityPolling'."), - Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority: diag(6227, ts.DiagnosticCategory.Message, "Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_6227", "Specify strategy for creating a polling watch when it fails to create using file system events: 'FixedInterval' (default), 'PriorityInterval', 'DynamicPriority'."), + Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_DynamicPriorityPolling_FixedChunkSizePolling_UseFsEvents_UseFsEventsOnParentDirectory: diag(6225, ts.DiagnosticCategory.Message, "Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_Dynami_6225", "Specify strategy for watching file: 'FixedPollingInterval' (default), 'PriorityPollingInterval', 'DynamicPriorityPolling', 'FixedChunkSizePolling', 'UseFsEvents', 'UseFsEventsOnParentDirectory'."), + Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling_FixedChunkSizePolling: diag(6226, ts.DiagnosticCategory.Message, "Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively__6226", "Specify strategy for watching directory on platforms that don't support recursive watching natively: 'UseFsEvents' (default), 'FixedPollingInterval', 'DynamicPriorityPolling', 'FixedChunkSizePolling'."), + Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority_FixedChunkSize: diag(6227, ts.DiagnosticCategory.Message, "Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_6227", "Specify strategy for creating a polling watch when it fails to create using file system events: 'FixedInterval' (default), 'PriorityInterval', 'DynamicPriority', 'FixedChunkSize'."), Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively: diag(6228, ts.DiagnosticCategory.Message, "Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_supp_6228", "Synchronously call callbacks and update the state of directory watchers on platforms that don't support recursive watching natively."), Tag_0_expects_at_least_1_arguments_but_the_JSX_factory_2_provides_at_most_3: diag(6229, ts.DiagnosticCategory.Error, "Tag_0_expects_at_least_1_arguments_but_the_JSX_factory_2_provides_at_most_3_6229", "Tag '{0}' expects at least '{1}' arguments, but the JSX factory '{2}' provides at most '{3}'."), Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line: diag(6230, ts.DiagnosticCategory.Error, "Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line_6230", "Option '{0}' can only be specified in 'tsconfig.json' file or set to 'false' or 'null' on command line."), @@ -6073,7 +6246,26 @@ var ts; Disable_loading_referenced_projects: diag(6235, ts.DiagnosticCategory.Message, "Disable_loading_referenced_projects_6235", "Disable loading referenced projects."), Arguments_for_the_rest_parameter_0_were_not_provided: diag(6236, ts.DiagnosticCategory.Error, "Arguments_for_the_rest_parameter_0_were_not_provided_6236", "Arguments for the rest parameter '{0}' were not provided."), Generates_an_event_trace_and_a_list_of_types: diag(6237, ts.DiagnosticCategory.Message, "Generates_an_event_trace_and_a_list_of_types_6237", "Generates an event trace and a list of types."), - Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react: diag(6238, ts.DiagnosticCategory.Error, "Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react_6238", "Specify the module specifier to be used to import the `jsx` and `jsxs` factory functions from. eg, react"), + Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react: diag(6238, ts.DiagnosticCategory.Error, "Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react_6238", "Specify the module specifier to be used to import the 'jsx' and 'jsxs' factory functions from. eg, react"), + File_0_exists_according_to_earlier_cached_lookups: diag(6239, ts.DiagnosticCategory.Message, "File_0_exists_according_to_earlier_cached_lookups_6239", "File '{0}' exists according to earlier cached lookups."), + File_0_does_not_exist_according_to_earlier_cached_lookups: diag(6240, ts.DiagnosticCategory.Message, "File_0_does_not_exist_according_to_earlier_cached_lookups_6240", "File '{0}' does not exist according to earlier cached lookups."), + Resolution_for_type_reference_directive_0_was_found_in_cache_from_location_1: diag(6241, ts.DiagnosticCategory.Message, "Resolution_for_type_reference_directive_0_was_found_in_cache_from_location_1_6241", "Resolution for type reference directive '{0}' was found in cache from location '{1}'."), + Resolving_type_reference_directive_0_containing_file_1: diag(6242, ts.DiagnosticCategory.Message, "Resolving_type_reference_directive_0_containing_file_1_6242", "======== Resolving type reference directive '{0}', containing file '{1}'. ========"), + Enable_strict_checking_of_optional_properties: diag(6243, ts.DiagnosticCategory.Message, "Enable_strict_checking_of_optional_properties_6243", "Enable strict checking of optional properties."), + Modules: diag(6244, ts.DiagnosticCategory.Message, "Modules_6244", "Modules"), + File_Management: diag(6245, ts.DiagnosticCategory.Message, "File_Management_6245", "File Management"), + Emit: diag(6246, ts.DiagnosticCategory.Message, "Emit_6246", "Emit"), + JavaScript_Support: diag(6247, ts.DiagnosticCategory.Message, "JavaScript_Support_6247", "JavaScript Support"), + Type_Checking: diag(6248, ts.DiagnosticCategory.Message, "Type_Checking_6248", "Type Checking"), + Editor_Support: diag(6249, ts.DiagnosticCategory.Message, "Editor_Support_6249", "Editor Support"), + Watch_and_Build_Modes: diag(6250, ts.DiagnosticCategory.Message, "Watch_and_Build_Modes_6250", "Watch and Build Modes"), + Compiler_Diagnostics: diag(6251, ts.DiagnosticCategory.Message, "Compiler_Diagnostics_6251", "Compiler Diagnostics"), + Interop_Constraints: diag(6252, ts.DiagnosticCategory.Message, "Interop_Constraints_6252", "Interop Constraints"), + Backwards_Compatibility: diag(6253, ts.DiagnosticCategory.Message, "Backwards_Compatibility_6253", "Backwards Compatibility"), + Language_and_Environment: diag(6254, ts.DiagnosticCategory.Message, "Language_and_Environment_6254", "Language and Environment"), + Projects: diag(6255, ts.DiagnosticCategory.Message, "Projects_6255", "Projects"), + Output_Formatting: diag(6256, ts.DiagnosticCategory.Message, "Output_Formatting_6256", "Output Formatting"), + Completeness: diag(6257, ts.DiagnosticCategory.Message, "Completeness_6257", "Completeness"), Projects_to_reference: diag(6300, ts.DiagnosticCategory.Message, "Projects_to_reference_6300", "Projects to reference"), Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"), Composite_projects_may_not_disable_declaration_emit: diag(6304, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_declaration_emit_6304", "Composite projects may not disable declaration emit."), @@ -6118,16 +6310,31 @@ var ts; Skipping_build_of_project_0_because_its_dependency_1_was_not_built: diag(6382, ts.DiagnosticCategory.Message, "Skipping_build_of_project_0_because_its_dependency_1_was_not_built_6382", "Skipping build of project '{0}' because its dependency '{1}' was not built"), Project_0_can_t_be_built_because_its_dependency_1_was_not_built: diag(6383, ts.DiagnosticCategory.Message, "Project_0_can_t_be_built_because_its_dependency_1_was_not_built_6383", "Project '{0}' can't be built because its dependency '{1}' was not built"), Have_recompiles_in_incremental_and_watch_assume_that_changes_within_a_file_will_only_affect_files_directly_depending_on_it: diag(6384, ts.DiagnosticCategory.Message, "Have_recompiles_in_incremental_and_watch_assume_that_changes_within_a_file_will_only_affect_files_di_6384", "Have recompiles in '--incremental' and '--watch' assume that changes within a file will only affect files directly depending on it."), - _0_is_deprecated: diag(6385, ts.DiagnosticCategory.Suggestion, "_0_is_deprecated_6385", "'{0}' is deprecated", undefined, undefined, true), + _0_is_deprecated: diag(6385, ts.DiagnosticCategory.Suggestion, "_0_is_deprecated_6385", "'{0}' is deprecated.", undefined, undefined, true), Performance_timings_for_diagnostics_or_extendedDiagnostics_are_not_available_in_this_session_A_native_implementation_of_the_Web_Performance_API_could_not_be_found: diag(6386, ts.DiagnosticCategory.Message, "Performance_timings_for_diagnostics_or_extendedDiagnostics_are_not_available_in_this_session_A_nativ_6386", "Performance timings for '--diagnostics' or '--extendedDiagnostics' are not available in this session. A native implementation of the Web Performance API could not be found."), + The_signature_0_of_1_is_deprecated: diag(6387, ts.DiagnosticCategory.Suggestion, "The_signature_0_of_1_is_deprecated_6387", "The signature '{0}' of '{1}' is deprecated.", undefined, undefined, true), + Project_0_is_being_forcibly_rebuilt: diag(6388, ts.DiagnosticCategory.Message, "Project_0_is_being_forcibly_rebuilt_6388", "Project '{0}' is being forcibly rebuilt"), + Reusing_resolution_of_module_0_from_1_of_old_program_it_was_not_resolved: diag(6389, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_of_old_program_it_was_not_resolved_6389", "Reusing resolution of module '{0}' from '{1}' of old program, it was not resolved."), + Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2: diag(6390, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved__6390", "Reusing resolution of type reference directive '{0}' from '{1}' of old program, it was successfully resolved to '{2}'."), + Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3: diag(6391, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved__6391", "Reusing resolution of type reference directive '{0}' from '{1}' of old program, it was successfully resolved to '{2}' with Package ID '{3}'."), + Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_not_resolved: diag(6392, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_not_resolved_6392", "Reusing resolution of type reference directive '{0}' from '{1}' of old program, it was not resolved."), + Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3: diag(6393, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_6393", "Reusing resolution of module '{0}' from '{1}' found in cache from location '{2}', it was successfully resolved to '{3}'."), + Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4: diag(6394, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_6394", "Reusing resolution of module '{0}' from '{1}' found in cache from location '{2}', it was successfully resolved to '{3}' with Package ID '{4}'."), + Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_not_resolved: diag(6395, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_not_resolved_6395", "Reusing resolution of module '{0}' from '{1}' found in cache from location '{2}', it was not resolved."), + Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3: diag(6396, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_succes_6396", "Reusing resolution of type reference directive '{0}' from '{1}' found in cache from location '{2}', it was successfully resolved to '{3}'."), + Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4: diag(6397, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_succes_6397", "Reusing resolution of type reference directive '{0}' from '{1}' found in cache from location '{2}', it was successfully resolved to '{3}' with Package ID '{4}'."), + Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_not_resolved: diag(6398, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_not_re_6398", "Reusing resolution of type reference directive '{0}' from '{1}' found in cache from location '{2}', it was not resolved."), The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"), The_expected_type_comes_from_this_index_signature: diag(6501, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."), The_expected_type_comes_from_the_return_type_of_this_signature: diag(6502, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_the_return_type_of_this_signature_6502", "The expected type comes from the return type of this signature."), Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing: diag(6503, ts.DiagnosticCategory.Message, "Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing_6503", "Print names of files that are part of the compilation and then stop processing."), File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option: diag(6504, ts.DiagnosticCategory.Error, "File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option_6504", "File '{0}' is a JavaScript file. Did you mean to enable the 'allowJs' option?"), Print_names_of_files_and_the_reason_they_are_part_of_the_compilation: diag(6505, ts.DiagnosticCategory.Message, "Print_names_of_files_and_the_reason_they_are_part_of_the_compilation_6505", "Print names of files and the reason they are part of the compilation."), - Require_undeclared_properties_from_index_signatures_to_use_element_accesses: diag(6803, ts.DiagnosticCategory.Error, "Require_undeclared_properties_from_index_signatures_to_use_element_accesses_6803", "Require undeclared properties from index signatures to use element accesses."), + Consider_adding_a_declare_modifier_to_this_class: diag(6506, ts.DiagnosticCategory.Message, "Consider_adding_a_declare_modifier_to_this_class_6506", "Consider adding a 'declare' modifier to this class."), Include_undefined_in_index_signature_results: diag(6800, ts.DiagnosticCategory.Message, "Include_undefined_in_index_signature_results_6800", "Include 'undefined' in index signature results"), + Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier: diag(6801, ts.DiagnosticCategory.Message, "Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier_6801", "Ensure overriding members in derived classes are marked with an 'override' modifier."), + Require_undeclared_properties_from_index_signatures_to_use_element_accesses: diag(6802, ts.DiagnosticCategory.Message, "Require_undeclared_properties_from_index_signatures_to_use_element_accesses_6802", "Require undeclared properties from index signatures to use element accesses."), + Type_catch_clause_variables_as_unknown_instead_of_any: diag(6803, ts.DiagnosticCategory.Message, "Type_catch_clause_variables_as_unknown_instead_of_any_6803", "Type catch clause variables as 'unknown' instead of 'any'."), Variable_0_implicitly_has_an_1_type: diag(7005, ts.DiagnosticCategory.Error, "Variable_0_implicitly_has_an_1_type_7005", "Variable '{0}' implicitly has an '{1}' type."), Parameter_0_implicitly_has_an_1_type: diag(7006, ts.DiagnosticCategory.Error, "Parameter_0_implicitly_has_an_1_type_7006", "Parameter '{0}' implicitly has an '{1}' type."), Member_0_implicitly_has_an_1_type: diag(7008, ts.DiagnosticCategory.Error, "Member_0_implicitly_has_an_1_type_7008", "Member '{0}' implicitly has an '{1}' type."), @@ -6160,7 +6367,7 @@ var ts; Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for_all_imports_Implies_allowSyntheticDefaultImports: diag(7037, ts.DiagnosticCategory.Message, "Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for__7037", "Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'."), Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead: diag(7038, ts.DiagnosticCategory.Message, "Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cau_7038", "Type originates at this import. A namespace-style import cannot be called or constructed, and will cause a failure at runtime. Consider using a default import or import require here instead."), Mapped_object_type_implicitly_has_an_any_template_type: diag(7039, ts.DiagnosticCategory.Error, "Mapped_object_type_implicitly_has_an_any_template_type_7039", "Mapped object type implicitly has an 'any' template type."), - If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_1: diag(7040, ts.DiagnosticCategory.Error, "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040", "If the '{0}' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}`"), + If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_1: diag(7040, ts.DiagnosticCategory.Error, "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040", "If the '{0}' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}'"), The_containing_arrow_function_captures_the_global_value_of_this: diag(7041, ts.DiagnosticCategory.Error, "The_containing_arrow_function_captures_the_global_value_of_this_7041", "The containing arrow function captures the global value of 'this'."), Module_0_was_resolved_to_1_but_resolveJsonModule_is_not_used: diag(7042, ts.DiagnosticCategory.Error, "Module_0_was_resolved_to_1_but_resolveJsonModule_is_not_used_7042", "Module '{0}' was resolved to '{1}', but '--resolveJsonModule' is not used."), Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage: diag(7043, ts.DiagnosticCategory.Suggestion, "Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7043", "Variable '{0}' implicitly has an '{1}' type, but a better type may be inferred from usage."), @@ -6200,7 +6407,7 @@ var ts; JSDoc_0_is_not_attached_to_a_class: diag(8022, ts.DiagnosticCategory.Error, "JSDoc_0_is_not_attached_to_a_class_8022", "JSDoc '@{0}' is not attached to a class."), JSDoc_0_1_does_not_match_the_extends_2_clause: diag(8023, ts.DiagnosticCategory.Error, "JSDoc_0_1_does_not_match_the_extends_2_clause_8023", "JSDoc '@{0} {1}' does not match the 'extends {2}' clause."), JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name: diag(8024, ts.DiagnosticCategory.Error, "JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_8024", "JSDoc '@param' tag has name '{0}', but there is no parameter with that name."), - Class_declarations_cannot_have_more_than_one_augments_or_extends_tag: diag(8025, ts.DiagnosticCategory.Error, "Class_declarations_cannot_have_more_than_one_augments_or_extends_tag_8025", "Class declarations cannot have more than one `@augments` or `@extends` tag."), + Class_declarations_cannot_have_more_than_one_augments_or_extends_tag: diag(8025, ts.DiagnosticCategory.Error, "Class_declarations_cannot_have_more_than_one_augments_or_extends_tag_8025", "Class declarations cannot have more than one '@augments' or '@extends' tag."), Expected_0_type_arguments_provide_these_with_an_extends_tag: diag(8026, ts.DiagnosticCategory.Error, "Expected_0_type_arguments_provide_these_with_an_extends_tag_8026", "Expected {0} type arguments; provide these with an '@extends' tag."), Expected_0_1_type_arguments_provide_these_with_an_extends_tag: diag(8027, ts.DiagnosticCategory.Error, "Expected_0_1_type_arguments_provide_these_with_an_extends_tag_8027", "Expected {0}-{1} type arguments; provide these with an '@extends' tag."), JSDoc_may_only_appear_in_the_last_parameter_of_a_signature: diag(8028, ts.DiagnosticCategory.Error, "JSDoc_may_only_appear_in_the_last_parameter_of_a_signature_8028", "JSDoc '...' may only appear in the last parameter of a signature."), @@ -6445,6 +6652,11 @@ var ts; Add_all_missing_function_declarations: diag(95157, ts.DiagnosticCategory.Message, "Add_all_missing_function_declarations_95157", "Add all missing function declarations"), Method_not_implemented: diag(95158, ts.DiagnosticCategory.Message, "Method_not_implemented_95158", "Method not implemented."), Function_not_implemented: diag(95159, ts.DiagnosticCategory.Message, "Function_not_implemented_95159", "Function not implemented."), + Add_override_modifier: diag(95160, ts.DiagnosticCategory.Message, "Add_override_modifier_95160", "Add 'override' modifier"), + Remove_override_modifier: diag(95161, ts.DiagnosticCategory.Message, "Remove_override_modifier_95161", "Remove 'override' modifier"), + Add_all_missing_override_modifiers: diag(95162, ts.DiagnosticCategory.Message, "Add_all_missing_override_modifiers_95162", "Add all missing 'override' modifiers"), + Remove_all_unnecessary_override_modifiers: diag(95163, ts.DiagnosticCategory.Message, "Remove_all_unnecessary_override_modifiers_95163", "Remove all unnecessary 'override' modifiers"), + Can_only_convert_named_export: diag(95164, ts.DiagnosticCategory.Message, "Can_only_convert_named_export_95164", "Can only convert named export"), No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, ts.DiagnosticCategory.Error, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."), Classes_may_not_have_a_field_named_constructor: diag(18006, ts.DiagnosticCategory.Error, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."), JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, ts.DiagnosticCategory.Error, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"), @@ -6459,8 +6671,6 @@ var ts; The_shadowing_declaration_of_0_is_defined_here: diag(18017, ts.DiagnosticCategory.Error, "The_shadowing_declaration_of_0_is_defined_here_18017", "The shadowing declaration of '{0}' is defined here"), The_declaration_of_0_that_you_probably_intended_to_use_is_defined_here: diag(18018, ts.DiagnosticCategory.Error, "The_declaration_of_0_that_you_probably_intended_to_use_is_defined_here_18018", "The declaration of '{0}' that you probably intended to use is defined here"), _0_modifier_cannot_be_used_with_a_private_identifier: diag(18019, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_with_a_private_identifier_18019", "'{0}' modifier cannot be used with a private identifier."), - A_method_cannot_be_named_with_a_private_identifier: diag(18022, ts.DiagnosticCategory.Error, "A_method_cannot_be_named_with_a_private_identifier_18022", "A method cannot be named with a private identifier."), - An_accessor_cannot_be_named_with_a_private_identifier: diag(18023, ts.DiagnosticCategory.Error, "An_accessor_cannot_be_named_with_a_private_identifier_18023", "An accessor cannot be named with a private identifier."), An_enum_member_cannot_be_named_with_a_private_identifier: diag(18024, ts.DiagnosticCategory.Error, "An_enum_member_cannot_be_named_with_a_private_identifier_18024", "An enum member cannot be named with a private identifier."), can_only_be_used_at_the_start_of_a_file: diag(18026, ts.DiagnosticCategory.Error, "can_only_be_used_at_the_start_of_a_file_18026", "'#!' can only be used at the start of a file."), Compiler_reserves_name_0_when_emitting_private_identifier_downlevel: diag(18027, ts.DiagnosticCategory.Error, "Compiler_reserves_name_0_when_emitting_private_identifier_downlevel_18027", "Compiler reserves name '{0}' when emitting private identifier downlevel."), @@ -6472,13 +6682,14 @@ var ts; 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: diag(18033, ts.DiagnosticCategory.Error, "Only_numeric_enums_can_have_computed_members_but_this_expression_has_type_0_If_you_do_not_need_exhau_18033", "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."), Specify_the_JSX_fragment_factory_function_to_use_when_targeting_react_JSX_emit_with_jsxFactory_compiler_option_is_specified_e_g_Fragment: diag(18034, ts.DiagnosticCategory.Message, "Specify_the_JSX_fragment_factory_function_to_use_when_targeting_react_JSX_emit_with_jsxFactory_compi_18034", "Specify the JSX fragment factory function to use when targeting 'react' JSX emit with 'jsxFactory' compiler option is specified, e.g. 'Fragment'."), Invalid_value_for_jsxFragmentFactory_0_is_not_a_valid_identifier_or_qualified_name: diag(18035, ts.DiagnosticCategory.Error, "Invalid_value_for_jsxFragmentFactory_0_is_not_a_valid_identifier_or_qualified_name_18035", "Invalid value for 'jsxFragmentFactory'. '{0}' is not a valid identifier or qualified-name."), + Class_decorators_can_t_be_used_with_static_private_identifier_Consider_removing_the_experimental_decorator: diag(18036, ts.DiagnosticCategory.Error, "Class_decorators_can_t_be_used_with_static_private_identifier_Consider_removing_the_experimental_dec_18036", "Class decorators can't be used with static private identifier. Consider removing the experimental decorator."), }; })(ts || (ts = {})); var ts; (function (ts) { var _a; function tokenIsIdentifierOrKeyword(token) { - return token >= 78; + return token >= 79; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; function tokenIsIdentifierOrKeywordOrGreaterThan(token) { @@ -6486,95 +6697,96 @@ var ts; } ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan; var textToKeywordObj = (_a = { - abstract: 125, - any: 128, - as: 126, - asserts: 127, - bigint: 155, - boolean: 131, - break: 80, - case: 81, - catch: 82, - class: 83, - continue: 85, - const: 84 + abstract: 126, + any: 129, + as: 127, + asserts: 128, + bigint: 156, + boolean: 132, + break: 81, + case: 82, + catch: 83, + class: 84, + continue: 86, + const: 85 }, - _a["" + "constructor"] = 132, - _a.debugger = 86, - _a.declare = 133, - _a.default = 87, - _a.delete = 88, - _a.do = 89, - _a.else = 90, - _a.enum = 91, - _a.export = 92, - _a.extends = 93, - _a.false = 94, - _a.finally = 95, - _a.for = 96, - _a.from = 153, - _a.function = 97, - _a.get = 134, - _a.if = 98, - _a.implements = 116, - _a.import = 99, - _a.in = 100, - _a.infer = 135, - _a.instanceof = 101, - _a.interface = 117, - _a.intrinsic = 136, - _a.is = 137, - _a.keyof = 138, - _a.let = 118, - _a.module = 139, - _a.namespace = 140, - _a.never = 141, - _a.new = 102, - _a.null = 103, - _a.number = 144, - _a.object = 145, - _a.package = 119, - _a.private = 120, - _a.protected = 121, - _a.public = 122, - _a.readonly = 142, - _a.require = 143, - _a.global = 154, - _a.return = 104, - _a.set = 146, - _a.static = 123, - _a.string = 147, - _a.super = 105, - _a.switch = 106, - _a.symbol = 148, - _a.this = 107, - _a.throw = 108, - _a.true = 109, - _a.try = 110, - _a.type = 149, - _a.typeof = 111, - _a.undefined = 150, - _a.unique = 151, - _a.unknown = 152, - _a.var = 112, - _a.void = 113, - _a.while = 114, - _a.with = 115, - _a.yield = 124, - _a.async = 129, - _a.await = 130, - _a.of = 156, + _a["" + "constructor"] = 133, + _a.debugger = 87, + _a.declare = 134, + _a.default = 88, + _a.delete = 89, + _a.do = 90, + _a.else = 91, + _a.enum = 92, + _a.export = 93, + _a.extends = 94, + _a.false = 95, + _a.finally = 96, + _a.for = 97, + _a.from = 154, + _a.function = 98, + _a.get = 135, + _a.if = 99, + _a.implements = 117, + _a.import = 100, + _a.in = 101, + _a.infer = 136, + _a.instanceof = 102, + _a.interface = 118, + _a.intrinsic = 137, + _a.is = 138, + _a.keyof = 139, + _a.let = 119, + _a.module = 140, + _a.namespace = 141, + _a.never = 142, + _a.new = 103, + _a.null = 104, + _a.number = 145, + _a.object = 146, + _a.package = 120, + _a.private = 121, + _a.protected = 122, + _a.public = 123, + _a.override = 157, + _a.readonly = 143, + _a.require = 144, + _a.global = 155, + _a.return = 105, + _a.set = 147, + _a.static = 124, + _a.string = 148, + _a.super = 106, + _a.switch = 107, + _a.symbol = 149, + _a.this = 108, + _a.throw = 109, + _a.true = 110, + _a.try = 111, + _a.type = 150, + _a.typeof = 112, + _a.undefined = 151, + _a.unique = 152, + _a.unknown = 153, + _a.var = 113, + _a.void = 114, + _a.while = 115, + _a.with = 116, + _a.yield = 125, + _a.async = 130, + _a.await = 131, + _a.of = 158, _a); var textToKeyword = new ts.Map(ts.getEntries(textToKeywordObj)); - var textToToken = new ts.Map(ts.getEntries(__assign(__assign({}, textToKeywordObj), { "{": 18, "}": 19, "(": 20, ")": 21, "[": 22, "]": 23, ".": 24, "...": 25, ";": 26, ",": 27, "<": 29, ">": 31, "<=": 32, ">=": 33, "==": 34, "!=": 35, "===": 36, "!==": 37, "=>": 38, "+": 39, "-": 40, "**": 42, "*": 41, "/": 43, "%": 44, "++": 45, "--": 46, "<<": 47, ">": 48, ">>>": 49, "&": 50, "|": 51, "^": 52, "!": 53, "~": 54, "&&": 55, "||": 56, "?": 57, "??": 60, "?.": 28, ":": 58, "=": 62, "+=": 63, "-=": 64, "*=": 65, "**=": 66, "/=": 67, "%=": 68, "<<=": 69, ">>=": 70, ">>>=": 71, "&=": 72, "|=": 73, "^=": 77, "||=": 74, "&&=": 75, "??=": 76, "@": 59, "`": 61 }))); + var textToToken = new ts.Map(ts.getEntries(__assign(__assign({}, textToKeywordObj), { "{": 18, "}": 19, "(": 20, ")": 21, "[": 22, "]": 23, ".": 24, "...": 25, ";": 26, ",": 27, "<": 29, ">": 31, "<=": 32, ">=": 33, "==": 34, "!=": 35, "===": 36, "!==": 37, "=>": 38, "+": 39, "-": 40, "**": 42, "*": 41, "/": 43, "%": 44, "++": 45, "--": 46, "<<": 47, ">": 48, ">>>": 49, "&": 50, "|": 51, "^": 52, "!": 53, "~": 54, "&&": 55, "||": 56, "?": 57, "??": 60, "?.": 28, ":": 58, "=": 63, "+=": 64, "-=": 65, "*=": 66, "**=": 67, "/=": 68, "%=": 69, "<<=": 70, ">>=": 71, ">>>=": 72, "&=": 73, "|=": 74, "^=": 78, "||=": 75, "&&=": 76, "??=": 77, "@": 59, "#": 62, "`": 61 }))); var unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; var unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; var unicodeES5IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2208, 2208, 2210, 2220, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 7413, 7414, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; var unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; var unicodeESNextIdentifierStart = [65, 90, 97, 122, 170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 895, 895, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1327, 1329, 1366, 1369, 1369, 1376, 1416, 1488, 1514, 1519, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2144, 2154, 2208, 2228, 2230, 2237, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2432, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2556, 2556, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2809, 2809, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3129, 3133, 3133, 3160, 3162, 3168, 3169, 3200, 3200, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3412, 3414, 3423, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3718, 3722, 3724, 3747, 3749, 3749, 3751, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5109, 5112, 5117, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5880, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6264, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6430, 6480, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7296, 7304, 7312, 7354, 7357, 7359, 7401, 7404, 7406, 7411, 7413, 7414, 7418, 7418, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8472, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12443, 12447, 12449, 12538, 12540, 12543, 12549, 12591, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40943, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42653, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42943, 42946, 42950, 42999, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43261, 43262, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43488, 43492, 43494, 43503, 43514, 43518, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43646, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43824, 43866, 43868, 43879, 43888, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 65536, 65547, 65549, 65574, 65576, 65594, 65596, 65597, 65599, 65613, 65616, 65629, 65664, 65786, 65856, 65908, 66176, 66204, 66208, 66256, 66304, 66335, 66349, 66378, 66384, 66421, 66432, 66461, 66464, 66499, 66504, 66511, 66513, 66517, 66560, 66717, 66736, 66771, 66776, 66811, 66816, 66855, 66864, 66915, 67072, 67382, 67392, 67413, 67424, 67431, 67584, 67589, 67592, 67592, 67594, 67637, 67639, 67640, 67644, 67644, 67647, 67669, 67680, 67702, 67712, 67742, 67808, 67826, 67828, 67829, 67840, 67861, 67872, 67897, 67968, 68023, 68030, 68031, 68096, 68096, 68112, 68115, 68117, 68119, 68121, 68149, 68192, 68220, 68224, 68252, 68288, 68295, 68297, 68324, 68352, 68405, 68416, 68437, 68448, 68466, 68480, 68497, 68608, 68680, 68736, 68786, 68800, 68850, 68864, 68899, 69376, 69404, 69415, 69415, 69424, 69445, 69600, 69622, 69635, 69687, 69763, 69807, 69840, 69864, 69891, 69926, 69956, 69956, 69968, 70002, 70006, 70006, 70019, 70066, 70081, 70084, 70106, 70106, 70108, 70108, 70144, 70161, 70163, 70187, 70272, 70278, 70280, 70280, 70282, 70285, 70287, 70301, 70303, 70312, 70320, 70366, 70405, 70412, 70415, 70416, 70419, 70440, 70442, 70448, 70450, 70451, 70453, 70457, 70461, 70461, 70480, 70480, 70493, 70497, 70656, 70708, 70727, 70730, 70751, 70751, 70784, 70831, 70852, 70853, 70855, 70855, 71040, 71086, 71128, 71131, 71168, 71215, 71236, 71236, 71296, 71338, 71352, 71352, 71424, 71450, 71680, 71723, 71840, 71903, 71935, 71935, 72096, 72103, 72106, 72144, 72161, 72161, 72163, 72163, 72192, 72192, 72203, 72242, 72250, 72250, 72272, 72272, 72284, 72329, 72349, 72349, 72384, 72440, 72704, 72712, 72714, 72750, 72768, 72768, 72818, 72847, 72960, 72966, 72968, 72969, 72971, 73008, 73030, 73030, 73056, 73061, 73063, 73064, 73066, 73097, 73112, 73112, 73440, 73458, 73728, 74649, 74752, 74862, 74880, 75075, 77824, 78894, 82944, 83526, 92160, 92728, 92736, 92766, 92880, 92909, 92928, 92975, 92992, 92995, 93027, 93047, 93053, 93071, 93760, 93823, 93952, 94026, 94032, 94032, 94099, 94111, 94176, 94177, 94179, 94179, 94208, 100343, 100352, 101106, 110592, 110878, 110928, 110930, 110948, 110951, 110960, 111355, 113664, 113770, 113776, 113788, 113792, 113800, 113808, 113817, 119808, 119892, 119894, 119964, 119966, 119967, 119970, 119970, 119973, 119974, 119977, 119980, 119982, 119993, 119995, 119995, 119997, 120003, 120005, 120069, 120071, 120074, 120077, 120084, 120086, 120092, 120094, 120121, 120123, 120126, 120128, 120132, 120134, 120134, 120138, 120144, 120146, 120485, 120488, 120512, 120514, 120538, 120540, 120570, 120572, 120596, 120598, 120628, 120630, 120654, 120656, 120686, 120688, 120712, 120714, 120744, 120746, 120770, 120772, 120779, 123136, 123180, 123191, 123197, 123214, 123214, 123584, 123627, 124928, 125124, 125184, 125251, 125259, 125259, 126464, 126467, 126469, 126495, 126497, 126498, 126500, 126500, 126503, 126503, 126505, 126514, 126516, 126519, 126521, 126521, 126523, 126523, 126530, 126530, 126535, 126535, 126537, 126537, 126539, 126539, 126541, 126543, 126545, 126546, 126548, 126548, 126551, 126551, 126553, 126553, 126555, 126555, 126557, 126557, 126559, 126559, 126561, 126562, 126564, 126564, 126567, 126570, 126572, 126578, 126580, 126583, 126585, 126588, 126590, 126590, 126592, 126601, 126603, 126619, 126625, 126627, 126629, 126633, 126635, 126651, 131072, 173782, 173824, 177972, 177984, 178205, 178208, 183969, 183984, 191456, 194560, 195101]; var unicodeESNextIdentifierPart = [48, 57, 65, 90, 95, 95, 97, 122, 170, 170, 181, 181, 183, 183, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 895, 895, 902, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1327, 1329, 1366, 1369, 1369, 1376, 1416, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1519, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2045, 2045, 2048, 2093, 2112, 2139, 2144, 2154, 2208, 2228, 2230, 2237, 2259, 2273, 2275, 2403, 2406, 2415, 2417, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2556, 2556, 2558, 2558, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2809, 2815, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3072, 3084, 3086, 3088, 3090, 3112, 3114, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3162, 3168, 3171, 3174, 3183, 3200, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3328, 3331, 3333, 3340, 3342, 3344, 3346, 3396, 3398, 3400, 3402, 3406, 3412, 3415, 3423, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3558, 3567, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3718, 3722, 3724, 3747, 3749, 3749, 3751, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4969, 4977, 4992, 5007, 5024, 5109, 5112, 5117, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5880, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6264, 6272, 6314, 6320, 6389, 6400, 6430, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6618, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6832, 6845, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7296, 7304, 7312, 7354, 7357, 7359, 7376, 7378, 7380, 7418, 7424, 7673, 7675, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8472, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12447, 12449, 12538, 12540, 12543, 12549, 12591, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40943, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42737, 42775, 42783, 42786, 42888, 42891, 42943, 42946, 42950, 42999, 43047, 43072, 43123, 43136, 43205, 43216, 43225, 43232, 43255, 43259, 43259, 43261, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43488, 43518, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43824, 43866, 43868, 43879, 43888, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65071, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 65536, 65547, 65549, 65574, 65576, 65594, 65596, 65597, 65599, 65613, 65616, 65629, 65664, 65786, 65856, 65908, 66045, 66045, 66176, 66204, 66208, 66256, 66272, 66272, 66304, 66335, 66349, 66378, 66384, 66426, 66432, 66461, 66464, 66499, 66504, 66511, 66513, 66517, 66560, 66717, 66720, 66729, 66736, 66771, 66776, 66811, 66816, 66855, 66864, 66915, 67072, 67382, 67392, 67413, 67424, 67431, 67584, 67589, 67592, 67592, 67594, 67637, 67639, 67640, 67644, 67644, 67647, 67669, 67680, 67702, 67712, 67742, 67808, 67826, 67828, 67829, 67840, 67861, 67872, 67897, 67968, 68023, 68030, 68031, 68096, 68099, 68101, 68102, 68108, 68115, 68117, 68119, 68121, 68149, 68152, 68154, 68159, 68159, 68192, 68220, 68224, 68252, 68288, 68295, 68297, 68326, 68352, 68405, 68416, 68437, 68448, 68466, 68480, 68497, 68608, 68680, 68736, 68786, 68800, 68850, 68864, 68903, 68912, 68921, 69376, 69404, 69415, 69415, 69424, 69456, 69600, 69622, 69632, 69702, 69734, 69743, 69759, 69818, 69840, 69864, 69872, 69881, 69888, 69940, 69942, 69951, 69956, 69958, 69968, 70003, 70006, 70006, 70016, 70084, 70089, 70092, 70096, 70106, 70108, 70108, 70144, 70161, 70163, 70199, 70206, 70206, 70272, 70278, 70280, 70280, 70282, 70285, 70287, 70301, 70303, 70312, 70320, 70378, 70384, 70393, 70400, 70403, 70405, 70412, 70415, 70416, 70419, 70440, 70442, 70448, 70450, 70451, 70453, 70457, 70459, 70468, 70471, 70472, 70475, 70477, 70480, 70480, 70487, 70487, 70493, 70499, 70502, 70508, 70512, 70516, 70656, 70730, 70736, 70745, 70750, 70751, 70784, 70853, 70855, 70855, 70864, 70873, 71040, 71093, 71096, 71104, 71128, 71133, 71168, 71232, 71236, 71236, 71248, 71257, 71296, 71352, 71360, 71369, 71424, 71450, 71453, 71467, 71472, 71481, 71680, 71738, 71840, 71913, 71935, 71935, 72096, 72103, 72106, 72151, 72154, 72161, 72163, 72164, 72192, 72254, 72263, 72263, 72272, 72345, 72349, 72349, 72384, 72440, 72704, 72712, 72714, 72758, 72760, 72768, 72784, 72793, 72818, 72847, 72850, 72871, 72873, 72886, 72960, 72966, 72968, 72969, 72971, 73014, 73018, 73018, 73020, 73021, 73023, 73031, 73040, 73049, 73056, 73061, 73063, 73064, 73066, 73102, 73104, 73105, 73107, 73112, 73120, 73129, 73440, 73462, 73728, 74649, 74752, 74862, 74880, 75075, 77824, 78894, 82944, 83526, 92160, 92728, 92736, 92766, 92768, 92777, 92880, 92909, 92912, 92916, 92928, 92982, 92992, 92995, 93008, 93017, 93027, 93047, 93053, 93071, 93760, 93823, 93952, 94026, 94031, 94087, 94095, 94111, 94176, 94177, 94179, 94179, 94208, 100343, 100352, 101106, 110592, 110878, 110928, 110930, 110948, 110951, 110960, 111355, 113664, 113770, 113776, 113788, 113792, 113800, 113808, 113817, 113821, 113822, 119141, 119145, 119149, 119154, 119163, 119170, 119173, 119179, 119210, 119213, 119362, 119364, 119808, 119892, 119894, 119964, 119966, 119967, 119970, 119970, 119973, 119974, 119977, 119980, 119982, 119993, 119995, 119995, 119997, 120003, 120005, 120069, 120071, 120074, 120077, 120084, 120086, 120092, 120094, 120121, 120123, 120126, 120128, 120132, 120134, 120134, 120138, 120144, 120146, 120485, 120488, 120512, 120514, 120538, 120540, 120570, 120572, 120596, 120598, 120628, 120630, 120654, 120656, 120686, 120688, 120712, 120714, 120744, 120746, 120770, 120772, 120779, 120782, 120831, 121344, 121398, 121403, 121452, 121461, 121461, 121476, 121476, 121499, 121503, 121505, 121519, 122880, 122886, 122888, 122904, 122907, 122913, 122915, 122916, 122918, 122922, 123136, 123180, 123184, 123197, 123200, 123209, 123214, 123214, 123584, 123641, 124928, 125124, 125136, 125142, 125184, 125259, 125264, 125273, 126464, 126467, 126469, 126495, 126497, 126498, 126500, 126500, 126503, 126503, 126505, 126514, 126516, 126519, 126521, 126521, 126523, 126523, 126530, 126530, 126535, 126535, 126537, 126537, 126539, 126539, 126541, 126543, 126545, 126546, 126548, 126548, 126551, 126551, 126553, 126553, 126555, 126555, 126557, 126557, 126559, 126559, 126561, 126562, 126564, 126564, 126567, 126570, 126572, 126578, 126580, 126583, 126585, 126588, 126590, 126590, 126592, 126601, 126603, 126619, 126625, 126627, 126629, 126633, 126635, 126651, 131072, 173782, 173824, 177972, 177984, 178205, 178208, 183969, 183984, 191456, 194560, 195101, 917760, 917999]; - var commentDirectiveRegExSingleLine = /^\s*\/\/\/?\s*@(ts-expect-error|ts-ignore)/; - var commentDirectiveRegExMultiLine = /^\s*(?:\/|\*)*\s*@(ts-expect-error|ts-ignore)/; + var commentDirectiveRegExSingleLine = /^\/\/\/?\s*@(ts-expect-error|ts-ignore)/; + var commentDirectiveRegExMultiLine = /^(?:\/|\*)*\s*@(ts-expect-error|ts-ignore)/; function lookupInUnicodeMap(code, map) { if (code < map[0]) { return false; @@ -6780,11 +6992,11 @@ var ts; } } ts.couldStartTrivia = couldStartTrivia; - function skipTrivia(text, pos, stopAfterLineBreak, stopAtComments) { - if (stopAtComments === void 0) { stopAtComments = false; } + function skipTrivia(text, pos, stopAfterLineBreak, stopAtComments, inJSDoc) { if (ts.positionIsSynthesized(pos)) { return pos; } + var canConsumeStar = false; while (true) { var ch = text.charCodeAt(pos); switch (ch) { @@ -6797,6 +7009,7 @@ var ts; if (stopAfterLineBreak) { return pos; } + canConsumeStar = !!inJSDoc; continue; case 9: case 11: @@ -6816,6 +7029,7 @@ var ts; } pos++; } + canConsumeStar = false; continue; } if (text.charCodeAt(pos + 1) === 42) { @@ -6827,6 +7041,7 @@ var ts; } pos++; } + canConsumeStar = false; continue; } break; @@ -6836,12 +7051,21 @@ var ts; case 62: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos); + canConsumeStar = false; continue; } break; case 35: if (pos === 0 && isShebangTrivia(text, pos)) { pos = scanShebangTrivia(text, pos); + canConsumeStar = false; + continue; + } + break; + case 42: + if (canConsumeStar) { + pos++; + canConsumeStar = false; continue; } break; @@ -7091,8 +7315,8 @@ var ts; hasExtendedUnicodeEscape: function () { return (tokenFlags & 8) !== 0; }, hasPrecedingLineBreak: function () { return (tokenFlags & 1) !== 0; }, hasPrecedingJSDocComment: function () { return (tokenFlags & 2) !== 0; }, - isIdentifier: function () { return token === 78 || token > 115; }, - isReservedWord: function () { return token >= 80 && token <= 115; }, + isIdentifier: function () { return token === 79 || token > 116; }, + isReservedWord: function () { return token >= 81 && token <= 116; }, isUnterminated: function () { return (tokenFlags & 4) !== 0; }, getCommentDirectives: function () { return commentDirectives; }, getNumericLiteralFlags: function () { return tokenFlags & 1008; }, @@ -7107,7 +7331,9 @@ var ts; reScanJsxAttributeValue: reScanJsxAttributeValue, reScanJsxToken: reScanJsxToken, reScanLessThanToken: reScanLessThanToken, + reScanHashToken: reScanHashToken, reScanQuestionToken: reScanQuestionToken, + reScanInvalidIdentifier: reScanInvalidIdentifier, scanJsxToken: scanJsxToken, scanJsDocToken: scanJsDocToken, scan: scan, @@ -7583,7 +7809,7 @@ var ts; } } } - return token = 78; + return token = 79; } function scanBinaryOrOctalDigits(base) { var value = ""; @@ -7724,19 +7950,19 @@ var ts; return token = scanTemplateAndSetTokenValue(false); case 37: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 68; + return pos += 2, token = 69; } pos++; return token = 44; case 38: if (text.charCodeAt(pos + 1) === 38) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 75; + return pos += 3, token = 76; } return pos += 2, token = 55; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 72; + return pos += 2, token = 73; } pos++; return token = 50; @@ -7748,11 +7974,11 @@ var ts; return token = 21; case 42: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 65; + return pos += 2, token = 66; } if (text.charCodeAt(pos + 1) === 42) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 66; + return pos += 3, token = 67; } return pos += 2, token = 42; } @@ -7767,7 +7993,7 @@ var ts; return pos += 2, token = 45; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 63; + return pos += 2, token = 64; } pos++; return token = 39; @@ -7779,7 +8005,7 @@ var ts; return pos += 2, token = 46; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 64; + return pos += 2, token = 65; } pos++; return token = 40; @@ -7845,7 +8071,7 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 67; + return pos += 2, token = 68; } pos++; return token = 43; @@ -7917,7 +8143,7 @@ var ts; } if (text.charCodeAt(pos + 1) === 60) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 69; + return pos += 3, token = 70; } return pos += 2, token = 47; } @@ -7951,7 +8177,7 @@ var ts; return pos += 2, token = 38; } pos++; - return token = 62; + return token = 63; case 62: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -7970,7 +8196,7 @@ var ts; } if (text.charCodeAt(pos + 1) === 63) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 76; + return pos += 3, token = 77; } return pos += 2, token = 60; } @@ -7984,7 +8210,7 @@ var ts; return token = 23; case 94: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 77; + return pos += 2, token = 78; } pos++; return token = 52; @@ -8003,12 +8229,12 @@ var ts; } if (text.charCodeAt(pos + 1) === 124) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 74; + return pos += 3, token = 75; } return pos += 2, token = 56; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 73; + return pos += 2, token = 74; } pos++; return token = 51; @@ -8046,30 +8272,12 @@ var ts; return token = 0; } pos++; - if (isIdentifierStart(ch = text.charCodeAt(pos), languageVersion)) { - pos++; - while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion)) - pos++; - tokenValue = text.substring(tokenPos, pos); - if (ch === 92) { - tokenValue += scanIdentifierParts(); - } - } - else { - tokenValue = "#"; - error(ts.Diagnostics.Invalid_character); - } - return token = 79; + scanIdentifier(codePointAt(text, pos), languageVersion); + return token = 80; default: - if (isIdentifierStart(ch, languageVersion)) { - pos += charSize(ch); - while (pos < end && isIdentifierPart(ch = codePointAt(text, pos), languageVersion)) - pos += charSize(ch); - tokenValue = text.substring(tokenPos, pos); - if (ch === 92) { - tokenValue += scanIdentifierParts(); - } - return token = getIdentifierToken(); + var identifierKind = scanIdentifier(ch, languageVersion); + if (identifierKind) { + return token = identifierKind; } else if (isWhiteSpaceSingleLine(ch)) { pos += charSize(ch); @@ -8086,17 +8294,42 @@ var ts; } } } + function reScanInvalidIdentifier() { + ts.Debug.assert(token === 0, "'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); + if (identifierKind) { + return token = identifierKind; + } + pos += charSize(ch); + return token; + } + function scanIdentifier(startCharacter, languageVersion) { + var ch = startCharacter; + if (isIdentifierStart(ch, languageVersion)) { + pos += charSize(ch); + while (pos < end && isIdentifierPart(ch = codePointAt(text, pos), languageVersion)) + pos += charSize(ch); + tokenValue = text.substring(tokenPos, pos); + if (ch === 92) { + tokenValue += scanIdentifierParts(); + } + return getIdentifierToken(); + } + } function reScanGreaterToken() { if (token === 31) { if (text.charCodeAt(pos) === 62) { if (text.charCodeAt(pos + 1) === 62) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 71; + return pos += 3, token = 72; } return pos += 2, token = 49; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 70; + return pos += 2, token = 71; } pos++; return token = 48; @@ -8109,12 +8342,12 @@ var ts; return token; } function reScanAsteriskEqualsToken() { - ts.Debug.assert(token === 65, "'reScanAsteriskEqualsToken' should only be called on a '*='"); + ts.Debug.assert(token === 66, "'reScanAsteriskEqualsToken' should only be called on a '*='"); pos = tokenPos + 1; - return token = 62; + return token = 63; } function reScanSlashToken() { - if (token === 43 || token === 67) { + if (token === 43 || token === 68) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -8158,7 +8391,7 @@ var ts; return token; } function appendIfCommentDirective(commentDirectives, text, commentDirectiveRegEx, lineStart) { - var type = getDirectiveFromComment(text, commentDirectiveRegEx); + var type = getDirectiveFromComment(ts.trimStringStart(text), commentDirectiveRegEx); if (type === undefined) { return commentDirectives; } @@ -8189,9 +8422,10 @@ var ts; pos = tokenPos; return token = scanTemplateAndSetTokenValue(true); } - function reScanJsxToken() { + function reScanJsxToken(allowMultilineJsxText) { + if (allowMultilineJsxText === void 0) { allowMultilineJsxText = true; } pos = tokenPos = startPos; - return token = scanJsxToken(); + return token = scanJsxToken(allowMultilineJsxText); } function reScanLessThanToken() { if (token === 47) { @@ -8200,12 +8434,20 @@ var ts; } return token; } + function reScanHashToken() { + if (token === 80) { + pos = tokenPos + 1; + return token = 62; + } + return token; + } function reScanQuestionToken() { ts.Debug.assert(token === 60, "'reScanQuestionToken' should only be called on a '??'"); pos = tokenPos + 1; return token = 57; } - function scanJsxToken() { + function scanJsxToken(allowMultilineJsxText) { + if (allowMultilineJsxText === void 0) { allowMultilineJsxText = true; } startPos = tokenPos = pos; if (pos >= end) { return token = 1; @@ -8224,11 +8466,7 @@ var ts; return token = 18; } var firstNonWhitespace = 0; - var lastNonWhitespace = -1; while (pos < end) { - if (!isWhiteSpaceSingleLine(char)) { - lastNonWhitespace = pos; - } char = text.charCodeAt(pos); if (char === 123) { break; @@ -8246,18 +8484,18 @@ var ts; if (char === 125) { error(ts.Diagnostics.Unexpected_token_Did_you_mean_or_rbrace, pos, 1); } - if (lastNonWhitespace > 0) - lastNonWhitespace++; if (isLineBreak(char) && firstNonWhitespace === 0) { firstNonWhitespace = -1; } + else if (!allowMultilineJsxText && isLineBreak(char) && firstNonWhitespace > 0) { + break; + } else if (!isWhiteSpaceLike(char)) { firstNonWhitespace = pos; } pos++; } - var endPosition = lastNonWhitespace === -1 ? pos : lastNonWhitespace; - tokenValue = text.substring(startPos, endPosition); + tokenValue = text.substring(startPos, pos); return firstNonWhitespace === -1 ? 12 : 11; } function scanJsxIdentifier() { @@ -8274,6 +8512,7 @@ var ts; tokenValue += ":"; pos++; namespaceSeparator = true; + token = 79; continue; } var oldPos = pos; @@ -8345,13 +8584,15 @@ var ts; case 62: return token = 31; case 61: - return token = 62; + return token = 63; case 44: return token = 27; case 46: return token = 24; case 96: return token = 61; + case 35: + return token = 62; case 92: pos--; var extendedCookedChar = peekExtendedUnicodeEscape(); @@ -8513,6 +8754,8 @@ var ts; switch (options.target) { case 99: return "lib.esnext.full.d.ts"; + case 8: + return "lib.es2021.full.d.ts"; case 7: return "lib.es2020.full.d.ts"; case 6: @@ -8640,9 +8883,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 159) { + if (d && d.kind === 161) { for (var current = d; current; current = current.parent) { - if (isFunctionLike(current) || isClassLike(current) || current.kind === 253) { + if (isFunctionLike(current) || isClassLike(current) || current.kind === 255) { return current; } } @@ -8650,7 +8893,7 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node, parent) { - return ts.hasSyntacticModifier(node, 92) && parent.kind === 166; + return ts.hasSyntacticModifier(node, 16476) && parent.kind === 168; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -8680,14 +8923,14 @@ var ts; node = walkUpBindingElementsAndPatterns(node); } var flags = getFlags(node); - if (node.kind === 249) { + if (node.kind === 251) { node = node.parent; } - if (node && node.kind === 250) { + if (node && node.kind === 252) { flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 232) { + if (node && node.kind === 234) { flags |= getFlags(node); } return flags; @@ -8704,8 +8947,10 @@ var ts; return getCombinedFlags(node, function (n) { return n.flags; }); } ts.getCombinedNodeFlags = getCombinedNodeFlags; + ts.supportedLocaleDirectories = ["cs", "de", "es", "fr", "it", "ja", "ko", "pl", "pt-br", "ru", "tr", "zh-cn", "zh-tw"]; function validateLocaleAndSetLanguage(locale, sys, errors) { - var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase()); + var lowerCaseLocale = locale.toLowerCase(); + var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(lowerCaseLocale); if (!matchResult) { if (errors) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1, "en", "ja-jp")); @@ -8714,7 +8959,7 @@ var ts; } var language = matchResult[1]; var territory = matchResult[3]; - if (!trySetLanguageAndTerritory(language, territory, errors)) { + if (ts.contains(ts.supportedLocaleDirectories, lowerCaseLocale) && !trySetLanguageAndTerritory(language, territory, errors)) { trySetLanguageAndTerritory(language, undefined, errors); } ts.setUILocale(locale); @@ -8806,7 +9051,7 @@ var ts; } ts.idText = idText; function symbolName(symbol) { - if (symbol.valueDeclaration && isPrivateIdentifierPropertyDeclaration(symbol.valueDeclaration)) { + if (symbol.valueDeclaration && isPrivateIdentifierClassElementDeclaration(symbol.valueDeclaration)) { return idText(symbol.valueDeclaration.name); } return unescapeLeadingUnderscores(symbol.escapedName); @@ -8821,30 +9066,30 @@ var ts; return getDeclarationIdentifier(hostNode); } switch (hostNode.kind) { - case 232: + case 234: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } break; - case 233: + case 235: var expr = hostNode.expression; - if (expr.kind === 216 && expr.operatorToken.kind === 62) { + if (expr.kind === 218 && expr.operatorToken.kind === 63) { expr = expr.left; } switch (expr.kind) { - case 201: + case 203: return expr.name; - case 202: + case 204: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; } } break; - case 207: { + case 209: { return getDeclarationIdentifier(hostNode.expression); } - case 245: { + case 247: { if (isDeclaration(hostNode.statement) || isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -8876,18 +9121,18 @@ var ts; ts.isNamedDeclaration = isNamedDeclaration; function getNonAssignedNameOfDeclaration(declaration) { switch (declaration.kind) { - case 78: + case 79: return declaration; - case 333: - case 326: { + case 341: + case 334: { var name = declaration.name; - if (name.kind === 157) { + if (name.kind === 159) { return name.right; } break; } - case 203: - case 216: { + case 205: + case 218: { var expr_1 = declaration; switch (ts.getAssignmentDeclarationKind(expr_1)) { case 1: @@ -8903,15 +9148,15 @@ var ts; return undefined; } } - case 331: + case 339: return getNameOfJSDocTypedef(declaration); - case 325: + case 333: return nameForNamelessJSDocTypedef(declaration); - case 266: { + case 268: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } - case 202: + case 204: var expr = declaration; if (ts.isBindableStaticElementAccessExpression(expr)) { return expr.argumentExpression; @@ -8924,7 +9169,7 @@ var ts; if (declaration === undefined) return undefined; return getNonAssignedNameOfDeclaration(declaration) || - (ts.isFunctionExpression(declaration) || ts.isClassExpression(declaration) ? getAssignedName(declaration) : undefined); + (ts.isFunctionExpression(declaration) || ts.isArrowFunction(declaration) || ts.isClassExpression(declaration) ? getAssignedName(declaration) : undefined); } ts.getNameOfDeclaration = getNameOfDeclaration; function getAssignedName(node) { @@ -9034,6 +9279,10 @@ var ts; return getFirstJSDocTag(node, ts.isJSDocReadonlyTag, true); } ts.getJSDocReadonlyTagNoCache = getJSDocReadonlyTagNoCache; + function getJSDocOverrideTagNoCache(node) { + return getFirstJSDocTag(node, ts.isJSDocOverrideTag, true); + } + ts.getJSDocOverrideTagNoCache = getJSDocOverrideTagNoCache; function getJSDocDeprecatedTag(node) { return getFirstJSDocTag(node, ts.isJSDocDeprecatedTag); } @@ -9123,12 +9372,19 @@ var ts; return getJSDocTags(node).filter(function (doc) { return doc.kind === kind; }); } ts.getAllJSDocTagsOfKind = getAllJSDocTagsOfKind; + function getTextOfJSDocComment(comment) { + return typeof comment === "string" ? comment + : comment === null || comment === void 0 ? void 0 : comment.map(function (c) { + return c.kind === 315 ? c.text : "{@link " + (c.name ? ts.entityNameToString(c.name) + " " : "") + c.text + "}"; + }).join(""); + } + ts.getTextOfJSDocComment = getTextOfJSDocComment; function getEffectiveTypeParameterDeclarations(node) { if (ts.isJSDocSignature(node)) { return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 311); + ts.Debug.assert(node.parent.kind === 314); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -9153,12 +9409,12 @@ var ts; undefined; } ts.getEffectiveConstraintOfTypeParameter = getEffectiveConstraintOfTypeParameter; - function isIdentifierOrPrivateIdentifier(node) { - return node.kind === 78 || node.kind === 79; + function isMemberName(node) { + return node.kind === 79 || node.kind === 80; } - ts.isIdentifierOrPrivateIdentifier = isIdentifierOrPrivateIdentifier; + ts.isMemberName = isMemberName; function isGetOrSetAccessorDeclaration(node) { - return node.kind === 168 || node.kind === 167; + return node.kind === 170 || node.kind === 169; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; function isPropertyAccessChain(node) { @@ -9176,10 +9432,10 @@ var ts; function isOptionalChain(node) { var kind = node.kind; return !!(node.flags & 32) && - (kind === 201 - || kind === 202 - || kind === 203 - || kind === 225); + (kind === 203 + || kind === 204 + || kind === 205 + || kind === 227); } ts.isOptionalChain = isOptionalChain; function isOptionalChainRoot(node) { @@ -9197,7 +9453,7 @@ var ts; } ts.isOutermostOptionalChain = isOutermostOptionalChain; function isNullishCoalesce(node) { - return node.kind === 216 && node.operatorToken.kind === 60; + return node.kind === 218 && node.operatorToken.kind === 60; } ts.isNullishCoalesce = isNullishCoalesce; function isConstTypeReference(node) { @@ -9214,17 +9470,17 @@ var ts; } ts.isNonNullChain = isNonNullChain; function isBreakOrContinueStatement(node) { - return node.kind === 241 || node.kind === 240; + return node.kind === 243 || node.kind === 242; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isNamedExportBindings(node) { - return node.kind === 269 || node.kind === 268; + return node.kind === 271 || node.kind === 270; } ts.isNamedExportBindings = isNamedExportBindings; function isUnparsedTextLike(node) { switch (node.kind) { - case 294: - case 295: + case 296: + case 297: return true; default: return false; @@ -9233,12 +9489,12 @@ var ts; ts.isUnparsedTextLike = isUnparsedTextLike; function isUnparsedNode(node) { return isUnparsedTextLike(node) || - node.kind === 292 || - node.kind === 296; + node.kind === 294 || + node.kind === 298; } ts.isUnparsedNode = isUnparsedNode; function isJSDocPropertyLikeTag(node) { - return node.kind === 333 || node.kind === 326; + return node.kind === 341 || node.kind === 334; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isNode(node) { @@ -9246,11 +9502,15 @@ var ts; } ts.isNode = isNode; function isNodeKind(kind) { - return kind >= 157; + return kind >= 159; } ts.isNodeKind = isNodeKind; + function isTokenKind(kind) { + return kind >= 0 && kind <= 158; + } + ts.isTokenKind = isTokenKind; function isToken(n) { - return n.kind >= 0 && n.kind <= 156; + return isTokenKind(n.kind); } ts.isToken = isToken; function isNodeArray(array) { @@ -9285,13 +9545,13 @@ var ts; ts.isImportOrExportSpecifier = isImportOrExportSpecifier; function isTypeOnlyImportOrExportDeclaration(node) { switch (node.kind) { - case 265: - case 270: + case 267: + case 272: return node.parent.parent.isTypeOnly; - case 263: + case 265: return node.parent.isTypeOnly; + case 264: case 262: - case 260: return node.isTypeOnly; default: return false; @@ -9306,38 +9566,39 @@ var ts; return ts.isIdentifier(node) && (node.autoGenerateFlags & 7) > 0; } ts.isGeneratedIdentifier = isGeneratedIdentifier; - function isPrivateIdentifierPropertyDeclaration(node) { - return ts.isPropertyDeclaration(node) && ts.isPrivateIdentifier(node.name); + function isPrivateIdentifierClassElementDeclaration(node) { + return (ts.isPropertyDeclaration(node) || isMethodOrAccessor(node)) && ts.isPrivateIdentifier(node.name); } - ts.isPrivateIdentifierPropertyDeclaration = isPrivateIdentifierPropertyDeclaration; + ts.isPrivateIdentifierClassElementDeclaration = isPrivateIdentifierClassElementDeclaration; function isPrivateIdentifierPropertyAccessExpression(node) { return ts.isPropertyAccessExpression(node) && ts.isPrivateIdentifier(node.name); } ts.isPrivateIdentifierPropertyAccessExpression = isPrivateIdentifierPropertyAccessExpression; function isModifierKind(token) { switch (token) { - case 125: - case 129: - case 84: - case 133: - case 87: - case 92: - case 122: - case 120: - case 121: - case 142: + case 126: + case 130: + case 85: + case 134: + case 88: + case 93: case 123: + case 121: + case 122: + case 143: + case 124: + case 157: return true; } return false; } ts.isModifierKind = isModifierKind; function isParameterPropertyModifier(kind) { - return !!(ts.modifierToFlag(kind) & 92); + return !!(ts.modifierToFlag(kind) & 16476); } ts.isParameterPropertyModifier = isParameterPropertyModifier; function isClassMemberModifier(idToken) { - return isParameterPropertyModifier(idToken) || idToken === 123; + return isParameterPropertyModifier(idToken) || idToken === 124 || idToken === 157; } ts.isClassMemberModifier = isClassMemberModifier; function isModifier(node) { @@ -9346,28 +9607,28 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 157 - || kind === 78; + return kind === 159 + || kind === 79; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 78 - || kind === 79 + return kind === 79 + || kind === 80 || kind === 10 || kind === 8 - || kind === 158; + || kind === 160; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; - return kind === 78 - || kind === 196 - || kind === 197; + return kind === 79 + || kind === 198 + || kind === 199; } ts.isBindingName = isBindingName; function isFunctionLike(node) { - return node && isFunctionLikeKind(node.kind); + return !!node && isFunctionLikeKind(node.kind); } ts.isFunctionLike = isFunctionLike; function isFunctionLikeDeclaration(node) { @@ -9376,13 +9637,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 251: - case 165: - case 166: + case 253: case 167: case 168: - case 208: - case 209: + case 169: + case 170: + case 210: + case 211: return true; default: return false; @@ -9390,14 +9651,14 @@ var ts; } function isFunctionLikeKind(kind) { switch (kind) { - case 164: - case 169: - case 313: - case 170: + case 166: case 171: - case 174: - case 308: - case 175: + case 317: + case 172: + case 173: + case 176: + case 311: + case 177: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -9410,28 +9671,28 @@ var ts; ts.isFunctionOrModuleBlock = isFunctionOrModuleBlock; function isClassElement(node) { var kind = node.kind; - return kind === 166 - || kind === 163 + return kind === 168 || kind === 165 || kind === 167 - || kind === 168 - || kind === 171 - || kind === 229; + || kind === 169 + || kind === 170 + || kind === 173 + || kind === 231; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 252 || node.kind === 221); + return node && (node.kind === 254 || node.kind === 223); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 167 || node.kind === 168); + return node && (node.kind === 169 || node.kind === 170); } ts.isAccessor = isAccessor; function isMethodOrAccessor(node) { switch (node.kind) { - case 165: case 167: - case 168: + case 169: + case 170: return true; default: return false; @@ -9440,11 +9701,11 @@ var ts; ts.isMethodOrAccessor = isMethodOrAccessor; function isTypeElement(node) { var kind = node.kind; - return kind === 170 - || kind === 169 - || kind === 162 + return kind === 172 + || kind === 171 || kind === 164 - || kind === 171; + || kind === 166 + || kind === 173; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -9453,12 +9714,12 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 288 - || kind === 289 - || kind === 290 - || kind === 165 + return kind === 290 + || kind === 291 + || kind === 292 || kind === 167 - || kind === 168; + || kind === 169 + || kind === 170; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; function isTypeNode(node) { @@ -9467,8 +9728,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 174: - case 175: + case 176: + case 177: return true; } return false; @@ -9477,29 +9738,29 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 197 - || kind === 196; + return kind === 199 + || kind === 198; } return false; } ts.isBindingPattern = isBindingPattern; function isAssignmentPattern(node) { var kind = node.kind; - return kind === 199 - || kind === 200; + return kind === 201 + || kind === 202; } ts.isAssignmentPattern = isAssignmentPattern; function isArrayBindingElement(node) { var kind = node.kind; - return kind === 198 - || kind === 222; + return kind === 200 + || kind === 224; } ts.isArrayBindingElement = isArrayBindingElement; function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 249: - case 160: - case 198: + case 251: + case 162: + case 200: return true; } return false; @@ -9512,8 +9773,8 @@ var ts; ts.isBindingOrAssignmentPattern = isBindingOrAssignmentPattern; function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 196: - case 200: + case 198: + case 202: return true; } return false; @@ -9521,8 +9782,8 @@ var ts; ts.isObjectBindingOrAssignmentPattern = isObjectBindingOrAssignmentPattern; function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 197: case 199: + case 201: return true; } return false; @@ -9530,25 +9791,25 @@ var ts; ts.isArrayBindingOrAssignmentPattern = isArrayBindingOrAssignmentPattern; function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 201 - || kind === 157 - || kind === 195; + return kind === 203 + || kind === 159 + || kind === 197; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 201 - || kind === 157; + return kind === 203 + || kind === 159; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 275: - case 274: - case 203: - case 204: + case 277: + case 276: case 205: - case 161: + case 206: + case 207: + case 163: return true; default: return false; @@ -9556,12 +9817,12 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 203 || node.kind === 204; + return node.kind === 205 || node.kind === 206; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 218 + return kind === 220 || kind === 14; } ts.isTemplateLiteral = isTemplateLiteral; @@ -9571,34 +9832,34 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 201: - case 202: - case 204: case 203: - case 273: - case 274: - case 277: + case 204: + case 206: case 205: - case 199: + case 275: + case 276: + case 279: case 207: - case 200: - case 221: - case 208: - case 78: + case 201: + case 209: + case 202: + case 223: + case 210: + case 79: case 13: case 8: case 9: case 10: case 14: - case 218: - case 94: - case 103: - case 107: - case 109: - case 105: - case 225: - case 226: - case 99: + case 220: + case 95: + case 104: + case 108: + case 110: + case 106: + case 227: + case 228: + case 100: return true; default: return false; @@ -9610,13 +9871,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 214: - case 215: - case 210: - case 211: + case 216: + case 217: case 212: case 213: - case 206: + case 214: + case 215: + case 208: return true; default: return isLeftHandSideExpressionKind(kind); @@ -9624,9 +9885,9 @@ var ts; } function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 215: + case 217: return true; - case 214: + case 216: return expr.operator === 45 || expr.operator === 46; default: @@ -9640,15 +9901,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 217: case 219: - case 209: - case 216: - case 220: - case 224: + case 221: + case 211: + case 218: case 222: - case 337: - case 336: + case 226: + case 224: + case 345: + case 344: return true; default: return isUnaryExpressionKind(kind); @@ -9656,8 +9917,8 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 206 - || kind === 224; + return kind === 208 + || kind === 226; } ts.isAssertionExpression = isAssertionExpression; function isNotEmittedOrPartiallyEmittedNode(node) { @@ -9667,13 +9928,13 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { + case 239: + case 240: + case 241: case 237: case 238: - case 239: - case 235: - case 236: return true; - case 245: + case 247: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -9696,7 +9957,7 @@ var ts; } ts.isExternalModuleIndicator = isExternalModuleIndicator; function isForInOrOfStatement(node) { - return node.kind === 238 || node.kind === 239; + return node.kind === 240 || node.kind === 241; } ts.isForInOrOfStatement = isForInOrOfStatement; function isConciseBody(node) { @@ -9715,109 +9976,109 @@ var ts; ts.isForInitializer = isForInitializer; function isModuleBody(node) { var kind = node.kind; - return kind === 257 - || kind === 256 - || kind === 78; + return kind === 259 + || kind === 258 + || kind === 79; } ts.isModuleBody = isModuleBody; function isNamespaceBody(node) { var kind = node.kind; - return kind === 257 - || kind === 256; + return kind === 259 + || kind === 258; } ts.isNamespaceBody = isNamespaceBody; function isJSDocNamespaceBody(node) { var kind = node.kind; - return kind === 78 - || kind === 256; + return kind === 79 + || kind === 258; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 264 - || kind === 263; + return kind === 266 + || kind === 265; } ts.isNamedImportBindings = isNamedImportBindings; function isModuleOrEnumDeclaration(node) { - return node.kind === 256 || node.kind === 255; + return node.kind === 258 || node.kind === 257; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 209 - || kind === 198 - || kind === 252 - || kind === 221 - || kind === 166 + return kind === 211 + || kind === 200 + || kind === 254 + || kind === 223 + || kind === 168 + || kind === 257 + || kind === 293 + || kind === 272 + || kind === 253 + || kind === 210 + || kind === 169 + || kind === 264 + || kind === 262 + || kind === 267 || kind === 255 - || kind === 291 - || kind === 270 - || kind === 251 - || kind === 208 + || kind === 282 || kind === 167 - || kind === 262 - || kind === 260 + || kind === 166 + || kind === 258 + || kind === 261 || kind === 265 - || kind === 253 - || kind === 280 + || kind === 271 + || kind === 162 + || kind === 290 || kind === 165 || kind === 164 + || kind === 170 + || kind === 291 || kind === 256 - || kind === 259 - || kind === 263 - || kind === 269 - || kind === 160 - || kind === 288 - || kind === 163 - || kind === 162 - || kind === 168 - || kind === 289 - || kind === 254 - || kind === 159 - || kind === 249 - || kind === 331 - || kind === 324 - || kind === 333; + || kind === 161 + || kind === 251 + || kind === 339 + || kind === 332 + || kind === 341; } function isDeclarationStatementKind(kind) { - return kind === 251 - || kind === 271 - || kind === 252 - || kind === 253 + return kind === 253 + || kind === 273 || kind === 254 || kind === 255 || kind === 256 - || kind === 261 - || kind === 260 - || kind === 267 - || kind === 266 - || kind === 259; + || kind === 257 + || kind === 258 + || kind === 263 + || kind === 262 + || kind === 269 + || kind === 268 + || kind === 261; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 241 - || kind === 240 - || kind === 248 + return kind === 243 + || kind === 242 + || kind === 250 + || kind === 237 || kind === 235 || kind === 233 - || kind === 231 - || kind === 238 + || kind === 240 + || kind === 241 || kind === 239 - || kind === 237 - || kind === 234 - || kind === 245 - || kind === 242 + || kind === 236 + || kind === 247 || kind === 244 || kind === 246 - || kind === 247 - || kind === 232 - || kind === 236 - || kind === 243 - || kind === 335 - || kind === 339 - || kind === 338; + || kind === 248 + || kind === 249 + || kind === 234 + || kind === 238 + || kind === 245 + || kind === 343 + || kind === 347 + || kind === 346; } function isDeclaration(node) { - if (node.kind === 159) { - return (node.parent && node.parent.kind !== 330) || ts.isInJSFile(node); + if (node.kind === 161) { + return (node.parent && node.parent.kind !== 338) || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -9838,10 +10099,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 230) + if (node.kind !== 232) return false; if (node.parent !== undefined) { - if (node.parent.kind === 247 || node.parent.kind === 287) { + if (node.parent.kind === 249 || node.parent.kind === 289) { return false; } } @@ -9851,74 +10112,80 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 230; + || kind === 232; } ts.isStatementOrBlock = isStatementOrBlock; function isModuleReference(node) { var kind = node.kind; - return kind === 272 - || kind === 157 - || kind === 78; + return kind === 274 + || kind === 159 + || kind === 79; } ts.isModuleReference = isModuleReference; function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 107 - || kind === 78 - || kind === 201; + return kind === 108 + || kind === 79 + || kind === 203; } ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 273 - || kind === 283 - || kind === 274 + return kind === 275 + || kind === 285 + || kind === 276 || kind === 11 - || kind === 277; + || kind === 279; } ts.isJsxChild = isJsxChild; function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 280 - || kind === 282; + return kind === 282 + || kind === 284; } ts.isJsxAttributeLike = isJsxAttributeLike; function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 10 - || kind === 283; + || kind === 285; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 275 - || kind === 274; + return kind === 277 + || kind === 276; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 284 - || kind === 285; + return kind === 286 + || kind === 287; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; function isJSDocNode(node) { - return node.kind >= 301 && node.kind <= 333; + return node.kind >= 303 && node.kind <= 341; } ts.isJSDocNode = isJSDocNode; function isJSDocCommentContainingNode(node) { - return node.kind === 311 || node.kind === 310 || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 314 + || node.kind === 313 + || node.kind === 315 + || isJSDocLinkLike(node) + || isJSDocTag(node) + || ts.isJSDocTypeLiteral(node) + || ts.isJSDocSignature(node); } ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode; function isJSDocTag(node) { - return node.kind >= 314 && node.kind <= 333; + return node.kind >= 321 && node.kind <= 341; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 168; + return node.kind === 170; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 167; + return node.kind === 169; } ts.isGetAccessor = isGetAccessor; function hasJSDocNodes(node) { @@ -9936,13 +10203,13 @@ var ts; ts.hasInitializer = hasInitializer; function hasOnlyExpressionInitializer(node) { switch (node.kind) { - case 249: - case 160: - case 198: + case 251: case 162: - case 163: - case 288: - case 291: + case 200: + case 164: + case 165: + case 290: + case 293: return true; default: return false; @@ -9950,11 +10217,11 @@ var ts; } ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { - return node.kind === 280 || node.kind === 282 || isObjectLiteralElementLike(node); + return node.kind === 282 || node.kind === 284 || isObjectLiteralElementLike(node); } ts.isObjectLiteralElement = isObjectLiteralElement; function isTypeReferenceType(node) { - return node.kind === 173 || node.kind === 223; + return node.kind === 175 || node.kind === 225; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -9985,6 +10252,10 @@ var ts; return node.kind === 10 || node.kind === 14; } ts.isStringLiteralLike = isStringLiteralLike; + function isJSDocLinkLike(node) { + return node.kind === 318 || node.kind === 319 || node.kind === 320; + } + ts.isJSDocLinkLike = isJSDocLinkLike; })(ts || (ts = {})); var ts; (function (ts) { @@ -10058,7 +10329,7 @@ var ts; increaseIndent: ts.noop, decreaseIndent: ts.noop, clear: function () { return str = ""; }, - trackSymbol: ts.noop, + trackSymbol: function () { return false; }, reportInaccessibleThisError: ts.noop, reportInaccessibleUniqueSymbolError: ts.noop, reportPrivateInBaseOfClassExpression: ts.noop, @@ -10070,11 +10341,19 @@ var ts; } ts.changesAffectModuleResolution = changesAffectModuleResolution; function optionsHaveModuleResolutionChanges(oldOptions, newOptions) { - return ts.moduleResolutionOptionDeclarations.some(function (o) { + return optionsHaveChanges(oldOptions, newOptions, ts.moduleResolutionOptionDeclarations); + } + ts.optionsHaveModuleResolutionChanges = optionsHaveModuleResolutionChanges; + function changesAffectingProgramStructure(oldOptions, newOptions) { + return optionsHaveChanges(oldOptions, newOptions, ts.optionsAffectingProgramStructure); + } + ts.changesAffectingProgramStructure = changesAffectingProgramStructure; + function optionsHaveChanges(oldOptions, newOptions, optionDeclarations) { + return oldOptions !== newOptions && optionDeclarations.some(function (o) { return !isJsonEqual(getCompilerOptionValue(oldOptions, o), getCompilerOptionValue(newOptions, o)); }); } - ts.optionsHaveModuleResolutionChanges = optionsHaveModuleResolutionChanges; + ts.optionsHaveChanges = optionsHaveChanges; function forEachAncestor(node, callback) { while (true) { var res = callback(node); @@ -10175,7 +10454,9 @@ var ts; } ts.packageIdToString = packageIdToString; function typeDirectiveIsEqualTo(oldResolution, newResolution) { - return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.primary === newResolution.primary; + return oldResolution.resolvedFileName === newResolution.resolvedFileName + && oldResolution.primary === newResolution.primary + && oldResolution.originalPath === newResolution.originalPath; } ts.typeDirectiveIsEqualTo = typeDirectiveIsEqualTo; function hasChangesInResolutions(names, newResolutions, oldResolutions, comparer) { @@ -10209,7 +10490,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 297) { + while (node && node.kind !== 299) { node = node.parent; } return node; @@ -10217,11 +10498,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 230: - case 258: - case 237: - case 238: + case 232: + case 260: case 239: + case 240: + case 241: return true; } return false; @@ -10320,10 +10601,10 @@ var ts; commentPos + 2 < commentEnd && text.charCodeAt(commentPos + 2) === 47) { var textSubStr = text.substring(commentPos, commentEnd); - return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) || - textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) || - textSubStr.match(fullTripleSlashReferenceTypeReferenceDirectiveRegEx) || - textSubStr.match(defaultLibReferenceRegEx) ? + return ts.fullTripleSlashReferencePathRegEx.test(textSubStr) || + ts.fullTripleSlashAMDReferencePathRegEx.test(textSubStr) || + fullTripleSlashReferenceTypeReferenceDirectiveRegEx.test(textSubStr) || + defaultLibReferenceRegEx.test(textSubStr) ? true : false; } return false; @@ -10371,10 +10652,10 @@ var ts; if (includeJsDoc && ts.hasJSDocNodes(node)) { return getTokenPosOfNode(node.jsDoc[0], sourceFile); } - if (node.kind === 334 && node._children.length > 0) { + if (node.kind === 342 && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } - return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); + return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, false, false, isInJSDoc(node)); } ts.getTokenPosOfNode = getTokenPosOfNode; function getNonDecoratorTokenPosOfNode(node, sourceFile) { @@ -10403,7 +10684,7 @@ var ts; } var text = sourceText.substring(includeTrivia ? node.pos : ts.skipTrivia(sourceText, node.pos), node.end); if (isJSDocTypeExpressionOrChild(node)) { - text = text.replace(/(^|\r?\n|\r)\s*\*\s*/g, "$1"); + text = text.split(/\r\n|\n|\r/).map(function (line) { return ts.trimStringStart(line.replace(/^\s*\*/, "")); }).join("\n"); } return text; } @@ -10485,9 +10766,11 @@ var ts; DataView: ["setBigInt64", "setBigUint64", "getBigInt64", "getBigUint64"], RelativeTimeFormat: ["format", "formatToParts", "resolvedOptions"] }, - esnext: { + es2021: { PromiseConstructor: ["any"], - String: ["replaceAll"], + String: ["replaceAll"] + }, + esnext: { NumberFormat: ["formatToParts"] } }; @@ -10564,7 +10847,7 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 249 && node.parent.kind === 287; + return node.kind === 251 && node.parent.kind === 289; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { @@ -10588,11 +10871,11 @@ var ts; } ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { - return node && node.kind === 256 && (!node.body); + return !!node && node.kind === 258 && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 297 || - node.kind === 256 || + return node.kind === 299 || + node.kind === 258 || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -10606,16 +10889,17 @@ var ts; ts.isExternalModuleAugmentation = isExternalModuleAugmentation; function isModuleAugmentationExternal(node) { switch (node.parent.kind) { - case 297: + case 299: return ts.isExternalModule(node.parent); - case 257: + case 259: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; } ts.isModuleAugmentationExternal = isModuleAugmentationExternal; function getNonAugmentationDeclaration(symbol) { - return ts.find(symbol.declarations, function (d) { return !isExternalModuleAugmentation(d) && !(ts.isModuleDeclaration(d) && isGlobalScopeAugmentation(d)); }); + var _a; + return (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return !isExternalModuleAugmentation(d) && !(ts.isModuleDeclaration(d) && isGlobalScopeAugmentation(d)); }); } ts.getNonAugmentationDeclaration = getNonAugmentationDeclaration; function isEffectiveExternalModule(node, compilerOptions) { @@ -10652,22 +10936,22 @@ var ts; ts.isEffectiveStrictModeSourceFile = isEffectiveStrictModeSourceFile; function isBlockScope(node, parentNode) { switch (node.kind) { - case 297: + case 299: + case 260: + case 289: case 258: - case 287: - case 256: - case 237: - case 238: case 239: - case 166: - case 165: - case 167: + case 240: + case 241: case 168: - case 251: - case 208: - case 209: + case 167: + case 169: + case 170: + case 253: + case 210: + case 211: return true; - case 230: + case 232: return !ts.isFunctionLike(parentNode); } return false; @@ -10675,9 +10959,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 324: - case 331: - case 313: + case 332: + case 339: + case 317: return true; default: ts.assertType(node); @@ -10687,25 +10971,25 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isDeclarationWithTypeParameterChildren(node) { switch (node.kind) { - case 169: - case 170: - case 164: case 171: - case 174: - case 175: - case 308: - case 252: - case 221: - case 253: - case 254: - case 330: - case 251: - case 165: + case 172: case 166: + case 173: + case 176: + case 177: + case 311: + case 254: + case 223: + case 255: + case 256: + case 338: + case 253: case 167: case 168: - case 208: - case 209: + case 169: + case 170: + case 210: + case 211: return true; default: ts.assertType(node); @@ -10715,8 +10999,8 @@ var ts; ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren; function isAnyImportSyntax(node) { switch (node.kind) { - case 261: - case 260: + case 263: + case 262: return true; default: return false; @@ -10725,15 +11009,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 261: - case 260: - case 232: - case 252: - case 251: - case 256: + case 263: + case 262: + case 234: case 254: case 253: + case 258: + case 256: case 255: + case 257: return true; default: return false; @@ -10761,19 +11045,19 @@ var ts; } ts.getNameFromIndexInfo = getNameFromIndexInfo; function isComputedNonLiteralName(name) { - return name.kind === 158 && !isStringOrNumericLiteralLike(name.expression); + return name.kind === 160 && !isStringOrNumericLiteralLike(name.expression); } ts.isComputedNonLiteralName = isComputedNonLiteralName; function getTextOfPropertyName(name) { switch (name.kind) { - case 78: case 79: + case 80: return name.escapedText; case 10: case 8: case 14: return ts.escapeLeadingUnderscores(name.text); - case 158: + case 160: if (isStringOrNumericLiteralLike(name.expression)) return ts.escapeLeadingUnderscores(name.expression.text); return ts.Debug.fail("Text of property name cannot be read from non-literal-valued ComputedPropertyNames"); @@ -10784,20 +11068,22 @@ var ts; ts.getTextOfPropertyName = getTextOfPropertyName; function entityNameToString(name) { switch (name.kind) { - case 107: + case 108: return "this"; + case 80: case 79: - case 78: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 157: + case 159: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 201: + case 203: if (ts.isIdentifier(name.name) || ts.isPrivateIdentifier(name.name)) { return entityNameToString(name.expression) + "." + entityNameToString(name.name); } else { return ts.Debug.assertNever(name.name); } + case 305: + return entityNameToString(name.left) + entityNameToString(name.right); default: return ts.Debug.assertNever(name); } @@ -10877,7 +11163,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 230) { + if (node.body && node.body.kind === 232) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -10889,34 +11175,34 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 297: + case 299: var pos_1 = ts.skipTrivia(sourceFile.text, 0, false); if (pos_1 === sourceFile.text.length) { return ts.createTextSpan(0, 0); } return getSpanOfTokenAtPosition(sourceFile, pos_1); - case 249: - case 198: - case 252: - case 221: + case 251: + case 200: + case 254: + case 223: + case 255: + case 258: + case 257: + case 293: case 253: + case 210: + case 167: + case 169: + case 170: case 256: - case 255: - case 291: - case 251: - case 208: case 165: - case 167: - case 168: - case 254: - case 163: - case 162: + case 164: errorNode = node.name; break; - case 209: + case 211: return getErrorSpanForArrowFunction(sourceFile, node); - case 284: - case 285: + case 286: + case 287: 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); @@ -10965,16 +11251,16 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 203 && n.expression.kind === 105; + return n.kind === 205 && n.expression.kind === 106; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 203 && n.expression.kind === 99; + return n.kind === 205 && n.expression.kind === 100; } ts.isImportCall = isImportCall; function isImportMeta(n) { return ts.isMetaProperty(n) - && n.keywordToken === 99 + && n.keywordToken === 100 && n.name.escapedText === "meta"; } ts.isImportMeta = isImportMeta; @@ -10983,7 +11269,7 @@ var ts; } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 233 + return node.kind === 235 && node.expression.kind === 10; } ts.isPrologueDirective = isPrologueDirective; @@ -11011,11 +11297,12 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 160 || - node.kind === 159 || - node.kind === 208 || + var commentRanges = (node.kind === 162 || + node.kind === 161 || + node.kind === 210 || + node.kind === 211 || node.kind === 209 || - node.kind === 207) ? + node.kind === 251) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : ts.getLeadingCommentRanges(text, node.pos); return ts.filter(commentRanges, function (comment) { @@ -11025,84 +11312,84 @@ var ts; }); } ts.getJSDocCommentRanges = getJSDocCommentRanges; - ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; - var fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; - ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; - var defaultLibReferenceRegEx = /^(\/\/\/\s*/; + ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; + var fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; + ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; + var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (172 <= node.kind && node.kind <= 195) { + if (174 <= node.kind && node.kind <= 197) { return true; } switch (node.kind) { - case 128: - case 152: - case 144: - case 155: - case 147: - case 131: - case 148: + case 129: + case 153: case 145: - case 150: - case 141: + case 156: + case 148: + case 132: + case 149: + case 146: + case 151: + case 142: return true; - case 113: - return node.parent.kind !== 212; - case 223: + case 114: + return node.parent.kind !== 214; + case 225: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 159: - return node.parent.kind === 190 || node.parent.kind === 185; - case 78: - if (node.parent.kind === 157 && node.parent.right === node) { + case 161: + return node.parent.kind === 192 || node.parent.kind === 187; + case 79: + if (node.parent.kind === 159 && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 201 && node.parent.name === node) { + else if (node.parent.kind === 203 && node.parent.name === node) { node = node.parent; } - ts.Debug.assert(node.kind === 78 || node.kind === 157 || node.kind === 201, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); - case 157: - case 201: - case 107: { + ts.Debug.assert(node.kind === 79 || node.kind === 159 || node.kind === 203, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + case 159: + case 203: + case 108: { var parent = node.parent; - if (parent.kind === 176) { + if (parent.kind === 178) { return false; } - if (parent.kind === 195) { + if (parent.kind === 197) { return !parent.isTypeOf; } - if (172 <= parent.kind && parent.kind <= 195) { + if (174 <= parent.kind && parent.kind <= 197) { return true; } switch (parent.kind) { - case 223: + case 225: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 159: + case 161: return node === parent.constraint; - case 330: + case 338: return node === parent.constraint; - case 163: - case 162: - case 160: - case 249: - return node === parent.type; - case 251: - case 208: - case 209: - case 166: case 165: case 164: - case 167: - case 168: + case 162: + case 251: return node === parent.type; + case 253: + case 210: + case 211: + case 168: + case 167: + case 166: case 169: case 170: + return node === parent.type; case 171: + case 172: + case 173: return node === parent.type; - case 206: + case 208: return node === parent.type; - case 203: - case 204: - return ts.contains(parent.typeArguments, node); case 205: + case 206: + return ts.contains(parent.typeArguments, node); + case 207: return false; } } @@ -11124,23 +11411,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 242: + case 244: return visitor(node); - case 258: - case 230: - case 234: - case 235: + case 260: + case 232: case 236: case 237: case 238: case 239: - case 243: - case 244: - case 284: - case 285: + case 240: + case 241: case 245: - case 247: + case 246: + case 286: case 287: + case 247: + case 249: + case 289: return ts.forEachChild(node, traverse); } } @@ -11150,21 +11437,21 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 219: + case 221: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; + case 257: case 255: - case 253: + case 258: case 256: - case 254: return; default: if (ts.isFunctionLike(node)) { - if (node.name && node.name.kind === 158) { + if (node.name && node.name.kind === 160) { traverse(node.name.expression); return; } @@ -11177,10 +11464,10 @@ var ts; } ts.forEachYieldExpression = forEachYieldExpression; function getRestParameterElementType(node) { - if (node && node.kind === 178) { + if (node && node.kind === 180) { return node.elementType; } - else if (node && node.kind === 173) { + else if (node && node.kind === 175) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -11190,12 +11477,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 253: - case 252: - case 221: - case 177: + case 255: + case 254: + case 223: + case 179: return node.members; - case 200: + case 202: return node.properties; } } @@ -11203,14 +11490,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 198: - case 291: - case 160: - case 288: - case 163: + case 200: + case 293: case 162: - case 289: - case 249: + case 290: + case 165: + case 164: + case 291: + case 251: return true; } } @@ -11222,8 +11509,8 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 250 - && node.parent.parent.kind === 232; + return node.parent.kind === 252 + && node.parent.parent.kind === 234; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { @@ -11234,13 +11521,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 165: - case 164: - case 166: case 167: + case 166: case 168: - case 251: - case 208: + case 169: + case 170: + case 253: + case 210: return true; } return false; @@ -11251,7 +11538,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 245) { + if (node.statement.kind !== 247) { return node.statement; } node = node.statement; @@ -11259,17 +11546,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 230 && ts.isFunctionLike(node.parent); + return node && node.kind === 232 && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 165 && node.parent.kind === 200; + return node && node.kind === 167 && node.parent.kind === 202; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 165 && - (node.parent.kind === 200 || - node.parent.kind === 221); + return node.kind === 167 && + (node.parent.kind === 202 || + node.parent.kind === 223); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -11282,7 +11569,7 @@ var ts; ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 288) { + if (property.kind === 290) { var propName = getTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -11331,46 +11618,46 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 297); + ts.Debug.assert(node.kind !== 299); while (true) { node = node.parent; if (!node) { return ts.Debug.fail(); } switch (node.kind) { - case 158: + case 160: if (ts.isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 161: - if (node.parent.kind === 160 && ts.isClassElement(node.parent.parent)) { + case 163: + if (node.parent.kind === 162 && ts.isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (ts.isClassElement(node.parent)) { node = node.parent; } break; - case 209: + case 211: if (!includeArrowFunctions) { continue; } - case 251: - case 208: - case 256: - case 163: - case 162: + case 253: + case 210: + case 258: case 165: case 164: - case 166: case 167: + case 166: case 168: case 169: case 170: case 171: - case 255: - case 297: + case 172: + case 173: + case 257: + case 299: return node; } } @@ -11388,9 +11675,9 @@ var ts; var container = getThisContainer(node, false); if (container) { switch (container.kind) { - case 166: - case 251: - case 208: + case 168: + case 253: + case 210: return container; } } @@ -11404,25 +11691,25 @@ var ts; return node; } switch (node.kind) { - case 158: + case 160: node = node.parent; break; - case 251: - case 208: - case 209: + case 253: + case 210: + case 211: if (!stopOnFunctions) { continue; } - case 163: - case 162: case 165: case 164: - case 166: case 167: + case 166: case 168: + case 169: + case 170: return node; - case 161: - if (node.parent.kind === 160 && ts.isClassElement(node.parent.parent)) { + case 163: + if (node.parent.kind === 162 && ts.isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (ts.isClassElement(node.parent)) { @@ -11434,51 +11721,59 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 208 || func.kind === 209) { + if (func.kind === 210 || func.kind === 211) { var prev = func; var parent = func.parent; - while (parent.kind === 207) { + while (parent.kind === 209) { prev = parent; parent = parent.parent; } - if (parent.kind === 203 && parent.expression === prev) { + if (parent.kind === 205 && parent.expression === prev) { return parent; } } } ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperOrSuperProperty(node) { - return node.kind === 105 + return node.kind === 106 || isSuperProperty(node); } ts.isSuperOrSuperProperty = isSuperOrSuperProperty; function isSuperProperty(node) { var kind = node.kind; - return (kind === 201 || kind === 202) - && node.expression.kind === 105; + return (kind === 203 || kind === 204) + && node.expression.kind === 106; } ts.isSuperProperty = isSuperProperty; function isThisProperty(node) { var kind = node.kind; - return (kind === 201 || kind === 202) - && node.expression.kind === 107; + return (kind === 203 || kind === 204) + && node.expression.kind === 108; } ts.isThisProperty = isThisProperty; function isThisInitializedDeclaration(node) { var _a; - return !!node && ts.isVariableDeclaration(node) && ((_a = node.initializer) === null || _a === void 0 ? void 0 : _a.kind) === 107; + return !!node && ts.isVariableDeclaration(node) && ((_a = node.initializer) === null || _a === void 0 ? void 0 : _a.kind) === 108; } 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 + && node.parent.parent.right.kind === 108; + } + ts.isThisInitializedObjectBindingExpression = isThisInitializedObjectBindingExpression; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 173: + case 175: return node.typeName; - case 223: + case 225: return isEntityNameExpression(node.expression) ? node.expression : undefined; - case 78: - case 157: + case 79: + case 159: return node; } return undefined; @@ -11486,10 +11781,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 205: + case 207: return node.tag; - case 275: - case 274: + case 277: + case 276: return node.tagName; default: return node.expression; @@ -11501,21 +11796,21 @@ var ts; return false; } switch (node.kind) { - case 252: + case 254: return true; - case 163: - return parent.kind === 252; - case 167: - case 168: case 165: + return parent.kind === 254; + case 169: + case 170: + case 167: return node.body !== undefined - && parent.kind === 252; - case 160: + && parent.kind === 254; + case 162: return parent.body !== undefined - && (parent.kind === 166 - || parent.kind === 165 - || parent.kind === 168) - && grandparent.kind === 252; + && (parent.kind === 168 + || parent.kind === 167 + || parent.kind === 170) + && grandparent.kind === 254; } return false; } @@ -11531,10 +11826,10 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 252: + case 254: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); - case 165: - case 168: + case 167: + case 170: return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); default: return false; @@ -11543,9 +11838,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 275 || - parent.kind === 274 || - parent.kind === 276) { + if (parent.kind === 277 || + parent.kind === 276 || + parent.kind === 278) { return parent.tagName === node; } return false; @@ -11553,56 +11848,61 @@ var ts; ts.isJSXTagName = isJSXTagName; function isExpressionNode(node) { switch (node.kind) { - case 105: - case 103: - case 109: - case 94: + case 106: + case 104: + case 110: + case 95: case 13: - case 199: - case 200: case 201: case 202: case 203: case 204: case 205: - case 224: case 206: - case 225: case 207: + case 226: case 208: - case 221: + case 227: case 209: - case 212: case 210: + case 223: case 211: case 214: - case 215: + case 212: + case 213: case 216: case 217: - case 220: case 218: - case 222: - case 273: - case 274: - case 277: case 219: - case 213: - case 226: + case 222: + case 220: + case 224: + case 275: + case 276: + case 279: + case 221: + case 215: + case 228: return true; - case 157: - while (node.parent.kind === 157) { + case 159: + while (node.parent.kind === 159) { node = node.parent; } - return node.parent.kind === 176 || isJSXTagName(node); - case 78: - if (node.parent.kind === 176 || isJSXTagName(node)) { + return node.parent.kind === 178 || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); + case 305: + while (ts.isJSDocMemberName(node.parent)) { + node = node.parent; + } + return node.parent.kind === 178 || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); + case 79: + if (node.parent.kind === 178 || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node)) { return true; } case 8: case 9: case 10: case 14: - case 107: + case 108: return isInExpressionContext(node); default: return false; @@ -11612,49 +11912,49 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 249: - case 160: - case 163: + case 251: case 162: - case 291: - case 288: - case 198: + case 165: + case 164: + case 293: + case 290: + case 200: return parent.initializer === node; - case 233: - case 234: case 235: case 236: - case 242: - case 243: + case 237: + case 238: case 244: - case 284: + case 245: case 246: + case 286: + case 248: return parent.expression === node; - case 237: + case 239: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 250) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 252) || forStatement.condition === node || forStatement.incrementor === node; - case 238: - case 239: + case 240: + case 241: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 250) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 252) || forInStatement.expression === node; - case 206: - case 224: + case 208: + case 226: return node === parent.expression; - case 228: + case 230: return node === parent.expression; - case 158: + case 160: return node === parent.expression; - case 161: - case 283: - case 282: - case 290: + case 163: + case 285: + case 284: + case 292: return true; - case 223: + case 225: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 289: + case 291: return parent.objectAssignmentInitializer === node; default: return isExpressionNode(parent); @@ -11662,14 +11962,18 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isPartOfTypeQuery(node) { - while (node.kind === 157 || node.kind === 78) { + while (node.kind === 159 || node.kind === 79) { node = node.parent; } - return node.kind === 176; + return node.kind === 178; } ts.isPartOfTypeQuery = isPartOfTypeQuery; + function isNamespaceReexportDeclaration(node) { + return ts.isNamespaceExport(node) && !!node.parent.moduleSpecifier; + } + ts.isNamespaceReexportDeclaration = isNamespaceReexportDeclaration; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 260 && node.moduleReference.kind === 272; + return node.kind === 262 && node.moduleReference.kind === 274; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -11678,12 +11982,11 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function getExternalModuleRequireArgument(node) { - return isRequireVariableDeclaration(node, true) - && getLeftmostAccessExpression(node.initializer).arguments[0]; + return isRequireVariableDeclaration(node) && getLeftmostAccessExpression(node.initializer).arguments[0]; } ts.getExternalModuleRequireArgument = getExternalModuleRequireArgument; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 260 && node.moduleReference.kind !== 272; + return node.kind === 262 && node.moduleReference.kind !== 274; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJS(file) { @@ -11715,15 +12018,15 @@ var ts; ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && node.typeArguments && node.typeArguments.length === 2 && - (node.typeArguments[0].kind === 147 || node.typeArguments[0].kind === 144); + (node.typeArguments[0].kind === 148 || node.typeArguments[0].kind === 145); } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, requireStringLiteralLikeArgument) { - if (callExpression.kind !== 203) { + if (callExpression.kind !== 205) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; - if (expression.kind !== 78 || expression.escapedText !== "require") { + if (expression.kind !== 79 || expression.escapedText !== "require") { return false; } if (args.length !== 1) { @@ -11733,18 +12036,17 @@ var ts; return !requireStringLiteralLikeArgument || ts.isStringLiteralLike(arg); } ts.isRequireCall = isRequireCall; - function isRequireVariableDeclaration(node, requireStringLiteralLikeArgument) { - if (node.kind === 198) { + function isRequireVariableDeclaration(node) { + if (node.kind === 200) { node = node.parent.parent; } - return ts.isVariableDeclaration(node) && !!node.initializer && isRequireCall(getLeftmostAccessExpression(node.initializer), requireStringLiteralLikeArgument); + return ts.isVariableDeclaration(node) && !!node.initializer && isRequireCall(getLeftmostAccessExpression(node.initializer), true); } ts.isRequireVariableDeclaration = isRequireVariableDeclaration; - function isRequireVariableStatement(node, requireStringLiteralLikeArgument) { - if (requireStringLiteralLikeArgument === void 0) { requireStringLiteralLikeArgument = true; } + function isRequireVariableStatement(node) { return ts.isVariableStatement(node) && node.declarationList.declarations.length > 0 - && ts.every(node.declarationList.declarations, function (decl) { return isRequireVariableDeclaration(decl, requireStringLiteralLikeArgument); }); + && ts.every(node.declarationList.declarations, function (decl) { return isRequireVariableDeclaration(decl); }); } ts.isRequireVariableStatement = isRequireVariableStatement; function isSingleOrDoubleQuote(charCode) { @@ -11784,7 +12086,7 @@ var ts; }); } function getAssignedExpandoInitializer(node) { - if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62) { + if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63) { var isPrototypeAssignment = isPrototypeAccess(node.parent.left); return getExpandoInitializer(node.parent.right, isPrototypeAssignment) || getDefaultedExpandoInitializer(node.parent.left, node.parent.right, isPrototypeAssignment); @@ -11800,11 +12102,11 @@ var ts; function getExpandoInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 208 || e.kind === 209 ? initializer : undefined; + return e.kind === 210 || e.kind === 211 ? initializer : undefined; } - if (initializer.kind === 208 || - initializer.kind === 221 || - initializer.kind === 209) { + if (initializer.kind === 210 || + initializer.kind === 223 || + initializer.kind === 211) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -11822,7 +12124,7 @@ var ts; } function isDefaultedExpandoInitializer(node) { var name = ts.isVariableDeclaration(node.parent) ? node.parent.name : - ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 ? node.parent.left : + ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 ? node.parent.left : undefined; return name && getExpandoInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left); } @@ -11830,7 +12132,7 @@ var ts; function getNameOfExpando(node) { if (ts.isBinaryExpression(node.parent)) { var parent = ((node.parent.operatorToken.kind === 56 || node.parent.operatorToken.kind === 60) && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; - if (parent.operatorToken.kind === 62 && ts.isIdentifier(parent.left)) { + if (parent.operatorToken.kind === 63 && ts.isIdentifier(parent.left)) { return parent.left; } } @@ -11844,7 +12146,7 @@ var ts; return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(initializer); } if (ts.isIdentifier(name) && isLiteralLikeAccess(initializer) && - (initializer.expression.kind === 107 || + (initializer.expression.kind === 108 || ts.isIdentifier(initializer.expression) && (initializer.expression.escapedText === "window" || initializer.expression.escapedText === "self" || @@ -11903,18 +12205,17 @@ var ts; } ts.isLiteralLikeAccess = isLiteralLikeAccess; function isLiteralLikeElementAccess(node) { - return ts.isElementAccessExpression(node) && (isStringOrNumericLiteralLike(node.argumentExpression) || - isWellKnownSymbolSyntactically(node.argumentExpression)); + return ts.isElementAccessExpression(node) && isStringOrNumericLiteralLike(node.argumentExpression); } ts.isLiteralLikeElementAccess = isLiteralLikeElementAccess; function isBindableStaticAccessExpression(node, excludeThisKeyword) { - return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 107 || ts.isIdentifier(node.name) && isBindableStaticNameExpression(node.expression, true)) + return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 108 || ts.isIdentifier(node.name) && isBindableStaticNameExpression(node.expression, true)) || isBindableStaticElementAccessExpression(node, excludeThisKeyword); } ts.isBindableStaticAccessExpression = isBindableStaticAccessExpression; function isBindableStaticElementAccessExpression(node, excludeThisKeyword) { return isLiteralLikeElementAccess(node) - && ((!excludeThisKeyword && node.expression.kind === 107) || + && ((!excludeThisKeyword && node.expression.kind === 108) || isEntityNameExpression(node.expression) || isBindableStaticAccessExpression(node.expression, true)); } @@ -11944,7 +12245,7 @@ var ts; } return 7; } - if (expr.operatorToken.kind !== 62 || !isAccessExpression(expr.left) || isVoidZero(getRightMostAssignedExpression(expr))) { + if (expr.operatorToken.kind !== 63 || !isAccessExpression(expr.left) || isVoidZero(getRightMostAssignedExpression(expr))) { return 0; } if (isBindableStaticNameExpression(expr.left.expression, true) && getElementOrPropertyAccessName(expr.left) === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { @@ -11976,14 +12277,11 @@ var ts; return ts.escapeLeadingUnderscores(name.text); } } - if (ts.isElementAccessExpression(node) && isWellKnownSymbolSyntactically(node.argumentExpression)) { - return getPropertyNameForKnownSymbolName(ts.idText(node.argumentExpression.name)); - } return undefined; } ts.getElementOrPropertyAccessName = getElementOrPropertyAccessName; function getAssignmentDeclarationPropertyAccessKind(lhs) { - if (lhs.expression.kind === 107) { + if (lhs.expression.kind === 108) { return 4; } else if (isModuleExportsAccessExpression(lhs)) { @@ -12023,7 +12321,7 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJSFile(expr) && - expr.parent && expr.parent.kind === 233 && + expr.parent && expr.parent.kind === 235 && (!ts.isElementAccessExpression(expr) || isLiteralLikeElementAccess(expr)) && !!ts.getJSDocTypeTag(expr.parent); } @@ -12043,23 +12341,37 @@ var ts; return false; } var decl = symbol.valueDeclaration; - return decl.kind === 251 || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); + return decl.kind === 253 || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); } ts.isFunctionSymbol = isFunctionSymbol; + function tryGetModuleSpecifierFromDeclaration(node) { + var _a, _b, _c; + switch (node.kind) { + case 251: + return node.initializer.arguments[0].text; + case 263: + return (_a = ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike)) === null || _a === void 0 ? void 0 : _a.text; + case 262: + return (_c = ts.tryCast((_b = ts.tryCast(node.moduleReference, ts.isExternalModuleReference)) === null || _b === void 0 ? void 0 : _b.expression, ts.isStringLiteralLike)) === null || _c === void 0 ? void 0 : _c.text; + default: + ts.Debug.assertNever(node); + } + } + ts.tryGetModuleSpecifierFromDeclaration = tryGetModuleSpecifierFromDeclaration; function importFromModuleSpecifier(node) { return tryGetImportFromModuleSpecifier(node) || ts.Debug.failBadSyntaxKind(node.parent); } ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 261: - case 267: + case 263: + case 269: return node.parent; - case 272: + case 274: return node.parent.parent; - case 203: + case 205: return isImportCall(node.parent) || isRequireCall(node.parent, false) ? node.parent : undefined; - case 191: + case 193: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -12069,15 +12381,17 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 261: - case 267: + case 263: + case 269: return node.moduleSpecifier; - case 260: - return node.moduleReference.kind === 272 ? node.moduleReference.expression : undefined; - case 195: + case 262: + return node.moduleReference.kind === 274 ? node.moduleReference.expression : undefined; + case 197: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; - case 203: + case 205: return node.arguments[0]; + case 258: + return node.name.kind === 10 ? node.name : undefined; default: return ts.Debug.assertNever(node); } @@ -12085,11 +12399,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 261: + case 263: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 260: + case 262: return node; - case 267: + case 269: return node.exportClause && ts.tryCast(node.exportClause, ts.isNamespaceExport); default: return ts.Debug.assertNever(node); @@ -12097,7 +12411,7 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 261 && !!node.importClause && !!node.importClause.name; + return node.kind === 263 && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function forEachImportClauseDeclaration(node, action) { @@ -12118,13 +12432,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 160: + case 162: + case 167: + case 166: + case 291: + case 290: case 165: case 164: - case 289: - case 288: - case 163: - case 162: return node.questionToken !== undefined; } } @@ -12138,7 +12452,7 @@ var ts; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 331 || node.kind === 324 || node.kind === 325; + return node.kind === 339 || node.kind === 332 || node.kind === 333; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -12148,7 +12462,7 @@ var ts; function getSourceOfAssignment(node) { return ts.isExpressionStatement(node) && ts.isBinaryExpression(node.expression) && - node.expression.operatorToken.kind === 62 + node.expression.operatorToken.kind === 63 ? getRightMostAssignedExpression(node.expression) : undefined; } @@ -12163,12 +12477,12 @@ var ts; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 232: + case 234: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 163: + case 165: return node.initializer; - case 288: + case 290: return node.initializer; } } @@ -12180,7 +12494,7 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 256 + node.body.kind === 258 ? node.body : undefined; } @@ -12194,11 +12508,11 @@ var ts; if (ts.hasJSDocNodes(node)) { result = ts.append(result, ts.last(node.jsDoc)); } - if (node.kind === 160) { + if (node.kind === 162) { result = ts.addRange(result, (noCache ? ts.getJSDocParameterTagsNoCache : ts.getJSDocParameterTags)(node)); break; } - if (node.kind === 159) { + if (node.kind === 161) { result = ts.addRange(result, (noCache ? ts.getJSDocTypeParameterTagsNoCache : ts.getJSDocTypeParameterTags)(node)); break; } @@ -12209,17 +12523,18 @@ var ts; ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; function getNextJSDocCommentLocation(node) { var parent = node.parent; - if (parent.kind === 288 || - parent.kind === 266 || - parent.kind === 163 || - parent.kind === 233 && node.kind === 201 || + if (parent.kind === 290 || + parent.kind === 268 || + parent.kind === 165 || + parent.kind === 235 && node.kind === 203 || + parent.kind === 244 || getNestedModuleDeclaration(parent) || - ts.isBinaryExpression(node) && node.operatorToken.kind === 62) { + ts.isBinaryExpression(node) && node.operatorToken.kind === 63) { return parent; } else if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node || - ts.isBinaryExpression(parent) && parent.operatorToken.kind === 62)) { + ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63)) { return parent.parent; } else if (parent.parent && parent.parent.parent && @@ -12242,7 +12557,7 @@ var ts; if (!decl) { return undefined; } - var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 78 && p.name.escapedText === name; }); + var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 79 && p.name.escapedText === name; }); return parameter && parameter.symbol; } ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc; @@ -12291,7 +12606,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 === 309; + return node.dotDotDotToken !== undefined || !!type && type.kind === 312; } ts.isRestParameter = isRestParameter; function hasTypeArguments(node) { @@ -12302,31 +12617,34 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 216: + case 218: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 62 || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 : 2 : + binaryOperator === 63 || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 : 2 : 0; - case 214: - case 215: + case 216: + case 217: var unaryOperator = parent.operator; return unaryOperator === 45 || unaryOperator === 46 ? 2 : 0; - case 238: - case 239: + case 240: + case 241: return parent.initializer === node ? 1 : 0; - case 207: - case 199: - case 220: - case 225: + case 209: + case 201: + case 222: + case 227: node = parent; break; - case 289: + case 292: + node = parent.parent; + break; + case 291: if (parent.name !== node) { return 0; } node = parent.parent; break; - case 288: + case 290: if (parent.name === node) { return 0; } @@ -12345,22 +12663,22 @@ var ts; ts.isAssignmentTarget = isAssignmentTarget; function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 230: case 232: - case 243: case 234: - case 244: - case 258: - case 284: - case 285: case 245: - case 237: - case 238: - case 239: - case 235: case 236: - case 247: + case 246: + case 260: + case 286: case 287: + case 247: + case 239: + case 240: + case 241: + case 237: + case 238: + case 249: + case 289: return true; } return false; @@ -12377,16 +12695,16 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 186); + return walkUp(node, 188); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 207); + return walkUp(node, 209); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; function walkUpParenthesizedTypesAndGetParentAndChild(node) { var child; - while (node && node.kind === 186) { + while (node && node.kind === 188) { child = node; node = node.parent; } @@ -12397,18 +12715,12 @@ var ts; return ts.skipOuterExpressions(node, 1); } ts.skipParentheses = skipParentheses; - function skipParenthesesUp(node) { - while (node.kind === 207) { - node = node.parent; - } - return node; - } function isDeleteTarget(node) { - if (node.kind !== 201 && node.kind !== 202) { + if (node.kind !== 203 && node.kind !== 204) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 210; + return node && node.kind === 212; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -12432,7 +12744,7 @@ var ts; case 8: if (ts.isComputedPropertyName(parent)) return parent.parent; - case 78: + case 79: if (ts.isDeclaration(parent)) { return parent.name === name ? parent : undefined; } @@ -12449,7 +12761,7 @@ var ts; ? binExp : undefined; } - case 79: + case 80: return ts.isDeclaration(parent) && parent.name === name ? parent : undefined; default: return undefined; @@ -12458,63 +12770,63 @@ var ts; ts.getDeclarationFromName = getDeclarationFromName; function isLiteralComputedPropertyDeclarationName(node) { return isStringOrNumericLiteralLike(node) && - node.parent.kind === 158 && + node.parent.kind === 160 && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 163: - case 162: case 165: case 164: case 167: - case 168: - case 291: - case 288: - case 201: + case 166: + case 169: + case 170: + case 293: + case 290: + case 203: return parent.name === node; - case 157: + case 159: return parent.right === node; - case 198: - case 265: + case 200: + case 267: return parent.propertyName === node; - case 270: - case 280: + case 272: + case 282: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 260 || - node.kind === 259 || - node.kind === 262 && !!node.name || - node.kind === 263 || - node.kind === 269 || + return node.kind === 262 || + node.kind === 261 || + node.kind === 264 && !!node.name || node.kind === 265 || - node.kind === 270 || - node.kind === 266 && exportAssignmentIsAlias(node) || + node.kind === 271 || + node.kind === 267 || + node.kind === 272 || + node.kind === 268 && exportAssignmentIsAlias(node) || ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 && exportAssignmentIsAlias(node) || - ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62 && isAliasableExpression(node.parent.right) || - node.kind === 289 || - node.kind === 288 && isAliasableExpression(node.initializer); + ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 && isAliasableExpression(node.parent.right) || + node.kind === 291 || + node.kind === 290 && isAliasableExpression(node.initializer); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getAliasDeclarationFromName(node) { switch (node.parent.kind) { - case 262: + case 264: + case 267: case 265: - case 263: - case 270: - case 266: - case 260: + case 272: + case 268: + case 262: return node.parent; - case 157: + case 159: do { node = node.parent; - } while (node.parent.kind === 157); + } while (node.parent.kind === 159); return getAliasDeclarationFromName(node); } } @@ -12533,7 +12845,7 @@ var ts; } ts.getExportAssignmentExpression = getExportAssignmentExpression; function getPropertyAssignmentAliasLikeExpression(node) { - return node.kind === 289 ? node.name : node.kind === 288 ? node.initializer : + return node.kind === 291 ? node.name : node.kind === 290 ? node.initializer : node.parent.right; } ts.getPropertyAssignmentAliasLikeExpression = getPropertyAssignmentAliasLikeExpression; @@ -12549,7 +12861,7 @@ var ts; } ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode; function getClassExtendsHeritageElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 93); + var heritageClause = getHeritageClause(node.heritageClauses, 94); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement; @@ -12558,7 +12870,7 @@ var ts; return ts.getJSDocImplementsTags(node).map(function (n) { return n.class; }); } else { - var heritageClause = getHeritageClause(node.heritageClauses, 116); + var heritageClause = getHeritageClause(node.heritageClauses, 117); return heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.types; } } @@ -12570,7 +12882,7 @@ var ts; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 93); + var heritageClause = getHeritageClause(node.heritageClauses, 94); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -12597,11 +12909,11 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 80 <= token && token <= 156; + return 81 <= token && token <= 158; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 125 <= token && token <= 156; + return 126 <= token && token <= 158; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { @@ -12609,7 +12921,7 @@ var ts; } ts.isNonContextualKeyword = isNonContextualKeyword; function isFutureReservedKeyword(token) { - return 116 <= token && token <= 124; + return 117 <= token && token <= 125; } ts.isFutureReservedKeyword = isFutureReservedKeyword; function isStringANonContextualKeyword(name) { @@ -12637,13 +12949,13 @@ var ts; } var flags = 0; switch (node.kind) { - case 251: - case 208: - case 165: + case 253: + case 210: + case 167: if (node.asteriskToken) { flags |= 1; } - case 209: + case 211: if (hasSyntacticModifier(node, 256)) { flags |= 2; } @@ -12657,10 +12969,10 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 251: - case 208: - case 209: - case 165: + case 253: + case 210: + case 211: + case 167: return node.body !== undefined && node.asteriskToken === undefined && hasSyntacticModifier(node, 256); @@ -12682,33 +12994,25 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - if (!(name.kind === 158 || name.kind === 202)) { + if (!(name.kind === 160 || name.kind === 204)) { return false; } var expr = ts.isElementAccessExpression(name) ? skipParentheses(name.argumentExpression) : name.expression; return !isStringOrNumericLiteralLike(expr) && - !isSignedNumericLiteral(expr) && - !isWellKnownSymbolSyntactically(expr); + !isSignedNumericLiteral(expr); } ts.isDynamicName = isDynamicName; - function isWellKnownSymbolSyntactically(node) { - return ts.isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression); - } - ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { switch (name.kind) { - case 78: case 79: + case 80: return name.escapedText; case 10: case 8: return ts.escapeLeadingUnderscores(name.text); - case 158: + case 160: var nameExpression = name.expression; - if (isWellKnownSymbolSyntactically(nameExpression)) { - return getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); - } - else if (isStringOrNumericLiteralLike(nameExpression)) { + if (isStringOrNumericLiteralLike(nameExpression)) { return ts.escapeLeadingUnderscores(nameExpression.text); } else if (isSignedNumericLiteral(nameExpression)) { @@ -12725,7 +13029,7 @@ var ts; ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; function isPropertyNameLiteral(node) { switch (node.kind) { - case 78: + case 79: case 10: case 14: case 8: @@ -12736,21 +13040,17 @@ var ts; } ts.isPropertyNameLiteral = isPropertyNameLiteral; function getTextOfIdentifierOrLiteral(node) { - return ts.isIdentifierOrPrivateIdentifier(node) ? ts.idText(node) : node.text; + return ts.isMemberName(node) ? ts.idText(node) : node.text; } ts.getTextOfIdentifierOrLiteral = getTextOfIdentifierOrLiteral; function getEscapedTextOfIdentifierOrLiteral(node) { - return ts.isIdentifierOrPrivateIdentifier(node) ? node.escapedText : ts.escapeLeadingUnderscores(node.text); + return ts.isMemberName(node) ? node.escapedText : ts.escapeLeadingUnderscores(node.text); } ts.getEscapedTextOfIdentifierOrLiteral = getEscapedTextOfIdentifierOrLiteral; function getPropertyNameForUniqueESSymbol(symbol) { return "__@" + ts.getSymbolId(symbol) + "@" + symbol.escapedName; } ts.getPropertyNameForUniqueESSymbol = getPropertyNameForUniqueESSymbol; - function getPropertyNameForKnownSymbolName(symbolName) { - return "__@" + symbolName; - } - ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; function getSymbolNameForPrivateIdentifier(containingClassSymbol, description) { return "__#" + ts.getSymbolId(containingClassSymbol) + "@" + description; } @@ -12760,7 +13060,7 @@ var ts; } ts.isKnownSymbol = isKnownSymbol; function isESSymbolIdentifier(node) { - return node.kind === 78 && node.escapedText === "Symbol"; + return node.kind === 79 && node.escapedText === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isPushOrUnshiftIdentifier(node) { @@ -12769,11 +13069,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 160; + return root.kind === 162; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 198) { + while (node.kind === 200) { node = node.parent.parent; } return node; @@ -12781,15 +13081,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 166 - || kind === 208 - || kind === 251 - || kind === 209 - || kind === 165 + return kind === 168 + || kind === 210 + || kind === 253 + || kind === 211 || kind === 167 - || kind === 168 - || kind === 256 - || kind === 297; + || kind === 169 + || kind === 170 + || kind === 258 + || kind === 299; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -12803,41 +13103,41 @@ var ts; ts.getOriginalSourceFile = getOriginalSourceFile; function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 204 && expression.arguments !== undefined; + var hasArguments = expression.kind === 206 && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 204: + case 206: return hasArguments ? 0 : 1; + case 216: + case 213: case 214: - case 211: case 212: - case 210: - case 213: - case 217: + case 215: case 219: + case 221: return 1; - case 216: + case 218: switch (operator) { case 42: - case 62: case 63: case 64: - case 66: case 65: case 67: + case 66: case 68: case 69: case 70: case 71: case 72: - case 77: case 73: + case 78: case 74: case 75: case 76: + case 77: return 1; } } @@ -12846,15 +13146,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 204 && expression.arguments !== undefined; + var hasArguments = expression.kind === 206 && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 216) { + if (expression.kind === 218) { return expression.operatorToken.kind; } - else if (expression.kind === 214 || expression.kind === 215) { + else if (expression.kind === 216 || expression.kind === 217) { return expression.operator; } else { @@ -12864,80 +13164,81 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 337: + case 345: return 0; - case 220: + case 222: return 1; - case 219: + case 221: return 2; - case 217: + case 219: return 4; - case 216: + case 218: switch (operatorKind) { case 27: return 0; - case 62: case 63: case 64: - case 66: case 65: case 67: + case 66: case 68: case 69: case 70: case 71: case 72: - case 77: case 73: + case 78: case 74: case 75: case 76: + case 77: return 3; default: return getBinaryOperatorPrecedence(operatorKind); } - case 206: - case 225: + case 208: + case 227: + case 216: + case 213: case 214: - case 211: case 212: - case 210: - case 213: - return 16; case 215: + return 16; + case 217: return 17; - case 203: + case 205: return 18; - case 204: + case 206: return hasArguments ? 19 : 18; - case 205: - case 201: - case 202: + case 207: + case 203: + case 204: + case 228: return 19; - case 224: + case 226: return 11; - case 107: - case 105: - case 78: - case 103: - case 109: - case 94: + case 108: + case 106: + case 79: + case 104: + case 110: + case 95: case 8: case 9: case 10: - case 199: - case 200: - case 208: - case 209: - case 221: + case 201: + case 202: + case 210: + case 211: + case 223: case 13: case 14: - case 218: - case 207: - case 222: - case 273: - case 274: - case 277: + case 220: + case 209: + case 224: + case 275: + case 276: + case 279: return 20; default: return -1; @@ -12967,9 +13268,9 @@ var ts; case 31: case 32: case 33: + case 102: case 101: - case 100: - case 126: + case 127: return 11; case 47: case 48: @@ -12991,7 +13292,7 @@ var ts; function getSemanticJsxChildren(children) { return ts.filter(children, function (i) { switch (i.kind) { - case 283: + case 285: return !!i.expression; case 11: return !i.containsOnlyTriviaWhiteSpaces; @@ -13266,7 +13567,7 @@ var ts; reportInaccessibleThisError: ts.noop, reportPrivateInBaseOfClassExpression: ts.noop, reportInaccessibleUniqueSymbolError: ts.noop, - trackSymbol: ts.noop, + trackSymbol: function () { return false; }, writeKeyword: write, writeOperator: write, writeParameter: write, @@ -13358,11 +13659,19 @@ var ts; return file.moduleName || getExternalModuleNameFromPath(host, file.fileName, referenceFile && referenceFile.fileName); } ts.getResolvedExternalModuleName = getResolvedExternalModuleName; + function getCanonicalAbsolutePath(host, path) { + return host.getCanonicalFileName(ts.getNormalizedAbsolutePath(path, host.getCurrentDirectory())); + } function getExternalModuleNameFromDeclaration(host, resolver, declaration) { var file = resolver.getExternalModuleFileFromDeclaration(declaration); if (!file || file.isDeclarationFile) { return undefined; } + var specifier = getExternalModuleName(declaration); + if (specifier && ts.isStringLiteralLike(specifier) && !ts.pathIsRelative(specifier.text) && + getCanonicalAbsolutePath(host, file.path).indexOf(getCanonicalAbsolutePath(host, ts.ensureTrailingDirectorySeparator(host.getCommonSourceDirectory()))) === -1) { + return undefined; + } return getResolvedExternalModuleName(host, file); } ts.getExternalModuleNameFromDeclaration = getExternalModuleNameFromDeclaration; @@ -13431,8 +13740,8 @@ var ts; return !(options.noEmitForJsFiles && isSourceFileJS(sourceFile)) && !sourceFile.isDeclarationFile && !host.isSourceFileFromExternalLibrary(sourceFile) && - !(isJsonSourceFile(sourceFile) && host.getResolvedProjectReferenceToRedirect(sourceFile.fileName)) && - (forceDtsEmit || !host.isSourceOfProjectReferenceRedirect(sourceFile.fileName)); + (forceDtsEmit || (!(isJsonSourceFile(sourceFile) && host.getResolvedProjectReferenceToRedirect(sourceFile.fileName)) && + !host.isSourceOfProjectReferenceRedirect(sourceFile.fileName))); } ts.sourceFileMayBeEmitted = sourceFileMayBeEmitted; function getSourceFilePathInNewDir(fileName, host, newDirPath) { @@ -13508,11 +13817,11 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return !!node && node.kind === 78 && identifierIsThisKeyword(node); + return !!node && node.kind === 79 && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 107; + return id.originalKeywordKind === 108; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -13522,10 +13831,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 167) { + if (accessor.kind === 169) { getAccessor = accessor; } - else if (accessor.kind === 168) { + else if (accessor.kind === 170) { setAccessor = accessor; } else { @@ -13545,10 +13854,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 167 && !getAccessor) { + if (member.kind === 169 && !getAccessor) { getAccessor = member; } - if (member.kind === 168 && !setAccessor) { + if (member.kind === 170 && !setAccessor) { setAccessor = member; } } @@ -13587,7 +13896,7 @@ var ts; } ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations; function isNonTypeAliasTemplate(tag) { - return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 311 && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 314 && tag.parent.tags.some(isJSDocTypeAlias)); } function getEffectiveSetAccessorTypeAnnotationNode(node) { var parameter = getSetAccessorValueParameter(node); @@ -13719,7 +14028,7 @@ var ts; ts.writeCommentRange = writeCommentRange; function writeTrimmedCurrentLine(text, commentEnd, writer, newLine, pos, nextLineStart) { var end = Math.min(commentEnd, nextLineStart - 1); - var currentLineText = text.substring(pos, end).replace(/^\s+|\s+$/g, ""); + var currentLineText = ts.trimString(text.substring(pos, end)); if (currentLineText) { writer.writeComment(currentLineText); if (end !== commentEnd) { @@ -13762,6 +14071,18 @@ var ts; return hasSyntacticModifier(node, 32); } ts.hasStaticModifier = hasStaticModifier; + function hasOverrideModifier(node) { + return hasEffectiveModifier(node, 16384); + } + ts.hasOverrideModifier = hasOverrideModifier; + function hasAbstractModifier(node) { + return hasSyntacticModifier(node, 128); + } + ts.hasAbstractModifier = hasAbstractModifier; + function hasAmbientModifier(node) { + return hasSyntacticModifier(node, 2); + } + ts.hasAmbientModifier = hasAmbientModifier; function hasEffectiveReadonlyModifier(node) { return hasEffectiveModifier(node, 64); } @@ -13775,7 +14096,7 @@ var ts; } ts.getSelectedSyntacticModifierFlags = getSelectedSyntacticModifierFlags; function getModifierFlagsWorker(node, includeJSDoc, alwaysIncludeJSDoc) { - if (node.kind >= 0 && node.kind <= 156) { + if (node.kind >= 0 && node.kind <= 158) { return 0; } if (!(node.modifierFlagsCache & 536870912)) { @@ -13810,6 +14131,8 @@ var ts; flags |= 16; if (ts.getJSDocReadonlyTagNoCache(node)) flags |= 64; + if (ts.getJSDocOverrideTagNoCache(node)) + flags |= 16384; } if (ts.getJSDocDeprecatedTagNoCache(node)) flags |= 8192; @@ -13822,7 +14145,7 @@ var ts; ts.getEffectiveModifierFlagsNoCache = getEffectiveModifierFlagsNoCache; function getSyntacticModifierFlagsNoCache(node) { var flags = modifiersToFlags(node.modifiers); - if (node.flags & 4 || (node.kind === 78 && node.isInJSDocNamespace)) { + if (node.flags & 4 || (node.kind === 79 && node.isInJSDocNamespace)) { flags |= 1; } return flags; @@ -13841,21 +14164,26 @@ var ts; ts.modifiersToFlags = modifiersToFlags; function modifierToFlag(token) { switch (token) { - case 123: return 32; - case 122: return 4; - case 121: return 16; - case 120: return 8; - case 125: return 128; - case 92: return 1; - case 133: return 2; - case 84: return 2048; - case 87: return 512; - case 129: return 256; - case 142: return 64; + case 124: return 32; + case 123: return 4; + case 122: return 16; + case 121: return 8; + case 126: return 128; + case 93: return 1; + case 134: return 2; + case 85: return 2048; + case 88: return 512; + case 130: return 256; + case 143: return 64; + case 157: return 16384; } return 0; } ts.modifierToFlag = modifierToFlag; + function createModifiers(modifierFlags) { + return modifierFlags ? ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(modifierFlags)) : undefined; + } + ts.createModifiers = createModifiers; function isLogicalOperator(token) { return token === 56 || token === 55 @@ -13863,9 +14191,9 @@ var ts; } ts.isLogicalOperator = isLogicalOperator; function isLogicalOrCoalescingAssignmentOperator(token) { - return token === 74 - || token === 75 - || token === 76; + return token === 75 + || token === 76 + || token === 77; } ts.isLogicalOrCoalescingAssignmentOperator = isLogicalOrCoalescingAssignmentOperator; function isLogicalOrCoalescingAssignmentExpression(expr) { @@ -13873,7 +14201,7 @@ var ts; } ts.isLogicalOrCoalescingAssignmentExpression = isLogicalOrCoalescingAssignmentExpression; function isAssignmentOperator(token) { - return token >= 62 && token <= 77; + return token >= 63 && token <= 78; } ts.isAssignmentOperator = isAssignmentOperator; function tryGetClassExtendingExpressionWithTypeArguments(node) { @@ -13885,23 +14213,27 @@ var ts; return ts.isExpressionWithTypeArguments(node) && ts.isHeritageClause(node.parent) && ts.isClassLike(node.parent.parent) - ? { class: node.parent.parent, isImplements: node.parent.token === 116 } + ? { class: node.parent.parent, isImplements: node.parent.token === 117 } : undefined; } ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments = tryGetClassImplementingOrExtendingExpressionWithTypeArguments; function isAssignmentExpression(node, excludeCompoundAssignment) { return ts.isBinaryExpression(node) && (excludeCompoundAssignment - ? node.operatorToken.kind === 62 + ? node.operatorToken.kind === 63 : isAssignmentOperator(node.operatorToken.kind)) && ts.isLeftHandSideExpression(node.left); } ts.isAssignmentExpression = isAssignmentExpression; + function isLeftHandSideOfAssignment(node) { + return isAssignmentExpression(node.parent) && node.parent.left === node; + } + ts.isLeftHandSideOfAssignment = isLeftHandSideOfAssignment; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, true)) { var kind = node.left.kind; - return kind === 200 - || kind === 199; + return kind === 202 + || kind === 201; } return false; } @@ -13911,30 +14243,33 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { - return node.kind === 78 || isPropertyAccessEntityNameExpression(node); + return node.kind === 79 || isPropertyAccessEntityNameExpression(node); } ts.isEntityNameExpression = isEntityNameExpression; function getFirstIdentifier(node) { switch (node.kind) { - case 78: + case 79: return node; - case 157: + case 159: do { node = node.left; - } while (node.kind !== 78); + } while (node.kind !== 79); return node; - case 201: + case 203: do { node = node.expression; - } while (node.kind !== 78); + } while (node.kind !== 79); return node; } } ts.getFirstIdentifier = getFirstIdentifier; function isDottedName(node) { - return node.kind === 78 || node.kind === 107 || node.kind === 105 || - node.kind === 201 && isDottedName(node.expression) || - node.kind === 207 && isDottedName(node.expression); + return node.kind === 79 + || node.kind === 108 + || node.kind === 106 + || node.kind === 228 + || node.kind === 203 && isDottedName(node.expression) + || node.kind === 209 && isDottedName(node.expression); } ts.isDottedName = isDottedName; function isPropertyAccessEntityNameExpression(node) { @@ -13948,6 +14283,12 @@ var ts; return baseStr + "." + entityNameToString(expr.name); } } + else if (ts.isElementAccessExpression(expr)) { + var baseStr = tryGetPropertyAccessOrIdentifierToString(expr.expression); + if (baseStr !== undefined && ts.isPropertyName(expr.argumentExpression)) { + return baseStr + "." + getPropertyNameForPropertyNameNode(expr.argumentExpression); + } + } else if (ts.isIdentifier(expr)) { return ts.unescapeLeadingUnderscores(expr.escapedText); } @@ -13959,22 +14300,28 @@ var ts; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 157 && node.parent.right === node) || - (node.parent.kind === 201 && node.parent.name === node); + return (node.parent.kind === 159 && node.parent.right === node) || + (node.parent.kind === 203 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; + function isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName(node) { + return ts.isQualifiedName(node.parent) && node.parent.right === node + || ts.isPropertyAccessExpression(node.parent) && node.parent.name === node + || ts.isJSDocMemberName(node.parent) && node.parent.right === node; + } + ts.isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName = isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName; function isEmptyObjectLiteral(expression) { - return expression.kind === 200 && + return expression.kind === 202 && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 199 && + return expression.kind === 201 && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; function getLocalSymbolForExportDefault(symbol) { - if (!isExportDefaultSymbol(symbol)) + if (!isExportDefaultSymbol(symbol) || !symbol.declarations) return undefined; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; @@ -14241,8 +14588,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 255: - case 256: + case 257: + case 258: return parseNode === parseNode.parent.name; } } @@ -14268,9 +14615,11 @@ var ts; return symbol.flags & 33554432 ? symbol.checkFlags : 0; } ts.getCheckFlags = getCheckFlags; - function getDeclarationModifierFlagsFromSymbol(s) { + function getDeclarationModifierFlagsFromSymbol(s, isWrite) { + if (isWrite === void 0) { isWrite = false; } if (s.valueDeclaration) { - var flags = ts.getCombinedModifierFlags(s.valueDeclaration); + var declaration = (isWrite && s.declarations && ts.find(s.declarations, function (d) { return d.kind === 170; })) || s.valueDeclaration; + var flags = ts.getCombinedModifierFlags(declaration); return s.parent && s.parent.flags & 32 ? flags : flags & ~28; } if (getCheckFlags(s) & 6) { @@ -14308,32 +14657,32 @@ var ts; if (!parent) return 0; switch (parent.kind) { - case 207: + case 209: return accessKind(parent); - case 215: - case 214: + case 217: + case 216: var operator = parent.operator; return operator === 45 || operator === 46 ? writeOrReadWrite() : 0; - case 216: + case 218: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? - operatorToken.kind === 62 ? 1 : writeOrReadWrite() + operatorToken.kind === 63 ? 1 : writeOrReadWrite() : 0; - case 201: + case 203: return parent.name !== node ? 0 : accessKind(parent); - case 288: { + case 290: { var parentAccess = accessKind(parent.parent); return node === parent.name ? reverseAccessKind(parentAccess) : parentAccess; } - case 289: + case 291: return node === parent.objectAssignmentInitializer ? 0 : accessKind(parent.parent); - case 199: + case 201: return accessKind(parent); default: return 0; } function writeOrReadWrite() { - return parent.parent && skipParenthesesUp(parent.parent).kind === 233 ? 1 : 2; + return parent.parent && walkUpParenthesizedExpressions(parent.parent).kind === 235 ? 1 : 2; } } function reverseAccessKind(a) { @@ -14405,7 +14754,8 @@ var ts; } ts.isAbstractConstructorSymbol = isAbstractConstructorSymbol; function getClassLikeDeclarationOfSymbol(symbol) { - return ts.find(symbol.declarations, ts.isClassLike); + var _a; + return (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isClassLike); } ts.getClassLikeDeclarationOfSymbol = getClassLikeDeclarationOfSymbol; function getObjectFlags(type) { @@ -14447,7 +14797,6 @@ var ts; ts.getLastChild = getLastChild; function addToSeen(seen, key, value) { if (value === void 0) { value = true; } - key = String(key); if (seen.has(key)) { return false; } @@ -14460,37 +14809,37 @@ var ts; } ts.isObjectTypeDeclaration = isObjectTypeDeclaration; function isTypeNodeKind(kind) { - return (kind >= 172 && kind <= 195) - || kind === 128 - || kind === 152 - || kind === 144 - || kind === 155 + return (kind >= 174 && kind <= 197) + || kind === 129 + || kind === 153 || kind === 145 - || kind === 131 - || kind === 147 + || kind === 156 + || kind === 146 + || kind === 132 || kind === 148 - || kind === 113 - || kind === 150 - || kind === 141 - || kind === 223 - || kind === 303 - || kind === 304 - || kind === 305 + || kind === 149 + || kind === 114 + || kind === 151 + || kind === 142 + || kind === 225 || kind === 306 || kind === 307 || kind === 308 - || kind === 309; + || kind === 309 + || kind === 310 + || kind === 311 + || kind === 312; } ts.isTypeNodeKind = isTypeNodeKind; function isAccessExpression(node) { - return node.kind === 201 || node.kind === 202; + return node.kind === 203 || node.kind === 204; } ts.isAccessExpression = isAccessExpression; function getNameOfAccessExpression(node) { - if (node.kind === 201) { + if (node.kind === 203) { return node.name; } - ts.Debug.assert(node.kind === 202); + ts.Debug.assert(node.kind === 204); return node.argumentExpression; } ts.getNameOfAccessExpression = getNameOfAccessExpression; @@ -14505,7 +14854,7 @@ var ts; } ts.isBundleFileTextLike = isBundleFileTextLike; function isNamedImportsOrExports(node) { - return node.kind === 264 || node.kind === 268; + return node.kind === 266 || node.kind === 270; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function getLeftmostAccessExpression(expr) { @@ -14518,27 +14867,27 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 215: + case 217: node = node.operand; continue; - case 216: + case 218: node = node.left; continue; - case 217: + case 219: node = node.condition; continue; - case 205: + case 207: node = node.tag; continue; - case 203: + case 205: if (stopAtCallExpressions) { return node; } - case 224: - case 202: - case 201: - case 225: - case 336: + case 226: + case 204: + case 203: + case 227: + case 344: node = node.expression; continue; } @@ -14557,7 +14906,7 @@ var ts; } function Type(checker, flags) { this.flags = flags; - if (ts.Debug.isDebugging || ts.tracing.isTracing()) { + if (ts.Debug.isDebugging || ts.tracing) { this.checker = checker; } } @@ -14898,6 +15247,10 @@ var ts; return !!(compilerOptions.declaration || compilerOptions.composite); } ts.getEmitDeclarations = getEmitDeclarations; + function shouldPreserveConstEnums(compilerOptions) { + return !!(compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); + } + ts.shouldPreserveConstEnums = shouldPreserveConstEnums; function isIncrementalCompilation(options) { return !!(options.incremental || options.composite); } @@ -14910,14 +15263,16 @@ var ts; return compilerOptions.allowJs === undefined ? !!compilerOptions.checkJs : compilerOptions.allowJs; } ts.getAllowJSCompilerOption = getAllowJSCompilerOption; + function getUseDefineForClassFields(compilerOptions) { + return compilerOptions.useDefineForClassFields === undefined ? compilerOptions.target === 99 : compilerOptions.useDefineForClassFields; + } + ts.getUseDefineForClassFields = getUseDefineForClassFields; function compilerOptionsAffectSemanticDiagnostics(newOptions, oldOptions) { - return oldOptions !== newOptions && - ts.semanticDiagnosticsOptionDeclarations.some(function (option) { return !isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); }); + return optionsHaveChanges(oldOptions, newOptions, ts.semanticDiagnosticsOptionDeclarations); } ts.compilerOptionsAffectSemanticDiagnostics = compilerOptionsAffectSemanticDiagnostics; function compilerOptionsAffectEmit(newOptions, oldOptions) { - return oldOptions !== newOptions && - ts.affectsEmitOptionDeclarations.some(function (option) { return !isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); }); + return optionsHaveChanges(oldOptions, newOptions, ts.affectsEmitOptionDeclarations); } ts.compilerOptionsAffectEmit = compilerOptionsAffectEmit; function getCompilerOptionValue(options, option) { @@ -14931,7 +15286,7 @@ var ts; 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[0] : jsxImportSourcePragmas; + var jsxImportSourcePragma = ts.isArray(jsxImportSourcePragmas) ? jsxImportSourcePragmas[jsxImportSourcePragmas.length - 1] : jsxImportSourcePragmas; return compilerOptions.jsx === 4 || compilerOptions.jsx === 5 || compilerOptions.jsxImportSource || @@ -14959,37 +15314,62 @@ var ts; return true; } ts.hasZeroOrOneAsteriskCharacter = hasZeroOrOneAsteriskCharacter; - function createSymlinkCache() { + function createSymlinkCache(cwd, getCanonicalFileName) { var symlinkedDirectories; + var symlinkedDirectoriesByRealpath; var symlinkedFiles; return { getSymlinkedFiles: function () { return symlinkedFiles; }, getSymlinkedDirectories: function () { return symlinkedDirectories; }, + getSymlinkedDirectoriesByRealpath: function () { return symlinkedDirectoriesByRealpath; }, setSymlinkedFile: function (path, real) { return (symlinkedFiles || (symlinkedFiles = new ts.Map())).set(path, real); }, - setSymlinkedDirectory: function (path, directory) { return (symlinkedDirectories || (symlinkedDirectories = new ts.Map())).set(path, directory); }, + setSymlinkedDirectory: function (symlink, real) { + var symlinkPath = ts.toPath(symlink, cwd, getCanonicalFileName); + if (!containsIgnoredPath(symlinkPath)) { + symlinkPath = ts.ensureTrailingDirectorySeparator(symlinkPath); + if (real !== false && !(symlinkedDirectories === null || symlinkedDirectories === void 0 ? void 0 : symlinkedDirectories.has(symlinkPath))) { + (symlinkedDirectoriesByRealpath || (symlinkedDirectoriesByRealpath = ts.createMultiMap())).add(ts.ensureTrailingDirectorySeparator(real.realPath), symlink); + } + (symlinkedDirectories || (symlinkedDirectories = new ts.Map())).set(symlinkPath, real); + } + }, + setSymlinkedDirectoryFromSymlinkedFile: function (symlink, real) { + this.setSymlinkedFile(ts.toPath(symlink, cwd, getCanonicalFileName), real); + var _a = guessDirectorySymlink(real, symlink, cwd, getCanonicalFileName) || ts.emptyArray, commonResolved = _a[0], commonOriginal = _a[1]; + if (commonResolved && commonOriginal) { + this.setSymlinkedDirectory(commonOriginal, { + real: commonResolved, + realPath: ts.toPath(commonResolved, cwd, getCanonicalFileName), + }); + } + }, }; } ts.createSymlinkCache = createSymlinkCache; function discoverProbableSymlinks(files, getCanonicalFileName, cwd) { - var cache = createSymlinkCache(); - var symlinks = ts.flatten(ts.mapDefined(files, function (sf) { - return sf.resolvedModules && ts.compact(ts.arrayFrom(ts.mapIterator(sf.resolvedModules.values(), function (res) { - return res && res.originalPath && res.resolvedFileName !== res.originalPath ? [res.resolvedFileName, res.originalPath] : undefined; + var cache = createSymlinkCache(cwd, getCanonicalFileName); + var symlinks = ts.flatMap(files, function (sf) { + var pairs = sf.resolvedModules && ts.arrayFrom(ts.mapDefinedIterator(sf.resolvedModules.values(), function (res) { + return (res === null || res === void 0 ? void 0 : res.originalPath) ? [res.resolvedFileName, res.originalPath] : undefined; + })); + return ts.concatenate(pairs, sf.resolvedTypeReferenceDirectiveNames && ts.arrayFrom(ts.mapDefinedIterator(sf.resolvedTypeReferenceDirectiveNames.values(), function (res) { + return (res === null || res === void 0 ? void 0 : res.originalPath) && res.resolvedFileName ? [res.resolvedFileName, res.originalPath] : undefined; }))); - })); + }); for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) { var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1]; + cache.setSymlinkedFile(ts.toPath(originalPath, cwd, getCanonicalFileName), resolvedPath); var _b = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName) || ts.emptyArray, commonResolved = _b[0], commonOriginal = _b[1]; if (commonResolved && commonOriginal) { - cache.setSymlinkedDirectory(ts.toPath(commonOriginal, cwd, getCanonicalFileName), { real: commonResolved, realPath: ts.toPath(commonResolved, cwd, getCanonicalFileName) }); + cache.setSymlinkedDirectory(commonOriginal, { real: commonResolved, realPath: ts.toPath(commonResolved, cwd, getCanonicalFileName) }); } } return cache; } ts.discoverProbableSymlinks = discoverProbableSymlinks; function guessDirectorySymlink(a, b, cwd, getCanonicalFileName) { - var aParts = ts.getPathComponents(ts.toPath(a, cwd, getCanonicalFileName)); - var bParts = ts.getPathComponents(ts.toPath(b, cwd, getCanonicalFileName)); + var aParts = ts.getPathComponents(ts.getNormalizedAbsolutePath(a, cwd)); + var bParts = ts.getPathComponents(ts.getNormalizedAbsolutePath(b, cwd)); var isDirectory = false; while (!isNodeModulesOrScopedPackageDirectory(aParts[aParts.length - 2], getCanonicalFileName) && !isNodeModulesOrScopedPackageDirectory(bParts[bParts.length - 2], getCanonicalFileName) && @@ -15312,6 +15692,14 @@ var ts; return false; } ts.isSupportedSourceFileName = isSupportedSourceFileName; + function numberOfDirectorySeparators(str) { + var match = str.match(/\//g); + return match ? match.length : 0; + } + function compareNumberOfDirectorySeparators(path1, path2) { + return ts.compareValues(numberOfDirectorySeparators(path1), numberOfDirectorySeparators(path2)); + } + ts.compareNumberOfDirectorySeparators = compareNumberOfDirectorySeparators; function getExtensionPriority(path, supportedExtensions) { for (var i = supportedExtensions.length - 1; i >= 0; i--) { if (ts.fileExtensionIs(path, supportedExtensions[i])) { @@ -15367,14 +15755,22 @@ var ts; } ts.changeExtension = changeExtension; function tryParsePattern(pattern) { - ts.Debug.assert(hasZeroOrOneAsteriskCharacter(pattern)); var indexOfStar = pattern.indexOf("*"); - return indexOfStar === -1 ? undefined : { - prefix: pattern.substr(0, indexOfStar), - suffix: pattern.substr(indexOfStar + 1) - }; + if (indexOfStar === -1) { + return pattern; + } + return pattern.indexOf("*", indexOfStar + 1) !== -1 + ? undefined + : { + prefix: pattern.substr(0, indexOfStar), + suffix: pattern.substr(indexOfStar + 1) + }; } ts.tryParsePattern = tryParsePattern; + function tryParsePatterns(paths) { + return ts.mapDefined(ts.getOwnKeys(paths), function (path) { return tryParsePattern(path); }); + } + ts.tryParsePatterns = tryParsePatterns; function positionIsSynthesized(pos) { return !(pos >= 0); } @@ -15408,18 +15804,15 @@ var ts; files: ts.emptyArray, directories: ts.emptyArray }; - function matchPatternOrExact(patternStrings, candidate) { + function matchPatternOrExact(patternOrStrings, candidate) { var patterns = []; - for (var _i = 0, patternStrings_1 = patternStrings; _i < patternStrings_1.length; _i++) { - var patternString = patternStrings_1[_i]; - if (!hasZeroOrOneAsteriskCharacter(patternString)) - continue; - var pattern = tryParsePattern(patternString); - if (pattern) { - patterns.push(pattern); + for (var _i = 0, patternOrStrings_1 = patternOrStrings; _i < patternOrStrings_1.length; _i++) { + var patternOrString = patternOrStrings_1[_i]; + if (patternOrString === candidate) { + return candidate; } - else if (patternString === candidate) { - return patternString; + if (!ts.isString(patternOrString)) { + patterns.push(patternOrString); } } return ts.findBestPatternMatch(patterns, function (_) { return _; }, candidate); @@ -15558,37 +15951,37 @@ var ts; } ts.isValidTypeOnlyAliasUseSite = isValidTypeOnlyAliasUseSite; function typeOnlyDeclarationIsExport(typeOnlyDeclaration) { - return typeOnlyDeclaration.kind === 270; + return typeOnlyDeclaration.kind === 272; } ts.typeOnlyDeclarationIsExport = typeOnlyDeclarationIsExport; function isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(node) { - while (node.kind === 78 || node.kind === 201) { + while (node.kind === 79 || node.kind === 203) { node = node.parent; } - if (node.kind !== 158) { + if (node.kind !== 160) { return false; } if (hasSyntacticModifier(node.parent, 128)) { return true; } var containerKind = node.parent.parent.kind; - return containerKind === 253 || containerKind === 177; + return containerKind === 255 || containerKind === 179; } function isIdentifierInNonEmittingHeritageClause(node) { - if (node.kind !== 78) + if (node.kind !== 79) return false; var heritageClause = ts.findAncestor(node.parent, function (parent) { switch (parent.kind) { - case 286: + case 288: return true; - case 201: - case 223: + case 203: + case 225: return false; default: return "quit"; } }); - return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 116 || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 253; + return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 117 || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 255; } function isIdentifierTypeReference(node) { return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName); @@ -15710,6 +16103,76 @@ var ts; } } ts.expressionResultIsUnused = expressionResultIsUnused; + function containsIgnoredPath(path) { + return ts.some(ts.ignoredPaths, function (p) { return ts.stringContains(path, p); }); + } + ts.containsIgnoredPath = containsIgnoredPath; + function getContainingNodeArray(node) { + if (!node.parent) + return undefined; + switch (node.kind) { + case 161: + var parent_1 = node.parent; + return parent_1.kind === 187 ? undefined : parent_1.typeParameters; + case 162: + return node.parent.parameters; + case 196: + return node.parent.templateSpans; + case 230: + return node.parent.templateSpans; + case 163: + return node.parent.decorators; + case 288: + return node.parent.heritageClauses; + } + var parent = node.parent; + if (ts.isJSDocTag(node)) { + return ts.isJSDocTypeLiteral(node.parent) ? undefined : node.parent.tags; + } + switch (parent.kind) { + case 179: + case 255: + return ts.isTypeElement(node) ? parent.members : undefined; + case 184: + case 185: + return parent.types; + case 181: + case 201: + case 345: + case 266: + case 270: + return parent.elements; + case 202: + case 283: + return parent.properties; + case 205: + case 206: + return ts.isTypeNode(node) ? parent.typeArguments : + parent.expression === node ? undefined : + parent.arguments; + case 275: + case 279: + return ts.isJsxChild(node) ? parent.children : undefined; + case 277: + case 276: + return ts.isTypeNode(node) ? parent.typeArguments : undefined; + case 232: + case 286: + case 287: + case 259: + return parent.statements; + case 260: + return parent.clauses; + case 254: + case 223: + return ts.isClassElement(node) ? parent.members : undefined; + case 257: + return ts.isEnumMember(node) ? parent.members : undefined; + case 299: + return parent.statements; + } + } + ts.getContainingNodeArray = getContainingNodeArray; })(ts || (ts = {})); var ts; (function (ts) { @@ -15747,7 +16210,11 @@ var ts; var ts; (function (ts) { function createParenthesizerRules(factory) { + var binaryLeftOperandParenthesizerCache; + var binaryRightOperandParenthesizerCache; return { + getParenthesizeLeftSideOfBinaryForOperator: getParenthesizeLeftSideOfBinaryForOperator, + getParenthesizeRightSideOfBinaryForOperator: getParenthesizeRightSideOfBinaryForOperator, parenthesizeLeftSideOfBinary: parenthesizeLeftSideOfBinary, parenthesizeRightSideOfBinary: parenthesizeRightSideOfBinary, parenthesizeExpressionOfComputedPropertyName: parenthesizeExpressionOfComputedPropertyName, @@ -15768,11 +16235,29 @@ var ts; parenthesizeConstituentTypesOfUnionOrIntersectionType: parenthesizeConstituentTypesOfUnionOrIntersectionType, parenthesizeTypeArguments: parenthesizeTypeArguments, }; + function getParenthesizeLeftSideOfBinaryForOperator(operatorKind) { + binaryLeftOperandParenthesizerCache || (binaryLeftOperandParenthesizerCache = new ts.Map()); + var parenthesizerRule = binaryLeftOperandParenthesizerCache.get(operatorKind); + if (!parenthesizerRule) { + parenthesizerRule = function (node) { return parenthesizeLeftSideOfBinary(operatorKind, node); }; + binaryLeftOperandParenthesizerCache.set(operatorKind, parenthesizerRule); + } + return parenthesizerRule; + } + function getParenthesizeRightSideOfBinaryForOperator(operatorKind) { + binaryRightOperandParenthesizerCache || (binaryRightOperandParenthesizerCache = new ts.Map()); + var parenthesizerRule = binaryRightOperandParenthesizerCache.get(operatorKind); + if (!parenthesizerRule) { + parenthesizerRule = function (node) { return parenthesizeRightSideOfBinary(operatorKind, undefined, node); }; + binaryRightOperandParenthesizerCache.set(operatorKind, parenthesizerRule); + } + return parenthesizerRule; + } function binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { - var binaryOperatorPrecedence = ts.getOperatorPrecedence(216, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(216, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(218, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(218, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); - if (!isLeftSideOfBinary && operand.kind === 209 && binaryOperatorPrecedence > 3) { + if (!isLeftSideOfBinary && operand.kind === 211 && binaryOperatorPrecedence > 3) { return true; } var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); @@ -15780,7 +16265,7 @@ var ts; case -1: if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 - && operand.kind === 219) { + && operand.kind === 221) { return false; } return true; @@ -15819,7 +16304,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 216 && node.operatorToken.kind === 39) { + if (node.kind === 218 && node.operatorToken.kind === 39) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -15835,7 +16320,7 @@ var ts; } function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = ts.skipPartiallyEmittedExpressions(operand); - if (skipped.kind === 207) { + if (skipped.kind === 209) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -15852,7 +16337,7 @@ var ts; return ts.isCommaSequence(expression) ? factory.createParenthesizedExpression(expression) : expression; } function parenthesizeConditionOfConditionalExpression(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(217, 57); + var conditionalPrecedence = ts.getOperatorPrecedence(219, 57); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) !== 1) { @@ -15871,8 +16356,8 @@ var ts; var needsParens = ts.isCommaSequence(check); if (!needsParens) { switch (ts.getLeftmostExpression(check, false).kind) { - case 221: - case 208: + case 223: + case 210: needsParens = true; } } @@ -15881,9 +16366,9 @@ var ts; function parenthesizeExpressionOfNew(expression) { var leftmostExpr = ts.getLeftmostExpression(expression, true); switch (leftmostExpr.kind) { - case 203: + case 205: return factory.createParenthesizedExpression(expression); - case 204: + case 206: return !leftmostExpr.arguments ? factory.createParenthesizedExpression(expression) : expression; @@ -15893,7 +16378,7 @@ var ts; function parenthesizeLeftSideOfAccess(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 204 || emittedExpression.arguments)) { + && (emittedExpression.kind !== 206 || emittedExpression.arguments)) { return expression; } return ts.setTextRange(factory.createParenthesizedExpression(expression), expression); @@ -15911,7 +16396,7 @@ var ts; function parenthesizeExpressionForDisallowedComma(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(216, 27); + var commaPrecedence = ts.getOperatorPrecedence(218, 27); return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(factory.createParenthesizedExpression(expression), expression); } function parenthesizeExpressionOfExpressionStatement(expression) { @@ -15919,41 +16404,41 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 208 || kind === 209) { + if (kind === 210 || kind === 211) { var updated = factory.updateCallExpression(emittedExpression, ts.setTextRange(factory.createParenthesizedExpression(callee), callee), emittedExpression.typeArguments, emittedExpression.arguments); return factory.restoreOuterExpressions(expression, updated, 8); } } var leftmostExpressionKind = ts.getLeftmostExpression(emittedExpression, false).kind; - if (leftmostExpressionKind === 200 || leftmostExpressionKind === 208) { + if (leftmostExpressionKind === 202 || leftmostExpressionKind === 210) { return ts.setTextRange(factory.createParenthesizedExpression(expression), expression); } return expression; } function parenthesizeConciseBodyOfArrowFunction(body) { - if (!ts.isBlock(body) && (ts.isCommaSequence(body) || ts.getLeftmostExpression(body, false).kind === 200)) { + if (!ts.isBlock(body) && (ts.isCommaSequence(body) || ts.getLeftmostExpression(body, false).kind === 202)) { return ts.setTextRange(factory.createParenthesizedExpression(body), body); } return body; } function parenthesizeMemberOfConditionalType(member) { - return member.kind === 184 ? factory.createParenthesizedType(member) : member; + return member.kind === 186 ? factory.createParenthesizedType(member) : member; } function parenthesizeMemberOfElementType(member) { switch (member.kind) { - case 182: - case 183: - case 174: - case 175: + case 184: + case 185: + case 176: + case 177: return factory.createParenthesizedType(member); } return parenthesizeMemberOfConditionalType(member); } function parenthesizeElementTypeOfArrayType(member) { switch (member.kind) { - case 176: - case 188: - case 185: + case 178: + case 190: + case 187: return factory.createParenthesizedType(member); } return parenthesizeMemberOfElementType(member); @@ -15972,6 +16457,8 @@ var ts; } ts.createParenthesizerRules = createParenthesizerRules; ts.nullParenthesizerRules = { + getParenthesizeLeftSideOfBinaryForOperator: function (_) { return ts.identity; }, + getParenthesizeRightSideOfBinaryForOperator: function (_) { return ts.identity; }, parenthesizeLeftSideOfBinary: function (_binaryOperator, leftSide) { return leftSide; }, parenthesizeRightSideOfBinary: function (_binaryOperator, _leftSide, rightSide) { return rightSide; }, parenthesizeExpressionOfComputedPropertyName: ts.identity, @@ -16056,11 +16543,11 @@ var ts; } function convertToAssignmentPattern(node) { switch (node.kind) { - case 197: case 199: + case 201: return convertToArrayAssignmentPattern(node); - case 196: - case 200: + case 198: + case 202: return convertToObjectAssignmentPattern(node); } } @@ -16379,18 +16866,18 @@ var ts; createMissingDeclaration: createMissingDeclaration, createExternalModuleReference: createExternalModuleReference, updateExternalModuleReference: updateExternalModuleReference, - get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(303); }, - get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(304); }, - get createJSDocNonNullableType() { return getJSDocUnaryTypeCreateFunction(306); }, - get updateJSDocNonNullableType() { return getJSDocUnaryTypeUpdateFunction(306); }, - get createJSDocNullableType() { return getJSDocUnaryTypeCreateFunction(305); }, - get updateJSDocNullableType() { return getJSDocUnaryTypeUpdateFunction(305); }, - get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(307); }, - get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(307); }, - get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(309); }, - get updateJSDocVariadicType() { return getJSDocUnaryTypeUpdateFunction(309); }, - get createJSDocNamepathType() { return getJSDocUnaryTypeCreateFunction(310); }, - get updateJSDocNamepathType() { return getJSDocUnaryTypeUpdateFunction(310); }, + get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(306); }, + get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(307); }, + get createJSDocNonNullableType() { return getJSDocUnaryTypeCreateFunction(309); }, + get updateJSDocNonNullableType() { return getJSDocUnaryTypeUpdateFunction(309); }, + get createJSDocNullableType() { return getJSDocUnaryTypeCreateFunction(308); }, + get updateJSDocNullableType() { return getJSDocUnaryTypeUpdateFunction(308); }, + get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(310); }, + get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(310); }, + get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(312); }, + get updateJSDocVariadicType() { return getJSDocUnaryTypeUpdateFunction(312); }, + get createJSDocNamepathType() { return getJSDocUnaryTypeCreateFunction(313); }, + get updateJSDocNamepathType() { return getJSDocUnaryTypeUpdateFunction(313); }, createJSDocFunctionType: createJSDocFunctionType, updateJSDocFunctionType: updateJSDocFunctionType, createJSDocTypeLiteral: createJSDocTypeLiteral, @@ -16417,30 +16904,42 @@ var ts; updateJSDocSeeTag: updateJSDocSeeTag, createJSDocNameReference: createJSDocNameReference, updateJSDocNameReference: updateJSDocNameReference, - get createJSDocTypeTag() { return getJSDocTypeLikeTagCreateFunction(329); }, - get updateJSDocTypeTag() { return getJSDocTypeLikeTagUpdateFunction(329); }, - get createJSDocReturnTag() { return getJSDocTypeLikeTagCreateFunction(327); }, - get updateJSDocReturnTag() { return getJSDocTypeLikeTagUpdateFunction(327); }, - get createJSDocThisTag() { return getJSDocTypeLikeTagCreateFunction(328); }, - get updateJSDocThisTag() { return getJSDocTypeLikeTagUpdateFunction(328); }, - get createJSDocEnumTag() { return getJSDocTypeLikeTagCreateFunction(325); }, - get updateJSDocEnumTag() { return getJSDocTypeLikeTagUpdateFunction(325); }, - get createJSDocAuthorTag() { return getJSDocSimpleTagCreateFunction(317); }, - get updateJSDocAuthorTag() { return getJSDocSimpleTagUpdateFunction(317); }, - get createJSDocClassTag() { return getJSDocSimpleTagCreateFunction(319); }, - get updateJSDocClassTag() { return getJSDocSimpleTagUpdateFunction(319); }, - get createJSDocPublicTag() { return getJSDocSimpleTagCreateFunction(320); }, - get updateJSDocPublicTag() { return getJSDocSimpleTagUpdateFunction(320); }, - get createJSDocPrivateTag() { return getJSDocSimpleTagCreateFunction(321); }, - get updateJSDocPrivateTag() { return getJSDocSimpleTagUpdateFunction(321); }, - get createJSDocProtectedTag() { return getJSDocSimpleTagCreateFunction(322); }, - get updateJSDocProtectedTag() { return getJSDocSimpleTagUpdateFunction(322); }, - get createJSDocReadonlyTag() { return getJSDocSimpleTagCreateFunction(323); }, - get updateJSDocReadonlyTag() { return getJSDocSimpleTagUpdateFunction(323); }, - get createJSDocDeprecatedTag() { return getJSDocSimpleTagCreateFunction(318); }, - get updateJSDocDeprecatedTag() { return getJSDocSimpleTagUpdateFunction(318); }, + createJSDocMemberName: createJSDocMemberName, + updateJSDocMemberName: updateJSDocMemberName, + createJSDocLink: createJSDocLink, + updateJSDocLink: updateJSDocLink, + createJSDocLinkCode: createJSDocLinkCode, + updateJSDocLinkCode: updateJSDocLinkCode, + createJSDocLinkPlain: createJSDocLinkPlain, + updateJSDocLinkPlain: updateJSDocLinkPlain, + get createJSDocTypeTag() { return getJSDocTypeLikeTagCreateFunction(337); }, + get updateJSDocTypeTag() { return getJSDocTypeLikeTagUpdateFunction(337); }, + get createJSDocReturnTag() { return getJSDocTypeLikeTagCreateFunction(335); }, + get updateJSDocReturnTag() { return getJSDocTypeLikeTagUpdateFunction(335); }, + get createJSDocThisTag() { return getJSDocTypeLikeTagCreateFunction(336); }, + get updateJSDocThisTag() { return getJSDocTypeLikeTagUpdateFunction(336); }, + get createJSDocEnumTag() { return getJSDocTypeLikeTagCreateFunction(333); }, + get updateJSDocEnumTag() { return getJSDocTypeLikeTagUpdateFunction(333); }, + get createJSDocAuthorTag() { return getJSDocSimpleTagCreateFunction(324); }, + get updateJSDocAuthorTag() { return getJSDocSimpleTagUpdateFunction(324); }, + get createJSDocClassTag() { return getJSDocSimpleTagCreateFunction(326); }, + get updateJSDocClassTag() { return getJSDocSimpleTagUpdateFunction(326); }, + get createJSDocPublicTag() { return getJSDocSimpleTagCreateFunction(327); }, + get updateJSDocPublicTag() { return getJSDocSimpleTagUpdateFunction(327); }, + get createJSDocPrivateTag() { return getJSDocSimpleTagCreateFunction(328); }, + get updateJSDocPrivateTag() { return getJSDocSimpleTagUpdateFunction(328); }, + get createJSDocProtectedTag() { return getJSDocSimpleTagCreateFunction(329); }, + get updateJSDocProtectedTag() { return getJSDocSimpleTagUpdateFunction(329); }, + get createJSDocReadonlyTag() { return getJSDocSimpleTagCreateFunction(330); }, + get updateJSDocReadonlyTag() { return getJSDocSimpleTagUpdateFunction(330); }, + get createJSDocOverrideTag() { return getJSDocSimpleTagCreateFunction(331); }, + get updateJSDocOverrideTag() { return getJSDocSimpleTagUpdateFunction(331); }, + get createJSDocDeprecatedTag() { return getJSDocSimpleTagCreateFunction(325); }, + get updateJSDocDeprecatedTag() { return getJSDocSimpleTagUpdateFunction(325); }, createJSDocUnknownTag: createJSDocUnknownTag, updateJSDocUnknownTag: updateJSDocUnknownTag, + createJSDocText: createJSDocText, + updateJSDocText: updateJSDocText, createJSDocComment: createJSDocComment, updateJSDocComment: updateJSDocComment, createJsxElement: createJsxElement, @@ -16504,7 +17003,7 @@ var ts; updateSyntheticReferenceExpression: updateSyntheticReferenceExpression, cloneNode: cloneNode, get createComma() { return getBinaryCreateFunction(27); }, - get createAssignment() { return getBinaryCreateFunction(62); }, + get createAssignment() { return getBinaryCreateFunction(63); }, get createLogicalOr() { return getBinaryCreateFunction(56); }, get createLogicalAnd() { return getBinaryCreateFunction(55); }, get createBitwiseOr() { return getBinaryCreateFunction(51); }, @@ -16611,11 +17110,11 @@ var ts; node.name = name; if (name) { switch (node.kind) { - case 165: case 167: - case 168: - case 163: - case 288: + case 169: + case 170: + case 165: + case 290: if (ts.isIdentifier(name)) { node.transformFlags |= propagateIdentifierNameFlags(name); break; @@ -16654,7 +17153,7 @@ var ts; function createBaseFunctionLikeDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type, body) { var node = createBaseSignatureDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type); node.body = body; - node.transformFlags |= propagateChildFlags(node.body) & ~8388608; + node.transformFlags |= propagateChildFlags(node.body) & ~16777216; if (!body) node.transformFlags |= 1; return node; @@ -16702,7 +17201,7 @@ var ts; var node = createBaseLiteral(8, typeof value === "number" ? value + "" : value); node.numericLiteralFlags = numericLiteralFlags; if (numericLiteralFlags & 384) - node.transformFlags |= 256; + node.transformFlags |= 512; return node; } function createBigIntLiteral(value) { @@ -16719,7 +17218,7 @@ var ts; var node = createBaseStringLiteral(text, isSingleQuote); node.hasExtendedUnicodeEscape = hasExtendedUnicodeEscape; if (hasExtendedUnicodeEscape) - node.transformFlags |= 256; + node.transformFlags |= 512; return node; } function createStringLiteralFromNode(sourceNode) { @@ -16746,10 +17245,10 @@ var ts; if (originalKeywordKind === undefined && text) { originalKeywordKind = ts.stringToToken(text); } - if (originalKeywordKind === 78) { + if (originalKeywordKind === 79) { originalKeywordKind = undefined; } - var node = baseFactory.createBaseIdentifierNode(78); + var node = baseFactory.createBaseIdentifierNode(79); node.originalKeywordKind = originalKeywordKind; node.escapedText = ts.escapeLeadingUnderscores(text); return node; @@ -16766,8 +17265,8 @@ var ts; if (typeArguments) { node.typeArguments = createNodeArray(typeArguments); } - if (node.originalKeywordKind === 130) { - node.transformFlags |= 8388608; + if (node.originalKeywordKind === 131) { + node.transformFlags |= 16777216; } return node; } @@ -16786,8 +17285,11 @@ var ts; } return name; } - function createLoopVariable() { - return createBaseGeneratedIdentifier("", 2); + function createLoopVariable(reservedInNestedScopes) { + var flags = 2; + if (reservedInNestedScopes) + flags |= 8; + return createBaseGeneratedIdentifier("", flags); } function createUniqueName(text, flags) { if (flags === void 0) { flags = 0; } @@ -16805,53 +17307,54 @@ var ts; function createPrivateIdentifier(text) { if (!ts.startsWith(text, "#")) ts.Debug.fail("First character of private identifier must be #: " + text); - var node = baseFactory.createBasePrivateIdentifierNode(79); + var node = baseFactory.createBasePrivateIdentifierNode(80); node.escapedText = ts.escapeLeadingUnderscores(text); - node.transformFlags |= 4194304; + node.transformFlags |= 8388608; return node; } function createBaseToken(kind) { return baseFactory.createBaseTokenNode(kind); } function createToken(token) { - ts.Debug.assert(token >= 0 && token <= 156, "Invalid token"); + ts.Debug.assert(token >= 0 && token <= 158, "Invalid token"); ts.Debug.assert(token <= 14 || token >= 17, "Invalid token. Use 'createTemplateLiteralLikeNode' to create template literals."); ts.Debug.assert(token <= 8 || token >= 14, "Invalid token. Use 'createLiteralLikeNode' to create literals."); - ts.Debug.assert(token !== 78, "Invalid token. Use 'createIdentifier' to create identifiers"); + ts.Debug.assert(token !== 79, "Invalid token. Use 'createIdentifier' to create identifiers"); var node = createBaseToken(token); var transformFlags = 0; switch (token) { - case 129: + case 130: transformFlags = - 64 | - 32; + 128 | + 64; break; - case 122: - case 120: + case 123: case 121: - case 142: - case 125: - case 133: - case 84: - case 128: - case 144: - case 155: - case 141: + case 122: + case 143: + case 126: + case 134: + case 85: + case 129: case 145: - case 147: - case 131: + case 156: + case 142: + case 146: + case 157: case 148: - case 113: - case 152: - case 150: + case 132: + case 149: + case 114: + case 153: + case 151: transformFlags = 1; break; - case 123: - case 105: - transformFlags = 256; + case 124: + case 106: + transformFlags = 512; break; - case 107: - transformFlags = 4096; + case 108: + transformFlags = 8192; break; } if (transformFlags) { @@ -16860,19 +17363,19 @@ var ts; return node; } function createSuper() { - return createToken(105); + return createToken(106); } function createThis() { - return createToken(107); + return createToken(108); } function createNull() { - return createToken(103); + return createToken(104); } function createTrue() { - return createToken(109); + return createToken(110); } function createFalse() { - return createToken(94); + return createToken(95); } function createModifier(kind) { return createToken(kind); @@ -16880,42 +17383,45 @@ var ts; function createModifiersFromModifierFlags(flags) { var result = []; if (flags & 1) { - result.push(createModifier(92)); + result.push(createModifier(93)); } if (flags & 2) { - result.push(createModifier(133)); + result.push(createModifier(134)); } if (flags & 512) { - result.push(createModifier(87)); + result.push(createModifier(88)); } if (flags & 2048) { - result.push(createModifier(84)); + result.push(createModifier(85)); } if (flags & 4) { - result.push(createModifier(122)); + result.push(createModifier(123)); } if (flags & 8) { - result.push(createModifier(120)); + result.push(createModifier(121)); } if (flags & 16) { - result.push(createModifier(121)); + result.push(createModifier(122)); } if (flags & 128) { - result.push(createModifier(125)); + result.push(createModifier(126)); } if (flags & 32) { - result.push(createModifier(123)); + result.push(createModifier(124)); + } + if (flags & 16384) { + result.push(createModifier(157)); } if (flags & 64) { - result.push(createModifier(142)); + result.push(createModifier(143)); } if (flags & 256) { - result.push(createModifier(129)); + result.push(createModifier(130)); } return result; } function createQualifiedName(left, right) { - var node = createBaseNode(157); + var node = createBaseNode(159); node.left = left; node.right = asName(right); node.transformFlags |= @@ -16930,12 +17436,12 @@ var ts; : node; } function createComputedPropertyName(expression) { - var node = createBaseNode(158); + var node = createBaseNode(160); node.expression = parenthesizerRules().parenthesizeExpressionOfComputedPropertyName(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 256 | - 32768; + 512 | + 65536; return node; } function updateComputedPropertyName(node, expression) { @@ -16944,7 +17450,7 @@ var ts; : node; } function createTypeParameterDeclaration(name, constraint, defaultType) { - var node = createBaseNamedDeclaration(159, undefined, undefined, name); + var node = createBaseNamedDeclaration(161, undefined, undefined, name); node.constraint = constraint; node.default = defaultType; node.transformFlags = 1; @@ -16958,7 +17464,7 @@ var ts; : node; } function createParameterDeclaration(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(160, decorators, modifiers, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); + var node = createBaseVariableLikeDeclaration(162, decorators, modifiers, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.dotDotDotToken = dotDotDotToken; node.questionToken = questionToken; if (ts.isThisIdentifier(node.name)) { @@ -16970,10 +17476,10 @@ var ts; propagateChildFlags(node.questionToken); if (questionToken) node.transformFlags |= 1; - if (ts.modifiersToFlags(node.modifiers) & 92) - node.transformFlags |= 2048; + if (ts.modifiersToFlags(node.modifiers) & 16476) + node.transformFlags |= 4096; if (initializer || dotDotDotToken) - node.transformFlags |= 256; + node.transformFlags |= 512; } return node; } @@ -16989,12 +17495,12 @@ var ts; : node; } function createDecorator(expression) { - var node = createBaseNode(161); + var node = createBaseNode(163); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= propagateChildFlags(node.expression) | 1 | - 2048; + 4096; return node; } function updateDecorator(node, expression) { @@ -17003,7 +17509,7 @@ var ts; : node; } function createPropertySignature(modifiers, name, questionToken, type) { - var node = createBaseNamedDeclaration(162, undefined, modifiers, name); + var node = createBaseNamedDeclaration(164, undefined, modifiers, name); node.type = type; node.questionToken = questionToken; node.transformFlags = 1; @@ -17018,15 +17524,15 @@ var ts; : node; } function createPropertyDeclaration(decorators, modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(163, decorators, modifiers, name, type, initializer); + var node = createBaseVariableLikeDeclaration(165, decorators, 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) | - 4194304; + 8388608; if (ts.isComputedPropertyName(node.name) || (ts.hasStaticModifier(node) && node.initializer)) { - node.transformFlags |= 2048; + node.transformFlags |= 4096; } if (questionOrExclamationToken || ts.modifiersToFlags(node.modifiers) & 2) { node.transformFlags |= 1; @@ -17045,7 +17551,7 @@ var ts; : node; } function createMethodSignature(modifiers, name, questionToken, typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(164, undefined, modifiers, name, typeParameters, parameters, type); + var node = createBaseSignatureDeclaration(166, undefined, modifiers, name, typeParameters, parameters, type); node.questionToken = questionToken; node.transformFlags = 1; return node; @@ -17061,26 +17567,26 @@ var ts; : node; } function createMethodDeclaration(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(165, decorators, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(167, decorators, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; node.questionToken = questionToken; node.transformFlags |= propagateChildFlags(node.asteriskToken) | propagateChildFlags(node.questionToken) | - 256; + 512; if (questionToken) { node.transformFlags |= 1; } if (ts.modifiersToFlags(node.modifiers) & 256) { if (asteriskToken) { - node.transformFlags |= 32; + node.transformFlags |= 64; } else { - node.transformFlags |= 64; + node.transformFlags |= 128; } } else if (asteriskToken) { - node.transformFlags |= 512; + node.transformFlags |= 1024; } return node; } @@ -17098,8 +17604,8 @@ var ts; : node; } function createConstructorDeclaration(decorators, modifiers, parameters, body) { - var node = createBaseFunctionLikeDeclaration(166, decorators, modifiers, undefined, undefined, parameters, undefined, body); - node.transformFlags |= 256; + var node = createBaseFunctionLikeDeclaration(168, decorators, modifiers, undefined, undefined, parameters, undefined, body); + node.transformFlags |= 512; return node; } function updateConstructorDeclaration(node, decorators, modifiers, parameters, body) { @@ -17111,7 +17617,7 @@ var ts; : node; } function createGetAccessorDeclaration(decorators, modifiers, name, parameters, type, body) { - return createBaseFunctionLikeDeclaration(167, decorators, modifiers, name, undefined, parameters, type, body); + return createBaseFunctionLikeDeclaration(169, decorators, modifiers, name, undefined, parameters, type, body); } function updateGetAccessorDeclaration(node, decorators, modifiers, name, parameters, type, body) { return node.decorators !== decorators @@ -17124,7 +17630,7 @@ var ts; : node; } function createSetAccessorDeclaration(decorators, modifiers, name, parameters, body) { - return createBaseFunctionLikeDeclaration(168, decorators, modifiers, name, undefined, parameters, undefined, body); + return createBaseFunctionLikeDeclaration(170, decorators, modifiers, name, undefined, parameters, undefined, body); } function updateSetAccessorDeclaration(node, decorators, modifiers, name, parameters, body) { return node.decorators !== decorators @@ -17136,7 +17642,7 @@ var ts; : node; } function createCallSignature(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(169, undefined, undefined, undefined, typeParameters, parameters, type); + var node = createBaseSignatureDeclaration(171, undefined, undefined, undefined, typeParameters, parameters, type); node.transformFlags = 1; return node; } @@ -17148,7 +17654,7 @@ var ts; : node; } function createConstructSignature(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(170, undefined, undefined, undefined, typeParameters, parameters, type); + var node = createBaseSignatureDeclaration(172, undefined, undefined, undefined, typeParameters, parameters, type); node.transformFlags = 1; return node; } @@ -17160,7 +17666,7 @@ var ts; : node; } function createIndexSignature(decorators, modifiers, parameters, type) { - var node = createBaseSignatureDeclaration(171, decorators, modifiers, undefined, undefined, parameters, type); + var node = createBaseSignatureDeclaration(173, decorators, modifiers, undefined, undefined, parameters, type); node.transformFlags = 1; return node; } @@ -17173,7 +17679,7 @@ var ts; : node; } function createTemplateLiteralTypeSpan(type, literal) { - var node = createBaseNode(194); + var node = createBaseNode(196); node.type = type; node.literal = literal; node.transformFlags = 1; @@ -17189,7 +17695,7 @@ var ts; return createToken(kind); } function createTypePredicateNode(assertsModifier, parameterName, type) { - var node = createBaseNode(172); + var node = createBaseNode(174); node.assertsModifier = assertsModifier; node.parameterName = asName(parameterName); node.type = type; @@ -17204,7 +17710,7 @@ var ts; : node; } function createTypeReferenceNode(typeName, typeArguments) { - var node = createBaseNode(173); + var node = createBaseNode(175); node.typeName = asName(typeName); node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(createNodeArray(typeArguments)); node.transformFlags = 1; @@ -17217,7 +17723,7 @@ var ts; : node; } function createFunctionTypeNode(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(174, undefined, undefined, undefined, typeParameters, parameters, type); + var node = createBaseSignatureDeclaration(176, undefined, undefined, undefined, typeParameters, parameters, type); node.transformFlags = 1; return node; } @@ -17238,7 +17744,7 @@ var ts; ts.Debug.fail("Incorrect number of arguments specified."); } function createConstructorTypeNode1(modifiers, typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(175, undefined, modifiers, undefined, typeParameters, parameters, type); + var node = createBaseSignatureDeclaration(177, undefined, modifiers, undefined, typeParameters, parameters, type); node.transformFlags = 1; return node; } @@ -17266,7 +17772,7 @@ var ts; return updateConstructorTypeNode1(node, node.modifiers, typeParameters, parameters, type); } function createTypeQueryNode(exprName) { - var node = createBaseNode(176); + var node = createBaseNode(178); node.exprName = exprName; node.transformFlags = 1; return node; @@ -17277,7 +17783,7 @@ var ts; : node; } function createTypeLiteralNode(members) { - var node = createBaseNode(177); + var node = createBaseNode(179); node.members = createNodeArray(members); node.transformFlags = 1; return node; @@ -17288,7 +17794,7 @@ var ts; : node; } function createArrayTypeNode(elementType) { - var node = createBaseNode(178); + var node = createBaseNode(180); node.elementType = parenthesizerRules().parenthesizeElementTypeOfArrayType(elementType); node.transformFlags = 1; return node; @@ -17299,7 +17805,7 @@ var ts; : node; } function createTupleTypeNode(elements) { - var node = createBaseNode(179); + var node = createBaseNode(181); node.elements = createNodeArray(elements); node.transformFlags = 1; return node; @@ -17310,7 +17816,7 @@ var ts; : node; } function createNamedTupleMember(dotDotDotToken, name, questionToken, type) { - var node = createBaseNode(192); + var node = createBaseNode(194); node.dotDotDotToken = dotDotDotToken; node.name = name; node.questionToken = questionToken; @@ -17327,7 +17833,7 @@ var ts; : node; } function createOptionalTypeNode(type) { - var node = createBaseNode(180); + var node = createBaseNode(182); node.type = parenthesizerRules().parenthesizeElementTypeOfArrayType(type); node.transformFlags = 1; return node; @@ -17338,7 +17844,7 @@ var ts; : node; } function createRestTypeNode(type) { - var node = createBaseNode(181); + var node = createBaseNode(183); node.type = type; node.transformFlags = 1; return node; @@ -17360,19 +17866,19 @@ var ts; : node; } function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(182, types); + return createUnionOrIntersectionTypeNode(184, types); } function updateUnionTypeNode(node, types) { return updateUnionOrIntersectionTypeNode(node, types); } function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(183, types); + return createUnionOrIntersectionTypeNode(185, types); } function updateIntersectionTypeNode(node, types) { return updateUnionOrIntersectionTypeNode(node, types); } function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createBaseNode(184); + var node = createBaseNode(186); node.checkType = parenthesizerRules().parenthesizeMemberOfConditionalType(checkType); node.extendsType = parenthesizerRules().parenthesizeMemberOfConditionalType(extendsType); node.trueType = trueType; @@ -17389,7 +17895,7 @@ var ts; : node; } function createInferTypeNode(typeParameter) { - var node = createBaseNode(185); + var node = createBaseNode(187); node.typeParameter = typeParameter; node.transformFlags = 1; return node; @@ -17400,7 +17906,7 @@ var ts; : node; } function createTemplateLiteralType(head, templateSpans) { - var node = createBaseNode(193); + var node = createBaseNode(195); node.head = head; node.templateSpans = createNodeArray(templateSpans); node.transformFlags = 1; @@ -17414,7 +17920,7 @@ var ts; } function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { if (isTypeOf === void 0) { isTypeOf = false; } - var node = createBaseNode(195); + var node = createBaseNode(197); node.argument = argument; node.qualifier = qualifier; node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); @@ -17432,7 +17938,7 @@ var ts; : node; } function createParenthesizedType(type) { - var node = createBaseNode(186); + var node = createBaseNode(188); node.type = type; node.transformFlags = 1; return node; @@ -17443,12 +17949,12 @@ var ts; : node; } function createThisTypeNode() { - var node = createBaseNode(187); + var node = createBaseNode(189); node.transformFlags = 1; return node; } function createTypeOperatorNode(operator, type) { - var node = createBaseNode(188); + var node = createBaseNode(190); node.operator = operator; node.type = parenthesizerRules().parenthesizeMemberOfElementType(type); node.transformFlags = 1; @@ -17460,7 +17966,7 @@ var ts; : node; } function createIndexedAccessTypeNode(objectType, indexType) { - var node = createBaseNode(189); + var node = createBaseNode(191); node.objectType = parenthesizerRules().parenthesizeMemberOfElementType(objectType); node.indexType = indexType; node.transformFlags = 1; @@ -17473,7 +17979,7 @@ var ts; : node; } function createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type) { - var node = createBaseNode(190); + var node = createBaseNode(192); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.nameType = nameType; @@ -17492,7 +17998,7 @@ var ts; : node; } function createLiteralTypeNode(literal) { - var node = createBaseNode(191); + var node = createBaseNode(193); node.literal = literal; node.transformFlags = 1; return node; @@ -17503,16 +18009,16 @@ var ts; : node; } function createObjectBindingPattern(elements) { - var node = createBaseNode(196); + var node = createBaseNode(198); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements) | - 256 | - 131072; - if (node.transformFlags & 8192) { + 512 | + 262144; + if (node.transformFlags & 16384) { node.transformFlags |= - 32 | - 16384; + 64 | + 32768; } return node; } @@ -17522,12 +18028,12 @@ var ts; : node; } function createArrayBindingPattern(elements) { - var node = createBaseNode(197); + var node = createBaseNode(199); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements) | - 256 | - 131072; + 512 | + 262144; return node; } function updateArrayBindingPattern(node, elements) { @@ -17536,19 +18042,19 @@ var ts; : node; } function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createBaseBindingLikeDeclaration(198, undefined, undefined, name, initializer); + var node = createBaseBindingLikeDeclaration(200, undefined, undefined, name, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.propertyName = asName(propertyName); node.dotDotDotToken = dotDotDotToken; node.transformFlags |= propagateChildFlags(node.dotDotDotToken) | - 256; + 512; if (node.propertyName) { node.transformFlags |= ts.isIdentifier(node.propertyName) ? propagateIdentifierNameFlags(node.propertyName) : propagateChildFlags(node.propertyName); } if (dotDotDotToken) - node.transformFlags |= 8192; + node.transformFlags |= 16384; return node; } function updateBindingElement(node, dotDotDotToken, propertyName, name, initializer) { @@ -17564,7 +18070,7 @@ var ts; return node; } function createArrayLiteralExpression(elements, multiLine) { - var node = createBaseExpression(199); + var node = createBaseExpression(201); node.elements = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(elements)); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.elements); @@ -17576,7 +18082,7 @@ var ts; : node; } function createObjectLiteralExpression(properties, multiLine) { - var node = createBaseExpression(200); + var node = createBaseExpression(202); node.properties = createNodeArray(properties); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.properties); @@ -17588,7 +18094,7 @@ var ts; : node; } function createPropertyAccessExpression(expression, name) { - var node = createBaseExpression(201); + var node = createBaseExpression(203); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.name = asName(name); node.transformFlags = @@ -17598,8 +18104,8 @@ var ts; propagateChildFlags(node.name)); if (ts.isSuperKeyword(expression)) { node.transformFlags |= - 64 | - 32; + 128 | + 64; } return node; } @@ -17613,13 +18119,13 @@ var ts; : node; } function createPropertyAccessChain(expression, questionDotToken, name) { - var node = createBaseExpression(201); + var node = createBaseExpression(203); node.flags |= 32; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.questionDotToken = questionDotToken; node.name = asName(name); node.transformFlags |= - 8 | + 16 | propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | (ts.isIdentifier(node.name) ? @@ -17636,7 +18142,7 @@ var ts; : node; } function createElementAccessExpression(expression, index) { - var node = createBaseExpression(202); + var node = createBaseExpression(204); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.argumentExpression = asExpression(index); node.transformFlags |= @@ -17644,8 +18150,8 @@ var ts; propagateChildFlags(node.argumentExpression); if (ts.isSuperKeyword(expression)) { node.transformFlags |= - 64 | - 32; + 128 | + 64; } return node; } @@ -17659,7 +18165,7 @@ var ts; : node; } function createElementAccessChain(expression, questionDotToken, index) { - var node = createBaseExpression(202); + var node = createBaseExpression(204); node.flags |= 32; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.questionDotToken = questionDotToken; @@ -17668,7 +18174,7 @@ var ts; propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | propagateChildFlags(node.argumentExpression) | - 8; + 16; return node; } function updateElementAccessChain(node, expression, questionDotToken, argumentExpression) { @@ -17680,7 +18186,7 @@ var ts; : node; } function createCallExpression(expression, typeArguments, argumentsArray) { - var node = createBaseExpression(203); + var node = createBaseExpression(205); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray)); @@ -17692,10 +18198,10 @@ var ts; node.transformFlags |= 1; } if (ts.isImportKeyword(node.expression)) { - node.transformFlags |= 2097152; + node.transformFlags |= 4194304; } else if (ts.isSuperProperty(node.expression)) { - node.transformFlags |= 4096; + node.transformFlags |= 8192; } return node; } @@ -17710,7 +18216,7 @@ var ts; : node; } function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) { - var node = createBaseExpression(203); + var node = createBaseExpression(205); node.flags |= 32; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.questionDotToken = questionDotToken; @@ -17721,12 +18227,12 @@ var ts; propagateChildFlags(node.questionDotToken) | propagateChildrenFlags(node.typeArguments) | propagateChildrenFlags(node.arguments) | - 8; + 16; if (node.typeArguments) { node.transformFlags |= 1; } if (ts.isSuperProperty(node.expression)) { - node.transformFlags |= 4096; + node.transformFlags |= 8192; } return node; } @@ -17740,7 +18246,7 @@ var ts; : node; } function createNewExpression(expression, typeArguments, argumentsArray) { - var node = createBaseExpression(204); + var node = createBaseExpression(206); node.expression = parenthesizerRules().parenthesizeExpressionOfNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(argumentsArray) : undefined; @@ -17748,7 +18254,7 @@ var ts; propagateChildFlags(node.expression) | propagateChildrenFlags(node.typeArguments) | propagateChildrenFlags(node.arguments) | - 8; + 16; if (node.typeArguments) { node.transformFlags |= 1; } @@ -17762,7 +18268,7 @@ var ts; : node; } function createTaggedTemplateExpression(tag, typeArguments, template) { - var node = createBaseExpression(205); + var node = createBaseExpression(207); node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag); node.typeArguments = asNodeArray(typeArguments); node.template = template; @@ -17770,12 +18276,12 @@ var ts; propagateChildFlags(node.tag) | propagateChildrenFlags(node.typeArguments) | propagateChildFlags(node.template) | - 256; + 512; if (node.typeArguments) { node.transformFlags |= 1; } if (ts.hasInvalidEscape(node.template)) { - node.transformFlags |= 32; + node.transformFlags |= 64; } return node; } @@ -17787,7 +18293,7 @@ var ts; : node; } function createTypeAssertion(type, expression) { - var node = createBaseExpression(206); + var node = createBaseExpression(208); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.type = type; node.transformFlags |= @@ -17803,7 +18309,7 @@ var ts; : node; } function createParenthesizedExpression(expression) { - var node = createBaseExpression(207); + var node = createBaseExpression(209); node.expression = expression; node.transformFlags = propagateChildFlags(node.expression); return node; @@ -17814,7 +18320,7 @@ var ts; : node; } function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(208, undefined, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(210, undefined, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; node.transformFlags |= propagateChildFlags(node.asteriskToken); if (node.typeParameters) { @@ -17822,14 +18328,14 @@ var ts; } if (ts.modifiersToFlags(node.modifiers) & 256) { if (node.asteriskToken) { - node.transformFlags |= 32; + node.transformFlags |= 64; } else { - node.transformFlags |= 64; + node.transformFlags |= 128; } } else if (node.asteriskToken) { - node.transformFlags |= 512; + node.transformFlags |= 1024; } return node; } @@ -17845,13 +18351,13 @@ var ts; : node; } function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createBaseFunctionLikeDeclaration(209, undefined, modifiers, undefined, typeParameters, parameters, type, parenthesizerRules().parenthesizeConciseBodyOfArrowFunction(body)); + var node = createBaseFunctionLikeDeclaration(211, undefined, modifiers, undefined, typeParameters, parameters, type, parenthesizerRules().parenthesizeConciseBodyOfArrowFunction(body)); node.equalsGreaterThanToken = equalsGreaterThanToken !== null && equalsGreaterThanToken !== void 0 ? equalsGreaterThanToken : createToken(38); node.transformFlags |= propagateChildFlags(node.equalsGreaterThanToken) | - 256; + 512; if (ts.modifiersToFlags(node.modifiers) & 256) { - node.transformFlags |= 64; + node.transformFlags |= 128; } return node; } @@ -17866,7 +18372,7 @@ var ts; : node; } function createDeleteExpression(expression) { - var node = createBaseExpression(210); + var node = createBaseExpression(212); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -17877,7 +18383,7 @@ var ts; : node; } function createTypeOfExpression(expression) { - var node = createBaseExpression(211); + var node = createBaseExpression(213); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -17888,7 +18394,7 @@ var ts; : node; } function createVoidExpression(expression) { - var node = createBaseExpression(212); + var node = createBaseExpression(214); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -17899,13 +18405,13 @@ var ts; : node; } function createAwaitExpression(expression) { - var node = createBaseExpression(213); + var node = createBaseExpression(215); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression) | + 128 | 64 | - 32 | - 524288; + 1048576; return node; } function updateAwaitExpression(node, expression) { @@ -17914,7 +18420,7 @@ var ts; : node; } function createPrefixUnaryExpression(operator, operand) { - var node = createBaseExpression(214); + var node = createBaseExpression(216); node.operator = operator; node.operand = parenthesizerRules().parenthesizeOperandOfPrefixUnary(operand); node.transformFlags |= propagateChildFlags(node.operand); @@ -17926,7 +18432,7 @@ var ts; : node; } function createPostfixUnaryExpression(operand, operator) { - var node = createBaseExpression(215); + var node = createBaseExpression(217); node.operator = operator; node.operand = parenthesizerRules().parenthesizeOperandOfPostfixUnary(operand); node.transformFlags = propagateChildFlags(node.operand); @@ -17938,7 +18444,7 @@ var ts; : node; } function createBinaryExpression(left, operator, right) { - var node = createBaseExpression(216); + var node = createBaseExpression(218); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = parenthesizerRules().parenthesizeLeftSideOfBinary(operatorKind, left); @@ -17949,43 +18455,43 @@ var ts; propagateChildFlags(node.operatorToken) | propagateChildFlags(node.right); if (operatorKind === 60) { - node.transformFlags |= 8; + node.transformFlags |= 16; } - else if (operatorKind === 62) { + else if (operatorKind === 63) { if (ts.isObjectLiteralExpression(node.left)) { node.transformFlags |= - 256 | - 32 | - 1024 | + 512 | + 64 | + 2048 | propagateAssignmentPatternFlags(node.left); } else if (ts.isArrayLiteralExpression(node.left)) { node.transformFlags |= - 256 | - 1024 | + 512 | + 2048 | propagateAssignmentPatternFlags(node.left); } } - else if (operatorKind === 42 || operatorKind === 66) { - node.transformFlags |= 128; + else if (operatorKind === 42 || operatorKind === 67) { + node.transformFlags |= 256; } else if (ts.isLogicalOrCoalescingAssignmentOperator(operatorKind)) { - node.transformFlags |= 4; + node.transformFlags |= 8; } return node; } function propagateAssignmentPatternFlags(node) { - if (node.transformFlags & 16384) - return 16384; - if (node.transformFlags & 32) { + if (node.transformFlags & 32768) + return 32768; + if (node.transformFlags & 64) { 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 & 16384) { - return 16384; + if (target.transformFlags & 32768) { + return 32768; } - if (target.transformFlags & 32) { + if (target.transformFlags & 64) { var flags_1 = propagateAssignmentPatternFlags(target); if (flags_1) return flags_1; @@ -18003,7 +18509,7 @@ var ts; : node; } function createConditionalExpression(condition, questionToken, whenTrue, colonToken, whenFalse) { - var node = createBaseExpression(217); + var node = createBaseExpression(219); node.condition = parenthesizerRules().parenthesizeConditionOfConditionalExpression(condition); node.questionToken = questionToken !== null && questionToken !== void 0 ? questionToken : createToken(57); node.whenTrue = parenthesizerRules().parenthesizeBranchOfConditionalExpression(whenTrue); @@ -18027,13 +18533,13 @@ var ts; : node; } function createTemplateExpression(head, templateSpans) { - var node = createBaseExpression(218); + var node = createBaseExpression(220); node.head = head; node.templateSpans = createNodeArray(templateSpans); node.transformFlags |= propagateChildFlags(node.head) | propagateChildrenFlags(node.templateSpans) | - 256; + 512; return node; } function updateTemplateExpression(node, head, templateSpans) { @@ -18068,9 +18574,9 @@ var ts; node.text = text; node.rawText = rawText; node.templateFlags = templateFlags & 2048; - node.transformFlags |= 256; + node.transformFlags |= 512; if (node.templateFlags) { - node.transformFlags |= 32; + node.transformFlags |= 64; } return node; } @@ -18088,15 +18594,15 @@ var ts; } function createYieldExpression(asteriskToken, expression) { ts.Debug.assert(!asteriskToken || !!expression, "A `YieldExpression` with an asteriskToken must have an expression."); - var node = createBaseExpression(219); + var node = createBaseExpression(221); node.expression = expression && parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.asteriskToken = asteriskToken; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.asteriskToken) | - 256 | - 32 | - 262144; + 512 | + 64 | + 524288; return node; } function updateYieldExpression(node, asteriskToken, expression) { @@ -18106,12 +18612,12 @@ var ts; : node; } function createSpreadElement(expression) { - var node = createBaseExpression(220); + var node = createBaseExpression(222); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 256 | - 8192; + 512 | + 16384; return node; } function updateSpreadElement(node, expression) { @@ -18120,8 +18626,8 @@ var ts; : node; } function createClassExpression(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseClassLikeDeclaration(221, decorators, modifiers, name, typeParameters, heritageClauses, members); - node.transformFlags |= 256; + var node = createBaseClassLikeDeclaration(223, decorators, modifiers, name, typeParameters, heritageClauses, members); + node.transformFlags |= 512; return node; } function updateClassExpression(node, decorators, modifiers, name, typeParameters, heritageClauses, members) { @@ -18135,16 +18641,16 @@ var ts; : node; } function createOmittedExpression() { - return createBaseExpression(222); + return createBaseExpression(224); } function createExpressionWithTypeArguments(expression, typeArguments) { - var node = createBaseNode(223); + var node = createBaseNode(225); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); node.transformFlags |= propagateChildFlags(node.expression) | propagateChildrenFlags(node.typeArguments) | - 256; + 512; return node; } function updateExpressionWithTypeArguments(node, expression, typeArguments) { @@ -18154,7 +18660,7 @@ var ts; : node; } function createAsExpression(expression, type) { - var node = createBaseExpression(224); + var node = createBaseExpression(226); node.expression = expression; node.type = type; node.transformFlags |= @@ -18170,7 +18676,7 @@ var ts; : node; } function createNonNullExpression(expression) { - var node = createBaseExpression(225); + var node = createBaseExpression(227); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= propagateChildFlags(node.expression) | @@ -18186,7 +18692,7 @@ var ts; : node; } function createNonNullChain(expression) { - var node = createBaseExpression(225); + var node = createBaseExpression(227); node.flags |= 32; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= @@ -18201,15 +18707,15 @@ var ts; : node; } function createMetaProperty(keywordToken, name) { - var node = createBaseExpression(226); + var node = createBaseExpression(228); node.keywordToken = keywordToken; node.name = name; node.transformFlags |= propagateChildFlags(node.name); switch (keywordToken) { - case 102: - node.transformFlags |= 256; + case 103: + node.transformFlags |= 512; break; - case 99: + case 100: node.transformFlags |= 4; break; default: @@ -18223,13 +18729,13 @@ var ts; : node; } function createTemplateSpan(expression, literal) { - var node = createBaseNode(228); + var node = createBaseNode(230); node.expression = expression; node.literal = literal; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.literal) | - 256; + 512; return node; } function updateTemplateSpan(node, expression, literal) { @@ -18239,12 +18745,12 @@ var ts; : node; } function createSemicolonClassElement() { - var node = createBaseNode(229); - node.transformFlags |= 256; + var node = createBaseNode(231); + node.transformFlags |= 512; return node; } function createBlock(statements, multiLine) { - var node = createBaseNode(230); + var node = createBaseNode(232); node.statements = createNodeArray(statements); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.statements); @@ -18256,7 +18762,7 @@ var ts; : node; } function createVariableStatement(modifiers, declarationList) { - var node = createBaseDeclaration(232, undefined, modifiers); + var node = createBaseDeclaration(234, undefined, modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; node.transformFlags |= propagateChildFlags(node.declarationList); @@ -18272,10 +18778,10 @@ var ts; : node; } function createEmptyStatement() { - return createBaseNode(231); + return createBaseNode(233); } function createExpressionStatement(expression) { - var node = createBaseNode(233); + var node = createBaseNode(235); node.expression = parenthesizerRules().parenthesizeExpressionOfExpressionStatement(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -18286,7 +18792,7 @@ var ts; : node; } function createIfStatement(expression, thenStatement, elseStatement) { - var node = createBaseNode(234); + var node = createBaseNode(236); node.expression = expression; node.thenStatement = asEmbeddedStatement(thenStatement); node.elseStatement = asEmbeddedStatement(elseStatement); @@ -18304,7 +18810,7 @@ var ts; : node; } function createDoStatement(statement, expression) { - var node = createBaseNode(235); + var node = createBaseNode(237); node.statement = asEmbeddedStatement(statement); node.expression = expression; node.transformFlags |= @@ -18319,7 +18825,7 @@ var ts; : node; } function createWhileStatement(expression, statement) { - var node = createBaseNode(236); + var node = createBaseNode(238); node.expression = expression; node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -18334,7 +18840,7 @@ var ts; : node; } function createForStatement(initializer, condition, incrementor, statement) { - var node = createBaseNode(237); + var node = createBaseNode(239); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -18355,7 +18861,7 @@ var ts; : node; } function createForInStatement(initializer, expression, statement) { - var node = createBaseNode(238); + var node = createBaseNode(240); node.initializer = initializer; node.expression = expression; node.statement = asEmbeddedStatement(statement); @@ -18373,7 +18879,7 @@ var ts; : node; } function createForOfStatement(awaitModifier, initializer, expression, statement) { - var node = createBaseNode(239); + var node = createBaseNode(241); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); @@ -18383,9 +18889,9 @@ var ts; propagateChildFlags(node.initializer) | propagateChildFlags(node.expression) | propagateChildFlags(node.statement) | - 256; + 512; if (awaitModifier) - node.transformFlags |= 32; + node.transformFlags |= 64; return node; } function updateForOfStatement(node, awaitModifier, initializer, expression, statement) { @@ -18397,11 +18903,11 @@ var ts; : node; } function createContinueStatement(label) { - var node = createBaseNode(240); + var node = createBaseNode(242); node.label = asName(label); node.transformFlags |= propagateChildFlags(node.label) | - 1048576; + 2097152; return node; } function updateContinueStatement(node, label) { @@ -18410,11 +18916,11 @@ var ts; : node; } function createBreakStatement(label) { - var node = createBaseNode(241); + var node = createBaseNode(243); node.label = asName(label); node.transformFlags |= propagateChildFlags(node.label) | - 1048576; + 2097152; return node; } function updateBreakStatement(node, label) { @@ -18423,12 +18929,12 @@ var ts; : node; } function createReturnStatement(expression) { - var node = createBaseNode(242); + var node = createBaseNode(244); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression) | - 32 | - 1048576; + 64 | + 2097152; return node; } function updateReturnStatement(node, expression) { @@ -18437,7 +18943,7 @@ var ts; : node; } function createWithStatement(expression, statement) { - var node = createBaseNode(243); + var node = createBaseNode(245); node.expression = expression; node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -18452,7 +18958,7 @@ var ts; : node; } function createSwitchStatement(expression, caseBlock) { - var node = createBaseNode(244); + var node = createBaseNode(246); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.caseBlock = caseBlock; node.transformFlags |= @@ -18467,7 +18973,7 @@ var ts; : node; } function createLabeledStatement(label, statement) { - var node = createBaseNode(245); + var node = createBaseNode(247); node.label = asName(label); node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -18482,7 +18988,7 @@ var ts; : node; } function createThrowStatement(expression) { - var node = createBaseNode(246); + var node = createBaseNode(248); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -18493,7 +18999,7 @@ var ts; : node; } function createTryStatement(tryBlock, catchClause, finallyBlock) { - var node = createBaseNode(247); + var node = createBaseNode(249); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -18511,10 +19017,10 @@ var ts; : node; } function createDebuggerStatement() { - return createBaseNode(248); + return createBaseNode(250); } function createVariableDeclaration(name, exclamationToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(249, undefined, undefined, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); + var node = createBaseVariableLikeDeclaration(251, undefined, undefined, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.exclamationToken = exclamationToken; node.transformFlags |= propagateChildFlags(node.exclamationToken); if (exclamationToken) { @@ -18532,16 +19038,16 @@ var ts; } function createVariableDeclarationList(declarations, flags) { if (flags === void 0) { flags = 0; } - var node = createBaseNode(250); + var node = createBaseNode(252); node.flags |= flags & 3; node.declarations = createNodeArray(declarations); node.transformFlags |= propagateChildrenFlags(node.declarations) | - 1048576; + 2097152; if (flags & 3) { node.transformFlags |= - 256 | - 65536; + 512 | + 131072; } return node; } @@ -18551,7 +19057,7 @@ var ts; : node; } function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(251, decorators, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(253, decorators, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; if (!node.body || ts.modifiersToFlags(node.modifiers) & 2) { node.transformFlags = 1; @@ -18559,17 +19065,17 @@ var ts; else { node.transformFlags |= propagateChildFlags(node.asteriskToken) | - 1048576; + 2097152; if (ts.modifiersToFlags(node.modifiers) & 256) { if (node.asteriskToken) { - node.transformFlags |= 32; + node.transformFlags |= 64; } else { - node.transformFlags |= 64; + node.transformFlags |= 128; } } else if (node.asteriskToken) { - node.transformFlags |= 512; + node.transformFlags |= 1024; } } return node; @@ -18587,13 +19093,13 @@ var ts; : node; } function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseClassLikeDeclaration(252, decorators, modifiers, name, typeParameters, heritageClauses, members); + var node = createBaseClassLikeDeclaration(254, decorators, modifiers, name, typeParameters, heritageClauses, members); if (ts.modifiersToFlags(node.modifiers) & 2) { node.transformFlags = 1; } else { - node.transformFlags |= 256; - if (node.transformFlags & 2048) { + node.transformFlags |= 512; + if (node.transformFlags & 4096) { node.transformFlags |= 1; } } @@ -18610,7 +19116,7 @@ var ts; : node; } function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseInterfaceOrClassLikeDeclaration(253, decorators, modifiers, name, typeParameters, heritageClauses); + var node = createBaseInterfaceOrClassLikeDeclaration(255, decorators, modifiers, name, typeParameters, heritageClauses); node.members = createNodeArray(members); node.transformFlags = 1; return node; @@ -18626,7 +19132,7 @@ var ts; : node; } function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createBaseGenericNamedDeclaration(254, decorators, modifiers, name, typeParameters); + var node = createBaseGenericNamedDeclaration(256, decorators, modifiers, name, typeParameters); node.type = type; node.transformFlags = 1; return node; @@ -18641,12 +19147,12 @@ var ts; : node; } function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createBaseNamedDeclaration(255, decorators, modifiers, name); + var node = createBaseNamedDeclaration(257, decorators, modifiers, name); node.members = createNodeArray(members); node.transformFlags |= propagateChildrenFlags(node.members) | 1; - node.transformFlags &= ~8388608; + node.transformFlags &= ~16777216; return node; } function updateEnumDeclaration(node, decorators, modifiers, name, members) { @@ -18659,7 +19165,7 @@ var ts; } function createModuleDeclaration(decorators, modifiers, name, body, flags) { if (flags === void 0) { flags = 0; } - var node = createBaseDeclaration(256, decorators, modifiers); + var node = createBaseDeclaration(258, decorators, modifiers); node.flags |= flags & (16 | 4 | 1024); node.name = name; node.body = body; @@ -18672,7 +19178,7 @@ var ts; propagateChildFlags(node.body) | 1; } - node.transformFlags &= ~8388608; + node.transformFlags &= ~16777216; return node; } function updateModuleDeclaration(node, decorators, modifiers, name, body) { @@ -18684,7 +19190,7 @@ var ts; : node; } function createModuleBlock(statements) { - var node = createBaseNode(257); + var node = createBaseNode(259); node.statements = createNodeArray(statements); node.transformFlags |= propagateChildrenFlags(node.statements); return node; @@ -18695,7 +19201,7 @@ var ts; : node; } function createCaseBlock(clauses) { - var node = createBaseNode(258); + var node = createBaseNode(260); node.clauses = createNodeArray(clauses); node.transformFlags |= propagateChildrenFlags(node.clauses); return node; @@ -18706,7 +19212,7 @@ var ts; : node; } function createNamespaceExportDeclaration(name) { - var node = createBaseNamedDeclaration(259, undefined, undefined, name); + var node = createBaseNamedDeclaration(261, undefined, undefined, name); node.transformFlags = 1; return node; } @@ -18716,13 +19222,13 @@ var ts; : node; } function createImportEqualsDeclaration(decorators, modifiers, isTypeOnly, name, moduleReference) { - var node = createBaseNamedDeclaration(260, decorators, modifiers, name); + var node = createBaseNamedDeclaration(262, decorators, modifiers, name); node.isTypeOnly = isTypeOnly; node.moduleReference = moduleReference; node.transformFlags |= propagateChildFlags(node.moduleReference); if (!ts.isExternalModuleReference(node.moduleReference)) node.transformFlags |= 1; - node.transformFlags &= ~8388608; + node.transformFlags &= ~16777216; return node; } function updateImportEqualsDeclaration(node, decorators, modifiers, isTypeOnly, name, moduleReference) { @@ -18735,13 +19241,13 @@ var ts; : node; } function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createBaseDeclaration(261, decorators, modifiers); + var node = createBaseDeclaration(263, decorators, modifiers); node.importClause = importClause; node.moduleSpecifier = moduleSpecifier; node.transformFlags |= propagateChildFlags(node.importClause) | propagateChildFlags(node.moduleSpecifier); - node.transformFlags &= ~8388608; + node.transformFlags &= ~16777216; return node; } function updateImportDeclaration(node, decorators, modifiers, importClause, moduleSpecifier) { @@ -18753,7 +19259,7 @@ var ts; : node; } function createImportClause(isTypeOnly, name, namedBindings) { - var node = createBaseNode(262); + var node = createBaseNode(264); node.isTypeOnly = isTypeOnly; node.name = name; node.namedBindings = namedBindings; @@ -18763,7 +19269,7 @@ var ts; if (isTypeOnly) { node.transformFlags |= 1; } - node.transformFlags &= ~8388608; + node.transformFlags &= ~16777216; return node; } function updateImportClause(node, isTypeOnly, name, namedBindings) { @@ -18774,10 +19280,10 @@ var ts; : node; } function createNamespaceImport(name) { - var node = createBaseNode(263); + var node = createBaseNode(265); node.name = name; node.transformFlags |= propagateChildFlags(node.name); - node.transformFlags &= ~8388608; + node.transformFlags &= ~16777216; return node; } function updateNamespaceImport(node, name) { @@ -18786,12 +19292,12 @@ var ts; : node; } function createNamespaceExport(name) { - var node = createBaseNode(269); + var node = createBaseNode(271); node.name = name; node.transformFlags |= propagateChildFlags(node.name) | 4; - node.transformFlags &= ~8388608; + node.transformFlags &= ~16777216; return node; } function updateNamespaceExport(node, name) { @@ -18800,10 +19306,10 @@ var ts; : node; } function createNamedImports(elements) { - var node = createBaseNode(264); + var node = createBaseNode(266); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements); - node.transformFlags &= ~8388608; + node.transformFlags &= ~16777216; return node; } function updateNamedImports(node, elements) { @@ -18812,13 +19318,13 @@ var ts; : node; } function createImportSpecifier(propertyName, name) { - var node = createBaseNode(265); + var node = createBaseNode(267); node.propertyName = propertyName; node.name = name; node.transformFlags |= propagateChildFlags(node.propertyName) | propagateChildFlags(node.name); - node.transformFlags &= ~8388608; + node.transformFlags &= ~16777216; return node; } function updateImportSpecifier(node, propertyName, name) { @@ -18828,13 +19334,13 @@ var ts; : node; } function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createBaseDeclaration(266, decorators, modifiers); + var node = createBaseDeclaration(268, decorators, modifiers); node.isExportEquals = isExportEquals; node.expression = isExportEquals - ? parenthesizerRules().parenthesizeRightSideOfBinary(62, undefined, expression) + ? parenthesizerRules().parenthesizeRightSideOfBinary(63, undefined, expression) : parenthesizerRules().parenthesizeExpressionOfExportDefault(expression); node.transformFlags |= propagateChildFlags(node.expression); - node.transformFlags &= ~8388608; + node.transformFlags &= ~16777216; return node; } function updateExportAssignment(node, decorators, modifiers, expression) { @@ -18845,14 +19351,14 @@ var ts; : node; } function createExportDeclaration(decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier) { - var node = createBaseDeclaration(267, decorators, modifiers); + var node = createBaseDeclaration(269, decorators, modifiers); node.isTypeOnly = isTypeOnly; node.exportClause = exportClause; node.moduleSpecifier = moduleSpecifier; node.transformFlags |= propagateChildFlags(node.exportClause) | propagateChildFlags(node.moduleSpecifier); - node.transformFlags &= ~8388608; + node.transformFlags &= ~16777216; return node; } function updateExportDeclaration(node, decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier) { @@ -18865,10 +19371,10 @@ var ts; : node; } function createNamedExports(elements) { - var node = createBaseNode(268); + var node = createBaseNode(270); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements); - node.transformFlags &= ~8388608; + node.transformFlags &= ~16777216; return node; } function updateNamedExports(node, elements) { @@ -18877,13 +19383,13 @@ var ts; : node; } function createExportSpecifier(propertyName, name) { - var node = createBaseNode(270); + var node = createBaseNode(272); node.propertyName = asName(propertyName); node.name = asName(name); node.transformFlags |= propagateChildFlags(node.propertyName) | propagateChildFlags(node.name); - node.transformFlags &= ~8388608; + node.transformFlags &= ~16777216; return node; } function updateExportSpecifier(node, propertyName, name) { @@ -18893,14 +19399,14 @@ var ts; : node; } function createMissingDeclaration() { - var node = createBaseDeclaration(271, undefined, undefined); + var node = createBaseDeclaration(273, undefined, undefined); return node; } function createExternalModuleReference(expression) { - var node = createBaseNode(272); + var node = createBaseNode(274); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression); - node.transformFlags &= ~8388608; + node.transformFlags &= ~16777216; return node; } function updateExternalModuleReference(node, expression) { @@ -18922,7 +19428,7 @@ var ts; : node; } function createJSDocFunctionType(parameters, type) { - var node = createBaseSignatureDeclaration(308, undefined, undefined, undefined, undefined, parameters, type); + var node = createBaseSignatureDeclaration(311, undefined, undefined, undefined, undefined, parameters, type); return node; } function updateJSDocFunctionType(node, parameters, type) { @@ -18933,7 +19439,7 @@ var ts; } function createJSDocTypeLiteral(propertyTags, isArrayType) { if (isArrayType === void 0) { isArrayType = false; } - var node = createBaseNode(312); + var node = createBaseNode(316); node.jsDocPropertyTags = asNodeArray(propertyTags); node.isArrayType = isArrayType; return node; @@ -18945,7 +19451,7 @@ var ts; : node; } function createJSDocTypeExpression(type) { - var node = createBaseNode(301); + var node = createBaseNode(303); node.type = type; return node; } @@ -18955,7 +19461,7 @@ var ts; : node; } function createJSDocSignature(typeParameters, parameters, type) { - var node = createBaseNode(313); + var node = createBaseNode(317); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; @@ -18981,7 +19487,7 @@ var ts; return node; } function createJSDocTemplateTag(tagName, constraint, typeParameters, comment) { - var node = createBaseJSDocTag(330, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("template"), comment); + var node = createBaseJSDocTag(338, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("template"), comment); node.constraint = constraint; node.typeParameters = createNodeArray(typeParameters); return node; @@ -18996,7 +19502,7 @@ var ts; : node; } function createJSDocTypedefTag(tagName, typeExpression, fullName, comment) { - var node = createBaseJSDocTag(331, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("typedef"), comment); + var node = createBaseJSDocTag(339, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("typedef"), comment); node.typeExpression = typeExpression; node.fullName = fullName; node.name = ts.getJSDocTypeAliasName(fullName); @@ -19012,7 +19518,7 @@ var ts; : node; } function createJSDocParameterTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) { - var node = createBaseJSDocTag(326, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("param"), comment); + var node = createBaseJSDocTag(334, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("param"), comment); node.typeExpression = typeExpression; node.name = name; node.isNameFirst = !!isNameFirst; @@ -19031,7 +19537,7 @@ var ts; : node; } function createJSDocPropertyTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) { - var node = createBaseJSDocTag(333, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("prop"), comment); + var node = createBaseJSDocTag(341, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("prop"), comment); node.typeExpression = typeExpression; node.name = name; node.isNameFirst = !!isNameFirst; @@ -19050,7 +19556,7 @@ var ts; : node; } function createJSDocCallbackTag(tagName, typeExpression, fullName, comment) { - var node = createBaseJSDocTag(324, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("callback"), comment); + var node = createBaseJSDocTag(332, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("callback"), comment); node.typeExpression = typeExpression; node.fullName = fullName; node.name = ts.getJSDocTypeAliasName(fullName); @@ -19066,7 +19572,7 @@ var ts; : node; } function createJSDocAugmentsTag(tagName, className, comment) { - var node = createBaseJSDocTag(315, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("augments"), comment); + var node = createBaseJSDocTag(322, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("augments"), comment); node.class = className; return node; } @@ -19079,12 +19585,12 @@ var ts; : node; } function createJSDocImplementsTag(tagName, className, comment) { - var node = createBaseJSDocTag(316, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("implements"), comment); + var node = createBaseJSDocTag(323, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("implements"), comment); node.class = className; return node; } function createJSDocSeeTag(tagName, name, comment) { - var node = createBaseJSDocTag(332, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("see"), comment); + var node = createBaseJSDocTag(340, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("see"), comment); node.name = name; return node; } @@ -19096,7 +19602,7 @@ var ts; : node; } function createJSDocNameReference(name) { - var node = createBaseNode(302); + var node = createBaseNode(304); node.name = name; return node; } @@ -19105,6 +19611,54 @@ var ts; ? update(createJSDocNameReference(name), node) : node; } + function createJSDocMemberName(left, right) { + var node = createBaseNode(305); + node.left = left; + node.right = right; + node.transformFlags |= + propagateChildFlags(node.left) | + propagateChildFlags(node.right); + return node; + } + function updateJSDocMemberName(node, left, right) { + return node.left !== left + || node.right !== right + ? update(createJSDocMemberName(left, right), node) + : node; + } + function createJSDocLink(name, text) { + var node = createBaseNode(318); + node.name = name; + node.text = text; + return node; + } + function updateJSDocLink(node, name, text) { + return node.name !== name + ? update(createJSDocLink(name, text), node) + : node; + } + function createJSDocLinkCode(name, text) { + var node = createBaseNode(319); + node.name = name; + node.text = text; + return node; + } + function updateJSDocLinkCode(node, name, text) { + return node.name !== name + ? update(createJSDocLinkCode(name, text), node) + : node; + } + function createJSDocLinkPlain(name, text) { + var node = createBaseNode(320); + node.name = name; + node.text = text; + return node; + } + function updateJSDocLinkPlain(node, name, text) { + return node.name !== name + ? update(createJSDocLinkPlain(name, text), node) + : node; + } function updateJSDocImplementsTag(node, tagName, className, comment) { if (tagName === void 0) { tagName = getDefaultTagName(node); } return node.tagName !== tagName @@ -19138,7 +19692,7 @@ var ts; : node; } function createJSDocUnknownTag(tagName, comment) { - var node = createBaseJSDocTag(314, tagName, comment); + var node = createBaseJSDocTag(321, tagName, comment); return node; } function updateJSDocUnknownTag(node, tagName, comment) { @@ -19147,8 +19701,18 @@ var ts; ? update(createJSDocUnknownTag(tagName, comment), node) : node; } + function createJSDocText(text) { + var node = createBaseNode(315); + node.text = text; + return node; + } + function updateJSDocText(node, text) { + return node.text !== text + ? update(createJSDocText(text), node) + : node; + } function createJSDocComment(comment, tags) { - var node = createBaseNode(311); + var node = createBaseNode(314); node.comment = comment; node.tags = asNodeArray(tags); return node; @@ -19160,7 +19724,7 @@ var ts; : node; } function createJsxElement(openingElement, children, closingElement) { - var node = createBaseNode(273); + var node = createBaseNode(275); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -19179,7 +19743,7 @@ var ts; : node; } function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createBaseNode(274); + var node = createBaseNode(276); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -19201,7 +19765,7 @@ var ts; : node; } function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createBaseNode(275); + var node = createBaseNode(277); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -19223,7 +19787,7 @@ var ts; : node; } function createJsxClosingElement(tagName) { - var node = createBaseNode(276); + var node = createBaseNode(278); node.tagName = tagName; node.transformFlags |= propagateChildFlags(node.tagName) | @@ -19236,7 +19800,7 @@ var ts; : node; } function createJsxFragment(openingFragment, children, closingFragment) { - var node = createBaseNode(277); + var node = createBaseNode(279); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -19268,17 +19832,17 @@ var ts; : node; } function createJsxOpeningFragment() { - var node = createBaseNode(278); + var node = createBaseNode(280); node.transformFlags |= 2; return node; } function createJsxJsxClosingFragment() { - var node = createBaseNode(279); + var node = createBaseNode(281); node.transformFlags |= 2; return node; } function createJsxAttribute(name, initializer) { - var node = createBaseNode(280); + var node = createBaseNode(282); node.name = name; node.initializer = initializer; node.transformFlags |= @@ -19294,7 +19858,7 @@ var ts; : node; } function createJsxAttributes(properties) { - var node = createBaseNode(281); + var node = createBaseNode(283); node.properties = createNodeArray(properties); node.transformFlags |= propagateChildrenFlags(node.properties) | @@ -19307,7 +19871,7 @@ var ts; : node; } function createJsxSpreadAttribute(expression) { - var node = createBaseNode(282); + var node = createBaseNode(284); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression) | @@ -19320,7 +19884,7 @@ var ts; : node; } function createJsxExpression(dotDotDotToken, expression) { - var node = createBaseNode(283); + var node = createBaseNode(285); node.dotDotDotToken = dotDotDotToken; node.expression = expression; node.transformFlags |= @@ -19335,7 +19899,7 @@ var ts; : node; } function createCaseClause(expression, statements) { - var node = createBaseNode(284); + var node = createBaseNode(286); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.statements = createNodeArray(statements); node.transformFlags |= @@ -19350,7 +19914,7 @@ var ts; : node; } function createDefaultClause(statements) { - var node = createBaseNode(285); + var node = createBaseNode(287); node.statements = createNodeArray(statements); node.transformFlags = propagateChildrenFlags(node.statements); return node; @@ -19361,15 +19925,15 @@ var ts; : node; } function createHeritageClause(token, types) { - var node = createBaseNode(286); + var node = createBaseNode(288); node.token = token; node.types = createNodeArray(types); node.transformFlags |= propagateChildrenFlags(node.types); switch (token) { - case 93: - node.transformFlags |= 256; + case 94: + node.transformFlags |= 512; break; - case 116: + case 117: node.transformFlags |= 1; break; default: @@ -19383,7 +19947,7 @@ var ts; : node; } function createCatchClause(variableDeclaration, block) { - var node = createBaseNode(287); + var node = createBaseNode(289); variableDeclaration = !ts.isString(variableDeclaration) ? variableDeclaration : createVariableDeclaration(variableDeclaration, undefined, undefined, undefined); node.variableDeclaration = variableDeclaration; node.block = block; @@ -19391,7 +19955,7 @@ var ts; propagateChildFlags(node.variableDeclaration) | propagateChildFlags(node.block); if (!variableDeclaration) - node.transformFlags |= 16; + node.transformFlags |= 32; return node; } function updateCatchClause(node, variableDeclaration, block) { @@ -19401,7 +19965,7 @@ var ts; : node; } function createPropertyAssignment(name, initializer) { - var node = createBaseNamedDeclaration(288, undefined, undefined, name); + var node = createBaseNamedDeclaration(290, undefined, undefined, name); node.initializer = parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); node.transformFlags |= propagateChildFlags(node.name) | @@ -19426,11 +19990,11 @@ var ts; : node; } function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createBaseNamedDeclaration(289, undefined, undefined, name); + var node = createBaseNamedDeclaration(291, undefined, undefined, name); node.objectAssignmentInitializer = objectAssignmentInitializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(objectAssignmentInitializer); node.transformFlags |= propagateChildFlags(node.objectAssignmentInitializer) | - 256; + 512; return node; } function finishUpdateShorthandPropertyAssignment(updated, original) { @@ -19453,12 +20017,12 @@ var ts; : node; } function createSpreadAssignment(expression) { - var node = createBaseNode(290); + var node = createBaseNode(292); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 32 | - 16384; + 64 | + 32768; return node; } function updateSpreadAssignment(node, expression) { @@ -19467,7 +20031,7 @@ var ts; : node; } function createEnumMember(name, initializer) { - var node = createBaseNode(291); + var node = createBaseNode(293); node.name = asName(name); node.initializer = initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); node.transformFlags |= @@ -19483,7 +20047,7 @@ var ts; : node; } function createSourceFile(statements, endOfFileToken, flags) { - var node = baseFactory.createBaseSourceFileNode(297); + var node = baseFactory.createBaseSourceFileNode(299); node.statements = createNodeArray(statements); node.endOfFileToken = endOfFileToken; node.flags |= flags; @@ -19500,7 +20064,7 @@ var ts; return node; } function cloneSourceFileWithChanges(source, statements, isDeclarationFile, referencedFiles, typeReferences, hasNoDefaultLib, libReferences) { - var node = baseFactory.createBaseSourceFileNode(297); + var node = baseFactory.createBaseSourceFileNode(299); for (var p in source) { if (p === "emitNode" || ts.hasProperty(node, p) || !ts.hasProperty(source, p)) continue; @@ -19536,7 +20100,7 @@ var ts; } function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = createBaseNode(298); + var node = createBaseNode(300); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; @@ -19549,7 +20113,7 @@ var ts; : node; } function createUnparsedSource(prologues, syntheticReferences, texts) { - var node = createBaseNode(299); + var node = createBaseNode(301); node.prologues = prologues; node.syntheticReferences = syntheticReferences; node.texts = texts; @@ -19566,49 +20130,49 @@ var ts; return node; } function createUnparsedPrologue(data) { - return createBaseUnparsedNode(292, data); + return createBaseUnparsedNode(294, data); } function createUnparsedPrepend(data, texts) { - var node = createBaseUnparsedNode(293, data); + var node = createBaseUnparsedNode(295, data); node.texts = texts; return node; } function createUnparsedTextLike(data, internal) { - return createBaseUnparsedNode(internal ? 295 : 294, data); + return createBaseUnparsedNode(internal ? 297 : 296, data); } function createUnparsedSyntheticReference(section) { - var node = createBaseNode(296); + var node = createBaseNode(298); node.data = section.data; node.section = section; return node; } function createInputFiles() { - var node = createBaseNode(300); + var node = createBaseNode(302); node.javascriptText = ""; node.declarationText = ""; return node; } function createSyntheticExpression(type, isSpread, tupleNameSource) { if (isSpread === void 0) { isSpread = false; } - var node = createBaseNode(227); + var node = createBaseNode(229); node.type = type; node.isSpread = isSpread; node.tupleNameSource = tupleNameSource; return node; } function createSyntaxList(children) { - var node = createBaseNode(334); + var node = createBaseNode(342); node._children = children; return node; } function createNotEmittedStatement(original) { - var node = createBaseNode(335); + var node = createBaseNode(343); node.original = original; ts.setTextRange(node, original); return node; } function createPartiallyEmittedExpression(expression, original) { - var node = createBaseNode(336); + var node = createBaseNode(344); node.expression = expression; node.original = original; node.transformFlags |= @@ -19634,7 +20198,7 @@ var ts; return node; } function createCommaListExpression(elements) { - var node = createBaseNode(337); + var node = createBaseNode(345); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); node.transformFlags |= propagateChildrenFlags(node.elements); return node; @@ -19645,19 +20209,19 @@ var ts; : node; } function createEndOfDeclarationMarker(original) { - var node = createBaseNode(339); + var node = createBaseNode(347); node.emitNode = {}; node.original = original; return node; } function createMergeDeclarationMarker(original) { - var node = createBaseNode(338); + var node = createBaseNode(346); node.emitNode = {}; node.original = original; return node; } function createSyntheticReferenceExpression(expression, thisArg) { - var node = createBaseNode(340); + var node = createBaseNode(348); node.expression = expression; node.thisArg = thisArg; node.transformFlags |= @@ -19675,9 +20239,9 @@ var ts; if (node === undefined) { return node; } - var clone = ts.isSourceFile(node) ? baseFactory.createBaseSourceFileNode(297) : - ts.isIdentifier(node) ? baseFactory.createBaseIdentifierNode(78) : - ts.isPrivateIdentifier(node) ? baseFactory.createBasePrivateIdentifierNode(79) : + var clone = ts.isSourceFile(node) ? baseFactory.createBaseSourceFileNode(299) : + ts.isIdentifier(node) ? baseFactory.createBaseIdentifierNode(79) : + ts.isPrivateIdentifier(node) ? baseFactory.createBasePrivateIdentifierNode(80) : !ts.isNodeKind(node.kind) ? baseFactory.createBaseTokenNode(node.kind) : baseFactory.createBaseNode(node.kind); clone.flags |= (node.flags & ~8); @@ -19757,11 +20321,11 @@ var ts; } function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 207: return updateParenthesizedExpression(outerExpression, expression); - case 206: return updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 224: return updateAsExpression(outerExpression, expression, outerExpression.type); - case 225: return updateNonNullExpression(outerExpression, expression); - case 336: return updatePartiallyEmittedExpression(outerExpression, expression); + case 209: return updateParenthesizedExpression(outerExpression, expression); + case 208: return updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 226: return updateAsExpression(outerExpression, expression, outerExpression.type); + case 227: return updateNonNullExpression(outerExpression, expression); + case 344: return updatePartiallyEmittedExpression(outerExpression, expression); } } function isIgnorableParen(node) { @@ -19794,20 +20358,20 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = ts.skipParentheses(node); switch (target.kind) { - case 78: + case 79: return cacheIdentifiers; - case 107: + case 108: case 8: case 9: case 10: return false; - case 199: + case 201: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 200: + case 202: return target.properties.length > 0; default: return true; @@ -20088,23 +20652,24 @@ var ts; } function getDefaultTagNameForKind(kind) { switch (kind) { - case 329: return "type"; - case 327: return "returns"; - case 328: return "this"; - case 325: return "enum"; - case 317: return "author"; - case 319: return "class"; - case 320: return "public"; - case 321: return "private"; - case 322: return "protected"; - case 323: return "readonly"; - case 330: return "template"; - case 331: return "typedef"; - case 326: return "param"; - case 333: return "prop"; - case 324: return "callback"; - case 315: return "augments"; - case 316: return "implements"; + case 337: return "type"; + case 335: return "returns"; + case 336: return "this"; + case 333: return "enum"; + case 324: return "author"; + case 326: return "class"; + case 327: return "public"; + case 328: return "private"; + case 329: return "protected"; + case 330: return "readonly"; + case 331: return "override"; + case 338: return "template"; + case 339: return "typedef"; + case 334: return "param"; + case 341: return "prop"; + case 332: return "callback"; + case 322: return "augments"; + case 323: return "implements"; default: return ts.Debug.fail("Unsupported kind: " + ts.Debug.formatSyntaxKind(kind)); } @@ -20154,10 +20719,10 @@ var ts; return tokenValue; } function propagateIdentifierNameFlags(node) { - return propagateChildFlags(node) & ~8388608; + return propagateChildFlags(node) & ~16777216; } function propagatePropertyNameFlagsOfChild(node, transformFlags) { - return transformFlags | (node.transformFlags & 4096); + return transformFlags | (node.transformFlags & 8192); } function propagateChildFlags(child) { if (!child) @@ -20177,69 +20742,69 @@ var ts; children.transformFlags = subtreeFlags; } function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 172 && kind <= 195) { + if (kind >= 174 && kind <= 197) { return -2; } switch (kind) { - case 203: - case 204: - case 199: - return 536879104; - case 256: - return 546379776; - case 160: + case 205: + case 206: + case 201: + return 536887296; + case 258: + return 555888640; + case 162: return 536870912; - case 209: - return 547309568; - case 208: - case 251: - return 547313664; - case 250: - return 537018368; + case 211: + return 557748224; + case 210: + case 253: + return 557756416; case 252: - case 221: - return 536905728; - case 166: - return 547311616; - case 163: - return 536875008; + return 537165824; + case 254: + case 223: + return 536940544; + case 168: + return 557752320; case 165: + return 536879104; case 167: - case 168: - return 538923008; - case 128: - case 144: - case 155: - case 141: - case 147: + case 169: + case 170: + return 540975104; + case 129: case 145: - case 131: + case 156: + case 142: case 148: - case 113: - case 159: - case 162: + case 146: + case 132: + case 149: + case 114: + case 161: case 164: - case 169: - case 170: + case 166: case 171: - case 253: - case 254: + case 172: + case 173: + case 255: + case 256: return -2; - case 200: - return 536922112; - case 287: + case 202: + return 536973312; + case 289: + return 536903680; + case 198: + case 199: return 536887296; - case 196: - case 197: - return 536879104; - case 206: - case 224: - case 336: - case 207: - case 105: + case 208: + case 226: + case 344: + case 209: + case 106: return 536870912; - case 201: - case 202: + case 203: + case 204: return 536870912; default: return 536870912; @@ -20522,7 +21087,7 @@ var ts; var _a; if (!node.emitNode) { if (ts.isParseTreeNode(node)) { - if (node.kind === 297) { + if (node.kind === 299) { 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."); @@ -20885,13 +21450,27 @@ var ts; context.requestEmitHelper(ts.createBindingHelper); return factory.createCallExpression(getUnscopedHelperName("__exportStar"), undefined, [moduleExpression, exportsExpression]); } - function createClassPrivateFieldGetHelper(receiver, privateField) { + function createClassPrivateFieldGetHelper(receiver, state, kind, f) { context.requestEmitHelper(ts.classPrivateFieldGetHelper); - return factory.createCallExpression(getUnscopedHelperName("__classPrivateFieldGet"), undefined, [receiver, privateField]); + var args; + if (!f) { + args = [receiver, state, factory.createStringLiteral(kind)]; + } + else { + args = [receiver, state, factory.createStringLiteral(kind), f]; + } + return factory.createCallExpression(getUnscopedHelperName("__classPrivateFieldGet"), undefined, args); } - function createClassPrivateFieldSetHelper(receiver, privateField, value) { + function createClassPrivateFieldSetHelper(receiver, state, value, kind, f) { context.requestEmitHelper(ts.classPrivateFieldSetHelper); - return factory.createCallExpression(getUnscopedHelperName("__classPrivateFieldSet"), undefined, [receiver, privateField, value]); + var args; + if (!f) { + args = [receiver, state, value, factory.createStringLiteral(kind)]; + } + else { + args = [receiver, state, value, factory.createStringLiteral(kind), f]; + } + return factory.createCallExpression(getUnscopedHelperName("__classPrivateFieldSet"), undefined, args); } } ts.createEmitHelperFactory = createEmitHelperFactory; @@ -21069,13 +21648,13 @@ var ts; name: "typescript:classPrivateFieldGet", importName: "__classPrivateFieldGet", scoped: false, - text: "\n var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, privateMap) {\n if (!privateMap.has(receiver)) {\n throw new TypeError(\"attempted to get private field on non-instance\");\n }\n return privateMap.get(receiver);\n };" + text: "\n var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n };" }; ts.classPrivateFieldSetHelper = { name: "typescript:classPrivateFieldSet", importName: "__classPrivateFieldSet", scoped: false, - text: "\n var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, privateMap, value) {\n if (!privateMap.has(receiver)) {\n throw new TypeError(\"attempted to set private field on non-instance\");\n }\n privateMap.set(receiver, value);\n return value;\n };" + text: "\n var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\n };" }; var allUnscopedEmitHelpers; function getAllUnscopedEmitHelpers() { @@ -21162,748 +21741,820 @@ var ts; return node.kind === 17; } ts.isTemplateTail = isTemplateTail; - function isIdentifier(node) { - return node.kind === 78; + function isDotDotDotToken(node) { + return node.kind === 25; } - ts.isIdentifier = isIdentifier; - function isQualifiedName(node) { - return node.kind === 157; + ts.isDotDotDotToken = isDotDotDotToken; + function isCommaToken(node) { + return node.kind === 27; } - ts.isQualifiedName = isQualifiedName; - function isComputedPropertyName(node) { - return node.kind === 158; + ts.isCommaToken = isCommaToken; + function isPlusToken(node) { + return node.kind === 39; } - ts.isComputedPropertyName = isComputedPropertyName; - function isPrivateIdentifier(node) { + ts.isPlusToken = isPlusToken; + function isMinusToken(node) { + return node.kind === 40; + } + ts.isMinusToken = isMinusToken; + function isAsteriskToken(node) { + return node.kind === 41; + } + ts.isAsteriskToken = isAsteriskToken; + function isExclamationToken(node) { + return node.kind === 53; + } + ts.isExclamationToken = isExclamationToken; + function isQuestionToken(node) { + return node.kind === 57; + } + ts.isQuestionToken = isQuestionToken; + function isColonToken(node) { + return node.kind === 58; + } + ts.isColonToken = isColonToken; + function isQuestionDotToken(node) { + return node.kind === 28; + } + ts.isQuestionDotToken = isQuestionDotToken; + function isEqualsGreaterThanToken(node) { + return node.kind === 38; + } + ts.isEqualsGreaterThanToken = isEqualsGreaterThanToken; + function isIdentifier(node) { return node.kind === 79; } + ts.isIdentifier = isIdentifier; + function isPrivateIdentifier(node) { + return node.kind === 80; + } ts.isPrivateIdentifier = isPrivateIdentifier; + function isExportModifier(node) { + return node.kind === 93; + } + ts.isExportModifier = isExportModifier; + function isAsyncModifier(node) { + return node.kind === 130; + } + ts.isAsyncModifier = isAsyncModifier; + function isAssertsKeyword(node) { + return node.kind === 128; + } + ts.isAssertsKeyword = isAssertsKeyword; + function isAwaitKeyword(node) { + return node.kind === 131; + } + ts.isAwaitKeyword = isAwaitKeyword; + function isReadonlyKeyword(node) { + return node.kind === 143; + } + ts.isReadonlyKeyword = isReadonlyKeyword; + function isStaticModifier(node) { + return node.kind === 124; + } + ts.isStaticModifier = isStaticModifier; function isSuperKeyword(node) { - return node.kind === 105; + return node.kind === 106; } ts.isSuperKeyword = isSuperKeyword; function isImportKeyword(node) { - return node.kind === 99; + return node.kind === 100; } ts.isImportKeyword = isImportKeyword; - function isCommaToken(node) { - return node.kind === 27; - } - ts.isCommaToken = isCommaToken; - function isQuestionToken(node) { - return node.kind === 57; + function isQualifiedName(node) { + return node.kind === 159; } - ts.isQuestionToken = isQuestionToken; - function isExclamationToken(node) { - return node.kind === 53; + ts.isQualifiedName = isQualifiedName; + function isComputedPropertyName(node) { + return node.kind === 160; } - ts.isExclamationToken = isExclamationToken; + ts.isComputedPropertyName = isComputedPropertyName; function isTypeParameterDeclaration(node) { - return node.kind === 159; + return node.kind === 161; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; function isParameter(node) { - return node.kind === 160; + return node.kind === 162; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 161; + return node.kind === 163; } ts.isDecorator = isDecorator; function isPropertySignature(node) { - return node.kind === 162; + return node.kind === 164; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 163; + return node.kind === 165; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 164; + return node.kind === 166; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 165; + return node.kind === 167; } ts.isMethodDeclaration = isMethodDeclaration; function isConstructorDeclaration(node) { - return node.kind === 166; + return node.kind === 168; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 167; + return node.kind === 169; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 168; + return node.kind === 170; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 169; + return node.kind === 171; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 170; + return node.kind === 172; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 171; + return node.kind === 173; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; function isTypePredicateNode(node) { - return node.kind === 172; + return node.kind === 174; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 173; + return node.kind === 175; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 174; + return node.kind === 176; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 175; + return node.kind === 177; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 176; + return node.kind === 178; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 177; + return node.kind === 179; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 178; + return node.kind === 180; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 179; + return node.kind === 181; } ts.isTupleTypeNode = isTupleTypeNode; function isNamedTupleMember(node) { - return node.kind === 192; + return node.kind === 194; } ts.isNamedTupleMember = isNamedTupleMember; function isOptionalTypeNode(node) { - return node.kind === 180; + return node.kind === 182; } ts.isOptionalTypeNode = isOptionalTypeNode; function isRestTypeNode(node) { - return node.kind === 181; + return node.kind === 183; } ts.isRestTypeNode = isRestTypeNode; function isUnionTypeNode(node) { - return node.kind === 182; + return node.kind === 184; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 183; + return node.kind === 185; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 184; + return node.kind === 186; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 185; + return node.kind === 187; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 186; + return node.kind === 188; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 187; + return node.kind === 189; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 188; + return node.kind === 190; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 189; + return node.kind === 191; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 190; + return node.kind === 192; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 191; + return node.kind === 193; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 195; + return node.kind === 197; } ts.isImportTypeNode = isImportTypeNode; function isTemplateLiteralTypeSpan(node) { - return node.kind === 194; + return node.kind === 196; } ts.isTemplateLiteralTypeSpan = isTemplateLiteralTypeSpan; function isTemplateLiteralTypeNode(node) { - return node.kind === 193; + return node.kind === 195; } ts.isTemplateLiteralTypeNode = isTemplateLiteralTypeNode; function isObjectBindingPattern(node) { - return node.kind === 196; + return node.kind === 198; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 197; + return node.kind === 199; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 198; + return node.kind === 200; } ts.isBindingElement = isBindingElement; function isArrayLiteralExpression(node) { - return node.kind === 199; + return node.kind === 201; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 200; + return node.kind === 202; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 201; + return node.kind === 203; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 202; + return node.kind === 204; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 203; + return node.kind === 205; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 204; + return node.kind === 206; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 205; + return node.kind === 207; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertionExpression(node) { - return node.kind === 206; + return node.kind === 208; } ts.isTypeAssertionExpression = isTypeAssertionExpression; function isParenthesizedExpression(node) { - return node.kind === 207; + return node.kind === 209; } ts.isParenthesizedExpression = isParenthesizedExpression; function isFunctionExpression(node) { - return node.kind === 208; + return node.kind === 210; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 209; + return node.kind === 211; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 210; + return node.kind === 212; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 211; + return node.kind === 213; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 212; + return node.kind === 214; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 213; + return node.kind === 215; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 214; + return node.kind === 216; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 215; + return node.kind === 217; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 216; + return node.kind === 218; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 217; + return node.kind === 219; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 218; + return node.kind === 220; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 219; + return node.kind === 221; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 220; + return node.kind === 222; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 221; + return node.kind === 223; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 222; + return node.kind === 224; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 223; + return node.kind === 225; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 224; + return node.kind === 226; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 225; + return node.kind === 227; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 226; + return node.kind === 228; } ts.isMetaProperty = isMetaProperty; function isSyntheticExpression(node) { - return node.kind === 227; + return node.kind === 229; } ts.isSyntheticExpression = isSyntheticExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 336; + return node.kind === 344; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isCommaListExpression(node) { - return node.kind === 337; + return node.kind === 345; } ts.isCommaListExpression = isCommaListExpression; function isTemplateSpan(node) { - return node.kind === 228; + return node.kind === 230; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 229; + return node.kind === 231; } ts.isSemicolonClassElement = isSemicolonClassElement; function isBlock(node) { - return node.kind === 230; + return node.kind === 232; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 232; + return node.kind === 234; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 231; + return node.kind === 233; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 233; + return node.kind === 235; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 234; + return node.kind === 236; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 235; + return node.kind === 237; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 236; + return node.kind === 238; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 237; + return node.kind === 239; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 238; + return node.kind === 240; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 239; + return node.kind === 241; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 240; + return node.kind === 242; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 241; + return node.kind === 243; } ts.isBreakStatement = isBreakStatement; function isReturnStatement(node) { - return node.kind === 242; + return node.kind === 244; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 243; + return node.kind === 245; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 244; + return node.kind === 246; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 245; + return node.kind === 247; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 246; + return node.kind === 248; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 247; + return node.kind === 249; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 248; + return node.kind === 250; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 249; + return node.kind === 251; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 250; + return node.kind === 252; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 251; + return node.kind === 253; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 252; + return node.kind === 254; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 253; + return node.kind === 255; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 254; + return node.kind === 256; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 255; + return node.kind === 257; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 256; + return node.kind === 258; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 257; + return node.kind === 259; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 258; + return node.kind === 260; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 259; + return node.kind === 261; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 260; + return node.kind === 262; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 261; + return node.kind === 263; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 262; + return node.kind === 264; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 263; + return node.kind === 265; } ts.isNamespaceImport = isNamespaceImport; function isNamespaceExport(node) { - return node.kind === 269; + return node.kind === 271; } ts.isNamespaceExport = isNamespaceExport; function isNamedImports(node) { - return node.kind === 264; + return node.kind === 266; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 265; + return node.kind === 267; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 266; + return node.kind === 268; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 267; + return node.kind === 269; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 268; + return node.kind === 270; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 270; + return node.kind === 272; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 271; + return node.kind === 273; } ts.isMissingDeclaration = isMissingDeclaration; function isNotEmittedStatement(node) { - return node.kind === 335; + return node.kind === 343; } ts.isNotEmittedStatement = isNotEmittedStatement; function isSyntheticReference(node) { - return node.kind === 340; + return node.kind === 348; } ts.isSyntheticReference = isSyntheticReference; function isMergeDeclarationMarker(node) { - return node.kind === 338; + return node.kind === 346; } ts.isMergeDeclarationMarker = isMergeDeclarationMarker; function isEndOfDeclarationMarker(node) { - return node.kind === 339; + return node.kind === 347; } ts.isEndOfDeclarationMarker = isEndOfDeclarationMarker; function isExternalModuleReference(node) { - return node.kind === 272; + return node.kind === 274; } ts.isExternalModuleReference = isExternalModuleReference; function isJsxElement(node) { - return node.kind === 273; + return node.kind === 275; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 274; + return node.kind === 276; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 275; + return node.kind === 277; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 276; + return node.kind === 278; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 277; + return node.kind === 279; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 278; + return node.kind === 280; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 279; + return node.kind === 281; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 280; + return node.kind === 282; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 281; + return node.kind === 283; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 282; + return node.kind === 284; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 283; + return node.kind === 285; } ts.isJsxExpression = isJsxExpression; function isCaseClause(node) { - return node.kind === 284; + return node.kind === 286; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 285; + return node.kind === 287; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 286; + return node.kind === 288; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 287; + return node.kind === 289; } ts.isCatchClause = isCatchClause; function isPropertyAssignment(node) { - return node.kind === 288; + return node.kind === 290; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 289; + return node.kind === 291; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 290; + return node.kind === 292; } ts.isSpreadAssignment = isSpreadAssignment; function isEnumMember(node) { - return node.kind === 291; + return node.kind === 293; } ts.isEnumMember = isEnumMember; function isUnparsedPrepend(node) { - return node.kind === 293; + return node.kind === 295; } ts.isUnparsedPrepend = isUnparsedPrepend; function isSourceFile(node) { - return node.kind === 297; + return node.kind === 299; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 298; + return node.kind === 300; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 299; + return node.kind === 301; } ts.isUnparsedSource = isUnparsedSource; function isJSDocTypeExpression(node) { - return node.kind === 301; + return node.kind === 303; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocNameReference(node) { - return node.kind === 302; + return node.kind === 304; } ts.isJSDocNameReference = isJSDocNameReference; + function isJSDocMemberName(node) { + return node.kind === 305; + } + ts.isJSDocMemberName = isJSDocMemberName; + function isJSDocLink(node) { + return node.kind === 318; + } + ts.isJSDocLink = isJSDocLink; + function isJSDocLinkCode(node) { + return node.kind === 319; + } + ts.isJSDocLinkCode = isJSDocLinkCode; + function isJSDocLinkPlain(node) { + return node.kind === 320; + } + ts.isJSDocLinkPlain = isJSDocLinkPlain; function isJSDocAllType(node) { - return node.kind === 303; + return node.kind === 306; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 304; + return node.kind === 307; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 305; + return node.kind === 308; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 306; + return node.kind === 309; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 307; + return node.kind === 310; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 308; + return node.kind === 311; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 309; + return node.kind === 312; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDocNamepathType(node) { - return node.kind === 310; + return node.kind === 313; } ts.isJSDocNamepathType = isJSDocNamepathType; function isJSDoc(node) { - return node.kind === 311; + return node.kind === 314; } ts.isJSDoc = isJSDoc; function isJSDocTypeLiteral(node) { - return node.kind === 312; + return node.kind === 316; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocSignature(node) { - return node.kind === 313; + return node.kind === 317; } ts.isJSDocSignature = isJSDocSignature; function isJSDocAugmentsTag(node) { - return node.kind === 315; + return node.kind === 322; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocAuthorTag(node) { - return node.kind === 317; + return node.kind === 324; } ts.isJSDocAuthorTag = isJSDocAuthorTag; function isJSDocClassTag(node) { - return node.kind === 319; + return node.kind === 326; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocCallbackTag(node) { - return node.kind === 324; + return node.kind === 332; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocPublicTag(node) { - return node.kind === 320; + return node.kind === 327; } ts.isJSDocPublicTag = isJSDocPublicTag; function isJSDocPrivateTag(node) { - return node.kind === 321; + return node.kind === 328; } ts.isJSDocPrivateTag = isJSDocPrivateTag; function isJSDocProtectedTag(node) { - return node.kind === 322; + return node.kind === 329; } ts.isJSDocProtectedTag = isJSDocProtectedTag; function isJSDocReadonlyTag(node) { - return node.kind === 323; + return node.kind === 330; } ts.isJSDocReadonlyTag = isJSDocReadonlyTag; + function isJSDocOverrideTag(node) { + return node.kind === 331; + } + ts.isJSDocOverrideTag = isJSDocOverrideTag; function isJSDocDeprecatedTag(node) { - return node.kind === 318; + return node.kind === 325; } ts.isJSDocDeprecatedTag = isJSDocDeprecatedTag; function isJSDocSeeTag(node) { - return node.kind === 332; + return node.kind === 340; } ts.isJSDocSeeTag = isJSDocSeeTag; function isJSDocEnumTag(node) { - return node.kind === 325; + return node.kind === 333; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocParameterTag(node) { - return node.kind === 326; + return node.kind === 334; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 327; + return node.kind === 335; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocThisTag(node) { - return node.kind === 328; + return node.kind === 336; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocTypeTag(node) { - return node.kind === 329; + return node.kind === 337; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 330; + return node.kind === 338; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 331; + return node.kind === 339; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocUnknownTag(node) { - return node.kind === 314; + return node.kind === 321; } ts.isJSDocUnknownTag = isJSDocUnknownTag; function isJSDocPropertyTag(node) { - return node.kind === 333; + return node.kind === 341; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocImplementsTag(node) { - return node.kind === 316; + return node.kind === 323; } ts.isJSDocImplementsTag = isJSDocImplementsTag; function isSyntaxList(n) { - return n.kind === 334; + return n.kind === 342; } ts.isSyntaxList = isSyntaxList; })(ts || (ts = {})); @@ -21918,7 +22569,7 @@ var ts; return ts.setTextRange(factory.createElementAccessExpression(target, memberName.expression), location); } else { - var expression = ts.setTextRange(ts.isIdentifierOrPrivateIdentifier(memberName) + var expression = ts.setTextRange(ts.isMemberName(memberName) ? factory.createPropertyAccessExpression(target, memberName) : factory.createElementAccessExpression(target, memberName), memberName); ts.getOrCreateEmitNode(expression).flags |= 64; @@ -22064,14 +22715,14 @@ var ts; ts.Debug.failBadSyntaxKind(property.name, "Private identifiers are not allowed in object literals."); } switch (property.kind) { - case 167: - case 168: + case 169: + case 170: return createExpressionForAccessorDeclaration(factory, node.properties, property, receiver, !!node.multiLine); - case 288: + case 290: return createExpressionForPropertyAssignment(factory, property, receiver); - case 289: + case 291: return createExpressionForShorthandPropertyAssignment(factory, property, receiver); - case 165: + case 167: return createExpressionForMethodDeclaration(factory, property, receiver); } } @@ -22114,21 +22765,21 @@ var ts; } ts.startsWithUseStrict = startsWithUseStrict; function isCommaSequence(node) { - return node.kind === 216 && node.operatorToken.kind === 27 || - node.kind === 337; + return node.kind === 218 && node.operatorToken.kind === 27 || + node.kind === 345; } ts.isCommaSequence = isCommaSequence; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 15; } switch (node.kind) { - case 207: + case 209: return (kinds & 1) !== 0; - case 206: - case 224: + case 208: + case 226: return (kinds & 2) !== 0; - case 225: + case 227: return (kinds & 4) !== 0; - case 336: + case 344: return (kinds & 8) !== 0; } return false; @@ -22240,10 +22891,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : factory.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 261 && node.importClause) { + if (node.kind === 263 && node.importClause) { return factory.getGeneratedNameForNode(node); } - if (node.kind === 267 && node.moduleSpecifier) { + if (node.kind === 269 && node.moduleSpecifier) { return factory.getGeneratedNameForNode(node); } return undefined; @@ -22306,11 +22957,11 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 288: + case 290: return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 289: + case 291: return bindingElement.name; - case 290: + case 292: return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } return undefined; @@ -22326,11 +22977,11 @@ var ts; ts.getTargetOfBindingOrAssignmentElement = getTargetOfBindingOrAssignmentElement; function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 160: - case 198: + case 162: + case 200: return bindingElement.dotDotDotToken; - case 220: - case 290: + case 222: + case 292: return bindingElement; } return undefined; @@ -22344,7 +22995,7 @@ var ts; ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement; function tryGetPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 198: + case 200: if (bindingElement.propertyName) { var propertyName = bindingElement.propertyName; if (ts.isPrivateIdentifier(propertyName)) { @@ -22355,7 +23006,7 @@ var ts; : propertyName; } break; - case 288: + case 290: if (bindingElement.name) { var propertyName = bindingElement.name; if (ts.isPrivateIdentifier(propertyName)) { @@ -22366,7 +23017,7 @@ var ts; : propertyName; } break; - case 290: + case 292: if (bindingElement.name && ts.isPrivateIdentifier(bindingElement.name)) { return ts.Debug.failBadSyntaxKind(bindingElement.name); } @@ -22385,11 +23036,11 @@ var ts; } function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 196: - case 197: + case 198: case 199: + case 201: return name.elements; - case 200: + case 202: return name.properties; } } @@ -22408,43 +23059,253 @@ var ts; ts.getJSDocTypeAliasName = getJSDocTypeAliasName; function canHaveModifiers(node) { var kind = node.kind; - return kind === 160 - || kind === 162 - || kind === 163 + return kind === 162 || kind === 164 || kind === 165 || kind === 166 || kind === 167 || kind === 168 - || kind === 171 - || kind === 208 - || kind === 209 - || kind === 221 - || kind === 232 - || kind === 251 - || kind === 252 + || kind === 169 + || kind === 170 + || kind === 173 + || kind === 210 + || kind === 211 + || kind === 223 + || kind === 234 || kind === 253 || kind === 254 || kind === 255 || kind === 256 - || kind === 260 - || kind === 261 - || kind === 266 - || kind === 267; + || kind === 257 + || kind === 258 + || kind === 262 + || kind === 263 + || kind === 268 + || kind === 269; } ts.canHaveModifiers = canHaveModifiers; - function isExportModifier(node) { - return node.kind === 92; - } - ts.isExportModifier = isExportModifier; - function isAsyncModifier(node) { - return node.kind === 129; - } - ts.isAsyncModifier = isAsyncModifier; - function isStaticModifier(node) { - return node.kind === 123; + ts.isTypeNodeOrTypeParameterDeclaration = ts.or(ts.isTypeNode, ts.isTypeParameterDeclaration); + ts.isQuestionOrExclamationToken = ts.or(ts.isQuestionToken, ts.isExclamationToken); + ts.isIdentifierOrThisTypeNode = ts.or(ts.isIdentifier, ts.isThisTypeNode); + ts.isReadonlyKeywordOrPlusOrMinusToken = ts.or(ts.isReadonlyKeyword, ts.isPlusToken, ts.isMinusToken); + ts.isQuestionOrPlusOrMinusToken = ts.or(ts.isQuestionToken, ts.isPlusToken, ts.isMinusToken); + ts.isModuleName = ts.or(ts.isIdentifier, ts.isStringLiteral); + function isLiteralTypeLikeExpression(node) { + var kind = node.kind; + return kind === 104 + || kind === 110 + || kind === 95 + || ts.isLiteralExpression(node) + || ts.isPrefixUnaryExpression(node); + } + ts.isLiteralTypeLikeExpression = isLiteralTypeLikeExpression; + function isExponentiationOperator(kind) { + return kind === 42; + } + function isMultiplicativeOperator(kind) { + return kind === 41 + || kind === 43 + || kind === 44; + } + function isMultiplicativeOperatorOrHigher(kind) { + return isExponentiationOperator(kind) + || isMultiplicativeOperator(kind); + } + function isAdditiveOperator(kind) { + return kind === 39 + || kind === 40; + } + function isAdditiveOperatorOrHigher(kind) { + return isAdditiveOperator(kind) + || isMultiplicativeOperatorOrHigher(kind); + } + function isShiftOperator(kind) { + return kind === 47 + || kind === 48 + || kind === 49; + } + function isShiftOperatorOrHigher(kind) { + return isShiftOperator(kind) + || isAdditiveOperatorOrHigher(kind); + } + function isRelationalOperator(kind) { + return kind === 29 + || kind === 32 + || kind === 31 + || kind === 33 + || kind === 102 + || kind === 101; + } + function isRelationalOperatorOrHigher(kind) { + return isRelationalOperator(kind) + || isShiftOperatorOrHigher(kind); + } + function isEqualityOperator(kind) { + return kind === 34 + || kind === 36 + || kind === 35 + || kind === 37; + } + function isEqualityOperatorOrHigher(kind) { + return isEqualityOperator(kind) + || isRelationalOperatorOrHigher(kind); + } + function isBitwiseOperator(kind) { + return kind === 50 + || kind === 51 + || kind === 52; + } + function isBitwiseOperatorOrHigher(kind) { + return isBitwiseOperator(kind) + || isEqualityOperatorOrHigher(kind); + } + function isLogicalOperator(kind) { + return kind === 55 + || kind === 56; + } + function isLogicalOperatorOrHigher(kind) { + return isLogicalOperator(kind) + || isBitwiseOperatorOrHigher(kind); + } + function isAssignmentOperatorOrHigher(kind) { + return kind === 60 + || isLogicalOperatorOrHigher(kind) + || ts.isAssignmentOperator(kind); + } + function isBinaryOperator(kind) { + return isAssignmentOperatorOrHigher(kind) + || kind === 27; + } + function isBinaryOperatorToken(node) { + return isBinaryOperator(node.kind); + } + ts.isBinaryOperatorToken = isBinaryOperatorToken; + var BinaryExpressionState; + (function (BinaryExpressionState) { + function enter(machine, stackIndex, stateStack, nodeStack, userStateStack, _resultHolder, outerState) { + var prevUserState = stackIndex > 0 ? userStateStack[stackIndex - 1] : undefined; + ts.Debug.assertEqual(stateStack[stackIndex], enter); + userStateStack[stackIndex] = machine.onEnter(nodeStack[stackIndex], prevUserState, outerState); + stateStack[stackIndex] = nextState(machine, enter); + return stackIndex; + } + BinaryExpressionState.enter = enter; + function left(machine, stackIndex, stateStack, nodeStack, userStateStack, _resultHolder, _outerState) { + ts.Debug.assertEqual(stateStack[stackIndex], left); + ts.Debug.assertIsDefined(machine.onLeft); + stateStack[stackIndex] = nextState(machine, left); + var nextNode = machine.onLeft(nodeStack[stackIndex].left, userStateStack[stackIndex], nodeStack[stackIndex]); + if (nextNode) { + checkCircularity(stackIndex, nodeStack, nextNode); + return pushStack(stackIndex, stateStack, nodeStack, userStateStack, nextNode); + } + return stackIndex; + } + BinaryExpressionState.left = left; + function operator(machine, stackIndex, stateStack, nodeStack, userStateStack, _resultHolder, _outerState) { + ts.Debug.assertEqual(stateStack[stackIndex], operator); + ts.Debug.assertIsDefined(machine.onOperator); + stateStack[stackIndex] = nextState(machine, operator); + machine.onOperator(nodeStack[stackIndex].operatorToken, userStateStack[stackIndex], nodeStack[stackIndex]); + return stackIndex; + } + BinaryExpressionState.operator = operator; + function right(machine, stackIndex, stateStack, nodeStack, userStateStack, _resultHolder, _outerState) { + ts.Debug.assertEqual(stateStack[stackIndex], right); + ts.Debug.assertIsDefined(machine.onRight); + stateStack[stackIndex] = nextState(machine, right); + var nextNode = machine.onRight(nodeStack[stackIndex].right, userStateStack[stackIndex], nodeStack[stackIndex]); + if (nextNode) { + checkCircularity(stackIndex, nodeStack, nextNode); + return pushStack(stackIndex, stateStack, nodeStack, userStateStack, nextNode); + } + return stackIndex; + } + BinaryExpressionState.right = right; + function exit(machine, stackIndex, stateStack, nodeStack, userStateStack, resultHolder, _outerState) { + ts.Debug.assertEqual(stateStack[stackIndex], exit); + stateStack[stackIndex] = nextState(machine, exit); + var result = machine.onExit(nodeStack[stackIndex], userStateStack[stackIndex]); + if (stackIndex > 0) { + stackIndex--; + if (machine.foldState) { + var side = stateStack[stackIndex] === exit ? "right" : "left"; + userStateStack[stackIndex] = machine.foldState(userStateStack[stackIndex], result, side); + } + } + else { + resultHolder.value = result; + } + return stackIndex; + } + BinaryExpressionState.exit = exit; + function done(_machine, stackIndex, stateStack, _nodeStack, _userStateStack, _resultHolder, _outerState) { + ts.Debug.assertEqual(stateStack[stackIndex], done); + return stackIndex; + } + BinaryExpressionState.done = done; + function nextState(machine, currentState) { + switch (currentState) { + case enter: + if (machine.onLeft) + return left; + case left: + if (machine.onOperator) + return operator; + case operator: + if (machine.onRight) + return right; + case right: return exit; + case exit: return done; + case done: return done; + default: ts.Debug.fail("Invalid state"); + } + } + BinaryExpressionState.nextState = nextState; + function pushStack(stackIndex, stateStack, nodeStack, userStateStack, node) { + stackIndex++; + stateStack[stackIndex] = enter; + nodeStack[stackIndex] = node; + userStateStack[stackIndex] = undefined; + return stackIndex; + } + function checkCircularity(stackIndex, nodeStack, node) { + if (ts.Debug.shouldAssert(2)) { + while (stackIndex >= 0) { + ts.Debug.assert(nodeStack[stackIndex] !== node, "Circular traversal detected."); + stackIndex--; + } + } + } + })(BinaryExpressionState || (BinaryExpressionState = {})); + var BinaryExpressionStateMachine = (function () { + function BinaryExpressionStateMachine(onEnter, onLeft, onOperator, onRight, onExit, foldState) { + this.onEnter = onEnter; + this.onLeft = onLeft; + this.onOperator = onOperator; + this.onRight = onRight; + this.onExit = onExit; + this.foldState = foldState; + } + return BinaryExpressionStateMachine; + }()); + function createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, foldState) { + var machine = new BinaryExpressionStateMachine(onEnter, onLeft, onOperator, onRight, onExit, foldState); + return trampoline; + function trampoline(node, outerState) { + var resultHolder = { value: undefined }; + var stateStack = [BinaryExpressionState.enter]; + var nodeStack = [node]; + var userStateStack = [undefined]; + var stackIndex = 0; + while (stateStack[stackIndex] !== BinaryExpressionState.done) { + stackIndex = stateStack[stackIndex](machine, stackIndex, stateStack, nodeStack, userStateStack, resultHolder, outerState); + } + ts.Debug.assertEqual(stackIndex, 0); + return resultHolder.value; + } } - ts.isStaticModifier = isStaticModifier; + ts.createBinaryExpressionTrampoline = createBinaryExpressionTrampoline; })(ts || (ts = {})); var ts; (function (ts) { @@ -22492,19 +23353,19 @@ var ts; } ts.isJSDocLikeText = isJSDocLikeText; function forEachChild(node, cbNode, cbNodes) { - if (!node || node.kind <= 156) { + if (!node || node.kind <= 158) { return; } switch (node.kind) { - case 157: + case 159: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 159: + case 161: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 289: + case 291: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -22512,9 +23373,9 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 290: + case 292: return visitNode(cbNode, node.expression); - case 160: + case 162: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -22522,7 +23383,7 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 163: + case 165: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -22530,51 +23391,51 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 162: + case 164: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 288: + case 290: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.initializer); - case 249: + case 251: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 198: + case 200: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 174: - case 175: - case 169: - case 170: + case 176: + case 177: case 171: + case 172: + case 173: 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 165: - case 164: - case 166: case 167: + case 166: case 168: - case 208: - case 251: - case 209: + case 169: + case 170: + case 210: + case 253: + case 211: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -22586,435 +23447,451 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 173: + case 175: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 172: + case 174: return visitNode(cbNode, node.assertsModifier) || visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 176: + case 178: return visitNode(cbNode, node.exprName); - case 177: + case 179: return visitNodes(cbNode, cbNodes, node.members); - case 178: + case 180: return visitNode(cbNode, node.elementType); - case 179: + case 181: return visitNodes(cbNode, cbNodes, node.elements); - case 182: - case 183: - return visitNodes(cbNode, cbNodes, node.types); case 184: + case 185: + return visitNodes(cbNode, cbNodes, node.types); + case 186: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 185: + case 187: return visitNode(cbNode, node.typeParameter); - case 195: + case 197: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 186: case 188: + case 190: return visitNode(cbNode, node.type); - case 189: + case 191: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 190: + case 192: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.nameType) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 191: + case 193: return visitNode(cbNode, node.literal); - case 192: + case 194: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 196: - case 197: - return visitNodes(cbNode, cbNodes, node.elements); + case 198: case 199: return visitNodes(cbNode, cbNodes, node.elements); - case 200: - return visitNodes(cbNode, cbNodes, node.properties); case 201: + return visitNodes(cbNode, cbNodes, node.elements); + case 202: + return visitNodes(cbNode, cbNodes, node.properties); + case 203: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.name); - case 202: + case 204: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.argumentExpression); - case 203: - case 204: + case 205: + case 206: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 205: + case 207: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 206: + case 208: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 207: - return visitNode(cbNode, node.expression); - case 210: - return visitNode(cbNode, node.expression); - case 211: + case 209: return visitNode(cbNode, node.expression); case 212: return visitNode(cbNode, node.expression); + case 213: + return visitNode(cbNode, node.expression); case 214: + return visitNode(cbNode, node.expression); + case 216: return visitNode(cbNode, node.operand); - case 219: + case 221: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 213: - return visitNode(cbNode, node.expression); case 215: + return visitNode(cbNode, node.expression); + case 217: return visitNode(cbNode, node.operand); - case 216: + case 218: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 224: + case 226: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 225: + case 227: return visitNode(cbNode, node.expression); - case 226: + case 228: return visitNode(cbNode, node.name); - case 217: + case 219: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 220: + case 222: return visitNode(cbNode, node.expression); - case 230: - case 257: + case 232: + case 259: return visitNodes(cbNode, cbNodes, node.statements); - case 297: + case 299: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 232: + case 234: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 250: + case 252: return visitNodes(cbNode, cbNodes, node.declarations); - case 233: + case 235: return visitNode(cbNode, node.expression); - case 234: + case 236: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 235: + case 237: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 236: + case 238: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 237: + case 239: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 238: + case 240: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 239: + case 241: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 240: - case 241: - return visitNode(cbNode, node.label); case 242: - return visitNode(cbNode, node.expression); case 243: + return visitNode(cbNode, node.label); + case 244: + return visitNode(cbNode, node.expression); + case 245: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 244: + case 246: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 258: + case 260: return visitNodes(cbNode, cbNodes, node.clauses); - case 284: + case 286: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 285: + case 287: return visitNodes(cbNode, cbNodes, node.statements); - case 245: + case 247: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 246: + case 248: return visitNode(cbNode, node.expression); - case 247: + case 249: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 287: + case 289: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 161: + case 163: return visitNode(cbNode, node.expression); - case 252: - case 221: + case 254: + case 223: 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 253: + case 255: 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 254: + case 256: 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 255: + case 257: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 291: + case 293: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 256: + case 258: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 260: + case 262: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 261: + case 263: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 262: + case 264: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 259: + case 261: return visitNode(cbNode, node.name); - case 263: + case 265: return visitNode(cbNode, node.name); - case 269: + case 271: return visitNode(cbNode, node.name); - case 264: - case 268: + case 266: + case 270: return visitNodes(cbNode, cbNodes, node.elements); - case 267: + case 269: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 265: - case 270: + case 267: + case 272: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 266: + case 268: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 218: + case 220: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 228: + case 230: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 193: + case 195: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 194: + case 196: return visitNode(cbNode, node.type) || visitNode(cbNode, node.literal); - case 158: + case 160: return visitNode(cbNode, node.expression); - case 286: + case 288: return visitNodes(cbNode, cbNodes, node.types); - case 223: + case 225: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 272: + case 274: return visitNode(cbNode, node.expression); - case 271: + case 273: return visitNodes(cbNode, cbNodes, node.decorators); - case 337: + case 345: return visitNodes(cbNode, cbNodes, node.elements); - case 273: + case 275: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 277: + case 279: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 274: - case 275: + case 276: + case 277: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 281: + case 283: return visitNodes(cbNode, cbNodes, node.properties); - case 280: + case 282: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 282: + case 284: return visitNode(cbNode, node.expression); - case 283: + case 285: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 276: + case 278: return visitNode(cbNode, node.tagName); - case 180: - case 181: - case 301: - case 306: - case 305: - case 307: + case 182: + case 183: + case 303: case 309: - return visitNode(cbNode, node.type); case 308: + case 310: + case 312: + return visitNode(cbNode, node.type); + case 311: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 311: - return visitNodes(cbNode, cbNodes, node.tags); - case 332: + case 314: + return (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) + || visitNodes(cbNode, cbNodes, node.tags); + case 340: return visitNode(cbNode, node.tagName) || - visitNode(cbNode, node.name); - case 302: + visitNode(cbNode, node.name) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 304: return visitNode(cbNode, node.name); - case 326: - case 333: + case 305: + return visitNode(cbNode, node.left) || + visitNode(cbNode, node.right); + case 334: + case 341: return visitNode(cbNode, node.tagName) || (node.isNameFirst ? visitNode(cbNode, node.name) || - visitNode(cbNode, node.typeExpression) + visitNode(cbNode, node.typeExpression) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) : visitNode(cbNode, node.typeExpression) || - visitNode(cbNode, node.name)); - case 317: - return visitNode(cbNode, node.tagName); - case 316: + visitNode(cbNode, node.name)) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 324: return visitNode(cbNode, node.tagName) || - visitNode(cbNode, node.class); - case 315: + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 323: return visitNode(cbNode, node.tagName) || - visitNode(cbNode, node.class); - case 330: + visitNode(cbNode, node.class) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 322: + return visitNode(cbNode, node.tagName) || + visitNode(cbNode, node.class) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 338: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.constraint) || - visitNodes(cbNode, cbNodes, node.typeParameters); - case 331: + visitNodes(cbNode, cbNodes, node.typeParameters) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 339: return visitNode(cbNode, node.tagName) || (node.typeExpression && - node.typeExpression.kind === 301 + node.typeExpression.kind === 303 ? visitNode(cbNode, node.typeExpression) || - visitNode(cbNode, node.fullName) + visitNode(cbNode, node.fullName) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) : visitNode(cbNode, node.fullName) || - visitNode(cbNode, node.typeExpression)); - case 324: + visitNode(cbNode, node.typeExpression)) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 332: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.fullName) || - visitNode(cbNode, node.typeExpression); - case 327: - case 329: - case 328: - case 325: + visitNode(cbNode, node.typeExpression) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 335: + case 337: + case 336: + case 333: return visitNode(cbNode, node.tagName) || - visitNode(cbNode, node.typeExpression); - case 313: + visitNode(cbNode, node.typeExpression) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 317: return ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 312: - return ts.forEach(node.jsDocPropertyTags, cbNode); - case 314: + case 318: case 319: case 320: + return visitNode(cbNode, node.name); + case 316: + return ts.forEach(node.jsDocPropertyTags, cbNode); case 321: - case 322: - case 323: - return visitNode(cbNode, node.tagName); - case 336: + case 326: + case 327: + case 328: + case 329: + case 330: + case 325: + return visitNode(cbNode, node.tagName) + || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 344: return visitNode(cbNode, node.expression); } } ts.forEachChild = forEachChild; function forEachChildRecursively(rootNode, cbNode, cbNodes) { - var stack = [rootNode]; - while (stack.length) { - var parent = stack.pop(); - var res = visitAllPossibleChildren(parent, gatherPossibleChildren(parent)); - if (res) { - return res; - } - } - return; - function gatherPossibleChildren(node) { - var children = []; - forEachChild(node, addWorkItem, addWorkItem); - return children; - function addWorkItem(n) { - children.unshift(n); - } - } - function visitAllPossibleChildren(parent, children) { - for (var _i = 0, children_5 = children; _i < children_5.length; _i++) { - var child = children_5[_i]; - if (ts.isArray(child)) { - if (cbNodes) { - var res = cbNodes(child, parent); - if (res) { - if (res === "skip") - continue; - return res; - } - } - for (var i = child.length - 1; i >= 0; i--) { - var realChild = child[i]; - var res = cbNode(realChild, parent); - if (res) { - if (res === "skip") - continue; - return res; - } - stack.push(realChild); - } - } - else { - stack.push(child); - var res = cbNode(child, parent); + var queue = gatherPossibleChildren(rootNode); + var parents = []; + while (parents.length < queue.length) { + parents.push(rootNode); + } + while (queue.length !== 0) { + var current = queue.pop(); + var parent = parents.pop(); + if (ts.isArray(current)) { + if (cbNodes) { + var res = cbNodes(current, parent); if (res) { if (res === "skip") continue; return res; } } + for (var i = current.length - 1; i >= 0; --i) { + queue.push(current[i]); + parents.push(parent); + } + } + else { + var res = cbNode(current, parent); + if (res) { + if (res === "skip") + continue; + return res; + } + if (current.kind >= 159) { + for (var _i = 0, _a = gatherPossibleChildren(current); _i < _a.length; _i++) { + var child = _a[_i]; + queue.push(child); + parents.push(current); + } + } } } } ts.forEachChildRecursively = forEachChildRecursively; + function gatherPossibleChildren(node) { + var children = []; + forEachChild(node, addWorkItem, addWorkItem); + return children; + function addWorkItem(n) { + children.unshift(n); + } + } function createSourceFile(fileName, sourceText, languageVersion, setParentNodes, scriptKind) { if (setParentNodes === void 0) { setParentNodes = false; } - ts.tracing.push("parse", "createSourceFile", { path: fileName }, true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse", "createSourceFile", { path: fileName }, true); ts.performance.mark("beforeParse"); var result; ts.perfLogger.logStartParseSourceFile(fileName); @@ -23027,7 +23904,7 @@ var ts; ts.perfLogger.logStopParseSourceFile(); ts.performance.mark("afterParse"); ts.performance.measure("Parse", "beforeParse", "afterParse"); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; } ts.createSourceFile = createSourceFile; @@ -23103,11 +23980,12 @@ var ts; var topLevel = true; var parseErrorBeforeNextFinishedNode = false; function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes, scriptKind) { + var _a; if (setParentNodes === void 0) { setParentNodes = false; } scriptKind = ts.ensureScriptKind(fileName, scriptKind); if (scriptKind === 6) { var result_3 = parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes); - ts.convertToObjectWorker(result_3, result_3.parseDiagnostics, false, undefined, undefined); + ts.convertToObjectWorker(result_3, (_a = result_3.statements[0]) === null || _a === void 0 ? void 0 : _a.expression, result_3.parseDiagnostics, false, undefined, undefined); result_3.referencedFiles = ts.emptyArray; result_3.typeReferenceDirectives = ts.emptyArray; result_3.libReferenceDirectives = ts.emptyArray; @@ -23144,34 +24022,50 @@ var ts; endOfFileToken = parseTokenNode(); } else { - var expression = void 0; - switch (token()) { - case 22: - expression = parseArrayLiteralExpression(); - break; - case 109: - case 94: - case 103: - expression = parseTokenNode(); - break; - case 40: - if (lookAhead(function () { return nextToken() === 8 && nextToken() !== 58; })) { - expression = parsePrefixUnaryExpression(); - } - else { - expression = parseObjectLiteralExpression(); - } - break; - case 8: - case 10: - if (lookAhead(function () { return nextToken() !== 58; })) { - expression = parseLiteralNode(); + var expressions = void 0; + while (token() !== 1) { + var expression_1 = void 0; + switch (token()) { + case 22: + expression_1 = parseArrayLiteralExpression(); + break; + case 110: + case 95: + case 104: + expression_1 = parseTokenNode(); + break; + case 40: + if (lookAhead(function () { return nextToken() === 8 && nextToken() !== 58; })) { + expression_1 = parsePrefixUnaryExpression(); + } + else { + expression_1 = parseObjectLiteralExpression(); + } + break; + case 8: + case 10: + if (lookAhead(function () { return nextToken() !== 58; })) { + expression_1 = parseLiteralNode(); + break; + } + default: + expression_1 = parseObjectLiteralExpression(); break; + } + if (expressions && ts.isArray(expressions)) { + expressions.push(expression_1); + } + else if (expressions) { + expressions = [expressions, expression_1]; + } + else { + expressions = expression_1; + if (token() !== 1) { + parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token); } - default: - expression = parseObjectLiteralExpression(); - break; + } } + var expression = ts.isArray(expressions) ? finishNode(factory.createArrayLiteralExpression(expressions), pos) : ts.Debug.checkDefined(expressions); var statement = factory.createExpressionStatement(expression); finishNode(statement, pos); statements = createNodeArray([statement], pos); @@ -23352,7 +24246,7 @@ var ts; return factory.updateSourceFile(sourceFile, ts.setTextRange(factory.createNodeArray(statements), sourceFile.statements)); function containsPossibleTopLevelAwait(node) { return !(node.flags & 32768) - && !!(node.transformFlags & 8388608); + && !!(node.transformFlags & 16777216); } function findNextStatementWithAwait(statements, start) { for (var i = start; i < statements.length; i++) { @@ -23386,7 +24280,7 @@ var ts; var sourceFile = factory.createSourceFile(statements, endOfFileToken, flags); ts.setTextRangePosWidth(sourceFile, 0, sourceText.length); setExternalModuleIndicator(sourceFile); - if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 8388608) { + if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 16777216) { sourceFile = reparseTopLevelAwait(sourceFile); } sourceFile.text = sourceText; @@ -23537,6 +24431,9 @@ var ts; function reScanLessThanToken() { return currentToken = scanner.reScanLessThanToken(); } + function reScanHashToken() { + return currentToken = scanner.reScanHashToken(); + } function scanJsxIdentifier() { return currentToken = scanner.scanJsxIdentifier(); } @@ -23571,22 +24468,22 @@ var ts; return speculationHelper(callback, 0); } function isBindingIdentifier() { - if (token() === 78) { + if (token() === 79) { return true; } - return token() > 115; + return token() > 116; } function isIdentifier() { - if (token() === 78) { + if (token() === 79) { return true; } - if (token() === 124 && inYieldContext()) { + if (token() === 125 && inYieldContext()) { return false; } - if (token() === 130 && inAwaitContext()) { + if (token() === 131 && inAwaitContext()) { return false; } - return token() > 115; + return token() > 116; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -23692,11 +24589,11 @@ var ts; parseErrorAtCurrentToken(diagnosticMessage, arg0); } var pos = getNodePos(); - var result = kind === 78 ? factory.createIdentifier("", undefined, undefined) : + var result = kind === 79 ? factory.createIdentifier("", undefined, undefined) : ts.isTemplateLiteralKind(kind) ? factory.createTemplateLiteralLikeNode(kind, "", "", undefined) : kind === 8 ? factory.createNumericLiteral("", undefined) : kind === 10 ? factory.createStringLiteral("", undefined) : - kind === 271 ? factory.createMissingDeclaration() : + kind === 273 ? factory.createMissingDeclaration() : factory.createToken(kind); return finishNode(result, pos); } @@ -23708,25 +24605,29 @@ var ts; return identifier; } function createIdentifier(isIdentifier, diagnosticMessage, privateIdentifierDiagnosticMessage) { - identifierCount++; if (isIdentifier) { + identifierCount++; var pos = getNodePos(); var originalKeywordKind = token(); var text = internIdentifier(scanner.getTokenValue()); nextTokenWithoutCheck(); return finishNode(factory.createIdentifier(text, undefined, originalKeywordKind), pos); } - if (token() === 79) { + if (token() === 80) { parseErrorAtCurrentToken(privateIdentifierDiagnosticMessage || ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); return createIdentifier(true); } + if (token() === 0 && scanner.tryScan(function () { return scanner.reScanInvalidIdentifier() === 79; })) { + return createIdentifier(true); + } + identifierCount++; var reportAtCurrentPosition = token() === 1; 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(78, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg); + return createMissingNode(79, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg); } function parseBindingIdentifier(privateIdentifierDiagnosticMessage) { return createIdentifier(isBindingIdentifier(), undefined, privateIdentifierDiagnosticMessage); @@ -23751,7 +24652,7 @@ var ts; if (allowComputedPropertyNames && token() === 22) { return parseComputedPropertyName(); } - if (token() === 79) { + if (token() === 80) { return parsePrivateIdentifier(); } return parseIdentifierName(); @@ -23791,23 +24692,23 @@ var ts; } function nextTokenCanFollowModifier() { switch (token()) { - case 84: - return nextToken() === 91; - case 92: + case 85: + return nextToken() === 92; + case 93: nextToken(); - if (token() === 87) { + if (token() === 88) { return lookAhead(nextTokenCanFollowDefaultKeyword); } - if (token() === 149) { + if (token() === 150) { return lookAhead(nextTokenCanFollowExportModifier); } return canFollowExportModifier(); - case 87: + case 88: return nextTokenCanFollowDefaultKeyword(); - case 123: + case 124: return nextTokenIsOnSameLineAndCanFollowModifier(); - case 134: - case 146: + case 135: + case 147: nextToken(); return canFollowModifier(); default: @@ -23816,7 +24717,7 @@ var ts; } function canFollowExportModifier() { return token() !== 41 - && token() !== 126 + && token() !== 127 && token() !== 18 && canFollowModifier(); } @@ -23836,10 +24737,10 @@ var ts; } function nextTokenCanFollowDefaultKeyword() { nextToken(); - return token() === 83 || token() === 97 || - token() === 117 || - (token() === 125 && lookAhead(nextTokenIsClassKeywordOnSameLine)) || - (token() === 129 && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 84 || token() === 98 || + token() === 118 || + (token() === 126 && lookAhead(nextTokenIsClassKeywordOnSameLine)) || + (token() === 130 && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } function isListElement(parsingContext, inErrorRecovery) { var node = currentNode(parsingContext); @@ -23852,7 +24753,7 @@ var ts; case 3: return !(token() === 26 && inErrorRecovery) && isStartOfStatement(); case 2: - return token() === 81 || token() === 87; + return token() === 82 || token() === 88; case 4: return lookAhead(isTypeMemberStart); case 5: @@ -23919,7 +24820,7 @@ var ts; ts.Debug.assert(token() === 18); if (nextToken() === 19) { var next = nextToken(); - return next === 27 || next === 18 || next === 93 || next === 116; + return next === 27 || next === 18 || next === 94 || next === 117; } return true; } @@ -23936,8 +24837,8 @@ var ts; return ts.tokenIsIdentifierOrKeywordOrGreaterThan(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 116 || - token() === 93) { + if (token() === 117 || + token() === 94) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -23965,13 +24866,13 @@ var ts; case 23: return token() === 19; case 3: - return token() === 19 || token() === 81 || token() === 87; + return token() === 19 || token() === 82 || token() === 88; case 7: - return token() === 18 || token() === 93 || token() === 116; + return token() === 18 || token() === 94 || token() === 117; case 8: return isVariableDeclaratorListTerminator(); case 19: - return token() === 31 || token() === 20 || token() === 18 || token() === 93 || token() === 116; + return token() === 31 || token() === 20 || token() === 18 || token() === 94 || token() === 117; case 11: return token() === 21 || token() === 26; case 15: @@ -24023,8 +24924,7 @@ var ts; var listPos = getNodePos(); while (!isListTerminator(kind)) { if (isListElement(kind, false)) { - var element = parseListElement(kind, parseElement); - list.push(element); + list.push(parseListElement(kind, parseElement)); continue; } if (abortParsingListOrMoveToNextToken(kind)) { @@ -24107,17 +25007,17 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 166: - case 171: - case 167: case 168: - case 163: - case 229: - return true; + case 173: + case 169: + case 170: case 165: + case 231: + return true; + case 167: var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 78 && - methodDeclaration.name.originalKeywordKind === 132; + var nameIsConstructor = methodDeclaration.name.kind === 79 && + methodDeclaration.name.originalKeywordKind === 133; return !nameIsConstructor; } } @@ -24126,8 +25026,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 284: - case 285: + case 286: + case 287: return true; } } @@ -24136,65 +25036,65 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 251: - case 232: - case 230: + case 253: case 234: - case 233: + case 232: + case 236: + case 235: + case 248: + case 244: case 246: + case 243: case 242: - case 244: - case 241: case 240: - case 238: + case 241: case 239: - case 237: - case 236: - case 243: - case 231: - case 247: + case 238: case 245: - case 235: - case 248: - case 261: - case 260: - case 267: - case 266: - case 256: - case 252: - case 253: - case 255: + case 233: + case 249: + case 247: + case 237: + case 250: + case 263: + case 262: + case 269: + case 268: + case 258: case 254: + case 255: + case 257: + case 256: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 291; + return node.kind === 293; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 170: + case 172: + case 166: + case 173: case 164: case 171: - case 162: - case 169: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 249) { + if (node.kind !== 251) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 160) { + if (node.kind !== 162) { return false; } var parameter = node; @@ -24317,12 +25217,12 @@ var ts; if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token())) { var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); if (matchesPattern) { - return createMissingNode(78, true, ts.Diagnostics.Identifier_expected); + return createMissingNode(79, true, ts.Diagnostics.Identifier_expected); } } - if (token() === 79) { + if (token() === 80) { var node = parsePrivateIdentifier(); - return allowPrivateIdentifiers ? node : createMissingNode(78, true, ts.Diagnostics.Identifier_expected); + return allowPrivateIdentifiers ? node : createMissingNode(79, true, ts.Diagnostics.Identifier_expected); } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } @@ -24422,14 +25322,14 @@ var ts; } function typeHasArrowFunctionBlockingParseError(node) { switch (node.kind) { - case 173: + case 175: return ts.nodeIsMissing(node.typeName); - case 174: - case 175: { + case 176: + case 177: { var _a = node, parameters = _a.parameters, type = _a.type; return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 186: + case 188: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -24461,7 +25361,7 @@ var ts; token() === 19 || token() === 21 || token() === 31 || - token() === 62 || + token() === 63 || token() === 51) { return finishNode(factory.createJSDocUnknownType(), pos); } @@ -24483,7 +25383,7 @@ var ts; function parseJSDocParameter() { var pos = getNodePos(); var name; - if (token() === 107 || token() === 102) { + if (token() === 108 || token() === 103) { name = parseIdentifierName(); parseExpected(58); } @@ -24492,7 +25392,7 @@ var ts; function parseJSDocType() { scanner.setInJSDocType(true); var pos = getNodePos(); - if (parseOptional(139)) { + if (parseOptional(140)) { var moduleTag = factory.createJSDocNamepathType(undefined); terminate: while (true) { switch (token()) { @@ -24514,7 +25414,7 @@ var ts; if (hasDotDotDot) { type = finishNode(factory.createJSDocVariadicType(type), pos); } - if (token() === 62) { + if (token() === 63) { nextToken(); return finishNode(factory.createJSDocOptionalType(type), pos); } @@ -24522,7 +25422,7 @@ var ts; } function parseTypeQuery() { var pos = getNodePos(); - parseExpected(111); + parseExpected(112); return finishNode(factory.createTypeQueryNode(parseEntityName(true)), pos); } function parseTypeParameter() { @@ -24530,7 +25430,7 @@ var ts; var name = parseIdentifier(); var constraint; var expression; - if (parseOptional(93)) { + if (parseOptional(94)) { if (isStartOfType() || !isStartOfExpression()) { constraint = parseType(); } @@ -24538,7 +25438,7 @@ var ts; expression = parseUnaryExpressionOrHigher(); } } - var defaultType = parseOptional(62) ? parseType() : undefined; + var defaultType = parseOptional(63) ? parseType() : undefined; var node = factory.createTypeParameterDeclaration(name, constraint, defaultType); node.expression = expression; return finishNode(node, pos); @@ -24571,11 +25471,14 @@ var ts; function parseParameterWorker(inOuterAwaitContext) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - if (token() === 107) { - var node_1 = factory.createParameterDeclaration(undefined, undefined, undefined, createIdentifier(true), undefined, parseTypeAnnotation(), undefined); + var decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : parseDecorators(); + if (token() === 108) { + var node_1 = factory.createParameterDeclaration(decorators, undefined, undefined, createIdentifier(true), undefined, parseTypeAnnotation(), undefined); + if (decorators) { + parseErrorAtRange(decorators[0], ts.Diagnostics.Decorators_may_not_be_applied_to_this_parameters); + } return withJSDoc(finishNode(node_1, pos), hasJSDoc); } - var decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : parseDecorators(); var savedTopLevel = topLevel; topLevel = false; var modifiers = parseModifiers(); @@ -24632,14 +25535,14 @@ var ts; function parseSignatureMember(kind) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - if (kind === 170) { - parseExpected(102); + if (kind === 172) { + parseExpected(103); } var typeParameters = parseTypeParameters(); var parameters = parseParameters(4); var type = parseReturnType(58, true); parseTypeMemberSemicolon(); - var node = kind === 169 + var node = kind === 171 ? factory.createCallSignature(typeParameters, parameters, type) : factory.createConstructSignature(typeParameters, parameters, type); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -24693,14 +25596,17 @@ var ts; else { var type = parseTypeAnnotation(); node = factory.createPropertySignature(modifiers, name, questionToken, type); - if (token() === 62) + if (token() === 63) node.initializer = parseInitializer(); } parseTypeMemberSemicolon(); return withJSDoc(finishNode(node, pos), hasJSDoc); } function isTypeMemberStart() { - if (token() === 20 || token() === 29) { + if (token() === 20 || + token() === 29 || + token() === 135 || + token() === 147) { return true; } var idToken = false; @@ -24727,14 +25633,20 @@ var ts; } function parseTypeMember() { if (token() === 20 || token() === 29) { - return parseSignatureMember(169); + return parseSignatureMember(171); } - if (token() === 102 && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(170); + if (token() === 103 && lookAhead(nextTokenIsOpenParenOrLessThan)) { + return parseSignatureMember(172); } var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiers(); + if (parseContextualModifier(135)) { + return parseAccessorDeclaration(pos, hasJSDoc, undefined, modifiers, 169); + } + if (parseContextualModifier(147)) { + return parseAccessorDeclaration(pos, hasJSDoc, undefined, modifiers, 170); + } if (isIndexSignature()) { return parseIndexSignatureDeclaration(pos, hasJSDoc, undefined, modifiers); } @@ -24774,17 +25686,17 @@ var ts; function isStartOfMappedType() { nextToken(); if (token() === 39 || token() === 40) { - return nextToken() === 142; + return nextToken() === 143; } - if (token() === 142) { + if (token() === 143) { nextToken(); } - return token() === 22 && nextTokenIsIdentifier() && nextToken() === 100; + return token() === 22 && nextTokenIsIdentifier() && nextToken() === 101; } function parseMappedTypeParameter() { var pos = getNodePos(); var name = parseIdentifierName(); - parseExpected(100); + parseExpected(101); var type = parseType(); return finishNode(factory.createTypeParameterDeclaration(name, type, undefined), pos); } @@ -24792,15 +25704,15 @@ var ts; var pos = getNodePos(); parseExpected(18); var readonlyToken; - if (token() === 142 || token() === 39 || token() === 40) { + if (token() === 143 || token() === 39 || token() === 40) { readonlyToken = parseTokenNode(); - if (readonlyToken.kind !== 142) { - parseExpected(142); + if (readonlyToken.kind !== 143) { + parseExpected(143); } } parseExpected(22); var typeParameter = parseMappedTypeParameter(); - var nameType = parseOptional(126) ? parseType() : undefined; + var nameType = parseOptional(127) ? parseType() : undefined; parseExpected(23); var questionToken; if (token() === 57 || token() === 39 || token() === 40) { @@ -24864,10 +25776,10 @@ var ts; } function parseModifiersForConstructorType() { var modifiers; - if (token() === 125) { + if (token() === 126) { var pos = getNodePos(); nextToken(); - var modifier = finishNode(factory.createToken(125), pos); + var modifier = finishNode(factory.createToken(126), pos); modifiers = createNodeArray([modifier], pos); } return modifiers; @@ -24876,7 +25788,7 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiersForConstructorType(); - var isConstructorType = parseOptional(102); + var isConstructorType = parseOptional(103); var typeParameters = parseTypeParameters(); var parameters = parseParameters(4); var type = parseReturnType(38, false); @@ -24896,7 +25808,7 @@ var ts; if (negative) { nextToken(); } - var expression = token() === 109 || token() === 94 || token() === 103 ? + var expression = token() === 110 || token() === 95 || token() === 104 ? parseTokenNode() : parseLiteralLikeNode(token()); if (negative) { @@ -24906,13 +25818,13 @@ var ts; } function isStartOfTypeOfImportType() { nextToken(); - return token() === 99; + return token() === 100; } function parseImportType() { sourceFlags |= 1048576; var pos = getNodePos(); - var isTypeOf = parseOptional(111); - parseExpected(99); + var isTypeOf = parseOptional(112); + parseExpected(100); parseExpected(20); var type = parseType(); parseExpected(21); @@ -24926,18 +25838,18 @@ var ts; } function parseNonArrayType() { switch (token()) { - case 128: - case 152: - case 147: - case 144: - case 155: + case 129: + case 153: case 148: - case 131: - case 150: - case 141: case 145: + case 156: + case 149: + case 132: + case 151: + case 142: + case 146: return tryParse(parseKeywordAndNoDot) || parseTypeReference(); - case 65: + case 66: scanner.reScanAsteriskEqualsToken(); case 41: return parseJSDocAllType(); @@ -24945,7 +25857,7 @@ var ts; scanner.reScanQuestionToken(); case 57: return parseJSDocUnknownOrNullableType(); - case 97: + case 98: return parseJSDocFunctionType(); case 53: return parseJSDocNonNullableType(); @@ -24953,24 +25865,24 @@ var ts; case 10: case 8: case 9: - case 109: - case 94: - case 103: + case 110: + case 95: + case 104: return parseLiteralTypeNode(); case 40: return lookAhead(nextTokenIsNumericOrBigIntLiteral) ? parseLiteralTypeNode(true) : parseTypeReference(); - case 113: + case 114: return parseTokenNode(); - case 107: { + case 108: { var thisKeyword = parseThisTypeNode(); - if (token() === 137 && !scanner.hasPrecedingLineBreak()) { + if (token() === 138 && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 111: + case 112: return lookAhead(isStartOfTypeOfImportType) ? parseImportType() : parseTypeQuery(); case 18: return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral(); @@ -24978,9 +25890,9 @@ var ts; return parseTupleType(); case 20: return parseParenthesizedType(); - case 99: + case 100: return parseImportType(); - case 127: + case 128: return lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? parseAssertsTypePredicate() : parseTypeReference(); case 15: return parseTemplateType(); @@ -24990,44 +25902,44 @@ var ts; } function isStartOfType(inStartOfParameter) { switch (token()) { - case 128: - case 152: - case 147: - case 144: - case 155: - case 131: - case 142: + case 129: + case 153: case 148: + case 145: + case 156: + case 132: + case 143: + case 149: + case 152: + case 114: case 151: - case 113: - case 150: - case 103: - case 107: - case 111: - case 141: + case 104: + case 108: + case 112: + case 142: case 18: case 22: case 29: case 51: case 50: - case 102: + case 103: case 10: case 8: case 9: - case 109: - case 94: - case 145: + case 110: + case 95: + case 146: case 41: case 57: case 53: case 25: - case 135: - case 99: - case 127: + case 136: + case 100: + case 128: case 14: case 15: return true; - case 97: + case 98: return !inStartOfParameter; case 40: return !inStartOfParameter && lookAhead(nextTokenIsNumericOrBigIntLiteral); @@ -25086,17 +25998,17 @@ var ts; } function parseInferType() { var pos = getNodePos(); - parseExpected(135); + parseExpected(136); return finishNode(factory.createInferTypeNode(parseTypeParameterOfInferType()), pos); } function parseTypeOperatorOrHigher() { var operator = token(); switch (operator) { - case 138: - case 151: - case 142: + case 139: + case 152: + case 143: return parseTypeOperator(operator); - case 135: + case 136: return parseInferType(); } return parsePostfixTypeOrHigher(); @@ -25143,7 +26055,7 @@ var ts; } function nextTokenIsNewKeyword() { nextToken(); - return token() === 102; + return token() === 103; } function isStartOfFunctionTypeOrConstructorType() { if (token() === 29) { @@ -25152,14 +26064,14 @@ var ts; if (token() === 20 && lookAhead(isUnambiguouslyStartOfFunctionType)) { return true; } - return token() === 102 || - token() === 125 && lookAhead(nextTokenIsNewKeyword); + return token() === 103 || + token() === 126 && lookAhead(nextTokenIsNewKeyword); } function skipParameterStart() { if (ts.isModifierKind(token())) { parseModifiers(); } - if (isIdentifier() || token() === 107) { + if (isIdentifier() || token() === 108) { nextToken(); return true; } @@ -25177,7 +26089,7 @@ var ts; } if (skipParameterStart()) { if (token() === 58 || token() === 27 || - token() === 57 || token() === 62) { + token() === 57 || token() === 63) { return true; } if (token() === 21) { @@ -25202,16 +26114,16 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 137 && !scanner.hasPrecedingLineBreak()) { + if (token() === 138 && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } } function parseAssertsTypePredicate() { var pos = getNodePos(); - var assertsModifier = parseExpectedToken(127); - var parameterName = token() === 107 ? parseThisTypeNode() : parseIdentifier(); - var type = parseOptional(137) ? parseType() : undefined; + var assertsModifier = parseExpectedToken(128); + var parameterName = token() === 108 ? parseThisTypeNode() : parseIdentifier(); + var type = parseOptional(138) ? parseType() : undefined; return finishNode(factory.createTypePredicateNode(assertsModifier, parameterName, type), pos); } function parseType() { @@ -25223,7 +26135,7 @@ var ts; } var pos = getNodePos(); var type = parseUnionTypeOrHigher(); - if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(93)) { + if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(94)) { var extendsType = parseTypeWorker(true); parseExpected(57); var trueType = parseTypeWorker(); @@ -25238,11 +26150,11 @@ var ts; } function isStartOfLeftHandSideExpression() { switch (token()) { - case 107: - case 105: - case 103: - case 109: - case 94: + case 108: + case 106: + case 104: + case 110: + case 95: case 8: case 9: case 10: @@ -25251,14 +26163,14 @@ var ts; case 20: case 22: case 18: - case 97: - case 83: - case 102: + case 98: + case 84: + case 103: case 43: - case 67: - case 78: + case 68: + case 79: return true; - case 99: + case 100: return lookAhead(nextTokenIsOpenParenOrLessThanOrDot); default: return isIdentifier(); @@ -25273,15 +26185,15 @@ var ts; case 40: case 54: case 53: - case 88: - case 111: - case 113: + case 89: + case 112: + case 114: case 45: case 46: case 29: - case 130: - case 124: - case 79: + case 131: + case 125: + case 80: return true; default: if (isBinaryOperator()) { @@ -25292,8 +26204,8 @@ var ts; } function isStartOfExpressionStatement() { return token() !== 18 && - token() !== 97 && - token() !== 83 && + token() !== 98 && + token() !== 84 && token() !== 59 && isStartOfExpression(); } @@ -25314,7 +26226,7 @@ var ts; return expr; } function parseInitializer() { - return parseOptional(62) ? parseAssignmentExpressionOrHigher() : undefined; + return parseOptional(63) ? parseAssignmentExpressionOrHigher() : undefined; } function parseAssignmentExpressionOrHigher() { if (isYieldExpression()) { @@ -25326,7 +26238,7 @@ var ts; } var pos = getNodePos(); var expr = parseBinaryExpressionOrHigher(0); - if (expr.kind === 78 && token() === 38) { + if (expr.kind === 79 && token() === 38) { return parseSimpleArrowFunctionExpression(pos, expr, undefined); } if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) { @@ -25335,7 +26247,7 @@ var ts; return parseConditionalExpressionRest(expr, pos); } function isYieldExpression() { - if (token() === 124) { + if (token() === 125) { if (inYieldContext()) { return true; } @@ -25378,7 +26290,7 @@ var ts; tryParse(parsePossibleParenthesizedArrowFunctionExpression); } function isParenthesizedArrowFunctionExpression() { - if (token() === 20 || token() === 29 || token() === 129) { + if (token() === 20 || token() === 29 || token() === 130) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } if (token() === 38) { @@ -25387,7 +26299,7 @@ var ts; return 0; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 129) { + if (token() === 130) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0; @@ -25416,10 +26328,10 @@ var ts; if (second === 25) { return 1; } - if (ts.isModifierKind(second) && second !== 129 && lookAhead(nextTokenIsIdentifier)) { + if (ts.isModifierKind(second) && second !== 130 && lookAhead(nextTokenIsIdentifier)) { return 1; } - if (!isIdentifier() && second !== 107) { + if (!isIdentifier() && second !== 108) { return 0; } switch (nextToken()) { @@ -25427,12 +26339,12 @@ var ts; return 1; case 57: nextToken(); - if (token() === 58 || token() === 27 || token() === 62 || token() === 21) { + if (token() === 58 || token() === 27 || token() === 63 || token() === 21) { return 1; } return 0; case 27: - case 62: + case 63: case 21: return 2; } @@ -25446,10 +26358,10 @@ var ts; if (languageVariant === 1) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 93) { + if (third === 94) { var fourth = nextToken(); switch (fourth) { - case 62: + case 63: case 31: return false; default: @@ -25481,7 +26393,7 @@ var ts; return result; } function tryParseAsyncSimpleArrowFunctionExpression() { - if (token() === 129) { + if (token() === 130) { if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1) { var pos = getNodePos(); var asyncModifier = parseModifiersForArrowFunction(); @@ -25492,13 +26404,13 @@ var ts; return undefined; } function isUnParenthesizedAsyncArrowFunctionWorker() { - if (token() === 129) { + if (token() === 130) { nextToken(); if (scanner.hasPrecedingLineBreak() || token() === 38) { return 0; } var expr = parseBinaryExpressionOrHigher(0); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 78 && token() === 38) { + if (!scanner.hasPrecedingLineBreak() && expr.kind === 79 && token() === 38) { return 1; } } @@ -25544,8 +26456,8 @@ var ts; return parseFunctionBlock(isAsync ? 2 : 0); } if (token() !== 26 && - token() !== 97 && - token() !== 83 && + token() !== 98 && + token() !== 84 && isStartOfStatement() && !isStartOfExpressionStatement()) { return parseFunctionBlock(16 | (isAsync ? 2 : 0)); @@ -25566,7 +26478,7 @@ var ts; var colonToken; return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher), colonToken = parseExpectedToken(58), ts.nodeIsPresent(colonToken) ? parseAssignmentExpressionOrHigher() - : createMissingNode(78, false, ts.Diagnostics._0_expected, ts.tokenToString(58))), pos); + : createMissingNode(79, false, ts.Diagnostics._0_expected, ts.tokenToString(58))), pos); } function parseBinaryExpressionOrHigher(precedence) { var pos = getNodePos(); @@ -25574,7 +26486,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand, pos); } function isInOrOfKeyword(t) { - return t === 100 || t === 156; + return t === 101 || t === 158; } function parseBinaryExpressionRest(precedence, leftOperand, pos) { while (true) { @@ -25586,10 +26498,10 @@ var ts; if (!consumeCurrentOperator) { break; } - if (token() === 100 && inDisallowInContext()) { + if (token() === 101 && inDisallowInContext()) { break; } - if (token() === 126) { + if (token() === 127) { if (scanner.hasPrecedingLineBreak()) { break; } @@ -25605,7 +26517,7 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 100) { + if (inDisallowInContext() && token() === 101) { return false; } return ts.getBinaryOperatorPrecedence(token()) > 0; @@ -25633,7 +26545,7 @@ var ts; return finishNode(factory.createVoidExpression(nextTokenAnd(parseSimpleUnaryExpression)), pos); } function isAwaitExpression() { - if (token() === 130) { + if (token() === 131) { if (inAwaitContext()) { return true; } @@ -25658,7 +26570,7 @@ var ts; if (token() === 42) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 206) { + if (simpleUnaryExpression.kind === 208) { 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 { @@ -25674,15 +26586,15 @@ var ts; case 54: case 53: return parsePrefixUnaryExpression(); - case 88: + case 89: return parseDeleteExpression(); - case 111: + case 112: return parseTypeOfExpression(); - case 113: + case 114: return parseVoidExpression(); case 29: return parseTypeAssertion(); - case 130: + case 131: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -25696,10 +26608,10 @@ var ts; case 40: case 54: case 53: - case 88: - case 111: - case 113: - case 130: + case 89: + case 112: + case 114: + case 131: return false; case 29: if (languageVariant !== 1) { @@ -25729,7 +26641,7 @@ var ts; function parseLeftHandSideExpressionOrHigher() { var pos = getNodePos(); var expression; - if (token() === 99) { + if (token() === 100) { if (lookAhead(nextTokenIsOpenParenOrLessThan)) { sourceFlags |= 1048576; expression = parseTokenNode(); @@ -25737,7 +26649,7 @@ var ts; else if (lookAhead(nextTokenIsDot)) { nextToken(); nextToken(); - expression = finishNode(factory.createMetaProperty(99, parseIdentifierName()), pos); + expression = finishNode(factory.createMetaProperty(100, parseIdentifierName()), pos); sourceFlags |= 2097152; } else { @@ -25745,7 +26657,7 @@ var ts; } } else { - expression = token() === 105 ? parseSuperExpression() : parseMemberExpressionOrHigher(); + expression = token() === 106 ? parseSuperExpression() : parseMemberExpressionOrHigher(); } return parseCallExpressionRest(pos, expression); } @@ -25770,23 +26682,40 @@ var ts; parseExpectedToken(24, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); return finishNode(factory.createPropertyAccessExpression(expression, parseRightSideOfDot(true, true)), pos); } - function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext, topInvalidNodePosition) { + function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext, topInvalidNodePosition, openingTag) { var pos = getNodePos(); var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 275) { + if (opening.kind === 277) { var children = parseJsxChildren(opening); - var closingElement = parseJsxClosingElement(inExpressionContext); - if (!tagNamesAreEquivalent(opening.tagName, closingElement.tagName)) { - parseErrorAtRange(closingElement, ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNodeFromSourceText(sourceText, opening.tagName)); + var closingElement = void 0; + var lastChild = children[children.length - 1]; + if ((lastChild === null || lastChild === void 0 ? void 0 : lastChild.kind) === 275 + && !tagNamesAreEquivalent(lastChild.openingElement.tagName, lastChild.closingElement.tagName) + && tagNamesAreEquivalent(opening.tagName, lastChild.closingElement.tagName)) { + var end = lastChild.openingElement.end; + var newLast = finishNode(factory.createJsxElement(lastChild.openingElement, createNodeArray([], end, end), finishNode(factory.createJsxClosingElement(finishNode(factory.createIdentifier(""), end, end)), end, end)), lastChild.openingElement.pos, end); + children = createNodeArray(__spreadArray(__spreadArray([], children.slice(0, children.length - 1)), [newLast]), children.pos, end); + closingElement = lastChild.closingElement; + } + else { + closingElement = parseJsxClosingElement(opening, inExpressionContext); + if (!tagNamesAreEquivalent(opening.tagName, closingElement.tagName)) { + if (openingTag && ts.isJsxOpeningElement(openingTag) && tagNamesAreEquivalent(closingElement.tagName, openingTag.tagName)) { + parseErrorAtRange(opening.tagName, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, opening.tagName)); + } + else { + parseErrorAtRange(closingElement.tagName, ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNodeFromSourceText(sourceText, opening.tagName)); + } + } } result = finishNode(factory.createJsxElement(opening, children, closingElement), pos); } - else if (opening.kind === 278) { + else if (opening.kind === 280) { result = finishNode(factory.createJsxFragment(opening, parseJsxChildren(opening), parseJsxClosingFragment(inExpressionContext)), pos); } else { - ts.Debug.assert(opening.kind === 274); + ts.Debug.assert(opening.kind === 276); result = opening; } if (inExpressionContext && token() === 29) { @@ -25828,7 +26757,7 @@ var ts; case 18: return parseJsxExpression(false); case 29: - return parseJsxElementOrSelfClosingElementOrFragment(false); + return parseJsxElementOrSelfClosingElementOrFragment(false, undefined, openingTag); default: return ts.Debug.assertNever(token); } @@ -25843,6 +26772,12 @@ var ts; if (!child) break; list.push(child); + if (ts.isJsxOpeningElement(openingTag) + && (child === null || child === void 0 ? void 0 : child.kind) === 275 + && !tagNamesAreEquivalent(child.openingElement.tagName, child.closingElement.tagName) + && tagNamesAreEquivalent(openingTag.tagName, child.closingElement.tagName)) { + break; + } } parsingContext = saveParsingContext; return createNodeArray(list, listPos); @@ -25868,12 +26803,13 @@ var ts; } else { parseExpected(43); - if (inExpressionContext) { - parseExpected(31); - } - else { - parseExpected(31, undefined, false); - scanJsxText(); + if (parseExpected(31, undefined, false)) { + if (inExpressionContext) { + nextToken(); + } + else { + scanJsxText(); + } } node = factory.createJsxSelfClosingElement(tagName, typeArguments, attributes); } @@ -25882,7 +26818,7 @@ var ts; function parseJsxElementName() { var pos = getNodePos(); scanJsxIdentifier(); - var expression = token() === 107 ? + var expression = token() === 108 ? parseTokenNode() : parseIdentifierName(); while (parseOptional(24)) { expression = finishNode(factory.createPropertyAccessExpression(expression, parseRightSideOfDot(true, false)), pos); @@ -25916,7 +26852,7 @@ var ts; } scanJsxIdentifier(); var pos = getNodePos(); - return finishNode(factory.createJsxAttribute(parseIdentifierName(), token() !== 62 ? undefined : + return finishNode(factory.createJsxAttribute(parseIdentifierName(), token() !== 63 ? undefined : scanJsxAttributeValue() === 10 ? parseLiteralNode() : parseJsxExpression(true)), pos); } @@ -25928,16 +26864,17 @@ var ts; parseExpected(19); return finishNode(factory.createJsxSpreadAttribute(expression), pos); } - function parseJsxClosingElement(inExpressionContext) { + function parseJsxClosingElement(open, inExpressionContext) { var pos = getNodePos(); parseExpected(30); var tagName = parseJsxElementName(); - if (inExpressionContext) { - parseExpected(31); - } - else { - parseExpected(31, undefined, false); - scanJsxText(); + if (parseExpected(31, undefined, false)) { + if (inExpressionContext || !tagNamesAreEquivalent(open.tagName, tagName)) { + nextToken(); + } + else { + scanJsxText(); + } } return finishNode(factory.createJsxClosingElement(tagName), pos); } @@ -25947,12 +26884,13 @@ var ts; if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); } - if (inExpressionContext) { - parseExpected(31); - } - else { - parseExpected(31, undefined, false); - scanJsxText(); + if (parseExpected(31, undefined, false)) { + if (inExpressionContext) { + nextToken(); + } + else { + scanJsxText(); + } } return finishNode(factory.createJsxJsxClosingFragment(), pos); } @@ -26007,7 +26945,7 @@ var ts; function parseElementAccessExpressionRest(pos, expression, questionDotToken) { var argumentExpression; if (token() === 23) { - argumentExpression = createMissingNode(78, true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); + argumentExpression = createMissingNode(79, true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); } else { var argument = allowInAnd(parseExpression); @@ -26094,7 +27032,7 @@ var ts; continue; } if (questionDotToken) { - var name = createMissingNode(78, false, ts.Diagnostics.Identifier_expected); + var name = createMissingNode(79, false, ts.Diagnostics.Identifier_expected); expression = finishNode(factory.createPropertyAccessChain(expression, questionDotToken, name), pos); } break; @@ -26160,11 +27098,11 @@ var ts; case 10: case 14: return parseLiteralNode(); - case 107: - case 105: - case 103: - case 109: - case 94: + case 108: + case 106: + case 104: + case 110: + case 95: return parseTokenNode(); case 20: return parseParenthesizedExpression(); @@ -26172,19 +27110,19 @@ var ts; return parseArrayLiteralExpression(); case 18: return parseObjectLiteralExpression(); - case 129: + case 130: if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) { break; } return parseFunctionExpression(); - case 83: + case 84: return parseClassExpression(); - case 97: + case 98: return parseFunctionExpression(); - case 102: + case 103: return parseNewExpressionOrNewDotTarget(); case 43: - case 67: + case 68: if (reScanSlashToken() === 13) { return parseLiteralNode(); } @@ -26233,11 +27171,11 @@ var ts; } var decorators = parseDecorators(); var modifiers = parseModifiers(); - if (parseContextualModifier(134)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 167); + if (parseContextualModifier(135)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 169); } - if (parseContextualModifier(146)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 168); + if (parseContextualModifier(147)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 170); } var asteriskToken = parseOptionalToken(41); var tokenIsIdentifier = isIdentifier(); @@ -26250,7 +27188,7 @@ var ts; var node; var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58); if (isShorthandPropertyAssignment) { - var equalsToken = parseOptionalToken(62); + var equalsToken = parseOptionalToken(63); var objectAssignmentInitializer = equalsToken ? allowInAnd(parseAssignmentExpressionOrHigher) : undefined; node = factory.createShorthandPropertyAssignment(name, objectAssignmentInitializer); node.equalsToken = equalsToken; @@ -26288,7 +27226,7 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiers(); - parseExpected(97); + parseExpected(98); var asteriskToken = parseOptionalToken(41); var isGenerator = asteriskToken ? 1 : 0; var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 : 0; @@ -26311,10 +27249,10 @@ var ts; } function parseNewExpressionOrNewDotTarget() { var pos = getNodePos(); - parseExpected(102); + parseExpected(103); if (parseOptional(24)) { var name = parseIdentifierName(); - return finishNode(factory.createMetaProperty(102, name), pos); + return finishNode(factory.createMetaProperty(103, name), pos); } var expressionPos = getNodePos(); var expression = parsePrimaryExpression(); @@ -26340,6 +27278,7 @@ var ts; } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { var pos = getNodePos(); + var hasJSDoc = hasPrecedingJSDocComment(); var openBracePosition = scanner.getTokenPos(); if (parseExpected(18, diagnosticMessage) || ignoreMissingOpenBrace) { var multiLine = scanner.hasPrecedingLineBreak(); @@ -26350,11 +27289,16 @@ var ts; ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here)); } } - return finishNode(factory.createBlock(statements, multiLine), pos); + var result = withJSDoc(finishNode(factory.createBlock(statements, multiLine), pos), hasJSDoc); + if (token() === 63) { + 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(); + } + return result; } else { var statements = createMissingList(); - return finishNode(factory.createBlock(statements, undefined), pos); + return withJSDoc(finishNode(factory.createBlock(statements, undefined), pos), hasJSDoc); } } function parseFunctionBlock(flags, diagnosticMessage) { @@ -26379,47 +27323,52 @@ var ts; } function parseEmptyStatement() { var pos = getNodePos(); + var hasJSDoc = hasPrecedingJSDocComment(); parseExpected(26); - return finishNode(factory.createEmptyStatement(), pos); + return withJSDoc(finishNode(factory.createEmptyStatement(), pos), hasJSDoc); } function parseIfStatement() { var pos = getNodePos(); - parseExpected(98); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(99); parseExpected(20); var expression = allowInAnd(parseExpression); parseExpected(21); var thenStatement = parseStatement(); - var elseStatement = parseOptional(90) ? parseStatement() : undefined; - return finishNode(factory.createIfStatement(expression, thenStatement, elseStatement), pos); + var elseStatement = parseOptional(91) ? parseStatement() : undefined; + return withJSDoc(finishNode(factory.createIfStatement(expression, thenStatement, elseStatement), pos), hasJSDoc); } function parseDoStatement() { var pos = getNodePos(); - parseExpected(89); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(90); var statement = parseStatement(); - parseExpected(114); + parseExpected(115); parseExpected(20); var expression = allowInAnd(parseExpression); parseExpected(21); parseOptional(26); - return finishNode(factory.createDoStatement(statement, expression), pos); + return withJSDoc(finishNode(factory.createDoStatement(statement, expression), pos), hasJSDoc); } function parseWhileStatement() { var pos = getNodePos(); - parseExpected(114); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(115); parseExpected(20); var expression = allowInAnd(parseExpression); parseExpected(21); var statement = parseStatement(); - return finishNode(factory.createWhileStatement(expression, statement), pos); + return withJSDoc(finishNode(factory.createWhileStatement(expression, statement), pos), hasJSDoc); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(96); - var awaitToken = parseOptionalToken(130); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(97); + var awaitToken = parseOptionalToken(131); parseExpected(20); var initializer; if (token() !== 26) { - if (token() === 112 || token() === 118 || token() === 84) { + if (token() === 113 || token() === 119 || token() === 85) { initializer = parseVariableDeclarationList(true); } else { @@ -26427,12 +27376,12 @@ var ts; } } var node; - if (awaitToken ? parseExpected(156) : parseOptional(156)) { + if (awaitToken ? parseExpected(158) : parseOptional(158)) { var expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(21); node = factory.createForOfStatement(awaitToken, initializer, expression, parseStatement()); } - else if (parseOptional(100)) { + else if (parseOptional(101)) { var expression = allowInAnd(parseExpression); parseExpected(21); node = factory.createForInStatement(initializer, expression, parseStatement()); @@ -26449,37 +27398,40 @@ var ts; parseExpected(21); node = factory.createForStatement(initializer, condition, incrementor, parseStatement()); } - return finishNode(node, pos); + return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseBreakOrContinueStatement(kind) { var pos = getNodePos(); - parseExpected(kind === 241 ? 80 : 85); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(kind === 243 ? 81 : 86); var label = canParseSemicolon() ? undefined : parseIdentifier(); parseSemicolon(); - var node = kind === 241 + var node = kind === 243 ? factory.createBreakStatement(label) : factory.createContinueStatement(label); - return finishNode(node, pos); + return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseReturnStatement() { var pos = getNodePos(); - parseExpected(104); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(105); var expression = canParseSemicolon() ? undefined : allowInAnd(parseExpression); parseSemicolon(); - return finishNode(factory.createReturnStatement(expression), pos); + return withJSDoc(finishNode(factory.createReturnStatement(expression), pos), hasJSDoc); } function parseWithStatement() { var pos = getNodePos(); - parseExpected(115); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(116); parseExpected(20); var expression = allowInAnd(parseExpression); parseExpected(21); var statement = doInsideOfContext(16777216, parseStatement); - return finishNode(factory.createWithStatement(expression, statement), pos); + return withJSDoc(finishNode(factory.createWithStatement(expression, statement), pos), hasJSDoc); } function parseCaseClause() { var pos = getNodePos(); - parseExpected(81); + parseExpected(82); var expression = allowInAnd(parseExpression); parseExpected(58); var statements = parseList(3, parseStatement); @@ -26487,13 +27439,13 @@ var ts; } function parseDefaultClause() { var pos = getNodePos(); - parseExpected(87); + parseExpected(88); parseExpected(58); var statements = parseList(3, parseStatement); return finishNode(factory.createDefaultClause(statements), pos); } function parseCaseOrDefaultClause() { - return token() === 81 ? parseCaseClause() : parseDefaultClause(); + return token() === 82 ? parseCaseClause() : parseDefaultClause(); } function parseCaseBlock() { var pos = getNodePos(); @@ -26504,39 +27456,42 @@ var ts; } function parseSwitchStatement() { var pos = getNodePos(); - parseExpected(106); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(107); parseExpected(20); var expression = allowInAnd(parseExpression); parseExpected(21); var caseBlock = parseCaseBlock(); - return finishNode(factory.createSwitchStatement(expression, caseBlock), pos); + return withJSDoc(finishNode(factory.createSwitchStatement(expression, caseBlock), pos), hasJSDoc); } function parseThrowStatement() { var pos = getNodePos(); - parseExpected(108); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(109); var expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); if (expression === undefined) { identifierCount++; expression = finishNode(factory.createIdentifier(""), getNodePos()); } parseSemicolon(); - return finishNode(factory.createThrowStatement(expression), pos); + return withJSDoc(finishNode(factory.createThrowStatement(expression), pos), hasJSDoc); } function parseTryStatement() { var pos = getNodePos(); - parseExpected(110); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(111); var tryBlock = parseBlock(false); - var catchClause = token() === 82 ? parseCatchClause() : undefined; + var catchClause = token() === 83 ? parseCatchClause() : undefined; var finallyBlock; - if (!catchClause || token() === 95) { - parseExpected(95); + if (!catchClause || token() === 96) { + parseExpected(96); finallyBlock = parseBlock(false); } - return finishNode(factory.createTryStatement(tryBlock, catchClause, finallyBlock), pos); + return withJSDoc(finishNode(factory.createTryStatement(tryBlock, catchClause, finallyBlock), pos), hasJSDoc); } function parseCatchClause() { var pos = getNodePos(); - parseExpected(82); + parseExpected(83); var variableDeclaration; if (parseOptional(20)) { variableDeclaration = parseVariableDeclaration(); @@ -26550,9 +27505,10 @@ var ts; } function parseDebuggerStatement() { var pos = getNodePos(); - parseExpected(86); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(87); parseSemicolon(); - return finishNode(factory.createDebuggerStatement(), pos); + return withJSDoc(finishNode(factory.createDebuggerStatement(), pos), hasJSDoc); } function parseExpressionOrLabeledStatement() { var pos = getNodePos(); @@ -26578,11 +27534,11 @@ var ts; } function nextTokenIsClassKeywordOnSameLine() { nextToken(); - return token() === 83 && !scanner.hasPrecedingLineBreak(); + return token() === 84 && !scanner.hasPrecedingLineBreak(); } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 97 && !scanner.hasPrecedingLineBreak(); + return token() === 98 && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine() { nextToken(); @@ -26591,50 +27547,50 @@ var ts; function isDeclaration() { while (true) { switch (token()) { - case 112: - case 118: + case 113: + case 119: + case 85: + case 98: case 84: - case 97: - case 83: - case 91: + case 92: return true; - case 117: - case 149: + case 118: + case 150: return nextTokenIsIdentifierOnSameLine(); - case 139: case 140: + case 141: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 125: - case 129: - case 133: - case 120: + case 126: + case 130: + case 134: case 121: case 122: - case 142: + case 123: + case 143: nextToken(); if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 154: + case 155: nextToken(); - return token() === 18 || token() === 78 || token() === 92; - case 99: + return token() === 18 || token() === 79 || token() === 93; + case 100: nextToken(); return token() === 10 || token() === 41 || token() === 18 || ts.tokenIsIdentifierOrKeyword(token()); - case 92: + case 93: var currentToken_1 = nextToken(); - if (currentToken_1 === 149) { + if (currentToken_1 === 150) { currentToken_1 = lookAhead(nextToken); } - if (currentToken_1 === 62 || currentToken_1 === 41 || - currentToken_1 === 18 || currentToken_1 === 87 || - currentToken_1 === 126) { + if (currentToken_1 === 63 || currentToken_1 === 41 || + currentToken_1 === 18 || currentToken_1 === 88 || + currentToken_1 === 127) { return true; } continue; - case 123: + case 124: nextToken(); continue; default: @@ -26650,44 +27606,44 @@ var ts; case 59: case 26: case 18: - case 112: - case 118: - case 97: - case 83: - case 91: + case 113: + case 119: case 98: - case 89: - case 114: - case 96: - case 85: - case 80: - case 104: + case 84: + case 92: + case 99: + case 90: case 115: - case 106: - case 108: - case 110: + case 97: case 86: - case 82: - case 95: + case 81: + case 105: + case 116: + case 107: + case 109: + case 111: + case 87: + case 83: + case 96: return true; - case 99: + case 100: return isStartOfDeclaration() || lookAhead(nextTokenIsOpenParenOrLessThanOrDot); - case 84: - case 92: + case 85: + case 93: return isStartOfDeclaration(); - case 129: - case 133: - case 117: - case 139: + case 130: + case 134: + case 118: case 140: - case 149: - case 154: + case 141: + case 150: + case 155: return true; - case 122: - case 120: - case 121: case 123: - case 142: + case 121: + case 122: + case 124: + case 143: return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); default: return isStartOfExpression(); @@ -26706,62 +27662,62 @@ var ts; return parseEmptyStatement(); case 18: return parseBlock(false); - case 112: + case 113: return parseVariableStatement(getNodePos(), hasPrecedingJSDocComment(), undefined, undefined); - case 118: + case 119: if (isLetDeclaration()) { return parseVariableStatement(getNodePos(), hasPrecedingJSDocComment(), undefined, undefined); } break; - case 97: + case 98: return parseFunctionDeclaration(getNodePos(), hasPrecedingJSDocComment(), undefined, undefined); - case 83: + case 84: return parseClassDeclaration(getNodePos(), hasPrecedingJSDocComment(), undefined, undefined); - case 98: + case 99: return parseIfStatement(); - case 89: + case 90: return parseDoStatement(); - case 114: + case 115: return parseWhileStatement(); - case 96: + case 97: return parseForOrForInOrForOfStatement(); - case 85: - return parseBreakOrContinueStatement(240); - case 80: - return parseBreakOrContinueStatement(241); - case 104: + case 86: + return parseBreakOrContinueStatement(242); + case 81: + return parseBreakOrContinueStatement(243); + case 105: return parseReturnStatement(); - case 115: + case 116: return parseWithStatement(); - case 106: + case 107: return parseSwitchStatement(); - case 108: + case 109: return parseThrowStatement(); - case 110: - case 82: - case 95: + case 111: + case 83: + case 96: return parseTryStatement(); - case 86: + case 87: return parseDebuggerStatement(); case 59: return parseDeclaration(); - case 129: - case 117: - case 149: - case 139: + case 130: + case 118: + case 150: case 140: - case 133: - case 84: - case 91: + case 141: + case 134: + case 85: case 92: - case 99: - case 120: + case 93: + case 100: case 121: case 122: - case 125: case 123: - case 142: - case 154: + case 126: + case 124: + case 143: + case 155: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -26770,7 +27726,7 @@ var ts; return parseExpressionOrLabeledStatement(); } function isDeclareModifier(modifier) { - return modifier.kind === 133; + return modifier.kind === 134; } function parseDeclaration() { var isAmbient = ts.some(lookAhead(function () { return (parseDecorators(), parseModifiers()); }), isDeclareModifier); @@ -26805,40 +27761,40 @@ var ts; } function parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers) { switch (token()) { - case 112: - case 118: - case 84: + case 113: + case 119: + case 85: return parseVariableStatement(pos, hasJSDoc, decorators, modifiers); - case 97: + case 98: return parseFunctionDeclaration(pos, hasJSDoc, decorators, modifiers); - case 83: + case 84: return parseClassDeclaration(pos, hasJSDoc, decorators, modifiers); - case 117: + case 118: return parseInterfaceDeclaration(pos, hasJSDoc, decorators, modifiers); - case 149: + case 150: return parseTypeAliasDeclaration(pos, hasJSDoc, decorators, modifiers); - case 91: + case 92: return parseEnumDeclaration(pos, hasJSDoc, decorators, modifiers); - case 154: - case 139: + case 155: case 140: + case 141: return parseModuleDeclaration(pos, hasJSDoc, decorators, modifiers); - case 99: + case 100: return parseImportDeclarationOrImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers); - case 92: + case 93: nextToken(); switch (token()) { - case 87: - case 62: + case 88: + case 63: return parseExportAssignment(pos, hasJSDoc, decorators, modifiers); - case 126: + case 127: return parseNamespaceExportDeclaration(pos, hasJSDoc, decorators, modifiers); default: return parseExportDeclaration(pos, hasJSDoc, decorators, modifiers); } default: if (decorators || modifiers) { - var missing = createMissingNode(271, true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(273, true, ts.Diagnostics.Declaration_expected); ts.setTextRangePos(missing, pos); missing.decorators = decorators; missing.modifiers = modifiers; @@ -26902,7 +27858,7 @@ var ts; function isBindingIdentifierOrPrivateIdentifierOrPattern() { return token() === 18 || token() === 22 - || token() === 79 + || token() === 80 || isBindingIdentifier(); } function parseIdentifierOrPattern(privateIdentifierDiagnosticMessage) { @@ -26919,27 +27875,28 @@ var ts; } function parseVariableDeclaration(allowExclamation) { var pos = getNodePos(); + var hasJSDoc = hasPrecedingJSDocComment(); var name = parseIdentifierOrPattern(ts.Diagnostics.Private_identifiers_are_not_allowed_in_variable_declarations); var exclamationToken; - if (allowExclamation && name.kind === 78 && + if (allowExclamation && name.kind === 79 && token() === 53 && !scanner.hasPrecedingLineBreak()) { exclamationToken = parseTokenNode(); } var type = parseTypeAnnotation(); var initializer = isInOrOfKeyword(token()) ? undefined : parseInitializer(); var node = factory.createVariableDeclaration(name, exclamationToken, type, initializer); - return finishNode(node, pos); + return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseVariableDeclarationList(inForStatementInitializer) { var pos = getNodePos(); var flags = 0; switch (token()) { - case 112: + case 113: break; - case 118: + case 119: flags |= 1; break; - case 84: + case 85: flags |= 2; break; default: @@ -26947,7 +27904,7 @@ var ts; } nextToken(); var declarations; - if (token() === 156 && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 158 && lookAhead(canFollowContextualOfKeyword)) { declarations = createMissingList(); } else { @@ -26971,7 +27928,7 @@ var ts; function parseFunctionDeclaration(pos, hasJSDoc, decorators, modifiers) { var savedAwaitContext = inAwaitContext(); var modifierFlags = ts.modifiersToFlags(modifiers); - parseExpected(97); + parseExpected(98); var asteriskToken = parseOptionalToken(41); var name = modifierFlags & 512 ? parseOptionalBindingIdentifier() : parseBindingIdentifier(); var isGenerator = asteriskToken ? 1 : 0; @@ -26987,8 +27944,8 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseConstructorName() { - if (token() === 132) { - return parseExpected(132); + if (token() === 133) { + return parseExpected(133); } if (token() === 10 && lookAhead(nextToken) === 20) { return tryParse(function () { @@ -27045,11 +28002,11 @@ var ts; var parameters = parseParameters(0); var type = parseReturnType(58, false); var body = parseFunctionBlockOrSemicolon(0); - var node = kind === 167 + var node = kind === 169 ? factory.createGetAccessorDeclaration(decorators, modifiers, name, parameters, type, body) : factory.createSetAccessorDeclaration(decorators, modifiers, name, parameters, body); node.typeParameters = typeParameters; - if (type && node.kind === 168) + if (type && node.kind === 170) node.type = type; return withJSDoc(finishNode(node, pos), hasJSDoc); } @@ -27076,7 +28033,7 @@ var ts; return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 146 || idToken === 134) { + if (!ts.isKeyword(idToken) || idToken === 147 || idToken === 135) { return true; } switch (token()) { @@ -27084,7 +28041,7 @@ var ts; case 29: case 53: case 58: - case 62: + case 63: case 57: return true; default: @@ -27094,7 +28051,7 @@ var ts; return false; } function parseDecoratorExpression() { - if (inAwaitContext() && token() === 130) { + if (inAwaitContext() && token() === 131) { var pos = getNodePos(); var awaitExpression = parseIdentifier(ts.Diagnostics.Expression_expected); nextToken(); @@ -27122,7 +28079,7 @@ var ts; function tryParseModifier(permitInvalidConstAsModifier) { var pos = getNodePos(); var kind = token(); - if (token() === 84 && permitInvalidConstAsModifier) { + if (token() === 85 && permitInvalidConstAsModifier) { if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) { return undefined; } @@ -27144,10 +28101,10 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 129) { + if (token() === 130) { var pos = getNodePos(); nextToken(); - var modifier = finishNode(factory.createToken(129), pos); + var modifier = finishNode(factory.createToken(130), pos); modifiers = createNodeArray([modifier], pos); } return modifiers; @@ -27161,13 +28118,13 @@ var ts; var hasJSDoc = hasPrecedingJSDocComment(); var decorators = parseDecorators(); var modifiers = parseModifiers(true); - if (parseContextualModifier(134)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 167); + if (parseContextualModifier(135)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 169); } - if (parseContextualModifier(146)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 168); + if (parseContextualModifier(147)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 170); } - if (token() === 132 || token() === 10) { + if (token() === 133 || token() === 10) { var constructorDeclaration = tryParseConstructorDeclaration(pos, hasJSDoc, decorators, modifiers); if (constructorDeclaration) { return constructorDeclaration; @@ -27194,20 +28151,20 @@ var ts; } } if (decorators || modifiers) { - var name = createMissingNode(78, true, ts.Diagnostics.Declaration_expected); + var name = createMissingNode(79, true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, undefined); } return ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(getNodePos(), hasPrecedingJSDocComment(), undefined, undefined, 221); + return parseClassDeclarationOrExpression(getNodePos(), hasPrecedingJSDocComment(), undefined, undefined, 223); } function parseClassDeclaration(pos, hasJSDoc, decorators, modifiers) { - return parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, 252); + return parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, 254); } function parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, kind) { var savedAwaitContext = inAwaitContext(); - parseExpected(83); + parseExpected(84); var name = parseNameOfClassDeclarationOrExpression(); var typeParameters = parseTypeParameters(); if (ts.some(modifiers, ts.isExportModifier)) @@ -27222,7 +28179,7 @@ var ts; members = createMissingList(); } setAwaitContext(savedAwaitContext); - var node = kind === 252 + var node = kind === 254 ? factory.createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) : factory.createClassExpression(decorators, modifiers, name, typeParameters, heritageClauses, members); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -27233,7 +28190,7 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 116 && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 117 && lookAhead(nextTokenIsIdentifierOrKeyword); } function parseHeritageClauses() { if (isHeritageClause()) { @@ -27244,7 +28201,7 @@ var ts; function parseHeritageClause() { var pos = getNodePos(); var tok = token(); - ts.Debug.assert(tok === 93 || tok === 116); + ts.Debug.assert(tok === 94 || tok === 117); nextToken(); var types = parseDelimitedList(7, parseExpressionWithTypeArguments); return finishNode(factory.createHeritageClause(tok, types), pos); @@ -27260,13 +28217,13 @@ var ts; parseBracketedList(20, parseType, 29, 31) : undefined; } function isHeritageClause() { - return token() === 93 || token() === 116; + return token() === 94 || token() === 117; } function parseClassMembers() { return parseList(5, parseClassElement); } function parseInterfaceDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(117); + parseExpected(118); var name = parseIdentifier(); var typeParameters = parseTypeParameters(); var heritageClauses = parseHeritageClauses(); @@ -27275,11 +28232,11 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseTypeAliasDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(149); + parseExpected(150); var name = parseIdentifier(); var typeParameters = parseTypeParameters(); - parseExpected(62); - var type = token() === 136 && tryParse(parseKeywordAndNoDot) || parseType(); + parseExpected(63); + var type = token() === 137 && tryParse(parseKeywordAndNoDot) || parseType(); parseSemicolon(); var node = factory.createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -27292,7 +28249,7 @@ var ts; return withJSDoc(finishNode(factory.createEnumMember(name, initializer), pos), hasJSDoc); } function parseEnumDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(91); + parseExpected(92); var name = parseIdentifier(); var members; if (parseExpected(18)) { @@ -27329,7 +28286,7 @@ var ts; function parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers) { var flags = 0; var name; - if (token() === 154) { + if (token() === 155) { name = parseIdentifier(); flags |= 1024; } @@ -27349,14 +28306,14 @@ var ts; } function parseModuleDeclaration(pos, hasJSDoc, decorators, modifiers) { var flags = 0; - if (token() === 154) { + if (token() === 155) { return parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers); } - else if (parseOptional(140)) { + else if (parseOptional(141)) { flags |= 16; } else { - parseExpected(139); + parseExpected(140); if (token() === 10) { return parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers); } @@ -27364,7 +28321,7 @@ var ts; return parseModuleOrNamespaceDeclaration(pos, hasJSDoc, decorators, modifiers, flags); } function isExternalModuleReference() { - return token() === 143 && + return token() === 144 && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { @@ -27374,8 +28331,8 @@ var ts; return nextToken() === 43; } function parseNamespaceExportDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(126); - parseExpected(140); + parseExpected(127); + parseExpected(141); var name = parseIdentifier(); parseSemicolon(); var node = factory.createNamespaceExportDeclaration(name); @@ -27384,14 +28341,14 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseImportDeclarationOrImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(99); + parseExpected(100); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); } var isTypeOnly = false; - if (token() !== 153 && + if (token() !== 154 && (identifier === null || identifier === void 0 ? void 0 : identifier.escapedText) === "type" && (isIdentifier() || tokenAfterImportDefinitelyProducesImportDeclaration())) { isTypeOnly = true; @@ -27405,7 +28362,7 @@ var ts; token() === 41 || token() === 18) { importClause = parseImportClause(identifier, afterImportPos, isTypeOnly); - parseExpected(153); + parseExpected(154); } var moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -27416,10 +28373,10 @@ var ts; return token() === 41 || token() === 18; } function tokenAfterImportedIdentifierDefinitelyProducesImportDeclaration() { - return token() === 27 || token() === 153; + return token() === 27 || token() === 154; } function parseImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers, identifier, isTypeOnly) { - parseExpected(62); + parseExpected(63); var moduleReference = parseModuleReference(); parseSemicolon(); var node = factory.createImportEqualsDeclaration(decorators, modifiers, isTypeOnly, identifier, moduleReference); @@ -27430,7 +28387,7 @@ var ts; var namedBindings; if (!identifier || parseOptional(27)) { - namedBindings = token() === 41 ? parseNamespaceImport() : parseNamedImportsOrExports(264); + namedBindings = token() === 41 ? parseNamespaceImport() : parseNamedImportsOrExports(266); } return finishNode(factory.createImportClause(isTypeOnly, identifier, namedBindings), pos); } @@ -27441,7 +28398,7 @@ var ts; } function parseExternalModuleReference() { var pos = getNodePos(); - parseExpected(143); + parseExpected(144); parseExpected(20); var expression = parseModuleSpecifier(); parseExpected(21); @@ -27460,22 +28417,22 @@ var ts; function parseNamespaceImport() { var pos = getNodePos(); parseExpected(41); - parseExpected(126); + parseExpected(127); var name = parseIdentifier(); return finishNode(factory.createNamespaceImport(name), pos); } function parseNamedImportsOrExports(kind) { var pos = getNodePos(); - var node = kind === 264 + var node = kind === 266 ? factory.createNamedImports(parseBracketedList(23, parseImportSpecifier, 18, 19)) : factory.createNamedExports(parseBracketedList(23, parseExportSpecifier, 18, 19)); return finishNode(node, pos); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(270); + return parseImportOrExportSpecifier(272); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(265); + return parseImportOrExportSpecifier(267); } function parseImportOrExportSpecifier(kind) { var pos = getNodePos(); @@ -27485,9 +28442,9 @@ var ts; var identifierName = parseIdentifierName(); var propertyName; var name; - if (token() === 126) { + if (token() === 127) { propertyName = identifierName; - parseExpected(126); + parseExpected(127); checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -27496,10 +28453,10 @@ var ts; else { name = identifierName; } - if (kind === 265 && checkIdentifierIsKeyword) { + if (kind === 267 && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } - var node = kind === 265 + var node = kind === 267 ? factory.createImportSpecifier(propertyName, name) : factory.createExportSpecifier(propertyName, name); return finishNode(node, pos); @@ -27512,19 +28469,19 @@ var ts; setAwaitContext(true); var exportClause; var moduleSpecifier; - var isTypeOnly = parseOptional(149); + var isTypeOnly = parseOptional(150); var namespaceExportPos = getNodePos(); if (parseOptional(41)) { - if (parseOptional(126)) { + if (parseOptional(127)) { exportClause = parseNamespaceExport(namespaceExportPos); } - parseExpected(153); + parseExpected(154); moduleSpecifier = parseModuleSpecifier(); } else { - exportClause = parseNamedImportsOrExports(268); - if (token() === 153 || (token() === 10 && !scanner.hasPrecedingLineBreak())) { - parseExpected(153); + exportClause = parseNamedImportsOrExports(270); + if (token() === 154 || (token() === 10 && !scanner.hasPrecedingLineBreak())) { + parseExpected(154); moduleSpecifier = parseModuleSpecifier(); } } @@ -27537,11 +28494,11 @@ var ts; var savedAwaitContext = inAwaitContext(); setAwaitContext(true); var isExportEquals; - if (parseOptional(62)) { + if (parseOptional(63)) { isExportEquals = true; } else { - parseExpected(87); + parseExpected(88); } var expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -27555,7 +28512,7 @@ var ts; getImportMetaIfNecessary(sourceFile); } function isAnExternalModuleIndicatorNode(node) { - return hasModifierOfKind(node, 92) + return hasModifierOfKind(node, 93) || ts.isImportEqualsDeclaration(node) && ts.isExternalModuleReference(node.moduleReference) || ts.isImportDeclaration(node) || ts.isExportAssignment(node) @@ -27573,7 +28530,7 @@ var ts; return ts.some(node.modifiers, function (m) { return m.kind === kind; }); } function isImportMeta(node) { - return ts.isMetaProperty(node) && node.keywordToken === 99 && node.name.escapedText === "meta"; + return ts.isMetaProperty(node) && node.keywordToken === 100 && node.name.escapedText === "meta"; } var JSDocParser; (function (JSDocParser) { @@ -27606,7 +28563,13 @@ var ts; function parseJSDocNameReference() { var pos = getNodePos(); var hasBrace = parseOptional(18); + var p2 = getNodePos(); var entityName = parseEntityName(false); + while (token() === 80) { + reScanHashToken(); + nextTokenJSDoc(); + entityName = finishNode(factory.createJSDocMemberName(entityName, parseIdentifier()), p2); + } if (hasBrace) { parseExpectedJSDoc(19); } @@ -27656,7 +28619,10 @@ var ts; var tags; var tagsPos; var tagsEnd; + var linkEnd; + var commentsPos; var comments = []; + var parts = []; return scanner.scanRange(start + 3, length - 5, function () { var state = 1; var margin; @@ -27680,6 +28646,8 @@ var ts; case 59: if (state === 0 || state === 1) { removeTrailingWhitespace(comments); + if (!commentsPos) + commentsPos = getNodePos(); addTag(parseTag(indent)); state = 0; margin = undefined; @@ -27716,6 +28684,21 @@ var ts; break; case 1: break loop; + case 18: + state = 2; + var commentEnd = scanner.getStartPos(); + var linkStart = scanner.getTextPos() - 1; + var link = parseJSDocLink(linkStart); + if (link) { + if (!linkEnd) { + removeLeadingNewlines(comments); + } + parts.push(finishNode(factory.createJSDocText(comments.join("")), linkEnd !== null && linkEnd !== void 0 ? linkEnd : start, commentEnd)); + parts.push(link); + comments = []; + linkEnd = scanner.getTextPos(); + break; + } default: state = 2; pushComment(scanner.getTokenText()); @@ -27723,9 +28706,14 @@ var ts; } nextTokenJSDoc(); } - removeLeadingNewlines(comments); removeTrailingWhitespace(comments); - return createJSDocComment(); + if (parts.length && comments.length) { + parts.push(finishNode(factory.createJSDocText(comments.join("")), linkEnd !== null && linkEnd !== void 0 ? linkEnd : start, commentsPos)); + } + if (parts.length && tags) + ts.Debug.assertIsDefined(commentsPos, "having parsed tags implies that the end of the comment span should be set"); + var tagsArray = tags && createNodeArray(tags, tagsPos, tagsEnd); + return finishNode(factory.createJSDocComment(parts.length ? createNodeArray(parts, start, commentsPos) : comments.length ? comments.join("") : undefined, tagsArray), start, end); }); function removeLeadingNewlines(comments) { while (comments.length && (comments[0] === "\n" || comments[0] === "\r")) { @@ -27737,11 +28725,6 @@ var ts; comments.pop(); } } - function createJSDocComment() { - var comment = comments.length ? comments.join("") : undefined; - var tagsArray = tags && createNodeArray(tags, tagsPos, tagsEnd); - return finishNode(factory.createJSDocComment(comment, tagsArray), start, end); - } function isNextNonwhitespaceTokenEndOfFile() { while (true) { nextTokenJSDoc(); @@ -27820,6 +28803,9 @@ var ts; case "readonly": tag = parseSimpleTag(start, factory.createJSDocReadonlyTag, tagName, margin, indentText); break; + case "override": + tag = parseSimpleTag(start, factory.createJSDocOverrideTag, tagName, margin, indentText); + break; case "deprecated": hasDeprecatedTag = true; tag = parseSimpleTag(start, factory.createJSDocDeprecatedTag, tagName, margin, indentText); @@ -27866,8 +28852,12 @@ var ts; return parseTagComments(margin, indentText.slice(margin)); } function parseTagComments(indent, initialMargin) { + var commentsPos = getNodePos(); var comments = []; + var parts = []; + var linkEnd; var state = 0; + var previousWhitespace = true; var margin; function pushComment(text) { if (!margin) { @@ -27891,7 +28881,8 @@ var ts; indent = 0; break; case 59: - if (state === 3) { + if (state === 3 + || state === 2 && (!previousWhitespace || lookAhead(isNextJSDocTokenWhitespace))) { comments.push(scanner.getTokenText()); break; } @@ -27912,13 +28903,18 @@ var ts; break; case 18: state = 2; - if (lookAhead(function () { return nextTokenJSDoc() === 59 && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenText() === "link"; })) { - pushComment(scanner.getTokenText()); - nextTokenJSDoc(); + var commentEnd = scanner.getStartPos(); + var linkStart = scanner.getTextPos() - 1; + var link = parseJSDocLink(linkStart); + if (link) { + parts.push(finishNode(factory.createJSDocText(comments.join("")), linkEnd !== null && linkEnd !== void 0 ? linkEnd : commentsPos, commentEnd)); + parts.push(link); + comments = []; + linkEnd = scanner.getTextPos(); + } + else { pushComment(scanner.getTokenText()); - nextTokenJSDoc(); } - pushComment(scanner.getTokenText()); break; case 61: if (state === 3) { @@ -27942,15 +28938,66 @@ var ts; pushComment(scanner.getTokenText()); break; } + previousWhitespace = token() === 5; tok = nextTokenJSDoc(); } removeLeadingNewlines(comments); removeTrailingWhitespace(comments); - return comments.length === 0 ? undefined : comments.join(""); + if (parts.length) { + if (comments.length) { + parts.push(finishNode(factory.createJSDocText(comments.join("")), linkEnd !== null && linkEnd !== void 0 ? linkEnd : commentsPos)); + } + return createNodeArray(parts, commentsPos, scanner.getTextPos()); + } + else if (comments.length) { + return comments.join(""); + } + } + function isNextJSDocTokenWhitespace() { + var next = nextTokenJSDoc(); + return next === 5 || next === 4; + } + function parseJSDocLink(start) { + var linkType = tryParse(parseJSDocLinkPrefix); + if (!linkType) { + return undefined; + } + nextTokenJSDoc(); + skipWhitespace(); + var p2 = getNodePos(); + var name = ts.tokenIsIdentifierOrKeyword(token()) + ? parseEntityName(true) + : undefined; + if (name) { + while (token() === 80) { + reScanHashToken(); + nextTokenJSDoc(); + name = finishNode(factory.createJSDocMemberName(name, parseIdentifier()), p2); + } + } + var text = []; + while (token() !== 19 && token() !== 4 && token() !== 1) { + text.push(scanner.getTokenText()); + nextTokenJSDoc(); + } + var create = linkType === "link" ? factory.createJSDocLink + : linkType === "linkcode" ? factory.createJSDocLinkCode + : factory.createJSDocLinkPlain; + return finishNode(create(name, text.join("")), start, scanner.getTextPos()); + } + function parseJSDocLinkPrefix() { + skipWhitespaceOrAsterisk(); + if (token() === 18 + && nextTokenJSDoc() === 59 + && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc())) { + var kind = scanner.getTokenValue(); + if (kind === "link" || kind === "linkcode" || kind === "linkplain") { + return kind; + } + } } function parseUnknownTag(start, tagName, indent, indentText) { - var end = getNodePos(); - return finishNode(factory.createJSDocUnknownTag(tagName, parseTrailingTagComments(start, end, indent, indentText)), start, end); + return finishNode(factory.createJSDocUnknownTag(tagName, parseTrailingTagComments(start, getNodePos(), indent, indentText)), start); } function addTag(tag) { if (!tag) { @@ -27981,7 +29028,7 @@ var ts; } if (isBracketed) { skipWhitespace(); - if (parseOptionalToken(62)) { + if (parseOptionalToken(63)) { parseExpression(); } parseExpected(23); @@ -27990,9 +29037,9 @@ var ts; } function isObjectOrObjectArrayTypeReference(node) { switch (node.kind) { - case 145: + case 146: return true; - case 178: + case 180: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && !node.typeArguments; @@ -28003,11 +29050,11 @@ var ts; var isNameFirst = !typeExpression; skipWhitespaceOrAsterisk(); var _a = parseBracketNameInPropertyAndParamTag(), name = _a.name, isBracketed = _a.isBracketed; - skipWhitespace(); - if (isNameFirst) { + var indentText = skipWhitespaceOrAsterisk(); + if (isNameFirst && !lookAhead(parseJSDocLinkPrefix)) { typeExpression = tryParseTypeExpression(); } - var comment = parseTagComments(indent + scanner.getStartPos() - start); + var comment = parseTrailingTagComments(start, getNodePos(), indent, indentText); var nestedTypeLiteral = target !== 4 && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { typeExpression = nestedTypeLiteral; @@ -28024,12 +29071,12 @@ var ts; var child = void 0; var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 326 || child.kind === 333) { + if (child.kind === 334 || child.kind === 341) { children = ts.append(children, child); } } if (children) { - var literal = finishNode(factory.createJSDocTypeLiteral(children, typeExpression.type.kind === 178), pos); + var literal = finishNode(factory.createJSDocTypeLiteral(children, typeExpression.type.kind === 180), pos); return finishNode(factory.createJSDocTypeExpression(literal), pos); } } @@ -28039,27 +29086,34 @@ var ts; parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } var typeExpression = tryParseTypeExpression(); - var end = getNodePos(); - return finishNode(factory.createJSDocReturnTag(tagName, typeExpression, parseTrailingTagComments(start, end, indent, indentText)), start, end); + return finishNode(factory.createJSDocReturnTag(tagName, typeExpression, parseTrailingTagComments(start, getNodePos(), indent, indentText)), start); } function parseTypeTag(start, tagName, indent, indentText) { if (ts.some(tags, ts.isJSDocTypeTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } var typeExpression = parseJSDocTypeExpression(true); - var end = getNodePos(); - var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, end, indent, indentText) : undefined; - return finishNode(factory.createJSDocTypeTag(tagName, typeExpression, comments), start, end); + var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, getNodePos(), indent, indentText) : undefined; + return finishNode(factory.createJSDocTypeTag(tagName, typeExpression, comments), start); } function parseSeeTag(start, tagName, indent, indentText) { - var nameExpression = parseJSDocNameReference(); - var end = getNodePos(); - var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, end, indent, indentText) : undefined; - return finishNode(factory.createJSDocSeeTag(tagName, nameExpression, comments), start, end); + var isLink = lookAhead(function () { return nextTokenJSDoc() === 59 && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenValue() === "link"; }); + var nameExpression = isLink ? undefined : parseJSDocNameReference(); + var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, getNodePos(), indent, indentText) : undefined; + return finishNode(factory.createJSDocSeeTag(tagName, nameExpression, comments), start); } function parseAuthorTag(start, tagName, indent, indentText) { - var comments = parseAuthorNameAndEmail() + (parseTrailingTagComments(start, end, indent, indentText) || ""); - return finishNode(factory.createJSDocAuthorTag(tagName, comments || undefined), start); + var commentStart = getNodePos(); + var textOnly = parseAuthorNameAndEmail(); + var commentEnd = scanner.getStartPos(); + var comments = parseTrailingTagComments(start, commentEnd, indent, indentText); + if (!comments) { + commentEnd = scanner.getStartPos(); + } + var allParts = typeof comments !== "string" + ? createNodeArray(ts.concatenate([finishNode(textOnly, commentStart, commentEnd)], comments), commentStart) + : textOnly.text + comments; + return finishNode(factory.createJSDocAuthorTag(tagName, allParts), start); } function parseAuthorNameAndEmail() { var comments = []; @@ -28080,17 +29134,15 @@ var ts; comments.push(scanner.getTokenText()); token = nextTokenJSDoc(); } - return comments.join(""); + return factory.createJSDocText(comments.join("")); } function parseImplementsTag(start, tagName, margin, indentText) { var className = parseExpressionWithTypeArgumentsForAugments(); - var end = getNodePos(); - return finishNode(factory.createJSDocImplementsTag(tagName, className, parseTrailingTagComments(start, end, margin, indentText)), start, end); + return finishNode(factory.createJSDocImplementsTag(tagName, className, parseTrailingTagComments(start, getNodePos(), margin, indentText)), start); } function parseAugmentsTag(start, tagName, margin, indentText) { var className = parseExpressionWithTypeArgumentsForAugments(); - var end = getNodePos(); - return finishNode(factory.createJSDocAugmentsTag(tagName, className, parseTrailingTagComments(start, end, margin, indentText)), start, end); + return finishNode(factory.createJSDocAugmentsTag(tagName, className, parseTrailingTagComments(start, getNodePos(), margin, indentText)), start); } function parseExpressionWithTypeArgumentsForAugments() { var usedBrace = parseOptional(18); @@ -28114,20 +29166,17 @@ var ts; return node; } function parseSimpleTag(start, createTag, tagName, margin, indentText) { - var end = getNodePos(); - return finishNode(createTag(tagName, parseTrailingTagComments(start, end, margin, indentText)), start, end); + return finishNode(createTag(tagName, parseTrailingTagComments(start, getNodePos(), margin, indentText)), start); } function parseThisTag(start, tagName, margin, indentText) { var typeExpression = parseJSDocTypeExpression(true); skipWhitespace(); - var end = getNodePos(); - return finishNode(factory.createJSDocThisTag(tagName, typeExpression, parseTrailingTagComments(start, end, margin, indentText)), start, end); + return finishNode(factory.createJSDocThisTag(tagName, typeExpression, parseTrailingTagComments(start, getNodePos(), margin, indentText)), start); } function parseEnumTag(start, tagName, margin, indentText) { var typeExpression = parseJSDocTypeExpression(true); skipWhitespace(); - var end = getNodePos(); - return finishNode(factory.createJSDocEnumTag(tagName, typeExpression, parseTrailingTagComments(start, end, margin, indentText)), start, end); + return finishNode(factory.createJSDocEnumTag(tagName, typeExpression, parseTrailingTagComments(start, getNodePos(), margin, indentText)), start); } function parseTypedefTag(start, tagName, indent, indentText) { var _a; @@ -28144,7 +29193,7 @@ var ts; var hasChildren = false; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { hasChildren = true; - if (child.kind === 329) { + if (child.kind === 337) { if (childTypeTag) { parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags); var lastError = ts.lastOrUndefined(parseDiagnostics); @@ -28162,7 +29211,7 @@ var ts; } } if (hasChildren) { - var isArrayType = typeExpression && typeExpression.type.kind === 178; + var isArrayType = typeExpression && typeExpression.type.kind === 180; var jsdocTypeLiteral = factory.createJSDocTypeLiteral(jsDocPropertyTags, isArrayType); typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? childTypeTag.typeExpression : @@ -28212,17 +29261,16 @@ var ts; var returnTag = tryParse(function () { if (parseOptionalJsdoc(59)) { var tag = parseTag(indent); - if (tag && tag.kind === 327) { + if (tag && tag.kind === 335) { return tag; } } }); var typeExpression = finishNode(factory.createJSDocSignature(undefined, parameters, returnTag), start); - var end = getNodePos(); if (!comment) { - comment = parseTrailingTagComments(start, end, indent, indentText); + comment = parseTrailingTagComments(start, getNodePos(), indent, indentText); } - return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start, end); + return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start); } function escapedTextsEqual(a, b) { while (!ts.isIdentifier(a) || !ts.isIdentifier(b)) { @@ -28247,7 +29295,7 @@ var ts; case 59: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 326 || child.kind === 333) && + if (child && (child.kind === 334 || child.kind === 341) && target !== 4 && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; @@ -28266,7 +29314,7 @@ var ts; } seenAsterisk = true; break; - case 78: + case 79: canParseTag = false; break; case 1: @@ -28304,6 +29352,9 @@ var ts; function parseTemplateTagTypeParameter() { var typeParameterPos = getNodePos(); var name = parseJSDocIdentifierName(ts.Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces); + if (ts.nodeIsMissing(name)) { + return undefined; + } return finishNode(factory.createTypeParameterDeclaration(name, undefined, undefined), typeParameterPos); } function parseTemplateTagTypeParameters() { @@ -28311,7 +29362,10 @@ var ts; var typeParameters = []; do { skipWhitespace(); - typeParameters.push(parseTemplateTagTypeParameter()); + var node = parseTemplateTagTypeParameter(); + if (node !== undefined) { + typeParameters.push(node); + } skipWhitespaceOrAsterisk(); } while (parseOptionalJsdoc(27)); return createNodeArray(typeParameters, pos); @@ -28319,8 +29373,7 @@ var ts; function parseTemplateTag(start, tagName, indent, indentText) { var constraint = token() === 18 ? parseJSDocTypeExpression() : undefined; var typeParameters = parseTemplateTagTypeParameters(); - var end = getNodePos(); - return finishNode(factory.createJSDocTemplateTag(tagName, constraint, typeParameters, parseTrailingTagComments(start, end, indent, indentText)), start, end); + return finishNode(factory.createJSDocTemplateTag(tagName, constraint, typeParameters, parseTrailingTagComments(start, getNodePos(), indent, indentText)), start); } function parseOptionalJsdoc(t) { if (token() === t) { @@ -28345,7 +29398,7 @@ var ts; } function parseJSDocIdentifierName(message) { if (!ts.tokenIsIdentifierOrKeyword(token())) { - return createMissingNode(78, !message, message || ts.Diagnostics.Identifier_expected); + return createMissingNode(79, !message, message || ts.Diagnostics.Identifier_expected); } identifierCount++; var pos = scanner.getTokenPos(); @@ -28467,7 +29520,7 @@ var ts; switch (node.kind) { case 10: case 8: - case 78: + case 79: return true; } return false; @@ -28791,7 +29844,7 @@ var ts; if (namedArgRegExCache.has(name)) { return namedArgRegExCache.get(name); } - var result = new RegExp("(\\s" + name + "\\s*=\\s*)('|\")(.+?)\\2", "im"); + var result = new RegExp("(\\s" + name + "\\s*=\\s*)(?:(?:'([^']*)')|(?:\"([^\"]*)\"))", "im"); namedArgRegExCache.set(name, result); return result; } @@ -28815,16 +29868,17 @@ var ts; return; } else if (matchResult) { + var value = matchResult[2] || matchResult[3]; if (arg.captureSpan) { - var startPos = range.pos + matchResult.index + matchResult[1].length + matchResult[2].length; + var startPos = range.pos + matchResult.index + matchResult[1].length + 1; argument[arg.name] = { - value: matchResult[3], + value: value, pos: startPos, - end: startPos + matchResult[3].length + end: startPos + value.length }; } else { - argument[arg.name] = matchResult[3]; + argument[arg.name] = value; } } } @@ -28840,7 +29894,7 @@ var ts; return addPragmaForMatch(pragmas, range, 2, singleLine); } if (range.kind === 3) { - var multiLinePragmaRegEx = /\s*@(\S+)\s*(.*)\s*$/gim; + var multiLinePragmaRegEx = /@(\S+)(\s+.*)?$/gim; var multiLineMatch = void 0; while (multiLineMatch = multiLinePragmaRegEx.exec(text)) { addPragmaForMatch(pragmas, range, 4, multiLineMatch); @@ -28867,7 +29921,7 @@ var ts; return {}; if (!pragma.args) return {}; - var args = text.split(/\s+/); + var args = ts.trimString(text).split(/\s+/); var argMap = {}; for (var i = 0; i < pragma.args.length; i++) { var argument = pragma.args[i]; @@ -28885,10 +29939,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 78) { + if (lhs.kind === 79) { return lhs.escapedText === rhs.escapedText; } - if (lhs.kind === 107) { + if (lhs.kind === 108) { return true; } return lhs.name.escapedText === rhs.name.escapedText && @@ -28920,6 +29974,7 @@ var ts; ["es2018", "lib.es2018.d.ts"], ["es2019", "lib.es2019.d.ts"], ["es2020", "lib.es2020.d.ts"], + ["es2021", "lib.es2021.d.ts"], ["esnext", "lib.esnext.d.ts"], ["dom", "lib.dom.d.ts"], ["dom.iterable", "lib.dom.iterable.d.ts"], @@ -28957,14 +30012,17 @@ var ts; ["es2020.string", "lib.es2020.string.d.ts"], ["es2020.symbol.wellknown", "lib.es2020.symbol.wellknown.d.ts"], ["es2020.intl", "lib.es2020.intl.d.ts"], + ["es2021.promise", "lib.es2021.promise.d.ts"], + ["es2021.string", "lib.es2021.string.d.ts"], + ["es2021.weakref", "lib.es2021.weakref.d.ts"], ["esnext.array", "lib.es2019.array.d.ts"], ["esnext.symbol", "lib.es2019.symbol.d.ts"], ["esnext.asynciterable", "lib.es2018.asynciterable.d.ts"], ["esnext.intl", "lib.esnext.intl.d.ts"], ["esnext.bigint", "lib.es2020.bigint.d.ts"], - ["esnext.string", "lib.esnext.string.d.ts"], - ["esnext.promise", "lib.esnext.promise.d.ts"], - ["esnext.weakref", "lib.esnext.weakref.d.ts"] + ["esnext.string", "lib.es2021.string.d.ts"], + ["esnext.promise", "lib.es2021.promise.d.ts"], + ["esnext.weakref", "lib.es2021.weakref.d.ts"] ]; ts.libs = libEntries.map(function (entry) { return entry[0]; }); ts.libMap = new ts.Map(libEntries); @@ -28975,11 +30033,12 @@ var ts; fixedpollinginterval: ts.WatchFileKind.FixedPollingInterval, prioritypollinginterval: ts.WatchFileKind.PriorityPollingInterval, dynamicprioritypolling: ts.WatchFileKind.DynamicPriorityPolling, + fixedchunksizepolling: ts.WatchFileKind.FixedChunkSizePolling, usefsevents: ts.WatchFileKind.UseFsEvents, usefseventsonparentdirectory: ts.WatchFileKind.UseFsEventsOnParentDirectory, })), - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_DynamicPriorityPolling_UseFsEvents_UseFsEventsOnParentDirectory, + category: ts.Diagnostics.Watch_and_Build_Modes, + description: ts.Diagnostics.Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_DynamicPriorityPolling_FixedChunkSizePolling_UseFsEvents_UseFsEventsOnParentDirectory, }, { name: "watchDirectory", @@ -28987,9 +30046,10 @@ var ts; usefsevents: ts.WatchDirectoryKind.UseFsEvents, fixedpollinginterval: ts.WatchDirectoryKind.FixedPollingInterval, dynamicprioritypolling: ts.WatchDirectoryKind.DynamicPriorityPolling, + fixedchunksizepolling: ts.WatchDirectoryKind.FixedChunkSizePolling, })), - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling, + category: ts.Diagnostics.Watch_and_Build_Modes, + description: ts.Diagnostics.Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling_FixedChunkSizePolling, }, { name: "fallbackPolling", @@ -28997,14 +30057,15 @@ var ts; fixedinterval: ts.PollingWatchKind.FixedInterval, priorityinterval: ts.PollingWatchKind.PriorityInterval, dynamicpriority: ts.PollingWatchKind.DynamicPriority, + fixedchunksize: ts.PollingWatchKind.FixedChunkSize, })), - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority, + category: ts.Diagnostics.Watch_and_Build_Modes, + description: ts.Diagnostics.Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority_FixedChunkSize, }, { name: "synchronousWatchDirectory", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Watch_and_Build_Modes, description: ts.Diagnostics.Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively, }, { @@ -29016,7 +30077,7 @@ var ts; isFilePath: true, extraValidation: specToDiagnostic }, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Watch_and_Build_Modes, description: ts.Diagnostics.Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively, }, { @@ -29028,7 +30089,7 @@ var ts; isFilePath: true, extraValidation: specToDiagnostic }, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Watch_and_Build_Modes, description: ts.Diagnostics.Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively, }, ]; @@ -29051,6 +30112,7 @@ var ts; shortName: "w", type: "boolean", showInSimplifiedHelpView: true, + isCommandLineOnly: true, category: ts.Diagnostics.Command_line_Options, description: ts.Diagnostics.Watch_input_files, }, @@ -29058,49 +30120,50 @@ var ts; name: "preserveWatchOutput", type: "boolean", showInSimplifiedHelpView: false, - category: ts.Diagnostics.Command_line_Options, + category: ts.Diagnostics.Output_Formatting, description: ts.Diagnostics.Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen, }, { name: "listFiles", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Print_names_of_files_part_of_the_compilation }, { name: "explainFiles", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Print_names_of_files_and_the_reason_they_are_part_of_the_compilation - }, { + }, + { name: "listEmittedFiles", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Print_names_of_generated_files_part_of_the_compilation }, { name: "pretty", type: "boolean", showInSimplifiedHelpView: true, - category: ts.Diagnostics.Command_line_Options, + category: ts.Diagnostics.Output_Formatting, description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental }, { name: "traceResolution", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Enable_tracing_of_the_name_resolution_process }, { name: "diagnostics", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Show_diagnostic_information }, { name: "extendedDiagnostics", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Show_verbose_diagnostic_information }, { @@ -29108,7 +30171,7 @@ var ts; type: "string", isFilePath: true, paramType: ts.Diagnostics.FILE_OR_DIRECTORY, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Generates_a_CPU_profile }, { @@ -29117,14 +30180,14 @@ var ts; isFilePath: true, isCommandLineOnly: true, paramType: ts.Diagnostics.DIRECTORY, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Generates_an_event_trace_and_a_list_of_types }, { name: "incremental", shortName: "i", type: "boolean", - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Projects, description: ts.Diagnostics.Enable_incremental_compilation, transpileOptionValue: undefined }, @@ -29133,13 +30196,14 @@ var ts; type: "boolean", affectsSemanticDiagnostics: true, affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Watch_and_Build_Modes, description: ts.Diagnostics.Have_recompiles_in_incremental_and_watch_assume_that_changes_within_a_file_will_only_affect_files_directly_depending_on_it }, { name: "locale", type: "string", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Command_line_Options, + isCommandLineOnly: true, description: ts.Diagnostics.The_locale_used_when_displaying_messages_to_the_user_e_g_en_us }, ]; @@ -29156,6 +30220,7 @@ var ts; es2018: 5, es2019: 6, es2020: 7, + es2021: 8, esnext: 99, })), affectsSourceFile: true, @@ -29163,10 +30228,10 @@ var ts; affectsEmit: true, paramType: ts.Diagnostics.VERSION, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_or_ESNEXT, + category: ts.Diagnostics.Language_and_Environment, + description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_ES2021_or_ESNEXT, }; - ts.optionDeclarations = __spreadArray(__spreadArray([], ts.commonOptionsWithBuild), [ + var commandOptionsWithoutBuild = [ { name: "all", type: "boolean", @@ -29242,7 +30307,7 @@ var ts; affectsEmit: true, paramType: ts.Diagnostics.KIND, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_es2020_or_ESNext, }, { @@ -29252,9 +30317,9 @@ var ts; name: "lib", type: ts.libMap }, - affectsModuleResolution: true, + affectsProgramStructure: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation, transpileOptionValue: undefined }, @@ -29263,13 +30328,13 @@ var ts; type: "boolean", affectsModuleResolution: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.JavaScript_Support, description: ts.Diagnostics.Allow_javascript_files_to_be_compiled }, { name: "checkJs", type: "boolean", - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.JavaScript_Support, description: ts.Diagnostics.Report_errors_in_js_files }, { @@ -29280,7 +30345,7 @@ var ts; affectsModuleResolution: true, paramType: ts.Diagnostics.KIND, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_react_react_jsx_or_react_jsxdev, }, { @@ -29289,7 +30354,7 @@ var ts; type: "boolean", affectsEmit: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Generates_corresponding_d_ts_file, transpileOptionValue: undefined }, @@ -29298,7 +30363,7 @@ var ts; type: "boolean", affectsEmit: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Generates_a_sourcemap_for_each_corresponding_d_ts_file, transpileOptionValue: undefined }, @@ -29306,7 +30371,7 @@ var ts; name: "emitDeclarationOnly", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Only_emit_d_ts_declaration_files, transpileOptionValue: undefined }, @@ -29315,7 +30380,7 @@ var ts; type: "boolean", affectsEmit: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Generates_corresponding_map_file, }, { @@ -29325,7 +30390,7 @@ var ts; isFilePath: true, paramType: ts.Diagnostics.FILE, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, transpileOptionValue: undefined }, @@ -29336,7 +30401,7 @@ var ts; isFilePath: true, paramType: ts.Diagnostics.DIRECTORY, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Redirect_output_structure_to_the_directory, }, { @@ -29345,7 +30410,7 @@ var ts; affectsEmit: true, isFilePath: true, paramType: ts.Diagnostics.LOCATION, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, }, { @@ -29353,7 +30418,7 @@ var ts; type: "boolean", affectsEmit: true, isTSConfigOnly: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Projects, description: ts.Diagnostics.Enable_project_compilation, transpileOptionValue: undefined }, @@ -29363,7 +30428,7 @@ var ts; affectsEmit: true, isFilePath: true, paramType: ts.Diagnostics.FILE, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Projects, description: ts.Diagnostics.Specify_file_to_store_incremental_compilation_information, transpileOptionValue: undefined }, @@ -29372,14 +30437,14 @@ var ts; type: "boolean", affectsEmit: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Do_not_emit_comments_to_output, }, { name: "noEmit", type: "boolean", showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Do_not_emit_outputs, transpileOptionValue: undefined }, @@ -29387,7 +30452,7 @@ var ts; name: "importHelpers", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Import_emit_helpers_from_tslib }, { @@ -29399,20 +30464,20 @@ var ts; })), affectsEmit: true, affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types }, { name: "downlevelIteration", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3 }, { name: "isolatedModules", type: "boolean", - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Interop_Constraints, description: ts.Diagnostics.Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule, transpileOptionValue: true }, @@ -29420,7 +30485,7 @@ var ts; name: "strict", type: "boolean", showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Enable_all_strict_type_checking_options }, { @@ -29429,7 +30494,7 @@ var ts; affectsSemanticDiagnostics: true, strictFlag: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type }, { @@ -29438,7 +30503,7 @@ var ts; affectsSemanticDiagnostics: true, strictFlag: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Enable_strict_null_checks }, { @@ -29447,7 +30512,7 @@ var ts; affectsSemanticDiagnostics: true, strictFlag: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Enable_strict_checking_of_function_types }, { @@ -29455,7 +30520,7 @@ var ts; type: "boolean", strictFlag: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Enable_strict_bind_call_and_apply_methods_on_functions }, { @@ -29464,25 +30529,43 @@ var ts; affectsSemanticDiagnostics: true, strictFlag: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Enable_strict_checking_of_property_initialization_in_classes }, + { + name: "strictOptionalProperties", + type: "boolean", + affectsSemanticDiagnostics: true, + strictFlag: true, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Type_Checking, + description: ts.Diagnostics.Enable_strict_checking_of_optional_properties + }, { name: "noImplicitThis", type: "boolean", affectsSemanticDiagnostics: true, strictFlag: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, }, + { + name: "useUnknownInCatchVariables", + type: "boolean", + affectsSemanticDiagnostics: true, + strictFlag: true, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Type_Checking, + description: ts.Diagnostics.Type_catch_clause_variables_as_unknown_instead_of_any, + }, { name: "alwaysStrict", type: "boolean", affectsSourceFile: true, strictFlag: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file }, { @@ -29490,7 +30573,7 @@ var ts; type: "boolean", affectsSemanticDiagnostics: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Additional_Checks, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Report_errors_on_unused_locals, }, { @@ -29498,7 +30581,7 @@ var ts; type: "boolean", affectsSemanticDiagnostics: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Additional_Checks, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Report_errors_on_unused_parameters, }, { @@ -29506,7 +30589,7 @@ var ts; type: "boolean", affectsSemanticDiagnostics: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Additional_Checks, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value }, { @@ -29515,7 +30598,7 @@ var ts; affectsBindDiagnostics: true, affectsSemanticDiagnostics: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Additional_Checks, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement }, { @@ -29523,14 +30606,22 @@ var ts; type: "boolean", affectsSemanticDiagnostics: true, showInSimplifiedHelpView: false, - category: ts.Diagnostics.Additional_Checks, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Include_undefined_in_index_signature_results }, + { + name: "noImplicitOverride", + type: "boolean", + affectsSemanticDiagnostics: true, + showInSimplifiedHelpView: false, + category: ts.Diagnostics.Type_Checking, + description: ts.Diagnostics.Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier + }, { name: "noPropertyAccessFromIndexSignature", type: "boolean", showInSimplifiedHelpView: false, - category: ts.Diagnostics.Additional_Checks, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Require_undeclared_properties_from_index_signatures_to_use_element_accesses }, { @@ -29541,7 +30632,7 @@ var ts; })), affectsModuleResolution: true, paramType: ts.Diagnostics.STRATEGY, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, }, { @@ -29549,7 +30640,7 @@ var ts; type: "string", affectsModuleResolution: true, isFilePath: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Base_directory_to_resolve_non_absolute_module_names }, { @@ -29557,7 +30648,7 @@ var ts; type: "object", affectsModuleResolution: true, isTSConfigOnly: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl, transpileOptionValue: undefined }, @@ -29571,7 +30662,7 @@ var ts; isFilePath: true }, affectsModuleResolution: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime, transpileOptionValue: undefined }, @@ -29584,7 +30675,7 @@ var ts; isFilePath: true }, affectsModuleResolution: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.List_of_folders_to_include_type_definitions_from }, { @@ -29594,9 +30685,9 @@ var ts; name: "types", type: "string" }, - affectsModuleResolution: true, + affectsProgramStructure: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation, transpileOptionValue: undefined }, @@ -29604,7 +30695,7 @@ var ts; name: "allowSyntheticDefaultImports", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Interop_Constraints, description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking }, { @@ -29613,20 +30704,20 @@ var ts; affectsSemanticDiagnostics: true, affectsEmit: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Interop_Constraints, description: ts.Diagnostics.Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for_all_imports_Implies_allowSyntheticDefaultImports }, { name: "preserveSymlinks", type: "boolean", - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Interop_Constraints, description: ts.Diagnostics.Do_not_resolve_the_real_path_of_symlinks, }, { name: "allowUmdGlobalAccess", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Allow_accessing_UMD_globals_from_modules, }, { @@ -29634,7 +30725,7 @@ var ts; type: "string", affectsEmit: true, paramType: ts.Diagnostics.LOCATION, - category: ts.Diagnostics.Source_Map_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, }, { @@ -29642,28 +30733,28 @@ var ts; type: "string", affectsEmit: true, paramType: ts.Diagnostics.LOCATION, - category: ts.Diagnostics.Source_Map_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, }, { name: "inlineSourceMap", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Source_Map_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file }, { name: "inlineSources", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Source_Map_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap_to_be_set }, { name: "experimentalDecorators", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Experimental_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators }, { @@ -29671,19 +30762,19 @@ var ts; type: "boolean", affectsSemanticDiagnostics: true, affectsEmit: true, - category: ts.Diagnostics.Experimental_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators }, { name: "jsxFactory", type: "string", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h }, { name: "jsxFragmentFactory", type: "string", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Specify_the_JSX_fragment_factory_function_to_use_when_targeting_react_JSX_emit_with_jsxFactory_compiler_option_is_specified_e_g_Fragment }, { @@ -29692,14 +30783,14 @@ var ts; affectsSemanticDiagnostics: true, affectsEmit: true, affectsModuleResolution: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react }, { name: "resolveJsonModule", type: "boolean", affectsModuleResolution: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Include_modules_imported_with_json_extension }, { @@ -29707,7 +30798,7 @@ var ts; type: "string", affectsEmit: true, isFilePath: false, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Backwards_Compatibility, paramType: ts.Diagnostics.FILE, description: ts.Diagnostics.Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file, transpileOptionValue: undefined @@ -29716,26 +30807,26 @@ var ts; name: "reactNamespace", type: "string", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react_JSX_emit }, { name: "skipDefaultLibCheck", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Completeness, description: ts.Diagnostics.Deprecated_Use_skipLibCheck_instead_Skip_type_checking_of_default_library_declaration_files }, { name: "charset", type: "string", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Backwards_Compatibility, description: ts.Diagnostics.The_character_set_of_the_input_files }, { name: "emitBOM", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files }, { @@ -29746,21 +30837,21 @@ var ts; })), affectsEmit: true, paramType: ts.Diagnostics.NEWLINE, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, }, { name: "noErrorTruncation", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Output_Formatting, description: ts.Diagnostics.Do_not_truncate_error_messages }, { name: "noLib", type: "boolean", - affectsModuleResolution: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Language_and_Environment, + affectsProgramStructure: true, description: ts.Diagnostics.Do_not_include_the_default_library_file_lib_d_ts, transpileOptionValue: true }, @@ -29768,7 +30859,7 @@ var ts; name: "noResolve", type: "boolean", affectsModuleResolution: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files, transpileOptionValue: true }, @@ -29776,56 +30867,56 @@ var ts; name: "stripInternal", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation, }, { name: "disableSizeLimit", type: "boolean", - affectsSourceFile: true, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Disable_size_limitations_on_JavaScript_projects + affectsProgramStructure: true, + category: ts.Diagnostics.Editor_Support, + description: ts.Diagnostics.JavaScript_Support }, { name: "disableSourceOfProjectReferenceRedirect", type: "boolean", isTSConfigOnly: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Projects, description: ts.Diagnostics.Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects }, { name: "disableSolutionSearching", type: "boolean", isTSConfigOnly: true, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Disable_solution_searching_for_this_project + category: ts.Diagnostics.Projects, + description: ts.Diagnostics.Projects }, { name: "disableReferencedProjectLoad", type: "boolean", isTSConfigOnly: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Projects, description: ts.Diagnostics.Disable_loading_referenced_projects }, { name: "noImplicitUseStrict", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Backwards_Compatibility, description: ts.Diagnostics.Do_not_emit_use_strict_directives_in_module_output }, { name: "noEmitHelpers", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Do_not_generate_custom_helper_functions_like_extends_in_compiled_output }, { name: "noEmitOnError", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, transpileOptionValue: undefined }, @@ -29833,7 +30924,7 @@ var ts; name: "preserveConstEnums", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code }, { @@ -29842,14 +30933,14 @@ var ts; affectsEmit: true, isFilePath: true, paramType: ts.Diagnostics.DIRECTORY, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Output_directory_for_generated_declaration_files, transpileOptionValue: undefined }, { name: "skipLibCheck", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Completeness, description: ts.Diagnostics.Skip_type_checking_of_declaration_files, }, { @@ -29857,7 +30948,7 @@ var ts; type: "boolean", affectsBindDiagnostics: true, affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Do_not_report_errors_on_unused_labels }, { @@ -29865,42 +30956,42 @@ var ts; type: "boolean", affectsBindDiagnostics: true, affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Do_not_report_errors_on_unreachable_code }, { name: "suppressExcessPropertyErrors", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Backwards_Compatibility, description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals, }, { name: "suppressImplicitAnyIndexErrors", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Backwards_Compatibility, description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, }, { name: "forceConsistentCasingInFileNames", type: "boolean", affectsModuleResolution: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Interop_Constraints, description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file }, { name: "maxNodeModuleJsDepth", type: "number", affectsModuleResolution: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.JavaScript_Support, description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files }, { name: "noStrictGenericChecks", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Backwards_Compatibility, description: ts.Diagnostics.Disable_strict_checking_of_generic_signatures_in_function_types, }, { @@ -29908,13 +30999,13 @@ var ts; type: "boolean", affectsSemanticDiagnostics: true, affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Emit_class_fields_with_Define_instead_of_Set, }, { name: "keyofStringsOnly", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Backwards_Compatibility, description: ts.Diagnostics.Resolve_keyof_to_string_valued_property_names_only_no_numbers_or_symbols, }, { @@ -29925,19 +31016,22 @@ var ts; name: "plugin", type: "object" }, - description: ts.Diagnostics.List_of_language_service_plugins + description: ts.Diagnostics.List_of_language_service_plugins, + category: ts.Diagnostics.Editor_Support, }, - ]); + ]; + ts.optionDeclarations = __spreadArray(__spreadArray([], ts.commonOptionsWithBuild), commandOptionsWithoutBuild); ts.semanticDiagnosticsOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsSemanticDiagnostics; }); ts.affectsEmitOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsEmit; }); ts.moduleResolutionOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsModuleResolution; }); ts.sourceFileAffectingCompilerOptions = ts.optionDeclarations.filter(function (option) { return !!option.affectsSourceFile || !!option.affectsModuleResolution || !!option.affectsBindDiagnostics; }); + ts.optionsAffectingProgramStructure = ts.optionDeclarations.filter(function (option) { return !!option.affectsProgramStructure; }); ts.transpileOptionValueCompilerOptions = ts.optionDeclarations.filter(function (option) { return ts.hasProperty(option, "transpileOptionValue"); }); - ts.buildOpts = __spreadArray(__spreadArray([], ts.commonOptionsWithBuild), [ + var commandOptionsOnlyBuild = [ { name: "verbose", shortName: "v", @@ -29965,7 +31059,8 @@ var ts; description: ts.Diagnostics.Delete_the_outputs_of_all_projects, type: "boolean" } - ]); + ]; + ts.buildOpts = __spreadArray(__spreadArray([], ts.commonOptionsWithBuild), commandOptionsOnlyBuild); ts.typeAcquisitionDeclarations = [ { name: "enableAutoDiscovery", @@ -30013,6 +31108,10 @@ var ts; return optionsNameMapCache || (optionsNameMapCache = createOptionNameMap(ts.optionDeclarations)); } ts.getOptionsNameMap = getOptionsNameMap; + var compilerOptionsAlternateMode = { + diagnostic: ts.Diagnostics.Compiler_option_0_may_only_be_used_with_build, + getOptionsNameMap: getBuildOptionsNameMap + }; ts.defaultInitCompilerOptions = { module: ts.ModuleKind.CommonJS, target: 1, @@ -30041,12 +31140,12 @@ var ts; return createDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); } function parseCustomTypeOption(opt, value, errors) { - return convertJsonOptionOfCustomType(opt, trimString(value || ""), errors); + return convertJsonOptionOfCustomType(opt, ts.trimString(value || ""), errors); } ts.parseCustomTypeOption = parseCustomTypeOption; function parseListTypeOption(opt, value, errors) { if (value === void 0) { value = ""; } - value = trimString(value); + value = ts.trimString(value); if (ts.startsWith(value, "-")) { return undefined; } @@ -30068,6 +31167,10 @@ var ts; return option.name; } function createUnknownOptionError(unknownOption, diagnostics, createDiagnostics, unknownOptionErrorText) { + var _a; + if ((_a = diagnostics.alternateMode) === null || _a === void 0 ? void 0 : _a.getOptionsNameMap().optionsNameMap.has(unknownOption.toLowerCase())) { + return createDiagnostics(diagnostics.alternateMode.diagnostic, unknownOption); + } var possibleOption = ts.getSpellingSuggestion(unknownOption, diagnostics.optionDeclarations, getOptionName); return possibleOption ? createDiagnostics(diagnostics.unknownDidYouMeanDiagnostic, unknownOptionErrorText || unknownOption, possibleOption.name) : @@ -30216,6 +31319,7 @@ var ts; return i; } ts.compilerOptionsDidYouMeanDiagnostics = { + alternateMode: compilerOptionsAlternateMode, getOptionsNameMap: getOptionsNameMap, optionDeclarations: ts.optionDeclarations, unknownOptionDiagnostic: ts.Diagnostics.Unknown_compiler_option_0, @@ -30246,7 +31350,12 @@ var ts; function getBuildOptionsNameMap() { return buildOptionsNameMapCache || (buildOptionsNameMapCache = createOptionNameMap(ts.buildOpts)); } + var buildOptionsAlternateMode = { + diagnostic: ts.Diagnostics.Compiler_option_0_may_not_be_used_with_build, + getOptionsNameMap: getOptionsNameMap + }; var buildOptionsDidYouMeanDiagnostics = { + alternateMode: buildOptionsAlternateMode, getOptionsNameMap: getBuildOptionsNameMap, optionDeclarations: ts.buildOpts, unknownOptionDiagnostic: ts.Diagnostics.Unknown_build_option_0, @@ -30305,7 +31414,7 @@ var ts; function parseConfigFileTextToJson(fileName, jsonText) { var jsonSourceFile = ts.parseJsonText(fileName, jsonText); return { - config: convertToObject(jsonSourceFile, jsonSourceFile.parseDiagnostics), + config: convertConfigFileToObject(jsonSourceFile, jsonSourceFile.parseDiagnostics, false, undefined), error: jsonSourceFile.parseDiagnostics.length ? jsonSourceFile.parseDiagnostics[0] : undefined }; } @@ -30390,7 +31499,8 @@ var ts; }, { name: "extends", - type: "string" + type: "string", + category: ts.Diagnostics.File_Management, }, { name: "references", @@ -30398,7 +31508,8 @@ var ts; element: { name: "references", type: "object" - } + }, + category: ts.Diagnostics.Projects, }, { name: "files", @@ -30406,7 +31517,8 @@ var ts; element: { name: "files", type: "string" - } + }, + category: ts.Diagnostics.File_Management, }, { name: "include", @@ -30414,7 +31526,8 @@ var ts; element: { name: "include", type: "string" - } + }, + category: ts.Diagnostics.File_Management, }, { name: "exclude", @@ -30422,7 +31535,8 @@ var ts; element: { name: "exclude", type: "string" - } + }, + category: ts.Diagnostics.File_Management, }, ts.compileOnSaveCommandLineOption ]) @@ -30430,22 +31544,39 @@ var ts; } return _tsconfigRootOptions; } + function convertConfigFileToObject(sourceFile, errors, reportOptionsErrors, optionsIterator) { + 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 !== 202) { + 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")); + if (ts.isArrayLiteralExpression(rootExpression)) { + var firstObject = ts.find(rootExpression.elements, ts.isObjectLiteralExpression); + if (firstObject) { + return convertToObjectWorker(sourceFile, firstObject, errors, true, knownRootOptions, optionsIterator); + } + } + return {}; + } + return convertToObjectWorker(sourceFile, rootExpression, errors, true, knownRootOptions, optionsIterator); + } function convertToObject(sourceFile, errors) { - return convertToObjectWorker(sourceFile, errors, true, undefined, undefined); + var _a; + return convertToObjectWorker(sourceFile, (_a = sourceFile.statements[0]) === null || _a === void 0 ? void 0 : _a.expression, errors, true, undefined, undefined); } ts.convertToObject = convertToObject; - function convertToObjectWorker(sourceFile, errors, returnValue, knownRootOptions, jsonConversionNotifier) { - if (!sourceFile.statements.length) { + function convertToObjectWorker(sourceFile, rootExpression, errors, returnValue, knownRootOptions, jsonConversionNotifier) { + if (!rootExpression) { return returnValue ? {} : undefined; } - return convertPropertyValueToJson(sourceFile.statements[0].expression, knownRootOptions); + return convertPropertyValueToJson(rootExpression, knownRootOptions); function isRootOptionMap(knownOptions) { return knownRootOptions && knownRootOptions.elementOptions === knownOptions; } function convertObjectLiteralExpressionToJson(node, knownOptions, extraKeyDiagnostics, parentOption) { var result = returnValue ? {} : undefined; var _loop_4 = function (element) { - if (element.kind !== 288) { + if (element.kind !== 290) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); return "continue"; } @@ -30506,13 +31637,13 @@ var ts; function convertPropertyValueToJson(valueExpression, option) { var invalidReported; switch (valueExpression.kind) { - case 109: + case 110: reportInvalidOptionValue(option && option.type !== "boolean"); return validateValue(true); - case 94: + case 95: reportInvalidOptionValue(option && option.type !== "boolean"); return validateValue(false); - case 103: + case 104: reportInvalidOptionValue(option && option.name === "extends"); return validateValue(null); case 10: @@ -30532,13 +31663,13 @@ var ts; case 8: reportInvalidOptionValue(option && option.type !== "number"); return validateValue(Number(valueExpression.text)); - case 214: + case 216: if (valueExpression.operator !== 40 || valueExpression.operand.kind !== 8) { break; } reportInvalidOptionValue(option && option.type !== "number"); return validateValue(-Number(valueExpression.operand.text)); - case 200: + case 202: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; if (option) { @@ -30548,7 +31679,7 @@ var ts; else { return validateValue(convertObjectLiteralExpressionToJson(objectLiteralExpression, undefined, undefined, undefined)); } - case 199: + case 201: reportInvalidOptionValue(option && option.type !== "list"); return validateValue(convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element)); } @@ -30674,7 +31805,7 @@ var ts; var getCanonicalFileName = pathOptions && ts.createGetCanonicalFileName(pathOptions.useCaseSensitiveFileNames); var _loop_5 = function (name) { if (ts.hasProperty(options, name)) { - if (optionsNameMap.has(name) && optionsNameMap.get(name).category === ts.Diagnostics.Command_line_Options) { + if (optionsNameMap.has(name) && (optionsNameMap.get(name).category === ts.Diagnostics.Command_line_Options || optionsNameMap.get(name).category === ts.Diagnostics.Output_Formatting)) { return "continue"; } var value = options[name]; @@ -30731,18 +31862,17 @@ var ts; function makePadding(paddingLength) { return Array(paddingLength + 1).join(" "); } - function isAllowedOption(_a) { - var category = _a.category, name = _a.name; - return category !== undefined - && category !== ts.Diagnostics.Command_line_Options - && (category !== ts.Diagnostics.Advanced_Options || compilerOptionsMap.has(name)); + function isAllowedOptionForOutput(_a) { + var category = _a.category, name = _a.name, isCommandLineOnly = _a.isCommandLineOnly; + var categoriesToSkip = [ts.Diagnostics.Command_line_Options, ts.Diagnostics.Editor_Support, ts.Diagnostics.Compiler_Diagnostics, ts.Diagnostics.Backwards_Compatibility, ts.Diagnostics.Watch_and_Build_Modes, ts.Diagnostics.Output_Formatting]; + return !isCommandLineOnly && category !== undefined && (!categoriesToSkip.includes(category) || compilerOptionsMap.has(name)); } function writeConfigurations() { var categorizedOptions = ts.createMultiMap(); for (var _i = 0, optionDeclarations_1 = ts.optionDeclarations; _i < optionDeclarations_1.length; _i++) { var option = optionDeclarations_1[_i]; var category = option.category; - if (isAllowedOption(option)) { + if (isAllowedOptionForOutput(option)) { categorizedOptions.add(ts.getLocaleSpecificMessage(category), option); } } @@ -30922,6 +32052,7 @@ var ts; validatedFilesSpec: ts.filter(filesSpecs, ts.isString), validatedIncludeSpecs: validatedIncludeSpecs, validatedExcludeSpecs: validatedExcludeSpecs, + pathPatterns: undefined, }; } function getFileNames(basePath) { @@ -31024,14 +32155,14 @@ var ts; } if (ownConfig.extendedConfigPath) { resolutionStack = resolutionStack.concat([resolvedPath]); - var extendedConfig = getExtendedConfig(sourceFile, ownConfig.extendedConfigPath, host, basePath, resolutionStack, errors, extendedConfigCache); + var extendedConfig = getExtendedConfig(sourceFile, ownConfig.extendedConfigPath, host, resolutionStack, errors, extendedConfigCache); if (extendedConfig && isSuccessfulParsedTsconfig(extendedConfig)) { var baseRaw_1 = extendedConfig.raw; var raw_1 = ownConfig.raw; + var relativeDifference_1; var setPropertyInRawIfNotUndefined = function (propertyName) { - var value = raw_1[propertyName] || baseRaw_1[propertyName]; - if (value) { - raw_1[propertyName] = value; + if (!raw_1[propertyName] && baseRaw_1[propertyName]) { + raw_1[propertyName] = ts.map(baseRaw_1[propertyName], function (path) { return ts.isRootedDiskPath(path) ? path : ts.combinePaths(relativeDifference_1 || (relativeDifference_1 = ts.convertToRelativePath(ts.getDirectoryPath(ownConfig.extendedConfigPath), basePath, ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames))), path); }); } }; setPropertyInRawIfNotUndefined("include"); @@ -31110,7 +32241,7 @@ var ts; } } }; - var json = convertToObjectWorker(sourceFile, errors, true, getTsconfigRootOptionsMap(), optionsIterator); + var json = convertConfigFileToObject(sourceFile, errors, true, optionsIterator); if (!typeAcquisition) { if (typingOptionstypeAcquisition) { typeAcquisition = (typingOptionstypeAcquisition.enableAutoDiscovery !== undefined) ? @@ -31147,7 +32278,7 @@ var ts; errors.push(createDiagnostic(ts.Diagnostics.File_0_not_found, extendedConfig)); return undefined; } - function getExtendedConfig(sourceFile, extendedConfigPath, host, basePath, resolutionStack, errors, extendedConfigCache) { + function getExtendedConfig(sourceFile, extendedConfigPath, host, resolutionStack, errors, extendedConfigCache) { var _a; var path = host.useCaseSensitiveFileNames ? extendedConfigPath : ts.toFileNameLowerCase(extendedConfigPath); var value; @@ -31159,21 +32290,7 @@ var ts; else { extendedResult = readJsonConfigFile(extendedConfigPath, function (path) { return host.readFile(path); }); if (!extendedResult.parseDiagnostics.length) { - var extendedDirname = ts.getDirectoryPath(extendedConfigPath); - extendedConfig = parseConfig(undefined, extendedResult, host, extendedDirname, ts.getBaseFileName(extendedConfigPath), resolutionStack, errors, extendedConfigCache); - if (isSuccessfulParsedTsconfig(extendedConfig)) { - var relativeDifference_1 = ts.convertToRelativePath(extendedDirname, basePath, ts.identity); - var updatePath_1 = function (path) { return ts.isRootedDiskPath(path) ? path : ts.combinePaths(relativeDifference_1, path); }; - var mapPropertiesInRawIfNotUndefined = function (propertyName) { - if (raw_2[propertyName]) { - raw_2[propertyName] = ts.map(raw_2[propertyName], updatePath_1); - } - }; - var raw_2 = extendedConfig.raw; - mapPropertiesInRawIfNotUndefined("include"); - mapPropertiesInRawIfNotUndefined("exclude"); - mapPropertiesInRawIfNotUndefined("files"); - } + extendedConfig = parseConfig(undefined, extendedResult, host, ts.getDirectoryPath(extendedConfigPath), ts.getBaseFileName(extendedConfigPath), resolutionStack, errors, extendedConfigCache); } if (extendedConfigCache) { extendedConfigCache.set(path, { extendedResult: extendedResult, extendedConfig: extendedConfig }); @@ -31317,12 +32434,7 @@ var ts; function convertJsonOptionOfListType(option, values, basePath, errors) { return ts.filter(ts.map(values, function (v) { return convertJsonOption(option.element, v, basePath, errors); }), function (v) { return !!v; }); } - function trimString(s) { - return typeof s.trim === "function" ? s.trim() : s.replace(/^[\s]+|[\s]+$/g, ""); - } var invalidTrailingRecursionPattern = /(^|\/)\*\*\/?$/; - var invalidDotDotAfterRecursiveWildcardPattern = /(^|\/)\*\*\/(.*\/)?\.\.($|\/)/; - var watchRecursivePattern = /\/[^/]*?[*?][^/]*\//; var wildcardDirectoryPattern = /^[^*?]*(?=\/[^/]*[*?])/; function getFileNamesFromConfigSpecs(configFileSpecs, basePath, options, host, extraFileExtensions) { if (extraFileExtensions === void 0) { extraFileExtensions = ts.emptyArray; } @@ -31394,8 +32506,16 @@ var ts; return matchesExcludeWorker(pathToCheck, validatedExcludeSpecs, useCaseSensitiveFileNames, currentDirectory, basePath); } ts.isExcludedFile = isExcludedFile; + function invalidDotDotAfterRecursiveWildcard(s) { + var wildcardIndex = ts.startsWith(s, "**/") ? 0 : s.indexOf("/**/"); + if (wildcardIndex === -1) { + return false; + } + var lastDotIndex = ts.endsWith(s, "/..") ? s.length : s.lastIndexOf("/../"); + return lastDotIndex > wildcardIndex; + } function matchesExclude(pathToCheck, excludeSpecs, useCaseSensitiveFileNames, currentDirectory) { - return matchesExcludeWorker(pathToCheck, ts.filter(excludeSpecs, function (spec) { return !invalidDotDotAfterRecursiveWildcardPattern.test(spec); }), useCaseSensitiveFileNames, currentDirectory); + return matchesExcludeWorker(pathToCheck, ts.filter(excludeSpecs, function (spec) { return !invalidDotDotAfterRecursiveWildcard(spec); }), useCaseSensitiveFileNames, currentDirectory); } ts.matchesExclude = matchesExclude; function matchesExcludeWorker(pathToCheck, excludeSpecs, useCaseSensitiveFileNames, currentDirectory, basePath) { @@ -31428,7 +32548,7 @@ var ts; if (disallowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) { return [ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec]; } - else if (invalidDotDotAfterRecursiveWildcardPattern.test(spec)) { + else if (invalidDotDotAfterRecursiveWildcard(spec)) { return [ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec]; } } @@ -31473,9 +32593,14 @@ var ts; function getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames) { var match = wildcardDirectoryPattern.exec(spec); if (match) { + var questionWildcardIndex = spec.indexOf("?"); + var starWildcardIndex = spec.indexOf("*"); + var lastDirectorySeperatorIndex = spec.lastIndexOf(ts.directorySeparator); return { key: useCaseSensitiveFileNames ? match[0] : ts.toFileNameLowerCase(match[0]), - flags: watchRecursivePattern.test(spec) ? 1 : 0 + flags: (questionWildcardIndex !== -1 && questionWildcardIndex < lastDirectorySeperatorIndex) + || (starWildcardIndex !== -1 && starWildcardIndex < lastDirectorySeperatorIndex) + ? 1 : 0 }; } if (ts.isImplicitGlob(spec)) { @@ -31728,13 +32853,24 @@ var ts; return typeRoots; } var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types"); - function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference) { + function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, cache) { var traceEnabled = isTraceEnabled(options, host); if (redirectedReference) { options = redirectedReference.commandLine.options; } - var failedLookupLocations = []; - var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations }; + var containingDirectory = containingFile ? ts.getDirectoryPath(containingFile) : undefined; + var perFolderCache = containingDirectory ? cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference) : undefined; + var result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName); + if (result) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1, typeReferenceDirectiveName, containingFile); + if (redirectedReference) + trace(host, ts.Diagnostics.Using_compiler_options_of_project_reference_redirect_0, redirectedReference.sourceFile.fileName); + trace(host, ts.Diagnostics.Resolution_for_type_reference_directive_0_was_found_in_cache_from_location_1, typeReferenceDirectiveName, containingDirectory); + traceResult(result); + } + return result; + } var typeRoots = getEffectiveTypeRoots(options, host); if (traceEnabled) { if (containingFile === undefined) { @@ -31757,6 +32893,8 @@ var ts; trace(host, ts.Diagnostics.Using_compiler_options_of_project_reference_redirect_0, redirectedReference.sourceFile.fileName); } } + var failedLookupLocations = []; + var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache }; var resolved = primaryLookup(); var primary = true; if (!resolved) { @@ -31767,17 +32905,31 @@ var ts; if (resolved) { var fileName = resolved.fileName, packageId = resolved.packageId; var resolvedFileName = options.preserveSymlinks ? fileName : realPath(fileName, host, traceEnabled); - if (traceEnabled) { - if (packageId) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3, typeReferenceDirectiveName, resolvedFileName, ts.packageIdToString(packageId), primary); - } - else { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFileName, primary); - } + resolvedTypeReferenceDirective = { + primary: primary, + resolvedFileName: resolvedFileName, + originalPath: fileName === resolvedFileName ? undefined : fileName, + packageId: packageId, + isExternalLibraryImport: pathContainsNodeModules(fileName), + }; + } + result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations }; + perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, result); + if (traceEnabled) + traceResult(result); + return result; + function traceResult(result) { + var _a; + if (!((_a = result.resolvedTypeReferenceDirective) === null || _a === void 0 ? void 0 : _a.resolvedFileName)) { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); + } + else if (result.resolvedTypeReferenceDirective.packageId) { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3, typeReferenceDirectiveName, result.resolvedTypeReferenceDirective.resolvedFileName, ts.packageIdToString(result.resolvedTypeReferenceDirective.packageId), result.resolvedTypeReferenceDirective.primary); + } + else { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, result.resolvedTypeReferenceDirective.resolvedFileName, result.resolvedTypeReferenceDirective.primary); } - resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolvedFileName, packageId: packageId, isExternalLibraryImport: pathContainsNodeModules(fileName) }; } - return { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations }; function primaryLookup() { if (typeRoots && typeRoots.length) { if (traceEnabled) { @@ -31805,20 +32957,16 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); } - var result = void 0; + var result_4; if (!ts.isExternalModuleNameRelative(typeReferenceDirectiveName)) { var searchResult = loadModuleFromNearestNodeModulesDirectory(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, moduleResolutionState, undefined, undefined); - result = searchResult && searchResult.value; + result_4 = searchResult && searchResult.value; } else { var candidate = ts.normalizePathAndParts(ts.combinePaths(initialLocationForSecondaryLookup, typeReferenceDirectiveName)).path; - result = nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, false, moduleResolutionState, true); + result_4 = nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, false, moduleResolutionState, true); } - var resolvedFile = resolvedTypeScriptOnly(result); - if (!resolvedFile && traceEnabled) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); - } - return resolvedFile; + return resolvedTypeScriptOnly(result_4); } else { if (traceEnabled) { @@ -31858,21 +33006,20 @@ var ts; return result; } ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; - function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options) { - return createModuleResolutionCacheWithMaps(createCacheWithRedirects(options), createCacheWithRedirects(options), currentDirectory, getCanonicalFileName); - } - ts.createModuleResolutionCache = createModuleResolutionCache; function createCacheWithRedirects(options) { var ownMap = new ts.Map(); var redirectsMap = new ts.Map(); return { - ownMap: ownMap, + getOwnMap: getOwnMap, redirectsMap: redirectsMap, getOrCreateMapOfCacheRedirects: getOrCreateMapOfCacheRedirects, clear: clear, setOwnOptions: setOwnOptions, setOwnMap: setOwnMap }; + function getOwnMap() { + return ownMap; + } function setOwnOptions(newOptions) { options = newOptions; } @@ -31897,25 +33044,86 @@ var ts; } } ts.createCacheWithRedirects = createCacheWithRedirects; - function createModuleResolutionCacheWithMaps(directoryToModuleNameMap, moduleNameToDirectoryMap, currentDirectory, getCanonicalFileName) { - return { getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, directoryToModuleNameMap: directoryToModuleNameMap, moduleNameToDirectoryMap: moduleNameToDirectoryMap }; + function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName) { + var cache; + return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear }; + function getPackageJsonInfo(packageJsonPath) { + return cache === null || cache === void 0 ? void 0 : cache.get(ts.toPath(packageJsonPath, currentDirectory, getCanonicalFileName)); + } + function setPackageJsonInfo(packageJsonPath, info) { + (cache || (cache = new ts.Map())).set(ts.toPath(packageJsonPath, currentDirectory, getCanonicalFileName), info); + } + function clear() { + cache = undefined; + } + } + function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) { + var cache = cacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference); + var result = cache.get(key); + if (!result) { + result = create(); + cache.set(key, result); + } + return result; + } + function updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap) { + if (!options.configFile) + return; + if (directoryToModuleNameMap.redirectsMap.size === 0) { + ts.Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.redirectsMap.size === 0); + ts.Debug.assert(directoryToModuleNameMap.getOwnMap().size === 0); + ts.Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.getOwnMap().size === 0); + directoryToModuleNameMap.redirectsMap.set(options.configFile.path, directoryToModuleNameMap.getOwnMap()); + moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.redirectsMap.set(options.configFile.path, moduleNameToDirectoryMap.getOwnMap()); + } + else { + ts.Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.redirectsMap.size > 0); + var ref = { + sourceFile: options.configFile, + commandLine: { options: options } + }; + directoryToModuleNameMap.setOwnMap(directoryToModuleNameMap.getOrCreateMapOfCacheRedirects(ref)); + moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.setOwnMap(moduleNameToDirectoryMap.getOrCreateMapOfCacheRedirects(ref)); + } + directoryToModuleNameMap.setOwnOptions(options); + moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.setOwnOptions(options); + } + function createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap) { + return { + getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, + clear: clear, + update: update, + }; + function clear() { + directoryToModuleNameMap.clear(); + } + function update(options) { + updateRedirectsMap(options, directoryToModuleNameMap); + } function getOrCreateCacheForDirectory(directoryName, redirectedReference) { var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName); return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, function () { return new ts.Map(); }); } + } + function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options, directoryToModuleNameMap, moduleNameToDirectoryMap) { + var preDirectoryResolutionCache = 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; } }); + function clear() { + preDirectoryResolutionCache.clear(); + moduleNameToDirectoryMap.clear(); + packageJsonInfoCache.clear(); + } + function update(options) { + updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap); + } function getOrCreateCacheForModuleName(nonRelativeModuleName, redirectedReference) { ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName)); return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, nonRelativeModuleName, createPerModuleNameCache); } - function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) { - var cache = cacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference); - var result = cache.get(key); - if (!result) { - result = create(); - cache.set(key, result); - } - return result; - } function createPerModuleNameCache() { var directoryPathMap = new ts.Map(); return { get: get, set: set }; @@ -31963,7 +33171,17 @@ var ts; } } } - ts.createModuleResolutionCacheWithMaps = createModuleResolutionCacheWithMaps; + ts.createModuleResolutionCache = createModuleResolutionCache; + function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache, directoryToModuleNameMap) { + var preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options))); + packageJsonInfoCache || (packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName)); + return __assign(__assign(__assign({}, packageJsonInfoCache), preDirectoryResolutionCache), { clear: clear }); + function clear() { + preDirectoryResolutionCache.clear(); + packageJsonInfoCache.clear(); + } + } + ts.createTypeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache; function resolveModuleNameFromCache(moduleName, containingFile, cache) { var containingDirectory = ts.getDirectoryPath(containingFile); var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); @@ -32051,7 +33269,8 @@ var ts; } } function tryLoadModuleUsingPathsIfEligible(extensions, moduleName, loader, state) { - var _a = state.compilerOptions, baseUrl = _a.baseUrl, paths = _a.paths; + var _a; + var _b = state.compilerOptions, baseUrl = _b.baseUrl, paths = _b.paths, configFile = _b.configFile; if (paths && !ts.pathIsRelative(moduleName)) { if (state.traceEnabled) { if (baseUrl) { @@ -32060,7 +33279,8 @@ var ts; trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); } var baseDirectory = ts.getPathsBasePath(state.compilerOptions, state.host); - return tryLoadModuleUsingPaths(extensions, moduleName, baseDirectory, paths, loader, false, state); + var pathPatterns = (configFile === null || configFile === void 0 ? void 0 : configFile.configFileSpecs) ? (_a = configFile.configFileSpecs).pathPatterns || (_a.pathPatterns = ts.tryParsePatterns(paths)) : undefined; + return tryLoadModuleUsingPaths(extensions, moduleName, baseDirectory, paths, pathPatterns, loader, false, state); } } function tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, state) { @@ -32167,7 +33387,7 @@ var ts; var _a, _b; var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations }; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache }; var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); }); return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, state.resultFromCache); function tryResolve(extensions) { @@ -32225,7 +33445,7 @@ var ts; } var resolvedFromFile = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state); if (resolvedFromFile) { - var packageDirectory = considerPackageJson ? parseNodeModuleFromPath(resolvedFromFile) : undefined; + var packageDirectory = considerPackageJson ? parseNodeModuleFromPath(resolvedFromFile.path) : undefined; var packageInfo = packageDirectory ? getPackageJsonInfo(packageDirectory, false, state) : undefined; return withPackageId(packageInfo, resolvedFromFile); } @@ -32247,7 +33467,7 @@ var ts; } ts.pathContainsNodeModules = pathContainsNodeModules; function parseNodeModuleFromPath(resolved) { - var path = ts.normalizePath(resolved.path); + var path = ts.normalizePath(resolved); var idx = path.lastIndexOf(ts.nodeModulesPathPart); if (idx === -1) { return undefined; @@ -32259,6 +33479,7 @@ var ts; } return path.slice(0, indexAfterPackageName); } + ts.parseNodeModuleFromPath = parseNodeModuleFromPath; function moveToNextDirectorySeparatorIfAvailable(path, prevSeparatorIndex) { var nextSeparatorIndex = path.indexOf(ts.directorySeparator, prevSeparatorIndex + 1); return nextSeparatorIndex === -1 ? prevSeparatorIndex : nextSeparatorIndex; @@ -32332,21 +33553,43 @@ var ts; return withPackageId(packageInfo, loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJsonContent, versionPaths)); } function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) { + var _a, _b, _c; var host = state.host, traceEnabled = state.traceEnabled; - var directoryExists = !onlyRecordFailures && ts.directoryProbablyExists(packageDirectory, host); var packageJsonPath = ts.combinePaths(packageDirectory, "package.json"); + if (onlyRecordFailures) { + state.failedLookupLocations.push(packageJsonPath); + return undefined; + } + var existing = (_a = state.packageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.getPackageJsonInfo(packageJsonPath); + if (existing !== undefined) { + if (typeof existing !== "boolean") { + if (traceEnabled) + trace(host, ts.Diagnostics.File_0_exists_according_to_earlier_cached_lookups, packageJsonPath); + return existing; + } + else { + if (existing && traceEnabled) + trace(host, ts.Diagnostics.File_0_does_not_exist_according_to_earlier_cached_lookups, packageJsonPath); + state.failedLookupLocations.push(packageJsonPath); + return undefined; + } + } + var directoryExists = ts.directoryProbablyExists(packageDirectory, host); if (directoryExists && host.fileExists(packageJsonPath)) { var packageJsonContent = ts.readJson(packageJsonPath, host); if (traceEnabled) { trace(host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); } var versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state); - return { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths }; + var result = { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths }; + (_b = state.packageJsonInfoCache) === null || _b === void 0 ? void 0 : _b.setPackageJsonInfo(packageJsonPath, result); + return result; } else { if (directoryExists && traceEnabled) { trace(host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); } + (_c = state.packageJsonInfoCache) === null || _c === void 0 ? void 0 : _c.setPackageJsonInfo(packageJsonPath, directoryExists); state.failedLookupLocations.push(packageJsonPath); } } @@ -32393,7 +33636,7 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2, versionPaths.version, ts.version, moduleName); } - var result = tryLoadModuleUsingPaths(extensions, moduleName, candidate, versionPaths.paths, loader, onlyRecordFailuresForPackageFile || onlyRecordFailuresForIndex, state); + var result = tryLoadModuleUsingPaths(extensions, moduleName, candidate, versionPaths.paths, undefined, loader, onlyRecordFailuresForPackageFile || onlyRecordFailuresForIndex, state); if (result) { return removeIgnoredPackageId(result.value); } @@ -32493,7 +33736,7 @@ var ts; trace(state.host, ts.Diagnostics.package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2, packageInfo.versionPaths.version, ts.version, rest); } var packageDirectoryExists = nodeModulesDirectoryExists && ts.directoryProbablyExists(packageDirectory, state.host); - var fromPaths = tryLoadModuleUsingPaths(extensions, rest, packageDirectory, packageInfo.versionPaths.paths, loader, !packageDirectoryExists, state); + var fromPaths = tryLoadModuleUsingPaths(extensions, rest, packageDirectory, packageInfo.versionPaths.paths, undefined, loader, !packageDirectoryExists, state); if (fromPaths) { return fromPaths.value; } @@ -32501,8 +33744,9 @@ var ts; } return loader(extensions, candidate, !nodeModulesDirectoryExists, state); } - function tryLoadModuleUsingPaths(extensions, moduleName, baseDirectory, paths, loader, onlyRecordFailures, state) { - var matchedPattern = ts.matchPatternOrExact(ts.getOwnKeys(paths), moduleName); + function tryLoadModuleUsingPaths(extensions, moduleName, baseDirectory, paths, pathPatterns, loader, onlyRecordFailures, state) { + pathPatterns || (pathPatterns = ts.tryParsePatterns(paths)); + var matchedPattern = ts.matchPatternOrExact(pathPatterns, moduleName); if (matchedPattern) { var matchedStar_1 = ts.isString(matchedPattern) ? undefined : ts.matchedText(matchedPattern, moduleName); var matchedPatternText = ts.isString(matchedPattern) ? matchedPattern : ts.patternText(matchedPattern); @@ -32576,7 +33820,7 @@ var ts; function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) { var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations }; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache }; var containingDirectory = ts.getDirectoryPath(containingFile); var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, false, failedLookupLocations, state.resultFromCache); @@ -32609,13 +33853,13 @@ var ts; } } ts.classicNameResolver = classicNameResolver; - function loadModuleFromGlobalCache(moduleName, projectName, compilerOptions, host, globalCache) { + function loadModuleFromGlobalCache(moduleName, projectName, compilerOptions, host, globalCache, packageJsonInfoCache) { var traceEnabled = isTraceEnabled(compilerOptions, host); if (traceEnabled) { trace(host, ts.Diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2, projectName, moduleName, globalCache); } var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations }; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: packageJsonInfoCache }; var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, false); return createResolvedModuleWithFailedLookupLocations(resolved, true, failedLookupLocations, state.resultFromCache); } @@ -32647,23 +33891,23 @@ var ts; } function getModuleInstanceStateWorker(node, visited) { switch (node.kind) { - case 253: - case 254: - return 0; case 255: + case 256: + return 0; + case 257: if (ts.isEnumConst(node)) { return 2; } break; - case 261: - case 260: + case 263: + case 262: if (!(ts.hasSyntacticModifier(node, 1))) { return 0; } break; - case 267: + case 269: var exportDeclaration = node; - if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 268) { + if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 270) { var state = 0; for (var _i = 0, _a = exportDeclaration.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; @@ -32678,7 +33922,7 @@ var ts; return state; } break; - case 257: { + case 259: { var state_1 = 0; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateCached(n, visited); @@ -32697,9 +33941,9 @@ var ts; }); return state_1; } - case 256: + case 258: return getModuleInstanceState(node, visited); - case 78: + case 79: if (node.isInJSDocNamespace) { return 0; } @@ -32743,14 +33987,14 @@ var ts; } var binder = createBinder(); function bindSourceFile(file, options) { - ts.tracing.push("bind", "bindSourceFile", { path: file.path }, true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("bind", "bindSourceFile", { path: file.path }, true); ts.performance.mark("beforeBind"); ts.perfLogger.logStartBindFile("" + file.fileName); binder(file, options); ts.perfLogger.logStopBindFile(); ts.performance.mark("afterBind"); ts.performance.measure("Bind", "beforeBind", "afterBind"); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } ts.bindSourceFile = bindSourceFile; function createBinder() { @@ -32782,6 +34026,7 @@ var ts; var classifiableNames; var unreachableFlow = { flags: 1 }; var reportedUnreachableFlow = { flags: 1 }; + var bindBinaryExpressionFlow = createBindBinaryExpressionFlow(); function createDiagnosticForNode(node, message, arg0, arg1, arg2) { return ts.createDiagnosticForNodeInSourceFile(ts.getSourceFileOfNode(node) || file, node, message, arg0, arg1, arg2); } @@ -32854,7 +34099,7 @@ var ts; } } function getDeclarationName(node) { - if (node.kind === 266) { + if (node.kind === 268) { return node.isExportEquals ? "export=" : "default"; } var name = ts.getNameOfDeclaration(node); @@ -32863,7 +34108,7 @@ var ts; var moduleName = ts.getTextOfIdentifierOrLiteral(name); return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); } - if (name.kind === 158) { + if (name.kind === 160) { var nameExpression = name.expression; if (ts.isStringOrNumericLiteralLike(nameExpression)) { return ts.escapeLeadingUnderscores(nameExpression.text); @@ -32871,11 +34116,9 @@ var ts; if (ts.isSignedNumericLiteral(nameExpression)) { return ts.tokenToString(nameExpression.operator) + nameExpression.operand.text; } - ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); - return ts.getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); - } - if (ts.isWellKnownSymbolSyntactically(name)) { - return ts.getPropertyNameForKnownSymbolName(ts.idText(name.name)); + else { + ts.Debug.fail("Only computed properties with literal names have declaration names"); + } } if (ts.isPrivateIdentifier(name)) { var containingClass = ts.getContainingClass(node); @@ -32888,31 +34131,31 @@ var ts; return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 166: + case 168: return "__constructor"; - case 174: - case 169: - case 313: + case 176: + case 171: + case 317: return "__call"; - case 175: - case 170: + case 177: + case 172: return "__new"; - case 171: + case 173: return "__index"; - case 267: + case 269: return "__export"; - case 297: + case 299: return "export="; - case 216: + case 218: if (ts.getAssignmentDeclarationKind(node) === 2) { return "export="; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 308: + case 311: return (ts.isJSDocConstructSignature(node) ? "__new" : "__call"); - case 160: - ts.Debug.assert(node.parent.kind === 308, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); + case 162: + ts.Debug.assert(node.parent.kind === 311, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); var functionType = node.parent; var index = functionType.parameters.indexOf(node); return "arg" + index; @@ -32967,7 +34210,7 @@ var ts; } else { if (symbol.declarations && symbol.declarations.length && - (node.kind === 266 && !node.isExportEquals)) { + (node.kind === 268 && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; messageNeedsName_1 = false; multipleDefaultExports_1 = true; @@ -33005,7 +34248,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = !!(ts.getCombinedModifierFlags(node) & 1) || jsdocTreatAsExported(node); if (symbolFlags & 2097152) { - if (node.kind === 270 || (node.kind === 260 && hasExportModifier)) { + if (node.kind === 272 || (node.kind === 262 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -33052,7 +34295,7 @@ var ts; var saveThisParentContainer = thisParentContainer; var savedBlockScopeContainer = blockScopeContainer; if (containerFlags & 1) { - if (node.kind !== 209) { + if (node.kind !== 211) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -33081,7 +34324,7 @@ var ts; currentFlow.node = node; } } - currentReturnTarget = isIIFE || node.kind === 166 || (ts.isInJSFile(node) && (node.kind === 251 || node.kind === 208)) ? createBranchLabel() : undefined; + currentReturnTarget = isIIFE || node.kind === 168 || (ts.isInJSFile(node) && (node.kind === 253 || node.kind === 210)) ? createBranchLabel() : undefined; currentExceptionTarget = undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; @@ -33095,13 +34338,14 @@ var ts; node.flags |= 512; node.endFlowNode = currentFlow; } - if (node.kind === 297) { + if (node.kind === 299) { node.flags |= emitFlags; + node.endFlowNode = currentFlow; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 166 || (ts.isInJSFile(node) && (node.kind === 251 || node.kind === 208))) { + if (node.kind === 168 || (ts.isInJSFile(node) && (node.kind === 253 || node.kind === 210))) { node.returnFlowNode = currentFlow; } } @@ -33128,8 +34372,8 @@ var ts; blockScopeContainer = savedBlockScopeContainer; } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 251 ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 251 ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 253 ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 253 ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -33150,59 +34394,59 @@ var ts; inAssignmentPattern = saveInAssignmentPattern; return; } - if (node.kind >= 232 && node.kind <= 248 && !options.allowUnreachableCode) { + if (node.kind >= 234 && node.kind <= 250 && !options.allowUnreachableCode) { node.flowNode = currentFlow; } switch (node.kind) { - case 236: + case 238: bindWhileStatement(node); break; - case 235: + case 237: bindDoStatement(node); break; - case 237: + case 239: bindForStatement(node); break; - case 238: - case 239: + case 240: + case 241: bindForInOrForOfStatement(node); break; - case 234: + case 236: bindIfStatement(node); break; - case 242: - case 246: + case 244: + case 248: bindReturnOrThrow(node); break; - case 241: - case 240: + case 243: + case 242: bindBreakOrContinueStatement(node); break; - case 247: + case 249: bindTryStatement(node); break; - case 244: + case 246: bindSwitchStatement(node); break; - case 258: + case 260: bindCaseBlock(node); break; - case 284: + case 286: bindCaseClause(node); break; - case 233: + case 235: bindExpressionStatement(node); break; - case 245: + case 247: bindLabeledStatement(node); break; - case 214: + case 216: bindPrefixUnaryExpressionFlow(node); break; - case 215: + case 217: bindPostfixUnaryExpressionFlow(node); break; - case 216: + case 218: if (ts.isDestructuringAssignment(node)) { inAssignmentPattern = saveInAssignmentPattern; bindDestructuringAssignmentFlow(node); @@ -33210,46 +34454,46 @@ var ts; } bindBinaryExpressionFlow(node); break; - case 210: + case 212: bindDeleteExpressionFlow(node); break; - case 217: + case 219: bindConditionalExpressionFlow(node); break; - case 249: + case 251: bindVariableDeclarationFlow(node); break; - case 201: - case 202: + case 203: + case 204: bindAccessExpressionFlow(node); break; - case 203: + case 205: bindCallExpressionFlow(node); break; - case 225: + case 227: bindNonNullExpressionFlow(node); break; - case 331: - case 324: - case 325: + case 339: + case 332: + case 333: bindJSDocTypeAlias(node); break; - case 297: { + case 299: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; } - case 230: - case 257: + case 232: + case 259: bindEachFunctionsFirst(node.statements); break; - case 198: + case 200: bindBindingElementFlow(node); break; - case 200: - case 199: - case 288: - case 220: + case 202: + case 201: + case 290: + case 222: inAssignmentPattern = saveInAssignmentPattern; default: bindEachChild(node); @@ -33260,32 +34504,32 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 78: case 79: - case 107: - case 201: - case 202: - return containsNarrowableReference(expr); + case 80: + case 108: case 203: + case 204: + return containsNarrowableReference(expr); + case 205: return hasNarrowableArgument(expr); - case 207: - case 225: + case 209: + case 227: return isNarrowingExpression(expr.expression); - case 216: + case 218: return isNarrowingBinaryExpression(expr); - case 214: + case 216: return expr.operator === 53 && isNarrowingExpression(expr.operand); - case 211: + case 213: return isNarrowingExpression(expr.expression); } return false; } function isNarrowableReference(expr) { - return expr.kind === 78 || expr.kind === 79 || expr.kind === 107 || expr.kind === 105 || - (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) || - ts.isBinaryExpression(expr) && expr.operatorToken.kind === 27 && isNarrowableReference(expr.right) || - ts.isElementAccessExpression(expr) && ts.isStringOrNumericLiteralLike(expr.argumentExpression) && isNarrowableReference(expr.expression) || - ts.isAssignmentExpression(expr) && isNarrowableReference(expr.left); + return ts.isDottedName(expr) + || (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) + || ts.isBinaryExpression(expr) && expr.operatorToken.kind === 27 && isNarrowableReference(expr.right) + || ts.isElementAccessExpression(expr) && ts.isStringOrNumericLiteralLike(expr.argumentExpression) && isNarrowableReference(expr.expression) + || ts.isAssignmentExpression(expr) && isNarrowableReference(expr.left); } function containsNarrowableReference(expr) { return isNarrowableReference(expr) || ts.isOptionalChain(expr) && containsNarrowableReference(expr.expression); @@ -33299,7 +34543,7 @@ var ts; } } } - if (expr.expression.kind === 201 && + if (expr.expression.kind === 203 && containsNarrowableReference(expr.expression.expression)) { return true; } @@ -33313,10 +34557,10 @@ var ts; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 62: - case 74: + case 63: case 75: case 76: + case 77: return containsNarrowableReference(expr.left); case 34: case 35: @@ -33324,9 +34568,9 @@ var ts; case 37: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 101: + case 102: return isNarrowableOperand(expr.left); - case 100: + case 101: return isNarrowableInOperands(expr.left, expr.right); case 27: return isNarrowingExpression(expr.right); @@ -33335,11 +34579,11 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 207: + case 209: return isNarrowableOperand(expr.expression); - case 216: + case 218: switch (expr.operatorToken.kind) { - case 62: + case 63: return isNarrowableOperand(expr.left); case 27: return isNarrowableOperand(expr.right); @@ -33372,8 +34616,8 @@ var ts; if (!expression) { return flags & 32 ? antecedent : unreachableFlow; } - if ((expression.kind === 109 && flags & 64 || - expression.kind === 94 && flags & 32) && + if ((expression.kind === 110 && flags & 64 || + expression.kind === 95 && flags & 32) && !ts.isExpressionOfOptionalChainRoot(expression) && !ts.isNullishCoalesce(expression.parent)) { return unreachableFlow; } @@ -33412,26 +34656,26 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 234: case 236: - case 235: - return parent.expression === node; + case 238: case 237: - case 217: + return parent.expression === node; + case 239: + case 219: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 207) { + if (node.kind === 209) { node = node.expression; } - else if (node.kind === 214 && node.operator === 53) { + else if (node.kind === 216 && node.operator === 53) { node = node.operand; } else { - return node.kind === 216 && (node.operatorToken.kind === 55 || + return node.kind === 218 && (node.operatorToken.kind === 55 || node.operatorToken.kind === 56 || node.operatorToken.kind === 60); } @@ -33478,7 +34722,7 @@ var ts; } function setContinueTarget(node, target) { var label = activeLabelList; - while (label && node.parent.kind === 245) { + while (label && node.parent.kind === 247) { label.continueTarget = target; label = label.next; node = node.parent; @@ -33529,12 +34773,12 @@ var ts; bind(node.expression); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 239) { + if (node.kind === 241) { bind(node.awaitModifier); } addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 250) { + if (node.initializer.kind !== 252) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -33556,7 +34800,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 242) { + if (node.kind === 244) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -33573,7 +34817,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 241 ? breakTarget : continueTarget; + var flowLabel = node.kind === 243 ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -33646,7 +34890,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 285; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 287; }); node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; if (!hasDefault) { addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0)); @@ -33689,9 +34933,9 @@ var ts; maybeBindExpressionFlowIfCall(node.expression); } function maybeBindExpressionFlowIfCall(node) { - if (node.kind === 203) { + if (node.kind === 205) { var call = node; - if (ts.isDottedName(call.expression) && call.expression.kind !== 105) { + if (call.expression.kind !== 106 && ts.isDottedName(call.expression)) { currentFlow = createFlowCall(currentFlow, call); } } @@ -33715,7 +34959,7 @@ var ts; currentFlow = finishFlowLabel(postStatementLabel); } function bindDestructuringTargetFlow(node) { - if (node.kind === 216 && node.operatorToken.kind === 62) { + if (node.kind === 218 && node.operatorToken.kind === 63) { bindAssignmentTargetFlow(node.left); } else { @@ -33726,10 +34970,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowMutation(16, currentFlow, node); } - else if (node.kind === 199) { + else if (node.kind === 201) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 220) { + if (e.kind === 222) { bindAssignmentTargetFlow(e.expression); } else { @@ -33737,16 +34981,16 @@ var ts; } } } - else if (node.kind === 200) { + else if (node.kind === 202) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 288) { + if (p.kind === 290) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 289) { + else if (p.kind === 291) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 290) { + else if (p.kind === 292) { bindAssignmentTargetFlow(p.expression); } } @@ -33754,7 +34998,7 @@ var ts; } function bindLogicalLikeExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 55 || node.operatorToken.kind === 75) { + if (node.operatorToken.kind === 55 || node.operatorToken.kind === 76) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -33811,108 +35055,97 @@ var ts; } bindAssignmentTargetFlow(node.left); } - function bindBinaryExpressionFlow(node) { - var workStacks = { - expr: [node], - state: [1], - inStrictMode: [undefined], - parent: [undefined], - }; - var stackIndex = 0; - while (stackIndex >= 0) { - node = workStacks.expr[stackIndex]; - switch (workStacks.state[stackIndex]) { - case 0: { - ts.setParent(node, parent); - var saveInStrictMode = inStrictMode; - bindWorker(node); - var saveParent = parent; - parent = node; - advanceState(1, saveInStrictMode, saveParent); - break; - } - case 1: { - var operator = node.operatorToken.kind; - if (operator === 55 || operator === 56 || operator === 60 || - ts.isLogicalOrCoalescingAssignmentOperator(operator)) { - if (isTopLevelLogicalExpression(node)) { - var postExpressionLabel = createBranchLabel(); - bindLogicalLikeExpression(node, postExpressionLabel, postExpressionLabel); - currentFlow = finishFlowLabel(postExpressionLabel); - } - else { - bindLogicalLikeExpression(node, currentTrueTarget, currentFalseTarget); - } - completeNode(); - } - else { - advanceState(2); - maybeBind(node.left); - } - break; + function createBindBinaryExpressionFlow() { + return ts.createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, undefined); + function onEnter(node, state) { + if (state) { + state.stackIndex++; + ts.setParent(node, parent); + var saveInStrictMode = inStrictMode; + bindWorker(node); + var saveParent = parent; + parent = node; + state.skip = false; + state.inStrictModeStack[state.stackIndex] = saveInStrictMode; + state.parentStack[state.stackIndex] = saveParent; + } + else { + state = { + stackIndex: 0, + skip: false, + inStrictModeStack: [undefined], + parentStack: [undefined] + }; + } + var operator = node.operatorToken.kind; + if (operator === 55 || + operator === 56 || + operator === 60 || + ts.isLogicalOrCoalescingAssignmentOperator(operator)) { + if (isTopLevelLogicalExpression(node)) { + var postExpressionLabel = createBranchLabel(); + bindLogicalLikeExpression(node, postExpressionLabel, postExpressionLabel); + currentFlow = finishFlowLabel(postExpressionLabel); } - case 2: { - if (node.operatorToken.kind === 27) { - maybeBindExpressionFlowIfCall(node.left); - } - advanceState(3); - maybeBind(node.operatorToken); - break; + else { + bindLogicalLikeExpression(node, currentTrueTarget, currentFalseTarget); } - case 3: { - advanceState(4); - maybeBind(node.right); - break; + state.skip = true; + } + return state; + } + function onLeft(left, state, _node) { + if (!state.skip) { + return maybeBind(left); + } + } + function onOperator(operatorToken, state, node) { + if (!state.skip) { + if (operatorToken.kind === 27) { + maybeBindExpressionFlowIfCall(node.left); } - case 4: { - var operator = node.operatorToken.kind; - if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { - bindAssignmentTargetFlow(node.left); - if (operator === 62 && node.left.kind === 202) { - var elementAccess = node.left; - if (isNarrowableOperand(elementAccess.expression)) { - currentFlow = createFlowMutation(256, currentFlow, node); - } + bind(operatorToken); + } + } + function onRight(right, state, _node) { + if (!state.skip) { + return maybeBind(right); + } + } + function onExit(node, state) { + if (!state.skip) { + var operator = node.operatorToken.kind; + if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { + bindAssignmentTargetFlow(node.left); + if (operator === 63 && node.left.kind === 204) { + var elementAccess = node.left; + if (isNarrowableOperand(elementAccess.expression)) { + currentFlow = createFlowMutation(256, currentFlow, node); } } - completeNode(); - break; } - default: return ts.Debug.fail("Invalid state " + workStacks.state[stackIndex] + " for bindBinaryExpressionFlow"); } - } - function advanceState(state, isInStrictMode, parent) { - workStacks.state[stackIndex] = state; - if (isInStrictMode !== undefined) { - workStacks.inStrictMode[stackIndex] = isInStrictMode; + var savedInStrictMode = state.inStrictModeStack[state.stackIndex]; + var savedParent = state.parentStack[state.stackIndex]; + if (savedInStrictMode !== undefined) { + inStrictMode = savedInStrictMode; } - if (parent !== undefined) { - workStacks.parent[stackIndex] = parent; + if (savedParent !== undefined) { + parent = savedParent; } - } - function completeNode() { - if (workStacks.inStrictMode[stackIndex] !== undefined) { - inStrictMode = workStacks.inStrictMode[stackIndex]; - parent = workStacks.parent[stackIndex]; - } - stackIndex--; + state.skip = false; + state.stackIndex--; } function maybeBind(node) { if (node && ts.isBinaryExpression(node) && !ts.isDestructuringAssignment(node)) { - stackIndex++; - workStacks.expr[stackIndex] = node; - workStacks.state[stackIndex] = 0; - workStacks.inStrictMode[stackIndex] = undefined; - workStacks.parent[stackIndex] = undefined; - } - else { - bind(node); + return node; } + bind(node); } } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 201) { + if (node.expression.kind === 203) { bindAssignmentTargetFlow(node.expression); } } @@ -33964,7 +35197,7 @@ var ts; } function bindJSDocTypeAlias(node) { ts.setParent(node.tagName, node); - if (node.kind !== 325 && node.fullName) { + if (node.kind !== 333 && node.fullName) { ts.setParent(node.fullName, node); ts.setParentRecursive(node.fullName, false); } @@ -33972,7 +35205,7 @@ var ts; function bindJSDocClassTag(node) { bindEachChild(node); var host = ts.getHostSignatureFromJSDoc(node); - if (host && host.kind !== 165) { + if (host && host.kind !== 167) { addDeclarationToSymbol(host.symbol, host, 32); } } @@ -33985,15 +35218,15 @@ var ts; } function bindOptionalChainRest(node) { switch (node.kind) { - case 201: + case 203: bind(node.questionDotToken); bind(node.name); break; - case 202: + case 204: bind(node.questionDotToken); bind(node.argumentExpression); break; - case 203: + case 205: bind(node.questionDotToken); bindEach(node.typeArguments); bindEach(node.arguments); @@ -34044,19 +35277,19 @@ var ts; } else { var expr = ts.skipParentheses(node.expression); - if (expr.kind === 208 || expr.kind === 209) { + if (expr.kind === 210 || expr.kind === 211) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); } else { bindEachChild(node); - if (node.expression.kind === 105) { + if (node.expression.kind === 106) { currentFlow = createFlowCall(currentFlow, node); } } } - if (node.expression.kind === 201) { + if (node.expression.kind === 203) { var propertyAccess = node.expression; if (ts.isIdentifier(propertyAccess.name) && isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowMutation(256, currentFlow, node); @@ -34065,53 +35298,53 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 221: - case 252: - case 255: - case 200: - case 177: - case 312: - case 281: + case 223: + case 254: + case 257: + case 202: + case 179: + case 316: + case 283: return 1; - case 253: + case 255: return 1 | 64; + case 258: case 256: - case 254: - case 190: + case 192: return 1 | 32; - case 297: + case 299: return 1 | 4 | 32; - case 165: + case 167: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 | 4 | 32 | 8 | 128; } - case 166: - case 251: - case 164: - case 167: case 168: + case 253: + case 166: case 169: - case 313: - case 308: - case 174: case 170: case 171: - case 175: + case 317: + case 311: + case 176: + case 172: + case 173: + case 177: return 1 | 4 | 32 | 8; - case 208: - case 209: + case 210: + case 211: return 1 | 4 | 32 | 8 | 16; - case 257: + case 259: return 4; - case 163: + case 165: return node.initializer ? 4 : 0; - case 287: - case 237: - case 238: + case 289: case 239: - case 258: + case 240: + case 241: + case 260: return 2; - case 230: + case 232: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -34124,40 +35357,40 @@ var ts; } function declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 256: + case 258: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 297: + case 299: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 221: - case 252: + case 223: + case 254: return declareClassMember(node, symbolFlags, symbolExcludes); - case 255: + case 257: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 177: - case 312: - case 200: - case 253: - case 281: + case 179: + case 316: + case 202: + case 255: + case 283: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 174: - case 175: - case 169: - case 170: - case 313: + case 176: + case 177: case 171: - case 165: - case 164: - case 166: + case 172: + case 317: + case 173: case 167: + case 166: case 168: - case 251: - case 208: - case 209: - case 308: - case 331: - case 324: - case 254: - case 190: + case 169: + case 170: + case 253: + case 210: + case 211: + case 311: + case 339: + case 332: + case 256: + case 192: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -34196,15 +35429,13 @@ var ts; var pattern = void 0; if (node.name.kind === 10) { var text = node.name.text; - if (ts.hasZeroOrOneAsteriskCharacter(text)) { - pattern = ts.tryParsePattern(text); - } - else { + 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, 110735); - file.patternAmbientModules = ts.append(file.patternAmbientModules, pattern && { pattern: pattern, symbol: symbol }); + file.patternAmbientModules = ts.append(file.patternAmbientModules, pattern && !ts.isString(pattern) ? { pattern: pattern, symbol: symbol } : undefined); } } else { @@ -34236,11 +35467,11 @@ 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 === 290 || prop.name.kind !== 78) { + if (prop.kind === 292 || prop.name.kind !== 79) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 288 || prop.kind === 289 || prop.kind === 165 + var currentKind = prop.kind === 290 || prop.kind === 291 || prop.kind === 167 ? 1 : 2; var existingKind = seen.get(identifier.escapedText); @@ -34272,10 +35503,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 256: + case 258: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 297: + case 299: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -34299,9 +35530,9 @@ var ts; var saveCurrentFlow = currentFlow; for (var _i = 0, delayedTypeAliases_1 = delayedTypeAliases; _i < delayedTypeAliases_1.length; _i++) { var typeAlias = delayedTypeAliases_1[_i]; - var host = ts.getJSDocHost(typeAlias); - container = (host && ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1); })) || file; - blockScopeContainer = (host && ts.getEnclosingBlockScopeContainer(host)) || file; + var host = typeAlias.parent.parent; + container = ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1); }) || file; + blockScopeContainer = ts.getEnclosingBlockScopeContainer(host) || file; currentFlow = initFlowNode({ flags: 2 }); parent = typeAlias; bind(typeAlias.typeExpression); @@ -34341,7 +35572,7 @@ var ts; container = oldContainer; } } - else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 78) { + else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 79) { parent = typeAlias.parent; bindBlockScopedDeclaration(typeAlias, 524288, 788968); } @@ -34361,11 +35592,11 @@ var ts; !(node.flags & 4194304) && !ts.isIdentifierName(node)) { if (inStrictMode && - node.originalKeywordKind >= 116 && - node.originalKeywordKind <= 124) { + node.originalKeywordKind >= 117 && + node.originalKeywordKind <= 125) { file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); } - else if (node.originalKeywordKind === 130) { + else if (node.originalKeywordKind === 131) { 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))); } @@ -34373,7 +35604,7 @@ var ts; 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 === 124 && node.flags & 8192) { + else if (node.originalKeywordKind === 125 && node.flags & 8192) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node))); } } @@ -34405,7 +35636,7 @@ var ts; } } function checkStrictModeDeleteExpression(node) { - if (inStrictMode && node.expression.kind === 78) { + if (inStrictMode && node.expression.kind === 79) { var span = ts.getErrorSpanForNode(file, node.expression); file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode)); } @@ -34414,7 +35645,7 @@ var ts; return ts.isIdentifier(node) && (node.escapedText === "eval" || node.escapedText === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 78) { + if (name && name.kind === 79) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { var span = ts.getErrorSpanForNode(file, name); @@ -34447,8 +35678,8 @@ var ts; } function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2) { - if (blockScopeContainer.kind !== 297 && - blockScopeContainer.kind !== 256 && + if (blockScopeContainer.kind !== 299 && + blockScopeContainer.kind !== 258 && !ts.isFunctionLike(blockScopeContainer)) { var errorSpan = ts.getErrorSpanForNode(file, node); file.bindDiagnostics.push(ts.createFileDiagnostic(file, errorSpan.start, errorSpan.length, getStrictModeBlockScopeFunctionDeclarationMessage(node))); @@ -34510,7 +35741,7 @@ var ts; ts.setParent(node, parent); var saveInStrictMode = inStrictMode; bindWorker(node); - if (node.kind > 156) { + if (node.kind > 158) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -34568,7 +35799,7 @@ var ts; } function bindWorker(node) { switch (node.kind) { - case 78: + case 79: if (node.isInJSDocNamespace) { var parentNode = node.parent; while (parentNode && !ts.isJSDocTypeAlias(parentNode)) { @@ -34577,18 +35808,24 @@ var ts; bindBlockScopedDeclaration(parentNode, 524288, 788968); break; } - case 107: - if (currentFlow && (ts.isExpression(node) || parent.kind === 289)) { + case 108: + if (currentFlow && (ts.isExpression(node) || parent.kind === 291)) { node.flowNode = currentFlow; } return checkContextualIdentifier(node); - case 105: + case 159: + if (currentFlow && ts.isPartOfTypeQuery(node)) { + node.flowNode = currentFlow; + } + break; + case 228: + case 106: node.flowNode = currentFlow; break; - case 79: + case 80: return checkPrivateIdentifier(node); - case 201: - case 202: + case 203: + case 204: var expr = node; if (currentFlow && isNarrowableReference(expr)) { expr.flowNode = currentFlow; @@ -34603,7 +35840,7 @@ var ts; declareSymbol(file.locals, undefined, expr.expression, 1 | 134217728, 111550); } break; - case 216: + case 218: var specialKind = ts.getAssignmentDeclarationKind(node); switch (specialKind) { case 1: @@ -34638,74 +35875,74 @@ var ts; ts.Debug.fail("Unknown binary expression special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 287: + case 289: return checkStrictModeCatchClause(node); - case 210: + case 212: return checkStrictModeDeleteExpression(node); case 8: return checkStrictModeNumericLiteral(node); - case 215: + case 217: return checkStrictModePostfixUnaryExpression(node); - case 214: + case 216: return checkStrictModePrefixUnaryExpression(node); - case 243: - return checkStrictModeWithStatement(node); case 245: + return checkStrictModeWithStatement(node); + case 247: return checkStrictModeLabeledStatement(node); - case 187: + case 189: seenThisKeyword = true; return; - case 172: + case 174: break; - case 159: + case 161: return bindTypeParameter(node); - case 160: + case 162: return bindParameter(node); - case 249: + case 251: return bindVariableDeclarationOrBindingElement(node); - case 198: + case 200: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); - case 163: - case 162: + case 165: + case 164: return bindPropertyWorker(node); - case 288: - case 289: - return bindPropertyOrMethodOrAccessor(node, 4, 0); + case 290: case 291: + return bindPropertyOrMethodOrAccessor(node, 4, 0); + case 293: return bindPropertyOrMethodOrAccessor(node, 8, 900095); - case 169: - case 170: case 171: + case 172: + case 173: return declareSymbolAndAddToSymbolTable(node, 131072, 0); - case 165: - case 164: + case 167: + case 166: return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 16777216 : 0), ts.isObjectLiteralMethod(node) ? 0 : 103359); - case 251: + case 253: return bindFunctionDeclaration(node); - case 166: + case 168: return declareSymbolAndAddToSymbolTable(node, 16384, 0); - case 167: + case 169: return bindPropertyOrMethodOrAccessor(node, 32768, 46015); - case 168: + case 170: return bindPropertyOrMethodOrAccessor(node, 65536, 78783); - case 174: - case 308: - case 313: - case 175: - return bindFunctionOrConstructorType(node); + case 176: + case 311: + case 317: case 177: - case 312: - case 190: + return bindFunctionOrConstructorType(node); + case 179: + case 316: + case 192: return bindAnonymousTypeWorker(node); - case 319: + case 326: return bindJSDocClassTag(node); - case 200: + case 202: return bindObjectLiteralExpression(node); - case 208: - case 209: + case 210: + case 211: return bindFunctionExpression(node); - case 203: + case 205: var assignmentKind = ts.getAssignmentDeclarationKind(node); switch (assignmentKind) { case 7: @@ -34723,60 +35960,60 @@ var ts; bindCallExpression(node); } break; - case 221: - case 252: + case 223: + case 254: inStrictMode = true; return bindClassLikeDeclaration(node); - case 253: + case 255: return bindBlockScopedDeclaration(node, 64, 788872); - case 254: + case 256: return bindBlockScopedDeclaration(node, 524288, 788968); - case 255: + case 257: return bindEnumDeclaration(node); - case 256: + case 258: return bindModuleDeclaration(node); - case 281: + case 283: return bindJsxAttributes(node); - case 280: + case 282: return bindJsxAttribute(node, 4, 0); - case 260: - case 263: + case 262: case 265: - case 270: + case 267: + case 272: return declareSymbolAndAddToSymbolTable(node, 2097152, 2097152); - case 259: + case 261: return bindNamespaceExportDeclaration(node); - case 262: + case 264: return bindImportClause(node); - case 267: + case 269: return bindExportDeclaration(node); - case 266: + case 268: return bindExportAssignment(node); - case 297: + case 299: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 230: + case 232: if (!ts.isFunctionLike(node.parent)) { return; } - case 257: + case 259: return updateStrictModeStatementList(node.statements); - case 326: - if (node.parent.kind === 313) { + case 334: + if (node.parent.kind === 317) { return bindParameter(node); } - if (node.parent.kind !== 312) { + if (node.parent.kind !== 316) { break; } - case 333: + case 341: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 307 ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 310 ? 4 | 16777216 : 4; return declareSymbolAndAddToSymbolTable(propTag, flags, 0); - case 331: - case 324: - case 325: + case 339: + case 332: + case 333: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -34803,7 +36040,7 @@ var ts; } function bindExportAssignment(node) { if (!container.symbol || !container.symbol.exports) { - bindAnonymousDeclaration(node, 2097152, getDeclarationName(node)); + bindAnonymousDeclaration(node, 111551, getDeclarationName(node)); } else { var flags = ts.exportAssignmentIsAlias(node) @@ -34920,10 +36157,10 @@ var ts; } var thisContainer = ts.getThisContainer(node, false); switch (thisContainer.kind) { - case 251: - case 208: + case 253: + case 210: var constructorSymbol = thisContainer.symbol; - if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 62) { + if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 63) { var l = thisContainer.parent.left; if (ts.isBindableStaticAccessExpression(l) && ts.isPrototypeAccess(l.expression)) { constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer); @@ -34940,11 +36177,11 @@ var ts; addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32); } break; - case 166: - case 163: + case 168: case 165: case 167: - case 168: + case 169: + case 170: var containingClass = thisContainer.parent; var symbolTable = ts.hasSyntacticModifier(thisContainer, 32) ? containingClass.symbol.exports : containingClass.symbol.members; if (ts.hasDynamicName(node)) { @@ -34954,7 +36191,7 @@ var ts; declareSymbol(symbolTable, containingClass.symbol, node, 4 | 67108864, 0, true); } break; - case 297: + case 299: if (ts.hasDynamicName(node)) { break; } @@ -34979,10 +36216,10 @@ var ts; } } function bindSpecialPropertyDeclaration(node) { - if (node.expression.kind === 107) { + if (node.expression.kind === 108) { bindThisPropertyAssignment(node); } - else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 297) { + else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 299) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -35013,7 +36250,7 @@ var ts; } function bindObjectDefinePropertyAssignment(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); - var isToplevel = node.parent.parent.kind === 297; + var isToplevel = node.parent.parent.kind === 299; namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, false, false); bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, false); } @@ -35107,8 +36344,8 @@ var ts; } function isTopLevelNamespaceAssignment(propertyAccess) { return ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 297 - : propertyAccess.parent.parent.kind === 297; + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 299 + : propertyAccess.parent.parent.kind === 299; } function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) { var namespaceSymbol = lookupSymbolForPropertyAccess(name, container) || lookupSymbolForPropertyAccess(name, blockScopeContainer); @@ -35174,7 +36411,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 252) { + if (node.kind === 254) { bindBlockScopedDeclaration(node, 32, 899503); } else { @@ -35206,7 +36443,7 @@ var ts; checkStrictModeEvalOrArguments(node, node.name); } if (!ts.isBindingPattern(node.name)) { - if (ts.isInJSFile(node) && ts.isRequireVariableDeclaration(node, true) && !ts.getJSDocTypeTag(node)) { + if (ts.isInJSFile(node) && ts.isRequireVariableDeclaration(node) && !ts.getJSDocTypeTag(node)) { declareSymbolAndAddToSymbolTable(node, 2097152, 2097152); } else if (ts.isBlockOrCatchScoped(node)) { @@ -35221,7 +36458,7 @@ var ts; } } function bindParameter(node) { - if (node.kind === 326 && container.kind !== 313) { + if (node.kind === 334 && container.kind !== 317) { return; } if (inStrictMode && !(node.flags & 8388608)) { @@ -35294,7 +36531,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 262144, 526824); } } - else if (node.parent.kind === 185) { + else if (node.parent.kind === 187) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { @@ -35312,16 +36549,16 @@ var ts; } function shouldReportErrorOnModuleDeclaration(node) { var instanceState = getModuleInstanceState(node); - return instanceState === 1 || (instanceState === 2 && !!options.preserveConstEnums); + return instanceState === 1 || (instanceState === 2 && ts.shouldPreserveConstEnums(options)); } function checkUnreachable(node) { if (!(currentFlow.flags & 1)) { return false; } if (currentFlow === unreachableFlow) { - var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 231) || - node.kind === 252 || - (node.kind === 256 && shouldReportErrorOnModuleDeclaration(node)); + var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 233) || + node.kind === 254 || + (node.kind === 258 && shouldReportErrorOnModuleDeclaration(node)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -35353,12 +36590,12 @@ var ts; } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 253: - case 254: - return true; + case 255: case 256: + return true; + case 258: return getModuleInstanceState(s) !== 1; - case 255: + case 257: return ts.hasSyntacticModifier(s, 2048); default: return false; @@ -35549,7 +36786,7 @@ var ts; symbol.exports.forEach(visitSymbol); } ts.forEach(symbol.declarations, function (d) { - if (d.type && d.type.kind === 176) { + if (d.type && d.type.kind === 178) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); @@ -35649,21 +36886,24 @@ var ts; var instantiationCount = 0; var instantiationDepth = 0; var currentNode; - var typeCatalog = []; var emptySymbols = ts.createSymbolTable(); var arrayVariances = [1]; var compilerOptions = host.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var moduleKind = ts.getEmitModuleKind(compilerOptions); + var useDefineForClassFields = ts.getUseDefineForClassFields(compilerOptions); var allowSyntheticDefaultImports = ts.getAllowSyntheticDefaultImports(compilerOptions); var strictNullChecks = ts.getStrictOptionValue(compilerOptions, "strictNullChecks"); var strictFunctionTypes = ts.getStrictOptionValue(compilerOptions, "strictFunctionTypes"); var strictBindCallApply = ts.getStrictOptionValue(compilerOptions, "strictBindCallApply"); var strictPropertyInitialization = ts.getStrictOptionValue(compilerOptions, "strictPropertyInitialization"); + var strictOptionalProperties = ts.getStrictOptionValue(compilerOptions, "strictOptionalProperties"); var noImplicitAny = ts.getStrictOptionValue(compilerOptions, "noImplicitAny"); var noImplicitThis = ts.getStrictOptionValue(compilerOptions, "noImplicitThis"); + var useUnknownInCatchVariables = ts.getStrictOptionValue(compilerOptions, "useUnknownInCatchVariables"); var keyofStringsOnly = !!compilerOptions.keyofStringsOnly; - var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 32768; + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 16384; + var checkBinaryExpression = createCheckBinaryExpression(); var emitResolver = createResolver(); var nodeBuilder = createNodeBuilder(); var globals = ts.createSymbolTable(); @@ -35680,7 +36920,6 @@ var ts; getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); }, getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); }, getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount") + symbolCount; }, - getTypeCatalog: function () { return typeCatalog; }, getTypeCount: function () { return typeCount; }, getInstantiationCount: function () { return totalInstantiationCount; }, getRelationCacheSizes: function () { return ({ @@ -35843,6 +37082,7 @@ var ts; return node && getContextualTypeForJsxAttribute(node); }, isContextSensitive: isContextSensitive, + getTypeOfPropertyOfContextualType: getTypeOfPropertyOfContextualType, getFullyQualifiedName: getFullyQualifiedName, getResolvedSignature: function (node, candidatesOutArray, argumentCount) { return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 0); @@ -35886,6 +37126,7 @@ var ts; }, tryGetMemberInModuleExports: function (name, symbol) { return tryGetMemberInModuleExports(ts.escapeLeadingUnderscores(name), symbol); }, tryGetMemberInModuleExportsAndProperties: function (name, symbol) { return tryGetMemberInModuleExportsAndProperties(ts.escapeLeadingUnderscores(name), symbol); }, + tryFindAmbientModule: function (moduleName) { return tryFindAmbientModule(moduleName, true); }, tryFindAmbientModuleWithoutAugmentations: function (moduleName) { return tryFindAmbientModule(moduleName, false); }, @@ -35998,6 +37239,7 @@ var ts; var templateLiteralTypes = new ts.Map(); var stringMappingTypes = new ts.Map(); var substitutionTypes = new ts.Map(); + var subtypeReductionCache = new ts.Map(); var evolvingArrayTypes = []; var undefinedProperties = new ts.Map(); var unknownSymbol = createSymbol(4, "unknown"); @@ -36006,14 +37248,15 @@ var ts; var autoType = createIntrinsicType(1, "any"); var wildcardType = createIntrinsicType(1, "any"); var errorType = createIntrinsicType(1, "error"); - var nonInferrableAnyType = createIntrinsicType(1, "any", 524288); + var nonInferrableAnyType = createIntrinsicType(1, "any", 131072); var intrinsicMarkerType = createIntrinsicType(1, "intrinsic"); var unknownType = createIntrinsicType(2, "unknown"); var undefinedType = createIntrinsicType(32768, "undefined"); - var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768, "undefined", 524288); + var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768, "undefined", 131072); var optionalType = createIntrinsicType(32768, "undefined"); + var missingType = strictOptionalProperties ? createIntrinsicType(32768, "undefined") : undefinedType; var nullType = createIntrinsicType(65536, "null"); - var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536, "null", 524288); + var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536, "null", 131072); var stringType = createIntrinsicType(4, "string"); var numberType = createIntrinsicType(8, "number"); var bigintType = createIntrinsicType(64, "bigint"); @@ -36037,7 +37280,7 @@ var ts; var voidType = createIntrinsicType(16384, "void"); var neverType = createIntrinsicType(131072, "never"); var silentNeverType = createIntrinsicType(131072, "never"); - var nonInferrableType = createIntrinsicType(131072, "never", 2097152); + var nonInferrableType = createIntrinsicType(131072, "never", 524288); var implicitNeverType = createIntrinsicType(131072, "never"); var unreachableNeverType = createIntrinsicType(131072, "never"); var nonPrimitiveType = createIntrinsicType(67108864, "object"); @@ -36049,14 +37292,14 @@ var ts; var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 ? wildcardType : t; }); var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var emptyJsxObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); - emptyJsxObjectType.objectFlags |= 4096; + emptyJsxObjectType.objectFlags |= 2048; var emptyTypeLiteralSymbol = createSymbol(2048, "__type"); emptyTypeLiteralSymbol.members = ts.createSymbolTable(); var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var emptyGenericType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); emptyGenericType.instantiations = new ts.Map(); var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); - anyFunctionType.objectFlags |= 2097152; + anyFunctionType.objectFlags |= 524288; var noConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var circularConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var resolvingDefaultType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); @@ -36127,6 +37370,7 @@ var ts; var anyReadonlyArrayType; var deferredGlobalNonNullableTypeAlias; var deferredGlobalESSymbolConstructorSymbol; + var deferredGlobalESSymbolConstructorTypeSymbol; var deferredGlobalESSymbolType; var deferredGlobalTypedPropertyDescriptorType; var deferredGlobalPromiseType; @@ -36178,7 +37422,7 @@ var ts; var flowNodePostSuper = []; var potentialThisCollisions = []; var potentialNewTargetCollisions = []; - var potentialWeakMapCollisions = []; + var potentialWeakMapSetCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); var suggestionDiagnostics = ts.createDiagnosticCollection(); @@ -36321,9 +37565,27 @@ var ts; } return diagnostic; } + function addDeprecatedSuggestionWorker(declarations, diagnostic) { + var deprecatedTag = Array.isArray(declarations) ? ts.forEach(declarations, ts.getJSDocDeprecatedTag) : ts.getJSDocDeprecatedTag(declarations); + if (deprecatedTag) { + ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(deprecatedTag, ts.Diagnostics.The_declaration_was_marked_as_deprecated_here)); + } + suggestionDiagnostics.add(diagnostic); + return diagnostic; + } + function addDeprecatedSuggestion(location, declarations, deprecatedEntity) { + var diagnostic = ts.createDiagnosticForNode(location, ts.Diagnostics._0_is_deprecated, deprecatedEntity); + return addDeprecatedSuggestionWorker(declarations, diagnostic); + } + function addDeprecatedSuggestionWithSignature(location, declaration, deprecatedEntity, signatureString) { + var diagnostic = deprecatedEntity + ? ts.createDiagnosticForNode(location, ts.Diagnostics.The_signature_0_of_1_is_deprecated, signatureString, deprecatedEntity) + : ts.createDiagnosticForNode(location, ts.Diagnostics._0_is_deprecated, signatureString); + return addDeprecatedSuggestionWorker(declaration, diagnostic); + } function createSymbol(flags, name, checkFlags) { symbolCount++; - var symbol = (new Symbol(flags | 33554432, name)); + var symbol = new Symbol(flags | 33554432, name); symbol.checkFlags = checkFlags || 0; return symbol; } @@ -36423,7 +37685,7 @@ var ts; } else if (target.flags & 1024) { if (target !== globalThisSymbol) { - error(ts.getNameOfDeclaration(source.declarations[0]), ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); + error(source.declarations && ts.getNameOfDeclaration(source.declarations[0]), ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); } } else { @@ -36456,9 +37718,11 @@ var ts; } return target; function addDuplicateLocations(locs, symbol) { - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - ts.pushIfUnique(locs, decl); + if (symbol.declarations) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + ts.pushIfUnique(locs, decl); + } } } } @@ -36504,9 +37768,9 @@ var ts; }); } function mergeModuleAugmentation(moduleName) { - var _a, _b; + var _a, _b, _c; var moduleAugmentation = moduleName.parent; - if (moduleAugmentation.symbol.declarations[0] !== moduleAugmentation) { + if (((_a = moduleAugmentation.symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]) !== moduleAugmentation) { ts.Debug.assert(moduleAugmentation.symbol.declarations.length > 1); return; } @@ -36531,10 +37795,10 @@ var ts; patternAmbientModuleAugmentations.set(moduleName.text, merged); } else { - if (((_a = mainModule_1.exports) === null || _a === void 0 ? void 0 : _a.get("__export")) && ((_b = moduleAugmentation.symbol.exports) === null || _b === void 0 ? void 0 : _b.size)) { + if (((_b = mainModule_1.exports) === null || _b === void 0 ? void 0 : _b.get("__export")) && ((_c = moduleAugmentation.symbol.exports) === null || _c === void 0 ? void 0 : _c.size)) { var resolvedExports = getResolvedMembersOrExportsOfSymbol(mainModule_1, "resolvedExports"); - for (var _i = 0, _c = ts.arrayFrom(moduleAugmentation.symbol.exports.entries()); _i < _c.length; _i++) { - var _d = _c[_i], key = _d[0], value = _d[1]; + 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)) { mergeSymbol(resolvedExports.get(key), value); } @@ -36573,7 +37837,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = new NodeLinks()); } function isGlobalSourceFile(node) { - return node.kind === 297 && !ts.isExternalOrCommonJsModule(node); + return node.kind === 299 && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -36620,15 +37884,15 @@ var ts; return sourceFiles.indexOf(declarationFile) <= sourceFiles.indexOf(useFile); } if (declaration.pos <= usage.pos && !(ts.isPropertyDeclaration(declaration) && ts.isThisProperty(usage.parent) && !declaration.initializer && !declaration.exclamationToken)) { - if (declaration.kind === 198) { - var errorBindingElement = ts.getAncestor(usage, 198); + if (declaration.kind === 200) { + var errorBindingElement = ts.getAncestor(usage, 200); if (errorBindingElement) { return ts.findAncestor(errorBindingElement, ts.isBindingElement) !== ts.findAncestor(declaration, ts.isBindingElement) || declaration.pos < errorBindingElement.pos; } - return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 249), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 251), usage); } - else if (declaration.kind === 249) { + else if (declaration.kind === 251) { return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } else if (ts.isClassDeclaration(declaration)) { @@ -36638,23 +37902,23 @@ var ts; return !isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, false); } else if (ts.isParameterPropertyDeclaration(declaration, declaration.parent)) { - return !(compilerOptions.target === 99 && !!compilerOptions.useDefineForClassFields + return !(compilerOptions.target === 99 && useDefineForClassFields && ts.getContainingClass(declaration) === ts.getContainingClass(usage) && isUsedInFunctionOrInstanceProperty(usage, declaration)); } return true; } - if (usage.parent.kind === 270 || (usage.parent.kind === 266 && usage.parent.isExportEquals)) { + if (usage.parent.kind === 272 || (usage.parent.kind === 268 && usage.parent.isExportEquals)) { return true; } - if (usage.kind === 266 && usage.isExportEquals) { + if (usage.kind === 268 && usage.isExportEquals) { return true; } if (!!(usage.flags & 4194304) || isInTypeQuery(usage) || usageInTypeDeclaration()) { return true; } if (isUsedInFunctionOrInstanceProperty(usage, declaration)) { - if (compilerOptions.target === 99 && !!compilerOptions.useDefineForClassFields + if (compilerOptions.target === 99 && useDefineForClassFields && ts.getContainingClass(declaration) && (ts.isPropertyDeclaration(declaration) || ts.isParameterPropertyDeclaration(declaration, declaration.parent))) { return !isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, true); @@ -36669,9 +37933,9 @@ var ts; } function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { switch (declaration.parent.parent.kind) { - case 232: - case 237: + case 234: case 239: + case 241: if (isSameScopeDescendentOf(usage, declaration, declContainer)) { return true; } @@ -36689,16 +37953,16 @@ var ts; return true; } var initializerOfProperty = current.parent && - current.parent.kind === 163 && + current.parent.kind === 165 && current.parent.initializer === current; if (initializerOfProperty) { if (ts.hasSyntacticModifier(current.parent, 32)) { - if (declaration.kind === 165) { + if (declaration.kind === 167) { return true; } } else { - var isDeclarationInstanceProperty = declaration.kind === 163 && !ts.hasSyntacticModifier(declaration, 32); + var isDeclarationInstanceProperty = declaration.kind === 165 && !ts.hasSyntacticModifier(declaration, 32); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -36716,18 +37980,18 @@ var ts; return "quit"; } switch (node.kind) { - case 209: + case 211: return true; - case 163: + case 165: return stopAtAnyPropertyDeclaration && (ts.isPropertyDeclaration(declaration) && node.parent === declaration.parent || ts.isParameterPropertyDeclaration(declaration, declaration.parent) && node.parent === declaration.parent.parent) ? "quit" : true; - case 230: + case 232: switch (node.parent.kind) { + case 169: case 167: - case 165: - case 168: + case 170: return true; default: return false; @@ -36742,7 +38006,11 @@ var ts; function useOuterVariableScopeInParameter(result, location, lastLocation) { var target = ts.getEmitScriptTarget(compilerOptions); var functionLocation = location; - if (ts.isParameter(lastLocation) && functionLocation.body && result.valueDeclaration.pos >= functionLocation.body.pos && result.valueDeclaration.end <= functionLocation.body.end) { + if (ts.isParameter(lastLocation) + && functionLocation.body + && result.valueDeclaration + && result.valueDeclaration.pos >= functionLocation.body.pos + && result.valueDeclaration.end <= functionLocation.body.end) { if (target >= 2) { var links = getNodeLinks(functionLocation); if (links.declarationRequiresScopeChange === undefined) { @@ -36758,19 +38026,19 @@ var ts; } function requiresScopeChangeWorker(node) { switch (node.kind) { - case 209: - case 208: - case 251: - case 166: + case 211: + case 210: + case 253: + case 168: return false; - case 165: case 167: - case 168: - case 288: + case 169: + case 170: + case 290: return requiresScopeChangeWorker(node.name); - case 163: + case 165: if (ts.hasStaticModifier(node)) { - return target < 99 || !compilerOptions.useDefineForClassFields; + return target < 99 || !useDefineForClassFields; } return requiresScopeChangeWorker(node.name); default: @@ -36791,6 +38059,7 @@ var ts; return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSymbol, suggestedNameNotFoundMessage); } function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, lookup, suggestedNameNotFoundMessage) { + var _a; var originalLocation = location; var result; var lastLocation; @@ -36806,11 +38075,11 @@ var ts; if (result = lookup(location.locals, name, meaning)) { var useResult = true; if (ts.isFunctionLike(location) && lastLocation && lastLocation !== location.body) { - if (meaning & result.flags & 788968 && lastLocation.kind !== 311) { + if (meaning & result.flags & 788968 && lastLocation.kind !== 314) { useResult = result.flags & 262144 ? lastLocation === location.type || - lastLocation.kind === 160 || - lastLocation.kind === 159 + lastLocation.kind === 162 || + lastLocation.kind === 161 : false; } if (meaning & result.flags & 3) { @@ -36819,13 +38088,13 @@ var ts; } else if (result.flags & 1) { useResult = - lastLocation.kind === 160 || + lastLocation.kind === 162 || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } } - else if (location.kind === 184) { + else if (location.kind === 186) { useResult = lastLocation === location.trueType; } if (useResult) { @@ -36838,13 +38107,13 @@ var ts; } withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation); switch (location.kind) { - case 297: + case 299: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 256: + case 258: var moduleExports = getSymbolOfNode(location).exports || emptySymbols; - if (location.kind === 297 || (ts.isModuleDeclaration(location) && location.flags & 8388608 && !ts.isGlobalScopeAugmentation(location))) { + if (location.kind === 299 || (ts.isModuleDeclaration(location) && location.flags & 8388608 && !ts.isGlobalScopeAugmentation(location))) { if (result = moduleExports.get("default")) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.escapedName === name) { @@ -36855,12 +38124,12 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 && - (ts.getDeclarationOfKind(moduleExport, 270) || ts.getDeclarationOfKind(moduleExport, 269))) { + (ts.getDeclarationOfKind(moduleExport, 272) || ts.getDeclarationOfKind(moduleExport, 271))) { break; } } if (name !== "default" && (result = lookup(moduleExports, name, meaning & 2623475))) { - if (ts.isSourceFile(location) && location.commonJsModuleIndicator && !result.declarations.some(ts.isJSDocTypeAlias)) { + if (ts.isSourceFile(location) && location.commonJsModuleIndicator && !((_a = result.declarations) === null || _a === void 0 ? void 0 : _a.some(ts.isJSDocTypeAlias))) { result = undefined; } else { @@ -36868,12 +38137,12 @@ var ts; } } break; - case 255: + case 257: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; - case 163: + case 165: if (!ts.hasSyntacticModifier(location, 32)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { @@ -36883,9 +38152,9 @@ var ts; } } break; - case 252: - case 221: - case 253: + case 254: + case 223: + case 255: if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 788968)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { result = undefined; @@ -36897,7 +38166,7 @@ var ts; } break loop; } - if (location.kind === 221 && meaning & 32) { + if (location.kind === 223 && meaning & 32) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -36905,8 +38174,8 @@ var ts; } } break; - case 223: - if (lastLocation === location.expression && location.parent.token === 93) { + case 225: + if (lastLocation === location.expression && location.parent.token === 94) { var container = location.parent.parent; if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968))) { if (nameNotFoundMessage) { @@ -36916,30 +38185,30 @@ var ts; } } break; - case 158: + case 160: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 253) { + if (ts.isClassLike(grandparent) || grandparent.kind === 255) { if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 209: + case 211: if (compilerOptions.target >= 2) { break; } - case 165: - case 166: case 167: case 168: - case 251: + case 169: + case 170: + case 253: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 208: + case 210: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -36952,23 +38221,23 @@ var ts; } } break; - case 161: - if (location.parent && location.parent.kind === 160) { + case 163: + if (location.parent && location.parent.kind === 162) { location = location.parent; } - if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 252)) { + if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 254)) { location = location.parent; } break; - case 331: - case 324: - case 325: + case 339: + case 332: + case 333: var root = ts.getJSDocRoot(location); if (root) { location = root.parent; } break; - case 160: + case 162: if (lastLocation && (lastLocation === location.initializer || lastLocation === location.name && ts.isBindingPattern(lastLocation))) { if (!associatedDeclarationForContainingInitializerOrBindingName) { @@ -36976,7 +38245,7 @@ var ts; } } break; - case 198: + case 200: if (lastLocation && (lastLocation === location.initializer || lastLocation === location.name && ts.isBindingPattern(lastLocation))) { if (ts.isParameterDeclaration(location) && !associatedDeclarationForContainingInitializerOrBindingName) { @@ -36984,7 +38253,7 @@ var ts; } } break; - case 185: + case 187: if (meaning & 262144) { var parameterName = location.typeParameter.name; if (parameterName && name === parameterName.escapedText) { @@ -37005,7 +38274,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 297); + ts.Debug.assert(lastLocation.kind === 299); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -37034,6 +38303,10 @@ var ts; var suggestion = void 0; if (suggestedNameNotFoundMessage && suggestionCount < maximumSuggestionCount) { suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning); + var isGlobalScopeAugmentationDeclaration = suggestion && suggestion.valueDeclaration && ts.isAmbientModule(suggestion.valueDeclaration) && ts.isGlobalScopeAugmentation(suggestion.valueDeclaration); + if (isGlobalScopeAugmentationDeclaration) { + suggestion = undefined; + } if (suggestion) { var suggestionName = symbolToString(suggestion); var diagnostic = error(errorLocation, suggestedNameNotFoundMessage, diagnosticName(nameArg), suggestionName); @@ -37059,7 +38332,7 @@ var ts; return undefined; } if (nameNotFoundMessage) { - if (propertyWithInvalidInitializer && !(compilerOptions.target === 99 && compilerOptions.useDefineForClassFields)) { + if (propertyWithInvalidInitializer && !(compilerOptions.target === 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)); return undefined; @@ -37111,9 +38384,9 @@ var ts; } } function getIsDeferredContext(location, lastLocation) { - if (location.kind !== 209 && location.kind !== 208) { + if (location.kind !== 211 && location.kind !== 210) { return ts.isTypeQueryNode(location) || ((ts.isFunctionLikeDeclaration(location) || - (location.kind === 163 && !ts.hasSyntacticModifier(location, 32))) && (!lastLocation || lastLocation !== location.name)); + (location.kind === 165 && !ts.hasSyntacticModifier(location, 32))) && (!lastLocation || lastLocation !== location.name)); } if (lastLocation && lastLocation === location.name) { return false; @@ -37125,12 +38398,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 251: - case 252: case 253: - case 255: case 254: + case 255: + case 257: case 256: + case 258: return true; default: return false; @@ -37140,12 +38413,14 @@ var ts; return ts.isString(nameArg) ? ts.unescapeLeadingUnderscores(nameArg) : ts.declarationNameToString(nameArg); } function isTypeParameterSymbolDeclaredInContainer(symbol, container) { - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - if (decl.kind === 159) { - 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)); + if (symbol.declarations) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + if (decl.kind === 161) { + 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)); + } } } } @@ -37190,10 +38465,10 @@ var ts; } function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 78: - case 201: + case 79: + case 203: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 223: + case 225: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -37236,7 +38511,7 @@ 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 === 270) { + if (isPrimitiveTypeName(name) && errorLocation.parent.kind === 272) { error(errorLocation, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, name); return true; } @@ -37305,11 +38580,12 @@ var ts; return false; } function checkResolvedBlockScopedVariable(result, errorLocation) { + var _a; ts.Debug.assert(!!(result.flags & 2 || result.flags & 32 || result.flags & 384)); if (result.flags & (16 | 1 | 67108864) && result.flags & 32) { return; } - var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 255); }); + var declaration = (_a = result.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 257); }); if (declaration === undefined) return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration"); if (!(declaration.flags & 8388608) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { @@ -37326,7 +38602,7 @@ var ts; } else { ts.Debug.assert(!!(result.flags & 128)); - if (compilerOptions.preserveConstEnums) { + if (ts.shouldPreserveConstEnums(compilerOptions)) { diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName); } } @@ -37340,39 +38616,39 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 260: - return node; case 262: + return node; + case 264: return node.parent; - case 263: - return node.parent.parent; case 265: + return node.parent.parent; + case 267: return node.parent.parent.parent; default: return undefined; } } function getDeclarationOfAliasSymbol(symbol) { - return ts.find(symbol.declarations, isAliasSymbolDeclaration); + return symbol.declarations && ts.findLast(symbol.declarations, isAliasSymbolDeclaration); } function isAliasSymbolDeclaration(node) { - return node.kind === 260 - || node.kind === 259 - || node.kind === 262 && !!node.name - || node.kind === 263 - || node.kind === 269 + return node.kind === 262 + || node.kind === 261 + || node.kind === 264 && !!node.name || node.kind === 265 - || node.kind === 270 - || node.kind === 266 && ts.exportAssignmentIsAlias(node) + || node.kind === 271 + || node.kind === 267 + || node.kind === 272 + || node.kind === 268 && ts.exportAssignmentIsAlias(node) || ts.isBinaryExpression(node) && ts.getAssignmentDeclarationKind(node) === 2 && ts.exportAssignmentIsAlias(node) || ts.isAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node - && node.parent.operatorToken.kind === 62 + && node.parent.operatorToken.kind === 63 && isAliasableOrJsExpression(node.parent.right) - || node.kind === 289 - || node.kind === 288 && isAliasableOrJsExpression(node.initializer) - || ts.isRequireVariableDeclaration(node, true); + || node.kind === 291 + || node.kind === 290 && isAliasableOrJsExpression(node.initializer) + || ts.isRequireVariableDeclaration(node); } function isAliasableOrJsExpression(e) { return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e); @@ -37385,7 +38661,7 @@ var ts; ? resolveSymbol(getPropertyOfType(resolveExternalModuleTypeByLiteral(name), commonJSPropertyAccess.name.escapedText)) : undefined; } - if (ts.isVariableDeclaration(node) || node.moduleReference.kind === 272) { + if (ts.isVariableDeclaration(node) || node.moduleReference.kind === 274) { var immediate = resolveExternalModuleName(node, ts.getExternalModuleRequireArgument(node) || ts.getExternalModuleImportEqualsDeclarationExpression(node)); var resolved_4 = resolveExternalModuleSymbol(immediate); markSymbolOfAliasDeclarationIfTypeOnly(node, immediate, resolved_4, false); @@ -37439,6 +38715,7 @@ var ts; return !file.externalModuleIndicator && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), undefined, dontResolveAlias); } function getTargetOfImportClause(node, dontResolveAlias) { + var _a; var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier); if (moduleSymbol) { var exportDefaultSymbol = void 0; @@ -37448,7 +38725,7 @@ var ts; else { exportDefaultSymbol = resolveExportByName(moduleSymbol, "default", node, dontResolveAlias); } - var file = ts.find(moduleSymbol.declarations, ts.isSourceFile); + var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); var hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias); if (!exportDefaultSymbol && !hasSyntheticDefault) { if (hasExportAssignmentSymbol(moduleSymbol)) { @@ -37456,7 +38733,9 @@ var ts; var exportEqualsSymbol = moduleSymbol.exports.get("export="); 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); - ts.addRelatedInfo(err, ts.createDiagnosticForNode(exportAssignment, ts.Diagnostics.This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag, compilerOptionName)); + if (exportAssignment) { + ts.addRelatedInfo(err, ts.createDiagnosticForNode(exportAssignment, ts.Diagnostics.This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag, compilerOptionName)); + } } else { reportNonDefaultExport(moduleSymbol, node); @@ -37472,7 +38751,7 @@ var ts; } } function reportNonDefaultExport(moduleSymbol, node) { - var _a, _b; + var _a, _b, _c; if ((_a = moduleSymbol.exports) === null || _a === void 0 ? void 0 : _a.has(node.symbol.escapedName)) { error(node.name, ts.Diagnostics.Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead, symbolToString(moduleSymbol), symbolToString(node.symbol)); } @@ -37480,7 +38759,7 @@ var ts; 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"); if (exportStar) { - var defaultExport = ts.find(exportStar.declarations, function (decl) { + 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"))); @@ -37540,7 +38819,7 @@ var ts; } } function getExternalModuleMember(node, specifier, dontResolveAlias) { - var _a; + var _a, _b; if (dontResolveAlias === void 0) { dontResolveAlias = false; } var moduleSpecifier = ts.getExternalModuleRequireArgument(node) || node.moduleSpecifier; var moduleSymbol = resolveExternalModuleName(node, moduleSpecifier); @@ -37549,7 +38828,7 @@ var ts; return undefined; } var suppressInteropError = name.escapedText === "default" && !!(compilerOptions.allowSyntheticDefaultImports || compilerOptions.esModuleInterop); - var targetSymbol = resolveESModuleSymbol(moduleSymbol, moduleSpecifier, dontResolveAlias, suppressInteropError); + var targetSymbol = resolveESModuleSymbol(moduleSymbol, moduleSpecifier, false, suppressInteropError); if (targetSymbol) { if (name.escapedText) { if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { @@ -37565,7 +38844,7 @@ var ts; symbolFromVariable = resolveSymbol(symbolFromVariable, dontResolveAlias); var symbolFromModule = getExportOfModule(targetSymbol, name, specifier, dontResolveAlias); if (symbolFromModule === undefined && name.escapedText === "default") { - var file = ts.find(moduleSymbol.declarations, ts.isSourceFile); + var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); if (canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias)) { symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias); } @@ -37585,7 +38864,7 @@ var ts; } } else { - if ((_a = moduleSymbol.exports) === null || _a === void 0 ? void 0 : _a.has("default")) { + if ((_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.has("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 { @@ -37598,8 +38877,8 @@ var ts; } } function reportNonExportedMember(node, name, declarationName, moduleSymbol, moduleName) { - var _a; - var localSymbol = (_a = moduleSymbol.valueDeclaration.locals) === null || _a === void 0 ? void 0 : _a.get(name.escapedText); + var _a, _b; + 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="); @@ -37611,9 +38890,11 @@ var ts; var exportedSymbol = exports ? ts.find(symbolsToArray(exports), function (symbol) { return !!getSymbolIfSameReference(symbol, localSymbol); }) : undefined; var diagnostic = exportedSymbol ? error(name, ts.Diagnostics.Module_0_declares_1_locally_but_it_is_exported_as_2, moduleName, declarationName, symbolToString(exportedSymbol)) : error(name, ts.Diagnostics.Module_0_declares_1_locally_but_it_is_not_exported, moduleName, declarationName); - ts.addRelatedInfo.apply(void 0, __spreadArray([diagnostic], ts.map(localSymbol.declarations, function (decl, index) { - return ts.createDiagnosticForNode(decl, index === 0 ? ts.Diagnostics._0_is_declared_here : ts.Diagnostics.and_here, declarationName); - }))); + if (localSymbol.declarations) { + ts.addRelatedInfo.apply(void 0, __spreadArray([diagnostic], ts.map(localSymbol.declarations, function (decl, index) { + return ts.createDiagnosticForNode(decl, index === 0 ? ts.Diagnostics._0_is_declared_here : ts.Diagnostics.and_here, declarationName); + }))); + } } } else { @@ -37692,7 +38973,7 @@ var ts; return getTargetOfAliasLikeExpression(expression, dontRecursivelyResolve); } function getTargetOfAccessExpression(node, dontRecursivelyResolve) { - if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62)) { + if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63)) { return undefined; } return getTargetOfAliasLikeExpression(node.parent.right, dontRecursivelyResolve); @@ -37700,31 +38981,31 @@ var ts; function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 260: - case 249: - return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); case 262: + case 251: + return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); + case 264: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 263: + case 265: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 269: + case 271: return getTargetOfNamespaceExport(node, dontRecursivelyResolve); - case 265: - case 198: + case 267: + case 200: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 270: + case 272: return getTargetOfExportSpecifier(node, 111551 | 788968 | 1920, dontRecursivelyResolve); - case 266: - case 216: + case 268: + case 218: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 259: + case 261: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); - case 289: + case 291: return resolveEntityName(node.name, 111551 | 788968 | 1920, true, dontRecursivelyResolve); - case 288: + case 290: return getTargetOfPropertyAssignment(node, dontRecursivelyResolve); - case 202: - case 201: + case 204: + case 203: return getTargetOfAccessExpression(node, dontRecursivelyResolve); default: return ts.Debug.fail(); @@ -37829,14 +39110,14 @@ var ts; } } function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, dontResolveAlias) { - if (entityName.kind === 78 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 79 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 78 || entityName.parent.kind === 157) { + if (entityName.kind === 79 || entityName.parent.kind === 159) { return resolveEntityName(entityName, 1920, false, dontResolveAlias); } else { - ts.Debug.assert(entityName.parent.kind === 260); + ts.Debug.assert(entityName.parent.kind === 262); return resolveEntityName(entityName, 111551 | 788968 | 1920, false, dontResolveAlias); } } @@ -37849,7 +39130,7 @@ var ts; } var namespaceMeaning = 1920 | (ts.isInJSFile(name) ? meaning & 111551 : 0); var symbol; - if (name.kind === 78) { + if (name.kind === 79) { 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, true)); @@ -37857,9 +39138,9 @@ var ts; return getMergedSymbol(symbolFromJSPrototype); } } - else if (name.kind === 157 || name.kind === 201) { - var left = name.kind === 157 ? name.left : name.expression; - var right = name.kind === 157 ? name.right : name.name; + else if (name.kind === 159 || name.kind === 203) { + var left = name.kind === 159 ? name.left : name.expression; + var right = name.kind === 159 ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -37867,18 +39148,17 @@ var ts; else if (namespace === unknownSymbol) { return namespace; } - if (ts.isInJSFile(name)) { - if (namespace.valueDeclaration && - ts.isVariableDeclaration(namespace.valueDeclaration) && - namespace.valueDeclaration.initializer && - isCommonJsRequire(namespace.valueDeclaration.initializer)) { - var moduleName = namespace.valueDeclaration.initializer.arguments[0]; - var moduleSym = resolveExternalModuleName(moduleName, moduleName); - if (moduleSym) { - var resolvedModuleSymbol = resolveExternalModuleSymbol(moduleSym); - if (resolvedModuleSymbol) { - namespace = resolvedModuleSymbol; - } + if (namespace.valueDeclaration && + ts.isInJSFile(namespace.valueDeclaration) && + ts.isVariableDeclaration(namespace.valueDeclaration) && + namespace.valueDeclaration.initializer && + isCommonJsRequire(namespace.valueDeclaration.initializer)) { + var moduleName = namespace.valueDeclaration.initializer.arguments[0]; + var moduleSym = resolveExternalModuleName(moduleName, moduleName); + if (moduleSym) { + var resolvedModuleSymbol = resolveExternalModuleSymbol(moduleSym); + if (resolvedModuleSymbol) { + namespace = resolvedModuleSymbol; } } } @@ -37899,7 +39179,7 @@ var ts; throw ts.Debug.assertNever(name, "Unknown entity name kind."); } ts.Debug.assert((ts.getCheckFlags(symbol) & 1) === 0, "Should never get an instantiated symbol here."); - if (!ts.nodeIsSynthesized(name) && ts.isEntityName(name) && (symbol.flags & 2097152 || name.parent.kind === 266)) { + if (!ts.nodeIsSynthesized(name) && ts.isEntityName(name) && (symbol.flags & 2097152 || name.parent.kind === 268)) { markSymbolOfAliasDeclarationIfTypeOnly(ts.getAliasDeclarationFromName(name), symbol, undefined, true); } return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol); @@ -38104,7 +39384,7 @@ var ts; function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias, suppressInteropError) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!suppressInteropError && !(symbol.flags & (1536 | 3)) && !ts.getDeclarationOfKind(symbol, 297)) { + if (!suppressInteropError && !(symbol.flags & (1536 | 3)) && !ts.getDeclarationOfKind(symbol, 299)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; @@ -38154,7 +39434,10 @@ var ts; var exports = getExportsOfModuleAsArray(moduleSymbol); var exportEquals = resolveExternalModuleSymbol(moduleSymbol); if (exportEquals !== moduleSymbol) { - ts.addRange(exports, getPropertiesOfType(getTypeOfSymbol(exportEquals))); + var type = getTypeOfSymbol(exportEquals); + if (shouldTreatPropertiesOfExternalModuleAsExports(type)) { + ts.addRange(exports, getPropertiesOfType(type)); + } } return exports; } @@ -38174,11 +39457,13 @@ var ts; return undefined; } var type = getTypeOfSymbol(exportEquals); - return type.flags & 131068 || - ts.getObjectFlags(type) & 1 || - isArrayOrTupleLikeType(type) - ? undefined - : getPropertyOfType(type, memberName); + return shouldTreatPropertiesOfExternalModuleAsExports(type) ? getPropertyOfType(type, memberName) : undefined; + } + function shouldTreatPropertiesOfExternalModuleAsExports(resolvedExternalModuleType) { + return !(resolvedExternalModuleType.flags & 131068 || + ts.getObjectFlags(resolvedExternalModuleType) & 1 || + isArrayType(resolvedExternalModuleType) || + isTupleType(resolvedExternalModuleType)); } function getExportsOfSymbol(symbol) { return symbol.flags & 6256 ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports") : @@ -38228,11 +39513,13 @@ var ts; if (exportStars) { var nestedSymbols = ts.createSymbolTable(); var lookupTable_1 = new ts.Map(); - for (var _i = 0, _a = exportStars.declarations; _i < _a.length; _i++) { - var node = _a[_i]; - var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); - var exportedSymbols = visit(resolvedModule); - extendExportSymbols(nestedSymbols, exportedSymbols, lookupTable_1, node); + if (exportStars.declarations) { + for (var _i = 0, _a = exportStars.declarations; _i < _a.length; _i++) { + var node = _a[_i]; + var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); + var exportedSymbols = visit(resolvedModule); + extendExportSymbols(nestedSymbols, exportedSymbols, lookupTable_1, node); + } } lookupTable_1.forEach(function (_a, id) { var exportsWithDuplicate = _a.exportsWithDuplicate; @@ -38307,17 +39594,32 @@ var ts; var additionalContainers = ts.mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer); var reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration); var objectLiteralContainer = getVariableDeclarationOfObjectLiteral(container, meaning); - if (enclosingDeclaration && getAccessibleSymbolChain(container, enclosingDeclaration, 1920, false)) { + if (enclosingDeclaration && + container.flags & getQualifiedLeftMeaning(meaning) && + getAccessibleSymbolChain(container, enclosingDeclaration, 1920, false)) { return ts.append(ts.concatenate(ts.concatenate([container], additionalContainers), reexportContainers), objectLiteralContainer); } - var res = ts.append(ts.append(additionalContainers, container), objectLiteralContainer); - return ts.concatenate(res, reexportContainers); + var firstVariableMatch = !(container.flags & getQualifiedLeftMeaning(meaning)) + && container.flags & 788968 + && getDeclaredTypeOfSymbol(container).flags & 524288 + && meaning === 111551 + ? forEachSymbolTableInScope(enclosingDeclaration, function (t) { + return ts.forEachEntry(t, function (s) { + if (s.flags & getQualifiedLeftMeaning(meaning) && getTypeOfSymbol(s) === getDeclaredTypeOfSymbol(container)) { + return s; + } + }); + }) : undefined; + var res = firstVariableMatch ? __spreadArray(__spreadArray([firstVariableMatch], additionalContainers), [container]) : __spreadArray(__spreadArray([], additionalContainers), [container]); + res = ts.append(res, objectLiteralContainer); + res = ts.addRange(res, reexportContainers); + return res; } var candidates = ts.mapDefined(symbol.declarations, function (d) { if (!ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent)) { return getSymbolOfNode(d.parent); } - if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 62 && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) { + if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 63 && 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)); } @@ -38380,7 +39682,7 @@ var ts; var members = node.members; for (var _i = 0, members_3 = members; _i < members_3.length; _i++) { var member = members_3[_i]; - if (member.kind === 166 && ts.nodeIsPresent(member.body)) { + if (member.kind === 168 && ts.nodeIsPresent(member.body)) { return member; } } @@ -38389,7 +39691,9 @@ var ts; var result = new Type(checker, flags); typeCount++; result.id = typeCount; - typeCatalog.push(result); + if (produceDiagnostics) { + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.recordType(result); + } return result; } function createOriginType(flags) { @@ -38445,14 +39749,22 @@ var ts; }); return result || ts.emptyArray; } + function getNamedOrIndexSignatureMembers(members) { + var result = getNamedMembers(members); + var index = getIndexSymbolFromSymbolTable(members); + return index ? ts.concatenate(result, [index]) : result; + } function setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { - type.members = members; - type.properties = members === emptySymbols ? ts.emptyArray : getNamedMembers(members); - type.callSignatures = callSignatures; - type.constructSignatures = constructSignatures; - type.stringIndexInfo = stringIndexInfo; - type.numberIndexInfo = numberIndexInfo; - return type; + var resolved = type; + resolved.members = members; + resolved.properties = ts.emptyArray; + resolved.callSignatures = callSignatures; + resolved.constructSignatures = constructSignatures; + resolved.stringIndexInfo = stringIndexInfo; + resolved.numberIndexInfo = numberIndexInfo; + if (members !== emptySymbols) + resolved.properties = getNamedMembers(members); + return resolved; } function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { return setStructuredTypeMembers(createObjectType(16, symbol), members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); @@ -38474,31 +39786,31 @@ var ts; var result; var _loop_8 = function (location) { if (location.locals && !isGlobalSourceFile(location)) { - if (result = callback(location.locals)) { + if (result = callback(location.locals, undefined, true, location)) { return { value: result }; } } switch (location.kind) { - case 297: + case 299: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 256: + case 258: var sym = getSymbolOfNode(location); - if (result = callback((sym === null || sym === void 0 ? void 0 : sym.exports) || emptySymbols)) { + if (result = callback((sym === null || sym === void 0 ? void 0 : sym.exports) || emptySymbols, undefined, true, location)) { return { value: result }; } break; - case 252: - case 221: - case 253: + case 254: + case 223: + case 255: var table_1; (getSymbolOfNode(location).members || emptySymbols).forEach(function (memberSymbol, key) { if (memberSymbol.flags & (788968 & ~67108864)) { (table_1 || (table_1 = ts.createSymbolTable())).set(key, memberSymbol); } }); - if (table_1 && (result = callback(table_1))) { + if (table_1 && (result = callback(table_1, undefined, false, location))) { return { value: result }; } break; @@ -38509,7 +39821,7 @@ var ts; if (typeof state_2 === "object") return state_2.value; } - return callback(globals); + return callback(globals, undefined, true); } function getQualifiedLeftMeaning(rightMeaning) { return rightMeaning === 111551 ? 111551 : 1920; @@ -38519,17 +39831,26 @@ var ts; if (!(symbol && !isPropertyOrMethodDeclarationSymbol(symbol))) { return undefined; } + 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; + if (cache.has(key)) { + return cache.get(key); + } var id = getSymbolId(symbol); var visitedSymbolTables = visitedSymbolTablesMap.get(id); if (!visitedSymbolTables) { visitedSymbolTablesMap.set(id, visitedSymbolTables = []); } - return forEachSymbolTableInScope(enclosingDeclaration, getAccessibleSymbolChainFromSymbolTable); - function getAccessibleSymbolChainFromSymbolTable(symbols, ignoreQualification) { + var result = forEachSymbolTableInScope(enclosingDeclaration, getAccessibleSymbolChainFromSymbolTable); + cache.set(key, result); + return result; + function getAccessibleSymbolChainFromSymbolTable(symbols, ignoreQualification, isLocalNameLookup) { if (!ts.pushIfUnique(visitedSymbolTables, symbols)) { return undefined; } - var result = trySymbolTable(symbols, ignoreQualification); + var result = trySymbolTable(symbols, ignoreQualification, isLocalNameLookup); visitedSymbolTables.pop(); return result; } @@ -38542,7 +39863,7 @@ var ts; !ts.some(symbolFromSymbolTable.declarations, hasNonGlobalAugmentationExternalModuleSymbol) && (ignoreQualification || canQualifySymbol(getMergedSymbol(symbolFromSymbolTable), meaning)); } - function trySymbolTable(symbols, ignoreQualification) { + function trySymbolTable(symbols, ignoreQualification, isLocalNameLookup) { if (isAccessible(symbols.get(symbol.escapedName), undefined, ignoreQualification)) { return [symbol]; } @@ -38552,7 +39873,8 @@ var ts; && symbolFromSymbolTable.escapedName !== "default" && !(ts.isUMDExportSymbol(symbolFromSymbolTable) && enclosingDeclaration && ts.isExternalModule(ts.getSourceFileOfNode(enclosingDeclaration))) && (!useOnlyExternalAliasing || ts.some(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) - && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 270))) { + && (isLocalNameLookup ? !ts.some(symbolFromSymbolTable.declarations, ts.isNamespaceReexportDeclaration) : true) + && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 272))) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); var candidate = getCandidateListForSymbol(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification); if (candidate) { @@ -38588,7 +39910,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 270)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 272)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -38602,10 +39924,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 163: case 165: case 167: - case 168: + case 169: + case 170: continue; default: return false; @@ -38642,7 +39964,7 @@ var ts; return hasAccessibleDeclarations; } } - else if (allowModules) { + if (allowModules) { if (ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { if (shouldComputeAliasesToMakeVisible) { earlyModuleBail = true; @@ -38688,7 +40010,8 @@ var ts; return { accessibility: 2, errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning), - errorModuleName: symbolToString(symbolExternalModule) + errorModuleName: symbolToString(symbolExternalModule), + errorNode: ts.isInJSFile(enclosingDeclaration) ? enclosingDeclaration : undefined, }; } } @@ -38704,14 +40027,14 @@ var ts; return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 297 && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 299 && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 297 && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 299 && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; - if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 78; }), getIsDeclarationVisible)) { + if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 79; }), getIsDeclarationVisible)) { return undefined; } return { accessibility: 0, aliasesToMakeVisible: aliasesToMakeVisible }; @@ -38756,13 +40079,13 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 176 || + if (entityName.parent.kind === 178 || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) || - entityName.parent.kind === 158) { + entityName.parent.kind === 160) { meaning = 111551 | 1048576; } - else if (entityName.kind === 157 || entityName.kind === 201 || - entityName.parent.kind === 260) { + else if (entityName.kind === 159 || entityName.kind === 203 || + entityName.parent.kind === 262) { meaning = 1920; } else { @@ -38798,7 +40121,7 @@ var ts; return writer ? symbolToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(symbolToStringWorker); function symbolToStringWorker(writer) { var entity = builder(symbol, meaning, enclosingDeclaration, nodeFlags); - var printer = (enclosingDeclaration === null || enclosingDeclaration === void 0 ? void 0 : enclosingDeclaration.kind) === 297 ? ts.createPrinter({ removeComments: true, neverAsciiEscape: true }) : ts.createPrinter({ removeComments: true }); + var printer = (enclosingDeclaration === null || enclosingDeclaration === void 0 ? void 0 : enclosingDeclaration.kind) === 299 ? ts.createPrinter({ removeComments: true, neverAsciiEscape: true }) : ts.createPrinter({ removeComments: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); printer.writeNode(4, entity, sourceFile, writer); return writer; @@ -38810,10 +40133,10 @@ var ts; function signatureToStringWorker(writer) { var sigOutput; if (flags & 262144) { - sigOutput = kind === 1 ? 175 : 174; + sigOutput = kind === 1 ? 177 : 176; } else { - sigOutput = kind === 1 ? 170 : 169; + sigOutput = kind === 1 ? 172 : 171; } var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 | 512); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); @@ -38853,14 +40176,14 @@ var ts; return typeToString(type, undefined, 64); } function symbolValueDeclarationIsContextSensitive(symbol) { - return symbol && symbol.valueDeclaration && ts.isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration); + return symbol && !!symbol.valueDeclaration && ts.isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration); } function toNodeBuilderFlags(flags) { if (flags === void 0) { flags = 0; } return flags & 814775659; } function isClassInstanceSide(type) { - return !!type.symbol && !!(type.symbol.flags & 32) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || !!(ts.getObjectFlags(type) & 1073741824)); + return !!type.symbol && !!(type.symbol.flags & 32) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288) && !!(ts.getObjectFlags(type) & 16777216))); } function createNodeBuilder() { return { @@ -38898,7 +40221,7 @@ var ts; var context = { enclosingDeclaration: enclosingDeclaration, flags: flags || 0, - tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: ts.noop, moduleResolverHost: flags & 134217728 ? { + tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: function () { return false; }, moduleResolverHost: flags & 134217728 ? { getCommonSourceDirectory: !!host.getCommonSourceDirectory ? function () { return host.getCommonSourceDirectory(); } : function () { return ""; }, getSourceFiles: function () { return host.getSourceFiles(); }, getCurrentDirectory: function () { return host.getCurrentDirectory(); }, @@ -38911,17 +40234,46 @@ var ts; getFileIncludeReasons: function () { return host.getFileIncludeReasons(); }, } : undefined }, encounteredError: false, + reportedDiagnostic: false, visitedTypes: undefined, symbolDepth: undefined, inferTypeParameters: undefined, approximateLength: 0 }; + context.tracker = wrapSymbolTrackerToReportForContext(context, context.tracker); var resultingNode = cb(context); if (context.truncating && context.flags & 1) { (_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; } + function wrapSymbolTrackerToReportForContext(context, tracker) { + var oldTrackSymbol = tracker.trackSymbol; + return __assign(__assign({}, tracker), { reportCyclicStructureError: wrapReportedDiagnostic(tracker.reportCyclicStructureError), reportInaccessibleThisError: wrapReportedDiagnostic(tracker.reportInaccessibleThisError), reportInaccessibleUniqueSymbolError: wrapReportedDiagnostic(tracker.reportInaccessibleUniqueSymbolError), reportLikelyUnsafeImportRequiredError: wrapReportedDiagnostic(tracker.reportLikelyUnsafeImportRequiredError), reportNonlocalAugmentation: wrapReportedDiagnostic(tracker.reportNonlocalAugmentation), reportPrivateInBaseOfClassExpression: wrapReportedDiagnostic(tracker.reportPrivateInBaseOfClassExpression), trackSymbol: oldTrackSymbol && (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var result = oldTrackSymbol.apply(void 0, args); + if (result) { + context.reportedDiagnostic = true; + } + return result; + }) }); + function wrapReportedDiagnostic(method) { + if (!method) { + return method; + } + return (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + context.reportedDiagnostic = true; + return method.apply(void 0, args); + }); + } + } function checkTruncationLength(context) { if (context.truncating) return context.truncating; @@ -38939,33 +40291,33 @@ var ts; return undefined; } context.approximateLength += 3; - return ts.factory.createKeywordTypeNode(128); + return ts.factory.createKeywordTypeNode(129); } if (!(context.flags & 536870912)) { type = getReducedType(type); } if (type.flags & 1) { context.approximateLength += 3; - return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 136 : 128); + return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 137 : 129); } if (type.flags & 2) { - return ts.factory.createKeywordTypeNode(152); + return ts.factory.createKeywordTypeNode(153); } if (type.flags & 4) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(147); + return ts.factory.createKeywordTypeNode(148); } if (type.flags & 8) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(144); + return ts.factory.createKeywordTypeNode(145); } if (type.flags & 64) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(155); + return ts.factory.createKeywordTypeNode(156); } if (type.flags & 16) { context.approximateLength += 7; - return ts.factory.createKeywordTypeNode(131); + return ts.factory.createKeywordTypeNode(132); } if (type.flags & 1024 && !(type.flags & 1048576)) { var parentSymbol = getParentOfSymbol(type.symbol); @@ -39019,15 +40371,15 @@ var ts; } } context.approximateLength += 13; - return ts.factory.createTypeOperatorNode(151, ts.factory.createKeywordTypeNode(148)); + return ts.factory.createTypeOperatorNode(152, ts.factory.createKeywordTypeNode(149)); } if (type.flags & 16384) { context.approximateLength += 4; - return ts.factory.createKeywordTypeNode(113); + return ts.factory.createKeywordTypeNode(114); } if (type.flags & 32768) { context.approximateLength += 9; - return ts.factory.createKeywordTypeNode(150); + return ts.factory.createKeywordTypeNode(151); } if (type.flags & 65536) { context.approximateLength += 4; @@ -39035,15 +40387,15 @@ var ts; } if (type.flags & 131072) { context.approximateLength += 5; - return ts.factory.createKeywordTypeNode(141); + return ts.factory.createKeywordTypeNode(142); } if (type.flags & 4096) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(148); + return ts.factory.createKeywordTypeNode(149); } if (type.flags & 67108864) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(145); + return ts.factory.createKeywordTypeNode(146); } if (isThisTypeParameter(type)) { if (context.flags & 4194304) { @@ -39111,7 +40463,7 @@ var ts; var indexedType = type.type; context.approximateLength += 6; var indexTypeNode = typeToTypeNodeHelper(indexedType, context); - return ts.factory.createTypeOperatorNode(138, indexTypeNode); + return ts.factory.createTypeOperatorNode(139, indexTypeNode); } if (type.flags & 134217728) { var texts_1 = type.texts; @@ -39166,14 +40518,14 @@ var ts; var questionToken = type.declaration.questionToken ? ts.factory.createToken(type.declaration.questionToken.kind) : undefined; var appropriateConstraintTypeNode; if (isMappedTypeWithKeyofConstraintDeclaration(type)) { - appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(138, typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context)); + appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(139, 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(getTemplateTypeFromMappedType(type), context); + var templateTypeNode = typeToTypeNodeHelper(removeMissingType(getTemplateTypeFromMappedType(type), !!(getMappedTypeModifiers(type) & 4)), context); var mappedTypeNode = ts.factory.createMappedTypeNode(readonlyToken, typeParameterNode, nameTypeNode, questionToken, templateTypeNode); context.approximateLength += 10; return ts.setEmitFlags(mappedTypeNode, 1); @@ -39187,7 +40539,9 @@ var ts; if (isJSConstructor(symbol.valueDeclaration)) { return symbolToTypeNode(symbol, context, isInstanceType); } - else if (symbol.flags & 32 && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 221 && context.flags & 2048) || + else if (symbol.flags & 32 + && !getBaseTypeVariableOfClass(symbol) + && !(symbol.valueDeclaration && symbol.valueDeclaration.kind === 223 && context.flags & 2048) || symbol.flags & (384 | 512) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, isInstanceType); @@ -39215,7 +40569,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 297 || declaration.parent.kind === 257; + return declaration.parent.kind === 299 || declaration.parent.kind === 259; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return (!!(context.flags & 4096) || ((_a = context.visitedTypes) === null || _a === void 0 ? void 0 : _a.has(typeId))) && @@ -39224,6 +40578,7 @@ var ts; } } function visitAndTransformType(type, transform) { + var _a, _b; var typeId = type.id; var isConstructorObject = ts.getObjectFlags(type) & 16 && type.symbol && type.symbol.flags & 32; var id = ts.getObjectFlags(type) & 4 && type.node ? "N" + getNodeId(type.node) : @@ -39235,6 +40590,19 @@ var ts; if (id && !context.symbolDepth) { context.symbolDepth = new ts.Map(); } + var links = context.enclosingDeclaration && getNodeLinks(context.enclosingDeclaration); + var key = getTypeId(type) + "|" + context.flags; + if (links) { + links.serializedTypes || (links.serializedTypes = new ts.Map()); + } + var cachedResult = (_a = links === null || links === void 0 ? void 0 : links.serializedTypes) === null || _a === void 0 ? void 0 : _a.get(key); + if (cachedResult) { + if (cachedResult.truncating) { + context.truncating = true; + } + context.approximateLength += cachedResult.addedLength; + return deepCloneOrReuseNode(cachedResult); + } var depth; if (id) { depth = context.symbolDepth.get(id) || 0; @@ -39244,12 +40612,27 @@ var ts; context.symbolDepth.set(id, depth + 1); } context.visitedTypes.add(typeId); + var startLength = context.approximateLength; var result = transform(type); + var addedLength = context.approximateLength - startLength; + if (!context.reportedDiagnostic && !context.encounteredError) { + if (context.truncating) { + result.truncating = true; + } + result.addedLength = addedLength; + (_b = links === null || links === void 0 ? void 0 : links.serializedTypes) === null || _b === void 0 ? void 0 : _b.set(key, result); + } context.visitedTypes.delete(typeId); if (id) { context.symbolDepth.set(id, depth); } return result; + function deepCloneOrReuseNode(node) { + if (!ts.nodeIsSynthesized(node) && ts.getParseTreeNode(node) === node) { + return node; + } + return ts.setTextRange(ts.factory.cloneNode(ts.visitEachChild(node, deepCloneOrReuseNode, ts.nullTransformationContext)), node); + } } function createTypeNodeFromObjectType(type) { if (isGenericMappedType(type) || type.containsError) { @@ -39263,12 +40646,12 @@ var ts; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 174, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 176, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 175, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 177, context); return signatureNode; } } @@ -39305,9 +40688,10 @@ var ts; } var elementType = typeToTypeNodeHelper(typeArguments[0], context); var arrayType = ts.factory.createArrayTypeNode(elementType); - return type.target === globalArrayType ? arrayType : ts.factory.createTypeOperatorNode(142, arrayType); + return type.target === globalArrayType ? arrayType : ts.factory.createTypeOperatorNode(143, arrayType); } else if (type.target.objectFlags & 8) { + typeArguments = ts.sameMap(typeArguments, function (t, i) { return removeMissingType(t, !!(type.target.elementFlags[i] & 2)); }); if (typeArguments.length > 0) { var arity = getTypeReferenceArity(type); var tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, arity), context); @@ -39329,12 +40713,12 @@ var ts; } } var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode(tupleConstituentNodes), 1); - return type.target.readonly ? ts.factory.createTypeOperatorNode(142, tupleTypeNode) : tupleTypeNode; + return type.target.readonly ? ts.factory.createTypeOperatorNode(143, tupleTypeNode) : tupleTypeNode; } } if (context.encounteredError || (context.flags & 524288)) { var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode([]), 1); - return type.target.readonly ? ts.factory.createTypeOperatorNode(142, tupleTypeNode) : tupleTypeNode; + return type.target.readonly ? ts.factory.createTypeOperatorNode(143, tupleTypeNode) : tupleTypeNode; } context.encounteredError = true; return undefined; @@ -39434,17 +40818,17 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 169, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 171, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; if (signature.flags & 4) continue; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 170, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 172, context)); } if (resolvedType.stringIndexInfo) { var indexSignature = void 0; - if (resolvedType.objectFlags & 2048) { + if (resolvedType.objectFlags & 1024) { indexSignature = indexInfoToIndexSignatureDeclarationHelper(createIndexInfo(anyType, resolvedType.stringIndexInfo.isReadonly, resolvedType.stringIndexInfo.declaration), 0, context, createElidedInformationPlaceholder(context)); } else { @@ -39486,17 +40870,25 @@ var ts; if (!(context.flags & 1)) { return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier("..."), undefined); } - return ts.factory.createKeywordTypeNode(128); + return ts.factory.createKeywordTypeNode(129); + } + function shouldUsePlaceholderForProperty(propertySymbol, context) { + var _a; + return !!(ts.getCheckFlags(propertySymbol) & 8192) + && (ts.contains(context.reverseMappedStack, propertySymbol) + || (((_a = context.reverseMappedStack) === null || _a === void 0 ? void 0 : _a[0]) + && !(ts.getObjectFlags(ts.last(context.reverseMappedStack).propertyType) & 16))); } function addPropertyToElementList(propertySymbol, context, typeElements) { + var _a; var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192); - var propertyType = propertyIsReverseMapped && context.flags & 33554432 ? - anyType : getTypeOfSymbol(propertySymbol); + var propertyType = shouldUsePlaceholderForProperty(propertySymbol, context) ? + anyType : getNonMissingTypeOfSymbol(propertySymbol); var saveEnclosingDeclaration = context.enclosingDeclaration; context.enclosingDeclaration = undefined; if (context.tracker.trackSymbol && ts.getCheckFlags(propertySymbol) & 4096 && isLateBoundName(propertySymbol.escapedName)) { var decl = ts.first(propertySymbol.declarations); - if (hasLateBindableName(decl)) { + if (propertySymbol.declarations && hasLateBindableName(decl)) { if (ts.isBinaryExpression(decl)) { var name = ts.getNameOfDeclaration(decl); if (name && ts.isElementAccessExpression(name) && ts.isPropertyAccessEntityNameExpression(name.argumentExpression)) { @@ -39508,30 +40900,35 @@ var ts; } } } - context.enclosingDeclaration = saveEnclosingDeclaration; + context.enclosingDeclaration = propertySymbol.valueDeclaration || ((_a = propertySymbol.declarations) === null || _a === void 0 ? void 0 : _a[0]) || saveEnclosingDeclaration; var propertyName = getPropertyNameNodeForSymbol(propertySymbol, context); + context.enclosingDeclaration = saveEnclosingDeclaration; context.approximateLength += (ts.symbolName(propertySymbol).length + 1); var optionalToken = propertySymbol.flags & 16777216 ? ts.factory.createToken(57) : undefined; if (propertySymbol.flags & (16 | 8192) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) { var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768); }), 0); for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { var signature = signatures_1[_i]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 164, context, { name: propertyName, questionToken: optionalToken }); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 166, context, { name: propertyName, questionToken: optionalToken }); typeElements.push(preserveCommentsOn(methodDeclaration)); } } else { - var savedFlags = context.flags; - context.flags |= propertyIsReverseMapped ? 33554432 : 0; var propertyTypeNode = void 0; - if (propertyIsReverseMapped && !!(savedFlags & 33554432)) { + if (shouldUsePlaceholderForProperty(propertySymbol, context)) { propertyTypeNode = createElidedInformationPlaceholder(context); } else { - propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.factory.createKeywordTypeNode(128); + if (propertyIsReverseMapped) { + context.reverseMappedStack || (context.reverseMappedStack = []); + context.reverseMappedStack.push(propertySymbol); + } + propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.factory.createKeywordTypeNode(129); + if (propertyIsReverseMapped) { + context.reverseMappedStack.pop(); + } } - context.flags = savedFlags; - var modifiers = isReadonlySymbol(propertySymbol) ? [ts.factory.createToken(142)] : undefined; + var modifiers = isReadonlySymbol(propertySymbol) ? [ts.factory.createToken(143)] : undefined; if (modifiers) { context.approximateLength += 9; } @@ -39539,9 +40936,10 @@ var ts; typeElements.push(preserveCommentsOn(propertySignature)); } function preserveCommentsOn(node) { - if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 333; })) { - var d = ts.find(propertySymbol.declarations, function (d) { return d.kind === 333; }); - var commentText = d.comment; + var _a; + if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 341; })) { + var d = (_a = propertySymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 341; }); + var commentText = ts.getTextOfJSDocComment(d.comment); if (commentText) { ts.setSyntheticLeadingComments(node, [{ kind: 3, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]); } @@ -39568,25 +40966,25 @@ var ts; } var mayHaveNameCollisions = !(context.flags & 64); var seenNames = mayHaveNameCollisions ? ts.createUnderscoreEscapedMultiMap() : undefined; - var result_4 = []; + var result_5 = []; var i = 0; for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { var type = types_2[_i]; i++; if (checkTruncationLength(context) && (i + 2 < types.length - 1)) { - result_4.push(ts.factory.createTypeReferenceNode("... " + (types.length - i) + " more ...", undefined)); + result_5.push(ts.factory.createTypeReferenceNode("... " + (types.length - i) + " more ...", undefined)); var typeNode_1 = typeToTypeNodeHelper(types[types.length - 1], context); if (typeNode_1) { - result_4.push(typeNode_1); + result_5.push(typeNode_1); } break; } context.approximateLength += 2; var typeNode = typeToTypeNodeHelper(type, context); if (typeNode) { - result_4.push(typeNode); + result_5.push(typeNode); if (seenNames && ts.isIdentifierTypeReference(typeNode)) { - seenNames.add(typeNode.typeName.escapedText, [type, result_4.length - 1]); + seenNames.add(typeNode.typeName.escapedText, [type, result_5.length - 1]); } } } @@ -39601,13 +40999,13 @@ var ts; })) { for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { var _a = types_3[_i], type = _a[0], resultIndex = _a[1]; - result_4[resultIndex] = typeToTypeNodeHelper(type, context); + result_5[resultIndex] = typeToTypeNodeHelper(type, context); } } }); context.flags = saveContextFlags; } - return result_4; + return result_5; } } function typesAreSameReference(a, b) { @@ -39617,7 +41015,7 @@ var ts; } function indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context, typeNode) { var name = ts.getNameFromIndexInfo(indexInfo) || "x"; - var indexerTypeNode = ts.factory.createKeywordTypeNode(kind === 0 ? 147 : 144); + var indexerTypeNode = ts.factory.createKeywordTypeNode(kind === 0 ? 148 : 145); var indexingParameter = ts.factory.createParameterDeclaration(undefined, undefined, undefined, name, undefined, indexerTypeNode, undefined); if (!typeNode) { typeNode = typeToTypeNodeHelper(indexInfo.type || anyType, context); @@ -39626,13 +41024,14 @@ var ts; context.encounteredError = true; } context.approximateLength += (name.length + 4); - return ts.factory.createIndexSignature(undefined, indexInfo.isReadonly ? [ts.factory.createToken(142)] : undefined, [indexingParameter], typeNode); + return ts.factory.createIndexSignature(undefined, indexInfo.isReadonly ? [ts.factory.createToken(143)] : undefined, [indexingParameter], typeNode); } function signatureToSignatureDeclarationHelper(signature, kind, context, options) { var _a, _b, _c, _d; var suppressAny = context.flags & 256; if (suppressAny) context.flags &= ~256; + context.approximateLength += 3; var typeParameters; var typeArguments; if (context.flags & 32 && signature.target && signature.mapper && signature.target.typeParameters) { @@ -39642,7 +41041,7 @@ var ts; typeParameters = signature.typeParameters && signature.typeParameters.map(function (parameter) { return typeParameterToDeclaration(parameter, context); }); } 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 === 166, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); }); + 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 === 168, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -39651,7 +41050,7 @@ var ts; var typePredicate = getTypePredicateOfSignature(signature); if (typePredicate) { var assertsModifier = typePredicate.kind === 2 || typePredicate.kind === 3 ? - ts.factory.createToken(127) : + ts.factory.createToken(128) : undefined; var parameterName = typePredicate.kind === 1 || typePredicate.kind === 3 ? ts.setEmitFlags(ts.factory.createIdentifier(typePredicate.parameterName), 16777216) : @@ -39665,29 +41064,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(128); + returnTypeNode = ts.factory.createKeywordTypeNode(129); } } var modifiers = options === null || options === void 0 ? void 0 : options.modifiers; - if ((kind === 175) && signature.flags & 4) { + if ((kind === 177) && signature.flags & 4) { var flags = ts.modifiersToFlags(modifiers); modifiers = ts.factory.createModifiersFromModifierFlags(flags | 128); } - context.approximateLength += 3; - var node = kind === 169 ? ts.factory.createCallSignature(typeParameters, parameters, returnTypeNode) : - kind === 170 ? ts.factory.createConstructSignature(typeParameters, parameters, returnTypeNode) : - kind === 164 ? 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 === 165 ? ts.factory.createMethodDeclaration(undefined, modifiers, undefined, (_b = options === null || options === void 0 ? void 0 : options.name) !== null && _b !== void 0 ? _b : ts.factory.createIdentifier(""), undefined, typeParameters, parameters, returnTypeNode, undefined) : - kind === 166 ? ts.factory.createConstructorDeclaration(undefined, modifiers, parameters, undefined) : - kind === 167 ? ts.factory.createGetAccessorDeclaration(undefined, modifiers, (_c = options === null || options === void 0 ? void 0 : options.name) !== null && _c !== void 0 ? _c : ts.factory.createIdentifier(""), parameters, returnTypeNode, undefined) : - kind === 168 ? ts.factory.createSetAccessorDeclaration(undefined, modifiers, (_d = options === null || options === void 0 ? void 0 : options.name) !== null && _d !== void 0 ? _d : ts.factory.createIdentifier(""), parameters, undefined) : - kind === 171 ? ts.factory.createIndexSignature(undefined, modifiers, parameters, returnTypeNode) : - kind === 308 ? ts.factory.createJSDocFunctionType(parameters, returnTypeNode) : - kind === 174 ? ts.factory.createFunctionTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : - kind === 175 ? ts.factory.createConstructorTypeNode(modifiers, typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : - kind === 251 ? ts.factory.createFunctionDeclaration(undefined, modifiers, undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, undefined) : - kind === 208 ? ts.factory.createFunctionExpression(modifiers, 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 === 209 ? ts.factory.createArrowFunction(modifiers, typeParameters, parameters, returnTypeNode, undefined, ts.factory.createBlock([])) : + var node = kind === 171 ? ts.factory.createCallSignature(typeParameters, parameters, returnTypeNode) : + kind === 172 ? ts.factory.createConstructSignature(typeParameters, parameters, returnTypeNode) : + kind === 166 ? 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 === 167 ? ts.factory.createMethodDeclaration(undefined, modifiers, undefined, (_b = options === null || options === void 0 ? void 0 : options.name) !== null && _b !== void 0 ? _b : ts.factory.createIdentifier(""), undefined, typeParameters, parameters, returnTypeNode, undefined) : + kind === 168 ? ts.factory.createConstructorDeclaration(undefined, modifiers, parameters, undefined) : + kind === 169 ? ts.factory.createGetAccessorDeclaration(undefined, modifiers, (_c = options === null || options === void 0 ? void 0 : options.name) !== null && _c !== void 0 ? _c : ts.factory.createIdentifier(""), parameters, returnTypeNode, undefined) : + kind === 170 ? ts.factory.createSetAccessorDeclaration(undefined, modifiers, (_d = options === null || options === void 0 ? void 0 : options.name) !== null && _d !== void 0 ? _d : ts.factory.createIdentifier(""), parameters, undefined) : + kind === 173 ? ts.factory.createIndexSignature(undefined, modifiers, parameters, returnTypeNode) : + kind === 311 ? ts.factory.createJSDocFunctionType(parameters, returnTypeNode) : + kind === 176 ? ts.factory.createFunctionTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : + kind === 177 ? ts.factory.createConstructorTypeNode(modifiers, typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : + kind === 253 ? ts.factory.createFunctionDeclaration(undefined, modifiers, undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, undefined) : + kind === 210 ? ts.factory.createFunctionExpression(modifiers, 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 === 211 ? ts.factory.createArrowFunction(modifiers, typeParameters, parameters, returnTypeNode, undefined, ts.factory.createBlock([])) : ts.Debug.assertNever(kind); if (typeArguments) { node.typeArguments = ts.factory.createNodeArray(typeArguments); @@ -39709,9 +41107,9 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags, privateSymbolVisitor, bundledImports) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 160); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 162); if (!parameterDeclaration && !ts.isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 326); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 334); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -39725,8 +41123,8 @@ var ts; var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768; var dotDotDotToken = isRest ? ts.factory.createToken(25) : undefined; var name = parameterDeclaration ? parameterDeclaration.name ? - parameterDeclaration.name.kind === 78 ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name), 16777216) : - parameterDeclaration.name.kind === 157 ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name.right), 16777216) : + parameterDeclaration.name.kind === 79 ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name), 16777216) : + parameterDeclaration.name.kind === 159 ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name.right), 16777216) : cloneBindingName(parameterDeclaration.name) : ts.symbolName(parameterSymbol) : ts.symbolName(parameterSymbol); @@ -39872,11 +41270,11 @@ var ts; } function getSpecifierForModuleSymbol(symbol, context) { var _a; - var file = ts.getDeclarationOfKind(symbol, 297); + var file = ts.getDeclarationOfKind(symbol, 299); if (!file) { var equivalentFileSymbol = ts.firstDefined(symbol.declarations, function (d) { return getFileSymbolIfFileSymbolExportEqualsContainer(d, symbol); }); if (equivalentFileSymbol) { - file = ts.getDeclarationOfKind(equivalentFileSymbol, 297); + file = ts.getDeclarationOfKind(equivalentFileSymbol, 299); } } if (file && file.moduleName !== undefined) { @@ -39886,8 +41284,8 @@ var ts; if (context.tracker.trackReferencedAmbientModule) { var ambientDecls = ts.filter(symbol.declarations, ts.isAmbientModule); if (ts.length(ambientDecls)) { - for (var _i = 0, ambientDecls_1 = ambientDecls; _i < ambientDecls_1.length; _i++) { - var decl = ambientDecls_1[_i]; + for (var _i = 0, _b = ambientDecls; _i < _b.length; _i++) { + var decl = _b[_i]; context.tracker.trackReferencedAmbientModule(decl, symbol); } } @@ -39909,7 +41307,7 @@ var ts; var isBundle_1 = !!ts.outFile(compilerOptions); var moduleResolverHost = context.tracker.moduleResolverHost; var specifierCompilerOptions = isBundle_1 ? __assign(__assign({}, compilerOptions), { baseUrl: moduleResolverHost.getCommonSourceDirectory() }) : compilerOptions; - specifier = ts.first(ts.moduleSpecifiers.getModuleSpecifiers(symbol, checker, specifierCompilerOptions, contextFile, moduleResolverHost, { importModuleSpecifierPreference: isBundle_1 ? "non-relative" : "relative", importModuleSpecifierEnding: isBundle_1 ? "minimal" : undefined })); + specifier = ts.first(ts.moduleSpecifiers.getModuleSpecifiers(symbol, checker, specifierCompilerOptions, contextFile, moduleResolverHost, { importModuleSpecifierPreference: isBundle_1 ? "non-relative" : "project-relative", importModuleSpecifierEnding: isBundle_1 ? "minimal" : undefined })); (_a = links.specifierCache) !== null && _a !== void 0 ? _a : (links.specifierCache = new ts.Map()); links.specifierCache.set(contextFile.path, specifier); } @@ -40018,7 +41416,7 @@ var ts; return false; } function typeParameterToName(type, context) { - var _a; + var _a, _b; if (context.flags & 4 && context.typeParameterNames) { var cached = context.typeParameterNames.get(getTypeId(type)); if (cached) { @@ -40026,22 +41424,23 @@ var ts; } } var result = symbolToName(type.symbol, context, 788968, true); - if (!(result.kind & 78)) { + if (!(result.kind & 79)) { return ts.factory.createIdentifier("(Missing type parameter)"); } if (context.flags & 4) { var rawtext = result.escapedText; - var i = 0; + var i = ((_a = context.typeParameterNamesByTextNextNameCount) === null || _a === void 0 ? void 0 : _a.get(rawtext)) || 0; var text = rawtext; - while (((_a = context.typeParameterNamesByText) === null || _a === void 0 ? void 0 : _a.has(text)) || typeParameterShadowsNameInScope(text, context, type)) { + while (((_b = context.typeParameterNamesByText) === null || _b === void 0 ? void 0 : _b.has(text)) || typeParameterShadowsNameInScope(text, context, type)) { i++; text = rawtext + "_" + i; } if (text !== rawtext) { result = ts.factory.createIdentifier(text, result.typeArguments); } + (context.typeParameterNamesByTextNextNameCount || (context.typeParameterNamesByTextNextNameCount = new ts.Map())).set(rawtext, i); (context.typeParameterNames || (context.typeParameterNames = new ts.Map())).set(getTypeId(type), result); - (context.typeParameterNamesByText || (context.typeParameterNamesByText = new ts.Set())).add(result.escapedText); + (context.typeParameterNamesByText || (context.typeParameterNamesByText = new ts.Set())).add(rawtext); } return result; } @@ -40129,9 +41528,6 @@ var ts; if (fromNameType) { return fromNameType; } - if (ts.isKnownSymbol(symbol)) { - return ts.factory.createComputedPropertyName(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("Symbol"), symbol.escapedName.substr(3))); - } var rawName = ts.unescapeLeadingUnderscores(symbol.escapedName); var stringNamed = !!ts.length(symbol.declarations) && ts.every(symbol.declarations, isStringNamed); return createPropertyNameNodeForIdentifierOrLiteral(rawName, stringNamed, singleQuote); @@ -40170,6 +41566,7 @@ var ts; if (initial.typeParameterSymbolList) { initial.typeParameterSymbolList = new ts.Set(initial.typeParameterSymbolList); } + initial.tracker = wrapSymbolTrackerToReportForContext(initial, initial.tracker); return initial; } function getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration) { @@ -40181,12 +41578,12 @@ var ts; function serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled) { if (type !== errorType && enclosingDeclaration) { var declWithExistingAnnotation = getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration); - if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation)) { + if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation) && !ts.isGetAccessorDeclaration(declWithExistingAnnotation)) { var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation); if (getTypeFromTypeNode(existing) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) { - var result_5 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled); - if (result_5) { - return result_5; + var result_6 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled); + if (result_6) { + return result_6; } } } @@ -40203,10 +41600,14 @@ var ts; function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) { if (type !== errorType && context.enclosingDeclaration) { var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); - if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation && instantiateType(getTypeFromTypeNode(annotation), signature.mapper) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) { - var result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled); - if (result) { - return result; + if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation) { + var annotated = getTypeFromTypeNode(annotation); + var thisInstantiated = annotated.flags & 262144 && annotated.isThisType ? instantiateType(annotated, signature.mapper) : annotated; + if (thisInstantiated === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) { + var result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled); + if (result) { + return result; + } } } } @@ -40249,17 +41650,17 @@ var ts; } return transformed === existing ? ts.setTextRange(ts.factory.cloneNode(existing), existing) : transformed; function visitExistingNodeTreeSymbols(node) { - if (ts.isJSDocAllType(node) || node.kind === 310) { - return ts.factory.createKeywordTypeNode(128); + if (ts.isJSDocAllType(node) || node.kind === 313) { + return ts.factory.createKeywordTypeNode(129); } if (ts.isJSDocUnknownType(node)) { - return ts.factory.createKeywordTypeNode(152); + return ts.factory.createKeywordTypeNode(153); } 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(150)]); + return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createKeywordTypeNode(151)]); } if (ts.isJSDocNonNullableType(node)) { return ts.visitNode(node.type, visitExistingNodeTreeSymbols); @@ -40272,11 +41673,11 @@ var ts; var name = ts.isIdentifier(t.name) ? t.name : t.name.right; var typeViaParent = getTypeOfPropertyOfType(getTypeFromTypeNode(node), name.escapedText); var overrideTypeNode = typeViaParent && t.typeExpression && getTypeFromTypeNode(t.typeExpression.type) !== typeViaParent ? typeToTypeNodeHelper(typeViaParent, context) : undefined; - return ts.factory.createPropertySignature(undefined, name, t.isBracketed || t.typeExpression && ts.isJSDocOptionalType(t.typeExpression.type) ? ts.factory.createToken(57) : undefined, overrideTypeNode || (t.typeExpression && ts.visitNode(t.typeExpression.type, visitExistingNodeTreeSymbols)) || ts.factory.createKeywordTypeNode(128)); + return ts.factory.createPropertySignature(undefined, name, t.isBracketed || t.typeExpression && ts.isJSDocOptionalType(t.typeExpression.type) ? ts.factory.createToken(57) : undefined, overrideTypeNode || (t.typeExpression && ts.visitNode(t.typeExpression.type, visitExistingNodeTreeSymbols)) || ts.factory.createKeywordTypeNode(129)); })); } if (ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "") { - return ts.setOriginalNode(ts.factory.createKeywordTypeNode(128), node); + return ts.setOriginalNode(ts.factory.createKeywordTypeNode(129), node); } if ((ts.isExpressionWithTypeArguments(node) || ts.isTypeReferenceNode(node)) && ts.isJSDocIndexSignature(node)) { return ts.factory.createTypeLiteralNode([ts.factory.createIndexSignature(undefined, undefined, [ts.factory.createParameterDeclaration(undefined, undefined, undefined, "x", undefined, ts.visitNode(node.typeArguments[0], visitExistingNodeTreeSymbols))], ts.visitNode(node.typeArguments[1], visitExistingNodeTreeSymbols))]); @@ -40284,10 +41685,10 @@ var ts; if (ts.isJSDocFunctionType(node)) { if (ts.isJSDocConstructSignature(node)) { var newTypeNode_1; - return ts.factory.createConstructorTypeNode(node.modifiers, 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(undefined, undefined, getEffectiveDotDotDotForParameter(p), getNameForJSDocFunctionParameter(p, i), p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(128)); + return ts.factory.createConstructorTypeNode(node.modifiers, 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(undefined, undefined, getEffectiveDotDotDotForParameter(p), getNameForJSDocFunctionParameter(p, i), p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(129)); } else { - return ts.factory.createFunctionTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.map(node.parameters, function (p, i) { return ts.factory.createParameterDeclaration(undefined, undefined, getEffectiveDotDotDotForParameter(p), getNameForJSDocFunctionParameter(p, i), p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(128)); + return ts.factory.createFunctionTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.map(node.parameters, function (p, i) { return ts.factory.createParameterDeclaration(undefined, undefined, getEffectiveDotDotDotForParameter(p), getNameForJSDocFunctionParameter(p, i), p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(129)); } } if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(getTypeReferenceName(node), 788968, true))) { @@ -40351,8 +41752,8 @@ var ts; } } function symbolTableToDeclarationStatements(symbolTable, context, bundled) { - var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.factory.createPropertyDeclaration, 165, true); - var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type) { return ts.factory.createPropertySignature(mods, name, question, type); }, 164, false); + var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.factory.createPropertyDeclaration, 167, true); + var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type) { return ts.factory.createPropertySignature(mods, name, question, type); }, 166, false); var enclosingDeclaration = context.enclosingDeclaration; var results = []; var visitedSymbols = new ts.Set(); @@ -40367,9 +41768,11 @@ var ts; } } else if (oldcontext.tracker && oldcontext.tracker.trackSymbol) { - oldcontext.tracker.trackSymbol(sym, decl, meaning); + return oldcontext.tracker.trackSymbol(sym, decl, meaning); } + return false; } }) }); + context.tracker = wrapSymbolTrackerToReportForContext(context, context.tracker); ts.forEachEntry(symbolTable, function (symbol, name) { var baseName = ts.unescapeLeadingUnderscores(name); void getInternalSymbolName(symbol, baseName); @@ -40383,7 +41786,7 @@ var ts; visitSymbolTable(symbolTable); return mergeRedundantStatements(results); function isIdentifierAndNotUndefined(node) { - return !!node && node.kind === 78; + return !!node && node.kind === 79; } function getNamesOfDeclaration(statement) { if (ts.isVariableStatement(statement)) { @@ -40521,11 +41924,15 @@ var ts; var oldContext = context; context = cloneNodeBuilderContext(context); var result = serializeSymbolWorker(symbol, isPrivate, propertyAsAlias); + if (context.reportedDiagnostic) { + oldcontext.reportedDiagnostic = context.reportedDiagnostic; + } context = oldContext; return result; } } function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias) { + var _a, _b; var symbolName = ts.unescapeLeadingUnderscores(symbol.escapedName); var isDefault = symbol.escapedName === "default"; if (isPrivate && !(context.flags & 131072) && ts.isStringANonContextualKeyword(symbolName) && !isDefault) { @@ -40576,9 +41983,9 @@ var ts; if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) { textRange = textRange.parent.parent; } - var propertyAccessRequire = ts.find(symbol.declarations, ts.isPropertyAccessExpression); + var propertyAccessRequire = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isPropertyAccessExpression); if (propertyAccessRequire && ts.isBinaryExpression(propertyAccessRequire.parent) && ts.isIdentifier(propertyAccessRequire.parent.right) - && type.symbol && ts.isSourceFile(type.symbol.valueDeclaration)) { + && ((_b = type.symbol) === null || _b === void 0 ? void 0 : _b.valueDeclaration) && ts.isSourceFile(type.symbol.valueDeclaration)) { var alias = localName === propertyAccessRequire.parent.right.escapedText ? undefined : propertyAccessRequire.parent.right; addResult(ts.factory.createExportDeclaration(undefined, undefined, false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(alias, localName)])), 0); context.tracker.trackSymbol(type.symbol, context.enclosingDeclaration, 111551); @@ -40601,7 +42008,10 @@ var ts; serializeEnum(symbol, symbolName, modifierFlags); } if (symbol.flags & 32) { - if (symbol.flags & 4 && ts.isBinaryExpression(symbol.valueDeclaration.parent) && ts.isClassExpression(symbol.valueDeclaration.parent.right)) { + if (symbol.flags & 4 + && symbol.valueDeclaration + && ts.isBinaryExpression(symbol.valueDeclaration.parent) + && ts.isClassExpression(symbol.valueDeclaration.parent.right)) { serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); } else { @@ -40621,12 +42031,14 @@ var ts; serializeMaybeAliasAssignment(symbol); } if (symbol.flags & 8388608) { - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var node = _a[_i]; - var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); - if (!resolvedModule) - continue; - addResult(ts.factory.createExportDeclaration(undefined, undefined, false, undefined, ts.factory.createStringLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0); + if (symbol.declarations) { + for (var _i = 0, _c = symbol.declarations; _i < _c.length; _i++) { + var node = _c[_i]; + var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); + if (!resolvedModule) + continue; + addResult(ts.factory.createExportDeclaration(undefined, undefined, false, undefined, ts.factory.createStringLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0); + } } } if (needsPostExportDefault) { @@ -40655,14 +42067,15 @@ var ts; function addResult(node, additionalModifierFlags) { if (ts.canHaveModifiers(node)) { var newModifierFlags = 0; + var enclosingDeclaration_1 = context.enclosingDeclaration && + (ts.isJSDocTypeAlias(context.enclosingDeclaration) ? ts.getSourceFileOfNode(context.enclosingDeclaration) : context.enclosingDeclaration); if (additionalModifierFlags & 1 && - context.enclosingDeclaration && - (isExportingScope(context.enclosingDeclaration) || ts.isModuleDeclaration(context.enclosingDeclaration)) && + enclosingDeclaration_1 && (isExportingScope(enclosingDeclaration_1) || ts.isModuleDeclaration(enclosingDeclaration_1)) && canHaveExportModifier(node)) { newModifierFlags |= 1; } if (addingDeclare && !(newModifierFlags & 1) && - (!context.enclosingDeclaration || !(context.enclosingDeclaration.flags & 8388608)) && + (!enclosingDeclaration_1 || !(enclosingDeclaration_1.flags & 8388608)) && (ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node) || ts.isModuleDeclaration(node))) { newModifierFlags |= 2; } @@ -40676,19 +42089,23 @@ var ts; results.push(node); } function serializeTypeAlias(symbol, symbolName, modifierFlags) { + var _a; var aliasType = getDeclaredTypeOfTypeAlias(symbol); var typeParams = getSymbolLinks(symbol).typeParameters; var typeParamDecls = ts.map(typeParams, function (p) { return typeParameterToDeclaration(p, context); }); - var jsdocAliasDecl = ts.find(symbol.declarations, ts.isJSDocTypeAlias); - var commentText = jsdocAliasDecl ? jsdocAliasDecl.comment || jsdocAliasDecl.parent.comment : undefined; + 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; + 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(undefined, undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, typeNode), !commentText ? [] : [{ kind: 3, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]), modifierFlags); context.flags = oldFlags; + context.enclosingDeclaration = oldEnclosingDecl; } function serializeInterface(symbol, symbolName, modifierFlags) { var interfaceType = getDeclaredTypeOfClassOrInterface(symbol); @@ -40697,10 +42114,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, interfaceType, baseType, 169); - var constructSignatures = serializeSignatures(1, interfaceType, baseType, 170); + var callSignatures = serializeSignatures(0, interfaceType, baseType, 171); + var constructSignatures = serializeSignatures(1, interfaceType, baseType, 172); var indexSignatures = serializeIndexSignatures(interfaceType, baseType); - var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.factory.createHeritageClause(93, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b, 111551); }))]; + var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.factory.createHeritageClause(94, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b, 111551); }))]; addResult(ts.factory.createInterfaceDeclaration(undefined, undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, heritageClauses, __spreadArray(__spreadArray(__spreadArray(__spreadArray([], indexSignatures), constructSignatures), callSignatures), members)), modifierFlags); } function getNamespaceMembersForSerialization(symbol) { @@ -40750,14 +42167,25 @@ var ts; var signatures = getSignaturesOfType(type, 0); for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var sig = signatures_2[_i]; - var decl = signatureToSignatureDeclarationHelper(sig, 251, context, { name: ts.factory.createIdentifier(localName), privateSymbolVisitor: includePrivateSymbol, bundledImports: bundled }); - addResult(ts.setTextRange(decl, sig.declaration && ts.isVariableDeclaration(sig.declaration.parent) && sig.declaration.parent.parent || sig.declaration), modifierFlags); + var decl = signatureToSignatureDeclarationHelper(sig, 253, context, { name: ts.factory.createIdentifier(localName), privateSymbolVisitor: includePrivateSymbol, bundledImports: bundled }); + addResult(ts.setTextRange(decl, getSignatureTextRangeLocation(sig)), modifierFlags); } if (!(symbol.flags & (512 | 1024) && !!symbol.exports && !!symbol.exports.size)) { var props = ts.filter(getPropertiesOfType(type), isNamespaceMember); serializeAsNamespaceDeclaration(props, localName, modifierFlags, true); } } + function getSignatureTextRangeLocation(signature) { + if (signature.declaration && signature.declaration.parent) { + if (ts.isBinaryExpression(signature.declaration.parent) && ts.getAssignmentDeclarationKind(signature.declaration.parent) === 5) { + return signature.declaration.parent; + } + if (ts.isVariableDeclaration(signature.declaration.parent) && signature.declaration.parent.parent) { + return signature.declaration.parent.parent; + } + } + return signature.declaration; + } function serializeAsNamespaceDeclaration(props, localName, modifierFlags, suppressNewPrivateContext) { if (ts.length(props)) { var localVsRemoteMap = ts.arrayToMultiMap(props, function (p) { @@ -40823,8 +42251,8 @@ var ts; return undefined; } function serializeAsClass(symbol, localName, modifierFlags) { - var _a; - var originalDecl = ts.find(symbol.declarations, ts.isClassLike); + var _a, _b; + var originalDecl = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isClassLike); var oldEnclosing = context.enclosingDeclaration; context.enclosingDeclaration = originalDecl || oldEnclosing; var localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -40835,19 +42263,19 @@ var ts; var implementsExpressions = originalImplements && sanitizeJSDocImplements(originalImplements) || ts.mapDefined(getImplementsTypes(classType), serializeImplementedType); var staticType = getTypeOfSymbol(symbol); - var isClass = !!((_a = staticType.symbol) === null || _a === void 0 ? void 0 : _a.valueDeclaration) && ts.isClassLike(staticType.symbol.valueDeclaration); + var isClass = !!((_b = staticType.symbol) === null || _b === void 0 ? void 0 : _b.valueDeclaration) && ts.isClassLike(staticType.symbol.valueDeclaration); var staticBaseType = isClass ? getBaseConstructorTypeOfClass(staticType) : anyType; - var heritageClauses = __spreadArray(__spreadArray([], !ts.length(baseTypes) ? [] : [ts.factory.createHeritageClause(93, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))]), !ts.length(implementsExpressions) ? [] : [ts.factory.createHeritageClause(116, implementsExpressions)]); + var heritageClauses = __spreadArray(__spreadArray([], !ts.length(baseTypes) ? [] : [ts.factory.createHeritageClause(94, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))]), !ts.length(implementsExpressions) ? [] : [ts.factory.createHeritageClause(117, implementsExpressions)]); var symbolProps = getNonInterhitedProperties(classType, baseTypes, getPropertiesOfType(classType)); var publicSymbolProps = ts.filter(symbolProps, function (s) { var valueDecl = s.valueDeclaration; - return valueDecl && !(ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name)); + return !!valueDecl && !(ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name)); }); var hasPrivateIdentifier = ts.some(symbolProps, function (s) { var valueDecl = s.valueDeclaration; - return valueDecl && ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name); + return !!valueDecl && ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name); }); var privateProperties = hasPrivateIdentifier ? [ts.factory.createPropertyDeclaration(undefined, undefined, ts.factory.createPrivateIdentifier("#private"), undefined, undefined, undefined)] : @@ -40860,7 +42288,7 @@ var ts; !ts.some(getSignaturesOfType(staticType, 1)); var constructors = isNonConstructableClassLikeInJsFile ? [ts.factory.createConstructorDeclaration(undefined, ts.factory.createModifiersFromModifierFlags(8), [], undefined)] : - serializeSignatures(1, staticType, staticBaseType, 166); + serializeSignatures(1, staticType, staticBaseType, 168); var indexSignatures = serializeIndexSignatures(classType, baseTypes[0]); context.enclosingDeclaration = oldEnclosing; addResult(ts.setTextRange(ts.factory.createClassDeclaration(undefined, undefined, localName, typeParamDecls, heritageClauses, __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], indexSignatures), staticMembers), constructors), publicProperties), privateProperties)), symbol.declarations && ts.filter(symbol.declarations, function (d) { return ts.isClassDeclaration(d) || ts.isClassExpression(d); })[0]), modifierFlags); @@ -40881,8 +42309,8 @@ var ts; var targetName = getInternalSymbolName(target, verbatimTargetName); includePrivateSymbol(target); switch (node.kind) { - case 198: - if (((_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.kind) === 249) { + case 200: + if (((_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.kind) === 251) { var specifier_1 = getSpecifierForModuleSymbol(target.parent || target, context); var propertyName = node.propertyName; addResult(ts.factory.createImportDeclaration(undefined, undefined, ts.factory.createImportClause(false, undefined, ts.factory.createNamedImports([ts.factory.createImportSpecifier(propertyName && ts.isIdentifier(propertyName) ? ts.factory.createIdentifier(ts.idText(propertyName)) : undefined, ts.factory.createIdentifier(localName))])), ts.factory.createStringLiteral(specifier_1)), 0); @@ -40890,12 +42318,12 @@ var ts; } 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 289: - if (((_e = (_d = node.parent) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.kind) === 216) { + case 291: + if (((_e = (_d = node.parent) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.kind) === 218) { serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), targetName); } break; - case 249: + case 251: if (ts.isPropertyAccessExpression(node.initializer)) { var initializer = node.initializer; var uniqueName = ts.factory.createUniqueName(localName); @@ -40904,7 +42332,7 @@ var ts; addResult(ts.factory.createImportEqualsDeclaration(undefined, undefined, false, ts.factory.createIdentifier(localName), ts.factory.createQualifiedName(uniqueName, initializer.name)), modifierFlags); break; } - case 260: + case 262: if (target.escapedName === "export=" && ts.some(target.declarations, ts.isJsonSourceFile)) { serializeMaybeAliasAssignment(symbol); break; @@ -40914,33 +42342,33 @@ var ts; ? symbolToName(target, context, 67108863, false) : ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)))), isLocalImport ? modifierFlags : 0); break; - case 259: + case 261: addResult(ts.factory.createNamespaceExportDeclaration(ts.idText(node.name)), 0); break; - case 262: + case 264: addResult(ts.factory.createImportDeclaration(undefined, undefined, ts.factory.createImportClause(false, ts.factory.createIdentifier(localName), undefined), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context))), 0); break; - case 263: + case 265: addResult(ts.factory.createImportDeclaration(undefined, undefined, ts.factory.createImportClause(false, undefined, ts.factory.createNamespaceImport(ts.factory.createIdentifier(localName))), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))), 0); break; - case 269: + case 271: addResult(ts.factory.createExportDeclaration(undefined, undefined, false, ts.factory.createNamespaceExport(ts.factory.createIdentifier(localName)), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))), 0); break; - case 265: + case 267: addResult(ts.factory.createImportDeclaration(undefined, undefined, ts.factory.createImportClause(false, undefined, ts.factory.createNamedImports([ ts.factory.createImportSpecifier(localName !== verbatimTargetName ? ts.factory.createIdentifier(verbatimTargetName) : undefined, ts.factory.createIdentifier(localName)) ])), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context))), 0); break; - case 270: + case 272: var specifier = node.parent.parent.moduleSpecifier; serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), specifier ? verbatimTargetName : targetName, specifier && ts.isStringLiteralLike(specifier) ? ts.factory.createStringLiteral(specifier.text) : undefined); break; - case 266: + case 268: serializeMaybeAliasAssignment(symbol); break; - case 216: - case 201: - case 202: + case 218: + case 203: + case 204: if (symbol.escapedName === "default" || symbol.escapedName === "export=") { serializeMaybeAliasAssignment(symbol); } @@ -40973,7 +42401,7 @@ var ts; includePrivateSymbol(referenced || target); } var oldTrack = context.tracker.trackSymbol; - context.tracker.trackSymbol = ts.noop; + context.tracker.trackSymbol = function () { return false; }; if (isExportAssignmentCompatibleSymbolName) { results.push(ts.factory.createExportAssignment(undefined, undefined, isExportEquals, symbolToExpression(target, context, 67108863))); } @@ -41034,6 +42462,7 @@ var ts; } function makeSerializePropertySymbol(createProperty, methodKind, useAccessors) { return function serializePropertySymbol(p, isStatic, baseType) { + var _a, _b, _c, _d, _e; var modifierFlags = ts.getDeclarationModifierFlagsFromSymbol(p); var isPrivate = !!(modifierFlags & 8); if (isStatic && (p.flags & (788968 | 1920 | 2097152))) { @@ -41048,26 +42477,26 @@ var ts; } var flag = (modifierFlags & ~256) | (isStatic ? 32 : 0); var name = getPropertyNameNodeForSymbol(p, context); - var firstPropertyLikeDecl = ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isAccessor, ts.isVariableDeclaration, ts.isPropertySignature, ts.isBinaryExpression, ts.isPropertyAccessExpression)); + 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 && useAccessors) { var result = []; if (p.flags & 65536) { - result.push(ts.setTextRange(ts.factory.createSetAccessorDeclaration(undefined, ts.factory.createModifiersFromModifierFlags(flag), name, [ts.factory.createParameterDeclaration(undefined, undefined, undefined, "arg", undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled))], undefined), ts.find(p.declarations, ts.isSetAccessor) || firstPropertyLikeDecl)); + result.push(ts.setTextRange(ts.factory.createSetAccessorDeclaration(undefined, ts.factory.createModifiersFromModifierFlags(flag), name, [ts.factory.createParameterDeclaration(undefined, undefined, undefined, "arg", undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled))], undefined), ((_b = p.declarations) === null || _b === void 0 ? void 0 : _b.find(ts.isSetAccessor)) || firstPropertyLikeDecl)); } if (p.flags & 32768) { var isPrivate_1 = modifierFlags & 8; - result.push(ts.setTextRange(ts.factory.createGetAccessorDeclaration(undefined, ts.factory.createModifiersFromModifierFlags(flag), name, [], isPrivate_1 ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), undefined), ts.find(p.declarations, ts.isGetAccessor) || firstPropertyLikeDecl)); + result.push(ts.setTextRange(ts.factory.createGetAccessorDeclaration(undefined, ts.factory.createModifiersFromModifierFlags(flag), name, [], isPrivate_1 ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), undefined), ((_c = p.declarations) === null || _c === void 0 ? void 0 : _c.find(ts.isGetAccessor)) || firstPropertyLikeDecl)); } return result; } else if (p.flags & (4 | 3 | 98304)) { - return ts.setTextRange(createProperty(undefined, ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 : 0) | flag), name, p.flags & 16777216 ? ts.factory.createToken(57) : undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), undefined), ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isVariableDeclaration)) || firstPropertyLikeDecl); + return ts.setTextRange(createProperty(undefined, ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 : 0) | flag), name, p.flags & 16777216 ? ts.factory.createToken(57) : undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), undefined), ((_d = p.declarations) === null || _d === void 0 ? void 0 : _d.find(ts.or(ts.isPropertyDeclaration, ts.isVariableDeclaration))) || firstPropertyLikeDecl); } if (p.flags & (8192 | 16)) { var type = getTypeOfSymbol(p); var signatures = getSignaturesOfType(type, 0); if (flag & 8) { - return ts.setTextRange(createProperty(undefined, ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 : 0) | flag), name, p.flags & 16777216 ? ts.factory.createToken(57) : undefined, undefined, undefined), ts.find(p.declarations, ts.isFunctionLikeDeclaration) || signatures[0] && signatures[0].declaration || p.declarations[0]); + return ts.setTextRange(createProperty(undefined, ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 : 0) | flag), name, p.flags & 16777216 ? ts.factory.createToken(57) : undefined, undefined, undefined), ((_e = p.declarations) === null || _e === void 0 ? void 0 : _e.find(ts.isFunctionLikeDeclaration)) || signatures[0] && signatures[0].declaration || p.declarations && p.declarations[0]); } var results_1 = []; for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { @@ -41077,7 +42506,8 @@ var ts; questionToken: p.flags & 16777216 ? ts.factory.createToken(57) : undefined, modifiers: flag ? ts.factory.createModifiersFromModifierFlags(flag) : undefined }); - results_1.push(ts.setTextRange(decl, sig.declaration)); + var location = sig.declaration && ts.isPrototypePropertyAssignment(sig.declaration.parent) ? sig.declaration.parent : sig.declaration; + results_1.push(ts.setTextRange(decl, location)); } return results_1; } @@ -41239,7 +42669,7 @@ var ts; if (flags === void 0) { flags = 16384; } return writer ? typePredicateToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(typePredicateToStringWorker); function typePredicateToStringWorker(writer) { - var predicate = ts.factory.createTypePredicateNode(typePredicate.kind === 2 || typePredicate.kind === 3 ? ts.factory.createToken(127) : undefined, typePredicate.kind === 1 || typePredicate.kind === 3 ? ts.factory.createIdentifier(typePredicate.parameterName) : ts.factory.createThisTypeNode(), typePredicate.type && nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 | 512)); + var predicate = ts.factory.createTypePredicateNode(typePredicate.kind === 2 || typePredicate.kind === 3 ? ts.factory.createToken(128) : undefined, typePredicate.kind === 1 || typePredicate.kind === 3 ? ts.factory.createIdentifier(typePredicate.parameterName) : ts.factory.createThisTypeNode(), typePredicate.type && nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 | 512)); var printer = ts.createPrinter({ removeComments: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); printer.writeNode(4, predicate, sourceFile, writer); @@ -41283,9 +42713,9 @@ var ts; return "public"; } function getTypeAliasForTypeLiteral(type) { - if (type.symbol && type.symbol.flags & 2048) { + if (type.symbol && type.symbol.flags & 2048 && type.symbol.declarations) { var node = ts.walkUpParenthesizedTypes(type.symbol.declarations[0].parent); - if (node.kind === 254) { + if (node.kind === 256) { return getSymbolOfNode(node); } } @@ -41293,11 +42723,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 257 && + node.parent.kind === 259 && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 297 || ts.isAmbientModule(location); + return location.kind === 299 || ts.isAmbientModule(location); } function getNameOfSymbolFromNameType(symbol, context) { var nameType = getSymbolLinks(symbol).nameType; @@ -41345,17 +42775,17 @@ var ts; if (!declaration) { declaration = symbol.declarations[0]; } - if (declaration.parent && declaration.parent.kind === 249) { + if (declaration.parent && declaration.parent.kind === 251) { return ts.declarationNameToString(declaration.parent.name); } switch (declaration.kind) { - case 221: - case 208: - case 209: + case 223: + case 210: + case 211: if (context && !context.encounteredError && !(context.flags & 131072)) { context.encounteredError = true; } - return declaration.kind === 221 ? "(Anonymous class)" : "(Anonymous function)"; + return declaration.kind === 223 ? "(Anonymous class)" : "(Anonymous function)"; } } var name = getNameOfSymbolFromNameType(symbol, context); @@ -41372,68 +42802,68 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 324: - case 331: - case 325: + case 332: + case 339: + case 333: return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent)); - case 198: + case 200: return isDeclarationVisible(node.parent.parent); - case 249: + case 251: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 256: - case 252: - case 253: + case 258: case 254: - case 251: case 255: - case 260: + case 256: + case 253: + case 257: + case 262: if (ts.isExternalModuleAugmentation(node)) { return true; } var parent = getDeclarationContainer(node); if (!(ts.getCombinedModifierFlags(node) & 1) && - !(node.kind !== 260 && parent.kind !== 297 && parent.flags & 8388608)) { + !(node.kind !== 262 && parent.kind !== 299 && parent.flags & 8388608)) { return isGlobalSourceFile(parent); } return isDeclarationVisible(parent); - case 163: - case 162: - case 167: - case 168: case 165: case 164: + case 169: + case 170: + case 167: + case 166: if (ts.hasEffectiveModifier(node, 8 | 16)) { return false; } - case 166: - case 170: - case 169: + case 168: + case 172: case 171: - case 160: - case 257: - case 174: - case 175: - case 177: case 173: - case 178: + case 162: + case 259: + case 176: + case 177: case 179: - case 182: - case 183: - case 186: - case 192: + case 175: + case 180: + case 181: + case 184: + case 185: + case 188: + case 194: return isDeclarationVisible(node.parent); - case 262: - case 263: + case 264: case 265: + case 267: return false; - case 159: - case 297: - case 259: + case 161: + case 299: + case 261: return true; - case 266: + case 268: return false; default: return false; @@ -41442,10 +42872,10 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 266) { + if (node.parent && node.parent.kind === 268) { exportSymbol = resolveName(node, node.escapedText, 111551 | 788968 | 1920 | 2097152, undefined, node, false); } - else if (node.parent.kind === 270) { + else if (node.parent.kind === 272) { exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 | 788968 | 1920 | 2097152); } var result; @@ -41533,12 +42963,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 249: - case 250: + case 251: + case 252: + case 267: + case 266: case 265: case 264: - case 263: - case 262: return false; default: return true; @@ -41594,9 +43024,16 @@ var ts; var stringIndexInfo = getIndexInfoOfType(source, 0); var numberIndexInfo = getIndexInfoOfType(source, 1); var result = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); - result.objectFlags |= 131072; + result.objectFlags |= 8388608; return result; } + function isGenericTypeWithUndefinedConstraint(type) { + return !!(type.flags & 465829888) && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 32768); + } + function getNonUndefinedType(type) { + var typeOrConstraint = someType(type, isGenericTypeWithUndefinedConstraint) ? mapType(type, function (t) { return t.flags & 465829888 ? getBaseConstraintOrType(t) : t; }) : type; + return getTypeWithFacts(typeOrConstraint, 524288); + } function getFlowTypeOfDestructuring(node, declaredType) { var reference = getSyntheticElementAccess(node); return reference ? getFlowTypeOfReference(reference, declaredType) : declaredType; @@ -41622,23 +43059,23 @@ var ts; function getParentElementAccess(node) { var ancestor = node.parent.parent; switch (ancestor.kind) { - case 198: - case 288: + case 200: + case 290: return getSyntheticElementAccess(ancestor); - case 199: + case 201: return getSyntheticElementAccess(node.parent); - case 249: + case 251: return ancestor.initializer; - case 216: + case 218: return ancestor.right; } } function getDestructuringPropertyName(node) { var parent = node.parent; - if (node.kind === 198 && parent.kind === 196) { + if (node.kind === 200 && parent.kind === 198) { return getLiteralPropertyNameText(node.propertyName || node.name); } - if (node.kind === 288 || node.kind === 289) { + if (node.kind === 290 || node.kind === 291) { return getLiteralPropertyNameText(node.name); } return "" + parent.elements.indexOf(node); @@ -41660,7 +43097,7 @@ var ts; parentType = getTypeWithFacts(parentType, 524288); } var type; - if (pattern.kind === 196) { + if (pattern.kind === 198) { if (declaration.dotDotDotToken) { parentType = getReducedType(parentType); if (parentType.flags & 2 || !isValidSpreadType(parentType)) { @@ -41679,7 +43116,7 @@ var ts; else { var name = declaration.propertyName || declaration.name; var indexType = getLiteralTypeFromPropertyName(name); - var declaredType = getConstraintForLocation(getIndexedAccessType(parentType, indexType, undefined, name, undefined, undefined, 16), declaration.name); + var declaredType = getIndexedAccessType(parentType, indexType, 32, name); type = getFlowTypeOfDestructuring(declaration, declaredType); } } @@ -41693,8 +43130,8 @@ var ts; } else if (isArrayLikeType(parentType)) { var indexType = getLiteralType(index_2); - var accessFlags = hasDefaultValue(declaration) ? 8 : 0; - var declaredType = getConstraintForLocation(getIndexedAccessTypeOrUndefined(parentType, indexType, undefined, declaration.name, accessFlags | 16) || errorType, declaration.name); + var accessFlags = 32 | (hasDefaultValue(declaration) ? 16 : 0); + var declaredType = getIndexedAccessTypeOrUndefined(parentType, indexType, accessFlags, declaration.name) || errorType; type = getFlowTypeOfDestructuring(declaration, declaredType); } else { @@ -41705,11 +43142,9 @@ var ts; return type; } if (ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration))) { - return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 32768) ? - getTypeWithFacts(type, 524288) : - type; + return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 32768) ? getNonUndefinedType(type) : type; } - return widenTypeInferredFromInitializer(declaration, getUnionType([getTypeWithFacts(type, 524288), checkDeclarationInitializer(declaration)], 2)); + return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration)], 2)); } function getTypeForDeclarationFromJSDocComment(declaration) { var jsdocType = ts.getJSDocType(declaration); @@ -41720,34 +43155,36 @@ var ts; } function isNullOrUndefined(node) { var expr = ts.skipParentheses(node); - return expr.kind === 103 || expr.kind === 78 && getResolvedSymbol(expr) === undefinedSymbol; + return expr.kind === 104 || expr.kind === 79 && getResolvedSymbol(expr) === undefinedSymbol; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 199 && expr.elements.length === 0; + return expr.kind === 201 && expr.elements.length === 0; } - function addOptionality(type, optional) { - if (optional === void 0) { optional = true; } - return strictNullChecks && optional ? getOptionalType(type) : type; + function addOptionality(type, isProperty, isOptional) { + if (isProperty === void 0) { isProperty = false; } + if (isOptional === void 0) { isOptional = true; } + return strictNullChecks && isOptional ? getOptionalType(type, isProperty) : type; } function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 238) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 240) { var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression))); return indexType.flags & (262144 | 4194304) ? getExtractStringType(indexType) : stringType; } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 239) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 241) { var forOfStatement = declaration.parent.parent; return checkRightHandSideOfForOf(forOfStatement) || anyType; } if (ts.isBindingPattern(declaration.parent)) { return getTypeForBindingElement(declaration); } - var isOptional = includeOptionality && (ts.isParameter(declaration) && isJSDocOptionalParameter(declaration) - || isOptionalJSDocPropertyLikeTag(declaration) - || !ts.isBindingElement(declaration) && !ts.isVariableDeclaration(declaration) && !!declaration.questionToken); + var isProperty = ts.isPropertyDeclaration(declaration) || ts.isPropertySignature(declaration); + var isOptional = includeOptionality && (isProperty && !!declaration.questionToken || + ts.isParameter(declaration) && (!!declaration.questionToken || isJSDocOptionalParameter(declaration)) || + isOptionalJSDocPropertyLikeTag(declaration)); var declaredType = tryGetTypeFromEffectiveTypeNode(declaration); if (declaredType) { - return addOptionality(declaredType, isOptional); + return addOptionality(declaredType, isProperty, isOptional); } if ((noImplicitAny || ts.isInJSFile(declaration)) && ts.isVariableDeclaration(declaration) && !ts.isBindingPattern(declaration.name) && @@ -41761,8 +43198,8 @@ var ts; } if (ts.isParameter(declaration)) { var func = declaration.parent; - if (func.kind === 168 && !hasNonBindableDynamicName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 167); + if (func.kind === 170 && hasBindableName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 169); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -41783,7 +43220,7 @@ var ts; } var type = declaration.symbol.escapedName === "this" ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration); if (type) { - return addOptionality(type, isOptional); + return addOptionality(type, false, isOptional); } } if (ts.hasOnlyExpressionInitializer(declaration) && !!declaration.initializer) { @@ -41794,14 +43231,14 @@ var ts; } } var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration)); - return addOptionality(type, isOptional); + return addOptionality(type, isProperty, isOptional); } if (ts.isPropertyDeclaration(declaration) && !ts.hasStaticModifier(declaration) && (noImplicitAny || ts.isInJSFile(declaration))) { var constructor = findConstructorDeclaration(declaration.parent); var type = constructor ? getFlowTypeInConstructor(declaration.symbol, constructor) : ts.getEffectiveModifierFlags(declaration) & 2 ? getTypeOfPropertyInBaseClass(declaration.symbol) : undefined; - return type && addOptionality(type, isOptional); + return type && addOptionality(type, true, isOptional); } if (ts.isJsxAttribute(declaration)) { return trueType; @@ -41819,7 +43256,7 @@ var ts; links.isConstructorDeclaredProperty = !!getDeclaringConstructor(symbol) && ts.every(symbol.declarations, function (declaration) { return ts.isBinaryExpression(declaration) && isPossiblyAliasedThisProperty(declaration) && - (declaration.left.kind !== 202 || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) && + (declaration.left.kind !== 204 || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) && !getAnnotatedTypeForAssignmentDeclaration(undefined, declaration, symbol, declaration); }); } @@ -41833,13 +43270,32 @@ var ts; !declaration.initializer && (noImplicitAny || ts.isInJSFile(declaration)); } function getDeclaringConstructor(symbol) { + if (!symbol.declarations) { + return; + } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; var container = ts.getThisContainer(declaration, false); - if (container && (container.kind === 166 || isJSConstructor(container))) { + if (container && (container.kind === 168 || isJSConstructor(container))) { return container; } } + ; + } + function getFlowTypeFromCommonJSExport(symbol) { + var file = ts.getSourceFileOfNode(symbol.declarations[0]); + var accessName = ts.unescapeLeadingUnderscores(symbol.escapedName); + var areAllModuleExports = symbol.declarations.every(function (d) { return ts.isInJSFile(d) && ts.isAccessExpression(d) && ts.isModuleExportsAccessExpression(d.expression); }); + var reference = areAllModuleExports + ? ts.factory.createPropertyAccessExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("module"), ts.factory.createIdentifier("exports")), accessName) + : ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("exports"), accessName); + if (areAllModuleExports) { + ts.setParent(reference.expression.expression, reference.expression); + } + ts.setParent(reference.expression, reference); + ts.setParent(reference, file); + reference.flowNode = file.endFlowNode; + return getFlowTypeOfReference(reference, autoType, undefinedType); } function getFlowTypeInConstructor(symbol, constructor) { var accessName = ts.startsWith(symbol.escapedName, "__#") @@ -41856,7 +43312,10 @@ var ts; return everyType(flowType, isNullableType) ? undefined : convertAutoToAny(flowType); } function getFlowTypeOfProperty(reference, prop) { - var initialType = prop && (!isAutoTypedProperty(prop) || ts.getEffectiveModifierFlags(prop.valueDeclaration) & 2) && getTypeOfPropertyInBaseClass(prop) || undefinedType; + var initialType = (prop === null || prop === void 0 ? void 0 : prop.valueDeclaration) + && (!isAutoTypedProperty(prop) || ts.getEffectiveModifierFlags(prop.valueDeclaration) & 2) + && getTypeOfPropertyInBaseClass(prop) + || undefinedType; return getFlowTypeOfReference(reference, autoType, initialType); } function getWidenedTypeForAssignmentDeclaration(symbol, resolvedSymbol) { @@ -41866,7 +43325,7 @@ var ts; if (tag && tag.typeExpression) { return getTypeFromTypeNode(tag.typeExpression); } - var containerObjectType = getJSContainerObjectType(symbol.valueDeclaration, symbol, container); + var containerObjectType = symbol.valueDeclaration && getJSContainerObjectType(symbol.valueDeclaration, symbol, container); return containerObjectType || getWidenedLiteralType(checkExpressionCached(container)); } var type; @@ -41876,40 +43335,42 @@ var ts; type = getFlowTypeInConstructor(symbol, getDeclaringConstructor(symbol)); } if (!type) { - var jsdocType = void 0; var types = void 0; - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration : - ts.isAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : - undefined; - if (!expression) { - continue; - } - var kind = ts.isAccessExpression(expression) - ? ts.getAssignmentDeclarationPropertyAccessKind(expression) - : ts.getAssignmentDeclarationKind(expression); - if (kind === 4 || ts.isBinaryExpression(expression) && isPossiblyAliasedThisProperty(expression, kind)) { - if (isDeclarationInConstructor(expression)) { - definedInConstructor = true; + if (symbol.declarations) { + var jsdocType = void 0; + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration : + ts.isAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : + undefined; + if (!expression) { + continue; } - else { - definedInMethod = true; + var kind = ts.isAccessExpression(expression) + ? ts.getAssignmentDeclarationPropertyAccessKind(expression) + : ts.getAssignmentDeclarationKind(expression); + if (kind === 4 || ts.isBinaryExpression(expression) && isPossiblyAliasedThisProperty(expression, kind)) { + if (isDeclarationInConstructor(expression)) { + definedInConstructor = true; + } + else { + definedInMethod = true; + } + } + if (!ts.isCallExpression(expression)) { + jsdocType = getAnnotatedTypeForAssignmentDeclaration(jsdocType, expression, symbol, declaration); + } + if (!jsdocType) { + (types || (types = [])).push((ts.isBinaryExpression(expression) || ts.isCallExpression(expression)) ? getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) : neverType); } } - if (!ts.isCallExpression(expression)) { - jsdocType = getAnnotatedTypeForAssignmentDeclaration(jsdocType, expression, symbol, declaration); - } - if (!jsdocType) { - (types || (types = [])).push((ts.isBinaryExpression(expression) || ts.isCallExpression(expression)) ? getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) : neverType); - } + type = jsdocType; } - type = jsdocType; if (!type) { if (!ts.length(types)) { return errorType; } - var constructorTypes = definedInConstructor ? getConstructorDefinedThisAssignmentTypes(types, symbol.declarations) : undefined; + var constructorTypes = definedInConstructor && symbol.declarations ? getConstructorDefinedThisAssignmentTypes(types, symbol.declarations) : undefined; if (definedInMethod) { var propType = getTypeOfPropertyInBaseClass(symbol); if (propType) { @@ -41921,8 +43382,8 @@ var ts; type = getUnionType(sourceTypes, 2); } } - var widened = getWidenedType(addOptionality(type, definedInMethod && !definedInConstructor)); - if (filterType(widened, function (t) { return !!(t.flags & ~98304); }) === neverType) { + var widened = getWidenedType(addOptionality(type, false, definedInMethod && !definedInConstructor)); + if (symbol.valueDeclaration && filterType(widened, function (t) { return !!(t.flags & ~98304); }) === neverType) { reportImplicitAny(symbol.valueDeclaration, anyType); return anyType; } @@ -41946,10 +43407,11 @@ var ts; mergeSymbolTable(exports, s.exports); } var type = createAnonymousType(symbol, exports, ts.emptyArray, ts.emptyArray, undefined, undefined); - type.objectFlags |= 16384; + type.objectFlags |= 8192; return type; } function getAnnotatedTypeForAssignmentDeclaration(declaredType, expression, symbol, declaration) { + var _a; var typeNode = ts.getEffectiveTypeAnnotationNode(expression.parent); if (typeNode) { var type = getWidenedType(getTypeFromTypeNode(typeNode)); @@ -41960,10 +43422,13 @@ var ts; errorNextVariableOrPropertyDeclarationMustHaveSameType(undefined, declaredType, declaration, type); } } - if (symbol.parent) { + if ((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.valueDeclaration) { var typeNode_2 = ts.getEffectiveTypeAnnotationNode(symbol.parent.valueDeclaration); if (typeNode_2) { - return getTypeOfPropertyOfType(getTypeFromTypeNode(typeNode_2), symbol.escapedName); + var annotationSymbol = getPropertyOfType(getTypeFromTypeNode(typeNode_2), symbol.escapedName); + if (annotationSymbol) { + return getNonMissingTypeOfSymbol(annotationSymbol); + } } } return declaredType; @@ -42013,7 +43478,7 @@ var ts; var exportedMember = members_4.get(name); if (exportedMember && exportedMember !== s) { if (s.flags & 111551 && exportedMember.flags & 111551) { - if (ts.getSourceFileOfNode(s.valueDeclaration) !== ts.getSourceFileOfNode(exportedMember.valueDeclaration)) { + if (s.valueDeclaration && exportedMember.valueDeclaration && ts.getSourceFileOfNode(s.valueDeclaration) !== ts.getSourceFileOfNode(exportedMember.valueDeclaration)) { var unescapedName = ts.unescapeLeadingUnderscores(s.escapedName); var exportedMemberName = ((_a = ts.tryCast(exportedMember.valueDeclaration, ts.isNamedDeclaration)) === null || _a === void 0 ? void 0 : _a.name) || exportedMember.valueDeclaration; ts.addRelatedInfo(error(s.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0, unescapedName), ts.createDiagnosticForNode(exportedMemberName, ts.Diagnostics._0_was_also_declared_here, unescapedName)); @@ -42034,9 +43499,9 @@ var ts; } }); var result = createAnonymousType(initialSize !== members_4.size ? undefined : exportedType.symbol, members_4, exportedType.callSignatures, exportedType.constructSignatures, exportedType.stringIndexInfo, exportedType.numberIndexInfo); - result.objectFlags |= (ts.getObjectFlags(type) & 16384); + result.objectFlags |= (ts.getObjectFlags(type) & 8192); if (result.symbol && result.symbol.flags & 32 && type === getDeclaredTypeOfClassOrInterface(result.symbol)) { - result.objectFlags |= 1073741824; + result.objectFlags |= 16777216; } return result; } @@ -42048,14 +43513,14 @@ var ts; } function containsSameNamedThisProperty(thisProperty, expression) { return ts.isPropertyAccessExpression(thisProperty) - && thisProperty.expression.kind === 107 + && thisProperty.expression.kind === 108 && ts.forEachChildRecursively(expression, function (n) { return isMatchingReference(thisProperty, n); }); } function isDeclarationInConstructor(expression) { var thisContainer = ts.getThisContainer(expression, false); - return thisContainer.kind === 166 || - thisContainer.kind === 251 || - (thisContainer.kind === 208 && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + return thisContainer.kind === 168 || + thisContainer.kind === 253 || + (thisContainer.kind === 210 && !ts.isPrototypePropertyAssignment(thisContainer.parent)); } function getConstructorDefinedThisAssignmentTypes(types, declarations) { ts.Debug.assert(types.length === declarations.length); @@ -42082,7 +43547,7 @@ var ts; function getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) { var members = ts.createSymbolTable(); var stringIndexInfo; - var objectFlags = 128 | 1048576; + var objectFlags = 128 | 262144; ts.forEach(pattern.elements, function (e) { var name = e.propertyName || e.name; if (e.dotDotDotToken) { @@ -42105,14 +43570,14 @@ var ts; result.objectFlags |= objectFlags; if (includePatternInType) { result.pattern = pattern; - result.objectFlags |= 1048576; + result.objectFlags |= 262144; } return result; } function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - var restElement = lastElement && lastElement.kind === 198 && lastElement.dotDotDotToken ? lastElement : undefined; + var restElement = lastElement && lastElement.kind === 200 && lastElement.dotDotDotToken ? lastElement : undefined; if (elements.length === 0 || elements.length === 1 && restElement) { return languageVersion >= 2 ? createIterableType(anyType) : anyArrayType; } @@ -42123,22 +43588,30 @@ var ts; if (includePatternInType) { result = cloneTypeReference(result); result.pattern = pattern; - result.objectFlags |= 1048576; + result.objectFlags |= 262144; } return result; } function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 196 + return pattern.kind === 198 ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) { return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, true), declaration, reportErrors); } + function isGlobalSymbolConstructor(node) { + var symbol = getSymbolOfNode(node); + var globalSymbol = getGlobalESSymbolConstructorTypeSymbol(false); + return globalSymbol && symbol && symbol === globalSymbol; + } function widenTypeForVariableLikeDeclaration(type, declaration, reportErrors) { if (type) { + if (type.flags & 4096 && isGlobalSymbolConstructor(declaration.parent)) { + type = getESSymbolLikeTypeForNode(declaration); + } if (reportErrors) { reportErrorsFromWidening(declaration, type); } @@ -42157,7 +43630,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 160 ? root.parent : root; + var memberDeclaration = root.kind === 162 ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(declaration) { @@ -42183,18 +43656,30 @@ var ts; if (symbol === requireSymbol) { return anyType; } - if (symbol.flags & 134217728) { + if (symbol.flags & 134217728 && symbol.valueDeclaration) { var fileSymbol = getSymbolOfNode(ts.getSourceFileOfNode(symbol.valueDeclaration)); + var result = createSymbol(fileSymbol.flags, "exports"); + result.declarations = fileSymbol.declarations ? fileSymbol.declarations.slice() : []; + result.parent = symbol; + result.target = fileSymbol; + if (fileSymbol.valueDeclaration) + result.valueDeclaration = fileSymbol.valueDeclaration; + if (fileSymbol.members) + result.members = new ts.Map(fileSymbol.members); + if (fileSymbol.exports) + result.exports = new ts.Map(fileSymbol.exports); var members = ts.createSymbolTable(); - members.set("exports", fileSymbol); + members.set("exports", result); return createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, undefined, undefined); } + ts.Debug.assertIsDefined(symbol.valueDeclaration); var declaration = symbol.valueDeclaration; if (ts.isCatchClauseVariableDeclarationOrBindingElement(declaration)) { - var decl = declaration; - if (!decl.type) - return anyType; - var type_1 = getTypeOfNode(decl.type); + var typeNode = ts.getEffectiveTypeAnnotationNode(declaration); + if (typeNode === undefined) { + return useUnknownInCatchVariables ? unknownType : anyType; + } + var type_1 = getTypeOfNode(typeNode); return isTypeAny(type_1) || type_1 === unknownType ? type_1 : errorType; } if (ts.isSourceFile(declaration) && ts.isJsonSourceFile(declaration)) { @@ -42210,7 +43695,7 @@ var ts; return reportCircularityError(symbol); } var type; - if (declaration.kind === 266) { + if (declaration.kind === 268) { type = widenTypeForVariableLikeDeclaration(checkExpressionCached(declaration.expression), declaration); } else if (ts.isBinaryExpression(declaration) || @@ -42262,7 +43747,7 @@ var ts; type = getTypeOfEnumMember(symbol); } else if (ts.isAccessor(declaration)) { - type = resolveTypeOfAccessors(symbol); + type = resolveTypeOfAccessors(symbol) || ts.Debug.fail("Non-write accessor resolution must always produce a type"); } else { return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.formatSyntaxKind(declaration.kind) + " for " + ts.Debug.formatSymbol(symbol)); @@ -42277,7 +43762,7 @@ var ts; } function getAnnotatedAccessorTypeNode(accessor) { if (accessor) { - if (accessor.kind === 167) { + if (accessor.kind === 169) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation; } @@ -42301,59 +43786,72 @@ var ts; } function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); - return links.type || (links.type = getTypeOfAccessorsWorker(symbol)); + return links.type || (links.type = getTypeOfAccessorsWorker(symbol) || ts.Debug.fail("Read type of accessor must always produce a type")); } - function getTypeOfAccessorsWorker(symbol) { + function getTypeOfSetAccessor(symbol) { + var links = getSymbolLinks(symbol); + return links.writeType || (links.writeType = getTypeOfAccessorsWorker(symbol, true)); + } + function getTypeOfAccessorsWorker(symbol, writing) { + if (writing === void 0) { writing = false; } if (!pushTypeResolution(symbol, 0)) { return errorType; } - var type = resolveTypeOfAccessors(symbol); + var type = resolveTypeOfAccessors(symbol, writing); if (!popTypeResolution()) { type = anyType; if (noImplicitAny) { - var getter = ts.getDeclarationOfKind(symbol, 167); + var getter = ts.getDeclarationOfKind(symbol, 169); error(getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } return type; } - function resolveTypeOfAccessors(symbol) { - var getter = ts.getDeclarationOfKind(symbol, 167); - var setter = ts.getDeclarationOfKind(symbol, 168); + function resolveTypeOfAccessors(symbol, writing) { + if (writing === void 0) { writing = false; } + var getter = ts.getDeclarationOfKind(symbol, 169); + var setter = ts.getDeclarationOfKind(symbol, 170); + var setterType = getAnnotatedAccessorType(setter); + if (writing && setterType) { + return instantiateTypeIfNeeded(setterType, symbol); + } if (getter && ts.isInJSFile(getter)) { var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { - return jsDocType; + return instantiateTypeIfNeeded(jsDocType, symbol); } } - var getterReturnType = getAnnotatedAccessorType(getter); - if (getterReturnType) { - return getterReturnType; + var getterType = getAnnotatedAccessorType(getter); + if (getterType) { + return instantiateTypeIfNeeded(getterType, symbol); } - else { - var setterParameterType = getAnnotatedAccessorType(setter); - if (setterParameterType) { - return setterParameterType; + if (setterType) { + return setterType; + } + if (getter && getter.body) { + var returnTypeFromBody = getReturnTypeFromBody(getter); + return instantiateTypeIfNeeded(returnTypeFromBody, symbol); + } + if (setter) { + if (!isPrivateWithinAmbient(setter)) { + errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol)); } - else { - if (getter && getter.body) { - return getReturnTypeFromBody(getter); - } - else { - if (setter) { - if (!isPrivateWithinAmbient(setter)) { - errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol)); - } - } - else { - ts.Debug.assert(!!getter, "there must exist a getter as we are current checking either setter or getter in this function"); - if (!isPrivateWithinAmbient(getter)) { - errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol)); - } - } - return anyType; - } + return anyType; + } + else if (getter) { + ts.Debug.assert(!!getter, "there must exist a getter as we are current checking either setter or getter in this function"); + if (!isPrivateWithinAmbient(getter)) { + errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol)); } + return anyType; + } + return undefined; + function instantiateTypeIfNeeded(type, symbol) { + if (ts.getCheckFlags(symbol) & 1) { + var links = getSymbolLinks(symbol); + return instantiateType(type, links.mapper); + } + return type; } } function getBaseTypeVariableOfClass(symbol) { @@ -42382,9 +43880,9 @@ var ts; if (symbol.flags & 1536 && ts.isShorthandAmbientModuleSymbol(symbol)) { return anyType; } - else if (declaration && (declaration.kind === 216 || + else if (declaration && (declaration.kind === 218 || ts.isAccessExpression(declaration) && - declaration.parent.kind === 216)) { + declaration.parent.kind === 218)) { return getWidenedTypeForAssignmentDeclaration(symbol); } else if (symbol.flags & 512 && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { @@ -42418,9 +43916,11 @@ var ts; var links = getSymbolLinks(symbol); if (!links.type) { var targetSymbol = resolveAlias(symbol); - links.type = targetSymbol.flags & 111551 - ? getTypeOfSymbol(targetSymbol) - : errorType; + var exportSymbol = symbol.declarations && getTargetOfAliasDeclaration(getDeclarationOfAliasSymbol(symbol), true); + links.type = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.declarations) && isDuplicatedCommonJSExport(exportSymbol.declarations) && symbol.declarations.length ? getFlowTypeFromCommonJSExport(exportSymbol) + : isDuplicatedCommonJSExport(symbol.declarations) ? autoType + : targetSymbol.flags & 111551 ? getTypeOfSymbol(targetSymbol) + : errorType; } return links.type; } @@ -42444,7 +43944,7 @@ var ts; error(symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol)); return errorType; } - if (noImplicitAny && (declaration.kind !== 160 || declaration.initializer)) { + if (noImplicitAny && (declaration.kind !== 162 || 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)); } return anyType; @@ -42458,6 +43958,15 @@ var ts; } return links.type; } + function getSetAccessorTypeOfSymbol(symbol) { + if (symbol.flags & 98304) { + var type = getTypeOfSetAccessor(symbol); + if (type) { + return type; + } + } + return getTypeOfSymbol(symbol); + } function getTypeOfSymbol(symbol) { var checkFlags = ts.getCheckFlags(symbol); if (checkFlags & 65536) { @@ -42489,6 +43998,9 @@ var ts; } return errorType; } + function getNonMissingTypeOfSymbol(symbol) { + return removeMissingType(getTypeOfSymbol(symbol), !!(symbol.flags & 16777216)); + } function isReferenceToType(type, target) { return type !== undefined && target !== undefined @@ -42534,63 +44046,69 @@ var ts; return undefined; } switch (node.kind) { - case 232: - case 252: - case 221: - case 253: - case 169: - case 170: - case 164: - case 174: - case 175: - case 308: - case 251: - case 165: - case 208: - case 209: case 254: - case 330: - case 331: - case 325: - case 324: - case 190: - case 184: + case 223: + case 255: + case 171: + case 172: + case 166: + case 176: + case 177: + case 311: + case 253: + case 167: + case 210: + case 211: + case 256: + case 338: + case 339: + case 333: + case 332: + case 192: + case 186: { var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 190) { + if (node.kind === 192) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 184) { + else if (node.kind === 186) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } - else if (node.kind === 232 && !ts.isInJSFile(node)) { - break; - } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 252 || node.kind === 221 || node.kind === 253 || isJSConstructor(node)) && + (node.kind === 254 || node.kind === 223 || node.kind === 255 || isJSConstructor(node)) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; - case 326: + } + case 334: var paramSymbol = ts.getParameterSymbolFromJSDoc(node); if (paramSymbol) { node = paramSymbol.valueDeclaration; } break; + case 314: { + var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); + return node.tags + ? appendTypeParameters(outerTypeParameters, ts.flatMap(node.tags, function (t) { return ts.isJSDocTemplateTag(t) ? t.typeParameters : undefined; })) + : outerTypeParameters; + } } } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 253); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 255); ts.Debug.assert(!!declaration, "Class was missing valueDeclaration -OR- non-class had no interface declarations"); return getOuterTypeParameters(declaration); } function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { + if (!symbol.declarations) { + return; + } var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 253 || - node.kind === 252 || - node.kind === 221 || + if (node.kind === 255 || + node.kind === 254 || + node.kind === 223 || isJSConstructor(node) || ts.isTypeAlias(node)) { var declaration = node; @@ -42670,7 +44188,9 @@ var ts; ctorReturn = getReturnTypeOfSignature(ctorSig[0]); } } - ts.addRelatedInfo(err, ts.createDiagnosticForNode(baseConstructorType.symbol.declarations[0], ts.Diagnostics.Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1, symbolToString(baseConstructorType.symbol), typeToString(ctorReturn))); + if (baseConstructorType.symbol.declarations) { + ts.addRelatedInfo(err, ts.createDiagnosticForNode(baseConstructorType.symbol.declarations[0], ts.Diagnostics.Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1, symbolToString(baseConstructorType.symbol), typeToString(ctorReturn))); + } } return type.resolvedBaseConstructorType = errorType; } @@ -42680,20 +44200,22 @@ var ts; } function getImplementsTypes(type) { var resolvedImplementsTypes = ts.emptyArray; - for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - var implementsTypeNodes = ts.getEffectiveImplementsTypeNodes(declaration); - if (!implementsTypeNodes) - continue; - for (var _b = 0, implementsTypeNodes_1 = implementsTypeNodes; _b < implementsTypeNodes_1.length; _b++) { - var node = implementsTypeNodes_1[_b]; - var implementsType = getTypeFromTypeNode(node); - if (implementsType !== errorType) { - if (resolvedImplementsTypes === ts.emptyArray) { - resolvedImplementsTypes = [implementsType]; - } - else { - resolvedImplementsTypes.push(implementsType); + if (type.symbol.declarations) { + for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + var implementsTypeNodes = ts.getEffectiveImplementsTypeNodes(declaration); + if (!implementsTypeNodes) + continue; + for (var _b = 0, implementsTypeNodes_1 = implementsTypeNodes; _b < implementsTypeNodes_1.length; _b++) { + var node = implementsTypeNodes_1[_b]; + var implementsType = getTypeFromTypeNode(node); + if (implementsType !== errorType) { + if (resolvedImplementsTypes === ts.emptyArray) { + resolvedImplementsTypes = [implementsType]; + } + else { + resolvedImplementsTypes.push(implementsType); + } } } } @@ -42720,10 +44242,10 @@ var ts; else { ts.Debug.fail("type must be class or interface"); } - if (!popTypeResolution()) { + if (!popTypeResolution() && type.symbol.declarations) { for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 252 || declaration.kind === 253) { + if (declaration.kind === 254 || declaration.kind === 255) { reportCircularBaseType(declaration, type); } } @@ -42801,38 +44323,43 @@ var ts; } function resolveBaseTypesOfInterface(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray; - for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 253 && ts.getInterfaceBaseTypeNodes(declaration)) { - for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { - var node = _c[_b]; - var baseType = getReducedType(getTypeFromTypeNode(node)); - if (baseType !== errorType) { - if (isValidBaseType(baseType)) { - if (type !== baseType && !hasBaseType(baseType, type)) { - if (type.resolvedBaseTypes === ts.emptyArray) { - type.resolvedBaseTypes = [baseType]; + if (type.symbol.declarations) { + for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 255 && ts.getInterfaceBaseTypeNodes(declaration)) { + for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { + var node = _c[_b]; + var baseType = getReducedType(getTypeFromTypeNode(node)); + if (baseType !== errorType) { + if (isValidBaseType(baseType)) { + if (type !== baseType && !hasBaseType(baseType, type)) { + if (type.resolvedBaseTypes === ts.emptyArray) { + type.resolvedBaseTypes = [baseType]; + } + else { + type.resolvedBaseTypes.push(baseType); + } } else { - type.resolvedBaseTypes.push(baseType); + reportCircularBaseType(declaration, type); } } else { - reportCircularBaseType(declaration, type); + error(node, ts.Diagnostics.An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_members); } } - else { - error(node, ts.Diagnostics.An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_members); - } } } } } } function isThislessInterface(symbol) { + if (!symbol.declarations) { + return true; + } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 253) { + if (declaration.kind === 255) { if (declaration.flags & 128) { return false; } @@ -42857,7 +44384,7 @@ var ts; var originalLinks = links; if (!links.declaredType) { var kind = symbol.flags & 32 ? 1 : 2; - var merged = mergeJSSymbols(symbol, getAssignedClassSymbol(symbol.valueDeclaration)); + var merged = mergeJSSymbols(symbol, symbol.valueDeclaration && getAssignedClassSymbol(symbol.valueDeclaration)); if (merged) { symbol = links = merged; } @@ -42881,12 +44408,13 @@ var ts; return links.declaredType; } function getDeclaredTypeOfTypeAlias(symbol) { + var _a; var links = getSymbolLinks(symbol); if (!links.declaredType) { if (!pushTypeResolution(symbol, 2)) { return errorType; } - var declaration = ts.Debug.checkDefined(ts.find(symbol.declarations, ts.isTypeAlias), "Type alias symbol with no valid declaration found"); + 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"); var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type; var type = typeNode ? getTypeFromTypeNode(typeNode) : errorType; if (popTypeResolution()) { @@ -42899,7 +44427,12 @@ var ts; } else { type = errorType; - error(ts.isNamedDeclaration(declaration) ? declaration.name : declaration || declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); + if (declaration.kind === 333) { + 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)); + } } links.declaredType = type; } @@ -42909,7 +44442,7 @@ var ts; if (ts.isStringLiteralLike(expr)) { return true; } - else if (expr.kind === 216) { + else if (expr.kind === 218) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -42924,12 +44457,12 @@ var ts; case 8: case 14: return true; - case 214: + case 216: return expr.operator === 40 && expr.operand.kind === 8; - case 78: + case 79: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 216: + case 218: return isStringConcatExpression(expr); default: return false; @@ -42941,16 +44474,18 @@ var ts; return links.enumKind; } var hasNonLiteralMember = false; - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 255) { - 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; - } - if (!isLiteralEnumMember(member)) { - hasNonLiteralMember = true; + if (symbol.declarations) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 257) { + 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; + } + if (!isLiteralEnumMember(member)) { + hasNonLiteralMember = true; + } } } } @@ -42968,15 +44503,17 @@ var ts; if (getEnumKind(symbol) === 1) { enumCount++; var memberTypeList = []; - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 255) { - for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { - var member = _c[_b]; - var value = getEnumMemberValue(member); - var memberType = getFreshTypeOfLiteralType(getLiteralType(value !== undefined ? value : 0, enumCount, getSymbolOfNode(member))); - getSymbolLinks(getSymbolOfNode(member)).declaredType = memberType; - memberTypeList.push(getRegularTypeOfLiteralType(memberType)); + if (symbol.declarations) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 257) { + for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { + var member = _c[_b]; + var value = getEnumMemberValue(member); + var memberType = getFreshTypeOfLiteralType(getLiteralType(value !== undefined ? value : 0, enumCount, getSymbolOfNode(member))); + getSymbolLinks(getSymbolOfNode(member)).declaredType = memberType; + memberTypeList.push(getRegularTypeOfLiteralType(memberType)); + } } } } @@ -43037,22 +44574,22 @@ var ts; } function isThislessType(node) { switch (node.kind) { - case 128: - case 152: - case 147: - case 144: - case 155: - case 131: + case 129: + case 153: case 148: case 145: - case 113: - case 150: - case 141: - case 191: + case 156: + case 132: + case 149: + case 146: + case 114: + case 151: + case 142: + case 193: return true; - case 178: + case 180: return isThislessType(node.elementType); - case 173: + case 175: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -43068,7 +44605,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 166 || (!!returnType && isThislessType(returnType))) && + return (node.kind === 168 || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -43077,14 +44614,14 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 163: - case 162: - return isThislessVariableLikeDeclaration(declaration); case 165: case 164: - case 166: + return isThislessVariableLikeDeclaration(declaration); case 167: + case 166: case 168: + case 169: + case 170: return isThislessFunctionLikeDeclaration(declaration); } } @@ -43108,7 +44645,7 @@ var ts; } } function isStaticPrivateIdentifierProperty(s) { - return !!s.valueDeclaration && ts.isPrivateIdentifierPropertyDeclaration(s.valueDeclaration) && ts.hasSyntacticModifier(s.valueDeclaration, 32); + return !!s.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(s.valueDeclaration) && ts.hasSyntacticModifier(s.valueDeclaration, 32); } function resolveDeclaredMembers(type) { if (!type.declaredProperties) { @@ -43144,8 +44681,8 @@ var ts; var name = ts.getNameOfDeclaration(node); return !!name && isLateBindableName(name); } - function hasNonBindableDynamicName(node) { - return ts.hasDynamicName(node) && !hasLateBindableName(node); + function hasBindableName(node) { + return !ts.hasDynamicName(node) || hasLateBindableName(node); } function isNonBindableDynamicName(node) { return ts.isDynamicName(node) && !isLateBindableName(node); @@ -43352,19 +44889,22 @@ var ts; sig.resolvedMinArgumentCount = undefined; sig.target = undefined; sig.mapper = undefined; - sig.unionSignatures = undefined; + sig.compositeSignatures = undefined; + sig.compositeKind = undefined; return sig; } function cloneSignature(sig) { var result = createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, undefined, undefined, sig.minArgumentCount, sig.flags & 39); result.target = sig.target; result.mapper = sig.mapper; - result.unionSignatures = sig.unionSignatures; + result.compositeSignatures = sig.compositeSignatures; + result.compositeKind = sig.compositeKind; return result; } function createUnionSignature(signature, unionSignatures) { var result = cloneSignature(signature); - result.unionSignatures = unionSignatures; + result.compositeSignatures = unionSignatures; + result.compositeKind = 1048576; result.target = undefined; result.mapper = undefined; return result; @@ -43508,7 +45048,7 @@ var ts; if (signatures !== masterList) { var signature_1 = signatures[0]; ts.Debug.assert(!!signature_1, "getUnionSignatures bails early on empty signature lists and should not have empty lists on second pass"); - results = signature_1.typeParameters && ts.some(results, function (s) { return !!s.typeParameters && !compareTypeParametersIdentical(signature_1.typeParameters, s.typeParameters); }) ? undefined : ts.map(results, function (sig) { return combineSignaturesOfUnionMembers(sig, signature_1); }); + results = !!signature_1.typeParameters && ts.some(results, function (s) { return !!s.typeParameters && !compareTypeParametersIdentical(signature_1.typeParameters, s.typeParameters); }) ? undefined : ts.map(results, function (sig) { return combineSignaturesOfUnionMembers(sig, signature_1); }); if (!results) { return "break"; } @@ -43525,9 +45065,12 @@ var ts; return result || ts.emptyArray; } function compareTypeParametersIdentical(sourceParams, targetParams) { - if (sourceParams.length !== targetParams.length) { + if (ts.length(sourceParams) !== ts.length(targetParams)) { return false; } + if (!sourceParams || !targetParams) { + return true; + } var mapper = createTypeMapper(targetParams, sourceParams); for (var i = 0; i < sourceParams.length; i++) { var source = sourceParams[i]; @@ -43598,9 +45141,10 @@ var ts; var thisParam = combineUnionThisParam(left.thisParameter, right.thisParameter, paramMapper); var minArgCount = Math.max(left.minArgumentCount, right.minArgumentCount); var result = createSignature(declaration, typeParams, thisParam, params, undefined, undefined, minArgCount, (left.flags | right.flags) & 39); - result.unionSignatures = ts.concatenate(left.unionSignatures || [left], [right]); + result.compositeKind = 1048576; + result.compositeSignatures = ts.concatenate(left.compositeKind !== 2097152 && left.compositeSignatures || [left], [right]); if (paramMapper) { - result.mapper = left.mapper && left.unionSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; + result.mapper = left.compositeKind !== 2097152 && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; } return result; } @@ -43720,6 +45264,7 @@ var ts; else { var members = emptySymbols; var stringIndexInfo = void 0; + var numberIndexInfo = void 0; if (symbol.exports) { members = getExportsOfSymbol(symbol); if (symbol === globalThisSymbol) { @@ -43732,20 +45277,31 @@ var ts; members = varsOnly_1; } } + var baseConstructorIndexInfo = void 0; setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, undefined, undefined); if (symbol.flags & 32) { var classType = getDeclaredTypeOfClassOrInterface(symbol); var baseConstructorType = getBaseConstructorTypeOfClass(classType); if (baseConstructorType.flags & (524288 | 2097152 | 8650752)) { - members = ts.createSymbolTable(getNamedMembers(members)); + members = ts.createSymbolTable(getNamedOrIndexSignatureMembers(members)); addInheritedMembers(members, getPropertiesOfType(baseConstructorType)); } else if (baseConstructorType === anyType) { - stringIndexInfo = createIndexInfo(anyType, false); + baseConstructorIndexInfo = createIndexInfo(anyType, false); + } + } + var indexSymbol = getIndexSymbolFromSymbolTable(members); + if (indexSymbol) { + stringIndexInfo = getIndexInfoOfIndexSymbol(indexSymbol, 0); + numberIndexInfo = getIndexInfoOfIndexSymbol(indexSymbol, 1); + } + else { + stringIndexInfo = baseConstructorIndexInfo; + if (symbol.flags & 384 && (getDeclaredTypeOfSymbol(symbol).flags & 32 || + ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296); }))) { + numberIndexInfo = enumNumberIndexInfo; } } - var numberIndexInfo = symbol.flags & 384 && (getDeclaredTypeOfSymbol(symbol).flags & 32 || - ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296); })) ? enumNumberIndexInfo : undefined; setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); if (symbol.flags & (16 | 8192)) { type.callSignatures = getSignaturesOfSymbol(symbol); @@ -43765,6 +45321,15 @@ var ts; } } } + function replaceIndexedAccess(instantiable, type, replacement) { + return instantiateType(instantiable, createTypeMapper([type.indexType, type.objectType], [getLiteralType(0), createTupleType([replacement])])); + } + function getIndexInfoOfIndexSymbol(indexSymbol, indexKind) { + var declaration = getIndexDeclarationOfIndexSymbol(indexSymbol, indexKind); + if (!declaration) + return undefined; + return createIndexInfo(declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasEffectiveModifier(declaration, 64), declaration); + } function resolveReverseMappedTypeMembers(type) { var indexInfo = getIndexInfoOfType(type.source, 0); var modifiers = getMappedTypeModifiers(type.mappedType); @@ -43779,8 +45344,18 @@ var ts; inferredProp.declarations = prop.declarations; inferredProp.nameType = getSymbolLinks(prop).nameType; inferredProp.propertyType = getTypeOfSymbol(prop); - inferredProp.mappedType = type.mappedType; - inferredProp.constraintType = type.constraintType; + if (type.constraintType.type.flags & 8388608 + && type.constraintType.type.objectType.flags & 262144 + && type.constraintType.type.indexType.flags & 262144) { + var newTypeParam = type.constraintType.type.objectType; + var newMappedType = replaceIndexedAccess(type.mappedType, type.constraintType.type, newTypeParam); + inferredProp.mappedType = newMappedType; + inferredProp.constraintType = getIndexType(newTypeParam); + } + else { + inferredProp.mappedType = type.mappedType; + inferredProp.constraintType = type.constraintType; + } members.set(prop.escapedName, inferredProp); } setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, undefined); @@ -43891,7 +45466,7 @@ var ts; var templateType = getTemplateTypeFromMappedType(mappedType.target || mappedType); var mapper = appendTypeMapping(mappedType.mapper, getTypeParameterFromMappedType(mappedType), symbol.keyType); var propType = instantiateType(templateType, mapper); - var type = strictNullChecks && symbol.flags & 16777216 && !maybeTypeOfKind(propType, 32768 | 16384) ? getOptionalType(propType) : + var type = strictNullChecks && symbol.flags & 16777216 && !maybeTypeOfKind(propType, 32768 | 16384) ? getOptionalType(propType, true) : symbol.checkFlags & 524288 ? getTypeWithFacts(propType, 524288) : propType; if (!popTypeResolution()) { @@ -43918,7 +45493,7 @@ var ts; function getTemplateTypeFromMappedType(type) { return type.templateType || (type.templateType = type.declaration.type ? - instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), !!(getMappedTypeModifiers(type) & 4)), type.mapper) : + instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), true, !!(getMappedTypeModifiers(type) & 4)), type.mapper) : errorType); } function getConstraintDeclarationForMappedType(type) { @@ -43926,8 +45501,8 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); - return constraintDeclaration.kind === 188 && - constraintDeclaration.operator === 138; + return constraintDeclaration.kind === 190 && + constraintDeclaration.operator === 139; } function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { @@ -43972,7 +45547,7 @@ var ts; else if (type.objectFlags & 3) { resolveClassOrInterfaceMembers(type); } - else if (type.objectFlags & 2048) { + else if (type.objectFlags & 1024) { resolveReverseMappedTypeMembers(type); } else if (type.objectFlags & 16) { @@ -44081,14 +45656,14 @@ var ts; function getConstraintFromIndexedAccess(type) { var indexConstraint = getSimplifiedTypeOrConstraint(type.indexType); if (indexConstraint && indexConstraint !== type.indexType) { - var indexedAccess = getIndexedAccessTypeOrUndefined(type.objectType, indexConstraint, type.noUncheckedIndexedAccessCandidate); + var indexedAccess = getIndexedAccessTypeOrUndefined(type.objectType, indexConstraint, type.accessFlags); if (indexedAccess) { return indexedAccess; } } var objectConstraint = getSimplifiedTypeOrConstraint(type.objectType); if (objectConstraint && objectConstraint !== type.objectType) { - return getIndexedAccessTypeOrUndefined(objectConstraint, type.indexType, type.noUncheckedIndexedAccessCandidate); + return getIndexedAccessTypeOrUndefined(objectConstraint, type.indexType, type.accessFlags); } return undefined; } @@ -44213,12 +45788,22 @@ var ts; if (t.flags & 3145728) { var types = t.types; var baseTypes = []; + var different = false; for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { var type_3 = types_8[_i]; var baseType = getBaseConstraint(type_3); if (baseType) { + if (baseType !== type_3) { + different = true; + } baseTypes.push(baseType); } + else { + different = true; + } + } + if (!different) { + return t; } return t.flags & 1048576 && baseTypes.length === types.length ? getUnionType(baseTypes) : t.flags & 2097152 && baseTypes.length ? getIntersectionType(baseTypes) : @@ -44239,7 +45824,7 @@ var ts; if (t.flags & 8388608) { var baseObjectType = getBaseConstraint(t.objectType); var baseIndexType = getBaseConstraint(t.indexType); - var baseIndexedAccess = baseObjectType && baseIndexType && getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, t.noUncheckedIndexedAccessCandidate); + var baseIndexedAccess = baseObjectType && baseIndexType && getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, t.accessFlags); return baseIndexedAccess && getBaseConstraint(baseIndexedAccess); } if (t.flags & 16777216) { @@ -44316,6 +45901,7 @@ var ts; return getReducedType(getApparentType(getReducedType(type))); } function createUnionOrIntersectionProperty(containingType, name, skipObjectFunctionPropertyAugment) { + var _a, _b; var singleProp; var propSet; var indexTypes; @@ -44323,8 +45909,9 @@ var ts; var optionalFlag = isUnion ? 0 : 16777216; var syntheticFlag = 4; var checkFlags = 0; - for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { - var current = _a[_i]; + var mergedInstantiations = false; + for (var _i = 0, _c = containingType.types; _i < _c.length; _i++) { + var current = _c[_i]; var type = getApparentType(current); if (!(type === errorType || type.flags & 131072)) { var prop = getPropertyOfType(type, name, skipObjectFunctionPropertyAugment); @@ -44340,13 +45927,19 @@ var ts; singleProp = prop; } else if (prop !== singleProp) { - if (!propSet) { - propSet = new ts.Map(); - propSet.set(getSymbolId(singleProp), singleProp); + var isInstantiation = (getTargetSymbol(prop) || prop) === (getTargetSymbol(singleProp) || singleProp); + if (isInstantiation && compareProperties(singleProp, prop, function (a, b) { return a === b ? -1 : 0; }) === -1) { + mergedInstantiations = !!singleProp.parent && !!ts.length(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(singleProp.parent)); } - var id = getSymbolId(prop); - if (!propSet.has(id)) { - propSet.set(id, prop); + else { + if (!propSet) { + propSet = new ts.Map(); + propSet.set(getSymbolId(singleProp), singleProp); + } + var id = getSymbolId(prop); + if (!propSet.has(id)) { + propSet.set(id, prop); + } } } checkFlags |= (isReadonlySymbol(prop) ? 8 : 0) | @@ -44364,7 +45957,7 @@ var ts; checkFlags |= 32 | (indexInfo.isReadonly ? 8 : 0); indexTypes = ts.append(indexTypes, isTupleType(type) ? getRestTypeOfTupleType(type) || undefinedType : indexInfo.type); } - else if (isObjectLiteralType(type)) { + else if (isObjectLiteralType(type) && !(ts.getObjectFlags(type) & 4194304)) { checkFlags |= 32; indexTypes = ts.append(indexTypes, undefinedType); } @@ -44378,7 +45971,16 @@ var ts; return undefined; } if (!propSet && !(checkFlags & 16) && !indexTypes) { - return singleProp; + if (mergedInstantiations) { + var clone_1 = createSymbolWithType(singleProp, singleProp.type); + clone_1.parent = (_b = (_a = singleProp.valueDeclaration) === null || _a === void 0 ? void 0 : _a.symbol) === null || _b === void 0 ? void 0 : _b.parent; + clone_1.containingType = containingType; + clone_1.mapper = singleProp.mapper; + return clone_1; + } + else { + return singleProp; + } } var props = propSet ? ts.arrayFrom(propSet.values()) : [singleProp]; var declarations; @@ -44387,8 +45989,8 @@ var ts; var propTypes = []; var firstValueDeclaration; var hasNonUniformValueDeclaration = false; - for (var _b = 0, props_1 = props; _b < props_1.length; _b++) { - var prop = props_1[_b]; + for (var _d = 0, props_1 = props; _d < props_1.length; _d++) { + var prop = props_1[_d]; if (!firstValueDeclaration) { firstValueDeclaration = prop.valueDeclaration; } @@ -44451,15 +46053,15 @@ var ts; return property && !(ts.getCheckFlags(property) & 16) ? property : undefined; } function getReducedType(type) { - if (type.flags & 1048576 && type.objectFlags & 268435456) { + if (type.flags & 1048576 && type.objectFlags & 67108864) { return type.resolvedReducedType || (type.resolvedReducedType = getReducedUnionType(type)); } else if (type.flags & 2097152) { - if (!(type.objectFlags & 268435456)) { - type.objectFlags |= 268435456 | - (ts.some(getPropertiesOfUnionOrIntersectionType(type), isNeverReducedProperty) ? 536870912 : 0); + if (!(type.objectFlags & 67108864)) { + type.objectFlags |= 67108864 | + (ts.some(getPropertiesOfUnionOrIntersectionType(type), isNeverReducedProperty) ? 134217728 : 0); } - return type.objectFlags & 536870912 ? neverType : type; + return type.objectFlags & 134217728 ? neverType : type; } return type; } @@ -44486,7 +46088,7 @@ var ts; return !prop.valueDeclaration && !!(ts.getCheckFlags(prop) & 1024); } function elaborateNeverIntersection(errorInfo, type) { - if (ts.getObjectFlags(type) & 536870912) { + if (type.flags & 2097152 && ts.getObjectFlags(type) & 134217728) { 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, undefined, 536870912), symbolToString(neverProp)); @@ -44557,7 +46159,8 @@ var ts; for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) { var prop = _a[_i]; if (kind === 0 || isNumericLiteralName(prop.escapedName)) { - propTypes.push(getTypeOfSymbol(prop)); + var propType = getTypeOfSymbol(prop); + propTypes.push(prop.flags & 16777216 ? getTypeWithFacts(propType, 524288) : propType); } } if (kind === 0) { @@ -44587,10 +46190,10 @@ var ts; return result; } function isJSDocOptionalParameter(node) { - return ts.isInJSFile(node) && (node.type && node.type.kind === 307 + return ts.isInJSFile(node) && (node.type && node.type.kind === 310 || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 307; + return isBracketed || !!typeExpression && typeExpression.type.kind === 310; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -44618,12 +46221,15 @@ var ts; } return false; } + function isOptionalPropertyDeclaration(node) { + return ts.isPropertyDeclaration(node) && node.questionToken; + } function isOptionalJSDocPropertyLikeTag(node) { if (!ts.isJSDocPropertyLikeTag(node)) { return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 307; + return isBracketed || !!typeExpression && typeExpression.type.kind === 310; } function createTypePredicate(kind, parameterName, parameterIndex, type) { return { kind: kind, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; @@ -44696,7 +46302,7 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 191) { + if (type && type.kind === 193) { flags |= 2; } var isOptionalParameter_1 = isOptionalJSDocPropertyLikeTag(param) || @@ -44707,16 +46313,16 @@ var ts; minArgumentCount = parameters.length; } } - if ((declaration.kind === 167 || declaration.kind === 168) && - !hasNonBindableDynamicName(declaration) && + if ((declaration.kind === 169 || declaration.kind === 170) && + hasBindableName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 167 ? 168 : 167; + var otherKind = declaration.kind === 169 ? 170 : 169; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 166 ? + var classType = declaration.kind === 168 ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); @@ -44752,8 +46358,7 @@ var ts; if (!(ts.isInJSFile(node) && ts.isFunctionLikeDeclaration(node))) return undefined; var typeTag = ts.getJSDocTypeTag(node); - var signature = typeTag && typeTag.typeExpression && getSingleCallSignature(getTypeFromTypeNode(typeTag.typeExpression)); - return signature && getErasedSignature(signature); + return (typeTag === null || typeTag === void 0 ? void 0 : typeTag.typeExpression) && getSingleCallSignature(getTypeFromTypeNode(typeTag.typeExpression)); } function getReturnTypeOfTypeTag(node) { var signature = getSignatureOfTypeTag(node); @@ -44774,16 +46379,16 @@ var ts; if (!node) return false; switch (node.kind) { - case 78: + case 79: return node.escapedText === argumentsSymbol.escapedName && getResolvedSymbol(node) === argumentsSymbol; - case 163: case 165: case 167: - case 168: - return node.name.kind === 158 + case 169: + case 170: + return node.name.kind === 160 && traverse(node.name); - case 201: - case 202: + case 203: + case 204: return traverse(node.expression); default: return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); @@ -44791,7 +46396,7 @@ var ts; } } function getSignaturesOfSymbol(symbol) { - if (!symbol) + if (!symbol || !symbol.declarations) return ts.emptyArray; var result = []; for (var i = 0; i < symbol.declarations.length; i++) { @@ -44829,8 +46434,8 @@ var ts; var targetTypePredicate = getTypePredicateOfSignature(signature.target); signature.resolvedTypePredicate = targetTypePredicate ? instantiateTypePredicate(targetTypePredicate, signature.mapper) : noTypePredicate; } - else if (signature.unionSignatures) { - signature.resolvedTypePredicate = getUnionTypePredicate(signature.unionSignatures) || noTypePredicate; + else if (signature.compositeSignatures) { + signature.resolvedTypePredicate = getUnionOrIntersectionTypePredicate(signature.compositeSignatures, signature.compositeKind) || noTypePredicate; } else { var type = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); @@ -44852,17 +46457,20 @@ var ts; function createTypePredicateFromTypePredicateNode(node, signature) { var parameterName = node.parameterName; var type = node.type && getTypeFromTypeNode(node.type); - return parameterName.kind === 187 ? + return parameterName.kind === 189 ? createTypePredicate(node.assertsModifier ? 2 : 0, undefined, undefined, type) : createTypePredicate(node.assertsModifier ? 3 : 1, parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); } + function getUnionOrIntersectionType(types, kind, unionReduction) { + return kind !== 2097152 ? getUnionType(types, unionReduction) : getIntersectionType(types); + } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { if (!pushTypeResolution(signature, 3)) { return errorType; } var type = signature.target ? instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper) : - signature.unionSignatures ? instantiateType(getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature), 2), signature.mapper) : + signature.compositeSignatures ? instantiateType(getUnionOrIntersectionType(ts.map(signature.compositeSignatures, getReturnTypeOfSignature), signature.compositeKind, 2), signature.mapper) : getReturnTypeFromAnnotation(signature.declaration) || (ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration)); if (signature.flags & 8) { @@ -44895,7 +46503,7 @@ var ts; return signature.resolvedReturnType; } function getReturnTypeFromAnnotation(declaration) { - if (declaration.kind === 166) { + if (declaration.kind === 168) { return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)); } if (ts.isJSDocConstructSignature(declaration)) { @@ -44905,12 +46513,12 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 167 && !hasNonBindableDynamicName(declaration)) { + if (declaration.kind === 169 && hasBindableName(declaration)) { var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration); if (jsDocType) { return jsDocType; } - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 168); + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 170); var setterType = getAnnotatedAccessorType(setter); if (setterType) { return setterType; @@ -44980,16 +46588,24 @@ var ts; function getBaseSignature(signature) { var typeParameters = signature.typeParameters; if (typeParameters) { - var typeEraser_1 = createTypeEraser(typeParameters); - var baseConstraints = ts.map(typeParameters, function (tp) { return instantiateType(getBaseConstraintOfType(tp), typeEraser_1) || unknownType; }); - return instantiateSignature(signature, createTypeMapper(typeParameters, baseConstraints), true); + if (signature.baseSignatureCache) { + return signature.baseSignatureCache; + } + var typeEraser = createTypeEraser(typeParameters); + var baseConstraintMapper_1 = createTypeMapper(typeParameters, ts.map(typeParameters, function (tp) { return getConstraintOfTypeParameter(tp) || unknownType; })); + var baseConstraints = ts.map(typeParameters, function (tp) { return instantiateType(tp, baseConstraintMapper_1) || unknownType; }); + for (var i = 0; i < typeParameters.length - 1; i++) { + baseConstraints = instantiateTypes(baseConstraints, baseConstraintMapper_1); + } + baseConstraints = instantiateTypes(baseConstraints, typeEraser); + return signature.baseSignatureCache = instantiateSignature(signature, createTypeMapper(typeParameters, baseConstraints), true); } return signature; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { var kind = signature.declaration ? signature.declaration.kind : 0; - var isConstructor = kind === 166 || kind === 170 || kind === 175; + var isConstructor = kind === 168 || kind === 172 || kind === 177; var type = createObjectType(16); type.members = emptySymbols; type.properties = ts.emptyArray; @@ -45000,12 +46616,22 @@ var ts; return signature.isolatedSignatureType; } function getIndexSymbol(symbol) { - return symbol.members.get("__index"); + return symbol.members ? getIndexSymbolFromSymbolTable(symbol.members) : undefined; + } + function getIndexSymbolFromSymbolTable(symbolTable) { + return symbolTable.get("__index"); } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 144 : 147; - var indexSymbol = getIndexSymbol(symbol); - if (indexSymbol) { + var indexSymbol = symbol && getIndexSymbol(symbol); + return indexSymbol && getIndexDeclarationOfIndexSymbol(indexSymbol, kind); + } + function getIndexDeclarationOfSymbolTable(symbolTable, kind) { + var indexSymbol = symbolTable && getIndexSymbolFromSymbolTable(symbolTable); + return indexSymbol && getIndexDeclarationOfIndexSymbol(indexSymbol, kind); + } + function getIndexDeclarationOfIndexSymbol(indexSymbol, kind) { + var syntaxKind = kind === 1 ? 145 : 148; + if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; var node = ts.cast(decl, ts.isIndexSignatureDeclaration); @@ -45033,13 +46659,14 @@ var ts; return ts.mapDefined(ts.filter(type.symbol && type.symbol.declarations, ts.isTypeParameterDeclaration), ts.getEffectiveConstraintOfTypeParameter)[0]; } function getInferredTypeParameterConstraint(typeParameter) { + var _a; var inferences; - if (typeParameter.symbol) { - for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.parent.kind === 185) { - var _b = ts.walkUpParenthesizedTypesAndGetParentAndChild(declaration.parent.parent), _c = _b[0], childTypeParameter = _c === void 0 ? declaration.parent : _c, grandParent = _b[1]; - if (grandParent.kind === 173) { + 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 === 187) { + var _c = ts.walkUpParenthesizedTypesAndGetParentAndChild(declaration.parent.parent), _d = _c[0], childTypeParameter = _d === void 0 ? declaration.parent : _d, grandParent = _c[1]; + if (grandParent.kind === 175) { var typeReference = grandParent; var typeParameters = getTypeParametersForTypeReference(typeReference); if (typeParameters) { @@ -45056,17 +46683,25 @@ var ts; } } } - else if (grandParent.kind === 160 && grandParent.dotDotDotToken || - grandParent.kind === 181 || - grandParent.kind === 192 && grandParent.dotDotDotToken) { + else if (grandParent.kind === 162 && grandParent.dotDotDotToken || + grandParent.kind === 183 || + grandParent.kind === 194 && grandParent.dotDotDotToken) { inferences = ts.append(inferences, createArrayType(unknownType)); } - else if (grandParent.kind === 194) { + else if (grandParent.kind === 196) { inferences = ts.append(inferences, stringType); } - else if (grandParent.kind === 159 && grandParent.parent.kind === 190) { + else if (grandParent.kind === 161 && grandParent.parent.kind === 192) { inferences = ts.append(inferences, keyofConstraintType); } + else if (grandParent.kind === 192 && grandParent.type && + ts.skipParentheses(grandParent.type) === declaration.parent && grandParent.parent.kind === 186 && + grandParent.parent.extendsType === grandParent && grandParent.parent.checkType.kind === 192 && + 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))); + } } } } @@ -45086,7 +46721,7 @@ var ts; else { var type = getTypeFromTypeNode(constraintDeclaration); if (type.flags & 1 && type !== errorType) { - type = constraintDeclaration.parent.parent.kind === 190 ? keyofConstraintType : unknownType; + type = constraintDeclaration.parent.parent.kind === 192 ? keyofConstraintType : unknownType; } typeParameter.constraint = type; } @@ -45095,7 +46730,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - var tp = ts.getDeclarationOfKind(typeParameter.symbol, 159); + var tp = ts.getDeclarationOfKind(typeParameter.symbol, 161); var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getHostSignatureFromJSDoc(tp.parent) : tp.parent; return host && getSymbolOfNode(host); } @@ -45122,6 +46757,9 @@ var ts; } return result; } + function getAliasId(aliasSymbol, aliasTypeArguments) { + return aliasSymbol ? "@" + getSymbolId(aliasSymbol) + (aliasTypeArguments ? ":" + getTypeListId(aliasTypeArguments) : "") : ""; + } function getPropagatingFlagsOfTypes(types, excludeKinds) { var result = 0; for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { @@ -45130,7 +46768,7 @@ var ts; result |= ts.getObjectFlags(type); } } - return result & 3670016; + return result & 917504; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); @@ -45152,15 +46790,18 @@ var ts; type.resolvedTypeArguments = source.resolvedTypeArguments; return type; } - function createDeferredTypeReference(target, node, mapper) { - var aliasSymbol = getAliasSymbolForTypeNode(node); - var aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); + function createDeferredTypeReference(target, node, mapper, aliasSymbol, aliasTypeArguments) { + if (!aliasSymbol) { + aliasSymbol = getAliasSymbolForTypeNode(node); + var localAliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); + aliasTypeArguments = mapper ? instantiateTypes(localAliasTypeArguments, mapper) : localAliasTypeArguments; + } var type = createObjectType(4, target.symbol); type.target = target; type.node = node; type.mapper = mapper; type.aliasSymbol = aliasSymbol; - type.aliasTypeArguments = mapper ? instantiateTypes(aliasTypeArguments, mapper) : aliasTypeArguments; + type.aliasTypeArguments = aliasTypeArguments; return type; } function getTypeArguments(type) { @@ -45171,8 +46812,8 @@ var ts; } var node = type.node; var typeArguments = !node ? ts.emptyArray : - node.kind === 173 ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : - node.kind === 178 ? [getTypeFromTypeNode(node.elementType)] : + node.kind === 175 ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : + node.kind === 180 ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); if (popTypeResolution()) { type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments; @@ -45210,7 +46851,7 @@ var ts; return errorType; } } - if (node.kind === 173 && isDeferredTypeReferenceNode(node, ts.length(node.typeArguments) !== typeParameters.length)) { + if (node.kind === 175 && isDeferredTypeReferenceNode(node, ts.length(node.typeArguments) !== typeParameters.length)) { return createDeferredTypeReference(type, node, undefined); } var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgumentsFromTypeReferenceNode(node), typeParameters, minTypeArgumentCount, isJs)); @@ -45218,17 +46859,17 @@ var ts; } return checkNoTypeArguments(node, symbol) ? type : errorType; } - function getTypeAliasInstantiation(symbol, typeArguments) { + function getTypeAliasInstantiation(symbol, typeArguments, aliasSymbol, aliasTypeArguments) { var type = getDeclaredTypeOfSymbol(symbol); if (type === intrinsicMarkerType && intrinsicTypeKinds.has(symbol.escapedName) && typeArguments && typeArguments.length === 1) { return getStringMappingType(symbol, typeArguments[0]); } var links = getSymbolLinks(symbol); var typeParameters = links.typeParameters; - var id = getTypeListId(typeArguments); + var id = getTypeListId(typeArguments) + getAliasId(aliasSymbol, aliasTypeArguments); var instantiation = links.instantiations.get(id); if (!instantiation) { - links.instantiations.set(id, instantiation = instantiateType(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters), ts.isInJSFile(symbol.valueDeclaration))))); + links.instantiations.set(id, instantiation = instantiateTypeWithAlias(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters), ts.isInJSFile(symbol.valueDeclaration))), aliasSymbol, aliasTypeArguments)); } return instantiation; } @@ -45244,15 +46885,22 @@ var ts; ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); return errorType; } - return getTypeAliasInstantiation(symbol, typeArgumentsFromTypeReferenceNode(node)); + var aliasSymbol = getAliasSymbolForTypeNode(node); + var newAliasSymbol = aliasSymbol && (isLocalTypeAlias(symbol) || !isLocalTypeAlias(aliasSymbol)) ? aliasSymbol : undefined; + return getTypeAliasInstantiation(symbol, typeArgumentsFromTypeReferenceNode(node), newAliasSymbol, getTypeArgumentsForAliasSymbol(newAliasSymbol)); } return checkNoTypeArguments(node, symbol) ? type : errorType; } + function isLocalTypeAlias(symbol) { + var _a; + var declaration = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isTypeAlias); + return !!(declaration && ts.getContainingFunction(declaration)); + } function getTypeReferenceName(node) { switch (node.kind) { - case 173: + case 175: return node.typeName; - case 223: + case 225: var expr = node.expression; if (ts.isEntityNameExpression(expr)) { return expr; @@ -45299,7 +46947,7 @@ var ts; var valueType = getTypeOfSymbol(symbol); var typeType = valueType; if (symbol.valueDeclaration) { - var isImportTypeWithQualifier = node.kind === 195 && node.qualifier; + var isImportTypeWithQualifier = node.kind === 197 && node.qualifier; if (valueType.symbol && valueType.symbol !== symbol && isImportTypeWithQualifier) { typeType = getTypeReferenceType(node, valueType.symbol); } @@ -45324,7 +46972,7 @@ var ts; return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 179 && node.elements.length === 1; + return node.kind === 181 && node.elements.length === 1; } function getImpliedConstraint(type, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(type, checkNode.elements[0], extendsNode.elements[0]) : @@ -45333,9 +46981,13 @@ var ts; } function getConditionalFlowTypeOfType(type, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 311) { + var covariant = true; + while (node && !ts.isStatement(node) && node.kind !== 314) { var parent = node.parent; - if (parent.kind === 184 && node === parent.trueType) { + if (parent.kind === 162) { + covariant = !covariant; + } + if ((covariant || type.flags & 8650752) && parent.kind === 186 && node === parent.trueType) { var constraint = getImpliedConstraint(type, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -45346,7 +46998,7 @@ var ts; return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type; } function isJSDocTypeReference(node) { - return !!(node.flags & 4194304) && (node.kind === 173 || node.kind === 195); + return !!(node.flags & 4194304) && (node.kind === 175 || node.kind === 197); } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -45449,13 +47101,15 @@ var ts; function getTypeOfGlobalSymbol(symbol, arity) { function getTypeDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { - var declaration = declarations_3[_i]; - switch (declaration.kind) { - case 252: - case 253: - case 255: - return declaration; + if (declarations) { + for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { + var declaration = declarations_3[_i]; + switch (declaration.kind) { + case 254: + case 255: + case 257: + return declaration; + } } } } @@ -45498,6 +47152,9 @@ var ts; function getGlobalESSymbolConstructorSymbol(reportErrors) { return deferredGlobalESSymbolConstructorSymbol || (deferredGlobalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol", reportErrors)); } + function getGlobalESSymbolConstructorTypeSymbol(reportErrors) { + return deferredGlobalESSymbolConstructorTypeSymbol || (deferredGlobalESSymbolConstructorTypeSymbol = getGlobalTypeSymbol("SymbolConstructor", reportErrors)); + } function getGlobalESSymbolType(reportErrors) { return deferredGlobalESSymbolType || (deferredGlobalESSymbolType = getGlobalType("Symbol", 0, reportErrors)) || emptyObjectType; } @@ -45571,11 +47228,11 @@ var ts; } function getTupleElementFlags(node) { switch (node.kind) { - case 180: + case 182: return 2; - case 181: + case 183: return getRestTypeElementFlags(node); - case 192: + case 194: return node.questionToken ? 2 : node.dotDotDotToken ? getRestTypeElementFlags(node) : 1; @@ -45593,57 +47250,57 @@ var ts; return readonly ? globalReadonlyArrayType : globalArrayType; } var elementFlags = ts.map(node.elements, getTupleElementFlags); - var missingName = ts.some(node.elements, function (e) { return e.kind !== 192; }); + var missingName = ts.some(node.elements, function (e) { return e.kind !== 194; }); return getTupleTargetType(elementFlags, readonly, missingName ? undefined : node.elements); } function isDeferredTypeReferenceNode(node, hasDefaultTypeArguments) { - return !!getAliasSymbolForTypeNode(node) || isResolvedByTypeAlias(node) && (node.kind === 178 ? mayResolveTypeAlias(node.elementType) : - node.kind === 179 ? ts.some(node.elements, mayResolveTypeAlias) : + return !!getAliasSymbolForTypeNode(node) || isResolvedByTypeAlias(node) && (node.kind === 180 ? mayResolveTypeAlias(node.elementType) : + node.kind === 181 ? ts.some(node.elements, mayResolveTypeAlias) : hasDefaultTypeArguments || ts.some(node.typeArguments, mayResolveTypeAlias)); } function isResolvedByTypeAlias(node) { var parent = node.parent; switch (parent.kind) { - case 186: - case 192: - case 173: - case 182: - case 183: - case 189: - case 184: case 188: - case 178: - case 179: + case 194: + case 175: + case 184: + case 185: + case 191: + case 186: + case 190: + case 180: + case 181: return isResolvedByTypeAlias(parent); - case 254: + case 256: return true; } return false; } function mayResolveTypeAlias(node) { switch (node.kind) { - case 173: + case 175: return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node.typeName, 788968).flags & 524288); - case 176: + case 178: return true; + case 190: + return node.operator !== 152 && mayResolveTypeAlias(node.type); case 188: - return node.operator !== 151 && mayResolveTypeAlias(node.type); - case 186: - case 180: - case 192: - case 307: - case 305: - case 306: - case 301: - return mayResolveTypeAlias(node.type); - case 181: - return node.type.kind !== 178 || mayResolveTypeAlias(node.type.elementType); case 182: + case 194: + case 310: + case 308: + case 309: + case 303: + return mayResolveTypeAlias(node.type); case 183: + return node.type.kind !== 180 || mayResolveTypeAlias(node.type.elementType); + case 184: + case 185: return ts.some(node.types, mayResolveTypeAlias); - case 189: + case 191: return mayResolveTypeAlias(node.objectType) || mayResolveTypeAlias(node.indexType); - case 184: + case 186: return mayResolveTypeAlias(node.checkType) || mayResolveTypeAlias(node.extendsType) || mayResolveTypeAlias(node.trueType) || mayResolveTypeAlias(node.falseType); } @@ -45656,19 +47313,19 @@ var ts; if (target === emptyGenericType) { links.resolvedType = emptyObjectType; } - else if (!(node.kind === 179 && ts.some(node.elements, function (e) { return !!(getTupleElementFlags(e) & 8); })) && isDeferredTypeReferenceNode(node)) { - links.resolvedType = node.kind === 179 && node.elements.length === 0 ? target : + else if (!(node.kind === 181 && ts.some(node.elements, function (e) { return !!(getTupleElementFlags(e) & 8); })) && isDeferredTypeReferenceNode(node)) { + links.resolvedType = node.kind === 181 && node.elements.length === 0 ? target : createDeferredTypeReference(target, node, undefined); } else { - var elementTypes = node.kind === 178 ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); + var elementTypes = node.kind === 180 ? [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 === 142; + return ts.isTypeOperatorNode(node) && node.operator === 143; } function createTupleType(elementTypes, elementFlags, readonly, namedMemberDeclarations) { if (readonly === void 0) { readonly = false; } @@ -45777,7 +47434,14 @@ var ts; addElement(type, 8, (_a = target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]); } else if (isTupleType(type)) { - ts.forEach(getTypeArguments(type), function (t, n) { var _a; return addElement(t, type.target.elementFlags[n], (_a = type.target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[n]); }); + var elements = getTypeArguments(type); + if (elements.length + expandedTypes.length >= 10000) { + error(currentNode, ts.isPartOfTypeNode(currentNode) + ? ts.Diagnostics.Type_produces_a_tuple_type_that_is_too_large_to_represent + : ts.Diagnostics.Expression_produces_a_tuple_type_that_is_too_large_to_represent); + return { value: errorType }; + } + ts.forEach(elements, function (t, n) { var _a; return addElement(t, type.target.elementFlags[n], (_a = type.target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[n]); }); } else { addElement(isArrayLikeType(type) && getIndexTypeOfType(type, 1) || errorType, 4, (_b = target.labeledElementDeclarations) === null || _b === void 0 ? void 0 : _b[i]); @@ -45788,7 +47452,9 @@ var ts; } }; for (var i = 0; i < elementTypes.length; i++) { - _loop_13(i); + var state_4 = _loop_13(i); + if (typeof state_4 === "object") + return state_4.value; } for (var i = 0; i < lastRequiredIndex; i++) { if (expandedFlags[i] & 2) @@ -45842,8 +47508,7 @@ var ts; return type.elementFlags.length - ts.findLastIndex(type.elementFlags, function (f) { return !(f & flags); }) - 1; } function getTypeFromOptionalTypeNode(node) { - var type = getTypeFromTypeNode(node.type); - return strictNullChecks ? getOptionalType(type) : type; + return addOptionality(getTypeFromTypeNode(node.type), true); } function getTypeId(type) { return type.id; @@ -45871,7 +47536,7 @@ var ts; if (type === wildcardType) includes |= 8388608; if (!strictNullChecks && flags & 98304) { - if (!(ts.getObjectFlags(type) & 524288)) + if (!(ts.getObjectFlags(type) & 131072)) includes |= 4194304; } else { @@ -45891,62 +47556,66 @@ var ts; } return includes; } - function isSetOfLiteralsFromSameEnum(types) { - var first = types[0]; - if (first.flags & 1024) { - var firstEnum = getParentOfSymbol(first.symbol); - for (var i = 1; i < types.length; i++) { - var other = types[i]; - if (!(other.flags & 1024) || (firstEnum !== getParentOfSymbol(other.symbol))) { - return false; - } - } - return true; + function removeSubtypes(types, hasObjectTypes) { + var id = getTypeListId(types); + var match = subtypeReductionCache.get(id); + if (match) { + return match; } - return false; - } - function removeSubtypes(types, primitivesOnly) { + var hasEmptyObject = hasObjectTypes && ts.some(types, function (t) { return !!(t.flags & 524288) && !isGenericMappedType(t) && isEmptyResolvedType(resolveStructuredTypeMembers(t)); }); var len = types.length; - if (len === 0 || isSetOfLiteralsFromSameEnum(types)) { - return true; - } var i = len; var count = 0; while (i > 0) { i--; var source = types[i]; - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var target = types_11[_i]; - if (source !== target) { - if (count === 100000) { - var estimatedCount = (count / (len - i)) * len; - if (estimatedCount > (primitivesOnly ? 25000000 : 1000000)) { - ts.tracing.instant("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 false; + if (hasEmptyObject || source.flags & 469499904) { + var keyProperty = source.flags & (524288 | 2097152 | 58982400) ? + ts.find(getPropertiesOfType(source), function (p) { return isUnitType(getTypeOfSymbol(p)); }) : + undefined; + var keyPropertyType = keyProperty && getRegularTypeOfLiteralType(getTypeOfSymbol(keyProperty)); + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var target = types_11[_i]; + if (source !== target) { + if (count === 100000) { + var estimatedCount = (count / (len - i)) * len; + if (estimatedCount > 1000000) { + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("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 | 2097152 | 58982400)) { + var t = getTypeOfPropertyOfType(target, keyProperty.escapedName); + if (t && isUnitType(t) && getRegularTypeOfLiteralType(t) !== keyPropertyType) { + continue; + } + } + if (isTypeRelatedTo(source, target, strictSubtypeRelation) && (!(ts.getObjectFlags(getTargetType(source)) & 1) || + !(ts.getObjectFlags(getTargetType(target)) & 1) || + isTypeDerivedFrom(source, target))) { + ts.orderedRemoveItemAt(types, i); + break; } - } - count++; - if (isTypeRelatedTo(source, target, strictSubtypeRelation) && (!(ts.getObjectFlags(getTargetType(source)) & 1) || - !(ts.getObjectFlags(getTargetType(target)) & 1) || - isTypeDerivedFrom(source, target))) { - ts.orderedRemoveItemAt(types, i); - break; } } } } - return true; + subtypeReductionCache.set(id, types); + return types; } - function removeRedundantLiteralTypes(types, includes) { + function removeRedundantLiteralTypes(types, includes, reduceVoidUndefined) { var i = types.length; while (i > 0) { i--; var t = types[i]; - var remove = t.flags & 134217856 && includes & 4 || - t.flags & 256 && includes & 8 || - t.flags & 2048 && includes & 64 || - t.flags & 8192 && includes & 4096 || + var flags = t.flags; + var remove = flags & 128 && includes & 4 || + flags & 256 && includes & 8 || + flags & 2048 && includes & 64 || + flags & 8192 && includes & 4096 || + reduceVoidUndefined && flags & 32768 && includes & 16384 || isFreshLiteralType(t) && containsType(types, t.regularType); if (remove) { ts.orderedRemoveItemAt(types, i); @@ -45978,7 +47647,7 @@ var ts; if (t.flags & 1048576) { var origin = t.origin; if (t.aliasSymbol || origin && !(origin.flags & 1048576)) { - namedUnions.push(t); + ts.pushIfUnique(namedUnions, t); } else if (origin && origin.flags & 1048576) { addNamedUnions(namedUnions, origin.types); @@ -46005,20 +47674,23 @@ var ts; if (includes & 3) { return includes & 1 ? includes & 8388608 ? wildcardType : anyType : unknownType; } - switch (unionReduction) { - case 1: - if (includes & (134220672 | 8192)) { - removeRedundantLiteralTypes(typeSet, includes); - } - if (includes & 128 && includes & 134217728) { - removeStringLiteralsMatchedByTemplateLiterals(typeSet); - } - break; - case 2: - if (!removeSubtypes(typeSet, !(includes & 262144))) { - return errorType; - } - break; + if (strictOptionalProperties && includes & 32768) { + var missingIndex = ts.binarySearch(typeSet, missingType, getTypeId, ts.compareValues); + if (missingIndex >= 0 && containsType(typeSet, undefinedType)) { + ts.orderedRemoveItemAt(typeSet, missingIndex); + } + } + if (includes & (2944 | 8192) || includes & 16384 && includes & 32768) { + removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2)); + } + if (includes & 128 && includes & 134217728) { + removeStringLiteralsMatchedByTemplateLiterals(typeSet); + } + if (unionReduction === 2) { + typeSet = removeSubtypes(typeSet, !!(includes & 524288)); + if (!typeSet) { + return errorType; + } } if (typeSet.length === 0) { return includes & 65536 ? includes & 4194304 ? nullType : nullWideningType : @@ -46051,18 +47723,23 @@ var ts; origin = createOriginUnionOrIntersectionType(1048576, reducedTypes); } } - var objectFlags = (includes & 468598819 ? 0 : 262144) | - (includes & 2097152 ? 268435456 : 0); + var objectFlags = (includes & 468598819 ? 0 : 65536) | + (includes & 2097152 ? 67108864 : 0); return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin); } - function getUnionTypePredicate(signatures) { + function getUnionOrIntersectionTypePredicate(signatures, kind) { var first; var types = []; 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 || pred.kind === 3) { - continue; + if (kind !== 2097152) { + continue; + } + else { + return; + } } if (first) { if (!typePredicateKindsMatch(first, pred)) { @@ -46077,8 +47754,8 @@ var ts; if (!first) { return undefined; } - var unionType = getUnionType(types); - return createTypePredicate(first.kind, first.parameterName, first.parameterIndex, unionType); + var compositeType = getUnionOrIntersectionType(types, kind); + return createTypePredicate(first.kind, first.parameterName, first.parameterIndex, compositeType); } function typePredicateKindsMatch(a, b) { return a.kind === b.kind && a.parameterIndex === b.parameterIndex; @@ -46102,8 +47779,8 @@ var ts; var typeKey = !origin ? getTypeListId(types) : origin.flags & 1048576 ? "|" + getTypeListId(origin.types) : origin.flags & 2097152 ? "&" + getTypeListId(origin.types) : - "#" + origin.type.id; - var id = typeKey + (aliasSymbol ? "@" + getSymbolId(aliasSymbol) : ""); + "#" + origin.type.id + "|" + getTypeListId(types); + var id = typeKey + getAliasId(aliasSymbol, aliasTypeArguments); var type = unionTypes.get(id); if (!type) { type = createUnionType(types, aliasSymbol, aliasTypeArguments, origin); @@ -46215,14 +47892,14 @@ var ts; } function intersectUnionsOfPrimitiveTypes(types) { var unionTypes; - var index = ts.findIndex(types, function (t) { return !!(ts.getObjectFlags(t) & 262144); }); + var index = ts.findIndex(types, function (t) { return !!(ts.getObjectFlags(t) & 65536); }); if (index < 0) { return false; } var i = index + 1; while (i < types.length) { var t = types[i]; - if (ts.getObjectFlags(t) & 262144) { + if (ts.getObjectFlags(t) & 65536) { (unionTypes || (unionTypes = [types[index]])).push(t); ts.orderedRemoveItemAt(types, i); } @@ -46246,7 +47923,7 @@ var ts; } } } - types[index] = getUnionTypeFromSortedList(result, 262144); + types[index] = getUnionTypeFromSortedList(result, 65536); return true; } function createIntersectionType(types, aliasSymbol, aliasTypeArguments) { @@ -46295,7 +47972,7 @@ var ts; if (typeSet.length === 1) { return typeSet[0]; } - var id = getTypeListId(typeSet) + (aliasSymbol ? "@" + getSymbolId(aliasSymbol) : ""); + var id = getTypeListId(typeSet) + getAliasId(aliasSymbol, aliasTypeArguments); var result = intersectionTypes.get(id); if (!result) { if (includes & 1048576) { @@ -46330,7 +48007,7 @@ var ts; function checkCrossProductUnion(types) { var size = getCrossProductUnionSize(types); if (size >= 100000) { - ts.tracing.instant("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", "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; } @@ -46380,19 +48057,29 @@ var ts; type.resolvedStringIndexType || (type.resolvedStringIndexType = createIndexType(type, true)) : type.resolvedIndexType || (type.resolvedIndexType = createIndexType(type, false)); } + function instantiateTypeAsMappedNameType(nameType, type, t) { + return instantiateType(nameType, appendTypeMapping(type.mapper, getTypeParameterFromMappedType(type), t)); + } function getIndexTypeForMappedType(type, noIndexSignatures) { var constraint = filterType(getConstraintTypeFromMappedType(type), function (t) { return !(noIndexSignatures && t.flags & (1 | 4)); }); var nameType = type.declaration.nameType && getTypeFromTypeNode(type.declaration.nameType); + var properties = nameType && everyType(constraint, function (t) { return !!(t.flags & (4 | 8 | 131072)); }) && getPropertiesOfType(getApparentType(getModifiersTypeFromMappedType(type))); return nameType ? - mapType(constraint, function (t) { return instantiateType(nameType, appendTypeMapping(type.mapper, getTypeParameterFromMappedType(type), t)); }) : + getUnionType([mapType(constraint, function (t) { return instantiateTypeAsMappedNameType(nameType, type, t); }), mapType(getUnionType(ts.map(properties || ts.emptyArray, function (p) { return getLiteralTypeFromProperty(p, 8576); })), function (t) { return instantiateTypeAsMappedNameType(nameType, type, t); })]) : constraint; } - function maybeNonDistributiveNameType(type) { - return !!(type && (type.flags & 16777216 && (!type.root.isDistributive || maybeNonDistributiveNameType(type.checkType)) || - type.flags & (3145728 | 134217728) && ts.some(type.types, maybeNonDistributiveNameType) || - type.flags & (4194304 | 268435456) && maybeNonDistributiveNameType(type.type) || - type.flags & 8388608 && maybeNonDistributiveNameType(type.indexType) || - type.flags & 33554432 && maybeNonDistributiveNameType(type.substitute))); + function hasDistributiveNameType(mappedType) { + var typeVariable = getTypeParameterFromMappedType(mappedType); + return isDistributive(getNameTypeFromMappedType(mappedType) || typeVariable); + function isDistributive(type) { + return type.flags & (3 | 131068 | 131072 | 262144 | 524288 | 67108864) ? true : + type.flags & 16777216 ? type.root.isDistributive && type.checkType === typeVariable : + type.flags & (3145728 | 134217728) ? ts.every(type.types, isDistributive) : + type.flags & 8388608 ? isDistributive(type.objectType) && isDistributive(type.indexType) : + type.flags & 33554432 ? isDistributive(type.substitute) : + type.flags & 268435456 ? isDistributive(type.type) : + false; + } } function getLiteralTypeFromPropertyName(name) { if (ts.isPrivateIdentifier(name)) { @@ -46410,13 +48097,13 @@ var ts; function getLiteralTypeFromProperty(prop, include) { if (!(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24)) { var type = getSymbolLinks(getLateBoundSymbol(prop)).nameType; - if (!type && !ts.isKnownSymbol(prop)) { + if (!type) { if (prop.escapedName === "default") { type = getLiteralType("default"); } else { var name = prop.valueDeclaration && ts.getNameOfDeclaration(prop.valueDeclaration); - type = name && getLiteralTypeFromPropertyName(name) || getLiteralType(ts.symbolName(prop)); + type = name && getLiteralTypeFromPropertyName(name) || (!ts.isKnownSymbol(prop) ? getLiteralType(ts.symbolName(prop)) : undefined); } } if (type && type.flags & include) { @@ -46439,7 +48126,7 @@ var ts; type = getReducedType(type); return 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); })) : - type.flags & 58982400 || isGenericTupleType(type) || isGenericMappedType(type) && maybeNonDistributiveNameType(getNameTypeFromMappedType(type)) ? getIndexTypeForGenericType(type, stringsOnly) : + type.flags & 58982400 || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) ? getIndexTypeForGenericType(type, stringsOnly) : ts.getObjectFlags(type) & 32 ? getIndexTypeForMappedType(type, noIndexSignatures) : type === wildcardType ? wildcardType : type.flags & 2 ? neverType : @@ -46464,15 +48151,15 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { switch (node.operator) { - case 138: + case 139: links.resolvedType = getIndexType(getTypeFromTypeNode(node.type)); break; - case 151: - links.resolvedType = node.type.kind === 148 + case 152: + links.resolvedType = node.type.kind === 149 ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent)) : errorType; break; - case 142: + case 143: links.resolvedType = getTypeFromTypeNode(node.type); break; default: @@ -46515,7 +48202,6 @@ var ts; var type = templateLiteralTypes.get(id); if (!type) { templateLiteralTypes.set(id, type = createTemplateLiteralType(newTexts, newTypes)); - type.regularType = type; } return type; function addSpans(texts, types) { @@ -46547,10 +48233,8 @@ var ts; return type.flags & 128 ? type.value : type.flags & 256 ? "" + type.value : type.flags & 2048 ? ts.pseudoBigIntToString(type.value) : - type.flags & 512 ? type.intrinsicName : - type.flags & 65536 ? "null" : - type.flags & 32768 ? "undefined" : - undefined; + type.flags & (512 | 98304) ? type.intrinsicName : + undefined; } function createTemplateLiteralType(texts, types) { var type = createType(134217728); @@ -46587,20 +48271,20 @@ var ts; result.type = type; return result; } - function createIndexedAccessType(objectType, indexType, aliasSymbol, aliasTypeArguments, shouldIncludeUndefined) { + function createIndexedAccessType(objectType, indexType, accessFlags, aliasSymbol, aliasTypeArguments) { var type = createType(8388608); type.objectType = objectType; type.indexType = indexType; + type.accessFlags = accessFlags; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; - type.noUncheckedIndexedAccessCandidate = shouldIncludeUndefined; return type; } function isJSLiteralType(type) { if (noImplicitAny) { return false; } - if (ts.getObjectFlags(type) & 16384) { + if (ts.getObjectFlags(type) & 8192) { return true; } if (type.flags & 1048576) { @@ -46610,19 +48294,17 @@ var ts; return ts.some(type.types, isJSLiteralType); } if (type.flags & 465829888) { - return isJSLiteralType(getResolvedBaseConstraint(type)); + var constraint = getResolvedBaseConstraint(type); + return constraint !== type && isJSLiteralType(constraint); } return false; } function getPropertyNameFromIndex(indexType, accessNode) { - var accessExpression = accessNode && accessNode.kind === 202 ? accessNode : undefined; return isTypeUsableAsPropertyName(indexType) ? getPropertyNameFromType(indexType) : - accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, false) ? - ts.getPropertyNameForKnownSymbolName(ts.idText(accessExpression.argumentExpression.name)) : - accessNode && ts.isPropertyName(accessNode) ? - ts.getPropertyNameForPropertyNameNode(accessNode) : - undefined; + accessNode && ts.isPropertyName(accessNode) ? + ts.getPropertyNameForPropertyNameNode(accessNode) : + undefined; } function isUncalledFunctionReference(node, symbol) { if (symbol.flags & (16 | 8192)) { @@ -46634,24 +48316,27 @@ var ts; } return true; } - function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, suppressNoImplicitAnyError, accessNode, accessFlags, noUncheckedIndexedAccessCandidate, reportDeprecated) { + function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, accessNode, accessFlags) { var _a; - var accessExpression = accessNode && accessNode.kind === 202 ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 204 ? accessNode : undefined; var propName = accessNode && ts.isPrivateIdentifier(accessNode) ? undefined : getPropertyNameFromIndex(indexType, accessNode); if (propName !== undefined) { + if (accessFlags & 256) { + return getTypeOfPropertyOfContextualType(objectType, propName) || anyType; + } var prop = getPropertyOfType(objectType, propName); if (prop) { - if (reportDeprecated && accessNode && getDeclarationNodeFlagsFromSymbol(prop) & 134217728 && isUncalledFunctionReference(accessNode, prop)) { + if (accessFlags & 64 && accessNode && prop.declarations && getDeclarationNodeFlagsFromSymbol(prop) & 134217728 && 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); - errorOrSuggestion(false, deprecatedNode, ts.Diagnostics._0_is_deprecated, propName); + addDeprecatedSuggestion(deprecatedNode, prop.declarations, propName); } if (accessExpression) { - markPropertyAsReferenced(prop, accessExpression, accessExpression.expression.kind === 107); + markPropertyAsReferenced(prop, accessExpression, isSelfTypeAccess(accessExpression.expression, objectType.symbol)); if (isAssignmentToReadonlyEntity(accessExpression, prop, ts.getAssignmentTargetKind(accessExpression))) { error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(prop)); return undefined; } - if (accessFlags & 4) { + if (accessFlags & 8) { getNodeLinks(accessNode).resolvedSymbol = prop; } if (isThisPropertyAccessInConstructor(accessExpression, prop)) { @@ -46664,7 +48349,7 @@ var ts; propType; } if (everyType(objectType, isTupleType) && isNumericLiteralName(propName) && +propName >= 0) { - if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 8)) { + if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 16)) { var indexNode = getIndexNodeForAccessExpression(accessNode); if (isTupleType(objectType)) { error(indexNode, ts.Diagnostics.Tuple_type_0_of_length_1_has_no_element_at_index_2, typeToString(objectType), getTypeReferenceArity(objectType), ts.unescapeLeadingUnderscores(propName)); @@ -46676,7 +48361,7 @@ var ts; errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, 1)); return mapType(objectType, function (t) { var restType = getRestTypeOfTupleType(t) || undefinedType; - return noUncheckedIndexedAccessCandidate ? getUnionType([restType, undefinedType]) : restType; + return accessFlags & 1 ? getUnionType([restType, undefinedType]) : restType; }); } } @@ -46687,7 +48372,7 @@ var ts; var stringIndexInfo = getIndexInfoOfType(objectType, 0); var indexInfo = isTypeAssignableToKind(indexType, 296) && getIndexInfoOfType(objectType, 1) || stringIndexInfo; if (indexInfo) { - if (accessFlags & 1 && indexInfo === stringIndexInfo) { + if (accessFlags & 2 && indexInfo === stringIndexInfo) { if (accessExpression) { error(accessExpression, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(originalObjectType)); } @@ -46696,10 +48381,10 @@ var ts; if (accessNode && !isTypeAssignableToKind(indexType, 4 | 8)) { var indexNode = getIndexNodeForAccessExpression(accessNode); error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); - return noUncheckedIndexedAccessCandidate ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; + return accessFlags & 1 ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; } errorIfWritingToReadonlyIndex(indexInfo); - return noUncheckedIndexedAccessCandidate ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; + return accessFlags & 1 ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; } if (indexType.flags & 131072) { return neverType; @@ -46723,7 +48408,7 @@ var ts; if (objectType.symbol === globalThisSymbol && propName !== undefined && globalThisSymbol.exports.has(propName) && (globalThisSymbol.exports.get(propName).flags & 418)) { error(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType)); } - else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !suppressNoImplicitAnyError) { + else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !(accessFlags & 128)) { 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) + "]"); @@ -46796,13 +48481,13 @@ var ts; } } function getIndexNodeForAccessExpression(accessNode) { - return accessNode.kind === 202 ? accessNode.argumentExpression : - accessNode.kind === 189 ? accessNode.indexType : - accessNode.kind === 158 ? accessNode.expression : + return accessNode.kind === 204 ? accessNode.argumentExpression : + accessNode.kind === 191 ? accessNode.indexType : + accessNode.kind === 160 ? accessNode.expression : accessNode; } function isPatternLiteralPlaceholderType(type) { - return templateConstraintType.types.indexOf(type) !== -1 || !!(type.flags & 1); + return !!(type.flags & (1 | 4 | 8 | 64)); } function isPatternLiteralType(type) { return !!(type.flags & 134217728) && ts.every(type.types, isPatternLiteralPlaceholderType); @@ -46815,6 +48500,13 @@ var ts; } return !!(type.objectFlags & 8388608); } + if (type.flags & 33554432) { + if (!(type.objectFlags & 4194304)) { + type.objectFlags |= 4194304 | + (isGenericObjectType(type.substitute) || isGenericObjectType(type.baseType) ? 8388608 : 0); + } + return !!(type.objectFlags & 8388608); + } return !!(type.flags & 58982400) || isGenericMappedType(type) || isGenericTupleType(type); } function isGenericIndexType(type) { @@ -46825,6 +48517,13 @@ var ts; } return !!(type.objectFlags & 33554432); } + if (type.flags & 33554432) { + if (!(type.objectFlags & 16777216)) { + type.objectFlags |= 16777216 | + (isGenericIndexType(type.substitute) || isGenericIndexType(type.baseType) ? 33554432 : 0); + } + return !!(type.objectFlags & 33554432); + } return !!(type.flags & (58982400 | 4194304 | 134217728 | 268435456)) && !isPatternLiteralType(type); } function isThisTypeParameter(type) { @@ -46876,6 +48575,12 @@ var ts; } return type[cache] = type; } + function isConditionalTypeAlwaysTrueDisregardingInferTypes(type) { + var extendsInferParamMapper = type.root.inferTypeParameters && createTypeMapper(type.root.inferTypeParameters, ts.map(type.root.inferTypeParameters, function () { return wildcardType; })); + var checkType = type.checkType; + var extendsType = type.extendsType; + return isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(instantiateType(extendsType, extendsInferParamMapper))); + } function getSimplifiedConditionalType(type, writing) { var checkType = type.checkType; var extendsType = type.extendsType; @@ -46907,9 +48612,9 @@ var ts; var templateMapper = combineTypeMappers(objectType.mapper, mapper); return instantiateType(getTemplateTypeFromMappedType(objectType), templateMapper); } - function getIndexedAccessType(objectType, indexType, noUncheckedIndexedAccessCandidate, accessNode, aliasSymbol, aliasTypeArguments, accessFlags) { + function getIndexedAccessType(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) { if (accessFlags === void 0) { accessFlags = 0; } - return getIndexedAccessTypeOrUndefined(objectType, indexType, noUncheckedIndexedAccessCandidate, accessNode, accessFlags, aliasSymbol, aliasTypeArguments) || (accessNode ? errorType : unknownType); + return getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) || (accessNode ? errorType : unknownType); } function indexTypeLessThan(indexType, limit) { return everyType(indexType, function (t) { @@ -46923,27 +48628,27 @@ var ts; return false; }); } - function getIndexedAccessTypeOrUndefined(objectType, indexType, noUncheckedIndexedAccessCandidate, accessNode, accessFlags, aliasSymbol, aliasTypeArguments) { + function getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) { if (accessFlags === void 0) { accessFlags = 0; } if (objectType === wildcardType || indexType === wildcardType) { return wildcardType; } - var shouldIncludeUndefined = noUncheckedIndexedAccessCandidate || - (!!compilerOptions.noUncheckedIndexedAccess && - (accessFlags & (2 | 16)) === 16); if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags & 98304) && isTypeAssignableToKind(indexType, 4 | 8)) { indexType = stringType; } - if (isGenericIndexType(indexType) || (accessNode && accessNode.kind !== 189 ? + if (compilerOptions.noUncheckedIndexedAccess && accessFlags & 32) + accessFlags |= 1; + if (isGenericIndexType(indexType) || (accessNode && accessNode.kind !== 191 ? isGenericTupleType(objectType) && !indexTypeLessThan(indexType, objectType.target.fixedLength) : isGenericObjectType(objectType) && !(isTupleType(objectType) && indexTypeLessThan(indexType, objectType.target.fixedLength)))) { if (objectType.flags & 3) { return objectType; } - var id = objectType.id + "," + indexType.id + (shouldIncludeUndefined ? "?" : "") + (aliasSymbol ? "@" + getSymbolId(aliasSymbol) : ""); + var persistentAccessFlags = accessFlags & 1; + var id = objectType.id + "," + indexType.id + "," + persistentAccessFlags + getAliasId(aliasSymbol, aliasTypeArguments); var type = indexedAccessTypes.get(id); if (!type) { - indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType, aliasSymbol, aliasTypeArguments, shouldIncludeUndefined)); + indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType, persistentAccessFlags, aliasSymbol, aliasTypeArguments)); } return type; } @@ -46953,7 +48658,7 @@ var ts; 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, wasMissingProp, accessNode, accessFlags, shouldIncludeUndefined); + var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, indexType, accessNode, accessFlags | (wasMissingProp ? 128 : 0)); if (propType) { propTypes.push(propType); } @@ -46967,11 +48672,11 @@ var ts; if (wasMissingProp) { return undefined; } - return accessFlags & 2 + return accessFlags & 4 ? getIntersectionType(propTypes, aliasSymbol, aliasTypeArguments) : getUnionType(propTypes, 1, aliasSymbol, aliasTypeArguments); } - return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, false, accessNode, accessFlags | 4, shouldIncludeUndefined, true); + return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, accessNode, accessFlags | 8 | 64); } function getTypeFromIndexedAccessTypeNode(node) { var links = getNodeLinks(node); @@ -46979,7 +48684,7 @@ var ts; var objectType = getTypeFromTypeNode(node.objectType); var indexType = getTypeFromTypeNode(node.indexType); var potentialAlias = getAliasSymbolForTypeNode(node); - var resolved = getIndexedAccessType(objectType, indexType, undefined, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias)); + var resolved = getIndexedAccessType(objectType, indexType, 0, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias)); links.resolvedType = resolved.flags & 8388608 && resolved.objectType === objectType && resolved.indexType === indexType ? @@ -47009,13 +48714,24 @@ var ts; } return type; } - function getConditionalType(root, mapper) { + function isTypicalNondistributiveConditional(root) { + return !root.isDistributive + && root.node.checkType.kind === 181 + && ts.length(root.node.checkType.elements) === 1 + && root.node.extendsType.kind === 181 + && ts.length(root.node.extendsType.elements) === 1; + } + function unwrapNondistributiveConditionalTuple(root, type) { + return isTypicalNondistributiveConditional(root) && isTupleType(type) ? getTypeArguments(type)[0] : type; + } + function getConditionalType(root, mapper, aliasSymbol, aliasTypeArguments) { var result; var extraTypes; while (true) { - var checkType = instantiateType(root.checkType, mapper); + var isUnwrapped = isTypicalNondistributiveConditional(root); + var checkType = instantiateType(unwrapNondistributiveConditionalTuple(root, getActualTypeVariable(root.checkType)), mapper); var checkTypeInstantiable = isGenericObjectType(checkType) || isGenericIndexType(checkType); - var extendsType = instantiateType(root.extendsType, mapper); + var extendsType = instantiateType(unwrapNondistributiveConditionalTuple(root, root.extendsType), mapper); if (checkType === wildcardType || extendsType === wildcardType) { return wildcardType; } @@ -47023,14 +48739,14 @@ var ts; if (root.inferTypeParameters) { var context = createInferenceContext(root.inferTypeParameters, undefined, 0); if (!checkTypeInstantiable) { - inferTypes(context.inferences, checkType, extendsType, 256 | 512); + inferTypes(context.inferences, checkType, extendsType, 512 | 1024); } - combinedMapper = mergeTypeMappers(mapper, context.mapper); + combinedMapper = mapper ? combineTypeMappers(context.mapper, mapper) : context.mapper; } - var inferredExtendsType = combinedMapper ? instantiateType(root.extendsType, combinedMapper) : extendsType; + var inferredExtendsType = combinedMapper ? instantiateType(unwrapNondistributiveConditionalTuple(root, root.extendsType), combinedMapper) : extendsType; if (!checkTypeInstantiable && !isGenericObjectType(inferredExtendsType) && !isGenericIndexType(inferredExtendsType)) { - if (!(inferredExtendsType.flags & 3) && (checkType.flags & 1 || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) { - if (checkType.flags & 1) { + if (!(inferredExtendsType.flags & 3) && ((checkType.flags & 1 && !isUnwrapped) || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) { + if (checkType.flags & 1 && !isUnwrapped) { (extraTypes || (extraTypes = [])).push(instantiateType(getTypeFromTypeNode(root.node.trueType), combinedMapper || mapper)); } var falseType_1 = getTypeFromTypeNode(root.node.falseType); @@ -47051,12 +48767,12 @@ var ts; } result = createType(16777216); result.root = root; - result.checkType = checkType; - result.extendsType = extendsType; + result.checkType = instantiateType(root.checkType, mapper); + result.extendsType = instantiateType(root.extendsType, mapper); result.mapper = mapper; result.combinedMapper = combinedMapper; - result.aliasSymbol = root.aliasSymbol; - result.aliasTypeArguments = instantiateTypes(root.aliasTypeArguments, mapper); + result.aliasSymbol = aliasSymbol || root.aliasSymbol; + result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(root.aliasTypeArguments, mapper); break; } return extraTypes ? getUnionType(ts.append(extraTypes, result)) : result; @@ -47210,7 +48926,7 @@ var ts; } function getAliasSymbolForTypeNode(node) { var host = node.parent; - while (ts.isParenthesizedTypeNode(host) || ts.isJSDocTypeExpression(host) || ts.isTypeOperatorNode(host) && host.operator === 142) { + while (ts.isParenthesizedTypeNode(host) || ts.isJSDocTypeExpression(host) || ts.isTypeOperatorNode(host) && host.operator === 143) { host = host.parent; } return ts.isTypeAlias(host) ? getSymbolOfNode(host) : undefined; @@ -47247,7 +48963,7 @@ var ts; var isSetonlyAccessor = prop.flags & 65536 && !(prop.flags & 32768); var flags = 4 | 16777216; var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 : 0)); - result.type = isSetonlyAccessor ? undefinedType : getUnionType([getTypeOfSymbol(prop), undefinedType]); + result.type = isSetonlyAccessor ? undefinedType : addOptionality(getTypeOfSymbol(prop), true); result.declarations = prop.declarations; result.nameType = getSymbolLinks(prop).nameType; result.syntheticOrigin = prop; @@ -47255,7 +48971,7 @@ var ts; } } var spread = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfoOfType(type, 0), getIndexInfoOfType(type, 1)); - spread.objectFlags |= 128 | 1048576; + spread.objectFlags |= 128 | 262144; return spread; } } @@ -47352,13 +49068,14 @@ var ts; } } var spread = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfoWithReadonly(stringIndexInfo, readonly), getIndexInfoWithReadonly(numberIndexInfo, readonly)); - spread.objectFlags |= 128 | 1048576 | 1024 | objectFlags; + spread.objectFlags |= 128 | 262144 | 4194304 | objectFlags; return spread; } function isSpreadableProperty(prop) { - return !ts.some(prop.declarations, ts.isPrivateIdentifierPropertyDeclaration) && + var _a; + return !ts.some(prop.declarations, ts.isPrivateIdentifierClassElementDeclaration) && (!(prop.flags & (8192 | 32768 | 65536)) || - !prop.declarations.some(function (decl) { return ts.isClassLike(decl.parent); })); + !((_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 && !(prop.flags & 32768); @@ -47383,11 +49100,9 @@ var ts; return type; } function getFreshTypeOfLiteralType(type) { - if (type.flags & 134220672) { + if (type.flags & 2944) { if (!type.freshType) { - var freshType = type.flags & 134217728 ? - createTemplateLiteralType(type.texts, type.types) : - createLiteralType(type.flags, type.value, type.symbol); + var freshType = createLiteralType(type.flags, type.value, type.symbol); freshType.regularType = type; freshType.freshType = freshType; type.freshType = freshType; @@ -47397,12 +49112,12 @@ var ts; return type; } function getRegularTypeOfLiteralType(type) { - return type.flags & 134220672 ? type.regularType : + return type.flags & 2944 ? type.regularType : type.flags & 1048576 ? (type.regularType || (type.regularType = mapType(type, getRegularTypeOfLiteralType))) : type; } function isFreshLiteralType(type) { - return !!(type.flags & 134220672) && type.freshType === type; + return !!(type.flags & 2944) && type.freshType === type; } function getLiteralType(value, enumId, symbol) { var qualifier = typeof value === "number" ? "#" : typeof value === "string" ? "@" : "n"; @@ -47418,7 +49133,7 @@ var ts; return type; } function getTypeFromLiteralTypeNode(node) { - if (node.literal.kind === 103) { + if (node.literal.kind === 104) { return nullType; } var links = getNodeLinks(node); @@ -47444,7 +49159,7 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 253)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 255)) { if (!ts.hasSyntacticModifier(container, 32) && (!ts.isConstructorDeclaration(container) || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; @@ -47475,17 +49190,17 @@ var ts; } function getArrayElementTypeNode(node) { switch (node.kind) { - case 186: + case 188: return getArrayElementTypeNode(node.type); - case 179: + case 181: if (node.elements.length === 1) { node = node.elements[0]; - if (node.kind === 181 || node.kind === 192 && node.dotDotDotToken) { + if (node.kind === 183 || node.kind === 194 && node.dotDotDotToken) { return getArrayElementTypeNode(node.type); } } break; - case 178: + case 180: return node.elementType; } return undefined; @@ -47494,102 +49209,101 @@ var ts; var links = getNodeLinks(node); return links.resolvedType || (links.resolvedType = node.dotDotDotToken ? getTypeFromRestTypeNode(node) : - node.questionToken && strictNullChecks ? getOptionalType(getTypeFromTypeNode(node.type)) : - getTypeFromTypeNode(node.type)); + addOptionality(getTypeFromTypeNode(node.type), true, !!node.questionToken)); } function getTypeFromTypeNode(node) { return getConditionalFlowTypeOfType(getTypeFromTypeNodeWorker(node), node); } function getTypeFromTypeNodeWorker(node) { switch (node.kind) { - case 128: - case 303: - case 304: + case 129: + case 306: + case 307: return anyType; - case 152: + case 153: return unknownType; - case 147: + case 148: return stringType; - case 144: + case 145: return numberType; - case 155: + case 156: return bigintType; - case 131: + case 132: return booleanType; - case 148: + case 149: return esSymbolType; - case 113: + case 114: return voidType; - case 150: + case 151: return undefinedType; - case 103: + case 104: return nullType; - case 141: + case 142: return neverType; - case 145: + case 146: return node.flags & 131072 && !noImplicitAny ? anyType : nonPrimitiveType; - case 136: + case 137: return intrinsicMarkerType; - case 187: - case 107: + case 189: + case 108: return getTypeFromThisTypeNode(node); - case 191: + case 193: return getTypeFromLiteralTypeNode(node); - case 173: + case 175: return getTypeFromTypeReference(node); - case 172: + case 174: return node.assertsModifier ? voidType : booleanType; - case 223: + case 225: return getTypeFromTypeReference(node); - case 176: - return getTypeFromTypeQueryNode(node); case 178: - case 179: - return getTypeFromArrayOrTupleTypeNode(node); + return getTypeFromTypeQueryNode(node); case 180: - return getTypeFromOptionalTypeNode(node); + case 181: + return getTypeFromArrayOrTupleTypeNode(node); case 182: + return getTypeFromOptionalTypeNode(node); + case 184: return getTypeFromUnionTypeNode(node); - case 183: + case 185: return getTypeFromIntersectionTypeNode(node); - case 305: + case 308: return getTypeFromJSDocNullableTypeNode(node); - case 307: + case 310: return addOptionality(getTypeFromTypeNode(node.type)); - case 192: + case 194: return getTypeFromNamedTupleTypeNode(node); - case 186: - case 306: - case 301: + case 188: + case 309: + case 303: return getTypeFromTypeNode(node.type); - case 181: + case 183: return getTypeFromRestTypeNode(node); - case 309: + case 312: return getTypeFromJSDocVariadicType(node); - case 174: - case 175: + case 176: case 177: - case 312: - case 308: - case 313: + case 179: + case 316: + case 311: + case 317: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 188: + case 190: return getTypeFromTypeOperatorNode(node); - case 189: + case 191: return getTypeFromIndexedAccessTypeNode(node); - case 190: + case 192: return getTypeFromMappedTypeNode(node); - case 184: + case 186: return getTypeFromConditionalTypeNode(node); - case 185: + case 187: return getTypeFromInferTypeNode(node); - case 193: - return getTypeFromTemplateTypeNode(node); case 195: + return getTypeFromTemplateTypeNode(node); + case 197: return getTypeFromImportTypeNode(node); - case 78: - case 157: - case 201: + case 79: + case 159: + case 203: var symbol = getSymbolAtLocation(node); return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType; default: @@ -47723,7 +49437,7 @@ var ts; } return result; } - function getObjectTypeInstantiation(type, mapper) { + function getObjectTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) { var declaration = type.objectFlags & 4 ? type.node : type.symbol.declarations[0]; var links = getNodeLinks(declaration); var target = type.objectFlags & 4 ? links.resolvedType : @@ -47736,25 +49450,28 @@ var ts; outerTypeParameters = ts.addRange(outerTypeParameters, templateTagParameters); } typeParameters = outerTypeParameters || ts.emptyArray; - typeParameters = (target.objectFlags & 4 || target.symbol.flags & 2048) && !target.aliasTypeArguments ? - ts.filter(typeParameters, function (tp) { return isTypeParameterPossiblyReferenced(tp, declaration); }) : + var allDeclarations_1 = type.objectFlags & 4 ? [declaration] : type.symbol.declarations; + typeParameters = (target.objectFlags & 4 || target.symbol.flags & 8192 || target.symbol.flags & 2048) && !target.aliasTypeArguments ? + ts.filter(typeParameters, function (tp) { return ts.some(allDeclarations_1, function (d) { return isTypeParameterPossiblyReferenced(tp, d); }); }) : typeParameters; links.outerTypeParameters = typeParameters; } if (typeParameters.length) { var combinedMapper_1 = combineTypeMappers(type.mapper, mapper); var typeArguments = ts.map(typeParameters, function (t) { return getMappedType(t, combinedMapper_1); }); - var id = getTypeListId(typeArguments); + var newAliasSymbol = aliasSymbol || type.aliasSymbol; + var newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper); + var id = getTypeListId(typeArguments) + getAliasId(newAliasSymbol, newAliasTypeArguments); if (!target.instantiations) { target.instantiations = new ts.Map(); - target.instantiations.set(getTypeListId(typeParameters), target); + target.instantiations.set(getTypeListId(typeParameters) + getAliasId(target.aliasSymbol, target.aliasTypeArguments), target); } var result = target.instantiations.get(id); if (!result) { var newMapper = createTypeMapper(typeParameters, typeArguments); - result = target.objectFlags & 4 ? createDeferredTypeReference(type.target, type.node, newMapper) : - target.objectFlags & 32 ? instantiateMappedType(target, newMapper) : - instantiateAnonymousType(target, newMapper); + result = target.objectFlags & 4 ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : + target.objectFlags & 32 ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : + instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments); target.instantiations.set(id, result); } return result; @@ -47762,30 +49479,35 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 157 || - node.parent.kind === 173 && node.parent.typeArguments && node === node.parent.typeName || - node.parent.kind === 195 && node.parent.typeArguments && node === node.parent.qualifier); + return !(node.parent.kind === 175 && node.parent.typeArguments && node === node.parent.typeName || + node.parent.kind === 197 && node.parent.typeArguments && node === node.parent.qualifier); } function isTypeParameterPossiblyReferenced(tp, node) { 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 === 230 || n.kind === 184 && ts.forEachChild(n.extendsType, containsReference)) { + if (!n || n.kind === 232 || n.kind === 186 && ts.forEachChild(n.extendsType, containsReference)) { return true; } } - return !!ts.forEachChild(node, containsReference); + return containsReference(node); } return true; function containsReference(node) { switch (node.kind) { - case 187: + case 189: return !!tp.isThisType; - case 78: + case 79: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNodeWorker(node) === tp; - case 176: + case 178: return true; + case 167: + case 166: + return !node.type && !!node.body || + ts.some(node.typeParameters, containsReference) || + ts.some(node.parameters, containsReference) || + !!node.type && containsReference(node.type); } return !!ts.forEachChild(node, containsReference); } @@ -47800,12 +49522,12 @@ var ts; } return undefined; } - function instantiateMappedType(type, mapper) { + function instantiateMappedType(type, mapper, aliasSymbol, aliasTypeArguments) { var typeVariable = getHomomorphicTypeVariable(type); if (typeVariable) { var mappedTypeVariable = instantiateType(typeVariable, mapper); if (typeVariable !== mappedTypeVariable) { - return mapType(getReducedType(mappedTypeVariable), function (t) { + return mapTypeWithAlias(getReducedType(mappedTypeVariable), function (t) { if (t.flags & (3 | 58982400 | 524288 | 2097152) && t !== wildcardType && t !== errorType) { if (!type.declaration.nameType) { if (isArrayType(t)) { @@ -47821,10 +49543,10 @@ var ts; return instantiateAnonymousType(type, prependTypeMapping(typeVariable, t, mapper)); } return t; - }); + }, aliasSymbol, aliasTypeArguments); } } - return instantiateType(getConstraintTypeFromMappedType(type), mapper) === wildcardType ? wildcardType : instantiateAnonymousType(type, mapper); + return instantiateType(getConstraintTypeFromMappedType(type), mapper) === wildcardType ? wildcardType : instantiateAnonymousType(type, mapper, aliasSymbol, aliasTypeArguments); } function getModifiedReadonlyState(state, modifiers) { return modifiers & 1 ? true : modifiers & 2 ? false : state; @@ -47862,11 +49584,11 @@ 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 && !maybeTypeOfKind(propType, 32768 | 16384) ? getOptionalType(propType) : + return strictNullChecks && modifiers & 4 && !maybeTypeOfKind(propType, 32768 | 16384) ? getOptionalType(propType, true) : strictNullChecks && modifiers & 8 && isOptional ? getTypeWithFacts(propType, 524288) : propType; } - function instantiateAnonymousType(type, mapper) { + function instantiateAnonymousType(type, mapper, aliasSymbol, aliasTypeArguments) { var result = createObjectType(type.objectFlags | 64, type.symbol); if (type.objectFlags & 32) { result.declaration = type.declaration; @@ -47878,52 +49600,55 @@ var ts; } result.target = type; result.mapper = mapper; - result.aliasSymbol = type.aliasSymbol; - result.aliasTypeArguments = instantiateTypes(type.aliasTypeArguments, mapper); + result.aliasSymbol = aliasSymbol || type.aliasSymbol; + result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper); return result; } - function getConditionalTypeInstantiation(type, mapper) { + function getConditionalTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) { var root = type.root; if (root.outerTypeParameters) { var typeArguments = ts.map(root.outerTypeParameters, function (t) { return getMappedType(t, mapper); }); - var id = getTypeListId(typeArguments); + var id = getTypeListId(typeArguments) + getAliasId(aliasSymbol, aliasTypeArguments); var result = root.instantiations.get(id); if (!result) { var newMapper = createTypeMapper(root.outerTypeParameters, typeArguments); - result = instantiateConditionalType(root, newMapper); + result = instantiateConditionalType(root, newMapper, aliasSymbol, aliasTypeArguments); root.instantiations.set(id, result); } return result; } return type; } - function instantiateConditionalType(root, mapper) { + function instantiateConditionalType(root, mapper, aliasSymbol, aliasTypeArguments) { if (root.isDistributive) { var checkType_1 = root.checkType; var instantiatedType = getMappedType(checkType_1, mapper); if (checkType_1 !== instantiatedType && instantiatedType.flags & (1048576 | 131072)) { - return mapType(instantiatedType, function (t) { return getConditionalType(root, prependTypeMapping(checkType_1, t, mapper)); }); + return mapTypeWithAlias(instantiatedType, function (t) { return getConditionalType(root, prependTypeMapping(checkType_1, t, mapper)); }, aliasSymbol, aliasTypeArguments); } } - return getConditionalType(root, mapper); + return getConditionalType(root, mapper, aliasSymbol, aliasTypeArguments); } function instantiateType(type, mapper) { - if (!(type && mapper && couldContainTypeVariables(type))) { + return type && mapper ? instantiateTypeWithAlias(type, mapper, undefined, undefined) : type; + } + function instantiateTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments) { + if (!couldContainTypeVariables(type)) { return type; } if (instantiationDepth === 50 || instantiationCount >= 5000000) { - ts.tracing.instant("checkTypes", "instantiateType_DepthLimit", { typeId: type.id, instantiationDepth: instantiationDepth, instantiationCount: instantiationCount }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes", "instantiateType_DepthLimit", { typeId: type.id, instantiationDepth: instantiationDepth, instantiationCount: instantiationCount }); error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite); return errorType; } totalInstantiationCount++; instantiationCount++; instantiationDepth++; - var result = instantiateTypeWorker(type, mapper); + var result = instantiateTypeWorker(type, mapper, aliasSymbol, aliasTypeArguments); instantiationDepth--; return result; } - function instantiateTypeWorker(type, mapper) { + function instantiateTypeWorker(type, mapper, aliasSymbol, aliasTypeArguments) { var flags = type.flags; if (flags & 262144) { return getMappedType(type, mapper); @@ -47931,12 +49656,15 @@ var ts; if (flags & 524288) { var objectFlags = type.objectFlags; if (objectFlags & (4 | 16 | 32)) { - if (objectFlags & 4 && !(type.node)) { + if (objectFlags & 4 && !type.node) { var resolvedTypeArguments = type.resolvedTypeArguments; var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper); return newTypeArguments !== resolvedTypeArguments ? createNormalizedTypeReference(type.target, newTypeArguments) : type; } - return getObjectTypeInstantiation(type, mapper); + if (objectFlags & 1024) { + return instantiateReverseMappedType(type, mapper); + } + return getObjectTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments); } return type; } @@ -47944,10 +49672,14 @@ var ts; var origin = type.flags & 1048576 ? type.origin : undefined; var types = origin && origin.flags & 3145728 ? origin.types : type.types; var newTypes = instantiateTypes(types, mapper); - return newTypes === types ? type : - flags & 2097152 || origin && origin.flags & 2097152 ? - getIntersectionType(newTypes, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) : - getUnionType(newTypes, 1, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, 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 || origin && origin.flags & 2097152 ? + getIntersectionType(newTypes, newAliasSymbol, newAliasTypeArguments) : + getUnionType(newTypes, 1, newAliasSymbol, newAliasTypeArguments); } if (flags & 4194304) { return getIndexType(instantiateType(type.type, mapper)); @@ -47959,10 +49691,12 @@ var ts; return getStringMappingType(type.symbol, instantiateType(type.type, mapper)); } if (flags & 8388608) { - return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper), type.noUncheckedIndexedAccessCandidate, undefined, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); + 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, undefined, newAliasSymbol, newAliasTypeArguments); } if (flags & 16777216) { - return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper)); + return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper), aliasSymbol, aliasTypeArguments); } if (flags & 33554432) { var maybeVariable = instantiateType(type.baseType, mapper); @@ -47979,6 +49713,21 @@ var ts; } return type; } + function instantiateReverseMappedType(type, mapper) { + var innerMappedType = instantiateType(type.mappedType, mapper); + if (!(ts.getObjectFlags(innerMappedType) & 32)) { + return type; + } + var innerIndexType = instantiateType(type.constraintType, mapper); + if (!(innerIndexType.flags & 4194304)) { + return type; + } + var instantiated = inferTypeForHomomorphicMappedType(instantiateType(type.source, mapper), innerMappedType, innerIndexType); + if (instantiated) { + return instantiated; + } + return type; + } function getPermissiveInstantiation(type) { return type.flags & (131068 | 3 | 131072) ? type : type.permissiveInstantiation || (type.permissiveInstantiation = instantiateType(type, permissiveMapper)); @@ -47998,34 +49747,34 @@ var ts; return info && createIndexInfo(instantiateType(info.type, mapper), info.isReadonly, info.declaration); } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 165 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 167 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 208: - case 209: - case 165: - case 251: + case 210: + case 211: + case 167: + case 253: return isContextSensitiveFunctionLikeDeclaration(node); - case 200: + case 202: return ts.some(node.properties, isContextSensitive); - case 199: + case 201: return ts.some(node.elements, isContextSensitive); - case 217: + case 219: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 216: + case 218: return (node.operatorToken.kind === 56 || node.operatorToken.kind === 60) && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 288: + case 290: return isContextSensitive(node.initializer); - case 207: + case 209: return isContextSensitive(node.expression); - case 281: + case 283: return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive); - case 280: { + case 282: { var initializer = node.initializer; return !!initializer && isContextSensitive(initializer); } - case 283: { + case 285: { var expression = node.expression; return !!expression && isContextSensitive(expression); } @@ -48041,7 +49790,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 209) { + if (node.kind !== 211) { var parameter = ts.firstOrUndefined(node.parameters); if (!(parameter && ts.parameterIsThisKeyword(parameter))) { return true; @@ -48051,7 +49800,7 @@ var ts; return false; } function hasContextSensitiveReturnExpression(node) { - return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 230 && isContextSensitive(node.body); + return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 232 && isContextSensitive(node.body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && @@ -48131,23 +49880,23 @@ var ts; return true; } switch (node.kind) { - case 283: - case 207: + case 285: + case 209: return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); - case 216: + case 218: switch (node.operatorToken.kind) { - case 62: + case 63: case 27: return elaborateError(node.right, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); } break; - case 200: + case 202: return elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 199: + case 201: return elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 281: + case 283: return elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 209: + case 211: return elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer); } return false; @@ -48238,7 +49987,14 @@ var ts; if (!targetPropType || targetPropType.flags & 8388608) continue; var sourcePropType = getIndexedAccessTypeOrUndefined(source, nameType); - if (sourcePropType && !checkTypeRelatedTo(sourcePropType, targetPropType, relation, undefined)) { + if (!sourcePropType) + continue; + var propName = getPropertyNameFromIndex(nameType, undefined); + var targetIsOptional = !!(propName && (getPropertyOfType(target, propName) || unknownSymbol).flags & 16777216); + var sourceIsOptional = !!(propName && (getPropertyOfType(source, propName) || unknownSymbol).flags & 16777216); + targetPropType = removeMissingType(targetPropType, targetIsOptional); + sourcePropType = removeMissingType(sourcePropType, targetIsOptional && sourceIsOptional); + if (!checkTypeRelatedTo(sourcePropType, targetPropType, relation, undefined)) { var elaborated = next && elaborateError(next, sourcePropType, targetPropType, relation, undefined, containingMessageChain, errorOutputContainer); if (elaborated) { reportedError = true; @@ -48334,16 +50090,16 @@ var ts; } function getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic) { switch (child.kind) { - case 283: + case 285: return { errorNode: child, innerExpression: child.expression, nameType: nameType }; case 11: if (child.containsOnlyTriviaWhiteSpaces) { break; } return { errorNode: child, innerExpression: undefined, nameType: nameType, errorMessage: getInvalidTextDiagnostic() }; - case 273: - case 274: - case 277: + case 275: + case 276: + case 279: return { errorNode: child, innerExpression: child, nameType: nameType }; default: return ts.Debug.assertNever(child, "Found invalid jsx child"); @@ -48485,11 +50241,11 @@ var ts; } _b = prop.kind; switch (_b) { - case 168: return [3, 2]; + case 170: return [3, 2]; + case 169: return [3, 2]; case 167: return [3, 2]; - case 165: return [3, 2]; - case 289: return [3, 2]; - case 288: return [3, 4]; + case 291: return [3, 2]; + case 290: return [3, 4]; } return [3, 6]; case 2: return [4, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; @@ -48553,8 +50309,8 @@ var ts; return 0; } var kind = target.declaration ? target.declaration.kind : 0; - var strictVariance = !(checkMode & 3) && strictFunctionTypes && kind !== 165 && - kind !== 164 && kind !== 166; + var strictVariance = !(checkMode & 3) && strictFunctionTypes && kind !== 167 && + kind !== 166 && kind !== 168; var result = -1; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { @@ -48767,7 +50523,7 @@ var ts; if (relation === assignableRelation || relation === comparableRelation) { if (s & 1) return true; - if (s & (8 | 256) && !(s & 1024) && (t & 32 || t & 256 && t & 1024)) + if (s & (8 | 256) && !(s & 1024) && (t & 32 || relation === assignableRelation && t & 256 && t & 1024)) return true; } return false; @@ -48804,7 +50560,7 @@ var ts; return false; } function isIgnoredJsxProperty(source, sourceProp) { - return ts.getObjectFlags(source) & 4096 && !isUnhyphenatedJsxName(sourceProp.escapedName); + return ts.getObjectFlags(source) & 2048 && !isUnhyphenatedJsxName(sourceProp.escapedName); } function getNormalizedType(type, writing) { while (true) { @@ -48814,6 +50570,7 @@ var ts; type.flags & 33554432 ? writing ? type.baseType : type.substitute : type.flags & 25165824 ? getSimplifiedType(type, writing) : type; + t = getSingleBaseForNonAugmentingSubtype(t) || t; if (t === type) break; type = t; @@ -48840,7 +50597,7 @@ var ts; reportIncompatibleStack(); } if (overflow) { - ts.tracing.instant("checkTypes", "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: depth }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes", "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: depth }); 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); @@ -48964,6 +50721,14 @@ var ts; } break; } + case ts.Diagnostics.Type_at_position_0_in_source_is_not_compatible_with_type_at_position_1_in_target.code: { + secondaryRootErrors.unshift([ts.Diagnostics.Type_at_position_0_in_source_is_not_compatible_with_type_at_position_1_in_target, args[0], args[1]]); + break; + } + case ts.Diagnostics.Type_at_positions_0_through_1_in_source_is_not_compatible_with_type_at_position_2_in_target.code: { + secondaryRootErrors.unshift([ts.Diagnostics.Type_at_positions_0_through_1_in_source_is_not_compatible_with_type_at_position_2_in_target, args[0], args[1], args[2]]); + break; + } default: return ts.Debug.fail("Unhandled Diagnostic: " + msg.code); } @@ -49022,6 +50787,7 @@ var ts; reportError(ts.Diagnostics._0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2, needsOriginalSource ? sourceType : generalizedSourceType, targetType, typeToString(constraint)); } else { + errorInfo = undefined; reportError(ts.Diagnostics._0_could_be_instantiated_with_an_arbitrary_type_which_could_be_unrelated_to_1, targetType, generalizedSourceType); } } @@ -49076,7 +50842,7 @@ var ts; if (isSimpleTypeRelatedTo(originalSource, originalTarget, relation, reportErrors ? reportError : undefined)) { return -1; } - reportErrorResults(originalSource, originalTarget, 0, !!(ts.getObjectFlags(originalSource) & 4096)); + reportErrorResults(originalSource, originalTarget, 0, !!(ts.getObjectFlags(originalSource) & 2048)); return 0; } var source = getNormalizedType(originalSource, false); @@ -49093,16 +50859,16 @@ var ts; target.types.length <= 3 && maybeTypeOfKind(target, 98304)) { var nullStrippedTarget = extractTypesOfKind(target, ~98304); if (!(nullStrippedTarget.flags & (1048576 | 131072))) { - if (source === nullStrippedTarget) - return -1; - target = nullStrippedTarget; + target = getNormalizedType(nullStrippedTarget, true); } + if (source === nullStrippedTarget) + return -1; } if (relation === comparableRelation && !(target.flags & 131072) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return -1; - var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096); - var isPerformingExcessPropertyChecks = !(intersectionState & 2) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 32768); + var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048); + var isPerformingExcessPropertyChecks = !(intersectionState & 2) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 16384); if (isPerformingExcessPropertyChecks) { if (hasExcessProperties(source, target, reportErrors)) { if (reportErrors) { @@ -49155,7 +50921,7 @@ var ts; } } if (result && !inPropertyCheck && (target.flags & 2097152 && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) || - isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 && getApparentType(source).flags & 3670016 && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 2097152); }))) { + isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 && getApparentType(source).flags & 3670016 && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 524288); }))) { inPropertyCheck = true; result &= recursiveTypeRelatedTo(source, target, reportErrors, 4); inPropertyCheck = false; @@ -49164,8 +50930,10 @@ var ts; return result; function reportErrorResults(source, target, result, isComparingJsxAttributes) { if (!result && reportErrors) { - source = originalSource.aliasSymbol ? originalSource : source; - target = originalTarget.aliasSymbol ? originalTarget : target; + var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource); + var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget); + source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source; + target = (originalTarget.aliasSymbol || targetHasBase) ? originalTarget : target; var maybeSuppress = overrideNextErrorInfo > 0; if (maybeSuppress) { overrideNextErrorInfo--; @@ -49204,13 +50972,13 @@ var ts; } } function traceUnionsOrIntersectionsTooLarge(source, target) { - if (!ts.tracing.isTracing()) { + if (!ts.tracing) { return; } if ((source.flags & 3145728) && (target.flags & 3145728)) { var sourceUnionOrIntersection = source; var targetUnionOrIntersection = target; - if (sourceUnionOrIntersection.objectFlags & targetUnionOrIntersection.objectFlags & 262144) { + if (sourceUnionOrIntersection.objectFlags & targetUnionOrIntersection.objectFlags & 65536) { return; } var sourceSize = sourceUnionOrIntersection.types.length; @@ -49234,11 +51002,11 @@ var ts; } traceUnionsOrIntersectionsTooLarge(source, target); if (flags & 3145728) { - var result_6 = eachTypeRelatedToSomeType(source, target); - if (result_6) { - result_6 &= eachTypeRelatedToSomeType(target, source); + var result_7 = eachTypeRelatedToSomeType(source, target); + if (result_7) { + result_7 &= eachTypeRelatedToSomeType(target, source); } - return result_6; + return result_7; } return recursiveTypeRelatedTo(source, target, false, 0); } @@ -49252,10 +51020,11 @@ var ts; return getUnionType(ts.reduceLeft(types, appendPropType, undefined) || ts.emptyArray); } function hasExcessProperties(source, target, reportErrors) { - if (!isExcessPropertyCheckTarget(target) || !noImplicitAny && ts.getObjectFlags(target) & 16384) { + var _a; + if (!isExcessPropertyCheckTarget(target) || !noImplicitAny && ts.getObjectFlags(target) & 8192) { return false; } - var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096); + var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048); if ((relation === assignableRelation || relation === comparableRelation) && (isTypeSubsetOf(globalObjectType, target) || (!isComparingJsxAttributes && isEmptyObjectType(target)))) { return false; @@ -49288,7 +51057,7 @@ var ts; } } else { - var objectLiteralDeclaration_1 = source.symbol && ts.firstOrUndefined(source.symbol.declarations); + var objectLiteralDeclaration_1 = ((_a = source.symbol) === null || _a === void 0 ? void 0 : _a.declarations) && ts.firstOrUndefined(source.symbol.declarations); var suggestion = void 0; if (prop.valueDeclaration && ts.findAncestor(prop.valueDeclaration, function (d) { return d === objectLiteralDeclaration_1; }) && ts.getSourceFileOfNode(objectLiteralDeclaration_1) === ts.getSourceFileOfNode(errorNode)) { var propDeclaration = prop.valueDeclaration; @@ -49317,11 +51086,11 @@ var ts; } } }; - for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) { - var prop = _a[_i]; - var state_4 = _loop_16(prop); - if (typeof state_4 === "object") - return state_4.value; + for (var _i = 0, _b = getPropertiesOfType(source); _i < _b.length; _i++) { + var prop = _b[_i]; + var state_5 = _loop_16(prop); + if (typeof state_5 === "object") + return state_5.value; } return false; } @@ -49343,8 +51112,17 @@ var ts; } function typeRelatedToSomeType(source, target, reportErrors) { var targetTypes = target.types; - if (target.flags & 1048576 && containsType(targetTypes, source)) { - return -1; + if (target.flags & 1048576) { + if (containsType(targetTypes, source)) { + return -1; + } + var match = getMatchingUnionConstituentForType(target, source); + if (match) { + var related = isRelatedTo(source, match, false); + if (related) { + return related; + } + } } for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { var type = targetTypes_1[_i]; @@ -49487,8 +51265,12 @@ var ts; targetStack = []; } else { + var broadestEquivalentId = id.split(",").map(function (i) { return i.replace(/-\d+/g, function (_match, offset) { + var index = ts.length(id.slice(0, offset).match(/[-=]/g) || undefined); + return "=" + index; + }); }).join(","); for (var i = 0; i < maybeCount; i++) { - if (id === maybeKeys[i]) { + if (id === maybeKeys[i] || broadestEquivalentId === maybeKeys[i]) { return 3; } } @@ -49518,7 +51300,7 @@ var ts; }; } if (expandingFlags === 3) { - ts.tracing.instant("checkTypes", "recursiveTypeRelatedTo_DepthLimit", { + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes", "recursiveTypeRelatedTo_DepthLimit", { sourceId: source.id, sourceIdStack: sourceStack.map(function (t) { return t.id; }), targetId: target.id, @@ -49549,9 +51331,9 @@ var ts; return result; } function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) { - ts.tracing.push("checkTypes", "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes", "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id }); var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; } function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState) { @@ -49570,6 +51352,15 @@ var ts; if (target.flags & 2097152) { return typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2); } + if (relation === comparableRelation && target.flags & 131068) { + var constraints = ts.sameMap(source.types, function (t) { return t.flags & 131068 ? t : getBaseConstraintOfType(t) || unknownType; }); + if (constraints !== source.types) { + source = getIntersectionType(constraints); + if (!(source.flags & 2097152)) { + return isRelatedTo(source, target, false); + } + } + } return someTypeRelatedToType(source, target, false, 1); } var flags = source.flags & target.flags; @@ -49577,21 +51368,21 @@ var ts; if (flags & 4194304) { return isRelatedTo(source.type, target.type, false); } - var result_7 = 0; + var result_8 = 0; if (flags & 8388608) { - if (result_7 = isRelatedTo(source.objectType, target.objectType, false)) { - if (result_7 &= isRelatedTo(source.indexType, target.indexType, false)) { - return result_7; + if (result_8 = isRelatedTo(source.objectType, target.objectType, false)) { + if (result_8 &= isRelatedTo(source.indexType, target.indexType, false)) { + return result_8; } } } if (flags & 16777216) { if (source.root.isDistributive === target.root.isDistributive) { - if (result_7 = isRelatedTo(source.checkType, target.checkType, false)) { - if (result_7 &= isRelatedTo(source.extendsType, target.extendsType, false)) { - if (result_7 &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), false)) { - if (result_7 &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), false)) { - return result_7; + if (result_8 = isRelatedTo(source.checkType, target.checkType, false)) { + if (result_8 &= isRelatedTo(source.extendsType, target.extendsType, false)) { + if (result_8 &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), false)) { + if (result_8 &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), false)) { + return result_8; } } } @@ -49656,19 +51447,42 @@ var ts; } } else if (target.flags & 8388608) { + if (source.flags & 8388608) { + if (result = isRelatedTo(source.objectType, target.objectType, reportErrors)) { + result &= isRelatedTo(source.indexType, target.indexType, reportErrors); + } + if (result) { + resetErrorInfo(saveErrorInfo); + return result; + } + if (reportErrors) { + originalErrorInfo = errorInfo; + } + } if (relation === assignableRelation || relation === comparableRelation) { var objectType = target.objectType; var indexType = target.indexType; var baseObjectType = getBaseConstraintOfType(objectType) || objectType; var baseIndexType = getBaseConstraintOfType(indexType) || indexType; if (!isGenericObjectType(baseObjectType) && !isGenericIndexType(baseIndexType)) { - var accessFlags = 2 | (baseObjectType !== objectType ? 1 : 0); - var constraint = getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, target.noUncheckedIndexedAccessCandidate, undefined, accessFlags); - if (constraint && (result = isRelatedTo(source, constraint, reportErrors))) { - return result; + var accessFlags = 4 | (baseObjectType !== objectType ? 2 : 0); + var constraint = getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, accessFlags); + if (constraint) { + if (reportErrors && originalErrorInfo) { + resetErrorInfo(saveErrorInfo); + } + if (result = isRelatedTo(source, constraint, reportErrors)) { + return result; + } + if (reportErrors && originalErrorInfo && errorInfo) { + errorInfo = countMessageChainBreadth([originalErrorInfo]) <= countMessageChainBreadth([errorInfo]) ? originalErrorInfo : errorInfo; + } } } } + if (reportErrors) { + originalErrorInfo = undefined; + } } else if (isGenericMappedType(target) && !target.declaration.nameType) { var template = getTemplateTypeFromMappedType(target); @@ -49707,25 +51521,39 @@ var ts; } } } - else if (target.flags & 134217728 && source.flags & 128) { - if (isPatternLiteralType(target)) { - var result_8 = inferLiteralsFromTemplateLiteralType(source, target); - if (result_8 && ts.every(result_8, function (r, i) { return isStringLiteralTypeValueParsableAsType(r, target.types[i]); })) { - return -1; - } + else if (target.flags & 16777216) { + var c = target; + var skipTrue = !isTypeAssignableTo(getPermissiveInstantiation(c.checkType), getPermissiveInstantiation(c.extendsType)); + var skipFalse = !skipTrue && isConditionalTypeAlwaysTrueDisregardingInferTypes(c); + var distributionMapper = void 0; + var checkVar = getActualTypeVariable(c.root.checkType); + if (c.root.isDistributive && checkVar.flags & 262144) { + var newParam = cloneTypeParameter(checkVar); + distributionMapper = prependTypeMapping(checkVar, newParam, c.mapper); + newParam.mapper = distributionMapper; + } + var localResult = void 0; + if (skipTrue || (localResult = isRelatedTo(source, distributionMapper ? instantiateType(getTypeFromTypeNode(c.root.node.trueType), distributionMapper) : getTrueTypeFromConditionalType(c), false))) { + if (!skipFalse) { + localResult = (localResult || 3) & isRelatedTo(source, distributionMapper ? instantiateType(getTypeFromTypeNode(c.root.node.falseType), distributionMapper) : getFalseTypeFromConditionalType(c), false); + } + } + if (localResult) { + resetErrorInfo(saveErrorInfo); + return localResult; } } - if (source.flags & 8650752) { - if (source.flags & 8388608 && target.flags & 8388608) { - if (result = isRelatedTo(source.objectType, target.objectType, reportErrors)) { - result &= isRelatedTo(source.indexType, target.indexType, reportErrors); - } - if (result) { - resetErrorInfo(saveErrorInfo); - return result; - } + else if (target.flags & 134217728) { + if (source.flags & 134217728) { + instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)); } - else { + var result_9 = inferTypesFromTemplateLiteralType(source, target); + if (result_9 && ts.every(result_9, function (r, i) { return isValidTypeForTemplateLiteralPlaceholder(r, target.types[i]); })) { + return -1; + } + } + if (source.flags & 8650752) { + if (!(source.flags & 8388608 && target.flags & 8388608)) { var constraint = getConstraintOfType(source); if (!constraint || (source.flags & 262144 && constraint.flags & 1)) { if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864))) { @@ -49737,7 +51565,7 @@ var ts; resetErrorInfo(saveErrorInfo); return result; } - else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, reportErrors, undefined, intersectionState)) { + else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, reportErrors && !(target.flags & source.flags & 262144), undefined, intersectionState)) { resetErrorInfo(saveErrorInfo); return result; } @@ -49750,17 +51578,10 @@ var ts; } } else if (source.flags & 134217728) { - if (target.flags & 134217728) { - if (source.texts.length === target.texts.length && - source.types.length === target.types.length && - ts.every(source.texts, function (t, i) { return t === target.texts[i]; }) && - ts.every(instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)).types, function (t, i) { return !!(target.types[i].flags & (1 | 4)) || !!isRelatedTo(t, target.types[i], false); })) { - return -1; - } - } - else { - var constraint = getBaseConstraintOfType(source); - if (result = isRelatedTo(constraint && constraint !== source ? constraint : stringType, target, reportErrors)) { + if (!(target.flags & 134217728)) { + var baseConstraint = getBaseConstraintOfType(source); + var constraint = baseConstraint && baseConstraint !== source ? baseConstraint : stringType; + if (result = isRelatedTo(constraint, target, reportErrors)) { resetErrorInfo(saveErrorInfo); return result; } @@ -49788,7 +51609,7 @@ var ts; var mapper = void 0; if (sourceParams) { var ctx = createInferenceContext(sourceParams, undefined, 0, isRelatedTo); - inferTypes(ctx.inferences, target.extendsType, sourceExtends, 256 | 512); + inferTypes(ctx.inferences, target.extendsType, sourceExtends, 512 | 1024); sourceExtends = instantiateType(sourceExtends, ctx.mapper); mapper = ctx.mapper; } @@ -49841,7 +51662,7 @@ var ts; return 0; } if (ts.getObjectFlags(source) & 4 && ts.getObjectFlags(target) & 4 && source.target === target.target && - !(ts.getObjectFlags(source) & 8192 || ts.getObjectFlags(target) & 8192)) { + !(ts.getObjectFlags(source) & 4096 || ts.getObjectFlags(target) & 4096)) { var variances = getVariances(source.target); if (variances === ts.emptyArray) { return 1; @@ -49859,7 +51680,7 @@ var ts; return 0; } } - else if ((relation === subtypeRelation || relation === strictSubtypeRelation) && isEmptyObjectType(target) && ts.getObjectFlags(target) & 32768 && !isEmptyObjectType(source)) { + else if ((relation === subtypeRelation || relation === strictSubtypeRelation) && isEmptyObjectType(target) && ts.getObjectFlags(target) & 16384 && !isEmptyObjectType(source)) { return 0; } if (source.flags & (524288 | 2097152) && target.flags & 524288) { @@ -49887,14 +51708,19 @@ var ts; if (source.flags & (524288 | 2097152) && target.flags & 1048576) { var objectOnlyTarget = extractTypesOfKind(target, 524288 | 2097152 | 33554432); if (objectOnlyTarget.flags & 1048576) { - var result_9 = typeRelatedToDiscriminatedType(source, objectOnlyTarget); - if (result_9) { - return result_9; + var result_10 = typeRelatedToDiscriminatedType(source, objectOnlyTarget); + if (result_10) { + return result_10; } } } } return 0; + function countMessageChainBreadth(info) { + if (!info) + return 0; + return ts.reduceLeft(info, function (value, chain) { return value + 1 + countMessageChainBreadth(chain.next); }, 0); + } function relateVariances(sourceTypeArguments, targetTypeArguments, variances, intersectionState) { if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors, intersectionState)) { return result; @@ -49931,13 +51757,13 @@ var ts; var modifiersRelated = relation === comparableRelation || (relation === identityRelation ? getMappedTypeModifiers(source) === getMappedTypeModifiers(target) : getCombinedMappedTypeOptionality(source) <= getCombinedMappedTypeOptionality(target)); if (modifiersRelated) { - var result_10; + var result_11; var targetConstraint = getConstraintTypeFromMappedType(target); var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), makeFunctionTypeMapper(getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMarkers : reportUnreliableMarkers)); - if (result_10 = isRelatedTo(targetConstraint, sourceConstraint, reportErrors)) { + if (result_11 = isRelatedTo(targetConstraint, sourceConstraint, 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), reportErrors); + return result_11 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), reportErrors); } } } @@ -49951,9 +51777,9 @@ var ts; var numCombinations = 1; for (var _i = 0, sourcePropertiesFiltered_1 = sourcePropertiesFiltered; _i < sourcePropertiesFiltered_1.length; _i++) { var sourceProperty = sourcePropertiesFiltered_1[_i]; - numCombinations *= countTypes(getTypeOfSymbol(sourceProperty)); + numCombinations *= countTypes(getNonMissingTypeOfSymbol(sourceProperty)); if (numCombinations > 25) { - ts.tracing.instant("checkTypes", "typeRelatedToDiscriminatedType_DepthLimit", { sourceId: source.id, targetId: target.id, numCombinations: numCombinations }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes", "typeRelatedToDiscriminatedType_DepthLimit", { sourceId: source.id, targetId: target.id, numCombinations: numCombinations }); return 0; } } @@ -49961,7 +51787,7 @@ var ts; var excludedProperties = new ts.Set(); for (var i = 0; i < sourcePropertiesFiltered.length; i++) { var sourceProperty = sourcePropertiesFiltered[i]; - var sourcePropertyType = getTypeOfSymbol(sourceProperty); + var sourcePropertyType = getNonMissingTypeOfSymbol(sourceProperty); sourceDiscriminantTypes[i] = sourcePropertyType.flags & 1048576 ? sourcePropertyType.types : [sourcePropertyType]; @@ -49986,8 +51812,8 @@ var ts; } }; for (var i = 0; i < sourcePropertiesFiltered.length; i++) { - var state_6 = _loop_18(i); - switch (state_6) { + var state_7 = _loop_18(i); + switch (state_7) { case "continue-outer": continue outer; } } @@ -50000,9 +51826,9 @@ var ts; }; for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) { var combination = discriminantCombinations_1[_a]; - var state_5 = _loop_17(combination); - if (typeof state_5 === "object") - return state_5.value; + var state_6 = _loop_17(combination); + if (typeof state_6 === "object") + return state_6.value; } var result = -1; for (var _b = 0, matchingTypes_1 = matchingTypes; _b < matchingTypes_1.length; _b++) { @@ -50044,40 +51870,9 @@ var ts; } function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState) { var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48); - var source = getTypeOfSourceProperty(sourceProp); - if (ts.getCheckFlags(targetProp) & 65536 && !getSymbolLinks(targetProp).type) { - var links = getSymbolLinks(targetProp); - ts.Debug.assertIsDefined(links.deferralParent); - ts.Debug.assertIsDefined(links.deferralConstituents); - var unionParent = !!(links.deferralParent.flags & 1048576); - var result_11 = unionParent ? 0 : -1; - var targetTypes = links.deferralConstituents; - for (var _i = 0, targetTypes_3 = targetTypes; _i < targetTypes_3.length; _i++) { - var targetType = targetTypes_3[_i]; - var related = isRelatedTo(source, targetType, false, undefined, unionParent ? 0 : 2); - if (!unionParent) { - if (!related) { - return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); - } - result_11 &= related; - } - else { - if (related) { - return related; - } - } - } - if (unionParent && !result_11 && targetIsOptional) { - result_11 = isRelatedTo(source, undefinedType); - } - if (unionParent && !result_11 && reportErrors) { - return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); - } - return result_11; - } - else { - return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors, undefined, intersectionState); - } + var effectiveTarget = addOptionality(getNonMissingTypeOfSymbol(targetProp), false, targetIsOptional); + var effectiveSource = getTypeOfSourceProperty(sourceProp); + return isRelatedTo(effectiveSource, effectiveTarget, reportErrors, undefined, intersectionState); } function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState, skipOptional) { var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp); @@ -50195,7 +51990,7 @@ var ts; } return 0; } - if (!targetRestFlag && sourceRestFlag) { + if (!targetRestFlag && (sourceRestFlag || targetArity < sourceArity)) { if (reportErrors) { if (sourceMinLength < targetMinLength) { reportError(ts.Diagnostics.Target_requires_0_element_s_but_source_may_have_fewer, targetMinLength); @@ -50242,10 +52037,11 @@ var ts; } } var sourceType = !isTupleType(source) ? sourceTypeArguments[0] : - i < startCount || i >= targetArity - endCount ? sourceTypeArguments[sourceIndex] : + i < startCount || i >= targetArity - endCount ? removeMissingType(sourceTypeArguments[sourceIndex], !!(sourceFlags & targetFlags & 2)) : getElementTypeOfSliceOfTupleType(source, startCount, endCount) || neverType; var targetType = targetTypeArguments[i]; - var targetCheckType = sourceFlags & 8 && targetFlags & 4 ? createArrayType(targetType) : targetType; + var targetCheckType = sourceFlags & 8 && targetFlags & 4 ? createArrayType(targetType) : + removeMissingType(targetType, !!(targetFlags & 2)); var related = isRelatedTo(sourceType, targetCheckType, reportErrors, undefined, intersectionState); if (!related) { if (reportErrors) { @@ -50279,7 +52075,7 @@ var ts; var sourceProp = _a[_i]; if (!getPropertyOfObjectType(target, sourceProp.escapedName)) { var sourceType = getTypeOfSymbol(sourceProp); - if (!(sourceType === undefinedType || sourceType === undefinedWideningType || sourceType === optionalType)) { + if (!(sourceType.flags & 32768)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(sourceProp), typeToString(target)); } @@ -50296,7 +52092,7 @@ var ts; if (!(targetProp.flags & 4194304) && (!numericNamesOnly || isNumericLiteralName(name) || name === "length")) { var sourceProp = getPropertyOfType(source, name); if (sourceProp && sourceProp !== targetProp) { - var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, intersectionState, relation === comparableRelation); + var related = propertyRelatedTo(source, target, sourceProp, targetProp, getNonMissingTypeOfSymbol, reportErrors, intersectionState, relation === comparableRelation); if (!related) { return 0; } @@ -50377,7 +52173,7 @@ var ts; var targetSignature = ts.first(targetSignatures); result = signatureRelatedTo(sourceSignature, targetSignature, eraseGenerics, reportErrors, incompatibleReporter(sourceSignature, targetSignature)); if (!result && reportErrors && kind === 1 && (sourceObjectFlags & targetObjectFlags) && - (((_a = targetSignature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 166 || ((_b = sourceSignature.declaration) === null || _b === void 0 ? void 0 : _b.kind) === 166)) { + (((_a = targetSignature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 168 || ((_b = sourceSignature.declaration) === null || _b === void 0 ? void 0 : _b.kind) === 168)) { var constructSignatureToString = function (signature) { return signatureToString(signature, undefined, 262144, kind); }; @@ -50480,9 +52276,15 @@ var ts; return indexTypesIdenticalTo(source, target, kind); } var targetType = getIndexTypeOfType(target, kind); - if (!targetType || targetType.flags & 1 && !sourceIsPrimitive) { + if (!targetType) { return -1; } + if (targetType.flags & 1 && !sourceIsPrimitive) { + var stringIndexType = kind === 0 ? targetType : getIndexTypeOfType(target, 0); + if (stringIndexType && stringIndexType.flags & 1) { + return -1; + } + } if (isGenericMappedType(source)) { return getIndexTypeOfType(target, 0) ? isRelatedTo(getTemplateTypeFromMappedType(source), targetType, reportErrors) : 0; } @@ -50618,7 +52420,7 @@ var ts; } function getMarkerTypeReference(type, source, target) { var result = createTypeReference(type, ts.map(type.typeParameters, function (t) { return t === source ? target : t; })); - result.objectFlags |= 8192; + result.objectFlags |= 4096; return result; } function getAliasVariances(symbol) { @@ -50634,7 +52436,7 @@ var ts; if (typeParameters === void 0) { typeParameters = ts.emptyArray; } var variances = cache.variances; if (!variances) { - ts.tracing.push("checkTypes", "getVariancesWorker", { arity: typeParameters.length, id: (_c = (_a = cache.id) !== null && _a !== void 0 ? _a : (_b = cache.declaredType) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : -1 }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes", "getVariancesWorker", { arity: typeParameters.length, id: (_c = (_a = cache.id) !== null && _a !== void 0 ? _a : (_b = cache.declaredType) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : -1 }); cache.variances = ts.emptyArray; variances = []; var _loop_19 = function (tp) { @@ -50665,7 +52467,7 @@ var ts; _loop_19(tp); } cache.variances = variances; - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } return variances; } @@ -50690,7 +52492,7 @@ var ts; return !!(ts.getObjectFlags(type) & 4) && !type.node; } function isTypeReferenceWithGenericArguments(type) { - return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); + return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return !!(t.flags & 262144) || isTypeReferenceWithGenericArguments(t); }); } function getTypeReferenceId(type, typeParameters, depth) { if (depth === void 0) { depth = 0; } @@ -50759,21 +52561,19 @@ var ts; return !forEachProperty(targetProp, function (tp) { return ts.getDeclarationModifierFlagsFromSymbol(tp) & 16 ? !isPropertyInClassDerivedFrom(sourceProp, getDeclaringClass(tp)) : false; }); } - function isClassDerivedFromDeclaringClasses(checkClass, prop) { - return forEachProperty(prop, function (p) { return ts.getDeclarationModifierFlagsFromSymbol(p) & 16 ? + function isClassDerivedFromDeclaringClasses(checkClass, prop, writing) { + return forEachProperty(prop, function (p) { return ts.getDeclarationModifierFlagsFromSymbol(p, writing) & 16 ? !hasBaseType(checkClass, getDeclaringClass(p)) : false; }) ? undefined : checkClass; } function isDeeplyNestedType(type, stack, depth) { if (depth >= 5) { var identity_1 = getRecursionIdentity(type); - if (identity_1) { - var count = 0; - for (var i = 0; i < depth; i++) { - if (getRecursionIdentity(stack[i]) === identity_1) { - count++; - if (count >= 5) { - return true; - } + var count = 0; + for (var i = 0; i < depth; i++) { + if (getRecursionIdentity(stack[i]) === identity_1) { + count++; + if (count >= 5) { + return true; } } } @@ -50792,6 +52592,9 @@ var ts; return type.target; } } + if (type.flags & 262144) { + return type.symbol; + } if (type.flags & 8388608) { do { type = type.objectType; @@ -50801,7 +52604,7 @@ var ts; if (type.flags & 16777216) { return type.root; } - return undefined; + return type; } function isPropertyIdenticalTo(sourceProp, targetProp) { return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0; @@ -50923,6 +52726,9 @@ var ts; 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; }); @@ -50954,9 +52760,35 @@ var ts; function isArrayLikeType(type) { return isArrayType(type) || !(type.flags & 98304) && isTypeAssignableTo(type, anyReadonlyArrayType); } + function getSingleBaseForNonAugmentingSubtype(type) { + if (!(ts.getObjectFlags(type) & 4) || !(ts.getObjectFlags(type.target) & 3)) { + return undefined; + } + if (ts.getObjectFlags(type) & 33554432) { + return ts.getObjectFlags(type) & 67108864 ? type.cachedEquivalentBaseType : undefined; + } + type.objectFlags |= 33554432; + var target = type.target; + var bases = getBaseTypes(target); + if (bases.length !== 1) { + return undefined; + } + if (getMembersOfSymbol(type.symbol).size) { + return undefined; + } + var instantiatedBase = !ts.length(target.typeParameters) ? bases[0] : instantiateType(bases[0], createTypeMapper(target.typeParameters, getTypeArguments(type).slice(0, target.typeParameters.length))); + if (ts.length(getTypeArguments(type)) > ts.length(target.typeParameters)) { + instantiatedBase = getTypeWithThisArgument(instantiatedBase, ts.last(getTypeArguments(type))); + } + type.objectFlags |= 67108864; + return type.cachedEquivalentBaseType = instantiatedBase; + } + function isEmptyLiteralType(type) { + return strictNullChecks ? type === implicitNeverType : type === undefinedWideningType; + } function isEmptyArrayLiteralType(type) { - var elementType = isArrayType(type) ? getTypeArguments(type)[0] : undefined; - return elementType === undefinedWideningType || elementType === implicitNeverType; + var elementType = getElementTypeOfArrayType(type); + return !!elementType && isEmptyLiteralType(elementType); } function isTupleLikeType(type) { return isTupleType(type) || !!getPropertyOfType(type, "0"); @@ -50980,6 +52812,13 @@ var ts; function isUnitType(type) { return !!(type.flags & 109440); } + function isUnitLikeType(type) { + return type.flags & 2097152 ? ts.some(type.types, isUnitType) : + !!(type.flags & 109440); + } + function extractUnitType(type) { + return type.flags & 2097152 ? ts.find(type.types, isUnitType) || type : type; + } function isLiteralType(type) { return type.flags & 16 ? true : type.flags & 1048576 ? type.flags & 1024 ? true : ts.every(type.types, isUnitType) : @@ -50987,7 +52826,7 @@ var ts; } function getBaseTypeOfLiteralType(type) { return type.flags & 1024 ? getBaseTypeOfEnumLiteralType(type) : - type.flags & 134217856 ? stringType : + type.flags & 128 ? stringType : type.flags & 256 ? numberType : type.flags & 2048 ? bigintType : type.flags & 512 ? booleanType : @@ -50996,7 +52835,7 @@ var ts; } function getWidenedLiteralType(type) { return type.flags & 1024 && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(type) : - type.flags & 134217856 && isFreshLiteralType(type) ? stringType : + type.flags & 128 && isFreshLiteralType(type) ? stringType : type.flags & 256 && isFreshLiteralType(type) ? numberType : type.flags & 2048 && isFreshLiteralType(type) ? bigintType : type.flags & 512 && isFreshLiteralType(type) ? booleanType : @@ -51113,18 +52952,19 @@ var ts; missing === 65536 ? getUnionType([type, nullType]) : getUnionType([type, undefinedType, nullType]); } - function getOptionalType(type) { + function getOptionalType(type, isProperty) { + if (isProperty === void 0) { isProperty = false; } ts.Debug.assert(strictNullChecks); - return type.flags & 32768 ? type : getUnionType([type, undefinedType]); + return type.flags & 32768 ? type : getUnionType([type, isProperty ? missingType : undefinedType]); } function getGlobalNonNullableTypeInstantiation(type) { + var reducedType = getTypeWithFacts(type, 2097152); if (!deferredGlobalNonNullableTypeAlias) { deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288, undefined) || unknownSymbol; } - if (deferredGlobalNonNullableTypeAlias !== unknownSymbol) { - return getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]); - } - return getTypeWithFacts(type, 2097152); + return deferredGlobalNonNullableTypeAlias !== unknownSymbol ? + getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [reducedType]) : + reducedType; } function getNonNullableType(type) { return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type; @@ -51146,6 +52986,12 @@ var ts; ts.isOptionalChain(expression) ? removeOptionalTypeMarker(exprType) : exprType; } + function removeMissingType(type, isOptional) { + return strictOptionalProperties && isOptional ? filterType(type, function (t) { return t !== missingType; }) : type; + } + function containsMissingType(type) { + return strictOptionalProperties && (type === missingType || type.flags & 1048576 && containsType(type.types, missingType)); + } function isCoercibleUnderDoubleEquals(source, target) { return ((source.flags & (8 | 4 | 512)) !== 0) && ((target.flags & (8 | 4 | 16)) !== 0); @@ -51153,7 +52999,7 @@ var ts; function isObjectTypeWithInferableIndex(type) { return type.flags & 2097152 ? ts.every(type.types, isObjectTypeWithInferableIndex) : !!(type.symbol && (type.symbol.flags & (4096 | 2048 | 384 | 512)) !== 0 && - !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 2048 && isObjectTypeWithInferableIndex(type.source)); + !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 1024 && isObjectTypeWithInferableIndex(type.source)); } function createSymbolWithType(source, type) { var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8); @@ -51181,7 +53027,7 @@ var ts; return members; } function getRegularTypeOfObjectLiteral(type) { - if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 32768)) { + if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 16384)) { return type; } var regularType = type.regularType; @@ -51192,7 +53038,7 @@ var ts; var members = transformTypeOfMembers(type, getRegularTypeOfObjectLiteral); var regularNew = createAnonymousType(resolved.symbol, members, resolved.callSignatures, resolved.constructSignatures, resolved.stringIndexInfo, resolved.numberIndexInfo); regularNew.flags = resolved.flags; - regularNew.objectFlags |= resolved.objectFlags & ~32768; + regularNew.objectFlags |= resolved.objectFlags & ~16384; type.regularType = regularNew; return regularNew; } @@ -51222,7 +53068,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) & 1024)) { + if (isObjectLiteralType(t) && !(ts.getObjectFlags(t) & 4194304)) { for (var _b = 0, _c = getPropertiesOfType(t); _b < _c.length; _b++) { var prop = _c[_b]; names.set(prop.escapedName, prop); @@ -51247,7 +53093,7 @@ var ts; if (cached) { return cached; } - var result = createSymbolWithType(prop, undefinedType); + var result = createSymbolWithType(prop, missingType); result.flags |= 16777216; undefinedProperties.set(prop.escapedName, result); return result; @@ -51269,14 +53115,14 @@ var ts; var stringIndexInfo = getIndexInfoOfType(type, 0); var numberIndexInfo = getIndexInfoOfType(type, 1); var result = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, stringIndexInfo && createIndexInfo(getWidenedType(stringIndexInfo.type), stringIndexInfo.isReadonly), numberIndexInfo && createIndexInfo(getWidenedType(numberIndexInfo.type), numberIndexInfo.isReadonly)); - result.objectFlags |= (ts.getObjectFlags(type) & (16384 | 2097152)); + result.objectFlags |= (ts.getObjectFlags(type) & (8192 | 524288)); return result; } function getWidenedType(type) { return getWidenedTypeWithContext(type, undefined); } function getWidenedTypeWithContext(type, context) { - if (ts.getObjectFlags(type) & 1572864) { + if (ts.getObjectFlags(type) & 393216) { if (context === undefined && type.widened) { return type.widened; } @@ -51307,7 +53153,7 @@ var ts; } function reportWideningErrorsInType(type) { var errorReported = false; - if (ts.getObjectFlags(type) & 524288) { + if (ts.getObjectFlags(type) & 131072) { if (type.flags & 1048576) { if (ts.some(type.types, isEmptyObjectType)) { errorReported = true; @@ -51333,7 +53179,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) & 524288) { + if (ts.getObjectFlags(t) & 131072) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, symbolToString(p), typeToString(getWidenedType(t))); } @@ -51351,12 +53197,12 @@ var ts; } var diagnostic; switch (declaration.kind) { - case 216: - case 163: - case 162: + case 218: + case 165: + case 164: 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 160: + case 162: var param = declaration; if (ts.isIdentifier(param.name) && (ts.isCallSignatureDeclaration(param.parent) || ts.isMethodSignature(param.parent) || ts.isFunctionTypeNode(param.parent)) && @@ -51371,22 +53217,22 @@ 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 198: + case 200: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; if (!noImplicitAny) { return; } break; - case 308: + case 311: error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; - case 251: - case 165: - case 164: + case 253: case 167: - case 168: - case 208: - case 209: + case 166: + case 169: + case 170: + case 210: + case 211: if (noImplicitAny && !declaration.name) { if (wideningKind === 3) { error(declaration, ts.Diagnostics.Generator_implicitly_has_yield_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type_annotation, typeAsString); @@ -51400,7 +53246,7 @@ var ts; wideningKind === 3 ? 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 190: + case 192: if (noImplicitAny) { error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); } @@ -51411,7 +53257,7 @@ var ts; errorOrSuggestion(noImplicitAny, declaration, diagnostic, ts.declarationNameToString(ts.getNameOfDeclaration(declaration)), typeAsString); } function reportErrorsFromWidening(declaration, type, wideningKind) { - if (produceDiagnostics && noImplicitAny && ts.getObjectFlags(type) & 524288 && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) { + if (produceDiagnostics && noImplicitAny && ts.getObjectFlags(type) & 131072 && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) { if (!reportWideningErrorsInType(type)) { reportImplicitAny(declaration, type, wideningKind); } @@ -51523,23 +53369,23 @@ var ts; } function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); - if (objectFlags & 67108864) { - return !!(objectFlags & 134217728); + if (objectFlags & 1048576) { + return !!(objectFlags & 2097152); } var result = !!(type.flags & 465829888 || type.flags & 524288 && !isNonGenericTopLevelType(type) && (objectFlags & 4 && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) || objectFlags & 16 && type.symbol && type.symbol.flags & (16 | 8192 | 32 | 2048 | 4096) && type.symbol.declarations || - objectFlags & (32 | 131072)) || + objectFlags & (32 | 1024 | 8388608)) || type.flags & 3145728 && !(type.flags & 1024) && !isNonGenericTopLevelType(type) && ts.some(type.types, couldContainTypeVariables)); if (type.flags & 3899393) { - type.objectFlags |= 67108864 | (result ? 134217728 : 0); + type.objectFlags |= 1048576 | (result ? 2097152 : 0); } return result; } function isNonGenericTopLevelType(type) { if (type.aliasSymbol && !type.aliasTypeArguments) { - var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 254); - return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 297 ? true : n.kind === 256 ? false : "quit"; })); + var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 256); + return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 299 ? true : n.kind === 258 ? false : "quit"; })); } return false; } @@ -51581,7 +53427,7 @@ var ts; return type; } function isPartiallyInferableType(type) { - return !(ts.getObjectFlags(type) & 2097152) || + return !(ts.getObjectFlags(type) & 524288) || isObjectLiteralType(type) && ts.some(getPropertiesOfType(type), function (prop) { return isPartiallyInferableType(getTypeOfSymbol(prop)); }) || isTupleType(type) && ts.some(getTypeArguments(type), isPartiallyInferableType); } @@ -51599,14 +53445,18 @@ var ts; source.target.elementFlags; return createTupleType(elementTypes, elementFlags, source.target.readonly, source.target.labeledElementDeclarations); } - var reversed = createObjectType(2048 | 16, undefined); + var reversed = createObjectType(1024 | 16, undefined); reversed.source = source; reversed.mappedType = target; reversed.constraintType = constraint; return reversed; } function getTypeOfReverseMappedSymbol(symbol) { - return inferReverseMappedType(symbol.propertyType, symbol.mappedType, symbol.constraintType); + var links = getSymbolLinks(symbol); + if (!links.type) { + links.type = inferReverseMappedType(symbol.propertyType, symbol.mappedType, symbol.constraintType); + } + return links.type; } function inferReverseMappedType(sourceType, target, constraint) { var typeParameter = getIndexedAccessType(constraint.type, getTypeParameterFromMappedType(target)); @@ -51690,49 +53540,94 @@ var ts; var flags = scanner.getTokenFlags(); return success && result === 9 && scanner.getTextPos() === (s.length + 1) && !(flags & 512); } - function isStringLiteralTypeValueParsableAsType(s, target) { - if (target.flags & 1048576) { - return !!forEachType(target, function (t) { return isStringLiteralTypeValueParsableAsType(s, t); }); - } - switch (target) { - case stringType: return true; - case numberType: return s.value !== "" && isFinite(+(s.value)); - case bigintType: return s.value !== "" && isValidBigIntString(s.value); - case trueType: return s.value === "true"; - case falseType: return s.value === "false"; - case undefinedType: return s.value === "undefined"; - case nullType: return s.value === "null"; - default: return !!(target.flags & 1); - } - } - function inferLiteralsFromTemplateLiteralType(source, target) { - var value = source.value; - var texts = target.texts; - var lastIndex = texts.length - 1; - var startText = texts[0]; - var endText = texts[lastIndex]; - if (!(value.startsWith(startText) && value.slice(startText.length).endsWith(endText))) + function isValidTypeForTemplateLiteralPlaceholder(source, target) { + if (source === target || target.flags & (1 | 4)) { + return true; + } + if (source.flags & 128) { + var value = source.value; + return !!(target.flags & 8 && value !== "" && isFinite(+value) || + target.flags & 64 && value !== "" && isValidBigIntString(value) || + target.flags & (512 | 98304) && value === target.intrinsicName); + } + if (source.flags & 134217728) { + 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 ? inferFromLiteralPartsToTemplateLiteral([source.value], ts.emptyArray, target) : + source.flags & 134217728 ? + ts.arraysEqual(source.texts, target.texts) ? ts.map(source.types, getStringLikeTypeForType) : + inferFromLiteralPartsToTemplateLiteral(source.texts, source.types, target) : + undefined; + } + function getStringLikeTypeForType(type) { + return type.flags & (1 | 402653316) ? type : getTemplateLiteralType(["", ""], [type]); + } + function inferFromLiteralPartsToTemplateLiteral(sourceTexts, sourceTypes, target) { + var lastSourceIndex = sourceTexts.length - 1; + var sourceStartText = sourceTexts[0]; + var sourceEndText = sourceTexts[lastSourceIndex]; + var targetTexts = target.texts; + var lastTargetIndex = targetTexts.length - 1; + var targetStartText = targetTexts[0]; + var targetEndText = targetTexts[lastTargetIndex]; + if (lastSourceIndex === 0 && sourceStartText.length < targetStartText.length + targetEndText.length || + !sourceStartText.startsWith(targetStartText) || !sourceEndText.endsWith(targetEndText)) return undefined; + var remainingEndText = sourceEndText.slice(0, sourceEndText.length - targetEndText.length); var matches = []; - var str = value.slice(startText.length, value.length - endText.length); - var pos = 0; - for (var i = 1; i < lastIndex; i++) { - var delim = texts[i]; - var delimPos = delim.length > 0 ? str.indexOf(delim, pos) : pos < str.length ? pos + 1 : -1; - if (delimPos < 0) + var seg = 0; + var pos = targetStartText.length; + for (var i = 1; i < lastTargetIndex; i++) { + var delim = targetTexts[i]; + if (delim.length > 0) { + var s = seg; + var p = pos; + while (true) { + p = getSourceText(s).indexOf(delim, p); + if (p >= 0) + break; + s++; + if (s === sourceTexts.length) + return undefined; + p = 0; + } + addMatch(s, p); + pos += delim.length; + } + else if (pos < getSourceText(seg).length) { + addMatch(seg, pos + 1); + } + else if (seg < lastSourceIndex) { + addMatch(seg + 1, 0); + } + else { return undefined; - matches.push(getLiteralType(str.slice(pos, delimPos))); - pos = delimPos + delim.length; + } } - matches.push(getLiteralType(str.slice(pos))); + addMatch(lastSourceIndex, getSourceText(lastSourceIndex).length); return matches; + function getSourceText(index) { + return index < lastSourceIndex ? sourceTexts[index] : remainingEndText; + } + function addMatch(s, p) { + var matchType = s === seg ? + getLiteralType(getSourceText(s).slice(pos, p)) : + getTemplateLiteralType(__spreadArray(__spreadArray([sourceTexts[seg].slice(pos)], sourceTexts.slice(seg + 1, s)), [getSourceText(s).slice(0, p)]), sourceTypes.slice(seg, s)); + matches.push(matchType); + seg = s; + pos = p; + } } function inferTypes(inferences, originalSource, originalTarget, priority, contravariant) { if (priority === void 0) { priority = 0; } if (contravariant === void 0) { contravariant = false; } var bivariant = false; var propagationType; - var inferencePriority = 1024; + var inferencePriority = 2048; var allowComplexConstraintInference = true; var visited; var sourceStack; @@ -51788,8 +53683,8 @@ var ts; target = getActualTypeVariable(target); } if (target.flags & 8650752) { - if (ts.getObjectFlags(source) & 2097152 || source === nonInferrableAnyType || source === silentNeverType || - (priority & 64 && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) { + if (ts.getObjectFlags(source) & 524288 || source === nonInferrableAnyType || source === silentNeverType || + (priority & 128 && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) { return; } var inference = getInferenceInfoForType(target); @@ -51814,7 +53709,7 @@ var ts; clearCachedInferences(inferences); } } - if (!(priority & 64) && target.flags & 262144 && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) { + if (!(priority & 128) && target.flags & 262144 && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) { inference.topLevel = false; clearCachedInferences(inferences); } @@ -51850,7 +53745,7 @@ var ts; else if ((isLiteralType(source) || source.flags & 4) && target.flags & 4194304) { var empty = createEmptyObjectTypeFromStringLiteral(source); contravariant = !contravariant; - inferWithPriority(empty, target.type, 128); + inferWithPriority(empty, target.type, 256); contravariant = !contravariant; } else if (source.flags & 8388608 && target.flags & 8388608) { @@ -51862,6 +53757,13 @@ var ts; inferFromTypes(source.type, target.type); } } + else if (source.flags & 33554432) { + inferFromTypes(source.baseType, target); + var oldPriority = priority; + priority |= 4; + inferFromTypes(source.substitute, target); + priority = oldPriority; + } else if (target.flags & 16777216) { invokeOnce(source, target, inferToConditionalType); } @@ -51880,7 +53782,7 @@ var ts; } else { source = getReducedType(source); - if (!(priority & 256 && source.flags & (2097152 | 465829888))) { + if (!(priority & 512 && source.flags & (2097152 | 465829888))) { var apparentSource = getApparentType(source); if (apparentSource !== source && allowComplexConstraintInference && !(apparentSource.flags & (524288 | 2097152))) { allowComplexConstraintInference = false; @@ -51908,24 +53810,20 @@ var ts; } (visited || (visited = new ts.Map())).set(key, -1); var saveInferencePriority = inferencePriority; - inferencePriority = 1024; + inferencePriority = 2048; var saveExpandingFlags = expandingFlags; - var sourceIdentity = getRecursionIdentity(source) || source; - var targetIdentity = getRecursionIdentity(target) || target; - if (sourceIdentity && ts.contains(sourceStack, sourceIdentity)) + var sourceIdentity = getRecursionIdentity(source); + var targetIdentity = getRecursionIdentity(target); + if (ts.contains(sourceStack, sourceIdentity)) expandingFlags |= 1; - if (targetIdentity && ts.contains(targetStack, targetIdentity)) + if (ts.contains(targetStack, targetIdentity)) expandingFlags |= 2; if (expandingFlags !== 3) { - if (sourceIdentity) - (sourceStack || (sourceStack = [])).push(sourceIdentity); - if (targetIdentity) - (targetStack || (targetStack = [])).push(targetIdentity); + (sourceStack || (sourceStack = [])).push(sourceIdentity); + (targetStack || (targetStack = [])).push(targetIdentity); action(source, target); - if (targetIdentity) - targetStack.pop(); - if (sourceIdentity) - sourceStack.pop(); + targetStack.pop(); + sourceStack.pop(); } else { inferencePriority = -1; @@ -51965,7 +53863,7 @@ var ts; } } function inferFromContravariantTypes(source, target) { - if (strictFunctionTypes || priority & 512) { + if (strictFunctionTypes || priority & 1024) { contravariant = !contravariant; inferFromTypes(source, target); contravariant = !contravariant; @@ -52013,7 +53911,7 @@ var ts; else { for (var i = 0; i < sources.length; i++) { var saveInferencePriority = inferencePriority; - inferencePriority = 1024; + inferencePriority = 2048; inferFromTypes(sources[i], t); if (inferencePriority === priority) matched_1[i] = true; @@ -52071,15 +53969,15 @@ var ts; if (inference && !inference.isFixed && !isFromInferenceBlockedSource(source)) { var inferredType = inferTypeForHomomorphicMappedType(source, target, constraintType); if (inferredType) { - inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 2097152 ? - 8 : - 4); + inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 524288 ? + 16 : + 8); } } return true; } if (constraintType.flags & 262144) { - inferWithPriority(getIndexType(source), constraintType, 16); + inferWithPriority(getIndexType(source), constraintType, 32); var extendedConstraint = getConstraintOfType(constraintType); if (extendedConstraint && inferToMappedType(source, target, extendedConstraint)) { return true; @@ -52102,16 +54000,14 @@ var ts; } else { var savePriority = priority; - priority |= contravariant ? 32 : 0; + priority |= contravariant ? 64 : 0; var targetTypes = [getTrueTypeFromConditionalType(target), getFalseTypeFromConditionalType(target)]; inferToMultipleTypes(source, targetTypes, target.flags); priority = savePriority; } } function inferToTemplateLiteralType(source, target) { - var matches = source.flags & 128 ? inferLiteralsFromTemplateLiteralType(source, target) : - source.flags & 134217728 && ts.arraysEqual(source.texts, target.texts) ? source.types : - undefined; + var matches = inferTypesFromTemplateLiteralType(source, target); var types = target.types; for (var i = 0; i < types.length; i++) { inferFromTypes(matches ? matches[i] : neverType, types[i]); @@ -52213,7 +54109,7 @@ var ts; var sourceLen = sourceSignatures.length; var targetLen = targetSignatures.length; var len = sourceLen < targetLen ? sourceLen : targetLen; - var skipParameters = !!(ts.getObjectFlags(source) & 2097152); + var skipParameters = !!(ts.getObjectFlags(source) & 524288); for (var i = 0; i < len; i++) { inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i]), skipParameters); } @@ -52222,19 +54118,20 @@ var ts; if (!skipParameters) { var saveBivariant = bivariant; var kind = target.declaration ? target.declaration.kind : 0; - bivariant = bivariant || kind === 165 || kind === 164 || kind === 166; + bivariant = bivariant || kind === 167 || kind === 166 || kind === 168; applyToParameterTypes(source, target, inferFromContravariantTypes); bivariant = saveBivariant; } applyToReturnTypes(source, target, inferFromTypes); } function inferFromIndexTypes(source, target) { + var priority = (ts.getObjectFlags(source) & ts.getObjectFlags(target) & 32) ? 8 : 0; var targetStringIndexType = getIndexTypeOfType(target, 0); if (targetStringIndexType) { var sourceIndexType = getIndexTypeOfType(source, 0) || getImplicitIndexTypeOfType(source, 0); if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetStringIndexType); + inferWithPriority(sourceIndexType, targetStringIndexType, priority); } } var targetNumberIndexType = getIndexTypeOfType(target, 1); @@ -52243,13 +54140,13 @@ var ts; getIndexTypeOfType(source, 0) || getImplicitIndexTypeOfType(source, 1); if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetNumberIndexType); + inferWithPriority(sourceIndexType, targetNumberIndexType, priority); } } } } function isTypeOrBaseIdenticalTo(s, t) { - return isTypeIdenticalTo(s, t) || !!(t.flags & 4 && s.flags & 134217856 || t.flags & 8 && s.flags & 256); + return isTypeIdenticalTo(s, t) || !!(t.flags & 4 && s.flags & 128 || t.flags & 8 && s.flags & 256); } function isTypeCloselyMatchedBy(s, t) { return !!(s.flags & 524288 && t.flags & 524288 && s.symbol && s.symbol === t.symbol || @@ -52263,7 +54160,7 @@ var ts; return !!(ts.getObjectFlags(type) & 128); } function isObjectOrArrayLiteralType(type) { - return !!(ts.getObjectFlags(type) & (128 | 65536)); + return !!(ts.getObjectFlags(type) & (128 | 32768)); } function unionObjectAndArrayLiteralCandidates(candidates) { if (candidates.length > 1) { @@ -52276,7 +54173,7 @@ var ts; return candidates; } function getContravariantInference(inference) { - return inference.priority & 208 ? getIntersectionType(inference.contraCandidates) : getCommonSubtype(inference.contraCandidates); + return inference.priority & 416 ? getIntersectionType(inference.contraCandidates) : getCommonSubtype(inference.contraCandidates); } function getCovariantInference(inference, signature) { var candidates = unionObjectAndArrayLiteralCandidates(inference.candidates); @@ -52286,7 +54183,7 @@ var ts; var baseCandidates = primitiveConstraint ? ts.sameMap(candidates, getRegularTypeOfLiteralType) : widenLiteralTypes ? ts.sameMap(candidates, getWidenedLiteralType) : candidates; - var unwidenedType = inference.priority & 208 ? + var unwidenedType = inference.priority & 416 ? getUnionType(baseCandidates, 2) : getCommonSupertype(baseCandidates); return getWidenedType(unwidenedType); @@ -52384,7 +54281,7 @@ var ts; case "BigUint64Array": return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_1_or_later; default: - if (node.parent.kind === 289) { + if (node.parent.kind === 291) { return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer; } else { @@ -52401,20 +54298,23 @@ var ts; return links.resolvedSymbol; } function isInTypeQuery(node) { - return !!ts.findAncestor(node, function (n) { return n.kind === 176 ? true : n.kind === 78 || n.kind === 157 ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 178 ? true : n.kind === 79 || n.kind === 159 ? false : "quit"; }); } function getFlowCacheKey(node, declaredType, initialType, flowContainer) { switch (node.kind) { - case 78: + case 79: var symbol = getResolvedSymbol(node); - return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + (isConstraintPosition(node) ? "@" : "") + getSymbolId(symbol) : undefined; - case 107: + return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + getSymbolId(symbol) : undefined; + case 108: return "0|" + (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType); - case 225: - case 207: + case 227: + case 209: return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); - case 201: - case 202: + case 159: + var left = getFlowCacheKey(node.left, declaredType, initialType, flowContainer); + return left && left + "." + node.right.escapedText; + case 203: + case 204: var propName = getAccessedPropertyName(node); if (propName !== undefined) { var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); @@ -52425,43 +54325,51 @@ var ts; } function isMatchingReference(source, target) { switch (target.kind) { - case 207: - case 225: + case 209: + case 227: return isMatchingReference(source, target.expression); - case 216: + case 218: return (ts.isAssignmentExpression(target) && isMatchingReference(source, target.left)) || (ts.isBinaryExpression(target) && target.operatorToken.kind === 27 && isMatchingReference(source, target.right)); } switch (source.kind) { - case 78: + case 228: + return target.kind === 228 + && source.keywordToken === target.keywordToken + && source.name.escapedText === target.name.escapedText; case 79: - return target.kind === 78 && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 249 || target.kind === 198) && + case 80: + return target.kind === 79 && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 251 || target.kind === 200) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 107: - return target.kind === 107; - case 105: - return target.kind === 105; - case 225: - case 207: + case 108: + return target.kind === 108; + case 106: + return target.kind === 106; + case 227: + case 209: return isMatchingReference(source.expression, target); - case 201: - case 202: + case 203: + case 204: return ts.isAccessExpression(target) && getAccessedPropertyName(source) === getAccessedPropertyName(target) && isMatchingReference(source.expression, target.expression); - case 216: + case 159: + return ts.isAccessExpression(target) && + source.right.escapedText === getAccessedPropertyName(target) && + isMatchingReference(source.left, target.expression); + case 218: return (ts.isBinaryExpression(source) && source.operatorToken.kind === 27 && isMatchingReference(source.right, target)); } return false; } function containsTruthyCheck(source, target) { return isMatchingReference(source, target) || - (target.kind === 216 && target.operatorToken.kind === 55 && + (target.kind === 218 && target.operatorToken.kind === 55 && (containsTruthyCheck(source, target.left) || containsTruthyCheck(source, target.right))); } function getAccessedPropertyName(access) { - return access.kind === 201 ? access.name.escapedText : + return access.kind === 203 ? access.name.escapedText : ts.isStringOrNumericLiteralLike(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) : undefined; } @@ -52511,6 +54419,75 @@ var ts; } return result; } + function mapTypesByKeyProperty(types, name) { + var map = new ts.Map(); + var count = 0; + var _loop_20 = function (type) { + if (type.flags & (524288 | 2097152 | 58982400)) { + var discriminant = getTypeOfPropertyOfType(type, name); + if (discriminant) { + if (!isLiteralType(discriminant)) { + return { value: undefined }; + } + var duplicate_1 = false; + forEachType(discriminant, function (t) { + var id = getTypeId(getRegularTypeOfLiteralType(t)); + var existing = map.get(id); + if (!existing) { + map.set(id, type); + } + else if (existing !== unknownType) { + map.set(id, unknownType); + duplicate_1 = true; + } + }); + if (!duplicate_1) + count++; + } + } + }; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var type = types_17[_i]; + var state_8 = _loop_20(type); + if (typeof state_8 === "object") + return state_8.value; + } + return count >= 10 && count * 2 >= types.length ? map : undefined; + } + function getKeyPropertyName(unionType) { + var types = unionType.types; + if (types.length < 10 || ts.getObjectFlags(unionType) & 65536) { + return undefined; + } + if (unionType.keyPropertyName === undefined) { + var keyPropertyName = ts.forEach(types, function (t) { + return t.flags & (524288 | 58982400) ? + ts.forEach(getPropertiesOfType(t), function (p) { return isUnitType(getTypeOfSymbol(p)) ? p.escapedName : undefined; }) : + undefined; + }); + var mapByKeyProperty = keyPropertyName && mapTypesByKeyProperty(types, keyPropertyName); + unionType.keyPropertyName = mapByKeyProperty ? keyPropertyName : ""; + unionType.constituentMap = mapByKeyProperty; + } + return unionType.keyPropertyName.length ? unionType.keyPropertyName : undefined; + } + function getConstituentTypeForKeyType(unionType, keyType) { + var _a; + var result = (_a = unionType.constituentMap) === null || _a === void 0 ? void 0 : _a.get(getTypeId(getRegularTypeOfLiteralType(keyType))); + return result !== unknownType ? result : undefined; + } + function getMatchingUnionConstituentForType(unionType, type) { + var keyPropertyName = getKeyPropertyName(unionType); + var propType = keyPropertyName && getTypeOfPropertyOfType(type, keyPropertyName); + return propType && getConstituentTypeForKeyType(unionType, propType); + } + function getMatchingUnionConstituentForObjectLiteral(unionType, node) { + var keyPropertyName = getKeyPropertyName(unionType); + var propNode = keyPropertyName && ts.find(node.properties, function (p) { return p.symbol && p.kind === 290 && + p.symbol.escapedName === keyPropertyName && isPossiblyDiscriminantValue(p.initializer); }); + var propType = propNode && getTypeOfExpression(propNode.initializer); + return propType && getConstituentTypeForKeyType(unionType, propType); + } function isOrContainsMatchingReference(source, target) { return isMatchingReference(source, target) || containsMatchingReference(source, target); } @@ -52523,7 +54500,7 @@ var ts; } } } - if (expression.expression.kind === 201 && + if (expression.expression.kind === 203 && isOrContainsMatchingReference(reference, expression.expression.expression)) { return true; } @@ -52563,20 +54540,13 @@ var ts; } return declaredType; } - function getTypeFactsOfTypes(types) { - var result = 0; - for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { - var t = types_17[_i]; - result |= getTypeFacts(t); - } - return result; - } function isFunctionObjectType(type) { var resolved = resolveStructuredTypeMembers(type); return !!(resolved.callSignatures.length || resolved.constructSignatures.length || resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType)); } - function getTypeFacts(type) { + function getTypeFacts(type, ignoreObjects) { + if (ignoreObjects === void 0) { ignoreObjects = false; } var flags = type.flags; if (flags & 4) { return strictNullChecks ? 16317953 : 16776705; @@ -52613,7 +54583,7 @@ var ts; (type === falseType || type === regularFalseType) ? 12121864 : 7927560 : (type === falseType || type === regularFalseType) ? 12580616 : 16774920; } - if (flags & 524288) { + if (flags & 524288 && !ignoreObjects) { return ts.getObjectFlags(type) & 16 && isEmptyObjectType(type) ? strictNullChecks ? 16318463 : 16777215 : isFunctionObjectType(type) ? @@ -52636,11 +54606,15 @@ var ts; return 0; } if (flags & 465829888) { - return !isPatternLiteralType(type) ? getTypeFacts(getBaseConstraintOfType(type) || unknownType) : + return !isPatternLiteralType(type) ? getTypeFacts(getBaseConstraintOfType(type) || unknownType, ignoreObjects) : strictNullChecks ? 7929345 : 16776705; } - if (flags & 3145728) { - return getTypeFactsOfTypes(type.types); + if (flags & 1048576) { + return ts.reduceLeft(type.types, function (facts, t) { return facts | getTypeFacts(t, ignoreObjects); }, 0); + } + if (flags & 2097152) { + ignoreObjects || (ignoreObjects = maybeTypeOfKind(type, 131068)); + return ts.reduceLeft(type.types, function (facts, t) { return facts & getTypeFacts(t, ignoreObjects); }, 16777215); } return 16777215; } @@ -52648,18 +54622,16 @@ var ts; return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; }); } function getTypeWithDefault(type, defaultExpression) { - if (defaultExpression) { - var defaultType = getTypeOfExpression(defaultExpression); - return getUnionType([getTypeWithFacts(type, 524288), defaultType]); - } - return type; + return defaultExpression ? + getUnionType([getNonUndefinedType(type), getTypeOfExpression(defaultExpression)]) : + type; } function getTypeOfDestructuredProperty(type, name) { var nameType = getLiteralTypeFromPropertyName(name); if (!isTypeUsableAsPropertyName(nameType)) return errorType; var text = getPropertyNameFromType(nameType); - return getConstraintForLocation(getTypeOfPropertyOfType(type, text), name) || + return getTypeOfPropertyOfType(type, text) || isNumericLiteralName(text) && includeUndefinedInIndexSignature(getIndexTypeOfType(type, 1)) || includeUndefinedInIndexSignature(getIndexTypeOfType(type, 0)) || errorType; @@ -52680,15 +54652,15 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(65, type, undefinedType, undefined) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 199 && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 288 && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 201 && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 290 && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 216 && parent.parent.left === parent || - parent.parent.kind === 239 && parent.parent.initializer === parent; + return parent.parent.kind === 218 && parent.parent.left === parent || + parent.parent.kind === 241 && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -52705,21 +54677,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 238: + case 240: return stringType; - case 239: + case 241: return checkRightHandSideOfForOf(parent) || errorType; - case 216: + case 218: return getAssignedTypeOfBinaryExpression(parent); - case 210: + case 212: return undefinedType; - case 199: + case 201: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 220: + case 222: return getAssignedTypeOfSpreadExpression(parent); - case 288: + case 290: return getAssignedTypeOfPropertyAssignment(parent); - case 289: + case 291: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -52727,7 +54699,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 196 ? + var type = pattern.kind === 198 ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -52742,35 +54714,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 238) { + if (node.parent.parent.kind === 240) { return stringType; } - if (node.parent.parent.kind === 239) { + if (node.parent.parent.kind === 241) { return checkRightHandSideOfForOf(node.parent.parent) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 249 ? + return node.kind === 251 ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function isEmptyArrayAssignment(node) { - return node.kind === 249 && node.initializer && + return node.kind === 251 && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 198 && node.parent.kind === 216 && + node.kind !== 200 && node.parent.kind === 218 && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 207: + case 209: return getReferenceCandidate(node.expression); - case 216: + case 218: switch (node.operatorToken.kind) { - case 62: - case 74: + case 63: case 75: case 76: + case 77: return getReferenceCandidate(node.left); case 27: return getReferenceCandidate(node.right); @@ -52780,13 +54752,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 207 || - parent.kind === 216 && parent.operatorToken.kind === 62 && parent.left === node || - parent.kind === 216 && parent.operatorToken.kind === 27 && parent.right === node ? + return parent.kind === 209 || + parent.kind === 218 && parent.operatorToken.kind === 63 && parent.left === node || + parent.kind === 218 && parent.operatorToken.kind === 27 && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 284) { + if (clause.kind === 286) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -52806,7 +54778,7 @@ var ts; var witnesses = []; for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) { var clause = _a[_i]; - if (clause.kind === 284) { + if (clause.kind === 286) { if (ts.isStringLiteralLike(clause.expression)) { witnesses.push(clause.expression.text); continue; @@ -52842,14 +54814,35 @@ var ts; function forEachType(type, f) { return type.flags & 1048576 ? ts.forEach(type.types, f) : f(type); } + function someType(type, f) { + return type.flags & 1048576 ? ts.some(type.types, f) : f(type); + } function everyType(type, f) { return type.flags & 1048576 ? ts.every(type.types, f) : f(type); } + function everyContainedType(type, f) { + return type.flags & 3145728 ? ts.every(type.types, f) : f(type); + } function filterType(type, f) { if (type.flags & 1048576) { var types = type.types; var filtered = ts.filter(types, f); - return filtered === types ? type : getUnionTypeFromSortedList(filtered, type.objectFlags); + if (filtered === types) { + return type; + } + var origin = type.origin; + var newOrigin = void 0; + if (origin && origin.flags & 1048576) { + var originTypes = origin.types; + var originFiltered = ts.filter(originTypes, function (t) { return !!(t.flags & 1048576) || f(t); }); + if (originTypes.length - originFiltered.length === types.length - filtered.length) { + if (originFiltered.length === 1) { + return originFiltered[0]; + } + newOrigin = createOriginUnionOrIntersectionType(1048576, originFiltered); + } + } + return getUnionTypeFromSortedList(filtered, type.objectFlags, undefined, undefined, newOrigin); } return type.flags & 131072 || f(type) ? type : neverType; } @@ -52882,6 +54875,11 @@ var ts; } return changed ? mappedTypes && getUnionType(mappedTypes, noReductions ? 0 : 1) : type; } + function mapTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments) { + return type.flags & 1048576 && aliasSymbol ? + getUnionType(ts.map(type.types, mapper), 1, aliasSymbol, aliasTypeArguments) : + mapType(type, mapper); + } function getConstituentCount(type) { return type.flags & 3145728 ? type.types.length : 1; } @@ -52954,21 +54952,21 @@ var ts; var root = getReferenceRoot(node); var parent = root.parent; var isLengthPushOrUnshift = ts.isPropertyAccessExpression(parent) && (parent.name.escapedText === "length" || - parent.parent.kind === 203 + parent.parent.kind === 205 && ts.isIdentifier(parent.name) && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 202 && + var isElementAssignment = parent.kind === 204 && parent.expression === root && - parent.parent.kind === 216 && - parent.parent.operatorToken.kind === 62 && + parent.parent.kind === 218 && + parent.parent.operatorToken.kind === 63 && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296); return isLengthPushOrUnshift || isElementAssignment; } function isDeclarationWithExplicitTypeAnnotation(declaration) { - return (declaration.kind === 249 || declaration.kind === 160 || - declaration.kind === 163 || declaration.kind === 162) && + return (declaration.kind === 251 || declaration.kind === 162 || + declaration.kind === 165 || declaration.kind === 164) && !!ts.getEffectiveTypeAnnotationNode(declaration); } function getExplicitTypeOfSymbol(symbol, diagnostic) { @@ -52987,7 +54985,7 @@ var ts; if (isDeclarationWithExplicitTypeAnnotation(declaration)) { return getTypeOfSymbol(symbol); } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 239) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 241) { var statement = declaration.parent.parent; var expressionType = getTypeOfDottedName(statement.expression, undefined); if (expressionType) { @@ -53004,18 +55002,32 @@ var ts; function getTypeOfDottedName(node, diagnostic) { if (!(node.flags & 16777216)) { switch (node.kind) { - case 78: + case 79: var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node)); return getExplicitTypeOfSymbol(symbol.flags & 2097152 ? resolveAlias(symbol) : symbol, diagnostic); - case 107: + case 108: return getExplicitThisType(node); - case 105: + case 106: return checkSuperExpression(node); - case 201: + case 203: { var type = getTypeOfDottedName(node.expression, diagnostic); - var prop = type && getPropertyOfType(type, node.name.escapedText); - return prop && getExplicitTypeOfSymbol(prop, diagnostic); - case 207: + if (type) { + var name = node.name; + var prop = void 0; + if (ts.isPrivateIdentifier(name)) { + if (!type.symbol) { + return undefined; + } + prop = getPropertyOfType(type, ts.getSymbolNameForPrivateIdentifier(type.symbol, name.escapedText)); + } + else { + prop = getPropertyOfType(type, name.escapedText); + } + return prop && getExplicitTypeOfSymbol(prop, diagnostic); + } + return undefined; + } + case 209: return getTypeOfDottedName(node.expression, diagnostic); } } @@ -53025,10 +55037,10 @@ var ts; var signature = links.effectsSignature; if (signature === undefined) { var funcType = void 0; - if (node.parent.kind === 233) { + if (node.parent.kind === 235) { funcType = getTypeOfDottedName(node.expression, undefined); } - else if (node.expression.kind !== 105) { + else if (node.expression.kind !== 106) { if (ts.isOptionalChain(node)) { funcType = checkNonNullType(getOptionalExpressionType(checkExpression(node.expression), node.expression), node.expression); } @@ -53069,7 +55081,7 @@ var ts; } function isFalseExpression(expr) { var node = ts.skipParentheses(expr); - return node.kind === 94 || node.kind === 216 && (node.operatorToken.kind === 55 && (isFalseExpression(node.left) || isFalseExpression(node.right)) || + return node.kind === 95 || node.kind === 218 && (node.operatorToken.kind === 55 && (isFalseExpression(node.left) || isFalseExpression(node.right)) || node.operatorToken.kind === 56 && isFalseExpression(node.left) && isFalseExpression(node.right)); } function isReachableFlowNodeWorker(flow, noCacheCheck) { @@ -53150,7 +55162,7 @@ var ts; flow = flow.antecedent; } else if (flags & 512) { - if (flow.node.expression.kind === 105) { + if (flow.node.expression.kind === 106) { return true; } flow = flow.antecedent; @@ -53190,7 +55202,7 @@ var ts; var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); sharedFlowCount = sharedFlowStart; var resultType = ts.getObjectFlags(evolvedType) & 256 && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType); - if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 225 && getTypeWithFacts(resultType, 2097152).flags & 131072) { + if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 227 && !(resultType.flags & 131072) && getTypeWithFacts(resultType, 2097152).flags & 131072) { return declaredType; } return resultType; @@ -53203,7 +55215,7 @@ var ts; } function getTypeAtFlowNode(flow) { if (flowDepth === 2000) { - ts.tracing.instant("checkTypes", "getTypeAtFlowNode_DepthLimit", { flowId: flow.id }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes", "getTypeAtFlowNode_DepthLimit", { flowId: flow.id }); flowAnalysisDisabled = true; reportFlowControlError(reference); return errorType; @@ -53268,9 +55280,9 @@ var ts; else if (flags & 2) { var container = flow.node; if (container && container !== flowContainer && - reference.kind !== 201 && - reference.kind !== 202 && - reference.kind !== 107) { + reference.kind !== 203 && + reference.kind !== 204 && + reference.kind !== 108) { flow = container.flowNode; continue; } @@ -53290,7 +55302,7 @@ var ts; } function getInitialOrAssignedType(flow) { var node = flow.node; - return getConstraintForLocation(node.kind === 249 || node.kind === 198 ? + return getNarrowableTypeForReference(node.kind === 251 || node.kind === 200 ? getInitialType(node) : getAssignedType(node), reference); } @@ -53322,23 +55334,23 @@ var ts; } if (ts.isVariableDeclaration(node) && (ts.isInJSFile(node) || ts.isVarConst(node))) { var init = ts.getDeclaredExpandoInitializer(node); - if (init && (init.kind === 208 || init.kind === 209)) { + if (init && (init.kind === 210 || init.kind === 211)) { return getTypeAtFlowNode(flow.antecedent); } } return declaredType; } - if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 238 && isMatchingReference(reference, node.parent.parent.expression)) { + if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 240 && isMatchingReference(reference, node.parent.parent.expression)) { return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); } return undefined; } function narrowTypeByAssertion(type, expr) { var node = ts.skipParentheses(expr); - if (node.kind === 94) { + if (node.kind === 95) { return unreachableNeverType; } - if (node.kind === 216) { + if (node.kind === 218) { if (node.operatorToken.kind === 55) { return narrowTypeByAssertion(narrowTypeByAssertion(type, node.left), node.right); } @@ -53369,7 +55381,7 @@ var ts; function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 203 ? + var expr = node.kind === 205 ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -53377,7 +55389,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256) { var evolvedType_1 = type; - if (node.kind === 203) { + if (node.kind === 205) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -53417,7 +55429,7 @@ var ts; if (isMatchingReference(reference, expr)) { type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } - else if (expr.kind === 211 && isMatchingReference(reference, expr.expression)) { + else if (expr.kind === 213 && isMatchingReference(reference, expr.expression)) { type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } else { @@ -53425,12 +55437,12 @@ var ts; if (optionalChainContainsReference(expr, reference)) { type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & (32768 | 131072)); }); } - else if (expr.kind === 211 && optionalChainContainsReference(expr.expression, reference)) { + else if (expr.kind === 213 && optionalChainContainsReference(expr.expression, reference)) { type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & 131072 || t.flags & 128 && t.value === "undefined"); }); } } if (isMatchingReferenceDiscriminant(expr, type)) { - type = narrowTypeByDiscriminant(type, expr, function (t) { return narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd); }); + type = narrowTypeBySwitchOnDiscriminantProperty(type, expr, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } } return createFlowType(type, isIncomplete(flowType)); @@ -53559,16 +55571,42 @@ var ts; if (propName === undefined) { return type; } - var propType = getTypeOfPropertyOfType(type, propName); + var removeNullable = strictNullChecks && ts.isOptionalChain(access) && maybeTypeOfKind(type, 98304); + var propType = getTypeOfPropertyOfType(removeNullable ? getTypeWithFacts(type, 2097152) : type, propName); if (!propType) { return type; } + propType = removeNullable ? getOptionalType(propType) : propType; var narrowedPropType = narrowType(propType); return filterType(type, function (t) { var discriminantType = getTypeOfPropertyOrIndexSignature(t, propName); return !(discriminantType.flags & 131072) && isTypeComparableTo(discriminantType, narrowedPropType); }); } + function narrowTypeByDiscriminantProperty(type, access, operator, value, assumeTrue) { + if ((operator === 36 || operator === 37) && type.flags & 1048576) { + var keyPropertyName = getKeyPropertyName(type); + if (keyPropertyName && keyPropertyName === getAccessedPropertyName(access)) { + var candidate_2 = getConstituentTypeForKeyType(type, getTypeOfExpression(value)); + if (candidate_2) { + return operator === (assumeTrue ? 36 : 37) ? candidate_2 : + isUnitType(getTypeOfPropertyOfType(candidate_2, keyPropertyName) || unknownType) ? filterType(type, function (t) { return t !== candidate_2; }) : + type; + } + } + } + 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 && 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) { + return candidate; + } + } + return narrowTypeByDiscriminant(type, access, function (t) { return narrowTypeBySwitchOnDiscriminant(t, switchStatement, clauseStart, clauseEnd); }); + } function narrowTypeByTruthiness(type, expr, assumeTrue) { if (isMatchingReference(reference, expr)) { return getTypeWithFacts(type, assumeTrue ? 4194304 : 8388608); @@ -53592,7 +55630,8 @@ var ts; return !assumeTrue; } function narrowByInKeyword(type, literal, assumeTrue) { - if (type.flags & (1048576 | 524288) + if (type.flags & 1048576 + || type.flags & 524288 && declaredType !== type || isThisTypeParameter(type) || type.flags & 2097152 && ts.every(type.types, function (t) { return t.symbol !== globalThisSymbol; })) { var propName_1 = ts.escapeLeadingUnderscores(literal.text); @@ -53602,57 +55641,63 @@ var ts; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 62: - case 74: + case 63: case 75: case 76: + case 77: return narrowTypeByTruthiness(narrowType(type, expr.right, assumeTrue), expr.left, assumeTrue); case 34: case 35: case 36: case 37: - var operator_1 = expr.operatorToken.kind; - var left_1 = getReferenceCandidate(expr.left); - var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 211 && ts.isStringLiteralLike(right_1)) { - return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); + var operator = expr.operatorToken.kind; + var left = getReferenceCandidate(expr.left); + var right = getReferenceCandidate(expr.right); + if (left.kind === 213 && ts.isStringLiteralLike(right)) { + return narrowTypeByTypeof(type, left, operator, right, assumeTrue); } - if (right_1.kind === 211 && ts.isStringLiteralLike(left_1)) { - return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); + if (right.kind === 213 && ts.isStringLiteralLike(left)) { + return narrowTypeByTypeof(type, right, operator, left, assumeTrue); } - if (isMatchingReference(reference, left_1)) { - return narrowTypeByEquality(type, operator_1, right_1, assumeTrue); + if (isMatchingReference(reference, left)) { + return narrowTypeByEquality(type, operator, right, assumeTrue); } - if (isMatchingReference(reference, right_1)) { - return narrowTypeByEquality(type, operator_1, left_1, assumeTrue); + if (isMatchingReference(reference, right)) { + return narrowTypeByEquality(type, operator, left, assumeTrue); } if (strictNullChecks) { - if (optionalChainContainsReference(left_1, reference)) { - type = narrowTypeByOptionalChainContainment(type, operator_1, right_1, assumeTrue); + if (optionalChainContainsReference(left, reference)) { + type = narrowTypeByOptionalChainContainment(type, operator, right, assumeTrue); } - else if (optionalChainContainsReference(right_1, reference)) { - type = narrowTypeByOptionalChainContainment(type, operator_1, left_1, assumeTrue); + else if (optionalChainContainsReference(right, reference)) { + type = narrowTypeByOptionalChainContainment(type, operator, left, assumeTrue); } } - if (isMatchingReferenceDiscriminant(left_1, type)) { - return narrowTypeByDiscriminant(type, left_1, function (t) { return narrowTypeByEquality(t, operator_1, right_1, assumeTrue); }); + if (isMatchingReferenceDiscriminant(left, type)) { + return narrowTypeByDiscriminantProperty(type, left, operator, right, assumeTrue); } - if (isMatchingReferenceDiscriminant(right_1, type)) { - return narrowTypeByDiscriminant(type, right_1, function (t) { return narrowTypeByEquality(t, operator_1, left_1, assumeTrue); }); + if (isMatchingReferenceDiscriminant(right, type)) { + return narrowTypeByDiscriminantProperty(type, right, operator, left, assumeTrue); } - if (isMatchingConstructorReference(left_1)) { - return narrowTypeByConstructor(type, operator_1, right_1, assumeTrue); + if (isMatchingConstructorReference(left)) { + return narrowTypeByConstructor(type, operator, right, assumeTrue); } - if (isMatchingConstructorReference(right_1)) { - return narrowTypeByConstructor(type, operator_1, left_1, assumeTrue); + if (isMatchingConstructorReference(right)) { + return narrowTypeByConstructor(type, operator, left, assumeTrue); } break; - case 101: + case 102: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 100: + case 101: var target = getReferenceCandidate(expr.right); - if (ts.isStringLiteralLike(expr.left) && isMatchingReference(reference, target)) { - return narrowByInKeyword(type, expr.left, assumeTrue); + if (ts.isStringLiteralLike(expr.left)) { + if (containsMissingType(type) && ts.isAccessExpression(reference) && isMatchingReference(reference.expression, target) && + getAccessedPropertyName(reference) === ts.escapeLeadingUnderscores(expr.left.text)) { + return getTypeWithFacts(type, assumeTrue ? 524288 : 65536); + } + if (isMatchingReference(reference, target)) { + return narrowByInKeyword(type, expr.left, assumeTrue); + } } break; case 27: @@ -53699,13 +55744,12 @@ var ts; } if (assumeTrue) { var filterFn = operator === 34 ? - (function (t) { return areTypesComparable(t, valueType) || isCoercibleUnderDoubleEquals(t, valueType); }) : + function (t) { return areTypesComparable(t, valueType) || isCoercibleUnderDoubleEquals(t, valueType); } : function (t) { return areTypesComparable(t, valueType); }; return replacePrimitivesWithLiterals(filterType(type, filterFn), valueType); } if (isUnitType(valueType)) { - var regularType_1 = getRegularTypeOfLiteralType(valueType); - return filterType(type, function (t) { return isUnitType(t) ? !areTypesComparable(t, valueType) : getRegularTypeOfLiteralType(t) !== regularType_1; }); + return filterType(type, function (t) { return !(isUnitLikeType(t) && areTypesComparable(t, valueType)); }); } return type; } @@ -53724,7 +55768,7 @@ var ts; return type; } if (assumeTrue && type.flags & 2 && literal.text === "object") { - if (typeOfExpr.parent.parent.kind === 216) { + if (typeOfExpr.parent.parent.kind === 218) { var expr = typeOfExpr.parent.parent; if (expr.operatorToken.kind === 55 && expr.right === typeOfExpr.parent && containsTruthyCheck(reference, expr.left)) { return nonPrimitiveType; @@ -53776,7 +55820,7 @@ var ts; if (!hasDefaultClause) { return caseType; } - var defaultType = filterType(type, function (t) { return !(isUnitType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(t))); }); + var defaultType = filterType(type, function (t) { return !(isUnitLikeType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(extractUnitType(t)))); }); return caseType.flags & 131072 ? defaultType : getUnionType([caseType, defaultType]); } function getImpliedTypeFromTypeofGuard(type, text) { @@ -53904,7 +55948,16 @@ var ts; } function getNarrowedType(type, candidate, assumeTrue, isRelated) { if (!assumeTrue) { - return filterType(type, function (t) { return !isRelated(t, candidate); }); + return filterType(type, function (t) { + if (!isRelated(t, candidate)) { + return true; + } + var constraint = getBaseConstraintOfType(t); + if (constraint && constraint !== t) { + return !isRelated(constraint, candidate); + } + return false; + }); } if (type.flags & 1048576) { var assignableType = filterType(type, function (t) { return isRelated(t, candidate); }); @@ -53912,7 +55965,10 @@ var ts; return assignableType; } } - return isTypeSubtypeOf(candidate, type) ? candidate : isTypeSubtypeOf(type, candidate) ? type : getIntersectionType([type, candidate]); + return isTypeSubtypeOf(candidate, type) ? candidate : + isTypeAssignableTo(type, candidate) ? type : + isTypeAssignableTo(candidate, type) ? candidate : + getIntersectionType([type, candidate]); } function narrowTypeByCallExpression(type, callExpression, assumeTrue) { if (hasMatchingArgument(callExpression, reference)) { @@ -53922,6 +55978,16 @@ var ts; return narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue); } } + if (containsMissingType(type) && ts.isAccessExpression(reference) && ts.isPropertyAccessExpression(callExpression.expression)) { + var callAccess = callExpression.expression; + if (isMatchingReference(reference.expression, getReferenceCandidate(callAccess.expression)) && + 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 : 65536); + } + } + } return type; } function narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue) { @@ -53948,20 +56014,20 @@ var ts; return narrowTypeByOptionality(type, expr, assumeTrue); } switch (expr.kind) { - case 78: - case 107: - case 105: - case 201: - case 202: - return narrowTypeByTruthiness(type, expr, assumeTrue); + case 79: + case 108: + case 106: case 203: + case 204: + return narrowTypeByTruthiness(type, expr, assumeTrue); + case 205: return narrowTypeByCallExpression(type, expr, assumeTrue); - case 207: - case 225: + case 209: + case 227: return narrowType(type, expr.expression, assumeTrue); - case 216: + case 218: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 214: + case 216: if (expr.operator === 53) { return narrowType(type, expr.operand, !assumeTrue); } @@ -53981,28 +56047,34 @@ var ts; } function getTypeOfSymbolAtLocation(symbol, location) { symbol = symbol.exportSymbol || symbol; - if (location.kind === 78) { + if (location.kind === 79 || location.kind === 80) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } - if (ts.isExpressionNode(location) && !ts.isAssignmentTarget(location)) { + if (ts.isExpressionNode(location) && (!ts.isAssignmentTarget(location) || ts.isWriteAccess(location))) { var type = getTypeOfExpression(location); if (getExportSymbolOfValueSymbolIfExported(getNodeLinks(location).resolvedSymbol) === symbol) { return type; } } } - return getTypeOfSymbol(symbol); + if (ts.isDeclarationName(location) && ts.isSetAccessor(location.parent) && getAnnotatedAccessorTypeNode(location.parent)) { + return resolveTypeOfAccessors(location.parent.symbol, true); + } + return getNonMissingTypeOfSymbol(symbol); } function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 257 || - node.kind === 297 || - node.kind === 163; + node.kind === 259 || + node.kind === 299 || + node.kind === 165; }); } function isParameterAssigned(symbol) { + if (!symbol.valueDeclaration) { + return false; + } var func = ts.getRootDeclaration(symbol.valueDeclaration).parent; var links = getNodeLinks(func); if (!(links.flags & 8388608)) { @@ -54017,10 +56089,10 @@ var ts; return !!ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !!(getNodeLinks(node).flags & 8388608); }); } function markParameterAssignments(node) { - if (node.kind === 78) { + if (node.kind === 79) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 160) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 162) { symbol.isAssigned = true; } } @@ -54035,7 +56107,7 @@ var ts; function removeOptionalityFromDeclaredType(declaredType, declaration) { if (pushTypeResolution(declaration.symbol, 2)) { var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 160 && + declaration.kind === 162 && declaration.initializer && getFalsyFlags(declaredType) & 32768 && !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768); @@ -54049,19 +56121,28 @@ var ts; } function isConstraintPosition(node) { var parent = node.parent; - return parent.kind === 201 || - parent.kind === 203 && parent.expression === node || - parent.kind === 202 && parent.expression === node || - parent.kind === 198 && parent.name === node && !!parent.initializer; + return parent.kind === 203 || + parent.kind === 205 && parent.expression === node || + parent.kind === 204 && parent.expression === node && + !isGenericIndexType(getTypeOfExpression(parent.argumentExpression)); } - function typeHasNullableConstraint(type) { - return type.flags & 58982400 && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 98304); + function isGenericTypeWithUnionConstraint(type) { + return !!(type.flags & 465829888 && getBaseConstraintOrType(type).flags & (98304 | 1048576)); } - function getConstraintForLocation(type, node) { - if (type && isConstraintPosition(node) && forEachType(type, typeHasNullableConstraint)) { - return mapType(getWidenedType(type), getBaseConstraintOrType); - } - return type; + function containsGenericType(type) { + return !!(type.flags & 465829888 || type.flags & 3145728 && ts.some(type.types, containsGenericType)); + } + function hasNonBindingPatternContextualTypeWithNoGenericTypes(node) { + var contextualType = (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) && + !((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && + getContextualType(node, 8); + return contextualType && !someType(contextualType, containsGenericType); + } + function getNarrowableTypeForReference(type, reference, checkMode) { + var substituteConstraints = !(checkMode && checkMode & 2) && + someType(type, isGenericTypeWithUnionConstraint) && + (isConstraintPosition(reference) || hasNonBindingPatternContextualTypeWithNoGenericTypes(reference)); + return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 ? getBaseConstraintOrType(t) : t; }) : type; } function isExportOrExportExpression(location) { return !!ts.findAncestor(location, function (e) { return e.parent && ts.isExportAssignment(e.parent) && e.parent.expression === e && ts.isEntityNameExpression(e); }); @@ -54070,7 +56151,9 @@ var ts; if (isNonLocalAlias(symbol, 111551) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) { var target = resolveAlias(symbol); if (target.flags & 111551) { - if (compilerOptions.preserveConstEnums && isExportOrExportExpression(location) || !isConstEnumOrConstEnumOnlyModule(target)) { + if (compilerOptions.isolatedModules || + ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(location) || + !isConstEnumOrConstEnumOnlyModule(target)) { markAliasSymbolAsReferenced(symbol); } else { @@ -54079,7 +56162,7 @@ var ts; } } } - function checkIdentifier(node) { + function checkIdentifier(node, checkMode) { var symbol = getResolvedSymbol(node); if (symbol === unknownSymbol) { return errorType; @@ -54087,7 +56170,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2) { - if (container.kind === 209) { + if (container.kind === 211) { 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)) { @@ -54102,12 +56185,12 @@ var ts; } var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); var sourceSymbol = localOrExportSymbol.flags & 2097152 ? resolveAlias(localOrExportSymbol) : localOrExportSymbol; - if (getDeclarationNodeFlagsFromSymbol(sourceSymbol) & 134217728 && isUncalledFunctionReference(node, sourceSymbol)) { - errorOrSuggestion(false, node, ts.Diagnostics._0_is_deprecated, node.escapedText); + if (sourceSymbol.declarations && getDeclarationNodeFlagsFromSymbol(sourceSymbol) & 134217728 && isUncalledFunctionReference(node, sourceSymbol)) { + addDeprecatedSuggestion(node, sourceSymbol.declarations, node.escapedText); } var declaration = localOrExportSymbol.valueDeclaration; - if (localOrExportSymbol.flags & 32) { - if (declaration.kind === 252 + if (declaration && localOrExportSymbol.flags & 32) { + if (declaration.kind === 254 && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -54119,11 +56202,11 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 221) { + else if (declaration.kind === 223) { var container = ts.getThisContainer(node, false); - while (container.kind !== 297) { + while (container.kind !== 299) { if (container.parent === declaration) { - if (container.kind === 163 && ts.hasSyntacticModifier(container, 32)) { + if (container.kind === 165 && ts.hasSyntacticModifier(container, 32)) { getNodeLinks(declaration).flags |= 16777216; getNodeLinks(node).flags |= 33554432; } @@ -54134,12 +56217,18 @@ var ts; } } checkNestedBlockScopedBinding(node, symbol); - var type = getConstraintForLocation(getTypeOfSymbol(localOrExportSymbol), node); + var type = getTypeOfSymbol(localOrExportSymbol); var assignmentKind = ts.getAssignmentTargetKind(node); if (assignmentKind) { if (!(localOrExportSymbol.flags & 3) && !(ts.isInJSFile(node) && localOrExportSymbol.flags & 512)) { - error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_not_a_variable, symbolToString(symbol)); + var assignmentError = localOrExportSymbol.flags & 384 ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_enum + : localOrExportSymbol.flags & 32 ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_class + : localOrExportSymbol.flags & 1536 ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_namespace + : localOrExportSymbol.flags & 16 ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_function + : localOrExportSymbol.flags & 2097152 ? 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)) { @@ -54159,7 +56248,7 @@ var ts; } } else if (isAlias) { - declaration = ts.find(symbol.declarations, isSomeImportDeclaration); + declaration = getDeclarationOfAliasSymbol(symbol); } else { return type; @@ -54167,22 +56256,23 @@ var ts; if (!declaration) { return type; } - var isParameter = ts.getRootDeclaration(declaration).kind === 160; + type = getNarrowableTypeForReference(type, node, checkMode); + var isParameter = ts.getRootDeclaration(declaration).kind === 162; 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; - while (flowContainer !== declarationContainer && (flowContainer.kind === 208 || - flowContainer.kind === 209 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 210 || + flowContainer.kind === 211 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || ts.isBindingElement(declaration) || type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 | 16384)) !== 0 || - isInTypeQuery(node) || node.parent.kind === 270) || - node.parent.kind === 225 || - declaration.kind === 249 && declaration.exclamationToken || + isInTypeQuery(node) || node.parent.kind === 272) || + node.parent.kind === 227 || + declaration.kind === 251 && declaration.exclamationToken || declaration.flags & 8388608; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : @@ -54203,35 +56293,31 @@ var ts; } return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } - function isInsideFunction(node, threshold) { - return !!ts.findAncestor(node, function (n) { return n === threshold ? "quit" : ts.isFunctionLike(n); }); + 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); }); } function getPartOfForStatementContainingNode(node, container) { return ts.findAncestor(node, function (n) { return n === container ? "quit" : n === container.initializer || n === container.condition || n === container.incrementor || n === container.statement; }); } + function getEnclosingIterationStatement(node) { + return ts.findAncestor(node, function (n) { return (!n || ts.nodeStartsNewLexicalEnvironment(n)) ? "quit" : ts.isIterationStatement(n, false); }); + } function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 || (symbol.flags & (2 | 32)) === 0 || + !symbol.valueDeclaration || ts.isSourceFile(symbol.valueDeclaration) || - symbol.valueDeclaration.parent.kind === 287) { + symbol.valueDeclaration.parent.kind === 289) { return; } var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); - var usedInFunction = isInsideFunction(node.parent, container); - var current = container; - var containedInIterationStatement = false; - while (current && !ts.nodeStartsNewLexicalEnvironment(current)) { - if (ts.isIterationStatement(current, false)) { - containedInIterationStatement = true; - break; - } - current = current.parent; - } - if (containedInIterationStatement) { - if (usedInFunction) { + var isCaptured = isInsideFunctionOrInstancePropertyInitializer(node, container); + var enclosingIterationStatement = getEnclosingIterationStatement(container); + if (enclosingIterationStatement) { + if (isCaptured) { var capturesBlockScopeBindingInLoopBody = true; if (ts.isForStatement(container)) { - var varDeclList = ts.getAncestor(symbol.valueDeclaration, 250); + var varDeclList = ts.getAncestor(symbol.valueDeclaration, 252); if (varDeclList && varDeclList.parent === container) { var part = getPartOfForStatementContainingNode(node.parent, container); if (part) { @@ -54246,18 +56332,18 @@ var ts; } } if (capturesBlockScopeBindingInLoopBody) { - getNodeLinks(current).flags |= 65536; + getNodeLinks(enclosingIterationStatement).flags |= 65536; } } if (ts.isForStatement(container)) { - var varDeclList = ts.getAncestor(symbol.valueDeclaration, 250); + var varDeclList = ts.getAncestor(symbol.valueDeclaration, 252); if (varDeclList && varDeclList.parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 4194304; } } getNodeLinks(symbol.valueDeclaration).flags |= 524288; } - if (usedInFunction) { + if (isCaptured) { getNodeLinks(symbol.valueDeclaration).flags |= 262144; } } @@ -54267,14 +56353,14 @@ var ts; } function isAssignedInBodyOfForStatement(node, container) { var current = node; - while (current.parent.kind === 207) { + while (current.parent.kind === 209) { current = current.parent; } var isAssigned = false; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 214 || current.parent.kind === 215)) { + else if ((current.parent.kind === 216 || current.parent.kind === 217)) { var expr = current.parent; isAssigned = expr.operator === 45 || expr.operator === 46; } @@ -54285,7 +56371,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2; - if (container.kind === 163 || container.kind === 166) { + if (container.kind === 165 || container.kind === 168) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4; } @@ -54316,32 +56402,32 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var capturedByArrowFunction = false; - if (container.kind === 166) { + if (container.kind === 168) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); } - if (container.kind === 209) { + if (container.kind === 211) { container = ts.getThisContainer(container, false); capturedByArrowFunction = true; } switch (container.kind) { - case 256: + case 258: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 255: + case 257: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 166: + case 168: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 163: - case 162: - if (ts.hasSyntacticModifier(container, 32) && !(compilerOptions.target === 99 && compilerOptions.useDefineForClassFields)) { + case 165: + case 164: + if (ts.hasSyntacticModifier(container, 32) && !(compilerOptions.target === 99 && useDefineForClassFields)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 158: + case 160: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -54422,7 +56508,7 @@ var ts; } } function getClassNameFromPrototypeMethod(container) { - if (container.kind === 208 && + if (container.kind === 210 && ts.isBinaryExpression(container.parent) && ts.getAssignmentDeclarationKind(container.parent) === 3) { return container.parent @@ -54430,20 +56516,20 @@ var ts; .expression .expression; } - else if (container.kind === 165 && - container.parent.kind === 200 && + else if (container.kind === 167 && + container.parent.kind === 202 && ts.isBinaryExpression(container.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent) === 6) { return container.parent.parent.left.expression; } - else if (container.kind === 208 && - container.parent.kind === 288 && - container.parent.parent.kind === 200 && + else if (container.kind === 210 && + container.parent.kind === 290 && + container.parent.parent.kind === 202 && ts.isBinaryExpression(container.parent.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6) { return container.parent.parent.parent.left.expression; } - else if (container.kind === 208 && + else if (container.kind === 210 && ts.isPropertyAssignment(container.parent) && ts.isIdentifier(container.parent.name) && (container.parent.name.escapedText === "value" || container.parent.name.escapedText === "get" || container.parent.name.escapedText === "set") && @@ -54465,7 +56551,7 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 308) { + if (jsdocType && jsdocType.kind === 311) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -54479,15 +56565,15 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 160 && n.parent === constructorDecl; }); + return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 162 && n.parent === constructorDecl; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 203 && node.parent.expression === node; + var isCallExpression = node.parent.kind === 205 && node.parent.expression === node; var immediateContainer = ts.getSuperContainer(node, true); var container = immediateContainer; var needToCaptureLexicalThis = false; if (!isCallExpression) { - while (container && container.kind === 209) { + while (container && container.kind === 211) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } @@ -54495,14 +56581,14 @@ var ts; var canUseSuperExpression = isLegalUsageOfSuperExpression(container); var nodeCheckFlag = 0; if (!canUseSuperExpression) { - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 158; }); - if (current && current.kind === 158) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 160; }); + if (current && current.kind === 160) { 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 === 200)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 202)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -54510,7 +56596,7 @@ var ts; } return errorType; } - if (!isCallExpression && immediateContainer.kind === 166) { + if (!isCallExpression && immediateContainer.kind === 168) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class); } if (ts.hasSyntacticModifier(container, 32) || isCallExpression) { @@ -54520,7 +56606,7 @@ var ts; nodeCheckFlag = 256; } getNodeLinks(node).flags |= nodeCheckFlag; - if (container.kind === 165 && ts.hasSyntacticModifier(container, 256)) { + if (container.kind === 167 && ts.hasSyntacticModifier(container, 256)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096; } @@ -54531,7 +56617,7 @@ var ts; if (needToCaptureLexicalThis) { captureLexicalThis(node.parent, container); } - if (container.parent.kind === 200) { + if (container.parent.kind === 202) { if (languageVersion < 2) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return errorType; @@ -54550,7 +56636,7 @@ var ts; if (!baseClassType) { return errorType; } - if (container.kind === 166 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 168 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return errorType; } @@ -54562,24 +56648,24 @@ var ts; return false; } if (isCallExpression) { - return container.kind === 166; + return container.kind === 168; } else { - if (ts.isClassLike(container.parent) || container.parent.kind === 200) { + if (ts.isClassLike(container.parent) || container.parent.kind === 202) { if (ts.hasSyntacticModifier(container, 32)) { - return container.kind === 165 || - container.kind === 164 || - container.kind === 167 || - container.kind === 168; + return container.kind === 167 || + container.kind === 166 || + container.kind === 169 || + container.kind === 170; } else { - return container.kind === 165 || + return container.kind === 167 || + container.kind === 166 || + container.kind === 169 || + container.kind === 170 || + container.kind === 165 || container.kind === 164 || - container.kind === 167 || - container.kind === 168 || - container.kind === 163 || - container.kind === 162 || - container.kind === 166; + container.kind === 168; } } } @@ -54587,10 +56673,10 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 165 || - func.kind === 167 || - func.kind === 168) && func.parent.kind === 200 ? func.parent : - func.kind === 208 && func.parent.kind === 288 ? func.parent.parent : + return (func.kind === 167 || + func.kind === 169 || + func.kind === 170) && func.parent.kind === 202 ? func.parent : + func.kind === 210 && func.parent.kind === 290 ? func.parent.parent : undefined; } function getThisTypeArgument(type) { @@ -54602,7 +56688,7 @@ var ts; }); } function getContextualThisParameterType(func) { - if (func.kind === 209) { + if (func.kind === 211) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -54626,7 +56712,7 @@ var ts; if (thisType) { return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral))); } - if (literal.parent.kind !== 288) { + if (literal.parent.kind !== 290) { break; } literal = literal.parent.parent; @@ -54635,7 +56721,7 @@ var ts; return getWidenedType(contextualType ? getNonNullableType(contextualType) : checkExpressionCached(containingLiteral)); } var parent = ts.walkUpParenthesizedExpressions(func.parent); - if (parent.kind === 216 && parent.operatorToken.kind === 62) { + if (parent.kind === 218 && parent.operatorToken.kind === 63) { var target = parent.left; if (ts.isAccessExpression(target)) { var expression = target.expression; @@ -54686,11 +56772,11 @@ var ts; return getTypeFromTypeNode(typeNode); } switch (declaration.kind) { - case 160: + case 162: return getContextuallyTypedParameterType(declaration); - case 198: + case 200: return getContextualTypeForBindingElement(declaration); - case 163: + case 165: if (ts.hasSyntacticModifier(declaration, 32)) { return getContextualTypeForStaticPropertyDeclaration(declaration); } @@ -54700,10 +56786,10 @@ var ts; var parent = declaration.parent.parent; var name = declaration.propertyName || declaration.name; var parentType = getContextualTypeForVariableLikeDeclaration(parent) || - parent.kind !== 198 && parent.initializer && checkDeclarationInitializer(parent); + parent.kind !== 200 && parent.initializer && checkDeclarationInitializer(parent); if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name)) return undefined; - if (parent.name.kind === 197) { + if (parent.name.kind === 199) { var index = ts.indexOfNode(declaration.parent.elements, declaration); if (index < 0) return undefined; @@ -54821,10 +56907,13 @@ var ts; if (ts.isJsxOpeningLikeElement(callTarget) && argIndex === 0) { return getEffectiveFirstArgumentForJsxSignature(signature, callTarget); } - return getTypeAtPosition(signature, argIndex); + var restIndex = signature.parameters.length - 1; + return signatureHasRestParameter(signature) && argIndex >= restIndex ? + getIndexedAccessType(getTypeOfSymbol(signature.parameters[restIndex]), getLiteralType(argIndex - restIndex), 256) : + getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 205) { + if (template.parent.kind === 207) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -54833,10 +56922,10 @@ var ts; var binaryExpression = node.parent; var left = binaryExpression.left, operatorToken = binaryExpression.operatorToken, right = binaryExpression.right; switch (operatorToken.kind) { - case 62: - case 75: - case 74: + case 63: case 76: + case 75: + case 77: return node === right ? getContextualTypeForAssignmentDeclaration(binaryExpression) : undefined; case 56: case 60: @@ -54851,16 +56940,16 @@ var ts; } } function getContextualTypeForAssignmentDeclaration(binaryExpression) { + var _a, _b; var kind = ts.getAssignmentDeclarationKind(binaryExpression); switch (kind) { case 0: return getTypeOfExpression(binaryExpression.left); + case 4: + return getContextualTypeForThisPropertyAssignment(binaryExpression); case 5: - case 1: - case 6: - case 3: if (isPossiblyAliasedThisProperty(binaryExpression, kind)) { - return getContextualTypeForThisPropertyAssignment(binaryExpression, kind); + return getContextualTypeForThisPropertyAssignment(binaryExpression); } else if (!binaryExpression.left.symbol) { return getTypeOfExpression(binaryExpression.left); @@ -54879,11 +56968,11 @@ var ts; var id = lhs.expression; var parentSymbol = resolveName(id, id.escapedText, 111551, undefined, id.escapedText, true); if (parentSymbol) { - var annotated = parentSymbol.valueDeclaration && ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration); - if (annotated) { + var annotated_1 = parentSymbol.valueDeclaration && ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration); + if (annotated_1) { var nameStr = ts.getElementOrPropertyAccessName(lhs); if (nameStr !== undefined) { - return getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated), nameStr); + return getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated_1), nameStr); } } return undefined; @@ -54891,9 +56980,14 @@ var ts; } return ts.isInJSFile(decl) ? undefined : getTypeOfExpression(binaryExpression.left); } + case 1: + case 6: + case 3: + var valueDeclaration = (_a = binaryExpression.left.symbol) === null || _a === void 0 ? void 0 : _a.valueDeclaration; case 2: - case 4: - return getContextualTypeForThisPropertyAssignment(binaryExpression, kind); + 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: case 8: case 9: @@ -54914,7 +57008,7 @@ var ts; var symbol = resolveName(declaration.left, name, 111551, undefined, undefined, true, true); return ts.isThisInitializedDeclaration(symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration); } - function getContextualTypeForThisPropertyAssignment(binaryExpression, kind) { + function getContextualTypeForThisPropertyAssignment(binaryExpression) { if (!binaryExpression.symbol) return getTypeOfExpression(binaryExpression.left); if (binaryExpression.symbol.valueDeclaration) { @@ -54926,8 +57020,6 @@ var ts; } } } - if (kind === 2) - return undefined; var thisAccess = ts.cast(binaryExpression.left, ts.isAccessExpression); if (!ts.isObjectLiteralMethod(ts.getThisContainer(thisAccess.expression, false))) { return undefined; @@ -54978,9 +57070,13 @@ var ts; } function getContextualTypeForObjectLiteralElement(element, contextFlags) { var objectLiteral = element.parent; + var propertyAssignmentType = ts.isPropertyAssignment(element) && getContextualTypeForVariableLikeDeclaration(element); + if (propertyAssignmentType) { + return propertyAssignmentType; + } var type = getApparentTypeOfContextualType(objectLiteral, contextFlags); if (type) { - if (!hasNonBindableDynamicName(element)) { + if (hasBindableName(element)) { var symbolName_3 = getSymbolOfNode(element).escapedName; var propertyType = getTypeOfPropertyOfContextualType(type, symbolName_3); if (propertyType) { @@ -55044,25 +57140,25 @@ var ts; case 8: case 9: case 14: - case 109: - case 94: - case 103: - case 78: - case 150: + case 110: + case 95: + case 104: + case 79: + case 151: return true; - case 201: - case 207: + case 203: + case 209: return isPossiblyDiscriminantValue(node.expression); - case 283: + case 285: return !node.expression || isPossiblyDiscriminantValue(node.expression); } return false; } function discriminateContextualTypeByObjectMembers(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 288 && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); + return getMatchingUnionConstituentForObjectLiteral(contextualType, node) || discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 290 && 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) && !!((_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.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 280 && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return checkExpression(prop.initializer); }), prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 282 && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return checkExpression(prop.initializer); }), prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216) && !!((_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 getApparentTypeOfContextualType(node, contextFlags) { var contextualType = ts.isObjectLiteralMethod(node) ? @@ -55071,15 +57167,9 @@ var ts; var instantiatedType = instantiateContextualType(contextualType, node, contextFlags); if (instantiatedType && !(contextFlags && contextFlags & 2 && instantiatedType.flags & 8650752)) { var apparentType = mapType(instantiatedType, getApparentType, true); - if (apparentType.flags & 1048576) { - if (ts.isObjectLiteralExpression(node)) { - return discriminateContextualTypeByObjectMembers(node, apparentType); - } - else if (ts.isJsxAttributes(node)) { - return discriminateContextualTypeByJSXAttributes(node, apparentType); - } - } - return apparentType; + return apparentType.flags & 1048576 && ts.isObjectLiteralExpression(node) ? discriminateContextualTypeByObjectMembers(node, apparentType) : + apparentType.flags & 1048576 && ts.isJsxAttributes(node) ? discriminateContextualTypeByJSXAttributes(node, apparentType) : + apparentType; } } function instantiateContextualType(contextualType, node, contextFlags) { @@ -55117,56 +57207,58 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 249: - case 160: - case 163: + case 251: case 162: - case 198: + case 165: + case 164: + case 200: return getContextualTypeForInitializerExpression(node, contextFlags); - case 209: - case 242: + case 211: + case 244: return getContextualTypeForReturnExpression(node); - case 219: + case 221: return getContextualTypeForYieldOperand(parent); - case 213: + case 215: return getContextualTypeForAwaitOperand(parent, contextFlags); - case 203: - if (parent.expression.kind === 99) { + case 205: + if (parent.expression.kind === 100) { return stringType; } - case 204: - return getContextualTypeForArgument(parent, node); case 206: - case 224: + return getContextualTypeForArgument(parent, node); + case 208: + case 226: return ts.isConstTypeReference(parent.type) ? tryFindWhenConstTypeReference(parent) : getTypeFromTypeNode(parent.type); - case 216: + case 218: return getContextualTypeForBinaryOperand(node, contextFlags); - case 288: - case 289: - return getContextualTypeForObjectLiteralElement(parent, contextFlags); case 290: - return getApparentTypeOfContextualType(parent.parent, contextFlags); - case 199: { + case 291: + return getContextualTypeForObjectLiteralElement(parent, contextFlags); + case 292: + return getContextualType(parent.parent, contextFlags); + case 201: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral, contextFlags); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 217: + case 219: return getContextualTypeForConditionalOperand(node, contextFlags); - case 228: - ts.Debug.assert(parent.parent.kind === 218); + case 230: + ts.Debug.assert(parent.parent.kind === 220); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 207: { + case 209: { var tag = ts.isInJSFile(parent) ? ts.getJSDocTypeTag(parent) : undefined; return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent, contextFlags); } - case 283: + case 227: + return getContextualType(parent, contextFlags); + case 285: return getContextualTypeForJsxExpression(parent); - case 280: case 282: + case 284: return getContextualTypeForJsxAttribute(parent); - case 275: - case 274: + case 277: + case 276: return getContextualJsxElementAttributesType(parent, contextFlags); } return undefined; @@ -55199,9 +57291,9 @@ var ts; return propsType; } function getJsxPropsTypeForSignatureFromMember(sig, forcedLookupLocation) { - if (sig.unionSignatures) { + if (sig.compositeSignatures) { var results = []; - for (var _i = 0, _a = sig.unionSignatures; _i < _a.length; _i++) { + for (var _i = 0, _a = sig.compositeSignatures; _i < _a.length; _i++) { var signature = _a[_i]; var instance = getReturnTypeOfSignature(signature); if (isTypeAny(instance)) { @@ -55240,14 +57332,17 @@ var ts; if (managedSym) { var declaredManagedType = getDeclaredTypeOfSymbol(managedSym); var ctorType = getStaticTypeOfReferencedJsxConstructor(context); + if (managedSym.flags & 524288) { + var params = getSymbolLinks(managedSym).typeParameters; + if (ts.length(params) >= 2) { + var args = fillMissingTypeArguments([ctorType, attributesType], params, 2, ts.isInJSFile(context)); + return getTypeAliasInstantiation(managedSym, args); + } + } if (ts.length(declaredManagedType.typeParameters) >= 2) { var args = fillMissingTypeArguments([ctorType, attributesType], declaredManagedType.typeParameters, 2, ts.isInJSFile(context)); return createTypeReference(declaredManagedType, args); } - else if (ts.length(declaredManagedType.aliasTypeArguments) >= 2) { - var args = fillMissingTypeArguments([ctorType, attributesType], declaredManagedType.aliasTypeArguments, 2, ts.isInJSFile(context)); - return getTypeAliasInstantiation(declaredManagedType.aliasSymbol, args); - } } return attributesType; } @@ -55286,14 +57381,85 @@ var ts; return apparentAttributesType; } } - function getContextualCallSignature(type, node) { - var signatures = getSignaturesOfType(type, 0); - if (signatures.length === 1) { - var signature = signatures[0]; - if (!isAritySmaller(signature, node)) { - return signature; + function getIntersectedSignatures(signatures) { + return ts.getStrictOptionValue(compilerOptions, "noImplicitAny") + ? ts.reduceLeft(signatures, function (left, right) { + return left === right || !left ? left + : compareTypeParametersIdentical(left.typeParameters, right.typeParameters) ? combineSignaturesOfIntersectionMembers(left, right) + : undefined; + }) + : undefined; + } + function combineIntersectionThisParam(left, right, mapper) { + if (!left || !right) { + return left || right; + } + var thisType = getUnionType([getTypeOfSymbol(left), instantiateType(getTypeOfSymbol(right), mapper)]); + return createSymbolWithType(left, thisType); + } + function combineIntersectionParameters(left, right, mapper) { + var leftCount = getParameterCount(left); + var rightCount = getParameterCount(right); + var longest = leftCount >= rightCount ? left : right; + var shorter = longest === left ? right : left; + var longestCount = longest === left ? leftCount : rightCount; + var eitherHasEffectiveRest = (hasEffectiveRestParameter(left) || hasEffectiveRestParameter(right)); + var needsExtraRestElement = eitherHasEffectiveRest && !hasEffectiveRestParameter(longest); + var params = new Array(longestCount + (needsExtraRestElement ? 1 : 0)); + for (var i = 0; i < longestCount; i++) { + var longestParamType = tryGetTypeAtPosition(longest, i); + if (longest === right) { + longestParamType = instantiateType(longestParamType, mapper); + } + var shorterParamType = tryGetTypeAtPosition(shorter, i) || unknownType; + if (shorter === right) { + shorterParamType = instantiateType(shorterParamType, mapper); } + var unionParamType = getUnionType([longestParamType, shorterParamType]); + var isRestParam = eitherHasEffectiveRest && !needsExtraRestElement && i === (longestCount - 1); + var isOptional = i >= getMinArgumentCount(longest) && i >= getMinArgumentCount(shorter); + var leftName = i >= leftCount ? undefined : getParameterNameAtPosition(left, i); + var rightName = i >= rightCount ? undefined : getParameterNameAtPosition(right, i); + var paramName = leftName === rightName ? leftName : + !leftName ? rightName : + !rightName ? leftName : + undefined; + var paramSymbol = createSymbol(1 | (isOptional && !isRestParam ? 16777216 : 0), paramName || "arg" + i); + paramSymbol.type = isRestParam ? createArrayType(unionParamType) : unionParamType; + params[i] = paramSymbol; + } + if (needsExtraRestElement) { + var restParamSymbol = createSymbol(1, "args"); + restParamSymbol.type = createArrayType(getTypeAtPosition(shorter, longestCount)); + if (shorter === right) { + restParamSymbol.type = instantiateType(restParamSymbol.type, mapper); + } + params[longestCount] = restParamSymbol; + } + return params; + } + function combineSignaturesOfIntersectionMembers(left, right) { + var typeParams = left.typeParameters || right.typeParameters; + var paramMapper; + if (left.typeParameters && right.typeParameters) { + paramMapper = createTypeMapper(right.typeParameters, left.typeParameters); } + var declaration = left.declaration; + var params = combineIntersectionParameters(left, right, paramMapper); + var thisParam = combineIntersectionThisParam(left.thisParameter, right.thisParameter, paramMapper); + var minArgCount = Math.max(left.minArgumentCount, right.minArgumentCount); + var result = createSignature(declaration, typeParams, thisParam, params, undefined, undefined, minArgCount, (left.flags | right.flags) & 39); + result.compositeKind = 2097152; + result.compositeSignatures = ts.concatenate(left.compositeKind === 2097152 && left.compositeSignatures || [left], [right]); + if (paramMapper) { + result.mapper = left.compositeKind === 2097152 && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; + } + return result; + } + function getContextualCallSignature(type, node) { + var signatures = getSignaturesOfType(type, 0); + var applicableByArity = ts.filter(signatures, function (s) { return !isAritySmaller(s, node); }); + return applicableByArity.length === 1 ? applicableByArity[0] : getIntersectedSignatures(applicableByArity); } function isAritySmaller(signature, target) { var targetParameterCount = 0; @@ -55309,7 +57475,7 @@ var ts; return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 208 || node.kind === 209; + return node.kind === 210 || node.kind === 211; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -55317,7 +57483,7 @@ var ts; : undefined; } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 165 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 167 || ts.isObjectLiteralMethod(node)); var typeTagSignature = getSignatureOfTypeTag(node); if (typeTagSignature) { return typeTagSignature; @@ -55361,8 +57527,8 @@ var ts; return node.isSpread ? getIndexedAccessType(node.type, numberType) : node.type; } function hasDefaultValue(node) { - return (node.kind === 198 && !!node.initializer) || - (node.kind === 216 && node.operatorToken.kind === 62); + return (node.kind === 200 && !!node.initializer) || + (node.kind === 218 && node.operatorToken.kind === 63); } function checkArrayLiteral(node, checkMode, forceTuple) { var elements = node.elements; @@ -55372,9 +57538,10 @@ var ts; var contextualType = getApparentTypeOfContextualType(node); 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 === 220) { + if (e.kind === 222) { if (languageVersion < 2) { checkExternalEmitHelpers(e, compilerOptions.downlevelIteration ? 1536 : 1024); } @@ -55395,17 +57562,22 @@ var ts; elementFlags.push(4); } } + else if (strictOptionalProperties && e.kind === 224) { + hasOmittedExpression = true; + elementTypes.push(missingType); + elementFlags.push(2); + } else { var elementContextualType = getContextualTypeForElementExpression(contextualType, elementTypes.length); var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple); - elementTypes.push(type); - elementFlags.push(1); + elementTypes.push(addOptionality(type, true, hasOmittedExpression)); + elementFlags.push(hasOmittedExpression ? 2 : 1); } } if (inDestructuringPattern) { return createTupleType(elementTypes, elementFlags); } - if (forceTuple || inConstContext || contextualType && forEachType(contextualType, isTupleLikeType)) { + if (forceTuple || inConstContext || contextualType && someType(contextualType, isTupleLikeType)) { return createArrayLiteralType(createTupleType(elementTypes, elementFlags, inConstContext)); } return createArrayLiteralType(createArrayType(elementTypes.length ? @@ -55419,15 +57591,15 @@ var ts; var literalType = type.literalType; if (!literalType) { literalType = type.literalType = cloneTypeReference(type); - literalType.objectFlags |= 65536 | 1048576; + literalType.objectFlags |= 32768 | 262144; } return literalType; } function isNumericName(name) { switch (name.kind) { - case 158: + case 160: return isNumericComputedName(name); - case 78: + case 79: return isNumericLiteralName(name.escapedText); case 8: case 10: @@ -55449,14 +57621,20 @@ var ts; var links = getNodeLinks(node.expression); if (!links.resolvedType) { links.resolvedType = checkExpression(node.expression); + if (ts.isPropertyDeclaration(node.parent) && !ts.hasStaticModifier(node.parent) && ts.isClassExpression(node.parent.parent)) { + var container = ts.getEnclosingBlockScopeContainer(node.parent.parent); + var enclosingIterationStatement = getEnclosingIterationStatement(container); + if (enclosingIterationStatement) { + getNodeLinks(enclosingIterationStatement).flags |= 65536; + getNodeLinks(node).flags |= 524288; + getNodeLinks(node.parent.parent).flags |= 524288; + } + } if (links.resolvedType.flags & 98304 || !isTypeAssignableToKind(links.resolvedType, 402653316 | 296 | 12288) && !isTypeAssignableTo(links.resolvedType, stringNumberSymbolType)) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } - else { - checkThatExpressionIsProperSymbolReference(node.expression, links.resolvedType, true); - } } return links.resolvedType; } @@ -55495,7 +57673,7 @@ var ts; var spread = emptyObjectType; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 196 || contextualType.pattern.kind === 200); + (contextualType.pattern.kind === 198 || contextualType.pattern.kind === 202); var inConstContext = isConstContext(node); var checkFlags = inConstContext ? 8 : 0; var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node); @@ -55507,7 +57685,7 @@ var ts; var hasComputedNumberProperty = false; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; - if (elem.name && ts.isComputedPropertyName(elem.name) && !ts.isWellKnownSymbolSyntactically(elem.name)) { + if (elem.name && ts.isComputedPropertyName(elem.name)) { checkComputedPropertyName(elem.name); } } @@ -55515,13 +57693,13 @@ 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 === 158 && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 160 ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 288 || - memberDecl.kind === 289 || + if (memberDecl.kind === 290 || + memberDecl.kind === 291 || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 288 ? checkPropertyAssignment(memberDecl, checkMode) : - memberDecl.kind === 289 ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : + var type = memberDecl.kind === 290 ? checkPropertyAssignment(memberDecl, checkMode) : + memberDecl.kind === 291 ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJavascript) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -55533,7 +57711,7 @@ var ts; checkTypeAssignableTo(type, getTypeFromTypeNode(enumTag.typeExpression), memberDecl); } } - objectFlags |= ts.getObjectFlags(type) & 3670016; + objectFlags |= ts.getObjectFlags(type) & 917504; var nameType = computedNameType && isTypeUsableAsPropertyName(computedNameType) ? computedNameType : undefined; var prop = nameType ? createSymbol(4 | member.flags, getPropertyNameFromType(nameType), checkFlags | 4096) : @@ -55542,8 +57720,8 @@ var ts; prop.nameType = nameType; } if (inDestructuringPattern) { - var isOptional = (memberDecl.kind === 288 && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 289 && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 290 && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 291 && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216; } @@ -55567,7 +57745,7 @@ var ts; member = prop; allPropertiesTable === null || allPropertiesTable === void 0 ? void 0 : allPropertiesTable.set(prop.escapedName, prop); } - else if (memberDecl.kind === 290) { + else if (memberDecl.kind === 292) { if (languageVersion < 2) { checkExternalEmitHelpers(memberDecl, 2); } @@ -55579,19 +57757,24 @@ var ts; hasComputedNumberProperty = false; } var type = getReducedType(checkExpression(memberDecl.expression)); - if (!isValidSpreadType(type)) { - error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); - return errorType; + if (isValidSpreadType(type)) { + if (allPropertiesTable) { + checkSpreadPropOverrides(type, allPropertiesTable, memberDecl); + } + offset = propertiesArray.length; + if (spread === errorType) { + continue; + } + spread = getSpreadType(spread, type, node.symbol, objectFlags, inConstContext); } - if (allPropertiesTable) { - checkSpreadPropOverrides(type, allPropertiesTable, memberDecl); + else { + error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); + spread = errorType; } - spread = getSpreadType(spread, type, node.symbol, objectFlags, inConstContext); - offset = propertiesArray.length; continue; } else { - ts.Debug.assert(memberDecl.kind === 167 || memberDecl.kind === 168); + ts.Debug.assert(memberDecl.kind === 169 || memberDecl.kind === 170); checkNodeDeferred(memberDecl); } if (computedNameType && !(computedNameType.flags & 8576)) { @@ -55612,7 +57795,7 @@ var ts; } propertiesArray.push(member); } - if (contextualTypeHasPattern && node.parent.kind !== 290) { + if (contextualTypeHasPattern && node.parent.kind !== 292) { for (var _d = 0, _e = getPropertiesOfType(contextualType); _d < _e.length; _d++) { var prop = _e[_d]; if (!propertiesTable.get(prop.escapedName) && !getPropertyOfType(spread, prop.escapedName)) { @@ -55624,6 +57807,9 @@ var ts; } } } + if (spread === errorType) { + return errorType; + } if (spread !== emptyObjectType) { if (propertiesArray.length > 0) { spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, objectFlags, inConstContext); @@ -55639,9 +57825,9 @@ var ts; var stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node, offset, propertiesArray, 0) : undefined; var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, offset, propertiesArray, 1) : undefined; var result = createAnonymousType(node.symbol, propertiesTable, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); - result.objectFlags |= objectFlags | 128 | 1048576; + result.objectFlags |= objectFlags | 128 | 262144; if (isJSObjectLiteral) { - result.objectFlags |= 16384; + result.objectFlags |= 8192; } if (patternWithComputedProperties) { result.objectFlags |= 512; @@ -55700,7 +57886,7 @@ var ts; return !ts.stringContains(name, "-"); } function isJsxIntrinsicIdentifier(tagName) { - return tagName.kind === 78 && ts.isIntrinsicJsxName(tagName.escapedText); + return tagName.kind === 79 && ts.isIntrinsicJsxName(tagName.escapedText); } function checkJsxAttribute(node, checkMode) { return node.initializer @@ -55715,14 +57901,14 @@ var ts; var hasSpreadAnyType = false; var typeToIntersect; var explicitlySpecifyChildrenAttribute = false; - var objectFlags = 4096; + var objectFlags = 2048; 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) & 3670016; + objectFlags |= ts.getObjectFlags(exprType) & 917504; var attributeSymbol = createSymbol(4 | member.flags, member.escapedName); attributeSymbol.declarations = member.declarations; attributeSymbol.parent = member.parent; @@ -55738,7 +57924,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 282); + ts.Debug.assert(attributeDecl.kind === 284); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, false); attributesTable = ts.createSymbolTable(); @@ -55763,7 +57949,7 @@ var ts; spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, false); } } - var parent = openingLikeElement.parent.kind === 273 ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 275 ? openingLikeElement.parent : undefined; if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) { var childrenTypes = checkJsxChildren(parent, checkMode); if (!hasSpreadAnyType && jsxChildrenPropertyName && jsxChildrenPropertyName !== "") { @@ -55774,7 +57960,7 @@ var ts; var childrenContextualType = contextualType && getTypeOfPropertyOfContextualType(contextualType, jsxChildrenPropertyName); var childrenPropSymbol = createSymbol(4, jsxChildrenPropertyName); childrenPropSymbol.type = childrenTypes.length === 1 ? childrenTypes[0] : - childrenContextualType && forEachType(childrenContextualType, isTupleLikeType) ? createTupleType(childrenTypes) : + childrenContextualType && someType(childrenContextualType, isTupleLikeType) ? createTupleType(childrenTypes) : createArrayType(getUnionType(childrenTypes)); childrenPropSymbol.valueDeclaration = ts.factory.createPropertySignature(undefined, ts.unescapeLeadingUnderscores(jsxChildrenPropertyName), undefined, undefined); ts.setParent(childrenPropSymbol.valueDeclaration, attributes); @@ -55794,7 +57980,7 @@ var ts; function createJsxAttributesType() { objectFlags |= freshObjectLiteralFlag; var result = createAnonymousType(attributes.symbol, attributesTable, ts.emptyArray, ts.emptyArray, undefined, undefined); - result.objectFlags |= objectFlags | 128 | 1048576; + result.objectFlags |= objectFlags | 128 | 262144; return result; } } @@ -55807,7 +57993,7 @@ var ts; childrenTypes.push(stringType); } } - else if (child.kind === 283 && !child.expression) { + else if (child.kind === 285 && !child.expression) { continue; } else { @@ -55930,7 +58116,7 @@ var ts; else if (propertiesOfJsxElementAttribPropInterface.length === 1) { return propertiesOfJsxElementAttribPropInterface[0].escapedName; } - else if (propertiesOfJsxElementAttribPropInterface.length > 1) { + else if (propertiesOfJsxElementAttribPropInterface.length > 1 && jsxElementAttribPropInterfaceSym.declarations) { error(jsxElementAttribPropInterfaceSym.declarations[0], ts.Diagnostics.The_global_type_JSX_0_may_not_have_more_than_one_property, ts.unescapeLeadingUnderscores(nameOfAttribPropContainer)); } } @@ -56019,11 +58205,11 @@ var ts; if (!links.resolvedJsxElementAttributesType) { var symbol = getIntrinsicTagSymbol(node); if (links.jsxFlags & 1) { - return links.resolvedJsxElementAttributesType = getTypeOfSymbol(symbol); + return links.resolvedJsxElementAttributesType = getTypeOfSymbol(symbol) || errorType; } else if (links.jsxFlags & 2) { return links.resolvedJsxElementAttributesType = - getIndexTypeOfType(getDeclaredTypeOfSymbol(symbol), 0); + getIndexTypeOfType(getJsxType(JsxNames.IntrinsicElements, node), 0) || errorType; } else { return links.resolvedJsxElementAttributesType = errorType; @@ -56140,34 +58326,37 @@ var ts; ts.getAssignmentDeclarationKind(parent) === 3; } } - function checkPropertyAccessibility(node, isSuper, type, prop) { - var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 157 ? node.right : node.kind === 195 ? node : node.name; + function checkPropertyAccessibility(node, isSuper, writing, type, prop, reportError) { + if (reportError === void 0) { reportError = true; } + var flags = ts.getDeclarationModifierFlagsFromSymbol(prop, writing); + var errorNode = node.kind === 159 ? node.right : + node.kind === 197 ? node : + node.kind === 200 && node.propertyName ? node.propertyName : node.name; if (isSuper) { if (languageVersion < 2) { if (symbolHasNonMethodDeclaration(prop)) { - error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); + if (reportError) { + error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); + } return false; } } if (flags & 128) { - error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(getDeclaringClass(prop))); + if (reportError) { + error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(getDeclaringClass(prop))); + } return false; } } - if ((flags & 128) && ts.isThisProperty(node) && symbolHasNonMethodDeclaration(prop)) { + if ((flags & 128) && symbolHasNonMethodDeclaration(prop) && + (ts.isThisProperty(node) || ts.isThisInitializedObjectBindingExpression(node) || ts.isObjectBindingPattern(node.parent) && ts.isThisInitializedDeclaration(node.parent.parent))) { var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (declaringClassDeclaration && isNodeUsedDuringClassInitialization(node)) { - error(errorNode, ts.Diagnostics.Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor, symbolToString(prop), ts.getTextOfIdentifierOrLiteral(declaringClassDeclaration.name)); - return false; - } - } - if (ts.isPropertyAccessExpression(node) && ts.isPrivateIdentifier(node.name)) { - if (!ts.getContainingClass(node)) { - error(errorNode, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); + if (reportError) { + error(errorNode, ts.Diagnostics.Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor, symbolToString(prop), ts.getTextOfIdentifierOrLiteral(declaringClassDeclaration.name)); + } return false; } - return true; } if (!(flags & 24)) { return true; @@ -56175,7 +58364,9 @@ var ts; if (flags & 8) { var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (!isNodeWithinClass(node, declaringClassDeclaration)) { - error(errorNode, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(getDeclaringClass(prop))); + if (reportError) { + error(errorNode, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(getDeclaringClass(prop))); + } return false; } return true; @@ -56185,12 +58376,14 @@ var ts; } var enclosingClass = forEachEnclosingClass(node, function (enclosingDeclaration) { var enclosingClass = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingDeclaration)); - return isClassDerivedFromDeclaringClasses(enclosingClass, prop) ? enclosingClass : undefined; + return isClassDerivedFromDeclaringClasses(enclosingClass, prop, writing) ? enclosingClass : undefined; }); if (!enclosingClass) { var thisParameter = void 0; if (flags & 32 || !(thisParameter = getThisParameterFromNodeContext(node)) || !thisParameter.type) { - error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || type)); + if (reportError) { + error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || type)); + } return false; } var thisType = getTypeFromTypeNode(thisParameter.type); @@ -56203,7 +58396,9 @@ var ts; type = type.isThisType ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(type); } if (!type || !hasBaseType(type, enclosingClass)) { - error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); + if (reportError) { + error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_This_is_an_instance_of_class_2, symbolToString(prop), typeToString(enclosingClass), typeToString(type)); + } return false; } return true; @@ -56259,20 +58454,20 @@ var ts; } return nonNullType; } - function checkPropertyAccessExpression(node) { - return node.flags & 32 ? checkPropertyAccessChain(node) : - checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullExpression(node.expression), node.name); + function checkPropertyAccessExpression(node, checkMode) { + return node.flags & 32 ? checkPropertyAccessChain(node, checkMode) : + checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullExpression(node.expression), node.name, checkMode); } - function checkPropertyAccessChain(node) { + function checkPropertyAccessChain(node, checkMode) { var leftType = checkExpression(node.expression); var nonOptionalType = getOptionalExpressionType(leftType, node.expression); - return propagateOptionalTypeMarker(checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullType(nonOptionalType, node.expression), node.name), node, nonOptionalType !== leftType); + return propagateOptionalTypeMarker(checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullType(nonOptionalType, node.expression), node.name, checkMode), node, nonOptionalType !== leftType); } - function checkQualifiedName(node) { - return checkPropertyAccessExpressionOrQualifiedName(node, node.left, checkNonNullExpression(node.left), node.right); + function checkQualifiedName(node, checkMode) { + return checkPropertyAccessExpressionOrQualifiedName(node, node.left, checkNonNullExpression(node.left), node.right, checkMode); } function isMethodAccessForCall(node) { - while (node.parent.kind === 207) { + while (node.parent.kind === 209) { node = node.parent; } return ts.isCallOrNewExpression(node.parent) && node.parent.expression === node; @@ -56304,10 +58499,9 @@ var ts; } var diagName = diagnosticName(right); if (propertyOnType) { - var typeValueDecl = propertyOnType.valueDeclaration; - var typeClass_1 = ts.getContainingClass(typeValueDecl); - ts.Debug.assert(!!typeClass_1); - if (lexicallyScopedIdentifier) { + var typeValueDecl = ts.Debug.checkDefined(propertyOnType.valueDeclaration); + var typeClass_1 = ts.Debug.checkDefined(ts.getContainingClass(typeValueDecl)); + if (lexicallyScopedIdentifier === null || lexicallyScopedIdentifier === void 0 ? void 0 : lexicallyScopedIdentifier.valueDeclaration) { var lexicalValueDecl = lexicallyScopedIdentifier.valueDeclaration; var lexicalClass = ts.getContainingClass(lexicalValueDecl); ts.Debug.assert(!!lexicalClass); @@ -56326,17 +58520,42 @@ var ts; return (isConstructorDeclaredProperty(prop) || ts.isThisProperty(node) && isAutoTypedProperty(prop)) && ts.getThisContainer(node, true) === getDeclaringConstructor(prop); } - function checkPropertyAccessExpressionOrQualifiedName(node, left, leftType, right) { + function checkPropertyAccessExpressionOrQualifiedName(node, left, leftType, right, checkMode) { var parentSymbol = getNodeLinks(left).resolvedSymbol; var assignmentKind = ts.getAssignmentTargetKind(node); var apparentType = getApparentType(assignmentKind !== 0 || isMethodAccessForCall(node) ? getWidenedType(leftType) : leftType); - if (ts.isPrivateIdentifier(right)) { - checkExternalEmitHelpers(node, 524288); - } var isAnyLike = isTypeAny(apparentType) || apparentType === silentNeverType; var prop; if (ts.isPrivateIdentifier(right)) { + if (languageVersion < 99) { + if (assignmentKind !== 0) { + checkExternalEmitHelpers(node, 1048576); + } + if (assignmentKind !== 1) { + checkExternalEmitHelpers(node, 524288); + } + } var lexicallyScopedSymbol = lookupSymbolForPrivateIdentifierDeclaration(right.escapedText, right); + if (assignmentKind && lexicallyScopedSymbol && lexicallyScopedSymbol.valueDeclaration && ts.isMethodDeclaration(lexicallyScopedSymbol.valueDeclaration)) { + grammarErrorOnNode(right, ts.Diagnostics.Cannot_assign_to_private_method_0_Private_methods_are_not_writable, ts.idText(right)); + } + if ((lexicallyScopedSymbol === null || lexicallyScopedSymbol === void 0 ? void 0 : lexicallyScopedSymbol.valueDeclaration) && (compilerOptions.target === 99 && !useDefineForClassFields)) { + var lexicalClass_1 = ts.getContainingClass(lexicallyScopedSymbol.valueDeclaration); + var parentStaticFieldInitializer = ts.findAncestor(node, function (n) { + if (n === lexicalClass_1) + return "quit"; + if (ts.isPropertyDeclaration(n.parent) && ts.hasStaticModifier(n.parent) && n.parent.initializer === n && n.parent.parent === lexicalClass_1) { + return true; + } + return false; + }); + if (parentStaticFieldInitializer) { + var parentStaticFieldInitializerSymbol = getSymbolOfNode(parentStaticFieldInitializer.parent); + ts.Debug.assert(parentStaticFieldInitializerSymbol, "Initializer without declaration symbol"); + var diagnostic = error(node, ts.Diagnostics.Property_0_may_not_be_used_in_a_static_property_s_initializer_in_the_same_class_when_target_is_esnext_and_useDefineForClassFields_is_false, ts.symbolName(lexicallyScopedSymbol)); + ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(parentStaticFieldInitializer.parent, ts.Diagnostics.Initializer_for_property_0, ts.symbolName(parentStaticFieldInitializerSymbol))); + } + } if (isAnyLike) { if (lexicallyScopedSymbol) { return apparentType; @@ -56350,6 +58569,12 @@ var ts; if (!prop && checkPrivateIdentifierPropertyAccess(leftType, right, lexicallyScopedSymbol)) { return errorType; } + else { + var isSetonlyAccessor = prop && prop.flags & 65536 && !(prop.flags & 32768); + if (isSetonlyAccessor && assignmentKind !== 1) { + error(node, ts.Diagnostics.Private_accessor_was_defined_without_a_getter); + } + } } else { if (isAnyLike) { @@ -56360,7 +58585,7 @@ var ts; } prop = getPropertyOfType(apparentType, right.escapedText); } - if (ts.isIdentifier(left) && parentSymbol && !(prop && isConstEnumOrConstEnumOnlyModule(prop))) { + if (ts.isIdentifier(left) && parentSymbol && (compilerOptions.isolatedModules || !(prop && isConstEnumOrConstEnumOnlyModule(prop)) || ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(node))) { markAliasReferenced(parentSymbol, node); } var propType; @@ -56393,37 +58618,43 @@ var ts; } } else { - if (getDeclarationNodeFlagsFromSymbol(prop) & 134217728 && isUncalledFunctionReference(node, prop)) { - errorOrSuggestion(false, right, ts.Diagnostics._0_is_deprecated, right.escapedText); + if (prop.declarations && getDeclarationNodeFlagsFromSymbol(prop) & 134217728 && isUncalledFunctionReference(node, prop)) { + addDeprecatedSuggestion(right, prop.declarations, right.escapedText); } checkPropertyNotUsedBeforeDeclaration(prop, node, right); - markPropertyAsReferenced(prop, node, left.kind === 107); + markPropertyAsReferenced(prop, node, isSelfTypeAccess(left, parentSymbol)); getNodeLinks(node).resolvedSymbol = prop; - checkPropertyAccessibility(node, left.kind === 105, apparentType, prop); + var writing = ts.isWriteAccess(node); + checkPropertyAccessibility(node, left.kind === 106, 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; } - propType = isThisPropertyAccessInConstructor(node, prop) ? autoType : getConstraintForLocation(getTypeOfSymbol(prop), node); + propType = isThisPropertyAccessInConstructor(node, prop) ? autoType : writing ? getSetAccessorTypeOfSymbol(prop) : getTypeOfSymbol(prop); } - return getFlowTypeOfAccessExpression(node, prop, propType, right); + return getFlowTypeOfAccessExpression(node, prop, propType, right, checkMode); } - function getFlowTypeOfAccessExpression(node, prop, propType, errorNode) { + function getFlowTypeOfAccessExpression(node, prop, propType, errorNode, checkMode) { var assignmentKind = ts.getAssignmentTargetKind(node); - if (!ts.isAccessExpression(node) || - assignmentKind === 1 || - prop && !(prop.flags & (3 | 4 | 98304)) && !(prop.flags & 8192 && propType.flags & 1048576)) { + if (assignmentKind === 1) { + return removeMissingType(propType, !!(prop && prop.flags & 16777216)); + } + if (prop && + !(prop.flags & (3 | 4 | 98304)) + && !(prop.flags & 8192 && propType.flags & 1048576) + && !isDuplicatedCommonJSExport(prop.declarations)) { return propType; } if (propType === autoType) { return getFlowTypeOfProperty(node, prop); } + propType = getNarrowableTypeForReference(propType, node, checkMode); var assumeUninitialized = false; - if (strictNullChecks && strictPropertyInitialization && node.expression.kind === 107) { + if (strictNullChecks && strictPropertyInitialization && ts.isAccessExpression(node) && node.expression.kind === 108) { var declaration = prop && prop.valueDeclaration; if (declaration && isInstancePropertyWithoutInitializer(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 166 && flowContainer.parent === declaration.parent && !(declaration.flags & 8388608)) { + if (flowContainer.kind === 168 && flowContainer.parent === declaration.parent && !(declaration.flags & 8388608)) { assumeUninitialized = true; } } @@ -56449,13 +58680,14 @@ var ts; var diagnosticMessage; var declarationName = ts.idText(right); if (isInPropertyInitializer(node) + && !isOptionalPropertyDeclaration(valueDeclaration) && !(ts.isAccessExpression(node) && ts.isAccessExpression(node.expression)) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) - && !isPropertyDeclaredInAncestorClass(prop)) { + && (compilerOptions.useDefineForClassFields || !isPropertyDeclaredInAncestorClass(prop))) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 252 && - node.parent.kind !== 173 && + else if (valueDeclaration.kind === 254 && + node.parent.kind !== 175 && !(valueDeclaration.flags & 8388608) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); @@ -56467,22 +58699,22 @@ var ts; function isInPropertyInitializer(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 163: - return true; - case 288: case 165: - case 167: - case 168: + return true; case 290: - case 158: - case 228: - case 283: - case 280: - case 281: + case 167: + case 169: + case 170: + case 292: + case 160: + case 230: + case 285: case 282: - case 275: - case 223: - case 286: + case 283: + case 284: + case 277: + case 225: + case 288: return false; default: return ts.isExpressionNode(node) ? false : "quit"; @@ -56550,7 +58782,10 @@ var ts; relatedInfo = suggestion.valueDeclaration && ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestedName); } else { - errorInfo = ts.chainDiagnosticMessages(elaborateNeverIntersection(errorInfo, containingType), ts.Diagnostics.Property_0_does_not_exist_on_type_1, missingProperty, container); + var diagnostic = containerSeemsToBeEmptyDomElement(containingType) + ? ts.Diagnostics.Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom + : ts.Diagnostics.Property_0_does_not_exist_on_type_1; + errorInfo = ts.chainDiagnosticMessages(elaborateNeverIntersection(errorInfo, containingType), diagnostic, missingProperty, container); } } } @@ -56561,9 +58796,14 @@ var ts; } diagnostics.add(resultDiagnostic); } + function containerSeemsToBeEmptyDomElement(containingType) { + return (compilerOptions.lib && !compilerOptions.lib.includes("dom")) && + everyContainedType(containingType, function (type) { return type.symbol && /^(EventTarget|Node|((HTML[a-zA-Z]*)?Element))$/.test(ts.unescapeLeadingUnderscores(type.symbol.escapedName)); }) && + isEmptyObjectType(containingType); + } function typeHasStaticProperty(propName, containingType) { var prop = containingType.symbol && getPropertyOfType(getTypeOfSymbol(containingType.symbol), propName); - return prop !== undefined && prop.valueDeclaration && ts.hasSyntacticModifier(prop.valueDeclaration, 32); + return prop !== undefined && !!prop.valueDeclaration && ts.hasSyntacticModifier(prop.valueDeclaration, 32); } function getSuggestedLibForNonExistentName(name) { var missingName = diagnosticName(name); @@ -56594,7 +58834,15 @@ var ts; } } function getSuggestedSymbolForNonexistentProperty(name, containingType) { - return getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 111551); + var props = getPropertiesOfType(containingType); + if (typeof name !== "string") { + var parent_2 = name.parent; + if (ts.isPropertyAccessExpression(parent_2)) { + props = ts.filter(props, function (prop) { return isValidPropertyAccessForCompletions(parent_2, containingType, prop); }); + } + name = ts.idText(name); + } + return getSpellingSuggestionForName(name, props, 111551); } function getSuggestedSymbolForNonexistentJSXAttribute(name, containingType) { var strName = ts.isString(name) ? name : ts.idText(name); @@ -56670,20 +58918,20 @@ var ts; return undefined; } } - function markPropertyAsReferenced(prop, nodeForCheckWriteOnly, isThisAccess) { + function markPropertyAsReferenced(prop, nodeForCheckWriteOnly, isSelfTypeAccess) { var valueDeclaration = prop && (prop.flags & 106500) && prop.valueDeclaration; if (!valueDeclaration) { return; } var hasPrivateModifier = ts.hasEffectiveModifier(valueDeclaration, 8); - var hasPrivateIdentifier = ts.isNamedDeclaration(prop.valueDeclaration) && ts.isPrivateIdentifier(prop.valueDeclaration.name); + 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)) { return; } - if (isThisAccess) { + if (isSelfTypeAccess) { var containingMethod = ts.findAncestor(nodeForCheckWriteOnly, ts.isFunctionLikeDeclaration); if (containingMethod && containingMethod.symbol === prop) { return; @@ -56691,18 +58939,22 @@ var ts; } (ts.getCheckFlags(prop) & 1 ? getSymbolLinks(prop).target : prop).isReferenced = 67108863; } + function isSelfTypeAccess(name, parent) { + return name.kind === 108 + || !!parent && ts.isEntityNameExpression(name) && parent === getResolvedSymbol(ts.getFirstIdentifier(name)); + } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 201: - return isValidPropertyAccessWithType(node, node.expression.kind === 105, propertyName, getWidenedType(checkExpression(node.expression))); - case 157: + case 203: + return isValidPropertyAccessWithType(node, node.expression.kind === 106, propertyName, getWidenedType(checkExpression(node.expression))); + case 159: return isValidPropertyAccessWithType(node, false, propertyName, getWidenedType(checkExpression(node.left))); - case 195: + case 197: return isValidPropertyAccessWithType(node, false, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind === 201 && node.expression.kind === 105, property.escapedName, type); + return isValidPropertyAccessWithType(node, node.kind === 203 && node.expression.kind === 106, property.escapedName, type); } function isValidPropertyAccessWithType(node, isSuper, propertyName, type) { if (type === errorType || isTypeAny(type)) { @@ -56710,23 +58962,23 @@ var ts; } var prop = getPropertyOfType(type, propertyName); if (prop) { - if (ts.isPropertyAccessExpression(node) && prop.valueDeclaration && ts.isPrivateIdentifierPropertyDeclaration(prop.valueDeclaration)) { + if (prop.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(prop.valueDeclaration)) { var declClass_1 = ts.getContainingClass(prop.valueDeclaration); return !ts.isOptionalChain(node) && !!ts.findAncestor(node, function (parent) { return parent === declClass_1; }); } - return checkPropertyAccessibility(node, isSuper, type, prop); + return checkPropertyAccessibility(node, isSuper, false, type, prop, false); } return ts.isInJSFile(node) && (type.flags & 1048576) !== 0 && type.types.some(function (elementType) { return isValidPropertyAccessWithType(node, isSuper, propertyName, elementType); }); } function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 250) { + if (initializer.kind === 252) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 78) { + else if (initializer.kind === 79) { return getResolvedSymbol(initializer); } return undefined; @@ -56736,13 +58988,13 @@ var ts; } function isForInVariableForNumericPropertyNames(expr) { var e = ts.skipParentheses(expr); - if (e.kind === 78) { + if (e.kind === 79) { var symbol = getResolvedSymbol(e); if (symbol.flags & 3) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 238 && + if (node.kind === 240 && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -56755,16 +59007,16 @@ var ts; } return false; } - function checkIndexedAccess(node) { - return node.flags & 32 ? checkElementAccessChain(node) : - checkElementAccessExpression(node, checkNonNullExpression(node.expression)); + function checkIndexedAccess(node, checkMode) { + return node.flags & 32 ? checkElementAccessChain(node, checkMode) : + checkElementAccessExpression(node, checkNonNullExpression(node.expression), checkMode); } - function checkElementAccessChain(node) { + function checkElementAccessChain(node, checkMode) { var exprType = checkExpression(node.expression); var nonOptionalType = getOptionalExpressionType(exprType, node.expression); - return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression)), node, nonOptionalType !== exprType); + return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression), checkMode), node, nonOptionalType !== exprType); } - function checkElementAccessExpression(node, exprType) { + function checkElementAccessExpression(node, exprType, checkMode) { var objectType = ts.getAssignmentTargetKind(node) !== 0 || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; var indexExpression = node.argumentExpression; var indexType = checkExpression(indexExpression); @@ -56777,40 +59029,10 @@ var ts; } var effectiveIndexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType; var accessFlags = ts.isAssignmentTarget(node) ? - 2 | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 1 : 0) : - 0; - var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, undefined, node, accessFlags | 16) || errorType; - return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, indexedAccessType.symbol, indexedAccessType, indexExpression), node); - } - function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) { - if (expressionType === errorType) { - return false; - } - if (!ts.isWellKnownSymbolSyntactically(expression)) { - return false; - } - if ((expressionType.flags & 12288) === 0) { - if (reportError) { - error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression)); - } - return false; - } - var leftHandSide = expression.expression; - var leftHandSideSymbol = getResolvedSymbol(leftHandSide); - if (!leftHandSideSymbol) { - return false; - } - var globalESSymbol = getGlobalESSymbolConstructorSymbol(true); - if (!globalESSymbol) { - return false; - } - if (leftHandSideSymbol !== globalESSymbol) { - if (reportError) { - error(leftHandSide, ts.Diagnostics.Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object); - } - return false; - } - return true; + 4 | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 2 : 0) : + 32; + var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, accessFlags, node) || errorType; + return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, getNodeLinks(node).resolvedSymbol, indexedAccessType, indexExpression, checkMode), node); } function callLikeExpressionMayHaveTypeArguments(node) { return ts.isCallOrNewExpression(node) || ts.isTaggedTemplateExpression(node) || ts.isJsxOpeningLikeElement(node); @@ -56819,13 +59041,13 @@ var ts; if (callLikeExpressionMayHaveTypeArguments(node)) { ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 205) { + if (node.kind === 207) { checkExpression(node.template); } else if (ts.isJsxOpeningLikeElement(node)) { checkExpression(node.attributes); } - else if (node.kind !== 161) { + else if (node.kind !== 163) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -56874,7 +59096,7 @@ var ts; } } function isSpreadArgument(arg) { - return !!arg && (arg.kind === 220 || arg.kind === 227 && arg.isSpread); + return !!arg && (arg.kind === 222 || arg.kind === 229 && arg.isSpread); } function getSpreadArgumentIndex(args) { return ts.findIndex(args, isSpreadArgument); @@ -56891,9 +59113,9 @@ var ts; var callIsIncomplete = false; var effectiveParameterCount = getParameterCount(signature); var effectiveMinimumArguments = getMinArgumentCount(signature); - if (node.kind === 205) { + if (node.kind === 207) { argCount = args.length; - if (node.template.kind === 218) { + if (node.template.kind === 220) { var lastSpan = ts.last(node.template.templateSpans); callIsIncomplete = ts.nodeIsMissing(lastSpan.literal) || !!lastSpan.literal.isUnterminated; } @@ -56903,7 +59125,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 161) { + else if (node.kind === 163) { argCount = getDecoratorArgumentCount(node, signature); } else if (ts.isJsxOpeningLikeElement(node)) { @@ -56916,7 +59138,7 @@ var ts; effectiveMinimumArguments = Math.min(effectiveMinimumArguments, 1); } else if (!node.arguments) { - ts.Debug.assert(node.kind === 204); + ts.Debug.assert(node.kind === 206); return getMinArgumentCount(signature) === 0; } else { @@ -56978,7 +59200,7 @@ var ts; }); if (!inferenceContext) { applyToReturnTypes(contextualSignature, signature, function (source, target) { - inferTypes(context.inferences, source, target, 64); + inferTypes(context.inferences, source, target, 128); }); } return getSignatureInstantiation(signature, getInferredTypes(context), ts.isInJSFile(contextualSignature.declaration)); @@ -56989,11 +59211,20 @@ var ts; inferTypes(context.inferences, checkAttrType, paramType); return getInferredTypes(context); } + function getThisArgumentType(thisArgumentNode) { + if (!thisArgumentNode) { + return voidType; + } + var thisArgumentType = checkExpression(thisArgumentNode); + return ts.isOptionalChainRoot(thisArgumentNode.parent) ? getNonNullableType(thisArgumentType) : + ts.isOptionalChain(thisArgumentNode.parent) ? removeOptionalTypeMarker(thisArgumentType) : + thisArgumentType; + } function inferTypeArguments(node, signature, args, checkMode, context) { if (ts.isJsxOpeningLikeElement(node)) { return inferJsxTypeArguments(node, signature, checkMode, context); } - if (node.kind !== 161) { + if (node.kind !== 163) { var contextualType = getContextualType(node, ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }) ? 8 : 0); if (contextualType) { var outerContext = getInferenceContext(node); @@ -57004,7 +59235,7 @@ var ts; getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) : instantiatedType; var inferenceTargetType = getReturnTypeOfSignature(signature); - inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 64); + inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128); var returnContext = createInferenceContext(signature.typeParameters, signature, context.flags); var returnSourceType = instantiateType(contextualType, outerContext && outerContext.returnMapper); inferTypes(returnContext.inferences, returnSourceType, inferenceTargetType); @@ -57022,12 +59253,11 @@ var ts; var thisType = getThisTypeOfSignature(signature); if (thisType) { var thisArgumentNode = getThisArgumentOfCall(node); - var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; - inferTypes(context.inferences, thisArgumentType, thisType); + inferTypes(context.inferences, getThisArgumentType(thisArgumentNode), thisType); } for (var i = 0; i < argCount; i++) { var arg = args[i]; - if (arg.kind !== 222) { + if (arg.kind !== 224) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode); inferTypes(context.inferences, argType, paramType); @@ -57049,7 +59279,7 @@ var ts; if (index >= argCount - 1) { var arg = args[argCount - 1]; if (isSpreadArgument(arg)) { - return getMutableArrayOrTupleType(arg.kind === 227 ? arg.type : + return getMutableArrayOrTupleType(arg.kind === 229 ? arg.type : checkExpressionWithContextualType(arg.expression, restType, context, checkMode)); } } @@ -57059,24 +59289,24 @@ var ts; for (var i = index; i < argCount; i++) { var arg = args[i]; if (isSpreadArgument(arg)) { - var spreadType = arg.kind === 227 ? arg.type : checkExpression(arg.expression); + var spreadType = arg.kind === 229 ? arg.type : checkExpression(arg.expression); if (isArrayLikeType(spreadType)) { types.push(spreadType); flags.push(8); } else { - types.push(checkIteratedTypeOrElementType(33, spreadType, undefinedType, arg.kind === 220 ? arg.expression : arg)); + types.push(checkIteratedTypeOrElementType(33, spreadType, undefinedType, arg.kind === 222 ? arg.expression : arg)); flags.push(4); } } else { - var contextualType = getIndexedAccessType(restType, getLiteralType(i - index)); + var contextualType = getIndexedAccessType(restType, getLiteralType(i - index), 256); var argType = checkExpressionWithContextualType(arg, contextualType, context, checkMode); var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 131068 | 4194304 | 134217728 | 268435456); types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType)); flags.push(1); } - if (arg.kind === 227 && arg.tupleNameSource) { + if (arg.kind === 229 && arg.tupleNameSource) { names.push(arg.tupleNameSource); } } @@ -57207,21 +59437,9 @@ var ts; return undefined; } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 204) { + if (thisType && thisType !== voidType && node.kind !== 206) { var thisArgumentNode = getThisArgumentOfCall(node); - var thisArgumentType = void 0; - if (thisArgumentNode) { - thisArgumentType = checkExpression(thisArgumentNode); - if (ts.isOptionalChainRoot(thisArgumentNode.parent)) { - thisArgumentType = getNonNullableType(thisArgumentType); - } - else if (ts.isOptionalChain(thisArgumentNode.parent)) { - thisArgumentType = removeOptionalTypeMarker(thisArgumentType); - } - } - else { - thisArgumentType = voidType; - } + var thisArgumentType = getThisArgumentType(thisArgumentNode); var errorNode = reportErrors ? (thisArgumentNode || node) : undefined; var headMessage_1 = ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1; if (!checkTypeRelatedTo(thisArgumentType, thisType, relation, errorNode, headMessage_1, containingMessageChain, errorOutputContainer)) { @@ -57234,7 +59452,7 @@ 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 !== 222) { + if (arg.kind !== 224) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, undefined, checkMode); var checkArgType = checkMode & 4 ? getRegularTypeOfObjectLiteral(argType) : argType; @@ -57272,7 +59490,7 @@ var ts; } } function getThisArgumentOfCall(node) { - if (node.kind === 203) { + if (node.kind === 205) { var callee = ts.skipOuterExpressions(node.expression); if (ts.isAccessExpression(callee)) { return callee.expression; @@ -57286,17 +59504,17 @@ var ts; return result; } function getEffectiveCallArguments(node) { - if (node.kind === 205) { + if (node.kind === 207) { var template = node.template; var args_3 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())]; - if (template.kind === 218) { + if (template.kind === 220) { ts.forEach(template.templateSpans, function (span) { args_3.push(span.expression); }); } return args_3; } - if (node.kind === 161) { + if (node.kind === 163) { return getEffectiveDecoratorArguments(node); } if (ts.isJsxOpeningLikeElement(node)) { @@ -57306,9 +59524,9 @@ var ts; var spreadIndex = getSpreadArgumentIndex(args); if (spreadIndex >= 0) { var effectiveArgs_1 = args.slice(0, spreadIndex); - var _loop_20 = function (i) { + var _loop_21 = function (i) { var arg = args[i]; - var spreadType = arg.kind === 220 && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression)); + var spreadType = arg.kind === 222 && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression)); if (spreadType && isTupleType(spreadType)) { ts.forEach(getTypeArguments(spreadType), function (t, i) { var _a; @@ -57322,7 +59540,7 @@ var ts; } }; for (var i = spreadIndex; i < args.length; i++) { - _loop_20(i); + _loop_21(i); } return effectiveArgs_1; } @@ -57332,23 +59550,23 @@ var ts; var parent = node.parent; var expr = node.expression; switch (parent.kind) { - case 252: - case 221: + case 254: + case 223: return [ createSyntheticExpression(expr, getTypeOfSymbol(getSymbolOfNode(parent))) ]; - case 160: + case 162: var func = parent.parent; return [ - createSyntheticExpression(expr, parent.parent.kind === 166 ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), + createSyntheticExpression(expr, parent.parent.kind === 168 ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), createSyntheticExpression(expr, anyType), createSyntheticExpression(expr, numberType) ]; - case 163: case 165: case 167: - case 168: - var hasPropDesc = parent.kind !== 163 && languageVersion !== 0; + case 169: + case 170: + var hasPropDesc = parent.kind !== 165 && languageVersion !== 0; return [ createSyntheticExpression(expr, getParentTypeOfClassElement(parent)), createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)), @@ -57359,16 +59577,16 @@ var ts; } function getDecoratorArgumentCount(node, signature) { switch (node.parent.kind) { - case 252: - case 221: + case 254: + case 223: return 1; - case 163: - return 2; case 165: + return 2; case 167: - case 168: + case 169: + case 170: return languageVersion === 0 || signature.parameters.length <= 2 ? 2 : 3; - case 160: + case 162: return 3; default: return ts.Debug.fail(); @@ -57414,77 +59632,61 @@ var ts; return constructorSymbol === globalPromiseSymbol; } function getArgumentArityError(node, signatures, args) { + var _a; + var spreadIndex = getSpreadArgumentIndex(args); + if (spreadIndex > -1) { + return ts.createDiagnosticForNode(args[spreadIndex], ts.Diagnostics.A_spread_argument_must_either_have_a_tuple_type_or_be_passed_to_a_rest_parameter); + } var min = Number.POSITIVE_INFINITY; var max = Number.NEGATIVE_INFINITY; - var belowArgCount = Number.NEGATIVE_INFINITY; - var aboveArgCount = Number.POSITIVE_INFINITY; - var argCount = args.length; + var maxBelow = Number.NEGATIVE_INFINITY; + var minAbove = Number.POSITIVE_INFINITY; var closestSignature; for (var _i = 0, signatures_8 = signatures; _i < signatures_8.length; _i++) { var sig = signatures_8[_i]; - var minCount = getMinArgumentCount(sig); - var maxCount = getParameterCount(sig); - if (minCount < argCount && minCount > belowArgCount) - belowArgCount = minCount; - if (argCount < maxCount && maxCount < aboveArgCount) - aboveArgCount = maxCount; - if (minCount < min) { - min = minCount; + var minParameter = getMinArgumentCount(sig); + var maxParameter = getParameterCount(sig); + if (minParameter < min) { + min = minParameter; closestSignature = sig; } - max = Math.max(max, maxCount); + max = Math.max(max, maxParameter); + if (minParameter < args.length && minParameter > maxBelow) + maxBelow = minParameter; + if (args.length < maxParameter && maxParameter < minAbove) + minAbove = maxParameter; } var hasRestParameter = ts.some(signatures, hasEffectiveRestParameter); - var paramRange = hasRestParameter ? min : - min < max ? min + "-" + max : - min; - var hasSpreadArgument = getSpreadArgumentIndex(args) > -1; - if (argCount <= max && hasSpreadArgument) { - argCount--; - } - var spanArray; - var related; - var error = hasRestParameter || hasSpreadArgument ? - hasRestParameter && hasSpreadArgument ? - ts.Diagnostics.Expected_at_least_0_arguments_but_got_1_or_more : - hasRestParameter ? - ts.Diagnostics.Expected_at_least_0_arguments_but_got_1 : - ts.Diagnostics.Expected_0_arguments_but_got_1_or_more : - paramRange === 1 && argCount === 0 && isPromiseResolveArityError(node) ? - ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise : - ts.Diagnostics.Expected_0_arguments_but_got_1; - if (closestSignature && getMinArgumentCount(closestSignature) > argCount && closestSignature.declaration) { - var paramDecl = closestSignature.declaration.parameters[closestSignature.thisParameter ? argCount + 1 : argCount]; - if (paramDecl) { - related = ts.createDiagnosticForNode(paramDecl, ts.isBindingPattern(paramDecl.name) ? ts.Diagnostics.An_argument_matching_this_binding_pattern_was_not_provided : - ts.isRestParameter(paramDecl) ? ts.Diagnostics.Arguments_for_the_rest_parameter_0_were_not_provided : ts.Diagnostics.An_argument_for_0_was_not_provided, !paramDecl.name ? argCount : !ts.isBindingPattern(paramDecl.name) ? ts.idText(ts.getFirstIdentifier(paramDecl.name)) : undefined); - } - } - if (min < argCount && argCount < max) { - return getDiagnosticForCallNode(node, ts.Diagnostics.No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments, argCount, belowArgCount, aboveArgCount); - } - if (!hasSpreadArgument && argCount < min) { - var diagnostic_1 = getDiagnosticForCallNode(node, error, paramRange, argCount); - return related ? ts.addRelatedInfo(diagnostic_1, related) : diagnostic_1; - } - if (hasRestParameter || hasSpreadArgument) { - spanArray = ts.factory.createNodeArray(args); - if (hasSpreadArgument && argCount) { - var nextArg = ts.elementAt(args, getSpreadArgumentIndex(args) + 1) || undefined; - spanArray = ts.factory.createNodeArray(args.slice(max > argCount && nextArg ? args.indexOf(nextArg) : Math.min(max, args.length - 1))); + var parameterRange = hasRestParameter ? min + : min < max ? min + "-" + max + : min; + var error = hasRestParameter ? ts.Diagnostics.Expected_at_least_0_arguments_but_got_1 + : parameterRange === 1 && args.length === 0 && isPromiseResolveArityError(node) ? ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise + : ts.Diagnostics.Expected_0_arguments_but_got_1; + if (min < args.length && args.length < max) { + return getDiagnosticForCallNode(node, ts.Diagnostics.No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments, args.length, maxBelow, minAbove); + } + else if (args.length < min) { + var diagnostic = getDiagnosticForCallNode(node, error, parameterRange, args.length); + var parameter = (_a = closestSignature === null || closestSignature === void 0 ? void 0 : closestSignature.declaration) === null || _a === void 0 ? void 0 : _a.parameters[closestSignature.thisParameter ? args.length + 1 : args.length]; + if (parameter) { + var parameterError = ts.createDiagnosticForNode(parameter, ts.isBindingPattern(parameter.name) ? ts.Diagnostics.An_argument_matching_this_binding_pattern_was_not_provided + : ts.isRestParameter(parameter) ? ts.Diagnostics.Arguments_for_the_rest_parameter_0_were_not_provided + : ts.Diagnostics.An_argument_for_0_was_not_provided, !parameter.name ? args.length : !ts.isBindingPattern(parameter.name) ? ts.idText(ts.getFirstIdentifier(parameter.name)) : undefined); + return ts.addRelatedInfo(diagnostic, parameterError); } + return diagnostic; } else { - spanArray = ts.factory.createNodeArray(args.slice(max)); - } - var pos = ts.first(spanArray).pos; - var end = ts.last(spanArray).end; - if (end === pos) { - end++; + var errorSpan = ts.factory.createNodeArray(args.slice(max)); + var pos = ts.first(errorSpan).pos; + var end = ts.last(errorSpan).end; + if (end === pos) { + end++; + } + ts.setTextRangePosEnd(errorSpan, pos, end); + return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), errorSpan, error, parameterRange, args.length); } - ts.setTextRangePosEnd(spanArray, pos, end); - var diagnostic = ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), spanArray, error, paramRange, argCount); - return related ? ts.addRelatedInfo(diagnostic, related) : diagnostic; } function getTypeArgumentArityError(node, signatures, typeArguments) { var argCount = typeArguments.length; @@ -57513,14 +59715,14 @@ 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 === 205; - var isDecorator = node.kind === 161; + var isTaggedTemplate = node.kind === 207; + var isDecorator = node.kind === 163; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var reportErrors = !candidatesOutArray && produceDiagnostics; var typeArguments; if (!isDecorator) { typeArguments = node.typeArguments; - if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 105) { + if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 106) { ts.forEach(typeArguments, checkSourceElement); } } @@ -57539,7 +59741,7 @@ var ts; var candidateForArgumentArityError; var candidateForTypeArgumentError; var result; - var signatureHelpTrailingComma = !!(checkMode & 16) && node.kind === 203 && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = !!(checkMode & 16) && node.kind === 205 && node.arguments.hasTrailingComma; if (candidates.length > 1) { result = chooseOverload(candidates, subtypeRelation, isSingleNonGenericCandidate, signatureHelpTrailingComma); } @@ -57579,7 +59781,7 @@ var ts; var min_3 = Number.MAX_VALUE; var minIndex = 0; var i_1 = 0; - var _loop_21 = function (c) { + var _loop_22 = 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) { @@ -57597,7 +59799,7 @@ var ts; }; for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) { var c = candidatesForArgumentError_1[_a]; - _loop_21(c); + _loop_22(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"); @@ -57740,7 +59942,7 @@ var ts; } var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max; var parameters = []; - var _loop_22 = function (i) { + var _loop_23 = 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; }); @@ -57748,7 +59950,7 @@ var ts; parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); }))); }; for (var i = 0; i < maxNonRestParam; i++) { - _loop_22(i); + _loop_23(i); } var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; }); var flags = 0; @@ -57818,7 +60020,7 @@ var ts; return maxParamsIndex; } function resolveCallExpression(node, candidatesOutArray, checkMode) { - if (node.expression.kind === 105) { + if (node.expression.kind === 106) { var superType = checkSuperExpression(node.expression); if (isTypeAny(superType)) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { @@ -57895,7 +60097,7 @@ var ts; } function isUntypedFunctionCall(funcType, apparentFuncType, numCallSignatures, numConstructSignatures) { return isTypeAny(funcType) || isTypeAny(apparentFuncType) && !!(funcType.flags & 262144) || - !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & (1048576 | 131072)) && isTypeAssignableTo(funcType, globalFunctionType); + !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & 1048576) && !(getReducedType(apparentFuncType).flags & 131072) && isTypeAssignableTo(funcType, globalFunctionType); } function resolveNewExpression(node, candidatesOutArray, checkMode) { if (node.arguments && languageVersion < 1) { @@ -57987,7 +60189,7 @@ var ts; } var declaration = signature.declaration; var modifiers = ts.getSelectedEffectiveModifierFlags(declaration, 24); - if (!modifiers || declaration.kind !== 166) { + if (!modifiers || declaration.kind !== 168) { return true; } var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(declaration.parent.symbol); @@ -58119,16 +60321,16 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 252: - case 221: + case 254: + case 223: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 160: + case 162: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 163: - return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; case 165: + return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; case 167: - case 168: + case 169: + case 170: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; default: return ts.Debug.fail(); @@ -58169,7 +60371,7 @@ var ts; var exports = namespace && getExportsOfSymbol(namespace); var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968); var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968, node); - var declaration = ts.factory.createFunctionTypeNode(undefined, [ts.factory.createParameterDeclaration(undefined, undefined, undefined, "props", undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.factory.createTypeReferenceNode(returnNode, undefined) : ts.factory.createKeywordTypeNode(128)); + var declaration = ts.factory.createFunctionTypeNode(undefined, [ts.factory.createParameterDeclaration(undefined, undefined, undefined, "props", undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.factory.createTypeReferenceNode(returnNode, undefined) : ts.factory.createKeywordTypeNode(129)); var parameterSymbol = createSymbol(1, "props"); parameterSymbol.type = result; return createSignature(declaration, undefined, undefined, [parameterSymbol], typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType, undefined, 1, 0); @@ -58209,16 +60411,16 @@ var ts; } function resolveSignature(node, candidatesOutArray, checkMode) { switch (node.kind) { - case 203: + case 205: return resolveCallExpression(node, candidatesOutArray, checkMode); - case 204: + case 206: return resolveNewExpression(node, candidatesOutArray, checkMode); - case 205: + case 207: return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode); - case 161: + case 163: return resolveDecorator(node, candidatesOutArray, checkMode); - case 275: - case 274: + case 277: + case 276: return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode); } throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); @@ -58296,7 +60498,7 @@ var ts; else if (ts.isBinaryExpression(node.parent)) { var parentNode = node.parent; var parentNodeOperator = node.parent.operatorToken.kind; - if (parentNodeOperator === 62 && (allowDeclaration || parentNode.right === node)) { + if (parentNodeOperator === 63 && (allowDeclaration || parentNode.right === node)) { name = parentNode.left; decl = name; } @@ -58305,7 +60507,7 @@ var ts; name = parentNode.parent.name; decl = parentNode.parent; } - else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 62 && (allowDeclaration || parentNode.parent.right === parentNode)) { + else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 63 && (allowDeclaration || parentNode.parent.right === parentNode)) { name = parentNode.parent.left; decl = name; } @@ -58328,10 +60530,10 @@ var ts; return false; } var parent = node.parent; - while (parent && parent.kind === 201) { + while (parent && parent.kind === 203) { parent = parent.parent; } - if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 62) { + if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 63) { var right = ts.getInitializerOfBinaryExpression(parent); return ts.isObjectLiteralExpression(right) && right; } @@ -58345,15 +60547,15 @@ var ts; return nonInferrableType; } checkDeprecatedSignature(signature, node); - if (node.expression.kind === 105) { + if (node.expression.kind === 106) { return voidType; } - if (node.kind === 204) { + if (node.kind === 206) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 166 && - declaration.kind !== 170 && - declaration.kind !== 175 && + declaration.kind !== 168 && + declaration.kind !== 172 && + declaration.kind !== 177 && !ts.isJSDocConstructSignature(declaration) && !isJSConstructor(declaration)) { if (noImplicitAny) { @@ -58369,7 +60571,7 @@ var ts; if (returnType.flags & 12288 && isSymbolOrSymbolForCall(node)) { return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent)); } - if (node.kind === 203 && node.parent.kind === 233 && + if (node.kind === 205 && !node.questionDotToken && node.parent.kind === 235 && returnType.flags & 16384 && getTypePredicateOfSignature(signature)) { if (!ts.isDottedName(node.expression)) { error(node.expression, ts.Diagnostics.Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name); @@ -58383,7 +60585,7 @@ var ts; var jsSymbol = getSymbolOfExpando(node, 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, undefined, undefined); - jsAssignmentType.objectFlags |= 16384; + jsAssignmentType.objectFlags |= 8192; return getIntersectionType([returnType, jsAssignmentType]); } } @@ -58392,26 +60594,27 @@ var ts; function checkDeprecatedSignature(signature, node) { if (signature.declaration && signature.declaration.flags & 134217728) { var suggestionNode = getDeprecatedSuggestionNode(node); - errorOrSuggestion(false, suggestionNode, ts.Diagnostics._0_is_deprecated, signatureToString(signature)); + var name = ts.tryGetPropertyAccessOrIdentifierToString(ts.getInvokedExpression(node)); + addDeprecatedSuggestionWithSignature(suggestionNode, signature.declaration, name, signatureToString(signature)); } } function getDeprecatedSuggestionNode(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 203: - case 161: - case 204: - return getDeprecatedSuggestionNode(node.expression); case 205: + case 163: + case 206: + return getDeprecatedSuggestionNode(node.expression); + case 207: return getDeprecatedSuggestionNode(node.tag); - case 275: - case 274: + case 277: + case 276: return getDeprecatedSuggestionNode(node.tagName); - case 202: + case 204: return node.argumentExpression; - case 201: + case 203: return node.name; - case 173: + case 175: var typeReference = node; return ts.isQualifiedName(typeReference.typeName) ? typeReference.typeName.right : typeReference; default: @@ -58458,10 +60661,11 @@ var ts; return createPromiseReturnType(node, anyType); } function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol) { + var _a; if (allowSyntheticDefaultImports && type && type !== errorType) { var synthType = type; if (!synthType.syntheticType) { - var file = ts.find(originalSymbol.declarations, ts.isSourceFile); + var file = (_a = originalSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, false); if (hasSyntheticDefault) { var memberTable = ts.createSymbolTable(); @@ -58497,9 +60701,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 - ? 251 + ? 253 : resolvedRequire.flags & 3 - ? 249 + ? 251 : 0; if (targetDeclarationKind !== 0) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -58526,21 +60730,21 @@ var ts; case 14: case 8: case 9: - case 109: - case 94: - case 199: - case 200: - case 218: + case 110: + case 95: + case 201: + case 202: + case 220: return true; - case 207: + case 209: return isValidConstAssertionArgument(node.expression); - case 214: + case 216: var op = node.operator; var arg = node.operand; return op === 40 && (arg.kind === 8 || arg.kind === 9) || op === 39 && arg.kind === 8; - case 201: - case 202: + case 203: + case 204: var expr = node.expression; if (ts.isIdentifier(expr)) { var symbol = getSymbolAtLocation(expr); @@ -58582,10 +60786,10 @@ var ts; } function checkMetaProperty(node) { checkGrammarMetaProperty(node); - if (node.keywordToken === 102) { + if (node.keywordToken === 103) { return checkNewTargetMetaProperty(node); } - if (node.keywordToken === 99) { + if (node.keywordToken === 100) { return checkImportMetaProperty(node); } return ts.Debug.assertNever(node.keywordToken); @@ -58596,7 +60800,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 === 166) { + else if (container.kind === 168) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -58643,7 +60847,7 @@ var ts; return restParameter.escapedName; } function isValidDeclarationForTupleLabel(d) { - return d.kind === 192 || (ts.isParameter(d) && d.name && ts.isIdentifier(d.name)); + return d.kind === 194 || (ts.isParameter(d) && d.name && ts.isIdentifier(d.name)); } function getNameableDeclarationAtPosition(signature, pos) { var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); @@ -58797,7 +61001,14 @@ var ts; } } function assignContextualParameterTypes(signature, context) { - signature.typeParameters = context.typeParameters; + if (context.typeParameters) { + if (!signature.typeParameters) { + signature.typeParameters = context.typeParameters; + } + else { + return; + } + } if (context.thisParameter) { var parameter = signature.thisParameter; if (!parameter || parameter.valueDeclaration && !parameter.valueDeclaration.type) { @@ -58837,7 +61048,7 @@ var ts; if (!links.type) { var declaration = parameter.valueDeclaration; links.type = type || getWidenedTypeForVariableLikeDeclaration(declaration, true); - if (declaration.name.kind !== 78) { + if (declaration.name.kind !== 79) { if (links.type === unknownType) { links.type = getTypeFromBindingPattern(declaration.name); } @@ -58849,7 +61060,7 @@ var ts; for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { var element = _a[_i]; if (!ts.isOmittedExpression(element)) { - if (element.name.kind === 78) { + if (element.name.kind === 79) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } else { @@ -58900,7 +61111,7 @@ var ts; var yieldType; var nextType; var fallbackReturnType = voidType; - if (func.body.kind !== 230) { + if (func.body.kind !== 232) { returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8); if (isAsync) { returnType = checkAwaitedType(returnType, func, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); @@ -59050,7 +61261,7 @@ var ts; return links.isExhaustive !== undefined ? links.isExhaustive : (links.isExhaustive = computeExhaustiveSwitchStatement(node)); } function computeExhaustiveSwitchStatement(node) { - if (node.expression.kind === 211) { + if (node.expression.kind === 213) { var operandType = getTypeOfExpression(node.expression.expression); var witnesses = getSwitchClauseTypeOfWitnesses(node, false); var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, true); @@ -59105,11 +61316,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 208: - case 209: + case 210: + case 211: return true; - case 165: - return func.parent.kind === 200; + case 167: + return func.parent.kind === 202; default: return false; } @@ -59123,18 +61334,19 @@ var ts; if (type && maybeTypeOfKind(type, 1 | 16384)) { return; } - if (func.kind === 164 || ts.nodeIsMissing(func.body) || func.body.kind !== 230 || !functionHasImplicitReturn(func)) { + if (func.kind === 166 || ts.nodeIsMissing(func.body) || func.body.kind !== 232 || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 512; + var errorNode = ts.getEffectiveReturnTypeNode(func) || func; if (type && type.flags & 131072) { - error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); + error(errorNode, ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); } else if (type && !hasExplicitReturn) { - error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value); + error(errorNode, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value); } else if (type && strictNullChecks && !isTypeAssignableTo(undefinedType, type)) { - error(ts.getEffectiveReturnTypeNode(func) || func, ts.Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined); + error(errorNode, ts.Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined); } else if (compilerOptions.noImplicitReturns) { if (!type) { @@ -59146,11 +61358,11 @@ var ts; return; } } - error(ts.getEffectiveReturnTypeNode(func) || func, ts.Diagnostics.Not_all_code_paths_return_a_value); + error(errorNode, ts.Diagnostics.Not_all_code_paths_return_a_value); } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 165 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 167 || ts.isObjectLiteralMethod(node)); checkNodeDeferred(node); if (checkMode && checkMode & 4 && isContextSensitive(node)) { if (!ts.getEffectiveReturnTypeNode(node) && !hasContextSensitiveParameters(node)) { @@ -59163,14 +61375,14 @@ var ts; var returnType = getReturnTypeFromBody(node, checkMode); var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, undefined, 0, 0); var returnOnlyType = createAnonymousType(node.symbol, emptySymbols, [returnOnlySignature], ts.emptyArray, undefined, undefined); - returnOnlyType.objectFlags |= 2097152; + returnOnlyType.objectFlags |= 524288; return links.contextFreeType = returnOnlyType; } } return anyFunctionType; } var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 208) { + if (!hasGrammarError && node.kind === 210) { checkGrammarForGenerator(node); } contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -59211,7 +61423,7 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 165 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 167 || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnType = getReturnTypeFromAnnotation(node); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); @@ -59219,7 +61431,7 @@ var ts; if (!ts.getEffectiveReturnTypeNode(node)) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 230) { + if (node.body.kind === 232) { checkSourceElement(node.body); } else { @@ -59289,9 +61501,9 @@ var ts; if (isReadonlySymbol(symbol)) { if (symbol.flags & 4 && ts.isAccessExpression(expr) && - expr.expression.kind === 107) { + expr.expression.kind === 108) { var ctor = ts.getContainingFunction(expr); - if (!(ctor && (ctor.kind === 166 || isJSConstructor(ctor)))) { + if (!(ctor && (ctor.kind === 168 || isJSConstructor(ctor)))) { return true; } if (symbol.valueDeclaration) { @@ -59311,11 +61523,11 @@ var ts; } if (ts.isAccessExpression(expr)) { var node = ts.skipParentheses(expr.expression); - if (node.kind === 78) { + if (node.kind === 79) { var symbol_2 = getNodeLinks(node).resolvedSymbol; if (symbol_2.flags & 2097152) { var declaration = getDeclarationOfAliasSymbol(symbol_2); - return !!declaration && declaration.kind === 263; + return !!declaration && declaration.kind === 265; } } } @@ -59323,7 +61535,7 @@ var ts; } function checkReferenceExpression(expr, invalidReferenceMessage, invalidOptionalChainMessage) { var node = ts.skipOuterExpressions(expr, 6 | 1); - if (node.kind !== 78 && !ts.isAccessExpression(node)) { + if (node.kind !== 79 && !ts.isAccessExpression(node)) { error(expr, invalidReferenceMessage); return false; } @@ -59393,7 +61605,7 @@ var ts; 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); var func = ts.getContainingFunction(node); - if (func && func.kind !== 166 && (ts.getFunctionFlags(func) & 2) === 0) { + if (func && func.kind !== 168 && (ts.getFunctionFlags(func) & 2) === 0) { var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); } @@ -59551,8 +61763,11 @@ var ts; isTypeAssignableToKind(leftType, 4194304 | 134217728 | 268435456 | 262144))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } - if (!allTypesAssignableToKind(rightType, 67108864 | 58982400)) { - error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); + var rightTypeConstraint = getConstraintOfType(rightType); + if (!allTypesAssignableToKind(rightType, 67108864 | 58982400) || + rightTypeConstraint && (isTypeAssignableToKind(rightType, 3145728) && !allTypesAssignableToKind(rightTypeConstraint, 67108864 | 58982400) || + !maybeTypeOfKind(rightTypeConstraint, 67108864 | 58982400 | 524288))) { + error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_not_be_a_primitive); } return booleanType; } @@ -59570,7 +61785,7 @@ var ts; if (rightIsThis === void 0) { rightIsThis = false; } var properties = node.properties; var property = properties[propertyIndex]; - if (property.kind === 288 || property.kind === 289) { + if (property.kind === 290 || property.kind === 291) { var name = property.name; var exprType = getLiteralTypeFromPropertyName(name); if (isTypeUsableAsPropertyName(exprType)) { @@ -59578,14 +61793,14 @@ var ts; var prop = getPropertyOfType(objectLiteralType, text); if (prop) { markPropertyAsReferenced(prop, property, rightIsThis); - checkPropertyAccessibility(property, false, objectLiteralType, prop); + checkPropertyAccessibility(property, false, true, objectLiteralType, prop); } } - var elementType = getIndexedAccessType(objectLiteralType, exprType, undefined, name, undefined, undefined, 16); + var elementType = getIndexedAccessType(objectLiteralType, exprType, 32, name); var type = getFlowTypeOfDestructuring(property, elementType); - return checkDestructuringAssignment(property.kind === 289 ? property : property.initializer, type); + return checkDestructuringAssignment(property.kind === 291 ? property : property.initializer, type); } - else if (property.kind === 290) { + else if (property.kind === 292) { if (propertyIndex < properties.length - 1) { error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } @@ -59620,7 +61835,7 @@ var ts; var inBoundsType = compilerOptions.noUncheckedIndexedAccess ? undefined : possiblyOutOfBoundsType; for (var i = 0; i < elements.length; i++) { var type = possiblyOutOfBoundsType; - if (node.elements[i].kind === 220) { + if (node.elements[i].kind === 222) { type = inBoundsType = inBoundsType !== null && inBoundsType !== void 0 ? inBoundsType : (checkIteratedTypeOrElementType(65, sourceType, undefinedType, node) || errorType); } checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, type, checkMode); @@ -59630,12 +61845,12 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 222) { - if (element.kind !== 220) { + if (element.kind !== 224) { + if (element.kind !== 222) { var indexType = getLiteralType(elementIndex); if (isArrayLikeType(sourceType)) { - var accessFlags = 16 | (hasDefaultValue(element) ? 8 : 0); - var elementType_2 = getIndexedAccessTypeOrUndefined(sourceType, indexType, undefined, createSyntheticExpression(element, indexType), accessFlags) || errorType; + var accessFlags = 32 | (hasDefaultValue(element) ? 16 : 0); + var elementType_2 = getIndexedAccessTypeOrUndefined(sourceType, indexType, accessFlags, createSyntheticExpression(element, indexType)) || errorType; var assignedType = hasDefaultValue(element) ? getTypeWithFacts(elementType_2, 524288) : elementType_2; var type = getFlowTypeOfDestructuring(element, assignedType); return checkDestructuringAssignment(element, type, checkMode); @@ -59647,7 +61862,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 216 && restExpression.operatorToken.kind === 62) { + if (restExpression.kind === 218 && restExpression.operatorToken.kind === 63) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -59663,7 +61878,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) { var target; - if (exprOrAssignment.kind === 289) { + if (exprOrAssignment.kind === 291) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { if (strictNullChecks && @@ -59677,24 +61892,24 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 216 && target.operatorToken.kind === 62) { + if (target.kind === 218 && target.operatorToken.kind === 63) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 200) { + if (target.kind === 202) { return checkObjectLiteralAssignment(target, sourceType, rightIsThis); } - if (target.kind === 199) { + if (target.kind === 201) { 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 === 290 ? + var error = target.parent.kind === 292 ? 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 === 290 ? + var optionalError = target.parent.kind === 292 ? 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)) { @@ -59708,39 +61923,39 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 78: + case 79: case 10: case 13: - case 205: - case 218: + case 207: + case 220: case 14: case 8: case 9: - case 109: - case 94: - case 103: - case 150: - case 208: - case 221: - case 209: - case 199: - case 200: + case 110: + case 95: + case 104: + case 151: + case 210: + case 223: case 211: - case 225: - case 274: - case 273: + case 201: + case 202: + case 213: + case 227: + case 276: + case 275: return true; - case 217: + case 219: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 216: + case 218: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 214: - case 215: + case 216: + case 217: switch (node.operator) { case 53: case 39: @@ -59749,9 +61964,9 @@ var ts; return true; } return false; - case 212: - case 206: - case 224: + case 214: + case 208: + case 226: default: return false; } @@ -59759,74 +61974,107 @@ var ts; function isTypeEqualityComparableTo(source, target) { return (target.flags & 98304) !== 0 || isTypeComparableTo(source, target); } - function checkBinaryExpression(node, checkMode) { - var workStacks = { - expr: [node], - state: [0], - leftType: [undefined] + function createCheckBinaryExpression() { + var trampoline = ts.createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, foldState); + return function (node, checkMode) { + var result = trampoline(node, checkMode); + ts.Debug.assertIsDefined(result); + return result; }; - var stackIndex = 0; - var lastResult; - while (stackIndex >= 0) { - node = workStacks.expr[stackIndex]; - switch (workStacks.state[stackIndex]) { - case 0: { - if (ts.isInJSFile(node) && ts.getAssignedExpandoInitializer(node)) { - finishInvocation(checkExpression(node.right, checkMode)); - break; - } - checkGrammarNullishCoalesceWithLogicalExpression(node); - var operator = node.operatorToken.kind; - if (operator === 62 && (node.left.kind === 200 || node.left.kind === 199)) { - finishInvocation(checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 107)); - break; - } - advanceState(1); - maybeCheckExpression(node.left); - break; - } - case 1: { - var leftType = lastResult; - workStacks.leftType[stackIndex] = leftType; - var operator = node.operatorToken.kind; - if (operator === 55 || operator === 56 || operator === 60) { - if (operator === 55) { - var parent = ts.walkUpParenthesizedExpressions(node.parent); - checkTestingKnownTruthyCallableType(node.left, leftType, ts.isIfStatement(parent) ? parent.thenStatement : undefined); - } - checkTruthinessOfType(leftType, node.left); + function onEnter(node, state, checkMode) { + if (state) { + state.stackIndex++; + state.skip = false; + setLeftType(state, undefined); + setLastResult(state, undefined); + } + else { + state = { + checkMode: checkMode, + skip: false, + stackIndex: 0, + typeStack: [undefined, undefined], + }; + } + if (ts.isInJSFile(node) && ts.getAssignedExpandoInitializer(node)) { + state.skip = true; + setLastResult(state, checkExpression(node.right, checkMode)); + return state; + } + checkGrammarNullishCoalesceWithLogicalExpression(node); + var operator = node.operatorToken.kind; + if (operator === 63 && (node.left.kind === 202 || node.left.kind === 201)) { + state.skip = true; + setLastResult(state, checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 108)); + return state; + } + return state; + } + function onLeft(left, state, _node) { + if (!state.skip) { + return maybeCheckExpression(state, left); + } + } + function onOperator(operatorToken, state, node) { + if (!state.skip) { + var leftType = getLastResult(state); + ts.Debug.assertIsDefined(leftType); + setLeftType(state, leftType); + setLastResult(state, undefined); + var operator = operatorToken.kind; + if (operator === 55 || operator === 56 || operator === 60) { + if (operator === 55) { + var parent = ts.walkUpParenthesizedExpressions(node.parent); + checkTestingKnownTruthyCallableOrAwaitableType(node.left, leftType, ts.isIfStatement(parent) ? parent.thenStatement : undefined); } - advanceState(2); - maybeCheckExpression(node.right); - break; + checkTruthinessOfType(leftType, node.left); } - case 2: { - var leftType = workStacks.leftType[stackIndex]; - var rightType = lastResult; - finishInvocation(checkBinaryLikeExpressionWorker(node.left, node.operatorToken, node.right, leftType, rightType, node)); - break; - } - default: return ts.Debug.fail("Invalid state " + workStacks.state[stackIndex] + " for checkBinaryExpression"); } } - return lastResult; - function finishInvocation(result) { - lastResult = result; - stackIndex--; - } - function advanceState(nextState) { - workStacks.state[stackIndex] = nextState; + function onRight(right, state, _node) { + if (!state.skip) { + return maybeCheckExpression(state, right); + } } - function maybeCheckExpression(node) { - if (ts.isBinaryExpression(node)) { - stackIndex++; - workStacks.expr[stackIndex] = node; - workStacks.state[stackIndex] = 0; - workStacks.leftType[stackIndex] = undefined; + function onExit(node, state) { + var result; + if (state.skip) { + result = getLastResult(state); } else { - lastResult = checkExpression(node, checkMode); + var leftType = getLeftType(state); + ts.Debug.assertIsDefined(leftType); + var rightType = getLastResult(state); + ts.Debug.assertIsDefined(rightType); + result = checkBinaryLikeExpressionWorker(node.left, node.operatorToken, node.right, leftType, rightType, node); + } + state.skip = false; + setLeftType(state, undefined); + setLastResult(state, undefined); + state.stackIndex--; + return result; + } + function foldState(state, result, _side) { + setLastResult(state, result); + return state; + } + function maybeCheckExpression(state, node) { + if (ts.isBinaryExpression(node)) { + return node; } + setLastResult(state, checkExpression(node, state.checkMode)); + } + function getLeftType(state) { + return state.typeStack[state.stackIndex]; + } + function setLeftType(state, type) { + state.typeStack[state.stackIndex] = type; + } + function getLastResult(state) { + return state.typeStack[state.stackIndex + 1]; + } + function setLastResult(state, type) { + state.typeStack[state.stackIndex + 1] = type; } } function checkGrammarNullishCoalesceWithLogicalExpression(node) { @@ -59842,8 +62090,8 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 62 && (left.kind === 200 || left.kind === 199)) { - return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 107); + if (operator === 63 && (left.kind === 202 || left.kind === 201)) { + return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 108); } var leftType; if (operator === 55 || operator === 56 || operator === 60) { @@ -59860,26 +62108,26 @@ var ts; switch (operator) { case 41: case 42: - case 65: case 66: - case 43: case 67: - case 44: + case 43: case 68: + case 44: + case 69: case 40: - case 64: + case 65: case 47: - case 69: - case 48: case 70: - case 49: + case 48: case 71: + case 49: + case 72: case 51: - case 73: + case 74: case 52: - case 77: + case 78: case 50: - case 72: + case 73: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -59903,11 +62151,11 @@ var ts; else if (bothAreBigIntLike(leftType, rightType)) { switch (operator) { case 49: - case 71: + case 72: reportOperatorError(); break; case 42: - case 66: + case 67: if (languageVersion < 3) { error(errorNode, ts.Diagnostics.Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_later); } @@ -59924,7 +62172,7 @@ var ts; return resultType_1; } case 39: - case 63: + case 64: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -59956,7 +62204,7 @@ var ts; }); return anyType; } - if (operator === 63) { + if (operator === 64) { checkAssignmentOperator(resultType); } return resultType; @@ -59978,41 +62226,41 @@ var ts; case 37: reportOperatorErrorUnless(function (left, right) { return isTypeEqualityComparableTo(left, right) || isTypeEqualityComparableTo(right, left); }); return booleanType; - case 101: + case 102: return checkInstanceOfExpression(left, right, leftType, rightType); - case 100: + case 101: return checkInExpression(left, right, leftType, rightType); case 55: - case 75: { + case 76: { var resultType_2 = getTypeFacts(leftType) & 4194304 ? getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) : leftType; - if (operator === 75) { + if (operator === 76) { checkAssignmentOperator(rightType); } return resultType_2; } case 56: - case 74: { + case 75: { var resultType_3 = getTypeFacts(leftType) & 8388608 ? getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2) : leftType; - if (operator === 74) { + if (operator === 75) { checkAssignmentOperator(rightType); } return resultType_3; } case 60: - case 76: { + case 77: { var resultType_4 = getTypeFacts(leftType) & 262144 ? getUnionType([getNonNullableType(leftType), rightType], 2) : leftType; - if (operator === 76) { + if (operator === 77) { checkAssignmentOperator(rightType); } return resultType_4; } - case 62: + case 63: var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0; checkAssignmentDeclaration(declKind, rightType); if (isAssignmentDeclaration(declKind)) { @@ -60058,7 +62306,7 @@ var ts; if (propType.symbol && propType.symbol.flags & 32) { var name = prop.escapedName; var symbol = resolveName(prop.valueDeclaration, name, 788968, undefined, name, false); - if (symbol && symbol.declarations.some(ts.isJSDocTypedefTag)) { + 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); } @@ -60067,7 +62315,7 @@ var ts; } } function isEvalNode(node) { - return node.kind === 78 && node.escapedText === "eval"; + return node.kind === 79 && node.escapedText === "eval"; } function checkForDisallowedESSymbolOperand(operator) { var offendingSymbolOperand = maybeTypeOfKind(leftType, 12288) ? left : @@ -60082,13 +62330,13 @@ var ts; function getSuggestedBooleanOperator(operator) { switch (operator) { case 51: - case 73: + case 74: return 56; case 52: - case 77: + case 78: return 37; case 50: - case 72: + case 73: return 55; default: return undefined; @@ -60234,7 +62482,7 @@ var ts; } function checkConditionalExpression(node, checkMode) { var type = checkTruthinessExpression(node.condition); - checkTestingKnownTruthyCallableType(node.condition, type, node.whenTrue); + checkTestingKnownTruthyCallableOrAwaitableType(node.condition, type, node.whenTrue); var type1 = checkExpression(node.whenTrue, checkMode); var type2 = checkExpression(node.whenFalse, checkMode); return getUnionType([type1, type2], 2); @@ -60251,10 +62499,14 @@ var ts; texts.push(span.literal.text); types.push(isTypeAssignableTo(type, templateConstraintType) ? type : stringType); } - return getFreshTypeOfLiteralType(getTemplateLiteralType(texts, types)); + return isConstContext(node) || someType(getContextualType(node) || unknownType, isTemplateLiteralContextualType) ? getTemplateLiteralType(texts, types) : stringType; + } + function isTemplateLiteralContextualType(type) { + return !!(type.flags & (128 | 134217728) || + type.flags & 58982400 && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 402653316)); } function getContextNode(node) { - if (node.kind === 281 && !ts.isJsxSelfClosingElement(node.parent)) { + if (node.kind === 283 && !ts.isJsxSelfClosingElement(node.parent)) { return node.parent.parent; } return node; @@ -60267,7 +62519,7 @@ var ts; context.contextualType = contextualType; context.inferenceContext = inferenceContext; var type = checkExpression(node, checkMode | 1 | (inferenceContext ? 2 : 0)); - var result = maybeTypeOfKind(type, 134220672) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ? + var result = maybeTypeOfKind(type, 2944) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ? getRegularTypeOfLiteralType(type) : type; return result; } @@ -60294,13 +62546,13 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 206 || node.kind === 224; + return node.kind === 208 || node.kind === 226; } function checkDeclarationInitializer(declaration, contextualType) { var initializer = ts.getEffectiveInitializer(declaration); var type = getQuickTypeOfExpression(initializer) || (contextualType ? checkExpressionWithContextualType(initializer, contextualType, undefined, 0) : checkExpressionCached(initializer)); - return ts.isParameter(declaration) && declaration.name.kind === 197 && + return ts.isParameter(declaration) && declaration.name.kind === 199 && isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ? padTupleType(type, declaration.name) : type; } @@ -60310,7 +62562,7 @@ 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 === 198 && e.dotDotDotToken)) { + if (i < patternElements.length - 1 || !(e.kind === 200 && e.dotDotDotToken)) { elementTypes.push(!ts.isOmittedExpression(e) && hasDefaultValue(e) ? getTypeFromBindingElement(e, false, false) : anyType); elementFlags.push(2); if (!ts.isOmittedExpression(e) && !hasDefaultValue(e)) { @@ -60323,7 +62575,7 @@ var ts; function widenTypeInferredFromInitializer(declaration, type) { var widened = ts.getCombinedNodeFlags(declaration) & 2 || ts.isDeclarationReadonly(declaration) ? type : getWidenedLiteralType(type); if (ts.isInJSFile(declaration)) { - if (widened.flags & 98304) { + if (isEmptyLiteralType(widened)) { reportImplicitAny(declaration, anyType); return anyType; } @@ -60342,13 +62594,13 @@ var ts; } if (contextualType.flags & 58982400) { var constraint = getBaseConstraintOfType(contextualType) || unknownType; - return maybeTypeOfKind(constraint, 4) && maybeTypeOfKind(candidateType, 134217856) || + return maybeTypeOfKind(constraint, 4) && maybeTypeOfKind(candidateType, 128) || maybeTypeOfKind(constraint, 8) && maybeTypeOfKind(candidateType, 256) || maybeTypeOfKind(constraint, 64) && maybeTypeOfKind(candidateType, 2048) || maybeTypeOfKind(constraint, 4096) && maybeTypeOfKind(candidateType, 8192) || isLiteralOfContextualType(candidateType, constraint); } - return !!(contextualType.flags & (134217856 | 4194304 | 268435456) && maybeTypeOfKind(candidateType, 134217856) || + return !!(contextualType.flags & (128 | 4194304 | 134217728 | 268435456) && maybeTypeOfKind(candidateType, 128) || contextualType.flags & 256 && maybeTypeOfKind(candidateType, 256) || contextualType.flags & 2048 && maybeTypeOfKind(candidateType, 2048) || contextualType.flags & 512 && maybeTypeOfKind(candidateType, 512) || @@ -60369,14 +62621,14 @@ var ts; getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node) : contextualType, node)); } function checkPropertyAssignment(node, checkMode) { - if (node.name.kind === 158) { + if (node.name.kind === 160) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); } function checkObjectLiteralMethod(node, checkMode) { checkGrammarMethod(node); - if (node.name.kind === 158) { + if (node.name.kind === 160) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -60486,7 +62738,7 @@ var ts; len--; var s = baseName.slice(0, len); for (var index = 1; true; index++) { - var augmentedName = (s + index); + var augmentedName = s + index; if (!hasTypeParameterByName(typeParameters, augmentedName)) { return augmentedName; } @@ -60526,7 +62778,7 @@ var ts; } function getQuickTypeOfExpression(node) { var expr = ts.skipParentheses(node); - if (ts.isCallExpression(expr) && expr.expression.kind !== 105 && !ts.isRequireCall(expr, true) && !isSymbolOrSymbolForCall(expr)) { + if (ts.isCallExpression(expr) && expr.expression.kind !== 106 && !ts.isRequireCall(expr, true) && !isSymbolOrSymbolForCall(expr)) { var type = ts.isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) : getReturnTypeOfSingleNonGenericCallSignature(checkNonNullExpression(expr.expression)); if (type) { @@ -60537,7 +62789,7 @@ var ts; return getTypeFromTypeNode(expr.type); } else if (node.kind === 8 || node.kind === 10 || - node.kind === 109 || node.kind === 94) { + node.kind === 110 || node.kind === 95) { return checkExpression(node); } return undefined; @@ -60558,7 +62810,7 @@ var ts; } } function checkExpression(node, checkMode, forceTuple) { - ts.tracing.push("check", "checkExpression", { kind: node.kind, pos: node.pos, end: node.end }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check", "checkExpression", { kind: node.kind, pos: node.pos, end: node.end }); var saveCurrentNode = currentNode; currentNode = node; instantiationCount = 0; @@ -60568,15 +62820,15 @@ var ts; checkConstEnumAccess(node, type); } currentNode = saveCurrentNode; - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return type; } function checkConstEnumAccess(node, type) { - var ok = (node.parent.kind === 201 && node.parent.expression === node) || - (node.parent.kind === 202 && node.parent.expression === node) || - ((node.kind === 78 || node.kind === 157) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 176 && node.parent.exprName === node)) || - (node.parent.kind === 270); + var ok = (node.parent.kind === 203 && node.parent.expression === node) || + (node.parent.kind === 204 && node.parent.expression === node) || + ((node.kind === 79 || node.kind === 159) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 178 && node.parent.exprName === node)) || + (node.parent.kind === 272); 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); } @@ -60591,7 +62843,7 @@ var ts; function checkParenthesizedExpression(node, checkMode) { var tag = ts.isInJSFile(node) ? ts.getJSDocTypeTag(node) : undefined; if (tag) { - return checkAssertionWorker(tag, tag.typeExpression.type, node.expression, checkMode); + return checkAssertionWorker(tag.typeExpression.type, tag.typeExpression.type, node.expression, checkMode); } return checkExpression(node.expression, checkMode); } @@ -60599,20 +62851,20 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { - case 221: - case 208: - case 209: + case 223: + case 210: + case 211: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 78: - return checkIdentifier(node); - case 107: + case 79: + return checkIdentifier(node, checkMode); + case 108: return checkThisExpression(node); - case 105: + case 106: return checkSuperExpression(node); - case 103: + case 104: return nullWideningType; case 14: case 10: @@ -60623,81 +62875,81 @@ var ts; case 9: checkGrammarBigIntLiteral(node); return getFreshTypeOfLiteralType(getBigIntLiteralType(node)); - case 109: + case 110: return trueType; - case 94: + case 95: return falseType; - case 218: + case 220: return checkTemplateExpression(node); case 13: return globalRegExpType; - case 199: - return checkArrayLiteral(node, checkMode, forceTuple); - case 200: - return checkObjectLiteral(node, checkMode); case 201: - return checkPropertyAccessExpression(node); - case 157: - return checkQualifiedName(node); + return checkArrayLiteral(node, checkMode, forceTuple); case 202: - return checkIndexedAccess(node); + return checkObjectLiteral(node, checkMode); case 203: - if (node.expression.kind === 99) { + return checkPropertyAccessExpression(node, checkMode); + case 159: + return checkQualifiedName(node, checkMode); + case 204: + return checkIndexedAccess(node, checkMode); + case 205: + if (node.expression.kind === 100) { return checkImportCallExpression(node); } - case 204: + case 206: return checkCallExpression(node, checkMode); - case 205: - return checkTaggedTemplateExpression(node); case 207: + return checkTaggedTemplateExpression(node); + case 209: return checkParenthesizedExpression(node, checkMode); - case 221: + case 223: return checkClassExpression(node); - case 208: - case 209: - return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); + case 210: case 211: + return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); + case 213: return checkTypeOfExpression(node); - case 206: - case 224: + case 208: + case 226: return checkAssertion(node); - case 225: + case 227: return checkNonNullAssertion(node); - case 226: + case 228: return checkMetaProperty(node); - case 210: - return checkDeleteExpression(node); case 212: + return checkDeleteExpression(node); + case 214: return checkVoidExpression(node); - case 213: + case 215: return checkAwaitExpression(node); - case 214: + case 216: return checkPrefixUnaryExpression(node); - case 215: + case 217: return checkPostfixUnaryExpression(node); - case 216: + case 218: return checkBinaryExpression(node, checkMode); - case 217: + case 219: return checkConditionalExpression(node, checkMode); - case 220: - return checkSpreadExpression(node, checkMode); case 222: + return checkSpreadExpression(node, checkMode); + case 224: return undefinedWideningType; - case 219: + case 221: return checkYieldExpression(node); - case 227: + case 229: return checkSyntheticExpression(node); - case 283: + case 285: return checkJsxExpression(node, checkMode); - case 273: + case 275: return checkJsxElement(node, checkMode); - case 274: + case 276: return checkJsxSelfClosingElement(node, checkMode); - case 277: + case 279: return checkJsxFragment(node); - case 281: + case 283: return checkJsxAttributes(node, checkMode); - case 275: + case 277: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -60726,11 +62978,11 @@ var ts; checkGrammarDecoratorsAndModifiers(node); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); - if (ts.hasSyntacticModifier(node, 92)) { - if (!(func.kind === 166 && ts.nodeIsPresent(func.body))) { + if (ts.hasSyntacticModifier(node, 16476)) { + if (!(func.kind === 168 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } - if (func.kind === 166 && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") { + if (func.kind === 168 && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") { error(node.name, ts.Diagnostics.constructor_cannot_be_used_as_a_parameter_property_name); } } @@ -60741,13 +62993,13 @@ var ts; if (func.parameters.indexOf(node) !== 0) { error(node, ts.Diagnostics.A_0_parameter_must_be_the_first_parameter, node.name.escapedText); } - if (func.kind === 166 || func.kind === 170 || func.kind === 175) { + if (func.kind === 168 || func.kind === 172 || func.kind === 177) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } - if (func.kind === 209) { + if (func.kind === 211) { error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter); } - if (func.kind === 167 || func.kind === 168) { + if (func.kind === 169 || func.kind === 170) { error(node, ts.Diagnostics.get_and_set_accessors_cannot_declare_this_parameters); } } @@ -60801,13 +63053,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 209: - case 169: - case 251: - case 208: - case 174: - case 165: - case 164: + case 211: + case 171: + case 253: + case 210: + case 176: + case 167: + case 166: var parent = node.parent; if (node === parent.type) { return parent; @@ -60821,11 +63073,11 @@ var ts; continue; } var name = element.name; - if (name.kind === 78 && name.escapedText === predicateVariableName) { + if (name.kind === 79 && 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 === 197 || name.kind === 196) { + else if (name.kind === 199 || name.kind === 198) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -60833,12 +63085,12 @@ var ts; } } function checkSignatureDeclaration(node) { - if (node.kind === 171) { + if (node.kind === 173) { checkGrammarIndexSignature(node); } - else if (node.kind === 174 || node.kind === 251 || node.kind === 175 || - node.kind === 169 || node.kind === 166 || - node.kind === 170) { + else if (node.kind === 176 || node.kind === 253 || node.kind === 177 || + node.kind === 171 || node.kind === 168 || + node.kind === 172) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); @@ -60863,10 +63115,10 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 170: + case 172: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 169: + case 171: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -60890,7 +63142,7 @@ var ts; checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 171 && node.kind !== 308) { + if (node.kind !== 173 && node.kind !== 311) { registerForUnusedIdentifiersCheck(node); } } @@ -60901,7 +63153,7 @@ 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 === 166) { + if (member.kind === 168) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param, member) && !ts.isBindingPattern(param.name)) { @@ -60913,25 +63165,27 @@ var ts; var isStatic = ts.hasSyntacticModifier(member, 32); var name = member.name; if (!name) { - return; + continue; } - var names = ts.isPrivateIdentifier(name) ? privateIdentifiers : + var isPrivate = ts.isPrivateIdentifier(name); + var privateStaticFlags = isPrivate && isStatic ? 16 : 0; + var names = isPrivate ? privateIdentifiers : isStatic ? staticNames : instanceNames; var memberName = name && ts.getPropertyNameForPropertyNameNode(name); if (memberName) { switch (member.kind) { - case 167: - addName(names, name, memberName, 1); + case 169: + addName(names, name, memberName, 1 | privateStaticFlags); break; - case 168: - addName(names, name, memberName, 2); - break; - case 163: - addName(names, name, memberName, 3); + case 170: + addName(names, name, memberName, 2 | privateStaticFlags); break; case 165: - addName(names, name, memberName, 8); + addName(names, name, memberName, 3 | privateStaticFlags); + break; + case 167: + addName(names, name, memberName, 8 | privateStaticFlags); break; } } @@ -60940,16 +63194,23 @@ var ts; function addName(names, location, name, meaning) { var prev = names.get(name); if (prev) { - if (prev & 8) { - if (meaning !== 8) { - error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); - } - } - else if (prev & meaning) { - error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); + if ((prev & 16) !== (meaning & 16)) { + error(location, ts.Diagnostics.Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name, ts.getTextOfNode(location)); } else { - names.set(name, prev | meaning); + var prevIsMethod = !!(prev & 8); + var isMethod = !!(meaning & 8); + if (prevIsMethod || isMethod) { + if (prevIsMethod !== isMethod) { + error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); + } + } + else if (prev & meaning & ~16) { + error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); + } + else { + names.set(name, prev | meaning); + } } } else { @@ -60982,7 +63243,7 @@ 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 === 162) { + if (member.kind === 164) { var memberName = void 0; var name = member.name; switch (name.kind) { @@ -60990,7 +63251,7 @@ var ts; case 8: memberName = name.text; break; - case 78: + case 79: memberName = ts.idText(name); break; default: @@ -61007,14 +63268,14 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 253) { + if (node.kind === 255) { var nodeSymbol = getSymbolOfNode(node); - if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { + if (nodeSymbol.declarations && nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; } } var indexSymbol = getIndexSymbol(getSymbolOfNode(node)); - if (indexSymbol) { + if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) { var seenNumericIndexer = false; var seenStringIndexer = false; for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -61022,7 +63283,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 147: + case 148: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -61030,7 +63291,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 144: + case 145: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -61047,10 +63308,12 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && !checkGrammarProperty(node)) checkGrammarComputedPropertyName(node.name); checkVariableLikeDeclaration(node); - if (ts.isPrivateIdentifier(node.name) && languageVersion < 99) { - for (var lexicalScope = ts.getEnclosingBlockScopeContainer(node); !!lexicalScope; lexicalScope = ts.getEnclosingBlockScopeContainer(lexicalScope)) { - getNodeLinks(lexicalScope).flags |= 67108864; - } + setNodeLinksForPrivateIdentifierScope(node); + if (ts.isPrivateIdentifier(node.name) && ts.hasStaticModifier(node) && node.initializer && languageVersion === 99 && !compilerOptions.useDefineForClassFields) { + error(node.initializer, ts.Diagnostics.Static_fields_with_private_names_can_t_have_initializers_when_the_useDefineForClassFields_flag_is_not_specified_with_a_target_of_esnext_Consider_adding_the_useDefineForClassFields_flag); + } + if (ts.hasSyntacticModifier(node, 128) && node.kind === 165 && node.initializer) { + error(node, ts.Diagnostics.Property_0_cannot_have_an_initializer_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } function checkPropertySignature(node) { @@ -61062,13 +63325,28 @@ var ts; function checkMethodDeclaration(node) { if (!checkGrammarMethod(node)) checkGrammarComputedPropertyName(node.name); - if (ts.isPrivateIdentifier(node.name)) { - error(node, ts.Diagnostics.A_method_cannot_be_named_with_a_private_identifier); - } checkFunctionOrMethodDeclaration(node); - if (ts.hasSyntacticModifier(node, 128) && node.kind === 165 && node.body) { + if (ts.hasSyntacticModifier(node, 128) && node.kind === 167 && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } + if (ts.isPrivateIdentifier(node.name) && !ts.getContainingClass(node)) { + error(node, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); + } + setNodeLinksForPrivateIdentifierScope(node); + } + function setNodeLinksForPrivateIdentifierScope(node) { + if (ts.isPrivateIdentifier(node.name) && languageVersion < 99) { + for (var lexicalScope = ts.getEnclosingBlockScopeContainer(node); !!lexicalScope; lexicalScope = ts.getEnclosingBlockScopeContainer(lexicalScope)) { + getNodeLinks(lexicalScope).flags |= 67108864; + } + if (ts.isClassExpression(node.parent)) { + var enclosingIterationStatement = getEnclosingIterationStatement(node.parent); + if (enclosingIterationStatement) { + getNodeLinks(node.name).flags |= 524288; + getNodeLinks(enclosingIterationStatement).flags |= 65536; + } + } + } } function checkConstructorDeclaration(node) { checkSignatureDeclaration(node); @@ -61087,10 +63365,10 @@ var ts; return; } function isInstancePropertyWithInitializerOrPrivateIdentifierProperty(n) { - if (ts.isPrivateIdentifierPropertyDeclaration(n)) { + if (ts.isPrivateIdentifierClassElementDeclaration(n)) { return true; } - return n.kind === 163 && + return n.kind === 165 && !ts.hasSyntacticModifier(n, 32) && !!n.initializer; } @@ -61103,15 +63381,15 @@ var ts; if (classExtendsNull) { error(superCall, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null); } - var superCallShouldBeFirst = (compilerOptions.target !== 99 || !compilerOptions.useDefineForClassFields) && + var superCallShouldBeFirst = (compilerOptions.target !== 99 || !useDefineForClassFields) && (ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) || - ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 92); })); + ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476); })); if (superCallShouldBeFirst) { var statements = node.body.statements; var superCallStatement = void 0; for (var _i = 0, statements_4 = statements; _i < statements_4.length; _i++) { var statement = statements_4[_i]; - if (statement.kind === 233 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 235 && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -61135,48 +63413,47 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 167) { + if (node.kind === 169) { if (!(node.flags & 8388608) && ts.nodeIsPresent(node.body) && (node.flags & 256)) { if (!(node.flags & 512)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); } } } - if (node.name.kind === 158) { + if (node.name.kind === 160) { checkComputedPropertyName(node.name); } - if (ts.isPrivateIdentifier(node.name)) { - error(node.name, ts.Diagnostics.An_accessor_cannot_be_named_with_a_private_identifier); - } - if (!hasNonBindableDynamicName(node)) { - var otherKind = node.kind === 167 ? 168 : 167; - var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); - if (otherAccessor) { - var nodeFlags = ts.getEffectiveModifierFlags(node); - var otherFlags = ts.getEffectiveModifierFlags(otherAccessor); - if ((nodeFlags & 28) !== (otherFlags & 28)) { - error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); + if (hasBindableName(node)) { + var symbol = getSymbolOfNode(node); + var getter = ts.getDeclarationOfKind(symbol, 169); + var setter = ts.getDeclarationOfKind(symbol, 170); + if (getter && setter && !(getNodeCheckFlags(getter) & 1)) { + getNodeLinks(getter).flags |= 1; + var getterFlags = ts.getEffectiveModifierFlags(getter); + var setterFlags = ts.getEffectiveModifierFlags(setter); + if ((getterFlags & 128) !== (setterFlags & 128)) { + 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) && !(setterFlags & (16 | 8))) || + ((getterFlags & 8) && !(setterFlags & 8))) { + 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); } - if ((nodeFlags & 128) !== (otherFlags & 128)) { - error(node.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); + var getterType = getAnnotatedAccessorType(getter); + var setterType = getAnnotatedAccessorType(setter); + if (getterType && setterType) { + checkTypeAssignableTo(getterType, setterType, getter, ts.Diagnostics.The_return_type_of_a_get_accessor_must_be_assignable_to_its_set_accessor_type); } - checkAccessorDeclarationTypesIdentical(node, otherAccessor, getAnnotatedAccessorType, ts.Diagnostics.get_and_set_accessor_must_have_the_same_type); - checkAccessorDeclarationTypesIdentical(node, otherAccessor, getThisTypeOfDeclaration, ts.Diagnostics.get_and_set_accessor_must_have_the_same_this_type); } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 167) { + if (node.kind === 169) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } checkSourceElement(node.body); - } - function checkAccessorDeclarationTypesIdentical(first, second, getAnnotatedType, message) { - var firstType = getAnnotatedType(first); - var secondType = getAnnotatedType(second); - if (firstType && secondType && !isTypeIdenticalTo(firstType, secondType)) { - error(first, message); - } + setNodeLinksForPrivateIdentifierScope(node); } function checkMissingDeclaration(node) { checkDecorators(node); @@ -61213,7 +63490,7 @@ var ts; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 173 && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 175 && 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); @@ -61228,7 +63505,7 @@ var ts; var symbol = getNodeLinks(node).resolvedSymbol; if (symbol) { if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 134217728); })) { - errorOrSuggestion(false, getDeprecatedSuggestionNode(node), ts.Diagnostics._0_is_deprecated, symbol.escapedName); + addDeprecatedSuggestion(getDeprecatedSuggestionNode(node), symbol.declarations, symbol.escapedName); } if (type.flags & 32 && symbol.flags & 8) { error(node, ts.Diagnostics.Enum_type_0_has_members_with_initializers_that_are_not_literals, typeToString(type)); @@ -61266,7 +63543,7 @@ 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 !== 192 && hasNamedElement) { + if (e.kind !== 194 && hasNamedElement) { grammarErrorOnNode(e, ts.Diagnostics.Tuple_members_must_all_have_names_or_all_not_have_names); break; } @@ -61314,7 +63591,7 @@ var ts; var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, false))) { - if (accessNode.kind === 202 && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 204 && ts.isAssignmentTarget(accessNode) && ts.getObjectFlags(objectType) & 32 && getMappedTypeModifiers(objectType) & 1) { error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); } @@ -61370,7 +63647,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 184 && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 186 && n.parent.extendsType === n; })) { grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type); } checkSourceElement(node.typeParameter); @@ -61393,23 +63670,23 @@ var ts; if (node.dotDotDotToken && node.questionToken) { grammarErrorOnNode(node, ts.Diagnostics.A_tuple_member_cannot_be_both_optional_and_rest); } - if (node.type.kind === 180) { + if (node.type.kind === 182) { 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 === 181) { + if (node.type.kind === 183) { 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) || ts.isPrivateIdentifierPropertyDeclaration(node)) && !!(node.flags & 8388608); + return (ts.hasEffectiveModifier(node, 8) || ts.isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 8388608); } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); - if (n.parent.kind !== 253 && - n.parent.kind !== 252 && - n.parent.kind !== 221 && + if (n.parent.kind !== 255 && + n.parent.kind !== 254 && + n.parent.kind !== 223 && n.flags & 8388608) { if (!(flags & 2) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) { flags |= 1; @@ -61490,7 +63767,7 @@ var ts; ts.isComputedPropertyName(node.name) && ts.isComputedPropertyName(subsequentName) || ts.isPropertyNameLiteral(node.name) && ts.isPropertyNameLiteral(subsequentName) && ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) { - var reportError = (node.kind === 165 || node.kind === 164) && + var reportError = (node.kind === 167 || node.kind === 166) && ts.hasSyntacticModifier(node, 32) !== ts.hasSyntacticModifier(subsequentNode, 32); if (reportError) { var diagnostic = ts.hasSyntacticModifier(node, 32) ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; @@ -61521,48 +63798,50 @@ var ts; var multipleConstructorImplementation = false; var hasNonAmbientClass = false; var functionDeclarations = []; - for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { - var current = declarations_4[_i]; - var node = current; - var inAmbientContext = node.flags & 8388608; - var inAmbientContextOrInterface = node.parent && (node.parent.kind === 253 || node.parent.kind === 177) || inAmbientContext; - if (inAmbientContextOrInterface) { - previousDeclaration = undefined; - } - if ((node.kind === 252 || node.kind === 221) && !inAmbientContext) { - hasNonAmbientClass = true; - } - if (node.kind === 251 || node.kind === 165 || node.kind === 164 || node.kind === 166) { - functionDeclarations.push(node); - var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); - someNodeFlags |= currentNodeFlags; - allNodeFlags &= currentNodeFlags; - someHaveQuestionToken = someHaveQuestionToken || ts.hasQuestionToken(node); - allHaveQuestionToken = allHaveQuestionToken && ts.hasQuestionToken(node); - var bodyIsPresent = ts.nodeIsPresent(node.body); - if (bodyIsPresent && bodyDeclaration) { - if (isConstructor) { - multipleConstructorImplementation = true; + if (declarations) { + for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { + var current = declarations_4[_i]; + var node = current; + var inAmbientContext = node.flags & 8388608; + var inAmbientContextOrInterface = node.parent && (node.parent.kind === 255 || node.parent.kind === 179) || inAmbientContext; + if (inAmbientContextOrInterface) { + previousDeclaration = undefined; + } + if ((node.kind === 254 || node.kind === 223) && !inAmbientContext) { + hasNonAmbientClass = true; + } + if (node.kind === 253 || node.kind === 167 || node.kind === 166 || node.kind === 168) { + functionDeclarations.push(node); + var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); + someNodeFlags |= currentNodeFlags; + allNodeFlags &= currentNodeFlags; + someHaveQuestionToken = someHaveQuestionToken || ts.hasQuestionToken(node); + allHaveQuestionToken = allHaveQuestionToken && ts.hasQuestionToken(node); + var bodyIsPresent = ts.nodeIsPresent(node.body); + if (bodyIsPresent && bodyDeclaration) { + if (isConstructor) { + multipleConstructorImplementation = true; + } + else { + duplicateFunctionDeclaration = true; + } + } + else if ((previousDeclaration === null || previousDeclaration === void 0 ? void 0 : previousDeclaration.parent) === node.parent && previousDeclaration.end !== node.pos) { + reportImplementationExpectedError(previousDeclaration); + } + if (bodyIsPresent) { + if (!bodyDeclaration) { + bodyDeclaration = node; + } } else { - duplicateFunctionDeclaration = true; + hasOverloads = true; } - } - else if ((previousDeclaration === null || previousDeclaration === void 0 ? void 0 : previousDeclaration.parent) === node.parent && previousDeclaration.end !== node.pos) { - reportImplementationExpectedError(previousDeclaration); - } - if (bodyIsPresent) { - if (!bodyDeclaration) { - bodyDeclaration = node; + previousDeclaration = node; + if (!inAmbientContextOrInterface) { + lastSeenNonAmbientDeclaration = node; } } - else { - hasOverloads = true; - } - previousDeclaration = node; - if (!inAmbientContextOrInterface) { - lastSeenNonAmbientDeclaration = node; - } } } if (multipleConstructorImplementation) { @@ -61575,9 +63854,18 @@ var ts; error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Duplicate_function_implementation); }); } - if (hasNonAmbientClass && !isConstructor && symbol.flags & 16) { + if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 && declarations) { + var relatedDiagnostics_1 = ts.filter(declarations, function (d) { return d.kind === 254; }) + .map(function (d) { return ts.createDiagnosticForNode(d, ts.Diagnostics.Consider_adding_a_declare_modifier_to_this_class); }); ts.forEach(declarations, function (declaration) { - addDuplicateDeclarationError(declaration, ts.Diagnostics.Duplicate_identifier_0, ts.symbolName(symbol), declarations); + var diagnostic = declaration.kind === 254 + ? ts.Diagnostics.Class_declaration_cannot_implement_overload_list_for_0 + : declaration.kind === 253 + ? ts.Diagnostics.Function_with_bodies_can_only_merge_with_classes_that_are_ambient + : undefined; + if (diagnostic) { + ts.addRelatedInfo.apply(void 0, __spreadArray([error(ts.getNameOfDeclaration(declaration) || declaration, diagnostic, ts.symbolName(symbol))], relatedDiagnostics_1)); + } }); } if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && @@ -61585,8 +63873,10 @@ var ts; reportImplementationExpectedError(lastSeenNonAmbientDeclaration); } if (hasOverloads) { - checkFlagAgreementBetweenOverloads(declarations, bodyDeclaration, flagsToCheck, someNodeFlags, allNodeFlags); - checkQuestionTokenAgreementBetweenOverloads(declarations, bodyDeclaration, someHaveQuestionToken, allHaveQuestionToken); + if (declarations) { + checkFlagAgreementBetweenOverloads(declarations, bodyDeclaration, flagsToCheck, someNodeFlags, allNodeFlags); + checkQuestionTokenAgreementBetweenOverloads(declarations, bodyDeclaration, someHaveQuestionToken, allHaveQuestionToken); + } if (bodyDeclaration) { var signatures = getSignaturesOfSymbol(symbol); var bodySignature = getSignatureFromDeclaration(bodyDeclaration); @@ -61652,39 +63942,42 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 253: - case 254: - case 331: - case 324: - case 325: - return 2; + case 255: case 256: + case 339: + case 332: + case 333: + return 2; + case 258: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 ? 4 | 1 : 4; - case 252: - case 255: - case 291: + case 254: + case 257: + case 293: return 2 | 1; - case 297: + case 299: return 2 | 1 | 4; - case 266: - if (!ts.isEntityNameExpression(d.expression)) { + case 268: + case 218: + var node_2 = d; + var expression = ts.isExportAssignment(node_2) ? node_2.expression : node_2.right; + if (!ts.isEntityNameExpression(expression)) { return 1; } - d = d.expression; - case 260: - case 263: + d = expression; case 262: + case 265: + case 264: var result_12 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_12 |= getDeclarationSpaces(d); }); return result_12; - case 249: - case 198: case 251: - case 265: - case 78: + case 200: + case 253: + case 267: + case 79: return 1; default: return ts.Debug.failBadSyntaxKind(d); @@ -61805,7 +64098,7 @@ var ts; var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551, true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; if (promiseConstructorType === errorType) { - if (promiseConstructorName.kind === 78 && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(false)) { + if (promiseConstructorName.kind === 79 && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(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 { @@ -61841,22 +64134,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 252: + case 254: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 160: + case 162: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 163: + case 165: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 165: case 167: - case 168: + case 169: + case 170: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -61873,7 +64166,7 @@ var ts; if (!typeName) return; var rootName = ts.getFirstIdentifier(typeName); - var meaning = (typeName.kind === 78 ? 788968 : 1920) | 2097152; + var meaning = (typeName.kind === 79 ? 788968 : 1920) | 2097152; var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, undefined, undefined, true); if (rootSymbol && rootSymbol.flags & 2097152 @@ -61892,15 +64185,15 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 183: - case 182: - return getEntityNameForDecoratorMetadataFromTypeList(node.types); + case 185: case 184: - return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]); + return getEntityNameForDecoratorMetadataFromTypeList(node.types); case 186: - case 192: + return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]); + case 188: + case 194: return getEntityNameForDecoratorMetadata(node.type); - case 173: + case 175: return node.typeName; } } @@ -61909,13 +64202,13 @@ var ts; var commonEntityName; for (var _i = 0, types_23 = types; _i < types_23.length; _i++) { var typeNode = types_23[_i]; - while (typeNode.kind === 186 || typeNode.kind === 192) { + while (typeNode.kind === 188 || typeNode.kind === 194) { typeNode = typeNode.type; } - if (typeNode.kind === 141) { + if (typeNode.kind === 142) { continue; } - if (!strictNullChecks && (typeNode.kind === 191 && typeNode.literal.kind === 103 || typeNode.kind === 150)) { + if (!strictNullChecks && (typeNode.kind === 193 && typeNode.literal.kind === 104 || typeNode.kind === 151)) { continue; } var individualEntityName = getEntityNameForDecoratorMetadata(typeNode); @@ -61951,13 +64244,13 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8); - if (node.kind === 160) { + if (node.kind === 162) { checkExternalEmitHelpers(firstDecorator, 32); } if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16); switch (node.kind) { - case 252: + case 254: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -61966,23 +64259,23 @@ var ts; } } break; - case 167: - case 168: - var otherKind = node.kind === 167 ? 168 : 167; + case 169: + case 170: + var otherKind = node.kind === 169 ? 170 : 169; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); break; - case 165: + case 167: for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveReturnTypeNode(node)); break; - case 163: + case 165: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 160: + case 162: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -62041,7 +64334,7 @@ var ts; else if (ts.findLast(ts.getJSDocTags(decl), ts.isJSDocParameterTag) === node && node.typeExpression && node.typeExpression.type && !isArrayType(getTypeFromTypeNode(node.typeExpression.type))) { - error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 157 ? node.name.right : node.name)); + error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 159 ? node.name.right : node.name)); } } } @@ -62083,25 +64376,26 @@ var ts; } function getIdentifierFromEntityNameExpression(node) { switch (node.kind) { - case 78: + case 79: return node; - case 201: + case 203: return node.name; default: return undefined; } } function checkFunctionOrMethodDeclaration(node) { + var _a; checkDecorators(node); checkSignatureDeclaration(node); var functionFlags = ts.getFunctionFlags(node); - if (node.name && node.name.kind === 158) { + if (node.name && node.name.kind === 160) { checkComputedPropertyName(node.name); } - if (!hasNonBindableDynamicName(node)) { + if (hasBindableName(node)) { var symbol = getSymbolOfNode(node); var localSymbol = node.localSymbol || symbol; - var firstDeclaration = ts.find(localSymbol.declarations, function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 131072); }); + var firstDeclaration = (_a = localSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 131072); }); if (node === firstDeclaration) { checkFunctionOrConstructorSymbol(localSymbol); } @@ -62109,7 +64403,7 @@ var ts; checkFunctionOrConstructorSymbol(symbol); } } - var body = node.kind === 164 ? undefined : node.body; + var body = node.kind === 166 ? undefined : node.body; checkSourceElement(body); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node)); if (produceDiagnostics && !ts.getEffectiveReturnTypeNode(node)) { @@ -62142,42 +64436,42 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 252: - case 221: + case 254: + case 223: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 297: - case 256: - case 230: + case 299: case 258: - case 237: - case 238: + case 232: + case 260: case 239: + case 240: + case 241: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 166: - case 208: - case 251: - case 209: - case 165: - case 167: case 168: + case 210: + case 253: + case 211: + case 167: + case 169: + case 170: if (node.body) { checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 164: - case 169: - case 170: - case 174: - case 175: - case 254: - case 253: + case 166: + case 171: + case 172: + case 176: + case 177: + case 256: + case 255: checkUnusedTypeParameters(node, addDiagnostic); break; - case 185: + case 187: checkUnusedInferTypeParameter(node, addDiagnostic); break; default: @@ -62197,11 +64491,11 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 165: - case 163: case 167: - case 168: - if (member.kind === 168 && member.symbol.flags & 32768) { + case 165: + case 169: + case 170: + if (member.kind === 170 && member.symbol.flags & 32768) { break; } var symbol = getSymbolOfNode(member); @@ -62211,7 +64505,7 @@ var ts; addDiagnostic(member, 0, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); } break; - case 166: + case 168: for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.hasSyntacticModifier(parameter, 8)) { @@ -62219,8 +64513,8 @@ var ts; } } break; - case 171: - case 229: + case 173: + case 231: break; default: ts.Debug.fail(); @@ -62234,7 +64528,8 @@ var ts; } } function checkUnusedTypeParameters(node, addDiagnostic) { - if (ts.last(getSymbolOfNode(node).declarations) !== node) + var declarations = getSymbolOfNode(node).declarations; + if (!declarations || ts.last(declarations) !== node) return; var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); var seenParentsWithEveryUnused = new ts.Set(); @@ -62244,7 +64539,7 @@ var ts; continue; var name = ts.idText(typeParameter.name); var parent = typeParameter.parent; - if (parent.kind !== 185 && parent.typeParameters.every(isTypeParameterUnused)) { + if (parent.kind !== 187 && parent.typeParameters.every(isTypeParameterUnused)) { if (ts.tryAddToSet(seenParentsWithEveryUnused, parent)) { var sourceFile = ts.getSourceFileOfNode(parent); var range = ts.isJSDocTemplateTag(parent) @@ -62278,11 +64573,11 @@ var ts; return ts.tryCast(ts.getRootDeclaration(node), ts.isParameter); } function isValidUnusedLocalDeclaration(declaration) { - if (ts.isBindingElement(declaration) && isIdentifierThatStartsWithUnderscore(declaration.name)) { - return !!ts.findAncestor(declaration.parent, function (ancestor) { - return ts.isArrayBindingPattern(ancestor) || ts.isVariableDeclaration(ancestor) || ts.isVariableDeclarationList(ancestor) ? false : - ts.isForOfStatement(ancestor) ? true : "quit"; - }); + if (ts.isBindingElement(declaration)) { + if (ts.isObjectBindingPattern(declaration.parent)) { + return !!(declaration.propertyName && isIdentifierThatStartsWithUnderscore(declaration.name)); + } + return isIdentifierThatStartsWithUnderscore(declaration.name); } return ts.isAmbientModule(declaration) || (ts.isVariableDeclaration(declaration) && ts.isForInOrOfStatement(declaration.parent.parent) || isImportedDeclaration(declaration)) && isIdentifierThatStartsWithUnderscore(declaration.name); @@ -62295,38 +64590,40 @@ var ts; if (local.flags & 262144 ? !(local.flags & 3 && !(local.isReferenced & 3)) : local.isReferenced || local.exportSymbol) { return; } - for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (isValidUnusedLocalDeclaration(declaration)) { - continue; - } - if (isImportedDeclaration(declaration)) { - addToGroup(unusedImports, importClauseFromImported(declaration), declaration, getNodeId); - } - else if (ts.isBindingElement(declaration) && ts.isObjectBindingPattern(declaration.parent)) { - var lastElement = ts.last(declaration.parent.elements); - if (declaration === lastElement || !ts.last(declaration.parent.elements).dotDotDotToken) { - addToGroup(unusedDestructures, declaration.parent, declaration, getNodeId); + if (local.declarations) { + for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (isValidUnusedLocalDeclaration(declaration)) { + continue; } - } - else if (ts.isVariableDeclaration(declaration)) { - addToGroup(unusedVariables, declaration.parent, declaration, getNodeId); - } - else { - var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); - var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration); - if (parameter && name) { - if (!ts.isParameterPropertyDeclaration(parameter, parameter.parent) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { - if (ts.isBindingElement(declaration) && ts.isArrayBindingPattern(declaration.parent)) { - addToGroup(unusedDestructures, declaration.parent, declaration, getNodeId); - } - else { - addDiagnostic(parameter, 1, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); - } + if (isImportedDeclaration(declaration)) { + addToGroup(unusedImports, importClauseFromImported(declaration), declaration, getNodeId); + } + else if (ts.isBindingElement(declaration) && ts.isObjectBindingPattern(declaration.parent)) { + var lastElement = ts.last(declaration.parent.elements); + if (declaration === lastElement || !ts.last(declaration.parent.elements).dotDotDotToken) { + addToGroup(unusedDestructures, declaration.parent, declaration, getNodeId); } } + else if (ts.isVariableDeclaration(declaration)) { + addToGroup(unusedVariables, declaration.parent, declaration, getNodeId); + } else { - errorUnusedLocal(declaration, ts.symbolName(local), addDiagnostic); + var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); + var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration); + if (parameter && name) { + if (!ts.isParameterPropertyDeclaration(parameter, parameter.parent) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { + if (ts.isBindingElement(declaration) && ts.isArrayBindingPattern(declaration.parent)) { + addToGroup(unusedDestructures, declaration.parent, declaration, getNodeId); + } + else { + addDiagnostic(parameter, 1, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); + } + } + } + else { + errorUnusedLocal(declaration, ts.symbolName(local), addDiagnostic); + } } } } @@ -62336,7 +64633,7 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 263 ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 265 ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { addDiagnostic(importDecl, 0, unuseds.length === 1 @@ -62354,7 +64651,7 @@ var ts; var bindingPattern = _a[0], bindingElements = _a[1]; var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 : 0; if (bindingPattern.elements.length === bindingElements.length) { - if (bindingElements.length === 1 && bindingPattern.parent.kind === 249 && bindingPattern.parent.parent.kind === 250) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 251 && bindingPattern.parent.parent.kind === 252) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -62375,7 +64672,7 @@ var ts; if (declarationList.declarations.length === declarations.length) { addDiagnostic(declarationList, 0, 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 === 232 ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 234 ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { @@ -62387,23 +64684,23 @@ var ts; } function bindingNameText(name) { switch (name.kind) { - case 78: + case 79: return ts.idText(name); - case 197: - case 196: + case 199: + case 198: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 262 || node.kind === 265 || node.kind === 263; + return node.kind === 264 || node.kind === 267 || node.kind === 265; } function importClauseFromImported(decl) { - return decl.kind === 262 ? decl : decl.kind === 263 ? decl.parent : decl.parent.parent; + return decl.kind === 264 ? decl : decl.kind === 265 ? decl.parent : decl.parent.parent; } function checkBlock(node) { - if (node.kind === 230) { + if (node.kind === 232) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -62432,19 +64729,19 @@ var ts; if (!(identifier && identifier.escapedText === name)) { return false; } - if (node.kind === 163 || - node.kind === 162 || - node.kind === 165 || + if (node.kind === 165 || node.kind === 164 || node.kind === 167 || - node.kind === 168) { + node.kind === 166 || + node.kind === 169 || + node.kind === 170) { return false; } if (node.flags & 8388608) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 160 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 162 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -62452,7 +64749,7 @@ var ts; function checkIfThisIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 4) { - var isDeclaration_1 = node.kind !== 78; + var isDeclaration_1 = node.kind !== 79; if (isDeclaration_1) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -62467,7 +64764,7 @@ var ts; function checkIfNewTargetIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 8) { - var isDeclaration_2 = node.kind !== 78; + var isDeclaration_2 = node.kind !== 79; if (isDeclaration_2) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference); } @@ -62479,10 +64776,11 @@ var ts; return false; }); } - function checkWeakMapCollision(node) { + function checkWeakMapSetCollision(node) { var enclosingBlockScope = ts.getEnclosingBlockScopeContainer(node); if (getNodeCheckFlags(enclosingBlockScope) & 67108864) { - errorSkippedOn("noEmit", node, ts.Diagnostics.Compiler_reserves_name_0_when_emitting_private_identifier_downlevel, "WeakMap"); + 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 checkCollisionWithRequireExportsInGeneratedCode(node, name) { @@ -62496,7 +64794,7 @@ var ts; return; } var parent = getDeclarationContainer(node); - if (parent.kind === 297 && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 299 && ts.isExternalOrCommonJsModule(parent)) { 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)); } } @@ -62508,7 +64806,7 @@ var ts; return; } var parent = getDeclarationContainer(node); - if (parent.kind === 297 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048) { + if (parent.kind === 299 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048) { 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)); } } @@ -62516,7 +64814,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 3) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 249 && !node.initializer) { + if (node.kind === 251 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -62528,15 +64826,15 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 250); - var container = varDeclList.parent.kind === 232 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 252); + var container = varDeclList.parent.kind === 234 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 230 && ts.isFunctionLike(container.parent) || - container.kind === 257 || - container.kind === 256 || - container.kind === 297); + (container.kind === 232 && ts.isFunctionLike(container.parent) || + container.kind === 259 || + container.kind === 258 || + container.kind === 299); if (!namesShareScope) { var name = symbolToString(localDeclarationSymbol); error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name, name); @@ -62557,17 +64855,17 @@ var ts; if (!node.name) { return; } - if (node.name.kind === 158) { + if (node.name.kind === 160) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 198) { - if (node.parent.kind === 196 && languageVersion < 99) { + if (ts.isBindingElement(node)) { + if (ts.isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5) { checkExternalEmitHelpers(node, 4); } - if (node.propertyName && node.propertyName.kind === 158) { + if (node.propertyName && node.propertyName.kind === 160) { checkComputedPropertyName(node.propertyName); } var parent = node.parent.parent; @@ -62580,13 +64878,13 @@ var ts; var property = getPropertyOfType(parentType, nameText); if (property) { markPropertyAsReferenced(property, undefined, false); - checkPropertyAccessibility(parent, !!parent.initializer && parent.initializer.kind === 105, parentType, property); + checkPropertyAccessibility(node, !!parent.initializer && parent.initializer.kind === 106, false, parentType, property); } } } } if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 197 && languageVersion < 2 && compilerOptions.downlevelIteration) { + if (node.name.kind === 199 && languageVersion < 2 && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, 512); } ts.forEach(node.name.elements, checkSourceElement); @@ -62596,7 +64894,7 @@ var ts; return; } if (ts.isBindingPattern(node.name)) { - var needCheckInitializer = node.initializer && node.parent.parent.kind !== 238; + var needCheckInitializer = node.initializer && node.parent.parent.kind !== 240; var needCheckWidenedType = node.name.elements.length === 0; if (needCheckInitializer || needCheckWidenedType) { var widenedType = getWidenedTypeForVariableLikeDeclaration(node); @@ -62621,7 +64919,7 @@ var ts; return; } var symbol = getSymbolOfNode(node); - if (symbol.flags & 2097152 && ts.isRequireVariableDeclaration(node, true)) { + if (symbol.flags & 2097152 && ts.isRequireVariableDeclaration(node)) { checkAliasSymbol(node); return; } @@ -62633,11 +64931,11 @@ 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 !== 238) { + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 240) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, undefined); } } - if (symbol.declarations.length > 1) { + if (symbol.declarations && symbol.declarations.length > 1) { if (ts.some(symbol.declarations, function (d) { return d !== node && ts.isVariableLike(d) && !areDeclarationFlagsIdentical(d, node); })) { error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } @@ -62653,25 +64951,26 @@ var ts; if (node.initializer) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(node.initializer), declarationType, node, node.initializer, undefined); } - if (!areDeclarationFlagsIdentical(node, symbol.valueDeclaration)) { + if (symbol.valueDeclaration && !areDeclarationFlagsIdentical(node, symbol.valueDeclaration)) { error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 163 && node.kind !== 162) { + if (node.kind !== 165 && node.kind !== 164) { checkExportsOnMergedDeclarations(node); - if (node.kind === 249 || node.kind === 198) { + if (node.kind === 251 || node.kind === 200) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); - if (languageVersion < 99 && needCollisionCheckForIdentifier(node, node.name, "WeakMap")) { - potentialWeakMapCollisions.push(node); + if (languageVersion < 99 + && (needCollisionCheckForIdentifier(node, node.name, "WeakMap") || needCollisionCheckForIdentifier(node, node.name, "WeakSet"))) { + potentialWeakMapSetCollisions.push(node); } } } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 163 || nextDeclaration.kind === 162 + var message = nextDeclaration.kind === 165 || nextDeclaration.kind === 164 ? 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); @@ -62681,8 +64980,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 160 && right.kind === 249) || - (left.kind === 249 && right.kind === 160)) { + if ((left.kind === 162 && right.kind === 251) || + (left.kind === 251 && right.kind === 162)) { return true; } if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { @@ -62697,10 +64996,10 @@ var ts; return ts.getSelectedEffectiveModifierFlags(left, interestingFlags) === ts.getSelectedEffectiveModifierFlags(right, interestingFlags); } function checkVariableDeclaration(node) { - ts.tracing.push("check", "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check", "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end }); checkGrammarVariableDeclaration(node); checkVariableLikeDeclaration(node); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } function checkBindingElement(node) { checkGrammarBindingElement(node); @@ -62718,44 +65017,49 @@ var ts; function checkIfStatement(node) { checkGrammarStatementInAmbientContext(node); var type = checkTruthinessExpression(node.expression); - checkTestingKnownTruthyCallableType(node.expression, type, node.thenStatement); + checkTestingKnownTruthyCallableOrAwaitableType(node.expression, type, node.thenStatement); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 231) { + if (node.thenStatement.kind === 233) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); } - function checkTestingKnownTruthyCallableType(condExpr, type, body) { - if (!strictNullChecks) { + function checkTestingKnownTruthyCallableOrAwaitableType(condExpr, type, body) { + if (!strictNullChecks) + return; + if (getFalsyFlags(type)) return; - } var location = ts.isBinaryExpression(condExpr) ? condExpr.right : condExpr; var testedNode = ts.isIdentifier(location) ? location : ts.isPropertyAccessExpression(location) ? location.name : ts.isBinaryExpression(location) && ts.isIdentifier(location.right) ? location.right : undefined; - if (!testedNode) { - return; - } - var possiblyFalsy = getFalsyFlags(type); - if (possiblyFalsy) { + var isPropertyExpressionCast = ts.isPropertyAccessExpression(location) + && ts.isAssertionExpression(ts.skipParentheses(location.expression)); + if (!testedNode || isPropertyExpressionCast) { return; } var callSignatures = getSignaturesOfType(type, 0); - if (callSignatures.length === 0) { + var isPromise = !!getAwaitedTypeOfPromise(type); + if (callSignatures.length === 0 && !isPromise) { return; } var testedSymbol = getSymbolAtLocation(testedNode); if (!testedSymbol) { return; } - var isUsed = ts.isBinaryExpression(condExpr.parent) && isFunctionUsedInBinaryExpressionChain(condExpr.parent, testedSymbol) - || body && isFunctionUsedInConditionBody(condExpr, body, testedNode, testedSymbol); + var isUsed = ts.isBinaryExpression(condExpr.parent) && isSymbolUsedInBinaryExpressionChain(condExpr.parent, testedSymbol) + || body && isSymbolUsedInConditionBody(condExpr, body, testedNode, testedSymbol); if (!isUsed) { - error(location, ts.Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead); + if (isPromise) { + errorAndMaybeSuggestAwait(location, true, ts.Diagnostics.This_condition_will_always_return_true_since_this_0_is_always_defined, getTypeNameForErrorDisplay(type)); + } + else { + error(location, ts.Diagnostics.This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_instead); + } } } - function isFunctionUsedInConditionBody(expr, body, testedNode, testedSymbol) { + function isSymbolUsedInConditionBody(expr, body, testedNode, testedSymbol) { return !!ts.forEachChild(body, function check(childNode) { if (ts.isIdentifier(childNode)) { var childSymbol = getSymbolAtLocation(childNode); @@ -62767,7 +65071,7 @@ var ts; var childExpression = childNode.parent; while (testedExpression && childExpression) { if (ts.isIdentifier(testedExpression) && ts.isIdentifier(childExpression) || - testedExpression.kind === 107 && childExpression.kind === 107) { + testedExpression.kind === 108 && childExpression.kind === 108) { return getSymbolAtLocation(testedExpression) === getSymbolAtLocation(childExpression); } else if (ts.isPropertyAccessExpression(testedExpression) && ts.isPropertyAccessExpression(childExpression)) { @@ -62790,7 +65094,7 @@ var ts; return ts.forEachChild(childNode, check); }); } - function isFunctionUsedInBinaryExpressionChain(node, testedSymbol) { + function isSymbolUsedInBinaryExpressionChain(node, testedSymbol) { while (ts.isBinaryExpression(node) && node.operatorToken.kind === 55) { var isUsed = ts.forEachChild(node.right, function visit(child) { if (ts.isIdentifier(child)) { @@ -62829,12 +65133,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 250) { + if (node.initializer && node.initializer.kind === 252) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 250) { + if (node.initializer.kind === 252) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -62861,13 +65165,13 @@ var ts; else if (compilerOptions.downlevelIteration && languageVersion < 2) { checkExternalEmitHelpers(node, 256); } - if (node.initializer.kind === 250) { + if (node.initializer.kind === 252) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node); - if (varExpr.kind === 199 || varExpr.kind === 200) { + if (varExpr.kind === 201 || varExpr.kind === 202) { checkDestructuringAssignment(varExpr, iteratedType || errorType); } else { @@ -62886,7 +65190,7 @@ var ts; function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); var rightType = getNonNullableTypeIfNeeded(checkExpression(node.expression)); - if (node.initializer.kind === 250) { + if (node.initializer.kind === 252) { 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); @@ -62896,7 +65200,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 199 || varExpr.kind === 200) { + if (varExpr.kind === 201 || varExpr.kind === 202) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) { @@ -62987,18 +65291,8 @@ var ts; } if (!isArrayLikeType(arrayType)) { if (errorNode && !reportedError) { - var yieldType = getIterationTypeOfIterable(use, 0, inputType, undefined); - var _a = !(use & 4) || hasStringConstituent - ? downlevelIteration - ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true] - : yieldType - ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false] - : [ts.Diagnostics.Type_0_is_not_an_array_type, true] - : downlevelIteration - ? [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] - : yieldType - ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false] - : [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type, true], defaultDiagnostic = _a[0], maybeMissingAwait = _a[1]; + var allowsStrings = !!(use & 4) && !hasStringConstituent; + var _a = getIterationDiagnosticDetails(allowsStrings, downlevelIteration), defaultDiagnostic = _a[0], maybeMissingAwait = _a[1]; errorAndMaybeSuggestAwait(errorNode, maybeMissingAwait && !!getAwaitedTypeOfPromise(arrayType), defaultDiagnostic, typeToString(arrayType)); } return hasStringConstituent ? possibleOutOfBounds ? includeUndefinedInIndexSignature(stringType) : stringType : undefined; @@ -63011,6 +65305,40 @@ var ts; return getUnionType(possibleOutOfBounds ? [arrayElementType, stringType, undefinedType] : [arrayElementType, stringType], 2); } return (use & 128) ? includeUndefinedInIndexSignature(arrayElementType) : arrayElementType; + function getIterationDiagnosticDetails(allowsStrings, downlevelIteration) { + var _a; + if (downlevelIteration) { + return allowsStrings + ? [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, inputType, undefined); + if (yieldType) { + return [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false]; + } + if (isES2015OrLaterIterable((_a = inputType.symbol) === null || _a === void 0 ? void 0 : _a.escapedName)) { + return [ts.Diagnostics.Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher, true]; + } + return allowsStrings + ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type, true] + : [ts.Diagnostics.Type_0_is_not_an_array_type, true]; + } + } + function isES2015OrLaterIterable(n) { + switch (n) { + case "Float32Array": + case "Float64Array": + case "Int16Array": + case "Int32Array": + case "Int8Array": + case "NodeList": + case "Uint16Array": + case "Uint32Array": + case "Uint8Array": + case "Uint8ClampedArray": + return true; + } + return false; } function getIterationTypeOfIterable(use, typeKind, inputType, errorNode) { if (isTypeAny(inputType)) { @@ -63175,9 +65503,14 @@ var ts; return setCachedIterationTypes(type, resolver.iterableCacheKey, createIterationTypes(yieldType, returnType, nextType)); } } + function getPropertyNameForKnownSymbolName(symbolName) { + var ctorType = getGlobalESSymbolConstructorSymbol(false); + var uniqueType = ctorType && getTypeOfPropertyOfType(getTypeOfSymbol(ctorType), ts.escapeLeadingUnderscores(symbolName)); + return uniqueType && isTypeUsableAsPropertyName(uniqueType) ? getPropertyNameFromType(uniqueType) : "__@" + symbolName; + } function getIterationTypesOfIterableSlow(type, resolver, errorNode) { var _a; - var method = getPropertyOfType(type, ts.getPropertyNameForKnownSymbolName(resolver.iteratorSymbolName)); + 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); @@ -63384,12 +65717,12 @@ var ts; var functionFlags = ts.getFunctionFlags(func); if (strictNullChecks || node.expression || returnType.flags & 131072) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; - if (func.kind === 168) { + if (func.kind === 170) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 166) { + else if (func.kind === 168) { 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); } @@ -63404,7 +65737,7 @@ var ts; } } } - else if (func.kind !== 166 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 168 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } } @@ -63429,7 +65762,7 @@ var ts; var expressionType = checkExpression(node.expression); var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 285 && !hasDuplicateDefaultClause) { + if (clause.kind === 287 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -63438,7 +65771,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 284) { + if (produceDiagnostics && clause.kind === 286) { var caseType = checkExpression(clause.expression); var caseIsLiteral = isLiteralType(caseType); var comparedExpressionType = expressionType; @@ -63465,7 +65798,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 245 && current.label.escapedText === node.label.escapedText) { + if (current.kind === 247 && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -63491,10 +65824,11 @@ var ts; if (catchClause) { if (catchClause.variableDeclaration) { var declaration = catchClause.variableDeclaration; - if (declaration.type) { + var typeNode = ts.getEffectiveTypeAnnotationNode(ts.getRootDeclaration(declaration)); + if (typeNode) { var type = getTypeForVariableLikeDeclaration(declaration, false); if (type && !(type.flags & 3)) { - grammarErrorOnFirstToken(declaration.type, ts.Diagnostics.Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified); + grammarErrorOnFirstToken(typeNode, ts.Diagnostics.Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified); } } else if (declaration.initializer) { @@ -63505,7 +65839,7 @@ var ts; if (blockLocals_1) { ts.forEachKey(catchClause.locals, function (caughtName) { var blockLocal = blockLocals_1.get(caughtName); - if (blockLocal && (blockLocal.flags & 2) !== 0) { + if ((blockLocal === null || blockLocal === void 0 ? void 0 : blockLocal.valueDeclaration) && (blockLocal.flags & 2) !== 0) { grammarErrorOnNode(blockLocal.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, caughtName); } }); @@ -63518,24 +65852,27 @@ var ts; checkBlock(node.finallyBlock); } } - function checkIndexConstraints(type) { - var declaredNumberIndexer = getIndexDeclarationOfSymbol(type.symbol, 1); - var declaredStringIndexer = getIndexDeclarationOfSymbol(type.symbol, 0); + function checkIndexConstraints(type, isStatic) { + var _a, _b, _c, _d; + var declaredNumberIndexer = getIndexDeclarationOfSymbolTable(isStatic ? (_a = type.symbol) === null || _a === void 0 ? void 0 : _a.exports : (_b = type.symbol) === null || _b === void 0 ? void 0 : _b.members, 1); + var declaredStringIndexer = getIndexDeclarationOfSymbolTable(isStatic ? (_c = type.symbol) === null || _c === void 0 ? void 0 : _c.exports : (_d = type.symbol) === null || _d === void 0 ? void 0 : _d.members, 0); var stringIndexType = getIndexTypeOfType(type, 0); var numberIndexType = getIndexTypeOfType(type, 1); if (stringIndexType || numberIndexType) { ts.forEach(getPropertiesOfObjectType(type), function (prop) { - var propType = getTypeOfSymbol(prop); + if (isStatic && prop.flags & 4194304) + return; + var propType = getNonMissingTypeOfSymbol(prop); checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0); checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1); }); var classDeclaration = type.symbol.valueDeclaration; - if (ts.getObjectFlags(type) & 1 && ts.isClassLike(classDeclaration)) { - for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) { - var member = _a[_i]; - if (!ts.hasSyntacticModifier(member, 32) && hasNonBindableDynamicName(member)) { + if (ts.getObjectFlags(type) & 1 && classDeclaration && ts.isClassLike(classDeclaration)) { + for (var _i = 0, _e = classDeclaration.members; _i < _e.length; _i++) { + var member = _e[_i]; + if (!ts.hasSyntacticModifier(member, 32) && !hasBindableName(member)) { var symbol = getSymbolOfNode(member); - var propType = getTypeOfSymbol(symbol); + var propType = getNonMissingTypeOfSymbol(symbol); checkIndexConstraintForProperty(symbol, propType, type, declaredStringIndexer, stringIndexType, 0); checkIndexConstraintForProperty(symbol, propType, type, declaredNumberIndexer, numberIndexType, 1); } @@ -63547,7 +65884,7 @@ var ts; errorNode = declaredNumberIndexer || declaredStringIndexer; if (!errorNode && (ts.getObjectFlags(type) & 2)) { var someBaseTypeHasBothIndexers = ts.forEach(getBaseTypes(type), function (base) { return getIndexTypeOfType(base, 0) && getIndexTypeOfType(base, 1); }); - errorNode = someBaseTypeHasBothIndexers ? undefined : type.symbol.declarations[0]; + errorNode = someBaseTypeHasBothIndexers || !type.symbol.declarations ? undefined : type.symbol.declarations[0]; } } if (errorNode && !isTypeAssignableTo(numberIndexType, stringIndexType)) { @@ -63567,8 +65904,8 @@ var ts; } var errorNode; if (propDeclaration && name && - (propDeclaration.kind === 216 || - name.kind === 158 || + (propDeclaration.kind === 218 || + name.kind === 160 || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -63577,7 +65914,7 @@ var ts; } else if (ts.getObjectFlags(containingType) & 2) { var someBaseClassHasBothPropertyAndIndexer = ts.forEach(getBaseTypes(containingType), function (base) { return getPropertyOfObjectType(base, prop.escapedName) && getIndexTypeOfType(base, indexKind); }); - errorNode = someBaseClassHasBothPropertyAndIndexer ? undefined : containingType.symbol.declarations[0]; + errorNode = someBaseClassHasBothPropertyAndIndexer || !containingType.symbol.declarations ? undefined : containingType.symbol.declarations[0]; } if (errorNode && !isTypeAssignableTo(propertyType, indexType)) { var errorMessage = indexKind === 0 @@ -63591,6 +65928,7 @@ var ts; switch (name.escapedText) { case "any": case "unknown": + case "never": case "number": case "bigint": case "boolean": @@ -63633,7 +65971,7 @@ var ts; function checkTypeParametersNotReferenced(root, typeParameters, index) { visit(root); function visit(node) { - if (node.kind === 173) { + if (node.kind === 175) { var type = getTypeFromTypeReference(node); if (type.flags & 262144) { for (var i = index; i < typeParameters.length; i++) { @@ -63647,14 +65985,14 @@ var ts; } } function checkTypeParameterListsIdentical(symbol) { - if (symbol.declarations.length === 1) { + if (symbol.declarations && symbol.declarations.length === 1) { return; } var links = getSymbolLinks(symbol); if (!links.typeParametersChecked) { links.typeParametersChecked = true; var declarations = getClassOrInterfaceDeclarationsOfSymbol(symbol); - if (declarations.length <= 1) { + if (!declarations || declarations.length <= 1) { return; } var type = getDeclaredTypeOfSymbol(symbol); @@ -63708,6 +66046,9 @@ var ts; registerForUnusedIdentifiersCheck(node); } function checkClassDeclaration(node) { + if (ts.some(node.decorators) && ts.some(node.members, function (p) { return ts.hasStaticModifier(p) && ts.isPrivateIdentifierClassElementDeclaration(p); })) { + grammarErrorOnNode(node.decorators[0], ts.Diagnostics.Class_decorators_can_t_be_used_with_static_private_identifier_Consider_removing_the_experimental_decorator); + } if (!node.name && !ts.hasSyntacticModifier(node, 512)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } @@ -63735,7 +66076,8 @@ var ts; checkTypeParameterListsIdentical(symbol); checkFunctionOrConstructorSymbol(symbol); checkClassForDuplicateDeclarations(node); - if (!(node.flags & 8388608)) { + var nodeInAmbientContext = !!(node.flags & 8388608); + if (!nodeInAmbientContext) { checkClassForStaticPropertyNameConflicts(node); } var baseTypeNode = ts.getEffectiveBaseTypeNode(node); @@ -63791,6 +66133,7 @@ var ts; checkKindsOfPropertyMemberOverrides(type, baseType_1); } } + checkMembersForMissingOverrideModifier(node, type, typeWithThis, staticType); var implementedTypeNodes = ts.getEffectiveImplementsTypeNodes(node); if (implementedTypeNodes) { for (var _b = 0, implementedTypeNodes_1 = implementedTypeNodes; _b < implementedTypeNodes_1.length; _b++) { @@ -63820,13 +66163,78 @@ var ts; } if (produceDiagnostics) { checkIndexConstraints(type); + checkIndexConstraints(staticType, true); checkTypeForDuplicateIndexSignatures(node); checkPropertyInitialization(node); } } + function checkMembersForMissingOverrideModifier(node, type, typeWithThis, staticType) { + var nodeInAmbientContext = !!(node.flags & 8388608); + var baseTypeNode = ts.getEffectiveBaseTypeNode(node); + 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_24 = function (member) { + if (ts.hasAmbientModifier(member)) { + return "continue"; + } + if (ts.isConstructorDeclaration(member)) { + ts.forEach(member.parameters, function (param) { + if (ts.isParameterPropertyDeclaration(param, member)) { + checkClassMember(param, true); + } + }); + } + checkClassMember(member); + }; + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + _loop_24(member); + } + function checkClassMember(member, memberIsParameterProperty) { + var hasOverride = ts.hasOverrideModifier(member); + var hasStatic = ts.hasStaticModifier(member); + if (baseWithThis && (hasOverride || compilerOptions.noImplicitOverride)) { + var declaredProp = member.name && getSymbolAtLocation(member.name) || getSymbolAtLocation(member); + if (!declaredProp) { + return; + } + var thisType = hasStatic ? staticType : typeWithThis; + var baseType = hasStatic ? baseStaticType : baseWithThis; + var prop = getPropertyOfType(thisType, declaredProp.escapedName); + var baseProp = getPropertyOfType(baseType, declaredProp.escapedName); + var baseClassName = typeToString(baseWithThis); + if (prop && !baseProp && hasOverride) { + var suggestion = getSpellingSuggestionForName(ts.symbolName(declaredProp), ts.arrayFrom(getMembersOfSymbol(baseType.symbol).values()), 106500); + suggestion ? + error(member, ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1, baseClassName, symbolToString(suggestion)) : + error(member, ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0, baseClassName); + } + else if (prop && (baseProp === null || baseProp === void 0 ? void 0 : baseProp.valueDeclaration) && compilerOptions.noImplicitOverride && !nodeInAmbientContext) { + var baseHasAbstract = ts.hasAbstractModifier(baseProp.valueDeclaration); + if (hasOverride) { + return; + } + if (!baseHasAbstract) { + var diag = memberIsParameterProperty ? + ts.Diagnostics.This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0 : + ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0; + error(member, diag, baseClassName); + } + else if (ts.hasAbstractModifier(member) && baseHasAbstract) { + error(member, ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0, baseClassName); + } + } + } + else if (hasOverride) { + var className = typeToString(type); + error(member, ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class, className); + } + } + } function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) { var issuedMemberError = false; - var _loop_23 = function (member) { + var _loop_25 = function (member) { if (ts.hasStaticModifier(member)) { return "continue"; } @@ -63844,7 +66252,7 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_23(member); + _loop_25(member); } if (!issuedMemberError) { checkTypeAssignableTo(typeWithThis, baseWithThis, node.name || node, broadDiag); @@ -63867,10 +66275,11 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 252 || d.kind === 253; + return d.kind === 254 || d.kind === 255; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { + var _a, _b; var baseProperties = getPropertiesOfType(baseType); basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { var baseProperty = baseProperties_1[_i]; @@ -63888,8 +66297,8 @@ var ts; if (derived === base) { var derivedClassDecl = ts.getClassLikeDeclarationOfSymbol(type.symbol); if (baseDeclarationFlags & 128 && (!derivedClassDecl || !ts.hasSyntacticModifier(derivedClassDecl, 128))) { - for (var _a = 0, _b = getBaseTypes(type); _a < _b.length; _a++) { - var otherBaseType = _b[_a]; + for (var _c = 0, _d = getBaseTypes(type); _c < _d.length; _c++) { + var otherBaseType = _d[_c]; if (otherBaseType === baseType) continue; var baseSymbol_1 = getPropertyOfObjectType(otherBaseType, base.escapedName); @@ -63898,7 +66307,7 @@ var ts; continue basePropertyCheck; } } - if (derivedClassDecl.kind === 221) { + if (derivedClassDecl.kind === 223) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -63916,7 +66325,7 @@ var ts; var derivedPropertyFlags = derived.flags & 98308; if (basePropertyFlags && derivedPropertyFlags) { if (baseDeclarationFlags & 128 && !(base.valueDeclaration && ts.isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer) - || base.valueDeclaration && base.valueDeclaration.parent.kind === 253 + || base.valueDeclaration && base.valueDeclaration.parent.kind === 255 || derived.valueDeclaration && ts.isBinaryExpression(derived.valueDeclaration)) { continue; } @@ -63928,13 +66337,13 @@ var ts; ts.Diagnostics._0_is_defined_as_a_property_in_class_1_but_is_overridden_here_in_2_as_an_accessor; error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_1, symbolToString(base), typeToString(baseType), typeToString(type)); } - else if (compilerOptions.useDefineForClassFields) { - var uninitialized = ts.find(derived.declarations, function (d) { return d.kind === 163 && !d.initializer; }); + else if (useDefineForClassFields) { + var uninitialized = (_a = derived.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 165 && !d.initializer; }); if (uninitialized && !(derived.flags & 33554432) && !(baseDeclarationFlags & 128) && !(derivedDeclarationFlags & 128) - && !derived.declarations.some(function (d) { return !!(d.flags & 8388608); })) { + && !((_b = derived.declarations) === null || _b === void 0 ? void 0 : _b.some(function (d) { return !!(d.flags & 8388608); }))) { var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol)); var propName = uninitialized.name; if (uninitialized.exclamationToken @@ -64043,7 +66452,7 @@ var ts; } } function isInstancePropertyWithoutInitializer(node) { - return node.kind === 163 && + return node.kind === 165 && !ts.hasSyntacticModifier(node, 32 | 128) && !node.exclamationToken && !node.initializer; @@ -64065,7 +66474,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 253); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 255); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -64096,7 +66505,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0); checkExportsOnMergedDeclarations(node); checkTypeParameters(node.typeParameters); - if (node.type.kind === 136) { + if (node.type.kind === 137) { 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); } @@ -64175,7 +66584,7 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 214: + case 216: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { @@ -64185,7 +66594,7 @@ var ts; } } break; - case 216: + case 218: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { @@ -64214,22 +66623,22 @@ var ts; case 8: checkGrammarNumericLiteral(expr); return +expr.text; - case 207: + case 209: return evaluate(expr.expression); - case 78: + case 79: var identifier = expr; if (isInfinityOrNaNString(identifier.escapedText)) { return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 202: - case 201: + case 204: + case 203: var ex = expr; if (isConstantMemberAccess(ex)) { var type = getTypeOfExpression(ex.expression); if (type.symbol && type.symbol.flags & 384) { var name = void 0; - if (ex.kind === 201) { + if (ex.kind === 203) { name = ex.name.escapedText; } else { @@ -64247,7 +66656,7 @@ var ts; if (memberSymbol) { var declaration = memberSymbol.valueDeclaration; if (declaration !== member) { - if (isBlockScopedNameDeclaredBeforeUse(declaration, member)) { + if (declaration && isBlockScopedNameDeclaredBeforeUse(declaration, member)) { return getEnumMemberValue(declaration); } error(expr, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums); @@ -64261,9 +66670,9 @@ var ts; } } function isConstantMemberAccess(node) { - return node.kind === 78 || - node.kind === 201 && isConstantMemberAccess(node.expression) || - node.kind === 202 && isConstantMemberAccess(node.expression) && + return node.kind === 79 || + node.kind === 203 && isConstantMemberAccess(node.expression) || + node.kind === 204 && isConstantMemberAccess(node.expression) && ts.isStringLiteralLike(node.argumentExpression); } function checkEnumDeclaration(node) { @@ -64280,7 +66689,7 @@ var ts; var enumSymbol = getSymbolOfNode(node); var firstDeclaration = ts.getDeclarationOfKind(enumSymbol, node.kind); if (node === firstDeclaration) { - if (enumSymbol.declarations.length > 1) { + if (enumSymbol.declarations && enumSymbol.declarations.length > 1) { var enumIsConst_1 = ts.isEnumConst(node); ts.forEach(enumSymbol.declarations, function (decl) { if (ts.isEnumDeclaration(decl) && ts.isEnumConst(decl) !== enumIsConst_1) { @@ -64290,7 +66699,7 @@ var ts; } var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 255) { + if (declaration.kind !== 257) { return false; } var enumDeclaration = declaration; @@ -64316,12 +66725,14 @@ var ts; } function getFirstNonAmbientClassOrFunctionDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { - var declaration = declarations_8[_i]; - if ((declaration.kind === 252 || - (declaration.kind === 251 && ts.nodeIsPresent(declaration.body))) && - !(declaration.flags & 8388608)) { - return declaration; + if (declarations) { + for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { + var declaration = declarations_8[_i]; + if ((declaration.kind === 254 || + (declaration.kind === 253 && ts.nodeIsPresent(declaration.body))) && + !(declaration.flags & 8388608)) { + return declaration; + } } } return undefined; @@ -64366,8 +66777,9 @@ var ts; var symbol = getSymbolOfNode(node); if (symbol.flags & 512 && !inAmbientContext + && symbol.declarations && symbol.declarations.length > 1 - && isInstantiatedModule(node, !!compilerOptions.preserveConstEnums || !!compilerOptions.isolatedModules)) { + && isInstantiatedModule(node, ts.shouldPreserveConstEnums(compilerOptions))) { var firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol); if (firstNonAmbientClassOrFunc) { if (ts.getSourceFileOfNode(node) !== ts.getSourceFileOfNode(firstNonAmbientClassOrFunc)) { @@ -64377,7 +66789,7 @@ var ts; error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged); } } - var mergedClass = ts.getDeclarationOfKind(symbol, 252); + var mergedClass = ts.getDeclarationOfKind(symbol, 254); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -64419,37 +66831,38 @@ var ts; } } function checkModuleAugmentationElement(node, isGlobalAugmentation) { + var _a; switch (node.kind) { - case 232: - for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; + case 234: + for (var _i = 0, _b = node.declarationList.declarations; _i < _b.length; _i++) { + var decl = _b[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 266: - case 267: + case 268: + case 269: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 260: - case 261: + case 262: + case 263: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 198: - case 249: + case 200: + case 251: var name = node.name; if (ts.isBindingPattern(name)) { - for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { - var el = _c[_b]; + for (var _c = 0, _d = name.elements; _c < _d.length; _c++) { + var el = _d[_c]; checkModuleAugmentationElement(el, isGlobalAugmentation); } break; } - case 252: - case 255: - case 251: + case 254: + case 257: case 253: + case 255: + case 258: case 256: - case 254: if (isGlobalAugmentation) { return; } @@ -64457,7 +66870,7 @@ var ts; if (symbol) { var reportError = !(symbol.flags & 33554432); if (!reportError) { - reportError = !!symbol.parent && ts.isExternalModuleAugmentation(symbol.parent.declarations[0]); + reportError = !!((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.declarations) && ts.isExternalModuleAugmentation(symbol.parent.declarations[0]); } } break; @@ -64465,20 +66878,20 @@ var ts; } function getFirstNonModuleExportsIdentifier(node) { switch (node.kind) { - case 78: + case 79: return node; - case 157: + case 159: do { node = node.left; - } while (node.kind !== 78); + } while (node.kind !== 79); return node; - case 201: + case 203: do { if (ts.isModuleExportsAccessExpression(node.expression) && !ts.isPrivateIdentifier(node.name)) { return node.name; } node = node.expression; - } while (node.kind !== 78); + } while (node.kind !== 79); return node; } } @@ -64491,9 +66904,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 257 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 297 && !inAmbientExternalModule) { - error(moduleName, node.kind === 267 ? + var inAmbientExternalModule = node.parent.kind === 259 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 299 && !inAmbientExternalModule) { + error(moduleName, node.kind === 269 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -64507,6 +66920,7 @@ var ts; return true; } function checkAliasSymbol(node) { + var _a; var symbol = getSymbolOfNode(node); var target = resolveAlias(symbol); if (target !== unknownSymbol) { @@ -64515,20 +66929,20 @@ var ts; (symbol.flags & 788968 ? 788968 : 0) | (symbol.flags & 1920 ? 1920 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 270 ? + var message = node.kind === 272 ? 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 - && node.kind === 270 + && node.kind === 272 && !node.parent.parent.isTypeOnly && !(target.flags & 111551) && !(node.flags & 8388608)) { error(node, ts.Diagnostics.Re_exporting_a_type_when_the_isolatedModules_flag_is_provided_requires_using_export_type); } - if (ts.isImportSpecifier(node) && ts.every(target.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 134217728); })) { - errorOrSuggestion(false, node.name, ts.Diagnostics._0_is_deprecated, symbol.escapedName); + if (ts.isImportSpecifier(node) && ((_a = target.declarations) === null || _a === void 0 ? void 0 : _a.every(function (d) { return !!(ts.getCombinedNodeFlags(d) & 134217728); }))) { + addDeprecatedSuggestion(node.name, target.declarations, symbol.escapedName); } } } @@ -64536,7 +66950,7 @@ var ts; checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); checkAliasSymbol(node); - if (node.kind === 265 && + if (node.kind === 267 && ts.idText(node.propertyName || node.name) === "default" && compilerOptions.esModuleInterop && moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015) { @@ -64557,7 +66971,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 263) { + if (importClause.namedBindings.kind === 265) { checkImportBinding(importClause.namedBindings); if (moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015 && compilerOptions.esModuleInterop) { checkExternalEmitHelpers(node, 65536); @@ -64583,7 +66997,7 @@ var ts; if (ts.hasSyntacticModifier(node, 1)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 272) { + if (node.moduleReference.kind !== 274) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { if (target.flags & 111551) { @@ -64621,10 +67035,10 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause && !ts.isNamespaceExport(node.exportClause)) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 257 && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 257 && + var inAmbientExternalModule = node.parent.kind === 259 && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 259 && !node.moduleSpecifier && node.flags & 8388608; - if (node.parent.kind !== 297 && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 299 && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -64651,14 +67065,14 @@ var ts; } function checkGrammarExportDeclaration(node) { var _a; - var isTypeOnlyExportStar = node.isTypeOnly && ((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) !== 268; + var isTypeOnlyExportStar = node.isTypeOnly && ((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) !== 270; if (isTypeOnlyExportStar) { grammarErrorOnNode(node, ts.Diagnostics.Only_named_exports_may_use_export_type); } return !isTypeOnlyExportStar; } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 297 || node.parent.kind === 257 || node.parent.kind === 256; + var isInAppropriateContext = node.parent.kind === 299 || node.parent.kind === 259 || node.parent.kind === 258; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -64706,7 +67120,7 @@ var ts; if (!node.parent.parent.moduleSpecifier) { var exportedName = node.propertyName || node.name; var symbol = resolveName(exportedName, exportedName.escapedText, 111551 | 788968 | 1920 | 2097152, undefined, undefined, true); - if (symbol && (symbol === undefinedSymbol || symbol === globalThisSymbol || isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { + 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 { @@ -64727,11 +67141,14 @@ var ts; } } function checkExportAssignment(node) { - if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { + var illegalContextMessage = node.isExportEquals + ? ts.Diagnostics.An_export_assignment_must_be_at_the_top_level_of_a_file_or_module_declaration + : ts.Diagnostics.A_default_export_must_be_at_the_top_level_of_a_file_or_module_declaration; + if (checkGrammarModuleElementContext(node, illegalContextMessage)) { return; } - var container = node.parent.kind === 297 ? node.parent : node.parent.parent; - if (container.kind === 256 && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 299 ? node.parent : node.parent.parent; + if (container.kind === 258 && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -64743,7 +67160,7 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasEffectiveModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 78) { + if (node.expression.kind === 79) { var id = node.expression; var sym = resolveEntityName(id, 67108863, true, true, node); if (sym) { @@ -64786,7 +67203,7 @@ var ts; var exportEqualsSymbol = moduleSymbol.exports.get("export="); if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) { var declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration; - if (!isTopLevelInExternalModuleAugmentation(declaration) && !ts.isInJSFile(declaration)) { + if (declaration && !isTopLevelInExternalModuleAugmentation(declaration) && !ts.isInJSFile(declaration)) { error(declaration, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); } } @@ -64805,10 +67222,12 @@ var ts; return; } if (exportedDeclarationsCount > 1) { - for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { - var declaration = declarations_9[_i]; - if (isNotOverload(declaration)) { - diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Cannot_redeclare_exported_variable_0, ts.unescapeLeadingUnderscores(id))); + if (!isDuplicatedCommonJSExport(declarations)) { + for (var _i = 0, _b = declarations; _i < _b.length; _i++) { + var declaration = _b[_i]; + if (isNotOverload(declaration)) { + diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Cannot_redeclare_exported_variable_0, ts.unescapeLeadingUnderscores(id))); + } } } } @@ -64817,6 +67236,11 @@ var ts; links.exportsChecked = true; } } + function isDuplicatedCommonJSExport(declarations) { + return declarations + && declarations.length > 1 + && declarations.every(function (d) { return ts.isInJSFile(d) && ts.isAccessExpression(d) && (ts.isExportsIdentifier(d.expression) || ts.isModuleExportsAccessExpression(d.expression)); }); + } function checkSourceElement(node) { if (node) { var saveCurrentNode = currentNode; @@ -64836,170 +67260,170 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { - case 256: - case 252: + case 258: + case 254: + case 255: case 253: - case 251: cancellationToken.throwIfCancellationRequested(); } } - if (kind >= 232 && kind <= 248 && node.flowNode && !isReachableFlowNode(node.flowNode)) { + if (kind >= 234 && kind <= 250 && node.flowNode && !isReachableFlowNode(node.flowNode)) { errorOrSuggestion(compilerOptions.allowUnreachableCode === false, node, ts.Diagnostics.Unreachable_code_detected); } switch (kind) { - case 159: + case 161: return checkTypeParameter(node); - case 160: + case 162: return checkParameter(node); - case 163: + case 165: return checkPropertyDeclaration(node); - case 162: + case 164: return checkPropertySignature(node); - case 175: - case 174: - case 169: - case 170: + case 177: + case 176: case 171: + case 172: + case 173: return checkSignatureDeclaration(node); - case 165: - case 164: - return checkMethodDeclaration(node); - case 166: - return checkConstructorDeclaration(node); case 167: + case 166: + return checkMethodDeclaration(node); case 168: + return checkConstructorDeclaration(node); + case 169: + case 170: return checkAccessorDeclaration(node); - case 173: + case 175: return checkTypeReferenceNode(node); - case 172: + case 174: return checkTypePredicate(node); - case 176: + case 178: return checkTypeQuery(node); - case 177: + case 179: return checkTypeLiteral(node); - case 178: + case 180: return checkArrayType(node); - case 179: + case 181: return checkTupleType(node); + case 184: + case 185: + return checkUnionOrIntersectionType(node); + case 188: case 182: case 183: - return checkUnionOrIntersectionType(node); - case 186: - case 180: - case 181: return checkSourceElement(node.type); - case 187: + case 189: return checkThisType(node); - case 188: + case 190: return checkTypeOperator(node); - case 184: + case 186: return checkConditionalType(node); - case 185: + case 187: return checkInferType(node); - case 193: - return checkTemplateLiteralType(node); case 195: + return checkTemplateLiteralType(node); + case 197: return checkImportType(node); - case 192: + case 194: return checkNamedTupleMember(node); - case 315: + case 322: return checkJSDocAugmentsTag(node); - case 316: + case 323: return checkJSDocImplementsTag(node); - case 331: - case 324: - case 325: + case 339: + case 332: + case 333: return checkJSDocTypeAliasTag(node); - case 330: + case 338: return checkJSDocTemplateTag(node); - case 329: + case 337: return checkJSDocTypeTag(node); - case 326: + case 334: return checkJSDocParameterTag(node); - case 333: + case 341: return checkJSDocPropertyTag(node); - case 308: + case 311: checkJSDocFunctionType(node); + case 309: + case 308: case 306: - case 305: - case 303: - case 304: - case 312: + case 307: + case 316: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 309: + case 312: checkJSDocVariadicType(node); return; - case 301: + case 303: return checkSourceElement(node.type); - case 189: + case 191: return checkIndexedAccessType(node); - case 190: + case 192: return checkMappedType(node); - case 251: + case 253: return checkFunctionDeclaration(node); - case 230: - case 257: - return checkBlock(node); case 232: - return checkVariableStatement(node); - case 233: - return checkExpressionStatement(node); + case 259: + return checkBlock(node); case 234: - return checkIfStatement(node); + return checkVariableStatement(node); case 235: - return checkDoStatement(node); + return checkExpressionStatement(node); case 236: - return checkWhileStatement(node); + return checkIfStatement(node); case 237: - return checkForStatement(node); + return checkDoStatement(node); case 238: - return checkForInStatement(node); + return checkWhileStatement(node); case 239: - return checkForOfStatement(node); + return checkForStatement(node); case 240: + return checkForInStatement(node); case 241: - return checkBreakOrContinueStatement(node); + return checkForOfStatement(node); case 242: - return checkReturnStatement(node); case 243: - return checkWithStatement(node); + return checkBreakOrContinueStatement(node); case 244: - return checkSwitchStatement(node); + return checkReturnStatement(node); case 245: - return checkLabeledStatement(node); + return checkWithStatement(node); case 246: - return checkThrowStatement(node); + return checkSwitchStatement(node); case 247: - return checkTryStatement(node); + return checkLabeledStatement(node); + case 248: + return checkThrowStatement(node); case 249: + return checkTryStatement(node); + case 251: return checkVariableDeclaration(node); - case 198: + case 200: return checkBindingElement(node); - case 252: + case 254: return checkClassDeclaration(node); - case 253: + case 255: return checkInterfaceDeclaration(node); - case 254: + case 256: return checkTypeAliasDeclaration(node); - case 255: + case 257: return checkEnumDeclaration(node); - case 256: + case 258: return checkModuleDeclaration(node); - case 261: + case 263: return checkImportDeclaration(node); - case 260: + case 262: return checkImportEqualsDeclaration(node); - case 267: + case 269: return checkExportDeclaration(node); - case 266: + case 268: return checkExportAssignment(node); - case 231: - case 248: + case 233: + case 250: checkGrammarStatementInAmbientContext(node); return; - case 271: + case 273: return checkMissingDeclaration(node); } } @@ -65041,8 +67465,11 @@ var ts; var paramTag = node.parent.parent; if (ts.isJSDocTypeExpression(node.parent) && ts.isJSDocParameterTag(paramTag)) { var host_1 = ts.getHostSignatureFromJSDoc(paramTag); - if (host_1) { - var lastParamDeclaration = ts.lastOrUndefined(host_1.parameters); + var isCallbackTag = ts.isJSDocCallbackTag(paramTag.parent.parent); + if (host_1 || isCallbackTag) { + var lastParamDeclaration = isCallbackTag + ? ts.lastOrUndefined(paramTag.parent.parent.typeExpression.parameters) + : ts.lastOrUndefined(host_1.parameters); var symbol = ts.getParameterSymbolFromJSDoc(paramTag); if (!lastParamDeclaration || symbol && lastParamDeclaration.symbol === symbol && ts.isRestParameter(lastParamDeclaration)) { @@ -65071,48 +67498,48 @@ var ts; } } function checkDeferredNode(node) { - ts.tracing.push("check", "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check", "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end }); var saveCurrentNode = currentNode; currentNode = node; instantiationCount = 0; switch (node.kind) { - case 203: - case 204: case 205: - case 161: - case 275: + case 206: + case 207: + case 163: + case 277: resolveUntypedCall(node); break; - case 208: - case 209: - case 165: - case 164: + case 210: + case 211: + case 167: + case 166: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 167: - case 168: + case 169: + case 170: checkAccessorDeclaration(node); break; - case 221: + case 223: checkClassExpressionDeferred(node); break; - case 274: + case 276: checkJsxSelfClosingElementDeferred(node); break; - case 273: + case 275: checkJsxElementDeferred(node); break; } currentNode = saveCurrentNode; - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } function checkSourceFile(node) { - ts.tracing.push("check", "checkSourceFile", { path: node.path }, true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check", "checkSourceFile", { path: node.path }, true); ts.performance.mark("beforeCheck"); checkSourceFileWorker(node); ts.performance.mark("afterCheck"); ts.performance.measure("Check", "beforeCheck", "afterCheck"); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } function unusedIsError(kind, isAmbient) { if (isAmbient) { @@ -65139,7 +67566,7 @@ var ts; checkGrammarSourceFile(node); ts.clear(potentialThisCollisions); ts.clear(potentialNewTargetCollisions); - ts.clear(potentialWeakMapCollisions); + ts.clear(potentialWeakMapSetCollisions); ts.forEach(node.statements, checkSourceElement); checkSourceElement(node.endOfFileToken); checkDeferredNodes(node); @@ -65169,9 +67596,9 @@ var ts; ts.forEach(potentialNewTargetCollisions, checkIfNewTargetIsCapturedInEnclosingScope); ts.clear(potentialNewTargetCollisions); } - if (potentialWeakMapCollisions.length) { - ts.forEach(potentialWeakMapCollisions, checkWeakMapCollision); - ts.clear(potentialWeakMapCollisions); + if (potentialWeakMapSetCollisions.length) { + ts.forEach(potentialWeakMapSetCollisions, checkWeakMapSetCollision); + ts.clear(potentialWeakMapSetCollisions); } links.flags |= 1; } @@ -65229,27 +67656,27 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 297: - if (!ts.isExternalOrCommonJsModule(location)) + case 299: + if (!ts.isExternalModule(location)) break; - case 256: - copySymbols(getSymbolOfNode(location).exports, meaning & 2623475); + case 258: + copyLocallyVisibleExportSymbols(getSymbolOfNode(location).exports, meaning & 2623475); break; - case 255: + case 257: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 221: + case 223: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - case 252: - case 253: + case 254: + case 255: if (!isStatic) { copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968); } break; - case 208: + case 210: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -65279,52 +67706,52 @@ var ts; }); } } + function copyLocallyVisibleExportSymbols(source, meaning) { + if (meaning) { + source.forEach(function (symbol) { + if (!ts.getDeclarationOfKind(symbol, 272) && !ts.getDeclarationOfKind(symbol, 271)) { + copySymbol(symbol, meaning); + } + }); + } + } } function isTypeDeclarationName(name) { - return name.kind === 78 && + return name.kind === 79 && isTypeDeclaration(name.parent) && ts.getNameOfDeclaration(name.parent) === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 159: - case 252: - case 253: + case 161: case 254: case 255: - case 331: - case 324: - case 325: + case 256: + case 257: + case 339: + case 332: + case 333: return true; - case 262: + case 264: return node.isTypeOnly; - case 265: - case 270: + case 267: + case 272: return node.parent.parent.isTypeOnly; default: return false; } } function isTypeReferenceIdentifier(node) { - while (node.parent.kind === 157) { + while (node.parent.kind === 159) { node = node.parent; } - return node.parent.kind === 173; + return node.parent.kind === 175; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 201) { + while (node.parent.kind === 203) { node = node.parent; } - return node.parent.kind === 223; - } - function isJSDocEntryNameReference(node) { - while (node.parent.kind === 157) { - node = node.parent; - } - while (node.parent.kind === 201) { - node = node.parent; - } - return node.parent.kind === 302; + return node.parent.kind === 225; } function forEachEnclosingClass(node, callback) { var result; @@ -65352,13 +67779,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 157) { + while (nodeOnRightSide.parent.kind === 159) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 260) { + if (nodeOnRightSide.parent.kind === 262) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 266) { + if (nodeOnRightSide.parent.kind === 268) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -65384,7 +67811,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 195 && parent.qualifier === node) { + if (parent && parent.kind === 197 && parent.qualifier === node) { return parent; } return undefined; @@ -65394,27 +67821,27 @@ var ts; return getSymbolOfNode(name.parent); } if (ts.isInJSFile(name) && - name.parent.kind === 201 && + name.parent.kind === 203 && name.parent === name.parent.parent.left) { - if (!ts.isPrivateIdentifier(name)) { + if (!ts.isPrivateIdentifier(name) && !ts.isJSDocMemberName(name)) { var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(name); if (specialPropertyAssignmentSymbol) { return specialPropertyAssignmentSymbol; } } } - if (name.parent.kind === 266 && ts.isEntityNameExpression(name)) { + if (name.parent.kind === 268 && ts.isEntityNameExpression(name)) { var success = resolveEntityName(name, 111551 | 788968 | 1920 | 2097152, true); if (success && success !== unknownSymbol) { return success; } } - else if (!ts.isPropertyAccessExpression(name) && !ts.isPrivateIdentifier(name) && isInRightSideOfImportOrExportAssignment(name)) { - var importEqualsDeclaration = ts.getAncestor(name, 260); + else if (ts.isEntityName(name) && isInRightSideOfImportOrExportAssignment(name)) { + var importEqualsDeclaration = ts.getAncestor(name, 262); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(name, true); } - if (!ts.isPropertyAccessExpression(name) && !ts.isPrivateIdentifier(name)) { + if (ts.isEntityName(name)) { var possibleImportNode = isImportTypeQualifierPart(name); if (possibleImportNode) { getTypeFromTypeNode(possibleImportNode); @@ -65422,12 +67849,12 @@ var ts; return sym === unknownSymbol ? undefined : sym; } } - while (ts.isRightSideOfQualifiedNameOrPropertyAccess(name)) { + while (ts.isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName(name)) { name = name.parent; } if (isHeritageClauseElementIdentifier(name)) { var meaning = 0; - if (name.parent.kind === 223) { + if (name.parent.kind === 225) { meaning = 788968; if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(name.parent)) { meaning |= 111551; @@ -65442,10 +67869,10 @@ var ts; return entityNameSymbol; } } - if (name.parent.kind === 326) { + if (name.parent.kind === 334) { return ts.getParameterSymbolFromJSDoc(name.parent); } - if (name.parent.kind === 159 && name.parent.parent.kind === 330) { + if (name.parent.kind === 161 && name.parent.parent.kind === 338) { ts.Debug.assert(!ts.isInJSFile(name)); var typeParameter = ts.getTypeParameterFromJsDoc(name.parent); return typeParameter && typeParameter.symbol; @@ -65454,42 +67881,72 @@ var ts; if (ts.nodeIsMissing(name)) { return undefined; } - if (name.kind === 78) { + var isJSDoc_1 = ts.findAncestor(name, ts.or(ts.isJSDocLinkLike, ts.isJSDocNameReference, ts.isJSDocMemberName)); + var meaning = isJSDoc_1 ? 788968 | 1920 | 111551 : 111551; + if (name.kind === 79) { if (ts.isJSXTagName(name) && isJsxIntrinsicIdentifier(name)) { var symbol = getIntrinsicTagSymbol(name.parent); return symbol === unknownSymbol ? undefined : symbol; } - return resolveEntityName(name, 111551, false, true); + var result = resolveEntityName(name, meaning, false, !isJSDoc_1, ts.getHostSignatureFromJSDoc(name)); + if (!result && isJSDoc_1) { + var container = ts.findAncestor(name, ts.or(ts.isClassLike, ts.isInterfaceDeclaration)); + if (container) { + return resolveJSDocMemberName(name, getSymbolOfNode(container)); + } + } + return result; } - else if (name.kind === 201 || name.kind === 157) { + else if (name.kind === 203 || name.kind === 159) { var links = getNodeLinks(name); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (name.kind === 201) { - checkPropertyAccessExpression(name); + if (name.kind === 203) { + checkPropertyAccessExpression(name, 0); } else { - checkQualifiedName(name); + checkQualifiedName(name, 0); + } + if (!links.resolvedSymbol && isJSDoc_1 && ts.isQualifiedName(name)) { + return resolveJSDocMemberName(name); } return links.resolvedSymbol; } + else if (ts.isJSDocMemberName(name)) { + return resolveJSDocMemberName(name); + } } else if (isTypeReferenceIdentifier(name)) { - var meaning = name.parent.kind === 173 ? 788968 : 1920; + var meaning = name.parent.kind === 175 ? 788968 : 1920; return resolveEntityName(name, meaning, false, true); } - else if (isJSDocEntryNameReference(name)) { - var meaning = 788968 | 1920 | 111551; - return resolveEntityName(name, meaning, false, true, ts.getHostSignatureFromJSDoc(name)); - } - if (name.parent.kind === 172) { + if (name.parent.kind === 174) { return resolveEntityName(name, 1); } return undefined; } + function resolveJSDocMemberName(name, container) { + if (ts.isEntityName(name)) { + var meaning = 788968 | 1920 | 111551; + var symbol = resolveEntityName(name, meaning, false, true, ts.getHostSignatureFromJSDoc(name)); + if (!symbol && ts.isIdentifier(name) && container) { + symbol = getMergedSymbol(getSymbol(getExportsOfSymbol(container), name.escapedText, meaning)); + } + if (symbol) { + return symbol; + } + } + var left = ts.isIdentifier(name) ? container : resolveJSDocMemberName(name.left); + var right = ts.isIdentifier(name) ? name.escapedText : name.right.escapedText; + if (left) { + var proto = left.flags & 111551 && getPropertyOfType(getTypeOfSymbol(left), "prototype"); + var t = proto ? getTypeOfSymbol(proto) : getDeclaredTypeOfSymbol(left); + return getPropertyOfType(t, right); + } + } function getSymbolAtLocation(node, ignoreErrors) { - if (node.kind === 297) { + if (node.kind === 299) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; @@ -65506,12 +67963,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(parent.parent); } - if (node.kind === 78) { + if (node.kind === 79) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfNameOrPropertyAccessExpression(node); } - else if (parent.kind === 198 && - grandParent.kind === 196 && + else if (parent.kind === 200 && + grandParent.kind === 198 && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText); @@ -65521,12 +67978,12 @@ var ts; } } switch (node.kind) { - case 78: case 79: - case 201: - case 157: + case 80: + case 203: + case 159: return getSymbolOfNameOrPropertyAccessExpression(node); - case 107: + case 108: var container = ts.getThisContainer(node, false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -65537,20 +67994,20 @@ var ts; if (ts.isInExpressionContext(node)) { return checkExpression(node).symbol; } - case 187: + case 189: return getTypeFromThisTypeNode(node).symbol; - case 105: + case 106: return checkExpression(node).symbol; - case 132: + case 133: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 166) { + if (constructorDeclaration && constructorDeclaration.kind === 168) { return constructorDeclaration.parent.symbol; } return undefined; case 10: case 14: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 261 || node.parent.kind === 267) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 263 || node.parent.kind === 269) && node.parent.moduleSpecifier === node) || ((ts.isInJSFile(node) && ts.isRequireCall(node.parent, 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); @@ -65565,21 +68022,21 @@ var ts; ? getTypeFromTypeNode(grandParent.objectType) : undefined; return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text)); - case 87: - case 97: + case 88: + case 98: case 38: - case 83: + case 84: return getSymbolOfNode(node.parent); - case 195: + case 197: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal, ignoreErrors) : undefined; - case 92: + case 93: return ts.isExportAssignment(node.parent) ? ts.Debug.checkDefined(node.parent.symbol) : undefined; default: return undefined; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 289) { + if (location && location.kind === 291) { return resolveEntityName(location.name, 111551 | 2097152); } return undefined; @@ -65646,20 +68103,20 @@ var ts; return errorType; } function getTypeOfAssignmentPattern(expr) { - ts.Debug.assert(expr.kind === 200 || expr.kind === 199); - if (expr.parent.kind === 239) { + ts.Debug.assert(expr.kind === 202 || expr.kind === 201); + if (expr.parent.kind === 241) { var iteratedType = checkRightHandSideOfForOf(expr.parent); return checkDestructuringAssignment(expr, iteratedType || errorType); } - if (expr.parent.kind === 216) { + if (expr.parent.kind === 218) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || errorType); } - if (expr.parent.kind === 288) { - var node_2 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); - var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_2) || errorType; - var propertyIndex = ts.indexOfNode(node_2.properties, expr.parent); - return checkObjectLiteralDestructuringPropertyAssignment(node_2, typeOfParentObjectLiteral, propertyIndex); + if (expr.parent.kind === 290) { + 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); + return checkObjectLiteralDestructuringPropertyAssignment(node_3, typeOfParentObjectLiteral, propertyIndex); } var node = ts.cast(expr.parent, ts.isArrayLiteralExpression); var typeOfArrayLiteral = getTypeOfAssignmentPattern(node) || errorType; @@ -65685,12 +68142,12 @@ var ts; function getClassElementPropertyKeyType(element) { var name = element.name; switch (name.kind) { - case 78: + case 79: return getLiteralType(ts.idText(name)); case 8: case 10: return getLiteralType(name.text); - case 158: + case 160: var nameType = checkComputedPropertyName(name); return isTypeAssignableToKind(nameType, 12288) ? nameType : stringType; default: @@ -65776,6 +68233,7 @@ var ts; return ts.isModuleOrEnumDeclaration(node.parent) && node === node.parent.name; } function getReferencedExportContainer(nodeIn, prefixLocals) { + var _a; var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { var symbol = getReferencedValueSymbol(node, isNameOfModuleOrEnumDeclaration(node)); @@ -65789,7 +68247,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 && parentSymbol_1.valueDeclaration.kind === 297) { + if (parentSymbol_1.flags & 512 && ((_a = parentSymbol_1.valueDeclaration) === null || _a === void 0 ? void 0 : _a.kind) === 299) { var symbolFile = parentSymbol_1.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); var symbolIsUmdExport = symbolFile !== referenceFile; @@ -65814,11 +68272,12 @@ var ts; return undefined; } function isSymbolOfDestructuredElementOfCatchBinding(symbol) { - return ts.isBindingElement(symbol.valueDeclaration) - && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 287; + return symbol.valueDeclaration + && ts.isBindingElement(symbol.valueDeclaration) + && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 289; } function isSymbolOfDeclarationWithCollidingName(symbol) { - if (symbol.flags & 418 && !ts.isSourceFile(symbol.valueDeclaration)) { + if (symbol.flags & 418 && symbol.valueDeclaration && !ts.isSourceFile(symbol.valueDeclaration)) { var links = getSymbolLinks(symbol); if (links.isDeclarationWithCollidingName === undefined) { var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); @@ -65830,7 +68289,7 @@ var ts; else if (nodeLinks_1.flags & 262144) { var isDeclaredInLoop = nodeLinks_1.flags & 524288; var inLoopInitializer = ts.isIterationStatement(container, false); - var inLoopBodyBlock = container.kind === 230 && ts.isIterationStatement(container.parent, false); + var inLoopBodyBlock = container.kind === 232 && ts.isIterationStatement(container.parent, false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -65866,20 +68325,20 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 260: - return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); case 262: - case 263: + return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); + case 264: case 265: - case 270: + case 267: + case 272: var symbol = getSymbolOfNode(node) || unknownSymbol; return isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol); - case 267: + case 269: var exportClause = node.exportClause; return !!exportClause && (ts.isNamespaceExport(exportClause) || ts.some(exportClause.elements, isValueAliasDeclaration)); - case 266: - return node.expression && node.expression.kind === 78 ? + case 268: + return node.expression && node.expression.kind === 79 ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : true; } @@ -65887,7 +68346,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 297 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 299 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -65899,7 +68358,7 @@ var ts; return true; } return !!(target.flags & 111551) && - (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target)); + (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target)); } function isConstEnumOrConstEnumOnlyModule(s) { return isConstEnumSymbol(s) || !!s.constEnumOnlyModule; @@ -65907,13 +68366,14 @@ var ts; function isReferencedAliasDeclaration(node, checkChildren) { if (isAliasSymbolDeclaration(node)) { var symbol = getSymbolOfNode(node); - if (symbol && getSymbolLinks(symbol).referenced) { + var links = symbol && getSymbolLinks(symbol); + if (links === null || links === void 0 ? void 0 : links.referenced) { return true; } var target = getSymbolLinks(symbol).target; if (target && ts.getEffectiveModifierFlags(node) & 1 && target.flags & 111551 && - (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) { + (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) { return true; } } @@ -65938,13 +68398,13 @@ var ts; !isOptionalParameter(parameter) && !ts.isJSDocParameterTag(parameter) && !!parameter.initializer && - !ts.hasSyntacticModifier(parameter, 92); + !ts.hasSyntacticModifier(parameter, 16476); } function isOptionalUninitializedParameterProperty(parameter) { return strictNullChecks && isOptionalParameter(parameter) && !parameter.initializer && - ts.hasSyntacticModifier(parameter, 92); + ts.hasSyntacticModifier(parameter, 16476); } function isOptionalUninitializedParameter(parameter) { return !!strictNullChecks && @@ -65979,15 +68439,15 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 291: - case 201: - case 202: + case 293: + case 203: + case 204: return true; } return false; } function getConstantValue(node) { - if (node.kind === 291) { + if (node.kind === 293) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -66070,7 +68530,7 @@ var ts; function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) { var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor); if (!declaration) { - return ts.factory.createToken(128); + return ts.factory.createToken(129); } var symbol = getSymbolOfNode(declaration); var type = symbol && !(symbol.flags & (2048 | 131072)) @@ -66088,7 +68548,7 @@ var ts; function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) { var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike); if (!signatureDeclaration) { - return ts.factory.createToken(128); + return ts.factory.createToken(129); } var signature = getSignatureFromDeclaration(signatureDeclaration); return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024, tracker); @@ -66096,7 +68556,7 @@ var ts; function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) { var expr = ts.getParseTreeNode(exprIn, ts.isExpression); if (!expr) { - return ts.factory.createToken(128); + return ts.factory.createToken(129); } var type = getWidenedType(getRegularTypeOfExpression(expr)); return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024, tracker); @@ -66132,8 +68592,7 @@ var ts; } function isLiteralConstDeclaration(node) { if (ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node)) { - var type = getTypeOfSymbol(getSymbolOfNode(node)); - return !!(type.flags & 2944) && isFreshLiteralType(type); + return isFreshLiteralType(getTypeOfSymbol(getSymbolOfNode(node))); } return false; } @@ -66245,12 +68704,12 @@ var ts; getJsxFragmentFactoryEntity: getJsxFragmentFactoryEntity, getAllAccessorDeclarations: function (accessor) { accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); - var otherKind = accessor.kind === 168 ? 167 : 168; + var otherKind = accessor.kind === 170 ? 169 : 170; 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 === 168 ? accessor : otherAccessor; - var getAccessor = accessor.kind === 167 ? accessor : otherAccessor; + var setAccessor = accessor.kind === 170 ? accessor : otherAccessor; + var getAccessor = accessor.kind === 169 ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -66266,7 +68725,7 @@ var ts; }, getDeclarationStatementsForSourceFile: function (node, flags, tracker, bundled) { var n = ts.getParseTreeNode(node); - ts.Debug.assert(n && n.kind === 297, "Non-sourcefile node passed into getDeclarationsForSourceFile"); + ts.Debug.assert(n && n.kind === 299, "Non-sourcefile node passed into getDeclarationsForSourceFile"); var sym = getSymbolOfNode(node); if (!sym) { return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker, bundled); @@ -66289,11 +68748,13 @@ var ts; var s = _a[_i]; if (s.mergeId) { var merged = getMergedSymbol(s); - for (var _b = 0, _c = merged.declarations; _b < _c.length; _b++) { - var d = _c[_b]; - var declFile = ts.getSourceFileOfNode(d); - if (declFile === importTarget) { - return true; + if (merged.declarations) { + for (var _b = 0, _c = merged.declarations; _b < _c.length; _b++) { + var d = _c[_b]; + var declFile = ts.getSourceFileOfNode(d); + if (declFile === importTarget) { + return true; + } } } } @@ -66301,24 +68762,21 @@ var ts; return false; } function isInHeritageClause(node) { - return node.parent && node.parent.kind === 223 && node.parent.parent && node.parent.parent.kind === 286; + return node.parent && node.parent.kind === 225 && node.parent.parent && node.parent.parent.kind === 288; } function getTypeReferenceDirectivesForEntityName(node) { if (!fileToDirective) { return undefined; } var meaning = 788968 | 1920; - if ((node.kind === 78 && isInTypeQuery(node)) || (node.kind === 201 && !isInHeritageClause(node))) { + if ((node.kind === 79 && isInTypeQuery(node)) || (node.kind === 203 && !isInHeritageClause(node))) { meaning = 111551 | 1048576; } var symbol = resolveEntityName(node, meaning, true); return symbol && symbol !== unknownSymbol ? getTypeReferenceDirectivesForSymbol(symbol, meaning) : undefined; } function getTypeReferenceDirectivesForSymbol(symbol, meaning) { - if (!fileToDirective) { - return undefined; - } - if (!isSymbolFromTypeDeclarationFile(symbol)) { + if (!fileToDirective || !isSymbolFromTypeDeclarationFile(symbol)) { return undefined; } var typeReferenceDirectives; @@ -66351,7 +68809,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 297 && current.flags & 512) { + if (current.valueDeclaration && current.valueDeclaration.kind === 299 && current.flags & 512) { return false; } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { @@ -66378,12 +68836,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 256 ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 258 ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); var moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, undefined); if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 297); + return ts.getDeclarationOfKind(moduleSymbol, 299); } function initializeTypeChecker() { for (var _i = 0, _a = host.getSourceFiles(); _i < _a.length; _i++) { @@ -66399,7 +68857,7 @@ var ts; } if (!ts.isExternalOrCommonJsModule(file)) { var fileGlobalThisSymbol = file.locals.get("globalThis"); - if (fileGlobalThisSymbol) { + if (fileGlobalThisSymbol === null || fileGlobalThisSymbol === void 0 ? void 0 : fileGlobalThisSymbol.declarations) { for (var _d = 0, _e = fileGlobalThisSymbol.declarations; _d < _e.length; _d++) { var declaration = _e[_d]; diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0, "globalThis")); @@ -66507,6 +68965,16 @@ var ts; 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) { + 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) { + 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); + } + } } } } @@ -66555,14 +69023,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 165 && !ts.nodeIsPresent(node.body)) { + if (node.kind === 167 && !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 === 167 || node.kind === 168) { + else if (node.kind === 169 || node.kind === 170) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -66575,31 +69043,50 @@ var ts; if (quickResult !== undefined) { return quickResult; } - var lastStatic, lastDeclare, lastAsync, lastReadonly; + var lastStatic, lastDeclare, lastAsync, lastReadonly, lastOverride; var flags = 0; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 142) { - if (node.kind === 162 || node.kind === 164) { + if (modifier.kind !== 143) { + if (node.kind === 164 || node.kind === 166) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 171) { + if (node.kind === 173 && (modifier.kind !== 124 || !ts.isClassLike(node.parent))) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 84: - if (node.kind !== 255) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(84)); + case 85: + if (node.kind !== 257) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(85)); + } + break; + case 157: + if (flags & 16384) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "override"); + } + else if (flags & 2) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "override", "declare"); } + else if (flags & 64) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "override", "readonly"); + } + else if (flags & 256) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "override", "async"); + } + flags |= 16384; + lastOverride = modifier; break; + case 123: case 122: case 121: - case 120: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); if (flags & 28) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); } + else if (flags & 16384) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "override"); + } else if (flags & 32) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } @@ -66609,23 +69096,23 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 257 || node.parent.kind === 297) { + else if (node.parent.kind === 259 || node.parent.kind === 299) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128) { - if (modifier.kind === 120) { + if (modifier.kind === 121) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "abstract"); } } - else if (ts.isPrivateIdentifierPropertyDeclaration(node)) { + else if (ts.isPrivateIdentifierClassElementDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics.An_accessibility_modifier_cannot_be_used_with_a_private_identifier); } flags |= ts.modifierToFlag(modifier.kind); break; - case 123: + case 124: if (flags & 32) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } @@ -66635,32 +69122,32 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 257 || node.parent.kind === 297) { + else if (node.parent.kind === 259 || node.parent.kind === 299) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 160) { + else if (node.kind === 162) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - else if (ts.isPrivateIdentifierPropertyDeclaration(node)) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "static"); + else if (flags & 16384) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "override"); } flags |= 32; lastStatic = modifier; break; - case 142: + case 143: if (flags & 64) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 163 && node.kind !== 162 && node.kind !== 171 && node.kind !== 160) { + else if (node.kind !== 165 && node.kind !== 164 && node.kind !== 173 && node.kind !== 162) { return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } flags |= 64; lastReadonly = modifier; break; - case 92: + case 93: if (flags & 1) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -66676,53 +69163,56 @@ var ts; 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 === 160) { + else if (node.kind === 162) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; break; - case 87: - var container = node.parent.kind === 297 ? node.parent : node.parent.parent; - if (container.kind === 256 && !ts.isAmbientModule(container)) { + case 88: + var container = node.parent.kind === 299 ? node.parent : node.parent.parent; + if (container.kind === 258 && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } flags |= 512; break; - case 133: + case 134: if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } + else if (flags & 16384) { + 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 === 160) { + else if (node.kind === 162) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 8388608) && node.parent.kind === 257) { + else if ((node.parent.flags & 8388608) && node.parent.kind === 259) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } - else if (ts.isPrivateIdentifierPropertyDeclaration(node)) { + else if (ts.isPrivateIdentifierClassElementDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "declare"); } flags |= 2; lastDeclare = modifier; break; - case 125: + case 126: if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 252 && - node.kind !== 175) { - if (node.kind !== 165 && - node.kind !== 163 && - node.kind !== 167 && - node.kind !== 168) { + if (node.kind !== 254 && + node.kind !== 177) { + if (node.kind !== 167 && + node.kind !== 165 && + node.kind !== 169 && + node.kind !== 170) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 252 && ts.hasSyntacticModifier(node.parent, 128))) { + if (!(node.parent.kind === 254 && ts.hasSyntacticModifier(node.parent, 128))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32) { @@ -66734,20 +69224,23 @@ var ts; if (flags & 256 && lastAsync) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "async", "abstract"); } + if (flags & 16384) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "abstract", "override"); + } } - if (ts.isNamedDeclaration(node) && node.name.kind === 79) { + if (ts.isNamedDeclaration(node) && node.name.kind === 80) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "abstract"); } flags |= 128; break; - case 129: + case 130: if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } else if (flags & 2 || node.parent.flags & 8388608) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 160) { + else if (node.kind === 162) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } if (flags & 128) { @@ -66758,13 +69251,16 @@ var ts; break; } } - if (node.kind === 166) { + if (node.kind === 168) { if (flags & 32) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } if (flags & 128) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract"); } + if (flags & 16384) { + return grammarErrorOnNode(lastOverride, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "override"); + } else if (flags & 256) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); } @@ -66773,13 +69269,13 @@ var ts; } return false; } - else if ((node.kind === 261 || node.kind === 260) && flags & 2) { + else if ((node.kind === 263 || node.kind === 262) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 160 && (flags & 92) && ts.isBindingPattern(node.name)) { + else if (node.kind === 162 && (flags & 16476) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 160 && (flags & 92) && node.dotDotDotToken) { + else if (node.kind === 162 && (flags & 16476) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256) { @@ -66796,39 +69292,39 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 167: + case 169: + case 170: case 168: - case 166: - case 163: - case 162: case 165: case 164: - case 171: - case 256: - case 261: - case 260: - case 267: - case 266: - case 208: - case 209: - case 160: + case 167: + case 166: + case 173: + case 258: + case 263: + case 262: + case 269: + case 268: + case 210: + case 211: + case 162: return false; default: - if (node.parent.kind === 257 || node.parent.kind === 297) { + if (node.parent.kind === 259 || node.parent.kind === 299) { return false; } switch (node.kind) { - case 251: - return nodeHasAnyModifiersExcept(node, 129); - case 252: - case 175: - return nodeHasAnyModifiersExcept(node, 125); case 253: - case 232: + return nodeHasAnyModifiersExcept(node, 130); case 254: - return true; + case 177: + return nodeHasAnyModifiersExcept(node, 126); case 255: - return nodeHasAnyModifiersExcept(node, 84); + case 234: + case 256: + return true; + case 257: + return nodeHasAnyModifiersExcept(node, 85); default: ts.Debug.fail(); } @@ -66839,10 +69335,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 165: - case 251: - case 208: - case 209: + case 167: + case 253: + case 210: + case 211: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -66960,7 +69456,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 147 && parameter.type.kind !== 144) { + if (parameter.type.kind !== 148 && parameter.type.kind !== 145) { var type = getTypeFromTypeNode(parameter.type); if (type.flags & 4 || type.flags & 8) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead, ts.getTextOfNode(parameter.name), typeToString(type), typeToString(node.type ? getTypeFromTypeNode(node.type) : anyType)); @@ -67001,7 +69497,7 @@ var ts; if (args) { for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 222) { + if (arg.kind === 224) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -67031,7 +69527,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 === 93) { + if (heritageClause.token === 94) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -67044,7 +69540,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 116); + ts.Debug.assert(heritageClause.token === 117); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -67059,14 +69555,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 93) { + if (heritageClause.token === 94) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 116); + ts.Debug.assert(heritageClause.token === 117); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } checkGrammarHeritageClause(heritageClause); @@ -67075,20 +69571,20 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 158) { + if (node.kind !== 160) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 216 && computedPropertyName.expression.operatorToken.kind === 27) { + if (computedPropertyName.expression.kind === 218 && computedPropertyName.expression.operatorToken.kind === 27) { 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 === 251 || - node.kind === 208 || - node.kind === 165); + ts.Debug.assert(node.kind === 253 || + node.kind === 210 || + node.kind === 167); if (node.flags & 8388608) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -67107,7 +69603,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 === 290) { + if (prop.kind === 292) { if (inDestructuring) { var expression = ts.skipParentheses(prop.expression); if (ts.isArrayLiteralExpression(expression) || ts.isObjectLiteralExpression(expression)) { @@ -67117,41 +69613,41 @@ var ts; continue; } var name = prop.name; - if (name.kind === 158) { + if (name.kind === 160) { checkGrammarComputedPropertyName(name); } - if (prop.kind === 289 && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 291 && !inDestructuring && prop.objectAssignmentInitializer) { return 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 === 79) { - return grammarErrorOnNode(name, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); + if (name.kind === 80) { + grammarErrorOnNode(name, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); } if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (mod.kind !== 129 || prop.kind !== 165) { + if (mod.kind !== 130 || prop.kind !== 167) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } } var currentKind = void 0; switch (prop.kind) { - case 289: + case 291: checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); - case 288: + case 290: checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8) { checkGrammarNumericLiteral(name); } currentKind = 4; break; - case 165: + case 167: currentKind = 8; break; - case 167: + case 169: currentKind = 1; break; - case 168: + case 170: currentKind = 2; break; default: @@ -67186,11 +69682,12 @@ var ts; } } function checkGrammarJsxElement(node) { + checkGrammarJsxName(node.tagName); checkGrammarTypeArguments(node, node.typeArguments); var seen = new ts.Map(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 282) { + if (attr.kind === 284) { continue; } var name = attr.name, initializer = attr.initializer; @@ -67200,11 +69697,32 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 283 && !initializer.expression) { + if (initializer && initializer.kind === 285 && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } } + function checkGrammarJsxName(node) { + if (ts.isPropertyAccessExpression(node)) { + var propName = node; + do { + var check_1 = checkGrammarJsxNestedIdentifier(propName.name); + if (check_1) { + return check_1; + } + propName = propName.expression; + } while (ts.isPropertyAccessExpression(propName)); + var check = checkGrammarJsxNestedIdentifier(propName); + if (check) { + return check; + } + } + function checkGrammarJsxNestedIdentifier(name) { + if (ts.isIdentifier(name) && ts.idText(name).indexOf(":") !== -1) { + return grammarErrorOnNode(name, ts.Diagnostics.JSX_property_access_expressions_cannot_include_JSX_namespace_names); + } + } + } function checkGrammarJsxExpression(node) { if (node.expression && ts.isCommaSequence(node.expression)) { return grammarErrorOnNode(node.expression, ts.Diagnostics.JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array); @@ -67214,24 +69732,41 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 239 && forInOrOfStatement.awaitModifier) { - if ((forInOrOfStatement.flags & 32768) === 0) { + if (forInOrOfStatement.kind === 241 && forInOrOfStatement.awaitModifier) { + if (!(forInOrOfStatement.flags & 32768)) { var sourceFile = ts.getSourceFileOfNode(forInOrOfStatement); - if (!hasParseDiagnostics(sourceFile)) { - var diagnostic = ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); - var func = ts.getContainingFunction(forInOrOfStatement); - if (func && func.kind !== 166) { - ts.Debug.assert((ts.getFunctionFlags(func) & 2) === 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); - } - diagnostics.add(diagnostic); - return true; + if (ts.isInTopLevelContext(forInOrOfStatement)) { + if (!hasParseDiagnostics(sourceFile)) { + if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) { + diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module)); + } + if ((moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) || languageVersion < 4) { + diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher)); + } + } + } + else { + 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 !== 168) { + ts.Debug.assert((ts.getFunctionFlags(func) & 2) === 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); + } + diagnostics.add(diagnostic); + return true; + } } return false; } } - if (forInOrOfStatement.initializer.kind === 250) { + if (ts.isForOfStatement(forInOrOfStatement) && !(forInOrOfStatement.flags & 32768) && + 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 === 252) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -67239,20 +69774,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 238 + var diagnostic = forInOrOfStatement.kind === 240 ? 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 === 238 + var diagnostic = forInOrOfStatement.kind === 240 ? 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 === 238 + var diagnostic = forInOrOfStatement.kind === 240 ? 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); @@ -67262,26 +69797,34 @@ var ts; return false; } function checkGrammarAccessor(accessor) { - if (!(accessor.flags & 8388608)) { + if (!(accessor.flags & 8388608) && (accessor.parent.kind !== 179) && (accessor.parent.kind !== 255)) { if (languageVersion < 1) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); } + if (languageVersion < 2 && 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)) { return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } } - if (accessor.body && ts.hasSyntacticModifier(accessor, 128)) { - return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation); + if (accessor.body) { + if (ts.hasSyntacticModifier(accessor, 128)) { + return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation); + } + if (accessor.parent.kind === 179 || accessor.parent.kind === 255) { + return grammarErrorOnNode(accessor.body, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); + } } if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, accessor.kind === 167 ? + return grammarErrorOnNode(accessor.name, accessor.kind === 169 ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - if (accessor.kind === 168) { + if (accessor.kind === 170) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -67299,17 +69842,17 @@ var ts; return false; } function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 167 ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 169 ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 167 ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 169 ? 1 : 2)) { return ts.getThisParameter(accessor); } } function checkGrammarTypeOperatorNode(node) { - if (node.operator === 151) { - if (node.type.kind !== 148) { - return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(148)); + if (node.operator === 152) { + if (node.type.kind !== 149) { + return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(149)); } var parent = ts.walkUpParenthesizedTypes(node.parent); if (ts.isInJSFile(parent) && ts.isJSDocTypeExpression(parent)) { @@ -67319,9 +69862,9 @@ var ts; } } switch (parent.kind) { - case 249: + case 251: var decl = parent; - if (decl.name.kind !== 78) { + if (decl.name.kind !== 79) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name); } if (!ts.isVariableDeclarationInVariableStatement(decl)) { @@ -67331,13 +69874,13 @@ var ts; return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 163: + case 165: if (!ts.hasSyntacticModifier(parent, 32) || !ts.hasEffectiveModifier(parent, 64)) { 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 162: + case 164: if (!ts.hasSyntacticModifier(parent, 64)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly); } @@ -67346,9 +69889,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_not_allowed_here); } } - else if (node.operator === 142) { - if (node.type.kind !== 178 && node.type.kind !== 179) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(148)); + else if (node.operator === 143) { + if (node.type.kind !== 180 && node.type.kind !== 181) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(149)); } } } @@ -67361,9 +69904,9 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 165) { - if (node.parent.kind === 200) { - if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 129)) { + if (node.kind === 167) { + if (node.parent.kind === 202) { + if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 130)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } else if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { @@ -67381,17 +69924,20 @@ var ts; } } if (ts.isClassLike(node.parent)) { + if (languageVersion < 2 && ts.isPrivateIdentifier(node.name)) { + return grammarErrorOnNode(node.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher); + } if (node.flags & 8388608) { 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 === 165 && !node.body) { + else if (node.kind === 167 && !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 === 253) { + else if (node.parent.kind === 255) { 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 === 177) { + else if (node.parent.kind === 179) { 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); } } @@ -67402,9 +69948,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 245: + case 247: if (node.label && current.label.escapedText === node.label.escapedText) { - var isMisplacedContinueLabel = node.kind === 240 + var isMisplacedContinueLabel = node.kind === 242 && !ts.isIterationStatement(current.statement, true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -67412,8 +69958,8 @@ var ts; return false; } break; - case 244: - if (node.kind === 241 && !node.label) { + case 246: + if (node.kind === 243 && !node.label) { return false; } break; @@ -67426,13 +69972,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 241 + var message = node.kind === 243 ? 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 === 241 + var message = node.kind === 243 ? 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); @@ -67455,12 +70001,12 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return ts.isStringOrNumericLiteralLike(expr) || - expr.kind === 214 && expr.operator === 40 && + expr.kind === 216 && expr.operator === 40 && expr.operand.kind === 8; } function isBigIntLiteralExpression(expr) { return expr.kind === 9 || - expr.kind === 214 && expr.operator === 40 && + expr.kind === 216 && expr.operator === 40 && expr.operand.kind === 9; } function isSimpleLiteralEnumReference(expr) { @@ -67474,7 +70020,7 @@ var ts; if (initializer) { var isInvalidInitializer = !(isStringOrNumberLiteralExpression(initializer) || isSimpleLiteralEnumReference(initializer) || - initializer.kind === 109 || initializer.kind === 94 || + initializer.kind === 110 || initializer.kind === 95 || isBigIntLiteralExpression(initializer)); var isConstOrReadonly = ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node); if (isConstOrReadonly && !node.type) { @@ -67491,7 +70037,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 238 && node.parent.parent.kind !== 239) { + if (node.parent.parent.kind !== 240 && node.parent.parent.kind !== 241) { if (node.flags & 8388608) { checkAmbientInitializer(node); } @@ -67504,7 +70050,7 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 232 || !node.type || node.initializer || node.flags & 8388608)) { + if (node.exclamationToken && (node.parent.parent.kind !== 234 || !node.type || node.initializer || node.flags & 8388608)) { var message = node.initializer ? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions : !node.type @@ -67521,7 +70067,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkESModuleMarker(name) { - if (name.kind === 78) { + if (name.kind === 79) { if (ts.idText(name) === "__esModule") { return grammarErrorOnNodeSkippedOn("noEmit", name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules); } @@ -67538,8 +70084,8 @@ var ts; return false; } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 78) { - if (name.originalKeywordKind === 118) { + if (name.kind === 79) { + if (name.originalKeywordKind === 119) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -67566,15 +70112,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 234: - case 235: case 236: - case 243: case 237: case 238: + case 245: case 239: + case 240: + case 241: return false; - case 245: + case 247: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -67592,12 +70138,12 @@ var ts; function checkGrammarMetaProperty(node) { var escapedText = node.name.escapedText; switch (node.keywordToken) { - case 102: + case 103: 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 99: + case 100: 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"); } @@ -67659,14 +70205,14 @@ var ts; if (ts.isStringLiteral(node.name) && node.name.text === "constructor") { return grammarErrorOnNode(node.name, ts.Diagnostics.Classes_may_not_have_a_field_named_constructor); } - if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { + 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 && 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 === 253) { + else if (node.parent.kind === 255) { 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; } @@ -67674,7 +70220,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 177) { + else if (node.parent.kind === 179) { if (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)) { return true; } @@ -67696,13 +70242,13 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 253 || - node.kind === 254 || + if (node.kind === 255 || + node.kind === 256 || + node.kind === 263 || + node.kind === 262 || + node.kind === 269 || + node.kind === 268 || node.kind === 261 || - node.kind === 260 || - node.kind === 267 || - node.kind === 266 || - node.kind === 259 || ts.hasSyntacticModifier(node, 2 | 1 | 512)) { return false; } @@ -67711,7 +70257,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 === 232) { + if (ts.isDeclaration(decl) || decl.kind === 234) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -67728,7 +70274,7 @@ var ts; if (!links.hasReportedStatementInAmbientContext && (ts.isFunctionLike(node.parent) || ts.isAccessor(node.parent))) { return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } - if (node.parent.kind === 230 || node.parent.kind === 257 || node.parent.kind === 297) { + if (node.parent.kind === 232 || node.parent.kind === 259 || node.parent.kind === 299) { var links_2 = getNodeLinks(node.parent); if (!links_2.hasReportedStatementInAmbientContext) { return links_2.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts); @@ -67745,10 +70291,10 @@ var ts; if (languageVersion >= 1) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 191)) { + else if (ts.isChildOfNodeWithKind(node, 193)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 291)) { + else if (ts.isChildOfNodeWithKind(node, 293)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { @@ -67843,7 +70389,7 @@ var ts; } } function findBestTypeForObjectLiteral(source, unionTarget) { - if (ts.getObjectFlags(source) & 128 && forEachType(unionTarget, isArrayLikeType)) { + if (ts.getObjectFlags(source) & 128 && someType(unionTarget, isArrayLikeType)) { return ts.find(unionTarget.types, function (t) { return !isArrayLikeType(t); }); } } @@ -67890,6 +70436,10 @@ var ts; } function findMatchingDiscriminantType(source, target, isRelatedTo, skipPartial) { if (target.flags & 1048576 && source.flags & (2097152 | 524288)) { + var match = getMatchingUnionConstituentForType(target, source); + if (match) { + return match; + } var sourceProperties = getPropertiesOfType(source); if (sourceProperties) { var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target); @@ -67906,31 +70456,18 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 251 && declaration.kind !== 165) || + return (declaration.kind !== 253 && declaration.kind !== 167) || !!declaration.body; } function isDeclarationNameOrImportPropertyName(name) { switch (name.parent.kind) { - case 265: - case 270: + case 267: + case 272: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); } } - function isSomeImportDeclaration(decl) { - switch (decl.kind) { - case 262: - case 260: - case 263: - case 265: - return true; - case 78: - return decl.parent.kind === 265; - default: - return false; - } - } var JsxNames; (function (JsxNames) { JsxNames.JSX = "JSX"; @@ -67961,7 +70498,6 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var isTypeNodeOrTypeParameterDeclaration = ts.or(ts.isTypeNode, ts.isTypeParameterDeclaration); function visitNode(node, visitor, test, lift) { if (node === undefined || visitor === undefined) { return node; @@ -68116,6 +70652,21 @@ var ts; return updated; } ts.visitFunctionBody = visitFunctionBody; + function visitIterationBody(body, visitor, context) { + context.startBlockScope(); + var updated = visitNode(body, visitor, ts.isStatement, context.factory.liftToBlock); + var declarations = context.endBlockScope(); + if (ts.some(declarations)) { + if (ts.isBlock(updated)) { + declarations.push.apply(declarations, updated.statements); + return context.factory.updateBlock(updated, declarations); + } + declarations.push(updated); + return context.factory.createBlock(declarations); + } + return updated; + } + ts.visitIterationBody = visitIterationBody; function visitEachChild(node, visitor, context, nodesVisitor, tokenVisitor, nodeVisitor) { if (nodesVisitor === void 0) { nodesVisitor = visitNodes; } if (nodeVisitor === void 0) { nodeVisitor = visitNode; } @@ -68123,282 +70674,416 @@ var ts; return undefined; } var kind = node.kind; - if ((kind > 0 && kind <= 156) || kind === 187) { + if ((kind > 0 && kind <= 158) || kind === 189) { return node; } var factory = context.factory; switch (kind) { - case 78: - return factory.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration)); - case 157: - return factory.updateQualifiedName(node, nodeVisitor(node.left, visitor, ts.isEntityName), nodeVisitor(node.right, visitor, ts.isIdentifier)); - case 158: - return factory.updateComputedPropertyName(node, nodeVisitor(node.expression, visitor, ts.isExpression)); + case 79: + ts.Debug.type(node); + return factory.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNodeOrTypeParameterDeclaration)); case 159: - return factory.updateTypeParameterDeclaration(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.constraint, visitor, ts.isTypeNode), nodeVisitor(node.default, visitor, ts.isTypeNode)); + ts.Debug.type(node); + return factory.updateQualifiedName(node, nodeVisitor(node.left, visitor, ts.isEntityName), nodeVisitor(node.right, visitor, ts.isIdentifier)); case 160: - return factory.updateParameterDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isToken), nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); + ts.Debug.type(node); + return factory.updateComputedPropertyName(node, nodeVisitor(node.expression, visitor, ts.isExpression)); case 161: - return factory.updateDecorator(node, nodeVisitor(node.expression, visitor, ts.isExpression)); + ts.Debug.type(node); + return factory.updateTypeParameterDeclaration(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.constraint, visitor, ts.isTypeNode), nodeVisitor(node.default, visitor, ts.isTypeNode)); case 162: - return factory.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isToken), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode)); + ts.Debug.type(node); + return factory.updateParameterDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), 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 163: - return factory.updatePropertyDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken || node.exclamationToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); + ts.Debug.type(node); + return factory.updateDecorator(node, nodeVisitor(node.expression, visitor, ts.isExpression)); case 164: - return factory.updateMethodSignature(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); + 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 165: - return factory.updateMethodDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isToken), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); + ts.Debug.type(node); + return factory.updatePropertyDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken || node.exclamationToken, tokenVisitor, ts.isQuestionOrExclamationToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); case 166: - return factory.updateConstructorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context, nodeVisitor)); + 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 167: - return factory.updateGetAccessorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); + ts.Debug.type(node); + return factory.updateMethodDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), 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 168: - return factory.updateSetAccessorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context, nodeVisitor)); + ts.Debug.type(node); + return factory.updateConstructorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context, nodeVisitor)); case 169: - return factory.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); + ts.Debug.type(node); + return factory.updateGetAccessorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), 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 170: - return factory.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); + ts.Debug.type(node); + return factory.updateSetAccessorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context, nodeVisitor)); case 171: - return factory.updateIndexSignature(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); + 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 172: - return factory.updateTypePredicateNode(node, nodeVisitor(node.assertsModifier, visitor), nodeVisitor(node.parameterName, visitor), nodeVisitor(node.type, visitor, ts.isTypeNode)); + 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 173: - return factory.updateTypeReferenceNode(node, nodeVisitor(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); + ts.Debug.type(node); + return factory.updateIndexSignature(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); case 174: - return factory.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); + 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 175: - 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)); + ts.Debug.type(node); + return factory.updateTypeReferenceNode(node, nodeVisitor(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); case 176: - return factory.updateTypeQueryNode(node, nodeVisitor(node.exprName, visitor, ts.isEntityName)); + 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 177: - return factory.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); + 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 178: - return factory.updateArrayTypeNode(node, nodeVisitor(node.elementType, visitor, ts.isTypeNode)); + ts.Debug.type(node); + return factory.updateTypeQueryNode(node, nodeVisitor(node.exprName, visitor, ts.isEntityName)); case 179: - return factory.updateTupleTypeNode(node, nodesVisitor(node.elements, visitor, ts.isTypeNode)); + ts.Debug.type(node); + return factory.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); case 180: - return factory.updateOptionalTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); + ts.Debug.type(node); + return factory.updateArrayTypeNode(node, nodeVisitor(node.elementType, visitor, ts.isTypeNode)); case 181: - return factory.updateRestTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); + ts.Debug.type(node); + return factory.updateTupleTypeNode(node, nodesVisitor(node.elements, visitor, ts.isTypeNode)); case 182: - return factory.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); + ts.Debug.type(node); + return factory.updateOptionalTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); case 183: - return factory.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); + ts.Debug.type(node); + return factory.updateRestTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); case 184: - 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)); + ts.Debug.type(node); + return factory.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); case 185: + ts.Debug.type(node); + return factory.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); + case 186: + 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 187: + ts.Debug.type(node); return factory.updateInferTypeNode(node, nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 195: + case 197: + ts.Debug.type(node); return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); - case 192: - return factory.updateNamedTupleMember(node, visitNode(node.dotDotDotToken, visitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode)); - case 186: - return factory.updateParenthesizedType(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); + case 194: + 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 188: - return factory.updateTypeOperatorNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 189: - return factory.updateIndexedAccessTypeNode(node, nodeVisitor(node.objectType, visitor, ts.isTypeNode), nodeVisitor(node.indexType, visitor, ts.isTypeNode)); + ts.Debug.type(node); + return factory.updateParenthesizedType(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); case 190: - return factory.updateMappedTypeNode(node, nodeVisitor(node.readonlyToken, tokenVisitor, ts.isToken), nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration), nodeVisitor(node.nameType, visitor, ts.isTypeNode), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode)); + ts.Debug.type(node); + return factory.updateTypeOperatorNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); case 191: - return factory.updateLiteralTypeNode(node, nodeVisitor(node.literal, visitor, ts.isExpression)); + ts.Debug.type(node); + return factory.updateIndexedAccessTypeNode(node, nodeVisitor(node.objectType, visitor, ts.isTypeNode), nodeVisitor(node.indexType, visitor, ts.isTypeNode)); + case 192: + 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)); case 193: + ts.Debug.type(node); + return factory.updateLiteralTypeNode(node, nodeVisitor(node.literal, visitor, ts.isExpression)); + case 195: + ts.Debug.type(node); return factory.updateTemplateLiteralType(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateLiteralTypeSpan)); - case 194: - return factory.updateTemplateLiteralTypeSpan(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); case 196: - return factory.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 197: - return factory.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); + ts.Debug.type(node); + return factory.updateTemplateLiteralTypeSpan(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); case 198: - return factory.updateBindingElement(node, nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isToken), nodeVisitor(node.propertyName, visitor, ts.isPropertyName), nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.initializer, visitor, ts.isExpression)); + ts.Debug.type(node); + return factory.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); case 199: - return factory.updateArrayLiteralExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression)); + ts.Debug.type(node); + return factory.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); case 200: - return factory.updateObjectLiteralExpression(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); + 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)); case 201: + ts.Debug.type(node); + return factory.updateArrayLiteralExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression)); + case 202: + ts.Debug.type(node); + return factory.updateObjectLiteralExpression(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); + case 203: if (node.flags & 32) { - return factory.updatePropertyAccessChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isToken), nodeVisitor(node.name, visitor, ts.isIdentifier)); + 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)); } - return factory.updatePropertyAccessExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.name, visitor, ts.isIdentifierOrPrivateIdentifier)); - case 202: + ts.Debug.type(node); + return factory.updatePropertyAccessExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.name, visitor, ts.isMemberName)); + case 204: if (node.flags & 32) { - return factory.updateElementAccessChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isToken), nodeVisitor(node.argumentExpression, visitor, ts.isExpression)); + 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 203: + case 205: if (node.flags & 32) { - return factory.updateCallChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); + 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 204: - return factory.updateNewExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 205: - return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), nodeVisitor(node.template, visitor, ts.isTemplateLiteral)); case 206: - return factory.updateTypeAssertion(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.expression, visitor, ts.isExpression)); + 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 207: - return factory.updateParenthesizedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); + 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 208: - return factory.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isToken), 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)); + ts.Debug.type(node); + return factory.updateTypeAssertion(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.expression, visitor, ts.isExpression)); case 209: - 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.isToken), visitFunctionBody(node.body, visitor, context, nodeVisitor)); + ts.Debug.type(node); + return factory.updateParenthesizedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); case 210: - return factory.updateDeleteExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); + 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 211: - return factory.updateTypeOfExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); + 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 212: - return factory.updateVoidExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); + ts.Debug.type(node); + return factory.updateDeleteExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); case 213: - return factory.updateAwaitExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); + ts.Debug.type(node); + return factory.updateTypeOfExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); case 214: - return factory.updatePrefixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression)); + ts.Debug.type(node); + return factory.updateVoidExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); case 215: - return factory.updatePostfixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression)); + ts.Debug.type(node); + return factory.updateAwaitExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); case 216: - return factory.updateBinaryExpression(node, nodeVisitor(node.left, visitor, ts.isExpression), nodeVisitor(node.operatorToken, tokenVisitor, ts.isToken), nodeVisitor(node.right, visitor, ts.isExpression)); + ts.Debug.type(node); + return factory.updatePrefixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression)); case 217: - return factory.updateConditionalExpression(node, nodeVisitor(node.condition, visitor, ts.isExpression), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.whenTrue, visitor, ts.isExpression), nodeVisitor(node.colonToken, tokenVisitor, ts.isToken), nodeVisitor(node.whenFalse, visitor, ts.isExpression)); + ts.Debug.type(node); + return factory.updatePostfixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression)); case 218: - return factory.updateTemplateExpression(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); + 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 219: - return factory.updateYieldExpression(node, nodeVisitor(node.asteriskToken, tokenVisitor, ts.isToken), nodeVisitor(node.expression, visitor, ts.isExpression)); + 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 220: - return factory.updateSpreadElement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); + ts.Debug.type(node); + return factory.updateTemplateExpression(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); case 221: - return factory.updateClassExpression(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), 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.isClassElement)); + ts.Debug.type(node); + return factory.updateYieldExpression(node, nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.expression, visitor, ts.isExpression)); + case 222: + ts.Debug.type(node); + return factory.updateSpreadElement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); case 223: + ts.Debug.type(node); + return factory.updateClassExpression(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), 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.isClassElement)); + case 225: + ts.Debug.type(node); return factory.updateExpressionWithTypeArguments(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 224: + case 226: + ts.Debug.type(node); return factory.updateAsExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 225: + case 227: if (node.flags & 32) { + 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 226: - return factory.updateMetaProperty(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); case 228: - return factory.updateTemplateSpan(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); + ts.Debug.type(node); + return factory.updateMetaProperty(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); case 230: - return factory.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); + ts.Debug.type(node); + return factory.updateTemplateSpan(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); case 232: - return factory.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 233: - return factory.updateExpressionStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); + ts.Debug.type(node); + return factory.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); case 234: - 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)); + ts.Debug.type(node); + return factory.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.declarationList, visitor, ts.isVariableDeclarationList)); case 235: - return factory.updateDoStatement(node, nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock), nodeVisitor(node.expression, visitor, ts.isExpression)); + ts.Debug.type(node); + return factory.updateExpressionStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); case 236: - return factory.updateWhileStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); + 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 237: - return factory.updateForStatement(node, nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.condition, visitor, ts.isExpression), nodeVisitor(node.incrementor, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); + ts.Debug.type(node); + return factory.updateDoStatement(node, visitIterationBody(node.statement, visitor, context), nodeVisitor(node.expression, visitor, ts.isExpression)); case 238: - return factory.updateForInStatement(node, nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); + ts.Debug.type(node); + return factory.updateWhileStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); case 239: - return factory.updateForOfStatement(node, nodeVisitor(node.awaitModifier, tokenVisitor, ts.isToken), nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); + 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 240: - return factory.updateContinueStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier)); + 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 241: - return factory.updateBreakStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier)); + 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 242: - return factory.updateReturnStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); + ts.Debug.type(node); + return factory.updateContinueStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier)); case 243: - return factory.updateWithStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); + ts.Debug.type(node); + return factory.updateBreakStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier)); case 244: - return factory.updateSwitchStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.caseBlock, visitor, ts.isCaseBlock)); + ts.Debug.type(node); + return factory.updateReturnStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); case 245: - return factory.updateLabeledStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); + ts.Debug.type(node); + return factory.updateWithStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); case 246: - return factory.updateThrowStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); + ts.Debug.type(node); + return factory.updateSwitchStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.caseBlock, visitor, ts.isCaseBlock)); case 247: - return factory.updateTryStatement(node, nodeVisitor(node.tryBlock, visitor, ts.isBlock), nodeVisitor(node.catchClause, visitor, ts.isCatchClause), nodeVisitor(node.finallyBlock, visitor, ts.isBlock)); + ts.Debug.type(node); + return factory.updateLabeledStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); + case 248: + ts.Debug.type(node); + return factory.updateThrowStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); case 249: - return factory.updateVariableDeclaration(node, nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.exclamationToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 250: - return factory.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); + 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 251: - return factory.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isToken), 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)); + 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 252: - return factory.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), 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.isClassElement)); + ts.Debug.type(node); + return factory.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); case 253: - return factory.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), 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)); + ts.Debug.type(node); + return factory.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), 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 254: - return factory.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); + ts.Debug.type(node); + return factory.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), 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.isClassElement)); case 255: - return factory.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); + ts.Debug.type(node); + return factory.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), 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 256: - return factory.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.body, visitor, ts.isModuleBody)); + ts.Debug.type(node); + return factory.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), 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 257: - return factory.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); + ts.Debug.type(node); + return factory.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); case 258: - return factory.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); + ts.Debug.type(node); + return factory.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isModuleName), nodeVisitor(node.body, visitor, ts.isModuleBody)); case 259: - return factory.updateNamespaceExportDeclaration(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); + ts.Debug.type(node); + return factory.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); case 260: - return factory.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.moduleReference, visitor, ts.isModuleReference)); + ts.Debug.type(node); + return factory.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); case 261: - return factory.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.importClause, visitor, ts.isImportClause), nodeVisitor(node.moduleSpecifier, visitor, ts.isExpression)); + ts.Debug.type(node); + return factory.updateNamespaceExportDeclaration(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); case 262: - return factory.updateImportClause(node, node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.namedBindings, visitor, ts.isNamedImportBindings)); + ts.Debug.type(node); + return factory.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.moduleReference, visitor, ts.isModuleReference)); case 263: + ts.Debug.type(node); + return factory.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.importClause, visitor, ts.isImportClause), nodeVisitor(node.moduleSpecifier, visitor, ts.isExpression)); + case 264: + ts.Debug.type(node); + return factory.updateImportClause(node, node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.namedBindings, visitor, ts.isNamedImportBindings)); + case 265: + ts.Debug.type(node); return factory.updateNamespaceImport(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 269: + case 271: + ts.Debug.type(node); return factory.updateNamespaceExport(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 264: + case 266: + ts.Debug.type(node); return factory.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 265: + case 267: + ts.Debug.type(node); return factory.updateImportSpecifier(node, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 266: + case 268: + ts.Debug.type(node); return factory.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 267: + case 269: + ts.Debug.type(node); return factory.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), node.isTypeOnly, nodeVisitor(node.exportClause, visitor, ts.isNamedExportBindings), nodeVisitor(node.moduleSpecifier, visitor, ts.isExpression)); - case 268: - return factory.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); case 270: - return factory.updateExportSpecifier(node, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier)); + ts.Debug.type(node); + return factory.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); case 272: + ts.Debug.type(node); + return factory.updateExportSpecifier(node, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier)); + case 274: + ts.Debug.type(node); return factory.updateExternalModuleReference(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 273: + case 275: + 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 274: + case 276: + 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 275: + case 277: + 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 276: + case 278: + ts.Debug.type(node); return factory.updateJsxClosingElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 277: + case 279: + 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 280: + case 282: + ts.Debug.type(node); return factory.updateJsxAttribute(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 281: + case 283: + ts.Debug.type(node); return factory.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 282: + case 284: + ts.Debug.type(node); return factory.updateJsxSpreadAttribute(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 283: + case 285: + ts.Debug.type(node); return factory.updateJsxExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 284: + case 286: + ts.Debug.type(node); return factory.updateCaseClause(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 285: + case 287: + ts.Debug.type(node); return factory.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 286: + case 288: + ts.Debug.type(node); return factory.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 287: + case 289: + ts.Debug.type(node); return factory.updateCatchClause(node, nodeVisitor(node.variableDeclaration, visitor, ts.isVariableDeclaration), nodeVisitor(node.block, visitor, ts.isBlock)); - case 288: + case 290: + ts.Debug.type(node); return factory.updatePropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 289: + case 291: + ts.Debug.type(node); return factory.updateShorthandPropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 290: + case 292: + ts.Debug.type(node); return factory.updateSpreadAssignment(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 291: + case 293: + ts.Debug.type(node); return factory.updateEnumMember(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 297: + case 299: + ts.Debug.type(node); return factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context)); - case 336: + case 344: + ts.Debug.type(node); return factory.updatePartiallyEmittedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 337: + case 345: + ts.Debug.type(node); return factory.updateCommaListExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: return node; @@ -68422,6 +71107,7 @@ var ts; var sourcesContent; var names = []; var nameToNameIndexMap; + var mappingCharCodes = []; var mappings = ""; var lastGeneratedLine = 0; var lastGeneratedCharacter = 0; @@ -68588,6 +71274,12 @@ var ts; || lastSourceCharacter !== pendingSourceCharacter || lastNameIndex !== pendingNameIndex; } + function appendMappingCharCode(charCode) { + mappingCharCodes.push(charCode); + if (mappingCharCodes.length >= 1024) { + flushMappingBuffer(); + } + } function commitPendingMapping() { if (!hasPending || !shouldCommitMapping()) { return; @@ -68595,36 +71287,43 @@ var ts; enter(); if (lastGeneratedLine < pendingGeneratedLine) { do { - mappings += ";"; + appendMappingCharCode(59); lastGeneratedLine++; - lastGeneratedCharacter = 0; } while (lastGeneratedLine < pendingGeneratedLine); + lastGeneratedCharacter = 0; } else { ts.Debug.assertEqual(lastGeneratedLine, pendingGeneratedLine, "generatedLine cannot backtrack"); if (hasLast) { - mappings += ","; + appendMappingCharCode(44); } } - mappings += base64VLQFormatEncode(pendingGeneratedCharacter - lastGeneratedCharacter); + appendBase64VLQ(pendingGeneratedCharacter - lastGeneratedCharacter); lastGeneratedCharacter = pendingGeneratedCharacter; if (hasPendingSource) { - mappings += base64VLQFormatEncode(pendingSourceIndex - lastSourceIndex); + appendBase64VLQ(pendingSourceIndex - lastSourceIndex); lastSourceIndex = pendingSourceIndex; - mappings += base64VLQFormatEncode(pendingSourceLine - lastSourceLine); + appendBase64VLQ(pendingSourceLine - lastSourceLine); lastSourceLine = pendingSourceLine; - mappings += base64VLQFormatEncode(pendingSourceCharacter - lastSourceCharacter); + appendBase64VLQ(pendingSourceCharacter - lastSourceCharacter); lastSourceCharacter = pendingSourceCharacter; if (hasPendingName) { - mappings += base64VLQFormatEncode(pendingNameIndex - lastNameIndex); + appendBase64VLQ(pendingNameIndex - lastNameIndex); lastNameIndex = pendingNameIndex; } } hasLast = true; exit(); } + function flushMappingBuffer() { + if (mappingCharCodes.length > 0) { + mappings += String.fromCharCode.apply(undefined, mappingCharCodes); + mappingCharCodes.length = 0; + } + } function toJSON() { commitPendingMapping(); + flushMappingBuffer(); return { version: 3, file: file, @@ -68635,9 +71334,25 @@ var ts; sourcesContent: sourcesContent, }; } + function appendBase64VLQ(inValue) { + if (inValue < 0) { + inValue = ((-inValue) << 1) + 1; + } + else { + inValue = inValue << 1; + } + do { + var currentDigit = inValue & 31; + inValue = inValue >> 5; + if (inValue > 0) { + currentDigit = currentDigit | 32; + } + appendMappingCharCode(base64FormatEncode(currentDigit)); + } while (inValue > 0); + } } ts.createSourceMapGenerator = createSourceMapGenerator; - var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)\s*$/; + var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)$/; var whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/; function getLineInfo(text, lineStarts) { return { @@ -68651,7 +71366,7 @@ var ts; var line = lineInfo.getLineText(index); var comment = sourceMapCommentRegExp.exec(line); if (comment) { - return comment[1]; + return ts.trimStringEnd(comment[1]); } else if (!line.match(whitespaceOrMapCommentRegExp)) { break; @@ -68845,24 +71560,6 @@ var ts; ch === 47 ? 63 : -1; } - function base64VLQFormatEncode(inValue) { - if (inValue < 0) { - inValue = ((-inValue) << 1) + 1; - } - else { - inValue = inValue << 1; - } - var encodedStr = ""; - do { - var currentDigit = inValue & 31; - inValue = inValue >> 5; - if (inValue > 0) { - currentDigit = currentDigit | 32; - } - encodedStr = encodedStr + String.fromCharCode(base64FormatEncode(currentDigit)); - } while (inValue > 0); - return encodedStr; - } function isSourceMappedPosition(value) { return value.sourceIndex !== undefined && value.sourcePosition !== undefined; @@ -69021,7 +71718,7 @@ var ts; function chainBundle(context, transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 297 ? transformSourceFile(node) : transformBundle(node); + return node.kind === 299 ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return context.factory.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -69070,7 +71767,7 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 261: + case 263: externalImports.push(node); if (!hasImportStar && getImportNeedsImportStarHelper(node)) { hasImportStar = true; @@ -69079,12 +71776,12 @@ var ts; hasImportDefault = true; } break; - case 260: - if (node.moduleReference.kind === 272) { + case 262: + if (node.moduleReference.kind === 274) { externalImports.push(node); } break; - case 267: + case 269: if (node.moduleSpecifier) { if (!node.exportClause) { externalImports.push(node); @@ -69110,12 +71807,12 @@ var ts; addExportedNamesForExportDeclaration(node); } break; - case 266: + case 268: if (node.isExportEquals && !exportEquals) { exportEquals = node; } break; - case 232: + case 234: if (ts.hasSyntacticModifier(node, 1)) { for (var _b = 0, _c = node.declarationList.declarations; _b < _c.length; _b++) { var decl = _c[_b]; @@ -69123,7 +71820,7 @@ var ts; } } break; - case 251: + case 253: if (ts.hasSyntacticModifier(node, 1)) { if (ts.hasSyntacticModifier(node, 512)) { if (!hasExportDefault) { @@ -69141,7 +71838,7 @@ var ts; } } break; - case 252: + case 254: if (ts.hasSyntacticModifier(node, 1)) { if (ts.hasSyntacticModifier(node, 512)) { if (!hasExportDefault) { @@ -69222,32 +71919,31 @@ var ts; } ts.isSimpleCopiableExpression = isSimpleCopiableExpression; function isSimpleInlineableExpression(expression) { - return !ts.isIdentifier(expression) && isSimpleCopiableExpression(expression) || - ts.isWellKnownSymbolSyntactically(expression); + return !ts.isIdentifier(expression) && isSimpleCopiableExpression(expression); } ts.isSimpleInlineableExpression = isSimpleInlineableExpression; function isCompoundAssignment(kind) { - return kind >= 63 - && kind <= 77; + return kind >= 64 + && kind <= 78; } ts.isCompoundAssignment = isCompoundAssignment; function getNonAssignmentOperatorForCompoundAssignment(kind) { switch (kind) { - case 63: return 39; - case 64: return 40; - case 65: return 41; - case 66: return 42; - case 67: return 43; - case 68: return 44; - case 69: return 47; - case 70: return 48; - case 71: return 49; - case 72: return 50; - case 73: return 51; - case 77: return 52; - case 74: return 56; - case 75: return 55; - case 76: return 60; + case 64: return 39; + case 65: return 40; + case 66: return 41; + case 67: return 42; + case 68: return 43; + case 69: return 44; + case 70: return 47; + case 71: return 48; + case 72: return 49; + case 73: return 50; + case 74: return 51; + case 78: return 52; + case 75: return 56; + case 76: return 55; + case 77: return 60; } } ts.getNonAssignmentOperatorForCompoundAssignment = getNonAssignmentOperatorForCompoundAssignment; @@ -69280,10 +71976,14 @@ var ts; && ts.hasStaticModifier(member) === isStatic; } function isInitializedProperty(member) { - return member.kind === 163 + return member.kind === 165 && member.initializer !== undefined; } ts.isInitializedProperty = isInitializedProperty; + function isNonStaticMethodOrAccessorWithPrivateName(member) { + return !ts.hasStaticModifier(member) && ts.isMethodOrAccessor(member) && ts.isPrivateIdentifier(member.name); + } + ts.isNonStaticMethodOrAccessorWithPrivateName = isNonStaticMethodOrAccessorWithPrivateName; })(ts || (ts = {})); var ts; (function (ts) { @@ -69485,8 +72185,8 @@ var ts; if (!ts.getRestIndicatorOfBindingOrAssignmentElement(element)) { var propertyName = ts.getPropertyNameOfBindingOrAssignmentElement(element); if (flattenContext.level >= 1 - && !(element.transformFlags & (8192 | 16384)) - && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (8192 | 16384)) + && !(element.transformFlags & (16384 | 32768)) + && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (16384 | 32768)) && !ts.isComputedPropertyName(propertyName)) { bindingElements = ts.append(bindingElements, ts.visitNode(element, flattenContext.visitor)); } @@ -69533,7 +72233,7 @@ var ts; for (var i = 0; i < numElements; i++) { var element = elements[i]; if (flattenContext.level >= 1) { - if (element.transformFlags & 16384 || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) { + if (element.transformFlags & 32768 || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) { flattenContext.hasTransformedPriorElement = true; var temp = flattenContext.context.factory.createTempVariable(undefined); if (flattenContext.hoistTempVariables) { @@ -69707,8 +72407,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(201); - context.enableSubstitution(202); + context.enableSubstitution(203); + context.enableSubstitution(204); var currentSourceFile; var currentNamespace; var currentNamespaceContainerName; @@ -69721,14 +72421,14 @@ var ts; var applicableSubstitutions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 298) { + if (node.kind === 300) { 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 === 300) { + if (prepend.kind === 302) { return ts.createUnparsedSourceFile(prepend, "js"); } return prepend; @@ -69761,16 +72461,16 @@ var ts; } function onBeforeVisitNode(node) { switch (node.kind) { - case 297: - case 258: - case 257: - case 230: + case 299: + case 260: + case 259: + case 232: currentLexicalScope = node; currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 252: - case 251: + case 254: + case 253: if (ts.hasSyntacticModifier(node, 2)) { break; } @@ -69778,7 +72478,7 @@ var ts; recordEmittedDeclarationInScope(node); } else { - ts.Debug.assert(node.kind === 252 || ts.hasSyntacticModifier(node, 512)); + ts.Debug.assert(node.kind === 254 || ts.hasSyntacticModifier(node, 512)); } if (ts.isClassDeclaration(node)) { currentNameScope = node; @@ -69800,10 +72500,10 @@ var ts; } function sourceElementVisitorWorker(node) { switch (node.kind) { - case 261: - case 260: - case 266: - case 267: + case 263: + case 262: + case 268: + case 269: return visitElidableStatement(node); default: return visitorWorker(node); @@ -69818,13 +72518,13 @@ var ts; return node; } switch (node.kind) { - case 261: + case 263: return visitImportDeclaration(node); - case 260: + case 262: return visitImportEqualsDeclaration(node); - case 266: + case 268: return visitExportAssignment(node); - case 267: + case 269: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -69834,11 +72534,11 @@ var ts; return saveStateAndInvoke(node, namespaceElementVisitorWorker); } function namespaceElementVisitorWorker(node) { - if (node.kind === 267 || - node.kind === 261 || - node.kind === 262 || - (node.kind === 260 && - node.moduleReference.kind === 272)) { + if (node.kind === 269 || + node.kind === 263 || + node.kind === 264 || + (node.kind === 262 && + node.moduleReference.kind === 274)) { return undefined; } else if (node.transformFlags & 1 || ts.hasSyntacticModifier(node, 1)) { @@ -69851,26 +72551,26 @@ var ts; } function classElementVisitorWorker(node) { switch (node.kind) { - case 166: + case 168: return visitConstructor(node); - case 163: + case 165: return visitPropertyDeclaration(node); - case 171: + case 173: + case 169: + case 170: case 167: - case 168: - case 165: return visitorWorker(node); - case 229: + case 231: return node; default: return ts.Debug.failBadSyntaxKind(node); } } function modifierVisitor(node) { - if (ts.modifierToFlag(node.kind) & 2270) { + if (ts.modifierToFlag(node.kind) & 18654) { return undefined; } - else if (currentNamespace && node.kind === 92) { + else if (currentNamespace && node.kind === 93) { return undefined; } return node; @@ -69880,104 +72580,104 @@ var ts; return factory.createNotEmittedStatement(node); } switch (node.kind) { - case 92: - case 87: + case 93: + case 88: return currentNamespace ? undefined : node; - case 122: - case 120: + case 123: case 121: - case 125: - case 84: - case 133: - case 142: - case 178: - case 179: + case 122: + case 126: + case 85: + case 134: + case 143: case 180: case 181: - case 177: - case 172: - case 159: - case 128: - case 152: - case 131: - case 147: - case 144: - case 141: - case 113: - case 148: - case 175: - case 174: - case 176: - case 173: case 182: case 183: + case 179: + case 174: + case 161: + case 129: + case 153: + case 132: + case 148: + case 145: + case 142: + case 114: + case 149: + case 177: + case 176: + case 178: + case 175: case 184: + case 185: case 186: - case 187: case 188: case 189: case 190: case 191: - case 171: - case 161: - case 254: - return undefined; + case 192: + case 193: + case 173: case 163: + case 256: + return undefined; + case 165: return visitPropertyDeclaration(node); - case 259: + case 261: return undefined; - case 166: + case 168: return visitConstructor(node); - case 253: + case 255: return factory.createNotEmittedStatement(node); - case 252: + case 254: return visitClassDeclaration(node); - case 221: + case 223: return visitClassExpression(node); - case 286: + case 288: return visitHeritageClause(node); - case 223: + case 225: return visitExpressionWithTypeArguments(node); - case 165: - return visitMethodDeclaration(node); case 167: + return visitMethodDeclaration(node); + case 169: return visitGetAccessor(node); - case 168: + case 170: return visitSetAccessor(node); - case 251: + case 253: return visitFunctionDeclaration(node); - case 208: + case 210: return visitFunctionExpression(node); - case 209: + case 211: return visitArrowFunction(node); - case 160: + case 162: return visitParameter(node); - case 207: + case 209: return visitParenthesizedExpression(node); - case 206: - case 224: + case 208: + case 226: return visitAssertionExpression(node); - case 203: + case 205: return visitCallExpression(node); - case 204: + case 206: return visitNewExpression(node); - case 205: + case 207: return visitTaggedTemplateExpression(node); - case 225: + case 227: return visitNonNullExpression(node); - case 255: + case 257: return visitEnumDeclaration(node); - case 232: + case 234: return visitVariableStatement(node); - case 249: + case 251: return visitVariableDeclaration(node); - case 256: + case 258: return visitModuleDeclaration(node); - case 260: + case 262: return visitImportEqualsDeclaration(node); - case 274: + case 276: return visitJsxSelfClosingElement(node); - case 275: + case 277: return visitJsxJsxOpeningElement(node); default: return ts.visitEachChild(node, visitor, context); @@ -70007,7 +72707,7 @@ var ts; if (ts.some(staticProperties)) facts |= 1; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 103) + if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104) facts |= 64; if (shouldEmitDecorateCallForClass(node)) facts |= 2; @@ -70024,7 +72724,7 @@ var ts; return facts; } function hasTypeScriptClassSyntax(node) { - return !!(node.transformFlags & 2048); + return !!(node.transformFlags & 4096); } function isClassLikeDeclarationWithTypeScriptSyntax(node) { return ts.some(node.decorators) @@ -70189,12 +72889,12 @@ var ts; } function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 167: - case 168: + case 169: + case 170: return getAllDecoratorsOfAccessors(node, member); - case 165: + case 167: return getAllDecoratorsOfMethod(member); - case 163: + case 165: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -70273,7 +72973,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, true); var descriptor = languageVersion > 0 - ? member.kind === 163 + ? member.kind === 165 ? factory.createVoidZero() : factory.createNull() : undefined; @@ -70359,22 +73059,22 @@ var ts; } function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 165 - || kind === 167 - || kind === 168 - || kind === 163; + return kind === 167 + || kind === 169 + || kind === 170 + || kind === 165; } function shouldAddReturnTypeMetadata(node) { - return node.kind === 165; + return node.kind === 167; } function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 252: - case 221: + case 254: + case 223: return ts.getFirstConstructorWithBody(node) !== undefined; - case 165: case 167: - case 168: + case 169: + case 170: return true; } return false; @@ -70386,15 +73086,15 @@ var ts; } function serializeTypeOfNode(node) { switch (node.kind) { - case 163: - case 160: + case 165: + case 162: return serializeTypeNode(node.type); - case 168: - case 167: + case 170: + case 169: return serializeTypeNode(getAccessorTypeNode(node)); - case 252: - case 221: - case 165: + case 254: + case 223: + case 167: return factory.createIdentifier("Function"); default: return factory.createVoidZero(); @@ -70426,7 +73126,7 @@ var ts; return factory.createArrayLiteralExpression(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 167) { + if (container && node.kind === 169) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -70448,81 +73148,81 @@ var ts; return factory.createIdentifier("Object"); } switch (node.kind) { - case 113: - case 150: - case 141: + case 114: + case 151: + case 142: return factory.createVoidZero(); - case 186: + case 188: return serializeTypeNode(node.type); - case 174: - case 175: + case 176: + case 177: return factory.createIdentifier("Function"); - case 178: - case 179: + case 180: + case 181: return factory.createIdentifier("Array"); - case 172: - case 131: + case 174: + case 132: return factory.createIdentifier("Boolean"); - case 147: + case 148: return factory.createIdentifier("String"); - case 145: + case 146: return factory.createIdentifier("Object"); - case 191: + case 193: switch (node.literal.kind) { case 10: case 14: return factory.createIdentifier("String"); - case 214: + case 216: case 8: return factory.createIdentifier("Number"); case 9: return getGlobalBigIntNameWithFallback(); - case 109: - case 94: + case 110: + case 95: return factory.createIdentifier("Boolean"); - case 103: + case 104: return factory.createVoidZero(); default: return ts.Debug.failBadSyntaxKind(node.literal); } - case 144: + case 145: return factory.createIdentifier("Number"); - case 155: + case 156: return getGlobalBigIntNameWithFallback(); - case 148: + case 149: return languageVersion < 2 ? getGlobalSymbolNameWithFallback() : factory.createIdentifier("Symbol"); - case 173: + case 175: return serializeTypeReferenceNode(node); - case 183: - case 182: - return serializeTypeList(node.types); + case 185: case 184: + return serializeTypeList(node.types); + case 186: return serializeTypeList([node.trueType, node.falseType]); - case 188: - if (node.operator === 142) { + case 190: + if (node.operator === 143) { return serializeTypeNode(node.type); } break; - case 176: + case 178: + case 191: + case 192: + case 179: + case 129: + case 153: case 189: - case 190: - case 177: - case 128: - case 152: - case 187: - case 195: + case 197: + break; + case 306: + case 307: + case 311: + case 312: + case 313: break; - case 303: - case 304: case 308: case 309: case 310: - break; - case 305: - case 306: - case 307: return serializeTypeNode(node.type); default: return ts.Debug.failBadSyntaxKind(node); @@ -70533,13 +73233,13 @@ var ts; var serializedUnion; for (var _i = 0, types_24 = types; _i < types_24.length; _i++) { var typeNode = types_24[_i]; - while (typeNode.kind === 186) { + while (typeNode.kind === 188) { typeNode = typeNode.type; } - if (typeNode.kind === 141) { + if (typeNode.kind === 142) { continue; } - if (!strictNullChecks && (typeNode.kind === 191 && typeNode.literal.kind === 103 || typeNode.kind === 150)) { + if (!strictNullChecks && (typeNode.kind === 193 && typeNode.literal.kind === 104 || typeNode.kind === 151)) { continue; } var serializedIndividual = serializeTypeNode(typeNode); @@ -70601,11 +73301,11 @@ var ts; return factory.createLogicalAnd(factory.createStrictInequality(factory.createTypeOfExpression(left), factory.createStringLiteral("undefined")), right); } function serializeEntityNameAsExpressionFallback(node) { - if (node.kind === 78) { + if (node.kind === 79) { var copied = serializeEntityNameAsExpression(node); return createCheckedValue(copied, copied); } - if (node.left.kind === 78) { + if (node.left.kind === 79) { return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node)); } var left = serializeEntityNameAsExpressionFallback(node.left); @@ -70614,12 +73314,12 @@ var ts; } function serializeEntityNameAsExpression(node) { switch (node.kind) { - case 78: + case 79: var name = ts.setParent(ts.setTextRange(ts.parseNodeFactory.cloneNode(node), node), node.parent); name.original = undefined; ts.setParent(name, ts.getParseTreeNode(currentLexicalScope)); return name; - case 157: + case 159: return serializeQualifiedNameAsExpression(node); } } @@ -70665,7 +73365,7 @@ var ts; return ts.visitNode(name, visitor, ts.isPropertyName); } function visitHeritageClause(node) { - if (node.token === 116) { + if (node.token === 117) { return undefined; } return ts.visitEachChild(node, visitor, context); @@ -70854,8 +73554,7 @@ var ts; } function shouldEmitEnumDeclaration(node) { return !ts.isEnumConst(node) - || compilerOptions.preserveConstEnums - || compilerOptions.isolatedModules; + || ts.shouldPreserveConstEnums(compilerOptions); } function visitEnumDeclaration(node) { if (!shouldEmitEnumDeclaration(node)) { @@ -70931,7 +73630,7 @@ var ts; if (!node) { return true; } - return ts.isInstantiatedModule(node, !!compilerOptions.preserveConstEnums || !!compilerOptions.isolatedModules); + return ts.isInstantiatedModule(node, ts.shouldPreserveConstEnums(compilerOptions)); } function hasNamespaceQualifiedExportName(node) { return isExportOfNamespace(node) @@ -70964,11 +73663,11 @@ var ts; function addVarForEnumOrModuleDeclaration(statements, node) { var statement = factory.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), factory.createVariableDeclarationList([ factory.createVariableDeclaration(factory.getLocalName(node, false, true)) - ], currentLexicalScope.kind === 297 ? 0 : 1)); + ], currentLexicalScope.kind === 299 ? 0 : 1)); ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { - if (node.kind === 255) { + if (node.kind === 257) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -71034,7 +73733,7 @@ var ts; var statementsLocation; var blockLocation; if (node.body) { - if (node.body.kind === 257) { + if (node.body.kind === 259) { saveStateAndInvoke(node.body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = node.body.statements; blockLocation = node.body; @@ -71059,13 +73758,13 @@ var ts; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), true); ts.setTextRange(block, blockLocation); - if (!node.body || node.body.kind !== 257) { + if (!node.body || node.body.kind !== 259) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 256) { + if (moduleDeclaration.body.kind === 258) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -71093,7 +73792,7 @@ var ts; return (name || namedBindings) ? factory.updateImportClause(node, false, name, namedBindings) : undefined; } function visitNamedImportBindings(node) { - if (node.kind === 263) { + if (node.kind === 265) { return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } else { @@ -71228,29 +73927,29 @@ var ts; function enableSubstitutionForNonQualifiedEnumMembers() { if ((enabledSubstitutions & 8) === 0) { enabledSubstitutions |= 8; - context.enableSubstitution(78); + context.enableSubstitution(79); } } function enableSubstitutionForClassAliases() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; - context.enableSubstitution(78); + context.enableSubstitution(79); classAliases = []; } } function enableSubstitutionForNamespaceExports() { if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; - context.enableSubstitution(78); - context.enableSubstitution(289); - context.enableEmitNotification(256); + context.enableSubstitution(79); + context.enableSubstitution(291); + context.enableEmitNotification(258); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 256; + return ts.getOriginalNode(node).kind === 258; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 255; + return ts.getOriginalNode(node).kind === 257; } function onEmitNode(hint, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; @@ -71294,11 +73993,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 78: + case 79: return substituteExpressionIdentifier(node); - case 201: + case 203: return substitutePropertyAccessExpression(node); - case 202: + case 204: return substituteElementAccessExpression(node); } return node; @@ -71315,10 +74014,10 @@ var ts; if (declaration) { var classAlias = classAliases[declaration.id]; if (classAlias) { - var clone_1 = factory.cloneNode(classAlias); - ts.setSourceMapRange(clone_1, node); - ts.setCommentRange(clone_1, node); - return clone_1; + var clone_2 = factory.cloneNode(classAlias); + ts.setSourceMapRange(clone_2, node); + ts.setCommentRange(clone_2, node); + return clone_2; } } } @@ -71328,9 +74027,9 @@ var ts; function trySubstituteNamespaceExportedName(node) { if (enabledSubstitutions & applicableSubstitutions && !ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var container = resolver.getReferencedExportContainer(node, false); - if (container && container.kind !== 297) { - var substitute = (applicableSubstitutions & 2 && container.kind === 256) || - (applicableSubstitutions & 8 && container.kind === 255); + if (container && container.kind !== 299) { + var substitute = (applicableSubstitutions & 2 && container.kind === 258) || + (applicableSubstitutions & 8 && container.kind === 257); if (substitute) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(container), node), node); } @@ -71372,11 +74071,12 @@ var ts; var ts; (function (ts) { function transformClassFields(context) { - var factory = context.factory, hoistVariableDeclaration = context.hoistVariableDeclaration, endLexicalEnvironment = context.endLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment; + var factory = context.factory, hoistVariableDeclaration = context.hoistVariableDeclaration, endLexicalEnvironment = context.endLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, addBlockScopedVariable = context.addBlockScopedVariable; var resolver = context.getEmitResolver(); var compilerOptions = context.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); - var shouldTransformPrivateFields = languageVersion < 99; + var useDefineForClassFields = ts.getUseDefineForClassFields(compilerOptions); + var shouldTransformPrivateElements = languageVersion < 99; var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; var enabledSubstitutions; @@ -71389,7 +74089,7 @@ var ts; function transformSourceFile(node) { var options = context.getCompilerOptions(); if (node.isDeclarationFile - || options.useDefineForClassFields && options.target === 99) { + || useDefineForClassFields && options.target === 99) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -71397,65 +74097,65 @@ var ts; return visited; } function visitor(node) { - if (!(node.transformFlags & 4194304)) + if (!(node.transformFlags & 8388608)) return node; switch (node.kind) { - case 221: - case 252: + case 223: + case 254: return visitClassLike(node); - case 163: + case 165: return visitPropertyDeclaration(node); - case 232: + case 234: return visitVariableStatement(node); - case 201: + case 203: return visitPropertyAccessExpression(node); - case 214: + case 216: return visitPrefixUnaryExpression(node); - case 215: + case 217: return visitPostfixUnaryExpression(node, false); - case 203: + case 205: return visitCallExpression(node); - case 216: + case 218: return visitBinaryExpression(node); - case 79: + case 80: return visitPrivateIdentifier(node); - case 233: + case 235: return visitExpressionStatement(node); - case 237: + case 239: return visitForStatement(node); - case 205: + case 207: return visitTaggedTemplateExpression(node); } return ts.visitEachChild(node, visitor, context); } function visitorDestructuringTarget(node) { switch (node.kind) { - case 200: - case 199: + case 202: + case 201: return visitAssignmentPattern(node); default: return visitor(node); } } function visitPrivateIdentifier(node) { - if (!shouldTransformPrivateFields) { + if (!shouldTransformPrivateElements) { return node; } return ts.setOriginalNode(factory.createIdentifier(""), node); } function classElementVisitor(node) { switch (node.kind) { - case 166: + case 168: return undefined; + case 169: + case 170: case 167: - case 168: + return visitMethodOrAccessorDeclaration(node); case 165: - return ts.visitEachChild(node, classElementVisitor, context); - case 163: return visitPropertyDeclaration(node); - case 158: + case 160: return visitComputedPropertyName(node); - case 229: + case 231: return node; default: return visitor(node); @@ -71480,36 +74180,83 @@ var ts; } return node; } + function visitMethodOrAccessorDeclaration(node) { + ts.Debug.assert(!ts.some(node.decorators)); + if (!shouldTransformPrivateElements || !ts.isPrivateIdentifier(node.name)) { + return ts.visitEachChild(node, classElementVisitor, context); + } + var info = accessPrivateIdentifier(node.name); + ts.Debug.assert(info, "Undeclared private name for property declaration."); + if (!info.isValid) { + return node; + } + var functionName = getHoistedFunctionName(node); + if (functionName) { + getPendingExpressions().push(factory.createAssignment(functionName, factory.createFunctionExpression(ts.filter(node.modifiers, function (m) { return !ts.isStaticModifier(m); }), node.asteriskToken, functionName, undefined, ts.visitParameterList(node.parameters, classElementVisitor, context), undefined, ts.visitFunctionBody(node.body, classElementVisitor, context)))); + } + return undefined; + } + function getHoistedFunctionName(node) { + 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") { + return info.methodName; + } + if (info.kind === "a") { + if (ts.isGetAccessor(node)) { + return info.getterName; + } + if (ts.isSetAccessor(node)) { + return info.setterName; + } + } + } function visitPropertyDeclaration(node) { ts.Debug.assert(!ts.some(node.decorators)); - if (!shouldTransformPrivateFields && ts.isPrivateIdentifier(node.name)) { - return factory.updatePropertyDeclaration(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name, undefined, undefined, undefined); + if (ts.isPrivateIdentifier(node.name)) { + if (!shouldTransformPrivateElements) { + return factory.updatePropertyDeclaration(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name, undefined, undefined, undefined); + } + var info = accessPrivateIdentifier(node.name); + ts.Debug.assert(info, "Undeclared private name for property declaration."); + if (!info.isValid) { + return node; + } } - var expr = getPropertyNameExpressionIfNeeded(node.name, !!node.initializer || !!context.getCompilerOptions().useDefineForClassFields); + var expr = getPropertyNameExpressionIfNeeded(node.name, !!node.initializer || useDefineForClassFields); if (expr && !ts.isSimpleInlineableExpression(expr)) { getPendingExpressions().push(expr); } return undefined; } function createPrivateIdentifierAccess(info, receiver) { - receiver = ts.visitNode(receiver, visitor, ts.isExpression); - switch (info.placement) { - case 0: - return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(ts.nodeIsSynthesized(receiver) ? receiver : factory.cloneNode(receiver), info.weakMapName); - default: return ts.Debug.fail("Unexpected private identifier placement"); + return createPrivateIdentifierAccessHelper(info, ts.visitNode(receiver, visitor, ts.isExpression)); + } + function createPrivateIdentifierAccessHelper(info, receiver) { + ts.setCommentRange(receiver, ts.moveRangePos(receiver, -1)); + switch (info.kind) { + case "a": + return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.getterName); + case "m": + return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.methodName); + case "f": + return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.variableName); + default: + ts.Debug.assertNever(info, "Unknown private element type"); } } function visitPropertyAccessExpression(node) { - if (shouldTransformPrivateFields && ts.isPrivateIdentifier(node.name)) { + if (shouldTransformPrivateElements && ts.isPrivateIdentifier(node.name)) { var privateIdentifierInfo = accessPrivateIdentifier(node.name); if (privateIdentifierInfo) { - return ts.setOriginalNode(createPrivateIdentifierAccess(privateIdentifierInfo, node.expression), node); + return ts.setTextRange(ts.setOriginalNode(createPrivateIdentifierAccess(privateIdentifierInfo, node.expression), node), node); } } return ts.visitEachChild(node, visitor, context); } function visitPrefixUnaryExpression(node) { - if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { + if (shouldTransformPrivateElements && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { var operator = node.operator === 45 ? 39 : node.operator === 46 ? 40 : undefined; @@ -71518,13 +74265,13 @@ var ts; var receiver = ts.visitNode(node.operand.expression, visitor, ts.isExpression); var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression; var existingValue = factory.createPrefixUnaryExpression(39, createPrivateIdentifierAccess(info, readExpression)); - return ts.setOriginalNode(createPrivateIdentifierAssignment(info, initializeExpression || readExpression, factory.createBinaryExpression(existingValue, operator, factory.createNumericLiteral(1)), 62), node); + return ts.setOriginalNode(createPrivateIdentifierAssignment(info, initializeExpression || readExpression, factory.createBinaryExpression(existingValue, operator, factory.createNumericLiteral(1)), 63), node); } } return ts.visitEachChild(node, visitor, context); } function visitPostfixUnaryExpression(node, valueIsDiscarded) { - if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { + if (shouldTransformPrivateElements && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { var operator = node.operator === 45 ? 39 : node.operator === 46 ? 40 : undefined; @@ -71535,7 +74282,7 @@ var ts; var existingValue = factory.createPrefixUnaryExpression(39, createPrivateIdentifierAccess(info, readExpression)); var returnValue = valueIsDiscarded ? undefined : factory.createTempVariable(hoistVariableDeclaration); return ts.setOriginalNode(factory.inlineExpressions(ts.compact([ - createPrivateIdentifierAssignment(info, initializeExpression || readExpression, factory.createBinaryExpression(returnValue ? factory.createAssignment(returnValue, existingValue) : existingValue, operator, factory.createNumericLiteral(1)), 62), + createPrivateIdentifierAssignment(info, initializeExpression || readExpression, factory.createBinaryExpression(returnValue ? factory.createAssignment(returnValue, existingValue) : existingValue, operator, factory.createNumericLiteral(1)), 63), returnValue ])), node); } @@ -71544,7 +74291,7 @@ var ts; } function visitForStatement(node) { if (node.incrementor && ts.isPostfixUnaryExpression(node.incrementor)) { - return factory.updateForStatement(node, ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), visitPostfixUnaryExpression(node.incrementor, true), ts.visitNode(node.statement, visitor, ts.isStatement)); + return factory.updateForStatement(node, ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), visitPostfixUnaryExpression(node.incrementor, true), ts.visitIterationBody(node.statement, visitor, context)); } return ts.visitEachChild(node, visitor, context); } @@ -71564,21 +74311,24 @@ var ts; return { readExpression: readExpression, initializeExpression: initializeExpression }; } function visitCallExpression(node) { - if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.expression)) { + if (shouldTransformPrivateElements && ts.isPrivateIdentifierPropertyAccessExpression(node.expression)) { var _a = factory.createCallBinding(node.expression, hoistVariableDeclaration, languageVersion), thisArg = _a.thisArg, target = _a.target; + if (ts.isCallChain(node)) { + return factory.updateCallChain(node, factory.createPropertyAccessChain(ts.visitNode(target, visitor), node.questionDotToken, "call"), undefined, undefined, __spreadArray([ts.visitNode(thisArg, visitor, ts.isExpression)], ts.visitNodes(node.arguments, visitor, ts.isExpression))); + } return factory.updateCallExpression(node, factory.createPropertyAccessExpression(ts.visitNode(target, visitor), "call"), undefined, __spreadArray([ts.visitNode(thisArg, visitor, ts.isExpression)], ts.visitNodes(node.arguments, visitor, ts.isExpression))); } return ts.visitEachChild(node, visitor, context); } function visitTaggedTemplateExpression(node) { - if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.tag)) { + if (shouldTransformPrivateElements && ts.isPrivateIdentifierPropertyAccessExpression(node.tag)) { var _a = factory.createCallBinding(node.tag, hoistVariableDeclaration, languageVersion), thisArg = _a.thisArg, target = _a.target; return factory.updateTaggedTemplateExpression(node, factory.createCallExpression(factory.createPropertyAccessExpression(ts.visitNode(target, visitor), "bind"), undefined, [ts.visitNode(thisArg, visitor, ts.isExpression)]), undefined, ts.visitNode(node.template, visitor, ts.isTemplateLiteral)); } return ts.visitEachChild(node, visitor, context); } function visitBinaryExpression(node) { - if (shouldTransformPrivateFields) { + if (shouldTransformPrivateElements) { if (ts.isDestructuringAssignment(node)) { var savedPendingExpressions = pendingExpressions; pendingExpressions = undefined; @@ -71592,62 +74342,83 @@ var ts; if (ts.isAssignmentExpression(node) && ts.isPrivateIdentifierPropertyAccessExpression(node.left)) { var info = accessPrivateIdentifier(node.left.name); if (info) { - return ts.setOriginalNode(createPrivateIdentifierAssignment(info, node.left.expression, node.right, node.operatorToken.kind), node); + return ts.setTextRange(ts.setOriginalNode(createPrivateIdentifierAssignment(info, node.left.expression, node.right, node.operatorToken.kind), node), node); } } } return ts.visitEachChild(node, visitor, context); } function createPrivateIdentifierAssignment(info, receiver, right, operator) { - switch (info.placement) { - case 0: { - return createPrivateIdentifierInstanceFieldAssignment(info, receiver, right, operator); - } - default: return ts.Debug.fail("Unexpected private identifier placement"); - } - } - function createPrivateIdentifierInstanceFieldAssignment(info, receiver, right, operator) { receiver = ts.visitNode(receiver, visitor, ts.isExpression); right = ts.visitNode(right, visitor, ts.isExpression); if (ts.isCompoundAssignment(operator)) { var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression; - return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(initializeExpression || readExpression, info.weakMapName, factory.createBinaryExpression(context.getEmitHelperFactory().createClassPrivateFieldGetHelper(readExpression, info.weakMapName), ts.getNonAssignmentOperatorForCompoundAssignment(operator), right)); - } - else { - return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.weakMapName, right); + receiver = initializeExpression || readExpression; + right = factory.createBinaryExpression(createPrivateIdentifierAccessHelper(info, readExpression), ts.getNonAssignmentOperatorForCompoundAssignment(operator), right); + } + ts.setCommentRange(receiver, ts.moveRangePos(receiver, -1)); + switch (info.kind) { + case "a": + return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, info.setterName); + case "m": + return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, undefined); + case "f": + return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, info.variableName); + default: + ts.Debug.assertNever(info, "Unknown private element type"); } } function visitClassLike(node) { var savedPendingExpressions = pendingExpressions; pendingExpressions = undefined; - if (shouldTransformPrivateFields) { + if (shouldTransformPrivateElements) { startPrivateIdentifierEnvironment(); + var name = ts.getNameOfDeclaration(node); + if (name && ts.isIdentifier(name)) { + getPrivateIdentifierEnvironment().className = ts.idText(name); + } + var privateInstanceMethodsAndAccessors = getPrivateInstanceMethodsAndAccessors(node); + if (ts.some(privateInstanceMethodsAndAccessors)) { + getPrivateIdentifierEnvironment().weakSetName = createHoistedVariableForClass("instances", privateInstanceMethodsAndAccessors[0].name); + } } var result = ts.isClassDeclaration(node) ? visitClassDeclaration(node) : visitClassExpression(node); - if (shouldTransformPrivateFields) { + if (shouldTransformPrivateElements) { endPrivateIdentifierEnvironment(); } pendingExpressions = savedPendingExpressions; return result; } function doesClassElementNeedTransform(node) { - return ts.isPropertyDeclaration(node) || (shouldTransformPrivateFields && node.name && ts.isPrivateIdentifier(node.name)); + return ts.isPropertyDeclaration(node) || (shouldTransformPrivateElements && node.name && ts.isPrivateIdentifier(node.name)); + } + function getPrivateInstanceMethodsAndAccessors(node) { + return ts.filter(node.members, ts.isNonStaticMethodOrAccessorWithPrivateName); } function visitClassDeclaration(node) { if (!ts.forEach(node.members, doesClassElementNeedTransform)) { return ts.visitEachChild(node, visitor, context); } + var staticProperties = ts.getProperties(node, false, true); + var pendingPrivateStateAssignment; + if (shouldTransformPrivateElements && ts.some(node.members, function (m) { return ts.hasStaticModifier(m) && !!m.name && ts.isPrivateIdentifier(m.name); })) { + var temp = factory.createTempVariable(hoistVariableDeclaration, true); + getPrivateIdentifierEnvironment().classConstructor = factory.cloneNode(temp); + pendingPrivateStateAssignment = factory.createAssignment(temp, factory.getInternalName(node)); + } var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 103); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104); var statements = [ factory.updateClassDeclaration(node, undefined, node.modifiers, node.name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass)) ]; + if (pendingPrivateStateAssignment) { + getPendingExpressions().unshift(pendingPrivateStateAssignment); + } if (ts.some(pendingExpressions)) { statements.push(factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))); } - var staticProperties = ts.getProperties(node, true, true); if (ts.some(staticProperties)) { addPropertyStatements(statements, staticProperties, factory.getInternalName(node)); } @@ -71658,11 +74429,24 @@ var ts; return ts.visitEachChild(node, visitor, context); } var isDecoratedClassDeclaration = ts.isClassDeclaration(ts.getOriginalNode(node)); - var staticProperties = ts.getProperties(node, true, true); + var staticProperties = ts.getProperties(node, false, true); var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 103); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104); + var isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 16777216; + var temp; + function createClassTempVar() { + var classCheckFlags = resolver.getNodeCheckFlags(node); + var isClassWithConstructorReference = classCheckFlags & 16777216; + var requiresBlockScopedVar = classCheckFlags & 524288; + return factory.createTempVariable(requiresBlockScopedVar ? addBlockScopedVariable : hoistVariableDeclaration, !!isClassWithConstructorReference); + } + if (shouldTransformPrivateElements && ts.some(node.members, function (m) { return ts.hasStaticModifier(m) && !!m.name && ts.isPrivateIdentifier(m.name); })) { + temp = createClassTempVar(); + getPrivateIdentifierEnvironment().classConstructor = factory.cloneNode(temp); + } var classExpression = factory.updateClassExpression(node, ts.visitNodes(node.decorators, visitor, ts.isDecorator), node.modifiers, node.name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass)); - if (ts.some(staticProperties) || ts.some(pendingExpressions)) { + var hasTransformableStatics = ts.some(staticProperties, function (p) { return !!p.initializer || (shouldTransformPrivateElements && ts.isPrivateIdentifier(p.name)); }); + if (hasTransformableStatics || ts.some(pendingExpressions)) { if (isDecoratedClassDeclaration) { ts.Debug.assertIsDefined(pendingStatements, "Decorated classes transformed by TypeScript are expected to be within a variable declaration."); if (pendingStatements && pendingExpressions && ts.some(pendingExpressions)) { @@ -71671,12 +74455,14 @@ var ts; if (pendingStatements && ts.some(staticProperties)) { addPropertyStatements(pendingStatements, staticProperties, factory.getInternalName(node)); } + if (temp) { + return factory.inlineExpressions([factory.createAssignment(temp, classExpression), temp]); + } return classExpression; } else { var expressions = []; - var isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 16777216; - var temp = factory.createTempVariable(hoistVariableDeclaration, !!isClassWithConstructorReference); + temp || (temp = createClassTempVar()); if (isClassWithConstructorReference) { enableSubstitutionForClassAliases(); var alias = factory.cloneNode(temp); @@ -71694,13 +74480,16 @@ var ts; return classExpression; } function transformClassMembers(node, isDerivedClass) { - if (shouldTransformPrivateFields) { + if (shouldTransformPrivateElements) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (ts.isPrivateIdentifierPropertyDeclaration(member)) { - addPrivateIdentifierToEnvironment(member.name); + if (ts.isPrivateIdentifierClassElementDeclaration(member)) { + addPrivateIdentifierToEnvironment(member); } } + if (ts.some(getPrivateInstanceMethodsAndAccessors(node))) { + createBrandCheckWeakSetForPrivateMethods(); + } } var members = []; var constructor = transformConstructor(node, isDerivedClass); @@ -71710,19 +74499,24 @@ var ts; ts.addRange(members, ts.visitNodes(node.members, classElementVisitor, ts.isClassElement)); return ts.setTextRange(factory.createNodeArray(members), node.members); } - function isPropertyDeclarationThatRequiresConstructorStatement(member) { - if (!ts.isPropertyDeclaration(member) || ts.hasStaticModifier(member) || ts.hasSyntacticModifier(ts.getOriginalNode(member), 128)) { + function createBrandCheckWeakSetForPrivateMethods() { + var weakSetName = getPrivateIdentifierEnvironment().weakSetName; + ts.Debug.assert(weakSetName, "weakSetName should be set in private identifier environment"); + getPendingExpressions().push(factory.createAssignment(weakSetName, factory.createNewExpression(factory.createIdentifier("WeakSet"), undefined, []))); + } + function isClassElementThatRequiresConstructorStatement(member) { + if (ts.hasStaticModifier(member) || ts.hasSyntacticModifier(ts.getOriginalNode(member), 128)) { return false; } - if (context.getCompilerOptions().useDefineForClassFields) { + if (useDefineForClassFields) { return languageVersion < 99; } - return ts.isInitializedProperty(member) || shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyDeclaration(member); + return ts.isInitializedProperty(member) || shouldTransformPrivateElements && ts.isPrivateIdentifierClassElementDeclaration(member); } function transformConstructor(node, isDerivedClass) { var constructor = ts.visitNode(ts.getFirstConstructorWithBody(node), visitor, ts.isConstructorDeclaration); - var properties = node.members.filter(isPropertyDeclarationThatRequiresConstructorStatement); - if (!ts.some(properties)) { + var elements = node.members.filter(isClassElementThatRequiresConstructorStatement); + if (!ts.some(elements)) { return constructor; } var parameters = ts.visitParameterList(constructor ? constructor.parameters : undefined, visitor, context); @@ -71733,12 +74527,13 @@ var ts; return ts.startOnNewLine(ts.setOriginalNode(ts.setTextRange(factory.createConstructorDeclaration(undefined, undefined, parameters !== null && parameters !== void 0 ? parameters : [], body), constructor || node), constructor)); } function transformConstructorBody(node, constructor, isDerivedClass) { - var useDefineForClassFields = context.getCompilerOptions().useDefineForClassFields; var properties = ts.getProperties(node, false, false); if (!useDefineForClassFields) { properties = ts.filter(properties, function (property) { return !!property.initializer || ts.isPrivateIdentifier(property.name); }); } - if (!constructor && !ts.some(properties)) { + var privateMethodsAndAccessors = getPrivateInstanceMethodsAndAccessors(node); + var needsConstructorBody = ts.some(properties) || ts.some(privateMethodsAndAccessors); + if (!constructor && !needsConstructorBody) { return ts.visitFunctionBody(undefined, visitor, context); } resumeLexicalEnvironment(); @@ -71762,7 +74557,9 @@ var ts; indexOfFirstStatement = afterParameterProperties; } } - addPropertyStatements(statements, properties, factory.createThis()); + var receiver = factory.createThis(); + addMethodStatements(statements, privateMethodsAndAccessors, receiver); + addPropertyStatements(statements, properties, receiver); if (constructor) { ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement)); } @@ -71801,27 +74598,30 @@ var ts; } function transformProperty(property, receiver) { var _a; - var emitAssignment = !context.getCompilerOptions().useDefineForClassFields; + var emitAssignment = !useDefineForClassFields; var propertyName = ts.isComputedPropertyName(property.name) && !ts.isSimpleInlineableExpression(property.name.expression) ? factory.updateComputedPropertyName(property.name, factory.getGeneratedNameForNode(property.name)) : property.name; - if (shouldTransformPrivateFields && ts.isPrivateIdentifier(propertyName)) { + if (shouldTransformPrivateElements && ts.isPrivateIdentifier(propertyName)) { var privateIdentifierInfo = accessPrivateIdentifier(propertyName); if (privateIdentifierInfo) { - switch (privateIdentifierInfo.placement) { - case 0: { - return createPrivateInstanceFieldInitializer(receiver, ts.visitNode(property.initializer, visitor, ts.isExpression), privateIdentifierInfo.weakMapName); + if (privateIdentifierInfo.kind === "f") { + if (!privateIdentifierInfo.isStatic) { + return createPrivateInstanceFieldInitializer(receiver, ts.visitNode(property.initializer, visitor, ts.isExpression), privateIdentifierInfo.brandCheckIdentifier); + } + else { + return createPrivateStaticFieldInitializer(privateIdentifierInfo.variableName, ts.visitNode(property.initializer, visitor, ts.isExpression)); } } + else { + return undefined; + } } else { ts.Debug.fail("Undeclared private name for property declaration."); } } - if (ts.isPrivateIdentifier(propertyName) && !property.initializer) { - return undefined; - } - if (ts.isPrivateIdentifier(propertyName) && !property.initializer) { + if ((ts.isPrivateIdentifier(propertyName) || ts.hasStaticModifier(property)) && !property.initializer) { return undefined; } var propertyOriginalNode = ts.getOriginalNode(property); @@ -71846,10 +74646,18 @@ var ts; function enableSubstitutionForClassAliases() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; - context.enableSubstitution(78); + context.enableSubstitution(79); classAliases = []; } } + function addMethodStatements(statements, methods, receiver) { + if (!shouldTransformPrivateElements || !ts.some(methods)) { + return; + } + var weakSetName = getPrivateIdentifierEnvironment().weakSetName; + ts.Debug.assert(weakSetName, "weakSetName should be set in private identifier environment"); + statements.push(factory.createExpressionStatement(createPrivateInstanceMethodInitializer(receiver, weakSetName))); + } function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); if (hint === 1) { @@ -71859,7 +74667,7 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 78: + case 79: return substituteExpressionIdentifier(node); } return node; @@ -71874,10 +74682,10 @@ var ts; if (declaration) { var classAlias = classAliases[declaration.id]; if (classAlias) { - var clone_2 = factory.cloneNode(classAlias); - ts.setSourceMapRange(clone_2, node); - ts.setCommentRange(clone_2, node); - return clone_2; + var clone_3 = factory.cloneNode(classAlias); + ts.setSourceMapRange(clone_3, node); + ts.setCommentRange(clone_3, node); + return clone_3; } } } @@ -71892,7 +74700,12 @@ var ts; var alreadyTransformed = ts.isAssignmentExpression(innerExpression) && ts.isGeneratedIdentifier(innerExpression.left); if (!alreadyTransformed && !inlinable && shouldHoist) { var generatedName = factory.getGeneratedNameForNode(name); - hoistVariableDeclaration(generatedName); + if (resolver.getNodeCheckFlags(name) & 524288) { + addBlockScopedVariable(generatedName); + } + else { + hoistVariableDeclaration(generatedName); + } return factory.createAssignment(generatedName, expression); } return (inlinable || ts.isIdentifier(innerExpression)) ? undefined : expression; @@ -71906,21 +74719,163 @@ var ts; currentPrivateIdentifierEnvironment = privateIdentifierEnvironmentStack.pop(); } function getPrivateIdentifierEnvironment() { - return currentPrivateIdentifierEnvironment || (currentPrivateIdentifierEnvironment = new ts.Map()); + if (!currentPrivateIdentifierEnvironment) { + currentPrivateIdentifierEnvironment = { + className: "", + identifiers: new ts.Map() + }; + } + return currentPrivateIdentifierEnvironment; } function getPendingExpressions() { return pendingExpressions || (pendingExpressions = []); } - function addPrivateIdentifierToEnvironment(name) { - var text = ts.getTextOfPropertyName(name); - var weakMapName = factory.createUniqueName("_" + text.substring(1), 16 | 8); - hoistVariableDeclaration(weakMapName); - getPrivateIdentifierEnvironment().set(name.escapedText, { placement: 0, weakMapName: weakMapName }); - getPendingExpressions().push(factory.createAssignment(weakMapName, factory.createNewExpression(factory.createIdentifier("WeakMap"), undefined, []))); + function addPrivateIdentifierToEnvironment(node) { + var _a; + var text = ts.getTextOfPropertyName(node.name); + var env = getPrivateIdentifierEnvironment(); + var weakSetName = env.weakSetName, classConstructor = env.classConstructor; + var assignmentExpressions = []; + var privateName = node.name.escapedText; + var previousInfo = env.identifiers.get(privateName); + var isValid = !isReservedPrivateName(node.name) && previousInfo === undefined; + if (ts.hasStaticModifier(node)) { + ts.Debug.assert(classConstructor, "weakSetName should be set in private identifier environment"); + if (ts.isPropertyDeclaration(node)) { + var variableName = createHoistedVariableForPrivateName(text, node); + env.identifiers.set(privateName, { + kind: "f", + variableName: variableName, + brandCheckIdentifier: classConstructor, + isStatic: true, + isValid: isValid, + }); + } + else if (ts.isMethodDeclaration(node)) { + var functionName = createHoistedVariableForPrivateName(text, node); + env.identifiers.set(privateName, { + kind: "m", + methodName: functionName, + brandCheckIdentifier: classConstructor, + isStatic: true, + isValid: isValid, + }); + } + else if (ts.isGetAccessorDeclaration(node)) { + var getterName = createHoistedVariableForPrivateName(text + "_get", node); + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" && previousInfo.isStatic && !previousInfo.getterName) { + previousInfo.getterName = getterName; + } + else { + env.identifiers.set(privateName, { + kind: "a", + getterName: getterName, + setterName: undefined, + brandCheckIdentifier: classConstructor, + isStatic: true, + isValid: isValid, + }); + } + } + else if (ts.isSetAccessorDeclaration(node)) { + var setterName = createHoistedVariableForPrivateName(text + "_set", node); + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" && previousInfo.isStatic && !previousInfo.setterName) { + previousInfo.setterName = setterName; + } + else { + env.identifiers.set(privateName, { + kind: "a", + getterName: undefined, + setterName: setterName, + brandCheckIdentifier: classConstructor, + isStatic: true, + isValid: isValid, + }); + } + } + else { + ts.Debug.assertNever(node, "Unknown class element type."); + } + } + else if (ts.isPropertyDeclaration(node)) { + var weakMapName = createHoistedVariableForPrivateName(text, node); + env.identifiers.set(privateName, { + kind: "f", + brandCheckIdentifier: weakMapName, + isStatic: false, + variableName: undefined, + isValid: isValid, + }); + assignmentExpressions.push(factory.createAssignment(weakMapName, factory.createNewExpression(factory.createIdentifier("WeakMap"), undefined, []))); + } + else if (ts.isMethodDeclaration(node)) { + ts.Debug.assert(weakSetName, "weakSetName should be set in private identifier environment"); + env.identifiers.set(privateName, { + kind: "m", + methodName: createHoistedVariableForPrivateName(text, node), + brandCheckIdentifier: weakSetName, + isStatic: false, + isValid: isValid, + }); + } + else if (ts.isAccessor(node)) { + 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" && !previousInfo.isStatic && !previousInfo.getterName) { + previousInfo.getterName = getterName; + } + else { + env.identifiers.set(privateName, { + kind: "a", + getterName: getterName, + setterName: undefined, + brandCheckIdentifier: weakSetName, + isStatic: false, + isValid: isValid, + }); + } + } + else { + var setterName = createHoistedVariableForPrivateName(text + "_set", node); + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" && !previousInfo.isStatic && !previousInfo.setterName) { + previousInfo.setterName = setterName; + } + else { + env.identifiers.set(privateName, { + kind: "a", + getterName: undefined, + setterName: setterName, + brandCheckIdentifier: weakSetName, + isStatic: false, + isValid: isValid, + }); + } + } + } + else { + ts.Debug.assertNever(node, "Unknown class element type."); + } + (_a = getPendingExpressions()).push.apply(_a, assignmentExpressions); + } + function createHoistedVariableForClass(name, node) { + var className = getPrivateIdentifierEnvironment().className; + var prefix = className ? "_" + className : ""; + var identifier = factory.createUniqueName(prefix + "_" + name, 16); + if (resolver.getNodeCheckFlags(node) & 524288) { + addBlockScopedVariable(identifier); + } + else { + hoistVariableDeclaration(identifier); + } + return identifier; + } + function createHoistedVariableForPrivateName(privateName, node) { + return createHoistedVariableForClass(privateName.substring(1), node.name); } function accessPrivateIdentifier(name) { if (currentPrivateIdentifierEnvironment) { - var info = currentPrivateIdentifierEnvironment.get(name.escapedText); + var info = currentPrivateIdentifierEnvironment.identifiers.get(name.escapedText); if (info) { return info; } @@ -71930,7 +74885,7 @@ var ts; if (!env) { continue; } - var info = env.get(name.escapedText); + var info = env.identifiers.get(name.escapedText); if (info) { return info; } @@ -71946,10 +74901,10 @@ var ts; var receiver = node.expression; if (ts.isThisProperty(node) || ts.isSuperProperty(node) || !ts.isSimpleCopiableExpression(node.expression)) { receiver = factory.createTempVariable(hoistVariableDeclaration, true); - getPendingExpressions().push(factory.createBinaryExpression(receiver, 62, node.expression)); + getPendingExpressions().push(factory.createBinaryExpression(receiver, 63, node.expression)); } return factory.createPropertyAccessExpression(factory.createParenthesizedExpression(factory.createObjectLiteralExpression([ - factory.createSetAccessorDeclaration(undefined, undefined, "value", [factory.createParameterDeclaration(undefined, undefined, undefined, parameter, undefined, undefined, undefined)], factory.createBlock([factory.createExpressionStatement(createPrivateIdentifierAssignment(info, receiver, parameter, 62))])) + factory.createSetAccessorDeclaration(undefined, undefined, "value", [factory.createParameterDeclaration(undefined, undefined, undefined, parameter, undefined, undefined, undefined)], factory.createBlock([factory.createExpressionStatement(createPrivateIdentifierAssignment(info, receiver, parameter, 63))])) ])), "value"); } function visitArrayAssignmentTarget(node) { @@ -71990,9 +74945,20 @@ var ts; } } ts.transformClassFields = transformClassFields; + function createPrivateStaticFieldInitializer(variableName, initializer) { + return ts.factory.createAssignment(variableName, ts.factory.createObjectLiteralExpression([ + ts.factory.createPropertyAssignment("value", initializer || ts.factory.createVoidZero()) + ])); + } function createPrivateInstanceFieldInitializer(receiver, initializer, weakMapName) { return ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(weakMapName, "set"), undefined, [receiver, initializer || ts.factory.createVoidZero()]); } + function createPrivateInstanceMethodInitializer(receiver, weakSetName) { + return ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(weakSetName, "add"), undefined, [receiver]); + } + function isReservedPrivateName(node) { + return node.escapedText === "#constructor"; + } })(ts || (ts = {})); var ts; (function (ts) { @@ -72049,37 +75015,37 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 64) === 0) { + if ((node.transformFlags & 128) === 0) { return node; } switch (node.kind) { - case 129: + case 130: return undefined; - case 213: + case 215: return visitAwaitExpression(node); - case 165: + case 167: return doWithContext(1 | 2, visitMethodDeclaration, node); - case 251: + case 253: return doWithContext(1 | 2, visitFunctionDeclaration, node); - case 208: + case 210: return doWithContext(1 | 2, visitFunctionExpression, node); - case 209: + case 211: return doWithContext(1, visitArrowFunction, node); - case 201: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 105) { + case 203: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106) { capturedSuperProperties.add(node.name.escapedText); } return ts.visitEachChild(node, visitor, context); - case 202: - if (capturedSuperProperties && node.expression.kind === 105) { + case 204: + if (capturedSuperProperties && node.expression.kind === 106) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 167: + case 169: + case 170: case 168: - case 166: - case 252: - case 221: + case 254: + case 223: return doWithContext(1 | 2, visitDefault, node); default: return ts.visitEachChild(node, visitor, context); @@ -72088,27 +75054,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 232: + case 234: return visitVariableStatementInAsyncBody(node); - case 237: + case 239: return visitForStatementInAsyncBody(node); - case 238: + case 240: return visitForInStatementInAsyncBody(node); - case 239: + case 241: return visitForOfStatementInAsyncBody(node); - case 287: + case 289: return visitCatchClauseInAsyncBody(node); - case 230: - case 244: - case 258: - case 284: - case 285: - case 247: - case 235: + case 232: + case 246: + case 260: + case 286: + case 287: + case 249: + case 237: + case 238: case 236: - case 234: - case 243: case 245: + case 247: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -72149,18 +75115,18 @@ var ts; function visitForInStatementInAsyncBody(node) { return factory.updateForInStatement(node, isVariableDeclarationListWithCollidingName(node.initializer) ? visitVariableDeclarationListWithCollidingNames(node.initializer, true) - : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, asyncBodyVisitor, ts.isStatement, factory.liftToBlock)); + : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitIterationBody(node.statement, asyncBodyVisitor, context)); } function visitForOfStatementInAsyncBody(node) { return factory.updateForOfStatement(node, ts.visitNode(node.awaitModifier, visitor, ts.isToken), isVariableDeclarationListWithCollidingName(node.initializer) ? visitVariableDeclarationListWithCollidingNames(node.initializer, true) - : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, asyncBodyVisitor, ts.isStatement, factory.liftToBlock)); + : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitIterationBody(node.statement, asyncBodyVisitor, context)); } function visitForStatementInAsyncBody(node) { var initializer = node.initializer; return factory.updateForStatement(node, isVariableDeclarationListWithCollidingName(initializer) ? visitVariableDeclarationListWithCollidingNames(initializer, false) - : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitor, ts.isExpression), ts.visitNode(node.statement, asyncBodyVisitor, ts.isStatement, factory.liftToBlock)); + : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitor, ts.isExpression), ts.visitIterationBody(node.statement, asyncBodyVisitor, context)); } function visitAwaitExpression(node) { if (inTopLevelContext()) { @@ -72260,7 +75226,7 @@ var ts; var original = ts.getOriginalNode(node, ts.isFunctionLike); var nodeType = original.type; var promiseConstructor = languageVersion < 2 ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 209; + var isArrowFunction = node.kind === 211; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0; var savedEnclosingFunctionParameterNames = enclosingFunctionParameterNames; enclosingFunctionParameterNames = new ts.Set(); @@ -72341,15 +75307,15 @@ var ts; function enableSubstitutionForAsyncMethodsWithSuper() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; + context.enableSubstitution(205); context.enableSubstitution(203); - context.enableSubstitution(201); - context.enableSubstitution(202); - context.enableEmitNotification(252); - context.enableEmitNotification(165); + context.enableSubstitution(204); + context.enableEmitNotification(254); context.enableEmitNotification(167); + context.enableEmitNotification(169); + context.enableEmitNotification(170); context.enableEmitNotification(168); - context.enableEmitNotification(166); - context.enableEmitNotification(232); + context.enableEmitNotification(234); } } function onEmitNode(hint, node, emitCallback) { @@ -72381,23 +75347,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 201: + case 203: return substitutePropertyAccessExpression(node); - case 202: + case 204: return substituteElementAccessExpression(node); - case 203: + case 205: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 105) { + if (node.expression.kind === 106) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 | 32), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 105) { + if (node.expression.kind === 106) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -72416,11 +75382,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 252 - || kind === 166 - || kind === 165 + return kind === 254 + || kind === 168 || kind === 167 - || kind === 168; + || kind === 169 + || kind === 170; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096) { @@ -72509,7 +75475,7 @@ var ts; return visitorWorker(node, true); } function visitorNoAsyncModifier(node) { - if (node.kind === 129) { + if (node.kind === 130) { return undefined; } return node; @@ -72527,74 +75493,74 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitorWorker(node, expressionResultIsUnused) { - if ((node.transformFlags & 32) === 0) { + if ((node.transformFlags & 64) === 0) { return node; } switch (node.kind) { - case 213: + case 215: return visitAwaitExpression(node); - case 219: + case 221: return visitYieldExpression(node); - case 242: + case 244: return visitReturnStatement(node); - case 245: + case 247: return visitLabeledStatement(node); - case 200: + case 202: return visitObjectLiteralExpression(node); - case 216: + case 218: return visitBinaryExpression(node, expressionResultIsUnused); - case 337: + case 345: return visitCommaListExpression(node, expressionResultIsUnused); - case 287: + case 289: return visitCatchClause(node); - case 232: + case 234: return visitVariableStatement(node); - case 249: + case 251: return visitVariableDeclaration(node); - case 235: - case 236: + case 237: case 238: + case 240: return doWithHierarchyFacts(visitDefault, node, 0, 2); - case 239: + case 241: return visitForOfStatement(node, undefined); - case 237: + case 239: return doWithHierarchyFacts(visitForStatement, node, 0, 2); - case 212: + case 214: return visitVoidExpression(node); - case 166: + case 168: return doWithHierarchyFacts(visitConstructorDeclaration, node, 2, 1); - case 165: - return doWithHierarchyFacts(visitMethodDeclaration, node, 2, 1); case 167: + return doWithHierarchyFacts(visitMethodDeclaration, node, 2, 1); + case 169: return doWithHierarchyFacts(visitGetAccessorDeclaration, node, 2, 1); - case 168: + case 170: return doWithHierarchyFacts(visitSetAccessorDeclaration, node, 2, 1); - case 251: + case 253: return doWithHierarchyFacts(visitFunctionDeclaration, node, 2, 1); - case 208: + case 210: return doWithHierarchyFacts(visitFunctionExpression, node, 2, 1); - case 209: + case 211: return doWithHierarchyFacts(visitArrowFunction, node, 2, 0); - case 160: + case 162: return visitParameter(node); - case 233: + case 235: return visitExpressionStatement(node); - case 207: + case 209: return visitParenthesizedExpression(node, expressionResultIsUnused); - case 205: + case 207: return visitTaggedTemplateExpression(node); - case 201: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 105) { + case 203: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106) { capturedSuperProperties.add(node.name.escapedText); } return ts.visitEachChild(node, visitor, context); - case 202: - if (capturedSuperProperties && node.expression.kind === 105) { + case 204: + if (capturedSuperProperties && node.expression.kind === 106) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 252: - case 221: + case 254: + case 223: return doWithHierarchyFacts(visitDefault, node, 2, 1); default: return ts.visitEachChild(node, visitor, context); @@ -72627,7 +75593,7 @@ var ts; function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 239 && statement.awaitModifier) { + if (statement.kind === 241 && statement.awaitModifier) { return visitForOfStatement(statement, node); } return factory.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement, factory.liftToBlock), node); @@ -72639,7 +75605,7 @@ var ts; var objects = []; for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) { var e = elements_4[_i]; - if (e.kind === 290) { + if (e.kind === 292) { if (chunkObject) { objects.push(factory.createObjectLiteralExpression(chunkObject)); chunkObject = undefined; @@ -72648,7 +75614,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 288 + chunkObject = ts.append(chunkObject, e.kind === 290 ? factory.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -72659,9 +75625,9 @@ var ts; return objects; } function visitObjectLiteralExpression(node) { - if (node.transformFlags & 16384) { + if (node.transformFlags & 32768) { var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 200) { + if (objects.length && objects[0].kind !== 202) { objects.unshift(factory.createObjectLiteralExpression()); } var expression = objects[0]; @@ -72700,7 +75666,7 @@ var ts; return ts.processTaggedTemplateExpression(context, node, visitor, currentSourceFile, recordTaggedTemplateString, ts.ProcessLevel.LiftRestriction); } function visitBinaryExpression(node, expressionResultIsUnused) { - if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 16384) { + if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 32768) { return ts.flattenDestructuringAssignment(node, visitor, context, 1, !expressionResultIsUnused); } if (node.operatorToken.kind === 27) { @@ -72727,7 +75693,7 @@ var ts; function visitCatchClause(node) { if (node.variableDeclaration && ts.isBindingPattern(node.variableDeclaration.name) && - node.variableDeclaration.name.transformFlags & 16384) { + node.variableDeclaration.name.transformFlags & 32768) { var name = factory.getGeneratedNameForNode(node.variableDeclaration.name); var updatedDecl = factory.updateVariableDeclaration(node.variableDeclaration, node.variableDeclaration.name, undefined, undefined, name); var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1); @@ -72762,20 +75728,20 @@ var ts; return visitVariableDeclarationWorker(node, false); } function visitVariableDeclarationWorker(node, exportedVariableStatement) { - if (ts.isBindingPattern(node.name) && node.name.transformFlags & 16384) { + if (ts.isBindingPattern(node.name) && node.name.transformFlags & 32768) { return ts.flattenDestructuringBinding(node, visitor, context, 1, undefined, exportedVariableStatement); } return ts.visitEachChild(node, visitor, context); } function visitForStatement(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)); + 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.visitIterationBody(node.statement, visitor, context)); } function visitVoidExpression(node) { return ts.visitEachChild(node, visitorWithUnusedExpressionResult, context); } function visitForOfStatement(node, outermostLabeledStatement) { var ancestorFacts = enterSubtree(0, 2); - if (node.initializer.transformFlags & 16384) { + if (node.initializer.transformFlags & 32768) { node = transformForOfStatementWithObjectRest(node); } var result = node.awaitModifier ? @@ -72812,7 +75778,7 @@ var ts; var bodyLocation; var statementsLocation; var statements = [ts.visitNode(binding, visitor, ts.isStatement)]; - var statement = ts.visitNode(node.statement, visitor, ts.isStatement); + var statement = ts.visitIterationBody(node.statement, visitor, context); if (ts.isBlock(statement)) { ts.addRange(statements, statement.statements); bodyLocation = statement; @@ -72864,7 +75830,7 @@ var ts; ])); } function visitParameter(node) { - if (node.transformFlags & 16384) { + if (node.transformFlags & 32768) { return factory.updateParameterDeclaration(node, undefined, undefined, node.dotDotDotToken, factory.getGeneratedNameForNode(node), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression)); } return ts.visitEachChild(node, visitor, context); @@ -72990,7 +75956,7 @@ var ts; function appendObjectRestAssignmentsIfNeeded(statements, node) { for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { var parameter = _a[_i]; - if (parameter.transformFlags & 16384) { + if (parameter.transformFlags & 32768) { var temp = factory.getGeneratedNameForNode(parameter); var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1, temp, false, true); if (ts.some(declarations)) { @@ -73005,15 +75971,15 @@ var ts; function enableSubstitutionForAsyncMethodsWithSuper() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; + context.enableSubstitution(205); context.enableSubstitution(203); - context.enableSubstitution(201); - context.enableSubstitution(202); - context.enableEmitNotification(252); - context.enableEmitNotification(165); + context.enableSubstitution(204); + context.enableEmitNotification(254); context.enableEmitNotification(167); + context.enableEmitNotification(169); + context.enableEmitNotification(170); context.enableEmitNotification(168); - context.enableEmitNotification(166); - context.enableEmitNotification(232); + context.enableEmitNotification(234); } } function onEmitNode(hint, node, emitCallback) { @@ -73045,23 +76011,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 201: + case 203: return substitutePropertyAccessExpression(node); - case 202: + case 204: return substituteElementAccessExpression(node); - case 203: + case 205: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 105) { + if (node.expression.kind === 106) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 | 32), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 105) { + if (node.expression.kind === 106) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -73080,11 +76046,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 252 - || kind === 166 - || kind === 165 + return kind === 254 + || kind === 168 || kind === 167 - || kind === 168; + || kind === 169 + || kind === 170; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096) { @@ -73109,11 +76075,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 16) === 0) { + if ((node.transformFlags & 32) === 0) { return node; } switch (node.kind) { - case 287: + case 289: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -73140,25 +76106,29 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 8) === 0) { + if ((node.transformFlags & 16) === 0) { return node; } switch (node.kind) { - case 201: - case 202: + case 205: { + var updated = visitNonOptionalCallExpression(node, false); + ts.Debug.assertNotNode(updated, ts.isSyntheticReference); + return updated; + } case 203: - if (node.flags & 32) { + case 204: + if (ts.isOptionalChain(node)) { var updated = visitOptionalExpression(node, false, false); ts.Debug.assertNotNode(updated, ts.isSyntheticReference); return updated; } return ts.visitEachChild(node, visitor, context); - case 216: + case 218: if (node.operatorToken.kind === 60) { return transformNullishCoalescingExpression(node); } return ts.visitEachChild(node, visitor, context); - case 210: + case 212: return visitDeleteExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -73197,7 +76167,7 @@ var ts; thisArg = expression; } } - expression = node.kind === 201 + expression = node.kind === 203 ? 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; @@ -73206,14 +76176,22 @@ var ts; if (ts.isOptionalChain(node)) { return visitOptionalExpression(node, captureThisArg, false); } + if (ts.isParenthesizedExpression(node.expression) && ts.isOptionalChain(ts.skipParentheses(node.expression))) { + var expression = visitNonOptionalParenthesizedExpression(node.expression, true, false); + var args = ts.visitNodes(node.arguments, visitor, ts.isExpression); + if (ts.isSyntheticReference(expression)) { + return ts.setTextRange(factory.createFunctionCallCall(expression.expression, expression.thisArg, args), node); + } + return factory.updateCallExpression(node, expression, undefined, args); + } return ts.visitEachChild(node, visitor, context); } function visitNonOptionalExpression(node, captureThisArg, isDelete) { switch (node.kind) { - case 207: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete); - case 201: - case 202: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete); - case 203: return visitNonOptionalCallExpression(node, captureThisArg); + case 209: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete); + case 203: + case 204: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete); + case 205: return visitNonOptionalCallExpression(node, captureThisArg); default: return ts.visitNode(node, visitor, ts.isExpression); } } @@ -73232,8 +76210,8 @@ var ts; for (var i = 0; i < chain.length; i++) { var segment = chain[i]; switch (segment.kind) { - case 201: - case 202: + case 203: + case 204: if (i === chain.length - 1 && captureThisArg) { if (!ts.isSimpleCopiableExpression(rightExpression)) { thisArg = factory.createTempVariable(hoistVariableDeclaration); @@ -73243,13 +76221,13 @@ var ts; thisArg = rightExpression; } } - rightExpression = segment.kind === 201 + rightExpression = segment.kind === 203 ? factory.createPropertyAccessExpression(rightExpression, ts.visitNode(segment.name, visitor, ts.isIdentifier)) : factory.createElementAccessExpression(rightExpression, ts.visitNode(segment.argumentExpression, visitor, ts.isExpression)); break; - case 203: + case 205: if (i === 0 && leftThisArg) { - rightExpression = factory.createFunctionCallCall(rightExpression, leftThisArg.kind === 105 ? factory.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); + rightExpression = factory.createFunctionCallCall(rightExpression, leftThisArg.kind === 106 ? factory.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); } else { rightExpression = factory.createCallExpression(rightExpression, undefined, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); @@ -73286,7 +76264,7 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function transformESNext(context) { + function transformES2021(context) { var hoistVariableDeclaration = context.hoistVariableDeclaration, factory = context.factory; return ts.chainBundle(context, transformSourceFile); function transformSourceFile(node) { @@ -73296,11 +76274,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 4) === 0) { + if ((node.transformFlags & 8) === 0) { return node; } switch (node.kind) { - case 216: + case 218: var binaryExpression = node; if (ts.isLogicalOrCoalescingAssignmentExpression(binaryExpression)) { return transformLogicalAssignment(binaryExpression); @@ -73335,6 +76313,28 @@ var ts; return factory.createBinaryExpression(left, nonAssignmentOperator, factory.createParenthesizedExpression(factory.createAssignment(assignmentTarget, right))); } } + ts.transformES2021 = transformES2021; +})(ts || (ts = {})); +var ts; +(function (ts) { + function transformESNext(context) { + return ts.chainBundle(context, transformSourceFile); + function transformSourceFile(node) { + if (node.isDeclarationFile) { + return node; + } + return ts.visitEachChild(node, visitor, context); + } + function visitor(node) { + if ((node.transformFlags & 4) === 0) { + return node; + } + switch (node.kind) { + default: + return ts.visitEachChild(node, visitor, context); + } + } + } ts.transformESNext = transformESNext; })(ts || (ts = {})); var ts; @@ -73434,13 +76434,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 273: + case 275: return visitJsxElement(node, false); - case 274: + case 276: return visitJsxSelfClosingElement(node, false); - case 277: + case 279: return visitJsxFragment(node, false); - case 283: + case 285: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -73450,13 +76450,13 @@ var ts; switch (node.kind) { case 11: return visitJsxText(node); - case 283: + case 285: return visitJsxExpression(node); - case 273: + case 275: return visitJsxElement(node, true); - case 274: + case 276: return visitJsxSelfClosingElement(node, true); - case 277: + case 279: return visitJsxFragment(node, true); default: return ts.Debug.failBadSyntaxKind(node); @@ -73560,15 +76560,23 @@ var ts; objectProperties = factory.createNull(); } else { - var segments = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread - ? ts.map(attrs, transformJsxSpreadAttributeToExpression) - : factory.createObjectLiteralExpression(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); })); - if (ts.isJsxSpreadAttribute(attrs[0])) { - segments.unshift(factory.createObjectLiteralExpression()); + var target = compilerOptions.target; + if (target && target >= 5) { + objectProperties = factory.createObjectLiteralExpression(ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { + return isSpread ? ts.map(attrs, transformJsxSpreadAttributeToSpreadAssignment) : ts.map(attrs, transformJsxAttributeToObjectLiteralElement); + }))); } - objectProperties = ts.singleOrUndefined(segments); - if (!objectProperties) { - objectProperties = emitHelpers().createAssignHelper(segments); + else { + var segments = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread + ? ts.map(attrs, transformJsxSpreadAttributeToExpression) + : factory.createObjectLiteralExpression(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); })); + if (ts.isJsxSpreadAttribute(attrs[0])) { + segments.unshift(factory.createObjectLiteralExpression()); + } + objectProperties = ts.singleOrUndefined(segments); + if (!objectProperties) { + objectProperties = emitHelpers().createAssignHelper(segments); + } } } var callee = currentFileState.importSpecifier === undefined @@ -73597,6 +76605,9 @@ var ts; } return element; } + function transformJsxSpreadAttributeToSpreadAssignment(node) { + return factory.createSpreadAssignment(ts.visitNode(node.expression, visitor, ts.isExpression)); + } function transformJsxSpreadAttributeToExpression(node) { return ts.visitNode(node.expression, visitor, ts.isExpression); } @@ -73614,7 +76625,7 @@ var ts; var literal = factory.createStringLiteral(tryDecodeEntities(node.text) || node.text, singleQuote); return ts.setTextRange(literal, node); } - else if (node.kind === 283) { + else if (node.kind === 285) { if (node.expression === undefined) { return factory.createTrue(); } @@ -73674,7 +76685,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 273) { + if (node.kind === 275) { return getTagName(node.openingElement); } else { @@ -73970,11 +76981,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 128) === 0) { + if ((node.transformFlags & 256) === 0) { return node; } switch (node.kind) { - case 216: + case 218: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -73982,7 +76993,7 @@ var ts; } function visitBinaryExpression(node) { switch (node.operatorToken.kind) { - case 66: + case 67: return visitExponentiationAssignmentExpression(node); case 42: return visitExponentiationExpression(node); @@ -74064,11 +77075,11 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return (hierarchyFacts & 8192) !== 0 - && node.kind === 242 + && node.kind === 244 && !node.expression; } function isOrMayContainReturnCompletion(node) { - return node.transformFlags & 1048576 + return node.transformFlags & 2097152 && (ts.isReturnStatement(node) || ts.isIfStatement(node) || ts.isWithStatement(node) @@ -74083,7 +77094,7 @@ var ts; || ts.isBlock(node)); } function shouldVisitNode(node) { - return (node.transformFlags & 256) !== 0 + return (node.transformFlags & 512) !== 0 || convertedLoopState !== undefined || (hierarchyFacts & 8192 && isOrMayContainReturnCompletion(node)) || (ts.isIterationStatement(node, false) && shouldConvertIterationStatement(node)) @@ -74096,74 +77107,74 @@ var ts; return shouldVisitNode(node) ? visitorWorker(node, true) : node; } function callExpressionVisitor(node) { - if (node.kind === 105) { + if (node.kind === 106) { return visitSuperKeyword(true); } return visitor(node); } function visitorWorker(node, expressionResultIsUnused) { switch (node.kind) { - case 123: + case 124: return undefined; - case 252: + case 254: return visitClassDeclaration(node); - case 221: + case 223: return visitClassExpression(node); - case 160: + case 162: return visitParameter(node); - case 251: + case 253: return visitFunctionDeclaration(node); - case 209: + case 211: return visitArrowFunction(node); - case 208: + case 210: return visitFunctionExpression(node); - case 249: + case 251: return visitVariableDeclaration(node); - case 78: + case 79: return visitIdentifier(node); - case 250: + case 252: return visitVariableDeclarationList(node); - case 244: + case 246: return visitSwitchStatement(node); - case 258: + case 260: return visitCaseBlock(node); - case 230: + case 232: return visitBlock(node, false); - case 241: - case 240: + case 243: + case 242: return visitBreakOrContinueStatement(node); - case 245: + case 247: return visitLabeledStatement(node); - case 235: - case 236: - return visitDoOrWhileStatement(node, undefined); case 237: - return visitForStatement(node, undefined); case 238: - return visitForInStatement(node, undefined); + return visitDoOrWhileStatement(node, undefined); case 239: + return visitForStatement(node, undefined); + case 240: + return visitForInStatement(node, undefined); + case 241: return visitForOfStatement(node, undefined); - case 233: + case 235: return visitExpressionStatement(node); - case 200: + case 202: return visitObjectLiteralExpression(node); - case 287: - return visitCatchClause(node); case 289: + return visitCatchClause(node); + case 291: return visitShorthandPropertyAssignment(node); - case 158: + case 160: return visitComputedPropertyName(node); - case 199: + case 201: return visitArrayLiteralExpression(node); - case 203: + case 205: return visitCallExpression(node); - case 204: + case 206: return visitNewExpression(node); - case 207: + case 209: return visitParenthesizedExpression(node, expressionResultIsUnused); - case 216: + case 218: return visitBinaryExpression(node, expressionResultIsUnused); - case 337: + case 345: return visitCommaListExpression(node, expressionResultIsUnused); case 14: case 15: @@ -74174,30 +77185,30 @@ var ts; return visitStringLiteral(node); case 8: return visitNumericLiteral(node); - case 205: + case 207: return visitTaggedTemplateExpression(node); - case 218: + case 220: return visitTemplateExpression(node); - case 219: + case 221: return visitYieldExpression(node); - case 220: + case 222: return visitSpreadElement(node); - case 105: + case 106: return visitSuperKeyword(false); - case 107: + case 108: return visitThisKeyword(node); - case 226: + case 228: return visitMetaProperty(node); - case 165: - return visitMethodDeclaration(node); case 167: - case 168: + return visitMethodDeclaration(node); + case 169: + case 170: return visitAccessorDeclaration(node); - case 232: + case 234: return visitVariableStatement(node); - case 242: + case 244: return visitReturnStatement(node); - case 212: + case 214: return visitVoidExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -74281,14 +77292,14 @@ var ts; } function visitBreakOrContinueStatement(node) { if (convertedLoopState) { - var jump = node.kind === 241 ? 2 : 4; + var jump = node.kind === 243 ? 2 : 4; 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 === 241) { + if (node.kind === 243) { convertedLoopState.nonLocalJumps |= 2; labelMarker = "break"; } @@ -74298,7 +77309,7 @@ var ts; } } else { - if (node.kind === 241) { + if (node.kind === 243) { labelMarker = "break-" + label.escapedText; setLabeledJump(convertedLoopState, true, ts.idText(label), labelMarker); } @@ -74432,7 +77443,7 @@ var ts; return block; } function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { - var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 103; + var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104; if (!constructor) return createDefaultConstructorBody(node, isDerivedClass); var prologue = []; @@ -74463,7 +77474,7 @@ var ts; factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment()); insertCaptureNewTargetIfNeeded(prologue, constructor, false); if (isDerivedClass) { - if (superCallExpression && statementOffset === constructor.body.statements.length && !(constructor.body.transformFlags & 4096)) { + if (superCallExpression && statementOffset === constructor.body.statements.length && !(constructor.body.transformFlags & 8192)) { var superCall = ts.cast(ts.cast(superCallExpression, ts.isBinaryExpression).left, ts.isCallExpression); var returnStatement = factory.createReturnStatement(superCallExpression); ts.setCommentRange(returnStatement, ts.getCommentRange(superCall)); @@ -74485,17 +77496,17 @@ var ts; return block; } function isSufficientlyCoveredByReturnStatements(statement) { - if (statement.kind === 242) { + if (statement.kind === 244) { return true; } - else if (statement.kind === 234) { + else if (statement.kind === 236) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 230) { + else if (statement.kind === 232) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -74578,9 +77589,9 @@ var ts; if (!shouldAddRestParameter(parameter, inConstructorWithSynthesizedSuper)) { return false; } - var declarationName = parameter.name.kind === 78 ? ts.setParent(ts.setTextRange(factory.cloneNode(parameter.name), parameter.name), parameter.name.parent) : factory.createTempVariable(undefined); + var declarationName = parameter.name.kind === 79 ? ts.setParent(ts.setTextRange(factory.cloneNode(parameter.name), parameter.name), parameter.name.parent) : factory.createTempVariable(undefined); ts.setEmitFlags(declarationName, 48); - var expressionName = parameter.name.kind === 78 ? factory.cloneNode(parameter.name) : declarationName; + var expressionName = parameter.name.kind === 79 ? factory.cloneNode(parameter.name) : declarationName; var restIndex = node.parameters.length - 1; var temp = factory.createLoopVariable(); prologueStatements.push(ts.setEmitFlags(ts.setTextRange(factory.createVariableStatement(undefined, factory.createVariableDeclarationList([ @@ -74596,14 +77607,14 @@ var ts; ts.setEmitFlags(forStatement, 1048576); ts.startOnNewLine(forStatement); prologueStatements.push(forStatement); - if (parameter.name.kind !== 78) { + if (parameter.name.kind !== 79) { prologueStatements.push(ts.setEmitFlags(ts.setTextRange(factory.createVariableStatement(undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0, expressionName))), parameter), 1048576)); } ts.insertStatementsAfterCustomPrologue(statements, prologueStatements); return true; } function insertCaptureThisForNodeIfNeeded(statements, node) { - if (hierarchyFacts & 32768 && node.kind !== 209) { + if (hierarchyFacts & 32768 && node.kind !== 211) { insertCaptureThisForNode(statements, node, factory.createThis()); return true; } @@ -74622,19 +77633,19 @@ var ts; if (hierarchyFacts & 16384) { var newTarget = void 0; switch (node.kind) { - case 209: + case 211: return statements; - case 165: case 167: - case 168: + case 169: + case 170: newTarget = factory.createVoidZero(); break; - case 166: + case 168: newTarget = factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4), "constructor"); break; - case 251: - case 208: - newTarget = factory.createConditionalExpression(factory.createLogicalAnd(ts.setEmitFlags(factory.createThis(), 4), factory.createBinaryExpression(ts.setEmitFlags(factory.createThis(), 4), 101, factory.getLocalName(node))), undefined, factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4), "constructor"), undefined, factory.createVoidZero()); + case 253: + case 210: + newTarget = factory.createConditionalExpression(factory.createLogicalAnd(ts.setEmitFlags(factory.createThis(), 4), factory.createBinaryExpression(ts.setEmitFlags(factory.createThis(), 4), 102, factory.getLocalName(node))), undefined, factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4), "constructor"), undefined, factory.createVoidZero()); break; default: return ts.Debug.failBadSyntaxKind(node); @@ -74654,20 +77665,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 229: + case 231: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 165: + case 167: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 167: - case 168: + case 169: + case 170: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 166: + case 168: break; default: ts.Debug.failBadSyntaxKind(member, currentSourceFile && currentSourceFile.fileName); @@ -74684,7 +77695,7 @@ var ts; var memberFunction = transformFunctionLikeToExpression(member, member, undefined, container); var propertyName = ts.visitNode(member.name, visitor, ts.isPropertyName); var e; - if (!ts.isPrivateIdentifier(propertyName) && context.getCompilerOptions().useDefineForClassFields) { + if (!ts.isPrivateIdentifier(propertyName) && ts.getUseDefineForClassFields(context.getCompilerOptions())) { var name = ts.isComputedPropertyName(propertyName) ? propertyName.expression : ts.isIdentifier(propertyName) ? factory.createStringLiteral(ts.unescapeLeadingUnderscores(propertyName.escapedText)) : propertyName; @@ -74749,7 +77760,7 @@ var ts; return call; } function visitArrowFunction(node) { - if (node.transformFlags & 4096) { + if (node.transformFlags & 8192) { hierarchyFacts |= 32768; } var savedConvertedLoopState = convertedLoopState; @@ -74802,7 +77813,7 @@ var ts; : enterSubtree(16286, 65); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 16384 && !name && (node.kind === 251 || node.kind === 208)) { + if (hierarchyFacts & 16384 && !name && (node.kind === 253 || node.kind === 210)) { name = factory.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152, 0); @@ -74835,7 +77846,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 209); + ts.Debug.assert(node.kind === 211); statementsLocation = ts.moveRangeEnd(body, -1); var equalsGreaterThanToken = node.equalsGreaterThanToken; if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) { @@ -74936,7 +77947,7 @@ var ts; assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0); } else { - assignment = factory.createBinaryExpression(decl.name, 62, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + assignment = factory.createBinaryExpression(decl.name, 63, ts.visitNode(decl.initializer, visitor, ts.isExpression)); ts.setTextRange(assignment, decl); } assignments = ts.append(assignments, assignment); @@ -74956,7 +77967,7 @@ var ts; return updated; } function visitVariableDeclarationList(node) { - if (node.flags & 3 || node.transformFlags & 131072) { + if (node.flags & 3 || node.transformFlags & 262144) { if (node.flags & 3) { enableSubstitutionsForBlockScopedBindings(); } @@ -74967,7 +77978,7 @@ var ts; ts.setOriginalNode(declarationList, node); ts.setTextRange(declarationList, node); ts.setCommentRange(declarationList, node); - if (node.transformFlags & 131072 + if (node.transformFlags & 262144 && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.last(node.declarations).name))) { ts.setSourceMapRange(declarationList, getRangeUnion(declarations)); } @@ -74977,8 +77988,8 @@ var ts; } function getRangeUnion(declarations) { var pos = -1, end = -1; - for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) { - var node = declarations_10[_i]; + for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { + var node = declarations_9[_i]; pos = pos === -1 ? node.pos : node.pos === -1 ? pos : Math.min(pos, node.pos); end = Math.max(end, node.end); } @@ -75039,14 +78050,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 235: - case 236: - return visitDoOrWhileStatement(node, outermostLabeledStatement); case 237: - return visitForStatement(node, outermostLabeledStatement); case 238: - return visitForInStatement(node, outermostLabeledStatement); + return visitDoOrWhileStatement(node, outermostLabeledStatement); case 239: + return visitForStatement(node, outermostLabeledStatement); + case 240: + return visitForInStatement(node, outermostLabeledStatement); + case 241: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -75169,9 +78180,9 @@ var ts; var numInitialProperties = -1, hasComputed = false; for (var i = 0; i < properties.length; i++) { var property = properties[i]; - if ((property.transformFlags & 262144 && + if ((property.transformFlags & 524288 && hierarchyFacts & 4) - || (hasComputed = ts.Debug.checkDefined(property.name).kind === 158)) { + || (hasComputed = ts.Debug.checkDefined(property.name).kind === 160)) { numInitialProperties = i; break; } @@ -75215,7 +78226,7 @@ var ts; } visit(node.name); function visit(node) { - if (node.kind === 78) { + if (node.kind === 79) { state.hoistedLocalVariables.push(node); } else { @@ -75264,24 +78275,24 @@ var ts; loop = convert(node, outermostLabeledStatement, bodyFunction.part, ancestorFacts); } else { - var clone_3 = convertIterationStatementCore(node, initializerFunction, factory.createBlock(bodyFunction.part, true)); - loop = factory.restoreEnclosingLabel(clone_3, outermostLabeledStatement, convertedLoopState && resetLabel); + var clone_4 = convertIterationStatementCore(node, initializerFunction, factory.createBlock(bodyFunction.part, true)); + loop = factory.restoreEnclosingLabel(clone_4, outermostLabeledStatement, convertedLoopState && resetLabel); } } else { - var clone_4 = convertIterationStatementCore(node, initializerFunction, ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - loop = factory.restoreEnclosingLabel(clone_4, outermostLabeledStatement, convertedLoopState && resetLabel); + var clone_5 = convertIterationStatementCore(node, initializerFunction, ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock)); + loop = factory.restoreEnclosingLabel(clone_5, outermostLabeledStatement, convertedLoopState && resetLabel); } statements.push(loop); return statements; } function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) { switch (node.kind) { - case 237: return convertForStatement(node, initializerFunction, convertedLoopBody); - case 238: return convertForInStatement(node, convertedLoopBody); - case 239: return convertForOfStatement(node, convertedLoopBody); - case 235: return convertDoStatement(node, convertedLoopBody); - case 236: return convertWhileStatement(node, convertedLoopBody); + case 239: return convertForStatement(node, initializerFunction, convertedLoopBody); + case 240: return convertForInStatement(node, convertedLoopBody); + case 241: return convertForOfStatement(node, convertedLoopBody); + case 237: return convertDoStatement(node, convertedLoopBody); + case 238: return convertWhileStatement(node, convertedLoopBody); default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected"); } } @@ -75305,11 +78316,11 @@ var ts; function createConvertedLoopState(node) { var loopInitializer; switch (node.kind) { - case 237: - case 238: case 239: + case 240: + case 241: var initializer = node.initializer; - if (initializer && initializer.kind === 250) { + if (initializer && initializer.kind === 252) { loopInitializer = initializer; } break; @@ -75393,7 +78404,7 @@ var ts; } function createFunctionForInitializerOfForStatement(node, currentState) { var functionName = factory.createUniqueName("_loop_init"); - var containsYield = (node.initializer.transformFlags & 262144) !== 0; + var containsYield = (node.initializer.transformFlags & 524288) !== 0; var emitFlags = 0; if (currentState.containsLexicalThis) emitFlags |= 8; @@ -75437,7 +78448,7 @@ var ts; var loopBody = factory.createBlock(statements, true); if (ts.isBlock(statement)) ts.setOriginalNode(loopBody, statement); - var containsYield = (node.statement.transformFlags & 262144) !== 0; + var containsYield = (node.statement.transformFlags & 524288) !== 0; var emitFlags = 524288; if (currentState.containsLexicalThis) emitFlags |= 8; @@ -75452,7 +78463,7 @@ var ts; function copyOutParameter(outParam, copyDirection) { var source = copyDirection === 0 ? outParam.outParamName : outParam.originalName; var target = copyDirection === 0 ? outParam.originalName : outParam.outParamName; - return factory.createBinaryExpression(target, 62, source); + return factory.createBinaryExpression(target, 63, source); } function copyOutParameters(outParams, partFlags, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { @@ -75573,20 +78584,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 167: - case 168: + case 169: + case 170: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 165: + case 167: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 288: + case 290: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 289: + case 291: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -75657,7 +78668,7 @@ var ts; var updated; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (node.kind === 167) { + if (node.kind === 169) { updated = factory.updateGetAccessorDeclaration(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); } else { @@ -75687,7 +78698,7 @@ var ts; return visitTypeScriptClassWrapper(node); } var expression = ts.skipOuterExpressions(node.expression); - if (expression.kind === 105 || + if (expression.kind === 106 || ts.isSuperProperty(expression) || ts.some(node.arguments, ts.isSpreadElement)) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, true); @@ -75738,21 +78749,21 @@ var ts; return visitCallExpressionWithPotentialCapturedThisAssignment(node, false); } function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) { - if (node.transformFlags & 8192 || - node.expression.kind === 105 || + if (node.transformFlags & 16384 || + node.expression.kind === 106 || ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) { var _a = factory.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 105) { + if (node.expression.kind === 106) { ts.setEmitFlags(thisArg, 4); } var resultingCall = void 0; - if (node.transformFlags & 8192) { - resultingCall = factory.createFunctionApplyCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 105 ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, false, false, false)); + if (node.transformFlags & 16384) { + resultingCall = factory.createFunctionApplyCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, false, false, false)); } else { - resultingCall = ts.setTextRange(factory.createFunctionCallCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 105 ? 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 ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression)), node); } - if (node.expression.kind === 105) { + if (node.expression.kind === 106) { var initializer = factory.createLogicalOr(resultingCall, createActualThis()); resultingCall = assignToCapturedThis ? factory.createAssignment(factory.createUniqueName("_this", 16 | 32), initializer) @@ -75864,7 +78875,7 @@ var ts; : factory.createUniqueName("_super", 16 | 32); } function visitMetaProperty(node) { - if (node.keywordToken === 102 && node.name.escapedText === "target") { + if (node.keywordToken === 103 && node.name.escapedText === "target") { hierarchyFacts |= 16384; return factory.createUniqueName("_newTarget", 16 | 32); } @@ -75884,20 +78895,20 @@ var ts; function enableSubstitutionsForBlockScopedBindings() { if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; - context.enableSubstitution(78); + context.enableSubstitution(79); } } function enableSubstitutionsForCapturedThis() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; - context.enableSubstitution(107); - context.enableEmitNotification(166); - context.enableEmitNotification(165); - context.enableEmitNotification(167); + context.enableSubstitution(108); context.enableEmitNotification(168); - context.enableEmitNotification(209); - context.enableEmitNotification(208); - context.enableEmitNotification(251); + context.enableEmitNotification(167); + context.enableEmitNotification(169); + context.enableEmitNotification(170); + context.enableEmitNotification(211); + context.enableEmitNotification(210); + context.enableEmitNotification(253); } } function onSubstituteNode(hint, node) { @@ -75921,10 +78932,10 @@ var ts; } function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 198: - case 252: - case 255: - case 249: + case 200: + case 254: + case 257: + case 251: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -75932,9 +78943,9 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 78: + case 79: return substituteExpressionIdentifier(node); - case 107: + case 108: return substituteThisKeyword(node); } return node; @@ -75985,19 +78996,19 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 233) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 235) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 203) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 205) { return false; } var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 105) { + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 106) { return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 220) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 222) { return false; } var expression = callArgument.expression; @@ -76016,24 +79027,24 @@ var ts; if (compilerOptions.jsx === 1 || compilerOptions.jsx === 3) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(275); + context.enableEmitNotification(277); + context.enableEmitNotification(278); context.enableEmitNotification(276); - context.enableEmitNotification(274); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(201); - context.enableSubstitution(288); + context.enableSubstitution(203); + context.enableSubstitution(290); return ts.chainBundle(context, transformSourceFile); function transformSourceFile(node) { return node; } function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 275: + case 277: + case 278: case 276: - case 274: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -76072,7 +79083,7 @@ var ts; } function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined); - if (token !== undefined && token >= 80 && token <= 115) { + if (token !== undefined && token >= 81 && token <= 116) { return ts.setTextRange(factory.createStringLiteralFromNode(name), name); } return undefined; @@ -76126,7 +79137,7 @@ var ts; var withBlockStack; return ts.chainBundle(context, transformSourceFile); function transformSourceFile(node) { - if (node.isDeclarationFile || (node.transformFlags & 512) === 0) { + if (node.isDeclarationFile || (node.transformFlags & 1024) === 0) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -76144,7 +79155,7 @@ var ts; else if (ts.isFunctionLikeDeclaration(node) && node.asteriskToken) { return visitGenerator(node); } - else if (transformFlags & 512) { + else if (transformFlags & 1024) { return ts.visitEachChild(node, visitor, context); } else { @@ -76153,13 +79164,13 @@ var ts; } function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 235: + case 237: return visitDoStatement(node); - case 236: + case 238: return visitWhileStatement(node); - case 244: + case 246: return visitSwitchStatement(node); - case 245: + case 247: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -76167,30 +79178,30 @@ var ts; } function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 251: + case 253: return visitFunctionDeclaration(node); - case 208: + case 210: return visitFunctionExpression(node); - case 167: - case 168: + case 169: + case 170: return visitAccessorDeclaration(node); - case 232: + case 234: return visitVariableStatement(node); - case 237: + case 239: return visitForStatement(node); - case 238: + case 240: return visitForInStatement(node); - case 241: + case 243: return visitBreakStatement(node); - case 240: - return visitContinueStatement(node); case 242: + return visitContinueStatement(node); + case 244: return visitReturnStatement(node); default: - if (node.transformFlags & 262144) { + if (node.transformFlags & 524288) { return visitJavaScriptContainingYield(node); } - else if (node.transformFlags & (512 | 1048576)) { + else if (node.transformFlags & (1024 | 2097152)) { return ts.visitEachChild(node, visitor, context); } else { @@ -76200,23 +79211,23 @@ var ts; } function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 216: + case 218: return visitBinaryExpression(node); - case 337: + case 345: return visitCommaListExpression(node); - case 217: - return visitConditionalExpression(node); case 219: + return visitConditionalExpression(node); + case 221: return visitYieldExpression(node); - case 199: + case 201: return visitArrayLiteralExpression(node); - case 200: - return visitObjectLiteralExpression(node); case 202: + return visitObjectLiteralExpression(node); + case 204: return visitElementAccessExpression(node); - case 203: + case 205: return visitCallExpression(node); - case 204: + case 206: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -76224,9 +79235,9 @@ var ts; } function visitGenerator(node) { switch (node.kind) { - case 251: + case 253: return visitFunctionDeclaration(node); - case 208: + case 210: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -76328,7 +79339,7 @@ var ts; return ts.setTextRange(factory.createBlock(statements, body.multiLine), body); } function visitVariableStatement(node) { - if (node.transformFlags & 262144) { + if (node.transformFlags & 524288) { transformAndEmitVariableDeclarationList(node.declarationList); return undefined; } @@ -76363,10 +79374,10 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 201: + case 203: target = factory.updatePropertyAccessExpression(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 202: + case 204: target = factory.updateElementAccessExpression(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), cacheExpression(ts.visitNode(left.argumentExpression, visitor, ts.isExpression))); break; default: @@ -76578,35 +79589,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 230: + case 232: return transformAndEmitBlock(node); - case 233: + case 235: return transformAndEmitExpressionStatement(node); - case 234: + case 236: return transformAndEmitIfStatement(node); - case 235: + case 237: return transformAndEmitDoStatement(node); - case 236: + case 238: return transformAndEmitWhileStatement(node); - case 237: + case 239: return transformAndEmitForStatement(node); - case 238: - return transformAndEmitForInStatement(node); case 240: + return transformAndEmitForInStatement(node); + case 242: return transformAndEmitContinueStatement(node); - case 241: + case 243: return transformAndEmitBreakStatement(node); - case 242: + case 244: return transformAndEmitReturnStatement(node); - case 243: + case 245: return transformAndEmitWithStatement(node); - case 244: + case 246: return transformAndEmitSwitchStatement(node); - case 245: + case 247: return transformAndEmitLabeledStatement(node); - case 246: + case 248: return transformAndEmitThrowStatement(node); - case 247: + case 249: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -76769,7 +79780,7 @@ var ts; var variables = ts.getInitializedVariables(initializer); node = factory.updateForStatement(node, variables.length > 0 ? factory.inlineExpressions(ts.map(variables, transformInitializedVariable)) - : undefined, ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitor, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock)); + : undefined, ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitor, ts.isExpression), ts.visitIterationBody(node.statement, visitor, context)); } else { node = ts.visitEachChild(node, visitor, context); @@ -76900,7 +79911,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 285 && defaultClauseIndex === -1) { + if (clause.kind === 287 && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -76910,7 +79921,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 284) { + if (clause.kind === 286) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -77001,7 +80012,7 @@ var ts; } } function containsYield(node) { - return !!node && (node.transformFlags & 262144) !== 0; + return !!node && (node.transformFlags & 524288) !== 0; } function countInitialNodesWithoutYield(nodes) { var numNodes = nodes.length; @@ -77033,10 +80044,10 @@ var ts; if (declaration) { var name = renamedCatchVariableDeclarations[ts.getOriginalNodeId(declaration)]; if (name) { - var clone_5 = ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent); - ts.setSourceMapRange(clone_5, node); - ts.setCommentRange(clone_5, node); - return clone_5; + var clone_6 = ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent); + ts.setSourceMapRange(clone_6, node); + ts.setCommentRange(clone_6, node); + return clone_6; } } } @@ -77145,7 +80156,7 @@ var ts; if (!renamedCatchVariables) { renamedCatchVariables = new ts.Map(); renamedCatchVariableDeclarations = []; - context.enableSubstitution(78); + context.enableSubstitution(79); } renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; @@ -77715,12 +80726,12 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(78); + context.enableSubstitution(79); + context.enableSubstitution(218); context.enableSubstitution(216); - context.enableSubstitution(214); - context.enableSubstitution(215); - context.enableSubstitution(289); - context.enableEmitNotification(297); + context.enableSubstitution(217); + context.enableSubstitution(291); + context.enableEmitNotification(299); var moduleInfoMap = []; var deferredExports = []; var currentSourceFile; @@ -77731,7 +80742,7 @@ var ts; function transformSourceFile(node) { if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || - node.transformFlags & 2097152 || + node.transformFlags & 4194304 || (ts.isJsonSourceFile(node) && ts.hasJsonModuleEmitEnabled(compilerOptions) && ts.outFile(compilerOptions)))) { return node; } @@ -77914,30 +80925,30 @@ var ts; } function sourceElementVisitor(node) { switch (node.kind) { - case 261: + case 263: return visitImportDeclaration(node); - case 260: + case 262: return visitImportEqualsDeclaration(node); - case 267: + case 269: return visitExportDeclaration(node); - case 266: + case 268: return visitExportAssignment(node); - case 232: + case 234: return visitVariableStatement(node); - case 251: + case 253: return visitFunctionDeclaration(node); - case 252: + case 254: return visitClassDeclaration(node); - case 338: + case 346: return visitMergeDeclarationMarker(node); - case 339: + case 347: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); } } function moduleExpressionElementVisitor(node) { - if (!(node.transformFlags & 2097152) && !(node.transformFlags & 1024)) { + if (!(node.transformFlags & 4194304) && !(node.transformFlags & 2048)) { return node; } if (ts.isImportCall(node)) { @@ -77955,24 +80966,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 288: + case 290: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 289: + case 291: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 290: + case 292: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 165: case 167: - case 168: + case 169: + case 170: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -78006,7 +81017,7 @@ var ts; var externalModuleName = ts.getExternalModuleNameLiteral(factory, node, currentSourceFile, host, resolver, compilerOptions); var firstArgument = ts.visitNode(ts.firstOrUndefined(node.arguments), moduleExpressionElementVisitor); var argument = externalModuleName && (!firstArgument || !ts.isStringLiteral(firstArgument) || firstArgument.text !== externalModuleName.text) ? externalModuleName : firstArgument; - var containsLexicalThis = !!(node.transformFlags & 4096); + var containsLexicalThis = !!(node.transformFlags & 8192); switch (compilerOptions.module) { case ts.ModuleKind.AMD: return createImportCallExpressionAMD(argument, containsLexicalThis); @@ -78324,7 +81335,7 @@ var ts; } } function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 232) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 234) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -78356,10 +81367,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 263: + case 265: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 264: + case 266: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding, true); @@ -78467,14 +81478,14 @@ var ts; } function modifierVisitor(node) { switch (node.kind) { - case 92: - case 87: + case 93: + case 88: return undefined; } return node; } function onEmitNode(hint, node, emitCallback) { - if (node.kind === 297) { + if (node.kind === 299) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -78514,12 +81525,12 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 78: + case 79: return substituteExpressionIdentifier(node); - case 216: + case 218: return substituteBinaryExpression(node); - case 215: - case 214: + case 217: + case 216: return substituteUnaryExpression(node); } return node; @@ -78533,9 +81544,9 @@ var ts; } return node; } - if (!(ts.isGeneratedIdentifier(node) && !(node.autoGenerateFlags & 64)) && !ts.isLocalName(node)) { + else if (!(ts.isGeneratedIdentifier(node) && !(node.autoGenerateFlags & 64)) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 297) { + if (exportContainer && exportContainer.kind === 299) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.cloneNode(node)), node); } var importDeclaration = resolver.getReferencedImportDeclaration(node); @@ -78578,14 +81589,20 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 215 - ? ts.setTextRange(factory.createBinaryExpression(node.operand, factory.createToken(node.operator === 45 ? 63 : 64), factory.createNumericLiteral(1)), node) + var expression = node.kind === 217 + ? ts.setTextRange(factory.createPrefixUnaryExpression(node.operator, node.operand), node) : node; for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) { var exportName = exportedNames_3[_i]; noSubstitution[ts.getNodeId(expression)] = true; expression = createExportExpression(exportName, expression); } + if (node.kind === 217) { + noSubstitution[ts.getNodeId(expression)] = true; + expression = node.operator === 45 + ? factory.createSubtract(expression, factory.createNumericLiteral(1)) + : factory.createAdd(expression, factory.createNumericLiteral(1)); + } return expression; } } @@ -78620,13 +81637,13 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(78); - context.enableSubstitution(289); + context.enableSubstitution(79); + context.enableSubstitution(291); + context.enableSubstitution(218); context.enableSubstitution(216); - context.enableSubstitution(214); - context.enableSubstitution(215); - context.enableSubstitution(226); - context.enableEmitNotification(297); + context.enableSubstitution(217); + context.enableSubstitution(228); + context.enableEmitNotification(299); var moduleInfoMap = []; var deferredExports = []; var exportFunctionsMap = []; @@ -78641,7 +81658,7 @@ var ts; var noSubstitution; return ts.chainBundle(context, transformSourceFile); function transformSourceFile(node) { - if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 2097152)) { + if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 4194304)) { return node; } var id = ts.getOriginalNodeId(node); @@ -78715,7 +81732,7 @@ var ts; ts.addRange(statements, hoistedStatements); ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); var exportStarFunction = addExportStarIfNeeded(statements); - var modifiers = node.transformFlags & 524288 ? + var modifiers = node.transformFlags & 1048576 ? factory.createModifiersFromModifierFlags(256) : undefined; var moduleObject = factory.createObjectLiteralExpression([ @@ -78733,7 +81750,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 267 && externalImport.exportClause) { + if (externalImport.kind === 269 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -78794,15 +81811,15 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(factory, entry, currentSourceFile); switch (entry.kind) { - case 261: + case 263: if (!entry.importClause) { break; } - case 260: + case 262: ts.Debug.assert(importVariableName !== undefined); statements.push(factory.createExpressionStatement(factory.createAssignment(importVariableName, parameterName))); break; - case 267: + case 269: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { if (ts.isNamedExports(entry.exportClause)) { @@ -78832,13 +81849,13 @@ var ts; } function sourceElementVisitor(node) { switch (node.kind) { - case 261: + case 263: return visitImportDeclaration(node); - case 260: + case 262: return visitImportEqualsDeclaration(node); - case 267: + case 269: return visitExportDeclaration(node); - case 266: + case 268: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -78963,7 +81980,7 @@ var ts; } function shouldHoistVariableDeclarationList(node) { return (ts.getEmitFlags(node) & 2097152) === 0 - && (enclosingBlockScopedContainer.kind === 297 + && (enclosingBlockScopedContainer.kind === 299 || (ts.getOriginalNode(node).flags & 3) === 0); } function transformInitializedVariable(node, isExportedDeclaration) { @@ -78985,7 +82002,7 @@ var ts; : preventSubstitution(ts.setTextRange(factory.createAssignment(name, value), location)); } function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 232) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 234) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasSyntacticModifier(node.original, 1); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -79024,10 +82041,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 263: + case 265: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 264: + case 266: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -79127,43 +82144,43 @@ var ts; } function nestedElementVisitor(node) { switch (node.kind) { - case 232: + case 234: return visitVariableStatement(node); - case 251: + case 253: return visitFunctionDeclaration(node); - case 252: + case 254: return visitClassDeclaration(node); - case 237: + case 239: return visitForStatement(node); - case 238: + case 240: return visitForInStatement(node); - case 239: + case 241: return visitForOfStatement(node); - case 235: + case 237: return visitDoStatement(node); - case 236: + case 238: return visitWhileStatement(node); - case 245: + case 247: return visitLabeledStatement(node); - case 243: + case 245: return visitWithStatement(node); - case 244: + case 246: return visitSwitchStatement(node); - case 258: + case 260: return visitCaseBlock(node); - case 284: + case 286: return visitCaseClause(node); - case 285: + case 287: return visitDefaultClause(node); - case 247: + case 249: return visitTryStatement(node); - case 287: + case 289: return visitCatchClause(node); - case 230: + case 232: return visitBlock(node); - case 338: + case 346: return visitMergeDeclarationMarker(node); - case 339: + case 347: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -79172,21 +82189,21 @@ var ts; function visitForStatement(node) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = factory.updateForStatement(node, node.initializer && visitForInitializer(node.initializer), ts.visitNode(node.condition, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.incrementor, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement)); + node = factory.updateForStatement(node, node.initializer && visitForInitializer(node.initializer), ts.visitNode(node.condition, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.incrementor, destructuringAndImportCallVisitor, ts.isExpression), ts.visitIterationBody(node.statement, nestedElementVisitor, context)); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } function visitForInStatement(node) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = factory.updateForInStatement(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock)); + node = factory.updateForInStatement(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitIterationBody(node.statement, nestedElementVisitor, context)); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } function visitForOfStatement(node) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = factory.updateForOfStatement(node, node.awaitModifier, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock)); + node = factory.updateForOfStatement(node, node.awaitModifier, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitIterationBody(node.statement, nestedElementVisitor, context)); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } @@ -79211,10 +82228,10 @@ var ts; } } function visitDoStatement(node) { - return factory.updateDoStatement(node, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression)); + return factory.updateDoStatement(node, ts.visitIterationBody(node.statement, nestedElementVisitor, context), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression)); } function visitWhileStatement(node) { - return factory.updateWhileStatement(node, ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock)); + return factory.updateWhileStatement(node, ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitIterationBody(node.statement, nestedElementVisitor, context)); } function visitLabeledStatement(node) { return factory.updateLabeledStatement(node, node.label, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock)); @@ -79262,7 +82279,7 @@ var ts; else if (ts.isImportCall(node)) { return visitImportCallExpression(node); } - else if ((node.transformFlags & 1024) || (node.transformFlags & 2097152)) { + else if ((node.transformFlags & 2048) || (node.transformFlags & 4194304)) { return ts.visitEachChild(node, destructuringAndImportCallVisitor, context); } else { @@ -79302,7 +82319,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 297; + return container !== undefined && container.kind === 299; } else { return false; @@ -79310,14 +82327,14 @@ var ts; } function modifierVisitor(node) { switch (node.kind) { - case 92: - case 87: + case 93: + case 88: return undefined; } return node; } function onEmitNode(hint, node, emitCallback) { - if (node.kind === 297) { + if (node.kind === 299) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -79353,7 +82370,7 @@ var ts; } function substituteUnspecified(node) { switch (node.kind) { - case 289: + case 291: return substituteShorthandPropertyAssignment(node); } return node; @@ -79376,14 +82393,14 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 78: + case 79: return substituteExpressionIdentifier(node); - case 216: + case 218: return substituteBinaryExpression(node); - case 214: - case 215: + case 216: + case 217: return substituteUnaryExpression(node); - case 226: + case 228: return substituteMetaProperty(node); } return node; @@ -79436,14 +82453,14 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 215 + var expression = node.kind === 217 ? ts.setTextRange(factory.createPrefixUnaryExpression(node.operator, node.operand), node) : node; for (var _i = 0, exportedNames_5 = exportedNames; _i < exportedNames_5.length; _i++) { var exportName = exportedNames_5[_i]; expression = createExportExpression(exportName, preventSubstitution(expression)); } - if (node.kind === 215) { + if (node.kind === 217) { expression = node.operator === 45 ? factory.createSubtract(preventSubstitution(expression), factory.createNumericLiteral(1)) : factory.createAdd(preventSubstitution(expression), factory.createNumericLiteral(1)); @@ -79466,7 +82483,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, false); - if (exportContainer && exportContainer.kind === 297) { + if (exportContainer && exportContainer.kind === 299) { exportedNames = ts.append(exportedNames, factory.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -79495,8 +82512,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(297); - context.enableSubstitution(78); + context.enableEmitNotification(299); + context.enableSubstitution(79); var helperNameSubstitutions; return ts.chainBundle(context, transformSourceFile); function transformSourceFile(node) { @@ -79527,11 +82544,11 @@ var ts; } function visitor(node) { switch (node.kind) { - case 260: + case 262: return undefined; - case 266: + case 268: return visitExportAssignment(node); - case 267: + case 269: var exportDecl = node; return visitExportDeclaration(exportDecl); } @@ -79606,7 +82623,8 @@ var ts; ts.isTypeAliasDeclaration(node) || ts.isConstructorDeclaration(node) || ts.isIndexSignatureDeclaration(node) || - ts.isPropertyAccessExpression(node); + ts.isPropertyAccessExpression(node) || + ts.isJSDocTypeAlias(node); } ts.canProduceDiagnostics = canProduceDiagnostics; function createGetSymbolAccessibilityDiagnosticForNodeName(node) { @@ -79635,7 +82653,7 @@ var ts; 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 === 252) { + else if (node.parent.kind === 254) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -79664,7 +82682,7 @@ var ts; 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 === 252) { + else if (node.parent.kind === 254) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -79704,22 +82722,22 @@ var ts; else if (ts.isImportEqualsDeclaration(node)) { return getImportEntityNameVisibilityError; } - else if (ts.isTypeAliasDeclaration(node)) { + else if (ts.isTypeAliasDeclaration(node) || ts.isJSDocTypeAlias(node)) { return getTypeAliasDeclarationVisibilityError; } else { return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]); } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 249 || node.kind === 198) { + if (node.kind === 251 || node.kind === 200) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? 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; } - else if (node.kind === 163 || node.kind === 201 || node.kind === 162 || - (node.kind === 160 && ts.hasSyntacticModifier(node.parent, 8))) { + else if (node.kind === 165 || node.kind === 203 || node.kind === 164 || + (node.kind === 162 && ts.hasSyntacticModifier(node.parent, 8))) { if (ts.hasSyntacticModifier(node, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -79727,7 +82745,7 @@ var ts; 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 === 252 || node.kind === 160) { + else if (node.parent.kind === 254 || node.kind === 162) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -79751,7 +82769,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 168) { + if (node.kind === 170) { if (ts.hasSyntacticModifier(node, 32)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 : @@ -79788,23 +82806,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 170: + case 172: 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 169: + case 171: 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 171: + case 173: 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 165: - case 164: + case 167: + case 166: if (ts.hasSyntacticModifier(node, 32)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -79812,7 +82830,7 @@ var ts; 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 === 252) { + else if (node.parent.kind === 254) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -79825,7 +82843,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 251: + case 253: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -79850,27 +82868,27 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 166: + case 168: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? 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 170: - case 175: + case 172: + case 177: 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 169: + case 171: 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 171: + case 173: 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 165: - case 164: + case 167: + case 166: if (ts.hasSyntacticModifier(node.parent, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -79878,7 +82896,7 @@ var ts; 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 === 252) { + else if (node.parent.parent.kind === 254) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -79890,15 +82908,15 @@ 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 251: - case 174: + case 253: + case 176: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? 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 168: - case 167: + case 170: + case 169: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -79911,39 +82929,39 @@ var ts; function getTypeParameterConstraintVisibilityError() { var diagnosticMessage; switch (node.parent.kind) { - case 252: + case 254: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 253: + case 255: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 190: + case 192: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1; break; - case 175: - case 170: + case 177: + case 172: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 169: + case 171: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 165: - case 164: + case 167: + case 166: if (ts.hasSyntacticModifier(node.parent, 32)) { 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 === 252) { + else if (node.parent.parent.kind === 254) { 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 174: - case 251: + case 176: + case 253: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 254: + case 256: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -79958,7 +82976,7 @@ var ts; function getHeritageClauseVisibilityError() { var diagnosticMessage; if (ts.isClassDeclaration(node.parent.parent)) { - diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 116 ? + diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 117 ? 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; @@ -79979,11 +82997,13 @@ var ts; typeName: node.name }; } - function getTypeAliasDeclarationVisibilityError() { + function getTypeAliasDeclarationVisibilityError(symbolAccessibilityResult) { return { - diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, - errorNode: node.type, - typeName: node.name + diagnosticMessage: symbolAccessibilityResult.errorModuleName + ? ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1_from_module_2 + : ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, + errorNode: ts.isJSDocTypeAlias(node) ? ts.Debug.checkDefined(node.typeExpression) : node.type, + typeName: ts.isJSDocTypeAlias(node) ? ts.getNameOfDeclaration(node) : node.name, }; } } @@ -80003,7 +83023,7 @@ var ts; } function isInternalDeclaration(node, currentSourceFile) { var parseTreeNode = ts.getParseTreeNode(node); - if (parseTreeNode && parseTreeNode.kind === 160) { + if (parseTreeNode && parseTreeNode.kind === 162) { var paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode); var previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : undefined; var text = currentSourceFile.text; @@ -80055,6 +83075,7 @@ var ts; reportNonlocalAugmentation: reportNonlocalAugmentation }; var errorNameNode; + var errorFallbackNode; var currentSourceFile; var refs; var libs; @@ -80104,8 +83125,10 @@ var ts; else { context.addDiagnostic(ts.createDiagnosticForNode(symbolAccessibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, symbolAccessibilityResult.errorSymbolName, symbolAccessibilityResult.errorModuleName)); } + return true; } } + return false; } function trackExternalModuleSymbolOfImportTypeNode(symbol) { if (!isBundledEmit) { @@ -80114,13 +83137,14 @@ var ts; } function trackSymbol(symbol, enclosingDeclaration, meaning) { if (symbol.flags & 262144) - return; - handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, true)); + return false; + var issuedDiagnostic = handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, true)); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForSymbol(symbol, meaning)); + return issuedDiagnostic; } function reportPrivateInBaseOfClassExpression(propertyName) { - if (errorNameNode) { - context.addDiagnostic(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.Property_0_of_exported_class_expression_may_not_be_private_or_protected, propertyName)); + if (errorNameNode || errorFallbackNode) { + context.addDiagnostic(ts.createDiagnosticForNode((errorNameNode || errorFallbackNode), ts.Diagnostics.Property_0_of_exported_class_expression_may_not_be_private_or_protected, propertyName)); } } function reportInaccessibleUniqueSymbolError() { @@ -80144,35 +83168,38 @@ var ts; } } function reportTruncationError() { - if (errorNameNode) { - context.addDiagnostic(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_this_node_exceeds_the_maximum_length_the_compiler_will_serialize_An_explicit_type_annotation_is_needed)); + if (errorNameNode || errorFallbackNode) { + context.addDiagnostic(ts.createDiagnosticForNode((errorNameNode || errorFallbackNode), ts.Diagnostics.The_inferred_type_of_this_node_exceeds_the_maximum_length_the_compiler_will_serialize_An_explicit_type_annotation_is_needed)); } } function reportNonlocalAugmentation(containingFile, parentSymbol, symbol) { - var primaryDeclaration = ts.find(parentSymbol.declarations, function (d) { return ts.getSourceFileOfNode(d) === containingFile; }); + var _a; + var primaryDeclaration = (_a = parentSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.getSourceFileOfNode(d) === containingFile; }); var augmentingDeclarations = ts.filter(symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== containingFile; }); - for (var _i = 0, augmentingDeclarations_1 = augmentingDeclarations; _i < augmentingDeclarations_1.length; _i++) { - var augmentations = augmentingDeclarations_1[_i]; - context.addDiagnostic(ts.addRelatedInfo(ts.createDiagnosticForNode(augmentations, ts.Diagnostics.Declaration_augments_declaration_in_another_file_This_cannot_be_serialized), ts.createDiagnosticForNode(primaryDeclaration, ts.Diagnostics.This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_file))); + if (augmentingDeclarations) { + for (var _i = 0, augmentingDeclarations_1 = augmentingDeclarations; _i < augmentingDeclarations_1.length; _i++) { + var augmentations = augmentingDeclarations_1[_i]; + context.addDiagnostic(ts.addRelatedInfo(ts.createDiagnosticForNode(augmentations, ts.Diagnostics.Declaration_augments_declaration_in_another_file_This_cannot_be_serialized), ts.createDiagnosticForNode(primaryDeclaration, ts.Diagnostics.This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_file))); + } } } function transformDeclarationsForJS(sourceFile, bundled) { var oldDiag = getSymbolAccessibilityDiagnostic; - getSymbolAccessibilityDiagnostic = function (s) { return ({ + getSymbolAccessibilityDiagnostic = function (s) { return (s.errorNode && ts.canProduceDiagnostics(s.errorNode) ? ts.createGetSymbolAccessibilityDiagnosticForNode(s.errorNode)(s) : ({ diagnosticMessage: s.errorModuleName ? ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit : ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit, errorNode: s.errorNode || sourceFile - }); }; + })); }; var result = resolver.getDeclarationStatementsForSourceFile(sourceFile, declarationEmitNodeBuilderFlags, symbolTracker, bundled); getSymbolAccessibilityDiagnostic = oldDiag; return result; } function transformRoot(node) { - if (node.kind === 297 && node.isDeclarationFile) { + if (node.kind === 299 && node.isDeclarationFile) { return node; } - if (node.kind === 298) { + if (node.kind === 300) { isBundledEmit = true; refs = new ts.Map(); libs = new ts.Map(); @@ -80195,14 +83222,14 @@ var ts; resultHasExternalModuleIndicator = false; needsDeclare = false; var statements = ts.isSourceFileJS(sourceFile) ? factory.createNodeArray(transformDeclarationsForJS(sourceFile, true)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements); - var newFile = factory.updateSourceFile(sourceFile, [factory.createModuleDeclaration([], [factory.createModifier(133)], factory.createStringLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), factory.createModuleBlock(ts.setTextRange(factory.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), sourceFile.statements)))], true, [], [], false, []); + var newFile = factory.updateSourceFile(sourceFile, [factory.createModuleDeclaration([], [factory.createModifier(134)], factory.createStringLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), factory.createModuleBlock(ts.setTextRange(factory.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), sourceFile.statements)))], true, [], [], false, []); return newFile; } needsDeclare = true; var updated = ts.isSourceFileJS(sourceFile) ? factory.createNodeArray(transformDeclarationsForJS(sourceFile)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return factory.updateSourceFile(sourceFile, transformAndReplaceLatePaintedStatements(updated), true, [], [], false, []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 300) { + if (prepend.kind === 302) { var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal); hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib; collectReferences(sourceFile, refs); @@ -80292,7 +83319,7 @@ var ts; declFileName = paths.declarationFilePath || paths.jsFilePath || file.fileName; } if (declFileName) { - var specifier = ts.moduleSpecifiers.getModuleSpecifier(__assign(__assign({}, options), { baseUrl: options.baseUrl && ts.toPath(options.baseUrl, host.getCurrentDirectory(), host.getCanonicalFileName) }), currentSourceFile, ts.toPath(outputFilePath, host.getCurrentDirectory(), host.getCanonicalFileName), ts.toPath(declFileName, host.getCurrentDirectory(), host.getCanonicalFileName), host, undefined); + var specifier = ts.moduleSpecifiers.getModuleSpecifier(options, currentSourceFile, ts.toPath(outputFilePath, host.getCurrentDirectory(), host.getCanonicalFileName), ts.toPath(declFileName, host.getCurrentDirectory(), host.getCanonicalFileName), host, undefined); if (!ts.pathIsRelative(specifier)) { recordTypeReferenceDirectivesIfNecessary([specifier]); return; @@ -80330,11 +83357,11 @@ var ts; return ret; } function filterBindingPatternInitializers(name) { - if (name.kind === 78) { + if (name.kind === 79) { return name; } else { - if (name.kind === 197) { + if (name.kind === 199) { return factory.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -80342,7 +83369,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 222) { + if (elem.kind === 224) { return elem; } return factory.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); @@ -80376,17 +83403,17 @@ var ts; if (shouldPrintWithInitializer(node)) { return; } - var shouldUseResolverType = node.kind === 160 && + var shouldUseResolverType = node.kind === 162 && (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(128); + return type ? ts.visitNode(type, visitDeclarationSubtree) : factory.createKeywordTypeNode(129); } - if (node.kind === 168) { - return factory.createKeywordTypeNode(128); + if (node.kind === 170) { + return factory.createKeywordTypeNode(129); } errorNameNode = node.name; var oldDiag; @@ -80394,12 +83421,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 249 || node.kind === 198) { + if (node.kind === 251 || node.kind === 200) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 160 - || node.kind === 163 - || node.kind === 162) { + if (node.kind === 162 + || node.kind === 165 + || node.kind === 164) { if (!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)); @@ -80410,29 +83437,37 @@ var ts; if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } - return returnValue || factory.createKeywordTypeNode(128); + return returnValue || factory.createKeywordTypeNode(129); } } function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 251: - case 256: case 253: - case 252: - case 254: + case 258: case 255: + case 254: + case 256: + case 257: return !resolver.isDeclarationVisible(node); - case 249: + case 251: return !getBindingNameVisible(node); - case 260: - case 261: - case 267: - case 266: + case 262: + case 263: + case 269: + case 268: return false; } return false; } + function shouldEmitFunctionProperties(input) { + var _a; + if (input.body) { + return true; + } + var overloadSignatures = (_a = input.symbol.declarations) === null || _a === void 0 ? void 0 : _a.filter(function (decl) { return ts.isFunctionDeclaration(decl) && !decl.body; }); + return !overloadSignatures || overloadSignatures.indexOf(input) === overloadSignatures.length - 1; + } function getBindingNameVisible(elem) { if (ts.isOmittedExpression(elem)) { return false; @@ -80505,7 +83540,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 256 && parent.kind !== 195); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 258 && parent.kind !== 197); if (ts.isStringLiteralLike(input)) { if (isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); @@ -80525,7 +83560,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 272) { + if (decl.moduleReference.kind === 274) { var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return factory.updateImportEqualsDeclaration(decl, undefined, decl.modifiers, decl.isTypeOnly, decl.name, factory.updateExternalModuleReference(decl.moduleReference, rewriteModuleSpecifier(decl, specifier))); } @@ -80545,7 +83580,7 @@ var ts; if (!decl.importClause.namedBindings) { return visibleDefaultBinding && factory.updateImportDeclaration(decl, undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier)); } - if (decl.importClause.namedBindings.kind === 263) { + if (decl.importClause.namedBindings.kind === 265) { var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : undefined; return visibleDefaultBinding || namedBindings ? factory.updateImportDeclaration(decl, undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier)) : undefined; } @@ -80612,7 +83647,7 @@ var ts; var oldDiag = getSymbolAccessibilityDiagnostic; var canProduceDiagnostic = ts.canProduceDiagnostics(input); var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 177 || input.kind === 190) && input.parent.kind !== 254); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 179 || input.kind === 192) && input.parent.kind !== 256); if (ts.isMethodDeclaration(input) || ts.isMethodSignature(input)) { if (ts.hasEffectiveModifier(input, 8)) { if (input.symbol && input.symbol.declarations && input.symbol.declarations[0] !== input) @@ -80631,67 +83666,67 @@ var ts; } if (isProcessedComponent(input)) { switch (input.kind) { - case 223: { + case 225: { 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 173: { + case 175: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(factory.updateTypeReferenceNode(node, node.typeName, node.typeArguments)); } - case 170: + case 172: return cleanup(factory.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 166: { + case 168: { var ctor = factory.createConstructorDeclaration(undefined, ensureModifiers(input), updateParamsList(input, input.parameters, 0), undefined); return cleanup(ctor); } - case 165: { + case 167: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(undefined); } var sig = factory.createMethodDeclaration(undefined, ensureModifiers(input), undefined, input.name, input.questionToken, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), undefined); return cleanup(sig); } - case 167: { + case 169: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(undefined); } var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); return cleanup(factory.updateGetAccessorDeclaration(input, undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8)), ensureType(input, accessorType), undefined)); } - case 168: { + case 170: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(undefined); } return cleanup(factory.updateSetAccessorDeclaration(input, undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8)), undefined)); } - case 163: + case 165: if (ts.isPrivateIdentifier(input.name)) { return cleanup(undefined); } return cleanup(factory.updatePropertyDeclaration(input, undefined, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type), ensureNoInitializer(input))); - case 162: + case 164: if (ts.isPrivateIdentifier(input.name)) { return cleanup(undefined); } return cleanup(factory.updatePropertySignature(input, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type))); - case 164: { + case 166: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(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 169: { + case 171: { return cleanup(factory.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 171: { - return cleanup(factory.updateIndexSignature(input, undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || factory.createKeywordTypeNode(128))); + case 173: { + return cleanup(factory.updateIndexSignature(input, undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || factory.createKeywordTypeNode(129))); } - case 249: { + case 251: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -80699,13 +83734,13 @@ var ts; suppressNewDiagnosticContexts = true; return cleanup(factory.updateVariableDeclaration(input, input.name, undefined, ensureType(input, input.type), ensureNoInitializer(input))); } - case 159: { + case 161: { if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) { return cleanup(factory.updateTypeParameterDeclaration(input, input.name, undefined, undefined)); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 184: { + case 186: { var checkType = ts.visitNode(input.checkType, visitDeclarationSubtree); var extendsType = ts.visitNode(input.extendsType, visitDeclarationSubtree); var oldEnclosingDecl = enclosingDeclaration; @@ -80715,13 +83750,13 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(factory.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 174: { + case 176: { return cleanup(factory.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 175: { + case 177: { return cleanup(factory.updateConstructorTypeNode(input, ensureModifiers(input), ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 195: { + case 197: { if (!ts.isLiteralImportTypeNode(input)) return cleanup(input); return cleanup(factory.updateImportTypeNode(input, factory.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); @@ -80753,7 +83788,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 165 && ts.hasEffectiveModifier(node.parent, 8); + return node.parent.kind === 167 && ts.hasEffectiveModifier(node.parent, 8); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -80762,19 +83797,19 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 267: { + case 269: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } resultHasScopeMarker = true; return factory.updateExportDeclaration(input, undefined, input.modifiers, input.isTypeOnly, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 266: { + case 268: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } resultHasScopeMarker = true; - if (input.expression.kind === 78) { + if (input.expression.kind === 79) { return input; } else { @@ -80783,8 +83818,10 @@ var ts; diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0, errorNode: input }); }; + errorFallbackNode = input; var varDecl = factory.createVariableDeclaration(newId, undefined, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), undefined); - var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(133)] : [], factory.createVariableDeclarationList([varDecl], 2)); + errorFallbackNode = undefined; + var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(134)] : [], factory.createVariableDeclarationList([varDecl], 2)); return [statement, factory.updateExportAssignment(input, input.decorators, input.modifiers, newId)]; } } @@ -80797,17 +83834,17 @@ var ts; if (ts.isImportEqualsDeclaration(statement) || ts.hasEffectiveModifier(statement, 512) || !ts.canHaveModifiers(statement)) { return statement; } - var modifiers = factory.createModifiersFromModifierFlags(ts.getEffectiveModifierFlags(statement) & (11263 ^ 1)); + var modifiers = factory.createModifiersFromModifierFlags(ts.getEffectiveModifierFlags(statement) & (27647 ^ 1)); return factory.updateModifiers(statement, modifiers); } function transformTopLevelDeclaration(input) { if (shouldStripInternal(input)) return; switch (input.kind) { - case 260: { + case 262: { return transformImportEqualsDeclaration(input); } - case 261: { + case 263: { return transformImportDeclaration(input); } } @@ -80827,14 +83864,14 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 254: + case 256: return cleanup(factory.updateTypeAliasDeclaration(input, undefined, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 253: { + case 255: { return cleanup(factory.updateInterfaceDeclaration(input, undefined, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 251: { + case 253: { var clean = cleanup(factory.updateFunctionDeclaration(input, undefined, ensureModifiers(input), undefined, input.name, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), undefined)); - if (clean && resolver.isExpandoFunctionDeclaration(input)) { + if (clean && resolver.isExpandoFunctionDeclaration(input) && shouldEmitFunctionProperties(input)) { var props = resolver.getPropertiesOfContainerFunction(input); var fakespace_1 = ts.parseNodeFactory.createModuleDeclaration(undefined, undefined, clean.name || factory.createIdentifier("_default"), factory.createModuleBlock([]), 16); ts.setParent(fakespace_1, enclosingDeclaration); @@ -80842,7 +83879,7 @@ var ts; fakespace_1.symbol = props[0].parent; var exportMappings_1 = []; var declarations = ts.mapDefined(props, function (p) { - if (!ts.isPropertyAccessExpression(p.valueDeclaration)) { + if (!p.valueDeclaration || !ts.isPropertyAccessExpression(p.valueDeclaration)) { return undefined; } getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p.valueDeclaration); @@ -80855,7 +83892,7 @@ var ts; exportMappings_1.push([name, nameStr]); } var varDecl = factory.createVariableDeclaration(name, undefined, type, undefined); - return factory.createVariableStatement(isNonContextualKeywordName ? undefined : [factory.createToken(92)], factory.createVariableDeclarationList([varDecl])); + return factory.createVariableStatement(isNonContextualKeywordName ? undefined : [factory.createToken(93)], factory.createVariableDeclarationList([varDecl])); }); if (!exportMappings_1.length) { declarations = ts.mapDefined(declarations, function (declaration) { return factory.updateModifiers(declaration, 0); }); @@ -80884,10 +83921,10 @@ var ts; return clean; } } - case 256: { + case 258: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 257) { + if (inner && inner.kind === 259) { var oldNeedsScopeFix = needsScopeFixMarker; var oldHasScopeFix = resultHasScopeMarker; resultHasScopeMarker = false; @@ -80923,7 +83960,9 @@ var ts; return cleanup(factory.updateModuleDeclaration(input, undefined, mods, input.name, body)); } } - case 252: { + case 254: { + errorNameNode = input.name; + errorFallbackNode = input; var modifiers = factory.createNodeArray(ensureModifiers(input)); var typeParameters = ensureTypeParams(input, input.typeParameters); var ctor = ts.getFirstConstructorWithBody(input); @@ -80931,10 +83970,10 @@ var ts; if (ctor) { var oldDiag_1 = getSymbolAccessibilityDiagnostic; parameterProperties = ts.compact(ts.flatMap(ctor.parameters, function (param) { - if (!ts.hasSyntacticModifier(param, 92) || shouldStripInternal(param)) + if (!ts.hasSyntacticModifier(param, 16476) || shouldStripInternal(param)) return; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(param); - if (param.name.kind === 78) { + if (param.name.kind === 79) { return preserveJsDoc(factory.createPropertyDeclaration(undefined, ensureModifiers(param), param.name, param.questionToken, ensureType(param, param.type), ensureNoInitializer(param)), param); } else { @@ -80964,7 +84003,7 @@ 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 !== 103) { + 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); getSymbolAccessibilityDiagnostic = function () { return ({ @@ -80973,16 +84012,16 @@ var ts; typeName: input.name }); }; var varDecl = factory.createVariableDeclaration(newId_1, undefined, resolver.createTypeOfExpression(extendsClause_1.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), undefined); - var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(133)] : [], factory.createVariableDeclarationList([varDecl], 2)); + var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(134)] : [], factory.createVariableDeclarationList([varDecl], 2)); var heritageClauses = factory.createNodeArray(ts.map(input.heritageClauses, function (clause) { - if (clause.token === 93) { + if (clause.token === 94) { 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 === 103; })), visitDeclarationSubtree)); + return factory.updateHeritageClause(clause, ts.visitNodes(factory.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 104; })), visitDeclarationSubtree)); })); return [statement, cleanup(factory.updateClassDeclaration(input, undefined, modifiers, input.name, typeParameters, heritageClauses, members))]; } @@ -80991,10 +84030,10 @@ var ts; return cleanup(factory.updateClassDeclaration(input, undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 232: { + case 234: { return cleanup(transformVariableStatement(input)); } - case 255: { + case 257: { return cleanup(factory.updateEnumDeclaration(input, undefined, factory.createNodeArray(ensureModifiers(input)), input.name, factory.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -81011,12 +84050,14 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 256) { + if (input.kind === 258) { needsDeclare = previousNeedsDeclare; } if (node === input) { return node; } + errorFallbackNode = undefined; + errorNameNode = undefined; return node && ts.setOriginalNode(preserveJsDoc(node, input), input); } } @@ -81032,7 +84073,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 222) { + if (e.kind === 224) { return; } if (e.name) { @@ -81080,9 +84121,9 @@ var ts; return factory.createModifiersFromModifierFlags(newFlags); } function ensureModifierFlags(node) { - var mask = 11263 ^ (4 | 256); + var mask = 27647 ^ (4 | 256 | 16384); var additions = (needsDeclare && !isAlwaysType(node)) ? 2 : 0; - var parentIsFile = node.parent.kind === 297; + var parentIsFile = node.parent.kind === 299; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= 2; additions = 0; @@ -81103,13 +84144,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 === 93 && t.expression.kind === 103); + return ts.isEntityNameExpression(t.expression) || (clause.token === 94 && t.expression.kind === 104); })), visitDeclarationSubtree)); }), function (clause) { return clause.types && !!clause.types.length; })); } } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 253) { + if (node.kind === 255) { return true; } return false; @@ -81118,7 +84159,7 @@ var ts; return ts.factory.createModifiersFromModifierFlags(maskModifierFlags(node, modifierMask, modifierAdditions)); } function maskModifierFlags(node, modifierMask, modifierAdditions) { - if (modifierMask === void 0) { modifierMask = 11263 ^ 4; } + if (modifierMask === void 0) { modifierMask = 27647 ^ 4; } if (modifierAdditions === void 0) { modifierAdditions = 0; } var flags = (ts.getEffectiveModifierFlags(node) & modifierMask) | modifierAdditions; if (flags & 512 && !(flags & 1)) { @@ -81131,7 +84172,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 167 + return accessor.kind === 169 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -81140,52 +84181,52 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 163: - case 162: + case 165: + case 164: return !ts.hasEffectiveModifier(node, 8); - case 160: - case 249: + case 162: + case 251: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 251: - case 256: - case 260: case 253: - case 252: - case 254: + case 258: + case 262: case 255: - case 232: - case 261: - case 267: - case 266: + case 254: + case 256: + case 257: + case 234: + case 263: + case 269: + case 268: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { + case 172: + case 168: + case 167: + case 169: case 170: - case 166: case 165: - case 167: - case 168: - case 163: - case 162: case 164: - case 169: + case 166: case 171: - case 249: - case 159: - case 223: case 173: - case 184: - case 174: + case 251: + case 161: + case 225: case 175: - case 195: + case 186: + case 176: + case 177: + case 197: return true; } return false; @@ -81228,6 +84269,9 @@ var ts; if (languageVersion < 99) { transformers.push(ts.transformESNext); } + if (languageVersion < 8) { + transformers.push(ts.transformES2021); + } if (languageVersion < 7) { transformers.push(ts.transformES2020); } @@ -81286,7 +84330,7 @@ var ts; } ts.noEmitNotification = noEmitNotification; function transformNodes(resolver, host, factory, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(341); + var enabledSyntaxKindFeatures = new Array(349); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentStatements; @@ -81297,6 +84341,9 @@ var ts; var lexicalEnvironmentFlagsStack = []; var lexicalEnvironmentStackOffset = 0; var lexicalEnvironmentSuspended = false; + var blockScopedVariableDeclarationsStack = []; + var blockScopeStackOffset = 0; + var blockScopedVariableDeclarations; var emitHelpers; var onSubstituteNode = noEmitSubstitution; var onEmitNode = noEmitNotification; @@ -81317,6 +84364,9 @@ var ts; hoistVariableDeclaration: hoistVariableDeclaration, hoistFunctionDeclaration: hoistFunctionDeclaration, addInitializationStatement: addInitializationStatement, + startBlockScope: startBlockScope, + endBlockScope: endBlockScope, + addBlockScopedVariable: addBlockScopedVariable, requestEmitHelper: requestEmitHelper, readEmitHelpers: readEmitHelpers, enableSubstitution: enableSubstitution, @@ -81356,9 +84406,9 @@ var ts; var transformed = []; for (var _a = 0, nodes_3 = nodes; _a < nodes_3.length; _a++) { var node = nodes_3[_a]; - ts.tracing.push("emit", "transformNodes", node.kind === 297 ? { 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", "transformNodes", node.kind === 299 ? { path: node.path } : { kind: node.kind, pos: node.pos, end: node.end }); transformed.push((allowDtsFiles ? transformation : transformRoot)(node)); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } state = 2; ts.performance.mark("afterTransform"); @@ -81518,6 +84568,31 @@ var ts; function getLexicalEnvironmentFlags() { return lexicalEnvironmentFlags; } + function startBlockScope() { + ts.Debug.assert(state > 0, "Cannot start a block scope during initialization."); + ts.Debug.assert(state < 2, "Cannot start a block scope after transformation has completed."); + blockScopedVariableDeclarationsStack[blockScopeStackOffset] = blockScopedVariableDeclarations; + blockScopeStackOffset++; + blockScopedVariableDeclarations = undefined; + } + function endBlockScope() { + ts.Debug.assert(state > 0, "Cannot end a block scope during initialization."); + ts.Debug.assert(state < 2, "Cannot end a block scope after transformation has completed."); + var statements = ts.some(blockScopedVariableDeclarations) ? + [ + factory.createVariableStatement(undefined, factory.createVariableDeclarationList(blockScopedVariableDeclarations.map(function (identifier) { return factory.createVariableDeclaration(identifier); }), 1)) + ] : undefined; + blockScopeStackOffset--; + blockScopedVariableDeclarations = blockScopedVariableDeclarationsStack[blockScopeStackOffset]; + if (blockScopeStackOffset === 0) { + blockScopedVariableDeclarationsStack = []; + } + return statements; + } + function addBlockScopedVariable(name) { + ts.Debug.assert(blockScopeStackOffset > 0, "Cannot add a block scoped variable outside of an iteration body."); + (blockScopedVariableDeclarations || (blockScopedVariableDeclarations = [])).push(name); + } function requestEmitHelper(helper) { ts.Debug.assert(state > 0, "Cannot modify the transformation context during initialization."); ts.Debug.assert(state < 2, "Cannot modify the transformation context after transformation has completed."); @@ -81556,35 +84631,37 @@ var ts; } ts.transformNodes = transformNodes; ts.nullTransformationContext = { - get factory() { return ts.factory; }, - enableEmitNotification: ts.noop, - enableSubstitution: ts.noop, - endLexicalEnvironment: ts.returnUndefined, + factory: ts.factory, getCompilerOptions: function () { return ({}); }, - getEmitHost: ts.notImplemented, getEmitResolver: ts.notImplemented, + getEmitHost: ts.notImplemented, getEmitHelperFactory: ts.notImplemented, + startLexicalEnvironment: ts.noop, + resumeLexicalEnvironment: ts.noop, + suspendLexicalEnvironment: ts.noop, + endLexicalEnvironment: ts.returnUndefined, setLexicalEnvironmentFlags: ts.noop, getLexicalEnvironmentFlags: function () { return 0; }, - hoistFunctionDeclaration: ts.noop, hoistVariableDeclaration: ts.noop, + hoistFunctionDeclaration: ts.noop, addInitializationStatement: ts.noop, - isEmitNotificationEnabled: ts.notImplemented, - isSubstitutionEnabled: ts.notImplemented, - onEmitNode: ts.noop, - onSubstituteNode: ts.notImplemented, - readEmitHelpers: ts.notImplemented, + startBlockScope: ts.noop, + endBlockScope: ts.returnUndefined, + addBlockScopedVariable: ts.noop, requestEmitHelper: ts.noop, - resumeLexicalEnvironment: ts.noop, - startLexicalEnvironment: ts.noop, - suspendLexicalEnvironment: ts.noop, + readEmitHelpers: ts.notImplemented, + enableSubstitution: ts.noop, + enableEmitNotification: ts.noop, + isSubstitutionEnabled: ts.notImplemented, + isEmitNotificationEnabled: ts.notImplemented, + onSubstituteNode: noEmitSubstitution, + onEmitNode: noEmitNotification, addDiagnostic: ts.noop, }; })(ts || (ts = {})); var ts; (function (ts) { var brackets = createBracketsMap(); - var syntheticParent = { pos: -1, end: -1 }; function isBuildInfoFile(file) { return ts.fileExtensionIs(file, ".tsbuildinfo"); } @@ -81657,7 +84734,7 @@ var ts; ts.getOutputPathsForBundle = getOutputPathsForBundle; function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 298) { + if (sourceFile.kind === 300) { return getOutputPathsForBundle(options, forceDtsPaths); } else { @@ -81864,15 +84941,15 @@ var ts; sourceFiles: sourceFileOrBundle.sourceFiles.map(function (file) { return relativeToBuildInfo(ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory())); }) }; } - ts.tracing.push("emit", "emitJsFileOrBundle", { jsFilePath: jsFilePath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit", "emitJsFileOrBundle", { jsFilePath: jsFilePath }); emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo); - ts.tracing.pop(); - ts.tracing.push("emit", "emitDeclarationFileOrBundle", { declarationFilePath: declarationFilePath }); + 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", "emitDeclarationFileOrBundle", { declarationFilePath: declarationFilePath }); emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo); - ts.tracing.pop(); - ts.tracing.push("emit", "emitBuildInfo", { buildInfoPath: buildInfoPath }); + 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", "emitBuildInfo", { buildInfoPath: buildInfoPath }); emitBuildInfo(bundleBuildInfo, buildInfoPath); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); if (!emitSkipped && emittedFilesList) { if (!emitOnlyDtsFiles) { if (jsFilePath) { @@ -81987,12 +85064,12 @@ var ts; 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: compilerOptions.declarationMap, + sourceMap: !forceDtsEmit && compilerOptions.declarationMap, sourceRoot: compilerOptions.sourceRoot, mapRoot: compilerOptions.mapRoot, extendedDiagnostics: compilerOptions.extendedDiagnostics, }); - if (forceDtsEmit && declarationTransform.transformed[0].kind === 297) { + if (forceDtsEmit && declarationTransform.transformed[0].kind === 299) { var sourceFile = declarationTransform.transformed[0]; exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; } @@ -82003,7 +85080,7 @@ var ts; } function collectLinkedAliases(node) { if (ts.isExportAssignment(node)) { - if (node.expression.kind === 78) { + if (node.expression.kind === 79) { resolver.collectLinkedAliases(node.expression, true); } return; @@ -82015,8 +85092,8 @@ var ts; ts.forEachChild(node, collectLinkedAliases); } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) { - var bundle = sourceFileOrBundle.kind === 298 ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 297 ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 300 ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 299 ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; var sourceMapGenerator; if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { @@ -82054,7 +85131,7 @@ var ts; } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { return (mapOptions.sourceMap || mapOptions.inlineSourceMap) - && (sourceFileOrBundle.kind !== 297 || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json")); + && (sourceFileOrBundle.kind !== 299 || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json")); } function getSourceRoot(mapOptions) { var sourceRoot = ts.normalizeSlashes(mapOptions.sourceRoot || ""); @@ -82100,7 +85177,7 @@ var ts; } ts.emitFiles = emitFiles; function getBuildInfoText(buildInfo) { - return JSON.stringify(buildInfo, undefined, 2); + return JSON.stringify(buildInfo); } ts.getBuildInfoText = getBuildInfoText; function getBuildInfo(buildInfoText) { @@ -82263,7 +85340,7 @@ var ts; function createPrinter(printerOptions, handlers) { if (printerOptions === void 0) { printerOptions = {}; } if (handlers === void 0) { handlers = {}; } - var hasGlobalName = handlers.hasGlobalName, _a = handlers.onEmitNode, onEmitNode = _a === void 0 ? ts.noEmitNotification : _a, isEmitNotificationEnabled = handlers.isEmitNotificationEnabled, _b = handlers.substituteNode, substituteNode = _b === void 0 ? ts.noEmitSubstitution : _b, onBeforeEmitNodeArray = handlers.onBeforeEmitNodeArray, onAfterEmitNodeArray = handlers.onAfterEmitNodeArray, onBeforeEmitToken = handlers.onBeforeEmitToken, onAfterEmitToken = handlers.onAfterEmitToken; + var hasGlobalName = handlers.hasGlobalName, _a = handlers.onEmitNode, onEmitNode = _a === void 0 ? ts.noEmitNotification : _a, isEmitNotificationEnabled = handlers.isEmitNotificationEnabled, _b = handlers.substituteNode, substituteNode = _b === void 0 ? ts.noEmitSubstitution : _b, onBeforeEmitNode = handlers.onBeforeEmitNode, onAfterEmitNode = handlers.onAfterEmitNode, onBeforeEmitNodeArray = handlers.onBeforeEmitNodeArray, onAfterEmitNodeArray = handlers.onAfterEmitNodeArray, onBeforeEmitToken = handlers.onBeforeEmitToken, onAfterEmitToken = handlers.onAfterEmitToken; var extendedDiagnostics = !!printerOptions.extendedDiagnostics; var newLine = ts.getNewLineCharacter(printerOptions); var moduleKind = ts.getEmitModuleKind(printerOptions); @@ -82300,9 +85377,11 @@ var ts; var detachedCommentsInfo; var hasWrittenComment = false; var commentsDisabled = !!printerOptions.removeComments; - var lastNode; var lastSubstitution; + var currentParenthesizerRule; var _c = ts.performance.createTimerIf(extendedDiagnostics, "commentTime", "beforeComment", "afterComment"), enterComment = _c.enter, exitComment = _c.exit; + var parenthesizer = ts.factory.parenthesizer; + var emitBinaryExpression = createEmitBinaryExpression(); reset(); return { printNode: printNode, @@ -82328,9 +85407,9 @@ var ts; break; } switch (node.kind) { - case 297: return printFile(node); - case 298: return printBundle(node); - case 299: return printUnparsedSource(node); + case 299: return printFile(node); + case 300: return printBundle(node); + case 301: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -82364,7 +85443,7 @@ var ts; if (sourceFile) { setSourceFile(sourceFile); } - emitList(syntheticParent, nodes, format); + emitList(undefined, nodes, format); reset(); writer = previousWriter; } @@ -82497,7 +85576,7 @@ var ts; if (sourceFile) { setSourceFile(sourceFile); } - pipelineEmit(hint, node); + pipelineEmit(hint, node, undefined); } function setSourceFile(sourceFile) { currentSourceFile = sourceFile; @@ -82525,51 +85604,54 @@ var ts; currentSourceFile = undefined; currentLineMap = undefined; detachedCommentsInfo = undefined; - lastNode = undefined; - lastSubstitution = undefined; setWriter(undefined, undefined); } function getCurrentLineMap() { return currentLineMap || (currentLineMap = ts.getLineStarts(currentSourceFile)); } - function emit(node) { + function emit(node, parenthesizerRule) { if (node === undefined) return; var prevSourceFileTextKind = recordBundleFileInternalSectionStart(node); - var substitute = pipelineEmit(4, node); + pipelineEmit(4, node, parenthesizerRule); recordBundleFileInternalSectionEnd(prevSourceFileTextKind); - return substitute; } function emitIdentifierName(node) { if (node === undefined) return; - return pipelineEmit(2, node); + pipelineEmit(2, node, undefined); } - function emitExpression(node) { + function emitExpression(node, parenthesizerRule) { if (node === undefined) return; - return pipelineEmit(1, node); + pipelineEmit(1, node, parenthesizerRule); } function emitJsxAttributeValue(node) { - return pipelineEmit(ts.isStringLiteral(node) ? 6 : 4, node); + pipelineEmit(ts.isStringLiteral(node) ? 6 : 4, node); } - function pipelineEmit(emitHint, node) { - var savedLastNode = lastNode; - var savedLastSubstitution = lastSubstitution; - var savedPreserveSourceNewlines = preserveSourceNewlines; - lastNode = node; - lastSubstitution = undefined; - if (preserveSourceNewlines && !!(ts.getEmitFlags(node) & 134217728)) { + function beforeEmitNode(node) { + if (preserveSourceNewlines && (ts.getEmitFlags(node) & 134217728)) { preserveSourceNewlines = false; } + } + function afterEmitNode(savedPreserveSourceNewlines) { + preserveSourceNewlines = savedPreserveSourceNewlines; + } + function pipelineEmit(emitHint, node, parenthesizerRule) { + currentParenthesizerRule = parenthesizerRule; var pipelinePhase = getPipelinePhase(0, emitHint, node); pipelinePhase(emitHint, node); - ts.Debug.assert(lastNode === node); - var substitute = lastSubstitution; - lastNode = savedLastNode; - lastSubstitution = savedLastSubstitution; - preserveSourceNewlines = savedPreserveSourceNewlines; - return substitute || node; + currentParenthesizerRule = undefined; + } + function shouldEmitComments(node) { + return !commentsDisabled && !ts.isSourceFile(node); + } + function shouldEmitSourceMaps(node) { + return !sourceMapsDisabled && + !ts.isSourceFile(node) && + !ts.isInJsonFile(node) && + !ts.isUnparsedSource(node) && + !ts.isUnparsedPrepend(node); } function getPipelinePhase(phase, emitHint, node) { switch (phase) { @@ -82578,16 +85660,19 @@ var ts; return pipelineEmitWithNotification; } case 1: - if (substituteNode !== ts.noEmitSubstitution && (lastSubstitution = substituteNode(emitHint, node)) !== node) { + if (substituteNode !== ts.noEmitSubstitution && (lastSubstitution = substituteNode(emitHint, node) || node) !== node) { + if (currentParenthesizerRule) { + lastSubstitution = currentParenthesizerRule(lastSubstitution); + } return pipelineEmitWithSubstitution; } case 2: - if (!commentsDisabled && node.kind !== 297) { + if (shouldEmitComments(node)) { return pipelineEmitWithComments; } case 3: - if (!sourceMapsDisabled && node.kind !== 297 && !ts.isInJsonFile(node)) { - return pipelineEmitWithSourceMap; + if (shouldEmitSourceMaps(node)) { + return pipelineEmitWithSourceMaps; } case 4: return pipelineEmitWithHint; @@ -82599,13 +85684,24 @@ var ts; return getPipelinePhase(currentPhase + 1, emitHint, node); } function pipelineEmitWithNotification(hint, node) { - ts.Debug.assert(lastNode === node); var pipelinePhase = getNextPipelinePhase(0, hint, node); onEmitNode(hint, node, pipelinePhase); - ts.Debug.assert(lastNode === node); } function pipelineEmitWithHint(hint, node) { - ts.Debug.assert(lastNode === node || lastSubstitution === node); + onBeforeEmitNode === null || onBeforeEmitNode === void 0 ? void 0 : onBeforeEmitNode(node); + if (preserveSourceNewlines) { + var savedPreserveSourceNewlines = preserveSourceNewlines; + beforeEmitNode(node); + pipelineEmitWithHintWorker(hint, node); + afterEmitNode(savedPreserveSourceNewlines); + } + else { + pipelineEmitWithHintWorker(hint, node); + } + onAfterEmitNode === null || onAfterEmitNode === void 0 ? void 0 : onAfterEmitNode(node); + currentParenthesizerRule = undefined; + } + function pipelineEmitWithHintWorker(hint, node) { if (hint === 0) return emitSourceFile(ts.cast(node, ts.isSourceFile)); if (hint === 2) @@ -82619,289 +85715,311 @@ var ts; return emitEmptyStatement(true); } if (hint === 4) { - if (ts.isKeyword(node.kind)) - return writeTokenNode(node, writeKeyword); switch (node.kind) { case 15: case 16: case 17: return emitLiteral(node, false); - case 299: - case 293: - return emitUnparsedSourceOrPrepend(node); - case 292: - return writeUnparsedNode(node); - case 294: - case 295: - return emitUnparsedTextLike(node); - case 296: - return emitUnparsedSyntheticReference(node); - case 78: - return emitIdentifier(node); case 79: + return emitIdentifier(node); + case 80: return emitPrivateIdentifier(node); - case 157: - return emitQualifiedName(node); - case 158: - return emitComputedPropertyName(node); case 159: - return emitTypeParameter(node); + return emitQualifiedName(node); case 160: - return emitParameter(node); + return emitComputedPropertyName(node); case 161: - return emitDecorator(node); + return emitTypeParameter(node); case 162: - return emitPropertySignature(node); + return emitParameter(node); case 163: - return emitPropertyDeclaration(node); + return emitDecorator(node); case 164: - return emitMethodSignature(node); + return emitPropertySignature(node); case 165: - return emitMethodDeclaration(node); + return emitPropertyDeclaration(node); case 166: - return emitConstructor(node); + return emitMethodSignature(node); case 167: + return emitMethodDeclaration(node); case 168: - return emitAccessorDeclaration(node); + return emitConstructor(node); case 169: - return emitCallSignature(node); case 170: - return emitConstructSignature(node); + return emitAccessorDeclaration(node); case 171: - return emitIndexSignature(node); - case 194: - return emitTemplateTypeSpan(node); + return emitCallSignature(node); case 172: - return emitTypePredicate(node); + return emitConstructSignature(node); case 173: - return emitTypeReference(node); + return emitIndexSignature(node); case 174: - return emitFunctionType(node); - case 308: - return emitJSDocFunctionType(node); + return emitTypePredicate(node); case 175: - return emitConstructorType(node); + return emitTypeReference(node); case 176: - return emitTypeQuery(node); + return emitFunctionType(node); case 177: - return emitTypeLiteral(node); + return emitConstructorType(node); case 178: - return emitArrayType(node); + return emitTypeQuery(node); case 179: - return emitTupleType(node); + return emitTypeLiteral(node); case 180: - return emitOptionalType(node); + return emitArrayType(node); + case 181: + return emitTupleType(node); case 182: + return emitOptionalType(node); + case 184: return emitUnionType(node); - case 183: + case 185: return emitIntersectionType(node); - case 184: + case 186: return emitConditionalType(node); - case 185: + case 187: return emitInferType(node); - case 186: + case 188: return emitParenthesizedType(node); - case 223: + case 225: return emitExpressionWithTypeArguments(node); - case 187: + case 189: return emitThisType(); - case 188: + case 190: return emitTypeOperator(node); - case 189: + case 191: return emitIndexedAccessType(node); - case 190: + case 192: return emitMappedType(node); - case 191: - return emitLiteralType(node); case 193: - return emitTemplateType(node); - case 195: - return emitImportTypeNode(node); - case 303: - writePunctuation("*"); - return; - case 304: - writePunctuation("?"); - return; - case 305: - return emitJSDocNullableType(node); - case 306: - return emitJSDocNonNullableType(node); - case 307: - return emitJSDocOptionalType(node); - case 181: - case 309: - return emitRestOrJSDocVariadicType(node); - case 192: + return emitLiteralType(node); + case 194: return emitNamedTupleMember(node); + case 195: + return emitTemplateType(node); case 196: - return emitObjectBindingPattern(node); + return emitTemplateTypeSpan(node); case 197: - return emitArrayBindingPattern(node); + return emitImportTypeNode(node); case 198: + return emitObjectBindingPattern(node); + case 199: + return emitArrayBindingPattern(node); + case 200: return emitBindingElement(node); - case 228: + case 230: return emitTemplateSpan(node); - case 229: + case 231: return emitSemicolonClassElement(); - case 230: - return emitBlock(node); case 232: + return emitBlock(node); + case 234: return emitVariableStatement(node); - case 231: - return emitEmptyStatement(false); case 233: + return emitEmptyStatement(false); + case 235: return emitExpressionStatement(node); - case 234: + case 236: return emitIfStatement(node); - case 235: + case 237: return emitDoStatement(node); - case 236: + case 238: return emitWhileStatement(node); - case 237: + case 239: return emitForStatement(node); - case 238: + case 240: return emitForInStatement(node); - case 239: + case 241: return emitForOfStatement(node); - case 240: + case 242: return emitContinueStatement(node); - case 241: + case 243: return emitBreakStatement(node); - case 242: + case 244: return emitReturnStatement(node); - case 243: + case 245: return emitWithStatement(node); - case 244: + case 246: return emitSwitchStatement(node); - case 245: + case 247: return emitLabeledStatement(node); - case 246: + case 248: return emitThrowStatement(node); - case 247: + case 249: return emitTryStatement(node); - case 248: + case 250: return emitDebuggerStatement(node); - case 249: + case 251: return emitVariableDeclaration(node); - case 250: + case 252: return emitVariableDeclarationList(node); - case 251: + case 253: return emitFunctionDeclaration(node); - case 252: + case 254: return emitClassDeclaration(node); - case 253: + case 255: return emitInterfaceDeclaration(node); - case 254: + case 256: return emitTypeAliasDeclaration(node); - case 255: + case 257: return emitEnumDeclaration(node); - case 256: + case 258: return emitModuleDeclaration(node); - case 257: + case 259: return emitModuleBlock(node); - case 258: + case 260: return emitCaseBlock(node); - case 259: + case 261: return emitNamespaceExportDeclaration(node); - case 260: + case 262: return emitImportEqualsDeclaration(node); - case 261: + case 263: return emitImportDeclaration(node); - case 262: + case 264: return emitImportClause(node); - case 263: + case 265: return emitNamespaceImport(node); - case 269: + case 271: return emitNamespaceExport(node); - case 264: + case 266: return emitNamedImports(node); - case 265: + case 267: return emitImportSpecifier(node); - case 266: + case 268: return emitExportAssignment(node); - case 267: + case 269: return emitExportDeclaration(node); - case 268: - return emitNamedExports(node); case 270: + return emitNamedExports(node); + case 272: return emitExportSpecifier(node); - case 271: + case 273: return; - case 272: + case 274: return emitExternalModuleReference(node); case 11: return emitJsxText(node); - case 275: - case 278: + case 277: + case 280: return emitJsxOpeningElementOrFragment(node); - case 276: - case 279: + case 278: + case 281: return emitJsxClosingElementOrFragment(node); - case 280: + case 282: return emitJsxAttribute(node); - case 281: + case 283: return emitJsxAttributes(node); - case 282: + case 284: return emitJsxSpreadAttribute(node); - case 283: + case 285: return emitJsxExpression(node); - case 284: + case 286: return emitCaseClause(node); - case 285: + case 287: return emitDefaultClause(node); - case 286: + case 288: return emitHeritageClause(node); - case 287: + case 289: return emitCatchClause(node); - case 288: + case 290: return emitPropertyAssignment(node); - case 289: + case 291: return emitShorthandPropertyAssignment(node); - case 290: + case 292: return emitSpreadAssignment(node); - case 291: + case 293: return emitEnumMember(node); + case 294: + return writeUnparsedNode(node); + case 301: + case 295: + return emitUnparsedSourceOrPrepend(node); + case 296: + case 297: + return emitUnparsedTextLike(node); + case 298: + return emitUnparsedSyntheticReference(node); + case 299: + return emitSourceFile(node); + case 300: + return ts.Debug.fail("Bundles should be printed using printBundle"); + case 302: + return ts.Debug.fail("InputFiles should not be printed"); + case 303: + return emitJSDocTypeExpression(node); + case 304: + return emitJSDocNameReference(node); + case 306: + return writePunctuation("*"); + case 307: + return writePunctuation("?"); + case 308: + return emitJSDocNullableType(node); + case 309: + return emitJSDocNonNullableType(node); + case 310: + return emitJSDocOptionalType(node); + case 311: + return emitJSDocFunctionType(node); + case 183: + case 312: + return emitRestOrJSDocVariadicType(node); + case 313: + return; + case 314: + return emitJSDoc(node); + case 316: + return emitJSDocTypeLiteral(node); + case 317: + return emitJSDocSignature(node); + case 321: case 326: - case 333: - return emitJSDocPropertyLikeTag(node); + return emitJSDocSimpleTag(node); + case 322: + case 323: + return emitJSDocHeritageTag(node); + case 324: + case 325: + return; case 327: - case 329: case 328: - case 325: - return emitJSDocSimpleTypedTag(node); - case 316: - case 315: - return emitJSDocHeritageTag(node); + case 329: case 330: - return emitJSDocTemplateTag(node); case 331: - return emitJSDocTypedefTag(node); - case 324: - return emitJSDocCallbackTag(node); - case 313: - return emitJSDocSignature(node); - case 312: - return emitJSDocTypeLiteral(node); - case 319: - case 314: - return emitJSDocSimpleTag(node); + return; case 332: + return emitJSDocCallbackTag(node); + case 334: + case 341: + return emitJSDocPropertyLikeTag(node); + case 333: + case 335: + case 336: + case 337: + return emitJSDocSimpleTypedTag(node); + case 338: + return emitJSDocTemplateTag(node); + case 339: + return emitJSDocTypedefTag(node); + case 340: return emitJSDocSeeTag(node); - case 302: - return emitJSDocNameReference(node); - case 311: - return emitJSDoc(node); + case 343: + case 347: + case 346: + return; } if (ts.isExpression(node)) { hint = 1; if (substituteNode !== ts.noEmitSubstitution) { - lastSubstitution = node = substituteNode(hint, node); + var substitute = substituteNode(hint, node) || node; + if (substitute !== node) { + node = substitute; + if (currentParenthesizerRule) { + node = currentParenthesizerRule(node); + } + } } } - else if (ts.isToken(node)) { - return writeTokenNode(node, writePunctuation); - } } if (hint === 1) { switch (node.kind) { @@ -82912,82 +86030,90 @@ var ts; case 13: case 14: return emitLiteral(node, false); - case 78: + case 79: return emitIdentifier(node); - case 94: - case 103: - case 105: - case 109: - case 107: - case 99: - writeTokenNode(node, writeKeyword); - return; - case 199: - return emitArrayLiteralExpression(node); - case 200: - return emitObjectLiteralExpression(node); case 201: - return emitPropertyAccessExpression(node); + return emitArrayLiteralExpression(node); case 202: - return emitElementAccessExpression(node); + return emitObjectLiteralExpression(node); case 203: - return emitCallExpression(node); + return emitPropertyAccessExpression(node); case 204: - return emitNewExpression(node); + return emitElementAccessExpression(node); case 205: - return emitTaggedTemplateExpression(node); + return emitCallExpression(node); case 206: - return emitTypeAssertionExpression(node); + return emitNewExpression(node); case 207: - return emitParenthesizedExpression(node); + return emitTaggedTemplateExpression(node); case 208: - return emitFunctionExpression(node); + return emitTypeAssertionExpression(node); case 209: - return emitArrowFunction(node); + return emitParenthesizedExpression(node); case 210: - return emitDeleteExpression(node); + return emitFunctionExpression(node); case 211: - return emitTypeOfExpression(node); + return emitArrowFunction(node); case 212: - return emitVoidExpression(node); + return emitDeleteExpression(node); case 213: - return emitAwaitExpression(node); + return emitTypeOfExpression(node); case 214: - return emitPrefixUnaryExpression(node); + return emitVoidExpression(node); case 215: - return emitPostfixUnaryExpression(node); + return emitAwaitExpression(node); case 216: - return emitBinaryExpression(node); + return emitPrefixUnaryExpression(node); case 217: - return emitConditionalExpression(node); + return emitPostfixUnaryExpression(node); case 218: - return emitTemplateExpression(node); + return emitBinaryExpression(node); case 219: - return emitYieldExpression(node); + return emitConditionalExpression(node); case 220: - return emitSpreadExpression(node); + return emitTemplateExpression(node); case 221: - return emitClassExpression(node); + return emitYieldExpression(node); case 222: - return; + return emitSpreadElement(node); + case 223: + return emitClassExpression(node); case 224: + return; + case 226: return emitAsExpression(node); - case 225: + case 227: return emitNonNullExpression(node); - case 226: + case 228: return emitMetaProperty(node); - case 273: + case 229: + return ts.Debug.fail("SyntheticExpression should never be printed."); + case 275: return emitJsxElement(node); - case 274: + case 276: return emitJsxSelfClosingElement(node); - case 277: + case 279: return emitJsxFragment(node); - case 336: + case 342: + return ts.Debug.fail("SyntaxList should not be printed"); + case 343: + return; + case 344: return emitPartiallyEmittedExpression(node); - case 337: + case 345: return emitCommaList(node); + case 346: + case 347: + return; + case 348: + return ts.Debug.fail("SyntheticReferenceExpression should not be printed"); } } + if (ts.isKeyword(node.kind)) + return writeTokenNode(node, writeKeyword); + if (ts.isTokenKind(node.kind)) + return writeTokenNode(node, writePunctuation); + ts.Debug.fail("Unhandled SyntaxKind: " + ts.Debug.formatSyntaxKind(node.kind) + "."); } function emitMappedTypeParameter(node) { emit(node.name); @@ -82997,10 +86123,11 @@ var ts; emit(node.constraint); } function pipelineEmitWithSubstitution(hint, node) { - ts.Debug.assert(lastNode === node || lastSubstitution === node); var pipelinePhase = getNextPipelinePhase(1, hint, node); - pipelinePhase(hint, lastSubstitution); - ts.Debug.assert(lastNode === node || lastSubstitution === node); + ts.Debug.assertIsDefined(lastSubstitution); + node = lastSubstitution; + lastSubstitution = undefined; + pipelinePhase(hint, node); } function getHelpersFromBundledSourceFiles(bundle) { var result; @@ -83026,7 +86153,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 298 ? node : undefined; + var bundle = node.kind === 300 ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -83100,7 +86227,7 @@ var ts; var pos = getTextPosWithWriteLine(); writeUnparsedNode(unparsed); if (bundleFileInfo) { - updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 294 ? + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 296 ? "text" : "internal"); } @@ -83130,7 +86257,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 78) { + if (node.kind === 79) { emitExpression(node); } else { @@ -83139,7 +86266,7 @@ var ts; } function emitComputedPropertyName(node) { writePunctuation("["); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfComputedPropertyName); writePunctuation("]"); } function emitTypeParameter(node) { @@ -83163,17 +86290,17 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 308 && !node.name) { + if (node.parent && node.parent.kind === 311 && !node.name) { emit(node.type); } else { emitTypeAnnotation(node.type); } - emitInitializer(node.initializer, node.type ? node.type.end : node.questionToken ? node.questionToken.end : node.name ? node.name.end : node.modifiers ? node.modifiers.end : node.decorators ? node.decorators.end : node.pos, node); + emitInitializer(node.initializer, node.type ? node.type.end : node.questionToken ? node.questionToken.end : node.name ? node.name.end : node.modifiers ? node.modifiers.end : node.decorators ? node.decorators.end : node.pos, node, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitDecorator(decorator) { writePunctuation("@"); - emitExpression(decorator.expression); + emitExpression(decorator.expression, parenthesizer.parenthesizeLeftSideOfAccess); } function emitPropertySignature(node) { emitDecorators(node, node.decorators); @@ -83221,7 +86348,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeKeyword(node.kind === 167 ? "get" : "set"); + writeKeyword(node.kind === 169 ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -83332,7 +86459,7 @@ var ts; writePunctuation("}"); } function emitArrayType(node) { - emit(node.elementType); + emit(node.elementType, parenthesizer.parenthesizeElementTypeOfArrayType); writePunctuation("["); writePunctuation("]"); } @@ -83355,21 +86482,21 @@ var ts; emit(node.type); } function emitOptionalType(node) { - emit(node.type); + emit(node.type, parenthesizer.parenthesizeElementTypeOfArrayType); writePunctuation("?"); } function emitUnionType(node) { - emitList(node, node.types, 516); + emitList(node, node.types, 516, parenthesizer.parenthesizeMemberOfElementType); } function emitIntersectionType(node) { - emitList(node, node.types, 520); + emitList(node, node.types, 520, parenthesizer.parenthesizeMemberOfElementType); } function emitConditionalType(node) { - emit(node.checkType); + emit(node.checkType, parenthesizer.parenthesizeMemberOfConditionalType); writeSpace(); writeKeyword("extends"); writeSpace(); - emit(node.extendsType); + emit(node.extendsType, parenthesizer.parenthesizeMemberOfConditionalType); writeSpace(); writePunctuation("?"); writeSpace(); @@ -83395,10 +86522,10 @@ var ts; function emitTypeOperator(node) { writeTokenText(node.operator, writeKeyword); writeSpace(); - emit(node.type); + emit(node.type, parenthesizer.parenthesizeMemberOfElementType); } function emitIndexedAccessType(node) { - emit(node.objectType); + emit(node.objectType, parenthesizer.parenthesizeMemberOfElementType); writePunctuation("["); emit(node.indexType); writePunctuation("]"); @@ -83415,7 +86542,7 @@ var ts; } if (node.readonlyToken) { emit(node.readonlyToken); - if (node.readonlyToken.kind !== 142) { + if (node.readonlyToken.kind !== 143) { writeKeyword("readonly"); } writeSpace(); @@ -83488,12 +86615,12 @@ var ts; writeSpace(); } emit(node.name); - emitInitializer(node.initializer, node.name.end, node); + emitInitializer(node.initializer, node.name.end, node, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitArrayLiteralExpression(node) { var elements = node.elements; var preferNewLine = node.multiLine ? 65536 : 0; - emitExpressionList(node, elements, 8914 | preferNewLine); + emitExpressionList(node, elements, 8914 | preferNewLine, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitObjectLiteralExpression(node) { ts.forEach(node.properties, generateMemberNames); @@ -83509,13 +86636,13 @@ var ts; } } function emitPropertyAccessExpression(node) { - var expression = ts.cast(emitExpression(node.expression), ts.isExpression); + emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); var token = node.questionDotToken || ts.setTextRangePosEnd(ts.factory.createToken(24), node.expression.end, node.name.pos); var linesBeforeDot = getLinesBetweenNodes(node, node.expression, token); var linesAfterDot = getLinesBetweenNodes(node, token, node.name); writeLinesAndIndent(linesBeforeDot, false); var shouldEmitDotDot = token.kind !== 28 && - mayNeedDotDotForPropertyAccess(expression) && + mayNeedDotDotForPropertyAccess(node.expression) && !writer.hasTrailingComment() && !writer.hasTrailingWhitespace(); if (shouldEmitDotDot) { @@ -83544,27 +86671,27 @@ var ts; } } function emitElementAccessExpression(node) { - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); emit(node.questionDotToken); emitTokenWithComment(22, node.expression.end, writePunctuation, node); emitExpression(node.argumentExpression); emitTokenWithComment(23, node.argumentExpression.end, writePunctuation, node); } function emitCallExpression(node) { - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); emit(node.questionDotToken); emitTypeArguments(node, node.typeArguments); - emitExpressionList(node, node.arguments, 2576); + emitExpressionList(node, node.arguments, 2576, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitNewExpression(node) { - emitTokenWithComment(102, node.pos, writeKeyword, node); + emitTokenWithComment(103, node.pos, writeKeyword, node); writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfNew); emitTypeArguments(node, node.typeArguments); - emitExpressionList(node, node.arguments, 18960); + emitExpressionList(node, node.arguments, 18960, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitTaggedTemplateExpression(node) { - emitExpression(node.tag); + emitExpression(node.tag, parenthesizer.parenthesizeLeftSideOfAccess); emitTypeArguments(node, node.typeArguments); writeSpace(); emitExpression(node.template); @@ -83573,12 +86700,12 @@ var ts; writePunctuation("<"); emit(node.type); writePunctuation(">"); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitParenthesizedExpression(node) { var openParenPos = emitTokenWithComment(20, node.pos, writePunctuation, node); var indented = writeLineSeparatorsAndIndentBefore(node.expression, node); - emitExpression(node.expression); + emitExpression(node.expression, undefined); writeLineSeparatorsAfter(node.expression, node); decreaseIndentIf(indented); emitTokenWithComment(21, node.expression ? node.expression.end : openParenPos, writePunctuation, node); @@ -83600,93 +86727,129 @@ var ts; emit(node.equalsGreaterThanToken); } function emitDeleteExpression(node) { - emitTokenWithComment(88, node.pos, writeKeyword, node); + emitTokenWithComment(89, node.pos, writeKeyword, node); writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitTypeOfExpression(node) { - emitTokenWithComment(111, node.pos, writeKeyword, node); + emitTokenWithComment(112, node.pos, writeKeyword, node); writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitVoidExpression(node) { - emitTokenWithComment(113, node.pos, writeKeyword, node); + emitTokenWithComment(114, node.pos, writeKeyword, node); writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitAwaitExpression(node) { - emitTokenWithComment(130, node.pos, writeKeyword, node); + emitTokenWithComment(131, node.pos, writeKeyword, node); writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitPrefixUnaryExpression(node) { writeTokenText(node.operator, writeOperator); if (shouldEmitWhitespaceBeforeOperand(node)) { writeSpace(); } - emitExpression(node.operand); + emitExpression(node.operand, parenthesizer.parenthesizeOperandOfPrefixUnary); } function shouldEmitWhitespaceBeforeOperand(node) { var operand = node.operand; - return operand.kind === 214 + return operand.kind === 216 && ((node.operator === 39 && (operand.operator === 39 || operand.operator === 45)) || (node.operator === 40 && (operand.operator === 40 || operand.operator === 46))); } function emitPostfixUnaryExpression(node) { - emitExpression(node.operand); + emitExpression(node.operand, parenthesizer.parenthesizeOperandOfPostfixUnary); writeTokenText(node.operator, writeOperator); } - function emitBinaryExpression(node) { - var nodeStack = [node]; - var stateStack = [0]; - var stackIndex = 0; - while (stackIndex >= 0) { - node = nodeStack[stackIndex]; - switch (stateStack[stackIndex]) { - case 0: { - maybePipelineEmitExpression(node.left); - break; - } - case 1: { - var isCommaOperator = node.operatorToken.kind !== 27; - var linesBeforeOperator = getLinesBetweenNodes(node, node.left, node.operatorToken); - var linesAfterOperator = getLinesBetweenNodes(node, node.operatorToken, node.right); - writeLinesAndIndent(linesBeforeOperator, isCommaOperator); - emitLeadingCommentsOfPosition(node.operatorToken.pos); - writeTokenNode(node.operatorToken, node.operatorToken.kind === 100 ? writeKeyword : writeOperator); - emitTrailingCommentsOfPosition(node.operatorToken.end, true); - writeLinesAndIndent(linesAfterOperator, true); - maybePipelineEmitExpression(node.right); - break; - } - case 2: { - var linesBeforeOperator = getLinesBetweenNodes(node, node.left, node.operatorToken); - var linesAfterOperator = getLinesBetweenNodes(node, node.operatorToken, node.right); - decreaseIndentIf(linesBeforeOperator, linesAfterOperator); - stackIndex--; - break; - } - default: return ts.Debug.fail("Invalid state " + stateStack[stackIndex] + " for emitBinaryExpressionWorker"); + function createEmitBinaryExpression() { + return ts.createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, undefined); + function onEnter(node, state) { + if (state) { + state.stackIndex++; + state.preserveSourceNewlinesStack[state.stackIndex] = preserveSourceNewlines; + state.containerPosStack[state.stackIndex] = containerPos; + state.containerEndStack[state.stackIndex] = containerEnd; + state.declarationListContainerEndStack[state.stackIndex] = declarationListContainerEnd; + var emitComments_1 = state.shouldEmitCommentsStack[state.stackIndex] = shouldEmitComments(node); + var emitSourceMaps = state.shouldEmitSourceMapsStack[state.stackIndex] = shouldEmitSourceMaps(node); + onBeforeEmitNode === null || onBeforeEmitNode === void 0 ? void 0 : onBeforeEmitNode(node); + if (emitComments_1) + emitCommentsBeforeNode(node); + if (emitSourceMaps) + emitSourceMapsBeforeNode(node); + beforeEmitNode(node); } - } - function maybePipelineEmitExpression(next) { - stateStack[stackIndex]++; - var savedLastNode = lastNode; - var savedLastSubstitution = lastSubstitution; - lastNode = next; - lastSubstitution = undefined; + else { + state = { + stackIndex: 0, + preserveSourceNewlinesStack: [undefined], + containerPosStack: [-1], + containerEndStack: [-1], + declarationListContainerEndStack: [-1], + shouldEmitCommentsStack: [false], + shouldEmitSourceMapsStack: [false], + }; + } + return state; + } + function onLeft(next, _workArea, parent) { + return maybeEmitExpression(next, parent, "left"); + } + function onOperator(operatorToken, _state, node) { + var isCommaOperator = operatorToken.kind !== 27; + 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 ? writeKeyword : writeOperator); + emitTrailingCommentsOfPosition(operatorToken.end, true); + writeLinesAndIndent(linesAfterOperator, true); + } + function onRight(next, _workArea, parent) { + return maybeEmitExpression(next, parent, "right"); + } + function onExit(node, state) { + var linesBeforeOperator = getLinesBetweenNodes(node, node.left, node.operatorToken); + var linesAfterOperator = getLinesBetweenNodes(node, node.operatorToken, node.right); + decreaseIndentIf(linesBeforeOperator, linesAfterOperator); + if (state.stackIndex > 0) { + var savedPreserveSourceNewlines = state.preserveSourceNewlinesStack[state.stackIndex]; + var savedContainerPos = state.containerPosStack[state.stackIndex]; + var savedContainerEnd = state.containerEndStack[state.stackIndex]; + var savedDeclarationListContainerEnd = state.declarationListContainerEndStack[state.stackIndex]; + var shouldEmitComments_1 = state.shouldEmitCommentsStack[state.stackIndex]; + var shouldEmitSourceMaps_1 = state.shouldEmitSourceMapsStack[state.stackIndex]; + afterEmitNode(savedPreserveSourceNewlines); + if (shouldEmitSourceMaps_1) + emitSourceMapsAfterNode(node); + if (shouldEmitComments_1) + emitCommentsAfterNode(node, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd); + onAfterEmitNode === null || onAfterEmitNode === void 0 ? void 0 : onAfterEmitNode(node); + state.stackIndex--; + } + } + function maybeEmitExpression(next, parent, side) { + var parenthesizerRule = side === "left" ? + parenthesizer.getParenthesizeLeftSideOfBinaryForOperator(parent.operatorToken.kind) : + parenthesizer.getParenthesizeRightSideOfBinaryForOperator(parent.operatorToken.kind); var pipelinePhase = getPipelinePhase(0, 1, next); - if (pipelinePhase === pipelineEmitWithHint && ts.isBinaryExpression(next)) { - stackIndex++; - stateStack[stackIndex] = 0; - nodeStack[stackIndex] = next; + if (pipelinePhase === pipelineEmitWithSubstitution) { + ts.Debug.assertIsDefined(lastSubstitution); + next = parenthesizerRule(ts.cast(lastSubstitution, ts.isExpression)); + pipelinePhase = getNextPipelinePhase(1, 1, next); + lastSubstitution = undefined; } - else { - pipelinePhase(1, next); + if (pipelinePhase === pipelineEmitWithComments || + pipelinePhase === pipelineEmitWithSourceMaps || + pipelinePhase === pipelineEmitWithHint) { + if (ts.isBinaryExpression(next)) { + return next; + } } - ts.Debug.assert(lastNode === next); - lastNode = savedLastNode; - lastSubstitution = savedLastSubstitution; + currentParenthesizerRule = parenthesizerRule; + pipelinePhase(1, next); } } function emitConditionalExpression(node) { @@ -83694,16 +86857,16 @@ var ts; var linesAfterQuestion = getLinesBetweenNodes(node, node.questionToken, node.whenTrue); var linesBeforeColon = getLinesBetweenNodes(node, node.whenTrue, node.colonToken); var linesAfterColon = getLinesBetweenNodes(node, node.colonToken, node.whenFalse); - emitExpression(node.condition); + emitExpression(node.condition, parenthesizer.parenthesizeConditionOfConditionalExpression); writeLinesAndIndent(linesBeforeQuestion, true); emit(node.questionToken); writeLinesAndIndent(linesAfterQuestion, true); - emitExpression(node.whenTrue); + emitExpression(node.whenTrue, parenthesizer.parenthesizeBranchOfConditionalExpression); decreaseIndentIf(linesBeforeQuestion, linesAfterQuestion); writeLinesAndIndent(linesBeforeColon, true); emit(node.colonToken); writeLinesAndIndent(linesAfterColon, true); - emitExpression(node.whenFalse); + emitExpression(node.whenFalse, parenthesizer.parenthesizeBranchOfConditionalExpression); decreaseIndentIf(linesBeforeColon, linesAfterColon); } function emitTemplateExpression(node) { @@ -83711,24 +86874,24 @@ var ts; emitList(node, node.templateSpans, 262144); } function emitYieldExpression(node) { - emitTokenWithComment(124, node.pos, writeKeyword, node); + emitTokenWithComment(125, node.pos, writeKeyword, node); emit(node.asteriskToken); - emitExpressionWithLeadingSpace(node.expression); + emitExpressionWithLeadingSpace(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); } - function emitSpreadExpression(node) { + function emitSpreadElement(node) { emitTokenWithComment(25, node.pos, writePunctuation, node); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitClassExpression(node) { generateNameIfNeeded(node.name); emitClassDeclarationOrExpression(node); } function emitExpressionWithTypeArguments(node) { - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); emitTypeArguments(node, node.typeArguments); } function emitAsExpression(node) { - emitExpression(node.expression); + emitExpression(node.expression, undefined); if (node.type) { writeSpace(); writeKeyword("as"); @@ -83737,7 +86900,7 @@ var ts; } } function emitNonNullExpression(node) { - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); writeOperator("!"); } function emitMetaProperty(node) { @@ -83772,13 +86935,13 @@ var ts; } } function emitExpressionStatement(node) { - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfExpressionStatement); if (!ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) { writeTrailingSemicolon(); } } function emitIfStatement(node) { - var openParenPos = emitTokenWithComment(98, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(99, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -83786,8 +86949,8 @@ var ts; emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { writeLineOrSpace(node, node.thenStatement, node.elseStatement); - emitTokenWithComment(90, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 234) { + emitTokenWithComment(91, node.thenStatement.end, writeKeyword, node); + if (node.elseStatement.kind === 236) { writeSpace(); emit(node.elseStatement); } @@ -83797,14 +86960,14 @@ var ts; } } function emitWhileClause(node, startPos) { - var openParenPos = emitTokenWithComment(114, startPos, writeKeyword, node); + var openParenPos = emitTokenWithComment(115, startPos, writeKeyword, node); writeSpace(); emitTokenWithComment(20, openParenPos, writePunctuation, node); emitExpression(node.expression); emitTokenWithComment(21, node.expression.end, writePunctuation, node); } function emitDoStatement(node) { - emitTokenWithComment(89, node.pos, writeKeyword, node); + emitTokenWithComment(90, node.pos, writeKeyword, node); emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement) && !preserveSourceNewlines) { writeSpace(); @@ -83820,7 +86983,7 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { - var openParenPos = emitTokenWithComment(96, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97, node.pos, writeKeyword, node); writeSpace(); var pos = emitTokenWithComment(20, openParenPos, writePunctuation, node); emitForBinding(node.initializer); @@ -83832,25 +86995,25 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { - var openParenPos = emitTokenWithComment(96, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(100, node.initializer.end, writeKeyword, node); + emitTokenWithComment(101, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { - var openParenPos = emitTokenWithComment(96, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97, node.pos, writeKeyword, node); writeSpace(); emitWithTrailingSpace(node.awaitModifier); emitTokenWithComment(20, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(156, node.initializer.end, writeKeyword, node); + emitTokenWithComment(158, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21, node.expression.end, writePunctuation, node); @@ -83858,7 +87021,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 250) { + if (node.kind === 252) { emit(node); } else { @@ -83867,12 +87030,12 @@ var ts; } } function emitContinueStatement(node) { - emitTokenWithComment(85, node.pos, writeKeyword, node); + emitTokenWithComment(86, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } function emitBreakStatement(node) { - emitTokenWithComment(80, node.pos, writeKeyword, node); + emitTokenWithComment(81, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } @@ -83895,18 +87058,18 @@ var ts; } pos = writeTokenText(token, writer, pos); if (isSimilarNode && contextNode.end !== pos) { - var isJsxExprContext = contextNode.kind === 283; + var isJsxExprContext = contextNode.kind === 285; emitTrailingCommentsOfPosition(pos, !isJsxExprContext, isJsxExprContext); } return pos; } function emitReturnStatement(node) { - emitTokenWithComment(104, node.pos, writeKeyword, node); + emitTokenWithComment(105, node.pos, writeKeyword, node); emitExpressionWithLeadingSpace(node.expression); writeTrailingSemicolon(); } function emitWithStatement(node) { - var openParenPos = emitTokenWithComment(115, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(116, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -83914,7 +87077,7 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { - var openParenPos = emitTokenWithComment(106, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(107, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -83929,12 +87092,12 @@ var ts; emit(node.statement); } function emitThrowStatement(node) { - emitTokenWithComment(108, node.pos, writeKeyword, node); + emitTokenWithComment(109, node.pos, writeKeyword, node); emitExpressionWithLeadingSpace(node.expression); writeTrailingSemicolon(); } function emitTryStatement(node) { - emitTokenWithComment(110, node.pos, writeKeyword, node); + emitTokenWithComment(111, node.pos, writeKeyword, node); writeSpace(); emit(node.tryBlock); if (node.catchClause) { @@ -83943,20 +87106,20 @@ var ts; } if (node.finallyBlock) { writeLineOrSpace(node, node.catchClause || node.tryBlock, node.finallyBlock); - emitTokenWithComment(95, (node.catchClause || node.tryBlock).end, writeKeyword, node); + emitTokenWithComment(96, (node.catchClause || node.tryBlock).end, writeKeyword, node); writeSpace(); emit(node.finallyBlock); } } function emitDebuggerStatement(node) { - writeToken(86, node.pos, writeKeyword); + writeToken(87, node.pos, writeKeyword); writeTrailingSemicolon(); } function emitVariableDeclaration(node) { emit(node.name); emit(node.exclamationToken); emitTypeAnnotation(node.type); - emitInitializer(node.initializer, node.type ? node.type.end : node.name.end, node); + emitInitializer(node.initializer, node.type ? node.type.end : node.name.end, node, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitVariableDeclarationList(node) { writeKeyword(ts.isLet(node) ? "let" : ts.isVarConst(node) ? "const" : "var"); @@ -83975,9 +87138,6 @@ var ts; emitIdentifierName(node.name); emitSignatureAndBody(node, emitSignatureHead); } - function emitBlockCallback(_hint, body) { - emitBlockFunctionBody(body); - } function emitSignatureAndBody(node, emitSignatureHead) { var body = node.body; if (body) { @@ -83990,12 +87150,7 @@ var ts; ts.forEach(node.parameters, generateNames); generateNames(node.body); emitSignatureHead(node); - if (onEmitNode) { - onEmitNode(4, body, emitBlockCallback); - } - else { - emitBlockFunctionBody(body); - } + emitBlockFunctionBody(body); popNameGenerationScope(node); if (indentedFlag) { decreaseIndent(); @@ -84004,7 +87159,7 @@ var ts; else { emitSignatureHead(node); writeSpace(); - emitExpression(body); + emitExpression(body, parenthesizer.parenthesizeConciseBodyOfArrowFunction); } } else { @@ -84042,6 +87197,7 @@ var ts; return true; } function emitBlockFunctionBody(body) { + onBeforeEmitNode === null || onBeforeEmitNode === void 0 ? void 0 : onBeforeEmitNode(body); writeSpace(); writePunctuation("{"); increaseIndent(); @@ -84056,6 +87212,7 @@ var ts; } decreaseIndent(); writeToken(19, body.statements.end, writePunctuation, body); + onAfterEmitNode === null || onAfterEmitNode === void 0 ? void 0 : onAfterEmitNode(body); } function emitBlockFunctionBodyOnSingleLine(body) { emitBlockFunctionBodyWorker(body, true); @@ -84070,7 +87227,7 @@ var ts; increaseIndent(); } else { - emitList(body, body.statements, 1, statementOffset); + emitList(body, body.statements, 1, undefined, statementOffset); } } function emitClassDeclaration(node) { @@ -84145,7 +87302,7 @@ var ts; var body = node.body; if (!body) return writeTrailingSemicolon(); - while (body.kind === 256) { + while (body && ts.isModuleDeclaration(body)) { writePunctuation("."); emit(body.name); body = body.body; @@ -84166,21 +87323,21 @@ var ts; } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(99, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(100, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.isTypeOnly) { - emitTokenWithComment(149, node.pos, writeKeyword, node); + emitTokenWithComment(150, node.pos, writeKeyword, node); writeSpace(); } emit(node.name); writeSpace(); - emitTokenWithComment(62, node.name.end, writePunctuation, node); + emitTokenWithComment(63, node.name.end, writePunctuation, node); writeSpace(); emitModuleReference(node.moduleReference); writeTrailingSemicolon(); } function emitModuleReference(node) { - if (node.kind === 78) { + if (node.kind === 79) { emitExpression(node); } else { @@ -84189,12 +87346,12 @@ var ts; } function emitImportDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(99, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(100, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.importClause) { emit(node.importClause); writeSpace(); - emitTokenWithComment(153, node.importClause.end, writeKeyword, node); + emitTokenWithComment(154, node.importClause.end, writeKeyword, node); writeSpace(); } emitExpression(node.moduleSpecifier); @@ -84202,7 +87359,7 @@ var ts; } function emitImportClause(node) { if (node.isTypeOnly) { - emitTokenWithComment(149, node.pos, writeKeyword, node); + emitTokenWithComment(150, node.pos, writeKeyword, node); writeSpace(); } emit(node.name); @@ -84215,7 +87372,7 @@ var ts; function emitNamespaceImport(node) { var asPos = emitTokenWithComment(41, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(126, asPos, writeKeyword, node); + emitTokenWithComment(127, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -84226,23 +87383,25 @@ var ts; emitImportOrExportSpecifier(node); } function emitExportAssignment(node) { - var nextPos = emitTokenWithComment(92, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93, node.pos, writeKeyword, node); writeSpace(); if (node.isExportEquals) { - emitTokenWithComment(62, nextPos, writeOperator, node); + emitTokenWithComment(63, nextPos, writeOperator, node); } else { - emitTokenWithComment(87, nextPos, writeKeyword, node); + emitTokenWithComment(88, nextPos, writeKeyword, node); } writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, node.isExportEquals ? + parenthesizer.getParenthesizeRightSideOfBinaryForOperator(63) : + parenthesizer.parenthesizeExpressionOfExportDefault); writeTrailingSemicolon(); } function emitExportDeclaration(node) { - var nextPos = emitTokenWithComment(92, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93, node.pos, writeKeyword, node); writeSpace(); if (node.isTypeOnly) { - nextPos = emitTokenWithComment(149, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(150, nextPos, writeKeyword, node); writeSpace(); } if (node.exportClause) { @@ -84254,18 +87413,18 @@ var ts; if (node.moduleSpecifier) { writeSpace(); var fromPos = node.exportClause ? node.exportClause.end : nextPos; - emitTokenWithComment(153, fromPos, writeKeyword, node); + emitTokenWithComment(154, fromPos, writeKeyword, node); writeSpace(); emitExpression(node.moduleSpecifier); } writeTrailingSemicolon(); } function emitNamespaceExportDeclaration(node) { - var nextPos = emitTokenWithComment(92, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93, node.pos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(126, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(127, nextPos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(140, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(141, nextPos, writeKeyword, node); writeSpace(); emit(node.name); writeTrailingSemicolon(); @@ -84273,7 +87432,7 @@ var ts; function emitNamespaceExport(node) { var asPos = emitTokenWithComment(41, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(126, asPos, writeKeyword, node); + emitTokenWithComment(127, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -84292,7 +87451,7 @@ var ts; if (node.propertyName) { emit(node.propertyName); writeSpace(); - emitTokenWithComment(126, node.propertyName.end, writeKeyword, node); + emitTokenWithComment(127, node.propertyName.end, writeKeyword, node); writeSpace(); } emit(node.name); @@ -84388,7 +87547,7 @@ var ts; } } function emitJsxTagName(node) { - if (node.kind === 78) { + if (node.kind === 79) { emitExpression(node); } else { @@ -84396,13 +87555,13 @@ var ts; } } function emitCaseClause(node) { - emitTokenWithComment(81, node.pos, writeKeyword, node); + emitTokenWithComment(82, node.pos, writeKeyword, node); writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); emitCaseOrDefaultClauseRest(node, node.statements, node.expression.end); } function emitDefaultClause(node) { - var pos = emitTokenWithComment(87, node.pos, writeKeyword, node); + var pos = emitTokenWithComment(88, node.pos, writeKeyword, node); emitCaseOrDefaultClauseRest(node, node.statements, pos); } function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) { @@ -84428,7 +87587,7 @@ var ts; emitList(node, node.types, 528); } function emitCatchClause(node) { - var openParenPos = emitTokenWithComment(82, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(83, node.pos, writeKeyword, node); writeSpace(); if (node.variableDeclaration) { emitTokenWithComment(20, openParenPos, writePunctuation, node); @@ -84447,7 +87606,7 @@ var ts; var commentRange = ts.getCommentRange(initializer); emitTrailingCommentsOfPosition(commentRange.pos); } - emitExpression(initializer); + emitExpression(initializer, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitShorthandPropertyAssignment(node) { emit(node.name); @@ -84455,34 +87614,37 @@ var ts; writeSpace(); writePunctuation("="); writeSpace(); - emitExpression(node.objectAssignmentInitializer); + emitExpression(node.objectAssignmentInitializer, parenthesizer.parenthesizeExpressionForDisallowedComma); } } function emitSpreadAssignment(node) { if (node.expression) { emitTokenWithComment(25, node.pos, writePunctuation, node); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); } } function emitEnumMember(node) { emit(node.name); - emitInitializer(node.initializer, node.name.end, node); + emitInitializer(node.initializer, node.name.end, node, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitJSDoc(node) { write("/**"); if (node.comment) { - var lines = node.comment.split(/\r\n?|\n/g); - for (var _a = 0, lines_2 = lines; _a < lines_2.length; _a++) { - var line = lines_2[_a]; - writeLine(); - writeSpace(); - writePunctuation("*"); - writeSpace(); - write(line); + var text = ts.getTextOfJSDocComment(node.comment); + if (text) { + var lines = text.split(/\r\n?|\n/g); + for (var _a = 0, lines_2 = lines; _a < lines_2.length; _a++) { + var line = lines_2[_a]; + writeLine(); + writeSpace(); + writePunctuation("*"); + writeSpace(); + write(line); + } } } if (node.tags) { - if (node.tags.length === 1 && node.tags[0].kind === 329 && !node.comment) { + if (node.tags.length === 1 && node.tags[0].kind === 337 && !node.comment) { writeSpace(); emit(node.tags[0]); } @@ -84527,7 +87689,7 @@ var ts; function emitJSDocTypedefTag(tag) { emitJSDocTagName(tag.tagName); if (tag.typeExpression) { - if (tag.typeExpression.kind === 301) { + if (tag.typeExpression.kind === 303) { emitJSDocTypeExpression(tag.typeExpression); } else { @@ -84546,7 +87708,7 @@ var ts; emit(tag.fullName); } emitJSDocComment(tag.comment); - if (tag.typeExpression && tag.typeExpression.kind === 312) { + if (tag.typeExpression && tag.typeExpression.kind === 316) { emitJSDocTypeLiteral(tag.typeExpression); } } @@ -84599,9 +87761,10 @@ var ts; emit(tagName); } function emitJSDocComment(comment) { - if (comment) { + var text = ts.getTextOfJSDocComment(comment); + if (text) { writeSpace(); - write(comment); + write(text); } } function emitJSDocTypeExpression(typeExpression) { @@ -84699,14 +87862,14 @@ var ts; emitHelpers(node); var index = ts.findIndex(statements, function (statement) { return !ts.isPrologueDirective(statement); }); emitTripleSlashDirectivesIfNeeded(node); - emitList(node, statements, 1, index === -1 ? statements.length : index); + emitList(node, statements, 1, undefined, index === -1 ? statements.length : index); popNameGenerationScope(node); } function emitPartiallyEmittedExpression(node) { emitExpression(node.expression); } function emitCommaList(node) { - emitExpressionList(node, node.elements, 528); + emitExpressionList(node, node.elements, 528, undefined); } function emitPrologueDirectives(statements, sourceFile, seenPrologueDirectives, recordBundleFileSection) { var needsToSetSourceFile = !!sourceFile; @@ -84843,12 +88006,12 @@ var ts; emit(node); } } - function emitInitializer(node, equalCommentStartPos, container) { + function emitInitializer(node, equalCommentStartPos, container, parenthesizerRule) { if (node) { writeSpace(); - emitTokenWithComment(62, equalCommentStartPos, writeOperator, container); + emitTokenWithComment(63, equalCommentStartPos, writeOperator, container); writeSpace(); - emitExpression(node); + emitExpression(node, parenthesizerRule); } } function emitNodeWithPrefix(prefix, prefixWriter, node, emit) { @@ -84863,10 +88026,10 @@ var ts; emit(node); } } - function emitExpressionWithLeadingSpace(node) { + function emitExpressionWithLeadingSpace(node, parenthesizerRule) { if (node) { writeSpace(); - emitExpression(node); + emitExpression(node, parenthesizerRule); } } function emitWithTrailingSpace(node) { @@ -84896,7 +88059,7 @@ var ts; emitList(parentNode, decorators, 2146305); } function emitTypeArguments(parentNode, typeArguments) { - emitList(parentNode, typeArguments, 53776); + emitList(parentNode, typeArguments, 53776, parenthesizer.parenthesizeMemberOfElementType); } function emitTypeParameters(parentNode, typeParameters) { if (ts.isFunctionLike(parentNode) && parentNode.typeArguments) { @@ -84935,12 +88098,6 @@ var ts; function emitParametersForIndexSignature(parentNode, parameters) { emitList(parentNode, parameters, 8848); } - function emitList(parentNode, children, format, start, count) { - emitNodeList(emit, parentNode, children, format, start, count); - } - function emitExpressionList(parentNode, children, format, start, count) { - emitNodeList(emitExpression, parentNode, children, format, start, count); - } function writeDelimiter(format) { switch (format & 60) { case 0: @@ -84963,7 +88120,13 @@ var ts; break; } } - function emitNodeList(emit, parentNode, children, format, start, count) { + function emitList(parentNode, children, format, parenthesizerRule, start, count) { + emitNodeList(emit, parentNode, children, format, parenthesizerRule, start, count); + } + function emitExpressionList(parentNode, children, format, parenthesizerRule, start, count) { + emitNodeList(emitExpression, parentNode, children, format, parenthesizerRule, start, count); + } + function emitNodeList(emit, parentNode, children, format, parenthesizerRule, start, count) { if (start === void 0) { start = 0; } if (count === void 0) { count = children ? children.length - start : 0; } var isUndefined = children === undefined; @@ -84982,7 +88145,7 @@ var ts; } if (format & 15360) { writePunctuation(getOpeningBracket(format)); - if (isEmpty && !isUndefined) { + if (isEmpty && children) { emitTrailingCommentsOfPosition(children.pos, true); } } @@ -84990,7 +88153,7 @@ var ts; onBeforeEmitNodeArray(children); } if (isEmpty) { - if (format & 1 && !(preserveSourceNewlines && ts.rangeIsOnSingleLine(parentNode, currentSourceFile))) { + if (format & 1 && !(preserveSourceNewlines && (!parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) { writeLine(); } else if (format & 256 && !(format & 524288)) { @@ -84998,6 +88161,7 @@ var ts; } } else { + ts.Debug.type(children); var mayEmitInterveningComments = (format & 262144) === 0; var shouldEmitInterveningComments = mayEmitInterveningComments; var leadingLineTerminatorCount = getLeadingLineTerminatorCount(parentNode, children, format); @@ -85021,7 +88185,7 @@ var ts; writeDelimiter(format); } else if (previousSibling) { - if (format & 60 && previousSibling.end !== parentNode.end) { + if (format & 60 && previousSibling.end !== (parentNode ? parentNode.end : -1)) { emitLeadingCommentsOfPosition(previousSibling.end); } writeDelimiter(format); @@ -85050,7 +88214,12 @@ var ts; shouldEmitInterveningComments = mayEmitInterveningComments; } nextListElementPos = child.pos; - emit(child); + if (emit.length === 1) { + emit(child); + } + else { + emit(child, parenthesizerRule); + } if (shouldDecreaseIndentAfterEmit) { decreaseIndent(); shouldDecreaseIndentAfterEmit = false; @@ -85068,7 +88237,7 @@ var ts; writePunctuation(","); } } - if (previousSibling && parentNode.end !== previousSibling.end && (format & 60) && !skipTrailingComments) { + if (previousSibling && (parentNode ? parentNode.end : -1) !== previousSibling.end && (format & 60) && !skipTrailingComments) { emitLeadingCommentsOfPosition(hasTrailingComma && (children === null || children === void 0 ? void 0 : children.end) ? children.end : previousSibling.end); } if (format & 128) { @@ -85087,7 +88256,7 @@ var ts; onAfterEmitNodeArray(children); } if (format & 15360) { - if (isEmpty && !isUndefined) { + if (isEmpty && children) { emitLeadingCommentsOfPosition(children.end); } writePunctuation(getClosingBracket(format)); @@ -85213,7 +88382,7 @@ var ts; } var firstChild_1 = children[0]; if (firstChild_1 === undefined) { - return ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; + return !parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; } if (firstChild_1.pos === nextListElementPos) { return 0; @@ -85221,7 +88390,8 @@ var ts; if (firstChild_1.kind === 11) { return 0; } - if (!ts.positionIsSynthesized(parentNode.pos) && + if (parentNode && + !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(firstChild_1) && (!firstChild_1.parent || ts.getOriginalNode(firstChild_1.parent) === ts.getOriginalNode(parentNode))) { if (preserveSourceNewlines) { @@ -85243,10 +88413,10 @@ var ts; if (nextNode.kind === 11) { return 0; } - else if (!ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode) && previousNode.parent === nextNode.parent) { - if (preserveSourceNewlines) { - return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); - } + else if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) { + return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); + } + else if (!preserveSourceNewlines && !ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) { return ts.rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile) ? 0 : 1; } else if (synthesizedNodeStartsOnNewLine(previousNode, format) || synthesizedNodeStartsOnNewLine(nextNode, format)) { @@ -85265,9 +88435,9 @@ var ts; } var lastChild = ts.lastOrUndefined(children); if (lastChild === undefined) { - return ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; + return !parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; } - if (!ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) { + if (parentNode && !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) { if (preserveSourceNewlines) { var end_1 = ts.isNodeArray(children) && !ts.positionIsSynthesized(children.end) ? children.end : lastChild.end; return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenPositionAndNextNonWhitespaceCharacter(end_1, parentNode.end, currentSourceFile, includeComments); }); @@ -85337,7 +88507,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 207 && ts.nodeIsSynthesized(node)) { + while (node.kind === 209 && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -85401,84 +88571,84 @@ var ts; if (!node) return; switch (node.kind) { - case 230: + case 232: ts.forEach(node.statements, generateNames); break; + case 247: case 245: - case 243: - case 235: - case 236: + case 237: + case 238: generateNames(node.statement); break; - case 234: + case 236: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 237: case 239: - case 238: + case 241: + case 240: generateNames(node.initializer); generateNames(node.statement); break; - case 244: + case 246: generateNames(node.caseBlock); break; - case 258: + case 260: ts.forEach(node.clauses, generateNames); break; - case 284: - case 285: + case 286: + case 287: ts.forEach(node.statements, generateNames); break; - case 247: + case 249: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 287: + case 289: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 232: + case 234: generateNames(node.declarationList); break; - case 250: + case 252: ts.forEach(node.declarations, generateNames); break; - case 249: - case 160: - case 198: - case 252: + case 251: + case 162: + case 200: + case 254: generateNameIfNeeded(node.name); break; - case 251: + case 253: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 196: - case 197: + case 198: + case 199: ts.forEach(node.elements, generateNames); break; - case 261: + case 263: generateNames(node.importClause); break; - case 262: + case 264: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 263: + case 265: generateNameIfNeeded(node.name); break; - case 269: + case 271: generateNameIfNeeded(node.name); break; - case 264: + case 266: ts.forEach(node.elements, generateNames); break; - case 265: + case 267: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -85487,12 +88657,12 @@ var ts; if (!node) return; switch (node.kind) { - case 288: - case 289: - case 163: + case 290: + case 291: case 165: case 167: - case 168: + case 169: + case 170: generateNameIfNeeded(node.name); break; } @@ -85624,25 +88794,25 @@ var ts; } function generateNameForNode(node, flags) { switch (node.kind) { - case 78: + case 79: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16), !!(flags & 8)); - case 256: - case 255: + case 258: + case 257: return generateNameForModuleOrEnum(node); - case 261: - case 267: + case 263: + case 269: return generateNameForImportOrExportDeclaration(node); - case 251: - case 252: - case 266: + case 253: + case 254: + case 268: return generateNameForExportDefault(); - case 221: + case 223: return generateNameForClassExpression(); - case 165: case 167: - case 168: + case 169: + case 170: return generateNameForMethodOrAccessor(node); - case 158: + case 160: return makeTempVariableName(0, true); default: return makeTempVariableName(0); @@ -85675,54 +88845,65 @@ var ts; return node; } function pipelineEmitWithComments(hint, node) { - ts.Debug.assert(lastNode === node || lastSubstitution === node); + var pipelinePhase = getNextPipelinePhase(2, hint, node); + var savedContainerPos = containerPos; + var savedContainerEnd = containerEnd; + var savedDeclarationListContainerEnd = declarationListContainerEnd; + emitCommentsBeforeNode(node); + pipelinePhase(hint, node); + emitCommentsAfterNode(node, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd); + } + function emitCommentsBeforeNode(node) { + var emitFlags = ts.getEmitFlags(node); + var commentRange = ts.getCommentRange(node); + emitLeadingCommentsOfNode(node, emitFlags, commentRange.pos, commentRange.end); + if (emitFlags & 2048) { + commentsDisabled = true; + } + } + function emitCommentsAfterNode(node, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd) { + var emitFlags = ts.getEmitFlags(node); + var commentRange = ts.getCommentRange(node); + if (emitFlags & 2048) { + commentsDisabled = false; + } + emitTrailingCommentsOfNode(node, emitFlags, commentRange.pos, commentRange.end, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd); + } + function emitLeadingCommentsOfNode(node, emitFlags, pos, end) { enterComment(); hasWrittenComment = false; - var emitFlags = ts.getEmitFlags(node); - var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; - var isEmittedNode = node.kind !== 335; var skipLeadingComments = pos < 0 || (emitFlags & 512) !== 0 || node.kind === 11; var skipTrailingComments = end < 0 || (emitFlags & 1024) !== 0 || node.kind === 11; - var savedContainerPos = containerPos; - var savedContainerEnd = containerEnd; - var savedDeclarationListContainerEnd = declarationListContainerEnd; if ((pos > 0 || end > 0) && pos !== end) { if (!skipLeadingComments) { - emitLeadingComments(pos, isEmittedNode); + emitLeadingComments(pos, node.kind !== 343); } if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512) !== 0)) { containerPos = pos; } if (!skipTrailingComments || (end >= 0 && (emitFlags & 1024) !== 0)) { containerEnd = end; - if (node.kind === 250) { + if (node.kind === 252) { declarationListContainerEnd = end; } } } ts.forEach(ts.getSyntheticLeadingComments(node), emitLeadingSynthesizedComment); exitComment(); - var pipelinePhase = getNextPipelinePhase(2, hint, node); - if (emitFlags & 2048) { - commentsDisabled = true; - pipelinePhase(hint, node); - commentsDisabled = false; - } - else { - pipelinePhase(hint, node); - } + } + function emitTrailingCommentsOfNode(node, emitFlags, pos, end, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd) { enterComment(); + var skipTrailingComments = end < 0 || (emitFlags & 1024) !== 0 || node.kind === 11; ts.forEach(ts.getSyntheticTrailingComments(node), emitTrailingSynthesizedComment); if ((pos > 0 || end > 0) && pos !== end) { containerPos = savedContainerPos; containerEnd = savedContainerEnd; declarationListContainerEnd = savedDeclarationListContainerEnd; - if (!skipTrailingComments && isEmittedNode) { + if (!skipTrailingComments && node.kind !== 343) { emitTrailingComments(end); } } exitComment(); - ts.Debug.assert(lastNode === node || lastSubstitution === node); } function emitLeadingSynthesizedComment(comment) { if (comment.hasLeadingNewline || comment.kind === 2) { @@ -85782,6 +88963,23 @@ var ts; } exitComment(); } + function siblingNodePositionsAreComparable(previousNode, nextNode) { + if (ts.nodeIsSynthesized(previousNode) || ts.nodeIsSynthesized(nextNode)) { + return false; + } + if (nextNode.pos < previousNode.end) { + return false; + } + previousNode = ts.getOriginalNode(previousNode); + nextNode = ts.getOriginalNode(nextNode); + var parent = previousNode.parent; + if (!parent || parent !== nextNode.parent) { + return false; + } + var parentNodeArray = ts.getContainingNodeArray(previousNode); + var prevNodeIndex = parentNodeArray === null || parentNodeArray === void 0 ? void 0 : parentNodeArray.indexOf(previousNode); + return prevNodeIndex !== undefined && prevNodeIndex > -1 && parentNodeArray.indexOf(nextNode) === prevNodeIndex + 1; + } function emitLeadingComments(pos, isEmittedNode) { hasWrittenComment = false; if (isEmittedNode) { @@ -85933,42 +89131,47 @@ var ts; } return node.parsedSourceMap || undefined; } - function pipelineEmitWithSourceMap(hint, node) { - ts.Debug.assert(lastNode === node || lastSubstitution === node); + function pipelineEmitWithSourceMaps(hint, node) { var pipelinePhase = getNextPipelinePhase(3, hint, node); - if (ts.isUnparsedSource(node) || ts.isUnparsedPrepend(node)) { - pipelinePhase(hint, node); - } - else if (ts.isUnparsedNode(node)) { + emitSourceMapsBeforeNode(node); + pipelinePhase(hint, node); + emitSourceMapsAfterNode(node); + } + function emitSourceMapsBeforeNode(node) { + var emitFlags = ts.getEmitFlags(node); + var sourceMapRange = ts.getSourceMapRange(node); + if (ts.isUnparsedNode(node)) { + ts.Debug.assertIsDefined(node.parent, "UnparsedNodes must have parent pointers"); var parsed = getParsedSourceMap(node.parent); if (parsed && sourceMapGenerator) { sourceMapGenerator.appendSourceMap(writer.getLine(), writer.getColumn(), parsed, node.parent.sourceMapPath, node.parent.getLineAndCharacterOfPosition(node.pos), node.parent.getLineAndCharacterOfPosition(node.end)); } - pipelinePhase(hint, node); } else { - var _a = ts.getSourceMapRange(node), pos = _a.pos, end = _a.end, _b = _a.source, source = _b === void 0 ? sourceMapSource : _b; - var emitFlags = ts.getEmitFlags(node); - if (node.kind !== 335 + var source = sourceMapRange.source || sourceMapSource; + if (node.kind !== 343 && (emitFlags & 16) === 0 - && pos >= 0) { - emitSourcePos(source, skipSourceTrivia(source, pos)); + && sourceMapRange.pos >= 0) { + emitSourcePos(sourceMapRange.source || sourceMapSource, skipSourceTrivia(source, sourceMapRange.pos)); } if (emitFlags & 64) { sourceMapsDisabled = true; - pipelinePhase(hint, node); - sourceMapsDisabled = false; } - else { - pipelinePhase(hint, node); + } + } + function emitSourceMapsAfterNode(node) { + var emitFlags = ts.getEmitFlags(node); + var sourceMapRange = ts.getSourceMapRange(node); + if (!ts.isUnparsedNode(node)) { + if (emitFlags & 64) { + sourceMapsDisabled = false; } - if (node.kind !== 335 + if (node.kind !== 343 && (emitFlags & 32) === 0 - && end >= 0) { - emitSourcePos(source, end); + && sourceMapRange.end >= 0) { + emitSourcePos(sourceMapRange.source || sourceMapSource, sourceMapRange.end); } } - ts.Debug.assert(lastNode === node || lastSubstitution === node); } function skipSourceTrivia(source, pos) { return source.skipTrivia ? source.skipTrivia(pos) : ts.skipTrivia(source.text, pos); @@ -86090,12 +89293,20 @@ var ts; return ts.getBaseFileName(ts.normalizePath(fileName)); } function createCachedFileSystemEntries(rootDir, rootDirPath) { - var resultFromHost = { - files: ts.map(host.readDirectory(rootDir, undefined, undefined, ["*.*"]), getBaseNameOfFileName) || [], - directories: host.getDirectories(rootDir) || [] - }; - cachedReadDirectoryResult.set(ts.ensureTrailingDirectorySeparator(rootDirPath), resultFromHost); - return resultFromHost; + var _a; + if (!host.realpath || ts.ensureTrailingDirectorySeparator(toPath(host.realpath(rootDir))) === rootDirPath) { + var resultFromHost = { + files: ts.map(host.readDirectory(rootDir, undefined, undefined, ["*.*"]), getBaseNameOfFileName) || [], + directories: host.getDirectories(rootDir) || [] + }; + cachedReadDirectoryResult.set(ts.ensureTrailingDirectorySeparator(rootDirPath), resultFromHost); + return resultFromHost; + } + if ((_a = host.directoryExists) === null || _a === void 0 ? void 0 : _a.call(host, rootDir)) { + cachedReadDirectoryResult.set(rootDirPath, false); + return false; + } + return undefined; } function tryReadDirectory(rootDir, rootDirPath) { rootDirPath = ts.ensureTrailingDirectorySeparator(rootDirPath); @@ -86164,17 +89375,32 @@ var ts; } function readDirectory(rootDir, extensions, excludes, includes, depth) { var rootDirPath = toPath(rootDir); - var result = tryReadDirectory(rootDir, rootDirPath); - if (result) { + var rootResult = tryReadDirectory(rootDir, rootDirPath); + var rootSymLinkResult; + if (rootResult !== undefined) { return ts.matchFiles(rootDir, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, depth, getFileSystemEntries, realpath); } return host.readDirectory(rootDir, extensions, excludes, includes, depth); function getFileSystemEntries(dir) { var path = toPath(dir); if (path === rootDirPath) { - return result; - } - return tryReadDirectory(dir, path) || ts.emptyFileSystemEntries; + return rootResult || getFileSystemEntriesFromHost(dir, path); + } + var result = tryReadDirectory(dir, path); + return result !== undefined ? + result || getFileSystemEntriesFromHost(dir, path) : + ts.emptyFileSystemEntries; + } + function getFileSystemEntriesFromHost(dir, path) { + if (rootSymLinkResult && path === rootDirPath) + return rootSymLinkResult; + var result = { + files: ts.map(host.readDirectory(dir, undefined, undefined, ["*.*"]), getBaseNameOfFileName) || ts.emptyArray, + directories: host.getDirectories(dir) || ts.emptyArray + }; + if (path === rootDirPath) + rootSymLinkResult = result; + return result; } } function realpath(s) { @@ -86182,7 +89408,7 @@ var ts; } function addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath) { var existingResult = getCachedFileSystemEntries(fileOrDirectoryPath); - if (existingResult) { + if (existingResult !== undefined) { clearCache(); return undefined; } @@ -86230,9 +89456,9 @@ var ts; ConfigFileProgramReloadLevel[ConfigFileProgramReloadLevel["Partial"] = 1] = "Partial"; ConfigFileProgramReloadLevel[ConfigFileProgramReloadLevel["Full"] = 2] = "Full"; })(ConfigFileProgramReloadLevel = ts.ConfigFileProgramReloadLevel || (ts.ConfigFileProgramReloadLevel = {})); - function updateSharedExtendedConfigFileWatcher(projectPath, parsed, extendedConfigFilesMap, createExtendedConfigFileWatch, toPath) { + function updateSharedExtendedConfigFileWatcher(projectPath, options, extendedConfigFilesMap, createExtendedConfigFileWatch, toPath) { var _a; - var extendedConfigs = ts.arrayToMap(((_a = parsed === null || parsed === void 0 ? void 0 : parsed.options.configFile) === null || _a === void 0 ? void 0 : _a.extendedSourceFiles) || ts.emptyArray, toPath); + var extendedConfigs = ts.arrayToMap(((_a = options === null || options === void 0 ? void 0 : options.configFile) === null || _a === void 0 ? void 0 : _a.extendedSourceFiles) || ts.emptyArray, toPath); extendedConfigFilesMap.forEach(function (watcher, extendedConfigFilePath) { if (!extendedConfigs.has(extendedConfigFilePath)) { watcher.projects.delete(projectPath); @@ -86247,12 +89473,12 @@ var ts; else { extendedConfigFilesMap.set(extendedConfigFilePath, { projects: new ts.Set([projectPath]), - fileWatcher: createExtendedConfigFileWatch(extendedConfigFileName, extendedConfigFilePath), + watcher: createExtendedConfigFileWatch(extendedConfigFileName, extendedConfigFilePath), close: function () { var existing = extendedConfigFilesMap.get(extendedConfigFilePath); if (!existing || existing.projects.size !== 0) return; - existing.fileWatcher.close(); + existing.watcher.close(); extendedConfigFilesMap.delete(extendedConfigFilePath); }, }); @@ -86260,6 +89486,25 @@ var ts; }); } ts.updateSharedExtendedConfigFileWatcher = updateSharedExtendedConfigFileWatcher; + function clearSharedExtendedConfigFileWatcher(projectPath, extendedConfigFilesMap) { + extendedConfigFilesMap.forEach(function (watcher) { + if (watcher.projects.delete(projectPath)) + watcher.close(); + }); + } + ts.clearSharedExtendedConfigFileWatcher = clearSharedExtendedConfigFileWatcher; + function cleanExtendedConfigCache(extendedConfigCache, extendedConfigFilePath, toPath) { + if (!extendedConfigCache.delete(extendedConfigFilePath)) + return; + extendedConfigCache.forEach(function (_a, key) { + var _b; + var extendedResult = _a.extendedResult; + if ((_b = extendedResult.extendedSourceFiles) === null || _b === void 0 ? void 0 : _b.some(function (extendedFile) { return toPath(extendedFile) === extendedConfigFilePath; })) { + cleanExtendedConfigCache(extendedConfigCache, key, toPath); + } + }); + } + ts.cleanExtendedConfigCache = cleanExtendedConfigCache; function updateMissingFilePathsWatch(program, missingFileWatches, createMissingFileWatch) { var missingFilePaths = program.getMissingFilePaths(); var newMissingFilePathMap = ts.arrayToMap(missingFilePaths, ts.identity, ts.returnTrue); @@ -86291,7 +89536,7 @@ var ts; } ts.updateWatchingWildcardDirectories = updateWatchingWildcardDirectories; function isIgnoredFileFromWildCardWatching(_a) { - 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; + 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); @@ -86310,7 +89555,7 @@ var ts; } if (!program) return false; - if (options.outFile || options.outDir) + if (ts.outFile(options) || options.outDir) return false; if (ts.fileExtensionIs(fileOrDirectoryPath, ".d.ts")) { if (options.declarationDir) @@ -86320,7 +89565,8 @@ var ts; return false; } var filePathWithoutExtension = ts.removeFileExtension(fileOrDirectoryPath); - var realProgram = isBuilderProgram(program) ? program.getProgramOrUndefined() : program; + var realProgram = ts.isArray(program) ? undefined : isBuilderProgram(program) ? program.getProgramOrUndefined() : program; + var builderProgram = !realProgram && !ts.isArray(program) ? program : undefined; if (hasSourceFile((filePathWithoutExtension + ".ts")) || hasSourceFile((filePathWithoutExtension + ".tsx"))) { writeLog("Project: " + configFileName + " Detected output file: " + fileOrDirectory); @@ -86330,7 +89576,9 @@ var ts; function hasSourceFile(file) { return realProgram ? !!realProgram.getSourceFileByPath(file) : - program.getState().fileInfos.has(file); + builderProgram ? + builderProgram.getState().fileInfos.has(file) : + !!ts.find(program, function (rootFile) { return toPath(rootFile) === file; }); } } ts.isIgnoredFileFromWildCardWatching = isIgnoredFileFromWildCardWatching; @@ -86782,8 +90030,8 @@ var ts; var lineStart = ts.getPositionOfLineAndCharacter(file, i, 0); var lineEnd = i < lastLineInFile ? ts.getPositionOfLineAndCharacter(file, i + 1, 0) : file.text.length; var lineContent = file.text.slice(lineStart, lineEnd); - lineContent = lineContent.replace(/\s+$/g, ""); - lineContent = lineContent.replace("\t", " "); + lineContent = ts.trimStringEnd(lineContent); + lineContent = lineContent.replace(/\t/g, " "); context += indent + formatColorAndReset(ts.padLeft(i + 1 + "", gutterWidth), gutterStyleSequence) + gutterSeparator; context += lineContent + host.getNewLine(); context += indent + formatColorAndReset(ts.padLeft("", gutterWidth), gutterStyleSequence) + gutterSeparator; @@ -86970,30 +90218,23 @@ var ts; return { file: file, pos: pos, end: end, packageId: packageId }; } ts.getReferencedFileLocation = getReferencedFileLocation; - function isProgramUptoDate(program, rootFileNames, newOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, projectReferences) { - if (!program || (hasChangedAutomaticTypeDirectiveNames === null || hasChangedAutomaticTypeDirectiveNames === void 0 ? void 0 : hasChangedAutomaticTypeDirectiveNames())) { + function isProgramUptoDate(program, rootFileNames, newOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences) { + if (!program || (hasChangedAutomaticTypeDirectiveNames === null || hasChangedAutomaticTypeDirectiveNames === void 0 ? void 0 : hasChangedAutomaticTypeDirectiveNames())) return false; - } - if (!ts.arrayIsEqualTo(program.getRootFileNames(), rootFileNames)) { + if (!ts.arrayIsEqualTo(program.getRootFileNames(), rootFileNames)) return false; - } var seenResolvedRefs; - if (!ts.arrayIsEqualTo(program.getProjectReferences(), projectReferences, projectReferenceUptoDate)) { + if (!ts.arrayIsEqualTo(program.getProjectReferences(), projectReferences, projectReferenceUptoDate)) return false; - } - if (program.getSourceFiles().some(sourceFileNotUptoDate)) { + if (program.getSourceFiles().some(sourceFileNotUptoDate)) return false; - } - if (program.getMissingFilePaths().some(fileExists)) { + if (program.getMissingFilePaths().some(fileExists)) return false; - } var currentOptions = program.getCompilerOptions(); - if (!ts.compareDataObjects(currentOptions, newOptions)) { + if (!ts.compareDataObjects(currentOptions, newOptions)) return false; - } - if (currentOptions.configFile && newOptions.configFile) { + if (currentOptions.configFile && newOptions.configFile) return currentOptions.configFile.text === newOptions.configFile.text; - } return true; function sourceFileNotUptoDate(sourceFile) { return !sourceFileVersionUptoDate(sourceFile) || @@ -87003,25 +90244,28 @@ var ts; return sourceFile.version === getSourceVersion(sourceFile.resolvedPath, sourceFile.fileName); } function projectReferenceUptoDate(oldRef, newRef, index) { - if (!ts.projectReferenceIsEqualTo(oldRef, newRef)) { - return false; - } - return resolvedProjectReferenceUptoDate(program.getResolvedProjectReferences()[index], oldRef); + return ts.projectReferenceIsEqualTo(oldRef, newRef) && + resolvedProjectReferenceUptoDate(program.getResolvedProjectReferences()[index], oldRef); } function resolvedProjectReferenceUptoDate(oldResolvedRef, oldRef) { if (oldResolvedRef) { - if (ts.contains(seenResolvedRefs, oldResolvedRef)) { + if (ts.contains(seenResolvedRefs, oldResolvedRef)) return true; - } - if (!sourceFileVersionUptoDate(oldResolvedRef.sourceFile)) { + var refPath_1 = resolveProjectReferencePath(oldRef); + var newParsedCommandLine = getParsedCommandLine(refPath_1); + if (!newParsedCommandLine) + return false; + if (oldResolvedRef.commandLine.options.configFile !== newParsedCommandLine.options.configFile) + return false; + if (!ts.arrayIsEqualTo(oldResolvedRef.commandLine.fileNames, newParsedCommandLine.fileNames)) return false; - } (seenResolvedRefs || (seenResolvedRefs = [])).push(oldResolvedRef); return !ts.forEach(oldResolvedRef.references, function (childResolvedRef, index) { return !resolvedProjectReferenceUptoDate(childResolvedRef, oldResolvedRef.commandLine.projectReferences[index]); }); } - return !fileExists(resolveProjectReferencePath(oldRef)); + var refPath = resolveProjectReferencePath(oldRef); + return !getParsedCommandLine(refPath); } } ts.isProgramUptoDate = isProgramUptoDate; @@ -87033,10 +90277,7 @@ var ts; function shouldProgramCreateNewSourceFiles(program, newOptions) { if (!program) return false; - var oldOptions = program.getCompilerOptions(); - return !!ts.sourceFileAffectingCompilerOptions.some(function (option) { - return !ts.isJsonEqual(ts.getCompilerOptionValue(oldOptions, option), ts.getCompilerOptionValue(newOptions, option)); - }); + return ts.optionsHaveChanges(program.getCompilerOptions(), newOptions, ts.sourceFileAffectingCompilerOptions); } function createCreateProgramOptions(rootNames, options, host, oldProgram, configFileParsingDiagnostics) { return { @@ -87070,7 +90311,7 @@ var ts; var currentNodeModulesDepth = 0; var modulesWithElidedImports = new ts.Map(); var sourceFilesFoundSearchingNodeModules = new ts.Map(); - ts.tracing.push("program", "createProgram", { configFilePath: options.configFilePath, rootDir: options.rootDir }, true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "createProgram", { configFilePath: options.configFilePath, rootDir: options.rootDir }, true); ts.performance.mark("beforeProgram"); var host = createProgramOptions.host || createCompilerHost(options); var configParsingHost = parseConfigHostFromCompilerHostLike(host); @@ -87084,6 +90325,7 @@ var ts; var hasEmitBlockingDiagnostics = new ts.Map(); var _compilerOptionsObjectLiteralSyntax; var moduleResolutionCache; + var typeReferenceDirectiveResolutionCache; var actualResolveModuleNamesWorker; var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse; if (host.resolveModuleNames) { @@ -87097,7 +90339,7 @@ var ts; }); }; } else { - moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, function (x) { return host.getCanonicalFileName(x); }, options); + moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName, options); var loader_1 = function (moduleName, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache, redirectedReference).resolvedModule; }; actualResolveModuleNamesWorker = function (moduleNames, containingFile, _reusedNames, redirectedReference) { return loadWithLocalCache(ts.Debug.checkEachDefined(moduleNames), containingFile, redirectedReference, loader_1); }; } @@ -87106,7 +90348,8 @@ var ts; actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options); }; } else { - var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference).resolvedTypeReferenceDirective; }; + typeReferenceDirectiveResolutionCache = ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache()); + var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache).resolvedTypeReferenceDirective; }; actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { return loadWithLocalCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, loader_2); }; } var packageIdToSourceFile = new ts.Map(); @@ -87130,13 +90373,13 @@ var ts; getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect, forEachResolvedProjectReference: forEachResolvedProjectReference }), onProgramCreateComplete = _d.onProgramCreateComplete, fileExists = _d.fileExists, directoryExists = _d.directoryExists; - ts.tracing.push("program", "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram }); var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); var structureIsReused; - ts.tracing.push("program", "tryReuseStructureFromOldProgram", {}); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "tryReuseStructureFromOldProgram", {}); structureIsReused = tryReuseStructureFromOldProgram(); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); if (structureIsReused !== 2) { processingDefaultLibFiles = []; processingOtherFiles = []; @@ -87174,19 +90417,19 @@ var ts; }); } } - ts.tracing.push("program", "processRootFiles", { count: rootNames.length }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "processRootFiles", { count: rootNames.length }); ts.forEach(rootNames, function (name, index) { return processRootFile(name, false, false, { kind: ts.FileIncludeKind.RootFile, index: index }); }); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); var typeReferences = rootNames.length ? ts.getAutomaticTypeDirectiveNames(options, host) : ts.emptyArray; if (typeReferences.length) { - ts.tracing.push("program", "processTypeReferences", { count: typeReferences.length }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "processTypeReferences", { count: typeReferences.length }); var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory(); var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile); var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename); for (var i = 0; i < typeReferences.length; i++) { processTypeReferenceDirective(typeReferences[i], resolutions[i], { kind: ts.FileIncludeKind.AutomaticTypeDirectiveFile, typeReference: typeReferences[i], packageId: (_b = resolutions[i]) === null || _b === void 0 ? void 0 : _b.packageId }); } - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } if (rootNames.length && !skipDefaultLib) { var defaultLibraryFileName = getDefaultLibraryFileName(); @@ -87218,12 +90461,24 @@ var ts; host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path)); } } - oldProgram.forEachResolvedProjectReference(function (resolvedProjectReference) { - if (!getResolvedProjectReferenceByPath(resolvedProjectReference.sourceFile.path)) { - host.onReleaseOldSourceFile(resolvedProjectReference.sourceFile, oldProgram.getCompilerOptions(), false); + if (!host.getParsedCommandLine) { + oldProgram.forEachResolvedProjectReference(function (resolvedProjectReference) { + if (!getResolvedProjectReferenceByPath(resolvedProjectReference.sourceFile.path)) { + host.onReleaseOldSourceFile(resolvedProjectReference.sourceFile, oldProgram.getCompilerOptions(), false); + } + }); + } + } + if (oldProgram && host.onReleaseParsedCommandLine) { + forEachProjectReference(oldProgram.getProjectReferences(), oldProgram.getResolvedProjectReferences(), function (oldResolvedRef, parent, index) { + var oldReference = (parent === null || parent === void 0 ? void 0 : parent.commandLine.projectReferences[index]) || oldProgram.getProjectReferences()[index]; + var oldRefPath = resolveProjectReferencePath(oldReference); + if (!(projectReferenceRedirects === null || projectReferenceRedirects === void 0 ? void 0 : projectReferenceRedirects.has(toPath(oldRefPath)))) { + host.onReleaseParsedCommandLine(oldRefPath, oldResolvedRef, oldProgram.getCompilerOptions()); } }); } + typeReferenceDirectiveResolutionCache = undefined; oldProgram = undefined; var program = { getRootFileNames: function () { return rootNames; }, @@ -87251,7 +90506,6 @@ var ts; getNodeCount: function () { return getDiagnosticsProducingTypeChecker().getNodeCount(); }, getIdentifierCount: function () { return getDiagnosticsProducingTypeChecker().getIdentifierCount(); }, getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); }, - getTypeCatalog: function () { return getDiagnosticsProducingTypeChecker().getTypeCatalog(); }, getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); }, getInstantiationCount: function () { return getDiagnosticsProducingTypeChecker().getInstantiationCount(); }, getRelationCacheSizes: function () { return getDiagnosticsProducingTypeChecker().getRelationCacheSizes(); }, @@ -87298,19 +90552,19 @@ var ts; verifyCompilerOptions(); ts.performance.mark("afterProgram"); ts.performance.measure("Program", "beforeProgram", "afterProgram"); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return program; function resolveModuleNamesWorker(moduleNames, containingFile, reusedNames) { if (!moduleNames.length) return ts.emptyArray; var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory); var redirectedReference = getRedirectReferenceForResolution(containingFile); - ts.tracing.push("program", "resolveModuleNamesWorker", { containingFileName: containingFileName }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "resolveModuleNamesWorker", { containingFileName: containingFileName }); ts.performance.mark("beforeResolveModule"); var result = actualResolveModuleNamesWorker(moduleNames, containingFileName, reusedNames, redirectedReference); ts.performance.mark("afterResolveModule"); ts.performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule"); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; } function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile) { @@ -87318,12 +90572,12 @@ var ts; return []; var containingFileName = !ts.isString(containingFile) ? ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile; var redirectedReference = !ts.isString(containingFile) ? getRedirectReferenceForResolution(containingFile) : undefined; - ts.tracing.push("program", "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName }); ts.performance.mark("beforeResolveTypeReference"); var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference); ts.performance.mark("afterResolveTypeReference"); ts.performance.measure("ResolveTypeReference", "beforeResolveTypeReference", "afterResolveTypeReference"); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; } function getRedirectReferenceForResolution(file) { @@ -87416,7 +90670,9 @@ var ts; var oldResolvedModule = ts.getResolvedModule(oldSourceFile, moduleName); if (oldResolvedModule) { if (ts.isTraceEnabled(options, host)) { - ts.trace(host, ts.Diagnostics.Reusing_resolution_of_module_0_to_file_1_from_old_program, moduleName, ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory)); + ts.trace(host, oldResolvedModule.packageId ? + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 : + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2, moduleName, ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory), oldResolvedModule.resolvedFileName, oldResolvedModule.packageId && ts.packageIdToString(oldResolvedModule.packageId)); } (result || (result = new Array(moduleNames.length)))[i] = oldResolvedModule; (reusedNames || (reusedNames = [])).push(moduleName); @@ -87482,7 +90738,9 @@ var ts; var newRef = (parent ? parent.commandLine.projectReferences : projectReferences)[index]; var newResolvedRef = parseProjectReferenceConfigFile(newRef); if (oldResolvedRef) { - return !newResolvedRef || newResolvedRef.sourceFile !== oldResolvedRef.sourceFile; + return !newResolvedRef || + newResolvedRef.sourceFile !== oldResolvedRef.sourceFile || + !ts.arrayIsEqualTo(oldResolvedRef.commandLine.fileNames, newResolvedRef.commandLine.fileNames); } else { return newResolvedRef !== undefined; @@ -87505,9 +90763,6 @@ var ts; if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) { return 0; } - if (!ts.arrayIsEqualTo(options.types, oldOptions.types)) { - return 0; - } if (!canReuseProjectReferences()) { return 0; } @@ -87563,7 +90818,7 @@ var ts; } if (fileChanged) { if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) { - return 0; + structureIsReused = 1; } if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { structureIsReused = 1; @@ -87631,7 +90886,7 @@ var ts; if (structureIsReused !== 2) { return structureIsReused; } - if ((_a = host.hasChangedAutomaticTypeDirectiveNames) === null || _a === void 0 ? void 0 : _a.call(host)) { + if (ts.changesAffectingProgramStructure(oldOptions, options) || ((_a = host.hasChangedAutomaticTypeDirectiveNames) === null || _a === void 0 ? void 0 : _a.call(host))) { return 1; } missingFilePaths = oldProgram.getMissingFilePaths(); @@ -87699,12 +90954,12 @@ var ts; } function emitBuildInfo(writeFileCallback) { ts.Debug.assert(!ts.outFile(options)); - ts.tracing.push("emit", "emitBuildInfo", {}, true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit", "emitBuildInfo", {}, true); ts.performance.mark("beforeEmit"); var emitResult = ts.emitFiles(ts.notImplementedResolver, getEmitHost(writeFileCallback), undefined, ts.noTransformers, false, true); ts.performance.mark("afterEmit"); ts.performance.measure("Emit", "beforeEmit", "afterEmit"); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return emitResult; } function getResolvedProjectReferences() { @@ -87748,9 +91003,9 @@ var ts; return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, false)); } function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) { - ts.tracing.push("emit", "emit", { path: sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.path }, true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit", "emit", { path: sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.path }, true); var result = runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit); }); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; } function isEmitBlocked(emitFileName) { @@ -87918,79 +91173,79 @@ var ts; return diagnostics; function walk(node, parent) { switch (parent.kind) { - case 160: - case 163: + case 162: case 165: + case 167: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?")); return "skip"; } - case 164: case 166: - case 167: case 168: - case 208: + case 169: + case 170: + case 210: + case 253: + case 211: case 251: - case 209: - case 249: if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files)); return "skip"; } } switch (node.kind) { - case 262: + case 264: if (node.isTypeOnly) { diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "import type")); return "skip"; } break; - case 267: + case 269: if (node.isTypeOnly) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "export type")); return "skip"; } break; - case 260: + case 262: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_TypeScript_files)); return "skip"; - case 266: + case 268: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 286: + case 288: var heritageClause = node; - if (heritageClause.token === 116) { + if (heritageClause.token === 117) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 253: - var interfaceKeyword = ts.tokenToString(117); + case 255: + var interfaceKeyword = ts.tokenToString(118); ts.Debug.assertIsDefined(interfaceKeyword); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, interfaceKeyword)); return "skip"; - case 256: - var moduleKeyword = node.flags & 16 ? ts.tokenToString(140) : ts.tokenToString(139); + case 258: + var moduleKeyword = node.flags & 16 ? ts.tokenToString(141) : ts.tokenToString(140); ts.Debug.assertIsDefined(moduleKeyword); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, moduleKeyword)); return "skip"; - case 254: + case 256: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_aliases_can_only_be_used_in_TypeScript_files)); return "skip"; - case 255: - var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(91)); + case 257: + var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(92)); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, enumKeyword)); return "skip"; - case 225: + case 227: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Non_null_assertions_can_only_be_used_in_TypeScript_files)); return "skip"; - case 224: + case 226: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.Type_assertion_expressions_can_only_be_used_in_TypeScript_files)); return "skip"; - case 206: + case 208: ts.Debug.fail(); } } @@ -87999,48 +91254,48 @@ 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 252: - case 221: - case 165: - case 166: + case 254: + case 223: case 167: case 168: - case 208: - case 251: - case 209: + case 169: + case 170: + case 210: + case 253: + case 211: if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_parameter_declarations_can_only_be_used_in_TypeScript_files)); return "skip"; } - case 232: + case 234: if (nodes === parent.modifiers) { - checkModifiers(parent.modifiers, parent.kind === 232); + checkModifiers(parent.modifiers, parent.kind === 234); return "skip"; } break; - case 163: + case 165: if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 123) { + if (modifier.kind !== 124) { diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, ts.tokenToString(modifier.kind))); } } return "skip"; } break; - case 160: + case 162: if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Parameter_modifiers_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 203: - case 204: - case 223: - case 274: - case 275: case 205: + case 206: + case 225: + case 276: + case 277: + case 207: if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_arguments_can_only_be_used_in_TypeScript_files)); return "skip"; @@ -88052,21 +91307,22 @@ var ts; for (var _i = 0, modifiers_2 = modifiers; _i < modifiers_2.length; _i++) { var modifier = modifiers_2[_i]; switch (modifier.kind) { - case 84: + case 85: if (isConstValid) { continue; } - case 122: - case 120: + case 123: case 121: - case 142: - case 133: - case 125: + case 122: + case 143: + case 134: + case 126: + case 157: diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, ts.tokenToString(modifier.kind))); break; - case 123: - case 92: - case 87: + case 124: + case 93: + case 88: } } } @@ -88134,8 +91390,8 @@ var ts; return a.fileName === b.fileName; } function moduleNameIsEqualTo(a, b) { - return a.kind === 78 - ? b.kind === 78 && a.escapedText === b.escapedText + return a.kind === 79 + ? b.kind === 79 && a.escapedText === b.escapedText : b.kind === 10 && a.text === b.text; } function createSyntheticImport(text, file) { @@ -88334,13 +91590,13 @@ var ts; return redirect; } function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, reason, packageId) { - ts.tracing.push("program", "findSourceFile", { + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "findSourceFile", { fileName: fileName, isDefaultLib: isDefaultLib || undefined, fileIncludeKind: ts.FileIncludeKind[reason.kind], }); var result = findSourceFileWorker(fileName, path, isDefaultLib, ignoreNoDefaultLib, reason, packageId); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; } function findSourceFileWorker(fileName, path, isDefaultLib, ignoreNoDefaultLib, reason, packageId) { @@ -88565,9 +91821,9 @@ var ts; } } function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, reason) { - 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: !!resolveModuleNamesReusingOldState, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined }); processTypeReferenceDirectiveWorker(typeReferenceDirective, resolvedTypeReferenceDirective, reason); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } function processTypeReferenceDirectiveWorker(typeReferenceDirective, resolvedTypeReferenceDirective, reason) { var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective); @@ -88630,11 +91886,13 @@ var ts; return host.getCanonicalFileName(fileName); } function processImportedModules(file) { + var _a; collectExternalModuleReferences(file); if (file.imports.length || file.moduleAugmentations.length) { var moduleNames = getModuleNames(file); var resolutions = resolveModuleNamesReusingOldState(moduleNames, file); ts.Debug.assert(resolutions.length === moduleNames.length); + var optionsForFile = (useSourceOfProjectReferenceRedirect ? (_a = getRedirectReferenceForResolution(file)) === null || _a === void 0 ? void 0 : _a.commandLine.options : undefined) || options; for (var index = 0; index < moduleNames.length; index++) { var resolution = resolutions[index]; ts.setResolvedModule(file, moduleNames[index], resolution); @@ -88650,11 +91908,11 @@ var ts; } var elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModuleJsDepth; var shouldAddFile = resolvedFileName - && !getResolutionDiagnostic(options, resolution) - && !options.noResolve + && !getResolutionDiagnostic(optionsForFile, resolution) + && !optionsForFile.noResolve && index < file.imports.length && !elideImport - && !(isJsFile && !ts.getAllowJSCompilerOption(options)) + && !(isJsFile && !ts.getAllowJSCompilerOption(optionsForFile)) && (ts.isInJSFile(file.imports[index]) || !(file.imports[index].flags & 4194304)); if (elideImport) { modulesWithElidedImports.set(file.path, true); @@ -88735,6 +91993,9 @@ var ts; if (options.strictPropertyInitialization && !ts.getStrictOptionValue(options, "strictNullChecks")) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictPropertyInitialization", "strictNullChecks"); } + if (options.strictOptionalProperties && !ts.getStrictOptionValue(options, "strictNullChecks")) { + createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictOptionalProperties", "strictNullChecks"); + } if (options.isolatedModules) { if (options.out) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules"); @@ -88849,6 +92110,9 @@ var ts; if (options.module === ts.ModuleKind.None && languageVersion < 2) { 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; }); if (firstNonExternalModuleSourceFile) { var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); @@ -88877,6 +92141,7 @@ var ts; } } if (options.outDir || + options.rootDir || options.sourceRoot || options.mapRoot) { var dir = getCommonSourceDirectory(); @@ -89341,7 +92606,7 @@ var ts; } function handleDirectoryCouldBeSymlink(directory) { var _a; - if (!host.getResolvedProjectReferences()) + if (!host.getResolvedProjectReferences() || ts.containsIgnoredPath(directory)) return; if (!originalRealpath || !ts.stringContains(directory, ts.nodeModulesPathPart)) return; @@ -89356,7 +92621,7 @@ var ts; symlinkCache.setSymlinkedDirectory(directoryPath, false); return; } - symlinkCache.setSymlinkedDirectory(directoryPath, { + symlinkCache.setSymlinkedDirectory(directory, { real: ts.ensureTrailingDirectorySeparator(real), realPath: realPath }); @@ -89588,12 +92853,15 @@ var ts; } for (var _f = 0, _g = program.getTypeChecker().getAmbientModules(); _f < _g.length; _f++) { var ambientModule = _g[_f]; - if (ambientModule.declarations.length > 1) { + if (ambientModule.declarations && ambientModule.declarations.length > 1) { addReferenceFromAmbientModule(ambientModule); } } return referencedFiles; function addReferenceFromAmbientModule(symbol) { + if (!symbol.declarations) { + return; + } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; var declarationSourceFile = ts.getSourceFileOfNode(declaration); @@ -89611,7 +92879,7 @@ var ts; return oldState && !oldState.referencedMap === !newReferencedMap; } BuilderState.canReuseOldState = canReuseOldState; - function create(newProgram, getCanonicalFileName, oldState) { + function create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) { var fileInfos = new ts.Map(); var referencedMap = newProgram.getCompilerOptions().module !== ts.ModuleKind.None ? new ts.Map() : undefined; var exportedModulesMap = referencedMap ? new ts.Map() : undefined; @@ -89634,13 +92902,14 @@ var ts; } } } - fileInfos.set(sourceFile.resolvedPath, { version: version_2, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) }); + fileInfos.set(sourceFile.resolvedPath, { version: version_2, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) || undefined }); } return { fileInfos: fileInfos, referencedMap: referencedMap, exportedModulesMap: exportedModulesMap, - hasCalledUpdateShapeSignature: hasCalledUpdateShapeSignature + hasCalledUpdateShapeSignature: hasCalledUpdateShapeSignature, + useFileVersionAsSignature: !disableUseFileVersionAsSignature && !useOldState }; } BuilderState.create = create; @@ -89655,6 +92924,7 @@ var ts; referencedMap: state.referencedMap && new ts.Map(state.referencedMap), exportedModulesMap: state.exportedModulesMap && new ts.Map(state.exportedModulesMap), hasCalledUpdateShapeSignature: new ts.Set(state.hasCalledUpdateShapeSignature), + useFileVersionAsSignature: state.useFileVersionAsSignature, }; } BuilderState.clone = clone; @@ -89694,19 +92964,9 @@ var ts; return ts.Debug.fail(); var prevSignature = info.signature; var latestSignature; - if (sourceFile.isDeclarationFile) { - latestSignature = sourceFile.version; - if (exportedModulesMapCache && latestSignature !== prevSignature) { - var references = state.referencedMap ? state.referencedMap.get(sourceFile.resolvedPath) : undefined; - exportedModulesMapCache.set(sourceFile.resolvedPath, references || false); - } - } - else { + if (!sourceFile.isDeclarationFile && !state.useFileVersionAsSignature) { var emitOutput_1 = getFileEmitOutput(programOfThisState, sourceFile, true, cancellationToken, undefined, true); - var firstDts_1 = emitOutput_1.outputFiles && - programOfThisState.getCompilerOptions().declarationMap ? - emitOutput_1.outputFiles.length > 1 ? emitOutput_1.outputFiles[1] : undefined : - emitOutput_1.outputFiles.length > 0 ? emitOutput_1.outputFiles[0] : undefined; + var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles); if (firstDts_1) { ts.Debug.assert(ts.fileExtensionIs(firstDts_1.name, ".d.ts"), "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 = (computeHash || ts.generateDjb2Hash)(firstDts_1.text); @@ -89714,12 +92974,16 @@ var ts; updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache); } } - else { - latestSignature = prevSignature; + } + if (latestSignature === undefined) { + latestSignature = sourceFile.version; + if (exportedModulesMapCache && latestSignature !== prevSignature) { + var references = state.referencedMap ? state.referencedMap.get(sourceFile.resolvedPath) : undefined; + exportedModulesMapCache.set(sourceFile.resolvedPath, references || false); } } cacheToUpdateSignature.set(sourceFile.resolvedPath, latestSignature); - return !prevSignature || latestSignature !== prevSignature; + return latestSignature !== prevSignature; } BuilderState.updateShapeSignature = updateShapeSignature; function updateExportedModules(sourceFile, exportedModulesFromDeclarationEmit, exportedModulesMapCache) { @@ -89807,7 +93071,7 @@ var ts; } function isFileAffectingGlobalScope(sourceFile) { return containsGlobalScopeAugmentation(sourceFile) || - !ts.isExternalModule(sourceFile) && !containsOnlyAmbientModules(sourceFile); + !ts.isExternalOrCommonJsModule(sourceFile) && !containsOnlyAmbientModules(sourceFile); } function getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, firstSourceFile) { if (state.allFilesExcludingDefaultLibraryFile) { @@ -89868,8 +93132,8 @@ var ts; function hasSameKeys(map1, map2) { return map1 === map2 || map1 !== undefined && map2 !== undefined && map1.size === map2.size && !ts.forEachKey(map1, function (key) { return !map2.has(key); }); } - function createBuilderProgramState(newProgram, getCanonicalFileName, oldState) { - var state = ts.BuilderState.create(newProgram, getCanonicalFileName, oldState); + function createBuilderProgramState(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) { + var state = ts.BuilderState.create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature); state.program = newProgram; var compilerOptions = newProgram.getCompilerOptions(); state.compilerOptions = compilerOptions; @@ -90063,6 +93327,7 @@ var ts; return undefined; } function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash) { + var _a; removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath); if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) { if (!state.cleanedDiagnosticsOfLibFiles) { @@ -90075,8 +93340,12 @@ var ts; removeSemanticDiagnosticsOf(state, f.resolvedPath); }); } + ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap); return; } + else { + ts.Debug.assert(state.hasCalledUpdateShapeSignature.has(affectedFile.resolvedPath) || ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.has(affectedFile.resolvedPath)), "Signature not updated for affected file: " + affectedFile.fileName); + } if (!state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) { forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash); }); } @@ -90230,81 +93499,113 @@ var ts; return undefined; var currentDirectory = ts.Debug.checkDefined(state.program).getCurrentDirectory(); var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory)); - var fileInfos = {}; - state.fileInfos.forEach(function (value, key) { + var fileNames = []; + var fileNameToFileId = new ts.Map(); + var fileIdsList; + var fileNamesToFileIdListId; + var fileInfos = ts.arrayFrom(state.fileInfos.entries(), function (_a) { + var key = _a[0], value = _a[1]; + var fileId = toFileId(key); + ts.Debug.assert(fileNames[fileId - 1] === relativeToBuildInfo(key)); var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key); - fileInfos[relativeToBuildInfo(key)] = signature === undefined ? value : { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope }; + var actualSignature = signature !== null && signature !== void 0 ? signature : value.signature; + return value.version === actualSignature ? + value.affectsGlobalScope ? + { version: value.version, signature: undefined, affectsGlobalScope: true } : + value.version : + actualSignature !== undefined ? + signature === undefined ? + value : + { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope } : + { version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope }; }); - var result = { - fileInfos: fileInfos, - options: convertToReusableCompilerOptions(state.compilerOptions, relativeToBuildInfoEnsuringAbsolutePath) - }; + var referencedMap; if (state.referencedMap) { - var referencedMap = {}; - for (var _i = 0, _a = ts.arrayFrom(state.referencedMap.keys()).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) { - var key = _a[_i]; - referencedMap[relativeToBuildInfo(key)] = ts.arrayFrom(state.referencedMap.get(key).keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive); - } - result.referencedMap = referencedMap; + referencedMap = ts.arrayFrom(state.referencedMap.keys()).sort(ts.compareStringsCaseSensitive).map(function (key) { return [ + toFileId(key), + toFileIdListId(state.referencedMap.get(key)) + ]; }); } + var exportedModulesMap; if (state.exportedModulesMap) { - var exportedModulesMap = {}; - for (var _b = 0, _c = ts.arrayFrom(state.exportedModulesMap.keys()).sort(ts.compareStringsCaseSensitive); _b < _c.length; _b++) { - var key = _c[_b]; + exportedModulesMap = ts.mapDefined(ts.arrayFrom(state.exportedModulesMap.keys()).sort(ts.compareStringsCaseSensitive), function (key) { var newValue = state.currentAffectedFilesExportedModulesMap && state.currentAffectedFilesExportedModulesMap.get(key); if (newValue === undefined) - exportedModulesMap[relativeToBuildInfo(key)] = ts.arrayFrom(state.exportedModulesMap.get(key).keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive); + return [toFileId(key), toFileIdListId(state.exportedModulesMap.get(key))]; else if (newValue) - exportedModulesMap[relativeToBuildInfo(key)] = ts.arrayFrom(newValue.keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive); - } - result.exportedModulesMap = exportedModulesMap; + return [toFileId(key), toFileIdListId(newValue)]; + }); } + var semanticDiagnosticsPerFile; if (state.semanticDiagnosticsPerFile) { - var semanticDiagnosticsPerFile = []; - for (var _d = 0, _e = ts.arrayFrom(state.semanticDiagnosticsPerFile.keys()).sort(ts.compareStringsCaseSensitive); _d < _e.length; _d++) { - var key = _e[_d]; + for (var _i = 0, _a = ts.arrayFrom(state.semanticDiagnosticsPerFile.keys()).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) { + var key = _a[_i]; var value = state.semanticDiagnosticsPerFile.get(key); - semanticDiagnosticsPerFile.push(value.length ? + (semanticDiagnosticsPerFile || (semanticDiagnosticsPerFile = [])).push(value.length ? [ - relativeToBuildInfo(key), + toFileId(key), state.hasReusableDiagnostic ? value : convertToReusableDiagnostics(value, relativeToBuildInfo) ] : - relativeToBuildInfo(key)); + toFileId(key)); } - result.semanticDiagnosticsPerFile = semanticDiagnosticsPerFile; } + var affectedFilesPendingEmit; if (state.affectedFilesPendingEmit) { - var affectedFilesPendingEmit = []; var seenFiles = new ts.Set(); - for (var _f = 0, _g = state.affectedFilesPendingEmit.slice(state.affectedFilesPendingEmitIndex).sort(ts.compareStringsCaseSensitive); _f < _g.length; _f++) { - var path = _g[_f]; + for (var _b = 0, _c = state.affectedFilesPendingEmit.slice(state.affectedFilesPendingEmitIndex).sort(ts.compareStringsCaseSensitive); _b < _c.length; _b++) { + var path = _c[_b]; if (ts.tryAddToSet(seenFiles, path)) { - affectedFilesPendingEmit.push([relativeToBuildInfo(path), state.affectedFilesPendingEmitKind.get(path)]); + (affectedFilesPendingEmit || (affectedFilesPendingEmit = [])).push([toFileId(path), state.affectedFilesPendingEmitKind.get(path)]); } } - result.affectedFilesPendingEmit = affectedFilesPendingEmit; } - return result; + return { + fileNames: fileNames, + fileInfos: fileInfos, + options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, relativeToBuildInfoEnsuringAbsolutePath), + fileIdsList: fileIdsList, + referencedMap: referencedMap, + exportedModulesMap: exportedModulesMap, + semanticDiagnosticsPerFile: semanticDiagnosticsPerFile, + affectedFilesPendingEmit: affectedFilesPendingEmit, + }; function relativeToBuildInfoEnsuringAbsolutePath(path) { return relativeToBuildInfo(ts.getNormalizedAbsolutePath(path, currentDirectory)); } function relativeToBuildInfo(path) { return ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(buildInfoDirectory, path, getCanonicalFileName)); } + function toFileId(path) { + var fileId = fileNameToFileId.get(path); + if (fileId === undefined) { + fileNames.push(relativeToBuildInfo(path)); + fileNameToFileId.set(path, fileId = fileNames.length); + } + return fileId; + } + function toFileIdListId(set) { + var fileIds = ts.arrayFrom(set.keys(), toFileId).sort(ts.compareValues); + var key = fileIds.join(); + var fileIdListId = fileNamesToFileIdListId === null || fileNamesToFileIdListId === void 0 ? void 0 : fileNamesToFileIdListId.get(key); + if (fileIdListId === undefined) { + (fileIdsList || (fileIdsList = [])).push(fileIds); + (fileNamesToFileIdListId || (fileNamesToFileIdListId = new ts.Map())).set(key, fileIdListId = fileIdsList.length); + } + return fileIdListId; + } } - function convertToReusableCompilerOptions(options, relativeToBuildInfo) { - var result = {}; + function convertToProgramBuildInfoCompilerOptions(options, relativeToBuildInfo) { + var result; var optionsNameMap = ts.getOptionsNameMap().optionsNameMap; - for (var name in options) { - if (ts.hasProperty(options, name)) { - result[name] = convertToReusableCompilerOptionValue(optionsNameMap.get(name.toLowerCase()), options[name], relativeToBuildInfo); + for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) { + var name = _a[_i]; + var optionInfo = optionsNameMap.get(name.toLowerCase()); + if ((optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsEmit) || (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsSemanticDiagnostics) || name === "skipLibCheck" || name === "skipDefaultLibCheck") { + (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfo); } } - if (result.configFilePath) { - result.configFilePath = relativeToBuildInfo(result.configFilePath); - } return result; } function convertToReusableCompilerOptionValue(option, value, relativeToBuildInfo) { @@ -90389,14 +93690,15 @@ var ts; } var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames()); var computeHash = ts.maybeBind(host, host.createHash); - var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState); + var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState, host.disableUseFileVersionAsSignature); var backupState; newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName); }; newProgram = undefined; oldProgram = undefined; oldState = undefined; - var builderProgram = createRedirectedBuilderProgram(state, configFileParsingDiagnostics); - builderProgram.getState = function () { return state; }; + var getState = function () { return state; }; + var builderProgram = createRedirectedBuilderProgram(getState, configFileParsingDiagnostics); + builderProgram.getState = getState; builderProgram.backupState = function () { ts.Debug.assert(backupState === undefined); backupState = cloneBuilderProgramState(state); @@ -90557,35 +93859,31 @@ var ts; state.affectedFilesPendingEmitIndex = 0; } } - function getMapOfReferencedSet(mapLike, toPath) { - if (!mapLike) - return undefined; - var map = new ts.Map(); - for (var key in mapLike) { - if (ts.hasProperty(mapLike, key)) { - map.set(toPath(key), new ts.Set(mapLike[key].map(toPath))); - } - } - return map; + function toBuilderStateFileInfo(fileInfo) { + return ts.isString(fileInfo) ? + { version: fileInfo, signature: fileInfo, affectsGlobalScope: undefined } : + ts.isString(fileInfo.signature) ? + fileInfo : + { version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope }; } + ts.toBuilderStateFileInfo = toBuilderStateFileInfo; function createBuildProgramUsingProgramBuildInfo(program, buildInfoPath, host) { + var _a; var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory())); var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames()); + var filePaths = program.fileNames.map(toPath); + var filePathsSetList = (_a = program.fileIdsList) === null || _a === void 0 ? void 0 : _a.map(function (fileIds) { return new ts.Set(fileIds.map(toFilePath)); }); var fileInfos = new ts.Map(); - for (var key in program.fileInfos) { - if (ts.hasProperty(program.fileInfos, key)) { - fileInfos.set(toPath(key), program.fileInfos[key]); - } - } + program.fileInfos.forEach(function (fileInfo, index) { return fileInfos.set(toFilePath(index + 1), toBuilderStateFileInfo(fileInfo)); }); var state = { fileInfos: fileInfos, - compilerOptions: ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath), - referencedMap: getMapOfReferencedSet(program.referencedMap, toPath), - exportedModulesMap: getMapOfReferencedSet(program.exportedModulesMap, toPath), - semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, function (value) { return toPath(ts.isString(value) ? value : value[0]); }, function (value) { return ts.isString(value) ? ts.emptyArray : value[1]; }), + compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {}, + referencedMap: toMapOfReferencedSet(program.referencedMap), + exportedModulesMap: toMapOfReferencedSet(program.exportedModulesMap), + semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, function (value) { return toFilePath(ts.isNumber(value) ? value : value[0]); }, function (value) { return ts.isNumber(value) ? ts.emptyArray : value[1]; }), hasReusableDiagnostic: true, - affectedFilesPendingEmit: ts.map(program.affectedFilesPendingEmit, function (value) { return toPath(value[0]); }), - affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toPath(value[0]); }, function (value) { return value[1]; }), + affectedFilesPendingEmit: ts.map(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }), + affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }, function (value) { return value[1]; }), affectedFilesPendingEmitIndex: program.affectedFilesPendingEmit && 0, }; return { @@ -90618,17 +93916,26 @@ var ts; function toAbsolutePath(path) { return ts.getNormalizedAbsolutePath(path, buildInfoDirectory); } + function toFilePath(fileId) { + return filePaths[fileId - 1]; + } + function toFilePathsSet(fileIdsListId) { + return filePathsSetList[fileIdsListId - 1]; + } + function toMapOfReferencedSet(referenceMap) { + return referenceMap && ts.arrayToMap(referenceMap, function (value) { return toFilePath(value[0]); }, function (value) { return toFilePathsSet(value[1]); }); + } } ts.createBuildProgramUsingProgramBuildInfo = createBuildProgramUsingProgramBuildInfo; - function createRedirectedBuilderProgram(state, configFileParsingDiagnostics) { + function createRedirectedBuilderProgram(getState, configFileParsingDiagnostics) { return { getState: ts.notImplemented, backupState: ts.noop, restoreState: ts.noop, getProgram: getProgram, - getProgramOrUndefined: function () { return state.program; }, - releaseProgram: function () { return state.program = undefined; }, - getCompilerOptions: function () { return state.compilerOptions; }, + getProgramOrUndefined: function () { return getState().program; }, + releaseProgram: function () { return getState().program = undefined; }, + getCompilerOptions: function () { return getState().compilerOptions; }, getSourceFile: function (fileName) { return getProgram().getSourceFile(fileName); }, getSourceFiles: function () { return getProgram().getSourceFiles(); }, getOptionsDiagnostics: function (cancellationToken) { return getProgram().getOptionsDiagnostics(cancellationToken); }, @@ -90644,7 +93951,7 @@ var ts; close: ts.noop, }; function getProgram() { - return ts.Debug.checkDefined(state.program); + return ts.Debug.checkDefined(getState().program); } } ts.createRedirectedBuilderProgram = createRedirectedBuilderProgram; @@ -90661,7 +93968,7 @@ var ts; ts.createEmitAndSemanticDiagnosticsBuilderProgram = createEmitAndSemanticDiagnosticsBuilderProgram; function createAbstractBuilder(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences) { var _a = ts.getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences), newProgram = _a.newProgram, newConfigFileParsingDiagnostics = _a.configFileParsingDiagnostics; - return ts.createRedirectedBuilderProgram({ program: newProgram, compilerOptions: newProgram.getCompilerOptions() }, newConfigFileParsingDiagnostics); + return ts.createRedirectedBuilderProgram(function () { return ({ program: newProgram, compilerOptions: newProgram.getCompilerOptions() }); }, newConfigFileParsingDiagnostics); } ts.createAbstractBuilder = createAbstractBuilder; })(ts || (ts = {})); @@ -90717,17 +94024,18 @@ var ts; var resolutionsWithFailedLookups = []; var resolvedFileToResolution = ts.createMultiMap(); var hasChangedAutomaticTypeDirectiveNames = false; - var failedLookupChecks = []; - var startsWithPathChecks = []; - var isInDirectoryChecks = []; + var failedLookupChecks; + var startsWithPathChecks; + var isInDirectoryChecks; var getCurrentDirectory = ts.memoize(function () { return resolutionHost.getCurrentDirectory(); }); var cachedDirectoryStructureHost = resolutionHost.getCachedDirectoryStructureHost(); var resolvedModuleNames = new ts.Map(); var perDirectoryResolvedModuleNames = ts.createCacheWithRedirects(); var nonRelativeModuleNameCache = ts.createCacheWithRedirects(); - var moduleResolutionCache = ts.createModuleResolutionCacheWithMaps(perDirectoryResolvedModuleNames, nonRelativeModuleNameCache, getCurrentDirectory(), resolutionHost.getCanonicalFileName); + var moduleResolutionCache = ts.createModuleResolutionCache(getCurrentDirectory(), resolutionHost.getCanonicalFileName, undefined, perDirectoryResolvedModuleNames, nonRelativeModuleNameCache); var resolvedTypeReferenceDirectives = new ts.Map(); var perDirectoryResolvedTypeReferenceDirectives = ts.createCacheWithRedirects(); + var typeReferenceDirectiveResolutionCache = ts.createTypeReferenceDirectiveResolutionCache(getCurrentDirectory(), resolutionHost.getCanonicalFileName, undefined, moduleResolutionCache.getPackageJsonInfoCache(), perDirectoryResolvedTypeReferenceDirectives); var failedLookupDefaultExtensions = [".ts", ".tsx", ".js", ".jsx", ".json"]; var customFailedLookupPaths = new ts.Map(); var directoryWatchesOfFailedLookups = new ts.Map(); @@ -90750,6 +94058,7 @@ var ts; invalidateResolutionsOfFailedLookupLocations: invalidateResolutionsOfFailedLookupLocations, setFilesWithInvalidatedNonRelativeUnresolvedImports: setFilesWithInvalidatedNonRelativeUnresolvedImports, createHasInvalidatedResolution: createHasInvalidatedResolution, + isFileWithInvalidatedNonRelativeUnresolvedImports: isFileWithInvalidatedNonRelativeUnresolvedImports, updateTypeRootsWatch: updateTypeRootsWatch, closeTypeRootsWatch: closeTypeRootsWatch, clear: clear @@ -90775,9 +94084,9 @@ var ts; resolvedTypeReferenceDirectives.clear(); resolvedFileToResolution.clear(); resolutionsWithFailedLookups.length = 0; - failedLookupChecks.length = 0; - startsWithPathChecks.length = 0; - isInDirectoryChecks.length = 0; + failedLookupChecks = undefined; + startsWithPathChecks = undefined; + isInDirectoryChecks = undefined; clearPerDirectoryResolutions(); hasChangedAutomaticTypeDirectiveNames = false; } @@ -90808,9 +94117,8 @@ var ts; isFileWithInvalidatedNonRelativeUnresolvedImports(path); }; } function clearPerDirectoryResolutions() { - perDirectoryResolvedModuleNames.clear(); - nonRelativeModuleNameCache.clear(); - perDirectoryResolvedTypeReferenceDirectives.clear(); + moduleResolutionCache.clear(); + typeReferenceDirectiveResolutionCache.clear(); nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions); nonRelativeExternalModuleResolutions.clear(); } @@ -90833,7 +94141,7 @@ var ts; } var globalCache = resolutionHost.getGlobalCache(); if (globalCache !== undefined && !ts.isExternalModuleNameRelative(moduleName) && !(primaryResult.resolvedModule && ts.extensionIsTS(primaryResult.resolvedModule.extension))) { - var _b = ts.loadModuleFromGlobalCache(ts.Debug.checkDefined(resolutionHost.globalCacheResolutionModuleName)(moduleName), resolutionHost.projectName, compilerOptions, host, globalCache), resolvedModule = _b.resolvedModule, failedLookupLocations = _b.failedLookupLocations; + var _b = ts.loadModuleFromGlobalCache(ts.Debug.checkDefined(resolutionHost.globalCacheResolutionModuleName)(moduleName), resolutionHost.projectName, compilerOptions, host, globalCache, moduleResolutionCache), resolvedModule = _b.resolvedModule, failedLookupLocations = _b.failedLookupLocations; if (resolvedModule) { primaryResult.resolvedModule = resolvedModule; (_a = primaryResult.failedLookupLocations).push.apply(_a, failedLookupLocations); @@ -90842,8 +94150,11 @@ var ts; } return primaryResult; } + function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference) { + return ts.resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache); + } function resolveNamesWithLocalCache(_a) { - var _b; + var _b, _c, _d; var names = _a.names, containingFile = _a.containingFile, redirectedReference = _a.redirectedReference, cache = _a.cache, perDirectoryCacheWithRedirects = _a.perDirectoryCacheWithRedirects, loader = _a.loader, getResolutionWithResolvedFileName = _a.getResolutionWithResolvedFileName, shouldRetryResolution = _a.shouldRetryResolution, reusedNames = _a.reusedNames, logChanges = _a.logChanges; var path = resolutionHost.toPath(containingFile); var resolutionsInFile = cache.get(path) || cache.set(path, new ts.Map()).get(path); @@ -90873,9 +94184,24 @@ var ts; var resolutionInDirectory = perDirectoryResolution.get(name); if (resolutionInDirectory) { resolution = resolutionInDirectory; + var host = ((_b = resolutionHost.getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(resolutionHost)) || resolutionHost; + if (ts.isTraceEnabled(compilerOptions, host)) { + var resolved = getResolutionWithResolvedFileName(resolution); + ts.trace(host, loader === resolveModuleName ? + (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ? + resolved.packagetId ? + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4 : + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3 : + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_not_resolved : + (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ? + resolved.packagetId ? + ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4 : + ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3 : + ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_not_resolved, name, containingFile, ts.getDirectoryPath(containingFile), resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName, (resolved === null || resolved === void 0 ? void 0 : resolved.packagetId) && ts.packageIdToString(resolved.packagetId)); + } } else { - resolution = loader(name, containingFile, compilerOptions, ((_b = resolutionHost.getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(resolutionHost)) || resolutionHost, redirectedReference); + resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference); perDirectoryResolution.set(name, resolution); } resolutionsInFile.set(name, resolution); @@ -90888,6 +94214,23 @@ var ts; logChanges = false; } } + else { + var host = ((_d = resolutionHost.getCompilerHost) === null || _d === void 0 ? void 0 : _d.call(resolutionHost)) || resolutionHost; + if (ts.isTraceEnabled(compilerOptions, host) && !seenNamesInFile.has(name)) { + var resolved = getResolutionWithResolvedFileName(resolution); + ts.trace(host, loader === resolveModuleName ? + (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ? + resolved.packagetId ? + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 : + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2 : + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_not_resolved : + (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ? + resolved.packagetId ? + ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 : + ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2 : + ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_not_resolved, name, containingFile, resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName, (resolved === null || resolved === void 0 ? void 0 : resolved.packagetId) && ts.packageIdToString(resolved.packagetId)); + } + } ts.Debug.assert(resolution !== undefined && !resolution.isInvalidated); seenNamesInFile.set(name, true); resolvedModules.push(getResolutionWithResolvedFileName(resolution)); @@ -90924,7 +94267,7 @@ var ts; redirectedReference: redirectedReference, cache: resolvedTypeReferenceDirectives, perDirectoryCacheWithRedirects: perDirectoryResolvedTypeReferenceDirectives, - loader: ts.resolveTypeReferenceDirective, + loader: resolveTypeReferenceDirective, getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective, shouldRetryResolution: function (resolution) { return resolution.resolvedTypeReferenceDirective === undefined; }, }); @@ -91180,7 +94523,7 @@ var ts; } function scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, isCreatingWatchedDirectory) { if (isCreatingWatchedDirectory) { - isInDirectoryChecks.push(fileOrDirectoryPath); + (isInDirectoryChecks || (isInDirectoryChecks = [])).push(fileOrDirectoryPath); } else { var updatedPath = removeIgnoredPath(fileOrDirectoryPath); @@ -91193,8 +94536,8 @@ var ts; var dirOfFileOrDirectory = ts.getDirectoryPath(fileOrDirectoryPath); if (isNodeModulesAtTypesDirectory(fileOrDirectoryPath) || ts.isNodeModulesDirectory(fileOrDirectoryPath) || isNodeModulesAtTypesDirectory(dirOfFileOrDirectory) || ts.isNodeModulesDirectory(dirOfFileOrDirectory)) { - failedLookupChecks.push(fileOrDirectoryPath); - startsWithPathChecks.push(fileOrDirectoryPath); + (failedLookupChecks || (failedLookupChecks = [])).push(fileOrDirectoryPath); + (startsWithPathChecks || (startsWithPathChecks = new ts.Set())).add(fileOrDirectoryPath); } else { if (!isPathWithDefaultFailedLookupExtension(fileOrDirectoryPath) && !customFailedLookupPaths.has(fileOrDirectoryPath)) { @@ -91203,27 +94546,30 @@ var ts; if (ts.isEmittedFileOfProgram(resolutionHost.getCurrentProgram(), fileOrDirectoryPath)) { return false; } - failedLookupChecks.push(fileOrDirectoryPath); + (failedLookupChecks || (failedLookupChecks = [])).push(fileOrDirectoryPath); + var packagePath = ts.parseNodeModuleFromPath(fileOrDirectoryPath); + if (packagePath) + (startsWithPathChecks || (startsWithPathChecks = new ts.Set())).add(packagePath); } } resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations(); } function invalidateResolutionsOfFailedLookupLocations() { - if (!failedLookupChecks.length && !startsWithPathChecks.length && !isInDirectoryChecks.length) { + if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks) { return false; } var invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution); - failedLookupChecks.length = 0; - startsWithPathChecks.length = 0; - isInDirectoryChecks.length = 0; + failedLookupChecks = undefined; + startsWithPathChecks = undefined; + isInDirectoryChecks = undefined; return invalidated; } function canInvalidateFailedLookupResolution(resolution) { return resolution.failedLookupLocations.some(function (location) { var locationPath = resolutionHost.toPath(location); return ts.contains(failedLookupChecks, locationPath) || - startsWithPathChecks.some(function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath); }) || - isInDirectoryChecks.some(function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath); }); + ts.firstDefinedIterator((startsWithPathChecks === null || startsWithPathChecks === void 0 ? void 0 : startsWithPathChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath) ? true : undefined; }) || + (isInDirectoryChecks === null || isInDirectoryChecks === void 0 ? void 0 : isInDirectoryChecks.some(function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath); })); }); } function closeTypeRootsWatch() { @@ -91336,6 +94682,9 @@ var ts; return [ambient]; var info = getInfo(importingSourceFile.path, host); var moduleSourceFile = ts.getSourceFileOfNode(moduleSymbol.valueDeclaration || ts.getNonAugmentationDeclaration(moduleSymbol)); + if (!moduleSourceFile) { + return []; + } var modulePaths = getAllModulePaths(importingSourceFile.path, moduleSourceFile.originalFileName, host); var preferences = getPreferences(userPreferences, compilerOptions, importingSourceFile); var existingSpecifier = ts.forEach(modulePaths, function (modulePath) { return ts.forEach(host.getFileIncludeReasons().get(ts.toPath(modulePath.path, host.getCurrentDirectory(), info.getCanonicalFileName)), function (reason) { @@ -91388,7 +94737,7 @@ var ts; if (!baseUrl && !paths || relativePreference === 0) { return relativePath; } - var baseDirectory = ts.getPathsBasePath(compilerOptions, host) || baseUrl; + var baseDirectory = ts.getNormalizedAbsolutePath(ts.getPathsBasePath(compilerOptions, host) || baseUrl, host.getCurrentDirectory()); var relativeToBaseUrl = getRelativePathIfInDirectory(moduleFileName, baseDirectory, getCanonicalFileName); if (!relativeToBaseUrl) { return relativePath; @@ -91403,7 +94752,9 @@ var ts; return nonRelative; } if (relativePreference === 3) { - var projectDirectory = host.getCurrentDirectory(); + var projectDirectory = compilerOptions.configFilePath ? + ts.toPath(ts.getDirectoryPath(compilerOptions.configFilePath), host.getCurrentDirectory(), info.getCanonicalFileName) : + info.getCanonicalFileName(host.getCurrentDirectory()); var modulePath = ts.toPath(moduleFileName, projectDirectory, getCanonicalFileName); var sourceIsInternal = ts.startsWith(sourceDirectory, projectDirectory); var targetIsInternal = ts.startsWith(modulePath, projectDirectory); @@ -91437,12 +94788,8 @@ var ts; return ts.pathIsRelative(text) ? ts.hasJSFileExtension(text) : undefined; }) || false; } - function numberOfDirectorySeparators(str) { - var match = str.match(/\//g); - return match ? match.length : 0; - } function comparePathsByRedirectAndNumberOfDirectorySeparators(a, b) { - return ts.compareBooleans(b.isRedirect, a.isRedirect) || ts.compareValues(numberOfDirectorySeparators(a.path), numberOfDirectorySeparators(b.path)); + return ts.compareBooleans(b.isRedirect, a.isRedirect) || ts.compareNumberOfDirectorySeparators(a.path, b.path); } function getNearestAncestorDirectoryWithPackageJson(host, fileName) { if (host.getNearestAncestorDirectoryWithPackageJson) { @@ -91456,45 +94803,57 @@ var ts; var getCanonicalFileName = ts.hostGetCanonicalFileName(host); var cwd = host.getCurrentDirectory(); var referenceRedirect = host.isSourceOfProjectReferenceRedirect(importedFileName) ? host.getProjectReferenceRedirect(importedFileName) : undefined; - var redirects = host.redirectTargetsMap.get(ts.toPath(importedFileName, cwd, getCanonicalFileName)) || ts.emptyArray; + var importedPath = ts.toPath(importedFileName, cwd, getCanonicalFileName); + var redirects = host.redirectTargetsMap.get(importedPath) || ts.emptyArray; var importedFileNames = __spreadArray(__spreadArray(__spreadArray([], (referenceRedirect ? [referenceRedirect] : ts.emptyArray)), [importedFileName]), redirects); var targets = importedFileNames.map(function (f) { return ts.getNormalizedAbsolutePath(f, cwd); }); + var shouldFilterIgnoredPaths = !ts.every(targets, ts.containsIgnoredPath); if (!preferSymlinks) { - var result_15 = ts.forEach(targets, function (p) { return cb(p, referenceRedirect === p); }); + var result_15 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); }); if (result_15) return result_15; } var links = host.getSymlinkCache ? host.getSymlinkCache() : ts.discoverProbableSymlinks(host.getSourceFiles(), getCanonicalFileName, cwd); - var symlinkedDirectories = links.getSymlinkedDirectories(); - var useCaseSensitiveFileNames = !host.useCaseSensitiveFileNames || host.useCaseSensitiveFileNames(); - var result = symlinkedDirectories && ts.forEachEntry(symlinkedDirectories, function (resolved, path) { - if (resolved === false) - return undefined; - if (ts.startsWithDirectory(importingFileName, resolved.realPath, getCanonicalFileName)) { + var symlinkedDirectories = links.getSymlinkedDirectoriesByRealpath(); + var fullImportedFileName = ts.getNormalizedAbsolutePath(importedFileName, cwd); + var result = symlinkedDirectories && ts.forEachAncestorDirectory(ts.getDirectoryPath(fullImportedFileName), function (realPathDirectory) { + var symlinkDirectories = symlinkedDirectories.get(ts.ensureTrailingDirectorySeparator(ts.toPath(realPathDirectory, cwd, getCanonicalFileName))); + if (!symlinkDirectories) return undefined; + if (ts.startsWithDirectory(importingFileName, realPathDirectory, getCanonicalFileName)) { + return false; } return ts.forEach(targets, function (target) { - if (!ts.containsPath(resolved.real, target, !useCaseSensitiveFileNames)) { + if (!ts.startsWithDirectory(target, realPathDirectory, getCanonicalFileName)) { return; } - var relative = ts.getRelativePathFromDirectory(resolved.real, target, getCanonicalFileName); - var option = ts.resolvePath(path, relative); - if (!host.fileExists || host.fileExists(option)) { + var relative = ts.getRelativePathFromDirectory(realPathDirectory, target, getCanonicalFileName); + for (var _i = 0, symlinkDirectories_1 = symlinkDirectories; _i < symlinkDirectories_1.length; _i++) { + var symlinkDirectory = symlinkDirectories_1[_i]; + var option = ts.resolvePath(symlinkDirectory, relative); var result_16 = cb(option, target === referenceRedirect); + shouldFilterIgnoredPaths = true; if (result_16) return result_16; } }); }); - return result || - (preferSymlinks ? ts.forEach(targets, function (p) { return cb(p, p === referenceRedirect); }) : undefined); + return result || (preferSymlinks + ? ts.forEach(targets, function (p) { return shouldFilterIgnoredPaths && ts.containsIgnoredPath(p) ? undefined : cb(p, p === referenceRedirect); }) + : undefined); } moduleSpecifiers.forEachFileNameOfModule = forEachFileNameOfModule; function getAllModulePaths(importingFileName, importedFileName, host) { - var cwd = host.getCurrentDirectory(); + var _a; + var cache = (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host); var getCanonicalFileName = ts.hostGetCanonicalFileName(host); + if (cache) { + var cached = cache.get(importingFileName, ts.toPath(importedFileName, host.getCurrentDirectory(), getCanonicalFileName)); + if (typeof cached === "object") + return cached; + } var allFileNames = new ts.Map(); var importedFileFromNodeModules = false; forEachFileNameOfModule(importingFileName, importedFileName, host, true, function (path, isRedirect) { @@ -91503,7 +94862,7 @@ var ts; importedFileFromNodeModules = importedFileFromNodeModules || isInNodeModules; }); var sortedPaths = []; - var _loop_24 = function (directory) { + var _loop_26 = function (directory) { var directoryStart = ts.ensureTrailingDirectorySeparator(directory); var pathsInDirectory; allFileNames.forEach(function (_a, fileName) { @@ -91526,10 +94885,10 @@ var ts; out_directory_1 = directory; }; var out_directory_1; - for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0;) { - var state_7 = _loop_24(directory); + for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) { + var state_9 = _loop_26(directory); directory = out_directory_1; - if (state_7 === "break") + if (state_9 === "break") break; } if (allFileNames.size) { @@ -91538,10 +94897,14 @@ var ts; remainingPaths.sort(comparePathsByRedirectAndNumberOfDirectorySeparators); sortedPaths.push.apply(sortedPaths, remainingPaths); } + if (cache) { + cache.set(importingFileName, ts.toPath(importedFileName, host.getCurrentDirectory(), getCanonicalFileName), sortedPaths); + } return sortedPaths; } function tryGetModuleNameFromAmbientModule(moduleSymbol, checker) { - var decl = ts.find(moduleSymbol.declarations, function (d) { return ts.isNonGlobalAmbientModule(d) && (!ts.isExternalModuleAugmentation(d) || !ts.isExternalModuleNameRelative(ts.getTextOfIdentifierOrLiteral(d.name))); }); + var _a; + var decl = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.isNonGlobalAmbientModule(d) && (!ts.isExternalModuleAugmentation(d) || !ts.isExternalModuleNameRelative(ts.getTextOfIdentifierOrLiteral(d.name))); }); if (decl) { return decl.name.text; } @@ -91587,7 +94950,7 @@ var ts; ts.startsWith(relativeToBaseUrl, prefix) && ts.endsWith(relativeToBaseUrl, suffix) || !suffix && relativeToBaseUrl === ts.removeTrailingDirectorySeparator(prefix)) { - var matchedStar = relativeToBaseUrl.substr(prefix.length, relativeToBaseUrl.length - suffix.length); + var matchedStar = relativeToBaseUrl.substr(prefix.length, relativeToBaseUrl.length - suffix.length - prefix.length); return key.replace("*", matchedStar); } } @@ -91855,10 +95218,10 @@ var ts; }; } ts.createWatchStatusReporter = createWatchStatusReporter; - function parseConfigFileWithSystem(configFileName, optionsToExtend, watchOptionsToExtend, system, reportDiagnostic) { + function parseConfigFileWithSystem(configFileName, optionsToExtend, extendedConfigCache, watchOptionsToExtend, system, reportDiagnostic) { var host = system; host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(system, reportDiagnostic, diagnostic); }; - var result = ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtend, host, undefined, watchOptionsToExtend); + var result = ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtend, host, extendedConfigCache, watchOptionsToExtend); host.onUnRecoverableConfigFileDiagnostic = undefined; return result; } @@ -92108,7 +95471,10 @@ var ts; MissingFile: "Missing file", WildcardDirectory: "Wild card directory", FailedLookupLocations: "Failed Lookup Locations", - TypeRoots: "Type roots" + TypeRoots: "Type roots", + ConfigFileOfReferencedProject: "Config file of referened project", + ExtendedConfigOfReferencedProject: "Extended config file of referenced project", + WildcardDirectoryOfReferencedProject: "Wild card directory of referenced project", }; function createWatchFactory(host, options) { var watchLogLevel = host.trace ? options.extendedDiagnostics ? ts.WatchLogLevel.Verbose : options.diagnostics ? ts.WatchLogLevel.TriggerOnly : ts.WatchLogLevel.None : ts.WatchLogLevel.None; @@ -92155,6 +95521,7 @@ var ts; getEnvironmentVariable: ts.maybeBind(host, host.getEnvironmentVariable) || (function () { return ""; }), createHash: ts.maybeBind(host, host.createHash), readDirectory: ts.maybeBind(host, host.readDirectory), + disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature, }; function writeFile(fileName, text, writeByteOrderMark, onError) { try { @@ -92206,7 +95573,8 @@ var ts; createDirectory: function (path) { return system.createDirectory(path); }, writeFile: function (path, data, writeByteOrderMark) { return system.writeFile(path, data, writeByteOrderMark); }, createHash: ts.maybeBind(system, system.createHash), - createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram + createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram, + disableUseFileVersionAsSignature: system.disableUseFileVersionAsSignature, }; } ts.createProgramHost = createProgramHost; @@ -92282,6 +95650,7 @@ var ts; if (system === void 0) { system = ts.sys; } var host = ts.createCompilerHostWorker(options, undefined, system); host.createHash = ts.maybeBind(system, system.createHash); + host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature; ts.setGetSourceFileAsHashVersioned(host, system); ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); }); return host; @@ -92325,11 +95694,13 @@ var ts; function createWatchProgram(host) { var builderProgram; var reloadLevel; - var extendedConfigFilesMap; var missingFilesMap; var watchedWildcardDirectories; var timerToUpdateProgram; var timerToInvalidateFailedLookupResolutions; + var parsedConfigs; + var sharedExtendedConfigFileWatchers; + var extendedConfigCache = host.extendedConfigCache; var sourceFilesCache = new ts.Map(); var missingFilePathsRequestedForRelease; var hasChangedCompilerOptions = false; @@ -92377,6 +95748,7 @@ var ts; compilerHost.getNewLine = function () { return newLine; }; compilerHost.fileExists = fileExists; compilerHost.onReleaseOldSourceFile = onReleaseOldSourceFile; + compilerHost.onReleaseParsedCommandLine = onReleaseParsedCommandLine; compilerHost.toPath = toPath; compilerHost.getCompilationSettings = function () { return compilerOptions; }; compilerHost.useSourceOfProjectReferenceRedirect = ts.maybeBind(host, host.useSourceOfProjectReferenceRedirect); @@ -92389,6 +95761,7 @@ var ts; compilerHost.fileIsOpen = ts.returnFalse; compilerHost.getCurrentProgram = getCurrentProgram; compilerHost.writeLog = writeLog; + compilerHost.getParsedCommandLine = getParsedCommandLine; var resolutionCache = ts.createResolutionCache(compilerHost, configFileName ? ts.getDirectoryPath(ts.getNormalizedAbsolutePath(configFileName, currentDirectory)) : currentDirectory, false); @@ -92414,7 +95787,8 @@ var ts; builderProgram = readBuilderProgram(compilerOptions, compilerHost); synchronizeProgram(); watchConfigFileWildCardDirectories(); - watchExtendedConfigFiles(); + if (configFileName) + updateExtendedConfigFilesWatches(toPath(configFileName), compilerOptions, watchOptions, ts.WatchType.ExtendedConfigFile); return configFileName ? { getCurrentProgram: getCurrentBuilderProgram, getProgram: updateProgram, close: close } : { getCurrentProgram: getCurrentBuilderProgram, getProgram: updateProgram, updateRootFileNames: updateRootFileNames, close: close }; @@ -92431,9 +95805,11 @@ var ts; configFileWatcher.close(); configFileWatcher = undefined; } - if (extendedConfigFilesMap) { - ts.clearMap(extendedConfigFilesMap, ts.closeFileWatcher); - extendedConfigFilesMap = undefined; + extendedConfigCache === null || extendedConfigCache === void 0 ? void 0 : extendedConfigCache.clear(); + extendedConfigCache = undefined; + if (sharedExtendedConfigFileWatchers) { + ts.clearMap(sharedExtendedConfigFileWatchers, ts.closeFileWatcherOf); + sharedExtendedConfigFileWatchers = undefined; } if (watchedWildcardDirectories) { ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcherOf); @@ -92443,6 +95819,17 @@ var ts; ts.clearMap(missingFilesMap, ts.closeFileWatcher); missingFilesMap = undefined; } + if (parsedConfigs) { + ts.clearMap(parsedConfigs, function (config) { + var _a; + (_a = config.watcher) === null || _a === void 0 ? void 0 : _a.close(); + config.watcher = undefined; + if (config.watchedDirectories) + ts.clearMap(config.watchedDirectories, ts.closeFileWatcherOf); + config.watchedDirectories = undefined; + }); + parsedConfigs = undefined; + } } function getCurrentBuilderProgram() { return builderProgram; @@ -92461,7 +95848,7 @@ var ts; } } var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution); - if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, projectReferences)) { + if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) { if (hasChangedConfigFileParsingErrors) { builderProgram = createProgram(undefined, undefined, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences); hasChangedConfigFileParsingErrors = false; @@ -92479,6 +95866,8 @@ var ts; writeLog("CreatingProgramWith::"); writeLog(" roots: " + JSON.stringify(rootFileNames)); writeLog(" options: " + JSON.stringify(compilerOptions)); + if (projectReferences) + writeLog(" projectReferences: " + JSON.stringify(projectReferences)); var needsUpdateInTypeRootWatch = hasChangedCompilerOptions || !getCurrentProgram(); hasChangedCompilerOptions = false; hasChangedConfigFileParsingErrors = false; @@ -92677,10 +96066,10 @@ var ts; hasChangedCompilerOptions = true; synchronizeProgram(); watchConfigFileWildCardDirectories(); - watchExtendedConfigFiles(); + updateExtendedConfigFilesWatches(toPath(configFileName), compilerOptions, watchOptions, ts.WatchType.ExtendedConfigFile); } function parseConfigFile() { - setConfigFileParsingResult(ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtendForConfigFile, parseConfigFileHost, undefined, watchOptionsToExtend, extraFileExtensions)); + setConfigFileParsingResult(ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtendForConfigFile, parseConfigFileHost, extendedConfigCache || (extendedConfigCache = new ts.Map()), watchOptionsToExtend, extraFileExtensions)); } function setConfigFileParsingResult(configFileParseResult) { rootFileNames = configFileParseResult.fileNames; @@ -92692,6 +96081,53 @@ var ts; canConfigFileJsonReportNoInputFiles = ts.canJsonReportNoInputFiles(configFileParseResult.raw); hasChangedConfigFileParsingErrors = true; } + function getParsedCommandLine(configFileName) { + var configPath = toPath(configFileName); + var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(configPath); + if (config) { + if (!config.reloadLevel) + return config.parsedCommandLine; + if (config.parsedCommandLine && config.reloadLevel === ts.ConfigFileProgramReloadLevel.Partial && !host.getParsedCommandLine) { + writeLog("Reloading new file names and options"); + var fileNames = ts.getFileNamesFromConfigSpecs(config.parsedCommandLine.options.configFile.configFileSpecs, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), compilerOptions, parseConfigFileHost); + config.parsedCommandLine = __assign(__assign({}, config.parsedCommandLine), { fileNames: fileNames }); + config.reloadLevel = undefined; + return config.parsedCommandLine; + } + } + writeLog("Loading config file: " + configFileName); + var parsedCommandLine = host.getParsedCommandLine ? + host.getParsedCommandLine(configFileName) : + getParsedCommandLineFromConfigFileHost(configFileName); + if (config) { + config.parsedCommandLine = parsedCommandLine; + config.reloadLevel = undefined; + } + else { + (parsedConfigs || (parsedConfigs = new ts.Map())).set(configPath, config = { parsedCommandLine: parsedCommandLine }); + } + watchReferencedProject(configFileName, configPath, config); + return parsedCommandLine; + } + function getParsedCommandLineFromConfigFileHost(configFileName) { + var onUnRecoverableConfigFileDiagnostic = parseConfigFileHost.onUnRecoverableConfigFileDiagnostic; + parseConfigFileHost.onUnRecoverableConfigFileDiagnostic = ts.noop; + var parsedCommandLine = ts.getParsedCommandLineOfConfigFile(configFileName, undefined, parseConfigFileHost, extendedConfigCache || (extendedConfigCache = new ts.Map()), watchOptionsToExtend); + parseConfigFileHost.onUnRecoverableConfigFileDiagnostic = onUnRecoverableConfigFileDiagnostic; + return parsedCommandLine; + } + function onReleaseParsedCommandLine(fileName) { + var _a; + var path = toPath(fileName); + var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(path); + if (!config) + return; + parsedConfigs.delete(path); + if (config.watchedDirectories) + ts.clearMap(config.watchedDirectories, ts.closeFileWatcherOf); + (_a = config.watcher) === null || _a === void 0 ? void 0 : _a.close(); + ts.clearSharedExtendedConfigFileWatcher(path, sharedExtendedConfigFileWatchers); + } function watchFilePath(path, file, callback, pollingInterval, options, watchType) { return watchFile(file, function (fileName, eventKind) { return callback(fileName, eventKind, path); }, pollingInterval, options, watchType); } @@ -92700,7 +96136,6 @@ var ts; if (eventKind === ts.FileWatcherEventKind.Deleted && sourceFilesCache.has(path)) { resolutionCache.invalidateResolutionOfFile(path); } - resolutionCache.removeResolutionsFromProjectReferenceRedirects(path); nextSourceFileVersion(path); scheduleProgramUpdate(); } @@ -92710,7 +96145,9 @@ var ts; } } function watchMissingFilePath(missingFilePath) { - return watchFilePath(missingFilePath, missingFilePath, onMissingFileChange, ts.PollingInterval.Medium, watchOptions, ts.WatchType.MissingFile); + return (parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.has(missingFilePath)) ? + ts.noopFileWatcher : + watchFilePath(missingFilePath, missingFilePath, onMissingFileChange, ts.PollingInterval.Medium, watchOptions, ts.WatchType.MissingFile); } function onMissingFileChange(fileName, eventKind, missingFilePath) { updateCachedSystemWithFile(fileName, missingFilePath, eventKind); @@ -92744,10 +96181,11 @@ var ts; configFileName: configFileName, extraFileExtensions: extraFileExtensions, options: compilerOptions, - program: getCurrentBuilderProgram(), + program: getCurrentBuilderProgram() || rootFileNames, currentDirectory: currentDirectory, useCaseSensitiveFileNames: useCaseSensitiveFileNames, - writeLog: writeLog + writeLog: writeLog, + toPath: toPath, })) return; if (reloadLevel !== ts.ConfigFileProgramReloadLevel.Full) { @@ -92756,15 +96194,76 @@ var ts; } }, flags, watchOptions, ts.WatchType.WildcardDirectory); } - function watchExtendedConfigFiles() { - var _a; - ts.mutateMap(extendedConfigFilesMap || (extendedConfigFilesMap = new ts.Map()), ts.arrayToMap(((_a = compilerOptions.configFile) === null || _a === void 0 ? void 0 : _a.extendedSourceFiles) || ts.emptyArray, toPath), { - createNewValue: watchExtendedConfigFile, - onDeleteValue: ts.closeFileWatcher - }); - } - function watchExtendedConfigFile(extendedConfigFile) { - return watchFile(extendedConfigFile, scheduleProgramReload, ts.PollingInterval.High, watchOptions, ts.WatchType.ExtendedConfigFile); + function updateExtendedConfigFilesWatches(forProjectPath, options, watchOptions, watchType) { + ts.updateSharedExtendedConfigFileWatcher(forProjectPath, options, sharedExtendedConfigFileWatchers || (sharedExtendedConfigFileWatchers = new ts.Map()), function (extendedConfigFileName, extendedConfigFilePath) { return watchFile(extendedConfigFileName, function (_fileName, eventKind) { + var _a; + updateCachedSystemWithFile(extendedConfigFileName, extendedConfigFilePath, eventKind); + if (extendedConfigCache) + ts.cleanExtendedConfigCache(extendedConfigCache, extendedConfigFilePath, toPath); + var projects = (_a = sharedExtendedConfigFileWatchers.get(extendedConfigFilePath)) === null || _a === void 0 ? void 0 : _a.projects; + if (!(projects === null || projects === void 0 ? void 0 : projects.size)) + return; + projects.forEach(function (projectPath) { + if (toPath(configFileName) === projectPath) { + reloadLevel = ts.ConfigFileProgramReloadLevel.Full; + } + else { + var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(projectPath); + if (config) + config.reloadLevel = ts.ConfigFileProgramReloadLevel.Full; + resolutionCache.removeResolutionsFromProjectReferenceRedirects(projectPath); + } + scheduleProgramUpdate(); + }); + }, ts.PollingInterval.High, watchOptions, watchType); }, toPath); + } + function watchReferencedProject(configFileName, configPath, commandLine) { + var _a, _b, _c, _d, _e; + commandLine.watcher || (commandLine.watcher = watchFile(configFileName, function (_fileName, eventKind) { + updateCachedSystemWithFile(configFileName, configPath, eventKind); + var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(configPath); + if (config) + config.reloadLevel = ts.ConfigFileProgramReloadLevel.Full; + resolutionCache.removeResolutionsFromProjectReferenceRedirects(configPath); + scheduleProgramUpdate(); + }, ts.PollingInterval.High, ((_a = commandLine.parsedCommandLine) === null || _a === void 0 ? void 0 : _a.watchOptions) || watchOptions, ts.WatchType.ConfigFileOfReferencedProject)); + if ((_b = commandLine.parsedCommandLine) === null || _b === void 0 ? void 0 : _b.wildcardDirectories) { + ts.updateWatchingWildcardDirectories(commandLine.watchedDirectories || (commandLine.watchedDirectories = new ts.Map()), new ts.Map(ts.getEntries((_c = commandLine.parsedCommandLine) === null || _c === void 0 ? void 0 : _c.wildcardDirectories)), function (directory, flags) { + var _a; + return watchDirectory(directory, function (fileOrDirectory) { + var fileOrDirectoryPath = toPath(fileOrDirectory); + if (cachedDirectoryStructureHost) { + cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); + } + nextSourceFileVersion(fileOrDirectoryPath); + var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(configPath); + if (!(config === null || config === void 0 ? void 0 : config.parsedCommandLine)) + return; + if (ts.isIgnoredFileFromWildCardWatching({ + watchedDirPath: toPath(directory), + fileOrDirectory: fileOrDirectory, + fileOrDirectoryPath: fileOrDirectoryPath, + configFileName: configFileName, + options: config.parsedCommandLine.options, + program: config.parsedCommandLine.fileNames, + currentDirectory: currentDirectory, + useCaseSensitiveFileNames: useCaseSensitiveFileNames, + writeLog: writeLog, + toPath: toPath, + })) + return; + if (config.reloadLevel !== ts.ConfigFileProgramReloadLevel.Full) { + config.reloadLevel = ts.ConfigFileProgramReloadLevel.Partial; + scheduleProgramUpdate(); + } + }, flags, ((_a = commandLine.parsedCommandLine) === null || _a === void 0 ? void 0 : _a.watchOptions) || watchOptions, ts.WatchType.WildcardDirectoryOfReferencedProject); + }); + } + else if (commandLine.watchedDirectories) { + ts.clearMap(commandLine.watchedDirectories, ts.closeFileWatcherOf); + commandLine.watchedDirectories = undefined; + } + updateExtendedConfigFilesWatches(configPath, (_d = commandLine.parsedCommandLine) === null || _d === void 0 ? void 0 : _d.options, ((_e = commandLine.parsedCommandLine) === null || _e === void 0 ? void 0 : _e.watchOptions) || watchOptions, ts.WatchType.ExtendedConfigOfReferencedProject); } } ts.createWatchProgram = createWatchProgram; @@ -92897,12 +96396,19 @@ var ts; compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames); compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives); 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) { var loader_3 = function (moduleName, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference).resolvedModule; }; compilerHost.resolveModuleNames = function (moduleNames, containingFile, _reusedNames, redirectedReference) { return ts.loadWithLocalCache(ts.Debug.checkEachDefined(moduleNames), containingFile, redirectedReference, loader_3); }; } + if (!compilerHost.resolveTypeReferenceDirectives) { + var loader_4 = function (moduleName, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache).resolvedTypeReferenceDirective; }; + compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { + return ts.loadWithLocalCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, loader_4); + }; + } var _a = ts.createWatchFactory(hostWithWatch, options), watchFile = _a.watchFile, watchDirectory = _a.watchDirectory, writeLog = _a.writeLog; var state = { host: host, @@ -92926,6 +96432,7 @@ var ts; projectErrorsReported: new ts.Map(), compilerHost: compilerHost, moduleResolutionCache: moduleResolutionCache, + typeReferenceDirectiveResolutionCache: typeReferenceDirectiveResolutionCache, buildOrder: undefined, readFileWithCache: function (f) { return host.readFile(f); }, projectCompilerOptions: baseCompilerOptions, @@ -92962,6 +96469,10 @@ var ts; function isParsedCommandLine(entry) { return !!entry.options; } + function getCachedParsedConfigFile(state, configFilePath) { + var value = state.configFileCache.get(configFilePath); + return value && isParsedCommandLine(value) ? value : undefined; + } function parseConfigFile(state, configFileName, configFilePath) { var configFileCache = state.configFileCache; var value = configFileCache.get(configFilePath); @@ -93101,7 +96612,7 @@ var ts; function disableCache(state) { if (!state.cache) return; - var cache = state.cache, host = state.host, compilerHost = state.compilerHost, extendedConfigCache = state.extendedConfigCache, moduleResolutionCache = state.moduleResolutionCache; + var cache = state.cache, host = state.host, compilerHost = state.compilerHost, extendedConfigCache = state.extendedConfigCache, moduleResolutionCache = state.moduleResolutionCache, typeReferenceDirectiveResolutionCache = state.typeReferenceDirectiveResolutionCache; host.readFile = cache.originalReadFile; host.fileExists = cache.originalFileExists; host.directoryExists = cache.originalDirectoryExists; @@ -93110,10 +96621,8 @@ var ts; compilerHost.getSourceFile = cache.originalGetSourceFile; state.readFileWithCache = cache.originalReadFileWithCache; extendedConfigCache.clear(); - if (moduleResolutionCache) { - moduleResolutionCache.directoryToModuleNameMap.clear(); - moduleResolutionCache.moduleNameToDirectoryMap.clear(); - } + moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.clear(); + typeReferenceDirectiveResolutionCache === null || typeReferenceDirectiveResolutionCache === void 0 ? void 0 : typeReferenceDirectiveResolutionCache.clear(); state.cache = undefined; } function clearProjectStatus(state, resolved) { @@ -93279,6 +96788,7 @@ var ts; return withProgramOrUndefined(action) || ts.emptyArray; } function createProgram() { + var _a, _b; ts.Debug.assert(program === undefined); if (state.options.dry) { reportStatus(state, ts.Diagnostics.A_non_dry_build_would_build_project_0, project); @@ -93296,7 +96806,8 @@ var ts; } var host = state.host, compilerHost = state.compilerHost; state.projectCompilerOptions = config.options; - updateModuleResolutionCache(state, project, config); + (_a = state.moduleResolutionCache) === null || _a === void 0 ? void 0 : _a.update(config.options); + (_b = state.typeReferenceDirectiveResolutionCache) === null || _b === void 0 ? void 0 : _b.update(config.options); program = host.createProgram(config.fileNames, config.options, compilerHost, getOldProgram(state, projectPath, config), ts.getConfigFileParsingDiagnostics(config), config.projectReferences); if (state.watch) { state.builderPrograms.set(projectPath, program); @@ -93458,7 +96969,7 @@ var ts; emitBundle(writeFile, customTransformers); break; case BuildStep.BuildInvalidatedProjectOfBundle: - ts.Debug.checkDefined(invalidatedProjectOfBundle).done(cancellationToken); + ts.Debug.checkDefined(invalidatedProjectOfBundle).done(cancellationToken, writeFile, customTransformers); step = BuildStep.Done; break; case BuildStep.QueueReferencingProjects: @@ -93594,30 +97105,8 @@ var ts; afterProgramDone(state, program, config); return { buildResult: buildResult, step: BuildStep.QueueReferencingProjects }; } - function updateModuleResolutionCache(state, proj, config) { - if (!state.moduleResolutionCache) - return; - var moduleResolutionCache = state.moduleResolutionCache; - var projPath = toPath(state, proj); - if (moduleResolutionCache.directoryToModuleNameMap.redirectsMap.size === 0) { - ts.Debug.assert(moduleResolutionCache.moduleNameToDirectoryMap.redirectsMap.size === 0); - moduleResolutionCache.directoryToModuleNameMap.redirectsMap.set(projPath, moduleResolutionCache.directoryToModuleNameMap.ownMap); - moduleResolutionCache.moduleNameToDirectoryMap.redirectsMap.set(projPath, moduleResolutionCache.moduleNameToDirectoryMap.ownMap); - } - else { - ts.Debug.assert(moduleResolutionCache.moduleNameToDirectoryMap.redirectsMap.size > 0); - var ref = { - sourceFile: config.options.configFile, - commandLine: config - }; - moduleResolutionCache.directoryToModuleNameMap.setOwnMap(moduleResolutionCache.directoryToModuleNameMap.getOrCreateMapOfCacheRedirects(ref)); - moduleResolutionCache.moduleNameToDirectoryMap.setOwnMap(moduleResolutionCache.moduleNameToDirectoryMap.getOrCreateMapOfCacheRedirects(ref)); - } - moduleResolutionCache.directoryToModuleNameMap.setOwnOptions(config.options); - moduleResolutionCache.moduleNameToDirectoryMap.setOwnOptions(config.options); - } function checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName) { - var tsconfigTime = state.host.getModifiedTime(configFile) || ts.missingFileModifiedTime; + var tsconfigTime = ts.getModifiedTime(state.host, configFile); if (oldestOutputFileTime < tsconfigTime) { return { type: ts.UpToDateStatusType.OutOfDateWithSelf, @@ -93627,6 +97116,7 @@ var ts; } } function getUpToDateStatusWorker(state, project, resolvedPath) { + var force = !!state.options.force; var newestInputFileName = undefined; var newestInputFileTime = minimumDate; var host = state.host; @@ -93638,10 +97128,13 @@ var ts; reason: inputFile + " does not exist" }; } - var inputTime = host.getModifiedTime(inputFile) || ts.missingFileModifiedTime; - if (inputTime > newestInputFileTime) { - newestInputFileName = inputFile; - newestInputFileTime = inputTime; + if (!force) { + var inputTime = ts.getModifiedTime(host, inputFile); + host.getModifiedTime(inputFile); + if (inputTime > newestInputFileTime) { + newestInputFileName = inputFile; + newestInputFileTime = inputTime; + } } } if (!project.fileNames.length && !ts.canJsonReportNoInputFiles(project.raw)) { @@ -93657,28 +97150,30 @@ var ts; var missingOutputFileName; var newestDeclarationFileContentChangedTime = minimumDate; var isOutOfDateWithInputs = false; - for (var _b = 0, outputs_1 = outputs; _b < outputs_1.length; _b++) { - var output = outputs_1[_b]; - if (!host.fileExists(output)) { - missingOutputFileName = output; - break; - } - var outputTime = host.getModifiedTime(output) || ts.missingFileModifiedTime; - if (outputTime < oldestOutputFileTime) { - oldestOutputFileTime = outputTime; - oldestOutputFileName = output; - } - if (outputTime < newestInputFileTime) { - isOutOfDateWithInputs = true; - break; - } - if (outputTime > newestOutputFileTime) { - newestOutputFileTime = outputTime; - newestOutputFileName = output; - } - if (isDeclarationFile(output)) { - var outputModifiedTime = host.getModifiedTime(output) || ts.missingFileModifiedTime; - newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime); + if (!force) { + for (var _b = 0, outputs_1 = outputs; _b < outputs_1.length; _b++) { + var output = outputs_1[_b]; + if (!host.fileExists(output)) { + missingOutputFileName = output; + break; + } + var outputTime = ts.getModifiedTime(host, output); + if (outputTime < oldestOutputFileTime) { + oldestOutputFileTime = outputTime; + oldestOutputFileName = output; + } + if (outputTime < newestInputFileTime) { + isOutOfDateWithInputs = true; + break; + } + if (outputTime > newestOutputFileTime) { + newestOutputFileTime = outputTime; + newestOutputFileName = output; + } + if (isDeclarationFile(output)) { + var outputModifiedTime = ts.getModifiedTime(host, output); + newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime); + } } } var pseudoUpToDate = false; @@ -93710,7 +97205,7 @@ var ts; upstreamProjectName: ref.path }; } - if (!missingOutputFileName) { + if (!force && !missingOutputFileName) { if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) { continue; } @@ -93749,7 +97244,7 @@ var ts; if (extendedConfigStatus) return extendedConfigStatus; } - if (!state.buildInfoChecked.has(resolvedPath)) { + if (!force && !state.buildInfoChecked.has(resolvedPath)) { state.buildInfoChecked.set(resolvedPath, true); var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options); if (buildInfoPath) { @@ -93793,6 +97288,8 @@ var ts; return actual; } function updateOutputTimestampsWorker(state, proj, priorNewestUpdateTime, verboseMessage, skipOutputs) { + if (proj.options.noEmit) + return priorNewestUpdateTime; var host = state.host; var outputs = ts.getAllProjectOutputs(proj, !host.useCaseSensitiveFileNames()); if (!skipOutputs || outputs.length !== skipOutputs.size) { @@ -93808,7 +97305,7 @@ var ts; reportStatus(state, verboseMessage, proj.options.configFilePath); } if (isDeclarationFile(file)) { - priorNewestUpdateTime = newer(priorNewestUpdateTime, host.getModifiedTime(file) || ts.missingFileModifiedTime); + priorNewestUpdateTime = newer(priorNewestUpdateTime, ts.getModifiedTime(host, file)); } host.setModifiedTime(file, now); } @@ -93883,7 +97380,7 @@ var ts; } } } - function build(state, project, cancellationToken, onlyReferences) { + function build(state, project, cancellationToken, writeFile, getCustomTransformers, onlyReferences) { var buildOrder = getBuildOrderFor(state, project, onlyReferences); if (!buildOrder) return ts.ExitStatus.InvalidProject_OutputsSkipped; @@ -93895,7 +97392,7 @@ var ts; if (!invalidatedProject) break; reportQueue = false; - invalidatedProject.done(cancellationToken); + invalidatedProject.done(cancellationToken, writeFile, getCustomTransformers === null || getCustomTransformers === void 0 ? void 0 : getCustomTransformers(invalidatedProject.project)); if (!state.diagnostics.has(invalidatedProject.projectPath)) successfulProjects++; } @@ -93929,8 +97426,13 @@ var ts; continue; } var outputs = ts.getAllProjectOutputs(parsed, !host.useCaseSensitiveFileNames()); + if (!outputs.length) + continue; + var inputFileNames = new ts.Set(parsed.fileNames.map(function (f) { return toPath(state, f); })); for (var _a = 0, outputs_3 = outputs; _a < outputs_3.length; _a++) { var output = outputs_3[_a]; + if (inputFileNames.has(toPath(state, output))) + continue; if (host.fileExists(output)) { if (filesToDelete) { filesToDelete.push(output); @@ -94004,7 +97506,7 @@ var ts; }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.ConfigFile, resolved)); } function watchExtendedConfigFiles(state, resolvedPath, parsed) { - ts.updateSharedExtendedConfigFileWatcher(resolvedPath, parsed, state.allWatchedExtendedConfigFiles, function (extendedConfigFileName, extendedConfigFilePath) { return state.watchFile(extendedConfigFileName, function () { + ts.updateSharedExtendedConfigFileWatcher(resolvedPath, parsed === null || parsed === void 0 ? void 0 : parsed.options, state.allWatchedExtendedConfigFiles, function (extendedConfigFileName, extendedConfigFilePath) { return state.watchFile(extendedConfigFileName, function () { var _a; return (_a = state.allWatchedExtendedConfigFiles.get(extendedConfigFilePath)) === null || _a === void 0 ? void 0 : _a.projects.forEach(function (projectConfigFilePath) { return invalidateProjectAndScheduleBuilds(state, projectConfigFilePath, ts.ConfigFileProgramReloadLevel.Full); @@ -94015,6 +97517,7 @@ var ts; if (!state.watch) return; ts.updateWatchingWildcardDirectories(getOrCreateValueMapFromConfigFileMap(state.allWatchedWildcardDirectories, resolvedPath), new ts.Map(ts.getEntries(parsed.wildcardDirectories)), function (dir, flags) { return state.watchDirectory(dir, function (fileOrDirectory) { + var _a; if (ts.isIgnoredFileFromWildCardWatching({ watchedDirPath: toPath(state, dir), fileOrDirectory: fileOrDirectory, @@ -94022,9 +97525,10 @@ var ts; configFileName: resolved, currentDirectory: state.currentDirectory, options: parsed.options, - program: state.builderPrograms.get(resolvedPath), + program: state.builderPrograms.get(resolvedPath) || ((_a = getCachedParsedConfigFile(state, resolvedPath)) === null || _a === void 0 ? void 0 : _a.fileNames), useCaseSensitiveFileNames: state.parseConfigFileHost.useCaseSensitiveFileNames, - writeLog: function (s) { return state.writeLog(s); } + writeLog: function (s) { return state.writeLog(s); }, + toPath: function (fileName) { return toPath(state, fileName); } })) return; invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.Partial); @@ -94056,19 +97560,16 @@ var ts; } function stopWatching(state) { ts.clearMap(state.allWatchedConfigFiles, ts.closeFileWatcher); - ts.clearMap(state.allWatchedExtendedConfigFiles, function (watcher) { - watcher.projects.clear(); - watcher.close(); - }); + ts.clearMap(state.allWatchedExtendedConfigFiles, ts.closeFileWatcherOf); ts.clearMap(state.allWatchedWildcardDirectories, function (watchedWildcardDirectories) { return ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcherOf); }); ts.clearMap(state.allWatchedInputFiles, function (watchedWildcardDirectories) { return ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcher); }); } function createSolutionBuilderWorker(watch, hostOrHostWithWatch, rootNames, options, baseWatchOptions) { var state = createSolutionBuilderState(watch, hostOrHostWithWatch, rootNames, options, baseWatchOptions); return { - build: function (project, cancellationToken) { return build(state, project, cancellationToken); }, + build: function (project, cancellationToken, writeFile, getCustomTransformers) { return build(state, project, cancellationToken, writeFile, getCustomTransformers); }, clean: function (project) { return clean(state, project); }, - buildReferences: function (project, cancellationToken) { return build(state, project, cancellationToken, true); }, + buildReferences: function (project, cancellationToken, writeFile, getCustomTransformers) { return build(state, project, cancellationToken, writeFile, getCustomTransformers, true); }, cleanReferences: function (project) { return clean(state, project, true); }, getNextInvalidatedProject: function (cancellationToken) { setupInitialBuild(state, cancellationToken); @@ -94154,6 +97655,9 @@ var ts; } } function reportUpToDateStatus(state, configFileName, status) { + if (state.options.force && (status.type === ts.UpToDateStatusType.UpToDate || status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes)) { + return reportStatus(state, ts.Diagnostics.Project_0_is_being_forcibly_rebuilt, relName(state, configFileName)); + } switch (status.type) { case ts.UpToDateStatusType.OutOfDateWithSelf: return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, relName(state, configFileName), relName(state, status.outOfDateOutputFileName), relName(state, status.newerInputFileName)); @@ -94415,7 +97919,8 @@ var ts; var currentDirectory = sys.getCurrentDirectory(); var commandLineOptions = ts.convertToOptionsWithAbsolutePaths(commandLine.options, function (fileName) { return ts.getNormalizedAbsolutePath(fileName, currentDirectory); }); if (configFileName) { - var configParseResult = ts.parseConfigFileWithSystem(configFileName, commandLineOptions, commandLine.watchOptions, sys, reportDiagnostic); + var extendedConfigCache = new ts.Map(); + var configParseResult = ts.parseConfigFileWithSystem(configFileName, commandLineOptions, extendedConfigCache, commandLine.watchOptions, sys, reportDiagnostic); if (commandLineOptions.showConfig) { if (configParseResult.errors.length !== 0) { reportDiagnostic = updateReportDiagnostic(sys, reportDiagnostic, configParseResult.options); @@ -94429,7 +97934,7 @@ var ts; if (ts.isWatchSet(configParseResult.options)) { if (reportWatchModeWithoutSysSupport(sys, reportDiagnostic)) return; - return createWatchOfConfigFile(sys, cb, reportDiagnostic, configParseResult, commandLineOptions, commandLine.watchOptions); + return createWatchOfConfigFile(sys, cb, reportDiagnostic, configParseResult, commandLineOptions, commandLine.watchOptions, extendedConfigCache); } else if (ts.isIncrementalCompilation(configParseResult.options)) { performIncrementalCompilation(sys, cb, reportDiagnostic, configParseResult); @@ -94528,7 +98033,7 @@ var ts; updateSolutionBuilderHost(sys, cb, buildHost); var builder = ts.createSolutionBuilder(buildHost, projects, buildOptions); var exitStatus = buildOptions.clean ? builder.clean() : builder.build(); - ts.tracing.dumpLegend(); + ts.dumpTracingLegend(); return sys.exit(exitStatus); } function createReportErrorSummary(sys, options) { @@ -94606,7 +98111,7 @@ var ts; function createWatchStatusReporter(sys, options) { return ts.createWatchStatusReporter(sys, shouldBePretty(sys, options)); } - function createWatchOfConfigFile(system, cb, reportDiagnostic, configParseResult, optionsToExtend, watchOptionsToExtend) { + function createWatchOfConfigFile(system, cb, reportDiagnostic, configParseResult, optionsToExtend, watchOptionsToExtend, extendedConfigCache) { var watchCompilerHost = ts.createWatchCompilerHostOfConfigFile({ configFileName: configParseResult.options.configFilePath, optionsToExtend: optionsToExtend, @@ -94617,6 +98122,7 @@ var ts; }); updateWatchCompilationHost(system, cb, watchCompilerHost); watchCompilerHost.configFileParsingResult = configParseResult; + watchCompilerHost.extendedConfigCache = extendedConfigCache; return ts.createWatchProgram(watchCompilerHost); } function createWatchOfFilesAndCompilerOptions(system, cb, reportDiagnostic, rootFiles, options, watchOptions) { @@ -94639,16 +98145,16 @@ var ts; } function enableStatisticsAndTracing(system, compilerOptions, isBuildMode) { if (canReportDiagnostics(system, compilerOptions)) { - ts.performance.enable(); + ts.performance.enable(system); } if (canTrace(system, compilerOptions)) { - ts.tracing.startTracing(isBuildMode ? 1 : 0, compilerOptions.generateTrace, compilerOptions.configFilePath); + ts.startTracing(isBuildMode ? "build" : "project", compilerOptions.generateTrace, compilerOptions.configFilePath); } } function reportStatistics(sys, program) { var compilerOptions = program.getCompilerOptions(); if (canTrace(sys, compilerOptions)) { - ts.tracing.stopTracing(program.getTypeCatalog()); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.stopTracing(); } var statistics; if (canReportDiagnostics(sys, compilerOptions)) { diff --git a/lib/tsserver.js b/lib/tsserver.js index fea2c7355c212..66ec411647b26 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -92,7 +92,7 @@ var ts; (function (ts) { // WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values. // If changing the text in this section, be sure to test `configurePrerelease` too. - ts.versionMajorMinor = "4.2"; + ts.versionMajorMinor = "4.4"; // 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 @@ -1939,10 +1939,46 @@ var ts; * Takes a string like "jquery-min.4.2.3" and returns "jquery" */ function removeMinAndVersionNumbers(fileName) { - // Match a "." or "-" followed by a version number or 'min' at the end of the name - var trailingMinOrVersion = /[.-]((min)|(\d+(\.\d+)*))$/; - // The "min" or version may both be present, in either order, so try applying the above twice. - return fileName.replace(trailingMinOrVersion, "").replace(trailingMinOrVersion, ""); + // We used to use the regex /[.-]((min)|(\d+(\.\d+)*))$/ and would just .replace it twice. + // Unfortunately, that regex has O(n^2) performance because v8 doesn't match from the end of the string. + // Instead, we now essentially scan the filename (backwards) ourselves. + var end = fileName.length; + for (var pos = end - 1; pos > 0; pos--) { + var ch = fileName.charCodeAt(pos); + if (ch >= 48 /* _0 */ && ch <= 57 /* _9 */) { + // Match a \d+ segment + do { + --pos; + ch = fileName.charCodeAt(pos); + } while (pos > 0 && ch >= 48 /* _0 */ && ch <= 57 /* _9 */); + } + else if (pos > 4 && (ch === 110 /* n */ || ch === 78 /* N */)) { + // Looking for "min" or "min" + // Already matched the 'n' + --pos; + ch = fileName.charCodeAt(pos); + if (ch !== 105 /* i */ && ch !== 73 /* I */) { + break; + } + --pos; + ch = fileName.charCodeAt(pos); + if (ch !== 109 /* m */ && ch !== 77 /* M */) { + break; + } + --pos; + ch = fileName.charCodeAt(pos); + } + else { + // This character is not part of either suffix pattern + break; + } + if (ch !== 45 /* minus */ && ch !== 46 /* dot */) { + break; + } + end = pos; + } + // end might be fileName.length, in which case this should internally no-op + return end === fileName.length ? fileName : fileName.slice(0, end); } ts.removeMinAndVersionNumbers = removeMinAndVersionNumbers; /** Remove an item from an array, moving everything to its right one space left. */ @@ -2183,6 +2219,33 @@ var ts; return array.slice(0, index); } ts.takeWhile = takeWhile; + /** + * Removes the leading and trailing white space and line terminator characters from a string. + */ + ts.trimString = !!String.prototype.trim ? (function (s) { return s.trim(); }) : function (s) { return ts.trimStringEnd(ts.trimStringStart(s)); }; + /** + * Returns a copy with trailing whitespace removed. + */ + ts.trimStringEnd = !!String.prototype.trimEnd ? (function (s) { return s.trimEnd(); }) : trimEndImpl; + /** + * Returns a copy with leading whitespace removed. + */ + ts.trimStringStart = !!String.prototype.trimStart ? (function (s) { return s.trimStart(); }) : function (s) { return s.replace(/^\s+/g, ""); }; + /** + * https://jsbench.me/gjkoxld4au/1 + * The simple regex for this, /\s+$/g is O(n^2) in v8. + * The native .trimEnd method is by far best, but since that's technically ES2019, + * we provide a (still much faster than the simple regex) fallback. + */ + function trimEndImpl(s) { + var end = s.length - 1; + while (end >= 0) { + if (!ts.isWhiteSpaceLike(s.charCodeAt(end))) + break; + end--; + } + return s.slice(0, end + 1); + } })(ts || (ts = {})); /* @internal */ var ts; @@ -2400,6 +2463,8 @@ var ts; } } Debug.assertMissingNode = assertMissingNode; + function type(_value) { } + Debug.type = type; function getFunctionName(func) { if (typeof func !== "function") { return ""; @@ -2577,6 +2642,9 @@ var ts; // An `Array` with extra properties is rendered as `[A, B, prop1: 1, prop2: 2]`. Most of // these aren't immediately useful so we trim off the `prop1: ..., prop2: ...` part from the // formatted string. + // This regex can trigger slow backtracking because of overlapping potential captures. + // 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; } @@ -2661,11 +2729,11 @@ var ts; this.objectFlags & 8 /* Tuple */ ? "TupleType" : this.objectFlags & 16 /* Anonymous */ ? "AnonymousType" : this.objectFlags & 32 /* Mapped */ ? "MappedType" : - this.objectFlags & 2048 /* ReverseMapped */ ? "ReverseMappedType" : + this.objectFlags & 1024 /* ReverseMapped */ ? "ReverseMappedType" : this.objectFlags & 256 /* EvolvingArray */ ? "EvolvingArrayType" : "ObjectType" : "Type"; - var remainingObjectFlags = this.flags & 524288 /* Object */ ? this.objectFlags & ~2367 /* ObjectTypeKindMask */ : 0; + var remainingObjectFlags = this.flags & 524288 /* Object */ ? this.objectFlags & ~1343 /* ObjectTypeKindMask */ : 0; return "" + typeHeader + (this.symbol ? " '" + ts.symbolName(this.symbol) + "'" : "") + (remainingObjectFlags ? " (" + formatObjectFlags(remainingObjectFlags) + ")" : ""); } }, @@ -3025,7 +3093,7 @@ var ts; // range-set ::= range ( logical-or range ) * // range ::= hyphen | simple ( ' ' simple ) * | '' // logical-or ::= ( ' ' ) * '||' ( ' ' ) * - var logicalOrRegExp = /\s*\|\|\s*/g; + var logicalOrRegExp = /\|\|/g; var whitespaceRegExp = /\s+/g; // https://github.com/npm/node-semver#range-grammar // @@ -3048,14 +3116,15 @@ var ts; // primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial // tilde ::= '~' partial // caret ::= '^' partial - var rangeRegExp = /^\s*(~|\^|<|<=|>|>=|=)?\s*([a-z0-9-+.*]+)$/i; + var rangeRegExp = /^(~|\^|<|<=|>|>=|=)?\s*([a-z0-9-+.*]+)$/i; function parseRange(text) { var alternatives = []; - for (var _i = 0, _a = text.trim().split(logicalOrRegExp); _i < _a.length; _i++) { + for (var _i = 0, _a = ts.trimString(text).split(logicalOrRegExp); _i < _a.length; _i++) { var range = _a[_i]; if (!range) continue; var comparators = []; + range = ts.trimString(range); var match = hyphenRegExp.exec(range); if (match) { if (!parseHyphen(match[1], match[2], comparators)) @@ -3064,7 +3133,7 @@ var ts; else { for (var _b = 0, _c = range.split(whitespaceRegExp); _b < _c.length; _b++) { var simple = _c[_b]; - var match_1 = rangeRegExp.exec(simple); + var match_1 = rangeRegExp.exec(ts.trimString(simple)); if (!match_1 || !parseComparator(match_1[1], match_1[2], comparators)) return undefined; } @@ -3211,16 +3280,22 @@ var ts; typeof PerformanceObserver === "function" && hasRequiredAPI(performance, PerformanceObserver)) { return { + // For now we always write native performance events when running in the browser. We may + // make this conditional in the future if we find that native web performance hooks + // in the browser also slow down compilation. + shouldWriteNativeEvents: true, performance: performance, PerformanceObserver: PerformanceObserver }; } } function tryGetNodePerformanceHooks() { - if (typeof module === "object" && typeof require === "function") { + if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof module === "object" && typeof require === "function") { try { - var _a = require("perf_hooks"), performance_1 = _a.performance, PerformanceObserver_1 = _a.PerformanceObserver; - if (hasRequiredAPI(performance_1, PerformanceObserver_1)) { + var performance_1; + var _a = require("perf_hooks"), nodePerformance_1 = _a.performance, PerformanceObserver_1 = _a.PerformanceObserver; + if (hasRequiredAPI(nodePerformance_1, PerformanceObserver_1)) { + performance_1 = nodePerformance_1; // There is a bug in Node's performance.measure prior to 12.16.3/13.13.0 that does not // match the Web Performance API specification. Node's implementation did not allow // optional `start` and `end` arguments for `performance.measure`. @@ -3228,27 +3303,26 @@ var ts; var version_1 = new ts.Version(process.versions.node); var range = new ts.VersionRange("<12.16.3 || 13 <13.13"); if (range.test(version_1)) { - return { - performance: { - get timeOrigin() { return performance_1.timeOrigin; }, - now: function () { return performance_1.now(); }, - mark: function (name) { return performance_1.mark(name); }, - measure: function (name, start, end) { - if (start === void 0) { start = "nodeStart"; } - if (end === undefined) { - end = "__performance.measure-fix__"; - performance_1.mark(end); - } - performance_1.measure(name, start, end); - if (end === "__performance.measure-fix__") { - performance_1.clearMarks("__performance.measure-fix__"); - } + performance_1 = { + get timeOrigin() { return nodePerformance_1.timeOrigin; }, + now: function () { return nodePerformance_1.now(); }, + mark: function (name) { return nodePerformance_1.mark(name); }, + measure: function (name, start, end) { + if (start === void 0) { start = "nodeStart"; } + if (end === undefined) { + end = "__performance.measure-fix__"; + nodePerformance_1.mark(end); + } + nodePerformance_1.measure(name, start, end); + if (end === "__performance.measure-fix__") { + nodePerformance_1.clearMarks("__performance.measure-fix__"); } - }, - PerformanceObserver: PerformanceObserver_1 + } }; } return { + // By default, only write native events when generating a cpu profile or using the v8 profiler. + shouldWriteNativeEvents: false, performance: performance_1, PerformanceObserver: PerformanceObserver_1 }; @@ -3279,7 +3353,6 @@ var ts; var performance; (function (performance) { var perfHooks; - var perfObserver; // when set, indicates the implementation of `Performance` to use for user timing. // when unset, indicates user timing is unavailable or disabled. var performanceImpl; @@ -3310,6 +3383,9 @@ var ts; } performance.createTimer = createTimer; performance.nullTimer = { enter: ts.noop, exit: ts.noop }; + var enabled = false; + var timeorigin = ts.timestamp(); + var marks = new ts.Map(); var counts = new ts.Map(); var durations = new ts.Map(); /** @@ -3318,7 +3394,13 @@ var ts; * @param markName The name of the mark. */ function mark(markName) { - performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.mark(markName); + var _a; + if (enabled) { + var count = (_a = counts.get(markName)) !== null && _a !== void 0 ? _a : 0; + counts.set(markName, count + 1); + marks.set(markName, ts.timestamp()); + performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.mark(markName); + } } performance.mark = mark; /** @@ -3331,7 +3413,14 @@ var ts; * used. */ function measure(measureName, startMarkName, endMarkName) { - performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.measure(measureName, startMarkName, endMarkName); + var _a, _b; + if (enabled) { + var end = (_a = (endMarkName !== undefined ? marks.get(endMarkName) : undefined)) !== null && _a !== void 0 ? _a : ts.timestamp(); + var start = (_b = (startMarkName !== undefined ? marks.get(startMarkName) : undefined)) !== null && _b !== void 0 ? _b : timeorigin; + var previousDuration = durations.get(measureName) || 0; + durations.set(measureName, previousDuration + (end - start)); + performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.measure(measureName, startMarkName, endMarkName); + } } performance.measure = measure; /** @@ -3365,40 +3454,41 @@ var ts; * Indicates whether the performance API is enabled. */ function isEnabled() { - return !!performanceImpl; + return enabled; } performance.isEnabled = isEnabled; /** Enables (and resets) performance measurements for the compiler. */ - function enable() { - if (!performanceImpl) { + function enable(system) { + var _a; + if (system === void 0) { system = ts.sys; } + if (!enabled) { + enabled = true; perfHooks || (perfHooks = ts.tryGetNativePerformanceHooks()); - if (!perfHooks) - return false; - perfObserver || (perfObserver = new perfHooks.PerformanceObserver(updateStatisticsFromList)); - perfObserver.observe({ entryTypes: ["mark", "measure"] }); - performanceImpl = perfHooks.performance; + if (perfHooks) { + timeorigin = perfHooks.performance.timeOrigin; + // NodeJS's Web Performance API is currently slower than expected, but we'd still like + // to be able to leverage native trace events when node is run with either `--cpu-prof` + // or `--prof`, if we're running with our own `--generateCpuProfile` flag, or when + // running in debug mode (since its possible to generate a cpu profile while debugging). + if (perfHooks.shouldWriteNativeEvents || ((_a = system === null || system === void 0 ? void 0 : system.cpuProfilingEnabled) === null || _a === void 0 ? void 0 : _a.call(system)) || (system === null || system === void 0 ? void 0 : system.debugMode)) { + performanceImpl = perfHooks.performance; + } + } } return true; } performance.enable = enable; /** Disables performance measurements for the compiler. */ function disable() { - perfObserver === null || perfObserver === void 0 ? void 0 : perfObserver.disconnect(); - performanceImpl = undefined; - counts.clear(); - durations.clear(); - } - performance.disable = disable; - function updateStatisticsFromList(list) { - for (var _i = 0, _a = list.getEntriesByType("mark"); _i < _a.length; _i++) { - var mark_1 = _a[_i]; - counts.set(mark_1.name, (counts.get(mark_1.name) || 0) + 1); - } - for (var _b = 0, _c = list.getEntriesByType("measure"); _b < _c.length; _b++) { - var measure_1 = _c[_b]; - durations.set(measure_1.name, (durations.get(measure_1.name) || 0) + measure_1.duration); + if (enabled) { + marks.clear(); + counts.clear(); + durations.clear(); + performanceImpl = undefined; + enabled = false; } } + performance.disable = disable; })(performance = ts.performance || (ts.performance = {})); })(ts || (ts = {})); /* @internal */ @@ -3442,40 +3532,35 @@ var ts; /** Performance logger that will generate ETW events if possible - check for `logEvent` member, as `etwModule` will be `{}` when browserified */ ts.perfLogger = etwModule && etwModule.logEvent ? etwModule : nullLogger; })(ts || (ts = {})); +/* Tracing events for the compiler. */ /*@internal*/ -/** Tracing events for the compiler. */ var ts; (function (ts) { - var tracing; - (function (tracing) { - var Mode; - (function (Mode) { - Mode[Mode["Project"] = 0] = "Project"; - Mode[Mode["Build"] = 1] = "Build"; - Mode[Mode["Server"] = 2] = "Server"; - })(Mode = tracing.Mode || (tracing.Mode = {})); + // enable the above using startTracing() + // `tracingEnabled` should never be used directly, only through the above + var tracingEnabled; + (function (tracingEnabled) { var fs; var traceCount = 0; - var traceFd; + var traceFd = 0; var mode; + var typeCatalog = []; // NB: id is index + 1 var legendPath; var legend = []; ; - /** Starts tracing for the given project (unless the `fs` module is unavailable). */ + /** Starts tracing for the given project. */ function startTracing(tracingMode, traceDir, configFilePath) { - ts.Debug.assert(!traceFd, "Tracing already started"); + ts.Debug.assert(!ts.tracing, "Tracing already started"); if (fs === undefined) { try { fs = require("fs"); } - catch (_a) { - fs = false; + catch (e) { + throw new Error("tracing requires having fs\n(original error: " + (e.message || e) + ")"); } } - if (!fs) { - return; - } mode = tracingMode; + typeCatalog.length = 0; if (legendPath === undefined) { legendPath = ts.combinePaths(traceDir, "legend.json"); } @@ -3483,9 +3568,9 @@ var ts; if (!fs.existsSync(traceDir)) { fs.mkdirSync(traceDir, { recursive: true }); } - var countPart = mode === 1 /* Build */ ? "." + process.pid + "-" + ++traceCount : - mode === 2 /* Server */ ? "." + process.pid : - ""; + var countPart = mode === "build" ? "." + process.pid + "-" + ++traceCount + : mode === "server" ? "." + process.pid + : ""; var tracePath = ts.combinePaths(traceDir, "trace" + countPart + ".json"); var typesPath = ts.combinePaths(traceDir, "types" + countPart + ".json"); legend.push({ @@ -3494,25 +3579,22 @@ var ts; typesPath: typesPath, }); traceFd = fs.openSync(tracePath, "w"); + ts.tracing = tracingEnabled; // only when traceFd is properly set // Start with a prefix that contains some metadata that the devtools profiler expects (also avoids a warning on import) var meta = { cat: "__metadata", ph: "M", ts: 1000 * ts.timestamp(), pid: 1, tid: 1 }; fs.writeSync(traceFd, "[\n" + [__assign({ name: "process_name", args: { name: "tsc" } }, meta), __assign({ name: "thread_name", args: { name: "Main" } }, meta), __assign(__assign({ name: "TracingStartedInBrowser" }, meta), { cat: "disabled-by-default-devtools.timeline" })] .map(function (v) { return JSON.stringify(v); }).join(",\n")); } - tracing.startTracing = startTracing; - /** Stops tracing for the in-progress project and dumps the type catalog (unless the `fs` module is unavailable). */ - function stopTracing(typeCatalog) { - if (!traceFd) { - ts.Debug.assert(!fs, "Tracing is not in progress"); - return; - } - ts.Debug.assert(fs); - ts.Debug.assert(!!typeCatalog === (mode !== 2 /* Server */)); // Have a type catalog iff not in server mode + tracingEnabled.startTracing = startTracing; + /** Stops tracing for the in-progress project and dumps the type catalog. */ + function stopTracing() { + ts.Debug.assert(ts.tracing, "Tracing is not in progress"); + ts.Debug.assert(!!typeCatalog.length === (mode !== "server")); // Have a type catalog iff not in server mode fs.writeSync(traceFd, "\n]\n"); fs.closeSync(traceFd); - traceFd = undefined; - if (typeCatalog) { + ts.tracing = undefined; + if (typeCatalog.length) { dumpTypes(typeCatalog); } else { @@ -3521,11 +3603,13 @@ var ts; legend[legend.length - 1].typesPath = undefined; } } - tracing.stopTracing = stopTracing; - function isTracing() { - return !!traceFd; + tracingEnabled.stopTracing = stopTracing; + function recordType(type) { + if (mode !== "server") { + typeCatalog.push(type); + } } - tracing.isTracing = isTracing; + tracingEnabled.recordType = recordType; var Phase; (function (Phase) { Phase["Parse"] = "parse"; @@ -3535,13 +3619,11 @@ var ts; Phase["CheckTypes"] = "checkTypes"; Phase["Emit"] = "emit"; Phase["Session"] = "session"; - })(Phase = tracing.Phase || (tracing.Phase = {})); + })(Phase = tracingEnabled.Phase || (tracingEnabled.Phase = {})); function instant(phase, name, args) { - if (!traceFd) - return; writeEvent("I", phase, name, args, "\"s\":\"g\""); } - tracing.instant = instant; + tracingEnabled.instant = instant; var eventStack = []; /** * @param separateBeginAndEnd - used for special cases where we need the trace point even if the event @@ -3551,47 +3633,42 @@ var ts; */ function push(phase, name, args, separateBeginAndEnd) { if (separateBeginAndEnd === void 0) { separateBeginAndEnd = false; } - if (!traceFd) - return; if (separateBeginAndEnd) { writeEvent("B", phase, name, args); } eventStack.push({ phase: phase, name: name, args: args, time: 1000 * ts.timestamp(), separateBeginAndEnd: separateBeginAndEnd }); } - tracing.push = push; + tracingEnabled.push = push; function pop() { - if (!traceFd) - return; ts.Debug.assert(eventStack.length > 0); writeStackEvent(eventStack.length - 1, 1000 * ts.timestamp()); eventStack.length--; } - tracing.pop = pop; + tracingEnabled.pop = pop; function popAll() { - if (!traceFd) - return; var endTime = 1000 * ts.timestamp(); for (var i = eventStack.length - 1; i >= 0; i--) { writeStackEvent(i, endTime); } eventStack.length = 0; } - tracing.popAll = popAll; + tracingEnabled.popAll = popAll; + // sample every 10ms + var sampleInterval = 1000 * 10; function writeStackEvent(index, endTime) { var _a = eventStack[index], phase = _a.phase, name = _a.name, args = _a.args, time = _a.time, separateBeginAndEnd = _a.separateBeginAndEnd; if (separateBeginAndEnd) { writeEvent("E", phase, name, args, /*extras*/ undefined, endTime); } - else { + // test if [time,endTime) straddles a sampling point + else if (sampleInterval - (time % sampleInterval) <= endTime - time) { writeEvent("X", phase, name, args, "\"dur\":" + (endTime - time), time); } } function writeEvent(eventType, phase, name, args, extras, time) { if (time === void 0) { time = 1000 * ts.timestamp(); } - ts.Debug.assert(traceFd); - ts.Debug.assert(fs); // In server mode, there's no easy way to dump type information, so we drop events that would require it. - if (mode === 2 /* Server */ && phase === "checkTypes" /* CheckTypes */) + if (mode === "server" && phase === "checkTypes" /* CheckTypes */) return; ts.performance.mark("beginTracing"); fs.writeSync(traceFd, ",\n{\"pid\":1,\"tid\":1,\"ph\":\"" + eventType + "\",\"cat\":\"" + phase + "\",\"ts\":" + time + ",\"name\":\"" + name + "\""); @@ -3603,15 +3680,24 @@ var ts; ts.performance.mark("endTracing"); ts.performance.measure("Tracing", "beginTracing", "endTracing"); } - function indexFromOne(lc) { - return { - line: lc.line + 1, - character: lc.character + 1, - }; + function getLocation(node) { + var file = ts.getSourceFileOfNode(node); + return !file + ? undefined + : { + path: file.path, + start: indexFromOne(ts.getLineAndCharacterOfPosition(file, node.pos)), + end: indexFromOne(ts.getLineAndCharacterOfPosition(file, node.end)), + }; + function indexFromOne(lc) { + return { + line: lc.line + 1, + character: lc.character + 1, + }; + } } function dumpTypes(types) { - var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r; - ts.Debug.assert(fs); + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x; ts.performance.mark("beginDumpTypes"); var typesPath = legend[legend.length - 1].typesPath; var typesFd = fs.openSync(typesPath, "w"); @@ -3623,15 +3709,13 @@ var ts; var type = types[i]; var objectFlags = type.objectFlags; var symbol = (_a = type.aliasSymbol) !== null && _a !== void 0 ? _a : type.symbol; - var firstDeclaration = (_b = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _b === void 0 ? void 0 : _b[0]; - var firstFile = firstDeclaration && ts.getSourceFileOfNode(firstDeclaration); // 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 */)) { try { - display = (_c = type.checker) === null || _c === void 0 ? void 0 : _c.typeToString(type); + display = (_b = type.checker) === null || _b === void 0 ? void 0 : _b.typeToString(type); } - catch (_s) { + catch (_y) { display = undefined; } } @@ -3639,26 +3723,52 @@ var ts; if (type.flags & 8388608 /* IndexedAccess */) { var indexedAccessType = type; indexedAccessProperties = { - indexedAccessObjectType: (_d = indexedAccessType.objectType) === null || _d === void 0 ? void 0 : _d.id, - indexedAccessIndexType: (_e = indexedAccessType.indexType) === null || _e === void 0 ? void 0 : _e.id, + indexedAccessObjectType: (_c = indexedAccessType.objectType) === null || _c === void 0 ? void 0 : _c.id, + indexedAccessIndexType: (_d = indexedAccessType.indexType) === null || _d === void 0 ? void 0 : _d.id, }; } var referenceProperties = {}; if (objectFlags & 4 /* Reference */) { var referenceType = type; referenceProperties = { - instantiatedType: (_f = referenceType.target) === null || _f === void 0 ? void 0 : _f.id, - typeArguments: (_g = referenceType.resolvedTypeArguments) === null || _g === void 0 ? void 0 : _g.map(function (t) { return t.id; }), + instantiatedType: (_e = referenceType.target) === null || _e === void 0 ? void 0 : _e.id, + typeArguments: (_f = referenceType.resolvedTypeArguments) === null || _f === void 0 ? void 0 : _f.map(function (t) { return t.id; }), + referenceLocation: getLocation(referenceType.node), }; } var conditionalProperties = {}; if (type.flags & 16777216 /* Conditional */) { var conditionalType = type; conditionalProperties = { - conditionalCheckType: (_h = conditionalType.checkType) === null || _h === void 0 ? void 0 : _h.id, - conditionalExtendsType: (_j = conditionalType.extendsType) === null || _j === void 0 ? void 0 : _j.id, - conditionalTrueType: (_l = (_k = conditionalType.resolvedTrueType) === null || _k === void 0 ? void 0 : _k.id) !== null && _l !== void 0 ? _l : -1, - conditionalFalseType: (_o = (_m = conditionalType.resolvedFalseType) === null || _m === void 0 ? void 0 : _m.id) !== null && _o !== void 0 ? _o : -1, + conditionalCheckType: (_g = conditionalType.checkType) === null || _g === void 0 ? void 0 : _g.id, + conditionalExtendsType: (_h = conditionalType.extendsType) === null || _h === void 0 ? void 0 : _h.id, + conditionalTrueType: (_k = (_j = conditionalType.resolvedTrueType) === null || _j === void 0 ? void 0 : _j.id) !== null && _k !== void 0 ? _k : -1, + conditionalFalseType: (_m = (_l = conditionalType.resolvedFalseType) === null || _l === void 0 ? void 0 : _l.id) !== null && _m !== void 0 ? _m : -1, + }; + } + var substitutionProperties = {}; + if (type.flags & 33554432 /* Substitution */) { + var substitutionType = type; + substitutionProperties = { + substitutionBaseType: (_o = substitutionType.baseType) === null || _o === void 0 ? void 0 : _o.id, + substituteType: (_p = substitutionType.substitute) === null || _p === void 0 ? void 0 : _p.id, + }; + } + var reverseMappedProperties = {}; + if (objectFlags & 1024 /* ReverseMapped */) { + var reverseMappedType = type; + reverseMappedProperties = { + reverseMappedSourceType: (_q = reverseMappedType.source) === null || _q === void 0 ? void 0 : _q.id, + reverseMappedMappedType: (_r = reverseMappedType.mappedType) === null || _r === void 0 ? void 0 : _r.id, + reverseMappedConstraintType: (_s = reverseMappedType.constraintType) === null || _s === void 0 ? void 0 : _s.id, + }; + } + var evolvingArrayProperties = {}; + if (objectFlags & 256 /* EvolvingArray */) { + var evolvingArrayType = type; + evolvingArrayProperties = { + evolvingArrayElementType: evolvingArrayType.elementType.id, + evolvingArrayFinalType: (_t = evolvingArrayType.finalArrayType) === null || _t === void 0 ? void 0 : _t.id, }; } // We can't print out an arbitrary object, so just assign each one a unique number. @@ -3672,11 +3782,7 @@ var ts; recursionIdentityMap.set(recursionIdentity, recursionToken); } } - var descriptor = __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, unionTypes: (type.flags & 1048576 /* Union */) ? (_p = type.types) === null || _p === void 0 ? void 0 : _p.map(function (t) { return t.id; }) : undefined, intersectionTypes: (type.flags & 2097152 /* Intersection */) ? type.types.map(function (t) { return t.id; }) : undefined, aliasTypeArguments: (_q = type.aliasTypeArguments) === null || _q === void 0 ? void 0 : _q.map(function (t) { return t.id; }), keyofType: (type.flags & 4194304 /* Index */) ? (_r = type.type) === null || _r === void 0 ? void 0 : _r.id : undefined }, indexedAccessProperties), referenceProperties), conditionalProperties), { firstDeclaration: firstDeclaration && { - path: firstFile.path, - start: indexFromOne(ts.getLineAndCharacterOfPosition(firstFile, firstDeclaration.pos)), - end: indexFromOne(ts.getLineAndCharacterOfPosition(ts.getSourceFileOfNode(firstDeclaration), firstDeclaration.end)), - }, 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 /* 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 }); fs.writeSync(typesFd, JSON.stringify(descriptor)); if (i < numTypes - 1) { fs.writeSync(typesFd, ",\n"); @@ -3691,11 +3797,13 @@ var ts; if (!legendPath) { return; } - ts.Debug.assert(fs); fs.writeFileSync(legendPath, JSON.stringify(legend)); } - tracing.dumpLegend = dumpLegend; - })(tracing = ts.tracing || (ts.tracing = {})); + tracingEnabled.dumpLegend = dumpLegend; + })(tracingEnabled || (tracingEnabled = {})); + // define after tracingEnabled is initialized + ts.startTracing = tracingEnabled.startTracing; + ts.dumpTracingLegend = tracingEnabled.dumpLegend; })(ts || (ts = {})); var ts; (function (ts) { @@ -3772,331 +3880,337 @@ var ts; SyntaxKind[SyntaxKind["QuestionQuestionToken"] = 60] = "QuestionQuestionToken"; /** Only the JSDoc scanner produces BacktickToken. The normal scanner produces NoSubstitutionTemplateLiteral and related kinds. */ SyntaxKind[SyntaxKind["BacktickToken"] = 61] = "BacktickToken"; + /** Only the JSDoc scanner produces HashToken. The normal scanner produces PrivateIdentifier. */ + SyntaxKind[SyntaxKind["HashToken"] = 62] = "HashToken"; // Assignments - SyntaxKind[SyntaxKind["EqualsToken"] = 62] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 63] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 64] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 65] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 66] = "AsteriskAsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 67] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 68] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 69] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 70] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 71] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 72] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 73] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["BarBarEqualsToken"] = 74] = "BarBarEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandEqualsToken"] = 75] = "AmpersandAmpersandEqualsToken"; - SyntaxKind[SyntaxKind["QuestionQuestionEqualsToken"] = 76] = "QuestionQuestionEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 77] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 63] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 64] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 65] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 66] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 67] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 68] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 69] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 70] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 71] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 72] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 73] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 74] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["BarBarEqualsToken"] = 75] = "BarBarEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandEqualsToken"] = 76] = "AmpersandAmpersandEqualsToken"; + SyntaxKind[SyntaxKind["QuestionQuestionEqualsToken"] = 77] = "QuestionQuestionEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 78] = "CaretEqualsToken"; // Identifiers and PrivateIdentifiers - SyntaxKind[SyntaxKind["Identifier"] = 78] = "Identifier"; - SyntaxKind[SyntaxKind["PrivateIdentifier"] = 79] = "PrivateIdentifier"; + SyntaxKind[SyntaxKind["Identifier"] = 79] = "Identifier"; + SyntaxKind[SyntaxKind["PrivateIdentifier"] = 80] = "PrivateIdentifier"; // Reserved words - SyntaxKind[SyntaxKind["BreakKeyword"] = 80] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 81] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 82] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 83] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 84] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 85] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 86] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 87] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 88] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 89] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 90] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 91] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 92] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 93] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 94] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 95] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 96] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 97] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 98] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 99] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 100] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 101] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 102] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 103] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 104] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 105] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 106] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 107] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 108] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 109] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 110] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 111] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 112] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 113] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 114] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 115] = "WithKeyword"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 81] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 82] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 83] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 84] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 85] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 86] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 87] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 88] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 89] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 90] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 91] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 92] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 93] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 94] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 95] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 96] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 97] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 98] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 99] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 100] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 101] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 102] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 103] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 104] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 105] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 106] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 107] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 108] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 109] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 110] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 111] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 112] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 113] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 114] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 115] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 116] = "WithKeyword"; // Strict mode reserved words - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 116] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 117] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 118] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 119] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 120] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 121] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 122] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 123] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 124] = "YieldKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 117] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 118] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 119] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 120] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 121] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 122] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 123] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 124] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 125] = "YieldKeyword"; // Contextual keywords - SyntaxKind[SyntaxKind["AbstractKeyword"] = 125] = "AbstractKeyword"; - SyntaxKind[SyntaxKind["AsKeyword"] = 126] = "AsKeyword"; - SyntaxKind[SyntaxKind["AssertsKeyword"] = 127] = "AssertsKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 128] = "AnyKeyword"; - SyntaxKind[SyntaxKind["AsyncKeyword"] = 129] = "AsyncKeyword"; - SyntaxKind[SyntaxKind["AwaitKeyword"] = 130] = "AwaitKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 131] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 132] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 133] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 134] = "GetKeyword"; - SyntaxKind[SyntaxKind["InferKeyword"] = 135] = "InferKeyword"; - SyntaxKind[SyntaxKind["IntrinsicKeyword"] = 136] = "IntrinsicKeyword"; - SyntaxKind[SyntaxKind["IsKeyword"] = 137] = "IsKeyword"; - SyntaxKind[SyntaxKind["KeyOfKeyword"] = 138] = "KeyOfKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 139] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["NamespaceKeyword"] = 140] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["NeverKeyword"] = 141] = "NeverKeyword"; - SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 142] = "ReadonlyKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 143] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 144] = "NumberKeyword"; - SyntaxKind[SyntaxKind["ObjectKeyword"] = 145] = "ObjectKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 146] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 147] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 148] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 149] = "TypeKeyword"; - SyntaxKind[SyntaxKind["UndefinedKeyword"] = 150] = "UndefinedKeyword"; - SyntaxKind[SyntaxKind["UniqueKeyword"] = 151] = "UniqueKeyword"; - SyntaxKind[SyntaxKind["UnknownKeyword"] = 152] = "UnknownKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 153] = "FromKeyword"; - SyntaxKind[SyntaxKind["GlobalKeyword"] = 154] = "GlobalKeyword"; - SyntaxKind[SyntaxKind["BigIntKeyword"] = 155] = "BigIntKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 156] = "OfKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 126] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 127] = "AsKeyword"; + SyntaxKind[SyntaxKind["AssertsKeyword"] = 128] = "AssertsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 129] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 130] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 131] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 132] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 133] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 134] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 135] = "GetKeyword"; + SyntaxKind[SyntaxKind["InferKeyword"] = 136] = "InferKeyword"; + SyntaxKind[SyntaxKind["IntrinsicKeyword"] = 137] = "IntrinsicKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 138] = "IsKeyword"; + SyntaxKind[SyntaxKind["KeyOfKeyword"] = 139] = "KeyOfKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 140] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 141] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 142] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 143] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 144] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 145] = "NumberKeyword"; + SyntaxKind[SyntaxKind["ObjectKeyword"] = 146] = "ObjectKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 147] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 148] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 149] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 150] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 151] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["UniqueKeyword"] = 152] = "UniqueKeyword"; + SyntaxKind[SyntaxKind["UnknownKeyword"] = 153] = "UnknownKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 154] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 155] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["BigIntKeyword"] = 156] = "BigIntKeyword"; + SyntaxKind[SyntaxKind["OverrideKeyword"] = 157] = "OverrideKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 158] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 157] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 158] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 159] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 160] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 159] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 160] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 161] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 161] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 162] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 163] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 162] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 163] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 164] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 165] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 166] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 167] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 168] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 169] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 170] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 171] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 164] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 165] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 166] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 167] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 168] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 169] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 170] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 171] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 172] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 173] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 172] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 173] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 174] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 175] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 176] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 177] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 178] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 179] = "TupleType"; - SyntaxKind[SyntaxKind["OptionalType"] = 180] = "OptionalType"; - SyntaxKind[SyntaxKind["RestType"] = 181] = "RestType"; - SyntaxKind[SyntaxKind["UnionType"] = 182] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 183] = "IntersectionType"; - SyntaxKind[SyntaxKind["ConditionalType"] = 184] = "ConditionalType"; - SyntaxKind[SyntaxKind["InferType"] = 185] = "InferType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 186] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 187] = "ThisType"; - SyntaxKind[SyntaxKind["TypeOperator"] = 188] = "TypeOperator"; - SyntaxKind[SyntaxKind["IndexedAccessType"] = 189] = "IndexedAccessType"; - SyntaxKind[SyntaxKind["MappedType"] = 190] = "MappedType"; - SyntaxKind[SyntaxKind["LiteralType"] = 191] = "LiteralType"; - SyntaxKind[SyntaxKind["NamedTupleMember"] = 192] = "NamedTupleMember"; - SyntaxKind[SyntaxKind["TemplateLiteralType"] = 193] = "TemplateLiteralType"; - SyntaxKind[SyntaxKind["TemplateLiteralTypeSpan"] = 194] = "TemplateLiteralTypeSpan"; - SyntaxKind[SyntaxKind["ImportType"] = 195] = "ImportType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 174] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 175] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 176] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 177] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 178] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 179] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 180] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 181] = "TupleType"; + SyntaxKind[SyntaxKind["OptionalType"] = 182] = "OptionalType"; + SyntaxKind[SyntaxKind["RestType"] = 183] = "RestType"; + SyntaxKind[SyntaxKind["UnionType"] = 184] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 185] = "IntersectionType"; + SyntaxKind[SyntaxKind["ConditionalType"] = 186] = "ConditionalType"; + SyntaxKind[SyntaxKind["InferType"] = 187] = "InferType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 188] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 189] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 190] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 191] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 192] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 193] = "LiteralType"; + SyntaxKind[SyntaxKind["NamedTupleMember"] = 194] = "NamedTupleMember"; + SyntaxKind[SyntaxKind["TemplateLiteralType"] = 195] = "TemplateLiteralType"; + SyntaxKind[SyntaxKind["TemplateLiteralTypeSpan"] = 196] = "TemplateLiteralTypeSpan"; + SyntaxKind[SyntaxKind["ImportType"] = 197] = "ImportType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 196] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 197] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 198] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 198] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 199] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 200] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 199] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 200] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 201] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 202] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 203] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 204] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 205] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 206] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 207] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 208] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 209] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 210] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 211] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 212] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 213] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 214] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 215] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 216] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 217] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 218] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 219] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElement"] = 220] = "SpreadElement"; - SyntaxKind[SyntaxKind["ClassExpression"] = 221] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 222] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 223] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 224] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 225] = "NonNullExpression"; - SyntaxKind[SyntaxKind["MetaProperty"] = 226] = "MetaProperty"; - SyntaxKind[SyntaxKind["SyntheticExpression"] = 227] = "SyntheticExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 201] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 202] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 203] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 204] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 205] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 206] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 207] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 208] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 209] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 210] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 211] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 212] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 213] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 214] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 215] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 216] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 217] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 218] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 219] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 220] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 221] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 222] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 223] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 224] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 225] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 226] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 227] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 228] = "MetaProperty"; + SyntaxKind[SyntaxKind["SyntheticExpression"] = 229] = "SyntheticExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 228] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 229] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 230] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 231] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 230] = "Block"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 231] = "EmptyStatement"; - SyntaxKind[SyntaxKind["VariableStatement"] = 232] = "VariableStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 233] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 234] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 235] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 236] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 237] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 238] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 239] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 240] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 241] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 242] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 243] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 244] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 245] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 246] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 247] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 248] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 249] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 250] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 251] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 252] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 253] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 254] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 255] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 256] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 257] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 258] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 259] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 260] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 261] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 262] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 263] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 264] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 265] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 266] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 267] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 268] = "NamedExports"; - SyntaxKind[SyntaxKind["NamespaceExport"] = 269] = "NamespaceExport"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 270] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 271] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 232] = "Block"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 233] = "EmptyStatement"; + SyntaxKind[SyntaxKind["VariableStatement"] = 234] = "VariableStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 235] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 236] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 237] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 238] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 239] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 240] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 241] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 242] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 243] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 244] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 245] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 246] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 247] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 248] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 249] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 250] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 251] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 252] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 253] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 254] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 255] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 256] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 257] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 258] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 259] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 260] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 261] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 262] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 263] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 264] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 265] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 266] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 267] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 268] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 269] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 270] = "NamedExports"; + SyntaxKind[SyntaxKind["NamespaceExport"] = 271] = "NamespaceExport"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 272] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 273] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 272] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 274] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 273] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 274] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 275] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 276] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxFragment"] = 277] = "JsxFragment"; - SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 278] = "JsxOpeningFragment"; - SyntaxKind[SyntaxKind["JsxClosingFragment"] = 279] = "JsxClosingFragment"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 280] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxAttributes"] = 281] = "JsxAttributes"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 282] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 283] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 275] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 276] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 277] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 278] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxFragment"] = 279] = "JsxFragment"; + SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 280] = "JsxOpeningFragment"; + SyntaxKind[SyntaxKind["JsxClosingFragment"] = 281] = "JsxClosingFragment"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 282] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 283] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 284] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 285] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 284] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 285] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 286] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 287] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 286] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 287] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 288] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 289] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 288] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 289] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 290] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 290] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 291] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 292] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 291] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 293] = "EnumMember"; // Unparsed - SyntaxKind[SyntaxKind["UnparsedPrologue"] = 292] = "UnparsedPrologue"; - SyntaxKind[SyntaxKind["UnparsedPrepend"] = 293] = "UnparsedPrepend"; - SyntaxKind[SyntaxKind["UnparsedText"] = 294] = "UnparsedText"; - SyntaxKind[SyntaxKind["UnparsedInternalText"] = 295] = "UnparsedInternalText"; - SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 296] = "UnparsedSyntheticReference"; + SyntaxKind[SyntaxKind["UnparsedPrologue"] = 294] = "UnparsedPrologue"; + SyntaxKind[SyntaxKind["UnparsedPrepend"] = 295] = "UnparsedPrepend"; + SyntaxKind[SyntaxKind["UnparsedText"] = 296] = "UnparsedText"; + SyntaxKind[SyntaxKind["UnparsedInternalText"] = 297] = "UnparsedInternalText"; + SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 298] = "UnparsedSyntheticReference"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 297] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 298] = "Bundle"; - SyntaxKind[SyntaxKind["UnparsedSource"] = 299] = "UnparsedSource"; - SyntaxKind[SyntaxKind["InputFiles"] = 300] = "InputFiles"; + SyntaxKind[SyntaxKind["SourceFile"] = 299] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 300] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 301] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 302] = "InputFiles"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 301] = "JSDocTypeExpression"; - SyntaxKind[SyntaxKind["JSDocNameReference"] = 302] = "JSDocNameReference"; - // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 303] = "JSDocAllType"; - // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 304] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 305] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 306] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 307] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 308] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 309] = "JSDocVariadicType"; - // https://jsdoc.app/about-namepaths.html - SyntaxKind[SyntaxKind["JSDocNamepathType"] = 310] = "JSDocNamepathType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 311] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 312] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocSignature"] = 313] = "JSDocSignature"; - SyntaxKind[SyntaxKind["JSDocTag"] = 314] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 315] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocImplementsTag"] = 316] = "JSDocImplementsTag"; - SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 317] = "JSDocAuthorTag"; - SyntaxKind[SyntaxKind["JSDocDeprecatedTag"] = 318] = "JSDocDeprecatedTag"; - SyntaxKind[SyntaxKind["JSDocClassTag"] = 319] = "JSDocClassTag"; - SyntaxKind[SyntaxKind["JSDocPublicTag"] = 320] = "JSDocPublicTag"; - SyntaxKind[SyntaxKind["JSDocPrivateTag"] = 321] = "JSDocPrivateTag"; - SyntaxKind[SyntaxKind["JSDocProtectedTag"] = 322] = "JSDocProtectedTag"; - SyntaxKind[SyntaxKind["JSDocReadonlyTag"] = 323] = "JSDocReadonlyTag"; - SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 324] = "JSDocCallbackTag"; - SyntaxKind[SyntaxKind["JSDocEnumTag"] = 325] = "JSDocEnumTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 326] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 327] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocThisTag"] = 328] = "JSDocThisTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 329] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 330] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 331] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocSeeTag"] = 332] = "JSDocSeeTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 333] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 303] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocNameReference"] = 304] = "JSDocNameReference"; + SyntaxKind[SyntaxKind["JSDocMemberName"] = 305] = "JSDocMemberName"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 306] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 307] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 308] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 309] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 310] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 311] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 312] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocNamepathType"] = 313] = "JSDocNamepathType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 314] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocText"] = 315] = "JSDocText"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 316] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 317] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocLink"] = 318] = "JSDocLink"; + SyntaxKind[SyntaxKind["JSDocLinkCode"] = 319] = "JSDocLinkCode"; + SyntaxKind[SyntaxKind["JSDocLinkPlain"] = 320] = "JSDocLinkPlain"; + SyntaxKind[SyntaxKind["JSDocTag"] = 321] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 322] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocImplementsTag"] = 323] = "JSDocImplementsTag"; + SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 324] = "JSDocAuthorTag"; + SyntaxKind[SyntaxKind["JSDocDeprecatedTag"] = 325] = "JSDocDeprecatedTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 326] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocPublicTag"] = 327] = "JSDocPublicTag"; + SyntaxKind[SyntaxKind["JSDocPrivateTag"] = 328] = "JSDocPrivateTag"; + SyntaxKind[SyntaxKind["JSDocProtectedTag"] = 329] = "JSDocProtectedTag"; + SyntaxKind[SyntaxKind["JSDocReadonlyTag"] = 330] = "JSDocReadonlyTag"; + SyntaxKind[SyntaxKind["JSDocOverrideTag"] = 331] = "JSDocOverrideTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 332] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocEnumTag"] = 333] = "JSDocEnumTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 334] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 335] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocThisTag"] = 336] = "JSDocThisTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 337] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 338] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 339] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocSeeTag"] = 340] = "JSDocSeeTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 341] = "JSDocPropertyTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 334] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 342] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 335] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 336] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["CommaListExpression"] = 337] = "CommaListExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 338] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 339] = "EndOfDeclarationMarker"; - SyntaxKind[SyntaxKind["SyntheticReferenceExpression"] = 340] = "SyntheticReferenceExpression"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 343] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 344] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 345] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 346] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 347] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["SyntheticReferenceExpression"] = 348] = "SyntheticReferenceExpression"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 341] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 349] = "Count"; // Markers - SyntaxKind[SyntaxKind["FirstAssignment"] = 62] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 77] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 63] = "FirstCompoundAssignment"; - SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 77] = "LastCompoundAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 80] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 115] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 80] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 156] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 116] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 124] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 172] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 195] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 63] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 78] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 64] = "FirstCompoundAssignment"; + SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 78] = "LastCompoundAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 81] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 116] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 81] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 158] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 117] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 125] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 174] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 197] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 18] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 77] = "LastPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 78] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 156] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 158] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; @@ -4104,16 +4218,16 @@ var ts; SyntaxKind[SyntaxKind["FirstTemplateToken"] = 14] = "FirstTemplateToken"; SyntaxKind[SyntaxKind["LastTemplateToken"] = 17] = "LastTemplateToken"; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 29] = "FirstBinaryOperator"; - SyntaxKind[SyntaxKind["LastBinaryOperator"] = 77] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstStatement"] = 232] = "FirstStatement"; - SyntaxKind[SyntaxKind["LastStatement"] = 248] = "LastStatement"; - SyntaxKind[SyntaxKind["FirstNode"] = 157] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 301] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 333] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 314] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 333] = "LastJSDocTagNode"; - /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 125] = "FirstContextualKeyword"; - /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 156] = "LastContextualKeyword"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 78] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstStatement"] = 234] = "FirstStatement"; + SyntaxKind[SyntaxKind["LastStatement"] = 250] = "LastStatement"; + SyntaxKind[SyntaxKind["FirstNode"] = 159] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 303] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 341] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 321] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 341] = "LastJSDocTagNode"; + /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 126] = "FirstContextualKeyword"; + /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 158] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); var NodeFlags; (function (NodeFlags) { @@ -4183,14 +4297,15 @@ var ts; ModifierFlags[ModifierFlags["Const"] = 2048] = "Const"; ModifierFlags[ModifierFlags["HasComputedJSDocModifiers"] = 4096] = "HasComputedJSDocModifiers"; ModifierFlags[ModifierFlags["Deprecated"] = 8192] = "Deprecated"; + ModifierFlags[ModifierFlags["Override"] = 16384] = "Override"; ModifierFlags[ModifierFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; ModifierFlags[ModifierFlags["AccessibilityModifier"] = 28] = "AccessibilityModifier"; // Accessibility modifiers and 'readonly' can be attached to a parameter in a constructor to make it a property. - ModifierFlags[ModifierFlags["ParameterPropertyModifier"] = 92] = "ParameterPropertyModifier"; + ModifierFlags[ModifierFlags["ParameterPropertyModifier"] = 16476] = "ParameterPropertyModifier"; ModifierFlags[ModifierFlags["NonPublicAccessibilityModifier"] = 24] = "NonPublicAccessibilityModifier"; - ModifierFlags[ModifierFlags["TypeScriptModifier"] = 2270] = "TypeScriptModifier"; + ModifierFlags[ModifierFlags["TypeScriptModifier"] = 18654] = "TypeScriptModifier"; ModifierFlags[ModifierFlags["ExportDefault"] = 513] = "ExportDefault"; - ModifierFlags[ModifierFlags["All"] = 11263] = "All"; + ModifierFlags[ModifierFlags["All"] = 27647] = "All"; })(ModifierFlags = ts.ModifierFlags || (ts.ModifierFlags = {})); var JsxFlags; (function (JsxFlags) { @@ -4371,6 +4486,8 @@ var ts; NodeBuilderFlags[NodeBuilderFlags["NoUndefinedOptionalParameterType"] = 1073741824] = "NoUndefinedOptionalParameterType"; // Error handling NodeBuilderFlags[NodeBuilderFlags["AllowThisInObjectLiteral"] = 32768] = "AllowThisInObjectLiteral"; + NodeBuilderFlags[NodeBuilderFlags["AllowQualifiedNameInPlaceOfIdentifier"] = 65536] = "AllowQualifiedNameInPlaceOfIdentifier"; + /** @deprecated AllowQualifedNameInPlaceOfIdentifier. Use AllowQualifiedNameInPlaceOfIdentifier instead. */ NodeBuilderFlags[NodeBuilderFlags["AllowQualifedNameInPlaceOfIdentifier"] = 65536] = "AllowQualifedNameInPlaceOfIdentifier"; NodeBuilderFlags[NodeBuilderFlags["AllowAnonymousIdentifier"] = 131072] = "AllowAnonymousIdentifier"; NodeBuilderFlags[NodeBuilderFlags["AllowEmptyUnionOrIntersection"] = 262144] = "AllowEmptyUnionOrIntersection"; @@ -4385,7 +4502,6 @@ var ts; NodeBuilderFlags[NodeBuilderFlags["InObjectTypeLiteral"] = 4194304] = "InObjectTypeLiteral"; NodeBuilderFlags[NodeBuilderFlags["InTypeAlias"] = 8388608] = "InTypeAlias"; NodeBuilderFlags[NodeBuilderFlags["InInitialEntityName"] = 16777216] = "InInitialEntityName"; - NodeBuilderFlags[NodeBuilderFlags["InReverseMappedType"] = 33554432] = "InReverseMappedType"; })(NodeBuilderFlags = ts.NodeBuilderFlags || (ts.NodeBuilderFlags = {})); // Ensure the shared flags between this and `NodeBuilderFlags` stay in alignment var TypeFormatFlags; @@ -4690,10 +4806,6 @@ var ts; TypeFlags[TypeFlags["Unit"] = 109440] = "Unit"; TypeFlags[TypeFlags["StringOrNumberLiteral"] = 384] = "StringOrNumberLiteral"; /* @internal */ - TypeFlags[TypeFlags["StringLikeLiteral"] = 134217856] = "StringLikeLiteral"; - /* @internal */ - TypeFlags[TypeFlags["FreshableLiteral"] = 134220672] = "FreshableLiteral"; - /* @internal */ TypeFlags[TypeFlags["StringOrNumberLiteralOrUnique"] = 8576] = "StringOrNumberLiteralOrUnique"; /* @internal */ TypeFlags[TypeFlags["DefinitelyFalsy"] = 117632] = "DefinitelyFalsy"; @@ -4742,6 +4854,9 @@ var ts; /* @internal */ TypeFlags[TypeFlags["IncludesEmptyObject"] = 16777216] = "IncludesEmptyObject"; })(TypeFlags = ts.TypeFlags || (ts.TypeFlags = {})); + // Types included in TypeFlags.ObjectFlagsType have an objectFlags property. Some ObjectFlags + // are specific to certain types and reuse the same bit position. Those ObjectFlags require a check + // for a certain TypeFlags value to determine their meaning. var ObjectFlags; (function (ObjectFlags) { ObjectFlags[ObjectFlags["Class"] = 1] = "Class"; @@ -4754,50 +4869,59 @@ var ts; ObjectFlags[ObjectFlags["ObjectLiteral"] = 128] = "ObjectLiteral"; ObjectFlags[ObjectFlags["EvolvingArray"] = 256] = "EvolvingArray"; ObjectFlags[ObjectFlags["ObjectLiteralPatternWithComputedProperties"] = 512] = "ObjectLiteralPatternWithComputedProperties"; - ObjectFlags[ObjectFlags["ContainsSpread"] = 1024] = "ContainsSpread"; - ObjectFlags[ObjectFlags["ReverseMapped"] = 2048] = "ReverseMapped"; - ObjectFlags[ObjectFlags["JsxAttributes"] = 4096] = "JsxAttributes"; - ObjectFlags[ObjectFlags["MarkerType"] = 8192] = "MarkerType"; - ObjectFlags[ObjectFlags["JSLiteral"] = 16384] = "JSLiteral"; - ObjectFlags[ObjectFlags["FreshLiteral"] = 32768] = "FreshLiteral"; - ObjectFlags[ObjectFlags["ArrayLiteral"] = 65536] = "ArrayLiteral"; - ObjectFlags[ObjectFlags["ObjectRestType"] = 131072] = "ObjectRestType"; + ObjectFlags[ObjectFlags["ReverseMapped"] = 1024] = "ReverseMapped"; + ObjectFlags[ObjectFlags["JsxAttributes"] = 2048] = "JsxAttributes"; + ObjectFlags[ObjectFlags["MarkerType"] = 4096] = "MarkerType"; + ObjectFlags[ObjectFlags["JSLiteral"] = 8192] = "JSLiteral"; + ObjectFlags[ObjectFlags["FreshLiteral"] = 16384] = "FreshLiteral"; + ObjectFlags[ObjectFlags["ArrayLiteral"] = 32768] = "ArrayLiteral"; /* @internal */ - ObjectFlags[ObjectFlags["PrimitiveUnion"] = 262144] = "PrimitiveUnion"; + ObjectFlags[ObjectFlags["PrimitiveUnion"] = 65536] = "PrimitiveUnion"; /* @internal */ - ObjectFlags[ObjectFlags["ContainsWideningType"] = 524288] = "ContainsWideningType"; + ObjectFlags[ObjectFlags["ContainsWideningType"] = 131072] = "ContainsWideningType"; /* @internal */ - ObjectFlags[ObjectFlags["ContainsObjectOrArrayLiteral"] = 1048576] = "ContainsObjectOrArrayLiteral"; + ObjectFlags[ObjectFlags["ContainsObjectOrArrayLiteral"] = 262144] = "ContainsObjectOrArrayLiteral"; /* @internal */ - ObjectFlags[ObjectFlags["NonInferrableType"] = 2097152] = "NonInferrableType"; + ObjectFlags[ObjectFlags["NonInferrableType"] = 524288] = "NonInferrableType"; /* @internal */ - ObjectFlags[ObjectFlags["IsGenericObjectTypeComputed"] = 4194304] = "IsGenericObjectTypeComputed"; + ObjectFlags[ObjectFlags["CouldContainTypeVariablesComputed"] = 1048576] = "CouldContainTypeVariablesComputed"; /* @internal */ - ObjectFlags[ObjectFlags["IsGenericObjectType"] = 8388608] = "IsGenericObjectType"; + ObjectFlags[ObjectFlags["CouldContainTypeVariables"] = 2097152] = "CouldContainTypeVariables"; + ObjectFlags[ObjectFlags["ClassOrInterface"] = 3] = "ClassOrInterface"; /* @internal */ - ObjectFlags[ObjectFlags["IsGenericIndexTypeComputed"] = 16777216] = "IsGenericIndexTypeComputed"; + ObjectFlags[ObjectFlags["RequiresWidening"] = 393216] = "RequiresWidening"; /* @internal */ - ObjectFlags[ObjectFlags["IsGenericIndexType"] = 33554432] = "IsGenericIndexType"; + ObjectFlags[ObjectFlags["PropagatingFlags"] = 917504] = "PropagatingFlags"; + // Object flags that uniquely identify the kind of ObjectType /* @internal */ - ObjectFlags[ObjectFlags["CouldContainTypeVariablesComputed"] = 67108864] = "CouldContainTypeVariablesComputed"; + ObjectFlags[ObjectFlags["ObjectTypeKindMask"] = 1343] = "ObjectTypeKindMask"; + // Flags that require TypeFlags.Object + ObjectFlags[ObjectFlags["ContainsSpread"] = 4194304] = "ContainsSpread"; + ObjectFlags[ObjectFlags["ObjectRestType"] = 8388608] = "ObjectRestType"; /* @internal */ - ObjectFlags[ObjectFlags["CouldContainTypeVariables"] = 134217728] = "CouldContainTypeVariables"; + ObjectFlags[ObjectFlags["IsClassInstanceClone"] = 16777216] = "IsClassInstanceClone"; + // Flags that require TypeFlags.Object and ObjectFlags.Reference /* @internal */ - ObjectFlags[ObjectFlags["ContainsIntersections"] = 268435456] = "ContainsIntersections"; + ObjectFlags[ObjectFlags["IdenticalBaseTypeCalculated"] = 33554432] = "IdenticalBaseTypeCalculated"; /* @internal */ - ObjectFlags[ObjectFlags["IsNeverIntersectionComputed"] = 268435456] = "IsNeverIntersectionComputed"; + ObjectFlags[ObjectFlags["IdenticalBaseTypeExists"] = 67108864] = "IdenticalBaseTypeExists"; + // Flags that require TypeFlags.UnionOrIntersection or TypeFlags.Substitution /* @internal */ - ObjectFlags[ObjectFlags["IsNeverIntersection"] = 536870912] = "IsNeverIntersection"; + ObjectFlags[ObjectFlags["IsGenericObjectTypeComputed"] = 4194304] = "IsGenericObjectTypeComputed"; /* @internal */ - ObjectFlags[ObjectFlags["IsClassInstanceClone"] = 1073741824] = "IsClassInstanceClone"; - ObjectFlags[ObjectFlags["ClassOrInterface"] = 3] = "ClassOrInterface"; + ObjectFlags[ObjectFlags["IsGenericObjectType"] = 8388608] = "IsGenericObjectType"; /* @internal */ - ObjectFlags[ObjectFlags["RequiresWidening"] = 1572864] = "RequiresWidening"; + ObjectFlags[ObjectFlags["IsGenericIndexTypeComputed"] = 16777216] = "IsGenericIndexTypeComputed"; /* @internal */ - ObjectFlags[ObjectFlags["PropagatingFlags"] = 3670016] = "PropagatingFlags"; - // Object flags that uniquely identify the kind of ObjectType + ObjectFlags[ObjectFlags["IsGenericIndexType"] = 33554432] = "IsGenericIndexType"; + // Flags that require TypeFlags.Union /* @internal */ - ObjectFlags[ObjectFlags["ObjectTypeKindMask"] = 2367] = "ObjectTypeKindMask"; + ObjectFlags[ObjectFlags["ContainsIntersections"] = 67108864] = "ContainsIntersections"; + // Flags that require TypeFlags.Intersection + /* @internal */ + ObjectFlags[ObjectFlags["IsNeverIntersectionComputed"] = 67108864] = "IsNeverIntersectionComputed"; + /* @internal */ + ObjectFlags[ObjectFlags["IsNeverIntersection"] = 134217728] = "IsNeverIntersection"; })(ObjectFlags = ts.ObjectFlags || (ts.ObjectFlags = {})); /* @internal */ var VarianceFlags; @@ -4824,6 +4948,21 @@ var ts; ElementFlags[ElementFlags["NonRest"] = 11] = "NonRest"; })(ElementFlags = ts.ElementFlags || (ts.ElementFlags = {})); /* @internal */ + var AccessFlags; + (function (AccessFlags) { + AccessFlags[AccessFlags["None"] = 0] = "None"; + AccessFlags[AccessFlags["IncludeUndefined"] = 1] = "IncludeUndefined"; + AccessFlags[AccessFlags["NoIndexSignatures"] = 2] = "NoIndexSignatures"; + AccessFlags[AccessFlags["Writing"] = 4] = "Writing"; + AccessFlags[AccessFlags["CacheSymbol"] = 8] = "CacheSymbol"; + AccessFlags[AccessFlags["NoTupleBoundsCheck"] = 16] = "NoTupleBoundsCheck"; + AccessFlags[AccessFlags["ExpressionPosition"] = 32] = "ExpressionPosition"; + AccessFlags[AccessFlags["ReportDeprecated"] = 64] = "ReportDeprecated"; + AccessFlags[AccessFlags["SuppressNoImplicitAnyError"] = 128] = "SuppressNoImplicitAnyError"; + AccessFlags[AccessFlags["Contextual"] = 256] = "Contextual"; + AccessFlags[AccessFlags["Persistent"] = 1] = "Persistent"; + })(AccessFlags = ts.AccessFlags || (ts.AccessFlags = {})); + /* @internal */ var JsxReferenceKind; (function (JsxReferenceKind) { JsxReferenceKind[JsxReferenceKind["Component"] = 0] = "Component"; @@ -4871,16 +5010,17 @@ var ts; (function (InferencePriority) { InferencePriority[InferencePriority["NakedTypeVariable"] = 1] = "NakedTypeVariable"; InferencePriority[InferencePriority["SpeculativeTuple"] = 2] = "SpeculativeTuple"; - InferencePriority[InferencePriority["HomomorphicMappedType"] = 4] = "HomomorphicMappedType"; - InferencePriority[InferencePriority["PartialHomomorphicMappedType"] = 8] = "PartialHomomorphicMappedType"; - InferencePriority[InferencePriority["MappedTypeConstraint"] = 16] = "MappedTypeConstraint"; - InferencePriority[InferencePriority["ContravariantConditional"] = 32] = "ContravariantConditional"; - InferencePriority[InferencePriority["ReturnType"] = 64] = "ReturnType"; - InferencePriority[InferencePriority["LiteralKeyof"] = 128] = "LiteralKeyof"; - InferencePriority[InferencePriority["NoConstraints"] = 256] = "NoConstraints"; - InferencePriority[InferencePriority["AlwaysStrict"] = 512] = "AlwaysStrict"; - InferencePriority[InferencePriority["MaxValue"] = 1024] = "MaxValue"; - InferencePriority[InferencePriority["PriorityImpliesCombination"] = 208] = "PriorityImpliesCombination"; + InferencePriority[InferencePriority["SubstituteSource"] = 4] = "SubstituteSource"; + InferencePriority[InferencePriority["HomomorphicMappedType"] = 8] = "HomomorphicMappedType"; + InferencePriority[InferencePriority["PartialHomomorphicMappedType"] = 16] = "PartialHomomorphicMappedType"; + InferencePriority[InferencePriority["MappedTypeConstraint"] = 32] = "MappedTypeConstraint"; + InferencePriority[InferencePriority["ContravariantConditional"] = 64] = "ContravariantConditional"; + InferencePriority[InferencePriority["ReturnType"] = 128] = "ReturnType"; + InferencePriority[InferencePriority["LiteralKeyof"] = 256] = "LiteralKeyof"; + InferencePriority[InferencePriority["NoConstraints"] = 512] = "NoConstraints"; + InferencePriority[InferencePriority["AlwaysStrict"] = 1024] = "AlwaysStrict"; + InferencePriority[InferencePriority["MaxValue"] = 2048] = "MaxValue"; + InferencePriority[InferencePriority["PriorityImpliesCombination"] = 416] = "PriorityImpliesCombination"; InferencePriority[InferencePriority["Circularity"] = -1] = "Circularity"; })(InferencePriority = ts.InferencePriority || (ts.InferencePriority = {})); /* @internal */ @@ -4958,20 +5098,23 @@ var ts; WatchFileKind[WatchFileKind["FixedPollingInterval"] = 0] = "FixedPollingInterval"; WatchFileKind[WatchFileKind["PriorityPollingInterval"] = 1] = "PriorityPollingInterval"; WatchFileKind[WatchFileKind["DynamicPriorityPolling"] = 2] = "DynamicPriorityPolling"; - WatchFileKind[WatchFileKind["UseFsEvents"] = 3] = "UseFsEvents"; - WatchFileKind[WatchFileKind["UseFsEventsOnParentDirectory"] = 4] = "UseFsEventsOnParentDirectory"; + WatchFileKind[WatchFileKind["FixedChunkSizePolling"] = 3] = "FixedChunkSizePolling"; + WatchFileKind[WatchFileKind["UseFsEvents"] = 4] = "UseFsEvents"; + WatchFileKind[WatchFileKind["UseFsEventsOnParentDirectory"] = 5] = "UseFsEventsOnParentDirectory"; })(WatchFileKind = ts.WatchFileKind || (ts.WatchFileKind = {})); var WatchDirectoryKind; (function (WatchDirectoryKind) { WatchDirectoryKind[WatchDirectoryKind["UseFsEvents"] = 0] = "UseFsEvents"; WatchDirectoryKind[WatchDirectoryKind["FixedPollingInterval"] = 1] = "FixedPollingInterval"; WatchDirectoryKind[WatchDirectoryKind["DynamicPriorityPolling"] = 2] = "DynamicPriorityPolling"; + WatchDirectoryKind[WatchDirectoryKind["FixedChunkSizePolling"] = 3] = "FixedChunkSizePolling"; })(WatchDirectoryKind = ts.WatchDirectoryKind || (ts.WatchDirectoryKind = {})); var PollingWatchKind; (function (PollingWatchKind) { PollingWatchKind[PollingWatchKind["FixedInterval"] = 0] = "FixedInterval"; PollingWatchKind[PollingWatchKind["PriorityInterval"] = 1] = "PriorityInterval"; PollingWatchKind[PollingWatchKind["DynamicPriority"] = 2] = "DynamicPriority"; + PollingWatchKind[PollingWatchKind["FixedChunkSize"] = 3] = "FixedChunkSize"; })(PollingWatchKind = ts.PollingWatchKind || (ts.PollingWatchKind = {})); var ModuleKind; (function (ModuleKind) { @@ -5032,6 +5175,7 @@ var ts; ScriptTarget[ScriptTarget["ES2018"] = 5] = "ES2018"; ScriptTarget[ScriptTarget["ES2019"] = 6] = "ES2019"; ScriptTarget[ScriptTarget["ES2020"] = 7] = "ES2020"; + ScriptTarget[ScriptTarget["ES2021"] = 8] = "ES2021"; ScriptTarget[ScriptTarget["ESNext"] = 99] = "ESNext"; ScriptTarget[ScriptTarget["JSON"] = 100] = "JSON"; ScriptTarget[ScriptTarget["Latest"] = 99] = "Latest"; @@ -5194,29 +5338,30 @@ var ts; TransformFlags[TransformFlags["ContainsTypeScript"] = 1] = "ContainsTypeScript"; TransformFlags[TransformFlags["ContainsJsx"] = 2] = "ContainsJsx"; TransformFlags[TransformFlags["ContainsESNext"] = 4] = "ContainsESNext"; - TransformFlags[TransformFlags["ContainsES2020"] = 8] = "ContainsES2020"; - TransformFlags[TransformFlags["ContainsES2019"] = 16] = "ContainsES2019"; - TransformFlags[TransformFlags["ContainsES2018"] = 32] = "ContainsES2018"; - TransformFlags[TransformFlags["ContainsES2017"] = 64] = "ContainsES2017"; - TransformFlags[TransformFlags["ContainsES2016"] = 128] = "ContainsES2016"; - TransformFlags[TransformFlags["ContainsES2015"] = 256] = "ContainsES2015"; - TransformFlags[TransformFlags["ContainsGenerator"] = 512] = "ContainsGenerator"; - TransformFlags[TransformFlags["ContainsDestructuringAssignment"] = 1024] = "ContainsDestructuringAssignment"; + TransformFlags[TransformFlags["ContainsES2021"] = 8] = "ContainsES2021"; + TransformFlags[TransformFlags["ContainsES2020"] = 16] = "ContainsES2020"; + TransformFlags[TransformFlags["ContainsES2019"] = 32] = "ContainsES2019"; + TransformFlags[TransformFlags["ContainsES2018"] = 64] = "ContainsES2018"; + TransformFlags[TransformFlags["ContainsES2017"] = 128] = "ContainsES2017"; + TransformFlags[TransformFlags["ContainsES2016"] = 256] = "ContainsES2016"; + TransformFlags[TransformFlags["ContainsES2015"] = 512] = "ContainsES2015"; + TransformFlags[TransformFlags["ContainsGenerator"] = 1024] = "ContainsGenerator"; + TransformFlags[TransformFlags["ContainsDestructuringAssignment"] = 2048] = "ContainsDestructuringAssignment"; // Markers // - Flags used to indicate that a subtree contains a specific transformation. - TransformFlags[TransformFlags["ContainsTypeScriptClassSyntax"] = 2048] = "ContainsTypeScriptClassSyntax"; - TransformFlags[TransformFlags["ContainsLexicalThis"] = 4096] = "ContainsLexicalThis"; - TransformFlags[TransformFlags["ContainsRestOrSpread"] = 8192] = "ContainsRestOrSpread"; - TransformFlags[TransformFlags["ContainsObjectRestOrSpread"] = 16384] = "ContainsObjectRestOrSpread"; - TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 32768] = "ContainsComputedPropertyName"; - TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 65536] = "ContainsBlockScopedBinding"; - TransformFlags[TransformFlags["ContainsBindingPattern"] = 131072] = "ContainsBindingPattern"; - TransformFlags[TransformFlags["ContainsYield"] = 262144] = "ContainsYield"; - TransformFlags[TransformFlags["ContainsAwait"] = 524288] = "ContainsAwait"; - TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 1048576] = "ContainsHoistedDeclarationOrCompletion"; - TransformFlags[TransformFlags["ContainsDynamicImport"] = 2097152] = "ContainsDynamicImport"; - TransformFlags[TransformFlags["ContainsClassFields"] = 4194304] = "ContainsClassFields"; - TransformFlags[TransformFlags["ContainsPossibleTopLevelAwait"] = 8388608] = "ContainsPossibleTopLevelAwait"; + TransformFlags[TransformFlags["ContainsTypeScriptClassSyntax"] = 4096] = "ContainsTypeScriptClassSyntax"; + TransformFlags[TransformFlags["ContainsLexicalThis"] = 8192] = "ContainsLexicalThis"; + TransformFlags[TransformFlags["ContainsRestOrSpread"] = 16384] = "ContainsRestOrSpread"; + TransformFlags[TransformFlags["ContainsObjectRestOrSpread"] = 32768] = "ContainsObjectRestOrSpread"; + TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 65536] = "ContainsComputedPropertyName"; + TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 131072] = "ContainsBlockScopedBinding"; + TransformFlags[TransformFlags["ContainsBindingPattern"] = 262144] = "ContainsBindingPattern"; + TransformFlags[TransformFlags["ContainsYield"] = 524288] = "ContainsYield"; + TransformFlags[TransformFlags["ContainsAwait"] = 1048576] = "ContainsAwait"; + TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 2097152] = "ContainsHoistedDeclarationOrCompletion"; + TransformFlags[TransformFlags["ContainsDynamicImport"] = 4194304] = "ContainsDynamicImport"; + TransformFlags[TransformFlags["ContainsClassFields"] = 8388608] = "ContainsClassFields"; + TransformFlags[TransformFlags["ContainsPossibleTopLevelAwait"] = 16777216] = "ContainsPossibleTopLevelAwait"; // 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 @@ -5226,37 +5371,38 @@ var ts; TransformFlags[TransformFlags["AssertTypeScript"] = 1] = "AssertTypeScript"; TransformFlags[TransformFlags["AssertJsx"] = 2] = "AssertJsx"; TransformFlags[TransformFlags["AssertESNext"] = 4] = "AssertESNext"; - TransformFlags[TransformFlags["AssertES2020"] = 8] = "AssertES2020"; - TransformFlags[TransformFlags["AssertES2019"] = 16] = "AssertES2019"; - TransformFlags[TransformFlags["AssertES2018"] = 32] = "AssertES2018"; - TransformFlags[TransformFlags["AssertES2017"] = 64] = "AssertES2017"; - TransformFlags[TransformFlags["AssertES2016"] = 128] = "AssertES2016"; - TransformFlags[TransformFlags["AssertES2015"] = 256] = "AssertES2015"; - TransformFlags[TransformFlags["AssertGenerator"] = 512] = "AssertGenerator"; - TransformFlags[TransformFlags["AssertDestructuringAssignment"] = 1024] = "AssertDestructuringAssignment"; + TransformFlags[TransformFlags["AssertES2021"] = 8] = "AssertES2021"; + TransformFlags[TransformFlags["AssertES2020"] = 16] = "AssertES2020"; + TransformFlags[TransformFlags["AssertES2019"] = 32] = "AssertES2019"; + TransformFlags[TransformFlags["AssertES2018"] = 64] = "AssertES2018"; + TransformFlags[TransformFlags["AssertES2017"] = 128] = "AssertES2017"; + TransformFlags[TransformFlags["AssertES2016"] = 256] = "AssertES2016"; + TransformFlags[TransformFlags["AssertES2015"] = 512] = "AssertES2015"; + TransformFlags[TransformFlags["AssertGenerator"] = 1024] = "AssertGenerator"; + TransformFlags[TransformFlags["AssertDestructuringAssignment"] = 2048] = "AssertDestructuringAssignment"; // 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"] = 547309568] = "ArrowFunctionExcludes"; - TransformFlags[TransformFlags["FunctionExcludes"] = 547313664] = "FunctionExcludes"; - TransformFlags[TransformFlags["ConstructorExcludes"] = 547311616] = "ConstructorExcludes"; - TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 538923008] = "MethodOrAccessorExcludes"; - TransformFlags[TransformFlags["PropertyExcludes"] = 536875008] = "PropertyExcludes"; - TransformFlags[TransformFlags["ClassExcludes"] = 536905728] = "ClassExcludes"; - TransformFlags[TransformFlags["ModuleExcludes"] = 546379776] = "ModuleExcludes"; + TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 557748224] = "ArrowFunctionExcludes"; + TransformFlags[TransformFlags["FunctionExcludes"] = 557756416] = "FunctionExcludes"; + TransformFlags[TransformFlags["ConstructorExcludes"] = 557752320] = "ConstructorExcludes"; + TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 540975104] = "MethodOrAccessorExcludes"; + TransformFlags[TransformFlags["PropertyExcludes"] = 536879104] = "PropertyExcludes"; + TransformFlags[TransformFlags["ClassExcludes"] = 536940544] = "ClassExcludes"; + TransformFlags[TransformFlags["ModuleExcludes"] = 555888640] = "ModuleExcludes"; TransformFlags[TransformFlags["TypeExcludes"] = -2] = "TypeExcludes"; - TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 536922112] = "ObjectLiteralExcludes"; - TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 536879104] = "ArrayLiteralOrCallOrNewExcludes"; - TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 537018368] = "VariableDeclarationListExcludes"; + TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 536973312] = "ObjectLiteralExcludes"; + TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 536887296] = "ArrayLiteralOrCallOrNewExcludes"; + TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 537165824] = "VariableDeclarationListExcludes"; TransformFlags[TransformFlags["ParameterExcludes"] = 536870912] = "ParameterExcludes"; - TransformFlags[TransformFlags["CatchClauseExcludes"] = 536887296] = "CatchClauseExcludes"; - TransformFlags[TransformFlags["BindingPatternExcludes"] = 536879104] = "BindingPatternExcludes"; + TransformFlags[TransformFlags["CatchClauseExcludes"] = 536903680] = "CatchClauseExcludes"; + TransformFlags[TransformFlags["BindingPatternExcludes"] = 536887296] = "BindingPatternExcludes"; // Propagating flags // - Bitmasks for flags that should propagate from a child - TransformFlags[TransformFlags["PropertyNamePropagatingFlags"] = 4096] = "PropertyNamePropagatingFlags"; + TransformFlags[TransformFlags["PropertyNamePropagatingFlags"] = 8192] = "PropertyNamePropagatingFlags"; // Masks // - Additional bitmasks })(TransformFlags = ts.TransformFlags || (ts.TransformFlags = {})); @@ -5854,6 +6000,11 @@ var ts; * Normalize path separators, converting `\` into `/`. */ function normalizeSlashes(path) { + var index = path.indexOf("\\"); + if (index === -1) { + return path; + } + backslashRegExp.lastIndex = index; // prime regex with known position return path.replace(backslashRegExp, ts.directorySeparator); } ts.normalizeSlashes = normalizeSlashes; @@ -5964,6 +6115,19 @@ var ts; ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath; function normalizePath(path) { path = normalizeSlashes(path); + // Most paths don't require normalization + if (!relativePathSegmentRegExp.test(path)) { + return path; + } + // Some paths only require cleanup of `/./` or leading `./` + var simplified = path.replace(/\/\.\//g, "/").replace(/^\.\//, ""); + if (simplified !== path) { + path = simplified; + if (!relativePathSegmentRegExp.test(path)) { + return path; + } + } + // Other paths require full normalization var normalized = getPathFromPathComponents(reducePathComponents(getPathComponents(path))); return normalized && hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalized) : normalized; } @@ -6032,7 +6196,7 @@ var ts; ts.changeAnyExtension = changeAnyExtension; //// Path Comparisons // check path for these segments: '', '.'. '..' - var relativePathSegmentRegExp = /(^|\/)\.{0,2}($|\/)/; + var relativePathSegmentRegExp = /(?:\/\/)|(?:^|\/)\.\.?(?:$|\/)/; function comparePathsWorker(a, b, componentComparer) { if (a === b) return 0 /* EqualTo */; @@ -6124,7 +6288,7 @@ var ts; * Determines whether `fileName` starts with the specified `directoryName` using the provided path canonicalization callback. * Comparison is case-sensitive between the canonical paths. * - * @deprecated Use `containsPath` if possible. + * Use `containsPath` if file names are not already reduced and absolute. */ function startsWithDirectory(fileName, directoryName, getCanonicalFileName) { var canonicalFileName = getCanonicalFileName(fileName); @@ -6244,6 +6408,11 @@ var ts; })(PollingInterval = ts.PollingInterval || (ts.PollingInterval = {})); /* @internal */ ts.missingFileModifiedTime = new Date(0); // Any subsequent modification will occur after this time + /* @internal */ + function getModifiedTime(host, fileName) { + return host.getModifiedTime(fileName) || ts.missingFileModifiedTime; + } + ts.getModifiedTime = getModifiedTime; function createPollingIntervalBasedLevels(levels) { var _a; return _a = {}, @@ -6300,6 +6469,51 @@ var ts; } } ts.setCustomPollingValues = setCustomPollingValues; + function pollWatchedFileQueue(host, queue, pollIndex, chunkSize, callbackOnWatchFileStat) { + var definedValueCopyToIndex = pollIndex; + // Max visit would be all elements of the queue + for (var canVisit = queue.length; chunkSize && canVisit; nextPollIndex(), canVisit--) { + var watchedFile = queue[pollIndex]; + if (!watchedFile) { + continue; + } + else if (watchedFile.isClosed) { + queue[pollIndex] = undefined; + continue; + } + // Only files polled count towards chunkSize + chunkSize--; + var fileChanged = onWatchedFileStat(watchedFile, getModifiedTime(host, watchedFile.fileName)); + if (watchedFile.isClosed) { + // Closed watcher as part of callback + queue[pollIndex] = undefined; + continue; + } + callbackOnWatchFileStat === null || callbackOnWatchFileStat === void 0 ? void 0 : callbackOnWatchFileStat(watchedFile, pollIndex, fileChanged); + // Defragment the queue while we are at it + if (queue[pollIndex]) { + // Copy this file to the non hole location + if (definedValueCopyToIndex < pollIndex) { + queue[definedValueCopyToIndex] = watchedFile; + queue[pollIndex] = undefined; + } + definedValueCopyToIndex++; + } + } + // Return next poll index + return pollIndex; + function nextPollIndex() { + pollIndex++; + if (pollIndex === queue.length) { + if (definedValueCopyToIndex < pollIndex) { + // There are holes from definedValueCopyToIndex to end of queue, change queue size + queue.length = definedValueCopyToIndex; + } + pollIndex = 0; + definedValueCopyToIndex = 0; + } + } + } /* @internal */ function createDynamicPriorityPollingWatchFile(host) { var watchedFiles = []; @@ -6313,7 +6527,7 @@ var ts; fileName: fileName, callback: callback, unchangedPolls: 0, - mtime: getModifiedTime(fileName) + mtime: getModifiedTime(host, fileName) }; watchedFiles.push(file); addToPollingIntervalQueue(file, defaultPollingInterval); @@ -6356,25 +6570,9 @@ var ts; } } function pollQueue(queue, pollingInterval, pollIndex, chunkSize) { - // Max visit would be all elements of the queue - var needsVisit = queue.length; - var definedValueCopyToIndex = pollIndex; - for (var polled = 0; polled < chunkSize && needsVisit > 0; nextPollIndex(), needsVisit--) { - var watchedFile = queue[pollIndex]; - if (!watchedFile) { - continue; - } - else if (watchedFile.isClosed) { - queue[pollIndex] = undefined; - continue; - } - polled++; - var fileChanged = onWatchedFileStat(watchedFile, getModifiedTime(watchedFile.fileName)); - if (watchedFile.isClosed) { - // Closed watcher as part of callback - queue[pollIndex] = undefined; - } - else if (fileChanged) { + return pollWatchedFileQueue(host, queue, pollIndex, chunkSize, onWatchFileStat); + function onWatchFileStat(watchedFile, pollIndex, fileChanged) { + if (fileChanged) { watchedFile.unchangedPolls = 0; // Changed files go to changedFilesInLastPoll queue if (queue !== changedFilesInLastPoll) { @@ -6396,27 +6594,6 @@ var ts; queue[pollIndex] = undefined; addToPollingIntervalQueue(watchedFile, pollingInterval === PollingInterval.Low ? PollingInterval.Medium : PollingInterval.High); } - if (queue[pollIndex]) { - // Copy this file to the non hole location - if (definedValueCopyToIndex < pollIndex) { - queue[definedValueCopyToIndex] = watchedFile; - queue[pollIndex] = undefined; - } - definedValueCopyToIndex++; - } - } - // Return next poll index - return pollIndex; - function nextPollIndex() { - pollIndex++; - if (pollIndex === queue.length) { - if (definedValueCopyToIndex < pollIndex) { - // There are holes from nextDefinedValueIndex to end of queue, change queue size - queue.length = definedValueCopyToIndex; - } - pollIndex = 0; - definedValueCopyToIndex = 0; - } } } function pollingIntervalQueue(pollingInterval) { @@ -6445,9 +6622,6 @@ var ts; function scheduleNextPoll(pollingInterval) { pollingIntervalQueue(pollingInterval).pollScheduled = host.setTimeout(pollingInterval === PollingInterval.Low ? pollLowPollingIntervalQueue : pollPollingIntervalQueue, pollingInterval, pollingIntervalQueue(pollingInterval)); } - function getModifiedTime(fileName) { - return host.getModifiedTime(fileName) || ts.missingFileModifiedTime; - } } ts.createDynamicPriorityPollingWatchFile = createDynamicPriorityPollingWatchFile; function createUseFsEventsOnParentDirectoryWatchFile(fsWatch, useCaseSensitiveFileNames) { @@ -6498,6 +6672,37 @@ var ts; return watcher; } } + function createFixedChunkSizePollingWatchFile(host) { + var watchedFiles = []; + var pollIndex = 0; + var pollScheduled; + return watchFile; + function watchFile(fileName, callback) { + var file = { + fileName: fileName, + callback: callback, + mtime: getModifiedTime(host, fileName) + }; + watchedFiles.push(file); + scheduleNextPoll(); + return { + close: function () { + file.isClosed = true; + ts.unorderedRemoveItem(watchedFiles, file); + } + }; + } + function pollQueue() { + pollScheduled = undefined; + pollIndex = pollWatchedFileQueue(host, watchedFiles, pollIndex, pollingChunkSize[PollingInterval.Low]); + scheduleNextPoll(); + } + function scheduleNextPoll() { + if (!watchedFiles.length || pollScheduled) + return; + pollScheduled = host.setTimeout(pollQueue, PollingInterval.High); + } + } /* @internal */ function createSingleFileWatcherPerName(watchFile, useCaseSensitiveFileNames) { var cache = new ts.Map(); @@ -6820,8 +7025,9 @@ var ts; } /*@internal*/ function createSystemWatchFunctions(_a) { - var pollingWatchFile = _a.pollingWatchFile, getModifiedTime = _a.getModifiedTime, setTimeout = _a.setTimeout, clearTimeout = _a.clearTimeout, fsWatch = _a.fsWatch, fileExists = _a.fileExists, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, getCurrentDirectory = _a.getCurrentDirectory, fsSupportsRecursiveFsWatch = _a.fsSupportsRecursiveFsWatch, directoryExists = _a.directoryExists, getAccessibleSortedChildDirectories = _a.getAccessibleSortedChildDirectories, realpath = _a.realpath, tscWatchFile = _a.tscWatchFile, useNonPollingWatchers = _a.useNonPollingWatchers, tscWatchDirectory = _a.tscWatchDirectory; + var pollingWatchFile = _a.pollingWatchFile, getModifiedTime = _a.getModifiedTime, setTimeout = _a.setTimeout, clearTimeout = _a.clearTimeout, fsWatch = _a.fsWatch, fileExists = _a.fileExists, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, getCurrentDirectory = _a.getCurrentDirectory, fsSupportsRecursiveFsWatch = _a.fsSupportsRecursiveFsWatch, directoryExists = _a.directoryExists, getAccessibleSortedChildDirectories = _a.getAccessibleSortedChildDirectories, realpath = _a.realpath, tscWatchFile = _a.tscWatchFile, useNonPollingWatchers = _a.useNonPollingWatchers, tscWatchDirectory = _a.tscWatchDirectory, defaultWatchFileKind = _a.defaultWatchFileKind; var dynamicPollingWatchFile; + var fixedChunkSizePollingWatchFile; var nonPollingWatchFile; var hostRecursiveDirectoryWatcher; return { @@ -6838,6 +7044,8 @@ var ts; return pollingWatchFile(fileName, callback, pollingInterval, /*options*/ undefined); case ts.WatchFileKind.DynamicPriorityPolling: return ensureDynamicPollingWatchFile()(fileName, callback, pollingInterval, /*options*/ undefined); + case ts.WatchFileKind.FixedChunkSizePolling: + return ensureFixedChunkSizePollingWatchFile()(fileName, callback, /* pollingInterval */ undefined, /*options*/ undefined); case ts.WatchFileKind.UseFsEvents: return fsWatch(fileName, 0 /* File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists), /*recursive*/ false, pollingInterval, ts.getFallbackOptions(options)); @@ -6851,8 +7059,10 @@ var ts; } } function ensureDynamicPollingWatchFile() { - return dynamicPollingWatchFile || - (dynamicPollingWatchFile = createDynamicPriorityPollingWatchFile({ getModifiedTime: getModifiedTime, setTimeout: setTimeout })); + return dynamicPollingWatchFile || (dynamicPollingWatchFile = createDynamicPriorityPollingWatchFile({ getModifiedTime: getModifiedTime, setTimeout: setTimeout })); + } + function ensureFixedChunkSizePollingWatchFile() { + return fixedChunkSizePollingWatchFile || (fixedChunkSizePollingWatchFile = createFixedChunkSizePollingWatchFile({ getModifiedTime: getModifiedTime, setTimeout: setTimeout })); } function updateOptionsForWatchFile(options, useNonPollingWatchers) { if (options && options.watchFile !== undefined) @@ -6878,7 +7088,7 @@ var ts; // Use notifications from FS to watch with falling back to fs.watchFile generateWatchFileOptions(ts.WatchFileKind.UseFsEventsOnParentDirectory, ts.PollingWatchKind.PriorityInterval, options) : // Default to do not use fixed polling interval - { watchFile: ts.WatchFileKind.FixedPollingInterval }; + { watchFile: (defaultWatchFileKind === null || defaultWatchFileKind === void 0 ? void 0 : defaultWatchFileKind()) || ts.WatchFileKind.FixedPollingInterval }; } } function generateWatchFileOptions(watchFile, fallbackPolling, options) { @@ -6919,6 +7129,10 @@ var ts; case ts.WatchDirectoryKind.DynamicPriorityPolling: return ensureDynamicPollingWatchFile()(directoryName, function () { return callback(directoryName); }, PollingInterval.Medium, /*options*/ undefined); + case ts.WatchDirectoryKind.FixedChunkSizePolling: + return ensureFixedChunkSizePollingWatchFile()(directoryName, function () { return callback(directoryName); }, + /* 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)); default: @@ -6997,13 +7211,13 @@ var ts; } var activeSession; var profilePath = "./profile.cpuprofile"; - var realpathSync = (_a = _fs.realpathSync.native) !== null && _a !== void 0 ? _a : _fs.realpathSync; var Buffer = require("buffer").Buffer; var nodeVersion = getNodeMajorVersion(); var isNode4OrLater = nodeVersion >= 4; var isLinuxOrMacOs = process.platform === "linux" || process.platform === "darwin"; var platform = _os.platform(); var useCaseSensitiveFileNames = isFileSystemCaseSensitive(); + var realpathSync = useCaseSensitiveFileNames ? ((_a = _fs.realpathSync.native) !== null && _a !== void 0 ? _a : _fs.realpathSync) : _fs.realpathSync; var fsSupportsRecursiveFsWatch = isNode4OrLater && (process.platform === "win32" || process.platform === "darwin"); var getCurrentDirectory = ts.memoize(function () { return process.cwd(); }); var _c = createSystemWatchFunctions({ @@ -7024,6 +7238,7 @@ var ts; tscWatchFile: process.env.TSC_WATCHFILE, useNonPollingWatchers: process.env.TSC_NONPOLLING_WATCHER, tscWatchDirectory: process.env.TSC_WATCHDIRECTORY, + defaultWatchFileKind: function () { var _a, _b; return (_b = (_a = sys).defaultWatchFileKind) === null || _b === void 0 ? void 0 : _b.call(_a); }, }), watchFile = _c.watchFile, watchDirectory = _c.watchDirectory; var nodeSystem = { args: process.argv.slice(2), @@ -7092,6 +7307,7 @@ var ts; }, enableCPUProfiler: enableCPUProfiler, disableCPUProfiler: disableCPUProfiler, + cpuProfilingEnabled: function () { return !!activeSession || ts.contains(process.execArgv, "--cpu-prof") || ts.contains(process.execArgv, "--prof"); }, realpath: realpath, debugMode: !!process.env.NODE_INSPECTOR_IPC || !!process.env.VSCODE_INSPECTOR_OPTIONS || ts.some(process.execArgv, function (arg) { return /^--(inspect|debug)(-brk)?(=\d+)?$/i.test(arg); }), tryEnableSourceMapsForHost: function () { @@ -7341,7 +7557,7 @@ var ts; return event === "rename" && (!relativeName || relativeName === lastDirectoryPart || - relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length) && + (relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) !== -1 && relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length)) && !fileSystemEntryExists(fileOrDirectory, entryKind) ? invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry) : callback(event, relativeName); @@ -7651,9 +7867,10 @@ var ts; Invalid_use_of_0_in_strict_mode: diag(1100, ts.DiagnosticCategory.Error, "Invalid_use_of_0_in_strict_mode_1100", "Invalid use of '{0}' in strict mode."), with_statements_are_not_allowed_in_strict_mode: diag(1101, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_strict_mode_1101", "'with' statements are not allowed in strict mode."), delete_cannot_be_called_on_an_identifier_in_strict_mode: diag(1102, ts.DiagnosticCategory.Error, "delete_cannot_be_called_on_an_identifier_in_strict_mode_1102", "'delete' cannot be called on an identifier in strict mode."), - A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator: diag(1103, ts.DiagnosticCategory.Error, "A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator_1103", "A 'for-await-of' statement is only allowed within an async function or async generator."), + for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1103, ts.DiagnosticCategory.Error, "for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1103", "'for await' loops are only allowed within async functions and at the top levels of modules."), A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: diag(1104, ts.DiagnosticCategory.Error, "A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement_1104", "A 'continue' statement can only be used within an enclosing iteration statement."), A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: diag(1105, ts.DiagnosticCategory.Error, "A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement_1105", "A 'break' statement can only be used within an enclosing iteration or switch statement."), + The_left_hand_side_of_a_for_of_statement_may_not_be_async: diag(1106, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_of_statement_may_not_be_async_1106", "The left-hand side of a 'for...of' statement may not be 'async'."), Jump_target_cannot_cross_function_boundary: diag(1107, ts.DiagnosticCategory.Error, "Jump_target_cannot_cross_function_boundary_1107", "Jump target cannot cross function boundary."), A_return_statement_can_only_be_used_within_a_function_body: diag(1108, ts.DiagnosticCategory.Error, "A_return_statement_can_only_be_used_within_a_function_body_1108", "A 'return' statement can only be used within a function body."), Expression_expected: diag(1109, ts.DiagnosticCategory.Error, "Expression_expected_1109", "Expression expected."), @@ -7700,7 +7917,7 @@ var ts; A_yield_expression_is_only_allowed_in_a_generator_body: diag(1163, ts.DiagnosticCategory.Error, "A_yield_expression_is_only_allowed_in_a_generator_body_1163", "A 'yield' expression is only allowed in a generator body."), Computed_property_names_are_not_allowed_in_enums: diag(1164, ts.DiagnosticCategory.Error, "Computed_property_names_are_not_allowed_in_enums_1164", "Computed property names are not allowed in enums."), A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1165, ts.DiagnosticCategory.Error, "A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_t_1165", "A computed property name in an ambient context must refer to an expression whose type is a literal type or a 'unique symbol' type."), - A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1166, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_1166", "A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type."), + A_computed_property_name_in_a_class_property_declaration_must_have_a_simple_literal_type_or_a_unique_symbol_type: diag(1166, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_class_property_declaration_must_have_a_simple_literal_type_or_a_unique_1166", "A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type."), A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1168, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_ty_1168", "A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type."), A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1169, ts.DiagnosticCategory.Error, "A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_1169", "A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type."), A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1170, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type__1170", "A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type."), @@ -7760,7 +7977,7 @@ var ts; A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: diag(1228, ts.DiagnosticCategory.Error, "A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods_1228", "A type predicate is only allowed in return type position for functions and methods."), A_type_predicate_cannot_reference_a_rest_parameter: diag(1229, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_a_rest_parameter_1229", "A type predicate cannot reference a rest parameter."), A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: diag(1230, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_element_0_in_a_binding_pattern_1230", "A type predicate cannot reference element '{0}' in a binding pattern."), - An_export_assignment_can_only_be_used_in_a_module: diag(1231, ts.DiagnosticCategory.Error, "An_export_assignment_can_only_be_used_in_a_module_1231", "An export assignment can only be used in a module."), + An_export_assignment_must_be_at_the_top_level_of_a_file_or_module_declaration: diag(1231, ts.DiagnosticCategory.Error, "An_export_assignment_must_be_at_the_top_level_of_a_file_or_module_declaration_1231", "An export assignment must be at the top level of a file or module declaration."), An_import_declaration_can_only_be_used_in_a_namespace_or_module: diag(1232, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_in_a_namespace_or_module_1232", "An import declaration can only be used in a namespace or module."), An_export_declaration_can_only_be_used_in_a_module: diag(1233, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_in_a_module_1233", "An export declaration can only be used in a module."), An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: diag(1234, ts.DiagnosticCategory.Error, "An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file_1234", "An ambient module declaration is only allowed at the top level in a file."), @@ -7786,6 +8003,7 @@ var ts; A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_reference: diag(1254, ts.DiagnosticCategory.Error, "A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_refere_1254", "A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference."), A_definite_assignment_assertion_is_not_permitted_in_this_context: diag(1255, ts.DiagnosticCategory.Error, "A_definite_assignment_assertion_is_not_permitted_in_this_context_1255", "A definite assignment assertion '!' is not permitted in this context."), A_required_element_cannot_follow_an_optional_element: diag(1257, ts.DiagnosticCategory.Error, "A_required_element_cannot_follow_an_optional_element_1257", "A required element cannot follow an optional element."), + A_default_export_must_be_at_the_top_level_of_a_file_or_module_declaration: diag(1258, ts.DiagnosticCategory.Error, "A_default_export_must_be_at_the_top_level_of_a_file_or_module_declaration_1258", "A default export must be at the top level of a file or module declaration."), Module_0_can_only_be_default_imported_using_the_1_flag: diag(1259, ts.DiagnosticCategory.Error, "Module_0_can_only_be_default_imported_using_the_1_flag_1259", "Module '{0}' can only be default-imported using the '{1}' flag"), Keywords_cannot_contain_escape_characters: diag(1260, ts.DiagnosticCategory.Error, "Keywords_cannot_contain_escape_characters_1260", "Keywords cannot contain escape characters."), Already_included_file_name_0_differs_from_file_name_1_only_in_casing: diag(1261, ts.DiagnosticCategory.Error, "Already_included_file_name_0_differs_from_file_name_1_only_in_casing_1261", "Already included file name '{0}' differs from file name '{1}' only in casing."), @@ -7794,6 +8012,7 @@ var ts; Declarations_with_definite_assignment_assertions_must_also_have_type_annotations: diag(1264, ts.DiagnosticCategory.Error, "Declarations_with_definite_assignment_assertions_must_also_have_type_annotations_1264", "Declarations with definite assignment assertions must also have type annotations."), A_rest_element_cannot_follow_another_rest_element: diag(1265, ts.DiagnosticCategory.Error, "A_rest_element_cannot_follow_another_rest_element_1265", "A rest element cannot follow another rest element."), An_optional_element_cannot_follow_a_rest_element: diag(1266, ts.DiagnosticCategory.Error, "An_optional_element_cannot_follow_a_rest_element_1266", "An optional element cannot follow a rest element."), + Property_0_cannot_have_an_initializer_because_it_is_marked_abstract: diag(1267, ts.DiagnosticCategory.Error, "Property_0_cannot_have_an_initializer_because_it_is_marked_abstract_1267", "Property '{0}' cannot have an initializer because it is marked abstract."), with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1308, ts.DiagnosticCategory.Error, "await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1308", "'await' expressions are only allowed within async functions and at the top levels of modules."), 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: diag(1312, ts.DiagnosticCategory.Error, "Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_1312", "Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern."), @@ -7872,7 +8091,7 @@ var ts; Constructor_type_notation_must_be_parenthesized_when_used_in_an_intersection_type: diag(1388, ts.DiagnosticCategory.Error, "Constructor_type_notation_must_be_parenthesized_when_used_in_an_intersection_type_1388", "Constructor type notation must be parenthesized when used in an intersection type."), _0_is_not_allowed_as_a_variable_declaration_name: diag(1389, ts.DiagnosticCategory.Error, "_0_is_not_allowed_as_a_variable_declaration_name_1389", "'{0}' is not allowed as a variable declaration name."), Provides_a_root_package_name_when_using_outFile_with_declarations: diag(1390, ts.DiagnosticCategory.Message, "Provides_a_root_package_name_when_using_outFile_with_declarations_1390", "Provides a root package name when using outFile with declarations."), - The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_declaration_emit: diag(1391, ts.DiagnosticCategory.Error, "The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_de_1391", "The `bundledPackageName` option must be provided when using outFile and node module resolution with declaration emit."), + The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_declaration_emit: diag(1391, ts.DiagnosticCategory.Error, "The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_de_1391", "The 'bundledPackageName' option must be provided when using outFile and node module resolution with declaration emit."), An_import_alias_cannot_use_import_type: diag(1392, ts.DiagnosticCategory.Error, "An_import_alias_cannot_use_import_type_1392", "An import alias cannot use 'import type'"), Imported_via_0_from_file_1: diag(1393, ts.DiagnosticCategory.Message, "Imported_via_0_from_file_1_1393", "Imported via {0} from file '{1}'"), Imported_via_0_from_file_1_with_packageId_2: diag(1394, ts.DiagnosticCategory.Message, "Imported_via_0_from_file_1_with_packageId_2_1394", "Imported via {0} from file '{1}' with packageId '{2}'"), @@ -7912,6 +8131,9 @@ var ts; File_is_output_of_project_reference_source_0: diag(1428, ts.DiagnosticCategory.Message, "File_is_output_of_project_reference_source_0_1428", "File is output of project reference source '{0}'"), File_redirects_to_file_0: diag(1429, ts.DiagnosticCategory.Message, "File_redirects_to_file_0_1429", "File redirects to file '{0}'"), The_file_is_in_the_program_because_Colon: diag(1430, ts.DiagnosticCategory.Message, "The_file_is_in_the_program_because_Colon_1430", "The file is in the program because:"), + for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module: diag(1431, ts.DiagnosticCategory.Error, "for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_1431", "'for await' loops are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module."), + Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher: diag(1432, ts.DiagnosticCategory.Error, "Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_1432", "Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher."), + Decorators_may_not_be_applied_to_this_parameters: diag(1433, ts.DiagnosticCategory.Error, "Decorators_may_not_be_applied_to_this_parameters_1433", "Decorators may not be applied to 'this' parameters."), 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), @@ -7979,7 +8201,7 @@ var ts; The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2358, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter."), The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: diag(2359, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type."), The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: diag(2360, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol_2360", "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'."), - The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2361, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter_2361", "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter."), + The_right_hand_side_of_an_in_expression_must_not_be_a_primitive: diag(2361, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_in_expression_must_not_be_a_primitive_2361", "The right-hand side of an 'in' expression must not be a primitive."), The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2362, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2362", "The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."), The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2363, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2363", "The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."), The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: diag(2364, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", "The left-hand side of an assignment expression must be a variable or a property access."), @@ -7997,8 +8219,7 @@ var ts; A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_parameter_properties_or_private_identifiers: diag(2376, ts.DiagnosticCategory.Error, "A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_proper_2376", "A 'super' call must be the first statement in the constructor when a class contains initialized properties, parameter properties, or private identifiers."), Constructors_for_derived_classes_must_contain_a_super_call: diag(2377, ts.DiagnosticCategory.Error, "Constructors_for_derived_classes_must_contain_a_super_call_2377", "Constructors for derived classes must contain a 'super' call."), A_get_accessor_must_return_a_value: diag(2378, ts.DiagnosticCategory.Error, "A_get_accessor_must_return_a_value_2378", "A 'get' accessor must return a value."), - Getter_and_setter_accessors_do_not_agree_in_visibility: diag(2379, ts.DiagnosticCategory.Error, "Getter_and_setter_accessors_do_not_agree_in_visibility_2379", "Getter and setter accessors do not agree in visibility."), - get_and_set_accessor_must_have_the_same_type: diag(2380, ts.DiagnosticCategory.Error, "get_and_set_accessor_must_have_the_same_type_2380", "'get' and 'set' accessor must have the same type."), + The_return_type_of_a_get_accessor_must_be_assignable_to_its_set_accessor_type: diag(2380, ts.DiagnosticCategory.Error, "The_return_type_of_a_get_accessor_must_be_assignable_to_its_set_accessor_type_2380", "The return type of a 'get' accessor must be assignable to its 'set' accessor type"), A_signature_with_an_implementation_cannot_use_a_string_literal_type: diag(2381, ts.DiagnosticCategory.Error, "A_signature_with_an_implementation_cannot_use_a_string_literal_type_2381", "A signature with an implementation cannot use a string literal type."), Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: diag(2382, ts.DiagnosticCategory.Error, "Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature_2382", "Specialized overload signature is not assignable to any non-specialized signature."), Overload_signatures_must_all_be_exported_or_non_exported: diag(2383, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_exported_or_non_exported_2383", "Overload signatures must all be exported or non-exported."), @@ -8061,7 +8282,7 @@ var ts; Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2: diag(2443, ts.DiagnosticCategory.Error, "Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2_2443", "Property '{0}' is protected but type '{1}' is not a class derived from '{2}'."), Property_0_is_protected_in_type_1_but_public_in_type_2: diag(2444, ts.DiagnosticCategory.Error, "Property_0_is_protected_in_type_1_but_public_in_type_2_2444", "Property '{0}' is protected in type '{1}' but public in type '{2}'."), Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses: diag(2445, ts.DiagnosticCategory.Error, "Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses_2445", "Property '{0}' is protected and only accessible within class '{1}' and its subclasses."), - Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: diag(2446, ts.DiagnosticCategory.Error, "Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_2446", "Property '{0}' is protected and only accessible through an instance of class '{1}'."), + Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_This_is_an_instance_of_class_2: diag(2446, ts.DiagnosticCategory.Error, "Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_This_is_an_instance_of_cl_2446", "Property '{0}' is protected and only accessible through an instance of class '{1}'. This is an instance of class '{2}'."), The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: diag(2447, ts.DiagnosticCategory.Error, "The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead_2447", "The '{0}' operator is not allowed for boolean types. Consider using '{1}' instead."), Block_scoped_variable_0_used_before_its_declaration: diag(2448, ts.DiagnosticCategory.Error, "Block_scoped_variable_0_used_before_its_declaration_2448", "Block-scoped variable '{0}' used before its declaration."), Class_0_used_before_its_declaration: diag(2449, ts.DiagnosticCategory.Error, "Class_0_used_before_its_declaration_2449", "Class '{0}' used before its declaration."), @@ -8161,14 +8382,13 @@ var ts; The_type_returned_by_the_0_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_property: diag(2547, ts.DiagnosticCategory.Error, "The_type_returned_by_the_0_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_pro_2547", "The type returned by the '{0}()' method of an async iterator must be a promise for a type with a 'value' property."), Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator: diag(2548, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator_2548", "Type '{0}' is not an array type or does not have a '[Symbol.iterator]()' method that returns an iterator."), Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator: diag(2549, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns__2549", "Type '{0}' is not an array type or a string type or does not have a '[Symbol.iterator]()' method that returns an iterator."), - Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2_or_later: diag(2550, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_c_2550", "Property '{0}' does not exist on type '{1}'. Do you need to change your target library? Try changing the `lib` compiler option to '{2}' or later."), + Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2_or_later: diag(2550, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_c_2550", "Property '{0}' does not exist on type '{1}'. Do you need to change your target library? Try changing the 'lib' compiler option to '{2}' or later."), Property_0_does_not_exist_on_type_1_Did_you_mean_2: diag(2551, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Did_you_mean_2_2551", "Property '{0}' does not exist on type '{1}'. Did you mean '{2}'?"), Cannot_find_name_0_Did_you_mean_1: diag(2552, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Did_you_mean_1_2552", "Cannot find name '{0}'. Did you mean '{1}'?"), Computed_values_are_not_permitted_in_an_enum_with_string_valued_members: diag(2553, ts.DiagnosticCategory.Error, "Computed_values_are_not_permitted_in_an_enum_with_string_valued_members_2553", "Computed values are not permitted in an enum with string valued members."), Expected_0_arguments_but_got_1: diag(2554, ts.DiagnosticCategory.Error, "Expected_0_arguments_but_got_1_2554", "Expected {0} arguments, but got {1}."), Expected_at_least_0_arguments_but_got_1: diag(2555, ts.DiagnosticCategory.Error, "Expected_at_least_0_arguments_but_got_1_2555", "Expected at least {0} arguments, but got {1}."), - Expected_0_arguments_but_got_1_or_more: diag(2556, ts.DiagnosticCategory.Error, "Expected_0_arguments_but_got_1_or_more_2556", "Expected {0} arguments, but got {1} or more."), - Expected_at_least_0_arguments_but_got_1_or_more: diag(2557, ts.DiagnosticCategory.Error, "Expected_at_least_0_arguments_but_got_1_or_more_2557", "Expected at least {0} arguments, but got {1} or more."), + A_spread_argument_must_either_have_a_tuple_type_or_be_passed_to_a_rest_parameter: diag(2556, ts.DiagnosticCategory.Error, "A_spread_argument_must_either_have_a_tuple_type_or_be_passed_to_a_rest_parameter_2556", "A spread argument must either have a tuple type or be passed to a rest parameter."), Expected_0_type_arguments_but_got_1: diag(2558, ts.DiagnosticCategory.Error, "Expected_0_type_arguments_but_got_1_2558", "Expected {0} type arguments, but got {1}."), Type_0_has_no_properties_in_common_with_type_1: diag(2559, ts.DiagnosticCategory.Error, "Type_0_has_no_properties_in_common_with_type_1_2559", "Type '{0}' has no properties in common with type '{1}'."), Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it: diag(2560, ts.DiagnosticCategory.Error, "Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it_2560", "Value of type '{0}' has no properties in common with type '{1}'. Did you mean to call it?"), @@ -8191,17 +8411,17 @@ var ts; Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode: diag(2580, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashno_2580", "Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`."), Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery: diag(2581, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slash_2581", "Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i --save-dev @types/jquery`."), Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_types_Slashjest_or_npm_i_save_dev_types_Slashmocha: diag(2582, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_type_2582", "Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`."), - Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_1_or_later: diag(2583, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2583", "Cannot find name '{0}'. Do you need to change your target library? Try changing the `lib` compiler option to '{1}' or later."), - Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_include_dom: diag(2584, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2584", "Cannot find name '{0}'. Do you need to change your target library? Try changing the `lib` compiler option to include 'dom'."), - _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: diag(2585, ts.DiagnosticCategory.Error, "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_2585", "'{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."), + Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_1_or_later: diag(2583, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2583", "Cannot find name '{0}'. Do you need to change your target library? Try changing the 'lib' compiler option to '{1}' or later."), + Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_include_dom: diag(2584, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2584", "Cannot find name '{0}'. Do you need to change your target library? Try changing the 'lib' compiler option to include 'dom'."), + _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: diag(2585, ts.DiagnosticCategory.Error, "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_2585", "'{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."), Enum_type_0_circularly_references_itself: diag(2586, ts.DiagnosticCategory.Error, "Enum_type_0_circularly_references_itself_2586", "Enum type '{0}' circularly references itself."), JSDoc_type_0_circularly_references_itself: diag(2587, ts.DiagnosticCategory.Error, "JSDoc_type_0_circularly_references_itself_2587", "JSDoc type '{0}' circularly references itself."), Cannot_assign_to_0_because_it_is_a_constant: diag(2588, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_a_constant_2588", "Cannot assign to '{0}' because it is a constant."), Type_instantiation_is_excessively_deep_and_possibly_infinite: diag(2589, ts.DiagnosticCategory.Error, "Type_instantiation_is_excessively_deep_and_possibly_infinite_2589", "Type instantiation is excessively deep and possibly infinite."), Expression_produces_a_union_type_that_is_too_complex_to_represent: diag(2590, ts.DiagnosticCategory.Error, "Expression_produces_a_union_type_that_is_too_complex_to_represent_2590", "Expression produces a union type that is too complex to represent."), - Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode_and_then_add_node_to_the_types_field_in_your_tsconfig: diag(2591, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashno_2591", "Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node` and then add `node` to the types field in your tsconfig."), - Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery_and_then_add_jquery_to_the_types_field_in_your_tsconfig: diag(2592, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slash_2592", "Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i --save-dev @types/jquery` and then add `jquery` to the types field in your tsconfig."), - Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_types_Slashjest_or_npm_i_save_dev_types_Slashmocha_and_then_add_jest_or_mocha_to_the_types_field_in_your_tsconfig: diag(2593, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_type_2593", "Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode_and_then_add_node_to_the_types_field_in_your_tsconfig: diag(2591, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashno_2591", "Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node` and then add 'node' to the types field in your tsconfig."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery_and_then_add_jquery_to_the_types_field_in_your_tsconfig: diag(2592, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slash_2592", "Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i --save-dev @types/jquery` and then add 'jquery' to the types field in your tsconfig."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_types_Slashjest_or_npm_i_save_dev_types_Slashmocha_and_then_add_jest_or_mocha_to_the_types_field_in_your_tsconfig: diag(2593, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_type_2593", "Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig."), This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag: diag(2594, ts.DiagnosticCategory.Error, "This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the__2594", "This module is declared with using 'export =', and can only be used with a default import when using the '{0}' flag."), _0_can_only_be_imported_by_using_a_default_import: diag(2595, ts.DiagnosticCategory.Error, "_0_can_only_be_imported_by_using_a_default_import_2595", "'{0}' can only be imported by using a default import."), _0_can_only_be_imported_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import: diag(2596, ts.DiagnosticCategory.Error, "_0_can_only_be_imported_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import_2596", "'{0}' can only be imported by turning on the 'esModuleInterop' flag and using a default import."), @@ -8234,6 +8454,12 @@ var ts; Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target: diag(2625, ts.DiagnosticCategory.Error, "Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target_2625", "Variadic element at position {0} in source does not match element at position {1} in target."), Type_at_position_0_in_source_is_not_compatible_with_type_at_position_1_in_target: diag(2626, ts.DiagnosticCategory.Error, "Type_at_position_0_in_source_is_not_compatible_with_type_at_position_1_in_target_2626", "Type at position {0} in source is not compatible with type at position {1} in target."), Type_at_positions_0_through_1_in_source_is_not_compatible_with_type_at_position_2_in_target: diag(2627, ts.DiagnosticCategory.Error, "Type_at_positions_0_through_1_in_source_is_not_compatible_with_type_at_position_2_in_target_2627", "Type at positions {0} through {1} in source is not compatible with type at position {2} in target."), + Cannot_assign_to_0_because_it_is_an_enum: diag(2628, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_an_enum_2628", "Cannot assign to '{0}' because it is an enum."), + Cannot_assign_to_0_because_it_is_a_class: diag(2629, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_a_class_2629", "Cannot assign to '{0}' because it is a class."), + Cannot_assign_to_0_because_it_is_a_function: diag(2630, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_a_function_2630", "Cannot assign to '{0}' because it is a function."), + Cannot_assign_to_0_because_it_is_a_namespace: diag(2631, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_a_namespace_2631", "Cannot assign to '{0}' because it is a namespace."), + Cannot_assign_to_0_because_it_is_an_import: diag(2632, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_an_import_2632", "Cannot assign to '{0}' because it is an import."), + JSX_property_access_expressions_cannot_include_JSX_namespace_names: diag(2633, ts.DiagnosticCategory.Error, "JSX_property_access_expressions_cannot_include_JSX_namespace_names_2633", "JSX property access expressions cannot include JSX namespace names"), Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: diag(2649, ts.DiagnosticCategory.Error, "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", "Cannot augment module '{0}' with value exports because it resolves to a non-module entity."), A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: diag(2651, ts.DiagnosticCategory.Error, "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums."), Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: diag(2652, ts.DiagnosticCategory.Error, "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead."), @@ -8280,7 +8506,7 @@ var ts; Namespace_0_has_no_exported_member_1: diag(2694, ts.DiagnosticCategory.Error, "Namespace_0_has_no_exported_member_1_2694", "Namespace '{0}' has no exported member '{1}'."), Left_side_of_comma_operator_is_unused_and_has_no_side_effects: diag(2695, ts.DiagnosticCategory.Error, "Left_side_of_comma_operator_is_unused_and_has_no_side_effects_2695", "Left side of comma operator is unused and has no side effects.", /*reportsUnnecessary*/ true), The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead: diag(2696, ts.DiagnosticCategory.Error, "The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead_2696", "The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?"), - An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: diag(2697, ts.DiagnosticCategory.Error, "An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_in_2697", "An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option."), + An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: diag(2697, ts.DiagnosticCategory.Error, "An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_in_2697", "An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your '--lib' option."), Spread_types_may_only_be_created_from_object_types: diag(2698, ts.DiagnosticCategory.Error, "Spread_types_may_only_be_created_from_object_types_2698", "Spread types may only be created from object types."), Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1: diag(2699, ts.DiagnosticCategory.Error, "Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1_2699", "Static property '{0}' conflicts with built-in property 'Function.{0}' of constructor function '{1}'."), Rest_types_may_only_be_created_from_object_types: diag(2700, ts.DiagnosticCategory.Error, "Rest_types_may_only_be_created_from_object_types_2700", "Rest types may only be created from object types."), @@ -8288,14 +8514,14 @@ var ts; _0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here: diag(2702, ts.DiagnosticCategory.Error, "_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here_2702", "'{0}' only refers to a type, but is being used as a namespace here."), The_operand_of_a_delete_operator_must_be_a_property_reference: diag(2703, ts.DiagnosticCategory.Error, "The_operand_of_a_delete_operator_must_be_a_property_reference_2703", "The operand of a 'delete' operator must be a property reference."), The_operand_of_a_delete_operator_cannot_be_a_read_only_property: diag(2704, ts.DiagnosticCategory.Error, "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704", "The operand of a 'delete' operator cannot be a read-only property."), - 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: diag(2705, ts.DiagnosticCategory.Error, "An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_de_2705", "An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option."), + 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: diag(2705, ts.DiagnosticCategory.Error, "An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_de_2705", "An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option."), Required_type_parameters_may_not_follow_optional_type_parameters: diag(2706, ts.DiagnosticCategory.Error, "Required_type_parameters_may_not_follow_optional_type_parameters_2706", "Required type parameters may not follow optional type parameters."), Generic_type_0_requires_between_1_and_2_type_arguments: diag(2707, ts.DiagnosticCategory.Error, "Generic_type_0_requires_between_1_and_2_type_arguments_2707", "Generic type '{0}' requires between {1} and {2} type arguments."), Cannot_use_namespace_0_as_a_value: diag(2708, ts.DiagnosticCategory.Error, "Cannot_use_namespace_0_as_a_value_2708", "Cannot use namespace '{0}' as a value."), Cannot_use_namespace_0_as_a_type: diag(2709, ts.DiagnosticCategory.Error, "Cannot_use_namespace_0_as_a_type_2709", "Cannot use namespace '{0}' as a type."), _0_are_specified_twice_The_attribute_named_0_will_be_overwritten: diag(2710, ts.DiagnosticCategory.Error, "_0_are_specified_twice_The_attribute_named_0_will_be_overwritten_2710", "'{0}' are specified twice. The attribute named '{0}' will be overwritten."), - A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: diag(2711, ts.DiagnosticCategory.Error, "A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES20_2711", "A dynamic import call returns a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option."), - A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option: diag(2712, ts.DiagnosticCategory.Error, "A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declarat_2712", "A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option."), + A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: diag(2711, ts.DiagnosticCategory.Error, "A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES20_2711", "A dynamic import call returns a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your '--lib' option."), + A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option: diag(2712, ts.DiagnosticCategory.Error, "A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declarat_2712", "A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option."), 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: diag(2713, ts.DiagnosticCategory.Error, "Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_p_2713", "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}\"]'?"), The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context: diag(2714, ts.DiagnosticCategory.Error, "The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context_2714", "The expression of an export assignment must be an identifier or qualified name in an ambient context."), Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor: diag(2715, ts.DiagnosticCategory.Error, "Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor_2715", "Abstract property '{0}' in class '{1}' cannot be accessed in the constructor."), @@ -8357,7 +8583,7 @@ var ts; The_last_overload_is_declared_here: diag(2771, ts.DiagnosticCategory.Error, "The_last_overload_is_declared_here_2771", "The last overload is declared here."), Overload_0_of_1_2_gave_the_following_error: diag(2772, ts.DiagnosticCategory.Error, "Overload_0_of_1_2_gave_the_following_error_2772", "Overload {0} of {1}, '{2}', gave the following error."), Did_you_forget_to_use_await: diag(2773, ts.DiagnosticCategory.Error, "Did_you_forget_to_use_await_2773", "Did you forget to use 'await'?"), - This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead: diag(2774, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it__2774", "This condition will always return true since the function is always defined. Did you mean to call it instead?"), + This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_instead: diag(2774, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_2774", "This condition will always return true since this function is always defined. Did you mean to call it instead?"), Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation: diag(2775, ts.DiagnosticCategory.Error, "Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation_2775", "Assertions require every name in the call target to be declared with an explicit type annotation."), Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name: diag(2776, ts.DiagnosticCategory.Error, "Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name_2776", "Assertions require the call target to be an identifier or qualified name."), The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access: diag(2777, ts.DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access_2777", "The operand of an increment or decrement operator may not be an optional property access."), @@ -8381,6 +8607,23 @@ var ts; The_intrinsic_keyword_can_only_be_used_to_declare_compiler_provided_intrinsic_types: diag(2795, ts.DiagnosticCategory.Error, "The_intrinsic_keyword_can_only_be_used_to_declare_compiler_provided_intrinsic_types_2795", "The 'intrinsic' keyword can only be used to declare compiler provided intrinsic types."), It_is_likely_that_you_are_missing_a_comma_to_separate_these_two_template_expressions_They_form_a_tagged_template_expression_which_cannot_be_invoked: diag(2796, ts.DiagnosticCategory.Error, "It_is_likely_that_you_are_missing_a_comma_to_separate_these_two_template_expressions_They_form_a_tag_2796", "It is likely that you are missing a comma to separate these two template expressions. They form a tagged template expression which cannot be invoked."), A_mixin_class_that_extends_from_a_type_variable_containing_an_abstract_construct_signature_must_also_be_declared_abstract: diag(2797, ts.DiagnosticCategory.Error, "A_mixin_class_that_extends_from_a_type_variable_containing_an_abstract_construct_signature_must_also_2797", "A mixin class that extends from a type variable containing an abstract construct signature must also be declared 'abstract'."), + The_declaration_was_marked_as_deprecated_here: diag(2798, ts.DiagnosticCategory.Error, "The_declaration_was_marked_as_deprecated_here_2798", "The declaration was marked as deprecated here."), + Type_produces_a_tuple_type_that_is_too_large_to_represent: diag(2799, ts.DiagnosticCategory.Error, "Type_produces_a_tuple_type_that_is_too_large_to_represent_2799", "Type produces a tuple type that is too large to represent."), + Expression_produces_a_tuple_type_that_is_too_large_to_represent: diag(2800, ts.DiagnosticCategory.Error, "Expression_produces_a_tuple_type_that_is_too_large_to_represent_2800", "Expression produces a tuple type that is too large to represent."), + This_condition_will_always_return_true_since_this_0_is_always_defined: diag(2801, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_this_0_is_always_defined_2801", "This condition will always return true since this '{0}' is always defined."), + Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher: diag(2802, ts.DiagnosticCategory.Error, "Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es201_2802", "Type '{0}' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher."), + Cannot_assign_to_private_method_0_Private_methods_are_not_writable: diag(2803, ts.DiagnosticCategory.Error, "Cannot_assign_to_private_method_0_Private_methods_are_not_writable_2803", "Cannot assign to private method '{0}'. Private methods are not writable."), + Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name: diag(2804, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name_2804", "Duplicate identifier '{0}'. Static and instance elements cannot share the same private name."), + Static_fields_with_private_names_can_t_have_initializers_when_the_useDefineForClassFields_flag_is_not_specified_with_a_target_of_esnext_Consider_adding_the_useDefineForClassFields_flag: diag(2805, ts.DiagnosticCategory.Error, "Static_fields_with_private_names_can_t_have_initializers_when_the_useDefineForClassFields_flag_is_no_2805", "Static fields with private names can't have initializers when the '--useDefineForClassFields' flag is not specified with a '--target' of 'esnext'. Consider adding the '--useDefineForClassFields' flag."), + Private_accessor_was_defined_without_a_getter: diag(2806, ts.DiagnosticCategory.Error, "Private_accessor_was_defined_without_a_getter_2806", "Private accessor was defined without a getter."), + 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: diag(2807, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807", "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}'."), + A_get_accessor_must_be_at_least_as_accessible_as_the_setter: diag(2808, ts.DiagnosticCategory.Error, "A_get_accessor_must_be_at_least_as_accessible_as_the_setter_2808", "A get accessor must be at least as accessible as the setter"), + 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: diag(2809, ts.DiagnosticCategory.Error, "Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_d_2809", "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."), + Property_0_may_not_be_used_in_a_static_property_s_initializer_in_the_same_class_when_target_is_esnext_and_useDefineForClassFields_is_false: diag(2810, ts.DiagnosticCategory.Error, "Property_0_may_not_be_used_in_a_static_property_s_initializer_in_the_same_class_when_target_is_esnex_2810", "Property '{0}' may not be used in a static property's initializer in the same class when 'target' is 'esnext' and 'useDefineForClassFields' is 'false'."), + Initializer_for_property_0: diag(2811, ts.DiagnosticCategory.Error, "Initializer_for_property_0_2811", "Initializer for property '{0}'"), + Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom: diag(2812, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom_2812", "Property '{0}' does not exist on type '{1}'. Try changing the 'lib' compiler option to include 'dom'."), + Class_declaration_cannot_implement_overload_list_for_0: diag(2813, ts.DiagnosticCategory.Error, "Class_declaration_cannot_implement_overload_list_for_0_2813", "Class declaration cannot implement overload list for '{0}'."), + Function_with_bodies_can_only_merge_with_classes_that_are_ambient: diag(2814, ts.DiagnosticCategory.Error, "Function_with_bodies_can_only_merge_with_classes_that_are_ambient_2814", "Function with bodies can only merge with classes that are ambient."), 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}'."), @@ -8453,6 +8696,7 @@ var ts; Exported_type_alias_0_has_or_is_using_private_name_1: diag(4081, ts.DiagnosticCategory.Error, "Exported_type_alias_0_has_or_is_using_private_name_1_4081", "Exported type alias '{0}' has or is using private name '{1}'."), Default_export_of_the_module_has_or_is_using_private_name_0: diag(4082, ts.DiagnosticCategory.Error, "Default_export_of_the_module_has_or_is_using_private_name_0_4082", "Default export of the module has or is using private name '{0}'."), Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1: diag(4083, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1_4083", "Type parameter '{0}' of exported type alias has or is using private name '{1}'."), + Exported_type_alias_0_has_or_is_using_private_name_1_from_module_2: diag(4084, ts.DiagnosticCategory.Error, "Exported_type_alias_0_has_or_is_using_private_name_1_from_module_2_4084", "Exported type alias '{0}' has or is using private name '{1}' from module {2}."), Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict: diag(4090, ts.DiagnosticCategory.Error, "Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_librar_4090", "Conflicting definitions for '{0}' found at '{1}' and '{2}'. Consider installing a specific version of this library to resolve the conflict."), Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: diag(4091, ts.DiagnosticCategory.Error, "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4091", "Parameter '{0}' of index signature from exported interface has or is using name '{1}' from private module '{2}'."), Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1: diag(4092, ts.DiagnosticCategory.Error, "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1_4092", "Parameter '{0}' of index signature from exported interface has or is using private name '{1}'."), @@ -8474,6 +8718,12 @@ var ts; Type_arguments_for_0_circularly_reference_themselves: diag(4109, ts.DiagnosticCategory.Error, "Type_arguments_for_0_circularly_reference_themselves_4109", "Type arguments for '{0}' circularly reference themselves."), Tuple_type_arguments_circularly_reference_themselves: diag(4110, ts.DiagnosticCategory.Error, "Tuple_type_arguments_circularly_reference_themselves_4110", "Tuple type arguments circularly reference themselves."), Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0: diag(4111, ts.DiagnosticCategory.Error, "Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0_4111", "Property '{0}' comes from an index signature, so it must be accessed with ['{0}']."), + This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class: diag(4112, ts.DiagnosticCategory.Error, "This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another__4112", "This member cannot have an 'override' modifier because its containing class '{0}' does not extend another class."), + This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0: diag(4113, ts.DiagnosticCategory.Error, "This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0_4113", "This member cannot have an 'override' modifier because it is not declared in the base class '{0}'."), + This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0: diag(4114, ts.DiagnosticCategory.Error, "This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0_4114", "This member must have an 'override' modifier because it overrides a member in the base class '{0}'."), + This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0: diag(4115, ts.DiagnosticCategory.Error, "This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0_4115", "This parameter property must have an 'override' modifier because it overrides a member in base class '{0}'."), + This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0: diag(4116, ts.DiagnosticCategory.Error, "This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared__4116", "This member must have an 'override' modifier because it overrides an abstract method that is declared in the base class '{0}'."), + This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1: diag(4117, ts.DiagnosticCategory.Error, "This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0_Did_you__4117", "This member cannot have an 'override' modifier because it is not declared in the base class '{0}'. Did you mean '{1}'?"), The_current_host_does_not_support_the_0_option: diag(5001, ts.DiagnosticCategory.Error, "The_current_host_does_not_support_the_0_option_5001", "The current host does not support the '{0}' option."), Cannot_find_the_common_subdirectory_path_for_the_input_files: diag(5009, ts.DiagnosticCategory.Error, "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", "Cannot find the common subdirectory path for the input files."), File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5010, ts.DiagnosticCategory.Error, "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", "File specification cannot end in a recursive directory wildcard ('**'): '{0}'."), @@ -8508,7 +8758,7 @@ var ts; Option_resolveJsonModule_can_only_be_specified_when_module_code_generation_is_commonjs_amd_es2015_or_esNext: diag(5071, ts.DiagnosticCategory.Error, "Option_resolveJsonModule_can_only_be_specified_when_module_code_generation_is_commonjs_amd_es2015_or_5071", "Option '--resolveJsonModule' can only be specified when module code generation is 'commonjs', 'amd', 'es2015' or 'esNext'."), Unknown_build_option_0: diag(5072, ts.DiagnosticCategory.Error, "Unknown_build_option_0_5072", "Unknown build option '{0}'."), Build_option_0_requires_a_value_of_type_1: diag(5073, ts.DiagnosticCategory.Error, "Build_option_0_requires_a_value_of_type_1_5073", "Build option '{0}' requires a value of type {1}."), - Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified: diag(5074, ts.DiagnosticCategory.Error, "Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBui_5074", "Option '--incremental' can only be specified using tsconfig, emitting to single file or when option `--tsBuildInfoFile` is specified."), + Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified: diag(5074, ts.DiagnosticCategory.Error, "Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBui_5074", "Option '--incremental' can only be specified using tsconfig, emitting to single file or when option '--tsBuildInfoFile' is specified."), _0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2: diag(5075, ts.DiagnosticCategory.Error, "_0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_5075", "'{0}' is assignable to the constraint of type '{1}', but '{1}' could be instantiated with a different subtype of constraint '{2}'."), _0_and_1_operations_cannot_be_mixed_without_parentheses: diag(5076, ts.DiagnosticCategory.Error, "_0_and_1_operations_cannot_be_mixed_without_parentheses_5076", "'{0}' and '{1}' operations cannot be mixed without parentheses."), Unknown_build_option_0_Did_you_mean_1: diag(5077, ts.DiagnosticCategory.Error, "Unknown_build_option_0_Did_you_mean_1_5077", "Unknown build option '{0}'. Did you mean '{1}'?"), @@ -8521,10 +8771,14 @@ var ts; Tuple_members_must_all_have_names_or_all_not_have_names: diag(5084, ts.DiagnosticCategory.Error, "Tuple_members_must_all_have_names_or_all_not_have_names_5084", "Tuple members must all have names or all not have names."), A_tuple_member_cannot_be_both_optional_and_rest: diag(5085, ts.DiagnosticCategory.Error, "A_tuple_member_cannot_be_both_optional_and_rest_5085", "A tuple member cannot be both optional and rest."), A_labeled_tuple_element_is_declared_as_optional_with_a_question_mark_after_the_name_and_before_the_colon_rather_than_after_the_type: diag(5086, ts.DiagnosticCategory.Error, "A_labeled_tuple_element_is_declared_as_optional_with_a_question_mark_after_the_name_and_before_the_c_5086", "A labeled tuple element is declared as optional with a question mark after the name and before the colon, rather than after the type."), - A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type: diag(5087, ts.DiagnosticCategory.Error, "A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type_5087", "A labeled tuple element is declared as rest with a `...` before the name, rather than before the type."), + A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type: diag(5087, ts.DiagnosticCategory.Error, "A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type_5087", "A labeled tuple element is declared as rest with a '...' before the name, rather than before the type."), The_inferred_type_of_0_references_a_type_with_a_cyclic_structure_which_cannot_be_trivially_serialized_A_type_annotation_is_necessary: diag(5088, ts.DiagnosticCategory.Error, "The_inferred_type_of_0_references_a_type_with_a_cyclic_structure_which_cannot_be_trivially_serialize_5088", "The inferred type of '{0}' references a type with a cyclic structure which cannot be trivially serialized. A type annotation is necessary."), Option_0_cannot_be_specified_when_option_jsx_is_1: diag(5089, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_when_option_jsx_is_1_5089", "Option '{0}' cannot be specified when option 'jsx' is '{1}'."), Non_relative_paths_are_not_allowed_when_baseUrl_is_not_set_Did_you_forget_a_leading_Slash: diag(5090, ts.DiagnosticCategory.Error, "Non_relative_paths_are_not_allowed_when_baseUrl_is_not_set_Did_you_forget_a_leading_Slash_5090", "Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?"), + Option_preserveConstEnums_cannot_be_disabled_when_isolatedModules_is_enabled: diag(5091, ts.DiagnosticCategory.Error, "Option_preserveConstEnums_cannot_be_disabled_when_isolatedModules_is_enabled_5091", "Option 'preserveConstEnums' cannot be disabled when 'isolatedModules' is enabled."), + The_root_value_of_a_0_file_must_be_an_object: diag(5092, ts.DiagnosticCategory.Error, "The_root_value_of_a_0_file_must_be_an_object_5092", "The root value of a '{0}' file must be an object."), + Compiler_option_0_may_only_be_used_with_build: diag(5093, ts.DiagnosticCategory.Error, "Compiler_option_0_may_only_be_used_with_build_5093", "Compiler option '--{0}' may only be used with '--build'."), + Compiler_option_0_may_not_be_used_with_build: diag(5094, ts.DiagnosticCategory.Error, "Compiler_option_0_may_not_be_used_with_build_5094", "Compiler option '--{0}' may not be used with '--build'."), Generates_a_sourcemap_for_each_corresponding_d_ts_file: diag(6000, ts.DiagnosticCategory.Message, "Generates_a_sourcemap_for_each_corresponding_d_ts_file_6000", "Generates a sourcemap for each corresponding '.d.ts' file."), Concatenate_and_emit_output_to_single_file: diag(6001, ts.DiagnosticCategory.Message, "Concatenate_and_emit_output_to_single_file_6001", "Concatenate and emit output to single file."), Generates_corresponding_d_ts_file: diag(6002, ts.DiagnosticCategory.Message, "Generates_corresponding_d_ts_file_6002", "Generates corresponding '.d.ts' file."), @@ -8540,7 +8794,7 @@ var ts; Skip_type_checking_of_declaration_files: diag(6012, ts.DiagnosticCategory.Message, "Skip_type_checking_of_declaration_files_6012", "Skip type checking of declaration files."), Do_not_resolve_the_real_path_of_symlinks: diag(6013, ts.DiagnosticCategory.Message, "Do_not_resolve_the_real_path_of_symlinks_6013", "Do not resolve the real path of symlinks."), Only_emit_d_ts_declaration_files: diag(6014, ts.DiagnosticCategory.Message, "Only_emit_d_ts_declaration_files_6014", "Only emit '.d.ts' declaration files."), - Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_or_ESNEXT: diag(6015, ts.DiagnosticCategory.Message, "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_or_6015", "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'."), + Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_ES2021_or_ESNEXT: diag(6015, ts.DiagnosticCategory.Message, "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_ES_6015", "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'."), Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_es2020_or_ESNext: diag(6016, ts.DiagnosticCategory.Message, "Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_es2020_or_ESNext_6016", "Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'."), Print_this_message: diag(6017, ts.DiagnosticCategory.Message, "Print_this_message_6017", "Print this message."), Print_the_compiler_s_version: diag(6019, ts.DiagnosticCategory.Message, "Print_the_compiler_s_version_6019", "Print the compiler's version."), @@ -8683,19 +8937,12 @@ var ts; Show_all_compiler_options: diag(6169, ts.DiagnosticCategory.Message, "Show_all_compiler_options_6169", "Show all compiler options."), Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file: diag(6170, ts.DiagnosticCategory.Message, "Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file_6170", "[Deprecated] Use '--outFile' instead. Concatenate and emit output to single file"), Command_line_Options: diag(6171, ts.DiagnosticCategory.Message, "Command_line_Options_6171", "Command-line Options"), - Basic_Options: diag(6172, ts.DiagnosticCategory.Message, "Basic_Options_6172", "Basic Options"), - Strict_Type_Checking_Options: diag(6173, ts.DiagnosticCategory.Message, "Strict_Type_Checking_Options_6173", "Strict Type-Checking Options"), - Module_Resolution_Options: diag(6174, ts.DiagnosticCategory.Message, "Module_Resolution_Options_6174", "Module Resolution Options"), - Source_Map_Options: diag(6175, ts.DiagnosticCategory.Message, "Source_Map_Options_6175", "Source Map Options"), - Additional_Checks: diag(6176, ts.DiagnosticCategory.Message, "Additional_Checks_6176", "Additional Checks"), - Experimental_Options: diag(6177, ts.DiagnosticCategory.Message, "Experimental_Options_6177", "Experimental Options"), - Advanced_Options: diag(6178, ts.DiagnosticCategory.Message, "Advanced_Options_6178", "Advanced Options"), Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3: diag(6179, ts.DiagnosticCategory.Message, "Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3_6179", "Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'."), Enable_all_strict_type_checking_options: diag(6180, ts.DiagnosticCategory.Message, "Enable_all_strict_type_checking_options_6180", "Enable all strict type-checking options."), List_of_language_service_plugins: diag(6181, ts.DiagnosticCategory.Message, "List_of_language_service_plugins_6181", "List of language service plugins."), Scoped_package_detected_looking_in_0: diag(6182, ts.DiagnosticCategory.Message, "Scoped_package_detected_looking_in_0_6182", "Scoped package detected, looking in '{0}'"), - Reusing_resolution_of_module_0_to_file_1_from_old_program: diag(6183, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_to_file_1_from_old_program_6183", "Reusing resolution of module '{0}' to file '{1}' from old program."), - Reusing_module_resolutions_originating_in_0_since_resolutions_are_unchanged_from_old_program: diag(6184, ts.DiagnosticCategory.Message, "Reusing_module_resolutions_originating_in_0_since_resolutions_are_unchanged_from_old_program_6184", "Reusing module resolutions originating in '{0}' since resolutions are unchanged from old program."), + Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2: diag(6183, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_6183", "Reusing resolution of module '{0}' from '{1}' of old program, it was successfully resolved to '{2}'."), + Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3: diag(6184, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package__6184", "Reusing resolution of module '{0}' from '{1}' of old program, it was successfully resolved to '{2}' with Package ID '{3}'."), Disable_strict_checking_of_generic_signatures_in_function_types: diag(6185, ts.DiagnosticCategory.Message, "Disable_strict_checking_of_generic_signatures_in_function_types_6185", "Disable strict checking of generic signatures in function types."), Enable_strict_checking_of_function_types: diag(6186, ts.DiagnosticCategory.Message, "Enable_strict_checking_of_function_types_6186", "Enable strict checking of function types."), Enable_strict_checking_of_property_initialization_in_classes: diag(6187, ts.DiagnosticCategory.Message, "Enable_strict_checking_of_property_initialization_in_classes_6187", "Enable strict checking of property initialization in classes."), @@ -8735,9 +8982,9 @@ var ts; Emit_class_fields_with_Define_instead_of_Set: diag(6222, ts.DiagnosticCategory.Message, "Emit_class_fields_with_Define_instead_of_Set_6222", "Emit class fields with Define instead of Set."), Generates_a_CPU_profile: diag(6223, ts.DiagnosticCategory.Message, "Generates_a_CPU_profile_6223", "Generates a CPU profile."), Disable_solution_searching_for_this_project: diag(6224, ts.DiagnosticCategory.Message, "Disable_solution_searching_for_this_project_6224", "Disable solution searching for this project."), - Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_DynamicPriorityPolling_UseFsEvents_UseFsEventsOnParentDirectory: diag(6225, ts.DiagnosticCategory.Message, "Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_Dynami_6225", "Specify strategy for watching file: 'FixedPollingInterval' (default), 'PriorityPollingInterval', 'DynamicPriorityPolling', 'UseFsEvents', 'UseFsEventsOnParentDirectory'."), - Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling: diag(6226, ts.DiagnosticCategory.Message, "Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively__6226", "Specify strategy for watching directory on platforms that don't support recursive watching natively: 'UseFsEvents' (default), 'FixedPollingInterval', 'DynamicPriorityPolling'."), - Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority: diag(6227, ts.DiagnosticCategory.Message, "Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_6227", "Specify strategy for creating a polling watch when it fails to create using file system events: 'FixedInterval' (default), 'PriorityInterval', 'DynamicPriority'."), + Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_DynamicPriorityPolling_FixedChunkSizePolling_UseFsEvents_UseFsEventsOnParentDirectory: diag(6225, ts.DiagnosticCategory.Message, "Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_Dynami_6225", "Specify strategy for watching file: 'FixedPollingInterval' (default), 'PriorityPollingInterval', 'DynamicPriorityPolling', 'FixedChunkSizePolling', 'UseFsEvents', 'UseFsEventsOnParentDirectory'."), + Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling_FixedChunkSizePolling: diag(6226, ts.DiagnosticCategory.Message, "Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively__6226", "Specify strategy for watching directory on platforms that don't support recursive watching natively: 'UseFsEvents' (default), 'FixedPollingInterval', 'DynamicPriorityPolling', 'FixedChunkSizePolling'."), + Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority_FixedChunkSize: diag(6227, ts.DiagnosticCategory.Message, "Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_6227", "Specify strategy for creating a polling watch when it fails to create using file system events: 'FixedInterval' (default), 'PriorityInterval', 'DynamicPriority', 'FixedChunkSize'."), Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively: diag(6228, ts.DiagnosticCategory.Message, "Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_supp_6228", "Synchronously call callbacks and update the state of directory watchers on platforms that don't support recursive watching natively."), Tag_0_expects_at_least_1_arguments_but_the_JSX_factory_2_provides_at_most_3: diag(6229, ts.DiagnosticCategory.Error, "Tag_0_expects_at_least_1_arguments_but_the_JSX_factory_2_provides_at_most_3_6229", "Tag '{0}' expects at least '{1}' arguments, but the JSX factory '{2}' provides at most '{3}'."), Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line: diag(6230, ts.DiagnosticCategory.Error, "Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line_6230", "Option '{0}' can only be specified in 'tsconfig.json' file or set to 'false' or 'null' on command line."), @@ -8748,7 +8995,26 @@ var ts; Disable_loading_referenced_projects: diag(6235, ts.DiagnosticCategory.Message, "Disable_loading_referenced_projects_6235", "Disable loading referenced projects."), Arguments_for_the_rest_parameter_0_were_not_provided: diag(6236, ts.DiagnosticCategory.Error, "Arguments_for_the_rest_parameter_0_were_not_provided_6236", "Arguments for the rest parameter '{0}' were not provided."), Generates_an_event_trace_and_a_list_of_types: diag(6237, ts.DiagnosticCategory.Message, "Generates_an_event_trace_and_a_list_of_types_6237", "Generates an event trace and a list of types."), - Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react: diag(6238, ts.DiagnosticCategory.Error, "Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react_6238", "Specify the module specifier to be used to import the `jsx` and `jsxs` factory functions from. eg, react"), + Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react: diag(6238, ts.DiagnosticCategory.Error, "Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react_6238", "Specify the module specifier to be used to import the 'jsx' and 'jsxs' factory functions from. eg, react"), + File_0_exists_according_to_earlier_cached_lookups: diag(6239, ts.DiagnosticCategory.Message, "File_0_exists_according_to_earlier_cached_lookups_6239", "File '{0}' exists according to earlier cached lookups."), + File_0_does_not_exist_according_to_earlier_cached_lookups: diag(6240, ts.DiagnosticCategory.Message, "File_0_does_not_exist_according_to_earlier_cached_lookups_6240", "File '{0}' does not exist according to earlier cached lookups."), + Resolution_for_type_reference_directive_0_was_found_in_cache_from_location_1: diag(6241, ts.DiagnosticCategory.Message, "Resolution_for_type_reference_directive_0_was_found_in_cache_from_location_1_6241", "Resolution for type reference directive '{0}' was found in cache from location '{1}'."), + Resolving_type_reference_directive_0_containing_file_1: diag(6242, ts.DiagnosticCategory.Message, "Resolving_type_reference_directive_0_containing_file_1_6242", "======== Resolving type reference directive '{0}', containing file '{1}'. ========"), + Enable_strict_checking_of_optional_properties: diag(6243, ts.DiagnosticCategory.Message, "Enable_strict_checking_of_optional_properties_6243", "Enable strict checking of optional properties."), + Modules: diag(6244, ts.DiagnosticCategory.Message, "Modules_6244", "Modules"), + File_Management: diag(6245, ts.DiagnosticCategory.Message, "File_Management_6245", "File Management"), + Emit: diag(6246, ts.DiagnosticCategory.Message, "Emit_6246", "Emit"), + JavaScript_Support: diag(6247, ts.DiagnosticCategory.Message, "JavaScript_Support_6247", "JavaScript Support"), + Type_Checking: diag(6248, ts.DiagnosticCategory.Message, "Type_Checking_6248", "Type Checking"), + Editor_Support: diag(6249, ts.DiagnosticCategory.Message, "Editor_Support_6249", "Editor Support"), + Watch_and_Build_Modes: diag(6250, ts.DiagnosticCategory.Message, "Watch_and_Build_Modes_6250", "Watch and Build Modes"), + Compiler_Diagnostics: diag(6251, ts.DiagnosticCategory.Message, "Compiler_Diagnostics_6251", "Compiler Diagnostics"), + Interop_Constraints: diag(6252, ts.DiagnosticCategory.Message, "Interop_Constraints_6252", "Interop Constraints"), + Backwards_Compatibility: diag(6253, ts.DiagnosticCategory.Message, "Backwards_Compatibility_6253", "Backwards Compatibility"), + Language_and_Environment: diag(6254, ts.DiagnosticCategory.Message, "Language_and_Environment_6254", "Language and Environment"), + Projects: diag(6255, ts.DiagnosticCategory.Message, "Projects_6255", "Projects"), + Output_Formatting: diag(6256, ts.DiagnosticCategory.Message, "Output_Formatting_6256", "Output Formatting"), + Completeness: diag(6257, ts.DiagnosticCategory.Message, "Completeness_6257", "Completeness"), Projects_to_reference: diag(6300, ts.DiagnosticCategory.Message, "Projects_to_reference_6300", "Projects to reference"), Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"), Composite_projects_may_not_disable_declaration_emit: diag(6304, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_declaration_emit_6304", "Composite projects may not disable declaration emit."), @@ -8793,16 +9059,31 @@ var ts; Skipping_build_of_project_0_because_its_dependency_1_was_not_built: diag(6382, ts.DiagnosticCategory.Message, "Skipping_build_of_project_0_because_its_dependency_1_was_not_built_6382", "Skipping build of project '{0}' because its dependency '{1}' was not built"), Project_0_can_t_be_built_because_its_dependency_1_was_not_built: diag(6383, ts.DiagnosticCategory.Message, "Project_0_can_t_be_built_because_its_dependency_1_was_not_built_6383", "Project '{0}' can't be built because its dependency '{1}' was not built"), Have_recompiles_in_incremental_and_watch_assume_that_changes_within_a_file_will_only_affect_files_directly_depending_on_it: diag(6384, ts.DiagnosticCategory.Message, "Have_recompiles_in_incremental_and_watch_assume_that_changes_within_a_file_will_only_affect_files_di_6384", "Have recompiles in '--incremental' and '--watch' assume that changes within a file will only affect files directly depending on it."), - _0_is_deprecated: diag(6385, ts.DiagnosticCategory.Suggestion, "_0_is_deprecated_6385", "'{0}' is deprecated", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ undefined, /*reportsDeprecated*/ true), + _0_is_deprecated: diag(6385, ts.DiagnosticCategory.Suggestion, "_0_is_deprecated_6385", "'{0}' is deprecated.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ undefined, /*reportsDeprecated*/ true), Performance_timings_for_diagnostics_or_extendedDiagnostics_are_not_available_in_this_session_A_native_implementation_of_the_Web_Performance_API_could_not_be_found: diag(6386, ts.DiagnosticCategory.Message, "Performance_timings_for_diagnostics_or_extendedDiagnostics_are_not_available_in_this_session_A_nativ_6386", "Performance timings for '--diagnostics' or '--extendedDiagnostics' are not available in this session. A native implementation of the Web Performance API could not be found."), + The_signature_0_of_1_is_deprecated: diag(6387, ts.DiagnosticCategory.Suggestion, "The_signature_0_of_1_is_deprecated_6387", "The signature '{0}' of '{1}' is deprecated.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ undefined, /*reportsDeprecated*/ true), + Project_0_is_being_forcibly_rebuilt: diag(6388, ts.DiagnosticCategory.Message, "Project_0_is_being_forcibly_rebuilt_6388", "Project '{0}' is being forcibly rebuilt"), + Reusing_resolution_of_module_0_from_1_of_old_program_it_was_not_resolved: diag(6389, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_of_old_program_it_was_not_resolved_6389", "Reusing resolution of module '{0}' from '{1}' of old program, it was not resolved."), + Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2: diag(6390, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved__6390", "Reusing resolution of type reference directive '{0}' from '{1}' of old program, it was successfully resolved to '{2}'."), + Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3: diag(6391, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved__6391", "Reusing resolution of type reference directive '{0}' from '{1}' of old program, it was successfully resolved to '{2}' with Package ID '{3}'."), + Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_not_resolved: diag(6392, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_not_resolved_6392", "Reusing resolution of type reference directive '{0}' from '{1}' of old program, it was not resolved."), + Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3: diag(6393, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_6393", "Reusing resolution of module '{0}' from '{1}' found in cache from location '{2}', it was successfully resolved to '{3}'."), + Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4: diag(6394, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_6394", "Reusing resolution of module '{0}' from '{1}' found in cache from location '{2}', it was successfully resolved to '{3}' with Package ID '{4}'."), + Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_not_resolved: diag(6395, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_not_resolved_6395", "Reusing resolution of module '{0}' from '{1}' found in cache from location '{2}', it was not resolved."), + Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3: diag(6396, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_succes_6396", "Reusing resolution of type reference directive '{0}' from '{1}' found in cache from location '{2}', it was successfully resolved to '{3}'."), + Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4: diag(6397, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_succes_6397", "Reusing resolution of type reference directive '{0}' from '{1}' found in cache from location '{2}', it was successfully resolved to '{3}' with Package ID '{4}'."), + Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_not_resolved: diag(6398, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_not_re_6398", "Reusing resolution of type reference directive '{0}' from '{1}' found in cache from location '{2}', it was not resolved."), The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"), The_expected_type_comes_from_this_index_signature: diag(6501, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."), The_expected_type_comes_from_the_return_type_of_this_signature: diag(6502, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_the_return_type_of_this_signature_6502", "The expected type comes from the return type of this signature."), Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing: diag(6503, ts.DiagnosticCategory.Message, "Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing_6503", "Print names of files that are part of the compilation and then stop processing."), File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option: diag(6504, ts.DiagnosticCategory.Error, "File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option_6504", "File '{0}' is a JavaScript file. Did you mean to enable the 'allowJs' option?"), Print_names_of_files_and_the_reason_they_are_part_of_the_compilation: diag(6505, ts.DiagnosticCategory.Message, "Print_names_of_files_and_the_reason_they_are_part_of_the_compilation_6505", "Print names of files and the reason they are part of the compilation."), - Require_undeclared_properties_from_index_signatures_to_use_element_accesses: diag(6803, ts.DiagnosticCategory.Error, "Require_undeclared_properties_from_index_signatures_to_use_element_accesses_6803", "Require undeclared properties from index signatures to use element accesses."), + Consider_adding_a_declare_modifier_to_this_class: diag(6506, ts.DiagnosticCategory.Message, "Consider_adding_a_declare_modifier_to_this_class_6506", "Consider adding a 'declare' modifier to this class."), Include_undefined_in_index_signature_results: diag(6800, ts.DiagnosticCategory.Message, "Include_undefined_in_index_signature_results_6800", "Include 'undefined' in index signature results"), + Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier: diag(6801, ts.DiagnosticCategory.Message, "Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier_6801", "Ensure overriding members in derived classes are marked with an 'override' modifier."), + Require_undeclared_properties_from_index_signatures_to_use_element_accesses: diag(6802, ts.DiagnosticCategory.Message, "Require_undeclared_properties_from_index_signatures_to_use_element_accesses_6802", "Require undeclared properties from index signatures to use element accesses."), + Type_catch_clause_variables_as_unknown_instead_of_any: diag(6803, ts.DiagnosticCategory.Message, "Type_catch_clause_variables_as_unknown_instead_of_any_6803", "Type catch clause variables as 'unknown' instead of 'any'."), Variable_0_implicitly_has_an_1_type: diag(7005, ts.DiagnosticCategory.Error, "Variable_0_implicitly_has_an_1_type_7005", "Variable '{0}' implicitly has an '{1}' type."), Parameter_0_implicitly_has_an_1_type: diag(7006, ts.DiagnosticCategory.Error, "Parameter_0_implicitly_has_an_1_type_7006", "Parameter '{0}' implicitly has an '{1}' type."), Member_0_implicitly_has_an_1_type: diag(7008, ts.DiagnosticCategory.Error, "Member_0_implicitly_has_an_1_type_7008", "Member '{0}' implicitly has an '{1}' type."), @@ -8835,7 +9116,7 @@ var ts; Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for_all_imports_Implies_allowSyntheticDefaultImports: diag(7037, ts.DiagnosticCategory.Message, "Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for__7037", "Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'."), Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead: diag(7038, ts.DiagnosticCategory.Message, "Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cau_7038", "Type originates at this import. A namespace-style import cannot be called or constructed, and will cause a failure at runtime. Consider using a default import or import require here instead."), Mapped_object_type_implicitly_has_an_any_template_type: diag(7039, ts.DiagnosticCategory.Error, "Mapped_object_type_implicitly_has_an_any_template_type_7039", "Mapped object type implicitly has an 'any' template type."), - If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_1: diag(7040, ts.DiagnosticCategory.Error, "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040", "If the '{0}' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}`"), + If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_1: diag(7040, ts.DiagnosticCategory.Error, "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040", "If the '{0}' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}'"), The_containing_arrow_function_captures_the_global_value_of_this: diag(7041, ts.DiagnosticCategory.Error, "The_containing_arrow_function_captures_the_global_value_of_this_7041", "The containing arrow function captures the global value of 'this'."), Module_0_was_resolved_to_1_but_resolveJsonModule_is_not_used: diag(7042, ts.DiagnosticCategory.Error, "Module_0_was_resolved_to_1_but_resolveJsonModule_is_not_used_7042", "Module '{0}' was resolved to '{1}', but '--resolveJsonModule' is not used."), Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage: diag(7043, ts.DiagnosticCategory.Suggestion, "Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7043", "Variable '{0}' implicitly has an '{1}' type, but a better type may be inferred from usage."), @@ -8875,7 +9156,7 @@ var ts; JSDoc_0_is_not_attached_to_a_class: diag(8022, ts.DiagnosticCategory.Error, "JSDoc_0_is_not_attached_to_a_class_8022", "JSDoc '@{0}' is not attached to a class."), JSDoc_0_1_does_not_match_the_extends_2_clause: diag(8023, ts.DiagnosticCategory.Error, "JSDoc_0_1_does_not_match_the_extends_2_clause_8023", "JSDoc '@{0} {1}' does not match the 'extends {2}' clause."), JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name: diag(8024, ts.DiagnosticCategory.Error, "JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_8024", "JSDoc '@param' tag has name '{0}', but there is no parameter with that name."), - Class_declarations_cannot_have_more_than_one_augments_or_extends_tag: diag(8025, ts.DiagnosticCategory.Error, "Class_declarations_cannot_have_more_than_one_augments_or_extends_tag_8025", "Class declarations cannot have more than one `@augments` or `@extends` tag."), + Class_declarations_cannot_have_more_than_one_augments_or_extends_tag: diag(8025, ts.DiagnosticCategory.Error, "Class_declarations_cannot_have_more_than_one_augments_or_extends_tag_8025", "Class declarations cannot have more than one '@augments' or '@extends' tag."), Expected_0_type_arguments_provide_these_with_an_extends_tag: diag(8026, ts.DiagnosticCategory.Error, "Expected_0_type_arguments_provide_these_with_an_extends_tag_8026", "Expected {0} type arguments; provide these with an '@extends' tag."), Expected_0_1_type_arguments_provide_these_with_an_extends_tag: diag(8027, ts.DiagnosticCategory.Error, "Expected_0_1_type_arguments_provide_these_with_an_extends_tag_8027", "Expected {0}-{1} type arguments; provide these with an '@extends' tag."), JSDoc_may_only_appear_in_the_last_parameter_of_a_signature: diag(8028, ts.DiagnosticCategory.Error, "JSDoc_may_only_appear_in_the_last_parameter_of_a_signature_8028", "JSDoc '...' may only appear in the last parameter of a signature."), @@ -9120,6 +9401,11 @@ var ts; Add_all_missing_function_declarations: diag(95157, ts.DiagnosticCategory.Message, "Add_all_missing_function_declarations_95157", "Add all missing function declarations"), Method_not_implemented: diag(95158, ts.DiagnosticCategory.Message, "Method_not_implemented_95158", "Method not implemented."), Function_not_implemented: diag(95159, ts.DiagnosticCategory.Message, "Function_not_implemented_95159", "Function not implemented."), + Add_override_modifier: diag(95160, ts.DiagnosticCategory.Message, "Add_override_modifier_95160", "Add 'override' modifier"), + Remove_override_modifier: diag(95161, ts.DiagnosticCategory.Message, "Remove_override_modifier_95161", "Remove 'override' modifier"), + Add_all_missing_override_modifiers: diag(95162, ts.DiagnosticCategory.Message, "Add_all_missing_override_modifiers_95162", "Add all missing 'override' modifiers"), + Remove_all_unnecessary_override_modifiers: diag(95163, ts.DiagnosticCategory.Message, "Remove_all_unnecessary_override_modifiers_95163", "Remove all unnecessary 'override' modifiers"), + Can_only_convert_named_export: diag(95164, ts.DiagnosticCategory.Message, "Can_only_convert_named_export_95164", "Can only convert named export"), No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, ts.DiagnosticCategory.Error, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."), Classes_may_not_have_a_field_named_constructor: diag(18006, ts.DiagnosticCategory.Error, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."), JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, ts.DiagnosticCategory.Error, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"), @@ -9134,8 +9420,6 @@ var ts; The_shadowing_declaration_of_0_is_defined_here: diag(18017, ts.DiagnosticCategory.Error, "The_shadowing_declaration_of_0_is_defined_here_18017", "The shadowing declaration of '{0}' is defined here"), The_declaration_of_0_that_you_probably_intended_to_use_is_defined_here: diag(18018, ts.DiagnosticCategory.Error, "The_declaration_of_0_that_you_probably_intended_to_use_is_defined_here_18018", "The declaration of '{0}' that you probably intended to use is defined here"), _0_modifier_cannot_be_used_with_a_private_identifier: diag(18019, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_with_a_private_identifier_18019", "'{0}' modifier cannot be used with a private identifier."), - A_method_cannot_be_named_with_a_private_identifier: diag(18022, ts.DiagnosticCategory.Error, "A_method_cannot_be_named_with_a_private_identifier_18022", "A method cannot be named with a private identifier."), - An_accessor_cannot_be_named_with_a_private_identifier: diag(18023, ts.DiagnosticCategory.Error, "An_accessor_cannot_be_named_with_a_private_identifier_18023", "An accessor cannot be named with a private identifier."), An_enum_member_cannot_be_named_with_a_private_identifier: diag(18024, ts.DiagnosticCategory.Error, "An_enum_member_cannot_be_named_with_a_private_identifier_18024", "An enum member cannot be named with a private identifier."), can_only_be_used_at_the_start_of_a_file: diag(18026, ts.DiagnosticCategory.Error, "can_only_be_used_at_the_start_of_a_file_18026", "'#!' can only be used at the start of a file."), Compiler_reserves_name_0_when_emitting_private_identifier_downlevel: diag(18027, ts.DiagnosticCategory.Error, "Compiler_reserves_name_0_when_emitting_private_identifier_downlevel_18027", "Compiler reserves name '{0}' when emitting private identifier downlevel."), @@ -9147,6 +9431,7 @@ var ts; 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: diag(18033, ts.DiagnosticCategory.Error, "Only_numeric_enums_can_have_computed_members_but_this_expression_has_type_0_If_you_do_not_need_exhau_18033", "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."), Specify_the_JSX_fragment_factory_function_to_use_when_targeting_react_JSX_emit_with_jsxFactory_compiler_option_is_specified_e_g_Fragment: diag(18034, ts.DiagnosticCategory.Message, "Specify_the_JSX_fragment_factory_function_to_use_when_targeting_react_JSX_emit_with_jsxFactory_compi_18034", "Specify the JSX fragment factory function to use when targeting 'react' JSX emit with 'jsxFactory' compiler option is specified, e.g. 'Fragment'."), Invalid_value_for_jsxFragmentFactory_0_is_not_a_valid_identifier_or_qualified_name: diag(18035, ts.DiagnosticCategory.Error, "Invalid_value_for_jsxFragmentFactory_0_is_not_a_valid_identifier_or_qualified_name_18035", "Invalid value for 'jsxFragmentFactory'. '{0}' is not a valid identifier or qualified-name."), + Class_decorators_can_t_be_used_with_static_private_identifier_Consider_removing_the_experimental_decorator: diag(18036, ts.DiagnosticCategory.Error, "Class_decorators_can_t_be_used_with_static_private_identifier_Consider_removing_the_experimental_dec_18036", "Class decorators can't be used with static private identifier. Consider removing the experimental decorator."), }; })(ts || (ts = {})); var ts; @@ -9154,7 +9439,7 @@ var ts; var _a; /* @internal */ function tokenIsIdentifierOrKeyword(token) { - return token >= 78 /* Identifier */; + return token >= 79 /* Identifier */; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; /* @internal */ @@ -9163,87 +9448,88 @@ var ts; } ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan; var textToKeywordObj = (_a = { - abstract: 125 /* AbstractKeyword */, - any: 128 /* AnyKeyword */, - as: 126 /* AsKeyword */, - asserts: 127 /* AssertsKeyword */, - bigint: 155 /* BigIntKeyword */, - boolean: 131 /* BooleanKeyword */, - break: 80 /* BreakKeyword */, - case: 81 /* CaseKeyword */, - catch: 82 /* CatchKeyword */, - class: 83 /* ClassKeyword */, - continue: 85 /* ContinueKeyword */, - const: 84 /* ConstKeyword */ + abstract: 126 /* AbstractKeyword */, + any: 129 /* AnyKeyword */, + as: 127 /* AsKeyword */, + asserts: 128 /* AssertsKeyword */, + bigint: 156 /* BigIntKeyword */, + boolean: 132 /* BooleanKeyword */, + break: 81 /* BreakKeyword */, + case: 82 /* CaseKeyword */, + catch: 83 /* CatchKeyword */, + class: 84 /* ClassKeyword */, + continue: 86 /* ContinueKeyword */, + const: 85 /* ConstKeyword */ }, - _a["" + "constructor"] = 132 /* ConstructorKeyword */, - _a.debugger = 86 /* DebuggerKeyword */, - _a.declare = 133 /* DeclareKeyword */, - _a.default = 87 /* DefaultKeyword */, - _a.delete = 88 /* DeleteKeyword */, - _a.do = 89 /* DoKeyword */, - _a.else = 90 /* ElseKeyword */, - _a.enum = 91 /* EnumKeyword */, - _a.export = 92 /* ExportKeyword */, - _a.extends = 93 /* ExtendsKeyword */, - _a.false = 94 /* FalseKeyword */, - _a.finally = 95 /* FinallyKeyword */, - _a.for = 96 /* ForKeyword */, - _a.from = 153 /* FromKeyword */, - _a.function = 97 /* FunctionKeyword */, - _a.get = 134 /* GetKeyword */, - _a.if = 98 /* IfKeyword */, - _a.implements = 116 /* ImplementsKeyword */, - _a.import = 99 /* ImportKeyword */, - _a.in = 100 /* InKeyword */, - _a.infer = 135 /* InferKeyword */, - _a.instanceof = 101 /* InstanceOfKeyword */, - _a.interface = 117 /* InterfaceKeyword */, - _a.intrinsic = 136 /* IntrinsicKeyword */, - _a.is = 137 /* IsKeyword */, - _a.keyof = 138 /* KeyOfKeyword */, - _a.let = 118 /* LetKeyword */, - _a.module = 139 /* ModuleKeyword */, - _a.namespace = 140 /* NamespaceKeyword */, - _a.never = 141 /* NeverKeyword */, - _a.new = 102 /* NewKeyword */, - _a.null = 103 /* NullKeyword */, - _a.number = 144 /* NumberKeyword */, - _a.object = 145 /* ObjectKeyword */, - _a.package = 119 /* PackageKeyword */, - _a.private = 120 /* PrivateKeyword */, - _a.protected = 121 /* ProtectedKeyword */, - _a.public = 122 /* PublicKeyword */, - _a.readonly = 142 /* ReadonlyKeyword */, - _a.require = 143 /* RequireKeyword */, - _a.global = 154 /* GlobalKeyword */, - _a.return = 104 /* ReturnKeyword */, - _a.set = 146 /* SetKeyword */, - _a.static = 123 /* StaticKeyword */, - _a.string = 147 /* StringKeyword */, - _a.super = 105 /* SuperKeyword */, - _a.switch = 106 /* SwitchKeyword */, - _a.symbol = 148 /* SymbolKeyword */, - _a.this = 107 /* ThisKeyword */, - _a.throw = 108 /* ThrowKeyword */, - _a.true = 109 /* TrueKeyword */, - _a.try = 110 /* TryKeyword */, - _a.type = 149 /* TypeKeyword */, - _a.typeof = 111 /* TypeOfKeyword */, - _a.undefined = 150 /* UndefinedKeyword */, - _a.unique = 151 /* UniqueKeyword */, - _a.unknown = 152 /* UnknownKeyword */, - _a.var = 112 /* VarKeyword */, - _a.void = 113 /* VoidKeyword */, - _a.while = 114 /* WhileKeyword */, - _a.with = 115 /* WithKeyword */, - _a.yield = 124 /* YieldKeyword */, - _a.async = 129 /* AsyncKeyword */, - _a.await = 130 /* AwaitKeyword */, - _a.of = 156 /* OfKeyword */, + _a["" + "constructor"] = 133 /* ConstructorKeyword */, + _a.debugger = 87 /* DebuggerKeyword */, + _a.declare = 134 /* 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 = 154 /* FromKeyword */, + _a.function = 98 /* FunctionKeyword */, + _a.get = 135 /* GetKeyword */, + _a.if = 99 /* IfKeyword */, + _a.implements = 117 /* ImplementsKeyword */, + _a.import = 100 /* ImportKeyword */, + _a.in = 101 /* InKeyword */, + _a.infer = 136 /* InferKeyword */, + _a.instanceof = 102 /* InstanceOfKeyword */, + _a.interface = 118 /* InterfaceKeyword */, + _a.intrinsic = 137 /* IntrinsicKeyword */, + _a.is = 138 /* IsKeyword */, + _a.keyof = 139 /* KeyOfKeyword */, + _a.let = 119 /* LetKeyword */, + _a.module = 140 /* ModuleKeyword */, + _a.namespace = 141 /* NamespaceKeyword */, + _a.never = 142 /* NeverKeyword */, + _a.new = 103 /* NewKeyword */, + _a.null = 104 /* NullKeyword */, + _a.number = 145 /* NumberKeyword */, + _a.object = 146 /* ObjectKeyword */, + _a.package = 120 /* PackageKeyword */, + _a.private = 121 /* PrivateKeyword */, + _a.protected = 122 /* ProtectedKeyword */, + _a.public = 123 /* PublicKeyword */, + _a.override = 157 /* OverrideKeyword */, + _a.readonly = 143 /* ReadonlyKeyword */, + _a.require = 144 /* RequireKeyword */, + _a.global = 155 /* GlobalKeyword */, + _a.return = 105 /* ReturnKeyword */, + _a.set = 147 /* SetKeyword */, + _a.static = 124 /* StaticKeyword */, + _a.string = 148 /* StringKeyword */, + _a.super = 106 /* SuperKeyword */, + _a.switch = 107 /* SwitchKeyword */, + _a.symbol = 149 /* SymbolKeyword */, + _a.this = 108 /* ThisKeyword */, + _a.throw = 109 /* ThrowKeyword */, + _a.true = 110 /* TrueKeyword */, + _a.try = 111 /* TryKeyword */, + _a.type = 150 /* TypeKeyword */, + _a.typeof = 112 /* TypeOfKeyword */, + _a.undefined = 151 /* UndefinedKeyword */, + _a.unique = 152 /* UniqueKeyword */, + _a.unknown = 153 /* UnknownKeyword */, + _a.var = 113 /* VarKeyword */, + _a.void = 114 /* VoidKeyword */, + _a.while = 115 /* WhileKeyword */, + _a.with = 116 /* WithKeyword */, + _a.yield = 125 /* YieldKeyword */, + _a.async = 130 /* AsyncKeyword */, + _a.await = 131 /* AwaitKeyword */, + _a.of = 158 /* OfKeyword */, _a); var textToKeyword = new ts.Map(ts.getEntries(textToKeywordObj)); - var textToToken = new ts.Map(ts.getEntries(__assign(__assign({}, 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 */, "=": 62 /* EqualsToken */, "+=": 63 /* PlusEqualsToken */, "-=": 64 /* MinusEqualsToken */, "*=": 65 /* AsteriskEqualsToken */, "**=": 66 /* AsteriskAsteriskEqualsToken */, "/=": 67 /* SlashEqualsToken */, "%=": 68 /* PercentEqualsToken */, "<<=": 69 /* LessThanLessThanEqualsToken */, ">>=": 70 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 72 /* AmpersandEqualsToken */, "|=": 73 /* BarEqualsToken */, "^=": 77 /* CaretEqualsToken */, "||=": 74 /* BarBarEqualsToken */, "&&=": 75 /* AmpersandAmpersandEqualsToken */, "??=": 76 /* QuestionQuestionEqualsToken */, "@": 59 /* AtToken */, "`": 61 /* BacktickToken */ }))); + var textToToken = new ts.Map(ts.getEntries(__assign(__assign({}, 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 */ }))); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers IdentifierStart :: @@ -9299,13 +9585,13 @@ var ts; var unicodeESNextIdentifierStart = [65, 90, 97, 122, 170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 895, 895, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1327, 1329, 1366, 1369, 1369, 1376, 1416, 1488, 1514, 1519, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2144, 2154, 2208, 2228, 2230, 2237, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2432, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2556, 2556, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2809, 2809, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3129, 3133, 3133, 3160, 3162, 3168, 3169, 3200, 3200, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3412, 3414, 3423, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3718, 3722, 3724, 3747, 3749, 3749, 3751, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5109, 5112, 5117, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5880, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6264, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6430, 6480, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7296, 7304, 7312, 7354, 7357, 7359, 7401, 7404, 7406, 7411, 7413, 7414, 7418, 7418, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8472, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12443, 12447, 12449, 12538, 12540, 12543, 12549, 12591, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40943, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42653, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42943, 42946, 42950, 42999, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43261, 43262, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43488, 43492, 43494, 43503, 43514, 43518, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43646, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43824, 43866, 43868, 43879, 43888, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 65536, 65547, 65549, 65574, 65576, 65594, 65596, 65597, 65599, 65613, 65616, 65629, 65664, 65786, 65856, 65908, 66176, 66204, 66208, 66256, 66304, 66335, 66349, 66378, 66384, 66421, 66432, 66461, 66464, 66499, 66504, 66511, 66513, 66517, 66560, 66717, 66736, 66771, 66776, 66811, 66816, 66855, 66864, 66915, 67072, 67382, 67392, 67413, 67424, 67431, 67584, 67589, 67592, 67592, 67594, 67637, 67639, 67640, 67644, 67644, 67647, 67669, 67680, 67702, 67712, 67742, 67808, 67826, 67828, 67829, 67840, 67861, 67872, 67897, 67968, 68023, 68030, 68031, 68096, 68096, 68112, 68115, 68117, 68119, 68121, 68149, 68192, 68220, 68224, 68252, 68288, 68295, 68297, 68324, 68352, 68405, 68416, 68437, 68448, 68466, 68480, 68497, 68608, 68680, 68736, 68786, 68800, 68850, 68864, 68899, 69376, 69404, 69415, 69415, 69424, 69445, 69600, 69622, 69635, 69687, 69763, 69807, 69840, 69864, 69891, 69926, 69956, 69956, 69968, 70002, 70006, 70006, 70019, 70066, 70081, 70084, 70106, 70106, 70108, 70108, 70144, 70161, 70163, 70187, 70272, 70278, 70280, 70280, 70282, 70285, 70287, 70301, 70303, 70312, 70320, 70366, 70405, 70412, 70415, 70416, 70419, 70440, 70442, 70448, 70450, 70451, 70453, 70457, 70461, 70461, 70480, 70480, 70493, 70497, 70656, 70708, 70727, 70730, 70751, 70751, 70784, 70831, 70852, 70853, 70855, 70855, 71040, 71086, 71128, 71131, 71168, 71215, 71236, 71236, 71296, 71338, 71352, 71352, 71424, 71450, 71680, 71723, 71840, 71903, 71935, 71935, 72096, 72103, 72106, 72144, 72161, 72161, 72163, 72163, 72192, 72192, 72203, 72242, 72250, 72250, 72272, 72272, 72284, 72329, 72349, 72349, 72384, 72440, 72704, 72712, 72714, 72750, 72768, 72768, 72818, 72847, 72960, 72966, 72968, 72969, 72971, 73008, 73030, 73030, 73056, 73061, 73063, 73064, 73066, 73097, 73112, 73112, 73440, 73458, 73728, 74649, 74752, 74862, 74880, 75075, 77824, 78894, 82944, 83526, 92160, 92728, 92736, 92766, 92880, 92909, 92928, 92975, 92992, 92995, 93027, 93047, 93053, 93071, 93760, 93823, 93952, 94026, 94032, 94032, 94099, 94111, 94176, 94177, 94179, 94179, 94208, 100343, 100352, 101106, 110592, 110878, 110928, 110930, 110948, 110951, 110960, 111355, 113664, 113770, 113776, 113788, 113792, 113800, 113808, 113817, 119808, 119892, 119894, 119964, 119966, 119967, 119970, 119970, 119973, 119974, 119977, 119980, 119982, 119993, 119995, 119995, 119997, 120003, 120005, 120069, 120071, 120074, 120077, 120084, 120086, 120092, 120094, 120121, 120123, 120126, 120128, 120132, 120134, 120134, 120138, 120144, 120146, 120485, 120488, 120512, 120514, 120538, 120540, 120570, 120572, 120596, 120598, 120628, 120630, 120654, 120656, 120686, 120688, 120712, 120714, 120744, 120746, 120770, 120772, 120779, 123136, 123180, 123191, 123197, 123214, 123214, 123584, 123627, 124928, 125124, 125184, 125251, 125259, 125259, 126464, 126467, 126469, 126495, 126497, 126498, 126500, 126500, 126503, 126503, 126505, 126514, 126516, 126519, 126521, 126521, 126523, 126523, 126530, 126530, 126535, 126535, 126537, 126537, 126539, 126539, 126541, 126543, 126545, 126546, 126548, 126548, 126551, 126551, 126553, 126553, 126555, 126555, 126557, 126557, 126559, 126559, 126561, 126562, 126564, 126564, 126567, 126570, 126572, 126578, 126580, 126583, 126585, 126588, 126590, 126590, 126592, 126601, 126603, 126619, 126625, 126627, 126629, 126633, 126635, 126651, 131072, 173782, 173824, 177972, 177984, 178205, 178208, 183969, 183984, 191456, 194560, 195101]; var unicodeESNextIdentifierPart = [48, 57, 65, 90, 95, 95, 97, 122, 170, 170, 181, 181, 183, 183, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 895, 895, 902, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1327, 1329, 1366, 1369, 1369, 1376, 1416, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1519, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2045, 2045, 2048, 2093, 2112, 2139, 2144, 2154, 2208, 2228, 2230, 2237, 2259, 2273, 2275, 2403, 2406, 2415, 2417, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2556, 2556, 2558, 2558, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2809, 2815, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3072, 3084, 3086, 3088, 3090, 3112, 3114, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3162, 3168, 3171, 3174, 3183, 3200, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3328, 3331, 3333, 3340, 3342, 3344, 3346, 3396, 3398, 3400, 3402, 3406, 3412, 3415, 3423, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3558, 3567, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3718, 3722, 3724, 3747, 3749, 3749, 3751, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4969, 4977, 4992, 5007, 5024, 5109, 5112, 5117, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5880, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6264, 6272, 6314, 6320, 6389, 6400, 6430, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6618, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6832, 6845, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7296, 7304, 7312, 7354, 7357, 7359, 7376, 7378, 7380, 7418, 7424, 7673, 7675, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8472, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12447, 12449, 12538, 12540, 12543, 12549, 12591, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40943, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42737, 42775, 42783, 42786, 42888, 42891, 42943, 42946, 42950, 42999, 43047, 43072, 43123, 43136, 43205, 43216, 43225, 43232, 43255, 43259, 43259, 43261, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43488, 43518, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43824, 43866, 43868, 43879, 43888, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65071, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 65536, 65547, 65549, 65574, 65576, 65594, 65596, 65597, 65599, 65613, 65616, 65629, 65664, 65786, 65856, 65908, 66045, 66045, 66176, 66204, 66208, 66256, 66272, 66272, 66304, 66335, 66349, 66378, 66384, 66426, 66432, 66461, 66464, 66499, 66504, 66511, 66513, 66517, 66560, 66717, 66720, 66729, 66736, 66771, 66776, 66811, 66816, 66855, 66864, 66915, 67072, 67382, 67392, 67413, 67424, 67431, 67584, 67589, 67592, 67592, 67594, 67637, 67639, 67640, 67644, 67644, 67647, 67669, 67680, 67702, 67712, 67742, 67808, 67826, 67828, 67829, 67840, 67861, 67872, 67897, 67968, 68023, 68030, 68031, 68096, 68099, 68101, 68102, 68108, 68115, 68117, 68119, 68121, 68149, 68152, 68154, 68159, 68159, 68192, 68220, 68224, 68252, 68288, 68295, 68297, 68326, 68352, 68405, 68416, 68437, 68448, 68466, 68480, 68497, 68608, 68680, 68736, 68786, 68800, 68850, 68864, 68903, 68912, 68921, 69376, 69404, 69415, 69415, 69424, 69456, 69600, 69622, 69632, 69702, 69734, 69743, 69759, 69818, 69840, 69864, 69872, 69881, 69888, 69940, 69942, 69951, 69956, 69958, 69968, 70003, 70006, 70006, 70016, 70084, 70089, 70092, 70096, 70106, 70108, 70108, 70144, 70161, 70163, 70199, 70206, 70206, 70272, 70278, 70280, 70280, 70282, 70285, 70287, 70301, 70303, 70312, 70320, 70378, 70384, 70393, 70400, 70403, 70405, 70412, 70415, 70416, 70419, 70440, 70442, 70448, 70450, 70451, 70453, 70457, 70459, 70468, 70471, 70472, 70475, 70477, 70480, 70480, 70487, 70487, 70493, 70499, 70502, 70508, 70512, 70516, 70656, 70730, 70736, 70745, 70750, 70751, 70784, 70853, 70855, 70855, 70864, 70873, 71040, 71093, 71096, 71104, 71128, 71133, 71168, 71232, 71236, 71236, 71248, 71257, 71296, 71352, 71360, 71369, 71424, 71450, 71453, 71467, 71472, 71481, 71680, 71738, 71840, 71913, 71935, 71935, 72096, 72103, 72106, 72151, 72154, 72161, 72163, 72164, 72192, 72254, 72263, 72263, 72272, 72345, 72349, 72349, 72384, 72440, 72704, 72712, 72714, 72758, 72760, 72768, 72784, 72793, 72818, 72847, 72850, 72871, 72873, 72886, 72960, 72966, 72968, 72969, 72971, 73014, 73018, 73018, 73020, 73021, 73023, 73031, 73040, 73049, 73056, 73061, 73063, 73064, 73066, 73102, 73104, 73105, 73107, 73112, 73120, 73129, 73440, 73462, 73728, 74649, 74752, 74862, 74880, 75075, 77824, 78894, 82944, 83526, 92160, 92728, 92736, 92766, 92768, 92777, 92880, 92909, 92912, 92916, 92928, 92982, 92992, 92995, 93008, 93017, 93027, 93047, 93053, 93071, 93760, 93823, 93952, 94026, 94031, 94087, 94095, 94111, 94176, 94177, 94179, 94179, 94208, 100343, 100352, 101106, 110592, 110878, 110928, 110930, 110948, 110951, 110960, 111355, 113664, 113770, 113776, 113788, 113792, 113800, 113808, 113817, 113821, 113822, 119141, 119145, 119149, 119154, 119163, 119170, 119173, 119179, 119210, 119213, 119362, 119364, 119808, 119892, 119894, 119964, 119966, 119967, 119970, 119970, 119973, 119974, 119977, 119980, 119982, 119993, 119995, 119995, 119997, 120003, 120005, 120069, 120071, 120074, 120077, 120084, 120086, 120092, 120094, 120121, 120123, 120126, 120128, 120132, 120134, 120134, 120138, 120144, 120146, 120485, 120488, 120512, 120514, 120538, 120540, 120570, 120572, 120596, 120598, 120628, 120630, 120654, 120656, 120686, 120688, 120712, 120714, 120744, 120746, 120770, 120772, 120779, 120782, 120831, 121344, 121398, 121403, 121452, 121461, 121461, 121476, 121476, 121499, 121503, 121505, 121519, 122880, 122886, 122888, 122904, 122907, 122913, 122915, 122916, 122918, 122922, 123136, 123180, 123184, 123197, 123200, 123209, 123214, 123214, 123584, 123641, 124928, 125124, 125136, 125142, 125184, 125259, 125264, 125273, 126464, 126467, 126469, 126495, 126497, 126498, 126500, 126500, 126503, 126503, 126505, 126514, 126516, 126519, 126521, 126521, 126523, 126523, 126530, 126530, 126535, 126535, 126537, 126537, 126539, 126539, 126541, 126543, 126545, 126546, 126548, 126548, 126551, 126551, 126553, 126553, 126555, 126555, 126557, 126557, 126559, 126559, 126561, 126562, 126564, 126564, 126567, 126570, 126572, 126578, 126580, 126583, 126585, 126588, 126590, 126590, 126592, 126601, 126603, 126619, 126625, 126627, 126629, 126633, 126635, 126651, 131072, 173782, 173824, 177972, 177984, 178205, 178208, 183969, 183984, 191456, 194560, 195101, 917760, 917999]; /** - * Test for whether a single line comment's text contains a directive. + * Test for whether a single line comment with leading whitespace trimmed's text contains a directive. */ - var commentDirectiveRegExSingleLine = /^\s*\/\/\/?\s*@(ts-expect-error|ts-ignore)/; + var commentDirectiveRegExSingleLine = /^\/\/\/?\s*@(ts-expect-error|ts-ignore)/; /** - * Test for whether a multi-line comment's last line contains a directive. + * Test for whether a multi-line comment with leading whitespace trimmed's last line contains a directive. */ - var commentDirectiveRegExMultiLine = /^\s*(?:\/|\*)*\s*@(ts-expect-error|ts-ignore)/; + var commentDirectiveRegExMultiLine = /^(?:\/|\*)*\s*@(ts-expect-error|ts-ignore)/; function lookupInUnicodeMap(code, map) { // Bail out quickly if it couldn't possibly be in the map. if (code < map[0]) { @@ -9556,11 +9842,11 @@ var ts; } ts.couldStartTrivia = couldStartTrivia; /* @internal */ - function skipTrivia(text, pos, stopAfterLineBreak, stopAtComments) { - if (stopAtComments === void 0) { stopAtComments = false; } + function skipTrivia(text, pos, stopAfterLineBreak, stopAtComments, inJSDoc) { if (ts.positionIsSynthesized(pos)) { return pos; } + var canConsumeStar = false; // Keep in sync with couldStartTrivia while (true) { var ch = text.charCodeAt(pos); @@ -9575,6 +9861,7 @@ var ts; if (stopAfterLineBreak) { return pos; } + canConsumeStar = !!inJSDoc; continue; case 9 /* tab */: case 11 /* verticalTab */: @@ -9594,6 +9881,7 @@ var ts; } pos++; } + canConsumeStar = false; continue; } if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { @@ -9605,6 +9893,7 @@ var ts; } pos++; } + canConsumeStar = false; continue; } break; @@ -9614,12 +9903,21 @@ var ts; case 62 /* greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos); + canConsumeStar = false; continue; } break; case 35 /* hash */: if (pos === 0 && isShebangTrivia(text, pos)) { pos = scanShebangTrivia(text, pos); + canConsumeStar = false; + continue; + } + break; + case 42 /* asterisk */: + if (canConsumeStar) { + pos++; + canConsumeStar = false; continue; } break; @@ -9907,8 +10205,8 @@ var ts; 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 === 78 /* Identifier */ || token > 115 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 80 /* FirstReservedWord */ && token <= 115 /* LastReservedWord */; }, + 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; }, getCommentDirectives: function () { return commentDirectives; }, getNumericLiteralFlags: function () { return tokenFlags & 1008 /* NumericLiteralFlags */; }, @@ -9923,7 +10221,9 @@ var ts; reScanJsxAttributeValue: reScanJsxAttributeValue, reScanJsxToken: reScanJsxToken, reScanLessThanToken: reScanLessThanToken, + reScanHashToken: reScanHashToken, reScanQuestionToken: reScanQuestionToken, + reScanInvalidIdentifier: reScanInvalidIdentifier, scanJsxToken: scanJsxToken, scanJsDocToken: scanJsDocToken, scan: scan, @@ -10432,7 +10732,7 @@ var ts; } } } - return token = 78 /* Identifier */; + return token = 79 /* Identifier */; } function scanBinaryOrOctalDigits(base) { var value = ""; @@ -10581,19 +10881,19 @@ var ts; return token = scanTemplateAndSetTokenValue(/* isTaggedTemplate */ false); case 37 /* percent */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 68 /* PercentEqualsToken */; + return pos += 2, token = 69 /* 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 = 75 /* AmpersandAmpersandEqualsToken */; + return pos += 3, token = 76 /* AmpersandAmpersandEqualsToken */; } return pos += 2, token = 55 /* AmpersandAmpersandToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 72 /* AmpersandEqualsToken */; + return pos += 2, token = 73 /* AmpersandEqualsToken */; } pos++; return token = 50 /* AmpersandToken */; @@ -10605,11 +10905,11 @@ var ts; return token = 21 /* CloseParenToken */; case 42 /* asterisk */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 65 /* AsteriskEqualsToken */; + return pos += 2, token = 66 /* AsteriskEqualsToken */; } if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 66 /* AsteriskAsteriskEqualsToken */; + return pos += 3, token = 67 /* AsteriskAsteriskEqualsToken */; } return pos += 2, token = 42 /* AsteriskAsteriskToken */; } @@ -10625,7 +10925,7 @@ var ts; return pos += 2, token = 45 /* PlusPlusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 63 /* PlusEqualsToken */; + return pos += 2, token = 64 /* PlusEqualsToken */; } pos++; return token = 39 /* PlusToken */; @@ -10637,7 +10937,7 @@ var ts; return pos += 2, token = 46 /* MinusMinusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 64 /* MinusEqualsToken */; + return pos += 2, token = 65 /* MinusEqualsToken */; } pos++; return token = 40 /* MinusToken */; @@ -10705,7 +11005,7 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 67 /* SlashEqualsToken */; + return pos += 2, token = 68 /* SlashEqualsToken */; } pos++; return token = 43 /* SlashToken */; @@ -10782,7 +11082,7 @@ var ts; } if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 69 /* LessThanLessThanEqualsToken */; + return pos += 3, token = 70 /* LessThanLessThanEqualsToken */; } return pos += 2, token = 47 /* LessThanLessThanToken */; } @@ -10816,7 +11116,7 @@ var ts; return pos += 2, token = 38 /* EqualsGreaterThanToken */; } pos++; - return token = 62 /* EqualsToken */; + return token = 63 /* EqualsToken */; case 62 /* greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -10835,7 +11135,7 @@ var ts; } if (text.charCodeAt(pos + 1) === 63 /* question */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 76 /* QuestionQuestionEqualsToken */; + return pos += 3, token = 77 /* QuestionQuestionEqualsToken */; } return pos += 2, token = 60 /* QuestionQuestionToken */; } @@ -10849,7 +11149,7 @@ var ts; return token = 23 /* CloseBracketToken */; case 94 /* caret */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 77 /* CaretEqualsToken */; + return pos += 2, token = 78 /* CaretEqualsToken */; } pos++; return token = 52 /* CaretToken */; @@ -10868,12 +11168,12 @@ var ts; } if (text.charCodeAt(pos + 1) === 124 /* bar */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 74 /* BarBarEqualsToken */; + return pos += 3, token = 75 /* BarBarEqualsToken */; } return pos += 2, token = 56 /* BarBarToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 73 /* BarEqualsToken */; + return pos += 2, token = 74 /* BarEqualsToken */; } pos++; return token = 51 /* BarToken */; @@ -10911,30 +11211,12 @@ var ts; return token = 0 /* Unknown */; } pos++; - if (isIdentifierStart(ch = text.charCodeAt(pos), languageVersion)) { - pos++; - while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion)) - pos++; - tokenValue = text.substring(tokenPos, pos); - if (ch === 92 /* backslash */) { - tokenValue += scanIdentifierParts(); - } - } - else { - tokenValue = "#"; - error(ts.Diagnostics.Invalid_character); - } - return token = 79 /* PrivateIdentifier */; + scanIdentifier(codePointAt(text, pos), languageVersion); + return token = 80 /* PrivateIdentifier */; default: - if (isIdentifierStart(ch, languageVersion)) { - pos += charSize(ch); - while (pos < end && isIdentifierPart(ch = codePointAt(text, pos), languageVersion)) - pos += charSize(ch); - tokenValue = text.substring(tokenPos, pos); - if (ch === 92 /* backslash */) { - tokenValue += scanIdentifierParts(); - } - return token = getIdentifierToken(); + var identifierKind = scanIdentifier(ch, languageVersion); + if (identifierKind) { + return token = identifierKind; } else if (isWhiteSpaceSingleLine(ch)) { pos += charSize(ch); @@ -10951,17 +11233,42 @@ var ts; } } } + function reScanInvalidIdentifier() { + ts.Debug.assert(token === 0 /* 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 */); + if (identifierKind) { + return token = identifierKind; + } + pos += charSize(ch); + return token; // Still `SyntaKind.Unknown` + } + function scanIdentifier(startCharacter, languageVersion) { + var ch = startCharacter; + if (isIdentifierStart(ch, languageVersion)) { + pos += charSize(ch); + while (pos < end && isIdentifierPart(ch = codePointAt(text, pos), languageVersion)) + pos += charSize(ch); + tokenValue = text.substring(tokenPos, pos); + if (ch === 92 /* 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 = 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + return pos += 3, token = 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */; } return pos += 2, token = 49 /* GreaterThanGreaterThanGreaterThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 70 /* GreaterThanGreaterThanEqualsToken */; + return pos += 2, token = 71 /* GreaterThanGreaterThanEqualsToken */; } pos++; return token = 48 /* GreaterThanGreaterThanToken */; @@ -10974,12 +11281,12 @@ var ts; return token; } function reScanAsteriskEqualsToken() { - ts.Debug.assert(token === 65 /* AsteriskEqualsToken */, "'reScanAsteriskEqualsToken' should only be called on a '*='"); + ts.Debug.assert(token === 66 /* AsteriskEqualsToken */, "'reScanAsteriskEqualsToken' should only be called on a '*='"); pos = tokenPos + 1; - return token = 62 /* EqualsToken */; + return token = 63 /* EqualsToken */; } function reScanSlashToken() { - if (token === 43 /* SlashToken */ || token === 67 /* SlashEqualsToken */) { + if (token === 43 /* SlashToken */ || token === 68 /* SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -11029,7 +11336,7 @@ var ts; return token; } function appendIfCommentDirective(commentDirectives, text, commentDirectiveRegEx, lineStart) { - var type = getDirectiveFromComment(text, commentDirectiveRegEx); + var type = getDirectiveFromComment(ts.trimStringStart(text), commentDirectiveRegEx); if (type === undefined) { return commentDirectives; } @@ -11063,9 +11370,10 @@ var ts; pos = tokenPos; return token = scanTemplateAndSetTokenValue(/* isTaggedTemplate */ true); } - function reScanJsxToken() { + function reScanJsxToken(allowMultilineJsxText) { + if (allowMultilineJsxText === void 0) { allowMultilineJsxText = true; } pos = tokenPos = startPos; - return token = scanJsxToken(); + return token = scanJsxToken(allowMultilineJsxText); } function reScanLessThanToken() { if (token === 47 /* LessThanLessThanToken */) { @@ -11074,12 +11382,20 @@ var ts; } return token; } + function reScanHashToken() { + if (token === 80 /* PrivateIdentifier */) { + pos = tokenPos + 1; + return token = 62 /* HashToken */; + } + return token; + } function reScanQuestionToken() { ts.Debug.assert(token === 60 /* QuestionQuestionToken */, "'reScanQuestionToken' should only be called on a '??'"); pos = tokenPos + 1; return token = 57 /* QuestionToken */; } - function scanJsxToken() { + function scanJsxToken(allowMultilineJsxText) { + if (allowMultilineJsxText === void 0) { allowMultilineJsxText = true; } startPos = tokenPos = pos; if (pos >= end) { return token = 1 /* EndOfFileToken */; @@ -11099,15 +11415,9 @@ var ts; } // First non-whitespace character on this line. var firstNonWhitespace = 0; - var lastNonWhitespace = -1; // These initial values are special because the first line is: // firstNonWhitespace = 0 to indicate that we want leading whitespace, while (pos < end) { - // We want to keep track of the last non-whitespace (but including - // newlines character for hitting the end of the JSX Text region) - if (!isWhiteSpaceSingleLine(char)) { - lastNonWhitespace = pos; - } char = text.charCodeAt(pos); if (char === 123 /* openBrace */) { break; @@ -11125,8 +11435,6 @@ var ts; if (char === 125 /* closeBrace */) { error(ts.Diagnostics.Unexpected_token_Did_you_mean_or_rbrace, pos, 1); } - if (lastNonWhitespace > 0) - lastNonWhitespace++; // FirstNonWhitespace is 0, then we only see whitespaces so far. If we see a linebreak, we want to ignore that whitespaces. // i.e (- : whitespace) //
---- @@ -11136,13 +11444,17 @@ var ts; if (isLineBreak(char) && firstNonWhitespace === 0) { firstNonWhitespace = -1; } + else if (!allowMultilineJsxText && isLineBreak(char) && firstNonWhitespace > 0) { + // Stop JsxText on each line during formatting. This allows the formatter to + // indent each line correctly. + break; + } else if (!isWhiteSpaceLike(char)) { firstNonWhitespace = pos; } pos++; } - var endPosition = lastNonWhitespace === -1 ? pos : lastNonWhitespace; - tokenValue = text.substring(startPos, endPosition); + tokenValue = text.substring(startPos, pos); return firstNonWhitespace === -1 ? 12 /* JsxTextAllWhiteSpaces */ : 11 /* JsxText */; } // Scans a JSX identifier; these differ from normal identifiers in that @@ -11165,6 +11477,7 @@ var ts; tokenValue += ":"; pos++; namespaceSeparator = true; + token = 79 /* Identifier */; // swap from keyword kind to identifier kind continue; } var oldPos = pos; @@ -11239,13 +11552,15 @@ var ts; case 62 /* greaterThan */: return token = 31 /* GreaterThanToken */; case 61 /* equals */: - return token = 62 /* EqualsToken */; + 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 */: pos--; var extendedCookedChar = peekExtendedUnicodeEscape(); @@ -11421,6 +11736,8 @@ var ts; switch (options.target) { case 99 /* ESNext */: return "lib.esnext.full.d.ts"; + case 8 /* ES2021 */: + return "lib.es2021.full.d.ts"; case 7 /* ES2020 */: return "lib.es2020.full.d.ts"; case 6 /* ES2019 */: @@ -11639,9 +11956,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 159 /* TypeParameter */) { + if (d && d.kind === 161 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (isFunctionLike(current) || isClassLike(current) || current.kind === 253 /* InterfaceDeclaration */) { + if (isFunctionLike(current) || isClassLike(current) || current.kind === 255 /* InterfaceDeclaration */) { return current; } } @@ -11649,7 +11966,7 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node, parent) { - return ts.hasSyntacticModifier(node, 92 /* ParameterPropertyModifier */) && parent.kind === 166 /* Constructor */; + return ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */) && parent.kind === 168 /* Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -11679,14 +11996,14 @@ var ts; node = walkUpBindingElementsAndPatterns(node); } var flags = getFlags(node); - if (node.kind === 249 /* VariableDeclaration */) { + if (node.kind === 251 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 250 /* VariableDeclarationList */) { + if (node && node.kind === 252 /* VariableDeclarationList */) { flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 232 /* VariableStatement */) { + if (node && node.kind === 234 /* VariableStatement */) { flags |= getFlags(node); } return flags; @@ -11704,19 +12021,22 @@ var ts; // nodes like variable declarations and binding elements can returned a view of their flags // that includes the modifiers from their container. i.e. flags like export/declare aren't // stored on the variable declaration directly, but on the containing variable statement - // (if it has one). Similarly, flags for let/const are store on the variable declaration + // (if it has one). Similarly, flags for let/const are stored on the variable declaration // list. By calling this function, all those flags are combined so that the client can treat // the node as if it actually had those flags. function getCombinedNodeFlags(node) { return getCombinedFlags(node, function (n) { return n.flags; }); } ts.getCombinedNodeFlags = getCombinedNodeFlags; + /* @internal */ + ts.supportedLocaleDirectories = ["cs", "de", "es", "fr", "it", "ja", "ko", "pl", "pt-br", "ru", "tr", "zh-cn", "zh-tw"]; /** * Checks to see if the locale is in the appropriate format, * and if it is, attempts to set the appropriate language. */ function validateLocaleAndSetLanguage(locale, sys, errors) { - var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase()); + var lowerCaseLocale = locale.toLowerCase(); + var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(lowerCaseLocale); if (!matchResult) { if (errors) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1, "en", "ja-jp")); @@ -11727,7 +12047,7 @@ var ts; var territory = matchResult[3]; // First try the entire locale, then fall back to just language if that's all we have. // Either ways do not fail, and fallback to the English diagnostic strings. - if (!trySetLanguageAndTerritory(language, territory, errors)) { + if (ts.contains(ts.supportedLocaleDirectories, lowerCaseLocale) && !trySetLanguageAndTerritory(language, territory, errors)) { trySetLanguageAndTerritory(language, /*territory*/ undefined, errors); } // Set the UI locale for string collation @@ -11834,7 +12154,7 @@ var ts; } ts.idText = idText; function symbolName(symbol) { - if (symbol.valueDeclaration && isPrivateIdentifierPropertyDeclaration(symbol.valueDeclaration)) { + if (symbol.valueDeclaration && isPrivateIdentifierClassElementDeclaration(symbol.valueDeclaration)) { return idText(symbol.valueDeclaration.name); } return unescapeLeadingUnderscores(symbol.escapedName); @@ -11856,30 +12176,30 @@ var ts; } // Covers remaining cases (returning undefined if none match). switch (hostNode.kind) { - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } break; - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: var expr = hostNode.expression; - if (expr.kind === 216 /* BinaryExpression */ && expr.operatorToken.kind === 62 /* EqualsToken */) { + if (expr.kind === 218 /* BinaryExpression */ && expr.operatorToken.kind === 63 /* EqualsToken */) { expr = expr.left; } switch (expr.kind) { - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return expr.name; - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; } } break; - case 207 /* ParenthesizedExpression */: { + case 209 /* ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 245 /* LabeledStatement */: { + case 247 /* LabeledStatement */: { if (isDeclaration(hostNode.statement) || isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -11914,18 +12234,18 @@ var ts; /** @internal */ function getNonAssignedNameOfDeclaration(declaration) { switch (declaration.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return declaration; - case 333 /* JSDocPropertyTag */: - case 326 /* JSDocParameterTag */: { + case 341 /* JSDocPropertyTag */: + case 334 /* JSDocParameterTag */: { var name = declaration.name; - if (name.kind === 157 /* QualifiedName */) { + if (name.kind === 159 /* QualifiedName */) { return name.right; } break; } - case 203 /* CallExpression */: - case 216 /* BinaryExpression */: { + case 205 /* CallExpression */: + case 218 /* BinaryExpression */: { var expr_1 = declaration; switch (ts.getAssignmentDeclarationKind(expr_1)) { case 1 /* ExportsProperty */: @@ -11941,15 +12261,15 @@ var ts; return undefined; } } - case 331 /* JSDocTypedefTag */: + case 339 /* JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 325 /* JSDocEnumTag */: + case 333 /* JSDocEnumTag */: return nameForNamelessJSDocTypedef(declaration); - case 266 /* ExportAssignment */: { + case 268 /* ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: var expr = declaration; if (ts.isBindableStaticElementAccessExpression(expr)) { return expr.argumentExpression; @@ -11962,7 +12282,7 @@ var ts; if (declaration === undefined) return undefined; return getNonAssignedNameOfDeclaration(declaration) || - (ts.isFunctionExpression(declaration) || ts.isClassExpression(declaration) ? getAssignedName(declaration) : undefined); + (ts.isFunctionExpression(declaration) || ts.isArrowFunction(declaration) || ts.isClassExpression(declaration) ? getAssignedName(declaration) : undefined); } ts.getNameOfDeclaration = getNameOfDeclaration; /*@internal*/ @@ -12115,6 +12435,10 @@ var ts; return getFirstJSDocTag(node, ts.isJSDocReadonlyTag, /*noCache*/ true); } ts.getJSDocReadonlyTagNoCache = getJSDocReadonlyTagNoCache; + function getJSDocOverrideTagNoCache(node) { + return getFirstJSDocTag(node, ts.isJSDocOverrideTag, /*noCache*/ true); + } + ts.getJSDocOverrideTagNoCache = getJSDocOverrideTagNoCache; /** Gets the JSDoc deprecated tag for the node if present */ function getJSDocDeprecatedTag(node) { return getFirstJSDocTag(node, ts.isJSDocDeprecatedTag); @@ -12235,6 +12559,15 @@ var ts; return getJSDocTags(node).filter(function (doc) { return doc.kind === kind; }); } ts.getAllJSDocTagsOfKind = getAllJSDocTagsOfKind; + /** 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) { + // TODO: Other kinds here + return c.kind === 315 /* JSDocText */ ? c.text : "{@link " + (c.name ? ts.entityNameToString(c.name) + " " : "") + c.text + "}"; + }).join(""); + } + ts.getTextOfJSDocComment = getTextOfJSDocComment; /** * Gets the effective type parameters. If the node was parsed in a * JavaScript file, gets the type parameters from the `@template` tag from JSDoc. @@ -12244,7 +12577,7 @@ var ts; return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 311 /* JSDocComment */); + ts.Debug.assert(node.parent.kind === 314 /* JSDocComment */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -12270,13 +12603,13 @@ var ts; } ts.getEffectiveConstraintOfTypeParameter = getEffectiveConstraintOfTypeParameter; // #region - function isIdentifierOrPrivateIdentifier(node) { - return node.kind === 78 /* Identifier */ || node.kind === 79 /* PrivateIdentifier */; + function isMemberName(node) { + return node.kind === 79 /* Identifier */ || node.kind === 80 /* PrivateIdentifier */; } - ts.isIdentifierOrPrivateIdentifier = isIdentifierOrPrivateIdentifier; + ts.isMemberName = isMemberName; /* @internal */ function isGetOrSetAccessorDeclaration(node) { - return node.kind === 168 /* SetAccessor */ || node.kind === 167 /* GetAccessor */; + return node.kind === 170 /* SetAccessor */ || node.kind === 169 /* GetAccessor */; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; function isPropertyAccessChain(node) { @@ -12294,10 +12627,10 @@ var ts; function isOptionalChain(node) { var kind = node.kind; return !!(node.flags & 32 /* OptionalChain */) && - (kind === 201 /* PropertyAccessExpression */ - || kind === 202 /* ElementAccessExpression */ - || kind === 203 /* CallExpression */ - || kind === 225 /* NonNullExpression */); + (kind === 203 /* PropertyAccessExpression */ + || kind === 204 /* ElementAccessExpression */ + || kind === 205 /* CallExpression */ + || kind === 227 /* NonNullExpression */); } ts.isOptionalChain = isOptionalChain; /* @internal */ @@ -12332,7 +12665,7 @@ var ts; } ts.isOutermostOptionalChain = isOutermostOptionalChain; function isNullishCoalesce(node) { - return node.kind === 216 /* BinaryExpression */ && node.operatorToken.kind === 60 /* QuestionQuestionToken */; + return node.kind === 218 /* BinaryExpression */ && node.operatorToken.kind === 60 /* QuestionQuestionToken */; } ts.isNullishCoalesce = isNullishCoalesce; function isConstTypeReference(node) { @@ -12349,17 +12682,17 @@ var ts; } ts.isNonNullChain = isNonNullChain; function isBreakOrContinueStatement(node) { - return node.kind === 241 /* BreakStatement */ || node.kind === 240 /* ContinueStatement */; + return node.kind === 243 /* BreakStatement */ || node.kind === 242 /* ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isNamedExportBindings(node) { - return node.kind === 269 /* NamespaceExport */ || node.kind === 268 /* NamedExports */; + return node.kind === 271 /* NamespaceExport */ || node.kind === 270 /* NamedExports */; } ts.isNamedExportBindings = isNamedExportBindings; function isUnparsedTextLike(node) { switch (node.kind) { - case 294 /* UnparsedText */: - case 295 /* UnparsedInternalText */: + case 296 /* UnparsedText */: + case 297 /* UnparsedInternalText */: return true; default: return false; @@ -12368,12 +12701,12 @@ var ts; ts.isUnparsedTextLike = isUnparsedTextLike; function isUnparsedNode(node) { return isUnparsedTextLike(node) || - node.kind === 292 /* UnparsedPrologue */ || - node.kind === 296 /* UnparsedSyntheticReference */; + node.kind === 294 /* UnparsedPrologue */ || + node.kind === 298 /* UnparsedSyntheticReference */; } ts.isUnparsedNode = isUnparsedNode; function isJSDocPropertyLikeTag(node) { - return node.kind === 333 /* JSDocPropertyTag */ || node.kind === 326 /* JSDocParameterTag */; + return node.kind === 341 /* JSDocPropertyTag */ || node.kind === 334 /* JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; // #endregion @@ -12389,16 +12722,25 @@ var ts; ts.isNode = isNode; /* @internal */ function isNodeKind(kind) { - return kind >= 157 /* FirstNode */; + return kind >= 159 /* FirstNode */; } ts.isNodeKind = isNodeKind; + /** + * True if kind is of some token syntax kind. + * For example, this is true for an IfKeyword but not for an IfStatement. + * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. + */ + function isTokenKind(kind) { + return kind >= 0 /* FirstToken */ && kind <= 158 /* LastToken */; + } + ts.isTokenKind = isTokenKind; /** * True if node is of some token syntax kind. * For example, this is true for an IfKeyword but not for an IfStatement. * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. */ function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 156 /* LastToken */; + return isTokenKind(n.kind); } ts.isToken = isToken; // Node Arrays @@ -12439,13 +12781,13 @@ var ts; ts.isImportOrExportSpecifier = isImportOrExportSpecifier; function isTypeOnlyImportOrExportDeclaration(node) { switch (node.kind) { - case 265 /* ImportSpecifier */: - case 270 /* ExportSpecifier */: + case 267 /* ImportSpecifier */: + case 272 /* ExportSpecifier */: return node.parent.parent.isTypeOnly; - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: return node.parent.isTypeOnly; - case 262 /* ImportClause */: - case 260 /* ImportEqualsDeclaration */: + case 264 /* ImportClause */: + case 262 /* ImportEqualsDeclaration */: return node.isTypeOnly; default: return false; @@ -12464,10 +12806,10 @@ var ts; ts.isGeneratedIdentifier = isGeneratedIdentifier; // Private Identifiers /*@internal*/ - function isPrivateIdentifierPropertyDeclaration(node) { - return ts.isPropertyDeclaration(node) && ts.isPrivateIdentifier(node.name); + function isPrivateIdentifierClassElementDeclaration(node) { + return (ts.isPropertyDeclaration(node) || isMethodOrAccessor(node)) && ts.isPrivateIdentifier(node.name); } - ts.isPrivateIdentifierPropertyDeclaration = isPrivateIdentifierPropertyDeclaration; + ts.isPrivateIdentifierClassElementDeclaration = isPrivateIdentifierClassElementDeclaration; /*@internal*/ function isPrivateIdentifierPropertyAccessExpression(node) { return ts.isPropertyAccessExpression(node) && ts.isPrivateIdentifier(node.name); @@ -12477,17 +12819,18 @@ var ts; /* @internal */ function isModifierKind(token) { switch (token) { - case 125 /* AbstractKeyword */: - case 129 /* AsyncKeyword */: - case 84 /* ConstKeyword */: - case 133 /* DeclareKeyword */: - case 87 /* DefaultKeyword */: - case 92 /* ExportKeyword */: - case 122 /* PublicKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 142 /* ReadonlyKeyword */: - case 123 /* StaticKeyword */: + case 126 /* AbstractKeyword */: + case 130 /* AsyncKeyword */: + case 85 /* ConstKeyword */: + case 134 /* DeclareKeyword */: + case 88 /* DefaultKeyword */: + case 93 /* ExportKeyword */: + case 123 /* PublicKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + case 143 /* ReadonlyKeyword */: + case 124 /* StaticKeyword */: + case 157 /* OverrideKeyword */: return true; } return false; @@ -12495,12 +12838,12 @@ var ts; ts.isModifierKind = isModifierKind; /* @internal */ function isParameterPropertyModifier(kind) { - return !!(ts.modifierToFlag(kind) & 92 /* ParameterPropertyModifier */); + return !!(ts.modifierToFlag(kind) & 16476 /* ParameterPropertyModifier */); } ts.isParameterPropertyModifier = isParameterPropertyModifier; /* @internal */ function isClassMemberModifier(idToken) { - return isParameterPropertyModifier(idToken) || idToken === 123 /* StaticKeyword */; + return isParameterPropertyModifier(idToken) || idToken === 124 /* StaticKeyword */ || idToken === 157 /* OverrideKeyword */; } ts.isClassMemberModifier = isClassMemberModifier; function isModifier(node) { @@ -12509,29 +12852,29 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 157 /* QualifiedName */ - || kind === 78 /* Identifier */; + return kind === 159 /* QualifiedName */ + || kind === 79 /* Identifier */; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 78 /* Identifier */ - || kind === 79 /* PrivateIdentifier */ + return kind === 79 /* Identifier */ + || kind === 80 /* PrivateIdentifier */ || kind === 10 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 158 /* ComputedPropertyName */; + || kind === 160 /* ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; - return kind === 78 /* Identifier */ - || kind === 196 /* ObjectBindingPattern */ - || kind === 197 /* ArrayBindingPattern */; + return kind === 79 /* Identifier */ + || kind === 198 /* ObjectBindingPattern */ + || kind === 199 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions function isFunctionLike(node) { - return node && isFunctionLikeKind(node.kind); + return !!node && isFunctionLikeKind(node.kind); } ts.isFunctionLike = isFunctionLike; /* @internal */ @@ -12541,13 +12884,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 251 /* FunctionDeclaration */: - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 253 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return true; default: return false; @@ -12556,14 +12899,14 @@ var ts; /* @internal */ function isFunctionLikeKind(kind) { switch (kind) { - case 164 /* MethodSignature */: - case 169 /* CallSignature */: - case 313 /* JSDocSignature */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: - case 174 /* FunctionType */: - case 308 /* JSDocFunctionType */: - case 175 /* ConstructorType */: + case 166 /* MethodSignature */: + case 171 /* CallSignature */: + case 317 /* JSDocSignature */: + case 172 /* ConstructSignature */: + case 173 /* IndexSignature */: + case 176 /* FunctionType */: + case 311 /* JSDocFunctionType */: + case 177 /* ConstructorType */: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -12578,29 +12921,29 @@ var ts; // Classes function isClassElement(node) { var kind = node.kind; - return kind === 166 /* Constructor */ - || kind === 163 /* PropertyDeclaration */ - || kind === 165 /* MethodDeclaration */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */ - || kind === 171 /* IndexSignature */ - || kind === 229 /* SemicolonClassElement */; + return kind === 168 /* Constructor */ + || kind === 165 /* PropertyDeclaration */ + || kind === 167 /* MethodDeclaration */ + || kind === 169 /* GetAccessor */ + || kind === 170 /* SetAccessor */ + || kind === 173 /* IndexSignature */ + || kind === 231 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 252 /* ClassDeclaration */ || node.kind === 221 /* ClassExpression */); + return node && (node.kind === 254 /* ClassDeclaration */ || node.kind === 223 /* ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 167 /* GetAccessor */ || node.kind === 168 /* SetAccessor */); + return node && (node.kind === 169 /* GetAccessor */ || node.kind === 170 /* SetAccessor */); } ts.isAccessor = isAccessor; /* @internal */ function isMethodOrAccessor(node) { switch (node.kind) { - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return true; default: return false; @@ -12610,11 +12953,11 @@ var ts; // Type members function isTypeElement(node) { var kind = node.kind; - return kind === 170 /* ConstructSignature */ - || kind === 169 /* CallSignature */ - || kind === 162 /* PropertySignature */ - || kind === 164 /* MethodSignature */ - || kind === 171 /* IndexSignature */; + return kind === 172 /* ConstructSignature */ + || kind === 171 /* CallSignature */ + || kind === 164 /* PropertySignature */ + || kind === 166 /* MethodSignature */ + || kind === 173 /* IndexSignature */; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -12623,12 +12966,12 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 288 /* PropertyAssignment */ - || kind === 289 /* ShorthandPropertyAssignment */ - || kind === 290 /* SpreadAssignment */ - || kind === 165 /* MethodDeclaration */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */; + return kind === 290 /* PropertyAssignment */ + || kind === 291 /* ShorthandPropertyAssignment */ + || kind === 292 /* SpreadAssignment */ + || kind === 167 /* MethodDeclaration */ + || kind === 169 /* GetAccessor */ + || kind === 170 /* SetAccessor */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type @@ -12643,8 +12986,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 174 /* FunctionType */: - case 175 /* ConstructorType */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: return true; } return false; @@ -12655,8 +12998,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 197 /* ArrayBindingPattern */ - || kind === 196 /* ObjectBindingPattern */; + return kind === 199 /* ArrayBindingPattern */ + || kind === 198 /* ObjectBindingPattern */; } return false; } @@ -12664,15 +13007,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 199 /* ArrayLiteralExpression */ - || kind === 200 /* ObjectLiteralExpression */; + return kind === 201 /* ArrayLiteralExpression */ + || kind === 202 /* ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 198 /* BindingElement */ - || kind === 222 /* OmittedExpression */; + return kind === 200 /* BindingElement */ + || kind === 224 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -12681,9 +13024,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 249 /* VariableDeclaration */: - case 160 /* Parameter */: - case 198 /* BindingElement */: + case 251 /* VariableDeclaration */: + case 162 /* Parameter */: + case 200 /* BindingElement */: return true; } return false; @@ -12704,8 +13047,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 196 /* ObjectBindingPattern */: - case 200 /* ObjectLiteralExpression */: + case 198 /* ObjectBindingPattern */: + case 202 /* ObjectLiteralExpression */: return true; } return false; @@ -12717,8 +13060,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 197 /* ArrayBindingPattern */: - case 199 /* ArrayLiteralExpression */: + case 199 /* ArrayBindingPattern */: + case 201 /* ArrayLiteralExpression */: return true; } return false; @@ -12727,26 +13070,26 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 201 /* PropertyAccessExpression */ - || kind === 157 /* QualifiedName */ - || kind === 195 /* ImportType */; + return kind === 203 /* PropertyAccessExpression */ + || kind === 159 /* QualifiedName */ + || kind === 197 /* ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 201 /* PropertyAccessExpression */ - || kind === 157 /* QualifiedName */; + return kind === 203 /* PropertyAccessExpression */ + || kind === 159 /* QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 275 /* JsxOpeningElement */: - case 274 /* JsxSelfClosingElement */: - case 203 /* CallExpression */: - case 204 /* NewExpression */: - case 205 /* TaggedTemplateExpression */: - case 161 /* Decorator */: + case 277 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: + case 207 /* TaggedTemplateExpression */: + case 163 /* Decorator */: return true; default: return false; @@ -12754,12 +13097,12 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 203 /* CallExpression */ || node.kind === 204 /* NewExpression */; + return node.kind === 205 /* CallExpression */ || node.kind === 206 /* NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 218 /* TemplateExpression */ + return kind === 220 /* TemplateExpression */ || kind === 14 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; @@ -12770,34 +13113,34 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: - case 204 /* NewExpression */: - case 203 /* CallExpression */: - case 273 /* JsxElement */: - case 274 /* JsxSelfClosingElement */: - case 277 /* JsxFragment */: - case 205 /* TaggedTemplateExpression */: - case 199 /* ArrayLiteralExpression */: - case 207 /* ParenthesizedExpression */: - case 200 /* ObjectLiteralExpression */: - case 221 /* ClassExpression */: - case 208 /* FunctionExpression */: - case 78 /* Identifier */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: + case 206 /* NewExpression */: + case 205 /* CallExpression */: + case 275 /* JsxElement */: + case 276 /* JsxSelfClosingElement */: + case 279 /* JsxFragment */: + case 207 /* TaggedTemplateExpression */: + case 201 /* ArrayLiteralExpression */: + case 209 /* ParenthesizedExpression */: + case 202 /* ObjectLiteralExpression */: + case 223 /* ClassExpression */: + case 210 /* FunctionExpression */: + case 79 /* Identifier */: case 13 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 218 /* TemplateExpression */: - case 94 /* FalseKeyword */: - case 103 /* NullKeyword */: - case 107 /* ThisKeyword */: - case 109 /* TrueKeyword */: - case 105 /* SuperKeyword */: - case 225 /* NonNullExpression */: - case 226 /* MetaProperty */: - case 99 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression + case 220 /* TemplateExpression */: + case 95 /* FalseKeyword */: + case 104 /* NullKeyword */: + case 108 /* ThisKeyword */: + case 110 /* TrueKeyword */: + case 106 /* SuperKeyword */: + case 227 /* NonNullExpression */: + case 228 /* MetaProperty */: + case 100 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: return false; @@ -12810,13 +13153,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 214 /* PrefixUnaryExpression */: - case 215 /* PostfixUnaryExpression */: - case 210 /* DeleteExpression */: - case 211 /* TypeOfExpression */: - case 212 /* VoidExpression */: - case 213 /* AwaitExpression */: - case 206 /* TypeAssertionExpression */: + case 216 /* PrefixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: + case 212 /* DeleteExpression */: + case 213 /* TypeOfExpression */: + case 214 /* VoidExpression */: + case 215 /* AwaitExpression */: + case 208 /* TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -12825,9 +13168,9 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: return true; - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return expr.operator === 45 /* PlusPlusToken */ || expr.operator === 46 /* MinusMinusToken */; default: @@ -12846,15 +13189,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 217 /* ConditionalExpression */: - case 219 /* YieldExpression */: - case 209 /* ArrowFunction */: - case 216 /* BinaryExpression */: - case 220 /* SpreadElement */: - case 224 /* AsExpression */: - case 222 /* OmittedExpression */: - case 337 /* CommaListExpression */: - case 336 /* PartiallyEmittedExpression */: + case 219 /* ConditionalExpression */: + case 221 /* YieldExpression */: + case 211 /* ArrowFunction */: + case 218 /* BinaryExpression */: + case 222 /* SpreadElement */: + case 226 /* AsExpression */: + case 224 /* OmittedExpression */: + case 345 /* CommaListExpression */: + case 344 /* PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -12862,8 +13205,8 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 206 /* TypeAssertionExpression */ - || kind === 224 /* AsExpression */; + return kind === 208 /* TypeAssertionExpression */ + || kind === 226 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ @@ -12874,13 +13217,13 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: return true; - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -12909,7 +13252,7 @@ var ts; ts.isExternalModuleIndicator = isExternalModuleIndicator; /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 238 /* ForInStatement */ || node.kind === 239 /* ForOfStatement */; + return node.kind === 240 /* ForInStatement */ || node.kind === 241 /* ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -12933,114 +13276,114 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 257 /* ModuleBlock */ - || kind === 256 /* ModuleDeclaration */ - || kind === 78 /* Identifier */; + return kind === 259 /* ModuleBlock */ + || kind === 258 /* ModuleDeclaration */ + || kind === 79 /* Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 257 /* ModuleBlock */ - || kind === 256 /* ModuleDeclaration */; + return kind === 259 /* ModuleBlock */ + || kind === 258 /* ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; - return kind === 78 /* Identifier */ - || kind === 256 /* ModuleDeclaration */; + return kind === 79 /* Identifier */ + || kind === 258 /* ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 264 /* NamedImports */ - || kind === 263 /* NamespaceImport */; + return kind === 266 /* NamedImports */ + || kind === 265 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 256 /* ModuleDeclaration */ || node.kind === 255 /* EnumDeclaration */; + return node.kind === 258 /* ModuleDeclaration */ || node.kind === 257 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 209 /* ArrowFunction */ - || kind === 198 /* BindingElement */ - || kind === 252 /* ClassDeclaration */ - || kind === 221 /* ClassExpression */ - || kind === 166 /* Constructor */ - || kind === 255 /* EnumDeclaration */ - || kind === 291 /* EnumMember */ - || kind === 270 /* ExportSpecifier */ - || kind === 251 /* FunctionDeclaration */ - || kind === 208 /* FunctionExpression */ - || kind === 167 /* GetAccessor */ - || kind === 262 /* ImportClause */ - || kind === 260 /* ImportEqualsDeclaration */ - || kind === 265 /* ImportSpecifier */ - || kind === 253 /* InterfaceDeclaration */ - || kind === 280 /* JsxAttribute */ - || kind === 165 /* MethodDeclaration */ - || kind === 164 /* MethodSignature */ - || kind === 256 /* ModuleDeclaration */ - || kind === 259 /* NamespaceExportDeclaration */ - || kind === 263 /* NamespaceImport */ - || kind === 269 /* NamespaceExport */ - || kind === 160 /* Parameter */ - || kind === 288 /* PropertyAssignment */ - || kind === 163 /* PropertyDeclaration */ - || kind === 162 /* PropertySignature */ - || kind === 168 /* SetAccessor */ - || kind === 289 /* ShorthandPropertyAssignment */ - || kind === 254 /* TypeAliasDeclaration */ - || kind === 159 /* TypeParameter */ - || kind === 249 /* VariableDeclaration */ - || kind === 331 /* JSDocTypedefTag */ - || kind === 324 /* JSDocCallbackTag */ - || kind === 333 /* JSDocPropertyTag */; + return kind === 211 /* ArrowFunction */ + || kind === 200 /* BindingElement */ + || kind === 254 /* ClassDeclaration */ + || kind === 223 /* ClassExpression */ + || kind === 168 /* Constructor */ + || kind === 257 /* EnumDeclaration */ + || kind === 293 /* EnumMember */ + || kind === 272 /* ExportSpecifier */ + || kind === 253 /* FunctionDeclaration */ + || kind === 210 /* FunctionExpression */ + || kind === 169 /* GetAccessor */ + || kind === 264 /* ImportClause */ + || kind === 262 /* ImportEqualsDeclaration */ + || kind === 267 /* ImportSpecifier */ + || kind === 255 /* InterfaceDeclaration */ + || kind === 282 /* JsxAttribute */ + || kind === 167 /* MethodDeclaration */ + || kind === 166 /* MethodSignature */ + || kind === 258 /* ModuleDeclaration */ + || kind === 261 /* NamespaceExportDeclaration */ + || kind === 265 /* NamespaceImport */ + || kind === 271 /* NamespaceExport */ + || kind === 162 /* Parameter */ + || kind === 290 /* PropertyAssignment */ + || kind === 165 /* PropertyDeclaration */ + || kind === 164 /* PropertySignature */ + || kind === 170 /* SetAccessor */ + || kind === 291 /* ShorthandPropertyAssignment */ + || kind === 256 /* TypeAliasDeclaration */ + || kind === 161 /* TypeParameter */ + || kind === 251 /* VariableDeclaration */ + || kind === 339 /* JSDocTypedefTag */ + || kind === 332 /* JSDocCallbackTag */ + || kind === 341 /* JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - return kind === 251 /* FunctionDeclaration */ - || kind === 271 /* MissingDeclaration */ - || kind === 252 /* ClassDeclaration */ - || kind === 253 /* InterfaceDeclaration */ - || kind === 254 /* TypeAliasDeclaration */ - || kind === 255 /* EnumDeclaration */ - || kind === 256 /* ModuleDeclaration */ - || kind === 261 /* ImportDeclaration */ - || kind === 260 /* ImportEqualsDeclaration */ - || kind === 267 /* ExportDeclaration */ - || kind === 266 /* ExportAssignment */ - || kind === 259 /* NamespaceExportDeclaration */; + return kind === 253 /* FunctionDeclaration */ + || kind === 273 /* MissingDeclaration */ + || kind === 254 /* ClassDeclaration */ + || kind === 255 /* InterfaceDeclaration */ + || kind === 256 /* TypeAliasDeclaration */ + || kind === 257 /* EnumDeclaration */ + || kind === 258 /* ModuleDeclaration */ + || kind === 263 /* ImportDeclaration */ + || kind === 262 /* ImportEqualsDeclaration */ + || kind === 269 /* ExportDeclaration */ + || kind === 268 /* ExportAssignment */ + || kind === 261 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 241 /* BreakStatement */ - || kind === 240 /* ContinueStatement */ - || kind === 248 /* DebuggerStatement */ - || kind === 235 /* DoStatement */ - || kind === 233 /* ExpressionStatement */ - || kind === 231 /* EmptyStatement */ - || kind === 238 /* ForInStatement */ - || kind === 239 /* ForOfStatement */ - || kind === 237 /* ForStatement */ - || kind === 234 /* IfStatement */ - || kind === 245 /* LabeledStatement */ - || kind === 242 /* ReturnStatement */ - || kind === 244 /* SwitchStatement */ - || kind === 246 /* ThrowStatement */ - || kind === 247 /* TryStatement */ - || kind === 232 /* VariableStatement */ - || kind === 236 /* WhileStatement */ - || kind === 243 /* WithStatement */ - || kind === 335 /* NotEmittedStatement */ - || kind === 339 /* EndOfDeclarationMarker */ - || kind === 338 /* MergeDeclarationMarker */; + return kind === 243 /* BreakStatement */ + || kind === 242 /* ContinueStatement */ + || kind === 250 /* DebuggerStatement */ + || kind === 237 /* DoStatement */ + || kind === 235 /* ExpressionStatement */ + || kind === 233 /* EmptyStatement */ + || kind === 240 /* ForInStatement */ + || kind === 241 /* ForOfStatement */ + || kind === 239 /* ForStatement */ + || kind === 236 /* IfStatement */ + || kind === 247 /* LabeledStatement */ + || kind === 244 /* ReturnStatement */ + || kind === 246 /* SwitchStatement */ + || kind === 248 /* ThrowStatement */ + || kind === 249 /* TryStatement */ + || kind === 234 /* VariableStatement */ + || kind === 238 /* WhileStatement */ + || kind === 245 /* WithStatement */ + || kind === 343 /* NotEmittedStatement */ + || kind === 347 /* EndOfDeclarationMarker */ + || kind === 346 /* MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { - if (node.kind === 159 /* TypeParameter */) { - return (node.parent && node.parent.kind !== 330 /* JSDocTemplateTag */) || ts.isInJSFile(node); + if (node.kind === 161 /* TypeParameter */) { + return (node.parent && node.parent.kind !== 338 /* JSDocTemplateTag */) || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -13067,10 +13410,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 230 /* Block */) + if (node.kind !== 232 /* Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 247 /* TryStatement */ || node.parent.kind === 287 /* CatchClause */) { + if (node.parent.kind === 249 /* TryStatement */ || node.parent.kind === 289 /* CatchClause */) { return false; } } @@ -13084,88 +13427,94 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 230 /* Block */; + || kind === 232 /* Block */; } ts.isStatementOrBlock = isStatementOrBlock; // Module references /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 272 /* ExternalModuleReference */ - || kind === 157 /* QualifiedName */ - || kind === 78 /* Identifier */; + return kind === 274 /* ExternalModuleReference */ + || kind === 159 /* QualifiedName */ + || kind === 79 /* Identifier */; } ts.isModuleReference = isModuleReference; // JSX /* @internal */ function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 107 /* ThisKeyword */ - || kind === 78 /* Identifier */ - || kind === 201 /* PropertyAccessExpression */; + return kind === 108 /* ThisKeyword */ + || kind === 79 /* Identifier */ + || kind === 203 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 273 /* JsxElement */ - || kind === 283 /* JsxExpression */ - || kind === 274 /* JsxSelfClosingElement */ + return kind === 275 /* JsxElement */ + || kind === 285 /* JsxExpression */ + || kind === 276 /* JsxSelfClosingElement */ || kind === 11 /* JsxText */ - || kind === 277 /* JsxFragment */; + || kind === 279 /* JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 280 /* JsxAttribute */ - || kind === 282 /* JsxSpreadAttribute */; + return kind === 282 /* JsxAttribute */ + || kind === 284 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 10 /* StringLiteral */ - || kind === 283 /* JsxExpression */; + || kind === 285 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 275 /* JsxOpeningElement */ - || kind === 274 /* JsxSelfClosingElement */; + return kind === 277 /* JsxOpeningElement */ + || kind === 276 /* JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 284 /* CaseClause */ - || kind === 285 /* DefaultClause */; + return kind === 286 /* CaseClause */ + || kind === 287 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 301 /* FirstJSDocNode */ && node.kind <= 333 /* LastJSDocNode */; + return node.kind >= 303 /* FirstJSDocNode */ && node.kind <= 341 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 311 /* JSDocComment */ || node.kind === 310 /* JSDocNamepathType */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 314 /* JSDocComment */ + || node.kind === 313 /* JSDocNamepathType */ + || node.kind === 315 /* JSDocText */ + || isJSDocLinkLike(node) + || isJSDocTag(node) + || ts.isJSDocTypeLiteral(node) + || ts.isJSDocSignature(node); } ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode; // TODO: determine what this does before making it public. /* @internal */ function isJSDocTag(node) { - return node.kind >= 314 /* FirstJSDocTagNode */ && node.kind <= 333 /* LastJSDocTagNode */; + return node.kind >= 321 /* FirstJSDocTagNode */ && node.kind <= 341 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 168 /* SetAccessor */; + return node.kind === 170 /* SetAccessor */; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 167 /* GetAccessor */; + return node.kind === 169 /* GetAccessor */; } ts.isGetAccessor = isGetAccessor; /** True if has jsdoc nodes attached to it. */ @@ -13191,13 +13540,13 @@ var ts; /** True if has initializer node attached to it. */ function hasOnlyExpressionInitializer(node) { switch (node.kind) { - case 249 /* VariableDeclaration */: - case 160 /* Parameter */: - case 198 /* BindingElement */: - case 162 /* PropertySignature */: - case 163 /* PropertyDeclaration */: - case 288 /* PropertyAssignment */: - case 291 /* EnumMember */: + case 251 /* VariableDeclaration */: + case 162 /* Parameter */: + case 200 /* BindingElement */: + case 164 /* PropertySignature */: + case 165 /* PropertyDeclaration */: + case 290 /* PropertyAssignment */: + case 293 /* EnumMember */: return true; default: return false; @@ -13205,12 +13554,12 @@ var ts; } ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { - return node.kind === 280 /* JsxAttribute */ || node.kind === 282 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); + return node.kind === 282 /* JsxAttribute */ || node.kind === 284 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); } ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 173 /* TypeReference */ || node.kind === 223 /* ExpressionWithTypeArguments */; + return node.kind === 175 /* TypeReference */ || node.kind === 225 /* ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -13242,6 +13591,10 @@ var ts; return node.kind === 10 /* StringLiteral */ || node.kind === 14 /* NoSubstitutionTemplateLiteral */; } ts.isStringLiteralLike = isStringLiteralLike; + function isJSDocLinkLike(node) { + return node.kind === 318 /* JSDocLink */ || node.kind === 319 /* JSDocLinkCode */ || node.kind === 320 /* JSDocLinkPlain */; + } + ts.isJSDocLinkLike = isJSDocLinkLike; // #endregion })(ts || (ts = {})); /* @internal */ @@ -13326,7 +13679,7 @@ var ts; increaseIndent: ts.noop, decreaseIndent: ts.noop, clear: function () { return str = ""; }, - trackSymbol: ts.noop, + trackSymbol: function () { return false; }, reportInaccessibleThisError: ts.noop, reportInaccessibleUniqueSymbolError: ts.noop, reportPrivateInBaseOfClassExpression: ts.noop, @@ -13338,11 +13691,19 @@ var ts; } ts.changesAffectModuleResolution = changesAffectModuleResolution; function optionsHaveModuleResolutionChanges(oldOptions, newOptions) { - return ts.moduleResolutionOptionDeclarations.some(function (o) { + return optionsHaveChanges(oldOptions, newOptions, ts.moduleResolutionOptionDeclarations); + } + ts.optionsHaveModuleResolutionChanges = optionsHaveModuleResolutionChanges; + function changesAffectingProgramStructure(oldOptions, newOptions) { + return optionsHaveChanges(oldOptions, newOptions, ts.optionsAffectingProgramStructure); + } + ts.changesAffectingProgramStructure = changesAffectingProgramStructure; + function optionsHaveChanges(oldOptions, newOptions, optionDeclarations) { + return oldOptions !== newOptions && optionDeclarations.some(function (o) { return !isJsonEqual(getCompilerOptionValue(oldOptions, o), getCompilerOptionValue(newOptions, o)); }); } - ts.optionsHaveModuleResolutionChanges = optionsHaveModuleResolutionChanges; + ts.optionsHaveChanges = optionsHaveChanges; function forEachAncestor(node, callback) { while (true) { var res = callback(node); @@ -13449,7 +13810,9 @@ var ts; } ts.packageIdToString = packageIdToString; function typeDirectiveIsEqualTo(oldResolution, newResolution) { - return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.primary === newResolution.primary; + return oldResolution.resolvedFileName === newResolution.resolvedFileName + && oldResolution.primary === newResolution.primary + && oldResolution.originalPath === newResolution.originalPath; } ts.typeDirectiveIsEqualTo = typeDirectiveIsEqualTo; function hasChangesInResolutions(names, newResolutions, oldResolutions, comparer) { @@ -13491,7 +13854,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 297 /* SourceFile */) { + while (node && node.kind !== 299 /* SourceFile */) { node = node.parent; } return node; @@ -13499,11 +13862,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 230 /* Block */: - case 258 /* CaseBlock */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: + case 232 /* Block */: + case 260 /* CaseBlock */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: return true; } return false; @@ -13641,10 +14004,10 @@ var ts; commentPos + 2 < commentEnd && text.charCodeAt(commentPos + 2) === 47 /* slash */) { var textSubStr = text.substring(commentPos, commentEnd); - return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) || - textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) || - textSubStr.match(fullTripleSlashReferenceTypeReferenceDirectiveRegEx) || - textSubStr.match(defaultLibReferenceRegEx) ? + return ts.fullTripleSlashReferencePathRegEx.test(textSubStr) || + ts.fullTripleSlashAMDReferencePathRegEx.test(textSubStr) || + fullTripleSlashReferenceTypeReferenceDirectiveRegEx.test(textSubStr) || + defaultLibReferenceRegEx.test(textSubStr) ? true : false; } return false; @@ -13699,10 +14062,12 @@ 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 === 334 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 342 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } - return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); + return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, + /*stopAfterLineBreak*/ false, + /*stopAtComments*/ false, isInJSDoc(node)); } ts.getTokenPosOfNode = getTokenPosOfNode; function getNonDecoratorTokenPosOfNode(node, sourceFile) { @@ -13732,7 +14097,7 @@ var ts; var text = sourceText.substring(includeTrivia ? node.pos : ts.skipTrivia(sourceText, node.pos), node.end); if (isJSDocTypeExpressionOrChild(node)) { // strip space + asterisk at line start - text = text.replace(/(^|\r?\n|\r)\s*\*\s*/g, "$1"); + text = text.split(/\r\n|\n|\r/).map(function (line) { return ts.trimStringStart(line.replace(/^\s*\*/, "")); }).join("\n"); } return text; } @@ -13821,9 +14186,11 @@ var ts; DataView: ["setBigInt64", "setBigUint64", "getBigInt64", "getBigUint64"], RelativeTimeFormat: ["format", "formatToParts", "resolvedOptions"] }, - esnext: { + es2021: { PromiseConstructor: ["any"], - String: ["replaceAll"], + String: ["replaceAll"] + }, + esnext: { NumberFormat: ["formatToParts"] } }; @@ -13916,7 +14283,7 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 249 /* VariableDeclaration */ && node.parent.kind === 287 /* CatchClause */; + return node.kind === 251 /* VariableDeclaration */ && node.parent.kind === 289 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { @@ -13948,11 +14315,11 @@ 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 === 256 /* ModuleDeclaration */ && (!node.body); + return !!node && node.kind === 258 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 297 /* SourceFile */ || - node.kind === 256 /* ModuleDeclaration */ || + return node.kind === 299 /* SourceFile */ || + node.kind === 258 /* ModuleDeclaration */ || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -13969,16 +14336,17 @@ 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 297 /* SourceFile */: + case 299 /* SourceFile */: return ts.isExternalModule(node.parent); - case 257 /* ModuleBlock */: + case 259 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; } ts.isModuleAugmentationExternal = isModuleAugmentationExternal; function getNonAugmentationDeclaration(symbol) { - return ts.find(symbol.declarations, function (d) { return !isExternalModuleAugmentation(d) && !(ts.isModuleDeclaration(d) && isGlobalScopeAugmentation(d)); }); + var _a; + return (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return !isExternalModuleAugmentation(d) && !(ts.isModuleDeclaration(d) && isGlobalScopeAugmentation(d)); }); } ts.getNonAugmentationDeclaration = getNonAugmentationDeclaration; function isEffectiveExternalModule(node, compilerOptions) { @@ -14024,22 +14392,22 @@ var ts; ts.isEffectiveStrictModeSourceFile = isEffectiveStrictModeSourceFile; function isBlockScope(node, parentNode) { switch (node.kind) { - case 297 /* SourceFile */: - case 258 /* CaseBlock */: - case 287 /* CatchClause */: - case 256 /* ModuleDeclaration */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 166 /* Constructor */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 299 /* SourceFile */: + case 260 /* CaseBlock */: + case 289 /* CatchClause */: + case 258 /* ModuleDeclaration */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 168 /* Constructor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return true; - case 230 /* Block */: + case 232 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return !ts.isFunctionLike(parentNode); @@ -14049,9 +14417,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 324 /* JSDocCallbackTag */: - case 331 /* JSDocTypedefTag */: - case 313 /* JSDocSignature */: + case 332 /* JSDocCallbackTag */: + case 339 /* JSDocTypedefTag */: + case 317 /* JSDocSignature */: return true; default: ts.assertType(node); @@ -14061,25 +14429,25 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isDeclarationWithTypeParameterChildren(node) { switch (node.kind) { - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 164 /* MethodSignature */: - case 171 /* IndexSignature */: - case 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 308 /* JSDocFunctionType */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 330 /* JSDocTemplateTag */: - case 251 /* FunctionDeclaration */: - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 166 /* MethodSignature */: + case 173 /* IndexSignature */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: + case 311 /* JSDocFunctionType */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 338 /* JSDocTemplateTag */: + case 253 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return true; default: ts.assertType(node); @@ -14089,8 +14457,8 @@ var ts; ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren; function isAnyImportSyntax(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: - case 260 /* ImportEqualsDeclaration */: + case 263 /* ImportDeclaration */: + case 262 /* ImportEqualsDeclaration */: return true; default: return false; @@ -14099,15 +14467,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: - case 260 /* ImportEqualsDeclaration */: - case 232 /* VariableStatement */: - case 252 /* ClassDeclaration */: - case 251 /* FunctionDeclaration */: - case 256 /* ModuleDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: + case 263 /* ImportDeclaration */: + case 262 /* ImportEqualsDeclaration */: + case 234 /* VariableStatement */: + case 254 /* ClassDeclaration */: + case 253 /* FunctionDeclaration */: + case 258 /* ModuleDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 255 /* InterfaceDeclaration */: + case 257 /* EnumDeclaration */: return true; default: return false; @@ -14140,19 +14508,19 @@ var ts; } ts.getNameFromIndexInfo = getNameFromIndexInfo; function isComputedNonLiteralName(name) { - return name.kind === 158 /* ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression); + return name.kind === 160 /* ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression); } ts.isComputedNonLiteralName = isComputedNonLiteralName; function getTextOfPropertyName(name) { switch (name.kind) { - case 78 /* Identifier */: - case 79 /* PrivateIdentifier */: + case 79 /* Identifier */: + case 80 /* PrivateIdentifier */: return name.escapedText; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: if (isStringOrNumericLiteralLike(name.expression)) return ts.escapeLeadingUnderscores(name.expression.text); return ts.Debug.fail("Text of property name cannot be read from non-literal-valued ComputedPropertyNames"); @@ -14163,20 +14531,22 @@ var ts; ts.getTextOfPropertyName = getTextOfPropertyName; function entityNameToString(name) { switch (name.kind) { - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: return "this"; - case 79 /* PrivateIdentifier */: - case 78 /* Identifier */: + case 80 /* PrivateIdentifier */: + case 79 /* Identifier */: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 157 /* QualifiedName */: + case 159 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 201 /* PropertyAccessExpression */: + case 203 /* 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 305 /* JSDocMemberName */: + return entityNameToString(name.left) + entityNameToString(name.right); default: return ts.Debug.assertNever(name); } @@ -14256,7 +14626,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 230 /* Block */) { + if (node.body && node.body.kind === 232 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -14270,7 +14640,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 297 /* SourceFile */: + case 299 /* 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 @@ -14279,28 +14649,28 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 249 /* VariableDeclaration */: - case 198 /* BindingElement */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 256 /* ModuleDeclaration */: - case 255 /* EnumDeclaration */: - case 291 /* EnumMember */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 254 /* TypeAliasDeclaration */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 251 /* VariableDeclaration */: + case 200 /* BindingElement */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: + case 258 /* ModuleDeclaration */: + case 257 /* EnumDeclaration */: + case 293 /* EnumMember */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 256 /* TypeAliasDeclaration */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: errorNode = node.name; break; - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); - case 284 /* CaseClause */: - case 285 /* DefaultClause */: + case 286 /* CaseClause */: + case 287 /* 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); @@ -14352,16 +14722,16 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 203 /* CallExpression */ && n.expression.kind === 105 /* SuperKeyword */; + return n.kind === 205 /* CallExpression */ && n.expression.kind === 106 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 203 /* CallExpression */ && n.expression.kind === 99 /* ImportKeyword */; + return n.kind === 205 /* CallExpression */ && n.expression.kind === 100 /* ImportKeyword */; } ts.isImportCall = isImportCall; function isImportMeta(n) { return ts.isMetaProperty(n) - && n.keywordToken === 99 /* ImportKeyword */ + && n.keywordToken === 100 /* ImportKeyword */ && n.name.escapedText === "meta"; } ts.isImportMeta = isImportMeta; @@ -14370,7 +14740,7 @@ var ts; } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 233 /* ExpressionStatement */ + return node.kind === 235 /* ExpressionStatement */ && node.expression.kind === 10 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; @@ -14398,11 +14768,12 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 160 /* Parameter */ || - node.kind === 159 /* TypeParameter */ || - node.kind === 208 /* FunctionExpression */ || - node.kind === 209 /* ArrowFunction */ || - node.kind === 207 /* ParenthesizedExpression */) ? + var commentRanges = (node.kind === 162 /* Parameter */ || + node.kind === 161 /* TypeParameter */ || + node.kind === 210 /* FunctionExpression */ || + node.kind === 211 /* ArrowFunction */ || + node.kind === 209 /* ParenthesizedExpression */ || + node.kind === 251 /* VariableDeclaration */) ? 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 '/**/' @@ -14413,53 +14784,53 @@ var ts; }); } ts.getJSDocCommentRanges = getJSDocCommentRanges; - ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; - var fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; - ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; - var defaultLibReferenceRegEx = /^(\/\/\/\s*/; + ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; + var fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; + ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; + var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (172 /* FirstTypeNode */ <= node.kind && node.kind <= 195 /* LastTypeNode */) { + if (174 /* FirstTypeNode */ <= node.kind && node.kind <= 197 /* LastTypeNode */) { return true; } switch (node.kind) { - case 128 /* AnyKeyword */: - case 152 /* UnknownKeyword */: - case 144 /* NumberKeyword */: - case 155 /* BigIntKeyword */: - case 147 /* StringKeyword */: - case 131 /* BooleanKeyword */: - case 148 /* SymbolKeyword */: - case 145 /* ObjectKeyword */: - case 150 /* UndefinedKeyword */: - case 141 /* NeverKeyword */: + case 129 /* AnyKeyword */: + case 153 /* UnknownKeyword */: + case 145 /* NumberKeyword */: + case 156 /* BigIntKeyword */: + case 148 /* StringKeyword */: + case 132 /* BooleanKeyword */: + case 149 /* SymbolKeyword */: + case 146 /* ObjectKeyword */: + case 151 /* UndefinedKeyword */: + case 142 /* NeverKeyword */: return true; - case 113 /* VoidKeyword */: - return node.parent.kind !== 212 /* VoidExpression */; - case 223 /* ExpressionWithTypeArguments */: + case 114 /* VoidKeyword */: + return node.parent.kind !== 214 /* VoidExpression */; + case 225 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 159 /* TypeParameter */: - return node.parent.kind === 190 /* MappedType */ || node.parent.kind === 185 /* InferType */; + case 161 /* TypeParameter */: + return node.parent.kind === 192 /* MappedType */ || node.parent.kind === 187 /* InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container - case 78 /* Identifier */: + case 79 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 157 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 159 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 201 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 203 /* 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 === 78 /* Identifier */ || node.kind === 157 /* QualifiedName */ || node.kind === 201 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 79 /* Identifier */ || node.kind === 159 /* QualifiedName */ || node.kind === 203 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through - case 157 /* QualifiedName */: - case 201 /* PropertyAccessExpression */: - case 107 /* ThisKeyword */: { + case 159 /* QualifiedName */: + case 203 /* PropertyAccessExpression */: + case 108 /* ThisKeyword */: { var parent = node.parent; - if (parent.kind === 176 /* TypeQuery */) { + if (parent.kind === 178 /* TypeQuery */) { return false; } - if (parent.kind === 195 /* ImportType */) { + if (parent.kind === 197 /* ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -14468,40 +14839,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 (172 /* FirstTypeNode */ <= parent.kind && parent.kind <= 195 /* LastTypeNode */) { + if (174 /* FirstTypeNode */ <= parent.kind && parent.kind <= 197 /* LastTypeNode */) { return true; } switch (parent.kind) { - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 159 /* TypeParameter */: + case 161 /* TypeParameter */: return node === parent.constraint; - case 330 /* JSDocTemplateTag */: + case 338 /* JSDocTemplateTag */: return node === parent.constraint; - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 160 /* Parameter */: - case 249 /* VariableDeclaration */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 162 /* Parameter */: + case 251 /* VariableDeclaration */: return node === parent.type; - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 166 /* Constructor */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 168 /* Constructor */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return node === parent.type; - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 173 /* IndexSignature */: return node === parent.type; - case 206 /* TypeAssertionExpression */: + case 208 /* TypeAssertionExpression */: return node === parent.type; - case 203 /* CallExpression */: - case 204 /* NewExpression */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: return ts.contains(parent.typeArguments, node); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -14526,23 +14897,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: return visitor(node); - case 258 /* CaseBlock */: - case 230 /* Block */: - case 234 /* IfStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 243 /* WithStatement */: - case 244 /* SwitchStatement */: - case 284 /* CaseClause */: - case 285 /* DefaultClause */: - case 245 /* LabeledStatement */: - case 247 /* TryStatement */: - case 287 /* CatchClause */: + case 260 /* CaseBlock */: + case 232 /* Block */: + case 236 /* IfStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 245 /* WithStatement */: + case 246 /* SwitchStatement */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: + case 247 /* LabeledStatement */: + case 249 /* TryStatement */: + case 289 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -14552,23 +14923,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 255 /* EnumDeclaration */: - case 253 /* InterfaceDeclaration */: - case 256 /* ModuleDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 257 /* EnumDeclaration */: + case 255 /* InterfaceDeclaration */: + case 258 /* ModuleDeclaration */: + case 256 /* 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 === 158 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 160 /* 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); @@ -14591,10 +14962,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 178 /* ArrayType */) { + if (node && node.kind === 180 /* ArrayType */) { return node.elementType; } - else if (node && node.kind === 173 /* TypeReference */) { + else if (node && node.kind === 175 /* TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -14604,12 +14975,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 253 /* InterfaceDeclaration */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 177 /* TypeLiteral */: + case 255 /* InterfaceDeclaration */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 179 /* TypeLiteral */: return node.members; - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return node.properties; } } @@ -14617,14 +14988,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 198 /* BindingElement */: - case 291 /* EnumMember */: - case 160 /* Parameter */: - case 288 /* PropertyAssignment */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 289 /* ShorthandPropertyAssignment */: - case 249 /* VariableDeclaration */: + case 200 /* BindingElement */: + case 293 /* EnumMember */: + case 162 /* Parameter */: + case 290 /* PropertyAssignment */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 291 /* ShorthandPropertyAssignment */: + case 251 /* VariableDeclaration */: return true; } } @@ -14636,8 +15007,8 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 250 /* VariableDeclarationList */ - && node.parent.parent.kind === 232 /* VariableStatement */; + return node.parent.kind === 252 /* VariableDeclarationList */ + && node.parent.parent.kind === 234 /* VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { @@ -14648,13 +15019,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: return true; } return false; @@ -14665,7 +15036,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 245 /* LabeledStatement */) { + if (node.statement.kind !== 247 /* LabeledStatement */) { return node.statement; } node = node.statement; @@ -14673,17 +15044,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 230 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 232 /* Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 165 /* MethodDeclaration */ && node.parent.kind === 200 /* ObjectLiteralExpression */; + return node && node.kind === 167 /* MethodDeclaration */ && node.parent.kind === 202 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 165 /* MethodDeclaration */ && - (node.parent.kind === 200 /* ObjectLiteralExpression */ || - node.parent.kind === 221 /* ClassExpression */); + return node.kind === 167 /* MethodDeclaration */ && + (node.parent.kind === 202 /* ObjectLiteralExpression */ || + node.parent.kind === 223 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -14696,7 +15067,7 @@ var ts; ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 288 /* PropertyAssignment */) { + if (property.kind === 290 /* PropertyAssignment */) { var propName = getTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -14745,14 +15116,14 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 297 /* SourceFile */); + ts.Debug.assert(node.kind !== 299 /* 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 158 /* ComputedPropertyName */: + case 160 /* 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 @@ -14767,9 +15138,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 161 /* Decorator */: + case 163 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 160 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 162 /* 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; @@ -14780,26 +15151,26 @@ var ts; node = node.parent; } break; - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 256 /* ModuleDeclaration */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: - case 255 /* EnumDeclaration */: - case 297 /* SourceFile */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 258 /* ModuleDeclaration */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 173 /* IndexSignature */: + case 257 /* EnumDeclaration */: + case 299 /* SourceFile */: return node; } } @@ -14818,9 +15189,9 @@ var ts; var container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { switch (container.kind) { - case 166 /* Constructor */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: + case 168 /* Constructor */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: return container; } } @@ -14842,27 +15213,27 @@ var ts; return node; } switch (node.kind) { - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: node = node.parent; break; - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: if (!stopOnFunctions) { continue; } // falls through - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return node; - case 161 /* Decorator */: + case 163 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 160 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 162 /* 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; @@ -14878,21 +15249,21 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 208 /* FunctionExpression */ || func.kind === 209 /* ArrowFunction */) { + if (func.kind === 210 /* FunctionExpression */ || func.kind === 211 /* ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 207 /* ParenthesizedExpression */) { + while (parent.kind === 209 /* ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 203 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 205 /* CallExpression */ && parent.expression === prev) { return parent; } } } ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperOrSuperProperty(node) { - return node.kind === 105 /* SuperKeyword */ + return node.kind === 106 /* SuperKeyword */ || isSuperProperty(node); } ts.isSuperOrSuperProperty = isSuperOrSuperProperty; @@ -14901,8 +15272,8 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 201 /* PropertyAccessExpression */ || kind === 202 /* ElementAccessExpression */) - && node.expression.kind === 105 /* SuperKeyword */; + return (kind === 203 /* PropertyAccessExpression */ || kind === 204 /* ElementAccessExpression */) + && node.expression.kind === 106 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; /** @@ -14910,26 +15281,34 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 201 /* PropertyAccessExpression */ || kind === 202 /* ElementAccessExpression */) - && node.expression.kind === 107 /* ThisKeyword */; + return (kind === 203 /* PropertyAccessExpression */ || kind === 204 /* ElementAccessExpression */) + && node.expression.kind === 108 /* 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) === 107 /* ThisKeyword */; + return !!node && ts.isVariableDeclaration(node) && ((_a = node.initializer) === null || _a === void 0 ? void 0 : _a.kind) === 108 /* 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 */; + } + ts.isThisInitializedObjectBindingExpression = isThisInitializedObjectBindingExpression; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 173 /* TypeReference */: + case 175 /* TypeReference */: return node.typeName; - case 223 /* ExpressionWithTypeArguments */: + case 225 /* 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 78 /* Identifier */: - case 157 /* QualifiedName */: + case 79 /* Identifier */: + case 159 /* QualifiedName */: return node; } return undefined; @@ -14937,10 +15316,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return node.tag; - case 275 /* JsxOpeningElement */: - case 274 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -14953,25 +15332,25 @@ var ts; return false; } switch (node.kind) { - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: // classes are valid targets return true; - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 252 /* ClassDeclaration */; - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 165 /* MethodDeclaration */: + return parent.kind === 254 /* ClassDeclaration */; + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 167 /* 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 === 252 /* ClassDeclaration */; - case 160 /* Parameter */: + && parent.kind === 254 /* ClassDeclaration */; + case 162 /* 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 === 166 /* Constructor */ - || parent.kind === 165 /* MethodDeclaration */ - || parent.kind === 168 /* SetAccessor */) - && grandparent.kind === 252 /* ClassDeclaration */; + && (parent.kind === 168 /* Constructor */ + || parent.kind === 167 /* MethodDeclaration */ + || parent.kind === 170 /* SetAccessor */) + && grandparent.kind === 254 /* ClassDeclaration */; } return false; } @@ -14987,10 +15366,10 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 - case 165 /* MethodDeclaration */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 170 /* SetAccessor */: return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); // TODO: GH#18217 default: return false; @@ -14999,9 +15378,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 275 /* JsxOpeningElement */ || - parent.kind === 274 /* JsxSelfClosingElement */ || - parent.kind === 276 /* JsxClosingElement */) { + if (parent.kind === 277 /* JsxOpeningElement */ || + parent.kind === 276 /* JsxSelfClosingElement */ || + parent.kind === 278 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -15009,49 +15388,54 @@ var ts; ts.isJSXTagName = isJSXTagName; function isExpressionNode(node) { switch (node.kind) { - case 105 /* SuperKeyword */: - case 103 /* NullKeyword */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: + case 106 /* SuperKeyword */: + case 104 /* NullKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: case 13 /* RegularExpressionLiteral */: - case 199 /* ArrayLiteralExpression */: - case 200 /* ObjectLiteralExpression */: - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: - case 203 /* CallExpression */: - case 204 /* NewExpression */: - case 205 /* TaggedTemplateExpression */: - case 224 /* AsExpression */: - case 206 /* TypeAssertionExpression */: - case 225 /* NonNullExpression */: - case 207 /* ParenthesizedExpression */: - case 208 /* FunctionExpression */: - case 221 /* ClassExpression */: - case 209 /* ArrowFunction */: - case 212 /* VoidExpression */: - case 210 /* DeleteExpression */: - case 211 /* TypeOfExpression */: - case 214 /* PrefixUnaryExpression */: - case 215 /* PostfixUnaryExpression */: - case 216 /* BinaryExpression */: - case 217 /* ConditionalExpression */: - case 220 /* SpreadElement */: - case 218 /* TemplateExpression */: - case 222 /* OmittedExpression */: - case 273 /* JsxElement */: - case 274 /* JsxSelfClosingElement */: - case 277 /* JsxFragment */: - case 219 /* YieldExpression */: - case 213 /* AwaitExpression */: - case 226 /* MetaProperty */: + case 201 /* ArrayLiteralExpression */: + case 202 /* ObjectLiteralExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: + case 207 /* TaggedTemplateExpression */: + case 226 /* AsExpression */: + case 208 /* TypeAssertionExpression */: + case 227 /* NonNullExpression */: + case 209 /* ParenthesizedExpression */: + case 210 /* FunctionExpression */: + case 223 /* ClassExpression */: + case 211 /* ArrowFunction */: + case 214 /* VoidExpression */: + case 212 /* DeleteExpression */: + case 213 /* TypeOfExpression */: + case 216 /* PrefixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: + case 218 /* BinaryExpression */: + case 219 /* ConditionalExpression */: + case 222 /* SpreadElement */: + case 220 /* TemplateExpression */: + case 224 /* OmittedExpression */: + case 275 /* JsxElement */: + case 276 /* JsxSelfClosingElement */: + case 279 /* JsxFragment */: + case 221 /* YieldExpression */: + case 215 /* AwaitExpression */: + case 228 /* MetaProperty */: return true; - case 157 /* QualifiedName */: - while (node.parent.kind === 157 /* QualifiedName */) { + case 159 /* QualifiedName */: + while (node.parent.kind === 159 /* QualifiedName */) { + node = node.parent; + } + return node.parent.kind === 178 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); + case 305 /* JSDocMemberName */: + while (ts.isJSDocMemberName(node.parent)) { node = node.parent; } - return node.parent.kind === 176 /* TypeQuery */ || isJSXTagName(node); - case 78 /* Identifier */: - if (node.parent.kind === 176 /* TypeQuery */ || isJSXTagName(node)) { + return node.parent.kind === 178 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); + case 79 /* Identifier */: + if (node.parent.kind === 178 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node)) { return true; } // falls through @@ -15059,7 +15443,7 @@ var ts; case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: return isInExpressionContext(node); default: return false; @@ -15069,49 +15453,49 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 249 /* VariableDeclaration */: - case 160 /* Parameter */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 291 /* EnumMember */: - case 288 /* PropertyAssignment */: - case 198 /* BindingElement */: + case 251 /* VariableDeclaration */: + case 162 /* Parameter */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 293 /* EnumMember */: + case 290 /* PropertyAssignment */: + case 200 /* BindingElement */: return parent.initializer === node; - case 233 /* ExpressionStatement */: - case 234 /* IfStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: - case 242 /* ReturnStatement */: - case 243 /* WithStatement */: - case 244 /* SwitchStatement */: - case 284 /* CaseClause */: - case 246 /* ThrowStatement */: + case 235 /* ExpressionStatement */: + case 236 /* IfStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: + case 244 /* ReturnStatement */: + case 245 /* WithStatement */: + case 246 /* SwitchStatement */: + case 286 /* CaseClause */: + case 248 /* ThrowStatement */: return parent.expression === node; - case 237 /* ForStatement */: + case 239 /* ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 250 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 252 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 250 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 252 /* VariableDeclarationList */) || forInStatement.expression === node; - case 206 /* TypeAssertionExpression */: - case 224 /* AsExpression */: + case 208 /* TypeAssertionExpression */: + case 226 /* AsExpression */: return node === parent.expression; - case 228 /* TemplateSpan */: + case 230 /* TemplateSpan */: return node === parent.expression; - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return node === parent.expression; - case 161 /* Decorator */: - case 283 /* JsxExpression */: - case 282 /* JsxSpreadAttribute */: - case 290 /* SpreadAssignment */: + case 163 /* Decorator */: + case 285 /* JsxExpression */: + case 284 /* JsxSpreadAttribute */: + case 292 /* SpreadAssignment */: return true; - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return parent.objectAssignmentInitializer === node; default: return isExpressionNode(parent); @@ -15119,14 +15503,18 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isPartOfTypeQuery(node) { - while (node.kind === 157 /* QualifiedName */ || node.kind === 78 /* Identifier */) { + while (node.kind === 159 /* QualifiedName */ || node.kind === 79 /* Identifier */) { node = node.parent; } - return node.kind === 176 /* TypeQuery */; + return node.kind === 178 /* TypeQuery */; } ts.isPartOfTypeQuery = isPartOfTypeQuery; + function isNamespaceReexportDeclaration(node) { + return ts.isNamespaceExport(node) && !!node.parent.moduleSpecifier; + } + ts.isNamespaceReexportDeclaration = isNamespaceReexportDeclaration; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 260 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 272 /* ExternalModuleReference */; + return node.kind === 262 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 274 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -15135,12 +15523,11 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function getExternalModuleRequireArgument(node) { - return isRequireVariableDeclaration(node, /*requireStringLiteralLikeArgument*/ true) - && getLeftmostAccessExpression(node.initializer).arguments[0]; + return isRequireVariableDeclaration(node) && getLeftmostAccessExpression(node.initializer).arguments[0]; } ts.getExternalModuleRequireArgument = getExternalModuleRequireArgument; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 260 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 272 /* ExternalModuleReference */; + return node.kind === 262 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 274 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJS(file) { @@ -15172,15 +15559,15 @@ var ts; ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && node.typeArguments && node.typeArguments.length === 2 && - (node.typeArguments[0].kind === 147 /* StringKeyword */ || node.typeArguments[0].kind === 144 /* NumberKeyword */); + (node.typeArguments[0].kind === 148 /* StringKeyword */ || node.typeArguments[0].kind === 145 /* NumberKeyword */); } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, requireStringLiteralLikeArgument) { - if (callExpression.kind !== 203 /* CallExpression */) { + if (callExpression.kind !== 205 /* CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; - if (expression.kind !== 78 /* Identifier */ || expression.escapedText !== "require") { + if (expression.kind !== 79 /* Identifier */ || expression.escapedText !== "require") { return false; } if (args.length !== 1) { @@ -15190,18 +15577,21 @@ var ts; return !requireStringLiteralLikeArgument || ts.isStringLiteralLike(arg); } ts.isRequireCall = isRequireCall; - function isRequireVariableDeclaration(node, requireStringLiteralLikeArgument) { - if (node.kind === 198 /* BindingElement */) { + /** + * Returns true if the node is a VariableDeclaration initialized to a require call (see `isRequireCall`). + * This function does not test if the node is in a JavaScript file or not. + */ + function isRequireVariableDeclaration(node) { + if (node.kind === 200 /* BindingElement */) { node = node.parent.parent; } - return ts.isVariableDeclaration(node) && !!node.initializer && isRequireCall(getLeftmostAccessExpression(node.initializer), requireStringLiteralLikeArgument); + return ts.isVariableDeclaration(node) && !!node.initializer && isRequireCall(getLeftmostAccessExpression(node.initializer), /*requireStringLiteralLikeArgument*/ true); } ts.isRequireVariableDeclaration = isRequireVariableDeclaration; - function isRequireVariableStatement(node, requireStringLiteralLikeArgument) { - if (requireStringLiteralLikeArgument === void 0) { requireStringLiteralLikeArgument = true; } + function isRequireVariableStatement(node) { return ts.isVariableStatement(node) && node.declarationList.declarations.length > 0 - && ts.every(node.declarationList.declarations, function (decl) { return isRequireVariableDeclaration(decl, requireStringLiteralLikeArgument); }); + && ts.every(node.declarationList.declarations, function (decl) { return isRequireVariableDeclaration(decl); }); } ts.isRequireVariableStatement = isRequireVariableStatement; function isSingleOrDoubleQuote(charCode) { @@ -15247,7 +15637,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 === 62 /* EqualsToken */) { + if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* EqualsToken */) { var isPrototypeAssignment = isPrototypeAccess(node.parent.left); return getExpandoInitializer(node.parent.right, isPrototypeAssignment) || getDefaultedExpandoInitializer(node.parent.left, node.parent.right, isPrototypeAssignment); @@ -15273,11 +15663,11 @@ var ts; function getExpandoInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 208 /* FunctionExpression */ || e.kind === 209 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 210 /* FunctionExpression */ || e.kind === 211 /* ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 208 /* FunctionExpression */ || - initializer.kind === 221 /* ClassExpression */ || - initializer.kind === 209 /* ArrowFunction */) { + if (initializer.kind === 210 /* FunctionExpression */ || + initializer.kind === 223 /* ClassExpression */ || + initializer.kind === 211 /* ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -15303,7 +15693,7 @@ var ts; } function isDefaultedExpandoInitializer(node) { var name = ts.isVariableDeclaration(node.parent) ? node.parent.name : - ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 /* EqualsToken */ ? node.parent.left : + ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* EqualsToken */ ? node.parent.left : undefined; return name && getExpandoInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left); } @@ -15312,7 +15702,7 @@ var ts; 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 === 62 /* EqualsToken */ && ts.isIdentifier(parent.left)) { + if (parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isIdentifier(parent.left)) { return parent.left; } } @@ -15335,7 +15725,7 @@ var ts; return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(initializer); } if (ts.isIdentifier(name) && isLiteralLikeAccess(initializer) && - (initializer.expression.kind === 107 /* ThisKeyword */ || + (initializer.expression.kind === 108 /* ThisKeyword */ || ts.isIdentifier(initializer.expression) && (initializer.expression.escapedText === "window" || initializer.expression.escapedText === "self" || @@ -15398,20 +15788,19 @@ var ts; ts.isLiteralLikeAccess = isLiteralLikeAccess; /** x[0] OR x['a'] OR x[Symbol.y] */ function isLiteralLikeElementAccess(node) { - return ts.isElementAccessExpression(node) && (isStringOrNumericLiteralLike(node.argumentExpression) || - isWellKnownSymbolSyntactically(node.argumentExpression)); + return ts.isElementAccessExpression(node) && isStringOrNumericLiteralLike(node.argumentExpression); } ts.isLiteralLikeElementAccess = isLiteralLikeElementAccess; /** Any series of property and element accesses. */ function isBindableStaticAccessExpression(node, excludeThisKeyword) { - return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 107 /* ThisKeyword */ || ts.isIdentifier(node.name) && isBindableStaticNameExpression(node.expression, /*excludeThisKeyword*/ true)) + return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 108 /* 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 === 107 /* ThisKeyword */) || + && ((!excludeThisKeyword && node.expression.kind === 108 /* ThisKeyword */) || isEntityNameExpression(node.expression) || isBindableStaticAccessExpression(node.expression, /*excludeThisKeyword*/ true)); } @@ -15441,7 +15830,7 @@ var ts; } return 7 /* ObjectDefinePropertyValue */; } - if (expr.operatorToken.kind !== 62 /* EqualsToken */ || !isAccessExpression(expr.left) || isVoidZero(getRightMostAssignedExpression(expr))) { + if (expr.operatorToken.kind !== 63 /* EqualsToken */ || !isAccessExpression(expr.left) || isVoidZero(getRightMostAssignedExpression(expr))) { return 0 /* None */; } if (isBindableStaticNameExpression(expr.left.expression, /*excludeThisKeyword*/ true) && getElementOrPropertyAccessName(expr.left) === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { @@ -15479,14 +15868,11 @@ var ts; return ts.escapeLeadingUnderscores(name.text); } } - if (ts.isElementAccessExpression(node) && isWellKnownSymbolSyntactically(node.argumentExpression)) { - return getPropertyNameForKnownSymbolName(ts.idText(node.argumentExpression.name)); - } return undefined; } ts.getElementOrPropertyAccessName = getElementOrPropertyAccessName; function getAssignmentDeclarationPropertyAccessKind(lhs) { - if (lhs.expression.kind === 107 /* ThisKeyword */) { + if (lhs.expression.kind === 108 /* ThisKeyword */) { return 4 /* ThisProperty */; } else if (isModuleExportsAccessExpression(lhs)) { @@ -15531,7 +15917,7 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJSFile(expr) && - expr.parent && expr.parent.kind === 233 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 235 /* ExpressionStatement */ && (!ts.isElementAccessExpression(expr) || isLiteralLikeElementAccess(expr)) && !!ts.getJSDocTypeTag(expr.parent); } @@ -15552,23 +15938,37 @@ var ts; return false; } var decl = symbol.valueDeclaration; - return decl.kind === 251 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); + return decl.kind === 253 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); } ts.isFunctionSymbol = isFunctionSymbol; + function tryGetModuleSpecifierFromDeclaration(node) { + var _a, _b, _c; + switch (node.kind) { + case 251 /* VariableDeclaration */: + return node.initializer.arguments[0].text; + case 263 /* ImportDeclaration */: + return (_a = ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike)) === null || _a === void 0 ? void 0 : _a.text; + case 262 /* ImportEqualsDeclaration */: + return (_c = ts.tryCast((_b = ts.tryCast(node.moduleReference, ts.isExternalModuleReference)) === null || _b === void 0 ? void 0 : _b.expression, ts.isStringLiteralLike)) === null || _c === void 0 ? void 0 : _c.text; + default: + ts.Debug.assertNever(node); + } + } + ts.tryGetModuleSpecifierFromDeclaration = tryGetModuleSpecifierFromDeclaration; function importFromModuleSpecifier(node) { return tryGetImportFromModuleSpecifier(node) || ts.Debug.failBadSyntaxKind(node.parent); } ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 261 /* ImportDeclaration */: - case 267 /* ExportDeclaration */: + case 263 /* ImportDeclaration */: + case 269 /* ExportDeclaration */: return node.parent; - case 272 /* ExternalModuleReference */: + case 274 /* ExternalModuleReference */: return node.parent.parent; - case 203 /* CallExpression */: + case 205 /* CallExpression */: return isImportCall(node.parent) || isRequireCall(node.parent, /*checkArg*/ false) ? node.parent : undefined; - case 191 /* LiteralType */: + case 193 /* LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -15578,15 +15978,17 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: - case 267 /* ExportDeclaration */: + case 263 /* ImportDeclaration */: + case 269 /* ExportDeclaration */: return node.moduleSpecifier; - case 260 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 272 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 195 /* ImportType */: + case 262 /* ImportEqualsDeclaration */: + return node.moduleReference.kind === 274 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 197 /* ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; - case 203 /* CallExpression */: + case 205 /* CallExpression */: return node.arguments[0]; + case 258 /* ModuleDeclaration */: + return node.name.kind === 10 /* StringLiteral */ ? node.name : undefined; default: return ts.Debug.assertNever(node); } @@ -15594,11 +15996,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return node; - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: return node.exportClause && ts.tryCast(node.exportClause, ts.isNamespaceExport); default: return ts.Debug.assertNever(node); @@ -15606,7 +16008,7 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 261 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 263 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function forEachImportClauseDeclaration(node, action) { @@ -15627,13 +16029,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 160 /* Parameter */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 289 /* ShorthandPropertyAssignment */: - case 288 /* PropertyAssignment */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 162 /* Parameter */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 291 /* ShorthandPropertyAssignment */: + case 290 /* PropertyAssignment */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -15647,7 +16049,7 @@ var ts; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 331 /* JSDocTypedefTag */ || node.kind === 324 /* JSDocCallbackTag */ || node.kind === 325 /* JSDocEnumTag */; + return node.kind === 339 /* JSDocTypedefTag */ || node.kind === 332 /* JSDocCallbackTag */ || node.kind === 333 /* JSDocEnumTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -15657,7 +16059,7 @@ var ts; function getSourceOfAssignment(node) { return ts.isExpressionStatement(node) && ts.isBinaryExpression(node.expression) && - node.expression.operatorToken.kind === 62 /* EqualsToken */ + node.expression.operatorToken.kind === 63 /* EqualsToken */ ? getRightMostAssignedExpression(node.expression) : undefined; } @@ -15672,12 +16074,12 @@ var ts; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return node.initializer; - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: return node.initializer; } } @@ -15689,7 +16091,7 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 256 /* ModuleDeclaration */ + node.body.kind === 258 /* ModuleDeclaration */ ? node.body : undefined; } @@ -15704,11 +16106,11 @@ var ts; if (ts.hasJSDocNodes(node)) { result = ts.append(result, ts.last(node.jsDoc)); } - if (node.kind === 160 /* Parameter */) { + if (node.kind === 162 /* Parameter */) { result = ts.addRange(result, (noCache ? ts.getJSDocParameterTagsNoCache : ts.getJSDocParameterTags)(node)); break; } - if (node.kind === 159 /* TypeParameter */) { + if (node.kind === 161 /* TypeParameter */) { result = ts.addRange(result, (noCache ? ts.getJSDocTypeParameterTagsNoCache : ts.getJSDocTypeParameterTags)(node)); break; } @@ -15719,12 +16121,13 @@ var ts; ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; function getNextJSDocCommentLocation(node) { var parent = node.parent; - if (parent.kind === 288 /* PropertyAssignment */ || - parent.kind === 266 /* ExportAssignment */ || - parent.kind === 163 /* PropertyDeclaration */ || - parent.kind === 233 /* ExpressionStatement */ && node.kind === 201 /* PropertyAccessExpression */ || + if (parent.kind === 290 /* PropertyAssignment */ || + parent.kind === 268 /* ExportAssignment */ || + parent.kind === 165 /* PropertyDeclaration */ || + parent.kind === 235 /* ExpressionStatement */ && node.kind === 203 /* PropertyAccessExpression */ || + parent.kind === 244 /* ReturnStatement */ || getNestedModuleDeclaration(parent) || - ts.isBinaryExpression(node) && node.operatorToken.kind === 62 /* EqualsToken */) { + ts.isBinaryExpression(node) && node.operatorToken.kind === 63 /* EqualsToken */) { return parent; } // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. @@ -15735,7 +16138,7 @@ var ts; // var x = function(name) { return name.length; } else if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node || - ts.isBinaryExpression(parent) && parent.operatorToken.kind === 62 /* EqualsToken */)) { + ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */)) { return parent.parent; } else if (parent.parent && parent.parent.parent && @@ -15759,7 +16162,7 @@ var ts; if (!decl) { return undefined; } - var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 78 /* Identifier */ && p.name.escapedText === name; }); + var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 79 /* Identifier */ && p.name.escapedText === name; }); return parameter && parameter.symbol; } ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc; @@ -15809,7 +16212,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 === 309 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 312 /* JSDocVariadicType */; } ts.isRestParameter = isRestParameter; function hasTypeArguments(node) { @@ -15826,31 +16229,34 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 62 /* EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* Definite */ : 2 /* Compound */ : + binaryOperator === 63 /* EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; - case 214 /* PrefixUnaryExpression */: - case 215 /* PostfixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; return unaryOperator === 45 /* PlusPlusToken */ || unaryOperator === 46 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 207 /* ParenthesizedExpression */: - case 199 /* ArrayLiteralExpression */: - case 220 /* SpreadElement */: - case 225 /* NonNullExpression */: + case 209 /* ParenthesizedExpression */: + case 201 /* ArrayLiteralExpression */: + case 222 /* SpreadElement */: + case 227 /* NonNullExpression */: node = parent; break; - case 289 /* ShorthandPropertyAssignment */: + case 292 /* SpreadAssignment */: + node = parent.parent; + break; + case 291 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } node = parent.parent; break; - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: if (parent.name === node) { return 0 /* None */; } @@ -15877,22 +16283,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 230 /* Block */: - case 232 /* VariableStatement */: - case 243 /* WithStatement */: - case 234 /* IfStatement */: - case 244 /* SwitchStatement */: - case 258 /* CaseBlock */: - case 284 /* CaseClause */: - case 285 /* DefaultClause */: - case 245 /* LabeledStatement */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: - case 247 /* TryStatement */: - case 287 /* CatchClause */: + case 232 /* Block */: + case 234 /* VariableStatement */: + case 245 /* WithStatement */: + case 236 /* IfStatement */: + case 246 /* SwitchStatement */: + case 260 /* CaseBlock */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: + case 247 /* LabeledStatement */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: + case 249 /* TryStatement */: + case 289 /* CatchClause */: return true; } return false; @@ -15909,11 +16315,11 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 186 /* ParenthesizedType */); + return walkUp(node, 188 /* ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 207 /* ParenthesizedExpression */); + return walkUp(node, 209 /* ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; /** @@ -15923,7 +16329,7 @@ var ts; */ function walkUpParenthesizedTypesAndGetParentAndChild(node) { var child; - while (node && node.kind === 186 /* ParenthesizedType */) { + while (node && node.kind === 188 /* ParenthesizedType */) { child = node; node = node.parent; } @@ -15934,19 +16340,13 @@ var ts; return ts.skipOuterExpressions(node, 1 /* Parentheses */); } ts.skipParentheses = skipParentheses; - function skipParenthesesUp(node) { - while (node.kind === 207 /* ParenthesizedExpression */) { - node = node.parent; - } - return node; - } // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped function isDeleteTarget(node) { - if (node.kind !== 201 /* PropertyAccessExpression */ && node.kind !== 202 /* ElementAccessExpression */) { + if (node.kind !== 203 /* PropertyAccessExpression */ && node.kind !== 204 /* ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 210 /* DeleteExpression */; + return node && node.kind === 212 /* DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -15973,7 +16373,7 @@ var ts; if (ts.isComputedPropertyName(parent)) return parent.parent; // falls through - case 78 /* Identifier */: + case 79 /* Identifier */: if (ts.isDeclaration(parent)) { return parent.name === name ? parent : undefined; } @@ -15990,7 +16390,7 @@ var ts; ? binExp : undefined; } - case 79 /* PrivateIdentifier */: + case 80 /* PrivateIdentifier */: return ts.isDeclaration(parent) && parent.name === name ? parent : undefined; default: return undefined; @@ -15999,7 +16399,7 @@ var ts; ts.getDeclarationFromName = getDeclarationFromName; function isLiteralComputedPropertyDeclarationName(node) { return isStringOrNumericLiteralLike(node) && - node.parent.kind === 158 /* ComputedPropertyName */ && + node.parent.kind === 160 /* ComputedPropertyName */ && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -16007,26 +16407,26 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 291 /* EnumMember */: - case 288 /* PropertyAssignment */: - case 201 /* PropertyAccessExpression */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 293 /* EnumMember */: + case 290 /* PropertyAssignment */: + case 203 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 157 /* QualifiedName */: + case 159 /* QualifiedName */: // Name on right hand side of dot in a type query or type reference return parent.right === node; - case 198 /* BindingElement */: - case 265 /* ImportSpecifier */: + case 200 /* BindingElement */: + case 267 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 270 /* ExportSpecifier */: - case 280 /* JsxAttribute */: + case 272 /* ExportSpecifier */: + case 282 /* JsxAttribute */: // Any name in an export specifier or JSX Attribute return true; } @@ -16046,33 +16446,33 @@ var ts; // {} // {name: } function isAliasSymbolDeclaration(node) { - return node.kind === 260 /* ImportEqualsDeclaration */ || - node.kind === 259 /* NamespaceExportDeclaration */ || - node.kind === 262 /* ImportClause */ && !!node.name || - node.kind === 263 /* NamespaceImport */ || - node.kind === 269 /* NamespaceExport */ || - node.kind === 265 /* ImportSpecifier */ || - node.kind === 270 /* ExportSpecifier */ || - node.kind === 266 /* ExportAssignment */ && exportAssignmentIsAlias(node) || + return node.kind === 262 /* ImportEqualsDeclaration */ || + node.kind === 261 /* NamespaceExportDeclaration */ || + node.kind === 264 /* ImportClause */ && !!node.name || + node.kind === 265 /* NamespaceImport */ || + node.kind === 271 /* NamespaceExport */ || + node.kind === 267 /* ImportSpecifier */ || + node.kind === 272 /* ExportSpecifier */ || + node.kind === 268 /* ExportAssignment */ && exportAssignmentIsAlias(node) || ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) || - ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62 /* EqualsToken */ && isAliasableExpression(node.parent.right) || - node.kind === 289 /* ShorthandPropertyAssignment */ || - node.kind === 288 /* PropertyAssignment */ && isAliasableExpression(node.initializer); + ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* EqualsToken */ && isAliasableExpression(node.parent.right) || + node.kind === 291 /* ShorthandPropertyAssignment */ || + node.kind === 290 /* PropertyAssignment */ && isAliasableExpression(node.initializer); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getAliasDeclarationFromName(node) { switch (node.parent.kind) { - case 262 /* ImportClause */: - case 265 /* ImportSpecifier */: - case 263 /* NamespaceImport */: - case 270 /* ExportSpecifier */: - case 266 /* ExportAssignment */: - case 260 /* ImportEqualsDeclaration */: + case 264 /* ImportClause */: + case 267 /* ImportSpecifier */: + case 265 /* NamespaceImport */: + case 272 /* ExportSpecifier */: + case 268 /* ExportAssignment */: + case 262 /* ImportEqualsDeclaration */: return node.parent; - case 157 /* QualifiedName */: + case 159 /* QualifiedName */: do { node = node.parent; - } while (node.parent.kind === 157 /* QualifiedName */); + } while (node.parent.kind === 159 /* QualifiedName */); return getAliasDeclarationFromName(node); } } @@ -16091,7 +16491,7 @@ var ts; } ts.getExportAssignmentExpression = getExportAssignmentExpression; function getPropertyAssignmentAliasLikeExpression(node) { - return node.kind === 289 /* ShorthandPropertyAssignment */ ? node.name : node.kind === 288 /* PropertyAssignment */ ? node.initializer : + return node.kind === 291 /* ShorthandPropertyAssignment */ ? node.name : node.kind === 290 /* PropertyAssignment */ ? node.initializer : node.parent.right; } ts.getPropertyAssignmentAliasLikeExpression = getPropertyAssignmentAliasLikeExpression; @@ -16108,7 +16508,7 @@ var ts; } ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode; function getClassExtendsHeritageElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 93 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 94 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement; @@ -16117,7 +16517,7 @@ var ts; return ts.getJSDocImplementsTags(node).map(function (n) { return n.class; }); } else { - var heritageClause = getHeritageClause(node.heritageClauses, 116 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 117 /* ImplementsKeyword */); return heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.types; } } @@ -16130,7 +16530,7 @@ var ts; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 93 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 94 /* ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -16157,11 +16557,11 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 80 /* FirstKeyword */ <= token && token <= 156 /* LastKeyword */; + return 81 /* FirstKeyword */ <= token && token <= 158 /* LastKeyword */; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 125 /* FirstContextualKeyword */ <= token && token <= 156 /* LastContextualKeyword */; + return 126 /* FirstContextualKeyword */ <= token && token <= 158 /* LastContextualKeyword */; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { @@ -16169,7 +16569,7 @@ var ts; } ts.isNonContextualKeyword = isNonContextualKeyword; function isFutureReservedKeyword(token) { - return 116 /* FirstFutureReservedWord */ <= token && token <= 124 /* LastFutureReservedWord */; + return 117 /* FirstFutureReservedWord */ <= token && token <= 125 /* LastFutureReservedWord */; } ts.isFutureReservedKeyword = isFutureReservedKeyword; function isStringANonContextualKeyword(name) { @@ -16205,14 +16605,14 @@ var ts; } var flags = 0 /* Normal */; switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 165 /* MethodDeclaration */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 167 /* MethodDeclaration */: if (node.asteriskToken) { flags |= 1 /* Generator */; } // falls through - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: if (hasSyntacticModifier(node, 256 /* Async */)) { flags |= 2 /* Async */; } @@ -16226,10 +16626,10 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 167 /* MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined && hasSyntacticModifier(node, 256 /* Async */); @@ -16252,9 +16652,6 @@ var ts; * 3. The computed name is *not* expressed as a NumericLiteral. * 4. The computed name is *not* expressed as a PlusToken or MinusToken * immediately followed by a NumericLiteral. - * 5. The computed name is *not* expressed as `Symbol.`, where `` - * is a property of the Symbol constructor that denotes a built-in - * Symbol. */ function hasDynamicName(declaration) { var name = ts.getNameOfDeclaration(declaration); @@ -16262,38 +16659,25 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - if (!(name.kind === 158 /* ComputedPropertyName */ || name.kind === 202 /* ElementAccessExpression */)) { + if (!(name.kind === 160 /* ComputedPropertyName */ || name.kind === 204 /* ElementAccessExpression */)) { return false; } var expr = ts.isElementAccessExpression(name) ? skipParentheses(name.argumentExpression) : name.expression; return !isStringOrNumericLiteralLike(expr) && - !isSignedNumericLiteral(expr) && - !isWellKnownSymbolSyntactically(expr); + !isSignedNumericLiteral(expr); } ts.isDynamicName = isDynamicName; - /** - * Checks if the expression is of the form: - * Symbol.name - * where Symbol is literally the word "Symbol", and name is any identifierName - */ - function isWellKnownSymbolSyntactically(node) { - return ts.isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression); - } - ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { switch (name.kind) { - case 78 /* Identifier */: - case 79 /* PrivateIdentifier */: + case 79 /* Identifier */: + case 80 /* PrivateIdentifier */: return name.escapedText; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: var nameExpression = name.expression; - if (isWellKnownSymbolSyntactically(nameExpression)) { - return getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); - } - else if (isStringOrNumericLiteralLike(nameExpression)) { + if (isStringOrNumericLiteralLike(nameExpression)) { return ts.escapeLeadingUnderscores(nameExpression.text); } else if (isSignedNumericLiteral(nameExpression)) { @@ -16310,7 +16694,7 @@ var ts; ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; function isPropertyNameLiteral(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: @@ -16321,21 +16705,17 @@ var ts; } ts.isPropertyNameLiteral = isPropertyNameLiteral; function getTextOfIdentifierOrLiteral(node) { - return ts.isIdentifierOrPrivateIdentifier(node) ? ts.idText(node) : node.text; + return ts.isMemberName(node) ? ts.idText(node) : node.text; } ts.getTextOfIdentifierOrLiteral = getTextOfIdentifierOrLiteral; function getEscapedTextOfIdentifierOrLiteral(node) { - return ts.isIdentifierOrPrivateIdentifier(node) ? node.escapedText : ts.escapeLeadingUnderscores(node.text); + return ts.isMemberName(node) ? node.escapedText : ts.escapeLeadingUnderscores(node.text); } ts.getEscapedTextOfIdentifierOrLiteral = getEscapedTextOfIdentifierOrLiteral; function getPropertyNameForUniqueESSymbol(symbol) { return "__@" + ts.getSymbolId(symbol) + "@" + symbol.escapedName; } ts.getPropertyNameForUniqueESSymbol = getPropertyNameForUniqueESSymbol; - function getPropertyNameForKnownSymbolName(symbolName) { - return "__@" + symbolName; - } - ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; function getSymbolNameForPrivateIdentifier(containingClassSymbol, description) { return "__#" + ts.getSymbolId(containingClassSymbol) + "@" + description; } @@ -16348,7 +16728,7 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 78 /* Identifier */ && node.escapedText === "Symbol"; + return node.kind === 79 /* Identifier */ && node.escapedText === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isPushOrUnshiftIdentifier(node) { @@ -16357,11 +16737,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 160 /* Parameter */; + return root.kind === 162 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 198 /* BindingElement */) { + while (node.kind === 200 /* BindingElement */) { node = node.parent.parent; } return node; @@ -16369,15 +16749,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 166 /* Constructor */ - || kind === 208 /* FunctionExpression */ - || kind === 251 /* FunctionDeclaration */ - || kind === 209 /* ArrowFunction */ - || kind === 165 /* MethodDeclaration */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */ - || kind === 256 /* ModuleDeclaration */ - || kind === 297 /* SourceFile */; + return kind === 168 /* Constructor */ + || kind === 210 /* FunctionExpression */ + || kind === 253 /* FunctionDeclaration */ + || kind === 211 /* ArrowFunction */ + || kind === 167 /* MethodDeclaration */ + || kind === 169 /* GetAccessor */ + || kind === 170 /* SetAccessor */ + || kind === 258 /* ModuleDeclaration */ + || kind === 299 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -16396,41 +16776,41 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 204 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 206 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 204 /* NewExpression */: + case 206 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 214 /* PrefixUnaryExpression */: - case 211 /* TypeOfExpression */: - case 212 /* VoidExpression */: - case 210 /* DeleteExpression */: - case 213 /* AwaitExpression */: - case 217 /* ConditionalExpression */: - case 219 /* YieldExpression */: + case 216 /* PrefixUnaryExpression */: + case 213 /* TypeOfExpression */: + case 214 /* VoidExpression */: + case 212 /* DeleteExpression */: + case 215 /* AwaitExpression */: + case 219 /* ConditionalExpression */: + case 221 /* YieldExpression */: return 1 /* Right */; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: switch (operator) { case 42 /* AsteriskAsteriskToken */: - case 62 /* EqualsToken */: - case 63 /* PlusEqualsToken */: - case 64 /* MinusEqualsToken */: - case 66 /* AsteriskAsteriskEqualsToken */: - case 65 /* AsteriskEqualsToken */: - case 67 /* SlashEqualsToken */: - case 68 /* PercentEqualsToken */: - case 69 /* LessThanLessThanEqualsToken */: - case 70 /* GreaterThanGreaterThanEqualsToken */: - case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 72 /* AmpersandEqualsToken */: - case 77 /* CaretEqualsToken */: - case 73 /* BarEqualsToken */: - case 74 /* BarBarEqualsToken */: - case 75 /* AmpersandAmpersandEqualsToken */: - case 76 /* QuestionQuestionEqualsToken */: + 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 */; } } @@ -16439,15 +16819,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 204 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 206 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 216 /* BinaryExpression */) { + if (expression.kind === 218 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 214 /* PrefixUnaryExpression */ || expression.kind === 215 /* PostfixUnaryExpression */) { + else if (expression.kind === 216 /* PrefixUnaryExpression */ || expression.kind === 217 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -16626,81 +17006,82 @@ var ts; })(OperatorPrecedence = ts.OperatorPrecedence || (ts.OperatorPrecedence = {})); function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 337 /* CommaListExpression */: + case 345 /* CommaListExpression */: return 0 /* Comma */; - case 220 /* SpreadElement */: + case 222 /* SpreadElement */: return 1 /* Spread */; - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: return 2 /* Yield */; - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: return 4 /* Conditional */; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: switch (operatorKind) { case 27 /* CommaToken */: return 0 /* Comma */; - case 62 /* EqualsToken */: - case 63 /* PlusEqualsToken */: - case 64 /* MinusEqualsToken */: - case 66 /* AsteriskAsteriskEqualsToken */: - case 65 /* AsteriskEqualsToken */: - case 67 /* SlashEqualsToken */: - case 68 /* PercentEqualsToken */: - case 69 /* LessThanLessThanEqualsToken */: - case 70 /* GreaterThanGreaterThanEqualsToken */: - case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 72 /* AmpersandEqualsToken */: - case 77 /* CaretEqualsToken */: - case 73 /* BarEqualsToken */: - case 74 /* BarBarEqualsToken */: - case 75 /* AmpersandAmpersandEqualsToken */: - case 76 /* QuestionQuestionEqualsToken */: + 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 */; default: return getBinaryOperatorPrecedence(operatorKind); } // TODO: Should prefix `++` and `--` be moved to the `Update` precedence? - case 206 /* TypeAssertionExpression */: - case 225 /* NonNullExpression */: - case 214 /* PrefixUnaryExpression */: - case 211 /* TypeOfExpression */: - case 212 /* VoidExpression */: - case 210 /* DeleteExpression */: - case 213 /* AwaitExpression */: + case 208 /* TypeAssertionExpression */: + case 227 /* NonNullExpression */: + case 216 /* PrefixUnaryExpression */: + case 213 /* TypeOfExpression */: + case 214 /* VoidExpression */: + case 212 /* DeleteExpression */: + case 215 /* AwaitExpression */: return 16 /* Unary */; - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: return 17 /* Update */; - case 203 /* CallExpression */: + case 205 /* CallExpression */: return 18 /* LeftHandSide */; - case 204 /* NewExpression */: + case 206 /* NewExpression */: return hasArguments ? 19 /* Member */ : 18 /* LeftHandSide */; - case 205 /* TaggedTemplateExpression */: - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 207 /* TaggedTemplateExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: + case 228 /* MetaProperty */: return 19 /* Member */; - case 224 /* AsExpression */: + case 226 /* AsExpression */: return 11 /* Relational */; - case 107 /* ThisKeyword */: - case 105 /* SuperKeyword */: - case 78 /* Identifier */: - case 103 /* NullKeyword */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: + case 108 /* ThisKeyword */: + case 106 /* SuperKeyword */: + case 79 /* Identifier */: + case 104 /* NullKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: - case 199 /* ArrayLiteralExpression */: - case 200 /* ObjectLiteralExpression */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 221 /* ClassExpression */: + case 201 /* ArrayLiteralExpression */: + case 202 /* ObjectLiteralExpression */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 223 /* ClassExpression */: case 13 /* RegularExpressionLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 218 /* TemplateExpression */: - case 207 /* ParenthesizedExpression */: - case 222 /* OmittedExpression */: - case 273 /* JsxElement */: - case 274 /* JsxSelfClosingElement */: - case 277 /* JsxFragment */: + case 220 /* TemplateExpression */: + case 209 /* ParenthesizedExpression */: + case 224 /* OmittedExpression */: + case 275 /* JsxElement */: + case 276 /* JsxSelfClosingElement */: + case 279 /* JsxFragment */: return 20 /* Primary */; default: return -1 /* Invalid */; @@ -16730,9 +17111,9 @@ var ts; case 31 /* GreaterThanToken */: case 32 /* LessThanEqualsToken */: case 33 /* GreaterThanEqualsToken */: - case 101 /* InstanceOfKeyword */: - case 100 /* InKeyword */: - case 126 /* AsKeyword */: + case 102 /* InstanceOfKeyword */: + case 101 /* InKeyword */: + case 127 /* AsKeyword */: return 11 /* Relational */; case 47 /* LessThanLessThanToken */: case 48 /* GreaterThanGreaterThanToken */: @@ -16756,7 +17137,7 @@ var ts; function getSemanticJsxChildren(children) { return ts.filter(children, function (i) { switch (i.kind) { - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: return !!i.expression; case 11 /* JsxText */: return !i.containsOnlyTriviaWhiteSpaces; @@ -17058,7 +17439,7 @@ var ts; reportInaccessibleThisError: ts.noop, reportPrivateInBaseOfClassExpression: ts.noop, reportInaccessibleUniqueSymbolError: ts.noop, - trackSymbol: ts.noop, + trackSymbol: function () { return false; }, writeKeyword: write, writeOperator: write, writeParameter: write, @@ -17150,11 +17531,20 @@ var ts; return file.moduleName || getExternalModuleNameFromPath(host, file.fileName, referenceFile && referenceFile.fileName); } ts.getResolvedExternalModuleName = getResolvedExternalModuleName; + function getCanonicalAbsolutePath(host, path) { + return host.getCanonicalFileName(ts.getNormalizedAbsolutePath(path, host.getCurrentDirectory())); + } function getExternalModuleNameFromDeclaration(host, resolver, declaration) { var file = resolver.getExternalModuleFileFromDeclaration(declaration); if (!file || file.isDeclarationFile) { return undefined; } + // If the declaration already uses a non-relative name, and is outside the common source directory, continue to use it + var specifier = getExternalModuleName(declaration); + if (specifier && ts.isStringLiteralLike(specifier) && !ts.pathIsRelative(specifier.text) && + getCanonicalAbsolutePath(host, file.path).indexOf(getCanonicalAbsolutePath(host, ts.ensureTrailingDirectorySeparator(host.getCommonSourceDirectory()))) === -1) { + return undefined; + } return getResolvedExternalModuleName(host, file); } ts.getExternalModuleNameFromDeclaration = getExternalModuleNameFromDeclaration; @@ -17238,8 +17628,8 @@ var ts; return !(options.noEmitForJsFiles && isSourceFileJS(sourceFile)) && !sourceFile.isDeclarationFile && !host.isSourceFileFromExternalLibrary(sourceFile) && - !(isJsonSourceFile(sourceFile) && host.getResolvedProjectReferenceToRedirect(sourceFile.fileName)) && - (forceDtsEmit || !host.isSourceOfProjectReferenceRedirect(sourceFile.fileName)); + (forceDtsEmit || (!(isJsonSourceFile(sourceFile) && host.getResolvedProjectReferenceToRedirect(sourceFile.fileName)) && + !host.isSourceOfProjectReferenceRedirect(sourceFile.fileName))); } ts.sourceFileMayBeEmitted = sourceFileMayBeEmitted; function getSourceFilePathInNewDir(fileName, host, newDirPath) { @@ -17319,11 +17709,11 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return !!node && node.kind === 78 /* Identifier */ && identifierIsThisKeyword(node); + return !!node && node.kind === 79 /* Identifier */ && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 107 /* ThisKeyword */; + return id.originalKeywordKind === 108 /* ThisKeyword */; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -17334,10 +17724,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 167 /* GetAccessor */) { + if (accessor.kind === 169 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 168 /* SetAccessor */) { + else if (accessor.kind === 170 /* SetAccessor */) { setAccessor = accessor; } else { @@ -17357,10 +17747,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 167 /* GetAccessor */ && !getAccessor) { + if (member.kind === 169 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 168 /* SetAccessor */ && !setAccessor) { + if (member.kind === 170 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -17409,7 +17799,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 === 311 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 314 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -17585,7 +17975,7 @@ var ts; ts.writeCommentRange = writeCommentRange; function writeTrimmedCurrentLine(text, commentEnd, writer, newLine, pos, nextLineStart) { var end = Math.min(commentEnd, nextLineStart - 1); - var currentLineText = text.substring(pos, end).replace(/^\s+|\s+$/g, ""); + var currentLineText = ts.trimString(text.substring(pos, end)); if (currentLineText) { // trimmed forward and ending spaces text writer.writeComment(currentLineText); @@ -17632,6 +18022,18 @@ var ts; return hasSyntacticModifier(node, 32 /* Static */); } ts.hasStaticModifier = hasStaticModifier; + function hasOverrideModifier(node) { + return hasEffectiveModifier(node, 16384 /* Override */); + } + ts.hasOverrideModifier = hasOverrideModifier; + function hasAbstractModifier(node) { + return hasSyntacticModifier(node, 128 /* Abstract */); + } + ts.hasAbstractModifier = hasAbstractModifier; + function hasAmbientModifier(node) { + return hasSyntacticModifier(node, 2 /* Ambient */); + } + ts.hasAmbientModifier = hasAmbientModifier; function hasEffectiveReadonlyModifier(node) { return hasEffectiveModifier(node, 64 /* Readonly */); } @@ -17645,7 +18047,7 @@ var ts; } ts.getSelectedSyntacticModifierFlags = getSelectedSyntacticModifierFlags; function getModifierFlagsWorker(node, includeJSDoc, alwaysIncludeJSDoc) { - if (node.kind >= 0 /* FirstToken */ && node.kind <= 156 /* LastToken */) { + if (node.kind >= 0 /* FirstToken */ && node.kind <= 158 /* LastToken */) { return 0 /* None */; } if (!(node.modifierFlagsCache & 536870912 /* HasComputedFlags */)) { @@ -17690,6 +18092,8 @@ var ts; flags |= 16 /* Protected */; if (ts.getJSDocReadonlyTagNoCache(node)) flags |= 64 /* Readonly */; + if (ts.getJSDocOverrideTagNoCache(node)) + flags |= 16384 /* Override */; } if (ts.getJSDocDeprecatedTagNoCache(node)) flags |= 8192 /* Deprecated */; @@ -17712,7 +18116,7 @@ var ts; */ function getSyntacticModifierFlagsNoCache(node) { var flags = modifiersToFlags(node.modifiers); - if (node.flags & 4 /* NestedNamespace */ || (node.kind === 78 /* Identifier */ && node.isInJSDocNamespace)) { + if (node.flags & 4 /* NestedNamespace */ || (node.kind === 79 /* Identifier */ && node.isInJSDocNamespace)) { flags |= 1 /* Export */; } return flags; @@ -17731,21 +18135,26 @@ var ts; ts.modifiersToFlags = modifiersToFlags; function modifierToFlag(token) { switch (token) { - case 123 /* StaticKeyword */: return 32 /* Static */; - case 122 /* PublicKeyword */: return 4 /* Public */; - case 121 /* ProtectedKeyword */: return 16 /* Protected */; - case 120 /* PrivateKeyword */: return 8 /* Private */; - case 125 /* AbstractKeyword */: return 128 /* Abstract */; - case 92 /* ExportKeyword */: return 1 /* Export */; - case 133 /* DeclareKeyword */: return 2 /* Ambient */; - case 84 /* ConstKeyword */: return 2048 /* Const */; - case 87 /* DefaultKeyword */: return 512 /* Default */; - case 129 /* AsyncKeyword */: return 256 /* Async */; - case 142 /* ReadonlyKeyword */: return 64 /* Readonly */; + 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 134 /* DeclareKeyword */: return 2 /* Ambient */; + case 85 /* ConstKeyword */: return 2048 /* Const */; + case 88 /* DefaultKeyword */: return 512 /* Default */; + case 130 /* AsyncKeyword */: return 256 /* Async */; + case 143 /* ReadonlyKeyword */: return 64 /* Readonly */; + case 157 /* OverrideKeyword */: return 16384 /* Override */; } return 0 /* None */; } ts.modifierToFlag = modifierToFlag; + function createModifiers(modifierFlags) { + return modifierFlags ? ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(modifierFlags)) : undefined; + } + ts.createModifiers = createModifiers; function isLogicalOperator(token) { return token === 56 /* BarBarToken */ || token === 55 /* AmpersandAmpersandToken */ @@ -17753,9 +18162,9 @@ var ts; } ts.isLogicalOperator = isLogicalOperator; function isLogicalOrCoalescingAssignmentOperator(token) { - return token === 74 /* BarBarEqualsToken */ - || token === 75 /* AmpersandAmpersandEqualsToken */ - || token === 76 /* QuestionQuestionEqualsToken */; + return token === 75 /* BarBarEqualsToken */ + || token === 76 /* AmpersandAmpersandEqualsToken */ + || token === 77 /* QuestionQuestionEqualsToken */; } ts.isLogicalOrCoalescingAssignmentOperator = isLogicalOrCoalescingAssignmentOperator; function isLogicalOrCoalescingAssignmentExpression(expr) { @@ -17763,7 +18172,7 @@ var ts; } ts.isLogicalOrCoalescingAssignmentExpression = isLogicalOrCoalescingAssignmentExpression; function isAssignmentOperator(token) { - return token >= 62 /* FirstAssignment */ && token <= 77 /* LastAssignment */; + return token >= 63 /* FirstAssignment */ && token <= 78 /* LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ @@ -17776,23 +18185,27 @@ var ts; return ts.isExpressionWithTypeArguments(node) && ts.isHeritageClause(node.parent) && ts.isClassLike(node.parent.parent) - ? { class: node.parent.parent, isImplements: node.parent.token === 116 /* ImplementsKeyword */ } + ? { class: node.parent.parent, isImplements: node.parent.token === 117 /* ImplementsKeyword */ } : undefined; } ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments = tryGetClassImplementingOrExtendingExpressionWithTypeArguments; function isAssignmentExpression(node, excludeCompoundAssignment) { return ts.isBinaryExpression(node) && (excludeCompoundAssignment - ? node.operatorToken.kind === 62 /* EqualsToken */ + ? node.operatorToken.kind === 63 /* EqualsToken */ : isAssignmentOperator(node.operatorToken.kind)) && ts.isLeftHandSideExpression(node.left); } ts.isAssignmentExpression = isAssignmentExpression; + function isLeftHandSideOfAssignment(node) { + return isAssignmentExpression(node.parent) && node.parent.left === node; + } + ts.isLeftHandSideOfAssignment = isLeftHandSideOfAssignment; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 200 /* ObjectLiteralExpression */ - || kind === 199 /* ArrayLiteralExpression */; + return kind === 202 /* ObjectLiteralExpression */ + || kind === 201 /* ArrayLiteralExpression */; } return false; } @@ -17802,30 +18215,33 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { - return node.kind === 78 /* Identifier */ || isPropertyAccessEntityNameExpression(node); + return node.kind === 79 /* Identifier */ || isPropertyAccessEntityNameExpression(node); } ts.isEntityNameExpression = isEntityNameExpression; function getFirstIdentifier(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return node; - case 157 /* QualifiedName */: + case 159 /* QualifiedName */: do { node = node.left; - } while (node.kind !== 78 /* Identifier */); + } while (node.kind !== 79 /* Identifier */); return node; - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: do { node = node.expression; - } while (node.kind !== 78 /* Identifier */); + } while (node.kind !== 79 /* Identifier */); return node; } } ts.getFirstIdentifier = getFirstIdentifier; function isDottedName(node) { - return node.kind === 78 /* Identifier */ || node.kind === 107 /* ThisKeyword */ || node.kind === 105 /* SuperKeyword */ || - node.kind === 201 /* PropertyAccessExpression */ && isDottedName(node.expression) || - node.kind === 207 /* ParenthesizedExpression */ && isDottedName(node.expression); + return node.kind === 79 /* Identifier */ + || node.kind === 108 /* ThisKeyword */ + || node.kind === 106 /* SuperKeyword */ + || node.kind === 228 /* MetaProperty */ + || node.kind === 203 /* PropertyAccessExpression */ && isDottedName(node.expression) + || node.kind === 209 /* ParenthesizedExpression */ && isDottedName(node.expression); } ts.isDottedName = isDottedName; function isPropertyAccessEntityNameExpression(node) { @@ -17839,6 +18255,12 @@ var ts; return baseStr + "." + entityNameToString(expr.name); } } + else if (ts.isElementAccessExpression(expr)) { + var baseStr = tryGetPropertyAccessOrIdentifierToString(expr.expression); + if (baseStr !== undefined && ts.isPropertyName(expr.argumentExpression)) { + return baseStr + "." + getPropertyNameForPropertyNameNode(expr.argumentExpression); + } + } else if (ts.isIdentifier(expr)) { return ts.unescapeLeadingUnderscores(expr.escapedText); } @@ -17850,22 +18272,28 @@ var ts; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 157 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 201 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 159 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 203 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; + function isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName(node) { + return ts.isQualifiedName(node.parent) && node.parent.right === node + || ts.isPropertyAccessExpression(node.parent) && node.parent.name === node + || ts.isJSDocMemberName(node.parent) && node.parent.right === node; + } + ts.isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName = isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName; function isEmptyObjectLiteral(expression) { - return expression.kind === 200 /* ObjectLiteralExpression */ && + return expression.kind === 202 /* ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 199 /* ArrayLiteralExpression */ && + return expression.kind === 201 /* ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; function getLocalSymbolForExportDefault(symbol) { - if (!isExportDefaultSymbol(symbol)) + if (!isExportDefaultSymbol(symbol) || !symbol.declarations) return undefined; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; @@ -18192,8 +18620,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 255 /* EnumDeclaration */: - case 256 /* ModuleDeclaration */: + case 257 /* EnumDeclaration */: + case 258 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -18220,9 +18648,11 @@ var ts; return symbol.flags & 33554432 /* Transient */ ? symbol.checkFlags : 0; } ts.getCheckFlags = getCheckFlags; - function getDeclarationModifierFlagsFromSymbol(s) { + function getDeclarationModifierFlagsFromSymbol(s, isWrite) { + if (isWrite === void 0) { isWrite = false; } if (s.valueDeclaration) { - var flags = ts.getCombinedModifierFlags(s.valueDeclaration); + var declaration = (isWrite && s.declarations && ts.find(s.declarations, function (d) { return d.kind === 170 /* SetAccessor */; })) || s.valueDeclaration; + var flags = ts.getCombinedModifierFlags(declaration); return s.parent && s.parent.flags & 32 /* Class */ ? flags : flags & ~28 /* AccessibilityModifier */; } if (getCheckFlags(s) & 6 /* Synthetic */) { @@ -18270,35 +18700,35 @@ var ts; if (!parent) return 0 /* Read */; switch (parent.kind) { - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return accessKind(parent); - case 215 /* PostfixUnaryExpression */: - case 214 /* PrefixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: var operator = parent.operator; return operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? - operatorToken.kind === 62 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() + operatorToken.kind === 63 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() : 0 /* Read */; - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return parent.name !== node ? 0 /* Read */ : accessKind(parent); - case 288 /* PropertyAssignment */: { + case 290 /* 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 289 /* ShorthandPropertyAssignment */: + case 291 /* 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 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return accessKind(parent); default: return 0 /* 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 && skipParenthesesUp(parent.parent).kind === 233 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && walkUpParenthesizedExpressions(parent.parent).kind === 235 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; } } function reverseAccessKind(a) { @@ -18386,7 +18816,8 @@ var ts; } ts.isAbstractConstructorSymbol = isAbstractConstructorSymbol; function getClassLikeDeclarationOfSymbol(symbol) { - return ts.find(symbol.declarations, ts.isClassLike); + var _a; + return (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isClassLike); } ts.getClassLikeDeclarationOfSymbol = getClassLikeDeclarationOfSymbol; function getObjectFlags(type) { @@ -18429,7 +18860,6 @@ var ts; ts.getLastChild = getLastChild; function addToSeen(seen, key, value) { if (value === void 0) { value = true; } - key = String(key); if (seen.has(key)) { return false; } @@ -18442,37 +18872,37 @@ var ts; } ts.isObjectTypeDeclaration = isObjectTypeDeclaration; function isTypeNodeKind(kind) { - return (kind >= 172 /* FirstTypeNode */ && kind <= 195 /* LastTypeNode */) - || kind === 128 /* AnyKeyword */ - || kind === 152 /* UnknownKeyword */ - || kind === 144 /* NumberKeyword */ - || kind === 155 /* BigIntKeyword */ - || kind === 145 /* ObjectKeyword */ - || kind === 131 /* BooleanKeyword */ - || kind === 147 /* StringKeyword */ - || kind === 148 /* SymbolKeyword */ - || kind === 113 /* VoidKeyword */ - || kind === 150 /* UndefinedKeyword */ - || kind === 141 /* NeverKeyword */ - || kind === 223 /* ExpressionWithTypeArguments */ - || kind === 303 /* JSDocAllType */ - || kind === 304 /* JSDocUnknownType */ - || kind === 305 /* JSDocNullableType */ - || kind === 306 /* JSDocNonNullableType */ - || kind === 307 /* JSDocOptionalType */ - || kind === 308 /* JSDocFunctionType */ - || kind === 309 /* JSDocVariadicType */; + return (kind >= 174 /* FirstTypeNode */ && kind <= 197 /* LastTypeNode */) + || kind === 129 /* AnyKeyword */ + || kind === 153 /* UnknownKeyword */ + || kind === 145 /* NumberKeyword */ + || kind === 156 /* BigIntKeyword */ + || kind === 146 /* ObjectKeyword */ + || kind === 132 /* BooleanKeyword */ + || kind === 148 /* StringKeyword */ + || kind === 149 /* SymbolKeyword */ + || kind === 114 /* VoidKeyword */ + || kind === 151 /* UndefinedKeyword */ + || kind === 142 /* NeverKeyword */ + || kind === 225 /* ExpressionWithTypeArguments */ + || kind === 306 /* JSDocAllType */ + || kind === 307 /* JSDocUnknownType */ + || kind === 308 /* JSDocNullableType */ + || kind === 309 /* JSDocNonNullableType */ + || kind === 310 /* JSDocOptionalType */ + || kind === 311 /* JSDocFunctionType */ + || kind === 312 /* JSDocVariadicType */; } ts.isTypeNodeKind = isTypeNodeKind; function isAccessExpression(node) { - return node.kind === 201 /* PropertyAccessExpression */ || node.kind === 202 /* ElementAccessExpression */; + return node.kind === 203 /* PropertyAccessExpression */ || node.kind === 204 /* ElementAccessExpression */; } ts.isAccessExpression = isAccessExpression; function getNameOfAccessExpression(node) { - if (node.kind === 201 /* PropertyAccessExpression */) { + if (node.kind === 203 /* PropertyAccessExpression */) { return node.name; } - ts.Debug.assert(node.kind === 202 /* ElementAccessExpression */); + ts.Debug.assert(node.kind === 204 /* ElementAccessExpression */); return node.argumentExpression; } ts.getNameOfAccessExpression = getNameOfAccessExpression; @@ -18487,7 +18917,7 @@ var ts; } ts.isBundleFileTextLike = isBundleFileTextLike; function isNamedImportsOrExports(node) { - return node.kind === 264 /* NamedImports */ || node.kind === 268 /* NamedExports */; + return node.kind === 266 /* NamedImports */ || node.kind === 270 /* NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function getLeftmostAccessExpression(expr) { @@ -18500,28 +18930,28 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: node = node.operand; continue; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: node = node.left; continue; - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: node = node.condition; continue; - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: node = node.tag; continue; - case 203 /* CallExpression */: + case 205 /* CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 224 /* AsExpression */: - case 202 /* ElementAccessExpression */: - case 201 /* PropertyAccessExpression */: - case 225 /* NonNullExpression */: - case 336 /* PartiallyEmittedExpression */: + case 226 /* AsExpression */: + case 204 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 227 /* NonNullExpression */: + case 344 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -18540,7 +18970,7 @@ var ts; } function Type(checker, flags) { this.flags = flags; - if (ts.Debug.isDebugging || ts.tracing.isTracing()) { + if (ts.Debug.isDebugging || ts.tracing) { this.checker = checker; } } @@ -18884,6 +19314,10 @@ var ts; return !!(compilerOptions.declaration || compilerOptions.composite); } ts.getEmitDeclarations = getEmitDeclarations; + function shouldPreserveConstEnums(compilerOptions) { + return !!(compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); + } + ts.shouldPreserveConstEnums = shouldPreserveConstEnums; function isIncrementalCompilation(options) { return !!(options.incremental || options.composite); } @@ -18896,14 +19330,16 @@ var ts; return compilerOptions.allowJs === undefined ? !!compilerOptions.checkJs : compilerOptions.allowJs; } ts.getAllowJSCompilerOption = getAllowJSCompilerOption; + function getUseDefineForClassFields(compilerOptions) { + return compilerOptions.useDefineForClassFields === undefined ? compilerOptions.target === 99 /* ESNext */ : compilerOptions.useDefineForClassFields; + } + ts.getUseDefineForClassFields = getUseDefineForClassFields; function compilerOptionsAffectSemanticDiagnostics(newOptions, oldOptions) { - return oldOptions !== newOptions && - ts.semanticDiagnosticsOptionDeclarations.some(function (option) { return !isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); }); + return optionsHaveChanges(oldOptions, newOptions, ts.semanticDiagnosticsOptionDeclarations); } ts.compilerOptionsAffectSemanticDiagnostics = compilerOptionsAffectSemanticDiagnostics; function compilerOptionsAffectEmit(newOptions, oldOptions) { - return oldOptions !== newOptions && - ts.affectsEmitOptionDeclarations.some(function (option) { return !isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); }); + return optionsHaveChanges(oldOptions, newOptions, ts.affectsEmitOptionDeclarations); } ts.compilerOptionsAffectEmit = compilerOptionsAffectEmit; function getCompilerOptionValue(options, option) { @@ -18917,7 +19353,7 @@ var ts; 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[0] : jsxImportSourcePragmas; + var jsxImportSourcePragma = ts.isArray(jsxImportSourcePragmas) ? jsxImportSourcePragmas[jsxImportSourcePragmas.length - 1] : jsxImportSourcePragmas; return compilerOptions.jsx === 4 /* ReactJSX */ || compilerOptions.jsx === 5 /* ReactJSXDev */ || compilerOptions.jsxImportSource || @@ -18946,37 +19382,65 @@ var ts; return true; } ts.hasZeroOrOneAsteriskCharacter = hasZeroOrOneAsteriskCharacter; - function createSymlinkCache() { + function createSymlinkCache(cwd, getCanonicalFileName) { var symlinkedDirectories; + var symlinkedDirectoriesByRealpath; var symlinkedFiles; return { getSymlinkedFiles: function () { return symlinkedFiles; }, getSymlinkedDirectories: function () { return symlinkedDirectories; }, + getSymlinkedDirectoriesByRealpath: function () { return symlinkedDirectoriesByRealpath; }, setSymlinkedFile: function (path, real) { return (symlinkedFiles || (symlinkedFiles = new ts.Map())).set(path, real); }, - setSymlinkedDirectory: function (path, directory) { return (symlinkedDirectories || (symlinkedDirectories = new ts.Map())).set(path, directory); }, + setSymlinkedDirectory: function (symlink, real) { + // Large, interconnected dependency graphs in pnpm will have a huge number of symlinks + // where both the realpath and the symlink path are inside node_modules/.pnpm. Since + // this path is never a candidate for a module specifier, we can ignore it entirely. + var symlinkPath = ts.toPath(symlink, cwd, getCanonicalFileName); + if (!containsIgnoredPath(symlinkPath)) { + symlinkPath = ts.ensureTrailingDirectorySeparator(symlinkPath); + if (real !== false && !(symlinkedDirectories === null || symlinkedDirectories === void 0 ? void 0 : symlinkedDirectories.has(symlinkPath))) { + (symlinkedDirectoriesByRealpath || (symlinkedDirectoriesByRealpath = ts.createMultiMap())).add(ts.ensureTrailingDirectorySeparator(real.realPath), symlink); + } + (symlinkedDirectories || (symlinkedDirectories = new ts.Map())).set(symlinkPath, real); + } + }, + setSymlinkedDirectoryFromSymlinkedFile: function (symlink, real) { + this.setSymlinkedFile(ts.toPath(symlink, cwd, getCanonicalFileName), real); + var _a = guessDirectorySymlink(real, symlink, cwd, getCanonicalFileName) || ts.emptyArray, commonResolved = _a[0], commonOriginal = _a[1]; + if (commonResolved && commonOriginal) { + this.setSymlinkedDirectory(commonOriginal, { + real: commonResolved, + realPath: ts.toPath(commonResolved, cwd, getCanonicalFileName), + }); + } + }, }; } ts.createSymlinkCache = createSymlinkCache; function discoverProbableSymlinks(files, getCanonicalFileName, cwd) { - var cache = createSymlinkCache(); - var symlinks = ts.flatten(ts.mapDefined(files, function (sf) { - return sf.resolvedModules && ts.compact(ts.arrayFrom(ts.mapIterator(sf.resolvedModules.values(), function (res) { - return res && res.originalPath && res.resolvedFileName !== res.originalPath ? [res.resolvedFileName, res.originalPath] : undefined; + var cache = createSymlinkCache(cwd, getCanonicalFileName); + var symlinks = ts.flatMap(files, function (sf) { + var pairs = sf.resolvedModules && ts.arrayFrom(ts.mapDefinedIterator(sf.resolvedModules.values(), function (res) { + return (res === null || res === void 0 ? void 0 : res.originalPath) ? [res.resolvedFileName, res.originalPath] : undefined; + })); + return ts.concatenate(pairs, sf.resolvedTypeReferenceDirectiveNames && ts.arrayFrom(ts.mapDefinedIterator(sf.resolvedTypeReferenceDirectiveNames.values(), function (res) { + return (res === null || res === void 0 ? void 0 : res.originalPath) && res.resolvedFileName ? [res.resolvedFileName, res.originalPath] : undefined; }))); - })); + }); for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) { var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1]; + cache.setSymlinkedFile(ts.toPath(originalPath, cwd, getCanonicalFileName), resolvedPath); var _b = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName) || ts.emptyArray, commonResolved = _b[0], commonOriginal = _b[1]; if (commonResolved && commonOriginal) { - cache.setSymlinkedDirectory(ts.toPath(commonOriginal, cwd, getCanonicalFileName), { real: commonResolved, realPath: ts.toPath(commonResolved, cwd, getCanonicalFileName) }); + cache.setSymlinkedDirectory(commonOriginal, { real: commonResolved, realPath: ts.toPath(commonResolved, cwd, getCanonicalFileName) }); } } return cache; } ts.discoverProbableSymlinks = discoverProbableSymlinks; function guessDirectorySymlink(a, b, cwd, getCanonicalFileName) { - var aParts = ts.getPathComponents(ts.toPath(a, cwd, getCanonicalFileName)); - var bParts = ts.getPathComponents(ts.toPath(b, cwd, getCanonicalFileName)); + var aParts = ts.getPathComponents(ts.getNormalizedAbsolutePath(a, cwd)); + var bParts = ts.getPathComponents(ts.getNormalizedAbsolutePath(b, cwd)); var isDirectory = false; while (!isNodeModulesOrScopedPackageDirectory(aParts[aParts.length - 2], getCanonicalFileName) && !isNodeModulesOrScopedPackageDirectory(bParts[bParts.length - 2], getCanonicalFileName) && @@ -19360,6 +19824,14 @@ var ts; return false; } ts.isSupportedSourceFileName = isSupportedSourceFileName; + function numberOfDirectorySeparators(str) { + var match = str.match(/\//g); + return match ? match.length : 0; + } + function compareNumberOfDirectorySeparators(path1, path2) { + return ts.compareValues(numberOfDirectorySeparators(path1), numberOfDirectorySeparators(path2)); + } + ts.compareNumberOfDirectorySeparators = compareNumberOfDirectorySeparators; /** * Extension boundaries by priority. Lower numbers indicate higher priorities, and are * aligned to the offset of the highest priority extension in the @@ -19434,16 +19906,27 @@ var ts; return ts.changeAnyExtension(path, newExtension, extensionsToRemove, /*ignoreCase*/ false); } ts.changeExtension = changeExtension; + /** + * Returns the input if there are no stars, a pattern if there is exactly one, + * and undefined if there are more. + */ function tryParsePattern(pattern) { - // This should be verified outside of here and a proper error thrown. - ts.Debug.assert(hasZeroOrOneAsteriskCharacter(pattern)); var indexOfStar = pattern.indexOf("*"); - return indexOfStar === -1 ? undefined : { - prefix: pattern.substr(0, indexOfStar), - suffix: pattern.substr(indexOfStar + 1) - }; + if (indexOfStar === -1) { + return pattern; + } + return pattern.indexOf("*", indexOfStar + 1) !== -1 + ? undefined + : { + prefix: pattern.substr(0, indexOfStar), + suffix: pattern.substr(indexOfStar + 1) + }; } ts.tryParsePattern = tryParsePattern; + function tryParsePatterns(paths) { + return ts.mapDefined(ts.getOwnKeys(paths), function (path) { return tryParsePattern(path); }); + } + ts.tryParsePatterns = tryParsePatterns; function positionIsSynthesized(pos) { // This is a fast way of testing the following conditions: // pos === undefined || pos === null || isNaN(pos) || pos < 0; @@ -19485,23 +19968,19 @@ var ts; directories: ts.emptyArray }; /** - * patternStrings contains both pattern strings (containing "*") and regular strings. + * patternOrStrings contains both patterns (containing "*") and regular strings. * Return an exact match if possible, or a pattern match, or undefined. * (These are verified by verifyCompilerOptions to have 0 or 1 "*" characters.) */ - function matchPatternOrExact(patternStrings, candidate) { + function matchPatternOrExact(patternOrStrings, candidate) { var patterns = []; - for (var _i = 0, patternStrings_1 = patternStrings; _i < patternStrings_1.length; _i++) { - var patternString = patternStrings_1[_i]; - if (!hasZeroOrOneAsteriskCharacter(patternString)) - continue; - var pattern = tryParsePattern(patternString); - if (pattern) { - patterns.push(pattern); + for (var _i = 0, patternOrStrings_1 = patternOrStrings; _i < patternOrStrings_1.length; _i++) { + var patternOrString = patternOrStrings_1[_i]; + if (patternOrString === candidate) { + return candidate; } - else if (patternString === candidate) { - // pattern was matched as is - no need to search further - return patternString; + if (!ts.isString(patternOrString)) { + patterns.push(patternOrString); } } return ts.findBestPatternMatch(patterns, function (_) { return _; }, candidate); @@ -19656,38 +20135,38 @@ var ts; } ts.isValidTypeOnlyAliasUseSite = isValidTypeOnlyAliasUseSite; function typeOnlyDeclarationIsExport(typeOnlyDeclaration) { - return typeOnlyDeclaration.kind === 270 /* ExportSpecifier */; + return typeOnlyDeclaration.kind === 272 /* ExportSpecifier */; } ts.typeOnlyDeclarationIsExport = typeOnlyDeclarationIsExport; function isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(node) { - while (node.kind === 78 /* Identifier */ || node.kind === 201 /* PropertyAccessExpression */) { + while (node.kind === 79 /* Identifier */ || node.kind === 203 /* PropertyAccessExpression */) { node = node.parent; } - if (node.kind !== 158 /* ComputedPropertyName */) { + if (node.kind !== 160 /* ComputedPropertyName */) { return false; } if (hasSyntacticModifier(node.parent, 128 /* Abstract */)) { return true; } var containerKind = node.parent.parent.kind; - return containerKind === 253 /* InterfaceDeclaration */ || containerKind === 177 /* TypeLiteral */; + return containerKind === 255 /* InterfaceDeclaration */ || containerKind === 179 /* 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 !== 78 /* Identifier */) + if (node.kind !== 79 /* Identifier */) return false; var heritageClause = ts.findAncestor(node.parent, function (parent) { switch (parent.kind) { - case 286 /* HeritageClause */: + case 288 /* HeritageClause */: return true; - case 201 /* PropertyAccessExpression */: - case 223 /* ExpressionWithTypeArguments */: + case 203 /* PropertyAccessExpression */: + case 225 /* ExpressionWithTypeArguments */: return false; default: return "quit"; } }); - return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 116 /* ImplementsKeyword */ || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 253 /* InterfaceDeclaration */; + return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 117 /* ImplementsKeyword */ || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 255 /* InterfaceDeclaration */; } function isIdentifierTypeReference(node) { return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName); @@ -19840,6 +20319,76 @@ var ts; } } ts.expressionResultIsUnused = expressionResultIsUnused; + function containsIgnoredPath(path) { + return ts.some(ts.ignoredPaths, function (p) { return ts.stringContains(path, p); }); + } + ts.containsIgnoredPath = containsIgnoredPath; + function getContainingNodeArray(node) { + if (!node.parent) + return undefined; + switch (node.kind) { + case 161 /* TypeParameter */: + var parent_1 = node.parent; + return parent_1.kind === 187 /* InferType */ ? undefined : parent_1.typeParameters; + case 162 /* Parameter */: + return node.parent.parameters; + case 196 /* TemplateLiteralTypeSpan */: + return node.parent.templateSpans; + case 230 /* TemplateSpan */: + return node.parent.templateSpans; + case 163 /* Decorator */: + return node.parent.decorators; + case 288 /* HeritageClause */: + return node.parent.heritageClauses; + } + var parent = node.parent; + if (ts.isJSDocTag(node)) { + return ts.isJSDocTypeLiteral(node.parent) ? undefined : node.parent.tags; + } + switch (parent.kind) { + case 179 /* TypeLiteral */: + case 255 /* InterfaceDeclaration */: + return ts.isTypeElement(node) ? parent.members : undefined; + case 184 /* UnionType */: + case 185 /* IntersectionType */: + return parent.types; + case 181 /* TupleType */: + case 201 /* ArrayLiteralExpression */: + case 345 /* CommaListExpression */: + case 266 /* NamedImports */: + case 270 /* NamedExports */: + return parent.elements; + case 202 /* ObjectLiteralExpression */: + case 283 /* JsxAttributes */: + return parent.properties; + case 205 /* CallExpression */: + case 206 /* NewExpression */: + return ts.isTypeNode(node) ? parent.typeArguments : + parent.expression === node ? undefined : + parent.arguments; + case 275 /* JsxElement */: + case 279 /* JsxFragment */: + return ts.isJsxChild(node) ? parent.children : undefined; + case 277 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: + return ts.isTypeNode(node) ? parent.typeArguments : undefined; + case 232 /* Block */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: + case 259 /* ModuleBlock */: + return parent.statements; + case 260 /* CaseBlock */: + return parent.clauses; + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + return ts.isClassElement(node) ? parent.members : undefined; + case 257 /* EnumDeclaration */: + return ts.isEnumMember(node) ? parent.members : undefined; + case 299 /* SourceFile */: + return parent.statements; + } + } + ts.getContainingNodeArray = getContainingNodeArray; })(ts || (ts = {})); /* @internal */ var ts; @@ -19884,7 +20433,11 @@ var ts; var ts; (function (ts) { function createParenthesizerRules(factory) { + var binaryLeftOperandParenthesizerCache; + var binaryRightOperandParenthesizerCache; return { + getParenthesizeLeftSideOfBinaryForOperator: getParenthesizeLeftSideOfBinaryForOperator, + getParenthesizeRightSideOfBinaryForOperator: getParenthesizeRightSideOfBinaryForOperator, parenthesizeLeftSideOfBinary: parenthesizeLeftSideOfBinary, parenthesizeRightSideOfBinary: parenthesizeRightSideOfBinary, parenthesizeExpressionOfComputedPropertyName: parenthesizeExpressionOfComputedPropertyName, @@ -19905,6 +20458,24 @@ var ts; parenthesizeConstituentTypesOfUnionOrIntersectionType: parenthesizeConstituentTypesOfUnionOrIntersectionType, parenthesizeTypeArguments: parenthesizeTypeArguments, }; + function getParenthesizeLeftSideOfBinaryForOperator(operatorKind) { + binaryLeftOperandParenthesizerCache || (binaryLeftOperandParenthesizerCache = new ts.Map()); + var parenthesizerRule = binaryLeftOperandParenthesizerCache.get(operatorKind); + if (!parenthesizerRule) { + parenthesizerRule = function (node) { return parenthesizeLeftSideOfBinary(operatorKind, node); }; + binaryLeftOperandParenthesizerCache.set(operatorKind, parenthesizerRule); + } + return parenthesizerRule; + } + function getParenthesizeRightSideOfBinaryForOperator(operatorKind) { + binaryRightOperandParenthesizerCache || (binaryRightOperandParenthesizerCache = new ts.Map()); + var parenthesizerRule = binaryRightOperandParenthesizerCache.get(operatorKind); + if (!parenthesizerRule) { + parenthesizerRule = function (node) { return parenthesizeRightSideOfBinary(operatorKind, /*leftSide*/ undefined, node); }; + binaryRightOperandParenthesizerCache.set(operatorKind, parenthesizerRule); + } + return parenthesizerRule; + } /** * Determines whether the operand to a BinaryExpression needs to be parenthesized. * @@ -19931,10 +20502,10 @@ 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(216 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(216 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(218 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(218 /* BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); - if (!isLeftSideOfBinary && operand.kind === 209 /* ArrowFunction */ && binaryOperatorPrecedence > 3 /* Assignment */) { + if (!isLeftSideOfBinary && operand.kind === 211 /* ArrowFunction */ && binaryOperatorPrecedence > 3 /* Assignment */) { // We need to parenthesize arrow functions on the right side to avoid it being // parsed as parenthesized expression: `a && (() => {})` return true; @@ -19946,7 +20517,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 219 /* YieldExpression */) { + && operand.kind === 221 /* YieldExpression */) { return false; } return true; @@ -20034,7 +20605,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 216 /* BinaryExpression */ && node.operatorToken.kind === 39 /* PlusToken */) { + if (node.kind === 218 /* BinaryExpression */ && node.operatorToken.kind === 39 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -20060,7 +20631,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 === 207 /* ParenthesizedExpression */) { + if (skipped.kind === 209 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -20077,7 +20648,7 @@ var ts; return ts.isCommaSequence(expression) ? factory.createParenthesizedExpression(expression) : expression; } function parenthesizeConditionOfConditionalExpression(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(217 /* ConditionalExpression */, 57 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(219 /* ConditionalExpression */, 57 /* QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) !== 1 /* GreaterThan */) { @@ -20110,8 +20681,8 @@ var ts; var needsParens = ts.isCommaSequence(check); if (!needsParens) { switch (ts.getLeftmostExpression(check, /*stopAtCallExpression*/ false).kind) { - case 221 /* ClassExpression */: - case 208 /* FunctionExpression */: + case 223 /* ClassExpression */: + case 210 /* FunctionExpression */: needsParens = true; } } @@ -20124,9 +20695,9 @@ var ts; function parenthesizeExpressionOfNew(expression) { var leftmostExpr = ts.getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 203 /* CallExpression */: + case 205 /* CallExpression */: return factory.createParenthesizedExpression(expression); - case 204 /* NewExpression */: + case 206 /* NewExpression */: return !leftmostExpr.arguments ? factory.createParenthesizedExpression(expression) : expression; // TODO(rbuckton): Verify this assertion holds @@ -20146,7 +20717,7 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 204 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 206 /* NewExpression */ || emittedExpression.arguments)) { // TODO(rbuckton): Verify whether this assertion holds. return expression; } @@ -20168,7 +20739,7 @@ var ts; function parenthesizeExpressionForDisallowedComma(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(216 /* BinaryExpression */, 27 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(218 /* BinaryExpression */, 27 /* CommaToken */); // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(factory.createParenthesizedExpression(expression), expression); } @@ -20177,44 +20748,44 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 208 /* FunctionExpression */ || kind === 209 /* ArrowFunction */) { + if (kind === 210 /* FunctionExpression */ || kind === 211 /* 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 */); } } var leftmostExpressionKind = ts.getLeftmostExpression(emittedExpression, /*stopAtCallExpressions*/ false).kind; - if (leftmostExpressionKind === 200 /* ObjectLiteralExpression */ || leftmostExpressionKind === 208 /* FunctionExpression */) { + if (leftmostExpressionKind === 202 /* ObjectLiteralExpression */ || leftmostExpressionKind === 210 /* 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 === 200 /* ObjectLiteralExpression */)) { + if (!ts.isBlock(body) && (ts.isCommaSequence(body) || ts.getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 202 /* ObjectLiteralExpression */)) { // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return ts.setTextRange(factory.createParenthesizedExpression(body), body); } return body; } function parenthesizeMemberOfConditionalType(member) { - return member.kind === 184 /* ConditionalType */ ? factory.createParenthesizedType(member) : member; + return member.kind === 186 /* ConditionalType */ ? factory.createParenthesizedType(member) : member; } function parenthesizeMemberOfElementType(member) { switch (member.kind) { - case 182 /* UnionType */: - case 183 /* IntersectionType */: - case 174 /* FunctionType */: - case 175 /* ConstructorType */: + case 184 /* UnionType */: + case 185 /* IntersectionType */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: return factory.createParenthesizedType(member); } return parenthesizeMemberOfConditionalType(member); } function parenthesizeElementTypeOfArrayType(member) { switch (member.kind) { - case 176 /* TypeQuery */: - case 188 /* TypeOperator */: - case 185 /* InferType */: + case 178 /* TypeQuery */: + case 190 /* TypeOperator */: + case 187 /* InferType */: return factory.createParenthesizedType(member); } return parenthesizeMemberOfElementType(member); @@ -20233,6 +20804,8 @@ var ts; } ts.createParenthesizerRules = createParenthesizerRules; ts.nullParenthesizerRules = { + getParenthesizeLeftSideOfBinaryForOperator: function (_) { return ts.identity; }, + getParenthesizeRightSideOfBinaryForOperator: function (_) { return ts.identity; }, parenthesizeLeftSideOfBinary: function (_binaryOperator, leftSide) { return leftSide; }, parenthesizeRightSideOfBinary: function (_binaryOperator, _leftSide, rightSide) { return rightSide; }, parenthesizeExpressionOfComputedPropertyName: ts.identity, @@ -20318,11 +20891,11 @@ var ts; } function convertToAssignmentPattern(node) { switch (node.kind) { - case 197 /* ArrayBindingPattern */: - case 199 /* ArrayLiteralExpression */: + case 199 /* ArrayBindingPattern */: + case 201 /* ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 196 /* ObjectBindingPattern */: - case 200 /* ObjectLiteralExpression */: + case 198 /* ObjectBindingPattern */: + case 202 /* ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -20663,18 +21236,18 @@ var ts; createExternalModuleReference: createExternalModuleReference, updateExternalModuleReference: updateExternalModuleReference, // lazily load factory members for JSDoc types with similar structure - get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(303 /* JSDocAllType */); }, - get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(304 /* JSDocUnknownType */); }, - get createJSDocNonNullableType() { return getJSDocUnaryTypeCreateFunction(306 /* JSDocNonNullableType */); }, - get updateJSDocNonNullableType() { return getJSDocUnaryTypeUpdateFunction(306 /* JSDocNonNullableType */); }, - get createJSDocNullableType() { return getJSDocUnaryTypeCreateFunction(305 /* JSDocNullableType */); }, - get updateJSDocNullableType() { return getJSDocUnaryTypeUpdateFunction(305 /* JSDocNullableType */); }, - get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(307 /* JSDocOptionalType */); }, - get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(307 /* JSDocOptionalType */); }, - get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(309 /* JSDocVariadicType */); }, - get updateJSDocVariadicType() { return getJSDocUnaryTypeUpdateFunction(309 /* JSDocVariadicType */); }, - get createJSDocNamepathType() { return getJSDocUnaryTypeCreateFunction(310 /* JSDocNamepathType */); }, - get updateJSDocNamepathType() { return getJSDocUnaryTypeUpdateFunction(310 /* JSDocNamepathType */); }, + get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(306 /* JSDocAllType */); }, + get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(307 /* JSDocUnknownType */); }, + get createJSDocNonNullableType() { return getJSDocUnaryTypeCreateFunction(309 /* JSDocNonNullableType */); }, + get updateJSDocNonNullableType() { return getJSDocUnaryTypeUpdateFunction(309 /* JSDocNonNullableType */); }, + get createJSDocNullableType() { return getJSDocUnaryTypeCreateFunction(308 /* JSDocNullableType */); }, + get updateJSDocNullableType() { return getJSDocUnaryTypeUpdateFunction(308 /* JSDocNullableType */); }, + get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(310 /* JSDocOptionalType */); }, + get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(310 /* JSDocOptionalType */); }, + get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(312 /* JSDocVariadicType */); }, + get updateJSDocVariadicType() { return getJSDocUnaryTypeUpdateFunction(312 /* JSDocVariadicType */); }, + get createJSDocNamepathType() { return getJSDocUnaryTypeCreateFunction(313 /* JSDocNamepathType */); }, + get updateJSDocNamepathType() { return getJSDocUnaryTypeUpdateFunction(313 /* JSDocNamepathType */); }, createJSDocFunctionType: createJSDocFunctionType, updateJSDocFunctionType: updateJSDocFunctionType, createJSDocTypeLiteral: createJSDocTypeLiteral, @@ -20701,31 +21274,43 @@ var ts; updateJSDocSeeTag: updateJSDocSeeTag, createJSDocNameReference: createJSDocNameReference, updateJSDocNameReference: updateJSDocNameReference, + createJSDocMemberName: createJSDocMemberName, + updateJSDocMemberName: updateJSDocMemberName, + createJSDocLink: createJSDocLink, + updateJSDocLink: updateJSDocLink, + createJSDocLinkCode: createJSDocLinkCode, + updateJSDocLinkCode: updateJSDocLinkCode, + createJSDocLinkPlain: createJSDocLinkPlain, + updateJSDocLinkPlain: updateJSDocLinkPlain, // lazily load factory members for JSDoc tags with similar structure - get createJSDocTypeTag() { return getJSDocTypeLikeTagCreateFunction(329 /* JSDocTypeTag */); }, - get updateJSDocTypeTag() { return getJSDocTypeLikeTagUpdateFunction(329 /* JSDocTypeTag */); }, - get createJSDocReturnTag() { return getJSDocTypeLikeTagCreateFunction(327 /* JSDocReturnTag */); }, - get updateJSDocReturnTag() { return getJSDocTypeLikeTagUpdateFunction(327 /* JSDocReturnTag */); }, - get createJSDocThisTag() { return getJSDocTypeLikeTagCreateFunction(328 /* JSDocThisTag */); }, - get updateJSDocThisTag() { return getJSDocTypeLikeTagUpdateFunction(328 /* JSDocThisTag */); }, - get createJSDocEnumTag() { return getJSDocTypeLikeTagCreateFunction(325 /* JSDocEnumTag */); }, - get updateJSDocEnumTag() { return getJSDocTypeLikeTagUpdateFunction(325 /* JSDocEnumTag */); }, - get createJSDocAuthorTag() { return getJSDocSimpleTagCreateFunction(317 /* JSDocAuthorTag */); }, - get updateJSDocAuthorTag() { return getJSDocSimpleTagUpdateFunction(317 /* JSDocAuthorTag */); }, - get createJSDocClassTag() { return getJSDocSimpleTagCreateFunction(319 /* JSDocClassTag */); }, - get updateJSDocClassTag() { return getJSDocSimpleTagUpdateFunction(319 /* JSDocClassTag */); }, - get createJSDocPublicTag() { return getJSDocSimpleTagCreateFunction(320 /* JSDocPublicTag */); }, - get updateJSDocPublicTag() { return getJSDocSimpleTagUpdateFunction(320 /* JSDocPublicTag */); }, - get createJSDocPrivateTag() { return getJSDocSimpleTagCreateFunction(321 /* JSDocPrivateTag */); }, - get updateJSDocPrivateTag() { return getJSDocSimpleTagUpdateFunction(321 /* JSDocPrivateTag */); }, - get createJSDocProtectedTag() { return getJSDocSimpleTagCreateFunction(322 /* JSDocProtectedTag */); }, - get updateJSDocProtectedTag() { return getJSDocSimpleTagUpdateFunction(322 /* JSDocProtectedTag */); }, - get createJSDocReadonlyTag() { return getJSDocSimpleTagCreateFunction(323 /* JSDocReadonlyTag */); }, - get updateJSDocReadonlyTag() { return getJSDocSimpleTagUpdateFunction(323 /* JSDocReadonlyTag */); }, - get createJSDocDeprecatedTag() { return getJSDocSimpleTagCreateFunction(318 /* JSDocDeprecatedTag */); }, - get updateJSDocDeprecatedTag() { return getJSDocSimpleTagUpdateFunction(318 /* JSDocDeprecatedTag */); }, + get createJSDocTypeTag() { return getJSDocTypeLikeTagCreateFunction(337 /* JSDocTypeTag */); }, + get updateJSDocTypeTag() { return getJSDocTypeLikeTagUpdateFunction(337 /* JSDocTypeTag */); }, + get createJSDocReturnTag() { return getJSDocTypeLikeTagCreateFunction(335 /* JSDocReturnTag */); }, + get updateJSDocReturnTag() { return getJSDocTypeLikeTagUpdateFunction(335 /* JSDocReturnTag */); }, + get createJSDocThisTag() { return getJSDocTypeLikeTagCreateFunction(336 /* JSDocThisTag */); }, + get updateJSDocThisTag() { return getJSDocTypeLikeTagUpdateFunction(336 /* JSDocThisTag */); }, + get createJSDocEnumTag() { return getJSDocTypeLikeTagCreateFunction(333 /* JSDocEnumTag */); }, + get updateJSDocEnumTag() { return getJSDocTypeLikeTagUpdateFunction(333 /* JSDocEnumTag */); }, + get createJSDocAuthorTag() { return getJSDocSimpleTagCreateFunction(324 /* JSDocAuthorTag */); }, + get updateJSDocAuthorTag() { return getJSDocSimpleTagUpdateFunction(324 /* JSDocAuthorTag */); }, + get createJSDocClassTag() { return getJSDocSimpleTagCreateFunction(326 /* JSDocClassTag */); }, + get updateJSDocClassTag() { return getJSDocSimpleTagUpdateFunction(326 /* JSDocClassTag */); }, + get createJSDocPublicTag() { return getJSDocSimpleTagCreateFunction(327 /* JSDocPublicTag */); }, + get updateJSDocPublicTag() { return getJSDocSimpleTagUpdateFunction(327 /* JSDocPublicTag */); }, + get createJSDocPrivateTag() { return getJSDocSimpleTagCreateFunction(328 /* JSDocPrivateTag */); }, + get updateJSDocPrivateTag() { return getJSDocSimpleTagUpdateFunction(328 /* JSDocPrivateTag */); }, + get createJSDocProtectedTag() { return getJSDocSimpleTagCreateFunction(329 /* JSDocProtectedTag */); }, + get updateJSDocProtectedTag() { return getJSDocSimpleTagUpdateFunction(329 /* JSDocProtectedTag */); }, + get createJSDocReadonlyTag() { return getJSDocSimpleTagCreateFunction(330 /* JSDocReadonlyTag */); }, + get updateJSDocReadonlyTag() { return getJSDocSimpleTagUpdateFunction(330 /* JSDocReadonlyTag */); }, + get createJSDocOverrideTag() { return getJSDocSimpleTagCreateFunction(331 /* JSDocOverrideTag */); }, + get updateJSDocOverrideTag() { return getJSDocSimpleTagUpdateFunction(331 /* JSDocOverrideTag */); }, + get createJSDocDeprecatedTag() { return getJSDocSimpleTagCreateFunction(325 /* JSDocDeprecatedTag */); }, + get updateJSDocDeprecatedTag() { return getJSDocSimpleTagUpdateFunction(325 /* JSDocDeprecatedTag */); }, createJSDocUnknownTag: createJSDocUnknownTag, updateJSDocUnknownTag: updateJSDocUnknownTag, + createJSDocText: createJSDocText, + updateJSDocText: updateJSDocText, createJSDocComment: createJSDocComment, updateJSDocComment: updateJSDocComment, createJsxElement: createJsxElement, @@ -20790,7 +21375,7 @@ var ts; cloneNode: cloneNode, // Lazily load factory methods for common operator factories and utilities get createComma() { return getBinaryCreateFunction(27 /* CommaToken */); }, - get createAssignment() { return getBinaryCreateFunction(62 /* EqualsToken */); }, + get createAssignment() { return getBinaryCreateFunction(63 /* EqualsToken */); }, get createLogicalOr() { return getBinaryCreateFunction(56 /* BarBarToken */); }, get createLogicalAnd() { return getBinaryCreateFunction(55 /* AmpersandAmpersandToken */); }, get createBitwiseOr() { return getBinaryCreateFunction(51 /* BarToken */); }, @@ -20909,11 +21494,11 @@ var ts; // don't propagate child flags. if (name) { switch (node.kind) { - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 163 /* PropertyDeclaration */: - case 288 /* PropertyAssignment */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 290 /* PropertyAssignment */: if (ts.isIdentifier(name)) { node.transformFlags |= propagateIdentifierNameFlags(name); break; @@ -20954,7 +21539,7 @@ var ts; function createBaseFunctionLikeDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type, body) { var node = createBaseSignatureDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type); node.body = body; - node.transformFlags |= propagateChildFlags(node.body) & ~8388608 /* ContainsPossibleTopLevelAwait */; + node.transformFlags |= propagateChildFlags(node.body) & ~16777216 /* ContainsPossibleTopLevelAwait */; if (!body) node.transformFlags |= 1 /* ContainsTypeScript */; return node; @@ -21007,7 +21592,7 @@ var ts; var node = createBaseLiteral(8 /* NumericLiteral */, typeof value === "number" ? value + "" : value); node.numericLiteralFlags = numericLiteralFlags; if (numericLiteralFlags & 384 /* BinaryOrOctalSpecifier */) - node.transformFlags |= 256 /* ContainsES2015 */; + node.transformFlags |= 512 /* ContainsES2015 */; return node; } // @api @@ -21026,7 +21611,7 @@ var ts; var node = createBaseStringLiteral(text, isSingleQuote); node.hasExtendedUnicodeEscape = hasExtendedUnicodeEscape; if (hasExtendedUnicodeEscape) - node.transformFlags |= 256 /* ContainsES2015 */; + node.transformFlags |= 512 /* ContainsES2015 */; return node; } // @api @@ -21059,10 +21644,10 @@ var ts; if (originalKeywordKind === undefined && text) { originalKeywordKind = ts.stringToToken(text); } - if (originalKeywordKind === 78 /* Identifier */) { + if (originalKeywordKind === 79 /* Identifier */) { originalKeywordKind = undefined; } - var node = baseFactory.createBaseIdentifierNode(78 /* Identifier */); + var node = baseFactory.createBaseIdentifierNode(79 /* Identifier */); node.originalKeywordKind = originalKeywordKind; node.escapedText = ts.escapeLeadingUnderscores(text); return node; @@ -21081,8 +21666,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 === 130 /* AwaitKeyword */) { - node.transformFlags |= 8388608 /* ContainsPossibleTopLevelAwait */; + if (node.originalKeywordKind === 131 /* AwaitKeyword */) { + node.transformFlags |= 16777216 /* ContainsPossibleTopLevelAwait */; } return node; } @@ -21105,8 +21690,11 @@ var ts; } /** Create a unique temporary variable for use in a loop. */ // @api - function createLoopVariable() { - return createBaseGeneratedIdentifier("", 2 /* Loop */); + function createLoopVariable(reservedInNestedScopes) { + var flags = 2 /* Loop */; + if (reservedInNestedScopes) + flags |= 8 /* ReservedInNestedScopes */; + return createBaseGeneratedIdentifier("", flags); } /** Create a unique name based on the supplied text. */ // @api @@ -21129,9 +21717,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(79 /* PrivateIdentifier */); + var node = baseFactory.createBasePrivateIdentifierNode(80 /* PrivateIdentifier */); node.escapedText = ts.escapeLeadingUnderscores(text); - node.transformFlags |= 4194304 /* ContainsClassFields */; + node.transformFlags |= 8388608 /* ContainsClassFields */; return node; } // @@ -21141,46 +21729,47 @@ var ts; return baseFactory.createBaseTokenNode(kind); } function createToken(token) { - ts.Debug.assert(token >= 0 /* FirstToken */ && token <= 156 /* LastToken */, "Invalid token"); + ts.Debug.assert(token >= 0 /* FirstToken */ && token <= 158 /* 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 !== 78 /* Identifier */, "Invalid token. Use 'createIdentifier' to create identifiers"); + ts.Debug.assert(token !== 79 /* Identifier */, "Invalid token. Use 'createIdentifier' to create identifiers"); var node = createBaseToken(token); var transformFlags = 0 /* None */; switch (token) { - case 129 /* AsyncKeyword */: + case 130 /* AsyncKeyword */: // 'async' modifier is ES2017 (async functions) or ES2018 (async generators) transformFlags = - 64 /* ContainsES2017 */ | - 32 /* ContainsES2018 */; + 128 /* ContainsES2017 */ | + 64 /* ContainsES2018 */; break; - case 122 /* PublicKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 142 /* ReadonlyKeyword */: - case 125 /* AbstractKeyword */: - case 133 /* DeclareKeyword */: - case 84 /* ConstKeyword */: - case 128 /* AnyKeyword */: - case 144 /* NumberKeyword */: - case 155 /* BigIntKeyword */: - case 141 /* NeverKeyword */: - case 145 /* ObjectKeyword */: - case 147 /* StringKeyword */: - case 131 /* BooleanKeyword */: - case 148 /* SymbolKeyword */: - case 113 /* VoidKeyword */: - case 152 /* UnknownKeyword */: - case 150 /* UndefinedKeyword */: // `undefined` is an Identifier in the expression case. + case 123 /* PublicKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + case 143 /* ReadonlyKeyword */: + case 126 /* AbstractKeyword */: + case 134 /* DeclareKeyword */: + case 85 /* ConstKeyword */: + case 129 /* AnyKeyword */: + case 145 /* NumberKeyword */: + case 156 /* BigIntKeyword */: + case 142 /* NeverKeyword */: + case 146 /* ObjectKeyword */: + case 157 /* OverrideKeyword */: + case 148 /* StringKeyword */: + case 132 /* BooleanKeyword */: + case 149 /* SymbolKeyword */: + case 114 /* VoidKeyword */: + case 153 /* UnknownKeyword */: + case 151 /* UndefinedKeyword */: // `undefined` is an Identifier in the expression case. transformFlags = 1 /* ContainsTypeScript */; break; - case 123 /* StaticKeyword */: - case 105 /* SuperKeyword */: - transformFlags = 256 /* ContainsES2015 */; + case 124 /* StaticKeyword */: + case 106 /* SuperKeyword */: + transformFlags = 512 /* ContainsES2015 */; break; - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: // 'this' indicates a lexical 'this' - transformFlags = 4096 /* ContainsLexicalThis */; + transformFlags = 8192 /* ContainsLexicalThis */; break; } if (transformFlags) { @@ -21193,23 +21782,23 @@ var ts; // // @api function createSuper() { - return createToken(105 /* SuperKeyword */); + return createToken(106 /* SuperKeyword */); } // @api function createThis() { - return createToken(107 /* ThisKeyword */); + return createToken(108 /* ThisKeyword */); } // @api function createNull() { - return createToken(103 /* NullKeyword */); + return createToken(104 /* NullKeyword */); } // @api function createTrue() { - return createToken(109 /* TrueKeyword */); + return createToken(110 /* TrueKeyword */); } // @api function createFalse() { - return createToken(94 /* FalseKeyword */); + return createToken(95 /* FalseKeyword */); } // // Modifiers @@ -21222,37 +21811,40 @@ var ts; function createModifiersFromModifierFlags(flags) { var result = []; if (flags & 1 /* Export */) { - result.push(createModifier(92 /* ExportKeyword */)); + result.push(createModifier(93 /* ExportKeyword */)); } if (flags & 2 /* Ambient */) { - result.push(createModifier(133 /* DeclareKeyword */)); + result.push(createModifier(134 /* DeclareKeyword */)); } if (flags & 512 /* Default */) { - result.push(createModifier(87 /* DefaultKeyword */)); + result.push(createModifier(88 /* DefaultKeyword */)); } if (flags & 2048 /* Const */) { - result.push(createModifier(84 /* ConstKeyword */)); + result.push(createModifier(85 /* ConstKeyword */)); } if (flags & 4 /* Public */) { - result.push(createModifier(122 /* PublicKeyword */)); + result.push(createModifier(123 /* PublicKeyword */)); } if (flags & 8 /* Private */) { - result.push(createModifier(120 /* PrivateKeyword */)); + result.push(createModifier(121 /* PrivateKeyword */)); } if (flags & 16 /* Protected */) { - result.push(createModifier(121 /* ProtectedKeyword */)); + result.push(createModifier(122 /* ProtectedKeyword */)); } if (flags & 128 /* Abstract */) { - result.push(createModifier(125 /* AbstractKeyword */)); + result.push(createModifier(126 /* AbstractKeyword */)); } if (flags & 32 /* Static */) { - result.push(createModifier(123 /* StaticKeyword */)); + result.push(createModifier(124 /* StaticKeyword */)); + } + if (flags & 16384 /* Override */) { + result.push(createModifier(157 /* OverrideKeyword */)); } if (flags & 64 /* Readonly */) { - result.push(createModifier(142 /* ReadonlyKeyword */)); + result.push(createModifier(143 /* ReadonlyKeyword */)); } if (flags & 256 /* Async */) { - result.push(createModifier(129 /* AsyncKeyword */)); + result.push(createModifier(130 /* AsyncKeyword */)); } return result; } @@ -21261,7 +21853,7 @@ var ts; // // @api function createQualifiedName(left, right) { - var node = createBaseNode(157 /* QualifiedName */); + var node = createBaseNode(159 /* QualifiedName */); node.left = left; node.right = asName(right); node.transformFlags |= @@ -21278,12 +21870,12 @@ var ts; } // @api function createComputedPropertyName(expression) { - var node = createBaseNode(158 /* ComputedPropertyName */); + var node = createBaseNode(160 /* ComputedPropertyName */); node.expression = parenthesizerRules().parenthesizeExpressionOfComputedPropertyName(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 256 /* ContainsES2015 */ | - 32768 /* ContainsComputedPropertyName */; + 512 /* ContainsES2015 */ | + 65536 /* ContainsComputedPropertyName */; return node; } // @api @@ -21297,7 +21889,7 @@ var ts; // // @api function createTypeParameterDeclaration(name, constraint, defaultType) { - var node = createBaseNamedDeclaration(159 /* TypeParameter */, + var node = createBaseNamedDeclaration(161 /* TypeParameter */, /*decorators*/ undefined, /*modifiers*/ undefined, name); node.constraint = constraint; @@ -21315,7 +21907,7 @@ var ts; } // @api function createParameterDeclaration(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(160 /* Parameter */, decorators, modifiers, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); + var node = createBaseVariableLikeDeclaration(162 /* Parameter */, decorators, modifiers, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.dotDotDotToken = dotDotDotToken; node.questionToken = questionToken; if (ts.isThisIdentifier(node.name)) { @@ -21327,10 +21919,10 @@ var ts; propagateChildFlags(node.questionToken); if (questionToken) node.transformFlags |= 1 /* ContainsTypeScript */; - if (ts.modifiersToFlags(node.modifiers) & 92 /* ParameterPropertyModifier */) - node.transformFlags |= 2048 /* ContainsTypeScriptClassSyntax */; + if (ts.modifiersToFlags(node.modifiers) & 16476 /* ParameterPropertyModifier */) + node.transformFlags |= 4096 /* ContainsTypeScriptClassSyntax */; if (initializer || dotDotDotToken) - node.transformFlags |= 256 /* ContainsES2015 */; + node.transformFlags |= 512 /* ContainsES2015 */; } return node; } @@ -21348,12 +21940,12 @@ var ts; } // @api function createDecorator(expression) { - var node = createBaseNode(161 /* Decorator */); + var node = createBaseNode(163 /* Decorator */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= propagateChildFlags(node.expression) | 1 /* ContainsTypeScript */ | - 2048 /* ContainsTypeScriptClassSyntax */; + 4096 /* ContainsTypeScriptClassSyntax */; return node; } // @api @@ -21367,7 +21959,7 @@ var ts; // // @api function createPropertySignature(modifiers, name, questionToken, type) { - var node = createBaseNamedDeclaration(162 /* PropertySignature */, + var node = createBaseNamedDeclaration(164 /* PropertySignature */, /*decorators*/ undefined, modifiers, name); node.type = type; node.questionToken = questionToken; @@ -21385,15 +21977,15 @@ var ts; } // @api function createPropertyDeclaration(decorators, modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(163 /* PropertyDeclaration */, decorators, modifiers, name, type, initializer); + var node = createBaseVariableLikeDeclaration(165 /* PropertyDeclaration */, decorators, 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) | - 4194304 /* ContainsClassFields */; + 8388608 /* ContainsClassFields */; if (ts.isComputedPropertyName(node.name) || (ts.hasStaticModifier(node) && node.initializer)) { - node.transformFlags |= 2048 /* ContainsTypeScriptClassSyntax */; + node.transformFlags |= 4096 /* ContainsTypeScriptClassSyntax */; } if (questionOrExclamationToken || ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { node.transformFlags |= 1 /* ContainsTypeScript */; @@ -21414,7 +22006,7 @@ var ts; } // @api function createMethodSignature(modifiers, name, questionToken, typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(164 /* MethodSignature */, + var node = createBaseSignatureDeclaration(166 /* MethodSignature */, /*decorators*/ undefined, modifiers, name, typeParameters, parameters, type); node.questionToken = questionToken; node.transformFlags = 1 /* ContainsTypeScript */; @@ -21433,26 +22025,26 @@ var ts; } // @api function createMethodDeclaration(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(165 /* MethodDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(167 /* MethodDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; node.questionToken = questionToken; node.transformFlags |= propagateChildFlags(node.asteriskToken) | propagateChildFlags(node.questionToken) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; if (questionToken) { node.transformFlags |= 1 /* ContainsTypeScript */; } if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { if (asteriskToken) { - node.transformFlags |= 32 /* ContainsES2018 */; + node.transformFlags |= 64 /* ContainsES2018 */; } else { - node.transformFlags |= 64 /* ContainsES2017 */; + node.transformFlags |= 128 /* ContainsES2017 */; } } else if (asteriskToken) { - node.transformFlags |= 512 /* ContainsGenerator */; + node.transformFlags |= 1024 /* ContainsGenerator */; } return node; } @@ -21472,11 +22064,11 @@ var ts; } // @api function createConstructorDeclaration(decorators, modifiers, parameters, body) { - var node = createBaseFunctionLikeDeclaration(166 /* Constructor */, decorators, modifiers, + var node = createBaseFunctionLikeDeclaration(168 /* Constructor */, decorators, modifiers, /*name*/ undefined, /*typeParameters*/ undefined, parameters, /*type*/ undefined, body); - node.transformFlags |= 256 /* ContainsES2015 */; + node.transformFlags |= 512 /* ContainsES2015 */; return node; } // @api @@ -21490,7 +22082,7 @@ var ts; } // @api function createGetAccessorDeclaration(decorators, modifiers, name, parameters, type, body) { - return createBaseFunctionLikeDeclaration(167 /* GetAccessor */, decorators, modifiers, name, + return createBaseFunctionLikeDeclaration(169 /* GetAccessor */, decorators, modifiers, name, /*typeParameters*/ undefined, parameters, type, body); } // @api @@ -21506,7 +22098,7 @@ var ts; } // @api function createSetAccessorDeclaration(decorators, modifiers, name, parameters, body) { - return createBaseFunctionLikeDeclaration(168 /* SetAccessor */, decorators, modifiers, name, + return createBaseFunctionLikeDeclaration(170 /* SetAccessor */, decorators, modifiers, name, /*typeParameters*/ undefined, parameters, /*type*/ undefined, body); } @@ -21522,7 +22114,7 @@ var ts; } // @api function createCallSignature(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(169 /* CallSignature */, + var node = createBaseSignatureDeclaration(171 /* CallSignature */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); @@ -21539,7 +22131,7 @@ var ts; } // @api function createConstructSignature(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(170 /* ConstructSignature */, + var node = createBaseSignatureDeclaration(172 /* ConstructSignature */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); @@ -21556,7 +22148,7 @@ var ts; } // @api function createIndexSignature(decorators, modifiers, parameters, type) { - var node = createBaseSignatureDeclaration(171 /* IndexSignature */, decorators, modifiers, + var node = createBaseSignatureDeclaration(173 /* IndexSignature */, decorators, modifiers, /*name*/ undefined, /*typeParameters*/ undefined, parameters, type); node.transformFlags = 1 /* ContainsTypeScript */; @@ -21573,7 +22165,7 @@ var ts; } // @api function createTemplateLiteralTypeSpan(type, literal) { - var node = createBaseNode(194 /* TemplateLiteralTypeSpan */); + var node = createBaseNode(196 /* TemplateLiteralTypeSpan */); node.type = type; node.literal = literal; node.transformFlags = 1 /* ContainsTypeScript */; @@ -21595,7 +22187,7 @@ var ts; } // @api function createTypePredicateNode(assertsModifier, parameterName, type) { - var node = createBaseNode(172 /* TypePredicate */); + var node = createBaseNode(174 /* TypePredicate */); node.assertsModifier = assertsModifier; node.parameterName = asName(parameterName); node.type = type; @@ -21612,7 +22204,7 @@ var ts; } // @api function createTypeReferenceNode(typeName, typeArguments) { - var node = createBaseNode(173 /* TypeReference */); + var node = createBaseNode(175 /* TypeReference */); node.typeName = asName(typeName); node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(createNodeArray(typeArguments)); node.transformFlags = 1 /* ContainsTypeScript */; @@ -21627,7 +22219,7 @@ var ts; } // @api function createFunctionTypeNode(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(174 /* FunctionType */, + var node = createBaseSignatureDeclaration(176 /* FunctionType */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); @@ -21653,7 +22245,7 @@ var ts; ts.Debug.fail("Incorrect number of arguments specified."); } function createConstructorTypeNode1(modifiers, typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(175 /* ConstructorType */, + var node = createBaseSignatureDeclaration(177 /* ConstructorType */, /*decorators*/ undefined, modifiers, /*name*/ undefined, typeParameters, parameters, type); node.transformFlags = 1 /* ContainsTypeScript */; @@ -21687,7 +22279,7 @@ var ts; } // @api function createTypeQueryNode(exprName) { - var node = createBaseNode(176 /* TypeQuery */); + var node = createBaseNode(178 /* TypeQuery */); node.exprName = exprName; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -21700,7 +22292,7 @@ var ts; } // @api function createTypeLiteralNode(members) { - var node = createBaseNode(177 /* TypeLiteral */); + var node = createBaseNode(179 /* TypeLiteral */); node.members = createNodeArray(members); node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -21713,7 +22305,7 @@ var ts; } // @api function createArrayTypeNode(elementType) { - var node = createBaseNode(178 /* ArrayType */); + var node = createBaseNode(180 /* ArrayType */); node.elementType = parenthesizerRules().parenthesizeElementTypeOfArrayType(elementType); node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -21726,7 +22318,7 @@ var ts; } // @api function createTupleTypeNode(elements) { - var node = createBaseNode(179 /* TupleType */); + var node = createBaseNode(181 /* TupleType */); node.elements = createNodeArray(elements); node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -21739,7 +22331,7 @@ var ts; } // @api function createNamedTupleMember(dotDotDotToken, name, questionToken, type) { - var node = createBaseNode(192 /* NamedTupleMember */); + var node = createBaseNode(194 /* NamedTupleMember */); node.dotDotDotToken = dotDotDotToken; node.name = name; node.questionToken = questionToken; @@ -21758,7 +22350,7 @@ var ts; } // @api function createOptionalTypeNode(type) { - var node = createBaseNode(180 /* OptionalType */); + var node = createBaseNode(182 /* OptionalType */); node.type = parenthesizerRules().parenthesizeElementTypeOfArrayType(type); node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -21771,7 +22363,7 @@ var ts; } // @api function createRestTypeNode(type) { - var node = createBaseNode(181 /* RestType */); + var node = createBaseNode(183 /* RestType */); node.type = type; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -21795,7 +22387,7 @@ var ts; } // @api function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(182 /* UnionType */, types); + return createUnionOrIntersectionTypeNode(184 /* UnionType */, types); } // @api function updateUnionTypeNode(node, types) { @@ -21803,7 +22395,7 @@ var ts; } // @api function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(183 /* IntersectionType */, types); + return createUnionOrIntersectionTypeNode(185 /* IntersectionType */, types); } // @api function updateIntersectionTypeNode(node, types) { @@ -21811,7 +22403,7 @@ var ts; } // @api function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createBaseNode(184 /* ConditionalType */); + var node = createBaseNode(186 /* ConditionalType */); node.checkType = parenthesizerRules().parenthesizeMemberOfConditionalType(checkType); node.extendsType = parenthesizerRules().parenthesizeMemberOfConditionalType(extendsType); node.trueType = trueType; @@ -21830,7 +22422,7 @@ var ts; } // @api function createInferTypeNode(typeParameter) { - var node = createBaseNode(185 /* InferType */); + var node = createBaseNode(187 /* InferType */); node.typeParameter = typeParameter; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -21843,7 +22435,7 @@ var ts; } // @api function createTemplateLiteralType(head, templateSpans) { - var node = createBaseNode(193 /* TemplateLiteralType */); + var node = createBaseNode(195 /* TemplateLiteralType */); node.head = head; node.templateSpans = createNodeArray(templateSpans); node.transformFlags = 1 /* ContainsTypeScript */; @@ -21859,7 +22451,7 @@ var ts; // @api function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { if (isTypeOf === void 0) { isTypeOf = false; } - var node = createBaseNode(195 /* ImportType */); + var node = createBaseNode(197 /* ImportType */); node.argument = argument; node.qualifier = qualifier; node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); @@ -21879,7 +22471,7 @@ var ts; } // @api function createParenthesizedType(type) { - var node = createBaseNode(186 /* ParenthesizedType */); + var node = createBaseNode(188 /* ParenthesizedType */); node.type = type; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -21892,13 +22484,13 @@ var ts; } // @api function createThisTypeNode() { - var node = createBaseNode(187 /* ThisType */); + var node = createBaseNode(189 /* ThisType */); node.transformFlags = 1 /* ContainsTypeScript */; return node; } // @api function createTypeOperatorNode(operator, type) { - var node = createBaseNode(188 /* TypeOperator */); + var node = createBaseNode(190 /* TypeOperator */); node.operator = operator; node.type = parenthesizerRules().parenthesizeMemberOfElementType(type); node.transformFlags = 1 /* ContainsTypeScript */; @@ -21912,7 +22504,7 @@ var ts; } // @api function createIndexedAccessTypeNode(objectType, indexType) { - var node = createBaseNode(189 /* IndexedAccessType */); + var node = createBaseNode(191 /* IndexedAccessType */); node.objectType = parenthesizerRules().parenthesizeMemberOfElementType(objectType); node.indexType = indexType; node.transformFlags = 1 /* ContainsTypeScript */; @@ -21927,7 +22519,7 @@ var ts; } // @api function createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type) { - var node = createBaseNode(190 /* MappedType */); + var node = createBaseNode(192 /* MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.nameType = nameType; @@ -21948,7 +22540,7 @@ var ts; } // @api function createLiteralTypeNode(literal) { - var node = createBaseNode(191 /* LiteralType */); + var node = createBaseNode(193 /* LiteralType */); node.literal = literal; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -21964,16 +22556,16 @@ var ts; // // @api function createObjectBindingPattern(elements) { - var node = createBaseNode(196 /* ObjectBindingPattern */); + var node = createBaseNode(198 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements) | - 256 /* ContainsES2015 */ | - 131072 /* ContainsBindingPattern */; - if (node.transformFlags & 8192 /* ContainsRestOrSpread */) { + 512 /* ContainsES2015 */ | + 262144 /* ContainsBindingPattern */; + if (node.transformFlags & 16384 /* ContainsRestOrSpread */) { node.transformFlags |= - 32 /* ContainsES2018 */ | - 16384 /* ContainsObjectRestOrSpread */; + 64 /* ContainsES2018 */ | + 32768 /* ContainsObjectRestOrSpread */; } return node; } @@ -21985,12 +22577,12 @@ var ts; } // @api function createArrayBindingPattern(elements) { - var node = createBaseNode(197 /* ArrayBindingPattern */); + var node = createBaseNode(199 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements) | - 256 /* ContainsES2015 */ | - 131072 /* ContainsBindingPattern */; + 512 /* ContainsES2015 */ | + 262144 /* ContainsBindingPattern */; return node; } // @api @@ -22001,21 +22593,21 @@ var ts; } // @api function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createBaseBindingLikeDeclaration(198 /* BindingElement */, + var node = createBaseBindingLikeDeclaration(200 /* BindingElement */, /*decorators*/ undefined, - /*modifiers*/ undefined, name, initializer); + /*modifiers*/ undefined, name, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.propertyName = asName(propertyName); node.dotDotDotToken = dotDotDotToken; node.transformFlags |= propagateChildFlags(node.dotDotDotToken) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; if (node.propertyName) { node.transformFlags |= ts.isIdentifier(node.propertyName) ? propagateIdentifierNameFlags(node.propertyName) : propagateChildFlags(node.propertyName); } if (dotDotDotToken) - node.transformFlags |= 8192 /* ContainsRestOrSpread */; + node.transformFlags |= 16384 /* ContainsRestOrSpread */; return node; } // @api @@ -22037,7 +22629,7 @@ var ts; } // @api function createArrayLiteralExpression(elements, multiLine) { - var node = createBaseExpression(199 /* ArrayLiteralExpression */); + var node = createBaseExpression(201 /* ArrayLiteralExpression */); node.elements = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(elements)); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.elements); @@ -22051,7 +22643,7 @@ var ts; } // @api function createObjectLiteralExpression(properties, multiLine) { - var node = createBaseExpression(200 /* ObjectLiteralExpression */); + var node = createBaseExpression(202 /* ObjectLiteralExpression */); node.properties = createNodeArray(properties); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.properties); @@ -22065,7 +22657,7 @@ var ts; } // @api function createPropertyAccessExpression(expression, name) { - var node = createBaseExpression(201 /* PropertyAccessExpression */); + var node = createBaseExpression(203 /* PropertyAccessExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.name = asName(name); node.transformFlags = @@ -22077,8 +22669,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 |= - 64 /* ContainsES2017 */ | - 32 /* ContainsES2018 */; + 128 /* ContainsES2017 */ | + 64 /* ContainsES2018 */; } return node; } @@ -22094,13 +22686,13 @@ var ts; } // @api function createPropertyAccessChain(expression, questionDotToken, name) { - var node = createBaseExpression(201 /* PropertyAccessExpression */); + var node = createBaseExpression(203 /* PropertyAccessExpression */); node.flags |= 32 /* OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.questionDotToken = questionDotToken; node.name = asName(name); node.transformFlags |= - 8 /* ContainsES2020 */ | + 16 /* ContainsES2020 */ | propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | (ts.isIdentifier(node.name) ? @@ -22121,7 +22713,7 @@ var ts; } // @api function createElementAccessExpression(expression, index) { - var node = createBaseExpression(202 /* ElementAccessExpression */); + var node = createBaseExpression(204 /* ElementAccessExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.argumentExpression = asExpression(index); node.transformFlags |= @@ -22131,8 +22723,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 |= - 64 /* ContainsES2017 */ | - 32 /* ContainsES2018 */; + 128 /* ContainsES2017 */ | + 64 /* ContainsES2018 */; } return node; } @@ -22148,7 +22740,7 @@ var ts; } // @api function createElementAccessChain(expression, questionDotToken, index) { - var node = createBaseExpression(202 /* ElementAccessExpression */); + var node = createBaseExpression(204 /* ElementAccessExpression */); node.flags |= 32 /* OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.questionDotToken = questionDotToken; @@ -22157,7 +22749,7 @@ var ts; propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | propagateChildFlags(node.argumentExpression) | - 8 /* ContainsES2020 */; + 16 /* ContainsES2020 */; return node; } // @api @@ -22173,7 +22765,7 @@ var ts; } // @api function createCallExpression(expression, typeArguments, argumentsArray) { - var node = createBaseExpression(203 /* CallExpression */); + var node = createBaseExpression(205 /* CallExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray)); @@ -22185,10 +22777,10 @@ var ts; node.transformFlags |= 1 /* ContainsTypeScript */; } if (ts.isImportKeyword(node.expression)) { - node.transformFlags |= 2097152 /* ContainsDynamicImport */; + node.transformFlags |= 4194304 /* ContainsDynamicImport */; } else if (ts.isSuperProperty(node.expression)) { - node.transformFlags |= 4096 /* ContainsLexicalThis */; + node.transformFlags |= 8192 /* ContainsLexicalThis */; } return node; } @@ -22205,7 +22797,7 @@ var ts; } // @api function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) { - var node = createBaseExpression(203 /* CallExpression */); + var node = createBaseExpression(205 /* CallExpression */); node.flags |= 32 /* OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.questionDotToken = questionDotToken; @@ -22216,12 +22808,12 @@ var ts; propagateChildFlags(node.questionDotToken) | propagateChildrenFlags(node.typeArguments) | propagateChildrenFlags(node.arguments) | - 8 /* ContainsES2020 */; + 16 /* ContainsES2020 */; if (node.typeArguments) { node.transformFlags |= 1 /* ContainsTypeScript */; } if (ts.isSuperProperty(node.expression)) { - node.transformFlags |= 4096 /* ContainsLexicalThis */; + node.transformFlags |= 8192 /* ContainsLexicalThis */; } return node; } @@ -22237,7 +22829,7 @@ var ts; } // @api function createNewExpression(expression, typeArguments, argumentsArray) { - var node = createBaseExpression(204 /* NewExpression */); + var node = createBaseExpression(206 /* NewExpression */); node.expression = parenthesizerRules().parenthesizeExpressionOfNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(argumentsArray) : undefined; @@ -22245,7 +22837,7 @@ var ts; propagateChildFlags(node.expression) | propagateChildrenFlags(node.typeArguments) | propagateChildrenFlags(node.arguments) | - 8 /* ContainsES2020 */; + 16 /* ContainsES2020 */; if (node.typeArguments) { node.transformFlags |= 1 /* ContainsTypeScript */; } @@ -22261,7 +22853,7 @@ var ts; } // @api function createTaggedTemplateExpression(tag, typeArguments, template) { - var node = createBaseExpression(205 /* TaggedTemplateExpression */); + var node = createBaseExpression(207 /* TaggedTemplateExpression */); node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag); node.typeArguments = asNodeArray(typeArguments); node.template = template; @@ -22269,12 +22861,12 @@ var ts; propagateChildFlags(node.tag) | propagateChildrenFlags(node.typeArguments) | propagateChildFlags(node.template) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; if (node.typeArguments) { node.transformFlags |= 1 /* ContainsTypeScript */; } if (ts.hasInvalidEscape(node.template)) { - node.transformFlags |= 32 /* ContainsES2018 */; + node.transformFlags |= 64 /* ContainsES2018 */; } return node; } @@ -22288,7 +22880,7 @@ var ts; } // @api function createTypeAssertion(type, expression) { - var node = createBaseExpression(206 /* TypeAssertionExpression */); + var node = createBaseExpression(208 /* TypeAssertionExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.type = type; node.transformFlags |= @@ -22306,7 +22898,7 @@ var ts; } // @api function createParenthesizedExpression(expression) { - var node = createBaseExpression(207 /* ParenthesizedExpression */); + var node = createBaseExpression(209 /* ParenthesizedExpression */); node.expression = expression; node.transformFlags = propagateChildFlags(node.expression); return node; @@ -22319,7 +22911,7 @@ var ts; } // @api function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(208 /* FunctionExpression */, + var node = createBaseFunctionLikeDeclaration(210 /* FunctionExpression */, /*decorators*/ undefined, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; node.transformFlags |= propagateChildFlags(node.asteriskToken); @@ -22328,14 +22920,14 @@ var ts; } if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { if (node.asteriskToken) { - node.transformFlags |= 32 /* ContainsES2018 */; + node.transformFlags |= 64 /* ContainsES2018 */; } else { - node.transformFlags |= 64 /* ContainsES2017 */; + node.transformFlags |= 128 /* ContainsES2017 */; } } else if (node.asteriskToken) { - node.transformFlags |= 512 /* ContainsGenerator */; + node.transformFlags |= 1024 /* ContainsGenerator */; } return node; } @@ -22353,15 +22945,15 @@ var ts; } // @api function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createBaseFunctionLikeDeclaration(209 /* ArrowFunction */, + var node = createBaseFunctionLikeDeclaration(211 /* ArrowFunction */, /*decorators*/ undefined, modifiers, /*name*/ undefined, typeParameters, parameters, type, parenthesizerRules().parenthesizeConciseBodyOfArrowFunction(body)); node.equalsGreaterThanToken = equalsGreaterThanToken !== null && equalsGreaterThanToken !== void 0 ? equalsGreaterThanToken : createToken(38 /* EqualsGreaterThanToken */); node.transformFlags |= propagateChildFlags(node.equalsGreaterThanToken) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { - node.transformFlags |= 64 /* ContainsES2017 */; + node.transformFlags |= 128 /* ContainsES2017 */; } return node; } @@ -22378,7 +22970,7 @@ var ts; } // @api function createDeleteExpression(expression) { - var node = createBaseExpression(210 /* DeleteExpression */); + var node = createBaseExpression(212 /* DeleteExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -22391,7 +22983,7 @@ var ts; } // @api function createTypeOfExpression(expression) { - var node = createBaseExpression(211 /* TypeOfExpression */); + var node = createBaseExpression(213 /* TypeOfExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -22404,7 +22996,7 @@ var ts; } // @api function createVoidExpression(expression) { - var node = createBaseExpression(212 /* VoidExpression */); + var node = createBaseExpression(214 /* VoidExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -22417,13 +23009,13 @@ var ts; } // @api function createAwaitExpression(expression) { - var node = createBaseExpression(213 /* AwaitExpression */); + var node = createBaseExpression(215 /* AwaitExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 64 /* ContainsES2017 */ | - 32 /* ContainsES2018 */ | - 524288 /* ContainsAwait */; + 128 /* ContainsES2017 */ | + 64 /* ContainsES2018 */ | + 1048576 /* ContainsAwait */; return node; } // @api @@ -22434,7 +23026,7 @@ var ts; } // @api function createPrefixUnaryExpression(operator, operand) { - var node = createBaseExpression(214 /* PrefixUnaryExpression */); + var node = createBaseExpression(216 /* PrefixUnaryExpression */); node.operator = operator; node.operand = parenthesizerRules().parenthesizeOperandOfPrefixUnary(operand); node.transformFlags |= propagateChildFlags(node.operand); @@ -22448,7 +23040,7 @@ var ts; } // @api function createPostfixUnaryExpression(operand, operator) { - var node = createBaseExpression(215 /* PostfixUnaryExpression */); + var node = createBaseExpression(217 /* PostfixUnaryExpression */); node.operator = operator; node.operand = parenthesizerRules().parenthesizeOperandOfPostfixUnary(operand); node.transformFlags = propagateChildFlags(node.operand); @@ -22462,7 +23054,7 @@ var ts; } // @api function createBinaryExpression(left, operator, right) { - var node = createBaseExpression(216 /* BinaryExpression */); + var node = createBaseExpression(218 /* BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = parenthesizerRules().parenthesizeLeftSideOfBinary(operatorKind, left); @@ -22473,45 +23065,45 @@ var ts; propagateChildFlags(node.operatorToken) | propagateChildFlags(node.right); if (operatorKind === 60 /* QuestionQuestionToken */) { - node.transformFlags |= 8 /* ContainsES2020 */; + node.transformFlags |= 16 /* ContainsES2020 */; } - else if (operatorKind === 62 /* EqualsToken */) { + else if (operatorKind === 63 /* EqualsToken */) { if (ts.isObjectLiteralExpression(node.left)) { node.transformFlags |= - 256 /* ContainsES2015 */ | - 32 /* ContainsES2018 */ | - 1024 /* ContainsDestructuringAssignment */ | + 512 /* ContainsES2015 */ | + 64 /* ContainsES2018 */ | + 2048 /* ContainsDestructuringAssignment */ | propagateAssignmentPatternFlags(node.left); } else if (ts.isArrayLiteralExpression(node.left)) { node.transformFlags |= - 256 /* ContainsES2015 */ | - 1024 /* ContainsDestructuringAssignment */ | + 512 /* ContainsES2015 */ | + 2048 /* ContainsDestructuringAssignment */ | propagateAssignmentPatternFlags(node.left); } } - else if (operatorKind === 42 /* AsteriskAsteriskToken */ || operatorKind === 66 /* AsteriskAsteriskEqualsToken */) { - node.transformFlags |= 128 /* ContainsES2016 */; + else if (operatorKind === 42 /* AsteriskAsteriskToken */ || operatorKind === 67 /* AsteriskAsteriskEqualsToken */) { + node.transformFlags |= 256 /* ContainsES2016 */; } else if (ts.isLogicalOrCoalescingAssignmentOperator(operatorKind)) { - node.transformFlags |= 4 /* ContainsESNext */; + node.transformFlags |= 8 /* ContainsES2021 */; } return node; } function propagateAssignmentPatternFlags(node) { - if (node.transformFlags & 16384 /* ContainsObjectRestOrSpread */) - return 16384 /* ContainsObjectRestOrSpread */; - if (node.transformFlags & 32 /* ContainsES2018 */) { + if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) + return 32768 /* ContainsObjectRestOrSpread */; + if (node.transformFlags & 64 /* 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 & 16384 /* ContainsObjectRestOrSpread */) { - return 16384 /* ContainsObjectRestOrSpread */; + if (target.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { + return 32768 /* ContainsObjectRestOrSpread */; } - if (target.transformFlags & 32 /* ContainsES2018 */) { + if (target.transformFlags & 64 /* ContainsES2018 */) { var flags_1 = propagateAssignmentPatternFlags(target); if (flags_1) return flags_1; @@ -22531,7 +23123,7 @@ var ts; } // @api function createConditionalExpression(condition, questionToken, whenTrue, colonToken, whenFalse) { - var node = createBaseExpression(217 /* ConditionalExpression */); + var node = createBaseExpression(219 /* ConditionalExpression */); node.condition = parenthesizerRules().parenthesizeConditionOfConditionalExpression(condition); node.questionToken = questionToken !== null && questionToken !== void 0 ? questionToken : createToken(57 /* QuestionToken */); node.whenTrue = parenthesizerRules().parenthesizeBranchOfConditionalExpression(whenTrue); @@ -22557,13 +23149,13 @@ var ts; } // @api function createTemplateExpression(head, templateSpans) { - var node = createBaseExpression(218 /* TemplateExpression */); + var node = createBaseExpression(220 /* TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); node.transformFlags |= propagateChildFlags(node.head) | propagateChildrenFlags(node.templateSpans) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; return node; } // @api @@ -22602,9 +23194,9 @@ var ts; node.text = text; node.rawText = rawText; node.templateFlags = templateFlags & 2048 /* TemplateLiteralLikeFlags */; - node.transformFlags |= 256 /* ContainsES2015 */; + node.transformFlags |= 512 /* ContainsES2015 */; if (node.templateFlags) { - node.transformFlags |= 32 /* ContainsES2018 */; + node.transformFlags |= 64 /* ContainsES2018 */; } return node; } @@ -22627,15 +23219,15 @@ var ts; // @api function createYieldExpression(asteriskToken, expression) { ts.Debug.assert(!asteriskToken || !!expression, "A `YieldExpression` with an asteriskToken must have an expression."); - var node = createBaseExpression(219 /* YieldExpression */); + var node = createBaseExpression(221 /* YieldExpression */); node.expression = expression && parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.asteriskToken = asteriskToken; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.asteriskToken) | - 256 /* ContainsES2015 */ | - 32 /* ContainsES2018 */ | - 262144 /* ContainsYield */; + 512 /* ContainsES2015 */ | + 64 /* ContainsES2018 */ | + 524288 /* ContainsYield */; return node; } // @api @@ -22647,12 +23239,12 @@ var ts; } // @api function createSpreadElement(expression) { - var node = createBaseExpression(220 /* SpreadElement */); + var node = createBaseExpression(222 /* SpreadElement */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 256 /* ContainsES2015 */ | - 8192 /* ContainsRestOrSpread */; + 512 /* ContainsES2015 */ | + 16384 /* ContainsRestOrSpread */; return node; } // @api @@ -22663,8 +23255,8 @@ var ts; } // @api function createClassExpression(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseClassLikeDeclaration(221 /* ClassExpression */, decorators, modifiers, name, typeParameters, heritageClauses, members); - node.transformFlags |= 256 /* ContainsES2015 */; + var node = createBaseClassLikeDeclaration(223 /* ClassExpression */, decorators, modifiers, name, typeParameters, heritageClauses, members); + node.transformFlags |= 512 /* ContainsES2015 */; return node; } // @api @@ -22680,17 +23272,17 @@ var ts; } // @api function createOmittedExpression() { - return createBaseExpression(222 /* OmittedExpression */); + return createBaseExpression(224 /* OmittedExpression */); } // @api function createExpressionWithTypeArguments(expression, typeArguments) { - var node = createBaseNode(223 /* ExpressionWithTypeArguments */); + var node = createBaseNode(225 /* ExpressionWithTypeArguments */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); node.transformFlags |= propagateChildFlags(node.expression) | propagateChildrenFlags(node.typeArguments) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; return node; } // @api @@ -22702,7 +23294,7 @@ var ts; } // @api function createAsExpression(expression, type) { - var node = createBaseExpression(224 /* AsExpression */); + var node = createBaseExpression(226 /* AsExpression */); node.expression = expression; node.type = type; node.transformFlags |= @@ -22720,7 +23312,7 @@ var ts; } // @api function createNonNullExpression(expression) { - var node = createBaseExpression(225 /* NonNullExpression */); + var node = createBaseExpression(227 /* NonNullExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= propagateChildFlags(node.expression) | @@ -22738,7 +23330,7 @@ var ts; } // @api function createNonNullChain(expression) { - var node = createBaseExpression(225 /* NonNullExpression */); + var node = createBaseExpression(227 /* NonNullExpression */); node.flags |= 32 /* OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= @@ -22755,15 +23347,15 @@ var ts; } // @api function createMetaProperty(keywordToken, name) { - var node = createBaseExpression(226 /* MetaProperty */); + var node = createBaseExpression(228 /* MetaProperty */); node.keywordToken = keywordToken; node.name = name; node.transformFlags |= propagateChildFlags(node.name); switch (keywordToken) { - case 102 /* NewKeyword */: - node.transformFlags |= 256 /* ContainsES2015 */; + case 103 /* NewKeyword */: + node.transformFlags |= 512 /* ContainsES2015 */; break; - case 99 /* ImportKeyword */: + case 100 /* ImportKeyword */: node.transformFlags |= 4 /* ContainsESNext */; break; default: @@ -22782,13 +23374,13 @@ var ts; // // @api function createTemplateSpan(expression, literal) { - var node = createBaseNode(228 /* TemplateSpan */); + var node = createBaseNode(230 /* TemplateSpan */); node.expression = expression; node.literal = literal; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.literal) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; return node; } // @api @@ -22800,8 +23392,8 @@ var ts; } // @api function createSemicolonClassElement() { - var node = createBaseNode(229 /* SemicolonClassElement */); - node.transformFlags |= 256 /* ContainsES2015 */; + var node = createBaseNode(231 /* SemicolonClassElement */); + node.transformFlags |= 512 /* ContainsES2015 */; return node; } // @@ -22809,7 +23401,7 @@ var ts; // // @api function createBlock(statements, multiLine) { - var node = createBaseNode(230 /* Block */); + var node = createBaseNode(232 /* Block */); node.statements = createNodeArray(statements); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.statements); @@ -22823,7 +23415,7 @@ var ts; } // @api function createVariableStatement(modifiers, declarationList) { - var node = createBaseDeclaration(232 /* VariableStatement */, /*decorators*/ undefined, modifiers); + var node = createBaseDeclaration(234 /* VariableStatement */, /*decorators*/ undefined, modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; node.transformFlags |= propagateChildFlags(node.declarationList); @@ -22841,11 +23433,11 @@ var ts; } // @api function createEmptyStatement() { - return createBaseNode(231 /* EmptyStatement */); + return createBaseNode(233 /* EmptyStatement */); } // @api function createExpressionStatement(expression) { - var node = createBaseNode(233 /* ExpressionStatement */); + var node = createBaseNode(235 /* ExpressionStatement */); node.expression = parenthesizerRules().parenthesizeExpressionOfExpressionStatement(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -22858,7 +23450,7 @@ var ts; } // @api function createIfStatement(expression, thenStatement, elseStatement) { - var node = createBaseNode(234 /* IfStatement */); + var node = createBaseNode(236 /* IfStatement */); node.expression = expression; node.thenStatement = asEmbeddedStatement(thenStatement); node.elseStatement = asEmbeddedStatement(elseStatement); @@ -22878,7 +23470,7 @@ var ts; } // @api function createDoStatement(statement, expression) { - var node = createBaseNode(235 /* DoStatement */); + var node = createBaseNode(237 /* DoStatement */); node.statement = asEmbeddedStatement(statement); node.expression = expression; node.transformFlags |= @@ -22895,7 +23487,7 @@ var ts; } // @api function createWhileStatement(expression, statement) { - var node = createBaseNode(236 /* WhileStatement */); + var node = createBaseNode(238 /* WhileStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -22912,7 +23504,7 @@ var ts; } // @api function createForStatement(initializer, condition, incrementor, statement) { - var node = createBaseNode(237 /* ForStatement */); + var node = createBaseNode(239 /* ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -22935,7 +23527,7 @@ var ts; } // @api function createForInStatement(initializer, expression, statement) { - var node = createBaseNode(238 /* ForInStatement */); + var node = createBaseNode(240 /* ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = asEmbeddedStatement(statement); @@ -22955,7 +23547,7 @@ var ts; } // @api function createForOfStatement(awaitModifier, initializer, expression, statement) { - var node = createBaseNode(239 /* ForOfStatement */); + var node = createBaseNode(241 /* ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); @@ -22965,9 +23557,9 @@ var ts; propagateChildFlags(node.initializer) | propagateChildFlags(node.expression) | propagateChildFlags(node.statement) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; if (awaitModifier) - node.transformFlags |= 32 /* ContainsES2018 */; + node.transformFlags |= 64 /* ContainsES2018 */; return node; } // @api @@ -22981,11 +23573,11 @@ var ts; } // @api function createContinueStatement(label) { - var node = createBaseNode(240 /* ContinueStatement */); + var node = createBaseNode(242 /* ContinueStatement */); node.label = asName(label); node.transformFlags |= propagateChildFlags(node.label) | - 1048576 /* ContainsHoistedDeclarationOrCompletion */; + 2097152 /* ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -22996,11 +23588,11 @@ var ts; } // @api function createBreakStatement(label) { - var node = createBaseNode(241 /* BreakStatement */); + var node = createBaseNode(243 /* BreakStatement */); node.label = asName(label); node.transformFlags |= propagateChildFlags(node.label) | - 1048576 /* ContainsHoistedDeclarationOrCompletion */; + 2097152 /* ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -23011,13 +23603,13 @@ var ts; } // @api function createReturnStatement(expression) { - var node = createBaseNode(242 /* ReturnStatement */); + var node = createBaseNode(244 /* ReturnStatement */); node.expression = expression; // return in an ES2018 async generator must be awaited node.transformFlags |= propagateChildFlags(node.expression) | - 32 /* ContainsES2018 */ | - 1048576 /* ContainsHoistedDeclarationOrCompletion */; + 64 /* ContainsES2018 */ | + 2097152 /* ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -23028,7 +23620,7 @@ var ts; } // @api function createWithStatement(expression, statement) { - var node = createBaseNode(243 /* WithStatement */); + var node = createBaseNode(245 /* WithStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -23045,7 +23637,7 @@ var ts; } // @api function createSwitchStatement(expression, caseBlock) { - var node = createBaseNode(244 /* SwitchStatement */); + var node = createBaseNode(246 /* SwitchStatement */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.caseBlock = caseBlock; node.transformFlags |= @@ -23062,7 +23654,7 @@ var ts; } // @api function createLabeledStatement(label, statement) { - var node = createBaseNode(245 /* LabeledStatement */); + var node = createBaseNode(247 /* LabeledStatement */); node.label = asName(label); node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -23079,7 +23671,7 @@ var ts; } // @api function createThrowStatement(expression) { - var node = createBaseNode(246 /* ThrowStatement */); + var node = createBaseNode(248 /* ThrowStatement */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -23092,7 +23684,7 @@ var ts; } // @api function createTryStatement(tryBlock, catchClause, finallyBlock) { - var node = createBaseNode(247 /* TryStatement */); + var node = createBaseNode(249 /* TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -23112,11 +23704,11 @@ var ts; } // @api function createDebuggerStatement() { - return createBaseNode(248 /* DebuggerStatement */); + return createBaseNode(250 /* DebuggerStatement */); } // @api function createVariableDeclaration(name, exclamationToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(249 /* VariableDeclaration */, + var node = createBaseVariableLikeDeclaration(251 /* VariableDeclaration */, /*decorators*/ undefined, /*modifiers*/ undefined, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.exclamationToken = exclamationToken; @@ -23138,16 +23730,16 @@ var ts; // @api function createVariableDeclarationList(declarations, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createBaseNode(250 /* VariableDeclarationList */); + var node = createBaseNode(252 /* VariableDeclarationList */); node.flags |= flags & 3 /* BlockScoped */; node.declarations = createNodeArray(declarations); node.transformFlags |= propagateChildrenFlags(node.declarations) | - 1048576 /* ContainsHoistedDeclarationOrCompletion */; + 2097152 /* ContainsHoistedDeclarationOrCompletion */; if (flags & 3 /* BlockScoped */) { node.transformFlags |= - 256 /* ContainsES2015 */ | - 65536 /* ContainsBlockScopedBinding */; + 512 /* ContainsES2015 */ | + 131072 /* ContainsBlockScopedBinding */; } return node; } @@ -23159,7 +23751,7 @@ var ts; } // @api function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(251 /* FunctionDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(253 /* FunctionDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; if (!node.body || ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { node.transformFlags = 1 /* ContainsTypeScript */; @@ -23167,17 +23759,17 @@ var ts; else { node.transformFlags |= propagateChildFlags(node.asteriskToken) | - 1048576 /* ContainsHoistedDeclarationOrCompletion */; + 2097152 /* ContainsHoistedDeclarationOrCompletion */; if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { if (node.asteriskToken) { - node.transformFlags |= 32 /* ContainsES2018 */; + node.transformFlags |= 64 /* ContainsES2018 */; } else { - node.transformFlags |= 64 /* ContainsES2017 */; + node.transformFlags |= 128 /* ContainsES2017 */; } } else if (node.asteriskToken) { - node.transformFlags |= 512 /* ContainsGenerator */; + node.transformFlags |= 1024 /* ContainsGenerator */; } } return node; @@ -23197,13 +23789,13 @@ var ts; } // @api function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseClassLikeDeclaration(252 /* ClassDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses, members); + var node = createBaseClassLikeDeclaration(254 /* ClassDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses, members); if (ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { node.transformFlags = 1 /* ContainsTypeScript */; } else { - node.transformFlags |= 256 /* ContainsES2015 */; - if (node.transformFlags & 2048 /* ContainsTypeScriptClassSyntax */) { + node.transformFlags |= 512 /* ContainsES2015 */; + if (node.transformFlags & 4096 /* ContainsTypeScriptClassSyntax */) { node.transformFlags |= 1 /* ContainsTypeScript */; } } @@ -23222,7 +23814,7 @@ var ts; } // @api function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseInterfaceOrClassLikeDeclaration(253 /* InterfaceDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses); + var node = createBaseInterfaceOrClassLikeDeclaration(255 /* InterfaceDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses); node.members = createNodeArray(members); node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -23240,7 +23832,7 @@ var ts; } // @api function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createBaseGenericNamedDeclaration(254 /* TypeAliasDeclaration */, decorators, modifiers, name, typeParameters); + var node = createBaseGenericNamedDeclaration(256 /* TypeAliasDeclaration */, decorators, modifiers, name, typeParameters); node.type = type; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -23257,12 +23849,12 @@ var ts; } // @api function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createBaseNamedDeclaration(255 /* EnumDeclaration */, decorators, modifiers, name); + var node = createBaseNamedDeclaration(257 /* EnumDeclaration */, decorators, modifiers, name); node.members = createNodeArray(members); node.transformFlags |= propagateChildrenFlags(node.members) | 1 /* ContainsTypeScript */; - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await` + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await` return node; } // @api @@ -23277,7 +23869,7 @@ var ts; // @api function createModuleDeclaration(decorators, modifiers, name, body, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createBaseDeclaration(256 /* ModuleDeclaration */, decorators, modifiers); + var node = createBaseDeclaration(258 /* ModuleDeclaration */, decorators, modifiers); node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 1024 /* GlobalAugmentation */); node.name = name; node.body = body; @@ -23290,7 +23882,7 @@ var ts; propagateChildFlags(node.body) | 1 /* ContainsTypeScript */; } - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`. + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`. return node; } // @api @@ -23304,7 +23896,7 @@ var ts; } // @api function createModuleBlock(statements) { - var node = createBaseNode(257 /* ModuleBlock */); + var node = createBaseNode(259 /* ModuleBlock */); node.statements = createNodeArray(statements); node.transformFlags |= propagateChildrenFlags(node.statements); return node; @@ -23317,7 +23909,7 @@ var ts; } // @api function createCaseBlock(clauses) { - var node = createBaseNode(258 /* CaseBlock */); + var node = createBaseNode(260 /* CaseBlock */); node.clauses = createNodeArray(clauses); node.transformFlags |= propagateChildrenFlags(node.clauses); return node; @@ -23330,7 +23922,7 @@ var ts; } // @api function createNamespaceExportDeclaration(name) { - var node = createBaseNamedDeclaration(259 /* NamespaceExportDeclaration */, + var node = createBaseNamedDeclaration(261 /* NamespaceExportDeclaration */, /*decorators*/ undefined, /*modifiers*/ undefined, name); node.transformFlags = 1 /* ContainsTypeScript */; @@ -23344,13 +23936,13 @@ var ts; } // @api function createImportEqualsDeclaration(decorators, modifiers, isTypeOnly, name, moduleReference) { - var node = createBaseNamedDeclaration(260 /* ImportEqualsDeclaration */, decorators, modifiers, name); + var node = createBaseNamedDeclaration(262 /* ImportEqualsDeclaration */, decorators, modifiers, name); node.isTypeOnly = isTypeOnly; node.moduleReference = moduleReference; node.transformFlags |= propagateChildFlags(node.moduleReference); if (!ts.isExternalModuleReference(node.moduleReference)) node.transformFlags |= 1 /* ContainsTypeScript */; - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // Import= declaration is always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Import= declaration is always parsed in an Await context return node; } // @api @@ -23365,13 +23957,13 @@ var ts; } // @api function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createBaseDeclaration(261 /* ImportDeclaration */, decorators, modifiers); + var node = createBaseDeclaration(263 /* ImportDeclaration */, decorators, modifiers); node.importClause = importClause; node.moduleSpecifier = moduleSpecifier; node.transformFlags |= propagateChildFlags(node.importClause) | propagateChildFlags(node.moduleSpecifier); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23385,7 +23977,7 @@ var ts; } // @api function createImportClause(isTypeOnly, name, namedBindings) { - var node = createBaseNode(262 /* ImportClause */); + var node = createBaseNode(264 /* ImportClause */); node.isTypeOnly = isTypeOnly; node.name = name; node.namedBindings = namedBindings; @@ -23395,7 +23987,7 @@ var ts; if (isTypeOnly) { node.transformFlags |= 1 /* ContainsTypeScript */; } - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23408,10 +24000,10 @@ var ts; } // @api function createNamespaceImport(name) { - var node = createBaseNode(263 /* NamespaceImport */); + var node = createBaseNode(265 /* NamespaceImport */); node.name = name; node.transformFlags |= propagateChildFlags(node.name); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23422,12 +24014,12 @@ var ts; } // @api function createNamespaceExport(name) { - var node = createBaseNode(269 /* NamespaceExport */); + var node = createBaseNode(271 /* NamespaceExport */); node.name = name; node.transformFlags |= propagateChildFlags(node.name) | 4 /* ContainsESNext */; - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23438,10 +24030,10 @@ var ts; } // @api function createNamedImports(elements) { - var node = createBaseNode(264 /* NamedImports */); + var node = createBaseNode(266 /* NamedImports */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23452,13 +24044,13 @@ var ts; } // @api function createImportSpecifier(propertyName, name) { - var node = createBaseNode(265 /* ImportSpecifier */); + var node = createBaseNode(267 /* ImportSpecifier */); node.propertyName = propertyName; node.name = name; node.transformFlags |= propagateChildFlags(node.propertyName) | propagateChildFlags(node.name); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23470,13 +24062,13 @@ var ts; } // @api function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createBaseDeclaration(266 /* ExportAssignment */, decorators, modifiers); + var node = createBaseDeclaration(268 /* ExportAssignment */, decorators, modifiers); node.isExportEquals = isExportEquals; node.expression = isExportEquals - ? parenthesizerRules().parenthesizeRightSideOfBinary(62 /* EqualsToken */, /*leftSide*/ undefined, expression) + ? parenthesizerRules().parenthesizeRightSideOfBinary(63 /* EqualsToken */, /*leftSide*/ undefined, expression) : parenthesizerRules().parenthesizeExpressionOfExportDefault(expression); node.transformFlags |= propagateChildFlags(node.expression); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23489,14 +24081,14 @@ var ts; } // @api function createExportDeclaration(decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier) { - var node = createBaseDeclaration(267 /* ExportDeclaration */, decorators, modifiers); + var node = createBaseDeclaration(269 /* ExportDeclaration */, decorators, modifiers); node.isTypeOnly = isTypeOnly; node.exportClause = exportClause; node.moduleSpecifier = moduleSpecifier; node.transformFlags |= propagateChildFlags(node.exportClause) | propagateChildFlags(node.moduleSpecifier); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23511,10 +24103,10 @@ var ts; } // @api function createNamedExports(elements) { - var node = createBaseNode(268 /* NamedExports */); + var node = createBaseNode(270 /* NamedExports */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23525,13 +24117,13 @@ var ts; } // @api function createExportSpecifier(propertyName, name) { - var node = createBaseNode(270 /* ExportSpecifier */); + var node = createBaseNode(272 /* ExportSpecifier */); node.propertyName = asName(propertyName); node.name = asName(name); node.transformFlags |= propagateChildFlags(node.propertyName) | propagateChildFlags(node.name); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23543,7 +24135,7 @@ var ts; } // @api function createMissingDeclaration() { - var node = createBaseDeclaration(271 /* MissingDeclaration */, + var node = createBaseDeclaration(273 /* MissingDeclaration */, /*decorators*/ undefined, /*modifiers*/ undefined); return node; @@ -23553,10 +24145,10 @@ var ts; // // @api function createExternalModuleReference(expression) { - var node = createBaseNode(272 /* ExternalModuleReference */); + var node = createBaseNode(274 /* ExternalModuleReference */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23598,7 +24190,7 @@ var ts; } // @api function createJSDocFunctionType(parameters, type) { - var node = createBaseSignatureDeclaration(308 /* JSDocFunctionType */, + var node = createBaseSignatureDeclaration(311 /* JSDocFunctionType */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, @@ -23615,7 +24207,7 @@ var ts; // @api function createJSDocTypeLiteral(propertyTags, isArrayType) { if (isArrayType === void 0) { isArrayType = false; } - var node = createBaseNode(312 /* JSDocTypeLiteral */); + var node = createBaseNode(316 /* JSDocTypeLiteral */); node.jsDocPropertyTags = asNodeArray(propertyTags); node.isArrayType = isArrayType; return node; @@ -23629,7 +24221,7 @@ var ts; } // @api function createJSDocTypeExpression(type) { - var node = createBaseNode(301 /* JSDocTypeExpression */); + var node = createBaseNode(303 /* JSDocTypeExpression */); node.type = type; return node; } @@ -23641,7 +24233,7 @@ var ts; } // @api function createJSDocSignature(typeParameters, parameters, type) { - var node = createBaseNode(313 /* JSDocSignature */); + var node = createBaseNode(317 /* JSDocSignature */); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; @@ -23670,7 +24262,7 @@ var ts; } // @api function createJSDocTemplateTag(tagName, constraint, typeParameters, comment) { - var node = createBaseJSDocTag(330 /* JSDocTemplateTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("template"), comment); + var node = createBaseJSDocTag(338 /* JSDocTemplateTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("template"), comment); node.constraint = constraint; node.typeParameters = createNodeArray(typeParameters); return node; @@ -23687,7 +24279,7 @@ var ts; } // @api function createJSDocTypedefTag(tagName, typeExpression, fullName, comment) { - var node = createBaseJSDocTag(331 /* JSDocTypedefTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("typedef"), comment); + var node = createBaseJSDocTag(339 /* JSDocTypedefTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("typedef"), comment); node.typeExpression = typeExpression; node.fullName = fullName; node.name = ts.getJSDocTypeAliasName(fullName); @@ -23705,7 +24297,7 @@ var ts; } // @api function createJSDocParameterTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) { - var node = createBaseJSDocTag(326 /* JSDocParameterTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("param"), comment); + var node = createBaseJSDocTag(334 /* JSDocParameterTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("param"), comment); node.typeExpression = typeExpression; node.name = name; node.isNameFirst = !!isNameFirst; @@ -23726,7 +24318,7 @@ var ts; } // @api function createJSDocPropertyTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) { - var node = createBaseJSDocTag(333 /* JSDocPropertyTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("prop"), comment); + var node = createBaseJSDocTag(341 /* JSDocPropertyTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("prop"), comment); node.typeExpression = typeExpression; node.name = name; node.isNameFirst = !!isNameFirst; @@ -23747,7 +24339,7 @@ var ts; } // @api function createJSDocCallbackTag(tagName, typeExpression, fullName, comment) { - var node = createBaseJSDocTag(324 /* JSDocCallbackTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("callback"), comment); + var node = createBaseJSDocTag(332 /* JSDocCallbackTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("callback"), comment); node.typeExpression = typeExpression; node.fullName = fullName; node.name = ts.getJSDocTypeAliasName(fullName); @@ -23765,7 +24357,7 @@ var ts; } // @api function createJSDocAugmentsTag(tagName, className, comment) { - var node = createBaseJSDocTag(315 /* JSDocAugmentsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("augments"), comment); + var node = createBaseJSDocTag(322 /* JSDocAugmentsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("augments"), comment); node.class = className; return node; } @@ -23780,13 +24372,13 @@ var ts; } // @api function createJSDocImplementsTag(tagName, className, comment) { - var node = createBaseJSDocTag(316 /* JSDocImplementsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("implements"), comment); + var node = createBaseJSDocTag(323 /* JSDocImplementsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("implements"), comment); node.class = className; return node; } // @api function createJSDocSeeTag(tagName, name, comment) { - var node = createBaseJSDocTag(332 /* JSDocSeeTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("see"), comment); + var node = createBaseJSDocTag(340 /* JSDocSeeTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("see"), comment); node.name = name; return node; } @@ -23800,7 +24392,7 @@ var ts; } // @api function createJSDocNameReference(name) { - var node = createBaseNode(302 /* JSDocNameReference */); + var node = createBaseNode(304 /* JSDocNameReference */); node.name = name; return node; } @@ -23811,6 +24403,62 @@ var ts; : node; } // @api + function createJSDocMemberName(left, right) { + var node = createBaseNode(305 /* JSDocMemberName */); + node.left = left; + node.right = right; + node.transformFlags |= + propagateChildFlags(node.left) | + propagateChildFlags(node.right); + return node; + } + // @api + function updateJSDocMemberName(node, left, right) { + return node.left !== left + || node.right !== right + ? update(createJSDocMemberName(left, right), node) + : node; + } + // @api + function createJSDocLink(name, text) { + var node = createBaseNode(318 /* JSDocLink */); + node.name = name; + node.text = text; + return node; + } + // @api + function updateJSDocLink(node, name, text) { + return node.name !== name + ? update(createJSDocLink(name, text), node) + : node; + } + // @api + function createJSDocLinkCode(name, text) { + var node = createBaseNode(319 /* JSDocLinkCode */); + node.name = name; + node.text = text; + return node; + } + // @api + function updateJSDocLinkCode(node, name, text) { + return node.name !== name + ? update(createJSDocLinkCode(name, text), node) + : node; + } + // @api + function createJSDocLinkPlain(name, text) { + var node = createBaseNode(320 /* JSDocLinkPlain */); + node.name = name; + node.text = text; + return node; + } + // @api + function updateJSDocLinkPlain(node, name, text) { + return node.name !== name + ? update(createJSDocLinkPlain(name, text), node) + : node; + } + // @api function updateJSDocImplementsTag(node, tagName, className, comment) { if (tagName === void 0) { tagName = getDefaultTagName(node); } return node.tagName !== tagName @@ -23871,7 +24519,7 @@ var ts; } // @api function createJSDocUnknownTag(tagName, comment) { - var node = createBaseJSDocTag(314 /* JSDocTag */, tagName, comment); + var node = createBaseJSDocTag(321 /* JSDocTag */, tagName, comment); return node; } // @api @@ -23882,8 +24530,20 @@ var ts; : node; } // @api + function createJSDocText(text) { + var node = createBaseNode(315 /* JSDocText */); + node.text = text; + return node; + } + // @api + function updateJSDocText(node, text) { + return node.text !== text + ? update(createJSDocText(text), node) + : node; + } + // @api function createJSDocComment(comment, tags) { - var node = createBaseNode(311 /* JSDocComment */); + var node = createBaseNode(314 /* JSDocComment */); node.comment = comment; node.tags = asNodeArray(tags); return node; @@ -23900,7 +24560,7 @@ var ts; // // @api function createJsxElement(openingElement, children, closingElement) { - var node = createBaseNode(273 /* JsxElement */); + var node = createBaseNode(275 /* JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -23921,7 +24581,7 @@ var ts; } // @api function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createBaseNode(274 /* JsxSelfClosingElement */); + var node = createBaseNode(276 /* JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -23945,7 +24605,7 @@ var ts; } // @api function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createBaseNode(275 /* JsxOpeningElement */); + var node = createBaseNode(277 /* JsxOpeningElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -23969,7 +24629,7 @@ var ts; } // @api function createJsxClosingElement(tagName) { - var node = createBaseNode(276 /* JsxClosingElement */); + var node = createBaseNode(278 /* JsxClosingElement */); node.tagName = tagName; node.transformFlags |= propagateChildFlags(node.tagName) | @@ -23984,7 +24644,7 @@ var ts; } // @api function createJsxFragment(openingFragment, children, closingFragment) { - var node = createBaseNode(277 /* JsxFragment */); + var node = createBaseNode(279 /* JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -24020,19 +24680,19 @@ var ts; } // @api function createJsxOpeningFragment() { - var node = createBaseNode(278 /* JsxOpeningFragment */); + var node = createBaseNode(280 /* JsxOpeningFragment */); node.transformFlags |= 2 /* ContainsJsx */; return node; } // @api function createJsxJsxClosingFragment() { - var node = createBaseNode(279 /* JsxClosingFragment */); + var node = createBaseNode(281 /* JsxClosingFragment */); node.transformFlags |= 2 /* ContainsJsx */; return node; } // @api function createJsxAttribute(name, initializer) { - var node = createBaseNode(280 /* JsxAttribute */); + var node = createBaseNode(282 /* JsxAttribute */); node.name = name; node.initializer = initializer; node.transformFlags |= @@ -24050,7 +24710,7 @@ var ts; } // @api function createJsxAttributes(properties) { - var node = createBaseNode(281 /* JsxAttributes */); + var node = createBaseNode(283 /* JsxAttributes */); node.properties = createNodeArray(properties); node.transformFlags |= propagateChildrenFlags(node.properties) | @@ -24065,7 +24725,7 @@ var ts; } // @api function createJsxSpreadAttribute(expression) { - var node = createBaseNode(282 /* JsxSpreadAttribute */); + var node = createBaseNode(284 /* JsxSpreadAttribute */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression) | @@ -24080,7 +24740,7 @@ var ts; } // @api function createJsxExpression(dotDotDotToken, expression) { - var node = createBaseNode(283 /* JsxExpression */); + var node = createBaseNode(285 /* JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; node.transformFlags |= @@ -24100,7 +24760,7 @@ var ts; // // @api function createCaseClause(expression, statements) { - var node = createBaseNode(284 /* CaseClause */); + var node = createBaseNode(286 /* CaseClause */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.statements = createNodeArray(statements); node.transformFlags |= @@ -24117,7 +24777,7 @@ var ts; } // @api function createDefaultClause(statements) { - var node = createBaseNode(285 /* DefaultClause */); + var node = createBaseNode(287 /* DefaultClause */); node.statements = createNodeArray(statements); node.transformFlags = propagateChildrenFlags(node.statements); return node; @@ -24130,15 +24790,15 @@ var ts; } // @api function createHeritageClause(token, types) { - var node = createBaseNode(286 /* HeritageClause */); + var node = createBaseNode(288 /* HeritageClause */); node.token = token; node.types = createNodeArray(types); node.transformFlags |= propagateChildrenFlags(node.types); switch (token) { - case 93 /* ExtendsKeyword */: - node.transformFlags |= 256 /* ContainsES2015 */; + case 94 /* ExtendsKeyword */: + node.transformFlags |= 512 /* ContainsES2015 */; break; - case 116 /* ImplementsKeyword */: + case 117 /* ImplementsKeyword */: node.transformFlags |= 1 /* ContainsTypeScript */; break; default: @@ -24154,7 +24814,7 @@ var ts; } // @api function createCatchClause(variableDeclaration, block) { - var node = createBaseNode(287 /* CatchClause */); + var node = createBaseNode(289 /* CatchClause */); variableDeclaration = !ts.isString(variableDeclaration) ? variableDeclaration : createVariableDeclaration(variableDeclaration, /*exclamationToken*/ undefined, /*type*/ undefined, @@ -24165,7 +24825,7 @@ var ts; propagateChildFlags(node.variableDeclaration) | propagateChildFlags(node.block); if (!variableDeclaration) - node.transformFlags |= 16 /* ContainsES2019 */; + node.transformFlags |= 32 /* ContainsES2019 */; return node; } // @api @@ -24180,7 +24840,7 @@ var ts; // // @api function createPropertyAssignment(name, initializer) { - var node = createBaseNamedDeclaration(288 /* PropertyAssignment */, + var node = createBaseNamedDeclaration(290 /* PropertyAssignment */, /*decorators*/ undefined, /*modifiers*/ undefined, name); node.initializer = parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); @@ -24210,13 +24870,13 @@ var ts; } // @api function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createBaseNamedDeclaration(289 /* ShorthandPropertyAssignment */, + var node = createBaseNamedDeclaration(291 /* ShorthandPropertyAssignment */, /*decorators*/ undefined, /*modifiers*/ undefined, name); node.objectAssignmentInitializer = objectAssignmentInitializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(objectAssignmentInitializer); node.transformFlags |= propagateChildFlags(node.objectAssignmentInitializer) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; return node; } function finishUpdateShorthandPropertyAssignment(updated, original) { @@ -24242,12 +24902,12 @@ var ts; } // @api function createSpreadAssignment(expression) { - var node = createBaseNode(290 /* SpreadAssignment */); + var node = createBaseNode(292 /* SpreadAssignment */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 32 /* ContainsES2018 */ | - 16384 /* ContainsObjectRestOrSpread */; + 64 /* ContainsES2018 */ | + 32768 /* ContainsObjectRestOrSpread */; return node; } // @api @@ -24261,7 +24921,7 @@ var ts; // // @api function createEnumMember(name, initializer) { - var node = createBaseNode(291 /* EnumMember */); + var node = createBaseNode(293 /* EnumMember */); node.name = asName(name); node.initializer = initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); node.transformFlags |= @@ -24282,7 +24942,7 @@ var ts; // // @api function createSourceFile(statements, endOfFileToken, flags) { - var node = baseFactory.createBaseSourceFileNode(297 /* SourceFile */); + var node = baseFactory.createBaseSourceFileNode(299 /* SourceFile */); node.statements = createNodeArray(statements); node.endOfFileToken = endOfFileToken; node.flags |= flags; @@ -24299,7 +24959,7 @@ var ts; return node; } function cloneSourceFileWithChanges(source, statements, isDeclarationFile, referencedFiles, typeReferences, hasNoDefaultLib, libReferences) { - var node = baseFactory.createBaseSourceFileNode(297 /* SourceFile */); + var node = baseFactory.createBaseSourceFileNode(299 /* SourceFile */); for (var p in source) { if (p === "emitNode" || ts.hasProperty(node, p) || !ts.hasProperty(source, p)) continue; @@ -24337,7 +24997,7 @@ var ts; // @api function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = createBaseNode(298 /* Bundle */); + var node = createBaseNode(300 /* Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; @@ -24352,7 +25012,7 @@ var ts; } // @api function createUnparsedSource(prologues, syntheticReferences, texts) { - var node = createBaseNode(299 /* UnparsedSource */); + var node = createBaseNode(301 /* UnparsedSource */); node.prologues = prologues; node.syntheticReferences = syntheticReferences; node.texts = texts; @@ -24370,28 +25030,28 @@ var ts; } // @api function createUnparsedPrologue(data) { - return createBaseUnparsedNode(292 /* UnparsedPrologue */, data); + return createBaseUnparsedNode(294 /* UnparsedPrologue */, data); } // @api function createUnparsedPrepend(data, texts) { - var node = createBaseUnparsedNode(293 /* UnparsedPrepend */, data); + var node = createBaseUnparsedNode(295 /* UnparsedPrepend */, data); node.texts = texts; return node; } // @api function createUnparsedTextLike(data, internal) { - return createBaseUnparsedNode(internal ? 295 /* UnparsedInternalText */ : 294 /* UnparsedText */, data); + return createBaseUnparsedNode(internal ? 297 /* UnparsedInternalText */ : 296 /* UnparsedText */, data); } // @api function createUnparsedSyntheticReference(section) { - var node = createBaseNode(296 /* UnparsedSyntheticReference */); + var node = createBaseNode(298 /* UnparsedSyntheticReference */); node.data = section.data; node.section = section; return node; } // @api function createInputFiles() { - var node = createBaseNode(300 /* InputFiles */); + var node = createBaseNode(302 /* InputFiles */); node.javascriptText = ""; node.declarationText = ""; return node; @@ -24402,7 +25062,7 @@ var ts; // @api function createSyntheticExpression(type, isSpread, tupleNameSource) { if (isSpread === void 0) { isSpread = false; } - var node = createBaseNode(227 /* SyntheticExpression */); + var node = createBaseNode(229 /* SyntheticExpression */); node.type = type; node.isSpread = isSpread; node.tupleNameSource = tupleNameSource; @@ -24410,7 +25070,7 @@ var ts; } // @api function createSyntaxList(children) { - var node = createBaseNode(334 /* SyntaxList */); + var node = createBaseNode(342 /* SyntaxList */); node._children = children; return node; } @@ -24425,7 +25085,7 @@ var ts; */ // @api function createNotEmittedStatement(original) { - var node = createBaseNode(335 /* NotEmittedStatement */); + var node = createBaseNode(343 /* NotEmittedStatement */); node.original = original; ts.setTextRange(node, original); return node; @@ -24439,7 +25099,7 @@ var ts; */ // @api function createPartiallyEmittedExpression(expression, original) { - var node = createBaseNode(336 /* PartiallyEmittedExpression */); + var node = createBaseNode(344 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; node.transformFlags |= @@ -24467,7 +25127,7 @@ var ts; } // @api function createCommaListExpression(elements) { - var node = createBaseNode(337 /* CommaListExpression */); + var node = createBaseNode(345 /* CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); node.transformFlags |= propagateChildrenFlags(node.elements); return node; @@ -24484,7 +25144,7 @@ var ts; */ // @api function createEndOfDeclarationMarker(original) { - var node = createBaseNode(339 /* EndOfDeclarationMarker */); + var node = createBaseNode(347 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -24495,14 +25155,14 @@ var ts; */ // @api function createMergeDeclarationMarker(original) { - var node = createBaseNode(338 /* MergeDeclarationMarker */); + var node = createBaseNode(346 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; } // @api function createSyntheticReferenceExpression(expression, thisArg) { - var node = createBaseNode(340 /* SyntheticReferenceExpression */); + var node = createBaseNode(348 /* SyntheticReferenceExpression */); node.expression = expression; node.thisArg = thisArg; node.transformFlags |= @@ -24524,9 +25184,9 @@ var ts; if (node === undefined) { return node; } - var clone = ts.isSourceFile(node) ? baseFactory.createBaseSourceFileNode(297 /* SourceFile */) : - ts.isIdentifier(node) ? baseFactory.createBaseIdentifierNode(78 /* Identifier */) : - ts.isPrivateIdentifier(node) ? baseFactory.createBasePrivateIdentifierNode(79 /* PrivateIdentifier */) : + var clone = ts.isSourceFile(node) ? baseFactory.createBaseSourceFileNode(299 /* SourceFile */) : + ts.isIdentifier(node) ? baseFactory.createBaseIdentifierNode(79 /* Identifier */) : + ts.isPrivateIdentifier(node) ? baseFactory.createBasePrivateIdentifierNode(80 /* PrivateIdentifier */) : !ts.isNodeKind(node.kind) ? baseFactory.createBaseTokenNode(node.kind) : baseFactory.createBaseNode(node.kind); clone.flags |= (node.flags & ~8 /* Synthesized */); @@ -24631,11 +25291,11 @@ var ts; } function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 207 /* ParenthesizedExpression */: return updateParenthesizedExpression(outerExpression, expression); - case 206 /* TypeAssertionExpression */: return updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 224 /* AsExpression */: return updateAsExpression(outerExpression, expression, outerExpression.type); - case 225 /* NonNullExpression */: return updateNonNullExpression(outerExpression, expression); - case 336 /* PartiallyEmittedExpression */: return updatePartiallyEmittedExpression(outerExpression, expression); + case 209 /* ParenthesizedExpression */: return updateParenthesizedExpression(outerExpression, expression); + case 208 /* TypeAssertionExpression */: return updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 226 /* AsExpression */: return updateAsExpression(outerExpression, expression, outerExpression.type); + case 227 /* NonNullExpression */: return updateNonNullExpression(outerExpression, expression); + case 344 /* PartiallyEmittedExpression */: return updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -24682,20 +25342,20 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = ts.skipParentheses(node); switch (target.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return cacheIdentifiers; - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: return false; - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -25098,23 +25758,24 @@ var ts; } function getDefaultTagNameForKind(kind) { switch (kind) { - case 329 /* JSDocTypeTag */: return "type"; - case 327 /* JSDocReturnTag */: return "returns"; - case 328 /* JSDocThisTag */: return "this"; - case 325 /* JSDocEnumTag */: return "enum"; - case 317 /* JSDocAuthorTag */: return "author"; - case 319 /* JSDocClassTag */: return "class"; - case 320 /* JSDocPublicTag */: return "public"; - case 321 /* JSDocPrivateTag */: return "private"; - case 322 /* JSDocProtectedTag */: return "protected"; - case 323 /* JSDocReadonlyTag */: return "readonly"; - case 330 /* JSDocTemplateTag */: return "template"; - case 331 /* JSDocTypedefTag */: return "typedef"; - case 326 /* JSDocParameterTag */: return "param"; - case 333 /* JSDocPropertyTag */: return "prop"; - case 324 /* JSDocCallbackTag */: return "callback"; - case 315 /* JSDocAugmentsTag */: return "augments"; - case 316 /* JSDocImplementsTag */: return "implements"; + case 337 /* JSDocTypeTag */: return "type"; + case 335 /* JSDocReturnTag */: return "returns"; + case 336 /* JSDocThisTag */: return "this"; + case 333 /* JSDocEnumTag */: return "enum"; + case 324 /* JSDocAuthorTag */: return "author"; + case 326 /* JSDocClassTag */: return "class"; + case 327 /* JSDocPublicTag */: return "public"; + case 328 /* JSDocPrivateTag */: return "private"; + case 329 /* JSDocProtectedTag */: return "protected"; + case 330 /* JSDocReadonlyTag */: return "readonly"; + case 331 /* JSDocOverrideTag */: return "override"; + case 338 /* JSDocTemplateTag */: return "template"; + case 339 /* JSDocTypedefTag */: return "typedef"; + case 334 /* JSDocParameterTag */: return "param"; + case 341 /* JSDocPropertyTag */: return "prop"; + case 332 /* JSDocCallbackTag */: return "callback"; + case 322 /* JSDocAugmentsTag */: return "augments"; + case 323 /* JSDocImplementsTag */: return "implements"; default: return ts.Debug.fail("Unsupported kind: " + ts.Debug.formatSyntaxKind(kind)); } @@ -25167,10 +25828,10 @@ var ts; } function propagateIdentifierNameFlags(node) { // An IdentifierName is allowed to be `await` - return propagateChildFlags(node) & ~8388608 /* ContainsPossibleTopLevelAwait */; + return propagateChildFlags(node) & ~16777216 /* ContainsPossibleTopLevelAwait */; } function propagatePropertyNameFlagsOfChild(node, transformFlags) { - return transformFlags | (node.transformFlags & 4096 /* PropertyNamePropagatingFlags */); + return transformFlags | (node.transformFlags & 8192 /* PropertyNamePropagatingFlags */); } function propagateChildFlags(child) { if (!child) @@ -25194,69 +25855,69 @@ var ts; */ /* @internal */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 172 /* FirstTypeNode */ && kind <= 195 /* LastTypeNode */) { + if (kind >= 174 /* FirstTypeNode */ && kind <= 197 /* LastTypeNode */) { return -2 /* TypeExcludes */; } switch (kind) { - case 203 /* CallExpression */: - case 204 /* NewExpression */: - case 199 /* ArrayLiteralExpression */: - return 536879104 /* ArrayLiteralOrCallOrNewExcludes */; - case 256 /* ModuleDeclaration */: - return 546379776 /* ModuleExcludes */; - case 160 /* Parameter */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: + case 201 /* ArrayLiteralExpression */: + return 536887296 /* ArrayLiteralOrCallOrNewExcludes */; + case 258 /* ModuleDeclaration */: + return 555888640 /* ModuleExcludes */; + case 162 /* Parameter */: return 536870912 /* ParameterExcludes */; - case 209 /* ArrowFunction */: - return 547309568 /* ArrowFunctionExcludes */; - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: - return 547313664 /* FunctionExcludes */; - case 250 /* VariableDeclarationList */: - return 537018368 /* VariableDeclarationListExcludes */; - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - return 536905728 /* ClassExcludes */; - case 166 /* Constructor */: - return 547311616 /* ConstructorExcludes */; - case 163 /* PropertyDeclaration */: - return 536875008 /* PropertyExcludes */; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - return 538923008 /* MethodOrAccessorExcludes */; - case 128 /* AnyKeyword */: - case 144 /* NumberKeyword */: - case 155 /* BigIntKeyword */: - case 141 /* NeverKeyword */: - case 147 /* StringKeyword */: - case 145 /* ObjectKeyword */: - case 131 /* BooleanKeyword */: - case 148 /* SymbolKeyword */: - case 113 /* VoidKeyword */: - case 159 /* TypeParameter */: - case 162 /* PropertySignature */: - case 164 /* MethodSignature */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 211 /* ArrowFunction */: + return 557748224 /* ArrowFunctionExcludes */; + case 210 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + return 557756416 /* FunctionExcludes */; + case 252 /* VariableDeclarationList */: + return 537165824 /* VariableDeclarationListExcludes */; + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + return 536940544 /* ClassExcludes */; + case 168 /* Constructor */: + return 557752320 /* ConstructorExcludes */; + case 165 /* PropertyDeclaration */: + return 536879104 /* PropertyExcludes */; + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + return 540975104 /* MethodOrAccessorExcludes */; + case 129 /* AnyKeyword */: + case 145 /* NumberKeyword */: + case 156 /* BigIntKeyword */: + case 142 /* NeverKeyword */: + case 148 /* StringKeyword */: + case 146 /* ObjectKeyword */: + case 132 /* BooleanKeyword */: + case 149 /* SymbolKeyword */: + case 114 /* VoidKeyword */: + case 161 /* TypeParameter */: + case 164 /* PropertySignature */: + case 166 /* MethodSignature */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 173 /* IndexSignature */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: return -2 /* TypeExcludes */; - case 200 /* ObjectLiteralExpression */: - return 536922112 /* ObjectLiteralExcludes */; - case 287 /* CatchClause */: - return 536887296 /* CatchClauseExcludes */; - case 196 /* ObjectBindingPattern */: - case 197 /* ArrayBindingPattern */: - return 536879104 /* BindingPatternExcludes */; - case 206 /* TypeAssertionExpression */: - case 224 /* AsExpression */: - case 336 /* PartiallyEmittedExpression */: - case 207 /* ParenthesizedExpression */: - case 105 /* SuperKeyword */: + case 202 /* ObjectLiteralExpression */: + return 536973312 /* ObjectLiteralExcludes */; + case 289 /* CatchClause */: + return 536903680 /* CatchClauseExcludes */; + case 198 /* ObjectBindingPattern */: + case 199 /* ArrayBindingPattern */: + return 536887296 /* BindingPatternExcludes */; + case 208 /* TypeAssertionExpression */: + case 226 /* AsExpression */: + case 344 /* PartiallyEmittedExpression */: + case 209 /* ParenthesizedExpression */: + case 106 /* SuperKeyword */: return 536870912 /* OuterExpressionExcludes */; - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: return 536870912 /* PropertyAccessExcludes */; default: return 536870912 /* NodeExcludes */; @@ -25555,7 +26216,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 === 297 /* SourceFile */) { + if (node.kind === 299 /* 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."); @@ -26042,13 +26703,27 @@ var ts; /*typeArguments*/ undefined, [moduleExpression, exportsExpression]); } // Class Fields Helpers - function createClassPrivateFieldGetHelper(receiver, privateField) { + function createClassPrivateFieldGetHelper(receiver, state, kind, f) { context.requestEmitHelper(ts.classPrivateFieldGetHelper); - return factory.createCallExpression(getUnscopedHelperName("__classPrivateFieldGet"), /*typeArguments*/ undefined, [receiver, privateField]); + var args; + if (!f) { + args = [receiver, state, factory.createStringLiteral(kind)]; + } + else { + args = [receiver, state, factory.createStringLiteral(kind), f]; + } + return factory.createCallExpression(getUnscopedHelperName("__classPrivateFieldGet"), /*typeArguments*/ undefined, args); } - function createClassPrivateFieldSetHelper(receiver, privateField, value) { + function createClassPrivateFieldSetHelper(receiver, state, value, kind, f) { context.requestEmitHelper(ts.classPrivateFieldSetHelper); - return factory.createCallExpression(getUnscopedHelperName("__classPrivateFieldSet"), /*typeArguments*/ undefined, [receiver, privateField, value]); + var args; + if (!f) { + args = [receiver, state, value, factory.createStringLiteral(kind)]; + } + else { + args = [receiver, state, value, factory.createStringLiteral(kind), f]; + } + return factory.createCallExpression(getUnscopedHelperName("__classPrivateFieldSet"), /*typeArguments*/ undefined, args); } } ts.createEmitHelperFactory = createEmitHelperFactory; @@ -26288,7 +26963,6 @@ var ts; scoped: false, text: "\n var __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n };" }; - // emit output for the __export helper function ts.exportStarHelper = { name: "typescript:export-star", importName: "__exportStar", @@ -26297,18 +26971,116 @@ var ts; priority: 2, text: "\n var __exportStar = (this && this.__exportStar) || function(m, exports) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\n };" }; - // Class fields helpers + /** + * Parameters: + * @param receiver — The object from which the private member will be read. + * @param state — One of the following: + * - A WeakMap used to read a private instance field. + * - A WeakSet used as an instance brand for private instance methods and accessors. + * - A function value that should be the undecorated class constructor used to brand check private static fields, methods, and accessors. + * @param kind — (optional pre TS 4.3, required for TS 4.3+) One of the following values: + * - undefined — Indicates a private instance field (pre TS 4.3). + * - "f" — Indicates a private field (instance or static). + * - "m" — Indicates a private method (instance or static). + * - "a" — Indicates a private accessor (instance or static). + * @param f — (optional pre TS 4.3) Depends on the arguments for state and kind: + * - If kind is "m", this should be the function corresponding to the static or instance method. + * - If kind is "a", this should be the function corresponding to the getter method, or undefined if the getter was not defined. + * - If kind is "f" and state is a function, this should be an object holding the value of a static field, or undefined if the static field declaration has not yet been evaluated. + * Usage: + * This helper will only ever be used by the compiler in the following ways: + * + * Reading from a private instance field (pre TS 4.3): + * __classPrivateFieldGet(, ) + * + * Reading from a private instance field (TS 4.3+): + * __classPrivateFieldGet(, , "f") + * + * Reading from a private instance get accessor (when defined, TS 4.3+): + * __classPrivateFieldGet(, , "a", ) + * + * Reading from a private instance get accessor (when not defined, TS 4.3+): + * __classPrivateFieldGet(, , "a", void 0) + * NOTE: This always results in a runtime error. + * + * Reading from a private instance method (TS 4.3+): + * __classPrivateFieldGet(, , "m", ) + * + * Reading from a private static field (TS 4.3+): + * __classPrivateFieldGet(, , "f", <{ value: any }>) + * + * Reading from a private static get accessor (when defined, TS 4.3+): + * __classPrivateFieldGet(, , "a", ) + * + * Reading from a private static get accessor (when not defined, TS 4.3+): + * __classPrivateFieldGet(, , "a", void 0) + * NOTE: This always results in a runtime error. + * + * Reading from a private static method (TS 4.3+): + * __classPrivateFieldGet(, , "m", ) + */ ts.classPrivateFieldGetHelper = { name: "typescript:classPrivateFieldGet", importName: "__classPrivateFieldGet", scoped: false, - text: "\n var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, privateMap) {\n if (!privateMap.has(receiver)) {\n throw new TypeError(\"attempted to get private field on non-instance\");\n }\n return privateMap.get(receiver);\n };" + text: "\n var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n };" }; + /** + * Parameters: + * @param receiver — The object on which the private member will be set. + * @param state — One of the following: + * - A WeakMap used to store a private instance field. + * - A WeakSet used as an instance brand for private instance methods and accessors. + * - A function value that should be the undecorated class constructor used to brand check private static fields, methods, and accessors. + * @param value — The value to set. + * @param kind — (optional pre TS 4.3, required for TS 4.3+) One of the following values: + * - undefined — Indicates a private instance field (pre TS 4.3). + * - "f" — Indicates a private field (instance or static). + * - "m" — Indicates a private method (instance or static). + * - "a" — Indicates a private accessor (instance or static). + * @param f — (optional pre TS 4.3) Depends on the arguments for state and kind: + * - If kind is "m", this should be the function corresponding to the static or instance method. + * - If kind is "a", this should be the function corresponding to the setter method, or undefined if the setter was not defined. + * - If kind is "f" and state is a function, this should be an object holding the value of a static field, or undefined if the static field declaration has not yet been evaluated. + * Usage: + * This helper will only ever be used by the compiler in the following ways: + * + * Writing to a private instance field (pre TS 4.3): + * __classPrivateFieldSet(, , ) + * + * Writing to a private instance field (TS 4.3+): + * __classPrivateFieldSet(, , , "f") + * + * Writing to a private instance set accessor (when defined, TS 4.3+): + * __classPrivateFieldSet(, , , "a", ) + * + * Writing to a private instance set accessor (when not defined, TS 4.3+): + * __classPrivateFieldSet(, , , "a", void 0) + * NOTE: This always results in a runtime error. + * + * Writing to a private instance method (TS 4.3+): + * __classPrivateFieldSet(, , , "m", ) + * NOTE: This always results in a runtime error. + * + * Writing to a private static field (TS 4.3+): + * __classPrivateFieldSet(, , , "f", <{ value: any }>) + * + * Writing to a private static set accessor (when defined, TS 4.3+): + * __classPrivateFieldSet(, , , "a", ) + * + * Writing to a private static set accessor (when not defined, TS 4.3+): + * __classPrivateFieldSet(, , , "a", void 0) + * NOTE: This always results in a runtime error. + * + * Writing to a private static method (TS 4.3+): + * __classPrivateFieldSet(, , , "m", ) + * NOTE: This always results in a runtime error. + */ ts.classPrivateFieldSetHelper = { name: "typescript:classPrivateFieldSet", importName: "__classPrivateFieldSet", scoped: false, - text: "\n var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, privateMap, value) {\n if (!privateMap.has(receiver)) {\n throw new TypeError(\"attempted to set private field on non-instance\");\n }\n privateMap.set(receiver, value);\n return value;\n };" + text: "\n var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\n };" }; var allUnscopedEmitHelpers; function getAllUnscopedEmitHelpers() { @@ -26397,626 +27169,688 @@ var ts; return node.kind === 17 /* TemplateTail */; } ts.isTemplateTail = isTemplateTail; + // Punctuation + function isDotDotDotToken(node) { + return node.kind === 25 /* DotDotDotToken */; + } + ts.isDotDotDotToken = isDotDotDotToken; + /*@internal*/ + function isCommaToken(node) { + return node.kind === 27 /* CommaToken */; + } + ts.isCommaToken = isCommaToken; + function isPlusToken(node) { + return node.kind === 39 /* PlusToken */; + } + ts.isPlusToken = isPlusToken; + function isMinusToken(node) { + return node.kind === 40 /* MinusToken */; + } + ts.isMinusToken = isMinusToken; + function isAsteriskToken(node) { + return node.kind === 41 /* AsteriskToken */; + } + ts.isAsteriskToken = isAsteriskToken; + /*@internal*/ + function isExclamationToken(node) { + return node.kind === 53 /* ExclamationToken */; + } + ts.isExclamationToken = isExclamationToken; + /*@internal*/ + function isQuestionToken(node) { + return node.kind === 57 /* QuestionToken */; + } + ts.isQuestionToken = isQuestionToken; + /*@internal*/ + function isColonToken(node) { + return node.kind === 58 /* ColonToken */; + } + ts.isColonToken = isColonToken; + /*@internal*/ + function isQuestionDotToken(node) { + return node.kind === 28 /* QuestionDotToken */; + } + ts.isQuestionDotToken = isQuestionDotToken; + /*@internal*/ + function isEqualsGreaterThanToken(node) { + return node.kind === 38 /* EqualsGreaterThanToken */; + } + ts.isEqualsGreaterThanToken = isEqualsGreaterThanToken; // Identifiers function isIdentifier(node) { - return node.kind === 78 /* Identifier */; + return node.kind === 79 /* Identifier */; } ts.isIdentifier = isIdentifier; - // Names - function isQualifiedName(node) { - return node.kind === 157 /* QualifiedName */; - } - ts.isQualifiedName = isQualifiedName; - function isComputedPropertyName(node) { - return node.kind === 158 /* ComputedPropertyName */; - } - ts.isComputedPropertyName = isComputedPropertyName; function isPrivateIdentifier(node) { - return node.kind === 79 /* PrivateIdentifier */; + return node.kind === 80 /* PrivateIdentifier */; } ts.isPrivateIdentifier = isPrivateIdentifier; - // Tokens + // Reserved Words + /* @internal */ + function isExportModifier(node) { + return node.kind === 93 /* ExportKeyword */; + } + ts.isExportModifier = isExportModifier; + /* @internal */ + function isAsyncModifier(node) { + return node.kind === 130 /* AsyncKeyword */; + } + ts.isAsyncModifier = isAsyncModifier; + /* @internal */ + function isAssertsKeyword(node) { + return node.kind === 128 /* AssertsKeyword */; + } + ts.isAssertsKeyword = isAssertsKeyword; + /* @internal */ + function isAwaitKeyword(node) { + return node.kind === 131 /* AwaitKeyword */; + } + ts.isAwaitKeyword = isAwaitKeyword; + /* @internal */ + function isReadonlyKeyword(node) { + return node.kind === 143 /* ReadonlyKeyword */; + } + ts.isReadonlyKeyword = isReadonlyKeyword; + /* @internal */ + function isStaticModifier(node) { + return node.kind === 124 /* StaticKeyword */; + } + ts.isStaticModifier = isStaticModifier; /*@internal*/ function isSuperKeyword(node) { - return node.kind === 105 /* SuperKeyword */; + return node.kind === 106 /* SuperKeyword */; } ts.isSuperKeyword = isSuperKeyword; /*@internal*/ function isImportKeyword(node) { - return node.kind === 99 /* ImportKeyword */; + return node.kind === 100 /* ImportKeyword */; } ts.isImportKeyword = isImportKeyword; - /*@internal*/ - function isCommaToken(node) { - return node.kind === 27 /* CommaToken */; - } - ts.isCommaToken = isCommaToken; - /*@internal*/ - function isQuestionToken(node) { - return node.kind === 57 /* QuestionToken */; + // Names + function isQualifiedName(node) { + return node.kind === 159 /* QualifiedName */; } - ts.isQuestionToken = isQuestionToken; - /*@internal*/ - function isExclamationToken(node) { - return node.kind === 53 /* ExclamationToken */; + ts.isQualifiedName = isQualifiedName; + function isComputedPropertyName(node) { + return node.kind === 160 /* ComputedPropertyName */; } - ts.isExclamationToken = isExclamationToken; + ts.isComputedPropertyName = isComputedPropertyName; // Signature elements function isTypeParameterDeclaration(node) { - return node.kind === 159 /* TypeParameter */; + return node.kind === 161 /* TypeParameter */; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; // TODO(rbuckton): Rename to 'isParameterDeclaration' function isParameter(node) { - return node.kind === 160 /* Parameter */; + return node.kind === 162 /* Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 161 /* Decorator */; + return node.kind === 163 /* Decorator */; } ts.isDecorator = isDecorator; // TypeMember function isPropertySignature(node) { - return node.kind === 162 /* PropertySignature */; + return node.kind === 164 /* PropertySignature */; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 163 /* PropertyDeclaration */; + return node.kind === 165 /* PropertyDeclaration */; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 164 /* MethodSignature */; + return node.kind === 166 /* MethodSignature */; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 165 /* MethodDeclaration */; + return node.kind === 167 /* MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isConstructorDeclaration(node) { - return node.kind === 166 /* Constructor */; + return node.kind === 168 /* Constructor */; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 167 /* GetAccessor */; + return node.kind === 169 /* GetAccessor */; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 168 /* SetAccessor */; + return node.kind === 170 /* SetAccessor */; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 169 /* CallSignature */; + return node.kind === 171 /* CallSignature */; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 170 /* ConstructSignature */; + return node.kind === 172 /* ConstructSignature */; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 171 /* IndexSignature */; + return node.kind === 173 /* IndexSignature */; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; // Type function isTypePredicateNode(node) { - return node.kind === 172 /* TypePredicate */; + return node.kind === 174 /* TypePredicate */; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 173 /* TypeReference */; + return node.kind === 175 /* TypeReference */; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 174 /* FunctionType */; + return node.kind === 176 /* FunctionType */; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 175 /* ConstructorType */; + return node.kind === 177 /* ConstructorType */; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 176 /* TypeQuery */; + return node.kind === 178 /* TypeQuery */; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 177 /* TypeLiteral */; + return node.kind === 179 /* TypeLiteral */; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 178 /* ArrayType */; + return node.kind === 180 /* ArrayType */; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 179 /* TupleType */; + return node.kind === 181 /* TupleType */; } ts.isTupleTypeNode = isTupleTypeNode; function isNamedTupleMember(node) { - return node.kind === 192 /* NamedTupleMember */; + return node.kind === 194 /* NamedTupleMember */; } ts.isNamedTupleMember = isNamedTupleMember; function isOptionalTypeNode(node) { - return node.kind === 180 /* OptionalType */; + return node.kind === 182 /* OptionalType */; } ts.isOptionalTypeNode = isOptionalTypeNode; function isRestTypeNode(node) { - return node.kind === 181 /* RestType */; + return node.kind === 183 /* RestType */; } ts.isRestTypeNode = isRestTypeNode; function isUnionTypeNode(node) { - return node.kind === 182 /* UnionType */; + return node.kind === 184 /* UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 183 /* IntersectionType */; + return node.kind === 185 /* IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 184 /* ConditionalType */; + return node.kind === 186 /* ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 185 /* InferType */; + return node.kind === 187 /* InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 186 /* ParenthesizedType */; + return node.kind === 188 /* ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 187 /* ThisType */; + return node.kind === 189 /* ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 188 /* TypeOperator */; + return node.kind === 190 /* TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 189 /* IndexedAccessType */; + return node.kind === 191 /* IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 190 /* MappedType */; + return node.kind === 192 /* MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 191 /* LiteralType */; + return node.kind === 193 /* LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 195 /* ImportType */; + return node.kind === 197 /* ImportType */; } ts.isImportTypeNode = isImportTypeNode; function isTemplateLiteralTypeSpan(node) { - return node.kind === 194 /* TemplateLiteralTypeSpan */; + return node.kind === 196 /* TemplateLiteralTypeSpan */; } ts.isTemplateLiteralTypeSpan = isTemplateLiteralTypeSpan; function isTemplateLiteralTypeNode(node) { - return node.kind === 193 /* TemplateLiteralType */; + return node.kind === 195 /* TemplateLiteralType */; } ts.isTemplateLiteralTypeNode = isTemplateLiteralTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 196 /* ObjectBindingPattern */; + return node.kind === 198 /* ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 197 /* ArrayBindingPattern */; + return node.kind === 199 /* ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 198 /* BindingElement */; + return node.kind === 200 /* BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 199 /* ArrayLiteralExpression */; + return node.kind === 201 /* ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 200 /* ObjectLiteralExpression */; + return node.kind === 202 /* ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 201 /* PropertyAccessExpression */; + return node.kind === 203 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 202 /* ElementAccessExpression */; + return node.kind === 204 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 203 /* CallExpression */; + return node.kind === 205 /* CallExpression */; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 204 /* NewExpression */; + return node.kind === 206 /* NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 205 /* TaggedTemplateExpression */; + return node.kind === 207 /* TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertionExpression(node) { - return node.kind === 206 /* TypeAssertionExpression */; + return node.kind === 208 /* TypeAssertionExpression */; } ts.isTypeAssertionExpression = isTypeAssertionExpression; function isParenthesizedExpression(node) { - return node.kind === 207 /* ParenthesizedExpression */; + return node.kind === 209 /* ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function isFunctionExpression(node) { - return node.kind === 208 /* FunctionExpression */; + return node.kind === 210 /* FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 209 /* ArrowFunction */; + return node.kind === 211 /* ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 210 /* DeleteExpression */; + return node.kind === 212 /* DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 211 /* TypeOfExpression */; + return node.kind === 213 /* TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 212 /* VoidExpression */; + return node.kind === 214 /* VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 213 /* AwaitExpression */; + return node.kind === 215 /* AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 214 /* PrefixUnaryExpression */; + return node.kind === 216 /* PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 215 /* PostfixUnaryExpression */; + return node.kind === 217 /* PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 216 /* BinaryExpression */; + return node.kind === 218 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 217 /* ConditionalExpression */; + return node.kind === 219 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 218 /* TemplateExpression */; + return node.kind === 220 /* TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 219 /* YieldExpression */; + return node.kind === 221 /* YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 220 /* SpreadElement */; + return node.kind === 222 /* SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 221 /* ClassExpression */; + return node.kind === 223 /* ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 222 /* OmittedExpression */; + return node.kind === 224 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 223 /* ExpressionWithTypeArguments */; + return node.kind === 225 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 224 /* AsExpression */; + return node.kind === 226 /* AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 225 /* NonNullExpression */; + return node.kind === 227 /* NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 226 /* MetaProperty */; + return node.kind === 228 /* MetaProperty */; } ts.isMetaProperty = isMetaProperty; function isSyntheticExpression(node) { - return node.kind === 227 /* SyntheticExpression */; + return node.kind === 229 /* SyntheticExpression */; } ts.isSyntheticExpression = isSyntheticExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 336 /* PartiallyEmittedExpression */; + return node.kind === 344 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isCommaListExpression(node) { - return node.kind === 337 /* CommaListExpression */; + return node.kind === 345 /* CommaListExpression */; } ts.isCommaListExpression = isCommaListExpression; // Misc function isTemplateSpan(node) { - return node.kind === 228 /* TemplateSpan */; + return node.kind === 230 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 229 /* SemicolonClassElement */; + return node.kind === 231 /* SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Elements function isBlock(node) { - return node.kind === 230 /* Block */; + return node.kind === 232 /* Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 232 /* VariableStatement */; + return node.kind === 234 /* VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 231 /* EmptyStatement */; + return node.kind === 233 /* EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 233 /* ExpressionStatement */; + return node.kind === 235 /* ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 234 /* IfStatement */; + return node.kind === 236 /* IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 235 /* DoStatement */; + return node.kind === 237 /* DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 236 /* WhileStatement */; + return node.kind === 238 /* WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 237 /* ForStatement */; + return node.kind === 239 /* ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 238 /* ForInStatement */; + return node.kind === 240 /* ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 239 /* ForOfStatement */; + return node.kind === 241 /* ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 240 /* ContinueStatement */; + return node.kind === 242 /* ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 241 /* BreakStatement */; + return node.kind === 243 /* BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isReturnStatement(node) { - return node.kind === 242 /* ReturnStatement */; + return node.kind === 244 /* ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 243 /* WithStatement */; + return node.kind === 245 /* WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 244 /* SwitchStatement */; + return node.kind === 246 /* SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 245 /* LabeledStatement */; + return node.kind === 247 /* LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 246 /* ThrowStatement */; + return node.kind === 248 /* ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 247 /* TryStatement */; + return node.kind === 249 /* TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 248 /* DebuggerStatement */; + return node.kind === 250 /* DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 249 /* VariableDeclaration */; + return node.kind === 251 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 250 /* VariableDeclarationList */; + return node.kind === 252 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 251 /* FunctionDeclaration */; + return node.kind === 253 /* FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 252 /* ClassDeclaration */; + return node.kind === 254 /* ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 253 /* InterfaceDeclaration */; + return node.kind === 255 /* InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 254 /* TypeAliasDeclaration */; + return node.kind === 256 /* TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 255 /* EnumDeclaration */; + return node.kind === 257 /* EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 256 /* ModuleDeclaration */; + return node.kind === 258 /* ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 257 /* ModuleBlock */; + return node.kind === 259 /* ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 258 /* CaseBlock */; + return node.kind === 260 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 259 /* NamespaceExportDeclaration */; + return node.kind === 261 /* NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 260 /* ImportEqualsDeclaration */; + return node.kind === 262 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 261 /* ImportDeclaration */; + return node.kind === 263 /* ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 262 /* ImportClause */; + return node.kind === 264 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 263 /* NamespaceImport */; + return node.kind === 265 /* NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamespaceExport(node) { - return node.kind === 269 /* NamespaceExport */; + return node.kind === 271 /* NamespaceExport */; } ts.isNamespaceExport = isNamespaceExport; function isNamedImports(node) { - return node.kind === 264 /* NamedImports */; + return node.kind === 266 /* NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 265 /* ImportSpecifier */; + return node.kind === 267 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 266 /* ExportAssignment */; + return node.kind === 268 /* ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 267 /* ExportDeclaration */; + return node.kind === 269 /* ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 268 /* NamedExports */; + return node.kind === 270 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 270 /* ExportSpecifier */; + return node.kind === 272 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 271 /* MissingDeclaration */; + return node.kind === 273 /* MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; function isNotEmittedStatement(node) { - return node.kind === 335 /* NotEmittedStatement */; + return node.kind === 343 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ function isSyntheticReference(node) { - return node.kind === 340 /* SyntheticReferenceExpression */; + return node.kind === 348 /* SyntheticReferenceExpression */; } ts.isSyntheticReference = isSyntheticReference; /* @internal */ function isMergeDeclarationMarker(node) { - return node.kind === 338 /* MergeDeclarationMarker */; + return node.kind === 346 /* MergeDeclarationMarker */; } ts.isMergeDeclarationMarker = isMergeDeclarationMarker; /* @internal */ function isEndOfDeclarationMarker(node) { - return node.kind === 339 /* EndOfDeclarationMarker */; + return node.kind === 347 /* EndOfDeclarationMarker */; } ts.isEndOfDeclarationMarker = isEndOfDeclarationMarker; // Module References function isExternalModuleReference(node) { - return node.kind === 272 /* ExternalModuleReference */; + return node.kind === 274 /* ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 273 /* JsxElement */; + return node.kind === 275 /* JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 274 /* JsxSelfClosingElement */; + return node.kind === 276 /* JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 275 /* JsxOpeningElement */; + return node.kind === 277 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 276 /* JsxClosingElement */; + return node.kind === 278 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 277 /* JsxFragment */; + return node.kind === 279 /* JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 278 /* JsxOpeningFragment */; + return node.kind === 280 /* JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 279 /* JsxClosingFragment */; + return node.kind === 281 /* JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 280 /* JsxAttribute */; + return node.kind === 282 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 281 /* JsxAttributes */; + return node.kind === 283 /* JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 282 /* JsxSpreadAttribute */; + return node.kind === 284 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 283 /* JsxExpression */; + return node.kind === 285 /* JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 284 /* CaseClause */; + return node.kind === 286 /* CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 285 /* DefaultClause */; + return node.kind === 287 /* DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 286 /* HeritageClause */; + return node.kind === 288 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 287 /* CatchClause */; + return node.kind === 289 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 288 /* PropertyAssignment */; + return node.kind === 290 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 289 /* ShorthandPropertyAssignment */; + return node.kind === 291 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 290 /* SpreadAssignment */; + return node.kind === 292 /* SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 291 /* EnumMember */; + return node.kind === 293 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Unparsed // TODO(rbuckton): isUnparsedPrologue function isUnparsedPrepend(node) { - return node.kind === 293 /* UnparsedPrepend */; + return node.kind === 295 /* UnparsedPrepend */; } ts.isUnparsedPrepend = isUnparsedPrepend; // TODO(rbuckton): isUnparsedText @@ -27024,156 +27858,176 @@ var ts; // TODO(rbuckton): isUnparsedSyntheticReference // Top-level nodes function isSourceFile(node) { - return node.kind === 297 /* SourceFile */; + return node.kind === 299 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 298 /* Bundle */; + return node.kind === 300 /* Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 299 /* UnparsedSource */; + return node.kind === 301 /* UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; // TODO(rbuckton): isInputFiles // JSDoc Elements function isJSDocTypeExpression(node) { - return node.kind === 301 /* JSDocTypeExpression */; + return node.kind === 303 /* JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocNameReference(node) { - return node.kind === 302 /* JSDocNameReference */; + return node.kind === 304 /* JSDocNameReference */; } ts.isJSDocNameReference = isJSDocNameReference; + function isJSDocMemberName(node) { + return node.kind === 305 /* JSDocMemberName */; + } + ts.isJSDocMemberName = isJSDocMemberName; + function isJSDocLink(node) { + return node.kind === 318 /* JSDocLink */; + } + ts.isJSDocLink = isJSDocLink; + function isJSDocLinkCode(node) { + return node.kind === 319 /* JSDocLinkCode */; + } + ts.isJSDocLinkCode = isJSDocLinkCode; + function isJSDocLinkPlain(node) { + return node.kind === 320 /* JSDocLinkPlain */; + } + ts.isJSDocLinkPlain = isJSDocLinkPlain; function isJSDocAllType(node) { - return node.kind === 303 /* JSDocAllType */; + return node.kind === 306 /* JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 304 /* JSDocUnknownType */; + return node.kind === 307 /* JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 305 /* JSDocNullableType */; + return node.kind === 308 /* JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 306 /* JSDocNonNullableType */; + return node.kind === 309 /* JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 307 /* JSDocOptionalType */; + return node.kind === 310 /* JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 308 /* JSDocFunctionType */; + return node.kind === 311 /* JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 309 /* JSDocVariadicType */; + return node.kind === 312 /* JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDocNamepathType(node) { - return node.kind === 310 /* JSDocNamepathType */; + return node.kind === 313 /* JSDocNamepathType */; } ts.isJSDocNamepathType = isJSDocNamepathType; function isJSDoc(node) { - return node.kind === 311 /* JSDocComment */; + return node.kind === 314 /* JSDocComment */; } ts.isJSDoc = isJSDoc; function isJSDocTypeLiteral(node) { - return node.kind === 312 /* JSDocTypeLiteral */; + return node.kind === 316 /* JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocSignature(node) { - return node.kind === 313 /* JSDocSignature */; + return node.kind === 317 /* JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; // JSDoc Tags function isJSDocAugmentsTag(node) { - return node.kind === 315 /* JSDocAugmentsTag */; + return node.kind === 322 /* JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocAuthorTag(node) { - return node.kind === 317 /* JSDocAuthorTag */; + return node.kind === 324 /* JSDocAuthorTag */; } ts.isJSDocAuthorTag = isJSDocAuthorTag; function isJSDocClassTag(node) { - return node.kind === 319 /* JSDocClassTag */; + return node.kind === 326 /* JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocCallbackTag(node) { - return node.kind === 324 /* JSDocCallbackTag */; + return node.kind === 332 /* JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocPublicTag(node) { - return node.kind === 320 /* JSDocPublicTag */; + return node.kind === 327 /* JSDocPublicTag */; } ts.isJSDocPublicTag = isJSDocPublicTag; function isJSDocPrivateTag(node) { - return node.kind === 321 /* JSDocPrivateTag */; + return node.kind === 328 /* JSDocPrivateTag */; } ts.isJSDocPrivateTag = isJSDocPrivateTag; function isJSDocProtectedTag(node) { - return node.kind === 322 /* JSDocProtectedTag */; + return node.kind === 329 /* JSDocProtectedTag */; } ts.isJSDocProtectedTag = isJSDocProtectedTag; function isJSDocReadonlyTag(node) { - return node.kind === 323 /* JSDocReadonlyTag */; + return node.kind === 330 /* JSDocReadonlyTag */; } ts.isJSDocReadonlyTag = isJSDocReadonlyTag; + function isJSDocOverrideTag(node) { + return node.kind === 331 /* JSDocOverrideTag */; + } + ts.isJSDocOverrideTag = isJSDocOverrideTag; function isJSDocDeprecatedTag(node) { - return node.kind === 318 /* JSDocDeprecatedTag */; + return node.kind === 325 /* JSDocDeprecatedTag */; } ts.isJSDocDeprecatedTag = isJSDocDeprecatedTag; function isJSDocSeeTag(node) { - return node.kind === 332 /* JSDocSeeTag */; + return node.kind === 340 /* JSDocSeeTag */; } ts.isJSDocSeeTag = isJSDocSeeTag; function isJSDocEnumTag(node) { - return node.kind === 325 /* JSDocEnumTag */; + return node.kind === 333 /* JSDocEnumTag */; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocParameterTag(node) { - return node.kind === 326 /* JSDocParameterTag */; + return node.kind === 334 /* JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 327 /* JSDocReturnTag */; + return node.kind === 335 /* JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocThisTag(node) { - return node.kind === 328 /* JSDocThisTag */; + return node.kind === 336 /* JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocTypeTag(node) { - return node.kind === 329 /* JSDocTypeTag */; + return node.kind === 337 /* JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 330 /* JSDocTemplateTag */; + return node.kind === 338 /* JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 331 /* JSDocTypedefTag */; + return node.kind === 339 /* JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocUnknownTag(node) { - return node.kind === 314 /* JSDocTag */; + return node.kind === 321 /* JSDocTag */; } ts.isJSDocUnknownTag = isJSDocUnknownTag; function isJSDocPropertyTag(node) { - return node.kind === 333 /* JSDocPropertyTag */; + return node.kind === 341 /* JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocImplementsTag(node) { - return node.kind === 316 /* JSDocImplementsTag */; + return node.kind === 323 /* JSDocImplementsTag */; } ts.isJSDocImplementsTag = isJSDocImplementsTag; // Synthesized list /* @internal */ function isSyntaxList(n) { - return n.kind === 334 /* SyntaxList */; + return n.kind === 342 /* SyntaxList */; } ts.isSyntaxList = isSyntaxList; })(ts || (ts = {})); @@ -27190,7 +28044,7 @@ var ts; return ts.setTextRange(factory.createElementAccessExpression(target, memberName.expression), location); } else { - var expression = ts.setTextRange(ts.isIdentifierOrPrivateIdentifier(memberName) + var expression = ts.setTextRange(ts.isMemberName(memberName) ? factory.createPropertyAccessExpression(target, memberName) : factory.createElementAccessExpression(target, memberName), memberName); ts.getOrCreateEmitNode(expression).flags |= 64 /* NoNestedSourceMaps */; @@ -27372,14 +28226,14 @@ var ts; ts.Debug.failBadSyntaxKind(property.name, "Private identifiers are not allowed in object literals."); } switch (property.kind) { - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return createExpressionForAccessorDeclaration(factory, node.properties, property, receiver, !!node.multiLine); - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: return createExpressionForPropertyAssignment(factory, property, receiver); - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(factory, property, receiver); - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: return createExpressionForMethodDeclaration(factory, property, receiver); } } @@ -27432,21 +28286,21 @@ var ts; } ts.startsWithUseStrict = startsWithUseStrict; function isCommaSequence(node) { - return node.kind === 216 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || - node.kind === 337 /* CommaListExpression */; + return node.kind === 218 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || + node.kind === 345 /* CommaListExpression */; } ts.isCommaSequence = isCommaSequence; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 15 /* All */; } switch (node.kind) { - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return (kinds & 1 /* Parentheses */) !== 0; - case 206 /* TypeAssertionExpression */: - case 224 /* AsExpression */: + case 208 /* TypeAssertionExpression */: + case 226 /* AsExpression */: return (kinds & 2 /* TypeAssertions */) !== 0; - case 225 /* NonNullExpression */: + case 227 /* NonNullExpression */: return (kinds & 4 /* NonNullAssertions */) !== 0; - case 336 /* PartiallyEmittedExpression */: + case 344 /* PartiallyEmittedExpression */: return (kinds & 8 /* PartiallyEmittedExpressions */) !== 0; } return false; @@ -27567,10 +28421,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : factory.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 261 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 263 /* ImportDeclaration */ && node.importClause) { return factory.getGeneratedNameForNode(node); } - if (node.kind === 267 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 269 /* ExportDeclaration */ && node.moduleSpecifier) { return factory.getGeneratedNameForNode(node); } return undefined; @@ -27689,7 +28543,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -27701,11 +28555,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 290 /* SpreadAssignment */: + case 292 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -27737,12 +28591,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 160 /* Parameter */: - case 198 /* BindingElement */: + case 162 /* Parameter */: + case 200 /* BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 220 /* SpreadElement */: - case 290 /* SpreadAssignment */: + case 222 /* SpreadElement */: + case 292 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -27760,7 +28614,7 @@ var ts; ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement; function tryGetPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 198 /* BindingElement */: + case 200 /* BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -27775,7 +28629,7 @@ var ts; : propertyName; } break; - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -27790,7 +28644,7 @@ var ts; : propertyName; } break; - case 290 /* SpreadAssignment */: + case 292 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` if (bindingElement.name && ts.isPrivateIdentifier(bindingElement.name)) { return ts.Debug.failBadSyntaxKind(bindingElement.name); @@ -27813,13 +28667,13 @@ var ts; */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 196 /* ObjectBindingPattern */: - case 197 /* ArrayBindingPattern */: - case 199 /* ArrayLiteralExpression */: + case 198 /* ObjectBindingPattern */: + case 199 /* ArrayBindingPattern */: + case 201 /* ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -27840,46 +28694,294 @@ var ts; ts.getJSDocTypeAliasName = getJSDocTypeAliasName; function canHaveModifiers(node) { var kind = node.kind; - return kind === 160 /* Parameter */ - || kind === 162 /* PropertySignature */ - || kind === 163 /* PropertyDeclaration */ - || kind === 164 /* MethodSignature */ - || kind === 165 /* MethodDeclaration */ - || kind === 166 /* Constructor */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */ - || kind === 171 /* IndexSignature */ - || kind === 208 /* FunctionExpression */ - || kind === 209 /* ArrowFunction */ - || kind === 221 /* ClassExpression */ - || kind === 232 /* VariableStatement */ - || kind === 251 /* FunctionDeclaration */ - || kind === 252 /* ClassDeclaration */ - || kind === 253 /* InterfaceDeclaration */ - || kind === 254 /* TypeAliasDeclaration */ - || kind === 255 /* EnumDeclaration */ - || kind === 256 /* ModuleDeclaration */ - || kind === 260 /* ImportEqualsDeclaration */ - || kind === 261 /* ImportDeclaration */ - || kind === 266 /* ExportAssignment */ - || kind === 267 /* ExportDeclaration */; + return kind === 162 /* Parameter */ + || kind === 164 /* PropertySignature */ + || kind === 165 /* PropertyDeclaration */ + || kind === 166 /* MethodSignature */ + || kind === 167 /* MethodDeclaration */ + || kind === 168 /* Constructor */ + || kind === 169 /* GetAccessor */ + || kind === 170 /* SetAccessor */ + || kind === 173 /* IndexSignature */ + || kind === 210 /* FunctionExpression */ + || kind === 211 /* ArrowFunction */ + || kind === 223 /* ClassExpression */ + || kind === 234 /* VariableStatement */ + || kind === 253 /* FunctionDeclaration */ + || kind === 254 /* ClassDeclaration */ + || kind === 255 /* InterfaceDeclaration */ + || kind === 256 /* TypeAliasDeclaration */ + || kind === 257 /* EnumDeclaration */ + || kind === 258 /* ModuleDeclaration */ + || kind === 262 /* ImportEqualsDeclaration */ + || kind === 263 /* ImportDeclaration */ + || kind === 268 /* ExportAssignment */ + || kind === 269 /* ExportDeclaration */; } ts.canHaveModifiers = canHaveModifiers; - /* @internal */ - function isExportModifier(node) { - return node.kind === 92 /* ExportKeyword */; - } - ts.isExportModifier = isExportModifier; - /* @internal */ - function isAsyncModifier(node) { - return node.kind === 129 /* AsyncKeyword */; - } - ts.isAsyncModifier = isAsyncModifier; - /* @internal */ - function isStaticModifier(node) { - return node.kind === 123 /* StaticKeyword */; + ts.isTypeNodeOrTypeParameterDeclaration = ts.or(ts.isTypeNode, ts.isTypeParameterDeclaration); + ts.isQuestionOrExclamationToken = ts.or(ts.isQuestionToken, ts.isExclamationToken); + ts.isIdentifierOrThisTypeNode = ts.or(ts.isIdentifier, ts.isThisTypeNode); + ts.isReadonlyKeywordOrPlusOrMinusToken = ts.or(ts.isReadonlyKeyword, ts.isPlusToken, ts.isMinusToken); + ts.isQuestionOrPlusOrMinusToken = ts.or(ts.isQuestionToken, ts.isPlusToken, ts.isMinusToken); + 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 */ + || ts.isLiteralExpression(node) + || ts.isPrefixUnaryExpression(node); + } + ts.isLiteralTypeLikeExpression = isLiteralTypeLikeExpression; + function isExponentiationOperator(kind) { + return kind === 42 /* AsteriskAsteriskToken */; + } + function isMultiplicativeOperator(kind) { + return kind === 41 /* AsteriskToken */ + || kind === 43 /* SlashToken */ + || kind === 44 /* PercentToken */; + } + function isMultiplicativeOperatorOrHigher(kind) { + return isExponentiationOperator(kind) + || isMultiplicativeOperator(kind); + } + function isAdditiveOperator(kind) { + return kind === 39 /* PlusToken */ + || kind === 40 /* MinusToken */; + } + function isAdditiveOperatorOrHigher(kind) { + return isAdditiveOperator(kind) + || isMultiplicativeOperatorOrHigher(kind); + } + function isShiftOperator(kind) { + return kind === 47 /* LessThanLessThanToken */ + || kind === 48 /* GreaterThanGreaterThanToken */ + || kind === 49 /* 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 */; + } + function isRelationalOperatorOrHigher(kind) { + return isRelationalOperator(kind) + || isShiftOperatorOrHigher(kind); + } + function isEqualityOperator(kind) { + return kind === 34 /* EqualsEqualsToken */ + || kind === 36 /* EqualsEqualsEqualsToken */ + || kind === 35 /* ExclamationEqualsToken */ + || kind === 37 /* ExclamationEqualsEqualsToken */; + } + function isEqualityOperatorOrHigher(kind) { + return isEqualityOperator(kind) + || isRelationalOperatorOrHigher(kind); + } + function isBitwiseOperator(kind) { + return kind === 50 /* AmpersandToken */ + || kind === 51 /* BarToken */ + || kind === 52 /* CaretToken */; + } + function isBitwiseOperatorOrHigher(kind) { + return isBitwiseOperator(kind) + || isEqualityOperatorOrHigher(kind); + } + // NOTE: The version in utilities includes ExclamationToken, which is not a binary operator. + function isLogicalOperator(kind) { + return kind === 55 /* AmpersandAmpersandToken */ + || kind === 56 /* BarBarToken */; + } + function isLogicalOperatorOrHigher(kind) { + return isLogicalOperator(kind) + || isBitwiseOperatorOrHigher(kind); + } + function isAssignmentOperatorOrHigher(kind) { + return kind === 60 /* QuestionQuestionToken */ + || isLogicalOperatorOrHigher(kind) + || ts.isAssignmentOperator(kind); + } + function isBinaryOperator(kind) { + return isAssignmentOperatorOrHigher(kind) + || kind === 27 /* CommaToken */; + } + function isBinaryOperatorToken(node) { + return isBinaryOperator(node.kind); + } + ts.isBinaryOperatorToken = isBinaryOperatorToken; + var BinaryExpressionState; + (function (BinaryExpressionState) { + /** + * Handles walking into a `BinaryExpression`. + * @param machine State machine handler functions + * @param frame The current frame + * @returns The new frame + */ + function enter(machine, stackIndex, stateStack, nodeStack, userStateStack, _resultHolder, outerState) { + var prevUserState = stackIndex > 0 ? userStateStack[stackIndex - 1] : undefined; + ts.Debug.assertEqual(stateStack[stackIndex], enter); + userStateStack[stackIndex] = machine.onEnter(nodeStack[stackIndex], prevUserState, outerState); + stateStack[stackIndex] = nextState(machine, enter); + return stackIndex; + } + BinaryExpressionState.enter = enter; + /** + * Handles walking the `left` side of a `BinaryExpression`. + * @param machine State machine handler functions + * @param frame The current frame + * @returns The new frame + */ + function left(machine, stackIndex, stateStack, nodeStack, userStateStack, _resultHolder, _outerState) { + ts.Debug.assertEqual(stateStack[stackIndex], left); + ts.Debug.assertIsDefined(machine.onLeft); + stateStack[stackIndex] = nextState(machine, left); + var nextNode = machine.onLeft(nodeStack[stackIndex].left, userStateStack[stackIndex], nodeStack[stackIndex]); + if (nextNode) { + checkCircularity(stackIndex, nodeStack, nextNode); + return pushStack(stackIndex, stateStack, nodeStack, userStateStack, nextNode); + } + return stackIndex; + } + BinaryExpressionState.left = left; + /** + * Handles walking the `operatorToken` of a `BinaryExpression`. + * @param machine State machine handler functions + * @param frame The current frame + * @returns The new frame + */ + function operator(machine, stackIndex, stateStack, nodeStack, userStateStack, _resultHolder, _outerState) { + ts.Debug.assertEqual(stateStack[stackIndex], operator); + ts.Debug.assertIsDefined(machine.onOperator); + stateStack[stackIndex] = nextState(machine, operator); + machine.onOperator(nodeStack[stackIndex].operatorToken, userStateStack[stackIndex], nodeStack[stackIndex]); + return stackIndex; + } + BinaryExpressionState.operator = operator; + /** + * Handles walking the `right` side of a `BinaryExpression`. + * @param machine State machine handler functions + * @param frame The current frame + * @returns The new frame + */ + function right(machine, stackIndex, stateStack, nodeStack, userStateStack, _resultHolder, _outerState) { + ts.Debug.assertEqual(stateStack[stackIndex], right); + ts.Debug.assertIsDefined(machine.onRight); + stateStack[stackIndex] = nextState(machine, right); + var nextNode = machine.onRight(nodeStack[stackIndex].right, userStateStack[stackIndex], nodeStack[stackIndex]); + if (nextNode) { + checkCircularity(stackIndex, nodeStack, nextNode); + return pushStack(stackIndex, stateStack, nodeStack, userStateStack, nextNode); + } + return stackIndex; + } + BinaryExpressionState.right = right; + /** + * Handles walking out of a `BinaryExpression`. + * @param machine State machine handler functions + * @param frame The current frame + * @returns The new frame + */ + function exit(machine, stackIndex, stateStack, nodeStack, userStateStack, resultHolder, _outerState) { + ts.Debug.assertEqual(stateStack[stackIndex], exit); + stateStack[stackIndex] = nextState(machine, exit); + var result = machine.onExit(nodeStack[stackIndex], userStateStack[stackIndex]); + if (stackIndex > 0) { + stackIndex--; + if (machine.foldState) { + var side = stateStack[stackIndex] === exit ? "right" : "left"; + userStateStack[stackIndex] = machine.foldState(userStateStack[stackIndex], result, side); + } + } + else { + resultHolder.value = result; + } + return stackIndex; + } + BinaryExpressionState.exit = exit; + /** + * Handles a frame that is already done. + * @returns The `done` state. + */ + function done(_machine, stackIndex, stateStack, _nodeStack, _userStateStack, _resultHolder, _outerState) { + ts.Debug.assertEqual(stateStack[stackIndex], done); + return stackIndex; + } + BinaryExpressionState.done = done; + function nextState(machine, currentState) { + switch (currentState) { + case enter: + if (machine.onLeft) + return left; + // falls through + case left: + if (machine.onOperator) + return operator; + // falls through + case operator: + if (machine.onRight) + return right; + // falls through + case right: return exit; + case exit: return done; + case done: return done; + default: ts.Debug.fail("Invalid state"); + } + } + BinaryExpressionState.nextState = nextState; + function pushStack(stackIndex, stateStack, nodeStack, userStateStack, node) { + stackIndex++; + stateStack[stackIndex] = enter; + nodeStack[stackIndex] = node; + userStateStack[stackIndex] = undefined; + return stackIndex; + } + function checkCircularity(stackIndex, nodeStack, node) { + if (ts.Debug.shouldAssert(2 /* Aggressive */)) { + while (stackIndex >= 0) { + ts.Debug.assert(nodeStack[stackIndex] !== node, "Circular traversal detected."); + stackIndex--; + } + } + } + })(BinaryExpressionState || (BinaryExpressionState = {})); + /** + * Holds state machine handler functions + */ + var BinaryExpressionStateMachine = /** @class */ (function () { + function BinaryExpressionStateMachine(onEnter, onLeft, onOperator, onRight, onExit, foldState) { + this.onEnter = onEnter; + this.onLeft = onLeft; + this.onOperator = onOperator; + this.onRight = onRight; + this.onExit = onExit; + this.foldState = foldState; + } + return BinaryExpressionStateMachine; + }()); + function createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, foldState) { + var machine = new BinaryExpressionStateMachine(onEnter, onLeft, onOperator, onRight, onExit, foldState); + return trampoline; + function trampoline(node, outerState) { + var resultHolder = { value: undefined }; + var stateStack = [BinaryExpressionState.enter]; + var nodeStack = [node]; + var userStateStack = [undefined]; + var stackIndex = 0; + while (stateStack[stackIndex] !== BinaryExpressionState.done) { + stackIndex = stateStack[stackIndex](machine, stackIndex, stateStack, nodeStack, userStateStack, resultHolder, outerState); + } + ts.Debug.assertEqual(stackIndex, 0); + return resultHolder.value; + } } - ts.isStaticModifier = isStaticModifier; + ts.createBinaryExpressionTrampoline = createBinaryExpressionTrampoline; })(ts || (ts = {})); var ts; (function (ts) { @@ -27961,19 +29063,19 @@ 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 <= 156 /* LastToken */) { + if (!node || node.kind <= 158 /* LastToken */) { return; } switch (node.kind) { - case 157 /* QualifiedName */: + case 159 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 159 /* TypeParameter */: + case 161 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -27981,9 +29083,9 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 290 /* SpreadAssignment */: + case 292 /* SpreadAssignment */: return visitNode(cbNode, node.expression); - case 160 /* Parameter */: + case 162 /* Parameter */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -27991,7 +29093,7 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -27999,51 +29101,51 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 162 /* PropertySignature */: + case 164 /* PropertySignature */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.initializer); - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 198 /* BindingElement */: + case 200 /* BindingElement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 173 /* 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 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: - case 209 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 210 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 211 /* ArrowFunction */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -28055,374 +29157,395 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 173 /* TypeReference */: + case 175 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 172 /* TypePredicate */: + case 174 /* TypePredicate */: return visitNode(cbNode, node.assertsModifier) || visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 176 /* TypeQuery */: + case 178 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 177 /* TypeLiteral */: + case 179 /* TypeLiteral */: return visitNodes(cbNode, cbNodes, node.members); - case 178 /* ArrayType */: + case 180 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 179 /* TupleType */: + case 181 /* TupleType */: return visitNodes(cbNode, cbNodes, node.elements); - case 182 /* UnionType */: - case 183 /* IntersectionType */: + case 184 /* UnionType */: + case 185 /* IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 184 /* ConditionalType */: + case 186 /* ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 185 /* InferType */: + case 187 /* InferType */: return visitNode(cbNode, node.typeParameter); - case 195 /* ImportType */: + case 197 /* ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 186 /* ParenthesizedType */: - case 188 /* TypeOperator */: + case 188 /* ParenthesizedType */: + case 190 /* TypeOperator */: return visitNode(cbNode, node.type); - case 189 /* IndexedAccessType */: + case 191 /* IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 190 /* MappedType */: + case 192 /* MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.nameType) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 191 /* LiteralType */: + case 193 /* LiteralType */: return visitNode(cbNode, node.literal); - case 192 /* NamedTupleMember */: + case 194 /* NamedTupleMember */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 196 /* ObjectBindingPattern */: - case 197 /* ArrayBindingPattern */: + case 198 /* ObjectBindingPattern */: + case 199 /* ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.name); - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.argumentExpression); - case 203 /* CallExpression */: - case 204 /* NewExpression */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 206 /* TypeAssertionExpression */: + case 208 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 210 /* DeleteExpression */: + case 212 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 211 /* TypeOfExpression */: + case 213 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 212 /* VoidExpression */: + case 214 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 213 /* AwaitExpression */: + case 215 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 224 /* AsExpression */: + case 226 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 225 /* NonNullExpression */: + case 227 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 226 /* MetaProperty */: + case 228 /* MetaProperty */: return visitNode(cbNode, node.name); - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 220 /* SpreadElement */: + case 222 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 230 /* Block */: - case 257 /* ModuleBlock */: + case 232 /* Block */: + case 259 /* ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 297 /* SourceFile */: + case 299 /* SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 250 /* VariableDeclarationList */: + case 252 /* VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 234 /* IfStatement */: + case 236 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 235 /* DoStatement */: + case 237 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 236 /* WhileStatement */: + case 238 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 240 /* ContinueStatement */: - case 241 /* BreakStatement */: + case 242 /* ContinueStatement */: + case 243 /* BreakStatement */: return visitNode(cbNode, node.label); - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 243 /* WithStatement */: + case 245 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 258 /* CaseBlock */: + case 260 /* CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 284 /* CaseClause */: + case 286 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 285 /* DefaultClause */: + case 287 /* DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 246 /* ThrowStatement */: + case 248 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 247 /* TryStatement */: + case 249 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 161 /* Decorator */: + case 163 /* Decorator */: return visitNode(cbNode, node.expression); - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: 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 253 /* InterfaceDeclaration */: + case 255 /* 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 254 /* TypeAliasDeclaration */: + case 256 /* 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 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 291 /* EnumMember */: + case 293 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 262 /* ImportClause */: + case 264 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 259 /* NamespaceExportDeclaration */: + case 261 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 269 /* NamespaceExport */: + case 271 /* NamespaceExport */: return visitNode(cbNode, node.name); - case 264 /* NamedImports */: - case 268 /* NamedExports */: + case 266 /* NamedImports */: + case 270 /* NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 265 /* ImportSpecifier */: - case 270 /* ExportSpecifier */: + case 267 /* ImportSpecifier */: + case 272 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 218 /* TemplateExpression */: + case 220 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 228 /* TemplateSpan */: + case 230 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 193 /* TemplateLiteralType */: + case 195 /* TemplateLiteralType */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 194 /* TemplateLiteralTypeSpan */: + case 196 /* TemplateLiteralTypeSpan */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.literal); - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 286 /* HeritageClause */: + case 288 /* HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 272 /* ExternalModuleReference */: + case 274 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 271 /* MissingDeclaration */: + case 273 /* MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 337 /* CommaListExpression */: + case 345 /* CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 273 /* JsxElement */: + case 275 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 277 /* JsxFragment */: + case 279 /* JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 274 /* JsxSelfClosingElement */: - case 275 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 281 /* JsxAttributes */: + case 283 /* JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 280 /* JsxAttribute */: + case 282 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 282 /* JsxSpreadAttribute */: + case 284 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 276 /* JsxClosingElement */: + case 278 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 180 /* OptionalType */: - case 181 /* RestType */: - case 301 /* JSDocTypeExpression */: - case 306 /* JSDocNonNullableType */: - case 305 /* JSDocNullableType */: - case 307 /* JSDocOptionalType */: - case 309 /* JSDocVariadicType */: + case 182 /* OptionalType */: + case 183 /* RestType */: + case 303 /* JSDocTypeExpression */: + case 309 /* JSDocNonNullableType */: + case 308 /* JSDocNullableType */: + case 310 /* JSDocOptionalType */: + case 312 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 308 /* JSDocFunctionType */: + case 311 /* JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 311 /* JSDocComment */: - return visitNodes(cbNode, cbNodes, node.tags); - case 332 /* JSDocSeeTag */: + case 314 /* JSDocComment */: + return (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) + || visitNodes(cbNode, cbNodes, node.tags); + case 340 /* JSDocSeeTag */: return visitNode(cbNode, node.tagName) || - visitNode(cbNode, node.name); - case 302 /* JSDocNameReference */: + visitNode(cbNode, node.name) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 304 /* JSDocNameReference */: return visitNode(cbNode, node.name); - case 326 /* JSDocParameterTag */: - case 333 /* JSDocPropertyTag */: + case 305 /* JSDocMemberName */: + return visitNode(cbNode, node.left) || + visitNode(cbNode, node.right); + case 334 /* JSDocParameterTag */: + case 341 /* JSDocPropertyTag */: return visitNode(cbNode, node.tagName) || (node.isNameFirst ? visitNode(cbNode, node.name) || - visitNode(cbNode, node.typeExpression) + visitNode(cbNode, node.typeExpression) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) : visitNode(cbNode, node.typeExpression) || - visitNode(cbNode, node.name)); - case 317 /* JSDocAuthorTag */: - return visitNode(cbNode, node.tagName); - case 316 /* JSDocImplementsTag */: + visitNode(cbNode, node.name)) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 324 /* JSDocAuthorTag */: + return visitNode(cbNode, node.tagName) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 323 /* JSDocImplementsTag */: return visitNode(cbNode, node.tagName) || - visitNode(cbNode, node.class); - case 315 /* JSDocAugmentsTag */: + visitNode(cbNode, node.class) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 322 /* JSDocAugmentsTag */: return visitNode(cbNode, node.tagName) || - visitNode(cbNode, node.class); - case 330 /* JSDocTemplateTag */: + visitNode(cbNode, node.class) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 338 /* JSDocTemplateTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.constraint) || - visitNodes(cbNode, cbNodes, node.typeParameters); - case 331 /* JSDocTypedefTag */: + visitNodes(cbNode, cbNodes, node.typeParameters) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 339 /* JSDocTypedefTag */: return visitNode(cbNode, node.tagName) || (node.typeExpression && - node.typeExpression.kind === 301 /* JSDocTypeExpression */ + node.typeExpression.kind === 303 /* JSDocTypeExpression */ ? visitNode(cbNode, node.typeExpression) || - visitNode(cbNode, node.fullName) + visitNode(cbNode, node.fullName) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) : visitNode(cbNode, node.fullName) || - visitNode(cbNode, node.typeExpression)); - case 324 /* JSDocCallbackTag */: + visitNode(cbNode, node.typeExpression)) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 332 /* JSDocCallbackTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.fullName) || - visitNode(cbNode, node.typeExpression); - case 327 /* JSDocReturnTag */: - case 329 /* JSDocTypeTag */: - case 328 /* JSDocThisTag */: - case 325 /* JSDocEnumTag */: + visitNode(cbNode, node.typeExpression) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 335 /* JSDocReturnTag */: + case 337 /* JSDocTypeTag */: + case 336 /* JSDocThisTag */: + case 333 /* JSDocEnumTag */: return visitNode(cbNode, node.tagName) || - visitNode(cbNode, node.typeExpression); - case 313 /* JSDocSignature */: + visitNode(cbNode, node.typeExpression) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 317 /* JSDocSignature */: return ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 312 /* JSDocTypeLiteral */: + case 318 /* JSDocLink */: + case 319 /* JSDocLinkCode */: + case 320 /* JSDocLinkPlain */: + return visitNode(cbNode, node.name); + case 316 /* JSDocTypeLiteral */: return ts.forEach(node.jsDocPropertyTags, cbNode); - case 314 /* JSDocTag */: - case 319 /* JSDocClassTag */: - case 320 /* JSDocPublicTag */: - case 321 /* JSDocPrivateTag */: - case 322 /* JSDocProtectedTag */: - case 323 /* JSDocReadonlyTag */: - return visitNode(cbNode, node.tagName); - case 336 /* PartiallyEmittedExpression */: + case 321 /* JSDocTag */: + case 326 /* JSDocClassTag */: + case 327 /* JSDocPublicTag */: + case 328 /* JSDocPrivateTag */: + case 329 /* JSDocProtectedTag */: + case 330 /* JSDocReadonlyTag */: + case 325 /* JSDocDeprecatedTag */: + return visitNode(cbNode, node.tagName) + || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 344 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -28442,62 +29565,58 @@ var ts; * and while doing so, handles traversing the structure without relying on the callstack to encode the tree structure. */ function forEachChildRecursively(rootNode, cbNode, cbNodes) { - var stack = [rootNode]; - while (stack.length) { - var parent = stack.pop(); - var res = visitAllPossibleChildren(parent, gatherPossibleChildren(parent)); - if (res) { - return res; - } - } - return; - function gatherPossibleChildren(node) { - var children = []; - forEachChild(node, addWorkItem, addWorkItem); // By using a stack above and `unshift` here, we emulate a depth-first preorder traversal - return children; - function addWorkItem(n) { - children.unshift(n); - } - } - function visitAllPossibleChildren(parent, children) { - for (var _i = 0, children_5 = children; _i < children_5.length; _i++) { - var child = children_5[_i]; - if (ts.isArray(child)) { - if (cbNodes) { - var res = cbNodes(child, parent); - if (res) { - if (res === "skip") - continue; - return res; - } - } - for (var i = child.length - 1; i >= 0; i--) { - var realChild = child[i]; - var res = cbNode(realChild, parent); - if (res) { - if (res === "skip") - continue; - return res; - } - stack.push(realChild); - } - } - else { - stack.push(child); - var res = cbNode(child, parent); + var queue = gatherPossibleChildren(rootNode); + var parents = []; // tracks parent references for elements in queue + while (parents.length < queue.length) { + parents.push(rootNode); + } + while (queue.length !== 0) { + var current = queue.pop(); + var parent = parents.pop(); + if (ts.isArray(current)) { + if (cbNodes) { + var res = cbNodes(current, parent); if (res) { if (res === "skip") continue; return res; } } + for (var i = current.length - 1; i >= 0; --i) { + queue.push(current[i]); + parents.push(parent); + } + } + else { + var res = cbNode(current, parent); + if (res) { + if (res === "skip") + continue; + return res; + } + if (current.kind >= 159 /* 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]; + queue.push(child); + parents.push(current); + } + } } } } ts.forEachChildRecursively = forEachChildRecursively; + function gatherPossibleChildren(node) { + var children = []; + forEachChild(node, addWorkItem, addWorkItem); // By using a stack above and `unshift` here, we emulate a depth-first preorder traversal + return children; + function addWorkItem(n) { + children.unshift(n); + } + } function createSourceFile(fileName, sourceText, languageVersion, setParentNodes, scriptKind) { if (setParentNodes === void 0) { setParentNodes = false; } - ts.tracing.push("parse" /* Parse */, "createSourceFile", { path: fileName }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* Parse */, "createSourceFile", { path: fileName }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeParse"); var result; ts.perfLogger.logStartParseSourceFile(fileName); @@ -28510,7 +29629,7 @@ var ts; ts.perfLogger.logStopParseSourceFile(); ts.performance.mark("afterParse"); ts.performance.measure("Parse", "beforeParse", "afterParse"); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; } ts.createSourceFile = createSourceFile; @@ -28692,11 +29811,12 @@ var ts; // attached to the EOF token. var parseErrorBeforeNextFinishedNode = false; function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes, scriptKind) { + var _a; if (setParentNodes === void 0) { setParentNodes = false; } scriptKind = ts.ensureScriptKind(fileName, scriptKind); if (scriptKind === 6 /* JSON */) { var result_3 = parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes); - ts.convertToObjectWorker(result_3, result_3.parseDiagnostics, /*returnValue*/ false, /*knownRootOptions*/ undefined, /*jsonConversionNotifier*/ undefined); + 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; result_3.typeReferenceDirectives = ts.emptyArray; result_3.libReferenceDirectives = ts.emptyArray; @@ -28736,35 +29856,54 @@ var ts; endOfFileToken = parseTokenNode(); } else { - var expression = void 0; - switch (token()) { - case 22 /* OpenBracketToken */: - expression = parseArrayLiteralExpression(); - break; - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: - case 103 /* NullKeyword */: - expression = parseTokenNode(); - break; - case 40 /* MinusToken */: - if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 58 /* ColonToken */; })) { - expression = parsePrefixUnaryExpression(); - } - else { - expression = parseObjectLiteralExpression(); - } - break; - case 8 /* NumericLiteral */: - case 10 /* StringLiteral */: - if (lookAhead(function () { return nextToken() !== 58 /* ColonToken */; })) { - expression = parseLiteralNode(); + // 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 */) { + var expression_1 = void 0; + switch (token()) { + case 22 /* OpenBracketToken */: + expression_1 = parseArrayLiteralExpression(); + break; + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: + case 104 /* NullKeyword */: + expression_1 = parseTokenNode(); break; + case 40 /* MinusToken */: + if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 58 /* ColonToken */; })) { + expression_1 = parsePrefixUnaryExpression(); + } + else { + expression_1 = parseObjectLiteralExpression(); + } + break; + case 8 /* NumericLiteral */: + case 10 /* StringLiteral */: + if (lookAhead(function () { return nextToken() !== 58 /* ColonToken */; })) { + expression_1 = parseLiteralNode(); + break; + } + // falls through + default: + expression_1 = parseObjectLiteralExpression(); + break; + } + // Error recovery: collect multiple top-level expressions + if (expressions && ts.isArray(expressions)) { + expressions.push(expression_1); + } + else if (expressions) { + expressions = [expressions, expression_1]; + } + else { + expressions = expression_1; + if (token() !== 1 /* EndOfFileToken */) { + parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token); } - // falls through - default: - expression = parseObjectLiteralExpression(); - break; + } } + var expression = ts.isArray(expressions) ? finishNode(factory.createArrayLiteralExpression(expressions), pos) : ts.Debug.checkDefined(expressions); var statement = factory.createExpressionStatement(expression); finishNode(statement, pos); statements = createNodeArray([statement], pos); @@ -28959,7 +30098,7 @@ var ts; return factory.updateSourceFile(sourceFile, ts.setTextRange(factory.createNodeArray(statements), sourceFile.statements)); function containsPossibleTopLevelAwait(node) { return !(node.flags & 32768 /* AwaitContext */) - && !!(node.transformFlags & 8388608 /* ContainsPossibleTopLevelAwait */); + && !!(node.transformFlags & 16777216 /* ContainsPossibleTopLevelAwait */); } function findNextStatementWithAwait(statements, start) { for (var i = start; i < statements.length; i++) { @@ -29000,7 +30139,7 @@ var ts; ts.setTextRangePosWidth(sourceFile, 0, sourceText.length); setExternalModuleIndicator(sourceFile); // If we parsed this as an external module, it may contain top-level await - if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 8388608 /* ContainsPossibleTopLevelAwait */) { + if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 16777216 /* ContainsPossibleTopLevelAwait */) { sourceFile = reparseTopLevelAwait(sourceFile); } sourceFile.text = sourceText; @@ -29180,6 +30319,9 @@ var ts; function reScanLessThanToken() { return currentToken = scanner.reScanLessThanToken(); } + function reScanHashToken() { + return currentToken = scanner.reScanHashToken(); + } function scanJsxIdentifier() { return currentToken = scanner.scanJsxIdentifier(); } @@ -29234,27 +30376,27 @@ var ts; return speculationHelper(callback, 0 /* TryParse */); } function isBindingIdentifier() { - if (token() === 78 /* Identifier */) { + if (token() === 79 /* Identifier */) { return true; } - return token() > 115 /* LastReservedWord */; + return token() > 116 /* LastReservedWord */; } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token() === 78 /* Identifier */) { + if (token() === 79 /* 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() === 124 /* YieldKeyword */ && inYieldContext()) { + if (token() === 125 /* 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() === 130 /* AwaitKeyword */ && inAwaitContext()) { + if (token() === 131 /* AwaitKeyword */ && inAwaitContext()) { return false; } - return token() > 115 /* LastReservedWord */; + return token() > 116 /* LastReservedWord */; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -29367,11 +30509,11 @@ var ts; parseErrorAtCurrentToken(diagnosticMessage, arg0); } var pos = getNodePos(); - var result = kind === 78 /* Identifier */ ? factory.createIdentifier("", /*typeArguments*/ undefined, /*originalKeywordKind*/ undefined) : + var result = kind === 79 /* 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 === 271 /* MissingDeclaration */ ? factory.createMissingDeclaration() : + kind === 273 /* MissingDeclaration */ ? factory.createMissingDeclaration() : factory.createToken(kind); return finishNode(result, pos); } @@ -29386,8 +30528,8 @@ var ts; // with magic property names like '__proto__'. The 'identifiers' object is used to share a single string instance for // each identifier in order to reduce memory consumption. function createIdentifier(isIdentifier, diagnosticMessage, privateIdentifierDiagnosticMessage) { - identifierCount++; if (isIdentifier) { + identifierCount++; var pos = getNodePos(); // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker var originalKeywordKind = token(); @@ -29395,10 +30537,15 @@ var ts; nextTokenWithoutCheck(); return finishNode(factory.createIdentifier(text, /*typeArguments*/ undefined, originalKeywordKind), pos); } - if (token() === 79 /* PrivateIdentifier */) { + if (token() === 80 /* 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 */; })) { + // 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 isReservedWord = scanner.isReservedWord(); @@ -29406,7 +30553,7 @@ var ts; var defaultMessage = isReservedWord ? ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here : ts.Diagnostics.Identifier_expected; - return createMissingNode(78 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg); + return createMissingNode(79 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg); } function parseBindingIdentifier(privateIdentifierDiagnosticMessage) { return createIdentifier(isBindingIdentifier(), /*diagnosticMessage*/ undefined, privateIdentifierDiagnosticMessage); @@ -29431,7 +30578,7 @@ var ts; if (allowComputedPropertyNames && token() === 22 /* OpenBracketToken */) { return parseComputedPropertyName(); } - if (token() === 79 /* PrivateIdentifier */) { + if (token() === 80 /* PrivateIdentifier */) { return parsePrivateIdentifier(); } return parseIdentifierName(); @@ -29477,24 +30624,24 @@ var ts; } function nextTokenCanFollowModifier() { switch (token()) { - case 84 /* ConstKeyword */: + case 85 /* ConstKeyword */: // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 91 /* EnumKeyword */; - case 92 /* ExportKeyword */: + return nextToken() === 92 /* EnumKeyword */; + case 93 /* ExportKeyword */: nextToken(); - if (token() === 87 /* DefaultKeyword */) { + if (token() === 88 /* DefaultKeyword */) { return lookAhead(nextTokenCanFollowDefaultKeyword); } - if (token() === 149 /* TypeKeyword */) { + if (token() === 150 /* TypeKeyword */) { return lookAhead(nextTokenCanFollowExportModifier); } return canFollowExportModifier(); - case 87 /* DefaultKeyword */: + case 88 /* DefaultKeyword */: return nextTokenCanFollowDefaultKeyword(); - case 123 /* StaticKeyword */: + case 124 /* StaticKeyword */: return nextTokenIsOnSameLineAndCanFollowModifier(); - case 134 /* GetKeyword */: - case 146 /* SetKeyword */: + case 135 /* GetKeyword */: + case 147 /* SetKeyword */: nextToken(); return canFollowModifier(); default: @@ -29503,7 +30650,7 @@ var ts; } function canFollowExportModifier() { return token() !== 41 /* AsteriskToken */ - && token() !== 126 /* AsKeyword */ + && token() !== 127 /* AsKeyword */ && token() !== 18 /* OpenBraceToken */ && canFollowModifier(); } @@ -29523,10 +30670,10 @@ var ts; } function nextTokenCanFollowDefaultKeyword() { nextToken(); - return token() === 83 /* ClassKeyword */ || token() === 97 /* FunctionKeyword */ || - token() === 117 /* InterfaceKeyword */ || - (token() === 125 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || - (token() === 129 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 84 /* ClassKeyword */ || token() === 98 /* FunctionKeyword */ || + token() === 118 /* InterfaceKeyword */ || + (token() === 126 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || + (token() === 130 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -29546,7 +30693,7 @@ var ts; // outer module. We just want to consume and move on. return !(token() === 26 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); case 2 /* SwitchClauses */: - return token() === 81 /* CaseKeyword */ || token() === 87 /* DefaultKeyword */; + return token() === 82 /* CaseKeyword */ || token() === 88 /* DefaultKeyword */; case 4 /* TypeMembers */: return lookAhead(isTypeMemberStart); case 5 /* ClassMembers */: @@ -29632,7 +30779,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 93 /* ExtendsKeyword */ || next === 116 /* ImplementsKeyword */; + return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 94 /* ExtendsKeyword */ || next === 117 /* ImplementsKeyword */; } return true; } @@ -29649,8 +30796,8 @@ var ts; return ts.tokenIsIdentifierOrKeywordOrGreaterThan(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 116 /* ImplementsKeyword */ || - token() === 93 /* ExtendsKeyword */) { + if (token() === 117 /* ImplementsKeyword */ || + token() === 94 /* ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -29680,14 +30827,14 @@ var ts; case 23 /* ImportOrExportSpecifiers */: return token() === 19 /* CloseBraceToken */; case 3 /* SwitchClauseStatements */: - return token() === 19 /* CloseBraceToken */ || token() === 81 /* CaseKeyword */ || token() === 87 /* DefaultKeyword */; + return token() === 19 /* CloseBraceToken */ || token() === 82 /* CaseKeyword */ || token() === 88 /* DefaultKeyword */; case 7 /* HeritageClauseElement */: - return token() === 18 /* OpenBraceToken */ || token() === 93 /* ExtendsKeyword */ || token() === 116 /* ImplementsKeyword */; + return token() === 18 /* OpenBraceToken */ || token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; case 8 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); case 19 /* TypeParameters */: // Tokens other than '>' are here for better error recovery - return token() === 31 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 93 /* ExtendsKeyword */ || token() === 116 /* ImplementsKeyword */; + return token() === 31 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; case 11 /* ArgumentExpressions */: // Tokens other than ')' are here for better error recovery return token() === 21 /* CloseParenToken */ || token() === 26 /* SemicolonToken */; @@ -29753,8 +30900,7 @@ var ts; var listPos = getNodePos(); while (!isListTerminator(kind)) { if (isListElement(kind, /*inErrorRecovery*/ false)) { - var element = parseListElement(kind, parseElement); - list.push(element); + list.push(parseListElement(kind, parseElement)); continue; } if (abortParsingListOrMoveToNextToken(kind)) { @@ -29904,20 +31050,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 166 /* Constructor */: - case 171 /* IndexSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 163 /* PropertyDeclaration */: - case 229 /* SemicolonClassElement */: + case 168 /* Constructor */: + case 173 /* IndexSignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 231 /* SemicolonClassElement */: return true; - case 165 /* MethodDeclaration */: + case 167 /* 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 === 78 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 132 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 79 /* Identifier */ && + methodDeclaration.name.originalKeywordKind === 133 /* ConstructorKeyword */; return !nameIsConstructor; } } @@ -29926,8 +31072,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 284 /* CaseClause */: - case 285 /* DefaultClause */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: return true; } } @@ -29936,58 +31082,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 232 /* VariableStatement */: - case 230 /* Block */: - case 234 /* IfStatement */: - case 233 /* ExpressionStatement */: - case 246 /* ThrowStatement */: - case 242 /* ReturnStatement */: - case 244 /* SwitchStatement */: - case 241 /* BreakStatement */: - case 240 /* ContinueStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 237 /* ForStatement */: - case 236 /* WhileStatement */: - case 243 /* WithStatement */: - case 231 /* EmptyStatement */: - case 247 /* TryStatement */: - case 245 /* LabeledStatement */: - case 235 /* DoStatement */: - case 248 /* DebuggerStatement */: - case 261 /* ImportDeclaration */: - case 260 /* ImportEqualsDeclaration */: - case 267 /* ExportDeclaration */: - case 266 /* ExportAssignment */: - case 256 /* ModuleDeclaration */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 253 /* FunctionDeclaration */: + case 234 /* VariableStatement */: + case 232 /* Block */: + case 236 /* IfStatement */: + case 235 /* ExpressionStatement */: + case 248 /* ThrowStatement */: + case 244 /* ReturnStatement */: + case 246 /* SwitchStatement */: + case 243 /* BreakStatement */: + case 242 /* ContinueStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 239 /* ForStatement */: + case 238 /* WhileStatement */: + case 245 /* WithStatement */: + case 233 /* EmptyStatement */: + case 249 /* TryStatement */: + case 247 /* LabeledStatement */: + case 237 /* DoStatement */: + case 250 /* DebuggerStatement */: + case 263 /* ImportDeclaration */: + case 262 /* ImportEqualsDeclaration */: + case 269 /* ExportDeclaration */: + case 268 /* ExportAssignment */: + case 258 /* ModuleDeclaration */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 257 /* EnumDeclaration */: + case 256 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 291 /* EnumMember */; + return node.kind === 293 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 170 /* ConstructSignature */: - case 164 /* MethodSignature */: - case 171 /* IndexSignature */: - case 162 /* PropertySignature */: - case 169 /* CallSignature */: + case 172 /* ConstructSignature */: + case 166 /* MethodSignature */: + case 173 /* IndexSignature */: + case 164 /* PropertySignature */: + case 171 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 249 /* VariableDeclaration */) { + if (node.kind !== 251 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -30008,7 +31154,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 160 /* Parameter */) { + if (node.kind !== 162 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -30175,12 +31321,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(78 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } } - if (token() === 79 /* PrivateIdentifier */) { + if (token() === 80 /* PrivateIdentifier */) { var node = parsePrivateIdentifier(); - return allowPrivateIdentifiers ? node : createMissingNode(78 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return allowPrivateIdentifiers ? node : createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } @@ -30289,14 +31435,14 @@ var ts; // If true, we should abort parsing an error function. function typeHasArrowFunctionBlockingParseError(node) { switch (node.kind) { - case 173 /* TypeReference */: + case 175 /* TypeReference */: return ts.nodeIsMissing(node.typeName); - case 174 /* FunctionType */: - case 175 /* ConstructorType */: { + case 176 /* FunctionType */: + case 177 /* ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 186 /* ParenthesizedType */: + case 188 /* ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -30338,7 +31484,7 @@ var ts; token() === 19 /* CloseBraceToken */ || token() === 21 /* CloseParenToken */ || token() === 31 /* GreaterThanToken */ || - token() === 62 /* EqualsToken */ || + token() === 63 /* EqualsToken */ || token() === 51 /* BarToken */) { return finishNode(factory.createJSDocUnknownType(), pos); } @@ -30360,7 +31506,7 @@ var ts; function parseJSDocParameter() { var pos = getNodePos(); var name; - if (token() === 107 /* ThisKeyword */ || token() === 102 /* NewKeyword */) { + if (token() === 108 /* ThisKeyword */ || token() === 103 /* NewKeyword */) { name = parseIdentifierName(); parseExpected(58 /* ColonToken */); } @@ -30376,7 +31522,7 @@ var ts; function parseJSDocType() { scanner.setInJSDocType(true); var pos = getNodePos(); - if (parseOptional(139 /* ModuleKeyword */)) { + if (parseOptional(140 /* 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) { @@ -30399,7 +31545,7 @@ var ts; if (hasDotDotDot) { type = finishNode(factory.createJSDocVariadicType(type), pos); } - if (token() === 62 /* EqualsToken */) { + if (token() === 63 /* EqualsToken */) { nextToken(); return finishNode(factory.createJSDocOptionalType(type), pos); } @@ -30407,7 +31553,7 @@ var ts; } function parseTypeQuery() { var pos = getNodePos(); - parseExpected(111 /* TypeOfKeyword */); + parseExpected(112 /* TypeOfKeyword */); return finishNode(factory.createTypeQueryNode(parseEntityName(/*allowReservedWords*/ true)), pos); } function parseTypeParameter() { @@ -30415,7 +31561,7 @@ var ts; var name = parseIdentifier(); var constraint; var expression; - if (parseOptional(93 /* ExtendsKeyword */)) { + if (parseOptional(94 /* 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 @@ -30434,7 +31580,7 @@ var ts; expression = parseUnaryExpressionOrHigher(); } } - var defaultType = parseOptional(62 /* EqualsToken */) ? parseType() : undefined; + var defaultType = parseOptional(63 /* EqualsToken */) ? parseType() : undefined; var node = factory.createTypeParameterDeclaration(name, constraint, defaultType); node.expression = expression; return finishNode(node, pos); @@ -30477,19 +31623,21 @@ var ts; function parseParameterWorker(inOuterAwaitContext) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - if (token() === 107 /* ThisKeyword */) { - var node_1 = factory.createParameterDeclaration( - /*decorators*/ undefined, + // 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 node_1 = factory.createParameterDeclaration(decorators, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, createIdentifier(/*isIdentifier*/ true), /*questionToken*/ undefined, parseTypeAnnotation(), /*initializer*/ undefined); + if (decorators) { + parseErrorAtRange(decorators[0], ts.Diagnostics.Decorators_may_not_be_applied_to_this_parameters); + } return withJSDoc(finishNode(node_1, pos), hasJSDoc); } - // 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(); var savedTopLevel = topLevel; topLevel = false; var modifiers = parseModifiers(); @@ -30576,14 +31724,14 @@ var ts; function parseSignatureMember(kind) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - if (kind === 170 /* ConstructSignature */) { - parseExpected(102 /* NewKeyword */); + if (kind === 172 /* ConstructSignature */) { + parseExpected(103 /* NewKeyword */); } var typeParameters = parseTypeParameters(); var parameters = parseParameters(4 /* Type */); var type = parseReturnType(58 /* ColonToken */, /*isType*/ true); parseTypeMemberSemicolon(); - var node = kind === 169 /* CallSignature */ + var node = kind === 171 /* CallSignature */ ? factory.createCallSignature(typeParameters, parameters, type) : factory.createConstructSignature(typeParameters, parameters, type); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -30666,7 +31814,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() === 62 /* EqualsToken */) + if (token() === 63 /* EqualsToken */) node.initializer = parseInitializer(); } parseTypeMemberSemicolon(); @@ -30674,7 +31822,10 @@ var ts; } function isTypeMemberStart() { // Return true if we have the start of a signature member - if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + if (token() === 20 /* OpenParenToken */ || + token() === 29 /* LessThanToken */ || + token() === 135 /* GetKeyword */ || + token() === 147 /* SetKeyword */) { return true; } var idToken = false; @@ -30706,14 +31857,20 @@ var ts; } function parseTypeMember() { if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { - return parseSignatureMember(169 /* CallSignature */); + return parseSignatureMember(171 /* CallSignature */); } - if (token() === 102 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(170 /* ConstructSignature */); + if (token() === 103 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { + return parseSignatureMember(172 /* ConstructSignature */); } var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiers(); + if (parseContextualModifier(135 /* GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 169 /* GetAccessor */); + } + if (parseContextualModifier(147 /* SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 170 /* SetAccessor */); + } if (isIndexSignature()) { return parseIndexSignatureDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers); } @@ -30753,17 +31910,17 @@ var ts; function isStartOfMappedType() { nextToken(); if (token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { - return nextToken() === 142 /* ReadonlyKeyword */; + return nextToken() === 143 /* ReadonlyKeyword */; } - if (token() === 142 /* ReadonlyKeyword */) { + if (token() === 143 /* ReadonlyKeyword */) { nextToken(); } - return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 100 /* InKeyword */; + return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 101 /* InKeyword */; } function parseMappedTypeParameter() { var pos = getNodePos(); var name = parseIdentifierName(); - parseExpected(100 /* InKeyword */); + parseExpected(101 /* InKeyword */); var type = parseType(); return finishNode(factory.createTypeParameterDeclaration(name, type, /*defaultType*/ undefined), pos); } @@ -30771,15 +31928,15 @@ var ts; var pos = getNodePos(); parseExpected(18 /* OpenBraceToken */); var readonlyToken; - if (token() === 142 /* ReadonlyKeyword */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { + if (token() === 143 /* ReadonlyKeyword */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { readonlyToken = parseTokenNode(); - if (readonlyToken.kind !== 142 /* ReadonlyKeyword */) { - parseExpected(142 /* ReadonlyKeyword */); + if (readonlyToken.kind !== 143 /* ReadonlyKeyword */) { + parseExpected(143 /* ReadonlyKeyword */); } } parseExpected(22 /* OpenBracketToken */); var typeParameter = parseMappedTypeParameter(); - var nameType = parseOptional(126 /* AsKeyword */) ? parseType() : undefined; + var nameType = parseOptional(127 /* AsKeyword */) ? parseType() : undefined; parseExpected(23 /* CloseBracketToken */); var questionToken; if (token() === 57 /* QuestionToken */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { @@ -30843,10 +32000,10 @@ var ts; } function parseModifiersForConstructorType() { var modifiers; - if (token() === 125 /* AbstractKeyword */) { + if (token() === 126 /* AbstractKeyword */) { var pos = getNodePos(); nextToken(); - var modifier = finishNode(factory.createToken(125 /* AbstractKeyword */), pos); + var modifier = finishNode(factory.createToken(126 /* AbstractKeyword */), pos); modifiers = createNodeArray([modifier], pos); } return modifiers; @@ -30855,7 +32012,7 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiersForConstructorType(); - var isConstructorType = parseOptional(102 /* NewKeyword */); + var isConstructorType = parseOptional(103 /* NewKeyword */); var typeParameters = parseTypeParameters(); var parameters = parseParameters(4 /* Type */); var type = parseReturnType(38 /* EqualsGreaterThanToken */, /*isType*/ false); @@ -30875,7 +32032,7 @@ var ts; if (negative) { nextToken(); } - var expression = token() === 109 /* TrueKeyword */ || token() === 94 /* FalseKeyword */ || token() === 103 /* NullKeyword */ ? + var expression = token() === 110 /* TrueKeyword */ || token() === 95 /* FalseKeyword */ || token() === 104 /* NullKeyword */ ? parseTokenNode() : parseLiteralLikeNode(token()); if (negative) { @@ -30885,13 +32042,13 @@ var ts; } function isStartOfTypeOfImportType() { nextToken(); - return token() === 99 /* ImportKeyword */; + return token() === 100 /* ImportKeyword */; } function parseImportType() { sourceFlags |= 1048576 /* PossiblyContainsDynamicImport */; var pos = getNodePos(); - var isTypeOf = parseOptional(111 /* TypeOfKeyword */); - parseExpected(99 /* ImportKeyword */); + var isTypeOf = parseOptional(112 /* TypeOfKeyword */); + parseExpected(100 /* ImportKeyword */); parseExpected(20 /* OpenParenToken */); var type = parseType(); parseExpected(21 /* CloseParenToken */); @@ -30905,19 +32062,19 @@ var ts; } function parseNonArrayType() { switch (token()) { - case 128 /* AnyKeyword */: - case 152 /* UnknownKeyword */: - case 147 /* StringKeyword */: - case 144 /* NumberKeyword */: - case 155 /* BigIntKeyword */: - case 148 /* SymbolKeyword */: - case 131 /* BooleanKeyword */: - case 150 /* UndefinedKeyword */: - case 141 /* NeverKeyword */: - case 145 /* ObjectKeyword */: + case 129 /* AnyKeyword */: + case 153 /* UnknownKeyword */: + case 148 /* StringKeyword */: + case 145 /* NumberKeyword */: + case 156 /* BigIntKeyword */: + case 149 /* SymbolKeyword */: + case 132 /* BooleanKeyword */: + case 151 /* UndefinedKeyword */: + case 142 /* NeverKeyword */: + case 146 /* ObjectKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. return tryParse(parseKeywordAndNoDot) || parseTypeReference(); - case 65 /* AsteriskEqualsToken */: + case 66 /* AsteriskEqualsToken */: // If there is '*=', treat it as * followed by postfix = scanner.reScanAsteriskEqualsToken(); // falls through @@ -30929,7 +32086,7 @@ var ts; // falls through case 57 /* QuestionToken */: return parseJSDocUnknownOrNullableType(); - case 97 /* FunctionKeyword */: + case 98 /* FunctionKeyword */: return parseJSDocFunctionType(); case 53 /* ExclamationToken */: return parseJSDocNonNullableType(); @@ -30937,24 +32094,24 @@ var ts; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: - case 103 /* NullKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: + case 104 /* NullKeyword */: return parseLiteralTypeNode(); case 40 /* MinusToken */: return lookAhead(nextTokenIsNumericOrBigIntLiteral) ? parseLiteralTypeNode(/*negative*/ true) : parseTypeReference(); - case 113 /* VoidKeyword */: + case 114 /* VoidKeyword */: return parseTokenNode(); - case 107 /* ThisKeyword */: { + case 108 /* ThisKeyword */: { var thisKeyword = parseThisTypeNode(); - if (token() === 137 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 138 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 111 /* TypeOfKeyword */: + case 112 /* TypeOfKeyword */: return lookAhead(isStartOfTypeOfImportType) ? parseImportType() : parseTypeQuery(); case 18 /* OpenBraceToken */: return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral(); @@ -30962,9 +32119,9 @@ var ts; return parseTupleType(); case 20 /* OpenParenToken */: return parseParenthesizedType(); - case 99 /* ImportKeyword */: + case 100 /* ImportKeyword */: return parseImportType(); - case 127 /* AssertsKeyword */: + case 128 /* AssertsKeyword */: return lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? parseAssertsTypePredicate() : parseTypeReference(); case 15 /* TemplateHead */: return parseTemplateType(); @@ -30974,44 +32131,44 @@ var ts; } function isStartOfType(inStartOfParameter) { switch (token()) { - case 128 /* AnyKeyword */: - case 152 /* UnknownKeyword */: - case 147 /* StringKeyword */: - case 144 /* NumberKeyword */: - case 155 /* BigIntKeyword */: - case 131 /* BooleanKeyword */: - case 142 /* ReadonlyKeyword */: - case 148 /* SymbolKeyword */: - case 151 /* UniqueKeyword */: - case 113 /* VoidKeyword */: - case 150 /* UndefinedKeyword */: - case 103 /* NullKeyword */: - case 107 /* ThisKeyword */: - case 111 /* TypeOfKeyword */: - case 141 /* NeverKeyword */: + case 129 /* AnyKeyword */: + case 153 /* UnknownKeyword */: + case 148 /* StringKeyword */: + case 145 /* NumberKeyword */: + case 156 /* BigIntKeyword */: + case 132 /* BooleanKeyword */: + case 143 /* ReadonlyKeyword */: + case 149 /* SymbolKeyword */: + case 152 /* UniqueKeyword */: + case 114 /* VoidKeyword */: + case 151 /* UndefinedKeyword */: + case 104 /* NullKeyword */: + case 108 /* ThisKeyword */: + case 112 /* TypeOfKeyword */: + case 142 /* NeverKeyword */: case 18 /* OpenBraceToken */: case 22 /* OpenBracketToken */: case 29 /* LessThanToken */: case 51 /* BarToken */: case 50 /* AmpersandToken */: - case 102 /* NewKeyword */: + case 103 /* NewKeyword */: case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: - case 145 /* ObjectKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: + case 146 /* ObjectKeyword */: case 41 /* AsteriskToken */: case 57 /* QuestionToken */: case 53 /* ExclamationToken */: case 25 /* DotDotDotToken */: - case 135 /* InferKeyword */: - case 99 /* ImportKeyword */: - case 127 /* AssertsKeyword */: + case 136 /* InferKeyword */: + case 100 /* ImportKeyword */: + case 128 /* AssertsKeyword */: case 14 /* NoSubstitutionTemplateLiteral */: case 15 /* TemplateHead */: return true; - case 97 /* FunctionKeyword */: + case 98 /* FunctionKeyword */: return !inStartOfParameter; case 40 /* MinusToken */: return !inStartOfParameter && lookAhead(nextTokenIsNumericOrBigIntLiteral); @@ -31075,17 +32232,17 @@ var ts; } function parseInferType() { var pos = getNodePos(); - parseExpected(135 /* InferKeyword */); + parseExpected(136 /* InferKeyword */); return finishNode(factory.createInferTypeNode(parseTypeParameterOfInferType()), pos); } function parseTypeOperatorOrHigher() { var operator = token(); switch (operator) { - case 138 /* KeyOfKeyword */: - case 151 /* UniqueKeyword */: - case 142 /* ReadonlyKeyword */: + case 139 /* KeyOfKeyword */: + case 152 /* UniqueKeyword */: + case 143 /* ReadonlyKeyword */: return parseTypeOperator(operator); - case 135 /* InferKeyword */: + case 136 /* InferKeyword */: return parseInferType(); } return parsePostfixTypeOrHigher(); @@ -31135,7 +32292,7 @@ var ts; } function nextTokenIsNewKeyword() { nextToken(); - return token() === 102 /* NewKeyword */; + return token() === 103 /* NewKeyword */; } function isStartOfFunctionTypeOrConstructorType() { if (token() === 29 /* LessThanToken */) { @@ -31144,15 +32301,15 @@ var ts; if (token() === 20 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType)) { return true; } - return token() === 102 /* NewKeyword */ || - token() === 125 /* AbstractKeyword */ && lookAhead(nextTokenIsNewKeyword); + return token() === 103 /* NewKeyword */ || + token() === 126 /* AbstractKeyword */ && lookAhead(nextTokenIsNewKeyword); } function skipParameterStart() { if (ts.isModifierKind(token())) { // Skip modifiers parseModifiers(); } - if (isIdentifier() || token() === 107 /* ThisKeyword */) { + if (isIdentifier() || token() === 108 /* ThisKeyword */) { nextToken(); return true; } @@ -31175,7 +32332,7 @@ var ts; // 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() === 62 /* EqualsToken */) { + token() === 57 /* QuestionToken */ || token() === 63 /* EqualsToken */) { // ( xxx : // ( xxx , // ( xxx ? @@ -31205,16 +32362,16 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 137 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 138 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } } function parseAssertsTypePredicate() { var pos = getNodePos(); - var assertsModifier = parseExpectedToken(127 /* AssertsKeyword */); - var parameterName = token() === 107 /* ThisKeyword */ ? parseThisTypeNode() : parseIdentifier(); - var type = parseOptional(137 /* IsKeyword */) ? parseType() : undefined; + var assertsModifier = parseExpectedToken(128 /* AssertsKeyword */); + var parameterName = token() === 108 /* ThisKeyword */ ? parseThisTypeNode() : parseIdentifier(); + var type = parseOptional(138 /* IsKeyword */) ? parseType() : undefined; return finishNode(factory.createTypePredicateNode(assertsModifier, parameterName, type), pos); } function parseType() { @@ -31228,7 +32385,7 @@ var ts; } var pos = getNodePos(); var type = parseUnionTypeOrHigher(); - if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(93 /* ExtendsKeyword */)) { + if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(94 /* ExtendsKeyword */)) { // The type following 'extends' is not permitted to be another conditional type var extendsType = parseTypeWorker(/*noConditionalTypes*/ true); parseExpected(57 /* QuestionToken */); @@ -31245,11 +32402,11 @@ var ts; // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token()) { - case 107 /* ThisKeyword */: - case 105 /* SuperKeyword */: - case 103 /* NullKeyword */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: + case 108 /* ThisKeyword */: + case 106 /* SuperKeyword */: + case 104 /* NullKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: @@ -31258,14 +32415,14 @@ var ts; case 20 /* OpenParenToken */: case 22 /* OpenBracketToken */: case 18 /* OpenBraceToken */: - case 97 /* FunctionKeyword */: - case 83 /* ClassKeyword */: - case 102 /* NewKeyword */: + case 98 /* FunctionKeyword */: + case 84 /* ClassKeyword */: + case 103 /* NewKeyword */: case 43 /* SlashToken */: - case 67 /* SlashEqualsToken */: - case 78 /* Identifier */: + case 68 /* SlashEqualsToken */: + case 79 /* Identifier */: return true; - case 99 /* ImportKeyword */: + case 100 /* ImportKeyword */: return lookAhead(nextTokenIsOpenParenOrLessThanOrDot); default: return isIdentifier(); @@ -31280,15 +32437,15 @@ var ts; case 40 /* MinusToken */: case 54 /* TildeToken */: case 53 /* ExclamationToken */: - case 88 /* DeleteKeyword */: - case 111 /* TypeOfKeyword */: - case 113 /* VoidKeyword */: + case 89 /* DeleteKeyword */: + case 112 /* TypeOfKeyword */: + case 114 /* VoidKeyword */: case 45 /* PlusPlusToken */: case 46 /* MinusMinusToken */: case 29 /* LessThanToken */: - case 130 /* AwaitKeyword */: - case 124 /* YieldKeyword */: - case 79 /* PrivateIdentifier */: + case 131 /* AwaitKeyword */: + case 125 /* YieldKeyword */: + case 80 /* 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. @@ -31307,8 +32464,8 @@ var ts; function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. return token() !== 18 /* OpenBraceToken */ && - token() !== 97 /* FunctionKeyword */ && - token() !== 83 /* ClassKeyword */ && + token() !== 98 /* FunctionKeyword */ && + token() !== 84 /* ClassKeyword */ && token() !== 59 /* AtToken */ && isStartOfExpression(); } @@ -31333,7 +32490,7 @@ var ts; return expr; } function parseInitializer() { - return parseOptional(62 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; + return parseOptional(63 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; } function parseAssignmentExpressionOrHigher() { // AssignmentExpression[in,yield]: @@ -31379,7 +32536,7 @@ var ts; // 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 === 78 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { + if (expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(pos, expr, /*asyncModifier*/ undefined); } // Now see if we might be in cases '2' or '3'. @@ -31395,7 +32552,7 @@ var ts; return parseConditionalExpressionRest(expr, pos); } function isYieldExpression() { - if (token() === 124 /* YieldKeyword */) { + if (token() === 125 /* 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()) { @@ -31475,7 +32632,7 @@ 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() === 129 /* AsyncKeyword */) { + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */ || token() === 130 /* AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } if (token() === 38 /* EqualsGreaterThanToken */) { @@ -31488,7 +32645,7 @@ var ts; return 0 /* False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 129 /* AsyncKeyword */) { + if (token() === 130 /* AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0 /* False */; @@ -31532,13 +32689,13 @@ var ts; // 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 !== 129 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { + if (ts.isModifierKind(second) && second !== 130 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { return 1 /* 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 !== 107 /* ThisKeyword */) { + if (!isIdentifier() && second !== 108 /* ThisKeyword */) { return 0 /* False */; } switch (nextToken()) { @@ -31549,13 +32706,13 @@ var ts; case 57 /* 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() === 62 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { + if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 63 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { return 1 /* True */; } // Otherwise it is definitely not a lambda. return 0 /* False */; case 27 /* CommaToken */: - case 62 /* EqualsToken */: + case 63 /* EqualsToken */: case 21 /* CloseParenToken */: // If we have "(a," or "(a=" or "(a)" this *could* be an arrow function return 2 /* Unknown */; @@ -31574,10 +32731,10 @@ var ts; if (languageVariant === 1 /* JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 93 /* ExtendsKeyword */) { + if (third === 94 /* ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 62 /* EqualsToken */: + case 63 /* EqualsToken */: case 31 /* GreaterThanToken */: return false; default: @@ -31611,7 +32768,7 @@ var ts; } function tryParseAsyncSimpleArrowFunctionExpression() { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" - if (token() === 129 /* AsyncKeyword */) { + if (token() === 130 /* AsyncKeyword */) { if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) { var pos = getNodePos(); var asyncModifier = parseModifiersForArrowFunction(); @@ -31625,7 +32782,7 @@ 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() === 129 /* AsyncKeyword */) { + if (token() === 130 /* 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" @@ -31634,7 +32791,7 @@ var ts; } // Check for un-parenthesized AsyncArrowFunction var expr = parseBinaryExpressionOrHigher(0 /* Lowest */); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 78 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { + if (!scanner.hasPrecedingLineBreak() && expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { return 1 /* True */; } } @@ -31699,8 +32856,8 @@ var ts; return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */); } if (token() !== 26 /* SemicolonToken */ && - token() !== 97 /* FunctionKeyword */ && - token() !== 83 /* ClassKeyword */ && + token() !== 98 /* FunctionKeyword */ && + token() !== 84 /* ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -31738,7 +32895,7 @@ var ts; var colonToken; return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher), colonToken = parseExpectedToken(58 /* ColonToken */), ts.nodeIsPresent(colonToken) ? parseAssignmentExpressionOrHigher() - : createMissingNode(78 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */))), pos); + : createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */))), pos); } function parseBinaryExpressionOrHigher(precedence) { var pos = getNodePos(); @@ -31746,7 +32903,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand, pos); } function isInOrOfKeyword(t) { - return t === 100 /* InKeyword */ || t === 156 /* OfKeyword */; + return t === 101 /* InKeyword */ || t === 158 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand, pos) { while (true) { @@ -31781,10 +32938,10 @@ var ts; if (!consumeCurrentOperator) { break; } - if (token() === 100 /* InKeyword */ && inDisallowInContext()) { + if (token() === 101 /* InKeyword */ && inDisallowInContext()) { break; } - if (token() === 126 /* AsKeyword */) { + if (token() === 127 /* AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -31805,7 +32962,7 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 100 /* InKeyword */) { + if (inDisallowInContext() && token() === 101 /* InKeyword */) { return false; } return ts.getBinaryOperatorPrecedence(token()) > 0; @@ -31833,7 +32990,7 @@ var ts; return finishNode(factory.createVoidExpression(nextTokenAnd(parseSimpleUnaryExpression)), pos); } function isAwaitExpression() { - if (token() === 130 /* AwaitKeyword */) { + if (token() === 131 /* AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -31886,7 +33043,7 @@ var ts; if (token() === 42 /* AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 206 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 208 /* 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 { @@ -31916,18 +33073,18 @@ var ts; case 54 /* TildeToken */: case 53 /* ExclamationToken */: return parsePrefixUnaryExpression(); - case 88 /* DeleteKeyword */: + case 89 /* DeleteKeyword */: return parseDeleteExpression(); - case 111 /* TypeOfKeyword */: + case 112 /* TypeOfKeyword */: return parseTypeOfExpression(); - case 113 /* VoidKeyword */: + case 114 /* VoidKeyword */: return parseVoidExpression(); case 29 /* LessThanToken */: // This is modified UnaryExpression grammar in TypeScript // UnaryExpression (modified): // < type > UnaryExpression return parseTypeAssertion(); - case 130 /* AwaitKeyword */: + case 131 /* AwaitKeyword */: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -31954,10 +33111,10 @@ var ts; case 40 /* MinusToken */: case 54 /* TildeToken */: case 53 /* ExclamationToken */: - case 88 /* DeleteKeyword */: - case 111 /* TypeOfKeyword */: - case 113 /* VoidKeyword */: - case 130 /* AwaitKeyword */: + case 89 /* DeleteKeyword */: + case 112 /* TypeOfKeyword */: + case 114 /* VoidKeyword */: + case 131 /* AwaitKeyword */: return false; case 29 /* LessThanToken */: // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression @@ -32033,7 +33190,7 @@ var ts; // or starts the beginning of the first four CallExpression productions. var pos = getNodePos(); var expression; - if (token() === 99 /* ImportKeyword */) { + if (token() === 100 /* 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: @@ -32047,7 +33204,7 @@ var ts; // This is an 'import.*' metaproperty (i.e. 'import.meta') nextToken(); // advance past the 'import' nextToken(); // advance past the dot - expression = finishNode(factory.createMetaProperty(99 /* ImportKeyword */, parseIdentifierName()), pos); + expression = finishNode(factory.createMetaProperty(100 /* ImportKeyword */, parseIdentifierName()), pos); sourceFlags |= 2097152 /* PossiblyContainsImportMeta */; } else { @@ -32055,7 +33212,7 @@ var ts; } } else { - expression = token() === 105 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); + expression = token() === 106 /* 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 @@ -32133,23 +33290,45 @@ var ts; // 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); } - function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext, topInvalidNodePosition) { + function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext, topInvalidNodePosition, openingTag) { var pos = getNodePos(); var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 275 /* JsxOpeningElement */) { + if (opening.kind === 277 /* JsxOpeningElement */) { var children = parseJsxChildren(opening); - var closingElement = parseJsxClosingElement(inExpressionContext); - if (!tagNamesAreEquivalent(opening.tagName, closingElement.tagName)) { - parseErrorAtRange(closingElement, ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNodeFromSourceText(sourceText, opening.tagName)); + var closingElement = void 0; + var lastChild = children[children.length - 1]; + if ((lastChild === null || lastChild === void 0 ? void 0 : lastChild.kind) === 275 /* JsxElement */ + && !tagNamesAreEquivalent(lastChild.openingElement.tagName, lastChild.closingElement.tagName) + && tagNamesAreEquivalent(opening.tagName, lastChild.closingElement.tagName)) { + // when an unclosed JsxOpeningElement incorrectly parses its parent's JsxClosingElement, + // restructure (
(...
)) --> (
(...)
) + // (no need to error; the parent will error) + var end = lastChild.openingElement.end; // newly-created children and closing are both zero-width end/end + var newLast = finishNode(factory.createJsxElement(lastChild.openingElement, createNodeArray([], end, end), finishNode(factory.createJsxClosingElement(finishNode(factory.createIdentifier(""), end, end)), end, end)), lastChild.openingElement.pos, end); + children = createNodeArray(__spreadArray(__spreadArray([], children.slice(0, children.length - 1)), [newLast]), children.pos, end); + closingElement = lastChild.closingElement; + } + else { + closingElement = parseJsxClosingElement(opening, inExpressionContext); + if (!tagNamesAreEquivalent(opening.tagName, closingElement.tagName)) { + if (openingTag && ts.isJsxOpeningElement(openingTag) && tagNamesAreEquivalent(closingElement.tagName, openingTag.tagName)) { + // opening incorrectly matched with its parent's closing -- put error on opening + parseErrorAtRange(opening.tagName, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, opening.tagName)); + } + else { + // other opening/closing mismatches -- put error on closing + parseErrorAtRange(closingElement.tagName, ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNodeFromSourceText(sourceText, opening.tagName)); + } + } } result = finishNode(factory.createJsxElement(opening, children, closingElement), pos); } - else if (opening.kind === 278 /* JsxOpeningFragment */) { + else if (opening.kind === 280 /* JsxOpeningFragment */) { result = finishNode(factory.createJsxFragment(opening, parseJsxChildren(opening), parseJsxClosingFragment(inExpressionContext)), pos); } else { - ts.Debug.assert(opening.kind === 274 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 276 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -32203,7 +33382,7 @@ var ts; case 18 /* OpenBraceToken */: return parseJsxExpression(/*inExpressionContext*/ false); case 29 /* LessThanToken */: - return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ false); + return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ false, /*topInvalidNodePosition*/ undefined, openingTag); default: return ts.Debug.assertNever(token); } @@ -32218,6 +33397,13 @@ var ts; if (!child) break; list.push(child); + if (ts.isJsxOpeningElement(openingTag) + && (child === null || child === void 0 ? void 0 : child.kind) === 275 /* 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 + break; + } } parsingContext = saveParsingContext; return createNodeArray(list, listPos); @@ -32247,12 +33433,14 @@ var ts; } else { parseExpected(43 /* SlashToken */); - if (inExpressionContext) { - parseExpected(31 /* GreaterThanToken */); - } - else { - parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); - scanJsxText(); + if (parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { + // manually advance the scanner in order to look for jsx text inside jsx + if (inExpressionContext) { + nextToken(); + } + else { + scanJsxText(); + } } node = factory.createJsxSelfClosingElement(tagName, typeArguments, attributes); } @@ -32266,7 +33454,7 @@ 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() === 107 /* ThisKeyword */ ? + var expression = token() === 108 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); while (parseOptional(24 /* DotToken */)) { expression = finishNode(factory.createPropertyAccessExpression(expression, parseRightSideOfDot(/*allowIdentifierNames*/ true, /*allowPrivateIdentifiers*/ false)), pos); @@ -32303,7 +33491,7 @@ var ts; } scanJsxIdentifier(); var pos = getNodePos(); - return finishNode(factory.createJsxAttribute(parseIdentifierName(), token() !== 62 /* EqualsToken */ ? undefined : + return finishNode(factory.createJsxAttribute(parseIdentifierName(), token() !== 63 /* EqualsToken */ ? undefined : scanJsxAttributeValue() === 10 /* StringLiteral */ ? parseLiteralNode() : parseJsxExpression(/*inExpressionContext*/ true)), pos); } @@ -32315,16 +33503,18 @@ var ts; parseExpected(19 /* CloseBraceToken */); return finishNode(factory.createJsxSpreadAttribute(expression), pos); } - function parseJsxClosingElement(inExpressionContext) { + function parseJsxClosingElement(open, inExpressionContext) { var pos = getNodePos(); parseExpected(30 /* LessThanSlashToken */); var tagName = parseJsxElementName(); - if (inExpressionContext) { - parseExpected(31 /* GreaterThanToken */); - } - else { - parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); - scanJsxText(); + if (parseExpected(31 /* 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(); + } + else { + scanJsxText(); + } } return finishNode(factory.createJsxClosingElement(tagName), pos); } @@ -32334,12 +33524,14 @@ var ts; if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); } - if (inExpressionContext) { - parseExpected(31 /* GreaterThanToken */); - } - else { - parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); - scanJsxText(); + if (parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { + // manually advance the scanner in order to look for jsx text inside jsx + if (inExpressionContext) { + nextToken(); + } + else { + scanJsxText(); + } } return finishNode(factory.createJsxJsxClosingFragment(), pos); } @@ -32396,7 +33588,7 @@ var ts; function parseElementAccessExpressionRest(pos, expression, questionDotToken) { var argumentExpression; if (token() === 23 /* CloseBracketToken */) { - argumentExpression = createMissingNode(78 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); + argumentExpression = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); } else { var argument = allowInAnd(parseExpression); @@ -32491,7 +33683,7 @@ var ts; } if (questionDotToken) { // We failed to parse anything, so report a missing identifier here. - var name = createMissingNode(78 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected); + var name = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected); expression = finishNode(factory.createPropertyAccessChain(expression, questionDotToken, name), pos); } break; @@ -32572,11 +33764,11 @@ var ts; case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 107 /* ThisKeyword */: - case 105 /* SuperKeyword */: - case 103 /* NullKeyword */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: + case 108 /* ThisKeyword */: + case 106 /* SuperKeyword */: + case 104 /* NullKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: return parseTokenNode(); case 20 /* OpenParenToken */: return parseParenthesizedExpression(); @@ -32584,7 +33776,7 @@ var ts; return parseArrayLiteralExpression(); case 18 /* OpenBraceToken */: return parseObjectLiteralExpression(); - case 129 /* AsyncKeyword */: + case 130 /* 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. @@ -32592,14 +33784,14 @@ var ts; break; } return parseFunctionExpression(); - case 83 /* ClassKeyword */: + case 84 /* ClassKeyword */: return parseClassExpression(); - case 97 /* FunctionKeyword */: + case 98 /* FunctionKeyword */: return parseFunctionExpression(); - case 102 /* NewKeyword */: + case 103 /* NewKeyword */: return parseNewExpressionOrNewDotTarget(); case 43 /* SlashToken */: - case 67 /* SlashEqualsToken */: + case 68 /* SlashEqualsToken */: if (reScanSlashToken() === 13 /* RegularExpressionLiteral */) { return parseLiteralNode(); } @@ -32648,11 +33840,11 @@ var ts; } var decorators = parseDecorators(); var modifiers = parseModifiers(); - if (parseContextualModifier(134 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 167 /* GetAccessor */); + if (parseContextualModifier(135 /* GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 169 /* GetAccessor */); } - if (parseContextualModifier(146 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 168 /* SetAccessor */); + if (parseContextualModifier(147 /* SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 170 /* SetAccessor */); } var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); @@ -32671,7 +33863,7 @@ var ts; var node; var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* ColonToken */); if (isShorthandPropertyAssignment) { - var equalsToken = parseOptionalToken(62 /* EqualsToken */); + var equalsToken = parseOptionalToken(63 /* EqualsToken */); var objectAssignmentInitializer = equalsToken ? allowInAnd(parseAssignmentExpressionOrHigher) : undefined; node = factory.createShorthandPropertyAssignment(name, objectAssignmentInitializer); // Save equals token for error reporting. @@ -32717,7 +33909,7 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiers(); - parseExpected(97 /* FunctionKeyword */); + 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 */; @@ -32740,10 +33932,10 @@ var ts; } function parseNewExpressionOrNewDotTarget() { var pos = getNodePos(); - parseExpected(102 /* NewKeyword */); + parseExpected(103 /* NewKeyword */); if (parseOptional(24 /* DotToken */)) { var name = parseIdentifierName(); - return finishNode(factory.createMetaProperty(102 /* NewKeyword */, name), pos); + return finishNode(factory.createMetaProperty(103 /* NewKeyword */, name), pos); } var expressionPos = getNodePos(); var expression = parsePrimaryExpression(); @@ -32770,6 +33962,7 @@ var ts; // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { var pos = getNodePos(); + var hasJSDoc = hasPrecedingJSDocComment(); var openBracePosition = scanner.getTokenPos(); if (parseExpected(18 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { var multiLine = scanner.hasPrecedingLineBreak(); @@ -32780,11 +33973,16 @@ var ts; ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here)); } } - return finishNode(factory.createBlock(statements, multiLine), pos); + var result = withJSDoc(finishNode(factory.createBlock(statements, multiLine), pos), hasJSDoc); + if (token() === 63 /* 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(); + } + return result; } else { var statements = createMissingList(); - return finishNode(factory.createBlock(statements, /*multiLine*/ undefined), pos); + return withJSDoc(finishNode(factory.createBlock(statements, /*multiLine*/ undefined), pos), hasJSDoc); } } function parseFunctionBlock(flags, diagnosticMessage) { @@ -32811,24 +34009,27 @@ var ts; } function parseEmptyStatement() { var pos = getNodePos(); + var hasJSDoc = hasPrecedingJSDocComment(); parseExpected(26 /* SemicolonToken */); - return finishNode(factory.createEmptyStatement(), pos); + return withJSDoc(finishNode(factory.createEmptyStatement(), pos), hasJSDoc); } function parseIfStatement() { var pos = getNodePos(); - parseExpected(98 /* IfKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(99 /* IfKeyword */); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); var thenStatement = parseStatement(); - var elseStatement = parseOptional(90 /* ElseKeyword */) ? parseStatement() : undefined; - return finishNode(factory.createIfStatement(expression, thenStatement, elseStatement), pos); + var elseStatement = parseOptional(91 /* ElseKeyword */) ? parseStatement() : undefined; + return withJSDoc(finishNode(factory.createIfStatement(expression, thenStatement, elseStatement), pos), hasJSDoc); } function parseDoStatement() { var pos = getNodePos(); - parseExpected(89 /* DoKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(90 /* DoKeyword */); var statement = parseStatement(); - parseExpected(114 /* WhileKeyword */); + parseExpected(115 /* WhileKeyword */); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); @@ -32837,25 +34038,27 @@ var ts; // 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 */); - return finishNode(factory.createDoStatement(statement, expression), pos); + return withJSDoc(finishNode(factory.createDoStatement(statement, expression), pos), hasJSDoc); } function parseWhileStatement() { var pos = getNodePos(); - parseExpected(114 /* WhileKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(115 /* WhileKeyword */); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); var statement = parseStatement(); - return finishNode(factory.createWhileStatement(expression, statement), pos); + return withJSDoc(finishNode(factory.createWhileStatement(expression, statement), pos), hasJSDoc); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(96 /* ForKeyword */); - var awaitToken = parseOptionalToken(130 /* AwaitKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(97 /* ForKeyword */); + var awaitToken = parseOptionalToken(131 /* AwaitKeyword */); parseExpected(20 /* OpenParenToken */); var initializer; if (token() !== 26 /* SemicolonToken */) { - if (token() === 112 /* VarKeyword */ || token() === 118 /* LetKeyword */ || token() === 84 /* ConstKeyword */) { + if (token() === 113 /* VarKeyword */ || token() === 119 /* LetKeyword */ || token() === 85 /* ConstKeyword */) { initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { @@ -32863,12 +34066,12 @@ var ts; } } var node; - if (awaitToken ? parseExpected(156 /* OfKeyword */) : parseOptional(156 /* OfKeyword */)) { + if (awaitToken ? parseExpected(158 /* OfKeyword */) : parseOptional(158 /* OfKeyword */)) { var expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(21 /* CloseParenToken */); node = factory.createForOfStatement(awaitToken, initializer, expression, parseStatement()); } - else if (parseOptional(100 /* InKeyword */)) { + else if (parseOptional(101 /* InKeyword */)) { var expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); node = factory.createForInStatement(initializer, expression, parseStatement()); @@ -32885,37 +34088,40 @@ var ts; parseExpected(21 /* CloseParenToken */); node = factory.createForStatement(initializer, condition, incrementor, parseStatement()); } - return finishNode(node, pos); + return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseBreakOrContinueStatement(kind) { var pos = getNodePos(); - parseExpected(kind === 241 /* BreakStatement */ ? 80 /* BreakKeyword */ : 85 /* ContinueKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(kind === 243 /* BreakStatement */ ? 81 /* BreakKeyword */ : 86 /* ContinueKeyword */); var label = canParseSemicolon() ? undefined : parseIdentifier(); parseSemicolon(); - var node = kind === 241 /* BreakStatement */ + var node = kind === 243 /* BreakStatement */ ? factory.createBreakStatement(label) : factory.createContinueStatement(label); - return finishNode(node, pos); + return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseReturnStatement() { var pos = getNodePos(); - parseExpected(104 /* ReturnKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(105 /* ReturnKeyword */); var expression = canParseSemicolon() ? undefined : allowInAnd(parseExpression); parseSemicolon(); - return finishNode(factory.createReturnStatement(expression), pos); + return withJSDoc(finishNode(factory.createReturnStatement(expression), pos), hasJSDoc); } function parseWithStatement() { var pos = getNodePos(); - parseExpected(115 /* WithKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(116 /* WithKeyword */); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); var statement = doInsideOfContext(16777216 /* InWithStatement */, parseStatement); - return finishNode(factory.createWithStatement(expression, statement), pos); + return withJSDoc(finishNode(factory.createWithStatement(expression, statement), pos), hasJSDoc); } function parseCaseClause() { var pos = getNodePos(); - parseExpected(81 /* CaseKeyword */); + parseExpected(82 /* CaseKeyword */); var expression = allowInAnd(parseExpression); parseExpected(58 /* ColonToken */); var statements = parseList(3 /* SwitchClauseStatements */, parseStatement); @@ -32923,13 +34129,13 @@ var ts; } function parseDefaultClause() { var pos = getNodePos(); - parseExpected(87 /* DefaultKeyword */); + parseExpected(88 /* DefaultKeyword */); parseExpected(58 /* ColonToken */); var statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(factory.createDefaultClause(statements), pos); } function parseCaseOrDefaultClause() { - return token() === 81 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token() === 82 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseCaseBlock() { var pos = getNodePos(); @@ -32940,18 +34146,20 @@ var ts; } function parseSwitchStatement() { var pos = getNodePos(); - parseExpected(106 /* SwitchKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(107 /* SwitchKeyword */); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); var caseBlock = parseCaseBlock(); - return finishNode(factory.createSwitchStatement(expression, caseBlock), pos); + return withJSDoc(finishNode(factory.createSwitchStatement(expression, caseBlock), pos), hasJSDoc); } function parseThrowStatement() { // ThrowStatement[Yield] : // throw [no LineTerminator here]Expression[In, ?Yield]; var pos = getNodePos(); - parseExpected(108 /* ThrowKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(109 /* 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. @@ -32963,26 +34171,27 @@ var ts; expression = finishNode(factory.createIdentifier(""), getNodePos()); } parseSemicolon(); - return finishNode(factory.createThrowStatement(expression), pos); + return withJSDoc(finishNode(factory.createThrowStatement(expression), pos), hasJSDoc); } // TODO: Review for error recovery function parseTryStatement() { var pos = getNodePos(); - parseExpected(110 /* TryKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(111 /* TryKeyword */); var tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); - var catchClause = token() === 82 /* CatchKeyword */ ? parseCatchClause() : undefined; + var catchClause = token() === 83 /* 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() === 95 /* FinallyKeyword */) { - parseExpected(95 /* FinallyKeyword */); + if (!catchClause || token() === 96 /* FinallyKeyword */) { + parseExpected(96 /* FinallyKeyword */); finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } - return finishNode(factory.createTryStatement(tryBlock, catchClause, finallyBlock), pos); + return withJSDoc(finishNode(factory.createTryStatement(tryBlock, catchClause, finallyBlock), pos), hasJSDoc); } function parseCatchClause() { var pos = getNodePos(); - parseExpected(82 /* CatchKeyword */); + parseExpected(83 /* CatchKeyword */); var variableDeclaration; if (parseOptional(20 /* OpenParenToken */)) { variableDeclaration = parseVariableDeclaration(); @@ -32997,9 +34206,10 @@ var ts; } function parseDebuggerStatement() { var pos = getNodePos(); - parseExpected(86 /* DebuggerKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(87 /* DebuggerKeyword */); parseSemicolon(); - return finishNode(factory.createDebuggerStatement(), pos); + return withJSDoc(finishNode(factory.createDebuggerStatement(), pos), hasJSDoc); } function parseExpressionOrLabeledStatement() { // Avoiding having to do the lookahead for a labeled statement by just trying to parse @@ -33029,11 +34239,11 @@ var ts; } function nextTokenIsClassKeywordOnSameLine() { nextToken(); - return token() === 83 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 84 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 97 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 98 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine() { nextToken(); @@ -33042,12 +34252,12 @@ var ts; function isDeclaration() { while (true) { switch (token()) { - case 112 /* VarKeyword */: - case 118 /* LetKeyword */: - case 84 /* ConstKeyword */: - case 97 /* FunctionKeyword */: - case 83 /* ClassKeyword */: - case 91 /* EnumKeyword */: + case 113 /* VarKeyword */: + case 119 /* LetKeyword */: + case 85 /* ConstKeyword */: + case 98 /* FunctionKeyword */: + case 84 /* ClassKeyword */: + case 92 /* 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 @@ -33070,44 +34280,44 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 117 /* InterfaceKeyword */: - case 149 /* TypeKeyword */: + case 118 /* InterfaceKeyword */: + case 150 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 139 /* ModuleKeyword */: - case 140 /* NamespaceKeyword */: + case 140 /* ModuleKeyword */: + case 141 /* NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 125 /* AbstractKeyword */: - case 129 /* AsyncKeyword */: - case 133 /* DeclareKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 122 /* PublicKeyword */: - case 142 /* ReadonlyKeyword */: + case 126 /* AbstractKeyword */: + case 130 /* AsyncKeyword */: + case 134 /* DeclareKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + case 123 /* PublicKeyword */: + case 143 /* ReadonlyKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 154 /* GlobalKeyword */: + case 155 /* GlobalKeyword */: nextToken(); - return token() === 18 /* OpenBraceToken */ || token() === 78 /* Identifier */ || token() === 92 /* ExportKeyword */; - case 99 /* ImportKeyword */: + return token() === 18 /* OpenBraceToken */ || token() === 79 /* Identifier */ || token() === 93 /* ExportKeyword */; + case 100 /* ImportKeyword */: nextToken(); return token() === 10 /* StringLiteral */ || token() === 41 /* AsteriskToken */ || token() === 18 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); - case 92 /* ExportKeyword */: + case 93 /* ExportKeyword */: var currentToken_1 = nextToken(); - if (currentToken_1 === 149 /* TypeKeyword */) { + if (currentToken_1 === 150 /* TypeKeyword */) { currentToken_1 = lookAhead(nextToken); } - if (currentToken_1 === 62 /* EqualsToken */ || currentToken_1 === 41 /* AsteriskToken */ || - currentToken_1 === 18 /* OpenBraceToken */ || currentToken_1 === 87 /* DefaultKeyword */ || - currentToken_1 === 126 /* AsKeyword */) { + if (currentToken_1 === 63 /* EqualsToken */ || currentToken_1 === 41 /* AsteriskToken */ || + currentToken_1 === 18 /* OpenBraceToken */ || currentToken_1 === 88 /* DefaultKeyword */ || + currentToken_1 === 127 /* AsKeyword */) { return true; } continue; - case 123 /* StaticKeyword */: + case 124 /* StaticKeyword */: nextToken(); continue; default: @@ -33123,48 +34333,48 @@ var ts; case 59 /* AtToken */: case 26 /* SemicolonToken */: case 18 /* OpenBraceToken */: - case 112 /* VarKeyword */: - case 118 /* LetKeyword */: - case 97 /* FunctionKeyword */: - case 83 /* ClassKeyword */: - case 91 /* EnumKeyword */: - case 98 /* IfKeyword */: - case 89 /* DoKeyword */: - case 114 /* WhileKeyword */: - case 96 /* ForKeyword */: - case 85 /* ContinueKeyword */: - case 80 /* BreakKeyword */: - case 104 /* ReturnKeyword */: - case 115 /* WithKeyword */: - case 106 /* SwitchKeyword */: - case 108 /* ThrowKeyword */: - case 110 /* TryKeyword */: - case 86 /* DebuggerKeyword */: + 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 */: // '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 82 /* CatchKeyword */: - case 95 /* FinallyKeyword */: + case 83 /* CatchKeyword */: + case 96 /* FinallyKeyword */: return true; - case 99 /* ImportKeyword */: + case 100 /* ImportKeyword */: return isStartOfDeclaration() || lookAhead(nextTokenIsOpenParenOrLessThanOrDot); - case 84 /* ConstKeyword */: - case 92 /* ExportKeyword */: + case 85 /* ConstKeyword */: + case 93 /* ExportKeyword */: return isStartOfDeclaration(); - case 129 /* AsyncKeyword */: - case 133 /* DeclareKeyword */: - case 117 /* InterfaceKeyword */: - case 139 /* ModuleKeyword */: - case 140 /* NamespaceKeyword */: - case 149 /* TypeKeyword */: - case 154 /* GlobalKeyword */: + case 130 /* AsyncKeyword */: + case 134 /* DeclareKeyword */: + case 118 /* InterfaceKeyword */: + case 140 /* ModuleKeyword */: + case 141 /* NamespaceKeyword */: + case 150 /* TypeKeyword */: + case 155 /* GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 122 /* PublicKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 123 /* StaticKeyword */: - case 142 /* ReadonlyKeyword */: + case 123 /* PublicKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + case 124 /* StaticKeyword */: + case 143 /* 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); @@ -33187,64 +34397,64 @@ var ts; return parseEmptyStatement(); case 18 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); - case 112 /* VarKeyword */: + case 113 /* VarKeyword */: return parseVariableStatement(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 118 /* LetKeyword */: + case 119 /* LetKeyword */: if (isLetDeclaration()) { return parseVariableStatement(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); } break; - case 97 /* FunctionKeyword */: + case 98 /* FunctionKeyword */: return parseFunctionDeclaration(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 83 /* ClassKeyword */: + case 84 /* ClassKeyword */: return parseClassDeclaration(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 98 /* IfKeyword */: + case 99 /* IfKeyword */: return parseIfStatement(); - case 89 /* DoKeyword */: + case 90 /* DoKeyword */: return parseDoStatement(); - case 114 /* WhileKeyword */: + case 115 /* WhileKeyword */: return parseWhileStatement(); - case 96 /* ForKeyword */: + case 97 /* ForKeyword */: return parseForOrForInOrForOfStatement(); - case 85 /* ContinueKeyword */: - return parseBreakOrContinueStatement(240 /* ContinueStatement */); - case 80 /* BreakKeyword */: - return parseBreakOrContinueStatement(241 /* BreakStatement */); - case 104 /* ReturnKeyword */: + case 86 /* ContinueKeyword */: + return parseBreakOrContinueStatement(242 /* ContinueStatement */); + case 81 /* BreakKeyword */: + return parseBreakOrContinueStatement(243 /* BreakStatement */); + case 105 /* ReturnKeyword */: return parseReturnStatement(); - case 115 /* WithKeyword */: + case 116 /* WithKeyword */: return parseWithStatement(); - case 106 /* SwitchKeyword */: + case 107 /* SwitchKeyword */: return parseSwitchStatement(); - case 108 /* ThrowKeyword */: + case 109 /* ThrowKeyword */: return parseThrowStatement(); - case 110 /* TryKeyword */: + case 111 /* TryKeyword */: // Include 'catch' and 'finally' for error recovery. // falls through - case 82 /* CatchKeyword */: - case 95 /* FinallyKeyword */: + case 83 /* CatchKeyword */: + case 96 /* FinallyKeyword */: return parseTryStatement(); - case 86 /* DebuggerKeyword */: + case 87 /* DebuggerKeyword */: return parseDebuggerStatement(); case 59 /* AtToken */: return parseDeclaration(); - case 129 /* AsyncKeyword */: - case 117 /* InterfaceKeyword */: - case 149 /* TypeKeyword */: - case 139 /* ModuleKeyword */: - case 140 /* NamespaceKeyword */: - case 133 /* DeclareKeyword */: - case 84 /* ConstKeyword */: - case 91 /* EnumKeyword */: - case 92 /* ExportKeyword */: - case 99 /* ImportKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 122 /* PublicKeyword */: - case 125 /* AbstractKeyword */: - case 123 /* StaticKeyword */: - case 142 /* ReadonlyKeyword */: - case 154 /* GlobalKeyword */: + case 130 /* AsyncKeyword */: + case 118 /* InterfaceKeyword */: + case 150 /* TypeKeyword */: + case 140 /* ModuleKeyword */: + case 141 /* NamespaceKeyword */: + case 134 /* 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 143 /* ReadonlyKeyword */: + case 155 /* GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -33253,7 +34463,7 @@ var ts; return parseExpressionOrLabeledStatement(); } function isDeclareModifier(modifier) { - return modifier.kind === 133 /* DeclareKeyword */; + return modifier.kind === 134 /* DeclareKeyword */; } function parseDeclaration() { // TODO: Can we hold onto the parsed decorators/modifiers and advance the scanner @@ -33294,33 +34504,33 @@ var ts; } function parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers) { switch (token()) { - case 112 /* VarKeyword */: - case 118 /* LetKeyword */: - case 84 /* ConstKeyword */: + case 113 /* VarKeyword */: + case 119 /* LetKeyword */: + case 85 /* ConstKeyword */: return parseVariableStatement(pos, hasJSDoc, decorators, modifiers); - case 97 /* FunctionKeyword */: + case 98 /* FunctionKeyword */: return parseFunctionDeclaration(pos, hasJSDoc, decorators, modifiers); - case 83 /* ClassKeyword */: + case 84 /* ClassKeyword */: return parseClassDeclaration(pos, hasJSDoc, decorators, modifiers); - case 117 /* InterfaceKeyword */: + case 118 /* InterfaceKeyword */: return parseInterfaceDeclaration(pos, hasJSDoc, decorators, modifiers); - case 149 /* TypeKeyword */: + case 150 /* TypeKeyword */: return parseTypeAliasDeclaration(pos, hasJSDoc, decorators, modifiers); - case 91 /* EnumKeyword */: + case 92 /* EnumKeyword */: return parseEnumDeclaration(pos, hasJSDoc, decorators, modifiers); - case 154 /* GlobalKeyword */: - case 139 /* ModuleKeyword */: - case 140 /* NamespaceKeyword */: + case 155 /* GlobalKeyword */: + case 140 /* ModuleKeyword */: + case 141 /* NamespaceKeyword */: return parseModuleDeclaration(pos, hasJSDoc, decorators, modifiers); - case 99 /* ImportKeyword */: + case 100 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers); - case 92 /* ExportKeyword */: + case 93 /* ExportKeyword */: nextToken(); switch (token()) { - case 87 /* DefaultKeyword */: - case 62 /* EqualsToken */: + case 88 /* DefaultKeyword */: + case 63 /* EqualsToken */: return parseExportAssignment(pos, hasJSDoc, decorators, modifiers); - case 126 /* AsKeyword */: + case 127 /* AsKeyword */: return parseNamespaceExportDeclaration(pos, hasJSDoc, decorators, modifiers); default: return parseExportDeclaration(pos, hasJSDoc, decorators, modifiers); @@ -33329,7 +34539,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(271 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(273 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); ts.setTextRangePos(missing, pos); missing.decorators = decorators; missing.modifiers = modifiers; @@ -33394,7 +34604,7 @@ var ts; function isBindingIdentifierOrPrivateIdentifierOrPattern() { return token() === 18 /* OpenBraceToken */ || token() === 22 /* OpenBracketToken */ - || token() === 79 /* PrivateIdentifier */ + || token() === 80 /* PrivateIdentifier */ || isBindingIdentifier(); } function parseIdentifierOrPattern(privateIdentifierDiagnosticMessage) { @@ -33411,27 +34621,28 @@ var ts; } function parseVariableDeclaration(allowExclamation) { var pos = getNodePos(); + var hasJSDoc = hasPrecedingJSDocComment(); var name = parseIdentifierOrPattern(ts.Diagnostics.Private_identifiers_are_not_allowed_in_variable_declarations); var exclamationToken; - if (allowExclamation && name.kind === 78 /* Identifier */ && + if (allowExclamation && name.kind === 79 /* Identifier */ && token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { exclamationToken = parseTokenNode(); } var type = parseTypeAnnotation(); var initializer = isInOrOfKeyword(token()) ? undefined : parseInitializer(); var node = factory.createVariableDeclaration(name, exclamationToken, type, initializer); - return finishNode(node, pos); + return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseVariableDeclarationList(inForStatementInitializer) { var pos = getNodePos(); var flags = 0; switch (token()) { - case 112 /* VarKeyword */: + case 113 /* VarKeyword */: break; - case 118 /* LetKeyword */: + case 119 /* LetKeyword */: flags |= 1 /* Let */; break; - case 84 /* ConstKeyword */: + case 85 /* ConstKeyword */: flags |= 2 /* Const */; break; default: @@ -33448,7 +34659,7 @@ var ts; // this context. // The checker will then give an error that there is an empty declaration list. var declarations; - if (token() === 156 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 158 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { declarations = createMissingList(); } else { @@ -33473,7 +34684,7 @@ var ts; function parseFunctionDeclaration(pos, hasJSDoc, decorators, modifiers) { var savedAwaitContext = inAwaitContext(); var modifierFlags = ts.modifiersToFlags(modifiers); - parseExpected(97 /* FunctionKeyword */); + parseExpected(98 /* FunctionKeyword */); var asteriskToken = parseOptionalToken(41 /* 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(); @@ -33490,8 +34701,8 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseConstructorName() { - if (token() === 132 /* ConstructorKeyword */) { - return parseExpected(132 /* ConstructorKeyword */); + if (token() === 133 /* ConstructorKeyword */) { + return parseExpected(133 /* ConstructorKeyword */); } if (token() === 10 /* StringLiteral */ && lookAhead(nextToken) === 20 /* OpenParenToken */) { return tryParse(function () { @@ -33552,12 +34763,12 @@ var ts; var parameters = parseParameters(0 /* None */); var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); var body = parseFunctionBlockOrSemicolon(0 /* None */); - var node = kind === 167 /* GetAccessor */ + var node = kind === 169 /* GetAccessor */ ? factory.createGetAccessorDeclaration(decorators, modifiers, name, parameters, type, body) : factory.createSetAccessorDeclaration(decorators, modifiers, name, parameters, body); // Keep track of `typeParameters` (for both) and `type` (for setters) if they were parsed those indicate grammar errors node.typeParameters = typeParameters; - if (type && node.kind === 168 /* SetAccessor */) + if (type && node.kind === 170 /* SetAccessor */) node.type = type; return withJSDoc(finishNode(node, pos), hasJSDoc); } @@ -33596,7 +34807,7 @@ var ts; // 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 === 146 /* SetKeyword */ || idToken === 134 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 147 /* SetKeyword */ || idToken === 135 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along @@ -33606,7 +34817,7 @@ var ts; case 29 /* LessThanToken */: // Generic Method declaration case 53 /* ExclamationToken */: // Non-null assertion on property name case 58 /* ColonToken */: // Type Annotation for declaration - case 62 /* EqualsToken */: // Initializer for declaration + case 63 /* EqualsToken */: // Initializer for declaration case 57 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. return true; default: @@ -33621,7 +34832,7 @@ var ts; return false; } function parseDecoratorExpression() { - if (inAwaitContext() && token() === 130 /* AwaitKeyword */) { + if (inAwaitContext() && token() === 131 /* 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(); @@ -33651,7 +34862,7 @@ var ts; function tryParseModifier(permitInvalidConstAsModifier) { var pos = getNodePos(); var kind = token(); - if (token() === 84 /* ConstKeyword */ && permitInvalidConstAsModifier) { + if (token() === 85 /* 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)) { @@ -33682,10 +34893,10 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 129 /* AsyncKeyword */) { + if (token() === 130 /* AsyncKeyword */) { var pos = getNodePos(); nextToken(); - var modifier = finishNode(factory.createToken(129 /* AsyncKeyword */), pos); + var modifier = finishNode(factory.createToken(130 /* AsyncKeyword */), pos); modifiers = createNodeArray([modifier], pos); } return modifiers; @@ -33699,13 +34910,13 @@ var ts; var hasJSDoc = hasPrecedingJSDocComment(); var decorators = parseDecorators(); var modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true); - if (parseContextualModifier(134 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 167 /* GetAccessor */); + if (parseContextualModifier(135 /* GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 169 /* GetAccessor */); } - if (parseContextualModifier(146 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 168 /* SetAccessor */); + if (parseContextualModifier(147 /* SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 170 /* SetAccessor */); } - if (token() === 132 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { + if (token() === 133 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { var constructorDeclaration = tryParseConstructorDeclaration(pos, hasJSDoc, decorators, modifiers); if (constructorDeclaration) { return constructorDeclaration; @@ -33735,21 +34946,21 @@ var ts; } if (decorators || modifiers) { // treat this as a property declaration with a missing name. - var name = createMissingNode(78 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var name = createMissingNode(79 /* 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, 221 /* ClassExpression */); + return parseClassDeclarationOrExpression(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined, 223 /* ClassExpression */); } function parseClassDeclaration(pos, hasJSDoc, decorators, modifiers) { - return parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, 252 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, 254 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, kind) { var savedAwaitContext = inAwaitContext(); - parseExpected(83 /* ClassKeyword */); + parseExpected(84 /* 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(); @@ -33767,7 +34978,7 @@ var ts; members = createMissingList(); } setAwaitContext(savedAwaitContext); - var node = kind === 252 /* ClassDeclaration */ + var node = kind === 254 /* ClassDeclaration */ ? factory.createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) : factory.createClassExpression(decorators, modifiers, name, typeParameters, heritageClauses, members); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -33783,7 +34994,7 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 116 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 117 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); } function parseHeritageClauses() { // ClassTail[Yield,Await] : (Modified) See 14.5 @@ -33796,7 +35007,7 @@ var ts; function parseHeritageClause() { var pos = getNodePos(); var tok = token(); - ts.Debug.assert(tok === 93 /* ExtendsKeyword */ || tok === 116 /* ImplementsKeyword */); // isListElement() should ensure this. + ts.Debug.assert(tok === 94 /* ExtendsKeyword */ || tok === 117 /* ImplementsKeyword */); // isListElement() should ensure this. nextToken(); var types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(factory.createHeritageClause(tok, types), pos); @@ -33812,13 +35023,13 @@ var ts; parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */) : undefined; } function isHeritageClause() { - return token() === 93 /* ExtendsKeyword */ || token() === 116 /* ImplementsKeyword */; + return token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; } function parseClassMembers() { return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(117 /* InterfaceKeyword */); + parseExpected(118 /* InterfaceKeyword */); var name = parseIdentifier(); var typeParameters = parseTypeParameters(); var heritageClauses = parseHeritageClauses(); @@ -33827,11 +35038,11 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseTypeAliasDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(149 /* TypeKeyword */); + parseExpected(150 /* TypeKeyword */); var name = parseIdentifier(); var typeParameters = parseTypeParameters(); - parseExpected(62 /* EqualsToken */); - var type = token() === 136 /* IntrinsicKeyword */ && tryParse(parseKeywordAndNoDot) || parseType(); + parseExpected(63 /* EqualsToken */); + var type = token() === 137 /* IntrinsicKeyword */ && tryParse(parseKeywordAndNoDot) || parseType(); parseSemicolon(); var node = factory.createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -33848,7 +35059,7 @@ var ts; return withJSDoc(finishNode(factory.createEnumMember(name, initializer), pos), hasJSDoc); } function parseEnumDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(91 /* EnumKeyword */); + parseExpected(92 /* EnumKeyword */); var name = parseIdentifier(); var members; if (parseExpected(18 /* OpenBraceToken */)) { @@ -33887,7 +35098,7 @@ var ts; function parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers) { var flags = 0; var name; - if (token() === 154 /* GlobalKeyword */) { + if (token() === 155 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation name = parseIdentifier(); flags |= 1024 /* GlobalAugmentation */; @@ -33908,15 +35119,15 @@ var ts; } function parseModuleDeclaration(pos, hasJSDoc, decorators, modifiers) { var flags = 0; - if (token() === 154 /* GlobalKeyword */) { + if (token() === 155 /* GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers); } - else if (parseOptional(140 /* NamespaceKeyword */)) { + else if (parseOptional(141 /* NamespaceKeyword */)) { flags |= 16 /* Namespace */; } else { - parseExpected(139 /* ModuleKeyword */); + parseExpected(140 /* ModuleKeyword */); if (token() === 10 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers); } @@ -33924,7 +35135,7 @@ var ts; return parseModuleOrNamespaceDeclaration(pos, hasJSDoc, decorators, modifiers, flags); } function isExternalModuleReference() { - return token() === 143 /* RequireKeyword */ && + return token() === 144 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { @@ -33934,8 +35145,8 @@ var ts; return nextToken() === 43 /* SlashToken */; } function parseNamespaceExportDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(126 /* AsKeyword */); - parseExpected(140 /* NamespaceKeyword */); + parseExpected(127 /* AsKeyword */); + parseExpected(141 /* NamespaceKeyword */); var name = parseIdentifier(); parseSemicolon(); var node = factory.createNamespaceExportDeclaration(name); @@ -33945,7 +35156,7 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseImportDeclarationOrImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(99 /* ImportKeyword */); + parseExpected(100 /* 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; @@ -33953,7 +35164,7 @@ var ts; identifier = parseIdentifier(); } var isTypeOnly = false; - if (token() !== 153 /* FromKeyword */ && + if (token() !== 154 /* FromKeyword */ && (identifier === null || identifier === void 0 ? void 0 : identifier.escapedText) === "type" && (isIdentifier() || tokenAfterImportDefinitelyProducesImportDeclaration())) { isTypeOnly = true; @@ -33971,7 +35182,7 @@ var ts; token() === 18 /* OpenBraceToken */ // import { ) { importClause = parseImportClause(identifier, afterImportPos, isTypeOnly); - parseExpected(153 /* FromKeyword */); + parseExpected(154 /* FromKeyword */); } var moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -33984,10 +35195,10 @@ var ts; function tokenAfterImportedIdentifierDefinitelyProducesImportDeclaration() { // In `import id ___`, the current token decides whether to produce // an ImportDeclaration or ImportEqualsDeclaration. - return token() === 27 /* CommaToken */ || token() === 153 /* FromKeyword */; + return token() === 27 /* CommaToken */ || token() === 154 /* FromKeyword */; } function parseImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers, identifier, isTypeOnly) { - parseExpected(62 /* EqualsToken */); + parseExpected(63 /* EqualsToken */); var moduleReference = parseModuleReference(); parseSemicolon(); var node = factory.createImportEqualsDeclaration(decorators, modifiers, isTypeOnly, identifier, moduleReference); @@ -34006,7 +35217,7 @@ var ts; var namedBindings; if (!identifier || parseOptional(27 /* CommaToken */)) { - namedBindings = token() === 41 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(264 /* NamedImports */); + namedBindings = token() === 41 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(266 /* NamedImports */); } return finishNode(factory.createImportClause(isTypeOnly, identifier, namedBindings), pos); } @@ -34017,7 +35228,7 @@ var ts; } function parseExternalModuleReference() { var pos = getNodePos(); - parseExpected(143 /* RequireKeyword */); + parseExpected(144 /* RequireKeyword */); parseExpected(20 /* OpenParenToken */); var expression = parseModuleSpecifier(); parseExpected(21 /* CloseParenToken */); @@ -34041,7 +35252,7 @@ var ts; // * as ImportedBinding var pos = getNodePos(); parseExpected(41 /* AsteriskToken */); - parseExpected(126 /* AsKeyword */); + parseExpected(127 /* AsKeyword */); var name = parseIdentifier(); return finishNode(factory.createNamespaceImport(name), pos); } @@ -34054,16 +35265,16 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - var node = kind === 264 /* NamedImports */ + var node = kind === 266 /* NamedImports */ ? factory.createNamedImports(parseBracketedList(23 /* ImportOrExportSpecifiers */, parseImportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */)) : factory.createNamedExports(parseBracketedList(23 /* ImportOrExportSpecifiers */, parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */)); return finishNode(node, pos); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(270 /* ExportSpecifier */); + return parseImportOrExportSpecifier(272 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(265 /* ImportSpecifier */); + return parseImportOrExportSpecifier(267 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var pos = getNodePos(); @@ -34079,9 +35290,9 @@ var ts; var identifierName = parseIdentifierName(); var propertyName; var name; - if (token() === 126 /* AsKeyword */) { + if (token() === 127 /* AsKeyword */) { propertyName = identifierName; - parseExpected(126 /* AsKeyword */); + parseExpected(127 /* AsKeyword */); checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -34090,10 +35301,10 @@ var ts; else { name = identifierName; } - if (kind === 265 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 267 /* ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } - var node = kind === 265 /* ImportSpecifier */ + var node = kind === 267 /* ImportSpecifier */ ? factory.createImportSpecifier(propertyName, name) : factory.createExportSpecifier(propertyName, name); return finishNode(node, pos); @@ -34106,22 +35317,22 @@ var ts; setAwaitContext(/*value*/ true); var exportClause; var moduleSpecifier; - var isTypeOnly = parseOptional(149 /* TypeKeyword */); + var isTypeOnly = parseOptional(150 /* TypeKeyword */); var namespaceExportPos = getNodePos(); if (parseOptional(41 /* AsteriskToken */)) { - if (parseOptional(126 /* AsKeyword */)) { + if (parseOptional(127 /* AsKeyword */)) { exportClause = parseNamespaceExport(namespaceExportPos); } - parseExpected(153 /* FromKeyword */); + parseExpected(154 /* FromKeyword */); moduleSpecifier = parseModuleSpecifier(); } else { - exportClause = parseNamedImportsOrExports(268 /* NamedExports */); + exportClause = parseNamedImportsOrExports(270 /* 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() === 153 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(153 /* FromKeyword */); + if (token() === 154 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(154 /* FromKeyword */); moduleSpecifier = parseModuleSpecifier(); } } @@ -34134,11 +35345,11 @@ var ts; var savedAwaitContext = inAwaitContext(); setAwaitContext(/*value*/ true); var isExportEquals; - if (parseOptional(62 /* EqualsToken */)) { + if (parseOptional(63 /* EqualsToken */)) { isExportEquals = true; } else { - parseExpected(87 /* DefaultKeyword */); + parseExpected(88 /* DefaultKeyword */); } var expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -34154,7 +35365,7 @@ var ts; getImportMetaIfNecessary(sourceFile); } function isAnExternalModuleIndicatorNode(node) { - return hasModifierOfKind(node, 92 /* ExportKeyword */) + return hasModifierOfKind(node, 93 /* ExportKeyword */) || ts.isImportEqualsDeclaration(node) && ts.isExternalModuleReference(node.moduleReference) || ts.isImportDeclaration(node) || ts.isExportAssignment(node) @@ -34173,7 +35384,7 @@ var ts; return ts.some(node.modifiers, function (m) { return m.kind === kind; }); } function isImportMeta(node) { - return ts.isMetaProperty(node) && node.keywordToken === 99 /* ImportKeyword */ && node.name.escapedText === "meta"; + return ts.isMetaProperty(node) && node.keywordToken === 100 /* ImportKeyword */ && node.name.escapedText === "meta"; } var ParsingContext; (function (ParsingContext) { @@ -34241,7 +35452,13 @@ var ts; function parseJSDocNameReference() { var pos = getNodePos(); var hasBrace = parseOptional(18 /* OpenBraceToken */); + var p2 = getNodePos(); var entityName = parseEntityName(/* allowReservedWords*/ false); + while (token() === 80 /* PrivateIdentifier */) { + reScanHashToken(); // rescan #id as # id + nextTokenJSDoc(); // then skip the # + entityName = finishNode(factory.createJSDocMemberName(entityName, parseIdentifier()), p2); + } if (hasBrace) { parseExpectedJSDoc(19 /* CloseBraceToken */); } @@ -34305,7 +35522,10 @@ var ts; var tags; var tagsPos; var tagsEnd; + var linkEnd; + var commentsPos; var comments = []; + var parts = []; // + 3 for leading /**, - 5 in total for /** */ return scanner.scanRange(start + 3, length - 5, function () { // Initially we can parse out a tag. We also have seen a starting asterisk. @@ -34334,6 +35554,8 @@ var ts; case 59 /* AtToken */: if (state === 0 /* BeginningOfLine */ || state === 1 /* SawAsterisk */) { removeTrailingWhitespace(comments); + if (!commentsPos) + commentsPos = getNodePos(); addTag(parseTag(indent)); // 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 @@ -34376,6 +35598,22 @@ var ts; break; case 1 /* EndOfFileToken */: break loop; + case 18 /* OpenBraceToken */: + state = 2 /* SavingComments */; + var commentEnd = scanner.getStartPos(); + var linkStart = scanner.getTextPos() - 1; + var link = parseJSDocLink(linkStart); + if (link) { + if (!linkEnd) { + removeLeadingNewlines(comments); + } + parts.push(finishNode(factory.createJSDocText(comments.join("")), linkEnd !== null && linkEnd !== void 0 ? linkEnd : start, commentEnd)); + parts.push(link); + comments = []; + linkEnd = scanner.getTextPos(); + break; + } + // fallthrough if it's not a {@link sequence default: // 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 @@ -34386,9 +35624,14 @@ var ts; } nextTokenJSDoc(); } - removeLeadingNewlines(comments); removeTrailingWhitespace(comments); - return createJSDocComment(); + if (parts.length && comments.length) { + parts.push(finishNode(factory.createJSDocText(comments.join("")), linkEnd !== null && linkEnd !== void 0 ? linkEnd : start, commentsPos)); + } + if (parts.length && tags) + ts.Debug.assertIsDefined(commentsPos, "having parsed tags implies that the end of the comment span should be set"); + var tagsArray = tags && createNodeArray(tags, tagsPos, tagsEnd); + return finishNode(factory.createJSDocComment(parts.length ? createNodeArray(parts, start, commentsPos) : comments.length ? comments.join("") : undefined, tagsArray), start, end); }); function removeLeadingNewlines(comments) { while (comments.length && (comments[0] === "\n" || comments[0] === "\r")) { @@ -34400,11 +35643,6 @@ var ts; comments.pop(); } } - function createJSDocComment() { - var comment = comments.length ? comments.join("") : undefined; - var tagsArray = tags && createNodeArray(tags, tagsPos, tagsEnd); - return finishNode(factory.createJSDocComment(comment, tagsArray), start, end); - } function isNextNonwhitespaceTokenEndOfFile() { // We must use infinite lookahead, as there could be any number of newlines :( while (true) { @@ -34484,6 +35722,9 @@ var ts; case "readonly": tag = parseSimpleTag(start, factory.createJSDocReadonlyTag, tagName, margin, indentText); break; + case "override": + tag = parseSimpleTag(start, factory.createJSDocOverrideTag, tagName, margin, indentText); + break; case "deprecated": hasDeprecatedTag = true; tag = parseSimpleTag(start, factory.createJSDocDeprecatedTag, tagName, margin, indentText); @@ -34531,8 +35772,12 @@ var ts; return parseTagComments(margin, indentText.slice(margin)); } function parseTagComments(indent, initialMargin) { + var commentsPos = getNodePos(); var comments = []; + var parts = []; + var linkEnd; var state = 0 /* BeginningOfLine */; + var previousWhitespace = true; var margin; function pushComment(text) { if (!margin) { @@ -34558,7 +35803,9 @@ var ts; indent = 0; break; case 59 /* AtToken */: - if (state === 3 /* SavingBackticks */) { + if (state === 3 /* SavingBackticks */ + || state === 2 /* 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; } @@ -34582,13 +35829,18 @@ var ts; break; case 18 /* OpenBraceToken */: state = 2 /* SavingComments */; - if (lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenText() === "link"; })) { - pushComment(scanner.getTokenText()); - nextTokenJSDoc(); + var commentEnd = scanner.getStartPos(); + var linkStart = scanner.getTextPos() - 1; + var link = parseJSDocLink(linkStart); + if (link) { + parts.push(finishNode(factory.createJSDocText(comments.join("")), linkEnd !== null && linkEnd !== void 0 ? linkEnd : commentsPos, commentEnd)); + parts.push(link); + comments = []; + linkEnd = scanner.getTextPos(); + } + else { pushComment(scanner.getTokenText()); - nextTokenJSDoc(); } - pushComment(scanner.getTokenText()); break; case 61 /* BacktickToken */: if (state === 3 /* SavingBackticks */) { @@ -34615,15 +35867,67 @@ var ts; pushComment(scanner.getTokenText()); break; } + previousWhitespace = token() === 5 /* WhitespaceTrivia */; tok = nextTokenJSDoc(); } removeLeadingNewlines(comments); removeTrailingWhitespace(comments); - return comments.length === 0 ? undefined : comments.join(""); + if (parts.length) { + if (comments.length) { + parts.push(finishNode(factory.createJSDocText(comments.join("")), linkEnd !== null && linkEnd !== void 0 ? linkEnd : commentsPos)); + } + return createNodeArray(parts, commentsPos, scanner.getTextPos()); + } + else if (comments.length) { + return comments.join(""); + } + } + function isNextJSDocTokenWhitespace() { + var next = nextTokenJSDoc(); + return next === 5 /* WhitespaceTrivia */ || next === 4 /* NewLineTrivia */; + } + function parseJSDocLink(start) { + var linkType = tryParse(parseJSDocLinkPrefix); + if (!linkType) { + return undefined; + } + nextTokenJSDoc(); // start at token after link, then skip any whitespace + skipWhitespace(); + // parseEntityName logs an error for non-identifier, so create a MissingNode ourselves to avoid the error + var p2 = getNodePos(); + var name = ts.tokenIsIdentifierOrKeyword(token()) + ? parseEntityName(/*allowReservedWords*/ true) + : undefined; + if (name) { + while (token() === 80 /* 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 */) { + text.push(scanner.getTokenText()); + nextTokenJSDoc(); + } + var create = linkType === "link" ? factory.createJSDocLink + : linkType === "linkcode" ? factory.createJSDocLinkCode + : factory.createJSDocLinkPlain; + return finishNode(create(name, text.join("")), start, scanner.getTextPos()); + } + function parseJSDocLinkPrefix() { + skipWhitespaceOrAsterisk(); + if (token() === 18 /* OpenBraceToken */ + && nextTokenJSDoc() === 59 /* AtToken */ + && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc())) { + var kind = scanner.getTokenValue(); + if (kind === "link" || kind === "linkcode" || kind === "linkplain") { + return kind; + } + } } function parseUnknownTag(start, tagName, indent, indentText) { - var end = getNodePos(); - return finishNode(factory.createJSDocUnknownTag(tagName, parseTrailingTagComments(start, end, indent, indentText)), start, end); + return finishNode(factory.createJSDocUnknownTag(tagName, parseTrailingTagComments(start, getNodePos(), indent, indentText)), start); } function addTag(tag) { if (!tag) { @@ -34657,7 +35961,7 @@ var ts; if (isBracketed) { skipWhitespace(); // May have an optional default, e.g. '[foo = 42]' - if (parseOptionalToken(62 /* EqualsToken */)) { + if (parseOptionalToken(63 /* EqualsToken */)) { parseExpression(); } parseExpected(23 /* CloseBracketToken */); @@ -34666,9 +35970,9 @@ var ts; } function isObjectOrObjectArrayTypeReference(node) { switch (node.kind) { - case 145 /* ObjectKeyword */: + case 146 /* ObjectKeyword */: return true; - case 178 /* ArrayType */: + case 180 /* ArrayType */: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && !node.typeArguments; @@ -34679,11 +35983,11 @@ var ts; var isNameFirst = !typeExpression; skipWhitespaceOrAsterisk(); var _a = parseBracketNameInPropertyAndParamTag(), name = _a.name, isBracketed = _a.isBracketed; - skipWhitespace(); - if (isNameFirst) { + var indentText = skipWhitespaceOrAsterisk(); + if (isNameFirst && !lookAhead(parseJSDocLinkPrefix)) { typeExpression = tryParseTypeExpression(); } - var comment = parseTagComments(indent + scanner.getStartPos() - start); + var comment = parseTrailingTagComments(start, getNodePos(), indent, indentText); var nestedTypeLiteral = target !== 4 /* CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { typeExpression = nestedTypeLiteral; @@ -34700,12 +36004,12 @@ var ts; var child = void 0; var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 326 /* JSDocParameterTag */ || child.kind === 333 /* JSDocPropertyTag */) { + if (child.kind === 334 /* JSDocParameterTag */ || child.kind === 341 /* JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - var literal = finishNode(factory.createJSDocTypeLiteral(children, typeExpression.type.kind === 178 /* ArrayType */), pos); + var literal = finishNode(factory.createJSDocTypeLiteral(children, typeExpression.type.kind === 180 /* ArrayType */), pos); return finishNode(factory.createJSDocTypeExpression(literal), pos); } } @@ -34715,27 +36019,34 @@ var ts; parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } var typeExpression = tryParseTypeExpression(); - var end = getNodePos(); - return finishNode(factory.createJSDocReturnTag(tagName, typeExpression, parseTrailingTagComments(start, end, indent, indentText)), start, end); + return finishNode(factory.createJSDocReturnTag(tagName, typeExpression, parseTrailingTagComments(start, getNodePos(), indent, indentText)), start); } function parseTypeTag(start, tagName, indent, indentText) { if (ts.some(tags, ts.isJSDocTypeTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } var typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); - var end = getNodePos(); - var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, end, indent, indentText) : undefined; - return finishNode(factory.createJSDocTypeTag(tagName, typeExpression, comments), start, end); + var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, getNodePos(), indent, indentText) : undefined; + return finishNode(factory.createJSDocTypeTag(tagName, typeExpression, comments), start); } function parseSeeTag(start, tagName, indent, indentText) { - var nameExpression = parseJSDocNameReference(); - var end = getNodePos(); - var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, end, indent, indentText) : undefined; - return finishNode(factory.createJSDocSeeTag(tagName, nameExpression, comments), start, end); + var isLink = lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenValue() === "link"; }); + var nameExpression = isLink ? undefined : parseJSDocNameReference(); + var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, getNodePos(), indent, indentText) : undefined; + return finishNode(factory.createJSDocSeeTag(tagName, nameExpression, comments), start); } function parseAuthorTag(start, tagName, indent, indentText) { - var comments = parseAuthorNameAndEmail() + (parseTrailingTagComments(start, end, indent, indentText) || ""); - return finishNode(factory.createJSDocAuthorTag(tagName, comments || undefined), start); + var commentStart = getNodePos(); + var textOnly = parseAuthorNameAndEmail(); + var commentEnd = scanner.getStartPos(); + var comments = parseTrailingTagComments(start, commentEnd, indent, indentText); + if (!comments) { + commentEnd = scanner.getStartPos(); + } + var allParts = typeof comments !== "string" + ? createNodeArray(ts.concatenate([finishNode(textOnly, commentStart, commentEnd)], comments), commentStart) // cast away readonly + : textOnly.text + comments; + return finishNode(factory.createJSDocAuthorTag(tagName, allParts), start); } function parseAuthorNameAndEmail() { var comments = []; @@ -34756,17 +36067,15 @@ var ts; comments.push(scanner.getTokenText()); token = nextTokenJSDoc(); } - return comments.join(""); + return factory.createJSDocText(comments.join("")); } function parseImplementsTag(start, tagName, margin, indentText) { var className = parseExpressionWithTypeArgumentsForAugments(); - var end = getNodePos(); - return finishNode(factory.createJSDocImplementsTag(tagName, className, parseTrailingTagComments(start, end, margin, indentText)), start, end); + return finishNode(factory.createJSDocImplementsTag(tagName, className, parseTrailingTagComments(start, getNodePos(), margin, indentText)), start); } function parseAugmentsTag(start, tagName, margin, indentText) { var className = parseExpressionWithTypeArgumentsForAugments(); - var end = getNodePos(); - return finishNode(factory.createJSDocAugmentsTag(tagName, className, parseTrailingTagComments(start, end, margin, indentText)), start, end); + return finishNode(factory.createJSDocAugmentsTag(tagName, className, parseTrailingTagComments(start, getNodePos(), margin, indentText)), start); } function parseExpressionWithTypeArgumentsForAugments() { var usedBrace = parseOptional(18 /* OpenBraceToken */); @@ -34790,20 +36099,17 @@ var ts; return node; } function parseSimpleTag(start, createTag, tagName, margin, indentText) { - var end = getNodePos(); - return finishNode(createTag(tagName, parseTrailingTagComments(start, end, margin, indentText)), start, end); + return finishNode(createTag(tagName, parseTrailingTagComments(start, getNodePos(), margin, indentText)), start); } function parseThisTag(start, tagName, margin, indentText) { var typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); - var end = getNodePos(); - return finishNode(factory.createJSDocThisTag(tagName, typeExpression, parseTrailingTagComments(start, end, margin, indentText)), start, end); + return finishNode(factory.createJSDocThisTag(tagName, typeExpression, parseTrailingTagComments(start, getNodePos(), margin, indentText)), start); } function parseEnumTag(start, tagName, margin, indentText) { var typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); - var end = getNodePos(); - return finishNode(factory.createJSDocEnumTag(tagName, typeExpression, parseTrailingTagComments(start, end, margin, indentText)), start, end); + return finishNode(factory.createJSDocEnumTag(tagName, typeExpression, parseTrailingTagComments(start, getNodePos(), margin, indentText)), start); } function parseTypedefTag(start, tagName, indent, indentText) { var _a; @@ -34820,7 +36126,7 @@ var ts; var hasChildren = false; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { hasChildren = true; - if (child.kind === 329 /* JSDocTypeTag */) { + if (child.kind === 337 /* JSDocTypeTag */) { if (childTypeTag) { parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags); var lastError = ts.lastOrUndefined(parseDiagnostics); @@ -34838,7 +36144,7 @@ var ts; } } if (hasChildren) { - var isArrayType = typeExpression && typeExpression.type.kind === 178 /* ArrayType */; + var isArrayType = typeExpression && typeExpression.type.kind === 180 /* ArrayType */; var jsdocTypeLiteral = factory.createJSDocTypeLiteral(jsDocPropertyTags, isArrayType); typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? childTypeTag.typeExpression : @@ -34891,17 +36197,16 @@ var ts; var returnTag = tryParse(function () { if (parseOptionalJsdoc(59 /* AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 327 /* JSDocReturnTag */) { + if (tag && tag.kind === 335 /* JSDocReturnTag */) { return tag; } } }); var typeExpression = finishNode(factory.createJSDocSignature(/*typeParameters*/ undefined, parameters, returnTag), start); - var end = getNodePos(); if (!comment) { - comment = parseTrailingTagComments(start, end, indent, indentText); + comment = parseTrailingTagComments(start, getNodePos(), indent, indentText); } - return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start, end); + return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start); } function escapedTextsEqual(a, b) { while (!ts.isIdentifier(a) || !ts.isIdentifier(b)) { @@ -34926,7 +36231,7 @@ var ts; case 59 /* AtToken */: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 326 /* JSDocParameterTag */ || child.kind === 333 /* JSDocPropertyTag */) && + if (child && (child.kind === 334 /* JSDocParameterTag */ || child.kind === 341 /* JSDocPropertyTag */) && target !== 4 /* CallbackParameter */ && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; @@ -34945,7 +36250,7 @@ var ts; } seenAsterisk = true; break; - case 78 /* Identifier */: + case 79 /* Identifier */: canParseTag = false; break; case 1 /* EndOfFileToken */: @@ -34983,6 +36288,9 @@ var ts; function parseTemplateTagTypeParameter() { var typeParameterPos = getNodePos(); var name = parseJSDocIdentifierName(ts.Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces); + if (ts.nodeIsMissing(name)) { + return undefined; + } return finishNode(factory.createTypeParameterDeclaration(name, /*constraint*/ undefined, /*defaultType*/ undefined), typeParameterPos); } function parseTemplateTagTypeParameters() { @@ -34990,7 +36298,10 @@ var ts; var typeParameters = []; do { skipWhitespace(); - typeParameters.push(parseTemplateTagTypeParameter()); + var node = parseTemplateTagTypeParameter(); + if (node !== undefined) { + typeParameters.push(node); + } skipWhitespaceOrAsterisk(); } while (parseOptionalJsdoc(27 /* CommaToken */)); return createNodeArray(typeParameters, pos); @@ -35009,8 +36320,7 @@ var ts; // TODO: Consider only parsing a single type parameter if there is a constraint. var constraint = token() === 18 /* OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; var typeParameters = parseTemplateTagTypeParameters(); - var end = getNodePos(); - return finishNode(factory.createJSDocTemplateTag(tagName, constraint, typeParameters, parseTrailingTagComments(start, end, indent, indentText)), start, end); + return finishNode(factory.createJSDocTemplateTag(tagName, constraint, typeParameters, parseTrailingTagComments(start, getNodePos(), indent, indentText)), start); } function parseOptionalJsdoc(t) { if (token() === t) { @@ -35038,7 +36348,7 @@ var ts; } function parseJSDocIdentifierName(message) { if (!ts.tokenIsIdentifierOrKeyword(token())) { - return createMissingNode(78 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); + return createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); } identifierCount++; var pos = scanner.getTokenPos(); @@ -35211,7 +36521,7 @@ var ts; switch (node.kind) { case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - case 78 /* Identifier */: + case 79 /* Identifier */: return true; } return false; @@ -35685,7 +36995,7 @@ var ts; if (namedArgRegExCache.has(name)) { return namedArgRegExCache.get(name); } - var result = new RegExp("(\\s" + name + "\\s*=\\s*)('|\")(.+?)\\2", "im"); + var result = new RegExp("(\\s" + name + "\\s*=\\s*)(?:(?:'([^']*)')|(?:\"([^\"]*)\"))", "im"); namedArgRegExCache.set(name, result); return result; } @@ -35709,16 +37019,17 @@ var ts; return; // Missing required argument, don't parse } else if (matchResult) { + var value = matchResult[2] || matchResult[3]; if (arg.captureSpan) { - var startPos = range.pos + matchResult.index + matchResult[1].length + matchResult[2].length; + var startPos = range.pos + matchResult.index + matchResult[1].length + 1; argument[arg.name] = { - value: matchResult[3], + value: value, pos: startPos, - end: startPos + matchResult[3].length + end: startPos + value.length }; } else { - argument[arg.name] = matchResult[3]; + argument[arg.name] = value; } } } @@ -35734,7 +37045,7 @@ var ts; return addPragmaForMatch(pragmas, range, 2 /* SingleLine */, singleLine); } if (range.kind === 3 /* MultiLineCommentTrivia */) { - var multiLinePragmaRegEx = /\s*@(\S+)\s*(.*)\s*$/gim; // Defined inline since it uses the "g" flag, which keeps a persistent index (for iterating) + 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); @@ -35761,7 +37072,7 @@ var ts; return {}; if (!pragma.args) return {}; - var args = text.split(/\s+/); + var args = ts.trimString(text).split(/\s+/); var argMap = {}; for (var i = 0; i < pragma.args.length; i++) { var argument = pragma.args[i]; @@ -35780,10 +37091,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 78 /* Identifier */) { + if (lhs.kind === 79 /* Identifier */) { return lhs.escapedText === rhs.escapedText; } - if (lhs.kind === 107 /* ThisKeyword */) { + if (lhs.kind === 108 /* ThisKeyword */) { return true; } // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only @@ -35825,6 +37136,7 @@ var ts; ["es2018", "lib.es2018.d.ts"], ["es2019", "lib.es2019.d.ts"], ["es2020", "lib.es2020.d.ts"], + ["es2021", "lib.es2021.d.ts"], ["esnext", "lib.esnext.d.ts"], // Host only ["dom", "lib.dom.d.ts"], @@ -35864,14 +37176,17 @@ var ts; ["es2020.string", "lib.es2020.string.d.ts"], ["es2020.symbol.wellknown", "lib.es2020.symbol.wellknown.d.ts"], ["es2020.intl", "lib.es2020.intl.d.ts"], + ["es2021.promise", "lib.es2021.promise.d.ts"], + ["es2021.string", "lib.es2021.string.d.ts"], + ["es2021.weakref", "lib.es2021.weakref.d.ts"], ["esnext.array", "lib.es2019.array.d.ts"], ["esnext.symbol", "lib.es2019.symbol.d.ts"], ["esnext.asynciterable", "lib.es2018.asynciterable.d.ts"], ["esnext.intl", "lib.esnext.intl.d.ts"], ["esnext.bigint", "lib.es2020.bigint.d.ts"], - ["esnext.string", "lib.esnext.string.d.ts"], - ["esnext.promise", "lib.esnext.promise.d.ts"], - ["esnext.weakref", "lib.esnext.weakref.d.ts"] + ["esnext.string", "lib.es2021.string.d.ts"], + ["esnext.promise", "lib.es2021.promise.d.ts"], + ["esnext.weakref", "lib.es2021.weakref.d.ts"] ]; /** * An array of supported "lib" reference file names used to determine the order for inclusion @@ -35895,11 +37210,12 @@ var ts; fixedpollinginterval: ts.WatchFileKind.FixedPollingInterval, prioritypollinginterval: ts.WatchFileKind.PriorityPollingInterval, dynamicprioritypolling: ts.WatchFileKind.DynamicPriorityPolling, + fixedchunksizepolling: ts.WatchFileKind.FixedChunkSizePolling, usefsevents: ts.WatchFileKind.UseFsEvents, usefseventsonparentdirectory: ts.WatchFileKind.UseFsEventsOnParentDirectory, })), - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_DynamicPriorityPolling_UseFsEvents_UseFsEventsOnParentDirectory, + category: ts.Diagnostics.Watch_and_Build_Modes, + description: ts.Diagnostics.Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_DynamicPriorityPolling_FixedChunkSizePolling_UseFsEvents_UseFsEventsOnParentDirectory, }, { name: "watchDirectory", @@ -35907,9 +37223,10 @@ var ts; usefsevents: ts.WatchDirectoryKind.UseFsEvents, fixedpollinginterval: ts.WatchDirectoryKind.FixedPollingInterval, dynamicprioritypolling: ts.WatchDirectoryKind.DynamicPriorityPolling, + fixedchunksizepolling: ts.WatchDirectoryKind.FixedChunkSizePolling, })), - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling, + category: ts.Diagnostics.Watch_and_Build_Modes, + description: ts.Diagnostics.Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling_FixedChunkSizePolling, }, { name: "fallbackPolling", @@ -35917,14 +37234,15 @@ var ts; fixedinterval: ts.PollingWatchKind.FixedInterval, priorityinterval: ts.PollingWatchKind.PriorityInterval, dynamicpriority: ts.PollingWatchKind.DynamicPriority, + fixedchunksize: ts.PollingWatchKind.FixedChunkSize, })), - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority, + category: ts.Diagnostics.Watch_and_Build_Modes, + description: ts.Diagnostics.Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority_FixedChunkSize, }, { name: "synchronousWatchDirectory", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Watch_and_Build_Modes, description: ts.Diagnostics.Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively, }, { @@ -35936,7 +37254,7 @@ var ts; isFilePath: true, extraValidation: specToDiagnostic }, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Watch_and_Build_Modes, description: ts.Diagnostics.Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively, }, { @@ -35948,7 +37266,7 @@ var ts; isFilePath: true, extraValidation: specToDiagnostic }, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Watch_and_Build_Modes, description: ts.Diagnostics.Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively, }, ]; @@ -35972,6 +37290,7 @@ var ts; shortName: "w", type: "boolean", showInSimplifiedHelpView: true, + isCommandLineOnly: true, category: ts.Diagnostics.Command_line_Options, description: ts.Diagnostics.Watch_input_files, }, @@ -35979,49 +37298,50 @@ var ts; name: "preserveWatchOutput", type: "boolean", showInSimplifiedHelpView: false, - category: ts.Diagnostics.Command_line_Options, + category: ts.Diagnostics.Output_Formatting, description: ts.Diagnostics.Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen, }, { name: "listFiles", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Print_names_of_files_part_of_the_compilation }, { name: "explainFiles", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Print_names_of_files_and_the_reason_they_are_part_of_the_compilation - }, { + }, + { name: "listEmittedFiles", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Print_names_of_generated_files_part_of_the_compilation }, { name: "pretty", type: "boolean", showInSimplifiedHelpView: true, - category: ts.Diagnostics.Command_line_Options, + category: ts.Diagnostics.Output_Formatting, description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental }, { name: "traceResolution", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Enable_tracing_of_the_name_resolution_process }, { name: "diagnostics", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Show_diagnostic_information }, { name: "extendedDiagnostics", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Show_verbose_diagnostic_information }, { @@ -36029,7 +37349,7 @@ var ts; type: "string", isFilePath: true, paramType: ts.Diagnostics.FILE_OR_DIRECTORY, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Generates_a_CPU_profile }, { @@ -36038,14 +37358,14 @@ var ts; isFilePath: true, isCommandLineOnly: true, paramType: ts.Diagnostics.DIRECTORY, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Generates_an_event_trace_and_a_list_of_types }, { name: "incremental", shortName: "i", type: "boolean", - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Projects, description: ts.Diagnostics.Enable_incremental_compilation, transpileOptionValue: undefined }, @@ -36054,13 +37374,14 @@ var ts; type: "boolean", affectsSemanticDiagnostics: true, affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Watch_and_Build_Modes, description: ts.Diagnostics.Have_recompiles_in_incremental_and_watch_assume_that_changes_within_a_file_will_only_affect_files_directly_depending_on_it }, { name: "locale", type: "string", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Command_line_Options, + isCommandLineOnly: true, description: ts.Diagnostics.The_locale_used_when_displaying_messages_to_the_user_e_g_en_us }, ]; @@ -36078,6 +37399,7 @@ var ts; es2018: 5 /* ES2018 */, es2019: 6 /* ES2019 */, es2020: 7 /* ES2020 */, + es2021: 8 /* ES2021 */, esnext: 99 /* ESNext */, })), affectsSourceFile: true, @@ -36085,11 +37407,11 @@ var ts; affectsEmit: true, paramType: ts.Diagnostics.VERSION, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_or_ESNEXT, + category: ts.Diagnostics.Language_and_Environment, + description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_ES2021_or_ESNEXT, }; - /* @internal */ - ts.optionDeclarations = __spreadArray(__spreadArray([], ts.commonOptionsWithBuild), [ + var commandOptionsWithoutBuild = [ + // CommandLine only options { name: "all", type: "boolean", @@ -36166,7 +37488,7 @@ var ts; affectsEmit: true, paramType: ts.Diagnostics.KIND, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_es2020_or_ESNext, }, { @@ -36176,9 +37498,9 @@ var ts; name: "lib", type: ts.libMap }, - affectsModuleResolution: true, + affectsProgramStructure: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation, transpileOptionValue: undefined }, @@ -36187,13 +37509,13 @@ var ts; type: "boolean", affectsModuleResolution: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.JavaScript_Support, description: ts.Diagnostics.Allow_javascript_files_to_be_compiled }, { name: "checkJs", type: "boolean", - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.JavaScript_Support, description: ts.Diagnostics.Report_errors_in_js_files }, { @@ -36204,7 +37526,7 @@ var ts; affectsModuleResolution: true, paramType: ts.Diagnostics.KIND, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_react_react_jsx_or_react_jsxdev, }, { @@ -36213,7 +37535,7 @@ var ts; type: "boolean", affectsEmit: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Generates_corresponding_d_ts_file, transpileOptionValue: undefined }, @@ -36222,7 +37544,7 @@ var ts; type: "boolean", affectsEmit: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Generates_a_sourcemap_for_each_corresponding_d_ts_file, transpileOptionValue: undefined }, @@ -36230,7 +37552,7 @@ var ts; name: "emitDeclarationOnly", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Only_emit_d_ts_declaration_files, transpileOptionValue: undefined }, @@ -36239,7 +37561,7 @@ var ts; type: "boolean", affectsEmit: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Generates_corresponding_map_file, }, { @@ -36249,7 +37571,7 @@ var ts; isFilePath: true, paramType: ts.Diagnostics.FILE, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, transpileOptionValue: undefined }, @@ -36260,7 +37582,7 @@ var ts; isFilePath: true, paramType: ts.Diagnostics.DIRECTORY, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Redirect_output_structure_to_the_directory, }, { @@ -36269,7 +37591,7 @@ var ts; affectsEmit: true, isFilePath: true, paramType: ts.Diagnostics.LOCATION, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, }, { @@ -36277,7 +37599,7 @@ var ts; type: "boolean", affectsEmit: true, isTSConfigOnly: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Projects, description: ts.Diagnostics.Enable_project_compilation, transpileOptionValue: undefined }, @@ -36287,7 +37609,7 @@ var ts; affectsEmit: true, isFilePath: true, paramType: ts.Diagnostics.FILE, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Projects, description: ts.Diagnostics.Specify_file_to_store_incremental_compilation_information, transpileOptionValue: undefined }, @@ -36296,14 +37618,14 @@ var ts; type: "boolean", affectsEmit: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Do_not_emit_comments_to_output, }, { name: "noEmit", type: "boolean", showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Do_not_emit_outputs, transpileOptionValue: undefined }, @@ -36311,7 +37633,7 @@ var ts; name: "importHelpers", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Import_emit_helpers_from_tslib }, { @@ -36323,20 +37645,20 @@ var ts; })), affectsEmit: true, affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types }, { name: "downlevelIteration", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3 }, { name: "isolatedModules", type: "boolean", - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Interop_Constraints, description: ts.Diagnostics.Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule, transpileOptionValue: true }, @@ -36345,7 +37667,7 @@ var ts; name: "strict", type: "boolean", showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Enable_all_strict_type_checking_options }, { @@ -36354,7 +37676,7 @@ var ts; affectsSemanticDiagnostics: true, strictFlag: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type }, { @@ -36363,7 +37685,7 @@ var ts; affectsSemanticDiagnostics: true, strictFlag: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Enable_strict_null_checks }, { @@ -36372,7 +37694,7 @@ var ts; affectsSemanticDiagnostics: true, strictFlag: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Enable_strict_checking_of_function_types }, { @@ -36380,7 +37702,7 @@ var ts; type: "boolean", strictFlag: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Enable_strict_bind_call_and_apply_methods_on_functions }, { @@ -36389,25 +37711,43 @@ var ts; affectsSemanticDiagnostics: true, strictFlag: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Enable_strict_checking_of_property_initialization_in_classes }, + { + name: "strictOptionalProperties", + type: "boolean", + affectsSemanticDiagnostics: true, + strictFlag: true, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Type_Checking, + description: ts.Diagnostics.Enable_strict_checking_of_optional_properties + }, { name: "noImplicitThis", type: "boolean", affectsSemanticDiagnostics: true, strictFlag: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, }, + { + name: "useUnknownInCatchVariables", + type: "boolean", + affectsSemanticDiagnostics: true, + strictFlag: true, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Type_Checking, + description: ts.Diagnostics.Type_catch_clause_variables_as_unknown_instead_of_any, + }, { name: "alwaysStrict", type: "boolean", affectsSourceFile: true, strictFlag: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file }, // Additional Checks @@ -36416,7 +37756,7 @@ var ts; type: "boolean", affectsSemanticDiagnostics: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Additional_Checks, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Report_errors_on_unused_locals, }, { @@ -36424,7 +37764,7 @@ var ts; type: "boolean", affectsSemanticDiagnostics: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Additional_Checks, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Report_errors_on_unused_parameters, }, { @@ -36432,7 +37772,7 @@ var ts; type: "boolean", affectsSemanticDiagnostics: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Additional_Checks, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value }, { @@ -36441,7 +37781,7 @@ var ts; affectsBindDiagnostics: true, affectsSemanticDiagnostics: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Additional_Checks, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement }, { @@ -36449,14 +37789,22 @@ var ts; type: "boolean", affectsSemanticDiagnostics: true, showInSimplifiedHelpView: false, - category: ts.Diagnostics.Additional_Checks, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Include_undefined_in_index_signature_results }, + { + name: "noImplicitOverride", + type: "boolean", + affectsSemanticDiagnostics: true, + showInSimplifiedHelpView: false, + category: ts.Diagnostics.Type_Checking, + description: ts.Diagnostics.Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier + }, { name: "noPropertyAccessFromIndexSignature", type: "boolean", showInSimplifiedHelpView: false, - category: ts.Diagnostics.Additional_Checks, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Require_undeclared_properties_from_index_signatures_to_use_element_accesses }, // Module Resolution @@ -36468,7 +37816,7 @@ var ts; })), affectsModuleResolution: true, paramType: ts.Diagnostics.STRATEGY, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, }, { @@ -36476,7 +37824,7 @@ var ts; type: "string", affectsModuleResolution: true, isFilePath: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Base_directory_to_resolve_non_absolute_module_names }, { @@ -36486,7 +37834,7 @@ var ts; type: "object", affectsModuleResolution: true, isTSConfigOnly: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl, transpileOptionValue: undefined }, @@ -36502,7 +37850,7 @@ var ts; isFilePath: true }, affectsModuleResolution: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime, transpileOptionValue: undefined }, @@ -36515,7 +37863,7 @@ var ts; isFilePath: true }, affectsModuleResolution: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.List_of_folders_to_include_type_definitions_from }, { @@ -36525,9 +37873,9 @@ var ts; name: "types", type: "string" }, - affectsModuleResolution: true, + affectsProgramStructure: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation, transpileOptionValue: undefined }, @@ -36535,7 +37883,7 @@ var ts; name: "allowSyntheticDefaultImports", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Interop_Constraints, description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking }, { @@ -36544,20 +37892,20 @@ var ts; affectsSemanticDiagnostics: true, affectsEmit: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Interop_Constraints, description: ts.Diagnostics.Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for_all_imports_Implies_allowSyntheticDefaultImports }, { name: "preserveSymlinks", type: "boolean", - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Interop_Constraints, description: ts.Diagnostics.Do_not_resolve_the_real_path_of_symlinks, }, { name: "allowUmdGlobalAccess", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Allow_accessing_UMD_globals_from_modules, }, // Source Maps @@ -36566,7 +37914,7 @@ var ts; type: "string", affectsEmit: true, paramType: ts.Diagnostics.LOCATION, - category: ts.Diagnostics.Source_Map_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, }, { @@ -36574,21 +37922,21 @@ var ts; type: "string", affectsEmit: true, paramType: ts.Diagnostics.LOCATION, - category: ts.Diagnostics.Source_Map_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, }, { name: "inlineSourceMap", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Source_Map_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file }, { name: "inlineSources", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Source_Map_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap_to_be_set }, // Experimental @@ -36596,7 +37944,7 @@ var ts; name: "experimentalDecorators", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Experimental_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators }, { @@ -36604,20 +37952,20 @@ var ts; type: "boolean", affectsSemanticDiagnostics: true, affectsEmit: true, - category: ts.Diagnostics.Experimental_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators }, // Advanced { name: "jsxFactory", type: "string", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h }, { name: "jsxFragmentFactory", type: "string", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Specify_the_JSX_fragment_factory_function_to_use_when_targeting_react_JSX_emit_with_jsxFactory_compiler_option_is_specified_e_g_Fragment }, { @@ -36626,14 +37974,14 @@ var ts; affectsSemanticDiagnostics: true, affectsEmit: true, affectsModuleResolution: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react }, { name: "resolveJsonModule", type: "boolean", affectsModuleResolution: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Include_modules_imported_with_json_extension }, { @@ -36642,7 +37990,7 @@ var ts; affectsEmit: true, isFilePath: false, // for correct behaviour, please use outFile - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Backwards_Compatibility, paramType: ts.Diagnostics.FILE, description: ts.Diagnostics.Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file, transpileOptionValue: undefined @@ -36651,26 +37999,26 @@ var ts; name: "reactNamespace", type: "string", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react_JSX_emit }, { name: "skipDefaultLibCheck", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Completeness, description: ts.Diagnostics.Deprecated_Use_skipLibCheck_instead_Skip_type_checking_of_default_library_declaration_files }, { name: "charset", type: "string", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Backwards_Compatibility, description: ts.Diagnostics.The_character_set_of_the_input_files }, { name: "emitBOM", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files }, { @@ -36681,21 +38029,21 @@ var ts; })), affectsEmit: true, paramType: ts.Diagnostics.NEWLINE, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, }, { name: "noErrorTruncation", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Output_Formatting, description: ts.Diagnostics.Do_not_truncate_error_messages }, { name: "noLib", type: "boolean", - affectsModuleResolution: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Language_and_Environment, + affectsProgramStructure: true, description: ts.Diagnostics.Do_not_include_the_default_library_file_lib_d_ts, // We are not returning a sourceFile for lib file when asked by the program, // so pass --noLib to avoid reporting a file not found error. @@ -36705,7 +38053,7 @@ var ts; name: "noResolve", type: "boolean", affectsModuleResolution: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files, // We are not doing a full typecheck, we are not resolving the whole context, // so pass --noResolve to avoid reporting missing file errors. @@ -36715,56 +38063,56 @@ var ts; name: "stripInternal", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation, }, { name: "disableSizeLimit", type: "boolean", - affectsSourceFile: true, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Disable_size_limitations_on_JavaScript_projects + affectsProgramStructure: true, + category: ts.Diagnostics.Editor_Support, + description: ts.Diagnostics.JavaScript_Support }, { name: "disableSourceOfProjectReferenceRedirect", type: "boolean", isTSConfigOnly: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Projects, description: ts.Diagnostics.Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects }, { name: "disableSolutionSearching", type: "boolean", isTSConfigOnly: true, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Disable_solution_searching_for_this_project + category: ts.Diagnostics.Projects, + description: ts.Diagnostics.Projects }, { name: "disableReferencedProjectLoad", type: "boolean", isTSConfigOnly: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Projects, description: ts.Diagnostics.Disable_loading_referenced_projects }, { name: "noImplicitUseStrict", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Backwards_Compatibility, description: ts.Diagnostics.Do_not_emit_use_strict_directives_in_module_output }, { name: "noEmitHelpers", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Do_not_generate_custom_helper_functions_like_extends_in_compiled_output }, { name: "noEmitOnError", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, transpileOptionValue: undefined }, @@ -36772,7 +38120,7 @@ var ts; name: "preserveConstEnums", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code }, { @@ -36781,14 +38129,14 @@ var ts; affectsEmit: true, isFilePath: true, paramType: ts.Diagnostics.DIRECTORY, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Output_directory_for_generated_declaration_files, transpileOptionValue: undefined }, { name: "skipLibCheck", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Completeness, description: ts.Diagnostics.Skip_type_checking_of_declaration_files, }, { @@ -36796,7 +38144,7 @@ var ts; type: "boolean", affectsBindDiagnostics: true, affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Do_not_report_errors_on_unused_labels }, { @@ -36804,42 +38152,42 @@ var ts; type: "boolean", affectsBindDiagnostics: true, affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Do_not_report_errors_on_unreachable_code }, { name: "suppressExcessPropertyErrors", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Backwards_Compatibility, description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals, }, { name: "suppressImplicitAnyIndexErrors", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Backwards_Compatibility, description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, }, { name: "forceConsistentCasingInFileNames", type: "boolean", affectsModuleResolution: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Interop_Constraints, description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file }, { name: "maxNodeModuleJsDepth", type: "number", affectsModuleResolution: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.JavaScript_Support, description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files }, { name: "noStrictGenericChecks", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Backwards_Compatibility, description: ts.Diagnostics.Disable_strict_checking_of_generic_signatures_in_function_types, }, { @@ -36847,13 +38195,13 @@ var ts; type: "boolean", affectsSemanticDiagnostics: true, affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Emit_class_fields_with_Define_instead_of_Set, }, { name: "keyofStringsOnly", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Backwards_Compatibility, description: ts.Diagnostics.Resolve_keyof_to_string_valued_property_names_only_no_numbers_or_symbols, }, { @@ -36865,9 +38213,12 @@ var ts; name: "plugin", type: "object" }, - description: ts.Diagnostics.List_of_language_service_plugins + description: ts.Diagnostics.List_of_language_service_plugins, + category: ts.Diagnostics.Editor_Support, }, - ]); + ]; + /* @internal */ + ts.optionDeclarations = __spreadArray(__spreadArray([], ts.commonOptionsWithBuild), commandOptionsWithoutBuild); /* @internal */ ts.semanticDiagnosticsOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsSemanticDiagnostics; }); /* @internal */ @@ -36879,11 +38230,12 @@ var ts; return !!option.affectsSourceFile || !!option.affectsModuleResolution || !!option.affectsBindDiagnostics; }); /* @internal */ + ts.optionsAffectingProgramStructure = ts.optionDeclarations.filter(function (option) { return !!option.affectsProgramStructure; }); + /* @internal */ ts.transpileOptionValueCompilerOptions = ts.optionDeclarations.filter(function (option) { return ts.hasProperty(option, "transpileOptionValue"); }); - /* @internal */ - ts.buildOpts = __spreadArray(__spreadArray([], ts.commonOptionsWithBuild), [ + var commandOptionsOnlyBuild = [ { name: "verbose", shortName: "v", @@ -36911,7 +38263,9 @@ var ts; description: ts.Diagnostics.Delete_the_outputs_of_all_projects, type: "boolean" } - ]); + ]; + /* @internal */ + ts.buildOpts = __spreadArray(__spreadArray([], ts.commonOptionsWithBuild), commandOptionsOnlyBuild); /* @internal */ ts.typeAcquisitionDeclarations = [ { @@ -36965,6 +38319,10 @@ var ts; return optionsNameMapCache || (optionsNameMapCache = createOptionNameMap(ts.optionDeclarations)); } ts.getOptionsNameMap = getOptionsNameMap; + var compilerOptionsAlternateMode = { + diagnostic: ts.Diagnostics.Compiler_option_0_may_only_be_used_with_build, + getOptionsNameMap: getBuildOptionsNameMap + }; /* @internal */ ts.defaultInitCompilerOptions = { module: ts.ModuleKind.CommonJS, @@ -36998,13 +38356,13 @@ var ts; } /* @internal */ function parseCustomTypeOption(opt, value, errors) { - return convertJsonOptionOfCustomType(opt, trimString(value || ""), errors); + return convertJsonOptionOfCustomType(opt, ts.trimString(value || ""), errors); } ts.parseCustomTypeOption = parseCustomTypeOption; /* @internal */ function parseListTypeOption(opt, value, errors) { if (value === void 0) { value = ""; } - value = trimString(value); + value = ts.trimString(value); if (ts.startsWith(value, "-")) { return undefined; } @@ -37026,6 +38384,10 @@ var ts; return option.name; } function createUnknownOptionError(unknownOption, diagnostics, createDiagnostics, unknownOptionErrorText) { + var _a; + if ((_a = diagnostics.alternateMode) === null || _a === void 0 ? void 0 : _a.getOptionsNameMap().optionsNameMap.has(unknownOption.toLowerCase())) { + return createDiagnostics(diagnostics.alternateMode.diagnostic, unknownOption); + } var possibleOption = ts.getSpellingSuggestion(unknownOption, diagnostics.optionDeclarations, getOptionName); return possibleOption ? createDiagnostics(diagnostics.unknownDidYouMeanDiagnostic, unknownOptionErrorText || unknownOption, possibleOption.name) : @@ -37180,6 +38542,7 @@ var ts; } /*@internal*/ ts.compilerOptionsDidYouMeanDiagnostics = { + alternateMode: compilerOptionsAlternateMode, getOptionsNameMap: getOptionsNameMap, optionDeclarations: ts.optionDeclarations, unknownOptionDiagnostic: ts.Diagnostics.Unknown_compiler_option_0, @@ -37212,7 +38575,12 @@ var ts; function getBuildOptionsNameMap() { return buildOptionsNameMapCache || (buildOptionsNameMapCache = createOptionNameMap(ts.buildOpts)); } + var buildOptionsAlternateMode = { + diagnostic: ts.Diagnostics.Compiler_option_0_may_not_be_used_with_build, + getOptionsNameMap: getOptionsNameMap + }; var buildOptionsDidYouMeanDiagnostics = { + alternateMode: buildOptionsAlternateMode, getOptionsNameMap: getBuildOptionsNameMap, optionDeclarations: ts.buildOpts, unknownOptionDiagnostic: ts.Diagnostics.Unknown_build_option_0, @@ -37288,7 +38656,7 @@ var ts; function parseConfigFileTextToJson(fileName, jsonText) { var jsonSourceFile = ts.parseJsonText(fileName, jsonText); return { - config: convertToObject(jsonSourceFile, jsonSourceFile.parseDiagnostics), + config: convertConfigFileToObject(jsonSourceFile, jsonSourceFile.parseDiagnostics, /*reportOptionsErrors*/ false, /*optionsIterator*/ undefined), error: jsonSourceFile.parseDiagnostics.length ? jsonSourceFile.parseDiagnostics[0] : undefined }; } @@ -37378,7 +38746,8 @@ var ts; }, { name: "extends", - type: "string" + type: "string", + category: ts.Diagnostics.File_Management, }, { name: "references", @@ -37386,7 +38755,8 @@ var ts; element: { name: "references", type: "object" - } + }, + category: ts.Diagnostics.Projects, }, { name: "files", @@ -37394,7 +38764,8 @@ var ts; element: { name: "files", type: "string" - } + }, + category: ts.Diagnostics.File_Management, }, { name: "include", @@ -37402,7 +38773,8 @@ var ts; element: { name: "include", type: "string" - } + }, + category: ts.Diagnostics.File_Management, }, { name: "exclude", @@ -37410,7 +38782,8 @@ var ts; element: { name: "exclude", type: "string" - } + }, + category: ts.Diagnostics.File_Management, }, ts.compileOnSaveCommandLineOption ]) @@ -37418,11 +38791,31 @@ var ts; } return _tsconfigRootOptions; } + function convertConfigFileToObject(sourceFile, errors, reportOptionsErrors, optionsIterator) { + 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 !== 202 /* 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 + // array is a well-formed configuration object, made into an array element by stray characters. + if (ts.isArrayLiteralExpression(rootExpression)) { + var firstObject = ts.find(rootExpression.elements, ts.isObjectLiteralExpression); + if (firstObject) { + return convertToObjectWorker(sourceFile, firstObject, errors, /*returnValue*/ true, knownRootOptions, optionsIterator); + } + } + return {}; + } + return convertToObjectWorker(sourceFile, rootExpression, errors, /*returnValue*/ true, knownRootOptions, optionsIterator); + } /** * Convert the json syntax tree into the json value */ function convertToObject(sourceFile, errors) { - return convertToObjectWorker(sourceFile, errors, /*returnValue*/ true, /*knownRootOptions*/ undefined, /*jsonConversionNotifier*/ undefined); + var _a; + return convertToObjectWorker(sourceFile, (_a = sourceFile.statements[0]) === null || _a === void 0 ? void 0 : _a.expression, errors, /*returnValue*/ true, /*knownRootOptions*/ undefined, /*jsonConversionNotifier*/ undefined); } ts.convertToObject = convertToObject; /** @@ -37431,18 +38824,18 @@ var ts; * Otherwise it just checks the errors and returns undefined */ /*@internal*/ - function convertToObjectWorker(sourceFile, errors, returnValue, knownRootOptions, jsonConversionNotifier) { - if (!sourceFile.statements.length) { + function convertToObjectWorker(sourceFile, rootExpression, errors, returnValue, knownRootOptions, jsonConversionNotifier) { + if (!rootExpression) { return returnValue ? {} : undefined; } - return convertPropertyValueToJson(sourceFile.statements[0].expression, knownRootOptions); + return convertPropertyValueToJson(rootExpression, knownRootOptions); function isRootOptionMap(knownOptions) { return knownRootOptions && knownRootOptions.elementOptions === knownOptions; } function convertObjectLiteralExpressionToJson(node, knownOptions, extraKeyDiagnostics, parentOption) { var result = returnValue ? {} : undefined; var _loop_4 = function (element) { - if (element.kind !== 288 /* PropertyAssignment */) { + if (element.kind !== 290 /* PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); return "continue"; } @@ -37509,13 +38902,13 @@ var ts; function convertPropertyValueToJson(valueExpression, option) { var invalidReported; switch (valueExpression.kind) { - case 109 /* TrueKeyword */: + case 110 /* TrueKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return validateValue(/*value*/ true); - case 94 /* FalseKeyword */: + case 95 /* FalseKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return validateValue(/*value*/ false); - case 103 /* NullKeyword */: + case 104 /* 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 */: @@ -37536,13 +38929,13 @@ var ts; case 8 /* NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return validateValue(Number(valueExpression.text)); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: if (valueExpression.operator !== 40 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { break; // not valid JSON syntax } reportInvalidOptionValue(option && option.type !== "number"); return validateValue(-Number(valueExpression.operand.text)); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -37559,7 +38952,7 @@ var ts; return validateValue(convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined)); } - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return validateValue(convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element)); } @@ -37697,7 +39090,7 @@ var ts; if (ts.hasProperty(options, name)) { // tsconfig only options cannot be specified via command line, // so we can assume that only types that can appear here string | number | boolean - if (optionsNameMap.has(name) && optionsNameMap.get(name).category === ts.Diagnostics.Command_line_Options) { + if (optionsNameMap.has(name) && (optionsNameMap.get(name).category === ts.Diagnostics.Command_line_Options || optionsNameMap.get(name).category === ts.Diagnostics.Output_Formatting)) { return "continue"; } var value = options[name]; @@ -37763,13 +39156,11 @@ var ts; function makePadding(paddingLength) { return Array(paddingLength + 1).join(" "); } - function isAllowedOption(_a) { - var category = _a.category, name = _a.name; - // Skip options which do not have a category or have category `Command_line_Options` - // Exclude all possible `Advanced_Options` in tsconfig.json which were NOT defined in command line - return category !== undefined - && category !== ts.Diagnostics.Command_line_Options - && (category !== ts.Diagnostics.Advanced_Options || compilerOptionsMap.has(name)); + function isAllowedOptionForOutput(_a) { + var category = _a.category, name = _a.name, isCommandLineOnly = _a.isCommandLineOnly; + // Skip options which do not have a category or have categories which are more niche + var categoriesToSkip = [ts.Diagnostics.Command_line_Options, ts.Diagnostics.Editor_Support, ts.Diagnostics.Compiler_Diagnostics, ts.Diagnostics.Backwards_Compatibility, ts.Diagnostics.Watch_and_Build_Modes, ts.Diagnostics.Output_Formatting]; + return !isCommandLineOnly && category !== undefined && (!categoriesToSkip.includes(category) || compilerOptionsMap.has(name)); } function writeConfigurations() { // Filter applicable options to place in the file @@ -37777,7 +39168,7 @@ var ts; for (var _i = 0, optionDeclarations_1 = ts.optionDeclarations; _i < optionDeclarations_1.length; _i++) { var option = optionDeclarations_1[_i]; var category = option.category; - if (isAllowedOption(option)) { + if (isAllowedOptionForOutput(option)) { categorizedOptions.add(ts.getLocaleSpecificMessage(category), option); } } @@ -37994,6 +39385,7 @@ var ts; validatedFilesSpec: ts.filter(filesSpecs, ts.isString), validatedIncludeSpecs: validatedIncludeSpecs, validatedExcludeSpecs: validatedExcludeSpecs, + pathPatterns: undefined, // Initialized on first use }; } function getFileNames(basePath) { @@ -38107,14 +39499,14 @@ var ts; if (ownConfig.extendedConfigPath) { // copy the resolution stack so it is never reused between branches in potential diamond-problem scenarios. resolutionStack = resolutionStack.concat([resolvedPath]); - var extendedConfig = getExtendedConfig(sourceFile, ownConfig.extendedConfigPath, host, basePath, resolutionStack, errors, extendedConfigCache); + var extendedConfig = getExtendedConfig(sourceFile, ownConfig.extendedConfigPath, host, resolutionStack, errors, extendedConfigCache); if (extendedConfig && isSuccessfulParsedTsconfig(extendedConfig)) { var baseRaw_1 = extendedConfig.raw; var raw_1 = ownConfig.raw; + var relativeDifference_1; var setPropertyInRawIfNotUndefined = function (propertyName) { - var value = raw_1[propertyName] || baseRaw_1[propertyName]; - if (value) { - raw_1[propertyName] = value; + if (!raw_1[propertyName] && baseRaw_1[propertyName]) { + raw_1[propertyName] = ts.map(baseRaw_1[propertyName], function (path) { return ts.isRootedDiskPath(path) ? path : ts.combinePaths(relativeDifference_1 || (relativeDifference_1 = ts.convertToRelativePath(ts.getDirectoryPath(ownConfig.extendedConfigPath), basePath, ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames))), path); }); } }; setPropertyInRawIfNotUndefined("include"); @@ -38196,7 +39588,7 @@ var ts; } } }; - var json = convertToObjectWorker(sourceFile, errors, /*returnValue*/ true, getTsconfigRootOptionsMap(), optionsIterator); + var json = convertConfigFileToObject(sourceFile, errors, /*reportOptionsErrors*/ true, optionsIterator); if (!typeAcquisition) { if (typingOptionstypeAcquisition) { typeAcquisition = (typingOptionstypeAcquisition.enableAutoDiscovery !== undefined) ? @@ -38234,7 +39626,7 @@ var ts; errors.push(createDiagnostic(ts.Diagnostics.File_0_not_found, extendedConfig)); return undefined; } - function getExtendedConfig(sourceFile, extendedConfigPath, host, basePath, resolutionStack, errors, extendedConfigCache) { + function getExtendedConfig(sourceFile, extendedConfigPath, host, resolutionStack, errors, extendedConfigCache) { var _a; var path = host.useCaseSensitiveFileNames ? extendedConfigPath : ts.toFileNameLowerCase(extendedConfigPath); var value; @@ -38246,22 +39638,7 @@ var ts; else { extendedResult = readJsonConfigFile(extendedConfigPath, function (path) { return host.readFile(path); }); if (!extendedResult.parseDiagnostics.length) { - var extendedDirname = ts.getDirectoryPath(extendedConfigPath); - extendedConfig = parseConfig(/*json*/ undefined, extendedResult, host, extendedDirname, ts.getBaseFileName(extendedConfigPath), resolutionStack, errors, extendedConfigCache); - if (isSuccessfulParsedTsconfig(extendedConfig)) { - // Update the paths to reflect base path - var relativeDifference_1 = ts.convertToRelativePath(extendedDirname, basePath, ts.identity); - var updatePath_1 = function (path) { return ts.isRootedDiskPath(path) ? path : ts.combinePaths(relativeDifference_1, path); }; - var mapPropertiesInRawIfNotUndefined = function (propertyName) { - if (raw_2[propertyName]) { - raw_2[propertyName] = ts.map(raw_2[propertyName], updatePath_1); - } - }; - var raw_2 = extendedConfig.raw; - mapPropertiesInRawIfNotUndefined("include"); - mapPropertiesInRawIfNotUndefined("exclude"); - mapPropertiesInRawIfNotUndefined("files"); - } + extendedConfig = parseConfig(/*json*/ undefined, extendedResult, host, ts.getDirectoryPath(extendedConfigPath), ts.getBaseFileName(extendedConfigPath), resolutionStack, errors, extendedConfigCache); } if (extendedConfigCache) { extendedConfigCache.set(path, { extendedResult: extendedResult, extendedConfig: extendedConfig }); @@ -38406,9 +39783,6 @@ var ts; function convertJsonOptionOfListType(option, values, basePath, errors) { return ts.filter(ts.map(values, function (v) { return convertJsonOption(option.element, v, basePath, errors); }), function (v) { return !!v; }); } - function trimString(s) { - return typeof s.trim === "function" ? s.trim() : s.replace(/^[\s]+|[\s]+$/g, ""); - } /** * Tests for a path that ends in a recursive directory wildcard. * Matches **, \**, **\, and \**\, but not a**b. @@ -38421,34 +39795,6 @@ var ts; * \/?$ # matches an optional trailing directory separator at the end of the string. */ var invalidTrailingRecursionPattern = /(^|\/)\*\*\/?$/; - /** - * Tests for a path where .. appears after a recursive directory wildcard. - * Matches **\..\*, **\a\..\*, and **\.., but not ..\**\* - * - * NOTE: used \ in place of / above to avoid issues with multiline comments. - * - * Breakdown: - * (^|\/) # matches either the beginning of the string or a directory separator. - * \*\*\/ # matches a recursive directory wildcard "**" followed by a directory separator. - * (.*\/)? # optionally matches any number of characters followed by a directory separator. - * \.\. # matches a parent directory path component ".." - * ($|\/) # matches either the end of the string or a directory separator. - */ - var invalidDotDotAfterRecursiveWildcardPattern = /(^|\/)\*\*\/(.*\/)?\.\.($|\/)/; - /** - * Tests for a path containing a wildcard character in a directory component of the path. - * Matches \*\, \?\, and \a*b\, but not \a\ or \a\*. - * - * NOTE: used \ in place of / above to avoid issues with multiline comments. - * - * Breakdown: - * \/ # matches a directory separator. - * [^/]*? # matches any number of characters excluding directory separators (non-greedy). - * [*?] # matches either a wildcard character (* or ?) - * [^/]* # matches any number of characters excluding directory separators (greedy). - * \/ # matches a directory separator. - */ - var watchRecursivePattern = /\/[^/]*?[*?][^/]*\//; /** * Matches the portion of a wildcard path that does not contain wildcards. * Matches \a of \a\*, or \a\b\c of \a\b\c\?\d. @@ -38489,7 +39835,7 @@ var ts; // via wildcard of *.json kind var wildCardJsonFileMap = new ts.Map(); var validatedFilesSpec = configFileSpecs.validatedFilesSpec, validatedIncludeSpecs = configFileSpecs.validatedIncludeSpecs, validatedExcludeSpecs = configFileSpecs.validatedExcludeSpecs; - // Rather than requery this for each file and filespec, we query the supported extensions + // Rather than re-query this for each file and filespec, we query the supported extensions // once and store it on the expansion context. var supportedExtensions = ts.getSupportedExtensions(options, extraFileExtensions); var supportedExtensionsWithJsonIfResolveJsonModule = ts.getSuppoertedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions); @@ -38567,9 +39913,22 @@ var ts; return matchesExcludeWorker(pathToCheck, validatedExcludeSpecs, useCaseSensitiveFileNames, currentDirectory, basePath); } ts.isExcludedFile = isExcludedFile; + function invalidDotDotAfterRecursiveWildcard(s) { + // We used to use the regex /(^|\/)\*\*\/(.*\/)?\.\.($|\/)/ to check for this case, but + // in v8, that has polynomial performance because the recursive wildcard match - **/ - + // can be matched in many arbitrary positions when multiple are present, resulting + // in bad backtracking (and we don't care which is matched - just that some /.. segment + // comes after some **/ segment). + var wildcardIndex = ts.startsWith(s, "**/") ? 0 : s.indexOf("/**/"); + if (wildcardIndex === -1) { + return false; + } + var lastDotIndex = ts.endsWith(s, "/..") ? s.length : s.lastIndexOf("/../"); + return lastDotIndex > wildcardIndex; + } /* @internal */ function matchesExclude(pathToCheck, excludeSpecs, useCaseSensitiveFileNames, currentDirectory) { - return matchesExcludeWorker(pathToCheck, ts.filter(excludeSpecs, function (spec) { return !invalidDotDotAfterRecursiveWildcardPattern.test(spec); }), useCaseSensitiveFileNames, currentDirectory); + return matchesExcludeWorker(pathToCheck, ts.filter(excludeSpecs, function (spec) { return !invalidDotDotAfterRecursiveWildcard(spec); }), useCaseSensitiveFileNames, currentDirectory); } ts.matchesExclude = matchesExclude; function matchesExcludeWorker(pathToCheck, excludeSpecs, useCaseSensitiveFileNames, currentDirectory, basePath) { @@ -38602,7 +39961,7 @@ var ts; if (disallowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) { return [ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec]; } - else if (invalidDotDotAfterRecursiveWildcardPattern.test(spec)) { + else if (invalidDotDotAfterRecursiveWildcard(spec)) { return [ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec]; } } @@ -38663,9 +40022,18 @@ var ts; function getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames) { var match = wildcardDirectoryPattern.exec(spec); if (match) { + // We check this with a few `indexOf` calls because 3 `indexOf`/`lastIndexOf` calls is + // less algorithmically complex (roughly O(3n) worst-case) than the regex we used to use, + // \/[^/]*?[*?][^/]*\/ which was polynominal in v8, since arbitrary sequences of wildcard + // characters could match any of the central patterns, resulting in bad backtracking. + var questionWildcardIndex = spec.indexOf("?"); + var starWildcardIndex = spec.indexOf("*"); + var lastDirectorySeperatorIndex = spec.lastIndexOf(ts.directorySeparator); return { key: useCaseSensitiveFileNames ? match[0] : ts.toFileNameLowerCase(match[0]), - flags: watchRecursivePattern.test(spec) ? 1 /* Recursive */ : 0 /* None */ + flags: (questionWildcardIndex !== -1 && questionWildcardIndex < lastDirectorySeperatorIndex) + || (starWildcardIndex !== -1 && starWildcardIndex < lastDirectorySeperatorIndex) + ? 1 /* Recursive */ : 0 /* None */ }; } if (ts.isImplicitGlob(spec)) { @@ -38958,13 +40326,24 @@ var ts; * This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups * is assumed to be the same as root directory of the project. */ - function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference) { + function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, cache) { var traceEnabled = isTraceEnabled(options, host); if (redirectedReference) { options = redirectedReference.commandLine.options; } - var failedLookupLocations = []; - var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations }; + var containingDirectory = containingFile ? ts.getDirectoryPath(containingFile) : undefined; + var perFolderCache = containingDirectory ? cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference) : undefined; + var result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName); + if (result) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1, typeReferenceDirectiveName, containingFile); + if (redirectedReference) + trace(host, ts.Diagnostics.Using_compiler_options_of_project_reference_redirect_0, redirectedReference.sourceFile.fileName); + trace(host, ts.Diagnostics.Resolution_for_type_reference_directive_0_was_found_in_cache_from_location_1, typeReferenceDirectiveName, containingDirectory); + traceResult(result); + } + return result; + } var typeRoots = getEffectiveTypeRoots(options, host); if (traceEnabled) { if (containingFile === undefined) { @@ -38987,6 +40366,8 @@ var ts; trace(host, ts.Diagnostics.Using_compiler_options_of_project_reference_redirect_0, redirectedReference.sourceFile.fileName); } } + var failedLookupLocations = []; + var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache }; var resolved = primaryLookup(); var primary = true; if (!resolved) { @@ -38997,17 +40378,31 @@ var ts; if (resolved) { var fileName = resolved.fileName, packageId = resolved.packageId; var resolvedFileName = options.preserveSymlinks ? fileName : realPath(fileName, host, traceEnabled); - if (traceEnabled) { - if (packageId) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3, typeReferenceDirectiveName, resolvedFileName, ts.packageIdToString(packageId), primary); - } - else { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFileName, primary); - } + resolvedTypeReferenceDirective = { + primary: primary, + resolvedFileName: resolvedFileName, + originalPath: fileName === resolvedFileName ? undefined : fileName, + packageId: packageId, + isExternalLibraryImport: pathContainsNodeModules(fileName), + }; + } + result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations }; + perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, result); + if (traceEnabled) + traceResult(result); + return result; + function traceResult(result) { + var _a; + if (!((_a = result.resolvedTypeReferenceDirective) === null || _a === void 0 ? void 0 : _a.resolvedFileName)) { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); + } + else if (result.resolvedTypeReferenceDirective.packageId) { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3, typeReferenceDirectiveName, result.resolvedTypeReferenceDirective.resolvedFileName, ts.packageIdToString(result.resolvedTypeReferenceDirective.packageId), result.resolvedTypeReferenceDirective.primary); + } + else { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, result.resolvedTypeReferenceDirective.resolvedFileName, result.resolvedTypeReferenceDirective.primary); } - resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolvedFileName, packageId: packageId, isExternalLibraryImport: pathContainsNodeModules(fileName) }; } - return { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations }; function primaryLookup() { // Check primary library paths if (typeRoots && typeRoots.length) { @@ -39037,20 +40432,16 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); } - var result = void 0; + var result_4; if (!ts.isExternalModuleNameRelative(typeReferenceDirectiveName)) { var searchResult = loadModuleFromNearestNodeModulesDirectory(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, moduleResolutionState, /*cache*/ undefined, /*redirectedReference*/ undefined); - result = searchResult && searchResult.value; + result_4 = searchResult && searchResult.value; } else { var candidate = ts.normalizePathAndParts(ts.combinePaths(initialLocationForSecondaryLookup, typeReferenceDirectiveName)).path; - result = nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, /*onlyRecordFailures*/ false, moduleResolutionState, /*considerPackageJson*/ true); + result_4 = nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, /*onlyRecordFailures*/ false, moduleResolutionState, /*considerPackageJson*/ true); } - var resolvedFile = resolvedTypeScriptOnly(result); - if (!resolvedFile && traceEnabled) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); - } - return resolvedFile; + return resolvedTypeScriptOnly(result_4); } else { if (traceEnabled) { @@ -39105,22 +40496,21 @@ var ts; return result; } ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; - function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options) { - return createModuleResolutionCacheWithMaps(createCacheWithRedirects(options), createCacheWithRedirects(options), currentDirectory, getCanonicalFileName); - } - ts.createModuleResolutionCache = createModuleResolutionCache; /*@internal*/ function createCacheWithRedirects(options) { var ownMap = new ts.Map(); var redirectsMap = new ts.Map(); return { - ownMap: ownMap, + getOwnMap: getOwnMap, redirectsMap: redirectsMap, getOrCreateMapOfCacheRedirects: getOrCreateMapOfCacheRedirects, clear: clear, setOwnOptions: setOwnOptions, setOwnMap: setOwnMap }; + function getOwnMap() { + return ownMap; + } function setOwnOptions(newOptions) { options = newOptions; } @@ -39146,26 +40536,88 @@ var ts; } } ts.createCacheWithRedirects = createCacheWithRedirects; - /*@internal*/ - function createModuleResolutionCacheWithMaps(directoryToModuleNameMap, moduleNameToDirectoryMap, currentDirectory, getCanonicalFileName) { - return { getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, directoryToModuleNameMap: directoryToModuleNameMap, moduleNameToDirectoryMap: moduleNameToDirectoryMap }; + function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName) { + var cache; + return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear }; + function getPackageJsonInfo(packageJsonPath) { + return cache === null || cache === void 0 ? void 0 : cache.get(ts.toPath(packageJsonPath, currentDirectory, getCanonicalFileName)); + } + function setPackageJsonInfo(packageJsonPath, info) { + (cache || (cache = new ts.Map())).set(ts.toPath(packageJsonPath, currentDirectory, getCanonicalFileName), info); + } + function clear() { + cache = undefined; + } + } + function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) { + var cache = cacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference); + var result = cache.get(key); + if (!result) { + result = create(); + cache.set(key, result); + } + return result; + } + function updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap) { + if (!options.configFile) + return; + if (directoryToModuleNameMap.redirectsMap.size === 0) { + // The own map will be for projectCompilerOptions + ts.Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.redirectsMap.size === 0); + ts.Debug.assert(directoryToModuleNameMap.getOwnMap().size === 0); + ts.Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.getOwnMap().size === 0); + directoryToModuleNameMap.redirectsMap.set(options.configFile.path, directoryToModuleNameMap.getOwnMap()); + moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.redirectsMap.set(options.configFile.path, moduleNameToDirectoryMap.getOwnMap()); + } + else { + // Set correct own map + ts.Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.redirectsMap.size > 0); + var ref = { + sourceFile: options.configFile, + commandLine: { options: options } + }; + directoryToModuleNameMap.setOwnMap(directoryToModuleNameMap.getOrCreateMapOfCacheRedirects(ref)); + moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.setOwnMap(moduleNameToDirectoryMap.getOrCreateMapOfCacheRedirects(ref)); + } + directoryToModuleNameMap.setOwnOptions(options); + moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.setOwnOptions(options); + } + function createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap) { + return { + getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, + clear: clear, + update: update, + }; + function clear() { + directoryToModuleNameMap.clear(); + } + function update(options) { + updateRedirectsMap(options, directoryToModuleNameMap); + } function getOrCreateCacheForDirectory(directoryName, redirectedReference) { var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName); return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, function () { return new ts.Map(); }); } + } + function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options, directoryToModuleNameMap, moduleNameToDirectoryMap) { + var preDirectoryResolutionCache = 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; } }); + function clear() { + preDirectoryResolutionCache.clear(); + moduleNameToDirectoryMap.clear(); + packageJsonInfoCache.clear(); + } + function update(options) { + updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap); + } function getOrCreateCacheForModuleName(nonRelativeModuleName, redirectedReference) { ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName)); return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, nonRelativeModuleName, createPerModuleNameCache); } - function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) { - var cache = cacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference); - var result = cache.get(key); - if (!result) { - result = create(); - cache.set(key, result); - } - return result; - } function createPerModuleNameCache() { var directoryPathMap = new ts.Map(); return { get: get, set: set }; @@ -39232,7 +40684,17 @@ var ts; } } } - ts.createModuleResolutionCacheWithMaps = createModuleResolutionCacheWithMaps; + ts.createModuleResolutionCache = createModuleResolutionCache; + function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache, directoryToModuleNameMap) { + var preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options))); + packageJsonInfoCache || (packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName)); + return __assign(__assign(__assign({}, packageJsonInfoCache), preDirectoryResolutionCache), { clear: clear }); + function clear() { + preDirectoryResolutionCache.clear(); + packageJsonInfoCache.clear(); + } + } + ts.createTypeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache; function resolveModuleNameFromCache(moduleName, containingFile, cache) { var containingDirectory = ts.getDirectoryPath(containingFile); var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); @@ -39381,7 +40843,8 @@ var ts; } } function tryLoadModuleUsingPathsIfEligible(extensions, moduleName, loader, state) { - var _a = state.compilerOptions, baseUrl = _a.baseUrl, paths = _a.paths; + var _a; + var _b = state.compilerOptions, baseUrl = _b.baseUrl, paths = _b.paths, configFile = _b.configFile; if (paths && !ts.pathIsRelative(moduleName)) { if (state.traceEnabled) { if (baseUrl) { @@ -39390,7 +40853,8 @@ var ts; trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); } var baseDirectory = ts.getPathsBasePath(state.compilerOptions, state.host); // Always defined when 'paths' is defined - return tryLoadModuleUsingPaths(extensions, moduleName, baseDirectory, paths, loader, /*onlyRecordFailures*/ false, state); + var pathPatterns = (configFile === null || configFile === void 0 ? void 0 : configFile.configFileSpecs) ? (_a = configFile.configFileSpecs).pathPatterns || (_a.pathPatterns = ts.tryParsePatterns(paths)) : undefined; + return tryLoadModuleUsingPaths(extensions, moduleName, baseDirectory, paths, pathPatterns, loader, /*onlyRecordFailures*/ false, state); } } function tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, state) { @@ -39510,7 +40974,7 @@ var ts; var _a, _b; var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations }; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache }; var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); }); return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, state.resultFromCache); function tryResolve(extensions) { @@ -39570,7 +41034,7 @@ var ts; } var resolvedFromFile = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state); if (resolvedFromFile) { - var packageDirectory = considerPackageJson ? parseNodeModuleFromPath(resolvedFromFile) : undefined; + var packageDirectory = considerPackageJson ? parseNodeModuleFromPath(resolvedFromFile.path) : undefined; var packageInfo = packageDirectory ? getPackageJsonInfo(packageDirectory, /*onlyRecordFailures*/ false, state) : undefined; return withPackageId(packageInfo, resolvedFromFile); } @@ -39603,8 +41067,9 @@ var ts; * For `/node_modules/@types/foo/bar/index.d.ts` this is packageDirectory: "@types/foo" * For `/node_modules/foo/bar/index.d.ts` this is packageDirectory: "foo" */ + /* @internal */ function parseNodeModuleFromPath(resolved) { - var path = ts.normalizePath(resolved.path); + var path = ts.normalizePath(resolved); var idx = path.lastIndexOf(ts.nodeModulesPathPart); if (idx === -1) { return undefined; @@ -39616,6 +41081,7 @@ var ts; } return path.slice(0, indexAfterPackageName); } + ts.parseNodeModuleFromPath = parseNodeModuleFromPath; function moveToNextDirectorySeparatorIfAvailable(path, prevSeparatorIndex) { var nextSeparatorIndex = path.indexOf(ts.directorySeparator, prevSeparatorIndex + 1); return nextSeparatorIndex === -1 ? prevSeparatorIndex : nextSeparatorIndex; @@ -39699,21 +41165,43 @@ var ts; return withPackageId(packageInfo, loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJsonContent, versionPaths)); } function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) { + var _a, _b, _c; var host = state.host, traceEnabled = state.traceEnabled; - var directoryExists = !onlyRecordFailures && ts.directoryProbablyExists(packageDirectory, host); var packageJsonPath = ts.combinePaths(packageDirectory, "package.json"); + if (onlyRecordFailures) { + state.failedLookupLocations.push(packageJsonPath); + return undefined; + } + var existing = (_a = state.packageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.getPackageJsonInfo(packageJsonPath); + if (existing !== undefined) { + if (typeof existing !== "boolean") { + if (traceEnabled) + trace(host, ts.Diagnostics.File_0_exists_according_to_earlier_cached_lookups, packageJsonPath); + return existing; + } + else { + if (existing && traceEnabled) + trace(host, ts.Diagnostics.File_0_does_not_exist_according_to_earlier_cached_lookups, packageJsonPath); + state.failedLookupLocations.push(packageJsonPath); + return undefined; + } + } + var directoryExists = ts.directoryProbablyExists(packageDirectory, host); if (directoryExists && host.fileExists(packageJsonPath)) { var packageJsonContent = ts.readJson(packageJsonPath, host); if (traceEnabled) { trace(host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); } var versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state); - return { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths }; + var result = { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths }; + (_b = state.packageJsonInfoCache) === null || _b === void 0 ? void 0 : _b.setPackageJsonInfo(packageJsonPath, result); + return result; } else { if (directoryExists && traceEnabled) { trace(host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); } + (_c = state.packageJsonInfoCache) === null || _c === void 0 ? void 0 : _c.setPackageJsonInfo(packageJsonPath, directoryExists); // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results state.failedLookupLocations.push(packageJsonPath); } @@ -39764,7 +41252,7 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2, versionPaths.version, ts.version, moduleName); } - var result = tryLoadModuleUsingPaths(extensions, moduleName, candidate, versionPaths.paths, loader, onlyRecordFailuresForPackageFile || onlyRecordFailuresForIndex, state); + var result = tryLoadModuleUsingPaths(extensions, moduleName, candidate, versionPaths.paths, /*pathPatterns*/ undefined, loader, onlyRecordFailuresForPackageFile || onlyRecordFailuresForIndex, state); if (result) { return removeIgnoredPackageId(result.value); } @@ -39871,7 +41359,7 @@ var ts; trace(state.host, ts.Diagnostics.package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2, packageInfo.versionPaths.version, ts.version, rest); } var packageDirectoryExists = nodeModulesDirectoryExists && ts.directoryProbablyExists(packageDirectory, state.host); - var fromPaths = tryLoadModuleUsingPaths(extensions, rest, packageDirectory, packageInfo.versionPaths.paths, loader, !packageDirectoryExists, state); + var fromPaths = tryLoadModuleUsingPaths(extensions, rest, packageDirectory, packageInfo.versionPaths.paths, /*pathPatterns*/ undefined, loader, !packageDirectoryExists, state); if (fromPaths) { return fromPaths.value; } @@ -39879,8 +41367,9 @@ var ts; } return loader(extensions, candidate, !nodeModulesDirectoryExists, state); } - function tryLoadModuleUsingPaths(extensions, moduleName, baseDirectory, paths, loader, onlyRecordFailures, state) { - var matchedPattern = ts.matchPatternOrExact(ts.getOwnKeys(paths), moduleName); + function tryLoadModuleUsingPaths(extensions, moduleName, baseDirectory, paths, pathPatterns, loader, onlyRecordFailures, state) { + pathPatterns || (pathPatterns = ts.tryParsePatterns(paths)); + var matchedPattern = ts.matchPatternOrExact(pathPatterns, moduleName); if (matchedPattern) { var matchedStar_1 = ts.isString(matchedPattern) ? undefined : ts.matchedText(matchedPattern, moduleName); var matchedPatternText = ts.isString(matchedPattern) ? matchedPattern : ts.patternText(matchedPattern); @@ -39962,7 +41451,7 @@ var ts; function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) { var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations }; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache }; var containingDirectory = ts.getDirectoryPath(containingFile); var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); // No originalPath because classic resolution doesn't resolve realPath @@ -40003,13 +41492,13 @@ var ts; * This is the minumum code needed to expose that functionality; the rest is in the host. */ /* @internal */ - function loadModuleFromGlobalCache(moduleName, projectName, compilerOptions, host, globalCache) { + function loadModuleFromGlobalCache(moduleName, projectName, compilerOptions, host, globalCache, packageJsonInfoCache) { var traceEnabled = isTraceEnabled(compilerOptions, host); if (traceEnabled) { trace(host, ts.Diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2, projectName, moduleName, globalCache); } var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations }; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: packageJsonInfoCache }; var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, /*typesScopeOnly*/ false); return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, state.resultFromCache); } @@ -40055,26 +41544,26 @@ var ts; // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: return 0 /* NonInstantiated */; // 2. const enum declarations - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: if (ts.isEnumConst(node)) { return 2 /* ConstEnumOnly */; } break; // 3. non-exported import declarations - case 261 /* ImportDeclaration */: - case 260 /* ImportEqualsDeclaration */: + case 263 /* ImportDeclaration */: + case 262 /* ImportEqualsDeclaration */: if (!(ts.hasSyntacticModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } break; // 4. Export alias declarations pointing at only uninstantiated modules or things uninstantiated modules contain - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: var exportDeclaration = node; - if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 268 /* NamedExports */) { + if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 270 /* NamedExports */) { var state = 0 /* NonInstantiated */; for (var _i = 0, _a = exportDeclaration.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; @@ -40090,7 +41579,7 @@ var ts; } break; // 5. other uninstantiated module declarations. - case 257 /* ModuleBlock */: { + case 259 /* ModuleBlock */: { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateCached(n, visited); @@ -40112,9 +41601,9 @@ var ts; }); return state_1; } - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return getModuleInstanceState(node, visited); - case 78 /* Identifier */: + case 79 /* Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should // be considered the same as type alias if (node.isInJSDocNamespace) { @@ -40184,14 +41673,14 @@ var ts; } var binder = createBinder(); function bindSourceFile(file, options) { - ts.tracing.push("bind" /* Bind */, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("bind" /* Bind */, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeBind"); ts.perfLogger.logStartBindFile("" + file.fileName); binder(file, options); ts.perfLogger.logStopBindFile(); ts.performance.mark("afterBind"); ts.performance.measure("Bind", "beforeBind", "afterBind"); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } ts.bindSourceFile = bindSourceFile; function createBinder() { @@ -40230,6 +41719,7 @@ var ts; var classifiableNames; var unreachableFlow = { flags: 1 /* Unreachable */ }; var reportedUnreachableFlow = { flags: 1 /* 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) * If so, the node _must_ be in the current file (as that's the only way anything could have traversed to it to yield it as the error node) @@ -40312,7 +41802,7 @@ var ts; // 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 === 266 /* ExportAssignment */) { + if (node.kind === 268 /* ExportAssignment */) { return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; } var name = ts.getNameOfDeclaration(node); @@ -40321,7 +41811,7 @@ var ts; var moduleName = ts.getTextOfIdentifierOrLiteral(name); return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); } - if (name.kind === 158 /* ComputedPropertyName */) { + if (name.kind === 160 /* ComputedPropertyName */) { var nameExpression = name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteralLike(nameExpression)) { @@ -40330,11 +41820,9 @@ var ts; if (ts.isSignedNumericLiteral(nameExpression)) { return ts.tokenToString(nameExpression.operator) + nameExpression.operand.text; } - ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); - return ts.getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); - } - if (ts.isWellKnownSymbolSyntactically(name)) { - return ts.getPropertyNameForKnownSymbolName(ts.idText(name.name)); + else { + ts.Debug.fail("Only computed properties with literal names have declaration names"); + } } if (ts.isPrivateIdentifier(name)) { // containingClass exists because private names only allowed inside classes @@ -40349,36 +41837,36 @@ var ts; return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 166 /* Constructor */: + case 168 /* Constructor */: return "__constructor" /* Constructor */; - case 174 /* FunctionType */: - case 169 /* CallSignature */: - case 313 /* JSDocSignature */: + case 176 /* FunctionType */: + case 171 /* CallSignature */: + case 317 /* JSDocSignature */: return "__call" /* Call */; - case 175 /* ConstructorType */: - case 170 /* ConstructSignature */: + case 177 /* ConstructorType */: + case 172 /* ConstructSignature */: return "__new" /* New */; - case 171 /* IndexSignature */: + case 173 /* IndexSignature */: return "__index" /* Index */; - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: return "__export" /* ExportStar */; - case 297 /* SourceFile */: + case 299 /* SourceFile */: // json file should behave as // module.exports = ... return "export=" /* ExportEquals */; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */) { // module.exports = ... return "export=" /* ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 308 /* JSDocFunctionType */: + case 311 /* JSDocFunctionType */: return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); - case 160 /* Parameter */: + case 162 /* 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 === 308 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); + ts.Debug.assert(node.parent.kind === 311 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); var functionType = node.parent; var index = functionType.parameters.indexOf(node); return "arg" + index; @@ -40478,7 +41966,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 === 266 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 268 /* ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; messageNeedsName_1 = false; multipleDefaultExports_1 = true; @@ -40517,7 +42005,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = !!(ts.getCombinedModifierFlags(node) & 1 /* Export */) || jsdocTreatAsExported(node); if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 270 /* ExportSpecifier */ || (node.kind === 260 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 272 /* ExportSpecifier */ || (node.kind === 262 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -40606,7 +42094,7 @@ var ts; // 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 !== 209 /* ArrowFunction */) { + if (node.kind !== 211 /* ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -40639,7 +42127,7 @@ var ts; } // We create a return control flow graph for IIFEs and constructors. For constructors // we use the return control flow graph in strict property initialization checks. - currentReturnTarget = isIIFE || node.kind === 166 /* Constructor */ || (ts.isInJSFile(node) && (node.kind === 251 /* FunctionDeclaration */ || node.kind === 208 /* FunctionExpression */)) ? createBranchLabel() : undefined; + currentReturnTarget = isIIFE || node.kind === 168 /* Constructor */ || (ts.isInJSFile(node) && (node.kind === 253 /* FunctionDeclaration */ || node.kind === 210 /* FunctionExpression */)) ? createBranchLabel() : undefined; currentExceptionTarget = undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; @@ -40654,13 +42142,14 @@ var ts; node.flags |= 512 /* HasExplicitReturn */; node.endFlowNode = currentFlow; } - if (node.kind === 297 /* SourceFile */) { + if (node.kind === 299 /* SourceFile */) { node.flags |= emitFlags; + node.endFlowNode = currentFlow; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 166 /* Constructor */ || (ts.isInJSFile(node) && (node.kind === 251 /* FunctionDeclaration */ || node.kind === 208 /* FunctionExpression */))) { + if (node.kind === 168 /* Constructor */ || (ts.isInJSFile(node) && (node.kind === 253 /* FunctionDeclaration */ || node.kind === 210 /* FunctionExpression */))) { node.returnFlowNode = currentFlow; } } @@ -40687,8 +42176,8 @@ var ts; blockScopeContainer = savedBlockScopeContainer; } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 251 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 251 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 253 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 253 /* FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -40711,59 +42200,59 @@ var ts; inAssignmentPattern = saveInAssignmentPattern; return; } - if (node.kind >= 232 /* FirstStatement */ && node.kind <= 248 /* LastStatement */ && !options.allowUnreachableCode) { + if (node.kind >= 234 /* FirstStatement */ && node.kind <= 250 /* LastStatement */ && !options.allowUnreachableCode) { node.flowNode = currentFlow; } switch (node.kind) { - case 236 /* WhileStatement */: + case 238 /* WhileStatement */: bindWhileStatement(node); break; - case 235 /* DoStatement */: + case 237 /* DoStatement */: bindDoStatement(node); break; - case 237 /* ForStatement */: + case 239 /* ForStatement */: bindForStatement(node); break; - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 234 /* IfStatement */: + case 236 /* IfStatement */: bindIfStatement(node); break; - case 242 /* ReturnStatement */: - case 246 /* ThrowStatement */: + case 244 /* ReturnStatement */: + case 248 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 241 /* BreakStatement */: - case 240 /* ContinueStatement */: + case 243 /* BreakStatement */: + case 242 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 247 /* TryStatement */: + case 249 /* TryStatement */: bindTryStatement(node); break; - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: bindSwitchStatement(node); break; - case 258 /* CaseBlock */: + case 260 /* CaseBlock */: bindCaseBlock(node); break; - case 284 /* CaseClause */: + case 286 /* CaseClause */: bindCaseClause(node); break; - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: bindExpressionStatement(node); break; - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: bindLabeledStatement(node); break; - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: if (ts.isDestructuringAssignment(node)) { // Carry over whether we are in an assignment pattern to // binary expressions that could actually be an initializer @@ -40773,47 +42262,47 @@ var ts; } bindBinaryExpressionFlow(node); break; - case 210 /* DeleteExpression */: + case 212 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: bindAccessExpressionFlow(node); break; - case 203 /* CallExpression */: + case 205 /* CallExpression */: bindCallExpressionFlow(node); break; - case 225 /* NonNullExpression */: + case 227 /* NonNullExpression */: bindNonNullExpressionFlow(node); break; - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 325 /* JSDocEnumTag */: + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + case 333 /* JSDocEnumTag */: bindJSDocTypeAlias(node); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 297 /* SourceFile */: { + case 299 /* SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; } - case 230 /* Block */: - case 257 /* ModuleBlock */: + case 232 /* Block */: + case 259 /* ModuleBlock */: bindEachFunctionsFirst(node.statements); break; - case 198 /* BindingElement */: + case 200 /* BindingElement */: bindBindingElementFlow(node); break; - case 200 /* ObjectLiteralExpression */: - case 199 /* ArrayLiteralExpression */: - case 288 /* PropertyAssignment */: - case 220 /* SpreadElement */: + case 202 /* ObjectLiteralExpression */: + case 201 /* ArrayLiteralExpression */: + case 290 /* PropertyAssignment */: + case 222 /* 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; @@ -40827,32 +42316,32 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 78 /* Identifier */: - case 79 /* PrivateIdentifier */: - case 107 /* ThisKeyword */: - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 79 /* Identifier */: + case 80 /* PrivateIdentifier */: + case 108 /* ThisKeyword */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: return containsNarrowableReference(expr); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return hasNarrowableArgument(expr); - case 207 /* ParenthesizedExpression */: - case 225 /* NonNullExpression */: + case 209 /* ParenthesizedExpression */: + case 227 /* NonNullExpression */: return isNarrowingExpression(expr.expression); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return expr.operator === 53 /* ExclamationToken */ && isNarrowingExpression(expr.operand); - case 211 /* TypeOfExpression */: + case 213 /* TypeOfExpression */: return isNarrowingExpression(expr.expression); } return false; } function isNarrowableReference(expr) { - return expr.kind === 78 /* Identifier */ || expr.kind === 79 /* PrivateIdentifier */ || expr.kind === 107 /* ThisKeyword */ || expr.kind === 105 /* SuperKeyword */ || - (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) || - ts.isBinaryExpression(expr) && expr.operatorToken.kind === 27 /* CommaToken */ && isNarrowableReference(expr.right) || - ts.isElementAccessExpression(expr) && ts.isStringOrNumericLiteralLike(expr.argumentExpression) && isNarrowableReference(expr.expression) || - ts.isAssignmentExpression(expr) && isNarrowableReference(expr.left); + 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.isElementAccessExpression(expr) && ts.isStringOrNumericLiteralLike(expr.argumentExpression) && isNarrowableReference(expr.expression) + || ts.isAssignmentExpression(expr) && isNarrowableReference(expr.left); } function containsNarrowableReference(expr) { return isNarrowableReference(expr) || ts.isOptionalChain(expr) && containsNarrowableReference(expr.expression); @@ -40866,7 +42355,7 @@ var ts; } } } - if (expr.expression.kind === 201 /* PropertyAccessExpression */ && + if (expr.expression.kind === 203 /* PropertyAccessExpression */ && containsNarrowableReference(expr.expression.expression)) { return true; } @@ -40880,10 +42369,10 @@ var ts; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 62 /* EqualsToken */: - case 74 /* BarBarEqualsToken */: - case 75 /* AmpersandAmpersandEqualsToken */: - case 76 /* QuestionQuestionEqualsToken */: + case 63 /* EqualsToken */: + case 75 /* BarBarEqualsToken */: + case 76 /* AmpersandAmpersandEqualsToken */: + case 77 /* QuestionQuestionEqualsToken */: return containsNarrowableReference(expr.left); case 34 /* EqualsEqualsToken */: case 35 /* ExclamationEqualsToken */: @@ -40891,9 +42380,9 @@ var ts; case 37 /* ExclamationEqualsEqualsToken */: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 101 /* InstanceOfKeyword */: + case 102 /* InstanceOfKeyword */: return isNarrowableOperand(expr.left); - case 100 /* InKeyword */: + case 101 /* InKeyword */: return isNarrowableInOperands(expr.left, expr.right); case 27 /* CommaToken */: return isNarrowingExpression(expr.right); @@ -40902,11 +42391,11 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: switch (expr.operatorToken.kind) { - case 62 /* EqualsToken */: + case 63 /* EqualsToken */: return isNarrowableOperand(expr.left); case 27 /* CommaToken */: return isNarrowableOperand(expr.right); @@ -40940,8 +42429,8 @@ var ts; if (!expression) { return flags & 32 /* TrueCondition */ ? antecedent : unreachableFlow; } - if ((expression.kind === 109 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || - expression.kind === 94 /* FalseKeyword */ && flags & 32 /* TrueCondition */) && + if ((expression.kind === 110 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || + expression.kind === 95 /* FalseKeyword */ && flags & 32 /* TrueCondition */) && !ts.isExpressionOfOptionalChainRoot(expression) && !ts.isNullishCoalesce(expression.parent)) { return unreachableFlow; } @@ -40980,26 +42469,26 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 234 /* IfStatement */: - case 236 /* WhileStatement */: - case 235 /* DoStatement */: + case 236 /* IfStatement */: + case 238 /* WhileStatement */: + case 237 /* DoStatement */: return parent.expression === node; - case 237 /* ForStatement */: - case 217 /* ConditionalExpression */: + case 239 /* ForStatement */: + case 219 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 207 /* ParenthesizedExpression */) { + if (node.kind === 209 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 214 /* PrefixUnaryExpression */ && node.operator === 53 /* ExclamationToken */) { + else if (node.kind === 216 /* PrefixUnaryExpression */ && node.operator === 53 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 216 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || + return node.kind === 218 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 56 /* BarBarToken */ || node.operatorToken.kind === 60 /* QuestionQuestionToken */); } @@ -41046,7 +42535,7 @@ var ts; } function setContinueTarget(node, target) { var label = activeLabelList; - while (label && node.parent.kind === 245 /* LabeledStatement */) { + while (label && node.parent.kind === 247 /* LabeledStatement */) { label.continueTarget = target; label = label.next; node = node.parent; @@ -41097,12 +42586,12 @@ var ts; bind(node.expression); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 239 /* ForOfStatement */) { + if (node.kind === 241 /* ForOfStatement */) { bind(node.awaitModifier); } addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 250 /* VariableDeclarationList */) { + if (node.initializer.kind !== 252 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -41124,7 +42613,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 242 /* ReturnStatement */) { + if (node.kind === 244 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -41141,7 +42630,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 241 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 243 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -41246,7 +42735,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 285 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 287 /* 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. @@ -41294,9 +42783,9 @@ var ts; function maybeBindExpressionFlowIfCall(node) { // A top level or LHS of 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 === 203 /* CallExpression */) { + if (node.kind === 205 /* CallExpression */) { var call = node; - if (ts.isDottedName(call.expression) && call.expression.kind !== 105 /* SuperKeyword */) { + if (call.expression.kind !== 106 /* SuperKeyword */ && ts.isDottedName(call.expression)) { currentFlow = createFlowCall(currentFlow, call); } } @@ -41320,7 +42809,7 @@ var ts; currentFlow = finishFlowLabel(postStatementLabel); } function bindDestructuringTargetFlow(node) { - if (node.kind === 216 /* BinaryExpression */ && node.operatorToken.kind === 62 /* EqualsToken */) { + if (node.kind === 218 /* BinaryExpression */ && node.operatorToken.kind === 63 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -41331,10 +42820,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowMutation(16 /* Assignment */, currentFlow, node); } - else if (node.kind === 199 /* ArrayLiteralExpression */) { + else if (node.kind === 201 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 220 /* SpreadElement */) { + if (e.kind === 222 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -41342,16 +42831,16 @@ var ts; } } } - else if (node.kind === 200 /* ObjectLiteralExpression */) { + else if (node.kind === 202 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 288 /* PropertyAssignment */) { + if (p.kind === 290 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 289 /* ShorthandPropertyAssignment */) { + else if (p.kind === 291 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 290 /* SpreadAssignment */) { + else if (p.kind === 292 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -41359,7 +42848,7 @@ var ts; } function bindLogicalLikeExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 75 /* AmpersandAmpersandEqualsToken */) { + if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 76 /* AmpersandAmpersandEqualsToken */) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -41416,128 +42905,102 @@ var ts; } bindAssignmentTargetFlow(node.left); } - var BindBinaryExpressionFlowState; - (function (BindBinaryExpressionFlowState) { - BindBinaryExpressionFlowState[BindBinaryExpressionFlowState["BindThenBindChildren"] = 0] = "BindThenBindChildren"; - BindBinaryExpressionFlowState[BindBinaryExpressionFlowState["MaybeBindLeft"] = 1] = "MaybeBindLeft"; - BindBinaryExpressionFlowState[BindBinaryExpressionFlowState["BindToken"] = 2] = "BindToken"; - BindBinaryExpressionFlowState[BindBinaryExpressionFlowState["BindRight"] = 3] = "BindRight"; - BindBinaryExpressionFlowState[BindBinaryExpressionFlowState["FinishBind"] = 4] = "FinishBind"; - })(BindBinaryExpressionFlowState || (BindBinaryExpressionFlowState = {})); - function bindBinaryExpressionFlow(node) { - var workStacks = { - expr: [node], - state: [1 /* MaybeBindLeft */], - inStrictMode: [undefined], - parent: [undefined], - }; - var stackIndex = 0; - while (stackIndex >= 0) { - node = workStacks.expr[stackIndex]; - switch (workStacks.state[stackIndex]) { - case 0 /* BindThenBindChildren */: { - // This state is used only when recuring, to emulate the work that `bind` does before - // reaching `bindChildren`. A normal call to `bindBinaryExpressionFlow` will already have done this work. - ts.setParent(node, parent); - var saveInStrictMode = inStrictMode; - bindWorker(node); - var saveParent = parent; - parent = node; - advanceState(1 /* MaybeBindLeft */, saveInStrictMode, saveParent); - break; - } - case 1 /* MaybeBindLeft */: { - var operator = node.operatorToken.kind; - // TODO: bindLogicalExpression is recursive - if we want to handle deeply nested `&&` expressions - // 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 - if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */ || - ts.isLogicalOrCoalescingAssignmentOperator(operator)) { - if (isTopLevelLogicalExpression(node)) { - var postExpressionLabel = createBranchLabel(); - bindLogicalLikeExpression(node, postExpressionLabel, postExpressionLabel); - currentFlow = finishFlowLabel(postExpressionLabel); - } - else { - bindLogicalLikeExpression(node, currentTrueTarget, currentFalseTarget); - } - completeNode(); - } - else { - advanceState(2 /* BindToken */); - maybeBind(node.left); - } - break; + function createBindBinaryExpressionFlow() { + return ts.createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, /*foldState*/ undefined); + function onEnter(node, state) { + if (state) { + state.stackIndex++; + // Emulate the work that `bind` does before reaching `bindChildren`. A normal call to + // `bindBinaryExpressionFlow` will already have done this work. + ts.setParent(node, parent); + var saveInStrictMode = inStrictMode; + bindWorker(node); + var saveParent = parent; + parent = node; + state.skip = false; + state.inStrictModeStack[state.stackIndex] = saveInStrictMode; + state.parentStack[state.stackIndex] = saveParent; + } + else { + state = { + stackIndex: 0, + skip: false, + inStrictModeStack: [undefined], + parentStack: [undefined] + }; + } + // TODO: bindLogicalExpression is recursive - if we want to handle deeply nested `&&` expressions + // 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 */ || + ts.isLogicalOrCoalescingAssignmentOperator(operator)) { + if (isTopLevelLogicalExpression(node)) { + var postExpressionLabel = createBranchLabel(); + bindLogicalLikeExpression(node, postExpressionLabel, postExpressionLabel); + currentFlow = finishFlowLabel(postExpressionLabel); } - case 2 /* BindToken */: { - if (node.operatorToken.kind === 27 /* CommaToken */) { - maybeBindExpressionFlowIfCall(node.left); - } - advanceState(3 /* BindRight */); - maybeBind(node.operatorToken); - break; + else { + bindLogicalLikeExpression(node, currentTrueTarget, currentFalseTarget); } - case 3 /* BindRight */: { - advanceState(4 /* FinishBind */); - maybeBind(node.right); - break; + state.skip = true; + } + return state; + } + function onLeft(left, state, _node) { + if (!state.skip) { + return maybeBind(left); + } + } + function onOperator(operatorToken, state, node) { + if (!state.skip) { + if (operatorToken.kind === 27 /* CommaToken */) { + maybeBindExpressionFlowIfCall(node.left); } - case 4 /* FinishBind */: { - var operator = node.operatorToken.kind; - if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { - bindAssignmentTargetFlow(node.left); - if (operator === 62 /* EqualsToken */ && node.left.kind === 202 /* ElementAccessExpression */) { - var elementAccess = node.left; - if (isNarrowableOperand(elementAccess.expression)) { - currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node); - } + bind(operatorToken); + } + } + function onRight(right, state, _node) { + if (!state.skip) { + return maybeBind(right); + } + } + function onExit(node, state) { + if (!state.skip) { + var operator = node.operatorToken.kind; + if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { + bindAssignmentTargetFlow(node.left); + if (operator === 63 /* EqualsToken */ && node.left.kind === 204 /* ElementAccessExpression */) { + var elementAccess = node.left; + if (isNarrowableOperand(elementAccess.expression)) { + currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node); } } - completeNode(); - break; } - default: return ts.Debug.fail("Invalid state " + workStacks.state[stackIndex] + " for bindBinaryExpressionFlow"); } - } - /** - * Note that `advanceState` sets the _current_ head state, and that `maybeBind` potentially pushes on a new - * head state; so `advanceState` must be called before any `maybeBind` during a state's execution. - */ - function advanceState(state, isInStrictMode, parent) { - workStacks.state[stackIndex] = state; - if (isInStrictMode !== undefined) { - workStacks.inStrictMode[stackIndex] = isInStrictMode; + var savedInStrictMode = state.inStrictModeStack[state.stackIndex]; + var savedParent = state.parentStack[state.stackIndex]; + if (savedInStrictMode !== undefined) { + inStrictMode = savedInStrictMode; } - if (parent !== undefined) { - workStacks.parent[stackIndex] = parent; + if (savedParent !== undefined) { + parent = savedParent; } + state.skip = false; + state.stackIndex--; } - function completeNode() { - if (workStacks.inStrictMode[stackIndex] !== undefined) { - inStrictMode = workStacks.inStrictMode[stackIndex]; - parent = workStacks.parent[stackIndex]; - } - stackIndex--; - } - /** - * If `node` is a BinaryExpression, adds it to the local work stack, otherwise recursively binds it - */ function maybeBind(node) { if (node && ts.isBinaryExpression(node) && !ts.isDestructuringAssignment(node)) { - stackIndex++; - workStacks.expr[stackIndex] = node; - workStacks.state[stackIndex] = 0 /* BindThenBindChildren */; - workStacks.inStrictMode[stackIndex] = undefined; - workStacks.parent[stackIndex] = undefined; - } - else { - bind(node); + return node; } + bind(node); } } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 201 /* PropertyAccessExpression */) { + if (node.expression.kind === 203 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -41594,7 +43057,7 @@ var ts; } function bindJSDocTypeAlias(node) { ts.setParent(node.tagName, node); - if (node.kind !== 325 /* JSDocEnumTag */ && node.fullName) { + if (node.kind !== 333 /* JSDocEnumTag */ && node.fullName) { ts.setParent(node.fullName, node); ts.setParentRecursive(node.fullName, /*incremental*/ false); } @@ -41602,7 +43065,7 @@ var ts; function bindJSDocClassTag(node) { bindEachChild(node); var host = ts.getHostSignatureFromJSDoc(node); - if (host && host.kind !== 165 /* MethodDeclaration */) { + if (host && host.kind !== 167 /* MethodDeclaration */) { addDeclarationToSymbol(host.symbol, host, 32 /* Class */); } } @@ -41615,15 +43078,15 @@ var ts; } function bindOptionalChainRest(node) { switch (node.kind) { - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: bind(node.questionDotToken); bind(node.name); break; - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: bind(node.questionDotToken); bind(node.argumentExpression); break; - case 203 /* CallExpression */: + case 205 /* CallExpression */: bind(node.questionDotToken); bindEach(node.typeArguments); bindEach(node.arguments); @@ -41688,19 +43151,19 @@ 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 === 208 /* FunctionExpression */ || expr.kind === 209 /* ArrowFunction */) { + if (expr.kind === 210 /* FunctionExpression */ || expr.kind === 211 /* ArrowFunction */) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); } else { bindEachChild(node); - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { currentFlow = createFlowCall(currentFlow, node); } } } - if (node.expression.kind === 201 /* PropertyAccessExpression */) { + if (node.expression.kind === 203 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (ts.isIdentifier(propertyAccess.name) && isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node); @@ -41709,54 +43172,54 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 221 /* ClassExpression */: - case 252 /* ClassDeclaration */: - case 255 /* EnumDeclaration */: - case 200 /* ObjectLiteralExpression */: - case 177 /* TypeLiteral */: - case 312 /* JSDocTypeLiteral */: - case 281 /* JsxAttributes */: + case 223 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 257 /* EnumDeclaration */: + case 202 /* ObjectLiteralExpression */: + case 179 /* TypeLiteral */: + case 316 /* JSDocTypeLiteral */: + case 283 /* JsxAttributes */: return 1 /* IsContainer */; - case 253 /* InterfaceDeclaration */: + case 255 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 256 /* ModuleDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 190 /* MappedType */: + case 258 /* ModuleDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 192 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 297 /* SourceFile */: + case 299 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } // falls through - case 166 /* Constructor */: - case 251 /* FunctionDeclaration */: - case 164 /* MethodSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 169 /* CallSignature */: - case 313 /* JSDocSignature */: - case 308 /* JSDocFunctionType */: - case 174 /* FunctionType */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: - case 175 /* ConstructorType */: + case 168 /* Constructor */: + case 253 /* FunctionDeclaration */: + case 166 /* MethodSignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 171 /* CallSignature */: + case 317 /* JSDocSignature */: + case 311 /* JSDocFunctionType */: + case 176 /* FunctionType */: + case 172 /* ConstructSignature */: + case 173 /* IndexSignature */: + case 177 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 257 /* ModuleBlock */: + case 259 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 287 /* CatchClause */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 258 /* CaseBlock */: + case 289 /* CatchClause */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 260 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 230 /* Block */: + case 232 /* 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 @@ -41789,45 +43252,45 @@ 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 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 297 /* SourceFile */: + case 299 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 221 /* ClassExpression */: - case 252 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 254 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 177 /* TypeLiteral */: - case 312 /* JSDocTypeLiteral */: - case 200 /* ObjectLiteralExpression */: - case 253 /* InterfaceDeclaration */: - case 281 /* JsxAttributes */: + case 179 /* TypeLiteral */: + case 316 /* JSDocTypeLiteral */: + case 202 /* ObjectLiteralExpression */: + case 255 /* InterfaceDeclaration */: + case 283 /* 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 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 313 /* JSDocSignature */: - case 171 /* IndexSignature */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 308 /* JSDocFunctionType */: - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 254 /* TypeAliasDeclaration */: - case 190 /* MappedType */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 317 /* JSDocSignature */: + case 173 /* IndexSignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 311 /* JSDocFunctionType */: + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + case 256 /* TypeAliasDeclaration */: + case 192 /* 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 @@ -41874,15 +43337,13 @@ var ts; var pattern = void 0; if (node.name.kind === 10 /* StringLiteral */) { var text = node.name.text; - if (ts.hasZeroOrOneAsteriskCharacter(text)) { - pattern = ts.tryParsePattern(text); - } - else { + 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 */); - file.patternAmbientModules = ts.append(file.patternAmbientModules, pattern && { pattern: pattern, symbol: symbol }); + file.patternAmbientModules = ts.append(file.patternAmbientModules, pattern && !ts.isString(pattern) ? { pattern: pattern, symbol: symbol } : undefined); } } else { @@ -41928,7 +43389,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 === 290 /* SpreadAssignment */ || prop.name.kind !== 78 /* Identifier */) { + if (prop.kind === 292 /* SpreadAssignment */ || prop.name.kind !== 79 /* Identifier */) { continue; } var identifier = prop.name; @@ -41940,7 +43401,7 @@ var ts; // 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 === 288 /* PropertyAssignment */ || prop.kind === 289 /* ShorthandPropertyAssignment */ || prop.kind === 165 /* MethodDeclaration */ + var currentKind = prop.kind === 290 /* PropertyAssignment */ || prop.kind === 291 /* ShorthandPropertyAssignment */ || prop.kind === 167 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.escapedText); @@ -41972,10 +43433,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 297 /* SourceFile */: + case 299 /* SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -42000,9 +43461,9 @@ var ts; var saveCurrentFlow = currentFlow; for (var _i = 0, delayedTypeAliases_1 = delayedTypeAliases; _i < delayedTypeAliases_1.length; _i++) { var typeAlias = delayedTypeAliases_1[_i]; - var host = ts.getJSDocHost(typeAlias); - container = (host && ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1 /* IsContainer */); })) || file; - blockScopeContainer = (host && ts.getEnclosingBlockScopeContainer(host)) || file; + var host = typeAlias.parent.parent; + container = ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1 /* IsContainer */); }) || file; + blockScopeContainer = ts.getEnclosingBlockScopeContainer(host) || file; currentFlow = initFlowNode({ flags: 2 /* Start */ }); parent = typeAlias; bind(typeAlias.typeExpression); @@ -42043,7 +43504,7 @@ var ts; container = oldContainer; } } - else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 78 /* Identifier */) { + else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 79 /* Identifier */) { parent = typeAlias.parent; bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); } @@ -42068,11 +43529,11 @@ var ts; !ts.isIdentifierName(node)) { // strict mode identifiers if (inStrictMode && - node.originalKeywordKind >= 116 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 124 /* LastFutureReservedWord */) { + node.originalKeywordKind >= 117 /* FirstFutureReservedWord */ && + node.originalKeywordKind <= 125 /* LastFutureReservedWord */) { file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); } - else if (node.originalKeywordKind === 130 /* AwaitKeyword */) { + else if (node.originalKeywordKind === 131 /* 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))); } @@ -42080,7 +43541,7 @@ var ts; 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 === 124 /* YieldKeyword */ && node.flags & 8192 /* YieldContext */) { + else if (node.originalKeywordKind === 125 /* YieldKeyword */ && node.flags & 8192 /* YieldContext */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node))); } } @@ -42122,7 +43583,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 78 /* Identifier */) { + if (inStrictMode && node.expression.kind === 79 /* 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); @@ -42133,7 +43594,7 @@ var ts; return ts.isIdentifier(node) && (node.escapedText === "eval" || node.escapedText === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 78 /* Identifier */) { + if (name && name.kind === 79 /* 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 @@ -42174,8 +43635,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 297 /* SourceFile */ && - blockScopeContainer.kind !== 256 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 299 /* SourceFile */ && + blockScopeContainer.kind !== 258 /* ModuleDeclaration */ && !ts.isFunctionLike(blockScopeContainer)) { // We check first if the name is inside class declaration or class expression; if so give explicit message // otherwise report generic error message. @@ -42270,7 +43731,7 @@ 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 > 156 /* LastToken */) { + if (node.kind > 158 /* LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -42332,7 +43793,7 @@ var ts; function bindWorker(node) { switch (node.kind) { /* Strict mode checks */ - case 78 /* Identifier */: + case 79 /* 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. @@ -42345,18 +43806,24 @@ var ts; break; } // falls through - case 107 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 289 /* ShorthandPropertyAssignment */)) { + case 108 /* ThisKeyword */: + if (currentFlow && (ts.isExpression(node) || parent.kind === 291 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkContextualIdentifier(node); - case 105 /* SuperKeyword */: + case 159 /* QualifiedName */: + if (currentFlow && ts.isPartOfTypeQuery(node)) { + node.flowNode = currentFlow; + } + break; + case 228 /* MetaProperty */: + case 106 /* SuperKeyword */: node.flowNode = currentFlow; break; - case 79 /* PrivateIdentifier */: + case 80 /* PrivateIdentifier */: return checkPrivateIdentifier(node); - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: var expr = node; if (currentFlow && isNarrowableReference(expr)) { expr.flowNode = currentFlow; @@ -42371,7 +43838,7 @@ var ts; declareSymbol(file.locals, /*parent*/ undefined, expr.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 111550 /* FunctionScopedVariableExcludes */); } break; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: var specialKind = ts.getAssignmentDeclarationKind(node); switch (specialKind) { case 1 /* ExportsProperty */: @@ -42407,78 +43874,78 @@ var ts; ts.Debug.fail("Unknown binary expression special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return checkStrictModeCatchClause(node); - case 210 /* DeleteExpression */: + case 212 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 243 /* WithStatement */: + case 245 /* WithStatement */: return checkStrictModeWithStatement(node); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return checkStrictModeLabeledStatement(node); - case 187 /* ThisType */: + case 189 /* ThisType */: seenThisKeyword = true; return; - case 172 /* TypePredicate */: + case 174 /* TypePredicate */: break; // Binding the children will handle everything - case 159 /* TypeParameter */: + case 161 /* TypeParameter */: return bindTypeParameter(node); - case 160 /* Parameter */: + case 162 /* Parameter */: return bindParameter(node); - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 198 /* BindingElement */: + case 200 /* BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: return bindPropertyWorker(node); - case 288 /* PropertyAssignment */: - case 289 /* ShorthandPropertyAssignment */: + case 290 /* PropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 291 /* EnumMember */: + case 293 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 173 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 167 /* MethodDeclaration */: + case 166 /* 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 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return bindFunctionDeclaration(node); - case 166 /* Constructor */: + case 168 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 167 /* GetAccessor */: + case 169 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 46015 /* GetAccessorExcludes */); - case 168 /* SetAccessor */: + case 170 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 78783 /* SetAccessorExcludes */); - case 174 /* FunctionType */: - case 308 /* JSDocFunctionType */: - case 313 /* JSDocSignature */: - case 175 /* ConstructorType */: + case 176 /* FunctionType */: + case 311 /* JSDocFunctionType */: + case 317 /* JSDocSignature */: + case 177 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 177 /* TypeLiteral */: - case 312 /* JSDocTypeLiteral */: - case 190 /* MappedType */: + case 179 /* TypeLiteral */: + case 316 /* JSDocTypeLiteral */: + case 192 /* MappedType */: return bindAnonymousTypeWorker(node); - case 319 /* JSDocClassTag */: + case 326 /* JSDocClassTag */: return bindJSDocClassTag(node); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return bindFunctionExpression(node); - case 203 /* CallExpression */: + case 205 /* CallExpression */: var assignmentKind = ts.getAssignmentDeclarationKind(node); switch (assignmentKind) { case 7 /* ObjectDefinePropertyValue */: @@ -42497,65 +43964,65 @@ var ts; } break; // Members of classes, interfaces, and modules - case 221 /* ClassExpression */: - case 252 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 254 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 253 /* InterfaceDeclaration */: + case 255 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 788872 /* InterfaceExcludes */); - case 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 281 /* JsxAttributes */: + case 283 /* JsxAttributes */: return bindJsxAttributes(node); - case 280 /* JsxAttribute */: + case 282 /* JsxAttribute */: return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); // Imports and exports - case 260 /* ImportEqualsDeclaration */: - case 263 /* NamespaceImport */: - case 265 /* ImportSpecifier */: - case 270 /* ExportSpecifier */: + case 262 /* ImportEqualsDeclaration */: + case 265 /* NamespaceImport */: + case 267 /* ImportSpecifier */: + case 272 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 259 /* NamespaceExportDeclaration */: + case 261 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 262 /* ImportClause */: + case 264 /* ImportClause */: return bindImportClause(node); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: return bindExportDeclaration(node); - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return bindExportAssignment(node); - case 297 /* SourceFile */: + case 299 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 230 /* Block */: + case 232 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // falls through - case 257 /* ModuleBlock */: + case 259 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 326 /* JSDocParameterTag */: - if (node.parent.kind === 313 /* JSDocSignature */) { + case 334 /* JSDocParameterTag */: + if (node.parent.kind === 317 /* JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 312 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 316 /* JSDocTypeLiteral */) { break; } // falls through - case 333 /* JSDocPropertyTag */: + case 341 /* JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 307 /* JSDocOptionalType */ ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 310 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 325 /* JSDocEnumTag */: + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + case 333 /* JSDocEnumTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -42583,8 +44050,8 @@ var ts; } function bindExportAssignment(node) { if (!container.symbol || !container.symbol.exports) { - // Export assignment in some sort of block construct - bindAnonymousDeclaration(node, 2097152 /* Alias */, getDeclarationName(node)); + // Incorrect export assignment in some sort of block construct + bindAnonymousDeclaration(node, 111551 /* Value */, getDeclarationName(node)); } else { var flags = ts.exportAssignmentIsAlias(node) @@ -42718,11 +44185,11 @@ var ts; } var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 210 /* 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 === 62 /* EqualsToken */) { + if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 63 /* EqualsToken */) { var l = thisContainer.parent.left; if (ts.isBindableStaticAccessExpression(l) && ts.isPrototypeAccess(l.expression)) { constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer); @@ -42741,11 +44208,11 @@ var ts; addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* Class */); } break; - case 166 /* Constructor */: - case 163 /* PropertyDeclaration */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 168 /* Constructor */: + case 165 /* PropertyDeclaration */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: // this.foo assignment in a JavaScript class // Bind this property to the containing class var containingClass = thisContainer.parent; @@ -42757,7 +44224,7 @@ var ts; declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* None */, /*isReplaceableByMethod*/ true); } break; - case 297 /* SourceFile */: + case 299 /* 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; @@ -42783,10 +44250,10 @@ var ts; } } function bindSpecialPropertyDeclaration(node) { - if (node.expression.kind === 107 /* ThisKeyword */) { + if (node.expression.kind === 108 /* ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 297 /* SourceFile */) { + else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 299 /* SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -42826,7 +44293,7 @@ var ts; } function bindObjectDefinePropertyAssignment(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); - var isToplevel = node.parent.parent.kind === 297 /* SourceFile */; + var isToplevel = node.parent.parent.kind === 299 /* SourceFile */; namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ false); } @@ -42935,8 +44402,8 @@ var ts; } function isTopLevelNamespaceAssignment(propertyAccess) { return ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 297 /* SourceFile */ - : propertyAccess.parent.parent.kind === 297 /* SourceFile */; + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 299 /* SourceFile */ + : propertyAccess.parent.parent.kind === 299 /* SourceFile */; } function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) { var namespaceSymbol = lookupSymbolForPropertyAccess(name, container) || lookupSymbolForPropertyAccess(name, blockScopeContainer); @@ -43015,7 +44482,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 252 /* ClassDeclaration */) { + if (node.kind === 254 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899503 /* ClassExcludes */); } else { @@ -43057,7 +44524,7 @@ var ts; checkStrictModeEvalOrArguments(node, node.name); } if (!ts.isBindingPattern(node.name)) { - if (ts.isInJSFile(node) && ts.isRequireVariableDeclaration(node, /*requireStringLiteralLikeArgument*/ true) && !ts.getJSDocTypeTag(node)) { + if (ts.isInJSFile(node) && ts.isRequireVariableDeclaration(node) && !ts.getJSDocTypeTag(node)) { declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); } else if (ts.isBlockOrCatchScoped(node)) { @@ -43081,7 +44548,7 @@ var ts; } } function bindParameter(node) { - if (node.kind === 326 /* JSDocParameterTag */ && container.kind !== 313 /* JSDocSignature */) { + if (node.kind === 334 /* JSDocParameterTag */ && container.kind !== 317 /* JSDocSignature */) { return; } if (inStrictMode && !(node.flags & 8388608 /* Ambient */)) { @@ -43158,7 +44625,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } } - else if (node.parent.kind === 185 /* InferType */) { + else if (node.parent.kind === 187 /* InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { @@ -43177,7 +44644,7 @@ var ts; // reachability checks function shouldReportErrorOnModuleDeclaration(node) { var instanceState = getModuleInstanceState(node); - return instanceState === 1 /* Instantiated */ || (instanceState === 2 /* ConstEnumOnly */ && !!options.preserveConstEnums); + return instanceState === 1 /* Instantiated */ || (instanceState === 2 /* ConstEnumOnly */ && ts.shouldPreserveConstEnums(options)); } function checkUnreachable(node) { if (!(currentFlow.flags & 1 /* Unreachable */)) { @@ -43186,11 +44653,11 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 231 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 233 /* EmptyStatement */) || // report error on class declarations - node.kind === 252 /* ClassDeclaration */ || + node.kind === 254 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 256 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); + (node.kind === 258 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -43234,12 +44701,12 @@ var ts; } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: return true; - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return getModuleInstanceState(s) !== 1 /* Instantiated */; - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: return ts.hasSyntacticModifier(s, 2048 /* Const */); default: return false; @@ -43439,7 +44906,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 === 176 /* TypeQuery */) { + if (d.type && d.type.kind === 178 /* TypeQuery */) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); @@ -43609,15 +45076,6 @@ var ts; CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions"; CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp"; })(CheckMode || (CheckMode = {})); - var AccessFlags; - (function (AccessFlags) { - AccessFlags[AccessFlags["None"] = 0] = "None"; - AccessFlags[AccessFlags["NoIndexSignatures"] = 1] = "NoIndexSignatures"; - AccessFlags[AccessFlags["Writing"] = 2] = "Writing"; - AccessFlags[AccessFlags["CacheSymbol"] = 4] = "CacheSymbol"; - AccessFlags[AccessFlags["NoTupleBoundsCheck"] = 8] = "NoTupleBoundsCheck"; - AccessFlags[AccessFlags["ExpressionPosition"] = 16] = "ExpressionPosition"; - })(AccessFlags || (AccessFlags = {})); var SignatureCheckMode; (function (SignatureCheckMode) { SignatureCheckMode[SignatureCheckMode["BivariantCallback"] = 1] = "BivariantCallback"; @@ -43666,6 +45124,7 @@ var ts; DeclarationMeaning[DeclarationMeaning["SetAccessor"] = 2] = "SetAccessor"; DeclarationMeaning[DeclarationMeaning["PropertyAssignment"] = 4] = "PropertyAssignment"; DeclarationMeaning[DeclarationMeaning["Method"] = 8] = "Method"; + DeclarationMeaning[DeclarationMeaning["PrivateStatic"] = 16] = "PrivateStatic"; DeclarationMeaning[DeclarationMeaning["GetOrSetAccessor"] = 3] = "GetOrSetAccessor"; DeclarationMeaning[DeclarationMeaning["PropertyAssignmentOrMethod"] = 12] = "PropertyAssignmentOrMethod"; })(DeclarationMeaning || (DeclarationMeaning = {})); @@ -43757,21 +45216,24 @@ var ts; var instantiationCount = 0; var instantiationDepth = 0; var currentNode; - var typeCatalog = []; // NB: id is index + 1 var emptySymbols = ts.createSymbolTable(); var arrayVariances = [1 /* Covariant */]; var compilerOptions = host.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var moduleKind = ts.getEmitModuleKind(compilerOptions); + var useDefineForClassFields = ts.getUseDefineForClassFields(compilerOptions); var allowSyntheticDefaultImports = ts.getAllowSyntheticDefaultImports(compilerOptions); var strictNullChecks = ts.getStrictOptionValue(compilerOptions, "strictNullChecks"); var strictFunctionTypes = ts.getStrictOptionValue(compilerOptions, "strictFunctionTypes"); var strictBindCallApply = ts.getStrictOptionValue(compilerOptions, "strictBindCallApply"); var strictPropertyInitialization = ts.getStrictOptionValue(compilerOptions, "strictPropertyInitialization"); + var strictOptionalProperties = ts.getStrictOptionValue(compilerOptions, "strictOptionalProperties"); var noImplicitAny = ts.getStrictOptionValue(compilerOptions, "noImplicitAny"); var noImplicitThis = ts.getStrictOptionValue(compilerOptions, "noImplicitThis"); + var useUnknownInCatchVariables = ts.getStrictOptionValue(compilerOptions, "useUnknownInCatchVariables"); var keyofStringsOnly = !!compilerOptions.keyofStringsOnly; - var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 32768 /* FreshLiteral */; + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 16384 /* FreshLiteral */; + var checkBinaryExpression = createCheckBinaryExpression(); var emitResolver = createResolver(); var nodeBuilder = createNodeBuilder(); var globals = ts.createSymbolTable(); @@ -43794,7 +45256,6 @@ var ts; getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); }, getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); }, getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount") + symbolCount; }, - getTypeCatalog: function () { return typeCatalog; }, getTypeCount: function () { return typeCount; }, getInstantiationCount: function () { return totalInstantiationCount; }, getRelationCacheSizes: function () { return ({ @@ -43958,6 +45419,7 @@ var ts; return node && getContextualTypeForJsxAttribute(node); }, isContextSensitive: isContextSensitive, + getTypeOfPropertyOfContextualType: getTypeOfPropertyOfContextualType, getFullyQualifiedName: getFullyQualifiedName, getResolvedSignature: function (node, candidatesOutArray, argumentCount) { return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 0 /* Normal */); @@ -44001,6 +45463,7 @@ var ts; }, tryGetMemberInModuleExports: function (name, symbol) { return tryGetMemberInModuleExports(ts.escapeLeadingUnderscores(name), symbol); }, tryGetMemberInModuleExportsAndProperties: function (name, symbol) { return tryGetMemberInModuleExportsAndProperties(ts.escapeLeadingUnderscores(name), symbol); }, + tryFindAmbientModule: function (moduleName) { return tryFindAmbientModule(moduleName, /*withAugmentations*/ true); }, tryFindAmbientModuleWithoutAugmentations: function (moduleName) { // we deliberately exclude augmentations // since we are only interested in declarations of the module itself @@ -44119,6 +45582,7 @@ var ts; var templateLiteralTypes = new ts.Map(); var stringMappingTypes = new ts.Map(); var substitutionTypes = new ts.Map(); + var subtypeReductionCache = new ts.Map(); var evolvingArrayTypes = []; var undefinedProperties = new ts.Map(); var unknownSymbol = createSymbol(4 /* Property */, "unknown"); @@ -44127,14 +45591,15 @@ var ts; var autoType = createIntrinsicType(1 /* Any */, "any"); var wildcardType = createIntrinsicType(1 /* Any */, "any"); var errorType = createIntrinsicType(1 /* Any */, "error"); - var nonInferrableAnyType = createIntrinsicType(1 /* Any */, "any", 524288 /* ContainsWideningType */); + var nonInferrableAnyType = createIntrinsicType(1 /* Any */, "any", 131072 /* ContainsWideningType */); var intrinsicMarkerType = createIntrinsicType(1 /* Any */, "intrinsic"); var unknownType = createIntrinsicType(2 /* Unknown */, "unknown"); var undefinedType = createIntrinsicType(32768 /* Undefined */, "undefined"); - var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* Undefined */, "undefined", 524288 /* ContainsWideningType */); + var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* Undefined */, "undefined", 131072 /* ContainsWideningType */); var optionalType = createIntrinsicType(32768 /* Undefined */, "undefined"); + var missingType = strictOptionalProperties ? createIntrinsicType(32768 /* Undefined */, "undefined") : undefinedType; var nullType = createIntrinsicType(65536 /* Null */, "null"); - var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* Null */, "null", 524288 /* ContainsWideningType */); + var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* Null */, "null", 131072 /* ContainsWideningType */); var stringType = createIntrinsicType(4 /* String */, "string"); var numberType = createIntrinsicType(8 /* Number */, "number"); var bigintType = createIntrinsicType(64 /* BigInt */, "bigint"); @@ -44160,7 +45625,7 @@ var ts; var voidType = createIntrinsicType(16384 /* Void */, "void"); var neverType = createIntrinsicType(131072 /* Never */, "never"); var silentNeverType = createIntrinsicType(131072 /* Never */, "never"); - var nonInferrableType = createIntrinsicType(131072 /* Never */, "never", 2097152 /* NonInferrableType */); + var nonInferrableType = createIntrinsicType(131072 /* Never */, "never", 524288 /* NonInferrableType */); var implicitNeverType = createIntrinsicType(131072 /* Never */, "never"); var unreachableNeverType = createIntrinsicType(131072 /* Never */, "never"); var nonPrimitiveType = createIntrinsicType(67108864 /* NonPrimitive */, "object"); @@ -44172,7 +45637,7 @@ var ts; var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? wildcardType : t; }); var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var emptyJsxObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); - emptyJsxObjectType.objectFlags |= 4096 /* JsxAttributes */; + emptyJsxObjectType.objectFlags |= 2048 /* JsxAttributes */; var emptyTypeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); emptyTypeLiteralSymbol.members = ts.createSymbolTable(); var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); @@ -44181,7 +45646,7 @@ var ts; var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); // The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated // in getPropagatingFlagsOfTypes, and it is checked in inferFromTypes. - anyFunctionType.objectFlags |= 2097152 /* NonInferrableType */; + anyFunctionType.objectFlags |= 524288 /* NonInferrableType */; var noConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var circularConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var resolvingDefaultType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); @@ -44261,6 +45726,7 @@ var ts; // This allows users to just specify library files they want to used through --lib // and they will not get an error from not having unrelated library files var deferredGlobalESSymbolConstructorSymbol; + var deferredGlobalESSymbolConstructorTypeSymbol; var deferredGlobalESSymbolType; var deferredGlobalTypedPropertyDescriptorType; var deferredGlobalPromiseType; @@ -44312,7 +45778,7 @@ var ts; var flowNodePostSuper = []; var potentialThisCollisions = []; var potentialNewTargetCollisions = []; - var potentialWeakMapCollisions = []; + var potentialWeakMapSetCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); var suggestionDiagnostics = ts.createDiagnosticCollection(); @@ -44459,9 +45925,28 @@ var ts; } return diagnostic; } + function addDeprecatedSuggestionWorker(declarations, diagnostic) { + var deprecatedTag = Array.isArray(declarations) ? ts.forEach(declarations, ts.getJSDocDeprecatedTag) : ts.getJSDocDeprecatedTag(declarations); + if (deprecatedTag) { + ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(deprecatedTag, ts.Diagnostics.The_declaration_was_marked_as_deprecated_here)); + } + // We call `addRelatedInfo()` before adding the diagnostic to prevent duplicates. + suggestionDiagnostics.add(diagnostic); + return diagnostic; + } + function addDeprecatedSuggestion(location, declarations, deprecatedEntity) { + var diagnostic = ts.createDiagnosticForNode(location, ts.Diagnostics._0_is_deprecated, deprecatedEntity); + return addDeprecatedSuggestionWorker(declarations, diagnostic); + } + function addDeprecatedSuggestionWithSignature(location, declaration, deprecatedEntity, signatureString) { + var diagnostic = deprecatedEntity + ? ts.createDiagnosticForNode(location, ts.Diagnostics.The_signature_0_of_1_is_deprecated, signatureString, deprecatedEntity) + : ts.createDiagnosticForNode(location, ts.Diagnostics._0_is_deprecated, signatureString); + return addDeprecatedSuggestionWorker(declaration, diagnostic); + } function createSymbol(flags, name, checkFlags) { symbolCount++; - var symbol = (new Symbol(flags | 33554432 /* Transient */, name)); + var symbol = new Symbol(flags | 33554432 /* Transient */, name); symbol.checkFlags = checkFlags || 0; return symbol; } @@ -44572,7 +46057,7 @@ var ts; // as we will already report a "Declaration name conflicts..." error, and this error // won't make much sense. if (target !== globalThisSymbol) { - error(ts.getNameOfDeclaration(source.declarations[0]), ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); + error(source.declarations && ts.getNameOfDeclaration(source.declarations[0]), ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); } } else { // error @@ -44606,9 +46091,11 @@ var ts; } return target; function addDuplicateLocations(locs, symbol) { - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - ts.pushIfUnique(locs, decl); + if (symbol.declarations) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + ts.pushIfUnique(locs, decl); + } } } } @@ -44654,9 +46141,9 @@ var ts; }); } function mergeModuleAugmentation(moduleName) { - var _a, _b; + var _a, _b, _c; var moduleAugmentation = moduleName.parent; - if (moduleAugmentation.symbol.declarations[0] !== moduleAugmentation) { + if (((_a = moduleAugmentation.symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]) !== moduleAugmentation) { // this is a combined symbol for multiple augmentations within the same file. // its symbol already has accumulated information for all declarations // so we need to add it just once - do the work only for first declaration @@ -44693,11 +46180,11 @@ var ts; patternAmbientModuleAugmentations.set(moduleName.text, merged); } else { - if (((_a = mainModule_1.exports) === null || _a === void 0 ? void 0 : _a.get("__export" /* ExportStar */)) && ((_b = moduleAugmentation.symbol.exports) === null || _b === void 0 ? void 0 : _b.size)) { + 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)) { // 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 */); - for (var _i = 0, _c = ts.arrayFrom(moduleAugmentation.symbol.exports.entries()); _i < _c.length; _i++) { - var _d = _c[_i], key = _d[0], value = _d[1]; + 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)) { mergeSymbol(resolvedExports.get(key), value); } @@ -44738,7 +46225,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = new NodeLinks()); } function isGlobalSourceFile(node) { - return node.kind === 297 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 299 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -44797,17 +46284,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 === 198 /* BindingElement */) { + if (declaration.kind === 200 /* 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, 198 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 200 /* 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, 249 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 251 /* VariableDeclaration */), usage); } - else if (declaration.kind === 249 /* VariableDeclaration */) { + else if (declaration.kind === 251 /* VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -44821,7 +46308,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 !(compilerOptions.target === 99 /* ESNext */ && !!compilerOptions.useDefineForClassFields + return !(compilerOptions.target === 99 /* ESNext */ && useDefineForClassFields && ts.getContainingClass(declaration) === ts.getContainingClass(usage) && isUsedInFunctionOrInstanceProperty(usage, declaration)); } @@ -44837,19 +46324,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 === 270 /* ExportSpecifier */ || (usage.parent.kind === 266 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 272 /* ExportSpecifier */ || (usage.parent.kind === 268 /* 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 === 266 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 268 /* ExportAssignment */ && usage.isExportEquals) { return true; } if (!!(usage.flags & 4194304 /* JSDoc */) || isInTypeQuery(usage) || usageInTypeDeclaration()) { return true; } if (isUsedInFunctionOrInstanceProperty(usage, declaration)) { - if (compilerOptions.target === 99 /* ESNext */ && !!compilerOptions.useDefineForClassFields + if (compilerOptions.target === 99 /* ESNext */ && useDefineForClassFields && ts.getContainingClass(declaration) && (ts.isPropertyDeclaration(declaration) || ts.isParameterPropertyDeclaration(declaration, declaration.parent))) { return !isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, /*stopAtAnyPropertyDeclaration*/ true); @@ -44864,9 +46351,9 @@ var ts; } function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { switch (declaration.parent.parent.kind) { - case 232 /* VariableStatement */: - case 237 /* ForStatement */: - case 239 /* ForOfStatement */: + case 234 /* VariableStatement */: + case 239 /* ForStatement */: + case 241 /* 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)) { @@ -44887,16 +46374,16 @@ var ts; return true; } var initializerOfProperty = current.parent && - current.parent.kind === 163 /* PropertyDeclaration */ && + current.parent.kind === 165 /* PropertyDeclaration */ && current.parent.initializer === current; if (initializerOfProperty) { if (ts.hasSyntacticModifier(current.parent, 32 /* Static */)) { - if (declaration.kind === 165 /* MethodDeclaration */) { + if (declaration.kind === 167 /* MethodDeclaration */) { return true; } } else { - var isDeclarationInstanceProperty = declaration.kind === 163 /* PropertyDeclaration */ && !ts.hasSyntacticModifier(declaration, 32 /* Static */); + var isDeclarationInstanceProperty = declaration.kind === 165 /* PropertyDeclaration */ && !ts.hasSyntacticModifier(declaration, 32 /* Static */); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -44918,19 +46405,19 @@ var ts; return "quit"; } switch (node.kind) { - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return true; - case 163 /* PropertyDeclaration */: + case 165 /* 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 230 /* Block */: + case 232 /* Block */: switch (node.parent.kind) { - case 167 /* GetAccessor */: - case 165 /* MethodDeclaration */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 167 /* MethodDeclaration */: + case 170 /* SetAccessor */: return true; default: return false; @@ -44945,7 +46432,11 @@ var ts; function useOuterVariableScopeInParameter(result, location, lastLocation) { var target = ts.getEmitScriptTarget(compilerOptions); var functionLocation = location; - if (ts.isParameter(lastLocation) && functionLocation.body && result.valueDeclaration.pos >= functionLocation.body.pos && result.valueDeclaration.end <= functionLocation.body.end) { + if (ts.isParameter(lastLocation) + && functionLocation.body + && result.valueDeclaration + && result.valueDeclaration.pos >= functionLocation.body.pos + && result.valueDeclaration.end <= functionLocation.body.end) { // check for several cases where we introduce temporaries that require moving the name/initializer of the parameter to the body // - static field in a class expression // - optional chaining pre-es2020 @@ -44966,21 +46457,21 @@ var ts; } function requiresScopeChangeWorker(node) { switch (node.kind) { - case 209 /* ArrowFunction */: - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: - case 166 /* Constructor */: + case 211 /* ArrowFunction */: + case 210 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 168 /* Constructor */: // do not descend into these return false; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 288 /* PropertyAssignment */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 290 /* PropertyAssignment */: return requiresScopeChangeWorker(node.name); - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: // static properties in classes introduce temporary variables if (ts.hasStaticModifier(node)) { - return target < 99 /* ESNext */ || !compilerOptions.useDefineForClassFields; + return target < 99 /* ESNext */ || !useDefineForClassFields; } return requiresScopeChangeWorker(node.name); default: @@ -45009,6 +46500,7 @@ var ts; return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSymbol, suggestedNameNotFoundMessage); } function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, lookup, suggestedNameNotFoundMessage) { + var _a; var originalLocation = location; // needed for did-you-mean error reporting, which gathers candidates starting from the original location var result; var lastLocation; @@ -45031,12 +46523,12 @@ 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 !== 311 /* JSDocComment */) { + if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 314 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || - lastLocation.kind === 160 /* Parameter */ || - lastLocation.kind === 159 /* TypeParameter */ + lastLocation.kind === 162 /* Parameter */ || + lastLocation.kind === 161 /* TypeParameter */ // local types not visible outside the function body : false; } @@ -45051,13 +46543,13 @@ var ts; // however it is detected separately when checking initializers of parameters // to make sure that they reference no variables declared after them. useResult = - lastLocation.kind === 160 /* Parameter */ || + lastLocation.kind === 162 /* Parameter */ || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } } - else if (location.kind === 184 /* ConditionalType */) { + else if (location.kind === 186 /* 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; @@ -45072,14 +46564,14 @@ var ts; } withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation); switch (location.kind) { - case 297 /* SourceFile */: + case 299 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports || emptySymbols; - if (location.kind === 297 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 8388608 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) { + if (location.kind === 299 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 8388608 /* 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 */)) { @@ -45103,13 +46595,13 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 /* Alias */ && - (ts.getDeclarationOfKind(moduleExport, 270 /* ExportSpecifier */) || ts.getDeclarationOfKind(moduleExport, 269 /* NamespaceExport */))) { + (ts.getDeclarationOfKind(moduleExport, 272 /* ExportSpecifier */) || ts.getDeclarationOfKind(moduleExport, 271 /* 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 (ts.isSourceFile(location) && location.commonJsModuleIndicator && !result.declarations.some(ts.isJSDocTypeAlias)) { + if (ts.isSourceFile(location) && location.commonJsModuleIndicator && !((_a = result.declarations) === null || _a === void 0 ? void 0 : _a.some(ts.isJSDocTypeAlias))) { result = undefined; } else { @@ -45117,12 +46609,12 @@ var ts; } } break; - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 163 /* PropertyDeclaration */: + case 165 /* 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 @@ -45139,9 +46631,9 @@ var ts; } } break; - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* 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! @@ -45160,7 +46652,7 @@ var ts; } break loop; } - if (location.kind === 221 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 223 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -45168,9 +46660,9 @@ var ts; } } break; - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: // The type parameters of a class are not in scope in the base class expression. - if (lastLocation === location.expression && location.parent.token === 93 /* ExtendsKeyword */) { + if (lastLocation === location.expression && location.parent.token === 94 /* ExtendsKeyword */) { var container = location.parent.parent; if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968 /* Type */))) { if (nameNotFoundMessage) { @@ -45188,9 +46680,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 253 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 255 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -45198,24 +46690,24 @@ var ts; } } break; - case 209 /* ArrowFunction */: + case 211 /* 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 (compilerOptions.target >= 2 /* ES2015 */) { break; } // falls through - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 251 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 253 /* FunctionDeclaration */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -45228,7 +46720,7 @@ var ts; } } break; - case 161 /* Decorator */: + case 163 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -45237,7 +46729,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 === 160 /* Parameter */) { + if (location.parent && location.parent.kind === 162 /* Parameter */) { location = location.parent; } // @@ -45252,20 +46744,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 === 252 /* ClassDeclaration */)) { + if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 254 /* ClassDeclaration */)) { location = location.parent; } break; - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 325 /* JSDocEnumTag */: + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + case 333 /* 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 160 /* Parameter */: + case 162 /* Parameter */: if (lastLocation && (lastLocation === location.initializer || lastLocation === location.name && ts.isBindingPattern(lastLocation))) { if (!associatedDeclarationForContainingInitializerOrBindingName) { @@ -45273,7 +46765,7 @@ var ts; } } break; - case 198 /* BindingElement */: + case 200 /* BindingElement */: if (lastLocation && (lastLocation === location.initializer || lastLocation === location.name && ts.isBindingPattern(lastLocation))) { if (ts.isParameterDeclaration(location) && !associatedDeclarationForContainingInitializerOrBindingName) { @@ -45281,7 +46773,7 @@ var ts; } } break; - case 185 /* InferType */: + case 187 /* InferType */: if (meaning & 262144 /* TypeParameter */) { var parameterName = location.typeParameter.name; if (parameterName && name === parameterName.escapedText) { @@ -45305,7 +46797,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 297 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 299 /* SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -45334,6 +46826,10 @@ var ts; var suggestion = void 0; if (suggestedNameNotFoundMessage && suggestionCount < maximumSuggestionCount) { suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning); + var isGlobalScopeAugmentationDeclaration = suggestion && suggestion.valueDeclaration && ts.isAmbientModule(suggestion.valueDeclaration) && ts.isGlobalScopeAugmentation(suggestion.valueDeclaration); + if (isGlobalScopeAugmentationDeclaration) { + suggestion = undefined; + } if (suggestion) { var suggestionName = symbolToString(suggestion); var diagnostic = error(errorLocation, suggestedNameNotFoundMessage, diagnosticName(nameArg), suggestionName); @@ -45360,7 +46856,7 @@ var ts; } // Perform extra checks only if error reporting was requested if (nameNotFoundMessage) { - if (propertyWithInvalidInitializer && !(compilerOptions.target === 99 /* ESNext */ && compilerOptions.useDefineForClassFields)) { + if (propertyWithInvalidInitializer && !(compilerOptions.target === 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. @@ -45430,10 +46926,10 @@ var ts; } } function getIsDeferredContext(location, lastLocation) { - if (location.kind !== 209 /* ArrowFunction */ && location.kind !== 208 /* FunctionExpression */) { + if (location.kind !== 211 /* ArrowFunction */ && location.kind !== 210 /* 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 === 163 /* PropertyDeclaration */ && !ts.hasSyntacticModifier(location, 32 /* Static */))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred + (location.kind === 165 /* PropertyDeclaration */ && !ts.hasSyntacticModifier(location, 32 /* Static */))) && (!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; @@ -45446,12 +46942,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 256 /* ModuleDeclaration */: // For `namespace N { N; }` + case 253 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 257 /* EnumDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 258 /* ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -45461,12 +46957,14 @@ var ts; return ts.isString(nameArg) ? ts.unescapeLeadingUnderscores(nameArg) : ts.declarationNameToString(nameArg); } function isTypeParameterSymbolDeclaredInContainer(symbol, container) { - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - if (decl.kind === 159 /* 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)); // TODO: GH#18217 + if (symbol.declarations) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + if (decl.kind === 161 /* 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)); // TODO: GH#18217 + } } } } @@ -45518,10 +47016,10 @@ var ts; */ function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 78 /* Identifier */: - case 201 /* PropertyAccessExpression */: + case 79 /* Identifier */: + case 203 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -45565,7 +47063,7 @@ 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 === 270 /* ExportSpecifier */) { + if (isPrimitiveTypeName(name) && errorLocation.parent.kind === 272 /* ExportSpecifier */) { error(errorLocation, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, name); return true; } @@ -45634,13 +47132,14 @@ var ts; return false; } 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 */) { // constructor functions aren't block scoped return; } // Block-scoped variables cannot be used before their definition - var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 255 /* 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 === 257 /* EnumDeclaration */); }); if (declaration === undefined) return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration"); if (!(declaration.flags & 8388608 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { @@ -45657,7 +47156,7 @@ var ts; } else { ts.Debug.assert(!!(result.flags & 128 /* ConstEnum */)); - if (compilerOptions.preserveConstEnums) { + if (ts.shouldPreserveConstEnums(compilerOptions)) { diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName); } } @@ -45675,20 +47174,20 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return node; - case 262 /* ImportClause */: + case 264 /* ImportClause */: return node.parent; - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: return node.parent.parent; - case 265 /* ImportSpecifier */: + case 267 /* ImportSpecifier */: return node.parent.parent.parent; default: return undefined; } } function getDeclarationOfAliasSymbol(symbol) { - return ts.find(symbol.declarations, isAliasSymbolDeclaration); + return symbol.declarations && ts.findLast(symbol.declarations, isAliasSymbolDeclaration); } /** * An alias symbol is created by one of the following declarations: @@ -45703,25 +47202,26 @@ var ts; * module.exports = * {} * {name: } + * const { x } = require ... */ function isAliasSymbolDeclaration(node) { - return node.kind === 260 /* ImportEqualsDeclaration */ - || node.kind === 259 /* NamespaceExportDeclaration */ - || node.kind === 262 /* ImportClause */ && !!node.name - || node.kind === 263 /* NamespaceImport */ - || node.kind === 269 /* NamespaceExport */ - || node.kind === 265 /* ImportSpecifier */ - || node.kind === 270 /* ExportSpecifier */ - || node.kind === 266 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) + return node.kind === 262 /* ImportEqualsDeclaration */ + || node.kind === 261 /* NamespaceExportDeclaration */ + || node.kind === 264 /* ImportClause */ && !!node.name + || node.kind === 265 /* NamespaceImport */ + || node.kind === 271 /* NamespaceExport */ + || node.kind === 267 /* ImportSpecifier */ + || node.kind === 272 /* ExportSpecifier */ + || node.kind === 268 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) || ts.isBinaryExpression(node) && ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && ts.exportAssignmentIsAlias(node) || ts.isAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node - && node.parent.operatorToken.kind === 62 /* EqualsToken */ + && node.parent.operatorToken.kind === 63 /* EqualsToken */ && isAliasableOrJsExpression(node.parent.right) - || node.kind === 289 /* ShorthandPropertyAssignment */ - || node.kind === 288 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer) - || ts.isRequireVariableDeclaration(node, /*requireStringLiteralLikeArgument*/ true); + || node.kind === 291 /* ShorthandPropertyAssignment */ + || node.kind === 290 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer) + || ts.isRequireVariableDeclaration(node); } function isAliasableOrJsExpression(e) { return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e); @@ -45734,7 +47234,7 @@ var ts; ? resolveSymbol(getPropertyOfType(resolveExternalModuleTypeByLiteral(name), commonJSPropertyAccess.name.escapedText)) : undefined; } - if (ts.isVariableDeclaration(node) || node.moduleReference.kind === 272 /* ExternalModuleReference */) { + if (ts.isVariableDeclaration(node) || node.moduleReference.kind === 274 /* ExternalModuleReference */) { var immediate = resolveExternalModuleName(node, ts.getExternalModuleRequireArgument(node) || ts.getExternalModuleImportEqualsDeclarationExpression(node)); var resolved_4 = resolveExternalModuleSymbol(immediate); markSymbolOfAliasDeclarationIfTypeOnly(node, immediate, resolved_4, /*overwriteEmpty*/ false); @@ -45801,6 +47301,7 @@ var ts; return !file.externalModuleIndicator && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), /*sourceNode*/ undefined, dontResolveAlias); } function getTargetOfImportClause(node, dontResolveAlias) { + var _a; var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier); if (moduleSymbol) { var exportDefaultSymbol = void 0; @@ -45810,7 +47311,7 @@ var ts; else { exportDefaultSymbol = resolveExportByName(moduleSymbol, "default" /* Default */, node, dontResolveAlias); } - var file = ts.find(moduleSymbol.declarations, ts.isSourceFile); + var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); var hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias); if (!exportDefaultSymbol && !hasSyntheticDefault) { if (hasExportAssignmentSymbol(moduleSymbol)) { @@ -45818,7 +47319,9 @@ var ts; var exportEqualsSymbol = moduleSymbol.exports.get("export=" /* 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); - ts.addRelatedInfo(err, ts.createDiagnosticForNode(exportAssignment, ts.Diagnostics.This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag, compilerOptionName)); + if (exportAssignment) { + ts.addRelatedInfo(err, ts.createDiagnosticForNode(exportAssignment, ts.Diagnostics.This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag, compilerOptionName)); + } } else { reportNonDefaultExport(moduleSymbol, node); @@ -45835,7 +47338,7 @@ var ts; } } function reportNonDefaultExport(moduleSymbol, node) { - var _a, _b; + var _a, _b, _c; if ((_a = moduleSymbol.exports) === null || _a === void 0 ? void 0 : _a.has(node.symbol.escapedName)) { error(node.name, ts.Diagnostics.Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead, symbolToString(moduleSymbol), symbolToString(node.symbol)); } @@ -45843,7 +47346,7 @@ var ts; 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 */); if (exportStar) { - var defaultExport = ts.find(exportStar.declarations, function (decl) { + 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 */))); @@ -45921,7 +47424,7 @@ var ts; } } function getExternalModuleMember(node, specifier, dontResolveAlias) { - var _a; + var _a, _b; if (dontResolveAlias === void 0) { dontResolveAlias = false; } var moduleSpecifier = ts.getExternalModuleRequireArgument(node) || node.moduleSpecifier; var moduleSymbol = resolveExternalModuleName(node, moduleSpecifier); // TODO: GH#18217 @@ -45930,7 +47433,7 @@ var ts; return undefined; } var suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || compilerOptions.esModuleInterop); - var targetSymbol = resolveESModuleSymbol(moduleSymbol, moduleSpecifier, dontResolveAlias, suppressInteropError); + var targetSymbol = resolveESModuleSymbol(moduleSymbol, moduleSpecifier, /*dontResolveAlias*/ false, suppressInteropError); if (targetSymbol) { if (name.escapedText) { if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { @@ -45948,7 +47451,7 @@ var ts; symbolFromVariable = resolveSymbol(symbolFromVariable, dontResolveAlias); var symbolFromModule = getExportOfModule(targetSymbol, name, specifier, dontResolveAlias); if (symbolFromModule === undefined && name.escapedText === "default" /* Default */) { - var file = ts.find(moduleSymbol.declarations, ts.isSourceFile); + var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); if (canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias)) { symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias); } @@ -45968,7 +47471,7 @@ var ts; } } else { - if ((_a = moduleSymbol.exports) === null || _a === void 0 ? void 0 : _a.has("default" /* Default */)) { + if ((_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* 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 { @@ -45981,8 +47484,8 @@ var ts; } } function reportNonExportedMember(node, name, declarationName, moduleSymbol, moduleName) { - var _a; - var localSymbol = (_a = moduleSymbol.valueDeclaration.locals) === null || _a === void 0 ? void 0 : _a.get(name.escapedText); + var _a, _b; + 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 */); @@ -45994,9 +47497,11 @@ var ts; var exportedSymbol = exports ? ts.find(symbolsToArray(exports), function (symbol) { return !!getSymbolIfSameReference(symbol, localSymbol); }) : undefined; var diagnostic = exportedSymbol ? error(name, ts.Diagnostics.Module_0_declares_1_locally_but_it_is_exported_as_2, moduleName, declarationName, symbolToString(exportedSymbol)) : error(name, ts.Diagnostics.Module_0_declares_1_locally_but_it_is_not_exported, moduleName, declarationName); - ts.addRelatedInfo.apply(void 0, __spreadArray([diagnostic], ts.map(localSymbol.declarations, function (decl, index) { - return ts.createDiagnosticForNode(decl, index === 0 ? ts.Diagnostics._0_is_declared_here : ts.Diagnostics.and_here, declarationName); - }))); + if (localSymbol.declarations) { + ts.addRelatedInfo.apply(void 0, __spreadArray([diagnostic], ts.map(localSymbol.declarations, function (decl, index) { + return ts.createDiagnosticForNode(decl, index === 0 ? ts.Diagnostics._0_is_declared_here : ts.Diagnostics.and_here, declarationName); + }))); + } } } else { @@ -46075,7 +47580,7 @@ var ts; return getTargetOfAliasLikeExpression(expression, dontRecursivelyResolve); } function getTargetOfAccessExpression(node, dontRecursivelyResolve) { - if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62 /* EqualsToken */)) { + if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* EqualsToken */)) { return undefined; } return getTargetOfAliasLikeExpression(node.parent.right, dontRecursivelyResolve); @@ -46083,31 +47588,31 @@ var ts; function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 260 /* ImportEqualsDeclaration */: - case 249 /* VariableDeclaration */: + case 262 /* ImportEqualsDeclaration */: + case 251 /* VariableDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 262 /* ImportClause */: + case 264 /* ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 269 /* NamespaceExport */: + case 271 /* NamespaceExport */: return getTargetOfNamespaceExport(node, dontRecursivelyResolve); - case 265 /* ImportSpecifier */: - case 198 /* BindingElement */: + case 267 /* ImportSpecifier */: + case 200 /* BindingElement */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 270 /* ExportSpecifier */: + case 272 /* ExportSpecifier */: return getTargetOfExportSpecifier(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 266 /* ExportAssignment */: - case 216 /* BinaryExpression */: + case 268 /* ExportAssignment */: + case 218 /* BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 259 /* NamespaceExportDeclaration */: + case 261 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return resolveEntityName(node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve); - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: return getTargetOfPropertyAssignment(node, dontRecursivelyResolve); - case 202 /* ElementAccessExpression */: - case 201 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: return getTargetOfAccessExpression(node, dontRecursivelyResolve); default: return ts.Debug.fail(); @@ -46255,17 +47760,17 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 78 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 79 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 78 /* Identifier */ || entityName.parent.kind === 157 /* QualifiedName */) { + if (entityName.kind === 79 /* Identifier */ || entityName.parent.kind === 159 /* QualifiedName */) { return resolveEntityName(entityName, 1920 /* 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 === 260 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 262 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } @@ -46281,7 +47786,7 @@ var ts; } var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 111551 /* Value */ : 0); var symbol; - if (name.kind === 78 /* Identifier */) { + if (name.kind === 79 /* 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)); @@ -46289,9 +47794,9 @@ var ts; return getMergedSymbol(symbolFromJSPrototype); } } - else if (name.kind === 157 /* QualifiedName */ || name.kind === 201 /* PropertyAccessExpression */) { - var left = name.kind === 157 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 157 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 159 /* QualifiedName */ || name.kind === 203 /* PropertyAccessExpression */) { + var left = name.kind === 159 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 159 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -46299,18 +47804,17 @@ var ts; else if (namespace === unknownSymbol) { return namespace; } - if (ts.isInJSFile(name)) { - if (namespace.valueDeclaration && - ts.isVariableDeclaration(namespace.valueDeclaration) && - namespace.valueDeclaration.initializer && - isCommonJsRequire(namespace.valueDeclaration.initializer)) { - var moduleName = namespace.valueDeclaration.initializer.arguments[0]; - var moduleSym = resolveExternalModuleName(moduleName, moduleName); - if (moduleSym) { - var resolvedModuleSymbol = resolveExternalModuleSymbol(moduleSym); - if (resolvedModuleSymbol) { - namespace = resolvedModuleSymbol; - } + if (namespace.valueDeclaration && + ts.isInJSFile(namespace.valueDeclaration) && + ts.isVariableDeclaration(namespace.valueDeclaration) && + namespace.valueDeclaration.initializer && + isCommonJsRequire(namespace.valueDeclaration.initializer)) { + var moduleName = namespace.valueDeclaration.initializer.arguments[0]; + var moduleSym = resolveExternalModuleName(moduleName, moduleName); + if (moduleSym) { + var resolvedModuleSymbol = resolveExternalModuleSymbol(moduleSym); + if (resolvedModuleSymbol) { + namespace = resolvedModuleSymbol; } } } @@ -46331,7 +47835,7 @@ var ts; 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 === 266 /* ExportAssignment */)) { + if (!ts.nodeIsSynthesized(name) && ts.isEntityName(name) && (symbol.flags & 2097152 /* Alias */ || name.parent.kind === 268 /* ExportAssignment */)) { markSymbolOfAliasDeclarationIfTypeOnly(ts.getAliasDeclarationFromName(name), symbol, /*finalTarget*/ undefined, /*overwriteEmpty*/ true); } return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol); @@ -46568,7 +48072,7 @@ var ts; function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias, suppressInteropError) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!suppressInteropError && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 297 /* SourceFile */)) { + if (!suppressInteropError && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 299 /* SourceFile */)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; @@ -46619,7 +48123,10 @@ var ts; var exports = getExportsOfModuleAsArray(moduleSymbol); var exportEquals = resolveExternalModuleSymbol(moduleSymbol); if (exportEquals !== moduleSymbol) { - ts.addRange(exports, getPropertiesOfType(getTypeOfSymbol(exportEquals))); + var type = getTypeOfSymbol(exportEquals); + if (shouldTreatPropertiesOfExternalModuleAsExports(type)) { + ts.addRange(exports, getPropertiesOfType(type)); + } } return exports; } @@ -46639,11 +48146,14 @@ var ts; return undefined; } var type = getTypeOfSymbol(exportEquals); - return type.flags & 131068 /* Primitive */ || - ts.getObjectFlags(type) & 1 /* Class */ || - isArrayOrTupleLikeType(type) - ? undefined - : getPropertyOfType(type, memberName); + return shouldTreatPropertiesOfExternalModuleAsExports(type) ? getPropertyOfType(type, memberName) : undefined; + } + function shouldTreatPropertiesOfExternalModuleAsExports(resolvedExternalModuleType) { + return !(resolvedExternalModuleType.flags & 131068 /* Primitive */ || + ts.getObjectFlags(resolvedExternalModuleType) & 1 /* 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 */) : @@ -46701,11 +48211,13 @@ var ts; if (exportStars) { var nestedSymbols = ts.createSymbolTable(); var lookupTable_1 = new ts.Map(); - for (var _i = 0, _a = exportStars.declarations; _i < _a.length; _i++) { - var node = _a[_i]; - var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); - var exportedSymbols = visit(resolvedModule); - extendExportSymbols(nestedSymbols, exportedSymbols, lookupTable_1, node); + if (exportStars.declarations) { + for (var _i = 0, _a = exportStars.declarations; _i < _a.length; _i++) { + var node = _a[_i]; + var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); + var exportedSymbols = visit(resolvedModule); + extendExportSymbols(nestedSymbols, exportedSymbols, lookupTable_1, node); + } } lookupTable_1.forEach(function (_a, id) { var exportsWithDuplicate = _a.exportsWithDuplicate; @@ -46788,17 +48300,34 @@ var ts; var additionalContainers = ts.mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer); var reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration); var objectLiteralContainer = getVariableDeclarationOfObjectLiteral(container, meaning); - if (enclosingDeclaration && getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* Namespace */, /*externalOnly*/ false)) { + if (enclosingDeclaration && + container.flags & getQualifiedLeftMeaning(meaning) && + getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* 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 } - var res = ts.append(ts.append(additionalContainers, container), objectLiteralContainer); - return ts.concatenate(res, reexportContainers); + // 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 */ + ? forEachSymbolTableInScope(enclosingDeclaration, function (t) { + return ts.forEachEntry(t, function (s) { + if (s.flags & getQualifiedLeftMeaning(meaning) && getTypeOfSymbol(s) === getDeclaredTypeOfSymbol(container)) { + return s; + } + }); + }) : undefined; + var res = firstVariableMatch ? __spreadArray(__spreadArray([firstVariableMatch], additionalContainers), [container]) : __spreadArray(__spreadArray([], additionalContainers), [container]); + res = ts.append(res, objectLiteralContainer); + res = ts.addRange(res, reexportContainers); + return res; } var candidates = ts.mapDefined(symbol.declarations, function (d) { if (!ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent)) { return getSymbolOfNode(d.parent); } - if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 62 /* 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 /* 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)); } @@ -46870,7 +48399,7 @@ var ts; var members = node.members; for (var _i = 0, members_3 = members; _i < members_3.length; _i++) { var member = members_3[_i]; - if (member.kind === 166 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 168 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -46879,7 +48408,9 @@ var ts; var result = new Type(checker, flags); typeCount++; result.id = typeCount; - typeCatalog.push(result); + if (produceDiagnostics) { // Only record types from one checker + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.recordType(result); + } return result; } function createOriginType(flags) { @@ -46939,14 +48470,23 @@ var ts; }); return result || ts.emptyArray; } + function getNamedOrIndexSignatureMembers(members) { + var result = getNamedMembers(members); + var index = getIndexSymbolFromSymbolTable(members); + return index ? ts.concatenate(result, [index]) : result; + } function setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { - type.members = members; - type.properties = members === emptySymbols ? ts.emptyArray : getNamedMembers(members); - type.callSignatures = callSignatures; - type.constructSignatures = constructSignatures; - type.stringIndexInfo = stringIndexInfo; - type.numberIndexInfo = numberIndexInfo; - return type; + var resolved = type; + resolved.members = members; + resolved.properties = ts.emptyArray; + resolved.callSignatures = callSignatures; + resolved.constructSignatures = constructSignatures; + resolved.stringIndexInfo = stringIndexInfo; + resolved.numberIndexInfo = numberIndexInfo; + // This can loop back to getPropertyOfType() which would crash if `callSignatures` & `constructSignatures` are not initialized. + if (members !== emptySymbols) + resolved.properties = getNamedMembers(members); + return resolved; } function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { return setStructuredTypeMembers(createObjectType(16 /* Anonymous */, symbol), members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); @@ -46969,28 +48509,28 @@ var ts; var _loop_8 = function (location) { // Locals of a source file are not in scope (because they get merged into the global symbol table) if (location.locals && !isGlobalSourceFile(location)) { - if (result = callback(location.locals)) { + if (result = callback(location.locals, /*ignoreQualification*/ undefined, /*isLocalNameLookup*/ true, location)) { return { value: result }; } } switch (location.kind) { - case 297 /* SourceFile */: + case 299 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 256 /* ModuleDeclaration */: + case 258 /* 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 // to one another anyway) - if (result = callback((sym === null || sym === void 0 ? void 0 : sym.exports) || emptySymbols)) { + if (result = callback((sym === null || sym === void 0 ? void 0 : sym.exports) || emptySymbols, /*ignoreQualification*/ undefined, /*isLocalNameLookup*/ true, location)) { return { value: result }; } break; - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* 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 @@ -47005,7 +48545,7 @@ var ts; (table_1 || (table_1 = ts.createSymbolTable())).set(key, memberSymbol); } }); - if (table_1 && (result = callback(table_1))) { + if (table_1 && (result = callback(table_1, /*ignoreQualification*/ undefined, /*isLocalNameLookup*/ false, location))) { return { value: result }; } break; @@ -47016,7 +48556,7 @@ var ts; if (typeof state_2 === "object") return state_2.value; } - return callback(globals); + return callback(globals, /*ignoreQualification*/ undefined, /*isLocalNameLookup*/ true); } function getQualifiedLeftMeaning(rightMeaning) { // If we are looking in value space, the parent meaning is value, other wise it is namespace @@ -47027,20 +48567,30 @@ var ts; if (!(symbol && !isPropertyOrMethodDeclarationSymbol(symbol))) { return undefined; } + var links = getSymbolLinks(symbol); + 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; + if (cache.has(key)) { + return cache.get(key); + } var id = getSymbolId(symbol); var visitedSymbolTables = visitedSymbolTablesMap.get(id); if (!visitedSymbolTables) { visitedSymbolTablesMap.set(id, visitedSymbolTables = []); } - return forEachSymbolTableInScope(enclosingDeclaration, getAccessibleSymbolChainFromSymbolTable); + var result = forEachSymbolTableInScope(enclosingDeclaration, getAccessibleSymbolChainFromSymbolTable); + cache.set(key, result); + return result; /** * @param {ignoreQualification} boolean Set when a symbol is being looked for through the exports of another symbol (meaning we have a route to qualify it already) */ - function getAccessibleSymbolChainFromSymbolTable(symbols, ignoreQualification) { + function getAccessibleSymbolChainFromSymbolTable(symbols, ignoreQualification, isLocalNameLookup) { if (!ts.pushIfUnique(visitedSymbolTables, symbols)) { return undefined; } - var result = trySymbolTable(symbols, ignoreQualification); + var result = trySymbolTable(symbols, ignoreQualification, isLocalNameLookup); visitedSymbolTables.pop(); return result; } @@ -47058,7 +48608,7 @@ var ts; !ts.some(symbolFromSymbolTable.declarations, hasNonGlobalAugmentationExternalModuleSymbol) && (ignoreQualification || canQualifySymbol(getMergedSymbol(symbolFromSymbolTable), meaning)); } - function trySymbolTable(symbols, ignoreQualification) { + function trySymbolTable(symbols, ignoreQualification, isLocalNameLookup) { // If symbol is directly available by its name in the symbol table if (isAccessible(symbols.get(symbol.escapedName), /*resolvedAliasSymbol*/ undefined, ignoreQualification)) { return [symbol]; @@ -47071,9 +48621,11 @@ var ts; && !(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)) + // If we're looking up a local name to reference directly, omit namespace reexports, otherwise when we're trawling through an export list to make a dotted name, we can keep it + && (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, 270 /* ExportSpecifier */))) { + && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 272 /* ExportSpecifier */))) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); var candidate = getCandidateListForSymbol(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification); if (candidate) { @@ -47117,7 +48669,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, 270 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 272 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -47132,10 +48684,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 163 /* PropertyDeclaration */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: continue; default: return false; @@ -47173,7 +48725,7 @@ var ts; return hasAccessibleDeclarations; } } - else if (allowModules) { + if (allowModules) { if (ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { if (shouldComputeAliasesToMakeVisible) { earlyModuleBail = true; @@ -47247,7 +48799,8 @@ var ts; return { accessibility: 2 /* CannotBeNamed */, errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning), - errorModuleName: symbolToString(symbolExternalModule) + errorModuleName: symbolToString(symbolExternalModule), + errorNode: ts.isInJSFile(enclosingDeclaration) ? enclosingDeclaration : undefined, }; } } @@ -47264,14 +48817,14 @@ var ts; return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 297 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 299 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 297 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 299 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; - if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 78 /* Identifier */; }), getIsDeclarationVisible)) { + if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 79 /* Identifier */; }), getIsDeclarationVisible)) { return undefined; } return { accessibility: 0 /* Accessible */, aliasesToMakeVisible: aliasesToMakeVisible }; @@ -47323,14 +48876,14 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 176 /* TypeQuery */ || + if (entityName.parent.kind === 178 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) || - entityName.parent.kind === 158 /* ComputedPropertyName */) { + entityName.parent.kind === 160 /* ComputedPropertyName */) { // Typeof value meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 157 /* QualifiedName */ || entityName.kind === 201 /* PropertyAccessExpression */ || - entityName.parent.kind === 260 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 159 /* QualifiedName */ || entityName.kind === 203 /* PropertyAccessExpression */ || + entityName.parent.kind === 262 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -47371,7 +48924,7 @@ var ts; 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) === 297 /* SourceFile */ ? ts.createPrinter({ removeComments: true, neverAsciiEscape: true }) : ts.createPrinter({ removeComments: true }); + var printer = (enclosingDeclaration === null || enclosingDeclaration === void 0 ? void 0 : enclosingDeclaration.kind) === 299 /* 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); return writer; @@ -47383,10 +48936,10 @@ var ts; function signatureToStringWorker(writer) { var sigOutput; if (flags & 262144 /* WriteArrowStyleSignature */) { - sigOutput = kind === 1 /* Construct */ ? 175 /* ConstructorType */ : 174 /* FunctionType */; + sigOutput = kind === 1 /* Construct */ ? 177 /* ConstructorType */ : 176 /* FunctionType */; } else { - sigOutput = kind === 1 /* Construct */ ? 170 /* ConstructSignature */ : 169 /* CallSignature */; + sigOutput = kind === 1 /* Construct */ ? 172 /* ConstructSignature */ : 171 /* CallSignature */; } var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); @@ -47426,14 +48979,14 @@ var ts; return typeToString(type, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */); } function symbolValueDeclarationIsContextSensitive(symbol) { - return symbol && symbol.valueDeclaration && ts.isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration); + 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 */; } function isClassInstanceSide(type) { - return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || !!(ts.getObjectFlags(type) & 1073741824 /* IsClassInstanceClone */)); + return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288 /* Object */) && !!(ts.getObjectFlags(type) & 16777216 /* IsClassInstanceClone */))); } function createNodeBuilder() { return { @@ -47472,7 +49025,7 @@ var ts; enclosingDeclaration: enclosingDeclaration, flags: flags || 0 /* None */, // If no full tracker is provided, fake up a dummy one with a basic limited-functionality moduleResolverHost - tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: ts.noop, moduleResolverHost: flags & 134217728 /* DoNotIncludeSymbolChain */ ? { + tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: function () { return false; }, moduleResolverHost: flags & 134217728 /* DoNotIncludeSymbolChain */ ? { getCommonSourceDirectory: !!host.getCommonSourceDirectory ? function () { return host.getCommonSourceDirectory(); } : function () { return ""; }, getSourceFiles: function () { return host.getSourceFiles(); }, getCurrentDirectory: function () { return host.getCurrentDirectory(); }, @@ -47485,17 +49038,46 @@ var ts; getFileIncludeReasons: function () { return host.getFileIncludeReasons(); }, } : undefined }, encounteredError: false, + reportedDiagnostic: false, visitedTypes: undefined, symbolDepth: undefined, inferTypeParameters: undefined, approximateLength: 0 }; + context.tracker = wrapSymbolTrackerToReportForContext(context, context.tracker); var resultingNode = cb(context); if (context.truncating && context.flags & 1 /* 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; } + function wrapSymbolTrackerToReportForContext(context, tracker) { + var oldTrackSymbol = tracker.trackSymbol; + return __assign(__assign({}, tracker), { reportCyclicStructureError: wrapReportedDiagnostic(tracker.reportCyclicStructureError), reportInaccessibleThisError: wrapReportedDiagnostic(tracker.reportInaccessibleThisError), reportInaccessibleUniqueSymbolError: wrapReportedDiagnostic(tracker.reportInaccessibleUniqueSymbolError), reportLikelyUnsafeImportRequiredError: wrapReportedDiagnostic(tracker.reportLikelyUnsafeImportRequiredError), reportNonlocalAugmentation: wrapReportedDiagnostic(tracker.reportNonlocalAugmentation), reportPrivateInBaseOfClassExpression: wrapReportedDiagnostic(tracker.reportPrivateInBaseOfClassExpression), trackSymbol: oldTrackSymbol && (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var result = oldTrackSymbol.apply(void 0, args); + if (result) { + context.reportedDiagnostic = true; + } + return result; + }) }); + function wrapReportedDiagnostic(method) { + if (!method) { + return method; + } + return (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + context.reportedDiagnostic = true; + return method.apply(void 0, args); + }); + } + } function checkTruncationLength(context) { if (context.truncating) return context.truncating; @@ -47513,33 +49095,33 @@ var ts; return undefined; // TODO: GH#18217 } context.approximateLength += 3; - return ts.factory.createKeywordTypeNode(128 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(129 /* AnyKeyword */); } if (!(context.flags & 536870912 /* NoTypeReduction */)) { type = getReducedType(type); } if (type.flags & 1 /* Any */) { context.approximateLength += 3; - return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 136 /* IntrinsicKeyword */ : 128 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 137 /* IntrinsicKeyword */ : 129 /* AnyKeyword */); } if (type.flags & 2 /* Unknown */) { - return ts.factory.createKeywordTypeNode(152 /* UnknownKeyword */); + return ts.factory.createKeywordTypeNode(153 /* UnknownKeyword */); } if (type.flags & 4 /* String */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(147 /* StringKeyword */); + return ts.factory.createKeywordTypeNode(148 /* StringKeyword */); } if (type.flags & 8 /* Number */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(144 /* NumberKeyword */); + return ts.factory.createKeywordTypeNode(145 /* NumberKeyword */); } if (type.flags & 64 /* BigInt */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(155 /* BigIntKeyword */); + return ts.factory.createKeywordTypeNode(156 /* BigIntKeyword */); } if (type.flags & 16 /* Boolean */) { context.approximateLength += 7; - return ts.factory.createKeywordTypeNode(131 /* BooleanKeyword */); + return ts.factory.createKeywordTypeNode(132 /* BooleanKeyword */); } if (type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */)) { var parentSymbol = getParentOfSymbol(type.symbol); @@ -47593,15 +49175,15 @@ var ts; } } context.approximateLength += 13; - return ts.factory.createTypeOperatorNode(151 /* UniqueKeyword */, ts.factory.createKeywordTypeNode(148 /* SymbolKeyword */)); + return ts.factory.createTypeOperatorNode(152 /* UniqueKeyword */, ts.factory.createKeywordTypeNode(149 /* SymbolKeyword */)); } if (type.flags & 16384 /* Void */) { context.approximateLength += 4; - return ts.factory.createKeywordTypeNode(113 /* VoidKeyword */); + return ts.factory.createKeywordTypeNode(114 /* VoidKeyword */); } if (type.flags & 32768 /* Undefined */) { context.approximateLength += 9; - return ts.factory.createKeywordTypeNode(150 /* UndefinedKeyword */); + return ts.factory.createKeywordTypeNode(151 /* UndefinedKeyword */); } if (type.flags & 65536 /* Null */) { context.approximateLength += 4; @@ -47609,15 +49191,15 @@ var ts; } if (type.flags & 131072 /* Never */) { context.approximateLength += 5; - return ts.factory.createKeywordTypeNode(141 /* NeverKeyword */); + return ts.factory.createKeywordTypeNode(142 /* NeverKeyword */); } if (type.flags & 4096 /* ESSymbol */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(148 /* SymbolKeyword */); + return ts.factory.createKeywordTypeNode(149 /* SymbolKeyword */); } if (type.flags & 67108864 /* NonPrimitive */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(145 /* ObjectKeyword */); + return ts.factory.createKeywordTypeNode(146 /* ObjectKeyword */); } if (isThisTypeParameter(type)) { if (context.flags & 4194304 /* InObjectTypeLiteral */) { @@ -47687,7 +49269,7 @@ var ts; var indexedType = type.type; context.approximateLength += 6; var indexTypeNode = typeToTypeNodeHelper(indexedType, context); - return ts.factory.createTypeOperatorNode(138 /* KeyOfKeyword */, indexTypeNode); + return ts.factory.createTypeOperatorNode(139 /* KeyOfKeyword */, indexTypeNode); } if (type.flags & 134217728 /* TemplateLiteral */) { var texts_1 = type.texts; @@ -47744,14 +49326,14 @@ 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` - appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(138 /* KeyOfKeyword */, typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context)); + appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(139 /* KeyOfKeyword */, 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(getTemplateTypeFromMappedType(type), context); + var templateTypeNode = typeToTypeNodeHelper(removeMissingType(getTemplateTypeFromMappedType(type), !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), context); var mappedTypeNode = ts.factory.createMappedTypeNode(readonlyToken, typeParameterNode, nameTypeNode, questionToken, templateTypeNode); context.approximateLength += 10; return ts.setEmitFlags(mappedTypeNode, 1 /* SingleLine */); @@ -47767,7 +49349,9 @@ var ts; return symbolToTypeNode(symbol, context, isInstanceType); } // Always use 'typeof T' for type of class, enum, and module objects - else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 221 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || + else if (symbol.flags & 32 /* Class */ + && !getBaseTypeVariableOfClass(symbol) + && !(symbol.valueDeclaration && symbol.valueDeclaration.kind === 223 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, isInstanceType); @@ -47798,7 +49382,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 297 /* SourceFile */ || declaration.parent.kind === 257 /* ModuleBlock */; + return declaration.parent.kind === 299 /* SourceFile */ || declaration.parent.kind === 259 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -47808,6 +49392,7 @@ var ts; } } 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) : @@ -47821,6 +49406,19 @@ var ts; if (id && !context.symbolDepth) { context.symbolDepth = new ts.Map(); } + var links = context.enclosingDeclaration && getNodeLinks(context.enclosingDeclaration); + var key = getTypeId(type) + "|" + context.flags; + if (links) { + links.serializedTypes || (links.serializedTypes = new ts.Map()); + } + var cachedResult = (_a = links === null || links === void 0 ? void 0 : links.serializedTypes) === null || _a === void 0 ? void 0 : _a.get(key); + if (cachedResult) { + if (cachedResult.truncating) { + context.truncating = true; + } + context.approximateLength += cachedResult.addedLength; + return deepCloneOrReuseNode(cachedResult); + } var depth; if (id) { depth = context.symbolDepth.get(id) || 0; @@ -47830,12 +49428,27 @@ var ts; context.symbolDepth.set(id, depth + 1); } context.visitedTypes.add(typeId); + var startLength = context.approximateLength; var result = transform(type); + var addedLength = context.approximateLength - startLength; + if (!context.reportedDiagnostic && !context.encounteredError) { + if (context.truncating) { + result.truncating = true; + } + result.addedLength = addedLength; + (_b = links === null || links === void 0 ? void 0 : links.serializedTypes) === null || _b === void 0 ? void 0 : _b.set(key, result); + } context.visitedTypes.delete(typeId); if (id) { context.symbolDepth.set(id, depth); } return result; + function deepCloneOrReuseNode(node) { + if (!ts.nodeIsSynthesized(node) && ts.getParseTreeNode(node) === node) { + return node; + } + return ts.setTextRange(ts.factory.cloneNode(ts.visitEachChild(node, deepCloneOrReuseNode, ts.nullTransformationContext)), node); + } } function createTypeNodeFromObjectType(type) { if (isGenericMappedType(type) || type.containsError) { @@ -47849,12 +49462,12 @@ var ts; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 174 /* FunctionType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 176 /* FunctionType */, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 175 /* ConstructorType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 177 /* ConstructorType */, context); return signatureNode; } } @@ -47898,9 +49511,10 @@ var ts; } var elementType = typeToTypeNodeHelper(typeArguments[0], context); var arrayType = ts.factory.createArrayTypeNode(elementType); - return type.target === globalArrayType ? arrayType : ts.factory.createTypeOperatorNode(142 /* ReadonlyKeyword */, arrayType); + return type.target === globalArrayType ? arrayType : ts.factory.createTypeOperatorNode(143 /* 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 */)); }); if (typeArguments.length > 0) { var arity = getTypeReferenceArity(type); var tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, arity), context); @@ -47922,12 +49536,12 @@ var ts; } } var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode(tupleConstituentNodes), 1 /* SingleLine */); - return type.target.readonly ? ts.factory.createTypeOperatorNode(142 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + return type.target.readonly ? ts.factory.createTypeOperatorNode(143 /* 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(142 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + return type.target.readonly ? ts.factory.createTypeOperatorNode(143 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } context.encounteredError = true; return undefined; // TODO: GH#18217 @@ -48034,17 +49648,17 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 169 /* CallSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 171 /* CallSignature */, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; if (signature.flags & 4 /* Abstract */) continue; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 170 /* ConstructSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 172 /* ConstructSignature */, context)); } if (resolvedType.stringIndexInfo) { var indexSignature = void 0; - if (resolvedType.objectFlags & 2048 /* ReverseMapped */) { + if (resolvedType.objectFlags & 1024 /* ReverseMapped */) { indexSignature = indexInfoToIndexSignatureDeclarationHelper(createIndexInfo(anyType, resolvedType.stringIndexInfo.isReadonly, resolvedType.stringIndexInfo.declaration), 0 /* String */, context, createElidedInformationPlaceholder(context)); } else { @@ -48086,17 +49700,31 @@ var ts; if (!(context.flags & 1 /* NoTruncation */)) { return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier("..."), /*typeArguments*/ undefined); } - return ts.factory.createKeywordTypeNode(128 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(129 /* AnyKeyword */); + } + function shouldUsePlaceholderForProperty(propertySymbol, context) { + var _a; + // Use placeholders for reverse mapped types we've either already descended into, or which + // are nested reverse mappings within a mapping over a non-anonymous type. The later is a restriction mostly just to + // reduce the blowup in printback size from doing, eg, a deep reverse mapping over `Window`. + // 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 */) + && (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 */))); } function addPropertyToElementList(propertySymbol, context, typeElements) { + var _a; var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */); - var propertyType = propertyIsReverseMapped && context.flags & 33554432 /* InReverseMappedType */ ? - anyType : getTypeOfSymbol(propertySymbol); + var propertyType = shouldUsePlaceholderForProperty(propertySymbol, context) ? + anyType : getNonMissingTypeOfSymbol(propertySymbol); var saveEnclosingDeclaration = context.enclosingDeclaration; context.enclosingDeclaration = undefined; if (context.tracker.trackSymbol && ts.getCheckFlags(propertySymbol) & 4096 /* Late */ && isLateBoundName(propertySymbol.escapedName)) { var decl = ts.first(propertySymbol.declarations); - if (hasLateBindableName(decl)) { + if (propertySymbol.declarations && hasLateBindableName(decl)) { if (ts.isBinaryExpression(decl)) { var name = ts.getNameOfDeclaration(decl); if (name && ts.isElementAccessExpression(name) && ts.isPropertyAccessEntityNameExpression(name.argumentExpression)) { @@ -48108,30 +49736,35 @@ var ts; } } } - context.enclosingDeclaration = saveEnclosingDeclaration; + context.enclosingDeclaration = propertySymbol.valueDeclaration || ((_a = propertySymbol.declarations) === null || _a === void 0 ? void 0 : _a[0]) || saveEnclosingDeclaration; 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 */); for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { var signature = signatures_1[_i]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 164 /* MethodSignature */, context, { name: propertyName, questionToken: optionalToken }); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 166 /* MethodSignature */, context, { name: propertyName, questionToken: optionalToken }); typeElements.push(preserveCommentsOn(methodDeclaration)); } } else { - var savedFlags = context.flags; - context.flags |= propertyIsReverseMapped ? 33554432 /* InReverseMappedType */ : 0; var propertyTypeNode = void 0; - if (propertyIsReverseMapped && !!(savedFlags & 33554432 /* InReverseMappedType */)) { + if (shouldUsePlaceholderForProperty(propertySymbol, context)) { propertyTypeNode = createElidedInformationPlaceholder(context); } else { - propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.factory.createKeywordTypeNode(128 /* AnyKeyword */); + if (propertyIsReverseMapped) { + context.reverseMappedStack || (context.reverseMappedStack = []); + context.reverseMappedStack.push(propertySymbol); + } + propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.factory.createKeywordTypeNode(129 /* AnyKeyword */); + if (propertyIsReverseMapped) { + context.reverseMappedStack.pop(); + } } - context.flags = savedFlags; - var modifiers = isReadonlySymbol(propertySymbol) ? [ts.factory.createToken(142 /* ReadonlyKeyword */)] : undefined; + var modifiers = isReadonlySymbol(propertySymbol) ? [ts.factory.createToken(143 /* ReadonlyKeyword */)] : undefined; if (modifiers) { context.approximateLength += 9; } @@ -48139,9 +49772,10 @@ var ts; typeElements.push(preserveCommentsOn(propertySignature)); } function preserveCommentsOn(node) { - if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 333 /* JSDocPropertyTag */; })) { - var d = ts.find(propertySymbol.declarations, function (d) { return d.kind === 333 /* JSDocPropertyTag */; }); - var commentText = d.comment; + var _a; + if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 341 /* JSDocPropertyTag */; })) { + var d = (_a = propertySymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 341 /* 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 }]); } @@ -48170,25 +49804,25 @@ var ts; var mayHaveNameCollisions = !(context.flags & 64 /* 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_4 = []; + var result_5 = []; var i = 0; for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { var type = types_2[_i]; i++; if (checkTruncationLength(context) && (i + 2 < types.length - 1)) { - result_4.push(ts.factory.createTypeReferenceNode("... " + (types.length - i) + " more ...", /*typeArguments*/ undefined)); + result_5.push(ts.factory.createTypeReferenceNode("... " + (types.length - i) + " more ...", /*typeArguments*/ undefined)); var typeNode_1 = typeToTypeNodeHelper(types[types.length - 1], context); if (typeNode_1) { - result_4.push(typeNode_1); + result_5.push(typeNode_1); } break; } context.approximateLength += 2; // Account for whitespace + separator var typeNode = typeToTypeNodeHelper(type, context); if (typeNode) { - result_4.push(typeNode); + result_5.push(typeNode); if (seenNames && ts.isIdentifierTypeReference(typeNode)) { - seenNames.add(typeNode.typeName.escapedText, [type, result_4.length - 1]); + seenNames.add(typeNode.typeName.escapedText, [type, result_5.length - 1]); } } } @@ -48210,13 +49844,13 @@ var ts; })) { for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { var _a = types_3[_i], type = _a[0], resultIndex = _a[1]; - result_4[resultIndex] = typeToTypeNodeHelper(type, context); + result_5[resultIndex] = typeToTypeNodeHelper(type, context); } } }); context.flags = saveContextFlags; } - return result_4; + return result_5; } } function typesAreSameReference(a, b) { @@ -48226,7 +49860,7 @@ var ts; } function indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context, typeNode) { var name = ts.getNameFromIndexInfo(indexInfo) || "x"; - var indexerTypeNode = ts.factory.createKeywordTypeNode(kind === 0 /* String */ ? 147 /* StringKeyword */ : 144 /* NumberKeyword */); + var indexerTypeNode = ts.factory.createKeywordTypeNode(kind === 0 /* String */ ? 148 /* StringKeyword */ : 145 /* NumberKeyword */); var indexingParameter = ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -48241,13 +49875,14 @@ var ts; } context.approximateLength += (name.length + 4); return ts.factory.createIndexSignature( - /*decorators*/ undefined, indexInfo.isReadonly ? [ts.factory.createToken(142 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); + /*decorators*/ undefined, indexInfo.isReadonly ? [ts.factory.createToken(143 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); } function signatureToSignatureDeclarationHelper(signature, kind, context, options) { var _a, _b, _c, _d; var suppressAny = context.flags & 256 /* SuppressAnyReturnType */; if (suppressAny) context.flags &= ~256 /* 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) { @@ -48258,7 +49893,7 @@ 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 === 166 /* Constructor */, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); }); + 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 === 168 /* Constructor */, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -48267,7 +49902,7 @@ var ts; var typePredicate = getTypePredicateOfSignature(signature); if (typePredicate) { var assertsModifier = typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? - ts.factory.createToken(127 /* AssertsKeyword */) : + ts.factory.createToken(128 /* AssertsKeyword */) : undefined; var parameterName = typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.setEmitFlags(ts.factory.createIdentifier(typePredicate.parameterName), 16777216 /* NoAsciiEscaping */) : @@ -48281,29 +49916,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(128 /* AnyKeyword */); + returnTypeNode = ts.factory.createKeywordTypeNode(129 /* AnyKeyword */); } } var modifiers = options === null || options === void 0 ? void 0 : options.modifiers; - if ((kind === 175 /* ConstructorType */) && signature.flags & 4 /* Abstract */) { + if ((kind === 177 /* ConstructorType */) && signature.flags & 4 /* Abstract */) { var flags = ts.modifiersToFlags(modifiers); modifiers = ts.factory.createModifiersFromModifierFlags(flags | 128 /* Abstract */); } - context.approximateLength += 3; // Usually a signature contributes a few more characters than this, but 3 is the minimum - var node = kind === 169 /* CallSignature */ ? ts.factory.createCallSignature(typeParameters, parameters, returnTypeNode) : - kind === 170 /* ConstructSignature */ ? ts.factory.createConstructSignature(typeParameters, parameters, returnTypeNode) : - kind === 164 /* 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 === 165 /* MethodDeclaration */ ? ts.factory.createMethodDeclaration(/*decorators*/ undefined, 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 === 166 /* Constructor */ ? ts.factory.createConstructorDeclaration(/*decorators*/ undefined, modifiers, parameters, /*body*/ undefined) : - kind === 167 /* GetAccessor */ ? ts.factory.createGetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_c = options === null || options === void 0 ? void 0 : options.name) !== null && _c !== void 0 ? _c : ts.factory.createIdentifier(""), parameters, returnTypeNode, /*body*/ undefined) : - kind === 168 /* SetAccessor */ ? ts.factory.createSetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_d = options === null || options === void 0 ? void 0 : options.name) !== null && _d !== void 0 ? _d : ts.factory.createIdentifier(""), parameters, /*body*/ undefined) : - kind === 171 /* IndexSignature */ ? ts.factory.createIndexSignature(/*decorators*/ undefined, modifiers, parameters, returnTypeNode) : - kind === 308 /* JSDocFunctionType */ ? ts.factory.createJSDocFunctionType(parameters, returnTypeNode) : - kind === 174 /* FunctionType */ ? ts.factory.createFunctionTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : - kind === 175 /* ConstructorType */ ? ts.factory.createConstructorTypeNode(modifiers, typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : - kind === 251 /* FunctionDeclaration */ ? ts.factory.createFunctionDeclaration(/*decorators*/ undefined, 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 === 208 /* 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 === 209 /* ArrowFunction */ ? ts.factory.createArrowFunction(modifiers, typeParameters, parameters, returnTypeNode, /*equalsGreaterThanToken*/ undefined, ts.factory.createBlock([])) : + var node = kind === 171 /* CallSignature */ ? ts.factory.createCallSignature(typeParameters, parameters, returnTypeNode) : + kind === 172 /* ConstructSignature */ ? ts.factory.createConstructSignature(typeParameters, parameters, returnTypeNode) : + kind === 166 /* 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 === 167 /* MethodDeclaration */ ? ts.factory.createMethodDeclaration(/*decorators*/ undefined, 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 === 168 /* Constructor */ ? ts.factory.createConstructorDeclaration(/*decorators*/ undefined, modifiers, parameters, /*body*/ undefined) : + kind === 169 /* GetAccessor */ ? ts.factory.createGetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_c = options === null || options === void 0 ? void 0 : options.name) !== null && _c !== void 0 ? _c : ts.factory.createIdentifier(""), parameters, returnTypeNode, /*body*/ undefined) : + kind === 170 /* SetAccessor */ ? ts.factory.createSetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_d = options === null || options === void 0 ? void 0 : options.name) !== null && _d !== void 0 ? _d : ts.factory.createIdentifier(""), parameters, /*body*/ undefined) : + kind === 173 /* IndexSignature */ ? ts.factory.createIndexSignature(/*decorators*/ undefined, modifiers, parameters, returnTypeNode) : + kind === 311 /* JSDocFunctionType */ ? ts.factory.createJSDocFunctionType(parameters, returnTypeNode) : + kind === 176 /* FunctionType */ ? ts.factory.createFunctionTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : + kind === 177 /* ConstructorType */ ? ts.factory.createConstructorTypeNode(modifiers, typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : + kind === 253 /* FunctionDeclaration */ ? ts.factory.createFunctionDeclaration(/*decorators*/ undefined, 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 === 210 /* 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 === 211 /* 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); @@ -48325,9 +49959,9 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags, privateSymbolVisitor, bundledImports) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 160 /* Parameter */); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 162 /* Parameter */); if (!parameterDeclaration && !ts.isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 326 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 334 /* JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -48341,8 +49975,8 @@ var ts; var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* RestParameter */; var dotDotDotToken = isRest ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined; var name = parameterDeclaration ? parameterDeclaration.name ? - parameterDeclaration.name.kind === 78 /* Identifier */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : - parameterDeclaration.name.kind === 157 /* QualifiedName */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 79 /* Identifier */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 159 /* QualifiedName */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : cloneBindingName(parameterDeclaration.name) : ts.symbolName(parameterSymbol) : ts.symbolName(parameterSymbol); @@ -48507,11 +50141,11 @@ var ts; } function getSpecifierForModuleSymbol(symbol, context) { var _a; - var file = ts.getDeclarationOfKind(symbol, 297 /* SourceFile */); + var file = ts.getDeclarationOfKind(symbol, 299 /* SourceFile */); if (!file) { var equivalentFileSymbol = ts.firstDefined(symbol.declarations, function (d) { return getFileSymbolIfFileSymbolExportEqualsContainer(d, symbol); }); if (equivalentFileSymbol) { - file = ts.getDeclarationOfKind(equivalentFileSymbol, 297 /* SourceFile */); + file = ts.getDeclarationOfKind(equivalentFileSymbol, 299 /* SourceFile */); } } if (file && file.moduleName !== undefined) { @@ -48522,8 +50156,8 @@ var ts; if (context.tracker.trackReferencedAmbientModule) { var ambientDecls = ts.filter(symbol.declarations, ts.isAmbientModule); if (ts.length(ambientDecls)) { - for (var _i = 0, ambientDecls_1 = ambientDecls; _i < ambientDecls_1.length; _i++) { - var decl = ambientDecls_1[_i]; + for (var _i = 0, _b = ambientDecls; _i < _b.length; _i++) { + var decl = _b[_i]; context.tracker.trackReferencedAmbientModule(decl, symbol); } } @@ -48550,7 +50184,7 @@ var ts; // specifier preference var moduleResolverHost = context.tracker.moduleResolverHost; var specifierCompilerOptions = isBundle_1 ? __assign(__assign({}, compilerOptions), { baseUrl: moduleResolverHost.getCommonSourceDirectory() }) : compilerOptions; - specifier = ts.first(ts.moduleSpecifiers.getModuleSpecifiers(symbol, checker, specifierCompilerOptions, contextFile, moduleResolverHost, { importModuleSpecifierPreference: isBundle_1 ? "non-relative" : "relative", importModuleSpecifierEnding: isBundle_1 ? "minimal" : undefined })); + specifier = ts.first(ts.moduleSpecifiers.getModuleSpecifiers(symbol, checker, specifierCompilerOptions, contextFile, moduleResolverHost, { importModuleSpecifierPreference: isBundle_1 ? "non-relative" : "project-relative", importModuleSpecifierEnding: isBundle_1 ? "minimal" : undefined })); (_a = links.specifierCache) !== null && _a !== void 0 ? _a : (links.specifierCache = new ts.Map()); links.specifierCache.set(contextFile.path, specifier); } @@ -48663,7 +50297,7 @@ var ts; return false; } function typeParameterToName(type, context) { - var _a; + var _a, _b; if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && context.typeParameterNames) { var cached = context.typeParameterNames.get(getTypeId(type)); if (cached) { @@ -48671,22 +50305,25 @@ var ts; } } var result = symbolToName(type.symbol, context, 788968 /* Type */, /*expectsIdentifier*/ true); - if (!(result.kind & 78 /* Identifier */)) { + if (!(result.kind & 79 /* Identifier */)) { return ts.factory.createIdentifier("(Missing type parameter)"); } if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { var rawtext = result.escapedText; - var i = 0; + var i = ((_a = context.typeParameterNamesByTextNextNameCount) === null || _a === void 0 ? void 0 : _a.get(rawtext)) || 0; var text = rawtext; - while (((_a = context.typeParameterNamesByText) === null || _a === void 0 ? void 0 : _a.has(text)) || typeParameterShadowsNameInScope(text, context, type)) { + while (((_b = context.typeParameterNamesByText) === null || _b === void 0 ? void 0 : _b.has(text)) || typeParameterShadowsNameInScope(text, context, type)) { i++; text = rawtext + "_" + i; } if (text !== rawtext) { result = ts.factory.createIdentifier(text, result.typeArguments); } + // avoiding iterations of the above loop turns out to be worth it when `i` starts to get large, so we cache the max + // `i` we've used thus far, to save work later + (context.typeParameterNamesByTextNextNameCount || (context.typeParameterNamesByTextNextNameCount = new ts.Map())).set(rawtext, i); (context.typeParameterNames || (context.typeParameterNames = new ts.Map())).set(getTypeId(type), result); - (context.typeParameterNamesByText || (context.typeParameterNamesByText = new ts.Set())).add(result.escapedText); + (context.typeParameterNamesByText || (context.typeParameterNamesByText = new ts.Set())).add(rawtext); } return result; } @@ -48694,7 +50331,7 @@ var ts; var chain = lookupSymbolChain(symbol, context, meaning); if (expectsIdentifier && chain.length !== 1 && !context.encounteredError - && !(context.flags & 65536 /* AllowQualifedNameInPlaceOfIdentifier */)) { + && !(context.flags & 65536 /* AllowQualifiedNameInPlaceOfIdentifier */)) { context.encounteredError = true; } return createEntityNameFromSymbolChain(chain, chain.length - 1); @@ -48774,9 +50411,6 @@ var ts; if (fromNameType) { return fromNameType; } - if (ts.isKnownSymbol(symbol)) { - return ts.factory.createComputedPropertyName(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("Symbol"), symbol.escapedName.substr(3))); - } var rawName = ts.unescapeLeadingUnderscores(symbol.escapedName); var stringNamed = !!ts.length(symbol.declarations) && ts.every(symbol.declarations, isStringNamed); return createPropertyNameNodeForIdentifierOrLiteral(rawName, stringNamed, singleQuote); @@ -48828,6 +50462,7 @@ var ts; if (initial.typeParameterSymbolList) { initial.typeParameterSymbolList = new ts.Set(initial.typeParameterSymbolList); } + initial.tracker = wrapSymbolTrackerToReportForContext(initial, initial.tracker); return initial; } function getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration) { @@ -48843,13 +50478,13 @@ var ts; function serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled) { if (type !== errorType && enclosingDeclaration) { var declWithExistingAnnotation = getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration); - if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation)) { + if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation) && !ts.isGetAccessorDeclaration(declWithExistingAnnotation)) { // try to reuse the existing annotation var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation); if (getTypeFromTypeNode(existing) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) { - var result_5 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled); - if (result_5) { - return result_5; + var result_6 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled); + if (result_6) { + return result_6; } } } @@ -48866,10 +50501,14 @@ var ts; function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) { if (type !== errorType && context.enclosingDeclaration) { var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); - if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation && instantiateType(getTypeFromTypeNode(annotation), signature.mapper) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) { - var result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled); - if (result) { - return result; + 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; + if (thisInstantiated === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) { + var result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled); + if (result) { + return result; + } } } } @@ -48913,17 +50552,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 === 310 /* JSDocNamepathType */) { - return ts.factory.createKeywordTypeNode(128 /* AnyKeyword */); + if (ts.isJSDocAllType(node) || node.kind === 313 /* JSDocNamepathType */) { + return ts.factory.createKeywordTypeNode(129 /* AnyKeyword */); } if (ts.isJSDocUnknownType(node)) { - return ts.factory.createKeywordTypeNode(152 /* UnknownKeyword */); + return ts.factory.createKeywordTypeNode(153 /* 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(150 /* UndefinedKeyword */)]); + return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createKeywordTypeNode(151 /* UndefinedKeyword */)]); } if (ts.isJSDocNonNullableType(node)) { return ts.visitNode(node.type, visitExistingNodeTreeSymbols); @@ -48937,11 +50576,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(128 /* AnyKeyword */)); + /*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(129 /* AnyKeyword */)); })); } if (ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "") { - return ts.setOriginalNode(ts.factory.createKeywordTypeNode(128 /* AnyKeyword */), node); + return ts.setOriginalNode(ts.factory.createKeywordTypeNode(129 /* AnyKeyword */), node); } if ((ts.isExpressionWithTypeArguments(node) || ts.isTypeReferenceNode(node)) && ts.isJSDocIndexSignature(node)) { return ts.factory.createTypeLiteralNode([ts.factory.createIndexSignature( @@ -48958,13 +50597,13 @@ var ts; return ts.factory.createConstructorTypeNode(node.modifiers, 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( /*decorators*/ undefined, /*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(128 /* AnyKeyword */)); + /*initializer*/ undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(129 /* AnyKeyword */)); } else { return ts.factory.createFunctionTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.map(node.parameters, function (p, i) { return ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, getEffectiveDotDotDotForParameter(p), getNameForJSDocFunctionParameter(p, i), p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), - /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(128 /* AnyKeyword */)); + /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(129 /* AnyKeyword */)); } } if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(getTypeReferenceName(node), 788968 /* Type */, /*ignoreErrors*/ true))) { @@ -49032,8 +50671,8 @@ var ts; } } function symbolTableToDeclarationStatements(symbolTable, context, bundled) { - var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.factory.createPropertyDeclaration, 165 /* MethodDeclaration */, /*useAcessors*/ true); - var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type) { return ts.factory.createPropertySignature(mods, name, question, type); }, 164 /* MethodSignature */, /*useAcessors*/ false); + var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.factory.createPropertyDeclaration, 167 /* MethodDeclaration */, /*useAcessors*/ true); + var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type) { return ts.factory.createPropertySignature(mods, name, question, type); }, 166 /* 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 @@ -49045,7 +50684,7 @@ var ts; var deferredPrivatesStack = []; 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); + var accessibleResult = isSymbolAccessible(sym, decl, meaning, /*computeAliases*/ false); if (accessibleResult.accessibility === 0 /* 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); @@ -49054,9 +50693,11 @@ var ts; } } else if (oldcontext.tracker && oldcontext.tracker.trackSymbol) { - oldcontext.tracker.trackSymbol(sym, decl, meaning); + return oldcontext.tracker.trackSymbol(sym, decl, meaning); } + return false; } }) }); + context.tracker = wrapSymbolTrackerToReportForContext(context, context.tracker); ts.forEachEntry(symbolTable, function (symbol, name) { var baseName = ts.unescapeLeadingUnderscores(name); void getInternalSymbolName(symbol, baseName); // Called to cache values into `usedSymbolNames` and `remappedSymbolNames` @@ -49071,7 +50712,7 @@ var ts; visitSymbolTable(symbolTable); return mergeRedundantStatements(results); function isIdentifierAndNotUndefined(node) { - return !!node && node.kind === 78 /* Identifier */; + return !!node && node.kind === 79 /* Identifier */; } function getNamesOfDeclaration(statement) { if (ts.isVariableStatement(statement)) { @@ -49240,6 +50881,9 @@ var ts; var oldContext = context; context = cloneNodeBuilderContext(context); var result = serializeSymbolWorker(symbol, isPrivate, propertyAsAlias); + if (context.reportedDiagnostic) { + oldcontext.reportedDiagnostic = context.reportedDiagnostic; // hoist diagnostic result into outer context + } context = oldContext; return result; } @@ -49254,6 +50898,7 @@ var ts; // If it's a class/interface/function: emit a class/interface/function with a `default` modifier // These forms can merge, eg (`export default 12; export default interface A {}`) function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias) { + var _a, _b; var symbolName = ts.unescapeLeadingUnderscores(symbol.escapedName); var isDefault = symbol.escapedName === "default" /* Default */; if (isPrivate && !(context.flags & 131072 /* AllowAnonymousIdentifier */) && ts.isStringANonContextualKeyword(symbolName) && !isDefault) { @@ -49312,9 +50957,9 @@ var ts; if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) { textRange = textRange.parent.parent; } - var propertyAccessRequire = ts.find(symbol.declarations, ts.isPropertyAccessExpression); + var propertyAccessRequire = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isPropertyAccessExpression); if (propertyAccessRequire && ts.isBinaryExpression(propertyAccessRequire.parent) && ts.isIdentifier(propertyAccessRequire.parent.right) - && type.symbol && ts.isSourceFile(type.symbol.valueDeclaration)) { + && ((_b = type.symbol) === null || _b === void 0 ? void 0 : _b.valueDeclaration) && ts.isSourceFile(type.symbol.valueDeclaration)) { var alias = localName === propertyAccessRequire.parent.right.escapedText ? undefined : propertyAccessRequire.parent.right; addResult(ts.factory.createExportDeclaration( /*decorators*/ undefined, @@ -49364,7 +51009,10 @@ var ts; serializeEnum(symbol, symbolName, modifierFlags); } if (symbol.flags & 32 /* Class */) { - if (symbol.flags & 4 /* Property */ && ts.isBinaryExpression(symbol.valueDeclaration.parent) && ts.isClassExpression(symbol.valueDeclaration.parent.right)) { + if (symbol.flags & 4 /* Property */ + && symbol.valueDeclaration + && ts.isBinaryExpression(symbol.valueDeclaration.parent) + && ts.isClassExpression(symbol.valueDeclaration.parent.right)) { // Looks like a `module.exports.Sub = class {}` - if we serialize `symbol` as a class, the result will have no members, // since the classiness is actually from the target of the effective alias the symbol is. yes. A BlockScopedVariable|Class|Property // _really_ acts like an Alias, and none of a BlockScopedVariable, Class, or Property. This is the travesty of JS binding today. @@ -49390,12 +51038,14 @@ var ts; if (symbol.flags & 8388608 /* ExportStar */) { // synthesize export * from "moduleReference" // Straightforward - only one thing to do - make an export declaration - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var node = _a[_i]; - var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); - if (!resolvedModule) - continue; - addResult(ts.factory.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, /*exportClause*/ undefined, ts.factory.createStringLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0 /* None */); + if (symbol.declarations) { + for (var _i = 0, _c = symbol.declarations; _i < _c.length; _i++) { + var node = _c[_i]; + var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); + if (!resolvedModule) + continue; + addResult(ts.factory.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, /*exportClause*/ undefined, ts.factory.createStringLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0 /* None */); + } } } if (needsPostExportDefault) { @@ -49433,15 +51083,16 @@ var ts; function addResult(node, additionalModifierFlags) { if (ts.canHaveModifiers(node)) { var newModifierFlags = 0 /* None */; + var enclosingDeclaration_1 = context.enclosingDeclaration && + (ts.isJSDocTypeAlias(context.enclosingDeclaration) ? ts.getSourceFileOfNode(context.enclosingDeclaration) : context.enclosingDeclaration); if (additionalModifierFlags & 1 /* Export */ && - context.enclosingDeclaration && - (isExportingScope(context.enclosingDeclaration) || ts.isModuleDeclaration(context.enclosingDeclaration)) && + 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 */; } if (addingDeclare && !(newModifierFlags & 1 /* Export */) && - (!context.enclosingDeclaration || !(context.enclosingDeclaration.flags & 8388608 /* Ambient */)) && + (!enclosingDeclaration_1 || !(enclosingDeclaration_1.flags & 8388608 /* 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 */; @@ -49456,19 +51107,23 @@ var ts; results.push(node); } function serializeTypeAlias(symbol, symbolName, modifierFlags) { + var _a; var aliasType = getDeclaredTypeOfTypeAlias(symbol); var typeParams = getSymbolLinks(symbol).typeParameters; var typeParamDecls = ts.map(typeParams, function (p) { return typeParameterToDeclaration(p, context); }); - var jsdocAliasDecl = ts.find(symbol.declarations, ts.isJSDocTypeAlias); - var commentText = jsdocAliasDecl ? jsdocAliasDecl.comment || jsdocAliasDecl.parent.comment : undefined; + 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 */; + 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(/*decorators*/ undefined, /*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); context.flags = oldFlags; + context.enclosingDeclaration = oldEnclosingDecl; } function serializeInterface(symbol, symbolName, modifierFlags) { var interfaceType = getDeclaredTypeOfClassOrInterface(symbol); @@ -49477,10 +51132,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, 169 /* CallSignature */); - var constructSignatures = serializeSignatures(1 /* Construct */, interfaceType, baseType, 170 /* ConstructSignature */); + var callSignatures = serializeSignatures(0 /* Call */, interfaceType, baseType, 171 /* CallSignature */); + var constructSignatures = serializeSignatures(1 /* Construct */, interfaceType, baseType, 172 /* ConstructSignature */); var indexSignatures = serializeIndexSignatures(interfaceType, baseType); - var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.factory.createHeritageClause(93 /* ExtendsKeyword */, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b, 111551 /* Value */); }))]; + var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.factory.createHeritageClause(94 /* ExtendsKeyword */, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b, 111551 /* Value */); }))]; addResult(ts.factory.createInterfaceDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, heritageClauses, __spreadArray(__spreadArray(__spreadArray(__spreadArray([], indexSignatures), constructSignatures), callSignatures), members)), modifierFlags); @@ -49547,9 +51202,8 @@ var ts; 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, 251 /* FunctionDeclaration */, context, { name: ts.factory.createIdentifier(localName), privateSymbolVisitor: includePrivateSymbol, bundledImports: bundled }); - // for expressions assigned to `var`s, use the `var` as the text range - addResult(ts.setTextRange(decl, sig.declaration && ts.isVariableDeclaration(sig.declaration.parent) && sig.declaration.parent.parent || sig.declaration), modifierFlags); + var decl = signatureToSignatureDeclarationHelper(sig, 253 /* 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)) { @@ -49557,6 +51211,18 @@ var ts; 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 */) { + return signature.declaration.parent; + } + // for expressions assigned to `var`s, use the `var` as the text range + if (ts.isVariableDeclaration(signature.declaration.parent) && signature.declaration.parent.parent) { + return signature.declaration.parent.parent; + } + } + return signature.declaration; + } function serializeAsNamespaceDeclaration(props, localName, modifierFlags, suppressNewPrivateContext) { if (ts.length(props)) { var localVsRemoteMap = ts.arrayToMultiMap(props, function (p) { @@ -49643,8 +51309,8 @@ var ts; return undefined; } function serializeAsClass(symbol, localName, modifierFlags) { - var _a; - var originalDecl = ts.find(symbol.declarations, ts.isClassLike); + var _a, _b; + var originalDecl = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isClassLike); var oldEnclosing = context.enclosingDeclaration; context.enclosingDeclaration = originalDecl || oldEnclosing; var localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -49655,25 +51321,25 @@ var ts; var implementsExpressions = originalImplements && sanitizeJSDocImplements(originalImplements) || ts.mapDefined(getImplementsTypes(classType), serializeImplementedType); var staticType = getTypeOfSymbol(symbol); - var isClass = !!((_a = staticType.symbol) === null || _a === void 0 ? void 0 : _a.valueDeclaration) && ts.isClassLike(staticType.symbol.valueDeclaration); + var isClass = !!((_b = staticType.symbol) === null || _b === void 0 ? void 0 : _b.valueDeclaration) && ts.isClassLike(staticType.symbol.valueDeclaration); var staticBaseType = isClass ? getBaseConstructorTypeOfClass(staticType) : anyType; - var heritageClauses = __spreadArray(__spreadArray([], !ts.length(baseTypes) ? [] : [ts.factory.createHeritageClause(93 /* ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))]), !ts.length(implementsExpressions) ? [] : [ts.factory.createHeritageClause(116 /* ImplementsKeyword */, implementsExpressions)]); + var heritageClauses = __spreadArray(__spreadArray([], !ts.length(baseTypes) ? [] : [ts.factory.createHeritageClause(94 /* ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))]), !ts.length(implementsExpressions) ? [] : [ts.factory.createHeritageClause(117 /* ImplementsKeyword */, implementsExpressions)]); var symbolProps = getNonInterhitedProperties(classType, baseTypes, getPropertiesOfType(classType)); var publicSymbolProps = ts.filter(symbolProps, function (s) { // `valueDeclaration` could be undefined if inherited from // a union/intersection base type, but inherited properties // don't matter here. var valueDecl = s.valueDeclaration; - return valueDecl && !(ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name)); + return !!valueDecl && !(ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name)); }); var hasPrivateIdentifier = ts.some(symbolProps, function (s) { // `valueDeclaration` could be undefined if inherited from // a union/intersection base type, but inherited properties // don't matter here. var valueDecl = s.valueDeclaration; - return valueDecl && ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name); + return !!valueDecl && ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name); }); // Boil down all private properties into a single one. var privateProperties = hasPrivateIdentifier ? @@ -49696,7 +51362,7 @@ var ts; !ts.some(getSignaturesOfType(staticType, 1 /* Construct */)); var constructors = isNonConstructableClassLikeInJsFile ? [ts.factory.createConstructorDeclaration(/*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(8 /* Private */), [], /*body*/ undefined)] : - serializeSignatures(1 /* Construct */, staticType, staticBaseType, 166 /* Constructor */); + serializeSignatures(1 /* Construct */, staticType, staticBaseType, 168 /* Constructor */); var indexSignatures = serializeIndexSignatures(classType, baseTypes[0]); context.enclosingDeclaration = oldEnclosing; addResult(ts.setTextRange(ts.factory.createClassDeclaration( @@ -49723,8 +51389,8 @@ var ts; var targetName = getInternalSymbolName(target, verbatimTargetName); includePrivateSymbol(target); // the target may be within the same scope - attempt to serialize it first switch (node.kind) { - case 198 /* BindingElement */: - if (((_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.kind) === 249 /* VariableDeclaration */) { + case 200 /* BindingElement */: + if (((_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.kind) === 251 /* VariableDeclaration */) { // const { SomeClass } = require('./lib'); var specifier_1 = getSpecifierForModuleSymbol(target.parent || target, context); // './lib' var propertyName = node.propertyName; @@ -49736,13 +51402,13 @@ var ts; // 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 289 /* ShorthandPropertyAssignment */: - if (((_e = (_d = node.parent) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.kind) === 216 /* BinaryExpression */) { + case 291 /* ShorthandPropertyAssignment */: + if (((_e = (_d = node.parent) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.kind) === 218 /* BinaryExpression */) { // module.exports = { SomeClass } serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), targetName); } break; - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: // commonjs require: const x = require('y') if (ts.isPropertyAccessExpression(node.initializer)) { // const x = require('y').z @@ -49762,7 +51428,7 @@ var ts; break; } // else fall through and treat commonjs require just like import= - case 260 /* ImportEqualsDeclaration */: + case 262 /* 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)) { @@ -49779,13 +51445,13 @@ var ts; ? symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false) : ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)))), isLocalImport ? modifierFlags : 0 /* None */); break; - case 259 /* NamespaceExportDeclaration */: + case 261 /* 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 */); break; - case 262 /* ImportClause */: + case 264 /* ImportClause */: addResult(ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, ts.factory.createIdentifier(localName), /*namedBindings*/ undefined), @@ -49794,18 +51460,18 @@ var ts; // In such cases, the `target` refers to the module itself already ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context))), 0 /* None */); break; - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: addResult(ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*importClause*/ undefined, ts.factory.createNamespaceImport(ts.factory.createIdentifier(localName))), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* None */); break; - case 269 /* NamespaceExport */: + case 271 /* NamespaceExport */: addResult(ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, ts.factory.createNamespaceExport(ts.factory.createIdentifier(localName)), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* None */); break; - case 265 /* ImportSpecifier */: + case 267 /* ImportSpecifier */: addResult(ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause( @@ -49814,7 +51480,7 @@ var ts; ts.factory.createImportSpecifier(localName !== verbatimTargetName ? ts.factory.createIdentifier(verbatimTargetName) : undefined, ts.factory.createIdentifier(localName)) ])), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context))), 0 /* None */); break; - case 270 /* ExportSpecifier */: + case 272 /* 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; @@ -49822,12 +51488,12 @@ var ts; // another file serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), specifier ? verbatimTargetName : targetName, specifier && ts.isStringLiteralLike(specifier) ? ts.factory.createStringLiteral(specifier.text) : undefined); break; - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: serializeMaybeAliasAssignment(symbol); break; - case 216 /* BinaryExpression */: - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 218 /* BinaryExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* 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 @@ -49882,7 +51548,7 @@ var ts; // a visibility error here (as they're not visible within any scope), but we want to hoist them // into the containing scope anyway, so we want to skip the visibility checks. var oldTrack = context.tracker.trackSymbol; - context.tracker.trackSymbol = ts.noop; + context.tracker.trackSymbol = function () { return false; }; if (isExportAssignmentCompatibleSymbolName) { results.push(ts.factory.createExportAssignment( /*decorators*/ undefined, @@ -49961,6 +51627,7 @@ var ts; } function makeSerializePropertySymbol(createProperty, methodKind, useAccessors) { 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 */))) { @@ -49977,7 +51644,7 @@ var ts; } var flag = (modifierFlags & ~256 /* Async */) | (isStatic ? 32 /* Static */ : 0); var name = getPropertyNameNodeForSymbol(p, context); - var firstPropertyLikeDecl = ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isAccessor, ts.isVariableDeclaration, ts.isPropertySignature, ts.isBinaryExpression, ts.isPropertyAccessExpression)); + 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) { var result = []; if (p.flags & 65536 /* SetAccessor */) { @@ -49987,13 +51654,13 @@ var ts; /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "arg", /*questionToken*/ undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled))], - /*body*/ undefined), ts.find(p.declarations, ts.isSetAccessor) || firstPropertyLikeDecl)); + /*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 */; result.push(ts.setTextRange(ts.factory.createGetAccessorDeclaration( /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(flag), name, [], isPrivate_1 ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), - /*body*/ undefined), ts.find(p.declarations, ts.isGetAccessor) || firstPropertyLikeDecl)); + /*body*/ undefined), ((_c = p.declarations) === null || _c === void 0 ? void 0 : _c.find(ts.isGetAccessor)) || firstPropertyLikeDecl)); } return result; } @@ -50004,7 +51671,7 @@ var ts; /*decorators*/ undefined, 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), // TODO: https://github.com/microsoft/TypeScript/pull/32372#discussion_r328386357 // interface members can't have initializers, however class members _can_ - /*initializer*/ undefined), ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isVariableDeclaration)) || firstPropertyLikeDecl); + /*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 */)) { var type = getTypeOfSymbol(p); @@ -50013,7 +51680,7 @@ var ts; return ts.setTextRange(createProperty( /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | flag), name, p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, /*type*/ undefined, - /*initializer*/ undefined), ts.find(p.declarations, ts.isFunctionLikeDeclaration) || signatures[0] && signatures[0].declaration || p.declarations[0]); + /*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]); } var results_1 = []; for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { @@ -50024,7 +51691,8 @@ var ts; questionToken: p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, modifiers: flag ? ts.factory.createModifiersFromModifierFlags(flag) : undefined }); - results_1.push(ts.setTextRange(decl, sig.declaration)); + var location = sig.declaration && ts.isPrototypePropertyAssignment(sig.declaration.parent) ? sig.declaration.parent : sig.declaration; + results_1.push(ts.setTextRange(decl, location)); } return results_1; } @@ -50195,7 +51863,7 @@ var ts; if (flags === void 0) { flags = 16384 /* 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(127 /* 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 /* 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 printer = ts.createPrinter({ removeComments: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); @@ -50240,9 +51908,9 @@ var ts; return "public"; } function getTypeAliasForTypeLiteral(type) { - if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { + if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */ && type.symbol.declarations) { var node = ts.walkUpParenthesizedTypes(type.symbol.declarations[0].parent); - if (node.kind === 254 /* TypeAliasDeclaration */) { + if (node.kind === 256 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -50250,11 +51918,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 257 /* ModuleBlock */ && + node.parent.kind === 259 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 297 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 299 /* SourceFile */ || ts.isAmbientModule(location); } function getNameOfSymbolFromNameType(symbol, context) { var nameType = getSymbolLinks(symbol).nameType; @@ -50313,17 +51981,17 @@ var ts; if (!declaration) { declaration = symbol.declarations[0]; // Declaration may be nameless, but we'll try anyway } - if (declaration.parent && declaration.parent.kind === 249 /* VariableDeclaration */) { + if (declaration.parent && declaration.parent.kind === 251 /* VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } switch (declaration.kind) { - case 221 /* ClassExpression */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 223 /* ClassExpression */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { context.encounteredError = true; } - return declaration.kind === 221 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; + return declaration.kind === 223 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var name = getNameOfSymbolFromNameType(symbol, context); @@ -50340,28 +52008,28 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 324 /* JSDocCallbackTag */: - case 331 /* JSDocTypedefTag */: - case 325 /* JSDocEnumTag */: + case 332 /* JSDocCallbackTag */: + case 339 /* JSDocTypedefTag */: + case 333 /* 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 198 /* BindingElement */: + case 200 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 249 /* VariableDeclaration */: + case 251 /* 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 256 /* ModuleDeclaration */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 251 /* FunctionDeclaration */: - case 255 /* EnumDeclaration */: - case 260 /* ImportEqualsDeclaration */: + case 258 /* ModuleDeclaration */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 253 /* FunctionDeclaration */: + case 257 /* EnumDeclaration */: + case 262 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; @@ -50369,55 +52037,55 @@ var ts; 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 !== 260 /* ImportEqualsDeclaration */ && parent.kind !== 297 /* SourceFile */ && parent.flags & 8388608 /* Ambient */)) { + !(node.kind !== 262 /* ImportEqualsDeclaration */ && parent.kind !== 299 /* SourceFile */ && parent.flags & 8388608 /* Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent); - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: if (ts.hasEffectiveModifier(node, 8 /* Private */ | 16 /* Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so: // falls through - case 166 /* Constructor */: - case 170 /* ConstructSignature */: - case 169 /* CallSignature */: - case 171 /* IndexSignature */: - case 160 /* Parameter */: - case 257 /* ModuleBlock */: - case 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 177 /* TypeLiteral */: - case 173 /* TypeReference */: - case 178 /* ArrayType */: - case 179 /* TupleType */: - case 182 /* UnionType */: - case 183 /* IntersectionType */: - case 186 /* ParenthesizedType */: - case 192 /* NamedTupleMember */: + case 168 /* Constructor */: + case 172 /* ConstructSignature */: + case 171 /* CallSignature */: + case 173 /* IndexSignature */: + case 162 /* Parameter */: + case 259 /* ModuleBlock */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: + case 179 /* TypeLiteral */: + case 175 /* TypeReference */: + case 180 /* ArrayType */: + case 181 /* TupleType */: + case 184 /* UnionType */: + case 185 /* IntersectionType */: + case 188 /* ParenthesizedType */: + case 194 /* 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 262 /* ImportClause */: - case 263 /* NamespaceImport */: - case 265 /* ImportSpecifier */: + case 264 /* ImportClause */: + case 265 /* NamespaceImport */: + case 267 /* ImportSpecifier */: return false; // Type parameters are always visible - case 159 /* TypeParameter */: + case 161 /* TypeParameter */: // Source file and namespace export are always visible // falls through - case 297 /* SourceFile */: - case 259 /* NamespaceExportDeclaration */: + case 299 /* SourceFile */: + case 261 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return false; default: return false; @@ -50426,10 +52094,10 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 266 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 268 /* ExportAssignment */) { exportSymbol = resolveName(node, node.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 270 /* ExportSpecifier */) { + else if (node.parent.kind === 272 /* ExportSpecifier */) { exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } var result; @@ -50534,12 +52202,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 249 /* VariableDeclaration */: - case 250 /* VariableDeclarationList */: - case 265 /* ImportSpecifier */: - case 264 /* NamedImports */: - case 263 /* NamespaceImport */: - case 262 /* ImportClause */: + case 251 /* VariableDeclaration */: + case 252 /* VariableDeclarationList */: + case 267 /* ImportSpecifier */: + case 266 /* NamedImports */: + case 265 /* NamespaceImport */: + case 264 /* ImportClause */: return false; default: return true; @@ -50602,9 +52270,16 @@ var ts; var stringIndexInfo = getIndexInfoOfType(source, 0 /* String */); var numberIndexInfo = getIndexInfoOfType(source, 1 /* Number */); var result = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); - result.objectFlags |= 131072 /* ObjectRestType */; + result.objectFlags |= 8388608 /* ObjectRestType */; return result; } + function isGenericTypeWithUndefinedConstraint(type) { + return !!(type.flags & 465829888 /* Instantiable */) && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 32768 /* 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 */); + } // Determine the control flow type associated with a destructuring declaration or assignment. The following // forms of destructuring are possible: // let { x } = obj; // BindingElement @@ -50639,23 +52314,23 @@ var ts; function getParentElementAccess(node) { var ancestor = node.parent.parent; switch (ancestor.kind) { - case 198 /* BindingElement */: - case 288 /* PropertyAssignment */: + case 200 /* BindingElement */: + case 290 /* PropertyAssignment */: return getSyntheticElementAccess(ancestor); - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return getSyntheticElementAccess(node.parent); - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return ancestor.initializer; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return ancestor.right; } } function getDestructuringPropertyName(node) { var parent = node.parent; - if (node.kind === 198 /* BindingElement */ && parent.kind === 196 /* ObjectBindingPattern */) { + if (node.kind === 200 /* BindingElement */ && parent.kind === 198 /* ObjectBindingPattern */) { return getLiteralPropertyNameText(node.propertyName || node.name); } - if (node.kind === 288 /* PropertyAssignment */ || node.kind === 289 /* ShorthandPropertyAssignment */) { + if (node.kind === 290 /* PropertyAssignment */ || node.kind === 291 /* ShorthandPropertyAssignment */) { return getLiteralPropertyNameText(node.name); } return "" + parent.elements.indexOf(node); @@ -50681,7 +52356,7 @@ var ts; parentType = getTypeWithFacts(parentType, 524288 /* NEUndefined */); } var type; - if (pattern.kind === 196 /* ObjectBindingPattern */) { + if (pattern.kind === 198 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { parentType = getReducedType(parentType); if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { @@ -50701,7 +52376,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 = getConstraintForLocation(getIndexedAccessType(parentType, indexType, /*noUncheckedIndexedAccessCandidate*/ undefined, name, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, 16 /* ExpressionPosition */), declaration.name); + var declaredType = getIndexedAccessType(parentType, indexType, 32 /* ExpressionPosition */, name); type = getFlowTypeOfDestructuring(declaration, declaredType); } } @@ -50721,8 +52396,8 @@ var ts; } else if (isArrayLikeType(parentType)) { var indexType = getLiteralType(index_2); - var accessFlags = hasDefaultValue(declaration) ? 8 /* NoTupleBoundsCheck */ : 0; - var declaredType = getConstraintForLocation(getIndexedAccessTypeOrUndefined(parentType, indexType, /*noUncheckedIndexedAccessCandidate*/ undefined, declaration.name, accessFlags | 16 /* ExpressionPosition */) || errorType, declaration.name); + var accessFlags = 32 /* ExpressionPosition */ | (hasDefaultValue(declaration) ? 16 /* NoTupleBoundsCheck */ : 0); + var declaredType = getIndexedAccessTypeOrUndefined(parentType, indexType, accessFlags, declaration.name) || errorType; type = getFlowTypeOfDestructuring(declaration, declaredType); } else { @@ -50735,11 +52410,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 && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 32768 /* Undefined */) ? - getTypeWithFacts(type, 524288 /* NEUndefined */) : - type; + return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 32768 /* Undefined */) ? getNonUndefinedType(type) : type; } - return widenTypeInferredFromInitializer(declaration, getUnionType([getTypeWithFacts(type, 524288 /* NEUndefined */), checkDeclarationInitializer(declaration)], 2 /* Subtype */)); + return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration)], 2 /* Subtype */)); } function getTypeForDeclarationFromJSDocComment(declaration) { var jsdocType = ts.getJSDocType(declaration); @@ -50750,25 +52423,26 @@ var ts; } function isNullOrUndefined(node) { var expr = ts.skipParentheses(node); - return expr.kind === 103 /* NullKeyword */ || expr.kind === 78 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; + return expr.kind === 104 /* NullKeyword */ || expr.kind === 79 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 199 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 201 /* ArrayLiteralExpression */ && expr.elements.length === 0; } - function addOptionality(type, optional) { - if (optional === void 0) { optional = true; } - return strictNullChecks && optional ? getOptionalType(type) : type; + function addOptionality(type, isProperty, isOptional) { + if (isProperty === void 0) { isProperty = false; } + if (isOptional === void 0) { isOptional = true; } + return strictNullChecks && isOptional ? getOptionalType(type, isProperty) : type; } // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { // 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 === 238 /* ForInStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 240 /* ForInStatement */) { var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression))); return indexType.flags & (262144 /* TypeParameter */ | 4194304 /* Index */) ? getExtractStringType(indexType) : stringType; } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 239 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 241 /* 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, @@ -50779,13 +52453,14 @@ var ts; if (ts.isBindingPattern(declaration.parent)) { return getTypeForBindingElement(declaration); } - var isOptional = includeOptionality && (ts.isParameter(declaration) && isJSDocOptionalParameter(declaration) - || isOptionalJSDocPropertyLikeTag(declaration) - || !ts.isBindingElement(declaration) && !ts.isVariableDeclaration(declaration) && !!declaration.questionToken); + var isProperty = ts.isPropertyDeclaration(declaration) || ts.isPropertySignature(declaration); + var isOptional = includeOptionality && (isProperty && !!declaration.questionToken || + ts.isParameter(declaration) && (!!declaration.questionToken || isJSDocOptionalParameter(declaration)) || + isOptionalJSDocPropertyLikeTag(declaration)); // Use type from type annotation if one is present var declaredType = tryGetTypeFromEffectiveTypeNode(declaration); if (declaredType) { - return addOptionality(declaredType, isOptional); + return addOptionality(declaredType, isProperty, isOptional); } if ((noImplicitAny || ts.isInJSFile(declaration)) && ts.isVariableDeclaration(declaration) && !ts.isBindingPattern(declaration.name) && @@ -50805,8 +52480,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 === 168 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 167 /* GetAccessor */); + if (func.kind === 170 /* SetAccessor */ && hasBindableName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 169 /* GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -50829,7 +52504,7 @@ var ts; // Use contextual parameter type if one is available var type = declaration.symbol.escapedName === "this" /* This */ ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration); if (type) { - return addOptionality(type, isOptional); + return addOptionality(type, /*isProperty*/ false, isOptional); } } // Use the type of the initializer expression if one is present and the declaration is @@ -50842,7 +52517,7 @@ var ts; } } var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration)); - return addOptionality(type, isOptional); + return addOptionality(type, isProperty, isOptional); } if (ts.isPropertyDeclaration(declaration) && !ts.hasStaticModifier(declaration) && (noImplicitAny || ts.isInJSFile(declaration))) { // We have a property declaration with no type annotation or initializer, in noImplicitAny mode or a .js file. @@ -50851,7 +52526,7 @@ var ts; var type = constructor ? getFlowTypeInConstructor(declaration.symbol, constructor) : ts.getEffectiveModifierFlags(declaration) & 2 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : undefined; - return type && addOptionality(type, isOptional); + return type && addOptionality(type, /*isProperty*/ true, isOptional); } if (ts.isJsxAttribute(declaration)) { // if JSX attribute doesn't have initializer, by default the attribute will have boolean value of true. @@ -50877,7 +52552,7 @@ var ts; links.isConstructorDeclaredProperty = !!getDeclaringConstructor(symbol) && ts.every(symbol.declarations, function (declaration) { return ts.isBinaryExpression(declaration) && isPossiblyAliasedThisProperty(declaration) && - (declaration.left.kind !== 202 /* ElementAccessExpression */ || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) && + (declaration.left.kind !== 204 /* ElementAccessExpression */ || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) && !getAnnotatedTypeForAssignmentDeclaration(/*declaredType*/ undefined, declaration, symbol, declaration); }); } @@ -50893,13 +52568,33 @@ var ts; !declaration.initializer && (noImplicitAny || ts.isInJSFile(declaration)); } function getDeclaringConstructor(symbol) { + if (!symbol.declarations) { + return; + } 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 === 166 /* Constructor */ || isJSConstructor(container))) { + if (container && (container.kind === 168 /* Constructor */ || isJSConstructor(container))) { return container; } } + ; + } + /** Create a synthetic property access flow node after the last statement of the file */ + function getFlowTypeFromCommonJSExport(symbol) { + var file = ts.getSourceFileOfNode(symbol.declarations[0]); + var accessName = ts.unescapeLeadingUnderscores(symbol.escapedName); + var areAllModuleExports = symbol.declarations.every(function (d) { return ts.isInJSFile(d) && ts.isAccessExpression(d) && ts.isModuleExportsAccessExpression(d.expression); }); + var reference = areAllModuleExports + ? ts.factory.createPropertyAccessExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("module"), ts.factory.createIdentifier("exports")), accessName) + : ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("exports"), accessName); + if (areAllModuleExports) { + ts.setParent(reference.expression.expression, reference.expression); + } + ts.setParent(reference.expression, reference); + ts.setParent(reference, file); + reference.flowNode = file.endFlowNode; + return getFlowTypeOfReference(reference, autoType, undefinedType); } function getFlowTypeInConstructor(symbol, constructor) { var accessName = ts.startsWith(symbol.escapedName, "__#") @@ -50917,7 +52612,10 @@ var ts; return everyType(flowType, isNullableType) ? undefined : convertAutoToAny(flowType); } function getFlowTypeOfProperty(reference, prop) { - var initialType = prop && (!isAutoTypedProperty(prop) || ts.getEffectiveModifierFlags(prop.valueDeclaration) & 2 /* Ambient */) && getTypeOfPropertyInBaseClass(prop) || undefinedType; + var initialType = (prop === null || prop === void 0 ? void 0 : prop.valueDeclaration) + && (!isAutoTypedProperty(prop) || ts.getEffectiveModifierFlags(prop.valueDeclaration) & 2 /* Ambient */) + && getTypeOfPropertyInBaseClass(prop) + || undefinedType; return getFlowTypeOfReference(reference, autoType, initialType); } function getWidenedTypeForAssignmentDeclaration(symbol, resolvedSymbol) { @@ -50928,7 +52626,7 @@ var ts; if (tag && tag.typeExpression) { return getTypeFromTypeNode(tag.typeExpression); } - var containerObjectType = getJSContainerObjectType(symbol.valueDeclaration, symbol, container); + var containerObjectType = symbol.valueDeclaration && getJSContainerObjectType(symbol.valueDeclaration, symbol, container); return containerObjectType || getWidenedLiteralType(checkExpressionCached(container)); } var type; @@ -50940,40 +52638,42 @@ var ts; type = getFlowTypeInConstructor(symbol, getDeclaringConstructor(symbol)); } if (!type) { - var jsdocType = void 0; var types = void 0; - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration : - ts.isAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : - undefined; - if (!expression) { - continue; // Non-assignment declaration merged in (eg, an Identifier to mark the thing as a namespace) - skip over it and pull type info from elsewhere - } - var kind = ts.isAccessExpression(expression) - ? ts.getAssignmentDeclarationPropertyAccessKind(expression) - : ts.getAssignmentDeclarationKind(expression); - if (kind === 4 /* ThisProperty */ || ts.isBinaryExpression(expression) && isPossiblyAliasedThisProperty(expression, kind)) { - if (isDeclarationInConstructor(expression)) { - definedInConstructor = true; + if (symbol.declarations) { + var jsdocType = void 0; + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration : + ts.isAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : + undefined; + if (!expression) { + continue; // Non-assignment declaration merged in (eg, an Identifier to mark the thing as a namespace) - skip over it and pull type info from elsewhere } - else { - definedInMethod = true; + var kind = ts.isAccessExpression(expression) + ? ts.getAssignmentDeclarationPropertyAccessKind(expression) + : ts.getAssignmentDeclarationKind(expression); + if (kind === 4 /* ThisProperty */ || ts.isBinaryExpression(expression) && isPossiblyAliasedThisProperty(expression, kind)) { + if (isDeclarationInConstructor(expression)) { + definedInConstructor = true; + } + else { + definedInMethod = true; + } + } + if (!ts.isCallExpression(expression)) { + jsdocType = getAnnotatedTypeForAssignmentDeclaration(jsdocType, expression, symbol, declaration); + } + if (!jsdocType) { + (types || (types = [])).push((ts.isBinaryExpression(expression) || ts.isCallExpression(expression)) ? getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) : neverType); } } - if (!ts.isCallExpression(expression)) { - jsdocType = getAnnotatedTypeForAssignmentDeclaration(jsdocType, expression, symbol, declaration); - } - if (!jsdocType) { - (types || (types = [])).push((ts.isBinaryExpression(expression) || ts.isCallExpression(expression)) ? getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) : neverType); - } + type = jsdocType; } - type = jsdocType; if (!type) { if (!ts.length(types)) { return errorType; // No types from any declarations :( } - var constructorTypes = definedInConstructor ? getConstructorDefinedThisAssignmentTypes(types, symbol.declarations) : undefined; + var constructorTypes = definedInConstructor && symbol.declarations ? getConstructorDefinedThisAssignmentTypes(types, symbol.declarations) : undefined; // use only the constructor types unless they were only assigned null | undefined (including widening variants) if (definedInMethod) { var propType = getTypeOfPropertyInBaseClass(symbol); @@ -50986,8 +52686,8 @@ var ts; type = getUnionType(sourceTypes, 2 /* Subtype */); } } - var widened = getWidenedType(addOptionality(type, definedInMethod && !definedInConstructor)); - if (filterType(widened, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) === neverType) { + var widened = getWidenedType(addOptionality(type, /*isProperty*/ false, definedInMethod && !definedInConstructor)); + if (symbol.valueDeclaration && filterType(widened, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) === neverType) { reportImplicitAny(symbol.valueDeclaration, anyType); return anyType; } @@ -51011,10 +52711,11 @@ var ts; mergeSymbolTable(exports, s.exports); } var type = createAnonymousType(symbol, exports, ts.emptyArray, ts.emptyArray, undefined, undefined); - type.objectFlags |= 16384 /* JSLiteral */; + type.objectFlags |= 8192 /* JSLiteral */; return type; } function getAnnotatedTypeForAssignmentDeclaration(declaredType, expression, symbol, declaration) { + var _a; var typeNode = ts.getEffectiveTypeAnnotationNode(expression.parent); if (typeNode) { var type = getWidenedType(getTypeFromTypeNode(typeNode)); @@ -51025,10 +52726,13 @@ var ts; errorNextVariableOrPropertyDeclarationMustHaveSameType(/*firstDeclaration*/ undefined, declaredType, declaration, type); } } - if (symbol.parent) { + if ((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.valueDeclaration) { var typeNode_2 = ts.getEffectiveTypeAnnotationNode(symbol.parent.valueDeclaration); if (typeNode_2) { - return getTypeOfPropertyOfType(getTypeFromTypeNode(typeNode_2), symbol.escapedName); + var annotationSymbol = getPropertyOfType(getTypeFromTypeNode(typeNode_2), symbol.escapedName); + if (annotationSymbol) { + return getNonMissingTypeOfSymbol(annotationSymbol); + } } } return declaredType; @@ -51089,7 +52793,7 @@ var ts; // but we may have a JS file with `module.exports = { a: true }` along with a TypeScript module augmentation // declaring an `export const a: number`. In that case, we issue a duplicate identifier error, because // it's unclear what that's supposed to mean, so it's probably a mistake. - if (ts.getSourceFileOfNode(s.valueDeclaration) !== ts.getSourceFileOfNode(exportedMember.valueDeclaration)) { + if (s.valueDeclaration && exportedMember.valueDeclaration && ts.getSourceFileOfNode(s.valueDeclaration) !== ts.getSourceFileOfNode(exportedMember.valueDeclaration)) { var unescapedName = ts.unescapeLeadingUnderscores(s.escapedName); var exportedMemberName = ((_a = ts.tryCast(exportedMember.valueDeclaration, ts.isNamedDeclaration)) === null || _a === void 0 ? void 0 : _a.name) || exportedMember.valueDeclaration; ts.addRelatedInfo(error(s.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0, unescapedName), ts.createDiagnosticForNode(exportedMemberName, ts.Diagnostics._0_was_also_declared_here, unescapedName)); @@ -51111,9 +52815,9 @@ var ts; }); var result = createAnonymousType(initialSize !== members_4.size ? undefined : exportedType.symbol, // Only set the type's symbol if it looks to be the same as the original type members_4, exportedType.callSignatures, exportedType.constructSignatures, exportedType.stringIndexInfo, exportedType.numberIndexInfo); - result.objectFlags |= (ts.getObjectFlags(type) & 16384 /* JSLiteral */); // Propagate JSLiteral flag + result.objectFlags |= (ts.getObjectFlags(type) & 8192 /* JSLiteral */); // Propagate JSLiteral flag if (result.symbol && result.symbol.flags & 32 /* Class */ && type === getDeclaredTypeOfClassOrInterface(result.symbol)) { - result.objectFlags |= 1073741824 /* IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type + result.objectFlags |= 16777216 /* IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type } return result; } @@ -51125,16 +52829,16 @@ var ts; } function containsSameNamedThisProperty(thisProperty, expression) { return ts.isPropertyAccessExpression(thisProperty) - && thisProperty.expression.kind === 107 /* ThisKeyword */ + && thisProperty.expression.kind === 108 /* 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 === 166 /* Constructor */ || - thisContainer.kind === 251 /* FunctionDeclaration */ || - (thisContainer.kind === 208 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + return thisContainer.kind === 168 /* Constructor */ || + thisContainer.kind === 253 /* FunctionDeclaration */ || + (thisContainer.kind === 210 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); } function getConstructorDefinedThisAssignmentTypes(types, declarations) { ts.Debug.assert(types.length === declarations.length); @@ -51172,7 +52876,7 @@ var ts; function getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) { var members = ts.createSymbolTable(); var stringIndexInfo; - var objectFlags = 128 /* ObjectLiteral */ | 1048576 /* ContainsObjectOrArrayLiteral */; + var objectFlags = 128 /* ObjectLiteral */ | 262144 /* ContainsObjectOrArrayLiteral */; ts.forEach(pattern.elements, function (e) { var name = e.propertyName || e.name; if (e.dotDotDotToken) { @@ -51196,7 +52900,7 @@ var ts; result.objectFlags |= objectFlags; if (includePatternInType) { result.pattern = pattern; - result.objectFlags |= 1048576 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= 262144 /* ContainsObjectOrArrayLiteral */; } return result; } @@ -51204,7 +52908,7 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - var restElement = lastElement && lastElement.kind === 198 /* BindingElement */ && lastElement.dotDotDotToken ? lastElement : undefined; + var restElement = lastElement && lastElement.kind === 200 /* BindingElement */ && lastElement.dotDotDotToken ? lastElement : undefined; if (elements.length === 0 || elements.length === 1 && restElement) { return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; } @@ -51215,7 +52919,7 @@ var ts; if (includePatternInType) { result = cloneTypeReference(result); result.pattern = pattern; - result.objectFlags |= 1048576 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= 262144 /* ContainsObjectOrArrayLiteral */; } return result; } @@ -51229,7 +52933,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 196 /* ObjectBindingPattern */ + return pattern.kind === 198 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -51245,8 +52949,17 @@ var ts; function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) { return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true), declaration, reportErrors); } + function isGlobalSymbolConstructor(node) { + var symbol = getSymbolOfNode(node); + var globalSymbol = getGlobalESSymbolConstructorTypeSymbol(/*reportErrors*/ false); + return globalSymbol && symbol && symbol === globalSymbol; + } 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)) { + type = getESSymbolLikeTypeForNode(declaration); + } if (reportErrors) { reportErrorsFromWidening(declaration, type); } @@ -51268,7 +52981,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 160 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 162 /* Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(declaration) { @@ -51299,19 +53012,31 @@ var ts; if (symbol === requireSymbol) { return anyType; } - if (symbol.flags & 134217728 /* ModuleExports */) { + if (symbol.flags & 134217728 /* ModuleExports */ && symbol.valueDeclaration) { var fileSymbol = getSymbolOfNode(ts.getSourceFileOfNode(symbol.valueDeclaration)); + var result = createSymbol(fileSymbol.flags, "exports"); + result.declarations = fileSymbol.declarations ? fileSymbol.declarations.slice() : []; + result.parent = symbol; + result.target = fileSymbol; + if (fileSymbol.valueDeclaration) + result.valueDeclaration = fileSymbol.valueDeclaration; + if (fileSymbol.members) + result.members = new ts.Map(fileSymbol.members); + if (fileSymbol.exports) + result.exports = new ts.Map(fileSymbol.exports); var members = ts.createSymbolTable(); - members.set("exports", fileSymbol); + members.set("exports", result); return createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, undefined, undefined); } // Handle catch clause variables + ts.Debug.assertIsDefined(symbol.valueDeclaration); var declaration = symbol.valueDeclaration; if (ts.isCatchClauseVariableDeclarationOrBindingElement(declaration)) { - var decl = declaration; - if (!decl.type) - return anyType; - var type_1 = getTypeOfNode(decl.type); + var typeNode = ts.getEffectiveTypeAnnotationNode(declaration); + if (typeNode === undefined) { + return useUnknownInCatchVariables ? unknownType : anyType; + } + var type_1 = getTypeOfNode(typeNode); // an errorType will make `checkTryStatement` issue an error return isTypeAny(type_1) || type_1 === unknownType ? type_1 : errorType; } @@ -51331,7 +53056,7 @@ var ts; return reportCircularityError(symbol); } var type; - if (declaration.kind === 266 /* ExportAssignment */) { + if (declaration.kind === 268 /* ExportAssignment */) { type = widenTypeForVariableLikeDeclaration(checkExpressionCached(declaration.expression), declaration); } else if (ts.isBinaryExpression(declaration) || @@ -51386,7 +53111,7 @@ var ts; type = getTypeOfEnumMember(symbol); } else if (ts.isAccessor(declaration)) { - type = resolveTypeOfAccessors(symbol); + type = resolveTypeOfAccessors(symbol) || ts.Debug.fail("Non-write accessor resolution must always produce a type"); } else { return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.formatSyntaxKind(declaration.kind) + " for " + ts.Debug.formatSymbol(symbol)); @@ -51402,7 +53127,7 @@ var ts; } function getAnnotatedAccessorTypeNode(accessor) { if (accessor) { - if (accessor.kind === 167 /* GetAccessor */) { + if (accessor.kind === 169 /* GetAccessor */) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation; } @@ -51426,63 +53151,78 @@ var ts; } function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); - return links.type || (links.type = getTypeOfAccessorsWorker(symbol)); + return links.type || (links.type = getTypeOfAccessorsWorker(symbol) || ts.Debug.fail("Read type of accessor must always produce a type")); + } + function getTypeOfSetAccessor(symbol) { + var links = getSymbolLinks(symbol); + return links.writeType || (links.writeType = getTypeOfAccessorsWorker(symbol, /*writing*/ true)); } - function getTypeOfAccessorsWorker(symbol) { + function getTypeOfAccessorsWorker(symbol, writing) { + if (writing === void 0) { writing = false; } if (!pushTypeResolution(symbol, 0 /* Type */)) { return errorType; } - var type = resolveTypeOfAccessors(symbol); + var type = resolveTypeOfAccessors(symbol, writing); if (!popTypeResolution()) { type = anyType; if (noImplicitAny) { - var getter = ts.getDeclarationOfKind(symbol, 167 /* GetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 169 /* GetAccessor */); error(getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } return type; } - function resolveTypeOfAccessors(symbol) { - var getter = ts.getDeclarationOfKind(symbol, 167 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 168 /* SetAccessor */); + function resolveTypeOfAccessors(symbol, writing) { + if (writing === void 0) { writing = false; } + var getter = ts.getDeclarationOfKind(symbol, 169 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 170 /* SetAccessor */); + var setterType = getAnnotatedAccessorType(setter); + // For write operations, prioritize type annotations on the setter + if (writing && setterType) { + return instantiateTypeIfNeeded(setterType, symbol); + } + // Else defer to the getter type if (getter && ts.isInJSFile(getter)) { var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { - return jsDocType; + return instantiateTypeIfNeeded(jsDocType, symbol); } } - // First try to see if the user specified a return type on the get-accessor. - var getterReturnType = getAnnotatedAccessorType(getter); - if (getterReturnType) { - return getterReturnType; + // Try to see if the user specified a return type on the get-accessor. + var getterType = getAnnotatedAccessorType(getter); + if (getterType) { + return instantiateTypeIfNeeded(getterType, symbol); } - else { - // If the user didn't specify a return type, try to use the set-accessor's parameter type. - var setterParameterType = getAnnotatedAccessorType(setter); - if (setterParameterType) { - return setterParameterType; + // If the user didn't specify a return type, try to use the set-accessor's parameter type. + if (setterType) { + return setterType; + } + // If there are no specified types, try to infer it from the body of the get accessor if it exists. + if (getter && getter.body) { + var returnTypeFromBody = getReturnTypeFromBody(getter); + return instantiateTypeIfNeeded(returnTypeFromBody, symbol); + } + // Otherwise, fall back to 'any'. + if (setter) { + if (!isPrivateWithinAmbient(setter)) { + errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol)); } - else { - // If there are no specified types, try to infer it from the body of the get accessor if it exists. - if (getter && getter.body) { - return getReturnTypeFromBody(getter); - } - // Otherwise, fall back to 'any'. - else { - if (setter) { - if (!isPrivateWithinAmbient(setter)) { - errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol)); - } - } - else { - ts.Debug.assert(!!getter, "there must exist a getter as we are current checking either setter or getter in this function"); - if (!isPrivateWithinAmbient(getter)) { - errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol)); - } - } - return anyType; - } + return anyType; + } + else if (getter) { + ts.Debug.assert(!!getter, "there must exist a getter as we are current checking either setter or getter in this function"); + if (!isPrivateWithinAmbient(getter)) { + errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol)); } + return anyType; + } + return undefined; + function instantiateTypeIfNeeded(type, symbol) { + if (ts.getCheckFlags(symbol) & 1 /* Instantiated */) { + var links = getSymbolLinks(symbol); + return instantiateType(type, links.mapper); + } + return type; } } function getBaseTypeVariableOfClass(symbol) { @@ -51512,9 +53252,9 @@ var ts; if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { return anyType; } - else if (declaration && (declaration.kind === 216 /* BinaryExpression */ || + else if (declaration && (declaration.kind === 218 /* BinaryExpression */ || ts.isAccessExpression(declaration) && - declaration.parent.kind === 216 /* BinaryExpression */)) { + declaration.parent.kind === 218 /* BinaryExpression */)) { return getWidenedTypeForAssignmentDeclaration(symbol); } else if (symbol.flags & 512 /* ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { @@ -51548,14 +53288,16 @@ var ts; var links = getSymbolLinks(symbol); if (!links.type) { var targetSymbol = resolveAlias(symbol); + var exportSymbol = symbol.declarations && getTargetOfAliasDeclaration(getDeclarationOfAliasSymbol(symbol), /*dontResolveAlias*/ true); // It only makes sense to get the type of a value symbol. If the result of resolving // the alias is not a value, then it has no type. To get the type associated with a // type symbol, call getDeclaredTypeOfSymbol. // This check is important because without it, a call to getTypeOfSymbol could end // up recursively calling getTypeOfAlias, causing a stack overflow. - links.type = targetSymbol.flags & 111551 /* Value */ - ? getTypeOfSymbol(targetSymbol) - : errorType; + links.type = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.declarations) && isDuplicatedCommonJSExport(exportSymbol.declarations) && symbol.declarations.length ? getFlowTypeFromCommonJSExport(exportSymbol) + : isDuplicatedCommonJSExport(symbol.declarations) ? autoType + : targetSymbol.flags & 111551 /* Value */ ? getTypeOfSymbol(targetSymbol) + : errorType; } return links.type; } @@ -51581,7 +53323,7 @@ var ts; return errorType; } // Check if variable has initializer that circularly references the variable itself - if (noImplicitAny && (declaration.kind !== 160 /* Parameter */ || declaration.initializer)) { + if (noImplicitAny && (declaration.kind !== 162 /* 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 @@ -51598,6 +53340,15 @@ var ts; } return links.type; } + function getSetAccessorTypeOfSymbol(symbol) { + if (symbol.flags & 98304 /* Accessor */) { + var type = getTypeOfSetAccessor(symbol); + if (type) { + return type; + } + } + return getTypeOfSymbol(symbol); + } function getTypeOfSymbol(symbol) { var checkFlags = ts.getCheckFlags(symbol); if (checkFlags & 65536 /* DeferredType */) { @@ -51629,6 +53380,9 @@ var ts; } return errorType; } + function getNonMissingTypeOfSymbol(symbol) { + return removeMissingType(getTypeOfSymbol(symbol), !!(symbol.flags & 16777216 /* Optional */)); + } function isReferenceToType(type, target) { return type !== undefined && target !== undefined @@ -51680,66 +53434,72 @@ var ts; return undefined; } switch (node.kind) { - case 232 /* VariableStatement */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 164 /* MethodSignature */: - case 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 308 /* JSDocFunctionType */: - case 251 /* FunctionDeclaration */: - case 165 /* MethodDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 254 /* TypeAliasDeclaration */: - case 330 /* JSDocTemplateTag */: - case 331 /* JSDocTypedefTag */: - case 325 /* JSDocEnumTag */: - case 324 /* JSDocCallbackTag */: - case 190 /* MappedType */: - case 184 /* ConditionalType */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 166 /* MethodSignature */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: + case 311 /* JSDocFunctionType */: + case 253 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 256 /* TypeAliasDeclaration */: + case 338 /* JSDocTemplateTag */: + case 339 /* JSDocTypedefTag */: + case 333 /* JSDocEnumTag */: + case 332 /* JSDocCallbackTag */: + case 192 /* MappedType */: + case 186 /* ConditionalType */: { var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 190 /* MappedType */) { + if (node.kind === 192 /* MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 184 /* ConditionalType */) { + else if (node.kind === 186 /* ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } - else if (node.kind === 232 /* VariableStatement */ && !ts.isInJSFile(node)) { - break; - } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 252 /* ClassDeclaration */ || node.kind === 221 /* ClassExpression */ || node.kind === 253 /* InterfaceDeclaration */ || isJSConstructor(node)) && + (node.kind === 254 /* ClassDeclaration */ || node.kind === 223 /* ClassExpression */ || node.kind === 255 /* InterfaceDeclaration */ || isJSConstructor(node)) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; - case 326 /* JSDocParameterTag */: + } + case 334 /* JSDocParameterTag */: var paramSymbol = ts.getParameterSymbolFromJSDoc(node); if (paramSymbol) { node = paramSymbol.valueDeclaration; } break; + case 314 /* JSDocComment */: { + var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); + return node.tags + ? appendTypeParameters(outerTypeParameters, ts.flatMap(node.tags, function (t) { return ts.isJSDocTemplateTag(t) ? t.typeParameters : undefined; })) + : outerTypeParameters; + } } } } // 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, 253 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 255 /* InterfaceDeclaration */); ts.Debug.assert(!!declaration, "Class was missing valueDeclaration -OR- non-class had no interface declarations"); return getOuterTypeParameters(declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, // interface, or type alias. function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { + if (!symbol.declarations) { + return; + } var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 253 /* InterfaceDeclaration */ || - node.kind === 252 /* ClassDeclaration */ || - node.kind === 221 /* ClassExpression */ || + if (node.kind === 255 /* InterfaceDeclaration */ || + node.kind === 254 /* ClassDeclaration */ || + node.kind === 223 /* ClassExpression */ || isJSConstructor(node) || ts.isTypeAlias(node)) { var declaration = node; @@ -51833,7 +53593,9 @@ var ts; ctorReturn = getReturnTypeOfSignature(ctorSig[0]); } } - ts.addRelatedInfo(err, ts.createDiagnosticForNode(baseConstructorType.symbol.declarations[0], ts.Diagnostics.Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1, symbolToString(baseConstructorType.symbol), typeToString(ctorReturn))); + if (baseConstructorType.symbol.declarations) { + ts.addRelatedInfo(err, ts.createDiagnosticForNode(baseConstructorType.symbol.declarations[0], ts.Diagnostics.Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1, symbolToString(baseConstructorType.symbol), typeToString(ctorReturn))); + } } return type.resolvedBaseConstructorType = errorType; } @@ -51843,20 +53605,22 @@ var ts; } function getImplementsTypes(type) { var resolvedImplementsTypes = ts.emptyArray; - for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - var implementsTypeNodes = ts.getEffectiveImplementsTypeNodes(declaration); - if (!implementsTypeNodes) - continue; - for (var _b = 0, implementsTypeNodes_1 = implementsTypeNodes; _b < implementsTypeNodes_1.length; _b++) { - var node = implementsTypeNodes_1[_b]; - var implementsType = getTypeFromTypeNode(node); - if (implementsType !== errorType) { - if (resolvedImplementsTypes === ts.emptyArray) { - resolvedImplementsTypes = [implementsType]; - } - else { - resolvedImplementsTypes.push(implementsType); + if (type.symbol.declarations) { + for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + var implementsTypeNodes = ts.getEffectiveImplementsTypeNodes(declaration); + if (!implementsTypeNodes) + continue; + for (var _b = 0, implementsTypeNodes_1 = implementsTypeNodes; _b < implementsTypeNodes_1.length; _b++) { + var node = implementsTypeNodes_1[_b]; + var implementsType = getTypeFromTypeNode(node); + if (implementsType !== errorType) { + if (resolvedImplementsTypes === ts.emptyArray) { + resolvedImplementsTypes = [implementsType]; + } + else { + resolvedImplementsTypes.push(implementsType); + } } } } @@ -51883,10 +53647,10 @@ var ts; else { ts.Debug.fail("type must be class or interface"); } - if (!popTypeResolution()) { + if (!popTypeResolution() && type.symbol.declarations) { for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 252 /* ClassDeclaration */ || declaration.kind === 253 /* InterfaceDeclaration */) { + if (declaration.kind === 254 /* ClassDeclaration */ || declaration.kind === 255 /* InterfaceDeclaration */) { reportCircularBaseType(declaration, type); } } @@ -51979,29 +53743,31 @@ var ts; } function resolveBaseTypesOfInterface(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray; - for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 253 /* 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)); - if (baseType !== errorType) { - if (isValidBaseType(baseType)) { - if (type !== baseType && !hasBaseType(baseType, type)) { - if (type.resolvedBaseTypes === ts.emptyArray) { - type.resolvedBaseTypes = [baseType]; + if (type.symbol.declarations) { + for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 255 /* 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)); + if (baseType !== errorType) { + if (isValidBaseType(baseType)) { + if (type !== baseType && !hasBaseType(baseType, type)) { + if (type.resolvedBaseTypes === ts.emptyArray) { + type.resolvedBaseTypes = [baseType]; + } + else { + type.resolvedBaseTypes.push(baseType); + } } else { - type.resolvedBaseTypes.push(baseType); + reportCircularBaseType(declaration, type); } } else { - reportCircularBaseType(declaration, type); + error(node, ts.Diagnostics.An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_members); } } - else { - error(node, ts.Diagnostics.An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_members); - } } } } @@ -52015,9 +53781,12 @@ var ts; * and if none of the base interfaces have a "this" type. */ function isThislessInterface(symbol) { + if (!symbol.declarations) { + return true; + } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 253 /* InterfaceDeclaration */) { + if (declaration.kind === 255 /* InterfaceDeclaration */) { if (declaration.flags & 128 /* ContainsThis */) { return false; } @@ -52042,7 +53811,7 @@ var ts; var originalLinks = links; if (!links.declaredType) { var kind = symbol.flags & 32 /* Class */ ? 1 /* Class */ : 2 /* Interface */; - var merged = mergeJSSymbols(symbol, getAssignedClassSymbol(symbol.valueDeclaration)); + var merged = mergeJSSymbols(symbol, symbol.valueDeclaration && getAssignedClassSymbol(symbol.valueDeclaration)); if (merged) { // note:we overwrite links because we just cloned the symbol symbol = links = merged; @@ -52072,6 +53841,7 @@ var ts; return links.declaredType; } function getDeclaredTypeOfTypeAlias(symbol) { + var _a; var links = getSymbolLinks(symbol); if (!links.declaredType) { // Note that we use the links object as the target here because the symbol object is used as the unique @@ -52079,7 +53849,7 @@ var ts; if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { return errorType; } - var declaration = ts.Debug.checkDefined(ts.find(symbol.declarations, ts.isTypeAlias), "Type alias symbol with no valid declaration found"); + 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"); var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type; // If typeNode is missing, we will error in checkJSDocTypedefTag. var type = typeNode ? getTypeFromTypeNode(typeNode) : errorType; @@ -52095,7 +53865,12 @@ var ts; } else { type = errorType; - error(ts.isNamedDeclaration(declaration) ? declaration.name : declaration || declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); + if (declaration.kind === 333 /* 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)); + } } links.declaredType = type; } @@ -52105,7 +53880,7 @@ var ts; if (ts.isStringLiteralLike(expr)) { return true; } - else if (expr.kind === 216 /* BinaryExpression */) { + else if (expr.kind === 218 /* BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -52120,12 +53895,12 @@ var ts; case 8 /* NumericLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return true; - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return expr.operator === 40 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; - case 78 /* Identifier */: + case 79 /* Identifier */: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -52137,16 +53912,18 @@ var ts; return links.enumKind; } var hasNonLiteralMember = false; - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 255 /* 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 */; - } - if (!isLiteralEnumMember(member)) { - hasNonLiteralMember = true; + if (symbol.declarations) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 257 /* 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 */; + } + if (!isLiteralEnumMember(member)) { + hasNonLiteralMember = true; + } } } } @@ -52164,15 +53941,17 @@ var ts; if (getEnumKind(symbol) === 1 /* Literal */) { enumCount++; var memberTypeList = []; - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 255 /* EnumDeclaration */) { - for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { - var member = _c[_b]; - var value = getEnumMemberValue(member); - var memberType = getFreshTypeOfLiteralType(getLiteralType(value !== undefined ? value : 0, enumCount, getSymbolOfNode(member))); - getSymbolLinks(getSymbolOfNode(member)).declaredType = memberType; - memberTypeList.push(getRegularTypeOfLiteralType(memberType)); + if (symbol.declarations) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 257 /* EnumDeclaration */) { + for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { + var member = _c[_b]; + var value = getEnumMemberValue(member); + var memberType = getFreshTypeOfLiteralType(getLiteralType(value !== undefined ? value : 0, enumCount, getSymbolOfNode(member))); + getSymbolLinks(getSymbolOfNode(member)).declaredType = memberType; + memberTypeList.push(getRegularTypeOfLiteralType(memberType)); + } } } } @@ -52238,22 +54017,22 @@ var ts; */ function isThislessType(node) { switch (node.kind) { - case 128 /* AnyKeyword */: - case 152 /* UnknownKeyword */: - case 147 /* StringKeyword */: - case 144 /* NumberKeyword */: - case 155 /* BigIntKeyword */: - case 131 /* BooleanKeyword */: - case 148 /* SymbolKeyword */: - case 145 /* ObjectKeyword */: - case 113 /* VoidKeyword */: - case 150 /* UndefinedKeyword */: - case 141 /* NeverKeyword */: - case 191 /* LiteralType */: + case 129 /* AnyKeyword */: + case 153 /* UnknownKeyword */: + case 148 /* StringKeyword */: + case 145 /* NumberKeyword */: + case 156 /* BigIntKeyword */: + case 132 /* BooleanKeyword */: + case 149 /* SymbolKeyword */: + case 146 /* ObjectKeyword */: + case 114 /* VoidKeyword */: + case 151 /* UndefinedKeyword */: + case 142 /* NeverKeyword */: + case 193 /* LiteralType */: return true; - case 178 /* ArrayType */: + case 180 /* ArrayType */: return isThislessType(node.elementType); - case 173 /* TypeReference */: + case 175 /* TypeReference */: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -52279,7 +54058,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 166 /* Constructor */ || (!!returnType && isThislessType(returnType))) && + return (node.kind === 168 /* Constructor */ || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -52295,14 +54074,14 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: return isThislessVariableLikeDeclaration(declaration); - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return isThislessFunctionLikeDeclaration(declaration); } } @@ -52328,7 +54107,7 @@ var ts; } } function isStaticPrivateIdentifierProperty(s) { - return !!s.valueDeclaration && ts.isPrivateIdentifierPropertyDeclaration(s.valueDeclaration) && ts.hasSyntacticModifier(s.valueDeclaration, 32 /* Static */); + return !!s.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(s.valueDeclaration) && ts.hasSyntacticModifier(s.valueDeclaration, 32 /* Static */); } function resolveDeclaredMembers(type) { if (!type.declaredProperties) { @@ -52380,10 +54159,10 @@ var ts; return !!name && isLateBindableName(name); } /** - * Indicates whether a declaration has a dynamic name that cannot be late-bound. + * Indicates whether a declaration has an early-bound name or a dynamic name that can be late-bound. */ - function hasNonBindableDynamicName(node) { - return ts.hasDynamicName(node) && !hasLateBindableName(node); + function hasBindableName(node) { + return !ts.hasDynamicName(node) || hasLateBindableName(node); } /** * Indicates whether a declaration name is a dynamic name that cannot be late-bound. @@ -52653,7 +54432,8 @@ var ts; sig.resolvedMinArgumentCount = undefined; sig.target = undefined; sig.mapper = undefined; - sig.unionSignatures = undefined; + sig.compositeSignatures = undefined; + sig.compositeKind = undefined; return sig; } function cloneSignature(sig) { @@ -52661,12 +54441,14 @@ var ts; /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* PropagatingFlags */); result.target = sig.target; result.mapper = sig.mapper; - result.unionSignatures = sig.unionSignatures; + result.compositeSignatures = sig.compositeSignatures; + result.compositeKind = sig.compositeKind; return result; } function createUnionSignature(signature, unionSignatures) { var result = cloneSignature(signature); - result.unionSignatures = unionSignatures; + result.compositeSignatures = unionSignatures; + result.compositeKind = 1048576 /* Union */; result.target = undefined; result.mapper = undefined; return result; @@ -52825,7 +54607,7 @@ var ts; if (signatures !== masterList) { var signature_1 = signatures[0]; ts.Debug.assert(!!signature_1, "getUnionSignatures bails early on empty signature lists and should not have empty lists on second pass"); - results = signature_1.typeParameters && ts.some(results, function (s) { return !!s.typeParameters && !compareTypeParametersIdentical(signature_1.typeParameters, s.typeParameters); }) ? undefined : ts.map(results, function (sig) { return combineSignaturesOfUnionMembers(sig, signature_1); }); + results = !!signature_1.typeParameters && ts.some(results, function (s) { return !!s.typeParameters && !compareTypeParametersIdentical(signature_1.typeParameters, s.typeParameters); }) ? undefined : ts.map(results, function (sig) { return combineSignaturesOfUnionMembers(sig, signature_1); }); if (!results) { return "break"; } @@ -52842,9 +54624,12 @@ var ts; return result || ts.emptyArray; } function compareTypeParametersIdentical(sourceParams, targetParams) { - if (sourceParams.length !== targetParams.length) { + if (ts.length(sourceParams) !== ts.length(targetParams)) { return false; } + if (!sourceParams || !targetParams) { + return true; + } var mapper = createTypeMapper(targetParams, sourceParams); for (var i = 0; i < sourceParams.length; i++) { var source = sourceParams[i]; @@ -52926,9 +54711,10 @@ var ts; var result = createSignature(declaration, typeParams, thisParam, params, /*resolvedReturnType*/ undefined, /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* PropagatingFlags */); - result.unionSignatures = ts.concatenate(left.unionSignatures || [left], [right]); + result.compositeKind = 1048576 /* Union */; + result.compositeSignatures = ts.concatenate(left.compositeKind !== 2097152 /* Intersection */ && left.compositeSignatures || [left], [right]); if (paramMapper) { - result.mapper = left.mapper && left.unionSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; + result.mapper = left.compositeKind !== 2097152 /* Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; } return result; } @@ -53061,6 +54847,7 @@ var ts; // Combinations of function, class, enum and module var members = emptySymbols; var stringIndexInfo = void 0; + var numberIndexInfo = void 0; if (symbol.exports) { members = getExportsOfSymbol(symbol); if (symbol === globalThisSymbol) { @@ -53073,20 +54860,31 @@ var ts; members = varsOnly_1; } } + var baseConstructorIndexInfo = void 0; setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, undefined, undefined); if (symbol.flags & 32 /* Class */) { var classType = getDeclaredTypeOfClassOrInterface(symbol); var baseConstructorType = getBaseConstructorTypeOfClass(classType); if (baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 8650752 /* TypeVariable */)) { - members = ts.createSymbolTable(getNamedMembers(members)); + members = ts.createSymbolTable(getNamedOrIndexSignatureMembers(members)); addInheritedMembers(members, getPropertiesOfType(baseConstructorType)); } else if (baseConstructorType === anyType) { - stringIndexInfo = createIndexInfo(anyType, /*isReadonly*/ false); + baseConstructorIndexInfo = createIndexInfo(anyType, /*isReadonly*/ false); + } + } + var indexSymbol = getIndexSymbolFromSymbolTable(members); + if (indexSymbol) { + stringIndexInfo = getIndexInfoOfIndexSymbol(indexSymbol, 0 /* String */); + numberIndexInfo = getIndexInfoOfIndexSymbol(indexSymbol, 1 /* Number */); + } + else { + stringIndexInfo = baseConstructorIndexInfo; + if (symbol.flags & 384 /* Enum */ && (getDeclaredTypeOfSymbol(symbol).flags & 32 /* Enum */ || + ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296 /* NumberLike */); }))) { + numberIndexInfo = enumNumberIndexInfo; } } - var numberIndexInfo = symbol.flags & 384 /* Enum */ && (getDeclaredTypeOfSymbol(symbol).flags & 32 /* Enum */ || - ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296 /* NumberLike */); })) ? enumNumberIndexInfo : undefined; setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); // We resolve the members before computing the signatures because a signature may use // typeof with a qualified name expression that circularly references the type we are @@ -53111,6 +54909,18 @@ var ts; } } } + function replaceIndexedAccess(instantiable, type, replacement) { + // map type.indexType to 0 + // map type.objectType to `[TReplacement]` + // thus making the indexed access `[TReplacement][0]` or `TReplacement` + return instantiateType(instantiable, createTypeMapper([type.indexType, type.objectType], [getLiteralType(0), createTupleType([replacement])])); + } + function getIndexInfoOfIndexSymbol(indexSymbol, indexKind) { + var declaration = getIndexDeclarationOfIndexSymbol(indexSymbol, indexKind); + if (!declaration) + return undefined; + return createIndexInfo(declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasEffectiveModifier(declaration, 64 /* Readonly */), declaration); + } function resolveReverseMappedTypeMembers(type) { var indexInfo = getIndexInfoOfType(type.source, 0 /* String */); var modifiers = getMappedTypeModifiers(type.mappedType); @@ -53125,8 +54935,21 @@ var ts; inferredProp.declarations = prop.declarations; inferredProp.nameType = getSymbolLinks(prop).nameType; inferredProp.propertyType = getTypeOfSymbol(prop); - inferredProp.mappedType = type.mappedType; - inferredProp.constraintType = type.constraintType; + if (type.constraintType.type.flags & 8388608 /* IndexedAccess */ + && type.constraintType.type.objectType.flags & 262144 /* TypeParameter */ + && type.constraintType.type.indexType.flags & 262144 /* 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 + var newTypeParam = type.constraintType.type.objectType; + var newMappedType = replaceIndexedAccess(type.mappedType, type.constraintType.type, newTypeParam); + inferredProp.mappedType = newMappedType; + inferredProp.constraintType = getIndexType(newTypeParam); + } + else { + inferredProp.mappedType = type.mappedType; + inferredProp.constraintType = type.constraintType; + } members.set(prop.escapedName, inferredProp); } setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, undefined); @@ -53253,7 +55076,7 @@ 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) : + var type = strictNullChecks && symbol.flags & 16777216 /* Optional */ && !maybeTypeOfKind(propType, 32768 /* Undefined */ | 16384 /* Void */) ? getOptionalType(propType, /*isProperty*/ true) : symbol.checkFlags & 524288 /* StripOptional */ ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : propType; if (!popTypeResolution()) { @@ -53280,7 +55103,7 @@ var ts; function getTemplateTypeFromMappedType(type) { return type.templateType || (type.templateType = type.declaration.type ? - instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), type.mapper) : + instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), /*isProperty*/ true, !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), type.mapper) : errorType); } function getConstraintDeclarationForMappedType(type) { @@ -53288,8 +55111,8 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 188 /* TypeOperator */ && - constraintDeclaration.operator === 138 /* KeyOfKeyword */; + return constraintDeclaration.kind === 190 /* TypeOperator */ && + constraintDeclaration.operator === 139 /* KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { @@ -53340,7 +55163,7 @@ var ts; else if (type.objectFlags & 3 /* ClassOrInterface */) { resolveClassOrInterfaceMembers(type); } - else if (type.objectFlags & 2048 /* ReverseMapped */) { + else if (type.objectFlags & 1024 /* ReverseMapped */) { resolveReverseMappedTypeMembers(type); } else if (type.objectFlags & 16 /* Anonymous */) { @@ -53456,14 +55279,14 @@ var ts; function getConstraintFromIndexedAccess(type) { var indexConstraint = getSimplifiedTypeOrConstraint(type.indexType); if (indexConstraint && indexConstraint !== type.indexType) { - var indexedAccess = getIndexedAccessTypeOrUndefined(type.objectType, indexConstraint, type.noUncheckedIndexedAccessCandidate); + var indexedAccess = getIndexedAccessTypeOrUndefined(type.objectType, indexConstraint, type.accessFlags); if (indexedAccess) { return indexedAccess; } } var objectConstraint = getSimplifiedTypeOrConstraint(type.objectType); if (objectConstraint && objectConstraint !== type.objectType) { - return getIndexedAccessTypeOrUndefined(objectConstraint, type.indexType, type.noUncheckedIndexedAccessCandidate); + return getIndexedAccessTypeOrUndefined(objectConstraint, type.indexType, type.accessFlags); } return undefined; } @@ -53624,12 +55447,22 @@ var ts; if (t.flags & 3145728 /* UnionOrIntersection */) { var types = t.types; var baseTypes = []; + var different = false; for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { var type_3 = types_8[_i]; var baseType = getBaseConstraint(type_3); if (baseType) { + if (baseType !== type_3) { + different = true; + } baseTypes.push(baseType); } + else { + different = true; + } + } + if (!different) { + return t; } return t.flags & 1048576 /* Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) : t.flags & 2097152 /* Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) : @@ -53650,7 +55483,7 @@ var ts; if (t.flags & 8388608 /* IndexedAccess */) { var baseObjectType = getBaseConstraint(t.objectType); var baseIndexType = getBaseConstraint(t.indexType); - var baseIndexedAccess = baseObjectType && baseIndexType && getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, t.noUncheckedIndexedAccessCandidate); + var baseIndexedAccess = baseObjectType && baseIndexType && getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, t.accessFlags); return baseIndexedAccess && getBaseConstraint(baseIndexedAccess); } if (t.flags & 16777216 /* Conditional */) { @@ -53749,6 +55582,7 @@ var ts; return getReducedType(getApparentType(getReducedType(type))); } function createUnionOrIntersectionProperty(containingType, name, skipObjectFunctionPropertyAugment) { + var _a, _b; var singleProp; var propSet; var indexTypes; @@ -53757,8 +55591,9 @@ var ts; var optionalFlag = isUnion ? 0 /* None */ : 16777216 /* Optional */; var syntheticFlag = 4 /* SyntheticMethod */; var checkFlags = 0; - for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { - var current = _a[_i]; + var mergedInstantiations = false; + for (var _i = 0, _c = containingType.types; _i < _c.length; _i++) { + var current = _c[_i]; var type = getApparentType(current); if (!(type === errorType || type.flags & 131072 /* Never */)) { var prop = getPropertyOfType(type, name, skipObjectFunctionPropertyAugment); @@ -53774,13 +55609,25 @@ var ts; singleProp = prop; } else if (prop !== singleProp) { - if (!propSet) { - propSet = new ts.Map(); - propSet.set(getSymbolId(singleProp), singleProp); + var isInstantiation = (getTargetSymbol(prop) || prop) === (getTargetSymbol(singleProp) || singleProp); + // 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 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[]` + mergedInstantiations = !!singleProp.parent && !!ts.length(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(singleProp.parent)); } - var id = getSymbolId(prop); - if (!propSet.has(id)) { - propSet.set(id, prop); + else { + if (!propSet) { + propSet = new ts.Map(); + propSet.set(getSymbolId(singleProp), singleProp); + } + var id = getSymbolId(prop); + if (!propSet.has(id)) { + propSet.set(id, prop); + } } } checkFlags |= (isReadonlySymbol(prop) ? 8 /* Readonly */ : 0) | @@ -53798,7 +55645,7 @@ var ts; checkFlags |= 32 /* WritePartial */ | (indexInfo.isReadonly ? 8 /* Readonly */ : 0); indexTypes = ts.append(indexTypes, isTupleType(type) ? getRestTypeOfTupleType(type) || undefinedType : indexInfo.type); } - else if (isObjectLiteralType(type)) { + else if (isObjectLiteralType(type) && !(ts.getObjectFlags(type) & 4194304 /* ContainsSpread */)) { checkFlags |= 32 /* WritePartial */; indexTypes = ts.append(indexTypes, undefinedType); } @@ -53814,7 +55661,19 @@ var ts; return undefined; } if (!propSet && !(checkFlags & 16 /* ReadPartial */) && !indexTypes) { - return singleProp; + 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!) + // They also have a `.containingType` set, which affects some services endpoints behavior, like `getRootSymbol` + var clone_1 = createSymbolWithType(singleProp, singleProp.type); + clone_1.parent = (_b = (_a = singleProp.valueDeclaration) === null || _a === void 0 ? void 0 : _a.symbol) === null || _b === void 0 ? void 0 : _b.parent; + clone_1.containingType = containingType; + clone_1.mapper = singleProp.mapper; + return clone_1; + } + else { + return singleProp; + } } var props = propSet ? ts.arrayFrom(propSet.values()) : [singleProp]; var declarations; @@ -53823,8 +55682,8 @@ var ts; var propTypes = []; var firstValueDeclaration; var hasNonUniformValueDeclaration = false; - for (var _b = 0, props_1 = props; _b < props_1.length; _b++) { - var prop = props_1[_b]; + for (var _d = 0, props_1 = props; _d < props_1.length; _d++) { + var prop = props_1[_d]; if (!firstValueDeclaration) { firstValueDeclaration = prop.valueDeclaration; } @@ -53901,15 +55760,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 & 268435456 /* ContainsIntersections */) { + if (type.flags & 1048576 /* Union */ && type.objectFlags & 67108864 /* ContainsIntersections */) { return type.resolvedReducedType || (type.resolvedReducedType = getReducedUnionType(type)); } else if (type.flags & 2097152 /* Intersection */) { - if (!(type.objectFlags & 268435456 /* IsNeverIntersectionComputed */)) { - type.objectFlags |= 268435456 /* IsNeverIntersectionComputed */ | - (ts.some(getPropertiesOfUnionOrIntersectionType(type), isNeverReducedProperty) ? 536870912 /* IsNeverIntersection */ : 0); + if (!(type.objectFlags & 67108864 /* IsNeverIntersectionComputed */)) { + type.objectFlags |= 67108864 /* IsNeverIntersectionComputed */ | + (ts.some(getPropertiesOfUnionOrIntersectionType(type), isNeverReducedProperty) ? 134217728 /* IsNeverIntersection */ : 0); } - return type.objectFlags & 536870912 /* IsNeverIntersection */ ? neverType : type; + return type.objectFlags & 134217728 /* IsNeverIntersection */ ? neverType : type; } return type; } @@ -53939,7 +55798,7 @@ var ts; return !prop.valueDeclaration && !!(ts.getCheckFlags(prop) & 1024 /* ContainsPrivate */); } function elaborateNeverIntersection(errorInfo, type) { - if (ts.getObjectFlags(type) & 536870912 /* IsNeverIntersection */) { + if (type.flags & 2097152 /* Intersection */ && ts.getObjectFlags(type) & 134217728 /* 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)); @@ -54026,7 +55885,8 @@ var ts; for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) { var prop = _a[_i]; if (kind === 0 /* String */ || isNumericLiteralName(prop.escapedName)) { - propTypes.push(getTypeOfSymbol(prop)); + var propType = getTypeOfSymbol(prop); + propTypes.push(prop.flags & 16777216 /* Optional */ ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : propType); } } if (kind === 0 /* String */) { @@ -54060,10 +55920,10 @@ 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 === 307 /* JSDocOptionalType */ + node.type && node.type.kind === 310 /* JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 307 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 310 /* JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -54095,12 +55955,15 @@ var ts; } return false; } + function isOptionalPropertyDeclaration(node) { + return ts.isPropertyDeclaration(node) && node.questionToken; + } function isOptionalJSDocPropertyLikeTag(node) { if (!ts.isJSDocPropertyLikeTag(node)) { return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 307 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 310 /* JSDocOptionalType */; } function createTypePredicate(kind, parameterName, parameterIndex, type) { return { kind: kind, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; @@ -54182,7 +56045,7 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 191 /* LiteralType */) { + if (type && type.kind === 193 /* LiteralType */) { flags |= 2 /* HasLiteralTypes */; } // Record a new minimum argument count if this is not an optional parameter @@ -54195,16 +56058,16 @@ 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 === 167 /* GetAccessor */ || declaration.kind === 168 /* SetAccessor */) && - !hasNonBindableDynamicName(declaration) && + if ((declaration.kind === 169 /* GetAccessor */ || declaration.kind === 170 /* SetAccessor */) && + hasBindableName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 167 /* GetAccessor */ ? 168 /* SetAccessor */ : 167 /* GetAccessor */; + var otherKind = declaration.kind === 169 /* GetAccessor */ ? 170 /* SetAccessor */ : 169 /* GetAccessor */; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 166 /* Constructor */ ? + var classType = declaration.kind === 168 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); @@ -54249,8 +56112,7 @@ var ts; if (!(ts.isInJSFile(node) && ts.isFunctionLikeDeclaration(node))) return undefined; var typeTag = ts.getJSDocTypeTag(node); - var signature = typeTag && typeTag.typeExpression && getSingleCallSignature(getTypeFromTypeNode(typeTag.typeExpression)); - return signature && getErasedSignature(signature); + return (typeTag === null || typeTag === void 0 ? void 0 : typeTag.typeExpression) && getSingleCallSignature(getTypeFromTypeNode(typeTag.typeExpression)); } function getReturnTypeOfTypeTag(node) { var signature = getSignatureOfTypeTag(node); @@ -54271,16 +56133,16 @@ var ts; if (!node) return false; switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return node.escapedText === argumentsSymbol.escapedName && getResolvedSymbol(node) === argumentsSymbol; - case 163 /* PropertyDeclaration */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - return node.name.kind === 158 /* ComputedPropertyName */ + case 165 /* PropertyDeclaration */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + return node.name.kind === 160 /* ComputedPropertyName */ && traverse(node.name); - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: return traverse(node.expression); default: return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); @@ -54288,7 +56150,7 @@ var ts; } } function getSignaturesOfSymbol(symbol) { - if (!symbol) + if (!symbol || !symbol.declarations) return ts.emptyArray; var result = []; for (var i = 0; i < symbol.declarations.length; i++) { @@ -54329,8 +56191,8 @@ var ts; var targetTypePredicate = getTypePredicateOfSignature(signature.target); signature.resolvedTypePredicate = targetTypePredicate ? instantiateTypePredicate(targetTypePredicate, signature.mapper) : noTypePredicate; } - else if (signature.unionSignatures) { - signature.resolvedTypePredicate = getUnionTypePredicate(signature.unionSignatures) || noTypePredicate; + else if (signature.compositeSignatures) { + signature.resolvedTypePredicate = getUnionOrIntersectionTypePredicate(signature.compositeSignatures, signature.compositeKind) || noTypePredicate; } else { var type = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); @@ -54352,17 +56214,20 @@ var ts; function createTypePredicateFromTypePredicateNode(node, signature) { var parameterName = node.parameterName; var type = node.type && getTypeFromTypeNode(node.type); - return parameterName.kind === 187 /* ThisType */ ? + return parameterName.kind === 189 /* 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); } + function getUnionOrIntersectionType(types, kind, unionReduction) { + return kind !== 2097152 /* Intersection */ ? getUnionType(types, unionReduction) : getIntersectionType(types); + } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { if (!pushTypeResolution(signature, 3 /* ResolvedReturnType */)) { return errorType; } var type = signature.target ? instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper) : - signature.unionSignatures ? instantiateType(getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature), 2 /* Subtype */), signature.mapper) : + signature.compositeSignatures ? instantiateType(getUnionOrIntersectionType(ts.map(signature.compositeSignatures, getReturnTypeOfSignature), signature.compositeKind, 2 /* Subtype */), signature.mapper) : getReturnTypeFromAnnotation(signature.declaration) || (ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration)); if (signature.flags & 8 /* IsInnerCallChain */) { @@ -54395,7 +56260,7 @@ var ts; return signature.resolvedReturnType; } function getReturnTypeFromAnnotation(declaration) { - if (declaration.kind === 166 /* Constructor */) { + if (declaration.kind === 168 /* Constructor */) { return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)); } if (ts.isJSDocConstructSignature(declaration)) { @@ -54405,12 +56270,12 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 167 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { + if (declaration.kind === 169 /* GetAccessor */ && hasBindableName(declaration)) { var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration); if (jsDocType) { return jsDocType; } - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 168 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 170 /* SetAccessor */); var setterType = getAnnotatedAccessorType(setter); if (setterType) { return setterType; @@ -54487,9 +56352,20 @@ var ts; function getBaseSignature(signature) { var typeParameters = signature.typeParameters; if (typeParameters) { - var typeEraser_1 = createTypeEraser(typeParameters); - var baseConstraints = ts.map(typeParameters, function (tp) { return instantiateType(getBaseConstraintOfType(tp), typeEraser_1) || unknownType; }); - return instantiateSignature(signature, createTypeMapper(typeParameters, baseConstraints), /*eraseTypeParameters*/ true); + if (signature.baseSignatureCache) { + return signature.baseSignatureCache; + } + var typeEraser = createTypeEraser(typeParameters); + var baseConstraintMapper_1 = createTypeMapper(typeParameters, ts.map(typeParameters, function (tp) { return getConstraintOfTypeParameter(tp) || unknownType; })); + var baseConstraints = ts.map(typeParameters, function (tp) { return instantiateType(tp, baseConstraintMapper_1) || unknownType; }); + // Run N type params thru the immediate constraint mapper up to N times + // This way any noncircular interdependent type parameters are definitely resolved to their external dependencies + for (var i = 0; i < typeParameters.length - 1; i++) { + baseConstraints = instantiateTypes(baseConstraints, baseConstraintMapper_1); + } + // and then apply a type eraser to remove any remaining circularly dependent type parameters + baseConstraints = instantiateTypes(baseConstraints, typeEraser); + return signature.baseSignatureCache = instantiateSignature(signature, createTypeMapper(typeParameters, baseConstraints), /*eraseTypeParameters*/ true); } return signature; } @@ -54500,7 +56376,7 @@ var ts; // will result in a different declaration kind. if (!signature.isolatedSignatureType) { var kind = signature.declaration ? signature.declaration.kind : 0 /* Unknown */; - var isConstructor = kind === 166 /* Constructor */ || kind === 170 /* ConstructSignature */ || kind === 175 /* ConstructorType */; + var isConstructor = kind === 168 /* Constructor */ || kind === 172 /* ConstructSignature */ || kind === 177 /* ConstructorType */; var type = createObjectType(16 /* Anonymous */); type.members = emptySymbols; type.properties = ts.emptyArray; @@ -54511,12 +56387,22 @@ var ts; return signature.isolatedSignatureType; } function getIndexSymbol(symbol) { - return symbol.members.get("__index" /* Index */); + return symbol.members ? getIndexSymbolFromSymbolTable(symbol.members) : undefined; + } + function getIndexSymbolFromSymbolTable(symbolTable) { + return symbolTable.get("__index" /* Index */); } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 144 /* NumberKeyword */ : 147 /* StringKeyword */; - var indexSymbol = getIndexSymbol(symbol); - if (indexSymbol) { + var indexSymbol = symbol && getIndexSymbol(symbol); + return indexSymbol && getIndexDeclarationOfIndexSymbol(indexSymbol, kind); + } + function getIndexDeclarationOfSymbolTable(symbolTable, kind) { + var indexSymbol = symbolTable && getIndexSymbolFromSymbolTable(symbolTable); + return indexSymbol && getIndexDeclarationOfIndexSymbol(indexSymbol, kind); + } + function getIndexDeclarationOfIndexSymbol(indexSymbol, kind) { + var syntaxKind = kind === 1 /* Number */ ? 145 /* NumberKeyword */ : 148 /* StringKeyword */; + if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; var node = ts.cast(decl, ts.isIndexSignatureDeclaration); @@ -54544,17 +56430,18 @@ var ts; return ts.mapDefined(ts.filter(type.symbol && type.symbol.declarations, ts.isTypeParameterDeclaration), ts.getEffectiveConstraintOfTypeParameter)[0]; } function getInferredTypeParameterConstraint(typeParameter) { + var _a; var inferences; - if (typeParameter.symbol) { - for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.parent.kind === 185 /* InferType */) { + 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 === 187 /* 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 _b = ts.walkUpParenthesizedTypesAndGetParentAndChild(declaration.parent.parent), _c = _b[0], childTypeParameter = _c === void 0 ? declaration.parent : _c, grandParent = _b[1]; - if (grandParent.kind === 173 /* TypeReference */) { + var _c = ts.walkUpParenthesizedTypesAndGetParentAndChild(declaration.parent.parent), _d = _c[0], childTypeParameter = _d === void 0 ? declaration.parent : _d, grandParent = _c[1]; + if (grandParent.kind === 175 /* TypeReference */) { var typeReference = grandParent; var typeParameters = getTypeParametersForTypeReference(typeReference); if (typeParameters) { @@ -54579,21 +56466,32 @@ 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 === 160 /* Parameter */ && grandParent.dotDotDotToken || - grandParent.kind === 181 /* RestType */ || - grandParent.kind === 192 /* NamedTupleMember */ && grandParent.dotDotDotToken) { + else if (grandParent.kind === 162 /* Parameter */ && grandParent.dotDotDotToken || + grandParent.kind === 183 /* RestType */ || + grandParent.kind === 194 /* 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 === 194 /* TemplateLiteralTypeSpan */) { + else if (grandParent.kind === 196 /* 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 === 159 /* TypeParameter */ && grandParent.parent.kind === 190 /* MappedType */) { + else if (grandParent.kind === 161 /* TypeParameter */ && grandParent.parent.kind === 192 /* 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 === 192 /* MappedType */ && grandParent.type && + ts.skipParentheses(grandParent.type) === declaration.parent && grandParent.parent.kind === 186 /* ConditionalType */ && + grandParent.parent.extendsType === grandParent && grandParent.parent.checkType.kind === 192 /* 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))); + } } } } @@ -54616,7 +56514,7 @@ var ts; if (type.flags & 1 /* Any */ && type !== errorType) { // 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 === 190 /* MappedType */ ? keyofConstraintType : unknownType; + type = constraintDeclaration.parent.parent.kind === 192 /* MappedType */ ? keyofConstraintType : unknownType; } typeParameter.constraint = type; } @@ -54625,7 +56523,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - var tp = ts.getDeclarationOfKind(typeParameter.symbol, 159 /* TypeParameter */); + var tp = ts.getDeclarationOfKind(typeParameter.symbol, 161 /* TypeParameter */); var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getHostSignatureFromJSDoc(tp.parent) : tp.parent; return host && getSymbolOfNode(host); } @@ -54652,6 +56550,9 @@ var ts; } return result; } + function getAliasId(aliasSymbol, aliasTypeArguments) { + return aliasSymbol ? "@" + getSymbolId(aliasSymbol) + (aliasTypeArguments ? ":" + 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 @@ -54664,7 +56565,7 @@ var ts; result |= ts.getObjectFlags(type); } } - return result & 3670016 /* PropagatingFlags */; + return result & 917504 /* PropagatingFlags */; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); @@ -54686,15 +56587,18 @@ var ts; type.resolvedTypeArguments = source.resolvedTypeArguments; return type; } - function createDeferredTypeReference(target, node, mapper) { - var aliasSymbol = getAliasSymbolForTypeNode(node); - var aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); + function createDeferredTypeReference(target, node, mapper, aliasSymbol, aliasTypeArguments) { + if (!aliasSymbol) { + aliasSymbol = getAliasSymbolForTypeNode(node); + var localAliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); + aliasTypeArguments = mapper ? instantiateTypes(localAliasTypeArguments, mapper) : localAliasTypeArguments; + } var type = createObjectType(4 /* Reference */, target.symbol); type.target = target; type.node = node; type.mapper = mapper; type.aliasSymbol = aliasSymbol; - type.aliasTypeArguments = mapper ? instantiateTypes(aliasTypeArguments, mapper) : aliasTypeArguments; + type.aliasTypeArguments = aliasTypeArguments; return type; } function getTypeArguments(type) { @@ -54705,8 +56609,8 @@ var ts; } var node = type.node; var typeArguments = !node ? ts.emptyArray : - node.kind === 173 /* TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : - node.kind === 178 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : + node.kind === 175 /* TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : + node.kind === 180 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); if (popTypeResolution()) { type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments; @@ -54748,7 +56652,7 @@ var ts; return errorType; } } - if (node.kind === 173 /* TypeReference */ && isDeferredTypeReferenceNode(node, ts.length(node.typeArguments) !== typeParameters.length)) { + if (node.kind === 175 /* 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 @@ -54759,17 +56663,17 @@ var ts; } return checkNoTypeArguments(node, symbol) ? type : errorType; } - function getTypeAliasInstantiation(symbol, typeArguments) { + function getTypeAliasInstantiation(symbol, typeArguments, aliasSymbol, aliasTypeArguments) { var type = getDeclaredTypeOfSymbol(symbol); if (type === intrinsicMarkerType && intrinsicTypeKinds.has(symbol.escapedName) && typeArguments && typeArguments.length === 1) { return getStringMappingType(symbol, typeArguments[0]); } var links = getSymbolLinks(symbol); var typeParameters = links.typeParameters; - var id = getTypeListId(typeArguments); + var id = getTypeListId(typeArguments) + getAliasId(aliasSymbol, aliasTypeArguments); var instantiation = links.instantiations.get(id); if (!instantiation) { - links.instantiations.set(id, instantiation = instantiateType(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters), ts.isInJSFile(symbol.valueDeclaration))))); + links.instantiations.set(id, instantiation = instantiateTypeWithAlias(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters), ts.isInJSFile(symbol.valueDeclaration))), aliasSymbol, aliasTypeArguments)); } return instantiation; } @@ -54790,15 +56694,26 @@ var ts; ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); return errorType; } - return getTypeAliasInstantiation(symbol, typeArgumentsFromTypeReferenceNode(node)); + // We refrain from associating a local type alias with an instantiation of a top-level type alias + // because the local alias may end up being referenced in an inferred return type where it is not + // accessible--which in turn may lead to a large structural expansion of the type when generating + // a .d.ts file. See #43622 for an example. + var aliasSymbol = getAliasSymbolForTypeNode(node); + var newAliasSymbol = aliasSymbol && (isLocalTypeAlias(symbol) || !isLocalTypeAlias(aliasSymbol)) ? aliasSymbol : undefined; + return getTypeAliasInstantiation(symbol, typeArgumentsFromTypeReferenceNode(node), newAliasSymbol, getTypeArgumentsForAliasSymbol(newAliasSymbol)); } return checkNoTypeArguments(node, symbol) ? type : errorType; } + function isLocalTypeAlias(symbol) { + var _a; + var declaration = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isTypeAlias); + return !!(declaration && ts.getContainingFunction(declaration)); + } function getTypeReferenceName(node) { switch (node.kind) { - case 173 /* TypeReference */: + case 175 /* TypeReference */: return node.typeName; - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -54854,7 +56769,7 @@ var ts; var valueType = getTypeOfSymbol(symbol); var typeType = valueType; if (symbol.valueDeclaration) { - var isImportTypeWithQualifier = node.kind === 195 /* ImportType */ && node.qualifier; + var isImportTypeWithQualifier = node.kind === 197 /* 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); @@ -54880,7 +56795,7 @@ var ts; return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 179 /* TupleType */ && node.elements.length === 1; + return node.kind === 181 /* TupleType */ && node.elements.length === 1; } function getImpliedConstraint(type, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(type, checkNode.elements[0], extendsNode.elements[0]) : @@ -54889,9 +56804,17 @@ var ts; } function getConditionalFlowTypeOfType(type, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 311 /* JSDocComment */) { + var covariant = true; + while (node && !ts.isStatement(node) && node.kind !== 314 /* JSDocComment */) { var parent = node.parent; - if (parent.kind === 184 /* ConditionalType */ && node === parent.trueType) { + // 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 === 162 /* 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 === 186 /* ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(type, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -54902,7 +56825,7 @@ var ts; return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type; } function isJSDocTypeReference(node) { - return !!(node.flags & 4194304 /* JSDoc */) && (node.kind === 173 /* TypeReference */ || node.kind === 195 /* ImportType */); + return !!(node.flags & 4194304 /* JSDoc */) && (node.kind === 175 /* TypeReference */ || node.kind === 197 /* ImportType */); } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -55012,13 +56935,15 @@ var ts; function getTypeOfGlobalSymbol(symbol, arity) { function getTypeDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { - var declaration = declarations_3[_i]; - switch (declaration.kind) { - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - return declaration; + if (declarations) { + for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { + var declaration = declarations_3[_i]; + switch (declaration.kind) { + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 257 /* EnumDeclaration */: + return declaration; + } } } } @@ -55062,6 +56987,9 @@ var ts; function getGlobalESSymbolConstructorSymbol(reportErrors) { return deferredGlobalESSymbolConstructorSymbol || (deferredGlobalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol", reportErrors)); } + function getGlobalESSymbolConstructorTypeSymbol(reportErrors) { + return deferredGlobalESSymbolConstructorTypeSymbol || (deferredGlobalESSymbolConstructorTypeSymbol = getGlobalTypeSymbol("SymbolConstructor", reportErrors)); + } function getGlobalESSymbolType(reportErrors) { return deferredGlobalESSymbolType || (deferredGlobalESSymbolType = getGlobalType("Symbol", /*arity*/ 0, reportErrors)) || emptyObjectType; } @@ -55138,11 +57066,11 @@ var ts; } function getTupleElementFlags(node) { switch (node.kind) { - case 180 /* OptionalType */: + case 182 /* OptionalType */: return 2 /* Optional */; - case 181 /* RestType */: + case 183 /* RestType */: return getRestTypeElementFlags(node); - case 192 /* NamedTupleMember */: + case 194 /* NamedTupleMember */: return node.questionToken ? 2 /* Optional */ : node.dotDotDotToken ? getRestTypeElementFlags(node) : 1 /* Required */; @@ -55160,14 +57088,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 !== 192 /* NamedTupleMember */; }); + var missingName = ts.some(node.elements, function (e) { return e.kind !== 194 /* 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 === 178 /* ArrayType */ ? mayResolveTypeAlias(node.elementType) : - node.kind === 179 /* TupleType */ ? ts.some(node.elements, mayResolveTypeAlias) : + return !!getAliasSymbolForTypeNode(node) || isResolvedByTypeAlias(node) && (node.kind === 180 /* ArrayType */ ? mayResolveTypeAlias(node.elementType) : + node.kind === 181 /* 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 @@ -55176,18 +57104,18 @@ var ts; function isResolvedByTypeAlias(node) { var parent = node.parent; switch (parent.kind) { - case 186 /* ParenthesizedType */: - case 192 /* NamedTupleMember */: - case 173 /* TypeReference */: - case 182 /* UnionType */: - case 183 /* IntersectionType */: - case 189 /* IndexedAccessType */: - case 184 /* ConditionalType */: - case 188 /* TypeOperator */: - case 178 /* ArrayType */: - case 179 /* TupleType */: + case 188 /* ParenthesizedType */: + case 194 /* NamedTupleMember */: + case 175 /* TypeReference */: + case 184 /* UnionType */: + case 185 /* IntersectionType */: + case 191 /* IndexedAccessType */: + case 186 /* ConditionalType */: + case 190 /* TypeOperator */: + case 180 /* ArrayType */: + case 181 /* TupleType */: return isResolvedByTypeAlias(parent); - case 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: return true; } return false; @@ -55196,28 +57124,28 @@ var ts; // of a type alias. function mayResolveTypeAlias(node) { switch (node.kind) { - case 173 /* TypeReference */: + case 175 /* TypeReference */: return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node.typeName, 788968 /* Type */).flags & 524288 /* TypeAlias */); - case 176 /* TypeQuery */: + case 178 /* TypeQuery */: return true; - case 188 /* TypeOperator */: - return node.operator !== 151 /* UniqueKeyword */ && mayResolveTypeAlias(node.type); - case 186 /* ParenthesizedType */: - case 180 /* OptionalType */: - case 192 /* NamedTupleMember */: - case 307 /* JSDocOptionalType */: - case 305 /* JSDocNullableType */: - case 306 /* JSDocNonNullableType */: - case 301 /* JSDocTypeExpression */: + case 190 /* TypeOperator */: + return node.operator !== 152 /* UniqueKeyword */ && mayResolveTypeAlias(node.type); + case 188 /* ParenthesizedType */: + case 182 /* OptionalType */: + case 194 /* NamedTupleMember */: + case 310 /* JSDocOptionalType */: + case 308 /* JSDocNullableType */: + case 309 /* JSDocNonNullableType */: + case 303 /* JSDocTypeExpression */: return mayResolveTypeAlias(node.type); - case 181 /* RestType */: - return node.type.kind !== 178 /* ArrayType */ || mayResolveTypeAlias(node.type.elementType); - case 182 /* UnionType */: - case 183 /* IntersectionType */: + case 183 /* RestType */: + return node.type.kind !== 180 /* ArrayType */ || mayResolveTypeAlias(node.type.elementType); + case 184 /* UnionType */: + case 185 /* IntersectionType */: return ts.some(node.types, mayResolveTypeAlias); - case 189 /* IndexedAccessType */: + case 191 /* IndexedAccessType */: return mayResolveTypeAlias(node.objectType) || mayResolveTypeAlias(node.indexType); - case 184 /* ConditionalType */: + case 186 /* ConditionalType */: return mayResolveTypeAlias(node.checkType) || mayResolveTypeAlias(node.extendsType) || mayResolveTypeAlias(node.trueType) || mayResolveTypeAlias(node.falseType); } @@ -55230,19 +57158,19 @@ var ts; if (target === emptyGenericType) { links.resolvedType = emptyObjectType; } - else if (!(node.kind === 179 /* TupleType */ && ts.some(node.elements, function (e) { return !!(getTupleElementFlags(e) & 8 /* Variadic */); })) && isDeferredTypeReferenceNode(node)) { - links.resolvedType = node.kind === 179 /* TupleType */ && node.elements.length === 0 ? target : + else if (!(node.kind === 181 /* TupleType */ && ts.some(node.elements, function (e) { return !!(getTupleElementFlags(e) & 8 /* Variadic */); })) && isDeferredTypeReferenceNode(node)) { + links.resolvedType = node.kind === 181 /* TupleType */ && node.elements.length === 0 ? target : createDeferredTypeReference(target, node, /*mapper*/ undefined); } else { - var elementTypes = node.kind === 178 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); + var elementTypes = node.kind === 180 /* 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 === 142 /* ReadonlyKeyword */; + return ts.isTypeOperatorNode(node) && node.operator === 143 /* ReadonlyKeyword */; } function createTupleType(elementTypes, elementFlags, readonly, namedMemberDeclarations) { if (readonly === void 0) { readonly = false; } @@ -55367,8 +57295,15 @@ var ts; addElement(type, 8 /* Variadic */, (_a = target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]); } else if (isTupleType(type)) { + var elements = getTypeArguments(type); + if (elements.length + expandedTypes.length >= 10000) { + error(currentNode, ts.isPartOfTypeNode(currentNode) + ? ts.Diagnostics.Type_produces_a_tuple_type_that_is_too_large_to_represent + : ts.Diagnostics.Expression_produces_a_tuple_type_that_is_too_large_to_represent); + return { value: errorType }; + } // Spread variadic elements with tuple types into the resulting tuple. - ts.forEach(getTypeArguments(type), function (t, n) { var _a; return addElement(t, type.target.elementFlags[n], (_a = type.target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[n]); }); + ts.forEach(elements, function (t, n) { var _a; return addElement(t, type.target.elementFlags[n], (_a = type.target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[n]); }); } else { // Treat everything else as an array type and create a rest element. @@ -55381,7 +57316,9 @@ var ts; } }; for (var i = 0; i < elementTypes.length; i++) { - _loop_13(i); + var state_4 = _loop_13(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++) { @@ -55440,8 +57377,7 @@ var ts; return type.elementFlags.length - ts.findLastIndex(type.elementFlags, function (f) { return !(f & flags); }) - 1; } function getTypeFromOptionalTypeNode(node) { - var type = getTypeFromTypeNode(node.type); - return strictNullChecks ? getOptionalType(type) : type; + return addOptionality(getTypeFromTypeNode(node.type), /*isProperty*/ true); } function getTypeId(type) { return type.id; @@ -55470,7 +57406,7 @@ var ts; if (type === wildcardType) includes |= 8388608 /* IncludesWildcard */; if (!strictNullChecks && flags & 98304 /* Nullable */) { - if (!(ts.getObjectFlags(type) & 524288 /* ContainsWideningType */)) + if (!(ts.getObjectFlags(type) & 131072 /* ContainsWideningType */)) includes |= 4194304 /* IncludesNonWideningType */; } else { @@ -55492,67 +57428,76 @@ var ts; } return includes; } - function isSetOfLiteralsFromSameEnum(types) { - var first = types[0]; - if (first.flags & 1024 /* EnumLiteral */) { - var firstEnum = getParentOfSymbol(first.symbol); - for (var i = 1; i < types.length; i++) { - var other = types[i]; - if (!(other.flags & 1024 /* EnumLiteral */) || (firstEnum !== getParentOfSymbol(other.symbol))) { - return false; - } - } - return true; + function removeSubtypes(types, hasObjectTypes) { + var id = getTypeListId(types); + var match = subtypeReductionCache.get(id); + if (match) { + return match; } - return false; - } - function removeSubtypes(types, primitivesOnly) { + // 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 len = types.length; - if (len === 0 || isSetOfLiteralsFromSameEnum(types)) { - return true; - } var i = len; var count = 0; while (i > 0) { i--; var source = types[i]; - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var target = types_11[_i]; - if (source !== target) { - if (count === 100000) { - // After 100000 subtype checks we estimate the remaining amount of work by assuming the - // same ratio of checks per element. If the estimated number of remaining type checks is - // greater than an upper limit we deem the union type too complex to represent. The - // upper limit is 25M for unions of primitives only, and 1M otherwise. This for example - // caps union types at 5000 unique literal types and 1000 unique object types. - var estimatedCount = (count / (len - i)) * len; - if (estimatedCount > (primitivesOnly ? 25000000 : 1000000)) { - ts.tracing.instant("checkTypes" /* 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 false; + if (hasEmptyObject || source.flags & 469499904 /* 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 */) ? + ts.find(getPropertiesOfType(source), function (p) { return isUnitType(getTypeOfSymbol(p)); }) : + undefined; + var keyPropertyType = keyProperty && getRegularTypeOfLiteralType(getTypeOfSymbol(keyProperty)); + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var target = types_11[_i]; + if (source !== target) { + if (count === 100000) { + // After 100000 subtype checks we estimate the remaining amount of work by assuming the + // same ratio of checks per element. If the estimated number of remaining type checks is + // greater than 1M we deem the union type too complex to represent. This for example + // 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; }) }); + 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 */)) { + 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 */) || + isTypeDerivedFrom(source, target))) { + ts.orderedRemoveItemAt(types, i); + break; } - } - count++; - if (isTypeRelatedTo(source, target, strictSubtypeRelation) && (!(ts.getObjectFlags(getTargetType(source)) & 1 /* Class */) || - !(ts.getObjectFlags(getTargetType(target)) & 1 /* Class */) || - isTypeDerivedFrom(source, target))) { - ts.orderedRemoveItemAt(types, i); - break; } } } } - return true; + subtypeReductionCache.set(id, types); + return types; } - function removeRedundantLiteralTypes(types, includes) { + function removeRedundantLiteralTypes(types, includes, reduceVoidUndefined) { var i = types.length; while (i > 0) { i--; var t = types[i]; - var remove = t.flags & 134217856 /* StringLikeLiteral */ && includes & 4 /* String */ || - t.flags & 256 /* NumberLiteral */ && includes & 8 /* Number */ || - t.flags & 2048 /* BigIntLiteral */ && includes & 64 /* BigInt */ || - t.flags & 8192 /* UniqueESSymbol */ && includes & 4096 /* ESSymbol */ || + var flags = t.flags; + var remove = flags & 128 /* StringLiteral */ && 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 */ || isFreshLiteralType(t) && containsType(types, t.regularType); if (remove) { ts.orderedRemoveItemAt(types, i); @@ -55584,7 +57529,7 @@ var ts; if (t.flags & 1048576 /* Union */) { var origin = t.origin; if (t.aliasSymbol || origin && !(origin.flags & 1048576 /* Union */)) { - namedUnions.push(t); + ts.pushIfUnique(namedUnions, t); } else if (origin && origin.flags & 1048576 /* Union */) { addNamedUnions(namedUnions, origin.types); @@ -55618,20 +57563,23 @@ var ts; if (includes & 3 /* AnyOrUnknown */) { return includes & 1 /* Any */ ? includes & 8388608 /* IncludesWildcard */ ? wildcardType : anyType : unknownType; } - switch (unionReduction) { - case 1 /* Literal */: - if (includes & (134220672 /* FreshableLiteral */ | 8192 /* UniqueESSymbol */)) { - removeRedundantLiteralTypes(typeSet, includes); - } - if (includes & 128 /* StringLiteral */ && includes & 134217728 /* TemplateLiteral */) { - removeStringLiteralsMatchedByTemplateLiterals(typeSet); - } - break; - case 2 /* Subtype */: - if (!removeSubtypes(typeSet, !(includes & 262144 /* IncludesStructuredOrInstantiable */))) { - return errorType; - } - break; + if (strictOptionalProperties && includes & 32768 /* 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 */) || includes & 16384 /* Void */ && includes & 32768 /* Undefined */) { + removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2 /* Subtype */)); + } + if (includes & 128 /* StringLiteral */ && includes & 134217728 /* TemplateLiteral */) { + removeStringLiteralsMatchedByTemplateLiterals(typeSet); + } + if (unionReduction === 2 /* Subtype */) { + typeSet = removeSubtypes(typeSet, !!(includes & 524288 /* Object */)); + if (!typeSet) { + return errorType; + } } if (typeSet.length === 0) { return includes & 65536 /* Null */ ? includes & 4194304 /* IncludesNonWideningType */ ? nullType : nullWideningType : @@ -55666,18 +57614,23 @@ var ts; origin = createOriginUnionOrIntersectionType(1048576 /* Union */, reducedTypes); } } - var objectFlags = (includes & 468598819 /* NotPrimitiveUnion */ ? 0 : 262144 /* PrimitiveUnion */) | - (includes & 2097152 /* Intersection */ ? 268435456 /* ContainsIntersections */ : 0); + var objectFlags = (includes & 468598819 /* NotPrimitiveUnion */ ? 0 : 65536 /* PrimitiveUnion */) | + (includes & 2097152 /* Intersection */ ? 67108864 /* ContainsIntersections */ : 0); return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin); } - function getUnionTypePredicate(signatures) { + function getUnionOrIntersectionTypePredicate(signatures, kind) { var first; var types = []; 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 */) { - continue; + if (kind !== 2097152 /* Intersection */) { + continue; + } + else { + return; // intersections demand all members be type predicates for the result to have a predicate + } } if (first) { if (!typePredicateKindsMatch(first, pred)) { @@ -55691,11 +57644,11 @@ var ts; types.push(pred.type); } if (!first) { - // No union signatures had a type predicate. + // No signatures had a type predicate. return undefined; } - var unionType = getUnionType(types); - return createTypePredicate(first.kind, first.parameterName, first.parameterIndex, unionType); + var compositeType = getUnionOrIntersectionType(types, kind); + return createTypePredicate(first.kind, first.parameterName, first.parameterIndex, compositeType); } function typePredicateKindsMatch(a, b) { return a.kind === b.kind && a.parameterIndex === b.parameterIndex; @@ -55720,8 +57673,8 @@ var ts; var typeKey = !origin ? getTypeListId(types) : origin.flags & 1048576 /* Union */ ? "|" + getTypeListId(origin.types) : origin.flags & 2097152 /* Intersection */ ? "&" + getTypeListId(origin.types) : - "#" + origin.type.id; - var id = typeKey + (aliasSymbol ? "@" + getSymbolId(aliasSymbol) : ""); + "#" + 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 + var id = typeKey + getAliasId(aliasSymbol, aliasTypeArguments); var type = unionTypes.get(id); if (!type) { type = createUnionType(types, aliasSymbol, aliasTypeArguments, origin); @@ -55847,7 +57800,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) & 262144 /* PrimitiveUnion */); }); + var index = ts.findIndex(types, function (t) { return !!(ts.getObjectFlags(t) & 65536 /* PrimitiveUnion */); }); if (index < 0) { return false; } @@ -55856,7 +57809,7 @@ var ts; // the unionTypes array. while (i < types.length) { var t = types[i]; - if (ts.getObjectFlags(t) & 262144 /* PrimitiveUnion */) { + if (ts.getObjectFlags(t) & 65536 /* PrimitiveUnion */) { (unionTypes || (unionTypes = [types[index]])).push(t); ts.orderedRemoveItemAt(types, i); } @@ -55885,14 +57838,14 @@ var ts; } } // Finally replace the first union with the result - types[index] = getUnionTypeFromSortedList(result, 262144 /* PrimitiveUnion */); + types[index] = getUnionTypeFromSortedList(result, 65536 /* PrimitiveUnion */); return true; } function createIntersectionType(types, aliasSymbol, aliasTypeArguments) { var result = createType(2097152 /* Intersection */); result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */); result.types = types; - result.aliasSymbol = aliasSymbol; // See comment in `getUnionTypeFromSortedList`. + result.aliasSymbol = aliasSymbol; result.aliasTypeArguments = aliasTypeArguments; return result; } @@ -55953,7 +57906,7 @@ var ts; if (typeSet.length === 1) { return typeSet[0]; } - var id = getTypeListId(typeSet) + (aliasSymbol ? "@" + getSymbolId(aliasSymbol) : ""); + var id = getTypeListId(typeSet) + getAliasId(aliasSymbol, aliasTypeArguments); var result = intersectionTypes.get(id); if (!result) { if (includes & 1048576 /* Union */) { @@ -55996,7 +57949,7 @@ var ts; function checkCrossProductUnion(types) { var size = getCrossProductUnionSize(types); if (size >= 100000) { - 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" /* 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; } @@ -56046,23 +57999,36 @@ var ts; type.resolvedStringIndexType || (type.resolvedStringIndexType = createIndexType(type, /*stringsOnly*/ true)) : type.resolvedIndexType || (type.resolvedIndexType = createIndexType(type, /*stringsOnly*/ false)); } + function instantiateTypeAsMappedNameType(nameType, type, t) { + return instantiateType(nameType, appendTypeMapping(type.mapper, getTypeParameterFromMappedType(type), t)); + } function getIndexTypeForMappedType(type, noIndexSignatures) { var constraint = filterType(getConstraintTypeFromMappedType(type), function (t) { return !(noIndexSignatures && t.flags & (1 /* Any */ | 4 /* String */)); }); var nameType = type.declaration.nameType && getTypeFromTypeNode(type.declaration.nameType); + // If the constraint is exclusively string/number/never type(s), we need to pull the property names from the modified type and run them through the `nameType` mapper as well + // since they won't appear in the constraint, due to subtype reducing with the string/number index types + var properties = nameType && everyType(constraint, function (t) { return !!(t.flags & (4 /* String */ | 8 /* Number */ | 131072 /* Never */)); }) && getPropertiesOfType(getApparentType(getModifiersTypeFromMappedType(type))); return nameType ? - mapType(constraint, function (t) { return instantiateType(nameType, appendTypeMapping(type.mapper, getTypeParameterFromMappedType(type), t)); }) : + getUnionType([mapType(constraint, function (t) { return instantiateTypeAsMappedNameType(nameType, type, t); }), mapType(getUnionType(ts.map(properties || ts.emptyArray, function (p) { return getLiteralTypeFromProperty(p, 8576 /* StringOrNumberLiteralOrUnique */); })), function (t) { return instantiateTypeAsMappedNameType(nameType, type, t); })]) : constraint; } // Ordinarily we reduce a keyof M, where M is a mapped type { [P in K as N

]: X }, to simply N. This however presumes - // that N distributes over union types, i.e. that N is equivalent to N | N | N. That presumption may not - // be true when N is a non-distributive conditional type or an instantiable type with a non-distributive conditional type as - // a constituent. In those cases, we cannot reduce keyof M and need to preserve it as is. - function maybeNonDistributiveNameType(type) { - return !!(type && (type.flags & 16777216 /* Conditional */ && (!type.root.isDistributive || maybeNonDistributiveNameType(type.checkType)) || - type.flags & (3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */) && ts.some(type.types, maybeNonDistributiveNameType) || - type.flags & (4194304 /* Index */ | 268435456 /* StringMapping */) && maybeNonDistributiveNameType(type.type) || - type.flags & 8388608 /* IndexedAccess */ && maybeNonDistributiveNameType(type.indexType) || - type.flags & 33554432 /* Substitution */ && maybeNonDistributiveNameType(type.substitute))); + // that N distributes over union types, i.e. that N is equivalent to N | N | N. Specifically, we only + // want to perform the reduction when the name type of a mapped type is distributive with respect to the type variable + // introduced by the 'in' clause of the mapped type. Note that non-generic types are considered to be distributive because + // they're the same type regardless of what's being distributed over. + function hasDistributiveNameType(mappedType) { + 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) : + false; + } } function getLiteralTypeFromPropertyName(name) { if (ts.isPrivateIdentifier(name)) { @@ -56080,13 +58046,13 @@ var ts; function getLiteralTypeFromProperty(prop, include) { if (!(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24 /* NonPublicAccessibilityModifier */)) { var type = getSymbolLinks(getLateBoundSymbol(prop)).nameType; - if (!type && !ts.isKnownSymbol(prop)) { + if (!type) { if (prop.escapedName === "default" /* Default */) { type = getLiteralType("default"); } else { var name = prop.valueDeclaration && ts.getNameOfDeclaration(prop.valueDeclaration); - type = name && getLiteralTypeFromPropertyName(name) || getLiteralType(ts.symbolName(prop)); + type = name && getLiteralTypeFromPropertyName(name) || (!ts.isKnownSymbol(prop) ? getLiteralType(ts.symbolName(prop)) : undefined); } } if (type && type.flags & include) { @@ -56110,7 +58076,7 @@ var ts; type = getReducedType(type); return type.flags & 1048576 /* Union */ ? 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) && maybeNonDistributiveNameType(getNameTypeFromMappedType(type)) ? getIndexTypeForGenericType(type, stringsOnly) : + type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) ? getIndexTypeForGenericType(type, stringsOnly) : ts.getObjectFlags(type) & 32 /* Mapped */ ? getIndexTypeForMappedType(type, noIndexSignatures) : type === wildcardType ? wildcardType : type.flags & 2 /* Unknown */ ? neverType : @@ -56135,15 +58101,15 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { switch (node.operator) { - case 138 /* KeyOfKeyword */: + case 139 /* KeyOfKeyword */: links.resolvedType = getIndexType(getTypeFromTypeNode(node.type)); break; - case 151 /* UniqueKeyword */: - links.resolvedType = node.type.kind === 148 /* SymbolKeyword */ + case 152 /* UniqueKeyword */: + links.resolvedType = node.type.kind === 149 /* SymbolKeyword */ ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent)) : errorType; break; - case 142 /* ReadonlyKeyword */: + case 143 /* ReadonlyKeyword */: links.resolvedType = getTypeFromTypeNode(node.type); break; default: @@ -56186,7 +58152,6 @@ var ts; var type = templateLiteralTypes.get(id); if (!type) { templateLiteralTypes.set(id, type = createTemplateLiteralType(newTexts, newTypes)); - type.regularType = type; } return type; function addSpans(texts, types) { @@ -56218,10 +58183,8 @@ var ts; 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 */ ? type.intrinsicName : - type.flags & 65536 /* Null */ ? "null" : - type.flags & 32768 /* Undefined */ ? "undefined" : - undefined; + type.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) ? type.intrinsicName : + undefined; } function createTemplateLiteralType(texts, types) { var type = createType(134217728 /* TemplateLiteral */); @@ -56258,13 +58221,13 @@ var ts; result.type = type; return result; } - function createIndexedAccessType(objectType, indexType, aliasSymbol, aliasTypeArguments, shouldIncludeUndefined) { + function createIndexedAccessType(objectType, indexType, accessFlags, aliasSymbol, aliasTypeArguments) { var type = createType(8388608 /* IndexedAccess */); type.objectType = objectType; type.indexType = indexType; + type.accessFlags = accessFlags; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; - type.noUncheckedIndexedAccessCandidate = shouldIncludeUndefined; return type; } /** @@ -56280,7 +58243,7 @@ var ts; if (noImplicitAny) { return false; // Flag is meaningless under `noImplicitAny` mode } - if (ts.getObjectFlags(type) & 16384 /* JSLiteral */) { + if (ts.getObjectFlags(type) & 8192 /* JSLiteral */) { return true; } if (type.flags & 1048576 /* Union */) { @@ -56290,20 +58253,18 @@ var ts; return ts.some(type.types, isJSLiteralType); } if (type.flags & 465829888 /* Instantiable */) { - return isJSLiteralType(getResolvedBaseConstraint(type)); + var constraint = getResolvedBaseConstraint(type); + return constraint !== type && isJSLiteralType(constraint); } return false; } function getPropertyNameFromIndex(indexType, accessNode) { - var accessExpression = accessNode && accessNode.kind === 202 /* ElementAccessExpression */ ? accessNode : undefined; return isTypeUsableAsPropertyName(indexType) ? getPropertyNameFromType(indexType) : - accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? - ts.getPropertyNameForKnownSymbolName(ts.idText(accessExpression.argumentExpression.name)) : - accessNode && ts.isPropertyName(accessNode) ? - // late bound names are handled in the first branch, so here we only need to handle normal names - ts.getPropertyNameForPropertyNameNode(accessNode) : - undefined; + accessNode && ts.isPropertyName(accessNode) ? + // late bound names are handled in the first branch, so here we only need to handle normal names + ts.getPropertyNameForPropertyNameNode(accessNode) : + undefined; } function isUncalledFunctionReference(node, symbol) { if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { @@ -56315,24 +58276,27 @@ var ts; } return true; } - function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, suppressNoImplicitAnyError, accessNode, accessFlags, noUncheckedIndexedAccessCandidate, reportDeprecated) { + function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, accessNode, accessFlags) { var _a; - var accessExpression = accessNode && accessNode.kind === 202 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 204 /* ElementAccessExpression */ ? accessNode : undefined; var propName = accessNode && ts.isPrivateIdentifier(accessNode) ? undefined : getPropertyNameFromIndex(indexType, accessNode); if (propName !== undefined) { + if (accessFlags & 256 /* Contextual */) { + return getTypeOfPropertyOfContextualType(objectType, propName) || anyType; + } var prop = getPropertyOfType(objectType, propName); if (prop) { - if (reportDeprecated && accessNode && getDeclarationNodeFlagsFromSymbol(prop) & 134217728 /* Deprecated */ && isUncalledFunctionReference(accessNode, prop)) { + if (accessFlags & 64 /* ReportDeprecated */ && accessNode && prop.declarations && getDeclarationNodeFlagsFromSymbol(prop) & 134217728 /* Deprecated */ && 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); - errorOrSuggestion(/* isError */ false, deprecatedNode, ts.Diagnostics._0_is_deprecated, propName); + addDeprecatedSuggestion(deprecatedNode, prop.declarations, propName); } if (accessExpression) { - markPropertyAsReferenced(prop, accessExpression, /*isThisAccess*/ accessExpression.expression.kind === 107 /* ThisKeyword */); + markPropertyAsReferenced(prop, accessExpression, isSelfTypeAccess(accessExpression.expression, objectType.symbol)); if (isAssignmentToReadonlyEntity(accessExpression, prop, ts.getAssignmentTargetKind(accessExpression))) { error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(prop)); return undefined; } - if (accessFlags & 4 /* CacheSymbol */) { + if (accessFlags & 8 /* CacheSymbol */) { getNodeLinks(accessNode).resolvedSymbol = prop; } if (isThisPropertyAccessInConstructor(accessExpression, prop)) { @@ -56345,7 +58309,7 @@ var ts; propType; } if (everyType(objectType, isTupleType) && isNumericLiteralName(propName) && +propName >= 0) { - if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 8 /* NoTupleBoundsCheck */)) { + if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 16 /* NoTupleBoundsCheck */)) { var indexNode = getIndexNodeForAccessExpression(accessNode); if (isTupleType(objectType)) { error(indexNode, ts.Diagnostics.Tuple_type_0_of_length_1_has_no_element_at_index_2, typeToString(objectType), getTypeReferenceArity(objectType), ts.unescapeLeadingUnderscores(propName)); @@ -56357,7 +58321,7 @@ var ts; errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, 1 /* Number */)); return mapType(objectType, function (t) { var restType = getRestTypeOfTupleType(t) || undefinedType; - return noUncheckedIndexedAccessCandidate ? getUnionType([restType, undefinedType]) : restType; + return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([restType, undefinedType]) : restType; }); } } @@ -56368,7 +58332,7 @@ var ts; var stringIndexInfo = getIndexInfoOfType(objectType, 0 /* String */); var indexInfo = isTypeAssignableToKind(indexType, 296 /* NumberLike */) && getIndexInfoOfType(objectType, 1 /* Number */) || stringIndexInfo; if (indexInfo) { - if (accessFlags & 1 /* NoIndexSignatures */ && indexInfo === stringIndexInfo) { + if (accessFlags & 2 /* NoIndexSignatures */ && indexInfo === stringIndexInfo) { if (accessExpression) { error(accessExpression, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(originalObjectType)); } @@ -56377,10 +58341,10 @@ var ts; if (accessNode && !isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) { var indexNode = getIndexNodeForAccessExpression(accessNode); error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); - return noUncheckedIndexedAccessCandidate ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; + return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; } errorIfWritingToReadonlyIndex(indexInfo); - return noUncheckedIndexedAccessCandidate ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; + return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; } if (indexType.flags & 131072 /* Never */) { return neverType; @@ -56404,7 +58368,7 @@ var ts; if (objectType.symbol === globalThisSymbol && propName !== undefined && globalThisSymbol.exports.has(propName) && (globalThisSymbol.exports.get(propName).flags & 418 /* BlockScoped */)) { error(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType)); } - else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !suppressNoImplicitAnyError) { + else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !(accessFlags & 128 /* 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) + "]"); @@ -56477,13 +58441,13 @@ var ts; } } function getIndexNodeForAccessExpression(accessNode) { - return accessNode.kind === 202 /* ElementAccessExpression */ ? accessNode.argumentExpression : - accessNode.kind === 189 /* IndexedAccessType */ ? accessNode.indexType : - accessNode.kind === 158 /* ComputedPropertyName */ ? accessNode.expression : + return accessNode.kind === 204 /* ElementAccessExpression */ ? accessNode.argumentExpression : + accessNode.kind === 191 /* IndexedAccessType */ ? accessNode.indexType : + accessNode.kind === 160 /* ComputedPropertyName */ ? accessNode.expression : accessNode; } function isPatternLiteralPlaceholderType(type) { - return templateConstraintType.types.indexOf(type) !== -1 || !!(type.flags & 1 /* Any */); + return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */)); } function isPatternLiteralType(type) { return !!(type.flags & 134217728 /* TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType); @@ -56496,6 +58460,13 @@ var ts; } return !!(type.objectFlags & 8388608 /* IsGenericObjectType */); } + if (type.flags & 33554432 /* Substitution */) { + if (!(type.objectFlags & 4194304 /* IsGenericObjectTypeComputed */)) { + type.objectFlags |= 4194304 /* IsGenericObjectTypeComputed */ | + (isGenericObjectType(type.substitute) || isGenericObjectType(type.baseType) ? 8388608 /* IsGenericObjectType */ : 0); + } + return !!(type.objectFlags & 8388608 /* IsGenericObjectType */); + } return !!(type.flags & 58982400 /* InstantiableNonPrimitive */) || isGenericMappedType(type) || isGenericTupleType(type); } function isGenericIndexType(type) { @@ -56506,6 +58477,13 @@ var ts; } return !!(type.objectFlags & 33554432 /* IsGenericIndexType */); } + if (type.flags & 33554432 /* Substitution */) { + if (!(type.objectFlags & 16777216 /* IsGenericIndexTypeComputed */)) { + type.objectFlags |= 16777216 /* IsGenericIndexTypeComputed */ | + (isGenericIndexType(type.substitute) || isGenericIndexType(type.baseType) ? 33554432 /* IsGenericIndexType */ : 0); + } + return !!(type.objectFlags & 33554432 /* IsGenericIndexType */); + } return !!(type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */)) && !isPatternLiteralType(type); } function isThisTypeParameter(type) { @@ -56581,6 +58559,12 @@ var ts; } return type[cache] = type; } + function isConditionalTypeAlwaysTrueDisregardingInferTypes(type) { + var extendsInferParamMapper = type.root.inferTypeParameters && createTypeMapper(type.root.inferTypeParameters, ts.map(type.root.inferTypeParameters, function () { return wildcardType; })); + var checkType = type.checkType; + var extendsType = type.extendsType; + return isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(instantiateType(extendsType, extendsInferParamMapper))); + } function getSimplifiedConditionalType(type, writing) { var checkType = type.checkType; var extendsType = type.extendsType; @@ -56616,9 +58600,9 @@ var ts; var templateMapper = combineTypeMappers(objectType.mapper, mapper); return instantiateType(getTemplateTypeFromMappedType(objectType), templateMapper); } - function getIndexedAccessType(objectType, indexType, noUncheckedIndexedAccessCandidate, accessNode, aliasSymbol, aliasTypeArguments, accessFlags) { + function getIndexedAccessType(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) { if (accessFlags === void 0) { accessFlags = 0 /* None */; } - return getIndexedAccessTypeOrUndefined(objectType, indexType, noUncheckedIndexedAccessCandidate, accessNode, accessFlags, aliasSymbol, aliasTypeArguments) || (accessNode ? errorType : unknownType); + return getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) || (accessNode ? errorType : unknownType); } function indexTypeLessThan(indexType, limit) { return everyType(indexType, function (t) { @@ -56632,36 +58616,38 @@ var ts; return false; }); } - function getIndexedAccessTypeOrUndefined(objectType, indexType, noUncheckedIndexedAccessCandidate, accessNode, accessFlags, aliasSymbol, aliasTypeArguments) { + function getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) { if (accessFlags === void 0) { accessFlags = 0 /* None */; } if (objectType === wildcardType || indexType === wildcardType) { return wildcardType; } - var shouldIncludeUndefined = noUncheckedIndexedAccessCandidate || - (!!compilerOptions.noUncheckedIndexedAccess && - (accessFlags & (2 /* Writing */ | 16 /* ExpressionPosition */)) === 16 /* ExpressionPosition */); // 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 */)) { 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 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 !== 189 /* IndexedAccessType */ ? + if (isGenericIndexType(indexType) || (accessNode && accessNode.kind !== 191 /* IndexedAccessType */ ? isGenericTupleType(objectType) && !indexTypeLessThan(indexType, objectType.target.fixedLength) : isGenericObjectType(objectType) && !(isTupleType(objectType) && indexTypeLessThan(indexType, objectType.target.fixedLength)))) { if (objectType.flags & 3 /* AnyOrUnknown */) { return objectType; } // Defer the operation by creating an indexed access type. - var id = objectType.id + "," + indexType.id + (shouldIncludeUndefined ? "?" : "") + (aliasSymbol ? "@" + getSymbolId(aliasSymbol) : ""); + var persistentAccessFlags = accessFlags & 1 /* Persistent */; + var id = objectType.id + "," + indexType.id + "," + persistentAccessFlags + getAliasId(aliasSymbol, aliasTypeArguments); var type = indexedAccessTypes.get(id); if (!type) { - indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType, aliasSymbol, aliasTypeArguments, shouldIncludeUndefined)); + indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType, persistentAccessFlags, aliasSymbol, aliasTypeArguments)); } return type; } @@ -56674,7 +58660,7 @@ var ts; 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, wasMissingProp, accessNode, accessFlags, shouldIncludeUndefined); + var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, indexType, accessNode, accessFlags | (wasMissingProp ? 128 /* SuppressNoImplicitAnyError */ : 0)); if (propType) { propTypes.push(propType); } @@ -56690,11 +58676,11 @@ var ts; if (wasMissingProp) { return undefined; } - return accessFlags & 2 /* Writing */ + return accessFlags & 4 /* Writing */ ? getIntersectionType(propTypes, aliasSymbol, aliasTypeArguments) : getUnionType(propTypes, 1 /* Literal */, aliasSymbol, aliasTypeArguments); } - return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, /* supressNoImplicitAnyError */ false, accessNode, accessFlags | 4 /* CacheSymbol */, shouldIncludeUndefined, /* reportDeprecated */ true); + return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, accessNode, accessFlags | 8 /* CacheSymbol */ | 64 /* ReportDeprecated */); } function getTypeFromIndexedAccessTypeNode(node) { var links = getNodeLinks(node); @@ -56702,7 +58688,7 @@ var ts; var objectType = getTypeFromTypeNode(node.objectType); var indexType = getTypeFromTypeNode(node.indexType); var potentialAlias = getAliasSymbolForTypeNode(node); - var resolved = getIndexedAccessType(objectType, indexType, /*noUncheckedIndexedAccessCandidate*/ undefined, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias)); + var resolved = getIndexedAccessType(objectType, indexType, 0 /* None */, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias)); links.resolvedType = resolved.flags & 8388608 /* IndexedAccess */ && resolved.objectType === objectType && resolved.indexType === indexType ? @@ -56734,16 +58720,32 @@ var ts; } return type; } - function getConditionalType(root, mapper) { + function isTypicalNondistributiveConditional(root) { + return !root.isDistributive + && root.node.checkType.kind === 181 /* TupleType */ + && ts.length(root.node.checkType.elements) === 1 + && root.node.extendsType.kind === 181 /* TupleType */ + && ts.length(root.node.extendsType.elements) === 1; + } + /** + * We syntactually check for common nondistributive conditional shapes and unwrap them into + * the intended comparison - we do this so we can check if the unwrapped types are generic or + * not and appropriately defer condition calculation + */ + function unwrapNondistributiveConditionalTuple(root, type) { + return isTypicalNondistributiveConditional(root) && isTupleType(type) ? getTypeArguments(type)[0] : type; + } + function getConditionalType(root, mapper, aliasSymbol, aliasTypeArguments) { var result; var extraTypes; // We loop here for an immediately nested conditional type in the false position, effectively treating // types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for // purposes of resolution. This means such types aren't subject to the instatiation depth limiter. while (true) { - var checkType = instantiateType(root.checkType, mapper); + var isUnwrapped = isTypicalNondistributiveConditional(root); + var checkType = instantiateType(unwrapNondistributiveConditionalTuple(root, getActualTypeVariable(root.checkType)), mapper); var checkTypeInstantiable = isGenericObjectType(checkType) || isGenericIndexType(checkType); - var extendsType = instantiateType(root.extendsType, mapper); + var extendsType = instantiateType(unwrapNondistributiveConditionalTuple(root, root.extendsType), mapper); if (checkType === wildcardType || extendsType === wildcardType) { return wildcardType; } @@ -56754,21 +58756,24 @@ 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, extendsType, 256 /* NoConstraints */ | 512 /* AlwaysStrict */); + inferTypes(context.inferences, checkType, extendsType, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */); } - combinedMapper = mergeTypeMappers(mapper, context.mapper); + // It's possible for 'infer T' type paramteters to be given uninstantiated constraints when the + // those type parameters are used in type references (see getInferredTypeParameterConstraint). For + // that reason we need context.mapper to be first in the combined mapper. See #42636 for examples. + combinedMapper = mapper ? combineTypeMappers(context.mapper, mapper) : context.mapper; } // Instantiate the extends type including inferences for 'infer T' type parameters - var inferredExtendsType = combinedMapper ? instantiateType(root.extendsType, combinedMapper) : extendsType; + var inferredExtendsType = combinedMapper ? instantiateType(unwrapNondistributiveConditionalTuple(root, root.extendsType), combinedMapper) : extendsType; // We attempt to resolve the conditional type only when the check and extends types are non-generic if (!checkTypeInstantiable && !isGenericObjectType(inferredExtendsType) && !isGenericIndexType(inferredExtendsType)) { // Return falseType for a definitely false extends check. We check an instantiations of the two // 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 */ || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) { + if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && ((checkType.flags & 1 /* Any */ && !isUnwrapped) || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) { // Return union of trueType and falseType for 'any' since it matches anything - if (checkType.flags & 1 /* Any */) { + if (checkType.flags & 1 /* 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 @@ -56797,12 +58802,12 @@ var ts; // Return a deferred type for a check that is neither definitely true nor definitely false result = createType(16777216 /* Conditional */); result.root = root; - result.checkType = checkType; - result.extendsType = extendsType; + result.checkType = instantiateType(root.checkType, mapper); + result.extendsType = instantiateType(root.extendsType, mapper); result.mapper = mapper; result.combinedMapper = combinedMapper; - result.aliasSymbol = root.aliasSymbol; - result.aliasTypeArguments = instantiateTypes(root.aliasTypeArguments, mapper); // TODO: GH#18217 + result.aliasSymbol = aliasSymbol || root.aliasSymbol; + result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(root.aliasTypeArguments, mapper); // TODO: GH#18217 break; } return extraTypes ? getUnionType(ts.append(extraTypes, result)) : result; @@ -56961,7 +58966,7 @@ var ts; } function getAliasSymbolForTypeNode(node) { var host = node.parent; - while (ts.isParenthesizedTypeNode(host) || ts.isJSDocTypeExpression(host) || ts.isTypeOperatorNode(host) && host.operator === 142 /* ReadonlyKeyword */) { + while (ts.isParenthesizedTypeNode(host) || ts.isJSDocTypeExpression(host) || ts.isTypeOperatorNode(host) && host.operator === 143 /* ReadonlyKeyword */) { host = host.parent; } return ts.isTypeAlias(host) ? getSymbolOfNode(host) : undefined; @@ -57000,7 +59005,7 @@ var ts; 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)); - result.type = isSetonlyAccessor ? undefinedType : getUnionType([getTypeOfSymbol(prop), undefinedType]); + result.type = isSetonlyAccessor ? undefinedType : addOptionality(getTypeOfSymbol(prop), /*isProperty*/ true); result.declarations = prop.declarations; result.nameType = getSymbolLinks(prop).nameType; result.syntheticOrigin = prop; @@ -57008,7 +59013,7 @@ var ts; } } var spread = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfoOfType(type, 0 /* String */), getIndexInfoOfType(type, 1 /* Number */)); - spread.objectFlags |= 128 /* ObjectLiteral */ | 1048576 /* ContainsObjectOrArrayLiteral */; + spread.objectFlags |= 128 /* ObjectLiteral */ | 262144 /* ContainsObjectOrArrayLiteral */; return spread; } } @@ -57114,14 +59119,15 @@ var ts; } } var spread = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfoWithReadonly(stringIndexInfo, readonly), getIndexInfoWithReadonly(numberIndexInfo, readonly)); - spread.objectFlags |= 128 /* ObjectLiteral */ | 1048576 /* ContainsObjectOrArrayLiteral */ | 1024 /* ContainsSpread */ | objectFlags; + spread.objectFlags |= 128 /* ObjectLiteral */ | 262144 /* ContainsObjectOrArrayLiteral */ | 4194304 /* ContainsSpread */ | objectFlags; return spread; } /** We approximate own properties as non-methods plus methods that are inside the object literal */ function isSpreadableProperty(prop) { - return !ts.some(prop.declarations, ts.isPrivateIdentifierPropertyDeclaration) && + var _a; + return !ts.some(prop.declarations, ts.isPrivateIdentifierClassElementDeclaration) && (!(prop.flags & (8192 /* Method */ | 32768 /* GetAccessor */ | 65536 /* SetAccessor */)) || - !prop.declarations.some(function (decl) { return ts.isClassLike(decl.parent); })); + !((_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 */); @@ -57146,11 +59152,9 @@ var ts; return type; } function getFreshTypeOfLiteralType(type) { - if (type.flags & 134220672 /* FreshableLiteral */) { + if (type.flags & 2944 /* Literal */) { if (!type.freshType) { - var freshType = type.flags & 134217728 /* TemplateLiteral */ ? - createTemplateLiteralType(type.texts, type.types) : - createLiteralType(type.flags, type.value, type.symbol); + var freshType = createLiteralType(type.flags, type.value, type.symbol); freshType.regularType = type; freshType.freshType = freshType; type.freshType = freshType; @@ -57160,12 +59164,12 @@ var ts; return type; } function getRegularTypeOfLiteralType(type) { - return type.flags & 134220672 /* FreshableLiteral */ ? type.regularType : + return type.flags & 2944 /* Literal */ ? type.regularType : type.flags & 1048576 /* Union */ ? (type.regularType || (type.regularType = mapType(type, getRegularTypeOfLiteralType))) : type; } function isFreshLiteralType(type) { - return !!(type.flags & 134220672 /* FreshableLiteral */) && type.freshType === type; + return !!(type.flags & 2944 /* Literal */) && type.freshType === type; } function getLiteralType(value, enumId, symbol) { // We store all literal types in a single map with keys of the form '#NNN' and '@SSS', @@ -57185,7 +59189,7 @@ var ts; return type; } function getTypeFromLiteralTypeNode(node) { - if (node.literal.kind === 103 /* NullKeyword */) { + if (node.literal.kind === 104 /* NullKeyword */) { return nullType; } var links = getNodeLinks(node); @@ -57211,7 +59215,7 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 253 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 255 /* InterfaceDeclaration */)) { if (!ts.hasSyntacticModifier(container, 32 /* Static */) && (!ts.isConstructorDeclaration(container) || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; @@ -57246,17 +59250,17 @@ var ts; } function getArrayElementTypeNode(node) { switch (node.kind) { - case 186 /* ParenthesizedType */: + case 188 /* ParenthesizedType */: return getArrayElementTypeNode(node.type); - case 179 /* TupleType */: + case 181 /* TupleType */: if (node.elements.length === 1) { node = node.elements[0]; - if (node.kind === 181 /* RestType */ || node.kind === 192 /* NamedTupleMember */ && node.dotDotDotToken) { + if (node.kind === 183 /* RestType */ || node.kind === 194 /* NamedTupleMember */ && node.dotDotDotToken) { return getArrayElementTypeNode(node.type); } } break; - case 178 /* ArrayType */: + case 180 /* ArrayType */: return node.elementType; } return undefined; @@ -57265,107 +59269,106 @@ var ts; var links = getNodeLinks(node); return links.resolvedType || (links.resolvedType = node.dotDotDotToken ? getTypeFromRestTypeNode(node) : - node.questionToken && strictNullChecks ? getOptionalType(getTypeFromTypeNode(node.type)) : - getTypeFromTypeNode(node.type)); + addOptionality(getTypeFromTypeNode(node.type), /*isProperty*/ true, !!node.questionToken)); } function getTypeFromTypeNode(node) { return getConditionalFlowTypeOfType(getTypeFromTypeNodeWorker(node), node); } function getTypeFromTypeNodeWorker(node) { switch (node.kind) { - case 128 /* AnyKeyword */: - case 303 /* JSDocAllType */: - case 304 /* JSDocUnknownType */: + case 129 /* AnyKeyword */: + case 306 /* JSDocAllType */: + case 307 /* JSDocUnknownType */: return anyType; - case 152 /* UnknownKeyword */: + case 153 /* UnknownKeyword */: return unknownType; - case 147 /* StringKeyword */: + case 148 /* StringKeyword */: return stringType; - case 144 /* NumberKeyword */: + case 145 /* NumberKeyword */: return numberType; - case 155 /* BigIntKeyword */: + case 156 /* BigIntKeyword */: return bigintType; - case 131 /* BooleanKeyword */: + case 132 /* BooleanKeyword */: return booleanType; - case 148 /* SymbolKeyword */: + case 149 /* SymbolKeyword */: return esSymbolType; - case 113 /* VoidKeyword */: + case 114 /* VoidKeyword */: return voidType; - case 150 /* UndefinedKeyword */: + case 151 /* UndefinedKeyword */: return undefinedType; - case 103 /* NullKeyword */: + case 104 /* 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 141 /* NeverKeyword */: + case 142 /* NeverKeyword */: return neverType; - case 145 /* ObjectKeyword */: + case 146 /* ObjectKeyword */: return node.flags & 131072 /* JavaScriptFile */ && !noImplicitAny ? anyType : nonPrimitiveType; - case 136 /* IntrinsicKeyword */: + case 137 /* IntrinsicKeyword */: return intrinsicMarkerType; - case 187 /* ThisType */: - case 107 /* ThisKeyword */: + case 189 /* ThisType */: + case 108 /* 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 191 /* LiteralType */: + case 193 /* LiteralType */: return getTypeFromLiteralTypeNode(node); - case 173 /* TypeReference */: + case 175 /* TypeReference */: return getTypeFromTypeReference(node); - case 172 /* TypePredicate */: + case 174 /* TypePredicate */: return node.assertsModifier ? voidType : booleanType; - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 176 /* TypeQuery */: + case 178 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 178 /* ArrayType */: - case 179 /* TupleType */: + case 180 /* ArrayType */: + case 181 /* TupleType */: return getTypeFromArrayOrTupleTypeNode(node); - case 180 /* OptionalType */: + case 182 /* OptionalType */: return getTypeFromOptionalTypeNode(node); - case 182 /* UnionType */: + case 184 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 183 /* IntersectionType */: + case 185 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 305 /* JSDocNullableType */: + case 308 /* JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 307 /* JSDocOptionalType */: + case 310 /* JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 192 /* NamedTupleMember */: + case 194 /* NamedTupleMember */: return getTypeFromNamedTupleTypeNode(node); - case 186 /* ParenthesizedType */: - case 306 /* JSDocNonNullableType */: - case 301 /* JSDocTypeExpression */: + case 188 /* ParenthesizedType */: + case 309 /* JSDocNonNullableType */: + case 303 /* JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 181 /* RestType */: + case 183 /* RestType */: return getTypeFromRestTypeNode(node); - case 309 /* JSDocVariadicType */: + case 312 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); - case 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 177 /* TypeLiteral */: - case 312 /* JSDocTypeLiteral */: - case 308 /* JSDocFunctionType */: - case 313 /* JSDocSignature */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: + case 179 /* TypeLiteral */: + case 316 /* JSDocTypeLiteral */: + case 311 /* JSDocFunctionType */: + case 317 /* JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 188 /* TypeOperator */: + case 190 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 189 /* IndexedAccessType */: + case 191 /* IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 190 /* MappedType */: + case 192 /* MappedType */: return getTypeFromMappedTypeNode(node); - case 184 /* ConditionalType */: + case 186 /* ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 185 /* InferType */: + case 187 /* InferType */: return getTypeFromInferTypeNode(node); - case 193 /* TemplateLiteralType */: + case 195 /* TemplateLiteralType */: return getTypeFromTemplateTypeNode(node); - case 195 /* ImportType */: + case 197 /* 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 78 /* Identifier */: - case 157 /* QualifiedName */: - case 201 /* PropertyAccessExpression */: + case 79 /* Identifier */: + case 159 /* QualifiedName */: + case 203 /* PropertyAccessExpression */: var symbol = getSymbolAtLocation(node); return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType; default: @@ -57518,7 +59521,7 @@ var ts; } return result; } - function getObjectTypeInstantiation(type, mapper) { + function getObjectTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) { var declaration = type.objectFlags & 4 /* Reference */ ? type.node : type.symbol.declarations[0]; var links = getNodeLinks(declaration); var target = type.objectFlags & 4 /* Reference */ ? links.resolvedType : @@ -57535,8 +59538,9 @@ var ts; outerTypeParameters = ts.addRange(outerTypeParameters, templateTagParameters); } typeParameters = outerTypeParameters || ts.emptyArray; - typeParameters = (target.objectFlags & 4 /* Reference */ || target.symbol.flags & 2048 /* TypeLiteral */) && !target.aliasTypeArguments ? - ts.filter(typeParameters, function (tp) { return isTypeParameterPossiblyReferenced(tp, declaration); }) : + var allDeclarations_1 = type.objectFlags & 4 /* Reference */ ? [declaration] : type.symbol.declarations; + typeParameters = (target.objectFlags & 4 /* Reference */ || target.symbol.flags & 8192 /* Method */ || target.symbol.flags & 2048 /* TypeLiteral */) && !target.aliasTypeArguments ? + ts.filter(typeParameters, function (tp) { return ts.some(allDeclarations_1, function (d) { return isTypeParameterPossiblyReferenced(tp, d); }); }) : typeParameters; links.outerTypeParameters = typeParameters; } @@ -57546,17 +59550,19 @@ var ts; // instantiation cache key from the type IDs of the type arguments. var combinedMapper_1 = combineTypeMappers(type.mapper, mapper); var typeArguments = ts.map(typeParameters, function (t) { return getMappedType(t, combinedMapper_1); }); - var id = getTypeListId(typeArguments); + var newAliasSymbol = aliasSymbol || type.aliasSymbol; + var newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper); + var id = getTypeListId(typeArguments) + getAliasId(newAliasSymbol, newAliasTypeArguments); if (!target.instantiations) { target.instantiations = new ts.Map(); - target.instantiations.set(getTypeListId(typeParameters), target); + target.instantiations.set(getTypeListId(typeParameters) + getAliasId(target.aliasSymbol, target.aliasTypeArguments), target); } var result = target.instantiations.get(id); if (!result) { var newMapper = createTypeMapper(typeParameters, typeArguments); - result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper) : - target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper) : - instantiateAnonymousType(target, newMapper); + result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : + target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : + instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments); target.instantiations.set(id, result); } return result; @@ -57564,9 +59570,8 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 157 /* QualifiedName */ || - node.parent.kind === 173 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || - node.parent.kind === 195 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); + return !(node.parent.kind === 175 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || + node.parent.kind === 197 /* 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 @@ -57575,22 +59580,28 @@ 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 === 230 /* Block */ || n.kind === 184 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { + if (!n || n.kind === 232 /* Block */ || n.kind === 186 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { return true; } } - return !!ts.forEachChild(node, containsReference); + return containsReference(node); } return true; function containsReference(node) { switch (node.kind) { - case 187 /* ThisType */: + case 189 /* ThisType */: return !!tp.isThisType; - case 78 /* Identifier */: + case 79 /* Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNodeWorker(node) === tp; // use worker because we're looking for === equality - case 176 /* TypeQuery */: + case 178 /* TypeQuery */: return true; + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + return !node.type && !!node.body || + ts.some(node.typeParameters, containsReference) || + ts.some(node.parameters, containsReference) || + !!node.type && containsReference(node.type); } return !!ts.forEachChild(node, containsReference); } @@ -57605,7 +59616,7 @@ var ts; } return undefined; } - function instantiateMappedType(type, mapper) { + function instantiateMappedType(type, mapper, aliasSymbol, aliasTypeArguments) { // For a homomorphic mapped type { [P in keyof T]: X }, where T is some type variable, the mapping // operation depends on T as follows: // * If T is a primitive type no mapping is performed and the result is simply T. @@ -57620,7 +59631,7 @@ var ts; if (typeVariable) { var mappedTypeVariable = instantiateType(typeVariable, mapper); if (typeVariable !== mappedTypeVariable) { - return mapType(getReducedType(mappedTypeVariable), function (t) { + return mapTypeWithAlias(getReducedType(mappedTypeVariable), function (t) { if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && t !== errorType) { if (!type.declaration.nameType) { if (isArrayType(t)) { @@ -57636,11 +59647,11 @@ var ts; return instantiateAnonymousType(type, prependTypeMapping(typeVariable, t, mapper)); } return t; - }); + }, aliasSymbol, aliasTypeArguments); } } // If the constraint type of the instantiation is the wildcard type, return the wildcard type. - return instantiateType(getConstraintTypeFromMappedType(type), mapper) === wildcardType ? wildcardType : instantiateAnonymousType(type, mapper); + 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; @@ -57683,11 +59694,11 @@ 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) : + return strictNullChecks && modifiers & 4 /* IncludeOptional */ && !maybeTypeOfKind(propType, 32768 /* Undefined */ | 16384 /* Void */) ? getOptionalType(propType, /*isProperty*/ true) : strictNullChecks && modifiers & 8 /* ExcludeOptional */ && isOptional ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : propType; } - function instantiateAnonymousType(type, mapper) { + function instantiateAnonymousType(type, mapper, aliasSymbol, aliasTypeArguments) { var result = createObjectType(type.objectFlags | 64 /* Instantiated */, type.symbol); if (type.objectFlags & 32 /* Mapped */) { result.declaration = type.declaration; @@ -57700,29 +59711,29 @@ var ts; } result.target = type; result.mapper = mapper; - result.aliasSymbol = type.aliasSymbol; - result.aliasTypeArguments = instantiateTypes(type.aliasTypeArguments, mapper); + result.aliasSymbol = aliasSymbol || type.aliasSymbol; + result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper); return result; } - function getConditionalTypeInstantiation(type, mapper) { + function getConditionalTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) { var root = type.root; if (root.outerTypeParameters) { // We are instantiating a conditional type that has one or more type parameters in scope. Apply the // mapper to the type parameters to produce the effective list of type arguments, and compute the // instantiation cache key from the type IDs of the type arguments. var typeArguments = ts.map(root.outerTypeParameters, function (t) { return getMappedType(t, mapper); }); - var id = getTypeListId(typeArguments); + var id = getTypeListId(typeArguments) + getAliasId(aliasSymbol, aliasTypeArguments); var result = root.instantiations.get(id); if (!result) { var newMapper = createTypeMapper(root.outerTypeParameters, typeArguments); - result = instantiateConditionalType(root, newMapper); + result = instantiateConditionalType(root, newMapper, aliasSymbol, aliasTypeArguments); root.instantiations.set(id, result); } return result; } return type; } - function instantiateConditionalType(root, mapper) { + function instantiateConditionalType(root, mapper, aliasSymbol, aliasTypeArguments) { // Check if we have a conditional type where the check type is a naked type parameter. If so, // the conditional type is distributive over union types and when T is instantiated to a union // type A | B, we produce (A extends U ? X : Y) | (B extends U ? X : Y). @@ -57730,31 +59741,34 @@ var ts; var checkType_1 = root.checkType; var instantiatedType = getMappedType(checkType_1, mapper); if (checkType_1 !== instantiatedType && instantiatedType.flags & (1048576 /* Union */ | 131072 /* Never */)) { - return mapType(instantiatedType, function (t) { return getConditionalType(root, prependTypeMapping(checkType_1, t, mapper)); }); + return mapTypeWithAlias(instantiatedType, function (t) { return getConditionalType(root, prependTypeMapping(checkType_1, t, mapper)); }, aliasSymbol, aliasTypeArguments); } } - return getConditionalType(root, mapper); + return getConditionalType(root, mapper, aliasSymbol, aliasTypeArguments); } function instantiateType(type, mapper) { - if (!(type && mapper && couldContainTypeVariables(type))) { + return type && mapper ? instantiateTypeWithAlias(type, mapper, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined) : type; + } + function instantiateTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments) { + if (!couldContainTypeVariables(type)) { return type; } if (instantiationDepth === 50 || instantiationCount >= 5000000) { // We have reached 50 recursive type instantiations and there is a very high likelyhood we're dealing // with a combination of infinite generic types that perpetually generate new type identities. We stop // the recursion here by yielding the error type. - 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" /* CheckTypes */, "instantiateType_DepthLimit", { typeId: type.id, instantiationDepth: instantiationDepth, instantiationCount: instantiationCount }); error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite); return errorType; } totalInstantiationCount++; instantiationCount++; instantiationDepth++; - var result = instantiateTypeWorker(type, mapper); + var result = instantiateTypeWorker(type, mapper, aliasSymbol, aliasTypeArguments); instantiationDepth--; return result; } - function instantiateTypeWorker(type, mapper) { + function instantiateTypeWorker(type, mapper, aliasSymbol, aliasTypeArguments) { var flags = type.flags; if (flags & 262144 /* TypeParameter */) { return getMappedType(type, mapper); @@ -57762,12 +59776,15 @@ var ts; if (flags & 524288 /* Object */) { var objectFlags = type.objectFlags; if (objectFlags & (4 /* Reference */ | 16 /* Anonymous */ | 32 /* Mapped */)) { - if (objectFlags & 4 /* Reference */ && !(type.node)) { + if (objectFlags & 4 /* Reference */ && !type.node) { var resolvedTypeArguments = type.resolvedTypeArguments; var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper); return newTypeArguments !== resolvedTypeArguments ? createNormalizedTypeReference(type.target, newTypeArguments) : type; } - return getObjectTypeInstantiation(type, mapper); + if (objectFlags & 1024 /* ReverseMapped */) { + return instantiateReverseMappedType(type, mapper); + } + return getObjectTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments); } return type; } @@ -57775,10 +59792,14 @@ var ts; var origin = type.flags & 1048576 /* Union */ ? type.origin : undefined; var types = origin && origin.flags & 3145728 /* UnionOrIntersection */ ? origin.types : type.types; var newTypes = instantiateTypes(types, mapper); - return newTypes === types ? type : - flags & 2097152 /* Intersection */ || origin && origin.flags & 2097152 /* Intersection */ ? - getIntersectionType(newTypes, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) : - getUnionType(newTypes, 1 /* Literal */, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, 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 */ ? + getIntersectionType(newTypes, newAliasSymbol, newAliasTypeArguments) : + getUnionType(newTypes, 1 /* Literal */, newAliasSymbol, newAliasTypeArguments); } if (flags & 4194304 /* Index */) { return getIndexType(instantiateType(type.type, mapper)); @@ -57790,10 +59811,12 @@ var ts; return getStringMappingType(type.symbol, instantiateType(type.type, mapper)); } if (flags & 8388608 /* IndexedAccess */) { - return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper), type.noUncheckedIndexedAccessCandidate, /*accessNode*/ undefined, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); + 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 */) { - return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper)); + return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper), aliasSymbol, aliasTypeArguments); } if (flags & 33554432 /* Substitution */) { var maybeVariable = instantiateType(type.baseType, mapper); @@ -57810,6 +59833,21 @@ var ts; } return type; } + function instantiateReverseMappedType(type, mapper) { + var innerMappedType = instantiateType(type.mappedType, mapper); + if (!(ts.getObjectFlags(innerMappedType) & 32 /* Mapped */)) { + return type; + } + var innerIndexType = instantiateType(type.constraintType, mapper); + if (!(innerIndexType.flags & 4194304 /* Index */)) { + return type; + } + var instantiated = inferTypeForHomomorphicMappedType(instantiateType(type.source, mapper), innerMappedType, innerIndexType); + if (instantiated) { + return instantiated; + } + return type; // Nested invocation of `inferTypeForHomomorphicMappedType` or the `source` instantiated into something unmappable + } function getPermissiveInstantiation(type) { return type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */) ? type : type.permissiveInstantiation || (type.permissiveInstantiation = instantiateType(type, permissiveMapper)); @@ -57836,35 +59874,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 !== 165 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 167 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: - case 251 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 253 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type return isContextSensitiveFunctionLikeDeclaration(node); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return (node.operatorToken.kind === 56 /* BarBarToken */ || node.operatorToken.kind === 60 /* QuestionQuestionToken */) && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return isContextSensitive(node.expression); - case 281 /* JsxAttributes */: + case 283 /* JsxAttributes */: return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive); - case 280 /* JsxAttribute */: { + case 282 /* 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 283 /* JsxExpression */: { + case 285 /* JsxExpression */: { // It is possible to that node.expression is undefined (e.g

) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -57883,7 +59921,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 209 /* ArrowFunction */) { + if (node.kind !== 211 /* 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); @@ -57896,7 +59934,7 @@ 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 !== 230 /* Block */ && isContextSensitive(node.body); + return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 232 /* Block */ && isContextSensitive(node.body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && @@ -57999,23 +60037,23 @@ var ts; return true; } switch (node.kind) { - case 283 /* JsxExpression */: - case 207 /* ParenthesizedExpression */: + case 285 /* JsxExpression */: + case 209 /* ParenthesizedExpression */: return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 62 /* EqualsToken */: + case 63 /* EqualsToken */: case 27 /* CommaToken */: return elaborateError(node.right, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); } break; - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 281 /* JsxAttributes */: + case 283 /* JsxAttributes */: return elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer); } return false; @@ -58116,7 +60154,14 @@ var ts; if (!targetPropType || targetPropType.flags & 8388608 /* IndexedAccess */) continue; // Don't elaborate on indexes on generic variables var sourcePropType = getIndexedAccessTypeOrUndefined(source, nameType); - if (sourcePropType && !checkTypeRelatedTo(sourcePropType, targetPropType, relation, /*errorNode*/ undefined)) { + if (!sourcePropType) + continue; + var propName = getPropertyNameFromIndex(nameType, /*accessNode*/ undefined); + var targetIsOptional = !!(propName && (getPropertyOfType(target, propName) || unknownSymbol).flags & 16777216 /* Optional */); + var sourceIsOptional = !!(propName && (getPropertyOfType(source, propName) || unknownSymbol).flags & 16777216 /* Optional */); + targetPropType = removeMissingType(targetPropType, targetIsOptional); + sourcePropType = removeMissingType(sourcePropType, targetIsOptional && sourceIsOptional); + if (!checkTypeRelatedTo(sourcePropType, targetPropType, relation, /*errorNode*/ undefined)) { var elaborated = next && elaborateError(next, sourcePropType, targetPropType, relation, /*headMessage*/ undefined, containingMessageChain, errorOutputContainer); if (elaborated) { reportedError = true; @@ -58215,7 +60260,7 @@ var ts; } function getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic) { switch (child.kind) { - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: // child is of the type of the expression return { errorNode: child, innerExpression: child.expression, nameType: nameType }; case 11 /* JsxText */: @@ -58224,9 +60269,9 @@ var ts; } // child is a string return { errorNode: child, innerExpression: undefined, nameType: nameType, errorMessage: getInvalidTextDiagnostic() }; - case 273 /* JsxElement */: - case 274 /* JsxSelfClosingElement */: - case 277 /* JsxFragment */: + case 275 /* JsxElement */: + case 276 /* JsxSelfClosingElement */: + case 279 /* JsxFragment */: // child is of type JSX.Element return { errorNode: child, innerExpression: child, nameType: nameType }; default: @@ -58374,11 +60419,11 @@ var ts; } _b = prop.kind; switch (_b) { - case 168 /* SetAccessor */: return [3 /*break*/, 2]; - case 167 /* GetAccessor */: return [3 /*break*/, 2]; - case 165 /* MethodDeclaration */: return [3 /*break*/, 2]; - case 289 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; - case 288 /* PropertyAssignment */: return [3 /*break*/, 4]; + case 170 /* SetAccessor */: return [3 /*break*/, 2]; + case 169 /* GetAccessor */: return [3 /*break*/, 2]; + case 167 /* MethodDeclaration */: return [3 /*break*/, 2]; + case 291 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 290 /* PropertyAssignment */: return [3 /*break*/, 4]; } return [3 /*break*/, 6]; case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; @@ -58455,8 +60500,8 @@ var ts; return 0 /* False */; } var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - var strictVariance = !(checkMode & 3 /* Callback */) && strictFunctionTypes && kind !== 165 /* MethodDeclaration */ && - kind !== 164 /* MethodSignature */ && kind !== 166 /* Constructor */; + var strictVariance = !(checkMode & 3 /* Callback */) && strictFunctionTypes && kind !== 167 /* MethodDeclaration */ && + kind !== 166 /* MethodSignature */ && kind !== 168 /* Constructor */; var result = -1 /* True */; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { @@ -58689,7 +60734,7 @@ var ts; // 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 */ || t & 256 /* NumberLiteral */ && t & 1024 /* EnumLiteral */)) + if (s & (8 /* Number */ | 256 /* NumberLiteral */) && !(s & 1024 /* EnumLiteral */) && (t & 32 /* Enum */ || relation === assignableRelation && t & 256 /* NumberLiteral */ && t & 1024 /* EnumLiteral */)) return true; } return false; @@ -58726,7 +60771,7 @@ var ts; return false; } function isIgnoredJsxProperty(source, sourceProp) { - return ts.getObjectFlags(source) & 4096 /* JsxAttributes */ && !isUnhyphenatedJsxName(sourceProp.escapedName); + return ts.getObjectFlags(source) & 2048 /* JsxAttributes */ && !isUnhyphenatedJsxName(sourceProp.escapedName); } function getNormalizedType(type, writing) { while (true) { @@ -58736,6 +60781,7 @@ var ts; type.flags & 33554432 /* Substitution */ ? writing ? type.baseType : type.substitute : type.flags & 25165824 /* Simplifiable */ ? getSimplifiedType(type, writing) : type; + t = getSingleBaseForNonAugmentingSubtype(t) || t; if (t === type) break; type = t; @@ -58773,7 +60819,7 @@ var ts; reportIncompatibleStack(); } if (overflow) { - ts.tracing.instant("checkTypes" /* CheckTypes */, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: depth }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: depth }); 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); @@ -58909,6 +60955,14 @@ var ts; } break; } + case ts.Diagnostics.Type_at_position_0_in_source_is_not_compatible_with_type_at_position_1_in_target.code: { + secondaryRootErrors.unshift([ts.Diagnostics.Type_at_position_0_in_source_is_not_compatible_with_type_at_position_1_in_target, args[0], args[1]]); + break; + } + case ts.Diagnostics.Type_at_positions_0_through_1_in_source_is_not_compatible_with_type_at_position_2_in_target.code: { + secondaryRootErrors.unshift([ts.Diagnostics.Type_at_positions_0_through_1_in_source_is_not_compatible_with_type_at_position_2_in_target, args[0], args[1], args[2]]); + break; + } default: return ts.Debug.fail("Unhandled Diagnostic: " + msg.code); } @@ -58969,6 +61023,7 @@ var ts; reportError(ts.Diagnostics._0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2, needsOriginalSource ? sourceType : generalizedSourceType, targetType, typeToString(constraint)); } else { + errorInfo = undefined; reportError(ts.Diagnostics._0_could_be_instantiated_with_an_arbitrary_type_which_could_be_unrelated_to_1, targetType, generalizedSourceType); } } @@ -59044,7 +61099,7 @@ var ts; if (isSimpleTypeRelatedTo(originalSource, originalTarget, relation, reportErrors ? reportError : undefined)) { return -1 /* True */; } - reportErrorResults(originalSource, originalTarget, 0 /* False */, !!(ts.getObjectFlags(originalSource) & 4096 /* JsxAttributes */)); + reportErrorResults(originalSource, originalTarget, 0 /* False */, !!(ts.getObjectFlags(originalSource) & 2048 /* JsxAttributes */)); return 0 /* False */; } // Normalize the source and target types: Turn fresh literal types into regular literal types, @@ -59079,16 +61134,16 @@ var ts; target.types.length <= 3 && maybeTypeOfKind(target, 98304 /* Nullable */)) { var nullStrippedTarget = extractTypesOfKind(target, ~98304 /* Nullable */); if (!(nullStrippedTarget.flags & (1048576 /* Union */ | 131072 /* Never */))) { - if (source === nullStrippedTarget) - return -1 /* True */; - target = nullStrippedTarget; + target = getNormalizedType(nullStrippedTarget, /*writing*/ true); } + if (source === nullStrippedTarget) + return -1 /* True */; } if (relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return -1 /* True */; - var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096 /* JsxAttributes */); - var isPerformingExcessPropertyChecks = !(intersectionState & 2 /* Target */) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 32768 /* FreshLiteral */); + var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* JsxAttributes */); + var isPerformingExcessPropertyChecks = !(intersectionState & 2 /* Target */) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 16384 /* FreshLiteral */); if (isPerformingExcessPropertyChecks) { if (hasExcessProperties(source, target, reportErrors)) { if (reportErrors) { @@ -59173,7 +61228,7 @@ var ts; // We suppress recursive intersection property checks because they can generate lots of work when relating // recursive intersections that are structurally similar but not exactly identical. See #37854. if (result && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) || - isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 2097152 /* NonInferrableType */); }))) { + isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 524288 /* NonInferrableType */); }))) { inPropertyCheck = true; result &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */); inPropertyCheck = false; @@ -59182,8 +61237,10 @@ var ts; return result; function reportErrorResults(source, target, result, isComparingJsxAttributes) { if (!result && reportErrors) { - source = originalSource.aliasSymbol ? originalSource : source; - target = originalTarget.aliasSymbol ? originalTarget : target; + var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource); + var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget); + source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source; + target = (originalTarget.aliasSymbol || targetHasBase) ? originalTarget : target; var maybeSuppress = overrideNextErrorInfo > 0; if (maybeSuppress) { overrideNextErrorInfo--; @@ -59224,13 +61281,13 @@ var ts; } } function traceUnionsOrIntersectionsTooLarge(source, target) { - if (!ts.tracing.isTracing()) { + if (!ts.tracing) { return; } if ((source.flags & 3145728 /* UnionOrIntersection */) && (target.flags & 3145728 /* UnionOrIntersection */)) { var sourceUnionOrIntersection = source; var targetUnionOrIntersection = target; - if (sourceUnionOrIntersection.objectFlags & targetUnionOrIntersection.objectFlags & 262144 /* PrimitiveUnion */) { + if (sourceUnionOrIntersection.objectFlags & targetUnionOrIntersection.objectFlags & 65536 /* PrimitiveUnion */) { // There's a fast path for comparing primitive unions return; } @@ -59255,11 +61312,11 @@ var ts; } traceUnionsOrIntersectionsTooLarge(source, target); if (flags & 3145728 /* UnionOrIntersection */) { - var result_6 = eachTypeRelatedToSomeType(source, target); - if (result_6) { - result_6 &= eachTypeRelatedToSomeType(target, source); + var result_7 = eachTypeRelatedToSomeType(source, target); + if (result_7) { + result_7 &= eachTypeRelatedToSomeType(target, source); } - return result_6; + return result_7; } return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None */); } @@ -59273,10 +61330,11 @@ var ts; return getUnionType(ts.reduceLeft(types, appendPropType, /*initial*/ undefined) || ts.emptyArray); } function hasExcessProperties(source, target, reportErrors) { - if (!isExcessPropertyCheckTarget(target) || !noImplicitAny && ts.getObjectFlags(target) & 16384 /* JSLiteral */) { + var _a; + if (!isExcessPropertyCheckTarget(target) || !noImplicitAny && ts.getObjectFlags(target) & 8192 /* 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) & 4096 /* JsxAttributes */); + var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* JsxAttributes */); if ((relation === assignableRelation || relation === comparableRelation) && (isTypeSubsetOf(globalObjectType, target) || (!isComparingJsxAttributes && isEmptyObjectType(target)))) { return false; @@ -59319,7 +61377,7 @@ var ts; } else { // use the property's value declaration if the property is assigned inside the literal itself - var objectLiteralDeclaration_1 = source.symbol && ts.firstOrUndefined(source.symbol.declarations); + var objectLiteralDeclaration_1 = ((_a = source.symbol) === null || _a === void 0 ? void 0 : _a.declarations) && ts.firstOrUndefined(source.symbol.declarations); var suggestion = void 0; if (prop.valueDeclaration && ts.findAncestor(prop.valueDeclaration, function (d) { return d === objectLiteralDeclaration_1; }) && ts.getSourceFileOfNode(objectLiteralDeclaration_1) === ts.getSourceFileOfNode(errorNode)) { var propDeclaration = prop.valueDeclaration; @@ -59348,11 +61406,11 @@ var ts; } } }; - for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) { - var prop = _a[_i]; - var state_4 = _loop_16(prop); - if (typeof state_4 === "object") - return state_4.value; + for (var _i = 0, _b = getPropertiesOfType(source); _i < _b.length; _i++) { + var prop = _b[_i]; + var state_5 = _loop_16(prop); + if (typeof state_5 === "object") + return state_5.value; } return false; } @@ -59374,8 +61432,17 @@ var ts; } function typeRelatedToSomeType(source, target, reportErrors) { var targetTypes = target.types; - if (target.flags & 1048576 /* Union */ && containsType(targetTypes, source)) { - return -1 /* True */; + if (target.flags & 1048576 /* Union */) { + if (containsType(targetTypes, source)) { + return -1 /* True */; + } + var match = getMatchingUnionConstituentForType(target, source); + if (match) { + var related = isRelatedTo(source, match, /*reportErrors*/ false); + if (related) { + return related; + } + } } for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { var type = targetTypes_1[_i]; @@ -59549,9 +61616,16 @@ var ts; targetStack = []; } else { + // generate a key where all type parameter id positions are replaced with unconstrained type parameter ids + // this isn't perfect - nested type references passed as type arguments will muck up the indexes and thus + // prevent finding matches- but it should hit up the common cases + var broadestEquivalentId = id.split(",").map(function (i) { return i.replace(/-\d+/g, function (_match, offset) { + var index = ts.length(id.slice(0, offset).match(/[-=]/g) || undefined); + return "=" + index; + }); }).join(","); for (var i = 0; i < maybeCount; i++) { // If source and target are already being compared, consider them related with assumptions - if (id === maybeKeys[i]) { + if (id === maybeKeys[i] || broadestEquivalentId === maybeKeys[i]) { return 3 /* Maybe */; } } @@ -59581,7 +61655,7 @@ var ts; }; } if (expandingFlags === 3 /* Both */) { - ts.tracing.instant("checkTypes" /* CheckTypes */, "recursiveTypeRelatedTo_DepthLimit", { + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "recursiveTypeRelatedTo_DepthLimit", { sourceId: source.id, sourceIdStack: sourceStack.map(function (t) { return t.id; }), targetId: target.id, @@ -59616,9 +61690,9 @@ var ts; return result; } function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) { - 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" /* CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id }); var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; } function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState) { @@ -59640,8 +61714,21 @@ var ts; if (target.flags & 2097152 /* Intersection */) { return typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2 /* Target */); } - // Source is an intersection. Check to see if any constituents of the intersection are immediately related - // to the 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 */) { + var constraints = ts.sameMap(source.types, function (t) { return t.flags & 131068 /* Primitive */ ? t : getBaseConstraintOfType(t) || unknownType; }); + if (constraints !== source.types) { + source = getIntersectionType(constraints); + if (!(source.flags & 2097152 /* Intersection */)) { + return isRelatedTo(source, target, /*reportErrors*/ false); + } + } + } + // Check to see if any constituents of the intersection are immediately related to the target. // // Don't report errors though. Checking whether a constituent is related to the source is not actually // useful and leads to some confusing error messages. Instead it is better to let the below checks @@ -59661,21 +61748,21 @@ var ts; if (flags & 4194304 /* Index */) { return isRelatedTo(source.type, target.type, /*reportErrors*/ false); } - var result_7 = 0 /* False */; + var result_8 = 0 /* False */; if (flags & 8388608 /* IndexedAccess */) { - if (result_7 = isRelatedTo(source.objectType, target.objectType, /*reportErrors*/ false)) { - if (result_7 &= isRelatedTo(source.indexType, target.indexType, /*reportErrors*/ false)) { - return result_7; + if (result_8 = isRelatedTo(source.objectType, target.objectType, /*reportErrors*/ false)) { + if (result_8 &= isRelatedTo(source.indexType, target.indexType, /*reportErrors*/ false)) { + return result_8; } } } if (flags & 16777216 /* Conditional */) { if (source.root.isDistributive === target.root.isDistributive) { - if (result_7 = isRelatedTo(source.checkType, target.checkType, /*reportErrors*/ false)) { - if (result_7 &= isRelatedTo(source.extendsType, target.extendsType, /*reportErrors*/ false)) { - if (result_7 &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), /*reportErrors*/ false)) { - if (result_7 &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), /*reportErrors*/ false)) { - return result_7; + if (result_8 = isRelatedTo(source.checkType, target.checkType, /*reportErrors*/ false)) { + if (result_8 &= isRelatedTo(source.extendsType, target.extendsType, /*reportErrors*/ false)) { + if (result_8 &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), /*reportErrors*/ false)) { + if (result_8 &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), /*reportErrors*/ false)) { + return result_8; } } } @@ -59755,6 +61842,20 @@ var ts; } } else if (target.flags & 8388608 /* IndexedAccess */) { + if (source.flags & 8388608 /* 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, reportErrors)) { + result &= isRelatedTo(source.indexType, target.indexType, reportErrors); + } + if (result) { + resetErrorInfo(saveErrorInfo); + return result; + } + if (reportErrors) { + originalErrorInfo = errorInfo; + } + } // A type S is related to a type T[K] if S is related to C, where C is the base // constraint of T[K] for writing. if (relation === assignableRelation || relation === comparableRelation) { @@ -59763,13 +61864,26 @@ var ts; var baseObjectType = getBaseConstraintOfType(objectType) || objectType; var baseIndexType = getBaseConstraintOfType(indexType) || indexType; if (!isGenericObjectType(baseObjectType) && !isGenericIndexType(baseIndexType)) { - var accessFlags = 2 /* Writing */ | (baseObjectType !== objectType ? 1 /* NoIndexSignatures */ : 0); - var constraint = getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, target.noUncheckedIndexedAccessCandidate, /*accessNode*/ undefined, accessFlags); - if (constraint && (result = isRelatedTo(source, constraint, reportErrors))) { - return result; + var accessFlags = 4 /* Writing */ | (baseObjectType !== objectType ? 2 /* 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, reportErrors)) { + return result; + } + // prefer the shorter chain of the constraint comparison chain, and the direct comparison chain + if (reportErrors && originalErrorInfo && errorInfo) { + errorInfo = countMessageChainBreadth([originalErrorInfo]) <= countMessageChainBreadth([errorInfo]) ? originalErrorInfo : errorInfo; + } } } } + if (reportErrors) { + originalErrorInfo = undefined; + } } else if (isGenericMappedType(target) && !target.declaration.nameType) { // A source type T is related to a target type { [P in X]: T[P] } @@ -59813,27 +61927,48 @@ var ts; } } } - else if (target.flags & 134217728 /* TemplateLiteral */ && source.flags & 128 /* StringLiteral */) { - if (isPatternLiteralType(target)) { - // match all non-`string` segments - var result_8 = inferLiteralsFromTemplateLiteralType(source, target); - if (result_8 && ts.every(result_8, function (r, i) { return isStringLiteralTypeValueParsableAsType(r, target.types[i]); })) { - return -1 /* True */; - } + else if (target.flags & 16777216 /* Conditional */) { + var c = target; + // Check if the conditional is always true or always false but still deferred for distribution purposes + var skipTrue = !isTypeAssignableTo(getPermissiveInstantiation(c.checkType), getPermissiveInstantiation(c.extendsType)); + var skipFalse = !skipTrue && isConditionalTypeAlwaysTrueDisregardingInferTypes(c); + // Instantiate with a replacement mapper if the conditional is distributive, replacing the check type with a clone of itself, + // this way {x: string | number, y: string | number} -> (T extends T ? { x: T, y: T } : never) appropriately _fails_ when + // T = string | number (since that will end up distributing and producing `{x: string, y: string} | {x: number, y: number}`, + // to which `{x: string | number, y: string | number}` isn't assignable) + var distributionMapper = void 0; + var checkVar = getActualTypeVariable(c.root.checkType); + if (c.root.isDistributive && checkVar.flags & 262144 /* TypeParameter */) { + var newParam = cloneTypeParameter(checkVar); + distributionMapper = prependTypeMapping(checkVar, newParam, c.mapper); + newParam.mapper = distributionMapper; + } + // TODO: Find a nice way to include potential conditional type breakdowns in error output, if they seem good (they usually don't) + var localResult = void 0; + if (skipTrue || (localResult = isRelatedTo(source, distributionMapper ? instantiateType(getTypeFromTypeNode(c.root.node.trueType), distributionMapper) : getTrueTypeFromConditionalType(c), /*reportErrors*/ false))) { + if (!skipFalse) { + localResult = (localResult || 3 /* Maybe */) & isRelatedTo(source, distributionMapper ? instantiateType(getTypeFromTypeNode(c.root.node.falseType), distributionMapper) : getFalseTypeFromConditionalType(c), /*reportErrors*/ false); + } + } + if (localResult) { + resetErrorInfo(saveErrorInfo); + return localResult; } } - if (source.flags & 8650752 /* TypeVariable */) { - if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) { - // 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, reportErrors)) { - result &= isRelatedTo(source.indexType, target.indexType, reportErrors); - } - if (result) { - resetErrorInfo(saveErrorInfo); - return result; - } + else if (target.flags & 134217728 /* TemplateLiteral */) { + if (source.flags & 134217728 /* TemplateLiteral */) { + // 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)); } - else { + var result_9 = inferTypesFromTemplateLiteralType(source, target); + if (result_9 && ts.every(result_9, function (r, i) { return isValidTypeForTemplateLiteralPlaceholder(r, target.types[i]); })) { + return -1 /* True */; + } + } + if (source.flags & 8650752 /* TypeVariable */) { + // IndexedAccess comparisons are handled above in the `target.flags & TypeFlage.IndexedAccess` branch + if (!(source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */)) { var constraint = getConstraintOfType(source); if (!constraint || (source.flags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) { // A type variable with no constraint is not related to the non-primitive object type. @@ -59848,7 +61983,7 @@ var ts; 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, reportErrors, /*headMessage*/ undefined, intersectionState)) { + else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, reportErrors && !(target.flags & source.flags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) { resetErrorInfo(saveErrorInfo); return result; } @@ -59861,17 +61996,10 @@ var ts; } } else if (source.flags & 134217728 /* TemplateLiteral */) { - if (target.flags & 134217728 /* TemplateLiteral */) { - if (source.texts.length === target.texts.length && - source.types.length === target.types.length && - ts.every(source.texts, function (t, i) { return t === target.texts[i]; }) && - ts.every(instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)).types, function (t, i) { return !!(target.types[i].flags & (1 /* Any */ | 4 /* String */)) || !!isRelatedTo(t, target.types[i], /*reportErrors*/ false); })) { - return -1 /* True */; - } - } - else { - var constraint = getBaseConstraintOfType(source); - if (result = isRelatedTo(constraint && constraint !== source ? constraint : stringType, target, reportErrors)) { + if (!(target.flags & 134217728 /* TemplateLiteral */)) { + var baseConstraint = getBaseConstraintOfType(source); + var constraint = baseConstraint && baseConstraint !== source ? baseConstraint : stringType; + if (result = isRelatedTo(constraint, target, reportErrors)) { resetErrorInfo(saveErrorInfo); return result; } @@ -59903,7 +62031,7 @@ var ts; 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 */, isRelatedTo); - inferTypes(ctx.inferences, target.extendsType, sourceExtends, 256 /* NoConstraints */ | 512 /* AlwaysStrict */); + inferTypes(ctx.inferences, target.extendsType, sourceExtends, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */); sourceExtends = instantiateType(sourceExtends, ctx.mapper); mapper = ctx.mapper; } @@ -59961,7 +62089,7 @@ var ts; return 0 /* False */; } if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && source.target === target.target && - !(ts.getObjectFlags(source) & 8192 /* MarkerType */ || ts.getObjectFlags(target) & 8192 /* MarkerType */)) { + !(ts.getObjectFlags(source) & 4096 /* MarkerType */ || ts.getObjectFlags(target) & 4096 /* MarkerType */)) { // 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 // information for the type parameters and relate the type arguments accordingly. @@ -59989,7 +62117,7 @@ var ts; } // 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) & 32768 /* FreshLiteral */ && !isEmptyObjectType(source)) { + else if ((relation === subtypeRelation || relation === strictSubtypeRelation) && isEmptyObjectType(target) && ts.getObjectFlags(target) & 16384 /* FreshLiteral */ && !isEmptyObjectType(source)) { return 0 /* False */; } // Even if relationship doesn't hold for unions, intersections, or generic type references, @@ -60027,14 +62155,19 @@ var ts; if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */) && target.flags & 1048576 /* Union */) { var objectOnlyTarget = extractTypesOfKind(target, 524288 /* Object */ | 2097152 /* Intersection */ | 33554432 /* Substitution */); if (objectOnlyTarget.flags & 1048576 /* Union */) { - var result_9 = typeRelatedToDiscriminatedType(source, objectOnlyTarget); - if (result_9) { - return result_9; + var result_10 = typeRelatedToDiscriminatedType(source, objectOnlyTarget); + if (result_10) { + return result_10; } } } } return 0 /* False */; + function countMessageChainBreadth(info) { + if (!info) + return 0; + return ts.reduceLeft(info, function (value, chain) { return value + 1 + countMessageChainBreadth(chain.next); }, 0); + } function relateVariances(sourceTypeArguments, targetTypeArguments, variances, intersectionState) { if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors, intersectionState)) { return result; @@ -60096,13 +62229,13 @@ var ts; var modifiersRelated = relation === comparableRelation || (relation === identityRelation ? getMappedTypeModifiers(source) === getMappedTypeModifiers(target) : getCombinedMappedTypeOptionality(source) <= getCombinedMappedTypeOptionality(target)); if (modifiersRelated) { - var result_10; + var result_11; var targetConstraint = getConstraintTypeFromMappedType(target); var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), makeFunctionTypeMapper(getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMarkers : reportUnreliableMarkers)); - if (result_10 = isRelatedTo(targetConstraint, sourceConstraint, reportErrors)) { + if (result_11 = isRelatedTo(targetConstraint, sourceConstraint, 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), reportErrors); + return result_11 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), reportErrors); } } } @@ -60130,10 +62263,10 @@ var ts; var numCombinations = 1; for (var _i = 0, sourcePropertiesFiltered_1 = sourcePropertiesFiltered; _i < sourcePropertiesFiltered_1.length; _i++) { var sourceProperty = sourcePropertiesFiltered_1[_i]; - numCombinations *= countTypes(getTypeOfSymbol(sourceProperty)); + numCombinations *= countTypes(getNonMissingTypeOfSymbol(sourceProperty)); if (numCombinations > 25) { // We've reached the complexity limit. - ts.tracing.instant("checkTypes" /* CheckTypes */, "typeRelatedToDiscriminatedType_DepthLimit", { sourceId: source.id, targetId: target.id, numCombinations: numCombinations }); + 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 */; } } @@ -60142,7 +62275,7 @@ var ts; var excludedProperties = new ts.Set(); for (var i = 0; i < sourcePropertiesFiltered.length; i++) { var sourceProperty = sourcePropertiesFiltered[i]; - var sourcePropertyType = getTypeOfSymbol(sourceProperty); + var sourcePropertyType = getNonMissingTypeOfSymbol(sourceProperty); sourceDiscriminantTypes[i] = sourcePropertyType.flags & 1048576 /* Union */ ? sourcePropertyType.types : [sourcePropertyType]; @@ -60172,8 +62305,8 @@ var ts; } }; for (var i = 0; i < sourcePropertiesFiltered.length; i++) { - var state_6 = _loop_18(i); - switch (state_6) { + var state_7 = _loop_18(i); + switch (state_7) { case "continue-outer": continue outer; } } @@ -60186,9 +62319,9 @@ var ts; }; for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) { var combination = discriminantCombinations_1[_a]; - var state_5 = _loop_17(combination); - if (typeof state_5 === "object") - return state_5.value; + var state_6 = _loop_17(combination); + if (typeof state_6 === "object") + return state_6.value; } // Compare the remaining non-discriminant properties of each match. var result = -1 /* True */; @@ -60235,46 +62368,9 @@ var ts; } function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState) { var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* Partial */); - var source = getTypeOfSourceProperty(sourceProp); - if (ts.getCheckFlags(targetProp) & 65536 /* DeferredType */ && !getSymbolLinks(targetProp).type) { - // Rather than resolving (and normalizing) the type, relate constituent-by-constituent without performing normalization or seconadary passes - var links = getSymbolLinks(targetProp); - ts.Debug.assertIsDefined(links.deferralParent); - ts.Debug.assertIsDefined(links.deferralConstituents); - var unionParent = !!(links.deferralParent.flags & 1048576 /* Union */); - var result_11 = unionParent ? 0 /* False */ : -1 /* True */; - var targetTypes = links.deferralConstituents; - for (var _i = 0, targetTypes_3 = targetTypes; _i < targetTypes_3.length; _i++) { - var targetType = targetTypes_3[_i]; - var related = isRelatedTo(source, targetType, /*reportErrors*/ false, /*headMessage*/ undefined, unionParent ? 0 : 2 /* Target */); - if (!unionParent) { - if (!related) { - // Can't assign to a target individually - have to fallback to assigning to the _whole_ intersection (which forces normalization) - return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); - } - result_11 &= related; - } - else { - if (related) { - return related; - } - } - } - if (unionParent && !result_11 && targetIsOptional) { - result_11 = isRelatedTo(source, undefinedType); - } - if (unionParent && !result_11 && reportErrors) { - // The easiest way to get the right errors here is to un-defer (which may be costly) - // If it turns out this is too costly too often, we can replicate the error handling logic within - // typeRelatedToSomeType without the discriminatable type branch (as that requires a manifest union - // type on which to hand discriminable properties, which we are expressly trying to avoid here) - return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); - } - return result_11; - } - else { - return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors, /*headMessage*/ undefined, intersectionState); - } + var effectiveTarget = addOptionality(getNonMissingTypeOfSymbol(targetProp), /*isProperty*/ false, targetIsOptional); + var effectiveSource = getTypeOfSourceProperty(sourceProp); + return isRelatedTo(effectiveSource, effectiveTarget, reportErrors, /*headMessage*/ undefined, intersectionState); } function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState, skipOptional) { var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp); @@ -60403,7 +62499,7 @@ var ts; } return 0 /* False */; } - if (!targetRestFlag && sourceRestFlag) { + if (!targetRestFlag && (sourceRestFlag || targetArity < sourceArity)) { if (reportErrors) { if (sourceMinLength < targetMinLength) { reportError(ts.Diagnostics.Target_requires_0_element_s_but_source_may_have_fewer, targetMinLength); @@ -60451,10 +62547,11 @@ var ts; } } var sourceType = !isTupleType(source) ? sourceTypeArguments[0] : - i < startCount || i >= targetArity - endCount ? sourceTypeArguments[sourceIndex] : + i < startCount || i >= targetArity - endCount ? removeMissingType(sourceTypeArguments[sourceIndex], !!(sourceFlags & targetFlags & 2 /* Optional */)) : getElementTypeOfSliceOfTupleType(source, startCount, endCount) || neverType; var targetType = targetTypeArguments[i]; - var targetCheckType = sourceFlags & 8 /* Variadic */ && targetFlags & 4 /* Rest */ ? createArrayType(targetType) : targetType; + var targetCheckType = sourceFlags & 8 /* Variadic */ && targetFlags & 4 /* Rest */ ? createArrayType(targetType) : + removeMissingType(targetType, !!(targetFlags & 2 /* Optional */)); var related = isRelatedTo(sourceType, targetCheckType, reportErrors, /*headMessage*/ undefined, intersectionState); if (!related) { if (reportErrors) { @@ -60488,7 +62585,7 @@ var ts; var sourceProp = _a[_i]; if (!getPropertyOfObjectType(target, sourceProp.escapedName)) { var sourceType = getTypeOfSymbol(sourceProp); - if (!(sourceType === undefinedType || sourceType === undefinedWideningType || sourceType === optionalType)) { + if (!(sourceType.flags & 32768 /* Undefined */)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(sourceProp), typeToString(target)); } @@ -60507,7 +62604,7 @@ var ts; if (!(targetProp.flags & 4194304 /* Prototype */) && (!numericNamesOnly || isNumericLiteralName(name) || name === "length")) { var sourceProp = getPropertyOfType(source, name); if (sourceProp && sourceProp !== targetProp) { - var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, intersectionState, relation === comparableRelation); + var related = propertyRelatedTo(source, target, sourceProp, targetProp, getNonMissingTypeOfSymbol, reportErrors, intersectionState, relation === comparableRelation); if (!related) { return 0 /* False */; } @@ -60601,7 +62698,7 @@ var ts; 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) === 166 /* Constructor */ || ((_b = sourceSignature.declaration) === null || _b === void 0 ? void 0 : _b.kind) === 166 /* Constructor */)) { + (((_a = targetSignature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 168 /* Constructor */ || ((_b = sourceSignature.declaration) === null || _b === void 0 ? void 0 : _b.kind) === 168 /* Constructor */)) { var constructSignatureToString = function (signature) { return signatureToString(signature, /*enclosingDeclaration*/ undefined, 262144 /* WriteArrowStyleSignature */, kind); }; @@ -60709,10 +62806,17 @@ var ts; return indexTypesIdenticalTo(source, target, kind); } var targetType = getIndexTypeOfType(target, kind); - if (!targetType || targetType.flags & 1 /* Any */ && !sourceIsPrimitive) { - // Index signature of type any permits assignment from everything but primitives + if (!targetType) { return -1 /* True */; } + if (targetType.flags & 1 /* Any */ && !sourceIsPrimitive) { + // An index signature of type `any` permits assignment from everything but primitives, + // provided that there is also a `string` index signature of type `any`. + var stringIndexType = kind === 0 /* String */ ? targetType : getIndexTypeOfType(target, 0 /* String */); + if (stringIndexType && stringIndexType.flags & 1 /* Any */) { + return -1 /* True */; + } + } if (isGenericMappedType(source)) { // A generic mapped type { [P in K]: T } is related to a type with an index signature // { [x: string]: U }, and optionally with an index signature { [x: number]: V }, @@ -60867,7 +62971,7 @@ var ts; // type, and flag the result as a marker type reference. function getMarkerTypeReference(type, source, target) { var result = createTypeReference(type, ts.map(type.typeParameters, function (t) { return t === source ? target : t; })); - result.objectFlags |= 8192 /* MarkerType */; + result.objectFlags |= 4096 /* MarkerType */; return result; } function getAliasVariances(symbol) { @@ -60888,7 +62992,7 @@ var ts; if (typeParameters === void 0) { typeParameters = ts.emptyArray; } var variances = cache.variances; if (!variances) { - ts.tracing.push("checkTypes" /* CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: (_c = (_a = cache.id) !== null && _a !== void 0 ? _a : (_b = cache.declaredType) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : -1 }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: (_c = (_a = cache.id) !== null && _a !== void 0 ? _a : (_b = cache.declaredType) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : -1 }); // The emptyArray singleton is used to signal a recursive invocation. cache.variances = ts.emptyArray; variances = []; @@ -60927,7 +63031,7 @@ var ts; _loop_19(tp); } cache.variances = variances; - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } return variances; } @@ -60955,7 +63059,7 @@ var ts; return !!(ts.getObjectFlags(type) & 4 /* Reference */) && !type.node; } function isTypeReferenceWithGenericArguments(type) { - return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); + return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return !!(t.flags & 262144 /* TypeParameter */) || isTypeReferenceWithGenericArguments(t); }); } /** * getTypeReferenceId(A) returns "111=0-12=1" @@ -61041,8 +63145,8 @@ var ts; } // 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) { - return forEachProperty(prop, function (p) { return ts.getDeclarationModifierFlagsFromSymbol(p) & 16 /* Protected */ ? + function isClassDerivedFromDeclaringClasses(checkClass, prop, writing) { + return forEachProperty(prop, function (p) { return ts.getDeclarationModifierFlagsFromSymbol(p, writing) & 16 /* 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 @@ -61060,23 +63164,26 @@ var ts; function isDeeplyNestedType(type, stack, depth) { if (depth >= 5) { var identity_1 = getRecursionIdentity(type); - if (identity_1) { - var count = 0; - for (var i = 0; i < depth; i++) { - if (getRecursionIdentity(stack[i]) === identity_1) { - count++; - if (count >= 5) { - return true; - } + var count = 0; + for (var i = 0; i < depth; i++) { + if (getRecursionIdentity(stack[i]) === identity_1) { + count++; + if (count >= 5) { + return true; } } } } return false; } - // Types with constituents that could circularly reference the type have a recursion identity. The recursion - // identity is some object that is common to instantiations of the type with the same origin. + // The recursion identity of a type is an object identity that is shared among multiple instantiations of the type. + // We track recursion identities in order to identify deeply nested and possibly infinite type instantiations with + // the same origin. For example, when type parameters are in scope in an object type such as { x: T }, all + // instantiations of that type have the same recursion identity. The default recursion identity is the object + // identity of the type, meaning that every type is unique. Generally, types with constituents that could circularly + // 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) { // Deferred type references are tracked through their associated AST node. This gives us finer @@ -61094,6 +63201,9 @@ var ts; return type.target; } } + if (type.flags & 262144 /* TypeParameter */) { + return type.symbol; + } if (type.flags & 8388608 /* IndexedAccess */) { // Identity is the leftmost object type in a chain of indexed accesses, eg, in A[P][Q] it is A do { @@ -61105,7 +63215,7 @@ var ts; // The root object represents the origin of the conditional type return type.root; } - return undefined; + return type; } function isPropertyIdenticalTo(sourceProp, targetProp) { return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0 /* False */; @@ -61244,6 +63354,9 @@ var ts; // 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; }); @@ -61278,9 +63391,35 @@ var ts; // 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); } + function getSingleBaseForNonAugmentingSubtype(type) { + if (!(ts.getObjectFlags(type) & 4 /* Reference */) || !(ts.getObjectFlags(type.target) & 3 /* ClassOrInterface */)) { + return undefined; + } + if (ts.getObjectFlags(type) & 33554432 /* IdenticalBaseTypeCalculated */) { + return ts.getObjectFlags(type) & 67108864 /* IdenticalBaseTypeExists */ ? type.cachedEquivalentBaseType : undefined; + } + type.objectFlags |= 33554432 /* IdenticalBaseTypeCalculated */; + var target = type.target; + var bases = getBaseTypes(target); + if (bases.length !== 1) { + return undefined; + } + if (getMembersOfSymbol(type.symbol).size) { + return undefined; // If the interface has any members, they may subtype members in the base, so we should do a full structural comparison + } + var instantiatedBase = !ts.length(target.typeParameters) ? bases[0] : instantiateType(bases[0], createTypeMapper(target.typeParameters, getTypeArguments(type).slice(0, target.typeParameters.length))); + if (ts.length(getTypeArguments(type)) > ts.length(target.typeParameters)) { + instantiatedBase = getTypeWithThisArgument(instantiatedBase, ts.last(getTypeArguments(type))); + } + type.objectFlags |= 67108864 /* IdenticalBaseTypeExists */; + return type.cachedEquivalentBaseType = instantiatedBase; + } + function isEmptyLiteralType(type) { + return strictNullChecks ? type === implicitNeverType : type === undefinedWideningType; + } function isEmptyArrayLiteralType(type) { - var elementType = isArrayType(type) ? getTypeArguments(type)[0] : undefined; - return elementType === undefinedWideningType || elementType === implicitNeverType; + var elementType = getElementTypeOfArrayType(type); + return !!elementType && isEmptyLiteralType(elementType); } function isTupleLikeType(type) { return isTupleType(type) || !!getPropertyOfType(type, "0"); @@ -61304,6 +63443,13 @@ var ts; function isUnitType(type) { return !!(type.flags & 109440 /* Unit */); } + function isUnitLikeType(type) { + return type.flags & 2097152 /* Intersection */ ? ts.some(type.types, isUnitType) : + !!(type.flags & 109440 /* Unit */); + } + function extractUnitType(type) { + return type.flags & 2097152 /* 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) : @@ -61311,7 +63457,7 @@ var ts; } function getBaseTypeOfLiteralType(type) { return type.flags & 1024 /* EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : - type.flags & 134217856 /* StringLikeLiteral */ ? stringType : + type.flags & 128 /* StringLiteral */ ? stringType : type.flags & 256 /* NumberLiteral */ ? numberType : type.flags & 2048 /* BigIntLiteral */ ? bigintType : type.flags & 512 /* BooleanLiteral */ ? booleanType : @@ -61320,7 +63466,7 @@ var ts; } function getWidenedLiteralType(type) { return type.flags & 1024 /* EnumLiteral */ && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(type) : - type.flags & 134217856 /* StringLikeLiteral */ && isFreshLiteralType(type) ? stringType : + 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 : @@ -61449,19 +63595,23 @@ var ts; missing === 65536 /* Null */ ? getUnionType([type, nullType]) : getUnionType([type, undefinedType, nullType]); } - function getOptionalType(type) { + function getOptionalType(type, isProperty) { + if (isProperty === void 0) { isProperty = false; } ts.Debug.assert(strictNullChecks); - return type.flags & 32768 /* Undefined */ ? type : getUnionType([type, undefinedType]); + return type.flags & 32768 /* Undefined */ ? type : getUnionType([type, isProperty ? missingType : undefinedType]); } function getGlobalNonNullableTypeInstantiation(type) { + // First reduce away any constituents that are assignable to 'undefined' or 'null'. This not only eliminates + // 'undefined' and 'null', but also higher-order types such as a type parameter 'U extends undefined | null' + // that isn't eliminated by a NonNullable instantiation. + var reducedType = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); if (!deferredGlobalNonNullableTypeAlias) { deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288 /* TypeAlias */, /*diagnostic*/ undefined) || unknownSymbol; } - // Use NonNullable global type alias if available to improve quick info/declaration emit - if (deferredGlobalNonNullableTypeAlias !== unknownSymbol) { - return getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]); - } - return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); // Type alias unavailable, fall back to non-higher-order behavior + // If the NonNullable type is available, return an instantiation. Otherwise just return the reduced type. + return deferredGlobalNonNullableTypeAlias !== unknownSymbol ? + getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [reducedType]) : + reducedType; } function getNonNullableType(type) { return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type; @@ -61483,6 +63633,12 @@ var ts; ts.isOptionalChain(expression) ? removeOptionalTypeMarker(exprType) : exprType; } + function removeMissingType(type, isOptional) { + return strictOptionalProperties && isOptional ? filterType(type, function (t) { return t !== missingType; }) : type; + } + function containsMissingType(type) { + return strictOptionalProperties && (type === missingType || type.flags & 1048576 /* Union */ && containsType(type.types, missingType)); + } /** * Is source potentially coercible to target type under `==`. * Assumes that `source` is a constituent of a union, hence @@ -61514,7 +63670,7 @@ var ts; function isObjectTypeWithInferableIndex(type) { return type.flags & 2097152 /* Intersection */ ? ts.every(type.types, isObjectTypeWithInferableIndex) : !!(type.symbol && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 && - !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 2048 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); + !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 1024 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); } function createSymbolWithType(source, type) { var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */); @@ -61547,7 +63703,7 @@ var ts; * Leave signatures alone since they are not subject to the check. */ function getRegularTypeOfObjectLiteral(type) { - if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 32768 /* FreshLiteral */)) { + if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 16384 /* FreshLiteral */)) { return type; } var regularType = type.regularType; @@ -61558,7 +63714,7 @@ var ts; var members = transformTypeOfMembers(type, getRegularTypeOfObjectLiteral); var regularNew = createAnonymousType(resolved.symbol, members, resolved.callSignatures, resolved.constructSignatures, resolved.stringIndexInfo, resolved.numberIndexInfo); regularNew.flags = resolved.flags; - regularNew.objectFlags |= resolved.objectFlags & ~32768 /* FreshLiteral */; + regularNew.objectFlags |= resolved.objectFlags & ~16384 /* FreshLiteral */; type.regularType = regularNew; return regularNew; } @@ -61588,7 +63744,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) & 1024 /* ContainsSpread */)) { + if (isObjectLiteralType(t) && !(ts.getObjectFlags(t) & 4194304 /* ContainsSpread */)) { for (var _b = 0, _c = getPropertiesOfType(t); _b < _c.length; _b++) { var prop = _c[_b]; names.set(prop.escapedName, prop); @@ -61615,7 +63771,7 @@ var ts; if (cached) { return cached; } - var result = createSymbolWithType(prop, undefinedType); + var result = createSymbolWithType(prop, missingType); result.flags |= 16777216 /* Optional */; undefinedProperties.set(prop.escapedName, result); return result; @@ -61637,14 +63793,14 @@ var ts; var stringIndexInfo = getIndexInfoOfType(type, 0 /* String */); var numberIndexInfo = getIndexInfoOfType(type, 1 /* Number */); var result = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, stringIndexInfo && createIndexInfo(getWidenedType(stringIndexInfo.type), stringIndexInfo.isReadonly), numberIndexInfo && createIndexInfo(getWidenedType(numberIndexInfo.type), numberIndexInfo.isReadonly)); - result.objectFlags |= (ts.getObjectFlags(type) & (16384 /* JSLiteral */ | 2097152 /* NonInferrableType */)); // Retain js literal flag through widening + result.objectFlags |= (ts.getObjectFlags(type) & (8192 /* JSLiteral */ | 524288 /* 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) & 1572864 /* RequiresWidening */) { + if (ts.getObjectFlags(type) & 393216 /* RequiresWidening */) { if (context === undefined && type.widened) { return type.widened; } @@ -61689,7 +63845,7 @@ var ts; */ function reportWideningErrorsInType(type) { var errorReported = false; - if (ts.getObjectFlags(type) & 524288 /* ContainsWideningType */) { + if (ts.getObjectFlags(type) & 131072 /* ContainsWideningType */) { if (type.flags & 1048576 /* Union */) { if (ts.some(type.types, isEmptyObjectType)) { errorReported = true; @@ -61715,7 +63871,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) & 524288 /* ContainsWideningType */) { + if (ts.getObjectFlags(t) & 131072 /* ContainsWideningType */) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, symbolToString(p), typeToString(getWidenedType(t))); } @@ -61734,12 +63890,12 @@ var ts; } var diagnostic; switch (declaration.kind) { - case 216 /* BinaryExpression */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 218 /* BinaryExpression */: + case 165 /* PropertyDeclaration */: + case 164 /* 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 160 /* Parameter */: + case 162 /* Parameter */: var param = declaration; if (ts.isIdentifier(param.name) && (ts.isCallSignatureDeclaration(param.parent) || ts.isMethodSignature(param.parent) || ts.isFunctionTypeNode(param.parent)) && @@ -61754,23 +63910,23 @@ 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 198 /* BindingElement */: + case 200 /* 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 308 /* JSDocFunctionType */: + case 311 /* JSDocFunctionType */: error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; - case 251 /* FunctionDeclaration */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 253 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: if (noImplicitAny && !declaration.name) { if (wideningKind === 3 /* 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); @@ -61784,7 +63940,7 @@ var ts; wideningKind === 3 /* 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 190 /* MappedType */: + case 192 /* MappedType */: if (noImplicitAny) { error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); } @@ -61795,7 +63951,7 @@ var ts; errorOrSuggestion(noImplicitAny, declaration, diagnostic, ts.declarationNameToString(ts.getNameOfDeclaration(declaration)), typeAsString); } function reportErrorsFromWidening(declaration, type, wideningKind) { - if (produceDiagnostics && noImplicitAny && ts.getObjectFlags(type) & 524288 /* ContainsWideningType */ && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) { + if (produceDiagnostics && noImplicitAny && ts.getObjectFlags(type) & 131072 /* ContainsWideningType */ && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) { // Report implicit any error within type if possible, otherwise report error on declaration if (!reportWideningErrorsInType(type)) { reportImplicitAny(declaration, type, wideningKind); @@ -61911,23 +64067,23 @@ var ts; // results for union and intersection types for performance reasons. function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); - if (objectFlags & 67108864 /* CouldContainTypeVariablesComputed */) { - return !!(objectFlags & 134217728 /* CouldContainTypeVariables */); + if (objectFlags & 1048576 /* CouldContainTypeVariablesComputed */) { + return !!(objectFlags & 2097152 /* 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 */ | 131072 /* ObjectRestType */)) || + objectFlags & (32 /* Mapped */ | 1024 /* ReverseMapped */ | 8388608 /* ObjectRestType */)) || type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && !isNonGenericTopLevelType(type) && ts.some(type.types, couldContainTypeVariables)); if (type.flags & 3899393 /* ObjectFlagsType */) { - type.objectFlags |= 67108864 /* CouldContainTypeVariablesComputed */ | (result ? 134217728 /* CouldContainTypeVariables */ : 0); + type.objectFlags |= 1048576 /* CouldContainTypeVariablesComputed */ | (result ? 2097152 /* CouldContainTypeVariables */ : 0); } return result; } function isNonGenericTopLevelType(type) { if (type.aliasSymbol && !type.aliasTypeArguments) { - var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 254 /* TypeAliasDeclaration */); - return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 297 /* SourceFile */ ? true : n.kind === 256 /* ModuleDeclaration */ ? false : "quit"; })); + var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 256 /* TypeAliasDeclaration */); + return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 299 /* SourceFile */ ? true : n.kind === 258 /* ModuleDeclaration */ ? false : "quit"; })); } return false; } @@ -61980,7 +64136,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) & 2097152 /* NonInferrableType */) || + return !(ts.getObjectFlags(type) & 524288 /* NonInferrableType */) || isObjectLiteralType(type) && ts.some(getPropertiesOfType(type), function (prop) { return isPartiallyInferableType(getTypeOfSymbol(prop)); }) || isTupleType(type) && ts.some(getTypeArguments(type), isPartiallyInferableType); } @@ -62004,14 +64160,18 @@ var ts; } // 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(2048 /* ReverseMapped */ | 16 /* Anonymous */, /*symbol*/ undefined); + var reversed = createObjectType(1024 /* ReverseMapped */ | 16 /* Anonymous */, /*symbol*/ undefined); reversed.source = source; reversed.mappedType = target; reversed.constraintType = constraint; return reversed; } function getTypeOfReverseMappedSymbol(symbol) { - return inferReverseMappedType(symbol.propertyType, symbol.mappedType, symbol.constraintType); + var links = getSymbolLinks(symbol); + if (!links.type) { + links.type = inferReverseMappedType(symbol.propertyType, symbol.mappedType, symbol.constraintType); + } + return links.type; } function inferReverseMappedType(sourceType, target, constraint) { var typeParameter = getIndexedAccessType(constraint.type, getTypeParameterFromMappedType(target)); @@ -62103,51 +64263,113 @@ var ts; // * 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 */); } - function isStringLiteralTypeValueParsableAsType(s, target) { - if (target.flags & 1048576 /* Union */) { - return !!forEachType(target, function (t) { return isStringLiteralTypeValueParsableAsType(s, t); }); - } - switch (target) { - case stringType: return true; - case numberType: return s.value !== "" && isFinite(+(s.value)); - case bigintType: return s.value !== "" && isValidBigIntString(s.value); - // the next 4 should be handled in `getTemplateLiteralType`, as they are all exactly one value, but are here for completeness, just in case - // this function is ever used on types which don't come from template literal holes - case trueType: return s.value === "true"; - case falseType: return s.value === "false"; - case undefinedType: return s.value === "undefined"; - case nullType: return s.value === "null"; - default: return !!(target.flags & 1 /* Any */); - } - } - function inferLiteralsFromTemplateLiteralType(source, target) { - var value = source.value; - var texts = target.texts; - var lastIndex = texts.length - 1; - var startText = texts[0]; - var endText = texts[lastIndex]; - if (!(value.startsWith(startText) && value.slice(startText.length).endsWith(endText))) + function isValidTypeForTemplateLiteralPlaceholder(source, target) { + if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) { + return true; + } + if (source.flags & 128 /* StringLiteral */) { + var value = source.value; + return !!(target.flags & 8 /* Number */ && value !== "" && isFinite(+value) || + target.flags & 64 /* BigInt */ && value !== "" && isValidBigIntString(value) || + target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName); + } + if (source.flags & 134217728 /* 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 */ ? + ts.arraysEqual(source.texts, target.texts) ? ts.map(source.types, getStringLikeTypeForType) : + inferFromLiteralPartsToTemplateLiteral(source.texts, source.types, target) : + undefined; + } + function getStringLikeTypeForType(type) { + return type.flags & (1 /* Any */ | 402653316 /* 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 + // with one text part and zero type parts. The function returns an array of inferred string or template literal types + // corresponding to the placeholders in the target template literal, or undefined if the source doesn't match the target. + // + // We first check that the starting source text part matches the starting target text part, and that the ending source + // text part ends matches the ending target text part. We then iterate through the remaining target text parts, finding + // a match for each in the source and inferring string or template literal types created from the segments of the source + // that occur between the matches. During this iteration, seg holds the index of the current text part in the sourceTexts + // array and pos holds the current character position in the current text part. + // + // Consider inference from type `<<${string}>.<${number}-${number}>>` to type `<${string}.${string}>`, i.e. + // sourceTexts = ['<<', '>.<', '-', '>>'] + // sourceTypes = [string, number, number] + // target.texts = ['<', '.', '>'] + // We first match '<' in the target to the start of '<<' in the source and '>' in the target to the end of '>>' in + // the source. The first match for the '.' in target occurs at character 1 in the source text part at index 1, and thus + // the first inference is the template literal type `<${string}>`. The remainder of the source makes up the second + // inference, the template literal type `<${number}-${number}>`. + function inferFromLiteralPartsToTemplateLiteral(sourceTexts, sourceTypes, target) { + var lastSourceIndex = sourceTexts.length - 1; + var sourceStartText = sourceTexts[0]; + var sourceEndText = sourceTexts[lastSourceIndex]; + var targetTexts = target.texts; + var lastTargetIndex = targetTexts.length - 1; + var targetStartText = targetTexts[0]; + var targetEndText = targetTexts[lastTargetIndex]; + if (lastSourceIndex === 0 && sourceStartText.length < targetStartText.length + targetEndText.length || + !sourceStartText.startsWith(targetStartText) || !sourceEndText.endsWith(targetEndText)) return undefined; + var remainingEndText = sourceEndText.slice(0, sourceEndText.length - targetEndText.length); var matches = []; - var str = value.slice(startText.length, value.length - endText.length); - var pos = 0; - for (var i = 1; i < lastIndex; i++) { - var delim = texts[i]; - var delimPos = delim.length > 0 ? str.indexOf(delim, pos) : pos < str.length ? pos + 1 : -1; - if (delimPos < 0) + var seg = 0; + var pos = targetStartText.length; + for (var i = 1; i < lastTargetIndex; i++) { + var delim = targetTexts[i]; + if (delim.length > 0) { + var s = seg; + var p = pos; + while (true) { + p = getSourceText(s).indexOf(delim, p); + if (p >= 0) + break; + s++; + if (s === sourceTexts.length) + return undefined; + p = 0; + } + addMatch(s, p); + pos += delim.length; + } + else if (pos < getSourceText(seg).length) { + addMatch(seg, pos + 1); + } + else if (seg < lastSourceIndex) { + addMatch(seg + 1, 0); + } + else { return undefined; - matches.push(getLiteralType(str.slice(pos, delimPos))); - pos = delimPos + delim.length; + } } - matches.push(getLiteralType(str.slice(pos))); + addMatch(lastSourceIndex, getSourceText(lastSourceIndex).length); return matches; + function getSourceText(index) { + return index < lastSourceIndex ? sourceTexts[index] : remainingEndText; + } + function addMatch(s, p) { + var matchType = s === seg ? + getLiteralType(getSourceText(s).slice(pos, p)) : + getTemplateLiteralType(__spreadArray(__spreadArray([sourceTexts[seg].slice(pos)], sourceTexts.slice(seg + 1, s)), [getSourceText(s).slice(0, p)]), sourceTypes.slice(seg, s)); + matches.push(matchType); + seg = s; + pos = p; + } } function inferTypes(inferences, originalSource, originalTarget, priority, contravariant) { if (priority === void 0) { priority = 0; } if (contravariant === void 0) { contravariant = false; } var bivariant = false; var propagationType; - var inferencePriority = 1024 /* MaxValue */; + var inferencePriority = 2048 /* MaxValue */; var allowComplexConstraintInference = true; var visited; var sourceStack; @@ -62234,8 +64456,8 @@ var ts; // 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 (ts.getObjectFlags(source) & 2097152 /* NonInferrableType */ || source === nonInferrableAnyType || source === silentNeverType || - (priority & 64 /* ReturnType */ && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) { + if (ts.getObjectFlags(source) & 524288 /* NonInferrableType */ || source === nonInferrableAnyType || source === silentNeverType || + (priority & 128 /* ReturnType */ && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) { return; } var inference = getInferenceInfoForType(target); @@ -62262,7 +64484,7 @@ var ts; clearCachedInferences(inferences); } } - if (!(priority & 64 /* ReturnType */) && target.flags & 262144 /* TypeParameter */ && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) { + if (!(priority & 128 /* ReturnType */) && target.flags & 262144 /* TypeParameter */ && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) { inference.topLevel = false; clearCachedInferences(inferences); } @@ -62302,7 +64524,7 @@ var ts; else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 4194304 /* Index */) { var empty = createEmptyObjectTypeFromStringLiteral(source); contravariant = !contravariant; - inferWithPriority(empty, target.type, 128 /* LiteralKeyof */); + inferWithPriority(empty, target.type, 256 /* LiteralKeyof */); contravariant = !contravariant; } else if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) { @@ -62314,6 +64536,13 @@ var ts; inferFromTypes(source.type, target.type); } } + else if (source.flags & 33554432 /* Substitution */) { + inferFromTypes(source.baseType, target); + var oldPriority = priority; + priority |= 4 /* SubstituteSource */; + inferFromTypes(source.substitute, target); // Make substitute inference at a lower priority + priority = oldPriority; + } else if (target.flags & 16777216 /* Conditional */) { invokeOnce(source, target, inferToConditionalType); } @@ -62333,7 +64562,7 @@ var ts; } else { source = getReducedType(source); - if (!(priority & 256 /* NoConstraints */ && source.flags & (2097152 /* Intersection */ | 465829888 /* Instantiable */))) { + if (!(priority & 512 /* NoConstraints */ && source.flags & (2097152 /* Intersection */ | 465829888 /* 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` @@ -62371,26 +64600,22 @@ var ts; } (visited || (visited = new ts.Map())).set(key, -1 /* Circularity */); var saveInferencePriority = inferencePriority; - inferencePriority = 1024 /* MaxValue */; + inferencePriority = 2048 /* 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) || source; - var targetIdentity = getRecursionIdentity(target) || target; - if (sourceIdentity && ts.contains(sourceStack, sourceIdentity)) + var sourceIdentity = getRecursionIdentity(source); + var targetIdentity = getRecursionIdentity(target); + if (ts.contains(sourceStack, sourceIdentity)) expandingFlags |= 1 /* Source */; - if (targetIdentity && ts.contains(targetStack, targetIdentity)) + if (ts.contains(targetStack, targetIdentity)) expandingFlags |= 2 /* Target */; if (expandingFlags !== 3 /* Both */) { - if (sourceIdentity) - (sourceStack || (sourceStack = [])).push(sourceIdentity); - if (targetIdentity) - (targetStack || (targetStack = [])).push(targetIdentity); + (sourceStack || (sourceStack = [])).push(sourceIdentity); + (targetStack || (targetStack = [])).push(targetIdentity); action(source, target); - if (targetIdentity) - targetStack.pop(); - if (sourceIdentity) - sourceStack.pop(); + targetStack.pop(); + sourceStack.pop(); } else { inferencePriority = -1 /* Circularity */; @@ -62430,7 +64655,7 @@ var ts; } } function inferFromContravariantTypes(source, target) { - if (strictFunctionTypes || priority & 512 /* AlwaysStrict */) { + if (strictFunctionTypes || priority & 1024 /* AlwaysStrict */) { contravariant = !contravariant; inferFromTypes(source, target); contravariant = !contravariant; @@ -62482,7 +64707,7 @@ var ts; else { for (var i = 0; i < sources.length; i++) { var saveInferencePriority = inferencePriority; - inferencePriority = 1024 /* MaxValue */; + inferencePriority = 2048 /* MaxValue */; inferFromTypes(sources[i], t); if (inferencePriority === priority) matched_1[i] = true; @@ -62561,9 +64786,9 @@ 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) & 2097152 /* NonInferrableType */ ? - 8 /* PartialHomomorphicMappedType */ : - 4 /* HomomorphicMappedType */); + inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 524288 /* NonInferrableType */ ? + 16 /* PartialHomomorphicMappedType */ : + 8 /* HomomorphicMappedType */); } } return true; @@ -62571,7 +64796,7 @@ var ts; if (constraintType.flags & 262144 /* 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, 16 /* MappedTypeConstraint */); + inferWithPriority(getIndexType(source), constraintType, 32 /* 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 @@ -62600,16 +64825,14 @@ var ts; } else { var savePriority = priority; - priority |= contravariant ? 32 /* ContravariantConditional */ : 0; + priority |= contravariant ? 64 /* ContravariantConditional */ : 0; var targetTypes = [getTrueTypeFromConditionalType(target), getFalseTypeFromConditionalType(target)]; inferToMultipleTypes(source, targetTypes, target.flags); priority = savePriority; } } function inferToTemplateLiteralType(source, target) { - var matches = source.flags & 128 /* StringLiteral */ ? inferLiteralsFromTemplateLiteralType(source, target) : - source.flags & 134217728 /* TemplateLiteral */ && ts.arraysEqual(source.texts, target.texts) ? source.types : - undefined; + var matches = inferTypesFromTemplateLiteralType(source, target); var types = target.types; for (var i = 0; i < types.length; i++) { inferFromTypes(matches ? matches[i] : neverType, types[i]); @@ -62725,7 +64948,7 @@ var ts; var sourceLen = sourceSignatures.length; var targetLen = targetSignatures.length; var len = sourceLen < targetLen ? sourceLen : targetLen; - var skipParameters = !!(ts.getObjectFlags(source) & 2097152 /* NonInferrableType */); + var skipParameters = !!(ts.getObjectFlags(source) & 524288 /* NonInferrableType */); for (var i = 0; i < len; i++) { inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i]), skipParameters); } @@ -62735,19 +64958,21 @@ var ts; 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 === 165 /* MethodDeclaration */ || kind === 164 /* MethodSignature */ || kind === 166 /* Constructor */; + bivariant = bivariant || kind === 167 /* MethodDeclaration */ || kind === 166 /* MethodSignature */ || kind === 168 /* Constructor */; applyToParameterTypes(source, target, inferFromContravariantTypes); 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 targetStringIndexType = getIndexTypeOfType(target, 0 /* String */); if (targetStringIndexType) { var sourceIndexType = getIndexTypeOfType(source, 0 /* String */) || getImplicitIndexTypeOfType(source, 0 /* String */); if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetStringIndexType); + inferWithPriority(sourceIndexType, targetStringIndexType, priority); } } var targetNumberIndexType = getIndexTypeOfType(target, 1 /* Number */); @@ -62756,13 +64981,13 @@ var ts; getIndexTypeOfType(source, 0 /* String */) || getImplicitIndexTypeOfType(source, 1 /* Number */); if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetNumberIndexType); + inferWithPriority(sourceIndexType, targetNumberIndexType, priority); } } } } function isTypeOrBaseIdenticalTo(s, t) { - return isTypeIdenticalTo(s, t) || !!(t.flags & 4 /* String */ && s.flags & 134217856 /* StringLikeLiteral */ || t.flags & 8 /* Number */ && s.flags & 256 /* NumberLiteral */); + return isTypeIdenticalTo(s, t) || !!(t.flags & 4 /* String */ && s.flags & 128 /* StringLiteral */ || t.flags & 8 /* Number */ && s.flags & 256 /* NumberLiteral */); } function isTypeCloselyMatchedBy(s, t) { return !!(s.flags & 524288 /* Object */ && t.flags & 524288 /* Object */ && s.symbol && s.symbol === t.symbol || @@ -62776,7 +65001,7 @@ var ts; return !!(ts.getObjectFlags(type) & 128 /* ObjectLiteral */); } function isObjectOrArrayLiteralType(type) { - return !!(ts.getObjectFlags(type) & (128 /* ObjectLiteral */ | 65536 /* ArrayLiteral */)); + return !!(ts.getObjectFlags(type) & (128 /* ObjectLiteral */ | 32768 /* ArrayLiteral */)); } function unionObjectAndArrayLiteralCandidates(candidates) { if (candidates.length > 1) { @@ -62789,7 +65014,7 @@ var ts; return candidates; } function getContravariantInference(inference) { - return inference.priority & 208 /* PriorityImpliesCombination */ ? getIntersectionType(inference.contraCandidates) : getCommonSubtype(inference.contraCandidates); + return inference.priority & 416 /* 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. @@ -62806,7 +65031,7 @@ 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 & 208 /* PriorityImpliesCombination */ ? + var unwidenedType = inference.priority & 416 /* PriorityImpliesCombination */ ? getUnionType(baseCandidates, 2 /* Subtype */) : getCommonSupertype(baseCandidates); return getWidenedType(unwidenedType); @@ -62915,7 +65140,7 @@ var ts; case "BigUint64Array": return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_1_or_later; default: - if (node.parent.kind === 289 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 291 /* ShorthandPropertyAssignment */) { return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer; } else { @@ -62936,26 +65161,27 @@ 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 === 176 /* TypeQuery */ ? true : n.kind === 78 /* Identifier */ || n.kind === 157 /* QualifiedName */ ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 178 /* TypeQuery */ ? true : n.kind === 79 /* Identifier */ || n.kind === 159 /* 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 // leftmost identifier followed by zero or more property names separated by dots. - // The result is undefined if the reference isn't a dotted name. We prefix nodes - // occurring in an apparent type position with '@' because the control flow type - // of such nodes may be based on the apparent type instead of the declared type. + // The result is undefined if the reference isn't a dotted name. function getFlowCacheKey(node, declaredType, initialType, flowContainer) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: var symbol = getResolvedSymbol(node); - return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + (isConstraintPosition(node) ? "@" : "") + getSymbolId(symbol) : undefined; - case 107 /* ThisKeyword */: + return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + getSymbolId(symbol) : undefined; + case 108 /* ThisKeyword */: return "0|" + (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType); - case 225 /* NonNullExpression */: - case 207 /* ParenthesizedExpression */: + case 227 /* NonNullExpression */: + case 209 /* ParenthesizedExpression */: return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 159 /* QualifiedName */: + var left = getFlowCacheKey(node.left, declaredType, initialType, flowContainer); + return left && left + "." + node.right.escapedText; + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: var propName = getAccessedPropertyName(node); if (propName !== undefined) { var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); @@ -62966,32 +65192,40 @@ var ts; } function isMatchingReference(source, target) { switch (target.kind) { - case 207 /* ParenthesizedExpression */: - case 225 /* NonNullExpression */: + case 209 /* ParenthesizedExpression */: + case 227 /* NonNullExpression */: return isMatchingReference(source, target.expression); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return (ts.isAssignmentExpression(target) && isMatchingReference(source, target.left)) || (ts.isBinaryExpression(target) && target.operatorToken.kind === 27 /* CommaToken */ && isMatchingReference(source, target.right)); } switch (source.kind) { - case 78 /* Identifier */: - case 79 /* PrivateIdentifier */: - return target.kind === 78 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 249 /* VariableDeclaration */ || target.kind === 198 /* BindingElement */) && + case 228 /* MetaProperty */: + return target.kind === 228 /* MetaProperty */ + && source.keywordToken === target.keywordToken + && source.name.escapedText === target.name.escapedText; + case 79 /* Identifier */: + case 80 /* PrivateIdentifier */: + return target.kind === 79 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 251 /* VariableDeclaration */ || target.kind === 200 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 107 /* ThisKeyword */: - return target.kind === 107 /* ThisKeyword */; - case 105 /* SuperKeyword */: - return target.kind === 105 /* SuperKeyword */; - case 225 /* NonNullExpression */: - case 207 /* ParenthesizedExpression */: + case 108 /* ThisKeyword */: + return target.kind === 108 /* ThisKeyword */; + case 106 /* SuperKeyword */: + return target.kind === 106 /* SuperKeyword */; + case 227 /* NonNullExpression */: + case 209 /* ParenthesizedExpression */: return isMatchingReference(source.expression, target); - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: return ts.isAccessExpression(target) && getAccessedPropertyName(source) === getAccessedPropertyName(target) && isMatchingReference(source.expression, target.expression); - case 216 /* BinaryExpression */: + case 159 /* QualifiedName */: + return ts.isAccessExpression(target) && + source.right.escapedText === getAccessedPropertyName(target) && + isMatchingReference(source.left, target.expression); + case 218 /* BinaryExpression */: return (ts.isBinaryExpression(source) && source.operatorToken.kind === 27 /* CommaToken */ && isMatchingReference(source.right, target)); } return false; @@ -62999,11 +65233,11 @@ var ts; // Given a source x, check if target matches x or is an && operation with an operand that matches x. function containsTruthyCheck(source, target) { return isMatchingReference(source, target) || - (target.kind === 216 /* BinaryExpression */ && target.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && + (target.kind === 218 /* BinaryExpression */ && target.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && (containsTruthyCheck(source, target.left) || containsTruthyCheck(source, target.right))); } function getAccessedPropertyName(access) { - return access.kind === 201 /* PropertyAccessExpression */ ? access.name.escapedText : + return access.kind === 203 /* PropertyAccessExpression */ ? access.name.escapedText : ts.isStringOrNumericLiteralLike(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) : undefined; } @@ -63053,6 +65287,86 @@ var ts; } return result; } + // Given a set of constituent types and a property name, create and return a map keyed by the literal + // types of the property by that name in each constituent type. No map is returned if some key property + // has a non-literal type or if less than 10 or less than 50% of the constituents have a unique key. + // Entries with duplicate keys have unknownType as the value. + function mapTypesByKeyProperty(types, name) { + var map = new ts.Map(); + var count = 0; + var _loop_20 = function (type) { + if (type.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) { + var discriminant = getTypeOfPropertyOfType(type, name); + if (discriminant) { + if (!isLiteralType(discriminant)) { + return { value: undefined }; + } + var duplicate_1 = false; + forEachType(discriminant, function (t) { + var id = getTypeId(getRegularTypeOfLiteralType(t)); + var existing = map.get(id); + if (!existing) { + map.set(id, type); + } + else if (existing !== unknownType) { + map.set(id, unknownType); + duplicate_1 = true; + } + }); + if (!duplicate_1) + count++; + } + } + }; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var type = types_17[_i]; + var state_8 = _loop_20(type); + if (typeof state_8 === "object") + return state_8.value; + } + return count >= 10 && count * 2 >= types.length ? map : undefined; + } + // Return the name of a discriminant property for which it was possible and feasible to construct a map of + // constituent types keyed by the literal types of the property by that name in each constituent type. + function getKeyPropertyName(unionType) { + var types = unionType.types; + // We only construct maps for large unions with non-primitive constituents. + if (types.length < 10 || ts.getObjectFlags(unionType) & 65536 /* PrimitiveUnion */) { + 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 */) ? + ts.forEach(getPropertiesOfType(t), function (p) { return isUnitType(getTypeOfSymbol(p)) ? p.escapedName : undefined; }) : + undefined; + }); + var mapByKeyProperty = keyPropertyName && mapTypesByKeyProperty(types, keyPropertyName); + unionType.keyPropertyName = mapByKeyProperty ? keyPropertyName : ""; + unionType.constituentMap = mapByKeyProperty; + } + return unionType.keyPropertyName.length ? unionType.keyPropertyName : undefined; + } + // Given a union type for which getKeyPropertyName returned a non-undefined result, return the constituent + // that corresponds to the given key type for that property name. + function getConstituentTypeForKeyType(unionType, keyType) { + var _a; + var result = (_a = unionType.constituentMap) === null || _a === void 0 ? void 0 : _a.get(getTypeId(getRegularTypeOfLiteralType(keyType))); + return result !== unknownType ? result : undefined; + } + function getMatchingUnionConstituentForType(unionType, type) { + var keyPropertyName = getKeyPropertyName(unionType); + var propType = keyPropertyName && getTypeOfPropertyOfType(type, keyPropertyName); + return propType && getConstituentTypeForKeyType(unionType, propType); + } + function getMatchingUnionConstituentForObjectLiteral(unionType, node) { + var keyPropertyName = getKeyPropertyName(unionType); + var propNode = keyPropertyName && ts.find(node.properties, function (p) { return p.symbol && p.kind === 290 /* PropertyAssignment */ && + p.symbol.escapedName === keyPropertyName && isPossiblyDiscriminantValue(p.initializer); }); + var propType = propNode && getTypeOfExpression(propNode.initializer); + return propType && getConstituentTypeForKeyType(unionType, propType); + } function isOrContainsMatchingReference(source, target) { return isMatchingReference(source, target) || containsMatchingReference(source, target); } @@ -63065,7 +65379,7 @@ var ts; } } } - if (expression.expression.kind === 201 /* PropertyAccessExpression */ && + if (expression.expression.kind === 203 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, expression.expression.expression)) { return true; } @@ -63112,14 +65426,6 @@ var ts; } return declaredType; } - function getTypeFactsOfTypes(types) { - var result = 0 /* None */; - for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { - var t = types_17[_i]; - result |= getTypeFacts(t); - } - return result; - } function isFunctionObjectType(type) { // We do a quick check for a "bind" property before performing the more expensive subtype // check. This gives us a quicker out in the common case where an object type is not a function. @@ -63127,7 +65433,8 @@ var ts; return !!(resolved.callSignatures.length || resolved.constructSignatures.length || resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType)); } - function getTypeFacts(type) { + function getTypeFacts(type, ignoreObjects) { + if (ignoreObjects === void 0) { ignoreObjects = false; } var flags = type.flags; if (flags & 4 /* String */) { return strictNullChecks ? 16317953 /* StringStrictFacts */ : 16776705 /* StringFacts */; @@ -63164,7 +65471,7 @@ var ts; (type === falseType || type === regularFalseType) ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ : (type === falseType || type === regularFalseType) ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */; } - if (flags & 524288 /* Object */) { + if (flags & 524288 /* Object */ && !ignoreObjects) { return ts.getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type) ? strictNullChecks ? 16318463 /* EmptyObjectStrictFacts */ : 16777215 /* EmptyObjectFacts */ : isFunctionObjectType(type) ? @@ -63187,11 +65494,17 @@ var ts; return 0 /* None */; } if (flags & 465829888 /* Instantiable */) { - return !isPatternLiteralType(type) ? getTypeFacts(getBaseConstraintOfType(type) || unknownType) : + return !isPatternLiteralType(type) ? getTypeFacts(getBaseConstraintOfType(type) || unknownType, ignoreObjects) : strictNullChecks ? 7929345 /* NonEmptyStringStrictFacts */ : 16776705 /* NonEmptyStringFacts */; } - if (flags & 3145728 /* UnionOrIntersection */) { - return getTypeFactsOfTypes(type.types); + if (flags & 1048576 /* Union */) { + return ts.reduceLeft(type.types, function (facts, t) { return facts | getTypeFacts(t, ignoreObjects); }, 0 /* None */); + } + if (flags & 2097152 /* Intersection */) { + // 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. + ignoreObjects || (ignoreObjects = maybeTypeOfKind(type, 131068 /* Primitive */)); + return ts.reduceLeft(type.types, function (facts, t) { return facts & getTypeFacts(t, ignoreObjects); }, 16777215 /* All */); } return 16777215 /* All */; } @@ -63199,18 +65512,16 @@ var ts; return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; }); } function getTypeWithDefault(type, defaultExpression) { - if (defaultExpression) { - var defaultType = getTypeOfExpression(defaultExpression); - return getUnionType([getTypeWithFacts(type, 524288 /* NEUndefined */), defaultType]); - } - return type; + return defaultExpression ? + getUnionType([getNonUndefinedType(type), getTypeOfExpression(defaultExpression)]) : + type; } function getTypeOfDestructuredProperty(type, name) { var nameType = getLiteralTypeFromPropertyName(name); if (!isTypeUsableAsPropertyName(nameType)) return errorType; var text = getPropertyNameFromType(nameType); - return getConstraintForLocation(getTypeOfPropertyOfType(type, text), name) || + return getTypeOfPropertyOfType(type, text) || isNumericLiteralName(text) && includeUndefinedInIndexSignature(getIndexTypeOfType(type, 1 /* Number */)) || includeUndefinedInIndexSignature(getIndexTypeOfType(type, 0 /* String */)) || errorType; @@ -63231,15 +65542,15 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 199 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 288 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 201 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 290 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 216 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 239 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 218 /* BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 241 /* ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -63256,21 +65567,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return stringType; - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: return checkRightHandSideOfForOf(parent) || errorType; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 210 /* DeleteExpression */: + case 212 /* DeleteExpression */: return undefinedType; - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 220 /* SpreadElement */: + case 222 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -63278,7 +65589,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 196 /* ObjectBindingPattern */ ? + var type = pattern.kind === 198 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -63296,35 +65607,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 238 /* ForInStatement */) { + if (node.parent.parent.kind === 240 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 239 /* ForOfStatement */) { + if (node.parent.parent.kind === 241 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 249 /* VariableDeclaration */ ? + return node.kind === 251 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function isEmptyArrayAssignment(node) { - return node.kind === 249 /* VariableDeclaration */ && node.initializer && + return node.kind === 251 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 198 /* BindingElement */ && node.parent.kind === 216 /* BinaryExpression */ && + node.kind !== 200 /* BindingElement */ && node.parent.kind === 218 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 62 /* EqualsToken */: - case 74 /* BarBarEqualsToken */: - case 75 /* AmpersandAmpersandEqualsToken */: - case 76 /* QuestionQuestionEqualsToken */: + case 63 /* EqualsToken */: + case 75 /* BarBarEqualsToken */: + case 76 /* AmpersandAmpersandEqualsToken */: + case 77 /* QuestionQuestionEqualsToken */: return getReferenceCandidate(node.left); case 27 /* CommaToken */: return getReferenceCandidate(node.right); @@ -63334,13 +65645,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 207 /* ParenthesizedExpression */ || - parent.kind === 216 /* BinaryExpression */ && parent.operatorToken.kind === 62 /* EqualsToken */ && parent.left === node || - parent.kind === 216 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? + return parent.kind === 209 /* ParenthesizedExpression */ || + parent.kind === 218 /* BinaryExpression */ && parent.operatorToken.kind === 63 /* EqualsToken */ && parent.left === node || + parent.kind === 218 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 284 /* CaseClause */) { + if (clause.kind === 286 /* CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -63360,7 +65671,7 @@ var ts; var witnesses = []; for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) { var clause = _a[_i]; - if (clause.kind === 284 /* CaseClause */) { + if (clause.kind === 286 /* CaseClause */) { if (ts.isStringLiteralLike(clause.expression)) { witnesses.push(clause.expression.text); continue; @@ -63396,14 +65707,40 @@ var ts; function forEachType(type, f) { return type.flags & 1048576 /* Union */ ? ts.forEach(type.types, f) : f(type); } + function someType(type, f) { + return type.flags & 1048576 /* Union */ ? ts.some(type.types, f) : f(type); + } function everyType(type, f) { return type.flags & 1048576 /* Union */ ? ts.every(type.types, f) : f(type); } + function everyContainedType(type, f) { + return type.flags & 3145728 /* UnionOrIntersection */ ? ts.every(type.types, f) : f(type); + } function filterType(type, f) { if (type.flags & 1048576 /* Union */) { var types = type.types; var filtered = ts.filter(types, f); - return filtered === types ? type : getUnionTypeFromSortedList(filtered, type.objectFlags); + if (filtered === types) { + return type; + } + var origin = type.origin; + var newOrigin = void 0; + if (origin && origin.flags & 1048576 /* 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); }); + if (originTypes.length - originFiltered.length === types.length - filtered.length) { + if (originFiltered.length === 1) { + return originFiltered[0]; + } + newOrigin = createOriginUnionOrIntersectionType(1048576 /* Union */, originFiltered); + } + } + return getUnionTypeFromSortedList(filtered, type.objectFlags, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, newOrigin); } return type.flags & 131072 /* Never */ || f(type) ? type : neverType; } @@ -63436,6 +65773,11 @@ var ts; } return changed ? mappedTypes && getUnionType(mappedTypes, noReductions ? 0 /* None */ : 1 /* Literal */) : type; } + function mapTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments) { + return type.flags & 1048576 /* Union */ && aliasSymbol ? + getUnionType(ts.map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments) : + mapType(type, mapper); + } function getConstituentCount(type) { return type.flags & 3145728 /* UnionOrIntersection */ ? type.types.length : 1; } @@ -63521,21 +65863,21 @@ var ts; var root = getReferenceRoot(node); var parent = root.parent; var isLengthPushOrUnshift = ts.isPropertyAccessExpression(parent) && (parent.name.escapedText === "length" || - parent.parent.kind === 203 /* CallExpression */ + parent.parent.kind === 205 /* CallExpression */ && ts.isIdentifier(parent.name) && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 202 /* ElementAccessExpression */ && + var isElementAssignment = parent.kind === 204 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 216 /* BinaryExpression */ && - parent.parent.operatorToken.kind === 62 /* EqualsToken */ && + parent.parent.kind === 218 /* BinaryExpression */ && + parent.parent.operatorToken.kind === 63 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* NumberLike */); return isLengthPushOrUnshift || isElementAssignment; } function isDeclarationWithExplicitTypeAnnotation(declaration) { - return (declaration.kind === 249 /* VariableDeclaration */ || declaration.kind === 160 /* Parameter */ || - declaration.kind === 163 /* PropertyDeclaration */ || declaration.kind === 162 /* PropertySignature */) && + return (declaration.kind === 251 /* VariableDeclaration */ || declaration.kind === 162 /* Parameter */ || + declaration.kind === 165 /* PropertyDeclaration */ || declaration.kind === 164 /* PropertySignature */) && !!ts.getEffectiveTypeAnnotationNode(declaration); } function getExplicitTypeOfSymbol(symbol, diagnostic) { @@ -63554,7 +65896,7 @@ var ts; if (isDeclarationWithExplicitTypeAnnotation(declaration)) { return getTypeOfSymbol(symbol); } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 239 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 241 /* ForOfStatement */) { var statement = declaration.parent.parent; var expressionType = getTypeOfDottedName(statement.expression, /*diagnostic*/ undefined); if (expressionType) { @@ -63575,18 +65917,32 @@ var ts; function getTypeOfDottedName(node, diagnostic) { if (!(node.flags & 16777216 /* InWithStatement */)) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node)); return getExplicitTypeOfSymbol(symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol, diagnostic); - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: return getExplicitThisType(node); - case 105 /* SuperKeyword */: + case 106 /* SuperKeyword */: return checkSuperExpression(node); - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: { var type = getTypeOfDottedName(node.expression, diagnostic); - var prop = type && getPropertyOfType(type, node.name.escapedText); - return prop && getExplicitTypeOfSymbol(prop, diagnostic); - case 207 /* ParenthesizedExpression */: + if (type) { + var name = node.name; + var prop = void 0; + if (ts.isPrivateIdentifier(name)) { + if (!type.symbol) { + return undefined; + } + prop = getPropertyOfType(type, ts.getSymbolNameForPrivateIdentifier(type.symbol, name.escapedText)); + } + else { + prop = getPropertyOfType(type, name.escapedText); + } + return prop && getExplicitTypeOfSymbol(prop, diagnostic); + } + return undefined; + } + case 209 /* ParenthesizedExpression */: return getTypeOfDottedName(node.expression, diagnostic); } } @@ -63600,10 +65956,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 === 233 /* ExpressionStatement */) { + if (node.parent.kind === 235 /* ExpressionStatement */) { funcType = getTypeOfDottedName(node.expression, /*diagnostic*/ undefined); } - else if (node.expression.kind !== 105 /* SuperKeyword */) { + else if (node.expression.kind !== 106 /* SuperKeyword */) { if (ts.isOptionalChain(node)) { funcType = checkNonNullType(getOptionalExpressionType(checkExpression(node.expression), node.expression), node.expression); } @@ -63644,7 +66000,7 @@ var ts; } function isFalseExpression(expr) { var node = ts.skipParentheses(expr); - return node.kind === 94 /* FalseKeyword */ || node.kind === 216 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && (isFalseExpression(node.left) || isFalseExpression(node.right)) || + return node.kind === 95 /* FalseKeyword */ || node.kind === 218 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && (isFalseExpression(node.left) || isFalseExpression(node.right)) || node.operatorToken.kind === 56 /* BarBarToken */ && isFalseExpression(node.left) && isFalseExpression(node.right)); } function isReachableFlowNodeWorker(flow, noCacheCheck) { @@ -63732,7 +66088,7 @@ var ts; flow = flow.antecedent; } else if (flags & 512 /* Call */) { - if (flow.node.expression.kind === 105 /* SuperKeyword */) { + if (flow.node.expression.kind === 106 /* SuperKeyword */) { return true; } flow = flow.antecedent; @@ -63779,7 +66135,7 @@ var ts; // 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 === 225 /* NonNullExpression */ && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { + if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 227 /* NonNullExpression */ && !(resultType.flags & 131072 /* Never */) && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { return declaredType; } return resultType; @@ -63794,7 +66150,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.instant("checkTypes" /* CheckTypes */, "getTypeAtFlowNode_DepthLimit", { flowId: flow.id }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "getTypeAtFlowNode_DepthLimit", { flowId: flow.id }); flowAnalysisDisabled = true; reportFlowControlError(reference); return errorType; @@ -63863,9 +66219,9 @@ var ts; // Check if we should continue with the control flow of the containing function. var container = flow.node; if (container && container !== flowContainer && - reference.kind !== 201 /* PropertyAccessExpression */ && - reference.kind !== 202 /* ElementAccessExpression */ && - reference.kind !== 107 /* ThisKeyword */) { + reference.kind !== 203 /* PropertyAccessExpression */ && + reference.kind !== 204 /* ElementAccessExpression */ && + reference.kind !== 108 /* ThisKeyword */) { flow = container.flowNode; continue; } @@ -63889,7 +66245,7 @@ var ts; } function getInitialOrAssignedType(flow) { var node = flow.node; - return getConstraintForLocation(node.kind === 249 /* VariableDeclaration */ || node.kind === 198 /* BindingElement */ ? + return getNarrowableTypeForReference(node.kind === 251 /* VariableDeclaration */ || node.kind === 200 /* BindingElement */ ? getInitialType(node) : getAssignedType(node), reference); } @@ -63929,14 +66285,14 @@ 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 === 208 /* FunctionExpression */ || init.kind === 209 /* ArrowFunction */)) { + if (init && (init.kind === 210 /* FunctionExpression */ || init.kind === 211 /* 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 === 238 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { + if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 240 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); } // Assignment doesn't affect reference @@ -63944,10 +66300,10 @@ var ts; } function narrowTypeByAssertion(type, expr) { var node = ts.skipParentheses(expr); - if (node.kind === 94 /* FalseKeyword */) { + if (node.kind === 95 /* FalseKeyword */) { return unreachableNeverType; } - if (node.kind === 216 /* BinaryExpression */) { + if (node.kind === 218 /* BinaryExpression */) { if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { return narrowTypeByAssertion(narrowTypeByAssertion(type, node.left), node.right); } @@ -63978,7 +66334,7 @@ var ts; function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 203 /* CallExpression */ ? + var expr = node.kind === 205 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -63986,7 +66342,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 203 /* CallExpression */) { + if (node.kind === 205 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -64034,7 +66390,7 @@ var ts; if (isMatchingReference(reference, expr)) { type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } - else if (expr.kind === 211 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { + else if (expr.kind === 213 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } else { @@ -64042,12 +66398,12 @@ var ts; if (optionalChainContainsReference(expr, reference)) { type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & (32768 /* Undefined */ | 131072 /* Never */)); }); } - else if (expr.kind === 211 /* TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) { + else if (expr.kind === 213 /* 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"); }); } } if (isMatchingReferenceDiscriminant(expr, type)) { - type = narrowTypeByDiscriminant(type, expr, function (t) { return narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd); }); + type = narrowTypeBySwitchOnDiscriminantProperty(type, expr, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } } return createFlowType(type, isIncomplete(flowType)); @@ -64218,16 +66574,42 @@ var ts; if (propName === undefined) { return type; } - var propType = getTypeOfPropertyOfType(type, propName); + var removeNullable = strictNullChecks && ts.isOptionalChain(access) && maybeTypeOfKind(type, 98304 /* Nullable */); + var propType = getTypeOfPropertyOfType(removeNullable ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type, propName); if (!propType) { return type; } + propType = removeNullable ? getOptionalType(propType) : propType; var narrowedPropType = narrowType(propType); return filterType(type, function (t) { var discriminantType = getTypeOfPropertyOrIndexSignature(t, propName); return !(discriminantType.flags & 131072 /* Never */) && isTypeComparableTo(discriminantType, narrowedPropType); }); } + function narrowTypeByDiscriminantProperty(type, access, operator, value, assumeTrue) { + if ((operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) && type.flags & 1048576 /* Union */) { + var keyPropertyName = getKeyPropertyName(type); + if (keyPropertyName && keyPropertyName === getAccessedPropertyName(access)) { + var candidate_2 = getConstituentTypeForKeyType(type, getTypeOfExpression(value)); + if (candidate_2) { + return operator === (assumeTrue ? 36 /* EqualsEqualsEqualsToken */ : 37 /* ExclamationEqualsEqualsToken */) ? candidate_2 : + isUnitType(getTypeOfPropertyOfType(candidate_2, keyPropertyName) || unknownType) ? filterType(type, function (t) { return t !== candidate_2; }) : + type; + } + } + } + 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)) { + var clauseTypes = getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd); + var candidate = getUnionType(ts.map(clauseTypes, function (t) { return getConstituentTypeForKeyType(type, t) || unknownType; })); + if (candidate !== unknownType) { + return candidate; + } + } + return narrowTypeByDiscriminant(type, access, function (t) { return narrowTypeBySwitchOnDiscriminant(t, switchStatement, clauseStart, clauseEnd); }); + } function narrowTypeByTruthiness(type, expr, assumeTrue) { if (isMatchingReference(reference, expr)) { return getTypeWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); @@ -64251,7 +66633,8 @@ var ts; return !assumeTrue; } function narrowByInKeyword(type, literal, assumeTrue) { - if (type.flags & (1048576 /* Union */ | 524288 /* Object */) + if (type.flags & 1048576 /* Union */ + || type.flags & 524288 /* Object */ && declaredType !== type || isThisTypeParameter(type) || type.flags & 2097152 /* Intersection */ && ts.every(type.types, function (t) { return t.symbol !== globalThisSymbol; })) { var propName_1 = ts.escapeLeadingUnderscores(literal.text); @@ -64261,57 +66644,63 @@ var ts; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 62 /* EqualsToken */: - case 74 /* BarBarEqualsToken */: - case 75 /* AmpersandAmpersandEqualsToken */: - case 76 /* QuestionQuestionEqualsToken */: + case 63 /* EqualsToken */: + case 75 /* BarBarEqualsToken */: + case 76 /* AmpersandAmpersandEqualsToken */: + case 77 /* QuestionQuestionEqualsToken */: return narrowTypeByTruthiness(narrowType(type, expr.right, assumeTrue), expr.left, assumeTrue); case 34 /* EqualsEqualsToken */: case 35 /* ExclamationEqualsToken */: case 36 /* EqualsEqualsEqualsToken */: case 37 /* ExclamationEqualsEqualsToken */: - var operator_1 = expr.operatorToken.kind; - var left_1 = getReferenceCandidate(expr.left); - var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 211 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { - return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); + var operator = expr.operatorToken.kind; + var left = getReferenceCandidate(expr.left); + var right = getReferenceCandidate(expr.right); + if (left.kind === 213 /* TypeOfExpression */ && ts.isStringLiteralLike(right)) { + return narrowTypeByTypeof(type, left, operator, right, assumeTrue); } - if (right_1.kind === 211 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { - return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); + if (right.kind === 213 /* TypeOfExpression */ && ts.isStringLiteralLike(left)) { + return narrowTypeByTypeof(type, right, operator, left, assumeTrue); } - if (isMatchingReference(reference, left_1)) { - return narrowTypeByEquality(type, operator_1, right_1, assumeTrue); + if (isMatchingReference(reference, left)) { + return narrowTypeByEquality(type, operator, right, assumeTrue); } - if (isMatchingReference(reference, right_1)) { - return narrowTypeByEquality(type, operator_1, left_1, assumeTrue); + if (isMatchingReference(reference, right)) { + return narrowTypeByEquality(type, operator, left, assumeTrue); } if (strictNullChecks) { - if (optionalChainContainsReference(left_1, reference)) { - type = narrowTypeByOptionalChainContainment(type, operator_1, right_1, assumeTrue); + if (optionalChainContainsReference(left, reference)) { + type = narrowTypeByOptionalChainContainment(type, operator, right, assumeTrue); } - else if (optionalChainContainsReference(right_1, reference)) { - type = narrowTypeByOptionalChainContainment(type, operator_1, left_1, assumeTrue); + else if (optionalChainContainsReference(right, reference)) { + type = narrowTypeByOptionalChainContainment(type, operator, left, assumeTrue); } } - if (isMatchingReferenceDiscriminant(left_1, type)) { - return narrowTypeByDiscriminant(type, left_1, function (t) { return narrowTypeByEquality(t, operator_1, right_1, assumeTrue); }); + if (isMatchingReferenceDiscriminant(left, type)) { + return narrowTypeByDiscriminantProperty(type, left, operator, right, assumeTrue); } - if (isMatchingReferenceDiscriminant(right_1, type)) { - return narrowTypeByDiscriminant(type, right_1, function (t) { return narrowTypeByEquality(t, operator_1, left_1, assumeTrue); }); + if (isMatchingReferenceDiscriminant(right, type)) { + return narrowTypeByDiscriminantProperty(type, right, operator, left, assumeTrue); } - if (isMatchingConstructorReference(left_1)) { - return narrowTypeByConstructor(type, operator_1, right_1, assumeTrue); + if (isMatchingConstructorReference(left)) { + return narrowTypeByConstructor(type, operator, right, assumeTrue); } - if (isMatchingConstructorReference(right_1)) { - return narrowTypeByConstructor(type, operator_1, left_1, assumeTrue); + if (isMatchingConstructorReference(right)) { + return narrowTypeByConstructor(type, operator, left, assumeTrue); } break; - case 101 /* InstanceOfKeyword */: + case 102 /* InstanceOfKeyword */: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 100 /* InKeyword */: + case 101 /* InKeyword */: var target = getReferenceCandidate(expr.right); - if (ts.isStringLiteralLike(expr.left) && isMatchingReference(reference, target)) { - return narrowByInKeyword(type, expr.left, assumeTrue); + if (ts.isStringLiteralLike(expr.left)) { + if (containsMissingType(type) && ts.isAccessExpression(reference) && isMatchingReference(reference.expression, target) && + getAccessedPropertyName(reference) === ts.escapeLeadingUnderscores(expr.left.text)) { + return getTypeWithFacts(type, assumeTrue ? 524288 /* NEUndefined */ : 65536 /* EQUndefined */); + } + if (isMatchingReference(reference, target)) { + return narrowByInKeyword(type, expr.left, assumeTrue); + } } break; case 27 /* CommaToken */: @@ -64368,13 +66757,12 @@ var ts; } if (assumeTrue) { var filterFn = operator === 34 /* EqualsEqualsToken */ ? - (function (t) { return areTypesComparable(t, valueType) || isCoercibleUnderDoubleEquals(t, valueType); }) : + function (t) { return areTypesComparable(t, valueType) || isCoercibleUnderDoubleEquals(t, valueType); } : function (t) { return areTypesComparable(t, valueType); }; return replacePrimitivesWithLiterals(filterType(type, filterFn), valueType); } if (isUnitType(valueType)) { - var regularType_1 = getRegularTypeOfLiteralType(valueType); - return filterType(type, function (t) { return isUnitType(t) ? !areTypesComparable(t, valueType) : getRegularTypeOfLiteralType(t) !== regularType_1; }); + return filterType(type, function (t) { return !(isUnitLikeType(t) && areTypesComparable(t, valueType)); }); } return type; } @@ -64396,7 +66784,7 @@ var ts; if (assumeTrue && type.flags & 2 /* Unknown */ && literal.text === "object") { // The pattern x && typeof x === 'object', where x is of type unknown, narrows x to type object. We don't // need to check for the reverse typeof x === 'object' && x since that already narrows correctly. - if (typeOfExpr.parent.parent.kind === 216 /* BinaryExpression */) { + if (typeOfExpr.parent.parent.kind === 218 /* BinaryExpression */) { var expr = typeOfExpr.parent.parent; if (expr.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && expr.right === typeOfExpr.parent && containsTruthyCheck(reference, expr.left)) { return nonPrimitiveType; @@ -64452,7 +66840,7 @@ var ts; if (!hasDefaultClause) { return caseType; } - var defaultType = filterType(type, function (t) { return !(isUnitType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(t))); }); + var defaultType = filterType(type, function (t) { return !(isUnitLikeType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(extractUnitType(t)))); }); return caseType.flags & 131072 /* Never */ ? defaultType : getUnionType([caseType, defaultType]); } function getImpliedTypeFromTypeofGuard(type, text) { @@ -64634,7 +67022,16 @@ var ts; } function getNarrowedType(type, candidate, assumeTrue, isRelated) { if (!assumeTrue) { - return filterType(type, function (t) { return !isRelated(t, candidate); }); + return filterType(type, function (t) { + if (!isRelated(t, candidate)) { + return true; + } + var constraint = getBaseConstraintOfType(t); + if (constraint && constraint !== t) { + return !isRelated(constraint, candidate); + } + return false; + }); } // 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. @@ -64644,10 +67041,15 @@ var ts; return assignableType; } } - // If the candidate type is a subtype of the target type, narrow to the candidate type, - // if the target type is a subtype of the candidate type, narrow to the target type, - // otherwise, narrow to an intersection of the two types. - return isTypeSubtypeOf(candidate, type) ? candidate : isTypeSubtypeOf(type, candidate) ? type : getIntersectionType([type, 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]); } function narrowTypeByCallExpression(type, callExpression, assumeTrue) { if (hasMatchingArgument(callExpression, reference)) { @@ -64657,6 +67059,16 @@ var ts; return narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue); } } + if (containsMissingType(type) && ts.isAccessExpression(reference) && ts.isPropertyAccessExpression(callExpression.expression)) { + var callAccess = callExpression.expression; + if (isMatchingReference(reference.expression, getReferenceCandidate(callAccess.expression)) && + 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 type; } function narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue) { @@ -64687,20 +67099,20 @@ var ts; return narrowTypeByOptionality(type, expr, assumeTrue); } switch (expr.kind) { - case 78 /* Identifier */: - case 107 /* ThisKeyword */: - case 105 /* SuperKeyword */: - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 79 /* Identifier */: + case 108 /* ThisKeyword */: + case 106 /* SuperKeyword */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return narrowTypeByCallExpression(type, expr, assumeTrue); - case 207 /* ParenthesizedExpression */: - case 225 /* NonNullExpression */: + case 209 /* ParenthesizedExpression */: + case 227 /* NonNullExpression */: return narrowType(type, expr.expression, assumeTrue); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: if (expr.operator === 53 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } @@ -64724,34 +67136,40 @@ 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 === 78 /* Identifier */) { + if (location.kind === 79 /* Identifier */ || location.kind === 80 /* PrivateIdentifier */) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } - if (ts.isExpressionNode(location) && !ts.isAssignmentTarget(location)) { + if (ts.isExpressionNode(location) && (!ts.isAssignmentTarget(location) || ts.isWriteAccess(location))) { var type = getTypeOfExpression(location); if (getExportSymbolOfValueSymbolIfExported(getNodeLinks(location).resolvedSymbol) === symbol) { return type; } } } + if (ts.isDeclarationName(location) && ts.isSetAccessor(location.parent) && getAnnotatedAccessorTypeNode(location.parent)) { + return resolveTypeOfAccessors(location.parent.symbol, /*writing*/ true); + } // The location isn't a reference to the given symbol, meaning we're being asked // a hypothetical question of what type the symbol would have if there was a reference // to it at the given location. Since we have no control flow information for the // hypothetical reference (control flow information is created and attached by the // binder), we simply return the declared type of the symbol. - return getTypeOfSymbol(symbol); + return getNonMissingTypeOfSymbol(symbol); } function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 257 /* ModuleBlock */ || - node.kind === 297 /* SourceFile */ || - node.kind === 163 /* PropertyDeclaration */; + node.kind === 259 /* ModuleBlock */ || + node.kind === 299 /* SourceFile */ || + node.kind === 165 /* PropertyDeclaration */; }); } // Check if a parameter is assigned anywhere within its declaring function. function isParameterAssigned(symbol) { + if (!symbol.valueDeclaration) { + return false; + } var func = ts.getRootDeclaration(symbol.valueDeclaration).parent; var links = getNodeLinks(func); if (!(links.flags & 8388608 /* AssignmentsMarked */)) { @@ -64766,10 +67184,10 @@ var ts; return !!ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !!(getNodeLinks(node).flags & 8388608 /* AssignmentsMarked */); }); } function markParameterAssignments(node) { - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 160 /* Parameter */) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 162 /* Parameter */) { symbol.isAssigned = true; } } @@ -64785,7 +67203,7 @@ var ts; function removeOptionalityFromDeclaredType(declaredType, declaration) { if (pushTypeResolution(declaration.symbol, 2 /* DeclaredType */)) { var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 160 /* Parameter */ && + declaration.kind === 162 /* Parameter */ && declaration.initializer && getFalsyFlags(declaredType) & 32768 /* Undefined */ && !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* Undefined */); @@ -64799,23 +67217,40 @@ var ts; } function isConstraintPosition(node) { var parent = node.parent; - return parent.kind === 201 /* PropertyAccessExpression */ || - parent.kind === 203 /* CallExpression */ && parent.expression === node || - parent.kind === 202 /* ElementAccessExpression */ && parent.expression === node || - parent.kind === 198 /* BindingElement */ && parent.name === node && !!parent.initializer; - } - function typeHasNullableConstraint(type) { - return type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 98304 /* Nullable */); - } - function getConstraintForLocation(type, node) { - // When a node is the left hand expression of a property access, element access, or call expression, - // and the type of the node includes type variables with constraints that are nullable, we fetch the - // apparent type of the node *before* performing control flow analysis such that narrowings apply to - // the constraint type. - if (type && isConstraintPosition(node) && forEachType(type, typeHasNullableConstraint)) { - return mapType(getWidenedType(type), getBaseConstraintOrType); - } - return type; + // In an element access obj[x], we consider obj to be in a constraint position only when x is not + // of 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 === 203 /* PropertyAccessExpression */ || + parent.kind === 205 /* CallExpression */ && parent.expression === node || + parent.kind === 204 /* ElementAccessExpression */ && parent.expression === node && + !isGenericIndexType(getTypeOfExpression(parent.argumentExpression)); + } + function isGenericTypeWithUnionConstraint(type) { + return !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */)); + } + function containsGenericType(type) { + return !!(type.flags & 465829888 /* Instantiable */ || type.flags & 3145728 /* UnionOrIntersection */ && ts.some(type.types, containsGenericType)); + } + function hasNonBindingPatternContextualTypeWithNoGenericTypes(node) { + // Computing the contextual type for a child of a JSX element involves resolving the type of the + // element's tag name, so we exclude that here to avoid circularities. + var contextualType = (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) && + !((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && + getContextualType(node, 8 /* SkipBindingPatterns */); + return contextualType && !someType(contextualType, containsGenericType); + } + function getNarrowableTypeForReference(type, reference, checkMode) { + // When the type of a reference is or contains an instantiable type with a union type constraint, and + // when the reference is in a constraint position (where it is known we'll obtain the apparent type) or + // has a contextual type containing no top-level instantiables (meaning constraints will determine + // assignability), we substitute constraints for all instantiables in the type of the reference to give + // 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 */) && + someType(type, isGenericTypeWithUnionConstraint) && + (isConstraintPosition(reference) || hasNonBindingPatternContextualTypeWithNoGenericTypes(reference)); + return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type; } function isExportOrExportExpression(location) { return !!ts.findAncestor(location, function (e) { return e.parent && ts.isExportAssignment(e.parent) && e.parent.expression === e && ts.isEntityNameExpression(e); }); @@ -64824,7 +67259,12 @@ var ts; if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) { var target = resolveAlias(symbol); if (target.flags & 111551 /* Value */) { - if (compilerOptions.preserveConstEnums && isExportOrExportExpression(location) || !isConstEnumOrConstEnumOnlyModule(target)) { + // 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. + if (compilerOptions.isolatedModules || + ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(location) || + !isConstEnumOrConstEnumOnlyModule(target)) { markAliasSymbolAsReferenced(symbol); } else { @@ -64833,7 +67273,7 @@ var ts; } } } - function checkIdentifier(node) { + function checkIdentifier(node, checkMode) { var symbol = getResolvedSymbol(node); if (symbol === unknownSymbol) { return errorType; @@ -64847,7 +67287,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 209 /* ArrowFunction */) { + if (container.kind === 211 /* 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 */)) { @@ -64864,15 +67304,15 @@ var ts; } var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); var sourceSymbol = localOrExportSymbol.flags & 2097152 /* Alias */ ? resolveAlias(localOrExportSymbol) : localOrExportSymbol; - if (getDeclarationNodeFlagsFromSymbol(sourceSymbol) & 134217728 /* Deprecated */ && isUncalledFunctionReference(node, sourceSymbol)) { - errorOrSuggestion(/* isError */ false, node, ts.Diagnostics._0_is_deprecated, node.escapedText); + if (sourceSymbol.declarations && getDeclarationNodeFlagsFromSymbol(sourceSymbol) & 134217728 /* Deprecated */ && isUncalledFunctionReference(node, sourceSymbol)) { + addDeprecatedSuggestion(node, sourceSymbol.declarations, node.escapedText); } var declaration = localOrExportSymbol.valueDeclaration; - if (localOrExportSymbol.flags & 32 /* Class */) { + if (declaration && localOrExportSymbol.flags & 32 /* 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 === 252 /* ClassDeclaration */ + if (declaration.kind === 254 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -64884,14 +67324,14 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 221 /* ClassExpression */) { + else if (declaration.kind === 223 /* 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 !== 297 /* SourceFile */) { + while (container.kind !== 299 /* SourceFile */) { if (container.parent === declaration) { - if (container.kind === 163 /* PropertyDeclaration */ && ts.hasSyntacticModifier(container, 32 /* Static */)) { + if (container.kind === 165 /* PropertyDeclaration */ && ts.hasSyntacticModifier(container, 32 /* Static */)) { getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; } @@ -64902,12 +67342,18 @@ var ts; } } checkNestedBlockScopedBinding(node, symbol); - var type = getConstraintForLocation(getTypeOfSymbol(localOrExportSymbol), node); + var type = getTypeOfSymbol(localOrExportSymbol); var assignmentKind = ts.getAssignmentTargetKind(node); if (assignmentKind) { if (!(localOrExportSymbol.flags & 3 /* Variable */) && !(ts.isInJSFile(node) && localOrExportSymbol.flags & 512 /* ValueModule */)) { - error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_not_a_variable, symbolToString(symbol)); + 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 + : ts.Diagnostics.Cannot_assign_to_0_because_it_is_not_a_variable; + error(node, assignmentError, symbolToString(symbol)); return errorType; } if (isReadonlySymbol(localOrExportSymbol)) { @@ -64929,7 +67375,7 @@ var ts; } } else if (isAlias) { - declaration = ts.find(symbol.declarations, isSomeImportDeclaration); + declaration = getDeclarationOfAliasSymbol(symbol); } else { return type; @@ -64937,10 +67383,11 @@ var ts; if (!declaration) { return type; } + type = getNarrowableTypeForReference(type, node, checkMode); // 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 === 160 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 162 /* Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; @@ -64949,8 +67396,8 @@ var ts; // 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 === 208 /* FunctionExpression */ || - flowContainer.kind === 209 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 210 /* FunctionExpression */ || + flowContainer.kind === 211 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -64959,9 +67406,9 @@ var ts; // 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 === 270 /* ExportSpecifier */) || - node.parent.kind === 225 /* NonNullExpression */ || - declaration.kind === 249 /* VariableDeclaration */ && declaration.exclamationToken || + isInTypeQuery(node) || node.parent.kind === 272 /* ExportSpecifier */) || + node.parent.kind === 227 /* NonNullExpression */ || + declaration.kind === 251 /* VariableDeclaration */ && declaration.exclamationToken || declaration.flags & 8388608 /* Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : @@ -64986,17 +67433,21 @@ var ts; } return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } - function isInsideFunction(node, threshold) { - return !!ts.findAncestor(node, function (n) { return n === threshold ? "quit" : ts.isFunctionLike(n); }); + 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); }); } function getPartOfForStatementContainingNode(node, container) { return ts.findAncestor(node, function (n) { return n === container ? "quit" : n === container.initializer || n === container.condition || n === container.incrementor || n === container.statement; }); } + function getEnclosingIterationStatement(node) { + 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 || + !symbol.valueDeclaration || ts.isSourceFile(symbol.valueDeclaration) || - symbol.valueDeclaration.parent.kind === 287 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 289 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -65004,22 +67455,14 @@ var ts; // 2. walk from the declaration up to the boundary of lexical environment and check // if there is an iteration statement in between declaration and boundary (is binding/class declared inside iteration statement) var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); - var usedInFunction = isInsideFunction(node.parent, container); - var current = container; - var containedInIterationStatement = false; - while (current && !ts.nodeStartsNewLexicalEnvironment(current)) { - if (ts.isIterationStatement(current, /*lookInLabeledStatements*/ false)) { - containedInIterationStatement = true; - break; - } - current = current.parent; - } - if (containedInIterationStatement) { - if (usedInFunction) { + var isCaptured = isInsideFunctionOrInstancePropertyInitializer(node, container); + var enclosingIterationStatement = getEnclosingIterationStatement(container); + if (enclosingIterationStatement) { + if (isCaptured) { // 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, 250 /* VariableDeclarationList */); + var varDeclList = ts.getAncestor(symbol.valueDeclaration, 252 /* VariableDeclarationList */); if (varDeclList && varDeclList.parent === container) { var part = getPartOfForStatementContainingNode(node.parent, container); if (part) { @@ -65034,13 +67477,13 @@ var ts; } } if (capturesBlockScopeBindingInLoopBody) { - getNodeLinks(current).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */; + getNodeLinks(enclosingIterationStatement).flags |= 65536 /* 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, 250 /* VariableDeclarationList */); + var varDeclList = ts.getAncestor(symbol.valueDeclaration, 252 /* VariableDeclarationList */); if (varDeclList && varDeclList.parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NeedsLoopOutParameter */; } @@ -65048,7 +67491,7 @@ var ts; // set 'declared inside loop' bit on the block-scoped binding getNodeLinks(symbol.valueDeclaration).flags |= 524288 /* BlockScopedBindingInLoop */; } - if (usedInFunction) { + if (isCaptured) { getNodeLinks(symbol.valueDeclaration).flags |= 262144 /* CapturedBlockScopedBinding */; } } @@ -65059,7 +67502,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 207 /* ParenthesizedExpression */) { + while (current.parent.kind === 209 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -65067,7 +67510,7 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 214 /* PrefixUnaryExpression */ || current.parent.kind === 215 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 216 /* PrefixUnaryExpression */ || current.parent.kind === 217 /* PostfixUnaryExpression */)) { var expr = current.parent; isAssigned = expr.operator === 45 /* PlusPlusToken */ || expr.operator === 46 /* MinusMinusToken */; } @@ -65080,7 +67523,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 163 /* PropertyDeclaration */ || container.kind === 166 /* Constructor */) { + if (container.kind === 165 /* PropertyDeclaration */ || container.kind === 168 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -65120,37 +67563,37 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var capturedByArrowFunction = false; - if (container.kind === 166 /* Constructor */) { + if (container.kind === 168 /* 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 === 209 /* ArrowFunction */) { + if (container.kind === 211 /* ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); capturedByArrowFunction = true; } switch (container.kind) { - case 256 /* ModuleDeclaration */: + case 258 /* 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 255 /* EnumDeclaration */: + case 257 /* 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 166 /* Constructor */: + case 168 /* 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 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - if (ts.hasSyntacticModifier(container, 32 /* Static */) && !(compilerOptions.target === 99 /* ESNext */ && compilerOptions.useDefineForClassFields)) { + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + if (ts.hasSyntacticModifier(container, 32 /* Static */) && !(compilerOptions.target === 99 /* ESNext */ && useDefineForClassFields)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } break; - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -65238,7 +67681,7 @@ var ts; } function getClassNameFromPrototypeMethod(container) { // Check if it's the RHS of a x.prototype.y = function [name]() { .... } - if (container.kind === 208 /* FunctionExpression */ && + if (container.kind === 210 /* FunctionExpression */ && ts.isBinaryExpression(container.parent) && ts.getAssignmentDeclarationKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = container' @@ -65248,16 +67691,16 @@ var ts; .expression; // x } // x.prototype = { method() { } } - else if (container.kind === 165 /* MethodDeclaration */ && - container.parent.kind === 200 /* ObjectLiteralExpression */ && + else if (container.kind === 167 /* MethodDeclaration */ && + container.parent.kind === 202 /* ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent) === 6 /* Prototype */) { return container.parent.parent.left.expression; } // x.prototype = { method: function() { } } - else if (container.kind === 208 /* FunctionExpression */ && - container.parent.kind === 288 /* PropertyAssignment */ && - container.parent.parent.kind === 200 /* ObjectLiteralExpression */ && + else if (container.kind === 210 /* FunctionExpression */ && + container.parent.kind === 290 /* PropertyAssignment */ && + container.parent.parent.kind === 202 /* ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* Prototype */) { return container.parent.parent.parent.left.expression; @@ -65265,7 +67708,7 @@ var ts; // Object.defineProperty(x, "method", { value: function() { } }); // Object.defineProperty(x, "method", { set: (x: () => void) => void }); // Object.defineProperty(x, "method", { get: () => function() { }) }); - else if (container.kind === 208 /* FunctionExpression */ && + else if (container.kind === 210 /* 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") && @@ -65290,7 +67733,7 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 308 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 311 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -65304,16 +67747,16 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 160 /* Parameter */ && n.parent === constructorDecl; }); + return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 162 /* Parameter */ && n.parent === constructorDecl; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 203 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 205 /* 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 === 209 /* ArrowFunction */) { + while (container && container.kind === 211 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -65326,14 +67769,14 @@ var ts; // class B { // [super.foo()]() {} // } - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 158 /* ComputedPropertyName */; }); - if (current && current.kind === 158 /* ComputedPropertyName */) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 160 /* ComputedPropertyName */; }); + if (current && current.kind === 160 /* 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 === 200 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 202 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -65341,7 +67784,7 @@ var ts; } return errorType; } - if (!isCallExpression && immediateContainer.kind === 166 /* Constructor */) { + if (!isCallExpression && immediateContainer.kind === 168 /* 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.hasSyntacticModifier(container, 32 /* Static */) || isCallExpression) { @@ -65410,7 +67853,7 @@ 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 === 165 /* MethodDeclaration */ && ts.hasSyntacticModifier(container, 256 /* Async */)) { + if (container.kind === 167 /* MethodDeclaration */ && ts.hasSyntacticModifier(container, 256 /* Async */)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; } @@ -65424,7 +67867,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 200 /* ObjectLiteralExpression */) { + if (container.parent.kind === 202 /* ObjectLiteralExpression */) { if (languageVersion < 2 /* ES2015 */) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return errorType; @@ -65445,7 +67888,7 @@ var ts; if (!baseClassType) { return errorType; } - if (container.kind === 166 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 168 /* 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; @@ -65460,7 +67903,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 === 166 /* Constructor */; + return container.kind === 168 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -65468,21 +67911,21 @@ 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 === 200 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 202 /* ObjectLiteralExpression */) { if (ts.hasSyntacticModifier(container, 32 /* Static */)) { - return container.kind === 165 /* MethodDeclaration */ || - container.kind === 164 /* MethodSignature */ || - container.kind === 167 /* GetAccessor */ || - container.kind === 168 /* SetAccessor */; + return container.kind === 167 /* MethodDeclaration */ || + container.kind === 166 /* MethodSignature */ || + container.kind === 169 /* GetAccessor */ || + container.kind === 170 /* SetAccessor */; } else { - return container.kind === 165 /* MethodDeclaration */ || - container.kind === 164 /* MethodSignature */ || - container.kind === 167 /* GetAccessor */ || - container.kind === 168 /* SetAccessor */ || - container.kind === 163 /* PropertyDeclaration */ || - container.kind === 162 /* PropertySignature */ || - container.kind === 166 /* Constructor */; + return container.kind === 167 /* MethodDeclaration */ || + container.kind === 166 /* MethodSignature */ || + container.kind === 169 /* GetAccessor */ || + container.kind === 170 /* SetAccessor */ || + container.kind === 165 /* PropertyDeclaration */ || + container.kind === 164 /* PropertySignature */ || + container.kind === 168 /* Constructor */; } } } @@ -65490,10 +67933,10 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 165 /* MethodDeclaration */ || - func.kind === 167 /* GetAccessor */ || - func.kind === 168 /* SetAccessor */) && func.parent.kind === 200 /* ObjectLiteralExpression */ ? func.parent : - func.kind === 208 /* FunctionExpression */ && func.parent.kind === 288 /* PropertyAssignment */ ? func.parent.parent : + return (func.kind === 167 /* MethodDeclaration */ || + func.kind === 169 /* GetAccessor */ || + func.kind === 170 /* SetAccessor */) && func.parent.kind === 202 /* ObjectLiteralExpression */ ? func.parent : + func.kind === 210 /* FunctionExpression */ && func.parent.kind === 290 /* PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { @@ -65505,7 +67948,7 @@ var ts; }); } function getContextualThisParameterType(func) { - if (func.kind === 209 /* ArrowFunction */) { + if (func.kind === 211 /* ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -65532,7 +67975,7 @@ var ts; if (thisType) { return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral))); } - if (literal.parent.kind !== 288 /* PropertyAssignment */) { + if (literal.parent.kind !== 290 /* PropertyAssignment */) { break; } literal = literal.parent.parent; @@ -65546,7 +67989,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 === 216 /* BinaryExpression */ && parent.operatorToken.kind === 62 /* EqualsToken */) { + if (parent.kind === 218 /* BinaryExpression */ && parent.operatorToken.kind === 63 /* EqualsToken */) { var target = parent.left; if (ts.isAccessExpression(target)) { var expression = target.expression; @@ -65599,11 +68042,11 @@ var ts; return getTypeFromTypeNode(typeNode); } switch (declaration.kind) { - case 160 /* Parameter */: + case 162 /* Parameter */: return getContextuallyTypedParameterType(declaration); - case 198 /* BindingElement */: + case 200 /* BindingElement */: return getContextualTypeForBindingElement(declaration); - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: if (ts.hasSyntacticModifier(declaration, 32 /* Static */)) { return getContextualTypeForStaticPropertyDeclaration(declaration); } @@ -65614,10 +68057,10 @@ var ts; var parent = declaration.parent.parent; var name = declaration.propertyName || declaration.name; var parentType = getContextualTypeForVariableLikeDeclaration(parent) || - parent.kind !== 198 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent); + parent.kind !== 200 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent); if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name)) return undefined; - if (parent.name.kind === 197 /* ArrayBindingPattern */) { + if (parent.name.kind === 199 /* ArrayBindingPattern */) { var index = ts.indexOfNode(declaration.parent.elements, declaration); if (index < 0) return undefined; @@ -65751,10 +68194,13 @@ var ts; if (ts.isJsxOpeningLikeElement(callTarget) && argIndex === 0) { return getEffectiveFirstArgumentForJsxSignature(signature, callTarget); } - return getTypeAtPosition(signature, argIndex); + var restIndex = signature.parameters.length - 1; + return signatureHasRestParameter(signature) && argIndex >= restIndex ? + getIndexedAccessType(getTypeOfSymbol(signature.parameters[restIndex]), getLiteralType(argIndex - restIndex), 256 /* Contextual */) : + getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 205 /* TaggedTemplateExpression */) { + if (template.parent.kind === 207 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -65763,10 +68209,10 @@ var ts; var binaryExpression = node.parent; var left = binaryExpression.left, operatorToken = binaryExpression.operatorToken, right = binaryExpression.right; switch (operatorToken.kind) { - case 62 /* EqualsToken */: - case 75 /* AmpersandAmpersandEqualsToken */: - case 74 /* BarBarEqualsToken */: - case 76 /* QuestionQuestionEqualsToken */: + case 63 /* EqualsToken */: + case 76 /* AmpersandAmpersandEqualsToken */: + case 75 /* BarBarEqualsToken */: + case 77 /* QuestionQuestionEqualsToken */: return node === right ? getContextualTypeForAssignmentDeclaration(binaryExpression) : undefined; case 56 /* BarBarToken */: case 60 /* QuestionQuestionToken */: @@ -65788,16 +68234,16 @@ var ts; // In an assignment expression, the right operand is contextually typed by the type of the left operand. // Don't do this for assignment declarations unless there is a type tag on the assignment, to avoid circularity from checking the right operand. function getContextualTypeForAssignmentDeclaration(binaryExpression) { + var _a, _b; var kind = ts.getAssignmentDeclarationKind(binaryExpression); switch (kind) { case 0 /* None */: return getTypeOfExpression(binaryExpression.left); + case 4 /* ThisProperty */: + return getContextualTypeForThisPropertyAssignment(binaryExpression); case 5 /* Property */: - case 1 /* ExportsProperty */: - case 6 /* Prototype */: - case 3 /* PrototypeProperty */: if (isPossiblyAliasedThisProperty(binaryExpression, kind)) { - return getContextualTypeForThisPropertyAssignment(binaryExpression, kind); + return getContextualTypeForThisPropertyAssignment(binaryExpression); } // If `binaryExpression.left` was assigned a symbol, then this is a new declaration; otherwise it is an assignment to an existing declaration. // See `bindStaticPropertyAssignment` in `binder.ts`. @@ -65818,11 +68264,11 @@ var ts; var id = lhs.expression; var parentSymbol = resolveName(id, id.escapedText, 111551 /* Value */, undefined, id.escapedText, /*isUse*/ true); if (parentSymbol) { - var annotated = parentSymbol.valueDeclaration && ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration); - if (annotated) { + var annotated_1 = parentSymbol.valueDeclaration && ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration); + if (annotated_1) { var nameStr = ts.getElementOrPropertyAccessName(lhs); if (nameStr !== undefined) { - return getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated), nameStr); + return getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated_1), nameStr); } } return undefined; @@ -65830,9 +68276,15 @@ var ts; } return ts.isInJSFile(decl) ? undefined : getTypeOfExpression(binaryExpression.left); } + case 1 /* ExportsProperty */: + case 6 /* Prototype */: + case 3 /* PrototypeProperty */: + var valueDeclaration = (_a = binaryExpression.left.symbol) === null || _a === void 0 ? void 0 : _a.valueDeclaration; + // falls through case 2 /* ModuleExports */: - case 4 /* ThisProperty */: - return getContextualTypeForThisPropertyAssignment(binaryExpression, kind); + 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 */: @@ -65853,7 +68305,7 @@ var ts; var symbol = resolveName(declaration.left, name, 111551 /* Value */, undefined, undefined, /*isUse*/ true, /*excludeGlobals*/ true); return ts.isThisInitializedDeclaration(symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration); } - function getContextualTypeForThisPropertyAssignment(binaryExpression, kind) { + function getContextualTypeForThisPropertyAssignment(binaryExpression) { if (!binaryExpression.symbol) return getTypeOfExpression(binaryExpression.left); if (binaryExpression.symbol.valueDeclaration) { @@ -65865,8 +68317,6 @@ var ts; } } } - if (kind === 2 /* ModuleExports */) - return undefined; var thisAccess = ts.cast(binaryExpression.left, ts.isAccessExpression); if (!ts.isObjectLiteralMethod(ts.getThisContainer(thisAccess.expression, /*includeArrowFunctions*/ false))) { return undefined; @@ -65921,9 +68371,13 @@ var ts; } function getContextualTypeForObjectLiteralElement(element, contextFlags) { var objectLiteral = element.parent; + var propertyAssignmentType = ts.isPropertyAssignment(element) && getContextualTypeForVariableLikeDeclaration(element); + if (propertyAssignmentType) { + return propertyAssignmentType; + } var type = getApparentTypeOfContextualType(objectLiteral, contextFlags); if (type) { - if (!hasNonBindableDynamicName(element)) { + if (hasBindableName(element)) { // For a (non-symbol) computed property, there is no reason to look up the name // in the type. It will just be "__computed", which does not appear in any // SymbolTable. @@ -66003,25 +68457,25 @@ var ts; case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: - case 103 /* NullKeyword */: - case 78 /* Identifier */: - case 150 /* UndefinedKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: + case 104 /* NullKeyword */: + case 79 /* Identifier */: + case 151 /* UndefinedKeyword */: return true; - case 201 /* PropertyAccessExpression */: - case 207 /* ParenthesizedExpression */: + case 203 /* PropertyAccessExpression */: + case 209 /* ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: return !node.expression || isPossiblyDiscriminantValue(node.expression); } return false; } function discriminateContextualTypeByObjectMembers(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 288 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); + return getMatchingUnionConstituentForObjectLiteral(contextualType, node) || discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 290 /* 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); } function discriminateContextualTypeByJSXAttributes(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 280 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return checkExpression(prop.initializer); }), prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 282 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return checkExpression(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 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. @@ -66032,15 +68486,9 @@ var ts; var instantiatedType = instantiateContextualType(contextualType, node, contextFlags); if (instantiatedType && !(contextFlags && contextFlags & 2 /* NoConstraints */ && instantiatedType.flags & 8650752 /* TypeVariable */)) { var apparentType = mapType(instantiatedType, getApparentType, /*noReductions*/ true); - if (apparentType.flags & 1048576 /* Union */) { - if (ts.isObjectLiteralExpression(node)) { - return discriminateContextualTypeByObjectMembers(node, apparentType); - } - else if (ts.isJsxAttributes(node)) { - return discriminateContextualTypeByJSXAttributes(node, apparentType); - } - } - return apparentType; + return apparentType.flags & 1048576 /* Union */ && ts.isObjectLiteralExpression(node) ? discriminateContextualTypeByObjectMembers(node, apparentType) : + apparentType.flags & 1048576 /* Union */ && ts.isJsxAttributes(node) ? discriminateContextualTypeByJSXAttributes(node, apparentType) : + apparentType; } } // If the given contextual type contains instantiable types and if a mapper representing @@ -66107,58 +68555,60 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 249 /* VariableDeclaration */: - case 160 /* Parameter */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 198 /* BindingElement */: + case 251 /* VariableDeclaration */: + case 162 /* Parameter */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 200 /* BindingElement */: return getContextualTypeForInitializerExpression(node, contextFlags); - case 209 /* ArrowFunction */: - case 242 /* ReturnStatement */: + case 211 /* ArrowFunction */: + case 244 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 213 /* AwaitExpression */: + case 215 /* AwaitExpression */: return getContextualTypeForAwaitOperand(parent, contextFlags); - case 203 /* CallExpression */: - if (parent.expression.kind === 99 /* ImportKeyword */) { + case 205 /* CallExpression */: + if (parent.expression.kind === 100 /* ImportKeyword */) { return stringType; } /* falls through */ - case 204 /* NewExpression */: + case 206 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 206 /* TypeAssertionExpression */: - case 224 /* AsExpression */: + case 208 /* TypeAssertionExpression */: + case 226 /* AsExpression */: return ts.isConstTypeReference(parent.type) ? tryFindWhenConstTypeReference(parent) : getTypeFromTypeNode(parent.type); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node, contextFlags); - case 288 /* PropertyAssignment */: - case 289 /* ShorthandPropertyAssignment */: + case 290 /* PropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent, contextFlags); - case 290 /* SpreadAssignment */: - return getApparentTypeOfContextualType(parent.parent, contextFlags); - case 199 /* ArrayLiteralExpression */: { + case 292 /* SpreadAssignment */: + return getContextualType(parent.parent, contextFlags); + case 201 /* ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral, contextFlags); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node, contextFlags); - case 228 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 218 /* TemplateExpression */); + case 230 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 220 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 207 /* ParenthesizedExpression */: { + case 209 /* 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 ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent, contextFlags); } - case 283 /* JsxExpression */: + case 227 /* NonNullExpression */: + return getContextualType(parent, contextFlags); + case 285 /* JsxExpression */: return getContextualTypeForJsxExpression(parent); - case 280 /* JsxAttribute */: - case 282 /* JsxSpreadAttribute */: + case 282 /* JsxAttribute */: + case 284 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 275 /* JsxOpeningElement */: - case 274 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent, contextFlags); } return undefined; @@ -66194,14 +68644,14 @@ var ts; return propsType; } function getJsxPropsTypeForSignatureFromMember(sig, forcedLookupLocation) { - if (sig.unionSignatures) { + if (sig.compositeSignatures) { // JSX Elements using the legacy `props`-field based lookup (eg, react class components) need to treat the `props` member as an input // instead of an output position when resolving the signature. We need to go back to the input signatures of the composite signature, // get the type of `props` on each return type individually, and then _intersect them_, rather than union them (as would normally occur // for a union signature). It's an unfortunate quirk of looking in the output of the signature for the type we want to use for the input. // The default behavior of `getTypeOfFirstParameterOfSignatureWithFallback` when no `props` member name is defined is much more sane. var results = []; - for (var _i = 0, _a = sig.unionSignatures; _i < _a.length; _i++) { + for (var _i = 0, _a = sig.compositeSignatures; _i < _a.length; _i++) { var signature = _a[_i]; var instance = getReturnTypeOfSignature(signature); if (isTypeAny(instance)) { @@ -66213,7 +68663,7 @@ var ts; } results.push(propType); } - return getIntersectionType(results); + return getIntersectionType(results); // Same result for both union and intersection signatures } var instanceType = getReturnTypeOfSignature(sig); return isTypeAny(instanceType) ? instanceType : getTypeOfPropertyOfType(instanceType, forcedLookupLocation); @@ -66238,16 +68688,19 @@ var ts; function getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType) { var managedSym = getJsxLibraryManagedAttributes(ns); if (managedSym) { - var declaredManagedType = getDeclaredTypeOfSymbol(managedSym); + var declaredManagedType = getDeclaredTypeOfSymbol(managedSym); // fetches interface type, or initializes symbol links type parmaeters var ctorType = getStaticTypeOfReferencedJsxConstructor(context); + if (managedSym.flags & 524288 /* TypeAlias */) { + var params = getSymbolLinks(managedSym).typeParameters; + if (ts.length(params) >= 2) { + var args = fillMissingTypeArguments([ctorType, attributesType], params, 2, ts.isInJSFile(context)); + return getTypeAliasInstantiation(managedSym, args); + } + } if (ts.length(declaredManagedType.typeParameters) >= 2) { var args = fillMissingTypeArguments([ctorType, attributesType], declaredManagedType.typeParameters, 2, ts.isInJSFile(context)); return createTypeReference(declaredManagedType, args); } - else if (ts.length(declaredManagedType.aliasTypeArguments) >= 2) { - var args = fillMissingTypeArguments([ctorType, attributesType], declaredManagedType.aliasTypeArguments, 2, ts.isInJSFile(context)); - return getTypeAliasInstantiation(declaredManagedType.aliasSymbol, args); - } } return attributesType; } @@ -66292,16 +68745,93 @@ var ts; return apparentAttributesType; } } + function getIntersectedSignatures(signatures) { + return ts.getStrictOptionValue(compilerOptions, "noImplicitAny") + ? ts.reduceLeft(signatures, function (left, right) { + return left === right || !left ? left + : compareTypeParametersIdentical(left.typeParameters, right.typeParameters) ? combineSignaturesOfIntersectionMembers(left, right) + : undefined; + }) + : undefined; + } + function combineIntersectionThisParam(left, right, mapper) { + if (!left || !right) { + return left || right; + } + // A signature `this` type might be a read or a write position... It's very possible that it should be invariant + // and we should refuse to merge signatures if there are `this` types and they do not match. However, so as to be + // pessimistic when contextual typing, for now, we'll union the `this` types. + var thisType = getUnionType([getTypeOfSymbol(left), instantiateType(getTypeOfSymbol(right), mapper)]); + return createSymbolWithType(left, thisType); + } + function combineIntersectionParameters(left, right, mapper) { + var leftCount = getParameterCount(left); + var rightCount = getParameterCount(right); + var longest = leftCount >= rightCount ? left : right; + var shorter = longest === left ? right : left; + var longestCount = longest === left ? leftCount : rightCount; + var eitherHasEffectiveRest = (hasEffectiveRestParameter(left) || hasEffectiveRestParameter(right)); + var needsExtraRestElement = eitherHasEffectiveRest && !hasEffectiveRestParameter(longest); + var params = new Array(longestCount + (needsExtraRestElement ? 1 : 0)); + for (var i = 0; i < longestCount; i++) { + var longestParamType = tryGetTypeAtPosition(longest, i); + if (longest === right) { + longestParamType = instantiateType(longestParamType, mapper); + } + var shorterParamType = tryGetTypeAtPosition(shorter, i) || unknownType; + if (shorter === right) { + shorterParamType = instantiateType(shorterParamType, mapper); + } + var unionParamType = getUnionType([longestParamType, shorterParamType]); + var isRestParam = eitherHasEffectiveRest && !needsExtraRestElement && i === (longestCount - 1); + var isOptional = i >= getMinArgumentCount(longest) && i >= getMinArgumentCount(shorter); + var leftName = i >= leftCount ? undefined : getParameterNameAtPosition(left, i); + var rightName = i >= rightCount ? undefined : getParameterNameAtPosition(right, i); + var paramName = leftName === rightName ? leftName : + !leftName ? rightName : + !rightName ? leftName : + undefined; + var paramSymbol = createSymbol(1 /* FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* Optional */ : 0), paramName || "arg" + i); + paramSymbol.type = isRestParam ? createArrayType(unionParamType) : unionParamType; + params[i] = paramSymbol; + } + if (needsExtraRestElement) { + var restParamSymbol = createSymbol(1 /* FunctionScopedVariable */, "args"); + restParamSymbol.type = createArrayType(getTypeAtPosition(shorter, longestCount)); + if (shorter === right) { + restParamSymbol.type = instantiateType(restParamSymbol.type, mapper); + } + params[longestCount] = restParamSymbol; + } + return params; + } + function combineSignaturesOfIntersectionMembers(left, right) { + var typeParams = left.typeParameters || right.typeParameters; + var paramMapper; + if (left.typeParameters && right.typeParameters) { + paramMapper = createTypeMapper(right.typeParameters, left.typeParameters); + // We just use the type parameter defaults from the first signature + } + var declaration = left.declaration; + var params = combineIntersectionParameters(left, right, paramMapper); + var thisParam = combineIntersectionThisParam(left.thisParameter, right.thisParameter, paramMapper); + 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]); + if (paramMapper) { + result.mapper = left.compositeKind === 2097152 /* 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 */); - if (signatures.length === 1) { - var signature = signatures[0]; - if (!isAritySmaller(signature, node)) { - return signature; - } - } + var applicableByArity = ts.filter(signatures, function (s) { return !isAritySmaller(s, node); }); + return applicableByArity.length === 1 ? applicableByArity[0] : getIntersectedSignatures(applicableByArity); } /** If the contextual signature has fewer parameters than the function expression, do not use it */ function isAritySmaller(signature, target) { @@ -66318,7 +68848,7 @@ var ts; return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 208 /* FunctionExpression */ || node.kind === 209 /* ArrowFunction */; + return node.kind === 210 /* FunctionExpression */ || node.kind === 211 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -66332,7 +68862,7 @@ 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 !== 165 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 167 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var typeTagSignature = getSignatureOfTypeTag(node); if (typeTagSignature) { return typeTagSignature; @@ -66380,8 +68910,8 @@ var ts; return node.isSpread ? getIndexedAccessType(node.type, numberType) : node.type; } function hasDefaultValue(node) { - return (node.kind === 198 /* BindingElement */ && !!node.initializer) || - (node.kind === 216 /* BinaryExpression */ && node.operatorToken.kind === 62 /* EqualsToken */); + return (node.kind === 200 /* BindingElement */ && !!node.initializer) || + (node.kind === 218 /* BinaryExpression */ && node.operatorToken.kind === 63 /* EqualsToken */); } function checkArrayLiteral(node, checkMode, forceTuple) { var elements = node.elements; @@ -66391,9 +68921,10 @@ var ts; var contextualType = getApparentTypeOfContextualType(node); 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 === 220 /* SpreadElement */) { + if (e.kind === 222 /* SpreadElement */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(e, compilerOptions.downlevelIteration ? 1536 /* SpreadIncludes */ : 1024 /* SpreadArray */); } @@ -66426,17 +68957,22 @@ var ts; elementFlags.push(4 /* Rest */); } } + else if (strictOptionalProperties && e.kind === 224 /* OmittedExpression */) { + hasOmittedExpression = true; + elementTypes.push(missingType); + elementFlags.push(2 /* Optional */); + } else { var elementContextualType = getContextualTypeForElementExpression(contextualType, elementTypes.length); var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple); - elementTypes.push(type); - elementFlags.push(1 /* Required */); + elementTypes.push(addOptionality(type, /*isProperty*/ true, hasOmittedExpression)); + elementFlags.push(hasOmittedExpression ? 2 /* Optional */ : 1 /* Required */); } } if (inDestructuringPattern) { return createTupleType(elementTypes, elementFlags); } - if (forceTuple || inConstContext || contextualType && forEachType(contextualType, isTupleLikeType)) { + if (forceTuple || inConstContext || contextualType && someType(contextualType, isTupleLikeType)) { return createArrayLiteralType(createTupleType(elementTypes, elementFlags, /*readonly*/ inConstContext)); } return createArrayLiteralType(createArrayType(elementTypes.length ? @@ -66450,15 +68986,15 @@ var ts; var literalType = type.literalType; if (!literalType) { literalType = type.literalType = cloneTypeReference(type); - literalType.objectFlags |= 65536 /* ArrayLiteral */ | 1048576 /* ContainsObjectOrArrayLiteral */; + literalType.objectFlags |= 32768 /* ArrayLiteral */ | 262144 /* ContainsObjectOrArrayLiteral */; } return literalType; } function isNumericName(name) { switch (name.kind) { - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return isNumericComputedName(name); - case 78 /* Identifier */: + case 79 /* Identifier */: return isNumericLiteralName(name.escapedText); case 8 /* NumericLiteral */: case 10 /* StringLiteral */: @@ -66503,6 +69039,20 @@ var ts; var links = getNodeLinks(node.expression); if (!links.resolvedType) { links.resolvedType = checkExpression(node.expression); + // The computed property name of a non-static class field within a loop must be stored in a block-scoped binding. + // (It needs to be bound at class evaluation time.) + if (ts.isPropertyDeclaration(node.parent) && !ts.hasStaticModifier(node.parent) && ts.isClassExpression(node.parent.parent)) { + var container = ts.getEnclosingBlockScopeContainer(node.parent.parent); + 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 */; + // The generated variable which stores the computed field name must be block-scoped. + getNodeLinks(node).flags |= 524288 /* BlockScopedBindingInLoop */; + // The generated variable which stores the class must be block-scoped. + getNodeLinks(node.parent.parent).flags |= 524288 /* 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 */ || @@ -66510,9 +69060,6 @@ var ts; !isTypeAssignableTo(links.resolvedType, stringNumberSymbolType)) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } - else { - checkThatExpressionIsProperSymbolReference(node.expression, links.resolvedType, /*reportError*/ true); - } } return links.resolvedType; } @@ -66552,7 +69099,7 @@ var ts; var spread = emptyObjectType; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 196 /* ObjectBindingPattern */ || contextualType.pattern.kind === 200 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 198 /* ObjectBindingPattern */ || contextualType.pattern.kind === 202 /* ObjectLiteralExpression */); var inConstContext = isConstContext(node); var checkFlags = inConstContext ? 8 /* Readonly */ : 0; var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node); @@ -66567,7 +69114,7 @@ var ts; // which may never occur. for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; - if (elem.name && ts.isComputedPropertyName(elem.name) && !ts.isWellKnownSymbolSyntactically(elem.name)) { + if (elem.name && ts.isComputedPropertyName(elem.name)) { checkComputedPropertyName(elem.name); } } @@ -66575,16 +69122,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 === 158 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 160 /* ComputedPropertyName */ ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 288 /* PropertyAssignment */ || - memberDecl.kind === 289 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 290 /* PropertyAssignment */ || + memberDecl.kind === 291 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 288 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + var type = memberDecl.kind === 290 /* 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 === 289 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : + memberDecl.kind === 291 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJavascript) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -66596,7 +69143,7 @@ var ts; checkTypeAssignableTo(type, getTypeFromTypeNode(enumTag.typeExpression), memberDecl); } } - objectFlags |= ts.getObjectFlags(type) & 3670016 /* PropagatingFlags */; + objectFlags |= ts.getObjectFlags(type) & 917504 /* PropagatingFlags */; var nameType = computedNameType && isTypeUsableAsPropertyName(computedNameType) ? computedNameType : undefined; var prop = nameType ? createSymbol(4 /* Property */ | member.flags, getPropertyNameFromType(nameType), checkFlags | 4096 /* Late */) : @@ -66607,8 +69154,8 @@ var ts; 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 === 288 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 289 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 290 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 291 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216 /* Optional */; } @@ -66634,7 +69181,7 @@ var ts; member = prop; allPropertiesTable === null || allPropertiesTable === void 0 ? void 0 : allPropertiesTable.set(prop.escapedName, prop); } - else if (memberDecl.kind === 290 /* SpreadAssignment */) { + else if (memberDecl.kind === 292 /* SpreadAssignment */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } @@ -66646,15 +69193,20 @@ var ts; hasComputedNumberProperty = false; } var type = getReducedType(checkExpression(memberDecl.expression)); - if (!isValidSpreadType(type)) { - error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); - return errorType; + if (isValidSpreadType(type)) { + if (allPropertiesTable) { + checkSpreadPropOverrides(type, allPropertiesTable, memberDecl); + } + offset = propertiesArray.length; + if (spread === errorType) { + continue; + } + spread = getSpreadType(spread, type, node.symbol, objectFlags, inConstContext); } - if (allPropertiesTable) { - checkSpreadPropOverrides(type, allPropertiesTable, memberDecl); + else { + error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); + spread = errorType; } - spread = getSpreadType(spread, type, node.symbol, objectFlags, inConstContext); - offset = propertiesArray.length; continue; } else { @@ -66663,7 +69215,7 @@ 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 === 167 /* GetAccessor */ || memberDecl.kind === 168 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 169 /* GetAccessor */ || memberDecl.kind === 170 /* SetAccessor */); checkNodeDeferred(memberDecl); } if (computedNameType && !(computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */)) { @@ -66688,7 +69240,7 @@ 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 !== 290 /* SpreadAssignment */) { + if (contextualTypeHasPattern && node.parent.kind !== 292 /* 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)) { @@ -66700,6 +69252,9 @@ var ts; } } } + if (spread === errorType) { + return errorType; + } if (spread !== emptyObjectType) { if (propertiesArray.length > 0) { spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, objectFlags, inConstContext); @@ -66716,9 +69271,9 @@ var ts; var stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node, offset, propertiesArray, 0 /* String */) : undefined; var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, offset, propertiesArray, 1 /* Number */) : undefined; var result = createAnonymousType(node.symbol, propertiesTable, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); - result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 1048576 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 262144 /* ContainsObjectOrArrayLiteral */; if (isJSObjectLiteral) { - result.objectFlags |= 16384 /* JSLiteral */; + result.objectFlags |= 8192 /* JSLiteral */; } if (patternWithComputedProperties) { result.objectFlags |= 512 /* ObjectLiteralPatternWithComputedProperties */; @@ -66784,7 +69339,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 === 78 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); + return tagName.kind === 79 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); } function checkJsxAttribute(node, checkMode) { return node.initializer @@ -66808,14 +69363,14 @@ var ts; var hasSpreadAnyType = false; var typeToIntersect; var explicitlySpecifyChildrenAttribute = false; - var objectFlags = 4096 /* JsxAttributes */; + var objectFlags = 2048 /* 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) & 3670016 /* PropagatingFlags */; + objectFlags |= ts.getObjectFlags(exprType) & 917504 /* PropagatingFlags */; var attributeSymbol = createSymbol(4 /* Property */ | member.flags, member.escapedName); attributeSymbol.declarations = member.declarations; attributeSymbol.parent = member.parent; @@ -66831,7 +69386,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 282 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 284 /* JsxSpreadAttribute */); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, /*readonly*/ false); attributesTable = ts.createSymbolTable(); @@ -66857,7 +69412,7 @@ var ts; } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 273 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 275 /* 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); @@ -66873,7 +69428,7 @@ var ts; // 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); childrenPropSymbol.type = childrenTypes.length === 1 ? childrenTypes[0] : - childrenContextualType && forEachType(childrenContextualType, isTupleLikeType) ? createTupleType(childrenTypes) : + childrenContextualType && someType(childrenContextualType, isTupleLikeType) ? createTupleType(childrenTypes) : createArrayType(getUnionType(childrenTypes)); // Fake up a property declaration for the children childrenPropSymbol.valueDeclaration = ts.factory.createPropertySignature(/*modifiers*/ undefined, ts.unescapeLeadingUnderscores(jsxChildrenPropertyName), /*questionToken*/ undefined, /*type*/ undefined); @@ -66899,7 +69454,7 @@ var ts; function createJsxAttributesType() { objectFlags |= freshObjectLiteralFlag; var result = createAnonymousType(attributes.symbol, attributesTable, ts.emptyArray, ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); - result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 1048576 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 262144 /* ContainsObjectOrArrayLiteral */; return result; } } @@ -66914,7 +69469,7 @@ var ts; childrenTypes.push(stringType); } } - else if (child.kind === 283 /* JsxExpression */ && !child.expression) { + else if (child.kind === 285 /* JsxExpression */ && !child.expression) { continue; // empty jsx expressions don't *really* count as present children } else { @@ -67065,7 +69620,7 @@ var ts; else if (propertiesOfJsxElementAttribPropInterface.length === 1) { return propertiesOfJsxElementAttribPropInterface[0].escapedName; } - else if (propertiesOfJsxElementAttribPropInterface.length > 1) { + else if (propertiesOfJsxElementAttribPropInterface.length > 1 && jsxElementAttribPropInterfaceSym.declarations) { // More than one property on ElementAttributesProperty is an error error(jsxElementAttribPropInterfaceSym.declarations[0], ts.Diagnostics.The_global_type_JSX_0_may_not_have_more_than_one_property, ts.unescapeLeadingUnderscores(nameOfAttribPropContainer)); } @@ -67175,11 +69730,11 @@ var ts; if (!links.resolvedJsxElementAttributesType) { var symbol = getIntrinsicTagSymbol(node); if (links.jsxFlags & 1 /* IntrinsicNamedElement */) { - return links.resolvedJsxElementAttributesType = getTypeOfSymbol(symbol); + return links.resolvedJsxElementAttributesType = getTypeOfSymbol(symbol) || errorType; } else if (links.jsxFlags & 2 /* IntrinsicIndexedElement */) { return links.resolvedJsxElementAttributesType = - getIndexTypeOfType(getDeclaredTypeOfSymbol(symbol), 0 /* String */); + getIndexTypeOfType(getJsxType(JsxNames.IntrinsicElements, node), 0 /* String */) || errorType; } else { return links.resolvedJsxElementAttributesType = errorType; @@ -67332,9 +69887,12 @@ var ts; * @param type The type of the object whose property is being accessed. (Not the type of the property.) * @param prop The symbol for the property being accessed. */ - function checkPropertyAccessibility(node, isSuper, type, prop) { - var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 157 /* QualifiedName */ ? node.right : node.kind === 195 /* ImportType */ ? node : node.name; + function checkPropertyAccessibility(node, isSuper, writing, type, prop, reportError) { + if (reportError === void 0) { reportError = true; } + var flags = ts.getDeclarationModifierFlagsFromSymbol(prop, writing); + var errorNode = node.kind === 159 /* QualifiedName */ ? node.right : + node.kind === 197 /* ImportType */ ? node : + node.kind === 200 /* BindingElement */ && node.propertyName ? node.propertyName : node.name; if (isSuper) { // TS 1.0 spec (April 2014): 4.8.2 // - In a constructor, instance member function, instance member accessor, or @@ -67345,7 +69903,9 @@ var ts; // a super property access is permitted and must specify a public static member function of the base class. if (languageVersion < 2 /* ES2015 */) { if (symbolHasNonMethodDeclaration(prop)) { - error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); + if (reportError) { + error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); + } return false; } } @@ -67354,24 +69914,22 @@ var ts; // This error could mask a private property access error. But, a member // cannot simultaneously be private and abstract, so this will trigger an // additional error elsewhere. - error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(getDeclaringClass(prop))); + if (reportError) { + error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(getDeclaringClass(prop))); + } return false; } } // Referencing abstract properties within their own constructors is not allowed - if ((flags & 128 /* Abstract */) && ts.isThisProperty(node) && symbolHasNonMethodDeclaration(prop)) { + if ((flags & 128 /* Abstract */) && symbolHasNonMethodDeclaration(prop) && + (ts.isThisProperty(node) || ts.isThisInitializedObjectBindingExpression(node) || ts.isObjectBindingPattern(node.parent) && ts.isThisInitializedDeclaration(node.parent.parent))) { var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (declaringClassDeclaration && isNodeUsedDuringClassInitialization(node)) { - error(errorNode, ts.Diagnostics.Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor, symbolToString(prop), ts.getTextOfIdentifierOrLiteral(declaringClassDeclaration.name)); // TODO: GH#18217 - return false; - } - } - if (ts.isPropertyAccessExpression(node) && ts.isPrivateIdentifier(node.name)) { - if (!ts.getContainingClass(node)) { - error(errorNode, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); + if (reportError) { + error(errorNode, ts.Diagnostics.Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor, symbolToString(prop), ts.getTextOfIdentifierOrLiteral(declaringClassDeclaration.name)); // TODO: GH#18217 + } return false; } - return true; } // Public properties are otherwise accessible. if (!(flags & 24 /* NonPublicAccessibilityModifier */)) { @@ -67382,7 +69940,9 @@ var ts; if (flags & 8 /* Private */) { var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (!isNodeWithinClass(node, declaringClassDeclaration)) { - error(errorNode, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(getDeclaringClass(prop))); + if (reportError) { + error(errorNode, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(getDeclaringClass(prop))); + } return false; } return true; @@ -67396,7 +69956,7 @@ var ts; // of the property as base classes var enclosingClass = forEachEnclosingClass(node, function (enclosingDeclaration) { var enclosingClass = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingDeclaration)); - return isClassDerivedFromDeclaringClasses(enclosingClass, prop) ? enclosingClass : undefined; + return isClassDerivedFromDeclaringClasses(enclosingClass, prop, writing) ? enclosingClass : undefined; }); // A protected property is accessible if the property is within the declaring class or classes derived from it if (!enclosingClass) { @@ -67404,7 +69964,9 @@ var ts; // static member access is disallow var thisParameter = void 0; if (flags & 32 /* Static */ || !(thisParameter = getThisParameterFromNodeContext(node)) || !thisParameter.type) { - error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || type)); + if (reportError) { + error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || type)); + } return false; } var thisType = getTypeFromTypeNode(thisParameter.type); @@ -67419,7 +69981,9 @@ var ts; type = type.isThisType ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(type); // TODO: GH#18217 Use a different variable that's allowed to be undefined } if (!type || !hasBaseType(type, enclosingClass)) { - error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); + if (reportError) { + error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_This_is_an_instance_of_class_2, symbolToString(prop), typeToString(enclosingClass), typeToString(type)); + } return false; } return true; @@ -67475,20 +70039,20 @@ var ts; } return nonNullType; } - function checkPropertyAccessExpression(node) { - return node.flags & 32 /* OptionalChain */ ? checkPropertyAccessChain(node) : - checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullExpression(node.expression), node.name); + function checkPropertyAccessExpression(node, checkMode) { + return node.flags & 32 /* OptionalChain */ ? checkPropertyAccessChain(node, checkMode) : + checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullExpression(node.expression), node.name, checkMode); } - function checkPropertyAccessChain(node) { + function checkPropertyAccessChain(node, checkMode) { var leftType = checkExpression(node.expression); var nonOptionalType = getOptionalExpressionType(leftType, node.expression); - return propagateOptionalTypeMarker(checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullType(nonOptionalType, node.expression), node.name), node, nonOptionalType !== leftType); + return propagateOptionalTypeMarker(checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullType(nonOptionalType, node.expression), node.name, checkMode), node, nonOptionalType !== leftType); } - function checkQualifiedName(node) { - return checkPropertyAccessExpressionOrQualifiedName(node, node.left, checkNonNullExpression(node.left), node.right); + function checkQualifiedName(node, checkMode) { + return checkPropertyAccessExpressionOrQualifiedName(node, node.left, checkNonNullExpression(node.left), node.right, checkMode); } function isMethodAccessForCall(node) { - while (node.parent.kind === 207 /* ParenthesizedExpression */) { + while (node.parent.kind === 209 /* ParenthesizedExpression */) { node = node.parent; } return ts.isCallOrNewExpression(node.parent) && node.parent.expression === node; @@ -67523,14 +70087,13 @@ var ts; } var diagName = diagnosticName(right); if (propertyOnType) { - var typeValueDecl = propertyOnType.valueDeclaration; - var typeClass_1 = ts.getContainingClass(typeValueDecl); - ts.Debug.assert(!!typeClass_1); + var typeValueDecl = ts.Debug.checkDefined(propertyOnType.valueDeclaration); + var typeClass_1 = ts.Debug.checkDefined(ts.getContainingClass(typeValueDecl)); // We found a private identifier property with the same description. // Either: // - There is a lexically scoped private identifier AND it shadows the one we found on the type. // - It is an attempt to access the private identifier outside of the class. - if (lexicallyScopedIdentifier) { + if (lexicallyScopedIdentifier === null || lexicallyScopedIdentifier === void 0 ? void 0 : lexicallyScopedIdentifier.valueDeclaration) { var lexicalValueDecl = lexicallyScopedIdentifier.valueDeclaration; var lexicalClass = ts.getContainingClass(lexicalValueDecl); ts.Debug.assert(!!lexicalClass); @@ -67549,17 +70112,42 @@ var ts; return (isConstructorDeclaredProperty(prop) || ts.isThisProperty(node) && isAutoTypedProperty(prop)) && ts.getThisContainer(node, /*includeArrowFunctions*/ true) === getDeclaringConstructor(prop); } - function checkPropertyAccessExpressionOrQualifiedName(node, left, leftType, right) { + 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); - if (ts.isPrivateIdentifier(right)) { - checkExternalEmitHelpers(node, 524288 /* ClassPrivateFieldGet */); - } 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 (assignmentKind !== 1 /* Definite */) { + checkExternalEmitHelpers(node, 524288 /* ClassPrivateFieldGet */); + } + } var lexicallyScopedSymbol = lookupSymbolForPrivateIdentifierDeclaration(right.escapedText, right); + if (assignmentKind && lexicallyScopedSymbol && lexicallyScopedSymbol.valueDeclaration && ts.isMethodDeclaration(lexicallyScopedSymbol.valueDeclaration)) { + grammarErrorOnNode(right, ts.Diagnostics.Cannot_assign_to_private_method_0_Private_methods_are_not_writable, ts.idText(right)); + } + if ((lexicallyScopedSymbol === null || lexicallyScopedSymbol === void 0 ? void 0 : lexicallyScopedSymbol.valueDeclaration) && (compilerOptions.target === 99 /* ESNext */ && !useDefineForClassFields)) { + var lexicalClass_1 = ts.getContainingClass(lexicallyScopedSymbol.valueDeclaration); + var parentStaticFieldInitializer = ts.findAncestor(node, function (n) { + if (n === lexicalClass_1) + return "quit"; + if (ts.isPropertyDeclaration(n.parent) && ts.hasStaticModifier(n.parent) && n.parent.initializer === n && n.parent.parent === lexicalClass_1) { + return true; + } + return false; + }); + if (parentStaticFieldInitializer) { + var parentStaticFieldInitializerSymbol = getSymbolOfNode(parentStaticFieldInitializer.parent); + ts.Debug.assert(parentStaticFieldInitializerSymbol, "Initializer without declaration symbol"); + var diagnostic = error(node, ts.Diagnostics.Property_0_may_not_be_used_in_a_static_property_s_initializer_in_the_same_class_when_target_is_esnext_and_useDefineForClassFields_is_false, ts.symbolName(lexicallyScopedSymbol)); + ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(parentStaticFieldInitializer.parent, ts.Diagnostics.Initializer_for_property_0, ts.symbolName(parentStaticFieldInitializerSymbol))); + } + } if (isAnyLike) { if (lexicallyScopedSymbol) { return apparentType; @@ -67574,6 +70162,12 @@ var ts; if (!prop && checkPrivateIdentifierPropertyAccess(leftType, right, lexicallyScopedSymbol)) { return errorType; } + else { + var isSetonlyAccessor = prop && prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); + if (isSetonlyAccessor && assignmentKind !== 1 /* Definite */) { + error(node, ts.Diagnostics.Private_accessor_was_defined_without_a_getter); + } + } } else { if (isAnyLike) { @@ -67584,7 +70178,11 @@ var ts; } prop = getPropertyOfType(apparentType, right.escapedText); } - if (ts.isIdentifier(left) && parentSymbol && !(prop && isConstEnumOrConstEnumOnlyModule(prop))) { + // In `Foo.Bar.Baz`, 'Foo' is not referenced if 'Bar' is a const enum or a module containing only const enums. + // The exceptions are: + // 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)) || ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(node))) { markAliasReferenced(parentSymbol, node); } var propType; @@ -67617,44 +70215,50 @@ var ts; } } else { - if (getDeclarationNodeFlagsFromSymbol(prop) & 134217728 /* Deprecated */ && isUncalledFunctionReference(node, prop)) { - errorOrSuggestion(/* isError */ false, right, ts.Diagnostics._0_is_deprecated, right.escapedText); + if (prop.declarations && getDeclarationNodeFlagsFromSymbol(prop) & 134217728 /* Deprecated */ && isUncalledFunctionReference(node, prop)) { + addDeprecatedSuggestion(right, prop.declarations, right.escapedText); } checkPropertyNotUsedBeforeDeclaration(prop, node, right); - markPropertyAsReferenced(prop, node, left.kind === 107 /* ThisKeyword */); + markPropertyAsReferenced(prop, node, isSelfTypeAccess(left, parentSymbol)); getNodeLinks(node).resolvedSymbol = prop; - checkPropertyAccessibility(node, left.kind === 105 /* SuperKeyword */, apparentType, prop); + var writing = ts.isWriteAccess(node); + checkPropertyAccessibility(node, left.kind === 106 /* 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; } - propType = isThisPropertyAccessInConstructor(node, prop) ? autoType : getConstraintForLocation(getTypeOfSymbol(prop), node); + propType = isThisPropertyAccessInConstructor(node, prop) ? autoType : writing ? getSetAccessorTypeOfSymbol(prop) : getTypeOfSymbol(prop); } - return getFlowTypeOfAccessExpression(node, prop, propType, right); + return getFlowTypeOfAccessExpression(node, prop, propType, right, checkMode); } - function getFlowTypeOfAccessExpression(node, prop, propType, errorNode) { + function getFlowTypeOfAccessExpression(node, prop, propType, errorNode, checkMode) { // Only compute control flow type if this is a property access expression that isn't an // assignment target, and the referenced property was declared as a variable, property, // accessor, or optional method. var assignmentKind = ts.getAssignmentTargetKind(node); - if (!ts.isAccessExpression(node) || - assignmentKind === 1 /* Definite */ || - prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */)) { + if (assignmentKind === 1 /* Definite */) { + return removeMissingType(propType, !!(prop && prop.flags & 16777216 /* Optional */)); + } + if (prop && + !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) + && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */) + && !isDuplicatedCommonJSExport(prop.declarations)) { return propType; } if (propType === autoType) { return getFlowTypeOfProperty(node, prop); } + propType = getNarrowableTypeForReference(propType, node, checkMode); // If strict null checks and strict property initialization checks are enabled, if we have // a this.xxx property access, if the property is an instance property without an initializer, // and if we are in a constructor of the same class as the property declaration, assume that // the property is uninitialized at the top of the control flow. var assumeUninitialized = false; - if (strictNullChecks && strictPropertyInitialization && node.expression.kind === 107 /* ThisKeyword */) { + if (strictNullChecks && strictPropertyInitialization && ts.isAccessExpression(node) && node.expression.kind === 108 /* ThisKeyword */) { var declaration = prop && prop.valueDeclaration; if (declaration && isInstancePropertyWithoutInitializer(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 166 /* Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 8388608 /* Ambient */)) { + if (flowContainer.kind === 168 /* Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 8388608 /* Ambient */)) { assumeUninitialized = true; } } @@ -67681,13 +70285,14 @@ var ts; var diagnosticMessage; var declarationName = ts.idText(right); if (isInPropertyInitializer(node) + && !isOptionalPropertyDeclaration(valueDeclaration) && !(ts.isAccessExpression(node) && ts.isAccessExpression(node.expression)) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) - && !isPropertyDeclaredInAncestorClass(prop)) { + && (compilerOptions.useDefineForClassFields || !isPropertyDeclaredInAncestorClass(prop))) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 252 /* ClassDeclaration */ && - node.parent.kind !== 173 /* TypeReference */ && + else if (valueDeclaration.kind === 254 /* ClassDeclaration */ && + node.parent.kind !== 175 /* TypeReference */ && !(valueDeclaration.flags & 8388608 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); @@ -67699,22 +70304,22 @@ var ts; function isInPropertyInitializer(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return true; - case 288 /* PropertyAssignment */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 290 /* SpreadAssignment */: - case 158 /* ComputedPropertyName */: - case 228 /* TemplateSpan */: - case 283 /* JsxExpression */: - case 280 /* JsxAttribute */: - case 281 /* JsxAttributes */: - case 282 /* JsxSpreadAttribute */: - case 275 /* JsxOpeningElement */: - case 223 /* ExpressionWithTypeArguments */: - case 286 /* HeritageClause */: + case 290 /* PropertyAssignment */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 292 /* SpreadAssignment */: + case 160 /* ComputedPropertyName */: + case 230 /* TemplateSpan */: + case 285 /* JsxExpression */: + case 282 /* JsxAttribute */: + case 283 /* JsxAttributes */: + case 284 /* JsxSpreadAttribute */: + case 277 /* JsxOpeningElement */: + case 225 /* ExpressionWithTypeArguments */: + case 288 /* HeritageClause */: return false; default: return ts.isExpressionNode(node) ? false : "quit"; @@ -67786,7 +70391,10 @@ var ts; relatedInfo = suggestion.valueDeclaration && ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestedName); } else { - errorInfo = ts.chainDiagnosticMessages(elaborateNeverIntersection(errorInfo, containingType), ts.Diagnostics.Property_0_does_not_exist_on_type_1, missingProperty, container); + var diagnostic = containerSeemsToBeEmptyDomElement(containingType) + ? ts.Diagnostics.Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom + : ts.Diagnostics.Property_0_does_not_exist_on_type_1; + errorInfo = ts.chainDiagnosticMessages(elaborateNeverIntersection(errorInfo, containingType), diagnostic, missingProperty, container); } } } @@ -67797,9 +70405,14 @@ var ts; } diagnostics.add(resultDiagnostic); } + function containerSeemsToBeEmptyDomElement(containingType) { + return (compilerOptions.lib && !compilerOptions.lib.includes("dom")) && + everyContainedType(containingType, function (type) { return type.symbol && /^(EventTarget|Node|((HTML[a-zA-Z]*)?Element))$/.test(ts.unescapeLeadingUnderscores(type.symbol.escapedName)); }) && + isEmptyObjectType(containingType); + } function typeHasStaticProperty(propName, containingType) { var prop = containingType.symbol && getPropertyOfType(getTypeOfSymbol(containingType.symbol), propName); - return prop !== undefined && prop.valueDeclaration && ts.hasSyntacticModifier(prop.valueDeclaration, 32 /* Static */); + return prop !== undefined && !!prop.valueDeclaration && ts.hasSyntacticModifier(prop.valueDeclaration, 32 /* Static */); } function getSuggestedLibForNonExistentName(name) { var missingName = diagnosticName(name); @@ -67830,7 +70443,15 @@ var ts; } } function getSuggestedSymbolForNonexistentProperty(name, containingType) { - return getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 111551 /* Value */); + var props = getPropertiesOfType(containingType); + if (typeof name !== "string") { + var parent_2 = name.parent; + if (ts.isPropertyAccessExpression(parent_2)) { + props = ts.filter(props, function (prop) { return isValidPropertyAccessForCompletions(parent_2, containingType, prop); }); + } + name = ts.idText(name); + } + return getSpellingSuggestionForName(name, props, 111551 /* Value */); } function getSuggestedSymbolForNonexistentJSXAttribute(name, containingType) { var strName = ts.isString(name) ? name : ts.idText(name); @@ -67925,20 +70546,20 @@ var ts; return undefined; } } - function markPropertyAsReferenced(prop, nodeForCheckWriteOnly, isThisAccess) { + function markPropertyAsReferenced(prop, nodeForCheckWriteOnly, isSelfTypeAccess) { var valueDeclaration = prop && (prop.flags & 106500 /* ClassMember */) && prop.valueDeclaration; if (!valueDeclaration) { return; } var hasPrivateModifier = ts.hasEffectiveModifier(valueDeclaration, 8 /* Private */); - var hasPrivateIdentifier = ts.isNamedDeclaration(prop.valueDeclaration) && ts.isPrivateIdentifier(prop.valueDeclaration.name); + 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 */)) { return; } - if (isThisAccess) { + if (isSelfTypeAccess) { // Find any FunctionLikeDeclaration because those create a new 'this' binding. But this should only matter for methods (or getters/setters). var containingMethod = ts.findAncestor(nodeForCheckWriteOnly, ts.isFunctionLikeDeclaration); if (containingMethod && containingMethod.symbol === prop) { @@ -67947,18 +70568,22 @@ var ts; } (ts.getCheckFlags(prop) & 1 /* Instantiated */ ? getSymbolLinks(prop).target : prop).isReferenced = 67108863 /* All */; } + function isSelfTypeAccess(name, parent) { + return name.kind === 108 /* ThisKeyword */ + || !!parent && ts.isEntityNameExpression(name) && parent === getResolvedSymbol(ts.getFirstIdentifier(name)); + } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 201 /* PropertyAccessExpression */: - return isValidPropertyAccessWithType(node, node.expression.kind === 105 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); - case 157 /* QualifiedName */: + case 203 /* PropertyAccessExpression */: + return isValidPropertyAccessWithType(node, node.expression.kind === 106 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); + case 159 /* QualifiedName */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getWidenedType(checkExpression(node.left))); - case 195 /* ImportType */: + case 197 /* ImportType */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind === 201 /* PropertyAccessExpression */ && node.expression.kind === 105 /* SuperKeyword */, property.escapedName, type); + return isValidPropertyAccessWithType(node, node.kind === 203 /* PropertyAccessExpression */ && node.expression.kind === 106 /* SuperKeyword */, property.escapedName, type); // Previously we validated the 'this' type of methods but this adversely affected performance. See #31377 for more context. } function isValidPropertyAccessWithType(node, isSuper, propertyName, type) { @@ -67967,11 +70592,11 @@ var ts; } var prop = getPropertyOfType(type, propertyName); if (prop) { - if (ts.isPropertyAccessExpression(node) && prop.valueDeclaration && ts.isPrivateIdentifierPropertyDeclaration(prop.valueDeclaration)) { + if (prop.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(prop.valueDeclaration)) { var declClass_1 = ts.getContainingClass(prop.valueDeclaration); return !ts.isOptionalChain(node) && !!ts.findAncestor(node, function (parent) { return parent === declClass_1; }); } - return checkPropertyAccessibility(node, isSuper, type, prop); + return checkPropertyAccessibility(node, isSuper, /*writing*/ false, type, prop, /* reportError */ false); } // In js files properties of unions are allowed in completion return ts.isInJSFile(node) && (type.flags & 1048576 /* Union */) !== 0 && type.types.some(function (elementType) { return isValidPropertyAccessWithType(node, isSuper, propertyName, elementType); }); @@ -67981,13 +70606,13 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 250 /* VariableDeclarationList */) { + if (initializer.kind === 252 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 78 /* Identifier */) { + else if (initializer.kind === 79 /* Identifier */) { return getResolvedSymbol(initializer); } return undefined; @@ -68004,13 +70629,13 @@ var ts; */ function isForInVariableForNumericPropertyNames(expr) { var e = ts.skipParentheses(expr); - if (e.kind === 78 /* Identifier */) { + if (e.kind === 79 /* Identifier */) { var symbol = getResolvedSymbol(e); if (symbol.flags & 3 /* Variable */) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 238 /* ForInStatement */ && + if (node.kind === 240 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -68023,16 +70648,16 @@ var ts; } return false; } - function checkIndexedAccess(node) { - return node.flags & 32 /* OptionalChain */ ? checkElementAccessChain(node) : - checkElementAccessExpression(node, checkNonNullExpression(node.expression)); + function checkIndexedAccess(node, checkMode) { + return node.flags & 32 /* OptionalChain */ ? checkElementAccessChain(node, checkMode) : + checkElementAccessExpression(node, checkNonNullExpression(node.expression), checkMode); } - function checkElementAccessChain(node) { + function checkElementAccessChain(node, checkMode) { var exprType = checkExpression(node.expression); var nonOptionalType = getOptionalExpressionType(exprType, node.expression); - return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression)), node, nonOptionalType !== exprType); + return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression), checkMode), node, nonOptionalType !== exprType); } - function checkElementAccessExpression(node, exprType) { + function checkElementAccessExpression(node, exprType, checkMode) { var objectType = ts.getAssignmentTargetKind(node) !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; var indexExpression = node.argumentExpression; var indexType = checkExpression(indexExpression); @@ -68045,45 +70670,10 @@ var ts; } var effectiveIndexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType; var accessFlags = ts.isAssignmentTarget(node) ? - 2 /* Writing */ | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 1 /* NoIndexSignatures */ : 0) : - 0 /* None */; - var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, /*noUncheckedIndexedAccessCandidate*/ undefined, node, accessFlags | 16 /* ExpressionPosition */) || errorType; - return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, indexedAccessType.symbol, indexedAccessType, indexExpression), node); - } - function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) { - if (expressionType === errorType) { - // There is already an error, so no need to report one. - return false; - } - if (!ts.isWellKnownSymbolSyntactically(expression)) { - return false; - } - // Make sure the property type is the primitive symbol type - if ((expressionType.flags & 12288 /* ESSymbolLike */) === 0) { - if (reportError) { - error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression)); - } - return false; - } - // The name is Symbol., so make sure Symbol actually resolves to the - // global Symbol object - var leftHandSide = expression.expression; - var leftHandSideSymbol = getResolvedSymbol(leftHandSide); - if (!leftHandSideSymbol) { - return false; - } - var globalESSymbol = getGlobalESSymbolConstructorSymbol(/*reportErrors*/ true); - if (!globalESSymbol) { - // Already errored when we tried to look up the symbol - return false; - } - if (leftHandSideSymbol !== globalESSymbol) { - if (reportError) { - error(leftHandSide, ts.Diagnostics.Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object); - } - return false; - } - return true; + 4 /* Writing */ | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 2 /* NoIndexSignatures */ : 0) : + 32 /* ExpressionPosition */; + var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, accessFlags, node) || errorType; + return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, getNodeLinks(node).resolvedSymbol, indexedAccessType, indexExpression, checkMode), node); } function callLikeExpressionMayHaveTypeArguments(node) { return ts.isCallOrNewExpression(node) || ts.isTaggedTemplateExpression(node) || ts.isJsxOpeningLikeElement(node); @@ -68094,13 +70684,13 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 205 /* TaggedTemplateExpression */) { + if (node.kind === 207 /* TaggedTemplateExpression */) { checkExpression(node.template); } else if (ts.isJsxOpeningLikeElement(node)) { checkExpression(node.attributes); } - else if (node.kind !== 161 /* Decorator */) { + else if (node.kind !== 163 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -68164,7 +70754,7 @@ var ts; } } function isSpreadArgument(arg) { - return !!arg && (arg.kind === 220 /* SpreadElement */ || arg.kind === 227 /* SyntheticExpression */ && arg.isSpread); + return !!arg && (arg.kind === 222 /* SpreadElement */ || arg.kind === 229 /* SyntheticExpression */ && arg.isSpread); } function getSpreadArgumentIndex(args) { return ts.findIndex(args, isSpreadArgument); @@ -68181,9 +70771,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 === 205 /* TaggedTemplateExpression */) { + if (node.kind === 207 /* TaggedTemplateExpression */) { argCount = args.length; - if (node.template.kind === 218 /* TemplateExpression */) { + if (node.template.kind === 220 /* 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. @@ -68198,7 +70788,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 161 /* Decorator */) { + else if (node.kind === 163 /* Decorator */) { argCount = getDecoratorArgumentCount(node, signature); } else if (ts.isJsxOpeningLikeElement(node)) { @@ -68212,7 +70802,7 @@ var ts; } else if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 204 /* NewExpression */); + ts.Debug.assert(node.kind === 206 /* NewExpression */); return getMinArgumentCount(signature) === 0; } else { @@ -68287,7 +70877,7 @@ var ts; }); if (!inferenceContext) { applyToReturnTypes(contextualSignature, signature, function (source, target) { - inferTypes(context.inferences, source, target, 64 /* ReturnType */); + inferTypes(context.inferences, source, target, 128 /* ReturnType */); }); } return getSignatureInstantiation(signature, getInferredTypes(context), ts.isInJSFile(contextualSignature.declaration)); @@ -68298,6 +70888,15 @@ var ts; inferTypes(context.inferences, checkAttrType, paramType); return getInferredTypes(context); } + function getThisArgumentType(thisArgumentNode) { + if (!thisArgumentNode) { + return voidType; + } + var thisArgumentType = checkExpression(thisArgumentNode); + return ts.isOptionalChainRoot(thisArgumentNode.parent) ? getNonNullableType(thisArgumentType) : + ts.isOptionalChain(thisArgumentNode.parent) ? removeOptionalTypeMarker(thisArgumentType) : + thisArgumentType; + } function inferTypeArguments(node, signature, args, checkMode, context) { if (ts.isJsxOpeningLikeElement(node)) { return inferJsxTypeArguments(node, signature, checkMode, context); @@ -68306,7 +70905,7 @@ 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 !== 161 /* Decorator */) { + if (node.kind !== 163 /* Decorator */) { var contextualType = getContextualType(node, ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }) ? 8 /* SkipBindingPatterns */ : 0 /* None */); if (contextualType) { // We clone the inference context to avoid disturbing a resolution in progress for an @@ -68328,7 +70927,7 @@ var ts; instantiatedType; var inferenceTargetType = getReturnTypeOfSignature(signature); // Inferences made from return types have lower priority than all other inferences. - inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 64 /* ReturnType */); + inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* 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 // the source type uses the outer context's return mapper (which excludes inferences made from @@ -68350,12 +70949,11 @@ var ts; var thisType = getThisTypeOfSignature(signature); if (thisType) { var thisArgumentNode = getThisArgumentOfCall(node); - var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; - inferTypes(context.inferences, thisArgumentType, thisType); + inferTypes(context.inferences, getThisArgumentType(thisArgumentNode), thisType); } for (var i = 0; i < argCount; i++) { var arg = args[i]; - if (arg.kind !== 222 /* OmittedExpression */) { + if (arg.kind !== 224 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode); inferTypes(context.inferences, argType, paramType); @@ -68379,7 +70977,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 === 227 /* SyntheticExpression */ ? arg.type : + return getMutableArrayOrTupleType(arg.kind === 229 /* SyntheticExpression */ ? arg.type : checkExpressionWithContextualType(arg.expression, restType, context, checkMode)); } } @@ -68389,24 +70987,24 @@ var ts; for (var i = index; i < argCount; i++) { var arg = args[i]; if (isSpreadArgument(arg)) { - var spreadType = arg.kind === 227 /* SyntheticExpression */ ? arg.type : checkExpression(arg.expression); + var spreadType = arg.kind === 229 /* SyntheticExpression */ ? arg.type : checkExpression(arg.expression); if (isArrayLikeType(spreadType)) { types.push(spreadType); flags.push(8 /* Variadic */); } else { - types.push(checkIteratedTypeOrElementType(33 /* Spread */, spreadType, undefinedType, arg.kind === 220 /* SpreadElement */ ? arg.expression : arg)); + types.push(checkIteratedTypeOrElementType(33 /* Spread */, spreadType, undefinedType, arg.kind === 222 /* SpreadElement */ ? arg.expression : arg)); flags.push(4 /* Rest */); } } else { - var contextualType = getIndexedAccessType(restType, getLiteralType(i - index)); + var contextualType = getIndexedAccessType(restType, getLiteralType(i - index), 256 /* Contextual */); var argType = checkExpressionWithContextualType(arg, contextualType, context, checkMode); var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 131068 /* Primitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */); types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType)); flags.push(1 /* Required */); } - if (arg.kind === 227 /* SyntheticExpression */ && arg.tupleNameSource) { + if (arg.kind === 229 /* SyntheticExpression */ && arg.tupleNameSource) { names.push(arg.tupleNameSource); } } @@ -68550,24 +71148,12 @@ var ts; return undefined; } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 204 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 206 /* 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. var thisArgumentNode = getThisArgumentOfCall(node); - var thisArgumentType = void 0; - if (thisArgumentNode) { - thisArgumentType = checkExpression(thisArgumentNode); - if (ts.isOptionalChainRoot(thisArgumentNode.parent)) { - thisArgumentType = getNonNullableType(thisArgumentType); - } - else if (ts.isOptionalChain(thisArgumentNode.parent)) { - thisArgumentType = removeOptionalTypeMarker(thisArgumentType); - } - } - else { - thisArgumentType = voidType; - } + var thisArgumentType = getThisArgumentType(thisArgumentNode); var errorNode = reportErrors ? (thisArgumentNode || node) : undefined; var headMessage_1 = ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1; if (!checkTypeRelatedTo(thisArgumentType, thisType, relation, errorNode, headMessage_1, containingMessageChain, errorOutputContainer)) { @@ -68580,7 +71166,7 @@ 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 !== 222 /* OmittedExpression */) { + if (arg.kind !== 224 /* 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), @@ -68625,7 +71211,7 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 203 /* CallExpression */) { + if (node.kind === 205 /* CallExpression */) { var callee = ts.skipOuterExpressions(node.expression); if (ts.isAccessExpression(callee)) { return callee.expression; @@ -68642,17 +71228,17 @@ var ts; * Returns the effective arguments for an expression that works like a function invocation. */ function getEffectiveCallArguments(node) { - if (node.kind === 205 /* TaggedTemplateExpression */) { + if (node.kind === 207 /* TaggedTemplateExpression */) { var template = node.template; var args_3 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())]; - if (template.kind === 218 /* TemplateExpression */) { + if (template.kind === 220 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_3.push(span.expression); }); } return args_3; } - if (node.kind === 161 /* Decorator */) { + if (node.kind === 163 /* Decorator */) { return getEffectiveDecoratorArguments(node); } if (ts.isJsxOpeningLikeElement(node)) { @@ -68663,10 +71249,10 @@ var ts; if (spreadIndex >= 0) { // Create synthetic arguments from spreads of tuple types. var effectiveArgs_1 = args.slice(0, spreadIndex); - var _loop_20 = function (i) { + var _loop_21 = function (i) { var arg = args[i]; // We can call checkExpressionCached because spread expressions never have a contextual type. - var spreadType = arg.kind === 220 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression)); + var spreadType = arg.kind === 222 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression)); if (spreadType && isTupleType(spreadType)) { ts.forEach(getTypeArguments(spreadType), function (t, i) { var _a; @@ -68680,7 +71266,7 @@ var ts; } }; for (var i = spreadIndex; i < args.length; i++) { - _loop_20(i); + _loop_21(i); } return effectiveArgs_1; } @@ -68693,30 +71279,30 @@ var ts; var parent = node.parent; var expr = node.expression; switch (parent.kind) { - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* 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 160 /* Parameter */: + case 162 /* 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 === 166 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), + createSyntheticExpression(expr, parent.parent.kind === 168 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), createSyntheticExpression(expr, anyType), createSyntheticExpression(expr, numberType) ]; - case 163 /* PropertyDeclaration */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* 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 !== 163 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; + var hasPropDesc = parent.kind !== 165 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; return [ createSyntheticExpression(expr, getParentTypeOfClassElement(parent)), createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)), @@ -68730,17 +71316,17 @@ var ts; */ function getDecoratorArgumentCount(node, signature) { switch (node.parent.kind) { - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: return 1; - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return 2; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* 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 160 /* Parameter */: + case 162 /* Parameter */: return 3; default: return ts.Debug.fail(); @@ -68786,77 +71372,66 @@ var ts; return constructorSymbol === globalPromiseSymbol; } function getArgumentArityError(node, signatures, args) { - var min = Number.POSITIVE_INFINITY; - var max = Number.NEGATIVE_INFINITY; - var belowArgCount = Number.NEGATIVE_INFINITY; - var aboveArgCount = Number.POSITIVE_INFINITY; - var argCount = args.length; + var _a; + var spreadIndex = getSpreadArgumentIndex(args); + if (spreadIndex > -1) { + return ts.createDiagnosticForNode(args[spreadIndex], ts.Diagnostics.A_spread_argument_must_either_have_a_tuple_type_or_be_passed_to_a_rest_parameter); + } + var min = Number.POSITIVE_INFINITY; // smallest parameter count + var max = Number.NEGATIVE_INFINITY; // largest parameter count + var maxBelow = Number.NEGATIVE_INFINITY; // largest parameter count that is smaller than the number of arguments + var minAbove = Number.POSITIVE_INFINITY; // smallest parameter count that is larger than the number of arguments var closestSignature; for (var _i = 0, signatures_8 = signatures; _i < signatures_8.length; _i++) { var sig = signatures_8[_i]; - var minCount = getMinArgumentCount(sig); - var maxCount = getParameterCount(sig); - if (minCount < argCount && minCount > belowArgCount) - belowArgCount = minCount; - if (argCount < maxCount && maxCount < aboveArgCount) - aboveArgCount = maxCount; - if (minCount < min) { - min = minCount; + var minParameter = getMinArgumentCount(sig); + var maxParameter = getParameterCount(sig); + // smallest/largest parameter counts + if (minParameter < min) { + min = minParameter; closestSignature = sig; } - max = Math.max(max, maxCount); + max = Math.max(max, maxParameter); + // shortest parameter count *longer than the call*/longest parameter count *shorter than the call* + if (minParameter < args.length && minParameter > maxBelow) + maxBelow = minParameter; + if (args.length < maxParameter && maxParameter < minAbove) + minAbove = maxParameter; } var hasRestParameter = ts.some(signatures, hasEffectiveRestParameter); - var paramRange = hasRestParameter ? min : - min < max ? min + "-" + max : - min; - var hasSpreadArgument = getSpreadArgumentIndex(args) > -1; - if (argCount <= max && hasSpreadArgument) { - argCount--; - } - var spanArray; - var related; - var error = hasRestParameter || hasSpreadArgument ? - hasRestParameter && hasSpreadArgument ? - ts.Diagnostics.Expected_at_least_0_arguments_but_got_1_or_more : - hasRestParameter ? - ts.Diagnostics.Expected_at_least_0_arguments_but_got_1 : - ts.Diagnostics.Expected_0_arguments_but_got_1_or_more : - paramRange === 1 && argCount === 0 && isPromiseResolveArityError(node) ? - ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise : - ts.Diagnostics.Expected_0_arguments_but_got_1; - if (closestSignature && getMinArgumentCount(closestSignature) > argCount && closestSignature.declaration) { - var paramDecl = closestSignature.declaration.parameters[closestSignature.thisParameter ? argCount + 1 : argCount]; - if (paramDecl) { - related = ts.createDiagnosticForNode(paramDecl, ts.isBindingPattern(paramDecl.name) ? ts.Diagnostics.An_argument_matching_this_binding_pattern_was_not_provided : - ts.isRestParameter(paramDecl) ? ts.Diagnostics.Arguments_for_the_rest_parameter_0_were_not_provided : ts.Diagnostics.An_argument_for_0_was_not_provided, !paramDecl.name ? argCount : !ts.isBindingPattern(paramDecl.name) ? ts.idText(ts.getFirstIdentifier(paramDecl.name)) : undefined); - } - } - if (min < argCount && argCount < max) { - return getDiagnosticForCallNode(node, ts.Diagnostics.No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments, argCount, belowArgCount, aboveArgCount); - } - if (!hasSpreadArgument && argCount < min) { - var diagnostic_1 = getDiagnosticForCallNode(node, error, paramRange, argCount); - return related ? ts.addRelatedInfo(diagnostic_1, related) : diagnostic_1; - } - if (hasRestParameter || hasSpreadArgument) { - spanArray = ts.factory.createNodeArray(args); - if (hasSpreadArgument && argCount) { - var nextArg = ts.elementAt(args, getSpreadArgumentIndex(args) + 1) || undefined; - spanArray = ts.factory.createNodeArray(args.slice(max > argCount && nextArg ? args.indexOf(nextArg) : Math.min(max, args.length - 1))); + var parameterRange = hasRestParameter ? min + : min < max ? min + "-" + max + : min; + var error = hasRestParameter ? ts.Diagnostics.Expected_at_least_0_arguments_but_got_1 + : parameterRange === 1 && args.length === 0 && isPromiseResolveArityError(node) ? ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise + : ts.Diagnostics.Expected_0_arguments_but_got_1; + if (min < args.length && args.length < max) { + // between min and max, but with no matching overload + return getDiagnosticForCallNode(node, ts.Diagnostics.No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments, args.length, maxBelow, minAbove); + } + else if (args.length < min) { + // too short: put the error span on the call expression, not any of the args + var diagnostic = getDiagnosticForCallNode(node, error, parameterRange, args.length); + var parameter = (_a = closestSignature === null || closestSignature === void 0 ? void 0 : closestSignature.declaration) === null || _a === void 0 ? void 0 : _a.parameters[closestSignature.thisParameter ? args.length + 1 : args.length]; + if (parameter) { + var parameterError = ts.createDiagnosticForNode(parameter, ts.isBindingPattern(parameter.name) ? ts.Diagnostics.An_argument_matching_this_binding_pattern_was_not_provided + : ts.isRestParameter(parameter) ? ts.Diagnostics.Arguments_for_the_rest_parameter_0_were_not_provided + : ts.Diagnostics.An_argument_for_0_was_not_provided, !parameter.name ? args.length : !ts.isBindingPattern(parameter.name) ? ts.idText(ts.getFirstIdentifier(parameter.name)) : undefined); + return ts.addRelatedInfo(diagnostic, parameterError); } + return diagnostic; } else { - spanArray = ts.factory.createNodeArray(args.slice(max)); - } - var pos = ts.first(spanArray).pos; - var end = ts.last(spanArray).end; - if (end === pos) { - end++; + // too long; error goes on the excess parameters + var errorSpan = ts.factory.createNodeArray(args.slice(max)); + var pos = ts.first(errorSpan).pos; + var end = ts.last(errorSpan).end; + if (end === pos) { + end++; + } + ts.setTextRangePosEnd(errorSpan, pos, end); + return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), errorSpan, error, parameterRange, args.length); } - ts.setTextRangePosEnd(spanArray, pos, end); - var diagnostic = ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), spanArray, error, paramRange, argCount); - return related ? ts.addRelatedInfo(diagnostic, related) : diagnostic; } function getTypeArgumentArityError(node, signatures, typeArguments) { var argCount = typeArguments.length; @@ -68887,15 +71462,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 === 205 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 161 /* Decorator */; + var isTaggedTemplate = node.kind === 207 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 163 /* Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var reportErrors = !candidatesOutArray && produceDiagnostics; var typeArguments; if (!isDecorator) { typeArguments = node.typeArguments; // We already perform checking on the type arguments on the class declaration itself. - if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 105 /* SuperKeyword */) { + if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 106 /* SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } @@ -68950,7 +71525,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 === 203 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 205 /* 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 @@ -69004,7 +71579,7 @@ var ts; var min_3 = Number.MAX_VALUE; var minIndex = 0; var i_1 = 0; - var _loop_21 = function (c) { + var _loop_22 = 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); if (diags_2) { @@ -69022,7 +71597,7 @@ var ts; }; for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) { var c = candidatesForArgumentError_1[_a]; - _loop_21(c); + _loop_22(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"); @@ -69180,7 +71755,7 @@ var ts; } var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max; var parameters = []; - var _loop_22 = function (i) { + var _loop_23 = 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; }); @@ -69188,7 +71763,7 @@ var ts; parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); }))); }; for (var i = 0; i < maxNonRestParam; i++) { - _loop_22(i); + _loop_23(i); } var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; }); var flags = 0 /* None */; @@ -69269,7 +71844,7 @@ var ts; return maxParamsIndex; } function resolveCallExpression(node, candidatesOutArray, checkMode) { - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (isTypeAny(superType)) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { @@ -69380,7 +71955,7 @@ 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 */ | 131072 /* Never */)) && isTypeAssignableTo(funcType, globalFunctionType); + !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & 1048576 /* Union */) && !(getReducedType(apparentFuncType).flags & 131072 /* Never */) && isTypeAssignableTo(funcType, globalFunctionType); } function resolveNewExpression(node, candidatesOutArray, checkMode) { if (node.arguments && languageVersion < 1 /* ES5 */) { @@ -69495,7 +72070,7 @@ var ts; var declaration = signature.declaration; var modifiers = ts.getSelectedEffectiveModifierFlags(declaration, 24 /* NonPublicAccessibilityModifier */); // (1) Public constructors and (2) constructor functions are always accessible. - if (!modifiers || declaration.kind !== 166 /* Constructor */) { + if (!modifiers || declaration.kind !== 168 /* Constructor */) { return true; } var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(declaration.parent.symbol); @@ -69639,16 +72214,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 160 /* Parameter */: + case 162 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; default: return ts.Debug.fail(); @@ -69694,7 +72269,7 @@ var ts; // 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(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.factory.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.factory.createKeywordTypeNode(128 /* AnyKeyword */)); + var declaration = ts.factory.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.factory.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.factory.createKeywordTypeNode(129 /* AnyKeyword */)); var parameterSymbol = createSymbol(1 /* FunctionScopedVariable */, "props"); parameterSymbol.type = result; return createSignature(declaration, @@ -69743,16 +72318,16 @@ var ts; } function resolveSignature(node, candidatesOutArray, checkMode) { switch (node.kind) { - case 203 /* CallExpression */: + case 205 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray, checkMode); - case 204 /* NewExpression */: + case 206 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray, checkMode); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode); - case 161 /* Decorator */: + case 163 /* Decorator */: return resolveDecorator(node, candidatesOutArray, checkMode); - case 275 /* JsxOpeningElement */: - case 274 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode); } throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); @@ -69852,7 +72427,7 @@ var ts; else if (ts.isBinaryExpression(node.parent)) { var parentNode = node.parent; var parentNodeOperator = node.parent.operatorToken.kind; - if (parentNodeOperator === 62 /* EqualsToken */ && (allowDeclaration || parentNode.right === node)) { + if (parentNodeOperator === 63 /* EqualsToken */ && (allowDeclaration || parentNode.right === node)) { name = parentNode.left; decl = name; } @@ -69861,7 +72436,7 @@ var ts; name = parentNode.parent.name; decl = parentNode.parent; } - else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 62 /* EqualsToken */ && (allowDeclaration || parentNode.parent.right === parentNode)) { + else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 63 /* EqualsToken */ && (allowDeclaration || parentNode.parent.right === parentNode)) { name = parentNode.parent.left; decl = name; } @@ -69884,10 +72459,10 @@ var ts; return false; } var parent = node.parent; - while (parent && parent.kind === 201 /* PropertyAccessExpression */) { + while (parent && parent.kind === 203 /* PropertyAccessExpression */) { parent = parent.parent; } - if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 62 /* EqualsToken */) { + if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 63 /* EqualsToken */) { var right = ts.getInitializerOfBinaryExpression(parent); return ts.isObjectLiteralExpression(right) && right; } @@ -69908,15 +72483,15 @@ var ts; return nonInferrableType; } checkDeprecatedSignature(signature, node); - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { return voidType; } - if (node.kind === 204 /* NewExpression */) { + if (node.kind === 206 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 166 /* Constructor */ && - declaration.kind !== 170 /* ConstructSignature */ && - declaration.kind !== 175 /* ConstructorType */ && + declaration.kind !== 168 /* Constructor */ && + declaration.kind !== 172 /* ConstructSignature */ && + declaration.kind !== 177 /* ConstructorType */ && !ts.isJSDocConstructSignature(declaration) && !isJSConstructor(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any @@ -69936,7 +72511,7 @@ var ts; if (returnType.flags & 12288 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent)); } - if (node.kind === 203 /* CallExpression */ && node.parent.kind === 233 /* ExpressionStatement */ && + if (node.kind === 205 /* CallExpression */ && !node.questionDotToken && node.parent.kind === 235 /* ExpressionStatement */ && returnType.flags & 16384 /* 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); @@ -69950,7 +72525,7 @@ 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, undefined, undefined); - jsAssignmentType.objectFlags |= 16384 /* JSLiteral */; + jsAssignmentType.objectFlags |= 8192 /* JSLiteral */; return getIntersectionType([returnType, jsAssignmentType]); } } @@ -69959,26 +72534,27 @@ var ts; function checkDeprecatedSignature(signature, node) { if (signature.declaration && signature.declaration.flags & 134217728 /* Deprecated */) { var suggestionNode = getDeprecatedSuggestionNode(node); - errorOrSuggestion(/*isError*/ false, suggestionNode, ts.Diagnostics._0_is_deprecated, signatureToString(signature)); + var name = ts.tryGetPropertyAccessOrIdentifierToString(ts.getInvokedExpression(node)); + addDeprecatedSuggestionWithSignature(suggestionNode, signature.declaration, name, signatureToString(signature)); } } function getDeprecatedSuggestionNode(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 203 /* CallExpression */: - case 161 /* Decorator */: - case 204 /* NewExpression */: + case 205 /* CallExpression */: + case 163 /* Decorator */: + case 206 /* NewExpression */: return getDeprecatedSuggestionNode(node.expression); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return getDeprecatedSuggestionNode(node.tag); - case 275 /* JsxOpeningElement */: - case 274 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: return getDeprecatedSuggestionNode(node.tagName); - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: return node.argumentExpression; - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return node.name; - case 173 /* TypeReference */: + case 175 /* TypeReference */: var typeReference = node; return ts.isQualifiedName(typeReference.typeName) ? typeReference.typeName.right : typeReference; default: @@ -70029,10 +72605,11 @@ var ts; return createPromiseReturnType(node, anyType); } function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol) { + var _a; if (allowSyntheticDefaultImports && type && type !== errorType) { var synthType = type; if (!synthType.syntheticType) { - var file = ts.find(originalSymbol.declarations, ts.isSourceFile); + var file = (_a = originalSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, /*dontResolveAlias*/ false); if (hasSyntheticDefault) { var memberTable = ts.createSymbolTable(); @@ -70070,9 +72647,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 251 /* FunctionDeclaration */ + ? 253 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 249 /* VariableDeclaration */ + ? 251 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -70100,21 +72677,21 @@ var ts; case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: - case 199 /* ArrayLiteralExpression */: - case 200 /* ObjectLiteralExpression */: - case 218 /* TemplateExpression */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: + case 201 /* ArrayLiteralExpression */: + case 202 /* ObjectLiteralExpression */: + case 220 /* TemplateExpression */: return true; - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return isValidConstAssertionArgument(node.expression); - case 214 /* PrefixUnaryExpression */: + case 216 /* 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 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: var expr = node.expression; if (ts.isIdentifier(expr)) { var symbol = getSymbolAtLocation(expr); @@ -70156,10 +72733,10 @@ var ts; } function checkMetaProperty(node) { checkGrammarMetaProperty(node); - if (node.keywordToken === 102 /* NewKeyword */) { + if (node.keywordToken === 103 /* NewKeyword */) { return checkNewTargetMetaProperty(node); } - if (node.keywordToken === 99 /* ImportKeyword */) { + if (node.keywordToken === 100 /* ImportKeyword */) { return checkImportMetaProperty(node); } return ts.Debug.assertNever(node.keywordToken); @@ -70170,7 +72747,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 === 166 /* Constructor */) { + else if (container.kind === 168 /* Constructor */) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -70217,7 +72794,7 @@ var ts; return restParameter.escapedName; } function isValidDeclarationForTupleLabel(d) { - return d.kind === 192 /* NamedTupleMember */ || (ts.isParameter(d) && d.name && ts.isIdentifier(d.name)); + return d.kind === 194 /* NamedTupleMember */ || (ts.isParameter(d) && d.name && ts.isIdentifier(d.name)); } function getNameableDeclarationAtPosition(signature, pos) { var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); @@ -70382,7 +72959,14 @@ var ts; } } function assignContextualParameterTypes(signature, context) { - signature.typeParameters = context.typeParameters; + if (context.typeParameters) { + if (!signature.typeParameters) { + signature.typeParameters = context.typeParameters; + } + else { + return; // This signature has already has a contextual inference performed and cached on it! + } + } if (context.thisParameter) { var parameter = signature.thisParameter; if (!parameter || parameter.valueDeclaration && !parameter.valueDeclaration.type) { @@ -70423,7 +73007,7 @@ var ts; if (!links.type) { var declaration = parameter.valueDeclaration; links.type = type || getWidenedTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true); - if (declaration.name.kind !== 78 /* Identifier */) { + if (declaration.name.kind !== 79 /* 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); @@ -70438,7 +73022,7 @@ var ts; for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { var element = _a[_i]; if (!ts.isOmittedExpression(element)) { - if (element.name.kind === 78 /* Identifier */) { + if (element.name.kind === 79 /* Identifier */) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } else { @@ -70493,7 +73077,7 @@ var ts; var yieldType; var nextType; var fallbackReturnType = voidType; - if (func.body.kind !== 230 /* Block */) { // Async or normal arrow function + if (func.body.kind !== 232 /* Block */) { // Async or normal arrow function returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8 /* SkipGenericFunctions */); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any @@ -70678,7 +73262,7 @@ var ts; return links.isExhaustive !== undefined ? links.isExhaustive : (links.isExhaustive = computeExhaustiveSwitchStatement(node)); } function computeExhaustiveSwitchStatement(node) { - if (node.expression.kind === 211 /* TypeOfExpression */) { + if (node.expression.kind === 213 /* TypeOfExpression */) { var operandType = getTypeOfExpression(node.expression.expression); var witnesses = getSwitchClauseTypeOfWitnesses(node, /*retainDefault*/ false); // notEqualFacts states that the type of the switched value is not equal to every type in the switch. @@ -70741,11 +73325,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return true; - case 165 /* MethodDeclaration */: - return func.parent.kind === 200 /* ObjectLiteralExpression */; + case 167 /* MethodDeclaration */: + return func.parent.kind === 202 /* ObjectLiteralExpression */; default: return false; } @@ -70771,21 +73355,21 @@ var ts; } // 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 === 164 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 230 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 166 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 232 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 512 /* HasExplicitReturn */; + var errorNode = ts.getEffectiveReturnTypeNode(func) || func; if (type && type.flags & 131072 /* Never */) { - error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); + error(errorNode, ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); } else if (type && !hasExplicitReturn) { // minimal check: function has syntactic return type annotation and no explicit return statements in the body // this function does not conform to the specification. - // NOTE: having returnType !== undefined is a precondition for entering this branch so func.type will always be present - error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value); + error(errorNode, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value); } else if (type && strictNullChecks && !isTypeAssignableTo(undefinedType, type)) { - error(ts.getEffectiveReturnTypeNode(func) || func, ts.Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined); + error(errorNode, ts.Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined); } else if (compilerOptions.noImplicitReturns) { if (!type) { @@ -70800,11 +73384,11 @@ var ts; return; } } - error(ts.getEffectiveReturnTypeNode(func) || func, ts.Diagnostics.Not_all_code_paths_return_a_value); + error(errorNode, ts.Diagnostics.Not_all_code_paths_return_a_value); } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 165 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 167 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); checkNodeDeferred(node); // The identityMapper object is used to indicate that function expressions are wildcards if (checkMode && checkMode & 4 /* SkipContextSensitive */ && isContextSensitive(node)) { @@ -70820,7 +73404,7 @@ var ts; var returnType = getReturnTypeFromBody(node, checkMode); var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); var returnOnlyType = createAnonymousType(node.symbol, emptySymbols, [returnOnlySignature], ts.emptyArray, undefined, undefined); - returnOnlyType.objectFlags |= 2097152 /* NonInferrableType */; + returnOnlyType.objectFlags |= 524288 /* NonInferrableType */; return links.contextFreeType = returnOnlyType; } } @@ -70828,7 +73412,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 208 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 210 /* FunctionExpression */) { checkGrammarForGenerator(node); } contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -70874,7 +73458,7 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 165 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 167 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnType = getReturnTypeFromAnnotation(node); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); @@ -70887,7 +73471,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 230 /* Block */) { + if (node.body.kind === 232 /* Block */) { checkSourceElement(node.body); } else { @@ -70974,10 +73558,10 @@ var ts; // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && ts.isAccessExpression(expr) && - expr.expression.kind === 107 /* ThisKeyword */) { + expr.expression.kind === 108 /* 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 === 166 /* Constructor */ || isJSConstructor(ctor)))) { + if (!(ctor && (ctor.kind === 168 /* Constructor */ || isJSConstructor(ctor)))) { return true; } if (symbol.valueDeclaration) { @@ -70998,11 +73582,11 @@ var ts; if (ts.isAccessExpression(expr)) { // references through namespace import should be readonly var node = ts.skipParentheses(expr.expression); - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { var symbol_2 = getNodeLinks(node).resolvedSymbol; if (symbol_2.flags & 2097152 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol_2); - return !!declaration && declaration.kind === 263 /* NamespaceImport */; + return !!declaration && declaration.kind === 265 /* NamespaceImport */; } } } @@ -71011,7 +73595,7 @@ 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 !== 78 /* Identifier */ && !ts.isAccessExpression(node)) { + if (node.kind !== 79 /* Identifier */ && !ts.isAccessExpression(node)) { error(expr, invalidReferenceMessage); return false; } @@ -71083,7 +73667,7 @@ var ts; 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); var func = ts.getContainingFunction(node); - if (func && func.kind !== 166 /* Constructor */ && (ts.getFunctionFlags(func) & 2 /* Async */) === 0) { + if (func && func.kind !== 168 /* Constructor */ && (ts.getFunctionFlags(func) & 2 /* Async */) === 0) { var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); } @@ -71250,14 +73834,33 @@ var ts; rightType = checkNonNullType(rightType, right); // TypeScript 1.0 spec (April 2014): 4.15.5 // The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, - // and the right operand to be of type Any, an object type, or a type parameter type. + // and the right operand to be + // + // 1. assignable to the non-primitive type, + // 2. an unconstrained type parameter, + // 3. a union or intersection including one or more type parameters, whose constituents are all assignable to the + // the non-primitive type, or are unconstrainted type parameters, or have constraints assignable to the + // non-primitive type, or + // 4. a type parameter whose constraint is + // i. an object type, + // ii. the non-primitive type, or + // iii. a union or intersection with at least one constituent assignable to an object or non-primitive type. + // + // The divergent behavior for type parameters and unions containing type parameters is a workaround for type + // parameters not being narrowable. If the right operand is a concrete type, we can error if there is any chance + // it is a primitive. But if the operand is a type parameter, it cannot be narrowed, so we don't issue an error + // unless *all* instantiations would result in an error. + // // The result is always of the Boolean primitive type. if (!(allTypesAssignableToKind(leftType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) || isTypeAssignableToKind(leftType, 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 262144 /* TypeParameter */))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } - if (!allTypesAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */)) { - error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); + 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 */))) { + error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_not_be_a_primitive); } return booleanType; } @@ -71276,7 +73879,7 @@ var ts; if (rightIsThis === void 0) { rightIsThis = false; } var properties = node.properties; var property = properties[propertyIndex]; - if (property.kind === 288 /* PropertyAssignment */ || property.kind === 289 /* ShorthandPropertyAssignment */) { + if (property.kind === 290 /* PropertyAssignment */ || property.kind === 291 /* ShorthandPropertyAssignment */) { var name = property.name; var exprType = getLiteralTypeFromPropertyName(name); if (isTypeUsableAsPropertyName(exprType)) { @@ -71284,14 +73887,14 @@ var ts; var prop = getPropertyOfType(objectLiteralType, text); if (prop) { markPropertyAsReferenced(prop, property, rightIsThis); - checkPropertyAccessibility(property, /*isSuper*/ false, objectLiteralType, prop); + checkPropertyAccessibility(property, /*isSuper*/ false, /*writing*/ true, objectLiteralType, prop); } } - var elementType = getIndexedAccessType(objectLiteralType, exprType, /*noUncheckedIndexedAccessCandidate*/ undefined, name, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, 16 /* ExpressionPosition */); + var elementType = getIndexedAccessType(objectLiteralType, exprType, 32 /* ExpressionPosition */, name); var type = getFlowTypeOfDestructuring(property, elementType); - return checkDestructuringAssignment(property.kind === 289 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); + return checkDestructuringAssignment(property.kind === 291 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); } - else if (property.kind === 290 /* SpreadAssignment */) { + else if (property.kind === 292 /* SpreadAssignment */) { if (propertyIndex < properties.length - 1) { error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } @@ -71329,7 +73932,7 @@ var ts; var inBoundsType = compilerOptions.noUncheckedIndexedAccess ? undefined : possiblyOutOfBoundsType; for (var i = 0; i < elements.length; i++) { var type = possiblyOutOfBoundsType; - if (node.elements[i].kind === 220 /* SpreadElement */) { + if (node.elements[i].kind === 222 /* SpreadElement */) { type = inBoundsType = inBoundsType !== null && inBoundsType !== void 0 ? inBoundsType : (checkIteratedTypeOrElementType(65 /* Destructuring */, sourceType, undefinedType, node) || errorType); } checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, type, checkMode); @@ -71339,14 +73942,14 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 222 /* OmittedExpression */) { - if (element.kind !== 220 /* SpreadElement */) { + if (element.kind !== 224 /* OmittedExpression */) { + if (element.kind !== 222 /* SpreadElement */) { var indexType = getLiteralType(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 = 16 /* ExpressionPosition */ | (hasDefaultValue(element) ? 8 /* NoTupleBoundsCheck */ : 0); - var elementType_2 = getIndexedAccessTypeOrUndefined(sourceType, indexType, /*noUncheckedIndexedAccessCandidate*/ undefined, createSyntheticExpression(element, indexType), accessFlags) || errorType; + var accessFlags = 32 /* ExpressionPosition */ | (hasDefaultValue(element) ? 16 /* 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 type = getFlowTypeOfDestructuring(element, assignedType); return checkDestructuringAssignment(element, type, checkMode); @@ -71358,7 +73961,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 216 /* BinaryExpression */ && restExpression.operatorToken.kind === 62 /* EqualsToken */) { + if (restExpression.kind === 218 /* BinaryExpression */ && restExpression.operatorToken.kind === 63 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -71374,7 +73977,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) { var target; - if (exprOrAssignment.kind === 289 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 291 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove @@ -71390,24 +73993,24 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 216 /* BinaryExpression */ && target.operatorToken.kind === 62 /* EqualsToken */) { + if (target.kind === 218 /* BinaryExpression */ && target.operatorToken.kind === 63 /* EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 200 /* ObjectLiteralExpression */) { + if (target.kind === 202 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, rightIsThis); } - if (target.kind === 199 /* ArrayLiteralExpression */) { + if (target.kind === 201 /* 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 === 290 /* SpreadAssignment */ ? + var error = target.parent.kind === 292 /* 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 === 290 /* SpreadAssignment */ ? + var optionalError = target.parent.kind === 292 /* 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)) { @@ -71429,39 +74032,39 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: case 10 /* StringLiteral */: case 13 /* RegularExpressionLiteral */: - case 205 /* TaggedTemplateExpression */: - case 218 /* TemplateExpression */: + case 207 /* TaggedTemplateExpression */: + case 220 /* TemplateExpression */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: - case 103 /* NullKeyword */: - case 150 /* UndefinedKeyword */: - case 208 /* FunctionExpression */: - case 221 /* ClassExpression */: - case 209 /* ArrowFunction */: - case 199 /* ArrayLiteralExpression */: - case 200 /* ObjectLiteralExpression */: - case 211 /* TypeOfExpression */: - case 225 /* NonNullExpression */: - case 274 /* JsxSelfClosingElement */: - case 273 /* JsxElement */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: + case 104 /* NullKeyword */: + case 151 /* UndefinedKeyword */: + case 210 /* FunctionExpression */: + case 223 /* ClassExpression */: + case 211 /* ArrowFunction */: + case 201 /* ArrayLiteralExpression */: + case 202 /* ObjectLiteralExpression */: + case 213 /* TypeOfExpression */: + case 227 /* NonNullExpression */: + case 276 /* JsxSelfClosingElement */: + case 275 /* JsxElement */: return true; - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 214 /* PrefixUnaryExpression */: - case 215 /* PostfixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { @@ -71473,9 +74076,9 @@ var ts; } return false; // Some forms listed here for clarity - case 212 /* VoidExpression */: // Explicit opt-out - case 206 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 224 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 214 /* VoidExpression */: // Explicit opt-out + case 208 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 226 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } @@ -71483,84 +74086,111 @@ var ts; function isTypeEqualityComparableTo(source, target) { return (target.flags & 98304 /* Nullable */) !== 0 || isTypeComparableTo(source, target); } - var CheckBinaryExpressionState; - (function (CheckBinaryExpressionState) { - CheckBinaryExpressionState[CheckBinaryExpressionState["MaybeCheckLeft"] = 0] = "MaybeCheckLeft"; - CheckBinaryExpressionState[CheckBinaryExpressionState["CheckRight"] = 1] = "CheckRight"; - CheckBinaryExpressionState[CheckBinaryExpressionState["FinishCheck"] = 2] = "FinishCheck"; - })(CheckBinaryExpressionState || (CheckBinaryExpressionState = {})); - function checkBinaryExpression(node, checkMode) { - var workStacks = { - expr: [node], - state: [0 /* MaybeCheckLeft */], - leftType: [undefined] + function createCheckBinaryExpression() { + var trampoline = ts.createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, foldState); + return function (node, checkMode) { + var result = trampoline(node, checkMode); + ts.Debug.assertIsDefined(result); + return result; }; - var stackIndex = 0; - var lastResult; - while (stackIndex >= 0) { - node = workStacks.expr[stackIndex]; - switch (workStacks.state[stackIndex]) { - case 0 /* MaybeCheckLeft */: { - if (ts.isInJSFile(node) && ts.getAssignedExpandoInitializer(node)) { - finishInvocation(checkExpression(node.right, checkMode)); - break; - } - checkGrammarNullishCoalesceWithLogicalExpression(node); - var operator = node.operatorToken.kind; - if (operator === 62 /* EqualsToken */ && (node.left.kind === 200 /* ObjectLiteralExpression */ || node.left.kind === 199 /* ArrayLiteralExpression */)) { - finishInvocation(checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 107 /* ThisKeyword */)); - break; - } - advanceState(1 /* CheckRight */); - maybeCheckExpression(node.left); - break; - } - case 1 /* CheckRight */: { - var leftType = lastResult; - workStacks.leftType[stackIndex] = leftType; - var operator = node.operatorToken.kind; - if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { - if (operator === 55 /* AmpersandAmpersandToken */) { - var parent = ts.walkUpParenthesizedExpressions(node.parent); - checkTestingKnownTruthyCallableType(node.left, leftType, ts.isIfStatement(parent) ? parent.thenStatement : undefined); - } - checkTruthinessOfType(leftType, node.left); + function onEnter(node, state, checkMode) { + if (state) { + state.stackIndex++; + state.skip = false; + setLeftType(state, /*type*/ undefined); + setLastResult(state, /*type*/ undefined); + } + else { + state = { + checkMode: checkMode, + skip: false, + stackIndex: 0, + typeStack: [undefined, undefined], + }; + } + if (ts.isInJSFile(node) && ts.getAssignedExpandoInitializer(node)) { + state.skip = true; + setLastResult(state, checkExpression(node.right, checkMode)); + return state; + } + checkGrammarNullishCoalesceWithLogicalExpression(node); + var operator = node.operatorToken.kind; + if (operator === 63 /* EqualsToken */ && (node.left.kind === 202 /* ObjectLiteralExpression */ || node.left.kind === 201 /* ArrayLiteralExpression */)) { + state.skip = true; + setLastResult(state, checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 108 /* ThisKeyword */)); + return state; + } + return state; + } + function onLeft(left, state, _node) { + if (!state.skip) { + return maybeCheckExpression(state, left); + } + } + function onOperator(operatorToken, state, node) { + if (!state.skip) { + var leftType = getLastResult(state); + ts.Debug.assertIsDefined(leftType); + 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); + checkTestingKnownTruthyCallableOrAwaitableType(node.left, leftType, ts.isIfStatement(parent) ? parent.thenStatement : undefined); } - advanceState(2 /* FinishCheck */); - maybeCheckExpression(node.right); - break; + checkTruthinessOfType(leftType, node.left); } - case 2 /* FinishCheck */: { - var leftType = workStacks.leftType[stackIndex]; - var rightType = lastResult; - finishInvocation(checkBinaryLikeExpressionWorker(node.left, node.operatorToken, node.right, leftType, rightType, node)); - break; - } - default: return ts.Debug.fail("Invalid state " + workStacks.state[stackIndex] + " for checkBinaryExpression"); } } - return lastResult; - function finishInvocation(result) { - lastResult = result; - stackIndex--; - } - /** - * Note that `advanceState` sets the _current_ head state, and that `maybeCheckExpression` potentially pushes on a new - * head state; so `advanceState` must be called before any `maybeCheckExpression` during a state's execution. - */ - function advanceState(nextState) { - workStacks.state[stackIndex] = nextState; + function onRight(right, state, _node) { + if (!state.skip) { + return maybeCheckExpression(state, right); + } } - function maybeCheckExpression(node) { - if (ts.isBinaryExpression(node)) { - stackIndex++; - workStacks.expr[stackIndex] = node; - workStacks.state[stackIndex] = 0 /* MaybeCheckLeft */; - workStacks.leftType[stackIndex] = undefined; + function onExit(node, state) { + var result; + if (state.skip) { + result = getLastResult(state); } else { - lastResult = checkExpression(node, checkMode); + var leftType = getLeftType(state); + ts.Debug.assertIsDefined(leftType); + var rightType = getLastResult(state); + ts.Debug.assertIsDefined(rightType); + result = checkBinaryLikeExpressionWorker(node.left, node.operatorToken, node.right, leftType, rightType, node); + } + state.skip = false; + setLeftType(state, /*type*/ undefined); + setLastResult(state, /*type*/ undefined); + state.stackIndex--; + return result; + } + function foldState(state, result, _side) { + setLastResult(state, result); + return state; + } + function maybeCheckExpression(state, node) { + if (ts.isBinaryExpression(node)) { + return node; } + setLastResult(state, checkExpression(node, state.checkMode)); + } + function getLeftType(state) { + return state.typeStack[state.stackIndex]; + } + function setLeftType(state, type) { + state.typeStack[state.stackIndex] = type; + } + function getLastResult(state) { + return state.typeStack[state.stackIndex + 1]; + } + function setLastResult(state, type) { + // To reduce overhead, reuse the next stack entry to store the + // last result. This avoids the overhead of an additional property + // on `WorkArea` and reuses empty stack entries as we walk back up + // the stack. + state.typeStack[state.stackIndex + 1] = type; } } function checkGrammarNullishCoalesceWithLogicalExpression(node) { @@ -71578,8 +74208,8 @@ 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 === 62 /* EqualsToken */ && (left.kind === 200 /* ObjectLiteralExpression */ || left.kind === 199 /* ArrayLiteralExpression */)) { - return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 107 /* ThisKeyword */); + if (operator === 63 /* EqualsToken */ && (left.kind === 202 /* ObjectLiteralExpression */ || left.kind === 201 /* ArrayLiteralExpression */)) { + return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 108 /* ThisKeyword */); } var leftType; if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { @@ -71596,26 +74226,26 @@ var ts; switch (operator) { case 41 /* AsteriskToken */: case 42 /* AsteriskAsteriskToken */: - case 65 /* AsteriskEqualsToken */: - case 66 /* AsteriskAsteriskEqualsToken */: + case 66 /* AsteriskEqualsToken */: + case 67 /* AsteriskAsteriskEqualsToken */: case 43 /* SlashToken */: - case 67 /* SlashEqualsToken */: + case 68 /* SlashEqualsToken */: case 44 /* PercentToken */: - case 68 /* PercentEqualsToken */: + case 69 /* PercentEqualsToken */: case 40 /* MinusToken */: - case 64 /* MinusEqualsToken */: + case 65 /* MinusEqualsToken */: case 47 /* LessThanLessThanToken */: - case 69 /* LessThanLessThanEqualsToken */: + case 70 /* LessThanLessThanEqualsToken */: case 48 /* GreaterThanGreaterThanToken */: - case 70 /* GreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanEqualsToken */: case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: case 51 /* BarToken */: - case 73 /* BarEqualsToken */: + case 74 /* BarEqualsToken */: case 52 /* CaretToken */: - case 77 /* CaretEqualsToken */: + case 78 /* CaretEqualsToken */: case 50 /* AmpersandToken */: - case 72 /* AmpersandEqualsToken */: + case 73 /* AmpersandEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -71645,11 +74275,11 @@ var ts; else if (bothAreBigIntLike(leftType, rightType)) { switch (operator) { case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: reportOperatorError(); break; case 42 /* AsteriskAsteriskToken */: - case 66 /* AsteriskAsteriskEqualsToken */: + case 67 /* AsteriskAsteriskEqualsToken */: if (languageVersion < 3 /* ES2016 */) { error(errorNode, ts.Diagnostics.Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_later); } @@ -71667,7 +74297,7 @@ var ts; return resultType_1; } case 39 /* PlusToken */: - case 63 /* PlusEqualsToken */: + case 64 /* PlusEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -71710,7 +74340,7 @@ var ts; }); return anyType; } - if (operator === 63 /* PlusEqualsToken */) { + if (operator === 64 /* PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; @@ -71732,41 +74362,41 @@ var ts; case 37 /* ExclamationEqualsEqualsToken */: reportOperatorErrorUnless(function (left, right) { return isTypeEqualityComparableTo(left, right) || isTypeEqualityComparableTo(right, left); }); return booleanType; - case 101 /* InstanceOfKeyword */: + case 102 /* InstanceOfKeyword */: return checkInstanceOfExpression(left, right, leftType, rightType); - case 100 /* InKeyword */: + case 101 /* InKeyword */: return checkInExpression(left, right, leftType, rightType); case 55 /* AmpersandAmpersandToken */: - case 75 /* AmpersandAmpersandEqualsToken */: { + case 76 /* AmpersandAmpersandEqualsToken */: { var resultType_2 = getTypeFacts(leftType) & 4194304 /* Truthy */ ? getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) : leftType; - if (operator === 75 /* AmpersandAmpersandEqualsToken */) { + if (operator === 76 /* AmpersandAmpersandEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_2; } case 56 /* BarBarToken */: - case 74 /* BarBarEqualsToken */: { + case 75 /* BarBarEqualsToken */: { var resultType_3 = getTypeFacts(leftType) & 8388608 /* Falsy */ ? getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2 /* Subtype */) : leftType; - if (operator === 74 /* BarBarEqualsToken */) { + if (operator === 75 /* BarBarEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_3; } case 60 /* QuestionQuestionToken */: - case 76 /* QuestionQuestionEqualsToken */: { + case 77 /* QuestionQuestionEqualsToken */: { var resultType_4 = getTypeFacts(leftType) & 262144 /* EQUndefinedOrNull */ ? getUnionType([getNonNullableType(leftType), rightType], 2 /* Subtype */) : leftType; - if (operator === 76 /* QuestionQuestionEqualsToken */) { + if (operator === 77 /* QuestionQuestionEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_4; } - case 62 /* EqualsToken */: + case 63 /* EqualsToken */: var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0 /* None */; checkAssignmentDeclaration(declKind, rightType); if (isAssignmentDeclaration(declKind)) { @@ -71813,7 +74443,7 @@ var ts; if (propType.symbol && propType.symbol.flags & 32 /* Class */) { var name = prop.escapedName; var symbol = resolveName(prop.valueDeclaration, name, 788968 /* Type */, undefined, name, /*isUse*/ false); - if (symbol && symbol.declarations.some(ts.isJSDocTypedefTag)) { + 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); } @@ -71822,7 +74452,7 @@ var ts; } } function isEvalNode(node) { - return node.kind === 78 /* Identifier */ && node.escapedText === "eval"; + return node.kind === 79 /* Identifier */ && node.escapedText === "eval"; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { @@ -71838,13 +74468,13 @@ var ts; function getSuggestedBooleanOperator(operator) { switch (operator) { case 51 /* BarToken */: - case 73 /* BarEqualsToken */: + case 74 /* BarEqualsToken */: return 56 /* BarBarToken */; case 52 /* CaretToken */: - case 77 /* CaretEqualsToken */: + case 78 /* CaretEqualsToken */: return 37 /* ExclamationEqualsEqualsToken */; case 50 /* AmpersandToken */: - case 72 /* AmpersandEqualsToken */: + case 73 /* AmpersandEqualsToken */: return 55 /* AmpersandAmpersandToken */; default: return undefined; @@ -72008,7 +74638,7 @@ var ts; } function checkConditionalExpression(node, checkMode) { var type = checkTruthinessExpression(node.condition); - checkTestingKnownTruthyCallableType(node.condition, type, node.whenTrue); + checkTestingKnownTruthyCallableOrAwaitableType(node.condition, type, node.whenTrue); var type1 = checkExpression(node.whenTrue, checkMode); var type2 = checkExpression(node.whenFalse, checkMode); return getUnionType([type1, type2], 2 /* Subtype */); @@ -72025,10 +74655,14 @@ var ts; texts.push(span.literal.text); types.push(isTypeAssignableTo(type, templateConstraintType) ? type : stringType); } - return getFreshTypeOfLiteralType(getTemplateLiteralType(texts, types)); + return isConstContext(node) || someType(getContextualType(node) || 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 */)); } function getContextNode(node) { - if (node.kind === 281 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { + if (node.kind === 283 /* 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; @@ -72044,7 +74678,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, 134220672 /* FreshableLiteral */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ? + var result = maybeTypeOfKind(type, 2944 /* Literal */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ? getRegularTypeOfLiteralType(type) : type; return result; } @@ -72077,13 +74711,13 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 206 /* TypeAssertionExpression */ || node.kind === 224 /* AsExpression */; + return node.kind === 208 /* TypeAssertionExpression */ || node.kind === 226 /* AsExpression */; } function checkDeclarationInitializer(declaration, contextualType) { var initializer = ts.getEffectiveInitializer(declaration); var type = getQuickTypeOfExpression(initializer) || (contextualType ? checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, 0 /* Normal */) : checkExpressionCached(initializer)); - return ts.isParameter(declaration) && declaration.name.kind === 197 /* ArrayBindingPattern */ && + return ts.isParameter(declaration) && declaration.name.kind === 199 /* ArrayBindingPattern */ && isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ? padTupleType(type, declaration.name) : type; } @@ -72093,7 +74727,7 @@ 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 === 198 /* BindingElement */ && e.dotDotDotToken)) { + if (i < patternElements.length - 1 || !(e.kind === 200 /* BindingElement */ && e.dotDotDotToken)) { elementTypes.push(!ts.isOmittedExpression(e) && hasDefaultValue(e) ? getTypeFromBindingElement(e, /*includePatternInType*/ false, /*reportErrors*/ false) : anyType); elementFlags.push(2 /* Optional */); if (!ts.isOmittedExpression(e) && !hasDefaultValue(e)) { @@ -72106,7 +74740,7 @@ var ts; function widenTypeInferredFromInitializer(declaration, type) { var widened = ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || ts.isDeclarationReadonly(declaration) ? type : getWidenedLiteralType(type); if (ts.isInJSFile(declaration)) { - if (widened.flags & 98304 /* Nullable */) { + if (isEmptyLiteralType(widened)) { reportImplicitAny(declaration, anyType); return anyType; } @@ -72128,7 +74762,7 @@ var ts; // 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, 134217856 /* StringLikeLiteral */) || + 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 */) || @@ -72136,7 +74770,7 @@ var ts; } // 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 & (134217856 /* StringLikeLiteral */ | 4194304 /* Index */ | 268435456 /* StringMapping */) && maybeTypeOfKind(candidateType, 134217856 /* StringLikeLiteral */) || + 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 */) || @@ -72160,7 +74794,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 === 158 /* ComputedPropertyName */) { + if (node.name.kind === 160 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); @@ -72171,7 +74805,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 === 158 /* ComputedPropertyName */) { + if (node.name.kind === 160 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -72298,7 +74932,7 @@ var ts; len--; var s = baseName.slice(0, len); for (var index = 1; true; index++) { - var augmentedName = (s + index); + var augmentedName = s + index; if (!hasTypeParameterByName(typeParameters, augmentedName)) { return augmentedName; } @@ -72347,7 +74981,7 @@ var ts; var 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 !== 105 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { + if (ts.isCallExpression(expr) && expr.expression.kind !== 106 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { var type = ts.isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) : getReturnTypeOfSingleNonGenericCallSignature(checkNonNullExpression(expr.expression)); if (type) { @@ -72358,7 +74992,7 @@ var ts; return getTypeFromTypeNode(expr.type); } else if (node.kind === 8 /* NumericLiteral */ || node.kind === 10 /* StringLiteral */ || - node.kind === 109 /* TrueKeyword */ || node.kind === 94 /* FalseKeyword */) { + node.kind === 110 /* TrueKeyword */ || node.kind === 95 /* FalseKeyword */) { return checkExpression(node); } return undefined; @@ -72389,7 +75023,7 @@ var ts; } } function checkExpression(node, checkMode, forceTuple) { - ts.tracing.push("check" /* Check */, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end }); var saveCurrentNode = currentNode; currentNode = node; instantiationCount = 0; @@ -72399,7 +75033,7 @@ var ts; checkConstEnumAccess(node, type); } currentNode = saveCurrentNode; - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return type; } function checkConstEnumAccess(node, type) { @@ -72407,11 +75041,11 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 201 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 202 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 78 /* Identifier */ || node.kind === 157 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 176 /* TypeQuery */ && node.parent.exprName === node)) || - (node.parent.kind === 270 /* ExportSpecifier */); // We allow reexporting const enums + var ok = (node.parent.kind === 203 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 204 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 79 /* Identifier */ || node.kind === 159 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 178 /* TypeQuery */ && node.parent.exprName === node)) || + (node.parent.kind === 272 /* 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); } @@ -72426,7 +75060,7 @@ var ts; function checkParenthesizedExpression(node, checkMode) { var tag = ts.isInJSFile(node) ? ts.getJSDocTypeTag(node) : undefined; if (tag) { - return checkAssertionWorker(tag, tag.typeExpression.type, node.expression, checkMode); + return checkAssertionWorker(tag.typeExpression.type, tag.typeExpression.type, node.expression, checkMode); } return checkExpression(node.expression, checkMode); } @@ -72436,20 +75070,20 @@ 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 221 /* ClassExpression */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 223 /* ClassExpression */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 78 /* Identifier */: - return checkIdentifier(node); - case 107 /* ThisKeyword */: + case 79 /* Identifier */: + return checkIdentifier(node, checkMode); + case 108 /* ThisKeyword */: return checkThisExpression(node); - case 105 /* SuperKeyword */: + case 106 /* SuperKeyword */: return checkSuperExpression(node); - case 103 /* NullKeyword */: + case 104 /* NullKeyword */: return nullWideningType; case 14 /* NoSubstitutionTemplateLiteral */: case 10 /* StringLiteral */: @@ -72460,82 +75094,82 @@ var ts; case 9 /* BigIntLiteral */: checkGrammarBigIntLiteral(node); return getFreshTypeOfLiteralType(getBigIntLiteralType(node)); - case 109 /* TrueKeyword */: + case 110 /* TrueKeyword */: return trueType; - case 94 /* FalseKeyword */: + case 95 /* FalseKeyword */: return falseType; - case 218 /* TemplateExpression */: + case 220 /* TemplateExpression */: return checkTemplateExpression(node); case 13 /* RegularExpressionLiteral */: return globalRegExpType; - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode, forceTuple); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 201 /* PropertyAccessExpression */: - return checkPropertyAccessExpression(node); - case 157 /* QualifiedName */: - return checkQualifiedName(node); - case 202 /* ElementAccessExpression */: - return checkIndexedAccess(node); - case 203 /* CallExpression */: - if (node.expression.kind === 99 /* ImportKeyword */) { + case 203 /* PropertyAccessExpression */: + return checkPropertyAccessExpression(node, checkMode); + case 159 /* QualifiedName */: + return checkQualifiedName(node, checkMode); + case 204 /* ElementAccessExpression */: + return checkIndexedAccess(node, checkMode); + case 205 /* CallExpression */: + if (node.expression.kind === 100 /* ImportKeyword */) { return checkImportCallExpression(node); } // falls through - case 204 /* NewExpression */: + case 206 /* NewExpression */: return checkCallExpression(node, checkMode); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: return checkClassExpression(node); - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 211 /* TypeOfExpression */: + case 213 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 206 /* TypeAssertionExpression */: - case 224 /* AsExpression */: + case 208 /* TypeAssertionExpression */: + case 226 /* AsExpression */: return checkAssertion(node); - case 225 /* NonNullExpression */: + case 227 /* NonNullExpression */: return checkNonNullAssertion(node); - case 226 /* MetaProperty */: + case 228 /* MetaProperty */: return checkMetaProperty(node); - case 210 /* DeleteExpression */: + case 212 /* DeleteExpression */: return checkDeleteExpression(node); - case 212 /* VoidExpression */: + case 214 /* VoidExpression */: return checkVoidExpression(node); - case 213 /* AwaitExpression */: + case 215 /* AwaitExpression */: return checkAwaitExpression(node); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 220 /* SpreadElement */: + case 222 /* SpreadElement */: return checkSpreadExpression(node, checkMode); - case 222 /* OmittedExpression */: + case 224 /* OmittedExpression */: return undefinedWideningType; - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: return checkYieldExpression(node); - case 227 /* SyntheticExpression */: + case 229 /* SyntheticExpression */: return checkSyntheticExpression(node); - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: return checkJsxExpression(node, checkMode); - case 273 /* JsxElement */: + case 275 /* JsxElement */: return checkJsxElement(node, checkMode); - case 274 /* JsxSelfClosingElement */: + case 276 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 277 /* JsxFragment */: + case 279 /* JsxFragment */: return checkJsxFragment(node); - case 281 /* JsxAttributes */: + case 283 /* JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 275 /* JsxOpeningElement */: + case 277 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -72571,11 +75205,11 @@ var ts; checkGrammarDecoratorsAndModifiers(node); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); - if (ts.hasSyntacticModifier(node, 92 /* ParameterPropertyModifier */)) { - if (!(func.kind === 166 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */)) { + if (!(func.kind === 168 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } - if (func.kind === 166 /* Constructor */ && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") { + if (func.kind === 168 /* Constructor */ && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") { error(node.name, ts.Diagnostics.constructor_cannot_be_used_as_a_parameter_property_name); } } @@ -72586,13 +75220,13 @@ var ts; if (func.parameters.indexOf(node) !== 0) { error(node, ts.Diagnostics.A_0_parameter_must_be_the_first_parameter, node.name.escapedText); } - if (func.kind === 166 /* Constructor */ || func.kind === 170 /* ConstructSignature */ || func.kind === 175 /* ConstructorType */) { + if (func.kind === 168 /* Constructor */ || func.kind === 172 /* ConstructSignature */ || func.kind === 177 /* ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } - if (func.kind === 209 /* ArrowFunction */) { + if (func.kind === 211 /* ArrowFunction */) { error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter); } - if (func.kind === 167 /* GetAccessor */ || func.kind === 168 /* SetAccessor */) { + if (func.kind === 169 /* GetAccessor */ || func.kind === 170 /* SetAccessor */) { error(node, ts.Diagnostics.get_and_set_accessors_cannot_declare_this_parameters); } } @@ -72650,13 +75284,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 209 /* ArrowFunction */: - case 169 /* CallSignature */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 174 /* FunctionType */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 211 /* ArrowFunction */: + case 171 /* CallSignature */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 176 /* FunctionType */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: var parent = node.parent; if (node === parent.type) { return parent; @@ -72670,11 +75304,11 @@ var ts; continue; } var name = element.name; - if (name.kind === 78 /* Identifier */ && name.escapedText === predicateVariableName) { + if (name.kind === 79 /* 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 === 197 /* ArrayBindingPattern */ || name.kind === 196 /* ObjectBindingPattern */) { + else if (name.kind === 199 /* ArrayBindingPattern */ || name.kind === 198 /* ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -72683,13 +75317,13 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 171 /* IndexSignature */) { + if (node.kind === 173 /* 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 === 174 /* FunctionType */ || node.kind === 251 /* FunctionDeclaration */ || node.kind === 175 /* ConstructorType */ || - node.kind === 169 /* CallSignature */ || node.kind === 166 /* Constructor */ || - node.kind === 170 /* ConstructSignature */) { + else if (node.kind === 176 /* FunctionType */ || node.kind === 253 /* FunctionDeclaration */ || node.kind === 177 /* ConstructorType */ || + node.kind === 171 /* CallSignature */ || node.kind === 168 /* Constructor */ || + node.kind === 172 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); @@ -72719,10 +75353,10 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 170 /* ConstructSignature */: + case 172 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 169 /* CallSignature */: + case 171 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -72752,7 +75386,7 @@ var ts; checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 171 /* IndexSignature */ && node.kind !== 308 /* JSDocFunctionType */) { + if (node.kind !== 173 /* IndexSignature */ && node.kind !== 311 /* JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } @@ -72764,7 +75398,7 @@ 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 === 166 /* Constructor */) { + if (member.kind === 168 /* 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)) { @@ -72776,25 +75410,27 @@ var ts; var isStatic = ts.hasSyntacticModifier(member, 32 /* Static */); var name = member.name; if (!name) { - return; + continue; } - var names = ts.isPrivateIdentifier(name) ? privateIdentifiers : + var isPrivate = ts.isPrivateIdentifier(name); + var privateStaticFlags = isPrivate && isStatic ? 16 /* PrivateStatic */ : 0; + var names = isPrivate ? privateIdentifiers : isStatic ? staticNames : instanceNames; var memberName = name && ts.getPropertyNameForPropertyNameNode(name); if (memberName) { switch (member.kind) { - case 167 /* GetAccessor */: - addName(names, name, memberName, 1 /* GetAccessor */); + case 169 /* GetAccessor */: + addName(names, name, memberName, 1 /* GetAccessor */ | privateStaticFlags); break; - case 168 /* SetAccessor */: - addName(names, name, memberName, 2 /* SetAccessor */); + case 170 /* SetAccessor */: + addName(names, name, memberName, 2 /* SetAccessor */ | privateStaticFlags); break; - case 163 /* PropertyDeclaration */: - addName(names, name, memberName, 3 /* GetOrSetAccessor */); + case 165 /* PropertyDeclaration */: + addName(names, name, memberName, 3 /* GetOrSetAccessor */ | privateStaticFlags); break; - case 165 /* MethodDeclaration */: - addName(names, name, memberName, 8 /* Method */); + case 167 /* MethodDeclaration */: + addName(names, name, memberName, 8 /* Method */ | privateStaticFlags); break; } } @@ -72803,16 +75439,25 @@ var ts; function addName(names, location, name, meaning) { var prev = names.get(name); if (prev) { - if (prev & 8 /* Method */) { - if (meaning !== 8 /* Method */) { - error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); - } - } - else if (prev & meaning) { - error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); + // For private identifiers, do not allow mixing of static and instance members with the same name + if ((prev & 16 /* PrivateStatic */) !== (meaning & 16 /* PrivateStatic */)) { + error(location, ts.Diagnostics.Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name, ts.getTextOfNode(location)); } else { - names.set(name, prev | meaning); + var prevIsMethod = !!(prev & 8 /* Method */); + var isMethod = !!(meaning & 8 /* 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 */) { + error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); + } + else { + names.set(name, prev | meaning); + } } } else { @@ -72856,7 +75501,7 @@ 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 === 162 /* PropertySignature */) { + if (member.kind === 164 /* PropertySignature */) { var memberName = void 0; var name = member.name; switch (name.kind) { @@ -72864,7 +75509,7 @@ var ts; case 8 /* NumericLiteral */: memberName = name.text; break; - case 78 /* Identifier */: + case 79 /* Identifier */: memberName = ts.idText(name); break; default: @@ -72881,11 +75526,11 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 253 /* InterfaceDeclaration */) { + if (node.kind === 255 /* 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 - if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { + if (nodeSymbol.declarations && nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; } } @@ -72893,7 +75538,7 @@ var ts; // 3.7.4: An object type can contain at most one string index signature and one numeric index signature. // 8.5: A class declaration can have at most one string index member declaration and one numeric index member declaration var indexSymbol = getIndexSymbol(getSymbolOfNode(node)); - if (indexSymbol) { + if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) { var seenNumericIndexer = false; var seenStringIndexer = false; for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -72901,7 +75546,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 147 /* StringKeyword */: + case 148 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -72909,7 +75554,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 144 /* NumberKeyword */: + case 145 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -72927,11 +75572,13 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && !checkGrammarProperty(node)) checkGrammarComputedPropertyName(node.name); checkVariableLikeDeclaration(node); - // Private class fields transformation relies on WeakMaps. - if (ts.isPrivateIdentifier(node.name) && languageVersion < 99 /* ESNext */) { - for (var lexicalScope = ts.getEnclosingBlockScopeContainer(node); !!lexicalScope; lexicalScope = ts.getEnclosingBlockScopeContainer(lexicalScope)) { - getNodeLinks(lexicalScope).flags |= 67108864 /* ContainsClassWithPrivateIdentifiers */; - } + setNodeLinksForPrivateIdentifierScope(node); + if (ts.isPrivateIdentifier(node.name) && ts.hasStaticModifier(node) && node.initializer && languageVersion === 99 /* ESNext */ && !compilerOptions.useDefineForClassFields) { + error(node.initializer, ts.Diagnostics.Static_fields_with_private_names_can_t_have_initializers_when_the_useDefineForClassFields_flag_is_not_specified_with_a_target_of_esnext_Consider_adding_the_useDefineForClassFields_flag); + } + // property signatures already report "initializer not allowed in ambient context" elsewhere + if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 165 /* PropertyDeclaration */ && node.initializer) { + error(node, ts.Diagnostics.Property_0_cannot_have_an_initializer_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } function checkPropertySignature(node) { @@ -72944,16 +75591,34 @@ var ts; // Grammar checking if (!checkGrammarMethod(node)) checkGrammarComputedPropertyName(node.name); - if (ts.isPrivateIdentifier(node.name)) { - error(node, ts.Diagnostics.A_method_cannot_be_named_with_a_private_identifier); - } // Grammar checking for modifiers is done inside the function checkGrammarFunctionLikeDeclaration checkFunctionOrMethodDeclaration(node); - // Abstract methods cannot have an implementation. - // Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node. - if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 165 /* MethodDeclaration */ && node.body) { + // method signatures already report "implementation not allowed in ambient context" elsewhere + if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 167 /* 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 + if (ts.isPrivateIdentifier(node.name) && !ts.getContainingClass(node)) { + error(node, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); + } + setNodeLinksForPrivateIdentifierScope(node); + } + function setNodeLinksForPrivateIdentifierScope(node) { + if (ts.isPrivateIdentifier(node.name) && languageVersion < 99 /* ESNext */) { + for (var lexicalScope = ts.getEnclosingBlockScopeContainer(node); !!lexicalScope; lexicalScope = ts.getEnclosingBlockScopeContainer(lexicalScope)) { + getNodeLinks(lexicalScope).flags |= 67108864 /* 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 + // to transform private elements. + if (ts.isClassExpression(node.parent)) { + var enclosingIterationStatement = getEnclosingIterationStatement(node.parent); + if (enclosingIterationStatement) { + getNodeLinks(node.name).flags |= 524288 /* BlockScopedBindingInLoop */; + getNodeLinks(enclosingIterationStatement).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */; + } + } + } } function checkConstructorDeclaration(node) { // Grammar check on signature of constructor and modifier of the constructor is done in checkSignatureDeclaration function. @@ -72976,10 +75641,10 @@ var ts; return; } function isInstancePropertyWithInitializerOrPrivateIdentifierProperty(n) { - if (ts.isPrivateIdentifierPropertyDeclaration(n)) { + if (ts.isPrivateIdentifierClassElementDeclaration(n)) { return true; } - return n.kind === 163 /* PropertyDeclaration */ && + return n.kind === 165 /* PropertyDeclaration */ && !ts.hasSyntacticModifier(n, 32 /* Static */) && !!n.initializer; } @@ -73000,9 +75665,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 superCallShouldBeFirst = (compilerOptions.target !== 99 /* ESNext */ || !compilerOptions.useDefineForClassFields) && + var superCallShouldBeFirst = (compilerOptions.target !== 99 /* ESNext */ || !useDefineForClassFields) && (ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) || - ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 92 /* ParameterPropertyModifier */); })); + ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476 /* ParameterPropertyModifier */); })); // Skip past any prologue directives to find the first statement // to ensure that it was a super call. if (superCallShouldBeFirst) { @@ -73010,7 +75675,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_4 = statements; _i < statements_4.length; _i++) { var statement = statements_4[_i]; - if (statement.kind === 233 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 235 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -73035,7 +75700,7 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 167 /* GetAccessor */) { + if (node.kind === 169 /* GetAccessor */) { if (!(node.flags & 8388608 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* HasImplicitReturn */)) { if (!(node.flags & 512 /* HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); @@ -73045,45 +75710,42 @@ 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 === 158 /* ComputedPropertyName */) { + if (node.name.kind === 160 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } - if (ts.isPrivateIdentifier(node.name)) { - error(node.name, ts.Diagnostics.An_accessor_cannot_be_named_with_a_private_identifier); - } - if (!hasNonBindableDynamicName(node)) { + if (hasBindableName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. - var otherKind = node.kind === 167 /* GetAccessor */ ? 168 /* SetAccessor */ : 167 /* GetAccessor */; - var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); - if (otherAccessor) { - var nodeFlags = ts.getEffectiveModifierFlags(node); - var otherFlags = ts.getEffectiveModifierFlags(otherAccessor); - if ((nodeFlags & 28 /* AccessibilityModifier */) !== (otherFlags & 28 /* AccessibilityModifier */)) { - error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); + var symbol = getSymbolOfNode(node); + var getter = ts.getDeclarationOfKind(symbol, 169 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 170 /* SetAccessor */); + if (getter && setter && !(getNodeCheckFlags(getter) & 1 /* TypeChecked */)) { + getNodeLinks(getter).flags |= 1 /* TypeChecked */; + var getterFlags = ts.getEffectiveModifierFlags(getter); + var setterFlags = ts.getEffectiveModifierFlags(setter); + if ((getterFlags & 128 /* Abstract */) !== (setterFlags & 128 /* 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 */))) { + 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); } - if ((nodeFlags & 128 /* Abstract */) !== (otherFlags & 128 /* Abstract */)) { - error(node.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); + var getterType = getAnnotatedAccessorType(getter); + var setterType = getAnnotatedAccessorType(setter); + if (getterType && setterType) { + checkTypeAssignableTo(getterType, setterType, getter, ts.Diagnostics.The_return_type_of_a_get_accessor_must_be_assignable_to_its_set_accessor_type); } - // TypeScript 1.0 spec (April 2014): 4.5 - // If both accessors include type annotations, the specified types must be identical. - checkAccessorDeclarationTypesIdentical(node, otherAccessor, getAnnotatedAccessorType, ts.Diagnostics.get_and_set_accessor_must_have_the_same_type); - checkAccessorDeclarationTypesIdentical(node, otherAccessor, getThisTypeOfDeclaration, ts.Diagnostics.get_and_set_accessor_must_have_the_same_this_type); } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 167 /* GetAccessor */) { + if (node.kind === 169 /* GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } checkSourceElement(node.body); - } - function checkAccessorDeclarationTypesIdentical(first, second, getAnnotatedType, message) { - var firstType = getAnnotatedType(first); - var secondType = getAnnotatedType(second); - if (firstType && secondType && !isTypeIdenticalTo(firstType, secondType)) { - error(first, message); - } + setNodeLinksForPrivateIdentifierScope(node); } function checkMissingDeclaration(node) { checkDecorators(node); @@ -73120,7 +75782,7 @@ var ts; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 173 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 175 /* 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); @@ -73135,7 +75797,7 @@ var ts; var symbol = getNodeLinks(node).resolvedSymbol; if (symbol) { if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 134217728 /* Deprecated */); })) { - errorOrSuggestion(/* isError */ false, getDeprecatedSuggestionNode(node), ts.Diagnostics._0_is_deprecated, symbol.escapedName); + addDeprecatedSuggestion(getDeprecatedSuggestionNode(node), symbol.declarations, symbol.escapedName); } if (type.flags & 32 /* Enum */ && symbol.flags & 8 /* EnumMember */) { error(node, ts.Diagnostics.Enum_type_0_has_members_with_initializers_that_are_not_literals, typeToString(type)); @@ -73173,7 +75835,7 @@ 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 !== 192 /* NamedTupleMember */ && hasNamedElement) { + if (e.kind !== 194 /* NamedTupleMember */ && hasNamedElement) { grammarErrorOnNode(e, ts.Diagnostics.Tuple_members_must_all_have_names_or_all_not_have_names); break; } @@ -73222,7 +75884,7 @@ var ts; var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, /*stringsOnly*/ false))) { - if (accessNode.kind === 202 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 204 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && ts.getObjectFlags(objectType) & 32 /* Mapped */ && getMappedTypeModifiers(objectType) & 1 /* IncludeReadonly */) { error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); } @@ -73280,7 +75942,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 184 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 186 /* 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); @@ -73303,25 +75965,25 @@ var ts; if (node.dotDotDotToken && node.questionToken) { grammarErrorOnNode(node, ts.Diagnostics.A_tuple_member_cannot_be_both_optional_and_rest); } - if (node.type.kind === 180 /* OptionalType */) { + if (node.type.kind === 182 /* 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 === 181 /* RestType */) { + if (node.type.kind === 183 /* 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.isPrivateIdentifierPropertyDeclaration(node)) && !!(node.flags & 8388608 /* Ambient */); + return (ts.hasEffectiveModifier(node, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 8388608 /* 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 !== 253 /* InterfaceDeclaration */ && - n.parent.kind !== 252 /* ClassDeclaration */ && - n.parent.kind !== 221 /* ClassExpression */ && + if (n.parent.kind !== 255 /* InterfaceDeclaration */ && + n.parent.kind !== 254 /* ClassDeclaration */ && + n.parent.kind !== 223 /* ClassExpression */ && n.flags & 8388608 /* Ambient */) { if (!(flags & 2 /* 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 @@ -73417,7 +76079,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 === 165 /* MethodDeclaration */ || node.kind === 164 /* MethodSignature */) && + var reportError = (node.kind === 167 /* MethodDeclaration */ || node.kind === 166 /* MethodSignature */) && ts.hasSyntacticModifier(node, 32 /* Static */) !== ts.hasSyntacticModifier(subsequentNode, 32 /* Static */); // we can get here in two cases // 1. mixed static and instance class members @@ -73454,55 +76116,57 @@ var ts; var multipleConstructorImplementation = false; var hasNonAmbientClass = false; var functionDeclarations = []; - for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { - var current = declarations_4[_i]; - var node = current; - var inAmbientContext = node.flags & 8388608 /* Ambient */; - var inAmbientContextOrInterface = node.parent && (node.parent.kind === 253 /* InterfaceDeclaration */ || node.parent.kind === 177 /* TypeLiteral */) || inAmbientContext; - if (inAmbientContextOrInterface) { - // check if declarations are consecutive only if they are non-ambient - // 1. ambient declarations can be interleaved - // i.e. this is legal - // declare function foo(); - // declare function bar(); - // declare function foo(); - // 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 === 252 /* ClassDeclaration */ || node.kind === 221 /* ClassExpression */) && !inAmbientContext) { - hasNonAmbientClass = true; - } - if (node.kind === 251 /* FunctionDeclaration */ || node.kind === 165 /* MethodDeclaration */ || node.kind === 164 /* MethodSignature */ || node.kind === 166 /* Constructor */) { - functionDeclarations.push(node); - var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); - someNodeFlags |= currentNodeFlags; - allNodeFlags &= currentNodeFlags; - someHaveQuestionToken = someHaveQuestionToken || ts.hasQuestionToken(node); - allHaveQuestionToken = allHaveQuestionToken && ts.hasQuestionToken(node); - var bodyIsPresent = ts.nodeIsPresent(node.body); - if (bodyIsPresent && bodyDeclaration) { - if (isConstructor) { - multipleConstructorImplementation = true; + if (declarations) { + for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { + var current = declarations_4[_i]; + var node = current; + var inAmbientContext = node.flags & 8388608 /* Ambient */; + var inAmbientContextOrInterface = node.parent && (node.parent.kind === 255 /* InterfaceDeclaration */ || node.parent.kind === 179 /* TypeLiteral */) || inAmbientContext; + if (inAmbientContextOrInterface) { + // check if declarations are consecutive only if they are non-ambient + // 1. ambient declarations can be interleaved + // i.e. this is legal + // declare function foo(); + // declare function bar(); + // declare function foo(); + // 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 === 254 /* ClassDeclaration */ || node.kind === 223 /* ClassExpression */) && !inAmbientContext) { + hasNonAmbientClass = true; + } + if (node.kind === 253 /* FunctionDeclaration */ || node.kind === 167 /* MethodDeclaration */ || node.kind === 166 /* MethodSignature */ || node.kind === 168 /* Constructor */) { + functionDeclarations.push(node); + var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); + someNodeFlags |= currentNodeFlags; + allNodeFlags &= currentNodeFlags; + someHaveQuestionToken = someHaveQuestionToken || ts.hasQuestionToken(node); + allHaveQuestionToken = allHaveQuestionToken && ts.hasQuestionToken(node); + var bodyIsPresent = ts.nodeIsPresent(node.body); + if (bodyIsPresent && bodyDeclaration) { + if (isConstructor) { + multipleConstructorImplementation = true; + } + else { + duplicateFunctionDeclaration = true; + } + } + else if ((previousDeclaration === null || previousDeclaration === void 0 ? void 0 : previousDeclaration.parent) === node.parent && previousDeclaration.end !== node.pos) { + reportImplementationExpectedError(previousDeclaration); + } + if (bodyIsPresent) { + if (!bodyDeclaration) { + bodyDeclaration = node; + } } else { - duplicateFunctionDeclaration = true; + hasOverloads = true; } - } - else if ((previousDeclaration === null || previousDeclaration === void 0 ? void 0 : previousDeclaration.parent) === node.parent && previousDeclaration.end !== node.pos) { - reportImplementationExpectedError(previousDeclaration); - } - if (bodyIsPresent) { - if (!bodyDeclaration) { - bodyDeclaration = node; + previousDeclaration = node; + if (!inAmbientContextOrInterface) { + lastSeenNonAmbientDeclaration = node; } } - else { - hasOverloads = true; - } - previousDeclaration = node; - if (!inAmbientContextOrInterface) { - lastSeenNonAmbientDeclaration = node; - } } } if (multipleConstructorImplementation) { @@ -73515,13 +76179,18 @@ var ts; error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Duplicate_function_implementation); }); } - if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 /* Function */) { - // A non-ambient class cannot be an implementation for a non-constructor function/class merge - // TODO: The below just replicates our older error from when classes and functions were - // entirely unable to merge - a more helpful message like "Class declaration cannot implement overload list" - // might be warranted. :shrug: + if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 /* Function */ && declarations) { + var relatedDiagnostics_1 = ts.filter(declarations, function (d) { return d.kind === 254 /* ClassDeclaration */; }) + .map(function (d) { return ts.createDiagnosticForNode(d, ts.Diagnostics.Consider_adding_a_declare_modifier_to_this_class); }); ts.forEach(declarations, function (declaration) { - addDuplicateDeclarationError(declaration, ts.Diagnostics.Duplicate_identifier_0, ts.symbolName(symbol), declarations); + var diagnostic = declaration.kind === 254 /* ClassDeclaration */ + ? ts.Diagnostics.Class_declaration_cannot_implement_overload_list_for_0 + : declaration.kind === 253 /* FunctionDeclaration */ + ? ts.Diagnostics.Function_with_bodies_can_only_merge_with_classes_that_are_ambient + : undefined; + if (diagnostic) { + ts.addRelatedInfo.apply(void 0, __spreadArray([error(ts.getNameOfDeclaration(declaration) || declaration, diagnostic, ts.symbolName(symbol))], relatedDiagnostics_1)); + } }); } // Abstract methods can't have an implementation -- in particular, they don't need one. @@ -73530,8 +76199,10 @@ var ts; reportImplementationExpectedError(lastSeenNonAmbientDeclaration); } if (hasOverloads) { - checkFlagAgreementBetweenOverloads(declarations, bodyDeclaration, flagsToCheck, someNodeFlags, allNodeFlags); - checkQuestionTokenAgreementBetweenOverloads(declarations, bodyDeclaration, someHaveQuestionToken, allHaveQuestionToken); + if (declarations) { + checkFlagAgreementBetweenOverloads(declarations, bodyDeclaration, flagsToCheck, someNodeFlags, allNodeFlags); + checkQuestionTokenAgreementBetweenOverloads(declarations, bodyDeclaration, someHaveQuestionToken, allHaveQuestionToken); + } if (bodyDeclaration) { var signatures = getSignaturesOfSymbol(symbol); var bodySignature = getSignatureFromDeclaration(bodyDeclaration); @@ -73605,44 +76276,47 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: // A jsdoc typedef and callback are, by definition, type aliases. // falls through - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 325 /* JSDocEnumTag */: + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + case 333 /* JSDocEnumTag */: return 2 /* ExportType */; - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4 /* ExportNamespace */ | 1 /* ExportValue */ : 4 /* ExportNamespace */; - case 252 /* ClassDeclaration */: - case 255 /* EnumDeclaration */: - case 291 /* EnumMember */: + case 254 /* ClassDeclaration */: + case 257 /* EnumDeclaration */: + case 293 /* EnumMember */: return 2 /* ExportType */ | 1 /* ExportValue */; - case 297 /* SourceFile */: + case 299 /* SourceFile */: return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: + case 218 /* 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(d.expression)) { + if (!ts.isEntityNameExpression(expression)) { return 1 /* ExportValue */; } - d = d.expression; + d = expression; // The below options all declare an Alias, which is allowed to merge with other values within the importing module. // falls through - case 260 /* ImportEqualsDeclaration */: - case 263 /* NamespaceImport */: - case 262 /* ImportClause */: + case 262 /* ImportEqualsDeclaration */: + case 265 /* NamespaceImport */: + case 264 /* ImportClause */: var result_12 = 0 /* None */; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_12 |= getDeclarationSpaces(d); }); return result_12; - case 249 /* VariableDeclaration */: - case 198 /* BindingElement */: - case 251 /* FunctionDeclaration */: - case 265 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 - case 78 /* Identifier */: // https://github.com/microsoft/TypeScript/issues/36098 + case 251 /* VariableDeclaration */: + case 200 /* BindingElement */: + case 253 /* FunctionDeclaration */: + case 267 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 79 /* 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) @@ -73894,7 +76568,7 @@ var ts; var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* Value */, /*ignoreErrors*/ true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; if (promiseConstructorType === errorType) { - if (promiseConstructorName.kind === 78 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { + if (promiseConstructorName.kind === 79 /* 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 { @@ -73934,24 +76608,24 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 160 /* Parameter */: + case 162 /* Parameter */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages( /*details*/ undefined, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages( /*details*/ undefined, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -73972,7 +76646,7 @@ var ts; if (!typeName) return; var rootName = ts.getFirstIdentifier(typeName); - var meaning = (typeName.kind === 78 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; + var meaning = (typeName.kind === 79 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isRefernce*/ true); if (rootSymbol && rootSymbol.flags & 2097152 /* Alias */ @@ -73998,15 +76672,15 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 183 /* IntersectionType */: - case 182 /* UnionType */: + case 185 /* IntersectionType */: + case 184 /* UnionType */: return getEntityNameForDecoratorMetadataFromTypeList(node.types); - case 184 /* ConditionalType */: + case 186 /* ConditionalType */: return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]); - case 186 /* ParenthesizedType */: - case 192 /* NamedTupleMember */: + case 188 /* ParenthesizedType */: + case 194 /* NamedTupleMember */: return getEntityNameForDecoratorMetadata(node.type); - case 173 /* TypeReference */: + case 175 /* TypeReference */: return node.typeName; } } @@ -74015,13 +76689,13 @@ var ts; var commonEntityName; for (var _i = 0, types_23 = types; _i < types_23.length; _i++) { var typeNode = types_23[_i]; - while (typeNode.kind === 186 /* ParenthesizedType */ || typeNode.kind === 192 /* NamedTupleMember */) { + while (typeNode.kind === 188 /* ParenthesizedType */ || typeNode.kind === 194 /* NamedTupleMember */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 141 /* NeverKeyword */) { + if (typeNode.kind === 142 /* NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 191 /* LiteralType */ && typeNode.literal.kind === 103 /* NullKeyword */ || typeNode.kind === 150 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 193 /* LiteralType */ && typeNode.literal.kind === 104 /* NullKeyword */ || typeNode.kind === 151 /* 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); @@ -74067,14 +76741,14 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 160 /* Parameter */) { + if (node.kind === 162 /* Parameter */) { checkExternalEmitHelpers(firstDecorator, 32 /* Param */); } if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16 /* 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 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -74083,23 +76757,23 @@ var ts; } } break; - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - var otherKind = node.kind === 167 /* GetAccessor */ ? 168 /* SetAccessor */ : 167 /* GetAccessor */; + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + var otherKind = node.kind === 169 /* GetAccessor */ ? 170 /* SetAccessor */ : 169 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); break; - case 165 /* MethodDeclaration */: + case 167 /* 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 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 160 /* Parameter */: + case 162 /* Parameter */: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -74162,7 +76836,7 @@ var ts; else if (ts.findLast(ts.getJSDocTags(decl), ts.isJSDocParameterTag) === node && node.typeExpression && node.typeExpression.type && !isArrayType(getTypeFromTypeNode(node.typeExpression.type))) { - error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 157 /* QualifiedName */ ? node.name.right : node.name)); + error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 159 /* QualifiedName */ ? node.name.right : node.name)); } } } @@ -74204,27 +76878,28 @@ var ts; } function getIdentifierFromEntityNameExpression(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return node; - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return node.name; default: return undefined; } } function checkFunctionOrMethodDeclaration(node) { + var _a; checkDecorators(node); checkSignatureDeclaration(node); var functionFlags = ts.getFunctionFlags(node); // 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 === 158 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 160 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); } - if (!hasNonBindableDynamicName(node)) { + if (hasBindableName(node)) { // first we want to check the local symbol that contain this declaration // - if node.localSymbol !== undefined - this is current declaration is exported and localSymbol points to the local symbol // - if node.localSymbol === undefined - this node is non-exported so we can just pick the result of getSymbolOfNode @@ -74233,7 +76908,7 @@ var ts; // Since the javascript won't do semantic analysis like typescript, // if the javascript file comes before the typescript file and both contain same name functions, // checkFunctionOrConstructorSymbol wouldn't be called if we didnt ignore javascript function. - var firstDeclaration = ts.find(localSymbol.declarations, + 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 & 131072 /* JavaScriptFile */); }); // Only type check the symbol once @@ -74245,7 +76920,7 @@ var ts; checkFunctionOrConstructorSymbol(symbol); } } - var body = node.kind === 164 /* MethodSignature */ ? undefined : node.body; + var body = node.kind === 166 /* MethodSignature */ ? undefined : node.body; checkSourceElement(body); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node)); if (produceDiagnostics && !ts.getEffectiveReturnTypeNode(node)) { @@ -74287,42 +76962,42 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 297 /* SourceFile */: - case 256 /* ModuleDeclaration */: - case 230 /* Block */: - case 258 /* CaseBlock */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: + case 299 /* SourceFile */: + case 258 /* ModuleDeclaration */: + case 232 /* Block */: + case 260 /* CaseBlock */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 166 /* Constructor */: - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 168 /* Constructor */: + case 210 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 211 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: if (node.body) { // Don't report unused parameters in overloads checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 164 /* MethodSignature */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 254 /* TypeAliasDeclaration */: - case 253 /* InterfaceDeclaration */: + case 166 /* MethodSignature */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: + case 256 /* TypeAliasDeclaration */: + case 255 /* InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 185 /* InferType */: + case 187 /* InferType */: checkUnusedInferTypeParameter(node, addDiagnostic); break; default: @@ -74342,11 +77017,11 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 165 /* MethodDeclaration */: - case 163 /* PropertyDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - if (member.kind === 168 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { + case 167 /* MethodDeclaration */: + case 165 /* PropertyDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + if (member.kind === 170 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { // Already would have reported an error on the getter. break; } @@ -74357,7 +77032,7 @@ var ts; addDiagnostic(member, 0 /* Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); } break; - case 166 /* Constructor */: + case 168 /* 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 */)) { @@ -74365,8 +77040,8 @@ var ts; } } break; - case 171 /* IndexSignature */: - case 229 /* SemicolonClassElement */: + case 173 /* IndexSignature */: + case 231 /* SemicolonClassElement */: // Can't be private break; default: @@ -74383,7 +77058,8 @@ var ts; function checkUnusedTypeParameters(node, addDiagnostic) { // Only report errors on the last declaration for the type parameter container; // this ensures that all uses have been accounted for. - if (ts.last(getSymbolOfNode(node).declarations) !== node) + var declarations = getSymbolOfNode(node).declarations; + if (!declarations || ts.last(declarations) !== node) return; var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); var seenParentsWithEveryUnused = new ts.Set(); @@ -74393,7 +77069,7 @@ var ts; continue; var name = ts.idText(typeParameter.name); var parent = typeParameter.parent; - if (parent.kind !== 185 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { + if (parent.kind !== 187 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { if (ts.tryAddToSet(seenParentsWithEveryUnused, parent)) { var sourceFile = ts.getSourceFileOfNode(parent); var range = ts.isJSDocTemplateTag(parent) @@ -74402,12 +77078,14 @@ var ts; // Include the `<>` in the error message : ts.rangeOfTypeParameters(sourceFile, parent.typeParameters); var only = parent.typeParameters.length === 1; + //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)); } } 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)); } } @@ -74429,11 +77107,15 @@ var ts; return ts.tryCast(ts.getRootDeclaration(node), ts.isParameter); } function isValidUnusedLocalDeclaration(declaration) { - if (ts.isBindingElement(declaration) && isIdentifierThatStartsWithUnderscore(declaration.name)) { - return !!ts.findAncestor(declaration.parent, function (ancestor) { - return ts.isArrayBindingPattern(ancestor) || ts.isVariableDeclaration(ancestor) || ts.isVariableDeclarationList(ancestor) ? false : - ts.isForOfStatement(ancestor) ? true : "quit"; - }); + if (ts.isBindingElement(declaration)) { + if (ts.isObjectBindingPattern(declaration.parent)) { + /** + * ignore starts with underscore names _ + * const { a: _a } = { a: 1 } + */ + return !!(declaration.propertyName && isIdentifierThatStartsWithUnderscore(declaration.name)); + } + return isIdentifierThatStartsWithUnderscore(declaration.name); } return ts.isAmbientModule(declaration) || (ts.isVariableDeclaration(declaration) && ts.isForInOrOfStatement(declaration.parent.parent) || isImportedDeclaration(declaration)) && isIdentifierThatStartsWithUnderscore(declaration.name); @@ -74449,39 +77131,41 @@ var ts; if (local.flags & 262144 /* TypeParameter */ ? !(local.flags & 3 /* Variable */ && !(local.isReferenced & 3 /* Variable */)) : local.isReferenced || local.exportSymbol) { return; } - for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (isValidUnusedLocalDeclaration(declaration)) { - continue; - } - if (isImportedDeclaration(declaration)) { - addToGroup(unusedImports, importClauseFromImported(declaration), declaration, getNodeId); - } - else if (ts.isBindingElement(declaration) && ts.isObjectBindingPattern(declaration.parent)) { - // In `{ a, ...b }, `a` is considered used since it removes a property from `b`. `b` may still be unused though. - var lastElement = ts.last(declaration.parent.elements); - if (declaration === lastElement || !ts.last(declaration.parent.elements).dotDotDotToken) { - addToGroup(unusedDestructures, declaration.parent, declaration, getNodeId); + if (local.declarations) { + for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (isValidUnusedLocalDeclaration(declaration)) { + continue; } - } - else if (ts.isVariableDeclaration(declaration)) { - addToGroup(unusedVariables, declaration.parent, declaration, getNodeId); - } - else { - var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); - var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration); - if (parameter && name) { - if (!ts.isParameterPropertyDeclaration(parameter, parameter.parent) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { - if (ts.isBindingElement(declaration) && ts.isArrayBindingPattern(declaration.parent)) { - 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))); - } + if (isImportedDeclaration(declaration)) { + addToGroup(unusedImports, importClauseFromImported(declaration), declaration, getNodeId); + } + else if (ts.isBindingElement(declaration) && ts.isObjectBindingPattern(declaration.parent)) { + // In `{ a, ...b }, `a` is considered used since it removes a property from `b`. `b` may still be unused though. + var lastElement = ts.last(declaration.parent.elements); + if (declaration === lastElement || !ts.last(declaration.parent.elements).dotDotDotToken) { + addToGroup(unusedDestructures, declaration.parent, declaration, getNodeId); } } + else if (ts.isVariableDeclaration(declaration)) { + addToGroup(unusedVariables, declaration.parent, declaration, getNodeId); + } else { - errorUnusedLocal(declaration, ts.symbolName(local), addDiagnostic); + var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); + var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration); + if (parameter && name) { + if (!ts.isParameterPropertyDeclaration(parameter, parameter.parent) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { + if (ts.isBindingElement(declaration) && ts.isArrayBindingPattern(declaration.parent)) { + 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))); + } + } + } + else { + errorUnusedLocal(declaration, ts.symbolName(local), addDiagnostic); + } } } } @@ -74491,7 +77175,7 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 263 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 265 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { addDiagnostic(importDecl, 0 /* Local */, unuseds.length === 1 @@ -74509,7 +77193,7 @@ var ts; var bindingPattern = _a[0], bindingElements = _a[1]; var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* Parameter */ : 0 /* Local */; if (bindingPattern.elements.length === bindingElements.length) { - if (bindingElements.length === 1 && bindingPattern.parent.kind === 249 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 250 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 251 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 252 /* VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -74530,7 +77214,7 @@ var ts; if (declarationList.declarations.length === declarations.length) { addDiagnostic(declarationList, 0 /* 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 === 232 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 234 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { @@ -74542,24 +77226,24 @@ var ts; } function bindingNameText(name) { switch (name.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return ts.idText(name); - case 197 /* ArrayBindingPattern */: - case 196 /* ObjectBindingPattern */: + case 199 /* ArrayBindingPattern */: + case 198 /* ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 262 /* ImportClause */ || node.kind === 265 /* ImportSpecifier */ || node.kind === 263 /* NamespaceImport */; + return node.kind === 264 /* ImportClause */ || node.kind === 267 /* ImportSpecifier */ || node.kind === 265 /* NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 262 /* ImportClause */ ? decl : decl.kind === 263 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 264 /* ImportClause */ ? decl : decl.kind === 265 /* NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 230 /* Block */) { + if (node.kind === 232 /* Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -74589,12 +77273,12 @@ var ts; if (!(identifier && identifier.escapedText === name)) { return false; } - if (node.kind === 163 /* PropertyDeclaration */ || - node.kind === 162 /* PropertySignature */ || - node.kind === 165 /* MethodDeclaration */ || - node.kind === 164 /* MethodSignature */ || - node.kind === 167 /* GetAccessor */ || - node.kind === 168 /* SetAccessor */) { + if (node.kind === 165 /* PropertyDeclaration */ || + node.kind === 164 /* PropertySignature */ || + node.kind === 167 /* MethodDeclaration */ || + node.kind === 166 /* MethodSignature */ || + node.kind === 169 /* GetAccessor */ || + node.kind === 170 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -74603,7 +77287,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 160 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 162 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -74613,7 +77297,7 @@ var ts; function checkIfThisIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 78 /* Identifier */; + var isDeclaration_1 = node.kind !== 79 /* Identifier */; if (isDeclaration_1) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -74628,7 +77312,7 @@ var ts; function checkIfNewTargetIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 8 /* CaptureNewTarget */) { - var isDeclaration_2 = node.kind !== 78 /* Identifier */; + var isDeclaration_2 = node.kind !== 79 /* 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); } @@ -74640,10 +77324,11 @@ var ts; return false; }); } - function checkWeakMapCollision(node) { + function checkWeakMapSetCollision(node) { var enclosingBlockScope = ts.getEnclosingBlockScopeContainer(node); if (getNodeCheckFlags(enclosingBlockScope) & 67108864 /* ContainsClassWithPrivateIdentifiers */) { - errorSkippedOn("noEmit", node, ts.Diagnostics.Compiler_reserves_name_0_when_emitting_private_identifier_downlevel, "WeakMap"); + 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 checkCollisionWithRequireExportsInGeneratedCode(node, name) { @@ -74660,7 +77345,7 @@ var ts; } // 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 === 297 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 299 /* 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)); } @@ -74675,7 +77360,7 @@ var ts; } // 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 === 297 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* HasAsyncFunctions */) { + if (parent.kind === 299 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* 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)); } @@ -74710,7 +77395,7 @@ var ts; // 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 === 249 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 251 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -74722,17 +77407,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 250 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 232 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 252 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 234 /* 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 === 230 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 257 /* ModuleBlock */ || - container.kind === 256 /* ModuleDeclaration */ || - container.kind === 297 /* SourceFile */); + (container.kind === 232 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 259 /* ModuleBlock */ || + container.kind === 258 /* ModuleDeclaration */ || + container.kind === 299 /* 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 @@ -74763,18 +77448,18 @@ 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 === 158 /* ComputedPropertyName */) { + if (node.name.kind === 160 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 198 /* BindingElement */) { - if (node.parent.kind === 196 /* ObjectBindingPattern */ && languageVersion < 99 /* ESNext */) { + if (ts.isBindingElement(node)) { + if (ts.isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ES2018 */) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 158 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 160 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access @@ -74787,15 +77472,15 @@ var ts; var nameText = getPropertyNameFromType(exprType); var property = getPropertyOfType(parentType, nameText); if (property) { - markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined, /*isThisAccess*/ false); // A destructuring is never a write-only reference. - checkPropertyAccessibility(parent, !!parent.initializer && parent.initializer.kind === 105 /* SuperKeyword */, parentType, 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); } } } } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 197 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + if (node.name.kind === 199 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, 512 /* Read */); } ts.forEach(node.name.elements, checkSourceElement); @@ -74807,7 +77492,7 @@ var ts; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { - var needCheckInitializer = node.initializer && node.parent.parent.kind !== 238 /* ForInStatement */; + var needCheckInitializer = node.initializer && node.parent.parent.kind !== 240 /* ForInStatement */; var needCheckWidenedType = node.name.elements.length === 0; if (needCheckInitializer || needCheckWidenedType) { // Don't validate for-in initializer as it is already an error @@ -74835,7 +77520,7 @@ var ts; } // For a commonjs `const x = require`, validate the alias and exit var symbol = getSymbolOfNode(node); - if (symbol.flags & 2097152 /* Alias */ && ts.isRequireVariableDeclaration(node, /*requireStringLiteralLikeArgument*/ true)) { + if (symbol.flags & 2097152 /* Alias */ && ts.isRequireVariableDeclaration(node)) { checkAliasSymbol(node); return; } @@ -74849,11 +77534,11 @@ 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 !== 238 /* ForInStatement */) { + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 240 /* ForInStatement */) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); } } - if (symbol.declarations.length > 1) { + if (symbol.declarations && symbol.declarations.length > 1) { if (ts.some(symbol.declarations, function (d) { return d !== node && ts.isVariableLike(d) && !areDeclarationFlagsIdentical(d, node); })) { error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } @@ -74871,26 +77556,27 @@ var ts; if (node.initializer) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(node.initializer), declarationType, node, node.initializer, /*headMessage*/ undefined); } - if (!areDeclarationFlagsIdentical(node, symbol.valueDeclaration)) { + if (symbol.valueDeclaration && !areDeclarationFlagsIdentical(node, symbol.valueDeclaration)) { error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 163 /* PropertyDeclaration */ && node.kind !== 162 /* PropertySignature */) { + if (node.kind !== 165 /* PropertyDeclaration */ && node.kind !== 164 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 249 /* VariableDeclaration */ || node.kind === 198 /* BindingElement */) { + if (node.kind === 251 /* VariableDeclaration */ || node.kind === 200 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); - if (languageVersion < 99 /* ESNext */ && needCollisionCheckForIdentifier(node, node.name, "WeakMap")) { - potentialWeakMapCollisions.push(node); + if (languageVersion < 99 /* ESNext */ + && (needCollisionCheckForIdentifier(node, node.name, "WeakMap") || needCollisionCheckForIdentifier(node, node.name, "WeakSet"))) { + potentialWeakMapSetCollisions.push(node); } } } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 163 /* PropertyDeclaration */ || nextDeclaration.kind === 162 /* PropertySignature */ + var message = nextDeclaration.kind === 165 /* PropertyDeclaration */ || nextDeclaration.kind === 164 /* 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); @@ -74900,8 +77586,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 160 /* Parameter */ && right.kind === 249 /* VariableDeclaration */) || - (left.kind === 249 /* VariableDeclaration */ && right.kind === 160 /* Parameter */)) { + if ((left.kind === 162 /* Parameter */ && right.kind === 251 /* VariableDeclaration */) || + (left.kind === 251 /* VariableDeclaration */ && right.kind === 162 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -74917,10 +77603,10 @@ var ts; return ts.getSelectedEffectiveModifierFlags(left, interestingFlags) === ts.getSelectedEffectiveModifierFlags(right, interestingFlags); } function checkVariableDeclaration(node) { - ts.tracing.push("check" /* Check */, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end }); checkGrammarVariableDeclaration(node); checkVariableLikeDeclaration(node); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } function checkBindingElement(node) { checkGrammarBindingElement(node); @@ -74941,49 +77627,55 @@ var ts; // Grammar checking checkGrammarStatementInAmbientContext(node); var type = checkTruthinessExpression(node.expression); - checkTestingKnownTruthyCallableType(node.expression, type, node.thenStatement); + checkTestingKnownTruthyCallableOrAwaitableType(node.expression, type, node.thenStatement); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 231 /* EmptyStatement */) { + if (node.thenStatement.kind === 233 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); } - function checkTestingKnownTruthyCallableType(condExpr, type, body) { - if (!strictNullChecks) { + function checkTestingKnownTruthyCallableOrAwaitableType(condExpr, type, body) { + if (!strictNullChecks) + return; + if (getFalsyFlags(type)) return; - } var location = ts.isBinaryExpression(condExpr) ? condExpr.right : condExpr; var testedNode = ts.isIdentifier(location) ? location : ts.isPropertyAccessExpression(location) ? location.name : ts.isBinaryExpression(location) && ts.isIdentifier(location.right) ? location.right : undefined; - if (!testedNode) { - return; - } - var possiblyFalsy = getFalsyFlags(type); - if (possiblyFalsy) { + var isPropertyExpressionCast = ts.isPropertyAccessExpression(location) + && ts.isAssertionExpression(ts.skipParentheses(location.expression)); + if (!testedNode || isPropertyExpressionCast) { return; } // While it technically should be invalid for any known-truthy value - // to be tested, we de-scope to functions unrefenced 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. + // 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 */); - if (callSignatures.length === 0) { + var isPromise = !!getAwaitedTypeOfPromise(type); + if (callSignatures.length === 0 && !isPromise) { return; } var testedSymbol = getSymbolAtLocation(testedNode); if (!testedSymbol) { return; } - var isUsed = ts.isBinaryExpression(condExpr.parent) && isFunctionUsedInBinaryExpressionChain(condExpr.parent, testedSymbol) - || body && isFunctionUsedInConditionBody(condExpr, body, testedNode, testedSymbol); + var isUsed = ts.isBinaryExpression(condExpr.parent) && isSymbolUsedInBinaryExpressionChain(condExpr.parent, testedSymbol) + || body && isSymbolUsedInConditionBody(condExpr, body, testedNode, testedSymbol); if (!isUsed) { - error(location, ts.Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead); + if (isPromise) { + errorAndMaybeSuggestAwait(location, + /*maybeMissingAwait*/ true, ts.Diagnostics.This_condition_will_always_return_true_since_this_0_is_always_defined, getTypeNameForErrorDisplay(type)); + } + else { + error(location, ts.Diagnostics.This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_instead); + } } } - function isFunctionUsedInConditionBody(expr, body, testedNode, testedSymbol) { + function isSymbolUsedInConditionBody(expr, body, testedNode, testedSymbol) { return !!ts.forEachChild(body, function check(childNode) { if (ts.isIdentifier(childNode)) { var childSymbol = getSymbolAtLocation(childNode); @@ -74997,7 +77689,7 @@ var ts; var childExpression = childNode.parent; while (testedExpression && childExpression) { if (ts.isIdentifier(testedExpression) && ts.isIdentifier(childExpression) || - testedExpression.kind === 107 /* ThisKeyword */ && childExpression.kind === 107 /* ThisKeyword */) { + testedExpression.kind === 108 /* ThisKeyword */ && childExpression.kind === 108 /* ThisKeyword */) { return getSymbolAtLocation(testedExpression) === getSymbolAtLocation(childExpression); } else if (ts.isPropertyAccessExpression(testedExpression) && ts.isPropertyAccessExpression(childExpression)) { @@ -75020,7 +77712,7 @@ var ts; return ts.forEachChild(childNode, check); }); } - function isFunctionUsedInBinaryExpressionChain(node, testedSymbol) { + function isSymbolUsedInBinaryExpressionChain(node, testedSymbol) { while (ts.isBinaryExpression(node) && node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { var isUsed = ts.forEachChild(node.right, function visit(child) { if (ts.isIdentifier(child)) { @@ -75062,12 +77754,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 250 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 252 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 250 /* VariableDeclarationList */) { + if (node.initializer.kind === 252 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -75101,14 +77793,14 @@ var ts; // 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 === 250 /* VariableDeclarationList */) { + if (node.initializer.kind === 252 /* 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 === 199 /* ArrayLiteralExpression */ || varExpr.kind === 200 /* ObjectLiteralExpression */) { + if (varExpr.kind === 201 /* ArrayLiteralExpression */ || varExpr.kind === 202 /* 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. @@ -75140,7 +77832,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 === 250 /* VariableDeclarationList */) { + if (node.initializer.kind === 252 /* 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); @@ -75154,7 +77846,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 === 199 /* ArrayLiteralExpression */ || varExpr.kind === 200 /* ObjectLiteralExpression */) { + if (varExpr.kind === 201 /* ArrayLiteralExpression */ || varExpr.kind === 202 /* 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)) { @@ -75270,18 +77962,8 @@ 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 yieldType = getIterationTypeOfIterable(use, 0 /* Yield */, inputType, /*errorNode*/ undefined); - var _a = !(use & 4 /* AllowsStringInputFlag */) || hasStringConstituent - ? downlevelIteration - ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true] - : yieldType - ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false] - : [ts.Diagnostics.Type_0_is_not_an_array_type, true] - : downlevelIteration - ? [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] - : yieldType - ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false] - : [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type, true], defaultDiagnostic = _a[0], maybeMissingAwait = _a[1]; + var allowsStrings = !!(use & 4 /* AllowsStringInputFlag */) && !hasStringConstituent; + var _a = getIterationDiagnosticDetails(allowsStrings, downlevelIteration), defaultDiagnostic = _a[0], maybeMissingAwait = _a[1]; errorAndMaybeSuggestAwait(errorNode, maybeMissingAwait && !!getAwaitedTypeOfPromise(arrayType), defaultDiagnostic, typeToString(arrayType)); } return hasStringConstituent ? possibleOutOfBounds ? includeUndefinedInIndexSignature(stringType) : stringType : undefined; @@ -75295,6 +77977,40 @@ var ts; return getUnionType(possibleOutOfBounds ? [arrayElementType, stringType, undefinedType] : [arrayElementType, stringType], 2 /* Subtype */); } return (use & 128 /* PossiblyOutOfBounds */) ? includeUndefinedInIndexSignature(arrayElementType) : arrayElementType; + function getIterationDiagnosticDetails(allowsStrings, downlevelIteration) { + var _a; + if (downlevelIteration) { + return allowsStrings + ? [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); + if (yieldType) { + return [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false]; + } + if (isES2015OrLaterIterable((_a = inputType.symbol) === null || _a === void 0 ? void 0 : _a.escapedName)) { + return [ts.Diagnostics.Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher, true]; + } + return allowsStrings + ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type, true] + : [ts.Diagnostics.Type_0_is_not_an_array_type, true]; + } + } + function isES2015OrLaterIterable(n) { + switch (n) { + case "Float32Array": + case "Float64Array": + case "Int16Array": + case "Int32Array": + case "Int8Array": + case "NodeList": + case "Uint16Array": + case "Uint32Array": + case "Uint8Array": + case "Uint8ClampedArray": + return true; + } + return false; } /** * Gets the requested "iteration type" from an `Iterable`-like or `AsyncIterable`-like type. @@ -75538,6 +78254,11 @@ var ts; return setCachedIterationTypes(type, resolver.iterableCacheKey, createIterationTypes(yieldType, returnType, nextType)); } } + function getPropertyNameForKnownSymbolName(symbolName) { + var ctorType = getGlobalESSymbolConstructorSymbol(/*reportErrors*/ false); + var uniqueType = ctorType && getTypeOfPropertyOfType(getTypeOfSymbol(ctorType), ts.escapeLeadingUnderscores(symbolName)); + return uniqueType && isTypeUsableAsPropertyName(uniqueType) ? getPropertyNameFromType(uniqueType) : "__@" + symbolName; + } /** * Gets the *yield*, *return*, and *next* types of an `Iterable`-like or `AsyncIterable`-like * type from its members. @@ -75550,7 +78271,7 @@ var ts; */ function getIterationTypesOfIterableSlow(type, resolver, errorNode) { var _a; - var method = getPropertyOfType(type, ts.getPropertyNameForKnownSymbolName(resolver.iteratorSymbolName)); + var method = getPropertyOfType(type, getPropertyNameForKnownSymbolName(resolver.iteratorSymbolName)); var methodType = method && !(method.flags & 16777216 /* Optional */) ? getTypeOfSymbol(method) : undefined; if (isTypeAny(methodType)) { return setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes); @@ -75849,12 +78570,12 @@ var ts; var functionFlags = ts.getFunctionFlags(func); if (strictNullChecks || node.expression || returnType.flags & 131072 /* Never */) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; - if (func.kind === 168 /* SetAccessor */) { + if (func.kind === 170 /* SetAccessor */) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 166 /* Constructor */) { + else if (func.kind === 168 /* 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); } @@ -75872,7 +78593,7 @@ var ts; } } } - else if (func.kind !== 166 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 168 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, 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); } @@ -75901,7 +78622,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 === 285 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 287 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -75910,7 +78631,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 284 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 286 /* CaseClause */) { // TypeScript 1.0 spec (April 2014): 5.9 // In a 'switch' statement, each 'case' expression must be of a type that is comparable // to or from the type of the 'switch' expression. @@ -75942,7 +78663,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 245 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 247 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -75972,10 +78693,11 @@ var ts; // Grammar checking if (catchClause.variableDeclaration) { var declaration = catchClause.variableDeclaration; - if (declaration.type) { + var typeNode = ts.getEffectiveTypeAnnotationNode(ts.getRootDeclaration(declaration)); + if (typeNode) { var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false); if (type && !(type.flags & 3 /* AnyOrUnknown */)) { - grammarErrorOnFirstToken(declaration.type, ts.Diagnostics.Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified); + grammarErrorOnFirstToken(typeNode, ts.Diagnostics.Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified); } } else if (declaration.initializer) { @@ -75986,7 +78708,7 @@ var ts; if (blockLocals_1) { ts.forEachKey(catchClause.locals, function (caughtName) { var blockLocal = blockLocals_1.get(caughtName); - if (blockLocal && (blockLocal.flags & 2 /* BlockScopedVariable */) !== 0) { + if ((blockLocal === null || blockLocal === void 0 ? void 0 : blockLocal.valueDeclaration) && (blockLocal.flags & 2 /* BlockScopedVariable */) !== 0) { grammarErrorOnNode(blockLocal.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, caughtName); } }); @@ -75999,27 +78721,30 @@ var ts; checkBlock(node.finallyBlock); } } - function checkIndexConstraints(type) { - var declaredNumberIndexer = getIndexDeclarationOfSymbol(type.symbol, 1 /* Number */); - var declaredStringIndexer = getIndexDeclarationOfSymbol(type.symbol, 0 /* String */); + function checkIndexConstraints(type, isStatic) { + var _a, _b, _c, _d; + var declaredNumberIndexer = getIndexDeclarationOfSymbolTable(isStatic ? (_a = type.symbol) === null || _a === void 0 ? void 0 : _a.exports : (_b = type.symbol) === null || _b === void 0 ? void 0 : _b.members, 1 /* Number */); + var declaredStringIndexer = getIndexDeclarationOfSymbolTable(isStatic ? (_c = type.symbol) === null || _c === void 0 ? void 0 : _c.exports : (_d = type.symbol) === null || _d === void 0 ? void 0 : _d.members, 0 /* String */); var stringIndexType = getIndexTypeOfType(type, 0 /* String */); var numberIndexType = getIndexTypeOfType(type, 1 /* Number */); if (stringIndexType || numberIndexType) { ts.forEach(getPropertiesOfObjectType(type), function (prop) { - var propType = getTypeOfSymbol(prop); + if (isStatic && prop.flags & 4194304 /* Prototype */) + return; + var propType = getNonMissingTypeOfSymbol(prop); checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */); checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */); }); var classDeclaration = type.symbol.valueDeclaration; - if (ts.getObjectFlags(type) & 1 /* Class */ && ts.isClassLike(classDeclaration)) { - for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) { - var member = _a[_i]; + if (ts.getObjectFlags(type) & 1 /* Class */ && classDeclaration && ts.isClassLike(classDeclaration)) { + for (var _i = 0, _e = classDeclaration.members; _i < _e.length; _i++) { + var member = _e[_i]; // Only process instance properties with computed names here. // Static properties cannot be in conflict with indexers, // and properties with literal names were already checked. - if (!ts.hasSyntacticModifier(member, 32 /* Static */) && hasNonBindableDynamicName(member)) { + if (!ts.hasSyntacticModifier(member, 32 /* Static */) && !hasBindableName(member)) { var symbol = getSymbolOfNode(member); - var propType = getTypeOfSymbol(symbol); + var propType = getNonMissingTypeOfSymbol(symbol); checkIndexConstraintForProperty(symbol, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */); checkIndexConstraintForProperty(symbol, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */); } @@ -76032,7 +78757,7 @@ var ts; // condition 'errorNode === undefined' may appear if types does not declare nor string neither number indexer if (!errorNode && (ts.getObjectFlags(type) & 2 /* Interface */)) { var someBaseTypeHasBothIndexers = ts.forEach(getBaseTypes(type), function (base) { return getIndexTypeOfType(base, 0 /* String */) && getIndexTypeOfType(base, 1 /* Number */); }); - errorNode = someBaseTypeHasBothIndexers ? undefined : type.symbol.declarations[0]; + errorNode = someBaseTypeHasBothIndexers || !type.symbol.declarations ? undefined : type.symbol.declarations[0]; } } if (errorNode && !isTypeAssignableTo(numberIndexType, stringIndexType)) { // TODO: GH#18217 @@ -76056,8 +78781,8 @@ var ts; // this allows us to rule out cases when both property and indexer are inherited from the base class var errorNode; if (propDeclaration && name && - (propDeclaration.kind === 216 /* BinaryExpression */ || - name.kind === 158 /* ComputedPropertyName */ || + (propDeclaration.kind === 218 /* BinaryExpression */ || + name.kind === 160 /* ComputedPropertyName */ || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -76069,7 +78794,7 @@ var ts; // check if any base class already has both property and indexer. // check should be performed only if 'type' is the first type that brings property\indexer together var someBaseClassHasBothPropertyAndIndexer = ts.forEach(getBaseTypes(containingType), function (base) { return getPropertyOfObjectType(base, prop.escapedName) && getIndexTypeOfType(base, indexKind); }); - errorNode = someBaseClassHasBothPropertyAndIndexer ? undefined : containingType.symbol.declarations[0]; + errorNode = someBaseClassHasBothPropertyAndIndexer || !containingType.symbol.declarations ? undefined : containingType.symbol.declarations[0]; } if (errorNode && !isTypeAssignableTo(propertyType, indexType)) { var errorMessage = indexKind === 0 /* String */ @@ -76085,6 +78810,7 @@ var ts; switch (name.escapedText) { case "any": case "unknown": + case "never": case "number": case "bigint": case "boolean": @@ -76134,7 +78860,7 @@ var ts; function checkTypeParametersNotReferenced(root, typeParameters, index) { visit(root); function visit(node) { - if (node.kind === 173 /* TypeReference */) { + if (node.kind === 175 /* TypeReference */) { var type = getTypeFromTypeReference(node); if (type.flags & 262144 /* TypeParameter */) { for (var i = index; i < typeParameters.length; i++) { @@ -76149,14 +78875,14 @@ var ts; } /** Check that type parameter lists are identical across multiple declarations */ function checkTypeParameterListsIdentical(symbol) { - if (symbol.declarations.length === 1) { + if (symbol.declarations && symbol.declarations.length === 1) { return; } var links = getSymbolLinks(symbol); if (!links.typeParametersChecked) { links.typeParametersChecked = true; var declarations = getClassOrInterfaceDeclarationsOfSymbol(symbol); - if (declarations.length <= 1) { + if (!declarations || declarations.length <= 1) { return; } var type = getDeclaredTypeOfSymbol(symbol); @@ -76220,6 +78946,9 @@ var ts; registerForUnusedIdentifiersCheck(node); } function checkClassDeclaration(node) { + if (ts.some(node.decorators) && ts.some(node.members, function (p) { return ts.hasStaticModifier(p) && ts.isPrivateIdentifierClassElementDeclaration(p); })) { + grammarErrorOnNode(node.decorators[0], 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 */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } @@ -76248,7 +78977,8 @@ var ts; checkFunctionOrConstructorSymbol(symbol); checkClassForDuplicateDeclarations(node); // Only check for reserved static identifiers on non-ambient context. - if (!(node.flags & 8388608 /* Ambient */)) { + var nodeInAmbientContext = !!(node.flags & 8388608 /* Ambient */); + if (!nodeInAmbientContext) { checkClassForStaticPropertyNameConflicts(node); } var baseTypeNode = ts.getEffectiveBaseTypeNode(node); @@ -76308,6 +79038,7 @@ var ts; checkKindsOfPropertyMemberOverrides(type, baseType_1); } } + checkMembersForMissingOverrideModifier(node, type, typeWithThis, staticType); var implementedTypeNodes = ts.getEffectiveImplementsTypeNodes(node); if (implementedTypeNodes) { for (var _b = 0, implementedTypeNodes_1 = implementedTypeNodes; _b < implementedTypeNodes_1.length; _b++) { @@ -76337,14 +79068,79 @@ var ts; } if (produceDiagnostics) { checkIndexConstraints(type); + checkIndexConstraints(staticType, /*isStatic*/ true); checkTypeForDuplicateIndexSignatures(node); checkPropertyInitialization(node); } } + function checkMembersForMissingOverrideModifier(node, type, typeWithThis, staticType) { + var nodeInAmbientContext = !!(node.flags & 8388608 /* Ambient */); + var baseTypeNode = ts.getEffectiveBaseTypeNode(node); + 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_24 = function (member) { + if (ts.hasAmbientModifier(member)) { + return "continue"; + } + if (ts.isConstructorDeclaration(member)) { + ts.forEach(member.parameters, function (param) { + if (ts.isParameterPropertyDeclaration(param, member)) { + checkClassMember(param, /*memberIsParameterProperty*/ true); + } + }); + } + checkClassMember(member); + }; + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + _loop_24(member); + } + function checkClassMember(member, memberIsParameterProperty) { + var hasOverride = ts.hasOverrideModifier(member); + var hasStatic = ts.hasStaticModifier(member); + if (baseWithThis && (hasOverride || compilerOptions.noImplicitOverride)) { + var declaredProp = member.name && getSymbolAtLocation(member.name) || getSymbolAtLocation(member); + if (!declaredProp) { + return; + } + var thisType = hasStatic ? staticType : typeWithThis; + var baseType = hasStatic ? baseStaticType : baseWithThis; + var prop = getPropertyOfType(thisType, declaredProp.escapedName); + var baseProp = getPropertyOfType(baseType, declaredProp.escapedName); + var baseClassName = typeToString(baseWithThis); + if (prop && !baseProp && hasOverride) { + var suggestion = getSpellingSuggestionForName(ts.symbolName(declaredProp), ts.arrayFrom(getMembersOfSymbol(baseType.symbol).values()), 106500 /* ClassMember */); + suggestion ? + error(member, ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1, baseClassName, symbolToString(suggestion)) : + error(member, ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0, baseClassName); + } + else if (prop && (baseProp === null || baseProp === void 0 ? void 0 : baseProp.valueDeclaration) && compilerOptions.noImplicitOverride && !nodeInAmbientContext) { + var baseHasAbstract = ts.hasAbstractModifier(baseProp.valueDeclaration); + if (hasOverride) { + return; + } + if (!baseHasAbstract) { + var diag = memberIsParameterProperty ? + ts.Diagnostics.This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0 : + ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0; + error(member, diag, baseClassName); + } + else if (ts.hasAbstractModifier(member) && baseHasAbstract) { + error(member, ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0, baseClassName); + } + } + } + else if (hasOverride) { + var className = typeToString(type); + error(member, ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class, className); + } + } + } 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_23 = function (member) { + var _loop_25 = function (member) { if (ts.hasStaticModifier(member)) { return "continue"; } @@ -76363,7 +79159,7 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_23(member); + _loop_25(member); } if (!issuedMemberError) { // check again with diagnostics to generate a less-specific error @@ -76389,7 +79185,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 252 /* ClassDeclaration */ || d.kind === 253 /* InterfaceDeclaration */; + return d.kind === 254 /* ClassDeclaration */ || d.kind === 255 /* InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -76406,6 +79202,7 @@ var ts; // but not by other kinds of members. // Base class instance member variables and accessors can be overridden by // derived class instance member variables and accessors, but not by other kinds of members. + var _a, _b; // NOTE: assignability is checked in checkClassDeclaration var baseProperties = getPropertiesOfType(baseType); basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { @@ -76434,8 +79231,8 @@ var ts; // 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.) - for (var _a = 0, _b = getBaseTypes(type); _a < _b.length; _a++) { - var otherBaseType = _b[_a]; + for (var _c = 0, _d = getBaseTypes(type); _c < _d.length; _c++) { + var otherBaseType = _d[_c]; if (otherBaseType === baseType) continue; var baseSymbol_1 = getPropertyOfObjectType(otherBaseType, base.escapedName); @@ -76444,7 +79241,7 @@ var ts; continue basePropertyCheck; } } - if (derivedClassDecl.kind === 221 /* ClassExpression */) { + if (derivedClassDecl.kind === 223 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -76465,7 +79262,7 @@ var ts; if (basePropertyFlags && derivedPropertyFlags) { // property/accessor is overridden with property/accessor if (baseDeclarationFlags & 128 /* Abstract */ && !(base.valueDeclaration && ts.isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer) - || base.valueDeclaration && base.valueDeclaration.parent.kind === 253 /* InterfaceDeclaration */ + || base.valueDeclaration && base.valueDeclaration.parent.kind === 255 /* InterfaceDeclaration */ || derived.valueDeclaration && ts.isBinaryExpression(derived.valueDeclaration)) { // when the base property is abstract or from an interface, base/derived flags don't need to match // same when the derived property is from an assignment @@ -76479,13 +79276,13 @@ var ts; ts.Diagnostics._0_is_defined_as_a_property_in_class_1_but_is_overridden_here_in_2_as_an_accessor; error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_1, symbolToString(base), typeToString(baseType), typeToString(type)); } - else if (compilerOptions.useDefineForClassFields) { - var uninitialized = ts.find(derived.declarations, function (d) { return d.kind === 163 /* PropertyDeclaration */ && !d.initializer; }); + else if (useDefineForClassFields) { + var uninitialized = (_a = derived.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 165 /* PropertyDeclaration */ && !d.initializer; }); if (uninitialized && !(derived.flags & 33554432 /* Transient */) && !(baseDeclarationFlags & 128 /* Abstract */) && !(derivedDeclarationFlags & 128 /* Abstract */) - && !derived.declarations.some(function (d) { return !!(d.flags & 8388608 /* Ambient */); })) { + && !((_b = derived.declarations) === null || _b === void 0 ? void 0 : _b.some(function (d) { return !!(d.flags & 8388608 /* Ambient */); }))) { var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol)); var propName = uninitialized.name; if (uninitialized.exclamationToken @@ -76596,7 +79393,7 @@ var ts; } } function isInstancePropertyWithoutInitializer(node) { - return node.kind === 163 /* PropertyDeclaration */ && + return node.kind === 165 /* PropertyDeclaration */ && !ts.hasSyntacticModifier(node, 32 /* Static */ | 128 /* Abstract */) && !node.exclamationToken && !node.initializer; @@ -76620,7 +79417,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 253 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 255 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -76653,7 +79450,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0); checkExportsOnMergedDeclarations(node); checkTypeParameters(node.typeParameters); - if (node.type.kind === 136 /* IntrinsicKeyword */) { + if (node.type.kind === 137 /* 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); } @@ -76739,7 +79536,7 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { @@ -76749,7 +79546,7 @@ var ts; } } break; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { @@ -76778,22 +79575,22 @@ var ts; case 8 /* NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return evaluate(expr.expression); - case 78 /* Identifier */: + case 79 /* Identifier */: var identifier = expr; if (isInfinityOrNaNString(identifier.escapedText)) { return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 202 /* ElementAccessExpression */: - case 201 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: var ex = expr; if (isConstantMemberAccess(ex)) { var type = getTypeOfExpression(ex.expression); if (type.symbol && type.symbol.flags & 384 /* Enum */) { var name = void 0; - if (ex.kind === 201 /* PropertyAccessExpression */) { + if (ex.kind === 203 /* PropertyAccessExpression */) { name = ex.name.escapedText; } else { @@ -76811,7 +79608,7 @@ var ts; if (memberSymbol) { var declaration = memberSymbol.valueDeclaration; if (declaration !== member) { - if (isBlockScopedNameDeclaredBeforeUse(declaration, member)) { + if (declaration && isBlockScopedNameDeclaredBeforeUse(declaration, member)) { return getEnumMemberValue(declaration); } error(expr, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums); @@ -76825,9 +79622,9 @@ var ts; } } function isConstantMemberAccess(node) { - return node.kind === 78 /* Identifier */ || - node.kind === 201 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 202 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + return node.kind === 79 /* Identifier */ || + node.kind === 203 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 204 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && ts.isStringLiteralLike(node.argumentExpression); } function checkEnumDeclaration(node) { @@ -76851,7 +79648,7 @@ var ts; var enumSymbol = getSymbolOfNode(node); var firstDeclaration = ts.getDeclarationOfKind(enumSymbol, node.kind); if (node === firstDeclaration) { - if (enumSymbol.declarations.length > 1) { + if (enumSymbol.declarations && enumSymbol.declarations.length > 1) { var enumIsConst_1 = ts.isEnumConst(node); // check that const is placed\omitted on all enum declarations ts.forEach(enumSymbol.declarations, function (decl) { @@ -76863,7 +79660,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 !== 255 /* EnumDeclaration */) { + if (declaration.kind !== 257 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -76889,12 +79686,14 @@ var ts; } function getFirstNonAmbientClassOrFunctionDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { - var declaration = declarations_8[_i]; - if ((declaration.kind === 252 /* ClassDeclaration */ || - (declaration.kind === 251 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && - !(declaration.flags & 8388608 /* Ambient */)) { - return declaration; + if (declarations) { + for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { + var declaration = declarations_8[_i]; + if ((declaration.kind === 254 /* ClassDeclaration */ || + (declaration.kind === 253 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + !(declaration.flags & 8388608 /* Ambient */)) { + return declaration; + } } } return undefined; @@ -76942,8 +79741,9 @@ var ts; // The following checks only apply on a non-ambient instantiated module declaration. if (symbol.flags & 512 /* ValueModule */ && !inAmbientContext + && symbol.declarations && symbol.declarations.length > 1 - && isInstantiatedModule(node, !!compilerOptions.preserveConstEnums || !!compilerOptions.isolatedModules)) { + && isInstantiatedModule(node, ts.shouldPreserveConstEnums(compilerOptions))) { var firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol); if (firstNonAmbientClassOrFunc) { if (ts.getSourceFileOfNode(node) !== ts.getSourceFileOfNode(firstNonAmbientClassOrFunc)) { @@ -76955,7 +79755,7 @@ 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, 252 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 254 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -77004,40 +79804,41 @@ var ts; } } function checkModuleAugmentationElement(node, isGlobalAugmentation) { + var _a; switch (node.kind) { - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: // error each individual name in variable statement instead of marking the entire variable statement - for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; + for (var _i = 0, _b = node.declarationList.declarations; _i < _b.length; _i++) { + var decl = _b[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 266 /* ExportAssignment */: - case 267 /* ExportDeclaration */: + case 268 /* ExportAssignment */: + case 269 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 260 /* ImportEqualsDeclaration */: - case 261 /* ImportDeclaration */: + case 262 /* ImportEqualsDeclaration */: + case 263 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 198 /* BindingElement */: - case 249 /* VariableDeclaration */: + case 200 /* BindingElement */: + case 251 /* VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { - for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { - var el = _c[_b]; + for (var _c = 0, _d = name.elements; _c < _d.length; _c++) { + var el = _d[_c]; // mark individual names in binding pattern checkModuleAugmentationElement(el, isGlobalAugmentation); } break; } // falls through - case 252 /* ClassDeclaration */: - case 255 /* EnumDeclaration */: - case 251 /* FunctionDeclaration */: - case 253 /* InterfaceDeclaration */: - case 256 /* ModuleDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 254 /* ClassDeclaration */: + case 257 /* EnumDeclaration */: + case 253 /* FunctionDeclaration */: + case 255 /* InterfaceDeclaration */: + case 258 /* ModuleDeclaration */: + case 256 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -77050,7 +79851,7 @@ var ts; var reportError = !(symbol.flags & 33554432 /* Transient */); if (!reportError) { // symbol should not originate in augmentation - reportError = !!symbol.parent && ts.isExternalModuleAugmentation(symbol.parent.declarations[0]); + reportError = !!((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.declarations) && ts.isExternalModuleAugmentation(symbol.parent.declarations[0]); } } break; @@ -77058,20 +79859,20 @@ var ts; } function getFirstNonModuleExportsIdentifier(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return node; - case 157 /* QualifiedName */: + case 159 /* QualifiedName */: do { node = node.left; - } while (node.kind !== 78 /* Identifier */); + } while (node.kind !== 79 /* Identifier */); return node; - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: do { if (ts.isModuleExportsAccessExpression(node.expression) && !ts.isPrivateIdentifier(node.name)) { return node.name; } node = node.expression; - } while (node.kind !== 78 /* Identifier */); + } while (node.kind !== 79 /* Identifier */); return node; } } @@ -77085,9 +79886,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 257 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 297 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 267 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 259 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 299 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 269 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -77107,6 +79908,7 @@ var ts; return true; } function checkAliasSymbol(node) { + var _a; var symbol = getSymbolOfNode(node); var target = resolveAlias(symbol); if (target !== unknownSymbol) { @@ -77121,21 +79923,21 @@ var ts; (symbol.flags & 788968 /* Type */ ? 788968 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 270 /* ExportSpecifier */ ? + var message = node.kind === 272 /* 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)); } // Don't allow to re-export something with no value side when `--isolatedModules` is set. if (compilerOptions.isolatedModules - && node.kind === 270 /* ExportSpecifier */ + && node.kind === 272 /* ExportSpecifier */ && !node.parent.parent.isTypeOnly && !(target.flags & 111551 /* Value */) && !(node.flags & 8388608 /* Ambient */)) { error(node, ts.Diagnostics.Re_exporting_a_type_when_the_isolatedModules_flag_is_provided_requires_using_export_type); } - if (ts.isImportSpecifier(node) && ts.every(target.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 134217728 /* Deprecated */); })) { - errorOrSuggestion(/* isError */ false, node.name, ts.Diagnostics._0_is_deprecated, symbol.escapedName); + if (ts.isImportSpecifier(node) && ((_a = target.declarations) === null || _a === void 0 ? void 0 : _a.every(function (d) { return !!(ts.getCombinedNodeFlags(d) & 134217728 /* Deprecated */); }))) { + addDeprecatedSuggestion(node.name, target.declarations, symbol.escapedName); } } } @@ -77143,7 +79945,7 @@ var ts; checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); checkAliasSymbol(node); - if (node.kind === 265 /* ImportSpecifier */ && + if (node.kind === 267 /* ImportSpecifier */ && ts.idText(node.propertyName || node.name) === "default" && compilerOptions.esModuleInterop && moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015) { @@ -77165,7 +79967,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 263 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 265 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); if (moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015 && compilerOptions.esModuleInterop) { // import * as ns from "foo"; @@ -77193,7 +79995,7 @@ var ts; if (ts.hasSyntacticModifier(node, 1 /* Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 272 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 274 /* ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { if (target.flags & 111551 /* Value */) { @@ -77236,10 +80038,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 257 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 257 /* ModuleBlock */ && + var inAmbientExternalModule = node.parent.kind === 259 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 259 /* ModuleBlock */ && !node.moduleSpecifier && node.flags & 8388608 /* Ambient */; - if (node.parent.kind !== 297 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 299 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -77272,14 +80074,14 @@ var ts; } function checkGrammarExportDeclaration(node) { var _a; - var isTypeOnlyExportStar = node.isTypeOnly && ((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) !== 268 /* NamedExports */; + var isTypeOnlyExportStar = node.isTypeOnly && ((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) !== 270 /* NamedExports */; if (isTypeOnlyExportStar) { grammarErrorOnNode(node, ts.Diagnostics.Only_named_exports_may_use_export_type); } return !isTypeOnlyExportStar; } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 297 /* SourceFile */ || node.parent.kind === 257 /* ModuleBlock */ || node.parent.kind === 256 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 299 /* SourceFile */ || node.parent.kind === 259 /* ModuleBlock */ || node.parent.kind === 258 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -77329,7 +80131,7 @@ var ts; // 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 */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); - if (symbol && (symbol === undefinedSymbol || symbol === globalThisSymbol || isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { + 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 { @@ -77350,12 +80152,15 @@ var ts; } } function checkExportAssignment(node) { - if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { + var illegalContextMessage = node.isExportEquals + ? ts.Diagnostics.An_export_assignment_must_be_at_the_top_level_of_a_file_or_module_declaration + : ts.Diagnostics.A_default_export_must_be_at_the_top_level_of_a_file_or_module_declaration; + if (checkGrammarModuleElementContext(node, illegalContextMessage)) { // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 297 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 256 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 299 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 258 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -77368,7 +80173,7 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasEffectiveModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 78 /* Identifier */) { + if (node.expression.kind === 79 /* Identifier */) { var id = node.expression; var sym = resolveEntityName(id, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node); if (sym) { @@ -77415,7 +80220,7 @@ var ts; var exportEqualsSymbol = moduleSymbol.exports.get("export="); if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) { var declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration; - if (!isTopLevelInExternalModuleAugmentation(declaration) && !ts.isInJSFile(declaration)) { + if (declaration && !isTopLevelInExternalModuleAugmentation(declaration) && !ts.isInJSFile(declaration)) { error(declaration, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); } } @@ -77439,10 +80244,12 @@ var ts; return; } if (exportedDeclarationsCount > 1) { - for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { - var declaration = declarations_9[_i]; - if (isNotOverload(declaration)) { - diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Cannot_redeclare_exported_variable_0, ts.unescapeLeadingUnderscores(id))); + if (!isDuplicatedCommonJSExport(declarations)) { + for (var _i = 0, _b = declarations; _i < _b.length; _i++) { + var declaration = _b[_i]; + if (isNotOverload(declaration)) { + diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Cannot_redeclare_exported_variable_0, ts.unescapeLeadingUnderscores(id))); + } } } } @@ -77451,6 +80258,11 @@ var ts; links.exportsChecked = true; } } + function isDuplicatedCommonJSExport(declarations) { + return declarations + && declarations.length > 1 + && declarations.every(function (d) { return ts.isInJSFile(d) && ts.isAccessExpression(d) && (ts.isExportsIdentifier(d.expression) || ts.isModuleExportsAccessExpression(d.expression)); }); + } function checkSourceElement(node) { if (node) { var saveCurrentNode = currentNode; @@ -77472,171 +80284,171 @@ 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 256 /* ModuleDeclaration */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 251 /* FunctionDeclaration */: + case 258 /* ModuleDeclaration */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 253 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } - if (kind >= 232 /* FirstStatement */ && kind <= 248 /* LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { + if (kind >= 234 /* FirstStatement */ && kind <= 250 /* LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { errorOrSuggestion(compilerOptions.allowUnreachableCode === false, node, ts.Diagnostics.Unreachable_code_detected); } switch (kind) { - case 159 /* TypeParameter */: + case 161 /* TypeParameter */: return checkTypeParameter(node); - case 160 /* Parameter */: + case 162 /* Parameter */: return checkParameter(node); - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return checkPropertyDeclaration(node); - case 162 /* PropertySignature */: + case 164 /* PropertySignature */: return checkPropertySignature(node); - case 175 /* ConstructorType */: - case 174 /* FunctionType */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: + case 177 /* ConstructorType */: + case 176 /* FunctionType */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 173 /* IndexSignature */: return checkSignatureDeclaration(node); - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: return checkMethodDeclaration(node); - case 166 /* Constructor */: + case 168 /* Constructor */: return checkConstructorDeclaration(node); - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return checkAccessorDeclaration(node); - case 173 /* TypeReference */: + case 175 /* TypeReference */: return checkTypeReferenceNode(node); - case 172 /* TypePredicate */: + case 174 /* TypePredicate */: return checkTypePredicate(node); - case 176 /* TypeQuery */: + case 178 /* TypeQuery */: return checkTypeQuery(node); - case 177 /* TypeLiteral */: + case 179 /* TypeLiteral */: return checkTypeLiteral(node); - case 178 /* ArrayType */: + case 180 /* ArrayType */: return checkArrayType(node); - case 179 /* TupleType */: + case 181 /* TupleType */: return checkTupleType(node); - case 182 /* UnionType */: - case 183 /* IntersectionType */: + case 184 /* UnionType */: + case 185 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 186 /* ParenthesizedType */: - case 180 /* OptionalType */: - case 181 /* RestType */: + case 188 /* ParenthesizedType */: + case 182 /* OptionalType */: + case 183 /* RestType */: return checkSourceElement(node.type); - case 187 /* ThisType */: + case 189 /* ThisType */: return checkThisType(node); - case 188 /* TypeOperator */: + case 190 /* TypeOperator */: return checkTypeOperator(node); - case 184 /* ConditionalType */: + case 186 /* ConditionalType */: return checkConditionalType(node); - case 185 /* InferType */: + case 187 /* InferType */: return checkInferType(node); - case 193 /* TemplateLiteralType */: + case 195 /* TemplateLiteralType */: return checkTemplateLiteralType(node); - case 195 /* ImportType */: + case 197 /* ImportType */: return checkImportType(node); - case 192 /* NamedTupleMember */: + case 194 /* NamedTupleMember */: return checkNamedTupleMember(node); - case 315 /* JSDocAugmentsTag */: + case 322 /* JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 316 /* JSDocImplementsTag */: + case 323 /* JSDocImplementsTag */: return checkJSDocImplementsTag(node); - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 325 /* JSDocEnumTag */: + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + case 333 /* JSDocEnumTag */: return checkJSDocTypeAliasTag(node); - case 330 /* JSDocTemplateTag */: + case 338 /* JSDocTemplateTag */: return checkJSDocTemplateTag(node); - case 329 /* JSDocTypeTag */: + case 337 /* JSDocTypeTag */: return checkJSDocTypeTag(node); - case 326 /* JSDocParameterTag */: + case 334 /* JSDocParameterTag */: return checkJSDocParameterTag(node); - case 333 /* JSDocPropertyTag */: + case 341 /* JSDocPropertyTag */: return checkJSDocPropertyTag(node); - case 308 /* JSDocFunctionType */: + case 311 /* JSDocFunctionType */: checkJSDocFunctionType(node); // falls through - case 306 /* JSDocNonNullableType */: - case 305 /* JSDocNullableType */: - case 303 /* JSDocAllType */: - case 304 /* JSDocUnknownType */: - case 312 /* JSDocTypeLiteral */: + case 309 /* JSDocNonNullableType */: + case 308 /* JSDocNullableType */: + case 306 /* JSDocAllType */: + case 307 /* JSDocUnknownType */: + case 316 /* JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 309 /* JSDocVariadicType */: + case 312 /* JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 301 /* JSDocTypeExpression */: + case 303 /* JSDocTypeExpression */: return checkSourceElement(node.type); - case 189 /* IndexedAccessType */: + case 191 /* IndexedAccessType */: return checkIndexedAccessType(node); - case 190 /* MappedType */: + case 192 /* MappedType */: return checkMappedType(node); - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 230 /* Block */: - case 257 /* ModuleBlock */: + case 232 /* Block */: + case 259 /* ModuleBlock */: return checkBlock(node); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return checkVariableStatement(node); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: return checkExpressionStatement(node); - case 234 /* IfStatement */: + case 236 /* IfStatement */: return checkIfStatement(node); - case 235 /* DoStatement */: + case 237 /* DoStatement */: return checkDoStatement(node); - case 236 /* WhileStatement */: + case 238 /* WhileStatement */: return checkWhileStatement(node); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return checkForStatement(node); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return checkForInStatement(node); - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: return checkForOfStatement(node); - case 240 /* ContinueStatement */: - case 241 /* BreakStatement */: + case 242 /* ContinueStatement */: + case 243 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: return checkReturnStatement(node); - case 243 /* WithStatement */: + case 245 /* WithStatement */: return checkWithStatement(node); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: return checkSwitchStatement(node); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return checkLabeledStatement(node); - case 246 /* ThrowStatement */: + case 248 /* ThrowStatement */: return checkThrowStatement(node); - case 247 /* TryStatement */: + case 249 /* TryStatement */: return checkTryStatement(node); - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 198 /* BindingElement */: + case 200 /* BindingElement */: return checkBindingElement(node); - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: return checkClassDeclaration(node); - case 253 /* InterfaceDeclaration */: + case 255 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return checkImportDeclaration(node); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: return checkExportDeclaration(node); - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return checkExportAssignment(node); - case 231 /* EmptyStatement */: - case 248 /* DebuggerStatement */: + case 233 /* EmptyStatement */: + case 250 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 271 /* MissingDeclaration */: + case 273 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -77681,7 +80493,8 @@ var ts; if (ts.isJSDocTypeExpression(node.parent) && ts.isJSDocParameterTag(paramTag)) { // Else we will add a diagnostic, see `checkJSDocVariadicType`. var host_1 = ts.getHostSignatureFromJSDoc(paramTag); - if (host_1) { + var isCallbackTag = ts.isJSDocCallbackTag(paramTag.parent.parent); + if (host_1 || isCallbackTag) { /* Only return an array type if the corresponding parameter is marked as a rest parameter, or if there are no parameters. So in the following situation we will not create an array type: @@ -77689,7 +80502,9 @@ var ts; function f(a) {} Because `a` will just be of type `number | undefined`. A synthetic `...args` will also be added, which *will* get an array type. */ - var lastParamDeclaration = ts.lastOrUndefined(host_1.parameters); + var lastParamDeclaration = isCallbackTag + ? ts.lastOrUndefined(paramTag.parent.parent.typeExpression.parameters) + : ts.lastOrUndefined(host_1.parameters); var symbol = ts.getParameterSymbolFromJSDoc(paramTag); if (!lastParamDeclaration || symbol && lastParamDeclaration.symbol === symbol && ts.isRestParameter(lastParamDeclaration)) { @@ -77727,51 +80542,51 @@ var ts; } } function checkDeferredNode(node) { - ts.tracing.push("check" /* Check */, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end }); var saveCurrentNode = currentNode; currentNode = node; instantiationCount = 0; switch (node.kind) { - case 203 /* CallExpression */: - case 204 /* NewExpression */: - case 205 /* TaggedTemplateExpression */: - case 161 /* Decorator */: - case 275 /* JsxOpeningElement */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: + case 207 /* TaggedTemplateExpression */: + case 163 /* Decorator */: + case 277 /* 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 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: checkAccessorDeclaration(node); break; - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: checkClassExpressionDeferred(node); break; - case 274 /* JsxSelfClosingElement */: + case 276 /* JsxSelfClosingElement */: checkJsxSelfClosingElementDeferred(node); break; - case 273 /* JsxElement */: + case 275 /* JsxElement */: checkJsxElementDeferred(node); break; } currentNode = saveCurrentNode; - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } function checkSourceFile(node) { - ts.tracing.push("check" /* Check */, "checkSourceFile", { path: node.path }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkSourceFile", { path: node.path }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeCheck"); checkSourceFileWorker(node); ts.performance.mark("afterCheck"); ts.performance.measure("Check", "beforeCheck", "afterCheck"); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } function unusedIsError(kind, isAmbient) { if (isAmbient) { @@ -77800,7 +80615,7 @@ var ts; checkGrammarSourceFile(node); ts.clear(potentialThisCollisions); ts.clear(potentialNewTargetCollisions); - ts.clear(potentialWeakMapCollisions); + ts.clear(potentialWeakMapSetCollisions); ts.forEach(node.statements, checkSourceElement); checkSourceElement(node.endOfFileToken); checkDeferredNodes(node); @@ -77830,9 +80645,9 @@ var ts; ts.forEach(potentialNewTargetCollisions, checkIfNewTargetIsCapturedInEnclosingScope); ts.clear(potentialNewTargetCollisions); } - if (potentialWeakMapCollisions.length) { - ts.forEach(potentialWeakMapCollisions, checkWeakMapCollision); - ts.clear(potentialWeakMapCollisions); + if (potentialWeakMapSetCollisions.length) { + ts.forEach(potentialWeakMapSetCollisions, checkWeakMapSetCollision); + ts.clear(potentialWeakMapSetCollisions); } links.flags |= 1 /* TypeChecked */; } @@ -77904,17 +80719,17 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 297 /* SourceFile */: - if (!ts.isExternalOrCommonJsModule(location)) + case 299 /* SourceFile */: + if (!ts.isExternalModule(location)) break; // falls through - case 256 /* ModuleDeclaration */: - copySymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); + case 258 /* ModuleDeclaration */: + copyLocallyVisibleExportSymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); break; - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); @@ -77922,8 +80737,8 @@ 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 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: + case 254 /* ClassDeclaration */: + case 255 /* 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. @@ -77932,7 +80747,7 @@ var ts; copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* Type */); } break; - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -77972,27 +80787,37 @@ var ts; }); } } + function copyLocallyVisibleExportSymbols(source, meaning) { + if (meaning) { + source.forEach(function (symbol) { + // Similar condition as in `resolveNameHelper` + if (!ts.getDeclarationOfKind(symbol, 272 /* ExportSpecifier */) && !ts.getDeclarationOfKind(symbol, 271 /* NamespaceExport */)) { + copySymbol(symbol, meaning); + } + }); + } + } } function isTypeDeclarationName(name) { - return name.kind === 78 /* Identifier */ && + return name.kind === 79 /* Identifier */ && isTypeDeclaration(name.parent) && ts.getNameOfDeclaration(name.parent) === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 159 /* TypeParameter */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 255 /* EnumDeclaration */: - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 325 /* JSDocEnumTag */: + case 161 /* TypeParameter */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 257 /* EnumDeclaration */: + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + case 333 /* JSDocEnumTag */: return true; - case 262 /* ImportClause */: + case 264 /* ImportClause */: return node.isTypeOnly; - case 265 /* ImportSpecifier */: - case 270 /* ExportSpecifier */: + case 267 /* ImportSpecifier */: + case 272 /* ExportSpecifier */: return node.parent.parent.isTypeOnly; default: return false; @@ -78000,25 +80825,16 @@ var ts; } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(node) { - while (node.parent.kind === 157 /* QualifiedName */) { + while (node.parent.kind === 159 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 173 /* TypeReference */; + return node.parent.kind === 175 /* TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 201 /* PropertyAccessExpression */) { - node = node.parent; - } - return node.parent.kind === 223 /* ExpressionWithTypeArguments */; - } - function isJSDocEntryNameReference(node) { - while (node.parent.kind === 157 /* QualifiedName */) { + while (node.parent.kind === 203 /* PropertyAccessExpression */) { node = node.parent; } - while (node.parent.kind === 201 /* PropertyAccessExpression */) { - node = node.parent; - } - return node.parent.kind === 302 /* JSDocNameReference */; + return node.parent.kind === 225 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -78046,13 +80862,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 157 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 159 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 260 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 262 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 266 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 268 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -78078,7 +80894,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 195 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 197 /* ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -78088,17 +80904,17 @@ var ts; return getSymbolOfNode(name.parent); } if (ts.isInJSFile(name) && - name.parent.kind === 201 /* PropertyAccessExpression */ && + name.parent.kind === 203 /* PropertyAccessExpression */ && name.parent === name.parent.parent.left) { // Check if this is a special property assignment - if (!ts.isPrivateIdentifier(name)) { + if (!ts.isPrivateIdentifier(name) && !ts.isJSDocMemberName(name)) { var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(name); if (specialPropertyAssignmentSymbol) { return specialPropertyAssignmentSymbol; } } } - if (name.parent.kind === 266 /* ExportAssignment */ && ts.isEntityNameExpression(name)) { + if (name.parent.kind === 268 /* 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); @@ -78106,13 +80922,13 @@ var ts; return success; } } - else if (!ts.isPropertyAccessExpression(name) && !ts.isPrivateIdentifier(name) && isInRightSideOfImportOrExportAssignment(name)) { + 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, 260 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(name, 262 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(name, /*dontResolveAlias*/ true); } - if (!ts.isPropertyAccessExpression(name) && !ts.isPrivateIdentifier(name)) { + if (ts.isEntityName(name)) { var possibleImportNode = isImportTypeQualifierPart(name); if (possibleImportNode) { getTypeFromTypeNode(possibleImportNode); @@ -78120,13 +80936,13 @@ var ts; return sym === unknownSymbol ? undefined : sym; } } - while (ts.isRightSideOfQualifiedNameOrPropertyAccess(name)) { + while (ts.isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName(name)) { name = name.parent; } if (isHeritageClauseElementIdentifier(name)) { var meaning = 0 /* None */; // In an interface or class, we're definitely interested in a type. - if (name.parent.kind === 223 /* ExpressionWithTypeArguments */) { + if (name.parent.kind === 225 /* ExpressionWithTypeArguments */) { meaning = 788968 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(name.parent)) { @@ -78142,10 +80958,10 @@ var ts; return entityNameSymbol; } } - if (name.parent.kind === 326 /* JSDocParameterTag */) { + if (name.parent.kind === 334 /* JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(name.parent); } - if (name.parent.kind === 159 /* TypeParameter */ && name.parent.parent.kind === 330 /* JSDocTemplateTag */) { + if (name.parent.kind === 161 /* TypeParameter */ && name.parent.parent.kind === 338 /* JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJSFile(name)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(name.parent); return typeParameter && typeParameter.symbol; @@ -78155,43 +80971,81 @@ var ts; // Missing entity name. return undefined; } - if (name.kind === 78 /* Identifier */) { + 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 */) { if (ts.isJSXTagName(name) && isJsxIntrinsicIdentifier(name)) { var symbol = getIntrinsicTagSymbol(name.parent); return symbol === unknownSymbol ? undefined : symbol; } - return resolveEntityName(name, 111551 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); + var result = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ !isJSDoc_1, ts.getHostSignatureFromJSDoc(name)); + if (!result && isJSDoc_1) { + var container = ts.findAncestor(name, ts.or(ts.isClassLike, ts.isInterfaceDeclaration)); + if (container) { + return resolveJSDocMemberName(name, getSymbolOfNode(container)); + } + } + return result; } - else if (name.kind === 201 /* PropertyAccessExpression */ || name.kind === 157 /* QualifiedName */) { + else if (name.kind === 203 /* PropertyAccessExpression */ || name.kind === 159 /* QualifiedName */) { var links = getNodeLinks(name); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (name.kind === 201 /* PropertyAccessExpression */) { - checkPropertyAccessExpression(name); + if (name.kind === 203 /* PropertyAccessExpression */) { + checkPropertyAccessExpression(name, 0 /* Normal */); } else { - checkQualifiedName(name); + checkQualifiedName(name, 0 /* Normal */); + } + if (!links.resolvedSymbol && isJSDoc_1 && ts.isQualifiedName(name)) { + return resolveJSDocMemberName(name); } return links.resolvedSymbol; } + else if (ts.isJSDocMemberName(name)) { + return resolveJSDocMemberName(name); + } } else if (isTypeReferenceIdentifier(name)) { - var meaning = name.parent.kind === 173 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; + var meaning = name.parent.kind === 175 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; return resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (isJSDocEntryNameReference(name)) { - var meaning = 788968 /* Type */ | 1920 /* Namespace */ | 111551 /* Value */; - return resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true, ts.getHostSignatureFromJSDoc(name)); - } - if (name.parent.kind === 172 /* TypePredicate */) { + if (name.parent.kind === 174 /* TypePredicate */) { return resolveEntityName(name, /*meaning*/ 1 /* FunctionScopedVariable */); } - // Do we want to return undefined here? return undefined; } + /** + * Recursively resolve entity names and jsdoc instance references: + * 1. K#m as K.prototype.m for a class (or other value) K + * 2. K.m as K.prototype.m + * 3. I.m as I.m for a type I, or any other I.m that fails to resolve in (1) or (2) + * + * For unqualified names, a container K may be provided as a second argument. + */ + function resolveJSDocMemberName(name, container) { + if (ts.isEntityName(name)) { + // resolve static values first + var meaning = 788968 /* Type */ | 1920 /* Namespace */ | 111551 /* Value */; + var symbol = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true, ts.getHostSignatureFromJSDoc(name)); + if (!symbol && ts.isIdentifier(name) && container) { + symbol = getMergedSymbol(getSymbol(getExportsOfSymbol(container), name.escapedText, meaning)); + } + if (symbol) { + return symbol; + } + } + var left = ts.isIdentifier(name) ? container : resolveJSDocMemberName(name.left); + var right = ts.isIdentifier(name) ? name.escapedText : name.right.escapedText; + if (left) { + var proto = left.flags & 111551 /* Value */ && getPropertyOfType(getTypeOfSymbol(left), "prototype"); + var t = proto ? getTypeOfSymbol(proto) : getDeclaredTypeOfSymbol(left); + return getPropertyOfType(t, right); + } + } function getSymbolAtLocation(node, ignoreErrors) { - if (node.kind === 297 /* SourceFile */) { + if (node.kind === 299 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; @@ -78210,12 +81064,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(parent.parent); } - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfNameOrPropertyAccessExpression(node); } - else if (parent.kind === 198 /* BindingElement */ && - grandParent.kind === 196 /* ObjectBindingPattern */ && + else if (parent.kind === 200 /* BindingElement */ && + grandParent.kind === 198 /* ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText); @@ -78225,12 +81079,12 @@ var ts; } } switch (node.kind) { - case 78 /* Identifier */: - case 79 /* PrivateIdentifier */: - case 201 /* PropertyAccessExpression */: - case 157 /* QualifiedName */: + case 79 /* Identifier */: + case 80 /* PrivateIdentifier */: + case 203 /* PropertyAccessExpression */: + case 159 /* QualifiedName */: return getSymbolOfNameOrPropertyAccessExpression(node); - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -78242,14 +81096,14 @@ var ts; return checkExpression(node).symbol; } // falls through - case 187 /* ThisType */: + case 189 /* ThisType */: return getTypeFromThisTypeNode(node).symbol; - case 105 /* SuperKeyword */: + case 106 /* SuperKeyword */: return checkExpression(node).symbol; - case 132 /* ConstructorKeyword */: + case 133 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 166 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 168 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -78260,7 +81114,7 @@ var ts; // 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 === 261 /* ImportDeclaration */ || node.parent.kind === 267 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 263 /* ImportDeclaration */ || node.parent.kind === 269 /* 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); @@ -78277,21 +81131,21 @@ var ts; ? getTypeFromTypeNode(grandParent.objectType) : undefined; return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text)); - case 87 /* DefaultKeyword */: - case 97 /* FunctionKeyword */: + case 88 /* DefaultKeyword */: + case 98 /* FunctionKeyword */: case 38 /* EqualsGreaterThanToken */: - case 83 /* ClassKeyword */: + case 84 /* ClassKeyword */: return getSymbolOfNode(node.parent); - case 195 /* ImportType */: + case 197 /* ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal, ignoreErrors) : undefined; - case 92 /* ExportKeyword */: + case 93 /* ExportKeyword */: return ts.isExportAssignment(node.parent) ? ts.Debug.checkDefined(node.parent.symbol) : undefined; default: return undefined; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 289 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 291 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 111551 /* Value */ | 2097152 /* Alias */); } return undefined; @@ -78370,27 +81224,27 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfAssignmentPattern(expr) { - ts.Debug.assert(expr.kind === 200 /* ObjectLiteralExpression */ || expr.kind === 199 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 202 /* ObjectLiteralExpression */ || expr.kind === 201 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 239 /* ForOfStatement */) { + if (expr.parent.kind === 241 /* 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 === 216 /* BinaryExpression */) { + if (expr.parent.kind === 218 /* 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 === 288 /* PropertyAssignment */) { - var node_2 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); - var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_2) || errorType; - var propertyIndex = ts.indexOfNode(node_2.properties, expr.parent); - return checkObjectLiteralDestructuringPropertyAssignment(node_2, typeOfParentObjectLiteral, propertyIndex); + if (expr.parent.kind === 290 /* 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); + return checkObjectLiteralDestructuringPropertyAssignment(node_3, typeOfParentObjectLiteral, propertyIndex); } // Array literal assignment - array destructuring pattern var node = ts.cast(expr.parent, ts.isArrayLiteralExpression); @@ -78429,12 +81283,12 @@ var ts; function getClassElementPropertyKeyType(element) { var name = element.name; switch (name.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return getLiteralType(ts.idText(name)); case 8 /* NumericLiteral */: case 10 /* StringLiteral */: return getLiteralType(name.text); - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(name); return isTypeAssignableToKind(nameType, 12288 /* ESSymbolLike */) ? nameType : stringType; default: @@ -78531,6 +81385,7 @@ var ts; // When resolved as an expression identifier, if the given node references an exported entity, return the declaration // node of the exported entity's container. Otherwise, return undefined. function getReferencedExportContainer(nodeIn, prefixLocals) { + var _a; var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { // When resolving the export container for the name of a module or enum @@ -78551,7 +81406,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 297 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && ((_a = parentSymbol_1.valueDeclaration) === null || _a === void 0 ? void 0 : _a.kind) === 299 /* 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. @@ -78581,11 +81436,12 @@ var ts; return undefined; } function isSymbolOfDestructuredElementOfCatchBinding(symbol) { - return ts.isBindingElement(symbol.valueDeclaration) - && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 287 /* CatchClause */; + return symbol.valueDeclaration + && ts.isBindingElement(symbol.valueDeclaration) + && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 289 /* CatchClause */; } function isSymbolOfDeclarationWithCollidingName(symbol) { - if (symbol.flags & 418 /* BlockScoped */ && !ts.isSourceFile(symbol.valueDeclaration)) { + if (symbol.flags & 418 /* BlockScoped */ && symbol.valueDeclaration && !ts.isSourceFile(symbol.valueDeclaration)) { var links = getSymbolLinks(symbol); if (links.isDeclarationWithCollidingName === undefined) { var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); @@ -78613,7 +81469,7 @@ var ts; // they will not collide with anything var isDeclaredInLoop = nodeLinks_1.flags & 524288 /* BlockScopedBindingInLoop */; var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false); - var inLoopBodyBlock = container.kind === 230 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 232 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -78654,20 +81510,20 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 262 /* ImportClause */: - case 263 /* NamespaceImport */: - case 265 /* ImportSpecifier */: - case 270 /* ExportSpecifier */: + case 264 /* ImportClause */: + case 265 /* NamespaceImport */: + case 267 /* ImportSpecifier */: + case 272 /* ExportSpecifier */: var symbol = getSymbolOfNode(node) || unknownSymbol; return isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && (ts.isNamespaceExport(exportClause) || ts.some(exportClause.elements, isValueAliasDeclaration)); - case 266 /* ExportAssignment */: - return node.expression && node.expression.kind === 78 /* Identifier */ ? + case 268 /* ExportAssignment */: + return node.expression && node.expression.kind === 79 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : true; } @@ -78675,7 +81531,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 297 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 299 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -78690,7 +81546,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 */) && - (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target)); + (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target)); } function isConstEnumOrConstEnumOnlyModule(s) { return isConstEnumSymbol(s) || !!s.constEnumOnlyModule; @@ -78698,13 +81554,14 @@ var ts; function isReferencedAliasDeclaration(node, checkChildren) { if (isAliasSymbolDeclaration(node)) { var symbol = getSymbolOfNode(node); - if (symbol && getSymbolLinks(symbol).referenced) { + var links = symbol && getSymbolLinks(symbol); + if (links === null || links === void 0 ? void 0 : links.referenced) { return true; } var target = getSymbolLinks(symbol).target; // TODO: GH#18217 if (target && ts.getEffectiveModifierFlags(node) & 1 /* Export */ && target.flags & 111551 /* Value */ && - (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) { + (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) { // An `export import ... =` of a value symbol is always considered referenced return true; } @@ -78741,13 +81598,13 @@ var ts; !isOptionalParameter(parameter) && !ts.isJSDocParameterTag(parameter) && !!parameter.initializer && - !ts.hasSyntacticModifier(parameter, 92 /* ParameterPropertyModifier */); + !ts.hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */); } function isOptionalUninitializedParameterProperty(parameter) { return strictNullChecks && isOptionalParameter(parameter) && !parameter.initializer && - ts.hasSyntacticModifier(parameter, 92 /* ParameterPropertyModifier */); + ts.hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */); } function isOptionalUninitializedParameter(parameter) { return !!strictNullChecks && @@ -78782,15 +81639,15 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 291 /* EnumMember */: - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 293 /* EnumMember */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 291 /* EnumMember */) { + if (node.kind === 293 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -78878,7 +81735,7 @@ var ts; function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) { var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor); if (!declaration) { - return ts.factory.createToken(128 /* AnyKeyword */); + return ts.factory.createToken(129 /* AnyKeyword */); } // Get type of the symbol if this is the valid symbol otherwise get type at location var symbol = getSymbolOfNode(declaration); @@ -78897,7 +81754,7 @@ var ts; function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) { var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike); if (!signatureDeclaration) { - return ts.factory.createToken(128 /* AnyKeyword */); + return ts.factory.createToken(129 /* AnyKeyword */); } var signature = getSignatureFromDeclaration(signatureDeclaration); return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); @@ -78905,7 +81762,7 @@ var ts; function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) { var expr = ts.getParseTreeNode(exprIn, ts.isExpression); if (!expr) { - return ts.factory.createToken(128 /* AnyKeyword */); + return ts.factory.createToken(129 /* AnyKeyword */); } var type = getWidenedType(getRegularTypeOfExpression(expr)); return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); @@ -78943,8 +81800,7 @@ var ts; } function isLiteralConstDeclaration(node) { if (ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node)) { - var type = getTypeOfSymbol(getSymbolOfNode(node)); - return !!(type.flags & 2944 /* Literal */) && isFreshLiteralType(type); + return isFreshLiteralType(getTypeOfSymbol(getSymbolOfNode(node))); } return false; } @@ -79063,12 +81919,12 @@ var ts; getJsxFragmentFactoryEntity: getJsxFragmentFactoryEntity, getAllAccessorDeclarations: function (accessor) { accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); // TODO: GH#18217 - var otherKind = accessor.kind === 168 /* SetAccessor */ ? 167 /* GetAccessor */ : 168 /* SetAccessor */; + var otherKind = accessor.kind === 170 /* SetAccessor */ ? 169 /* GetAccessor */ : 170 /* 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 === 168 /* SetAccessor */ ? accessor : otherAccessor; - var getAccessor = accessor.kind === 167 /* GetAccessor */ ? accessor : otherAccessor; + var setAccessor = accessor.kind === 170 /* SetAccessor */ ? accessor : otherAccessor; + var getAccessor = accessor.kind === 169 /* GetAccessor */ ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -79084,7 +81940,7 @@ var ts; }, getDeclarationStatementsForSourceFile: function (node, flags, tracker, bundled) { var n = ts.getParseTreeNode(node); - ts.Debug.assert(n && n.kind === 297 /* SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); + ts.Debug.assert(n && n.kind === 299 /* SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); var sym = getSymbolOfNode(node); if (!sym) { return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker, bundled); @@ -79107,11 +81963,13 @@ var ts; var s = _a[_i]; if (s.mergeId) { var merged = getMergedSymbol(s); - for (var _b = 0, _c = merged.declarations; _b < _c.length; _b++) { - var d = _c[_b]; - var declFile = ts.getSourceFileOfNode(d); - if (declFile === importTarget) { - return true; + if (merged.declarations) { + for (var _b = 0, _c = merged.declarations; _b < _c.length; _b++) { + var d = _c[_b]; + var declFile = ts.getSourceFileOfNode(d); + if (declFile === importTarget) { + return true; + } } } } @@ -79119,7 +81977,7 @@ var ts; return false; } function isInHeritageClause(node) { - return node.parent && node.parent.kind === 223 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 286 /* HeritageClause */; + return node.parent && node.parent.kind === 225 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 288 /* HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -79131,7 +81989,7 @@ var ts; // 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 === 78 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 201 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { + if ((node.kind === 79 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 203 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); @@ -79140,10 +81998,7 @@ var ts; // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForSymbol(symbol, meaning) { // program does not have any files with type reference directives - bail out - if (!fileToDirective) { - return undefined; - } - if (!isSymbolFromTypeDeclarationFile(symbol)) { + if (!fileToDirective || !isSymbolFromTypeDeclarationFile(symbol)) { return undefined; } // check what declarations in the symbol can contribute to the target meaning @@ -79182,7 +82037,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 297 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 299 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -79210,12 +82065,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 256 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 258 /* 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, 297 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 299 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -79235,7 +82090,7 @@ var ts; // It is an error for a non-external-module (i.e. script) to declare its own `globalThis`. // We can't use `builtinGlobals` for this due to synthetic expando-namespace generation in JS files. var fileGlobalThisSymbol = file.locals.get("globalThis"); - if (fileGlobalThisSymbol) { + if (fileGlobalThisSymbol === null || fileGlobalThisSymbol === void 0 ? void 0 : fileGlobalThisSymbol.declarations) { for (var _d = 0, _e = fileGlobalThisSymbol.declarations; _d < _e.length; _d++) { var declaration = _e[_d]; diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0, "globalThis")); @@ -79359,6 +82214,16 @@ var ts; 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 */) { + 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 */) { + 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); + } + } } } } @@ -79408,14 +82273,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 165 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 167 /* 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 === 167 /* GetAccessor */ || node.kind === 168 /* SetAccessor */) { + else if (node.kind === 169 /* GetAccessor */ || node.kind === 170 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -79428,31 +82293,51 @@ var ts; if (quickResult !== undefined) { return quickResult; } - var lastStatic, lastDeclare, lastAsync, lastReadonly; + var lastStatic, lastDeclare, lastAsync, lastReadonly, lastOverride; var flags = 0 /* None */; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 142 /* ReadonlyKeyword */) { - if (node.kind === 162 /* PropertySignature */ || node.kind === 164 /* MethodSignature */) { + if (modifier.kind !== 143 /* ReadonlyKeyword */) { + if (node.kind === 164 /* PropertySignature */ || node.kind === 166 /* MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 171 /* IndexSignature */) { + if (node.kind === 173 /* IndexSignature */ && (modifier.kind !== 124 /* StaticKeyword */ || !ts.isClassLike(node.parent))) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 84 /* ConstKeyword */: - if (node.kind !== 255 /* EnumDeclaration */) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(84 /* ConstKeyword */)); + case 85 /* ConstKeyword */: + if (node.kind !== 257 /* EnumDeclaration */) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(85 /* ConstKeyword */)); } break; - case 122 /* PublicKeyword */: - case 121 /* ProtectedKeyword */: - case 120 /* PrivateKeyword */: + case 157 /* OverrideKeyword */: + // If node.kind === SyntaxKind.Parameter, checkParameter reports an error if it's not a parameter property. + if (flags & 16384 /* Override */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "override"); + } + else if (flags & 2 /* Ambient */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "override", "declare"); + } + else if (flags & 64 /* Readonly */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "override", "readonly"); + } + else if (flags & 256 /* Async */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "override", "async"); + } + flags |= 16384 /* Override */; + lastOverride = modifier; + break; + case 123 /* PublicKeyword */: + case 122 /* ProtectedKeyword */: + case 121 /* PrivateKeyword */: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); if (flags & 28 /* AccessibilityModifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); } + else if (flags & 16384 /* Override */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "override"); + } else if (flags & 32 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } @@ -79462,23 +82347,23 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 257 /* ModuleBlock */ || node.parent.kind === 297 /* SourceFile */) { + else if (node.parent.kind === 259 /* ModuleBlock */ || node.parent.kind === 299 /* 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 === 120 /* PrivateKeyword */) { + if (modifier.kind === 121 /* PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "abstract"); } } - else if (ts.isPrivateIdentifierPropertyDeclaration(node)) { + else if (ts.isPrivateIdentifierClassElementDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics.An_accessibility_modifier_cannot_be_used_with_a_private_identifier); } flags |= ts.modifierToFlag(modifier.kind); break; - case 123 /* StaticKeyword */: + case 124 /* StaticKeyword */: if (flags & 32 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } @@ -79488,33 +82373,33 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 257 /* ModuleBlock */ || node.parent.kind === 297 /* SourceFile */) { + else if (node.parent.kind === 259 /* ModuleBlock */ || node.parent.kind === 299 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 160 /* Parameter */) { + else if (node.kind === 162 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - else if (ts.isPrivateIdentifierPropertyDeclaration(node)) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "static"); + else if (flags & 16384 /* Override */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "override"); } flags |= 32 /* Static */; lastStatic = modifier; break; - case 142 /* ReadonlyKeyword */: + case 143 /* ReadonlyKeyword */: if (flags & 64 /* Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 163 /* PropertyDeclaration */ && node.kind !== 162 /* PropertySignature */ && node.kind !== 171 /* IndexSignature */ && node.kind !== 160 /* Parameter */) { - // If node.kind === SyntaxKind.Parameter, checkParameter report an error if it's not a parameter property. + else if (node.kind !== 165 /* PropertyDeclaration */ && node.kind !== 164 /* PropertySignature */ && node.kind !== 173 /* IndexSignature */ && node.kind !== 162 /* 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 */; lastReadonly = modifier; break; - case 92 /* ExportKeyword */: + case 93 /* ExportKeyword */: if (flags & 1 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -79530,53 +82415,56 @@ var ts; 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 === 160 /* Parameter */) { + else if (node.kind === 162 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; - case 87 /* DefaultKeyword */: - var container = node.parent.kind === 297 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 256 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + case 88 /* DefaultKeyword */: + var container = node.parent.kind === 299 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 258 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } flags |= 512 /* Default */; break; - case 133 /* DeclareKeyword */: + case 134 /* DeclareKeyword */: if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } + else if (flags & 16384 /* 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 === 160 /* Parameter */) { + else if (node.kind === 162 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 8388608 /* Ambient */) && node.parent.kind === 257 /* ModuleBlock */) { + else if ((node.parent.flags & 8388608 /* Ambient */) && node.parent.kind === 259 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } - else if (ts.isPrivateIdentifierPropertyDeclaration(node)) { + else if (ts.isPrivateIdentifierClassElementDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "declare"); } flags |= 2 /* Ambient */; lastDeclare = modifier; break; - case 125 /* AbstractKeyword */: + case 126 /* AbstractKeyword */: if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 252 /* ClassDeclaration */ && - node.kind !== 175 /* ConstructorType */) { - if (node.kind !== 165 /* MethodDeclaration */ && - node.kind !== 163 /* PropertyDeclaration */ && - node.kind !== 167 /* GetAccessor */ && - node.kind !== 168 /* SetAccessor */) { + if (node.kind !== 254 /* ClassDeclaration */ && + node.kind !== 177 /* ConstructorType */) { + if (node.kind !== 167 /* MethodDeclaration */ && + node.kind !== 165 /* PropertyDeclaration */ && + node.kind !== 169 /* GetAccessor */ && + node.kind !== 170 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 252 /* ClassDeclaration */ && ts.hasSyntacticModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 254 /* ClassDeclaration */ && ts.hasSyntacticModifier(node.parent, 128 /* Abstract */))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32 /* Static */) { @@ -79588,20 +82476,23 @@ var ts; if (flags & 256 /* Async */ && lastAsync) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "async", "abstract"); } + if (flags & 16384 /* Override */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "abstract", "override"); + } } - if (ts.isNamedDeclaration(node) && node.name.kind === 79 /* PrivateIdentifier */) { + if (ts.isNamedDeclaration(node) && node.name.kind === 80 /* PrivateIdentifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "abstract"); } flags |= 128 /* Abstract */; break; - case 129 /* AsyncKeyword */: + case 130 /* AsyncKeyword */: if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } else if (flags & 2 /* Ambient */ || node.parent.flags & 8388608 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 160 /* Parameter */) { + else if (node.kind === 162 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } if (flags & 128 /* Abstract */) { @@ -79612,13 +82503,16 @@ var ts; break; } } - if (node.kind === 166 /* Constructor */) { + if (node.kind === 168 /* Constructor */) { if (flags & 32 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } if (flags & 128 /* Abstract */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract"); // TODO: GH#18217 } + if (flags & 16384 /* Override */) { + return grammarErrorOnNode(lastOverride, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "override"); // TODO: GH#18217 + } else if (flags & 256 /* Async */) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); } @@ -79627,13 +82521,13 @@ var ts; } return false; } - else if ((node.kind === 261 /* ImportDeclaration */ || node.kind === 260 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 263 /* ImportDeclaration */ || node.kind === 262 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 160 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 162 /* Parameter */ && (flags & 16476 /* 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 === 160 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 162 /* Parameter */ && (flags & 16476 /* ParameterPropertyModifier */) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256 /* Async */) { @@ -79654,39 +82548,39 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 166 /* Constructor */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 171 /* IndexSignature */: - case 256 /* ModuleDeclaration */: - case 261 /* ImportDeclaration */: - case 260 /* ImportEqualsDeclaration */: - case 267 /* ExportDeclaration */: - case 266 /* ExportAssignment */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 160 /* Parameter */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 168 /* Constructor */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 173 /* IndexSignature */: + case 258 /* ModuleDeclaration */: + case 263 /* ImportDeclaration */: + case 262 /* ImportEqualsDeclaration */: + case 269 /* ExportDeclaration */: + case 268 /* ExportAssignment */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 162 /* Parameter */: return false; default: - if (node.parent.kind === 257 /* ModuleBlock */ || node.parent.kind === 297 /* SourceFile */) { + if (node.parent.kind === 259 /* ModuleBlock */ || node.parent.kind === 299 /* SourceFile */) { return false; } switch (node.kind) { - case 251 /* FunctionDeclaration */: - return nodeHasAnyModifiersExcept(node, 129 /* AsyncKeyword */); - case 252 /* ClassDeclaration */: - case 175 /* ConstructorType */: - return nodeHasAnyModifiersExcept(node, 125 /* AbstractKeyword */); - case 253 /* InterfaceDeclaration */: - case 232 /* VariableStatement */: - case 254 /* TypeAliasDeclaration */: + case 253 /* FunctionDeclaration */: + return nodeHasAnyModifiersExcept(node, 130 /* AsyncKeyword */); + case 254 /* ClassDeclaration */: + case 177 /* ConstructorType */: + return nodeHasAnyModifiersExcept(node, 126 /* AbstractKeyword */); + case 255 /* InterfaceDeclaration */: + case 234 /* VariableStatement */: + case 256 /* TypeAliasDeclaration */: return true; - case 255 /* EnumDeclaration */: - return nodeHasAnyModifiersExcept(node, 84 /* ConstKeyword */); + case 257 /* EnumDeclaration */: + return nodeHasAnyModifiersExcept(node, 85 /* ConstKeyword */); default: ts.Debug.fail(); } @@ -79697,10 +82591,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 165 /* MethodDeclaration */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -79819,7 +82713,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 147 /* StringKeyword */ && parameter.type.kind !== 144 /* NumberKeyword */) { + if (parameter.type.kind !== 148 /* StringKeyword */ && parameter.type.kind !== 145 /* NumberKeyword */) { var type = getTypeFromTypeNode(parameter.type); if (type.flags & 4 /* String */ || type.flags & 8 /* Number */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead, ts.getTextOfNode(parameter.name), typeToString(type), typeToString(node.type ? getTypeFromTypeNode(node.type) : anyType)); @@ -79861,7 +82755,7 @@ var ts; if (args) { for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 222 /* OmittedExpression */) { + if (arg.kind === 224 /* OmittedExpression */) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -79891,7 +82785,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 === 93 /* ExtendsKeyword */) { + if (heritageClause.token === 94 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -79904,7 +82798,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 116 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 117 /* ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -79920,14 +82814,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 93 /* ExtendsKeyword */) { + if (heritageClause.token === 94 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 116 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 117 /* ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -79938,20 +82832,20 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 158 /* ComputedPropertyName */) { + if (node.kind !== 160 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 216 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* CommaToken */) { + if (computedPropertyName.expression.kind === 218 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* 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 === 251 /* FunctionDeclaration */ || - node.kind === 208 /* FunctionExpression */ || - node.kind === 165 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 253 /* FunctionDeclaration */ || + node.kind === 210 /* FunctionExpression */ || + node.kind === 167 /* MethodDeclaration */); if (node.flags & 8388608 /* Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -79970,7 +82864,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 === 290 /* SpreadAssignment */) { + if (prop.kind === 292 /* SpreadAssignment */) { if (inDestructuring) { // a rest property cannot be destructured any further var expression = ts.skipParentheses(prop.expression); @@ -79981,24 +82875,24 @@ var ts; continue; } var name = prop.name; - if (name.kind === 158 /* ComputedPropertyName */) { + if (name.kind === 160 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 289 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 291 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern // outside of destructuring it is a syntax error return 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 === 79 /* PrivateIdentifier */) { - return grammarErrorOnNode(name, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); + if (name.kind === 80 /* 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 (prop.modifiers) { // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { // TODO: GH#19955 var mod = _c[_b]; - if (mod.kind !== 129 /* AsyncKeyword */ || prop.kind !== 165 /* MethodDeclaration */) { + if (mod.kind !== 130 /* AsyncKeyword */ || prop.kind !== 167 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -80013,10 +82907,10 @@ 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 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); // falls through - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8 /* NumericLiteral */) { @@ -80024,13 +82918,13 @@ var ts; } currentKind = 4 /* PropertyAssignment */; break; - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: currentKind = 8 /* Method */; break; - case 167 /* GetAccessor */: + case 169 /* GetAccessor */: currentKind = 1 /* GetAccessor */; break; - case 168 /* SetAccessor */: + case 170 /* SetAccessor */: currentKind = 2 /* SetAccessor */; break; default: @@ -80065,11 +82959,12 @@ var ts; } } function checkGrammarJsxElement(node) { + checkGrammarJsxName(node.tagName); checkGrammarTypeArguments(node, node.typeArguments); var seen = new ts.Map(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 282 /* JsxSpreadAttribute */) { + if (attr.kind === 284 /* JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -80079,11 +82974,32 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 283 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 285 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } } + function checkGrammarJsxName(node) { + if (ts.isPropertyAccessExpression(node)) { + var propName = node; + do { + var check_1 = checkGrammarJsxNestedIdentifier(propName.name); + if (check_1) { + return check_1; + } + propName = propName.expression; + } while (ts.isPropertyAccessExpression(propName)); + var check = checkGrammarJsxNestedIdentifier(propName); + if (check) { + return check; + } + } + function checkGrammarJsxNestedIdentifier(name) { + if (ts.isIdentifier(name) && ts.idText(name).indexOf(":") !== -1) { + return grammarErrorOnNode(name, ts.Diagnostics.JSX_property_access_expressions_cannot_include_JSX_namespace_names); + } + } + } function checkGrammarJsxExpression(node) { if (node.expression && ts.isCommaSequence(node.expression)) { return grammarErrorOnNode(node.expression, ts.Diagnostics.JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array); @@ -80093,25 +83009,42 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 239 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { - if ((forInOrOfStatement.flags & 32768 /* AwaitContext */) === 0 /* None */) { - // use of 'for-await-of' in non-async function + if (forInOrOfStatement.kind === 241 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if (!(forInOrOfStatement.flags & 32768 /* AwaitContext */)) { var sourceFile = ts.getSourceFileOfNode(forInOrOfStatement); - if (!hasParseDiagnostics(sourceFile)) { - var diagnostic = ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); - var func = ts.getContainingFunction(forInOrOfStatement); - if (func && func.kind !== 166 /* Constructor */) { - ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* 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); - } - diagnostics.add(diagnostic); - return true; + if (ts.isInTopLevelContext(forInOrOfStatement)) { + if (!hasParseDiagnostics(sourceFile)) { + if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) { + diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module)); + } + if ((moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) || languageVersion < 4 /* ES2017 */) { + diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher)); + } + } + } + else { + // use of 'for-await-of' in non-async function + 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 !== 168 /* Constructor */) { + ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* 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); + } + diagnostics.add(diagnostic); + return true; + } } return false; } } - if (forInOrOfStatement.initializer.kind === 250 /* VariableDeclarationList */) { + if (ts.isForOfStatement(forInOrOfStatement) && !(forInOrOfStatement.flags & 32768 /* 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 === 252 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -80126,20 +83059,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 238 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 240 /* 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 === 238 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 240 /* 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 === 238 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 240 /* 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); @@ -80149,26 +83082,34 @@ var ts; return false; } function checkGrammarAccessor(accessor) { - if (!(accessor.flags & 8388608 /* Ambient */)) { + if (!(accessor.flags & 8388608 /* Ambient */) && (accessor.parent.kind !== 179 /* TypeLiteral */) && (accessor.parent.kind !== 255 /* InterfaceDeclaration */)) { if (languageVersion < 1 /* 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)) { + 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 */)) { return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } } - if (accessor.body && ts.hasSyntacticModifier(accessor, 128 /* Abstract */)) { - return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation); + if (accessor.body) { + if (ts.hasSyntacticModifier(accessor, 128 /* Abstract */)) { + return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation); + } + if (accessor.parent.kind === 179 /* TypeLiteral */ || accessor.parent.kind === 255 /* InterfaceDeclaration */) { + return grammarErrorOnNode(accessor.body, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); + } } if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, accessor.kind === 167 /* GetAccessor */ ? + return grammarErrorOnNode(accessor.name, accessor.kind === 169 /* GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - if (accessor.kind === 168 /* SetAccessor */) { + if (accessor.kind === 170 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -80190,17 +83131,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 === 167 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 169 /* GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 167 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 169 /* GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } function checkGrammarTypeOperatorNode(node) { - if (node.operator === 151 /* UniqueKeyword */) { - if (node.type.kind !== 148 /* SymbolKeyword */) { - return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(148 /* SymbolKeyword */)); + if (node.operator === 152 /* UniqueKeyword */) { + if (node.type.kind !== 149 /* SymbolKeyword */) { + return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(149 /* SymbolKeyword */)); } var parent = ts.walkUpParenthesizedTypes(node.parent); if (ts.isInJSFile(parent) && ts.isJSDocTypeExpression(parent)) { @@ -80211,9 +83152,9 @@ var ts; } } switch (parent.kind) { - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: var decl = parent; - if (decl.name.kind !== 78 /* Identifier */) { + if (decl.name.kind !== 79 /* 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)) { @@ -80223,13 +83164,13 @@ var ts; return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: if (!ts.hasSyntacticModifier(parent, 32 /* Static */) || !ts.hasEffectiveModifier(parent, 64 /* Readonly */)) { 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 162 /* PropertySignature */: + case 164 /* PropertySignature */: if (!ts.hasSyntacticModifier(parent, 64 /* 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); } @@ -80238,9 +83179,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_not_allowed_here); } } - else if (node.operator === 142 /* ReadonlyKeyword */) { - if (node.type.kind !== 178 /* ArrayType */ && node.type.kind !== 179 /* TupleType */) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(148 /* SymbolKeyword */)); + else if (node.operator === 143 /* ReadonlyKeyword */) { + if (node.type.kind !== 180 /* ArrayType */ && node.type.kind !== 181 /* TupleType */) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(149 /* SymbolKeyword */)); } } } @@ -80253,10 +83194,10 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 165 /* MethodDeclaration */) { - if (node.parent.kind === 200 /* ObjectLiteralExpression */) { + if (node.kind === 167 /* MethodDeclaration */) { + if (node.parent.kind === 202 /* 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 === 129 /* AsyncKeyword */)) { + if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 130 /* AsyncKeyword */)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } else if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { @@ -80274,6 +83215,9 @@ var ts; } } if (ts.isClassLike(node.parent)) { + if (languageVersion < 2 /* 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 // for property declarations and accessors too, not just methods. // However, property declarations disallow computed names in general, @@ -80282,14 +83226,14 @@ var ts; if (node.flags & 8388608 /* 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 === 165 /* MethodDeclaration */ && !node.body) { + else if (node.kind === 167 /* 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 === 253 /* InterfaceDeclaration */) { + else if (node.parent.kind === 255 /* 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 === 177 /* TypeLiteral */) { + else if (node.parent.kind === 179 /* 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); } } @@ -80300,11 +83244,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 245 /* LabeledStatement */: + case 247 /* 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 === 240 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 242 /* 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); @@ -80312,8 +83256,8 @@ var ts; return false; } break; - case 244 /* SwitchStatement */: - if (node.kind === 241 /* BreakStatement */ && !node.label) { + case 246 /* SwitchStatement */: + if (node.kind === 243 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -80328,13 +83272,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 241 /* BreakStatement */ + var message = node.kind === 243 /* 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 === 241 /* BreakStatement */ + var message = node.kind === 243 /* 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); @@ -80358,12 +83302,12 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return ts.isStringOrNumericLiteralLike(expr) || - expr.kind === 214 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && + expr.kind === 216 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function isBigIntLiteralExpression(expr) { return expr.kind === 9 /* BigIntLiteral */ || - expr.kind === 214 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && + expr.kind === 216 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && expr.operand.kind === 9 /* BigIntLiteral */; } function isSimpleLiteralEnumReference(expr) { @@ -80377,7 +83321,7 @@ var ts; if (initializer) { var isInvalidInitializer = !(isStringOrNumberLiteralExpression(initializer) || isSimpleLiteralEnumReference(initializer) || - initializer.kind === 109 /* TrueKeyword */ || initializer.kind === 94 /* FalseKeyword */ || + initializer.kind === 110 /* TrueKeyword */ || initializer.kind === 95 /* FalseKeyword */ || isBigIntLiteralExpression(initializer)); var isConstOrReadonly = ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node); if (isConstOrReadonly && !node.type) { @@ -80394,7 +83338,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 238 /* ForInStatement */ && node.parent.parent.kind !== 239 /* ForOfStatement */) { + if (node.parent.parent.kind !== 240 /* ForInStatement */ && node.parent.parent.kind !== 241 /* ForOfStatement */) { if (node.flags & 8388608 /* Ambient */) { checkAmbientInitializer(node); } @@ -80407,7 +83351,7 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 232 /* VariableStatement */ || !node.type || node.initializer || node.flags & 8388608 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 234 /* VariableStatement */ || !node.type || node.initializer || node.flags & 8388608 /* Ambient */)) { var message = node.initializer ? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions : !node.type @@ -80430,7 +83374,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkESModuleMarker(name) { - if (name.kind === 78 /* Identifier */) { + if (name.kind === 79 /* 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); } @@ -80447,8 +83391,8 @@ var ts; return false; } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 78 /* Identifier */) { - if (name.originalKeywordKind === 118 /* LetKeyword */) { + if (name.kind === 79 /* Identifier */) { + if (name.originalKeywordKind === 119 /* LetKeyword */) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -80475,15 +83419,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 234 /* IfStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: - case 243 /* WithStatement */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: + case 236 /* IfStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: + case 245 /* WithStatement */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: return false; - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -80501,12 +83445,12 @@ var ts; function checkGrammarMetaProperty(node) { var escapedText = node.name.escapedText; switch (node.keywordToken) { - case 102 /* NewKeyword */: + case 103 /* 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 99 /* ImportKeyword */: + case 100 /* 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"); } @@ -80568,14 +83512,14 @@ var ts; if (ts.isStringLiteral(node.name) && node.name.text === "constructor") { return grammarErrorOnNode(node.name, ts.Diagnostics.Classes_may_not_have_a_field_named_constructor); } - if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { + 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)) { return grammarErrorOnNode(node.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher); } } - else if (node.parent.kind === 253 /* InterfaceDeclaration */) { + else if (node.parent.kind === 255 /* 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; } @@ -80583,7 +83527,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 177 /* TypeLiteral */) { + else if (node.parent.kind === 179 /* TypeLiteral */) { if (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)) { return true; } @@ -80617,13 +83561,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 253 /* InterfaceDeclaration */ || - node.kind === 254 /* TypeAliasDeclaration */ || - node.kind === 261 /* ImportDeclaration */ || - node.kind === 260 /* ImportEqualsDeclaration */ || - node.kind === 267 /* ExportDeclaration */ || - node.kind === 266 /* ExportAssignment */ || - node.kind === 259 /* NamespaceExportDeclaration */ || + if (node.kind === 255 /* InterfaceDeclaration */ || + node.kind === 256 /* TypeAliasDeclaration */ || + node.kind === 263 /* ImportDeclaration */ || + node.kind === 262 /* ImportEqualsDeclaration */ || + node.kind === 269 /* ExportDeclaration */ || + node.kind === 268 /* ExportAssignment */ || + node.kind === 261 /* NamespaceExportDeclaration */ || ts.hasSyntacticModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -80632,7 +83576,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 === 232 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 234 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -80655,7 +83599,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 === 230 /* Block */ || node.parent.kind === 257 /* ModuleBlock */ || node.parent.kind === 297 /* SourceFile */) { + if (node.parent.kind === 232 /* Block */ || node.parent.kind === 259 /* ModuleBlock */ || node.parent.kind === 299 /* SourceFile */) { var links_2 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_2.hasReportedStatementInAmbientContext) { @@ -80677,10 +83621,10 @@ var ts; if (languageVersion >= 1 /* ES5 */) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 191 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 193 /* LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 291 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 293 /* EnumMember */)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { @@ -80786,7 +83730,7 @@ var ts; } } function findBestTypeForObjectLiteral(source, unionTarget) { - if (ts.getObjectFlags(source) & 128 /* ObjectLiteral */ && forEachType(unionTarget, isArrayLikeType)) { + if (ts.getObjectFlags(source) & 128 /* ObjectLiteral */ && someType(unionTarget, isArrayLikeType)) { return ts.find(unionTarget.types, function (t) { return !isArrayLikeType(t); }); } } @@ -80838,6 +83782,10 @@ 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 */)) { + var match = getMatchingUnionConstituentForType(target, source); + if (match) { + return match; + } var sourceProperties = getPropertiesOfType(source); if (sourceProperties) { var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target); @@ -80855,33 +83803,19 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 251 /* FunctionDeclaration */ && declaration.kind !== 165 /* MethodDeclaration */) || + return (declaration.kind !== 253 /* FunctionDeclaration */ && declaration.kind !== 167 /* 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 265 /* ImportSpecifier */: - case 270 /* ExportSpecifier */: + case 267 /* ImportSpecifier */: + case 272 /* ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); } } - function isSomeImportDeclaration(decl) { - switch (decl.kind) { - case 262 /* ImportClause */: // For default import - case 260 /* ImportEqualsDeclaration */: - case 263 /* NamespaceImport */: - case 265 /* ImportSpecifier */: // For rename import `x as y` - return true; - case 78 /* Identifier */: - // For regular import, `decl` is an Identifier under the ImportSpecifier. - return decl.parent.kind === 265 /* ImportSpecifier */; - default: - return false; - } - } var JsxNames; (function (JsxNames) { JsxNames.JSX = "JSX"; @@ -80912,7 +83846,6 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var isTypeNodeOrTypeParameterDeclaration = ts.or(ts.isTypeNode, ts.isTypeParameterDeclaration); function visitNode(node, visitor, test, lift) { if (node === undefined || visitor === undefined) { return node; @@ -81101,6 +84034,24 @@ var ts; return updated; } ts.visitFunctionBody = visitFunctionBody; + /** + * Visits an iteration body, adding any block-scoped variables required by the transformation. + */ + function visitIterationBody(body, visitor, context) { + context.startBlockScope(); + var updated = visitNode(body, visitor, ts.isStatement, context.factory.liftToBlock); + var declarations = context.endBlockScope(); + if (ts.some(declarations)) { + if (ts.isBlock(updated)) { + declarations.push.apply(declarations, updated.statements); + return context.factory.updateBlock(updated, declarations); + } + declarations.push(updated); + return context.factory.createBlock(declarations); + } + return updated; + } + ts.visitIterationBody = visitIterationBody; function visitEachChild(node, visitor, context, nodesVisitor, tokenVisitor, nodeVisitor) { if (nodesVisitor === void 0) { nodesVisitor = visitNodes; } if (nodeVisitor === void 0) { nodeVisitor = visitNode; } @@ -81109,299 +84060,433 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 156 /* LastToken */) || kind === 187 /* ThisType */) { + if ((kind > 0 /* FirstToken */ && kind <= 158 /* LastToken */) || kind === 189 /* ThisType */) { return node; } var factory = context.factory; switch (kind) { // Names - case 78 /* Identifier */: - return factory.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration)); - case 157 /* QualifiedName */: + case 79 /* Identifier */: + ts.Debug.type(node); + return factory.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNodeOrTypeParameterDeclaration)); + case 159 /* QualifiedName */: + ts.Debug.type(node); return factory.updateQualifiedName(node, nodeVisitor(node.left, visitor, ts.isEntityName), nodeVisitor(node.right, visitor, ts.isIdentifier)); - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: + ts.Debug.type(node); return factory.updateComputedPropertyName(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Signature elements - case 159 /* TypeParameter */: + case 161 /* TypeParameter */: + ts.Debug.type(node); return factory.updateTypeParameterDeclaration(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.constraint, visitor, ts.isTypeNode), nodeVisitor(node.default, visitor, ts.isTypeNode)); - case 160 /* Parameter */: - return factory.updateParameterDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isToken), nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 161 /* Decorator */: + case 162 /* Parameter */: + ts.Debug.type(node); + return factory.updateParameterDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), 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 163 /* Decorator */: + ts.Debug.type(node); return factory.updateDecorator(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Type elements - case 162 /* PropertySignature */: - return factory.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isToken), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 163 /* PropertyDeclaration */: + case 164 /* 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 165 /* PropertyDeclaration */: + ts.Debug.type(node); return factory.updatePropertyDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), 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.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 164 /* MethodSignature */: - return factory.updateMethodSignature(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 165 /* MethodDeclaration */: - return factory.updateMethodDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isToken), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), 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 166 /* Constructor */: + nodeVisitor(node.questionToken || node.exclamationToken, tokenVisitor, ts.isQuestionOrExclamationToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); + case 166 /* 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 167 /* MethodDeclaration */: + ts.Debug.type(node); + return factory.updateMethodDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), 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 168 /* Constructor */: + ts.Debug.type(node); return factory.updateConstructorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 167 /* GetAccessor */: + case 169 /* GetAccessor */: + ts.Debug.type(node); return factory.updateGetAccessorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), 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 168 /* SetAccessor */: + case 170 /* SetAccessor */: + ts.Debug.type(node); return factory.updateSetAccessorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 169 /* CallSignature */: + case 171 /* 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 170 /* ConstructSignature */: + case 172 /* 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 171 /* IndexSignature */: + case 173 /* IndexSignature */: + ts.Debug.type(node); return factory.updateIndexSignature(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); // Types - case 172 /* TypePredicate */: - return factory.updateTypePredicateNode(node, nodeVisitor(node.assertsModifier, visitor), nodeVisitor(node.parameterName, visitor), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 173 /* TypeReference */: + case 174 /* 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 175 /* TypeReference */: + ts.Debug.type(node); return factory.updateTypeReferenceNode(node, nodeVisitor(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 174 /* FunctionType */: + case 176 /* 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 175 /* ConstructorType */: + case 177 /* 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 176 /* TypeQuery */: + case 178 /* TypeQuery */: + ts.Debug.type(node); return factory.updateTypeQueryNode(node, nodeVisitor(node.exprName, visitor, ts.isEntityName)); - case 177 /* TypeLiteral */: + case 179 /* TypeLiteral */: + ts.Debug.type(node); return factory.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 178 /* ArrayType */: + case 180 /* ArrayType */: + ts.Debug.type(node); return factory.updateArrayTypeNode(node, nodeVisitor(node.elementType, visitor, ts.isTypeNode)); - case 179 /* TupleType */: + case 181 /* TupleType */: + ts.Debug.type(node); return factory.updateTupleTypeNode(node, nodesVisitor(node.elements, visitor, ts.isTypeNode)); - case 180 /* OptionalType */: + case 182 /* OptionalType */: + ts.Debug.type(node); return factory.updateOptionalTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 181 /* RestType */: + case 183 /* RestType */: + ts.Debug.type(node); return factory.updateRestTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 182 /* UnionType */: + case 184 /* UnionType */: + ts.Debug.type(node); return factory.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 183 /* IntersectionType */: + case 185 /* IntersectionType */: + ts.Debug.type(node); return factory.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 184 /* ConditionalType */: + case 186 /* 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 185 /* InferType */: + case 187 /* InferType */: + ts.Debug.type(node); return factory.updateInferTypeNode(node, nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 195 /* ImportType */: + case 197 /* ImportType */: + ts.Debug.type(node); return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); - case 192 /* NamedTupleMember */: - return factory.updateNamedTupleMember(node, visitNode(node.dotDotDotToken, visitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode)); - case 186 /* ParenthesizedType */: + case 194 /* 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 188 /* ParenthesizedType */: + ts.Debug.type(node); return factory.updateParenthesizedType(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 188 /* TypeOperator */: + case 190 /* TypeOperator */: + ts.Debug.type(node); return factory.updateTypeOperatorNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 189 /* IndexedAccessType */: + case 191 /* IndexedAccessType */: + ts.Debug.type(node); return factory.updateIndexedAccessTypeNode(node, nodeVisitor(node.objectType, visitor, ts.isTypeNode), nodeVisitor(node.indexType, visitor, ts.isTypeNode)); - case 190 /* MappedType */: - return factory.updateMappedTypeNode(node, nodeVisitor(node.readonlyToken, tokenVisitor, ts.isToken), nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration), nodeVisitor(node.nameType, visitor, ts.isTypeNode), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 191 /* LiteralType */: + case 192 /* 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)); + case 193 /* LiteralType */: + ts.Debug.type(node); return factory.updateLiteralTypeNode(node, nodeVisitor(node.literal, visitor, ts.isExpression)); - case 193 /* TemplateLiteralType */: + case 195 /* TemplateLiteralType */: + ts.Debug.type(node); return factory.updateTemplateLiteralType(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateLiteralTypeSpan)); - case 194 /* TemplateLiteralTypeSpan */: + case 196 /* TemplateLiteralTypeSpan */: + ts.Debug.type(node); return factory.updateTemplateLiteralTypeSpan(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Binding patterns - case 196 /* ObjectBindingPattern */: + case 198 /* ObjectBindingPattern */: + ts.Debug.type(node); return factory.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 197 /* ArrayBindingPattern */: + case 199 /* ArrayBindingPattern */: + ts.Debug.type(node); return factory.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 198 /* BindingElement */: - return factory.updateBindingElement(node, nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isToken), nodeVisitor(node.propertyName, visitor, ts.isPropertyName), nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.initializer, visitor, ts.isExpression)); + case 200 /* 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 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: + ts.Debug.type(node); return factory.updateArrayLiteralExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: + ts.Debug.type(node); return factory.updateObjectLiteralExpression(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: if (node.flags & 32 /* OptionalChain */) { - return factory.updatePropertyAccessChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isToken), nodeVisitor(node.name, visitor, ts.isIdentifier)); + 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)); } - return factory.updatePropertyAccessExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.name, visitor, ts.isIdentifierOrPrivateIdentifier)); - case 202 /* ElementAccessExpression */: + ts.Debug.type(node); + return factory.updatePropertyAccessExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.name, visitor, ts.isMemberName)); + case 204 /* ElementAccessExpression */: if (node.flags & 32 /* OptionalChain */) { - return factory.updateElementAccessChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isToken), nodeVisitor(node.argumentExpression, visitor, ts.isExpression)); + 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 203 /* CallExpression */: + case 205 /* CallExpression */: if (node.flags & 32 /* OptionalChain */) { - return factory.updateCallChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); + 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 204 /* NewExpression */: + case 206 /* 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 205 /* TaggedTemplateExpression */: - return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), nodeVisitor(node.template, visitor, ts.isTemplateLiteral)); - case 206 /* TypeAssertionExpression */: + case 207 /* 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 208 /* TypeAssertionExpression */: + ts.Debug.type(node); return factory.updateTypeAssertion(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: + ts.Debug.type(node); return factory.updateParenthesizedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 208 /* FunctionExpression */: - return factory.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isToken), 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 209 /* ArrowFunction */: - 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.isToken), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 210 /* DeleteExpression */: + case 210 /* 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 211 /* 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 212 /* DeleteExpression */: + ts.Debug.type(node); return factory.updateDeleteExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 211 /* TypeOfExpression */: + case 213 /* TypeOfExpression */: + ts.Debug.type(node); return factory.updateTypeOfExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 212 /* VoidExpression */: + case 214 /* VoidExpression */: + ts.Debug.type(node); return factory.updateVoidExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 213 /* AwaitExpression */: + case 215 /* AwaitExpression */: + ts.Debug.type(node); return factory.updateAwaitExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: + ts.Debug.type(node); return factory.updatePrefixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression)); - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: + ts.Debug.type(node); return factory.updatePostfixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression)); - case 216 /* BinaryExpression */: - return factory.updateBinaryExpression(node, nodeVisitor(node.left, visitor, ts.isExpression), nodeVisitor(node.operatorToken, tokenVisitor, ts.isToken), nodeVisitor(node.right, visitor, ts.isExpression)); - case 217 /* ConditionalExpression */: - return factory.updateConditionalExpression(node, nodeVisitor(node.condition, visitor, ts.isExpression), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.whenTrue, visitor, ts.isExpression), nodeVisitor(node.colonToken, tokenVisitor, ts.isToken), nodeVisitor(node.whenFalse, visitor, ts.isExpression)); - case 218 /* TemplateExpression */: + case 218 /* 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 219 /* 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 220 /* TemplateExpression */: + ts.Debug.type(node); return factory.updateTemplateExpression(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 219 /* YieldExpression */: - return factory.updateYieldExpression(node, nodeVisitor(node.asteriskToken, tokenVisitor, ts.isToken), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 220 /* SpreadElement */: + case 221 /* YieldExpression */: + ts.Debug.type(node); + return factory.updateYieldExpression(node, nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.expression, visitor, ts.isExpression)); + case 222 /* SpreadElement */: + ts.Debug.type(node); return factory.updateSpreadElement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: + ts.Debug.type(node); return factory.updateClassExpression(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), 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.isClassElement)); - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: + ts.Debug.type(node); return factory.updateExpressionWithTypeArguments(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 224 /* AsExpression */: + case 226 /* AsExpression */: + ts.Debug.type(node); return factory.updateAsExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 225 /* NonNullExpression */: + case 227 /* NonNullExpression */: if (node.flags & 32 /* 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 226 /* MetaProperty */: + case 228 /* MetaProperty */: + ts.Debug.type(node); return factory.updateMetaProperty(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); // Misc - case 228 /* TemplateSpan */: + case 230 /* TemplateSpan */: + ts.Debug.type(node); return factory.updateTemplateSpan(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 230 /* Block */: + case 232 /* Block */: + ts.Debug.type(node); return factory.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: + ts.Debug.type(node); return factory.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: + ts.Debug.type(node); return factory.updateExpressionStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 234 /* IfStatement */: + case 236 /* 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 235 /* DoStatement */: - return factory.updateDoStatement(node, nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 236 /* WhileStatement */: - return factory.updateWhileStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 237 /* ForStatement */: - return factory.updateForStatement(node, nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.condition, visitor, ts.isExpression), nodeVisitor(node.incrementor, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 238 /* ForInStatement */: - return factory.updateForInStatement(node, nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 239 /* ForOfStatement */: - return factory.updateForOfStatement(node, nodeVisitor(node.awaitModifier, tokenVisitor, ts.isToken), nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 240 /* ContinueStatement */: + case 237 /* DoStatement */: + ts.Debug.type(node); + return factory.updateDoStatement(node, visitIterationBody(node.statement, visitor, context), nodeVisitor(node.expression, visitor, ts.isExpression)); + case 238 /* WhileStatement */: + ts.Debug.type(node); + return factory.updateWhileStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); + case 239 /* 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 240 /* 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 241 /* 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 242 /* ContinueStatement */: + ts.Debug.type(node); return factory.updateContinueStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier)); - case 241 /* BreakStatement */: + case 243 /* BreakStatement */: + ts.Debug.type(node); return factory.updateBreakStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier)); - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: + ts.Debug.type(node); return factory.updateReturnStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 243 /* WithStatement */: + case 245 /* WithStatement */: + ts.Debug.type(node); return factory.updateWithStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: + ts.Debug.type(node); return factory.updateSwitchStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.caseBlock, visitor, ts.isCaseBlock)); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: + ts.Debug.type(node); return factory.updateLabeledStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 246 /* ThrowStatement */: + case 248 /* ThrowStatement */: + ts.Debug.type(node); return factory.updateThrowStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 247 /* TryStatement */: + case 249 /* 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 249 /* VariableDeclaration */: - return factory.updateVariableDeclaration(node, nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.exclamationToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 250 /* VariableDeclarationList */: + case 251 /* 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 252 /* VariableDeclarationList */: + ts.Debug.type(node); return factory.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 251 /* FunctionDeclaration */: - return factory.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isToken), 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 252 /* ClassDeclaration */: + case 253 /* FunctionDeclaration */: + ts.Debug.type(node); + return factory.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), 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 254 /* ClassDeclaration */: + ts.Debug.type(node); return factory.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), 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.isClassElement)); - case 253 /* InterfaceDeclaration */: + case 255 /* InterfaceDeclaration */: + ts.Debug.type(node); return factory.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), 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 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: + ts.Debug.type(node); return factory.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), 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 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: + ts.Debug.type(node); return factory.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); - case 256 /* ModuleDeclaration */: - return factory.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.body, visitor, ts.isModuleBody)); - case 257 /* ModuleBlock */: + case 258 /* ModuleDeclaration */: + ts.Debug.type(node); + return factory.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isModuleName), nodeVisitor(node.body, visitor, ts.isModuleBody)); + case 259 /* ModuleBlock */: + ts.Debug.type(node); return factory.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 258 /* CaseBlock */: + case 260 /* CaseBlock */: + ts.Debug.type(node); return factory.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 259 /* NamespaceExportDeclaration */: + case 261 /* NamespaceExportDeclaration */: + ts.Debug.type(node); return factory.updateNamespaceExportDeclaration(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: + ts.Debug.type(node); return factory.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.moduleReference, visitor, ts.isModuleReference)); - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: + ts.Debug.type(node); return factory.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.importClause, visitor, ts.isImportClause), nodeVisitor(node.moduleSpecifier, visitor, ts.isExpression)); - case 262 /* ImportClause */: + case 264 /* ImportClause */: + ts.Debug.type(node); return factory.updateImportClause(node, node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: + ts.Debug.type(node); return factory.updateNamespaceImport(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 269 /* NamespaceExport */: + case 271 /* NamespaceExport */: + ts.Debug.type(node); return factory.updateNamespaceExport(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 264 /* NamedImports */: + case 266 /* NamedImports */: + ts.Debug.type(node); return factory.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 265 /* ImportSpecifier */: + case 267 /* ImportSpecifier */: + ts.Debug.type(node); return factory.updateImportSpecifier(node, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: + ts.Debug.type(node); return factory.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: + ts.Debug.type(node); return factory.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), node.isTypeOnly, nodeVisitor(node.exportClause, visitor, ts.isNamedExportBindings), nodeVisitor(node.moduleSpecifier, visitor, ts.isExpression)); - case 268 /* NamedExports */: + case 270 /* NamedExports */: + ts.Debug.type(node); return factory.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 270 /* ExportSpecifier */: + case 272 /* ExportSpecifier */: + ts.Debug.type(node); return factory.updateExportSpecifier(node, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier)); // Module references - case 272 /* ExternalModuleReference */: + case 274 /* ExternalModuleReference */: + ts.Debug.type(node); return factory.updateExternalModuleReference(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // JSX - case 273 /* JsxElement */: + case 275 /* 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 274 /* JsxSelfClosingElement */: + case 276 /* 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 275 /* JsxOpeningElement */: + case 277 /* 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 276 /* JsxClosingElement */: + case 278 /* JsxClosingElement */: + ts.Debug.type(node); return factory.updateJsxClosingElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 277 /* JsxFragment */: + case 279 /* 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 280 /* JsxAttribute */: + case 282 /* JsxAttribute */: + ts.Debug.type(node); return factory.updateJsxAttribute(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 281 /* JsxAttributes */: + case 283 /* JsxAttributes */: + ts.Debug.type(node); return factory.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 282 /* JsxSpreadAttribute */: + case 284 /* JsxSpreadAttribute */: + ts.Debug.type(node); return factory.updateJsxSpreadAttribute(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: + ts.Debug.type(node); return factory.updateJsxExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Clauses - case 284 /* CaseClause */: + case 286 /* CaseClause */: + ts.Debug.type(node); return factory.updateCaseClause(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 285 /* DefaultClause */: + case 287 /* DefaultClause */: + ts.Debug.type(node); return factory.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 286 /* HeritageClause */: + case 288 /* HeritageClause */: + ts.Debug.type(node); return factory.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 287 /* CatchClause */: + case 289 /* CatchClause */: + ts.Debug.type(node); return factory.updateCatchClause(node, nodeVisitor(node.variableDeclaration, visitor, ts.isVariableDeclaration), nodeVisitor(node.block, visitor, ts.isBlock)); // Property assignments - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: + ts.Debug.type(node); return factory.updatePropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: + ts.Debug.type(node); return factory.updateShorthandPropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 290 /* SpreadAssignment */: + case 292 /* SpreadAssignment */: + ts.Debug.type(node); return factory.updateSpreadAssignment(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Enum - case 291 /* EnumMember */: + case 293 /* 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 297 /* SourceFile */: + case 299 /* SourceFile */: + ts.Debug.type(node); return factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 336 /* PartiallyEmittedExpression */: + case 344 /* PartiallyEmittedExpression */: + ts.Debug.type(node); return factory.updatePartiallyEmittedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 337 /* CommaListExpression */: + case 345 /* CommaListExpression */: + ts.Debug.type(node); return factory.updateCommaListExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: // No need to visit nodes with no children. @@ -81433,6 +84518,7 @@ var ts; var sourcesContent; var names = []; var nameToNameIndexMap; + var mappingCharCodes = []; var mappings = ""; // Last recorded and encoded mappings var lastGeneratedLine = 0; @@ -81607,6 +84693,14 @@ var ts; || lastSourceCharacter !== pendingSourceCharacter || lastNameIndex !== pendingNameIndex; } + function appendMappingCharCode(charCode) { + mappingCharCodes.push(charCode); + // String.fromCharCode accepts its arguments on the stack, so we have to chunk the input, + // otherwise we can get stack overflows for large source maps + if (mappingCharCodes.length >= 1024) { + flushMappingBuffer(); + } + } function commitPendingMapping() { if (!hasPending || !shouldCommitMapping()) { return; @@ -81616,42 +84710,50 @@ var ts; if (lastGeneratedLine < pendingGeneratedLine) { // Emit line delimiters do { - mappings += ";"; + appendMappingCharCode(59 /* semicolon */); lastGeneratedLine++; - lastGeneratedCharacter = 0; } while (lastGeneratedLine < pendingGeneratedLine); + // Only need to set this once + lastGeneratedCharacter = 0; } else { ts.Debug.assertEqual(lastGeneratedLine, pendingGeneratedLine, "generatedLine cannot backtrack"); // Emit comma to separate the entry if (hasLast) { - mappings += ","; + appendMappingCharCode(44 /* comma */); } } // 1. Relative generated character - mappings += base64VLQFormatEncode(pendingGeneratedCharacter - lastGeneratedCharacter); + appendBase64VLQ(pendingGeneratedCharacter - lastGeneratedCharacter); lastGeneratedCharacter = pendingGeneratedCharacter; if (hasPendingSource) { // 2. Relative sourceIndex - mappings += base64VLQFormatEncode(pendingSourceIndex - lastSourceIndex); + appendBase64VLQ(pendingSourceIndex - lastSourceIndex); lastSourceIndex = pendingSourceIndex; // 3. Relative source line - mappings += base64VLQFormatEncode(pendingSourceLine - lastSourceLine); + appendBase64VLQ(pendingSourceLine - lastSourceLine); lastSourceLine = pendingSourceLine; // 4. Relative source character - mappings += base64VLQFormatEncode(pendingSourceCharacter - lastSourceCharacter); + appendBase64VLQ(pendingSourceCharacter - lastSourceCharacter); lastSourceCharacter = pendingSourceCharacter; if (hasPendingName) { // 5. Relative nameIndex - mappings += base64VLQFormatEncode(pendingNameIndex - lastNameIndex); + appendBase64VLQ(pendingNameIndex - lastNameIndex); lastNameIndex = pendingNameIndex; } } hasLast = true; exit(); } + function flushMappingBuffer() { + if (mappingCharCodes.length > 0) { + mappings += String.fromCharCode.apply(undefined, mappingCharCodes); + mappingCharCodes.length = 0; + } + } function toJSON() { commitPendingMapping(); + flushMappingBuffer(); return { version: 3, file: file, @@ -81662,10 +84764,33 @@ var ts; sourcesContent: sourcesContent, }; } + function appendBase64VLQ(inValue) { + // Add a new least significant bit that has the sign of the value. + // if negative number the least significant bit that gets added to the number has value 1 + // else least significant bit value that gets added is 0 + // eg. -1 changes to binary : 01 [1] => 3 + // +1 changes to binary : 01 [0] => 2 + if (inValue < 0) { + inValue = ((-inValue) << 1) + 1; + } + else { + inValue = inValue << 1; + } + // Encode 5 bits at a time starting from least significant bits + do { + var currentDigit = inValue & 31; // 11111 + inValue = inValue >> 5; + if (inValue > 0) { + // There are still more digits to decode, set the msb (6th bit) + currentDigit = currentDigit | 32; + } + appendMappingCharCode(base64FormatEncode(currentDigit)); + } while (inValue > 0); + } } ts.createSourceMapGenerator = createSourceMapGenerator; // Sometimes tools can see the following line as a source mapping url comment, so we mangle it a bit (the [M]) - var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)\s*$/; + var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)$/; var whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/; function getLineInfo(text, lineStarts) { return { @@ -81682,7 +84807,7 @@ var ts; var line = lineInfo.getLineText(index); var comment = sourceMapCommentRegExp.exec(line); if (comment) { - return comment[1]; + return ts.trimStringEnd(comment[1]); } // If we see a non-whitespace/map comment-like line, break, to avoid scanning up the entire file else if (!line.match(whitespaceOrMapCommentRegExp)) { @@ -81888,31 +85013,6 @@ var ts; ch === 47 /* slash */ ? 63 : -1; } - function base64VLQFormatEncode(inValue) { - // Add a new least significant bit that has the sign of the value. - // if negative number the least significant bit that gets added to the number has value 1 - // else least significant bit value that gets added is 0 - // eg. -1 changes to binary : 01 [1] => 3 - // +1 changes to binary : 01 [0] => 2 - if (inValue < 0) { - inValue = ((-inValue) << 1) + 1; - } - else { - inValue = inValue << 1; - } - // Encode 5 bits at a time starting from least significant bits - var encodedStr = ""; - do { - var currentDigit = inValue & 31; // 11111 - inValue = inValue >> 5; - if (inValue > 0) { - // There are still more digits to decode, set the msb (6th bit) - currentDigit = currentDigit | 32; - } - encodedStr = encodedStr + String.fromCharCode(base64FormatEncode(currentDigit)); - } while (inValue > 0); - return encodedStr; - } function isSourceMappedPosition(value) { return value.sourceIndex !== undefined && value.sourcePosition !== undefined; @@ -82076,7 +85176,7 @@ var ts; function chainBundle(context, transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 297 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 299 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return context.factory.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -82127,7 +85227,7 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" @@ -82140,13 +85240,13 @@ var ts; hasImportDefault = true; } break; - case 260 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 272 /* ExternalModuleReference */) { + case 262 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 274 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -82177,13 +85277,13 @@ var ts; addExportedNamesForExportDeclaration(node); } break; - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: if (ts.hasSyntacticModifier(node, 1 /* Export */)) { for (var _b = 0, _c = node.declarationList.declarations; _b < _c.length; _b++) { var decl = _c[_b]; @@ -82191,7 +85291,7 @@ var ts; } } break; - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: if (ts.hasSyntacticModifier(node, 1 /* Export */)) { if (ts.hasSyntacticModifier(node, 512 /* Default */)) { // export default function() { } @@ -82211,7 +85311,7 @@ var ts; } } break; - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: if (ts.hasSyntacticModifier(node, 1 /* Export */)) { if (ts.hasSyntacticModifier(node, 512 /* Default */)) { // export default class { } @@ -82305,32 +85405,31 @@ var ts; * any such locations */ function isSimpleInlineableExpression(expression) { - return !ts.isIdentifier(expression) && isSimpleCopiableExpression(expression) || - ts.isWellKnownSymbolSyntactically(expression); + return !ts.isIdentifier(expression) && isSimpleCopiableExpression(expression); } ts.isSimpleInlineableExpression = isSimpleInlineableExpression; function isCompoundAssignment(kind) { - return kind >= 63 /* FirstCompoundAssignment */ - && kind <= 77 /* LastCompoundAssignment */; + return kind >= 64 /* FirstCompoundAssignment */ + && kind <= 78 /* LastCompoundAssignment */; } ts.isCompoundAssignment = isCompoundAssignment; function getNonAssignmentOperatorForCompoundAssignment(kind) { switch (kind) { - case 63 /* PlusEqualsToken */: return 39 /* PlusToken */; - case 64 /* MinusEqualsToken */: return 40 /* MinusToken */; - case 65 /* AsteriskEqualsToken */: return 41 /* AsteriskToken */; - case 66 /* AsteriskAsteriskEqualsToken */: return 42 /* AsteriskAsteriskToken */; - case 67 /* SlashEqualsToken */: return 43 /* SlashToken */; - case 68 /* PercentEqualsToken */: return 44 /* PercentToken */; - case 69 /* LessThanLessThanEqualsToken */: return 47 /* LessThanLessThanToken */; - case 70 /* GreaterThanGreaterThanEqualsToken */: return 48 /* GreaterThanGreaterThanToken */; - case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 49 /* GreaterThanGreaterThanGreaterThanToken */; - case 72 /* AmpersandEqualsToken */: return 50 /* AmpersandToken */; - case 73 /* BarEqualsToken */: return 51 /* BarToken */; - case 77 /* CaretEqualsToken */: return 52 /* CaretToken */; - case 74 /* BarBarEqualsToken */: return 56 /* BarBarToken */; - case 75 /* AmpersandAmpersandEqualsToken */: return 55 /* AmpersandAmpersandToken */; - case 76 /* QuestionQuestionEqualsToken */: return 60 /* QuestionQuestionToken */; + 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 */; } } ts.getNonAssignmentOperatorForCompoundAssignment = getNonAssignmentOperatorForCompoundAssignment; @@ -82385,10 +85484,19 @@ var ts; * @param isStatic A value indicating whether the member should be a static or instance member. */ function isInitializedProperty(member) { - return member.kind === 163 /* PropertyDeclaration */ + return member.kind === 165 /* PropertyDeclaration */ && member.initializer !== undefined; } ts.isInitializedProperty = isInitializedProperty; + /** + * Gets a value indicating whether a class element is a private instance method or accessor. + * + * @param member The class element node. + */ + function isNonStaticMethodOrAccessorWithPrivateName(member) { + return !ts.hasStaticModifier(member) && ts.isMethodOrAccessor(member) && ts.isPrivateIdentifier(member.name); + } + ts.isNonStaticMethodOrAccessorWithPrivateName = isNonStaticMethodOrAccessorWithPrivateName; })(ts || (ts = {})); /*@internal*/ var ts; @@ -82662,8 +85770,8 @@ var ts; if (!ts.getRestIndicatorOfBindingOrAssignmentElement(element)) { var propertyName = ts.getPropertyNameOfBindingOrAssignmentElement(element); if (flattenContext.level >= 1 /* ObjectRest */ - && !(element.transformFlags & (8192 /* ContainsRestOrSpread */ | 16384 /* ContainsObjectRestOrSpread */)) - && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (8192 /* ContainsRestOrSpread */ | 16384 /* ContainsObjectRestOrSpread */)) + && !(element.transformFlags & (16384 /* ContainsRestOrSpread */ | 32768 /* ContainsObjectRestOrSpread */)) + && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (16384 /* ContainsRestOrSpread */ | 32768 /* ContainsObjectRestOrSpread */)) && !ts.isComputedPropertyName(propertyName)) { bindingElements = ts.append(bindingElements, ts.visitNode(element, flattenContext.visitor)); } @@ -82729,7 +85837,7 @@ var ts; if (flattenContext.level >= 1 /* 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 & 16384 /* ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) { + if (element.transformFlags & 32768 /* ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) { flattenContext.hasTransformedPriorElement = true; var temp = flattenContext.context.factory.createTempVariable(/*recordTempVariable*/ undefined); if (flattenContext.hoistTempVariables) { @@ -82987,8 +86095,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(201 /* PropertyAccessExpression */); - context.enableSubstitution(202 /* ElementAccessExpression */); + context.enableSubstitution(203 /* PropertyAccessExpression */); + context.enableSubstitution(204 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -83014,14 +86122,14 @@ var ts; var applicableSubstitutions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 298 /* Bundle */) { + if (node.kind === 300 /* 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 === 300 /* InputFiles */) { + if (prepend.kind === 302 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend, "js"); } return prepend; @@ -83072,16 +86180,16 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 297 /* SourceFile */: - case 258 /* CaseBlock */: - case 257 /* ModuleBlock */: - case 230 /* Block */: + case 299 /* SourceFile */: + case 260 /* CaseBlock */: + case 259 /* ModuleBlock */: + case 232 /* Block */: currentLexicalScope = node; currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 252 /* ClassDeclaration */: - case 251 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: + case 253 /* FunctionDeclaration */: if (ts.hasSyntacticModifier(node, 2 /* Ambient */)) { break; } @@ -83093,7 +86201,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 === 252 /* ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 254 /* ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* Default */)); } if (ts.isClassDeclaration(node)) { // XXX: should probably also cover interfaces and type aliases that can have type variables? @@ -83136,10 +86244,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: - case 260 /* ImportEqualsDeclaration */: - case 266 /* ExportAssignment */: - case 267 /* ExportDeclaration */: + case 263 /* ImportDeclaration */: + case 262 /* ImportEqualsDeclaration */: + case 268 /* ExportAssignment */: + case 269 /* ExportDeclaration */: return visitElidableStatement(node); default: return visitorWorker(node); @@ -83160,13 +86268,13 @@ var ts; return node; } switch (node.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return visitImportDeclaration(node); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return visitExportAssignment(node); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -83186,11 +86294,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 267 /* ExportDeclaration */ || - node.kind === 261 /* ImportDeclaration */ || - node.kind === 262 /* ImportClause */ || - (node.kind === 260 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 272 /* ExternalModuleReference */)) { + if (node.kind === 269 /* ExportDeclaration */ || + node.kind === 263 /* ImportDeclaration */ || + node.kind === 264 /* ImportClause */ || + (node.kind === 262 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 274 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -83214,29 +86322,29 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 166 /* Constructor */: + case 168 /* Constructor */: return visitConstructor(node); - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: // Property declarations are not TypeScript syntax, but they must be visited // for the decorator transformation. return visitPropertyDeclaration(node); - case 171 /* IndexSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 165 /* MethodDeclaration */: + case 173 /* IndexSignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 167 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 229 /* SemicolonClassElement */: + case 231 /* SemicolonClassElement */: return node; default: return ts.Debug.failBadSyntaxKind(node); } } function modifierVisitor(node) { - if (ts.modifierToFlag(node.kind) & 2270 /* TypeScriptModifier */) { + if (ts.modifierToFlag(node.kind) & 18654 /* TypeScriptModifier */) { return undefined; } - else if (currentNamespace && node.kind === 92 /* ExportKeyword */) { + else if (currentNamespace && node.kind === 93 /* ExportKeyword */) { return undefined; } return node; @@ -83253,71 +86361,71 @@ var ts; return factory.createNotEmittedStatement(node); } switch (node.kind) { - case 92 /* ExportKeyword */: - case 87 /* DefaultKeyword */: + case 93 /* ExportKeyword */: + case 88 /* DefaultKeyword */: // ES6 export and default modifiers are elided when inside a namespace. return currentNamespace ? undefined : node; - case 122 /* PublicKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 125 /* AbstractKeyword */: - case 84 /* ConstKeyword */: - case 133 /* DeclareKeyword */: - case 142 /* ReadonlyKeyword */: + case 123 /* PublicKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + case 126 /* AbstractKeyword */: + case 85 /* ConstKeyword */: + case 134 /* DeclareKeyword */: + case 143 /* ReadonlyKeyword */: // TypeScript accessibility and readonly modifiers are elided // falls through - case 178 /* ArrayType */: - case 179 /* TupleType */: - case 180 /* OptionalType */: - case 181 /* RestType */: - case 177 /* TypeLiteral */: - case 172 /* TypePredicate */: - case 159 /* TypeParameter */: - case 128 /* AnyKeyword */: - case 152 /* UnknownKeyword */: - case 131 /* BooleanKeyword */: - case 147 /* StringKeyword */: - case 144 /* NumberKeyword */: - case 141 /* NeverKeyword */: - case 113 /* VoidKeyword */: - case 148 /* SymbolKeyword */: - case 175 /* ConstructorType */: - case 174 /* FunctionType */: - case 176 /* TypeQuery */: - case 173 /* TypeReference */: - case 182 /* UnionType */: - case 183 /* IntersectionType */: - case 184 /* ConditionalType */: - case 186 /* ParenthesizedType */: - case 187 /* ThisType */: - case 188 /* TypeOperator */: - case 189 /* IndexedAccessType */: - case 190 /* MappedType */: - case 191 /* LiteralType */: + case 180 /* ArrayType */: + case 181 /* TupleType */: + case 182 /* OptionalType */: + case 183 /* RestType */: + case 179 /* TypeLiteral */: + case 174 /* TypePredicate */: + case 161 /* TypeParameter */: + case 129 /* AnyKeyword */: + case 153 /* UnknownKeyword */: + case 132 /* BooleanKeyword */: + case 148 /* StringKeyword */: + case 145 /* NumberKeyword */: + case 142 /* NeverKeyword */: + case 114 /* VoidKeyword */: + case 149 /* SymbolKeyword */: + case 177 /* ConstructorType */: + case 176 /* FunctionType */: + case 178 /* TypeQuery */: + case 175 /* TypeReference */: + case 184 /* UnionType */: + case 185 /* IntersectionType */: + case 186 /* ConditionalType */: + case 188 /* ParenthesizedType */: + case 189 /* ThisType */: + case 190 /* TypeOperator */: + case 191 /* IndexedAccessType */: + case 192 /* MappedType */: + case 193 /* LiteralType */: // TypeScript type nodes are elided. // falls through - case 171 /* IndexSignature */: + case 173 /* IndexSignature */: // TypeScript index signatures are elided. // falls through - case 161 /* Decorator */: + case 163 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. // falls through - case 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return undefined; - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: // TypeScript property declarations are elided. However their names are still visited, and can potentially be retained if they could have sideeffects return visitPropertyDeclaration(node); - case 259 /* NamespaceExportDeclaration */: + case 261 /* NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; - case 166 /* Constructor */: + case 168 /* Constructor */: return visitConstructor(node); - case 253 /* InterfaceDeclaration */: + case 255 /* 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 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: // This may be a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -83327,7 +86435,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: // This may be a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -83337,35 +86445,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 286 /* HeritageClause */: + case 288 /* HeritageClause */: // This may be a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 167 /* GetAccessor */: + case 169 /* GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 168 /* SetAccessor */: + case 170 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 160 /* Parameter */: + case 162 /* Parameter */: // This may be a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -83375,40 +86483,40 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 206 /* TypeAssertionExpression */: - case 224 /* AsExpression */: + case 208 /* TypeAssertionExpression */: + case 226 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return visitCallExpression(node); - case 204 /* NewExpression */: + case 206 /* NewExpression */: return visitNewExpression(node); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 225 /* NonNullExpression */: + case 227 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); - case 274 /* JsxSelfClosingElement */: + case 276 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node); - case 275 /* JsxOpeningElement */: + case 277 /* JsxOpeningElement */: return visitJsxJsxOpeningElement(node); default: // node contains some other TypeScript syntax @@ -83445,7 +86553,7 @@ var ts; if (ts.some(staticProperties)) facts |= 1 /* HasStaticInitializedProperties */; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 103 /* NullKeyword */) + if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */) facts |= 64 /* IsDerivedClass */; if (shouldEmitDecorateCallForClass(node)) facts |= 2 /* HasConstructorDecorators */; @@ -83462,7 +86570,7 @@ var ts; return facts; } function hasTypeScriptClassSyntax(node) { - return !!(node.transformFlags & 2048 /* ContainsTypeScriptClassSyntax */); + return !!(node.transformFlags & 4096 /* ContainsTypeScriptClassSyntax */); } function isClassLikeDeclarationWithTypeScriptSyntax(node) { return ts.some(node.decorators) @@ -83817,12 +86925,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -83975,7 +87083,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ true); var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 163 /* PropertyDeclaration */ + ? member.kind === 165 /* 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() @@ -84099,10 +87207,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 165 /* MethodDeclaration */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */ - || kind === 163 /* PropertyDeclaration */; + return kind === 167 /* MethodDeclaration */ + || kind === 169 /* GetAccessor */ + || kind === 170 /* SetAccessor */ + || kind === 165 /* PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -84112,7 +87220,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 165 /* MethodDeclaration */; + return node.kind === 167 /* MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -84123,12 +87231,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return true; } return false; @@ -84145,15 +87253,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 163 /* PropertyDeclaration */: - case 160 /* Parameter */: + case 165 /* PropertyDeclaration */: + case 162 /* Parameter */: return serializeTypeNode(node.type); - case 168 /* SetAccessor */: - case 167 /* GetAccessor */: + case 170 /* SetAccessor */: + case 169 /* GetAccessor */: return serializeTypeNode(getAccessorTypeNode(node)); - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 165 /* MethodDeclaration */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 167 /* MethodDeclaration */: return factory.createIdentifier("Function"); default: return factory.createVoidZero(); @@ -84190,7 +87298,7 @@ var ts; return factory.createArrayLiteralExpression(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 167 /* GetAccessor */) { + if (container && node.kind === 169 /* GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -84235,82 +87343,82 @@ var ts; return factory.createIdentifier("Object"); } switch (node.kind) { - case 113 /* VoidKeyword */: - case 150 /* UndefinedKeyword */: - case 141 /* NeverKeyword */: + case 114 /* VoidKeyword */: + case 151 /* UndefinedKeyword */: + case 142 /* NeverKeyword */: return factory.createVoidZero(); - case 186 /* ParenthesizedType */: + case 188 /* ParenthesizedType */: return serializeTypeNode(node.type); - case 174 /* FunctionType */: - case 175 /* ConstructorType */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: return factory.createIdentifier("Function"); - case 178 /* ArrayType */: - case 179 /* TupleType */: + case 180 /* ArrayType */: + case 181 /* TupleType */: return factory.createIdentifier("Array"); - case 172 /* TypePredicate */: - case 131 /* BooleanKeyword */: + case 174 /* TypePredicate */: + case 132 /* BooleanKeyword */: return factory.createIdentifier("Boolean"); - case 147 /* StringKeyword */: + case 148 /* StringKeyword */: return factory.createIdentifier("String"); - case 145 /* ObjectKeyword */: + case 146 /* ObjectKeyword */: return factory.createIdentifier("Object"); - case 191 /* LiteralType */: + case 193 /* LiteralType */: switch (node.literal.kind) { case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return factory.createIdentifier("String"); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: case 8 /* NumericLiteral */: return factory.createIdentifier("Number"); case 9 /* BigIntLiteral */: return getGlobalBigIntNameWithFallback(); - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: return factory.createIdentifier("Boolean"); - case 103 /* NullKeyword */: + case 104 /* NullKeyword */: return factory.createVoidZero(); default: return ts.Debug.failBadSyntaxKind(node.literal); } - case 144 /* NumberKeyword */: + case 145 /* NumberKeyword */: return factory.createIdentifier("Number"); - case 155 /* BigIntKeyword */: + case 156 /* BigIntKeyword */: return getGlobalBigIntNameWithFallback(); - case 148 /* SymbolKeyword */: + case 149 /* SymbolKeyword */: return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : factory.createIdentifier("Symbol"); - case 173 /* TypeReference */: + case 175 /* TypeReference */: return serializeTypeReferenceNode(node); - case 183 /* IntersectionType */: - case 182 /* UnionType */: + case 185 /* IntersectionType */: + case 184 /* UnionType */: return serializeTypeList(node.types); - case 184 /* ConditionalType */: + case 186 /* ConditionalType */: return serializeTypeList([node.trueType, node.falseType]); - case 188 /* TypeOperator */: - if (node.operator === 142 /* ReadonlyKeyword */) { + case 190 /* TypeOperator */: + if (node.operator === 143 /* ReadonlyKeyword */) { return serializeTypeNode(node.type); } break; - case 176 /* TypeQuery */: - case 189 /* IndexedAccessType */: - case 190 /* MappedType */: - case 177 /* TypeLiteral */: - case 128 /* AnyKeyword */: - case 152 /* UnknownKeyword */: - case 187 /* ThisType */: - case 195 /* ImportType */: + case 178 /* TypeQuery */: + case 191 /* IndexedAccessType */: + case 192 /* MappedType */: + case 179 /* TypeLiteral */: + case 129 /* AnyKeyword */: + case 153 /* UnknownKeyword */: + case 189 /* ThisType */: + case 197 /* ImportType */: break; // handle JSDoc types from an invalid parse - case 303 /* JSDocAllType */: - case 304 /* JSDocUnknownType */: - case 308 /* JSDocFunctionType */: - case 309 /* JSDocVariadicType */: - case 310 /* JSDocNamepathType */: + case 306 /* JSDocAllType */: + case 307 /* JSDocUnknownType */: + case 311 /* JSDocFunctionType */: + case 312 /* JSDocVariadicType */: + case 313 /* JSDocNamepathType */: break; - case 305 /* JSDocNullableType */: - case 306 /* JSDocNonNullableType */: - case 307 /* JSDocOptionalType */: + case 308 /* JSDocNullableType */: + case 309 /* JSDocNonNullableType */: + case 310 /* JSDocOptionalType */: return serializeTypeNode(node.type); default: return ts.Debug.failBadSyntaxKind(node); @@ -84323,13 +87431,13 @@ var ts; var serializedUnion; for (var _i = 0, types_24 = types; _i < types_24.length; _i++) { var typeNode = types_24[_i]; - while (typeNode.kind === 186 /* ParenthesizedType */) { + while (typeNode.kind === 188 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 141 /* NeverKeyword */) { + if (typeNode.kind === 142 /* NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 191 /* LiteralType */ && typeNode.literal.kind === 103 /* NullKeyword */ || typeNode.kind === 150 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 193 /* LiteralType */ && typeNode.literal.kind === 104 /* NullKeyword */ || typeNode.kind === 151 /* UndefinedKeyword */)) { continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks } var serializedIndividual = serializeTypeNode(typeNode); @@ -84411,12 +87519,12 @@ var ts; * @param node The entity name to serialize. */ function serializeEntityNameAsExpressionFallback(node) { - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { // A -> typeof A !== undefined && A var copied = serializeEntityNameAsExpression(node); return createCheckedValue(copied, copied); } - if (node.left.kind === 78 /* Identifier */) { + if (node.left.kind === 79 /* Identifier */) { // A.B -> typeof A !== undefined && A.B return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node)); } @@ -84432,14 +87540,14 @@ var ts; */ function serializeEntityNameAsExpression(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* 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 157 /* QualifiedName */: + case 159 /* QualifiedName */: return serializeQualifiedNameAsExpression(node); } } @@ -84530,7 +87638,7 @@ var ts; * @param node The HeritageClause to transform. */ function visitHeritageClause(node) { - if (node.token === 116 /* ImplementsKeyword */) { + if (node.token === 117 /* ImplementsKeyword */) { // implements clauses are elided return undefined; } @@ -84827,8 +87935,7 @@ var ts; */ function shouldEmitEnumDeclaration(node) { return !ts.isEnumConst(node) - || compilerOptions.preserveConstEnums - || compilerOptions.isolatedModules; + || ts.shouldPreserveConstEnums(compilerOptions); } /** * Visits an enum declaration. @@ -84962,7 +88069,7 @@ var ts; // If we can't find a parse tree node, assume the node is instantiated. return true; } - return ts.isInstantiatedModule(node, !!compilerOptions.preserveConstEnums || !!compilerOptions.isolatedModules); + return ts.isInstantiatedModule(node, ts.shouldPreserveConstEnums(compilerOptions)); } /** * Determines whether an exported declaration will have a qualified export name (e.g. `f.x` @@ -85013,12 +88120,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 === 297 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 299 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { // Adjust the source map emit to match the old emitter. - if (node.kind === 255 /* EnumDeclaration */) { + if (node.kind === 257 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -85143,7 +88250,7 @@ var ts; var statementsLocation; var blockLocation; if (node.body) { - if (node.body.kind === 257 /* ModuleBlock */) { + if (node.body.kind === 259 /* ModuleBlock */) { saveStateAndInvoke(node.body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = node.body.statements; blockLocation = node.body; @@ -85190,13 +88297,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 !== 257 /* ModuleBlock */) { + if (!node.body || node.body.kind !== 259 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 256 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 258 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -85246,7 +88353,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 263 /* NamespaceImport */) { + if (node.kind === 265 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -85480,7 +88587,7 @@ var ts; function enableSubstitutionForNonQualifiedEnumMembers() { if ((enabledSubstitutions & 8 /* NonQualifiedEnumMembers */) === 0) { enabledSubstitutions |= 8 /* NonQualifiedEnumMembers */; - context.enableSubstitution(78 /* Identifier */); + context.enableSubstitution(79 /* Identifier */); } } function enableSubstitutionForClassAliases() { @@ -85488,7 +88595,7 @@ var ts; enabledSubstitutions |= 1 /* ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(78 /* Identifier */); + context.enableSubstitution(79 /* Identifier */); // Keep track of class aliases. classAliases = []; } @@ -85498,17 +88605,17 @@ var ts; enabledSubstitutions |= 2 /* 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(78 /* Identifier */); - context.enableSubstitution(289 /* ShorthandPropertyAssignment */); + context.enableSubstitution(79 /* Identifier */); + context.enableSubstitution(291 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(256 /* ModuleDeclaration */); + context.enableEmitNotification(258 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 256 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 258 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 255 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 257 /* EnumDeclaration */; } /** * Hook for node emit. @@ -85567,11 +88674,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return substituteExpressionIdentifier(node); - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -85593,10 +88700,10 @@ var ts; if (declaration) { var classAlias = classAliases[declaration.id]; // TODO: GH#18217 if (classAlias) { - var clone_1 = factory.cloneNode(classAlias); - ts.setSourceMapRange(clone_1, node); - ts.setCommentRange(clone_1, node); - return clone_1; + var clone_2 = factory.cloneNode(classAlias); + ts.setSourceMapRange(clone_2, node); + ts.setCommentRange(clone_2, node); + return clone_2; } } } @@ -85609,9 +88716,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 !== 297 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 256 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 255 /* EnumDeclaration */); + if (container && container.kind !== 299 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 258 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 257 /* EnumDeclaration */); if (substitute) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(container), node), /*location*/ node); @@ -85663,10 +88770,12 @@ var ts; */ ClassPropertySubstitutionFlags[ClassPropertySubstitutionFlags["ClassAliases"] = 1] = "ClassAliases"; })(ClassPropertySubstitutionFlags || (ClassPropertySubstitutionFlags = {})); - var PrivateIdentifierPlacement; - (function (PrivateIdentifierPlacement) { - PrivateIdentifierPlacement[PrivateIdentifierPlacement["InstanceField"] = 0] = "InstanceField"; - })(PrivateIdentifierPlacement || (PrivateIdentifierPlacement = {})); + var PrivateIdentifierKind; + (function (PrivateIdentifierKind) { + PrivateIdentifierKind["Field"] = "f"; + PrivateIdentifierKind["Method"] = "m"; + PrivateIdentifierKind["Accessor"] = "a"; + })(PrivateIdentifierKind = ts.PrivateIdentifierKind || (ts.PrivateIdentifierKind = {})); /** * Transforms ECMAScript Class Syntax. * TypeScript parameter property syntax is transformed in the TypeScript transformer. @@ -85675,11 +88784,12 @@ var ts; * When --useDefineForClassFields is on, this transforms to ECMAScript semantics, with Object.defineProperty. */ function transformClassFields(context) { - var factory = context.factory, hoistVariableDeclaration = context.hoistVariableDeclaration, endLexicalEnvironment = context.endLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment; + var factory = context.factory, hoistVariableDeclaration = context.hoistVariableDeclaration, endLexicalEnvironment = context.endLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, addBlockScopedVariable = context.addBlockScopedVariable; var resolver = context.getEmitResolver(); var compilerOptions = context.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); - var shouldTransformPrivateFields = languageVersion < 99 /* ESNext */; + var useDefineForClassFields = ts.getUseDefineForClassFields(compilerOptions); + var shouldTransformPrivateElements = languageVersion < 99 /* ESNext */; var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; var enabledSubstitutions; @@ -85700,7 +88810,7 @@ var ts; function transformSourceFile(node) { var options = context.getCompilerOptions(); if (node.isDeclarationFile - || options.useDefineForClassFields && options.target === 99 /* ESNext */) { + || useDefineForClassFields && options.target === 99 /* ESNext */) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -85708,41 +88818,41 @@ var ts; return visited; } function visitor(node) { - if (!(node.transformFlags & 4194304 /* ContainsClassFields */)) + if (!(node.transformFlags & 8388608 /* ContainsClassFields */)) return node; switch (node.kind) { - case 221 /* ClassExpression */: - case 252 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 254 /* ClassDeclaration */: return visitClassLike(node); - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return visitPropertyDeclaration(node); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return visitVariableStatement(node); - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return visitPropertyAccessExpression(node); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return visitPrefixUnaryExpression(node); - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: return visitPostfixUnaryExpression(node, /*valueIsDiscarded*/ false); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return visitCallExpression(node); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return visitBinaryExpression(node); - case 79 /* PrivateIdentifier */: + case 80 /* PrivateIdentifier */: return visitPrivateIdentifier(node); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: return visitExpressionStatement(node); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return visitForStatement(node); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); } return ts.visitEachChild(node, visitor, context); } function visitorDestructuringTarget(node) { switch (node.kind) { - case 200 /* ObjectLiteralExpression */: - case 199 /* ArrayLiteralExpression */: + case 202 /* ObjectLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return visitAssignmentPattern(node); default: return visitor(node); @@ -85753,7 +88863,7 @@ var ts; * Replace it with an empty identifier to indicate a problem with the code. */ function visitPrivateIdentifier(node) { - if (!shouldTransformPrivateFields) { + if (!shouldTransformPrivateElements) { return node; } return ts.setOriginalNode(factory.createIdentifier(""), node); @@ -85765,20 +88875,19 @@ var ts; */ function classElementVisitor(node) { switch (node.kind) { - case 166 /* Constructor */: + case 168 /* Constructor */: // Constructors for classes using class fields are transformed in // `visitClassDeclaration` or `visitClassExpression`. return undefined; - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 165 /* MethodDeclaration */: - // Visit the name of the member (if it's a computed property name). - return ts.visitEachChild(node, classElementVisitor, context); - case 163 /* PropertyDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 167 /* MethodDeclaration */: + return visitMethodOrAccessorDeclaration(node); + case 165 /* PropertyDeclaration */: return visitPropertyDeclaration(node); - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 229 /* SemicolonClassElement */: + case 231 /* SemicolonClassElement */: return node; default: return visitor(node); @@ -85803,44 +88912,96 @@ var ts; } return node; } + function visitMethodOrAccessorDeclaration(node) { + ts.Debug.assert(!ts.some(node.decorators)); + if (!shouldTransformPrivateElements || !ts.isPrivateIdentifier(node.name)) { + return ts.visitEachChild(node, classElementVisitor, context); + } + // leave invalid code untransformed + var info = accessPrivateIdentifier(node.name); + ts.Debug.assert(info, "Undeclared private name for property declaration."); + if (!info.isValid) { + return node; + } + var functionName = getHoistedFunctionName(node); + if (functionName) { + getPendingExpressions().push(factory.createAssignment(functionName, factory.createFunctionExpression(ts.filter(node.modifiers, function (m) { return !ts.isStaticModifier(m); }), node.asteriskToken, functionName, + /* typeParameters */ undefined, ts.visitParameterList(node.parameters, classElementVisitor, context), + /* type */ undefined, ts.visitFunctionBody(node.body, classElementVisitor, context)))); + } + // remove method declaration from class + return undefined; + } + function getHoistedFunctionName(node) { + 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 */) { + return info.methodName; + } + if (info.kind === "a" /* Accessor */) { + if (ts.isGetAccessor(node)) { + return info.getterName; + } + if (ts.isSetAccessor(node)) { + return info.setterName; + } + } + } function visitPropertyDeclaration(node) { ts.Debug.assert(!ts.some(node.decorators)); - if (!shouldTransformPrivateFields && ts.isPrivateIdentifier(node.name)) { - // Initializer is elided as the field is initialized in transformConstructor. - return factory.updatePropertyDeclaration(node, - /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name, - /*questionOrExclamationToken*/ undefined, - /*type*/ undefined, - /*initializer*/ undefined); + if (ts.isPrivateIdentifier(node.name)) { + if (!shouldTransformPrivateElements) { + // Initializer is elided as the field is initialized in transformConstructor. + return factory.updatePropertyDeclaration(node, + /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name, + /*questionOrExclamationToken*/ undefined, + /*type*/ undefined, + /*initializer*/ undefined); + } + // leave invalid code untransformed + var info = accessPrivateIdentifier(node.name); + ts.Debug.assert(info, "Undeclared private name for property declaration."); + if (!info.isValid) { + return node; + } } // Create a temporary variable to store a computed property name (if necessary). // If it's not inlineable, then we emit an expression after the class which assigns // the property name to the temporary variable. - var expr = getPropertyNameExpressionIfNeeded(node.name, !!node.initializer || !!context.getCompilerOptions().useDefineForClassFields); + var expr = getPropertyNameExpressionIfNeeded(node.name, !!node.initializer || useDefineForClassFields); if (expr && !ts.isSimpleInlineableExpression(expr)) { getPendingExpressions().push(expr); } return undefined; } function createPrivateIdentifierAccess(info, receiver) { - receiver = ts.visitNode(receiver, visitor, ts.isExpression); - switch (info.placement) { - case 0 /* InstanceField */: - return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(ts.nodeIsSynthesized(receiver) ? receiver : factory.cloneNode(receiver), info.weakMapName); - default: return ts.Debug.fail("Unexpected private identifier placement"); + return createPrivateIdentifierAccessHelper(info, ts.visitNode(receiver, visitor, ts.isExpression)); + } + function createPrivateIdentifierAccessHelper(info, receiver) { + ts.setCommentRange(receiver, ts.moveRangePos(receiver, -1)); + switch (info.kind) { + case "a" /* Accessor */: + return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.getterName); + case "m" /* Method */: + return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.methodName); + case "f" /* Field */: + return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.variableName); + default: + ts.Debug.assertNever(info, "Unknown private element type"); } } function visitPropertyAccessExpression(node) { - if (shouldTransformPrivateFields && ts.isPrivateIdentifier(node.name)) { + if (shouldTransformPrivateElements && ts.isPrivateIdentifier(node.name)) { var privateIdentifierInfo = accessPrivateIdentifier(node.name); if (privateIdentifierInfo) { - return ts.setOriginalNode(createPrivateIdentifierAccess(privateIdentifierInfo, node.expression), node); + return ts.setTextRange(ts.setOriginalNode(createPrivateIdentifierAccess(privateIdentifierInfo, node.expression), node), node); } } return ts.visitEachChild(node, visitor, context); } function visitPrefixUnaryExpression(node) { - if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { + if (shouldTransformPrivateElements && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { var operator = node.operator === 45 /* PlusPlusToken */ ? 39 /* PlusToken */ : node.operator === 46 /* MinusMinusToken */ ? 40 /* MinusToken */ : undefined; @@ -85849,13 +89010,13 @@ var ts; var receiver = ts.visitNode(node.operand.expression, visitor, ts.isExpression); var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression; var existingValue = factory.createPrefixUnaryExpression(39 /* PlusToken */, createPrivateIdentifierAccess(info, readExpression)); - return ts.setOriginalNode(createPrivateIdentifierAssignment(info, initializeExpression || readExpression, factory.createBinaryExpression(existingValue, operator, factory.createNumericLiteral(1)), 62 /* EqualsToken */), node); + return ts.setOriginalNode(createPrivateIdentifierAssignment(info, initializeExpression || readExpression, factory.createBinaryExpression(existingValue, operator, factory.createNumericLiteral(1)), 63 /* EqualsToken */), node); } } return ts.visitEachChild(node, visitor, context); } function visitPostfixUnaryExpression(node, valueIsDiscarded) { - if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { + if (shouldTransformPrivateElements && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { var operator = node.operator === 45 /* PlusPlusToken */ ? 39 /* PlusToken */ : node.operator === 46 /* MinusMinusToken */ ? 40 /* MinusToken */ : undefined; @@ -85867,7 +89028,7 @@ var ts; // Create a temporary variable to store the value returned by the expression. var returnValue = valueIsDiscarded ? undefined : factory.createTempVariable(hoistVariableDeclaration); return ts.setOriginalNode(factory.inlineExpressions(ts.compact([ - createPrivateIdentifierAssignment(info, initializeExpression || readExpression, factory.createBinaryExpression(returnValue ? factory.createAssignment(returnValue, existingValue) : existingValue, operator, factory.createNumericLiteral(1)), 62 /* EqualsToken */), + createPrivateIdentifierAssignment(info, initializeExpression || readExpression, factory.createBinaryExpression(returnValue ? factory.createAssignment(returnValue, existingValue) : existingValue, operator, factory.createNumericLiteral(1)), 63 /* EqualsToken */), returnValue ])), node); } @@ -85876,7 +89037,7 @@ var ts; } function visitForStatement(node) { if (node.incrementor && ts.isPostfixUnaryExpression(node.incrementor)) { - return factory.updateForStatement(node, ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), visitPostfixUnaryExpression(node.incrementor, /*valueIsDiscarded*/ true), ts.visitNode(node.statement, visitor, ts.isStatement)); + return factory.updateForStatement(node, ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), visitPostfixUnaryExpression(node.incrementor, /*valueIsDiscarded*/ true), ts.visitIterationBody(node.statement, visitor, context)); } return ts.visitEachChild(node, visitor, context); } @@ -85896,16 +89057,21 @@ var ts; return { readExpression: readExpression, initializeExpression: initializeExpression }; } function visitCallExpression(node) { - if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.expression)) { + if (shouldTransformPrivateElements && ts.isPrivateIdentifierPropertyAccessExpression(node.expression)) { // Transform call expressions of private names to properly bind the `this` parameter. var _a = factory.createCallBinding(node.expression, hoistVariableDeclaration, languageVersion), thisArg = _a.thisArg, target = _a.target; + if (ts.isCallChain(node)) { + return factory.updateCallChain(node, factory.createPropertyAccessChain(ts.visitNode(target, visitor), node.questionDotToken, "call"), + /*questionDotToken*/ undefined, + /*typeArguments*/ undefined, __spreadArray([ts.visitNode(thisArg, visitor, ts.isExpression)], ts.visitNodes(node.arguments, visitor, ts.isExpression))); + } return factory.updateCallExpression(node, factory.createPropertyAccessExpression(ts.visitNode(target, visitor), "call"), /*typeArguments*/ undefined, __spreadArray([ts.visitNode(thisArg, visitor, ts.isExpression)], ts.visitNodes(node.arguments, visitor, ts.isExpression))); } return ts.visitEachChild(node, visitor, context); } function visitTaggedTemplateExpression(node) { - if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.tag)) { + if (shouldTransformPrivateElements && ts.isPrivateIdentifierPropertyAccessExpression(node.tag)) { // Bind the `this` correctly for tagged template literals when the tag is a private identifier property access. var _a = factory.createCallBinding(node.tag, hoistVariableDeclaration, languageVersion), thisArg = _a.thisArg, target = _a.target; return factory.updateTaggedTemplateExpression(node, factory.createCallExpression(factory.createPropertyAccessExpression(ts.visitNode(target, visitor), "bind"), @@ -85915,7 +89081,7 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitBinaryExpression(node) { - if (shouldTransformPrivateFields) { + if (shouldTransformPrivateElements) { if (ts.isDestructuringAssignment(node)) { var savedPendingExpressions = pendingExpressions; pendingExpressions = undefined; @@ -85929,29 +89095,31 @@ var ts; if (ts.isAssignmentExpression(node) && ts.isPrivateIdentifierPropertyAccessExpression(node.left)) { var info = accessPrivateIdentifier(node.left.name); if (info) { - return ts.setOriginalNode(createPrivateIdentifierAssignment(info, node.left.expression, node.right, node.operatorToken.kind), node); + return ts.setTextRange(ts.setOriginalNode(createPrivateIdentifierAssignment(info, node.left.expression, node.right, node.operatorToken.kind), node), node); } } } return ts.visitEachChild(node, visitor, context); } function createPrivateIdentifierAssignment(info, receiver, right, operator) { - switch (info.placement) { - case 0 /* InstanceField */: { - return createPrivateIdentifierInstanceFieldAssignment(info, receiver, right, operator); - } - default: return ts.Debug.fail("Unexpected private identifier placement"); - } - } - function createPrivateIdentifierInstanceFieldAssignment(info, receiver, right, operator) { receiver = ts.visitNode(receiver, visitor, ts.isExpression); right = ts.visitNode(right, visitor, ts.isExpression); if (ts.isCompoundAssignment(operator)) { var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression; - return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(initializeExpression || readExpression, info.weakMapName, factory.createBinaryExpression(context.getEmitHelperFactory().createClassPrivateFieldGetHelper(readExpression, info.weakMapName), ts.getNonAssignmentOperatorForCompoundAssignment(operator), right)); - } - else { - return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.weakMapName, right); + receiver = initializeExpression || readExpression; + right = factory.createBinaryExpression(createPrivateIdentifierAccessHelper(info, readExpression), ts.getNonAssignmentOperatorForCompoundAssignment(operator), right); + } + ts.setCommentRange(receiver, ts.moveRangePos(receiver, -1)); + switch (info.kind) { + case "a" /* Accessor */: + return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, info.setterName); + case "m" /* Method */: + return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, + /* f */ undefined); + case "f" /* Field */: + return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, info.variableName); + default: + ts.Debug.assertNever(info, "Unknown private element type"); } } /** @@ -85960,32 +89128,53 @@ var ts; function visitClassLike(node) { var savedPendingExpressions = pendingExpressions; pendingExpressions = undefined; - if (shouldTransformPrivateFields) { + if (shouldTransformPrivateElements) { startPrivateIdentifierEnvironment(); + var name = ts.getNameOfDeclaration(node); + if (name && ts.isIdentifier(name)) { + getPrivateIdentifierEnvironment().className = ts.idText(name); + } + var privateInstanceMethodsAndAccessors = getPrivateInstanceMethodsAndAccessors(node); + if (ts.some(privateInstanceMethodsAndAccessors)) { + getPrivateIdentifierEnvironment().weakSetName = createHoistedVariableForClass("instances", privateInstanceMethodsAndAccessors[0].name); + } } var result = ts.isClassDeclaration(node) ? visitClassDeclaration(node) : visitClassExpression(node); - if (shouldTransformPrivateFields) { + if (shouldTransformPrivateElements) { endPrivateIdentifierEnvironment(); } pendingExpressions = savedPendingExpressions; return result; } function doesClassElementNeedTransform(node) { - return ts.isPropertyDeclaration(node) || (shouldTransformPrivateFields && node.name && ts.isPrivateIdentifier(node.name)); + return ts.isPropertyDeclaration(node) || (shouldTransformPrivateElements && node.name && ts.isPrivateIdentifier(node.name)); + } + function getPrivateInstanceMethodsAndAccessors(node) { + return ts.filter(node.members, ts.isNonStaticMethodOrAccessorWithPrivateName); } function visitClassDeclaration(node) { if (!ts.forEach(node.members, doesClassElementNeedTransform)) { return ts.visitEachChild(node, visitor, context); } + var staticProperties = ts.getProperties(node, /*requireInitializer*/ false, /*isStatic*/ true); + var pendingPrivateStateAssignment; + if (shouldTransformPrivateElements && ts.some(node.members, function (m) { return ts.hasStaticModifier(m) && !!m.name && ts.isPrivateIdentifier(m.name); })) { + var temp = factory.createTempVariable(hoistVariableDeclaration, /* reservedInNestedScopes */ true); + getPrivateIdentifierEnvironment().classConstructor = factory.cloneNode(temp); + pendingPrivateStateAssignment = factory.createAssignment(temp, factory.getInternalName(node)); + } var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 103 /* NullKeyword */); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */); var statements = [ factory.updateClassDeclaration(node, /*decorators*/ undefined, node.modifiers, node.name, /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass)) ]; + if (pendingPrivateStateAssignment) { + getPendingExpressions().unshift(pendingPrivateStateAssignment); + } // Write any pending expressions from elided or moved computed property names if (ts.some(pendingExpressions)) { statements.push(factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))); @@ -85995,7 +89184,6 @@ var ts; // From ES6 specification: // HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using // a lexical declaration such as a LexicalDeclaration or a ClassDeclaration. - var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); if (ts.some(staticProperties)) { addPropertyStatements(statements, staticProperties, factory.getInternalName(node)); } @@ -86013,12 +89201,25 @@ var ts; // class declaration transformation. The VariableStatement visitor will insert // these statements after the class expression variable statement. var isDecoratedClassDeclaration = ts.isClassDeclaration(ts.getOriginalNode(node)); - var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); + var staticProperties = ts.getProperties(node, /*requireInitializer*/ false, /*isStatic*/ true); var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 103 /* NullKeyword */); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */); + var isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */; + var temp; + function createClassTempVar() { + var classCheckFlags = resolver.getNodeCheckFlags(node); + var isClassWithConstructorReference = classCheckFlags & 16777216 /* ClassWithConstructorReference */; + var requiresBlockScopedVar = classCheckFlags & 524288 /* BlockScopedBindingInLoop */; + return factory.createTempVariable(requiresBlockScopedVar ? addBlockScopedVariable : hoistVariableDeclaration, !!isClassWithConstructorReference); + } + if (shouldTransformPrivateElements && ts.some(node.members, function (m) { return ts.hasStaticModifier(m) && !!m.name && ts.isPrivateIdentifier(m.name); })) { + temp = createClassTempVar(); + getPrivateIdentifierEnvironment().classConstructor = factory.cloneNode(temp); + } var classExpression = factory.updateClassExpression(node, ts.visitNodes(node.decorators, visitor, ts.isDecorator), node.modifiers, node.name, /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass)); - if (ts.some(staticProperties) || ts.some(pendingExpressions)) { + var hasTransformableStatics = ts.some(staticProperties, function (p) { return !!p.initializer || (shouldTransformPrivateElements && ts.isPrivateIdentifier(p.name)); }); + if (hasTransformableStatics || ts.some(pendingExpressions)) { if (isDecoratedClassDeclaration) { ts.Debug.assertIsDefined(pendingStatements, "Decorated classes transformed by TypeScript are expected to be within a variable declaration."); // Write any pending expressions from elided or moved computed property names @@ -86028,12 +89229,14 @@ var ts; if (pendingStatements && ts.some(staticProperties)) { addPropertyStatements(pendingStatements, staticProperties, factory.getInternalName(node)); } + if (temp) { + return factory.inlineExpressions([factory.createAssignment(temp, classExpression), temp]); + } return classExpression; } else { var expressions = []; - var isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */; - var temp = factory.createTempVariable(hoistVariableDeclaration, !!isClassWithConstructorReference); + temp || (temp = createClassTempVar()); if (isClassWithConstructorReference) { // record an alias as the class name is not in scope for statics. enableSubstitutionForClassAliases(); @@ -86055,14 +89258,17 @@ var ts; return classExpression; } function transformClassMembers(node, isDerivedClass) { - if (shouldTransformPrivateFields) { + if (shouldTransformPrivateElements) { // Declare private names. for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (ts.isPrivateIdentifierPropertyDeclaration(member)) { - addPrivateIdentifierToEnvironment(member.name); + if (ts.isPrivateIdentifierClassElementDeclaration(member)) { + addPrivateIdentifierToEnvironment(member); } } + if (ts.some(getPrivateInstanceMethodsAndAccessors(node))) { + createBrandCheckWeakSetForPrivateMethods(); + } } var members = []; var constructor = transformConstructor(node, isDerivedClass); @@ -86072,21 +89278,27 @@ var ts; ts.addRange(members, ts.visitNodes(node.members, classElementVisitor, ts.isClassElement)); return ts.setTextRange(factory.createNodeArray(members), /*location*/ node.members); } - function isPropertyDeclarationThatRequiresConstructorStatement(member) { - if (!ts.isPropertyDeclaration(member) || ts.hasStaticModifier(member) || ts.hasSyntacticModifier(ts.getOriginalNode(member), 128 /* Abstract */)) { + function createBrandCheckWeakSetForPrivateMethods() { + var weakSetName = getPrivateIdentifierEnvironment().weakSetName; + ts.Debug.assert(weakSetName, "weakSetName should be set in private identifier environment"); + getPendingExpressions().push(factory.createAssignment(weakSetName, factory.createNewExpression(factory.createIdentifier("WeakSet"), + /*typeArguments*/ undefined, []))); + } + function isClassElementThatRequiresConstructorStatement(member) { + if (ts.hasStaticModifier(member) || ts.hasSyntacticModifier(ts.getOriginalNode(member), 128 /* Abstract */)) { return false; } - if (context.getCompilerOptions().useDefineForClassFields) { + 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 < 99 /* ESNext */; } - return ts.isInitializedProperty(member) || shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyDeclaration(member); + return ts.isInitializedProperty(member) || shouldTransformPrivateElements && ts.isPrivateIdentifierClassElementDeclaration(member); } function transformConstructor(node, isDerivedClass) { var constructor = ts.visitNode(ts.getFirstConstructorWithBody(node), visitor, ts.isConstructorDeclaration); - var properties = node.members.filter(isPropertyDeclarationThatRequiresConstructorStatement); - if (!ts.some(properties)) { + var elements = node.members.filter(isClassElementThatRequiresConstructorStatement); + if (!ts.some(elements)) { return constructor; } var parameters = ts.visitParameterList(constructor ? constructor.parameters : undefined, visitor, context); @@ -86099,13 +89311,14 @@ var ts; /*modifiers*/ undefined, parameters !== null && parameters !== void 0 ? parameters : [], body), constructor || node), constructor)); } function transformConstructorBody(node, constructor, isDerivedClass) { - var useDefineForClassFields = context.getCompilerOptions().useDefineForClassFields; var properties = ts.getProperties(node, /*requireInitializer*/ false, /*isStatic*/ false); if (!useDefineForClassFields) { properties = ts.filter(properties, function (property) { return !!property.initializer || ts.isPrivateIdentifier(property.name); }); } + var privateMethodsAndAccessors = getPrivateInstanceMethodsAndAccessors(node); + var needsConstructorBody = ts.some(properties) || ts.some(privateMethodsAndAccessors); // Only generate synthetic constructor when there are property initializers to move. - if (!constructor && !ts.some(properties)) { + if (!constructor && !needsConstructorBody) { return ts.visitFunctionBody(/*node*/ undefined, visitor, context); } resumeLexicalEnvironment(); @@ -86144,7 +89357,10 @@ var ts; indexOfFirstStatement = afterParameterProperties; } } - addPropertyStatements(statements, properties, factory.createThis()); + var receiver = factory.createThis(); + // private methods can be called in property initializers, they should execute first. + addMethodStatements(statements, privateMethodsAndAccessors, receiver); + addPropertyStatements(statements, properties, receiver); // Add existing statements, skipping the initial super call. if (constructor) { ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement)); @@ -86206,27 +89422,30 @@ var ts; function transformProperty(property, receiver) { var _a; // We generate a name here in order to reuse the value cached by the relocated computed name expression (which uses the same generated name) - var emitAssignment = !context.getCompilerOptions().useDefineForClassFields; + var emitAssignment = !useDefineForClassFields; var propertyName = ts.isComputedPropertyName(property.name) && !ts.isSimpleInlineableExpression(property.name.expression) ? factory.updateComputedPropertyName(property.name, factory.getGeneratedNameForNode(property.name)) : property.name; - if (shouldTransformPrivateFields && ts.isPrivateIdentifier(propertyName)) { + if (shouldTransformPrivateElements && ts.isPrivateIdentifier(propertyName)) { var privateIdentifierInfo = accessPrivateIdentifier(propertyName); if (privateIdentifierInfo) { - switch (privateIdentifierInfo.placement) { - case 0 /* InstanceField */: { - return createPrivateInstanceFieldInitializer(receiver, ts.visitNode(property.initializer, visitor, ts.isExpression), privateIdentifierInfo.weakMapName); + if (privateIdentifierInfo.kind === "f" /* Field */) { + if (!privateIdentifierInfo.isStatic) { + return createPrivateInstanceFieldInitializer(receiver, ts.visitNode(property.initializer, visitor, ts.isExpression), privateIdentifierInfo.brandCheckIdentifier); + } + else { + return createPrivateStaticFieldInitializer(privateIdentifierInfo.variableName, ts.visitNode(property.initializer, visitor, ts.isExpression)); } } + else { + return undefined; + } } else { ts.Debug.fail("Undeclared private name for property declaration."); } } - if (ts.isPrivateIdentifier(propertyName) && !property.initializer) { - return undefined; - } - if (ts.isPrivateIdentifier(propertyName) && !property.initializer) { + if ((ts.isPrivateIdentifier(propertyName) || ts.hasStaticModifier(property)) && !property.initializer) { return undefined; } var propertyOriginalNode = ts.getOriginalNode(property); @@ -86253,11 +89472,26 @@ var ts; enabledSubstitutions |= 1 /* ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(78 /* Identifier */); + context.enableSubstitution(79 /* Identifier */); // Keep track of class aliases. classAliases = []; } } + /** + * Generates brand-check initializer for private methods. + * + * @param statements Statement list that should be used to append new statements. + * @param methods An array of method declarations. + * @param receiver The receiver on which each method should be assigned. + */ + function addMethodStatements(statements, methods, receiver) { + if (!shouldTransformPrivateElements || !ts.some(methods)) { + return; + } + var weakSetName = getPrivateIdentifierEnvironment().weakSetName; + ts.Debug.assert(weakSetName, "weakSetName should be set in private identifier environment"); + statements.push(factory.createExpressionStatement(createPrivateInstanceMethodInitializer(receiver, weakSetName))); + } /** * Hooks node substitutions. * @@ -86273,7 +89507,7 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return substituteExpressionIdentifier(node); } return node; @@ -86293,10 +89527,10 @@ var ts; if (declaration) { var classAlias = classAliases[declaration.id]; // TODO: GH#18217 if (classAlias) { - var clone_2 = factory.cloneNode(classAlias); - ts.setSourceMapRange(clone_2, node); - ts.setCommentRange(clone_2, node); - return clone_2; + var clone_3 = factory.cloneNode(classAlias); + ts.setSourceMapRange(clone_3, node); + ts.setCommentRange(clone_3, node); + return clone_3; } } } @@ -86316,7 +89550,12 @@ var ts; var alreadyTransformed = ts.isAssignmentExpression(innerExpression) && ts.isGeneratedIdentifier(innerExpression.left); if (!alreadyTransformed && !inlinable && shouldHoist) { var generatedName = factory.getGeneratedNameForNode(name); - hoistVariableDeclaration(generatedName); + if (resolver.getNodeCheckFlags(name) & 524288 /* BlockScopedBindingInLoop */) { + addBlockScopedVariable(generatedName); + } + else { + hoistVariableDeclaration(generatedName); + } return factory.createAssignment(generatedName, expression); } return (inlinable || ts.isIdentifier(innerExpression)) ? undefined : expression; @@ -86330,22 +89569,164 @@ var ts; currentPrivateIdentifierEnvironment = privateIdentifierEnvironmentStack.pop(); } function getPrivateIdentifierEnvironment() { - return currentPrivateIdentifierEnvironment || (currentPrivateIdentifierEnvironment = new ts.Map()); + if (!currentPrivateIdentifierEnvironment) { + currentPrivateIdentifierEnvironment = { + className: "", + identifiers: new ts.Map() + }; + } + return currentPrivateIdentifierEnvironment; } function getPendingExpressions() { return pendingExpressions || (pendingExpressions = []); } - function addPrivateIdentifierToEnvironment(name) { - var text = ts.getTextOfPropertyName(name); - var weakMapName = factory.createUniqueName("_" + text.substring(1), 16 /* Optimistic */ | 8 /* ReservedInNestedScopes */); - hoistVariableDeclaration(weakMapName); - getPrivateIdentifierEnvironment().set(name.escapedText, { placement: 0 /* InstanceField */, weakMapName: weakMapName }); - getPendingExpressions().push(factory.createAssignment(weakMapName, factory.createNewExpression(factory.createIdentifier("WeakMap"), - /*typeArguments*/ undefined, []))); + function addPrivateIdentifierToEnvironment(node) { + var _a; + var text = ts.getTextOfPropertyName(node.name); + var env = getPrivateIdentifierEnvironment(); + var weakSetName = env.weakSetName, classConstructor = env.classConstructor; + var assignmentExpressions = []; + var privateName = node.name.escapedText; + var previousInfo = env.identifiers.get(privateName); + var isValid = !isReservedPrivateName(node.name) && previousInfo === undefined; + if (ts.hasStaticModifier(node)) { + ts.Debug.assert(classConstructor, "weakSetName should be set in private identifier environment"); + if (ts.isPropertyDeclaration(node)) { + var variableName = createHoistedVariableForPrivateName(text, node); + env.identifiers.set(privateName, { + kind: "f" /* Field */, + variableName: variableName, + brandCheckIdentifier: classConstructor, + isStatic: true, + isValid: isValid, + }); + } + else if (ts.isMethodDeclaration(node)) { + var functionName = createHoistedVariableForPrivateName(text, node); + env.identifiers.set(privateName, { + kind: "m" /* Method */, + methodName: functionName, + brandCheckIdentifier: classConstructor, + isStatic: true, + isValid: isValid, + }); + } + 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) { + previousInfo.getterName = getterName; + } + else { + env.identifiers.set(privateName, { + kind: "a" /* Accessor */, + getterName: getterName, + setterName: undefined, + brandCheckIdentifier: classConstructor, + isStatic: true, + isValid: isValid, + }); + } + } + 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) { + previousInfo.setterName = setterName; + } + else { + env.identifiers.set(privateName, { + kind: "a" /* Accessor */, + getterName: undefined, + setterName: setterName, + brandCheckIdentifier: classConstructor, + isStatic: true, + isValid: isValid, + }); + } + } + else { + ts.Debug.assertNever(node, "Unknown class element type."); + } + } + else if (ts.isPropertyDeclaration(node)) { + var weakMapName = createHoistedVariableForPrivateName(text, node); + env.identifiers.set(privateName, { + kind: "f" /* Field */, + brandCheckIdentifier: weakMapName, + isStatic: false, + variableName: undefined, + isValid: isValid, + }); + assignmentExpressions.push(factory.createAssignment(weakMapName, factory.createNewExpression(factory.createIdentifier("WeakMap"), + /*typeArguments*/ undefined, []))); + } + else if (ts.isMethodDeclaration(node)) { + ts.Debug.assert(weakSetName, "weakSetName should be set in private identifier environment"); + env.identifiers.set(privateName, { + kind: "m" /* Method */, + methodName: createHoistedVariableForPrivateName(text, node), + brandCheckIdentifier: weakSetName, + isStatic: false, + isValid: isValid, + }); + } + else if (ts.isAccessor(node)) { + 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) { + previousInfo.getterName = getterName; + } + else { + env.identifiers.set(privateName, { + kind: "a" /* Accessor */, + getterName: getterName, + setterName: undefined, + brandCheckIdentifier: weakSetName, + isStatic: false, + isValid: isValid, + }); + } + } + else { + var setterName = createHoistedVariableForPrivateName(text + "_set", node); + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && !previousInfo.isStatic && !previousInfo.setterName) { + previousInfo.setterName = setterName; + } + else { + env.identifiers.set(privateName, { + kind: "a" /* Accessor */, + getterName: undefined, + setterName: setterName, + brandCheckIdentifier: weakSetName, + isStatic: false, + isValid: isValid, + }); + } + } + } + else { + ts.Debug.assertNever(node, "Unknown class element type."); + } + (_a = getPendingExpressions()).push.apply(_a, assignmentExpressions); + } + 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 */) { + addBlockScopedVariable(identifier); + } + else { + hoistVariableDeclaration(identifier); + } + return identifier; + } + function createHoistedVariableForPrivateName(privateName, node) { + return createHoistedVariableForClass(privateName.substring(1), node.name); } function accessPrivateIdentifier(name) { if (currentPrivateIdentifierEnvironment) { - var info = currentPrivateIdentifierEnvironment.get(name.escapedText); + var info = currentPrivateIdentifierEnvironment.identifiers.get(name.escapedText); if (info) { return info; } @@ -86355,7 +89736,7 @@ var ts; if (!env) { continue; } - var info = env.get(name.escapedText); + var info = env.identifiers.get(name.escapedText); if (info) { return info; } @@ -86373,7 +89754,7 @@ 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, 62 /* EqualsToken */, node.expression)); + getPendingExpressions().push(factory.createBinaryExpression(receiver, 63 /* EqualsToken */, node.expression)); } return factory.createPropertyAccessExpression( // Explicit parens required because of v8 regression (https://bugs.chromium.org/p/v8/issues/detail?id=9560) @@ -86386,7 +89767,7 @@ var ts; /*dotDotDotToken*/ undefined, parameter, /*questionToken*/ undefined, /*type*/ undefined, - /*initializer*/ undefined)], factory.createBlock([factory.createExpressionStatement(createPrivateIdentifierAssignment(info, receiver, parameter, 62 /* EqualsToken */))])) + /*initializer*/ undefined)], factory.createBlock([factory.createExpressionStatement(createPrivateIdentifierAssignment(info, receiver, parameter, 63 /* EqualsToken */))])) ])), "value"); } function visitArrayAssignmentTarget(node) { @@ -86441,10 +89822,22 @@ var ts; } } ts.transformClassFields = transformClassFields; + function createPrivateStaticFieldInitializer(variableName, initializer) { + return ts.factory.createAssignment(variableName, ts.factory.createObjectLiteralExpression([ + ts.factory.createPropertyAssignment("value", initializer || ts.factory.createVoidZero()) + ])); + } function createPrivateInstanceFieldInitializer(receiver, initializer, weakMapName) { return ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(weakMapName, "set"), /*typeArguments*/ undefined, [receiver, initializer || ts.factory.createVoidZero()]); } + function createPrivateInstanceMethodInitializer(receiver, weakSetName) { + return ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(weakSetName, "add"), + /*typeArguments*/ undefined, [receiver]); + } + function isReservedPrivateName(node) { + return node.escapedText === "#constructor"; + } })(ts || (ts = {})); /*@internal*/ var ts; @@ -86527,38 +89920,38 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 64 /* ContainsES2017 */) === 0) { + if ((node.transformFlags & 128 /* ContainsES2017 */) === 0) { return node; } switch (node.kind) { - case 129 /* AsyncKeyword */: + case 130 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 213 /* AwaitExpression */: + case 215 /* AwaitExpression */: return visitAwaitExpression(node); - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitMethodDeclaration, node); - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitFunctionDeclaration, node); - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitFunctionExpression, node); - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return doWithContext(1 /* NonTopLevel */, visitArrowFunction, node); - case 201 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 105 /* SuperKeyword */) { + case 203 /* PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SuperKeyword */) { capturedSuperProperties.add(node.name.escapedText); } return ts.visitEachChild(node, visitor, context); - case 202 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 105 /* SuperKeyword */) { + case 204 /* ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 106 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 166 /* Constructor */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 168 /* Constructor */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitDefault, node); default: return ts.visitEachChild(node, visitor, context); @@ -86567,27 +89960,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return visitForStatementInAsyncBody(node); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return visitForInStatementInAsyncBody(node); - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return visitCatchClauseInAsyncBody(node); - case 230 /* Block */: - case 244 /* SwitchStatement */: - case 258 /* CaseBlock */: - case 284 /* CaseClause */: - case 285 /* DefaultClause */: - case 247 /* TryStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: - case 234 /* IfStatement */: - case 243 /* WithStatement */: - case 245 /* LabeledStatement */: + case 232 /* Block */: + case 246 /* SwitchStatement */: + case 260 /* CaseBlock */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: + case 249 /* TryStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: + case 236 /* IfStatement */: + case 245 /* WithStatement */: + case 247 /* LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -86629,18 +90022,18 @@ var ts; function visitForInStatementInAsyncBody(node) { return factory.updateForInStatement(node, isVariableDeclarationListWithCollidingName(node.initializer) ? visitVariableDeclarationListWithCollidingNames(node.initializer, /*hasReceiver*/ true) - : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, asyncBodyVisitor, ts.isStatement, factory.liftToBlock)); + : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitIterationBody(node.statement, asyncBodyVisitor, context)); } function visitForOfStatementInAsyncBody(node) { return factory.updateForOfStatement(node, ts.visitNode(node.awaitModifier, visitor, ts.isToken), isVariableDeclarationListWithCollidingName(node.initializer) ? visitVariableDeclarationListWithCollidingNames(node.initializer, /*hasReceiver*/ true) - : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, asyncBodyVisitor, ts.isStatement, factory.liftToBlock)); + : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitIterationBody(node.statement, asyncBodyVisitor, context)); } function visitForStatementInAsyncBody(node) { var initializer = node.initializer; // TODO: GH#18217 return factory.updateForStatement(node, isVariableDeclarationListWithCollidingName(initializer) ? visitVariableDeclarationListWithCollidingNames(initializer, /*hasReceiver*/ false) - : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitor, ts.isExpression), ts.visitNode(node.statement, asyncBodyVisitor, ts.isStatement, factory.liftToBlock)); + : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitor, ts.isExpression), ts.visitIterationBody(node.statement, asyncBodyVisitor, context)); } /** * Visits an AwaitExpression node. @@ -86792,7 +90185,7 @@ var ts; var original = ts.getOriginalNode(node, ts.isFunctionLike); var nodeType = original.type; var promiseConstructor = languageVersion < 2 /* ES2015 */ ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 209 /* ArrowFunction */; + var isArrowFunction = node.kind === 211 /* ArrowFunction */; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* 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 @@ -86883,17 +90276,17 @@ var ts; enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(203 /* CallExpression */); - context.enableSubstitution(201 /* PropertyAccessExpression */); - context.enableSubstitution(202 /* ElementAccessExpression */); + context.enableSubstitution(205 /* CallExpression */); + context.enableSubstitution(203 /* PropertyAccessExpression */); + context.enableSubstitution(204 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(252 /* ClassDeclaration */); - context.enableEmitNotification(165 /* MethodDeclaration */); - context.enableEmitNotification(167 /* GetAccessor */); - context.enableEmitNotification(168 /* SetAccessor */); - context.enableEmitNotification(166 /* Constructor */); + context.enableEmitNotification(254 /* ClassDeclaration */); + context.enableEmitNotification(167 /* MethodDeclaration */); + context.enableEmitNotification(169 /* GetAccessor */); + context.enableEmitNotification(170 /* SetAccessor */); + context.enableEmitNotification(168 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(232 /* VariableStatement */); + context.enableEmitNotification(234 /* VariableStatement */); } } /** @@ -86941,23 +90334,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -86977,11 +90370,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 252 /* ClassDeclaration */ - || kind === 166 /* Constructor */ - || kind === 165 /* MethodDeclaration */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */; + return kind === 254 /* ClassDeclaration */ + || kind === 168 /* Constructor */ + || kind === 167 /* MethodDeclaration */ + || kind === 169 /* GetAccessor */ + || kind === 170 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -87138,7 +90531,7 @@ var ts; return visitorWorker(node, /*expressionResultIsUnused*/ true); } function visitorNoAsyncModifier(node) { - if (node.kind === 129 /* AsyncKeyword */) { + if (node.kind === 130 /* AsyncKeyword */) { return undefined; } return node; @@ -87160,74 +90553,74 @@ var ts; * expression of an `ExpressionStatement`). */ function visitorWorker(node, expressionResultIsUnused) { - if ((node.transformFlags & 32 /* ContainsES2018 */) === 0) { + if ((node.transformFlags & 64 /* ContainsES2018 */) === 0) { return node; } switch (node.kind) { - case 213 /* AwaitExpression */: + case 215 /* AwaitExpression */: return visitAwaitExpression(node); - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: return visitYieldExpression(node); - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: return visitReturnStatement(node); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return visitLabeledStatement(node); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return visitBinaryExpression(node, expressionResultIsUnused); - case 337 /* CommaListExpression */: + case 345 /* CommaListExpression */: return visitCommaListExpression(node, expressionResultIsUnused); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return visitCatchClause(node); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return visitVariableStatement(node); - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 235 /* DoStatement */: - case 236 /* WhileStatement */: - case 238 /* ForInStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: + case 240 /* ForInStatement */: return doWithHierarchyFacts(visitDefault, node, 0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return doWithHierarchyFacts(visitForStatement, node, 0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - case 212 /* VoidExpression */: + case 214 /* VoidExpression */: return visitVoidExpression(node); - case 166 /* Constructor */: + case 168 /* Constructor */: return doWithHierarchyFacts(visitConstructorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: return doWithHierarchyFacts(visitMethodDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 167 /* GetAccessor */: + case 169 /* GetAccessor */: return doWithHierarchyFacts(visitGetAccessorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 168 /* SetAccessor */: + case 170 /* SetAccessor */: return doWithHierarchyFacts(visitSetAccessorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return doWithHierarchyFacts(visitFunctionDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: return doWithHierarchyFacts(visitFunctionExpression, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return doWithHierarchyFacts(visitArrowFunction, node, 2 /* ArrowFunctionExcludes */, 0 /* ArrowFunctionIncludes */); - case 160 /* Parameter */: + case 162 /* Parameter */: return visitParameter(node); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: return visitExpressionStatement(node); - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, expressionResultIsUnused); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 201 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 105 /* SuperKeyword */) { + case 203 /* PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SuperKeyword */) { capturedSuperProperties.add(node.name.escapedText); } return ts.visitEachChild(node, visitor, context); - case 202 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 105 /* SuperKeyword */) { + case 204 /* ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 106 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: return doWithHierarchyFacts(visitDefault, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); default: return ts.visitEachChild(node, visitor, context); @@ -87263,7 +90656,7 @@ var ts; function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2 /* Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 239 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 241 /* ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return factory.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement, factory.liftToBlock), node); @@ -87275,7 +90668,7 @@ var ts; var objects = []; for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) { var e = elements_4[_i]; - if (e.kind === 290 /* SpreadAssignment */) { + if (e.kind === 292 /* SpreadAssignment */) { if (chunkObject) { objects.push(factory.createObjectLiteralExpression(chunkObject)); chunkObject = undefined; @@ -87284,7 +90677,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 288 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 290 /* PropertyAssignment */ ? factory.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -87295,7 +90688,7 @@ var ts; return objects; } function visitObjectLiteralExpression(node) { - if (node.transformFlags & 16384 /* ContainsObjectRestOrSpread */) { + if (node.transformFlags & 32768 /* 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}); @@ -87318,7 +90711,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 !== 200 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 202 /* ObjectLiteralExpression */) { objects.unshift(factory.createObjectLiteralExpression()); } var expression = objects[0]; @@ -87368,7 +90761,7 @@ var ts; * expression of an `ExpressionStatement`). */ function visitBinaryExpression(node, expressionResultIsUnused) { - if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 16384 /* ContainsObjectRestOrSpread */) { + if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { return ts.flattenDestructuringAssignment(node, visitor, context, 1 /* ObjectRest */, !expressionResultIsUnused); } if (node.operatorToken.kind === 27 /* CommaToken */) { @@ -87399,7 +90792,7 @@ var ts; function visitCatchClause(node) { if (node.variableDeclaration && ts.isBindingPattern(node.variableDeclaration.name) && - node.variableDeclaration.name.transformFlags & 16384 /* ContainsObjectRestOrSpread */) { + node.variableDeclaration.name.transformFlags & 32768 /* 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 */); @@ -87440,14 +90833,14 @@ 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 & 16384 /* ContainsObjectRestOrSpread */) { + if (ts.isBindingPattern(node.name) && node.name.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { return ts.flattenDestructuringBinding(node, visitor, context, 1 /* ObjectRest */, /*rval*/ undefined, exportedVariableStatement); } return ts.visitEachChild(node, visitor, context); } function visitForStatement(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)); + 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.visitIterationBody(node.statement, visitor, context)); } function visitVoidExpression(node) { return ts.visitEachChild(node, visitorWithUnusedExpressionResult, context); @@ -87459,7 +90852,7 @@ var ts; */ function visitForOfStatement(node, outermostLabeledStatement) { var ancestorFacts = enterSubtree(0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - if (node.initializer.transformFlags & 16384 /* ContainsObjectRestOrSpread */) { + if (node.initializer.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { node = transformForOfStatementWithObjectRest(node); } var result = node.awaitModifier ? @@ -87497,7 +90890,7 @@ var ts; var bodyLocation; var statementsLocation; var statements = [ts.visitNode(binding, visitor, ts.isStatement)]; - var statement = ts.visitNode(node.statement, visitor, ts.isStatement); + var statement = ts.visitIterationBody(node.statement, visitor, context); if (ts.isBlock(statement)) { ts.addRange(statements, statement.statements); bodyLocation = statement; @@ -87559,7 +90952,7 @@ var ts; ])); } function visitParameter(node) { - if (node.transformFlags & 16384 /* ContainsObjectRestOrSpread */) { + if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { // Binding patterns are converted into a generated name and are // evaluated inside the function body. return factory.updateParameterDeclaration(node, @@ -87711,7 +91104,7 @@ var ts; function appendObjectRestAssignmentsIfNeeded(statements, node) { for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { var parameter = _a[_i]; - if (parameter.transformFlags & 16384 /* ContainsObjectRestOrSpread */) { + if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { var temp = factory.getGeneratedNameForNode(parameter); var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* ObjectRest */, temp, /*doNotRecordTempVariablesInLine*/ false, @@ -87731,17 +91124,17 @@ var ts; enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(203 /* CallExpression */); - context.enableSubstitution(201 /* PropertyAccessExpression */); - context.enableSubstitution(202 /* ElementAccessExpression */); + context.enableSubstitution(205 /* CallExpression */); + context.enableSubstitution(203 /* PropertyAccessExpression */); + context.enableSubstitution(204 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(252 /* ClassDeclaration */); - context.enableEmitNotification(165 /* MethodDeclaration */); - context.enableEmitNotification(167 /* GetAccessor */); - context.enableEmitNotification(168 /* SetAccessor */); - context.enableEmitNotification(166 /* Constructor */); + context.enableEmitNotification(254 /* ClassDeclaration */); + context.enableEmitNotification(167 /* MethodDeclaration */); + context.enableEmitNotification(169 /* GetAccessor */); + context.enableEmitNotification(170 /* SetAccessor */); + context.enableEmitNotification(168 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(232 /* VariableStatement */); + context.enableEmitNotification(234 /* VariableStatement */); } } /** @@ -87789,23 +91182,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -87825,11 +91218,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 252 /* ClassDeclaration */ - || kind === 166 /* Constructor */ - || kind === 165 /* MethodDeclaration */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */; + return kind === 254 /* ClassDeclaration */ + || kind === 168 /* Constructor */ + || kind === 167 /* MethodDeclaration */ + || kind === 169 /* GetAccessor */ + || kind === 170 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -87857,11 +91250,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 16 /* ContainsES2019 */) === 0) { + if ((node.transformFlags & 32 /* ContainsES2019 */) === 0) { return node; } switch (node.kind) { - case 287 /* CatchClause */: + case 289 /* CatchClause */: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -87889,25 +91282,29 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 8 /* ContainsES2020 */) === 0) { + if ((node.transformFlags & 16 /* ContainsES2020 */) === 0) { return node; } switch (node.kind) { - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: - case 203 /* CallExpression */: - if (node.flags & 32 /* OptionalChain */) { + case 205 /* CallExpression */: { + var updated = visitNonOptionalCallExpression(node, /*captureThisArg*/ false); + ts.Debug.assertNotNode(updated, ts.isSyntheticReference); + return updated; + } + case 203 /* PropertyAccessExpression */: + case 204 /* 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 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: if (node.operatorToken.kind === 60 /* QuestionQuestionToken */) { return transformNullishCoalescingExpression(node); } return ts.visitEachChild(node, visitor, context); - case 210 /* DeleteExpression */: + case 212 /* DeleteExpression */: return visitDeleteExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -87949,7 +91346,7 @@ var ts; thisArg = expression; } } - expression = node.kind === 201 /* PropertyAccessExpression */ + expression = node.kind === 203 /* 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; @@ -87959,14 +91356,23 @@ var ts; // If `node` is an optional chain, then it is the outermost chain of an optional expression. return visitOptionalExpression(node, captureThisArg, /*isDelete*/ false); } + if (ts.isParenthesizedExpression(node.expression) && ts.isOptionalChain(ts.skipParentheses(node.expression))) { + // capture thisArg for calls of parenthesized optional chains like `(foo?.bar)()` + var expression = visitNonOptionalParenthesizedExpression(node.expression, /*captureThisArg*/ true, /*isDelete*/ false); + var args = ts.visitNodes(node.arguments, visitor, ts.isExpression); + if (ts.isSyntheticReference(expression)) { + return ts.setTextRange(factory.createFunctionCallCall(expression.expression, expression.thisArg, args), node); + } + return factory.updateCallExpression(node, expression, /*typeArguments*/ undefined, args); + } return ts.visitEachChild(node, visitor, context); } function visitNonOptionalExpression(node, captureThisArg, isDelete) { switch (node.kind) { - case 207 /* ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete); - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete); - case 203 /* CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); + case 209 /* ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete); + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete); + case 205 /* CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); default: return ts.visitNode(node, visitor, ts.isExpression); } } @@ -87985,8 +91391,8 @@ var ts; for (var i = 0; i < chain.length; i++) { var segment = chain[i]; switch (segment.kind) { - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: if (i === chain.length - 1 && captureThisArg) { if (!ts.isSimpleCopiableExpression(rightExpression)) { thisArg = factory.createTempVariable(hoistVariableDeclaration); @@ -87996,13 +91402,13 @@ var ts; thisArg = rightExpression; } } - rightExpression = segment.kind === 201 /* PropertyAccessExpression */ + rightExpression = segment.kind === 203 /* PropertyAccessExpression */ ? factory.createPropertyAccessExpression(rightExpression, ts.visitNode(segment.name, visitor, ts.isIdentifier)) : factory.createElementAccessExpression(rightExpression, ts.visitNode(segment.argumentExpression, visitor, ts.isExpression)); break; - case 203 /* CallExpression */: + case 205 /* CallExpression */: if (i === 0 && leftThisArg) { - rightExpression = factory.createFunctionCallCall(rightExpression, leftThisArg.kind === 105 /* SuperKeyword */ ? factory.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); + rightExpression = factory.createFunctionCallCall(rightExpression, leftThisArg.kind === 106 /* SuperKeyword */ ? factory.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); } else { rightExpression = factory.createCallExpression(rightExpression, @@ -88043,7 +91449,7 @@ var ts; /*@internal*/ var ts; (function (ts) { - function transformESNext(context) { + function transformES2021(context) { var hoistVariableDeclaration = context.hoistVariableDeclaration, factory = context.factory; return ts.chainBundle(context, transformSourceFile); function transformSourceFile(node) { @@ -88053,11 +91459,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 4 /* ContainsESNext */) === 0) { + if ((node.transformFlags & 8 /* ContainsES2021 */) === 0) { return node; } switch (node.kind) { - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: var binaryExpression = node; if (ts.isLogicalOrCoalescingAssignmentExpression(binaryExpression)) { return transformLogicalAssignment(binaryExpression); @@ -88093,6 +91499,29 @@ var ts; return factory.createBinaryExpression(left, nonAssignmentOperator, factory.createParenthesizedExpression(factory.createAssignment(assignmentTarget, right))); } } + ts.transformES2021 = transformES2021; +})(ts || (ts = {})); +/*@internal*/ +var ts; +(function (ts) { + function transformESNext(context) { + return ts.chainBundle(context, transformSourceFile); + function transformSourceFile(node) { + if (node.isDeclarationFile) { + return node; + } + return ts.visitEachChild(node, visitor, context); + } + function visitor(node) { + if ((node.transformFlags & 4 /* ContainsESNext */) === 0) { + return node; + } + switch (node.kind) { + default: + return ts.visitEachChild(node, visitor, context); + } + } + } ts.transformESNext = transformESNext; })(ts || (ts = {})); /*@internal*/ @@ -88203,13 +91632,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 273 /* JsxElement */: + case 275 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 274 /* JsxSelfClosingElement */: + case 276 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 277 /* JsxFragment */: + case 279 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -88219,13 +91648,13 @@ var ts; switch (node.kind) { case 11 /* JsxText */: return visitJsxText(node); - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: return visitJsxExpression(node); - case 273 /* JsxElement */: + case 275 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 274 /* JsxSelfClosingElement */: + case 276 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 277 /* JsxFragment */: + case 279 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -88343,21 +91772,29 @@ var ts; // When there are no attributes, React wants "null" } else { - // Map spans of JsxAttribute nodes into object literals and spans - // of JsxSpreadAttribute nodes into expressions. - var segments = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread - ? ts.map(attrs, transformJsxSpreadAttributeToExpression) - : factory.createObjectLiteralExpression(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); })); - if (ts.isJsxSpreadAttribute(attrs[0])) { - // We must always emit at least one object literal before a spread - // argument.factory.createObjectLiteral - segments.unshift(factory.createObjectLiteralExpression()); + var target = compilerOptions.target; + if (target && target >= 5 /* ES2018 */) { + objectProperties = factory.createObjectLiteralExpression(ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { + return isSpread ? ts.map(attrs, transformJsxSpreadAttributeToSpreadAssignment) : ts.map(attrs, transformJsxAttributeToObjectLiteralElement); + }))); } - // Either emit one big object literal (no spread attribs), or - // a call to the __assign helper. - objectProperties = ts.singleOrUndefined(segments); - if (!objectProperties) { - objectProperties = emitHelpers().createAssignHelper(segments); + else { + // Map spans of JsxAttribute nodes into object literals and spans + // of JsxSpreadAttribute nodes into expressions. + var segments = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread + ? ts.map(attrs, transformJsxSpreadAttributeToExpression) + : factory.createObjectLiteralExpression(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); })); + if (ts.isJsxSpreadAttribute(attrs[0])) { + // We must always emit at least one object literal before a spread + // argument.factory.createObjectLiteral + segments.unshift(factory.createObjectLiteralExpression()); + } + // Either emit one big object literal (no spread attribs), or + // a call to the __assign helper. + objectProperties = ts.singleOrUndefined(segments); + if (!objectProperties) { + objectProperties = emitHelpers().createAssignHelper(segments); + } } } var callee = currentFileState.importSpecifier === undefined @@ -88389,6 +91826,9 @@ var ts; } return element; } + function transformJsxSpreadAttributeToSpreadAssignment(node) { + return factory.createSpreadAssignment(ts.visitNode(node.expression, visitor, ts.isExpression)); + } function transformJsxSpreadAttributeToExpression(node) { return ts.visitNode(node.expression, visitor, ts.isExpression); } @@ -88408,7 +91848,7 @@ var ts; var literal = factory.createStringLiteral(tryDecodeEntities(node.text) || node.text, singleQuote); return ts.setTextRange(literal, node); } - else if (node.kind === 283 /* JsxExpression */) { + else if (node.kind === 285 /* JsxExpression */) { if (node.expression === undefined) { return factory.createTrue(); } @@ -88502,7 +91942,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 273 /* JsxElement */) { + if (node.kind === 275 /* JsxElement */) { return getTagName(node.openingElement); } else { @@ -88804,11 +92244,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 128 /* ContainsES2016 */) === 0) { + if ((node.transformFlags & 256 /* ContainsES2016 */) === 0) { return node; } switch (node.kind) { - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -88816,7 +92256,7 @@ var ts; } function visitBinaryExpression(node) { switch (node.operatorToken.kind) { - case 66 /* AsteriskAsteriskEqualsToken */: + case 67 /* AsteriskAsteriskEqualsToken */: return visitExponentiationAssignmentExpression(node); case 42 /* AsteriskAsteriskToken */: return visitExponentiationExpression(node); @@ -89021,11 +92461,11 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 242 /* ReturnStatement */ + && node.kind === 244 /* ReturnStatement */ && !node.expression; } function isOrMayContainReturnCompletion(node) { - return node.transformFlags & 1048576 /* ContainsHoistedDeclarationOrCompletion */ + return node.transformFlags & 2097152 /* ContainsHoistedDeclarationOrCompletion */ && (ts.isReturnStatement(node) || ts.isIfStatement(node) || ts.isWithStatement(node) @@ -89040,7 +92480,7 @@ var ts; || ts.isBlock(node)); } function shouldVisitNode(node) { - return (node.transformFlags & 256 /* ContainsES2015 */) !== 0 + return (node.transformFlags & 512 /* ContainsES2015 */) !== 0 || convertedLoopState !== undefined || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && isOrMayContainReturnCompletion(node)) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatement(node)) @@ -89053,74 +92493,74 @@ var ts; return shouldVisitNode(node) ? visitorWorker(node, /*expressionResultIsUnused*/ true) : node; } function callExpressionVisitor(node) { - if (node.kind === 105 /* SuperKeyword */) { + if (node.kind === 106 /* SuperKeyword */) { return visitSuperKeyword(/*isExpressionOfCall*/ true); } return visitor(node); } function visitorWorker(node, expressionResultIsUnused) { switch (node.kind) { - case 123 /* StaticKeyword */: + case 124 /* StaticKeyword */: return undefined; // elide static keyword - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: return visitClassDeclaration(node); - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: return visitClassExpression(node); - case 160 /* Parameter */: + case 162 /* Parameter */: return visitParameter(node); - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return visitArrowFunction(node); - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: return visitFunctionExpression(node); - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 78 /* Identifier */: + case 79 /* Identifier */: return visitIdentifier(node); - case 250 /* VariableDeclarationList */: + case 252 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: return visitSwitchStatement(node); - case 258 /* CaseBlock */: + case 260 /* CaseBlock */: return visitCaseBlock(node); - case 230 /* Block */: + case 232 /* Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 241 /* BreakStatement */: - case 240 /* ContinueStatement */: + case 243 /* BreakStatement */: + case 242 /* ContinueStatement */: return visitBreakOrContinueStatement(node); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return visitLabeledStatement(node); - case 235 /* DoStatement */: - case 236 /* WhileStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: return visitExpressionStatement(node); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return visitCatchClause(node); - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return visitCallExpression(node); - case 204 /* NewExpression */: + case 206 /* NewExpression */: return visitNewExpression(node); - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, expressionResultIsUnused); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return visitBinaryExpression(node, expressionResultIsUnused); - case 337 /* CommaListExpression */: + case 345 /* CommaListExpression */: return visitCommaListExpression(node, expressionResultIsUnused); case 14 /* NoSubstitutionTemplateLiteral */: case 15 /* TemplateHead */: @@ -89131,30 +92571,30 @@ var ts; return visitStringLiteral(node); case 8 /* NumericLiteral */: return visitNumericLiteral(node); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 218 /* TemplateExpression */: + case 220 /* TemplateExpression */: return visitTemplateExpression(node); - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: return visitYieldExpression(node); - case 220 /* SpreadElement */: + case 222 /* SpreadElement */: return visitSpreadElement(node); - case 105 /* SuperKeyword */: + case 106 /* SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: return visitThisKeyword(node); - case 226 /* MetaProperty */: + case 228 /* MetaProperty */: return visitMetaProperty(node); - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return visitAccessorDeclaration(node); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return visitVariableStatement(node); - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: return visitReturnStatement(node); - case 212 /* VoidExpression */: + case 214 /* VoidExpression */: return visitVoidExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -89244,14 +92684,14 @@ 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 === 241 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 243 /* BreakStatement */ ? 2 /* Break */ : 4 /* 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 === 241 /* BreakStatement */) { + if (node.kind === 243 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -89262,7 +92702,7 @@ var ts; } } else { - if (node.kind === 241 /* BreakStatement */) { + if (node.kind === 243 /* BreakStatement */) { labelMarker = "break-" + label.escapedText; setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } @@ -89522,7 +92962,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 !== 103 /* NullKeyword */; + var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */; // When the subclass does not have a constructor, we synthesize a *default* constructor using the following // representation: // @@ -89574,7 +93014,7 @@ var ts; factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment()); insertCaptureNewTargetIfNeeded(prologue, constructor, /*copyOnWrite*/ false); if (isDerivedClass) { - if (superCallExpression && statementOffset === constructor.body.statements.length && !(constructor.body.transformFlags & 4096 /* ContainsLexicalThis */)) { + if (superCallExpression && statementOffset === constructor.body.statements.length && !(constructor.body.transformFlags & 8192 /* ContainsLexicalThis */)) { // If the subclass constructor does *not* contain `this` and *ends* with a `super()` call, we will use the // following representation: // @@ -89660,11 +93100,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 242 /* ReturnStatement */) { + if (statement.kind === 244 /* ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 234 /* IfStatement */) { + else if (statement.kind === 236 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -89672,7 +93112,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 230 /* Block */) { + else if (statement.kind === 232 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -89830,10 +93270,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 === 78 /* Identifier */ ? ts.setParent(ts.setTextRange(factory.cloneNode(parameter.name), parameter.name), parameter.name.parent) : factory.createTempVariable(/*recordTempVariable*/ undefined); + 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 */); // `expressionName` is the name of the parameter used in expressions. - var expressionName = parameter.name.kind === 78 /* Identifier */ ? factory.cloneNode(parameter.name) : declarationName; + var expressionName = parameter.name.kind === 79 /* Identifier */ ? factory.cloneNode(parameter.name) : declarationName; var restIndex = node.parameters.length - 1; var temp = factory.createLoopVariable(); // var param = []; @@ -89858,7 +93298,7 @@ var ts; ts.setEmitFlags(forStatement, 1048576 /* CustomPrologue */); ts.startOnNewLine(forStatement); prologueStatements.push(forStatement); - if (parameter.name.kind !== 78 /* Identifier */) { + if (parameter.name.kind !== 79 /* 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 */)); @@ -89874,7 +93314,7 @@ var ts; * @param node A node. */ function insertCaptureThisForNodeIfNeeded(statements, node) { - if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 209 /* ArrowFunction */) { + if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 211 /* ArrowFunction */) { insertCaptureThisForNode(statements, node, factory.createThis()); return true; } @@ -89896,25 +93336,25 @@ var ts; if (hierarchyFacts & 16384 /* NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return statements; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: // Methods and accessors cannot be constructors, so 'new.target' will // always return 'undefined'. newTarget = factory.createVoidZero(); break; - case 166 /* Constructor */: + case 168 /* 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"); break; - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 210 /* 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 */), 101 /* InstanceOfKeyword */, factory.getLocalName(node))), + 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"), /*colonToken*/ undefined, factory.createVoidZero()); break; @@ -89946,20 +93386,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 229 /* SemicolonClassElement */: + case 231 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 166 /* Constructor */: + case 168 /* Constructor */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -89988,7 +93428,7 @@ var ts; var memberFunction = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined, container); var propertyName = ts.visitNode(member.name, visitor, ts.isPropertyName); var e; - if (!ts.isPrivateIdentifier(propertyName) && context.getCompilerOptions().useDefineForClassFields) { + if (!ts.isPrivateIdentifier(propertyName) && ts.getUseDefineForClassFields(context.getCompilerOptions())) { var name = ts.isComputedPropertyName(propertyName) ? propertyName.expression : ts.isIdentifier(propertyName) ? factory.createStringLiteral(ts.unescapeLeadingUnderscores(propertyName.escapedText)) : propertyName; @@ -90080,7 +93520,7 @@ var ts; * @param node An ArrowFunction node. */ function visitArrowFunction(node) { - if (node.transformFlags & 4096 /* ContainsLexicalThis */) { + if (node.transformFlags & 8192 /* ContainsLexicalThis */) { hierarchyFacts |= 32768 /* CapturedLexicalThis */; } var savedConvertedLoopState = convertedLoopState; @@ -90162,7 +93602,7 @@ var ts; : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 251 /* FunctionDeclaration */ || node.kind === 208 /* FunctionExpression */)) { + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 253 /* FunctionDeclaration */ || node.kind === 210 /* FunctionExpression */)) { name = factory.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */); @@ -90208,7 +93648,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 209 /* ArrowFunction */); + ts.Debug.assert(node.kind === 211 /* 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 @@ -90343,7 +93783,7 @@ var ts; assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0 /* All */); } else { - assignment = factory.createBinaryExpression(decl.name, 62 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + assignment = factory.createBinaryExpression(decl.name, 63 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); ts.setTextRange(assignment, decl); } assignments = ts.append(assignments, assignment); @@ -90369,7 +93809,7 @@ var ts; * @param node A VariableDeclarationList node. */ function visitVariableDeclarationList(node) { - if (node.flags & 3 /* BlockScoped */ || node.transformFlags & 131072 /* ContainsBindingPattern */) { + if (node.flags & 3 /* BlockScoped */ || node.transformFlags & 262144 /* ContainsBindingPattern */) { if (node.flags & 3 /* BlockScoped */) { enableSubstitutionsForBlockScopedBindings(); } @@ -90382,7 +93822,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 & 131072 /* ContainsBindingPattern */ + if (node.transformFlags & 262144 /* ContainsBindingPattern */ && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.last(node.declarations).name))) { ts.setSourceMapRange(declarationList, getRangeUnion(declarations)); } @@ -90394,8 +93834,8 @@ var ts; // declarations may not be sorted by position. // pos should be the minimum* position over all nodes (that's not -1), end should be the maximum end over all nodes. var pos = -1, end = -1; - for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) { - var node = declarations_10[_i]; + for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { + var node = declarations_9[_i]; pos = pos === -1 ? node.pos : node.pos === -1 ? pos : Math.min(pos, node.pos); end = Math.max(end, node.end); } @@ -90515,14 +93955,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 235 /* DoStatement */: - case 236 /* WhileStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -90706,9 +94146,9 @@ var ts; var numInitialProperties = -1, hasComputed = false; for (var i = 0; i < properties.length; i++) { var property = properties[i]; - if ((property.transformFlags & 262144 /* ContainsYield */ && + if ((property.transformFlags & 524288 /* ContainsYield */ && hierarchyFacts & 4 /* AsyncFunctionBody */) - || (hasComputed = ts.Debug.checkDefined(property.name).kind === 158 /* ComputedPropertyName */)) { + || (hasComputed = ts.Debug.checkDefined(property.name).kind === 160 /* ComputedPropertyName */)) { numInitialProperties = i; break; } @@ -90760,7 +94200,7 @@ var ts; } visit(node.name); function visit(node) { - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { state.hoistedLocalVariables.push(node); } else { @@ -90811,24 +94251,24 @@ var ts; loop = convert(node, outermostLabeledStatement, bodyFunction.part, ancestorFacts); } else { - var clone_3 = convertIterationStatementCore(node, initializerFunction, factory.createBlock(bodyFunction.part, /*multiLine*/ true)); - loop = factory.restoreEnclosingLabel(clone_3, outermostLabeledStatement, convertedLoopState && resetLabel); + var clone_4 = convertIterationStatementCore(node, initializerFunction, factory.createBlock(bodyFunction.part, /*multiLine*/ true)); + loop = factory.restoreEnclosingLabel(clone_4, outermostLabeledStatement, convertedLoopState && resetLabel); } } else { - var clone_4 = convertIterationStatementCore(node, initializerFunction, ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - loop = factory.restoreEnclosingLabel(clone_4, outermostLabeledStatement, convertedLoopState && resetLabel); + var clone_5 = convertIterationStatementCore(node, initializerFunction, ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock)); + loop = factory.restoreEnclosingLabel(clone_5, outermostLabeledStatement, convertedLoopState && resetLabel); } statements.push(loop); return statements; } function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) { switch (node.kind) { - case 237 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); - case 238 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); - case 239 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); - case 235 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); - case 236 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); + case 239 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); + case 240 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); + case 241 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); + case 237 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); + case 238 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected"); } } @@ -90853,11 +94293,11 @@ var ts; function createConvertedLoopState(node) { var loopInitializer; switch (node.kind) { - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 250 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 252 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -90977,7 +94417,7 @@ var ts; */ function createFunctionForInitializerOfForStatement(node, currentState) { var functionName = factory.createUniqueName("_loop_init"); - var containsYield = (node.initializer.transformFlags & 262144 /* ContainsYield */) !== 0; + var containsYield = (node.initializer.transformFlags & 524288 /* ContainsYield */) !== 0; var emitFlags = 0 /* None */; if (currentState.containsLexicalThis) emitFlags |= 8 /* CapturesThis */; @@ -91092,7 +94532,7 @@ var ts; var loopBody = factory.createBlock(statements, /*multiLine*/ true); if (ts.isBlock(statement)) ts.setOriginalNode(loopBody, statement); - var containsYield = (node.statement.transformFlags & 262144 /* ContainsYield */) !== 0; + var containsYield = (node.statement.transformFlags & 524288 /* ContainsYield */) !== 0; var emitFlags = 524288 /* ReuseTempVariableScope */; if (currentState.containsLexicalThis) emitFlags |= 8 /* CapturesThis */; @@ -91128,7 +94568,7 @@ var ts; 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, 62 /* EqualsToken */, source); + return factory.createBinaryExpression(target, 63 /* EqualsToken */, source); } function copyOutParameters(outParams, partFlags, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { @@ -91265,20 +94705,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -91385,7 +94825,7 @@ var ts; var updated; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (node.kind === 167 /* GetAccessor */) { + if (node.kind === 169 /* GetAccessor */) { updated = factory.updateGetAccessorDeclaration(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); } else { @@ -91438,7 +94878,7 @@ var ts; return visitTypeScriptClassWrapper(node); } var expression = ts.skipOuterExpressions(node.expression); - if (expression.kind === 105 /* SuperKeyword */ || + if (expression.kind === 106 /* SuperKeyword */ || ts.isSuperProperty(expression) || ts.some(node.arguments, ts.isSpreadElement)) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); @@ -91565,15 +95005,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 & 8192 /* ContainsRestOrSpread */ || - node.expression.kind === 105 /* SuperKeyword */ || + if (node.transformFlags & 16384 /* ContainsRestOrSpread */ || + node.expression.kind === 106 /* SuperKeyword */ || ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) { var _a = factory.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { ts.setEmitFlags(thisArg, 4 /* NoSubstitution */); } var resultingCall = void 0; - if (node.transformFlags & 8192 /* ContainsRestOrSpread */) { + if (node.transformFlags & 16384 /* ContainsRestOrSpread */) { // [source] // f(...a, b) // x.m(...a, b) @@ -91587,7 +95027,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 === 105 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); + resultingCall = factory.createFunctionApplyCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); } else { // [source] @@ -91599,9 +95039,9 @@ 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 === 105 /* 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 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression)), node); } - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { var initializer = factory.createLogicalOr(resultingCall, createActualThis()); resultingCall = assignToCapturedThis ? factory.createAssignment(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), initializer) @@ -91848,7 +95288,7 @@ var ts; : factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */); } function visitMetaProperty(node) { - if (node.keywordToken === 102 /* NewKeyword */ && node.name.escapedText === "target") { + if (node.keywordToken === 103 /* NewKeyword */ && node.name.escapedText === "target") { hierarchyFacts |= 16384 /* NewTarget */; return factory.createUniqueName("_newTarget", 16 /* Optimistic */ | 32 /* FileLevel */); } @@ -91880,7 +95320,7 @@ var ts; function enableSubstitutionsForBlockScopedBindings() { if ((enabledSubstitutions & 2 /* BlockScopedBindings */) === 0) { enabledSubstitutions |= 2 /* BlockScopedBindings */; - context.enableSubstitution(78 /* Identifier */); + context.enableSubstitution(79 /* Identifier */); } } /** @@ -91890,14 +95330,14 @@ var ts; function enableSubstitutionsForCapturedThis() { if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { enabledSubstitutions |= 1 /* CapturedThis */; - context.enableSubstitution(107 /* ThisKeyword */); - context.enableEmitNotification(166 /* Constructor */); - context.enableEmitNotification(165 /* MethodDeclaration */); - context.enableEmitNotification(167 /* GetAccessor */); - context.enableEmitNotification(168 /* SetAccessor */); - context.enableEmitNotification(209 /* ArrowFunction */); - context.enableEmitNotification(208 /* FunctionExpression */); - context.enableEmitNotification(251 /* FunctionDeclaration */); + context.enableSubstitution(108 /* ThisKeyword */); + context.enableEmitNotification(168 /* Constructor */); + context.enableEmitNotification(167 /* MethodDeclaration */); + context.enableEmitNotification(169 /* GetAccessor */); + context.enableEmitNotification(170 /* SetAccessor */); + context.enableEmitNotification(211 /* ArrowFunction */); + context.enableEmitNotification(210 /* FunctionExpression */); + context.enableEmitNotification(253 /* FunctionDeclaration */); } } /** @@ -91938,10 +95378,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 198 /* BindingElement */: - case 252 /* ClassDeclaration */: - case 255 /* EnumDeclaration */: - case 249 /* VariableDeclaration */: + case 200 /* BindingElement */: + case 254 /* ClassDeclaration */: + case 257 /* EnumDeclaration */: + case 251 /* VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -91954,9 +95394,9 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return substituteExpressionIdentifier(node); - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: return substituteThisKeyword(node); } return node; @@ -92023,19 +95463,19 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 233 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 235 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 203 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 205 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 105 /* SuperKeyword */) { + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 106 /* SuperKeyword */) { return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 220 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 222 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -92061,15 +95501,15 @@ var ts; if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(275 /* JsxOpeningElement */); - context.enableEmitNotification(276 /* JsxClosingElement */); - context.enableEmitNotification(274 /* JsxSelfClosingElement */); + context.enableEmitNotification(277 /* JsxOpeningElement */); + context.enableEmitNotification(278 /* JsxClosingElement */); + context.enableEmitNotification(276 /* JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(201 /* PropertyAccessExpression */); - context.enableSubstitution(288 /* PropertyAssignment */); + context.enableSubstitution(203 /* PropertyAccessExpression */); + context.enableSubstitution(290 /* PropertyAssignment */); return ts.chainBundle(context, transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -92088,9 +95528,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 275 /* JsxOpeningElement */: - case 276 /* JsxClosingElement */: - case 274 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: + case 278 /* JsxClosingElement */: + case 276 /* JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -92150,7 +95590,7 @@ var ts; */ function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined); - if (token !== undefined && token >= 80 /* FirstReservedWord */ && token <= 115 /* LastReservedWord */) { + if (token !== undefined && token >= 81 /* FirstReservedWord */ && token <= 116 /* LastReservedWord */) { return ts.setTextRange(factory.createStringLiteralFromNode(name), name); } return undefined; @@ -92388,7 +95828,7 @@ var ts; var withBlockStack; // A stack containing `with` blocks. return ts.chainBundle(context, transformSourceFile); function transformSourceFile(node) { - if (node.isDeclarationFile || (node.transformFlags & 512 /* ContainsGenerator */) === 0) { + if (node.isDeclarationFile || (node.transformFlags & 1024 /* ContainsGenerator */) === 0) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -92411,7 +95851,7 @@ var ts; else if (ts.isFunctionLikeDeclaration(node) && node.asteriskToken) { return visitGenerator(node); } - else if (transformFlags & 512 /* ContainsGenerator */) { + else if (transformFlags & 1024 /* ContainsGenerator */) { return ts.visitEachChild(node, visitor, context); } else { @@ -92425,13 +95865,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 235 /* DoStatement */: + case 237 /* DoStatement */: return visitDoStatement(node); - case 236 /* WhileStatement */: + case 238 /* WhileStatement */: return visitWhileStatement(node); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: return visitSwitchStatement(node); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -92444,30 +95884,30 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: return visitFunctionExpression(node); - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return visitAccessorDeclaration(node); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return visitVariableStatement(node); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return visitForStatement(node); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return visitForInStatement(node); - case 241 /* BreakStatement */: + case 243 /* BreakStatement */: return visitBreakStatement(node); - case 240 /* ContinueStatement */: + case 242 /* ContinueStatement */: return visitContinueStatement(node); - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: return visitReturnStatement(node); default: - if (node.transformFlags & 262144 /* ContainsYield */) { + if (node.transformFlags & 524288 /* ContainsYield */) { return visitJavaScriptContainingYield(node); } - else if (node.transformFlags & (512 /* ContainsGenerator */ | 1048576 /* ContainsHoistedDeclarationOrCompletion */)) { + else if (node.transformFlags & (1024 /* ContainsGenerator */ | 2097152 /* ContainsHoistedDeclarationOrCompletion */)) { return ts.visitEachChild(node, visitor, context); } else { @@ -92482,23 +95922,23 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return visitBinaryExpression(node); - case 337 /* CommaListExpression */: + case 345 /* CommaListExpression */: return visitCommaListExpression(node); - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: return visitConditionalExpression(node); - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: return visitYieldExpression(node); - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return visitCallExpression(node); - case 204 /* NewExpression */: + case 206 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -92511,9 +95951,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -92672,7 +96112,7 @@ var ts; * @param node The node to visit. */ function visitVariableStatement(node) { - if (node.transformFlags & 262144 /* ContainsYield */) { + if (node.transformFlags & 524288 /* ContainsYield */) { transformAndEmitVariableDeclarationList(node.declarationList); return undefined; } @@ -92721,7 +96161,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -92733,7 +96173,7 @@ var ts; // _a.b = %sent%; target = factory.updatePropertyAccessExpression(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -93127,35 +96567,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 230 /* Block */: + case 232 /* Block */: return transformAndEmitBlock(node); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 234 /* IfStatement */: + case 236 /* IfStatement */: return transformAndEmitIfStatement(node); - case 235 /* DoStatement */: + case 237 /* DoStatement */: return transformAndEmitDoStatement(node); - case 236 /* WhileStatement */: + case 238 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return transformAndEmitForStatement(node); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 240 /* ContinueStatement */: + case 242 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 241 /* BreakStatement */: + case 243 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 243 /* WithStatement */: + case 245 /* WithStatement */: return transformAndEmitWithStatement(node); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 246 /* ThrowStatement */: + case 248 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 247 /* TryStatement */: + case 249 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -93375,7 +96815,7 @@ var ts; var variables = ts.getInitializedVariables(initializer); node = factory.updateForStatement(node, variables.length > 0 ? factory.inlineExpressions(ts.map(variables, transformInitializedVariable)) - : undefined, ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitor, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock)); + : undefined, ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitor, ts.isExpression), ts.visitIterationBody(node.statement, visitor, context)); } else { node = ts.visitEachChild(node, visitor, context); @@ -93585,7 +97025,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 285 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 287 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -93598,7 +97038,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 284 /* CaseClause */) { + if (clause.kind === 286 /* CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -93730,7 +97170,7 @@ var ts; } } function containsYield(node) { - return !!node && (node.transformFlags & 262144 /* ContainsYield */) !== 0; + return !!node && (node.transformFlags & 524288 /* ContainsYield */) !== 0; } function countInitialNodesWithoutYield(nodes) { var numNodes = nodes.length; @@ -93763,10 +97203,10 @@ var ts; var name = renamedCatchVariableDeclarations[ts.getOriginalNodeId(declaration)]; if (name) { // TODO(rbuckton): Does this need to be parented? - var clone_5 = ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent); - ts.setSourceMapRange(clone_5, node); - ts.setCommentRange(clone_5, node); - return clone_5; + var clone_6 = ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent); + ts.setSourceMapRange(clone_6, node); + ts.setCommentRange(clone_6, node); + return clone_6; } } } @@ -93912,7 +97352,7 @@ var ts; if (!renamedCatchVariables) { renamedCatchVariables = new ts.Map(); renamedCatchVariableDeclarations = []; - context.enableSubstitution(78 /* Identifier */); + context.enableSubstitution(79 /* Identifier */); } renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; @@ -94758,12 +98198,12 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(78 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(216 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(214 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(215 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(289 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(297 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(79 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. + context.enableSubstitution(218 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(216 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(217 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(291 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(299 /* 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. @@ -94779,7 +98219,7 @@ var ts; function transformSourceFile(node) { if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || - node.transformFlags & 2097152 /* ContainsDynamicImport */ || + node.transformFlags & 4194304 /* ContainsDynamicImport */ || (ts.isJsonSourceFile(node) && ts.hasJsonModuleEmitEnabled(compilerOptions) && ts.outFile(compilerOptions)))) { return node; } @@ -95091,23 +98531,23 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return visitImportDeclaration(node); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: return visitExportDeclaration(node); - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return visitExportAssignment(node); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return visitVariableStatement(node); - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: return visitClassDeclaration(node); - case 338 /* MergeDeclarationMarker */: + case 346 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 339 /* EndOfDeclarationMarker */: + case 347 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -95116,7 +98556,7 @@ var ts; function moduleExpressionElementVisitor(node) { // This visitor does not need to descend into the tree if there is no dynamic import or destructuring assignment, // as export/import statements are only transformed at the top level of a file. - if (!(node.transformFlags & 2097152 /* ContainsDynamicImport */) && !(node.transformFlags & 1024 /* ContainsDestructuringAssignment */)) { + if (!(node.transformFlags & 4194304 /* ContainsDynamicImport */) && !(node.transformFlags & 2048 /* ContainsDestructuringAssignment */)) { return node; } if (ts.isImportCall(node)) { @@ -95134,24 +98574,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 290 /* SpreadAssignment */: + case 292 /* SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -95186,7 +98626,7 @@ var ts; var firstArgument = ts.visitNode(ts.firstOrUndefined(node.arguments), moduleExpressionElementVisitor); // 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 & 4096 /* ContainsLexicalThis */); + var containsLexicalThis = !!(node.transformFlags & 8192 /* ContainsLexicalThis */); switch (compilerOptions.module) { case ts.ModuleKind.AMD: return createImportCallExpressionAMD(argument, containsLexicalThis); @@ -95679,7 +99119,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 232 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 234 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -95734,10 +99174,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 264 /* NamedImports */: + case 266 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding, /* liveBinding */ true); @@ -95933,8 +99373,8 @@ var ts; function modifierVisitor(node) { // Elide module-specific modifiers. switch (node.kind) { - case 92 /* ExportKeyword */: - case 87 /* DefaultKeyword */: + case 93 /* ExportKeyword */: + case 88 /* DefaultKeyword */: return undefined; } return node; @@ -95950,7 +99390,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 297 /* SourceFile */) { + if (node.kind === 299 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -96012,12 +99452,12 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return substituteExpressionIdentifier(node); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return substituteBinaryExpression(node); - case 215 /* PostfixUnaryExpression */: - case 214 /* PrefixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -96037,9 +99477,9 @@ var ts; } return node; } - if (!(ts.isGeneratedIdentifier(node) && !(node.autoGenerateFlags & 64 /* AllowNameSubstitution */)) && !ts.isLocalName(node)) { + else if (!(ts.isGeneratedIdentifier(node) && !(node.autoGenerateFlags & 64 /* AllowNameSubstitution */)) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 297 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 299 /* SourceFile */) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.cloneNode(node)), /*location*/ node); } @@ -96114,8 +99554,8 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 215 /* PostfixUnaryExpression */ - ? ts.setTextRange(factory.createBinaryExpression(node.operand, factory.createToken(node.operator === 45 /* PlusPlusToken */ ? 63 /* PlusEqualsToken */ : 64 /* MinusEqualsToken */), factory.createNumericLiteral(1)), + var expression = node.kind === 217 /* PostfixUnaryExpression */ + ? ts.setTextRange(factory.createPrefixUnaryExpression(node.operator, node.operand), /*location*/ node) : node; for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) { @@ -96124,6 +99564,12 @@ var ts; noSubstitution[ts.getNodeId(expression)] = true; expression = createExportExpression(exportName, expression); } + if (node.kind === 217 /* PostfixUnaryExpression */) { + noSubstitution[ts.getNodeId(expression)] = true; + expression = node.operator === 45 /* PlusPlusToken */ + ? factory.createSubtract(expression, factory.createNumericLiteral(1)) + : factory.createAdd(expression, factory.createNumericLiteral(1)); + } return expression; } } @@ -96165,13 +99611,13 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(78 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(289 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols - context.enableSubstitution(216 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(214 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(215 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(226 /* MetaProperty */); // Substitutes 'import.meta' - context.enableEmitNotification(297 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(79 /* Identifier */); // Substitutes expression identifiers for imported symbols. + context.enableSubstitution(291 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(218 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(216 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(217 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(228 /* MetaProperty */); // Substitutes 'import.meta' + context.enableEmitNotification(299 /* 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. @@ -96191,7 +99637,7 @@ var ts; * @param node The SourceFile node. */ function transformSourceFile(node) { - if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 2097152 /* ContainsDynamicImport */)) { + if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 4194304 /* ContainsDynamicImport */)) { return node; } var id = ts.getOriginalNodeId(node); @@ -96360,7 +99806,7 @@ 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 & 524288 /* ContainsAwait */ ? + var modifiers = node.transformFlags & 1048576 /* ContainsAwait */ ? factory.createModifiersFromModifierFlags(256 /* Async */) : undefined; var moduleObject = factory.createObjectLiteralExpression([ @@ -96395,7 +99841,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 267 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 269 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -96485,19 +99931,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(factory, entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(factory.createExpressionStatement(factory.createAssignment(importVariableName, parameterName))); break; - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { if (ts.isNamedExports(entry.exportClause)) { @@ -96556,13 +100002,13 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return visitImportDeclaration(node); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: return visitExportDeclaration(node); - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -96742,7 +100188,7 @@ 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 === 297 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 299 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -96806,7 +100252,7 @@ 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 === 232 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 234 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasSyntacticModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -96868,10 +100314,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 264 /* NamedImports */: + case 266 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -97051,43 +100497,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return visitVariableStatement(node); - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: return visitClassDeclaration(node); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return visitForStatement(node); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return visitForInStatement(node); - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: return visitForOfStatement(node); - case 235 /* DoStatement */: + case 237 /* DoStatement */: return visitDoStatement(node); - case 236 /* WhileStatement */: + case 238 /* WhileStatement */: return visitWhileStatement(node); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return visitLabeledStatement(node); - case 243 /* WithStatement */: + case 245 /* WithStatement */: return visitWithStatement(node); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: return visitSwitchStatement(node); - case 258 /* CaseBlock */: + case 260 /* CaseBlock */: return visitCaseBlock(node); - case 284 /* CaseClause */: + case 286 /* CaseClause */: return visitCaseClause(node); - case 285 /* DefaultClause */: + case 287 /* DefaultClause */: return visitDefaultClause(node); - case 247 /* TryStatement */: + case 249 /* TryStatement */: return visitTryStatement(node); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return visitCatchClause(node); - case 230 /* Block */: + case 232 /* Block */: return visitBlock(node); - case 338 /* MergeDeclarationMarker */: + case 346 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 339 /* EndOfDeclarationMarker */: + case 347 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -97101,7 +100547,7 @@ var ts; function visitForStatement(node) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = factory.updateForStatement(node, node.initializer && visitForInitializer(node.initializer), ts.visitNode(node.condition, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.incrementor, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement)); + node = factory.updateForStatement(node, node.initializer && visitForInitializer(node.initializer), ts.visitNode(node.condition, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.incrementor, destructuringAndImportCallVisitor, ts.isExpression), ts.visitIterationBody(node.statement, nestedElementVisitor, context)); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } @@ -97113,7 +100559,7 @@ var ts; function visitForInStatement(node) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = factory.updateForInStatement(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock)); + node = factory.updateForInStatement(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitIterationBody(node.statement, nestedElementVisitor, context)); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } @@ -97125,7 +100571,7 @@ var ts; function visitForOfStatement(node) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = factory.updateForOfStatement(node, node.awaitModifier, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock)); + node = factory.updateForOfStatement(node, node.awaitModifier, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitIterationBody(node.statement, nestedElementVisitor, context)); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } @@ -97166,7 +100612,7 @@ var ts; * @param node The node to visit. */ function visitDoStatement(node) { - return factory.updateDoStatement(node, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression)); + return factory.updateDoStatement(node, ts.visitIterationBody(node.statement, nestedElementVisitor, context), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression)); } /** * Visits the body of a WhileStatement to hoist declarations. @@ -97174,7 +100620,7 @@ var ts; * @param node The node to visit. */ function visitWhileStatement(node) { - return factory.updateWhileStatement(node, ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock)); + return factory.updateWhileStatement(node, ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitIterationBody(node.statement, nestedElementVisitor, context)); } /** * Visits the body of a LabeledStatement to hoist declarations. @@ -97275,7 +100721,7 @@ var ts; else if (ts.isImportCall(node)) { return visitImportCallExpression(node); } - else if ((node.transformFlags & 1024 /* ContainsDestructuringAssignment */) || (node.transformFlags & 2097152 /* ContainsDynamicImport */)) { + else if ((node.transformFlags & 2048 /* ContainsDestructuringAssignment */) || (node.transformFlags & 4194304 /* ContainsDynamicImport */)) { return ts.visitEachChild(node, destructuringAndImportCallVisitor, context); } else { @@ -97313,7 +100759,7 @@ var ts; return ts.visitEachChild(node, destructuringAndImportCallVisitor, context); } /** - * Determines whether the target of a destructuring assigment refers to an exported symbol. + * Determines whether the target of a destructuring assignment refers to an exported symbol. * * @param node The destructuring target. */ @@ -97338,7 +100784,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 297 /* SourceFile */; + return container !== undefined && container.kind === 299 /* SourceFile */; } else { return false; @@ -97354,8 +100800,8 @@ var ts; */ function modifierVisitor(node) { switch (node.kind) { - case 92 /* ExportKeyword */: - case 87 /* DefaultKeyword */: + case 93 /* ExportKeyword */: + case 88 /* DefaultKeyword */: return undefined; } return node; @@ -97371,7 +100817,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 297 /* SourceFile */) { + if (node.kind === 299 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -97421,7 +100867,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -97456,14 +100902,14 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return substituteExpressionIdentifier(node); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return substituteBinaryExpression(node); - case 214 /* PrefixUnaryExpression */: - case 215 /* PostfixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: return substituteUnaryExpression(node); - case 226 /* MetaProperty */: + case 228 /* MetaProperty */: return substituteMetaProperty(node); } return node; @@ -97557,14 +101003,14 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 215 /* PostfixUnaryExpression */ + var expression = node.kind === 217 /* PostfixUnaryExpression */ ? ts.setTextRange(factory.createPrefixUnaryExpression(node.operator, node.operand), node) : node; for (var _i = 0, exportedNames_5 = exportedNames; _i < exportedNames_5.length; _i++) { var exportName = exportedNames_5[_i]; expression = createExportExpression(exportName, preventSubstitution(expression)); } - if (node.kind === 215 /* PostfixUnaryExpression */) { + if (node.kind === 217 /* PostfixUnaryExpression */) { expression = node.operator === 45 /* PlusPlusToken */ ? factory.createSubtract(preventSubstitution(expression), factory.createNumericLiteral(1)) : factory.createAdd(preventSubstitution(expression), factory.createNumericLiteral(1)); @@ -97592,7 +101038,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 297 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 299 /* SourceFile */) { exportedNames = ts.append(exportedNames, factory.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -97632,8 +101078,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(297 /* SourceFile */); - context.enableSubstitution(78 /* Identifier */); + context.enableEmitNotification(299 /* SourceFile */); + context.enableSubstitution(79 /* Identifier */); var helperNameSubstitutions; return ts.chainBundle(context, transformSourceFile); function transformSourceFile(node) { @@ -97664,12 +101110,12 @@ var ts; } function visitor(node) { switch (node.kind) { - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: // Elide `import=` as it is not legal with --module ES6 return undefined; - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return visitExportAssignment(node); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: var exportDecl = node; return visitExportDeclaration(exportDecl); } @@ -97774,7 +101220,8 @@ var ts; ts.isTypeAliasDeclaration(node) || ts.isConstructorDeclaration(node) || ts.isIndexSignatureDeclaration(node) || - ts.isPropertyAccessExpression(node); + ts.isPropertyAccessExpression(node) || + ts.isJSDocTypeAlias(node); } ts.canProduceDiagnostics = canProduceDiagnostics; function createGetSymbolAccessibilityDiagnosticForNodeName(node) { @@ -97803,7 +101250,7 @@ var ts; 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 === 252 /* ClassDeclaration */) { + else if (node.parent.kind === 254 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -97832,7 +101279,7 @@ var ts; 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 === 252 /* ClassDeclaration */) { + else if (node.parent.kind === 254 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -97872,14 +101319,14 @@ var ts; else if (ts.isImportEqualsDeclaration(node)) { return getImportEntityNameVisibilityError; } - else if (ts.isTypeAliasDeclaration(node)) { + else if (ts.isTypeAliasDeclaration(node) || ts.isJSDocTypeAlias(node)) { return getTypeAliasDeclarationVisibilityError; } else { return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]); } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 249 /* VariableDeclaration */ || node.kind === 198 /* BindingElement */) { + if (node.kind === 251 /* VariableDeclaration */ || node.kind === 200 /* BindingElement */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -97888,8 +101335,8 @@ var ts; } // 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 === 163 /* PropertyDeclaration */ || node.kind === 201 /* PropertyAccessExpression */ || node.kind === 162 /* PropertySignature */ || - (node.kind === 160 /* Parameter */ && ts.hasSyntacticModifier(node.parent, 8 /* Private */))) { + else if (node.kind === 165 /* PropertyDeclaration */ || node.kind === 203 /* PropertyAccessExpression */ || node.kind === 164 /* PropertySignature */ || + (node.kind === 162 /* Parameter */ && ts.hasSyntacticModifier(node.parent, 8 /* Private */))) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.hasSyntacticModifier(node, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? @@ -97898,7 +101345,7 @@ var ts; 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 === 252 /* ClassDeclaration */ || node.kind === 160 /* Parameter */) { + else if (node.parent.kind === 254 /* ClassDeclaration */ || node.kind === 162 /* Parameter */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -97923,7 +101370,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 168 /* SetAccessor */) { + if (node.kind === 170 /* 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.hasSyntacticModifier(node, 32 /* Static */)) { @@ -97962,26 +101409,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 170 /* ConstructSignature */: + case 172 /* 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 169 /* CallSignature */: + case 171 /* 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 171 /* IndexSignature */: + case 173 /* 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 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: if (ts.hasSyntacticModifier(node, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -97989,7 +101436,7 @@ var ts; 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 === 252 /* ClassDeclaration */) { + else if (node.parent.kind === 254 /* ClassDeclaration */) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* 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 : @@ -98003,7 +101450,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -98028,30 +101475,30 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 166 /* Constructor */: + case 168 /* Constructor */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* 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 170 /* ConstructSignature */: - case 175 /* ConstructorType */: + case 172 /* ConstructSignature */: + case 177 /* 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 169 /* CallSignature */: + case 171 /* 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 171 /* IndexSignature */: + case 173 /* 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 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: if (ts.hasSyntacticModifier(node.parent, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -98059,7 +101506,7 @@ var ts; 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 === 252 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 254 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* 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 : @@ -98072,15 +101519,15 @@ 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 251 /* FunctionDeclaration */: - case 174 /* FunctionType */: + case 253 /* FunctionDeclaration */: + case 176 /* FunctionType */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* 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 168 /* SetAccessor */: - case 167 /* GetAccessor */: + case 170 /* SetAccessor */: + case 169 /* GetAccessor */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -98094,39 +101541,39 @@ var ts; // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 253 /* InterfaceDeclaration */: + case 255 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 190 /* MappedType */: + case 192 /* MappedType */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1; break; - case 175 /* ConstructorType */: - case 170 /* ConstructSignature */: + case 177 /* ConstructorType */: + case 172 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 169 /* CallSignature */: + case 171 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: if (ts.hasSyntacticModifier(node.parent, 32 /* Static */)) { 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 === 252 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 254 /* 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 174 /* FunctionType */: - case 251 /* FunctionDeclaration */: + case 176 /* FunctionType */: + case 253 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -98143,7 +101590,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 === 116 /* ImplementsKeyword */ ? + diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 117 /* 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; @@ -98165,11 +101612,13 @@ var ts; typeName: node.name }; } - function getTypeAliasDeclarationVisibilityError() { + function getTypeAliasDeclarationVisibilityError(symbolAccessibilityResult) { return { - diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, - errorNode: node.type, - typeName: node.name + diagnosticMessage: symbolAccessibilityResult.errorModuleName + ? ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1_from_module_2 + : ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, + errorNode: ts.isJSDocTypeAlias(node) ? ts.Debug.checkDefined(node.typeExpression) : node.type, + typeName: ts.isJSDocTypeAlias(node) ? ts.getNameOfDeclaration(node) : node.name, }; } } @@ -98190,7 +101639,7 @@ var ts; } function isInternalDeclaration(node, currentSourceFile) { var parseTreeNode = ts.getParseTreeNode(node); - if (parseTreeNode && parseTreeNode.kind === 160 /* Parameter */) { + if (parseTreeNode && parseTreeNode.kind === 162 /* Parameter */) { var paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode); var previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : undefined; var text = currentSourceFile.text; @@ -98252,6 +101701,7 @@ var ts; reportNonlocalAugmentation: reportNonlocalAugmentation }; var errorNameNode; + var errorFallbackNode; var currentSourceFile; var refs; var libs; @@ -98306,8 +101756,10 @@ var ts; else { context.addDiagnostic(ts.createDiagnosticForNode(symbolAccessibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, symbolAccessibilityResult.errorSymbolName, symbolAccessibilityResult.errorModuleName)); } + return true; } } + return false; } function trackExternalModuleSymbolOfImportTypeNode(symbol) { if (!isBundledEmit) { @@ -98316,13 +101768,14 @@ var ts; } function trackSymbol(symbol, enclosingDeclaration, meaning) { if (symbol.flags & 262144 /* TypeParameter */) - return; - handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, /*shouldComputeAliasesToMakeVisible*/ true)); + return false; + var issuedDiagnostic = handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, /*shouldComputeAliasesToMakeVisible*/ true)); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForSymbol(symbol, meaning)); + return issuedDiagnostic; } function reportPrivateInBaseOfClassExpression(propertyName) { - if (errorNameNode) { - context.addDiagnostic(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.Property_0_of_exported_class_expression_may_not_be_private_or_protected, propertyName)); + if (errorNameNode || errorFallbackNode) { + context.addDiagnostic(ts.createDiagnosticForNode((errorNameNode || errorFallbackNode), ts.Diagnostics.Property_0_of_exported_class_expression_may_not_be_private_or_protected, propertyName)); } } function reportInaccessibleUniqueSymbolError() { @@ -98346,35 +101799,38 @@ var ts; } } function reportTruncationError() { - if (errorNameNode) { - context.addDiagnostic(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_this_node_exceeds_the_maximum_length_the_compiler_will_serialize_An_explicit_type_annotation_is_needed)); + if (errorNameNode || errorFallbackNode) { + context.addDiagnostic(ts.createDiagnosticForNode((errorNameNode || errorFallbackNode), ts.Diagnostics.The_inferred_type_of_this_node_exceeds_the_maximum_length_the_compiler_will_serialize_An_explicit_type_annotation_is_needed)); } } function reportNonlocalAugmentation(containingFile, parentSymbol, symbol) { - var primaryDeclaration = ts.find(parentSymbol.declarations, function (d) { return ts.getSourceFileOfNode(d) === containingFile; }); + var _a; + var primaryDeclaration = (_a = parentSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.getSourceFileOfNode(d) === containingFile; }); var augmentingDeclarations = ts.filter(symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== containingFile; }); - for (var _i = 0, augmentingDeclarations_1 = augmentingDeclarations; _i < augmentingDeclarations_1.length; _i++) { - var augmentations = augmentingDeclarations_1[_i]; - context.addDiagnostic(ts.addRelatedInfo(ts.createDiagnosticForNode(augmentations, ts.Diagnostics.Declaration_augments_declaration_in_another_file_This_cannot_be_serialized), ts.createDiagnosticForNode(primaryDeclaration, ts.Diagnostics.This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_file))); + if (augmentingDeclarations) { + for (var _i = 0, augmentingDeclarations_1 = augmentingDeclarations; _i < augmentingDeclarations_1.length; _i++) { + var augmentations = augmentingDeclarations_1[_i]; + context.addDiagnostic(ts.addRelatedInfo(ts.createDiagnosticForNode(augmentations, ts.Diagnostics.Declaration_augments_declaration_in_another_file_This_cannot_be_serialized), ts.createDiagnosticForNode(primaryDeclaration, ts.Diagnostics.This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_file))); + } } } function transformDeclarationsForJS(sourceFile, bundled) { var oldDiag = getSymbolAccessibilityDiagnostic; - getSymbolAccessibilityDiagnostic = function (s) { return ({ + getSymbolAccessibilityDiagnostic = function (s) { return (s.errorNode && ts.canProduceDiagnostics(s.errorNode) ? ts.createGetSymbolAccessibilityDiagnosticForNode(s.errorNode)(s) : ({ diagnosticMessage: s.errorModuleName ? ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit : ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit, errorNode: s.errorNode || sourceFile - }); }; + })); }; var result = resolver.getDeclarationStatementsForSourceFile(sourceFile, declarationEmitNodeBuilderFlags, symbolTracker, bundled); getSymbolAccessibilityDiagnostic = oldDiag; return result; } function transformRoot(node) { - if (node.kind === 297 /* SourceFile */ && node.isDeclarationFile) { + if (node.kind === 299 /* SourceFile */ && node.isDeclarationFile) { return node; } - if (node.kind === 298 /* Bundle */) { + if (node.kind === 300 /* Bundle */) { isBundledEmit = true; refs = new ts.Map(); libs = new ts.Map(); @@ -98397,14 +101853,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(133 /* 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(134 /* 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 === 300 /* InputFiles */) { + if (prepend.kind === 302 /* InputFiles */) { var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal); hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib; collectReferences(sourceFile, refs); @@ -98496,7 +101952,7 @@ var ts; declFileName = paths.declarationFilePath || paths.jsFilePath || file.fileName; } if (declFileName) { - var specifier = ts.moduleSpecifiers.getModuleSpecifier(__assign(__assign({}, options), { baseUrl: options.baseUrl && ts.toPath(options.baseUrl, host.getCurrentDirectory(), host.getCanonicalFileName) }), currentSourceFile, ts.toPath(outputFilePath, host.getCurrentDirectory(), host.getCanonicalFileName), ts.toPath(declFileName, host.getCurrentDirectory(), host.getCanonicalFileName), host, + var specifier = ts.moduleSpecifiers.getModuleSpecifier(options, currentSourceFile, ts.toPath(outputFilePath, host.getCurrentDirectory(), host.getCanonicalFileName), ts.toPath(declFileName, host.getCurrentDirectory(), host.getCanonicalFileName), host, /*preferences*/ undefined); if (!ts.pathIsRelative(specifier)) { // If some compiler option/symlink/whatever allows access to the file containing the ambient module declaration @@ -98541,11 +101997,11 @@ var ts; return ret; } function filterBindingPatternInitializers(name) { - if (name.kind === 78 /* Identifier */) { + if (name.kind === 79 /* Identifier */) { return name; } else { - if (name.kind === 197 /* ArrayBindingPattern */) { + if (name.kind === 199 /* ArrayBindingPattern */) { return factory.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -98553,7 +102009,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 222 /* OmittedExpression */) { + if (elem.kind === 224 /* OmittedExpression */) { return elem; } return factory.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); @@ -98591,19 +102047,19 @@ var ts; // Literal const declarations will have an initializer ensured rather than a type return; } - var shouldUseResolverType = node.kind === 160 /* Parameter */ && + var shouldUseResolverType = node.kind === 162 /* 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(128 /* AnyKeyword */); + return type ? ts.visitNode(type, visitDeclarationSubtree) : factory.createKeywordTypeNode(129 /* AnyKeyword */); } - if (node.kind === 168 /* SetAccessor */) { + if (node.kind === 170 /* 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(128 /* AnyKeyword */); + return factory.createKeywordTypeNode(129 /* AnyKeyword */); } errorNameNode = node.name; var oldDiag; @@ -98611,12 +102067,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 249 /* VariableDeclaration */ || node.kind === 198 /* BindingElement */) { + if (node.kind === 251 /* VariableDeclaration */ || node.kind === 200 /* BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 160 /* Parameter */ - || node.kind === 163 /* PropertyDeclaration */ - || node.kind === 162 /* PropertySignature */) { + if (node.kind === 162 /* Parameter */ + || node.kind === 165 /* PropertyDeclaration */ + || node.kind === 164 /* PropertySignature */) { if (!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)); @@ -98627,30 +102083,39 @@ var ts; if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } - return returnValue || factory.createKeywordTypeNode(128 /* AnyKeyword */); + return returnValue || factory.createKeywordTypeNode(129 /* AnyKeyword */); } } function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 256 /* ModuleDeclaration */: - case 253 /* InterfaceDeclaration */: - case 252 /* ClassDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 255 /* EnumDeclaration */: + case 253 /* FunctionDeclaration */: + case 258 /* ModuleDeclaration */: + case 255 /* InterfaceDeclaration */: + case 254 /* ClassDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 257 /* EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return !getBindingNameVisible(node); - case 260 /* ImportEqualsDeclaration */: - case 261 /* ImportDeclaration */: - case 267 /* ExportDeclaration */: - case 266 /* ExportAssignment */: + case 262 /* ImportEqualsDeclaration */: + case 263 /* ImportDeclaration */: + case 269 /* ExportDeclaration */: + case 268 /* ExportAssignment */: return false; } return false; } + // If the ExpandoFunctionDeclaration have multiple overloads, then we only need to emit properties for the last one. + function shouldEmitFunctionProperties(input) { + var _a; + if (input.body) { + return true; + } + var overloadSignatures = (_a = input.symbol.declarations) === null || _a === void 0 ? void 0 : _a.filter(function (decl) { return ts.isFunctionDeclaration(decl) && !decl.body; }); + return !overloadSignatures || overloadSignatures.indexOf(input) === overloadSignatures.length - 1; + } function getBindingNameVisible(elem) { if (ts.isOmittedExpression(elem)) { return false; @@ -98727,7 +102192,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 256 /* ModuleDeclaration */ && parent.kind !== 195 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 258 /* ModuleDeclaration */ && parent.kind !== 197 /* ImportType */); if (ts.isStringLiteralLike(input)) { if (isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); @@ -98747,7 +102212,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 272 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 274 /* ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return factory.updateImportEqualsDeclaration(decl, @@ -98774,7 +102239,7 @@ var ts; return visibleDefaultBinding && factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier)); } - if (decl.importClause.namedBindings.kind === 263 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 265 /* 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, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier)) : undefined; @@ -98869,7 +102334,7 @@ var ts; // We'd see a TDZ violation at runtime var canProduceDiagnostic = ts.canProduceDiagnostics(input); var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 177 /* TypeLiteral */ || input.kind === 190 /* MappedType */) && input.parent.kind !== 254 /* TypeAliasDeclaration */); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 179 /* TypeLiteral */ || input.kind === 192 /* MappedType */) && input.parent.kind !== 256 /* 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 */)) { @@ -98890,21 +102355,21 @@ var ts; } if (isProcessedComponent(input)) { switch (input.kind) { - case 223 /* ExpressionWithTypeArguments */: { + case 225 /* 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 173 /* TypeReference */: { + case 175 /* TypeReference */: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(factory.updateTypeReferenceNode(node, node.typeName, node.typeArguments)); } - case 170 /* ConstructSignature */: + case 172 /* ConstructSignature */: return cleanup(factory.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 166 /* Constructor */: { + case 168 /* Constructor */: { // A constructor declaration may not have a type annotation var ctor = factory.createConstructorDeclaration( /*decorators*/ undefined, @@ -98912,7 +102377,7 @@ var ts; /*body*/ undefined); return cleanup(ctor); } - case 165 /* MethodDeclaration */: { + case 167 /* MethodDeclaration */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } @@ -98922,7 +102387,7 @@ var ts; /*body*/ undefined); return cleanup(sig); } - case 167 /* GetAccessor */: { + case 169 /* GetAccessor */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } @@ -98931,7 +102396,7 @@ var ts; /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* Private */)), ensureType(input, accessorType), /*body*/ undefined)); } - case 168 /* SetAccessor */: { + case 170 /* SetAccessor */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } @@ -98939,31 +102404,31 @@ var ts; /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* Private */)), /*body*/ undefined)); } - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } return cleanup(factory.updatePropertyDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type), ensureNoInitializer(input))); - case 162 /* PropertySignature */: + case 164 /* 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 164 /* MethodSignature */: { + case 166 /* 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 169 /* CallSignature */: { + case 171 /* CallSignature */: { return cleanup(factory.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 171 /* IndexSignature */: { + case 173 /* IndexSignature */: { return cleanup(factory.updateIndexSignature(input, - /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || factory.createKeywordTypeNode(128 /* AnyKeyword */))); + /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || factory.createKeywordTypeNode(129 /* AnyKeyword */))); } - case 249 /* VariableDeclaration */: { + case 251 /* VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -98971,13 +102436,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 159 /* TypeParameter */: { + case 161 /* TypeParameter */: { if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) { return cleanup(factory.updateTypeParameterDeclaration(input, input.name, /*constraint*/ undefined, /*defaultType*/ undefined)); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 184 /* ConditionalType */: { + case 186 /* 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); @@ -98989,13 +102454,13 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(factory.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 174 /* FunctionType */: { + case 176 /* FunctionType */: { return cleanup(factory.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 175 /* ConstructorType */: { + case 177 /* ConstructorType */: { return cleanup(factory.updateConstructorTypeNode(input, ensureModifiers(input), ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 195 /* ImportType */: { + case 197 /* ImportType */: { if (!ts.isLiteralImportTypeNode(input)) return cleanup(input); return cleanup(factory.updateImportTypeNode(input, factory.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); @@ -99027,7 +102492,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 165 /* MethodDeclaration */ && ts.hasEffectiveModifier(node.parent, 8 /* Private */); + return node.parent.kind === 167 /* MethodDeclaration */ && ts.hasEffectiveModifier(node.parent, 8 /* Private */); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -99037,7 +102502,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 267 /* ExportDeclaration */: { + case 269 /* ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } @@ -99047,13 +102512,13 @@ var ts; return factory.updateExportDeclaration(input, /*decorators*/ undefined, input.modifiers, input.isTypeOnly, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 266 /* ExportAssignment */: { + case 268 /* 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 === 78 /* Identifier */) { + if (input.expression.kind === 79 /* Identifier */) { return input; } else { @@ -99062,8 +102527,10 @@ var ts; diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0, errorNode: input }); }; + errorFallbackNode = input; var varDecl = factory.createVariableDeclaration(newId, /*exclamationToken*/ undefined, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); - var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(133 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); + errorFallbackNode = undefined; + var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(134 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); return [statement, factory.updateExportAssignment(input, input.decorators, input.modifiers, newId)]; } } @@ -99079,17 +102546,17 @@ var ts; // 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) & (11263 /* All */ ^ 1 /* Export */)); + var modifiers = factory.createModifiersFromModifierFlags(ts.getEffectiveModifierFlags(statement) & (27647 /* All */ ^ 1 /* Export */)); return factory.updateModifiers(statement, modifiers); } function transformTopLevelDeclaration(input) { if (shouldStripInternal(input)) return; switch (input.kind) { - case 260 /* ImportEqualsDeclaration */: { + case 262 /* ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 261 /* ImportDeclaration */: { + case 263 /* ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -99110,20 +102577,20 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 254 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 256 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all return cleanup(factory.updateTypeAliasDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 253 /* InterfaceDeclaration */: { + case 255 /* InterfaceDeclaration */: { return cleanup(factory.updateInterfaceDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 251 /* FunctionDeclaration */: { + case 253 /* FunctionDeclaration */: { // Generators lose their generator-ness, excepting their return type var clean = cleanup(factory.updateFunctionDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), /*asteriskToken*/ undefined, input.name, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), /*body*/ undefined)); - if (clean && resolver.isExpandoFunctionDeclaration(input)) { + 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(/*decorators*/ undefined, /*modifiers*/ undefined, clean.name || factory.createIdentifier("_default"), factory.createModuleBlock([]), 16 /* Namespace */); @@ -99132,7 +102599,7 @@ var ts; fakespace_1.symbol = props[0].parent; var exportMappings_1 = []; var declarations = ts.mapDefined(props, function (p) { - if (!ts.isPropertyAccessExpression(p.valueDeclaration)) { + if (!p.valueDeclaration || !ts.isPropertyAccessExpression(p.valueDeclaration)) { return undefined; // TODO GH#33569: Handle element access expressions that created late bound names (rather than silently omitting them) } getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p.valueDeclaration); @@ -99145,7 +102612,7 @@ var ts; exportMappings_1.push([name, nameStr]); } var varDecl = factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, type, /*initializer*/ undefined); - return factory.createVariableStatement(isNonContextualKeywordName ? undefined : [factory.createToken(92 /* ExportKeyword */)], factory.createVariableDeclarationList([varDecl])); + return factory.createVariableStatement(isNonContextualKeywordName ? undefined : [factory.createToken(93 /* ExportKeyword */)], factory.createVariableDeclarationList([varDecl])); }); if (!exportMappings_1.length) { declarations = ts.mapDefined(declarations, function (declaration) { return factory.updateModifiers(declaration, 0 /* None */); }); @@ -99184,10 +102651,10 @@ var ts; return clean; } } - case 256 /* ModuleDeclaration */: { + case 258 /* ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 257 /* ModuleBlock */) { + if (inner && inner.kind === 259 /* ModuleBlock */) { var oldNeedsScopeFix = needsScopeFixMarker; var oldHasScopeFix = resultHasScopeMarker; resultHasScopeMarker = false; @@ -99230,7 +102697,9 @@ var ts; /*decorators*/ undefined, mods, input.name, body)); } } - case 252 /* ClassDeclaration */: { + case 254 /* ClassDeclaration */: { + errorNameNode = input.name; + errorFallbackNode = input; var modifiers = factory.createNodeArray(ensureModifiers(input)); var typeParameters = ensureTypeParams(input, input.typeParameters); var ctor = ts.getFirstConstructorWithBody(input); @@ -99238,10 +102707,10 @@ var ts; if (ctor) { var oldDiag_1 = getSymbolAccessibilityDiagnostic; parameterProperties = ts.compact(ts.flatMap(ctor.parameters, function (param) { - if (!ts.hasSyntacticModifier(param, 92 /* ParameterPropertyModifier */) || shouldStripInternal(param)) + if (!ts.hasSyntacticModifier(param, 16476 /* ParameterPropertyModifier */) || shouldStripInternal(param)) return; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(param); - if (param.name.kind === 78 /* Identifier */) { + if (param.name.kind === 79 /* Identifier */) { return preserveJsDoc(factory.createPropertyDeclaration( /*decorators*/ undefined, ensureModifiers(param), param.name, param.questionToken, ensureType(param, param.type), ensureNoInitializer(param)), param); } @@ -99283,7 +102752,7 @@ 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 !== 103 /* NullKeyword */) { + if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 104 /* 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 */); @@ -99293,16 +102762,16 @@ var ts; 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(133 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(134 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); var heritageClauses = factory.createNodeArray(ts.map(input.heritageClauses, function (clause) { - if (clause.token === 93 /* ExtendsKeyword */) { + if (clause.token === 94 /* 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 === 103 /* 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 /* NullKeyword */; })), visitDeclarationSubtree)); })); return [statement, cleanup(factory.updateClassDeclaration(input, /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members))]; // TODO: GH#18217 @@ -99313,10 +102782,10 @@ var ts; /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 232 /* VariableStatement */: { + case 234 /* VariableStatement */: { return cleanup(transformVariableStatement(input)); } - case 255 /* EnumDeclaration */: { + case 257 /* EnumDeclaration */: { return cleanup(factory.updateEnumDeclaration(input, /*decorators*/ undefined, factory.createNodeArray(ensureModifiers(input)), input.name, factory.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -99335,12 +102804,14 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 256 /* ModuleDeclaration */) { + if (input.kind === 258 /* ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { return node; } + errorFallbackNode = undefined; + errorNameNode = undefined; return node && ts.setOriginalNode(preserveJsDoc(node, input), input); } } @@ -99356,7 +102827,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 222 /* OmittedExpression */) { + if (e.kind === 224 /* OmittedExpression */) { return; } if (e.name) { @@ -99404,9 +102875,9 @@ var ts; return factory.createModifiersFromModifierFlags(newFlags); } function ensureModifierFlags(node) { - var mask = 11263 /* All */ ^ (4 /* Public */ | 256 /* Async */); // No async modifiers in declaration files + var mask = 27647 /* 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 === 297 /* SourceFile */; + var parentIsFile = node.parent.kind === 299 /* SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= 2 /* Ambient */; additions = 0 /* None */; @@ -99429,13 +102900,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 === 93 /* ExtendsKeyword */ && t.expression.kind === 103 /* NullKeyword */); + return ts.isEntityNameExpression(t.expression) || (clause.token === 94 /* ExtendsKeyword */ && t.expression.kind === 104 /* NullKeyword */); })), visitDeclarationSubtree)); }), function (clause) { return clause.types && !!clause.types.length; })); } } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 253 /* InterfaceDeclaration */) { + if (node.kind === 255 /* InterfaceDeclaration */) { return true; } return false; @@ -99445,7 +102916,7 @@ var ts; return ts.factory.createModifiersFromModifierFlags(maskModifierFlags(node, modifierMask, modifierAdditions)); } function maskModifierFlags(node, modifierMask, modifierAdditions) { - if (modifierMask === void 0) { modifierMask = 11263 /* All */ ^ 4 /* Public */; } + if (modifierMask === void 0) { modifierMask = 27647 /* All */ ^ 4 /* Public */; } if (modifierAdditions === void 0) { modifierAdditions = 0 /* None */; } var flags = (ts.getEffectiveModifierFlags(node) & modifierMask) | modifierAdditions; if (flags & 512 /* Default */ && !(flags & 1 /* Export */)) { @@ -99460,7 +102931,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 167 /* GetAccessor */ + return accessor.kind === 169 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -99469,52 +102940,52 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: return !ts.hasEffectiveModifier(node, 8 /* Private */); - case 160 /* Parameter */: - case 249 /* VariableDeclaration */: + case 162 /* Parameter */: + case 251 /* VariableDeclaration */: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 256 /* ModuleDeclaration */: - case 260 /* ImportEqualsDeclaration */: - case 253 /* InterfaceDeclaration */: - case 252 /* ClassDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 255 /* EnumDeclaration */: - case 232 /* VariableStatement */: - case 261 /* ImportDeclaration */: - case 267 /* ExportDeclaration */: - case 266 /* ExportAssignment */: + case 253 /* FunctionDeclaration */: + case 258 /* ModuleDeclaration */: + case 262 /* ImportEqualsDeclaration */: + case 255 /* InterfaceDeclaration */: + case 254 /* ClassDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 257 /* EnumDeclaration */: + case 234 /* VariableStatement */: + case 263 /* ImportDeclaration */: + case 269 /* ExportDeclaration */: + case 268 /* ExportAssignment */: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { - case 170 /* ConstructSignature */: - case 166 /* Constructor */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 164 /* MethodSignature */: - case 169 /* CallSignature */: - case 171 /* IndexSignature */: - case 249 /* VariableDeclaration */: - case 159 /* TypeParameter */: - case 223 /* ExpressionWithTypeArguments */: - case 173 /* TypeReference */: - case 184 /* ConditionalType */: - case 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 195 /* ImportType */: + case 172 /* ConstructSignature */: + case 168 /* Constructor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 166 /* MethodSignature */: + case 171 /* CallSignature */: + case 173 /* IndexSignature */: + case 251 /* VariableDeclaration */: + case 161 /* TypeParameter */: + case 225 /* ExpressionWithTypeArguments */: + case 175 /* TypeReference */: + case 186 /* ConditionalType */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: + case 197 /* ImportType */: return true; } return false; @@ -99570,6 +103041,9 @@ var ts; if (languageVersion < 99 /* ESNext */) { transformers.push(ts.transformESNext); } + if (languageVersion < 8 /* ES2021 */) { + transformers.push(ts.transformES2021); + } if (languageVersion < 7 /* ES2020 */) { transformers.push(ts.transformES2020); } @@ -99646,7 +103120,7 @@ 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(341 /* Count */); + var enabledSyntaxKindFeatures = new Array(349 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentStatements; @@ -99657,6 +103131,9 @@ var ts; var lexicalEnvironmentFlagsStack = []; var lexicalEnvironmentStackOffset = 0; var lexicalEnvironmentSuspended = false; + var blockScopedVariableDeclarationsStack = []; + var blockScopeStackOffset = 0; + var blockScopedVariableDeclarations; var emitHelpers; var onSubstituteNode = noEmitSubstitution; var onEmitNode = noEmitNotification; @@ -99679,6 +103156,9 @@ var ts; hoistVariableDeclaration: hoistVariableDeclaration, hoistFunctionDeclaration: hoistFunctionDeclaration, addInitializationStatement: addInitializationStatement, + startBlockScope: startBlockScope, + endBlockScope: endBlockScope, + addBlockScopedVariable: addBlockScopedVariable, requestEmitHelper: requestEmitHelper, readEmitHelpers: readEmitHelpers, enableSubstitution: enableSubstitution, @@ -99722,9 +103202,9 @@ var ts; var transformed = []; for (var _a = 0, nodes_3 = nodes; _a < nodes_3.length; _a++) { var node = nodes_3[_a]; - ts.tracing.push("emit" /* Emit */, "transformNodes", node.kind === 297 /* 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" /* Emit */, "transformNodes", node.kind === 299 /* SourceFile */ ? { path: node.path } : { kind: node.kind, pos: node.pos, end: node.end }); transformed.push((allowDtsFiles ? transformation : transformRoot)(node)); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } // prevent modification of the lexical environment. state = 2 /* Completed */; @@ -99939,6 +103419,38 @@ var ts; function getLexicalEnvironmentFlags() { return lexicalEnvironmentFlags; } + /** + * 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."); + blockScopedVariableDeclarationsStack[blockScopeStackOffset] = blockScopedVariableDeclarations; + blockScopeStackOffset++; + blockScopedVariableDeclarations = undefined; + } + /** + * 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."); + var statements = ts.some(blockScopedVariableDeclarations) ? + [ + factory.createVariableStatement( + /*modifiers*/ undefined, factory.createVariableDeclarationList(blockScopedVariableDeclarations.map(function (identifier) { return factory.createVariableDeclaration(identifier); }), 1 /* Let */)) + ] : undefined; + blockScopeStackOffset--; + blockScopedVariableDeclarations = blockScopedVariableDeclarationsStack[blockScopeStackOffset]; + if (blockScopeStackOffset === 0) { + blockScopedVariableDeclarationsStack = []; + } + return statements; + } + function addBlockScopedVariable(name) { + ts.Debug.assert(blockScopeStackOffset > 0, "Cannot add a block scoped variable outside of an iteration body."); + (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."); @@ -99980,35 +103492,37 @@ var ts; } ts.transformNodes = transformNodes; ts.nullTransformationContext = { - get factory() { return ts.factory; }, - enableEmitNotification: ts.noop, - enableSubstitution: ts.noop, - endLexicalEnvironment: ts.returnUndefined, + factory: ts.factory, getCompilerOptions: function () { return ({}); }, - getEmitHost: ts.notImplemented, getEmitResolver: ts.notImplemented, + getEmitHost: ts.notImplemented, getEmitHelperFactory: ts.notImplemented, + startLexicalEnvironment: ts.noop, + resumeLexicalEnvironment: ts.noop, + suspendLexicalEnvironment: ts.noop, + endLexicalEnvironment: ts.returnUndefined, setLexicalEnvironmentFlags: ts.noop, getLexicalEnvironmentFlags: function () { return 0; }, - hoistFunctionDeclaration: ts.noop, hoistVariableDeclaration: ts.noop, + hoistFunctionDeclaration: ts.noop, addInitializationStatement: ts.noop, - isEmitNotificationEnabled: ts.notImplemented, - isSubstitutionEnabled: ts.notImplemented, - onEmitNode: ts.noop, - onSubstituteNode: ts.notImplemented, - readEmitHelpers: ts.notImplemented, + startBlockScope: ts.noop, + endBlockScope: ts.returnUndefined, + addBlockScopedVariable: ts.noop, requestEmitHelper: ts.noop, - resumeLexicalEnvironment: ts.noop, - startLexicalEnvironment: ts.noop, - suspendLexicalEnvironment: ts.noop, + readEmitHelpers: ts.notImplemented, + enableSubstitution: ts.noop, + enableEmitNotification: ts.noop, + isSubstitutionEnabled: ts.notImplemented, + isEmitNotificationEnabled: ts.notImplemented, + onSubstituteNode: noEmitSubstitution, + onEmitNode: noEmitNotification, addDiagnostic: ts.noop, }; })(ts || (ts = {})); var ts; (function (ts) { var brackets = createBracketsMap(); - var syntheticParent = { pos: -1, end: -1 }; /*@internal*/ function isBuildInfoFile(file) { return ts.fileExtensionIs(file, ".tsbuildinfo" /* TsBuildInfo */); @@ -100094,7 +103608,7 @@ var ts; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 298 /* Bundle */) { + if (sourceFile.kind === 300 /* Bundle */) { return getOutputPathsForBundle(options, forceDtsPaths); } else { @@ -100320,15 +103834,15 @@ var ts; sourceFiles: sourceFileOrBundle.sourceFiles.map(function (file) { return relativeToBuildInfo(ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory())); }) }; } - ts.tracing.push("emit" /* Emit */, "emitJsFileOrBundle", { jsFilePath: jsFilePath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitJsFileOrBundle", { jsFilePath: jsFilePath }); emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo); - ts.tracing.pop(); - ts.tracing.push("emit" /* Emit */, "emitDeclarationFileOrBundle", { declarationFilePath: declarationFilePath }); + 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 }); emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo); - ts.tracing.pop(); - ts.tracing.push("emit" /* Emit */, "emitBuildInfo", { buildInfoPath: buildInfoPath }); + 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 }); emitBuildInfo(bundleBuildInfo, buildInfoPath); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); if (!emitSkipped && emittedFilesList) { if (!emitOnlyDtsFiles) { if (jsFilePath) { @@ -100455,13 +103969,13 @@ var ts; 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: compilerOptions.declarationMap, + sourceMap: !forceDtsEmit && compilerOptions.declarationMap, sourceRoot: compilerOptions.sourceRoot, mapRoot: compilerOptions.mapRoot, extendedDiagnostics: compilerOptions.extendedDiagnostics, // Explicitly do not passthru either `inline` option }); - if (forceDtsEmit && declarationTransform.transformed[0].kind === 297 /* SourceFile */) { + if (forceDtsEmit && declarationTransform.transformed[0].kind === 299 /* SourceFile */) { var sourceFile = declarationTransform.transformed[0]; exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; } @@ -100472,7 +103986,7 @@ var ts; } function collectLinkedAliases(node) { if (ts.isExportAssignment(node)) { - if (node.expression.kind === 78 /* Identifier */) { + if (node.expression.kind === 79 /* Identifier */) { resolver.collectLinkedAliases(node.expression, /*setVisibility*/ true); } return; @@ -100484,8 +103998,8 @@ var ts; ts.forEachChild(node, collectLinkedAliases); } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) { - var bundle = sourceFileOrBundle.kind === 298 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 297 /* SourceFile */ ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 300 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 299 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; var sourceMapGenerator; if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { @@ -100526,7 +104040,7 @@ var ts; } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { return (mapOptions.sourceMap || mapOptions.inlineSourceMap) - && (sourceFileOrBundle.kind !== 297 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); + && (sourceFileOrBundle.kind !== 299 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); } function getSourceRoot(mapOptions) { // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the @@ -100585,7 +104099,7 @@ var ts; ts.emitFiles = emitFiles; /*@internal*/ function getBuildInfoText(buildInfo) { - return JSON.stringify(buildInfo, undefined, 2); + return JSON.stringify(buildInfo); } ts.getBuildInfoText = getBuildInfoText; /*@internal*/ @@ -100766,7 +104280,7 @@ var ts; function createPrinter(printerOptions, handlers) { if (printerOptions === void 0) { printerOptions = {}; } if (handlers === void 0) { handlers = {}; } - var hasGlobalName = handlers.hasGlobalName, _a = handlers.onEmitNode, onEmitNode = _a === void 0 ? ts.noEmitNotification : _a, isEmitNotificationEnabled = handlers.isEmitNotificationEnabled, _b = handlers.substituteNode, substituteNode = _b === void 0 ? ts.noEmitSubstitution : _b, onBeforeEmitNodeArray = handlers.onBeforeEmitNodeArray, onAfterEmitNodeArray = handlers.onAfterEmitNodeArray, onBeforeEmitToken = handlers.onBeforeEmitToken, onAfterEmitToken = handlers.onAfterEmitToken; + var hasGlobalName = handlers.hasGlobalName, _a = handlers.onEmitNode, onEmitNode = _a === void 0 ? ts.noEmitNotification : _a, isEmitNotificationEnabled = handlers.isEmitNotificationEnabled, _b = handlers.substituteNode, substituteNode = _b === void 0 ? ts.noEmitSubstitution : _b, onBeforeEmitNode = handlers.onBeforeEmitNode, onAfterEmitNode = handlers.onAfterEmitNode, onBeforeEmitNodeArray = handlers.onBeforeEmitNodeArray, onAfterEmitNodeArray = handlers.onAfterEmitNodeArray, onBeforeEmitToken = handlers.onBeforeEmitToken, onAfterEmitToken = handlers.onAfterEmitToken; var extendedDiagnostics = !!printerOptions.extendedDiagnostics; var newLine = ts.getNewLineCharacter(printerOptions); var moduleKind = ts.getEmitModuleKind(printerOptions); @@ -100805,9 +104319,11 @@ var ts; var detachedCommentsInfo; var hasWrittenComment = false; var commentsDisabled = !!printerOptions.removeComments; - var lastNode; var lastSubstitution; + var currentParenthesizerRule; var _c = ts.performance.createTimerIf(extendedDiagnostics, "commentTime", "beforeComment", "afterComment"), enterComment = _c.enter, exitComment = _c.exit; + var parenthesizer = ts.factory.parenthesizer; + var emitBinaryExpression = createEmitBinaryExpression(); reset(); return { // public API @@ -100835,9 +104351,9 @@ var ts; break; } switch (node.kind) { - case 297 /* SourceFile */: return printFile(node); - case 298 /* Bundle */: return printBundle(node); - case 299 /* UnparsedSource */: return printUnparsedSource(node); + case 299 /* SourceFile */: return printFile(node); + case 300 /* Bundle */: return printBundle(node); + case 301 /* UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -100871,7 +104387,7 @@ var ts; if (sourceFile) { setSourceFile(sourceFile); } - emitList(syntheticParent, nodes, format); + emitList(/*parentNode*/ undefined, nodes, format); reset(); writer = previousWriter; } @@ -101006,7 +104522,7 @@ var ts; if (sourceFile) { setSourceFile(sourceFile); } - pipelineEmit(hint, node); + pipelineEmit(hint, node, /*parenthesizerRule*/ undefined); } function setSourceFile(sourceFile) { currentSourceFile = sourceFile; @@ -101034,51 +104550,54 @@ var ts; currentSourceFile = undefined; currentLineMap = undefined; detachedCommentsInfo = undefined; - lastNode = undefined; - lastSubstitution = undefined; setWriter(/*output*/ undefined, /*_sourceMapGenerator*/ undefined); } function getCurrentLineMap() { return currentLineMap || (currentLineMap = ts.getLineStarts(currentSourceFile)); } - function emit(node) { + function emit(node, parenthesizerRule) { if (node === undefined) return; var prevSourceFileTextKind = recordBundleFileInternalSectionStart(node); - var substitute = pipelineEmit(4 /* Unspecified */, node); + pipelineEmit(4 /* Unspecified */, node, parenthesizerRule); recordBundleFileInternalSectionEnd(prevSourceFileTextKind); - return substitute; } function emitIdentifierName(node) { if (node === undefined) return; - return pipelineEmit(2 /* IdentifierName */, node); + pipelineEmit(2 /* IdentifierName */, node, /*parenthesizerRule*/ undefined); } - function emitExpression(node) { + function emitExpression(node, parenthesizerRule) { if (node === undefined) return; - return pipelineEmit(1 /* Expression */, node); + pipelineEmit(1 /* Expression */, node, parenthesizerRule); } function emitJsxAttributeValue(node) { - return pipelineEmit(ts.isStringLiteral(node) ? 6 /* JsxAttributeValue */ : 4 /* Unspecified */, node); + pipelineEmit(ts.isStringLiteral(node) ? 6 /* JsxAttributeValue */ : 4 /* Unspecified */, node); } - function pipelineEmit(emitHint, node) { - var savedLastNode = lastNode; - var savedLastSubstitution = lastSubstitution; - var savedPreserveSourceNewlines = preserveSourceNewlines; - lastNode = node; - lastSubstitution = undefined; - if (preserveSourceNewlines && !!(ts.getEmitFlags(node) & 134217728 /* IgnoreSourceNewlines */)) { + function beforeEmitNode(node) { + if (preserveSourceNewlines && (ts.getEmitFlags(node) & 134217728 /* IgnoreSourceNewlines */)) { preserveSourceNewlines = false; } + } + function afterEmitNode(savedPreserveSourceNewlines) { + preserveSourceNewlines = savedPreserveSourceNewlines; + } + function pipelineEmit(emitHint, node, parenthesizerRule) { + currentParenthesizerRule = parenthesizerRule; var pipelinePhase = getPipelinePhase(0 /* Notification */, emitHint, node); pipelinePhase(emitHint, node); - ts.Debug.assert(lastNode === node); - var substitute = lastSubstitution; - lastNode = savedLastNode; - lastSubstitution = savedLastSubstitution; - preserveSourceNewlines = savedPreserveSourceNewlines; - return substitute || node; + currentParenthesizerRule = undefined; + } + function shouldEmitComments(node) { + return !commentsDisabled && !ts.isSourceFile(node); + } + function shouldEmitSourceMaps(node) { + return !sourceMapsDisabled && + !ts.isSourceFile(node) && + !ts.isInJsonFile(node) && + !ts.isUnparsedSource(node) && + !ts.isUnparsedPrepend(node); } function getPipelinePhase(phase, emitHint, node) { switch (phase) { @@ -101088,18 +104607,21 @@ var ts; } // falls through case 1 /* Substitution */: - if (substituteNode !== ts.noEmitSubstitution && (lastSubstitution = substituteNode(emitHint, node)) !== node) { + if (substituteNode !== ts.noEmitSubstitution && (lastSubstitution = substituteNode(emitHint, node) || node) !== node) { + if (currentParenthesizerRule) { + lastSubstitution = currentParenthesizerRule(lastSubstitution); + } return pipelineEmitWithSubstitution; } // falls through case 2 /* Comments */: - if (!commentsDisabled && node.kind !== 297 /* SourceFile */) { + if (shouldEmitComments(node)) { return pipelineEmitWithComments; } // falls through case 3 /* SourceMaps */: - if (!sourceMapsDisabled && node.kind !== 297 /* SourceFile */ && !ts.isInJsonFile(node)) { - return pipelineEmitWithSourceMap; + if (shouldEmitSourceMaps(node)) { + return pipelineEmitWithSourceMaps; } // falls through case 4 /* Emit */: @@ -101112,13 +104634,25 @@ var ts; return getPipelinePhase(currentPhase + 1, emitHint, node); } function pipelineEmitWithNotification(hint, node) { - ts.Debug.assert(lastNode === node); var pipelinePhase = getNextPipelinePhase(0 /* Notification */, hint, node); onEmitNode(hint, node, pipelinePhase); - ts.Debug.assert(lastNode === node); } function pipelineEmitWithHint(hint, node) { - ts.Debug.assert(lastNode === node || lastSubstitution === node); + onBeforeEmitNode === null || onBeforeEmitNode === void 0 ? void 0 : onBeforeEmitNode(node); + if (preserveSourceNewlines) { + var savedPreserveSourceNewlines = preserveSourceNewlines; + beforeEmitNode(node); + pipelineEmitWithHintWorker(hint, node); + afterEmitNode(savedPreserveSourceNewlines); + } + else { + pipelineEmitWithHintWorker(hint, node); + } + onAfterEmitNode === null || onAfterEmitNode === void 0 ? void 0 : onAfterEmitNode(node); + // clear the parenthesizer rule as we ascend + currentParenthesizerRule = undefined; + } + function pipelineEmitWithHintWorker(hint, node) { if (hint === 0 /* SourceFile */) return emitSourceFile(ts.cast(node, ts.isSourceFile)); if (hint === 2 /* IdentifierName */) @@ -101132,308 +104666,337 @@ var ts; return emitEmptyStatement(/*isEmbeddedStatement*/ true); } if (hint === 4 /* Unspecified */) { - if (ts.isKeyword(node.kind)) - return writeTokenNode(node, writeKeyword); switch (node.kind) { // Pseudo-literals case 15 /* TemplateHead */: case 16 /* TemplateMiddle */: case 17 /* TemplateTail */: return emitLiteral(node, /*jsxAttributeEscape*/ false); - case 299 /* UnparsedSource */: - case 293 /* UnparsedPrepend */: - return emitUnparsedSourceOrPrepend(node); - case 292 /* UnparsedPrologue */: - return writeUnparsedNode(node); - case 294 /* UnparsedText */: - case 295 /* UnparsedInternalText */: - return emitUnparsedTextLike(node); - case 296 /* UnparsedSyntheticReference */: - return emitUnparsedSyntheticReference(node); // Identifiers - case 78 /* Identifier */: + case 79 /* Identifier */: return emitIdentifier(node); // PrivateIdentifiers - case 79 /* PrivateIdentifier */: + case 80 /* PrivateIdentifier */: return emitPrivateIdentifier(node); // Parse tree nodes // Names - case 157 /* QualifiedName */: + case 159 /* QualifiedName */: return emitQualifiedName(node); - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 159 /* TypeParameter */: + case 161 /* TypeParameter */: return emitTypeParameter(node); - case 160 /* Parameter */: + case 162 /* Parameter */: return emitParameter(node); - case 161 /* Decorator */: + case 163 /* Decorator */: return emitDecorator(node); // Type members - case 162 /* PropertySignature */: + case 164 /* PropertySignature */: return emitPropertySignature(node); - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return emitPropertyDeclaration(node); - case 164 /* MethodSignature */: + case 166 /* MethodSignature */: return emitMethodSignature(node); - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: return emitMethodDeclaration(node); - case 166 /* Constructor */: + case 168 /* Constructor */: return emitConstructor(node); - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return emitAccessorDeclaration(node); - case 169 /* CallSignature */: + case 171 /* CallSignature */: return emitCallSignature(node); - case 170 /* ConstructSignature */: + case 172 /* ConstructSignature */: return emitConstructSignature(node); - case 171 /* IndexSignature */: + case 173 /* IndexSignature */: return emitIndexSignature(node); - case 194 /* TemplateLiteralTypeSpan */: - return emitTemplateTypeSpan(node); // Types - case 172 /* TypePredicate */: + case 174 /* TypePredicate */: return emitTypePredicate(node); - case 173 /* TypeReference */: + case 175 /* TypeReference */: return emitTypeReference(node); - case 174 /* FunctionType */: + case 176 /* FunctionType */: return emitFunctionType(node); - case 308 /* JSDocFunctionType */: - return emitJSDocFunctionType(node); - case 175 /* ConstructorType */: + case 177 /* ConstructorType */: return emitConstructorType(node); - case 176 /* TypeQuery */: + case 178 /* TypeQuery */: return emitTypeQuery(node); - case 177 /* TypeLiteral */: + case 179 /* TypeLiteral */: return emitTypeLiteral(node); - case 178 /* ArrayType */: + case 180 /* ArrayType */: return emitArrayType(node); - case 179 /* TupleType */: + case 181 /* TupleType */: return emitTupleType(node); - case 180 /* OptionalType */: + case 182 /* OptionalType */: return emitOptionalType(node); - case 182 /* UnionType */: + // SyntaxKind.RestType is handled below + case 184 /* UnionType */: return emitUnionType(node); - case 183 /* IntersectionType */: + case 185 /* IntersectionType */: return emitIntersectionType(node); - case 184 /* ConditionalType */: + case 186 /* ConditionalType */: return emitConditionalType(node); - case 185 /* InferType */: + case 187 /* InferType */: return emitInferType(node); - case 186 /* ParenthesizedType */: + case 188 /* ParenthesizedType */: return emitParenthesizedType(node); - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 187 /* ThisType */: + case 189 /* ThisType */: return emitThisType(); - case 188 /* TypeOperator */: + case 190 /* TypeOperator */: return emitTypeOperator(node); - case 189 /* IndexedAccessType */: + case 191 /* IndexedAccessType */: return emitIndexedAccessType(node); - case 190 /* MappedType */: + case 192 /* MappedType */: return emitMappedType(node); - case 191 /* LiteralType */: + case 193 /* LiteralType */: return emitLiteralType(node); - case 193 /* TemplateLiteralType */: + case 194 /* NamedTupleMember */: + return emitNamedTupleMember(node); + case 195 /* TemplateLiteralType */: return emitTemplateType(node); - case 195 /* ImportType */: + case 196 /* TemplateLiteralTypeSpan */: + return emitTemplateTypeSpan(node); + case 197 /* ImportType */: return emitImportTypeNode(node); - case 303 /* JSDocAllType */: - writePunctuation("*"); - return; - case 304 /* JSDocUnknownType */: - writePunctuation("?"); - return; - case 305 /* JSDocNullableType */: - return emitJSDocNullableType(node); - case 306 /* JSDocNonNullableType */: - return emitJSDocNonNullableType(node); - case 307 /* JSDocOptionalType */: - return emitJSDocOptionalType(node); - case 181 /* RestType */: - case 309 /* JSDocVariadicType */: - return emitRestOrJSDocVariadicType(node); - case 192 /* NamedTupleMember */: - return emitNamedTupleMember(node); // Binding patterns - case 196 /* ObjectBindingPattern */: + case 198 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 197 /* ArrayBindingPattern */: + case 199 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 198 /* BindingElement */: + case 200 /* BindingElement */: return emitBindingElement(node); // Misc - case 228 /* TemplateSpan */: + case 230 /* TemplateSpan */: return emitTemplateSpan(node); - case 229 /* SemicolonClassElement */: + case 231 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 230 /* Block */: + case 232 /* Block */: return emitBlock(node); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return emitVariableStatement(node); - case 231 /* EmptyStatement */: + case 233 /* EmptyStatement */: return emitEmptyStatement(/*isEmbeddedStatement*/ false); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: return emitExpressionStatement(node); - case 234 /* IfStatement */: + case 236 /* IfStatement */: return emitIfStatement(node); - case 235 /* DoStatement */: + case 237 /* DoStatement */: return emitDoStatement(node); - case 236 /* WhileStatement */: + case 238 /* WhileStatement */: return emitWhileStatement(node); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return emitForStatement(node); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return emitForInStatement(node); - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: return emitForOfStatement(node); - case 240 /* ContinueStatement */: + case 242 /* ContinueStatement */: return emitContinueStatement(node); - case 241 /* BreakStatement */: + case 243 /* BreakStatement */: return emitBreakStatement(node); - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: return emitReturnStatement(node); - case 243 /* WithStatement */: + case 245 /* WithStatement */: return emitWithStatement(node); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: return emitSwitchStatement(node); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return emitLabeledStatement(node); - case 246 /* ThrowStatement */: + case 248 /* ThrowStatement */: return emitThrowStatement(node); - case 247 /* TryStatement */: + case 249 /* TryStatement */: return emitTryStatement(node); - case 248 /* DebuggerStatement */: + case 250 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 250 /* VariableDeclarationList */: + case 252 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: return emitClassDeclaration(node); - case 253 /* InterfaceDeclaration */: + case 255 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 257 /* ModuleBlock */: + case 259 /* ModuleBlock */: return emitModuleBlock(node); - case 258 /* CaseBlock */: + case 260 /* CaseBlock */: return emitCaseBlock(node); - case 259 /* NamespaceExportDeclaration */: + case 261 /* NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return emitImportDeclaration(node); - case 262 /* ImportClause */: + case 264 /* ImportClause */: return emitImportClause(node); - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: return emitNamespaceImport(node); - case 269 /* NamespaceExport */: + case 271 /* NamespaceExport */: return emitNamespaceExport(node); - case 264 /* NamedImports */: + case 266 /* NamedImports */: return emitNamedImports(node); - case 265 /* ImportSpecifier */: + case 267 /* ImportSpecifier */: return emitImportSpecifier(node); - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return emitExportAssignment(node); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: return emitExportDeclaration(node); - case 268 /* NamedExports */: + case 270 /* NamedExports */: return emitNamedExports(node); - case 270 /* ExportSpecifier */: + case 272 /* ExportSpecifier */: return emitExportSpecifier(node); - case 271 /* MissingDeclaration */: + case 273 /* MissingDeclaration */: return; // Module references - case 272 /* ExternalModuleReference */: + case 274 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 11 /* JsxText */: return emitJsxText(node); - case 275 /* JsxOpeningElement */: - case 278 /* JsxOpeningFragment */: + case 277 /* JsxOpeningElement */: + case 280 /* JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 276 /* JsxClosingElement */: - case 279 /* JsxClosingFragment */: + case 278 /* JsxClosingElement */: + case 281 /* JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 280 /* JsxAttribute */: + case 282 /* JsxAttribute */: return emitJsxAttribute(node); - case 281 /* JsxAttributes */: + case 283 /* JsxAttributes */: return emitJsxAttributes(node); - case 282 /* JsxSpreadAttribute */: + case 284 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 284 /* CaseClause */: + case 286 /* CaseClause */: return emitCaseClause(node); - case 285 /* DefaultClause */: + case 287 /* DefaultClause */: return emitDefaultClause(node); - case 286 /* HeritageClause */: + case 288 /* HeritageClause */: return emitHeritageClause(node); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 290 /* SpreadAssignment */: + case 292 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 291 /* EnumMember */: + case 293 /* EnumMember */: return emitEnumMember(node); + // Unparsed + case 294 /* UnparsedPrologue */: + return writeUnparsedNode(node); + case 301 /* UnparsedSource */: + case 295 /* UnparsedPrepend */: + return emitUnparsedSourceOrPrepend(node); + case 296 /* UnparsedText */: + case 297 /* UnparsedInternalText */: + return emitUnparsedTextLike(node); + case 298 /* UnparsedSyntheticReference */: + return emitUnparsedSyntheticReference(node); + // Top-level nodes + case 299 /* SourceFile */: + return emitSourceFile(node); + case 300 /* Bundle */: + return ts.Debug.fail("Bundles should be printed using printBundle"); + // SyntaxKind.UnparsedSource (handled above) + case 302 /* InputFiles */: + return ts.Debug.fail("InputFiles should not be printed"); // JSDoc nodes (only used in codefixes currently) - case 326 /* JSDocParameterTag */: - case 333 /* JSDocPropertyTag */: + case 303 /* JSDocTypeExpression */: + return emitJSDocTypeExpression(node); + case 304 /* JSDocNameReference */: + return emitJSDocNameReference(node); + case 306 /* JSDocAllType */: + return writePunctuation("*"); + case 307 /* JSDocUnknownType */: + return writePunctuation("?"); + case 308 /* JSDocNullableType */: + return emitJSDocNullableType(node); + case 309 /* JSDocNonNullableType */: + return emitJSDocNonNullableType(node); + case 310 /* JSDocOptionalType */: + return emitJSDocOptionalType(node); + case 311 /* JSDocFunctionType */: + return emitJSDocFunctionType(node); + case 183 /* RestType */: + case 312 /* JSDocVariadicType */: + return emitRestOrJSDocVariadicType(node); + case 313 /* JSDocNamepathType */: + return; + case 314 /* JSDocComment */: + return emitJSDoc(node); + case 316 /* JSDocTypeLiteral */: + return emitJSDocTypeLiteral(node); + case 317 /* JSDocSignature */: + return emitJSDocSignature(node); + case 321 /* JSDocTag */: + case 326 /* JSDocClassTag */: + return emitJSDocSimpleTag(node); + case 322 /* JSDocAugmentsTag */: + case 323 /* JSDocImplementsTag */: + return emitJSDocHeritageTag(node); + case 324 /* JSDocAuthorTag */: + case 325 /* JSDocDeprecatedTag */: + return; + // SyntaxKind.JSDocClassTag (see JSDocTag, above) + case 327 /* JSDocPublicTag */: + case 328 /* JSDocPrivateTag */: + case 329 /* JSDocProtectedTag */: + case 330 /* JSDocReadonlyTag */: + case 331 /* JSDocOverrideTag */: + return; + case 332 /* JSDocCallbackTag */: + return emitJSDocCallbackTag(node); + // SyntaxKind.JSDocEnumTag (see below) + case 334 /* JSDocParameterTag */: + case 341 /* JSDocPropertyTag */: return emitJSDocPropertyLikeTag(node); - case 327 /* JSDocReturnTag */: - case 329 /* JSDocTypeTag */: - case 328 /* JSDocThisTag */: - case 325 /* JSDocEnumTag */: + case 333 /* JSDocEnumTag */: + case 335 /* JSDocReturnTag */: + case 336 /* JSDocThisTag */: + case 337 /* JSDocTypeTag */: return emitJSDocSimpleTypedTag(node); - case 316 /* JSDocImplementsTag */: - case 315 /* JSDocAugmentsTag */: - return emitJSDocHeritageTag(node); - case 330 /* JSDocTemplateTag */: + case 338 /* JSDocTemplateTag */: return emitJSDocTemplateTag(node); - case 331 /* JSDocTypedefTag */: + case 339 /* JSDocTypedefTag */: return emitJSDocTypedefTag(node); - case 324 /* JSDocCallbackTag */: - return emitJSDocCallbackTag(node); - case 313 /* JSDocSignature */: - return emitJSDocSignature(node); - case 312 /* JSDocTypeLiteral */: - return emitJSDocTypeLiteral(node); - case 319 /* JSDocClassTag */: - case 314 /* JSDocTag */: - return emitJSDocSimpleTag(node); - case 332 /* JSDocSeeTag */: + case 340 /* JSDocSeeTag */: return emitJSDocSeeTag(node); - case 302 /* JSDocNameReference */: - return emitJSDocNameReference(node); - case 311 /* JSDocComment */: - return emitJSDoc(node); - // Transformation nodes (ignored) + // SyntaxKind.JSDocPropertyTag (see JSDocParameterTag, above) + // Transformation nodes + case 343 /* NotEmittedStatement */: + case 347 /* EndOfDeclarationMarker */: + case 346 /* MergeDeclarationMarker */: + return; } if (ts.isExpression(node)) { hint = 1 /* Expression */; if (substituteNode !== ts.noEmitSubstitution) { - lastSubstitution = node = substituteNode(hint, node); + var substitute = substituteNode(hint, node) || node; + if (substitute !== node) { + node = substitute; + if (currentParenthesizerRule) { + node = currentParenthesizerRule(node); + } + } } } - else if (ts.isToken(node)) { - return writeTokenNode(node, writePunctuation); - } } if (hint === 1 /* Expression */) { switch (node.kind) { @@ -101446,86 +105009,94 @@ var ts; case 14 /* NoSubstitutionTemplateLiteral */: return emitLiteral(node, /*jsxAttributeEscape*/ false); // Identifiers - case 78 /* Identifier */: + case 79 /* Identifier */: return emitIdentifier(node); - // Reserved words - case 94 /* FalseKeyword */: - case 103 /* NullKeyword */: - case 105 /* SuperKeyword */: - case 109 /* TrueKeyword */: - case 107 /* ThisKeyword */: - case 99 /* ImportKeyword */: - writeTokenNode(node, writeKeyword); - return; // Expressions - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return emitCallExpression(node); - case 204 /* NewExpression */: + case 206 /* NewExpression */: return emitNewExpression(node); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 206 /* TypeAssertionExpression */: + case 208 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: return emitFunctionExpression(node); - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return emitArrowFunction(node); - case 210 /* DeleteExpression */: + case 212 /* DeleteExpression */: return emitDeleteExpression(node); - case 211 /* TypeOfExpression */: + case 213 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 212 /* VoidExpression */: + case 214 /* VoidExpression */: return emitVoidExpression(node); - case 213 /* AwaitExpression */: + case 215 /* AwaitExpression */: return emitAwaitExpression(node); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return emitBinaryExpression(node); - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: return emitConditionalExpression(node); - case 218 /* TemplateExpression */: + case 220 /* TemplateExpression */: return emitTemplateExpression(node); - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: return emitYieldExpression(node); - case 220 /* SpreadElement */: - return emitSpreadExpression(node); - case 221 /* ClassExpression */: + case 222 /* SpreadElement */: + return emitSpreadElement(node); + case 223 /* ClassExpression */: return emitClassExpression(node); - case 222 /* OmittedExpression */: + case 224 /* OmittedExpression */: return; - case 224 /* AsExpression */: + case 226 /* AsExpression */: return emitAsExpression(node); - case 225 /* NonNullExpression */: + case 227 /* NonNullExpression */: return emitNonNullExpression(node); - case 226 /* MetaProperty */: + case 228 /* MetaProperty */: return emitMetaProperty(node); + case 229 /* SyntheticExpression */: + return ts.Debug.fail("SyntheticExpression should never be printed."); // JSX - case 273 /* JsxElement */: + case 275 /* JsxElement */: return emitJsxElement(node); - case 274 /* JsxSelfClosingElement */: + case 276 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 277 /* JsxFragment */: + case 279 /* JsxFragment */: return emitJsxFragment(node); + // Synthesized list + case 342 /* SyntaxList */: + return ts.Debug.fail("SyntaxList should not be printed"); // Transformation nodes - case 336 /* PartiallyEmittedExpression */: + case 343 /* NotEmittedStatement */: + return; + case 344 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 337 /* CommaListExpression */: + case 345 /* CommaListExpression */: return emitCommaList(node); + case 346 /* MergeDeclarationMarker */: + case 347 /* EndOfDeclarationMarker */: + return; + case 348 /* SyntheticReferenceExpression */: + return ts.Debug.fail("SyntheticReferenceExpression should not be printed"); } } + if (ts.isKeyword(node.kind)) + return writeTokenNode(node, writeKeyword); + if (ts.isTokenKind(node.kind)) + return writeTokenNode(node, writePunctuation); + ts.Debug.fail("Unhandled SyntaxKind: " + ts.Debug.formatSyntaxKind(node.kind) + "."); } function emitMappedTypeParameter(node) { emit(node.name); @@ -101535,10 +105106,11 @@ var ts; emit(node.constraint); } function pipelineEmitWithSubstitution(hint, node) { - ts.Debug.assert(lastNode === node || lastSubstitution === node); var pipelinePhase = getNextPipelinePhase(1 /* Substitution */, hint, node); - pipelinePhase(hint, lastSubstitution); - ts.Debug.assert(lastNode === node || lastSubstitution === node); + ts.Debug.assertIsDefined(lastSubstitution); + node = lastSubstitution; + lastSubstitution = undefined; + pipelinePhase(hint, node); } function getHelpersFromBundledSourceFiles(bundle) { var result; @@ -101564,7 +105136,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 298 /* Bundle */ ? node : undefined; + var bundle = node.kind === 300 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -101664,7 +105236,7 @@ var ts; var pos = getTextPosWithWriteLine(); writeUnparsedNode(unparsed); if (bundleFileInfo) { - updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 294 /* UnparsedText */ ? + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 296 /* UnparsedText */ ? "text" /* Text */ : "internal" /* Internal */); } @@ -101701,7 +105273,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { emitExpression(node); } else { @@ -101710,7 +105282,7 @@ var ts; } function emitComputedPropertyName(node) { writePunctuation("["); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfComputedPropertyName); writePunctuation("]"); } // @@ -101737,18 +105309,18 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 308 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 311 /* JSDocFunctionType */ && !node.name) { emit(node.type); } else { emitTypeAnnotation(node.type); } // The comment position has to fallback to any present node within the parameterdeclaration because as it turns out, the parser can make parameter declarations with _just_ an initializer. - emitInitializer(node.initializer, node.type ? node.type.end : node.questionToken ? node.questionToken.end : node.name ? node.name.end : node.modifiers ? node.modifiers.end : node.decorators ? node.decorators.end : node.pos, node); + emitInitializer(node.initializer, node.type ? node.type.end : node.questionToken ? node.questionToken.end : node.name ? node.name.end : node.modifiers ? node.modifiers.end : node.decorators ? node.decorators.end : node.pos, node, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitDecorator(decorator) { writePunctuation("@"); - emitExpression(decorator.expression); + emitExpression(decorator.expression, parenthesizer.parenthesizeLeftSideOfAccess); } // // Type members @@ -101799,7 +105371,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeKeyword(node.kind === 167 /* GetAccessor */ ? "get" : "set"); + writeKeyword(node.kind === 169 /* GetAccessor */ ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -101913,7 +105485,7 @@ var ts; writePunctuation("}"); } function emitArrayType(node) { - emit(node.elementType); + emit(node.elementType, parenthesizer.parenthesizeElementTypeOfArrayType); writePunctuation("["); writePunctuation("]"); } @@ -101936,21 +105508,21 @@ var ts; emit(node.type); } function emitOptionalType(node) { - emit(node.type); + emit(node.type, parenthesizer.parenthesizeElementTypeOfArrayType); writePunctuation("?"); } function emitUnionType(node) { - emitList(node, node.types, 516 /* UnionTypeConstituents */); + emitList(node, node.types, 516 /* UnionTypeConstituents */, parenthesizer.parenthesizeMemberOfElementType); } function emitIntersectionType(node) { - emitList(node, node.types, 520 /* IntersectionTypeConstituents */); + emitList(node, node.types, 520 /* IntersectionTypeConstituents */, parenthesizer.parenthesizeMemberOfElementType); } function emitConditionalType(node) { - emit(node.checkType); + emit(node.checkType, parenthesizer.parenthesizeMemberOfConditionalType); writeSpace(); writeKeyword("extends"); writeSpace(); - emit(node.extendsType); + emit(node.extendsType, parenthesizer.parenthesizeMemberOfConditionalType); writeSpace(); writePunctuation("?"); writeSpace(); @@ -101976,10 +105548,10 @@ var ts; function emitTypeOperator(node) { writeTokenText(node.operator, writeKeyword); writeSpace(); - emit(node.type); + emit(node.type, parenthesizer.parenthesizeMemberOfElementType); } function emitIndexedAccessType(node) { - emit(node.objectType); + emit(node.objectType, parenthesizer.parenthesizeMemberOfElementType); writePunctuation("["); emit(node.indexType); writePunctuation("]"); @@ -101996,7 +105568,7 @@ var ts; } if (node.readonlyToken) { emit(node.readonlyToken); - if (node.readonlyToken.kind !== 142 /* ReadonlyKeyword */) { + if (node.readonlyToken.kind !== 143 /* ReadonlyKeyword */) { writeKeyword("readonly"); } writeSpace(); @@ -102072,7 +105644,7 @@ var ts; writeSpace(); } emit(node.name); - emitInitializer(node.initializer, node.name.end, node); + emitInitializer(node.initializer, node.name.end, node, parenthesizer.parenthesizeExpressionForDisallowedComma); } // // Expressions @@ -102080,7 +105652,7 @@ var ts; function emitArrayLiteralExpression(node) { var elements = node.elements; var preferNewLine = node.multiLine ? 65536 /* PreferNewLine */ : 0 /* None */; - emitExpressionList(node, elements, 8914 /* ArrayLiteralExpressionElements */ | preferNewLine); + emitExpressionList(node, elements, 8914 /* ArrayLiteralExpressionElements */ | preferNewLine, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitObjectLiteralExpression(node) { ts.forEach(node.properties, generateMemberNames); @@ -102096,13 +105668,13 @@ var ts; } } function emitPropertyAccessExpression(node) { - var expression = ts.cast(emitExpression(node.expression), ts.isExpression); + emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); var token = node.questionDotToken || ts.setTextRangePosEnd(ts.factory.createToken(24 /* 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 */ && - mayNeedDotDotForPropertyAccess(expression) && + mayNeedDotDotForPropertyAccess(node.expression) && !writer.hasTrailingComment() && !writer.hasTrailingWhitespace(); if (shouldEmitDotDot) { @@ -102138,27 +105710,27 @@ var ts; } } function emitElementAccessExpression(node) { - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); emit(node.questionDotToken); emitTokenWithComment(22 /* OpenBracketToken */, node.expression.end, writePunctuation, node); emitExpression(node.argumentExpression); emitTokenWithComment(23 /* CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); } function emitCallExpression(node) { - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); emit(node.questionDotToken); emitTypeArguments(node, node.typeArguments); - emitExpressionList(node, node.arguments, 2576 /* CallExpressionArguments */); + emitExpressionList(node, node.arguments, 2576 /* CallExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitNewExpression(node) { - emitTokenWithComment(102 /* NewKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(103 /* NewKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfNew); emitTypeArguments(node, node.typeArguments); - emitExpressionList(node, node.arguments, 18960 /* NewExpressionArguments */); + emitExpressionList(node, node.arguments, 18960 /* NewExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitTaggedTemplateExpression(node) { - emitExpression(node.tag); + emitExpression(node.tag, parenthesizer.parenthesizeLeftSideOfAccess); emitTypeArguments(node, node.typeArguments); writeSpace(); emitExpression(node.template); @@ -102167,12 +105739,12 @@ var ts; writePunctuation("<"); emit(node.type); writePunctuation(">"); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitParenthesizedExpression(node) { var openParenPos = emitTokenWithComment(20 /* OpenParenToken */, node.pos, writePunctuation, node); var indented = writeLineSeparatorsAndIndentBefore(node.expression, node); - emitExpression(node.expression); + emitExpression(node.expression, /*parenthesizerRules*/ undefined); writeLineSeparatorsAfter(node.expression, node); decreaseIndentIf(indented); emitTokenWithComment(21 /* CloseParenToken */, node.expression ? node.expression.end : openParenPos, writePunctuation, node); @@ -102194,31 +105766,31 @@ var ts; emit(node.equalsGreaterThanToken); } function emitDeleteExpression(node) { - emitTokenWithComment(88 /* DeleteKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(89 /* DeleteKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitTypeOfExpression(node) { - emitTokenWithComment(111 /* TypeOfKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(112 /* TypeOfKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitVoidExpression(node) { - emitTokenWithComment(113 /* VoidKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(114 /* VoidKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitAwaitExpression(node) { - emitTokenWithComment(130 /* AwaitKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(131 /* AwaitKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitPrefixUnaryExpression(node) { writeTokenText(node.operator, writeOperator); if (shouldEmitWhitespaceBeforeOperand(node)) { writeSpace(); } - emitExpression(node.operand); + emitExpression(node.operand, parenthesizer.parenthesizeOperandOfPrefixUnary); } function shouldEmitWhitespaceBeforeOperand(node) { // In some cases, we need to emit a space between the operator and the operand. One obvious case @@ -102234,84 +105806,101 @@ 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 === 214 /* PrefixUnaryExpression */ + return operand.kind === 216 /* 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 */))); } function emitPostfixUnaryExpression(node) { - emitExpression(node.operand); + emitExpression(node.operand, parenthesizer.parenthesizeOperandOfPostfixUnary); writeTokenText(node.operator, writeOperator); } - var EmitBinaryExpressionState; - (function (EmitBinaryExpressionState) { - EmitBinaryExpressionState[EmitBinaryExpressionState["EmitLeft"] = 0] = "EmitLeft"; - EmitBinaryExpressionState[EmitBinaryExpressionState["EmitRight"] = 1] = "EmitRight"; - EmitBinaryExpressionState[EmitBinaryExpressionState["FinishEmit"] = 2] = "FinishEmit"; - })(EmitBinaryExpressionState || (EmitBinaryExpressionState = {})); - /** - * emitBinaryExpression includes an embedded work stack to attempt to handle as many nested binary expressions - * as possible without creating any additional stack frames. This can only be done when the emit pipeline does - * not require notification/substitution/comment/sourcemap decorations. - */ - function emitBinaryExpression(node) { - var nodeStack = [node]; - var stateStack = [0 /* EmitLeft */]; - var stackIndex = 0; - while (stackIndex >= 0) { - node = nodeStack[stackIndex]; - switch (stateStack[stackIndex]) { - case 0 /* EmitLeft */: { - maybePipelineEmitExpression(node.left); - break; - } - case 1 /* EmitRight */: { - var isCommaOperator = node.operatorToken.kind !== 27 /* CommaToken */; - var linesBeforeOperator = getLinesBetweenNodes(node, node.left, node.operatorToken); - var linesAfterOperator = getLinesBetweenNodes(node, node.operatorToken, node.right); - writeLinesAndIndent(linesBeforeOperator, isCommaOperator); - emitLeadingCommentsOfPosition(node.operatorToken.pos); - writeTokenNode(node.operatorToken, node.operatorToken.kind === 100 /* InKeyword */ ? writeKeyword : writeOperator); - emitTrailingCommentsOfPosition(node.operatorToken.end, /*prefixSpace*/ true); // Binary operators should have a space before the comment starts - writeLinesAndIndent(linesAfterOperator, /*writeSpaceIfNotIndenting*/ true); - maybePipelineEmitExpression(node.right); - break; - } - case 2 /* FinishEmit */: { - var linesBeforeOperator = getLinesBetweenNodes(node, node.left, node.operatorToken); - var linesAfterOperator = getLinesBetweenNodes(node, node.operatorToken, node.right); - decreaseIndentIf(linesBeforeOperator, linesAfterOperator); - stackIndex--; - break; - } - default: return ts.Debug.fail("Invalid state " + stateStack[stackIndex] + " for emitBinaryExpressionWorker"); + function createEmitBinaryExpression() { + return ts.createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, /*foldState*/ undefined); + function onEnter(node, state) { + if (state) { + state.stackIndex++; + state.preserveSourceNewlinesStack[state.stackIndex] = preserveSourceNewlines; + state.containerPosStack[state.stackIndex] = containerPos; + state.containerEndStack[state.stackIndex] = containerEnd; + state.declarationListContainerEndStack[state.stackIndex] = declarationListContainerEnd; + var emitComments_1 = state.shouldEmitCommentsStack[state.stackIndex] = shouldEmitComments(node); + var emitSourceMaps = state.shouldEmitSourceMapsStack[state.stackIndex] = shouldEmitSourceMaps(node); + onBeforeEmitNode === null || onBeforeEmitNode === void 0 ? void 0 : onBeforeEmitNode(node); + if (emitComments_1) + emitCommentsBeforeNode(node); + if (emitSourceMaps) + emitSourceMapsBeforeNode(node); + beforeEmitNode(node); } - } - function maybePipelineEmitExpression(next) { - // Advance the state of this unit of work, - stateStack[stackIndex]++; - // Then actually do the work of emitting the node `next` returned by the prior state - // The following section should be identical to `pipelineEmit` save it assumes EmitHint.Expression and offloads - // binary expression handling, where possible, to the contained work queue - // #region trampolinePipelineEmit - var savedLastNode = lastNode; - var savedLastSubstitution = lastSubstitution; - lastNode = next; - lastSubstitution = undefined; + else { + state = { + stackIndex: 0, + preserveSourceNewlinesStack: [undefined], + containerPosStack: [-1], + containerEndStack: [-1], + declarationListContainerEndStack: [-1], + shouldEmitCommentsStack: [false], + shouldEmitSourceMapsStack: [false], + }; + } + return state; + } + function onLeft(next, _workArea, parent) { + return maybeEmitExpression(next, parent, "left"); + } + function onOperator(operatorToken, _state, node) { + var isCommaOperator = operatorToken.kind !== 27 /* 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); + emitTrailingCommentsOfPosition(operatorToken.end, /*prefixSpace*/ true); // Binary operators should have a space before the comment starts + writeLinesAndIndent(linesAfterOperator, /*writeSpaceIfNotIndenting*/ true); + } + function onRight(next, _workArea, parent) { + return maybeEmitExpression(next, parent, "right"); + } + function onExit(node, state) { + var linesBeforeOperator = getLinesBetweenNodes(node, node.left, node.operatorToken); + var linesAfterOperator = getLinesBetweenNodes(node, node.operatorToken, node.right); + decreaseIndentIf(linesBeforeOperator, linesAfterOperator); + if (state.stackIndex > 0) { + var savedPreserveSourceNewlines = state.preserveSourceNewlinesStack[state.stackIndex]; + var savedContainerPos = state.containerPosStack[state.stackIndex]; + var savedContainerEnd = state.containerEndStack[state.stackIndex]; + var savedDeclarationListContainerEnd = state.declarationListContainerEndStack[state.stackIndex]; + var shouldEmitComments_1 = state.shouldEmitCommentsStack[state.stackIndex]; + var shouldEmitSourceMaps_1 = state.shouldEmitSourceMapsStack[state.stackIndex]; + afterEmitNode(savedPreserveSourceNewlines); + if (shouldEmitSourceMaps_1) + emitSourceMapsAfterNode(node); + if (shouldEmitComments_1) + emitCommentsAfterNode(node, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd); + onAfterEmitNode === null || onAfterEmitNode === void 0 ? void 0 : onAfterEmitNode(node); + state.stackIndex--; + } + } + function maybeEmitExpression(next, parent, side) { + var parenthesizerRule = side === "left" ? + parenthesizer.getParenthesizeLeftSideOfBinaryForOperator(parent.operatorToken.kind) : + parenthesizer.getParenthesizeRightSideOfBinaryForOperator(parent.operatorToken.kind); var pipelinePhase = getPipelinePhase(0 /* Notification */, 1 /* Expression */, next); - if (pipelinePhase === pipelineEmitWithHint && ts.isBinaryExpression(next)) { - // If the target pipeline phase is emit directly, and the next node's also a binary expression, - // skip all the intermediate indirection and push the expression directly onto the work stack - stackIndex++; - stateStack[stackIndex] = 0 /* EmitLeft */; - nodeStack[stackIndex] = next; + if (pipelinePhase === pipelineEmitWithSubstitution) { + ts.Debug.assertIsDefined(lastSubstitution); + next = parenthesizerRule(ts.cast(lastSubstitution, ts.isExpression)); + pipelinePhase = getNextPipelinePhase(1 /* Substitution */, 1 /* Expression */, next); + lastSubstitution = undefined; } - else { - pipelinePhase(1 /* Expression */, next); + if (pipelinePhase === pipelineEmitWithComments || + pipelinePhase === pipelineEmitWithSourceMaps || + pipelinePhase === pipelineEmitWithHint) { + if (ts.isBinaryExpression(next)) { + return next; + } } - ts.Debug.assert(lastNode === next); - lastNode = savedLastNode; - lastSubstitution = savedLastSubstitution; - // #endregion trampolinePipelineEmit + currentParenthesizerRule = parenthesizerRule; + pipelinePhase(1 /* Expression */, next); } } function emitConditionalExpression(node) { @@ -102319,16 +105908,16 @@ var ts; var linesAfterQuestion = getLinesBetweenNodes(node, node.questionToken, node.whenTrue); var linesBeforeColon = getLinesBetweenNodes(node, node.whenTrue, node.colonToken); var linesAfterColon = getLinesBetweenNodes(node, node.colonToken, node.whenFalse); - emitExpression(node.condition); + emitExpression(node.condition, parenthesizer.parenthesizeConditionOfConditionalExpression); writeLinesAndIndent(linesBeforeQuestion, /*writeSpaceIfNotIndenting*/ true); emit(node.questionToken); writeLinesAndIndent(linesAfterQuestion, /*writeSpaceIfNotIndenting*/ true); - emitExpression(node.whenTrue); + emitExpression(node.whenTrue, parenthesizer.parenthesizeBranchOfConditionalExpression); decreaseIndentIf(linesBeforeQuestion, linesAfterQuestion); writeLinesAndIndent(linesBeforeColon, /*writeSpaceIfNotIndenting*/ true); emit(node.colonToken); writeLinesAndIndent(linesAfterColon, /*writeSpaceIfNotIndenting*/ true); - emitExpression(node.whenFalse); + emitExpression(node.whenFalse, parenthesizer.parenthesizeBranchOfConditionalExpression); decreaseIndentIf(linesBeforeColon, linesAfterColon); } function emitTemplateExpression(node) { @@ -102336,24 +105925,24 @@ var ts; emitList(node, node.templateSpans, 262144 /* TemplateExpressionSpans */); } function emitYieldExpression(node) { - emitTokenWithComment(124 /* YieldKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(125 /* YieldKeyword */, node.pos, writeKeyword, node); emit(node.asteriskToken); - emitExpressionWithLeadingSpace(node.expression); + emitExpressionWithLeadingSpace(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); } - function emitSpreadExpression(node) { + function emitSpreadElement(node) { emitTokenWithComment(25 /* DotDotDotToken */, node.pos, writePunctuation, node); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitClassExpression(node) { generateNameIfNeeded(node.name); emitClassDeclarationOrExpression(node); } function emitExpressionWithTypeArguments(node) { - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); emitTypeArguments(node, node.typeArguments); } function emitAsExpression(node) { - emitExpression(node.expression); + emitExpression(node.expression, /*parenthesizerRules*/ undefined); if (node.type) { writeSpace(); writeKeyword("as"); @@ -102362,7 +105951,7 @@ var ts; } } function emitNonNullExpression(node) { - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); writeOperator("!"); } function emitMetaProperty(node) { @@ -102405,7 +105994,7 @@ var ts; } } function emitExpressionStatement(node) { - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfExpressionStatement); // Emit semicolon in non json files // or if json file that created synthesized expression(eg.define expression statement when --out and amd code generation) if (!ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) { @@ -102413,7 +106002,7 @@ var ts; } } function emitIfStatement(node) { - var openParenPos = emitTokenWithComment(98 /* IfKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(99 /* IfKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -102421,8 +106010,8 @@ var ts; emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { writeLineOrSpace(node, node.thenStatement, node.elseStatement); - emitTokenWithComment(90 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 234 /* IfStatement */) { + emitTokenWithComment(91 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); + if (node.elseStatement.kind === 236 /* IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -102432,14 +106021,14 @@ var ts; } } function emitWhileClause(node, startPos) { - var openParenPos = emitTokenWithComment(114 /* WhileKeyword */, startPos, writeKeyword, node); + var openParenPos = emitTokenWithComment(115 /* WhileKeyword */, startPos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); } function emitDoStatement(node) { - emitTokenWithComment(89 /* DoKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(90 /* DoKeyword */, node.pos, writeKeyword, node); emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement) && !preserveSourceNewlines) { writeSpace(); @@ -102455,7 +106044,7 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { - var openParenPos = emitTokenWithComment(96 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); var pos = emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node); emitForBinding(node.initializer); @@ -102467,25 +106056,25 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { - var openParenPos = emitTokenWithComment(96 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(100 /* InKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(101 /* InKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { - var openParenPos = emitTokenWithComment(96 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitWithTrailingSpace(node.awaitModifier); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(156 /* OfKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(158 /* OfKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); @@ -102493,7 +106082,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 250 /* VariableDeclarationList */) { + if (node.kind === 252 /* VariableDeclarationList */) { emit(node); } else { @@ -102502,12 +106091,12 @@ var ts; } } function emitContinueStatement(node) { - emitTokenWithComment(85 /* ContinueKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(86 /* ContinueKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } function emitBreakStatement(node) { - emitTokenWithComment(80 /* BreakKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(81 /* BreakKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } @@ -102530,18 +106119,18 @@ var ts; } pos = writeTokenText(token, writer, pos); if (isSimilarNode && contextNode.end !== pos) { - var isJsxExprContext = contextNode.kind === 283 /* JsxExpression */; + var isJsxExprContext = contextNode.kind === 285 /* JsxExpression */; emitTrailingCommentsOfPosition(pos, /*prefixSpace*/ !isJsxExprContext, /*forceNoNewline*/ isJsxExprContext); } return pos; } function emitReturnStatement(node) { - emitTokenWithComment(104 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); + emitTokenWithComment(105 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); emitExpressionWithLeadingSpace(node.expression); writeTrailingSemicolon(); } function emitWithStatement(node) { - var openParenPos = emitTokenWithComment(115 /* WithKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(116 /* WithKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -102549,7 +106138,7 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { - var openParenPos = emitTokenWithComment(106 /* SwitchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(107 /* SwitchKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -102564,12 +106153,12 @@ var ts; emit(node.statement); } function emitThrowStatement(node) { - emitTokenWithComment(108 /* ThrowKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(109 /* ThrowKeyword */, node.pos, writeKeyword, node); emitExpressionWithLeadingSpace(node.expression); writeTrailingSemicolon(); } function emitTryStatement(node) { - emitTokenWithComment(110 /* TryKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(111 /* TryKeyword */, node.pos, writeKeyword, node); writeSpace(); emit(node.tryBlock); if (node.catchClause) { @@ -102578,13 +106167,13 @@ var ts; } if (node.finallyBlock) { writeLineOrSpace(node, node.catchClause || node.tryBlock, node.finallyBlock); - emitTokenWithComment(95 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); + emitTokenWithComment(96 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); writeSpace(); emit(node.finallyBlock); } } function emitDebuggerStatement(node) { - writeToken(86 /* DebuggerKeyword */, node.pos, writeKeyword); + writeToken(87 /* DebuggerKeyword */, node.pos, writeKeyword); writeTrailingSemicolon(); } // @@ -102594,7 +106183,7 @@ var ts; emit(node.name); emit(node.exclamationToken); emitTypeAnnotation(node.type); - emitInitializer(node.initializer, node.type ? node.type.end : node.name.end, node); + emitInitializer(node.initializer, node.type ? node.type.end : node.name.end, node, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitVariableDeclarationList(node) { writeKeyword(ts.isLet(node) ? "let" : ts.isVarConst(node) ? "const" : "var"); @@ -102613,9 +106202,6 @@ var ts; emitIdentifierName(node.name); emitSignatureAndBody(node, emitSignatureHead); } - function emitBlockCallback(_hint, body) { - emitBlockFunctionBody(body); - } function emitSignatureAndBody(node, emitSignatureHead) { var body = node.body; if (body) { @@ -102628,12 +106214,7 @@ var ts; ts.forEach(node.parameters, generateNames); generateNames(node.body); emitSignatureHead(node); - if (onEmitNode) { - onEmitNode(4 /* Unspecified */, body, emitBlockCallback); - } - else { - emitBlockFunctionBody(body); - } + emitBlockFunctionBody(body); popNameGenerationScope(node); if (indentedFlag) { decreaseIndent(); @@ -102642,7 +106223,7 @@ var ts; else { emitSignatureHead(node); writeSpace(); - emitExpression(body); + emitExpression(body, parenthesizer.parenthesizeConciseBodyOfArrowFunction); } } else { @@ -102686,6 +106267,7 @@ var ts; return true; } function emitBlockFunctionBody(body) { + onBeforeEmitNode === null || onBeforeEmitNode === void 0 ? void 0 : onBeforeEmitNode(body); writeSpace(); writePunctuation("{"); increaseIndent(); @@ -102700,6 +106282,7 @@ var ts; } decreaseIndent(); writeToken(19 /* CloseBraceToken */, body.statements.end, writePunctuation, body); + onAfterEmitNode === null || onAfterEmitNode === void 0 ? void 0 : onAfterEmitNode(body); } function emitBlockFunctionBodyOnSingleLine(body) { emitBlockFunctionBodyWorker(body, /*emitBlockFunctionBodyOnSingleLine*/ true); @@ -102715,7 +106298,7 @@ var ts; increaseIndent(); } else { - emitList(body, body.statements, 1 /* MultiLineFunctionBodyStatements */, statementOffset); + emitList(body, body.statements, 1 /* MultiLineFunctionBodyStatements */, /*parenthesizerRule*/ undefined, statementOffset); } } function emitClassDeclaration(node) { @@ -102790,7 +106373,7 @@ var ts; var body = node.body; if (!body) return writeTrailingSemicolon(); - while (body.kind === 256 /* ModuleDeclaration */) { + while (body && ts.isModuleDeclaration(body)) { writePunctuation("."); emit(body.name); body = body.body; @@ -102811,21 +106394,21 @@ var ts; } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(99 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(100 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.isTypeOnly) { - emitTokenWithComment(149 /* TypeKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(150 /* TypeKeyword */, node.pos, writeKeyword, node); writeSpace(); } emit(node.name); writeSpace(); - emitTokenWithComment(62 /* EqualsToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(63 /* EqualsToken */, node.name.end, writePunctuation, node); writeSpace(); emitModuleReference(node.moduleReference); writeTrailingSemicolon(); } function emitModuleReference(node) { - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { emitExpression(node); } else { @@ -102834,12 +106417,12 @@ var ts; } function emitImportDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(99 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(100 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.importClause) { emit(node.importClause); writeSpace(); - emitTokenWithComment(153 /* FromKeyword */, node.importClause.end, writeKeyword, node); + emitTokenWithComment(154 /* FromKeyword */, node.importClause.end, writeKeyword, node); writeSpace(); } emitExpression(node.moduleSpecifier); @@ -102847,7 +106430,7 @@ var ts; } function emitImportClause(node) { if (node.isTypeOnly) { - emitTokenWithComment(149 /* TypeKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(150 /* TypeKeyword */, node.pos, writeKeyword, node); writeSpace(); } emit(node.name); @@ -102860,7 +106443,7 @@ var ts; function emitNamespaceImport(node) { var asPos = emitTokenWithComment(41 /* AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(126 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(127 /* AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -102871,23 +106454,25 @@ var ts; emitImportOrExportSpecifier(node); } function emitExportAssignment(node) { - var nextPos = emitTokenWithComment(92 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isExportEquals) { - emitTokenWithComment(62 /* EqualsToken */, nextPos, writeOperator, node); + emitTokenWithComment(63 /* EqualsToken */, nextPos, writeOperator, node); } else { - emitTokenWithComment(87 /* DefaultKeyword */, nextPos, writeKeyword, node); + emitTokenWithComment(88 /* DefaultKeyword */, nextPos, writeKeyword, node); } writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, node.isExportEquals ? + parenthesizer.getParenthesizeRightSideOfBinaryForOperator(63 /* EqualsToken */) : + parenthesizer.parenthesizeExpressionOfExportDefault); writeTrailingSemicolon(); } function emitExportDeclaration(node) { - var nextPos = emitTokenWithComment(92 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isTypeOnly) { - nextPos = emitTokenWithComment(149 /* TypeKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(150 /* TypeKeyword */, nextPos, writeKeyword, node); writeSpace(); } if (node.exportClause) { @@ -102899,18 +106484,18 @@ var ts; if (node.moduleSpecifier) { writeSpace(); var fromPos = node.exportClause ? node.exportClause.end : nextPos; - emitTokenWithComment(153 /* FromKeyword */, fromPos, writeKeyword, node); + emitTokenWithComment(154 /* FromKeyword */, fromPos, writeKeyword, node); writeSpace(); emitExpression(node.moduleSpecifier); } writeTrailingSemicolon(); } function emitNamespaceExportDeclaration(node) { - var nextPos = emitTokenWithComment(92 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(126 /* AsKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(127 /* AsKeyword */, nextPos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(140 /* NamespaceKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(141 /* NamespaceKeyword */, nextPos, writeKeyword, node); writeSpace(); emit(node.name); writeTrailingSemicolon(); @@ -102918,7 +106503,7 @@ var ts; function emitNamespaceExport(node) { var asPos = emitTokenWithComment(41 /* AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(126 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(127 /* AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -102937,7 +106522,7 @@ var ts; if (node.propertyName) { emit(node.propertyName); writeSpace(); - emitTokenWithComment(126 /* AsKeyword */, node.propertyName.end, writeKeyword, node); + emitTokenWithComment(127 /* AsKeyword */, node.propertyName.end, writeKeyword, node); writeSpace(); } emit(node.name); @@ -103039,7 +106624,7 @@ var ts; } } function emitJsxTagName(node) { - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { emitExpression(node); } else { @@ -103050,13 +106635,13 @@ var ts; // Clauses // function emitCaseClause(node) { - emitTokenWithComment(81 /* CaseKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(82 /* CaseKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); emitCaseOrDefaultClauseRest(node, node.statements, node.expression.end); } function emitDefaultClause(node) { - var pos = emitTokenWithComment(87 /* DefaultKeyword */, node.pos, writeKeyword, node); + var pos = emitTokenWithComment(88 /* DefaultKeyword */, node.pos, writeKeyword, node); emitCaseOrDefaultClauseRest(node, node.statements, pos); } function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) { @@ -103084,7 +106669,7 @@ var ts; emitList(node, node.types, 528 /* HeritageClauseTypes */); } function emitCatchClause(node) { - var openParenPos = emitTokenWithComment(82 /* CatchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(83 /* CatchKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.variableDeclaration) { emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); @@ -103113,7 +106698,7 @@ var ts; var commentRange = ts.getCommentRange(initializer); emitTrailingCommentsOfPosition(commentRange.pos); } - emitExpression(initializer); + emitExpression(initializer, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitShorthandPropertyAssignment(node) { emit(node.name); @@ -103121,13 +106706,13 @@ var ts; writeSpace(); writePunctuation("="); writeSpace(); - emitExpression(node.objectAssignmentInitializer); + emitExpression(node.objectAssignmentInitializer, parenthesizer.parenthesizeExpressionForDisallowedComma); } } function emitSpreadAssignment(node) { if (node.expression) { emitTokenWithComment(25 /* DotDotDotToken */, node.pos, writePunctuation, node); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); } } // @@ -103135,7 +106720,7 @@ var ts; // function emitEnumMember(node) { emit(node.name); - emitInitializer(node.initializer, node.name.end, node); + emitInitializer(node.initializer, node.name.end, node, parenthesizer.parenthesizeExpressionForDisallowedComma); } // // JSDoc @@ -103143,18 +106728,21 @@ var ts; function emitJSDoc(node) { write("/**"); if (node.comment) { - var lines = node.comment.split(/\r\n?|\n/g); - for (var _a = 0, lines_2 = lines; _a < lines_2.length; _a++) { - var line = lines_2[_a]; - writeLine(); - writeSpace(); - writePunctuation("*"); - writeSpace(); - write(line); + var text = ts.getTextOfJSDocComment(node.comment); + if (text) { + var lines = text.split(/\r\n?|\n/g); + for (var _a = 0, lines_2 = lines; _a < lines_2.length; _a++) { + var line = lines_2[_a]; + writeLine(); + writeSpace(); + writePunctuation("*"); + writeSpace(); + write(line); + } } } if (node.tags) { - if (node.tags.length === 1 && node.tags[0].kind === 329 /* JSDocTypeTag */ && !node.comment) { + if (node.tags.length === 1 && node.tags[0].kind === 337 /* JSDocTypeTag */ && !node.comment) { writeSpace(); emit(node.tags[0]); } @@ -103199,7 +106787,7 @@ var ts; function emitJSDocTypedefTag(tag) { emitJSDocTagName(tag.tagName); if (tag.typeExpression) { - if (tag.typeExpression.kind === 301 /* JSDocTypeExpression */) { + if (tag.typeExpression.kind === 303 /* JSDocTypeExpression */) { emitJSDocTypeExpression(tag.typeExpression); } else { @@ -103218,7 +106806,7 @@ var ts; emit(tag.fullName); } emitJSDocComment(tag.comment); - if (tag.typeExpression && tag.typeExpression.kind === 312 /* JSDocTypeLiteral */) { + if (tag.typeExpression && tag.typeExpression.kind === 316 /* JSDocTypeLiteral */) { emitJSDocTypeLiteral(tag.typeExpression); } } @@ -103271,9 +106859,10 @@ var ts; emit(tagName); } function emitJSDocComment(comment) { - if (comment) { + var text = ts.getTextOfJSDocComment(comment); + if (text) { writeSpace(); - write(comment); + write(text); } } function emitJSDocTypeExpression(typeExpression) { @@ -103376,7 +106965,7 @@ var ts; emitHelpers(node); var index = ts.findIndex(statements, function (statement) { return !ts.isPrologueDirective(statement); }); emitTripleSlashDirectivesIfNeeded(node); - emitList(node, statements, 1 /* MultiLine */, index === -1 ? statements.length : index); + emitList(node, statements, 1 /* MultiLine */, /*parenthesizerRule*/ undefined, index === -1 ? statements.length : index); popNameGenerationScope(node); } // Transformation nodes @@ -103384,7 +106973,7 @@ var ts; emitExpression(node.expression); } function emitCommaList(node) { - emitExpressionList(node, node.elements, 528 /* CommaListElements */); + emitExpressionList(node, node.elements, 528 /* CommaListElements */, /*parenthesizerRule*/ undefined); } /** * Emits any prologue directives at the start of a Statement list, returning the @@ -103530,12 +107119,12 @@ var ts; emit(node); } } - function emitInitializer(node, equalCommentStartPos, container) { + function emitInitializer(node, equalCommentStartPos, container, parenthesizerRule) { if (node) { writeSpace(); - emitTokenWithComment(62 /* EqualsToken */, equalCommentStartPos, writeOperator, container); + emitTokenWithComment(63 /* EqualsToken */, equalCommentStartPos, writeOperator, container); writeSpace(); - emitExpression(node); + emitExpression(node, parenthesizerRule); } } function emitNodeWithPrefix(prefix, prefixWriter, node, emit) { @@ -103550,10 +107139,10 @@ var ts; emit(node); } } - function emitExpressionWithLeadingSpace(node) { + function emitExpressionWithLeadingSpace(node, parenthesizerRule) { if (node) { writeSpace(); - emitExpression(node); + emitExpression(node, parenthesizerRule); } } function emitWithTrailingSpace(node) { @@ -103583,7 +107172,7 @@ var ts; emitList(parentNode, decorators, 2146305 /* Decorators */); } function emitTypeArguments(parentNode, typeArguments) { - emitList(parentNode, typeArguments, 53776 /* TypeArguments */); + emitList(parentNode, typeArguments, 53776 /* TypeArguments */, parenthesizer.parenthesizeMemberOfElementType); } function emitTypeParameters(parentNode, typeParameters) { if (ts.isFunctionLike(parentNode) && parentNode.typeArguments) { // Quick info uses type arguments in place of type parameters on instantiated signatures @@ -103622,12 +107211,6 @@ var ts; function emitParametersForIndexSignature(parentNode, parameters) { emitList(parentNode, parameters, 8848 /* IndexSignatureParameters */); } - function emitList(parentNode, children, format, start, count) { - emitNodeList(emit, parentNode, children, format, start, count); - } - function emitExpressionList(parentNode, children, format, start, count) { - emitNodeList(emitExpression, parentNode, children, format, start, count); // TODO: GH#18217 - } function writeDelimiter(format) { switch (format & 60 /* DelimitersMask */) { case 0 /* None */: @@ -103650,7 +107233,13 @@ var ts; break; } } - function emitNodeList(emit, parentNode, children, format, start, count) { + function emitList(parentNode, children, format, parenthesizerRule, start, count) { + emitNodeList(emit, parentNode, children, format, parenthesizerRule, start, count); + } + function emitExpressionList(parentNode, children, format, parenthesizerRule, start, count) { + emitNodeList(emitExpression, parentNode, children, format, parenthesizerRule, start, count); + } + function emitNodeList(emit, parentNode, children, format, parenthesizerRule, start, count) { if (start === void 0) { start = 0; } if (count === void 0) { count = children ? children.length - start : 0; } var isUndefined = children === undefined; @@ -103669,8 +107258,7 @@ var ts; } if (format & 15360 /* BracketsMask */) { writePunctuation(getOpeningBracket(format)); - if (isEmpty && !isUndefined) { - // TODO: GH#18217 + if (isEmpty && children) { emitTrailingCommentsOfPosition(children.pos, /*prefixSpace*/ true); // Emit comments within empty bracketed lists } } @@ -103679,7 +107267,7 @@ var ts; } if (isEmpty) { // Write a line terminator if the parent node was multi-line - if (format & 1 /* MultiLine */ && !(preserveSourceNewlines && ts.rangeIsOnSingleLine(parentNode, currentSourceFile))) { + if (format & 1 /* MultiLine */ && !(preserveSourceNewlines && (!parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) { writeLine(); } else if (format & 256 /* SpaceBetweenBraces */ && !(format & 524288 /* NoSpaceIfEmpty */)) { @@ -103687,6 +107275,7 @@ var ts; } } else { + ts.Debug.type(children); // Write the opening line terminator or leading whitespace. var mayEmitInterveningComments = (format & 262144 /* NoInterveningComments */) === 0; var shouldEmitInterveningComments = mayEmitInterveningComments; @@ -103721,7 +107310,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.end) { + if (format & 60 /* DelimitersMask */ && previousSibling.end !== (parentNode ? parentNode.end : -1)) { emitLeadingCommentsOfPosition(previousSibling.end); } writeDelimiter(format); @@ -103754,7 +107343,12 @@ var ts; shouldEmitInterveningComments = mayEmitInterveningComments; } nextListElementPos = child.pos; - emit(child); + if (emit.length === 1) { + emit(child); + } + else { + emit(child, parenthesizerRule); + } if (shouldDecreaseIndentAfterEmit) { decreaseIndent(); shouldDecreaseIndentAfterEmit = false; @@ -103779,7 +107373,7 @@ var ts; // 2 // /* end of element 2 */ // ]; - if (previousSibling && parentNode.end !== previousSibling.end && (format & 60 /* DelimitersMask */) && !skipTrailingComments) { + if (previousSibling && (parentNode ? parentNode.end : -1) !== previousSibling.end && (format & 60 /* DelimitersMask */) && !skipTrailingComments) { emitLeadingCommentsOfPosition(hasTrailingComma && (children === null || children === void 0 ? void 0 : children.end) ? children.end : previousSibling.end); } // Decrease the indent, if requested. @@ -103800,8 +107394,7 @@ var ts; onAfterEmitNodeArray(children); } if (format & 15360 /* BracketsMask */) { - if (isEmpty && !isUndefined) { - // TODO: GH#18217 + if (isEmpty && children) { emitLeadingCommentsOfPosition(children.end); // Emit leading comments within empty lists } writePunctuation(getClosingBracket(format)); @@ -103932,7 +107525,7 @@ var ts; } var firstChild_1 = children[0]; if (firstChild_1 === undefined) { - return ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; + return !parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; } if (firstChild_1.pos === nextListElementPos) { // If this child starts at the beginning of a list item in a parent list, its leading @@ -103956,7 +107549,8 @@ var ts; // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } - if (!ts.positionIsSynthesized(parentNode.pos) && + if (parentNode && + !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(firstChild_1) && (!firstChild_1.parent || ts.getOriginalNode(firstChild_1.parent) === ts.getOriginalNode(parentNode))) { if (preserveSourceNewlines) { @@ -103979,10 +107573,10 @@ var ts; // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } - else if (!ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode) && previousNode.parent === nextNode.parent) { - if (preserveSourceNewlines) { - return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); - } + else if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) { + return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); + } + else if (!preserveSourceNewlines && !ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) { return ts.rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile) ? 0 : 1; } else if (synthesizedNodeStartsOnNewLine(previousNode, format) || synthesizedNodeStartsOnNewLine(nextNode, format)) { @@ -104001,9 +107595,9 @@ var ts; } var lastChild = ts.lastOrUndefined(children); if (lastChild === undefined) { - return ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; + return !parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; } - if (!ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) { + if (parentNode && !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) { if (preserveSourceNewlines) { var end_1 = ts.isNodeArray(children) && !ts.positionIsSynthesized(children.end) ? children.end : lastChild.end; return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenPositionAndNextNonWhitespaceCharacter(end_1, parentNode.end, currentSourceFile, includeComments); }); @@ -104089,7 +107683,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 207 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 209 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -104159,84 +107753,84 @@ var ts; if (!node) return; switch (node.kind) { - case 230 /* Block */: + case 232 /* Block */: ts.forEach(node.statements, generateNames); break; - case 245 /* LabeledStatement */: - case 243 /* WithStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: + case 247 /* LabeledStatement */: + case 245 /* WithStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: generateNames(node.statement); break; - case 234 /* IfStatement */: + case 236 /* IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 237 /* ForStatement */: - case 239 /* ForOfStatement */: - case 238 /* ForInStatement */: + case 239 /* ForStatement */: + case 241 /* ForOfStatement */: + case 240 /* ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: generateNames(node.caseBlock); break; - case 258 /* CaseBlock */: + case 260 /* CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 284 /* CaseClause */: - case 285 /* DefaultClause */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 247 /* TryStatement */: + case 249 /* TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 287 /* CatchClause */: + case 289 /* CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: generateNames(node.declarationList); break; - case 250 /* VariableDeclarationList */: + case 252 /* VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 249 /* VariableDeclaration */: - case 160 /* Parameter */: - case 198 /* BindingElement */: - case 252 /* ClassDeclaration */: + case 251 /* VariableDeclaration */: + case 162 /* Parameter */: + case 200 /* BindingElement */: + case 254 /* ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 196 /* ObjectBindingPattern */: - case 197 /* ArrayBindingPattern */: + case 198 /* ObjectBindingPattern */: + case 199 /* ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: generateNames(node.importClause); break; - case 262 /* ImportClause */: + case 264 /* ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: generateNameIfNeeded(node.name); break; - case 269 /* NamespaceExport */: + case 271 /* NamespaceExport */: generateNameIfNeeded(node.name); break; - case 264 /* NamedImports */: + case 266 /* NamedImports */: ts.forEach(node.elements, generateNames); break; - case 265 /* ImportSpecifier */: + case 267 /* ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -104245,12 +107839,12 @@ var ts; if (!node) return; switch (node.kind) { - case 288 /* PropertyAssignment */: - case 289 /* ShorthandPropertyAssignment */: - case 163 /* PropertyDeclaration */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 290 /* PropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: + case 165 /* PropertyDeclaration */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: generateNameIfNeeded(node.name); break; } @@ -104430,25 +108024,25 @@ var ts; */ function generateNameForNode(node, flags) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 256 /* ModuleDeclaration */: - case 255 /* EnumDeclaration */: + case 258 /* ModuleDeclaration */: + case 257 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 261 /* ImportDeclaration */: - case 267 /* ExportDeclaration */: + case 263 /* ImportDeclaration */: + case 269 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 251 /* FunctionDeclaration */: - case 252 /* ClassDeclaration */: - case 266 /* ExportAssignment */: + case 253 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: + case 268 /* ExportAssignment */: return generateNameForExportDefault(); - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: return generateNameForClassExpression(); - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return generateNameForMethodOrAccessor(node); - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return makeTempVariableName(0 /* Auto */, /*reserveInNestedScopes*/ true); default: return makeTempVariableName(0 /* Auto */); @@ -104491,25 +108085,45 @@ var ts; } // Comments function pipelineEmitWithComments(hint, node) { - ts.Debug.assert(lastNode === node || lastSubstitution === node); + var pipelinePhase = getNextPipelinePhase(2 /* Comments */, hint, node); + var savedContainerPos = containerPos; + var savedContainerEnd = containerEnd; + var savedDeclarationListContainerEnd = declarationListContainerEnd; + emitCommentsBeforeNode(node); + pipelinePhase(hint, node); + emitCommentsAfterNode(node, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd); + } + function emitCommentsBeforeNode(node) { + var emitFlags = ts.getEmitFlags(node); + var commentRange = ts.getCommentRange(node); + // Emit leading comments + emitLeadingCommentsOfNode(node, emitFlags, commentRange.pos, commentRange.end); + if (emitFlags & 2048 /* NoNestedComments */) { + commentsDisabled = true; + } + } + function emitCommentsAfterNode(node, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd) { + var emitFlags = ts.getEmitFlags(node); + var commentRange = ts.getCommentRange(node); + // Emit trailing comments + if (emitFlags & 2048 /* NoNestedComments */) { + commentsDisabled = false; + } + emitTrailingCommentsOfNode(node, emitFlags, commentRange.pos, commentRange.end, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd); + } + function emitLeadingCommentsOfNode(node, emitFlags, pos, end) { enterComment(); hasWrittenComment = false; - var emitFlags = ts.getEmitFlags(node); - var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; - var isEmittedNode = node.kind !== 335 /* NotEmittedStatement */; // 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 */; // Save current container state on the stack. - var savedContainerPos = containerPos; - var savedContainerEnd = containerEnd; - var savedDeclarationListContainerEnd = declarationListContainerEnd; 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); + emitLeadingComments(pos, /*isEmittedNode*/ node.kind !== 343 /* NotEmittedStatement */); } if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512 /* NoLeadingComments */) !== 0)) { // Advance the container position if comments get emitted or if they've been disabled explicitly using NoLeadingComments. @@ -104520,23 +108134,17 @@ var ts; 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 === 250 /* VariableDeclarationList */) { + if (node.kind === 252 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } } ts.forEach(ts.getSyntheticLeadingComments(node), emitLeadingSynthesizedComment); exitComment(); - var pipelinePhase = getNextPipelinePhase(2 /* Comments */, hint, node); - if (emitFlags & 2048 /* NoNestedComments */) { - commentsDisabled = true; - pipelinePhase(hint, node); - commentsDisabled = false; - } - else { - pipelinePhase(hint, node); - } + } + function emitTrailingCommentsOfNode(node, emitFlags, pos, end, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd) { enterComment(); + var skipTrailingComments = end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0 || node.kind === 11 /* JsxText */; ts.forEach(ts.getSyntheticTrailingComments(node), emitTrailingSynthesizedComment); if ((pos > 0 || end > 0) && pos !== end) { // Restore previous container state. @@ -104545,12 +108153,11 @@ 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 && isEmittedNode) { + if (!skipTrailingComments && node.kind !== 343 /* NotEmittedStatement */) { emitTrailingComments(end); } } exitComment(); - ts.Debug.assert(lastNode === node || lastSubstitution === node); } function emitLeadingSynthesizedComment(comment) { if (comment.hasLeadingNewline || comment.kind === 2 /* SingleLineCommentTrivia */) { @@ -104610,6 +108217,23 @@ var ts; } exitComment(); } + function siblingNodePositionsAreComparable(previousNode, nextNode) { + if (ts.nodeIsSynthesized(previousNode) || ts.nodeIsSynthesized(nextNode)) { + return false; + } + if (nextNode.pos < previousNode.end) { + return false; + } + previousNode = ts.getOriginalNode(previousNode); + nextNode = ts.getOriginalNode(nextNode); + var parent = previousNode.parent; + if (!parent || parent !== nextNode.parent) { + return false; + } + var parentNodeArray = ts.getContainingNodeArray(previousNode); + var prevNodeIndex = parentNodeArray === null || parentNodeArray === void 0 ? void 0 : parentNodeArray.indexOf(previousNode); + return prevNodeIndex !== undefined && prevNodeIndex > -1 && parentNodeArray.indexOf(nextNode) === prevNodeIndex + 1; + } function emitLeadingComments(pos, isEmittedNode) { hasWrittenComment = false; if (isEmittedNode) { @@ -104782,42 +108406,49 @@ var ts; } return node.parsedSourceMap || undefined; } - function pipelineEmitWithSourceMap(hint, node) { - ts.Debug.assert(lastNode === node || lastSubstitution === node); + function pipelineEmitWithSourceMaps(hint, node) { var pipelinePhase = getNextPipelinePhase(3 /* SourceMaps */, hint, node); - if (ts.isUnparsedSource(node) || ts.isUnparsedPrepend(node)) { - pipelinePhase(hint, node); - } - else if (ts.isUnparsedNode(node)) { + emitSourceMapsBeforeNode(node); + pipelinePhase(hint, node); + emitSourceMapsAfterNode(node); + } + function emitSourceMapsBeforeNode(node) { + var emitFlags = ts.getEmitFlags(node); + var sourceMapRange = ts.getSourceMapRange(node); + // Emit leading sourcemap + if (ts.isUnparsedNode(node)) { + ts.Debug.assertIsDefined(node.parent, "UnparsedNodes must have parent pointers"); var parsed = getParsedSourceMap(node.parent); if (parsed && sourceMapGenerator) { sourceMapGenerator.appendSourceMap(writer.getLine(), writer.getColumn(), parsed, node.parent.sourceMapPath, node.parent.getLineAndCharacterOfPosition(node.pos), node.parent.getLineAndCharacterOfPosition(node.end)); } - pipelinePhase(hint, node); } else { - var _a = ts.getSourceMapRange(node), pos = _a.pos, end = _a.end, _b = _a.source, source = _b === void 0 ? sourceMapSource : _b; - var emitFlags = ts.getEmitFlags(node); - if (node.kind !== 335 /* NotEmittedStatement */ + var source = sourceMapRange.source || sourceMapSource; + if (node.kind !== 343 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 - && pos >= 0) { - emitSourcePos(source, skipSourceTrivia(source, pos)); + && sourceMapRange.pos >= 0) { + emitSourcePos(sourceMapRange.source || sourceMapSource, skipSourceTrivia(source, sourceMapRange.pos)); } if (emitFlags & 64 /* NoNestedSourceMaps */) { sourceMapsDisabled = true; - pipelinePhase(hint, node); - sourceMapsDisabled = false; } - else { - pipelinePhase(hint, node); + } + } + function emitSourceMapsAfterNode(node) { + var emitFlags = ts.getEmitFlags(node); + var sourceMapRange = ts.getSourceMapRange(node); + // Emit trailing sourcemap + if (!ts.isUnparsedNode(node)) { + if (emitFlags & 64 /* NoNestedSourceMaps */) { + sourceMapsDisabled = false; } - if (node.kind !== 335 /* NotEmittedStatement */ + if (node.kind !== 343 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 - && end >= 0) { - emitSourcePos(source, end); + && sourceMapRange.end >= 0) { + emitSourcePos(sourceMapRange.source || sourceMapSource, sourceMapRange.end); } } - ts.Debug.assert(lastNode === node || lastSubstitution === node); } /** * Skips trivia such as comments and white-space that can be optionally overridden by the source-map source @@ -104969,12 +108600,22 @@ var ts; return ts.getBaseFileName(ts.normalizePath(fileName)); } function createCachedFileSystemEntries(rootDir, rootDirPath) { - var resultFromHost = { - files: ts.map(host.readDirectory(rootDir, /*extensions*/ undefined, /*exclude*/ undefined, /*include*/ ["*.*"]), getBaseNameOfFileName) || [], - directories: host.getDirectories(rootDir) || [] - }; - cachedReadDirectoryResult.set(ts.ensureTrailingDirectorySeparator(rootDirPath), resultFromHost); - return resultFromHost; + var _a; + if (!host.realpath || ts.ensureTrailingDirectorySeparator(toPath(host.realpath(rootDir))) === rootDirPath) { + var resultFromHost = { + files: ts.map(host.readDirectory(rootDir, /*extensions*/ undefined, /*exclude*/ undefined, /*include*/ ["*.*"]), getBaseNameOfFileName) || [], + directories: host.getDirectories(rootDir) || [] + }; + cachedReadDirectoryResult.set(ts.ensureTrailingDirectorySeparator(rootDirPath), resultFromHost); + return resultFromHost; + } + // If the directory is symlink do not cache the result + if ((_a = host.directoryExists) === null || _a === void 0 ? void 0 : _a.call(host, rootDir)) { + cachedReadDirectoryResult.set(rootDirPath, false); + return false; + } + // Non existing directory + return undefined; } /** * If the readDirectory result was already cached, it returns that @@ -105049,17 +108690,32 @@ var ts; } function readDirectory(rootDir, extensions, excludes, includes, depth) { var rootDirPath = toPath(rootDir); - var result = tryReadDirectory(rootDir, rootDirPath); - if (result) { + var rootResult = tryReadDirectory(rootDir, rootDirPath); + var rootSymLinkResult; + if (rootResult !== undefined) { return ts.matchFiles(rootDir, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, depth, getFileSystemEntries, realpath); } return host.readDirectory(rootDir, extensions, excludes, includes, depth); function getFileSystemEntries(dir) { var path = toPath(dir); if (path === rootDirPath) { - return result; + return rootResult || getFileSystemEntriesFromHost(dir, path); } - return tryReadDirectory(dir, path) || ts.emptyFileSystemEntries; + var result = tryReadDirectory(dir, path); + return result !== undefined ? + result || getFileSystemEntriesFromHost(dir, path) : + ts.emptyFileSystemEntries; + } + function getFileSystemEntriesFromHost(dir, path) { + if (rootSymLinkResult && path === rootDirPath) + return rootSymLinkResult; + var result = { + files: ts.map(host.readDirectory(dir, /*extensions*/ undefined, /*exclude*/ undefined, /*include*/ ["*.*"]), getBaseNameOfFileName) || ts.emptyArray, + directories: host.getDirectories(dir) || ts.emptyArray + }; + if (path === rootDirPath) + rootSymLinkResult = result; + return result; } } function realpath(s) { @@ -105067,7 +108723,7 @@ var ts; } function addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath) { var existingResult = getCachedFileSystemEntries(fileOrDirectoryPath); - if (existingResult) { + if (existingResult !== undefined) { // Just clear the cache for now // For now just clear the cache, since this could mean that multiple level entries might need to be re-evaluated clearCache(); @@ -105127,9 +108783,9 @@ var ts; /** * Updates the map of shared extended config file watches with a new set of extended config files from a base config file of the project */ - function updateSharedExtendedConfigFileWatcher(projectPath, parsed, extendedConfigFilesMap, createExtendedConfigFileWatch, toPath) { + function updateSharedExtendedConfigFileWatcher(projectPath, options, extendedConfigFilesMap, createExtendedConfigFileWatch, toPath) { var _a; - var extendedConfigs = ts.arrayToMap(((_a = parsed === null || parsed === void 0 ? void 0 : parsed.options.configFile) === null || _a === void 0 ? void 0 : _a.extendedSourceFiles) || ts.emptyArray, toPath); + var extendedConfigs = ts.arrayToMap(((_a = options === null || options === void 0 ? void 0 : options.configFile) === null || _a === void 0 ? void 0 : _a.extendedSourceFiles) || ts.emptyArray, toPath); // remove project from all unrelated watchers extendedConfigFilesMap.forEach(function (watcher, extendedConfigFilePath) { if (!extendedConfigs.has(extendedConfigFilePath)) { @@ -105147,12 +108803,12 @@ var ts; // start watching previously unseen extended config extendedConfigFilesMap.set(extendedConfigFilePath, { projects: new ts.Set([projectPath]), - fileWatcher: createExtendedConfigFileWatch(extendedConfigFileName, extendedConfigFilePath), + watcher: createExtendedConfigFileWatch(extendedConfigFileName, extendedConfigFilePath), close: function () { var existing = extendedConfigFilesMap.get(extendedConfigFilePath); if (!existing || existing.projects.size !== 0) return; - existing.fileWatcher.close(); + existing.watcher.close(); extendedConfigFilesMap.delete(extendedConfigFilePath); }, }); @@ -105160,6 +108816,31 @@ var ts; }); } ts.updateSharedExtendedConfigFileWatcher = updateSharedExtendedConfigFileWatcher; + /** + * Remove the project from the extended config file watchers and close not needed watches + */ + function clearSharedExtendedConfigFileWatcher(projectPath, extendedConfigFilesMap) { + extendedConfigFilesMap.forEach(function (watcher) { + if (watcher.projects.delete(projectPath)) + watcher.close(); + }); + } + ts.clearSharedExtendedConfigFileWatcher = clearSharedExtendedConfigFileWatcher; + /** + * Clean the extendsConfigCache when extended config file has changed + */ + function cleanExtendedConfigCache(extendedConfigCache, extendedConfigFilePath, toPath) { + if (!extendedConfigCache.delete(extendedConfigFilePath)) + return; + extendedConfigCache.forEach(function (_a, key) { + var _b; + var extendedResult = _a.extendedResult; + if ((_b = extendedResult.extendedSourceFiles) === null || _b === void 0 ? void 0 : _b.some(function (extendedFile) { return toPath(extendedFile) === extendedConfigFilePath; })) { + cleanExtendedConfigCache(extendedConfigCache, key, toPath); + } + }); + } + ts.cleanExtendedConfigCache = cleanExtendedConfigCache; /** * Updates the existing missing file watches with the new set of missing files after new program is created */ @@ -105211,7 +108892,7 @@ var ts; ts.updateWatchingWildcardDirectories = updateWatchingWildcardDirectories; /* @internal */ function isIgnoredFileFromWildCardWatching(_a) { - 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; + 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); @@ -105234,7 +108915,7 @@ var ts; return false; // We want to ignore emit file check if file is not going to be emitted next to source file // In that case we follow config file inclusion rules - if (options.outFile || options.outDir) + if (ts.outFile(options) || options.outDir) return false; // File if emitted next to input needs to be ignored if (ts.fileExtensionIs(fileOrDirectoryPath, ".d.ts" /* Dts */)) { @@ -105247,7 +108928,8 @@ var ts; } // just check if sourceFile with the name exists var filePathWithoutExtension = ts.removeFileExtension(fileOrDirectoryPath); - var realProgram = isBuilderProgram(program) ? program.getProgramOrUndefined() : program; + 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); @@ -105257,7 +108939,9 @@ var ts; function hasSourceFile(file) { return realProgram ? !!realProgram.getSourceFileByPath(file) : - program.getState().fileInfos.has(file); + builderProgram ? + builderProgram.getState().fileInfos.has(file) : + !!ts.find(program, function (rootFile) { return toPath(rootFile) === file; }); } } ts.isIgnoredFileFromWildCardWatching = isIgnoredFileFromWildCardWatching; @@ -105730,8 +109414,8 @@ var ts; var lineStart = ts.getPositionOfLineAndCharacter(file, i, 0); var lineEnd = i < lastLineInFile ? ts.getPositionOfLineAndCharacter(file, i + 1, 0) : file.text.length; var lineContent = file.text.slice(lineStart, lineEnd); - lineContent = lineContent.replace(/\s+$/g, ""); // trim from end - lineContent = lineContent.replace("\t", " "); // convert tabs to single spaces + lineContent = ts.trimStringEnd(lineContent); // trim from end + lineContent = lineContent.replace(/\t/g, " "); // convert tabs to single spaces // Output the gutter and the actual contents of the line. context += indent + formatColorAndReset(ts.padLeft(i + 1 + "", gutterWidth), gutterStyleSequence) + gutterSeparator; context += lineContent + host.getNewLine(); @@ -105936,38 +109620,31 @@ var ts; * Determines if program structure is upto date or needs to be recreated */ /* @internal */ - function isProgramUptoDate(program, rootFileNames, newOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, projectReferences) { + function isProgramUptoDate(program, rootFileNames, newOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences) { // If we haven't created a program yet or have changed automatic type directives, then it is not up-to-date - if (!program || (hasChangedAutomaticTypeDirectiveNames === null || hasChangedAutomaticTypeDirectiveNames === void 0 ? void 0 : hasChangedAutomaticTypeDirectiveNames())) { + if (!program || (hasChangedAutomaticTypeDirectiveNames === null || hasChangedAutomaticTypeDirectiveNames === void 0 ? void 0 : hasChangedAutomaticTypeDirectiveNames())) return false; - } // If root file names don't match - if (!ts.arrayIsEqualTo(program.getRootFileNames(), rootFileNames)) { + if (!ts.arrayIsEqualTo(program.getRootFileNames(), rootFileNames)) return false; - } var seenResolvedRefs; // If project references don't match - if (!ts.arrayIsEqualTo(program.getProjectReferences(), projectReferences, projectReferenceUptoDate)) { + if (!ts.arrayIsEqualTo(program.getProjectReferences(), projectReferences, projectReferenceUptoDate)) return false; - } // If any file is not up-to-date, then the whole program is not up-to-date - if (program.getSourceFiles().some(sourceFileNotUptoDate)) { + if (program.getSourceFiles().some(sourceFileNotUptoDate)) return false; - } // If any of the missing file paths are now created - if (program.getMissingFilePaths().some(fileExists)) { + if (program.getMissingFilePaths().some(fileExists)) return false; - } var currentOptions = program.getCompilerOptions(); // If the compilation settings do no match, then the program is not up-to-date - if (!ts.compareDataObjects(currentOptions, newOptions)) { + if (!ts.compareDataObjects(currentOptions, newOptions)) return false; - } // If everything matches but the text of config file is changed, // error locations can change for program options, so update the program - if (currentOptions.configFile && newOptions.configFile) { + if (currentOptions.configFile && newOptions.configFile) return currentOptions.configFile.text === newOptions.configFile.text; - } return true; function sourceFileNotUptoDate(sourceFile) { return !sourceFileVersionUptoDate(sourceFile) || @@ -105977,21 +109654,25 @@ var ts; return sourceFile.version === getSourceVersion(sourceFile.resolvedPath, sourceFile.fileName); } function projectReferenceUptoDate(oldRef, newRef, index) { - if (!ts.projectReferenceIsEqualTo(oldRef, newRef)) { - return false; - } - return resolvedProjectReferenceUptoDate(program.getResolvedProjectReferences()[index], oldRef); + return ts.projectReferenceIsEqualTo(oldRef, newRef) && + resolvedProjectReferenceUptoDate(program.getResolvedProjectReferences()[index], oldRef); } function resolvedProjectReferenceUptoDate(oldResolvedRef, oldRef) { if (oldResolvedRef) { - if (ts.contains(seenResolvedRefs, oldResolvedRef)) { - // Assume true + // Assume true + if (ts.contains(seenResolvedRefs, oldResolvedRef)) return true; - } - // If sourceFile for the oldResolvedRef existed, check the version for uptodate - if (!sourceFileVersionUptoDate(oldResolvedRef.sourceFile)) { + var refPath_1 = resolveProjectReferencePath(oldRef); + var newParsedCommandLine = getParsedCommandLine(refPath_1); + // Check if config file exists + if (!newParsedCommandLine) + return false; + // If change in source file + if (oldResolvedRef.commandLine.options.configFile !== newParsedCommandLine.options.configFile) + return false; + // check file names + if (!ts.arrayIsEqualTo(oldResolvedRef.commandLine.fileNames, newParsedCommandLine.fileNames)) return false; - } // Add to seen before checking the referenced paths of this config file (seenResolvedRefs || (seenResolvedRefs = [])).push(oldResolvedRef); // If child project references are upto date, this project reference is uptodate @@ -106001,7 +109682,8 @@ var ts; } // In old program, not able to resolve project reference path, // so if config file doesnt exist, it is uptodate. - return !fileExists(resolveProjectReferencePath(oldRef)); + var refPath = resolveProjectReferencePath(oldRef); + return !getParsedCommandLine(refPath); } } ts.isProgramUptoDate = isProgramUptoDate; @@ -106018,10 +109700,7 @@ var ts; return false; // If any compiler options change, we can't reuse old source file even if version match // The change in options like these could result in change in syntax tree or `sourceFile.bindDiagnostics`. - var oldOptions = program.getCompilerOptions(); - return !!ts.sourceFileAffectingCompilerOptions.some(function (option) { - return !ts.isJsonEqual(ts.getCompilerOptionValue(oldOptions, option), ts.getCompilerOptionValue(newOptions, option)); - }); + return ts.optionsHaveChanges(program.getCompilerOptions(), newOptions, ts.sourceFileAffectingCompilerOptions); } function createCreateProgramOptions(rootNames, options, host, oldProgram, configFileParsingDiagnostics) { return { @@ -106065,7 +109744,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.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" /* Program */, "createProgram", { configFilePath: options.configFilePath, rootDir: options.rootDir }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeProgram"); var host = createProgramOptions.host || createCompilerHost(options); var configParsingHost = parseConfigHostFromCompilerHostLike(host); @@ -106080,6 +109759,7 @@ var ts; var hasEmitBlockingDiagnostics = new ts.Map(); var _compilerOptionsObjectLiteralSyntax; var moduleResolutionCache; + var typeReferenceDirectiveResolutionCache; var actualResolveModuleNamesWorker; var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse; if (host.resolveModuleNames) { @@ -106094,7 +109774,7 @@ var ts; }); }; } else { - moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, function (x) { return host.getCanonicalFileName(x); }, options); + moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName, options); var loader_1 = function (moduleName, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache, redirectedReference).resolvedModule; }; // TODO: GH#18217 actualResolveModuleNamesWorker = function (moduleNames, containingFile, _reusedNames, redirectedReference) { return loadWithLocalCache(ts.Debug.checkEachDefined(moduleNames), containingFile, redirectedReference, loader_1); }; } @@ -106103,7 +109783,8 @@ var ts; actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options); }; } else { - var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference).resolvedTypeReferenceDirective; }; // TODO: GH#18217 + typeReferenceDirectiveResolutionCache = ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, /*options*/ undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache()); + var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache).resolvedTypeReferenceDirective; }; // TODO: GH#18217 actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { return loadWithLocalCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, loader_2); }; } // Map from a stringified PackageId to the source file with that id. @@ -106141,15 +109822,15 @@ var ts; getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect, forEachResolvedProjectReference: forEachResolvedProjectReference }), onProgramCreateComplete = _d.onProgramCreateComplete, fileExists = _d.fileExists, directoryExists = _d.directoryExists; - ts.tracing.push("program" /* Program */, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram }); var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options); - ts.tracing.pop(); + 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.push("program" /* Program */, "tryReuseStructureFromOldProgram", {}); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "tryReuseStructureFromOldProgram", {}); structureIsReused = tryReuseStructureFromOldProgram(); // eslint-disable-line prefer-const - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); if (structureIsReused !== 2 /* Completely */) { processingDefaultLibFiles = []; processingOtherFiles = []; @@ -106187,13 +109868,13 @@ var ts; }); } } - ts.tracing.push("program" /* Program */, "processRootFiles", { count: rootNames.length }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* 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.pop(); + 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.push("program" /* Program */, "processTypeReferences", { count: typeReferences.length }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* 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); @@ -106201,7 +109882,7 @@ var ts; for (var i = 0; i < typeReferences.length; i++) { processTypeReferenceDirective(typeReferences[i], resolutions[i], { kind: ts.FileIncludeKind.AutomaticTypeDirectiveFile, typeReference: typeReferences[i], packageId: (_b = resolutions[i]) === null || _b === void 0 ? void 0 : _b.packageId }); } - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } // Do not process the default library if: // - The '--noLib' flag is used. @@ -106242,12 +109923,25 @@ var ts; host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path)); } } - oldProgram.forEachResolvedProjectReference(function (resolvedProjectReference) { - if (!getResolvedProjectReferenceByPath(resolvedProjectReference.sourceFile.path)) { - host.onReleaseOldSourceFile(resolvedProjectReference.sourceFile, oldProgram.getCompilerOptions(), /*hasSourceFileByPath*/ false); + if (!host.getParsedCommandLine) { + oldProgram.forEachResolvedProjectReference(function (resolvedProjectReference) { + if (!getResolvedProjectReferenceByPath(resolvedProjectReference.sourceFile.path)) { + host.onReleaseOldSourceFile(resolvedProjectReference.sourceFile, oldProgram.getCompilerOptions(), /*hasSourceFileByPath*/ false); + } + }); + } + } + // Release commandlines that new program does not use + if (oldProgram && host.onReleaseParsedCommandLine) { + forEachProjectReference(oldProgram.getProjectReferences(), oldProgram.getResolvedProjectReferences(), function (oldResolvedRef, parent, index) { + var oldReference = (parent === null || parent === void 0 ? void 0 : parent.commandLine.projectReferences[index]) || oldProgram.getProjectReferences()[index]; + var oldRefPath = resolveProjectReferencePath(oldReference); + if (!(projectReferenceRedirects === null || projectReferenceRedirects === void 0 ? void 0 : projectReferenceRedirects.has(toPath(oldRefPath)))) { + host.onReleaseParsedCommandLine(oldRefPath, oldResolvedRef, oldProgram.getCompilerOptions()); } }); } + typeReferenceDirectiveResolutionCache = undefined; // unconditionally set oldProgram to undefined to prevent it from being captured in closure oldProgram = undefined; var program = { @@ -106276,7 +109970,6 @@ var ts; getNodeCount: function () { return getDiagnosticsProducingTypeChecker().getNodeCount(); }, getIdentifierCount: function () { return getDiagnosticsProducingTypeChecker().getIdentifierCount(); }, getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); }, - getTypeCatalog: function () { return getDiagnosticsProducingTypeChecker().getTypeCatalog(); }, getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); }, getInstantiationCount: function () { return getDiagnosticsProducingTypeChecker().getInstantiationCount(); }, getRelationCacheSizes: function () { return getDiagnosticsProducingTypeChecker().getRelationCacheSizes(); }, @@ -106324,19 +110017,19 @@ var ts; verifyCompilerOptions(); ts.performance.mark("afterProgram"); ts.performance.measure("Program", "beforeProgram", "afterProgram"); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return program; function resolveModuleNamesWorker(moduleNames, containingFile, reusedNames) { if (!moduleNames.length) return ts.emptyArray; var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory); var redirectedReference = getRedirectReferenceForResolution(containingFile); - ts.tracing.push("program" /* Program */, "resolveModuleNamesWorker", { containingFileName: containingFileName }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveModuleNamesWorker", { containingFileName: containingFileName }); ts.performance.mark("beforeResolveModule"); var result = actualResolveModuleNamesWorker(moduleNames, containingFileName, reusedNames, redirectedReference); ts.performance.mark("afterResolveModule"); ts.performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule"); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; } function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile) { @@ -106344,12 +110037,12 @@ var ts; return []; var containingFileName = !ts.isString(containingFile) ? ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile; var redirectedReference = !ts.isString(containingFile) ? getRedirectReferenceForResolution(containingFile) : undefined; - ts.tracing.push("program" /* Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName }); ts.performance.mark("beforeResolveTypeReference"); var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference); ts.performance.mark("afterResolveTypeReference"); ts.performance.measure("ResolveTypeReference", "beforeResolveTypeReference", "afterResolveTypeReference"); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; } function getRedirectReferenceForResolution(file) { @@ -106476,7 +110169,9 @@ var ts; var oldResolvedModule = ts.getResolvedModule(oldSourceFile, moduleName); if (oldResolvedModule) { if (ts.isTraceEnabled(options, host)) { - ts.trace(host, ts.Diagnostics.Reusing_resolution_of_module_0_to_file_1_from_old_program, moduleName, ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory)); + ts.trace(host, oldResolvedModule.packageId ? + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 : + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2, moduleName, ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory), oldResolvedModule.resolvedFileName, oldResolvedModule.packageId && ts.packageIdToString(oldResolvedModule.packageId)); } (result || (result = new Array(moduleNames.length)))[i] = oldResolvedModule; (reusedNames || (reusedNames = [])).push(moduleName); @@ -106559,7 +110254,9 @@ var ts; var newResolvedRef = parseProjectReferenceConfigFile(newRef); if (oldResolvedRef) { // Resolved project reference has gone missing or changed - return !newResolvedRef || newResolvedRef.sourceFile !== oldResolvedRef.sourceFile; + return !newResolvedRef || + newResolvedRef.sourceFile !== oldResolvedRef.sourceFile || + !ts.arrayIsEqualTo(oldResolvedRef.commandLine.fileNames, newResolvedRef.commandLine.fileNames); } else { // A previously-unresolved reference may be resolved now @@ -106587,9 +110284,6 @@ var ts; if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) { return 0 /* Not */; } - if (!ts.arrayIsEqualTo(options.types, oldOptions.types)) { - return 0 /* Not */; - } // Check if any referenced project tsconfig files are different if (!canReuseProjectReferences()) { return 0 /* Not */; @@ -106664,7 +110358,7 @@ var ts; // The `newSourceFile` object was created for the new program. if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) { // 'lib' references has changed. Matches behavior in changesAffectModuleResolution - return 0 /* Not */; + structureIsReused = 1 /* SafeModules */; } if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { // value of no-default-lib has changed @@ -106749,7 +110443,7 @@ var ts; if (structureIsReused !== 2 /* Completely */) { return structureIsReused; } - if ((_a = host.hasChangedAutomaticTypeDirectiveNames) === null || _a === void 0 ? void 0 : _a.call(host)) { + if (ts.changesAffectingProgramStructure(oldOptions, options) || ((_a = host.hasChangedAutomaticTypeDirectiveNames) === null || _a === void 0 ? void 0 : _a.call(host))) { return 1 /* SafeModules */; } missingFilePaths = oldProgram.getMissingFilePaths(); @@ -106821,7 +110515,7 @@ var ts; } function emitBuildInfo(writeFileCallback) { ts.Debug.assert(!ts.outFile(options)); - ts.tracing.push("emit" /* Emit */, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeEmit"); var emitResult = ts.emitFiles(ts.notImplementedResolver, getEmitHost(writeFileCallback), /*targetSourceFile*/ undefined, @@ -106830,7 +110524,7 @@ var ts; /*onlyBuildInfo*/ true); ts.performance.mark("afterEmit"); ts.performance.measure("Emit", "beforeEmit", "afterEmit"); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return emitResult; } function getResolvedProjectReferences() { @@ -106876,9 +110570,9 @@ var ts; return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ false)); } function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) { - 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" /* 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.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; } function isEmitBlocked(emitFileName) { @@ -107082,22 +110776,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 160 /* Parameter */: - case 163 /* PropertyDeclaration */: - case 165 /* MethodDeclaration */: + case 162 /* Parameter */: + case 165 /* PropertyDeclaration */: + case 167 /* 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 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: - case 209 /* ArrowFunction */: - case 249 /* VariableDeclaration */: + case 166 /* MethodSignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 210 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 211 /* ArrowFunction */: + case 251 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files)); @@ -107105,58 +110799,58 @@ var ts; } } switch (node.kind) { - case 262 /* ImportClause */: + case 264 /* 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 267 /* ExportDeclaration */: + case 269 /* 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 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_TypeScript_files)); return "skip"; - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 286 /* HeritageClause */: + case 288 /* HeritageClause */: var heritageClause = node; - if (heritageClause.token === 116 /* ImplementsKeyword */) { + if (heritageClause.token === 117 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 253 /* InterfaceDeclaration */: - var interfaceKeyword = ts.tokenToString(117 /* InterfaceKeyword */); + case 255 /* InterfaceDeclaration */: + var interfaceKeyword = ts.tokenToString(118 /* InterfaceKeyword */); ts.Debug.assertIsDefined(interfaceKeyword); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, interfaceKeyword)); return "skip"; - case 256 /* ModuleDeclaration */: - var moduleKeyword = node.flags & 16 /* Namespace */ ? ts.tokenToString(140 /* NamespaceKeyword */) : ts.tokenToString(139 /* ModuleKeyword */); + case 258 /* ModuleDeclaration */: + var moduleKeyword = node.flags & 16 /* Namespace */ ? ts.tokenToString(141 /* NamespaceKeyword */) : ts.tokenToString(140 /* ModuleKeyword */); ts.Debug.assertIsDefined(moduleKeyword); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, moduleKeyword)); return "skip"; - case 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_aliases_can_only_be_used_in_TypeScript_files)); return "skip"; - case 255 /* EnumDeclaration */: - var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(91 /* EnumKeyword */)); + case 257 /* EnumDeclaration */: + var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(92 /* EnumKeyword */)); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, enumKeyword)); return "skip"; - case 225 /* NonNullExpression */: + case 227 /* NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Non_null_assertions_can_only_be_used_in_TypeScript_files)); return "skip"; - case 224 /* AsExpression */: + case 226 /* AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.Type_assertion_expressions_can_only_be_used_in_TypeScript_files)); return "skip"; - case 206 /* TypeAssertionExpression */: + case 208 /* TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } } @@ -107165,53 +110859,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 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: - case 209 /* ArrowFunction */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 167 /* MethodDeclaration */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 210 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 211 /* 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 232 /* VariableStatement */: + case 234 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - checkModifiers(parent.modifiers, parent.kind === 232 /* VariableStatement */); + checkModifiers(parent.modifiers, parent.kind === 234 /* VariableStatement */); return "skip"; } break; - case 163 /* PropertyDeclaration */: + case 165 /* 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 (modifier.kind !== 123 /* StaticKeyword */) { + if (modifier.kind !== 124 /* 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 160 /* Parameter */: + case 162 /* Parameter */: // Check modifiers of parameter declaration if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Parameter_modifiers_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 203 /* CallExpression */: - case 204 /* NewExpression */: - case 223 /* ExpressionWithTypeArguments */: - case 274 /* JsxSelfClosingElement */: - case 275 /* JsxOpeningElement */: - case 205 /* TaggedTemplateExpression */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: + case 225 /* ExpressionWithTypeArguments */: + case 276 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: + case 207 /* TaggedTemplateExpression */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_arguments_can_only_be_used_in_TypeScript_files)); @@ -107224,24 +110918,25 @@ var ts; for (var _i = 0, modifiers_2 = modifiers; _i < modifiers_2.length; _i++) { var modifier = modifiers_2[_i]; switch (modifier.kind) { - case 84 /* ConstKeyword */: + case 85 /* ConstKeyword */: if (isConstValid) { continue; } // to report error, // falls through - case 122 /* PublicKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 142 /* ReadonlyKeyword */: - case 133 /* DeclareKeyword */: - case 125 /* AbstractKeyword */: + case 123 /* PublicKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + case 143 /* ReadonlyKeyword */: + case 134 /* DeclareKeyword */: + case 126 /* AbstractKeyword */: + case 157 /* OverrideKeyword */: 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 123 /* StaticKeyword */: - case 92 /* ExportKeyword */: - case 87 /* DefaultKeyword */: + case 124 /* StaticKeyword */: + case 93 /* ExportKeyword */: + case 88 /* DefaultKeyword */: } } } @@ -107312,8 +111007,8 @@ var ts; return a.fileName === b.fileName; } function moduleNameIsEqualTo(a, b) { - return a.kind === 78 /* Identifier */ - ? b.kind === 78 /* Identifier */ && a.escapedText === b.escapedText + return a.kind === 79 /* Identifier */ + ? b.kind === 79 /* Identifier */ && a.escapedText === b.escapedText : b.kind === 10 /* StringLiteral */ && a.text === b.text; } function createSyntheticImport(text, file) { @@ -107539,13 +111234,13 @@ var ts; } // Get source file from normalized fileName function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, reason, packageId) { - ts.tracing.push("program" /* Program */, "findSourceFile", { + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "findSourceFile", { fileName: fileName, isDefaultLib: isDefaultLib || undefined, fileIncludeKind: ts.FileIncludeKind[reason.kind], }); var result = findSourceFileWorker(fileName, path, isDefaultLib, ignoreNoDefaultLib, reason, packageId); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; } function findSourceFileWorker(fileName, path, isDefaultLib, ignoreNoDefaultLib, reason, packageId) { @@ -107804,9 +111499,9 @@ var ts; } } function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, reason) { - 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" /* Program */, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolveModuleNamesReusingOldState, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined }); processTypeReferenceDirectiveWorker(typeReferenceDirective, resolvedTypeReferenceDirective, reason); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } function processTypeReferenceDirectiveWorker(typeReferenceDirective, resolvedTypeReferenceDirective, reason) { // If we already found this library as a primary reference - nothing to do @@ -107877,12 +111572,14 @@ var ts; return host.getCanonicalFileName(fileName); } function processImportedModules(file) { + var _a; collectExternalModuleReferences(file); if (file.imports.length || file.moduleAugmentations.length) { // Because global augmentation doesn't have string literal name, we can check for global augmentation as such. var moduleNames = getModuleNames(file); var resolutions = resolveModuleNamesReusingOldState(moduleNames, file); ts.Debug.assert(resolutions.length === moduleNames.length); + var optionsForFile = (useSourceOfProjectReferenceRedirect ? (_a = getRedirectReferenceForResolution(file)) === null || _a === void 0 ? void 0 : _a.commandLine.options : undefined) || options; for (var index = 0; index < moduleNames.length; index++) { var resolution = resolutions[index]; ts.setResolvedModule(file, moduleNames[index], resolution); @@ -107905,11 +111602,11 @@ var ts; // Don't add the file if it has a bad extension (e.g. 'tsx' if we don't have '--allowJs') // This may still end up being an untyped module -- the file won't be included but imports will be allowed. var shouldAddFile = resolvedFileName - && !getResolutionDiagnostic(options, resolution) - && !options.noResolve + && !getResolutionDiagnostic(optionsForFile, resolution) + && !optionsForFile.noResolve && index < file.imports.length && !elideImport - && !(isJsFile && !ts.getAllowJSCompilerOption(options)) + && !(isJsFile && !ts.getAllowJSCompilerOption(optionsForFile)) && (ts.isInJSFile(file.imports[index]) || !(file.imports[index].flags & 4194304 /* JSDoc */)); if (elideImport) { modulesWithElidedImports.set(file.path, true); @@ -107995,6 +111692,9 @@ var ts; if (options.strictPropertyInitialization && !ts.getStrictOptionValue(options, "strictNullChecks")) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictPropertyInitialization", "strictNullChecks"); } + if (options.strictOptionalProperties && !ts.getStrictOptionValue(options, "strictNullChecks")) { + createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictOptionalProperties", "strictNullChecks"); + } if (options.isolatedModules) { if (options.out) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules"); @@ -108112,6 +111812,9 @@ var ts; if (options.module === ts.ModuleKind.None && languageVersion < 2 /* 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 */; }); if (firstNonExternalModuleSourceFile) { var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); @@ -108142,9 +111845,10 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Option_resolveJsonModule_can_only_be_specified_when_module_code_generation_is_commonjs_amd_es2015_or_esNext, "resolveJsonModule", "module"); } } - // there has to be common source directory if user specified --outdir || --sourceRoot + // there has to be common source directory if user specified --outdir || --rootDir || --sourceRoot // if user specified --mapRoot, there needs to be common source directory if there would be multiple files being emitted if (options.outDir || // there is --outDir specified + options.rootDir || // there is --rootDir specified options.sourceRoot || // there is --sourceRoot specified options.mapRoot) { // there is --mapRoot specified // Precalculate and cache the common source directory @@ -108641,7 +112345,7 @@ var ts; } function handleDirectoryCouldBeSymlink(directory) { var _a; - if (!host.getResolvedProjectReferences()) + if (!host.getResolvedProjectReferences() || ts.containsIgnoredPath(directory)) return; // Because we already watch node_modules, handle symlinks in there if (!originalRealpath || !ts.stringContains(directory, ts.nodeModulesPathPart)) @@ -108658,7 +112362,7 @@ var ts; symlinkCache.setSymlinkedDirectory(directoryPath, false); return; } - symlinkCache.setSymlinkedDirectory(directoryPath, { + symlinkCache.setSymlinkedDirectory(directory, { real: ts.ensureTrailingDirectorySeparator(real), realPath: realPath }); @@ -108934,12 +112638,15 @@ var ts; // From ambient modules for (var _f = 0, _g = program.getTypeChecker().getAmbientModules(); _f < _g.length; _f++) { var ambientModule = _g[_f]; - if (ambientModule.declarations.length > 1) { + if (ambientModule.declarations && ambientModule.declarations.length > 1) { addReferenceFromAmbientModule(ambientModule); } } return referencedFiles; function addReferenceFromAmbientModule(symbol) { + if (!symbol.declarations) { + return; + } // Add any file other than our own as reference for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; @@ -108964,7 +112671,7 @@ var ts; /** * Creates the state of file references and signature for the new program from oldState if it is safe */ - function create(newProgram, getCanonicalFileName, oldState) { + function create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) { var fileInfos = new ts.Map(); var referencedMap = newProgram.getCompilerOptions().module !== ts.ModuleKind.None ? new ts.Map() : undefined; var exportedModulesMap = referencedMap ? new ts.Map() : undefined; @@ -108990,13 +112697,14 @@ var ts; } } } - fileInfos.set(sourceFile.resolvedPath, { version: version_2, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) }); + fileInfos.set(sourceFile.resolvedPath, { version: version_2, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) || undefined }); } return { fileInfos: fileInfos, referencedMap: referencedMap, exportedModulesMap: exportedModulesMap, - hasCalledUpdateShapeSignature: hasCalledUpdateShapeSignature + hasCalledUpdateShapeSignature: hasCalledUpdateShapeSignature, + useFileVersionAsSignature: !disableUseFileVersionAsSignature && !useOldState }; } BuilderState.create = create; @@ -109018,6 +112726,7 @@ var ts; referencedMap: state.referencedMap && new ts.Map(state.referencedMap), exportedModulesMap: state.exportedModulesMap && new ts.Map(state.exportedModulesMap), hasCalledUpdateShapeSignature: new ts.Set(state.hasCalledUpdateShapeSignature), + useFileVersionAsSignature: state.useFileVersionAsSignature, }; } BuilderState.clone = clone; @@ -109073,23 +112782,12 @@ var ts; return ts.Debug.fail(); var prevSignature = info.signature; var latestSignature; - if (sourceFile.isDeclarationFile) { - latestSignature = sourceFile.version; - if (exportedModulesMapCache && latestSignature !== prevSignature) { - // All the references in this file are exported - var references = state.referencedMap ? state.referencedMap.get(sourceFile.resolvedPath) : undefined; - exportedModulesMapCache.set(sourceFile.resolvedPath, references || false); - } - } - else { + if (!sourceFile.isDeclarationFile && !state.useFileVersionAsSignature) { var emitOutput_1 = getFileEmitOutput(programOfThisState, sourceFile, /*emitOnlyDtsFiles*/ true, cancellationToken, /*customTransformers*/ undefined, /*forceDtsEmit*/ true); - var firstDts_1 = emitOutput_1.outputFiles && - programOfThisState.getCompilerOptions().declarationMap ? - emitOutput_1.outputFiles.length > 1 ? emitOutput_1.outputFiles[1] : undefined : - emitOutput_1.outputFiles.length > 0 ? emitOutput_1.outputFiles[0] : undefined; + var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles); if (firstDts_1) { ts.Debug.assert(ts.fileExtensionIs(firstDts_1.name, ".d.ts" /* Dts */), "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 = (computeHash || ts.generateDjb2Hash)(firstDts_1.text); @@ -109097,12 +112795,18 @@ var ts; updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache); } } - else { - latestSignature = prevSignature; // TODO: GH#18217 + } + // Default is to use file version as signature + if (latestSignature === undefined) { + latestSignature = sourceFile.version; + if (exportedModulesMapCache && latestSignature !== prevSignature) { + // All the references in this file are exported + var references = state.referencedMap ? state.referencedMap.get(sourceFile.resolvedPath) : undefined; + exportedModulesMapCache.set(sourceFile.resolvedPath, references || false); } } cacheToUpdateSignature.set(sourceFile.resolvedPath, latestSignature); - return !prevSignature || latestSignature !== prevSignature; + return latestSignature !== prevSignature; } BuilderState.updateShapeSignature = updateShapeSignature; /** @@ -109222,7 +112926,7 @@ var ts; */ function isFileAffectingGlobalScope(sourceFile) { return containsGlobalScopeAugmentation(sourceFile) || - !ts.isExternalModule(sourceFile) && !containsOnlyAmbientModules(sourceFile); + !ts.isExternalOrCommonJsModule(sourceFile) && !containsOnlyAmbientModules(sourceFile); } /** * Gets all files of the program excluding the default library file @@ -109310,8 +113014,8 @@ var ts; /** * Create the state so that we can iterate on changedFiles/affected files */ - function createBuilderProgramState(newProgram, getCanonicalFileName, oldState) { - var state = ts.BuilderState.create(newProgram, getCanonicalFileName, oldState); + function createBuilderProgramState(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) { + var state = ts.BuilderState.create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature); state.program = newProgram; var compilerOptions = newProgram.getCompilerOptions(); state.compilerOptions = compilerOptions; @@ -109549,6 +113253,7 @@ var ts; * 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) { + var _a; removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath); // If affected files is everything except default library, then nothing more to do if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) { @@ -109562,8 +113267,15 @@ var ts; removeSemanticDiagnosticsOf(state, f.resolvedPath); }); } + // 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, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap); return; } + else { + ts.Debug.assert(state.hasCalledUpdateShapeSignature.has(affectedFile.resolvedPath) || ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.has(affectedFile.resolvedPath)), "Signature not updated for affected file: " + affectedFile.fileName); + } if (!state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) { forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash); }); } @@ -109775,83 +113487,116 @@ var ts; return undefined; var currentDirectory = ts.Debug.checkDefined(state.program).getCurrentDirectory(); var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory)); - var fileInfos = {}; - state.fileInfos.forEach(function (value, key) { + var fileNames = []; + var fileNameToFileId = new ts.Map(); + var fileIdsList; + var fileNamesToFileIdListId; + var fileInfos = ts.arrayFrom(state.fileInfos.entries(), function (_a) { + var key = _a[0], value = _a[1]; + // Ensure fileId + var fileId = toFileId(key); + ts.Debug.assert(fileNames[fileId - 1] === relativeToBuildInfo(key)); var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key); - fileInfos[relativeToBuildInfo(key)] = signature === undefined ? value : { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope }; + var actualSignature = signature !== null && signature !== void 0 ? signature : value.signature; + return value.version === actualSignature ? + value.affectsGlobalScope ? + { version: value.version, signature: undefined, affectsGlobalScope: true } : + value.version : + actualSignature !== undefined ? + signature === undefined ? + value : + { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope } : + { version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope }; }); - var result = { - fileInfos: fileInfos, - options: convertToReusableCompilerOptions(state.compilerOptions, relativeToBuildInfoEnsuringAbsolutePath) - }; + var referencedMap; if (state.referencedMap) { - var referencedMap = {}; - for (var _i = 0, _a = ts.arrayFrom(state.referencedMap.keys()).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) { - var key = _a[_i]; - referencedMap[relativeToBuildInfo(key)] = ts.arrayFrom(state.referencedMap.get(key).keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive); - } - result.referencedMap = referencedMap; + referencedMap = ts.arrayFrom(state.referencedMap.keys()).sort(ts.compareStringsCaseSensitive).map(function (key) { return [ + toFileId(key), + toFileIdListId(state.referencedMap.get(key)) + ]; }); } + var exportedModulesMap; if (state.exportedModulesMap) { - var exportedModulesMap = {}; - for (var _b = 0, _c = ts.arrayFrom(state.exportedModulesMap.keys()).sort(ts.compareStringsCaseSensitive); _b < _c.length; _b++) { - var key = _c[_b]; + exportedModulesMap = ts.mapDefined(ts.arrayFrom(state.exportedModulesMap.keys()).sort(ts.compareStringsCaseSensitive), function (key) { var newValue = state.currentAffectedFilesExportedModulesMap && state.currentAffectedFilesExportedModulesMap.get(key); // Not in temporary cache, use existing value if (newValue === undefined) - exportedModulesMap[relativeToBuildInfo(key)] = ts.arrayFrom(state.exportedModulesMap.get(key).keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive); + return [toFileId(key), toFileIdListId(state.exportedModulesMap.get(key))]; // Value in cache and has updated value map, use that else if (newValue) - exportedModulesMap[relativeToBuildInfo(key)] = ts.arrayFrom(newValue.keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive); - } - result.exportedModulesMap = exportedModulesMap; + return [toFileId(key), toFileIdListId(newValue)]; + }); } + var semanticDiagnosticsPerFile; if (state.semanticDiagnosticsPerFile) { - var semanticDiagnosticsPerFile = []; - for (var _d = 0, _e = ts.arrayFrom(state.semanticDiagnosticsPerFile.keys()).sort(ts.compareStringsCaseSensitive); _d < _e.length; _d++) { - var key = _e[_d]; + for (var _i = 0, _a = ts.arrayFrom(state.semanticDiagnosticsPerFile.keys()).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) { + var key = _a[_i]; var value = state.semanticDiagnosticsPerFile.get(key); - semanticDiagnosticsPerFile.push(value.length ? + (semanticDiagnosticsPerFile || (semanticDiagnosticsPerFile = [])).push(value.length ? [ - relativeToBuildInfo(key), + toFileId(key), state.hasReusableDiagnostic ? value : convertToReusableDiagnostics(value, relativeToBuildInfo) ] : - relativeToBuildInfo(key)); + toFileId(key)); } - result.semanticDiagnosticsPerFile = semanticDiagnosticsPerFile; } + var affectedFilesPendingEmit; if (state.affectedFilesPendingEmit) { - var affectedFilesPendingEmit = []; var seenFiles = new ts.Set(); - for (var _f = 0, _g = state.affectedFilesPendingEmit.slice(state.affectedFilesPendingEmitIndex).sort(ts.compareStringsCaseSensitive); _f < _g.length; _f++) { - var path = _g[_f]; + for (var _b = 0, _c = state.affectedFilesPendingEmit.slice(state.affectedFilesPendingEmitIndex).sort(ts.compareStringsCaseSensitive); _b < _c.length; _b++) { + var path = _c[_b]; if (ts.tryAddToSet(seenFiles, path)) { - affectedFilesPendingEmit.push([relativeToBuildInfo(path), state.affectedFilesPendingEmitKind.get(path)]); + (affectedFilesPendingEmit || (affectedFilesPendingEmit = [])).push([toFileId(path), state.affectedFilesPendingEmitKind.get(path)]); } } - result.affectedFilesPendingEmit = affectedFilesPendingEmit; } - return result; + return { + fileNames: fileNames, + fileInfos: fileInfos, + options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, relativeToBuildInfoEnsuringAbsolutePath), + fileIdsList: fileIdsList, + referencedMap: referencedMap, + exportedModulesMap: exportedModulesMap, + semanticDiagnosticsPerFile: semanticDiagnosticsPerFile, + affectedFilesPendingEmit: affectedFilesPendingEmit, + }; function relativeToBuildInfoEnsuringAbsolutePath(path) { return relativeToBuildInfo(ts.getNormalizedAbsolutePath(path, currentDirectory)); } function relativeToBuildInfo(path) { return ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(buildInfoDirectory, path, getCanonicalFileName)); } + function toFileId(path) { + var fileId = fileNameToFileId.get(path); + if (fileId === undefined) { + fileNames.push(relativeToBuildInfo(path)); + fileNameToFileId.set(path, fileId = fileNames.length); + } + return fileId; + } + function toFileIdListId(set) { + var fileIds = ts.arrayFrom(set.keys(), toFileId).sort(ts.compareValues); + var key = fileIds.join(); + var fileIdListId = fileNamesToFileIdListId === null || fileNamesToFileIdListId === void 0 ? void 0 : fileNamesToFileIdListId.get(key); + if (fileIdListId === undefined) { + (fileIdsList || (fileIdsList = [])).push(fileIds); + (fileNamesToFileIdListId || (fileNamesToFileIdListId = new ts.Map())).set(key, fileIdListId = fileIdsList.length); + } + return fileIdListId; + } } - function convertToReusableCompilerOptions(options, relativeToBuildInfo) { - var result = {}; + function convertToProgramBuildInfoCompilerOptions(options, relativeToBuildInfo) { + var result; var optionsNameMap = ts.getOptionsNameMap().optionsNameMap; - for (var name in options) { - if (ts.hasProperty(options, name)) { - result[name] = convertToReusableCompilerOptionValue(optionsNameMap.get(name.toLowerCase()), options[name], relativeToBuildInfo); + for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) { + var name = _a[_i]; + var optionInfo = optionsNameMap.get(name.toLowerCase()); + if ((optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsEmit) || (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsSemanticDiagnostics) || name === "skipLibCheck" || name === "skipDefaultLibCheck") { + (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfo); } } - if (result.configFilePath) { - result.configFilePath = relativeToBuildInfo(result.configFilePath); - } return result; } function convertToReusableCompilerOptionValue(option, value, relativeToBuildInfo) { @@ -109943,15 +113688,16 @@ var ts; * Computing hash to for signature verification */ var computeHash = ts.maybeBind(host, host.createHash); - var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState); + var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState, host.disableUseFileVersionAsSignature); var backupState; 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; oldState = undefined; - var builderProgram = createRedirectedBuilderProgram(state, configFileParsingDiagnostics); - builderProgram.getState = function () { return state; }; + var getState = function () { return state; }; + var builderProgram = createRedirectedBuilderProgram(getState, configFileParsingDiagnostics); + builderProgram.getState = getState; builderProgram.backupState = function () { ts.Debug.assert(backupState === undefined); backupState = cloneBuilderProgramState(state); @@ -110167,37 +113913,31 @@ var ts; state.affectedFilesPendingEmitIndex = 0; } } - function getMapOfReferencedSet(mapLike, toPath) { - if (!mapLike) - return undefined; - var map = new ts.Map(); - // Copies keys/values from template. Note that for..in will not throw if - // template is undefined, and instead will just exit the loop. - for (var key in mapLike) { - if (ts.hasProperty(mapLike, key)) { - map.set(toPath(key), new ts.Set(mapLike[key].map(toPath))); - } - } - return map; + function toBuilderStateFileInfo(fileInfo) { + return ts.isString(fileInfo) ? + { version: fileInfo, signature: fileInfo, affectsGlobalScope: undefined } : + ts.isString(fileInfo.signature) ? + fileInfo : + { version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope }; } + ts.toBuilderStateFileInfo = toBuilderStateFileInfo; function createBuildProgramUsingProgramBuildInfo(program, buildInfoPath, host) { + var _a; var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory())); var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames()); + var filePaths = program.fileNames.map(toPath); + var filePathsSetList = (_a = program.fileIdsList) === null || _a === void 0 ? void 0 : _a.map(function (fileIds) { return new ts.Set(fileIds.map(toFilePath)); }); var fileInfos = new ts.Map(); - for (var key in program.fileInfos) { - if (ts.hasProperty(program.fileInfos, key)) { - fileInfos.set(toPath(key), program.fileInfos[key]); - } - } + program.fileInfos.forEach(function (fileInfo, index) { return fileInfos.set(toFilePath(index + 1), toBuilderStateFileInfo(fileInfo)); }); var state = { fileInfos: fileInfos, - compilerOptions: ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath), - referencedMap: getMapOfReferencedSet(program.referencedMap, toPath), - exportedModulesMap: getMapOfReferencedSet(program.exportedModulesMap, toPath), - semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, function (value) { return toPath(ts.isString(value) ? value : value[0]); }, function (value) { return ts.isString(value) ? ts.emptyArray : value[1]; }), + compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {}, + referencedMap: toMapOfReferencedSet(program.referencedMap), + exportedModulesMap: toMapOfReferencedSet(program.exportedModulesMap), + semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, function (value) { return toFilePath(ts.isNumber(value) ? value : value[0]); }, function (value) { return ts.isNumber(value) ? ts.emptyArray : value[1]; }), hasReusableDiagnostic: true, - affectedFilesPendingEmit: ts.map(program.affectedFilesPendingEmit, function (value) { return toPath(value[0]); }), - affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toPath(value[0]); }, function (value) { return value[1]; }), + affectedFilesPendingEmit: ts.map(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }), + affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }, function (value) { return value[1]; }), affectedFilesPendingEmitIndex: program.affectedFilesPendingEmit && 0, }; return { @@ -110230,17 +113970,26 @@ var ts; function toAbsolutePath(path) { return ts.getNormalizedAbsolutePath(path, buildInfoDirectory); } + function toFilePath(fileId) { + return filePaths[fileId - 1]; + } + function toFilePathsSet(fileIdsListId) { + return filePathsSetList[fileIdsListId - 1]; + } + function toMapOfReferencedSet(referenceMap) { + return referenceMap && ts.arrayToMap(referenceMap, function (value) { return toFilePath(value[0]); }, function (value) { return toFilePathsSet(value[1]); }); + } } ts.createBuildProgramUsingProgramBuildInfo = createBuildProgramUsingProgramBuildInfo; - function createRedirectedBuilderProgram(state, configFileParsingDiagnostics) { + function createRedirectedBuilderProgram(getState, configFileParsingDiagnostics) { return { getState: ts.notImplemented, backupState: ts.noop, restoreState: ts.noop, getProgram: getProgram, - getProgramOrUndefined: function () { return state.program; }, - releaseProgram: function () { return state.program = undefined; }, - getCompilerOptions: function () { return state.compilerOptions; }, + getProgramOrUndefined: function () { return getState().program; }, + releaseProgram: function () { return getState().program = undefined; }, + getCompilerOptions: function () { return getState().compilerOptions; }, getSourceFile: function (fileName) { return getProgram().getSourceFile(fileName); }, getSourceFiles: function () { return getProgram().getSourceFiles(); }, getOptionsDiagnostics: function (cancellationToken) { return getProgram().getOptionsDiagnostics(cancellationToken); }, @@ -110256,7 +114005,7 @@ var ts; close: ts.noop, }; function getProgram() { - return ts.Debug.checkDefined(state.program); + return ts.Debug.checkDefined(getState().program); } } ts.createRedirectedBuilderProgram = createRedirectedBuilderProgram; @@ -110273,7 +114022,7 @@ var ts; ts.createEmitAndSemanticDiagnosticsBuilderProgram = createEmitAndSemanticDiagnosticsBuilderProgram; function createAbstractBuilder(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences) { var _a = ts.getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences), newProgram = _a.newProgram, newConfigFileParsingDiagnostics = _a.configFileParsingDiagnostics; - return ts.createRedirectedBuilderProgram({ program: newProgram, compilerOptions: newProgram.getCompilerOptions() }, newConfigFileParsingDiagnostics); + return ts.createRedirectedBuilderProgram(function () { return ({ program: newProgram, compilerOptions: newProgram.getCompilerOptions() }); }, newConfigFileParsingDiagnostics); } ts.createAbstractBuilder = createAbstractBuilder; })(ts || (ts = {})); @@ -110342,9 +114091,9 @@ var ts; var resolutionsWithFailedLookups = []; var resolvedFileToResolution = ts.createMultiMap(); var hasChangedAutomaticTypeDirectiveNames = false; - var failedLookupChecks = []; - var startsWithPathChecks = []; - var isInDirectoryChecks = []; + var failedLookupChecks; + var startsWithPathChecks; + var isInDirectoryChecks; var getCurrentDirectory = ts.memoize(function () { return resolutionHost.getCurrentDirectory(); }); // TODO: GH#18217 var cachedDirectoryStructureHost = resolutionHost.getCachedDirectoryStructureHost(); // The resolvedModuleNames and resolvedTypeReferenceDirectives are the cache of resolutions per file. @@ -110353,9 +114102,12 @@ var ts; var resolvedModuleNames = new ts.Map(); var perDirectoryResolvedModuleNames = ts.createCacheWithRedirects(); var nonRelativeModuleNameCache = ts.createCacheWithRedirects(); - var moduleResolutionCache = ts.createModuleResolutionCacheWithMaps(perDirectoryResolvedModuleNames, nonRelativeModuleNameCache, getCurrentDirectory(), resolutionHost.getCanonicalFileName); + var moduleResolutionCache = ts.createModuleResolutionCache(getCurrentDirectory(), resolutionHost.getCanonicalFileName, + /*options*/ undefined, perDirectoryResolvedModuleNames, nonRelativeModuleNameCache); var resolvedTypeReferenceDirectives = new ts.Map(); var perDirectoryResolvedTypeReferenceDirectives = ts.createCacheWithRedirects(); + var typeReferenceDirectiveResolutionCache = ts.createTypeReferenceDirectiveResolutionCache(getCurrentDirectory(), resolutionHost.getCanonicalFileName, + /*options*/ undefined, moduleResolutionCache.getPackageJsonInfoCache(), perDirectoryResolvedTypeReferenceDirectives); /** * These are the extensions that failed lookup files will have by default, * any other extension of failed lookup will be store that path in custom failed lookup path @@ -110387,6 +114139,7 @@ var ts; invalidateResolutionsOfFailedLookupLocations: invalidateResolutionsOfFailedLookupLocations, setFilesWithInvalidatedNonRelativeUnresolvedImports: setFilesWithInvalidatedNonRelativeUnresolvedImports, createHasInvalidatedResolution: createHasInvalidatedResolution, + isFileWithInvalidatedNonRelativeUnresolvedImports: isFileWithInvalidatedNonRelativeUnresolvedImports, updateTypeRootsWatch: updateTypeRootsWatch, closeTypeRootsWatch: closeTypeRootsWatch, clear: clear @@ -110412,9 +114165,9 @@ var ts; resolvedTypeReferenceDirectives.clear(); resolvedFileToResolution.clear(); resolutionsWithFailedLookups.length = 0; - failedLookupChecks.length = 0; - startsWithPathChecks.length = 0; - isInDirectoryChecks.length = 0; + failedLookupChecks = undefined; + startsWithPathChecks = undefined; + isInDirectoryChecks = undefined; // perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update // (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution) clearPerDirectoryResolutions(); @@ -110450,9 +114203,8 @@ var ts; isFileWithInvalidatedNonRelativeUnresolvedImports(path); }; } function clearPerDirectoryResolutions() { - perDirectoryResolvedModuleNames.clear(); - nonRelativeModuleNameCache.clear(); - perDirectoryResolvedTypeReferenceDirectives.clear(); + moduleResolutionCache.clear(); + typeReferenceDirectiveResolutionCache.clear(); nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions); nonRelativeExternalModuleResolutions.clear(); } @@ -110479,7 +114231,7 @@ var ts; if (globalCache !== undefined && !ts.isExternalModuleNameRelative(moduleName) && !(primaryResult.resolvedModule && ts.extensionIsTS(primaryResult.resolvedModule.extension))) { // create different collection of failed lookup locations for second pass // if it will fail and we've already found something during the first pass - we don't want to pollute its results - var _b = ts.loadModuleFromGlobalCache(ts.Debug.checkDefined(resolutionHost.globalCacheResolutionModuleName)(moduleName), resolutionHost.projectName, compilerOptions, host, globalCache), resolvedModule = _b.resolvedModule, failedLookupLocations = _b.failedLookupLocations; + var _b = ts.loadModuleFromGlobalCache(ts.Debug.checkDefined(resolutionHost.globalCacheResolutionModuleName)(moduleName), resolutionHost.projectName, compilerOptions, host, globalCache, moduleResolutionCache), resolvedModule = _b.resolvedModule, failedLookupLocations = _b.failedLookupLocations; if (resolvedModule) { // Modify existing resolution so its saved in the directory cache as well primaryResult.resolvedModule = resolvedModule; @@ -110490,8 +114242,11 @@ var ts; // Default return the result from the first pass return primaryResult; } + function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference) { + return ts.resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache); + } function resolveNamesWithLocalCache(_a) { - var _b; + var _b, _c, _d; var names = _a.names, containingFile = _a.containingFile, redirectedReference = _a.redirectedReference, cache = _a.cache, perDirectoryCacheWithRedirects = _a.perDirectoryCacheWithRedirects, loader = _a.loader, getResolutionWithResolvedFileName = _a.getResolutionWithResolvedFileName, shouldRetryResolution = _a.shouldRetryResolution, reusedNames = _a.reusedNames, logChanges = _a.logChanges; var path = resolutionHost.toPath(containingFile); var resolutionsInFile = cache.get(path) || cache.set(path, new ts.Map()).get(path); @@ -110524,9 +114279,24 @@ var ts; var resolutionInDirectory = perDirectoryResolution.get(name); if (resolutionInDirectory) { resolution = resolutionInDirectory; + var host = ((_b = resolutionHost.getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(resolutionHost)) || resolutionHost; + if (ts.isTraceEnabled(compilerOptions, host)) { + var resolved = getResolutionWithResolvedFileName(resolution); + ts.trace(host, loader === resolveModuleName ? + (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ? + resolved.packagetId ? + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4 : + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3 : + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_not_resolved : + (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ? + resolved.packagetId ? + ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4 : + ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3 : + ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_not_resolved, name, containingFile, ts.getDirectoryPath(containingFile), resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName, (resolved === null || resolved === void 0 ? void 0 : resolved.packagetId) && ts.packageIdToString(resolved.packagetId)); + } } else { - resolution = loader(name, containingFile, compilerOptions, ((_b = resolutionHost.getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(resolutionHost)) || resolutionHost, redirectedReference); + resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference); perDirectoryResolution.set(name, resolution); } resolutionsInFile.set(name, resolution); @@ -110540,6 +114310,23 @@ var ts; logChanges = false; } } + else { + var host = ((_d = resolutionHost.getCompilerHost) === null || _d === void 0 ? void 0 : _d.call(resolutionHost)) || resolutionHost; + if (ts.isTraceEnabled(compilerOptions, host) && !seenNamesInFile.has(name)) { + var resolved = getResolutionWithResolvedFileName(resolution); + ts.trace(host, loader === resolveModuleName ? + (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ? + resolved.packagetId ? + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 : + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2 : + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_not_resolved : + (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ? + resolved.packagetId ? + ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 : + ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2 : + ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_not_resolved, name, containingFile, resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName, (resolved === null || resolved === void 0 ? void 0 : resolved.packagetId) && ts.packageIdToString(resolved.packagetId)); + } + } ts.Debug.assert(resolution !== undefined && !resolution.isInvalidated); seenNamesInFile.set(name, true); resolvedModules.push(getResolutionWithResolvedFileName(resolution)); @@ -110577,7 +114364,7 @@ var ts; redirectedReference: redirectedReference, cache: resolvedTypeReferenceDirectives, perDirectoryCacheWithRedirects: perDirectoryResolvedTypeReferenceDirectives, - loader: ts.resolveTypeReferenceDirective, + loader: resolveTypeReferenceDirective, getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective, shouldRetryResolution: function (resolution) { return resolution.resolvedTypeReferenceDirective === undefined; }, }); @@ -110852,7 +114639,7 @@ var ts; if (isCreatingWatchedDirectory) { // Watching directory is created // Invalidate any resolution has failed lookup in this directory - isInDirectoryChecks.push(fileOrDirectoryPath); + (isInDirectoryChecks || (isInDirectoryChecks = [])).push(fileOrDirectoryPath); } else { // If something to do with folder/file starting with "." in node_modules folder, skip it @@ -110870,8 +114657,8 @@ var ts; if (isNodeModulesAtTypesDirectory(fileOrDirectoryPath) || ts.isNodeModulesDirectory(fileOrDirectoryPath) || isNodeModulesAtTypesDirectory(dirOfFileOrDirectory) || ts.isNodeModulesDirectory(dirOfFileOrDirectory)) { // Invalidate any resolution from this directory - failedLookupChecks.push(fileOrDirectoryPath); - startsWithPathChecks.push(fileOrDirectoryPath); + (failedLookupChecks || (failedLookupChecks = [])).push(fileOrDirectoryPath); + (startsWithPathChecks || (startsWithPathChecks = new ts.Set())).add(fileOrDirectoryPath); } else { if (!isPathWithDefaultFailedLookupExtension(fileOrDirectoryPath) && !customFailedLookupPaths.has(fileOrDirectoryPath)) { @@ -110882,27 +114669,33 @@ var ts; return false; } // Resolution need to be invalidated if failed lookup location is same as the file or directory getting created - failedLookupChecks.push(fileOrDirectoryPath); + (failedLookupChecks || (failedLookupChecks = [])).push(fileOrDirectoryPath); + // If the invalidated file is from a node_modules package, invalidate everything else + // in the package since we might not get notifications for other files in the package. + // This hardens our logic against unreliable file watchers. + var packagePath = ts.parseNodeModuleFromPath(fileOrDirectoryPath); + if (packagePath) + (startsWithPathChecks || (startsWithPathChecks = new ts.Set())).add(packagePath); } } resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations(); } function invalidateResolutionsOfFailedLookupLocations() { - if (!failedLookupChecks.length && !startsWithPathChecks.length && !isInDirectoryChecks.length) { + if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks) { return false; } var invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution); - failedLookupChecks.length = 0; - startsWithPathChecks.length = 0; - isInDirectoryChecks.length = 0; + failedLookupChecks = undefined; + startsWithPathChecks = undefined; + isInDirectoryChecks = undefined; return invalidated; } function canInvalidateFailedLookupResolution(resolution) { return resolution.failedLookupLocations.some(function (location) { var locationPath = resolutionHost.toPath(location); return ts.contains(failedLookupChecks, locationPath) || - startsWithPathChecks.some(function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath); }) || - isInDirectoryChecks.some(function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath); }); + ts.firstDefinedIterator((startsWithPathChecks === null || startsWithPathChecks === void 0 ? void 0 : startsWithPathChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath) ? true : undefined; }) || + (isInDirectoryChecks === null || isInDirectoryChecks === void 0 ? void 0 : isInDirectoryChecks.some(function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath); })); }); } function closeTypeRootsWatch() { @@ -111053,6 +114846,9 @@ var ts; return [ambient]; var info = getInfo(importingSourceFile.path, host); var moduleSourceFile = ts.getSourceFileOfNode(moduleSymbol.valueDeclaration || ts.getNonAugmentationDeclaration(moduleSymbol)); + if (!moduleSourceFile) { + return []; + } var modulePaths = getAllModulePaths(importingSourceFile.path, moduleSourceFile.originalFileName, host); var preferences = getPreferences(userPreferences, compilerOptions, importingSourceFile); var existingSpecifier = ts.forEach(modulePaths, function (modulePath) { return ts.forEach(host.getFileIncludeReasons().get(ts.toPath(modulePath.path, host.getCurrentDirectory(), info.getCanonicalFileName)), function (reason) { @@ -111123,7 +114919,7 @@ var ts; if (!baseUrl && !paths || relativePreference === 0 /* Relative */) { return relativePath; } - var baseDirectory = ts.getPathsBasePath(compilerOptions, host) || baseUrl; + var baseDirectory = ts.getNormalizedAbsolutePath(ts.getPathsBasePath(compilerOptions, host) || baseUrl, host.getCurrentDirectory()); var relativeToBaseUrl = getRelativePathIfInDirectory(moduleFileName, baseDirectory, getCanonicalFileName); if (!relativeToBaseUrl) { return relativePath; @@ -111138,7 +114934,9 @@ var ts; return nonRelative; } if (relativePreference === 3 /* ExternalNonRelative */) { - var projectDirectory = host.getCurrentDirectory(); + var projectDirectory = compilerOptions.configFilePath ? + ts.toPath(ts.getDirectoryPath(compilerOptions.configFilePath), host.getCurrentDirectory(), info.getCanonicalFileName) : + info.getCanonicalFileName(host.getCurrentDirectory()); var modulePath = ts.toPath(moduleFileName, projectDirectory, getCanonicalFileName); var sourceIsInternal = ts.startsWith(sourceDirectory, projectDirectory); var targetIsInternal = ts.startsWith(modulePath, projectDirectory); @@ -111190,12 +114988,8 @@ var ts; return ts.pathIsRelative(text) ? ts.hasJSFileExtension(text) : undefined; }) || false; } - function numberOfDirectorySeparators(str) { - var match = str.match(/\//g); - return match ? match.length : 0; - } function comparePathsByRedirectAndNumberOfDirectorySeparators(a, b) { - return ts.compareBooleans(b.isRedirect, a.isRedirect) || ts.compareValues(numberOfDirectorySeparators(a.path), numberOfDirectorySeparators(b.path)); + return ts.compareBooleans(b.isRedirect, a.isRedirect) || ts.compareNumberOfDirectorySeparators(a.path, b.path); } function getNearestAncestorDirectoryWithPackageJson(host, fileName) { if (host.getNearestAncestorDirectoryWithPackageJson) { @@ -111209,40 +115003,49 @@ var ts; var getCanonicalFileName = ts.hostGetCanonicalFileName(host); var cwd = host.getCurrentDirectory(); var referenceRedirect = host.isSourceOfProjectReferenceRedirect(importedFileName) ? host.getProjectReferenceRedirect(importedFileName) : undefined; - var redirects = host.redirectTargetsMap.get(ts.toPath(importedFileName, cwd, getCanonicalFileName)) || ts.emptyArray; + var importedPath = ts.toPath(importedFileName, cwd, getCanonicalFileName); + var redirects = host.redirectTargetsMap.get(importedPath) || ts.emptyArray; var importedFileNames = __spreadArray(__spreadArray(__spreadArray([], (referenceRedirect ? [referenceRedirect] : ts.emptyArray)), [importedFileName]), redirects); var targets = importedFileNames.map(function (f) { return ts.getNormalizedAbsolutePath(f, cwd); }); + var shouldFilterIgnoredPaths = !ts.every(targets, ts.containsIgnoredPath); if (!preferSymlinks) { - var result_15 = ts.forEach(targets, function (p) { return cb(p, referenceRedirect === p); }); + // Symlinks inside ignored paths are already filtered out of the symlink cache, + // so we only need to remove them from the realpath filenames. + var result_15 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); }); if (result_15) return result_15; } var links = host.getSymlinkCache ? host.getSymlinkCache() : ts.discoverProbableSymlinks(host.getSourceFiles(), getCanonicalFileName, cwd); - var symlinkedDirectories = links.getSymlinkedDirectories(); - var useCaseSensitiveFileNames = !host.useCaseSensitiveFileNames || host.useCaseSensitiveFileNames(); - var result = symlinkedDirectories && ts.forEachEntry(symlinkedDirectories, function (resolved, path) { - if (resolved === false) - return undefined; - if (ts.startsWithDirectory(importingFileName, resolved.realPath, getCanonicalFileName)) { - return undefined; // Don't want to a package to globally import from itself + var symlinkedDirectories = links.getSymlinkedDirectoriesByRealpath(); + var fullImportedFileName = ts.getNormalizedAbsolutePath(importedFileName, cwd); + var result = symlinkedDirectories && ts.forEachAncestorDirectory(ts.getDirectoryPath(fullImportedFileName), function (realPathDirectory) { + var symlinkDirectories = symlinkedDirectories.get(ts.ensureTrailingDirectorySeparator(ts.toPath(realPathDirectory, cwd, getCanonicalFileName))); + if (!symlinkDirectories) + return undefined; // Continue to ancestor directory + // Don't want to a package to globally import from itself (importNameCodeFix_symlink_own_package.ts) + if (ts.startsWithDirectory(importingFileName, realPathDirectory, getCanonicalFileName)) { + return false; // Stop search, each ancestor directory will also hit this condition } return ts.forEach(targets, function (target) { - if (!ts.containsPath(resolved.real, target, !useCaseSensitiveFileNames)) { + if (!ts.startsWithDirectory(target, realPathDirectory, getCanonicalFileName)) { return; } - var relative = ts.getRelativePathFromDirectory(resolved.real, target, getCanonicalFileName); - var option = ts.resolvePath(path, relative); - if (!host.fileExists || host.fileExists(option)) { + var relative = ts.getRelativePathFromDirectory(realPathDirectory, target, getCanonicalFileName); + for (var _i = 0, symlinkDirectories_1 = symlinkDirectories; _i < symlinkDirectories_1.length; _i++) { + var symlinkDirectory = symlinkDirectories_1[_i]; + var option = ts.resolvePath(symlinkDirectory, relative); var result_16 = cb(option, target === referenceRedirect); + shouldFilterIgnoredPaths = true; // We found a non-ignored path in symlinks, so we can reject ignored-path realpaths if (result_16) return result_16; } }); }); - return result || - (preferSymlinks ? ts.forEach(targets, function (p) { return cb(p, p === referenceRedirect); }) : undefined); + return result || (preferSymlinks + ? ts.forEach(targets, function (p) { return shouldFilterIgnoredPaths && ts.containsIgnoredPath(p) ? undefined : cb(p, p === referenceRedirect); }) + : undefined); } moduleSpecifiers.forEachFileNameOfModule = forEachFileNameOfModule; /** @@ -111250,8 +115053,14 @@ var ts; * Symlinks will be returned first so they are preferred over the real path. */ function getAllModulePaths(importingFileName, importedFileName, host) { - var cwd = host.getCurrentDirectory(); + var _a; + var cache = (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host); var getCanonicalFileName = ts.hostGetCanonicalFileName(host); + if (cache) { + var cached = cache.get(importingFileName, ts.toPath(importedFileName, host.getCurrentDirectory(), getCanonicalFileName)); + if (typeof cached === "object") + return cached; + } var allFileNames = new ts.Map(); var importedFileFromNodeModules = false; forEachFileNameOfModule(importingFileName, importedFileName, host, @@ -111263,7 +115072,7 @@ var ts; }); // Sort by paths closest to importing file Name directory var sortedPaths = []; - var _loop_24 = function (directory) { + var _loop_26 = function (directory) { var directoryStart = ts.ensureTrailingDirectorySeparator(directory); var pathsInDirectory; allFileNames.forEach(function (_a, fileName) { @@ -111286,10 +115095,10 @@ var ts; out_directory_1 = directory; }; var out_directory_1; - for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0;) { - var state_7 = _loop_24(directory); + for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) { + var state_9 = _loop_26(directory); directory = out_directory_1; - if (state_7 === "break") + if (state_9 === "break") break; } if (allFileNames.size) { @@ -111298,10 +115107,14 @@ var ts; remainingPaths.sort(comparePathsByRedirectAndNumberOfDirectorySeparators); sortedPaths.push.apply(sortedPaths, remainingPaths); } + if (cache) { + cache.set(importingFileName, ts.toPath(importedFileName, host.getCurrentDirectory(), getCanonicalFileName), sortedPaths); + } return sortedPaths; } function tryGetModuleNameFromAmbientModule(moduleSymbol, checker) { - var decl = ts.find(moduleSymbol.declarations, function (d) { return ts.isNonGlobalAmbientModule(d) && (!ts.isExternalModuleAugmentation(d) || !ts.isExternalModuleNameRelative(ts.getTextOfIdentifierOrLiteral(d.name))); }); + var _a; + var decl = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.isNonGlobalAmbientModule(d) && (!ts.isExternalModuleAugmentation(d) || !ts.isExternalModuleNameRelative(ts.getTextOfIdentifierOrLiteral(d.name))); }); if (decl) { return decl.name.text; } @@ -111357,7 +115170,7 @@ var ts; ts.startsWith(relativeToBaseUrl, prefix) && ts.endsWith(relativeToBaseUrl, suffix) || !suffix && relativeToBaseUrl === ts.removeTrailingDirectorySeparator(prefix)) { - var matchedStar = relativeToBaseUrl.substr(prefix.length, relativeToBaseUrl.length - suffix.length); + var matchedStar = relativeToBaseUrl.substr(prefix.length, relativeToBaseUrl.length - suffix.length - prefix.length); return key.replace("*", matchedStar); } } @@ -111661,10 +115474,10 @@ var ts; } ts.createWatchStatusReporter = createWatchStatusReporter; /** Parses config file using System interface */ - function parseConfigFileWithSystem(configFileName, optionsToExtend, watchOptionsToExtend, system, reportDiagnostic) { + function parseConfigFileWithSystem(configFileName, optionsToExtend, extendedConfigCache, watchOptionsToExtend, system, reportDiagnostic) { var host = system; host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(system, reportDiagnostic, diagnostic); }; - var result = ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtend, host, /*extendedConfigCache*/ undefined, watchOptionsToExtend); + var result = ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtend, host, extendedConfigCache, watchOptionsToExtend); host.onUnRecoverableConfigFileDiagnostic = undefined; // TODO: GH#18217 return result; } @@ -111932,7 +115745,10 @@ var ts; MissingFile: "Missing file", WildcardDirectory: "Wild card directory", FailedLookupLocations: "Failed Lookup Locations", - TypeRoots: "Type roots" + TypeRoots: "Type roots", + ConfigFileOfReferencedProject: "Config file of referened project", + ExtendedConfigOfReferencedProject: "Extended config file of referenced project", + WildcardDirectoryOfReferencedProject: "Wild card directory of referenced project", }; function createWatchFactory(host, options) { var watchLogLevel = host.trace ? options.extendedDiagnostics ? ts.WatchLogLevel.Verbose : options.diagnostics ? ts.WatchLogLevel.TriggerOnly : ts.WatchLogLevel.None : ts.WatchLogLevel.None; @@ -111979,6 +115795,7 @@ var ts; getEnvironmentVariable: ts.maybeBind(host, host.getEnvironmentVariable) || (function () { return ""; }), createHash: ts.maybeBind(host, host.createHash), readDirectory: ts.maybeBind(host, host.readDirectory), + disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature, }; function writeFile(fileName, text, writeByteOrderMark, onError) { try { @@ -112036,7 +115853,8 @@ var ts; createDirectory: function (path) { return system.createDirectory(path); }, writeFile: function (path, data, writeByteOrderMark) { return system.writeFile(path, data, writeByteOrderMark); }, createHash: ts.maybeBind(system, system.createHash), - createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram + createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram, + disableUseFileVersionAsSignature: system.disableUseFileVersionAsSignature, }; } ts.createProgramHost = createProgramHost; @@ -112124,6 +115942,7 @@ var ts; if (system === void 0) { system = ts.sys; } var host = ts.createCompilerHostWorker(options, /*setParentNodes*/ undefined, system); host.createHash = ts.maybeBind(system, system.createHash); + host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature; ts.setGetSourceFileAsHashVersioned(host, system); ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); }); return host; @@ -112167,11 +115986,13 @@ var ts; function createWatchProgram(host) { var builderProgram; var reloadLevel; // level to indicate if the program needs to be reloaded from config file/just filenames etc - var extendedConfigFilesMap; // Map of file watchers for the extended config files var missingFilesMap; // Map of file watchers for the missing files var watchedWildcardDirectories; // map of watchers for the wild card directories in the config file var timerToUpdateProgram; // timer callback to recompile the program var timerToInvalidateFailedLookupResolutions; // timer callback to invalidate resolutions for changes in failed lookup locations + 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 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 var hasChangedCompilerOptions = false; // True if the compiler options have changed between compilations @@ -112221,6 +116042,7 @@ var ts; compilerHost.getNewLine = function () { return newLine; }; compilerHost.fileExists = fileExists; compilerHost.onReleaseOldSourceFile = onReleaseOldSourceFile; + compilerHost.onReleaseParsedCommandLine = onReleaseParsedCommandLine; // Members for ResolutionCacheHost compilerHost.toPath = toPath; compilerHost.getCompilationSettings = function () { return compilerOptions; }; @@ -112234,6 +116056,7 @@ var ts; compilerHost.fileIsOpen = ts.returnFalse; compilerHost.getCurrentProgram = getCurrentProgram; compilerHost.writeLog = writeLog; + compilerHost.getParsedCommandLine = getParsedCommandLine; // Cache for the module resolution var resolutionCache = ts.createResolutionCache(compilerHost, configFileName ? ts.getDirectoryPath(ts.getNormalizedAbsolutePath(configFileName, currentDirectory)) : @@ -112264,7 +116087,8 @@ var ts; // Update the wild card directory watch watchConfigFileWildCardDirectories(); // Update extended config file watch - watchExtendedConfigFiles(); + if (configFileName) + updateExtendedConfigFilesWatches(toPath(configFileName), compilerOptions, watchOptions, ts.WatchType.ExtendedConfigFile); return configFileName ? { getCurrentProgram: getCurrentBuilderProgram, getProgram: updateProgram, close: close } : { getCurrentProgram: getCurrentBuilderProgram, getProgram: updateProgram, updateRootFileNames: updateRootFileNames, close: close }; @@ -112281,9 +116105,11 @@ var ts; configFileWatcher.close(); configFileWatcher = undefined; } - if (extendedConfigFilesMap) { - ts.clearMap(extendedConfigFilesMap, ts.closeFileWatcher); - extendedConfigFilesMap = undefined; + extendedConfigCache === null || extendedConfigCache === void 0 ? void 0 : extendedConfigCache.clear(); + extendedConfigCache = undefined; + if (sharedExtendedConfigFileWatchers) { + ts.clearMap(sharedExtendedConfigFileWatchers, ts.closeFileWatcherOf); + sharedExtendedConfigFileWatchers = undefined; } if (watchedWildcardDirectories) { ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcherOf); @@ -112293,6 +116119,17 @@ var ts; ts.clearMap(missingFilesMap, ts.closeFileWatcher); missingFilesMap = undefined; } + if (parsedConfigs) { + ts.clearMap(parsedConfigs, function (config) { + var _a; + (_a = config.watcher) === null || _a === void 0 ? void 0 : _a.close(); + config.watcher = undefined; + if (config.watchedDirectories) + ts.clearMap(config.watchedDirectories, ts.closeFileWatcherOf); + config.watchedDirectories = undefined; + }); + parsedConfigs = undefined; + } } function getCurrentBuilderProgram() { return builderProgram; @@ -112312,7 +116149,7 @@ var ts; } // All resolutions are invalid if user provided resolutions var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution); - if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, projectReferences)) { + if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) { if (hasChangedConfigFileParsingErrors) { builderProgram = createProgram(/*rootNames*/ undefined, /*options*/ undefined, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences); hasChangedConfigFileParsingErrors = false; @@ -112331,6 +116168,8 @@ var ts; writeLog("CreatingProgramWith::"); writeLog(" roots: " + JSON.stringify(rootFileNames)); writeLog(" options: " + JSON.stringify(compilerOptions)); + if (projectReferences) + writeLog(" projectReferences: " + JSON.stringify(projectReferences)); var needsUpdateInTypeRootWatch = hasChangedCompilerOptions || !getCurrentProgram(); hasChangedCompilerOptions = false; hasChangedConfigFileParsingErrors = false; @@ -112553,10 +116392,10 @@ var ts; // Update the wild card directory watch watchConfigFileWildCardDirectories(); // Update extended config file watch - watchExtendedConfigFiles(); + updateExtendedConfigFilesWatches(toPath(configFileName), compilerOptions, watchOptions, ts.WatchType.ExtendedConfigFile); } function parseConfigFile() { - setConfigFileParsingResult(ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtendForConfigFile, parseConfigFileHost, /*extendedConfigCache*/ undefined, watchOptionsToExtend, extraFileExtensions)); // TODO: GH#18217 + setConfigFileParsingResult(ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtendForConfigFile, parseConfigFileHost, extendedConfigCache || (extendedConfigCache = new ts.Map()), watchOptionsToExtend, extraFileExtensions)); // TODO: GH#18217 } function setConfigFileParsingResult(configFileParseResult) { rootFileNames = configFileParseResult.fileNames; @@ -112568,6 +116407,56 @@ var ts; canConfigFileJsonReportNoInputFiles = ts.canJsonReportNoInputFiles(configFileParseResult.raw); hasChangedConfigFileParsingErrors = true; } + function getParsedCommandLine(configFileName) { + var configPath = toPath(configFileName); + var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(configPath); + if (config) { + if (!config.reloadLevel) + return config.parsedCommandLine; + // With host implementing getParsedCommandLine we cant just update file names + if (config.parsedCommandLine && config.reloadLevel === ts.ConfigFileProgramReloadLevel.Partial && !host.getParsedCommandLine) { + writeLog("Reloading new file names and options"); + var fileNames = ts.getFileNamesFromConfigSpecs(config.parsedCommandLine.options.configFile.configFileSpecs, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), compilerOptions, parseConfigFileHost); + config.parsedCommandLine = __assign(__assign({}, config.parsedCommandLine), { fileNames: fileNames }); + config.reloadLevel = undefined; + return config.parsedCommandLine; + } + } + writeLog("Loading config file: " + configFileName); + var parsedCommandLine = host.getParsedCommandLine ? + host.getParsedCommandLine(configFileName) : + getParsedCommandLineFromConfigFileHost(configFileName); + if (config) { + config.parsedCommandLine = parsedCommandLine; + config.reloadLevel = undefined; + } + else { + (parsedConfigs || (parsedConfigs = new ts.Map())).set(configPath, config = { parsedCommandLine: parsedCommandLine }); + } + watchReferencedProject(configFileName, configPath, config); + return parsedCommandLine; + } + function getParsedCommandLineFromConfigFileHost(configFileName) { + // Ignore the file absent errors + var onUnRecoverableConfigFileDiagnostic = parseConfigFileHost.onUnRecoverableConfigFileDiagnostic; + parseConfigFileHost.onUnRecoverableConfigFileDiagnostic = ts.noop; + var parsedCommandLine = ts.getParsedCommandLineOfConfigFile(configFileName, + /*optionsToExtend*/ undefined, parseConfigFileHost, extendedConfigCache || (extendedConfigCache = new ts.Map()), watchOptionsToExtend); + parseConfigFileHost.onUnRecoverableConfigFileDiagnostic = onUnRecoverableConfigFileDiagnostic; + return parsedCommandLine; + } + function onReleaseParsedCommandLine(fileName) { + var _a; + var path = toPath(fileName); + var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(path); + if (!config) + return; + parsedConfigs.delete(path); + if (config.watchedDirectories) + ts.clearMap(config.watchedDirectories, ts.closeFileWatcherOf); + (_a = config.watcher) === null || _a === void 0 ? void 0 : _a.close(); + ts.clearSharedExtendedConfigFileWatcher(path, sharedExtendedConfigFileWatchers); + } function watchFilePath(path, file, callback, pollingInterval, options, watchType) { return watchFile(file, function (fileName, eventKind) { return callback(fileName, eventKind, path); }, pollingInterval, options, watchType); } @@ -112577,7 +116466,6 @@ var ts; if (eventKind === ts.FileWatcherEventKind.Deleted && sourceFilesCache.has(path)) { resolutionCache.invalidateResolutionOfFile(path); } - resolutionCache.removeResolutionsFromProjectReferenceRedirects(path); nextSourceFileVersion(path); // Update the program scheduleProgramUpdate(); @@ -112588,7 +116476,10 @@ var ts; } } function watchMissingFilePath(missingFilePath) { - return watchFilePath(missingFilePath, missingFilePath, onMissingFileChange, ts.PollingInterval.Medium, watchOptions, ts.WatchType.MissingFile); + // If watching missing referenced config file, we are already watching it so no need for separate watcher + return (parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.has(missingFilePath)) ? + ts.noopFileWatcher : + watchFilePath(missingFilePath, missingFilePath, onMissingFileChange, ts.PollingInterval.Medium, watchOptions, ts.WatchType.MissingFile); } function onMissingFileChange(fileName, eventKind, missingFilePath) { updateCachedSystemWithFile(fileName, missingFilePath, eventKind); @@ -112625,10 +116516,11 @@ var ts; configFileName: configFileName, extraFileExtensions: extraFileExtensions, options: compilerOptions, - program: getCurrentBuilderProgram(), + program: getCurrentBuilderProgram() || rootFileNames, currentDirectory: currentDirectory, useCaseSensitiveFileNames: useCaseSensitiveFileNames, - writeLog: writeLog + writeLog: writeLog, + toPath: toPath, })) return; // Reload is pending, do the reload @@ -112639,18 +116531,87 @@ var ts; } }, flags, watchOptions, ts.WatchType.WildcardDirectory); } - function watchExtendedConfigFiles() { - var _a; - // Update the extended config files watcher - ts.mutateMap(extendedConfigFilesMap || (extendedConfigFilesMap = new ts.Map()), ts.arrayToMap(((_a = compilerOptions.configFile) === null || _a === void 0 ? void 0 : _a.extendedSourceFiles) || ts.emptyArray, toPath), { - // Watch the extended config files - createNewValue: watchExtendedConfigFile, - // Config files that are no longer extended should no longer be watched. - onDeleteValue: ts.closeFileWatcher - }); + function updateExtendedConfigFilesWatches(forProjectPath, options, watchOptions, watchType) { + ts.updateSharedExtendedConfigFileWatcher(forProjectPath, options, sharedExtendedConfigFileWatchers || (sharedExtendedConfigFileWatchers = new ts.Map()), function (extendedConfigFileName, extendedConfigFilePath) { return watchFile(extendedConfigFileName, function (_fileName, eventKind) { + var _a; + updateCachedSystemWithFile(extendedConfigFileName, extendedConfigFilePath, eventKind); + // Update extended config cache + if (extendedConfigCache) + ts.cleanExtendedConfigCache(extendedConfigCache, extendedConfigFilePath, toPath); + // Update projects + var projects = (_a = sharedExtendedConfigFileWatchers.get(extendedConfigFilePath)) === null || _a === void 0 ? void 0 : _a.projects; + // If there are no referenced projects this extended config file watcher depend on ignore + if (!(projects === null || projects === void 0 ? void 0 : projects.size)) + return; + projects.forEach(function (projectPath) { + if (toPath(configFileName) === projectPath) { + // If this is the config file of the project, reload completely + reloadLevel = ts.ConfigFileProgramReloadLevel.Full; + } + else { + // Reload config for the referenced projects and remove the resolutions from referenced projects since the config file changed + var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(projectPath); + if (config) + config.reloadLevel = ts.ConfigFileProgramReloadLevel.Full; + resolutionCache.removeResolutionsFromProjectReferenceRedirects(projectPath); + } + scheduleProgramUpdate(); + }); + }, ts.PollingInterval.High, watchOptions, watchType); }, toPath); } - function watchExtendedConfigFile(extendedConfigFile) { - return watchFile(extendedConfigFile, scheduleProgramReload, ts.PollingInterval.High, watchOptions, ts.WatchType.ExtendedConfigFile); + function watchReferencedProject(configFileName, configPath, commandLine) { + var _a, _b, _c, _d, _e; + // Watch file + commandLine.watcher || (commandLine.watcher = watchFile(configFileName, function (_fileName, eventKind) { + updateCachedSystemWithFile(configFileName, configPath, eventKind); + var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(configPath); + if (config) + config.reloadLevel = ts.ConfigFileProgramReloadLevel.Full; + resolutionCache.removeResolutionsFromProjectReferenceRedirects(configPath); + scheduleProgramUpdate(); + }, ts.PollingInterval.High, ((_a = commandLine.parsedCommandLine) === null || _a === void 0 ? void 0 : _a.watchOptions) || watchOptions, ts.WatchType.ConfigFileOfReferencedProject)); + // Watch Wild card + if ((_b = commandLine.parsedCommandLine) === null || _b === void 0 ? void 0 : _b.wildcardDirectories) { + ts.updateWatchingWildcardDirectories(commandLine.watchedDirectories || (commandLine.watchedDirectories = new ts.Map()), new ts.Map(ts.getEntries((_c = commandLine.parsedCommandLine) === null || _c === void 0 ? void 0 : _c.wildcardDirectories)), function (directory, flags) { + var _a; + return watchDirectory(directory, function (fileOrDirectory) { + var fileOrDirectoryPath = toPath(fileOrDirectory); + // Since the file existence changed, update the sourceFiles cache + if (cachedDirectoryStructureHost) { + cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); + } + nextSourceFileVersion(fileOrDirectoryPath); + var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(configPath); + if (!(config === null || config === void 0 ? void 0 : config.parsedCommandLine)) + return; + if (ts.isIgnoredFileFromWildCardWatching({ + watchedDirPath: toPath(directory), + fileOrDirectory: fileOrDirectory, + fileOrDirectoryPath: fileOrDirectoryPath, + configFileName: configFileName, + options: config.parsedCommandLine.options, + program: config.parsedCommandLine.fileNames, + currentDirectory: currentDirectory, + useCaseSensitiveFileNames: useCaseSensitiveFileNames, + writeLog: writeLog, + toPath: toPath, + })) + return; + // Reload is pending, do the reload + if (config.reloadLevel !== ts.ConfigFileProgramReloadLevel.Full) { + config.reloadLevel = ts.ConfigFileProgramReloadLevel.Partial; + // Schedule Update the program + scheduleProgramUpdate(); + } + }, flags, ((_a = commandLine.parsedCommandLine) === null || _a === void 0 ? void 0 : _a.watchOptions) || watchOptions, ts.WatchType.WildcardDirectoryOfReferencedProject); + }); + } + else if (commandLine.watchedDirectories) { + ts.clearMap(commandLine.watchedDirectories, ts.closeFileWatcherOf); + commandLine.watchedDirectories = undefined; + } + // Watch extended config files + updateExtendedConfigFilesWatches(configPath, (_d = commandLine.parsedCommandLine) === null || _d === void 0 ? void 0 : _d.options, ((_e = commandLine.parsedCommandLine) === null || _e === void 0 ? void 0 : _e.watchOptions) || watchOptions, ts.WatchType.ExtendedConfigOfReferencedProject); } } ts.createWatchProgram = createWatchProgram; @@ -112810,12 +116771,19 @@ var ts; compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames); compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives); 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) { var loader_3 = function (moduleName, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference).resolvedModule; }; compilerHost.resolveModuleNames = function (moduleNames, containingFile, _reusedNames, redirectedReference) { return ts.loadWithLocalCache(ts.Debug.checkEachDefined(moduleNames), containingFile, redirectedReference, loader_3); }; } + if (!compilerHost.resolveTypeReferenceDirectives) { + var loader_4 = function (moduleName, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache).resolvedTypeReferenceDirective; }; + compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { + return ts.loadWithLocalCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, loader_4); + }; + } var _a = ts.createWatchFactory(hostWithWatch, options), watchFile = _a.watchFile, watchDirectory = _a.watchDirectory, writeLog = _a.writeLog; var state = { host: host, @@ -112840,6 +116808,7 @@ var ts; projectErrorsReported: new ts.Map(), compilerHost: compilerHost, moduleResolutionCache: moduleResolutionCache, + typeReferenceDirectiveResolutionCache: typeReferenceDirectiveResolutionCache, // Mutable state buildOrder: undefined, readFileWithCache: function (f) { return host.readFile(f); }, @@ -112878,6 +116847,10 @@ var ts; function isParsedCommandLine(entry) { return !!entry.options; } + function getCachedParsedConfigFile(state, configFilePath) { + var value = state.configFileCache.get(configFilePath); + return value && isParsedCommandLine(value) ? value : undefined; + } function parseConfigFile(state, configFileName, configFilePath) { var configFileCache = state.configFileCache; var value = configFileCache.get(configFilePath); @@ -113023,7 +116996,7 @@ var ts; function disableCache(state) { if (!state.cache) return; - var cache = state.cache, host = state.host, compilerHost = state.compilerHost, extendedConfigCache = state.extendedConfigCache, moduleResolutionCache = state.moduleResolutionCache; + var cache = state.cache, host = state.host, compilerHost = state.compilerHost, extendedConfigCache = state.extendedConfigCache, moduleResolutionCache = state.moduleResolutionCache, typeReferenceDirectiveResolutionCache = state.typeReferenceDirectiveResolutionCache; host.readFile = cache.originalReadFile; host.fileExists = cache.originalFileExists; host.directoryExists = cache.originalDirectoryExists; @@ -113032,10 +117005,8 @@ var ts; compilerHost.getSourceFile = cache.originalGetSourceFile; state.readFileWithCache = cache.originalReadFileWithCache; extendedConfigCache.clear(); - if (moduleResolutionCache) { - moduleResolutionCache.directoryToModuleNameMap.clear(); - moduleResolutionCache.moduleNameToDirectoryMap.clear(); - } + moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.clear(); + typeReferenceDirectiveResolutionCache === null || typeReferenceDirectiveResolutionCache === void 0 ? void 0 : typeReferenceDirectiveResolutionCache.clear(); state.cache = undefined; } function clearProjectStatus(state, resolved) { @@ -113202,6 +117173,7 @@ var ts; return withProgramOrUndefined(action) || ts.emptyArray; } function createProgram() { + var _a, _b; ts.Debug.assert(program === undefined); if (state.options.dry) { reportStatus(state, ts.Diagnostics.A_non_dry_build_would_build_project_0, project); @@ -113221,7 +117193,8 @@ var ts; var host = state.host, compilerHost = state.compilerHost; state.projectCompilerOptions = config.options; // Update module resolution cache if needed - updateModuleResolutionCache(state, project, config); + (_a = state.moduleResolutionCache) === null || _a === void 0 ? void 0 : _a.update(config.options); + (_b = state.typeReferenceDirectiveResolutionCache) === null || _b === void 0 ? void 0 : _b.update(config.options); // Create program program = host.createProgram(config.fileNames, config.options, compilerHost, getOldProgram(state, projectPath, config), ts.getConfigFileParsingDiagnostics(config), config.projectReferences); if (state.watch) { @@ -113396,7 +117369,7 @@ var ts; emitBundle(writeFile, customTransformers); break; case BuildStep.BuildInvalidatedProjectOfBundle: - ts.Debug.checkDefined(invalidatedProjectOfBundle).done(cancellationToken); + ts.Debug.checkDefined(invalidatedProjectOfBundle).done(cancellationToken, writeFile, customTransformers); step = BuildStep.Done; break; case BuildStep.QueueReferencingProjects: @@ -113538,34 +117511,9 @@ var ts; afterProgramDone(state, program, config); return { buildResult: buildResult, step: BuildStep.QueueReferencingProjects }; } - function updateModuleResolutionCache(state, proj, config) { - if (!state.moduleResolutionCache) - return; - // Update module resolution cache if needed - var moduleResolutionCache = state.moduleResolutionCache; - var projPath = toPath(state, proj); - if (moduleResolutionCache.directoryToModuleNameMap.redirectsMap.size === 0) { - // The own map will be for projectCompilerOptions - ts.Debug.assert(moduleResolutionCache.moduleNameToDirectoryMap.redirectsMap.size === 0); - moduleResolutionCache.directoryToModuleNameMap.redirectsMap.set(projPath, moduleResolutionCache.directoryToModuleNameMap.ownMap); - moduleResolutionCache.moduleNameToDirectoryMap.redirectsMap.set(projPath, moduleResolutionCache.moduleNameToDirectoryMap.ownMap); - } - else { - // Set correct own map - ts.Debug.assert(moduleResolutionCache.moduleNameToDirectoryMap.redirectsMap.size > 0); - var ref = { - sourceFile: config.options.configFile, - commandLine: config - }; - moduleResolutionCache.directoryToModuleNameMap.setOwnMap(moduleResolutionCache.directoryToModuleNameMap.getOrCreateMapOfCacheRedirects(ref)); - moduleResolutionCache.moduleNameToDirectoryMap.setOwnMap(moduleResolutionCache.moduleNameToDirectoryMap.getOrCreateMapOfCacheRedirects(ref)); - } - moduleResolutionCache.directoryToModuleNameMap.setOwnOptions(config.options); - moduleResolutionCache.moduleNameToDirectoryMap.setOwnOptions(config.options); - } function checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName) { // Check tsconfig time - var tsconfigTime = state.host.getModifiedTime(configFile) || ts.missingFileModifiedTime; + var tsconfigTime = ts.getModifiedTime(state.host, configFile); if (oldestOutputFileTime < tsconfigTime) { return { type: ts.UpToDateStatusType.OutOfDateWithSelf, @@ -113575,6 +117523,7 @@ var ts; } } function getUpToDateStatusWorker(state, project, resolvedPath) { + var force = !!state.options.force; var newestInputFileName = undefined; var newestInputFileTime = minimumDate; var host = state.host; @@ -113587,10 +117536,13 @@ var ts; reason: inputFile + " does not exist" }; } - var inputTime = host.getModifiedTime(inputFile) || ts.missingFileModifiedTime; - if (inputTime > newestInputFileTime) { - newestInputFileName = inputFile; - newestInputFileTime = inputTime; + if (!force) { + var inputTime = ts.getModifiedTime(host, inputFile); + host.getModifiedTime(inputFile); + if (inputTime > newestInputFileTime) { + newestInputFileName = inputFile; + newestInputFileTime = inputTime; + } } } // Container if no files are specified in the project @@ -113609,36 +117561,38 @@ var ts; var missingOutputFileName; var newestDeclarationFileContentChangedTime = minimumDate; var isOutOfDateWithInputs = false; - for (var _b = 0, outputs_1 = outputs; _b < outputs_1.length; _b++) { - var output = outputs_1[_b]; - // Output is missing; can stop checking - // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status - if (!host.fileExists(output)) { - missingOutputFileName = output; - break; - } - var outputTime = host.getModifiedTime(output) || ts.missingFileModifiedTime; - if (outputTime < oldestOutputFileTime) { - oldestOutputFileTime = outputTime; - oldestOutputFileName = output; - } - // If an output is older than the newest input, we can stop checking - // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status - if (outputTime < newestInputFileTime) { - isOutOfDateWithInputs = true; - break; - } - if (outputTime > newestOutputFileTime) { - newestOutputFileTime = outputTime; - newestOutputFileName = output; - } - // Keep track of when the most recent time a .d.ts file was changed. - // In addition to file timestamps, we also keep track of when a .d.ts file - // had its file touched but not had its contents changed - this allows us - // to skip a downstream typecheck - if (isDeclarationFile(output)) { - var outputModifiedTime = host.getModifiedTime(output) || ts.missingFileModifiedTime; - newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime); + if (!force) { + for (var _b = 0, outputs_1 = outputs; _b < outputs_1.length; _b++) { + var output = outputs_1[_b]; + // Output is missing; can stop checking + // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status + if (!host.fileExists(output)) { + missingOutputFileName = output; + break; + } + var outputTime = ts.getModifiedTime(host, output); + if (outputTime < oldestOutputFileTime) { + oldestOutputFileTime = outputTime; + oldestOutputFileName = output; + } + // If an output is older than the newest input, we can stop checking + // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status + if (outputTime < newestInputFileTime) { + isOutOfDateWithInputs = true; + break; + } + if (outputTime > newestOutputFileTime) { + newestOutputFileTime = outputTime; + newestOutputFileName = output; + } + // Keep track of when the most recent time a .d.ts file was changed. + // In addition to file timestamps, we also keep track of when a .d.ts file + // had its file touched but not had its contents changed - this allows us + // to skip a downstream typecheck + if (isDeclarationFile(output)) { + var outputModifiedTime = ts.getModifiedTime(host, output); + newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime); + } } } var pseudoUpToDate = false; @@ -113674,7 +117628,8 @@ var ts; }; } // Check oldest output file name only if there is no missing output file name - if (!missingOutputFileName) { + // (a check we will have skipped if this is a forced build) + if (!force && !missingOutputFileName) { // If the upstream project's newest file is older than our oldest output, we // can't be out of date because of it if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) { @@ -113720,7 +117675,7 @@ var ts; if (extendedConfigStatus) return extendedConfigStatus; } - if (!state.buildInfoChecked.has(resolvedPath)) { + if (!force && !state.buildInfoChecked.has(resolvedPath)) { state.buildInfoChecked.set(resolvedPath, true); var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options); if (buildInfoPath) { @@ -113765,6 +117720,8 @@ var ts; return actual; } function updateOutputTimestampsWorker(state, proj, priorNewestUpdateTime, verboseMessage, skipOutputs) { + if (proj.options.noEmit) + return priorNewestUpdateTime; var host = state.host; var outputs = ts.getAllProjectOutputs(proj, !host.useCaseSensitiveFileNames()); if (!skipOutputs || outputs.length !== skipOutputs.size) { @@ -113780,7 +117737,7 @@ var ts; reportStatus(state, verboseMessage, proj.options.configFilePath); } if (isDeclarationFile(file)) { - priorNewestUpdateTime = newer(priorNewestUpdateTime, host.getModifiedTime(file) || ts.missingFileModifiedTime); + priorNewestUpdateTime = newer(priorNewestUpdateTime, ts.getModifiedTime(host, file)); } host.setModifiedTime(file, now); } @@ -113862,7 +117819,7 @@ var ts; } } } - function build(state, project, cancellationToken, onlyReferences) { + function build(state, project, cancellationToken, writeFile, getCustomTransformers, onlyReferences) { var buildOrder = getBuildOrderFor(state, project, onlyReferences); if (!buildOrder) return ts.ExitStatus.InvalidProject_OutputsSkipped; @@ -113874,7 +117831,7 @@ var ts; if (!invalidatedProject) break; reportQueue = false; - invalidatedProject.done(cancellationToken); + invalidatedProject.done(cancellationToken, writeFile, getCustomTransformers === null || getCustomTransformers === void 0 ? void 0 : getCustomTransformers(invalidatedProject.project)); if (!state.diagnostics.has(invalidatedProject.projectPath)) successfulProjects++; } @@ -113909,8 +117866,14 @@ var ts; continue; } var outputs = ts.getAllProjectOutputs(parsed, !host.useCaseSensitiveFileNames()); + if (!outputs.length) + continue; + var inputFileNames = new ts.Set(parsed.fileNames.map(function (f) { return toPath(state, f); })); for (var _a = 0, outputs_3 = outputs; _a < outputs_3.length; _a++) { var output = outputs_3[_a]; + // If output name is same as input file name, do not delete and ignore the error + if (inputFileNames.has(toPath(state, output))) + continue; if (host.fileExists(output)) { if (filesToDelete) { filesToDelete.push(output); @@ -113986,7 +117949,7 @@ var ts; }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.ConfigFile, resolved)); } function watchExtendedConfigFiles(state, resolvedPath, parsed) { - ts.updateSharedExtendedConfigFileWatcher(resolvedPath, parsed, state.allWatchedExtendedConfigFiles, function (extendedConfigFileName, extendedConfigFilePath) { return state.watchFile(extendedConfigFileName, function () { + ts.updateSharedExtendedConfigFileWatcher(resolvedPath, parsed === null || parsed === void 0 ? void 0 : parsed.options, state.allWatchedExtendedConfigFiles, function (extendedConfigFileName, extendedConfigFilePath) { return state.watchFile(extendedConfigFileName, function () { var _a; return (_a = state.allWatchedExtendedConfigFiles.get(extendedConfigFilePath)) === null || _a === void 0 ? void 0 : _a.projects.forEach(function (projectConfigFilePath) { return invalidateProjectAndScheduleBuilds(state, projectConfigFilePath, ts.ConfigFileProgramReloadLevel.Full); @@ -113997,6 +117960,7 @@ var ts; if (!state.watch) return; ts.updateWatchingWildcardDirectories(getOrCreateValueMapFromConfigFileMap(state.allWatchedWildcardDirectories, resolvedPath), new ts.Map(ts.getEntries(parsed.wildcardDirectories)), function (dir, flags) { return state.watchDirectory(dir, function (fileOrDirectory) { + var _a; if (ts.isIgnoredFileFromWildCardWatching({ watchedDirPath: toPath(state, dir), fileOrDirectory: fileOrDirectory, @@ -114004,9 +117968,10 @@ var ts; configFileName: resolved, currentDirectory: state.currentDirectory, options: parsed.options, - program: state.builderPrograms.get(resolvedPath), + program: state.builderPrograms.get(resolvedPath) || ((_a = getCachedParsedConfigFile(state, resolvedPath)) === null || _a === void 0 ? void 0 : _a.fileNames), useCaseSensitiveFileNames: state.parseConfigFileHost.useCaseSensitiveFileNames, - writeLog: function (s) { return state.writeLog(s); } + writeLog: function (s) { return state.writeLog(s); }, + toPath: function (fileName) { return toPath(state, fileName); } })) return; invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.Partial); @@ -114041,19 +118006,16 @@ var ts; } function stopWatching(state) { ts.clearMap(state.allWatchedConfigFiles, ts.closeFileWatcher); - ts.clearMap(state.allWatchedExtendedConfigFiles, function (watcher) { - watcher.projects.clear(); - watcher.close(); - }); + ts.clearMap(state.allWatchedExtendedConfigFiles, ts.closeFileWatcherOf); ts.clearMap(state.allWatchedWildcardDirectories, function (watchedWildcardDirectories) { return ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcherOf); }); ts.clearMap(state.allWatchedInputFiles, function (watchedWildcardDirectories) { return ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcher); }); } function createSolutionBuilderWorker(watch, hostOrHostWithWatch, rootNames, options, baseWatchOptions) { var state = createSolutionBuilderState(watch, hostOrHostWithWatch, rootNames, options, baseWatchOptions); return { - build: function (project, cancellationToken) { return build(state, project, cancellationToken); }, + build: function (project, cancellationToken, writeFile, getCustomTransformers) { return build(state, project, cancellationToken, writeFile, getCustomTransformers); }, clean: function (project) { return clean(state, project); }, - buildReferences: function (project, cancellationToken) { return build(state, project, cancellationToken, /*onlyReferences*/ true); }, + buildReferences: function (project, cancellationToken, writeFile, getCustomTransformers) { return build(state, project, cancellationToken, writeFile, getCustomTransformers, /*onlyReferences*/ true); }, cleanReferences: function (project) { return clean(state, project, /*onlyReferences*/ true); }, getNextInvalidatedProject: function (cancellationToken) { setupInitialBuild(state, cancellationToken); @@ -114143,6 +118105,9 @@ var ts; } } function reportUpToDateStatus(state, configFileName, status) { + if (state.options.force && (status.type === ts.UpToDateStatusType.UpToDate || status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes)) { + return reportStatus(state, ts.Diagnostics.Project_0_is_being_forcibly_rebuilt, relName(state, configFileName)); + } switch (status.type) { case ts.UpToDateStatusType.OutOfDateWithSelf: return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, relName(state, configFileName), relName(state, status.outOfDateOutputFileName), relName(state, status.newerInputFileName)); @@ -114317,6 +118282,9 @@ var ts; SymbolDisplayPartKind[SymbolDisplayPartKind["enumMemberName"] = 19] = "enumMemberName"; SymbolDisplayPartKind[SymbolDisplayPartKind["functionName"] = 20] = "functionName"; SymbolDisplayPartKind[SymbolDisplayPartKind["regularExpressionLiteral"] = 21] = "regularExpressionLiteral"; + SymbolDisplayPartKind[SymbolDisplayPartKind["link"] = 22] = "link"; + SymbolDisplayPartKind[SymbolDisplayPartKind["linkName"] = 23] = "linkName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["linkText"] = 24] = "linkText"; })(SymbolDisplayPartKind = ts.SymbolDisplayPartKind || (ts.SymbolDisplayPartKind = {})); var OutliningSpanKind; (function (OutliningSpanKind) { @@ -114427,6 +118395,12 @@ var ts; ScriptElementKind["jsxAttribute"] = "JSX attribute"; /** String literal */ ScriptElementKind["string"] = "string"; + /** Jsdoc @link: in `{@link C link text}`, the before and after text "{@link " and "}" */ + ScriptElementKind["link"] = "link"; + /** Jsdoc @link: in `{@link C link text}`, the entity name "C" */ + ScriptElementKind["linkName"] = "link name"; + /** Jsdoc @link: in `{@link C link text}`, the link text "link text" */ + ScriptElementKind["linkText"] = "link text"; })(ScriptElementKind = ts.ScriptElementKind || (ts.ScriptElementKind = {})); var ScriptElementKindModifier; (function (ScriptElementKindModifier) { @@ -114519,37 +118493,37 @@ var ts; })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return ts.isInJSFile(node) && ts.getJSDocEnumTag(node) ? 7 /* All */ : 1 /* Value */; - case 160 /* Parameter */: - case 198 /* BindingElement */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 288 /* PropertyAssignment */: - case 289 /* ShorthandPropertyAssignment */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 287 /* CatchClause */: - case 280 /* JsxAttribute */: + case 162 /* Parameter */: + case 200 /* BindingElement */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 290 /* PropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 289 /* CatchClause */: + case 282 /* JsxAttribute */: return 1 /* Value */; - case 159 /* TypeParameter */: - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 177 /* TypeLiteral */: + case 161 /* TypeParameter */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 179 /* TypeLiteral */: return 2 /* Type */; - case 331 /* JSDocTypedefTag */: + case 339 /* 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 291 /* EnumMember */: - case 252 /* ClassDeclaration */: + case 293 /* EnumMember */: + case 254 /* ClassDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -114559,16 +118533,16 @@ var ts; else { return 4 /* Namespace */; } - case 255 /* EnumDeclaration */: - case 264 /* NamedImports */: - case 265 /* ImportSpecifier */: - case 260 /* ImportEqualsDeclaration */: - case 261 /* ImportDeclaration */: - case 266 /* ExportAssignment */: - case 267 /* ExportDeclaration */: + case 257 /* EnumDeclaration */: + case 266 /* NamedImports */: + case 267 /* ImportSpecifier */: + case 262 /* ImportEqualsDeclaration */: + case 263 /* ImportDeclaration */: + case 268 /* ExportAssignment */: + case 269 /* ExportDeclaration */: return 7 /* All */; // An external module can be a Value - case 297 /* SourceFile */: + case 299 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 7 /* All */; @@ -114576,13 +118550,13 @@ var ts; ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { node = getAdjustedReferenceLocation(node); - if (node.kind === 297 /* SourceFile */) { + if (node.kind === 299 /* SourceFile */) { return 1 /* Value */; } - else if (node.parent.kind === 266 /* ExportAssignment */ - || node.parent.kind === 272 /* ExternalModuleReference */ - || node.parent.kind === 265 /* ImportSpecifier */ - || node.parent.kind === 262 /* ImportClause */ + else if (node.parent.kind === 268 /* ExportAssignment */ + || node.parent.kind === 274 /* ExternalModuleReference */ + || node.parent.kind === 267 /* ImportSpecifier */ + || node.parent.kind === 264 /* ImportClause */ || ts.isImportEqualsDeclaration(node.parent) && node === node.parent.name) { return 7 /* All */; } @@ -114592,7 +118566,7 @@ var ts; else if (ts.isDeclarationName(node)) { return getMeaningFromDeclaration(node.parent); } - else if (ts.isEntityName(node) && ts.isJSDocNameReference(node.parent)) { + else if (ts.isEntityName(node) && ts.findAncestor(node, ts.or(ts.isJSDocNameReference, ts.isJSDocLinkLike, ts.isJSDocMemberName))) { return 7 /* All */; } else if (isTypeReference(node)) { @@ -114618,11 +118592,11 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - var name = node.kind === 157 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; - return name && name.parent.kind === 260 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; + var name = node.kind === 159 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; + return name && name.parent.kind === 262 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; } function isInRightSideOfInternalImportEqualsDeclaration(node) { - while (node.parent.kind === 157 /* QualifiedName */) { + while (node.parent.kind === 159 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -114634,27 +118608,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 157 /* QualifiedName */) { - while (root.parent && root.parent.kind === 157 /* QualifiedName */) { + if (root.parent.kind === 159 /* QualifiedName */) { + while (root.parent && root.parent.kind === 159 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 173 /* TypeReference */ && !isLastClause; + return root.parent.kind === 175 /* TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 201 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 201 /* PropertyAccessExpression */) { + if (root.parent.kind === 203 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 203 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 223 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 286 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 225 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 288 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 252 /* ClassDeclaration */ && root.parent.parent.token === 116 /* ImplementsKeyword */) || - (decl.kind === 253 /* InterfaceDeclaration */ && root.parent.parent.token === 93 /* ExtendsKeyword */); + return (decl.kind === 254 /* ClassDeclaration */ && root.parent.parent.token === 117 /* ImplementsKeyword */) || + (decl.kind === 255 /* InterfaceDeclaration */ && root.parent.parent.token === 94 /* ExtendsKeyword */); } return false; } @@ -114663,17 +118637,17 @@ var ts; node = node.parent; } switch (node.kind) { - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: return !ts.isExpressionNode(node); - case 187 /* ThisType */: + case 189 /* ThisType */: return true; } switch (node.parent.kind) { - case 173 /* TypeReference */: + case 175 /* TypeReference */: return true; - case 195 /* ImportType */: + case 197 /* ImportType */: return !node.parent.isTypeOf; - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: return !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent); } return false; @@ -114740,7 +118714,7 @@ var ts; ts.climbPastPropertyOrElementAccess = climbPastPropertyOrElementAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 245 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { + if (referenceNode.kind === 247 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -114801,22 +118775,22 @@ var ts; ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { switch (node.parent.kind) { - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 288 /* PropertyAssignment */: - case 291 /* EnumMember */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 256 /* ModuleDeclaration */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 290 /* PropertyAssignment */: + case 293 /* EnumMember */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 258 /* ModuleDeclaration */: return ts.getNameOfDeclaration(node.parent) === node; - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: return node.parent.argumentExpression === node; - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return true; - case 191 /* LiteralType */: - return node.parent.parent.kind === 189 /* IndexedAccessType */; + case 193 /* LiteralType */: + return node.parent.parent.kind === 191 /* IndexedAccessType */; default: return false; } @@ -114840,17 +118814,17 @@ var ts; return undefined; } switch (node.kind) { - case 297 /* SourceFile */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - case 256 /* ModuleDeclaration */: + case 299 /* SourceFile */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 257 /* EnumDeclaration */: + case 258 /* ModuleDeclaration */: return node; } } @@ -114858,54 +118832,54 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 297 /* SourceFile */: + case 299 /* SourceFile */: return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return "module" /* moduleElement */; - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: return "class" /* classElement */; - case 253 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; - case 254 /* TypeAliasDeclaration */: - case 324 /* JSDocCallbackTag */: - case 331 /* JSDocTypedefTag */: + case 255 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; + case 256 /* TypeAliasDeclaration */: + case 332 /* JSDocCallbackTag */: + case 339 /* JSDocTypedefTag */: return "type" /* typeElement */; - case 255 /* EnumDeclaration */: return "enum" /* enumElement */; - case 249 /* VariableDeclaration */: + case 257 /* EnumDeclaration */: return "enum" /* enumElement */; + case 251 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 198 /* BindingElement */: + case 200 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 209 /* ArrowFunction */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: return "function" /* functionElement */; - case 167 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; - case 168 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 169 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; + case 170 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: return "method" /* memberFunctionElement */; - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: var initializer = node.initializer; return ts.isFunctionLike(initializer) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */; - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 289 /* ShorthandPropertyAssignment */: - case 290 /* SpreadAssignment */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 291 /* ShorthandPropertyAssignment */: + case 292 /* SpreadAssignment */: return "property" /* memberVariableElement */; - case 171 /* IndexSignature */: return "index" /* indexSignatureElement */; - case 170 /* ConstructSignature */: return "construct" /* constructSignatureElement */; - case 169 /* CallSignature */: return "call" /* callSignatureElement */; - case 166 /* Constructor */: return "constructor" /* constructorImplementationElement */; - case 159 /* TypeParameter */: return "type parameter" /* typeParameterElement */; - case 291 /* EnumMember */: return "enum member" /* enumMemberElement */; - case 160 /* Parameter */: return ts.hasSyntacticModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; - case 260 /* ImportEqualsDeclaration */: - case 265 /* ImportSpecifier */: - case 270 /* ExportSpecifier */: - case 263 /* NamespaceImport */: - case 269 /* NamespaceExport */: + case 173 /* IndexSignature */: return "index" /* indexSignatureElement */; + case 172 /* ConstructSignature */: return "construct" /* constructSignatureElement */; + case 171 /* CallSignature */: return "call" /* callSignatureElement */; + case 168 /* Constructor */: return "constructor" /* constructorImplementationElement */; + case 161 /* TypeParameter */: return "type parameter" /* typeParameterElement */; + case 293 /* EnumMember */: return "enum member" /* enumMemberElement */; + case 162 /* Parameter */: return ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; + case 262 /* ImportEqualsDeclaration */: + case 267 /* ImportSpecifier */: + case 272 /* ExportSpecifier */: + case 265 /* NamespaceImport */: + case 271 /* NamespaceExport */: return "alias" /* alias */; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: var kind = ts.getAssignmentDeclarationKind(node); var right = node.right; switch (kind) { @@ -114932,9 +118906,9 @@ var ts; return "" /* unknown */; } } - case 78 /* Identifier */: + case 79 /* Identifier */: return ts.isImportClause(node.parent) ? "alias" /* alias */ : "" /* unknown */; - case 266 /* ExportAssignment */: + case 268 /* 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; @@ -114952,12 +118926,12 @@ var ts; ts.getNodeKind = getNodeKind; function isThis(node) { switch (node.kind) { - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: // case SyntaxKind.ThisType: TODO: GH#9267 return true; - case 78 /* Identifier */: + case 79 /* Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 160 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 162 /* Parameter */; default: return false; } @@ -115022,42 +118996,42 @@ var ts; return false; } switch (n.kind) { - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - case 200 /* ObjectLiteralExpression */: - case 196 /* ObjectBindingPattern */: - case 177 /* TypeLiteral */: - case 230 /* Block */: - case 257 /* ModuleBlock */: - case 258 /* CaseBlock */: - case 264 /* NamedImports */: - case 268 /* NamedExports */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 257 /* EnumDeclaration */: + case 202 /* ObjectLiteralExpression */: + case 198 /* ObjectBindingPattern */: + case 179 /* TypeLiteral */: + case 232 /* Block */: + case 259 /* ModuleBlock */: + case 260 /* CaseBlock */: + case 266 /* NamedImports */: + case 270 /* NamedExports */: return nodeEndsWith(n, 19 /* CloseBraceToken */, sourceFile); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 204 /* NewExpression */: + case 206 /* NewExpression */: if (!n.arguments) { return true; } // falls through - case 203 /* CallExpression */: - case 207 /* ParenthesizedExpression */: - case 186 /* ParenthesizedType */: + case 205 /* CallExpression */: + case 209 /* ParenthesizedExpression */: + case 188 /* ParenthesizedType */: return nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile); - case 174 /* FunctionType */: - case 175 /* ConstructorType */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 170 /* ConstructSignature */: - case 169 /* CallSignature */: - case 209 /* ArrowFunction */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 172 /* ConstructSignature */: + case 171 /* CallSignature */: + case 211 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -115067,65 +119041,65 @@ 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 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return !!n.body && isCompletedNode(n.body, sourceFile); - case 234 /* IfStatement */: + case 236 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 26 /* SemicolonToken */, sourceFile); - case 199 /* ArrayLiteralExpression */: - case 197 /* ArrayBindingPattern */: - case 202 /* ElementAccessExpression */: - case 158 /* ComputedPropertyName */: - case 179 /* TupleType */: + case 201 /* ArrayLiteralExpression */: + case 199 /* ArrayBindingPattern */: + case 204 /* ElementAccessExpression */: + case 160 /* ComputedPropertyName */: + case 181 /* TupleType */: return nodeEndsWith(n, 23 /* CloseBracketToken */, sourceFile); - case 171 /* IndexSignature */: + case 173 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 23 /* CloseBracketToken */, sourceFile); - case 284 /* CaseClause */: - case 285 /* DefaultClause */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 236 /* WhileStatement */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 238 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 235 /* DoStatement */: + case 237 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; - return hasChildOfKind(n, 114 /* WhileKeyword */, sourceFile) + return hasChildOfKind(n, 115 /* WhileKeyword */, sourceFile) ? nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile) : isCompletedNode(n.statement, sourceFile); - case 176 /* TypeQuery */: + case 178 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 211 /* TypeOfExpression */: - case 210 /* DeleteExpression */: - case 212 /* VoidExpression */: - case 219 /* YieldExpression */: - case 220 /* SpreadElement */: + case 213 /* TypeOfExpression */: + case 212 /* DeleteExpression */: + case 214 /* VoidExpression */: + case 221 /* YieldExpression */: + case 222 /* SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 218 /* TemplateExpression */: + case 220 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 228 /* TemplateSpan */: + case 230 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 267 /* ExportDeclaration */: - case 261 /* ImportDeclaration */: + case 269 /* ExportDeclaration */: + case 263 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -115185,13 +119159,13 @@ var ts; } ts.findContainingList = findContainingList; function isDefaultModifier(node) { - return node.kind === 87 /* DefaultKeyword */; + return node.kind === 88 /* DefaultKeyword */; } function isClassKeyword(node) { - return node.kind === 83 /* ClassKeyword */; + return node.kind === 84 /* ClassKeyword */; } function isFunctionKeyword(node) { - return node.kind === 97 /* FunctionKeyword */; + return node.kind === 98 /* FunctionKeyword */; } function getAdjustedLocationForClass(node) { if (ts.isNamedDeclaration(node)) { @@ -115251,11 +119225,11 @@ var ts; function getAdjustedLocationForDeclaration(node, forRename) { if (!forRename) { switch (node.kind) { - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: return getAdjustedLocationForClass(node); - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: return getAdjustedLocationForFunction(node); } } @@ -115345,30 +119319,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 !== 87 /* DefaultKeyword */) ? ts.contains(parent.modifiers, node) : - node.kind === 83 /* ClassKeyword */ ? ts.isClassDeclaration(parent) || ts.isClassExpression(node) : - node.kind === 97 /* FunctionKeyword */ ? ts.isFunctionDeclaration(parent) || ts.isFunctionExpression(node) : - node.kind === 117 /* InterfaceKeyword */ ? ts.isInterfaceDeclaration(parent) : - node.kind === 91 /* EnumKeyword */ ? ts.isEnumDeclaration(parent) : - node.kind === 149 /* TypeKeyword */ ? ts.isTypeAliasDeclaration(parent) : - node.kind === 140 /* NamespaceKeyword */ || node.kind === 139 /* ModuleKeyword */ ? ts.isModuleDeclaration(parent) : - node.kind === 99 /* ImportKeyword */ ? ts.isImportEqualsDeclaration(parent) : - node.kind === 134 /* GetKeyword */ ? ts.isGetAccessorDeclaration(parent) : - node.kind === 146 /* SetKeyword */ && ts.isSetAccessorDeclaration(parent)) { + if (ts.isModifier(node) && (forRename || node.kind !== 88 /* DefaultKeyword */) ? 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 === 150 /* TypeKeyword */ ? ts.isTypeAliasDeclaration(parent) : + node.kind === 141 /* NamespaceKeyword */ || node.kind === 140 /* ModuleKeyword */ ? ts.isModuleDeclaration(parent) : + node.kind === 100 /* ImportKeyword */ ? ts.isImportEqualsDeclaration(parent) : + node.kind === 135 /* GetKeyword */ ? ts.isGetAccessorDeclaration(parent) : + node.kind === 147 /* SetKeyword */ && ts.isSetAccessorDeclaration(parent)) { var location = getAdjustedLocationForDeclaration(parent, forRename); if (location) { return location; } } // /**/ [|name|] ... - if ((node.kind === 112 /* VarKeyword */ || node.kind === 84 /* ConstKeyword */ || node.kind === 118 /* LetKeyword */) && + if ((node.kind === 113 /* VarKeyword */ || node.kind === 85 /* ConstKeyword */ || node.kind === 119 /* LetKeyword */) && ts.isVariableDeclarationList(parent) && parent.declarations.length === 1) { var decl = parent.declarations[0]; if (ts.isIdentifier(decl.name)) { return decl.name; } } - if (node.kind === 149 /* TypeKeyword */) { + if (node.kind === 150 /* TypeKeyword */) { // import /**/type [|name|] from ...; // import /**/type { [|name|] } from ...; // import /**/type { propertyName as [|name|] } from ...; @@ -115394,7 +119368,7 @@ var ts; // import * /**/as [|name|] ... // export { propertyName /**/as [|name|] } ... // export * /**/as [|name|] ... - if (node.kind === 126 /* AsKeyword */) { + if (node.kind === 127 /* AsKeyword */) { if (ts.isImportSpecifier(parent) && parent.propertyName || ts.isExportSpecifier(parent) && parent.propertyName || ts.isNamespaceImport(parent) || @@ -115410,13 +119384,13 @@ var ts; // /**/import { propertyName as [|name|] } from ...; // /**/import ... from "[|module|]"; // /**/import "[|module|]"; - if (node.kind === 99 /* ImportKeyword */ && ts.isImportDeclaration(parent)) { + if (node.kind === 100 /* ImportKeyword */ && ts.isImportDeclaration(parent)) { var location = getAdjustedLocationForImportDeclaration(parent, forRename); if (location) { return location; } } - if (node.kind === 92 /* ExportKeyword */) { + if (node.kind === 93 /* ExportKeyword */) { // /**/export { [|name|] } ...; // /**/export { propertyName as [|name|] } ...; // /**/export * from "[|module|]"; @@ -115435,12 +119409,12 @@ var ts; } } // import name = /**/require("[|module|]"); - if (node.kind === 143 /* RequireKeyword */ && ts.isExternalModuleReference(parent)) { + if (node.kind === 144 /* RequireKeyword */ && ts.isExternalModuleReference(parent)) { return parent.expression; } // import ... /**/from "[|module|]"; // export ... /**/from "[|module|]"; - if (node.kind === 153 /* FromKeyword */ && (ts.isImportDeclaration(parent) || ts.isExportDeclaration(parent)) && parent.moduleSpecifier) { + if (node.kind === 154 /* FromKeyword */ && (ts.isImportDeclaration(parent) || ts.isExportDeclaration(parent)) && parent.moduleSpecifier) { return parent.moduleSpecifier; } // class ... /**/extends [|name|] ... @@ -115448,13 +119422,13 @@ var ts; // class ... /**/implements name1, name2 ... // interface ... /**/extends [|name|] ... // interface ... /**/extends name1, name2 ... - if ((node.kind === 93 /* ExtendsKeyword */ || node.kind === 116 /* ImplementsKeyword */) && ts.isHeritageClause(parent) && parent.token === node.kind) { + if ((node.kind === 94 /* ExtendsKeyword */ || node.kind === 117 /* ImplementsKeyword */) && ts.isHeritageClause(parent) && parent.token === node.kind) { var location = getAdjustedLocationForHeritageClause(parent); if (location) { return location; } } - if (node.kind === 93 /* ExtendsKeyword */) { + if (node.kind === 94 /* ExtendsKeyword */) { // ... ... if (ts.isTypeParameterDeclaration(parent) && parent.constraint && ts.isTypeReferenceNode(parent.constraint)) { return parent.constraint.typeName; @@ -115465,20 +119439,20 @@ var ts; } } // ... T extends /**/infer [|U|] ? ... - if (node.kind === 135 /* InferKeyword */ && ts.isInferTypeNode(parent)) { + if (node.kind === 136 /* InferKeyword */ && ts.isInferTypeNode(parent)) { return parent.typeParameter.name; } // { [ [|K|] /**/in keyof T]: ... } - if (node.kind === 100 /* InKeyword */ && ts.isTypeParameterDeclaration(parent) && ts.isMappedTypeNode(parent.parent)) { + if (node.kind === 101 /* InKeyword */ && ts.isTypeParameterDeclaration(parent) && ts.isMappedTypeNode(parent.parent)) { return parent.name; } // /**/keyof [|T|] - if (node.kind === 138 /* KeyOfKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 138 /* KeyOfKeyword */ && + if (node.kind === 139 /* KeyOfKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 139 /* KeyOfKeyword */ && ts.isTypeReferenceNode(parent.type)) { return parent.type.typeName; } // /**/readonly [|name|][] - if (node.kind === 142 /* ReadonlyKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 142 /* ReadonlyKeyword */ && + if (node.kind === 143 /* ReadonlyKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 143 /* ReadonlyKeyword */ && ts.isArrayTypeNode(parent.type) && ts.isTypeReferenceNode(parent.type.elementType)) { return parent.type.elementType.typeName; } @@ -115493,29 +119467,29 @@ var ts; // /**/yield [|name|] // /**/yield obj.[|name|] // /**/delete obj.[|name|] - if (node.kind === 102 /* NewKeyword */ && ts.isNewExpression(parent) || - node.kind === 113 /* VoidKeyword */ && ts.isVoidExpression(parent) || - node.kind === 111 /* TypeOfKeyword */ && ts.isTypeOfExpression(parent) || - node.kind === 130 /* AwaitKeyword */ && ts.isAwaitExpression(parent) || - node.kind === 124 /* YieldKeyword */ && ts.isYieldExpression(parent) || - node.kind === 88 /* DeleteKeyword */ && ts.isDeleteExpression(parent)) { + if (node.kind === 103 /* NewKeyword */ && ts.isNewExpression(parent) || + node.kind === 114 /* VoidKeyword */ && ts.isVoidExpression(parent) || + node.kind === 112 /* TypeOfKeyword */ && ts.isTypeOfExpression(parent) || + node.kind === 131 /* AwaitKeyword */ && ts.isAwaitExpression(parent) || + node.kind === 125 /* YieldKeyword */ && ts.isYieldExpression(parent) || + node.kind === 89 /* DeleteKeyword */ && ts.isDeleteExpression(parent)) { if (parent.expression) { return ts.skipOuterExpressions(parent.expression); } } // left /**/in [|name|] // left /**/instanceof [|name|] - if ((node.kind === 100 /* InKeyword */ || node.kind === 101 /* InstanceOfKeyword */) && ts.isBinaryExpression(parent) && parent.operatorToken === node) { + if ((node.kind === 101 /* InKeyword */ || node.kind === 102 /* InstanceOfKeyword */) && ts.isBinaryExpression(parent) && parent.operatorToken === node) { return ts.skipOuterExpressions(parent.right); } // left /**/as [|name|] - if (node.kind === 126 /* AsKeyword */ && ts.isAsExpression(parent) && ts.isTypeReferenceNode(parent.type)) { + if (node.kind === 127 /* AsKeyword */ && ts.isAsExpression(parent) && ts.isTypeReferenceNode(parent.type)) { return parent.type.typeName; } // for (... /**/in [|name|]) // for (... /**/of [|name|]) - if (node.kind === 100 /* InKeyword */ && ts.isForInStatement(parent) || - node.kind === 156 /* OfKeyword */ && ts.isForOfStatement(parent)) { + if (node.kind === 101 /* InKeyword */ && ts.isForInStatement(parent) || + node.kind === 158 /* OfKeyword */ && ts.isForOfStatement(parent)) { return ts.skipOuterExpressions(parent.expression); } } @@ -115584,6 +119558,21 @@ var ts; return current; } } + /** + * Returns the first token where position is in [start, end), + * excluding `JsxText` tokens containing only whitespace. + */ + function findFirstNonJsxWhitespaceToken(sourceFile, position) { + var tokenAtPosition = getTokenAtPosition(sourceFile, position); + while (isWhiteSpaceOnlyJsxText(tokenAtPosition)) { + var nextToken = findNextToken(tokenAtPosition, tokenAtPosition.parent, sourceFile); + if (!nextToken) + return; + tokenAtPosition = nextToken; + } + return tokenAtPosition; + } + ts.findFirstNonJsxWhitespaceToken = findFirstNonJsxWhitespaceToken; /** * The token on the left of the position is the token that strictly includes the position * or sits to the left of the cursor if it is on a boundary. For example @@ -115670,7 +119659,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 297 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); + ts.Debug.assert(startNode !== undefined || n.kind === 299 /* SourceFile */ || n.kind === 1 /* 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. @@ -115743,17 +119732,17 @@ var ts; return true; } //
{ |
or
- if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 283 /* JsxExpression */) { + if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 285 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 283 /* JsxExpression */) { + if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 285 /* JsxExpression */) { return true; } //
|
- if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 276 /* JsxClosingElement */) { + if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 278 /* JsxClosingElement */) { return true; } return false; @@ -115784,17 +119773,17 @@ var ts; function isInsideJsxElement(sourceFile, position) { function isInsideJsxElementTraversal(node) { while (node) { - if (node.kind >= 274 /* JsxSelfClosingElement */ && node.kind <= 283 /* JsxExpression */ + if (node.kind >= 276 /* JsxSelfClosingElement */ && node.kind <= 285 /* JsxExpression */ || node.kind === 11 /* JsxText */ || node.kind === 29 /* LessThanToken */ || node.kind === 31 /* GreaterThanToken */ - || node.kind === 78 /* Identifier */ + || node.kind === 79 /* Identifier */ || node.kind === 19 /* CloseBraceToken */ || node.kind === 18 /* OpenBraceToken */ || node.kind === 43 /* SlashToken */) { node = node.parent; } - else if (node.kind === 273 /* JsxElement */) { + else if (node.kind === 275 /* JsxElement */) { if (position > node.getStart(sourceFile)) return true; node = node.parent; @@ -115933,16 +119922,16 @@ var ts; break; case 38 /* EqualsGreaterThanToken */: // falls through - case 78 /* Identifier */: + case 79 /* Identifier */: case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: // falls through - case 111 /* TypeOfKeyword */: - case 93 /* ExtendsKeyword */: - case 138 /* KeyOfKeyword */: + case 112 /* TypeOfKeyword */: + case 94 /* ExtendsKeyword */: + case 139 /* KeyOfKeyword */: case 24 /* DotToken */: case 51 /* BarToken */: case 57 /* QuestionToken */: @@ -116002,16 +119991,16 @@ var ts; result.push("deprecated" /* deprecatedModifier */); if (node.flags & 8388608 /* Ambient */) result.push("declare" /* ambientModifier */); - if (node.kind === 266 /* ExportAssignment */) + if (node.kind === 268 /* ExportAssignment */) result.push("export" /* exportedModifier */); return result.length > 0 ? result.join(",") : "" /* none */; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 173 /* TypeReference */ || node.kind === 203 /* CallExpression */) { + if (node.kind === 175 /* TypeReference */ || node.kind === 205 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 252 /* ClassDeclaration */ || node.kind === 253 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 254 /* ClassDeclaration */ || node.kind === 255 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; @@ -116031,7 +120020,7 @@ var ts; } ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; function isPunctuation(kind) { - return 18 /* FirstPunctuation */ <= kind && kind <= 77 /* LastPunctuation */; + return 18 /* FirstPunctuation */ <= kind && kind <= 78 /* LastPunctuation */; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position, sourceFile) { @@ -116041,9 +120030,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 122 /* PublicKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: + case 123 /* PublicKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: return true; } return false; @@ -116056,18 +120045,18 @@ var ts; } ts.cloneCompilerOptions = cloneCompilerOptions; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 199 /* ArrayLiteralExpression */ || - node.kind === 200 /* ObjectLiteralExpression */) { + if (node.kind === 201 /* ArrayLiteralExpression */ || + node.kind === 202 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 216 /* BinaryExpression */ && + if (node.parent.kind === 218 /* BinaryExpression */ && node.parent.left === node && - node.parent.operatorToken.kind === 62 /* EqualsToken */) { + node.parent.operatorToken.kind === 63 /* EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 239 /* ForOfStatement */ && + if (node.parent.kind === 241 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -116075,7 +120064,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 288 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 290 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -116137,32 +120126,32 @@ var ts; } ts.createTextChange = createTextChange; ts.typeKeywords = [ - 128 /* AnyKeyword */, - 127 /* AssertsKeyword */, - 155 /* BigIntKeyword */, - 131 /* BooleanKeyword */, - 94 /* FalseKeyword */, - 135 /* InferKeyword */, - 138 /* KeyOfKeyword */, - 141 /* NeverKeyword */, - 103 /* NullKeyword */, - 144 /* NumberKeyword */, - 145 /* ObjectKeyword */, - 142 /* ReadonlyKeyword */, - 147 /* StringKeyword */, - 148 /* SymbolKeyword */, - 109 /* TrueKeyword */, - 113 /* VoidKeyword */, - 150 /* UndefinedKeyword */, - 151 /* UniqueKeyword */, - 152 /* UnknownKeyword */, + 129 /* AnyKeyword */, + 128 /* AssertsKeyword */, + 156 /* BigIntKeyword */, + 132 /* BooleanKeyword */, + 95 /* FalseKeyword */, + 136 /* InferKeyword */, + 139 /* KeyOfKeyword */, + 142 /* NeverKeyword */, + 104 /* NullKeyword */, + 145 /* NumberKeyword */, + 146 /* ObjectKeyword */, + 143 /* ReadonlyKeyword */, + 148 /* StringKeyword */, + 149 /* SymbolKeyword */, + 110 /* TrueKeyword */, + 114 /* VoidKeyword */, + 151 /* UndefinedKeyword */, + 152 /* UniqueKeyword */, + 153 /* UnknownKeyword */, ]; function isTypeKeyword(kind) { return ts.contains(ts.typeKeywords, kind); } ts.isTypeKeyword = isTypeKeyword; function isTypeKeywordToken(node) { - return node.kind === 149 /* TypeKeyword */; + return node.kind === 150 /* TypeKeyword */; } ts.isTypeKeywordToken = isTypeKeywordToken; /** True if the symbol is for an external module, as opposed to a namespace. */ @@ -116195,7 +120184,7 @@ var ts; } ts.skipConstraint = skipConstraint; function getNameFromPropertyName(name) { - return name.kind === 158 /* ComputedPropertyName */ + return name.kind === 160 /* 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); @@ -116214,7 +120203,7 @@ var ts; } ts.compilerOptionsIndicateEs6Modules = compilerOptionsIndicateEs6Modules; function createModuleSpecifierResolutionHost(program, host) { - // Mix in `getProbableSymlinks` from Program when host doesn't have it + // Mix in `getSymlinkCache` from Program when host doesn't have it // in order for non-Project hosts to have a symlinks cache. return { fileExists: function (fileName) { return program.fileExists(fileName); }, @@ -116222,6 +120211,7 @@ var ts; readFile: ts.maybeBind(host, host.readFile), useCaseSensitiveFileNames: ts.maybeBind(host, host.useCaseSensitiveFileNames), getSymlinkCache: ts.maybeBind(host, host.getSymlinkCache) || program.getSymlinkCache, + getModuleSpecifierCache: ts.maybeBind(host, host.getModuleSpecifierCache), getGlobalTypingsCacheLocation: ts.maybeBind(host, host.getGlobalTypingsCacheLocation), getSourceFiles: function () { return program.getSourceFiles(); }, redirectTargetsMap: program.redirectTargetsMap, @@ -116292,10 +120282,17 @@ var ts; } return ts.firstDefined(symbol.declarations, function (decl) { var name = ts.getNameOfDeclaration(decl); - return name && name.kind === 78 /* Identifier */ ? name.escapedText : undefined; + return name && name.kind === 79 /* Identifier */ ? name.escapedText : undefined; }); } ts.symbolEscapedNameNoDefault = symbolEscapedNameNoDefault; + function isModuleSpecifierLike(node) { + return ts.isStringLiteralLike(node) && (ts.isExternalModuleReference(node.parent) || + ts.isImportDeclaration(node.parent) || + ts.isRequireCall(node.parent, /*requireStringLiteralLikeArgument*/ false) && node.parent.arguments[0] === node || + ts.isImportCall(node.parent) && node.parent.arguments[0] === node); + } + ts.isModuleSpecifierLike = isModuleSpecifierLike; function isObjectBindingElementWithoutPropertyName(bindingElement) { return ts.isBindingElement(bindingElement) && ts.isObjectBindingPattern(bindingElement.parent) && @@ -116329,7 +120326,7 @@ var ts; ts.findModifier = findModifier; function insertImports(changes, sourceFile, imports, blankLineBetween) { var decl = ts.isArray(imports) ? imports[0] : imports; - var importKindPredicate = decl.kind === 232 /* VariableStatement */ ? ts.isRequireVariableStatement : ts.isAnyImportSyntax; + var importKindPredicate = decl.kind === 234 /* 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) { @@ -116407,7 +120404,7 @@ var ts; // Display-part writer helpers // #region function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 160 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 162 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -116455,7 +120452,7 @@ var ts; increaseIndent: function () { indent++; }, decreaseIndent: function () { indent--; }, clear: resetWriter, - trackSymbol: ts.noop, + trackSymbol: function () { return false; }, reportInaccessibleThisError: ts.noop, reportInaccessibleUniqueSymbolError: ts.noop, reportPrivateInBaseOfClassExpression: ts.noop, @@ -116570,6 +120567,14 @@ var ts; return displayPart(ts.tokenToString(kind), ts.SymbolDisplayPartKind.operator); } ts.operatorPart = operatorPart; + function parameterNamePart(text) { + return displayPart(text, ts.SymbolDisplayPartKind.parameterName); + } + ts.parameterNamePart = parameterNamePart; + function propertyNamePart(text) { + return displayPart(text, ts.SymbolDisplayPartKind.propertyName); + } + ts.propertyNamePart = propertyNamePart; function textOrKeywordPart(text) { var kind = ts.stringToToken(text); return kind === undefined @@ -116581,6 +120586,61 @@ var ts; return displayPart(text, ts.SymbolDisplayPartKind.text); } ts.textPart = textPart; + function typeAliasNamePart(text) { + return displayPart(text, ts.SymbolDisplayPartKind.aliasName); + } + ts.typeAliasNamePart = typeAliasNamePart; + function typeParameterNamePart(text) { + return displayPart(text, ts.SymbolDisplayPartKind.typeParameterName); + } + ts.typeParameterNamePart = typeParameterNamePart; + function linkTextPart(text) { + return displayPart(text, ts.SymbolDisplayPartKind.linkText); + } + ts.linkTextPart = linkTextPart; + function linkNamePart(name, target) { + return { + text: ts.getTextOfNode(name), + kind: ts.SymbolDisplayPartKind[ts.SymbolDisplayPartKind.linkName], + target: { + fileName: ts.getSourceFileOfNode(target).fileName, + textSpan: createTextSpanFromNode(target), + }, + }; + } + ts.linkNamePart = linkNamePart; + function linkPart(text) { + return displayPart(text, ts.SymbolDisplayPartKind.link); + } + ts.linkPart = linkPart; + function buildLinkParts(link, checker) { + var _a; + var prefix = ts.isJSDocLink(link) ? "link" + : ts.isJSDocLinkCode(link) ? "linkcode" + : "linkplain"; + var parts = [linkPart("{@" + prefix + " ")]; + if (!link.name) { + if (link.text) { + parts.push(linkTextPart(link.text)); + } + } + else { + var symbol = checker === null || checker === void 0 ? void 0 : checker.getSymbolAtLocation(link.name); + var decl = (symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration) || ((_a = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]); + if (decl) { + parts.push(linkNamePart(link.name, decl)); + if (link.text) { + parts.push(linkTextPart(link.text)); + } + } + else { + parts.push(linkTextPart(ts.getTextOfNode(link.name) + " " + link.text)); + } + } + parts.push(linkPart("}")); + return parts; + } + ts.buildLinkParts = buildLinkParts; var carriageReturnLineFeed = "\r\n"; /** * The default is CRLF. @@ -116866,21 +120926,23 @@ var ts; } /* @internal */ function needsParentheses(expression) { - return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 27 /* CommaToken */ || ts.isObjectLiteralExpression(expression); + return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 27 /* CommaToken */ + || ts.isObjectLiteralExpression(expression) + || ts.isAsExpression(expression) && ts.isObjectLiteralExpression(expression.expression); } ts.needsParentheses = needsParentheses; function getContextualTypeFromParent(node, checker) { var parent = node.parent; switch (parent.kind) { - case 204 /* NewExpression */: + case 206 /* NewExpression */: return checker.getContextualType(parent); - case 216 /* BinaryExpression */: { + case 218 /* 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 284 /* CaseClause */: + case 286 /* CaseClause */: return parent.expression === node ? getSwitchedType(parent, checker) : undefined; default: return checker.getContextualType(node); @@ -116891,7 +120953,7 @@ 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("'", "\\'").replace('\\"', '"') + "'" : quoted; + return quotePreference === 0 /* Single */ ? "'" + ts.stripQuotes(quoted).replace(/'/g, "\\'").replace(/\\"/g, '"') + "'" : quoted; } ts.quote = quote; function isEqualityOperatorKind(kind) { @@ -116910,8 +120972,8 @@ var ts; switch (node.kind) { case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 218 /* TemplateExpression */: - case 205 /* TaggedTemplateExpression */: + case 220 /* TemplateExpression */: + case 207 /* TaggedTemplateExpression */: return true; default: return false; @@ -116934,6 +120996,7 @@ var ts; var res = checker.typeToTypeNode(type, enclosingScope, 1 /* NoTruncation */, { trackSymbol: function (symbol, declaration, meaning) { typeIsAccessible = typeIsAccessible && checker.isSymbolAccessible(symbol, declaration, meaning, /*shouldComputeAliasToMarkVisible*/ false).accessibility === 0 /* Accessible */; + return !typeIsAccessible; }, reportInaccessibleThisError: notAccessible, reportPrivateInBaseOfClassExpression: notAccessible, @@ -116944,41 +121007,41 @@ var ts; } ts.getTypeNodeIfAccessible = getTypeNodeIfAccessible; function syntaxRequiresTrailingCommaOrSemicolonOrASI(kind) { - return kind === 169 /* CallSignature */ - || kind === 170 /* ConstructSignature */ - || kind === 171 /* IndexSignature */ - || kind === 162 /* PropertySignature */ - || kind === 164 /* MethodSignature */; + return kind === 171 /* CallSignature */ + || kind === 172 /* ConstructSignature */ + || kind === 173 /* IndexSignature */ + || kind === 164 /* PropertySignature */ + || kind === 166 /* MethodSignature */; } ts.syntaxRequiresTrailingCommaOrSemicolonOrASI = syntaxRequiresTrailingCommaOrSemicolonOrASI; function syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI(kind) { - return kind === 251 /* FunctionDeclaration */ - || kind === 166 /* Constructor */ - || kind === 165 /* MethodDeclaration */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */; + return kind === 253 /* FunctionDeclaration */ + || kind === 168 /* Constructor */ + || kind === 167 /* MethodDeclaration */ + || kind === 169 /* GetAccessor */ + || kind === 170 /* SetAccessor */; } ts.syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI = syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI; function syntaxRequiresTrailingModuleBlockOrSemicolonOrASI(kind) { - return kind === 256 /* ModuleDeclaration */; + return kind === 258 /* ModuleDeclaration */; } ts.syntaxRequiresTrailingModuleBlockOrSemicolonOrASI = syntaxRequiresTrailingModuleBlockOrSemicolonOrASI; function syntaxRequiresTrailingSemicolonOrASI(kind) { - return kind === 232 /* VariableStatement */ - || kind === 233 /* ExpressionStatement */ - || kind === 235 /* DoStatement */ - || kind === 240 /* ContinueStatement */ - || kind === 241 /* BreakStatement */ - || kind === 242 /* ReturnStatement */ - || kind === 246 /* ThrowStatement */ - || kind === 248 /* DebuggerStatement */ - || kind === 163 /* PropertyDeclaration */ - || kind === 254 /* TypeAliasDeclaration */ - || kind === 261 /* ImportDeclaration */ - || kind === 260 /* ImportEqualsDeclaration */ - || kind === 267 /* ExportDeclaration */ - || kind === 259 /* NamespaceExportDeclaration */ - || kind === 266 /* ExportAssignment */; + return kind === 234 /* VariableStatement */ + || kind === 235 /* ExpressionStatement */ + || kind === 237 /* DoStatement */ + || kind === 242 /* ContinueStatement */ + || kind === 243 /* BreakStatement */ + || kind === 244 /* ReturnStatement */ + || kind === 248 /* ThrowStatement */ + || kind === 250 /* DebuggerStatement */ + || kind === 165 /* PropertyDeclaration */ + || kind === 256 /* TypeAliasDeclaration */ + || kind === 263 /* ImportDeclaration */ + || kind === 262 /* ImportEqualsDeclaration */ + || kind === 269 /* ExportDeclaration */ + || kind === 261 /* NamespaceExportDeclaration */ + || kind === 268 /* ExportAssignment */; } ts.syntaxRequiresTrailingSemicolonOrASI = syntaxRequiresTrailingSemicolonOrASI; ts.syntaxMayBeASICandidate = ts.or(syntaxRequiresTrailingCommaOrSemicolonOrASI, syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI, syntaxRequiresTrailingModuleBlockOrSemicolonOrASI, syntaxRequiresTrailingSemicolonOrASI); @@ -117008,7 +121071,7 @@ var ts; return false; } // See comment in parser’s `parseDoStatement` - if (node.kind === 235 /* DoStatement */) { + if (node.kind === 237 /* DoStatement */) { return true; } var topNode = ts.findAncestor(node, function (ancestor) { return !ancestor.parent; }); @@ -117182,6 +121245,94 @@ var ts; } } ts.createPackageJsonInfo = createPackageJsonInfo; + function createPackageJsonImportFilter(fromFile, host) { + var packageJsons = ((host.getPackageJsonsVisibleToFile && host.getPackageJsonsVisibleToFile(fromFile.fileName)) || getPackageJsonsVisibleToFile(fromFile.fileName, host)).filter(function (p) { return p.parseable; }); + var usesNodeCoreModules; + return { allowsImportingAmbientModule: allowsImportingAmbientModule, allowsImportingSourceFile: allowsImportingSourceFile, allowsImportingSpecifier: allowsImportingSpecifier }; + function moduleSpecifierIsCoveredByPackageJson(specifier) { + var packageName = getNodeModuleRootSpecifier(specifier); + for (var _i = 0, packageJsons_1 = packageJsons; _i < packageJsons_1.length; _i++) { + var packageJson = packageJsons_1[_i]; + if (packageJson.has(packageName) || packageJson.has(ts.getTypesPackageName(packageName))) { + return true; + } + } + return false; + } + function allowsImportingAmbientModule(moduleSymbol, moduleSpecifierResolutionHost) { + if (!packageJsons.length || !moduleSymbol.valueDeclaration) { + return true; + } + var declaringSourceFile = moduleSymbol.valueDeclaration.getSourceFile(); + var declaringNodeModuleName = getNodeModulesPackageNameFromFileName(declaringSourceFile.fileName, moduleSpecifierResolutionHost); + if (typeof declaringNodeModuleName === "undefined") { + return true; + } + var declaredModuleSpecifier = ts.stripQuotes(moduleSymbol.getName()); + if (isAllowedCoreNodeModulesImport(declaredModuleSpecifier)) { + return true; + } + return moduleSpecifierIsCoveredByPackageJson(declaringNodeModuleName) + || moduleSpecifierIsCoveredByPackageJson(declaredModuleSpecifier); + } + function allowsImportingSourceFile(sourceFile, moduleSpecifierResolutionHost) { + if (!packageJsons.length) { + return true; + } + var moduleSpecifier = getNodeModulesPackageNameFromFileName(sourceFile.fileName, moduleSpecifierResolutionHost); + if (!moduleSpecifier) { + return true; + } + return moduleSpecifierIsCoveredByPackageJson(moduleSpecifier); + } + function allowsImportingSpecifier(moduleSpecifier) { + if (!packageJsons.length || isAllowedCoreNodeModulesImport(moduleSpecifier)) { + return true; + } + if (ts.pathIsRelative(moduleSpecifier) || ts.isRootedDiskPath(moduleSpecifier)) { + return true; + } + return moduleSpecifierIsCoveredByPackageJson(moduleSpecifier); + } + function isAllowedCoreNodeModulesImport(moduleSpecifier) { + // If we’re in JavaScript, it can be difficult to tell whether the user wants to import + // from Node core modules or not. We can start by seeing if the user is actually using + // any node core modules, as opposed to simply having @types/node accidentally as a + // dependency of a dependency. + if (ts.isSourceFileJS(fromFile) && ts.JsTyping.nodeCoreModules.has(moduleSpecifier)) { + if (usesNodeCoreModules === undefined) { + usesNodeCoreModules = consumesNodeCoreModules(fromFile); + } + if (usesNodeCoreModules) { + return true; + } + } + return false; + } + function getNodeModulesPackageNameFromFileName(importedFileName, moduleSpecifierResolutionHost) { + if (!ts.stringContains(importedFileName, "node_modules")) { + return undefined; + } + var specifier = ts.moduleSpecifiers.getNodeModulesPackageName(host.getCompilationSettings(), fromFile.path, importedFileName, moduleSpecifierResolutionHost); + if (!specifier) { + return undefined; + } + // Paths here are not node_modules, so we don’t care about them; + // returning anything will trigger a lookup in package.json. + if (!ts.pathIsRelative(specifier) && !ts.isRootedDiskPath(specifier)) { + return getNodeModuleRootSpecifier(specifier); + } + } + function getNodeModuleRootSpecifier(fullSpecifier) { + var components = ts.getPathComponents(ts.getPackageNameFromTypesPackageName(fullSpecifier)).slice(1); + // Scoped packages + if (ts.startsWith(components[0], "@")) { + return components[0] + "/" + components[1]; + } + return components[0]; + } + } + ts.createPackageJsonImportFilter = createPackageJsonImportFilter; function tryParseJson(text) { try { return JSON.parse(text); @@ -117258,9 +121409,9 @@ var ts; } ts.firstOrOnly = firstOrOnly; function getNameForExportedSymbol(symbol, scriptTarget) { - if (symbol.escapedName === "export=" /* ExportEquals */ || symbol.escapedName === "default" /* Default */) { + if (!(symbol.flags & 33554432 /* Transient */) && (symbol.escapedName === "export=" /* ExportEquals */ || symbol.escapedName === "default" /* Default */)) { // Name of "export default foo;" is "foo". Name of "export default 0" is the filename converted to camelCase. - return ts.firstDefined(symbol.declarations, function (d) { return ts.isExportAssignment(d) && ts.isIdentifier(d.expression) ? d.expression.text : undefined; }) + 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; }) || ts.codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget); } return symbol.name; @@ -117324,6 +121475,188 @@ var ts; return ts.isInJSFile(declaration) || !ts.findAncestor(declaration, ts.isGlobalScopeAugmentation); } ts.isNonGlobalDeclaration = isNonGlobalDeclaration; + var ImportKind; + (function (ImportKind) { + ImportKind[ImportKind["Named"] = 0] = "Named"; + ImportKind[ImportKind["Default"] = 1] = "Default"; + ImportKind[ImportKind["Namespace"] = 2] = "Namespace"; + ImportKind[ImportKind["CommonJS"] = 3] = "CommonJS"; + })(ImportKind = ts.ImportKind || (ts.ImportKind = {})); + var ExportKind; + (function (ExportKind) { + ExportKind[ExportKind["Named"] = 0] = "Named"; + ExportKind[ExportKind["Default"] = 1] = "Default"; + ExportKind[ExportKind["ExportEquals"] = 2] = "ExportEquals"; + ExportKind[ExportKind["UMD"] = 3] = "UMD"; + })(ExportKind = ts.ExportKind || (ts.ExportKind = {})); + function createExportMapCache() { + var cache; + var projectVersion; + var usableByFileName; + var wrapped = { + isEmpty: function () { + return !cache; + }, + clear: function () { + cache = undefined; + projectVersion = undefined; + }, + set: function (suggestions, version) { + cache = suggestions; + if (version) { + projectVersion = version; + } + }, + get: function (file, checker, version) { + if (usableByFileName && file !== usableByFileName) { + return undefined; + } + if (version && projectVersion === version) { + return cache; + } + cache === null || cache === void 0 ? void 0 : cache.forEach(function (infos) { + var _a, _b, _c; + for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) { + var info = infos_1[_i]; + // If the symbol/moduleSymbol was a merged symbol, it will have a new identity + // in the checker, even though the symbols to merge are the same (guaranteed by + // cache invalidation in synchronizeHostData). + if ((_a = info.symbol.declarations) === null || _a === void 0 ? void 0 : _a.length) { + info.symbol = checker.getMergedSymbol(info.exportKind === 1 /* Default */ + ? (_b = info.symbol.declarations[0].localSymbol) !== null && _b !== void 0 ? _b : info.symbol.declarations[0].symbol + : info.symbol.declarations[0].symbol); + } + if ((_c = info.moduleSymbol.declarations) === null || _c === void 0 ? void 0 : _c.length) { + info.moduleSymbol = checker.getMergedSymbol(info.moduleSymbol.declarations[0].symbol); + } + } + }); + return cache; + }, + onFileChanged: function (oldSourceFile, newSourceFile, typeAcquisitionEnabled) { + if (fileIsGlobalOnly(oldSourceFile) && fileIsGlobalOnly(newSourceFile)) { + // File is purely global; doesn't affect export map + return false; + } + if (usableByFileName && usableByFileName !== newSourceFile.path || + // If ATA is enabled, auto-imports uses existing imports to guess whether you want auto-imports from node. + // Adding or removing imports from node could change the outcome of that guess, so could change the suggestions list. + typeAcquisitionEnabled && consumesNodeCoreModules(oldSourceFile) !== consumesNodeCoreModules(newSourceFile) || + // Module agumentation and ambient module changes can add or remove exports available to be auto-imported. + // Changes elsewhere in the file can change the *type* of an export in a module augmentation, + // but type info is gathered in getCompletionEntryDetails, which doesn’t use the cache. + !ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations) || + !ambientModuleDeclarationsAreEqual(oldSourceFile, newSourceFile)) { + this.clear(); + return true; + } + usableByFileName = newSourceFile.path; + return false; + }, + }; + if (ts.Debug.isDebugging) { + Object.defineProperty(wrapped, "__cache", { get: function () { return cache; } }); + } + return wrapped; + function fileIsGlobalOnly(file) { + return !file.commonJsModuleIndicator && !file.externalModuleIndicator && !file.moduleAugmentations && !file.ambientModuleNames; + } + function ambientModuleDeclarationsAreEqual(oldSourceFile, newSourceFile) { + if (!ts.arrayIsEqualTo(oldSourceFile.ambientModuleNames, newSourceFile.ambientModuleNames)) { + return false; + } + var oldFileStatementIndex = -1; + var newFileStatementIndex = -1; + var _loop_1 = function (ambientModuleName) { + var isMatchingModuleDeclaration = function (node) { return ts.isNonGlobalAmbientModule(node) && node.name.text === ambientModuleName; }; + oldFileStatementIndex = ts.findIndex(oldSourceFile.statements, isMatchingModuleDeclaration, oldFileStatementIndex + 1); + newFileStatementIndex = ts.findIndex(newSourceFile.statements, isMatchingModuleDeclaration, newFileStatementIndex + 1); + if (oldSourceFile.statements[oldFileStatementIndex] !== newSourceFile.statements[newFileStatementIndex]) { + return { value: false }; + } + }; + for (var _i = 0, _a = newSourceFile.ambientModuleNames; _i < _a.length; _i++) { + var ambientModuleName = _a[_i]; + var state_1 = _loop_1(ambientModuleName); + if (typeof state_1 === "object") + return state_1.value; + } + return true; + } + } + ts.createExportMapCache = createExportMapCache; + function createModuleSpecifierCache() { + var cache; + var importingFileName; + var wrapped = { + get: function (fromFileName, toFileName) { + if (!cache || fromFileName !== importingFileName) + return undefined; + return cache.get(toFileName); + }, + set: function (fromFileName, toFileName, moduleSpecifiers) { + if (cache && fromFileName !== importingFileName) { + cache.clear(); + } + importingFileName = fromFileName; + (cache || (cache = new ts.Map())).set(toFileName, moduleSpecifiers); + }, + clear: function () { + cache = undefined; + importingFileName = undefined; + }, + count: function () { + return cache ? cache.size : 0; + } + }; + if (ts.Debug.isDebugging) { + Object.defineProperty(wrapped, "__cache", { get: function () { return cache; } }); + } + return wrapped; + } + ts.createModuleSpecifierCache = createModuleSpecifierCache; + function isImportableFile(program, from, to, packageJsonFilter, moduleSpecifierResolutionHost, moduleSpecifierCache) { + var _a; + if (from === to) + return false; + var cachedResult = moduleSpecifierCache === null || moduleSpecifierCache === void 0 ? void 0 : moduleSpecifierCache.get(from.path, to.path); + if (cachedResult !== undefined) { + return !!cachedResult; + } + var getCanonicalFileName = ts.hostGetCanonicalFileName(moduleSpecifierResolutionHost); + var globalTypingsCache = (_a = moduleSpecifierResolutionHost.getGlobalTypingsCacheLocation) === null || _a === void 0 ? void 0 : _a.call(moduleSpecifierResolutionHost); + var hasImportablePath = !!ts.moduleSpecifiers.forEachFileNameOfModule(from.fileName, to.fileName, moduleSpecifierResolutionHost, + /*preferSymlinks*/ false, function (toPath) { + var toFile = program.getSourceFile(toPath); + // Determine to import using toPath only if toPath is what we were looking at + // or there doesnt exist the file in the program by the symlink + return (toFile === to || !toFile) && + isImportablePath(from.fileName, toPath, getCanonicalFileName, globalTypingsCache); + }); + if (packageJsonFilter) { + var isImportable = hasImportablePath && packageJsonFilter.allowsImportingSourceFile(to, moduleSpecifierResolutionHost); + moduleSpecifierCache === null || moduleSpecifierCache === void 0 ? void 0 : moduleSpecifierCache.set(from.path, to.path, isImportable); + return isImportable; + } + return hasImportablePath; + } + ts.isImportableFile = isImportableFile; + /** + * Don't include something from a `node_modules` that isn't actually reachable by a global import. + * A relative import to node_modules is usually a bad idea. + */ + function isImportablePath(fromPath, toPath, getCanonicalFileName, globalCachePath) { + // If it's in a `node_modules` but is not reachable from here via a global import, don't bother. + var toNodeModules = ts.forEachAncestorDirectory(toPath, function (ancestor) { return ts.getBaseFileName(ancestor) === "node_modules" ? ancestor : undefined; }); + var toNodeModulesParent = toNodeModules && ts.getDirectoryPath(getCanonicalFileName(toNodeModules)); + return toNodeModulesParent === undefined + || ts.startsWith(getCanonicalFileName(fromPath), toNodeModulesParent) + || (!!globalCachePath && ts.startsWith(getCanonicalFileName(globalCachePath), toNodeModulesParent)); + } + function isDeprecatedDeclaration(decl) { + return !!(ts.getCombinedNodeFlagsAlwaysIncludeJSDoc(decl) & 8192 /* Deprecated */); + } + ts.isDeprecatedDeclaration = isDeprecatedDeclaration; // #endregion })(ts || (ts = {})); var ts; @@ -117407,13 +121740,13 @@ var ts; function handleToken() { switch (token) { case 43 /* SlashToken */: - case 67 /* SlashEqualsToken */: + case 68 /* SlashEqualsToken */: if (!noRegexTable[lastNonTriviaToken] && scanner.reScanSlashToken() === 13 /* RegularExpressionLiteral */) { token = 13 /* RegularExpressionLiteral */; } break; case 29 /* LessThanToken */: - if (lastNonTriviaToken === 78 /* Identifier */) { + if (lastNonTriviaToken === 79 /* 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++; @@ -117426,16 +121759,16 @@ var ts; angleBracketStack--; } break; - case 128 /* AnyKeyword */: - case 147 /* StringKeyword */: - case 144 /* NumberKeyword */: - case 131 /* BooleanKeyword */: - case 148 /* SymbolKeyword */: + case 129 /* AnyKeyword */: + case 148 /* StringKeyword */: + case 145 /* NumberKeyword */: + case 132 /* BooleanKeyword */: + case 149 /* 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 = 78 /* Identifier */; + token = 79 /* Identifier */; } break; case 15 /* TemplateHead */: @@ -117474,14 +121807,14 @@ var ts; break; } if (lastNonTriviaToken === 24 /* DotToken */) { - token = 78 /* Identifier */; + token = 79 /* 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 = 78 /* Identifier */; + token = 79 /* Identifier */; } } } @@ -117495,19 +121828,19 @@ 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([ - 78 /* Identifier */, + 79 /* Identifier */, 10 /* StringLiteral */, 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 13 /* RegularExpressionLiteral */, - 107 /* ThisKeyword */, + 108 /* ThisKeyword */, 45 /* PlusPlusToken */, 46 /* MinusMinusToken */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 19 /* CloseBraceToken */, - 109 /* TrueKeyword */, - 94 /* FalseKeyword */, + 110 /* TrueKeyword */, + 95 /* FalseKeyword */, ], function (token) { return token; }, function () { return true; }); function getNewEndOfLineState(scanner, token, lastOnTemplateStack) { switch (token) { @@ -117619,10 +121952,10 @@ var ts; return true; } switch (keyword2) { - case 134 /* GetKeyword */: - case 146 /* SetKeyword */: - case 132 /* ConstructorKeyword */: - case 123 /* StaticKeyword */: + case 135 /* GetKeyword */: + case 147 /* SetKeyword */: + case 133 /* ConstructorKeyword */: + case 124 /* 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. @@ -117667,9 +122000,9 @@ var ts; case 31 /* GreaterThanToken */: case 32 /* LessThanEqualsToken */: case 33 /* GreaterThanEqualsToken */: - case 101 /* InstanceOfKeyword */: - case 100 /* InKeyword */: - case 126 /* AsKeyword */: + case 102 /* InstanceOfKeyword */: + case 101 /* InKeyword */: + case 127 /* AsKeyword */: case 34 /* EqualsEqualsToken */: case 35 /* ExclamationEqualsToken */: case 36 /* EqualsEqualsEqualsToken */: @@ -117679,23 +122012,23 @@ var ts; case 51 /* BarToken */: case 55 /* AmpersandAmpersandToken */: case 56 /* BarBarToken */: - case 73 /* BarEqualsToken */: - case 72 /* AmpersandEqualsToken */: - case 77 /* CaretEqualsToken */: - case 69 /* LessThanLessThanEqualsToken */: - case 70 /* GreaterThanGreaterThanEqualsToken */: - case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 63 /* PlusEqualsToken */: - case 64 /* MinusEqualsToken */: - case 65 /* AsteriskEqualsToken */: - case 67 /* SlashEqualsToken */: - case 68 /* PercentEqualsToken */: - case 62 /* EqualsToken */: + 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 74 /* BarBarEqualsToken */: - case 75 /* AmpersandAmpersandEqualsToken */: - case 76 /* QuestionQuestionEqualsToken */: + case 75 /* BarBarEqualsToken */: + case 76 /* AmpersandAmpersandEqualsToken */: + case 77 /* QuestionQuestionEqualsToken */: return true; default: return false; @@ -117721,7 +122054,7 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5 /* operator */; } - else if (token >= 18 /* FirstPunctuation */ && token <= 77 /* LastPunctuation */) { + else if (token >= 18 /* FirstPunctuation */ && token <= 78 /* LastPunctuation */) { return 10 /* punctuation */; } switch (token) { @@ -117740,7 +122073,7 @@ var ts; case 5 /* WhitespaceTrivia */: case 4 /* NewLineTrivia */: return 8 /* whiteSpace */; - case 78 /* Identifier */: + case 79 /* Identifier */: default: if (ts.isTemplateLiteralKind(token)) { return 6 /* stringLiteral */; @@ -117765,13 +122098,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 256 /* ModuleDeclaration */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 251 /* FunctionDeclaration */: - case 221 /* ClassExpression */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 258 /* ModuleDeclaration */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 253 /* FunctionDeclaration */: + case 223 /* ClassExpression */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } } @@ -117978,10 +122311,11 @@ var ts; pushClassification(start, width, 1 /* comment */); } function classifyJSDocComment(docComment) { + var _a, _b, _c, _d, _e, _f, _g; var pos = docComment.pos; if (docComment.tags) { - for (var _i = 0, _a = docComment.tags; _i < _a.length; _i++) { - var tag = _a[_i]; + for (var _i = 0, _h = docComment.tags; _i < _h.length; _i++) { + var tag = _h[_i]; // As we walk through each tag, classify the portion of text from the end of // the last tag (or the start of the entire doc comment) as 'comment'. if (tag.pos !== pos) { @@ -117990,22 +122324,56 @@ var ts; pushClassification(tag.pos, 1, 10 /* punctuation */); // "@" pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); // e.g. "param" pos = tag.tagName.end; + var commentStart = tag.tagName.end; switch (tag.kind) { - case 326 /* JSDocParameterTag */: - processJSDocParameterTag(tag); + case 334 /* 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 341 /* JSDocPropertyTag */: + var prop = tag; + commentStart = prop.isNameFirst && ((_b = prop.typeExpression) === null || _b === void 0 ? void 0 : _b.end) || prop.name.end; break; - case 330 /* JSDocTemplateTag */: + case 338 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); pos = tag.end; + commentStart = tag.typeParameters.end; + break; + case 339 /* JSDocTypedefTag */: + var type = tag; + commentStart = ((_c = type.typeExpression) === null || _c === void 0 ? void 0 : _c.kind) === 303 /* 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 329 /* JSDocTypeTag */: + case 332 /* JSDocCallbackTag */: + commentStart = tag.typeExpression.end; + break; + case 337 /* JSDocTypeTag */: processElement(tag.typeExpression); pos = tag.end; + commentStart = tag.typeExpression.end; + break; + case 336 /* JSDocThisTag */: + case 333 /* JSDocEnumTag */: + commentStart = tag.typeExpression.end; break; - case 327 /* JSDocReturnTag */: + case 335 /* JSDocReturnTag */: processElement(tag.typeExpression); pos = tag.end; + commentStart = ((_f = tag.typeExpression) === null || _f === void 0 ? void 0 : _f.end) || commentStart; break; + case 340 /* JSDocSeeTag */: + commentStart = ((_g = tag.name) === null || _g === void 0 ? void 0 : _g.end) || commentStart; + break; + case 322 /* JSDocAugmentsTag */: + case 323 /* JSDocImplementsTag */: + commentStart = tag.class.end; + break; + } + if (typeof tag.comment === "object") { + pushCommentRange(tag.comment.pos, tag.comment.end - tag.comment.pos); + } + else if (typeof tag.comment === "string") { + pushCommentRange(commentStart, tag.end - commentStart); } } } @@ -118033,7 +122401,8 @@ var ts; } function tryClassifyTripleSlashComment(start, width) { var tripleSlashXMLCommentRegEx = /^(\/\/\/\s*)(<)(?:(\S+)((?:[^/]|\/[^>])*)(\/>)?)?/im; - var attributeRegex = /(\S+)(\s*)(=)(\s*)('[^']+'|"[^"]+")/img; + // Require a leading whitespace character (the parser already does) to prevent terrible backtracking performance + var attributeRegex = /(\s)(\S+)(\s*)(=)(\s*)('[^']+'|"[^"]+")/img; var text = sourceFile.text.substr(start, width); var match = tripleSlashXMLCommentRegEx.exec(text); if (!match) { @@ -118061,25 +122430,25 @@ var ts; if (!attrMatch) { break; } - var newAttrPos = pos + attrMatch.index; + var newAttrPos = pos + attrMatch.index + attrMatch[1].length; // whitespace if (newAttrPos > attrPos) { pushCommentRange(attrPos, newAttrPos - attrPos); attrPos = newAttrPos; } - pushClassification(attrPos, attrMatch[1].length, 22 /* jsxAttribute */); // attribute name - attrPos += attrMatch[1].length; - if (attrMatch[2].length) { - pushCommentRange(attrPos, attrMatch[2].length); // whitespace - attrPos += attrMatch[2].length; + pushClassification(attrPos, attrMatch[2].length, 22 /* jsxAttribute */); // attribute name + attrPos += attrMatch[2].length; + if (attrMatch[3].length) { + pushCommentRange(attrPos, attrMatch[3].length); // whitespace + attrPos += attrMatch[3].length; } - pushClassification(attrPos, attrMatch[3].length, 5 /* operator */); // = - attrPos += attrMatch[3].length; - if (attrMatch[4].length) { - pushCommentRange(attrPos, attrMatch[4].length); // whitespace - attrPos += attrMatch[4].length; + pushClassification(attrPos, attrMatch[4].length, 5 /* operator */); // = + attrPos += attrMatch[4].length; + if (attrMatch[5].length) { + pushCommentRange(attrPos, attrMatch[5].length); // whitespace + attrPos += attrMatch[5].length; } - pushClassification(attrPos, attrMatch[5].length, 24 /* jsxAttributeStringLiteralValue */); // attribute value - attrPos += attrMatch[5].length; + pushClassification(attrPos, attrMatch[6].length, 24 /* jsxAttributeStringLiteralValue */); // attribute value + attrPos += attrMatch[6].length; } pos += match[4].length; if (pos > attrPos) { @@ -118153,22 +122522,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 275 /* JsxOpeningElement */: + case 277 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 276 /* JsxClosingElement */: + case 278 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 274 /* JsxSelfClosingElement */: + case 276 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 280 /* JsxAttribute */: + case 282 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -118195,19 +122564,19 @@ var ts; if (ts.isPunctuation(tokenKind)) { if (token) { var parent = token.parent; - if (tokenKind === 62 /* EqualsToken */) { + if (tokenKind === 63 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (parent.kind === 249 /* VariableDeclaration */ || - parent.kind === 163 /* PropertyDeclaration */ || - parent.kind === 160 /* Parameter */ || - parent.kind === 280 /* JsxAttribute */) { + if (parent.kind === 251 /* VariableDeclaration */ || + parent.kind === 165 /* PropertyDeclaration */ || + parent.kind === 162 /* Parameter */ || + parent.kind === 282 /* JsxAttribute */) { return 5 /* operator */; } } - if (parent.kind === 216 /* BinaryExpression */ || - parent.kind === 214 /* PrefixUnaryExpression */ || - parent.kind === 215 /* PostfixUnaryExpression */ || - parent.kind === 217 /* ConditionalExpression */) { + if (parent.kind === 218 /* BinaryExpression */ || + parent.kind === 216 /* PrefixUnaryExpression */ || + parent.kind === 217 /* PostfixUnaryExpression */ || + parent.kind === 219 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -118220,7 +122589,7 @@ var ts; return 25 /* bigintLiteral */; } else if (tokenKind === 10 /* StringLiteral */) { - return token && token.parent.kind === 280 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + return token && token.parent.kind === 282 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } else if (tokenKind === 13 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. @@ -118233,35 +122602,35 @@ var ts; else if (tokenKind === 11 /* JsxText */) { return 23 /* jsxText */; } - else if (tokenKind === 78 /* Identifier */) { + else if (tokenKind === 79 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 159 /* TypeParameter */: + case 161 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 253 /* InterfaceDeclaration */: + case 255 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 160 /* Parameter */: + case 162 /* Parameter */: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; } @@ -118363,13 +122732,13 @@ var ts; var inJSXElement = false; function visit(node) { switch (node.kind) { - case 256 /* ModuleDeclaration */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 251 /* FunctionDeclaration */: - case 221 /* ClassExpression */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 258 /* ModuleDeclaration */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 253 /* FunctionDeclaration */: + case 223 /* ClassExpression */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } if (!node || !ts.textSpanIntersectsWith(span, node.pos, node.getFullWidth()) || node.getFullWidth() === 0) { @@ -118515,25 +122884,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([ - [249 /* VariableDeclaration */, 7 /* variable */], - [160 /* Parameter */, 6 /* parameter */], - [163 /* PropertyDeclaration */, 9 /* property */], - [256 /* ModuleDeclaration */, 3 /* namespace */], - [255 /* EnumDeclaration */, 1 /* enum */], - [291 /* EnumMember */, 8 /* enumMember */], - [252 /* ClassDeclaration */, 0 /* class */], - [165 /* MethodDeclaration */, 11 /* member */], - [251 /* FunctionDeclaration */, 10 /* function */], - [208 /* FunctionExpression */, 10 /* function */], - [164 /* MethodSignature */, 11 /* member */], - [167 /* GetAccessor */, 9 /* property */], - [168 /* SetAccessor */, 9 /* property */], - [162 /* PropertySignature */, 9 /* property */], - [253 /* InterfaceDeclaration */, 2 /* interface */], - [254 /* TypeAliasDeclaration */, 5 /* type */], - [159 /* TypeParameter */, 4 /* typeParameter */], - [288 /* PropertyAssignment */, 9 /* property */], - [289 /* ShorthandPropertyAssignment */, 9 /* property */] + [251 /* VariableDeclaration */, 7 /* variable */], + [162 /* Parameter */, 6 /* parameter */], + [165 /* PropertyDeclaration */, 9 /* property */], + [258 /* ModuleDeclaration */, 3 /* namespace */], + [257 /* EnumDeclaration */, 1 /* enum */], + [293 /* EnumMember */, 8 /* enumMember */], + [254 /* ClassDeclaration */, 0 /* class */], + [167 /* MethodDeclaration */, 11 /* member */], + [253 /* FunctionDeclaration */, 10 /* function */], + [210 /* FunctionExpression */, 10 /* function */], + [166 /* MethodSignature */, 11 /* member */], + [169 /* GetAccessor */, 9 /* property */], + [170 /* SetAccessor */, 9 /* property */], + [164 /* PropertySignature */, 9 /* property */], + [255 /* InterfaceDeclaration */, 2 /* interface */], + [256 /* TypeAliasDeclaration */, 5 /* type */], + [161 /* TypeParameter */, 4 /* typeParameter */], + [290 /* PropertyAssignment */, 9 /* property */], + [291 /* ShorthandPropertyAssignment */, 9 /* property */] ]); })(v2020 = classifier.v2020 || (classifier.v2020 = {})); })(classifier = ts.classifier || (ts.classifier = {})); @@ -118553,12 +122922,12 @@ var ts; if (ts.isInString(sourceFile, position, contextToken)) { if (!contextToken || !ts.isStringLiteralLike(contextToken)) return undefined; - var entries = getStringLiteralCompletionEntries(sourceFile, contextToken, position, checker, options, host); - return convertStringLiteralCompletions(entries, contextToken, sourceFile, checker, log, preferences); + var entries = getStringLiteralCompletionEntries(sourceFile, contextToken, position, checker, options, host, preferences); + return convertStringLiteralCompletions(entries, contextToken, sourceFile, checker, log, options, preferences); } } StringCompletions.getStringLiteralCompletions = getStringLiteralCompletions; - function convertStringLiteralCompletions(completion, contextToken, sourceFile, checker, log, preferences) { + function convertStringLiteralCompletions(completion, contextToken, sourceFile, checker, log, options, preferences) { if (completion === undefined) { return undefined; } @@ -118568,7 +122937,7 @@ var ts; return convertPathCompletions(completion.paths); case 1 /* Properties */: { var entries = []; - Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, sourceFile, sourceFile, checker, 99 /* ESNext */, log, 4 /* String */, preferences); // Target will not be used, so arbitrary + Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, sourceFile, sourceFile, checker, 99 /* ESNext */, log, 4 /* String */, preferences, options); // Target will not be used, so arbitrary return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: completion.hasIndexSignature, optionalReplacementSpan: optionalReplacementSpan, entries: entries }; } case 2 /* Types */: { @@ -118585,10 +122954,10 @@ var ts; return ts.Debug.assertNever(completion); } } - function getStringLiteralCompletionDetails(name, sourceFile, position, contextToken, checker, options, host, cancellationToken) { + function getStringLiteralCompletionDetails(name, sourceFile, position, contextToken, checker, options, host, cancellationToken, preferences) { if (!contextToken || !ts.isStringLiteralLike(contextToken)) return undefined; - var completions = getStringLiteralCompletionEntries(sourceFile, contextToken, position, checker, options, host); + var completions = getStringLiteralCompletionEntries(sourceFile, contextToken, position, checker, options, host, preferences); return completions && stringLiteralCompletionDetails(name, contextToken, completions, sourceFile, checker, cancellationToken); } StringCompletions.getStringLiteralCompletionDetails = getStringLiteralCompletionDetails; @@ -118637,13 +123006,13 @@ var ts; StringLiteralCompletionKind[StringLiteralCompletionKind["Properties"] = 1] = "Properties"; StringLiteralCompletionKind[StringLiteralCompletionKind["Types"] = 2] = "Types"; })(StringLiteralCompletionKind || (StringLiteralCompletionKind = {})); - function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host) { + function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host, preferences) { var parent = walkUpParentheses(node.parent); switch (parent.kind) { - case 191 /* LiteralType */: { + case 193 /* LiteralType */: { var grandParent = walkUpParentheses(parent.parent); switch (grandParent.kind) { - case 173 /* TypeReference */: { + case 175 /* TypeReference */: { var typeReference_1 = grandParent; var typeArgument = ts.findAncestor(parent, function (n) { return n.parent === typeReference_1; }); if (typeArgument) { @@ -118651,7 +123020,7 @@ var ts; } return undefined; } - case 189 /* IndexedAccessType */: + case 191 /* IndexedAccessType */: // Get all apparent property names // i.e. interface Foo { // foo: string; @@ -118663,9 +123032,9 @@ var ts; return undefined; } return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(objectType)); - case 195 /* ImportType */: - return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) }; - case 182 /* UnionType */: { + case 197 /* ImportType */: + return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) }; + case 184 /* UnionType */: { if (!ts.isTypeReferenceNode(grandParent.parent)) { return undefined; } @@ -118677,7 +123046,7 @@ var ts; return undefined; } } - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: if (ts.isObjectLiteralExpression(parent.parent) && parent.name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { @@ -118694,7 +123063,7 @@ var ts; return stringLiteralCompletionsForObjectLiteral(typeChecker, parent.parent); } return fromContextualType(); - case 202 /* ElementAccessExpression */: { + case 204 /* ElementAccessExpression */: { var _b = parent, expression = _b.expression, argumentExpression = _b.argumentExpression; if (node === ts.skipParentheses(argumentExpression)) { // Get all names of properties on the expression @@ -118707,8 +123076,8 @@ var ts; } return undefined; } - case 203 /* CallExpression */: - case 204 /* NewExpression */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: if (!ts.isRequireCall(parent, /*checkArgumentIsStringLiteralLike*/ false) && !ts.isImportCall(parent)) { var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(node, position, sourceFile); // Get string literal completions from specialized signatures of the target @@ -118717,16 +123086,16 @@ var ts; return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo, typeChecker) : fromContextualType(); } // falls through (is `require("")` or `import("")`) - case 261 /* ImportDeclaration */: - case 267 /* ExportDeclaration */: - case 272 /* ExternalModuleReference */: + case 263 /* ImportDeclaration */: + case 269 /* ExportDeclaration */: + case 274 /* 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) }; + return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) }; default: return fromContextualType(); } @@ -118738,9 +123107,9 @@ var ts; } function walkUpParentheses(node) { switch (node.kind) { - case 186 /* ParenthesizedType */: + case 188 /* ParenthesizedType */: return ts.walkUpParenthesizedTypes(node); - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return ts.walkUpParenthesizedExpressions(node); default: return node; @@ -118768,7 +123137,7 @@ var ts; function stringLiteralCompletionsFromProperties(type) { return type && { kind: 1 /* Properties */, - symbols: ts.filter(type.getApparentProperties(), function (prop) { return !(prop.valueDeclaration && ts.isPrivateIdentifierPropertyDeclaration(prop.valueDeclaration)); }), + symbols: ts.filter(type.getApparentProperties(), function (prop) { return !(prop.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(prop.valueDeclaration)); }), hasIndexSignature: ts.hasIndexSignature(type) }; } @@ -118806,23 +123175,23 @@ var ts; return Math.max(name.indexOf(ts.directorySeparator), name.indexOf(ts.altDirectorySeparator)) !== -1 ? { name: name, kind: kind, extension: extension, span: wholeSpan } : { name: name, kind: kind, extension: extension, span: span }; }); } - function getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) { - return addReplacementSpans(node.text, node.getStart(sourceFile) + 1, getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker)); + function getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) { + return addReplacementSpans(node.text, node.getStart(sourceFile) + 1, getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker, preferences)); } - function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker) { + function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker, preferences) { var literalValue = ts.normalizeSlashes(node.text); 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) + ? getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, preferences) : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, compilerOptions, host, typeChecker); } function getExtensionOptions(compilerOptions, includeExtensions) { if (includeExtensions === void 0) { includeExtensions = false; } return { extensions: getSupportedExtensionsForModuleResolution(compilerOptions), includeExtensions: includeExtensions }; } - function getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath) { - var extensionOptions = getExtensionOptions(compilerOptions); + function getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, preferences) { + var extensionOptions = getExtensionOptions(compilerOptions, preferences.importModuleSpecifierEnding === "js"); if (compilerOptions.rootDirs) { return getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, extensionOptions, compilerOptions, host, scriptPath); } @@ -118939,7 +123308,7 @@ var ts; continue; var patterns = paths[path]; if (patterns) { - var _loop_1 = function (name, kind, extension) { + var _loop_2 = function (name, kind, extension) { // Path mappings may provide a duplicate way to get to something we've already added, so don't add again. if (!result.some(function (entry) { return entry.name === name; })) { result.push(nameAndKind(name, kind, extension)); @@ -118947,7 +123316,7 @@ var ts; }; for (var _i = 0, _a = getCompletionsForPathMapping(path, patterns, fragment, baseDirectory, fileExtensions, host); _i < _a.length; _i++) { var _b = _a[_i], name = _b.name, kind = _b.kind, extension = _b.extension; - _loop_1(name, kind, extension); + _loop_2(name, kind, extension); } } } @@ -118982,7 +123351,7 @@ var ts; // (But do if we didn't find anything, e.g. 'package.json' missing.) var foundGlobal = false; if (fragmentDirectory === undefined) { - var _loop_2 = function (moduleName) { + 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)); @@ -118990,7 +123359,7 @@ var ts; }; for (var _b = 0, _c = enumerateNodeModulesVisibleToScript(host, scriptPath); _b < _c.length; _b++) { var moduleName = _c[_b]; - _loop_2(moduleName); + _loop_3(moduleName); } } if (!foundGlobal) { @@ -119025,8 +123394,8 @@ var ts; if (!host.readDirectory) { return undefined; } - var parsed = ts.hasZeroOrOneAsteriskCharacter(pattern) ? ts.tryParsePattern(pattern) : undefined; - if (!parsed) { + var parsed = ts.tryParsePattern(pattern); + if (parsed === undefined || ts.isString(parsed)) { return undefined; } // The prefix has two effective parts: the directory path and the base component after the filepath that is not a @@ -119213,7 +123582,26 @@ var ts; SortText["GlobalsOrKeywords"] = "5"; SortText["AutoImportSuggestions"] = "6"; SortText["JavascriptIdentifiers"] = "7"; + SortText["DeprecatedLocalDeclarationPriority"] = "8"; + SortText["DeprecatedLocationPriority"] = "9"; + SortText["DeprecatedOptionalMember"] = "10"; + SortText["DeprecatedMemberDeclaredBySpreadAssignment"] = "11"; + SortText["DeprecatedSuggestedClassMembers"] = "12"; + SortText["DeprecatedGlobalsOrKeywords"] = "13"; + SortText["DeprecatedAutoImportSuggestions"] = "14"; })(SortText = Completions.SortText || (Completions.SortText = {})); + var SortTextId; + (function (SortTextId) { + SortTextId[SortTextId["LocalDeclarationPriority"] = 0] = "LocalDeclarationPriority"; + SortTextId[SortTextId["LocationPriority"] = 1] = "LocationPriority"; + SortTextId[SortTextId["OptionalMember"] = 2] = "OptionalMember"; + SortTextId[SortTextId["MemberDeclaredBySpreadAssignment"] = 3] = "MemberDeclaredBySpreadAssignment"; + SortTextId[SortTextId["SuggestedClassMembers"] = 4] = "SuggestedClassMembers"; + SortTextId[SortTextId["GlobalsOrKeywords"] = 5] = "GlobalsOrKeywords"; + SortTextId[SortTextId["AutoImportSuggestions"] = 6] = "AutoImportSuggestions"; + })(SortTextId || (SortTextId = {})); + // for JavaScript identifiers since they are preferred over deprecated symbols + var DeprecatedSortTextStart = SortTextId.AutoImportSuggestions + 2; /** * Special values for `CompletionInfo['source']` used to disambiguate * completion items with the same `name`. (Each completion item must @@ -119237,6 +123625,7 @@ var ts; SymbolOriginInfoKind[SymbolOriginInfoKind["Export"] = 4] = "Export"; SymbolOriginInfoKind[SymbolOriginInfoKind["Promise"] = 8] = "Promise"; SymbolOriginInfoKind[SymbolOriginInfoKind["Nullable"] = 16] = "Nullable"; + SymbolOriginInfoKind[SymbolOriginInfoKind["ResolvedExport"] = 32] = "ResolvedExport"; SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberNoExport"] = 2] = "SymbolMemberNoExport"; SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberExport"] = 6] = "SymbolMemberExport"; })(SymbolOriginInfoKind || (SymbolOriginInfoKind = {})); @@ -119249,8 +123638,14 @@ var ts; function originIsExport(origin) { return !!(origin && origin.kind & 4 /* Export */); } + function originIsResolvedExport(origin) { + return !!(origin && origin.kind === 32 /* ResolvedExport */); + } + function originIncludesSymbolName(origin) { + return originIsExport(origin) || originIsResolvedExport(origin); + } function originIsPackageJsonImport(origin) { - return originIsExport(origin) && !!origin.isFromPackageJson; + return (originIsExport(origin) || originIsResolvedExport(origin)) && !!origin.isFromPackageJson; } function originIsPromise(origin) { return !!(origin.kind & 8 /* Promise */); @@ -119276,52 +123671,6 @@ var ts; GlobalsSearch[GlobalsSearch["Success"] = 1] = "Success"; GlobalsSearch[GlobalsSearch["Fail"] = 2] = "Fail"; })(GlobalsSearch || (GlobalsSearch = {})); - function createImportSuggestionsForFileCache() { - var cache; - var projectVersion; - var fileName; - return { - isEmpty: function () { - return !cache; - }, - clear: function () { - cache = undefined; - fileName = undefined; - projectVersion = undefined; - }, - set: function (file, suggestions, version) { - cache = suggestions; - fileName = file; - if (version) { - projectVersion = version; - } - }, - get: function (file, checker, version) { - if (file !== fileName) { - return undefined; - } - if (version) { - return projectVersion === version ? cache : undefined; - } - ts.forEach(cache, function (suggestion) { - var _a, _b, _c; - // If the symbol/moduleSymbol was a merged symbol, it will have a new identity - // in the checker, even though the symbols to merge are the same (guaranteed by - // cache invalidation in synchronizeHostData). - if ((_a = suggestion.symbol.declarations) === null || _a === void 0 ? void 0 : _a.length) { - suggestion.symbol = checker.getMergedSymbol(suggestion.origin.isDefaultExport - ? (_b = suggestion.symbol.declarations[0].localSymbol) !== null && _b !== void 0 ? _b : suggestion.symbol.declarations[0].symbol - : suggestion.symbol.declarations[0].symbol); - } - if ((_c = suggestion.origin.moduleSymbol.declarations) === null || _c === void 0 ? void 0 : _c.length) { - suggestion.origin.moduleSymbol = checker.getMergedSymbol(suggestion.origin.moduleSymbol.declarations[0].symbol); - } - }); - return cache; - }, - }; - } - Completions.createImportSuggestionsForFileCache = createImportSuggestionsForFileCache; function getCompletionsAtPosition(host, program, log, sourceFile, position, preferences, triggerCharacter) { var typeChecker = program.getTypeChecker(); var compilerOptions = program.getCompilerOptions(); @@ -119329,12 +123678,19 @@ var ts; if (triggerCharacter && !ts.isInString(sourceFile, position, contextToken) && !isValidTrigger(sourceFile, triggerCharacter, contextToken, position)) { return undefined; } + if (triggerCharacter === " ") { + // `isValidTrigger` ensures we are at `import |` + if (preferences.includeCompletionsForImportStatements && preferences.includeCompletionsWithInsertText) { + return { isGlobalCompletion: true, isMemberCompletion: false, isNewIdentifierLocation: true, isIncomplete: true, entries: [] }; + } + return undefined; + } var stringCompletions = Completions.StringCompletions.getStringLiteralCompletions(sourceFile, position, contextToken, typeChecker, compilerOptions, host, log, preferences); if (stringCompletions) { return stringCompletions; } if (contextToken && ts.isBreakOrContinueStatement(contextToken.parent) - && (contextToken.kind === 80 /* BreakKeyword */ || contextToken.kind === 85 /* ContinueKeyword */ || contextToken.kind === 78 /* Identifier */)) { + && (contextToken.kind === 81 /* BreakKeyword */ || contextToken.kind === 86 /* ContinueKeyword */ || contextToken.kind === 79 /* Identifier */)) { return getLabelCompletionAtPosition(contextToken.parent); } var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, preferences, /*detailsEntryId*/ undefined, host); @@ -119352,6 +123708,8 @@ var ts; return jsdocCompletionInfo(ts.JsDoc.getJSDocTagCompletions()); case 3 /* JsDocParameterName */: return jsdocCompletionInfo(ts.JsDoc.getJSDocParameterNameCompletions(completionData.tag)); + case 4 /* Keywords */: + return specificKeywordCompletionInfo(completionData.keywords); default: return ts.Debug.assertNever(completionData); } @@ -119360,33 +123718,36 @@ var ts; function jsdocCompletionInfo(entries) { return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: entries }; } + function specificKeywordCompletionInfo(keywords) { + return { + isGlobalCompletion: false, + isMemberCompletion: false, + isNewIdentifierLocation: false, + entries: keywords.map(function (k) { return ({ + name: ts.tokenToString(k), + kind: "keyword" /* keyword */, + kindModifiers: "" /* none */, + sortText: SortText.GlobalsOrKeywords, + }); }), + }; + } function getOptionalReplacementSpan(location) { // StringLiteralLike locations are handled separately in stringCompletions.ts - return (location === null || location === void 0 ? void 0 : location.kind) === 78 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined; + return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined; } function completionInfoFromData(sourceFile, typeChecker, compilerOptions, log, completionData, preferences) { - var symbols = completionData.symbols, 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, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextMap = completionData.symbolToSortTextMap; - if (location && location.parent && ts.isJsxClosingElement(location.parent)) { - // In the TypeScript JSX element, if such element is not defined. When users query for completion at closing tag, - // instead of simply giving unknown value, the completion will return the tag-name of an associated opening-element. - // For example: - // var x =
" with type any - // And at `
` (with a closing `>`), the completion list will contain "div". - var tagName = location.parent.parent.openingElement.tagName; - var hasClosingAngleBracket = !!ts.findChildOfKind(location.parent, 31 /* GreaterThanToken */, sourceFile); - var entry = { - name: tagName.getFullText(sourceFile) + (hasClosingAngleBracket ? "" : ">"), - kind: "class" /* classElement */, - kindModifiers: undefined, - sortText: SortText.LocationPriority, - }; - return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: false, optionalReplacementSpan: getOptionalReplacementSpan(location), entries: [entry] }; + var symbols = completionData.symbols, 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, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextIdMap = completionData.symbolToSortTextIdMap; + // Verify if the file is JSX language variant + if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) { + var completionInfo = getJsxClosingTagCompletion(location, sourceFile); + if (completionInfo) { + return completionInfo; + } } var entries = []; if (isUncheckedFile(sourceFile, compilerOptions)) { var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, - /* contextToken */ undefined, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, propertyAccessToConvert, completionData.isJsxIdentifierExpected, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap); + /* contextToken */ undefined, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap); getJSCompletionEntries(sourceFile, location.pos, uniqueNames, compilerOptions.target, entries); // TODO: GH#18217 } else { @@ -119394,7 +123755,7 @@ var ts; return undefined; } getCompletionEntriesFromSymbols(symbols, entries, - /* contextToken */ undefined, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, propertyAccessToConvert, completionData.isJsxIdentifierExpected, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap); + /* contextToken */ undefined, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap); } if (keywordFilters !== 0 /* None */) { var entryNames = new ts.Set(entries.map(function (e) { return e.name; })); @@ -119430,6 +123791,49 @@ var ts; return false; } } + function getJsxClosingTagCompletion(location, sourceFile) { + // We wanna walk up the tree till we find a JSX closing element + var jsxClosingElement = ts.findAncestor(location, function (node) { + switch (node.kind) { + case 278 /* JsxClosingElement */: + return true; + case 43 /* SlashToken */: + case 31 /* GreaterThanToken */: + case 79 /* Identifier */: + case 203 /* PropertyAccessExpression */: + return false; + default: + return "quit"; + } + }); + if (jsxClosingElement) { + // In the TypeScript JSX element, if such element is not defined. When users query for completion at closing tag, + // instead of simply giving unknown value, the completion will return the tag-name of an associated opening-element. + // For example: + // var x =
" with type any + // And at `
` (with a closing `>`), the completion list will contain "div". + // And at property access expressions ` ` the completion will + // return full closing tag with an optional replacement span + // For example: + // 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 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 */, + kindModifiers: undefined, + sortText: SortText.LocationPriority, + }; + return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: false, optionalReplacementSpan: replacementSpan, entries: [entry] }; + } + return; + } function getJSCompletionEntries(sourceFile, position, uniqueNames, target, entries) { ts.getNameTable(sourceFile).forEach(function (pos, name) { // Skip identifiers produced only from the current location @@ -119456,9 +123860,13 @@ var ts; function createCompletionEntryForLiteral(sourceFile, preferences, literal) { return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority }; } - function createCompletionEntry(symbol, sortText, contextToken, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, preferences) { + function createCompletionEntry(symbol, sortText, contextToken, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences) { + var _a; var insertText; var replacementSpan = ts.getReplacementSpanForContextToken(contextToken); + var data; + var isSnippet; + var sourceDisplay; var insertQuestionDot = origin && originIsNullableMember(origin); var useBraces = origin && originIsSymbolMember(origin) || needsConvertPropertyAccess; if (origin && originIsThisType(origin)) { @@ -119502,9 +123910,24 @@ var ts; insertText = needsConvertPropertyAccess ? "" + awaitText + insertText : "" + awaitText + (insertQuestionDot ? "?." : ".") + insertText; replacementSpan = ts.createTextSpanFromBounds(propertyAccessToConvert.getStart(sourceFile), propertyAccessToConvert.end); } + if (originIsResolvedExport(origin)) { + ts.Debug.assertIsDefined(importCompletionNode); + (_a = getInsertTextAndReplacementSpanForImportCompletion(name, importCompletionNode, origin, useSemicolons, options, preferences), insertText = _a.insertText, replacementSpan = _a.replacementSpan); + sourceDisplay = [ts.textPart(origin.moduleSpecifier)]; + isSnippet = preferences.includeCompletionsWithSnippetText ? true : undefined; + } if (insertText !== undefined && !preferences.includeCompletionsWithInsertText) { return undefined; } + if (originIsExport(origin) || originIsResolvedExport(origin)) { + data = { + exportName: origin.exportName, + fileName: origin.fileName, + ambientModuleName: origin.fileName ? undefined : ts.stripQuotes(origin.moduleSymbol.name), + isPackageJsonImport: origin.isFromPackageJson ? true : undefined, + moduleSpecifier: originIsResolvedExport(origin) ? origin.moduleSpecifier : undefined, + }; + } // TODO(drosen): Right now we just permit *all* semantic meanings when calling // 'getSymbolKind' which is permissible given that it is backwards compatible; but // really we should consider passing the meaning for the node so that we don't report @@ -119522,8 +123945,29 @@ var ts; isRecommended: isRecommendedCompletionMatch(symbol, recommendedCompletion, typeChecker) || undefined, insertText: insertText, replacementSpan: replacementSpan, + sourceDisplay: sourceDisplay, + isSnippet: isSnippet, isPackageJsonImport: originIsPackageJsonImport(origin) || undefined, - }; + isImportStatementCompletion: originIsResolvedExport(origin) || undefined, + data: data, + }; + } + function getInsertTextAndReplacementSpanForImportCompletion(name, importCompletionNode, origin, useSemicolons, options, preferences) { + var sourceFile = importCompletionNode.getSourceFile(); + var replacementSpan = ts.createTextSpanFromNode(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 tabStop = preferences.includeCompletionsWithSnippetText ? "$1" : ""; + var importKind = ts.codefix.getImportKind(sourceFile, exportKind, options); + var suffix = useSemicolons ? ";" : ""; + switch (importKind) { + case 3 /* CommonJS */: return { replacementSpan: replacementSpan, insertText: "import " + name + tabStop + " = require(" + quotedModuleSpecifier + ")" + suffix }; + case 1 /* Default */: return { replacementSpan: replacementSpan, insertText: "import " + name + tabStop + " from " + quotedModuleSpecifier + suffix }; + case 2 /* Namespace */: return { replacementSpan: replacementSpan, insertText: "import * as " + name + tabStop + " from " + quotedModuleSpecifier + suffix }; + case 0 /* Named */: return { replacementSpan: replacementSpan, insertText: "import { " + name + tabStop + " } from " + quotedModuleSpecifier + suffix }; + } } function quotePropertyName(sourceFile, preferences, name) { if (/^\d+$/.test(name)) { @@ -119539,29 +123983,34 @@ var ts; if (originIsExport(origin)) { return ts.stripQuotes(origin.moduleSymbol.name); } + if (originIsResolvedExport(origin)) { + return origin.moduleSpecifier; + } if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 1 /* ThisType */) { return CompletionSource.ThisProperty; } } - function getCompletionEntriesFromSymbols(symbols, entries, contextToken, location, sourceFile, typeChecker, target, log, kind, preferences, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap) { + function getCompletionEntriesFromSymbols(symbols, entries, contextToken, location, sourceFile, typeChecker, target, log, kind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap) { + var _a; var start = ts.timestamp(); + var variableDeclaration = getVariableDeclaration(location); + var useSemicolons = ts.probablyUsesSemicolons(sourceFile); // Tracks unique names. // Value is set to false for global variables or completions from external module exports, because we can have multiple of those; // true otherwise. Based on the order we add things we will always see locals first, then globals, then module exports. // So adding a completion for a local will prevent us from adding completions for external module exports sharing the same name. var uniques = new ts.Map(); - for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) { - var symbol = symbols_1[_i]; - var origin = symbolToOriginInfoMap ? symbolToOriginInfoMap[ts.getSymbolId(symbol)] : undefined; + for (var i = 0; i < symbols.length; i++) { + 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) { + if (!info || uniques.get(info.name) || kind === 1 /* Global */ && symbolToSortTextIdMap && !shouldIncludeSymbol(symbol, symbolToSortTextIdMap)) { continue; } var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess; - if (uniques.get(name)) { - continue; - } - var entry = createCompletionEntry(symbol, symbolToSortTextMap && symbolToSortTextMap[ts.getSymbolId(symbol)] || SortText.LocationPriority, contextToken, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, preferences); + var sortTextId = (_a = symbolToSortTextIdMap === null || symbolToSortTextIdMap === void 0 ? void 0 : symbolToSortTextIdMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : SortTextId.LocationPriority; + var sortText = (isDeprecated(symbol, typeChecker) ? DeprecatedSortTextStart + sortTextId : sortTextId).toString(); + var entry = createCompletionEntry(symbol, sortText, contextToken, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences); if (!entry) { continue; } @@ -119578,6 +124027,46 @@ var ts; has: function (name) { return uniques.has(name); }, add: function (name) { return uniques.set(name, true); }, }; + function shouldIncludeSymbol(symbol, symbolToSortTextIdMap) { + if (!ts.isSourceFile(location)) { + // export = /**/ here we want to get all meanings, so any symbol is ok + if (ts.isExportAssignment(location.parent)) { + return true; + } + // Filter out variables from their own initializers + // `const a = /* no 'a' here */` + if (variableDeclaration && symbol.valueDeclaration === variableDeclaration) { + return false; + } + // External modules can have global export declarations that will be + // available as global keywords in all scopes. But if the external module + // already has an explicit export and user only wants to user explicit + // module imports then the global keywords will be filtered out so auto + // import suggestions will win in the completion + var symbolOrigin = ts.skipAlias(symbol, typeChecker); + // We only want to filter out the global keywords + // Auto Imports are not available for scripts so this conditional is always false + if (!!sourceFile.externalModuleIndicator + && !compilerOptions.allowUmdGlobalAccess + && symbolToSortTextIdMap[ts.getSymbolId(symbol)] === SortTextId.GlobalsOrKeywords + && (symbolToSortTextIdMap[ts.getSymbolId(symbolOrigin)] === SortTextId.AutoImportSuggestions + || symbolToSortTextIdMap[ts.getSymbolId(symbolOrigin)] === SortTextId.LocationPriority)) { + return false; + } + // Continue with origin symbol + symbol = 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 !!(symbol.flags & 1920 /* Namespace */); + } + if (isTypeOnlyLocation) { + // It's a type, but you can reach it by namespace.type as well + return symbolCanBeReferencedAtTypeLocation(symbol, typeChecker); + } + } + // expressions are value space (which includes the value namespaces) + return !!(ts.getCombinedLocalAndExportSymbolFlags(symbol) & 111551 /* Value */); + } } Completions.getCompletionEntriesFromSymbols = getCompletionEntriesFromSymbols; function getLabelCompletionAtPosition(node) { @@ -119611,6 +124100,20 @@ var ts; return entries; } function getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host, preferences) { + if (entryId.data) { + var autoImport = getAutoImportSymbolFromCompletionEntryData(entryId.name, entryId.data, program, host); + if (autoImport) { + return { + type: "symbol", + symbol: autoImport.symbol, + location: ts.getTouchingPropertyName(sourceFile, position), + previousToken: ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined), + isJsxInitializer: false, + isTypeOnlyLocation: false, + origin: autoImport.origin, + }; + } + } var compilerOptions = program.getCompilerOptions(); var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId, host); if (!completionData) { @@ -119627,11 +124130,11 @@ var ts; // We don't need to perform character checks here because we're only comparing the // name against 'entryName' (which is known to be good), not building a new // completion entry. - return ts.firstDefined(symbols, function (symbol) { - var origin = symbolToOriginInfoMap[ts.getSymbolId(symbol)]; + return ts.firstDefined(symbols, function (symbol, index) { + var origin = symbolToOriginInfoMap[index]; var info = getCompletionEntryDisplayNameForSymbol(symbol, compilerOptions.target, origin, completionKind, completionData.isJsxIdentifierExpected); return info && info.name === entryId.name && getSourceFromOrigin(origin) === entryId.source - ? { type: "symbol", symbol: symbol, location: location, symbolToOriginInfoMap: symbolToOriginInfoMap, previousToken: previousToken, isJsxInitializer: isJsxInitializer, isTypeOnlyLocation: isTypeOnlyLocation } + ? { type: "symbol", symbol: symbol, location: location, origin: origin, previousToken: previousToken, isJsxInitializer: isJsxInitializer, isTypeOnlyLocation: isTypeOnlyLocation } : undefined; }) || { type: "none" }; } @@ -119641,7 +124144,7 @@ var ts; var name = entryId.name; var contextToken = ts.findPrecedingToken(position, sourceFile); if (ts.isInString(sourceFile, position, contextToken)) { - return Completions.StringCompletions.getStringLiteralCompletionDetails(name, sourceFile, position, contextToken, typeChecker, compilerOptions, host, cancellationToken); + return Completions.StringCompletions.getStringLiteralCompletionDetails(name, sourceFile, position, contextToken, typeChecker, compilerOptions, host, cancellationToken, preferences); } // Compute all the completion symbols again. var symbolCompletion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host, preferences); @@ -119655,13 +124158,15 @@ var ts; return ts.JsDoc.getJSDocTagCompletionDetails(name); case 3 /* JsDocParameterName */: return ts.JsDoc.getJSDocParameterNameCompletionDetails(name); + case 4 /* Keywords */: + return request.keywords.indexOf(ts.stringToToken(name)) > -1 ? createSimpleDetails(name, "keyword" /* keyword */, ts.SymbolDisplayPartKind.keyword) : undefined; default: return ts.Debug.assertNever(request); } } case "symbol": { - var symbol = symbolCompletion.symbol, location = symbolCompletion.location, symbolToOriginInfoMap = symbolCompletion.symbolToOriginInfoMap, previousToken = symbolCompletion.previousToken; - var _a = getCompletionEntryCodeActionsAndSourceDisplay(symbolToOriginInfoMap, symbol, program, typeChecker, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences), codeActions = _a.codeActions, sourceDisplay = _a.sourceDisplay; + var symbol = symbolCompletion.symbol, location = symbolCompletion.location, origin = symbolCompletion.origin, previousToken = symbolCompletion.previousToken; + var _a = getCompletionEntryCodeActionsAndSourceDisplay(origin, symbol, program, typeChecker, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, entryId.data), codeActions = _a.codeActions, sourceDisplay = _a.sourceDisplay; return createCompletionDetailsForSymbol(symbol, typeChecker, sourceFile, location, cancellationToken, codeActions, sourceDisplay); // TODO: GH#18217 } case "literal": { @@ -119687,15 +124192,17 @@ var ts; } Completions.createCompletionDetailsForSymbol = createCompletionDetailsForSymbol; function createCompletionDetails(name, kindModifiers, kind, displayParts, documentation, tags, codeActions, source) { - return { name: name, kindModifiers: kindModifiers, kind: kind, displayParts: displayParts, documentation: documentation, tags: tags, codeActions: codeActions, source: source }; + return { name: name, kindModifiers: kindModifiers, kind: kind, displayParts: displayParts, documentation: documentation, tags: tags, codeActions: codeActions, source: source, sourceDisplay: source }; } Completions.createCompletionDetails = createCompletionDetails; - function getCompletionEntryCodeActionsAndSourceDisplay(symbolToOriginInfoMap, symbol, program, checker, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences) { - var symbolOriginInfo = symbolToOriginInfoMap[ts.getSymbolId(symbol)]; - if (!symbolOriginInfo || !originIsExport(symbolOriginInfo)) { + function getCompletionEntryCodeActionsAndSourceDisplay(origin, symbol, program, checker, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, data) { + if (data === null || data === void 0 ? void 0 : data.moduleSpecifier) { + return { codeActions: undefined, sourceDisplay: [ts.textPart(data.moduleSpecifier)] }; + } + if (!origin || !originIsExport(origin)) { return { codeActions: undefined, sourceDisplay: undefined }; } - var moduleSymbol = symbolOriginInfo.moduleSymbol; + var moduleSymbol = origin.moduleSymbol; var exportedSymbol = checker.getMergedSymbol(ts.skipAlias(symbol.exportSymbol || symbol, checker)); var _a = ts.codefix.getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, ts.getNameForExportedSymbol(symbol, compilerOptions.target), host, program, formatContext, previousToken && ts.isIdentifier(previousToken) ? previousToken.getStart(sourceFile) : position, preferences), moduleSpecifier = _a.moduleSpecifier, codeAction = _a.codeAction; return { sourceDisplay: [ts.textPart(moduleSpecifier)], codeActions: [codeAction] }; @@ -119711,6 +124218,7 @@ var ts; CompletionDataKind[CompletionDataKind["JsDocTagName"] = 1] = "JsDocTagName"; CompletionDataKind[CompletionDataKind["JsDocTag"] = 2] = "JsDocTag"; CompletionDataKind[CompletionDataKind["JsDocParameterName"] = 3] = "JsDocParameterName"; + CompletionDataKind[CompletionDataKind["Keywords"] = 4] = "Keywords"; })(CompletionDataKind || (CompletionDataKind = {})); var CompletionKind; (function (CompletionKind) { @@ -119734,25 +124242,25 @@ var ts; function getContextualType(previousToken, position, sourceFile, checker) { var parent = previousToken.parent; switch (previousToken.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return ts.getContextualTypeFromParent(previousToken, checker); - case 62 /* EqualsToken */: + case 63 /* EqualsToken */: switch (parent.kind) { - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return checker.getContextualType(parent.initializer); // TODO: GH#18217 - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return checker.getTypeAtLocation(parent.left); - case 280 /* JsxAttribute */: + case 282 /* JsxAttribute */: return checker.getContextualTypeForJsxAttribute(parent); default: return undefined; } - case 102 /* NewKeyword */: + case 103 /* NewKeyword */: return checker.getContextualType(parent); - case 81 /* CaseKeyword */: + case 82 /* CaseKeyword */: return ts.getSwitchedType(ts.cast(parent, ts.isCaseClause), checker); case 18 /* OpenBraceToken */: - return ts.isJsxExpression(parent) && parent.parent.kind !== 273 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; + return ts.isJsxExpression(parent) && parent.parent.kind !== 275 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; default: var argInfo = ts.SignatureHelp.getArgumentInfoForCompletions(previousToken, position, sourceFile); return argInfo ? @@ -119771,7 +124279,8 @@ var ts; return symbol.parent && (isModuleSymbol(symbol.parent) ? symbol : getFirstSymbolInChain(symbol.parent, enclosingDeclaration, checker)); } function isModuleSymbol(symbol) { - return symbol.declarations.some(function (d) { return d.kind === 297 /* SourceFile */; }); + var _a; + return !!((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d.kind === 299 /* SourceFile */; })); } function getCompletionData(program, log, sourceFile, isUncheckedFile, position, preferences, detailsEntryId, host) { var typeChecker = program.getTypeChecker(); @@ -119822,11 +124331,11 @@ var ts; if (tag.tagName.pos <= position && position <= tag.tagName.end) { return { kind: 1 /* JsDocTagName */ }; } - if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 301 /* JSDocTypeExpression */) { + if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 303 /* JSDocTypeExpression */) { currentToken = ts.getTokenAtPosition(sourceFile, position); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 333 /* JSDocPropertyTag */ || + (currentToken.parent.kind !== 341 /* JSDocPropertyTag */ || currentToken.parent.name !== currentToken))) { // Use as type location if inside tag's type expression insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression); @@ -119851,7 +124360,7 @@ var ts; var contextToken = previousToken; // Check if the caret is at the end of an identifier; this is a partial identifier that we want to complete: e.g. a.toS| // Skip this partial identifier and adjust the contextToken to the token that precedes it. - if (contextToken && position <= contextToken.end && (ts.isIdentifierOrPrivateIdentifier(contextToken) || ts.isKeyword(contextToken.kind))) { + if (contextToken && position <= contextToken.end && (ts.isMemberName(contextToken) || ts.isKeyword(contextToken.kind))) { var start_1 = ts.timestamp(); contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile, /*startNode*/ undefined); // TODO: GH#18217 log("getCompletionData: Get previous token 2: " + (ts.timestamp() - start_1)); @@ -119867,10 +124376,22 @@ var ts; var isStartingCloseTag = false; var isJsxInitializer = false; var isJsxIdentifierExpected = false; + var importCompletionNode; var location = ts.getTouchingPropertyName(sourceFile, position); if (contextToken) { + var importCompletionCandidate = getImportCompletionNode(contextToken); + if (importCompletionCandidate === 154 /* FromKeyword */) { + return { kind: 4 /* Keywords */, keywords: [154 /* FromKeyword */] }; + } + // Import statement completions use `insertText`, and also require the `data` property of `CompletionEntryIdentifier` + // added in TypeScript 4.3 to be sent back from the client during `getCompletionEntryDetails`. Since this feature + // 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. + if (importCompletionCandidate && preferences.includeCompletionsForImportStatements && preferences.includeCompletionsWithInsertText) { + importCompletionNode = importCompletionCandidate; + } // Bail out if this is a known invalid completion location - if (isCompletionListBlocker(contextToken)) { + if (!importCompletionNode && isCompletionListBlocker(contextToken)) { log("Returning an empty list because completion was requested in an invalid position."); return undefined; } @@ -119879,7 +124400,7 @@ var ts; isRightOfDot = contextToken.kind === 24 /* DotToken */; isRightOfQuestionDot = contextToken.kind === 28 /* QuestionDotToken */; switch (parent.kind) { - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: propertyAccessToConvert = parent; node = propertyAccessToConvert.expression; if ((ts.isCallExpression(node) || ts.isFunctionLike(node)) && @@ -119892,14 +124413,14 @@ var ts; return undefined; } break; - case 157 /* QualifiedName */: + case 159 /* QualifiedName */: node = parent.left; break; - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: node = parent.name; break; - case 195 /* ImportType */: - case 226 /* MetaProperty */: + case 197 /* ImportType */: + case 228 /* MetaProperty */: node = parent; break; default: @@ -119908,11 +124429,11 @@ var ts; return undefined; } } - else if (sourceFile.languageVariant === 1 /* JSX */) { + else if (!importCompletionNode && sourceFile.languageVariant === 1 /* 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 === 201 /* PropertyAccessExpression */) { + if (parent && parent.kind === 203 /* PropertyAccessExpression */) { contextToken = parent; parent = parent.parent; } @@ -119920,45 +124441,45 @@ var ts; if (currentToken.parent === location) { switch (currentToken.kind) { case 31 /* GreaterThanToken */: - if (currentToken.parent.kind === 273 /* JsxElement */ || currentToken.parent.kind === 275 /* JsxOpeningElement */) { + if (currentToken.parent.kind === 275 /* JsxElement */ || currentToken.parent.kind === 277 /* JsxOpeningElement */) { location = currentToken; } break; case 43 /* SlashToken */: - if (currentToken.parent.kind === 274 /* JsxSelfClosingElement */) { + if (currentToken.parent.kind === 276 /* JsxSelfClosingElement */) { location = currentToken; } break; } } switch (parent.kind) { - case 276 /* JsxClosingElement */: + case 278 /* JsxClosingElement */: if (contextToken.kind === 43 /* SlashToken */) { isStartingCloseTag = true; location = contextToken; } break; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: if (!binaryExpressionMayBeOpenTag(parent)) { break; } // falls through - case 274 /* JsxSelfClosingElement */: - case 273 /* JsxElement */: - case 275 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: + case 275 /* JsxElement */: + case 277 /* JsxOpeningElement */: isJsxIdentifierExpected = true; if (contextToken.kind === 29 /* LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } break; - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: // For `
`, `parent` will be `{true}` and `previousToken` will be `}` if (previousToken.kind === 19 /* CloseBraceToken */ && currentToken.kind === 31 /* GreaterThanToken */) { isJsxIdentifierExpected = true; } break; - case 280 /* JsxAttribute */: + case 282 /* JsxAttribute */: // For `
`, `parent` will be JsxAttribute and `previousToken` will be its initializer if (parent.initializer === previousToken && previousToken.end < position) { @@ -119966,16 +124487,16 @@ var ts; break; } switch (previousToken.kind) { - case 62 /* EqualsToken */: + case 63 /* EqualsToken */: isJsxInitializer = true; break; - case 78 /* Identifier */: + case 79 /* 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, 62 /* EqualsToken */, sourceFile)) { + ts.findChildOfKind(parent, 63 /* EqualsToken */, sourceFile)) { isJsxInitializer = previousToken; } } @@ -119991,9 +124512,12 @@ var ts; // This also gets mutated in nested-functions after the return var symbols = []; var symbolToOriginInfoMap = []; - var symbolToSortTextMap = []; - var importSuggestionsCache = host.getImportSuggestionsCache && host.getImportSuggestionsCache(); + var symbolToSortTextIdMap = []; + var seenPropertySymbols = new ts.Map(); var isTypeOnly = isTypeOnlyCompletion(); + var getModuleSpecifierResolutionHost = ts.memoizeOne(function (isFromPackageJson) { + return ts.createModuleSpecifierResolutionHost(isFromPackageJson ? host.getPackageJsonAutoImportProvider() : program, host); + }); if (isRightOfDot || isRightOfQuestionDot) { getTypeScriptMemberSymbols(); } @@ -120002,7 +124526,7 @@ var ts; ts.Debug.assertEachIsDefined(tagSymbols, "getJsxIntrinsicTagNames() should all be defined"); tryGetGlobalSymbols(); symbols = tagSymbols.concat(symbols); - completionKind = 3 /* MemberLike */; + completionKind = 1 /* Global */; keywordFilters = 0 /* None */; } else if (isStartingCloseTag) { @@ -120011,7 +124535,7 @@ var ts; if (tagSymbol) { symbols = [tagSymbol]; } - completionKind = 3 /* MemberLike */; + completionKind = 1 /* Global */; keywordFilters = 0 /* None */; } else { @@ -120041,17 +124565,18 @@ var ts; previousToken: previousToken, isJsxInitializer: isJsxInitializer, insideJsDocTagTypeExpression: insideJsDocTagTypeExpression, - symbolToSortTextMap: symbolToSortTextMap, + symbolToSortTextIdMap: symbolToSortTextIdMap, isTypeOnlyLocation: isTypeOnly, isJsxIdentifierExpected: isJsxIdentifierExpected, + importCompletionNode: importCompletionNode, }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 326 /* JSDocParameterTag */: - case 333 /* JSDocPropertyTag */: - case 327 /* JSDocReturnTag */: - case 329 /* JSDocTypeTag */: - case 331 /* JSDocTypedefTag */: + case 334 /* JSDocParameterTag */: + case 341 /* JSDocPropertyTag */: + case 335 /* JSDocReturnTag */: + case 337 /* JSDocTypeTag */: + case 339 /* JSDocTypedefTag */: return true; default: return false; @@ -120078,11 +124603,11 @@ var ts; // Extract module or enum members var exportedSymbols = typeChecker.getExportsOfModule(symbol); ts.Debug.assertEachIsDefined(exportedSymbols, "getExportsOfModule() should all be defined"); - var isValidValueAccess_1 = function (symbol) { return typeChecker.isValidPropertyAccess(isImportType ? node : (node.parent), symbol.name); }; - var isValidTypeAccess_1 = function (symbol) { return symbolCanBeReferencedAtTypeLocation(symbol); }; + var isValidValueAccess_1 = function (symbol) { return typeChecker.isValidPropertyAccess(isImportType ? node : node.parent, symbol.name); }; + 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) { return !!(symbol.flags & 1920 /* Namespace */) && !symbol.declarations.every(function (d) { return d.parent === node.parent; }); } + ? 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; })); } : isRhsOfImportDeclaration ? // Any kind is allowed when dotting off namespace in internal import equals declaration function (symbol) { return isValidTypeAccess_1(symbol) || isValidValueAccess_1(symbol); } : @@ -120096,7 +124621,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 !== 297 /* SourceFile */ && d.kind !== 256 /* ModuleDeclaration */ && d.kind !== 255 /* EnumDeclaration */; })) { + symbol.declarations.some(function (d) { return d.kind !== 299 /* SourceFile */ && d.kind !== 258 /* ModuleDeclaration */ && d.kind !== 257 /* EnumDeclaration */; })) { var type = typeChecker.getTypeOfSymbolAtLocation(symbol, node).getNonOptionalType(); var insertQuestionDot = false; if (type.isNullableType()) { @@ -120116,8 +124641,8 @@ var ts; } } } - if (ts.isMetaProperty(node) && (node.keywordToken === 102 /* NewKeyword */ || node.keywordToken === 99 /* ImportKeyword */) && contextToken === node.getChildAt(1)) { - var completion = (node.keywordToken === 102 /* NewKeyword */) ? "target" : "meta"; + if (ts.isMetaProperty(node) && (node.keywordToken === 103 /* NewKeyword */ || node.keywordToken === 100 /* ImportKeyword */) && contextToken === node.getChildAt(1)) { + var completion = (node.keywordToken === 103 /* NewKeyword */) ? "target" : "meta"; symbols.push(typeChecker.createSymbol(4 /* Property */, ts.escapeLeadingUnderscores(completion))); return; } @@ -120143,7 +124668,7 @@ var ts; if (isRightOfQuestionDot && ts.some(type.getCallSignatures())) { isNewIdentifierLocation = true; } - var propertyAccess = node.kind === 195 /* ImportType */ ? node : node.parent; + var propertyAccess = node.kind === 197 /* ImportType */ ? node : node.parent; if (isUncheckedFile) { // 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 @@ -120182,13 +124707,24 @@ var ts; var nameSymbol = leftMostName && typeChecker.getSymbolAtLocation(leftMostName); // If this is nested like for `namespace N { export const sym = Symbol(); }`, we'll add the completion for `N`. var firstAccessibleSymbol = nameSymbol && getFirstSymbolInChain(nameSymbol, contextToken, typeChecker); - if (firstAccessibleSymbol && !symbolToOriginInfoMap[ts.getSymbolId(firstAccessibleSymbol)]) { + if (firstAccessibleSymbol && ts.addToSeen(seenPropertySymbols, ts.getSymbolId(firstAccessibleSymbol))) { + var index = symbols.length; symbols.push(firstAccessibleSymbol); var moduleSymbol = firstAccessibleSymbol.parent; - symbolToOriginInfoMap[ts.getSymbolId(firstAccessibleSymbol)] = - !moduleSymbol || !ts.isExternalModuleSymbol(moduleSymbol) - ? { kind: getNullableSymbolOriginInfoKind(2 /* SymbolMemberNoExport */) } - : { kind: getNullableSymbolOriginInfoKind(6 /* SymbolMemberExport */), moduleSymbol: moduleSymbol, isDefaultExport: false }; + if (!moduleSymbol || !ts.isExternalModuleSymbol(moduleSymbol)) { + symbolToOriginInfoMap[index] = { kind: getNullableSymbolOriginInfoKind(2 /* SymbolMemberNoExport */) }; + } + else { + var origin = { + kind: getNullableSymbolOriginInfoKind(6 /* SymbolMemberExport */), + moduleSymbol: moduleSymbol, + isDefaultExport: false, + symbolName: firstAccessibleSymbol.name, + exportName: firstAccessibleSymbol.name, + fileName: ts.isExternalModuleNameRelative(ts.stripQuotes(moduleSymbol.name)) ? ts.cast(moduleSymbol.valueDeclaration, ts.isSourceFile).fileName : undefined, + }; + symbolToOriginInfoMap[index] = origin; + } } else if (preferences.includeCompletionsWithInsertText) { addSymbolOriginInfo(symbol); @@ -120203,16 +124739,16 @@ var ts; } function addSymbolSortInfo(symbol) { if (isStaticProperty(symbol)) { - symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.LocalDeclarationPriority; + symbolToSortTextIdMap[ts.getSymbolId(symbol)] = SortTextId.LocalDeclarationPriority; } } function addSymbolOriginInfo(symbol) { if (preferences.includeCompletionsWithInsertText) { - if (insertAwait && !symbolToOriginInfoMap[ts.getSymbolId(symbol)]) { - symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: getNullableSymbolOriginInfoKind(8 /* Promise */) }; + if (insertAwait && ts.addToSeen(seenPropertySymbols, ts.getSymbolId(symbol))) { + symbolToOriginInfoMap[symbols.length] = { kind: getNullableSymbolOriginInfoKind(8 /* Promise */) }; } else if (insertQuestionDot) { - symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: 16 /* Nullable */ }; + symbolToOriginInfoMap[symbols.length] = { kind: 16 /* Nullable */ }; } } } @@ -120225,7 +124761,9 @@ var ts; return ts.isIdentifier(e) ? e : ts.isPropertyAccessExpression(e) ? getLeftMostName(e.expression) : undefined; } function tryGetGlobalSymbols() { - var result = tryGetObjectLikeCompletionSymbols() + var result = tryGetObjectTypeLiteralInTypeArgumentCompletionSymbols() + || tryGetObjectLikeCompletionSymbols() + || tryGetImportCompletionSymbols() || tryGetImportOrExportClauseCompletionSymbols() || tryGetLocalNamedExportCompletionSymbols() || tryGetConstructorCompletion() @@ -120258,11 +124796,17 @@ var ts; isNewIdentifierLocation = false; return 1 /* Success */; } + function tryGetImportCompletionSymbols() { + if (!importCompletionNode) + return 0 /* Continue */; + collectAutoImports(/*resolveModuleSpecifiers*/ true); + return 1 /* Success */; + } function getGlobalCompletions() { keywordFilters = tryGetFunctionLikeBodyCompletionContainer(contextToken) ? 5 /* FunctionLikeBodyKeywords */ : 1 /* All */; // Get all entities in the current scope. completionKind = 1 /* Global */; - isNewIdentifierLocation = isNewIdentifierDefinitionLocation(contextToken); + isNewIdentifierLocation = isNewIdentifierDefinitionLocation(); if (previousToken !== contextToken) { ts.Debug.assert(!!previousToken, "Expected 'contextToken' to be defined when different from 'previousToken'."); } @@ -120299,50 +124843,36 @@ var ts; var symbolMeanings = (isTypeOnly ? 0 /* None */ : 111551 /* Value */) | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */; symbols = typeChecker.getSymbolsInScope(scopeNode, symbolMeanings); ts.Debug.assertEachIsDefined(symbols, "getSymbolsInScope() should all be defined"); - for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) { - var symbol = symbols_2[_i]; + for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) { + var symbol = symbols_1[_i]; if (!typeChecker.isArgumentsSymbol(symbol) && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === sourceFile; })) { - symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.GlobalsOrKeywords; + symbolToSortTextIdMap[ts.getSymbolId(symbol)] = SortTextId.GlobalsOrKeywords; } } // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions` - if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 297 /* SourceFile */) { + if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 299 /* SourceFile */) { var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false); if (thisType && !isProbablyGlobalType(thisType, sourceFile, typeChecker)) { for (var _a = 0, _b = getPropertiesForCompletion(thisType, typeChecker); _a < _b.length; _a++) { var symbol = _b[_a]; - symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: 1 /* ThisType */ }; + symbolToOriginInfoMap[symbols.length] = { kind: 1 /* ThisType */ }; symbols.push(symbol); - symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.SuggestedClassMembers; + symbolToSortTextIdMap[ts.getSymbolId(symbol)] = SortTextId.SuggestedClassMembers; } } } - if (shouldOfferImportCompletions()) { - var lowerCaseTokenText_1 = previousToken && ts.isIdentifier(previousToken) ? previousToken.text.toLowerCase() : ""; - var autoImportSuggestions = getSymbolsFromOtherSourceFileExports(program.getCompilerOptions().target, host); - if (!detailsEntryId && importSuggestionsCache) { - importSuggestionsCache.set(sourceFile.fileName, autoImportSuggestions, host.getProjectVersion && host.getProjectVersion()); - } - autoImportSuggestions.forEach(function (_a) { - var symbol = _a.symbol, symbolName = _a.symbolName, skipFilter = _a.skipFilter, origin = _a.origin; - if (detailsEntryId) { - if (detailsEntryId.source && ts.stripQuotes(origin.moduleSymbol.name) !== detailsEntryId.source) { - return; - } - } - else if (!skipFilter && !stringContainsCharactersInOrder(symbolName.toLowerCase(), lowerCaseTokenText_1)) { - return; - } - var symbolId = ts.getSymbolId(symbol); - symbols.push(symbol); - symbolToOriginInfoMap[symbolId] = origin; - symbolToSortTextMap[symbolId] = SortText.AutoImportSuggestions; - }); + collectAutoImports(/*resolveModuleSpecifier*/ false); + if (isTypeOnly) { + keywordFilters = contextToken && ts.isAssertionExpression(contextToken.parent) + ? 6 /* TypeAssertionKeywords */ + : 7 /* TypeKeywords */; } - filterGlobalCompletion(symbols); } function shouldOfferImportCompletions() { + // If already typing an import statement, provide completions for it. + if (importCompletionNode) + return true; // If current completion is for non-contextual Object literal shortahands, ignore auto-import symbols if (isNonContextualObjectLiteral) return false; @@ -120360,42 +124890,15 @@ var ts; } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { - case 297 /* SourceFile */: - case 218 /* TemplateExpression */: - case 283 /* JsxExpression */: - case 230 /* Block */: + case 299 /* SourceFile */: + case 220 /* TemplateExpression */: + case 285 /* JsxExpression */: + case 232 /* Block */: return true; default: return ts.isStatement(scopeNode); } } - function filterGlobalCompletion(symbols) { - var isTypeOnly = isTypeOnlyCompletion(); - if (isTypeOnly) { - keywordFilters = contextToken && ts.isAssertionExpression(contextToken.parent) - ? 6 /* TypeAssertionKeywords */ - : 7 /* TypeKeywords */; - } - ts.filterMutate(symbols, function (symbol) { - if (!ts.isSourceFile(location)) { - // export = /**/ here we want to get all meanings, so any symbol is ok - if (ts.isExportAssignment(location.parent)) { - return true; - } - symbol = ts.skipAlias(symbol, typeChecker); - // import m = /**/ <-- It can only access namespace (if typing import = x. this would get member symbols and not namespace) - if (ts.isInRightSideOfInternalImportEqualsDeclaration(location)) { - return !!(symbol.flags & 1920 /* Namespace */); - } - if (isTypeOnly) { - // It's a type, but you can reach it by namespace.type as well - return symbolCanBeReferencedAtTypeLocation(symbol); - } - } - // expressions are value space (which includes the value namespaces) - return !!(ts.getCombinedLocalAndExportSymbolFlags(symbol) & 111551 /* Value */); - }); - } function isTypeOnlyCompletion() { return insideJsDocTagTypeExpression || !isContextTokenValueLocation(contextToken) && @@ -120405,191 +124908,105 @@ var ts; } function isContextTokenValueLocation(contextToken) { return contextToken && - contextToken.kind === 111 /* TypeOfKeyword */ && - (contextToken.parent.kind === 176 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent)); + ((contextToken.kind === 112 /* TypeOfKeyword */ && + (contextToken.parent.kind === 178 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent))) || + (contextToken.kind === 128 /* AssertsKeyword */ && contextToken.parent.kind === 174 /* TypePredicate */)); } function isContextTokenTypeLocation(contextToken) { if (contextToken) { var parentKind = contextToken.parent.kind; switch (contextToken.kind) { case 58 /* ColonToken */: - return parentKind === 163 /* PropertyDeclaration */ || - parentKind === 162 /* PropertySignature */ || - parentKind === 160 /* Parameter */ || - parentKind === 249 /* VariableDeclaration */ || + return parentKind === 165 /* PropertyDeclaration */ || + parentKind === 164 /* PropertySignature */ || + parentKind === 162 /* Parameter */ || + parentKind === 251 /* VariableDeclaration */ || ts.isFunctionLikeKind(parentKind); - case 62 /* EqualsToken */: - return parentKind === 254 /* TypeAliasDeclaration */; - case 126 /* AsKeyword */: - return parentKind === 224 /* AsExpression */; + case 63 /* EqualsToken */: + return parentKind === 256 /* TypeAliasDeclaration */; + case 127 /* AsKeyword */: + return parentKind === 226 /* AsExpression */; case 29 /* LessThanToken */: - return parentKind === 173 /* TypeReference */ || - parentKind === 206 /* TypeAssertionExpression */; - case 93 /* ExtendsKeyword */: - return parentKind === 159 /* TypeParameter */; + return parentKind === 175 /* TypeReference */ || + parentKind === 208 /* TypeAssertionExpression */; + case 94 /* ExtendsKeyword */: + return parentKind === 161 /* TypeParameter */; } } return false; } - /** True if symbol is a type or a module containing at least one type. */ - function symbolCanBeReferencedAtTypeLocation(symbol, seenModules) { - if (seenModules === void 0) { seenModules = new ts.Map(); } - var sym = ts.skipAlias(symbol.exportSymbol || symbol, typeChecker); - return !!(sym.flags & 788968 /* Type */) || - !!(sym.flags & 1536 /* Module */) && - ts.addToSeen(seenModules, ts.getSymbolId(sym)) && - typeChecker.getExportsOfModule(sym).some(function (e) { return symbolCanBeReferencedAtTypeLocation(e, seenModules); }); - } - /** - * Gathers symbols that can be imported from other files, de-duplicating along the way. Symbols can be "duplicates" - * if re-exported from another module, e.g. `export { foo } from "./a"`. That syntax creates a fresh symbol, but - * it’s just an alias to the first, and both have the same name, so we generally want to filter those aliases out, - * if and only if the the first can be imported (it may be excluded due to package.json filtering in - * `codefix.forEachExternalModuleToImportFrom`). - * - * Example. Imagine a chain of node_modules re-exporting one original symbol: - * - * ```js - * node_modules/x/index.js node_modules/y/index.js node_modules/z/index.js - * +-----------------------+ +--------------------------+ +--------------------------+ - * | | | | | | - * | export const foo = 0; | <--- | export { foo } from 'x'; | <--- | export { foo } from 'y'; | - * | | | | | | - * +-----------------------+ +--------------------------+ +--------------------------+ - * ``` - * - * Also imagine three buckets, which we’ll reference soon: - * - * ```md - * | | | | | | - * | **Bucket A** | | **Bucket B** | | **Bucket C** | - * | Symbols to | | Aliases to symbols | | Symbols to return | - * | definitely | | in Buckets A or C | | if nothing better | - * | return | | (don’t return these) | | comes along | - * |__________________| |______________________| |___________________| - * ``` - * - * We _probably_ want to show `foo` from 'x', but not from 'y' or 'z'. However, if 'x' is not in a package.json, it - * will not appear in a `forEachExternalModuleToImportFrom` iteration. Furthermore, the order of iterations is not - * guaranteed, as it is host-dependent. Therefore, when presented with the symbol `foo` from module 'y' alone, we - * may not be sure whether or not it should go in the list. So, we’ll take the following steps: - * - * 1. Resolve alias `foo` from 'y' to the export declaration in 'x', get the symbol there, and see if that symbol is - * already in Bucket A (symbols we already know will be returned). If it is, put `foo` from 'y' in Bucket B - * (symbols that are aliases to symbols in Bucket A). If it’s not, put it in Bucket C. - * 2. Next, imagine we see `foo` from module 'z'. Again, we resolve the alias to the nearest export, which is in 'y'. - * At this point, if that nearest export from 'y' is in _any_ of the three buckets, we know the symbol in 'z' - * should never be returned in the final list, so put it in Bucket B. - * 3. Next, imagine we see `foo` from module 'x', the original. Syntactically, it doesn’t look like a re-export, so - * we can just check Bucket C to see if we put any aliases to the original in there. If they exist, throw them out. - * Put this symbol in Bucket A. - * 4. After we’ve iterated through every symbol of every module, any symbol left in Bucket C means that step 3 didn’t - * occur for that symbol---that is, the original symbol is not in Bucket A, so we should include the alias. Move - * everything from Bucket C to Bucket A. - */ - function getSymbolsFromOtherSourceFileExports(target, host) { - var cached = importSuggestionsCache && importSuggestionsCache.get(sourceFile.fileName, typeChecker, detailsEntryId && host.getProjectVersion ? host.getProjectVersion() : undefined); - if (cached) { - log("getSymbolsFromOtherSourceFileExports: Using cached list"); - return cached; - } - var startTime = ts.timestamp(); - log("getSymbolsFromOtherSourceFileExports: Recomputing list" + (detailsEntryId ? " for details entry" : "")); - var seenResolvedModules = new ts.Map(); - var seenExports = new ts.Map(); - /** Bucket B */ - var aliasesToAlreadyIncludedSymbols = new ts.Map(); - /** Bucket C */ - var aliasesToReturnIfOriginalsAreMissing = new ts.Map(); - /** Bucket A */ - var results = []; - /** Ids present in `results` for faster lookup */ - var resultSymbolIds = new ts.Map(); - ts.codefix.forEachExternalModuleToImportFrom(program, host, sourceFile, !detailsEntryId, /*useAutoImportProvider*/ true, function (moduleSymbol, _, program, isFromPackageJson) { - // Perf -- ignore other modules if this is a request for details - if (detailsEntryId && detailsEntryId.source && ts.stripQuotes(moduleSymbol.name) !== detailsEntryId.source) { - return; - } - var typeChecker = program.getTypeChecker(); - var resolvedModuleSymbol = typeChecker.resolveExternalModuleSymbol(moduleSymbol); - // resolvedModuleSymbol may be a namespace. A namespace may be `export =` by multiple module declarations, but only keep the first one. - if (!ts.addToSeen(seenResolvedModules, ts.getSymbolId(resolvedModuleSymbol))) { + /** Mutates `symbols`, `symbolToOriginInfoMap`, and `symbolToSortTextIdMap` */ + function collectAutoImports(resolveModuleSpecifiers) { + var _a, _b, _c, _d, _e; + if (!shouldOfferImportCompletions()) + return; + ts.Debug.assert(!(detailsEntryId === null || detailsEntryId === void 0 ? void 0 : detailsEntryId.data)); + var start = ts.timestamp(); + var moduleSpecifierCache = (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host); + (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, "collectAutoImports: starting, " + (resolveModuleSpecifiers ? "" : "not ") + "resolving module specifiers"); + if (moduleSpecifierCache) { + (_c = host.log) === null || _c === void 0 ? void 0 : _c.call(host, "collectAutoImports: module specifier cache size: " + moduleSpecifierCache.count()); + } + var lowerCaseTokenText = previousToken && ts.isIdentifier(previousToken) ? previousToken.text.toLowerCase() : ""; + var exportInfo = ts.codefix.getSymbolToExportInfoMap(sourceFile, host, program); + var packageJsonAutoImportProvider = (_d = host.getPackageJsonAutoImportProvider) === null || _d === void 0 ? void 0 : _d.call(host); + var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, host); + exportInfo.forEach(function (info, key) { + var symbolName = key.substring(0, key.indexOf("|")); + if (!detailsEntryId && ts.isStringANonContextualKeyword(symbolName)) return; - } - // Don't add another completion for `export =` of a symbol that's already global. - // So in `declare namespace foo {} declare module "foo" { export = foo; }`, there will just be the global completion for `foo`. - if (resolvedModuleSymbol !== moduleSymbol && ts.every(resolvedModuleSymbol.declarations, ts.isNonGlobalDeclaration)) { - pushSymbol(resolvedModuleSymbol, moduleSymbol, isFromPackageJson, /*skipFilter*/ true); - } - for (var _i = 0, _a = typeChecker.getExportsAndPropertiesOfModule(moduleSymbol); _i < _a.length; _i++) { - var symbol = _a[_i]; - var symbolId = ts.getSymbolId(symbol).toString(); - // `getExportsAndPropertiesOfModule` can include duplicates - if (!ts.addToSeen(seenExports, symbolId)) { - continue; - } - // If this is `export { _break as break };` (a keyword) -- skip this and prefer the keyword completion. - if (ts.some(symbol.declarations, function (d) { return ts.isExportSpecifier(d) && !!d.propertyName && ts.isIdentifierANonContextualKeyword(d.name); })) { - continue; - } - // If `symbol.parent !== moduleSymbol`, this is an `export * from "foo"` re-export. Those don't create new symbols. - var isExportStarFromReExport = typeChecker.getMergedSymbol(symbol.parent) !== resolvedModuleSymbol; - // If `!!d.parent.parent.moduleSpecifier`, this is `export { foo } from "foo"` re-export, which creates a new symbol (thus isn't caught by the first check). - if (isExportStarFromReExport || ts.some(symbol.declarations, function (d) { return ts.isExportSpecifier(d) && !d.propertyName && !!d.parent.parent.moduleSpecifier; })) { - // Walk the export chain back one module (step 1 or 2 in diagrammed example). - // Or, in the case of `export * from "foo"`, `symbol` already points to the original export, so just use that. - var nearestExportSymbol = isExportStarFromReExport ? symbol : getNearestExportSymbol(symbol); - if (!nearestExportSymbol) - continue; - var nearestExportSymbolId = ts.getSymbolId(nearestExportSymbol).toString(); - var symbolHasBeenSeen = resultSymbolIds.has(nearestExportSymbolId) || aliasesToAlreadyIncludedSymbols.has(nearestExportSymbolId); - if (!symbolHasBeenSeen) { - aliasesToReturnIfOriginalsAreMissing.set(nearestExportSymbolId, { alias: symbol, moduleSymbol: moduleSymbol, isFromPackageJson: isFromPackageJson }); - aliasesToAlreadyIncludedSymbols.set(symbolId, true); - } - else { - // Perf - we know this symbol is an alias to one that’s already covered in `symbols`, so store it here - // in case another symbol re-exports this one; that way we can short-circuit as soon as we see this symbol id. - ts.addToSeen(aliasesToAlreadyIncludedSymbols, symbolId); - } - } - else { - // This is not a re-export, so see if we have any aliases pending and remove them (step 3 in diagrammed example) - aliasesToReturnIfOriginalsAreMissing.delete(symbolId); - pushSymbol(symbol, moduleSymbol, isFromPackageJson, /*skipFilter*/ false); - } + var isCompletionDetailsMatch = detailsEntryId && ts.some(info, function (i) { return detailsEntryId.source === ts.stripQuotes(i.moduleSymbol.name); }); + if (isCompletionDetailsMatch || isNameMatch(symbolName)) { + // If we don't need to resolve module specifiers, we can use any re-export that is importable at all + // (We need to ensure that at least one is importable to show a completion.) + var _a = resolveModuleSpecifiers + ? ts.codefix.getModuleSpecifierForBestExportInfo(info, sourceFile, program, host, preferences) + : { moduleSpecifier: undefined, exportInfo: ts.find(info, isImportableExportInfo) }, moduleSpecifier = _a.moduleSpecifier, exportInfo_1 = _a.exportInfo; + if (!exportInfo_1) + return; + var moduleFile = ts.tryCast(exportInfo_1.moduleSymbol.valueDeclaration, ts.isSourceFile); + var isDefaultExport = exportInfo_1.exportKind === 1 /* Default */; + var symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(exportInfo_1.symbol) || exportInfo_1.symbol; + pushAutoImportSymbol(symbol, { + kind: resolveModuleSpecifiers ? 32 /* ResolvedExport */ : 4 /* Export */, + moduleSpecifier: moduleSpecifier, + symbolName: symbolName, + exportName: exportInfo_1.exportKind === 2 /* ExportEquals */ ? "export=" /* ExportEquals */ : exportInfo_1.symbol.name, + fileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName, + isDefaultExport: isDefaultExport, + moduleSymbol: exportInfo_1.moduleSymbol, + isFromPackageJson: exportInfo_1.isFromPackageJson, + }); } }); - // By this point, any potential duplicates that were actually duplicates have been - // removed, so the rest need to be added. (Step 4 in diagrammed example) - aliasesToReturnIfOriginalsAreMissing.forEach(function (_a) { - var alias = _a.alias, moduleSymbol = _a.moduleSymbol, isFromPackageJson = _a.isFromPackageJson; - return pushSymbol(alias, moduleSymbol, isFromPackageJson, /*skipFilter*/ false); - }); - log("getSymbolsFromOtherSourceFileExports: " + (ts.timestamp() - startTime)); - return results; - function pushSymbol(symbol, moduleSymbol, isFromPackageJson, skipFilter) { - var isDefaultExport = symbol.escapedName === "default" /* Default */; - if (isDefaultExport) { - symbol = ts.getLocalSymbolForExportDefault(symbol) || symbol; + (_e = host.log) === null || _e === void 0 ? void 0 : _e.call(host, "collectAutoImports: done in " + (ts.timestamp() - start) + " ms"); + function isNameMatch(symbolName) { + var lowerCaseSymbolName = symbolName.toLowerCase(); + if (resolveModuleSpecifiers && lowerCaseTokenText) { + // Use a more restrictive filter if resolving module specifiers since resolving module specifiers is expensive. + return lowerCaseTokenText[0] === lowerCaseSymbolName[0] && stringContainsCharactersInOrder(lowerCaseSymbolName, lowerCaseTokenText); } - if (typeChecker.isUndefinedSymbol(symbol)) { - return; + return stringContainsCharactersInOrder(lowerCaseSymbolName, lowerCaseTokenText); + } + function isImportableExportInfo(info) { + var moduleFile = ts.tryCast(info.moduleSymbol.valueDeclaration, ts.isSourceFile); + if (!moduleFile) { + return packageJsonFilter + ? packageJsonFilter.allowsImportingAmbientModule(info.moduleSymbol, getModuleSpecifierResolutionHost(info.isFromPackageJson)) + : true; } - ts.addToSeen(resultSymbolIds, ts.getSymbolId(symbol)); - var origin = { kind: 4 /* Export */, moduleSymbol: moduleSymbol, isDefaultExport: isDefaultExport, isFromPackageJson: isFromPackageJson }; - results.push({ - symbol: symbol, - symbolName: ts.getNameForExportedSymbol(symbol, target), - origin: origin, - skipFilter: skipFilter, - }); + return ts.isImportableFile(info.isFromPackageJson ? packageJsonAutoImportProvider : program, sourceFile, moduleFile, packageJsonFilter, getModuleSpecifierResolutionHost(info.isFromPackageJson), moduleSpecifierCache); } } - function getNearestExportSymbol(fromSymbol) { - return findAlias(typeChecker, fromSymbol, function (alias) { - return ts.some(alias.declarations, function (d) { return ts.isExportSpecifier(d) || !!d.localSymbol; }); - }); + function pushAutoImportSymbol(symbol, origin) { + var symbolId = ts.getSymbolId(symbol); + if (symbolToSortTextIdMap[symbolId] === SortTextId.GlobalsOrKeywords) { + // If an auto-importable symbol is available as a global, don't add the auto import + return; + } + symbolToOriginInfoMap[symbols.length] = origin; + symbolToSortTextIdMap[symbolId] = importCompletionNode ? SortTextId.LocationPriority : SortTextId.AutoImportSuggestions; + symbols.push(symbol); } /** * True if you could remove some characters in `a` to get `b`. @@ -120601,7 +125018,8 @@ var ts; return true; } var characterIndex = 0; - for (var strIndex = 0; strIndex < str.length; strIndex++) { + var len = str.length; + for (var strIndex = 0; strIndex < len; strIndex++) { if (str.charCodeAt(strIndex) === characters.charCodeAt(characterIndex)) { characterIndex++; if (characterIndex === characters.length) { @@ -120637,7 +125055,7 @@ var ts; return true; } if (contextToken.kind === 31 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 275 /* JsxOpeningElement */) { + if (contextToken.parent.kind === 277 /* JsxOpeningElement */) { // Two possibilities: // 1.
/**/ // - contextToken: GreaterThanToken (before cursor) @@ -120647,54 +125065,56 @@ var ts; // - contextToken: GreaterThanToken (before cursor) // - location: GreaterThanToken (after cursor) // - same parent (JSXOpeningElement) - return location.parent.kind !== 275 /* JsxOpeningElement */; + return location.parent.kind !== 277 /* JsxOpeningElement */; } - if (contextToken.parent.kind === 276 /* JsxClosingElement */ || contextToken.parent.kind === 274 /* JsxSelfClosingElement */) { - return !!contextToken.parent.parent && contextToken.parent.parent.kind === 273 /* JsxElement */; + if (contextToken.parent.kind === 278 /* JsxClosingElement */ || contextToken.parent.kind === 276 /* JsxSelfClosingElement */) { + return !!contextToken.parent.parent && contextToken.parent.parent.kind === 275 /* JsxElement */; } } return false; } - function isNewIdentifierDefinitionLocation(previousToken) { - if (previousToken) { - var containingNodeKind = previousToken.parent.kind; + function isNewIdentifierDefinitionLocation() { + if (contextToken) { + var containingNodeKind = contextToken.parent.kind; // Previous token may have been a keyword that was converted to an identifier. - switch (keywordForNode(previousToken)) { + switch (keywordForNode(contextToken)) { case 27 /* CommaToken */: - return containingNodeKind === 203 /* CallExpression */ // func( a, | - || containingNodeKind === 166 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 204 /* NewExpression */ // new C(a, | - || containingNodeKind === 199 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 216 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 174 /* FunctionType */; // var x: (s: string, list| + return containingNodeKind === 205 /* CallExpression */ // func( a, | + || containingNodeKind === 168 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 206 /* NewExpression */ // new C(a, | + || containingNodeKind === 201 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 218 /* BinaryExpression */ // const x = (a, | + || containingNodeKind === 176 /* FunctionType */ // var x: (s: string, list| + || containingNodeKind === 202 /* ObjectLiteralExpression */; // const obj = { x, | case 20 /* OpenParenToken */: - return containingNodeKind === 203 /* CallExpression */ // func( | - || containingNodeKind === 166 /* Constructor */ // constructor( | - || containingNodeKind === 204 /* NewExpression */ // new C(a| - || containingNodeKind === 207 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 186 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + return containingNodeKind === 205 /* CallExpression */ // func( | + || containingNodeKind === 168 /* Constructor */ // constructor( | + || containingNodeKind === 206 /* NewExpression */ // new C(a| + || containingNodeKind === 209 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 188 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case 22 /* OpenBracketToken */: - return containingNodeKind === 199 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 171 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 158 /* ComputedPropertyName */; // [ | /* this can become an index signature */ - case 139 /* ModuleKeyword */: // module | - case 140 /* NamespaceKeyword */: // namespace | + return containingNodeKind === 201 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 173 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 160 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + case 140 /* ModuleKeyword */: // module | + case 141 /* NamespaceKeyword */: // namespace | return true; case 24 /* DotToken */: - return containingNodeKind === 256 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 258 /* ModuleDeclaration */; // module A.| case 18 /* OpenBraceToken */: - return containingNodeKind === 252 /* ClassDeclaration */; // class A{ | - case 62 /* EqualsToken */: - return containingNodeKind === 249 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 216 /* BinaryExpression */; // x = a| + return containingNodeKind === 254 /* ClassDeclaration */ // class A { | + || containingNodeKind === 202 /* ObjectLiteralExpression */; // const obj = { | + case 63 /* EqualsToken */: + return containingNodeKind === 251 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 218 /* BinaryExpression */; // x = a| case 15 /* TemplateHead */: - return containingNodeKind === 218 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 220 /* TemplateExpression */; // `aa ${| case 16 /* TemplateMiddle */: - return containingNodeKind === 228 /* TemplateSpan */; // `aa ${10} dd ${| - case 122 /* PublicKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - return containingNodeKind === 163 /* PropertyDeclaration */; // class A{ public | + return containingNodeKind === 230 /* TemplateSpan */; // `aa ${10} dd ${| + case 123 /* PublicKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + return containingNodeKind === 165 /* PropertyDeclaration */; // class A{ public | } } return false; @@ -120707,6 +125127,25 @@ var ts; return (ts.isRegularExpressionLiteral(contextToken) || ts.isStringTextContainingNode(contextToken)) && (ts.rangeContainsPositionExclusive(ts.createTextRangeFromSpan(ts.createTextSpanFromNode(contextToken)), position) || position === contextToken.end && (!!contextToken.isUnterminated || ts.isRegularExpressionLiteral(contextToken))); } + function tryGetObjectTypeLiteralInTypeArgumentCompletionSymbols() { + var typeLiteralNode = tryGetTypeLiteralNode(contextToken); + if (!typeLiteralNode) + return 0 /* Continue */; + var intersectionTypeNode = ts.isIntersectionTypeNode(typeLiteralNode.parent) ? typeLiteralNode.parent : undefined; + var containerTypeNode = intersectionTypeNode || typeLiteralNode; + var containerExpectedType = getConstraintOfTypeArgumentProperty(containerTypeNode, typeChecker); + if (!containerExpectedType) + return 0 /* 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.filter(members, function (s) { return !existingMemberEscapedNames.has(s.escapedName); }); + completionKind = 0 /* ObjectPropertyDeclaration */; + isNewIdentifierLocation = true; + return 1 /* Success */; + } /** * Aggregates relevant symbols for completion in object literals and object binding patterns. * Relevant symbols are stored in the captured 'symbols' variable. @@ -120721,7 +125160,7 @@ var ts; completionKind = 0 /* ObjectPropertyDeclaration */; var typeMembers; var existingMembers; - if (objectLikeContainer.kind === 200 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 202 /* ObjectLiteralExpression */) { var instantiatedType = tryGetObjectLiteralContextualType(objectLikeContainer, typeChecker); // Check completions for Object property value shorthand if (instantiatedType === undefined) { @@ -120746,7 +125185,7 @@ var ts; } } else { - ts.Debug.assert(objectLikeContainer.kind === 196 /* ObjectBindingPattern */); + ts.Debug.assert(objectLikeContainer.kind === 198 /* ObjectBindingPattern */); // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -120757,12 +125196,12 @@ 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.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 239 /* ForOfStatement */; - if (!canGetType && rootDeclaration.kind === 160 /* Parameter */) { + var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 241 /* ForOfStatement */; + if (!canGetType && rootDeclaration.kind === 162 /* Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 165 /* MethodDeclaration */ || rootDeclaration.parent.kind === 168 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 167 /* MethodDeclaration */ || rootDeclaration.parent.kind === 170 /* SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -120809,9 +125248,9 @@ var ts; if (!namedImportsOrExports) return 0 /* Continue */; // try to show exported member for imported/re-exported module - var moduleSpecifier = (namedImportsOrExports.kind === 264 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; + var moduleSpecifier = (namedImportsOrExports.kind === 266 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; if (!moduleSpecifier) - return namedImportsOrExports.kind === 264 /* NamedImports */ ? 2 /* Fail */ : 0 /* Continue */; + return namedImportsOrExports.kind === 266 /* NamedImports */ ? 2 /* Fail */ : 0 /* Continue */; var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); // TODO: GH#18217 if (!moduleSpecifierSymbol) return 2 /* Fail */; @@ -120846,7 +125285,7 @@ var ts; var _a, _b; symbols.push(symbol); if ((_b = (_a = localsContainer.symbol) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.has(name)) { - symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.OptionalMember; + symbolToSortTextIdMap[ts.getSymbolId(symbol)] = SortTextId.OptionalMember; } }); return 1 /* Success */; @@ -120871,7 +125310,7 @@ var ts; var classElement = contextToken.kind === 26 /* SemicolonToken */ ? contextToken.parent.parent : contextToken.parent; var classElementModifierFlags = ts.isClassElement(classElement) ? ts.getEffectiveModifierFlags(classElement) : 0 /* None */; // If this is context token is not something we are editing now, consider if this would lead to be modifier - if (contextToken.kind === 78 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { + if (contextToken.kind === 79 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { switch (contextToken.getText()) { case "private": classElementModifierFlags = classElementModifierFlags | 8 /* Private */; @@ -120879,12 +125318,16 @@ var ts; case "static": classElementModifierFlags = classElementModifierFlags | 32 /* Static */; break; + case "override": + classElementModifierFlags = classElementModifierFlags | 16384 /* Override */; + break; } } // No member list for private methods if (!(classElementModifierFlags & 8 /* Private */)) { // List of property symbols of base type that are not private and already implemented - var baseSymbols = ts.flatMap(ts.getAllSuperTypeNodes(decl), function (baseTypeNode) { + var baseTypeNodes = ts.isClassLike(decl) && classElementModifierFlags & 16384 /* 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 */ ? (type === null || type === void 0 ? void 0 : type.symbol) && typeChecker.getPropertiesOfType(typeChecker.getTypeOfSymbolAtLocation(type.symbol, decl)) : @@ -120910,7 +125353,7 @@ var ts; break; case 41 /* AsteriskToken */: return ts.isMethodDeclaration(parent) ? ts.tryCast(parent.parent, ts.isObjectLiteralExpression) : undefined; - case 78 /* Identifier */: + case 79 /* Identifier */: return contextToken.text === "async" && ts.isShorthandPropertyAssignment(contextToken.parent) ? contextToken.parent.parent : undefined; } @@ -120963,12 +125406,12 @@ var ts; case 31 /* GreaterThanToken */: // End of a type argument list case 30 /* LessThanSlashToken */: case 43 /* SlashToken */: - case 78 /* Identifier */: - case 201 /* PropertyAccessExpression */: - case 281 /* JsxAttributes */: - case 280 /* JsxAttribute */: - case 282 /* JsxSpreadAttribute */: - if (parent && (parent.kind === 274 /* JsxSelfClosingElement */ || parent.kind === 275 /* JsxOpeningElement */)) { + case 79 /* Identifier */: + case 203 /* PropertyAccessExpression */: + case 283 /* JsxAttributes */: + case 282 /* JsxAttribute */: + case 284 /* JsxSpreadAttribute */: + if (parent && (parent.kind === 276 /* JsxSelfClosingElement */ || parent.kind === 277 /* JsxOpeningElement */)) { if (contextToken.kind === 31 /* GreaterThanToken */) { var precedingToken = ts.findPrecedingToken(contextToken.pos, sourceFile, /*startNode*/ undefined); if (!parent.typeArguments || (precedingToken && precedingToken.kind === 43 /* SlashToken */)) @@ -120976,7 +125419,7 @@ var ts; } return parent; } - else if (parent.kind === 280 /* JsxAttribute */) { + else if (parent.kind === 282 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -120988,7 +125431,7 @@ var ts; // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement case 10 /* StringLiteral */: - if (parent && ((parent.kind === 280 /* JsxAttribute */) || (parent.kind === 282 /* JsxSpreadAttribute */))) { + if (parent && ((parent.kind === 282 /* JsxAttribute */) || (parent.kind === 284 /* JsxSpreadAttribute */))) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -120998,8 +125441,8 @@ var ts; break; case 19 /* CloseBraceToken */: if (parent && - parent.kind === 283 /* JsxExpression */ && - parent.parent && parent.parent.kind === 280 /* JsxAttribute */) { + parent.kind === 285 /* JsxExpression */ && + parent.parent && parent.parent.kind === 282 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -121007,7 +125450,7 @@ var ts; // each JsxAttribute can have initializer as JsxExpression return parent.parent.parent.parent; } - if (parent && parent.kind === 282 /* JsxSpreadAttribute */) { + if (parent && parent.kind === 284 /* JsxSpreadAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -121027,67 +125470,67 @@ var ts; var containingNodeKind = parent.kind; switch (contextToken.kind) { case 27 /* CommaToken */: - return containingNodeKind === 249 /* VariableDeclaration */ || + return containingNodeKind === 251 /* VariableDeclaration */ || isVariableDeclarationListButNotTypeArgument(contextToken) || - containingNodeKind === 232 /* VariableStatement */ || - containingNodeKind === 255 /* EnumDeclaration */ || // enum a { foo, | + containingNodeKind === 234 /* VariableStatement */ || + containingNodeKind === 257 /* EnumDeclaration */ || // enum a { foo, | isFunctionLikeButNotConstructor(containingNodeKind) || - containingNodeKind === 253 /* InterfaceDeclaration */ || // interface A= contextToken.pos); case 24 /* DotToken */: - return containingNodeKind === 197 /* ArrayBindingPattern */; // var [.| + return containingNodeKind === 199 /* ArrayBindingPattern */; // var [.| case 58 /* ColonToken */: - return containingNodeKind === 198 /* BindingElement */; // var {x :html| + return containingNodeKind === 200 /* BindingElement */; // var {x :html| case 22 /* OpenBracketToken */: - return containingNodeKind === 197 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 199 /* ArrayBindingPattern */; // var [x| case 20 /* OpenParenToken */: - return containingNodeKind === 287 /* CatchClause */ || + return containingNodeKind === 289 /* CatchClause */ || isFunctionLikeButNotConstructor(containingNodeKind); case 18 /* OpenBraceToken */: - return containingNodeKind === 255 /* EnumDeclaration */; // enum a { | + return containingNodeKind === 257 /* EnumDeclaration */; // enum a { | case 29 /* LessThanToken */: - return containingNodeKind === 252 /* ClassDeclaration */ || // class A< | - containingNodeKind === 221 /* ClassExpression */ || // var C = class D< | - containingNodeKind === 253 /* InterfaceDeclaration */ || // interface A< | - containingNodeKind === 254 /* TypeAliasDeclaration */ || // type List< | + return containingNodeKind === 254 /* ClassDeclaration */ || // class A< | + containingNodeKind === 223 /* ClassExpression */ || // var C = class D< | + containingNodeKind === 255 /* InterfaceDeclaration */ || // interface A< | + containingNodeKind === 256 /* TypeAliasDeclaration */ || // type List< | ts.isFunctionLikeKind(containingNodeKind); - case 123 /* StaticKeyword */: - return containingNodeKind === 163 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); + case 124 /* StaticKeyword */: + return containingNodeKind === 165 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); case 25 /* DotDotDotToken */: - return containingNodeKind === 160 /* Parameter */ || - (!!parent.parent && parent.parent.kind === 197 /* ArrayBindingPattern */); // var [...z| - case 122 /* PublicKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - return containingNodeKind === 160 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); - case 126 /* AsKeyword */: - return containingNodeKind === 265 /* ImportSpecifier */ || - containingNodeKind === 270 /* ExportSpecifier */ || - containingNodeKind === 263 /* NamespaceImport */; - case 134 /* GetKeyword */: - case 146 /* SetKeyword */: + return containingNodeKind === 162 /* Parameter */ || + (!!parent.parent && parent.parent.kind === 199 /* ArrayBindingPattern */); // var [...z| + case 123 /* PublicKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + return containingNodeKind === 162 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); + case 127 /* AsKeyword */: + return containingNodeKind === 267 /* ImportSpecifier */ || + containingNodeKind === 272 /* ExportSpecifier */ || + containingNodeKind === 265 /* NamespaceImport */; + case 135 /* GetKeyword */: + case 147 /* SetKeyword */: return !isFromObjectTypeDeclaration(contextToken); - case 83 /* ClassKeyword */: - case 91 /* EnumKeyword */: - case 117 /* InterfaceKeyword */: - case 97 /* FunctionKeyword */: - case 112 /* VarKeyword */: - case 99 /* ImportKeyword */: - case 118 /* LetKeyword */: - case 84 /* ConstKeyword */: - case 135 /* InferKeyword */: - case 149 /* TypeKeyword */: // type htm| + 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 136 /* InferKeyword */: + case 150 /* TypeKeyword */: // type htm| return true; case 41 /* AsteriskToken */: return ts.isFunctionLike(contextToken.parent) && !ts.isMethodDeclaration(contextToken.parent); } - // If the previous token is keyword correspoding to class member completion keyword + // If the previous token is keyword corresponding to class member completion keyword // there will be completion available here if (isClassMemberCompletionKeyword(keywordForNode(contextToken)) && isFromObjectTypeDeclaration(contextToken)) { return false; @@ -121105,23 +125548,48 @@ var ts; } // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(contextToken)) { - case 125 /* AbstractKeyword */: - case 83 /* ClassKeyword */: - case 84 /* ConstKeyword */: - case 133 /* DeclareKeyword */: - case 91 /* EnumKeyword */: - case 97 /* FunctionKeyword */: - case 117 /* InterfaceKeyword */: - case 118 /* LetKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 122 /* PublicKeyword */: - case 123 /* StaticKeyword */: - case 112 /* VarKeyword */: + case 126 /* AbstractKeyword */: + case 84 /* ClassKeyword */: + case 85 /* ConstKeyword */: + case 134 /* 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 */: return true; - case 129 /* AsyncKeyword */: + case 130 /* AsyncKeyword */: return ts.isPropertyDeclaration(contextToken.parent); } + // If we are inside a class declaration, and `constructor` is totally not present, + // but we request a completion manually at a whitespace... + var ancestorClassLike = ts.findAncestor(contextToken.parent, ts.isClassLike); + if (ancestorClassLike && contextToken === previousToken && isPreviousPropertyDeclarationTerminated(contextToken, position)) { + return false; // Don't block completions. + } + var ancestorPropertyDeclaraion = ts.getAncestor(contextToken.parent, 165 /* PropertyDeclaration */); + // If we are inside a class declaration and typing `constructor` after property declaration... + if (ancestorPropertyDeclaraion + && contextToken !== previousToken + && ts.isClassLike(previousToken.parent.parent) + // And the cursor is at the token... + && position <= previousToken.end) { + // If we are sure that the previous property declaration is terminated according to newline or semicolon... + if (isPreviousPropertyDeclarationTerminated(contextToken, previousToken.end)) { + return false; // Don't block completions. + } + else if (contextToken.kind !== 63 /* 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) + || ts.hasType(ancestorPropertyDeclaraion))) { + return true; + } + } return ts.isDeclarationName(contextToken) && !ts.isShorthandPropertyAssignment(contextToken.parent) && !ts.isJsxAttribute(contextToken.parent) @@ -121129,8 +125597,13 @@ var ts; // If `contextToken !== previousToken`, this is `class C ex/**/`. && !(ts.isClassLike(contextToken.parent) && (contextToken !== previousToken || position > previousToken.end)); } + function isPreviousPropertyDeclarationTerminated(contextToken, position) { + return contextToken.kind !== 63 /* EqualsToken */ && + (contextToken.kind === 26 /* SemicolonToken */ + || !ts.positionsAreOnSameLine(contextToken.end, position, sourceFile)); + } function isFunctionLikeButNotConstructor(kind) { - return ts.isFunctionLikeKind(kind) && kind !== 166 /* Constructor */; + return ts.isFunctionLikeKind(kind) && kind !== 168 /* Constructor */; } function isDotOfNumericLiteral(contextToken) { if (contextToken.kind === 8 /* NumericLiteral */) { @@ -121140,7 +125613,7 @@ var ts; return false; } function isVariableDeclarationListButNotTypeArgument(node) { - return node.parent.kind === 250 /* VariableDeclarationList */ + return node.parent.kind === 252 /* VariableDeclarationList */ && !ts.isPossiblyTypeArgumentPosition(node, sourceFile, typeChecker); } /** @@ -121158,13 +125631,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 !== 288 /* PropertyAssignment */ && - m.kind !== 289 /* ShorthandPropertyAssignment */ && - m.kind !== 198 /* BindingElement */ && - m.kind !== 165 /* MethodDeclaration */ && - m.kind !== 167 /* GetAccessor */ && - m.kind !== 168 /* SetAccessor */ && - m.kind !== 290 /* SpreadAssignment */) { + if (m.kind !== 290 /* PropertyAssignment */ && + m.kind !== 291 /* ShorthandPropertyAssignment */ && + m.kind !== 200 /* BindingElement */ && + m.kind !== 167 /* MethodDeclaration */ && + m.kind !== 169 /* GetAccessor */ && + m.kind !== 170 /* SetAccessor */ && + m.kind !== 292 /* SpreadAssignment */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -121177,7 +125650,7 @@ var ts; } else if (ts.isBindingElement(m) && m.propertyName) { // include only identifiers in completion list - if (m.propertyName.kind === 78 /* Identifier */) { + if (m.propertyName.kind === 79 /* Identifier */) { existingName = m.propertyName.escapedText; } } @@ -121210,8 +125683,10 @@ var ts; // Set SortText to OptionalMember if it is an optional member function setSortTextToOptionalMember() { symbols.forEach(function (m) { + var _a; if (m.flags & 16777216 /* Optional */) { - symbolToSortTextMap[ts.getSymbolId(m)] = symbolToSortTextMap[ts.getSymbolId(m)] || SortText.OptionalMember; + var symbolId = ts.getSymbolId(m); + symbolToSortTextIdMap[symbolId] = (_a = symbolToSortTextIdMap[symbolId]) !== null && _a !== void 0 ? _a : SortTextId.OptionalMember; } }); } @@ -121223,7 +125698,7 @@ var ts; for (var _i = 0, contextualMemberSymbols_1 = contextualMemberSymbols; _i < contextualMemberSymbols_1.length; _i++) { var contextualMemberSymbol = contextualMemberSymbols_1[_i]; if (membersDeclaredBySpreadAssignment.has(contextualMemberSymbol.name)) { - symbolToSortTextMap[ts.getSymbolId(contextualMemberSymbol)] = SortText.MemberDeclaredBySpreadAssignment; + symbolToSortTextIdMap[ts.getSymbolId(contextualMemberSymbol)] = SortTextId.MemberDeclaredBySpreadAssignment; } } } @@ -121237,10 +125712,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 !== 163 /* PropertyDeclaration */ && - m.kind !== 165 /* MethodDeclaration */ && - m.kind !== 167 /* GetAccessor */ && - m.kind !== 168 /* SetAccessor */) { + if (m.kind !== 165 /* PropertyDeclaration */ && + m.kind !== 167 /* MethodDeclaration */ && + m.kind !== 169 /* GetAccessor */ && + m.kind !== 170 /* SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -121264,7 +125739,7 @@ var ts; return !existingMemberNames.has(propertySymbol.escapedName) && !!propertySymbol.declarations && !(ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 8 /* Private */) && - !(propertySymbol.valueDeclaration && ts.isPrivateIdentifierPropertyDeclaration(propertySymbol.valueDeclaration)); + !(propertySymbol.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(propertySymbol.valueDeclaration)); }); } /** @@ -121282,7 +125757,7 @@ var ts; if (isCurrentlyEditingNode(attr)) { continue; } - if (attr.kind === 280 /* JsxAttribute */) { + if (attr.kind === 282 /* JsxAttribute */) { seenNames.add(attr.name.escapedText); } else if (ts.isJsxSpreadAttribute(attr)) { @@ -121297,8 +125772,35 @@ var ts; return node.getStart(sourceFile) <= position && position <= node.getEnd(); } } + function getAutoImportSymbolFromCompletionEntryData(name, data, program, host) { + var containingProgram = data.isPackageJsonImport ? host.getPackageJsonAutoImportProvider() : program; + var checker = containingProgram.getTypeChecker(); + var moduleSymbol = data.ambientModuleName ? checker.tryFindAmbientModule(data.ambientModuleName) : + data.fileName ? checker.getMergedSymbol(ts.Debug.checkDefined(containingProgram.getSourceFile(data.fileName)).symbol) : + undefined; + if (!moduleSymbol) + return undefined; + var symbol = data.exportName === "export=" /* ExportEquals */ + ? checker.resolveExternalModuleSymbol(moduleSymbol) + : checker.tryGetMemberInModuleExportsAndProperties(data.exportName, moduleSymbol); + if (!symbol) + return undefined; + var isDefaultExport = data.exportName === "default" /* Default */; + symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(symbol) || symbol; + return { + symbol: symbol, + origin: { + kind: data.moduleSpecifier ? 32 /* ResolvedExport */ : 4 /* Export */, + moduleSymbol: moduleSymbol, + symbolName: name, + isDefaultExport: isDefaultExport, + exportName: data.exportName, + fileName: data.fileName, + } + }; + } function getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind, jsxIdentifierExpected) { - var name = originIsExport(origin) ? ts.getNameForExportedSymbol(symbol, target) : symbol.name; + var name = originIncludesSymbolName(origin) ? origin.symbolName : symbol.name; 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) @@ -121308,7 +125810,7 @@ var ts; return undefined; } var validNameResult = { name: name, needsConvertPropertyAccess: false }; - if (ts.isIdentifierText(name, target, jsxIdentifierExpected ? 1 /* JSX */ : 0 /* Standard */) || symbol.valueDeclaration && ts.isPrivateIdentifierPropertyDeclaration(symbol.valueDeclaration)) { + if (ts.isIdentifierText(name, target, jsxIdentifierExpected ? 1 /* JSX */ : 0 /* Standard */) || symbol.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(symbol.valueDeclaration)) { return validNameResult; } switch (kind) { @@ -121332,7 +125834,7 @@ var ts; var _keywordCompletions = []; var allKeywordsCompletions = ts.memoize(function () { var res = []; - for (var i = 80 /* FirstKeyword */; i <= 156 /* LastKeyword */; i++) { + for (var i = 81 /* FirstKeyword */; i <= 158 /* LastKeyword */; i++) { res.push({ name: ts.tokenToString(i), kind: "keyword" /* keyword */, @@ -121358,11 +125860,11 @@ var ts; return false; case 1 /* All */: return isFunctionLikeBodyKeyword(kind) - || kind === 133 /* DeclareKeyword */ - || kind === 139 /* ModuleKeyword */ - || kind === 149 /* TypeKeyword */ - || kind === 140 /* NamespaceKeyword */ - || ts.isTypeKeyword(kind) && kind !== 150 /* UndefinedKeyword */; + || kind === 134 /* DeclareKeyword */ + || kind === 140 /* ModuleKeyword */ + || kind === 150 /* TypeKeyword */ + || kind === 141 /* NamespaceKeyword */ + || ts.isTypeKeyword(kind) && kind !== 151 /* UndefinedKeyword */; case 5 /* FunctionLikeBodyKeywords */: return isFunctionLikeBodyKeyword(kind); case 2 /* ClassElementKeywords */: @@ -121372,7 +125874,7 @@ var ts; case 4 /* ConstructorParameterKeywords */: return ts.isParameterPropertyModifier(kind); case 6 /* TypeAssertionKeywords */: - return ts.isTypeKeyword(kind) || kind === 84 /* ConstKeyword */; + return ts.isTypeKeyword(kind) || kind === 85 /* ConstKeyword */; case 7 /* TypeKeywords */: return ts.isTypeKeyword(kind); default: @@ -121382,57 +125884,59 @@ var ts; } function isTypeScriptOnlyKeyword(kind) { switch (kind) { - case 125 /* AbstractKeyword */: - case 128 /* AnyKeyword */: - case 155 /* BigIntKeyword */: - case 131 /* BooleanKeyword */: - case 133 /* DeclareKeyword */: - case 91 /* EnumKeyword */: - case 154 /* GlobalKeyword */: - case 116 /* ImplementsKeyword */: - case 135 /* InferKeyword */: - case 117 /* InterfaceKeyword */: - case 137 /* IsKeyword */: - case 138 /* KeyOfKeyword */: - case 139 /* ModuleKeyword */: - case 140 /* NamespaceKeyword */: - case 141 /* NeverKeyword */: - case 144 /* NumberKeyword */: - case 145 /* ObjectKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 122 /* PublicKeyword */: - case 142 /* ReadonlyKeyword */: - case 147 /* StringKeyword */: - case 148 /* SymbolKeyword */: - case 149 /* TypeKeyword */: - case 151 /* UniqueKeyword */: - case 152 /* UnknownKeyword */: + case 126 /* AbstractKeyword */: + case 129 /* AnyKeyword */: + case 156 /* BigIntKeyword */: + case 132 /* BooleanKeyword */: + case 134 /* DeclareKeyword */: + case 92 /* EnumKeyword */: + case 155 /* GlobalKeyword */: + case 117 /* ImplementsKeyword */: + case 136 /* InferKeyword */: + case 118 /* InterfaceKeyword */: + case 138 /* IsKeyword */: + case 139 /* KeyOfKeyword */: + case 140 /* ModuleKeyword */: + case 141 /* NamespaceKeyword */: + case 142 /* NeverKeyword */: + case 145 /* NumberKeyword */: + case 146 /* ObjectKeyword */: + case 157 /* OverrideKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + case 123 /* PublicKeyword */: + case 143 /* ReadonlyKeyword */: + case 148 /* StringKeyword */: + case 149 /* SymbolKeyword */: + case 150 /* TypeKeyword */: + case 152 /* UniqueKeyword */: + case 153 /* UnknownKeyword */: return true; default: return false; } } function isInterfaceOrTypeLiteralCompletionKeyword(kind) { - return kind === 142 /* ReadonlyKeyword */; + return kind === 143 /* ReadonlyKeyword */; } function isClassMemberCompletionKeyword(kind) { switch (kind) { - case 125 /* AbstractKeyword */: - case 132 /* ConstructorKeyword */: - case 134 /* GetKeyword */: - case 146 /* SetKeyword */: - case 129 /* AsyncKeyword */: - case 133 /* DeclareKeyword */: + case 126 /* AbstractKeyword */: + case 133 /* ConstructorKeyword */: + case 135 /* GetKeyword */: + case 147 /* SetKeyword */: + case 130 /* AsyncKeyword */: + case 134 /* DeclareKeyword */: + case 157 /* OverrideKeyword */: return true; default: return ts.isClassMemberModifier(kind); } } function isFunctionLikeBodyKeyword(kind) { - return kind === 129 /* AsyncKeyword */ - || kind === 130 /* AwaitKeyword */ - || kind === 126 /* AsKeyword */ + return kind === 130 /* AsyncKeyword */ + || kind === 131 /* AwaitKeyword */ + || kind === 127 /* AsKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind); } function keywordForNode(node) { @@ -121484,7 +125988,7 @@ var ts; function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location, position) { // class c { method() { } | method2() { } } switch (location.kind) { - case 334 /* SyntaxList */: + case 342 /* SyntaxList */: return ts.tryCast(location.parent, ts.isObjectTypeDeclaration); case 1 /* EndOfFileToken */: var cls = ts.tryCast(ts.lastOrUndefined(ts.cast(location.parent, ts.isSourceFile).statements), ts.isObjectTypeDeclaration); @@ -121492,7 +125996,7 @@ var ts; return cls; } break; - case 78 /* Identifier */: { + case 79 /* Identifier */: { // class c { public prop = c| } if (ts.isPropertyDeclaration(location.parent) && location.parent.initializer === location) { return undefined; @@ -121505,8 +126009,14 @@ var ts; } if (!contextToken) return undefined; + // class C { blah; constructor/**/ } and so on + if (location.kind === 133 /* 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 62 /* EqualsToken */: // class c { public prop = | /* global completions */ } + case 63 /* EqualsToken */: // class c { public prop = | /* global completions */ } return undefined; case 26 /* SemicolonToken */: // class c {getValue(): number; | } case 19 /* CloseBraceToken */: // class c { method() { } | } @@ -121530,6 +126040,44 @@ var ts; ? contextToken.parent.parent : undefined; } } + function tryGetTypeLiteralNode(node) { + if (!node) + return undefined; + var parent = node.parent; + switch (node.kind) { + case 18 /* OpenBraceToken */: + if (ts.isTypeLiteralNode(parent)) { + return parent; + } + break; + case 26 /* SemicolonToken */: + case 27 /* CommaToken */: + case 79 /* Identifier */: + if (parent.kind === 164 /* PropertySignature */ && ts.isTypeLiteralNode(parent.parent)) { + return parent.parent; + } + break; + } + return undefined; + } + function getConstraintOfTypeArgumentProperty(node, checker) { + if (!node) + return undefined; + if (ts.isTypeNode(node) && ts.isTypeReferenceType(node.parent)) { + return checker.getTypeArgumentConstraint(node); + } + var t = getConstraintOfTypeArgumentProperty(node.parent, checker); + if (!t) + return undefined; + switch (node.kind) { + case 164 /* PropertySignature */: + return checker.getTypeOfPropertyOfContextualType(t, node.symbol.escapedName); + case 185 /* IntersectionType */: + case 179 /* TypeLiteral */: + case 184 /* UnionType */: + return t; + } + } // TODO: GH#19856 Would like to return `node is Node & { parent: (ClassElement | TypeElement) & { parent: ObjectTypeDeclaration } }` but then compilation takes > 10 minutes function isFromObjectTypeDeclaration(node) { return node.parent && ts.isClassOrTypeElement(node.parent) && ts.isObjectTypeDeclaration(node.parent.parent); @@ -121553,6 +126101,8 @@ var ts; return !!contextToken && (ts.isStringLiteralLike(contextToken) ? !!ts.tryGetImportFromModuleSpecifier(contextToken) : contextToken.kind === 43 /* SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); + case " ": + return !!contextToken && ts.isImportKeyword(contextToken) && contextToken.parent.kind === 299 /* SourceFile */; default: return ts.Debug.assertNever(triggerCharacter); } @@ -121561,14 +126111,6 @@ var ts; var left = _a.left; return ts.nodeIsMissing(left); } - function findAlias(typeChecker, symbol, predicate) { - var currentAlias = symbol; - while (currentAlias.flags & 2097152 /* Alias */ && (currentAlias = typeChecker.getImmediateAliasedSymbol(currentAlias))) { - if (predicate(currentAlias)) { - return currentAlias; - } - } - } /** Determines if a type is exactly the same type resolved by the global 'self', 'global', or 'globalThis'. */ 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 @@ -121595,11 +126137,71 @@ var ts; if (type) { return type; } - if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 /* EqualsToken */) { + if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* EqualsToken */ && node === node.parent.left) { + // Object literal is assignment pattern: ({ | } = x) return typeChecker.getTypeAtLocation(node.parent); } return undefined; } + function getImportCompletionNode(contextToken) { + var candidate = getCandidate(); + return candidate === 154 /* FromKeyword */ || candidate && ts.rangeIsOnSingleLine(candidate, candidate.getSourceFile()) ? candidate : undefined; + function getCandidate() { + var parent = contextToken.parent; + if (ts.isImportEqualsDeclaration(parent)) { + return isModuleSpecifierMissingOrEmpty(parent.moduleReference) ? parent : undefined; + } + if (ts.isNamedImports(parent) || ts.isNamespaceImport(parent)) { + if (isModuleSpecifierMissingOrEmpty(parent.parent.parent.moduleSpecifier) && (ts.isNamespaceImport(parent) || parent.elements.length < 2) && !parent.parent.name) { + // At `import { ... } |` or `import * as Foo |`, the only possible completion is `from` + return contextToken.kind === 19 /* CloseBraceToken */ || contextToken.kind === 79 /* Identifier */ + ? 154 /* FromKeyword */ + : parent.parent.parent; + } + return undefined; + } + if (ts.isImportKeyword(contextToken) && ts.isSourceFile(parent)) { + // A lone import keyword with nothing following it does not parse as a statement at all + return contextToken; + } + if (ts.isImportKeyword(contextToken) && ts.isImportDeclaration(parent)) { + // `import s| from` + return isModuleSpecifierMissingOrEmpty(parent.moduleSpecifier) ? parent : undefined; + } + return undefined; + } + } + function isModuleSpecifierMissingOrEmpty(specifier) { + var _a; + if (ts.nodeIsMissing(specifier)) + return true; + return !((_a = ts.tryCast(ts.isExternalModuleReference(specifier) ? specifier.expression : specifier, ts.isStringLiteralLike)) === null || _a === void 0 ? void 0 : _a.text); + } + function getVariableDeclaration(property) { + var variableDeclaration = ts.findAncestor(property, function (node) { + return ts.isFunctionBlock(node) || isArrowFunctionBody(node) || ts.isBindingPattern(node) + ? "quit" + : ts.isVariableDeclaration(node); + }); + return variableDeclaration; + } + function isArrowFunctionBody(node) { + return node.parent && ts.isArrowFunction(node.parent) && node.parent.body === node; + } + ; + /** True if symbol is a type or a module containing at least one type. */ + function symbolCanBeReferencedAtTypeLocation(symbol, checker, seenModules) { + if (seenModules === void 0) { seenModules = new ts.Map(); } + var sym = ts.skipAlias(symbol.exportSymbol || symbol, checker); + return !!(sym.flags & 788968 /* Type */) || + !!(sym.flags & 1536 /* Module */) && + ts.addToSeen(seenModules, ts.getSymbolId(sym)) && + checker.getExportsOfModule(sym).some(function (e) { return symbolCanBeReferencedAtTypeLocation(e, checker, seenModules); }); + } + function isDeprecated(symbol, checker) { + var declarations = ts.skipAlias(symbol, checker).declarations; + return !!ts.length(declarations) && ts.every(declarations, ts.isDeprecatedDeclaration); + } })(Completions = ts.Completions || (ts.Completions = {})); })(ts || (ts = {})); var ts; @@ -121634,10 +126236,13 @@ var ts; if (!referenceEntries) return undefined; var map = ts.arrayToMultiMap(referenceEntries.map(ts.FindAllReferences.toHighlightSpan), function (e) { return e.fileName; }, function (e) { return e.span; }); - return ts.arrayFrom(map.entries(), function (_a) { + var getCanonicalFileName = ts.createGetCanonicalFileName(program.useCaseSensitiveFileNames()); + return ts.mapDefined(ts.arrayFrom(map.entries()), function (_a) { var fileName = _a[0], highlightSpans = _a[1]; if (!sourceFilesSet.has(fileName)) { - ts.Debug.assert(program.redirectTargetsMap.has(fileName)); + if (!program.redirectTargetsMap.has(ts.toPath(fileName, program.getCurrentDirectory(), getCanonicalFileName))) { + return undefined; + } var redirectTarget_1 = program.getSourceFile(fileName); var redirect = ts.find(sourceFilesToSearch, function (f) { return !!f.redirectInfo && f.redirectInfo.redirectTarget === redirectTarget_1; }); fileName = redirect.fileName; @@ -121652,44 +126257,44 @@ var ts; } function getHighlightSpans(node, sourceFile) { switch (node.kind) { - case 98 /* IfKeyword */: - case 90 /* ElseKeyword */: + case 99 /* IfKeyword */: + case 91 /* ElseKeyword */: return ts.isIfStatement(node.parent) ? getIfElseOccurrences(node.parent, sourceFile) : undefined; - case 104 /* ReturnKeyword */: + case 105 /* ReturnKeyword */: return useParent(node.parent, ts.isReturnStatement, getReturnOccurrences); - case 108 /* ThrowKeyword */: + case 109 /* ThrowKeyword */: return useParent(node.parent, ts.isThrowStatement, getThrowOccurrences); - case 110 /* TryKeyword */: - case 82 /* CatchKeyword */: - case 95 /* FinallyKeyword */: - var tryStatement = node.kind === 82 /* CatchKeyword */ ? node.parent.parent : node.parent; + case 111 /* TryKeyword */: + case 83 /* CatchKeyword */: + case 96 /* FinallyKeyword */: + var tryStatement = node.kind === 83 /* CatchKeyword */ ? node.parent.parent : node.parent; return useParent(tryStatement, ts.isTryStatement, getTryCatchFinallyOccurrences); - case 106 /* SwitchKeyword */: + case 107 /* SwitchKeyword */: return useParent(node.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); - case 81 /* CaseKeyword */: - case 87 /* DefaultKeyword */: { + case 82 /* CaseKeyword */: + case 88 /* DefaultKeyword */: { if (ts.isDefaultClause(node.parent) || ts.isCaseClause(node.parent)) { return useParent(node.parent.parent.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); } return undefined; } - case 80 /* BreakKeyword */: - case 85 /* ContinueKeyword */: + case 81 /* BreakKeyword */: + case 86 /* ContinueKeyword */: return useParent(node.parent, ts.isBreakOrContinueStatement, getBreakOrContinueStatementOccurrences); - case 96 /* ForKeyword */: - case 114 /* WhileKeyword */: - case 89 /* DoKeyword */: + case 97 /* ForKeyword */: + case 115 /* WhileKeyword */: + case 90 /* DoKeyword */: return useParent(node.parent, function (n) { return ts.isIterationStatement(n, /*lookInLabeledStatements*/ true); }, getLoopBreakContinueOccurrences); - case 132 /* ConstructorKeyword */: - return getFromAllDeclarations(ts.isConstructorDeclaration, [132 /* ConstructorKeyword */]); - case 134 /* GetKeyword */: - case 146 /* SetKeyword */: - return getFromAllDeclarations(ts.isAccessor, [134 /* GetKeyword */, 146 /* SetKeyword */]); - case 130 /* AwaitKeyword */: + case 133 /* ConstructorKeyword */: + return getFromAllDeclarations(ts.isConstructorDeclaration, [133 /* ConstructorKeyword */]); + case 135 /* GetKeyword */: + case 147 /* SetKeyword */: + return getFromAllDeclarations(ts.isAccessor, [135 /* GetKeyword */, 147 /* SetKeyword */]); + case 131 /* AwaitKeyword */: return useParent(node.parent, ts.isAwaitExpression, getAsyncAndAwaitOccurrences); - case 129 /* AsyncKeyword */: + case 130 /* AsyncKeyword */: return highlightSpans(getAsyncAndAwaitOccurrences(node)); - case 124 /* YieldKeyword */: + case 125 /* YieldKeyword */: return highlightSpans(getYieldOccurrences(node)); default: return ts.isModifierKind(node.kind) && (ts.isDeclaration(node.parent) || ts.isVariableStatement(node.parent)) @@ -121732,7 +126337,7 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (ts.isFunctionBlock(parent) || parent.kind === 297 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 299 /* SourceFile */) { return parent; } // A throw-statement is only owned by a try-statement if the try-statement has @@ -121764,16 +126369,16 @@ var ts; function getBreakOrContinueOwner(statement) { return ts.findAncestor(statement, function (node) { switch (node.kind) { - case 244 /* SwitchStatement */: - if (statement.kind === 240 /* ContinueStatement */) { + case 246 /* SwitchStatement */: + if (statement.kind === 242 /* ContinueStatement */) { return false; } // falls through - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 236 /* WhileStatement */: - case 235 /* DoStatement */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 238 /* WhileStatement */: + case 237 /* DoStatement */: return !statement.label || isLabeledBy(node, statement.label.escapedText); default: // Don't cross function boundaries. @@ -121789,11 +126394,11 @@ var ts; // Types of node whose children might have modifiers. var container = declaration.parent; switch (container.kind) { - case 257 /* ModuleBlock */: - case 297 /* SourceFile */: - case 230 /* Block */: - case 284 /* CaseClause */: - case 285 /* DefaultClause */: + case 259 /* ModuleBlock */: + case 299 /* SourceFile */: + case 232 /* Block */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 128 /* Abstract */ && ts.isClassDeclaration(declaration)) { return __spreadArray(__spreadArray([], declaration.members), [declaration]); @@ -121801,14 +126406,14 @@ var ts; else { return container.statements; } - case 166 /* Constructor */: - case 165 /* MethodDeclaration */: - case 251 /* FunctionDeclaration */: + case 168 /* Constructor */: + case 167 /* MethodDeclaration */: + case 253 /* FunctionDeclaration */: return __spreadArray(__spreadArray([], container.parameters), (ts.isClassLike(container.parent) ? container.parent.members : [])); - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 177 /* TypeLiteral */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: + case 179 /* 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. @@ -121823,7 +126428,7 @@ var ts; } return nodes; // Syntactically invalid positions that the parser might produce anyway - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return undefined; default: ts.Debug.assertNever(container, "Invalid container kind."); @@ -121842,12 +126447,12 @@ var ts; } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 96 /* ForKeyword */, 114 /* WhileKeyword */, 89 /* DoKeyword */)) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 97 /* ForKeyword */, 115 /* WhileKeyword */, 90 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 235 /* DoStatement */) { + if (loopNode.kind === 237 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 114 /* WhileKeyword */)) { + if (pushKeywordIf(keywords, loopTokens[i], 115 /* WhileKeyword */)) { break; } } @@ -121855,7 +126460,7 @@ var ts; } ts.forEach(aggregateAllBreakAndContinueStatements(loopNode.statement), function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 80 /* BreakKeyword */, 85 /* ContinueKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 81 /* BreakKeyword */, 86 /* ContinueKeyword */); } }); return keywords; @@ -121864,13 +126469,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -121878,13 +126483,13 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 106 /* SwitchKeyword */); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 107 /* 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(), 81 /* CaseKeyword */, 87 /* DefaultKeyword */); + pushKeywordIf(keywords, clause.getFirstToken(), 82 /* CaseKeyword */, 88 /* DefaultKeyword */); ts.forEach(aggregateAllBreakAndContinueStatements(clause), function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 80 /* BreakKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 81 /* BreakKeyword */); } }); }); @@ -121892,13 +126497,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement, sourceFile) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 110 /* TryKeyword */); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 111 /* TryKeyword */); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 82 /* CatchKeyword */); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 83 /* CatchKeyword */); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 95 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 95 /* FinallyKeyword */); + var finallyKeyword = ts.findChildOfKind(tryStatement, 96 /* FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 96 /* FinallyKeyword */); } return keywords; } @@ -121909,13 +126514,13 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - keywords.push(ts.findChildOfKind(throwStatement, 108 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 109 /* 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, 104 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 105 /* ReturnKeyword */, sourceFile)); }); } return keywords; @@ -121927,11 +126532,11 @@ var ts; } var keywords = []; ts.forEachReturnStatement(ts.cast(func.body, ts.isBlock), function (returnStatement) { - keywords.push(ts.findChildOfKind(returnStatement, 104 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 105 /* 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, 108 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 109 /* ThrowKeyword */, sourceFile)); }); return keywords; } @@ -121943,13 +126548,13 @@ var ts; var keywords = []; if (func.modifiers) { func.modifiers.forEach(function (modifier) { - pushKeywordIf(keywords, modifier, 129 /* AsyncKeyword */); + pushKeywordIf(keywords, modifier, 130 /* AsyncKeyword */); }); } ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isAwaitExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 130 /* AwaitKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 131 /* AwaitKeyword */); } }); }); @@ -121964,7 +126569,7 @@ var ts; ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isYieldExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 124 /* YieldKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 125 /* YieldKeyword */); } }); }); @@ -121983,7 +126588,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 === 90 /* ElseKeyword */ && i < keywords.length - 1) { + if (keywords[i].kind === 91 /* ElseKeyword */ && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. var shouldCombineElseAndIf = true; @@ -122018,10 +126623,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], 98 /* IfKeyword */); + pushKeywordIf(keywords, children[0], 99 /* 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], 90 /* ElseKeyword */)) { + if (pushKeywordIf(keywords, children[i], 91 /* ElseKeyword */)) { break; } } @@ -122043,6 +126648,9 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + function isDocumentRegistryEntry(entry) { + return !!entry.sourceFile; + } function createDocumentRegistry(useCaseSensitiveFileNames, currentDirectory) { return createDocumentRegistryInternal(useCaseSensitiveFileNames, currentDirectory); } @@ -122059,10 +126667,16 @@ var ts; var entries = buckets.get(name); var sourceFiles = []; entries.forEach(function (entry, name) { - sourceFiles.push({ - name: name, - refCount: entry.languageServiceRefCount - }); + if (isDocumentRegistryEntry(entry)) { + sourceFiles.push({ + name: name, + scriptKind: entry.sourceFile.scriptKind, + refCount: entry.languageServiceRefCount + }); + } + else { + entry.forEach(function (value, scriptKind) { return sourceFiles.push({ name: name, scriptKind: scriptKind, refCount: value.languageServiceRefCount }); }); + } }); sourceFiles.sort(function (x, y) { return y.refCount - x.refCount; }); return { @@ -122088,10 +126702,17 @@ var ts; function updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind) { return acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, /*acquiring*/ false, scriptKind); } + 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); + return entry; + } function acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, acquiring, scriptKind) { - var bucket = ts.getOrUpdate(buckets, key, function () { return new ts.Map(); }); - var entry = bucket.get(path); + scriptKind = ts.ensureScriptKind(fileName, scriptKind); var scriptTarget = scriptKind === 6 /* JSON */ ? 100 /* JSON */ : compilationSettings.target || 1 /* ES5 */; + var bucket = ts.getOrUpdate(buckets, key, function () { return new ts.Map(); }); + var bucketEntry = bucket.get(path); + var entry = bucketEntry && getDocumentRegistryEntry(bucketEntry, scriptKind); if (!entry && externalCache) { var sourceFile = externalCache.getDocument(key, path); if (sourceFile) { @@ -122100,7 +126721,7 @@ var ts; sourceFile: sourceFile, languageServiceRefCount: 0 }; - bucket.set(path, entry); + setBucketEntry(); } } if (!entry) { @@ -122113,7 +126734,7 @@ var ts; sourceFile: sourceFile, languageServiceRefCount: 1, }; - bucket.set(path, entry); + setBucketEntry(); } else { // We have an entry for this file. However, it may be for a different version of @@ -122136,25 +126757,49 @@ var ts; } ts.Debug.assert(entry.languageServiceRefCount !== 0); return entry.sourceFile; + function setBucketEntry() { + if (!bucketEntry) { + bucket.set(path, entry); + } + else if (isDocumentRegistryEntry(bucketEntry)) { + var scriptKindMap = new ts.Map(); + scriptKindMap.set(bucketEntry.sourceFile.scriptKind, bucketEntry); + scriptKindMap.set(scriptKind, entry); + bucket.set(path, scriptKindMap); + } + else { + bucketEntry.set(scriptKind, entry); + } + } } - function releaseDocument(fileName, compilationSettings) { + function releaseDocument(fileName, compilationSettings, scriptKind) { var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); var key = getKeyForCompilationSettings(compilationSettings); - return releaseDocumentWithKey(path, key); + return releaseDocumentWithKey(path, key, scriptKind); } - function releaseDocumentWithKey(path, key) { + function releaseDocumentWithKey(path, key, scriptKind) { var bucket = ts.Debug.checkDefined(buckets.get(key)); - var entry = bucket.get(path); + var bucketEntry = bucket.get(path); + var entry = getDocumentRegistryEntry(bucketEntry, scriptKind); entry.languageServiceRefCount--; ts.Debug.assert(entry.languageServiceRefCount >= 0); if (entry.languageServiceRefCount === 0) { - bucket.delete(path); + if (isDocumentRegistryEntry(bucketEntry)) { + bucket.delete(path); + } + else { + bucketEntry.delete(scriptKind); + if (bucketEntry.size === 1) { + bucket.set(path, ts.firstDefinedIterator(bucketEntry.values(), ts.identity)); + } + } } } - function getLanguageServiceRefCounts(path) { + function getLanguageServiceRefCounts(path, scriptKind) { return ts.arrayFrom(buckets.entries(), function (_a) { var key = _a[0], bucket = _a[1]; - var entry = bucket.get(path); + var bucketEntry = bucket.get(path); + var entry = bucketEntry && getDocumentRegistryEntry(bucketEntry, scriptKind); return [key, entry && entry.languageServiceRefCount]; }); } @@ -122217,10 +126862,12 @@ var ts; return sourceFiles; } // Module augmentations may use this module's exports without importing it. - for (var _i = 0, _a = exportingModuleSymbol.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - if (ts.isExternalModuleAugmentation(decl) && sourceFilesSet.has(decl.getSourceFile().fileName)) { - addIndirectUser(decl); + if (exportingModuleSymbol.declarations) { + for (var _i = 0, _a = exportingModuleSymbol.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + if (ts.isExternalModuleAugmentation(decl) && sourceFilesSet.has(decl.getSourceFile().fileName)) { + addIndirectUser(decl); + } } } // This may return duplicates (if there are multiple module declarations in a single source file, all importing the same thing as a namespace), but `State.markSearchedSymbol` will handle that. @@ -122237,43 +126884,43 @@ var ts; if (cancellationToken) cancellationToken.throwIfCancellationRequested(); switch (direct.kind) { - case 203 /* CallExpression */: + case 205 /* CallExpression */: if (ts.isImportCall(direct)) { handleImportCall(direct); break; } if (!isAvailableThroughGlobal) { var parent = direct.parent; - if (exportKind === 2 /* ExportEquals */ && parent.kind === 249 /* VariableDeclaration */) { + if (exportKind === 2 /* ExportEquals */ && parent.kind === 251 /* VariableDeclaration */) { var name = parent.name; - if (name.kind === 78 /* Identifier */) { + if (name.kind === 79 /* Identifier */) { directImports.push(name); break; } } } break; - case 78 /* Identifier */: // for 'const x = require("y"); + case 79 /* Identifier */: // for 'const x = require("y"); break; // TODO: GH#23879 - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: handleNamespaceImport(direct, direct.name, ts.hasSyntacticModifier(direct, 1 /* Export */), /*alreadyAddedDirect*/ false); break; - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: directImports.push(direct); var namedBindings = direct.importClause && direct.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 263 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 265 /* 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 267 /* ExportDeclaration */: + case 269 /* 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 === 269 /* NamespaceExport */) { + else if (direct.exportClause.kind === 271 /* NamespaceExport */) { // `export * as foo from "foo"` add to indirect uses addIndirectUser(getSourceFileLikeForImportDeclaration(direct), /** addTransitiveDependencies */ true); } @@ -122282,7 +126929,7 @@ var ts; directImports.push(direct); } break; - case 195 /* ImportType */: + case 197 /* ImportType */: // Only check for typeof import('xyz') if (direct.isTypeOf && !direct.qualifier && isExported(direct)) { addIndirectUser(direct.getSourceFile(), /** addTransitiveDependencies */ true); @@ -122304,7 +126951,7 @@ var ts; return ts.findAncestor(node, function (node) { if (stopAtAmbientModule && isAmbientModuleDeclaration(node)) return "quit"; - return ts.some(node.modifiers, function (mod) { return mod.kind === 92 /* ExportKeyword */; }); + return ts.some(node.modifiers, function (mod) { return mod.kind === 93 /* ExportKeyword */; }); }); } function handleNamespaceImport(importDeclaration, name, isReExport, alreadyAddedDirect) { @@ -122315,7 +126962,7 @@ var ts; } else if (!isAvailableThroughGlobal) { var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); - ts.Debug.assert(sourceFileLike.kind === 297 /* SourceFile */ || sourceFileLike.kind === 256 /* ModuleDeclaration */); + ts.Debug.assert(sourceFileLike.kind === 299 /* SourceFile */ || sourceFileLike.kind === 258 /* ModuleDeclaration */); if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { addIndirectUser(sourceFileLike, /** addTransitiveDependencies */ true); } @@ -122371,17 +127018,17 @@ var ts; } return { importSearches: importSearches, singleReferences: singleReferences }; function handleImport(decl) { - if (decl.kind === 260 /* ImportEqualsDeclaration */) { + if (decl.kind === 262 /* ImportEqualsDeclaration */) { if (isExternalModuleImportEquals(decl)) { handleNamespaceImportLike(decl.name); } return; } - if (decl.kind === 78 /* Identifier */) { + if (decl.kind === 79 /* Identifier */) { handleNamespaceImportLike(decl); return; } - if (decl.kind === 195 /* ImportType */) { + if (decl.kind === 197 /* ImportType */) { if (decl.qualifier) { var firstIdentifier = ts.getFirstIdentifier(decl.qualifier); if (firstIdentifier.escapedText === ts.symbolName(exportSymbol)) { @@ -122397,7 +127044,7 @@ var ts; if (decl.moduleSpecifier.kind !== 10 /* StringLiteral */) { return; } - if (decl.kind === 267 /* ExportDeclaration */) { + if (decl.kind === 269 /* ExportDeclaration */) { if (decl.exportClause && ts.isNamedExports(decl.exportClause)) { searchForNamedImport(decl.exportClause); } @@ -122406,10 +127053,10 @@ var ts; var _a = decl.importClause || { name: undefined, namedBindings: undefined }, name = _a.name, namedBindings = _a.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: handleNamespaceImportLike(namedBindings.name); break; - case 264 /* NamedImports */: + case 266 /* NamedImports */: // 'default' might be accessed as a named import `{ default as foo }`. if (exportKind === 0 /* Named */ || exportKind === 1 /* Default */) { searchForNamedImport(namedBindings); @@ -122459,7 +127106,7 @@ var ts; } } else { - var localSymbol = element.kind === 270 /* ExportSpecifier */ && element.propertyName + var localSymbol = element.kind === 272 /* 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); @@ -122488,7 +127135,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.kind === 297 /* SourceFile */) { + if ((searchSourceFile === null || searchSourceFile === void 0 ? void 0 : searchSourceFile.kind) === 299 /* SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { var ref = _b[_a]; if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) { @@ -122536,7 +127183,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 === 297 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return ts.forEach(sourceFileLike.kind === 299 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); }); } @@ -122551,15 +127198,15 @@ var ts; else { forEachPossibleImportOrExportStatement(sourceFile, function (statement) { switch (statement.kind) { - case 267 /* ExportDeclaration */: - case 261 /* ImportDeclaration */: { + case 269 /* ExportDeclaration */: + case 263 /* ImportDeclaration */: { var decl = statement; if (decl.moduleSpecifier && ts.isStringLiteral(decl.moduleSpecifier)) { action(decl, decl.moduleSpecifier); } break; } - case 260 /* ImportEqualsDeclaration */: { + case 262 /* ImportEqualsDeclaration */: { var decl = statement; if (isExternalModuleImportEquals(decl)) { action(decl, decl.moduleReference.expression); @@ -122580,14 +127227,15 @@ var ts; function getImportOrExportSymbol(node, symbol, checker, comingFromExport) { return comingFromExport ? getExport() : getExport() || getImport(); function getExport() { + var _a; var parent = node.parent; - var grandParent = parent.parent; + var grandparent = parent.parent; if (symbol.exportSymbol) { - if (parent.kind === 201 /* PropertyAccessExpression */) { + if (parent.kind === 203 /* 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 symbol.declarations.some(function (d) { return d === parent; }) && ts.isBinaryExpression(grandParent) - ? getSpecialPropertyExport(grandParent, /*useLhsSymbol*/ false) + return ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d === parent; })) && ts.isBinaryExpression(grandparent) + ? getSpecialPropertyExport(grandparent, /*useLhsSymbol*/ false) : undefined; } else { @@ -122617,15 +127265,15 @@ var ts; return getExportAssignmentExport(parent); } // If we are in `export = class A {};` (or `export = class A {};`) at `A`, `parent.parent` is the export assignment. - else if (ts.isExportAssignment(grandParent)) { - return getExportAssignmentExport(grandParent); + else if (ts.isExportAssignment(grandparent)) { + return getExportAssignmentExport(grandparent); } // Similar for `module.exports =` and `exports.A =`. else if (ts.isBinaryExpression(parent)) { return getSpecialPropertyExport(parent, /*useLhsSymbol*/ true); } - else if (ts.isBinaryExpression(grandParent)) { - return getSpecialPropertyExport(grandParent, /*useLhsSymbol*/ true); + else if (ts.isBinaryExpression(grandparent)) { + return getSpecialPropertyExport(grandparent, /*useLhsSymbol*/ true); } else if (ts.isJSDocTypedefTag(parent)) { return exportInfo(symbol, 0 /* Named */); @@ -122633,9 +127281,10 @@ var ts; } function getExportAssignmentExport(ex) { // Get the symbol for the `export =` node; its parent is the module it's the export of. - var exportingModuleSymbol = ts.Debug.checkDefined(ex.symbol.parent, "Expected export symbol to have a parent"); + if (!ex.symbol.parent) + return undefined; var exportKind = ex.isExportEquals ? 2 /* ExportEquals */ : 1 /* Default */; - return { kind: 1 /* Export */, symbol: symbol, exportInfo: { exportingModuleSymbol: exportingModuleSymbol, exportKind: exportKind } }; + return { kind: 1 /* Export */, symbol: symbol, exportInfo: { exportingModuleSymbol: ex.symbol.parent, exportKind: exportKind } }; } function getSpecialPropertyExport(node, useLhsSymbol) { var kind; @@ -122689,7 +127338,7 @@ var ts; if (importedSymbol.flags & 2097152 /* Alias */) { return ts.Debug.checkDefined(checker.getImmediateAliasedSymbol(importedSymbol)); } - var decl = importedSymbol.valueDeclaration; + var decl = ts.Debug.checkDefined(importedSymbol.valueDeclaration); if (ts.isExportAssignment(decl)) { // `export = class {}` return ts.Debug.checkDefined(decl.expression.symbol); } @@ -122716,17 +127365,17 @@ var ts; function isNodeImport(node) { var parent = node.parent; switch (parent.kind) { - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return parent.name === node && isExternalModuleImportEquals(parent); - case 265 /* ImportSpecifier */: + case 267 /* 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 262 /* ImportClause */: - case 263 /* NamespaceImport */: + case 264 /* ImportClause */: + case 265 /* NamespaceImport */: ts.Debug.assert(parent.name === node); return true; - case 198 /* BindingElement */: - return ts.isInJSFile(node) && ts.isRequireVariableDeclaration(parent, /*requireStringLiteralLikeArgument*/ true); + case 200 /* BindingElement */: + return ts.isInJSFile(node) && ts.isRequireVariableDeclaration(parent); default: return false; } @@ -122750,7 +127399,8 @@ var ts; return checker.getExportSpecifierLocalTargetSymbol(declaration); } else if (ts.isPropertyAccessExpression(declaration) && ts.isModuleExportsAccessExpression(declaration.expression) && !ts.isPrivateIdentifier(declaration.name)) { - return checker.getExportSpecifierLocalTargetSymbol(declaration.name); + // Export of form 'module.exports.propName = expr'; + return checker.getSymbolAtLocation(declaration); } else if (ts.isShorthandPropertyAssignment(declaration) && ts.isBinaryExpression(declaration.parent.parent) @@ -122765,21 +127415,21 @@ var ts; return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol); } function getSourceFileLikeForImportDeclaration(node) { - if (node.kind === 203 /* CallExpression */) { + if (node.kind === 205 /* CallExpression */) { return node.getSourceFile(); } var parent = node.parent; - if (parent.kind === 297 /* SourceFile */) { + if (parent.kind === 299 /* SourceFile */) { return parent; } - ts.Debug.assert(parent.kind === 257 /* ModuleBlock */); + ts.Debug.assert(parent.kind === 259 /* ModuleBlock */); return ts.cast(parent.parent, isAmbientModuleDeclaration); } function isAmbientModuleDeclaration(node) { - return node.kind === 256 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; + return node.kind === 258 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; } function isExternalModuleImportEquals(eq) { - return eq.moduleReference.kind === 272 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; + return eq.moduleReference.kind === 274 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); @@ -122873,7 +127523,7 @@ var ts; ((ts.isImportOrExportSpecifier(node.parent) || ts.isBindingElement(node.parent)) && node.parent.propertyName === node) || // Is default export - (node.kind === 87 /* DefaultKeyword */ && ts.hasSyntacticModifier(node.parent, 513 /* ExportDefault */))) { + (node.kind === 88 /* DefaultKeyword */ && ts.hasSyntacticModifier(node.parent, 513 /* ExportDefault */))) { return getContextNode(node.parent); } return undefined; @@ -122882,7 +127532,7 @@ var ts; if (!node) return undefined; switch (node.kind) { - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return !ts.isVariableDeclarationList(node.parent) || node.parent.declarations.length !== 1 ? node : ts.isVariableStatement(node.parent.parent) ? @@ -122890,28 +127540,28 @@ var ts; ts.isForInOrOfStatement(node.parent.parent) ? getContextNode(node.parent.parent) : node.parent; - case 198 /* BindingElement */: + case 200 /* BindingElement */: return getContextNode(node.parent.parent); - case 265 /* ImportSpecifier */: + case 267 /* ImportSpecifier */: return node.parent.parent.parent; - case 270 /* ExportSpecifier */: - case 263 /* NamespaceImport */: + case 272 /* ExportSpecifier */: + case 265 /* NamespaceImport */: return node.parent.parent; - case 262 /* ImportClause */: - case 269 /* NamespaceExport */: + case 264 /* ImportClause */: + case 271 /* NamespaceExport */: return node.parent; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return ts.isExpressionStatement(node.parent) ? node.parent : node; - case 239 /* ForOfStatement */: - case 238 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 240 /* ForInStatement */: return { start: node.initializer, end: node.expression }; - case 288 /* PropertyAssignment */: - case 289 /* ShorthandPropertyAssignment */: + case 290 /* PropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent) ? getContextNode(ts.findAncestor(node.parent, function (node) { return ts.isBinaryExpression(node) || ts.isForInOrOfStatement(node); @@ -122968,10 +127618,10 @@ var ts; var node = ts.getTouchingPropertyName(sourceFile, position); var referenceEntries; var entries = getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position); - if (node.parent.kind === 201 /* PropertyAccessExpression */ - || node.parent.kind === 198 /* BindingElement */ - || node.parent.kind === 202 /* ElementAccessExpression */ - || node.kind === 105 /* SuperKeyword */) { + if (node.parent.kind === 203 /* PropertyAccessExpression */ + || node.parent.kind === 200 /* BindingElement */ + || node.parent.kind === 204 /* ElementAccessExpression */ + || node.kind === 106 /* SuperKeyword */) { referenceEntries = entries && __spreadArray([], entries); } else { @@ -122994,18 +127644,18 @@ var ts; } FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) { - if (node.kind === 297 /* SourceFile */) { + if (node.kind === 299 /* 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 === 289 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 291 /* ShorthandPropertyAssignment */) { var result_1 = []; Core.getReferenceEntriesForShorthandPropertyAssignment(node, checker, function (node) { return result_1.push(nodeEntry(node)); }); return result_1; } - else if (node.kind === 105 /* SuperKeyword */ || ts.isSuperProperty(node.parent)) { + else if (node.kind === 106 /* 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); @@ -123175,13 +127825,13 @@ var ts; if (symbol) { return getDefinitionKindAndDisplayParts(symbol, checker, node); } - else if (node.kind === 200 /* ObjectLiteralExpression */) { + else if (node.kind === 202 /* ObjectLiteralExpression */) { return { kind: "interface" /* interfaceElement */, displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(21 /* CloseParenToken */)] }; } - else if (node.kind === 221 /* ClassExpression */) { + else if (node.kind === 223 /* ClassExpression */) { return { kind: "local class" /* localClassElement */, displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(21 /* CloseParenToken */)] @@ -123225,13 +127875,13 @@ var ts; /** 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 === 87 /* DefaultKeyword */ || ts.isWriteAccess(node); + return !!decl && declarationIsWriteAccess(decl) || node.kind === 88 /* DefaultKeyword */ || ts.isWriteAccess(node); } function isDefinitionForReference(node) { - return node.kind === 87 /* DefaultKeyword */ + return node.kind === 88 /* DefaultKeyword */ || !!ts.getDeclarationFromName(node) || ts.isLiteralComputedPropertyDeclarationName(node) - || (node.kind === 132 /* ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent)); + || (node.kind === 133 /* ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent)); } /** * True if 'decl' provides a value, as in `function f() {}`; @@ -123242,47 +127892,47 @@ var ts; if (!!(decl.flags & 8388608 /* Ambient */)) return true; switch (decl.kind) { - case 216 /* BinaryExpression */: - case 198 /* BindingElement */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 87 /* DefaultKeyword */: - case 255 /* EnumDeclaration */: - case 291 /* EnumMember */: - case 270 /* ExportSpecifier */: - case 262 /* ImportClause */: // default import - case 260 /* ImportEqualsDeclaration */: - case 265 /* ImportSpecifier */: - case 253 /* InterfaceDeclaration */: - case 324 /* JSDocCallbackTag */: - case 331 /* JSDocTypedefTag */: - case 280 /* JsxAttribute */: - case 256 /* ModuleDeclaration */: - case 259 /* NamespaceExportDeclaration */: - case 263 /* NamespaceImport */: - case 269 /* NamespaceExport */: - case 160 /* Parameter */: - case 289 /* ShorthandPropertyAssignment */: - case 254 /* TypeAliasDeclaration */: - case 159 /* TypeParameter */: + case 218 /* BinaryExpression */: + case 200 /* BindingElement */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 88 /* DefaultKeyword */: + case 257 /* EnumDeclaration */: + case 293 /* EnumMember */: + case 272 /* ExportSpecifier */: + case 264 /* ImportClause */: // default import + case 262 /* ImportEqualsDeclaration */: + case 267 /* ImportSpecifier */: + case 255 /* InterfaceDeclaration */: + case 332 /* JSDocCallbackTag */: + case 339 /* JSDocTypedefTag */: + case 282 /* JsxAttribute */: + case 258 /* ModuleDeclaration */: + case 261 /* NamespaceExportDeclaration */: + case 265 /* NamespaceImport */: + case 271 /* NamespaceExport */: + case 162 /* Parameter */: + case 291 /* ShorthandPropertyAssignment */: + case 256 /* TypeAliasDeclaration */: + case 161 /* TypeParameter */: return true; - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: // In `({ x: y } = 0);`, `x` is not a write access. (Won't call this function for `y`.) return !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(decl.parent); - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 166 /* Constructor */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 168 /* Constructor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return !!decl.body; - case 249 /* VariableDeclaration */: - case 163 /* PropertyDeclaration */: + case 251 /* VariableDeclaration */: + case 165 /* PropertyDeclaration */: return !!decl.initializer || ts.isCatchClause(decl.parent); - case 164 /* MethodSignature */: - case 162 /* PropertySignature */: - case 333 /* JSDocPropertyTag */: - case 326 /* JSDocParameterTag */: + case 166 /* MethodSignature */: + case 164 /* PropertySignature */: + case 341 /* JSDocPropertyTag */: + case 334 /* JSDocParameterTag */: return false; default: return ts.Debug.failBadSyntaxKind(decl); @@ -123304,7 +127954,7 @@ var ts; } if (ts.isSourceFile(node)) { var resolvedRef = ts.GoToDefinition.getReferenceAtPosition(node, position, program); - if (!resolvedRef) { + if (!(resolvedRef === null || resolvedRef === void 0 ? void 0 : resolvedRef.file)) { return undefined; } var moduleSymbol = program.getTypeChecker().getMergedSymbol(resolvedRef.file.symbol); @@ -123333,7 +127983,7 @@ var ts; if (!symbol) { // String literal might be a property (and thus have a symbol), so do this here rather than in getReferencedSymbolsSpecial. if (!options.implementations && ts.isStringLiteralLike(node)) { - if (ts.isRequireCall(node.parent, /*requireStringLiteralLikeArgument*/ true) || ts.isExternalModuleReference(node.parent) || ts.isImportDeclaration(node.parent) || ts.isImportCall(node.parent)) { + if (ts.isModuleSpecifierLike(node)) { var fileIncludeReasons = program.getFileIncludeReasons(); var referencedFileName = (_b = (_a = node.getSourceFile().resolvedModules) === null || _a === void 0 ? void 0 : _a.get(node.text)) === null || _b === void 0 ? void 0 : _b.resolvedFileName; var referencedFile = referencedFileName ? program.getSourceFile(referencedFileName) : undefined; @@ -123434,7 +128084,7 @@ var ts; result = references; continue; } - var _loop_3 = function (entry) { + var _loop_4 = function (entry) { if (!entry.definition || entry.definition.type !== 0 /* Symbol */) { result.push(entry); return "continue"; @@ -123466,7 +128116,7 @@ var ts; }; for (var _b = 0, references_2 = references; _b < references_2.length; _b++) { var entry = references_2[_b]; - _loop_3(entry); + _loop_4(entry); } } return result; @@ -123503,10 +128153,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; switch (decl.kind) { - case 297 /* SourceFile */: + case 299 /* 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 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: if (sourceFilesSet.has(decl.getSourceFile().fileName)) { references.push(nodeEntry(decl.name)); } @@ -123518,14 +128168,14 @@ var ts; } } var exported = symbol.exports.get("export=" /* ExportEquals */); - if (exported) { + 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]; var sourceFile = decl.getSourceFile(); 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, 92 /* ExportKeyword */, sourceFile)) : + ts.isExportAssignment(decl) ? ts.Debug.checkDefined(ts.findChildOfKind(decl, 93 /* ExportKeyword */, sourceFile)) : ts.getNameOfDeclaration(decl) || decl; references.push(nodeEntry(node)); } @@ -123535,25 +128185,25 @@ var ts; } /** As in a `readonly prop: any` or `constructor(readonly prop: any)`, not a `readonly any[]`. */ function isReadonlyTypeOperator(node) { - return node.kind === 142 /* ReadonlyKeyword */ + return node.kind === 143 /* ReadonlyKeyword */ && ts.isTypeOperatorNode(node.parent) - && node.parent.operator === 142 /* ReadonlyKeyword */; + && node.parent.operator === 143 /* 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 === 113 /* VoidKeyword */ && ts.isVoidExpression(node.parent)) { + if (node.kind === 114 /* 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 === 142 /* ReadonlyKeyword */ && !isReadonlyTypeOperator(node)) { + if (node.kind === 143 /* 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 === 142 /* ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined); + return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken, node.kind === 143 /* ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined); } // Labels if (ts.isJumpStatementTarget(node)) { @@ -123569,7 +128219,7 @@ var ts; if (ts.isThis(node)) { return getReferencesForThisKeyword(node, sourceFiles, cancellationToken); } - if (node.kind === 105 /* SuperKeyword */) { + if (node.kind === 106 /* SuperKeyword */) { return getReferencesForSuperKeyword(node); } return undefined; @@ -123581,14 +128231,14 @@ var ts; var searchMeaning = node ? getIntersectingMeaningFromDeclarations(node, symbol) : 7 /* All */; var result = []; var state = new State(sourceFiles, sourceFilesSet, node ? getSpecialSearchKind(node) : 0 /* None */, checker, cancellationToken, searchMeaning, options, result); - var exportSpecifier = !isForRenameWithPrefixAndSuffixText(options) ? undefined : ts.find(symbol.declarations, ts.isExportSpecifier); + 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 === 87 /* DefaultKeyword */) { + else if (node && node.kind === 88 /* DefaultKeyword */ && symbol.escapedName === "default" /* Default */ && symbol.parent) { addReference(node, symbol, state); - searchForImportsOfExport(node, symbol, { exportingModuleSymbol: ts.Debug.checkDefined(symbol.parent, "Expected export symbol to have a parent"), exportKind: 1 /* Default */ }, state); + searchForImportsOfExport(node, symbol, { exportingModuleSymbol: symbol.parent, exportKind: 1 /* 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] }); @@ -123614,10 +128264,10 @@ var ts; } function getSpecialSearchKind(node) { switch (node.kind) { - case 166 /* Constructor */: - case 132 /* ConstructorKeyword */: + case 168 /* Constructor */: + case 133 /* ConstructorKeyword */: return 1 /* Constructor */; - case 78 /* Identifier */: + case 79 /* Identifier */: if (ts.isClassLike(node.parent)) { ts.Debug.assert(node.parent.name === node); return 2 /* Class */; @@ -123745,8 +128395,8 @@ var ts; var sourceId = ts.getNodeId(sourceFile); var seenSymbols = this.sourceFileToSeenSymbols[sourceId] || (this.sourceFileToSeenSymbols[sourceId] = new ts.Set()); var anyNewSymbols = false; - for (var _i = 0, symbols_3 = symbols; _i < symbols_3.length; _i++) { - var sym = symbols_3[_i]; + for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) { + var sym = symbols_2[_i]; anyNewSymbols = ts.tryAddToSet(seenSymbols, ts.getSymbolId(sym)) || anyNewSymbols; } return anyNewSymbols; @@ -123803,7 +128453,9 @@ var ts; for (var _c = 0, _d = getPossibleSymbolReferenceNodes(indirectUser, isDefaultExport ? "default" : exportName); _c < _d.length; _c++) { var node = _d[_c]; // Import specifiers should be handled by importSearches - if (ts.isIdentifier(node) && !ts.isImportOrExportSpecifier(node.parent) && checker.getSymbolAtLocation(node) === exportSymbol) { + var symbol = checker.getSymbolAtLocation(node); + var hasExportAssignmentDeclaration = ts.some(symbol === null || symbol === void 0 ? void 0 : symbol.declarations, function (d) { return ts.tryCast(d, ts.isExportAssignment) ? true : false; }); + if (ts.isIdentifier(node) && !ts.isImportOrExportSpecifier(node.parent) && (symbol === exportSymbol || hasExportAssignmentDeclaration)) { cb(node); } } @@ -123855,7 +128507,7 @@ 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 === 208 /* FunctionExpression */ || valueDeclaration.kind === 221 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 210 /* FunctionExpression */ || valueDeclaration.kind === 223 /* ClassExpression */)) { return valueDeclaration; } if (!declarations) { @@ -123863,9 +128515,9 @@ var ts; } // 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.isPrivateIdentifierPropertyDeclaration(d); }); + var privateDeclaration = ts.find(declarations, function (d) { return ts.hasEffectiveModifier(d, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(d); }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 252 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 254 /* ClassDeclaration */); } // Else this is a public property and could be accessed from anywhere. return undefined; @@ -123894,7 +128546,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (!container || container.kind === 297 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { + if (!container || container.kind === 299 /* 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; @@ -124010,8 +128662,12 @@ var ts; function isValidReferencePosition(node, searchSymbolName) { // Compare the length so we filter out strict superstrings of the symbol we are looking for switch (node.kind) { - case 79 /* PrivateIdentifier */: - case 78 /* Identifier */: + case 80 /* PrivateIdentifier */: + if (ts.isJSDocMemberName(node.parent)) { + return true; + } + // falls through I guess + case 79 /* Identifier */: return node.text.length === searchSymbolName.length; case 14 /* NoSubstitutionTemplateLiteral */: case 10 /* StringLiteral */: { @@ -124021,7 +128677,7 @@ var ts; } case 8 /* NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.text.length === searchSymbolName.length; - case 87 /* DefaultKeyword */: + case 88 /* DefaultKeyword */: return "default".length === searchSymbolName.length; default: return false; @@ -124087,7 +128743,7 @@ var ts; return; } if (ts.isExportSpecifier(parent)) { - ts.Debug.assert(referenceLocation.kind === 78 /* Identifier */); + ts.Debug.assert(referenceLocation.kind === 79 /* Identifier */); getReferencesAtExportSpecifier(referenceLocation, referenceSymbol, parent, search, state, addReferencesHere); return; } @@ -124110,6 +128766,10 @@ var ts; default: ts.Debug.assertNever(state.specialSearchKind); } + // Use the parent symbol if the location is commonjs require syntax on javascript files only. + referenceSymbol = ts.isInJSFile(referenceLocation) && referenceLocation.parent.kind === 200 /* BindingElement */ && ts.isRequireVariableDeclaration(referenceLocation.parent) + ? referenceLocation.parent.symbol + : referenceSymbol; getImportOrExportReferences(referenceLocation, referenceSymbol, search, state); } function getReferencesAtExportSpecifier(referenceLocation, referenceSymbol, exportSpecifier, search, state, addReferencesHere, alwaysGetReferences) { @@ -124143,8 +128803,8 @@ var ts; } // For `export { foo as bar }`, rename `foo`, but not `bar`. if (!isForRenameWithPrefixAndSuffixText(state.options) || alwaysGetReferences) { - var isDefaultExport = referenceLocation.originalKeywordKind === 87 /* DefaultKeyword */ - || exportSpecifier.name.originalKeywordKind === 87 /* DefaultKeyword */; + var isDefaultExport = referenceLocation.originalKeywordKind === 88 /* DefaultKeyword */ + || exportSpecifier.name.originalKeywordKind === 88 /* DefaultKeyword */; var exportKind = isDefaultExport ? 1 /* Default */ : 0 /* Named */; var exportSymbol = ts.Debug.checkDefined(exportSpecifier.symbol); var exportInfo = FindAllReferences.getExportInfo(exportSymbol, exportKind, state.checker); @@ -124225,7 +128885,7 @@ var ts; } var pusher = function () { return state.referenceAdder(search.symbol); }; if (ts.isClassLike(referenceLocation.parent)) { - ts.Debug.assert(referenceLocation.kind === 87 /* DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); + ts.Debug.assert(referenceLocation.kind === 88 /* DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); // This is the class declaration containing the constructor. findOwnConstructorReferences(search.symbol, sourceFile, pusher()); } @@ -124252,7 +128912,7 @@ var ts; } if (member.body) { member.body.forEachChild(function cb(node) { - if (node.kind === 107 /* ThisKeyword */) { + if (node.kind === 108 /* ThisKeyword */) { addRef(node); } else if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) { @@ -124271,18 +128931,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, 132 /* ConstructorKeyword */, sourceFile); - ts.Debug.assert(decl.kind === 166 /* Constructor */ && !!ctrKeyword); + var ctrKeyword = ts.findChildOfKind(decl, 133 /* ConstructorKeyword */, sourceFile); + ts.Debug.assert(decl.kind === 168 /* Constructor */ && !!ctrKeyword); addNode(ctrKeyword); } } if (classSymbol.exports) { classSymbol.exports.forEach(function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 165 /* MethodDeclaration */) { + if (decl && decl.kind === 167 /* MethodDeclaration */) { var body = decl.body; if (body) { - forEachDescendantOfKind(body, 107 /* ThisKeyword */, function (thisKeyword) { + forEachDescendantOfKind(body, 108 /* ThisKeyword */, function (thisKeyword) { if (ts.isNewExpressionTarget(thisKeyword)) { addNode(thisKeyword); } @@ -124303,10 +128963,10 @@ var ts; } for (var _i = 0, _a = constructor.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 166 /* Constructor */); + ts.Debug.assert(decl.kind === 168 /* Constructor */); var body = decl.body; if (body) { - forEachDescendantOfKind(body, 105 /* SuperKeyword */, function (node) { + forEachDescendantOfKind(body, 106 /* SuperKeyword */, function (node) { if (ts.isCallExpressionTarget(node)) { addNode(node); } @@ -124330,10 +128990,10 @@ var ts; addReference(refNode); return; } - if (refNode.kind !== 78 /* Identifier */) { + if (refNode.kind !== 79 /* Identifier */) { return; } - if (refNode.parent.kind === 289 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 291 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference); } @@ -124353,7 +129013,7 @@ var ts; } else if (ts.isFunctionLike(typeHavingNode) && typeHavingNode.body) { var body = typeHavingNode.body; - if (body.kind === 230 /* Block */) { + if (body.kind === 232 /* Block */) { ts.forEachReturnStatement(body, function (returnStatement) { if (returnStatement.expression) addIfImplementation(returnStatement.expression); @@ -124381,13 +129041,13 @@ var ts; */ function isImplementationExpression(node) { switch (node.kind) { - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return isImplementationExpression(node.expression); - case 209 /* ArrowFunction */: - case 208 /* FunctionExpression */: - case 200 /* ObjectLiteralExpression */: - case 221 /* ClassExpression */: - case 199 /* ArrayLiteralExpression */: + case 211 /* ArrowFunction */: + case 210 /* FunctionExpression */: + case 202 /* ObjectLiteralExpression */: + case 223 /* ClassExpression */: + case 201 /* ArrayLiteralExpression */: return true; default: return false; @@ -124440,13 +129100,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -124455,7 +129115,7 @@ var ts; } var sourceFile = searchSpaceNode.getSourceFile(); var references = ts.mapDefined(getPossibleSymbolReferenceNodes(sourceFile, "super", searchSpaceNode), function (node) { - if (node.kind !== 105 /* SuperKeyword */) { + if (node.kind !== 106 /* SuperKeyword */) { return; } var container = ts.getSuperContainer(node, /*stopOnFunctions*/ false); @@ -124467,41 +129127,43 @@ var ts; return [{ definition: { type: 0 /* Symbol */, symbol: searchSpaceNode.symbol }, references: references }]; } function isParameterName(node) { - return node.kind === 78 /* Identifier */ && node.parent.kind === 160 /* Parameter */ && node.parent.name === node; + return node.kind === 79 /* Identifier */ && node.parent.kind === 162 /* 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 */; switch (searchSpaceNode.kind) { - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { + staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); + searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning object literals break; } // falls through - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 297 /* SourceFile */: + case 299 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode) || isParameterName(thisOrSuperKeyword)) { return undefined; } // falls through - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 210 /* 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 === 297 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { + var references = ts.flatMap(searchSpaceNode.kind === 299 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { if (!ts.isThis(node)) { @@ -124509,19 +129171,20 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: return searchSpaceNode.symbol === container.symbol; - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: return ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol; - case 221 /* ClassExpression */: - case 252 /* ClassDeclaration */: - // Make sure the container belongs to the same class + case 223 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 202 /* 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.getSyntacticModifierFlags(container) & 32 /* Static */) === staticFlag; - case 297 /* SourceFile */: - return container.kind === 297 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); + case 299 /* SourceFile */: + return container.kind === 299 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); } }); }).map(function (n) { return nodeEntry(n); }); @@ -124631,7 +129294,7 @@ var ts; 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]); } - var exportSpecifier = ts.getDeclarationOfKind(symbol, 270 /* ExportSpecifier */); + var exportSpecifier = ts.getDeclarationOfKind(symbol, 272 /* ExportSpecifier */); if (!isForRenamePopulateSearchSymbolSet || exportSpecifier && !exportSpecifier.propertyName) { var localSymbol = exportSpecifier && checker.getExportSpecifierLocalTargetSymbol(exportSpecifier); if (localSymbol) { @@ -124676,7 +129339,7 @@ var ts; }); } function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker) { - var bindingElement = ts.getDeclarationOfKind(symbol, 198 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 200 /* BindingElement */); if (bindingElement && ts.isObjectBindingElementWithoutPropertyName(bindingElement)) { return ts.getPropertySymbolFromBindingElement(checker, bindingElement); } @@ -124880,7 +129543,7 @@ var ts; return ts.Debug.checkDefined(node.modifiers && ts.find(node.modifiers, isDefaultModifier)); } function isDefaultModifier(node) { - return node.kind === 87 /* DefaultKeyword */; + return node.kind === 88 /* DefaultKeyword */; } /** Gets the symbol for a call hierarchy declaration. */ function getSymbolOfCallHierarchyDeclaration(typeChecker, node) { @@ -124929,16 +129592,16 @@ var ts; return; } switch (node.kind) { - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 165 /* MethodDeclaration */: - if (node.parent.kind === 200 /* ObjectLiteralExpression */) { + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 167 /* MethodDeclaration */: + if (node.parent.kind === 202 /* 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 251 /* FunctionDeclaration */: - case 252 /* ClassDeclaration */: - case 256 /* ModuleDeclaration */: + case 253 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: + case 258 /* ModuleDeclaration */: if (ts.isModuleBlock(node.parent) && ts.isIdentifier(node.parent.parent.name)) { return node.parent.parent.name.getText(); } @@ -125143,56 +129806,56 @@ var ts; return; } switch (node.kind) { - case 78 /* Identifier */: - case 260 /* ImportEqualsDeclaration */: - case 261 /* ImportDeclaration */: - case 267 /* ExportDeclaration */: - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 79 /* Identifier */: + case 262 /* ImportEqualsDeclaration */: + case 263 /* ImportDeclaration */: + case 269 /* ExportDeclaration */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: // do not descend into nodes that cannot contain callable nodes return; - case 206 /* TypeAssertionExpression */: - case 224 /* AsExpression */: + case 208 /* TypeAssertionExpression */: + case 226 /* AsExpression */: // do not descend into the type side of an assertion collect(node.expression); return; - case 249 /* VariableDeclaration */: - case 160 /* Parameter */: + case 251 /* VariableDeclaration */: + case 162 /* Parameter */: // do not descend into the type of a variable or parameter declaration collect(node.name); collect(node.initializer); return; - case 203 /* CallExpression */: + case 205 /* CallExpression */: // do not descend into the type arguments of a call expression recordCallSite(node); collect(node.expression); ts.forEach(node.arguments, collect); return; - case 204 /* NewExpression */: + case 206 /* NewExpression */: // do not descend into the type arguments of a new expression recordCallSite(node); collect(node.expression); ts.forEach(node.arguments, collect); return; - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: // do not descend into the type arguments of a tagged template expression recordCallSite(node); collect(node.tag); collect(node.template); return; - case 275 /* JsxOpeningElement */: - case 274 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: // do not descend into the type arguments of a JsxOpeningLikeElement recordCallSite(node); collect(node.tagName); collect(node.attributes); return; - case 161 /* Decorator */: + case 163 /* Decorator */: recordCallSite(node); collect(node.expression); return; - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: recordCallSite(node); ts.forEachChild(node, collect); break; @@ -125242,22 +129905,22 @@ var ts; var callSites = []; var collect = createCallSiteCollector(program, callSites); switch (node.kind) { - case 297 /* SourceFile */: + case 299 /* SourceFile */: collectCallSitesOfSourceFile(node, collect); break; - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: collectCallSitesOfModuleDeclaration(node, collect); break; - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: collectCallSitesOfFunctionLikeDeclaration(program.getTypeChecker(), node, collect); break; - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: collectCallSitesOfClassLikeDeclaration(node, collect); break; default: @@ -125390,7 +130053,7 @@ var ts; } function updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName) { var allFiles = program.getSourceFiles(); - var _loop_4 = function (sourceFile) { + var _loop_5 = function (sourceFile) { var newFromOld = oldToNew(sourceFile.fileName); var newImportFromPath = newFromOld !== null && newFromOld !== void 0 ? newFromOld : sourceFile.fileName; var newImportFromDirectory = ts.getDirectoryPath(newImportFromPath); @@ -125407,7 +130070,7 @@ var ts; }, function (importLiteral) { var importedModuleSymbol = program.getTypeChecker().getSymbolAtLocation(importLiteral); // No need to update if it's an ambient module^M - if (importedModuleSymbol && importedModuleSymbol.declarations.some(function (d) { return ts.isAmbientModule(d); })) + if ((importedModuleSymbol === null || importedModuleSymbol === void 0 ? void 0 : importedModuleSymbol.declarations) && importedModuleSymbol.declarations.some(function (d) { return ts.isAmbientModule(d); })) return undefined; var toImport = oldFromNew !== undefined // If we're at the new location (file was already renamed), need to redo module resolution starting from the old location. @@ -125422,7 +130085,7 @@ var ts; }; for (var _i = 0, allFiles_1 = allFiles; _i < allFiles_1.length; _i++) { var sourceFile = allFiles_1[_i]; - _loop_4(sourceFile); + _loop_5(sourceFile); } } function combineNormal(pathA, pathB) { @@ -125513,8 +130176,10 @@ var ts; (function (GoToDefinition) { function getDefinitionAtPosition(program, sourceFile, position) { var resolvedRef = getReferenceAtPosition(sourceFile, position, program); - if (resolvedRef) { - return [getDefinitionInfoForFileReference(resolvedRef.reference.fileName, resolvedRef.file.fileName)]; + var fileReferenceDefinition = resolvedRef && [getDefinitionInfoForFileReference(resolvedRef.reference.fileName, resolvedRef.fileName, resolvedRef.unverified)] || ts.emptyArray; + if (resolvedRef === null || resolvedRef === void 0 ? void 0 : resolvedRef.file) { + // If `file` is missing, do a symbol-based lookup as well + return fileReferenceDefinition; } var node = ts.getTouchingPropertyName(sourceFile, position); if (node === sourceFile) { @@ -125531,7 +130196,7 @@ var ts; // Could not find a symbol e.g. node is string or number keyword, // or the symbol was an internal symbol and does not have a declaration e.g. undefined symbol if (!symbol) { - return getDefinitionInfoForIndexSignatures(node, typeChecker); + return ts.concatenate(fileReferenceDefinition, getDefinitionInfoForIndexSignatures(node, typeChecker)); } var calledDeclaration = tryGetSignatureDeclaration(typeChecker, node); // Don't go to the component constructor definition for a JSX element, just go to the component definition. @@ -125545,7 +130210,7 @@ var ts; else { var defs = getDefinitionFromSymbol(typeChecker, symbol, node, calledDeclaration) || ts.emptyArray; // For a 'super()' call, put the signature first, else put the variable first. - return node.kind === 105 /* SuperKeyword */ ? __spreadArray([sigInfo], defs) : __spreadArray(__spreadArray([], defs), [sigInfo]); + return node.kind === 106 /* SuperKeyword */ ? __spreadArray([sigInfo], defs) : __spreadArray(__spreadArray([], defs), [sigInfo]); } } // Because name in short-hand property assignment has two different meanings: property name and property value, @@ -125553,9 +130218,10 @@ 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 === 289 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 291 /* ShorthandPropertyAssignment */) { var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); - return shorthandSymbol_1 ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node); }) : []; + 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); }) : ts.emptyArray; + return ts.concatenate(definitions, getDefinitionFromObjectLiteralElement(typeChecker, node) || ts.emptyArray); } // If the node is the name of a BindingElement within an ObjectBindingPattern instead of just returning the // declaration the symbol (which is itself), we should try to get to the original type of the ObjectBindingPattern @@ -125577,25 +130243,7 @@ var ts; return prop && getDefinitionFromSymbol(typeChecker, prop, node); }); } - // If the current location we want to find its definition is in an object literal, try to get the contextual type for the - // object literal, lookup the property symbol in the contextual type, and use this for goto-definition. - // For example - // interface Props{ - // /*first*/prop1: number - // prop2: boolean - // } - // function Foo(arg: Props) {} - // Foo( { pr/*1*/op1: 10, prop2: true }) - var element = ts.getContainingObjectLiteralElement(node); - if (element) { - var contextualType = element && typeChecker.getContextualType(element.parent); - if (contextualType) { - return ts.flatMap(ts.getPropertySymbolsFromContextualType(element, typeChecker, contextualType, /*unionSymbolOk*/ false), function (propertySymbol) { - return getDefinitionFromSymbol(typeChecker, propertySymbol, node); - }); - } - } - return getDefinitionFromSymbol(typeChecker, symbol, node); + return ts.concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node)); } GoToDefinition.getDefinitionAtPosition = getDefinitionAtPosition; /** @@ -125609,22 +130257,60 @@ var ts; || ts.isAssignmentExpression(calledDeclaration.parent) || (!ts.isCallLikeExpression(calledDeclaration.parent) && s === calledDeclaration.parent.symbol); } + // If the current location we want to find its definition is in an object literal, try to get the contextual type for the + // object literal, lookup the property symbol in the contextual type, and use this for goto-definition. + // For example + // interface Props{ + // /*first*/prop1: number + // prop2: boolean + // } + // function Foo(arg: Props) {} + // Foo( { pr/*1*/op1: 10, prop2: true }) + function getDefinitionFromObjectLiteralElement(typeChecker, node) { + var element = ts.getContainingObjectLiteralElement(node); + if (element) { + var contextualType = element && typeChecker.getContextualType(element.parent); + if (contextualType) { + return ts.flatMap(ts.getPropertySymbolsFromContextualType(element, typeChecker, contextualType, /*unionSymbolOk*/ false), function (propertySymbol) { + return getDefinitionFromSymbol(typeChecker, propertySymbol, node); + }); + } + } + } function getReferenceAtPosition(sourceFile, position, program) { + var _a, _b; var referencePath = findReferenceInPosition(sourceFile.referencedFiles, position); if (referencePath) { var file = program.getSourceFileFromReference(sourceFile, referencePath); - return file && { reference: referencePath, file: file }; + return file && { reference: referencePath, fileName: file.fileName, file: file, unverified: false }; } var typeReferenceDirective = findReferenceInPosition(sourceFile.typeReferenceDirectives, position); if (typeReferenceDirective) { var reference = program.getResolvedTypeReferenceDirectives().get(typeReferenceDirective.fileName); var file = reference && program.getSourceFile(reference.resolvedFileName); // TODO:GH#18217 - return file && { reference: typeReferenceDirective, file: file }; + return file && { reference: typeReferenceDirective, fileName: file.fileName, file: file, unverified: false }; } var libReferenceDirective = findReferenceInPosition(sourceFile.libReferenceDirectives, position); if (libReferenceDirective) { var file = program.getLibFileFromReference(libReferenceDirective); - return file && { reference: libReferenceDirective, file: file }; + return file && { reference: libReferenceDirective, fileName: file.fileName, file: file, unverified: false }; + } + if ((_a = sourceFile.resolvedModules) === null || _a === void 0 ? void 0 : _a.size) { + var node = ts.getTokenAtPosition(sourceFile, position); + if (ts.isModuleSpecifierLike(node) && ts.isExternalModuleNameRelative(node.text) && sourceFile.resolvedModules.has(node.text)) { + var verifiedFileName = (_b = sourceFile.resolvedModules.get(node.text)) === null || _b === void 0 ? void 0 : _b.resolvedFileName; + var fileName = verifiedFileName || ts.resolvePath(ts.getDirectoryPath(sourceFile.fileName), node.text); + return { + file: program.getSourceFile(fileName), + fileName: fileName, + reference: { + pos: node.getStart(), + end: node.getEnd(), + fileName: node.text + }, + unverified: !verifiedFileName, + }; + } } return undefined; } @@ -125695,7 +130381,7 @@ var ts; // get the aliased symbol instead. This allows for goto def on an import e.g. // import {A, B} from "mod"; // to jump to the implementation directly. - if (symbol && symbol.flags & 2097152 /* Alias */ && shouldSkipAlias(node, symbol.declarations[0])) { + if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.flags & 2097152 /* Alias */ && shouldSkipAlias(node, symbol.declarations[0])) { var aliased = checker.getAliasedSymbol(symbol); if (aliased.declarations) { return aliased; @@ -125709,21 +130395,21 @@ var ts; // (2) when the aliased symbol is originating from an import. // function shouldSkipAlias(node, declaration) { - if (node.kind !== 78 /* Identifier */) { + if (node.kind !== 79 /* Identifier */) { return false; } if (node.parent === declaration) { return true; } switch (declaration.kind) { - case 262 /* ImportClause */: - case 260 /* ImportEqualsDeclaration */: + case 264 /* ImportClause */: + case 262 /* ImportEqualsDeclaration */: return true; - case 265 /* ImportSpecifier */: - return declaration.parent.kind === 264 /* NamedImports */; - case 198 /* BindingElement */: - case 249 /* VariableDeclaration */: - return ts.isInJSFile(declaration) && ts.isRequireVariableDeclaration(declaration, /*requireStringLiteralLikeArgument*/ true); + case 267 /* ImportSpecifier */: + return declaration.parent.kind === 266 /* NamedImports */; + case 200 /* BindingElement */: + case 251 /* VariableDeclaration */: + return ts.isInJSFile(declaration) && ts.isRequireVariableDeclaration(declaration); default: return false; } @@ -125738,7 +130424,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 === 132 /* ConstructorKeyword */)) { + if (symbol.flags & 32 /* Class */ && !(symbol.flags & (16 /* Function */ | 3 /* Variable */)) && (ts.isNewExpressionTarget(node) || node.kind === 133 /* 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); } @@ -125775,7 +130461,38 @@ var ts; var sourceFile = name.getSourceFile(); var 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: !checker.isDeclarationVisible(declaration) }); + containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration) }); + } + function isDefinitionVisible(checker, declaration) { + if (checker.isDeclarationVisible(declaration)) + return true; + if (!declaration.parent) + return false; + // Variable initializers are visible if variable is visible + if (ts.hasInitializer(declaration.parent) && declaration.parent.initializer === declaration) + 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 165 /* PropertyDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 167 /* MethodDeclaration */: + // Private/protected properties/methods are not visible + if (ts.hasEffectiveModifier(declaration, 8 /* Private */)) + return false; + // Public properties/methods are visible if its parents are visible, so: + // falls through + case 168 /* Constructor */: + case 290 /* PropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: + case 202 /* ObjectLiteralExpression */: + case 223 /* ClassExpression */: + case 211 /* ArrowFunction */: + case 210 /* FunctionExpression */: + return isDefinitionVisible(checker, declaration.parent); + default: + return false; + } } function createDefinitionFromSignatureDeclaration(typeChecker, decl) { return createDefinitionInfo(decl, typeChecker, decl.symbol, decl); @@ -125784,14 +130501,15 @@ var ts; return ts.find(refs, function (ref) { return ts.textRangeContainsPositionInclusive(ref, pos); }); } GoToDefinition.findReferenceInPosition = findReferenceInPosition; - function getDefinitionInfoForFileReference(name, targetFileName) { + function getDefinitionInfoForFileReference(name, targetFileName, unverified) { return { fileName: targetFileName, textSpan: ts.createTextSpanFromBounds(0, 0), kind: "script" /* scriptElement */, name: name, containerName: undefined, - containerKind: undefined, // TODO: GH#18217 + containerKind: undefined, + unverified: unverified, }; } /** Returns a CallLikeExpression where `node` is the target being invoked. */ @@ -125808,9 +130526,9 @@ var ts; } function isConstructorLike(node) { switch (node.kind) { - case 166 /* Constructor */: - case 175 /* ConstructorType */: - case 170 /* ConstructSignature */: + case 168 /* Constructor */: + case 177 /* ConstructorType */: + case 172 /* ConstructSignature */: return true; default: return false; @@ -125867,6 +130585,7 @@ var ts; "kind", "lends", "license", + "link", "listens", "member", "memberof", @@ -125904,78 +130623,115 @@ var ts; ]; var jsDocTagNameCompletionEntries; var jsDocTagCompletionEntries; - function getJsDocCommentsFromDeclarations(declarations) { + function getJsDocCommentsFromDeclarations(declarations, checker) { // Only collect doc comments from duplicate declarations once: // In case of a union property there might be same declaration multiple times // which only varies in type parameter // Eg. const a: Array | Array; a.length // The property length will have two declarations of property length coming // from Array - Array and Array - var documentationComment = []; + var parts = []; ts.forEachUnique(declarations, function (declaration) { for (var _i = 0, _a = getCommentHavingNodes(declaration); _i < _a.length; _i++) { var comment = _a[_i].comment; if (comment === undefined) continue; - ts.pushIfUnique(documentationComment, comment); + var newparts = getDisplayPartsFromComment(comment, checker); + if (!ts.contains(parts, newparts, isIdenticalListOfDisplayParts)) { + parts.push(newparts); + } } }); - return ts.intersperse(ts.map(documentationComment, ts.textPart), ts.lineBreakPart()); + return ts.flatten(ts.intersperse(parts, [ts.lineBreakPart()])); } JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; + function isIdenticalListOfDisplayParts(parts1, parts2) { + return ts.arraysEqual(parts1, parts2, function (p1, p2) { return p1.kind === p2.kind && p1.text === p2.text; }); + } function getCommentHavingNodes(declaration) { switch (declaration.kind) { - case 326 /* JSDocParameterTag */: - case 333 /* JSDocPropertyTag */: + case 334 /* JSDocParameterTag */: + case 341 /* JSDocPropertyTag */: return [declaration]; - case 324 /* JSDocCallbackTag */: - case 331 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + case 339 /* JSDocTypedefTag */: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); } } - function getJsDocTagsFromDeclarations(declarations) { + function getJsDocTagsFromDeclarations(declarations, checker) { // Only collect doc comments from duplicate declarations once. var tags = []; ts.forEachUnique(declarations, function (declaration) { for (var _i = 0, _a = ts.getJSDocTags(declaration); _i < _a.length; _i++) { var tag = _a[_i]; - tags.push({ name: tag.tagName.text, text: getCommentText(tag) }); + tags.push({ name: tag.tagName.text, text: getCommentDisplayParts(tag, checker) }); } }); return tags; } JsDoc.getJsDocTagsFromDeclarations = getJsDocTagsFromDeclarations; - function getCommentText(tag) { - var comment = tag.comment; - switch (tag.kind) { - case 316 /* JSDocImplementsTag */: + function getDisplayPartsFromComment(comment, checker) { + if (typeof comment === "string") { + return [ts.textPart(comment)]; + } + return ts.flatMap(comment, function (node) { return node.kind === 315 /* 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 323 /* JSDocImplementsTag */: return withNode(tag.class); - case 315 /* JSDocAugmentsTag */: + case 322 /* JSDocAugmentsTag */: return withNode(tag.class); - case 330 /* JSDocTemplateTag */: - return withList(tag.typeParameters); - case 329 /* JSDocTypeTag */: + case 338 /* JSDocTemplateTag */: + return addComment(tag.typeParameters.map(function (tp) { return tp.getText(); }).join(", ")); + case 337 /* JSDocTypeTag */: return withNode(tag.typeExpression); - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 333 /* JSDocPropertyTag */: - case 326 /* JSDocParameterTag */: - case 332 /* JSDocSeeTag */: + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + case 341 /* JSDocPropertyTag */: + case 334 /* JSDocParameterTag */: + case 340 /* JSDocSeeTag */: var name = tag.name; - return name ? withNode(name) : comment; + return name ? withNode(name) + : comment === undefined ? undefined + : getDisplayPartsFromComment(comment, checker); default: - return comment; + return comment === undefined ? undefined : getDisplayPartsFromComment(comment, checker); } function withNode(node) { return addComment(node.getText()); } - function withList(list) { - return addComment(list.map(function (x) { return x.getText(); }).join(", ")); - } function addComment(s) { - return comment === undefined ? s : s + " " + comment; + if (comment) { + if (s.match(/^https?$/)) { + return __spreadArray([ts.textPart(s)], getDisplayPartsFromComment(comment, checker)); + } + else { + return __spreadArray([namePart(s), ts.spacePart()], getDisplayPartsFromComment(comment, checker)); + } + } + else { + return [ts.textPart(s)]; + } + } + } + function getTagNameDisplayPart(kind) { + switch (kind) { + case 334 /* JSDocParameterTag */: + return ts.parameterNamePart; + case 341 /* JSDocPropertyTag */: + return ts.propertyNamePart; + case 338 /* JSDocTemplateTag */: + return ts.typeParameterNamePart; + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + return ts.typeAliasNamePart; + default: + return ts.textPart; } } function getJSDocTagNameCompletions() { @@ -126069,7 +130825,7 @@ var ts; * @param position The (character-indexed) position in the file where the check should * be performed. */ - function getDocCommentTemplateAtPosition(newLine, sourceFile, position) { + function getDocCommentTemplateAtPosition(newLine, sourceFile, position, options) { var tokenAtPos = ts.getTokenAtPosition(sourceFile, position); var existingDocComment = ts.findAncestor(tokenAtPos, ts.isJSDoc); if (existingDocComment && (existingDocComment.comment !== undefined || ts.length(existingDocComment.tags))) { @@ -126081,7 +130837,7 @@ var ts; if (!existingDocComment && tokenStart < position) { return undefined; } - var commentOwnerInfo = getCommentOwnerInfo(tokenAtPos); + var commentOwnerInfo = getCommentOwnerInfo(tokenAtPos, options); if (!commentOwnerInfo) { return undefined; } @@ -126123,7 +130879,7 @@ 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 === 78 /* Identifier */ ? name.text : "param" + i; + var paramName = name.kind === 79 /* Identifier */ ? name.text : "param" + i; var type = isJavaScriptFile ? (dotDotDotToken ? "{...any} " : "{any} ") : ""; return indentationStr + " * @param " + type + paramName + newLine; }).join(""); @@ -126131,76 +130887,77 @@ var ts; function returnsDocComment(indentationStr, newLine) { return indentationStr + " * @returns" + newLine; } - function getCommentOwnerInfo(tokenAtPos) { - return ts.forEachAncestor(tokenAtPos, getCommentOwnerInfoWorker); + function getCommentOwnerInfo(tokenAtPos, options) { + return ts.forEachAncestor(tokenAtPos, function (n) { return getCommentOwnerInfoWorker(n, options); }); } - function getCommentOwnerInfoWorker(commentOwner) { + function getCommentOwnerInfoWorker(commentOwner, options) { switch (commentOwner.kind) { - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: - case 164 /* MethodSignature */: - case 209 /* ArrowFunction */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 167 /* MethodDeclaration */: + case 168 /* Constructor */: + case 166 /* MethodSignature */: + case 211 /* ArrowFunction */: var host = commentOwner; - return { commentOwner: commentOwner, parameters: host.parameters, hasReturn: hasReturn(host) }; - case 288 /* PropertyAssignment */: - return getCommentOwnerInfoWorker(commentOwner.initializer); - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 162 /* PropertySignature */: - case 255 /* EnumDeclaration */: - case 291 /* EnumMember */: - case 254 /* TypeAliasDeclaration */: + return { commentOwner: commentOwner, parameters: host.parameters, hasReturn: hasReturn(host, options) }; + case 290 /* PropertyAssignment */: + return getCommentOwnerInfoWorker(commentOwner.initializer, options); + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 164 /* PropertySignature */: + case 257 /* EnumDeclaration */: + case 293 /* EnumMember */: + case 256 /* TypeAliasDeclaration */: return { commentOwner: commentOwner }; - case 232 /* VariableStatement */: { + case 234 /* VariableStatement */: { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; var host_1 = varDeclarations.length === 1 && varDeclarations[0].initializer ? getRightHandSideOfAssignment(varDeclarations[0].initializer) : undefined; return host_1 - ? { commentOwner: commentOwner, parameters: host_1.parameters, hasReturn: hasReturn(host_1) } + ? { commentOwner: commentOwner, parameters: host_1.parameters, hasReturn: hasReturn(host_1, options) } : { commentOwner: commentOwner }; } - case 297 /* SourceFile */: + case 299 /* SourceFile */: return "quit"; - case 256 /* ModuleDeclaration */: + case 258 /* 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 === 256 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; - case 233 /* ExpressionStatement */: - return getCommentOwnerInfoWorker(commentOwner.expression); - case 216 /* BinaryExpression */: { + return commentOwner.parent.kind === 258 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; + case 235 /* ExpressionStatement */: + return getCommentOwnerInfoWorker(commentOwner.expression, options); + case 218 /* BinaryExpression */: { var be = commentOwner; if (ts.getAssignmentDeclarationKind(be) === 0 /* None */) { return "quit"; } return ts.isFunctionLike(be.right) - ? { commentOwner: commentOwner, parameters: be.right.parameters, hasReturn: hasReturn(be.right) } + ? { commentOwner: commentOwner, parameters: be.right.parameters, hasReturn: hasReturn(be.right, options) } : { commentOwner: commentOwner }; } - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: var init = commentOwner.initializer; if (init && (ts.isFunctionExpression(init) || ts.isArrowFunction(init))) { - return { commentOwner: commentOwner, parameters: init.parameters, hasReturn: hasReturn(init) }; + return { commentOwner: commentOwner, parameters: init.parameters, hasReturn: hasReturn(init, options) }; } } } - function hasReturn(node) { - return ts.isArrowFunction(node) && ts.isExpression(node.body) - || ts.isFunctionLikeDeclaration(node) && node.body && ts.isBlock(node.body) && !!ts.forEachReturnStatement(node.body, function (n) { return n; }); + function hasReturn(node, options) { + return !!(options === null || options === void 0 ? void 0 : options.generateReturnInDocTemplate) && + (ts.isArrowFunction(node) && ts.isExpression(node.body) + || ts.isFunctionLikeDeclaration(node) && node.body && ts.isBlock(node.body) && !!ts.forEachReturnStatement(node.body, function (n) { return n; })); } function getRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 207 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 209 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return rightHandSide; - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: return ts.find(rightHandSide.members, ts.isConstructorDeclaration); } } @@ -126216,7 +130973,7 @@ var ts; if (!patternMatcher) return ts.emptyArray; var rawItems = []; - var _loop_5 = function (sourceFile) { + var _loop_6 = function (sourceFile) { cancellationToken.throwIfCancellationRequested(); if (excludeDtsFiles && sourceFile.isDeclarationFile) { return "continue"; @@ -126228,7 +130985,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_5(sourceFile); + _loop_6(sourceFile); } rawItems.sort(compareNavigateToItems); return (maxResultCount === undefined ? rawItems : rawItems.slice(0, maxResultCount)).map(createNavigateToItem); @@ -126259,9 +131016,9 @@ var ts; } function shouldKeepItem(declaration, checker) { switch (declaration.kind) { - case 262 /* ImportClause */: - case 265 /* ImportSpecifier */: - case 260 /* ImportEqualsDeclaration */: + case 264 /* ImportClause */: + case 267 /* ImportSpecifier */: + case 262 /* ImportEqualsDeclaration */: var importer = checker.getSymbolAtLocation(declaration.name); // TODO: GH#18217 var imported = checker.getAliasedSymbol(importer); return importer.escapedName !== imported.escapedName; @@ -126271,7 +131028,7 @@ var ts; } function tryAddSingleDeclarationName(declaration, containers) { var name = ts.getNameOfDeclaration(declaration); - return !!name && (pushLiteral(name, containers) || name.kind === 158 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); + return !!name && (pushLiteral(name, containers) || name.kind === 160 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); } // Only added the names of computed properties if they're simple dotted expressions, like: // @@ -126288,7 +131045,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 === 158 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { + if (name && name.kind === 160 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { return ts.emptyArray; } // Don't include the last portion. @@ -126488,6 +131245,28 @@ var ts; addChildrenRecursively(child); endNode(); } + function addNodeWithRecursiveInitializer(node) { + if (node.initializer && isFunctionOrClassExpression(node.initializer)) { + startNode(node); + ts.forEachChild(node.initializer, addChildrenRecursively); + endNode(); + } + else { + addNodeWithRecursiveChild(node, node.initializer); + } + } + /** + * Historically, we've elided dynamic names from the nav tree (including late bound names), + * but included certain "well known" symbol names. While we no longer distinguish those well-known + * symbols from other unique symbols, we do the below to retain those members in the nav tree. + */ + function hasNavigationBarName(node) { + return !ts.hasDynamicName(node) || + (node.kind !== 218 /* BinaryExpression */ && + ts.isPropertyAccessExpression(node.name.expression) && + ts.isIdentifier(node.name.expression.expression) && + ts.idText(node.name.expression.expression) === "Symbol"); + } /** Look for navigation bar items in node's subtree, adding them to the current `parent`. */ function addChildrenRecursively(node) { var _a; @@ -126496,7 +131275,7 @@ var ts; return; } switch (node.kind) { - case 166 /* Constructor */: + case 168 /* 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); @@ -126508,21 +131287,25 @@ var ts; } } break; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 164 /* MethodSignature */: - if (!ts.hasDynamicName(node)) { + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 166 /* MethodSignature */: + if (hasNavigationBarName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - if (!ts.hasDynamicName(node)) { + case 165 /* PropertyDeclaration */: + if (hasNavigationBarName(node)) { + addNodeWithRecursiveInitializer(node); + } + break; + case 164 /* PropertySignature */: + if (hasNavigationBarName(node)) { addLeafNode(node); } break; - case 262 /* ImportClause */: + case 264 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -126534,7 +131317,7 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 263 /* NamespaceImport */) { + if (namedBindings.kind === 265 /* NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -126545,32 +131328,27 @@ var ts; } } break; - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: addNodeWithRecursiveChild(node, node.name); break; - case 290 /* SpreadAssignment */: + case 292 /* 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 198 /* BindingElement */: - case 288 /* PropertyAssignment */: - case 249 /* VariableDeclaration */: - var _e = node, name = _e.name, initializer = _e.initializer; - if (ts.isBindingPattern(name)) { - addChildrenRecursively(name); - } - else if (initializer && isFunctionOrClassExpression(initializer)) { - // Add a node for the VariableDeclaration, but not for the initializer. - startNode(node); - ts.forEachChild(initializer, addChildrenRecursively); - endNode(); + case 200 /* BindingElement */: + case 290 /* PropertyAssignment */: + case 251 /* VariableDeclaration */: { + var child = node; + if (ts.isBindingPattern(child.name)) { + addChildrenRecursively(child.name); } else { - addNodeWithRecursiveChild(node, initializer); + addNodeWithRecursiveInitializer(child); } break; - case 251 /* FunctionDeclaration */: + } + case 253 /* FunctionDeclaration */: var nameNode = node.name; // If we see a function declaration track as a possible ES5 class if (nameNode && ts.isIdentifier(nameNode)) { @@ -126578,34 +131356,34 @@ var ts; } addNodeWithRecursiveChild(node, node.body); break; - case 209 /* ArrowFunction */: - case 208 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 210 /* FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: startNode(node); - for (var _f = 0, _g = node.members; _f < _g.length; _f++) { - var member = _g[_f]; + for (var _e = 0, _f = node.members; _e < _f.length; _e++) { + var member = _f[_e]; if (!isComputedProperty(member)) { addLeafNode(member); } } endNode(); break; - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: startNode(node); - for (var _h = 0, _j = node.members; _h < _j.length; _h++) { - var member = _j[_h]; + for (var _g = 0, _h = node.members; _g < _h.length; _g++) { + var member = _h[_g]; addChildrenRecursively(member); } endNode(); break; - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 266 /* ExportAssignment */: { + case 268 /* 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; @@ -126619,16 +131397,16 @@ var ts; } break; } - case 270 /* ExportSpecifier */: - case 260 /* ImportEqualsDeclaration */: - case 171 /* IndexSignature */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 254 /* TypeAliasDeclaration */: + case 272 /* ExportSpecifier */: + case 262 /* ImportEqualsDeclaration */: + case 173 /* IndexSignature */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 256 /* TypeAliasDeclaration */: addLeafNode(node); break; - case 203 /* CallExpression */: - case 216 /* BinaryExpression */: { + case 205 /* CallExpression */: + case 218 /* BinaryExpression */: { var special = ts.getAssignmentDeclarationKind(node); switch (special) { case 1 /* ExportsProperty */: @@ -126680,7 +131458,7 @@ var ts; defineCall.arguments[0] : defineCall.arguments[0].expression; var memberName = defineCall.arguments[1]; - var _k = startNestedNodes(node, className), depth = _k[0], classNameIdentifier = _k[1]; + var _j = startNestedNodes(node, className), depth = _j[0], classNameIdentifier = _j[1]; startNode(node, classNameIdentifier); startNode(node, ts.setTextRange(ts.factory.createIdentifier(memberName.text), memberName)); addChildrenRecursively(node.arguments[2]); @@ -126870,13 +131648,14 @@ var ts; return false; } switch (a.kind) { - case 163 /* PropertyDeclaration */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return ts.hasSyntacticModifier(a, 32 /* Static */) === ts.hasSyntacticModifier(b, 32 /* Static */); - case 256 /* ModuleDeclaration */: - return areSameModule(a, b); + case 258 /* ModuleDeclaration */: + return areSameModule(a, b) + && getFullyQualifiedModuleName(a) === getFullyQualifiedModuleName(b); default: return true; } @@ -126893,8 +131672,7 @@ var ts; // We use 1 NavNode to represent 'A.B.C', but there are multiple source nodes. // Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'! function areSameModule(a, b) { - // TODO: GH#18217 - return a.body.kind === b.body.kind && (a.body.kind !== 256 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); + return a.body.kind === b.body.kind && (a.body.kind !== 258 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); } /** Merge source into target. Source should be thrown away after this is called. */ function merge(target, source) { @@ -126924,7 +131702,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 256 /* ModuleDeclaration */) { + if (node.kind === 258 /* ModuleDeclaration */) { return getModuleName(node); } var declName = ts.getNameOfDeclaration(node); @@ -126933,16 +131711,16 @@ var ts; return propertyName && ts.unescapeLeadingUnderscores(propertyName); } switch (node.kind) { - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 221 /* ClassExpression */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 223 /* ClassExpression */: return getFunctionOrClassName(node); default: return undefined; } } function getItemName(node, name) { - if (node.kind === 256 /* ModuleDeclaration */) { + if (node.kind === 258 /* ModuleDeclaration */) { return cleanText(getModuleName(node)); } if (name) { @@ -126954,18 +131732,18 @@ var ts; } } switch (node.kind) { - case 297 /* SourceFile */: + case 299 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return ts.isExportAssignment(node) && node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; - case 209 /* ArrowFunction */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 211 /* ArrowFunction */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: if (ts.getSyntacticModifierFlags(node) & 512 /* Default */) { return "default"; } @@ -126973,13 +131751,13 @@ var ts; // (eg: "app\n.onactivated"), so we should remove the whitespace for readability in the // navigation bar. return getFunctionOrClassName(node); - case 166 /* Constructor */: + case 168 /* Constructor */: return "constructor"; - case 170 /* ConstructSignature */: + case 172 /* ConstructSignature */: return "new()"; - case 169 /* CallSignature */: + case 171 /* CallSignature */: return "()"; - case 171 /* IndexSignature */: + case 173 /* IndexSignature */: return "[]"; default: return ""; @@ -127012,19 +131790,19 @@ var ts; } // Some nodes are otherwise important enough to always include in the primary navigation menu. switch (navigationBarNodeKind(item)) { - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 255 /* EnumDeclaration */: - case 253 /* InterfaceDeclaration */: - case 256 /* ModuleDeclaration */: - case 297 /* SourceFile */: - case 254 /* TypeAliasDeclaration */: - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 257 /* EnumDeclaration */: + case 255 /* InterfaceDeclaration */: + case 258 /* ModuleDeclaration */: + case 299 /* SourceFile */: + case 256 /* TypeAliasDeclaration */: + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: return true; - case 209 /* ArrowFunction */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -127034,10 +131812,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 257 /* ModuleBlock */: - case 297 /* SourceFile */: - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: + case 259 /* ModuleBlock */: + case 299 /* SourceFile */: + case 167 /* MethodDeclaration */: + case 168 /* Constructor */: return true; default: return false; @@ -127094,9 +131872,12 @@ var ts; if (ts.isAmbientModule(moduleDeclaration)) { return ts.getTextOfNode(moduleDeclaration.name); } + return getFullyQualifiedModuleName(moduleDeclaration); + } + 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 === 256 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 258 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); } @@ -127110,13 +131891,13 @@ var ts; return decl.body && ts.isModuleDeclaration(decl.body) ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 158 /* ComputedPropertyName */; + return !member.name || member.name.kind === 160 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 297 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); + return node.kind === 299 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { - if (node.parent && node.parent.kind === 249 /* VariableDeclaration */) { + if (node.parent && node.parent.kind === 251 /* VariableDeclaration */) { node = node.parent; } return ts.getNodeModifiers(node); @@ -127131,7 +131912,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 === 62 /* EqualsToken */) { + else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */) { return nodeText(parent.left).replace(whiteSpaceRegex, ""); } // See if it is a property assignment, and if so use the property name @@ -127174,9 +131955,9 @@ var ts; } function isFunctionOrClassExpression(node) { switch (node.kind) { - case 209 /* ArrowFunction */: - case 208 /* FunctionExpression */: - case 221 /* ClassExpression */: + case 211 /* ArrowFunction */: + case 210 /* FunctionExpression */: + case 223 /* ClassExpression */: return true; default: return false; @@ -127205,9 +131986,9 @@ var ts; * 2) Coalescing imports from the same module * 3) Sorting imports */ - function organizeImports(sourceFile, formatContext, host, program, preferences) { + function organizeImports(sourceFile, formatContext, host, program, preferences, skipDestructiveCodeActions) { var changeTracker = ts.textChanges.ChangeTracker.fromContext({ host: host, formatContext: formatContext, preferences: preferences }); - var coalesceAndOrganizeImports = function (importGroup) { return ts.stableSort(coalesceImports(removeUnusedImports(importGroup, sourceFile, program)), function (s1, s2) { return compareImportsOrRequireStatements(s1, s2); }); }; + var coalesceAndOrganizeImports = function (importGroup) { return ts.stableSort(coalesceImports(removeUnusedImports(importGroup, sourceFile, program, skipDestructiveCodeActions)), function (s1, s2) { return compareImportsOrRequireStatements(s1, s2); }); }; // All of the old ImportDeclarations in the file, in syntactic order. var topLevelImportDecls = sourceFile.statements.filter(ts.isImportDeclaration); organizeImportsWorker(topLevelImportDecls, coalesceAndOrganizeImports); @@ -127242,26 +132023,35 @@ var ts; ? coalesce(importGroup) : importGroup; }); - // Delete or replace the first import. + // Delete all nodes if there are no imports. if (newImportDecls.length === 0) { - changeTracker.delete(sourceFile, oldImportDecls[0]); + // Consider the first node to have trailingTrivia as we want to exclude the + // "header" comment. + changeTracker.deleteNodes(sourceFile, oldImportDecls, { + trailingTriviaOption: ts.textChanges.TrailingTriviaOption.Include, + }, /*hasTrailingComment*/ true); } else { // Note: Delete the surrounding trivia because it will have been retained in newImportDecls. - changeTracker.replaceNodeWithNodes(sourceFile, oldImportDecls[0], newImportDecls, { + var replaceOptions = { leadingTriviaOption: ts.textChanges.LeadingTriviaOption.Exclude, trailingTriviaOption: ts.textChanges.TrailingTriviaOption.Include, suffix: ts.getNewLineOrDefaultFromHost(host, formatContext.options), - }); - } - // Delete any subsequent imports. - for (var i = 1; i < oldImportDecls.length; i++) { - changeTracker.deleteNode(sourceFile, oldImportDecls[i]); + }; + changeTracker.replaceNodeWithNodes(sourceFile, oldImportDecls[0], newImportDecls, replaceOptions); + var hasTrailingComment = changeTracker.nodeHasTrailingComment(sourceFile, oldImportDecls[0], replaceOptions); + changeTracker.deleteNodes(sourceFile, oldImportDecls.slice(1), { + trailingTriviaOption: ts.textChanges.TrailingTriviaOption.Include, + }, hasTrailingComment); } } } OrganizeImports.organizeImports = organizeImports; - function removeUnusedImports(oldImports, sourceFile, program) { + function removeUnusedImports(oldImports, sourceFile, program, skipDestructiveCodeActions) { + // As a precaution, consider unused import detection to be destructive (GH #43051) + if (skipDestructiveCodeActions) { + return oldImports; + } var typeChecker = program.getTypeChecker(); var jsxNamespace = typeChecker.getJsxNamespace(sourceFile); var jsxFragmentFactory = typeChecker.getJsxFragmentFactory(sourceFile); @@ -127532,11 +132322,11 @@ var ts; function getModuleSpecifierExpression(declaration) { var _a; switch (declaration.kind) { - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return (_a = ts.tryCast(declaration.moduleReference, ts.isExternalModuleReference)) === null || _a === void 0 ? void 0 : _a.expression; - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return declaration.moduleSpecifier; - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return declaration.declarationList.declarations[0].initializer.arguments[0]; } } @@ -127575,19 +132365,19 @@ var ts; function getImportKindOrder(s1) { var _a; switch (s1.kind) { - case 261 /* ImportDeclaration */: + case 263 /* 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) === 263 /* NamespaceImport */) + if (((_a = s1.importClause.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 265 /* NamespaceImport */) return 2; if (s1.importClause.name) return 3; return 4; - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return 5; - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return 6; } } @@ -127625,7 +132415,7 @@ var ts; } var lastImport = current - 1; if (lastImport !== firstImport) { - out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 99 /* ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* Imports */)); + out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 100 /* ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* Imports */)); } } function visitNonImportNode(n) { @@ -127689,8 +132479,15 @@ var ts; } } } - var regionDelimiterRegExp = /^\s*\/\/\s*#(end)?region(?:\s+(.*))?(?:\r)?$/; + var regionDelimiterRegExp = /^#(end)?region(?:\s+(.*))?(?:\r)?$/; function isRegionDelimiter(lineText) { + // We trim the leading whitespace and // without the regex since the + // multiple potential whitespace matches can make for some gnarly backtracking behavior + lineText = ts.trimStringStart(lineText); + if (!ts.startsWith(lineText, "\/\/")) { + return null; // eslint-disable-line no-null/no-null + } + lineText = ts.trimString(lineText.slice(2)); return regionDelimiterRegExp.exec(lineText); } function addOutliningForLeadingCommentsForNode(n, sourceFile, cancellationToken, out) { @@ -127743,7 +132540,7 @@ var ts; } function getOutliningSpanForNode(n, sourceFile) { switch (n.kind) { - case 230 /* Block */: + case 232 /* Block */: if (ts.isFunctionLike(n.parent)) { return functionSpan(n.parent, n, sourceFile); } @@ -127751,23 +132548,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 235 /* DoStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 237 /* ForStatement */: - case 234 /* IfStatement */: - case 236 /* WhileStatement */: - case 243 /* WithStatement */: - case 287 /* CatchClause */: + case 237 /* DoStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 239 /* ForStatement */: + case 236 /* IfStatement */: + case 238 /* WhileStatement */: + case 245 /* WithStatement */: + case 289 /* CatchClause */: return spanForNode(n.parent); - case 247 /* TryStatement */: + case 249 /* 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, 95 /* FinallyKeyword */, sourceFile); + var node = ts.findChildOfKind(tryStatement, 96 /* FinallyKeyword */, sourceFile); if (node) return spanForNode(node); } @@ -127777,40 +132574,40 @@ var ts; // the span of the block, independent of any parent span. return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* Code */); } - case 257 /* ModuleBlock */: + case 259 /* ModuleBlock */: return spanForNode(n.parent); - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - case 258 /* CaseBlock */: - case 177 /* TypeLiteral */: - case 196 /* ObjectBindingPattern */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: + case 257 /* EnumDeclaration */: + case 260 /* CaseBlock */: + case 179 /* TypeLiteral */: + case 198 /* ObjectBindingPattern */: return spanForNode(n); - case 179 /* TupleType */: + case 181 /* TupleType */: return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isTupleTypeNode(n.parent), 22 /* OpenBracketToken */); - case 284 /* CaseClause */: - case 285 /* DefaultClause */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: return spanForNodeArray(n.statements); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return spanForObjectOrArrayLiteral(n); - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return spanForObjectOrArrayLiteral(n, 22 /* OpenBracketToken */); - case 273 /* JsxElement */: + case 275 /* JsxElement */: return spanForJSXElement(n); - case 277 /* JsxFragment */: + case 279 /* JsxFragment */: return spanForJSXFragment(n); - case 274 /* JsxSelfClosingElement */: - case 275 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: return spanForJSXAttributes(n.attributes); - case 218 /* TemplateExpression */: + case 220 /* TemplateExpression */: case 14 /* NoSubstitutionTemplateLiteral */: return spanForTemplateLiteral(n); - case 197 /* ArrayBindingPattern */: + case 199 /* ArrayBindingPattern */: return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isBindingElement(n.parent), 22 /* OpenBracketToken */); - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return spanForArrowFunction(n); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return spanForCallExpression(n); } function spanForCallExpression(node) { @@ -127877,7 +132674,7 @@ var ts; 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 !== 209 /* ArrowFunction */); + return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 211 /* ArrowFunction */); } function spanBetweenTokens(openToken, closeToken, hintSpanNode, sourceFile, autoCollapse, useFullStart) { if (autoCollapse === void 0) { autoCollapse = false; } @@ -128180,15 +132977,15 @@ var ts; // Assumes 'value' is already lowercase. function indexOfIgnoringCase(str, value) { var n = str.length - value.length; - var _loop_6 = function (start) { + var _loop_7 = 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_1 = _loop_6(start); - if (typeof state_1 === "object") - return state_1.value; + var state_2 = _loop_7(start); + if (typeof state_2 === "object") + return state_2.value; } return -1; } @@ -128421,10 +133218,10 @@ var ts; */ function tryConsumeDeclare() { var token = ts.scanner.getToken(); - if (token === 133 /* DeclareKeyword */) { + if (token === 134 /* DeclareKeyword */) { // declare module "mod" token = nextToken(); - if (token === 139 /* ModuleKeyword */) { + if (token === 140 /* ModuleKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { recordAmbientExternalModule(); @@ -128442,7 +133239,7 @@ var ts; return false; } var token = ts.scanner.getToken(); - if (token === 99 /* ImportKeyword */) { + if (token === 100 /* ImportKeyword */) { token = nextToken(); if (token === 20 /* OpenParenToken */) { token = nextToken(); @@ -128458,21 +133255,21 @@ var ts; return true; } else { - if (token === 149 /* TypeKeyword */) { + if (token === 150 /* TypeKeyword */) { var skipTypeKeyword = ts.scanner.lookAhead(function () { var token = ts.scanner.scan(); - return token !== 153 /* FromKeyword */ && (token === 41 /* AsteriskToken */ || + return token !== 154 /* FromKeyword */ && (token === 41 /* AsteriskToken */ || token === 18 /* OpenBraceToken */ || - token === 78 /* Identifier */ || + token === 79 /* Identifier */ || ts.isKeyword(token)); }); if (skipTypeKeyword) { token = nextToken(); } } - if (token === 78 /* Identifier */ || ts.isKeyword(token)) { + if (token === 79 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 153 /* FromKeyword */) { + if (token === 154 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // import d from "mod"; @@ -128480,7 +133277,7 @@ var ts; return true; } } - else if (token === 62 /* EqualsToken */) { + else if (token === 63 /* EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } @@ -128503,7 +133300,7 @@ var ts; } if (token === 19 /* CloseBraceToken */) { token = nextToken(); - if (token === 153 /* FromKeyword */) { + if (token === 154 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // import {a as A} from "mod"; @@ -128515,11 +133312,11 @@ var ts; } else if (token === 41 /* AsteriskToken */) { token = nextToken(); - if (token === 126 /* AsKeyword */) { + if (token === 127 /* AsKeyword */) { token = nextToken(); - if (token === 78 /* Identifier */ || ts.isKeyword(token)) { + if (token === 79 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 153 /* FromKeyword */) { + if (token === 154 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // import * as NS from "mod" @@ -128537,10 +133334,10 @@ var ts; } function tryConsumeExport() { var token = ts.scanner.getToken(); - if (token === 92 /* ExportKeyword */) { + if (token === 93 /* ExportKeyword */) { markAsExternalModuleIfTopLevel(); token = nextToken(); - if (token === 149 /* TypeKeyword */) { + if (token === 150 /* TypeKeyword */) { var skipTypeKeyword = ts.scanner.lookAhead(function () { var token = ts.scanner.scan(); return token === 41 /* AsteriskToken */ || @@ -128559,7 +133356,7 @@ var ts; } if (token === 19 /* CloseBraceToken */) { token = nextToken(); - if (token === 153 /* FromKeyword */) { + if (token === 154 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // export {a as A} from "mod"; @@ -128571,7 +133368,7 @@ var ts; } else if (token === 41 /* AsteriskToken */) { token = nextToken(); - if (token === 153 /* FromKeyword */) { + if (token === 154 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // export * from "mod" @@ -128579,21 +133376,21 @@ var ts; } } } - else if (token === 99 /* ImportKeyword */) { + else if (token === 100 /* ImportKeyword */) { token = nextToken(); - if (token === 149 /* TypeKeyword */) { + if (token === 150 /* TypeKeyword */) { var skipTypeKeyword = ts.scanner.lookAhead(function () { var token = ts.scanner.scan(); - return token === 78 /* Identifier */ || + return token === 79 /* Identifier */ || ts.isKeyword(token); }); if (skipTypeKeyword) { token = nextToken(); } } - if (token === 78 /* Identifier */ || ts.isKeyword(token)) { + if (token === 79 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 62 /* EqualsToken */) { + if (token === 63 /* EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } @@ -128607,7 +133404,7 @@ var ts; function tryConsumeRequireCall(skipCurrentToken, allowTemplateLiterals) { if (allowTemplateLiterals === void 0) { allowTemplateLiterals = false; } var token = skipCurrentToken ? nextToken() : ts.scanner.getToken(); - if (token === 143 /* RequireKeyword */) { + if (token === 144 /* RequireKeyword */) { token = nextToken(); if (token === 20 /* OpenParenToken */) { token = nextToken(); @@ -128623,7 +133420,7 @@ var ts; } function tryConsumeDefine() { var token = ts.scanner.getToken(); - if (token === 78 /* Identifier */ && ts.scanner.getTokenValue() === "define") { + if (token === 79 /* Identifier */ && ts.scanner.getTokenValue() === "define") { token = nextToken(); if (token !== 20 /* OpenParenToken */) { return true; @@ -128740,7 +133537,7 @@ var ts; function getRenameInfo(program, sourceFile, position, options) { var node = ts.getAdjustedRenameLocation(ts.getTouchingPropertyName(sourceFile, position)); if (nodeIsEligibleForRename(node)) { - var renameInfo = getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, function (declaration) { return program.isSourceFileDefaultLibrary(declaration.getSourceFile()); }, options); + var renameInfo = getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, program, options); if (renameInfo) { return renameInfo; } @@ -128748,7 +133545,7 @@ var ts; return getRenameInfoError(ts.Diagnostics.You_cannot_rename_this_element); } Rename.getRenameInfo = getRenameInfo; - function getRenameInfoForNode(node, typeChecker, sourceFile, isDefinedInLibraryFile, options) { + function getRenameInfoForNode(node, typeChecker, sourceFile, program, options) { var symbol = typeChecker.getSymbolAtLocation(node); if (!symbol) { if (ts.isStringLiteralLike(node)) { @@ -128768,29 +133565,33 @@ var ts; if (!declarations || declarations.length === 0) return; // Disallow rename for elements that are defined in the standard TypeScript library. - if (declarations.some(isDefinedInLibraryFile)) { + if (declarations.some(function (declaration) { return isDefinedInLibraryFile(program, declaration); })) { 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 === 87 /* DefaultKeyword */ && symbol.parent && symbol.parent.flags & 1536 /* Module */) { + if (ts.isIdentifier(node) && node.originalKeywordKind === 88 /* DefaultKeyword */ && symbol.parent && symbol.parent.flags & 1536 /* Module */) { return undefined; } if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) { return options && options.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined; } var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); - var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 158 /* ComputedPropertyName */) + var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 160 /* ComputedPropertyName */) ? ts.stripQuotes(ts.getTextOfIdentifierOrLiteral(node)) : undefined; var displayName = specifierName || typeChecker.symbolToString(symbol); var fullDisplayName = specifierName || typeChecker.getFullyQualifiedName(symbol); return getRenameInfoSuccess(displayName, fullDisplayName, kind, ts.SymbolDisplay.getSymbolModifiers(typeChecker, symbol), node, sourceFile); } + function isDefinedInLibraryFile(program, declaration) { + var sourceFile = declaration.getSourceFile(); + return program.isSourceFileDefaultLibrary(sourceFile) && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Dts */); + } function getRenameInfoForModule(node, sourceFile, moduleSymbol) { if (!ts.isExternalModuleNameRelative(node.text)) { return getRenameInfoError(ts.Diagnostics.You_cannot_rename_a_module_via_a_global_import); } - var moduleSourceFile = ts.find(moduleSymbol.declarations, ts.isSourceFile); + var moduleSourceFile = moduleSymbol.declarations && ts.find(moduleSymbol.declarations, ts.isSourceFile); if (!moduleSourceFile) return undefined; var withoutIndex = ts.endsWith(node.text, "/index") || ts.endsWith(node.text, "/index.js") ? undefined : ts.tryRemoveSuffix(ts.removeFileExtension(moduleSourceFile.fileName), "/index"); @@ -128835,11 +133636,11 @@ var ts; } function nodeIsEligibleForRename(node) { switch (node.kind) { - case 78 /* Identifier */: - case 79 /* PrivateIdentifier */: + case 79 /* Identifier */: + case 80 /* PrivateIdentifier */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: return true; case 8 /* NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node); @@ -128871,6 +133672,10 @@ var ts; if (ts.getTokenPosOfNode(node, sourceFile, /*includeJsDoc*/ true) > pos) { break outer; } + var comment = ts.singleOrUndefined(ts.getTrailingCommentRanges(sourceFile.text, node.end)); + if (comment && comment.kind === 2 /* SingleLineCommentTrivia */) { + pushSelectionCommentRange(comment.pos, comment.end); + } if (positionShouldSnapToNode(sourceFile, pos, node)) { // 1. Blocks are effectively redundant with SyntaxLists. // 2. TemplateSpans, along with the SyntaxLists containing them, are a somewhat unintuitive grouping @@ -128933,6 +133738,14 @@ var ts; } } } + function pushSelectionCommentRange(start, end) { + pushSelectionRange(start, end); + var pos = start; + while (sourceFile.text.charCodeAt(pos) === 47 /* slash */) { + pos++; + } + pushSelectionRange(pos, end); + } } SmartSelectionRange.getSmartSelectionRange = getSmartSelectionRange; /** @@ -128989,14 +133802,14 @@ var ts; ts.Debug.assertEqual(closeBraceToken.kind, 19 /* CloseBraceToken */); // Group `-/+readonly` and `-/+?` var groupedWithPlusMinusTokens = groupChildren(children, function (child) { - return child === node.readonlyToken || child.kind === 142 /* ReadonlyKeyword */ || + return child === node.readonlyToken || child.kind === 143 /* ReadonlyKeyword */ || child === node.questionToken || child.kind === 57 /* QuestionToken */; }); // Group type parameter with surrounding brackets var groupedWithBrackets = groupChildren(groupedWithPlusMinusTokens, function (_a) { var kind = _a.kind; return kind === 22 /* OpenBracketToken */ || - kind === 159 /* TypeParameter */ || + kind === 161 /* TypeParameter */ || kind === 23 /* CloseBracketToken */; }); return [ @@ -129029,14 +133842,14 @@ var ts; }); return splitChildren(groupedWithQuestionToken, function (_a) { var kind = _a.kind; - return kind === 62 /* EqualsToken */; + return kind === 63 /* EqualsToken */; }); } // Pivot on '=' if (ts.isBindingElement(node)) { return splitChildren(node.getChildren(), function (_a) { var kind = _a.kind; - return kind === 62 /* EqualsToken */; + return kind === 63 /* EqualsToken */; }); } return node.getChildren(); @@ -129110,22 +133923,22 @@ var ts; return kind === 18 /* OpenBraceToken */ || kind === 22 /* OpenBracketToken */ || kind === 20 /* OpenParenToken */ - || kind === 275 /* JsxOpeningElement */; + || kind === 277 /* JsxOpeningElement */; } function isListCloser(token) { var kind = token && token.kind; return kind === 19 /* CloseBraceToken */ || kind === 23 /* CloseBracketToken */ || kind === 21 /* CloseParenToken */ - || kind === 276 /* JsxClosingElement */; + || kind === 278 /* JsxClosingElement */; } function getEndPos(sourceFile, node) { switch (node.kind) { - case 326 /* JSDocParameterTag */: - case 324 /* JSDocCallbackTag */: - case 333 /* JSDocPropertyTag */: - case 331 /* JSDocTypedefTag */: - case 328 /* JSDocThisTag */: + case 334 /* JSDocParameterTag */: + case 332 /* JSDocCallbackTag */: + case 341 /* JSDocPropertyTag */: + case 339 /* JSDocTypedefTag */: + case 336 /* JSDocThisTag */: return sourceFile.getLineEndOfPosition(node.getStart()); default: return node.getEnd(); @@ -129335,10 +134148,10 @@ var ts; } return undefined; } - else if (ts.isTemplateHead(node) && parent.parent.kind === 205 /* TaggedTemplateExpression */) { + else if (ts.isTemplateHead(node) && parent.parent.kind === 207 /* TaggedTemplateExpression */) { var templateExpression = parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 218 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 220 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position, sourceFile) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } @@ -129407,17 +134220,17 @@ var ts; return undefined; var parent = startingToken.parent; switch (parent.kind) { - case 207 /* ParenthesizedExpression */: - case 165 /* MethodDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 209 /* ParenthesizedExpression */: + case 167 /* MethodDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: var info = getArgumentOrParameterListInfo(startingToken, 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 216 /* BinaryExpression */: { + case 218 /* BinaryExpression */: { var highestBinary = getHighestBinary(parent); var contextualType_1 = checker.getContextualType(highestBinary); var argumentIndex_1 = startingToken.kind === 20 /* OpenParenToken */ ? 0 : countBinaryExpressionParameters(parent) - 1; @@ -129541,7 +134354,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 === 218 /* TemplateExpression */) { + if (template.kind === 220 /* TemplateExpression */) { var lastSpan = ts.last(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -129550,7 +134363,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node, position, sourceFile, checker, isManuallyInvoked) { - var _loop_7 = function (n) { + var _loop_8 = 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); }); @@ -129560,9 +134373,9 @@ var ts; } }; for (var n = node; !ts.isSourceFile(n) && (isManuallyInvoked || !ts.isBlock(n)); n = n.parent) { - var state_2 = _loop_7(n); - if (typeof state_2 === "object") - return state_2.value; + var state_3 = _loop_8(n); + if (typeof state_3 === "object") + return state_3.value; } return undefined; } @@ -129612,7 +134425,19 @@ var ts; itemsSeen += item.length; } ts.Debug.assert(selectedItemIndex !== -1); // If candidates is non-empty it should always include bestSignature. We check for an empty candidates before calling this function. - return { items: ts.flatMapToMutable(items, ts.identity), applicableSpan: applicableSpan, selectedItemIndex: selectedItemIndex, argumentIndex: argumentIndex, argumentCount: argumentCount }; + var help = { items: ts.flatMapToMutable(items, ts.identity), applicableSpan: applicableSpan, selectedItemIndex: selectedItemIndex, argumentIndex: argumentIndex, argumentCount: argumentCount }; + var selected = help.items[selectedItemIndex]; + if (selected.isVariadic) { + var firstRest = ts.findIndex(selected.parameters, function (p) { return !!p.isRest; }); + if (-1 < firstRest && firstRest < selected.parameters.length - 1) { + // We don't have any code to get this correct; instead, don't highlight a current parameter AT ALL + help.argumentIndex = selected.parameters.length; + } + else { + help.argumentIndex = Math.min(help.argumentIndex, selected.parameters.length - 1); + } + } + return help; } function createTypeHelpItems(symbol, _a, sourceFile, checker) { var argumentCount = _a.argumentCount, applicableSpan = _a.argumentsSpan, invocation = _a.invocation, argumentIndex = _a.argumentIndex; @@ -129627,7 +134452,7 @@ var ts; var printer = ts.createPrinter({ removeComments: true }); var parameters = typeParameters.map(function (t) { return createSignatureHelpParameterForTypeParameter(t, checker, enclosingDeclaration, sourceFile, printer); }); var documentation = symbol.getDocumentationComment(checker); - var tags = symbol.getJsDocTags(); + var tags = symbol.getJsDocTags(checker); var prefixDisplayParts = __spreadArray(__spreadArray([], typeSymbolDisplay), [ts.punctuationPart(29 /* LessThanToken */)]); return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(31 /* GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; } @@ -129670,7 +134495,6 @@ var ts; }); } function itemInfoForParameters(candidateSignature, checker, enclosingDeclaration, sourceFile) { - var isVariadic = checker.hasEffectiveRestParameter(candidateSignature); var printer = ts.createPrinter({ removeComments: true }); var typeParameterParts = ts.mapToDisplayParts(function (writer) { if (candidateSignature.typeParameters && candidateSignature.typeParameters.length) { @@ -129679,14 +134503,15 @@ var ts; } }); var lists = checker.getExpandedParameters(candidateSignature); - return lists.map(function (parameterList) { - return { - isVariadic: isVariadic && (lists.length === 1 || !!(parameterList[parameterList.length - 1].checkFlags & 32768 /* RestParameter */)), - parameters: parameterList.map(function (p) { return createSignatureHelpParameterForParameter(p, checker, enclosingDeclaration, sourceFile, printer); }), - prefix: __spreadArray(__spreadArray([], typeParameterParts), [ts.punctuationPart(20 /* OpenParenToken */)]), - suffix: [ts.punctuationPart(21 /* CloseParenToken */)] - }; - }); + 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 */); }; + 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), [ts.punctuationPart(20 /* OpenParenToken */)]), + suffix: [ts.punctuationPart(21 /* CloseParenToken */)] + }); }); } function createSignatureHelpParameterForParameter(parameter, checker, enclosingDeclaration, sourceFile, printer) { var displayParts = ts.mapToDisplayParts(function (writer) { @@ -129694,14 +134519,15 @@ var ts; printer.writeNode(4 /* Unspecified */, param, sourceFile, writer); }); var isOptional = checker.isOptionalParameter(parameter.valueDeclaration); - return { name: parameter.name, documentation: parameter.getDocumentationComment(checker), displayParts: displayParts, isOptional: isOptional }; + var isRest = !!(parameter.checkFlags & 32768 /* 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); }); - return { name: typeParameter.symbol.name, documentation: typeParameter.symbol.getDocumentationComment(checker), displayParts: displayParts, isOptional: false }; + return { name: typeParameter.symbol.name, documentation: typeParameter.symbol.getDocumentationComment(checker), displayParts: displayParts, isOptional: false, isRest: false }; } })(SignatureHelp = ts.SignatureHelp || (ts.SignatureHelp = {})); })(ts || (ts = {})); @@ -129911,7 +134737,7 @@ var ts; diags.push(ts.createDiagnosticForNode(node.name || node, ts.Diagnostics.JSDoc_types_may_be_moved_to_TypeScript_types)); } } - if (ts.isFunctionLikeDeclaration(node)) { + if (canBeConvertedToAsync(node)) { addConvertToAsyncFunctionDiagnostics(node, checker, diags); } node.forEachChild(check); @@ -129922,11 +134748,11 @@ var ts; function containsTopLevelCommonjs(sourceFile) { return sourceFile.statements.some(function (statement) { switch (statement.kind) { - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return statement.declarationList.declarations.some(function (decl) { return !!decl.initializer && ts.isRequireCall(propertyAccessLeftHandSide(decl.initializer), /*checkArgumentIsStringLiteralLike*/ true); }); - case 233 /* ExpressionStatement */: { + case 235 /* ExpressionStatement */: { var expression = statement.expression; if (!ts.isBinaryExpression(expression)) return ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true); @@ -129943,12 +134769,12 @@ var ts; } function importNameForConvertToDefaultImport(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: var importClause = node.importClause, moduleSpecifier = node.moduleSpecifier; - return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 263 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) + return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 265 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) ? importClause.namedBindings.name : undefined; - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return node.name; default: return undefined; @@ -129964,35 +134790,35 @@ var ts; return !ts.isAsyncFunction(node) && node.body && ts.isBlock(node.body) && - hasReturnStatementWithPromiseHandler(node.body) && + hasReturnStatementWithPromiseHandler(node.body, checker) && returnsPromise(node, checker); } function returnsPromise(node, checker) { - var functionType = checker.getTypeAtLocation(node); - var callSignatures = checker.getSignaturesOfType(functionType, 0 /* Call */); - var returnType = callSignatures.length ? checker.getReturnTypeOfSignature(callSignatures[0]) : undefined; + var signature = checker.getSignatureFromDeclaration(node); + var returnType = signature ? checker.getReturnTypeOfSignature(signature) : undefined; return !!returnType && !!checker.getPromisedTypeOfPromise(returnType); } + ts.returnsPromise = returnsPromise; function getErrorNodeFromCommonJsIndicator(commonJsModuleIndicator) { return ts.isBinaryExpression(commonJsModuleIndicator) ? commonJsModuleIndicator.left : commonJsModuleIndicator; } - function hasReturnStatementWithPromiseHandler(body) { - return !!ts.forEachReturnStatement(body, isReturnStatementWithFixablePromiseHandler); + function hasReturnStatementWithPromiseHandler(body, checker) { + return !!ts.forEachReturnStatement(body, function (statement) { return isReturnStatementWithFixablePromiseHandler(statement, checker); }); } - function isReturnStatementWithFixablePromiseHandler(node) { - return ts.isReturnStatement(node) && !!node.expression && isFixablePromiseHandler(node.expression); + function isReturnStatementWithFixablePromiseHandler(node, checker) { + return ts.isReturnStatement(node) && !!node.expression && isFixablePromiseHandler(node.expression, checker); } ts.isReturnStatementWithFixablePromiseHandler = isReturnStatementWithFixablePromiseHandler; // Should be kept up to date with transformExpression in convertToAsyncFunction.ts - function isFixablePromiseHandler(node) { + function isFixablePromiseHandler(node, checker) { // ensure outermost call exists and is a promise handler - if (!isPromiseHandler(node) || !node.arguments.every(isFixablePromiseArgument)) { + if (!isPromiseHandler(node) || !node.arguments.every(function (arg) { return isFixablePromiseArgument(arg, checker); })) { return false; } // ensure all chained calls are valid var currentNode = node.expression; while (isPromiseHandler(currentNode) || ts.isPropertyAccessExpression(currentNode)) { - if (ts.isCallExpression(currentNode) && !currentNode.arguments.every(isFixablePromiseArgument)) { + if (ts.isCallExpression(currentNode) && !currentNode.arguments.every(function (arg) { return isFixablePromiseArgument(arg, checker); })) { return false; } currentNode = currentNode.expression; @@ -130010,21 +134836,34 @@ var ts; if (node.arguments.length < 2) return true; return ts.some(node.arguments, function (arg) { - return arg.kind === 103 /* NullKeyword */ || + return arg.kind === 104 /* NullKeyword */ || ts.isIdentifier(arg) && arg.text === "undefined"; }); } // should be kept up to date with getTransformationBody in convertToAsyncFunction.ts - function isFixablePromiseArgument(arg) { + function isFixablePromiseArgument(arg, checker) { switch (arg.kind) { - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + var functionFlags = ts.getFunctionFlags(arg); + if (functionFlags & 1 /* Generator */) { + return false; + } + // falls through + case 211 /* ArrowFunction */: visitedNestedConvertibleFunctions.set(getKeyFromNode(arg), true); // falls through - case 103 /* NullKeyword */: - case 78 /* Identifier */: // identifier includes undefined + case 104 /* NullKeyword */: return true; + case 79 /* Identifier */: + case 203 /* PropertyAccessExpression */: { + var symbol = checker.getSymbolAtLocation(arg); + if (!symbol) { + return false; + } + return checker.isUndefinedSymbol(symbol) || + ts.some(ts.skipAlias(symbol, checker).declarations, function (d) { return ts.isFunctionLike(d) || ts.hasInitializer(d) && !!d.initializer && ts.isFunctionLike(d.initializer); }); + } default: return false; } @@ -130034,18 +134873,30 @@ var ts; } function canBeConvertedToClass(node, checker) { var _a, _b, _c, _d; - if (node.kind === 208 /* FunctionExpression */) { + if (node.kind === 210 /* 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 === 251 /* FunctionDeclaration */) { + if (node.kind === 253 /* FunctionDeclaration */) { return !!((_d = node.symbol.members) === null || _d === void 0 ? void 0 : _d.size); } return false; } + function canBeConvertedToAsync(node) { + switch (node.kind) { + case 253 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + return true; + default: + return false; + } + } + ts.canBeConvertedToAsync = canBeConvertedToAsync; })(ts || (ts = {})); /* @internal */ var ts; @@ -130061,7 +134912,7 @@ var ts; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); if (flags & 32 /* Class */) { - return ts.getDeclarationOfKind(symbol, 221 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 223 /* ClassExpression */) ? "local class" /* localClassElement */ : "class" /* classElement */; } if (flags & 384 /* Enum */) @@ -130096,7 +134947,7 @@ var ts; if (typeChecker.isArgumentsSymbol(symbol)) { return "local var" /* localVariableElement */; } - if (location.kind === 107 /* ThisKeyword */ && ts.isExpression(location)) { + if (location.kind === 108 /* ThisKeyword */ && ts.isExpression(location)) { return "parameter" /* parameterElement */; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); @@ -130145,11 +134996,11 @@ var ts; // If we requested completions after `x.` at the top-level, we may be at a source file location. switch (location.parent && location.parent.kind) { // If we've typed a character of the attribute name, will be 'JsxAttribute', else will be 'JsxOpeningElement'. - case 275 /* JsxOpeningElement */: - case 273 /* JsxElement */: - case 274 /* JsxSelfClosingElement */: - return location.kind === 78 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; - case 280 /* JsxAttribute */: + case 277 /* JsxOpeningElement */: + case 275 /* JsxElement */: + case 276 /* JsxSelfClosingElement */: + return location.kind === 79 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; + case 282 /* JsxAttribute */: return "JSX attribute" /* jsxAttribute */; default: return "property" /* memberVariableElement */; @@ -130157,14 +135008,11 @@ var ts; } return "" /* unknown */; } - function isDeprecatedDeclaration(decl) { - return !!(ts.getCombinedNodeFlagsAlwaysIncludeJSDoc(decl) & 8192 /* Deprecated */); - } 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) && isDeprecatedDeclaration(declaration) && ts.some(declarations, function (d) { return !isDeprecatedDeclaration(d); }) + var excludeFlags = ts.length(declarations) && ts.isDeprecatedDeclaration(declaration) && ts.some(declarations, function (d) { return !ts.isDeprecatedDeclaration(d); }) ? 8192 /* Deprecated */ : 0 /* None */; var modifiers = ts.getNodeModifiers(declaration, excludeFlags); @@ -130195,6 +135043,7 @@ var ts; SymbolDisplay.getSymbolModifiers = getSymbolModifiers; // TODO(drosen): Currently completion entry details passes the SemanticMeaning.All instead of using semanticMeaning of location function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, enclosingDeclaration, location, semanticMeaning, alias) { + var _a; if (semanticMeaning === void 0) { semanticMeaning = ts.getMeaningFromLocation(location); } var displayParts = []; var documentation = []; @@ -130202,14 +135051,14 @@ var ts; var symbolFlags = ts.getCombinedLocalAndExportSymbolFlags(symbol); var symbolKind = semanticMeaning & 1 /* Value */ ? getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) : "" /* unknown */; var hasAddedSymbolInfo = false; - var isThisExpression = location.kind === 107 /* ThisKeyword */ && ts.isInExpressionContext(location); + var isThisExpression = location.kind === 108 /* ThisKeyword */ && ts.isInExpressionContext(location); var type; var printer; var documentationFromAlias; var tagsFromAlias; var hasMultipleSignatures = false; - if (location.kind === 107 /* ThisKeyword */ && !isThisExpression) { - return { displayParts: [ts.keywordPart(107 /* ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* primitiveType */, tags: undefined }; + if (location.kind === 108 /* ThisKeyword */ && !isThisExpression) { + return { displayParts: [ts.keywordPart(108 /* ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* 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 */) { @@ -130218,8 +135067,8 @@ var ts; symbolKind = "property" /* memberVariableElement */; } var signature = void 0; - type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol.exportSymbol || symbol, location); - if (location.parent && location.parent.kind === 201 /* PropertyAccessExpression */) { + type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); + if (location.parent && location.parent.kind === 203 /* 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)) { @@ -130239,9 +135088,9 @@ var ts; } if (callExpressionLike) { signature = typeChecker.getResolvedSignature(callExpressionLike); // TODO: GH#18217 - var useConstructSignatures = callExpressionLike.kind === 204 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 105 /* SuperKeyword */); + var useConstructSignatures = callExpressionLike.kind === 206 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 106 /* SuperKeyword */); var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); - if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { + if (signature && !ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { // Get the first signature if there is one -- allSignatures may contain // either the original signature or its target, so check for either signature = allSignatures.length ? allSignatures[0] : undefined; @@ -130258,10 +135107,10 @@ var ts; displayParts.push(ts.spacePart()); if (useConstructSignatures) { if (signature.flags & 4 /* Abstract */) { - displayParts.push(ts.keywordPart(125 /* AbstractKeyword */)); + displayParts.push(ts.keywordPart(126 /* AbstractKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(102 /* NewKeyword */)); + displayParts.push(ts.keywordPart(103 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -130286,10 +135135,10 @@ var ts; } if (useConstructSignatures) { if (signature.flags & 4 /* Abstract */) { - displayParts.push(ts.keywordPart(125 /* AbstractKeyword */)); + displayParts.push(ts.keywordPart(126 /* AbstractKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(102 /* NewKeyword */)); + displayParts.push(ts.keywordPart(103 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addSignatureDisplayParts(signature, allSignatures, 262144 /* WriteArrowStyleSignature */); @@ -130303,32 +135152,34 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* Accessor */)) || // name of function declaration - (location.kind === 132 /* ConstructorKeyword */ && location.parent.kind === 166 /* Constructor */)) { // At constructor keyword of constructor declaration + (location.kind === 133 /* ConstructorKeyword */ && location.parent.kind === 168 /* 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 === 132 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); + return declaration === (location.kind === 133 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); }); if (locationIsSymbolDeclaration) { - var allSignatures = functionDeclaration_1.kind === 166 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration_1.kind === 168 /* 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 === 166 /* Constructor */) { + if (functionDeclaration_1.kind === 168 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = "constructor" /* constructorImplementationElement */; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 169 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 171 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } - addSignatureDisplayParts(signature, allSignatures); + if (signature) { + addSignatureDisplayParts(signature, allSignatures); + } hasAddedSymbolInfo = true; hasMultipleSignatures = allSignatures.length > 1; } @@ -130336,7 +135187,7 @@ var ts; } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { addAliasPrefixIfNecessary(); - if (ts.getDeclarationOfKind(symbol, 221 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 223 /* 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 @@ -130344,7 +135195,7 @@ var ts; } else { // Class declaration has name which is not local. - displayParts.push(ts.keywordPart(83 /* ClassKeyword */)); + displayParts.push(ts.keywordPart(84 /* ClassKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); @@ -130352,37 +135203,37 @@ var ts; } if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(117 /* InterfaceKeyword */)); + displayParts.push(ts.keywordPart(118 /* InterfaceKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if ((symbolFlags & 524288 /* TypeAlias */) && (semanticMeaning & 2 /* Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(149 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(150 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(62 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* EqualsToken */)); displayParts.push(ts.spacePart()); ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 8388608 /* InTypeAlias */)); } if (symbolFlags & 384 /* Enum */) { prefixNextMeaning(); if (ts.some(symbol.declarations, function (d) { return ts.isEnumDeclaration(d) && ts.isEnumConst(d); })) { - displayParts.push(ts.keywordPart(84 /* ConstKeyword */)); + displayParts.push(ts.keywordPart(85 /* ConstKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(91 /* EnumKeyword */)); + displayParts.push(ts.keywordPart(92 /* EnumKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536 /* Module */ && !isThisExpression) { prefixNextMeaning(); - var declaration = ts.getDeclarationOfKind(symbol, 256 /* ModuleDeclaration */); - var isNamespace = declaration && declaration.name && declaration.name.kind === 78 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 140 /* NamespaceKeyword */ : 139 /* ModuleKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 258 /* ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 79 /* Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 141 /* NamespaceKeyword */ : 140 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } @@ -130401,7 +135252,7 @@ var ts; } else { // Method/function type parameter - var decl = ts.getDeclarationOfKind(symbol, 159 /* TypeParameter */); + var decl = ts.getDeclarationOfKind(symbol, 161 /* TypeParameter */); if (decl === undefined) return ts.Debug.fail(); var declaration = decl.parent; @@ -130409,21 +135260,21 @@ var ts; if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); var signature = typeChecker.getSignatureFromDeclaration(declaration); // TODO: GH#18217 - if (declaration.kind === 170 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(102 /* NewKeyword */)); + if (declaration.kind === 172 /* ConstructSignature */) { + displayParts.push(ts.keywordPart(103 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 169 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 171 /* CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 254 /* TypeAliasDeclaration */) { + else if (declaration.kind === 256 /* TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path addInPrefix(); - displayParts.push(ts.keywordPart(149 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(150 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -130434,12 +135285,12 @@ var ts; if (symbolFlags & 8 /* EnumMember */) { symbolKind = "enum member" /* enumMemberElement */; addPrefixForAnyFunctionOrVar(symbol, "enum member"); - var declaration = symbol.declarations[0]; - if (declaration.kind === 291 /* EnumMember */) { + var declaration = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]; + if ((declaration === null || declaration === void 0 ? void 0 : declaration.kind) === 293 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(62 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* EqualsToken */)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(ts.getTextOfConstantValue(constantValue), typeof constantValue === "number" ? ts.SymbolDisplayPartKind.numericLiteral : ts.SymbolDisplayPartKind.stringLiteral)); } @@ -130465,37 +135316,39 @@ var ts; } else { documentationFromAlias = resolvedSymbol.getContextualDocumentationComment(resolvedNode, typeChecker); - tagsFromAlias = resolvedSymbol.getJsDocTags(); + tagsFromAlias = resolvedSymbol.getJsDocTags(typeChecker); } } } - switch (symbol.declarations[0].kind) { - case 259 /* NamespaceExportDeclaration */: - displayParts.push(ts.keywordPart(92 /* ExportKeyword */)); - displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(140 /* NamespaceKeyword */)); - break; - case 266 /* ExportAssignment */: - displayParts.push(ts.keywordPart(92 /* ExportKeyword */)); - displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 62 /* EqualsToken */ : 87 /* DefaultKeyword */)); - break; - case 270 /* ExportSpecifier */: - displayParts.push(ts.keywordPart(92 /* ExportKeyword */)); - break; - default: - displayParts.push(ts.keywordPart(99 /* ImportKeyword */)); + if (symbol.declarations) { + switch (symbol.declarations[0].kind) { + case 261 /* NamespaceExportDeclaration */: + displayParts.push(ts.keywordPart(93 /* ExportKeyword */)); + displayParts.push(ts.spacePart()); + displayParts.push(ts.keywordPart(141 /* NamespaceKeyword */)); + break; + case 268 /* ExportAssignment */: + displayParts.push(ts.keywordPart(93 /* ExportKeyword */)); + displayParts.push(ts.spacePart()); + displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 63 /* EqualsToken */ : 88 /* DefaultKeyword */)); + break; + case 272 /* ExportSpecifier */: + displayParts.push(ts.keywordPart(93 /* ExportKeyword */)); + break; + default: + displayParts.push(ts.keywordPart(100 /* ImportKeyword */)); + } } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 260 /* ImportEqualsDeclaration */) { + if (declaration.kind === 262 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(62 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(143 /* RequireKeyword */)); + displayParts.push(ts.keywordPart(144 /* RequireKeyword */)); displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); @@ -130504,7 +135357,7 @@ var ts; var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(62 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* EqualsToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -130518,7 +135371,7 @@ var ts; if (type) { if (isThisExpression) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(107 /* ThisKeyword */)); + displayParts.push(ts.keywordPart(108 /* ThisKeyword */)); } else { addPrefixForAnyFunctionOrVar(symbol, symbolKind); @@ -130576,10 +135429,10 @@ var ts; // 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 && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 297 /* SourceFile */; })) { - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 216 /* BinaryExpression */) { + if (symbol.parent && symbol.declarations && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 299 /* SourceFile */; })) { + for (var _i = 0, _b = symbol.declarations; _i < _b.length; _i++) { + var declaration = _b[_i]; + if (!declaration.parent || declaration.parent.kind !== 218 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -130587,7 +135440,7 @@ var ts; continue; } documentation = rhsSymbol.getDocumentationComment(typeChecker); - tags = rhsSymbol.getJsDocTags(); + tags = rhsSymbol.getJsDocTags(typeChecker); if (documentation.length > 0) { break; } @@ -130595,7 +135448,7 @@ var ts; } } if (tags.length === 0 && !hasMultipleSignatures) { - tags = symbol.getJsDocTags(); + tags = symbol.getJsDocTags(typeChecker); } if (documentation.length === 0 && documentationFromAlias) { documentation = documentationFromAlias; @@ -130624,7 +135477,7 @@ var ts; } function addInPrefix() { displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(100 /* InKeyword */)); + displayParts.push(ts.keywordPart(101 /* InKeyword */)); displayParts.push(ts.spacePart()); } function addFullSymbolName(symbolToDisplay, enclosingDeclaration) { @@ -130697,16 +135550,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 208 /* FunctionExpression */) { + if (declaration.kind === 210 /* FunctionExpression */) { return true; } - if (declaration.kind !== 249 /* VariableDeclaration */ && declaration.kind !== 251 /* FunctionDeclaration */) { + if (declaration.kind !== 251 /* VariableDeclaration */ && declaration.kind !== 253 /* 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 === 297 /* SourceFile */ || parent.kind === 257 /* ModuleBlock */) { + if (parent.kind === 299 /* SourceFile */ || parent.kind === 259 /* ModuleBlock */) { return false; } } @@ -130808,11 +135661,10 @@ var ts; /*@internal*/ function fixupCompilerOptions(options, diagnostics) { // Lazily create this value to fix module loading errors. - commandLineOptionsStringToEnum = commandLineOptionsStringToEnum || ts.filter(ts.optionDeclarations, function (o) { - return typeof o.type === "object" && !ts.forEachEntry(o.type, function (v) { return typeof v !== "number"; }); - }); + 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_8 = function (opt) { + var _loop_9 = function (opt) { if (!ts.hasProperty(options, opt.name)) { return "continue"; } @@ -130831,7 +135683,7 @@ var ts; }; for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) { var opt = commandLineOptionsStringToEnum_1[_i]; - _loop_8(opt); + _loop_9(opt); } return options; } @@ -130996,8 +135848,8 @@ var ts; function shouldRescanGreaterThanToken(node) { switch (node.kind) { case 33 /* GreaterThanEqualsToken */: - case 70 /* GreaterThanGreaterThanEqualsToken */: - case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanEqualsToken */: + case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: case 49 /* GreaterThanGreaterThanGreaterThanToken */: case 48 /* GreaterThanGreaterThanToken */: return true; @@ -131007,25 +135859,18 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 280 /* JsxAttribute */: - case 275 /* JsxOpeningElement */: - case 276 /* JsxClosingElement */: - case 274 /* JsxSelfClosingElement */: + case 282 /* JsxAttribute */: + case 277 /* JsxOpeningElement */: + case 278 /* JsxClosingElement */: + case 276 /* 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 === 78 /* Identifier */; + return ts.isKeyword(node.kind) || node.kind === 79 /* Identifier */; } } return false; } function shouldRescanJsxText(node) { - var isJSXText = ts.isJsxText(node); - if (isJSXText) { - var containingElement = ts.findAncestor(node.parent, function (p) { return ts.isJsxElement(p); }); - if (!containingElement) - return false; // should never happen - return !ts.isParenthesizedExpression(containingElement.parent); - } - return false; + return ts.isJsxText(node); } function shouldRescanSlashToken(container) { return container.kind === 13 /* RegularExpressionLiteral */; @@ -131038,7 +135883,7 @@ var ts; return node.parent && ts.isJsxAttribute(node.parent) && node.parent.initializer === node; } function startsWithSlashToken(t) { - return t === 43 /* SlashToken */ || t === 67 /* SlashEqualsToken */; + return t === 43 /* SlashToken */ || t === 68 /* SlashEqualsToken */; } function readTokenInfo(n) { ts.Debug.assert(isOnToken()); @@ -131122,7 +135967,7 @@ var ts; return scanner.scanJsxIdentifier(); case 5 /* RescanJsxText */: lastScanAction = 5 /* RescanJsxText */; - return scanner.reScanJsxToken(); + return scanner.reScanJsxToken(/* allowMultilineJsxText */ false); case 6 /* RescanJsxAttributeValue */: lastScanAction = 6 /* RescanJsxAttributeValue */; return scanner.reScanJsxAttributeValue(); @@ -131211,7 +136056,7 @@ var ts; (function (formatting) { function getAllRules() { var allTokens = []; - for (var token = 0 /* FirstToken */; token <= 156 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 158 /* LastToken */; token++) { if (token !== 1 /* EndOfFileToken */) { allTokens.push(token); } @@ -131226,27 +136071,27 @@ var ts; var anyToken = { tokens: allTokens, isSpecific: false }; var anyTokenIncludingMultilineComments = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens), [3 /* MultiLineCommentTrivia */])); var anyTokenIncludingEOF = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens), [1 /* EndOfFileToken */])); - var keywords = tokenRangeFromRange(80 /* FirstKeyword */, 156 /* LastKeyword */); - var binaryOperators = tokenRangeFromRange(29 /* FirstBinaryOperator */, 77 /* LastBinaryOperator */); - var binaryKeywordOperators = [100 /* InKeyword */, 101 /* InstanceOfKeyword */, 156 /* OfKeyword */, 126 /* AsKeyword */, 137 /* IsKeyword */]; + var keywords = tokenRangeFromRange(81 /* FirstKeyword */, 158 /* LastKeyword */); + var binaryOperators = tokenRangeFromRange(29 /* FirstBinaryOperator */, 78 /* LastBinaryOperator */); + var binaryKeywordOperators = [101 /* InKeyword */, 102 /* InstanceOfKeyword */, 158 /* OfKeyword */, 127 /* AsKeyword */, 138 /* IsKeyword */]; var unaryPrefixOperators = [45 /* PlusPlusToken */, 46 /* MinusMinusToken */, 54 /* TildeToken */, 53 /* ExclamationToken */]; var unaryPrefixExpressions = [ - 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 78 /* Identifier */, 20 /* OpenParenToken */, - 22 /* OpenBracketToken */, 18 /* OpenBraceToken */, 107 /* ThisKeyword */, 102 /* NewKeyword */ + 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 79 /* Identifier */, 20 /* OpenParenToken */, + 22 /* OpenBracketToken */, 18 /* OpenBraceToken */, 108 /* ThisKeyword */, 103 /* NewKeyword */ ]; - var unaryPreincrementExpressions = [78 /* Identifier */, 20 /* OpenParenToken */, 107 /* ThisKeyword */, 102 /* NewKeyword */]; - var unaryPostincrementExpressions = [78 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 102 /* NewKeyword */]; - var unaryPredecrementExpressions = [78 /* Identifier */, 20 /* OpenParenToken */, 107 /* ThisKeyword */, 102 /* NewKeyword */]; - var unaryPostdecrementExpressions = [78 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 102 /* 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([78 /* Identifier */], ts.typeKeywords); + var typeNames = __spreadArray([79 /* Identifier */], ts.typeKeywords); // 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([78 /* Identifier */, 3 /* MultiLineCommentTrivia */, 83 /* ClassKeyword */, 92 /* ExportKeyword */, 99 /* ImportKeyword */]); + var typeScriptOpenBraceLeftTokenRange = tokenRangeFrom([79 /* Identifier */, 3 /* MultiLineCommentTrivia */, 84 /* ClassKeyword */, 93 /* ExportKeyword */, 100 /* ImportKeyword */]); // Place a space before open brace in a control flow construct - var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 89 /* DoKeyword */, 110 /* TryKeyword */, 95 /* FinallyKeyword */, 90 /* ElseKeyword */]); + var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 90 /* DoKeyword */, 111 /* TryKeyword */, 96 /* FinallyKeyword */, 91 /* ElseKeyword */]); // These rules are higher in priority than user-configurable var highPriorityCommonRules = [ // Leave comments alone @@ -131261,7 +136106,7 @@ var ts; 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", 99 /* ImportKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 16 /* DeleteSpace */), + rule("NoSpaceBetweenImportParenInImportType", 100 /* ImportKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 16 /* DeleteSpace */), // Special handling of unary operators. // Prefix operators generally shouldn't have a space between // them and their target unary expression. @@ -131288,79 +136133,79 @@ var ts; rule("SpaceAfterCloseBrace", 19 /* CloseBraceToken */, anyTokenExcept(21 /* CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 4 /* 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 */, 90 /* ElseKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBetweenCloseBraceAndWhile", 19 /* CloseBraceToken */, 114 /* WhileKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + 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 */), // 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", 97 /* FunctionKeyword */, 41 /* AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 16 /* DeleteSpace */), - rule("SpaceAfterStarInGeneratorDeclaration", 41 /* AsteriskToken */, 78 /* Identifier */, [isFunctionDeclarationOrFunctionExpressionContext], 4 /* InsertSpace */), - rule("SpaceAfterFunctionInFuncDecl", 97 /* FunctionKeyword */, anyToken, [isFunctionDeclContext], 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 */), // Insert new line after { and before } in multi-line contexts. rule("NewLineAfterOpenBraceInBlockContext", 18 /* OpenBraceToken */, anyToken, [isMultilineBlockContext], 8 /* 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", [134 /* GetKeyword */, 146 /* SetKeyword */], 78 /* Identifier */, [isFunctionDeclContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenYieldKeywordAndStar", 124 /* YieldKeyword */, 41 /* AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 16 /* DeleteSpace */), - rule("SpaceBetweenYieldOrYieldStarAndOperand", [124 /* YieldKeyword */, 41 /* AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 4 /* InsertSpace */), - rule("NoSpaceBetweenReturnAndSemicolon", 104 /* ReturnKeyword */, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("SpaceAfterCertainKeywords", [112 /* VarKeyword */, 108 /* ThrowKeyword */, 102 /* NewKeyword */, 88 /* DeleteKeyword */, 104 /* ReturnKeyword */, 111 /* TypeOfKeyword */, 130 /* AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceAfterLetConstInVariableDeclaration", [118 /* LetKeyword */, 84 /* ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 4 /* InsertSpace */), + rule("SpaceAfterGetSetInMember", [135 /* GetKeyword */, 147 /* 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 */, 131 /* 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 */), // 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", 113 /* VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 4 /* InsertSpace */), + rule("SpaceAfterVoidOperator", 114 /* VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 4 /* InsertSpace */), // Async-await - rule("SpaceBetweenAsyncAndOpenParen", 129 /* AsyncKeyword */, 20 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBetweenAsyncAndFunctionKeyword", 129 /* AsyncKeyword */, [97 /* FunctionKeyword */, 78 /* Identifier */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenAsyncAndOpenParen", 130 /* AsyncKeyword */, 20 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenAsyncAndFunctionKeyword", 130 /* AsyncKeyword */, [98 /* FunctionKeyword */, 79 /* Identifier */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Template string - rule("NoSpaceBetweenTagAndTemplateString", [78 /* Identifier */, 21 /* CloseParenToken */], [14 /* NoSubstitutionTemplateLiteral */, 15 /* TemplateHead */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBetweenTagAndTemplateString", [79 /* Identifier */, 21 /* CloseParenToken */], [14 /* NoSubstitutionTemplateLiteral */, 15 /* TemplateHead */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // JSX opening elements - rule("SpaceBeforeJsxAttribute", anyToken, 78 /* Identifier */, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + 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, 62 /* EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterEqualInJsxAttribute", 62 /* EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeEqualInJsxAttribute", anyToken, 63 /* EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterEqualInJsxAttribute", 63 /* EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // TypeScript-specific rules // Use of module as a function call. e.g.: import m2 = module("m2"); - rule("NoSpaceAfterModuleImport", [139 /* ModuleKeyword */, 143 /* RequireKeyword */], 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterModuleImport", [140 /* ModuleKeyword */, 144 /* RequireKeyword */], 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Add a space around certain TypeScript keywords rule("SpaceAfterCertainTypeScriptKeywords", [ - 125 /* AbstractKeyword */, - 83 /* ClassKeyword */, - 133 /* DeclareKeyword */, - 87 /* DefaultKeyword */, - 91 /* EnumKeyword */, - 92 /* ExportKeyword */, - 93 /* ExtendsKeyword */, - 134 /* GetKeyword */, - 116 /* ImplementsKeyword */, - 99 /* ImportKeyword */, - 117 /* InterfaceKeyword */, - 139 /* ModuleKeyword */, - 140 /* NamespaceKeyword */, - 120 /* PrivateKeyword */, - 122 /* PublicKeyword */, - 121 /* ProtectedKeyword */, - 142 /* ReadonlyKeyword */, - 146 /* SetKeyword */, - 123 /* StaticKeyword */, - 149 /* TypeKeyword */, - 153 /* FromKeyword */, - 138 /* KeyOfKeyword */, - 135 /* InferKeyword */, + 126 /* AbstractKeyword */, + 84 /* ClassKeyword */, + 134 /* DeclareKeyword */, + 88 /* DefaultKeyword */, + 92 /* EnumKeyword */, + 93 /* ExportKeyword */, + 94 /* ExtendsKeyword */, + 135 /* GetKeyword */, + 117 /* ImplementsKeyword */, + 100 /* ImportKeyword */, + 118 /* InterfaceKeyword */, + 140 /* ModuleKeyword */, + 141 /* NamespaceKeyword */, + 121 /* PrivateKeyword */, + 123 /* PublicKeyword */, + 122 /* ProtectedKeyword */, + 143 /* ReadonlyKeyword */, + 147 /* SetKeyword */, + 124 /* StaticKeyword */, + 150 /* TypeKeyword */, + 154 /* FromKeyword */, + 139 /* KeyOfKeyword */, + 136 /* InferKeyword */, ], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [93 /* ExtendsKeyword */, 116 /* ImplementsKeyword */, 153 /* FromKeyword */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [94 /* ExtendsKeyword */, 117 /* ImplementsKeyword */, 154 /* FromKeyword */], [isNonJsxSameLineTokenContext], 4 /* 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 */), // Lambda expressions rule("SpaceBeforeArrow", anyToken, 38 /* EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), rule("SpaceAfterArrow", 38 /* EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Optional parameters and let args - rule("NoSpaceAfterEllipsis", 25 /* DotDotDotToken */, 78 /* Identifier */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterEllipsis", 25 /* DotDotDotToken */, 79 /* Identifier */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), rule("NoSpaceAfterOptionalParameters", 57 /* QuestionToken */, [21 /* CloseParenToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */), // Remove spaces in empty interface literals. e.g.: x: {} rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 16 /* DeleteSpace */), @@ -131371,38 +136216,38 @@ var ts; 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 */), // decorators - rule("SpaceBeforeAt", [21 /* CloseParenToken */, 78 /* Identifier */], 59 /* AtToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeAt", [21 /* CloseParenToken */, 79 /* Identifier */], 59 /* AtToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), rule("NoSpaceAfterAt", 59 /* AtToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Insert space after @ in decorator rule("SpaceAfterDecorator", anyToken, [ - 125 /* AbstractKeyword */, - 78 /* Identifier */, - 92 /* ExportKeyword */, - 87 /* DefaultKeyword */, - 83 /* ClassKeyword */, - 123 /* StaticKeyword */, - 122 /* PublicKeyword */, - 120 /* PrivateKeyword */, - 121 /* ProtectedKeyword */, - 134 /* GetKeyword */, - 146 /* SetKeyword */, + 126 /* AbstractKeyword */, + 79 /* Identifier */, + 93 /* ExportKeyword */, + 88 /* DefaultKeyword */, + 84 /* ClassKeyword */, + 124 /* StaticKeyword */, + 123 /* PublicKeyword */, + 121 /* PrivateKeyword */, + 122 /* ProtectedKeyword */, + 135 /* GetKeyword */, + 147 /* SetKeyword */, 22 /* OpenBracketToken */, 41 /* AsteriskToken */, ], [isEndOfDecoratorContextOnSameLine], 4 /* InsertSpace */), rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 53 /* ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterNewKeywordOnConstructorSignature", 102 /* NewKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterNewKeywordOnConstructorSignature", 103 /* NewKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 16 /* DeleteSpace */), rule("SpaceLessThanAndNonJSXTypeAnnotation", 29 /* LessThanToken */, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext], 4 /* 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", 132 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceAfterConstructor", 132 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterConstructor", 133 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceAfterConstructor", 133 /* 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 */), // Insert space after function keyword for anonymous functions - rule("SpaceAfterAnonymousFunctionKeyword", [97 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 4 /* InsertSpace */), - rule("NoSpaceAfterAnonymousFunctionKeyword", [97 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 16 /* DeleteSpace */), + 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 */), // 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 */), @@ -131471,16 +136316,16 @@ var ts; rule("SpaceBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), rule("NoSpaceBeforeComma", anyToken, 27 /* CommaToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // No space before and after indexer `x[]` - rule("NoSpaceBeforeOpenBracket", anyTokenExcept(129 /* AsyncKeyword */, 81 /* CaseKeyword */), 22 /* OpenBracketToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeOpenBracket", anyTokenExcept(130 /* 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 */), // Remove extra space between for and await - rule("SpaceBetweenForAndAwaitKeyword", 96 /* ForKeyword */, 130 /* AwaitKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenForAndAwaitKeyword", 97 /* ForKeyword */, 131 /* AwaitKeyword */, [isNonJsxSameLineTokenContext], 4 /* 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 */, 89 /* DoKeyword */, 90 /* ElseKeyword */, 81 /* CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 4 /* InsertSpace */), + rule("SpaceBetweenStatements", [21 /* CloseParenToken */, 90 /* DoKeyword */, 91 /* ElseKeyword */, 82 /* CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 4 /* InsertSpace */), // This low-pri rule takes care of "try {", "catch {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. - rule("SpaceAfterTryCatchFinally", [110 /* TryKeyword */, 82 /* CatchKeyword */, 95 /* FinallyKeyword */], 18 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceAfterTryCatchFinally", [111 /* TryKeyword */, 83 /* CatchKeyword */, 96 /* FinallyKeyword */], 18 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), ]; return __spreadArray(__spreadArray(__spreadArray([], highPriorityCommonRules), userConfigurableRules), lowPriorityCommonRules); } @@ -131539,51 +136384,51 @@ var ts; return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; }; } function isForContext(context) { - return context.contextNode.kind === 237 /* ForStatement */; + return context.contextNode.kind === 239 /* ForStatement */; } function isNotForContext(context) { return !isForContext(context); } function isBinaryOpContext(context) { switch (context.contextNode.kind) { - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return context.contextNode.operatorToken.kind !== 27 /* CommaToken */; - case 217 /* ConditionalExpression */: - case 184 /* ConditionalType */: - case 224 /* AsExpression */: - case 270 /* ExportSpecifier */: - case 265 /* ImportSpecifier */: - case 172 /* TypePredicate */: - case 182 /* UnionType */: - case 183 /* IntersectionType */: + case 219 /* ConditionalExpression */: + case 186 /* ConditionalType */: + case 226 /* AsExpression */: + case 272 /* ExportSpecifier */: + case 267 /* ImportSpecifier */: + case 174 /* TypePredicate */: + case 184 /* UnionType */: + case 185 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 198 /* BindingElement */: + case 200 /* BindingElement */: // equals in type X = ... // falls through - case 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: // equal in import a = module('a'); // falls through - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: // equal in let a = 0 // falls through - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: // equal in p = 0 // falls through - case 160 /* Parameter */: - case 291 /* EnumMember */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - return context.currentTokenSpan.kind === 62 /* EqualsToken */ || context.nextTokenSpan.kind === 62 /* EqualsToken */; + case 162 /* Parameter */: + case 293 /* EnumMember */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + return context.currentTokenSpan.kind === 63 /* EqualsToken */ || context.nextTokenSpan.kind === 63 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: // "in" keyword in [P in keyof T]: T[P] // falls through - case 159 /* TypeParameter */: - return context.currentTokenSpan.kind === 100 /* InKeyword */ || context.nextTokenSpan.kind === 100 /* InKeyword */ || context.currentTokenSpan.kind === 62 /* EqualsToken */ || context.nextTokenSpan.kind === 62 /* EqualsToken */; + case 161 /* TypeParameter */: + return context.currentTokenSpan.kind === 101 /* InKeyword */ || context.nextTokenSpan.kind === 101 /* InKeyword */ || context.currentTokenSpan.kind === 63 /* EqualsToken */ || context.nextTokenSpan.kind === 63 /* EqualsToken */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 239 /* ForOfStatement */: - return context.currentTokenSpan.kind === 156 /* OfKeyword */ || context.nextTokenSpan.kind === 156 /* OfKeyword */; + case 241 /* ForOfStatement */: + return context.currentTokenSpan.kind === 158 /* OfKeyword */ || context.nextTokenSpan.kind === 158 /* OfKeyword */; } return false; } @@ -131595,22 +136440,22 @@ var ts; } function isTypeAnnotationContext(context) { var contextKind = context.contextNode.kind; - return contextKind === 163 /* PropertyDeclaration */ || - contextKind === 162 /* PropertySignature */ || - contextKind === 160 /* Parameter */ || - contextKind === 249 /* VariableDeclaration */ || + return contextKind === 165 /* PropertyDeclaration */ || + contextKind === 164 /* PropertySignature */ || + contextKind === 162 /* Parameter */ || + contextKind === 251 /* VariableDeclaration */ || ts.isFunctionLikeKind(contextKind); } function isConditionalOperatorContext(context) { - return context.contextNode.kind === 217 /* ConditionalExpression */ || - context.contextNode.kind === 184 /* ConditionalType */; + return context.contextNode.kind === 219 /* ConditionalExpression */ || + context.contextNode.kind === 186 /* ConditionalType */; } function isSameLineTokenOrBeforeBlockContext(context) { return context.TokensAreOnSameLine() || isBeforeBlockContext(context); } function isBraceWrappedContext(context) { - return context.contextNode.kind === 196 /* ObjectBindingPattern */ || - context.contextNode.kind === 190 /* MappedType */ || + return context.contextNode.kind === 198 /* ObjectBindingPattern */ || + context.contextNode.kind === 192 /* MappedType */ || isSingleLineBlockContext(context); } // This check is done before an open brace in a control construct, a function, or a typescript block declaration @@ -131636,34 +136481,34 @@ var ts; return true; } switch (node.kind) { - case 230 /* Block */: - case 258 /* CaseBlock */: - case 200 /* ObjectLiteralExpression */: - case 257 /* ModuleBlock */: + case 232 /* Block */: + case 260 /* CaseBlock */: + case 202 /* ObjectLiteralExpression */: + case 259 /* ModuleBlock */: return true; } return false; } function isFunctionDeclContext(context) { switch (context.contextNode.kind) { - case 251 /* FunctionDeclaration */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 253 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: // falls through - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: // case SyntaxKind.MethodSignature: // falls through - case 169 /* CallSignature */: - case 208 /* FunctionExpression */: - case 166 /* Constructor */: - case 209 /* ArrowFunction */: + case 171 /* CallSignature */: + case 210 /* FunctionExpression */: + case 168 /* Constructor */: + case 211 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: // falls through - case 253 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one + case 255 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one return true; } return false; @@ -131672,40 +136517,40 @@ var ts; return !isFunctionDeclContext(context); } function isFunctionDeclarationOrFunctionExpressionContext(context) { - return context.contextNode.kind === 251 /* FunctionDeclaration */ || context.contextNode.kind === 208 /* FunctionExpression */; + return context.contextNode.kind === 253 /* FunctionDeclaration */ || context.contextNode.kind === 210 /* FunctionExpression */; } function isTypeScriptDeclWithBlockContext(context) { return nodeIsTypeScriptDeclWithBlockContext(context.contextNode); } function nodeIsTypeScriptDeclWithBlockContext(node) { switch (node.kind) { - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - case 177 /* TypeLiteral */: - case 256 /* ModuleDeclaration */: - case 267 /* ExportDeclaration */: - case 268 /* NamedExports */: - case 261 /* ImportDeclaration */: - case 264 /* NamedImports */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: + case 257 /* EnumDeclaration */: + case 179 /* TypeLiteral */: + case 258 /* ModuleDeclaration */: + case 269 /* ExportDeclaration */: + case 270 /* NamedExports */: + case 263 /* ImportDeclaration */: + case 266 /* NamedImports */: return true; } return false; } function isAfterCodeBlockContext(context) { switch (context.currentTokenParent.kind) { - case 252 /* ClassDeclaration */: - case 256 /* ModuleDeclaration */: - case 255 /* EnumDeclaration */: - case 287 /* CatchClause */: - case 257 /* ModuleBlock */: - case 244 /* SwitchStatement */: + case 254 /* ClassDeclaration */: + case 258 /* ModuleDeclaration */: + case 257 /* EnumDeclaration */: + case 289 /* CatchClause */: + case 259 /* ModuleBlock */: + case 246 /* SwitchStatement */: return true; - case 230 /* Block */: { + case 232 /* 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 !== 209 /* ArrowFunction */ && blockParent.kind !== 208 /* FunctionExpression */) { + if (!blockParent || blockParent.kind !== 211 /* ArrowFunction */ && blockParent.kind !== 210 /* FunctionExpression */) { return true; } } @@ -131714,32 +136559,32 @@ var ts; } function isControlDeclContext(context) { switch (context.contextNode.kind) { - case 234 /* IfStatement */: - case 244 /* SwitchStatement */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 236 /* WhileStatement */: - case 247 /* TryStatement */: - case 235 /* DoStatement */: - case 243 /* WithStatement */: + case 236 /* IfStatement */: + case 246 /* SwitchStatement */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 238 /* WhileStatement */: + case 249 /* TryStatement */: + case 237 /* DoStatement */: + case 245 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: // falls through - case 287 /* CatchClause */: + case 289 /* CatchClause */: return true; default: return false; } } function isObjectContext(context) { - return context.contextNode.kind === 200 /* ObjectLiteralExpression */; + return context.contextNode.kind === 202 /* ObjectLiteralExpression */; } function isFunctionCallContext(context) { - return context.contextNode.kind === 203 /* CallExpression */; + return context.contextNode.kind === 205 /* CallExpression */; } function isNewContext(context) { - return context.contextNode.kind === 204 /* NewExpression */; + return context.contextNode.kind === 206 /* NewExpression */; } function isFunctionCallOrNewContext(context) { return isFunctionCallContext(context) || isNewContext(context); @@ -131754,10 +136599,10 @@ var ts; return context.nextTokenSpan.kind !== 21 /* CloseParenToken */; } function isArrowFunctionContext(context) { - return context.contextNode.kind === 209 /* ArrowFunction */; + return context.contextNode.kind === 211 /* ArrowFunction */; } function isImportTypeContext(context) { - return context.contextNode.kind === 195 /* ImportType */; + return context.contextNode.kind === 197 /* ImportType */; } function isNonJsxSameLineTokenContext(context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 11 /* JsxText */; @@ -131766,19 +136611,19 @@ var ts; return context.contextNode.kind !== 11 /* JsxText */; } function isNonJsxElementOrFragmentContext(context) { - return context.contextNode.kind !== 273 /* JsxElement */ && context.contextNode.kind !== 277 /* JsxFragment */; + return context.contextNode.kind !== 275 /* JsxElement */ && context.contextNode.kind !== 279 /* JsxFragment */; } function isJsxExpressionContext(context) { - return context.contextNode.kind === 283 /* JsxExpression */ || context.contextNode.kind === 282 /* JsxSpreadAttribute */; + return context.contextNode.kind === 285 /* JsxExpression */ || context.contextNode.kind === 284 /* JsxSpreadAttribute */; } function isNextTokenParentJsxAttribute(context) { - return context.nextTokenParent.kind === 280 /* JsxAttribute */; + return context.nextTokenParent.kind === 282 /* JsxAttribute */; } function isJsxAttributeContext(context) { - return context.contextNode.kind === 280 /* JsxAttribute */; + return context.contextNode.kind === 282 /* JsxAttribute */; } function isJsxSelfClosingElementContext(context) { - return context.contextNode.kind === 274 /* JsxSelfClosingElement */; + return context.contextNode.kind === 276 /* JsxSelfClosingElement */; } function isNotBeforeBlockInFunctionDeclarationContext(context) { return !isFunctionDeclContext(context) && !isBeforeBlockContext(context); @@ -131793,45 +136638,45 @@ var ts; while (ts.isExpressionNode(node)) { node = node.parent; } - return node.kind === 161 /* Decorator */; + return node.kind === 163 /* Decorator */; } function isStartOfVariableDeclarationList(context) { - return context.currentTokenParent.kind === 250 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 252 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; } function isNotFormatOnEnter(context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; } function isModuleDeclContext(context) { - return context.contextNode.kind === 256 /* ModuleDeclaration */; + return context.contextNode.kind === 258 /* ModuleDeclaration */; } function isObjectTypeContext(context) { - return context.contextNode.kind === 177 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 179 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; } function isConstructorSignatureContext(context) { - return context.contextNode.kind === 170 /* ConstructSignature */; + return context.contextNode.kind === 172 /* ConstructSignature */; } function isTypeArgumentOrParameterOrAssertion(token, parent) { if (token.kind !== 29 /* LessThanToken */ && token.kind !== 31 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 173 /* TypeReference */: - case 206 /* TypeAssertionExpression */: - case 254 /* TypeAliasDeclaration */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 203 /* CallExpression */: - case 204 /* NewExpression */: - case 223 /* ExpressionWithTypeArguments */: + case 175 /* TypeReference */: + case 208 /* TypeAssertionExpression */: + case 256 /* TypeAliasDeclaration */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: + case 225 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -131842,28 +136687,28 @@ var ts; isTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); } function isTypeAssertionContext(context) { - return context.contextNode.kind === 206 /* TypeAssertionExpression */; + return context.contextNode.kind === 208 /* TypeAssertionExpression */; } function isVoidOpContext(context) { - return context.currentTokenSpan.kind === 113 /* VoidKeyword */ && context.currentTokenParent.kind === 212 /* VoidExpression */; + return context.currentTokenSpan.kind === 114 /* VoidKeyword */ && context.currentTokenParent.kind === 214 /* VoidExpression */; } function isYieldOrYieldStarWithOperand(context) { - return context.contextNode.kind === 219 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 221 /* YieldExpression */ && context.contextNode.expression !== undefined; } function isNonNullAssertionContext(context) { - return context.contextNode.kind === 225 /* NonNullExpression */; + return context.contextNode.kind === 227 /* NonNullExpression */; } function isNotStatementConditionContext(context) { return !isStatementConditionContext(context); } function isStatementConditionContext(context) { switch (context.contextNode.kind) { - case 234 /* IfStatement */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: + case 236 /* IfStatement */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: return true; default: return false; @@ -131888,12 +136733,12 @@ var ts; return nextTokenKind === 19 /* CloseBraceToken */ || nextTokenKind === 1 /* EndOfFileToken */; } - if (nextTokenKind === 229 /* SemicolonClassElement */ || + if (nextTokenKind === 231 /* SemicolonClassElement */ || nextTokenKind === 26 /* SemicolonToken */) { return false; } - if (context.contextNode.kind === 253 /* InterfaceDeclaration */ || - context.contextNode.kind === 254 /* TypeAliasDeclaration */) { + if (context.contextNode.kind === 255 /* InterfaceDeclaration */ || + context.contextNode.kind === 256 /* TypeAliasDeclaration */) { // Can’t remove semicolon after `foo`; it would parse as a method declaration: // // interface I { @@ -131907,9 +136752,9 @@ var ts; if (ts.isPropertyDeclaration(context.currentTokenParent)) { return !context.currentTokenParent.initializer; } - return context.currentTokenParent.kind !== 237 /* ForStatement */ - && context.currentTokenParent.kind !== 231 /* EmptyStatement */ - && context.currentTokenParent.kind !== 229 /* SemicolonClassElement */ + return context.currentTokenParent.kind !== 239 /* ForStatement */ + && context.currentTokenParent.kind !== 233 /* EmptyStatement */ + && context.currentTokenParent.kind !== 231 /* SemicolonClassElement */ && nextTokenKind !== 22 /* OpenBracketToken */ && nextTokenKind !== 20 /* OpenParenToken */ && nextTokenKind !== 39 /* PlusToken */ @@ -131917,7 +136762,7 @@ var ts; && nextTokenKind !== 43 /* SlashToken */ && nextTokenKind !== 13 /* RegularExpressionLiteral */ && nextTokenKind !== 27 /* CommaToken */ - && nextTokenKind !== 218 /* TemplateExpression */ + && nextTokenKind !== 220 /* TemplateExpression */ && nextTokenKind !== 15 /* TemplateHead */ && nextTokenKind !== 14 /* NoSubstitutionTemplateLiteral */ && nextTokenKind !== 24 /* DotToken */; @@ -132008,12 +136853,12 @@ var ts; return map; } function getRuleBucketIndex(row, column) { - ts.Debug.assert(row <= 156 /* LastKeyword */ && column <= 156 /* LastKeyword */, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 158 /* LastKeyword */ && column <= 158 /* LastKeyword */, "Must compute formatting context from tokens"); return (row * mapRowLength) + column; } var maskBitSize = 5; var mask = 31; // MaskBitSize bits - var mapRowLength = 156 /* LastToken */ + 1; + var mapRowLength = 158 /* LastToken */ + 1; var RulesPosition; (function (RulesPosition) { RulesPosition[RulesPosition["StopRulesSpecific"] = 0] = "StopRulesSpecific"; @@ -132201,17 +137046,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 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: var body = parent.body; - return !!body && body.kind === 257 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 297 /* SourceFile */: - case 230 /* Block */: - case 257 /* ModuleBlock */: + return !!body && body.kind === 259 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 299 /* SourceFile */: + case 232 /* Block */: + case 259 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -132365,14 +137210,17 @@ var ts; processNode(enclosingNode, enclosingNode, startLine, undecoratedStartLine, initialIndentation, delta); } if (!formattingScanner.isOnToken()) { + var indentation = formatting.SmartIndenter.nodeWillIndentChild(options, enclosingNode, /*child*/ undefined, sourceFile, /*indentByDefault*/ false) + ? initialIndentation + options.indentSize + : initialIndentation; var leadingTrivia = formattingScanner.getCurrentLeadingTrivia(); if (leadingTrivia) { - indentTriviaItems(leadingTrivia, initialIndentation, /*indentNextTokenOrTrivia*/ false, function (item) { return processRange(item, sourceFile.getLineAndCharacterOfPosition(item.pos), enclosingNode, enclosingNode, /*dynamicIndentation*/ undefined); }); - if (options.trimTrailingWhitespace !== false) { - trimTrailingWhitespacesForRemainingRange(); - } + indentTriviaItems(leadingTrivia, indentation, /*indentNextTokenOrTrivia*/ false, function (item) { return processRange(item, sourceFile.getLineAndCharacterOfPosition(item.pos), enclosingNode, enclosingNode, /*dynamicIndentation*/ undefined); }); } } + if (options.trimTrailingWhitespace !== false) { + trimTrailingWhitespacesForRemainingRange(); + } return edits; // local functions /** Tries to compute the indentation for a list element. @@ -132419,10 +137267,9 @@ var ts; // - we need to get the indentation on last line and the delta of parent return { indentation: indentationOnLastIndentedLine, delta: parentDynamicIndentation.getDelta(node) }; } - else if (formatting.SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement(parent, node, startLine, sourceFile)) { - return { indentation: parentDynamicIndentation.getIndentation(), delta: delta }; - } - else if (formatting.SmartIndenter.argumentStartsOnSameLineAsPreviousArgument(parent, node, startLine, sourceFile)) { + else if (formatting.SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement(parent, node, startLine, sourceFile) || + formatting.SmartIndenter.childIsUnindentedBranchOfConditionalExpression(parent, node, startLine, sourceFile) || + formatting.SmartIndenter.argumentStartsOnSameLineAsPreviousArgument(parent, node, startLine, sourceFile)) { return { indentation: parentDynamicIndentation.getIndentation(), delta: delta }; } else { @@ -132438,19 +137285,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 252 /* ClassDeclaration */: return 83 /* ClassKeyword */; - case 253 /* InterfaceDeclaration */: return 117 /* InterfaceKeyword */; - case 251 /* FunctionDeclaration */: return 97 /* FunctionKeyword */; - case 255 /* EnumDeclaration */: return 255 /* EnumDeclaration */; - case 167 /* GetAccessor */: return 134 /* GetKeyword */; - case 168 /* SetAccessor */: return 146 /* SetKeyword */; - case 165 /* MethodDeclaration */: + case 254 /* ClassDeclaration */: return 84 /* ClassKeyword */; + case 255 /* InterfaceDeclaration */: return 118 /* InterfaceKeyword */; + case 253 /* FunctionDeclaration */: return 98 /* FunctionKeyword */; + case 257 /* EnumDeclaration */: return 257 /* EnumDeclaration */; + case 169 /* GetAccessor */: return 135 /* GetKeyword */; + case 170 /* SetAccessor */: return 147 /* SetKeyword */; + case 167 /* MethodDeclaration */: if (node.asteriskToken) { return 41 /* AsteriskToken */; } // falls through - case 163 /* PropertyDeclaration */: - case 160 /* Parameter */: + case 165 /* PropertyDeclaration */: + case 162 /* Parameter */: var name = ts.getNameOfDeclaration(node); if (name) { return name.kind; @@ -132500,22 +137347,23 @@ var ts; case 18 /* OpenBraceToken */: case 19 /* CloseBraceToken */: case 21 /* CloseParenToken */: - case 90 /* ElseKeyword */: - case 114 /* WhileKeyword */: + case 91 /* ElseKeyword */: + case 115 /* WhileKeyword */: case 59 /* AtToken */: return false; case 43 /* SlashToken */: case 31 /* GreaterThanToken */: switch (container.kind) { - case 275 /* JsxOpeningElement */: - case 276 /* JsxClosingElement */: - case 274 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: + case 278 /* JsxClosingElement */: + case 276 /* JsxSelfClosingElement */: + case 225 /* ExpressionWithTypeArguments */: return false; } break; case 22 /* OpenBracketToken */: case 23 /* CloseBracketToken */: - if (container.kind !== 190 /* MappedType */) { + if (container.kind !== 192 /* MappedType */) { return false; } break; @@ -132560,11 +137408,6 @@ var ts; if (tokenInfo.token.end > node.end) { break; } - if (node.kind === 11 /* JsxText */) { - // Intentation rules for jsx text are handled by `indentMultilineCommentOrJsxText` inside `processChildNode`; just fastforward past it here - formattingScanner.advance(); - continue; - } consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation, node); } if (!node.parent && formattingScanner.isOnEOF()) { @@ -132623,27 +137466,11 @@ var ts; return inheritedIndentation; } } - var effectiveParentStartLine = child.kind === 161 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 163 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); - if (child.kind === 11 /* JsxText */) { - var range = { pos: child.getStart(), end: child.getEnd() }; - if (range.pos !== range.end) { // don't indent zero-width jsx text - var siblings = parent.getChildren(sourceFile); - var currentIndex = ts.findIndex(siblings, function (arg) { return arg.pos === child.pos; }); - var previousNode = siblings[currentIndex - 1]; - if (previousNode) { - // The jsx text needs no indentation whatsoever if it ends on the same line the previous sibling ends on - if (sourceFile.getLineAndCharacterOfPosition(range.end).line !== sourceFile.getLineAndCharacterOfPosition(previousNode.end).line) { - // The first line is (already) "indented" if the text starts on the same line as the previous sibling element ends on - var firstLineIsIndented = sourceFile.getLineAndCharacterOfPosition(range.pos).line === sourceFile.getLineAndCharacterOfPosition(previousNode.end).line; - indentMultilineCommentOrJsxText(range, childIndentation.indentation, firstLineIsIndented, /*indentFinalLine*/ false, /*jsxStyle*/ true); - } - } - } - } childContextNode = node; - if (isFirstListItem && parent.kind === 199 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 201 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -132767,7 +137594,7 @@ var ts; switch (triviaItem.kind) { case 3 /* MultiLineCommentTrivia */: if (triviaInRange) { - indentMultilineCommentOrJsxText(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia); + indentMultilineComment(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia); } indentNextTokenOrTrivia = false; break; @@ -132884,7 +137711,7 @@ var ts; function indentationIsDifferent(indentationString, startLinePosition) { return indentationString !== sourceFile.text.substr(startLinePosition, indentationString.length); } - function indentMultilineCommentOrJsxText(commentRange, indentation, firstLineIsIndented, indentFinalLine, jsxTextStyleIndent) { + function indentMultilineComment(commentRange, indentation, firstLineIsIndented, indentFinalLine) { if (indentFinalLine === void 0) { indentFinalLine = true; } // split comment in lines var startLine = sourceFile.getLineAndCharacterOfPosition(commentRange.pos).line; @@ -132922,13 +137749,6 @@ var ts; var nonWhitespaceCharacterAndColumn = i === 0 ? nonWhitespaceColumnInFirstPart : formatting.SmartIndenter.findFirstNonWhitespaceCharacterAndColumn(parts[i].pos, parts[i].end, sourceFile, options); - if (jsxTextStyleIndent) { - // skip adding indentation to blank lines - if (ts.isLineBreak(sourceFile.text.charCodeAt(ts.getStartPositionOfLine(startLine, sourceFile)))) - continue; - // reset delta on every line - delta = indentation - nonWhitespaceCharacterAndColumn.column; - } var newIndentation = nonWhitespaceCharacterAndColumn.column + delta; if (newIndentation > 0) { var indentationString = getIndentationString(newIndentation, options); @@ -133083,12 +137903,12 @@ var ts; formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment; function getOpenTokenForList(node, list) { switch (node.kind) { - case 166 /* Constructor */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 209 /* ArrowFunction */: + case 168 /* Constructor */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 211 /* ArrowFunction */: if (node.typeParameters === list) { return 29 /* LessThanToken */; } @@ -133096,8 +137916,8 @@ var ts; return 20 /* OpenParenToken */; } break; - case 203 /* CallExpression */: - case 204 /* NewExpression */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: if (node.typeArguments === list) { return 29 /* LessThanToken */; } @@ -133105,12 +137925,12 @@ var ts; return 20 /* OpenParenToken */; } break; - case 173 /* TypeReference */: + case 175 /* TypeReference */: if (node.typeArguments === list) { return 29 /* LessThanToken */; } break; - case 177 /* TypeLiteral */: + case 179 /* TypeLiteral */: return 18 /* OpenBraceToken */; } return 0 /* Unknown */; @@ -133228,7 +138048,7 @@ var ts; if (options.indentStyle === ts.IndentStyle.Block) { return getBlockIndent(sourceFile, position, options); } - if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 216 /* BinaryExpression */) { + if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 218 /* 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 */) { @@ -133311,6 +138131,7 @@ var ts; } SmartIndenter.getBaseIndentation = getBaseIndentation; function getIndentationForNodeWorker(current, currentStart, ignoreActualIndentationRange, indentationDelta, sourceFile, isNextChild, options) { + var _a; var parent = current.parent; // Walk up the tree and collect indentation for parent-child node pairs. Indentation is not added if // * parent and child nodes start on the same line, or @@ -133326,7 +138147,25 @@ var ts; childStartsOnTheSameLineWithElseInIfStatement(parent, current, currentStart.line, sourceFile); if (useActualIndentation) { // check if current node is a list item - if yes, take indentation from it - var actualIndentation = getActualIndentationForListItem(current, sourceFile, options, !parentAndChildShareLine); + var firstListChild = (_a = getContainingList(current, sourceFile)) === null || _a === void 0 ? void 0 : _a[0]; + // A list indents its children if the children begin on a later line than the list itself: + // + // f1( L0 - List start + // { L1 - First child start: indented, along with all other children + // prop: 0 + // }, + // { + // prop: 1 + // } + // ) + // + // f2({ L0 - List start and first child start: children are not indented. + // prop: 0 Object properties are indented only one level, because the list + // }, { itself contributes nothing. + // prop: 1 L3 - The indentation of the second object literal is best understood by + // }) 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 */) { return actualIndentation + indentationDelta; } @@ -133382,7 +138221,7 @@ 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 === 297 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 299 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -133430,8 +138269,8 @@ var ts; } SmartIndenter.isArgumentAndStartLineOverlapsExpressionBeingCalled = isArgumentAndStartLineOverlapsExpressionBeingCalled; function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 234 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 90 /* ElseKeyword */, sourceFile); + if (parent.kind === 236 /* IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 91 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -133439,6 +138278,49 @@ var ts; return false; } SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement = childStartsOnTheSameLineWithElseInIfStatement; + // A multiline conditional typically increases the indentation of its whenTrue and whenFalse children: + // + // condition + // ? whenTrue + // : whenFalse; + // + // However, that indentation does not apply if the subexpressions themselves span multiple lines, + // applying their own indentation: + // + // (() => { + // return complexCalculationForCondition(); + // })() ? { + // whenTrue: 'multiline object literal' + // } : ( + // whenFalse('multiline parenthesized expression') + // ); + // + // In these cases, we must discard the indentation increase that would otherwise be applied to the + // whenTrue and whenFalse children to avoid double-indenting their contents. To identify this scenario, + // we check for the whenTrue branch beginning on the line that the condition ends, and the whenFalse + // branch beginning on the line that the whenTrue branch ends. + function childIsUnindentedBranchOfConditionalExpression(parent, child, childStartLine, sourceFile) { + if (ts.isConditionalExpression(parent) && (child === parent.whenTrue || child === parent.whenFalse)) { + var conditionEndLine = ts.getLineAndCharacterOfPosition(sourceFile, parent.condition.end).line; + if (child === parent.whenTrue) { + return childStartLine === conditionEndLine; + } + else { + // On the whenFalse side, we have to look at the whenTrue side, because if that one was + // indented, whenFalse must also be indented: + // + // const y = true + // ? 1 : ( L1: whenTrue indented because it's on a new line + // 0 L2: indented two stops, one because whenTrue was indented + // ); and one because of the parentheses spanning multiple lines + var trueStartLine = getStartLineAndCharacterForNode(parent.whenTrue, sourceFile).line; + var trueEndLine = ts.getLineAndCharacterOfPosition(sourceFile, parent.whenTrue.end).line; + return conditionEndLine === trueStartLine && trueEndLine === childStartLine; + } + } + return false; + } + SmartIndenter.childIsUnindentedBranchOfConditionalExpression = childIsUnindentedBranchOfConditionalExpression; function argumentStartsOnSameLineAsPreviousArgument(parent, child, childStartLine, sourceFile) { if (ts.isCallOrNewExpression(parent)) { if (!parent.arguments) @@ -133468,40 +138350,40 @@ var ts; } function getListByRange(start, end, node, sourceFile) { switch (node.kind) { - case 173 /* TypeReference */: + case 175 /* TypeReference */: return getList(node.typeArguments); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return getList(node.properties); - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return getList(node.elements); - case 177 /* TypeLiteral */: + case 179 /* TypeLiteral */: return getList(node.members); - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 169 /* CallSignature */: - case 166 /* Constructor */: - case 175 /* ConstructorType */: - case 170 /* ConstructSignature */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 171 /* CallSignature */: + case 168 /* Constructor */: + case 177 /* ConstructorType */: + case 172 /* ConstructSignature */: return getList(node.typeParameters) || getList(node.parameters); - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 330 /* JSDocTemplateTag */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 338 /* JSDocTemplateTag */: return getList(node.typeParameters); - case 204 /* NewExpression */: - case 203 /* CallExpression */: + case 206 /* NewExpression */: + case 205 /* CallExpression */: return getList(node.typeArguments) || getList(node.arguments); - case 250 /* VariableDeclarationList */: + case 252 /* VariableDeclarationList */: return getList(node.declarations); - case 264 /* NamedImports */: - case 268 /* NamedExports */: + case 266 /* NamedImports */: + case 270 /* NamedExports */: return getList(node.elements); - case 196 /* ObjectBindingPattern */: - case 197 /* ArrayBindingPattern */: + case 198 /* ObjectBindingPattern */: + case 199 /* ArrayBindingPattern */: return getList(node.elements); } function getList(list) { @@ -133524,7 +138406,7 @@ var ts; return findColumnForFirstNonWhitespaceCharacterInLine(sourceFile.getLineAndCharacterOfPosition(list.pos), sourceFile, options); } function getActualIndentationForListItem(node, sourceFile, options, listIndentsChild) { - if (node.parent && node.parent.kind === 250 /* VariableDeclarationList */) { + if (node.parent && node.parent.kind === 252 /* VariableDeclarationList */) { // VariableDeclarationList has no wrapping tokens return -1 /* Unknown */; } @@ -133597,94 +138479,94 @@ var ts; function nodeWillIndentChild(settings, parent, child, sourceFile, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 233 /* ExpressionStatement */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 199 /* ArrayLiteralExpression */: - case 230 /* Block */: - case 257 /* ModuleBlock */: - case 200 /* ObjectLiteralExpression */: - case 177 /* TypeLiteral */: - case 190 /* MappedType */: - case 179 /* TupleType */: - case 258 /* CaseBlock */: - case 285 /* DefaultClause */: - case 284 /* CaseClause */: - case 207 /* ParenthesizedExpression */: - case 201 /* PropertyAccessExpression */: - case 203 /* CallExpression */: - case 204 /* NewExpression */: - case 232 /* VariableStatement */: - case 266 /* ExportAssignment */: - case 242 /* ReturnStatement */: - case 217 /* ConditionalExpression */: - case 197 /* ArrayBindingPattern */: - case 196 /* ObjectBindingPattern */: - case 275 /* JsxOpeningElement */: - case 278 /* JsxOpeningFragment */: - case 274 /* JsxSelfClosingElement */: - case 283 /* JsxExpression */: - case 164 /* MethodSignature */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 160 /* Parameter */: - case 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 186 /* ParenthesizedType */: - case 205 /* TaggedTemplateExpression */: - case 213 /* AwaitExpression */: - case 268 /* NamedExports */: - case 264 /* NamedImports */: - case 270 /* ExportSpecifier */: - case 265 /* ImportSpecifier */: - case 163 /* PropertyDeclaration */: + case 235 /* ExpressionStatement */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: + case 257 /* EnumDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 201 /* ArrayLiteralExpression */: + case 232 /* Block */: + case 259 /* ModuleBlock */: + case 202 /* ObjectLiteralExpression */: + case 179 /* TypeLiteral */: + case 192 /* MappedType */: + case 181 /* TupleType */: + case 260 /* CaseBlock */: + case 287 /* DefaultClause */: + case 286 /* CaseClause */: + case 209 /* ParenthesizedExpression */: + case 203 /* PropertyAccessExpression */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: + case 234 /* VariableStatement */: + case 268 /* ExportAssignment */: + case 244 /* ReturnStatement */: + case 219 /* ConditionalExpression */: + case 199 /* ArrayBindingPattern */: + case 198 /* ObjectBindingPattern */: + case 277 /* JsxOpeningElement */: + case 280 /* JsxOpeningFragment */: + case 276 /* JsxSelfClosingElement */: + case 285 /* JsxExpression */: + case 166 /* MethodSignature */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 162 /* Parameter */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: + case 188 /* ParenthesizedType */: + case 207 /* TaggedTemplateExpression */: + case 215 /* AwaitExpression */: + case 270 /* NamedExports */: + case 266 /* NamedImports */: + case 272 /* ExportSpecifier */: + case 267 /* ImportSpecifier */: + case 165 /* PropertyDeclaration */: return true; - case 249 /* VariableDeclaration */: - case 288 /* PropertyAssignment */: - case 216 /* BinaryExpression */: - if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 200 /* ObjectLiteralExpression */) { // TODO: GH#18217 + case 251 /* VariableDeclaration */: + case 290 /* PropertyAssignment */: + case 218 /* BinaryExpression */: + if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 202 /* ObjectLiteralExpression */) { // TODO: GH#18217 return rangeIsOnOneLine(sourceFile, child); } - if (parent.kind !== 216 /* BinaryExpression */) { + if (parent.kind !== 218 /* BinaryExpression */) { return true; } break; - case 235 /* DoStatement */: - case 236 /* WhileStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 237 /* ForStatement */: - case 234 /* IfStatement */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - return childKind !== 230 /* Block */; - case 209 /* ArrowFunction */: - if (sourceFile && childKind === 207 /* ParenthesizedExpression */) { + case 237 /* DoStatement */: + case 238 /* WhileStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 239 /* ForStatement */: + case 236 /* IfStatement */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 167 /* MethodDeclaration */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + return childKind !== 232 /* Block */; + case 211 /* ArrowFunction */: + if (sourceFile && childKind === 209 /* ParenthesizedExpression */) { return rangeIsOnOneLine(sourceFile, child); } - return childKind !== 230 /* Block */; - case 267 /* ExportDeclaration */: - return childKind !== 268 /* NamedExports */; - case 261 /* ImportDeclaration */: - return childKind !== 262 /* ImportClause */ || - (!!child.namedBindings && child.namedBindings.kind !== 264 /* NamedImports */); - case 273 /* JsxElement */: - return childKind !== 276 /* JsxClosingElement */; - case 277 /* JsxFragment */: - return childKind !== 279 /* JsxClosingFragment */; - case 183 /* IntersectionType */: - case 182 /* UnionType */: - if (childKind === 177 /* TypeLiteral */ || childKind === 179 /* TupleType */) { + return childKind !== 232 /* Block */; + case 269 /* ExportDeclaration */: + return childKind !== 270 /* NamedExports */; + case 263 /* ImportDeclaration */: + return childKind !== 264 /* ImportClause */ || + (!!child.namedBindings && child.namedBindings.kind !== 266 /* NamedImports */); + case 275 /* JsxElement */: + return childKind !== 278 /* JsxClosingElement */; + case 279 /* JsxFragment */: + return childKind !== 281 /* JsxClosingFragment */; + case 185 /* IntersectionType */: + case 184 /* UnionType */: + if (childKind === 179 /* TypeLiteral */ || childKind === 181 /* TupleType */) { return false; } - // falls through + break; } // No explicit rule for given nodes so the result will follow the default value argument return indentByDefault; @@ -133692,11 +138574,11 @@ var ts; SmartIndenter.nodeWillIndentChild = nodeWillIndentChild; function isControlFlowEndingStatement(kind, parent) { switch (kind) { - case 242 /* ReturnStatement */: - case 246 /* ThrowStatement */: - case 240 /* ContinueStatement */: - case 241 /* BreakStatement */: - return parent.kind !== 230 /* Block */; + case 244 /* ReturnStatement */: + case 248 /* ThrowStatement */: + case 242 /* ContinueStatement */: + case 243 /* BreakStatement */: + return parent.kind !== 232 /* Block */; default: return false; } @@ -133804,7 +138686,9 @@ var ts; function getAdjustedRange(sourceFile, startNode, endNode, options) { return { pos: getAdjustedStartPosition(sourceFile, startNode, options), end: getAdjustedEndPosition(sourceFile, endNode, options) }; } - function getAdjustedStartPosition(sourceFile, node, options) { + function getAdjustedStartPosition(sourceFile, node, options, hasTrailingComment) { + var _a, _b; + if (hasTrailingComment === void 0) { hasTrailingComment = false; } var leadingTriviaOption = options.leadingTriviaOption; if (leadingTriviaOption === LeadingTriviaOption.Exclude) { return node.getStart(sourceFile); @@ -133835,6 +138719,15 @@ var ts; // when b is deleted - we delete it return leadingTriviaOption === LeadingTriviaOption.IncludeAll ? fullStart : start; } + // if node has a trailing comments, use comment end position as the text has already been included. + if (hasTrailingComment) { + // Check first for leading comments as if the node is the first import, we want to exclude the trivia; + // otherwise we get the trailing comments. + var comment = ((_a = ts.getLeadingCommentRanges(sourceFile.text, fullStart)) === null || _a === void 0 ? void 0 : _a[0]) || ((_b = ts.getTrailingCommentRanges(sourceFile.text, fullStart)) === null || _b === void 0 ? void 0 : _b[0]); + if (comment) { + return ts.skipTrivia(sourceFile.text, comment.end, /*stopAfterLineBreak*/ true, /*stopAtComments*/ true); + } + } // get start position of the line following the line that contains fullstart position // (but only if the fullstart isn't the very beginning of the file) var nextLineStart = fullStart > 0 ? 1 : 0; @@ -133843,6 +138736,35 @@ var ts; adjustedStartPosition = skipWhitespacesAndLineBreaks(sourceFile.text, adjustedStartPosition); return ts.getStartPositionOfLine(ts.getLineOfLocalPosition(sourceFile, adjustedStartPosition), sourceFile); } + /** Return the end position of a multiline comment of it is on another line; otherwise returns `undefined`; */ + function getEndPositionOfMultilineTrailingComment(sourceFile, node, options) { + var end = node.end; + var trailingTriviaOption = options.trailingTriviaOption; + if (trailingTriviaOption === TrailingTriviaOption.Include) { + // If the trailing comment is a multiline comment that extends to the next lines, + // return the end of the comment and track it for the next nodes to adjust. + var comments = ts.getTrailingCommentRanges(sourceFile.text, end); + if (comments) { + var nodeEndLine = ts.getLineOfLocalPosition(sourceFile, node.end); + for (var _i = 0, comments_2 = comments; _i < comments_2.length; _i++) { + 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) { + break; + } + // Get the end line of the comment and compare against the end line of the node. + // If the comment end line position and the multiline comment extends to multiple lines, + // then is safe to return the end position. + var commentEndLine = ts.getLineOfLocalPosition(sourceFile, comment.end); + if (commentEndLine > nodeEndLine) { + return ts.skipTrivia(sourceFile.text, comment.end, /*stopAfterLineBreak*/ true, /*stopAtComments*/ true); + } + } + } + } + return undefined; + } function getAdjustedEndPosition(sourceFile, node, options) { var _a; var end = node.end; @@ -133858,6 +138780,10 @@ var ts; } return end; } + var multilineEndPosition = getEndPositionOfMultilineTrailingComment(sourceFile, node, options); + if (multilineEndPosition) { + return multilineEndPosition; + } var newEnd = ts.skipTrivia(sourceFile.text, end, /*stopAfterLineBreak*/ true); return newEnd !== end && (trailingTriviaOption === TrailingTriviaOption.Include || ts.isLineBreak(sourceFile.text.charCodeAt(newEnd - 1))) ? newEnd @@ -133867,14 +138793,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 === 200 /* ObjectLiteralExpression */)); - } - function spaces(count) { - var s = ""; - for (var i = 0; i < count; i++) { - s += " "; - } - return s; + return !!candidate && !!node.parent && (candidate.kind === 27 /* CommaToken */ || (candidate.kind === 26 /* SemicolonToken */ && node.parent.kind === 202 /* ObjectLiteralExpression */)); } function isThisTypeAnnotatable(containingFunction) { return ts.isFunctionExpression(containingFunction) || ts.isFunctionDeclaration(containingFunction); @@ -133920,6 +138839,17 @@ var ts; if (options === void 0) { options = { leadingTriviaOption: LeadingTriviaOption.IncludeAll }; } this.deleteRange(sourceFile, getAdjustedRange(sourceFile, node, node, options)); }; + ChangeTracker.prototype.deleteNodes = function (sourceFile, nodes, options, hasTrailingComment) { + if (options === void 0) { options = { leadingTriviaOption: LeadingTriviaOption.IncludeAll }; } + // When deleting multiple nodes we need to track if the end position is including multiline trailing comments. + for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { + var node = nodes_1[_i]; + var pos = getAdjustedStartPosition(sourceFile, node, options, hasTrailingComment); + var end = getAdjustedEndPosition(sourceFile, node, options); + this.deleteRange(sourceFile, { pos: pos, end: end }); + hasTrailingComment = !!getEndPositionOfMultilineTrailingComment(sourceFile, node, options); + } + }; ChangeTracker.prototype.deleteModifier = function (sourceFile, modifier) { this.deleteRange(sourceFile, { pos: modifier.getStart(sourceFile), end: ts.skipTrivia(sourceFile.text, modifier.end, /*stopAfterLineBreak*/ true) }); }; @@ -133962,6 +138892,10 @@ var ts; if (options === void 0) { options = useNonAdjustedPositions; } this.replaceRangeWithNodes(sourceFile, getAdjustedRange(sourceFile, startNode, endNode, options), newNodes, options); }; + ChangeTracker.prototype.nodeHasTrailingComment = function (sourceFile, oldNode, configurableEnd) { + if (configurableEnd === void 0) { configurableEnd = useNonAdjustedPositions; } + return !!getEndPositionOfMultilineTrailingComment(sourceFile, oldNode, configurableEnd); + }; ChangeTracker.prototype.nextCommaToken = function (sourceFile, node) { var next = ts.findNextToken(node, node.parent, sourceFile); return next && next.kind === 27 /* CommaToken */ ? next : undefined; @@ -134066,7 +139000,7 @@ var ts; } } else { - endNode = (_a = (node.kind === 249 /* VariableDeclaration */ ? node.exclamationToken : node.questionToken)) !== null && _a !== void 0 ? _a : node.name; + endNode = (_a = (node.kind === 251 /* VariableDeclaration */ ? node.exclamationToken : node.questionToken)) !== null && _a !== void 0 ? _a : node.name; } this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " }); return true; @@ -134108,6 +139042,15 @@ var ts; this.insertNodeBefore(sourceFile, firstStatement, newStatement); } }; + ChangeTracker.prototype.insertNodeAtConstructorStartAfterSuperCall = function (sourceFile, ctr, newStatement) { + var superCallStatement = ts.find(ctr.body.statements, function (stmt) { return ts.isExpressionStatement(stmt) && ts.isSuperCall(stmt.expression); }); + if (!superCallStatement || !ctr.body.multiLine) { + this.replaceConstructorBody(sourceFile, ctr, __spreadArray(__spreadArray([], ctr.body.statements), [newStatement])); + } + else { + this.insertNodeAfter(sourceFile, superCallStatement, newStatement); + } + }; ChangeTracker.prototype.insertNodeAtConstructorEnd = function (sourceFile, ctr, newStatement) { var lastStatement = ts.lastOrUndefined(ctr.body.statements); if (!lastStatement || !ctr.body.multiLine) { @@ -134223,18 +139166,18 @@ var ts; }; ChangeTracker.prototype.getInsertNodeAfterOptionsWorker = function (node) { switch (node.kind) { - case 252 /* ClassDeclaration */: - case 256 /* ModuleDeclaration */: + case 254 /* ClassDeclaration */: + case 258 /* ModuleDeclaration */: return { prefix: this.newLineCharacter, suffix: this.newLineCharacter }; - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: case 10 /* StringLiteral */: - case 78 /* Identifier */: + case 79 /* Identifier */: return { prefix: ", " }; - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: return { suffix: "," + this.newLineCharacter }; - case 92 /* ExportKeyword */: + case 93 /* ExportKeyword */: return { prefix: " " }; - case 160 /* Parameter */: + case 162 /* Parameter */: return {}; default: ts.Debug.assert(ts.isStatement(node) || ts.isClassOrTypeElement(node)); // Else we haven't handled this kind of node yet -- add it @@ -134243,12 +139186,12 @@ var ts; }; ChangeTracker.prototype.insertName = function (sourceFile, node, name) { ts.Debug.assert(!node.name); - if (node.kind === 209 /* ArrowFunction */) { + if (node.kind === 211 /* ArrowFunction */) { var arrow = ts.findChildOfKind(node, 38 /* EqualsGreaterThanToken */, sourceFile); var lparen = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); if (lparen) { // `() => {}` --> `function f() {}` - this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.factory.createToken(97 /* FunctionKeyword */), ts.factory.createIdentifier(name)], { joiner: " " }); + this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.factory.createToken(98 /* FunctionKeyword */), ts.factory.createIdentifier(name)], { joiner: " " }); deleteNode(this, sourceFile, arrow); } else { @@ -134257,14 +139200,14 @@ var ts; // Replacing full range of arrow to get rid of the leading space -- replace ` =>` with `)` this.replaceRange(sourceFile, arrow, ts.factory.createToken(21 /* CloseParenToken */)); } - if (node.body.kind !== 230 /* Block */) { + if (node.body.kind !== 232 /* Block */) { // `() => 0` => `function f() { return 0; }` - this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.factory.createToken(18 /* OpenBraceToken */), ts.factory.createToken(104 /* ReturnKeyword */)], { joiner: " ", suffix: " " }); + 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: " " }); } } else { - var pos = ts.findChildOfKind(node, node.kind === 208 /* FunctionExpression */ ? 97 /* FunctionKeyword */ : 83 /* ClassKeyword */, sourceFile).end; + var pos = ts.findChildOfKind(node, node.kind === 210 /* FunctionExpression */ ? 98 /* FunctionKeyword */ : 84 /* ClassKeyword */, sourceFile).end; this.insertNodeAt(sourceFile, pos, ts.factory.createIdentifier(name), { prefix: " " }); } }; @@ -134296,47 +139239,22 @@ var ts; // a, b, c // create change for adding 'e' after 'a' as // - find start of next element after a (it is b) - // - use this start as start and end position in final change - // - build text of change by formatting the text of node + separator + whitespace trivia of b + // - use next element start as start and end position in final change + // - build text of change by formatting the text of node + whitespace trivia of b // in multiline case it will work as // a, // b, // c, // result - '*' denotes leading trivia that will be inserted after new text (displayed as '#') - // a,* - // ***insertedtext# + // a, + // insertedtext# // ###b, // c, - // find line and character of the next element - var lineAndCharOfNextElement = ts.getLineAndCharacterOfPosition(sourceFile, skipWhitespacesAndLineBreaks(sourceFile.text, containingList[index + 1].getFullStart())); - // find line and character of the token that precedes next element (usually it is separator) - var lineAndCharOfNextToken = ts.getLineAndCharacterOfPosition(sourceFile, nextToken.end); - var prefix = void 0; - var startPos = void 0; - if (lineAndCharOfNextToken.line === lineAndCharOfNextElement.line) { - // next element is located on the same line with separator: - // a,$$$$b - // ^ ^ - // | |-next element - // |-separator - // where $$$ is some leading trivia - // for a newly inserted node we'll maintain the same relative position comparing to separator and replace leading trivia with spaces - // a, x,$$$$b - // ^ ^ ^ - // | | |-next element - // | |-new inserted node padded with spaces - // |-separator - startPos = nextToken.end; - prefix = spaces(lineAndCharOfNextElement.character - lineAndCharOfNextToken.character); - } - else { - // next element is located on different line that separator - // let insert position be the beginning of the line that contains next element - startPos = ts.getStartPositionOfLine(lineAndCharOfNextElement.line, sourceFile); - } + 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, containingList[index + 1].getStart(sourceFile)); - this.replaceRange(sourceFile, ts.createRange(startPos, containingList[index + 1].getStart(sourceFile)), newNode, { prefix: prefix, suffix: suffix }); + var suffix = "" + ts.tokenToString(nextToken.kind) + sourceFile.text.substring(nextToken.end, startPos); + this.insertNodesAt(sourceFile, startPos, [newNode], { suffix: suffix }); } } else { @@ -134408,7 +139326,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_9 = function (sourceFile, node) { + var _loop_10 = 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)); @@ -134421,7 +139339,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_9(sourceFile, node); + _loop_10(sourceFile, node); } deletedNodesInLists.forEach(function (node) { var sourceFile = node.getSourceFile(); @@ -134480,14 +139398,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_10 = function (i) { + var _loop_11 = 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); }); }; // verify that change intervals do not overlap, except possibly at end points. for (var i = 0; i < normalized.length - 1; i++) { - _loop_10(i); + _loop_11(i); } var textChanges = ts.mapDefined(normalized, function (c) { var span = ts.createTextSpanFromRange(c.range); @@ -134601,11 +139519,12 @@ var ts; function createWriter(newLine) { var lastNonTriviaPosition = 0; var writer = ts.createTextWriter(newLine); - var onEmitNode = function (hint, node, printCallback) { + var onBeforeEmitNode = function (node) { if (node) { setPos(node, lastNonTriviaPosition); } - printCallback(hint, node); + }; + var onAfterEmitNode = function (node) { if (node) { setEnd(node, lastNonTriviaPosition); } @@ -134724,7 +139643,8 @@ var ts; lastNonTriviaPosition = 0; } return { - onEmitNode: onEmitNode, + onBeforeEmitNode: onBeforeEmitNode, + onAfterEmitNode: onAfterEmitNode, onBeforeEmitNodeArray: onBeforeEmitNodeArray, onAfterEmitNodeArray: onAfterEmitNodeArray, onBeforeEmitToken: onBeforeEmitToken, @@ -134839,14 +139759,14 @@ var ts; } textChanges_3.isValidLocationToAddComment = isValidLocationToAddComment; function needSemicolonBetween(a, b) { - return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 158 /* ComputedPropertyName */ + return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 160 /* 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 160 /* Parameter */: { + case 162 /* Parameter */: { var oldFunction = node.parent; if (ts.isArrowFunction(oldFunction) && oldFunction.parameters.length === 1 && @@ -134861,15 +139781,17 @@ var ts; } break; } - case 261 /* ImportDeclaration */: - case 260 /* ImportEqualsDeclaration */: + case 263 /* ImportDeclaration */: + case 262 /* 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 }); + deleteNode(changes, sourceFile, node, { + leadingTriviaOption: isFirstImport ? LeadingTriviaOption.Exclude : ts.hasJSDocNodes(node) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine, + }); break; - case 198 /* BindingElement */: + case 200 /* BindingElement */: var pattern = node.parent; - var preserveComma = pattern.kind === 197 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); + var preserveComma = pattern.kind === 199 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); if (preserveComma) { deleteNode(changes, sourceFile, node); } @@ -134877,13 +139799,13 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node); break; - case 159 /* TypeParameter */: + case 161 /* TypeParameter */: deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); break; - case 265 /* ImportSpecifier */: + case 267 /* ImportSpecifier */: var namedImports = node.parent; if (namedImports.elements.length === 1) { deleteImportBinding(changes, sourceFile, namedImports); @@ -134892,21 +139814,25 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: deleteImportBinding(changes, sourceFile, node); break; case 26 /* SemicolonToken */: deleteNode(changes, sourceFile, node, { trailingTriviaOption: TrailingTriviaOption.Exclude }); break; - case 97 /* FunctionKeyword */: + case 98 /* FunctionKeyword */: deleteNode(changes, sourceFile, node, { leadingTriviaOption: LeadingTriviaOption.Exclude }); break; - case 252 /* ClassDeclaration */: - case 251 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: + case 253 /* FunctionDeclaration */: deleteNode(changes, sourceFile, node, { leadingTriviaOption: ts.hasJSDocNodes(node) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine }); break; default: - if (ts.isImportClause(node.parent) && node.parent.name === node) { + if (!node.parent) { + // a misbehaving client can reach here with the SourceFile node + deleteNode(changes, sourceFile, node); + } + else if (ts.isImportClause(node.parent) && node.parent.name === node) { deleteDefaultImport(changes, sourceFile, node.parent); } else if (ts.isCallExpression(node.parent) && ts.contains(node.parent.arguments, node)) { @@ -134949,13 +139875,13 @@ var ts; // Delete the entire import declaration // |import * as ns from './file'| // |import { a } from './file'| - var importDecl = ts.getAncestor(node, 261 /* ImportDeclaration */); + var importDecl = ts.getAncestor(node, 263 /* ImportDeclaration */); deleteNode(changes, sourceFile, importDecl); } } function deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node) { var parent = node.parent; - if (parent.kind === 287 /* CatchClause */) { + if (parent.kind === 289 /* 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)); return; @@ -134966,14 +139892,14 @@ var ts; } var gp = parent.parent; switch (gp.kind) { - case 239 /* ForOfStatement */: - case 238 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 240 /* ForInStatement */: changes.replaceNode(sourceFile, node, ts.factory.createObjectLiteralExpression()); break; - case 237 /* ForStatement */: + case 239 /* ForStatement */: deleteNode(changes, sourceFile, parent); break; - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: deleteNode(changes, sourceFile, gp, { leadingTriviaOption: ts.hasJSDocNodes(gp) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine }); break; default: @@ -135029,6 +139955,10 @@ var ts; return createCodeFixActionWorker(fixName, diagnosticToString(description), changes, fixId, diagnosticToString(fixAllDescription), command); } codefix.createCodeFixAction = createCodeFixAction; + function createCodeFixActionMaybeFixAll(fixName, changes, description, fixId, fixAllDescription, command) { + return createCodeFixActionWorker(fixName, diagnosticToString(description), changes, fixId, fixAllDescription && diagnosticToString(fixAllDescription), command); + } + codefix.createCodeFixActionMaybeFixAll = createCodeFixActionMaybeFixAll; function createCodeFixActionWorker(fixName, description, changes, fixId, fixAllDescription, command) { return { fixName: fixName, description: description, changes: changes, fixId: fixId, fixAllDescription: fixAllDescription, commands: command ? [command] : undefined }; } @@ -135155,8 +140085,8 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, pos); var assertion = ts.Debug.checkDefined(ts.findAncestor(token, function (n) { return ts.isAsExpression(n) || ts.isTypeAssertionExpression(n); }), "Expected to find an assertion expression"); var replacement = ts.isAsExpression(assertion) - ? ts.factory.createAsExpression(assertion.expression, ts.factory.createKeywordTypeNode(152 /* UnknownKeyword */)) - : ts.factory.createTypeAssertion(ts.factory.createKeywordTypeNode(152 /* UnknownKeyword */), assertion.expression); + ? ts.factory.createAsExpression(assertion.expression, ts.factory.createKeywordTypeNode(153 /* UnknownKeyword */)) + : ts.factory.createTypeAssertion(ts.factory.createKeywordTypeNode(153 /* UnknownKeyword */), assertion.expression); changeTracker.replaceNode(sourceFile, assertion.expression, replacement); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -135167,7 +140097,10 @@ var ts; var codefix; (function (codefix) { codefix.registerCodeFix({ - errorCodes: [ts.Diagnostics.await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module.code], + errorCodes: [ + ts.Diagnostics.await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module.code, + ts.Diagnostics.for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module.code, + ], getCodeActions: function (context) { var sourceFile = context.sourceFile; var changes = ts.textChanges.ChangeTracker.with(context, function (changes) { @@ -135280,6 +140213,7 @@ var ts; ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1.code, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2.code, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap.code, + ts.Diagnostics.This_condition_will_always_return_true_since_this_0_is_always_defined.code, ts.Diagnostics.Type_0_is_not_an_array_type.code, ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type.code, ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators.code, @@ -135378,14 +140312,14 @@ var ts; } var isCompleteFix = identifiers.isCompleteFix; var initializers; - var _loop_11 = function (identifier) { + var _loop_12 = 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, 232 /* VariableStatement */); + var variableStatement = ts.getAncestor(declaration, 234 /* VariableStatement */); if (!declaration || !variableStatement || declaration.type || !declaration.initializer || @@ -135411,7 +140345,7 @@ var ts; }; for (var _i = 0, _a = identifiers.identifiers; _i < _a.length; _i++) { var identifier = _a[_i]; - _loop_11(identifier); + _loop_12(identifier); } return initializers && { initializers: initializers, @@ -135463,10 +140397,10 @@ var ts; function isInsideAwaitableBody(node) { return node.kind & 32768 /* AwaitContext */ || !!ts.findAncestor(node, function (ancestor) { return ancestor.parent && ts.isArrowFunction(ancestor.parent) && ancestor.parent.body === ancestor || - ts.isBlock(ancestor) && (ancestor.parent.kind === 251 /* FunctionDeclaration */ || - ancestor.parent.kind === 208 /* FunctionExpression */ || - ancestor.parent.kind === 209 /* ArrowFunction */ || - ancestor.parent.kind === 165 /* MethodDeclaration */); + ts.isBlock(ancestor) && (ancestor.parent.kind === 253 /* FunctionDeclaration */ || + ancestor.parent.kind === 210 /* FunctionExpression */ || + ancestor.parent.kind === 211 /* ArrowFunction */ || + ancestor.parent.kind === 167 /* MethodDeclaration */); }); } function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite, fixedDeclarations) { @@ -135555,7 +140489,7 @@ var ts; if (forInitializer) return applyChange(changeTracker, forInitializer, sourceFile, fixedNodes); var parent = token.parent; - if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 62 /* EqualsToken */ && ts.isExpressionStatement(parent.parent)) { + if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isExpressionStatement(parent.parent)) { return applyChange(changeTracker, token, sourceFile, fixedNodes); } if (ts.isArrayLiteralExpression(parent)) { @@ -135579,16 +140513,16 @@ var ts; } function applyChange(changeTracker, initializer, sourceFile, fixedNodes) { if (!fixedNodes || ts.tryAddToSet(fixedNodes, initializer)) { - changeTracker.insertModifierBefore(sourceFile, 84 /* ConstKeyword */, initializer); + changeTracker.insertModifierBefore(sourceFile, 85 /* ConstKeyword */, initializer); } } function isPossiblyPartOfDestructuring(node) { switch (node.kind) { - case 78 /* Identifier */: - case 199 /* ArrayLiteralExpression */: - case 200 /* ObjectLiteralExpression */: - case 288 /* PropertyAssignment */: - case 289 /* ShorthandPropertyAssignment */: + case 79 /* Identifier */: + case 201 /* ArrayLiteralExpression */: + case 202 /* ObjectLiteralExpression */: + case 290 /* PropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return true; default: return false; @@ -135602,8 +140536,8 @@ var ts; } function isPossiblyPartOfCommaSeperatedInitializer(node) { switch (node.kind) { - case 78 /* Identifier */: - case 216 /* BinaryExpression */: + case 79 /* Identifier */: + case 218 /* BinaryExpression */: case 27 /* CommaToken */: return true; default: @@ -135617,7 +140551,7 @@ var ts; if (expression.operatorToken.kind === 27 /* CommaToken */) { return ts.every([expression.left, expression.right], function (expression) { return expressionCouldBeVariableDeclaration(expression, checker); }); } - return expression.operatorToken.kind === 62 /* EqualsToken */ + return expression.operatorToken.kind === 63 /* EqualsToken */ && ts.isIdentifier(expression.left) && !checker.getSymbolAtLocation(expression.left); } @@ -135652,9 +140586,9 @@ var ts; return; } var declaration = token.parent; - if (declaration.kind === 163 /* PropertyDeclaration */ && + if (declaration.kind === 165 /* PropertyDeclaration */ && (!fixedNodes || ts.tryAddToSet(fixedNodes, declaration))) { - changeTracker.insertModifierBefore(sourceFile, 133 /* DeclareKeyword */, declaration); + changeTracker.insertModifierBefore(sourceFile, 134 /* DeclareKeyword */, declaration); } } })(codefix = ts.codefix || (ts.codefix = {})); @@ -135789,26 +140723,26 @@ var ts; } function isDeclarationWithType(node) { return ts.isFunctionLikeDeclaration(node) || - node.kind === 249 /* VariableDeclaration */ || - node.kind === 162 /* PropertySignature */ || - node.kind === 163 /* PropertyDeclaration */; + node.kind === 251 /* VariableDeclaration */ || + node.kind === 164 /* PropertySignature */ || + node.kind === 165 /* PropertyDeclaration */; } function transformJSDocType(node) { switch (node.kind) { - case 303 /* JSDocAllType */: - case 304 /* JSDocUnknownType */: + case 306 /* JSDocAllType */: + case 307 /* JSDocUnknownType */: return ts.factory.createTypeReferenceNode("any", ts.emptyArray); - case 307 /* JSDocOptionalType */: + case 310 /* JSDocOptionalType */: return transformJSDocOptionalType(node); - case 306 /* JSDocNonNullableType */: + case 309 /* JSDocNonNullableType */: return transformJSDocType(node.type); - case 305 /* JSDocNullableType */: + case 308 /* JSDocNullableType */: return transformJSDocNullableType(node); - case 309 /* JSDocVariadicType */: + case 312 /* JSDocVariadicType */: return transformJSDocVariadicType(node); - case 308 /* JSDocFunctionType */: + case 311 /* JSDocFunctionType */: return transformJSDocFunctionType(node); - case 173 /* TypeReference */: + case 175 /* TypeReference */: return transformJSDocTypeReference(node); default: var visited = ts.visitEachChild(node, transformJSDocType, ts.nullTransformationContext); @@ -135829,11 +140763,11 @@ 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(128 /* AnyKeyword */)); + return ts.factory.createFunctionTypeNode(ts.emptyArray, node.parameters.map(transformJSDocParameter), (_a = node.type) !== null && _a !== void 0 ? _a : ts.factory.createKeywordTypeNode(129 /* AnyKeyword */)); } function transformJSDocParameter(node) { var index = node.parent.parameters.indexOf(node); - var isRest = node.type.kind === 309 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 + var isRest = node.type.kind === 312 /* 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; return ts.factory.createParameterDeclaration(node.decorators, node.modifiers, dotdotdot, name, node.questionToken, ts.visitNode(node.type, transformJSDocType), node.initializer); @@ -135873,8 +140807,8 @@ var ts; var index = ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 144 /* NumberKeyword */ ? "n" : "s", - /*questionToken*/ undefined, ts.factory.createTypeReferenceNode(node.typeArguments[0].kind === 144 /* NumberKeyword */ ? "number" : "string", []), + /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 145 /* NumberKeyword */ ? "n" : "s", + /*questionToken*/ undefined, ts.factory.createTypeReferenceNode(node.typeArguments[0].kind === 145 /* NumberKeyword */ ? "number" : "string", []), /*initializer*/ undefined); var indexSignature = ts.factory.createTypeLiteralNode([ts.factory.createIndexSignature(/*decorators*/ undefined, /*modifiers*/ undefined, [index], node.typeArguments[1])]); ts.setEmitFlags(indexSignature, 1 /* SingleLine */); @@ -135904,7 +140838,7 @@ var ts; }); function doChange(changes, sourceFile, position, checker, preferences, compilerOptions) { var ctorSymbol = checker.getSymbolAtLocation(ts.getTokenAtPosition(sourceFile, position)); - if (!ctorSymbol || !(ctorSymbol.flags & (16 /* Function */ | 3 /* Variable */))) { + if (!ctorSymbol || !ctorSymbol.valueDeclaration || !(ctorSymbol.flags & (16 /* Function */ | 3 /* Variable */))) { // Bad input return undefined; } @@ -135931,7 +140865,7 @@ var ts; // all instance members are stored in the "member" array of symbol if (symbol.members) { symbol.members.forEach(function (member, key) { - if (key === "constructor") { + if (key === "constructor" && member.valueDeclaration) { // fn.prototype.constructor = fn changes.delete(sourceFile, member.valueDeclaration.parent); return; @@ -135945,13 +140879,13 @@ var ts; // all static members are stored in the "exports" array of symbol if (symbol.exports) { symbol.exports.forEach(function (member) { - if (member.name === "prototype") { + if (member.name === "prototype" && member.declarations) { var firstDeclaration = member.declarations[0]; // only one "x.prototype = { ... }" will pass if (member.declarations.length === 1 && ts.isPropertyAccessExpression(firstDeclaration) && ts.isBinaryExpression(firstDeclaration.parent) && - firstDeclaration.parent.operatorToken.kind === 62 /* EqualsToken */ && + firstDeclaration.parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isObjectLiteralExpression(firstDeclaration.parent.right)) { var prototypes = firstDeclaration.parent.right; var memberElement = createClassElement(prototypes.symbol, /** modifiers */ undefined); @@ -135961,7 +140895,7 @@ var ts; } } else { - var memberElement = createClassElement(member, [ts.factory.createToken(123 /* StaticKeyword */)]); + var memberElement = createClassElement(member, [ts.factory.createToken(124 /* StaticKeyword */)]); if (memberElement) { memberElements.push.apply(memberElements, memberElement); } @@ -136007,7 +140941,7 @@ var ts; return members; } // delete the entire statement if this expression is the sole expression to take care of the semicolon at the end - var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 233 /* ExpressionStatement */ + var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 235 /* ExpressionStatement */ ? assignmentBinaryExpression.parent : assignmentBinaryExpression; changes.delete(sourceFile, nodeToDelete); if (!assignmentExpr) { @@ -136058,7 +140992,7 @@ var ts; return createArrowFunctionExpressionMember(members, expression, name); } function createFunctionExpressionMember(members, functionExpression, name) { - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 129 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 130 /* AsyncKeyword */)); var method = ts.factory.createMethodDeclaration(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined, /*typeParameters*/ undefined, functionExpression.parameters, /*type*/ undefined, functionExpression.body); ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); @@ -136068,14 +141002,14 @@ var ts; var arrowFunctionBody = arrowFunction.body; var bodyBlock; // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 230 /* Block */) { + if (arrowFunctionBody.kind === 232 /* Block */) { bodyBlock = arrowFunctionBody; } // case 2: () => [1,2,3] else { bodyBlock = ts.factory.createBlock([ts.factory.createReturnStatement(arrowFunctionBody)]); } - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 129 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 130 /* AsyncKeyword */)); var method = ts.factory.createMethodDeclaration(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined, /*typeParameters*/ undefined, arrowFunction.parameters, /*type*/ undefined, bodyBlock); ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); @@ -136092,7 +141026,7 @@ var ts; if (initializer.body) { memberElements.unshift(ts.factory.createConstructorDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, initializer.parameters, initializer.body)); } - var modifiers = getModifierKindFromSource(node.parent.parent, 92 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(node.parent.parent, 93 /* ExportKeyword */); var cls = ts.factory.createClassDeclaration(/*decorators*/ undefined, modifiers, node.name, /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); // Don't call copyComments here because we'll already leave them in place @@ -136103,7 +141037,7 @@ var ts; if (node.body) { memberElements.unshift(ts.factory.createConstructorDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, node.parameters, node.body)); } - var modifiers = getModifierKindFromSource(node, 92 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(node, 93 /* ExportKeyword */); var cls = ts.factory.createClassDeclaration(/*decorators*/ undefined, modifiers, node.name, /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); // Don't call copyComments here because we'll already leave them in place @@ -136170,7 +141104,7 @@ var ts; functionToConvert = tokenAtPosition.parent.initializer; } else { - functionToConvert = ts.tryCast(ts.getContainingFunction(ts.getTokenAtPosition(sourceFile, position)), ts.isFunctionLikeDeclaration); + functionToConvert = ts.tryCast(ts.getContainingFunction(ts.getTokenAtPosition(sourceFile, position)), ts.canBeConvertedToAsync); } if (!functionToConvert) { return; @@ -136179,7 +141113,10 @@ var ts; var isInJavascript = ts.isInJSFile(functionToConvert); var setOfExpressionsToReturn = getAllPromiseExpressionsToReturn(functionToConvert, checker); var functionToConvertRenamed = renameCollidingVarNames(functionToConvert, checker, synthNamesMap); - var returnStatements = functionToConvertRenamed.body && ts.isBlock(functionToConvertRenamed.body) ? getReturnStatementsWithPromiseHandlers(functionToConvertRenamed.body) : ts.emptyArray; + if (!ts.returnsPromise(functionToConvertRenamed, checker)) { + return; + } + var returnStatements = functionToConvertRenamed.body && ts.isBlock(functionToConvertRenamed.body) ? getReturnStatementsWithPromiseHandlers(functionToConvertRenamed.body, checker) : ts.emptyArray; var transformer = { checker: checker, synthNamesMap: synthNamesMap, setOfExpressionsToReturn: setOfExpressionsToReturn, isInJSFile: isInJavascript }; if (!returnStatements.length) { return; @@ -136188,8 +141125,8 @@ var ts; functionToConvert.decorators ? ts.skipTrivia(sourceFile.text, functionToConvert.decorators.end) : functionToConvert.getStart(sourceFile); var options = functionToConvert.modifiers ? { prefix: " " } : { suffix: " " }; - changes.insertModifierAt(sourceFile, pos, 129 /* AsyncKeyword */, options); - var _loop_12 = function (returnStatement) { + changes.insertModifierAt(sourceFile, pos, 130 /* AsyncKeyword */, options); + var _loop_13 = function (returnStatement) { ts.forEachChild(returnStatement, function visit(node) { if (ts.isCallExpression(node)) { var newNodes = transformExpression(node, transformer); @@ -136202,13 +141139,13 @@ var ts; }; for (var _i = 0, returnStatements_1 = returnStatements; _i < returnStatements_1.length; _i++) { var returnStatement = returnStatements_1[_i]; - _loop_12(returnStatement); + _loop_13(returnStatement); } } - function getReturnStatementsWithPromiseHandlers(body) { + function getReturnStatementsWithPromiseHandlers(body, checker) { var res = []; ts.forEachReturnStatement(body, function (ret) { - if (ts.isReturnStatementWithFixablePromiseHandler(ret)) + if (ts.isReturnStatementWithFixablePromiseHandler(ret, checker)) res.push(ret); }); return res; @@ -136279,7 +141216,10 @@ var ts; // so we push an entry for 'response'. if (lastCallSignature && !ts.isParameter(node.parent) && !ts.isFunctionLikeDeclaration(node.parent) && !synthNamesMap.has(symbolIdString)) { var firstParameter = ts.firstOrUndefined(lastCallSignature.parameters); - var ident = firstParameter && ts.isParameter(firstParameter.valueDeclaration) && ts.tryCast(firstParameter.valueDeclaration.name, ts.isIdentifier) || ts.factory.createUniqueName("result", 16 /* Optimistic */); + 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 */); var synthName = getNewNameIfConflict(ident, collidingSymbolMap); synthNamesMap.set(symbolIdString, synthName); collidingSymbolMap.add(ident.text, symbol); @@ -136454,10 +141394,11 @@ var ts; function getTransformationBody(func, prevArgName, argName, parent, transformer) { var _a, _b, _c, _d, _e; switch (func.kind) { - case 103 /* NullKeyword */: + case 104 /* NullKeyword */: // do not produce a transformed statement for a null argument break; - case 78 /* Identifier */: // identifier includes undefined + case 203 /* PropertyAccessExpression */: + case 79 /* Identifier */: // identifier includes undefined if (!argName) { // undefined was argument passed to promise handler break; @@ -136478,8 +141419,8 @@ var ts; prevArgName.types.push(returnType); } return varDeclOrAssignment; - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: { + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: { var funcBody = func.body; var returnType_1 = (_c = getLastCallSignature(transformer.checker.getTypeAtLocation(func), transformer.checker)) === null || _c === void 0 ? void 0 : _c.getReturnType(); // Arrow functions with block bodies { } will enter this control flow @@ -136490,7 +141431,7 @@ var ts; var statement = _f[_i]; if (ts.isReturnStatement(statement)) { seenReturnStatement = true; - if (ts.isReturnStatementWithFixablePromiseHandler(statement)) { + if (ts.isReturnStatementWithFixablePromiseHandler(statement, transformer.checker)) { refactoredStmts = refactoredStmts.concat(getInnerTransformationBody(transformer, [statement], prevArgName)); } else { @@ -136507,7 +141448,7 @@ var ts; : removeReturns(refactoredStmts, prevArgName, transformer, seenReturnStatement); } else { - var innerRetStmts = ts.isFixablePromiseHandler(funcBody) ? [ts.factory.createReturnStatement(funcBody)] : ts.emptyArray; + var innerRetStmts = ts.isFixablePromiseHandler(funcBody, transformer.checker) ? [ts.factory.createReturnStatement(funcBody)] : ts.emptyArray; var innerCbBody = getInnerTransformationBody(transformer, innerRetStmts, prevArgName); if (innerCbBody.length > 0) { return innerCbBody; @@ -136600,6 +141541,9 @@ var ts; else if (ts.isIdentifier(funcNode)) { name = getMapEntryOrDefault(funcNode); } + else if (ts.isPropertyAccessExpression(funcNode) && ts.isIdentifier(funcNode.name)) { + name = getMapEntryOrDefault(funcNode.name); + } // return undefined argName when arg is null or undefined // eslint-disable-next-line no-in-operator if (!name || "identifier" in name && name.identifier.text === "undefined") { @@ -136695,10 +141639,10 @@ var ts; } var importNode = ts.importFromModuleSpecifier(moduleSpecifier); switch (importNode.kind) { - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier, quotePreference)); break; - case 203 /* CallExpression */: + case 205 /* CallExpression */: if (ts.isRequireCall(importNode, /*checkArgumentIsStringLiteralLike*/ false)) { changes.replaceNode(importingFile, importNode, ts.factory.createPropertyAccessExpression(ts.getSynthesizedDeepClone(importNode), "default")); } @@ -136758,29 +141702,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 === 62 /* EqualsToken */); + cb(node, ts.isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === 63 /* EqualsToken */); } node.forEachChild(recur); }); } function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, useSitesToUnqualify, quotePreference) { switch (statement.kind) { - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, quotePreference); return false; - case 233 /* ExpressionStatement */: { + case 235 /* ExpressionStatement */: { var expression = statement.expression; switch (expression.kind) { - case 203 /* CallExpression */: { + case 205 /* 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 216 /* BinaryExpression */: { + case 218 /* BinaryExpression */: { var operatorToken = expression.operatorToken; - return operatorToken.kind === 62 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports, useSitesToUnqualify); + return operatorToken.kind === 63 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports, useSitesToUnqualify); } } } @@ -136827,8 +141771,8 @@ var ts; /** Converts `const name = require("moduleSpecifier").propertyName` */ function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers, quotePreference) { switch (name.kind) { - case 196 /* ObjectBindingPattern */: - case 197 /* ArrayBindingPattern */: { + case 198 /* ObjectBindingPattern */: + case 199 /* ArrayBindingPattern */: { // `const [a, b] = require("c").d` --> `import { d } from "c"; const [a, b] = d;` var tmp = makeUniqueName(propertyName, identifiers); return convertedImports([ @@ -136836,7 +141780,7 @@ var ts; makeConst(/*modifiers*/ undefined, name, ts.factory.createIdentifier(tmp)), ]); } - case 78 /* Identifier */: + case 79 /* Identifier */: // `const a = require("b").c` --> `import { c as a } from "./b"; return convertedImports([makeSingleImport(name.text, propertyName, moduleSpecifier, quotePreference)]); default: @@ -136879,17 +141823,17 @@ var ts; function tryChangeModuleExportsObject(object, useSitesToUnqualify) { var statements = ts.mapAllOrFail(object.properties, function (prop) { switch (prop.kind) { - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: // TODO: Maybe we should handle this? See fourslash test `refactorConvertToEs6Module_export_object_shorthand.ts`. // falls through - case 289 /* ShorthandPropertyAssignment */: - case 290 /* SpreadAssignment */: + case 291 /* ShorthandPropertyAssignment */: + case 292 /* SpreadAssignment */: return undefined; - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: return !ts.isIdentifier(prop.name) ? undefined : convertExportsDotXEquals_replaceNode(prop.name.text, prop.initializer, useSitesToUnqualify); - case 165 /* MethodDeclaration */: - return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.factory.createToken(92 /* ExportKeyword */)], prop, useSitesToUnqualify); + case 167 /* MethodDeclaration */: + return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.factory.createToken(93 /* ExportKeyword */)], prop, useSitesToUnqualify); default: ts.Debug.assertNever(prop, "Convert to ES6 got invalid prop kind " + prop.kind); } @@ -136936,7 +141880,7 @@ 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(92 /* ExportKeyword */), { suffix: " " }); + changes.replaceRange(sourceFile, { pos: left.getStart(sourceFile), end: right.getStart(sourceFile) }, ts.factory.createToken(93 /* ExportKeyword */), { suffix: " " }); if (!right.name) changes.insertName(sourceFile, right, name); var semi = ts.findChildOfKind(parent, 26 /* SemicolonToken */, sourceFile); @@ -136945,14 +141889,14 @@ var ts; } 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(92 /* ExportKeyword */), ts.factory.createToken(84 /* ConstKeyword */)], { joiner: " ", suffix: " " }); + changes.replaceNodeRangeWithNodes(sourceFile, left.expression, ts.findChildOfKind(left, 24 /* DotToken */, sourceFile), [ts.factory.createToken(93 /* ExportKeyword */), ts.factory.createToken(85 /* 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(92 /* ExportKeyword */)]; + var modifiers = [ts.factory.createToken(93 /* ExportKeyword */)]; switch (exported.kind) { - case 208 /* FunctionExpression */: { + case 210 /* FunctionExpression */: { var expressionName = exported.name; if (expressionName && expressionName.text !== name) { // `exports.f = function g() {}` -> `export const f = function g() {}` @@ -136960,10 +141904,10 @@ var ts; } } // falls through - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: // `exports.f = function() {}` --> `export function f() {}` return functionExpressionToDeclaration(name, modifiers, exported, useSitesToUnqualify); - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: // `exports.C = class {}` --> `export class C {}` return classExpressionToDeclaration(name, modifiers, exported, useSitesToUnqualify); default: @@ -136983,7 +141927,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 === 201 /* PropertyAccessExpression */) { + if (original.kind === 203 /* 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); @@ -136998,7 +141942,7 @@ var ts; */ function convertSingleImport(name, moduleSpecifier, checker, identifiers, target, quotePreference) { switch (name.kind) { - case 196 /* ObjectBindingPattern */: { + case 198 /* 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 @@ -137011,7 +141955,7 @@ var ts; } } // falls through -- object destructuring has an interesting pattern and must be a variable declaration - case 197 /* ArrayBindingPattern */: { + case 199 /* ArrayBindingPattern */: { /* import x from "x"; const [a, b, c] = x; @@ -137022,7 +141966,7 @@ var ts; makeConst(/*modifiers*/ undefined, ts.getSynthesizedDeepClone(name), ts.factory.createIdentifier(tmp)), ]); } - case 78 /* Identifier */: + case 79 /* Identifier */: return convertSingleIdentifierImport(name, moduleSpecifier, checker, identifiers, quotePreference); default: return ts.Debug.assertNever(name, "Convert to ES6 module got invalid name kind " + name.kind); @@ -137030,7 +141974,9 @@ var ts; } /** * Convert `import x = require("x").` - * Also converts uses like `x.y()` to `y()` and uses a named import. + * Also: + * - Convert `x.default()` to `x()` to handle ES6 default export + * - Converts uses like `x.y()` to `y()` and uses a named import. */ function convertSingleIdentifierImport(name, moduleSpecifier, checker, identifiers, quotePreference) { var nameSymbol = checker.getSymbolAtLocation(name); @@ -137047,14 +141993,21 @@ var ts; } var parent = use.parent; if (ts.isPropertyAccessExpression(parent)) { - var expression = parent.expression, propertyName = parent.name.text; - ts.Debug.assert(expression === use, "Didn't expect expression === use"); // Else shouldn't have been in `collectIdentifiers` - var idName = namedBindingsNames.get(propertyName); - if (idName === undefined) { - idName = makeUniqueName(propertyName, identifiers); - namedBindingsNames.set(propertyName, idName); + var propertyName = parent.name.text; + if (propertyName === "default") { + needDefaultImport = true; + var importDefaultName = use.getText(); + (useSitesToUnqualify !== null && useSitesToUnqualify !== void 0 ? useSitesToUnqualify : (useSitesToUnqualify = new ts.Map())).set(parent, ts.factory.createIdentifier(importDefaultName)); + } + else { + ts.Debug.assert(parent.expression === use, "Didn't expect expression === use"); // Else shouldn't have been in `collectIdentifiers` + var idName = namedBindingsNames.get(propertyName); + if (idName === undefined) { + idName = makeUniqueName(propertyName, identifiers); + namedBindingsNames.set(propertyName, idName); + } + (useSitesToUnqualify !== null && useSitesToUnqualify !== void 0 ? useSitesToUnqualify : (useSitesToUnqualify = new ts.Map())).set(parent, ts.factory.createIdentifier(idName)); } - (useSitesToUnqualify !== null && useSitesToUnqualify !== void 0 ? useSitesToUnqualify : (useSitesToUnqualify = new ts.Map())).set(parent, ts.factory.createIdentifier(idName)); } else { needDefaultImport = true; @@ -137095,11 +142048,11 @@ var ts; function isFreeIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return parent.name !== node; - case 198 /* BindingElement */: + case 200 /* BindingElement */: return parent.propertyName !== node; - case 265 /* ImportSpecifier */: + case 267 /* ImportSpecifier */: return parent.propertyName !== node; default: return true; @@ -137213,7 +142166,7 @@ var ts; var exportDeclaration = exportClause.parent; var typeExportSpecifiers = getTypeExportSpecifiers(exportSpecifier, context); if (typeExportSpecifiers.length === exportClause.elements.length) { - changes.insertModifierBefore(context.sourceFile, 149 /* TypeKeyword */, exportClause); + changes.insertModifierBefore(context.sourceFile, 150 /* TypeKeyword */, exportClause); } else { var valueExportDeclaration = ts.factory.updateExportDeclaration(exportDeclaration, exportDeclaration.decorators, exportDeclaration.modifiers, @@ -137576,87 +142529,138 @@ var ts; ImportFixKind[ImportFixKind["AddToExisting"] = 2] = "AddToExisting"; ImportFixKind[ImportFixKind["AddNew"] = 3] = "AddNew"; })(ImportFixKind || (ImportFixKind = {})); - var ImportKind; - (function (ImportKind) { - ImportKind[ImportKind["Named"] = 0] = "Named"; - ImportKind[ImportKind["Default"] = 1] = "Default"; - ImportKind[ImportKind["Namespace"] = 2] = "Namespace"; - ImportKind[ImportKind["CommonJS"] = 3] = "CommonJS"; - })(ImportKind || (ImportKind = {})); function getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, symbolName, host, program, formatContext, position, preferences) { var compilerOptions = program.getCompilerOptions(); var exportInfos = ts.pathIsBareSpecifier(ts.stripQuotes(moduleSymbol.name)) - ? [getSymbolExportInfoForSymbol(exportedSymbol, moduleSymbol, sourceFile, program, host)] + ? [getSymbolExportInfoForSymbol(exportedSymbol, moduleSymbol, program, host)] : getAllReExportingModules(sourceFile, exportedSymbol, moduleSymbol, symbolName, host, program, /*useAutoImportProvider*/ true); var useRequire = shouldUseRequire(sourceFile, program); var preferTypeOnlyImport = compilerOptions.importsNotUsedAsValues === 2 /* Error */ && !ts.isSourceFileJS(sourceFile) && ts.isValidTypeOnlyAliasUseSite(ts.getTokenAtPosition(sourceFile, position)); - var moduleSpecifier = ts.first(getNewImportInfos(program, sourceFile, position, preferTypeOnlyImport, useRequire, exportInfos, host, preferences)).moduleSpecifier; var fix = getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, preferTypeOnlyImport, useRequire, host, preferences); - return { moduleSpecifier: moduleSpecifier, codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, ts.getQuotePreference(sourceFile, preferences))) }; + return { moduleSpecifier: fix.moduleSpecifier, codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, ts.getQuotePreference(sourceFile, preferences))) }; } codefix.getImportCompletionAction = getImportCompletionAction; function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, preferTypeOnlyImport, useRequire, host, preferences) { ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol"); - // We sort the best codefixes first, so taking `first` is best. - return ts.first(getFixForImport(exportInfos, symbolName, position, preferTypeOnlyImport, useRequire, program, sourceFile, host, preferences)); + return getBestFix(getImportFixes(exportInfos, symbolName, position, preferTypeOnlyImport, useRequire, program, sourceFile, host, preferences), sourceFile, host); } function codeFixActionToCodeAction(_a) { var description = _a.description, changes = _a.changes, commands = _a.commands; return { description: description, changes: changes, commands: commands }; } - function getSymbolExportInfoForSymbol(symbol, moduleSymbol, importingFile, program, host) { + function getSymbolExportInfoForSymbol(symbol, moduleSymbol, program, host) { var _a, _b; var compilerOptions = program.getCompilerOptions(); - var mainProgramInfo = getInfoWithChecker(program.getTypeChecker()); + var mainProgramInfo = getInfoWithChecker(program.getTypeChecker(), /*isFromPackageJson*/ false); if (mainProgramInfo) { return mainProgramInfo; } var autoImportProvider = (_b = (_a = host.getPackageJsonAutoImportProvider) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getTypeChecker(); - return ts.Debug.checkDefined(autoImportProvider && getInfoWithChecker(autoImportProvider), "Could not find symbol in specified module for code actions"); - function getInfoWithChecker(checker) { - var defaultInfo = getDefaultLikeExportInfo(importingFile, moduleSymbol, checker, compilerOptions); + return ts.Debug.checkDefined(autoImportProvider && getInfoWithChecker(autoImportProvider, /*isFromPackageJson*/ true), "Could not find symbol in specified module for code actions"); + function getInfoWithChecker(checker, isFromPackageJson) { + var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); if (defaultInfo && ts.skipAlias(defaultInfo.symbol, checker) === symbol) { - return { moduleSymbol: moduleSymbol, importKind: defaultInfo.kind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(symbol, checker) }; + return { symbol: defaultInfo.symbol, moduleSymbol: moduleSymbol, exportKind: defaultInfo.exportKind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(symbol, checker), isFromPackageJson: isFromPackageJson }; } var named = checker.tryGetMemberInModuleExportsAndProperties(symbol.name, moduleSymbol); if (named && ts.skipAlias(named, checker) === symbol) { - return { moduleSymbol: moduleSymbol, importKind: 0 /* Named */, exportedSymbolIsTypeOnly: isTypeOnlySymbol(symbol, checker) }; + return { symbol: named, moduleSymbol: moduleSymbol, exportKind: 0 /* Named */, exportedSymbolIsTypeOnly: isTypeOnlySymbol(symbol, checker), isFromPackageJson: isFromPackageJson }; } } } function getAllReExportingModules(importingFile, exportedSymbol, exportingModuleSymbol, symbolName, host, program, useAutoImportProvider) { var result = []; var compilerOptions = program.getCompilerOptions(); - forEachExternalModuleToImportFrom(program, host, importingFile, /*filterByPackageJson*/ false, useAutoImportProvider, function (moduleSymbol, moduleFile, program) { + var getModuleSpecifierResolutionHost = ts.memoizeOne(function (isFromPackageJson) { + return ts.createModuleSpecifierResolutionHost(isFromPackageJson ? host.getPackageJsonAutoImportProvider() : program, host); + }); + forEachExternalModuleToImportFrom(program, host, useAutoImportProvider, function (moduleSymbol, moduleFile, program, isFromPackageJson) { var checker = program.getTypeChecker(); // Don't import from a re-export when looking "up" like to `./index` or `../index`. if (moduleFile && moduleSymbol !== exportingModuleSymbol && ts.startsWith(importingFile.fileName, ts.getDirectoryPath(moduleFile.fileName))) { return; } - var defaultInfo = getDefaultLikeExportInfo(importingFile, moduleSymbol, checker, compilerOptions); - if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, compilerOptions.target) === symbolName) && ts.skipAlias(defaultInfo.symbol, checker) === exportedSymbol) { - result.push({ moduleSymbol: moduleSymbol, importKind: defaultInfo.kind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(defaultInfo.symbol, checker) }); + var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); + if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, compilerOptions.target) === symbolName) && ts.skipAlias(defaultInfo.symbol, checker) === exportedSymbol && isImportable(program, moduleFile, isFromPackageJson)) { + result.push({ symbol: defaultInfo.symbol, moduleSymbol: moduleSymbol, exportKind: defaultInfo.exportKind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(defaultInfo.symbol, checker), isFromPackageJson: isFromPackageJson }); + } + for (var _i = 0, _a = checker.getExportsAndPropertiesOfModule(moduleSymbol); _i < _a.length; _i++) { + var exported = _a[_i]; + if (exported.name === symbolName && ts.skipAlias(exported, checker) === exportedSymbol && isImportable(program, moduleFile, isFromPackageJson)) { + result.push({ symbol: exported, moduleSymbol: moduleSymbol, exportKind: 0 /* Named */, exportedSymbolIsTypeOnly: isTypeOnlySymbol(exported, checker), isFromPackageJson: isFromPackageJson }); + } + } + }); + return result; + function isImportable(program, moduleFile, isFromPackageJson) { + var _a; + return !moduleFile || ts.isImportableFile(program, importingFile, moduleFile, /*packageJsonFilter*/ undefined, getModuleSpecifierResolutionHost(isFromPackageJson), (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host)); + } + } + function getModuleSpecifierForBestExportInfo(exportInfo, importingFile, program, host, preferences) { + return getBestFix(getNewImportFixes(program, importingFile, /*position*/ undefined, /*preferTypeOnlyImport*/ false, /*useRequire*/ false, exportInfo, host, preferences), importingFile, host); + } + codefix.getModuleSpecifierForBestExportInfo = getModuleSpecifierForBestExportInfo; + function getSymbolToExportInfoMap(importingFile, host, program) { + var _a, _b, _c, _d, _e, _f, _g, _h; + var start = ts.timestamp(); + // Pulling the AutoImportProvider project will trigger its updateGraph if pending, + // which will invalidate the export map cache if things change, so pull it before + // checking the cache. + (_a = host.getPackageJsonAutoImportProvider) === null || _a === void 0 ? void 0 : _a.call(host); + var cache = (_b = host.getExportMapCache) === null || _b === void 0 ? void 0 : _b.call(host); + if (cache) { + var cached = cache.get(importingFile.path, program.getTypeChecker(), (_c = host.getProjectVersion) === null || _c === void 0 ? void 0 : _c.call(host)); + if (cached) { + (_d = host.log) === null || _d === void 0 ? void 0 : _d.call(host, "getSymbolToExportInfoMap: cache hit"); + return cached; + } + else { + (_e = host.log) === null || _e === void 0 ? void 0 : _e.call(host, "getSymbolToExportInfoMap: cache miss or empty; calculating new results"); + } + } + var result = ts.createMultiMap(); + var compilerOptions = program.getCompilerOptions(); + var target = ts.getEmitScriptTarget(compilerOptions); + forEachExternalModuleToImportFrom(program, host, /*useAutoImportProvider*/ true, function (moduleSymbol, _moduleFile, program, isFromPackageJson) { + var checker = program.getTypeChecker(); + var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); + if (defaultInfo) { + var name = ts.getNameForExportedSymbol(ts.getLocalSymbolForExportDefault(defaultInfo.symbol) || defaultInfo.symbol, target); + result.add(key(name, defaultInfo.symbol, moduleSymbol, checker), { symbol: defaultInfo.symbol, moduleSymbol: moduleSymbol, exportKind: defaultInfo.exportKind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(defaultInfo.symbol, checker), isFromPackageJson: isFromPackageJson }); } + var seenExports = new ts.Map(); for (var _i = 0, _a = checker.getExportsAndPropertiesOfModule(moduleSymbol); _i < _a.length; _i++) { var exported = _a[_i]; - if (exported.name === symbolName && ts.skipAlias(exported, checker) === exportedSymbol) { - result.push({ moduleSymbol: moduleSymbol, importKind: 0 /* Named */, exportedSymbolIsTypeOnly: isTypeOnlySymbol(exported, checker) }); + if (exported !== (defaultInfo === null || defaultInfo === void 0 ? void 0 : defaultInfo.symbol) && ts.addToSeen(seenExports, exported)) { + result.add(key(ts.getNameForExportedSymbol(exported, target), exported, moduleSymbol, checker), { symbol: exported, moduleSymbol: moduleSymbol, exportKind: 0 /* Named */, exportedSymbolIsTypeOnly: isTypeOnlySymbol(exported, checker), isFromPackageJson: isFromPackageJson }); } } }); + if (cache) { + (_f = host.log) === null || _f === void 0 ? void 0 : _f.call(host, "getSymbolToExportInfoMap: caching results"); + cache.set(result, (_g = host.getProjectVersion) === null || _g === void 0 ? void 0 : _g.call(host)); + } + (_h = host.log) === null || _h === void 0 ? void 0 : _h.call(host, "getSymbolToExportInfoMap: done in " + (ts.timestamp() - start) + " ms"); return result; + function key(name, alias, moduleSymbol, checker) { + var moduleName = ts.stripQuotes(moduleSymbol.name); + var moduleKey = ts.isExternalModuleNameRelative(moduleName) ? "/" : moduleName; + return name + "|" + ts.getSymbolId(ts.skipAlias(alias, checker)) + "|" + moduleKey; + } } + codefix.getSymbolToExportInfoMap = getSymbolToExportInfoMap; function isTypeOnlySymbol(s, checker) { return !(ts.skipAlias(s, checker).flags & 111551 /* Value */); } function isTypeOnlyPosition(sourceFile, position) { return ts.isValidTypeOnlyAliasUseSite(ts.getTokenAtPosition(sourceFile, position)); } - function getFixForImport(exportInfos, symbolName, + function getImportFixes(exportInfos, symbolName, /** undefined only for missing JSX namespace */ position, preferTypeOnlyImport, useRequire, program, sourceFile, host, preferences) { var checker = program.getTypeChecker(); - var existingImports = ts.flatMap(exportInfos, function (info) { return getExistingImportDeclarations(info, checker, sourceFile); }); + var existingImports = ts.flatMap(exportInfos, function (info) { return getExistingImportDeclarations(info, checker, sourceFile, program.getCompilerOptions()); }); var useNamespace = position === undefined ? undefined : tryUseExistingNamespaceImport(existingImports, symbolName, position, checker); var addToExisting = tryAddToExistingImport(existingImports, position !== undefined && isTypeOnlyPosition(sourceFile, position)); // Don't bother providing an action to add a new import if we can add to an existing one. @@ -137679,10 +142683,11 @@ var ts; return ts.firstDefined(existingImports, function (_a) { var declaration = _a.declaration; var namespacePrefix = getNamespaceLikeImportText(declaration); - if (namespacePrefix) { + var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration); + if (namespacePrefix && moduleSpecifier) { var moduleSymbol = getTargetModuleFromNamespaceLikeImport(declaration, checker); if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(symbolName))) { - return { kind: 0 /* UseNamespace */, namespacePrefix: namespacePrefix, position: position }; + return { kind: 0 /* UseNamespace */, namespacePrefix: namespacePrefix, position: position, moduleSpecifier: moduleSpecifier }; } } }); @@ -137690,11 +142695,11 @@ var ts; function getTargetModuleFromNamespaceLikeImport(declaration, checker) { var _a; switch (declaration.kind) { - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return checker.resolveExternalModuleName(declaration.initializer.arguments[0]); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return checker.getAliasedSymbol(declaration.symbol); - case 261 /* ImportDeclaration */: + case 263 /* 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: @@ -137704,11 +142709,11 @@ var ts; function getNamespaceLikeImportText(declaration) { var _a, _b, _c; switch (declaration.kind) { - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return (_a = ts.tryCast(declaration.name, ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text; - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return declaration.name.text; - case 261 /* ImportDeclaration */: + case 263 /* 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); @@ -137717,31 +142722,38 @@ var ts; function tryAddToExistingImport(existingImports, canUseTypeOnlyImport) { return ts.firstDefined(existingImports, function (_a) { var declaration = _a.declaration, importKind = _a.importKind; - if (declaration.kind === 260 /* ImportEqualsDeclaration */) + if (declaration.kind === 262 /* ImportEqualsDeclaration */) return undefined; - if (declaration.kind === 249 /* VariableDeclaration */) { - return (importKind === 0 /* Named */ || importKind === 1 /* Default */) && declaration.name.kind === 196 /* ObjectBindingPattern */ + if (declaration.kind === 251 /* VariableDeclaration */) { + return (importKind === 0 /* Named */ || importKind === 1 /* Default */) && declaration.name.kind === 198 /* ObjectBindingPattern */ ? { kind: 2 /* AddToExisting */, importClauseOrBindingPattern: declaration.name, importKind: importKind, moduleSpecifier: declaration.initializer.arguments[0].text, canUseTypeOnlyImport: false } : undefined; } var importClause = declaration.importClause; - if (!importClause) + if (!importClause || !ts.isStringLiteralLike(declaration.moduleSpecifier)) return undefined; var name = importClause.name, namedBindings = importClause.namedBindings; - return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 264 /* NamedImports */) - ? { kind: 2 /* AddToExisting */, importClauseOrBindingPattern: importClause, importKind: importKind, moduleSpecifier: declaration.moduleSpecifier.getText(), canUseTypeOnlyImport: canUseTypeOnlyImport } + // 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)) + return undefined; + return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 266 /* NamedImports */) + ? { kind: 2 /* AddToExisting */, importClauseOrBindingPattern: importClause, importKind: importKind, moduleSpecifier: declaration.moduleSpecifier.text, canUseTypeOnlyImport: canUseTypeOnlyImport } : undefined; }); } - function getExistingImportDeclarations(_a, checker, sourceFile) { - var moduleSymbol = _a.moduleSymbol, importKind = _a.importKind, exportedSymbolIsTypeOnly = _a.exportedSymbolIsTypeOnly; + function getExistingImportDeclarations(_a, checker, importingFile, compilerOptions) { + var moduleSymbol = _a.moduleSymbol, exportKind = _a.exportKind, exportedSymbolIsTypeOnly = _a.exportedSymbolIsTypeOnly; // Can't use an es6 import for a type in JS. - return exportedSymbolIsTypeOnly && ts.isSourceFileJS(sourceFile) ? ts.emptyArray : ts.mapDefined(sourceFile.imports, function (moduleSpecifier) { + if (exportedSymbolIsTypeOnly && ts.isSourceFileJS(importingFile)) + return ts.emptyArray; + var importKind = getImportKind(importingFile, exportKind, compilerOptions); + return ts.mapDefined(importingFile.imports, function (moduleSpecifier) { var i = ts.importFromModuleSpecifier(moduleSpecifier); - if (ts.isRequireVariableDeclaration(i.parent, /*requireStringLiteralLikeArgument*/ true)) { + if (ts.isRequireVariableDeclaration(i.parent)) { return checker.resolveExternalModuleName(moduleSpecifier) === moduleSymbol ? { declaration: i.parent, importKind: importKind } : undefined; } - if (i.kind === 261 /* ImportDeclaration */ || i.kind === 260 /* ImportEqualsDeclaration */) { + if (i.kind === 263 /* ImportDeclaration */ || i.kind === 262 /* ImportEqualsDeclaration */) { return checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind } : undefined; } }); @@ -137774,45 +142786,29 @@ var ts; // 5. Literally nothing to go on return true; } - function getNewImportInfos(program, sourceFile, position, preferTypeOnlyImport, useRequire, moduleSymbols, host, preferences) { + function getNewImportFixes(program, sourceFile, position, preferTypeOnlyImport, useRequire, moduleSymbols, host, preferences) { var isJs = ts.isSourceFileJS(sourceFile); var compilerOptions = program.getCompilerOptions(); - var allowsImportingSpecifier = createAutoImportFilter(sourceFile, program, host).allowsImportingSpecifier; - var choicesForEachExportingModule = ts.flatMap(moduleSymbols, function (_a) { - var moduleSymbol = _a.moduleSymbol, importKind = _a.importKind, exportedSymbolIsTypeOnly = _a.exportedSymbolIsTypeOnly; - return ts.moduleSpecifiers.getModuleSpecifiers(moduleSymbol, program.getTypeChecker(), compilerOptions, sourceFile, ts.createModuleSpecifierResolutionHost(program, host), preferences) + var moduleSpecifierResolutionHost = ts.createModuleSpecifierResolutionHost(program, host); + return ts.flatMap(moduleSymbols, function (exportInfo) { + return ts.moduleSpecifiers.getModuleSpecifiers(exportInfo.moduleSymbol, program.getTypeChecker(), compilerOptions, sourceFile, moduleSpecifierResolutionHost, preferences) .map(function (moduleSpecifier) { // `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types. - return exportedSymbolIsTypeOnly && isJs - ? { kind: 1 /* ImportType */, moduleSpecifier: moduleSpecifier, position: ts.Debug.checkDefined(position, "position should be defined") } - : { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind, useRequire: useRequire, typeOnly: preferTypeOnlyImport }; + return exportInfo.exportedSymbolIsTypeOnly && isJs && position !== undefined + ? { kind: 1 /* ImportType */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo } + : { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: getImportKind(sourceFile, exportInfo.exportKind, compilerOptions), useRequire: useRequire, typeOnly: preferTypeOnlyImport, exportInfo: exportInfo }; }); }); - // Sort by presence in package.json, then shortest paths first - return ts.sort(choicesForEachExportingModule, function (a, b) { - var allowsImportingA = allowsImportingSpecifier(a.moduleSpecifier); - var allowsImportingB = allowsImportingSpecifier(b.moduleSpecifier); - if (allowsImportingA && !allowsImportingB) { - return -1; - } - if (allowsImportingB && !allowsImportingA) { - return 1; - } - return a.moduleSpecifier.length - b.moduleSpecifier.length; - }); } function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, preferTypeOnlyImport, useRequire, host, preferences) { var existingDeclaration = ts.firstDefined(existingImports, function (info) { return newImportInfoFromExistingSpecifier(info, preferTypeOnlyImport, useRequire); }); - return existingDeclaration ? [existingDeclaration] : getNewImportInfos(program, sourceFile, position, preferTypeOnlyImport, useRequire, exportInfos, host, preferences); + return existingDeclaration ? [existingDeclaration] : getNewImportFixes(program, sourceFile, position, preferTypeOnlyImport, useRequire, exportInfos, host, preferences); } function newImportInfoFromExistingSpecifier(_a, preferTypeOnlyImport, useRequire) { var declaration = _a.declaration, importKind = _a.importKind; - var moduleSpecifier = declaration.kind === 261 /* ImportDeclaration */ ? declaration.moduleSpecifier : - declaration.kind === 249 /* VariableDeclaration */ ? declaration.initializer.arguments[0] : - declaration.moduleReference.kind === 272 /* ExternalModuleReference */ ? declaration.moduleReference.expression : - undefined; - return moduleSpecifier && ts.isStringLiteral(moduleSpecifier) - ? { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier.text, importKind: importKind, typeOnly: preferTypeOnlyImport, useRequire: useRequire } + var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration); + return moduleSpecifier + ? { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind, typeOnly: preferTypeOnlyImport, useRequire: useRequire } : undefined; } function getFixesInfo(context, errorCode, pos, useAutoImportProvider) { @@ -137820,7 +142816,28 @@ var ts; var info = errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code ? getFixesInfoForUMDImport(context, symbolToken) : ts.isIdentifier(symbolToken) ? getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider) : undefined; - return info && __assign(__assign({}, info), { fixes: ts.sort(info.fixes, function (a, b) { return a.kind - b.kind; }) }); + return info && __assign(__assign({}, info), { fixes: sortFixes(info.fixes, context.sourceFile, context.host) }); + } + function sortFixes(fixes, sourceFile, host) { + var allowsImportingSpecifier = ts.createPackageJsonImportFilter(sourceFile, host).allowsImportingSpecifier; + return ts.sort(fixes, function (a, b) { return ts.compareValues(a.kind, b.kind) || compareModuleSpecifiers(a, b, allowsImportingSpecifier); }); + } + function getBestFix(fixes, sourceFile, host) { + // 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 */) { + return fixes[0]; + } + var allowsImportingSpecifier = ts.createPackageJsonImportFilter(sourceFile, host).allowsImportingSpecifier; + return fixes.reduce(function (best, fix) { + return compareModuleSpecifiers(fix, best, allowsImportingSpecifier) === -1 /* LessThan */ ? fix : best; + }); + } + function compareModuleSpecifiers(a, b, allowsImportingSpecifier) { + if (a.kind !== 0 /* UseNamespace */ && b.kind !== 0 /* UseNamespace */) { + return ts.compareBooleans(allowsImportingSpecifier(a.moduleSpecifier), allowsImportingSpecifier(b.moduleSpecifier)) + || ts.compareNumberOfDirectorySeparators(a.moduleSpecifier, b.moduleSpecifier); + } + return 0 /* EqualTo */; } function getFixesInfoForUMDImport(_a, token) { var sourceFile = _a.sourceFile, program = _a.program, host = _a.host, preferences = _a.preferences; @@ -137830,9 +142847,9 @@ var ts; return undefined; var symbol = checker.getAliasedSymbol(umdSymbol); var symbolName = umdSymbol.name; - var exportInfos = [{ moduleSymbol: symbol, importKind: getUmdImportKind(sourceFile, program.getCompilerOptions()), exportedSymbolIsTypeOnly: false }]; + var exportInfos = [{ symbol: umdSymbol, moduleSymbol: symbol, exportKind: 3 /* UMD */, exportedSymbolIsTypeOnly: false, isFromPackageJson: false }]; var useRequire = shouldUseRequire(sourceFile, program); - var fixes = getFixForImport(exportInfos, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, /*preferTypeOnlyImport*/ false, useRequire, program, sourceFile, host, preferences); + var fixes = getImportFixes(exportInfos, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, /*preferTypeOnlyImport*/ false, useRequire, program, sourceFile, host, preferences); return { fixes: fixes, symbolName: symbolName }; } function getUmdSymbol(token, checker) { @@ -137846,6 +142863,16 @@ var ts; ? ts.tryCast(checker.resolveName(checker.getJsxNamespace(parent), ts.isJsxOpeningLikeElement(parent) ? token : parent, 111551 /* Value */, /*excludeGlobals*/ false), ts.isUMDExportSymbol) : undefined; } + function getImportKind(importingFile, exportKind, compilerOptions) { + switch (exportKind) { + case 0 /* Named */: return 0 /* Named */; + case 1 /* Default */: return 1 /* Default */; + case 2 /* ExportEquals */: return getExportEqualsImportKind(importingFile, compilerOptions); + case 3 /* UMD */: return getUmdImportKind(importingFile, compilerOptions); + default: return ts.Debug.assertNever(exportKind); + } + } + codefix.getImportKind = getImportKind; function getUmdImportKind(importingFile, compilerOptions) { // Import a synthetic `default` if enabled. if (ts.getAllowSyntheticDefaultImports(compilerOptions)) { @@ -137875,22 +142902,22 @@ var ts; function getFixesInfoForNonUMDImport(_a, symbolToken, useAutoImportProvider) { var sourceFile = _a.sourceFile, program = _a.program, cancellationToken = _a.cancellationToken, host = _a.host, preferences = _a.preferences; var checker = program.getTypeChecker(); - var symbolName = getSymbolName(sourceFile, checker, symbolToken); + var compilerOptions = program.getCompilerOptions(); + var symbolName = getSymbolName(sourceFile, checker, symbolToken, compilerOptions); // "default" is a keyword and not a legal identifier for the import, so we don't expect it here ts.Debug.assert(symbolName !== "default" /* Default */, "'default' isn't a legal identifier and couldn't occur here"); - var compilerOptions = program.getCompilerOptions(); var preferTypeOnlyImport = compilerOptions.importsNotUsedAsValues === 2 /* Error */ && ts.isValidTypeOnlyAliasUseSite(symbolToken); var useRequire = shouldUseRequire(sourceFile, program); var exportInfos = getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host); var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfos.entries(), function (_a) { var _ = _a[0], exportInfos = _a[1]; - return getFixForImport(exportInfos, symbolName, symbolToken.getStart(sourceFile), preferTypeOnlyImport, useRequire, program, sourceFile, host, preferences); + return getImportFixes(exportInfos, symbolName, symbolToken.getStart(sourceFile), preferTypeOnlyImport, useRequire, program, sourceFile, host, preferences); })); return { fixes: fixes, symbolName: symbolName }; } - function getSymbolName(sourceFile, checker, symbolToken) { + function getSymbolName(sourceFile, checker, symbolToken, compilerOptions) { var parent = symbolToken.parent; - if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken) { + if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken && compilerOptions.jsx !== 4 /* ReactJSX */ && compilerOptions.jsx !== 5 /* ReactJSXDev */) { var jsxNamespace = checker.getJsxNamespace(sourceFile); if (ts.isIntrinsicJsxName(symbolToken.text) || !checker.resolveName(jsxNamespace, parent, 111551 /* Value */, /*excludeGlobals*/ true)) { return jsxNamespace; @@ -137899,43 +142926,55 @@ var ts; return symbolToken.text; } // Returns a map from an exported symbol's ID to a list of every way it's (re-)exported. - function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, sourceFile, program, useAutoImportProvider, host) { + function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, fromFile, program, useAutoImportProvider, host) { + var _a; // For each original symbol, keep all re-exports of that symbol together so we can call `getCodeActionsForImport` on the whole group at once. // Maps symbol id to info for modules providing that symbol (original export + re-exports). var originalSymbolToExportInfos = ts.createMultiMap(); - function addSymbol(moduleSymbol, exportedSymbol, importKind, checker) { - originalSymbolToExportInfos.add(ts.getUniqueSymbolId(exportedSymbol, checker).toString(), { moduleSymbol: moduleSymbol, importKind: importKind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(exportedSymbol, checker) }); + var packageJsonFilter = ts.createPackageJsonImportFilter(fromFile, host); + var moduleSpecifierCache = (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host); + var getModuleSpecifierResolutionHost = ts.memoizeOne(function (isFromPackageJson) { + return ts.createModuleSpecifierResolutionHost(isFromPackageJson ? host.getPackageJsonAutoImportProvider() : program, host); + }); + function addSymbol(moduleSymbol, toFile, exportedSymbol, exportKind, program, isFromPackageJson) { + var moduleSpecifierResolutionHost = getModuleSpecifierResolutionHost(isFromPackageJson); + if (toFile && ts.isImportableFile(program, fromFile, toFile, packageJsonFilter, moduleSpecifierResolutionHost, moduleSpecifierCache) || + !toFile && packageJsonFilter.allowsImportingAmbientModule(moduleSymbol, moduleSpecifierResolutionHost)) { + var checker = program.getTypeChecker(); + originalSymbolToExportInfos.add(ts.getUniqueSymbolId(exportedSymbol, checker).toString(), { symbol: exportedSymbol, moduleSymbol: moduleSymbol, exportKind: exportKind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(exportedSymbol, checker), isFromPackageJson: isFromPackageJson }); + } } - forEachExternalModuleToImportFrom(program, host, sourceFile, /*filterByPackageJson*/ true, useAutoImportProvider, function (moduleSymbol, _, program) { + forEachExternalModuleToImportFrom(program, host, useAutoImportProvider, function (moduleSymbol, sourceFile, program, isFromPackageJson) { var checker = program.getTypeChecker(); cancellationToken.throwIfCancellationRequested(); var compilerOptions = program.getCompilerOptions(); - var defaultInfo = getDefaultLikeExportInfo(sourceFile, moduleSymbol, checker, compilerOptions); + var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, compilerOptions.target) === symbolName) && symbolHasMeaning(defaultInfo.symbolForMeaning, currentTokenMeaning)) { - addSymbol(moduleSymbol, defaultInfo.symbol, defaultInfo.kind, checker); + addSymbol(moduleSymbol, sourceFile, defaultInfo.symbol, defaultInfo.exportKind, program, isFromPackageJson); } // check exports with the same name var exportSymbolWithIdenticalName = checker.tryGetMemberInModuleExportsAndProperties(symbolName, moduleSymbol); if (exportSymbolWithIdenticalName && symbolHasMeaning(exportSymbolWithIdenticalName, currentTokenMeaning)) { - addSymbol(moduleSymbol, exportSymbolWithIdenticalName, 0 /* Named */, checker); + addSymbol(moduleSymbol, sourceFile, exportSymbolWithIdenticalName, 0 /* Named */, program, isFromPackageJson); } }); return originalSymbolToExportInfos; } - function getDefaultLikeExportInfo(importingFile, moduleSymbol, checker, compilerOptions) { - var exported = getDefaultLikeExportWorker(importingFile, moduleSymbol, checker, compilerOptions); + function getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions) { + var exported = getDefaultLikeExportWorker(moduleSymbol, checker); if (!exported) return undefined; - var symbol = exported.symbol, kind = exported.kind; - var info = getDefaultExportInfoWorker(symbol, moduleSymbol, checker, compilerOptions); - return info && __assign({ symbol: symbol, kind: kind }, info); + var symbol = exported.symbol, exportKind = exported.exportKind; + var info = getDefaultExportInfoWorker(symbol, checker, compilerOptions); + return info && __assign({ symbol: symbol, exportKind: exportKind }, info); } - function getDefaultLikeExportWorker(importingFile, moduleSymbol, checker, compilerOptions) { + 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); if (defaultExport) - return { symbol: defaultExport, kind: 1 /* Default */ }; - var exportEquals = checker.resolveExternalModuleSymbol(moduleSymbol); - return exportEquals === moduleSymbol ? undefined : { symbol: exportEquals, kind: getExportEqualsImportKind(importingFile, compilerOptions) }; + return { symbol: defaultExport, exportKind: 1 /* Default */ }; } function getExportEqualsImportKind(importingFile, compilerOptions) { var allowSyntheticDefaults = ts.getAllowSyntheticDefaultImports(compilerOptions); @@ -137954,7 +142993,8 @@ var ts; // on how to handle it. for (var _i = 0, _a = importingFile.statements; _i < _a.length; _i++) { var statement = _a[_i]; - if (ts.isImportEqualsDeclaration(statement)) { + // `import foo` parses as an ImportEqualsDeclaration even though it could be an ImportDeclaration + if (ts.isImportEqualsDeclaration(statement) && !ts.nodeIsMissing(statement.moduleReference)) { return 3 /* CommonJS */; } } @@ -137962,7 +143002,7 @@ var ts; // allowSyntheticDefaultImports/esModuleInterop is enabled. return allowSyntheticDefaults ? 1 /* Default */ : 3 /* CommonJS */; } - function getDefaultExportInfoWorker(defaultExport, moduleSymbol, checker, compilerOptions) { + function getDefaultExportInfoWorker(defaultExport, checker, compilerOptions) { var localSymbol = ts.getLocalSymbolForExportDefault(defaultExport); if (localSymbol) return { symbolForMeaning: localSymbol, name: localSymbol.name }; @@ -137976,21 +143016,20 @@ var ts; // but we can still offer completions for it. // - `aliased.parent` will be undefined if the module is exporting `globalThis.something`, // or another expression that resolves to a global. - return getDefaultExportInfoWorker(aliased, aliased.parent, checker, compilerOptions); + return getDefaultExportInfoWorker(aliased, checker, compilerOptions); } } if (defaultExport.escapedName !== "default" /* Default */ && defaultExport.escapedName !== "export=" /* ExportEquals */) { return { symbolForMeaning: defaultExport, name: defaultExport.getName() }; } - return { symbolForMeaning: defaultExport, name: moduleSymbolToValidIdentifier(moduleSymbol, compilerOptions.target) }; + return { symbolForMeaning: defaultExport, name: ts.getNameForExportedSymbol(defaultExport, compilerOptions.target) }; } function getNameForExportDefault(symbol) { return symbol.declarations && ts.firstDefined(symbol.declarations, function (declaration) { + var _a; if (ts.isExportAssignment(declaration)) { - if (ts.isIdentifier(declaration.expression)) { - return declaration.expression.text; - } + 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"); @@ -138033,7 +143072,7 @@ var ts; } } function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports, canUseTypeOnlyImport) { - if (clause.kind === 196 /* ObjectBindingPattern */) { + if (clause.kind === 198 /* ObjectBindingPattern */) { if (defaultImport) { addElementToBindingPattern(clause, defaultImport, "default"); } @@ -138160,48 +143199,23 @@ var ts; var declarations = _a.declarations; return ts.some(declarations, function (decl) { return !!(ts.getMeaningFromDeclaration(decl) & meaning); }); } - function forEachExternalModuleToImportFrom(program, host, from, filterByPackageJson, useAutoImportProvider, cb) { + function forEachExternalModuleToImportFrom(program, host, useAutoImportProvider, cb) { var _a, _b; - forEachExternalModuleToImportFromInProgram(program, host, from, filterByPackageJson, function (module, file) { return cb(module, file, program, /*isFromPackageJson*/ false); }); + forEachExternalModule(program.getTypeChecker(), program.getSourceFiles(), function (module, file) { return cb(module, file, program, /*isFromPackageJson*/ false); }); var autoImportProvider = useAutoImportProvider && ((_a = host.getPackageJsonAutoImportProvider) === null || _a === void 0 ? void 0 : _a.call(host)); if (autoImportProvider) { var start = ts.timestamp(); - forEachExternalModuleToImportFromInProgram(autoImportProvider, host, from, filterByPackageJson, function (module, file) { return cb(module, file, autoImportProvider, /*isFromPackageJson*/ true); }); + forEachExternalModule(autoImportProvider.getTypeChecker(), autoImportProvider.getSourceFiles(), 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)); } } codefix.forEachExternalModuleToImportFrom = forEachExternalModuleToImportFrom; - function forEachExternalModuleToImportFromInProgram(program, host, from, filterByPackageJson, cb) { - var _a; - var filteredCount = 0; - var moduleSpecifierResolutionHost = ts.createModuleSpecifierResolutionHost(program, host); - var packageJson = filterByPackageJson && createAutoImportFilter(from, program, host, moduleSpecifierResolutionHost); - forEachExternalModule(program.getTypeChecker(), program.getSourceFiles(), function (module, sourceFile) { - if (sourceFile === undefined) { - if (!packageJson || packageJson.allowsImportingAmbientModule(module)) { - cb(module, sourceFile); - } - else if (packageJson) { - filteredCount++; - } - } - else if (sourceFile && - sourceFile !== from && - isImportableFile(program, from, sourceFile, moduleSpecifierResolutionHost)) { - if (!packageJson || packageJson.allowsImportingSourceFile(sourceFile)) { - cb(module, sourceFile); - } - else if (packageJson) { - filteredCount++; - } - } - }); - (_a = host.log) === null || _a === void 0 ? void 0 : _a.call(host, "forEachExternalModuleToImportFrom: filtered out " + filteredCount + " modules by package.json contents"); - } function forEachExternalModule(checker, allSourceFiles, cb) { for (var _i = 0, _a = checker.getAmbientModules(); _i < _a.length; _i++) { var ambient = _a[_i]; - cb(ambient, /*sourceFile*/ undefined); + if (!ts.stringContains(ambient.name, "*")) { + cb(ambient, /*sourceFile*/ undefined); + } } for (var _b = 0, allSourceFiles_1 = allSourceFiles; _b < allSourceFiles_1.length; _b++) { var sourceFile = allSourceFiles_1[_b]; @@ -138210,31 +143224,6 @@ var ts; } } } - function isImportableFile(program, from, to, moduleSpecifierResolutionHost) { - var _a; - var getCanonicalFileName = ts.hostGetCanonicalFileName(moduleSpecifierResolutionHost); - var globalTypingsCache = (_a = moduleSpecifierResolutionHost.getGlobalTypingsCacheLocation) === null || _a === void 0 ? void 0 : _a.call(moduleSpecifierResolutionHost); - return !!ts.moduleSpecifiers.forEachFileNameOfModule(from.fileName, to.fileName, moduleSpecifierResolutionHost, - /*preferSymlinks*/ false, function (toPath) { - var toFile = program.getSourceFile(toPath); - // Determine to import using toPath only if toPath is what we were looking at - // or there doesnt exist the file in the program by the symlink - return (toFile === to || !toFile) && - isImportablePath(from.fileName, toPath, getCanonicalFileName, globalTypingsCache); - }); - } - /** - * Don't include something from a `node_modules` that isn't actually reachable by a global import. - * A relative import to node_modules is usually a bad idea. - */ - function isImportablePath(fromPath, toPath, getCanonicalFileName, globalCachePath) { - // If it's in a `node_modules` but is not reachable from here via a global import, don't bother. - var toNodeModules = ts.forEachAncestorDirectory(toPath, function (ancestor) { return ts.getBaseFileName(ancestor) === "node_modules" ? ancestor : undefined; }); - var toNodeModulesParent = toNodeModules && ts.getDirectoryPath(getCanonicalFileName(toNodeModules)); - return toNodeModulesParent === undefined - || ts.startsWith(getCanonicalFileName(fromPath), toNodeModulesParent) - || (!!globalCachePath && ts.startsWith(getCanonicalFileName(globalCachePath), toNodeModulesParent)); - } function moduleSymbolToValidIdentifier(moduleSymbol, target) { return moduleSpecifierToValidIdentifier(ts.removeFileExtension(ts.stripQuotes(moduleSymbol.name)), target); } @@ -138266,99 +143255,122 @@ var ts; return !ts.isStringANonContextualKeyword(res) ? res || "_" : "_" + res; } codefix.moduleSpecifierToValidIdentifier = moduleSpecifierToValidIdentifier; - function createAutoImportFilter(fromFile, program, host, moduleSpecifierResolutionHost) { - if (moduleSpecifierResolutionHost === void 0) { moduleSpecifierResolutionHost = ts.createModuleSpecifierResolutionHost(program, host); } - var packageJsons = ((host.getPackageJsonsVisibleToFile && host.getPackageJsonsVisibleToFile(fromFile.fileName)) || ts.getPackageJsonsVisibleToFile(fromFile.fileName, host)).filter(function (p) { return p.parseable; }); - var usesNodeCoreModules; - return { allowsImportingAmbientModule: allowsImportingAmbientModule, allowsImportingSourceFile: allowsImportingSourceFile, allowsImportingSpecifier: allowsImportingSpecifier, moduleSpecifierResolutionHost: moduleSpecifierResolutionHost }; - function moduleSpecifierIsCoveredByPackageJson(specifier) { - var packageName = getNodeModuleRootSpecifier(specifier); - for (var _i = 0, packageJsons_1 = packageJsons; _i < packageJsons_1.length; _i++) { - var packageJson = packageJsons_1[_i]; - if (packageJson.has(packageName) || packageJson.has(ts.getTypesPackageName(packageName))) { - return true; + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var codefix; + (function (codefix) { + var _a; + var fixName = "fixOverrideModifier"; + var fixAddOverrideId = "fixAddOverrideModifier"; + var fixRemoveOverrideId = "fixRemoveOverrideModifier"; + var errorCodes = [ + ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0.code, + ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class.code, + ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0.code, + ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0.code, + ts.Diagnostics.This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0.code + ]; + var errorCodeFixIdMap = (_a = {}, + _a[ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0.code] = [ + ts.Diagnostics.Add_override_modifier, fixAddOverrideId, ts.Diagnostics.Add_all_missing_override_modifiers, + ], + _a[ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class.code] = [ + ts.Diagnostics.Remove_override_modifier, fixRemoveOverrideId, ts.Diagnostics.Remove_all_unnecessary_override_modifiers + ], + _a[ts.Diagnostics.This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0.code] = [ + ts.Diagnostics.Add_override_modifier, fixAddOverrideId, ts.Diagnostics.Add_all_missing_override_modifiers, + ], + _a[ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0.code] = [ + ts.Diagnostics.Add_override_modifier, fixAddOverrideId, ts.Diagnostics.Remove_all_unnecessary_override_modifiers + ], + _a[ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0.code] = [ + ts.Diagnostics.Remove_override_modifier, fixRemoveOverrideId, ts.Diagnostics.Remove_all_unnecessary_override_modifiers + ], + _a); + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var errorCode = context.errorCode, span = context.span, sourceFile = context.sourceFile; + var info = errorCodeFixIdMap[errorCode]; + if (!info) + return ts.emptyArray; + var descriptions = info[0], fixId = info[1], fixAllDescriptions = info[2]; + if (ts.isSourceFileJS(sourceFile)) + return ts.emptyArray; + var changes = ts.textChanges.ChangeTracker.with(context, function (changes) { return dispatchChanges(changes, context, errorCode, span.start); }); + return [ + codefix.createCodeFixActionMaybeFixAll(fixName, changes, descriptions, fixId, fixAllDescriptions) + ]; + }, + fixIds: [fixName, fixAddOverrideId, fixRemoveOverrideId], + getAllCodeActions: function (context) { + return codefix.codeFixAll(context, errorCodes, function (changes, diag) { + var code = diag.code, start = diag.start, file = diag.file; + var info = errorCodeFixIdMap[code]; + if (!info || info[1] !== context.fixId || ts.isSourceFileJS(file)) { + return; } - } - return false; - } - function allowsImportingAmbientModule(moduleSymbol) { - if (!packageJsons.length) { - return true; - } - var declaringSourceFile = moduleSymbol.valueDeclaration.getSourceFile(); - var declaringNodeModuleName = getNodeModulesPackageNameFromFileName(declaringSourceFile.fileName); - if (typeof declaringNodeModuleName === "undefined") { - return true; - } - var declaredModuleSpecifier = ts.stripQuotes(moduleSymbol.getName()); - if (isAllowedCoreNodeModulesImport(declaredModuleSpecifier)) { - return true; - } - return moduleSpecifierIsCoveredByPackageJson(declaringNodeModuleName) - || moduleSpecifierIsCoveredByPackageJson(declaredModuleSpecifier); - } - function allowsImportingSourceFile(sourceFile) { - if (!packageJsons.length) { - return true; - } - var moduleSpecifier = getNodeModulesPackageNameFromFileName(sourceFile.fileName); - if (!moduleSpecifier) { - return true; - } - return moduleSpecifierIsCoveredByPackageJson(moduleSpecifier); + dispatchChanges(changes, context, code, start); + }); } - /** - * Use for a specific module specifier that has already been resolved. - * Use `allowsImportingAmbientModule` or `allowsImportingSourceFile` to resolve - * the best module specifier for a given module _and_ determine if it’s importable. - */ - function allowsImportingSpecifier(moduleSpecifier) { - if (!packageJsons.length || isAllowedCoreNodeModulesImport(moduleSpecifier)) { - return true; - } - if (ts.pathIsRelative(moduleSpecifier) || ts.isRootedDiskPath(moduleSpecifier)) { + }); + function dispatchChanges(changeTracker, context, errorCode, pos) { + switch (errorCode) { + case ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0.code: + case ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0.code: + case ts.Diagnostics.This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0.code: + return doAddOverrideModifierChange(changeTracker, context.sourceFile, pos); + case ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0.code: + case ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class.code: + return doRemoveOverrideModifierChange(changeTracker, context.sourceFile, pos); + default: + ts.Debug.fail("Unexpected error code: " + errorCode); + } + } + function doAddOverrideModifierChange(changeTracker, sourceFile, pos) { + var classElement = findContainerClassElementLike(sourceFile, pos); + var modifiers = classElement.modifiers || ts.emptyArray; + var staticModifier = ts.find(modifiers, ts.isStaticModifier); + var accessibilityModifier = ts.find(modifiers, function (m) { return ts.isAccessibilityModifier(m.kind); }); + var modifierPos = staticModifier ? staticModifier.end : + accessibilityModifier ? accessibilityModifier.end : + classElement.decorators ? ts.skipTrivia(sourceFile.text, classElement.decorators.end) : classElement.getStart(sourceFile); + var options = accessibilityModifier || staticModifier ? { prefix: " " } : { suffix: " " }; + changeTracker.insertModifierAt(sourceFile, modifierPos, 157 /* OverrideKeyword */, options); + } + function doRemoveOverrideModifierChange(changeTracker, sourceFile, pos) { + var classElement = findContainerClassElementLike(sourceFile, pos); + var overrideModifier = classElement.modifiers && ts.find(classElement.modifiers, function (modifier) { return modifier.kind === 157 /* OverrideKeyword */; }); + ts.Debug.assertIsDefined(overrideModifier); + changeTracker.deleteModifier(sourceFile, overrideModifier); + } + function isClassElementLikeHasJSDoc(node) { + switch (node.kind) { + case 168 /* Constructor */: + case 165 /* PropertyDeclaration */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return true; - } - return moduleSpecifierIsCoveredByPackageJson(moduleSpecifier); - } - function isAllowedCoreNodeModulesImport(moduleSpecifier) { - // If we’re in JavaScript, it can be difficult to tell whether the user wants to import - // from Node core modules or not. We can start by seeing if the user is actually using - // any node core modules, as opposed to simply having @types/node accidentally as a - // dependency of a dependency. - if (ts.isSourceFileJS(fromFile) && ts.JsTyping.nodeCoreModules.has(moduleSpecifier)) { - if (usesNodeCoreModules === undefined) { - usesNodeCoreModules = ts.consumesNodeCoreModules(fromFile); - } - if (usesNodeCoreModules) { - return true; - } - } - return false; - } - function getNodeModulesPackageNameFromFileName(importedFileName) { - if (!ts.stringContains(importedFileName, "node_modules")) { - return undefined; - } - var specifier = ts.moduleSpecifiers.getNodeModulesPackageName(host.getCompilationSettings(), fromFile.path, importedFileName, moduleSpecifierResolutionHost); - if (!specifier) { - return undefined; - } - // Paths here are not node_modules, so we don’t care about them; - // returning anything will trigger a lookup in package.json. - if (!ts.pathIsRelative(specifier) && !ts.isRootedDiskPath(specifier)) { - return getNodeModuleRootSpecifier(specifier); - } - } - function getNodeModuleRootSpecifier(fullSpecifier) { - var components = ts.getPathComponents(ts.getPackageNameFromTypesPackageName(fullSpecifier)).slice(1); - // Scoped packages - if (ts.startsWith(components[0], "@")) { - return components[0] + "/" + components[1]; - } - return components[0]; + case 162 /* Parameter */: + return ts.isParameterPropertyDeclaration(node, node.parent); + default: + return false; } } + function findContainerClassElementLike(sourceFile, pos) { + var token = ts.getTokenAtPosition(sourceFile, pos); + var classElement = ts.findAncestor(token, function (node) { + if (ts.isClassLike(node)) + return "quit"; + return isClassElementLikeHasJSDoc(node); + }); + ts.Debug.assert(classElement && isClassElementLikeHasJSDoc(classElement)); + return classElement; + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -138419,12 +143431,12 @@ var ts; }); function doChange(changes, sourceFile, pos, checker) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 107 /* ThisKeyword */); + ts.Debug.assert(token.kind === 108 /* ThisKeyword */); var fn = ts.getThisContainer(token, /*includeArrowFunctions*/ false); 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.assertDefined(ts.findChildOfKind(fn, 97 /* FunctionKeyword */, sourceFile)); + var fnKeyword = ts.Debug.assertDefined(ts.findChildOfKind(fn, 98 /* FunctionKeyword */, sourceFile)); var name = fn.name; var body = ts.Debug.assertDefined(fn.body); // Should be defined because the function contained a 'this' expression if (ts.isFunctionExpression(fn)) { @@ -138443,7 +143455,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(84 /* ConstKeyword */)); + changes.replaceNode(sourceFile, fnKeyword, ts.factory.createToken(85 /* ConstKeyword */)); changes.insertText(sourceFile, name.end, " = "); changes.insertText(sourceFile, body.pos, " =>"); return [ts.Diagnostics.Convert_function_declaration_0_to_arrow_function, name.text]; @@ -138474,7 +143486,7 @@ var ts; }); function getNamedTupleMember(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - return ts.findAncestor(token, function (t) { return t.kind === 192 /* NamedTupleMember */; }); + return ts.findAncestor(token, function (t) { return t.kind === 194 /* NamedTupleMember */; }); } function doChange(changes, sourceFile, namedTupleMember) { if (!namedTupleMember) { @@ -138483,11 +143495,11 @@ var ts; var unwrappedType = namedTupleMember.type; var sawOptional = false; var sawRest = false; - while (unwrappedType.kind === 180 /* OptionalType */ || unwrappedType.kind === 181 /* RestType */ || unwrappedType.kind === 186 /* ParenthesizedType */) { - if (unwrappedType.kind === 180 /* OptionalType */) { + while (unwrappedType.kind === 182 /* OptionalType */ || unwrappedType.kind === 183 /* RestType */ || unwrappedType.kind === 188 /* ParenthesizedType */) { + if (unwrappedType.kind === 182 /* OptionalType */) { sawOptional = true; } - else if (unwrappedType.kind === 181 /* RestType */) { + else if (unwrappedType.kind === 183 /* RestType */) { sawRest = true; } unwrappedType = unwrappedType.type; @@ -138551,7 +143563,7 @@ var ts; var checker = context.program.getTypeChecker(); var suggestedSymbol; if (ts.isPropertyAccessExpression(parent) && parent.name === node) { - ts.Debug.assert(ts.isIdentifierOrPrivateIdentifier(node), "Expected an identifier for spelling (property access)"); + ts.Debug.assert(ts.isMemberName(node), "Expected an identifier for spelling (property access)"); var containingType = checker.getTypeAtLocation(parent.expression); if (parent.flags & 32 /* OptionalChain */) { containingType = checker.getNonNullableType(containingType); @@ -138590,7 +143602,7 @@ var ts; var suggestion = ts.symbolName(suggestedSymbol); if (!ts.isIdentifierText(suggestion, target) && ts.isPropertyAccessExpression(node.parent)) { var valDecl = suggestedSymbol.valueDeclaration; - if (ts.isNamedDeclaration(valDecl) && ts.isPrivateIdentifier(valDecl.name)) { + if (valDecl && ts.isNamedDeclaration(valDecl) && ts.isPrivateIdentifier(valDecl.name)) { changes.replaceNode(sourceFile, node, ts.factory.createIdentifier(suggestion)); } else { @@ -138787,19 +143799,19 @@ var ts; } function getVariableLikeInitializer(declaration) { switch (declaration.kind) { - case 249 /* VariableDeclaration */: - case 160 /* Parameter */: - case 198 /* BindingElement */: - case 163 /* PropertyDeclaration */: - case 288 /* PropertyAssignment */: + case 251 /* VariableDeclaration */: + case 162 /* Parameter */: + case 200 /* BindingElement */: + case 165 /* PropertyDeclaration */: + case 290 /* PropertyAssignment */: return declaration.initializer; - case 280 /* JsxAttribute */: + case 282 /* JsxAttribute */: return declaration.initializer && (ts.isJsxExpression(declaration.initializer) ? declaration.initializer.expression : undefined); - case 289 /* ShorthandPropertyAssignment */: - case 162 /* PropertySignature */: - case 291 /* EnumMember */: - case 333 /* JSDocPropertyTag */: - case 326 /* JSDocParameterTag */: + case 291 /* ShorthandPropertyAssignment */: + case 164 /* PropertySignature */: + case 293 /* EnumMember */: + case 341 /* JSDocPropertyTag */: + case 334 /* JSDocParameterTag */: return undefined; } } @@ -138900,7 +143912,7 @@ var ts; }); typeDeclToMembers.forEach(function (infos, classDeclaration) { var supers = codefix.getAllSupers(classDeclaration, checker); - var _loop_13 = function (info) { + var _loop_14 = function (info) { // If some superclass added this property, don't add it again. if (supers.some(function (superClassOrInterface) { var superInfos = typeDeclToMembers.get(superClassOrInterface); @@ -138925,9 +143937,9 @@ var ts; } } }; - for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) { - var info = infos_1[_i]; - _loop_13(info); + for (var _i = 0, infos_2 = infos; _i < infos_2.length; _i++) { + var info = infos_2[_i]; + _loop_14(info); } }); })); @@ -139017,7 +144029,7 @@ var ts; function addMissingMemberInJs(changeTracker, declSourceFile, classDeclaration, token, makeStatic) { var tokenName = token.text; if (makeStatic) { - if (classDeclaration.kind === 221 /* ClassExpression */) { + if (classDeclaration.kind === 223 /* ClassExpression */) { return; } var className = classDeclaration.name.getText(); @@ -139069,17 +144081,17 @@ var ts; } function getTypeNode(checker, classDeclaration, token) { var typeNode; - if (token.parent.parent.kind === 216 /* BinaryExpression */) { + if (token.parent.parent.kind === 218 /* 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, classDeclaration, /*flags*/ undefined); + typeNode = checker.typeToTypeNode(widenedType, classDeclaration, 1 /* NoTruncation */); } else { var contextualType = checker.getContextualType(token.parent); - typeNode = contextualType ? checker.typeToTypeNode(contextualType, /*enclosingDeclaration*/ undefined, /*flags*/ undefined) : undefined; + typeNode = contextualType ? checker.typeToTypeNode(contextualType, /*enclosingDeclaration*/ undefined, 1 /* NoTruncation */) : undefined; } - return typeNode || ts.factory.createKeywordTypeNode(128 /* AnyKeyword */); + return typeNode || ts.factory.createKeywordTypeNode(129 /* AnyKeyword */); } function addPropertyDeclaration(changeTracker, declSourceFile, classDeclaration, tokenName, typeNode, modifierFlags) { var property = ts.factory.createPropertyDeclaration( @@ -139108,7 +144120,7 @@ var ts; } function createAddIndexSignatureAction(context, declSourceFile, classDeclaration, tokenName, typeNode) { // Index signatures cannot have the static modifier. - var stringTypeNode = ts.factory.createKeywordTypeNode(147 /* StringKeyword */); + var stringTypeNode = ts.factory.createKeywordTypeNode(148 /* StringKeyword */); var indexingParameter = ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -139141,7 +144153,7 @@ var ts; } function addMethodDeclaration(context, changes, callExpression, name, modifierFlags, parentDeclaration, sourceFile) { var importAdder = codefix.createImportAdder(sourceFile, context.program, context.preferences, context.host); - var methodDeclaration = codefix.createSignatureDeclarationFromCallExpression(165 /* MethodDeclaration */, context, importAdder, callExpression, name, modifierFlags, parentDeclaration); + var methodDeclaration = codefix.createSignatureDeclarationFromCallExpression(167 /* MethodDeclaration */, context, importAdder, callExpression, name, modifierFlags, parentDeclaration); var containingMethodDeclaration = ts.findAncestor(callExpression, function (n) { return ts.isMethodDeclaration(n) || ts.isConstructorDeclaration(n); }); if (containingMethodDeclaration && containingMethodDeclaration.parent === parentDeclaration) { changes.insertNodeAfter(sourceFile, containingMethodDeclaration, methodDeclaration); @@ -139170,7 +144182,7 @@ var ts; } function addFunctionDeclaration(changes, context, info) { var importAdder = codefix.createImportAdder(context.sourceFile, context.program, context.preferences, context.host); - var functionDeclaration = codefix.createSignatureDeclarationFromCallExpression(251 /* FunctionDeclaration */, context, importAdder, info.call, info.token, info.modifierFlags, info.parentDeclaration); + var functionDeclaration = codefix.createSignatureDeclarationFromCallExpression(253 /* FunctionDeclaration */, context, importAdder, info.call, ts.idText(info.token), info.modifierFlags, info.parentDeclaration); changes.insertNodeAtEndOfScope(info.sourceFile, info.parentDeclaration, functionDeclaration); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -139257,7 +144269,10 @@ var ts; return { type: "install package", file: fileName, packageName: packageName }; } function tryGetImportedPackageName(sourceFile, pos) { - var moduleName = ts.cast(ts.getTokenAtPosition(sourceFile, pos), ts.isStringLiteral).text; + var moduleSpecifierText = ts.tryCast(ts.getTokenAtPosition(sourceFile, pos), ts.isStringLiteral); + if (!moduleSpecifierText) + return undefined; + var moduleName = moduleSpecifierText.text; var packageName = ts.parsePackageName(moduleName).packageName; return ts.isExternalModuleNameRelative(packageName) ? undefined : packageName; } @@ -139363,7 +144378,7 @@ var ts; } function getNodes(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - if (token.kind !== 107 /* ThisKeyword */) + if (token.kind !== 108 /* ThisKeyword */) return undefined; var constructor = ts.getContainingFunction(token); var superCall = findSuperCall(constructor.body); @@ -139487,7 +144502,10 @@ var ts; var codefix; (function (codefix) { codefix.registerCodeFix({ - errorCodes: [ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher.code], + errorCodes: [ + ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher.code, + ts.Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher.code, + ], getCodeActions: function (context) { var compilerOptions = context.program.getCompilerOptions(); var configFile = compilerOptions.configFile; @@ -139583,14 +144601,14 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, pos); var heritageClauses = ts.getContainingClass(token).heritageClauses; var extendsToken = heritageClauses[0].getFirstToken(); - return extendsToken.kind === 93 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; + return extendsToken.kind === 94 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; } function doChanges(changes, sourceFile, extendsToken, heritageClauses) { - changes.replaceNode(sourceFile, extendsToken, ts.factory.createToken(116 /* ImplementsKeyword */)); + changes.replaceNode(sourceFile, extendsToken, ts.factory.createToken(117 /* ImplementsKeyword */)); // If there is already an implements clause, replace the implements keyword with a comma. if (heritageClauses.length === 2 && - heritageClauses[0].token === 93 /* ExtendsKeyword */ && - heritageClauses[1].token === 116 /* ImplementsKeyword */) { + heritageClauses[0].token === 94 /* ExtendsKeyword */ && + heritageClauses[1].token === 117 /* ImplementsKeyword */) { var implementsToken = heritageClauses[1].getFirstToken(); var implementsFullStart = implementsToken.getFullStart(); changes.replaceRange(sourceFile, { pos: implementsFullStart, end: implementsFullStart }, ts.factory.createToken(27 /* CommaToken */)); @@ -139766,7 +144784,7 @@ var ts; ]; } var result = []; - if (token.kind === 135 /* InferKeyword */) { + if (token.kind === 136 /* 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)); @@ -139808,7 +144826,7 @@ var ts; break; } case fixIdDelete: { - if (token.kind === 135 /* InferKeyword */ || isImport(token)) { + if (token.kind === 136 /* InferKeyword */ || isImport(token)) { break; // Can't delete } else if (ts.isJSDocTemplateTag(token)) { @@ -139837,7 +144855,7 @@ var ts; break; } case fixIdInfer: - if (token.kind === 135 /* InferKeyword */) { + if (token.kind === 136 /* InferKeyword */) { changeInferToUnknown(changes, sourceFile, token); } break; @@ -139848,7 +144866,7 @@ var ts; }, }); function changeInferToUnknown(changes, sourceFile, token) { - changes.replaceNode(sourceFile, token.parent, ts.factory.createKeywordTypeNode(152 /* UnknownKeyword */)); + changes.replaceNode(sourceFile, token.parent, ts.factory.createKeywordTypeNode(153 /* UnknownKeyword */)); } function createDeleteFix(changes, diag) { return codefix.createCodeFixAction(fixName, changes, diag, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations); @@ -139857,18 +144875,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 === 99 /* ImportKeyword */ - || token.kind === 78 /* Identifier */ && (token.parent.kind === 265 /* ImportSpecifier */ || token.parent.kind === 262 /* ImportClause */); + return token.kind === 100 /* ImportKeyword */ + || token.kind === 79 /* Identifier */ && (token.parent.kind === 267 /* ImportSpecifier */ || token.parent.kind === 264 /* ImportClause */); } /** Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing. */ function tryGetFullImport(token) { - return token.kind === 99 /* ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; + return token.kind === 100 /* 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 === 232 /* VariableStatement */ ? node.parent : node); + changes.delete(sourceFile, node.parent.kind === 234 /* VariableStatement */ ? node.parent : node); } function deleteDestructuringElements(changes, sourceFile, node) { ts.forEach(node.elements, function (n) { return changes.delete(sourceFile, n); }); @@ -139877,7 +144895,7 @@ 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 === 135 /* InferKeyword */) { + if (token.kind === 136 /* InferKeyword */) { token = ts.cast(token.parent, ts.isInferTypeNode).typeParameter.name; } if (ts.isIdentifier(token) && canPrefix(token)) { @@ -139893,14 +144911,14 @@ var ts; } function canPrefix(token) { switch (token.parent.kind) { - case 160 /* Parameter */: - case 159 /* TypeParameter */: + case 162 /* Parameter */: + case 161 /* TypeParameter */: return true; - case 249 /* VariableDeclaration */: { + case 251 /* VariableDeclaration */: { var varDecl = token.parent; switch (varDecl.parent.parent.kind) { - case 239 /* ForOfStatement */: - case 238 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 240 /* ForInStatement */: return true; } } @@ -139924,8 +144942,10 @@ var ts; if (ts.isParameter(parent)) { tryDeleteParameter(changes, sourceFile, parent, checker, sourceFiles, program, cancellationToken, isFixAll); } - else if (!isFixAll || !(ts.isIdentifier(token) && ts.FindAllReferences.Core.isSymbolReferencedInFile(token, checker, sourceFile))) { - changes.delete(sourceFile, ts.isImportClause(parent) ? token : ts.isComputedPropertyName(parent) ? parent.parent : parent); + else if (!(isFixAll && ts.isIdentifier(token) && ts.FindAllReferences.Core.isSymbolReferencedInFile(token, checker, sourceFile))) { + var node = ts.isImportClause(parent) ? token : ts.isComputedPropertyName(parent) ? parent.parent : parent; + ts.Debug.assert(node !== sourceFile, "should not delete whole source file"); + changes.delete(sourceFile, node); } } function tryDeleteParameter(changes, sourceFile, parameter, checker, sourceFiles, program, cancellationToken, isFixAll) { @@ -139948,8 +144968,8 @@ var ts; function mayDeleteParameter(checker, sourceFile, parameter, sourceFiles, program, cancellationToken, isFixAll) { var parent = parameter.parent; switch (parent.kind) { - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: + case 167 /* MethodDeclaration */: + case 168 /* 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); @@ -139979,17 +144999,17 @@ var ts; } } return true; - case 251 /* FunctionDeclaration */: { + case 253 /* FunctionDeclaration */: { if (parent.name && isCallbackLike(checker, sourceFile, parent.name)) { return isLastParameter(parent, parameter, isFixAll); } return true; } - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 210 /* FunctionExpression */: + case 211 /* 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 168 /* SetAccessor */: + case 170 /* SetAccessor */: // Setter must have a parameter return false; default: @@ -140047,7 +145067,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 234 /* IfStatement */: + case 236 /* IfStatement */: if (container.elseStatement) { if (ts.isBlock(statement.parent)) { break; @@ -140058,8 +145078,8 @@ var ts; return; } // falls through - case 236 /* WhileStatement */: - case 237 /* ForStatement */: + case 238 /* WhileStatement */: + case 239 /* ForStatement */: changes.delete(sourceFile, container); return; } @@ -140132,7 +145152,7 @@ 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 === 305 /* JSDocNullableType */) { + if (typeNode.kind === 308 /* 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)); @@ -140152,7 +145172,7 @@ var ts; if (!info) return; var typeNode = info.typeNode, type = info.type; - var fixedType = typeNode.kind === 305 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; + var fixedType = typeNode.kind === 308 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; doChange(changes, sourceFile, typeNode, fixedType, checker); }); } @@ -140169,22 +145189,22 @@ var ts; // NOTE: Some locations are not handled yet: // MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments switch (node.kind) { - case 224 /* AsExpression */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 251 /* FunctionDeclaration */: - case 167 /* GetAccessor */: - case 171 /* IndexSignature */: - case 190 /* MappedType */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 160 /* Parameter */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 168 /* SetAccessor */: - case 254 /* TypeAliasDeclaration */: - case 206 /* TypeAssertionExpression */: - case 249 /* VariableDeclaration */: + case 226 /* AsExpression */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 253 /* FunctionDeclaration */: + case 169 /* GetAccessor */: + case 173 /* IndexSignature */: + case 192 /* MappedType */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 162 /* Parameter */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 170 /* SetAccessor */: + case 256 /* TypeAliasDeclaration */: + case 208 /* TypeAssertionExpression */: + case 251 /* VariableDeclaration */: return true; default: return false; @@ -140199,7 +145219,7 @@ var ts; (function (codefix) { var fixId = "fixMissingCallParentheses"; var errorCodes = [ - ts.Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead.code, + ts.Diagnostics.This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_instead.code, ]; codefix.registerCodeFix({ errorCodes: errorCodes, @@ -140245,7 +145265,7 @@ var ts; var fixId = "fixAwaitInSyncFunction"; var errorCodes = [ ts.Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code, - ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator.code, + ts.Diagnostics.for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code, ]; codefix.registerCodeFix({ errorCodes: errorCodes, @@ -140286,14 +145306,14 @@ var ts; } var insertBefore; switch (containingFunction.kind) { - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: insertBefore = containingFunction.name; break; - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - insertBefore = ts.findChildOfKind(containingFunction, 97 /* FunctionKeyword */, sourceFile); + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + insertBefore = ts.findChildOfKind(containingFunction, 98 /* FunctionKeyword */, sourceFile); break; - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: insertBefore = ts.findChildOfKind(containingFunction, 20 /* OpenParenToken */, sourceFile) || ts.first(containingFunction.parameters); break; default: @@ -140308,11 +145328,11 @@ var ts; var insertBefore = _a.insertBefore, returnType = _a.returnType; if (returnType) { var entityName = ts.getEntityNameFromTypeNode(returnType); - if (!entityName || entityName.kind !== 78 /* Identifier */ || entityName.text !== "Promise") { + if (!entityName || entityName.kind !== 79 /* Identifier */ || entityName.text !== "Promise") { changes.replaceNode(sourceFile, returnType, ts.factory.createTypeReferenceNode("Promise", ts.factory.createNodeArray([returnType]))); } } - changes.insertModifierBefore(sourceFile, 129 /* AsyncKeyword */, insertBefore); + changes.insertModifierBefore(sourceFile, 130 /* AsyncKeyword */, insertBefore); } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -140472,7 +145492,7 @@ var ts; return errorCode; } function doChange(changes, sourceFile, token, errorCode, program, cancellationToken, markSeen, host, preferences) { - if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 78 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 107 /* ThisKeyword */) { + if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 79 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 108 /* ThisKeyword */) { return undefined; } var parent = token.parent; @@ -140492,7 +145512,7 @@ var ts; var typeNode = ts.getTypeNodeIfAccessible(type, parent, program, host); if (typeNode) { // Note that the codefix will never fire with an existing `@type` tag, so there is no need to merge tags - var typeTag = ts.factory.createJSDocTypeTag(/*tagName*/ undefined, ts.factory.createJSDocTypeExpression(typeNode), /*comment*/ ""); + var typeTag = ts.factory.createJSDocTypeTag(/*tagName*/ undefined, ts.factory.createJSDocTypeExpression(typeNode), /*comment*/ undefined); addJSDocTags(changes, sourceFile, ts.cast(parent.parent.parent, ts.isExpressionStatement), [typeTag]); } importAdder.writeFixes(changes); @@ -140626,13 +145646,13 @@ 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 !== 162 /* PropertySignature */) { + if (ts.isInJSFile(sourceFile) && declaration.kind !== 164 /* PropertySignature */) { var parent = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : declaration; if (!parent) { return; } var typeExpression = ts.factory.createJSDocTypeExpression(typeNode); - var typeTag = ts.isGetAccessorDeclaration(declaration) ? ts.factory.createJSDocReturnTag(/*tagName*/ undefined, typeExpression, "") : ts.factory.createJSDocTypeTag(/*tagName*/ undefined, typeExpression, ""); + var typeTag = ts.isGetAccessorDeclaration(declaration) ? ts.factory.createJSDocReturnTag(/*tagName*/ undefined, typeExpression, /*comment*/ undefined) : ts.factory.createJSDocTypeTag(/*tagName*/ undefined, typeExpression, /*comment*/ undefined); addJSDocTags(changes, sourceFile, parent, [typeTag]); } else if (!tryReplaceImportTypeNodeWithAutoImport(typeNode, declaration, sourceFile, changes, importAdder, ts.getEmitScriptTarget(program.getCompilerOptions()))) { @@ -140687,13 +145707,13 @@ var ts; else { var paramTags = ts.map(inferences, function (_a) { var name = _a.name, typeNode = _a.typeNode, isOptional = _a.isOptional; - return ts.factory.createJSDocParameterTag(/*tagName*/ undefined, name, /*isBracketed*/ !!isOptional, ts.factory.createJSDocTypeExpression(typeNode), /* isNameFirst */ false, ""); + return ts.factory.createJSDocParameterTag(/*tagName*/ undefined, name, /*isBracketed*/ !!isOptional, ts.factory.createJSDocTypeExpression(typeNode), /* isNameFirst */ false, /*comment*/ undefined); }); addJSDocTags(changes, sourceFile, signature, paramTags); } } function addJSDocTags(changes, sourceFile, parent, newTags) { - var comments = ts.mapDefined(parent.jsDoc, function (j) { return j.comment; }); + var comments = ts.flatMap(parent.jsDoc, function (j) { return typeof j.comment === "string" ? ts.factory.createJSDocText(j.comment) : j.comment; }); var oldTags = ts.flatMapToMutable(parent.jsDoc, function (j) { return j.tags; }); var unmergedNewTags = newTags.filter(function (newTag) { return !oldTags || !oldTags.some(function (tag, i) { var merged = tryMergeJsdocTags(tag, newTag); @@ -140701,15 +145721,15 @@ var ts; oldTags[i] = merged; return !!merged; }); }); - var tag = ts.factory.createJSDocComment(comments.join("\n"), ts.factory.createNodeArray(__spreadArray(__spreadArray([], (oldTags || ts.emptyArray)), unmergedNewTags))); - var jsDocNode = parent.kind === 209 /* ArrowFunction */ ? getJsDocNodeForArrowFunction(parent) : parent; + var tag = ts.factory.createJSDocComment(ts.factory.createNodeArray(ts.intersperse(comments, ts.factory.createJSDocText("\n"))), ts.factory.createNodeArray(__spreadArray(__spreadArray([], (oldTags || ts.emptyArray)), unmergedNewTags))); + var jsDocNode = parent.kind === 211 /* ArrowFunction */ ? getJsDocNodeForArrowFunction(parent) : parent; jsDocNode.jsDoc = parent.jsDoc; jsDocNode.jsDocCache = parent.jsDocCache; changes.insertJsdocCommentBefore(sourceFile, jsDocNode, tag); } codefix.addJSDocTags = addJSDocTags; function getJsDocNodeForArrowFunction(signature) { - if (signature.parent.kind === 163 /* PropertyDeclaration */) { + if (signature.parent.kind === 165 /* PropertyDeclaration */) { return signature.parent; } return signature.parent.parent; @@ -140719,14 +145739,14 @@ var ts; return undefined; } switch (oldTag.kind) { - case 326 /* JSDocParameterTag */: { + case 334 /* 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 327 /* JSDocReturnTag */: + case 335 /* JSDocReturnTag */: return ts.factory.createJSDocReturnTag(/*tagName*/ undefined, newTag.typeExpression, oldTag.comment); } } @@ -140751,19 +145771,19 @@ var ts; function getFunctionReferences(containingFunction, sourceFile, program, cancellationToken) { var searchToken; switch (containingFunction.kind) { - case 166 /* Constructor */: - searchToken = ts.findChildOfKind(containingFunction, 132 /* ConstructorKeyword */, sourceFile); + case 168 /* Constructor */: + searchToken = ts.findChildOfKind(containingFunction, 133 /* ConstructorKeyword */, sourceFile); break; - case 209 /* ArrowFunction */: - case 208 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 210 /* FunctionExpression */: var parent = containingFunction.parent; searchToken = (ts.isVariableDeclaration(parent) || ts.isPropertyDeclaration(parent)) && ts.isIdentifier(parent.name) ? parent.name : containingFunction.name; break; - case 251 /* FunctionDeclaration */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 253 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: searchToken = containingFunction.name; break; } @@ -140905,24 +145925,24 @@ var ts; node = node.parent; } switch (node.parent.kind) { - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: inferTypeFromExpressionStatement(node, usage); break; - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: usage.isNumber = true; break; - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: inferTypeFromPrefixUnaryExpression(node.parent, usage); break; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: inferTypeFromBinaryExpression(node, node.parent, usage); break; - case 284 /* CaseClause */: - case 285 /* DefaultClause */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: inferTypeFromSwitchStatementLabel(node.parent, usage); break; - case 203 /* CallExpression */: - case 204 /* NewExpression */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: if (node.parent.expression === node) { inferTypeFromCallExpression(node.parent, usage); } @@ -140930,20 +145950,20 @@ var ts; inferTypeFromContextualType(node, usage); } break; - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: inferTypeFromPropertyAccessExpression(node.parent, usage); break; - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: inferTypeFromPropertyElementExpression(node.parent, node, usage); break; - case 288 /* PropertyAssignment */: - case 289 /* ShorthandPropertyAssignment */: + case 290 /* PropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: inferTypeFromPropertyAssignment(node.parent, usage); break; - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: inferTypeFromPropertyDeclaration(node.parent, usage); break; - case 249 /* VariableDeclaration */: { + case 251 /* 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. @@ -141001,17 +146021,17 @@ var ts; case 52 /* CaretToken */: // CompoundAssignmentOperator // falls through - case 64 /* MinusEqualsToken */: - case 66 /* AsteriskAsteriskEqualsToken */: - case 65 /* AsteriskEqualsToken */: - case 67 /* SlashEqualsToken */: - case 68 /* PercentEqualsToken */: - case 72 /* AmpersandEqualsToken */: - case 73 /* BarEqualsToken */: - case 77 /* CaretEqualsToken */: - case 69 /* LessThanLessThanEqualsToken */: - case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 70 /* GreaterThanGreaterThanEqualsToken */: + 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 */: // AdditiveOperator // falls through case 40 /* MinusToken */: @@ -141029,7 +146049,7 @@ var ts; usage.isNumber = true; } break; - case 63 /* PlusEqualsToken */: + case 64 /* PlusEqualsToken */: case 39 /* PlusToken */: var otherOperandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); if (otherOperandType.flags & 1056 /* EnumLike */) { @@ -141049,14 +146069,14 @@ var ts; } break; // AssignmentOperators - case 62 /* EqualsToken */: + case 63 /* EqualsToken */: case 34 /* EqualsEqualsToken */: case 36 /* EqualsEqualsEqualsToken */: case 37 /* ExclamationEqualsEqualsToken */: case 35 /* ExclamationEqualsToken */: addCandidateType(usage, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); break; - case 100 /* InKeyword */: + case 101 /* InKeyword */: if (node === parent.left) { usage.isString = true; } @@ -141065,7 +146085,7 @@ var ts; case 56 /* BarBarToken */: case 60 /* QuestionQuestionToken */: if (node === parent.left && - (node.parent.parent.kind === 249 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { + (node.parent.parent.kind === 251 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { // var x = x || {}; // TODO: use getFalsyflagsOfType addCandidateType(usage, checker.getTypeAtLocation(parent.right)); @@ -141073,7 +146093,7 @@ var ts; break; case 55 /* AmpersandAmpersandToken */: case 27 /* CommaToken */: - case 101 /* InstanceOfKeyword */: + case 102 /* InstanceOfKeyword */: // nothing to infer here break; } @@ -141093,7 +146113,7 @@ var ts; } } calculateUsageOfNode(parent, call.return_); - if (parent.kind === 203 /* CallExpression */) { + if (parent.kind === 205 /* CallExpression */) { (usage.calls || (usage.calls = [])).push(call); } else { @@ -141196,7 +146216,7 @@ var ts; var anon = anons_1[_i]; for (var _a = 0, _b = checker.getPropertiesOfType(anon); _a < _b.length; _a++) { var p = _b[_a]; - props.add(p.name, checker.getTypeOfSymbolAtLocation(p, p.valueDeclaration)); + 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 */)); @@ -141337,12 +146357,13 @@ var ts; if (!usageParam) { break; } - var genericParamType = checker.getTypeOfSymbolAtLocation(genericParam, genericParam.valueDeclaration); + var genericParamType = genericParam.valueDeclaration ? checker.getTypeOfSymbolAtLocation(genericParam, genericParam.valueDeclaration) : checker.getAnyType(); var elementType = isRest && checker.getElementTypeOfArrayType(genericParamType); if (elementType) { genericParamType = elementType; } - var targetType = usageParam.type || checker.getTypeOfSymbolAtLocation(usageParam, usageParam.valueDeclaration); + var targetType = usageParam.type + || (usageParam.valueDeclaration ? checker.getTypeOfSymbolAtLocation(usageParam, usageParam.valueDeclaration) : checker.getAnyType()); types.push.apply(types, inferTypeParameters(genericParamType, targetType, typeParameter)); } var genericReturn = checker.getReturnTypeOfSignature(genericSig); @@ -141356,7 +146377,7 @@ var ts; function getSignatureFromCalls(calls) { var parameters = []; var length = Math.max.apply(Math, calls.map(function (c) { return c.argumentTypes.length; })); - var _loop_14 = function (i) { + var _loop_15 = function (i) { var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i)); symbol.type = combineTypes(calls.map(function (call) { return call.argumentTypes[i] || checker.getUndefinedType(); })); if (calls.some(function (call) { return call.argumentTypes[i] === undefined; })) { @@ -141365,10 +146386,9 @@ var ts; parameters.push(symbol); }; for (var i = 0; i < length; i++) { - _loop_14(i); + _loop_15(i); } var returnType = combineFromUsage(combineUsages(calls.map(function (call) { return call.return_; }))); - // TODO: GH#18217 return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, 0 /* None */); } function addCandidateType(usage, type) { @@ -141512,7 +146532,7 @@ var ts; codefix.createMissingMemberNodes = createMissingMemberNodes; function getNoopSymbolTrackerWithResolver(context) { return { - trackSymbol: ts.noop, + trackSymbol: function () { return false; }, moduleResolverHost: ts.getModuleSpecifierResolverHost(context.program, context.host), }; } @@ -141536,8 +146556,8 @@ var ts; var ambient = !!(enclosingDeclaration.flags & 8388608 /* Ambient */); var quotePreference = ts.getQuotePreference(sourceFile, preferences); switch (declaration.kind) { - case 162 /* PropertySignature */: - case 163 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 165 /* PropertyDeclaration */: var flags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : undefined; var typeNode = checker.typeToTypeNode(type, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context)); if (importAdder) { @@ -141551,8 +146571,8 @@ var ts; /*decorators*/ undefined, modifiers, name, optional ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeNode, /*initializer*/ undefined)); break; - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: { + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: { var typeNode_1 = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); var allAccessors = ts.getAllAccessorDeclarations(declarations, declaration); var orderedAccessors = allAccessors.secondAccessor @@ -141581,8 +146601,8 @@ var ts; } break; } - case 164 /* MethodSignature */: - case 165 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 167 /* 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 @@ -141612,7 +146632,7 @@ var ts; } else { ts.Debug.assert(declarations.length === signatures.length, "Declarations and signatures should match count"); - addClassElement(createMethodImplementingSignatures(signatures, name, optional, modifiers, quotePreference)); + addClassElement(createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional, modifiers, quotePreference)); } } break; @@ -141628,7 +146648,7 @@ var ts; var checker = program.getTypeChecker(); var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions()); var flags = 1 /* NoTruncation */ | 1073741824 /* NoUndefinedOptionalParameterType */ | 256 /* SuppressAnyReturnType */ | (quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : 0); - var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, 165 /* MethodDeclaration */, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context)); + var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, 167 /* MethodDeclaration */, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context)); if (!signatureDeclaration) { return undefined; } @@ -141712,7 +146732,7 @@ var ts; var type = isJs || contextualType === undefined ? undefined : checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker); - if (kind === 165 /* MethodDeclaration */) { + if (kind === 167 /* MethodDeclaration */) { return ts.factory.createMethodDeclaration( /*decorators*/ undefined, modifiers, asteriskToken, name, /*questionToken*/ undefined, typeParameters, parameters, type, ts.isInterfaceDeclaration(contextNode) ? undefined : createStubbedMethodBody(quotePreference)); @@ -141742,13 +146762,13 @@ var ts; /*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(128 /* AnyKeyword */), + /*type*/ inJs ? undefined : types && types[i] || ts.factory.createKeywordTypeNode(129 /* AnyKeyword */), /*initializer*/ undefined); parameters.push(newParameter); } return parameters; } - function createMethodImplementingSignatures(signatures, name, optional, modifiers, quotePreference) { + function createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional, modifiers, quotePreference) { /** This is *a* signature with the maximal number of arguments, * such that if there is a "maximal" signature without rest arguments, * this is one of them. @@ -141770,7 +146790,7 @@ var ts; var maxArgsParameterSymbolNames = maxArgsSignature.parameters.map(function (symbol) { return symbol.name; }); var parameters = createDummyParameters(maxNonRestArgs, maxArgsParameterSymbolNames, /* types */ undefined, minArgumentCount, /*inJs*/ false); if (someSigHasRestParameter) { - var anyArrayType = ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(128 /* AnyKeyword */)); + var anyArrayType = ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(129 /* AnyKeyword */)); var restParameter = ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createToken(25 /* DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest", @@ -141779,8 +146799,13 @@ var ts; parameters.push(restParameter); } return createStubbedMethod(modifiers, name, optional, - /*typeParameters*/ undefined, parameters, - /*returnType*/ undefined, quotePreference); + /*typeParameters*/ undefined, parameters, getReturnTypeFromSignatures(signatures, checker, context, enclosingDeclaration), quotePreference); + } + function getReturnTypeFromSignatures(signatures, checker, context, enclosingDeclaration) { + if (ts.length(signatures)) { + var type = checker.getUnionType(ts.map(signatures, checker.getReturnTypeOfSignature)); + return checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); + } } function createStubbedMethod(modifiers, name, optional, typeParameters, parameters, returnType, quotePreference) { return ts.factory.createMethodDeclaration( @@ -141800,10 +146825,10 @@ var ts; codefix.createStubbedBody = createStubbedBody; function createVisibilityModifier(flags) { if (flags & 4 /* Public */) { - return ts.factory.createToken(122 /* PublicKeyword */); + return ts.factory.createToken(123 /* PublicKeyword */); } else if (flags & 16 /* Protected */) { - return ts.factory.createToken(121 /* ProtectedKeyword */); + return ts.factory.createToken(122 /* ProtectedKeyword */); } return undefined; } @@ -141876,7 +146901,7 @@ var ts; } codefix.tryGetAutoImportableReferenceFromTypeNode = tryGetAutoImportableReferenceFromTypeNode; function replaceFirstIdentifierOfEntityName(name, newIdentifier) { - if (name.kind === 78 /* Identifier */) { + if (name.kind === 79 /* Identifier */) { return newIdentifier; } return ts.factory.createQualifiedName(replaceFirstIdentifierOfEntityName(name.left, newIdentifier), name.right); @@ -141907,13 +146932,13 @@ var ts; if (ts.isClassLike(container)) { var modifierFlags = ts.getEffectiveModifierFlags(declaration); if (ts.isSourceFileJS(file)) { - var modifiers = createModifiers(modifierFlags); + var modifiers = ts.createModifiers(modifierFlags); accessorModifiers = modifiers; fieldModifiers = modifiers; } else { - accessorModifiers = createModifiers(prepareModifierFlagsForAccessor(modifierFlags)); - fieldModifiers = createModifiers(prepareModifierFlagsForField(modifierFlags)); + accessorModifiers = ts.createModifiers(prepareModifierFlagsForAccessor(modifierFlags)); + fieldModifiers = ts.createModifiers(prepareModifierFlagsForField(modifierFlags)); } } updateFieldDeclaration(changeTracker, file, declaration, type, fieldName, fieldModifiers); @@ -141948,9 +146973,6 @@ var ts; var leftHead = isStatic ? container.name : ts.factory.createThis(); // TODO: GH#18217 return ts.isIdentifier(fieldName) ? ts.factory.createPropertyAccessExpression(leftHead, fieldName) : ts.factory.createElementAccessExpression(leftHead, ts.factory.createStringLiteralFromNode(fieldName)); } - function createModifiers(modifierFlags) { - return modifierFlags ? ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(modifierFlags)) : undefined; - } function prepareModifierFlagsForAccessor(modifierFlags) { modifierFlags &= ~64 /* Readonly */; // avoid Readonly modifier because it will convert to get accessor modifierFlags &= ~8 /* Private */; @@ -141995,7 +147017,7 @@ var ts; isStatic: ts.hasStaticModifier(declaration), isReadonly: ts.hasEffectiveReadonlyModifier(declaration), type: getDeclarationType(declaration, program), - container: declaration.kind === 160 /* Parameter */ ? declaration.parent.parent : declaration.parent, + container: declaration.kind === 162 /* Parameter */ ? declaration.parent.parent : declaration.parent, originalName: declaration.name.text, declaration: declaration, fieldName: fieldName, @@ -142051,13 +147073,13 @@ var ts; return; constructor.body.forEachChild(function recur(node) { if (ts.isElementAccessExpression(node) && - node.expression.kind === 107 /* ThisKeyword */ && + node.expression.kind === 108 /* 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 === 107 /* ThisKeyword */ && node.name.text === originalName && ts.isWriteAccess(node)) { + if (ts.isPropertyAccessExpression(node) && node.expression.kind === 108 /* ThisKeyword */ && node.name.text === originalName && ts.isWriteAccess(node)) { changeTracker.replaceNode(file, node.name, ts.factory.createIdentifier(fieldName)); } if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) { @@ -142072,7 +147094,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), [ts.factory.createKeywordTypeNode(150 /* UndefinedKeyword */)])); + return ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], types), [ts.factory.createKeywordTypeNode(151 /* UndefinedKeyword */)])); } } return typeNode; @@ -142085,7 +147107,7 @@ var ts; if (!superSymbol) break; var symbol = superSymbol.flags & 2097152 /* Alias */ ? checker.getAliasedSymbol(superSymbol) : superSymbol; - var superDecl = ts.find(symbol.declarations, ts.isClassLike); + var superDecl = symbol.declarations && ts.find(symbol.declarations, ts.isClassLike); if (!superDecl) break; res.push(superDecl); @@ -142131,7 +147153,7 @@ var ts; }); function getActionsForUsageOfInvalidImport(context) { var sourceFile = context.sourceFile; - var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 203 /* CallExpression */ : 204 /* NewExpression */; + var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 205 /* CallExpression */ : 206 /* NewExpression */; var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start), function (a) { return a.kind === targetKind; }); if (!node) { return []; @@ -142250,7 +147272,7 @@ var ts; return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_undefined_type_to_property_0, propertyDeclaration.name.getText()], fixIdAddUndefinedType, ts.Diagnostics.Add_undefined_type_to_all_uninitialized_properties); } function addUndefinedType(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) { - var undefinedTypeNode = ts.factory.createKeywordTypeNode(150 /* UndefinedKeyword */); + var undefinedTypeNode = ts.factory.createKeywordTypeNode(151 /* UndefinedKeyword */); var type = propertyDeclaration.type; // TODO: GH#18217 var types = ts.isUnionTypeNode(type) ? type.types.concat(undefinedTypeNode) : [type, undefinedTypeNode]; changeTracker.replaceNode(propertyDeclarationSourceFile, type, ts.factory.createUnionTypeNode(types)); @@ -142464,8 +147486,8 @@ var ts; }); function getImportTypeNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 99 /* ImportKeyword */, "This token should be an ImportKeyword"); - ts.Debug.assert(token.parent.kind === 195 /* ImportType */, "Token parent should be an ImportType"); + ts.Debug.assert(token.kind === 100 /* ImportKeyword */, "This token should be an ImportKeyword"); + ts.Debug.assert(token.parent.kind === 197 /* ImportType */, "Token parent should be an ImportType"); return token.parent; } function doChange(changes, sourceFile, importType) { @@ -142484,10 +147506,6 @@ var ts; codefix.registerCodeFix({ errorCodes: errorCodes, getCodeActions: function (context) { - var jsx = context.program.getCompilerOptions().jsx; - if (jsx !== 2 /* React */ && jsx !== 3 /* ReactNative */) { - return undefined; - } var sourceFile = context.sourceFile, span = context.span; var node = findNodeToFix(sourceFile, span.start); if (!node) @@ -142597,7 +147615,7 @@ var ts; var otherMembers = members.filter(function (member) { return !ts.isIndexSignatureDeclaration(member); }); var parameter = ts.first(indexSignature.parameters); var mappedTypeParameter = ts.factory.createTypeParameterDeclaration(ts.cast(parameter.name, ts.isIdentifier), parameter.type); - var mappedIntersectionType = ts.factory.createMappedTypeNode(ts.hasEffectiveReadonlyModifier(indexSignature) ? ts.factory.createModifier(142 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, + var mappedIntersectionType = ts.factory.createMappedTypeNode(ts.hasEffectiveReadonlyModifier(indexSignature) ? ts.factory.createModifier(143 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, /*nameType*/ undefined, indexSignature.questionToken, indexSignature.type); var intersectionType = ts.factory.createIntersectionTypeNode(__spreadArray(__spreadArray(__spreadArray([], ts.getAllSuperTypeNodes(container)), [ mappedIntersectionType @@ -142654,7 +147672,7 @@ var ts; }, }); function makeChange(changeTracker, sourceFile, span) { - var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 130 /* AwaitKeyword */; }); + var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 131 /* AwaitKeyword */; }); var awaitExpression = awaitKeyword && ts.tryCast(awaitKeyword.parent, ts.isAwaitExpression); if (!awaitExpression) { return; @@ -142665,7 +147683,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 !== 102 /* NewKeyword */) { + if (precedingToken && precedingToken.kind !== 103 /* NewKeyword */) { expressionToReplace = awaitExpression.parent; } } @@ -142732,7 +147750,7 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, pos); var checker = program.getTypeChecker(); var symbol = checker.getSymbolAtLocation(token); - if (symbol) { + if (symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration) { return symbol.valueDeclaration.parent.parent; } } @@ -142827,7 +147845,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(113 /* VoidKeyword */)]).types[0]); + ts.isParenthesizedTypeNode(ts.factory.createUnionTypeNode([typeArgument, ts.factory.createKeywordTypeNode(114 /* VoidKeyword */)]).types[0]); if (needsParens) { changes.insertText(sourceFile, typeArgument.pos, "("); } @@ -142919,7 +147937,7 @@ var ts; ; function getInfo(context, considerPartialSpans) { if (considerPartialSpans === void 0) { considerPartialSpans = true; } - var file = context.file; + 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); @@ -142927,23 +147945,31 @@ var ts; return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_export_statement) }; } var exportingModuleSymbol = ts.isSourceFile(exportNode.parent) ? exportNode.parent.symbol : exportNode.parent.parent.symbol; - var flags = ts.getSyntacticModifierFlags(exportNode); + var flags = ts.getSyntacticModifierFlags(exportNode) || ((ts.isExportAssignment(exportNode) && !exportNode.isExportEquals) ? 513 /* ExportDefault */ : 0 /* None */); var wasDefault = !!(flags & 512 /* Default */); // If source file already has a default export, don't offer refactor. if (!(flags & 1 /* Export */) || !wasDefault && exportingModuleSymbol.exports.has("default" /* Default */)) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.This_file_already_has_a_default_export) }; } + var checker = program.getTypeChecker(); + var noSymbolError = function (id) { + return (ts.isIdentifier(id) && checker.getSymbolAtLocation(id)) ? undefined + : { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Can_only_convert_named_export) }; + }; switch (exportNode.kind) { - case 251 /* FunctionDeclaration */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 256 /* ModuleDeclaration */: { + case 253 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 257 /* EnumDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 258 /* ModuleDeclaration */: { var node = exportNode; - return node.name && ts.isIdentifier(node.name) ? { exportNode: node, exportName: node.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; + if (!node.name) + return undefined; + return noSymbolError(node.name) + || { exportNode: node, exportName: node.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol }; } - case 232 /* VariableStatement */: { + case 234 /* VariableStatement */: { var vs = exportNode; // Must be `export const x = something;`. if (!(vs.declarationList.flags & 2 /* Const */) || vs.declarationList.declarations.length !== 1) { @@ -142953,7 +147979,15 @@ var ts; if (!decl.initializer) return undefined; ts.Debug.assert(!wasDefault, "Can't have a default flag here"); - return ts.isIdentifier(decl.name) ? { exportNode: vs, exportName: decl.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; + return noSymbolError(decl.name) + || { exportNode: vs, exportName: decl.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol }; + } + case 268 /* ExportAssignment */: { + var node = exportNode; + if (node.isExportEquals) + return undefined; + return noSymbolError(node.expression) + || { exportNode: node, exportName: node.expression, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol }; } default: return undefined; @@ -142966,17 +148000,24 @@ var ts; function changeExport(exportingSourceFile, _a, changes, checker) { var wasDefault = _a.wasDefault, exportNode = _a.exportNode, exportName = _a.exportName; if (wasDefault) { - changes.delete(exportingSourceFile, ts.Debug.checkDefined(ts.findModifier(exportNode, 87 /* DefaultKeyword */), "Should find a default keyword in modifier list")); + if (ts.isExportAssignment(exportNode) && !exportNode.isExportEquals) { + var exp = exportNode.expression; + var spec = makeExportSpecifier(exp.text, exp.text); + changes.replaceNode(exportingSourceFile, exportNode, ts.factory.createExportDeclaration(/*decorators*/ undefined, /*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")); + } } else { - var exportKeyword = ts.Debug.checkDefined(ts.findModifier(exportNode, 92 /* ExportKeyword */), "Should find an export keyword in modifier list"); + var exportKeyword = ts.Debug.checkDefined(ts.findModifier(exportNode, 93 /* ExportKeyword */), "Should find an export keyword in modifier list"); switch (exportNode.kind) { - case 251 /* FunctionDeclaration */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.factory.createToken(87 /* DefaultKeyword */)); + case 253 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.factory.createToken(88 /* DefaultKeyword */)); break; - case 232 /* VariableStatement */: + case 234 /* 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) { @@ -142985,15 +148026,15 @@ var ts; break; } // falls through - case 255 /* EnumDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 256 /* ModuleDeclaration */: + case 257 /* EnumDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 258 /* 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.assertNever(exportNode, "Unexpected exportNode kind " + exportNode.kind); + ts.Debug.fail("Unexpected exportNode kind " + exportNode.kind); } } } @@ -143014,18 +148055,18 @@ var ts; function changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName) { var parent = ref.parent; switch (parent.kind) { - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: // `a.default` --> `a.foo` changes.replaceNode(importingSourceFile, ref, ts.factory.createIdentifier(exportName)); break; - case 265 /* ImportSpecifier */: - case 270 /* ExportSpecifier */: { + case 267 /* ImportSpecifier */: + case 272 /* 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 262 /* ImportClause */: { + case 264 /* ImportClause */: { var clause = parent; ts.Debug.assert(clause.name === ref, "Import clause name should match provided ref"); var spec = makeImportSpecifier(exportName, ref.text); @@ -143034,7 +148075,7 @@ var ts; // `import foo from "./a";` --> `import { foo } from "./a";` changes.replaceNode(importingSourceFile, ref, ts.factory.createNamedImports([spec])); } - else if (namedBindings.kind === 263 /* NamespaceImport */) { + else if (namedBindings.kind === 265 /* 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 */; @@ -143055,11 +148096,11 @@ var ts; function changeNamedToDefaultImport(importingSourceFile, ref, changes) { var parent = ref.parent; switch (parent.kind) { - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: // `a.foo` --> `a.default` changes.replaceNode(importingSourceFile, ref, ts.factory.createIdentifier("default")); break; - case 265 /* ImportSpecifier */: { + case 267 /* 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); @@ -143072,7 +148113,7 @@ var ts; } break; } - case 270 /* ExportSpecifier */: { + case 272 /* 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";` @@ -143118,7 +148159,7 @@ var ts; if (!info) return ts.emptyArray; if (!refactor.isRefactorErrorInfo(info)) { - var namespaceImport = info.kind === 263 /* NamespaceImport */; + var namespaceImport = info.kind === 265 /* NamespaceImport */; var action = namespaceImport ? namespaceToNamedAction : namedToNamespaceAction; return [{ name: refactorName, description: action.description, actions: [action] }]; } @@ -143160,7 +148201,7 @@ var ts; } function doChange(sourceFile, program, changes, toConvert) { var checker = program.getTypeChecker(); - if (toConvert.kind === 263 /* NamespaceImport */) { + if (toConvert.kind === 265 /* NamespaceImport */) { doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())); } else { @@ -143225,7 +148266,7 @@ var ts; }); var namespaceImportName = namespaceNameConflicts ? ts.getUniqueName(preferredName, sourceFile) : preferredName; var neededNamedImports = []; - var _loop_15 = function (element) { + var _loop_16 = 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); @@ -143244,7 +148285,7 @@ var ts; }; for (var _i = 0, _a = toConvert.elements; _i < _a.length; _i++) { var element = _a[_i]; - _loop_15(element); + _loop_16(element); } changes.replaceNode(sourceFile, toConvert, ts.factory.createNamespaceImport(ts.factory.createIdentifier(namespaceImportName))); if (neededNamedImports.length) { @@ -143561,27 +148602,27 @@ var ts; var lastDeclaration = signatureDecls[signatureDecls.length - 1]; var updated = lastDeclaration; switch (lastDeclaration.kind) { - case 164 /* MethodSignature */: { + case 166 /* MethodSignature */: { updated = ts.factory.updateMethodSignature(lastDeclaration, lastDeclaration.modifiers, lastDeclaration.name, lastDeclaration.questionToken, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 165 /* MethodDeclaration */: { + case 167 /* MethodDeclaration */: { updated = ts.factory.updateMethodDeclaration(lastDeclaration, lastDeclaration.decorators, lastDeclaration.modifiers, lastDeclaration.asteriskToken, lastDeclaration.name, lastDeclaration.questionToken, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type, lastDeclaration.body); break; } - case 169 /* CallSignature */: { + case 171 /* CallSignature */: { updated = ts.factory.updateCallSignature(lastDeclaration, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 166 /* Constructor */: { + case 168 /* Constructor */: { updated = ts.factory.updateConstructorDeclaration(lastDeclaration, lastDeclaration.decorators, lastDeclaration.modifiers, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.body); break; } - case 170 /* ConstructSignature */: { + case 172 /* ConstructSignature */: { updated = ts.factory.updateConstructSignature(lastDeclaration, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 251 /* FunctionDeclaration */: { + case 253 /* FunctionDeclaration */: { updated = ts.factory.updateFunctionDeclaration(lastDeclaration, lastDeclaration.decorators, lastDeclaration.modifiers, lastDeclaration.asteriskToken, lastDeclaration.name, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type, lastDeclaration.body); break; } @@ -143613,7 +148654,7 @@ var ts; } 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(128 /* AnyKeyword */)), p); + var result = ts.setTextRange(ts.factory.createNamedTupleMember(p.dotDotDotToken, p.name, p.questionToken, p.type || ts.factory.createKeywordTypeNode(129 /* AnyKeyword */)), p); var parameterDocComment = p.symbol && p.symbol.getDocumentationComment(checker); if (parameterDocComment) { var newComment = ts.displayPartsToString(parameterDocComment); @@ -143633,12 +148674,12 @@ var ts; } function isConvertableSignatureDeclaration(d) { switch (d.kind) { - case 164 /* MethodSignature */: - case 165 /* MethodDeclaration */: - case 169 /* CallSignature */: - case 166 /* Constructor */: - case 170 /* ConstructSignature */: - case 251 /* FunctionDeclaration */: + case 166 /* MethodSignature */: + case 167 /* MethodDeclaration */: + case 171 /* CallSignature */: + case 168 /* Constructor */: + case 172 /* ConstructSignature */: + case 253 /* FunctionDeclaration */: return true; } return false; @@ -143778,7 +148819,6 @@ var ts; }; } } - // Skip these since we don't have a way to report errors yet if (refactor.refactorKindBeginsWith(extractConstantAction.kind, requestedRefactor)) { if (constantExtraction.errors.length === 0) { // Don't issue refactorings with duplicated names. @@ -143910,24 +148950,28 @@ var ts; /** * getRangeToExtract takes a span inside a text file and returns either an expression or an array * of statements representing the minimum set of nodes needed to extract the entire span. This - * process may fail, in which case a set of errors is returned instead (these are currently - * not shown to the user, but can be used by us diagnostically) + * process may fail, in which case a set of errors is returned instead. These errors are shown to + * users if they have the provideRefactorNotApplicableReason option set. */ // exported only for tests - function getRangeToExtract(sourceFile, span, considerEmptySpans) { - if (considerEmptySpans === void 0) { considerEmptySpans = true; } + function getRangeToExtract(sourceFile, span, invoked) { + if (invoked === void 0) { invoked = true; } var length = span.length; - if (length === 0 && !considerEmptySpans) { + if (length === 0 && !invoked) { return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractEmpty)] }; } - var cursorRequest = length === 0 && considerEmptySpans; + var cursorRequest = length === 0 && invoked; + var startToken = ts.findFirstNonJsxWhitespaceToken(sourceFile, span.start); + var endToken = ts.findTokenOnLeftOfPosition(sourceFile, ts.textSpanEnd(span)); + /* If the refactoring command is invoked through a keyboard action it's safe to assume that the user is actively looking for + refactoring actions at the span location. As they may not know the exact range that will trigger a refactoring, we expand the + searched span to cover a real node range making it more likely that something useful will show up. */ + var adjustedSpan = startToken && endToken && invoked ? getAdjustedSpanFromNodes(startToken, endToken, sourceFile) : span; // Walk up starting from the the start position until we find a non-SourceFile node that subsumes the selected span. // This may fail (e.g. you select two statements in the root of a source file) - var startToken = ts.getTokenAtPosition(sourceFile, span.start); - var start = cursorRequest ? getExtractableParent(startToken) : ts.getParentNodeInSpan(startToken, sourceFile, span); + var start = cursorRequest ? getExtractableParent(startToken) : ts.getParentNodeInSpan(startToken, sourceFile, adjustedSpan); // Do the same for the ending position - var endToken = ts.findTokenOnLeftOfPosition(sourceFile, ts.textSpanEnd(span)); - var end = cursorRequest ? start : ts.getParentNodeInSpan(endToken, sourceFile, span); + var end = cursorRequest ? start : ts.getParentNodeInSpan(endToken, sourceFile, adjustedSpan); var declarations = []; // We'll modify these flags as we walk the tree to collect data // about what things need to be done as part of the extraction. @@ -143936,6 +148980,9 @@ var ts; // cannot find either start or end node return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] }; } + if (ts.isJSDoc(start)) { + return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractJSDoc)] }; + } if (start.parent !== end.parent) { // start and end nodes belong to different subtrees return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] }; @@ -143970,9 +149017,6 @@ var ts; } return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations } }; } - if (ts.isJSDoc(start)) { - return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractJSDoc)] }; - } if (ts.isReturnStatement(start) && !start.expression) { // Makes no sense to extract an expression-less return statement. return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] }; @@ -144025,20 +149069,20 @@ var ts; function checkForStaticContext(nodeToCheck, containingClass) { var current = nodeToCheck; while (current !== containingClass) { - if (current.kind === 163 /* PropertyDeclaration */) { + if (current.kind === 165 /* PropertyDeclaration */) { if (ts.hasSyntacticModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 160 /* Parameter */) { + else if (current.kind === 162 /* Parameter */) { var ctorOrMethod = ts.getContainingFunction(current); - if (ctorOrMethod.kind === 166 /* Constructor */) { + if (ctorOrMethod.kind === 168 /* Constructor */) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 165 /* MethodDeclaration */) { + else if (current.kind === 167 /* MethodDeclaration */) { if (ts.hasSyntacticModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } @@ -144081,7 +149125,7 @@ var ts; return true; } if (ts.isDeclaration(node)) { - var declaringNode = (node.kind === 249 /* VariableDeclaration */) ? node.parent.parent : node; + var declaringNode = (node.kind === 251 /* VariableDeclaration */) ? node.parent.parent : node; if (ts.hasSyntacticModifier(declaringNode, 1 /* 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`! @@ -144093,16 +149137,16 @@ var ts; } // Some things can't be extracted in certain situations switch (node.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractImport)); return true; - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractExportedEntity)); return true; - case 105 /* SuperKeyword */: + case 106 /* 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 === 203 /* CallExpression */) { + if (node.parent.kind === 205 /* CallExpression */) { // Super constructor call var containingClass_1 = ts.getContainingClass(node); // TODO:GH#18217 if (containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) { @@ -144114,7 +149158,7 @@ var ts; rangeFacts |= RangeFacts.UsesThis; } break; - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: // check if arrow function uses this ts.forEachChild(node, function check(n) { if (ts.isThis(n)) { @@ -144128,39 +149172,39 @@ var ts; } }); // falls through - case 252 /* ClassDeclaration */: - case 251 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: + case 253 /* 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 221 /* ClassExpression */: - case 208 /* FunctionExpression */: - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 223 /* ClassExpression */: + case 210 /* FunctionExpression */: + case 167 /* MethodDeclaration */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: // do not dive into functions or classes return false; } var savedPermittedJumps = permittedJumps; switch (node.kind) { - case 234 /* IfStatement */: + case 236 /* IfStatement */: permittedJumps = 0 /* None */; break; - case 247 /* TryStatement */: + case 249 /* TryStatement */: // forbid all jumps inside try blocks permittedJumps = 0 /* None */; break; - case 230 /* Block */: - if (node.parent && node.parent.kind === 247 /* TryStatement */ && node.parent.finallyBlock === node) { + case 232 /* Block */: + if (node.parent && node.parent.kind === 249 /* TryStatement */ && node.parent.finallyBlock === node) { // allow unconditional returns from finally blocks permittedJumps = 4 /* Return */; } break; - case 285 /* DefaultClause */: - case 284 /* CaseClause */: + case 287 /* DefaultClause */: + case 286 /* CaseClause */: // allow unlabeled break inside case clauses permittedJumps |= 1 /* Break */; break; @@ -144172,19 +149216,19 @@ var ts; break; } switch (node.kind) { - case 187 /* ThisType */: - case 107 /* ThisKeyword */: + case 189 /* ThisType */: + case 108 /* ThisKeyword */: rangeFacts |= RangeFacts.UsesThis; break; - case 245 /* LabeledStatement */: { + case 247 /* LabeledStatement */: { var label = node.label; (seenLabels || (seenLabels = [])).push(label.escapedText); ts.forEachChild(node, visit); seenLabels.pop(); break; } - case 241 /* BreakStatement */: - case 240 /* ContinueStatement */: { + case 243 /* BreakStatement */: + case 242 /* ContinueStatement */: { var label = node.label; if (label) { if (!ts.contains(seenLabels, label.escapedText)) { @@ -144193,20 +149237,20 @@ var ts; } } else { - if (!(permittedJumps & (node.kind === 241 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { + if (!(permittedJumps & (node.kind === 243 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { // attempt to break or continue in a forbidden context (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractRangeContainingConditionalBreakOrContinueStatements)); } } break; } - case 213 /* AwaitExpression */: + case 215 /* AwaitExpression */: rangeFacts |= RangeFacts.IsAsyncFunction; break; - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: rangeFacts |= RangeFacts.IsGenerator; break; - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: if (permittedJumps & 4 /* Return */) { rangeFacts |= RangeFacts.HasReturn; } @@ -144223,6 +149267,18 @@ var ts; } } extractSymbol.getRangeToExtract = getRangeToExtract; + /** + * Includes the final semicolon so that the span covers statements in cases where it would otherwise + * only cover the declaration list. + */ + function getAdjustedSpanFromNodes(startNode, endNode, sourceFile) { + var start = startNode.getStart(sourceFile); + var end = endNode.getEnd(); + if (sourceFile.text.charCodeAt(end) === 59 /* semicolon */) { + end++; + } + return { start: start, length: end - start }; + } function getStatementOrExpressionRange(node) { if (ts.isStatement(node)) { return [node]; @@ -144260,7 +149316,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 === 160 /* Parameter */) { + if (current.kind === 162 /* 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; } @@ -144271,7 +149327,7 @@ var ts; // * Module/namespace or source file if (isScope(current)) { scopes.push(current); - if (current.kind === 297 /* SourceFile */) { + if (current.kind === 299 /* SourceFile */) { return scopes; } } @@ -144361,32 +149417,32 @@ var ts; } function getDescriptionForFunctionLikeDeclaration(scope) { switch (scope.kind) { - case 166 /* Constructor */: + case 168 /* Constructor */: return "constructor"; - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: return scope.name ? "function '" + scope.name.text + "'" : ts.ANONYMOUS; - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return "arrow function"; - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: return "method '" + scope.name.getText() + "'"; - case 167 /* GetAccessor */: + case 169 /* GetAccessor */: return "'get " + scope.name.getText() + "'"; - case 168 /* SetAccessor */: + case 170 /* SetAccessor */: return "'set " + scope.name.getText() + "'"; default: throw ts.Debug.assertNever(scope, "Unexpected scope kind " + scope.kind); } } function getDescriptionForClassLikeDeclaration(scope) { - return scope.kind === 252 /* ClassDeclaration */ + return scope.kind === 254 /* ClassDeclaration */ ? scope.name ? "class '" + scope.name.text + "'" : "anonymous class declaration" : scope.name ? "class expression '" + scope.name.text + "'" : "anonymous class expression"; } function getDescriptionForModuleLikeDeclaration(scope) { - return scope.kind === 257 /* ModuleBlock */ + return scope.kind === 259 /* ModuleBlock */ ? "namespace '" + scope.parent.name.getText() + "'" : scope.externalModuleIndicator ? 0 /* Module */ : 1 /* Global */; } @@ -144454,12 +149510,12 @@ var ts; var newFunction; if (ts.isClassLike(scope)) { // always create private method in TypeScript files - var modifiers = isJS ? [] : [ts.factory.createModifier(120 /* PrivateKeyword */)]; + var modifiers = isJS ? [] : [ts.factory.createModifier(121 /* PrivateKeyword */)]; if (range.facts & RangeFacts.InStaticRegion) { - modifiers.push(ts.factory.createModifier(123 /* StaticKeyword */)); + modifiers.push(ts.factory.createModifier(124 /* StaticKeyword */)); } if (range.facts & RangeFacts.IsAsyncFunction) { - modifiers.push(ts.factory.createModifier(129 /* AsyncKeyword */)); + modifiers.push(ts.factory.createModifier(130 /* AsyncKeyword */)); } newFunction = ts.factory.createMethodDeclaration( /*decorators*/ undefined, modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* AsteriskToken */) : undefined, functionName, @@ -144467,7 +149523,7 @@ var ts; } else { newFunction = ts.factory.createFunctionDeclaration( - /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.factory.createToken(129 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body); + /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.factory.createToken(130 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* 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; @@ -144612,9 +149668,9 @@ var ts; while (ts.isParenthesizedTypeNode(withoutParens)) { withoutParens = withoutParens.type; } - return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 150 /* UndefinedKeyword */; }) + return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 151 /* UndefinedKeyword */; }) ? clone - : ts.factory.createUnionTypeNode([clone, ts.factory.createKeywordTypeNode(150 /* UndefinedKeyword */)]); + : ts.factory.createUnionTypeNode([clone, ts.factory.createKeywordTypeNode(151 /* UndefinedKeyword */)]); } } /** @@ -144639,11 +149695,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(120 /* PrivateKeyword */)); + modifiers.push(ts.factory.createModifier(121 /* PrivateKeyword */)); if (rangeFacts & RangeFacts.InStaticRegion) { - modifiers.push(ts.factory.createModifier(123 /* StaticKeyword */)); + modifiers.push(ts.factory.createModifier(124 /* StaticKeyword */)); } - modifiers.push(ts.factory.createModifier(142 /* ReadonlyKeyword */)); + modifiers.push(ts.factory.createModifier(143 /* ReadonlyKeyword */)); var newVariable = ts.factory.createPropertyDeclaration( /*decorators*/ undefined, modifiers, localNameText, /*questionToken*/ undefined, variableType, initializer); @@ -144675,7 +149731,7 @@ var ts; var localReference = ts.factory.createIdentifier(localNameText); changeTracker.replaceNode(context.file, node, localReference); } - else if (node.parent.kind === 233 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { + else if (node.parent.kind === 235 /* 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( @@ -144694,7 +149750,7 @@ var ts; changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariableStatement, /*blankLineBetween*/ false); } // Consume - if (node.parent.kind === 233 /* ExpressionStatement */) { + if (node.parent.kind === 235 /* ExpressionStatement */) { // If the parent is an expression statement, delete it. changeTracker.delete(context.file, node.parent); } @@ -145021,7 +150077,7 @@ var ts; var scope = scopes_1[_i]; usagesPerScope.push({ usages: new ts.Map(), typeParameterUsages: new ts.Map(), substitutions: new ts.Map() }); substitutionsPerScope.push(new ts.Map()); - functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 251 /* FunctionDeclaration */ + functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 253 /* FunctionDeclaration */ ? [ts.createDiagnosticForNode(scope, Messages.cannotExtractToOtherFunctionLike)] : []); var constantErrors = []; @@ -145084,7 +150140,7 @@ var ts; : ts.getEnclosingBlockScopeContainer(scopes[0]); ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations); } - var _loop_16 = function (i) { + var _loop_17 = 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 @@ -145124,7 +150180,7 @@ var ts; } }; for (var i = 0; i < scopes.length; i++) { - _loop_16(i); + _loop_17(i); } return { target: target, usagesPerScope: usagesPerScope, functionErrorsPerScope: functionErrorsPerScope, constantErrorsPerScope: constantErrorsPerScope, exposedVariableDeclarations: exposedVariableDeclarations }; function isInGenericContext(node) { @@ -145340,37 +150396,37 @@ var ts; function isExtractableExpression(node) { var parent = node.parent; switch (parent.kind) { - case 291 /* EnumMember */: + case 293 /* EnumMember */: return false; } switch (node.kind) { case 10 /* StringLiteral */: - return parent.kind !== 261 /* ImportDeclaration */ && - parent.kind !== 265 /* ImportSpecifier */; - case 220 /* SpreadElement */: - case 196 /* ObjectBindingPattern */: - case 198 /* BindingElement */: + return parent.kind !== 263 /* ImportDeclaration */ && + parent.kind !== 267 /* ImportSpecifier */; + case 222 /* SpreadElement */: + case 198 /* ObjectBindingPattern */: + case 200 /* BindingElement */: return false; - case 78 /* Identifier */: - return parent.kind !== 198 /* BindingElement */ && - parent.kind !== 265 /* ImportSpecifier */ && - parent.kind !== 270 /* ExportSpecifier */; + case 79 /* Identifier */: + return parent.kind !== 200 /* BindingElement */ && + parent.kind !== 267 /* ImportSpecifier */ && + parent.kind !== 272 /* ExportSpecifier */; } return true; } function isBlockLike(node) { switch (node.kind) { - case 230 /* Block */: - case 297 /* SourceFile */: - case 257 /* ModuleBlock */: - case 284 /* CaseClause */: + case 232 /* Block */: + case 299 /* SourceFile */: + case 259 /* ModuleBlock */: + case 286 /* CaseClause */: return true; default: return false; } } function isInJSXContent(node) { - return (ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node) || ts.isJsxFragment(node)) && ts.isJsxElement(node.parent); + return (ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node) || ts.isJsxFragment(node)) && (ts.isJsxElement(node.parent) || ts.isJsxFragment(node.parent)); } })(extractSymbol = refactor.extractSymbol || (refactor.extractSymbol = {})); })(refactor = ts.refactor || (ts.refactor = {})); @@ -145505,7 +150561,7 @@ var ts; if (ts.isTypeReferenceNode(node)) { if (ts.isIdentifier(node.typeName)) { var symbol = checker.resolveName(node.typeName.text, node.typeName, 262144 /* TypeParameter */, /* excludeGlobals */ true); - if (symbol) { + if (symbol === null || symbol === void 0 ? void 0 : symbol.declarations) { var declaration = ts.cast(ts.first(symbol.declarations), ts.isTypeParameterDeclaration); if (rangeContainsSkipTrivia(statement, declaration, file) && !rangeContainsSkipTrivia(selection, declaration, file)) { ts.pushIfUnique(result, declaration); @@ -145528,7 +150584,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); - if (symbol && rangeContainsSkipTrivia(statement, symbol.valueDeclaration, file) && !rangeContainsSkipTrivia(selection, symbol.valueDeclaration, file)) { + if ((symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration) && rangeContainsSkipTrivia(statement, symbol.valueDeclaration, file) && !rangeContainsSkipTrivia(selection, symbol.valueDeclaration, file)) { return true; } } @@ -145748,11 +150804,11 @@ var ts; } function isPureImport(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return true; - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return !ts.hasSyntacticModifier(node, 1 /* Export */); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return node.declarationList.declarations.every(function (d) { return !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); }); default: return false; @@ -145813,10 +150869,10 @@ var ts; } function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) { var checker = program.getTypeChecker(); - var _loop_17 = function (sourceFile) { + var _loop_18 = function (sourceFile) { if (sourceFile === oldFile) return "continue"; - var _loop_18 = function (statement) { + var _loop_19 = function (statement) { forEachImportInStatement(statement, function (importNode) { if (checker.getSymbolAtLocation(moduleSpecifierFromImport(importNode)) !== oldFile.symbol) return; @@ -145838,22 +150894,22 @@ var ts; }; for (var _b = 0, _c = sourceFile.statements; _b < _c.length; _b++) { var statement = _c[_b]; - _loop_18(statement); + _loop_19(statement); } }; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; - _loop_17(sourceFile); + _loop_18(sourceFile); } } function getNamespaceLikeImport(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: - return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 263 /* NamespaceImport */ ? + case 263 /* ImportDeclaration */: + return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 265 /* NamespaceImport */ ? node.importClause.namedBindings.name : undefined; - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return node.name; - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return ts.tryCast(node.name, ts.isIdentifier); default: return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); @@ -145884,20 +150940,20 @@ var ts; var newNamespaceId = ts.factory.createIdentifier(newNamespaceName); var newModuleString = ts.factory.createStringLiteral(newModuleSpecifier); switch (node.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, ts.factory.createNamespaceImport(newNamespaceId)), newModuleString); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return ts.factory.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, newNamespaceId, ts.factory.createExternalModuleReference(newModuleString)); - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return ts.factory.createVariableDeclaration(newNamespaceId, /*exclamationToken*/ undefined, /*type*/ undefined, createRequireCall(newModuleString)); default: return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); } } function moduleSpecifierFromImport(i) { - return (i.kind === 261 /* ImportDeclaration */ ? i.moduleSpecifier - : i.kind === 260 /* ImportEqualsDeclaration */ ? i.moduleReference.expression + return (i.kind === 263 /* ImportDeclaration */ ? i.moduleSpecifier + : i.kind === 262 /* ImportEqualsDeclaration */ ? i.moduleReference.expression : i.initializer.arguments[0]); } function forEachImportInStatement(statement, cb) { @@ -145967,15 +151023,15 @@ var ts; } function deleteUnusedImports(sourceFile, importDecl, changes, isUnused) { switch (importDecl.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused); break; - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: if (isUnused(importDecl.name)) { changes.delete(sourceFile, importDecl); } break; - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: deleteUnusedImportsInVariableDeclaration(sourceFile, importDecl, changes, isUnused); break; default: @@ -145988,7 +151044,7 @@ var ts; var _a = importDecl.importClause, name = _a.name, namedBindings = _a.namedBindings; var defaultUnused = !name || isUnused(name); var namedBindingsUnused = !namedBindings || - (namedBindings.kind === 263 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); + (namedBindings.kind === 265 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); if (defaultUnused && namedBindingsUnused) { changes.delete(sourceFile, importDecl); } @@ -146000,7 +151056,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 === 264 /* NamedImports */) { + else if (namedBindings.kind === 266 /* NamedImports */) { for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) { var element = _b[_i]; if (isUnused(element.name)) @@ -146013,14 +151069,14 @@ var ts; function deleteUnusedImportsInVariableDeclaration(sourceFile, varDecl, changes, isUnused) { var name = varDecl.name; switch (name.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: if (isUnused(name)) { changes.delete(sourceFile, name); } break; - case 197 /* ArrayBindingPattern */: + case 199 /* ArrayBindingPattern */: break; - case 196 /* ObjectBindingPattern */: + case 198 /* 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); } @@ -146048,6 +151104,9 @@ var ts; var oldFileNamedImports = []; var markSeenTop = ts.nodeSeenTracker(); // Needed because multiple declarations may appear in `const x = 0, y = 1;`. newFileImportsFromOldFile.forEach(function (symbol) { + if (!symbol.declarations) { + return; + } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; if (!isTopLevelDeclaration(decl)) @@ -146147,14 +151206,14 @@ var ts; // Below should all be utilities function isInImport(decl) { switch (decl.kind) { - case 260 /* ImportEqualsDeclaration */: - case 265 /* ImportSpecifier */: - case 262 /* ImportClause */: - case 263 /* NamespaceImport */: + case 262 /* ImportEqualsDeclaration */: + case 267 /* ImportSpecifier */: + case 264 /* ImportClause */: + case 265 /* NamespaceImport */: return true; - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return isVariableDeclarationInImport(decl); - case 198 /* BindingElement */: + case 200 /* BindingElement */: return ts.isVariableDeclaration(decl.parent.parent) && isVariableDeclarationInImport(decl.parent.parent); default: return false; @@ -146166,7 +151225,7 @@ var ts; } function filterImport(i, moduleSpecifier, keep) { switch (i.kind) { - case 261 /* ImportDeclaration */: { + case 263 /* ImportDeclaration */: { var clause = i.importClause; if (!clause) return undefined; @@ -146176,9 +151235,9 @@ var ts; ? ts.factory.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, defaultImport, namedBindings), moduleSpecifier) : undefined; } - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return keep(i.name) ? i : undefined; - case 249 /* VariableDeclaration */: { + case 251 /* VariableDeclaration */: { var name = filterBindingName(i.name, keep); return name ? makeVariableStatement(name, i.type, createRequireCall(moduleSpecifier), i.parent.flags) : undefined; } @@ -146187,7 +151246,7 @@ var ts; } } function filterNamedBindings(namedBindings, keep) { - if (namedBindings.kind === 263 /* NamespaceImport */) { + if (namedBindings.kind === 265 /* NamespaceImport */) { return keep(namedBindings.name) ? namedBindings : undefined; } else { @@ -146197,11 +151256,11 @@ var ts; } function filterBindingName(name, keep) { switch (name.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return keep(name) ? name : undefined; - case 197 /* ArrayBindingPattern */: + case 199 /* ArrayBindingPattern */: return name; - case 196 /* ObjectBindingPattern */: { + case 198 /* 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; @@ -146258,13 +151317,13 @@ var ts; } function isNonVariableTopLevelDeclaration(node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 252 /* ClassDeclaration */: - case 256 /* ModuleDeclaration */: - case 255 /* EnumDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 253 /* InterfaceDeclaration */: - case 260 /* ImportEqualsDeclaration */: + case 253 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: + case 258 /* ModuleDeclaration */: + case 257 /* EnumDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 255 /* InterfaceDeclaration */: + case 262 /* ImportEqualsDeclaration */: return true; default: return false; @@ -146272,17 +151331,17 @@ var ts; } function forEachTopLevelDeclaration(statement, cb) { switch (statement.kind) { - case 251 /* FunctionDeclaration */: - case 252 /* ClassDeclaration */: - case 256 /* ModuleDeclaration */: - case 255 /* EnumDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 253 /* InterfaceDeclaration */: - case 260 /* ImportEqualsDeclaration */: + case 253 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: + case 258 /* ModuleDeclaration */: + case 257 /* EnumDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 255 /* InterfaceDeclaration */: + case 262 /* ImportEqualsDeclaration */: return cb(statement); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return ts.firstDefined(statement.declarationList.declarations, function (decl) { return forEachTopLevelDeclarationInBindingName(decl.name, cb); }); - case 233 /* ExpressionStatement */: { + case 235 /* ExpressionStatement */: { var expression = statement.expression; return ts.isBinaryExpression(expression) && ts.getAssignmentDeclarationKind(expression) === 1 /* ExportsProperty */ ? cb(statement) @@ -146292,10 +151351,10 @@ var ts; } function forEachTopLevelDeclarationInBindingName(name, cb) { switch (name.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return cb(ts.cast(name.parent, function (x) { return ts.isVariableDeclaration(x) || ts.isBindingElement(x); })); - case 197 /* ArrayBindingPattern */: - case 196 /* ObjectBindingPattern */: + case 199 /* ArrayBindingPattern */: + case 198 /* 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); @@ -146306,9 +151365,9 @@ var ts; } function getTopLevelDeclarationStatement(d) { switch (d.kind) { - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return d.parent.parent; - case 198 /* BindingElement */: + case 200 /* BindingElement */: return getTopLevelDeclarationStatement(ts.cast(d.parent.parent, function (p) { return ts.isVariableDeclaration(p) || ts.isBindingElement(p); })); default: return d; @@ -146339,25 +151398,25 @@ var ts; return useEs6Exports ? [addEs6Export(decl)] : addCommonjsExport(decl); } function addEs6Export(d) { - var modifiers = ts.concatenate([ts.factory.createModifier(92 /* ExportKeyword */)], d.modifiers); + var modifiers = ts.concatenate([ts.factory.createModifier(93 /* ExportKeyword */)], d.modifiers); switch (d.kind) { - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return ts.factory.updateFunctionDeclaration(d, d.decorators, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body); - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: return ts.factory.updateClassDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return ts.factory.updateVariableStatement(d, modifiers, d.declarationList); - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return ts.factory.updateModuleDeclaration(d, d.decorators, modifiers, d.name, d.body); - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: return ts.factory.updateEnumDeclaration(d, d.decorators, modifiers, d.name, d.members); - case 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: return ts.factory.updateTypeAliasDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.type); - case 253 /* InterfaceDeclaration */: + case 255 /* InterfaceDeclaration */: return ts.factory.updateInterfaceDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return ts.factory.updateImportEqualsDeclaration(d, d.decorators, modifiers, d.isTypeOnly, d.name, d.moduleReference); - case 233 /* ExpressionStatement */: + case 235 /* 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); @@ -146368,18 +151427,18 @@ var ts; } function getNamesToExportInCommonJS(decl) { switch (decl.kind) { - case 251 /* FunctionDeclaration */: - case 252 /* ClassDeclaration */: + case 253 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: return [decl.name.text]; // TODO: GH#18217 - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return ts.mapDefined(decl.declarationList.declarations, function (d) { return ts.isIdentifier(d.name) ? d.name.text : undefined; }); - case 256 /* ModuleDeclaration */: - case 255 /* EnumDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 253 /* InterfaceDeclaration */: - case 260 /* ImportEqualsDeclaration */: + case 258 /* ModuleDeclaration */: + case 257 /* EnumDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 255 /* InterfaceDeclaration */: + case 262 /* ImportEqualsDeclaration */: return ts.emptyArray; - case 233 /* ExpressionStatement */: + case 235 /* 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); @@ -146387,7 +151446,7 @@ var ts; } /** 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)), 62 /* EqualsToken */, ts.factory.createIdentifier(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))); } })(refactor = ts.refactor || (ts.refactor = {})); })(ts || (ts = {})); @@ -146548,13 +151607,13 @@ var ts; return { edits: [] }; // TODO: GH#30113 } function doChange(sourceFile, program, host, changes, functionDeclaration, groupedReferences) { - var newParamDeclaration = ts.map(createNewParameters(functionDeclaration, program, host), function (param) { return ts.getSynthesizedDeepClone(param); }); - changes.replaceNodeRangeWithNodes(sourceFile, ts.first(functionDeclaration.parameters), ts.last(functionDeclaration.parameters), newParamDeclaration, { joiner: ", ", - // indentation is set to 0 because otherwise the object parameter will be indented if there is a `this` parameter - indentation: 0, - leadingTriviaOption: ts.textChanges.LeadingTriviaOption.IncludeAll, - trailingTriviaOption: ts.textChanges.TrailingTriviaOption.Include - }); + var signature = groupedReferences.signature; + var newFunctionDeclarationParams = ts.map(createNewParameters(functionDeclaration, program, host), function (param) { return ts.getSynthesizedDeepClone(param); }); + if (signature) { + var newSignatureParams = ts.map(createNewParameters(signature, program, host), function (param) { return ts.getSynthesizedDeepClone(param); }); + replaceParameters(signature, newSignatureParams); + } + replaceParameters(functionDeclaration, newFunctionDeclarationParams); var functionCalls = ts.sortAndDeduplicate(groupedReferences.functionCalls, /*comparer*/ function (a, b) { return ts.compareValues(a.pos, b.pos); }); for (var _i = 0, functionCalls_1 = functionCalls; _i < functionCalls_1.length; _i++) { var call = functionCalls_1[_i]; @@ -146563,6 +151622,15 @@ var ts; changes.replaceNodeRange(ts.getSourceFileOfNode(call), ts.first(call.arguments), ts.last(call.arguments), newArgument, { leadingTriviaOption: ts.textChanges.LeadingTriviaOption.IncludeAll, trailingTriviaOption: ts.textChanges.TrailingTriviaOption.Include }); } } + function replaceParameters(declarationOrSignature, parameterDeclarations) { + changes.replaceNodeRangeWithNodes(sourceFile, ts.first(declarationOrSignature.parameters), ts.last(declarationOrSignature.parameters), parameterDeclarations, { + joiner: ", ", + // indentation is set to 0 because otherwise the object parameter will be indented if there is a `this` parameter + indentation: 0, + leadingTriviaOption: ts.textChanges.LeadingTriviaOption.IncludeAll, + trailingTriviaOption: ts.textChanges.TrailingTriviaOption.Include + }); + } } function getGroupedReferences(functionDeclaration, program, cancellationToken) { var functionNames = getFunctionNames(functionDeclaration); @@ -146581,12 +151649,38 @@ var ts; var functionSymbols = ts.map(functionNames, getSymbolTargetAtLocation); var classSymbols = ts.map(classNames, getSymbolTargetAtLocation); var isConstructor = ts.isConstructorDeclaration(functionDeclaration); + 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 !== 1 /* Node */) { + if (entry.kind === 0 /* Span */) { groupedReferences.valid = false; continue; } + /* Declarations in object literals may be implementations of method signatures which have a different symbol from the declaration + For example: + interface IFoo { m(a: number): void } + const foo: IFoo = { m(a: number): void {} } + In these cases we get the symbol for the signature from the contextual type. + */ + if (ts.contains(contextualSymbols, getSymbolTargetAtLocation(entry.node))) { + if (isValidMethodSignature(entry.node.parent)) { + groupedReferences.signature = entry.node.parent; + continue; + } + var call = entryToFunctionCall(entry); + if (call) { + groupedReferences.functionCalls.push(call); + continue; + } + } + var contextualSymbol = getSymbolForContextualType(entry.node, checker); + if (contextualSymbol && ts.contains(contextualSymbols, contextualSymbol)) { + var decl = entryToDeclaration(entry); + if (decl) { + groupedReferences.declarations.push(decl); + continue; + } + } /* We compare symbols because in some cases find all references wil return a reference that may or may not be to the refactored function. Example from the refactorConvertParamsToDestructuredObject_methodCallUnion.ts test: class A { foo(a: number, b: number) { return a + b; } } @@ -146649,6 +151743,19 @@ var ts; return symbol && ts.getSymbolTarget(symbol, checker); } } + /** + * Gets the symbol for the contextual type of the node if it is not a union or intersection. + */ + function getSymbolForContextualType(node, checker) { + var element = ts.getContainingObjectLiteralElement(node); + 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 */)) { + return symbol; + } + } + } function entryToImportOrExport(entry) { var node = entry.node; if (ts.isImportSpecifier(node.parent) @@ -146674,15 +151781,15 @@ var ts; var parent = functionReference.parent; switch (parent.kind) { // foo(...) or super(...) or new Foo(...) - case 203 /* CallExpression */: - case 204 /* NewExpression */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: var callOrNewExpression = ts.tryCast(parent, ts.isCallOrNewExpression); if (callOrNewExpression && callOrNewExpression.expression === functionReference) { return callOrNewExpression; } break; // x.foo(...) - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.parent && propertyAccessExpression.name === functionReference) { var callOrNewExpression_1 = ts.tryCast(propertyAccessExpression.parent, ts.isCallOrNewExpression); @@ -146692,7 +151799,7 @@ var ts; } break; // x["foo"](...) - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.parent && elementAccessExpression.argumentExpression === functionReference) { var callOrNewExpression_2 = ts.tryCast(elementAccessExpression.parent, ts.isCallOrNewExpression); @@ -146711,14 +151818,14 @@ var ts; var parent = reference.parent; switch (parent.kind) { // `C.foo` - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.expression === reference) { return propertyAccessExpression; } break; // `C["foo"]` - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.expression === reference) { return elementAccessExpression; @@ -146756,15 +151863,24 @@ var ts; } return false; } + function isValidMethodSignature(node) { + return ts.isMethodSignature(node) && (ts.isInterfaceDeclaration(node.parent) || ts.isTypeLiteralNode(node.parent)); + } function isValidFunctionDeclaration(functionDeclaration, checker) { + var _a; if (!isValidParameterNodeArray(functionDeclaration.parameters, checker)) return false; switch (functionDeclaration.kind) { - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return hasNameOrDefault(functionDeclaration) && isSingleImplementation(functionDeclaration, checker); - case 165 /* MethodDeclaration */: + case 167 /* 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 166 /* Constructor */: + case 168 /* Constructor */: if (ts.isClassDeclaration(functionDeclaration.parent)) { return hasNameOrDefault(functionDeclaration.parent) && isSingleImplementation(functionDeclaration, checker); } @@ -146772,8 +151888,8 @@ var ts; return isValidVariableDeclaration(functionDeclaration.parent.parent) && isSingleImplementation(functionDeclaration, checker); } - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return isValidVariableDeclaration(functionDeclaration.parent); } return false; @@ -146783,7 +151899,7 @@ var ts; } function hasNameOrDefault(functionOrClassDeclaration) { if (!functionOrClassDeclaration.name) { - var defaultKeyword = ts.findModifier(functionOrClassDeclaration, 87 /* DefaultKeyword */); + var defaultKeyword = ts.findModifier(functionOrClassDeclaration, 88 /* DefaultKeyword */); return !!defaultKeyword; } return true; @@ -146923,15 +152039,15 @@ var ts; } function getClassNames(constructorDeclaration) { switch (constructorDeclaration.parent.kind) { - case 252 /* ClassDeclaration */: + case 254 /* 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, 87 /* DefaultKeyword */), "Nameless class declaration should be a default export"); + var defaultModifier = ts.Debug.checkDefined(ts.findModifier(classDeclaration, 88 /* DefaultKeyword */), "Nameless class declaration should be a default export"); return [defaultModifier]; - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: var classExpression = constructorDeclaration.parent; var variableDeclaration = constructorDeclaration.parent.parent; var className = classExpression.name; @@ -146942,25 +152058,25 @@ var ts; } function getFunctionNames(functionDeclaration) { switch (functionDeclaration.kind) { - case 251 /* FunctionDeclaration */: + case 253 /* 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, 87 /* DefaultKeyword */), "Nameless function declaration should be a default export"); + var defaultModifier = ts.Debug.checkDefined(ts.findModifier(functionDeclaration, 88 /* DefaultKeyword */), "Nameless function declaration should be a default export"); return [defaultModifier]; - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: return [functionDeclaration.name]; - case 166 /* Constructor */: - var ctrKeyword = ts.Debug.checkDefined(ts.findChildOfKind(functionDeclaration, 132 /* ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); - if (functionDeclaration.parent.kind === 221 /* ClassExpression */) { + case 168 /* Constructor */: + var ctrKeyword = ts.Debug.checkDefined(ts.findChildOfKind(functionDeclaration, 133 /* ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); + if (functionDeclaration.parent.kind === 223 /* ClassExpression */) { var variableDeclaration = functionDeclaration.parent.parent; return [variableDeclaration.name, ctrKeyword]; } return [ctrKeyword]; - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return [functionDeclaration.parent.name]; - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: if (functionDeclaration.name) return [functionDeclaration.name, functionDeclaration.parent.name]; return [functionDeclaration.parent.name]; @@ -147046,16 +152162,16 @@ var ts; } } function isNotEqualsOperator(node) { - return node.operatorToken.kind !== 62 /* EqualsToken */; + return node.operatorToken.kind !== 63 /* EqualsToken */; } function getParentBinaryExpression(expr) { var container = ts.findAncestor(expr.parent, function (n) { switch (n.kind) { - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: return false; - case 218 /* TemplateExpression */: - case 216 /* BinaryExpression */: + case 220 /* TemplateExpression */: + case 218 /* BinaryExpression */: return !(ts.isBinaryExpression(n.parent) && isNotEqualsOperator(n.parent)); default: return "quit"; @@ -147132,7 +152248,7 @@ var ts; var templateSpans = []; var templateHead = ts.factory.createTemplateHead(headText); copyCommentFromStringLiterals(headIndexes, templateHead); - var _loop_19 = function (i) { + var _loop_20 = function (i) { var currentNode = getExpressionFromParenthesesOrExpression(nodes[i]); copyOperatorComments(i, currentNode); var _c = concatConsecutiveString(i + 1, nodes), newIndex = _c[0], subsequentText = _c[1], stringIndexes = _c[2]; @@ -147156,7 +152272,7 @@ var ts; }; var out_i_1; for (var i = begin; i < nodes.length; i++) { - _loop_19(i); + _loop_20(i); i = out_i_1; } return ts.factory.createTemplateExpression(templateHead, templateSpans); @@ -147356,7 +152472,9 @@ var ts; var body = convertToBlock(func.body); var variableDeclaration = variableInfo.variableDeclaration, variableDeclarationList = variableInfo.variableDeclarationList, statement = variableInfo.statement, name = variableInfo.name; ts.suppressLeadingTrivia(statement); - var newNode = ts.factory.createFunctionDeclaration(func.decorators, statement.modifiers, func.asteriskToken, name, func.typeParameters, func.parameters, func.type, body); + var modifiersFlags = (ts.getCombinedModifierFlags(variableDeclaration) & 1 /* Export */) | ts.getEffectiveModifierFlags(func); + var modifiers = ts.factory.createModifiersFromModifierFlags(modifiersFlags); + var newNode = ts.factory.createFunctionDeclaration(func.decorators, ts.length(modifiers) ? modifiers : undefined, func.asteriskToken, name, func.typeParameters, func.parameters, func.type, body); if (variableDeclarationList.declarations.length === 1) { return ts.textChanges.ChangeTracker.with(context, function (t) { return t.replaceNode(file, statement, newNode); }); } @@ -147414,9 +152532,7 @@ var ts; function getEditsForAction(context) { var info = getInfo(context); if (info && !refactor.isRefactorErrorInfo(info)) { - var edits = ts.textChanges.ChangeTracker.with(context, function (t) { - return t.tryInsertTypeAnnotation(context.file, info.declaration, info.returnTypeNode); - }); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, t, info.declaration, info.returnTypeNode); }); return { renameFilename: undefined, renameLocation: undefined, edits: edits }; } return undefined; @@ -147441,11 +152557,26 @@ var ts; } return ts.emptyArray; } + function doChange(sourceFile, changes, declaration, typeNode) { + var closeParen = ts.findChildOfKind(declaration, 21 /* 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.insertNodeAt(sourceFile, endNode.end, typeNode, { prefix: ": " }); + } + } function getInfo(context) { if (ts.isInJSFile(context.file) || !refactor.refactorKindBeginsWith(inferReturnTypeAction.kind, context.kind)) return; var token = ts.getTokenAtPosition(context.file, context.startPosition); - var declaration = ts.findAncestor(token, isConvertibleDeclaration); + 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" : + isConvertibleDeclaration(n); + }); if (!declaration || !declaration.body || declaration.type) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Return_type_must_be_inferred_from_a_function) }; } @@ -147454,7 +152585,6 @@ var ts; if (!returnType) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_determine_function_return_type) }; } - ; var returnTypeNode = typeChecker.typeToTypeNode(returnType, declaration, 1 /* NoTruncation */); if (returnTypeNode) { return { declaration: declaration, returnTypeNode: returnTypeNode }; @@ -147462,10 +152592,10 @@ var ts; } function isConvertibleDeclaration(node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 167 /* MethodDeclaration */: return true; default: return false; @@ -147492,8 +152622,8 @@ var ts; ts.servicesVersion = "0.8"; function createNode(kind, pos, end, parent) { var node = ts.isNodeKind(kind) ? new NodeObject(kind, pos, end) : - kind === 78 /* Identifier */ ? new IdentifierObject(78 /* Identifier */, pos, end) : - kind === 79 /* PrivateIdentifier */ ? new PrivateIdentifierObject(79 /* PrivateIdentifier */, pos, end) : + kind === 79 /* Identifier */ ? new IdentifierObject(79 /* Identifier */, pos, end) : + kind === 80 /* PrivateIdentifier */ ? new PrivateIdentifierObject(80 /* PrivateIdentifier */, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; node.flags = parent.flags & 25358336 /* ContextFlags */; @@ -147567,8 +152697,8 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 301 /* FirstJSDocNode */ || kid.kind > 333 /* LastJSDocNode */; }); - return child.kind < 157 /* FirstNode */ ? + var child = ts.find(children, function (kid) { return kid.kind < 303 /* FirstJSDocNode */ || kid.kind > 341 /* LastJSDocNode */; }); + return child.kind < 159 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; @@ -147579,7 +152709,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 157 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 159 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; NodeObject.prototype.forEachChild = function (cbNode, cbNodeArray) { return ts.forEachChild(this, cbNode, cbNodeArray); @@ -147625,7 +152755,7 @@ var ts; var token = ts.scanner.scan(); var textPos = ts.scanner.getTextPos(); if (textPos <= end) { - if (token === 78 /* Identifier */) { + if (token === 79 /* Identifier */) { ts.Debug.fail("Did not expect " + ts.Debug.formatSyntaxKind(parent.kind) + " to have an Identifier in its trivia"); } nodes.push(createNode(token, pos, textPos, parent)); @@ -147637,11 +152767,11 @@ var ts; } } function createSyntaxList(nodes, parent) { - var list = createNode(334 /* SyntaxList */, nodes.pos, nodes.end, parent); + var list = createNode(342 /* SyntaxList */, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; - for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { - var node = nodes_1[_i]; + for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) { + var node = nodes_2[_i]; addSyntheticNodes(list._children, pos, node.pos, parent); list._children.push(node); pos = node.end; @@ -147748,13 +152878,13 @@ var ts; }; SymbolObject.prototype.getContextualDocumentationComment = function (context, checker) { switch (context === null || context === void 0 ? void 0 : context.kind) { - case 167 /* GetAccessor */: + case 169 /* GetAccessor */: if (!this.contextualGetAccessorDocumentationComment) { this.contextualGetAccessorDocumentationComment = ts.emptyArray; this.contextualGetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isGetAccessor), checker); } return this.contextualGetAccessorDocumentationComment; - case 168 /* SetAccessor */: + case 170 /* SetAccessor */: if (!this.contextualSetAccessorDocumentationComment) { this.contextualSetAccessorDocumentationComment = ts.emptyArray; this.contextualSetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isSetAccessor), checker); @@ -147764,9 +152894,9 @@ var ts; return this.getDocumentationComment(checker); } }; - SymbolObject.prototype.getJsDocTags = function () { + SymbolObject.prototype.getJsDocTags = function (checker) { if (this.tags === undefined) { - this.tags = ts.JsDoc.getJsDocTagsFromDeclarations(this.declarations); + this.tags = ts.JsDoc.getJsDocTagsFromDeclarations(this.declarations, checker); } return this.tags; }; @@ -147785,7 +152915,7 @@ var ts; __extends(IdentifierObject, _super); function IdentifierObject(_kind, pos, end) { var _this = _super.call(this, pos, end) || this; - _this.kind = 78 /* Identifier */; + _this.kind = 79 /* Identifier */; return _this; } Object.defineProperty(IdentifierObject.prototype, "text", { @@ -147797,7 +152927,7 @@ var ts; }); return IdentifierObject; }(TokenOrIdentifierObject)); - IdentifierObject.prototype.kind = 78 /* Identifier */; + IdentifierObject.prototype.kind = 79 /* Identifier */; var PrivateIdentifierObject = /** @class */ (function (_super) { __extends(PrivateIdentifierObject, _super); function PrivateIdentifierObject(_kind, pos, end) { @@ -147812,7 +152942,7 @@ var ts; }); return PrivateIdentifierObject; }(TokenOrIdentifierObject)); - PrivateIdentifierObject.prototype.kind = 79 /* PrivateIdentifier */; + PrivateIdentifierObject.prototype.kind = 80 /* PrivateIdentifier */; var TypeObject = /** @class */ (function () { function TypeObject(checker, flags) { this.checker = checker; @@ -147927,7 +153057,7 @@ var ts; }; SignatureObject.prototype.getJsDocTags = function () { if (this.jsDocTags === undefined) { - this.jsDocTags = this.declaration ? getJsDocTags([this.declaration], this.checker) : []; + this.jsDocTags = this.declaration ? getJsDocTagsOfSignature(this.declaration, this.checker) : []; } return this.jsDocTags; }; @@ -147941,29 +153071,34 @@ var ts; function hasJSDocInheritDocTag(node) { return ts.getJSDocTags(node).some(function (tag) { return tag.tagName.text === "inheritDoc"; }); } - function getJsDocTags(declarations, checker) { - var tags = ts.JsDoc.getJsDocTagsFromDeclarations(declarations); - if (tags.length === 0 || declarations.some(hasJSDocInheritDocTag)) { - ts.forEachUnique(declarations, function (declaration) { - var inheritedTags = findBaseOfDeclaration(checker, declaration, function (symbol) { return symbol.getJsDocTags(); }); - if (inheritedTags) { - tags = __spreadArray(__spreadArray([], inheritedTags), tags); - } - }); + function getJsDocTagsOfSignature(declaration, checker) { + var tags = ts.JsDoc.getJsDocTagsFromDeclarations([declaration], checker); + if (tags.length === 0 || hasJSDocInheritDocTag(declaration)) { + var inheritedTags = findBaseOfDeclaration(checker, declaration, function (symbol) { var _a; return ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.length) === 1 ? symbol.getJsDocTags() : undefined; }); + if (inheritedTags) { + tags = __spreadArray(__spreadArray([], inheritedTags), tags); + } } return tags; } function getDocumentationComment(declarations, checker) { if (!declarations) return ts.emptyArray; - var doc = ts.JsDoc.getJsDocCommentsFromDeclarations(declarations); + var doc = ts.JsDoc.getJsDocCommentsFromDeclarations(declarations, checker); if (checker && (doc.length === 0 || declarations.some(hasJSDocInheritDocTag))) { - ts.forEachUnique(declarations, function (declaration) { - var inheritedDocs = findBaseOfDeclaration(checker, declaration, function (symbol) { return symbol.getDocumentationComment(checker); }); + var seenSymbols_1 = new ts.Set(); + for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { + var declaration = declarations_4[_i]; + var inheritedDocs = findBaseOfDeclaration(checker, declaration, function (symbol) { + if (!seenSymbols_1.has(symbol)) { + seenSymbols_1.add(symbol); + return symbol.getDocumentationComment(checker); + } + }); // TODO: GH#16312 Return a ReadonlyArray, avoid copying inheritedDocs if (inheritedDocs) doc = doc.length === 0 ? inheritedDocs.slice() : inheritedDocs.concat(ts.lineBreakPart(), doc); - }); + } } return doc; } @@ -147977,7 +153112,7 @@ var ts; __extends(SourceFileObject, _super); function SourceFileObject(kind, pos, end) { var _this = _super.call(this, kind, pos, end) || this; - _this.kind = 297 /* SourceFile */; + _this.kind = 299 /* SourceFile */; return _this; } SourceFileObject.prototype.update = function (newText, textChangeRange) { @@ -148036,10 +153171,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -148059,31 +153194,31 @@ var ts; } ts.forEachChild(node, visit); break; - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 255 /* EnumDeclaration */: - case 256 /* ModuleDeclaration */: - case 260 /* ImportEqualsDeclaration */: - case 270 /* ExportSpecifier */: - case 265 /* ImportSpecifier */: - case 262 /* ImportClause */: - case 263 /* NamespaceImport */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 177 /* TypeLiteral */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 257 /* EnumDeclaration */: + case 258 /* ModuleDeclaration */: + case 262 /* ImportEqualsDeclaration */: + case 272 /* ExportSpecifier */: + case 267 /* ImportSpecifier */: + case 264 /* ImportClause */: + case 265 /* NamespaceImport */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 179 /* TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 160 /* Parameter */: + case 162 /* Parameter */: // Only consider parameter properties - if (!ts.hasSyntacticModifier(node, 92 /* ParameterPropertyModifier */)) { + if (!ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */)) { break; } // falls through - case 249 /* VariableDeclaration */: - case 198 /* BindingElement */: { + case 251 /* VariableDeclaration */: + case 200 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -148094,12 +153229,12 @@ var ts; } } // falls through - case 291 /* EnumMember */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 293 /* EnumMember */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: addDeclaration(node); break; - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; var exportDeclaration = node; @@ -148112,7 +153247,7 @@ var ts; } } break; - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -148124,7 +153259,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 263 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 265 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -148133,7 +153268,7 @@ var ts; } } break; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) !== 0 /* None */) { addDeclaration(node); } @@ -148227,15 +153362,7 @@ var ts; var fileName = rootFileNames_1[_i]; this.createEntry(fileName, ts.toPath(fileName, this.currentDirectory, getCanonicalFileName)); } - // store the compilation settings - this._compilationSettings = host.getCompilationSettings() || getDefaultCompilerOptions(); } - HostCache.prototype.compilationSettings = function () { - return this._compilationSettings; - }; - HostCache.prototype.getProjectReferences = function () { - return this.host.getProjectReferences && this.host.getProjectReferences(); - }; HostCache.prototype.createEntry = function (fileName, path) { var entry; var scriptSnapshot = this.host.getScriptSnapshot(fileName); @@ -148385,7 +153512,7 @@ var ts; }; CancellationTokenObject.prototype.throwIfCancellationRequested = function () { if (this.isCancellationRequested()) { - ts.tracing.instant("session" /* Session */, "cancellationThrown", { kind: "CancellationTokenObject" }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "cancellationThrown", { kind: "CancellationTokenObject" }); throw new ts.OperationCanceledException(); } }; @@ -148415,7 +153542,7 @@ var ts; }; ThrottledCancellationToken.prototype.throwIfCancellationRequested = function () { if (this.isCancellationRequested()) { - ts.tracing.instant("session" /* Session */, "cancellationThrown", { kind: "ThrottledCancellationToken" }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "cancellationThrown", { kind: "ThrottledCancellationToken" }); throw new ts.OperationCanceledException(); } }; @@ -148515,7 +153642,7 @@ var ts; return sourceFile; } function synchronizeHostData() { - var _a, _b; + var _a, _b, _c; ts.Debug.assert(languageServiceMode !== ts.LanguageServiceMode.Syntactic); // perform fast check if host supports it if (host.getProjectVersion) { @@ -148536,11 +153663,22 @@ var ts; // Get a fresh cache of the host information var hostCache = new HostCache(host, getCanonicalFileName); var rootFileNames = hostCache.getRootFileNames(); + var newSettings = host.getCompilationSettings() || getDefaultCompilerOptions(); var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse; var hasChangedAutomaticTypeDirectiveNames = ts.maybeBind(host, host.hasChangedAutomaticTypeDirectiveNames); - var projectReferences = hostCache.getProjectReferences(); + var projectReferences = (_b = host.getProjectReferences) === null || _b === void 0 ? void 0 : _b.call(host); + var parsedCommandLines; + var parseConfigHost = { + useCaseSensitiveFileNames: useCaseSensitiveFileNames, + fileExists: fileExists, + readFile: readFile, + readDirectory: readDirectory, + trace: ts.maybeBind(host, host.trace), + getCurrentDirectory: function () { return currentDirectory; }, + onUnRecoverableConfigFileDiagnostic: ts.noop, + }; // If the program is already up-to-date, we can reuse it - if (ts.isProgramUptoDate(program, rootFileNames, hostCache.compilationSettings(), function (_path, fileName) { return host.getScriptVersion(fileName); }, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, projectReferences)) { + if (ts.isProgramUptoDate(program, rootFileNames, newSettings, function (_path, fileName) { return host.getScriptVersion(fileName); }, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) { return; } // IMPORTANT - It is critical from this moment onward that we do not check @@ -148548,7 +153686,6 @@ var ts; // instance. If we cancel midway through, we may end up in an inconsistent state where // the program points to old source files that have been invalidated because of // incremental parsing. - var newSettings = hostCache.compilationSettings(); // Now create a new compiler var compilerHost = { getSourceFile: getOrCreateSourceFile, @@ -148570,19 +153707,18 @@ var ts; getDirectories: function (path) { return host.getDirectories ? host.getDirectories(path) : []; }, - readDirectory: function (path, extensions, exclude, include, depth) { - ts.Debug.checkDefined(host.readDirectory, "'LanguageServiceHost.readDirectory' must be implemented to correctly process 'projectReferences'"); - return host.readDirectory(path, extensions, exclude, include, depth); - }, + readDirectory: readDirectory, onReleaseOldSourceFile: onReleaseOldSourceFile, + onReleaseParsedCommandLine: onReleaseParsedCommandLine, hasInvalidatedResolution: hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames: hasChangedAutomaticTypeDirectiveNames, - trace: ts.maybeBind(host, host.trace), + trace: parseConfigHost.trace, resolveModuleNames: ts.maybeBind(host, host.resolveModuleNames), resolveTypeReferenceDirectives: ts.maybeBind(host, host.resolveTypeReferenceDirectives), useSourceOfProjectReferenceRedirect: ts.maybeBind(host, host.useSourceOfProjectReferenceRedirect), + getParsedCommandLine: getParsedCommandLine, }; - (_b = host.setCompilerHost) === null || _b === void 0 ? void 0 : _b.call(host, compilerHost); + (_c = host.setCompilerHost) === null || _c === void 0 ? void 0 : _c.call(host, compilerHost); var documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings); var options = { rootNames: rootFileNames, @@ -148595,6 +153731,7 @@ var ts; // hostCache is captured in the closure for 'getOrCreateSourceFile' but it should not be used past this point. // It needs to be cleared to allow all collected snapshots to be released hostCache = undefined; + parsedCommandLines = undefined; // We reset this cache on structure invalidation so we don't hold on to outdated files for long; however we can't use the `compilerHost` above, // Because it only functions until `hostCache` is cleared, while we'll potentially need the functionality to lazily read sourcemap files during // the course of whatever called `synchronizeHostData` @@ -148603,6 +153740,36 @@ var ts; // pointers set property. program.getTypeChecker(); return; + function getParsedCommandLine(fileName) { + var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); + var existing = parsedCommandLines === null || parsedCommandLines === void 0 ? void 0 : parsedCommandLines.get(path); + if (existing !== undefined) + return existing || undefined; + var result = host.getParsedCommandLine ? + host.getParsedCommandLine(fileName) : + getParsedCommandLineOfConfigFileUsingSourceFile(fileName); + (parsedCommandLines || (parsedCommandLines = new ts.Map())).set(path, result || false); + return result; + } + function getParsedCommandLineOfConfigFileUsingSourceFile(configFileName) { + var result = getOrCreateSourceFile(configFileName, 100 /* JSON */); + if (!result) + return undefined; + result.path = ts.toPath(configFileName, currentDirectory, getCanonicalFileName); + result.resolvedPath = result.path; + result.originalFileName = result.fileName; + return ts.parseJsonSourceFileConfigFileContent(result, parseConfigHost, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), + /*optionsToExtend*/ undefined, ts.getNormalizedAbsolutePath(configFileName, currentDirectory)); + } + function onReleaseParsedCommandLine(configFileName, oldResolvedRef, oldOptions) { + var _a; + if (host.getParsedCommandLine) { + (_a = host.onReleaseParsedCommandLine) === null || _a === void 0 ? void 0 : _a.call(host, configFileName, oldResolvedRef, oldOptions); + } + else if (oldResolvedRef) { + onReleaseOldSourceFile(oldResolvedRef.sourceFile, oldOptions); + } + } function fileExists(fileName) { var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); var entry = hostCache && hostCache.getEntryByPath(path); @@ -148619,11 +153786,15 @@ var ts; } return host.readFile && host.readFile(fileName); } + function readDirectory(path, extensions, exclude, include, depth) { + ts.Debug.checkDefined(host.readDirectory, "'LanguageServiceHost.readDirectory' must be implemented to correctly process 'projectReferences'"); + return host.readDirectory(path, extensions, exclude, include, depth); + } // Release any files we have acquired in the old program but are // not part of the new program. function onReleaseOldSourceFile(oldSourceFile, oldOptions) { var oldSettingsKey = documentRegistry.getKeyForCompilationSettings(oldOptions); - documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, oldSettingsKey); + documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, oldSettingsKey, oldSourceFile.scriptKind); } function getOrCreateSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile) { return getOrCreateSourceFileByPath(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), languageVersion, onError, shouldCreateNewSourceFile); @@ -148668,8 +153839,13 @@ var ts; // We do not support the scenario where a host can modify a registered // file's script kind, i.e. in one project some file is treated as ".ts" // and in another as ".js" - ts.Debug.assertEqual(hostFileInformation.scriptKind, oldSourceFile.scriptKind, "Registered script kind should match new script kind."); - return documentRegistry.updateDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind); + if (hostFileInformation.scriptKind === oldSourceFile.scriptKind) { + return documentRegistry.updateDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind); + } + 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); + } } // We didn't already have the file. Fall through and acquire it from the registry. } @@ -148698,7 +153874,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); + return documentRegistry.releaseDocumentWithKey(f.resolvedPath, key_1, f.scriptKind); }); program = undefined; // TODO: GH#18217 } @@ -148741,10 +153917,10 @@ var ts; synchronizeHostData(); return ts.Completions.getCompletionsAtPosition(host, program, log, getValidSourceFile(fileName), position, fullPreferences, options.triggerCharacter); } - function getCompletionEntryDetails(fileName, position, name, formattingOptions, source, preferences) { + function getCompletionEntryDetails(fileName, position, name, formattingOptions, source, preferences, data) { if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); - return ts.Completions.getCompletionEntryDetails(program, log, getValidSourceFile(fileName), position, { name: name, source: source }, host, (formattingOptions && ts.formatting.getFormatContext(formattingOptions, host)), // TODO: GH#18217 + return ts.Completions.getCompletionEntryDetails(program, log, getValidSourceFile(fileName), position, { name: name, source: source, data: data }, host, (formattingOptions && ts.formatting.getFormatContext(formattingOptions, host)), // TODO: GH#18217 preferences, cancellationToken); } function getCompletionEntrySymbol(fileName, position, name, source, preferences) { @@ -148771,7 +153947,7 @@ var ts; 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, - tags: type_2.symbol ? type_2.symbol.getJsDocTags() : undefined + tags: type_2.symbol ? type_2.symbol.getJsDocTags(typeChecker) : undefined }; } var _a = typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { @@ -148790,19 +153966,23 @@ var ts; if (ts.isNewExpression(node.parent) && node.pos === node.parent.pos) { return node.parent.expression; } + if (ts.isNamedTupleMember(node.parent) && node.pos === node.parent.pos) { + return node.parent; + } return node; } function shouldGetType(sourceFile, node, position) { switch (node.kind) { - case 78 /* Identifier */: - return !ts.isLabelName(node) && !ts.isTagName(node); - case 201 /* PropertyAccessExpression */: - case 157 /* QualifiedName */: + case 79 /* Identifier */: + return !ts.isLabelName(node) && !ts.isTagName(node) && !ts.isConstTypeReference(node.parent); + case 203 /* PropertyAccessExpression */: + case 159 /* QualifiedName */: // Don't return quickInfo if inside the comment in `a/**/.b` return !ts.isInComment(sourceFile, position); - case 107 /* ThisKeyword */: - case 187 /* ThisType */: - case 105 /* SuperKeyword */: + case 108 /* ThisKeyword */: + case 189 /* ThisType */: + case 106 /* SuperKeyword */: + case 194 /* NamedTupleMember */: return true; default: return false; @@ -148907,16 +154087,16 @@ var ts; return undefined; } switch (node.kind) { - case 201 /* PropertyAccessExpression */: - case 157 /* QualifiedName */: + case 203 /* PropertyAccessExpression */: + case 159 /* QualifiedName */: case 10 /* StringLiteral */: - case 94 /* FalseKeyword */: - case 109 /* TrueKeyword */: - case 103 /* NullKeyword */: - case 105 /* SuperKeyword */: - case 107 /* ThisKeyword */: - case 187 /* ThisType */: - case 78 /* Identifier */: + case 95 /* FalseKeyword */: + case 110 /* TrueKeyword */: + case 104 /* NullKeyword */: + case 106 /* SuperKeyword */: + case 108 /* ThisKeyword */: + case 189 /* ThisType */: + case 79 /* Identifier */: break; // Cant create the text span default: @@ -148932,7 +154112,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 === 256 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 258 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -148960,15 +154140,7 @@ var ts; function getNavigationTree(fileName) { return ts.NavigationBar.getNavigationTree(syntaxTreeCache.getCurrentSourceFile(fileName), cancellationToken); } - function isTsOrTsxFile(fileName) { - var kind = ts.getScriptKind(fileName, host); - return kind === 3 /* TS */ || kind === 4 /* TSX */; - } function getSemanticClassifications(fileName, span, format) { - if (!isTsOrTsxFile(fileName)) { - // do not run semantic classification on non-ts-or-tsx files - return []; - } synchronizeHostData(); var responseFormat = format || "original" /* Original */; if (responseFormat === "2020" /* TwentyTwenty */) { @@ -148979,10 +154151,6 @@ var ts; } } function getEncodedSemanticClassifications(fileName, span, format) { - if (!isTsOrTsxFile(fileName)) { - // do not run semantic classification on non-ts-or-tsx files - return { spans: [], endOfLineState: 0 /* None */ }; - } synchronizeHostData(); var responseFormat = format || "original" /* Original */; if (responseFormat === "original" /* Original */) { @@ -149073,13 +154241,13 @@ var ts; var formatContext = ts.formatting.getFormatContext(formatOptions, host); return ts.codefix.getAllFixes({ fixId: fixId, sourceFile: sourceFile, program: program, host: host, cancellationToken: cancellationToken, formatContext: formatContext, preferences: preferences }); } - function organizeImports(scope, formatOptions, preferences) { + function organizeImports(args, formatOptions, preferences) { if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); - ts.Debug.assert(scope.type === "file"); - var sourceFile = getValidSourceFile(scope.fileName); + ts.Debug.assert(args.type === "file"); + var sourceFile = getValidSourceFile(args.fileName); var formatContext = ts.formatting.getFormatContext(formatOptions, host); - return ts.OrganizeImports.organizeImports(sourceFile, formatContext, host, program, preferences); + return ts.OrganizeImports.organizeImports(sourceFile, formatContext, host, program, preferences, args.skipDestructiveCodeActions); } function getEditsForFileRename(oldFilePath, newFilePath, formatOptions, preferences) { if (preferences === void 0) { preferences = ts.emptyOptions; } @@ -149096,8 +154264,8 @@ var ts; ? host.installPackage({ fileName: getPath(action.file), packageName: action.packageName }) : Promise.reject("Host does not implement `installPackage`"); } - function getDocCommentTemplateAtPosition(fileName, position) { - return ts.JsDoc.getDocCommentTemplateAtPosition(ts.getNewLineOrDefaultFromHost(host), syntaxTreeCache.getCurrentSourceFile(fileName), position); + function getDocCommentTemplateAtPosition(fileName, position, options) { + return ts.JsDoc.getDocCommentTemplateAtPosition(ts.getNewLineOrDefaultFromHost(host), syntaxTreeCache.getCurrentSourceFile(fileName), position, options); } function isValidBraceCompletionAtPosition(fileName, position, openingBrace) { // '<' is currently not supported, figuring out if we're in a Generic Type vs. a comparison is too @@ -149512,6 +154680,16 @@ var ts; var file = getValidSourceFile(fileName); return ts.refactor.getEditsForRefactor(getRefactorContext(file, positionOrRange, preferences, formatOptions), refactorName, actionName); } + function toLineColumnOffset(fileName, position) { + // Go to Definition supports returning a zero-length span at position 0 for + // non-existent files. We need to special-case the conversion of position 0 + // to avoid a crash trying to get the text for that file, since this function + // otherwise assumes that 'fileName' is the name of a file that exists. + if (position === 0) { + return { line: 0, character: 0 }; + } + return sourceMapper.toLineColumnOffset(fileName, position); + } function prepareCallHierarchy(fileName, position) { synchronizeHostData(); var declarations = ts.CallHierarchy.resolveCallHierarchyDeclaration(program, ts.getTouchingPropertyName(getValidSourceFile(fileName), position)); @@ -149584,7 +154762,7 @@ var ts; getAutoImportProvider: getAutoImportProvider, getApplicableRefactors: getApplicableRefactors, getEditsForRefactor: getEditsForRefactor, - toLineColumnOffset: sourceMapper.toLineColumnOffset, + toLineColumnOffset: toLineColumnOffset, getSourceMapper: function () { return sourceMapper; }, clearSourceMapperCache: function () { return sourceMapper.clearCache(); }, prepareCallHierarchy: prepareCallHierarchy, @@ -149655,7 +154833,7 @@ var ts; */ function literalIsName(node) { return ts.isDeclarationName(node) || - node.parent.kind === 272 /* ExternalModuleReference */ || + node.parent.kind === 274 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node); } @@ -149673,13 +154851,13 @@ var ts; case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: - if (node.parent.kind === 158 /* ComputedPropertyName */) { + if (node.parent.kind === 160 /* ComputedPropertyName */) { return ts.isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; } // falls through - case 78 /* Identifier */: + case 79 /* Identifier */: return ts.isObjectLiteralElement(node.parent) && - (node.parent.parent.kind === 200 /* ObjectLiteralExpression */ || node.parent.parent.kind === 281 /* JsxAttributes */) && + (node.parent.parent.kind === 202 /* ObjectLiteralExpression */ || node.parent.parent.kind === 283 /* JsxAttributes */) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -149721,7 +154899,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 202 /* ElementAccessExpression */ && + node.parent.kind === 204 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -149801,114 +154979,114 @@ var ts; if (node) { var parent = node.parent; switch (node.kind) { - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 249 /* VariableDeclaration */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 251 /* VariableDeclaration */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: return spanInVariableDeclaration(node); - case 160 /* Parameter */: + case 162 /* Parameter */: return spanInParameterDeclaration(node); - case 251 /* FunctionDeclaration */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 166 /* Constructor */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 253 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 168 /* Constructor */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 230 /* Block */: + case 232 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // falls through - case 257 /* ModuleBlock */: + case 259 /* ModuleBlock */: return spanInBlock(node); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return spanInBlock(node.block); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 236 /* WhileStatement */: + case 238 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 235 /* DoStatement */: + case 237 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 248 /* DebuggerStatement */: + case 250 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 234 /* IfStatement */: + case 236 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 241 /* BreakStatement */: - case 240 /* ContinueStatement */: + case 243 /* BreakStatement */: + case 242 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return spanInForStatement(node); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 284 /* CaseClause */: - case 285 /* DefaultClause */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 247 /* TryStatement */: + case 249 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 246 /* ThrowStatement */: + case 248 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } // falls through - case 252 /* ClassDeclaration */: - case 255 /* EnumDeclaration */: - case 291 /* EnumMember */: - case 198 /* BindingElement */: + case 254 /* ClassDeclaration */: + case 257 /* EnumDeclaration */: + case 293 /* EnumMember */: + case 200 /* BindingElement */: // span on complete node return textSpan(node); - case 243 /* WithStatement */: + case 245 /* WithStatement */: // span in statement return spanInNode(node.statement); - case 161 /* Decorator */: + case 163 /* Decorator */: return spanInNodeArray(parent.decorators); - case 196 /* ObjectBindingPattern */: - case 197 /* ArrayBindingPattern */: + case 198 /* ObjectBindingPattern */: + case 199 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: return undefined; // Tokens: case 26 /* SemicolonToken */: @@ -149932,13 +155110,13 @@ var ts; case 29 /* LessThanToken */: return spanInGreaterThanOrLessThanToken(node); // Keywords: - case 114 /* WhileKeyword */: + case 115 /* WhileKeyword */: return spanInWhileKeyword(node); - case 90 /* ElseKeyword */: - case 82 /* CatchKeyword */: - case 95 /* FinallyKeyword */: + case 91 /* ElseKeyword */: + case 83 /* CatchKeyword */: + case 96 /* FinallyKeyword */: return spanInNextNode(node); - case 156 /* OfKeyword */: + case 158 /* OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -149950,14 +155128,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 === 78 /* Identifier */ || - node.kind === 220 /* SpreadElement */ || - node.kind === 288 /* PropertyAssignment */ || - node.kind === 289 /* ShorthandPropertyAssignment */) && + if ((node.kind === 79 /* Identifier */ || + node.kind === 222 /* SpreadElement */ || + node.kind === 290 /* PropertyAssignment */ || + node.kind === 291 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(parent)) { return textSpan(node); } - if (node.kind === 216 /* BinaryExpression */) { + if (node.kind === 218 /* 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 @@ -149966,7 +155144,7 @@ var ts; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(left); } - if (operatorToken.kind === 62 /* EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { + if (operatorToken.kind === 63 /* EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { // Set breakpoint on assignment expression element of destructuring pattern // a = expression of // [a = expression, b, c] = someExpression or @@ -149979,22 +155157,22 @@ var ts; } if (ts.isExpressionNode(node)) { switch (parent.kind) { - case 235 /* DoStatement */: + case 237 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 161 /* Decorator */: + case 163 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 237 /* ForStatement */: - case 239 /* ForOfStatement */: + case 239 /* ForStatement */: + case 241 /* ForOfStatement */: return textSpan(node); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: if (node.parent.operatorToken.kind === 27 /* CommaToken */) { // If this is a comma expression, the breakpoint is possible in this expression return textSpan(node); } break; - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -150003,21 +155181,21 @@ var ts; } } switch (node.parent.kind) { - case 288 /* PropertyAssignment */: + case 290 /* 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 206 /* TypeAssertionExpression */: + case 208 /* TypeAssertionExpression */: // Breakpoint in type assertion goes to its operand if (node.parent.type === node) { return spanInNextNode(node.parent.type); } break; - case 249 /* VariableDeclaration */: - case 160 /* Parameter */: { + case 251 /* VariableDeclaration */: + case 162 /* 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)) { @@ -150025,7 +155203,7 @@ var ts; } break; } - case 216 /* BinaryExpression */: { + case 218 /* BinaryExpression */: { var left = node.parent.left; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left) && node !== left) { // If initializer of destructuring assignment move to previous token @@ -150055,7 +155233,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 238 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 240 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } var parent = variableDeclaration.parent; @@ -150067,7 +155245,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasSyntacticModifier(variableDeclaration, 1 /* Export */) || - parent.parent.kind === 239 /* ForOfStatement */) { + parent.parent.kind === 241 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } if (ts.isVariableDeclarationList(variableDeclaration.parent) && @@ -150108,7 +155286,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasSyntacticModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 252 /* ClassDeclaration */ && functionDeclaration.kind !== 166 /* Constructor */); + (functionDeclaration.parent.kind === 254 /* ClassDeclaration */ && functionDeclaration.kind !== 168 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -150131,26 +155309,26 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement // falls through - case 236 /* WhileStatement */: - case 234 /* IfStatement */: - case 238 /* ForInStatement */: + case 238 /* WhileStatement */: + case 236 /* IfStatement */: + case 240 /* 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 237 /* ForStatement */: - case 239 /* ForOfStatement */: + case 239 /* ForStatement */: + case 241 /* 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 === 250 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 252 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -150175,21 +155353,21 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 222 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 224 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 198 /* BindingElement */) { + if (bindingPattern.parent.kind === 200 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 197 /* ArrayBindingPattern */ && node.kind !== 196 /* ObjectBindingPattern */); - var elements = node.kind === 199 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 222 /* OmittedExpression */ ? element : undefined; }); + ts.Debug.assert(node.kind !== 199 /* ArrayBindingPattern */ && node.kind !== 198 /* ObjectBindingPattern */); + var elements = node.kind === 201 /* ArrayLiteralExpression */ ? node.elements : node.properties; + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 224 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -150197,18 +155375,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 === 216 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 218 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 258 /* CaseBlock */: + case 260 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -150216,25 +155394,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 257 /* ModuleBlock */: + case 259 /* ModuleBlock */: // If this is not an instantiated module block, no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } // falls through - case 255 /* EnumDeclaration */: - case 252 /* ClassDeclaration */: + case 257 /* EnumDeclaration */: + case 254 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 230 /* Block */: + case 232 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // falls through - case 287 /* CatchClause */: + case 289 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 258 /* CaseBlock */: + case 260 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -150242,7 +155420,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 196 /* ObjectBindingPattern */: + case 198 /* 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); @@ -150258,7 +155436,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 197 /* ArrayBindingPattern */: + case 199 /* 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); @@ -150273,12 +155451,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 235 /* DoStatement */ || // Go to while keyword and do action instead - node.parent.kind === 203 /* CallExpression */ || - node.parent.kind === 204 /* NewExpression */) { + if (node.parent.kind === 237 /* DoStatement */ || // Go to while keyword and do action instead + node.parent.kind === 205 /* CallExpression */ || + node.parent.kind === 206 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 207 /* ParenthesizedExpression */) { + if (node.parent.kind === 209 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -150287,21 +155465,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 166 /* Constructor */: - case 236 /* WhileStatement */: - case 235 /* DoStatement */: - case 237 /* ForStatement */: - case 239 /* ForOfStatement */: - case 203 /* CallExpression */: - case 204 /* NewExpression */: - case 207 /* ParenthesizedExpression */: + case 210 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 211 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 168 /* Constructor */: + case 238 /* WhileStatement */: + case 237 /* DoStatement */: + case 239 /* ForStatement */: + case 241 /* ForOfStatement */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: + case 209 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -150311,20 +155489,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 288 /* PropertyAssignment */ || - node.parent.kind === 160 /* Parameter */) { + node.parent.kind === 290 /* PropertyAssignment */ || + node.parent.kind === 162 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 206 /* TypeAssertionExpression */) { + if (node.parent.kind === 208 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 235 /* DoStatement */) { + if (node.parent.kind === 237 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -150332,7 +155510,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 239 /* ForOfStatement */) { + if (node.parent.kind === 241 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -150873,11 +156051,11 @@ var ts; return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ", " + preferences + ")", function () { return _this.languageService.getCompletionsAtPosition(fileName, position, preferences); }); }; /** Get a string based representation of a completion list entry details */ - LanguageServiceShimObject.prototype.getCompletionEntryDetails = function (fileName, position, entryName, formatOptions, source, preferences) { + LanguageServiceShimObject.prototype.getCompletionEntryDetails = function (fileName, position, entryName, formatOptions, source, preferences, data) { var _this = this; return this.forwardJSONCall("getCompletionEntryDetails('" + fileName + "', " + position + ", '" + entryName + "')", function () { var localOptions = formatOptions === undefined ? undefined : JSON.parse(formatOptions); - return _this.languageService.getCompletionEntryDetails(fileName, position, entryName, localOptions, source, preferences); + return _this.languageService.getCompletionEntryDetails(fileName, position, entryName, localOptions, source, preferences, data); }); }; LanguageServiceShimObject.prototype.getFormattingEditsForRange = function (fileName, start, end, options /*Services.FormatCodeOptions*/) { @@ -150901,9 +156079,9 @@ var ts; return _this.languageService.getFormattingEditsAfterKeystroke(fileName, position, key, localOptions); }); }; - LanguageServiceShimObject.prototype.getDocCommentTemplateAtPosition = function (fileName, position) { + LanguageServiceShimObject.prototype.getDocCommentTemplateAtPosition = function (fileName, position, options) { var _this = this; - return this.forwardJSONCall("getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position); }); + return this.forwardJSONCall("getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position, options); }); }; /// NAVIGATE TO /** Return a list of symbols that are interesting to navigate to */ @@ -151985,6 +157163,7 @@ var ts; WatchFileKind["FixedPollingInterval"] = "FixedPollingInterval"; WatchFileKind["PriorityPollingInterval"] = "PriorityPollingInterval"; WatchFileKind["DynamicPriorityPolling"] = "DynamicPriorityPolling"; + WatchFileKind["FixedChunkSizePolling"] = "FixedChunkSizePolling"; WatchFileKind["UseFsEvents"] = "UseFsEvents"; WatchFileKind["UseFsEventsOnParentDirectory"] = "UseFsEventsOnParentDirectory"; })(WatchFileKind = protocol.WatchFileKind || (protocol.WatchFileKind = {})); @@ -151993,12 +157172,14 @@ var ts; WatchDirectoryKind["UseFsEvents"] = "UseFsEvents"; WatchDirectoryKind["FixedPollingInterval"] = "FixedPollingInterval"; WatchDirectoryKind["DynamicPriorityPolling"] = "DynamicPriorityPolling"; + WatchDirectoryKind["FixedChunkSizePolling"] = "FixedChunkSizePolling"; })(WatchDirectoryKind = protocol.WatchDirectoryKind || (protocol.WatchDirectoryKind = {})); var PollingWatchKind; (function (PollingWatchKind) { PollingWatchKind["FixedInterval"] = "FixedInterval"; PollingWatchKind["PriorityInterval"] = "PriorityInterval"; PollingWatchKind["DynamicPriority"] = "DynamicPriority"; + PollingWatchKind["FixedChunkSize"] = "FixedChunkSize"; })(PollingWatchKind = protocol.PollingWatchKind || (protocol.PollingWatchKind = {})); var IndentStyle; (function (IndentStyle) { @@ -152051,8 +157232,37 @@ var ts; ScriptTarget["ES2018"] = "ES2018"; ScriptTarget["ES2019"] = "ES2019"; ScriptTarget["ES2020"] = "ES2020"; + ScriptTarget["ES2021"] = "ES2021"; ScriptTarget["ESNext"] = "ESNext"; })(ScriptTarget = protocol.ScriptTarget || (protocol.ScriptTarget = {})); + var ClassificationType; + (function (ClassificationType) { + ClassificationType[ClassificationType["comment"] = 1] = "comment"; + ClassificationType[ClassificationType["identifier"] = 2] = "identifier"; + ClassificationType[ClassificationType["keyword"] = 3] = "keyword"; + ClassificationType[ClassificationType["numericLiteral"] = 4] = "numericLiteral"; + ClassificationType[ClassificationType["operator"] = 5] = "operator"; + ClassificationType[ClassificationType["stringLiteral"] = 6] = "stringLiteral"; + ClassificationType[ClassificationType["regularExpressionLiteral"] = 7] = "regularExpressionLiteral"; + ClassificationType[ClassificationType["whiteSpace"] = 8] = "whiteSpace"; + ClassificationType[ClassificationType["text"] = 9] = "text"; + ClassificationType[ClassificationType["punctuation"] = 10] = "punctuation"; + ClassificationType[ClassificationType["className"] = 11] = "className"; + ClassificationType[ClassificationType["enumName"] = 12] = "enumName"; + ClassificationType[ClassificationType["interfaceName"] = 13] = "interfaceName"; + ClassificationType[ClassificationType["moduleName"] = 14] = "moduleName"; + ClassificationType[ClassificationType["typeParameterName"] = 15] = "typeParameterName"; + ClassificationType[ClassificationType["typeAliasName"] = 16] = "typeAliasName"; + ClassificationType[ClassificationType["parameterName"] = 17] = "parameterName"; + ClassificationType[ClassificationType["docCommentTagName"] = 18] = "docCommentTagName"; + ClassificationType[ClassificationType["jsxOpenTagName"] = 19] = "jsxOpenTagName"; + ClassificationType[ClassificationType["jsxCloseTagName"] = 20] = "jsxCloseTagName"; + ClassificationType[ClassificationType["jsxSelfClosingTagName"] = 21] = "jsxSelfClosingTagName"; + ClassificationType[ClassificationType["jsxAttribute"] = 22] = "jsxAttribute"; + ClassificationType[ClassificationType["jsxText"] = 23] = "jsxText"; + ClassificationType[ClassificationType["jsxAttributeStringLiteralValue"] = 24] = "jsxAttributeStringLiteralValue"; + ClassificationType[ClassificationType["bigintLiteral"] = 25] = "bigintLiteral"; + })(ClassificationType = protocol.ClassificationType || (protocol.ClassificationType = {})); })(protocol = server.protocol || (server.protocol = {})); })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); @@ -152248,7 +157458,7 @@ var ts; if (this.pendingReloadFromDisk) { this.reloadWithFileText(); } - // At this point if svc is present its valid + // At this point if svc is present it's valid return this.svc; }; TextStorage.prototype.getOrLoadText = function () { @@ -152364,16 +157574,24 @@ var ts; ScriptInfo.prototype.getRealpathIfDifferent = function () { return this.realpath && this.realpath !== this.path ? this.realpath : undefined; }; + /** + * @internal + * Does not compute realpath; uses precomputed result. Use `ensureRealPath` + * first if a definite result is needed. + */ + ScriptInfo.prototype.isSymlink = function () { + return this.realpath && this.realpath !== this.path; + }; ScriptInfo.prototype.getFormatCodeSettings = function () { return this.formatSettings; }; ScriptInfo.prototype.getPreferences = function () { return this.preferences; }; ScriptInfo.prototype.attachToProject = function (project) { var isNew = !this.isAttached(project); if (isNew) { this.containingProjects.push(project); - project.onFileAddedOrRemoved(); if (!project.getCompilerOptions().preserveSymlinks) { this.ensureRealPath(); } + project.onFileAddedOrRemoved(this.isSymlink()); } return isNew; }; @@ -152393,23 +157611,23 @@ var ts; return; case 1: if (this.containingProjects[0] === project) { - project.onFileAddedOrRemoved(); + project.onFileAddedOrRemoved(this.isSymlink()); this.containingProjects.pop(); } break; case 2: if (this.containingProjects[0] === project) { - project.onFileAddedOrRemoved(); + project.onFileAddedOrRemoved(this.isSymlink()); this.containingProjects[0] = this.containingProjects.pop(); } else if (this.containingProjects[1] === project) { - project.onFileAddedOrRemoved(); + project.onFileAddedOrRemoved(this.isSymlink()); this.containingProjects.pop(); } break; default: if (ts.unorderedRemoveItem(this.containingProjects, project)) { - project.onFileAddedOrRemoved(); + project.onFileAddedOrRemoved(this.isSymlink()); } break; } @@ -152423,6 +157641,7 @@ var ts; var existingRoot = p.getRootFilesMap().get(this.path); // detach is unnecessary since we'll clean the list of containing projects anyways p.removeFile(this, /*fileExists*/ false, /*detachFromProjects*/ false); + p.onFileAddedOrRemoved(this.isSymlink()); // If the info was for the external or configured project's root, // add missing file as the root if (existingRoot && !server.isInferredProject(p)) { @@ -152819,6 +158038,8 @@ var ts; this.cachedUnresolvedImportsPerFile = new ts.Map(); /*@internal*/ this.hasAddedorRemovedFiles = false; + /*@internal*/ + this.hasAddedOrRemovedSymlinks = false; /** * Last version that was reported. */ @@ -152841,7 +158062,9 @@ var ts; /*@internal*/ this.typingFiles = server.emptyArray; /*@internal*/ - this.importSuggestionsCache = ts.Completions.createImportSuggestionsForFileCache(); + this.exportMapCache = ts.createExportMapCache(); + /*@internal*/ + this.moduleSpecifierCache = ts.createModuleSpecifierCache(); /*@internal*/ this.globalCacheResolutionModuleName = ts.JsTyping.nonRelativeModuleNameForTypingCache; this.directoryStructureHost = directoryStructureHost; @@ -153164,7 +158387,7 @@ var ts; return []; } server.updateProjectIfDirty(this); - this.builderState = ts.BuilderState.create(this.program, this.projectService.toCanonicalFileName, this.builderState); + 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; }); }; /** @@ -153467,8 +158690,8 @@ var ts; /*@internal*/ Project.prototype.markFileAsDirty = function (changedFile) { this.markAsDirty(); - if (!this.importSuggestionsCache.isEmpty()) { - (this.dirtyFilesForSuggestions || (this.dirtyFilesForSuggestions = new ts.Set())).add(changedFile); + if (!this.exportMapCache.isEmpty()) { + (this.changedFilesForExportMapCache || (this.changedFilesForExportMapCache = new ts.Set())).add(changedFile); } }; Project.prototype.markAsDirty = function () { @@ -153478,17 +158701,31 @@ var ts; } }; /*@internal*/ - Project.prototype.markAutoImportProviderAsDirty = function () { + Project.prototype.onAutoImportProviderSettingsChanged = function () { var _a; if (this.autoImportProviderHost === false) { this.autoImportProviderHost = undefined; } - (_a = this.autoImportProviderHost) === null || _a === void 0 ? void 0 : _a.markAsDirty(); - this.importSuggestionsCache.clear(); + else { + (_a = this.autoImportProviderHost) === null || _a === void 0 ? void 0 : _a.markAsDirty(); + } + }; + /*@internal*/ + Project.prototype.onPackageJsonChange = function (packageJsonPath) { + var _a; + if ((_a = this.packageJsonsForAutoImport) === null || _a === void 0 ? void 0 : _a.has(packageJsonPath)) { + this.moduleSpecifierCache.clear(); + if (this.autoImportProviderHost) { + this.autoImportProviderHost.markAsDirty(); + } + } }; /* @internal */ - Project.prototype.onFileAddedOrRemoved = function () { + Project.prototype.onFileAddedOrRemoved = function (isSymlink) { this.hasAddedorRemovedFiles = true; + if (isSymlink) { + this.hasAddedOrRemovedSymlinks = true; + } }; /** * Updates set of files that contribute to this project @@ -153501,6 +158738,7 @@ var ts; var hasNewProgram = this.updateGraphWorker(); var hasAddedorRemovedFiles = this.hasAddedorRemovedFiles; this.hasAddedorRemovedFiles = false; + this.hasAddedOrRemovedSymlinks = false; var changedFiles = this.resolutionCache.finishRecordingFilesWithChangedResolutions() || server.emptyArray; for (var _i = 0, changedFiles_1 = changedFiles; _i < changedFiles_1.length; _i++) { var file = changedFiles_1[_i]; @@ -153543,11 +158781,14 @@ var ts; /*@internal*/ Project.prototype.updateTypingFiles = function (typingFiles) { var _this = this; - ts.enumerateInsertsAndDeletes(typingFiles, this.typingFiles, ts.getStringComparer(!this.useCaseSensitiveFileNames()), - /*inserted*/ ts.noop, function (removed) { return _this.detachScriptInfoFromProject(removed); }); - this.typingFiles = typingFiles; - // Invalidate files with unresolved imports - this.resolutionCache.setFilesWithInvalidatedNonRelativeUnresolvedImports(this.cachedUnresolvedImportsPerFile); + if (ts.enumerateInsertsAndDeletes(typingFiles, this.typingFiles, ts.getStringComparer(!this.useCaseSensitiveFileNames()), + /*inserted*/ ts.noop, function (removed) { return _this.detachScriptInfoFromProject(removed); })) { + // If typing files changed, then only schedule project update + this.typingFiles = typingFiles; + // Invalidate files with unresolved imports + this.resolutionCache.setFilesWithInvalidatedNonRelativeUnresolvedImports(this.cachedUnresolvedImportsPerFile); + this.projectService.delayUpdateProjectGraphAndEnsureProjectStructureForOpenFiles(this); + } }; /* @internal */ Project.prototype.getCurrentProgram = function () { @@ -153572,8 +158813,9 @@ var ts; // 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 = this.program && (!oldProgram || (this.program !== oldProgram && !(this.program.structureIsReused & 2 /* Completely */))); - if (hasNewProgram) { + var hasNewProgram = false; + if (this.program && (!oldProgram || (this.program !== oldProgram && this.program.structureIsReused !== 2 /* Completely */))) { + hasNewProgram = true; if (oldProgram) { for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { var f = _a[_i]; @@ -153625,26 +158867,29 @@ var ts; this.resolutionCache.updateTypeRootsWatch(); } } - if (!this.importSuggestionsCache.isEmpty()) { + if (!this.exportMapCache.isEmpty()) { if (this.hasAddedorRemovedFiles || oldProgram && !this.program.structureIsReused) { - this.importSuggestionsCache.clear(); - } - else if (this.dirtyFilesForSuggestions && oldProgram && this.program) { - ts.forEachKey(this.dirtyFilesForSuggestions, function (fileName) { - var oldSourceFile = oldProgram.getSourceFile(fileName); - var sourceFile = _this.program.getSourceFile(fileName); - if (_this.sourceFileHasChangedOwnImportSuggestions(oldSourceFile, sourceFile)) { - _this.importSuggestionsCache.clear(); + this.exportMapCache.clear(); + } + else if (this.changedFilesForExportMapCache && oldProgram && this.program) { + ts.forEachKey(this.changedFilesForExportMapCache, function (fileName) { + var oldSourceFile = oldProgram.getSourceFileByPath(fileName); + var sourceFile = _this.program.getSourceFileByPath(fileName); + if (!oldSourceFile || !sourceFile) { + _this.exportMapCache.clear(); return true; } + return _this.exportMapCache.onFileChanged(oldSourceFile, sourceFile, !!_this.getTypeAcquisition().enable); }); } } - if (this.dirtyFilesForSuggestions) { - this.dirtyFilesForSuggestions.clear(); + if (this.changedFilesForExportMapCache) { + this.changedFilesForExportMapCache.clear(); } - if (this.hasAddedorRemovedFiles) { + if (this.hasAddedOrRemovedSymlinks || this.program && !this.program.structureIsReused && this.getCompilerOptions().preserveSymlinks) { + // With --preserveSymlinks, we may not determine that a file is a symlink, so we never set `hasAddedOrRemovedSymlinks` this.symlinks = undefined; + this.moduleSpecifierCache.clear(); } var oldExternalFiles = this.externalFiles || server.emptyArray; this.externalFiles = this.getExternalFiles(); @@ -153658,12 +158903,12 @@ 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 + " Elapsed: " + elapsed + "ms"); + this.writeLog("Finishing updateGraphWorker: Project: " + this.getProjectName() + " Version: " + this.getProjectVersion() + " structureChanged: " + hasNewProgram + (this.program ? " structureIsReused:: " + ts.StructureIsReused[this.program.structureIsReused] : "") + " Elapsed: " + elapsed + "ms"); if (this.hasAddedorRemovedFiles) { this.print(/*writeProjectFileNames*/ true); } else if (this.program !== oldProgram) { - this.writeLog("Different program with same set of files:: structureIsReused:: " + this.program.structureIsReused); + this.writeLog("Different program with same set of files"); } return hasNewProgram; }; @@ -153671,54 +158916,6 @@ var ts; Project.prototype.sendPerformanceEvent = function (kind, durationMs) { this.projectService.sendPerformanceEvent(kind, durationMs); }; - /*@internal*/ - Project.prototype.sourceFileHasChangedOwnImportSuggestions = function (oldSourceFile, newSourceFile) { - if (!oldSourceFile && !newSourceFile) { - return false; - } - // Probably shouldn’t get this far, but on the off chance the file was added or removed, - // we can’t reliably tell anything about it. - if (!oldSourceFile || !newSourceFile) { - return true; - } - ts.Debug.assertEqual(oldSourceFile.fileName, newSourceFile.fileName); - // If ATA is enabled, auto-imports uses existing imports to guess whether you want auto-imports from node. - // Adding or removing imports from node could change the outcome of that guess, so could change the suggestions list. - if (this.getTypeAcquisition().enable && ts.consumesNodeCoreModules(oldSourceFile) !== ts.consumesNodeCoreModules(newSourceFile)) { - return true; - } - // Module agumentation and ambient module changes can add or remove exports available to be auto-imported. - // Changes elsewhere in the file can change the *type* of an export in a module augmentation, - // but type info is gathered in getCompletionEntryDetails, which doesn’t use the cache. - if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations) || - !this.ambientModuleDeclarationsAreEqual(oldSourceFile, newSourceFile)) { - return true; - } - return false; - }; - /*@internal*/ - Project.prototype.ambientModuleDeclarationsAreEqual = function (oldSourceFile, newSourceFile) { - if (!ts.arrayIsEqualTo(oldSourceFile.ambientModuleNames, newSourceFile.ambientModuleNames)) { - return false; - } - var oldFileStatementIndex = -1; - var newFileStatementIndex = -1; - var _loop_1 = function (ambientModuleName) { - var isMatchingModuleDeclaration = function (node) { return ts.isNonGlobalAmbientModule(node) && node.name.text === ambientModuleName; }; - oldFileStatementIndex = ts.findIndex(oldSourceFile.statements, isMatchingModuleDeclaration, oldFileStatementIndex + 1); - newFileStatementIndex = ts.findIndex(newSourceFile.statements, isMatchingModuleDeclaration, newFileStatementIndex + 1); - if (oldSourceFile.statements[oldFileStatementIndex] !== newSourceFile.statements[newFileStatementIndex]) { - return { value: false }; - } - }; - for (var _i = 0, _a = newSourceFile.ambientModuleNames; _i < _a.length; _i++) { - var ambientModuleName = _a[_i]; - var state_1 = _loop_1(ambientModuleName); - if (typeof state_1 === "object") - return state_1.value; - } - return true; - }; Project.prototype.detachScriptInfoFromProject = function (uncheckedFileName, noRemoveResolution) { var scriptInfoToDetach = this.projectService.getScriptInfo(uncheckedFileName); if (scriptInfoToDetach) { @@ -153730,6 +158927,13 @@ var ts; }; Project.prototype.addMissingFileWatcher = function (missingFilePath) { var _this = this; + var _a; + if (isConfiguredProject(this)) { + // If this file is referenced config file, we are already watching it, no need to watch again + var configFileExistenceInfo = this.projectService.configFileExistenceInfoCache.get(missingFilePath); + if ((_a = configFileExistenceInfo === null || configFileExistenceInfo === void 0 ? void 0 : configFileExistenceInfo.config) === null || _a === void 0 ? void 0 : _a.projects.has(this.canonicalConfigFilePath)) + return ts.noopFileWatcher; + } var fileWatcher = this.projectService.watchFactory.watchFile(missingFilePath, function (fileName, eventKind) { if (isConfiguredProject(_this)) { _this.getCachedDirectoryStructureHost().addOrDeleteFile(fileName, missingFilePath, eventKind); @@ -153977,7 +159181,7 @@ var ts; ts.combinePaths(this.projectService.getExecutingFilePath(), "../../.."), ]); if (this.projectService.globalPlugins) { - var _loop_2 = function (globalPluginName) { + var _loop_1 = function (globalPluginName) { // Skip empty names from odd commandline parses if (!globalPluginName) return "continue"; @@ -153992,13 +159196,17 @@ var ts; // Enable global plugins with synthetic configuration entries for (var _i = 0, _a = this.projectService.globalPlugins; _i < _a.length; _i++) { var globalPluginName = _a[_i]; - _loop_2(globalPluginName); + _loop_1(globalPluginName); } } }; Project.prototype.enablePlugin = function (pluginConfigEntry, searchPaths, pluginConfigOverrides) { var _this = this; this.projectService.logger.info("Enabling plugin " + pluginConfigEntry.name + " from candidate paths: " + searchPaths.join(",")); + if (!pluginConfigEntry.name || ts.parsePackageName(pluginConfigEntry.name).rest) { + this.projectService.logger.info("Skipped loading plugin " + (pluginConfigEntry.name || JSON.stringify(pluginConfigEntry)) + " because only package name is allowed plugin name"); + return; + } var log = function (message) { return _this.projectService.logger.info(message); }; var errorLogs; var logError = function (message) { (errorLogs || (errorLogs = [])).push(message); }; @@ -154043,7 +159251,7 @@ var ts; newLS[k] = this.languageService[k]; } } - this.projectService.logger.info("Plugin validation succeded"); + this.projectService.logger.info("Plugin validation succeeded"); this.languageService = newLS; this.plugins.push({ name: configEntry.name, module: pluginModule }); } @@ -154080,8 +159288,12 @@ var ts; return packageJsons; }; /*@internal*/ - Project.prototype.getImportSuggestionsCache = function () { - return this.importSuggestionsCache; + Project.prototype.getExportMapCache = function () { + return this.exportMapCache; + }; + /*@internal*/ + Project.prototype.getModuleSpecifierCache = function () { + return this.moduleSpecifierCache; }; /*@internal*/ Project.prototype.includePackageJsonAutoImports = function () { @@ -154168,10 +159380,6 @@ var ts; return unresolvedImports || server.emptyArray; }); } - function createProjectNameFactoryWithCounter(nameFactory) { - var nextId = 1; - return function () { return nameFactory(nextId++); }; - } /** * If a file is opened and no tsconfig (or jsconfig) is found, * the file and its imports/references are put into an InferredProject. @@ -154180,7 +159388,7 @@ var ts; __extends(InferredProject, _super); /*@internal*/ function InferredProject(projectService, documentRegistry, compilerOptions, watchOptions, projectRootPath, currentDirectory, pluginConfigOverrides, typeAcquisition) { - var _this = _super.call(this, InferredProject.newName(), ProjectKind.Inferred, projectService, documentRegistry, + var _this = _super.call(this, projectService.newInferredProjectName(), ProjectKind.Inferred, projectService, documentRegistry, // TODO: GH#18217 /*files*/ undefined, /*lastFileExceededProgramSize*/ undefined, compilerOptions, @@ -154255,7 +159463,6 @@ var ts; exclude: ts.emptyArray }; }; - InferredProject.newName = createProjectNameFactoryWithCounter(server.makeInferredProjectName); return InferredProject; }(Project)); server.InferredProject = InferredProject; @@ -154263,17 +159470,19 @@ var ts; __extends(AutoImportProviderProject, _super); /*@internal*/ function AutoImportProviderProject(hostProject, initialRootNames, documentRegistry, compilerOptions) { - var _this = _super.call(this, AutoImportProviderProject.newName(), ProjectKind.AutoImportProvider, hostProject.projectService, documentRegistry, + var _this = _super.call(this, hostProject.projectService.newAutoImportProviderProjectName(), ProjectKind.AutoImportProvider, hostProject.projectService, documentRegistry, /*hasExplicitListOfFiles*/ false, /*lastFileExceededProgramSize*/ undefined, compilerOptions, /*compileOnSaveEnabled*/ false, hostProject.getWatchOptions(), hostProject.projectService.host, hostProject.currentDirectory) || this; _this.hostProject = hostProject; _this.rootFileNames = initialRootNames; + _this.useSourceOfProjectReferenceRedirect = ts.maybeBind(_this.hostProject, _this.hostProject.useSourceOfProjectReferenceRedirect); + _this.getParsedCommandLine = ts.maybeBind(_this.hostProject, _this.hostProject.getParsedCommandLine); return _this; } /*@internal*/ AutoImportProviderProject.getRootFileNames = function (dependencySelection, hostProject, moduleResolutionHost, compilerOptions) { - var _a, _b, _c, _d; + var _a, _b, _c; if (!dependencySelection) { return ts.emptyArray; } @@ -154288,18 +159497,22 @@ var ts; } if (dependencyNames) { var resolutions = ts.map(ts.arrayFrom(dependencyNames.keys()), function (name) { return ts.resolveTypeReferenceDirective(name, rootFileName, compilerOptions, moduleResolutionHost); }); - for (var _e = 0, resolutions_1 = resolutions; _e < resolutions_1.length; _e++) { - var resolution = resolutions_1[_e]; + var program = hostProject.getCurrentProgram(); + var symlinkCache = hostProject.getSymlinkCache(); + for (var _d = 0, resolutions_1 = resolutions; _d < resolutions_1.length; _d++) { + var resolution = resolutions_1[_d]; if (!((_c = resolution.resolvedTypeReferenceDirective) === null || _c === void 0 ? void 0 : _c.resolvedFileName)) continue; - var resolvedFileName = resolution.resolvedTypeReferenceDirective.resolvedFileName; - var fileName = ((_d = moduleResolutionHost.realpath) === null || _d === void 0 ? void 0 : _d.call(moduleResolutionHost, resolvedFileName)) || resolvedFileName; - if (!hostProject.getCurrentProgram().getSourceFile(fileName) && !hostProject.getCurrentProgram().getSourceFile(resolvedFileName)) { - rootNames = ts.append(rootNames, fileName); + var _e = resolution.resolvedTypeReferenceDirective, resolvedFileName = _e.resolvedFileName, originalPath = _e.originalPath; + if (!program.getSourceFile(resolvedFileName) && (!originalPath || !program.getSourceFile(originalPath))) { + rootNames = ts.append(rootNames, resolvedFileName); // Avoid creating a large project that would significantly slow down time to editor interactivity if (dependencySelection === 2 /* Auto */ && rootNames.length > this.maxDependencies) { return ts.emptyArray; } + if (originalPath) { + symlinkCache.setSymlinkedDirectoryFromSymlinkedFile(originalPath, resolvedFileName); + } } } } @@ -154315,7 +159528,7 @@ var ts; if (dependencySelection === 0 /* Off */) { return undefined; } - var compilerOptions = __assign(__assign({}, hostProject.getCompilerOptions()), { noLib: true, diagnostics: false, skipLibCheck: true, types: ts.emptyArray, lib: ts.emptyArray, sourceMap: false }); + var compilerOptions = __assign(__assign({}, hostProject.getCompilerOptions()), this.compilerOptionsOverrides); var rootNames = this.getRootFileNames(dependencySelection, hostProject, moduleResolutionHost, compilerOptions); if (!rootNames.length) { return undefined; @@ -154336,8 +159549,12 @@ var ts; } this.projectService.setFileNamesOfAutoImportProviderProject(this, rootFileNames); this.rootFileNames = rootFileNames; - this.hostProject.getImportSuggestionsCache().clear(); - return _super.prototype.updateGraph.call(this); + var oldProgram = this.getCurrentProgram(); + var hasSameSetOfFiles = _super.prototype.updateGraph.call(this); + if (oldProgram && oldProgram !== this.getCurrentProgram()) { + this.hostProject.getExportMapCache().clear(); + } + return hasSameSetOfFiles; }; AutoImportProviderProject.prototype.hasRoots = function () { var _a; @@ -154353,18 +159570,20 @@ var ts; AutoImportProviderProject.prototype.getLanguageService = function () { throw new Error("AutoImportProviderProject language service should never be used. To get the program, use `project.getCurrentProgram()`."); }; - AutoImportProviderProject.prototype.markAutoImportProviderAsDirty = function () { + /*@internal*/ + AutoImportProviderProject.prototype.onAutoImportProviderSettingsChanged = function () { throw new Error("AutoImportProviderProject is an auto import provider; use `markAsDirty()` instead."); }; + /*@internal*/ + AutoImportProviderProject.prototype.onPackageJsonChange = function () { + throw new Error("package.json changes should be notified on an AutoImportProvider's host project"); + }; AutoImportProviderProject.prototype.getModuleResolutionHostForAutoImportProvider = function () { throw new Error("AutoImportProviderProject cannot provide its own host; use `hostProject.getModuleResolutionHostForAutomImportProvider()` instead."); }; AutoImportProviderProject.prototype.getProjectReferences = function () { return this.hostProject.getProjectReferences(); }; - AutoImportProviderProject.prototype.useSourceOfProjectReferenceRedirect = function () { - return true; - }; /*@internal*/ AutoImportProviderProject.prototype.includePackageJsonAutoImports = function () { return 0 /* Off */; @@ -154376,9 +159595,17 @@ var ts; AutoImportProviderProject.prototype.getSymlinkCache = function () { return this.hostProject.getSymlinkCache(); }; - AutoImportProviderProject.newName = createProjectNameFactoryWithCounter(server.makeAutoImportProviderProjectName); /*@internal*/ AutoImportProviderProject.maxDependencies = 10; + /*@internal*/ + AutoImportProviderProject.compilerOptionsOverrides = { + diagnostics: false, + skipLibCheck: true, + sourceMap: false, + types: ts.emptyArray, + lib: ts.emptyArray, + noLib: true, + }; return AutoImportProviderProject; }(Project)); server.AutoImportProviderProject = AutoImportProviderProject; @@ -154390,13 +159617,14 @@ var ts; var ConfiguredProject = /** @class */ (function (_super) { __extends(ConfiguredProject, _super); /*@internal*/ - function ConfiguredProject(configFileName, projectService, documentRegistry, cachedDirectoryStructureHost) { + function ConfiguredProject(configFileName, canonicalConfigFilePath, projectService, documentRegistry, cachedDirectoryStructureHost) { var _this = _super.call(this, configFileName, ProjectKind.Configured, projectService, documentRegistry, /*hasExplicitListOfFiles*/ false, /*lastFileExceededProgramSize*/ undefined, /*compilerOptions*/ {}, /*compileOnSaveEnabled*/ false, /*watchOptions*/ undefined, cachedDirectoryStructureHost, ts.getDirectoryPath(configFileName)) || this; + _this.canonicalConfigFilePath = canonicalConfigFilePath; /* @internal */ _this.openFileWatchTriggered = new ts.Map(); /*@internal*/ @@ -154407,7 +159635,6 @@ var ts; _this.isInitialLoadPending = ts.returnTrue; /*@internal*/ _this.sendLoadingProjectFinish = false; - _this.canonicalConfigFilePath = server.asNormalizedPath(projectService.toCanonicalFileName(configFileName)); return _this; } /* @internal */ @@ -154423,22 +159650,30 @@ var ts; return this.languageServiceEnabled; }; /* @internal */ - ConfiguredProject.prototype.setWatchOptions = function (watchOptions) { - var oldOptions = this.getWatchOptions(); - _super.prototype.setWatchOptions.call(this, watchOptions); - // If watch options different than older options - if (this.isInitialLoadPending() && - !ts.isJsonEqual(oldOptions, this.getWatchOptions())) { - var oldWatcher = this.configFileWatcher; - this.createConfigFileWatcher(); - if (oldWatcher) - oldWatcher.close(); + ConfiguredProject.prototype.getParsedCommandLine = function (fileName) { + var configFileName = server.asNormalizedPath(ts.normalizePath(fileName)); + var canonicalConfigFilePath = server.asNormalizedPath(this.projectService.toCanonicalFileName(configFileName)); + // Ensure the config file existience info is cached + var configFileExistenceInfo = this.projectService.configFileExistenceInfoCache.get(canonicalConfigFilePath); + if (!configFileExistenceInfo) { + this.projectService.configFileExistenceInfoCache.set(canonicalConfigFilePath, configFileExistenceInfo = { exists: this.projectService.host.fileExists(configFileName) }); + } + // Ensure we have upto date parsed command line + this.projectService.ensureParsedConfigUptoDate(configFileName, canonicalConfigFilePath, configFileExistenceInfo, this); + // Watch wild cards if LS is enabled + if (this.languageServiceEnabled && this.projectService.serverMode === ts.LanguageServiceMode.Semantic) { + this.projectService.watchWildcards(configFileName, configFileExistenceInfo, this); } + return configFileExistenceInfo.exists ? configFileExistenceInfo.config.parsedCommandLine : undefined; }; /* @internal */ - ConfiguredProject.prototype.createConfigFileWatcher = function () { - var _this = this; - this.configFileWatcher = this.projectService.watchFactory.watchFile(this.getConfigFilePath(), function (_fileName, eventKind) { return _this.projectService.onConfigChangedForConfiguredProject(_this, eventKind); }, ts.PollingInterval.High, this.projectService.getWatchOptions(this), ts.WatchType.ConfigFile, this); + ConfiguredProject.prototype.onReleaseParsedCommandLine = function (fileName) { + this.releaseParsedConfig(server.asNormalizedPath(this.projectService.toCanonicalFileName(server.asNormalizedPath(ts.normalizePath(fileName))))); + }; + /* @internal */ + ConfiguredProject.prototype.releaseParsedConfig = function (canonicalConfigFilePath) { + this.projectService.stopWatchingWildCards(canonicalConfigFilePath, this); + this.projectService.releaseParsedConfig(canonicalConfigFilePath, this); }; /** * If the project has reload from disk pending, it reloads (and then updates graph as part of that) instead of just updating the graph @@ -154538,27 +159773,11 @@ var ts; ConfiguredProject.prototype.setProjectErrors = function (projectErrors) { this.projectErrors = projectErrors; }; - /*@internal*/ - ConfiguredProject.prototype.watchWildcards = function (wildcardDirectories) { - var _this = this; - ts.updateWatchingWildcardDirectories(this.directoriesWatchedForWildcards || (this.directoriesWatchedForWildcards = new ts.Map()), wildcardDirectories, - // Create new directory watcher - function (directory, flags) { return _this.projectService.watchWildcardDirectory(directory, flags, _this); }); - }; - /*@internal*/ - ConfiguredProject.prototype.stopWatchingWildCards = function () { - if (this.directoriesWatchedForWildcards) { - ts.clearMap(this.directoriesWatchedForWildcards, ts.closeFileWatcherOf); - this.directoriesWatchedForWildcards = undefined; - } - }; ConfiguredProject.prototype.close = function () { - if (this.configFileWatcher) { - this.configFileWatcher.close(); - this.configFileWatcher = undefined; - } - this.stopWatchingWildCards(); - this.projectService.removeProjectFromSharedExtendedConfigFileMap(this); + var _this = this; + this.projectService.configFileExistenceInfoCache.forEach(function (_configFileExistenceInfo, canonicalConfigFilePath) { + return _this.releaseParsedConfig(canonicalConfigFilePath); + }); this.projectErrors = undefined; this.openFileWatchTriggered.clear(); this.compilerHost = undefined; @@ -154588,6 +159807,7 @@ var ts; /* @internal */ ConfiguredProject.prototype.hasOpenRef = function () { var _this = this; + var _a; if (!!this.externalProjectRefCount) { return true; } @@ -154595,17 +159815,17 @@ var ts; if (this.isClosed()) { return false; } - var configFileExistenceInfo = this.projectService.getConfigFileExistenceInfo(this); + var configFileExistenceInfo = this.projectService.configFileExistenceInfoCache.get(this.canonicalConfigFilePath); if (this.projectService.hasPendingProjectUpdate(this)) { // If there is pending update for this project, // we dont know if this project would be needed by any of the open files impacted by this config file // In that case keep the project alive if there are open files impacted by this project - return !!configFileExistenceInfo.openFilesImpactedByConfigFile.size; + return !!((_a = configFileExistenceInfo.openFilesImpactedByConfigFile) === null || _a === void 0 ? void 0 : _a.size); } // If there is no pending update for this project, // We know exact set of open files that get impacted by this configured project as the files in the project // The project is referenced only if open files impacted by this project are present in this project - return ts.forEachEntry(configFileExistenceInfo.openFilesImpactedByConfigFile, function (_value, infoPath) { + return !!configFileExistenceInfo.openFilesImpactedByConfigFile && ts.forEachEntry(configFileExistenceInfo.openFilesImpactedByConfigFile, function (_value, infoPath) { var info = _this.projectService.getScriptInfoForPath(infoPath); return _this.containsScriptInfo(info) || !!server.forEachResolvedProjectReferenceProject(_this, info.path, function (child) { return child.containsScriptInfo(info); }, server.ProjectReferenceProjectLoadKind.Find); @@ -154728,7 +159948,7 @@ var ts; var defaultTypeSafeList = { "jquery": { // jquery files can have names like "jquery-1.10.2.min.js" (or "jquery.intellisense.js") - match: /jquery(-(\.?\d+)+)?(\.intellisense)?(\.min)?\.js$/i, + match: /jquery(-[\d\.]+)?(\.intellisense)?(\.min)?\.js$/i, types: ["jquery"] }, "WinJS": { @@ -154856,16 +160076,7 @@ var ts; } } } - var ConfigFileWatcherStatus; - (function (ConfigFileWatcherStatus) { - ConfigFileWatcherStatus["ReloadingFiles"] = "Reloading configured projects for files"; - ConfigFileWatcherStatus["ReloadingInferredRootFiles"] = "Reloading configured projects for only inferred root files"; - ConfigFileWatcherStatus["UpdatedCallback"] = "Updated the callback"; - ConfigFileWatcherStatus["OpenFilesImpactedByConfigFileAdd"] = "File added to open files impacted by this config file"; - ConfigFileWatcherStatus["OpenFilesImpactedByConfigFileRemove"] = "File removed from open files impacted by this config file"; - ConfigFileWatcherStatus["RootOfInferredProjectTrue"] = "Open file was set as Inferred root"; - ConfigFileWatcherStatus["RootOfInferredProjectFalse"] = "Open file was set as not inferred root"; - })(ConfigFileWatcherStatus || (ConfigFileWatcherStatus = {})); + var noopConfigFileWatcher = { close: ts.noop }; function isOpenScriptInfo(infoOrFileNameOrConfig) { return !!infoOrFileNameOrConfig.containingProjects; } @@ -154961,7 +160172,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 "Project: " + (project ? project.getProjectName() : "") + " WatchType: " + watchType; + return (ts.isString(project) ? "Config: " + project + " " : project ? "Project: " + project.getProjectName() + " " : "") + "WatchType: " + watchType; } function isScriptInfoWatchedFromNodeModules(info) { return !info.isScriptOpen() && info.mTime !== undefined; @@ -154984,6 +160195,10 @@ var ts; project.projectOptions = true; } } + function createProjectNameFactoryWithCounter(nameFactory) { + var nextId = 1; + return function () { return nameFactory(nextId++); }; + } var ProjectService = /** @class */ (function () { function ProjectService(opts) { var _this = this; @@ -155017,6 +160232,10 @@ var ts; * projects specified by a tsconfig.json file */ this.configuredProjects = new ts.Map(); + /*@internal*/ + this.newInferredProjectName = createProjectNameFactoryWithCounter(server.makeInferredProjectName); + /*@internal*/ + this.newAutoImportProviderProjectName = createProjectNameFactoryWithCounter(server.makeAutoImportProviderProjectName); /** * Open files: with value being project root path, and key being Path of the file that is open */ @@ -155041,7 +160260,7 @@ var ts; * - Or it is present if we have configured project open with config file at that location * In this case the exists property is always true */ - this.configFileExistenceInfoCache = new ts.Map(); + /*@internal*/ this.configFileExistenceInfoCache = new ts.Map(); this.safelist = defaultTypeSafeList; this.legacySafelist = new ts.Map(); this.pendingProjectUpdates = new ts.Map(); @@ -155051,6 +160270,8 @@ var ts; this.seenProjects = new ts.Map(); /*@internal*/ this.sharedExtendedConfigFileWatchers = new ts.Map(); + /*@internal*/ + this.extendedConfigCache = new ts.Map(); this.host = opts.host; this.logger = opts.logger; this.cancellationToken = opts.cancellationToken; @@ -155187,13 +160408,12 @@ var ts; case server.ActionSet: // Update the typing files and update the project project.updateTypingFiles(this.typingsCache.updateTypingsForProject(response.projectName, response.compilerOptions, response.typeAcquisition, response.unresolvedImports, response.typings)); - break; + return; case server.ActionInvalidate: // Do not clear resolution cache, there was changes detected in typings, so enque typing request and let it get us correct results this.typingsCache.enqueueInstallTypingsForProject(project, project.lastCachedUnresolvedImportsList, /*forceRefresh*/ true); return; } - this.delayUpdateProjectGraphAndEnsureProjectStructureForOpenFiles(project); }; /*@internal*/ ProjectService.prototype.delayEnsureProjectForOpenFiles = function () { @@ -155424,9 +160644,6 @@ var ts; return this.hostConfiguration.preferences; }; ProjectService.prototype.onSourceFileChanged = function (info, eventKind) { - if (info.containingProjects) { - info.containingProjects.forEach(function (project) { return project.resolutionCache.removeResolutionsFromProjectReferenceRedirects(info.path); }); - } if (eventKind === ts.FileWatcherEventKind.Deleted) { // File was deleted this.handleDeletedFile(info); @@ -155492,18 +160709,17 @@ var ts; * This is to watch whenever files are added or removed to the wildcard directories */ /*@internal*/ - ProjectService.prototype.watchWildcardDirectory = function (directory, flags, project) { + ProjectService.prototype.watchWildcardDirectory = function (directory, flags, configFileName, config) { var _this = this; - var watchOptions = this.getWatchOptions(project); return this.watchFactory.watchDirectory(directory, function (fileOrDirectory) { var fileOrDirectoryPath = _this.toPath(fileOrDirectory); - var fsResult = project.getCachedDirectoryStructureHost().addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); - var configFileName = project.getConfigFilePath(); + 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("Project: " + configFileName + " Detected new package.json: " + fileOrDirectory); + _this.logger.info("Config: " + configFileName + " Detected new package.json: " + fileOrDirectory); _this.onAddPackageJson(fileOrDirectoryPath); } + var configuredProjectForConfig = _this.findConfiguredProjectByProjectName(configFileName); if (ts.isIgnoredFileFromWildCardWatching({ watchedDirPath: directory, fileOrDirectory: fileOrDirectory, @@ -155511,109 +160727,111 @@ var ts; configFileName: configFileName, extraFileExtensions: _this.hostConfiguration.extraFileExtensions, currentDirectory: _this.currentDirectory, - options: project.getCompilationSettings(), - program: project.getCurrentProgram(), + options: config.parsedCommandLine.options, + program: (configuredProjectForConfig === null || configuredProjectForConfig === void 0 ? void 0 : configuredProjectForConfig.getCurrentProgram()) || config.parsedCommandLine.fileNames, useCaseSensitiveFileNames: _this.host.useCaseSensitiveFileNames, - writeLog: function (s) { return _this.logger.info(s); } + writeLog: function (s) { return _this.logger.info(s); }, + toPath: function (s) { return _this.toPath(s); } })) return; - // don't trigger callback on open, existing files - if (project.fileIsOpen(fileOrDirectoryPath)) { - if (project.pendingReload !== ts.ConfigFileProgramReloadLevel.Full) { + // Reload is pending, do the reload + if (config.reloadLevel !== ts.ConfigFileProgramReloadLevel.Full) + config.reloadLevel = ts.ConfigFileProgramReloadLevel.Partial; + config.projects.forEach(function (watchWildcardDirectories, projectCanonicalPath) { + if (!watchWildcardDirectories) + return; + var project = _this.getConfiguredProjectByCanonicalConfigFilePath(projectCanonicalPath); + if (!project) + return; + // Load root file names for configured project with the config file name + // But only schedule update if project references this config file + var reloadLevel = configuredProjectForConfig === project ? ts.ConfigFileProgramReloadLevel.Partial : ts.ConfigFileProgramReloadLevel.None; + if (project.pendingReload !== undefined && project.pendingReload > reloadLevel) + return; + // don't trigger callback on open, existing files + if (_this.openFiles.has(fileOrDirectoryPath)) { var info = ts.Debug.checkDefined(_this.getScriptInfoForPath(fileOrDirectoryPath)); if (info.isAttached(project)) { - project.openFileWatchTriggered.set(fileOrDirectoryPath, true); + var loadLevelToSet = Math.max(reloadLevel, project.openFileWatchTriggered.get(fileOrDirectoryPath) || ts.ConfigFileProgramReloadLevel.None); + project.openFileWatchTriggered.set(fileOrDirectoryPath, loadLevelToSet); } else { - project.pendingReload = ts.ConfigFileProgramReloadLevel.Partial; + project.pendingReload = reloadLevel; _this.delayUpdateProjectGraphAndEnsureProjectStructureForOpenFiles(project); } } + else { + project.pendingReload = reloadLevel; + _this.delayUpdateProjectGraphAndEnsureProjectStructureForOpenFiles(project); + } + }); + }, flags, this.getWatchOptionsFromProjectWatchOptions(config.parsedCommandLine.watchOptions), ts.WatchType.WildcardDirectory, configFileName); + }; + /*@internal*/ + ProjectService.prototype.delayUpdateProjectsFromParsedConfigOnConfigFileChange = function (canonicalConfigFilePath, reloadReason) { + var _this = this; + var configFileExistenceInfo = this.configFileExistenceInfoCache.get(canonicalConfigFilePath); + if (!(configFileExistenceInfo === null || configFileExistenceInfo === void 0 ? void 0 : configFileExistenceInfo.config)) + return false; + var scheduledAnyProjectUpdate = false; + // Update projects watching cached config + configFileExistenceInfo.config.reloadLevel = ts.ConfigFileProgramReloadLevel.Full; + configFileExistenceInfo.config.projects.forEach(function (_watchWildcardDirectories, projectCanonicalPath) { + var project = _this.getConfiguredProjectByCanonicalConfigFilePath(projectCanonicalPath); + if (!project) return; + scheduledAnyProjectUpdate = true; + if (projectCanonicalPath === canonicalConfigFilePath) { + // Skip refresh if project is not yet loaded + if (project.isInitialLoadPending()) + return; + project.pendingReload = ts.ConfigFileProgramReloadLevel.Full; + project.pendingReloadReason = reloadReason; + _this.delayUpdateProjectGraph(project); } - // Reload is pending, do the reload - if (project.pendingReload !== ts.ConfigFileProgramReloadLevel.Full) { - project.pendingReload = ts.ConfigFileProgramReloadLevel.Partial; - _this.delayUpdateProjectGraphAndEnsureProjectStructureForOpenFiles(project); + else { + // Change in referenced project config file + project.resolutionCache.removeResolutionsFromProjectReferenceRedirects(_this.toPath(canonicalConfigFilePath)); + _this.delayUpdateProjectGraph(project); } - }, flags, watchOptions, ts.WatchType.WildcardDirectory, project); - }; - /** Gets the config file existence info for the configured project */ - /*@internal*/ - ProjectService.prototype.getConfigFileExistenceInfo = function (project) { - return this.configFileExistenceInfoCache.get(project.canonicalConfigFilePath); + }); + return scheduledAnyProjectUpdate; }; /*@internal*/ - ProjectService.prototype.onConfigChangedForConfiguredProject = function (project, eventKind) { - var configFileExistenceInfo = this.getConfigFileExistenceInfo(project); + ProjectService.prototype.onConfigFileChanged = function (canonicalConfigFilePath, eventKind) { + var _a; + var configFileExistenceInfo = this.configFileExistenceInfoCache.get(canonicalConfigFilePath); if (eventKind === ts.FileWatcherEventKind.Deleted) { // Update the cached status // We arent updating or removing the cached config file presence info as that will be taken care of by - // setConfigFilePresenceByClosedConfigFile when the project is closed (depending on tracking open files) + // releaseParsedConfig when the project is closed or doesnt need this config any more (depending on tracking open files) configFileExistenceInfo.exists = false; - this.removeProject(project); - // Reload the configured projects for the open files in the map as they are affected by this config file - // Since the configured project was deleted, we want to reload projects for all the open files including files - // that are not root of the inferred project - this.logConfigFileWatchUpdate(project.getConfigFilePath(), project.canonicalConfigFilePath, configFileExistenceInfo, "Reloading configured projects for files" /* ReloadingFiles */); - this.delayReloadConfiguredProjectForFiles(configFileExistenceInfo, /*ignoreIfNotInferredProjectRoot*/ false); + // Remove the configured project for this config file + var project = ((_a = configFileExistenceInfo.config) === null || _a === void 0 ? void 0 : _a.projects.has(canonicalConfigFilePath)) ? + this.getConfiguredProjectByCanonicalConfigFilePath(canonicalConfigFilePath) : + undefined; + if (project) + this.removeProject(project); } else { - this.logConfigFileWatchUpdate(project.getConfigFilePath(), project.canonicalConfigFilePath, configFileExistenceInfo, "Reloading configured projects for only inferred root files" /* ReloadingInferredRootFiles */); - // Skip refresh if project is not yet loaded - if (project.isInitialLoadPending()) - return; - project.pendingReload = ts.ConfigFileProgramReloadLevel.Full; - project.pendingReloadReason = "Change in config file detected"; - this.delayUpdateProjectGraph(project); - // As we scheduled the update on configured project graph, - // we would need to schedule the project reload for only the root of inferred projects - this.delayReloadConfiguredProjectForFiles(configFileExistenceInfo, /*ignoreIfNotInferredProjectRoot*/ true); + // Update the cached status + configFileExistenceInfo.exists = true; } - }; - /*@internal*/ - ProjectService.prototype.updateSharedExtendedConfigFileMap = function (_a, parsedCommandLine) { - var _this = this; - var canonicalConfigFilePath = _a.canonicalConfigFilePath; - ts.updateSharedExtendedConfigFileWatcher(canonicalConfigFilePath, parsedCommandLine, this.sharedExtendedConfigFileWatchers, function (extendedConfigFileName, extendedConfigFilePath) { return _this.watchFactory.watchFile(extendedConfigFileName, function () { - var _a; - var ensureProjectsForOpenFiles = false; - (_a = _this.sharedExtendedConfigFileWatchers.get(extendedConfigFilePath)) === null || _a === void 0 ? void 0 : _a.projects.forEach(function (canonicalPath) { - var project = _this.configuredProjects.get(canonicalPath); - // Skip refresh if project is not yet loaded - if (!project || project.isInitialLoadPending()) - return; - project.pendingReload = ts.ConfigFileProgramReloadLevel.Full; - project.pendingReloadReason = "Change in extended config file " + extendedConfigFileName + " detected"; - _this.delayUpdateProjectGraph(project); - ensureProjectsForOpenFiles = true; - }); - if (ensureProjectsForOpenFiles) - _this.delayEnsureProjectForOpenFiles(); - }, ts.PollingInterval.High, _this.hostConfiguration.watchOptions, ts.WatchType.ExtendedConfigFile); }, function (fileName) { return _this.toPath(fileName); }); - }; - /*@internal*/ - ProjectService.prototype.removeProjectFromSharedExtendedConfigFileMap = function (project) { - this.sharedExtendedConfigFileWatchers.forEach(function (watcher) { - watcher.projects.delete(project.canonicalConfigFilePath); - watcher.close(); - }); - }; - /** - * This is the callback function for the config file add/remove/change at any location - * that matters to open script info but doesnt have configured project open - * for the config file - */ - ProjectService.prototype.onConfigFileChangeForOpenScriptInfo = function (configFileName, eventKind) { - // This callback is called only if we dont have config file project for this config file - var canonicalConfigPath = server.normalizedPathToPath(configFileName, this.currentDirectory, this.toCanonicalFileName); - var configFileExistenceInfo = this.configFileExistenceInfoCache.get(canonicalConfigPath); - configFileExistenceInfo.exists = (eventKind !== ts.FileWatcherEventKind.Deleted); - this.logConfigFileWatchUpdate(configFileName, canonicalConfigPath, configFileExistenceInfo, "Reloading configured projects for files" /* ReloadingFiles */); - // Because there is no configured project open for the config file, the tracking open files map - // will only have open files that need the re-detection of the project and hence - // reload projects for all the tracking open files in the map - this.delayReloadConfiguredProjectForFiles(configFileExistenceInfo, /*ignoreIfNotInferredProjectRoot*/ false); + // Update projects watching config + this.delayUpdateProjectsFromParsedConfigOnConfigFileChange(canonicalConfigFilePath, "Change in config file detected"); + // Reload the configured projects for the open files in the map as they are affected by this config file + // If the configured project was deleted, we want to reload projects for all the open files including files + // that are not root of the inferred project + // Otherwise, we scheduled the update on configured project graph, + // we would need to schedule the project reload for only the root of inferred projects + // Get open files to reload projects for + this.reloadConfiguredProjectForFiles(configFileExistenceInfo.openFilesImpactedByConfigFile, + /*clearSemanticCache*/ false, + /*delayReload*/ true, eventKind !== ts.FileWatcherEventKind.Deleted ? + ts.identity : // Reload open files if they are root of inferred project + ts.returnTrue, // Reload all the open files impacted by config file + "Change in config file detected"); + this.delayEnsureProjectForOpenFiles(); }; ProjectService.prototype.removeProject = function (project) { var _this = this; @@ -155639,7 +160857,6 @@ var ts; case server.ProjectKind.Configured: this.configuredProjects.delete(project.canonicalConfigFilePath); this.projectToSizeMap.delete(project.canonicalConfigFilePath); - this.setConfigFileExistenceInfoByClosedConfiguredProject(project); break; case server.ProjectKind.Inferred: ts.unorderedRemoveItem(this.inferredProjects, project); @@ -155666,7 +160883,7 @@ var ts; } project.updateGraph(); if (!this.useSingleInferredProject && !project.projectRootPath) { - var _loop_3 = function (inferredProject) { + var _loop_2 = function (inferredProject) { if (inferredProject === project || inferredProject.isOrphan()) { return "continue"; } @@ -155687,7 +160904,7 @@ var ts; // Note that we need to create a copy of the array since the list of project can change for (var _i = 0, _a = this.inferredProjects; _i < _a.length; _i++) { var inferredProject = _a[_i]; - _loop_3(inferredProject); + _loop_2(inferredProject); } } return project; @@ -155730,10 +160947,11 @@ var ts; // if it would need to be re-created with next file open // If project had open file affecting // Reload the root Files from config if its not already scheduled - if (p.openFileWatchTriggered.has(info.path)) { + var reloadLevel = p.openFileWatchTriggered.get(info.path); + if (reloadLevel !== undefined) { p.openFileWatchTriggered.delete(info.path); - if (!p.pendingReload) { - p.pendingReload = ts.ConfigFileProgramReloadLevel.Partial; + if (p.pendingReload !== undefined && p.pendingReload < reloadLevel) { + p.pendingReload = reloadLevel; p.markFileAsDirty(info.path); } } @@ -155781,13 +160999,13 @@ var ts; } }; ProjectService.prototype.configFileExists = function (configFileName, canonicalConfigFilePath, info) { + var _a; var configFileExistenceInfo = this.configFileExistenceInfoCache.get(canonicalConfigFilePath); if (configFileExistenceInfo) { // By default the info would get impacted by presence of config file since its in the detection path // Only adding the info as a root to inferred project will need the existence to be watched by file watcher - if (isOpenScriptInfo(info) && !configFileExistenceInfo.openFilesImpactedByConfigFile.has(info.path)) { - configFileExistenceInfo.openFilesImpactedByConfigFile.set(info.path, false); - this.logConfigFileWatchUpdate(configFileName, canonicalConfigFilePath, configFileExistenceInfo, "File added to open files impacted by this config file" /* OpenFilesImpactedByConfigFileAdd */); + if (isOpenScriptInfo(info) && !((_a = configFileExistenceInfo.openFilesImpactedByConfigFile) === null || _a === void 0 ? void 0 : _a.has(info.path))) { + (configFileExistenceInfo.openFilesImpactedByConfigFile || (configFileExistenceInfo.openFilesImpactedByConfigFile = new ts.Map())).set(info.path, false); } return configFileExistenceInfo.exists; } @@ -155800,104 +161018,82 @@ var ts; // Or the whole chain of config files for the roots of the inferred projects // Cache the host value of file exists and add the info to map of open files impacted by this config file var exists = this.host.fileExists(configFileName); - var openFilesImpactedByConfigFile = new ts.Map(); + var openFilesImpactedByConfigFile; if (isOpenScriptInfo(info)) { - openFilesImpactedByConfigFile.set(info.path, false); + (openFilesImpactedByConfigFile || (openFilesImpactedByConfigFile = new ts.Map())).set(info.path, false); } configFileExistenceInfo = { exists: exists, openFilesImpactedByConfigFile: openFilesImpactedByConfigFile }; this.configFileExistenceInfoCache.set(canonicalConfigFilePath, configFileExistenceInfo); - this.logConfigFileWatchUpdate(configFileName, canonicalConfigFilePath, configFileExistenceInfo, "File added to open files impacted by this config file" /* OpenFilesImpactedByConfigFileAdd */); return exists; }; - ProjectService.prototype.setConfigFileExistenceByNewConfiguredProject = function (project) { - var configFileExistenceInfo = this.getConfigFileExistenceInfo(project); - if (configFileExistenceInfo) { - // The existence might not be set if the file watcher is not invoked by the time config project is created by external project - configFileExistenceInfo.exists = true; - // close existing watcher - if (configFileExistenceInfo.configFileWatcherForRootOfInferredProject) { - var configFileName = project.getConfigFilePath(); - configFileExistenceInfo.configFileWatcherForRootOfInferredProject.close(); - configFileExistenceInfo.configFileWatcherForRootOfInferredProject = undefined; - this.logConfigFileWatchUpdate(configFileName, project.canonicalConfigFilePath, configFileExistenceInfo, "Updated the callback" /* UpdatedCallback */); - } - } - else { - // We could be in this scenario if project is the configured project tracked by external project - // Since that route doesnt check if the config file is present or not - this.configFileExistenceInfoCache.set(project.canonicalConfigFilePath, { - exists: true, - openFilesImpactedByConfigFile: new ts.Map() - }); + /*@internal*/ + ProjectService.prototype.createConfigFileWatcherForParsedConfig = function (configFileName, canonicalConfigFilePath, forProject) { + var _this = this; + var _a, _b; + var configFileExistenceInfo = this.configFileExistenceInfoCache.get(canonicalConfigFilePath); + // When watching config file for parsed config, remove the noopFileWatcher that can be created for open files impacted by config file and watch for real + if (!configFileExistenceInfo.watcher || configFileExistenceInfo.watcher === noopConfigFileWatcher) { + configFileExistenceInfo.watcher = this.watchFactory.watchFile(configFileName, function (_fileName, eventKind) { return _this.onConfigFileChanged(canonicalConfigFilePath, eventKind); }, ts.PollingInterval.High, this.getWatchOptionsFromProjectWatchOptions((_b = (_a = configFileExistenceInfo === null || configFileExistenceInfo === void 0 ? void 0 : configFileExistenceInfo.config) === null || _a === void 0 ? void 0 : _a.parsedCommandLine) === null || _b === void 0 ? void 0 : _b.watchOptions), ts.WatchType.ConfigFile, forProject); } + // Watching config file for project, update the map + var projects = configFileExistenceInfo.config.projects; + projects.set(forProject.canonicalConfigFilePath, projects.get(forProject.canonicalConfigFilePath) || false); }; /** * Returns true if the configFileExistenceInfo is needed/impacted by open files that are root of inferred project */ ProjectService.prototype.configFileExistenceImpactsRootOfInferredProject = function (configFileExistenceInfo) { - return ts.forEachEntry(configFileExistenceInfo.openFilesImpactedByConfigFile, function (isRootOfInferredProject) { return isRootOfInferredProject; }); + return configFileExistenceInfo.openFilesImpactedByConfigFile && + ts.forEachEntry(configFileExistenceInfo.openFilesImpactedByConfigFile, ts.identity); }; - ProjectService.prototype.setConfigFileExistenceInfoByClosedConfiguredProject = function (closedProject) { - var configFileExistenceInfo = this.getConfigFileExistenceInfo(closedProject); - ts.Debug.assert(!!configFileExistenceInfo); - if (configFileExistenceInfo.openFilesImpactedByConfigFile.size) { - var configFileName = closedProject.getConfigFilePath(); + /* @internal */ + ProjectService.prototype.releaseParsedConfig = function (canonicalConfigFilePath, forProject) { + var _a, _b, _c; + var configFileExistenceInfo = this.configFileExistenceInfoCache.get(canonicalConfigFilePath); + if (!((_a = configFileExistenceInfo.config) === null || _a === void 0 ? void 0 : _a.projects.delete(forProject.canonicalConfigFilePath))) + return; + // If there are still projects watching this config file existence and config, there is nothing to do + if ((_b = configFileExistenceInfo.config) === null || _b === void 0 ? void 0 : _b.projects.size) + return; + configFileExistenceInfo.config = undefined; + ts.clearSharedExtendedConfigFileWatcher(canonicalConfigFilePath, this.sharedExtendedConfigFileWatchers); + ts.Debug.checkDefined(configFileExistenceInfo.watcher); + if ((_c = configFileExistenceInfo.openFilesImpactedByConfigFile) === null || _c === void 0 ? void 0 : _c.size) { // If there are open files that are impacted by this config file existence // but none of them are root of inferred project, the config file watcher will be // created when any of the script infos are added as root of inferred project if (this.configFileExistenceImpactsRootOfInferredProject(configFileExistenceInfo)) { - ts.Debug.assert(!configFileExistenceInfo.configFileWatcherForRootOfInferredProject); - this.createConfigFileWatcherOfConfigFileExistence(configFileName, closedProject.canonicalConfigFilePath, configFileExistenceInfo); + // If we cannot watch config file existence without configured project, close the configured file watcher + if (!ts.canWatchDirectory(ts.getDirectoryPath(canonicalConfigFilePath))) { + configFileExistenceInfo.watcher.close(); + configFileExistenceInfo.watcher = noopConfigFileWatcher; + } + } + else { + // Close existing watcher + configFileExistenceInfo.watcher.close(); + configFileExistenceInfo.watcher = undefined; } } else { // There is not a single file open thats tracking the status of this config file. Remove from cache - this.configFileExistenceInfoCache.delete(closedProject.canonicalConfigFilePath); + configFileExistenceInfo.watcher.close(); + this.configFileExistenceInfoCache.delete(canonicalConfigFilePath); } }; - ProjectService.prototype.logConfigFileWatchUpdate = function (configFileName, canonicalConfigFilePath, configFileExistenceInfo, status) { - var _this = this; - if (!this.logger.hasLevel(server.LogLevel.verbose)) { - return; - } - var inferredRoots = []; - var otherFiles = []; - configFileExistenceInfo.openFilesImpactedByConfigFile.forEach(function (isRootOfInferredProject, key) { - var info = _this.getScriptInfoForPath(key); - (isRootOfInferredProject ? inferredRoots : otherFiles).push(info.fileName); - }); - var watches = []; - if (configFileExistenceInfo.configFileWatcherForRootOfInferredProject) { - watches.push(configFileExistenceInfo.configFileWatcherForRootOfInferredProject === ts.noopFileWatcher ? - ts.WatchType.NoopConfigFileForInferredRoot : - ts.WatchType.ConfigFileForInferredRoot); - } - if (this.configuredProjects.has(canonicalConfigFilePath)) { - watches.push(ts.WatchType.ConfigFile); - } - this.logger.info("ConfigFilePresence:: Current Watches: " + watches + ":: File: " + configFileName + " Currently impacted open files: RootsOfInferredProjects: " + inferredRoots + " OtherOpenFiles: " + otherFiles + " Status: " + status); - }; - /** - * Create the watcher for the configFileExistenceInfo - */ - ProjectService.prototype.createConfigFileWatcherOfConfigFileExistence = function (configFileName, canonicalConfigFilePath, configFileExistenceInfo) { - var _this = this; - configFileExistenceInfo.configFileWatcherForRootOfInferredProject = - ts.canWatchDirectory(ts.getDirectoryPath(canonicalConfigFilePath)) ? - this.watchFactory.watchFile(configFileName, function (_filename, eventKind) { return _this.onConfigFileChangeForOpenScriptInfo(configFileName, eventKind); }, ts.PollingInterval.High, this.hostConfiguration.watchOptions, ts.WatchType.ConfigFileForInferredRoot) : - ts.noopFileWatcher; - this.logConfigFileWatchUpdate(configFileName, canonicalConfigFilePath, configFileExistenceInfo, "Updated the callback" /* UpdatedCallback */); - }; /** * Close the config file watcher in the cached ConfigFileExistenceInfo - * if there arent any open files that are root of inferred project + * if there arent any open files that are root of inferred project and there is no parsed config held by any project */ - ProjectService.prototype.closeConfigFileWatcherOfConfigFileExistenceInfo = function (configFileExistenceInfo) { + /*@internal*/ + ProjectService.prototype.closeConfigFileWatcherOnReleaseOfOpenFile = function (configFileExistenceInfo) { // Close the config file watcher if there are no more open files that are root of inferred project - if (configFileExistenceInfo.configFileWatcherForRootOfInferredProject && + // or if there are no projects that need to watch this config file existence info + if (configFileExistenceInfo.watcher && + !configFileExistenceInfo.config && !this.configFileExistenceImpactsRootOfInferredProject(configFileExistenceInfo)) { - configFileExistenceInfo.configFileWatcherForRootOfInferredProject.close(); - configFileExistenceInfo.configFileWatcherForRootOfInferredProject = undefined; + configFileExistenceInfo.watcher.close(); + configFileExistenceInfo.watcher = undefined; } }; /** @@ -155906,25 +161102,26 @@ var ts; ProjectService.prototype.stopWatchingConfigFilesForClosedScriptInfo = function (info) { var _this = this; ts.Debug.assert(!info.isScriptOpen()); - this.forEachConfigFileLocation(info, function (configFileName, canonicalConfigFilePath) { + this.forEachConfigFileLocation(info, function (canonicalConfigFilePath) { + var _a, _b, _c; var configFileExistenceInfo = _this.configFileExistenceInfoCache.get(canonicalConfigFilePath); if (configFileExistenceInfo) { - var infoIsRootOfInferredProject = configFileExistenceInfo.openFilesImpactedByConfigFile.get(info.path); + var infoIsRootOfInferredProject = (_a = configFileExistenceInfo.openFilesImpactedByConfigFile) === null || _a === void 0 ? void 0 : _a.get(info.path); // Delete the info from map, since this file is no more open - configFileExistenceInfo.openFilesImpactedByConfigFile.delete(info.path); - _this.logConfigFileWatchUpdate(configFileName, canonicalConfigFilePath, configFileExistenceInfo, "File removed from open files impacted by this config file" /* OpenFilesImpactedByConfigFileRemove */); + (_b = configFileExistenceInfo.openFilesImpactedByConfigFile) === null || _b === void 0 ? void 0 : _b.delete(info.path); // If the script info was not root of inferred project, // there wont be config file watch open because of this script info if (infoIsRootOfInferredProject) { // But if it is a root, it could be the last script info that is root of inferred project // and hence we would need to close the config file watcher - _this.closeConfigFileWatcherOfConfigFileExistenceInfo(configFileExistenceInfo); + _this.closeConfigFileWatcherOnReleaseOfOpenFile(configFileExistenceInfo); } // If there are no open files that are impacted by configFileExistenceInfo after closing this script info - // there is no configured project present, remove the cached existence info - if (!configFileExistenceInfo.openFilesImpactedByConfigFile.size && - !_this.getConfiguredProjectByCanonicalConfigFilePath(canonicalConfigFilePath)) { - ts.Debug.assert(!configFileExistenceInfo.configFileWatcherForRootOfInferredProject); + // and there is are no projects that need the config file existence or parsed config, + // remove the cached existence info + if (!((_c = configFileExistenceInfo.openFilesImpactedByConfigFile) === null || _c === void 0 ? void 0 : _c.size) && + !configFileExistenceInfo.config) { + ts.Debug.assert(!configFileExistenceInfo.watcher); _this.configFileExistenceInfoCache.delete(canonicalConfigFilePath); } } @@ -155937,24 +161134,19 @@ var ts; ProjectService.prototype.startWatchingConfigFilesForInferredProjectRoot = function (info) { var _this = this; ts.Debug.assert(info.isScriptOpen()); - this.forEachConfigFileLocation(info, function (configFileName, canonicalConfigFilePath) { + this.forEachConfigFileLocation(info, function (canonicalConfigFilePath, configFileName) { var configFileExistenceInfo = _this.configFileExistenceInfoCache.get(canonicalConfigFilePath); if (!configFileExistenceInfo) { // Create the cache - configFileExistenceInfo = { - exists: _this.host.fileExists(configFileName), - openFilesImpactedByConfigFile: new ts.Map() - }; + configFileExistenceInfo = { exists: _this.host.fileExists(configFileName) }; _this.configFileExistenceInfoCache.set(canonicalConfigFilePath, configFileExistenceInfo); } // Set this file as the root of inferred project - configFileExistenceInfo.openFilesImpactedByConfigFile.set(info.path, true); - _this.logConfigFileWatchUpdate(configFileName, canonicalConfigFilePath, configFileExistenceInfo, "Open file was set as Inferred root" /* RootOfInferredProjectTrue */); + (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 - if (!configFileExistenceInfo.configFileWatcherForRootOfInferredProject && - !_this.getConfiguredProjectByCanonicalConfigFilePath(canonicalConfigFilePath)) { - _this.createConfigFileWatcherOfConfigFileExistence(configFileName, canonicalConfigFilePath, configFileExistenceInfo); - } + configFileExistenceInfo.watcher || (configFileExistenceInfo.watcher = ts.canWatchDirectory(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); }); }; /** @@ -155963,15 +161155,15 @@ var ts; /* @internal */ ProjectService.prototype.stopWatchingConfigFilesForInferredProjectRoot = function (info) { var _this = this; - this.forEachConfigFileLocation(info, function (configFileName, canonicalConfigFilePath) { + this.forEachConfigFileLocation(info, function (canonicalConfigFilePath) { + var _a; var configFileExistenceInfo = _this.configFileExistenceInfoCache.get(canonicalConfigFilePath); - if (configFileExistenceInfo && configFileExistenceInfo.openFilesImpactedByConfigFile.has(info.path)) { + if ((_a = configFileExistenceInfo === null || configFileExistenceInfo === void 0 ? void 0 : configFileExistenceInfo.openFilesImpactedByConfigFile) === null || _a === void 0 ? void 0 : _a.has(info.path)) { ts.Debug.assert(info.isScriptOpen()); // Info is not root of inferred project any more configFileExistenceInfo.openFilesImpactedByConfigFile.set(info.path, false); - _this.logConfigFileWatchUpdate(configFileName, canonicalConfigFilePath, configFileExistenceInfo, "Open file was set as not inferred root" /* RootOfInferredProjectFalse */); // Close the config file watcher - _this.closeConfigFileWatcherOfConfigFileExistenceInfo(configFileExistenceInfo); + _this.closeConfigFileWatcherOnReleaseOfOpenFile(configFileExistenceInfo); } }); }; @@ -156003,11 +161195,11 @@ var ts; if (searchInDirectory) { var canonicalSearchPath = server.normalizedPathToPath(searchPath, this.currentDirectory, this.toCanonicalFileName); var tsconfigFileName = server.asNormalizedPath(ts.combinePaths(searchPath, "tsconfig.json")); - var result = action(tsconfigFileName, ts.combinePaths(canonicalSearchPath, "tsconfig.json")); + var result = action(ts.combinePaths(canonicalSearchPath, "tsconfig.json"), tsconfigFileName); if (result) return tsconfigFileName; var jsconfigFileName = server.asNormalizedPath(ts.combinePaths(searchPath, "jsconfig.json")); - result = action(jsconfigFileName, ts.combinePaths(canonicalSearchPath, "jsconfig.json")); + result = action(ts.combinePaths(canonicalSearchPath, "jsconfig.json"), jsconfigFileName); if (result) return jsconfigFileName; // If we started within node_modules, don't look outside node_modules. @@ -156055,7 +161247,7 @@ var ts; return result || undefined; } this.logger.info("Search path: " + ts.getDirectoryPath(info.fileName)); - var configFileName = this.forEachConfigFileLocation(info, function (configFileName, canonicalConfigFilePath) { + var configFileName = this.forEachConfigFileLocation(info, function (canonicalConfigFilePath, configFileName) { return _this.configFileExists(configFileName, canonicalConfigFilePath, info); }); if (configFileName) { @@ -156100,6 +161292,7 @@ var ts; }; /** Get a filename if the language service exceeds the maximum allowed program size; otherwise returns undefined. */ ProjectService.prototype.getFilenameForExceededTotalSizeLimitForNonTsFiles = function (name, options, fileNames, propertyReader) { + var _this = this; if (options && options.disableSizeLimit || !this.host.getFileSize) { return; } @@ -156115,25 +161308,17 @@ var ts; } totalNonTsFileSize += this.host.getFileSize(fileName); if (totalNonTsFileSize > server.maxProgramSizeForNonTsFiles || totalNonTsFileSize > availableSpace) { - this.logger.info(getExceedLimitMessage({ propertyReader: propertyReader, hasTSFileExtension: ts.hasTSFileExtension, host: this.host }, totalNonTsFileSize)); // eslint-disable-line @typescript-eslint/no-unnecessary-qualifier + var top5LargestFiles = fileNames.map(function (f) { return propertyReader.getFileName(f); }) + .filter(function (name) { return !ts.hasTSFileExtension(name); }) + .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(", ")); // Keep the size as zero since it's disabled return fileName; } } this.projectToSizeMap.set(name, totalNonTsFileSize); - return; - function getExceedLimitMessage(context, totalNonTsFileSize) { - var files = getTop5LargestFiles(context); - return "Non TS file size exceeded limit (" + totalNonTsFileSize + "). Largest files: " + files.map(function (file) { return file.name + ":" + file.size; }).join(", "); - } - function getTop5LargestFiles(_a) { - var propertyReader = _a.propertyReader, hasTSFileExtension = _a.hasTSFileExtension, host = _a.host; - return fileNames.map(function (f) { return propertyReader.getFileName(f); }) - .filter(function (name) { return hasTSFileExtension(name); }) - .map(function (name) { return ({ name: name, size: host.getFileSize(name) }); }) // TODO: GH#18217 - .sort(function (a, b) { return b.size - a.size; }) - .slice(0, 5); - } }; ProjectService.prototype.createExternalProject = function (projectFileName, files, options, typeAcquisition, excludedFiles) { var compilerOptions = convertCompilerOptions(options); @@ -156197,12 +161382,27 @@ var ts; }; /* @internal */ ProjectService.prototype.createConfiguredProject = function (configFileName) { - var cachedDirectoryStructureHost = ts.createCachedDirectoryStructureHost(this.host, this.host.getCurrentDirectory(), this.host.useCaseSensitiveFileNames); // TODO: GH#18217 - this.logger.info("Opened configuration file " + configFileName); - var project = new server.ConfiguredProject(configFileName, this, this.documentRegistry, cachedDirectoryStructureHost); - project.createConfigFileWatcher(); - this.configuredProjects.set(project.canonicalConfigFilePath, project); - this.setConfigFileExistenceByNewConfiguredProject(project); + this.logger.info("Creating configuration project " + 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 + // Since that route doesnt check if the config file is present or not + if (!configFileExistenceInfo) { + this.configFileExistenceInfoCache.set(canonicalConfigFilePath, configFileExistenceInfo = { exists: true }); + } + else { + configFileExistenceInfo.exists = true; + } + if (!configFileExistenceInfo.config) { + configFileExistenceInfo.config = { + cachedDirectoryStructureHost: ts.createCachedDirectoryStructureHost(this.host, this.host.getCurrentDirectory(), this.host.useCaseSensitiveFileNames), + projects: new ts.Map(), + reloadLevel: ts.ConfigFileProgramReloadLevel.Full + }; + } + var project = new server.ConfiguredProject(configFileName, canonicalConfigFilePath, this, this.documentRegistry, configFileExistenceInfo.config.cachedDirectoryStructureHost); + this.configuredProjects.set(canonicalConfigFilePath, project); + this.createConfigFileWatcherForParsedConfig(configFileName, canonicalConfigFilePath, project); return project; }; /* @internal */ @@ -156232,24 +161432,9 @@ var ts; var _this = this; this.sendProjectLoadingStartEvent(project, reason); // Read updated contents from disk - var configFilename = ts.normalizePath(project.getConfigFilePath()); - var configFileContent = ts.tryReadFile(configFilename, function (fileName) { return _this.host.readFile(fileName); }); - var result = ts.parseJsonText(configFilename, ts.isString(configFileContent) ? configFileContent : ""); - var configFileErrors = result.parseDiagnostics; - if (!ts.isString(configFileContent)) - configFileErrors.push(configFileContent); - var parsedCommandLine = ts.parseJsonSourceFileConfigFileContent(result, project.getCachedDirectoryStructureHost(), ts.getDirectoryPath(configFilename), - /*existingOptions*/ {}, configFilename, - /*resolutionStack*/ [], this.hostConfiguration.extraFileExtensions, - /*extendedConfigCache*/ undefined); - if (parsedCommandLine.errors.length) { - configFileErrors.push.apply(configFileErrors, parsedCommandLine.errors); - } - this.logger.info("Config: " + configFilename + " : " + JSON.stringify({ - rootNames: parsedCommandLine.fileNames, - options: parsedCommandLine.options, - projectReferences: parsedCommandLine.projectReferences - }, /*replacer*/ undefined, " ")); + var configFilename = server.asNormalizedPath(ts.normalizePath(project.getConfigFilePath())); + var configFileExistenceInfo = this.ensureParsedConfigUptoDate(configFilename, project.canonicalConfigFilePath, this.configFileExistenceInfoCache.get(project.canonicalConfigFilePath), project); + var parsedCommandLine = configFileExistenceInfo.config.parsedCommandLine; ts.Debug.assert(!!parsedCommandLine.fileNames); var compilerOptions = parsedCommandLine.options; // Update the project @@ -156262,25 +161447,131 @@ var ts; }; } project.canConfigFileJsonReportNoInputFiles = ts.canJsonReportNoInputFiles(parsedCommandLine.raw); - project.setProjectErrors(configFileErrors); + project.setProjectErrors(parsedCommandLine.options.configFile.parseDiagnostics); project.updateReferences(parsedCommandLine.projectReferences); var lastFileExceededProgramSize = this.getFilenameForExceededTotalSizeLimitForNonTsFiles(project.canonicalConfigFilePath, compilerOptions, parsedCommandLine.fileNames, fileNamePropertyReader); if (lastFileExceededProgramSize) { project.disableLanguageService(lastFileExceededProgramSize); - project.stopWatchingWildCards(); - this.removeProjectFromSharedExtendedConfigFileMap(project); + this.configFileExistenceInfoCache.forEach(function (_configFileExistenceInfo, canonicalConfigFilePath) { + return _this.stopWatchingWildCards(canonicalConfigFilePath, project); + }); } else { project.setCompilerOptions(compilerOptions); project.setWatchOptions(parsedCommandLine.watchOptions); project.enableLanguageService(); - project.watchWildcards(new ts.Map(ts.getEntries(parsedCommandLine.wildcardDirectories))); // TODO: GH#18217 - this.updateSharedExtendedConfigFileMap(project, parsedCommandLine); + this.watchWildcards(configFilename, configFileExistenceInfo, project); } project.enablePluginsWithOptions(compilerOptions, this.currentPluginConfigOverrides); var filesToAdd = parsedCommandLine.fileNames.concat(project.getExternalFiles()); this.updateRootAndOptionsOfNonInferredProject(project, filesToAdd, fileNamePropertyReader, compilerOptions, parsedCommandLine.typeAcquisition, parsedCommandLine.compileOnSave, parsedCommandLine.watchOptions); }; + /*@internal*/ + ProjectService.prototype.ensureParsedConfigUptoDate = function (configFilename, canonicalConfigFilePath, configFileExistenceInfo, forProject) { + var _this = this; + var _a, _b, _c; + if (configFileExistenceInfo.config) { + if (!configFileExistenceInfo.config.reloadLevel) + return configFileExistenceInfo; + if (configFileExistenceInfo.config.reloadLevel === ts.ConfigFileProgramReloadLevel.Partial) { + this.reloadFileNamesOfParsedConfig(configFilename, configFileExistenceInfo.config); + return configFileExistenceInfo; + } + } + // Parse the config file and ensure its cached + var cachedDirectoryStructureHost = ((_a = configFileExistenceInfo.config) === null || _a === void 0 ? void 0 : _a.cachedDirectoryStructureHost) || + ts.createCachedDirectoryStructureHost(this.host, this.host.getCurrentDirectory(), this.host.useCaseSensitiveFileNames); + // Read updated contents from disk + var configFileContent = ts.tryReadFile(configFilename, function (fileName) { return _this.host.readFile(fileName); }); + var configFile = ts.parseJsonText(configFilename, ts.isString(configFileContent) ? configFileContent : ""); + var configFileErrors = configFile.parseDiagnostics; + if (!ts.isString(configFileContent)) + configFileErrors.push(configFileContent); + var parsedCommandLine = ts.parseJsonSourceFileConfigFileContent(configFile, cachedDirectoryStructureHost, ts.getDirectoryPath(configFilename), + /*existingOptions*/ {}, configFilename, + /*resolutionStack*/ [], this.hostConfiguration.extraFileExtensions, this.extendedConfigCache); + if (parsedCommandLine.errors.length) { + configFileErrors.push.apply(configFileErrors, parsedCommandLine.errors); + } + this.logger.info("Config: " + configFilename + " : " + JSON.stringify({ + rootNames: parsedCommandLine.fileNames, + options: parsedCommandLine.options, + watchOptions: parsedCommandLine.watchOptions, + projectReferences: parsedCommandLine.projectReferences + }, /*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() }; + } + else { + configFileExistenceInfo.config.parsedCommandLine = parsedCommandLine; + configFileExistenceInfo.config.watchedDirectoriesStale = true; + configFileExistenceInfo.config.reloadLevel = undefined; + } + // If watch options different than older options when setting for the first time, update the config file watcher + if (!oldCommandLine && !ts.isJsonEqual( + // Old options + this.getWatchOptionsFromProjectWatchOptions(/*projectOptions*/ undefined), + // New options + this.getWatchOptionsFromProjectWatchOptions(parsedCommandLine.watchOptions))) { + // Reset the config file watcher + (_c = configFileExistenceInfo.watcher) === null || _c === void 0 ? void 0 : _c.close(); + configFileExistenceInfo.watcher = undefined; + } + // Ensure there is watcher for this config file + this.createConfigFileWatcherForParsedConfig(configFilename, canonicalConfigFilePath, forProject); + // Watch extended config files + ts.updateSharedExtendedConfigFileWatcher(canonicalConfigFilePath, parsedCommandLine.options, this.sharedExtendedConfigFileWatchers, function (extendedConfigFileName, extendedConfigFilePath) { return _this.watchFactory.watchFile(extendedConfigFileName, function () { + var _a; + // Update extended config cache + ts.cleanExtendedConfigCache(_this.extendedConfigCache, extendedConfigFilePath, function (fileName) { return _this.toPath(fileName); }); + // 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; + }); + if (ensureProjectsForOpenFiles) + _this.delayEnsureProjectForOpenFiles(); + }, ts.PollingInterval.High, _this.hostConfiguration.watchOptions, ts.WatchType.ExtendedConfigFile, configFilename); }, function (fileName) { return _this.toPath(fileName); }); + return configFileExistenceInfo; + }; + /*@internal*/ + ProjectService.prototype.watchWildcards = function (configFileName, _a, forProject) { + var _this = this; + var _b; + var exists = _a.exists, config = _a.config; + config.projects.set(forProject.canonicalConfigFilePath, true); + if (exists) { + if (config.watchedDirectories && !config.watchedDirectoriesStale) + return; + config.watchedDirectoriesStale = false; + ts.updateWatchingWildcardDirectories((_b = config).watchedDirectories || (_b.watchedDirectories = new ts.Map()), new ts.Map(ts.getEntries(config.parsedCommandLine.wildcardDirectories)), + // Create new directory watcher + function (directory, flags) { return _this.watchWildcardDirectory(directory, flags, configFileName, config); }); + } + else { + config.watchedDirectoriesStale = false; + if (!config.watchedDirectories) + return; + ts.clearMap(config.watchedDirectories, ts.closeFileWatcherOf); + config.watchedDirectories = undefined; + } + }; + /*@internal*/ + ProjectService.prototype.stopWatchingWildCards = function (canonicalConfigFilePath, forProject) { + var configFileExistenceInfo = this.configFileExistenceInfoCache.get(canonicalConfigFilePath); + if (!configFileExistenceInfo.config || + !configFileExistenceInfo.config.projects.get(forProject.canonicalConfigFilePath)) { + return; + } + configFileExistenceInfo.config.projects.set(forProject.canonicalConfigFilePath, false); + // If any of the project is still watching wild cards dont close the watcher + if (ts.forEachEntry(configFileExistenceInfo.config.projects, ts.identity)) + return; + ts.clearMap(configFileExistenceInfo.config.watchedDirectories, ts.closeFileWatcherOf); + configFileExistenceInfo.config.watchedDirectories = undefined; + configFileExistenceInfo.config.watchedDirectoriesStale = undefined; + }; ProjectService.prototype.updateNonInferredProjectFiles = function (project, files, propertyReader) { var projectRootFilesMap = project.getRootFilesMap(); var newRootScriptInfoMap = new ts.Map(); @@ -156360,14 +161651,22 @@ var ts; */ /*@internal*/ ProjectService.prototype.reloadFileNamesOfConfiguredProject = function (project) { - var configFileSpecs = project.getCompilerOptions().configFile.configFileSpecs; - var configFileName = project.getConfigFilePath(); - var fileNames = ts.getFileNamesFromConfigSpecs(configFileSpecs, ts.getDirectoryPath(configFileName), project.getCompilationSettings(), project.getCachedDirectoryStructureHost(), this.hostConfiguration.extraFileExtensions); + var fileNames = this.reloadFileNamesOfParsedConfig(project.getConfigFilePath(), this.configFileExistenceInfoCache.get(project.canonicalConfigFilePath).config); project.updateErrorOnNoInputFiles(fileNames); this.updateNonInferredProjectFiles(project, fileNames.concat(project.getExternalFiles()), fileNamePropertyReader); return project.updateGraph(); }; /*@internal*/ + ProjectService.prototype.reloadFileNamesOfParsedConfig = function (configFileName, config) { + if (config.reloadLevel === undefined) + return config.parsedCommandLine.fileNames; + ts.Debug.assert(config.reloadLevel === ts.ConfigFileProgramReloadLevel.Partial); + var configFileSpecs = config.parsedCommandLine.options.configFile.configFileSpecs; + var fileNames = ts.getFileNamesFromConfigSpecs(configFileSpecs, ts.getDirectoryPath(configFileName), config.parsedCommandLine.options, config.cachedDirectoryStructureHost, this.hostConfiguration.extraFileExtensions); + config.parsedCommandLine = __assign(__assign({}, config.parsedCommandLine), { fileNames: fileNames }); + return fileNames; + }; + /*@internal*/ ProjectService.prototype.setFileNamesOfAutoImportProviderProject = function (project, fileNames) { this.updateNonInferredProjectFiles(project, fileNames, fileNamePropertyReader); }; @@ -156541,7 +161840,7 @@ var ts; return projects; function combineProjects(toAddInfo) { if (toAddInfo !== info) { - var _loop_4 = function (project) { + var _loop_3 = function (project) { // Add the projects only if they can use symLink targets and not already in the list if (project.languageServiceEnabled && !project.isOrphan() && @@ -156558,7 +161857,7 @@ var ts; }; for (var _i = 0, _a = toAddInfo.containingProjects; _i < _a.length; _i++) { var project = _a[_i]; - _loop_4(project); + _loop_3(project); } } } @@ -156766,7 +162065,7 @@ var ts; var snap = mapInfo.getSnapshot(); if (mapInfo.documentPositionMapper !== undefined) return mapInfo.documentPositionMapper; - return snap.getText(0, snap.getLength()); + return ts.getSnapshotText(snap); }; var projectName = project.projectName; var documentPositionMapper = ts.getDocumentPositionMapper({ getCanonicalFileName: this.toCanonicalFileName, log: function (s) { return _this.logger.info(s); }, getSourceFileLike: function (f) { return _this.getSourceFileLike(f, projectName, declarationInfo); } }, declarationInfo.fileName, declarationInfo.getLineInfo(), readMapFile); @@ -156887,7 +162186,7 @@ var ts; }); } if (includePackageJsonAutoImports !== args.preferences.includePackageJsonAutoImports) { - this.invalidateProjectAutoImports(/*packageJsonPath*/ undefined); + this.invalidateProjectPackageJson(/*packageJsonPath*/ undefined); } } if (args.extraFileExtensions) { @@ -156905,7 +162204,10 @@ var ts; }; /*@internal*/ ProjectService.prototype.getWatchOptions = function (project) { - var projectOptions = project.getWatchOptions(); + return this.getWatchOptionsFromProjectWatchOptions(project.getWatchOptions()); + }; + /*@internal*/ + ProjectService.prototype.getWatchOptionsFromProjectWatchOptions = function (projectOptions) { return projectOptions && this.hostConfiguration.watchOptions ? __assign(__assign({}, this.hostConfiguration.watchOptions), projectOptions) : projectOptions || this.hostConfiguration.watchOptions; }; @@ -156939,6 +162241,11 @@ var ts; }); this.throttledOperations.cancel(ensureProjectForOpenFileSchedule); this.pendingEnsureProjectForOpenFiles = false; + // Ensure everything is reloaded for cached configs + this.configFileExistenceInfoCache.forEach(function (info) { + if (info.config) + info.config.reloadLevel = ts.ConfigFileProgramReloadLevel.Full; + }); // Reload Projects this.reloadConfiguredProjectForFiles(this.openFiles, /*clearSemanticCache*/ true, /*delayReload*/ false, ts.returnTrue, "User requested reload projects"); this.externalProjects.forEach(function (project) { @@ -156948,21 +162255,11 @@ var ts; this.inferredProjects.forEach(function (project) { return _this.clearSemanticCache(project); }); this.ensureProjectForOpenFiles(); }; - ProjectService.prototype.delayReloadConfiguredProjectForFiles = function (configFileExistenceInfo, ignoreIfNotRootOfInferredProject) { - // Get open files to reload projects for - this.reloadConfiguredProjectForFiles(configFileExistenceInfo.openFilesImpactedByConfigFile, - /*clearSemanticCache*/ false, - /*delayReload*/ true, ignoreIfNotRootOfInferredProject ? - function (isRootOfInferredProject) { return isRootOfInferredProject; } : // Reload open files if they are root of inferred project - ts.returnTrue, // Reload all the open files impacted by config file - "Change in config file detected"); - this.delayEnsureProjectForOpenFiles(); - }; /** * This function goes through all the openFiles and tries to file the config file for them. * If the config file is found and it refers to existing project, it reloads it either immediately * or schedules it for reload depending on delayReload option - * If the there is no existing project it just opens the configured project for the config file + * If there is no existing project it just opens the configured project for the config file * reloadForInfo provides a way to filter out files to reload configured project for */ ProjectService.prototype.reloadConfiguredProjectForFiles = function (openFiles, clearSemanticCache, delayReload, shouldReloadProjectFor, reason) { @@ -156975,7 +162272,7 @@ var ts; } }; // try to reload config file for all open files - openFiles.forEach(function (openFileValue, path) { + openFiles === null || openFiles === void 0 ? void 0 : openFiles.forEach(function (openFileValue, path) { // Invalidate default config file name for open file _this.configFileForOpenFiles.delete(path); // Filter out the files that need to be ignored @@ -157447,13 +162744,13 @@ var ts; return result; }; ProjectService.prototype.collectChanges = function (lastKnownProjectVersions, currentProjects, includeProjectReferenceRedirectInfo, result) { - var _loop_5 = function (proj) { + var _loop_4 = function (proj) { var knownProject = ts.find(lastKnownProjectVersions, function (p) { return p.projectName === proj.getProjectName(); }); result.push(proj.getChangesSinceVersion(knownProject && knownProject.version, includeProjectReferenceRedirectInfo)); }; for (var _i = 0, currentProjects_1 = currentProjects; _i < currentProjects_1.length; _i++) { var proj = currentProjects_1[_i]; - _loop_5(proj); + _loop_4(proj); } }; /* @internal */ @@ -157593,7 +162890,7 @@ var ts; var excludeRules = []; var normalizedNames = rootFiles.map(function (f) { return ts.normalizeSlashes(f.fileName); }); var excludedFiles = []; - var _loop_6 = function (name) { + var _loop_5 = function (name) { var rule = this_2.safelist[name]; for (var _b = 0, normalizedNames_1 = normalizedNames; _b < normalizedNames_1.length; _b++) { var root = normalizedNames_1[_b]; @@ -157611,7 +162908,7 @@ var ts; } } if (rule.exclude) { - var _loop_8 = function (exclude) { + var _loop_7 = function (exclude) { var processedRule = root.replace(rule.match, function () { var groups = []; for (var _i = 0; _i < arguments.length; _i++) { @@ -157638,7 +162935,7 @@ var ts; }; for (var _e = 0, _f = rule.exclude; _e < _f.length; _e++) { var exclude = _f[_e]; - _loop_8(exclude); + _loop_7(exclude); } } else { @@ -157654,11 +162951,11 @@ var ts; var this_2 = this; for (var _i = 0, _a = Object.keys(this.safelist); _i < _a.length; _i++) { var name = _a[_i]; - _loop_6(name); + _loop_5(name); } var excludeRegexes = excludeRules.map(function (e) { return new RegExp(e, "i"); }); var filesToKeep = []; - var _loop_7 = function (i) { + var _loop_6 = function (i) { if (excludeRegexes.some(function (re) { return re.test(normalizedNames[i]); })) { excludedFiles.push(normalizedNames[i]); } @@ -157696,7 +162993,7 @@ var ts; }; var this_3 = this; for (var i = 0; i < proj.rootFiles.length; i++) { - _loop_7(i); + _loop_6(i); } proj.rootFiles = filesToKeep; return excludedFiles; @@ -157883,7 +163180,7 @@ var ts; var _this = this; var watchers = this.packageJsonFilesMap || (this.packageJsonFilesMap = new ts.Map()); if (!watchers.has(path)) { - this.invalidateProjectAutoImports(path); + this.invalidateProjectPackageJson(path); watchers.set(path, this.watchFactory.watchFile(path, function (fileName, eventKind) { var path = _this.toPath(fileName); switch (eventKind) { @@ -157891,11 +163188,11 @@ var ts; return ts.Debug.fail(); case ts.FileWatcherEventKind.Changed: _this.packageJsonCache.addOrUpdate(path); - _this.invalidateProjectAutoImports(path); + _this.invalidateProjectPackageJson(path); break; case ts.FileWatcherEventKind.Deleted: _this.packageJsonCache.delete(path); - _this.invalidateProjectAutoImports(path); + _this.invalidateProjectPackageJson(path); watchers.get(path).close(); watchers.delete(path); } @@ -157916,16 +163213,16 @@ var ts; } }; /*@internal*/ - ProjectService.prototype.invalidateProjectAutoImports = function (packageJsonPath) { - if (this.includePackageJsonAutoImports()) { - this.configuredProjects.forEach(invalidate); - this.inferredProjects.forEach(invalidate); - this.externalProjects.forEach(invalidate); - } + ProjectService.prototype.invalidateProjectPackageJson = function (packageJsonPath) { + this.configuredProjects.forEach(invalidate); + this.inferredProjects.forEach(invalidate); + this.externalProjects.forEach(invalidate); function invalidate(project) { - var _a; - if (!packageJsonPath || ((_a = project.packageJsonsForAutoImport) === null || _a === void 0 ? void 0 : _a.has(packageJsonPath))) { - project.markAutoImportProviderAsDirty(); + if (packageJsonPath) { + project.onPackageJsonChange(packageJsonPath); + } + else { + project.onAutoImportProviderSettingsChanged(); } } }; @@ -158144,24 +163441,24 @@ var ts; try { if (this.operationHost.isCancellationRequested()) { stop = true; - ts.tracing.instant("session" /* Session */, "stepCanceled", { seq: this.requestId, early: true }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "stepCanceled", { seq: this.requestId, early: true }); } else { - ts.tracing.push("session" /* Session */, "stepAction", { seq: this.requestId }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "stepAction", { seq: this.requestId }); action(this); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } } catch (e) { // Cancellation or an error may have left incomplete events on the tracing stack. - ts.tracing.popAll(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.popAll(); stop = true; // ignore cancellation request if (e instanceof ts.OperationCanceledException) { - ts.tracing.instant("session" /* Session */, "stepCanceled", { seq: this.requestId }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "stepCanceled", { seq: this.requestId }); } else { - ts.tracing.instant("session" /* Session */, "stepError", { seq: this.requestId, message: e.message }); + 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); } } @@ -158263,7 +163560,7 @@ var ts; function combineProjectOutputForReferences(projects, defaultProject, initialLocation) { var outputs = []; combineProjectOutputWorker(projects, defaultProject, initialLocation, function (project, location, getMappedLocation) { - var _loop_9 = function (outputReferencedSymbol) { + var _loop_8 = function (outputReferencedSymbol) { var mappedDefinitionFile = getMappedLocation(project, documentSpanLocation(outputReferencedSymbol.definition)); var definition = mappedDefinitionFile === undefined ? outputReferencedSymbol.definition : __assign(__assign({}, outputReferencedSymbol.definition), { textSpan: ts.createTextSpan(mappedDefinitionFile.pos, outputReferencedSymbol.definition.textSpan.length), fileName: mappedDefinitionFile.fileName, contextSpan: getMappedContextSpan(outputReferencedSymbol.definition, project) }); @@ -158282,7 +163579,7 @@ var ts; }; for (var _i = 0, _a = project.getLanguageService().findReferences(location.fileName, location.pos) || server.emptyArray; _i < _a.length; _i++) { var outputReferencedSymbol = _a[_i]; - _loop_9(outputReferencedSymbol); + _loop_8(outputReferencedSymbol); } }); return outputs.filter(function (o) { return o.references.length !== 0; }); @@ -158695,10 +163992,10 @@ var ts; return _this.requiredResponse(_this.getCompletions(request.arguments, server.CommandNames.CompletionsFull)); }, _a[server.CommandNames.CompletionDetails] = function (request) { - return _this.requiredResponse(_this.getCompletionEntryDetails(request.arguments, /*simplifiedResult*/ true)); + return _this.requiredResponse(_this.getCompletionEntryDetails(request.arguments, /*fullResult*/ false)); }, _a[server.CommandNames.CompletionDetailsFull] = function (request) { - return _this.requiredResponse(_this.getCompletionEntryDetails(request.arguments, /*simplifiedResult*/ false)); + return _this.requiredResponse(_this.getCompletionEntryDetails(request.arguments, /*fullResult*/ true)); }, _a[server.CommandNames.CompileOnSaveAffectedFileList] = function (request) { return _this.requiredResponse(_this.getCompileOnSaveAffectedFileList(request.arguments)); @@ -159091,7 +164388,7 @@ var ts; this.host.write(msgText); }; Session.prototype.event = function (body, eventName) { - ts.tracing.instant("session" /* Session */, "event", { eventName: eventName }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "event", { eventName: eventName }); this.send(toEvent(eventName, body)); }; // For backwards-compatibility only. @@ -159242,7 +164539,8 @@ var ts; }; Session.prototype.getEncodedSemanticClassifications = function (args) { var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - return project.getLanguageService().getEncodedSemanticClassifications(file, args); + var format = args.format === "2020" ? "2020" /* TwentyTwenty */ : "original" /* Original */; + return project.getLanguageService().getEncodedSemanticClassifications(file, args, format); }; Session.prototype.getProject = function (projectFileName) { return projectFileName === undefined ? undefined : this.projectService.findProject(projectFileName); @@ -159323,7 +164621,7 @@ var ts; Session.prototype.mapDefinitionInfoLocations = function (definitions, project) { return definitions.map(function (info) { var newDocumentSpan = getMappedDocumentSpan(info, project); - return !newDocumentSpan ? info : __assign(__assign({}, newDocumentSpan), { containerKind: info.containerKind, containerName: info.containerName, kind: info.kind, name: info.name }); + return !newDocumentSpan ? info : __assign(__assign(__assign({}, newDocumentSpan), { containerKind: info.containerKind, containerName: info.containerName, kind: info.kind, name: info.name }), info.unverified && { unverified: info.unverified }); }); }; Session.prototype.getDefinitionAndBoundSpan = function (args, simplifiedResult) { @@ -159361,9 +164659,27 @@ var ts; result.diagnostics.map(function (d) { return formatDiagnosticToProtocol(d, /*includeFileName*/ true); }) }) : result; }; + Session.prototype.mapJSDocTagInfo = function (tags, project, richResponse) { + var _this = this; + return tags ? tags.map(function (tag) { + var _a; + return (__assign(__assign({}, tag), { text: richResponse ? _this.mapDisplayParts(tag.text, project) : (_a = tag.text) === null || _a === void 0 ? void 0 : _a.map(function (part) { return part.text; }).join("") })); + }) : []; + }; + Session.prototype.mapDisplayParts = function (parts, project) { + var _this = this; + if (!parts) { + return []; + } + return parts.map(function (part) { return part.kind !== "linkName" ? part : __assign(__assign({}, part), { target: _this.toFileSpan(part.target.fileName, part.target.textSpan, project) }); }); + }; + Session.prototype.mapSignatureHelpItems = function (items, project, richResponse) { + var _this = this; + return items.map(function (item) { return (__assign(__assign({}, item), { documentation: _this.mapDisplayParts(item.documentation, project), parameters: item.parameters.map(function (p) { return (__assign(__assign({}, p), { documentation: _this.mapDisplayParts(p.documentation, project) })); }), tags: _this.mapJSDocTagInfo(item.tags, project, richResponse) })); }); + }; Session.prototype.mapDefinitionInfo = function (definitions, project) { var _this = this; - return definitions.map(function (def) { return _this.toFileSpanWithContext(def.fileName, def.textSpan, def.contextSpan, project); }); + return definitions.map(function (def) { return (__assign(__assign({}, _this.toFileSpanWithContext(def.fileName, def.textSpan, def.contextSpan, project)), def.unverified && { unverified: def.unverified })); }); }; /* * When we map a .d.ts location to .ts, Visual Studio gets confused because there's no associated Roslyn Document in @@ -159670,7 +164986,7 @@ var ts; Session.prototype.getDocCommentTemplate = function (args) { var _a = this.getFileAndLanguageServiceForSyntacticOperation(args), file = _a.file, languageService = _a.languageService; var position = this.getPositionInFile(args, file); - return languageService.getDocCommentTemplateAtPosition(file, position); + return languageService.getDocCommentTemplateAtPosition(file, position, this.getPreferences(file)); }; Session.prototype.getSpanOfEnclosingComment = function (args) { var _a = this.getFileAndLanguageServiceForSyntacticOperation(args), file = _a.file, languageService = _a.languageService; @@ -159707,21 +165023,21 @@ var ts; if (!quickInfo) { return undefined; } + var useDisplayParts = !!this.getPreferences(file).displayPartsForJSDoc; if (simplifiedResult) { var displayString = ts.displayPartsToString(quickInfo.displayParts); - var docString = ts.displayPartsToString(quickInfo.documentation); return { kind: quickInfo.kind, kindModifiers: quickInfo.kindModifiers, start: scriptInfo.positionToLineOffset(quickInfo.textSpan.start), end: scriptInfo.positionToLineOffset(ts.textSpanEnd(quickInfo.textSpan)), displayString: displayString, - documentation: docString, - tags: quickInfo.tags || [] + documentation: useDisplayParts ? this.mapDisplayParts(quickInfo.documentation, project) : ts.displayPartsToString(quickInfo.documentation), + tags: this.mapJSDocTagInfo(quickInfo.tags, project, useDisplayParts), }; } else { - return quickInfo; + return useDisplayParts ? quickInfo : __assign(__assign({}, quickInfo), { tags: this.mapJSDocTagInfo(quickInfo.tags, project, /*useDisplayParts*/ false) }); } }; Session.prototype.getFormattingEditsForRange = function (args) { @@ -159812,14 +165128,14 @@ var ts; if (kind === "completions-full" /* CompletionsFull */) return completions; var prefix = args.prefix || ""; - var entries = ts.mapDefined(completions.entries, function (entry) { + var entries = ts.stableSort(ts.mapDefined(completions.entries, function (entry) { if (completions.isMemberCompletion || ts.startsWith(entry.name.toLowerCase(), prefix.toLowerCase())) { - var name = entry.name, kind_1 = entry.kind, kindModifiers = entry.kindModifiers, sortText = entry.sortText, insertText = entry.insertText, replacementSpan = entry.replacementSpan, hasAction = entry.hasAction, source = entry.source, isRecommended = entry.isRecommended, isPackageJsonImport = entry.isPackageJsonImport; + var name = entry.name, kind_1 = entry.kind, kindModifiers = entry.kindModifiers, sortText = entry.sortText, insertText = entry.insertText, replacementSpan = entry.replacementSpan, hasAction = entry.hasAction, source = entry.source, sourceDisplay = entry.sourceDisplay, isSnippet = entry.isSnippet, isRecommended = entry.isRecommended, isPackageJsonImport = entry.isPackageJsonImport, isImportStatementCompletion = entry.isImportStatementCompletion, data = entry.data; var convertedSpan = replacementSpan ? toProtocolTextSpan(replacementSpan, scriptInfo) : undefined; // Use `hasAction || undefined` to avoid serializing `false`. - return { name: name, kind: kind_1, kindModifiers: kindModifiers, sortText: sortText, insertText: insertText, replacementSpan: convertedSpan, hasAction: hasAction || undefined, source: source, isRecommended: isRecommended, isPackageJsonImport: isPackageJsonImport }; + return { name: name, kind: kind_1, kindModifiers: kindModifiers, sortText: sortText, insertText: insertText, replacementSpan: convertedSpan, isSnippet: isSnippet, hasAction: hasAction || undefined, source: source, sourceDisplay: sourceDisplay, isRecommended: isRecommended, isPackageJsonImport: isPackageJsonImport, isImportStatementCompletion: isImportStatementCompletion, data: data }; } - }).sort(function (a, b) { return ts.compareStringsCaseSensitiveUI(a.name, b.name); }); + }), function (a, b) { return ts.compareStringsCaseSensitiveUI(a.name, b.name); }); if (kind === "completions" /* Completions */) { if (completions.metadata) entries.metadata = completions.metadata; @@ -159828,19 +165144,20 @@ var ts; var res = __assign(__assign({}, completions), { optionalReplacementSpan: completions.optionalReplacementSpan && toProtocolTextSpan(completions.optionalReplacementSpan, scriptInfo), entries: entries }); return res; }; - Session.prototype.getCompletionEntryDetails = function (args, simplifiedResult) { + Session.prototype.getCompletionEntryDetails = function (args, fullResult) { var _this = this; var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; var scriptInfo = this.projectService.getScriptInfoForNormalizedPath(file); var position = this.getPosition(args, scriptInfo); var formattingOptions = project.projectService.getFormatCodeOptions(file); + var useDisplayParts = !!this.getPreferences(file).displayPartsForJSDoc; var result = ts.mapDefined(args.entryNames, function (entryName) { - var _a = typeof entryName === "string" ? { name: entryName, source: undefined } : entryName, name = _a.name, source = _a.source; - return project.getLanguageService().getCompletionEntryDetails(file, position, name, formattingOptions, source, _this.getPreferences(file)); + var _a = typeof entryName === "string" ? { name: entryName, source: undefined, data: undefined } : entryName, name = _a.name, source = _a.source, data = _a.data; + return project.getLanguageService().getCompletionEntryDetails(file, position, name, formattingOptions, source, _this.getPreferences(file), data ? ts.cast(data, isCompletionEntryData) : undefined); }); - return simplifiedResult - ? result.map(function (details) { return (__assign(__assign({}, details), { codeActions: ts.map(details.codeActions, function (action) { return _this.mapCodeAction(action); }) })); }) - : result; + return fullResult + ? (useDisplayParts ? result : result.map(function (details) { return (__assign(__assign({}, details), { tags: _this.mapJSDocTagInfo(details.tags, project, /*richResponse*/ false) })); })) + : result.map(function (details) { return (__assign(__assign({}, details), { codeActions: ts.map(details.codeActions, function (action) { return _this.mapCodeAction(action); }), documentation: _this.mapDisplayParts(details.documentation, project), tags: _this.mapJSDocTagInfo(details.tags, project, useDisplayParts) })); }); }; Session.prototype.getCompileOnSaveAffectedFileList = function (args) { var _this = this; @@ -159886,29 +165203,25 @@ var ts; !emitSkipped; }; Session.prototype.getSignatureHelpItems = function (args, simplifiedResult) { + var _this = this; var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; var scriptInfo = this.projectService.getScriptInfoForNormalizedPath(file); var position = this.getPosition(args, scriptInfo); var helpItems = project.getLanguageService().getSignatureHelpItems(file, position, args); - if (!helpItems) { - return undefined; - } - if (simplifiedResult) { + var useDisplayParts = !!this.getPreferences(file).displayPartsForJSDoc; + if (helpItems && simplifiedResult) { var span = helpItems.applicableSpan; - return { - items: helpItems.items, - applicableSpan: { + return __assign(__assign({}, helpItems), { applicableSpan: { start: scriptInfo.positionToLineOffset(span.start), end: scriptInfo.positionToLineOffset(span.start + span.length) - }, - selectedItemIndex: helpItems.selectedItemIndex, - argumentIndex: helpItems.argumentIndex, - argumentCount: helpItems.argumentCount, - }; + }, items: this.mapSignatureHelpItems(helpItems.items, project, useDisplayParts) }); } - else { + else if (useDisplayParts || !helpItems) { return helpItems; } + else { + return __assign(__assign({}, helpItems), { items: helpItems.items.map(function (item) { return (__assign(__assign({}, item), { tags: _this.mapJSDocTagInfo(item.tags, project, /*richResponse*/ false) })); }) }); + } }; Session.prototype.toPendingErrorCheck = function (uncheckedFileName) { var fileName = server.toNormalizedPath(uncheckedFileName); @@ -160114,11 +165427,14 @@ var ts; return result; } }; - Session.prototype.organizeImports = function (_a, simplifiedResult) { - var scope = _a.scope; - ts.Debug.assert(scope.type === "file"); - var _b = this.getFileAndProject(scope.args), file = _b.file, project = _b.project; - var changes = project.getLanguageService().organizeImports({ type: "file", fileName: file }, this.getFormatOptions(file), this.getPreferences(file)); + Session.prototype.organizeImports = function (args, simplifiedResult) { + ts.Debug.assert(args.scope.type === "file"); + var _a = this.getFileAndProject(args.scope.args), file = _a.file, project = _a.project; + var changes = project.getLanguageService().organizeImports({ + fileName: file, + skipDestructiveCodeActions: args.skipDestructiveCodeActions, + type: "file", + }, this.getFormatOptions(file), this.getPreferences(file)); if (simplifiedResult) { return this.mapTextChangesToCodeEdits(changes); } @@ -160140,7 +165456,22 @@ var ts; var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; var scriptInfo = project.getScriptInfoForNormalizedPath(file); var _b = this.getStartAndEndPosition(args, scriptInfo), startPosition = _b.startPosition, endPosition = _b.endPosition; - var codeActions = project.getLanguageService().getCodeFixesAtPosition(file, startPosition, endPosition, args.errorCodes, this.getFormatOptions(file), this.getPreferences(file)); + var codeActions; + try { + codeActions = project.getLanguageService().getCodeFixesAtPosition(file, startPosition, endPosition, args.errorCodes, this.getFormatOptions(file), this.getPreferences(file)); + } + catch (e) { + var ls = project.getLanguageService(); + var existingDiagCodes_1 = __spreadArray(__spreadArray(__spreadArray([], ls.getSyntacticDiagnostics(file)), ls.getSemanticDiagnostics(file)), ls.getSuggestionDiagnostics(file)).map(function (d) { + return ts.decodedTextSpanIntersectsWith(startPosition, endPosition - startPosition, d.start, d.length) + && d.code; + }); + 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; + } + throw e; + } return simplifiedResult ? codeActions.map(function (codeAction) { return _this.mapCodeFixAction(codeAction); }) : codeActions; }; Session.prototype.getCombinedCodeFix = function (_a, simplifiedResult) { @@ -160463,11 +165794,11 @@ var ts; try { request = this.parseMessage(message); relevantFile = request.arguments && request.arguments.file ? request.arguments : undefined; - 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" /* Session */, "request", { seq: request.seq, command: request.command }); ts.perfLogger.logStartCommand("" + request.command, this.toStringMessage(message).substring(0, 100)); - 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" /* Session */, "executeCommand", { seq: request.seq, command: request.command }, /*separateBeginAndEnd*/ true); var _a = this.executeCommand(request), response = _a.response, responseRequired = _a.responseRequired; - ts.tracing.pop(); + 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) { @@ -160479,7 +165810,7 @@ var ts; } // 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.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" /* Session */, "response", { seq: request.seq, command: request.command, success: !!response }); if (response) { this.doOutput(response, request.command, request.seq, /*success*/ true); } @@ -160489,17 +165820,17 @@ var ts; } catch (err) { // Cancellation or an error may have left incomplete events on the tracing stack. - ts.tracing.popAll(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.popAll(); if (err instanceof ts.OperationCanceledException) { // Handle cancellation exceptions ts.perfLogger.logStopCommand("" + (request && request.command), "Canceled: " + err); - 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" /* 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.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" /* 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); @@ -160583,6 +165914,13 @@ var ts; isWriteAccess: isWriteAccess, isDefinition: isDefinition }); } + function isCompletionEntryData(data) { + return data === undefined || data && typeof data === "object" + && typeof data.exportName === "string" + && (data.fileName === undefined || typeof data.fileName === "string") + && (data.ambientModuleName === undefined || typeof data.ambientModuleName === "string" + && (data.isPackageJsonImport === undefined || typeof data.isPackageJsonImport === "boolean")); + } })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); /*@internal*/ @@ -162224,7 +167562,7 @@ var ts; } else { type = operatorOrType; - operator = 138 /* KeyOfKeyword */; + operator = 139 /* KeyOfKeyword */; } return ts.factory.createTypeOperatorNode(operator, type); }, factoryDeprecation); @@ -162352,7 +167690,7 @@ var ts; }, factoryDeprecation); /** @deprecated Use `factory.createJSDocParameterTag` or the factory supplied by your transformation context instead. */ ts.createJSDocParamTag = ts.Debug.deprecate(function createJSDocParamTag(name, isBracketed, typeExpression, comment) { - return ts.factory.createJSDocParameterTag(/*tagName*/ undefined, name, isBracketed, typeExpression, /*isNameFirst*/ false, comment); + return ts.factory.createJSDocParameterTag(/*tagName*/ undefined, name, isBracketed, typeExpression, /*isNameFirst*/ false, comment ? ts.factory.createNodeArray([ts.factory.createJSDocText(comment)]) : undefined); }, factoryDeprecation); /** @deprecated Use `factory.createComma` or the factory supplied by your transformation context instead. */ ts.createComma = ts.Debug.deprecate(function createComma(left, right) { @@ -162402,9 +167740,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 === 297 /* SourceFile */ ? ts.parseBaseNodeFactory.createBaseSourceFileNode(kind) : - kind === 78 /* Identifier */ ? ts.parseBaseNodeFactory.createBaseIdentifierNode(kind) : - kind === 79 /* PrivateIdentifier */ ? ts.parseBaseNodeFactory.createBasePrivateIdentifierNode(kind) : + return ts.setTextRangePosEnd(kind === 299 /* SourceFile */ ? ts.parseBaseNodeFactory.createBaseSourceFileNode(kind) : + kind === 79 /* Identifier */ ? ts.parseBaseNodeFactory.createBaseIdentifierNode(kind) : + kind === 80 /* 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." }); @@ -162431,13 +167769,30 @@ var ts; // #region Renamed node Tests /** @deprecated Use `isTypeAssertionExpression` instead. */ ts.isTypeAssertion = ts.Debug.deprecate(function isTypeAssertion(node) { - return node.kind === 206 /* TypeAssertionExpression */; + return node.kind === 208 /* TypeAssertionExpression */; }, { since: "4.0", warnAfter: "4.1", message: "Use `isTypeAssertionExpression` instead." }); // #endregion + // DEPRECATION: Renamed node tests + // DEPRECATION PLAN: + // - soft: 4.2 + // - warn: 4.3 + // - error: TBD + // #region Renamed node Tests + /** + * @deprecated Use `isMemberName` instead. + */ + ts.isIdentifierOrPrivateIdentifier = ts.Debug.deprecate(function isIdentifierOrPrivateIdentifier(node) { + return ts.isMemberName(node); + }, { + since: "4.2", + warnAfter: "4.3", + message: "Use `isMemberName` instead." + }); + // #endregion Renamed node Tests })(ts || (ts = {})); /*@internal*/ var ts; @@ -162557,20 +167912,6 @@ var ts; var useWatchGuard = process.platform === "win32" && nodeVersion >= 4; var originalWatchDirectory = sys.watchDirectory.bind(sys); var logger = createLogger(); - // REVIEW: for now this implementation uses polling. - // The advantage of polling is that it works reliably - // on all os and with network mounted files. - // For 90 referenced files, the average time to detect - // changes is 2*msInterval (by default 5 seconds). - // The overhead of this is .04 percent (1/2500) with - // average pause of < 1 millisecond (and max - // pause less than 1.5 milliseconds); question is - // do we anticipate reference sets in the 100s and - // do we care about waiting 10-20 seconds to detect - // changes for large reference sets? If so, do we want - // to increase the chunk size or decrease the interval - // time dynamically to match the large reference set? - var pollingWatchedFileSet = createPollingWatchedFileSet(); var pending = []; var canWrite = true; if (useWatchGuard) { @@ -162622,12 +167963,20 @@ var ts; } // Override sys.write because fs.writeSync is not reliable on Node 4 sys.write = function (s) { return writeMessage(sys.bufferFrom(s, "utf8")); }; - sys.watchFile = function (fileName, callback) { - var watchedFile = pollingWatchedFileSet.addFile(fileName, callback); - return { - close: function () { return pollingWatchedFileSet.removeFile(watchedFile); } - }; - }; + // REVIEW: for now this implementation uses polling. + // The advantage of polling is that it works reliably + // on all os and with network mounted files. + // For 90 referenced files, the average time to detect + // changes is 2*msInterval (by default 5 seconds). + // The overhead of this is .04 percent (1/2500) with + // average pause of < 1 millisecond (and max + // pause less than 1.5 milliseconds); question is + // do we anticipate reference sets in the 100s and + // do we care about waiting 10-20 seconds to detect + // changes for large reference sets? If so, do we want + // to increase the chunk size or decrease the interval + // time dynamically to match the large reference set? + sys.defaultWatchFileKind = function () { return ts.WatchFileKind.FixedChunkSizePolling; }; /* eslint-disable no-restricted-globals */ sys.setTimeout = setTimeout; sys.clearTimeout = clearTimeout; @@ -162690,83 +168039,6 @@ var ts; var logVerbosity = cmdLineVerbosity || envLogOptions.detailLevel; return new Logger(substitutedLogFileName, envLogOptions.traceToConsole, logVerbosity); // TODO: GH#18217 } - // This places log file in the directory containing editorServices.js - // TODO: check that this location is writable - // average async stat takes about 30 microseconds - // set chunk size to do 30 files in < 1 millisecond - function createPollingWatchedFileSet(interval, chunkSize) { - if (interval === void 0) { interval = 2500; } - if (chunkSize === void 0) { chunkSize = 30; } - var watchedFiles = []; - var nextFileToCheck = 0; - return { getModifiedTime: getModifiedTime, poll: poll, startWatchTimer: startWatchTimer, addFile: addFile, removeFile: removeFile }; - function getModifiedTime(fileName) { - // Caller guarantees that `fileName` exists, so there'd be no benefit from throwIfNoEntry - return fs.statSync(fileName).mtime; - } - function poll(checkedIndex) { - var watchedFile = watchedFiles[checkedIndex]; - if (!watchedFile) { - return; - } - fs.stat(watchedFile.fileName, function (err, stats) { - if (err) { - if (err.code === "ENOENT") { - if (watchedFile.mtime.getTime() !== 0) { - watchedFile.mtime = ts.missingFileModifiedTime; - watchedFile.callback(watchedFile.fileName, ts.FileWatcherEventKind.Deleted); - } - } - else { - watchedFile.callback(watchedFile.fileName, ts.FileWatcherEventKind.Changed); - } - } - else { - ts.onWatchedFileStat(watchedFile, stats.mtime); - } - }); - } - // this implementation uses polling and - // stat due to inconsistencies of fs.watch - // and efficiency of stat on modern filesystems - function startWatchTimer() { - // eslint-disable-next-line no-restricted-globals - setInterval(function () { - var count = 0; - var nextToCheck = nextFileToCheck; - var firstCheck = -1; - while ((count < chunkSize) && (nextToCheck !== firstCheck)) { - poll(nextToCheck); - if (firstCheck < 0) { - firstCheck = nextToCheck; - } - nextToCheck++; - if (nextToCheck === watchedFiles.length) { - nextToCheck = 0; - } - count++; - } - nextFileToCheck = nextToCheck; - }, interval); - } - function addFile(fileName, callback) { - var file = { - fileName: fileName, - callback: callback, - mtime: sys.fileExists(fileName) - ? getModifiedTime(fileName) - : ts.missingFileModifiedTime // Any subsequent modification will occur after this time - }; - watchedFiles.push(file); - if (watchedFiles.length === 1) { - startWatchTimer(); - } - return file; - } - function removeFile(file) { - ts.unorderedRemoveItem(watchedFiles, file); - } - } function writeMessage(buf) { if (!canWrite) { pending.push(buf); @@ -163120,9 +168392,7 @@ var ts; IOSession.prototype.exit = function () { this.logger.info("Exiting..."); this.projectService.closeLog(); - if (traceDir) { - ts.tracing.stopTracing(ts.emptyArray); - } + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.stopTracing(); process.exit(0); }; IOSession.prototype.listen = function () { @@ -163149,7 +168419,7 @@ var ts; ? ts.stripQuotes(commandLineTraceDir) : process.env.TSS_TRACE; if (traceDir) { - ts.tracing.startTracing(2 /* Server */, traceDir); + ts.startTracing("server", traceDir); } var ioSession = new IOSession(); process.on("uncaughtException", function (err) { diff --git a/lib/tsserverlibrary.d.ts b/lib/tsserverlibrary.d.ts index be9c82b1e1d9f..376ebc377765f 100644 --- a/lib/tsserverlibrary.d.ts +++ b/lib/tsserverlibrary.d.ts @@ -14,7 +14,7 @@ and limitations under the License. ***************************************************************************** */ declare namespace ts { - const versionMajorMinor = "4.2"; + const versionMajorMinor = "4.4"; /** The version of the TypeScript compiler release */ const version: string; /** @@ -166,302 +166,311 @@ declare namespace ts { QuestionQuestionToken = 60, /** Only the JSDoc scanner produces BacktickToken. The normal scanner produces NoSubstitutionTemplateLiteral and related kinds. */ BacktickToken = 61, - EqualsToken = 62, - PlusEqualsToken = 63, - MinusEqualsToken = 64, - AsteriskEqualsToken = 65, - AsteriskAsteriskEqualsToken = 66, - SlashEqualsToken = 67, - PercentEqualsToken = 68, - LessThanLessThanEqualsToken = 69, - GreaterThanGreaterThanEqualsToken = 70, - GreaterThanGreaterThanGreaterThanEqualsToken = 71, - AmpersandEqualsToken = 72, - BarEqualsToken = 73, - BarBarEqualsToken = 74, - AmpersandAmpersandEqualsToken = 75, - QuestionQuestionEqualsToken = 76, - CaretEqualsToken = 77, - Identifier = 78, - PrivateIdentifier = 79, - BreakKeyword = 80, - CaseKeyword = 81, - CatchKeyword = 82, - ClassKeyword = 83, - ConstKeyword = 84, - ContinueKeyword = 85, - DebuggerKeyword = 86, - DefaultKeyword = 87, - DeleteKeyword = 88, - DoKeyword = 89, - ElseKeyword = 90, - EnumKeyword = 91, - ExportKeyword = 92, - ExtendsKeyword = 93, - FalseKeyword = 94, - FinallyKeyword = 95, - ForKeyword = 96, - FunctionKeyword = 97, - IfKeyword = 98, - ImportKeyword = 99, - InKeyword = 100, - InstanceOfKeyword = 101, - NewKeyword = 102, - NullKeyword = 103, - ReturnKeyword = 104, - SuperKeyword = 105, - SwitchKeyword = 106, - ThisKeyword = 107, - ThrowKeyword = 108, - TrueKeyword = 109, - TryKeyword = 110, - TypeOfKeyword = 111, - VarKeyword = 112, - VoidKeyword = 113, - WhileKeyword = 114, - WithKeyword = 115, - ImplementsKeyword = 116, - InterfaceKeyword = 117, - LetKeyword = 118, - PackageKeyword = 119, - PrivateKeyword = 120, - ProtectedKeyword = 121, - PublicKeyword = 122, - StaticKeyword = 123, - YieldKeyword = 124, - AbstractKeyword = 125, - AsKeyword = 126, - AssertsKeyword = 127, - AnyKeyword = 128, - AsyncKeyword = 129, - AwaitKeyword = 130, - BooleanKeyword = 131, - ConstructorKeyword = 132, - DeclareKeyword = 133, - GetKeyword = 134, - InferKeyword = 135, - IntrinsicKeyword = 136, - IsKeyword = 137, - KeyOfKeyword = 138, - ModuleKeyword = 139, - NamespaceKeyword = 140, - NeverKeyword = 141, - ReadonlyKeyword = 142, - RequireKeyword = 143, - NumberKeyword = 144, - ObjectKeyword = 145, - SetKeyword = 146, - StringKeyword = 147, - SymbolKeyword = 148, - TypeKeyword = 149, - UndefinedKeyword = 150, - UniqueKeyword = 151, - UnknownKeyword = 152, - FromKeyword = 153, - GlobalKeyword = 154, - BigIntKeyword = 155, - OfKeyword = 156, - QualifiedName = 157, - ComputedPropertyName = 158, - TypeParameter = 159, - Parameter = 160, - Decorator = 161, - PropertySignature = 162, - PropertyDeclaration = 163, - MethodSignature = 164, - MethodDeclaration = 165, - Constructor = 166, - GetAccessor = 167, - SetAccessor = 168, - CallSignature = 169, - ConstructSignature = 170, - IndexSignature = 171, - TypePredicate = 172, - TypeReference = 173, - FunctionType = 174, - ConstructorType = 175, - TypeQuery = 176, - TypeLiteral = 177, - ArrayType = 178, - TupleType = 179, - OptionalType = 180, - RestType = 181, - UnionType = 182, - IntersectionType = 183, - ConditionalType = 184, - InferType = 185, - ParenthesizedType = 186, - ThisType = 187, - TypeOperator = 188, - IndexedAccessType = 189, - MappedType = 190, - LiteralType = 191, - NamedTupleMember = 192, - TemplateLiteralType = 193, - TemplateLiteralTypeSpan = 194, - ImportType = 195, - ObjectBindingPattern = 196, - ArrayBindingPattern = 197, - BindingElement = 198, - ArrayLiteralExpression = 199, - ObjectLiteralExpression = 200, - PropertyAccessExpression = 201, - ElementAccessExpression = 202, - CallExpression = 203, - NewExpression = 204, - TaggedTemplateExpression = 205, - TypeAssertionExpression = 206, - ParenthesizedExpression = 207, - FunctionExpression = 208, - ArrowFunction = 209, - DeleteExpression = 210, - TypeOfExpression = 211, - VoidExpression = 212, - AwaitExpression = 213, - PrefixUnaryExpression = 214, - PostfixUnaryExpression = 215, - BinaryExpression = 216, - ConditionalExpression = 217, - TemplateExpression = 218, - YieldExpression = 219, - SpreadElement = 220, - ClassExpression = 221, - OmittedExpression = 222, - ExpressionWithTypeArguments = 223, - AsExpression = 224, - NonNullExpression = 225, - MetaProperty = 226, - SyntheticExpression = 227, - TemplateSpan = 228, - SemicolonClassElement = 229, - Block = 230, - EmptyStatement = 231, - VariableStatement = 232, - ExpressionStatement = 233, - IfStatement = 234, - DoStatement = 235, - WhileStatement = 236, - ForStatement = 237, - ForInStatement = 238, - ForOfStatement = 239, - ContinueStatement = 240, - BreakStatement = 241, - ReturnStatement = 242, - WithStatement = 243, - SwitchStatement = 244, - LabeledStatement = 245, - ThrowStatement = 246, - TryStatement = 247, - DebuggerStatement = 248, - VariableDeclaration = 249, - VariableDeclarationList = 250, - FunctionDeclaration = 251, - ClassDeclaration = 252, - InterfaceDeclaration = 253, - TypeAliasDeclaration = 254, - EnumDeclaration = 255, - ModuleDeclaration = 256, - ModuleBlock = 257, - CaseBlock = 258, - NamespaceExportDeclaration = 259, - ImportEqualsDeclaration = 260, - ImportDeclaration = 261, - ImportClause = 262, - NamespaceImport = 263, - NamedImports = 264, - ImportSpecifier = 265, - ExportAssignment = 266, - ExportDeclaration = 267, - NamedExports = 268, - NamespaceExport = 269, - ExportSpecifier = 270, - MissingDeclaration = 271, - ExternalModuleReference = 272, - JsxElement = 273, - JsxSelfClosingElement = 274, - JsxOpeningElement = 275, - JsxClosingElement = 276, - JsxFragment = 277, - JsxOpeningFragment = 278, - JsxClosingFragment = 279, - JsxAttribute = 280, - JsxAttributes = 281, - JsxSpreadAttribute = 282, - JsxExpression = 283, - CaseClause = 284, - DefaultClause = 285, - HeritageClause = 286, - CatchClause = 287, - PropertyAssignment = 288, - ShorthandPropertyAssignment = 289, - SpreadAssignment = 290, - EnumMember = 291, - UnparsedPrologue = 292, - UnparsedPrepend = 293, - UnparsedText = 294, - UnparsedInternalText = 295, - UnparsedSyntheticReference = 296, - SourceFile = 297, - Bundle = 298, - UnparsedSource = 299, - InputFiles = 300, - JSDocTypeExpression = 301, - JSDocNameReference = 302, - JSDocAllType = 303, - JSDocUnknownType = 304, - JSDocNullableType = 305, - JSDocNonNullableType = 306, - JSDocOptionalType = 307, - JSDocFunctionType = 308, - JSDocVariadicType = 309, - JSDocNamepathType = 310, - JSDocComment = 311, - JSDocTypeLiteral = 312, - JSDocSignature = 313, - JSDocTag = 314, - JSDocAugmentsTag = 315, - JSDocImplementsTag = 316, - JSDocAuthorTag = 317, - JSDocDeprecatedTag = 318, - JSDocClassTag = 319, - JSDocPublicTag = 320, - JSDocPrivateTag = 321, - JSDocProtectedTag = 322, - JSDocReadonlyTag = 323, - JSDocCallbackTag = 324, - JSDocEnumTag = 325, - JSDocParameterTag = 326, - JSDocReturnTag = 327, - JSDocThisTag = 328, - JSDocTypeTag = 329, - JSDocTemplateTag = 330, - JSDocTypedefTag = 331, - JSDocSeeTag = 332, - JSDocPropertyTag = 333, - SyntaxList = 334, - NotEmittedStatement = 335, - PartiallyEmittedExpression = 336, - CommaListExpression = 337, - MergeDeclarationMarker = 338, - EndOfDeclarationMarker = 339, - SyntheticReferenceExpression = 340, - Count = 341, - FirstAssignment = 62, - LastAssignment = 77, - FirstCompoundAssignment = 63, - LastCompoundAssignment = 77, - FirstReservedWord = 80, - LastReservedWord = 115, - FirstKeyword = 80, - LastKeyword = 156, - FirstFutureReservedWord = 116, - LastFutureReservedWord = 124, - FirstTypeNode = 172, - LastTypeNode = 195, + /** Only the JSDoc scanner produces HashToken. The normal scanner produces PrivateIdentifier. */ + HashToken = 62, + EqualsToken = 63, + PlusEqualsToken = 64, + MinusEqualsToken = 65, + AsteriskEqualsToken = 66, + AsteriskAsteriskEqualsToken = 67, + SlashEqualsToken = 68, + PercentEqualsToken = 69, + LessThanLessThanEqualsToken = 70, + GreaterThanGreaterThanEqualsToken = 71, + GreaterThanGreaterThanGreaterThanEqualsToken = 72, + AmpersandEqualsToken = 73, + BarEqualsToken = 74, + BarBarEqualsToken = 75, + AmpersandAmpersandEqualsToken = 76, + QuestionQuestionEqualsToken = 77, + CaretEqualsToken = 78, + Identifier = 79, + PrivateIdentifier = 80, + BreakKeyword = 81, + CaseKeyword = 82, + CatchKeyword = 83, + ClassKeyword = 84, + ConstKeyword = 85, + ContinueKeyword = 86, + DebuggerKeyword = 87, + DefaultKeyword = 88, + DeleteKeyword = 89, + DoKeyword = 90, + ElseKeyword = 91, + EnumKeyword = 92, + ExportKeyword = 93, + ExtendsKeyword = 94, + FalseKeyword = 95, + FinallyKeyword = 96, + ForKeyword = 97, + FunctionKeyword = 98, + IfKeyword = 99, + ImportKeyword = 100, + InKeyword = 101, + InstanceOfKeyword = 102, + NewKeyword = 103, + NullKeyword = 104, + ReturnKeyword = 105, + SuperKeyword = 106, + SwitchKeyword = 107, + ThisKeyword = 108, + ThrowKeyword = 109, + TrueKeyword = 110, + TryKeyword = 111, + TypeOfKeyword = 112, + VarKeyword = 113, + VoidKeyword = 114, + WhileKeyword = 115, + WithKeyword = 116, + ImplementsKeyword = 117, + InterfaceKeyword = 118, + LetKeyword = 119, + PackageKeyword = 120, + PrivateKeyword = 121, + ProtectedKeyword = 122, + PublicKeyword = 123, + StaticKeyword = 124, + YieldKeyword = 125, + AbstractKeyword = 126, + AsKeyword = 127, + AssertsKeyword = 128, + AnyKeyword = 129, + AsyncKeyword = 130, + AwaitKeyword = 131, + BooleanKeyword = 132, + ConstructorKeyword = 133, + DeclareKeyword = 134, + GetKeyword = 135, + InferKeyword = 136, + IntrinsicKeyword = 137, + IsKeyword = 138, + KeyOfKeyword = 139, + ModuleKeyword = 140, + NamespaceKeyword = 141, + NeverKeyword = 142, + ReadonlyKeyword = 143, + RequireKeyword = 144, + NumberKeyword = 145, + ObjectKeyword = 146, + SetKeyword = 147, + StringKeyword = 148, + SymbolKeyword = 149, + TypeKeyword = 150, + UndefinedKeyword = 151, + UniqueKeyword = 152, + UnknownKeyword = 153, + FromKeyword = 154, + GlobalKeyword = 155, + BigIntKeyword = 156, + OverrideKeyword = 157, + OfKeyword = 158, + QualifiedName = 159, + ComputedPropertyName = 160, + TypeParameter = 161, + Parameter = 162, + Decorator = 163, + PropertySignature = 164, + PropertyDeclaration = 165, + MethodSignature = 166, + MethodDeclaration = 167, + Constructor = 168, + GetAccessor = 169, + SetAccessor = 170, + CallSignature = 171, + ConstructSignature = 172, + IndexSignature = 173, + TypePredicate = 174, + TypeReference = 175, + FunctionType = 176, + ConstructorType = 177, + TypeQuery = 178, + TypeLiteral = 179, + ArrayType = 180, + TupleType = 181, + OptionalType = 182, + RestType = 183, + UnionType = 184, + IntersectionType = 185, + ConditionalType = 186, + InferType = 187, + ParenthesizedType = 188, + ThisType = 189, + TypeOperator = 190, + IndexedAccessType = 191, + MappedType = 192, + LiteralType = 193, + NamedTupleMember = 194, + TemplateLiteralType = 195, + TemplateLiteralTypeSpan = 196, + ImportType = 197, + ObjectBindingPattern = 198, + ArrayBindingPattern = 199, + BindingElement = 200, + ArrayLiteralExpression = 201, + ObjectLiteralExpression = 202, + PropertyAccessExpression = 203, + ElementAccessExpression = 204, + CallExpression = 205, + NewExpression = 206, + TaggedTemplateExpression = 207, + TypeAssertionExpression = 208, + ParenthesizedExpression = 209, + FunctionExpression = 210, + ArrowFunction = 211, + DeleteExpression = 212, + TypeOfExpression = 213, + VoidExpression = 214, + AwaitExpression = 215, + PrefixUnaryExpression = 216, + PostfixUnaryExpression = 217, + BinaryExpression = 218, + ConditionalExpression = 219, + TemplateExpression = 220, + YieldExpression = 221, + SpreadElement = 222, + ClassExpression = 223, + OmittedExpression = 224, + ExpressionWithTypeArguments = 225, + AsExpression = 226, + NonNullExpression = 227, + MetaProperty = 228, + SyntheticExpression = 229, + TemplateSpan = 230, + SemicolonClassElement = 231, + Block = 232, + EmptyStatement = 233, + VariableStatement = 234, + ExpressionStatement = 235, + IfStatement = 236, + DoStatement = 237, + WhileStatement = 238, + ForStatement = 239, + ForInStatement = 240, + ForOfStatement = 241, + ContinueStatement = 242, + BreakStatement = 243, + ReturnStatement = 244, + WithStatement = 245, + SwitchStatement = 246, + LabeledStatement = 247, + ThrowStatement = 248, + TryStatement = 249, + DebuggerStatement = 250, + VariableDeclaration = 251, + VariableDeclarationList = 252, + FunctionDeclaration = 253, + ClassDeclaration = 254, + InterfaceDeclaration = 255, + TypeAliasDeclaration = 256, + EnumDeclaration = 257, + ModuleDeclaration = 258, + ModuleBlock = 259, + CaseBlock = 260, + NamespaceExportDeclaration = 261, + ImportEqualsDeclaration = 262, + ImportDeclaration = 263, + ImportClause = 264, + NamespaceImport = 265, + NamedImports = 266, + ImportSpecifier = 267, + ExportAssignment = 268, + ExportDeclaration = 269, + NamedExports = 270, + NamespaceExport = 271, + ExportSpecifier = 272, + MissingDeclaration = 273, + ExternalModuleReference = 274, + JsxElement = 275, + JsxSelfClosingElement = 276, + JsxOpeningElement = 277, + JsxClosingElement = 278, + JsxFragment = 279, + JsxOpeningFragment = 280, + JsxClosingFragment = 281, + JsxAttribute = 282, + JsxAttributes = 283, + JsxSpreadAttribute = 284, + JsxExpression = 285, + CaseClause = 286, + DefaultClause = 287, + HeritageClause = 288, + CatchClause = 289, + PropertyAssignment = 290, + ShorthandPropertyAssignment = 291, + SpreadAssignment = 292, + EnumMember = 293, + UnparsedPrologue = 294, + UnparsedPrepend = 295, + UnparsedText = 296, + UnparsedInternalText = 297, + UnparsedSyntheticReference = 298, + SourceFile = 299, + Bundle = 300, + UnparsedSource = 301, + InputFiles = 302, + JSDocTypeExpression = 303, + JSDocNameReference = 304, + JSDocMemberName = 305, + JSDocAllType = 306, + JSDocUnknownType = 307, + JSDocNullableType = 308, + JSDocNonNullableType = 309, + JSDocOptionalType = 310, + JSDocFunctionType = 311, + JSDocVariadicType = 312, + JSDocNamepathType = 313, + JSDocComment = 314, + JSDocText = 315, + JSDocTypeLiteral = 316, + JSDocSignature = 317, + JSDocLink = 318, + JSDocLinkCode = 319, + JSDocLinkPlain = 320, + JSDocTag = 321, + JSDocAugmentsTag = 322, + JSDocImplementsTag = 323, + JSDocAuthorTag = 324, + JSDocDeprecatedTag = 325, + JSDocClassTag = 326, + JSDocPublicTag = 327, + JSDocPrivateTag = 328, + JSDocProtectedTag = 329, + JSDocReadonlyTag = 330, + JSDocOverrideTag = 331, + JSDocCallbackTag = 332, + JSDocEnumTag = 333, + JSDocParameterTag = 334, + JSDocReturnTag = 335, + JSDocThisTag = 336, + JSDocTypeTag = 337, + JSDocTemplateTag = 338, + JSDocTypedefTag = 339, + JSDocSeeTag = 340, + JSDocPropertyTag = 341, + SyntaxList = 342, + NotEmittedStatement = 343, + PartiallyEmittedExpression = 344, + CommaListExpression = 345, + MergeDeclarationMarker = 346, + EndOfDeclarationMarker = 347, + SyntheticReferenceExpression = 348, + Count = 349, + FirstAssignment = 63, + LastAssignment = 78, + FirstCompoundAssignment = 64, + LastCompoundAssignment = 78, + FirstReservedWord = 81, + LastReservedWord = 116, + FirstKeyword = 81, + LastKeyword = 158, + FirstFutureReservedWord = 117, + LastFutureReservedWord = 125, + FirstTypeNode = 174, + LastTypeNode = 197, FirstPunctuation = 18, - LastPunctuation = 77, + LastPunctuation = 78, FirstToken = 0, - LastToken = 156, + LastToken = 158, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -469,25 +478,25 @@ declare namespace ts { FirstTemplateToken = 14, LastTemplateToken = 17, FirstBinaryOperator = 29, - LastBinaryOperator = 77, - FirstStatement = 232, - LastStatement = 248, - FirstNode = 157, - FirstJSDocNode = 301, - LastJSDocNode = 333, - FirstJSDocTagNode = 314, - LastJSDocTagNode = 333, + LastBinaryOperator = 78, + FirstStatement = 234, + LastStatement = 250, + FirstNode = 159, + FirstJSDocNode = 303, + LastJSDocNode = 341, + FirstJSDocTagNode = 321, + LastJSDocTagNode = 341, } export type TriviaSyntaxKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia; export type LiteralSyntaxKind = SyntaxKind.NumericLiteral | SyntaxKind.BigIntLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral; export type PseudoLiteralSyntaxKind = SyntaxKind.TemplateHead | SyntaxKind.TemplateMiddle | SyntaxKind.TemplateTail; - export type PunctuationSyntaxKind = SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.OpenParenToken | SyntaxKind.CloseParenToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.DotToken | SyntaxKind.DotDotDotToken | SyntaxKind.SemicolonToken | SyntaxKind.CommaToken | SyntaxKind.QuestionDotToken | SyntaxKind.LessThanToken | SyntaxKind.LessThanSlashToken | SyntaxKind.GreaterThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.EqualsEqualsToken | SyntaxKind.ExclamationEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.EqualsGreaterThanToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.AsteriskToken | SyntaxKind.AsteriskAsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken | SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken | SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken | SyntaxKind.ExclamationToken | SyntaxKind.TildeToken | SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken | SyntaxKind.QuestionQuestionToken | SyntaxKind.QuestionToken | SyntaxKind.ColonToken | SyntaxKind.AtToken | SyntaxKind.BacktickToken | SyntaxKind.EqualsToken | SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken; - export type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.AssertsKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InferKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.OfKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword; - export type ModifierSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.ConstKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.ExportKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.StaticKeyword; + export type PunctuationSyntaxKind = SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.OpenParenToken | SyntaxKind.CloseParenToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.DotToken | SyntaxKind.DotDotDotToken | SyntaxKind.SemicolonToken | SyntaxKind.CommaToken | SyntaxKind.QuestionDotToken | SyntaxKind.LessThanToken | SyntaxKind.LessThanSlashToken | SyntaxKind.GreaterThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.EqualsEqualsToken | SyntaxKind.ExclamationEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.EqualsGreaterThanToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.AsteriskToken | SyntaxKind.AsteriskAsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken | SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken | SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken | SyntaxKind.ExclamationToken | SyntaxKind.TildeToken | SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken | SyntaxKind.QuestionQuestionToken | SyntaxKind.QuestionToken | SyntaxKind.ColonToken | SyntaxKind.AtToken | SyntaxKind.BacktickToken | SyntaxKind.HashToken | SyntaxKind.EqualsToken | SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken; + export type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.AssertsKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InferKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.OfKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.RequireKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword; + export type ModifierSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.ConstKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.ExportKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.StaticKeyword; export type KeywordTypeSyntaxKind = SyntaxKind.AnyKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VoidKeyword; export type TokenSyntaxKind = SyntaxKind.Unknown | SyntaxKind.EndOfFileToken | TriviaSyntaxKind | LiteralSyntaxKind | PseudoLiteralSyntaxKind | PunctuationSyntaxKind | SyntaxKind.Identifier | KeywordSyntaxKind; export type JsxTokenSyntaxKind = SyntaxKind.LessThanSlashToken | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken; - export type JSDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.GreaterThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.BacktickToken | SyntaxKind.Unknown | KeywordSyntaxKind; + export type JSDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.GreaterThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.BacktickToken | SyntaxKind.HashToken | SyntaxKind.Unknown | KeywordSyntaxKind; export enum NodeFlags { None = 0, Let = 1, @@ -533,13 +542,14 @@ declare namespace ts { Const = 2048, HasComputedJSDocModifiers = 4096, Deprecated = 8192, + Override = 16384, HasComputedFlags = 536870912, AccessibilityModifier = 28, - ParameterPropertyModifier = 92, + ParameterPropertyModifier = 16476, NonPublicAccessibilityModifier = 24, - TypeScriptModifier = 2270, + TypeScriptModifier = 18654, ExportDefault = 513, - All = 11263 + All = 27647 } export enum JsxFlags { None = 0, @@ -558,7 +568,7 @@ declare namespace ts { } export interface JSDocContainer { } - export type HasJSDoc = ParameterDeclaration | CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | PropertySignature | ArrowFunction | ParenthesizedExpression | SpreadAssignment | ShorthandPropertyAssignment | PropertyAssignment | FunctionExpression | LabeledStatement | ExpressionStatement | VariableStatement | FunctionDeclaration | ConstructorDeclaration | MethodDeclaration | PropertyDeclaration | AccessorDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | EnumMember | EnumDeclaration | ModuleDeclaration | ImportEqualsDeclaration | ImportDeclaration | NamespaceExportDeclaration | ExportAssignment | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | ExportDeclaration | NamedTupleMember | EndOfFileToken; + export type HasJSDoc = ParameterDeclaration | CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | PropertySignature | ArrowFunction | ParenthesizedExpression | SpreadAssignment | ShorthandPropertyAssignment | PropertyAssignment | FunctionExpression | EmptyStatement | DebuggerStatement | Block | VariableStatement | ExpressionStatement | IfStatement | DoStatement | WhileStatement | ForStatement | ForInStatement | ForOfStatement | BreakStatement | ContinueStatement | ReturnStatement | WithStatement | SwitchStatement | LabeledStatement | ThrowStatement | TryStatement | FunctionDeclaration | ConstructorDeclaration | MethodDeclaration | VariableDeclaration | PropertyDeclaration | AccessorDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | EnumMember | EnumDeclaration | ModuleDeclaration | ImportEqualsDeclaration | ImportDeclaration | NamespaceExportDeclaration | ExportAssignment | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | ExportDeclaration | NamedTupleMember | EndOfFileToken; export type HasType = SignatureDeclaration | VariableDeclaration | ParameterDeclaration | PropertySignature | PropertyDeclaration | TypePredicateNode | ParenthesizedTypeNode | TypeOperatorNode | MappedTypeNode | AssertionExpression | TypeAliasDeclaration | JSDocTypeExpression | JSDocNonNullableType | JSDocNullableType | JSDocOptionalType | JSDocVariadicType; export type HasTypeArguments = CallExpression | NewExpression | TaggedTemplateExpression | JsxOpeningElement | JsxSelfClosingElement; export type HasInitializer = HasExpressionInitializer | ForStatement | ForInStatement | ForOfStatement | JsxAttribute; @@ -603,10 +613,11 @@ declare namespace ts { export type ProtectedKeyword = ModifierToken; export type PublicKeyword = ModifierToken; export type ReadonlyKeyword = ModifierToken; + export type OverrideKeyword = ModifierToken; export type StaticKeyword = ModifierToken; /** @deprecated Use `ReadonlyKeyword` instead. */ export type ReadonlyToken = ReadonlyKeyword; - export type Modifier = AbstractKeyword | AsyncKeyword | ConstKeyword | DeclareKeyword | DefaultKeyword | ExportKeyword | PrivateKeyword | ProtectedKeyword | PublicKeyword | ReadonlyKeyword | StaticKeyword; + export type Modifier = AbstractKeyword | AsyncKeyword | ConstKeyword | DeclareKeyword | DefaultKeyword | ExportKeyword | PrivateKeyword | ProtectedKeyword | PublicKeyword | OverrideKeyword | ReadonlyKeyword | StaticKeyword; export type AccessibilityModifier = PublicKeyword | PrivateKeyword | ProtectedKeyword; export type ParameterPropertyModifier = AccessibilityModifier | ReadonlyKeyword; export type ClassMemberModifier = AccessibilityModifier | ReadonlyKeyword | StaticKeyword; @@ -638,6 +649,7 @@ declare namespace ts { } export type EntityName = Identifier | QualifiedName; export type PropertyName = Identifier | StringLiteral | NumericLiteral | ComputedPropertyName | PrivateIdentifier; + export type MemberName = Identifier | PrivateIdentifier; export type DeclarationName = Identifier | PrivateIdentifier | StringLiteralLike | NumericLiteral | ComputedPropertyName | ElementAccessExpression | BindingPattern | EntityNameExpression; export interface Declaration extends Node { _declarationBrand: any; @@ -686,7 +698,7 @@ declare namespace ts { readonly kind: SyntaxKind.ConstructSignature; } export type BindingName = Identifier | BindingPattern; - export interface VariableDeclaration extends NamedDeclaration { + export interface VariableDeclaration extends NamedDeclaration, JSDocContainer { readonly kind: SyntaxKind.VariableDeclaration; readonly parent: VariableDeclarationList | CatchClause; readonly name: BindingName; @@ -820,15 +832,15 @@ declare namespace ts { readonly kind: SyntaxKind.SemicolonClassElement; readonly parent: ClassLikeDeclaration; } - export interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { + export interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, TypeElement, ObjectLiteralElement, JSDocContainer { readonly kind: SyntaxKind.GetAccessor; - readonly parent: ClassLikeDeclaration | ObjectLiteralExpression; + readonly parent: ClassLikeDeclaration | ObjectLiteralExpression | TypeLiteralNode | InterfaceDeclaration; readonly name: PropertyName; readonly body?: FunctionBody; } - export interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { + export interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, TypeElement, ObjectLiteralElement, JSDocContainer { readonly kind: SyntaxKind.SetAccessor; - readonly parent: ClassLikeDeclaration | ObjectLiteralExpression; + readonly parent: ClassLikeDeclaration | ObjectLiteralExpression | TypeLiteralNode | InterfaceDeclaration; readonly name: PropertyName; readonly body?: FunctionBody; } @@ -1216,11 +1228,11 @@ declare namespace ts { readonly kind: SyntaxKind.PropertyAccessExpression; readonly expression: LeftHandSideExpression; readonly questionDotToken?: QuestionDotToken; - readonly name: Identifier | PrivateIdentifier; + readonly name: MemberName; } export interface PropertyAccessChain extends PropertyAccessExpression { _optionalChainBrand: any; - readonly name: Identifier | PrivateIdentifier; + readonly name: MemberName; } export interface SuperPropertyAccessExpression extends PropertyAccessExpression { readonly expression: SuperExpression; @@ -1373,7 +1385,7 @@ declare namespace ts { readonly containsOnlyTriviaWhiteSpaces: boolean; } export type JsxChild = JsxText | JsxExpression | JsxElement | JsxSelfClosingElement | JsxFragment; - export interface Statement extends Node { + export interface Statement extends Node, JSDocContainer { _statementBrand: any; } export interface NotEmittedStatement extends Statement { @@ -1401,11 +1413,11 @@ declare namespace ts { readonly kind: SyntaxKind.Block; readonly statements: NodeArray; } - export interface VariableStatement extends Statement, JSDocContainer { + export interface VariableStatement extends Statement { readonly kind: SyntaxKind.VariableStatement; readonly declarationList: VariableDeclarationList; } - export interface ExpressionStatement extends Statement, JSDocContainer { + export interface ExpressionStatement extends Statement { readonly kind: SyntaxKind.ExpressionStatement; readonly expression: Expression; } @@ -1486,7 +1498,7 @@ declare namespace ts { readonly statements: NodeArray; } export type CaseOrDefaultClause = CaseClause | DefaultClause; - export interface LabeledStatement extends Statement, JSDocContainer { + export interface LabeledStatement extends Statement { readonly kind: SyntaxKind.LabeledStatement; readonly label: Identifier; readonly statement: Statement; @@ -1606,7 +1618,7 @@ declare namespace ts { readonly parent: ImportEqualsDeclaration; readonly expression: Expression; } - export interface ImportDeclaration extends Statement, JSDocContainer { + export interface ImportDeclaration extends Statement { readonly kind: SyntaxKind.ImportDeclaration; readonly parent: SourceFile | ModuleBlock; readonly importClause?: ImportClause; @@ -1703,7 +1715,13 @@ declare namespace ts { } export interface JSDocNameReference extends Node { readonly kind: SyntaxKind.JSDocNameReference; - readonly name: EntityName; + readonly name: EntityName | JSDocMemberName; + } + /** Class#method reference in JSDoc */ + export interface JSDocMemberName extends Node { + readonly kind: SyntaxKind.JSDocMemberName; + readonly left: EntityName | JSDocMemberName; + readonly right: Identifier; } export interface JSDocType extends TypeNode { _jsDocTypeBrand: any; @@ -1742,12 +1760,32 @@ declare namespace ts { readonly kind: SyntaxKind.JSDocComment; readonly parent: HasJSDoc; readonly tags?: NodeArray; - readonly comment?: string; + readonly comment?: string | NodeArray; } export interface JSDocTag extends Node { readonly parent: JSDoc | JSDocTypeLiteral; readonly tagName: Identifier; - readonly comment?: string; + readonly comment?: string | NodeArray; + } + export interface JSDocLink extends Node { + readonly kind: SyntaxKind.JSDocLink; + readonly name?: EntityName | JSDocMemberName; + text: string; + } + export interface JSDocLinkCode extends Node { + readonly kind: SyntaxKind.JSDocLinkCode; + readonly name?: EntityName | JSDocMemberName; + text: string; + } + export interface JSDocLinkPlain extends Node { + readonly kind: SyntaxKind.JSDocLinkPlain; + readonly name?: EntityName | JSDocMemberName; + text: string; + } + export type JSDocComment = JSDocText | JSDocLink | JSDocLinkCode | JSDocLinkPlain; + export interface JSDocText extends Node { + readonly kind: SyntaxKind.JSDocText; + text: string; } export interface JSDocUnknownTag extends JSDocTag { readonly kind: SyntaxKind.JSDocTag; @@ -1789,6 +1827,9 @@ declare namespace ts { export interface JSDocReadonlyTag extends JSDocTag { readonly kind: SyntaxKind.JSDocReadonlyTag; } + export interface JSDocOverrideTag extends JSDocTag { + readonly kind: SyntaxKind.JSDocOverrideTag; + } export interface JSDocEnumTag extends JSDocTag, Declaration { readonly kind: SyntaxKind.JSDocEnumTag; readonly parent: JSDoc; @@ -2080,7 +2121,6 @@ declare namespace ts { * Gets a type checker that can be used to semantically analyze source files in the program. */ getTypeChecker(): TypeChecker; - getTypeCatalog(): readonly Type[]; getNodeCount(): number; getIdentifierCount(): number; getSymbolCount(): number; @@ -2186,7 +2226,7 @@ declare namespace ts { * The function returns the value (local variable) symbol of an identifier in the short-hand property assignment. * This is necessary as an identifier in short-hand property assignment can contains two meaning: property name and property value. */ - getShorthandAssignmentValueSymbol(location: Node): Symbol | undefined; + getShorthandAssignmentValueSymbol(location: Node | undefined): Symbol | undefined; getExportSpecifierLocalTargetSymbol(location: ExportSpecifier | Identifier): Symbol | undefined; /** * If a symbol is a local symbol with an associated exported symbol, returns the exported symbol. @@ -2261,6 +2301,8 @@ declare namespace ts { NoTypeReduction = 536870912, NoUndefinedOptionalParameterType = 1073741824, AllowThisInObjectLiteral = 32768, + AllowQualifiedNameInPlaceOfIdentifier = 65536, + /** @deprecated AllowQualifedNameInPlaceOfIdentifier. Use AllowQualifiedNameInPlaceOfIdentifier instead. */ AllowQualifedNameInPlaceOfIdentifier = 65536, AllowAnonymousIdentifier = 131072, AllowEmptyUnionOrIntersection = 262144, @@ -2271,8 +2313,7 @@ declare namespace ts { IgnoreErrors = 70221824, InObjectTypeLiteral = 4194304, InTypeAlias = 8388608, - InInitialEntityName = 16777216, - InReverseMappedType = 33554432 + InInitialEntityName = 16777216 } export enum TypeFormatFlags { None = 0, @@ -2405,8 +2446,8 @@ declare namespace ts { export interface Symbol { flags: SymbolFlags; escapedName: __String; - declarations: Declaration[]; - valueDeclaration: Declaration; + declarations?: Declaration[]; + valueDeclaration?: Declaration; members?: SymbolTable; exports?: SymbolTable; globalExports?: SymbolTable; @@ -2540,15 +2581,15 @@ declare namespace ts { ObjectLiteral = 128, EvolvingArray = 256, ObjectLiteralPatternWithComputedProperties = 512, - ContainsSpread = 1024, - ReverseMapped = 2048, - JsxAttributes = 4096, - MarkerType = 8192, - JSLiteral = 16384, - FreshLiteral = 32768, - ArrayLiteral = 65536, - ObjectRestType = 131072, + ReverseMapped = 1024, + JsxAttributes = 2048, + MarkerType = 4096, + JSLiteral = 8192, + FreshLiteral = 16384, + ArrayLiteral = 32768, ClassOrInterface = 3, + ContainsSpread = 4194304, + ObjectRestType = 8388608, } export interface ObjectType extends Type { objectFlags: ObjectFlags; @@ -2656,14 +2697,13 @@ declare namespace ts { export interface TemplateLiteralType extends InstantiableType { texts: readonly string[]; types: readonly Type[]; - freshType: TemplateLiteralType; - regularType: TemplateLiteralType; } export interface StringMappingType extends InstantiableType { symbol: Symbol; type: Type; } export interface SubstitutionType extends InstantiableType { + objectFlags: ObjectFlags; baseType: Type; substitute: Type; } @@ -2688,16 +2728,17 @@ declare namespace ts { export enum InferencePriority { NakedTypeVariable = 1, SpeculativeTuple = 2, - HomomorphicMappedType = 4, - PartialHomomorphicMappedType = 8, - MappedTypeConstraint = 16, - ContravariantConditional = 32, - ReturnType = 64, - LiteralKeyof = 128, - NoConstraints = 256, - AlwaysStrict = 512, - MaxValue = 1024, - PriorityImpliesCombination = 208, + SubstituteSource = 4, + HomomorphicMappedType = 8, + PartialHomomorphicMappedType = 16, + MappedTypeConstraint = 32, + ContravariantConditional = 64, + ReturnType = 128, + LiteralKeyof = 256, + NoConstraints = 512, + AlwaysStrict = 1024, + MaxValue = 2048, + PriorityImpliesCombination = 416, Circularity = -1 } /** @deprecated Use FileExtensionInfo instead. */ @@ -2774,18 +2815,21 @@ declare namespace ts { FixedPollingInterval = 0, PriorityPollingInterval = 1, DynamicPriorityPolling = 2, - UseFsEvents = 3, - UseFsEventsOnParentDirectory = 4 + FixedChunkSizePolling = 3, + UseFsEvents = 4, + UseFsEventsOnParentDirectory = 5 } export enum WatchDirectoryKind { UseFsEvents = 0, FixedPollingInterval = 1, - DynamicPriorityPolling = 2 + DynamicPriorityPolling = 2, + FixedChunkSizePolling = 3 } export enum PollingWatchKind { FixedInterval = 0, PriorityInterval = 1, - DynamicPriority = 2 + DynamicPriority = 2, + FixedChunkSize = 3 } export type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[] | ProjectReference[] | null | undefined; export interface CompilerOptions { @@ -2847,6 +2891,7 @@ declare namespace ts { outFile?: string; paths?: MapLike; preserveConstEnums?: boolean; + noImplicitOverride?: boolean; preserveSymlinks?: boolean; project?: string; reactNamespace?: string; @@ -2868,11 +2913,13 @@ declare namespace ts { strictBindCallApply?: boolean; strictNullChecks?: boolean; strictPropertyInitialization?: boolean; + strictOptionalProperties?: boolean; stripInternal?: boolean; suppressExcessPropertyErrors?: boolean; suppressImplicitAnyIndexErrors?: boolean; target?: ScriptTarget; traceResolution?: boolean; + useUnknownInCatchVariables?: boolean; resolveJsonModule?: boolean; types?: string[]; /** Paths used to compute primary types search locations */ @@ -2957,6 +3004,7 @@ declare namespace ts { ES2018 = 5, ES2019 = 6, ES2020 = 7, + ES2021 = 8, ESNext = 99, JSON = 100, Latest = 99 @@ -3130,17 +3178,21 @@ declare namespace ts { Iterator = 8388608, NoAsciiEscaping = 16777216, } - export interface EmitHelper { + export interface EmitHelperBase { readonly name: string; readonly scoped: boolean; readonly text: string | ((node: EmitHelperUniqueNameCallback) => string); readonly priority?: number; readonly dependencies?: EmitHelper[]; } - export interface UnscopedEmitHelper extends EmitHelper { + export interface ScopedEmitHelper extends EmitHelperBase { + readonly scoped: true; + } + export interface UnscopedEmitHelper extends EmitHelperBase { readonly scoped: false; readonly text: string; } + export type EmitHelper = ScopedEmitHelper | UnscopedEmitHelper; export type EmitHelperUniqueNameCallback = (name: string) => string; export enum EmitHint { SourceFile = 0, @@ -3168,14 +3220,27 @@ declare namespace ts { createStringLiteralFromNode(sourceNode: PropertyNameLiteral, isSingleQuote?: boolean): StringLiteral; createRegularExpressionLiteral(text: string): RegularExpressionLiteral; createIdentifier(text: string): Identifier; - /** Create a unique temporary variable. */ - createTempVariable(recordTempVariable: ((node: Identifier) => void) | undefined): Identifier; - /** Create a unique temporary variable for use in a loop. */ - createLoopVariable(): Identifier; + /** + * Create a unique temporary variable. + * @param recordTempVariable An optional callback used to record the temporary variable name. This + * should usually be a reference to `hoistVariableDeclaration` from a `TransformationContext`, but + * can be `undefined` if you plan to record the temporary variable manually. + * @param reservedInNestedScopes When `true`, reserves the temporary variable name in all nested scopes + * during emit so that the variable can be referenced in a nested function body. This is an alternative to + * setting `EmitFlags.ReuseTempVariableScope` on the nested function itself. + */ + createTempVariable(recordTempVariable: ((node: Identifier) => void) | undefined, reservedInNestedScopes?: boolean): Identifier; + /** + * Create a unique temporary variable for use in a loop. + * @param reservedInNestedScopes When `true`, reserves the temporary variable name in all nested scopes + * during emit so that the variable can be referenced in a nested function body. This is an alternative to + * setting `EmitFlags.ReuseTempVariableScope` on the nested function itself. + */ + createLoopVariable(reservedInNestedScopes?: boolean): Identifier; /** Create a unique name based on the supplied text. */ createUniqueName(text: string, flags?: GeneratedIdentifierFlags): Identifier; /** Create a unique name generated for a node. */ - getGeneratedNameForNode(node: Node | undefined): Identifier; + getGeneratedNameForNode(node: Node | undefined, flags?: GeneratedIdentifierFlags): Identifier; createPrivateIdentifier(text: string): PrivateIdentifier; createToken(token: SyntaxKind.SuperKeyword): SuperExpression; createToken(token: SyntaxKind.ThisKeyword): ThisExpression; @@ -3286,10 +3351,10 @@ declare namespace ts { updateArrayLiteralExpression(node: ArrayLiteralExpression, elements: readonly Expression[]): ArrayLiteralExpression; createObjectLiteralExpression(properties?: readonly ObjectLiteralElementLike[], multiLine?: boolean): ObjectLiteralExpression; updateObjectLiteralExpression(node: ObjectLiteralExpression, properties: readonly ObjectLiteralElementLike[]): ObjectLiteralExpression; - createPropertyAccessExpression(expression: Expression, name: string | Identifier | PrivateIdentifier): PropertyAccessExpression; - updatePropertyAccessExpression(node: PropertyAccessExpression, expression: Expression, name: Identifier | PrivateIdentifier): PropertyAccessExpression; - createPropertyAccessChain(expression: Expression, questionDotToken: QuestionDotToken | undefined, name: string | Identifier | PrivateIdentifier): PropertyAccessChain; - updatePropertyAccessChain(node: PropertyAccessChain, expression: Expression, questionDotToken: QuestionDotToken | undefined, name: Identifier | PrivateIdentifier): PropertyAccessChain; + createPropertyAccessExpression(expression: Expression, name: string | MemberName): PropertyAccessExpression; + updatePropertyAccessExpression(node: PropertyAccessExpression, expression: Expression, name: MemberName): PropertyAccessExpression; + createPropertyAccessChain(expression: Expression, questionDotToken: QuestionDotToken | undefined, name: string | MemberName): PropertyAccessChain; + updatePropertyAccessChain(node: PropertyAccessChain, expression: Expression, questionDotToken: QuestionDotToken | undefined, name: MemberName): PropertyAccessChain; createElementAccessExpression(expression: Expression, index: number | Expression): ElementAccessExpression; updateElementAccessExpression(node: ElementAccessExpression, expression: Expression, argumentExpression: Expression): ElementAccessExpression; createElementAccessChain(expression: Expression, questionDotToken: QuestionDotToken | undefined, index: number | Expression): ElementAccessChain; @@ -3455,54 +3520,66 @@ declare namespace ts { updateJSDocNamepathType(node: JSDocNamepathType, type: TypeNode): JSDocNamepathType; createJSDocTypeExpression(type: TypeNode): JSDocTypeExpression; updateJSDocTypeExpression(node: JSDocTypeExpression, type: TypeNode): JSDocTypeExpression; - createJSDocNameReference(name: EntityName): JSDocNameReference; - updateJSDocNameReference(node: JSDocNameReference, name: EntityName): JSDocNameReference; + createJSDocNameReference(name: EntityName | JSDocMemberName): JSDocNameReference; + updateJSDocNameReference(node: JSDocNameReference, name: EntityName | JSDocMemberName): JSDocNameReference; + createJSDocMemberName(left: EntityName | JSDocMemberName, right: Identifier): JSDocMemberName; + updateJSDocMemberName(node: JSDocMemberName, left: EntityName | JSDocMemberName, right: Identifier): JSDocMemberName; + createJSDocLink(name: EntityName | JSDocMemberName | undefined, text: string): JSDocLink; + updateJSDocLink(node: JSDocLink, name: EntityName | JSDocMemberName | undefined, text: string): JSDocLink; + createJSDocLinkCode(name: EntityName | JSDocMemberName | undefined, text: string): JSDocLinkCode; + updateJSDocLinkCode(node: JSDocLinkCode, name: EntityName | JSDocMemberName | undefined, text: string): JSDocLinkCode; + createJSDocLinkPlain(name: EntityName | JSDocMemberName | undefined, text: string): JSDocLinkPlain; + updateJSDocLinkPlain(node: JSDocLinkPlain, name: EntityName | JSDocMemberName | undefined, text: string): JSDocLinkPlain; createJSDocTypeLiteral(jsDocPropertyTags?: readonly JSDocPropertyLikeTag[], isArrayType?: boolean): JSDocTypeLiteral; updateJSDocTypeLiteral(node: JSDocTypeLiteral, jsDocPropertyTags: readonly JSDocPropertyLikeTag[] | undefined, isArrayType: boolean | undefined): JSDocTypeLiteral; createJSDocSignature(typeParameters: readonly JSDocTemplateTag[] | undefined, parameters: readonly JSDocParameterTag[], type?: JSDocReturnTag): JSDocSignature; updateJSDocSignature(node: JSDocSignature, typeParameters: readonly JSDocTemplateTag[] | undefined, parameters: readonly JSDocParameterTag[], type: JSDocReturnTag | undefined): JSDocSignature; - createJSDocTemplateTag(tagName: Identifier | undefined, constraint: JSDocTypeExpression | undefined, typeParameters: readonly TypeParameterDeclaration[], comment?: string): JSDocTemplateTag; - updateJSDocTemplateTag(node: JSDocTemplateTag, tagName: Identifier | undefined, constraint: JSDocTypeExpression | undefined, typeParameters: readonly TypeParameterDeclaration[], comment: string | undefined): JSDocTemplateTag; - createJSDocTypedefTag(tagName: Identifier | undefined, typeExpression?: JSDocTypeExpression | JSDocTypeLiteral, fullName?: Identifier | JSDocNamespaceDeclaration, comment?: string): JSDocTypedefTag; - updateJSDocTypedefTag(node: JSDocTypedefTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression | JSDocTypeLiteral | undefined, fullName: Identifier | JSDocNamespaceDeclaration | undefined, comment: string | undefined): JSDocTypedefTag; - createJSDocParameterTag(tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression, isNameFirst?: boolean, comment?: string): JSDocParameterTag; - updateJSDocParameterTag(node: JSDocParameterTag, tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression: JSDocTypeExpression | undefined, isNameFirst: boolean, comment: string | undefined): JSDocParameterTag; - createJSDocPropertyTag(tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression, isNameFirst?: boolean, comment?: string): JSDocPropertyTag; - updateJSDocPropertyTag(node: JSDocPropertyTag, tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression: JSDocTypeExpression | undefined, isNameFirst: boolean, comment: string | undefined): JSDocPropertyTag; - createJSDocTypeTag(tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string): JSDocTypeTag; - updateJSDocTypeTag(node: JSDocTypeTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment: string | undefined): JSDocTypeTag; - createJSDocSeeTag(tagName: Identifier | undefined, nameExpression: JSDocNameReference | undefined, comment?: string): JSDocSeeTag; - updateJSDocSeeTag(node: JSDocSeeTag, tagName: Identifier | undefined, nameExpression: JSDocNameReference | undefined, comment?: string): JSDocSeeTag; - createJSDocReturnTag(tagName: Identifier | undefined, typeExpression?: JSDocTypeExpression, comment?: string): JSDocReturnTag; - updateJSDocReturnTag(node: JSDocReturnTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression | undefined, comment: string | undefined): JSDocReturnTag; - createJSDocThisTag(tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string): JSDocThisTag; - updateJSDocThisTag(node: JSDocThisTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression | undefined, comment: string | undefined): JSDocThisTag; - createJSDocEnumTag(tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string): JSDocEnumTag; - updateJSDocEnumTag(node: JSDocEnumTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment: string | undefined): JSDocEnumTag; - createJSDocCallbackTag(tagName: Identifier | undefined, typeExpression: JSDocSignature, fullName?: Identifier | JSDocNamespaceDeclaration, comment?: string): JSDocCallbackTag; - updateJSDocCallbackTag(node: JSDocCallbackTag, tagName: Identifier | undefined, typeExpression: JSDocSignature, fullName: Identifier | JSDocNamespaceDeclaration | undefined, comment: string | undefined): JSDocCallbackTag; - createJSDocAugmentsTag(tagName: Identifier | undefined, className: JSDocAugmentsTag["class"], comment?: string): JSDocAugmentsTag; - updateJSDocAugmentsTag(node: JSDocAugmentsTag, tagName: Identifier | undefined, className: JSDocAugmentsTag["class"], comment: string | undefined): JSDocAugmentsTag; - createJSDocImplementsTag(tagName: Identifier | undefined, className: JSDocImplementsTag["class"], comment?: string): JSDocImplementsTag; - updateJSDocImplementsTag(node: JSDocImplementsTag, tagName: Identifier | undefined, className: JSDocImplementsTag["class"], comment: string | undefined): JSDocImplementsTag; - createJSDocAuthorTag(tagName: Identifier | undefined, comment?: string): JSDocAuthorTag; - updateJSDocAuthorTag(node: JSDocAuthorTag, tagName: Identifier | undefined, comment: string | undefined): JSDocAuthorTag; - createJSDocClassTag(tagName: Identifier | undefined, comment?: string): JSDocClassTag; - updateJSDocClassTag(node: JSDocClassTag, tagName: Identifier | undefined, comment: string | undefined): JSDocClassTag; - createJSDocPublicTag(tagName: Identifier | undefined, comment?: string): JSDocPublicTag; - updateJSDocPublicTag(node: JSDocPublicTag, tagName: Identifier | undefined, comment: string | undefined): JSDocPublicTag; - createJSDocPrivateTag(tagName: Identifier | undefined, comment?: string): JSDocPrivateTag; - updateJSDocPrivateTag(node: JSDocPrivateTag, tagName: Identifier | undefined, comment: string | undefined): JSDocPrivateTag; - createJSDocProtectedTag(tagName: Identifier | undefined, comment?: string): JSDocProtectedTag; - updateJSDocProtectedTag(node: JSDocProtectedTag, tagName: Identifier | undefined, comment: string | undefined): JSDocProtectedTag; - createJSDocReadonlyTag(tagName: Identifier | undefined, comment?: string): JSDocReadonlyTag; - updateJSDocReadonlyTag(node: JSDocReadonlyTag, tagName: Identifier | undefined, comment: string | undefined): JSDocReadonlyTag; - createJSDocUnknownTag(tagName: Identifier, comment?: string): JSDocUnknownTag; - updateJSDocUnknownTag(node: JSDocUnknownTag, tagName: Identifier, comment: string | undefined): JSDocUnknownTag; - createJSDocDeprecatedTag(tagName: Identifier, comment?: string): JSDocDeprecatedTag; - updateJSDocDeprecatedTag(node: JSDocDeprecatedTag, tagName: Identifier, comment?: string): JSDocDeprecatedTag; - createJSDocComment(comment?: string | undefined, tags?: readonly JSDocTag[] | undefined): JSDoc; - updateJSDocComment(node: JSDoc, comment: string | undefined, tags: readonly JSDocTag[] | undefined): JSDoc; + createJSDocTemplateTag(tagName: Identifier | undefined, constraint: JSDocTypeExpression | undefined, typeParameters: readonly TypeParameterDeclaration[], comment?: string | NodeArray): JSDocTemplateTag; + updateJSDocTemplateTag(node: JSDocTemplateTag, tagName: Identifier | undefined, constraint: JSDocTypeExpression | undefined, typeParameters: readonly TypeParameterDeclaration[], comment: string | NodeArray | undefined): JSDocTemplateTag; + createJSDocTypedefTag(tagName: Identifier | undefined, typeExpression?: JSDocTypeExpression | JSDocTypeLiteral, fullName?: Identifier | JSDocNamespaceDeclaration, comment?: string | NodeArray): JSDocTypedefTag; + updateJSDocTypedefTag(node: JSDocTypedefTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression | JSDocTypeLiteral | undefined, fullName: Identifier | JSDocNamespaceDeclaration | undefined, comment: string | NodeArray | undefined): JSDocTypedefTag; + createJSDocParameterTag(tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression, isNameFirst?: boolean, comment?: string | NodeArray): JSDocParameterTag; + updateJSDocParameterTag(node: JSDocParameterTag, tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression: JSDocTypeExpression | undefined, isNameFirst: boolean, comment: string | NodeArray | undefined): JSDocParameterTag; + createJSDocPropertyTag(tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression, isNameFirst?: boolean, comment?: string | NodeArray): JSDocPropertyTag; + updateJSDocPropertyTag(node: JSDocPropertyTag, tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression: JSDocTypeExpression | undefined, isNameFirst: boolean, comment: string | NodeArray | undefined): JSDocPropertyTag; + createJSDocTypeTag(tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | NodeArray): JSDocTypeTag; + updateJSDocTypeTag(node: JSDocTypeTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment: string | NodeArray | undefined): JSDocTypeTag; + createJSDocSeeTag(tagName: Identifier | undefined, nameExpression: JSDocNameReference | undefined, comment?: string | NodeArray): JSDocSeeTag; + updateJSDocSeeTag(node: JSDocSeeTag, tagName: Identifier | undefined, nameExpression: JSDocNameReference | undefined, comment?: string | NodeArray): JSDocSeeTag; + createJSDocReturnTag(tagName: Identifier | undefined, typeExpression?: JSDocTypeExpression, comment?: string | NodeArray): JSDocReturnTag; + updateJSDocReturnTag(node: JSDocReturnTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression | undefined, comment: string | NodeArray | undefined): JSDocReturnTag; + createJSDocThisTag(tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | NodeArray): JSDocThisTag; + updateJSDocThisTag(node: JSDocThisTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression | undefined, comment: string | NodeArray | undefined): JSDocThisTag; + createJSDocEnumTag(tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | NodeArray): JSDocEnumTag; + updateJSDocEnumTag(node: JSDocEnumTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment: string | NodeArray | undefined): JSDocEnumTag; + createJSDocCallbackTag(tagName: Identifier | undefined, typeExpression: JSDocSignature, fullName?: Identifier | JSDocNamespaceDeclaration, comment?: string | NodeArray): JSDocCallbackTag; + updateJSDocCallbackTag(node: JSDocCallbackTag, tagName: Identifier | undefined, typeExpression: JSDocSignature, fullName: Identifier | JSDocNamespaceDeclaration | undefined, comment: string | NodeArray | undefined): JSDocCallbackTag; + createJSDocAugmentsTag(tagName: Identifier | undefined, className: JSDocAugmentsTag["class"], comment?: string | NodeArray): JSDocAugmentsTag; + updateJSDocAugmentsTag(node: JSDocAugmentsTag, tagName: Identifier | undefined, className: JSDocAugmentsTag["class"], comment: string | NodeArray | undefined): JSDocAugmentsTag; + createJSDocImplementsTag(tagName: Identifier | undefined, className: JSDocImplementsTag["class"], comment?: string | NodeArray): JSDocImplementsTag; + updateJSDocImplementsTag(node: JSDocImplementsTag, tagName: Identifier | undefined, className: JSDocImplementsTag["class"], comment: string | NodeArray | undefined): JSDocImplementsTag; + createJSDocAuthorTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocAuthorTag; + updateJSDocAuthorTag(node: JSDocAuthorTag, tagName: Identifier | undefined, comment: string | NodeArray | undefined): JSDocAuthorTag; + createJSDocClassTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocClassTag; + updateJSDocClassTag(node: JSDocClassTag, tagName: Identifier | undefined, comment: string | NodeArray | undefined): JSDocClassTag; + createJSDocPublicTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocPublicTag; + updateJSDocPublicTag(node: JSDocPublicTag, tagName: Identifier | undefined, comment: string | NodeArray | undefined): JSDocPublicTag; + createJSDocPrivateTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocPrivateTag; + updateJSDocPrivateTag(node: JSDocPrivateTag, tagName: Identifier | undefined, comment: string | NodeArray | undefined): JSDocPrivateTag; + createJSDocProtectedTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocProtectedTag; + updateJSDocProtectedTag(node: JSDocProtectedTag, tagName: Identifier | undefined, comment: string | NodeArray | undefined): JSDocProtectedTag; + createJSDocReadonlyTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocReadonlyTag; + updateJSDocReadonlyTag(node: JSDocReadonlyTag, tagName: Identifier | undefined, comment: string | NodeArray | undefined): JSDocReadonlyTag; + createJSDocUnknownTag(tagName: Identifier, comment?: string | NodeArray): JSDocUnknownTag; + updateJSDocUnknownTag(node: JSDocUnknownTag, tagName: Identifier, comment: string | NodeArray | undefined): JSDocUnknownTag; + createJSDocDeprecatedTag(tagName: Identifier, comment?: string | NodeArray): JSDocDeprecatedTag; + updateJSDocDeprecatedTag(node: JSDocDeprecatedTag, tagName: Identifier, comment?: string | NodeArray): JSDocDeprecatedTag; + createJSDocOverrideTag(tagName: Identifier, comment?: string | NodeArray): JSDocOverrideTag; + updateJSDocOverrideTag(node: JSDocOverrideTag, tagName: Identifier, comment?: string | NodeArray): JSDocOverrideTag; + createJSDocText(text: string): JSDocText; + updateJSDocText(node: JSDocText, text: string): JSDocText; + createJSDocComment(comment?: string | NodeArray | undefined, tags?: readonly JSDocTag[] | undefined): JSDoc; + updateJSDocComment(node: JSDoc, comment: string | NodeArray | undefined, tags: readonly JSDocTag[] | undefined): JSDoc; createJsxElement(openingElement: JsxOpeningElement, children: readonly JsxChild[], closingElement: JsxClosingElement): JsxElement; updateJsxElement(node: JsxElement, openingElement: JsxOpeningElement, children: readonly JsxChild[], closingElement: JsxClosingElement): JsxElement; createJsxSelfClosingElement(tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxSelfClosingElement; @@ -3750,12 +3827,12 @@ declare namespace ts { * }); * ``` */ - onEmitNode?(hint: EmitHint, node: Node | undefined, emitCallback: (hint: EmitHint, node: Node | undefined) => void): void; + onEmitNode?(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void): void; /** * A hook used to check if an emit notification is required for a node. * @param node The node to emit. */ - isEmitNotificationEnabled?(node: Node | undefined): boolean; + isEmitNotificationEnabled?(node: Node): boolean; /** * A hook used by the Printer to perform just-in-time substitution of a node. This is * primarily used by node transformations that need to substitute one node for another, @@ -3869,6 +3946,8 @@ declare namespace ts { readonly disableSuggestions?: boolean; readonly quotePreference?: "auto" | "double" | "single"; readonly includeCompletionsForModuleExports?: boolean; + readonly includeCompletionsForImportStatements?: boolean; + readonly includeCompletionsWithSnippetText?: boolean; readonly includeAutomaticOptionalChainCompletions?: boolean; readonly includeCompletionsWithInsertText?: boolean; readonly importModuleSpecifierPreference?: "shortest" | "project-relative" | "relative" | "non-relative"; @@ -3967,9 +4046,11 @@ declare namespace ts { scanJsxIdentifier(): SyntaxKind; scanJsxAttributeValue(): SyntaxKind; reScanJsxAttributeValue(): SyntaxKind; - reScanJsxToken(): JsxTokenSyntaxKind; + reScanJsxToken(allowMultilineJsxText?: boolean): JsxTokenSyntaxKind; reScanLessThanToken(): SyntaxKind; + reScanHashToken(): SyntaxKind; reScanQuestionToken(): SyntaxKind; + reScanInvalidIdentifier(): SyntaxKind; scanJsxToken(): JsxTokenSyntaxKind; scanJsDocToken(): JSDocSyntaxKind; scan(): SyntaxKind; @@ -4101,7 +4182,7 @@ declare namespace ts { function idText(identifierOrPrivateName: Identifier | PrivateIdentifier): string; function symbolName(symbol: Symbol): string; function getNameOfJSDocTypedef(declaration: JSDocTypedefTag): Identifier | PrivateIdentifier | undefined; - function getNameOfDeclaration(declaration: Declaration | Expression): DeclarationName | undefined; + function getNameOfDeclaration(declaration: Declaration | Expression | undefined): DeclarationName | undefined; /** * Gets the JSDoc parameter tags for the node if present. * @@ -4147,6 +4228,7 @@ declare namespace ts { function getJSDocProtectedTag(node: Node): JSDocProtectedTag | undefined; /** Gets the JSDoc protected tag for the node if present */ function getJSDocReadonlyTag(node: Node): JSDocReadonlyTag | undefined; + function getJSDocOverrideTagNoCache(node: Node): JSDocOverrideTag | undefined; /** Gets the JSDoc deprecated tag for the node if present */ function getJSDocDeprecatedTag(node: Node): JSDocDeprecatedTag | undefined; /** Gets the JSDoc enum tag for the node if present */ @@ -4184,13 +4266,15 @@ declare namespace ts { function getAllJSDocTags(node: Node, predicate: (tag: JSDocTag) => tag is T): readonly T[]; /** Gets all JSDoc tags of a specified kind */ function getAllJSDocTagsOfKind(node: Node, kind: SyntaxKind): readonly JSDocTag[]; + /** Gets the text of a jsdoc comment, flattening links to their text. */ + function getTextOfJSDocComment(comment?: string | NodeArray): string | undefined; /** * Gets the effective type parameters. If the node was parsed in a * JavaScript file, gets the type parameters from the `@template` tag from JSDoc. */ function getEffectiveTypeParameterDeclarations(node: DeclarationWithTypeParameters): readonly TypeParameterDeclaration[]; function getEffectiveConstraintOfTypeParameter(node: TypeParameterDeclaration): TypeNode | undefined; - function isIdentifierOrPrivateIdentifier(node: Node): node is Identifier | PrivateIdentifier; + function isMemberName(node: Node): node is MemberName; function isPropertyAccessChain(node: Node): node is PropertyAccessChain; function isElementAccessChain(node: Node): node is ElementAccessChain; function isCallChain(node: Node): node is CallChain; @@ -4205,6 +4289,12 @@ declare namespace ts { function isUnparsedTextLike(node: Node): node is UnparsedTextLike; function isUnparsedNode(node: Node): node is UnparsedNode; function isJSDocPropertyLikeTag(node: Node): node is JSDocPropertyLikeTag; + /** + * True if kind is of some token syntax kind. + * For example, this is true for an IfKeyword but not for an IfStatement. + * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. + */ + function isTokenKind(kind: SyntaxKind): boolean; /** * True if node is of some token syntax kind. * For example, this is true for an IfKeyword but not for an IfStatement. @@ -4221,7 +4311,7 @@ declare namespace ts { function isEntityName(node: Node): node is EntityName; function isPropertyName(node: Node): node is PropertyName; function isBindingName(node: Node): node is BindingName; - function isFunctionLike(node: Node): node is SignatureDeclaration; + function isFunctionLike(node: Node | undefined): node is SignatureDeclaration; function isClassElement(node: Node): node is ClassElement; function isClassLike(node: Node): node is ClassLikeDeclaration; function isAccessor(node: Node): node is AccessorDeclaration; @@ -4252,6 +4342,7 @@ declare namespace ts { function hasOnlyExpressionInitializer(node: Node): node is HasExpressionInitializer; function isObjectLiteralElement(node: Node): node is ObjectLiteralElement; function isStringLiteralLike(node: Node): node is StringLiteralLike; + function isJSDocLinkLike(node: Node): node is JSDocLink | JSDocLinkCode | JSDocLinkPlain; } declare namespace ts { const factory: NodeFactory; @@ -4347,10 +4438,14 @@ declare namespace ts { function isTemplateHead(node: Node): node is TemplateHead; function isTemplateMiddle(node: Node): node is TemplateMiddle; function isTemplateTail(node: Node): node is TemplateTail; + function isDotDotDotToken(node: Node): node is DotDotDotToken; + function isPlusToken(node: Node): node is PlusToken; + function isMinusToken(node: Node): node is MinusToken; + function isAsteriskToken(node: Node): node is AsteriskToken; function isIdentifier(node: Node): node is Identifier; + function isPrivateIdentifier(node: Node): node is PrivateIdentifier; function isQualifiedName(node: Node): node is QualifiedName; function isComputedPropertyName(node: Node): node is ComputedPropertyName; - function isPrivateIdentifier(node: Node): node is PrivateIdentifier; function isTypeParameterDeclaration(node: Node): node is TypeParameterDeclaration; function isParameter(node: Node): node is ParameterDeclaration; function isDecorator(node: Node): node is Decorator; @@ -4493,6 +4588,10 @@ declare namespace ts { function isUnparsedSource(node: Node): node is UnparsedSource; function isJSDocTypeExpression(node: Node): node is JSDocTypeExpression; function isJSDocNameReference(node: Node): node is JSDocNameReference; + function isJSDocMemberName(node: Node): node is JSDocMemberName; + function isJSDocLink(node: Node): node is JSDocLink; + function isJSDocLinkCode(node: Node): node is JSDocLinkCode; + function isJSDocLinkPlain(node: Node): node is JSDocLinkPlain; function isJSDocAllType(node: Node): node is JSDocAllType; function isJSDocUnknownType(node: Node): node is JSDocUnknownType; function isJSDocNullableType(node: Node): node is JSDocNullableType; @@ -4512,6 +4611,7 @@ declare namespace ts { function isJSDocPrivateTag(node: Node): node is JSDocPrivateTag; function isJSDocProtectedTag(node: Node): node is JSDocProtectedTag; function isJSDocReadonlyTag(node: Node): node is JSDocReadonlyTag; + function isJSDocOverrideTag(node: Node): node is JSDocOverrideTag; function isJSDocDeprecatedTag(node: Node): node is JSDocDeprecatedTag; function isJSDocSeeTag(node: Node): node is JSDocSeeTag; function isJSDocEnumTag(node: Node): node is JSDocEnumTag; @@ -4576,7 +4676,7 @@ declare namespace ts { /** * Reads the config file, reports errors if any and exits if the config file cannot be found */ - export function getParsedCommandLineOfConfigFile(configFileName: string, optionsToExtend: CompilerOptions, host: ParseConfigFileHost, extendedConfigCache?: Map, watchOptionsToExtend?: WatchOptions, extraFileExtensions?: readonly FileExtensionInfo[]): ParsedCommandLine | undefined; + export function getParsedCommandLineOfConfigFile(configFileName: string, optionsToExtend: CompilerOptions | undefined, host: ParseConfigFileHost, extendedConfigCache?: Map, watchOptionsToExtend?: WatchOptions, extraFileExtensions?: readonly FileExtensionInfo[]): ParsedCommandLine | undefined; /** * Read tsconfig.json file * @param fileName The path to the config file @@ -4644,13 +4744,13 @@ declare namespace ts { export {}; } declare namespace ts { - function getEffectiveTypeRoots(options: CompilerOptions, host: GetEffectiveTypeRootsHost): string[] | undefined; + export function getEffectiveTypeRoots(options: CompilerOptions, host: GetEffectiveTypeRootsHost): string[] | undefined; /** * @param {string | undefined} containingFile - file that contains type reference directive, can be undefined if containing file is unknown. * This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups * is assumed to be the same as root directory of the project. */ - function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string | undefined, options: CompilerOptions, host: ModuleResolutionHost, redirectedReference?: ResolvedProjectReference): ResolvedTypeReferenceDirectiveWithFailedLookupLocations; + export function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string | undefined, options: CompilerOptions, host: ModuleResolutionHost, redirectedReference?: ResolvedProjectReference, cache?: TypeReferenceDirectiveResolutionCache): ResolvedTypeReferenceDirectiveWithFailedLookupLocations; /** * Given a set of options, returns the set of type directive names * that should be included for this program automatically. @@ -4659,30 +4759,46 @@ declare namespace ts { * More type directives might appear in the program later as a result of loading actual source files; * this list is only the set of defaults that are implicitly included. */ - function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[]; + export function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[]; + export interface TypeReferenceDirectiveResolutionCache extends PerDirectoryResolutionCache, PackageJsonInfoCache { + } /** - * Cached module resolutions per containing directory. + * Cached resolutions per containing directory. * This assumes that any module id will have the same resolution for sibling files located in the same folder. */ - interface ModuleResolutionCache extends NonRelativeModuleNameResolutionCache { - getOrCreateCacheForDirectory(directoryName: string, redirectedReference?: ResolvedProjectReference): Map; + export interface PerDirectoryResolutionCache { + getOrCreateCacheForDirectory(directoryName: string, redirectedReference?: ResolvedProjectReference): Map; + clear(): void; + /** + * Updates with the current compilerOptions the cache will operate with. + * This updates the redirects map as well if needed so module resolutions are cached if they can across the projects + */ + update(options: CompilerOptions): void; + } + export interface ModuleResolutionCache extends PerDirectoryResolutionCache, NonRelativeModuleNameResolutionCache, PackageJsonInfoCache { + getPackageJsonInfoCache(): PackageJsonInfoCache; } /** * Stored map from non-relative module name to a table: directory -> result of module lookup in this directory * We support only non-relative module names because resolution of relative module names is usually more deterministic and thus less expensive. */ - interface NonRelativeModuleNameResolutionCache { + export interface NonRelativeModuleNameResolutionCache extends PackageJsonInfoCache { getOrCreateCacheForModuleName(nonRelativeModuleName: string, redirectedReference?: ResolvedProjectReference): PerModuleNameCache; } - interface PerModuleNameCache { + export interface PackageJsonInfoCache { + clear(): void; + } + export interface PerModuleNameCache { get(directory: string): ResolvedModuleWithFailedLookupLocations | undefined; set(directory: string, result: ResolvedModuleWithFailedLookupLocations): void; } - function createModuleResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string, options?: CompilerOptions): ModuleResolutionCache; - function resolveModuleNameFromCache(moduleName: string, containingFile: string, cache: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations | undefined; - function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; - function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; - function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; + export function createModuleResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string, options?: CompilerOptions): ModuleResolutionCache; + export function createTypeReferenceDirectiveResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string, options?: CompilerOptions, packageJsonInfoCache?: PackageJsonInfoCache): TypeReferenceDirectiveResolutionCache; + export function resolveModuleNameFromCache(moduleName: string, containingFile: string, cache: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations | undefined; + export function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; + export function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; + export function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; + export {}; } declare namespace ts { /** @@ -4749,6 +4865,10 @@ declare namespace ts { * environment and merging hoisted declarations upon completion. */ function visitFunctionBody(node: ConciseBody, visitor: Visitor, context: TransformationContext): ConciseBody; + /** + * Visits an iteration body, adding any block-scoped variables required by the transformation. + */ + function visitIterationBody(body: Statement, visitor: Visitor, context: TransformationContext): Statement; /** * Visits each child of a Node using the supplied visitor, possibly returning a new Node of the same kind in its place. * @@ -5037,6 +5157,8 @@ declare namespace ts { interface WatchCompilerHost extends ProgramHost, WatchHost { /** Instead of using output d.ts file from project reference, use its source file */ useSourceOfProjectReferenceRedirect?(): boolean; + /** If provided, use this method to get parsed command lines for referenced projects */ + getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined; /** If provided, callback to invoke after every new program creation */ afterProgramCreate?(program: T): void; } @@ -5132,9 +5254,9 @@ declare namespace ts { interface SolutionBuilderWithWatchHost extends SolutionBuilderHostBase, WatchHost { } interface SolutionBuilder { - build(project?: string, cancellationToken?: CancellationToken): ExitStatus; + build(project?: string, cancellationToken?: CancellationToken, writeFile?: WriteFileCallback, getCustomTransformers?: (project: string) => CustomTransformers): ExitStatus; clean(project?: string): ExitStatus; - buildReferences(project: string, cancellationToken?: CancellationToken): ExitStatus; + buildReferences(project: string, cancellationToken?: CancellationToken, writeFile?: WriteFileCallback, getCustomTransformers?: (project: string) => CustomTransformers): ExitStatus; cleanReferences(project?: string): ExitStatus; getNextInvalidatedProject(cancellationToken?: CancellationToken): InvalidatedProject | undefined; } @@ -5292,7 +5414,7 @@ declare namespace ts { getName(): string; getDeclarations(): Declaration[] | undefined; getDocumentationComment(typeChecker: TypeChecker | undefined): SymbolDisplayPart[]; - getJsDocTags(): JSDocTagInfo[]; + getJsDocTags(checker?: TypeChecker): JSDocTagInfo[]; } interface Type { getFlags(): TypeFlags; @@ -5423,6 +5545,7 @@ declare namespace ts { isKnownTypesPackageName?(name: string): boolean; installPackage?(options: InstallPackageOptions): Promise; writeFile?(fileName: string, content: string): void; + getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined; } type WithMetadata = T & { metadata?: unknown; @@ -5512,12 +5635,13 @@ declare namespace ts { * * @param fileName The path to the file * @param position A zero based index of the character where you want the entries - * @param entryName The name from an existing completion which came from `getCompletionsAtPosition` + * @param entryName The `name` from an existing completion which came from `getCompletionsAtPosition` * @param formatOptions How should code samples in the completions be formatted, can be undefined for backwards compatibility - * @param source Source code for the current file, can be undefined for backwards compatibility + * @param source `source` property from the completion entry * @param preferences User settings, can be undefined for backwards compatibility + * @param data `data` property from the completion entry */ - getCompletionEntryDetails(fileName: string, position: number, entryName: string, formatOptions: FormatCodeOptions | FormatCodeSettings | undefined, source: string | undefined, preferences: UserPreferences | undefined): CompletionEntryDetails | undefined; + getCompletionEntryDetails(fileName: string, position: number, entryName: string, formatOptions: FormatCodeOptions | FormatCodeSettings | undefined, source: string | undefined, preferences: UserPreferences | undefined, data: CompletionEntryData | undefined): CompletionEntryDetails | undefined; getCompletionEntrySymbol(fileName: string, position: number, name: string, source: string | undefined): Symbol | undefined; /** * Gets semantic information about the identifier at a particular position in a @@ -5556,7 +5680,7 @@ declare namespace ts { getFormattingEditsForRange(fileName: string, start: number, end: number, options: FormatCodeOptions | FormatCodeSettings): TextChange[]; getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions | FormatCodeSettings): TextChange[]; getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions | FormatCodeSettings): TextChange[]; - getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion | undefined; + getDocCommentTemplateAtPosition(fileName: string, position: number, options?: DocCommentTemplateOptions): TextInsertion | undefined; isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean; /** * This will return a defined result if the position is after the `>` of the opening tag, or somewhere in the text, of a JSXElement with no closing tag. @@ -5578,7 +5702,7 @@ declare namespace ts { applyCodeActionCommand(fileName: string, action: CodeActionCommand | CodeActionCommand[]): Promise; getApplicableRefactors(fileName: string, positionOrRange: number | TextRange, preferences: UserPreferences | undefined, triggerReason?: RefactorTriggerReason, kind?: string): ApplicableRefactorInfo[]; getEditsForRefactor(fileName: string, formatOptions: FormatCodeSettings, positionOrRange: number | TextRange, refactorName: string, actionName: string, preferences: UserPreferences | undefined): RefactorEditInfo | undefined; - organizeImports(scope: OrganizeImportsScope, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): readonly FileTextChanges[]; + organizeImports(args: OrganizeImportsArgs, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): readonly FileTextChanges[]; getEditsForFileRename(oldFilePath: string, newFilePath: string, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): readonly FileTextChanges[]; getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean, forceDtsEmit?: boolean): EmitOutput; getProgram(): Program | undefined; @@ -5595,8 +5719,10 @@ declare namespace ts { type: "file"; fileName: string; } - type OrganizeImportsScope = CombinedCodeFixScope; - type CompletionsTriggerCharacter = "." | '"' | "'" | "`" | "/" | "@" | "<" | "#"; + interface OrganizeImportsArgs extends CombinedCodeFixScope { + skipDestructiveCodeActions?: boolean; + } + type CompletionsTriggerCharacter = "." | '"' | "'" | "`" | "/" | "@" | "<" | "#" | " "; interface GetCompletionsAtPositionOptions extends UserPreferences { /** * If the editor is asking for completions because a certain character was typed @@ -5948,6 +6074,7 @@ declare namespace ts { name: string; containerKind: ScriptElementKind; containerName: string; + unverified?: boolean; } interface DefinitionInfoAndBoundSpan { definitions?: readonly DefinitionInfo[]; @@ -5982,15 +6109,21 @@ declare namespace ts { typeParameterName = 18, enumMemberName = 19, functionName = 20, - regularExpressionLiteral = 21 + regularExpressionLiteral = 21, + link = 22, + linkName = 23, + linkText = 24 } interface SymbolDisplayPart { text: string; kind: string; } + interface JSDocLinkDisplayPart extends SymbolDisplayPart { + target: DocumentSpan; + } interface JSDocTagInfo { name: string; - text?: string; + text?: SymbolDisplayPart[]; } interface QuickInfo { kind: ScriptElementKind; @@ -6021,11 +6154,15 @@ declare namespace ts { interface RenameInfoOptions { readonly allowRenameOfImportPath?: boolean; } + interface DocCommentTemplateOptions { + readonly generateReturnInDocTemplate?: boolean; + } interface SignatureHelpParameter { name: string; documentation: SymbolDisplayPart[]; displayParts: SymbolDisplayPart[]; isOptional: boolean; + isRest?: boolean; } interface SelectionRange { textSpan: TextSpan; @@ -6071,14 +6208,36 @@ declare namespace ts { * true when the current location also allows for a new identifier */ isNewIdentifierLocation: boolean; + /** + * Indicates to client to continue requesting completions on subsequent keystrokes. + */ + isIncomplete?: true; entries: CompletionEntry[]; } + interface CompletionEntryData { + /** The file name declaring the export's module symbol, if it was an external module */ + fileName?: string; + /** The module name (with quotes stripped) of the export's module symbol, if it was an ambient module */ + ambientModuleName?: string; + /** True if the export was found in the package.json AutoImportProvider */ + isPackageJsonImport?: true; + /** + * The name of the property or export in the module's symbol table. Differs from the completion name + * in the case of InternalSymbolName.ExportEquals and InternalSymbolName.Default. + */ + exportName: string; + /** + * Set for auto imports with eagerly resolved module specifiers. + */ + moduleSpecifier?: string; + } interface CompletionEntry { name: string; kind: ScriptElementKind; kindModifiers?: string; sortText: string; insertText?: string; + isSnippet?: true; /** * An optional span that indicates the text to be replaced by this completion item. * If present, this span should be used instead of the default one. @@ -6087,9 +6246,20 @@ declare namespace ts { replacementSpan?: TextSpan; hasAction?: true; source?: string; + sourceDisplay?: SymbolDisplayPart[]; isRecommended?: true; isFromUncheckedFile?: true; isPackageJsonImport?: true; + isImportStatementCompletion?: true; + /** + * A property to be sent back to TS Server in the CompletionDetailsRequest, along with `name`, + * that allows TS Server to look up the symbol represented by the completion item, disambiguating + * items with the same name. Currently only defined for auto-import completions, but the type is + * `unknown` in the protocol, so it can be changed as needed to support other kinds of completions. + * The presence of this property should generally not be used to assume that this completion entry + * is an auto-import. + */ + data?: CompletionEntryData; } interface CompletionEntryDetails { name: string; @@ -6099,7 +6269,9 @@ declare namespace ts { documentation?: SymbolDisplayPart[]; tags?: JSDocTagInfo[]; codeActions?: CodeAction[]; + /** @deprecated Use `sourceDisplay` instead. */ source?: SymbolDisplayPart[]; + sourceDisplay?: SymbolDisplayPart[]; } interface OutliningSpan { /** The span of the document to actually collapse. */ @@ -6253,7 +6425,13 @@ declare namespace ts { */ jsxAttribute = "JSX attribute", /** String literal */ - string = "string" + string = "string", + /** Jsdoc @link: in `{@link C link text}`, the before and after text "{@link " and "}" */ + link = "link", + /** Jsdoc @link: in `{@link C link text}`, the entity name "C" */ + linkName = "link name", + /** Jsdoc @link: in `{@link C link text}`, the link text "link text" */ + linkText = "link text" } enum ScriptElementKindModifier { none = "", @@ -6394,8 +6572,23 @@ declare namespace ts { * @param fileName The name of the file to be released * @param compilationSettings The compilation settings used to acquire the file */ + /**@deprecated pass scriptKind for correctness */ releaseDocument(fileName: string, compilationSettings: CompilerOptions): void; + /** + * Informs the DocumentRegistry that a file is not needed any longer. + * + * Note: It is not allowed to call release on a SourceFile that was not acquired from + * this registry originally. + * + * @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 + */ + releaseDocument(fileName: string, compilationSettings: CompilerOptions, scriptKind: ScriptKind): void; + /** + * @deprecated pass scriptKind for correctness */ releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey): void; + releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey, scriptKind: ScriptKind): void; reportStats(): string; } type DocumentRegistryBucketKey = string & { @@ -7031,6 +7224,7 @@ declare namespace ts.server.protocol { type OrganizeImportsScope = GetCombinedCodeFixScope; interface OrganizeImportsRequestArgs { scope: OrganizeImportsScope; + skipDestructiveCodeActions?: boolean; } interface OrganizeImportsResponse extends Response { body: readonly FileCodeEdits[]; @@ -7133,6 +7327,41 @@ declare namespace ts.server.protocol { */ body?: string[]; } + /** + * A request to get encoded semantic classifications for a span in the file + */ + interface EncodedSemanticClassificationsRequest extends FileRequest { + arguments: EncodedSemanticClassificationsRequestArgs; + } + /** + * Arguments for EncodedSemanticClassificationsRequest request. + */ + interface EncodedSemanticClassificationsRequestArgs extends FileRequestArgs { + /** + * Start position of the span. + */ + start: number; + /** + * Length of the span. + */ + length: number; + /** + * Optional parameter for the semantic highlighting response, if absent it + * defaults to "original". + */ + format?: "original" | "2020"; + } + /** The response for a EncodedSemanticClassificationsRequest */ + interface EncodedSemanticClassificationsResponse extends Response { + body?: EncodedSemanticClassificationsResponseBody; + } + /** + * Implementation response message. Gives series of text spans depending on the format ar. + */ + interface EncodedSemanticClassificationsResponseBody { + endOfLineState: EndOfLineState; + spans: number[]; + } /** * Arguments in document highlight request; include: filesToSearch, file, * line, offset. @@ -7202,21 +7431,36 @@ declare namespace ts.server.protocol { */ file: string; } + interface JSDocTagInfo { + /** Name of the JSDoc tag */ + name: string; + /** + * Comment text after the JSDoc tag -- the text after the tag name until the next tag or end of comment + * Display parts when UserPreferences.displayPartsForJSDoc is true, flattened to string otherwise. + */ + text?: string | SymbolDisplayPart[]; + } interface TextSpanWithContext extends TextSpan { contextStart?: Location; contextEnd?: Location; } interface FileSpanWithContext extends FileSpan, TextSpanWithContext { } + interface DefinitionInfo extends FileSpanWithContext { + /** + * When true, the file may or may not exist. + */ + unverified?: boolean; + } interface DefinitionInfoAndBoundSpan { - definitions: readonly FileSpanWithContext[]; + definitions: readonly DefinitionInfo[]; textSpan: TextSpan; } /** * Definition response message. Gives text range for definition. */ interface DefinitionResponse extends Response { - body?: FileSpanWithContext[]; + body?: DefinitionInfo[]; } interface DefinitionInfoAndBoundSpanResponse extends Response { body?: DefinitionInfoAndBoundSpan; @@ -7600,18 +7844,21 @@ declare namespace ts.server.protocol { FixedPollingInterval = "FixedPollingInterval", PriorityPollingInterval = "PriorityPollingInterval", DynamicPriorityPolling = "DynamicPriorityPolling", + FixedChunkSizePolling = "FixedChunkSizePolling", UseFsEvents = "UseFsEvents", UseFsEventsOnParentDirectory = "UseFsEventsOnParentDirectory" } enum WatchDirectoryKind { UseFsEvents = "UseFsEvents", FixedPollingInterval = "FixedPollingInterval", - DynamicPriorityPolling = "DynamicPriorityPolling" + DynamicPriorityPolling = "DynamicPriorityPolling", + FixedChunkSizePolling = "FixedChunkSizePolling" } enum PollingWatchKind { FixedInterval = "FixedInterval", PriorityInterval = "PriorityInterval", - DynamicPriority = "DynamicPriority" + DynamicPriority = "DynamicPriority", + FixedChunkSize = "FixedChunkSize" } interface WatchOptions { watchFile?: WatchFileKind | ts.WatchFileKind; @@ -7913,6 +8160,7 @@ declare namespace ts.server.protocol { */ interface QuickInfoRequest extends FileLocationRequest { command: CommandTypes.Quickinfo; + arguments: FileLocationRequestArgs; } /** * Body of QuickInfoResponse. @@ -7940,8 +8188,9 @@ declare namespace ts.server.protocol { displayString: string; /** * Documentation associated with symbol. + * Display parts when UserPreferences.displayPartsForJSDoc is true, flattened to string otherwise. */ - documentation: string; + documentation: string | SymbolDisplayPart[]; /** * JSDoc tags associated with symbol. */ @@ -8062,7 +8311,7 @@ declare namespace ts.server.protocol { command: CommandTypes.Formatonkey; arguments: FormatOnKeyRequestArgs; } - type CompletionsTriggerCharacter = "." | '"' | "'" | "`" | "/" | "@" | "<" | "#"; + type CompletionsTriggerCharacter = "." | '"' | "'" | "`" | "/" | "@" | "<" | "#" | " "; /** * Arguments for completions messages. */ @@ -8107,6 +8356,7 @@ declare namespace ts.server.protocol { interface CompletionEntryIdentifier { name: string; source?: string; + data?: unknown; } /** * Completion entry details request; value of command field is @@ -8131,6 +8381,11 @@ declare namespace ts.server.protocol { */ kind: string; } + /** A part of a symbol description that links from a jsdoc @link tag to a declaration */ + interface JSDocLinkDisplayPart extends SymbolDisplayPart { + /** The location of the declaration that the @link tag links to. */ + target: FileSpan; + } /** * An item found in a completion response. */ @@ -8158,6 +8413,10 @@ declare namespace ts.server.protocol { * coupled with `replacementSpan` to replace a dotted access with a bracket access. */ insertText?: string; + /** + * `insertText` should be interpreted as a snippet if true. + */ + isSnippet?: true; /** * An optional span that indicates the text to be replaced by this completion item. * If present, this span should be used instead of the default one. @@ -8173,6 +8432,10 @@ declare namespace ts.server.protocol { * Identifier (not necessarily human-readable) identifying where this completion came from. */ source?: string; + /** + * Human-readable description of the `source`. + */ + sourceDisplay?: SymbolDisplayPart[]; /** * If true, this completion should be highlighted as recommended. There will only be one of these. * This will be set when we know the user should write an expression with a certain type and that type is an enum or constructable class. @@ -8186,9 +8449,20 @@ declare namespace ts.server.protocol { isFromUncheckedFile?: true; /** * If true, this completion was for an auto-import of a module not yet in the program, but listed - * in the project package.json. + * in the project package.json. Used for telemetry reporting. */ isPackageJsonImport?: true; + /** + * If true, this completion was an auto-import-style completion of an import statement (i.e., the + * module specifier was inserted along with the imported identifier). Used for telemetry reporting. + */ + isImportStatementCompletion?: true; + /** + * A property to be sent back to TS Server in the CompletionDetailsRequest, along with `name`, + * that allows TS Server to look up the symbol represented by the completion item, disambiguating + * items with the same name. + */ + data?: unknown; } /** * Additional completion entry details, available on demand @@ -8223,9 +8497,13 @@ declare namespace ts.server.protocol { */ codeActions?: CodeAction[]; /** - * Human-readable description of the `source` from the CompletionEntry. + * @deprecated Use `sourceDisplay` instead. */ source?: SymbolDisplayPart[]; + /** + * Human-readable description of the `source` from the CompletionEntry. + */ + sourceDisplay?: SymbolDisplayPart[]; } /** @deprecated Prefer CompletionInfoResponse, which supports several top-level fields in addition to the array of entries. */ interface CompletionsResponse extends Response { @@ -8244,6 +8522,7 @@ declare namespace ts.server.protocol { * must be used to commit that completion entry. */ readonly optionalReplacementSpan?: TextSpan; + readonly isIncomplete?: boolean; readonly entries: readonly CompletionEntry[]; } interface CompletionDetailsResponse extends Response { @@ -9026,6 +9305,15 @@ declare namespace ts.server.protocol { * This affects lone identifier completions but not completions on the right hand side of `obj.`. */ readonly includeCompletionsForModuleExports?: boolean; + /** + * Enables auto-import-style completions on partially-typed import statements. E.g., allows + * `import write|` to be completed to `import { writeFile } from "fs"`. + */ + readonly includeCompletionsForImportStatements?: boolean; + /** + * Allows completions to be formatted with snippet text, indicated by `CompletionItem["isSnippet"]`. + */ + readonly includeCompletionsWithSnippetText?: boolean; /** * If enabled, the completion list will include completions with invalid identifier names. * For those entries, The `insertText` and `replacementSpan` properties will be set to change from `.x` property access to `["x"]`. @@ -9046,6 +9334,8 @@ declare namespace ts.server.protocol { readonly provideRefactorNotApplicableReason?: boolean; readonly allowRenameOfImportPath?: boolean; readonly includePackageJsonAutoImports?: "auto" | "on" | "off"; + readonly displayPartsForJSDoc?: boolean; + readonly generateReturnInDocTemplate?: boolean; } interface CompilerOptions { allowJs?: boolean; @@ -9153,8 +9443,36 @@ declare namespace ts.server.protocol { ES2018 = "ES2018", ES2019 = "ES2019", ES2020 = "ES2020", + ES2021 = "ES2021", ESNext = "ESNext" } + enum ClassificationType { + comment = 1, + identifier = 2, + keyword = 3, + numericLiteral = 4, + operator = 5, + stringLiteral = 6, + regularExpressionLiteral = 7, + whiteSpace = 8, + text = 9, + punctuation = 10, + className = 11, + enumName = 12, + interfaceName = 13, + moduleName = 14, + typeParameterName = 15, + typeAliasName = 16, + parameterName = 17, + docCommentTagName = 18, + jsxOpenTagName = 19, + jsxCloseTagName = 20, + jsxSelfClosingTagName = 21, + jsxAttribute = 22, + jsxText = 23, + jsxAttributeStringLiteralValue = 24, + bigintLiteral = 25 + } } declare namespace ts.server { interface ScriptInfoVersion { @@ -9267,7 +9585,6 @@ declare namespace ts.server { private missingFilesMap; private generatedFilesMap; private plugins; - private lastFileExceededProgramSize; protected languageService: LanguageService; languageServiceEnabled: boolean; readonly trace?: (s: string) => void; @@ -9402,7 +9719,6 @@ declare namespace ts.server { * the file and its imports/references are put into an InferredProject. */ class InferredProject extends Project { - private static readonly newName; private _isJsInferredProject; toggleJsInferredProject(isJsInferredProject: boolean): void; setCompilerOptions(options?: CompilerOptions): void; @@ -9416,7 +9732,6 @@ declare namespace ts.server { } class AutoImportProviderProject extends Project { private hostProject; - private static readonly newName; private rootFileNames; isOrphan(): boolean; updateGraph(): boolean; @@ -9424,10 +9739,8 @@ declare namespace ts.server { markAsDirty(): void; getScriptFileNames(): string[]; getLanguageService(): never; - markAutoImportProviderAsDirty(): never; getModuleResolutionHostForAutoImportProvider(): never; getProjectReferences(): readonly ProjectReference[] | undefined; - useSourceOfProjectReferenceRedirect(): boolean; getTypeAcquisition(): TypeAcquisition; } /** @@ -9436,7 +9749,6 @@ declare namespace ts.server { * Otherwise it will create an InferredProject. */ class ConfiguredProject extends Project { - private directoriesWatchedForWildcards; readonly canonicalConfigFilePath: NormalizedPath; /** Ref count to the project when opened from external project */ private externalProjectRefCount; @@ -9683,14 +9995,6 @@ declare namespace ts.server { * Project size for configured or external projects */ private readonly projectToSizeMap; - /** - * This is a map of config file paths existence that doesnt need query to disk - * - The entry can be present because there is inferred project that needs to watch addition of config file to directory - * In this case the exists could be true/false based on config file is present or not - * - Or it is present if we have configured project open with config file at that location - * In this case the exists property is always true - */ - private readonly configFileExistenceInfoCache; private readonly hostConfiguration; private safelist; private readonly legacySafelist; @@ -9746,12 +10050,6 @@ declare namespace ts.server { private delayUpdateSourceInfoProjects; private delayUpdateProjectsOfScriptInfoPath; private handleDeletedFile; - /** - * This is the callback function for the config file add/remove/change at any location - * that matters to open script info but doesnt have configured project open - * for the config file - */ - private onConfigFileChangeForOpenScriptInfo; private removeProject; private assignOrphanScriptInfosToInferredProject; /** @@ -9761,22 +10059,10 @@ declare namespace ts.server { private closeOpenFile; private deleteScriptInfo; private configFileExists; - private setConfigFileExistenceByNewConfiguredProject; /** * Returns true if the configFileExistenceInfo is needed/impacted by open files that are root of inferred project */ private configFileExistenceImpactsRootOfInferredProject; - private setConfigFileExistenceInfoByClosedConfiguredProject; - private logConfigFileWatchUpdate; - /** - * Create the watcher for the configFileExistenceInfo - */ - private createConfigFileWatcherOfConfigFileExistence; - /** - * Close the config file watcher in the cached ConfigFileExistenceInfo - * if there arent any open files that are root of inferred project - */ - private closeConfigFileWatcherOfConfigFileExistenceInfo; /** * This is called on file close, so that we stop watching the config file for this script info */ @@ -9842,12 +10128,11 @@ declare namespace ts.server { * This does not reload contents of open files from disk. But we could do that if needed */ reloadProjects(): void; - private delayReloadConfiguredProjectForFiles; /** * This function goes through all the openFiles and tries to file the config file for them. * If the config file is found and it refers to existing project, it reloads it either immediately * or schedules it for reload depending on delayReload option - * If the there is no existing project it just opens the configured project for the config file + * If there is no existing project it just opens the configured project for the config file * reloadForInfo provides a way to filter out files to reload configured project for */ private reloadConfiguredProjectForFiles; @@ -9993,6 +10278,9 @@ declare namespace ts.server { private mapDefinitionInfoLocations; private getDefinitionAndBoundSpan; private getEmitOutput; + private mapJSDocTagInfo; + private mapDisplayParts; + private mapSignatureHelpItems; private mapDefinitionInfo; private static mapToOriginalLocation; private toFileSpan; @@ -10131,7 +10419,7 @@ declare namespace ts { /** @deprecated Use `factory.createRegularExpressionLiteral` or the factory supplied by your transformation context instead. */ const createRegularExpressionLiteral: (text: string) => RegularExpressionLiteral; /** @deprecated Use `factory.createLoopVariable` or the factory supplied by your transformation context instead. */ - const createLoopVariable: () => Identifier; + const createLoopVariable: (reservedInNestedScopes?: boolean | undefined) => Identifier; /** @deprecated Use `factory.createUniqueName` or the factory supplied by your transformation context instead. */ const createUniqueName: (text: string, flags?: GeneratedIdentifierFlags | undefined) => Identifier; /** @deprecated Use `factory.createPrivateIdentifier` or the factory supplied by your transformation context instead. */ @@ -10303,13 +10591,13 @@ declare namespace ts { /** @deprecated Use `factory.updateObjectLiteralExpression` or the factory supplied by your transformation context instead. */ const updateObjectLiteral: (node: ObjectLiteralExpression, properties: readonly ObjectLiteralElementLike[]) => ObjectLiteralExpression; /** @deprecated Use `factory.createPropertyAccessExpression` or the factory supplied by your transformation context instead. */ - const createPropertyAccess: (expression: Expression, name: string | Identifier | PrivateIdentifier) => PropertyAccessExpression; + const createPropertyAccess: (expression: Expression, name: string | MemberName) => PropertyAccessExpression; /** @deprecated Use `factory.updatePropertyAccessExpression` or the factory supplied by your transformation context instead. */ - const updatePropertyAccess: (node: PropertyAccessExpression, expression: Expression, name: Identifier | PrivateIdentifier) => PropertyAccessExpression; + const updatePropertyAccess: (node: PropertyAccessExpression, expression: Expression, name: MemberName) => PropertyAccessExpression; /** @deprecated Use `factory.createPropertyAccessChain` or the factory supplied by your transformation context instead. */ - const createPropertyAccessChain: (expression: Expression, questionDotToken: QuestionDotToken | undefined, name: string | Identifier | PrivateIdentifier) => PropertyAccessChain; + const createPropertyAccessChain: (expression: Expression, questionDotToken: QuestionDotToken | undefined, name: string | MemberName) => PropertyAccessChain; /** @deprecated Use `factory.updatePropertyAccessChain` or the factory supplied by your transformation context instead. */ - const updatePropertyAccessChain: (node: PropertyAccessChain, expression: Expression, questionDotToken: QuestionDotToken | undefined, name: Identifier | PrivateIdentifier) => PropertyAccessChain; + const updatePropertyAccessChain: (node: PropertyAccessChain, expression: Expression, questionDotToken: QuestionDotToken | undefined, name: MemberName) => PropertyAccessChain; /** @deprecated Use `factory.createElementAccessExpression` or the factory supplied by your transformation context instead. */ const createElementAccess: (expression: Expression, index: number | Expression) => ElementAccessExpression; /** @deprecated Use `factory.updateElementAccessExpression` or the factory supplied by your transformation context instead. */ @@ -10579,51 +10867,51 @@ declare namespace ts { /** @deprecated Use `factory.createJSDocTypeExpression` or the factory supplied by your transformation context instead. */ const createJSDocTypeExpression: (type: TypeNode) => JSDocTypeExpression; /** @deprecated Use `factory.createJSDocTypeTag` or the factory supplied by your transformation context instead. */ - const createJSDocTypeTag: (tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | undefined) => JSDocTypeTag; + const createJSDocTypeTag: (tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | NodeArray | undefined) => JSDocTypeTag; /** @deprecated Use `factory.createJSDocReturnTag` or the factory supplied by your transformation context instead. */ - const createJSDocReturnTag: (tagName: Identifier | undefined, typeExpression?: JSDocTypeExpression | undefined, comment?: string | undefined) => JSDocReturnTag; + const createJSDocReturnTag: (tagName: Identifier | undefined, typeExpression?: JSDocTypeExpression | undefined, comment?: string | NodeArray | undefined) => JSDocReturnTag; /** @deprecated Use `factory.createJSDocThisTag` or the factory supplied by your transformation context instead. */ - const createJSDocThisTag: (tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | undefined) => JSDocThisTag; + const createJSDocThisTag: (tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | NodeArray | undefined) => JSDocThisTag; /** @deprecated Use `factory.createJSDocComment` or the factory supplied by your transformation context instead. */ - const createJSDocComment: (comment?: string | undefined, tags?: readonly JSDocTag[] | undefined) => JSDoc; + const createJSDocComment: (comment?: string | NodeArray | undefined, tags?: readonly JSDocTag[] | undefined) => JSDoc; /** @deprecated Use `factory.createJSDocParameterTag` or the factory supplied by your transformation context instead. */ - const createJSDocParameterTag: (tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression | undefined, isNameFirst?: boolean | undefined, comment?: string | undefined) => JSDocParameterTag; + const createJSDocParameterTag: (tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression | undefined, isNameFirst?: boolean | undefined, comment?: string | NodeArray | undefined) => JSDocParameterTag; /** @deprecated Use `factory.createJSDocClassTag` or the factory supplied by your transformation context instead. */ - const createJSDocClassTag: (tagName: Identifier | undefined, comment?: string | undefined) => JSDocClassTag; + const createJSDocClassTag: (tagName: Identifier | undefined, comment?: string | NodeArray | undefined) => JSDocClassTag; /** @deprecated Use `factory.createJSDocAugmentsTag` or the factory supplied by your transformation context instead. */ const createJSDocAugmentsTag: (tagName: Identifier | undefined, className: ExpressionWithTypeArguments & { readonly expression: Identifier | PropertyAccessEntityNameExpression; - }, comment?: string | undefined) => JSDocAugmentsTag; + }, comment?: string | NodeArray | undefined) => JSDocAugmentsTag; /** @deprecated Use `factory.createJSDocEnumTag` or the factory supplied by your transformation context instead. */ - const createJSDocEnumTag: (tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | undefined) => JSDocEnumTag; + const createJSDocEnumTag: (tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | NodeArray | undefined) => JSDocEnumTag; /** @deprecated Use `factory.createJSDocTemplateTag` or the factory supplied by your transformation context instead. */ - const createJSDocTemplateTag: (tagName: Identifier | undefined, constraint: JSDocTypeExpression | undefined, typeParameters: readonly TypeParameterDeclaration[], comment?: string | undefined) => JSDocTemplateTag; + const createJSDocTemplateTag: (tagName: Identifier | undefined, constraint: JSDocTypeExpression | undefined, typeParameters: readonly TypeParameterDeclaration[], comment?: string | NodeArray | undefined) => JSDocTemplateTag; /** @deprecated Use `factory.createJSDocTypedefTag` or the factory supplied by your transformation context instead. */ - const createJSDocTypedefTag: (tagName: Identifier | undefined, typeExpression?: JSDocTypeLiteral | JSDocTypeExpression | undefined, fullName?: Identifier | JSDocNamespaceDeclaration | undefined, comment?: string | undefined) => JSDocTypedefTag; + const createJSDocTypedefTag: (tagName: Identifier | undefined, typeExpression?: JSDocTypeLiteral | JSDocTypeExpression | undefined, fullName?: Identifier | JSDocNamespaceDeclaration | undefined, comment?: string | NodeArray | undefined) => JSDocTypedefTag; /** @deprecated Use `factory.createJSDocCallbackTag` or the factory supplied by your transformation context instead. */ - const createJSDocCallbackTag: (tagName: Identifier | undefined, typeExpression: JSDocSignature, fullName?: Identifier | JSDocNamespaceDeclaration | undefined, comment?: string | undefined) => JSDocCallbackTag; + const createJSDocCallbackTag: (tagName: Identifier | undefined, typeExpression: JSDocSignature, fullName?: Identifier | JSDocNamespaceDeclaration | undefined, comment?: string | NodeArray | undefined) => JSDocCallbackTag; /** @deprecated Use `factory.createJSDocSignature` or the factory supplied by your transformation context instead. */ const createJSDocSignature: (typeParameters: readonly JSDocTemplateTag[] | undefined, parameters: readonly JSDocParameterTag[], type?: JSDocReturnTag | undefined) => JSDocSignature; /** @deprecated Use `factory.createJSDocPropertyTag` or the factory supplied by your transformation context instead. */ - const createJSDocPropertyTag: (tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression | undefined, isNameFirst?: boolean | undefined, comment?: string | undefined) => JSDocPropertyTag; + const createJSDocPropertyTag: (tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression | undefined, isNameFirst?: boolean | undefined, comment?: string | NodeArray | undefined) => JSDocPropertyTag; /** @deprecated Use `factory.createJSDocTypeLiteral` or the factory supplied by your transformation context instead. */ const createJSDocTypeLiteral: (jsDocPropertyTags?: readonly JSDocPropertyLikeTag[] | undefined, isArrayType?: boolean | undefined) => JSDocTypeLiteral; /** @deprecated Use `factory.createJSDocImplementsTag` or the factory supplied by your transformation context instead. */ const createJSDocImplementsTag: (tagName: Identifier | undefined, className: ExpressionWithTypeArguments & { readonly expression: Identifier | PropertyAccessEntityNameExpression; - }, comment?: string | undefined) => JSDocImplementsTag; + }, comment?: string | NodeArray | undefined) => JSDocImplementsTag; /** @deprecated Use `factory.createJSDocAuthorTag` or the factory supplied by your transformation context instead. */ - const createJSDocAuthorTag: (tagName: Identifier | undefined, comment?: string | undefined) => JSDocAuthorTag; + const createJSDocAuthorTag: (tagName: Identifier | undefined, comment?: string | NodeArray | undefined) => JSDocAuthorTag; /** @deprecated Use `factory.createJSDocPublicTag` or the factory supplied by your transformation context instead. */ - const createJSDocPublicTag: (tagName: Identifier | undefined, comment?: string | undefined) => JSDocPublicTag; + const createJSDocPublicTag: (tagName: Identifier | undefined, comment?: string | NodeArray | undefined) => JSDocPublicTag; /** @deprecated Use `factory.createJSDocPrivateTag` or the factory supplied by your transformation context instead. */ - const createJSDocPrivateTag: (tagName: Identifier | undefined, comment?: string | undefined) => JSDocPrivateTag; + const createJSDocPrivateTag: (tagName: Identifier | undefined, comment?: string | NodeArray | undefined) => JSDocPrivateTag; /** @deprecated Use `factory.createJSDocProtectedTag` or the factory supplied by your transformation context instead. */ - const createJSDocProtectedTag: (tagName: Identifier | undefined, comment?: string | undefined) => JSDocProtectedTag; + const createJSDocProtectedTag: (tagName: Identifier | undefined, comment?: string | NodeArray | undefined) => JSDocProtectedTag; /** @deprecated Use `factory.createJSDocReadonlyTag` or the factory supplied by your transformation context instead. */ - const createJSDocReadonlyTag: (tagName: Identifier | undefined, comment?: string | undefined) => JSDocReadonlyTag; + const createJSDocReadonlyTag: (tagName: Identifier | undefined, comment?: string | NodeArray | undefined) => JSDocReadonlyTag; /** @deprecated Use `factory.createJSDocUnknownTag` or the factory supplied by your transformation context instead. */ - const createJSDocTag: (tagName: Identifier, comment?: string | undefined) => JSDocUnknownTag; + const createJSDocTag: (tagName: Identifier, comment?: string | NodeArray | undefined) => JSDocUnknownTag; /** @deprecated Use `factory.createJsxElement` or the factory supplied by your transformation context instead. */ const createJsxElement: (openingElement: JsxOpeningElement, children: readonly JsxChild[], closingElement: JsxClosingElement) => JsxElement; /** @deprecated Use `factory.updateJsxElement` or the factory supplied by your transformation context instead. */ @@ -10879,6 +11167,10 @@ declare namespace ts { */ interface Map extends ESMap { } + /** + * @deprecated Use `isMemberName` instead. + */ + const isIdentifierOrPrivateIdentifier: (node: Node) => node is MemberName; } export = ts; diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index 871fc59961b13..b2b03f617d00b 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -286,7 +286,7 @@ var ts; (function (ts) { // WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values. // If changing the text in this section, be sure to test `configurePrerelease` too. - ts.versionMajorMinor = "4.2"; + ts.versionMajorMinor = "4.4"; // 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 @@ -2133,10 +2133,46 @@ var ts; * Takes a string like "jquery-min.4.2.3" and returns "jquery" */ function removeMinAndVersionNumbers(fileName) { - // Match a "." or "-" followed by a version number or 'min' at the end of the name - var trailingMinOrVersion = /[.-]((min)|(\d+(\.\d+)*))$/; - // The "min" or version may both be present, in either order, so try applying the above twice. - return fileName.replace(trailingMinOrVersion, "").replace(trailingMinOrVersion, ""); + // We used to use the regex /[.-]((min)|(\d+(\.\d+)*))$/ and would just .replace it twice. + // Unfortunately, that regex has O(n^2) performance because v8 doesn't match from the end of the string. + // Instead, we now essentially scan the filename (backwards) ourselves. + var end = fileName.length; + for (var pos = end - 1; pos > 0; pos--) { + var ch = fileName.charCodeAt(pos); + if (ch >= 48 /* _0 */ && ch <= 57 /* _9 */) { + // Match a \d+ segment + do { + --pos; + ch = fileName.charCodeAt(pos); + } while (pos > 0 && ch >= 48 /* _0 */ && ch <= 57 /* _9 */); + } + else if (pos > 4 && (ch === 110 /* n */ || ch === 78 /* N */)) { + // Looking for "min" or "min" + // Already matched the 'n' + --pos; + ch = fileName.charCodeAt(pos); + if (ch !== 105 /* i */ && ch !== 73 /* I */) { + break; + } + --pos; + ch = fileName.charCodeAt(pos); + if (ch !== 109 /* m */ && ch !== 77 /* M */) { + break; + } + --pos; + ch = fileName.charCodeAt(pos); + } + else { + // This character is not part of either suffix pattern + break; + } + if (ch !== 45 /* minus */ && ch !== 46 /* dot */) { + break; + } + end = pos; + } + // end might be fileName.length, in which case this should internally no-op + return end === fileName.length ? fileName : fileName.slice(0, end); } ts.removeMinAndVersionNumbers = removeMinAndVersionNumbers; /** Remove an item from an array, moving everything to its right one space left. */ @@ -2377,6 +2413,33 @@ var ts; return array.slice(0, index); } ts.takeWhile = takeWhile; + /** + * Removes the leading and trailing white space and line terminator characters from a string. + */ + ts.trimString = !!String.prototype.trim ? (function (s) { return s.trim(); }) : function (s) { return ts.trimStringEnd(ts.trimStringStart(s)); }; + /** + * Returns a copy with trailing whitespace removed. + */ + ts.trimStringEnd = !!String.prototype.trimEnd ? (function (s) { return s.trimEnd(); }) : trimEndImpl; + /** + * Returns a copy with leading whitespace removed. + */ + ts.trimStringStart = !!String.prototype.trimStart ? (function (s) { return s.trimStart(); }) : function (s) { return s.replace(/^\s+/g, ""); }; + /** + * https://jsbench.me/gjkoxld4au/1 + * The simple regex for this, /\s+$/g is O(n^2) in v8. + * The native .trimEnd method is by far best, but since that's technically ES2019, + * we provide a (still much faster than the simple regex) fallback. + */ + function trimEndImpl(s) { + var end = s.length - 1; + while (end >= 0) { + if (!ts.isWhiteSpaceLike(s.charCodeAt(end))) + break; + end--; + } + return s.slice(0, end + 1); + } })(ts || (ts = {})); /* @internal */ var ts; @@ -2594,6 +2657,8 @@ var ts; } } Debug.assertMissingNode = assertMissingNode; + function type(_value) { } + Debug.type = type; function getFunctionName(func) { if (typeof func !== "function") { return ""; @@ -2771,6 +2836,9 @@ var ts; // An `Array` with extra properties is rendered as `[A, B, prop1: 1, prop2: 2]`. Most of // these aren't immediately useful so we trim off the `prop1: ..., prop2: ...` part from the // formatted string. + // This regex can trigger slow backtracking because of overlapping potential captures. + // 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; } @@ -2855,11 +2923,11 @@ var ts; this.objectFlags & 8 /* Tuple */ ? "TupleType" : this.objectFlags & 16 /* Anonymous */ ? "AnonymousType" : this.objectFlags & 32 /* Mapped */ ? "MappedType" : - this.objectFlags & 2048 /* ReverseMapped */ ? "ReverseMappedType" : + this.objectFlags & 1024 /* ReverseMapped */ ? "ReverseMappedType" : this.objectFlags & 256 /* EvolvingArray */ ? "EvolvingArrayType" : "ObjectType" : "Type"; - var remainingObjectFlags = this.flags & 524288 /* Object */ ? this.objectFlags & ~2367 /* ObjectTypeKindMask */ : 0; + var remainingObjectFlags = this.flags & 524288 /* Object */ ? this.objectFlags & ~1343 /* ObjectTypeKindMask */ : 0; return "" + typeHeader + (this.symbol ? " '" + ts.symbolName(this.symbol) + "'" : "") + (remainingObjectFlags ? " (" + formatObjectFlags(remainingObjectFlags) + ")" : ""); } }, @@ -3219,7 +3287,7 @@ var ts; // range-set ::= range ( logical-or range ) * // range ::= hyphen | simple ( ' ' simple ) * | '' // logical-or ::= ( ' ' ) * '||' ( ' ' ) * - var logicalOrRegExp = /\s*\|\|\s*/g; + var logicalOrRegExp = /\|\|/g; var whitespaceRegExp = /\s+/g; // https://github.com/npm/node-semver#range-grammar // @@ -3242,14 +3310,15 @@ var ts; // primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial // tilde ::= '~' partial // caret ::= '^' partial - var rangeRegExp = /^\s*(~|\^|<|<=|>|>=|=)?\s*([a-z0-9-+.*]+)$/i; + var rangeRegExp = /^(~|\^|<|<=|>|>=|=)?\s*([a-z0-9-+.*]+)$/i; function parseRange(text) { var alternatives = []; - for (var _i = 0, _a = text.trim().split(logicalOrRegExp); _i < _a.length; _i++) { + for (var _i = 0, _a = ts.trimString(text).split(logicalOrRegExp); _i < _a.length; _i++) { var range = _a[_i]; if (!range) continue; var comparators = []; + range = ts.trimString(range); var match = hyphenRegExp.exec(range); if (match) { if (!parseHyphen(match[1], match[2], comparators)) @@ -3258,7 +3327,7 @@ var ts; else { for (var _b = 0, _c = range.split(whitespaceRegExp); _b < _c.length; _b++) { var simple = _c[_b]; - var match_1 = rangeRegExp.exec(simple); + var match_1 = rangeRegExp.exec(ts.trimString(simple)); if (!match_1 || !parseComparator(match_1[1], match_1[2], comparators)) return undefined; } @@ -3405,16 +3474,22 @@ var ts; typeof PerformanceObserver === "function" && hasRequiredAPI(performance, PerformanceObserver)) { return { + // For now we always write native performance events when running in the browser. We may + // make this conditional in the future if we find that native web performance hooks + // in the browser also slow down compilation. + shouldWriteNativeEvents: true, performance: performance, PerformanceObserver: PerformanceObserver }; } } function tryGetNodePerformanceHooks() { - if (typeof module === "object" && typeof require === "function") { + if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof module === "object" && typeof require === "function") { try { - var _a = require("perf_hooks"), performance_1 = _a.performance, PerformanceObserver_1 = _a.PerformanceObserver; - if (hasRequiredAPI(performance_1, PerformanceObserver_1)) { + var performance_1; + var _a = require("perf_hooks"), nodePerformance_1 = _a.performance, PerformanceObserver_1 = _a.PerformanceObserver; + if (hasRequiredAPI(nodePerformance_1, PerformanceObserver_1)) { + performance_1 = nodePerformance_1; // There is a bug in Node's performance.measure prior to 12.16.3/13.13.0 that does not // match the Web Performance API specification. Node's implementation did not allow // optional `start` and `end` arguments for `performance.measure`. @@ -3422,27 +3497,26 @@ var ts; var version_1 = new ts.Version(process.versions.node); var range = new ts.VersionRange("<12.16.3 || 13 <13.13"); if (range.test(version_1)) { - return { - performance: { - get timeOrigin() { return performance_1.timeOrigin; }, - now: function () { return performance_1.now(); }, - mark: function (name) { return performance_1.mark(name); }, - measure: function (name, start, end) { - if (start === void 0) { start = "nodeStart"; } - if (end === undefined) { - end = "__performance.measure-fix__"; - performance_1.mark(end); - } - performance_1.measure(name, start, end); - if (end === "__performance.measure-fix__") { - performance_1.clearMarks("__performance.measure-fix__"); - } + performance_1 = { + get timeOrigin() { return nodePerformance_1.timeOrigin; }, + now: function () { return nodePerformance_1.now(); }, + mark: function (name) { return nodePerformance_1.mark(name); }, + measure: function (name, start, end) { + if (start === void 0) { start = "nodeStart"; } + if (end === undefined) { + end = "__performance.measure-fix__"; + nodePerformance_1.mark(end); + } + nodePerformance_1.measure(name, start, end); + if (end === "__performance.measure-fix__") { + nodePerformance_1.clearMarks("__performance.measure-fix__"); } - }, - PerformanceObserver: PerformanceObserver_1 + } }; } return { + // By default, only write native events when generating a cpu profile or using the v8 profiler. + shouldWriteNativeEvents: false, performance: performance_1, PerformanceObserver: PerformanceObserver_1 }; @@ -3473,7 +3547,6 @@ var ts; var performance; (function (performance) { var perfHooks; - var perfObserver; // when set, indicates the implementation of `Performance` to use for user timing. // when unset, indicates user timing is unavailable or disabled. var performanceImpl; @@ -3504,6 +3577,9 @@ var ts; } performance.createTimer = createTimer; performance.nullTimer = { enter: ts.noop, exit: ts.noop }; + var enabled = false; + var timeorigin = ts.timestamp(); + var marks = new ts.Map(); var counts = new ts.Map(); var durations = new ts.Map(); /** @@ -3512,7 +3588,13 @@ var ts; * @param markName The name of the mark. */ function mark(markName) { - performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.mark(markName); + var _a; + if (enabled) { + var count = (_a = counts.get(markName)) !== null && _a !== void 0 ? _a : 0; + counts.set(markName, count + 1); + marks.set(markName, ts.timestamp()); + performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.mark(markName); + } } performance.mark = mark; /** @@ -3525,7 +3607,14 @@ var ts; * used. */ function measure(measureName, startMarkName, endMarkName) { - performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.measure(measureName, startMarkName, endMarkName); + var _a, _b; + if (enabled) { + var end = (_a = (endMarkName !== undefined ? marks.get(endMarkName) : undefined)) !== null && _a !== void 0 ? _a : ts.timestamp(); + var start = (_b = (startMarkName !== undefined ? marks.get(startMarkName) : undefined)) !== null && _b !== void 0 ? _b : timeorigin; + var previousDuration = durations.get(measureName) || 0; + durations.set(measureName, previousDuration + (end - start)); + performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.measure(measureName, startMarkName, endMarkName); + } } performance.measure = measure; /** @@ -3559,40 +3648,41 @@ var ts; * Indicates whether the performance API is enabled. */ function isEnabled() { - return !!performanceImpl; + return enabled; } performance.isEnabled = isEnabled; /** Enables (and resets) performance measurements for the compiler. */ - function enable() { - if (!performanceImpl) { + function enable(system) { + var _a; + if (system === void 0) { system = ts.sys; } + if (!enabled) { + enabled = true; perfHooks || (perfHooks = ts.tryGetNativePerformanceHooks()); - if (!perfHooks) - return false; - perfObserver || (perfObserver = new perfHooks.PerformanceObserver(updateStatisticsFromList)); - perfObserver.observe({ entryTypes: ["mark", "measure"] }); - performanceImpl = perfHooks.performance; + if (perfHooks) { + timeorigin = perfHooks.performance.timeOrigin; + // NodeJS's Web Performance API is currently slower than expected, but we'd still like + // to be able to leverage native trace events when node is run with either `--cpu-prof` + // or `--prof`, if we're running with our own `--generateCpuProfile` flag, or when + // running in debug mode (since its possible to generate a cpu profile while debugging). + if (perfHooks.shouldWriteNativeEvents || ((_a = system === null || system === void 0 ? void 0 : system.cpuProfilingEnabled) === null || _a === void 0 ? void 0 : _a.call(system)) || (system === null || system === void 0 ? void 0 : system.debugMode)) { + performanceImpl = perfHooks.performance; + } + } } return true; } performance.enable = enable; /** Disables performance measurements for the compiler. */ function disable() { - perfObserver === null || perfObserver === void 0 ? void 0 : perfObserver.disconnect(); - performanceImpl = undefined; - counts.clear(); - durations.clear(); - } - performance.disable = disable; - function updateStatisticsFromList(list) { - for (var _i = 0, _a = list.getEntriesByType("mark"); _i < _a.length; _i++) { - var mark_1 = _a[_i]; - counts.set(mark_1.name, (counts.get(mark_1.name) || 0) + 1); - } - for (var _b = 0, _c = list.getEntriesByType("measure"); _b < _c.length; _b++) { - var measure_1 = _c[_b]; - durations.set(measure_1.name, (durations.get(measure_1.name) || 0) + measure_1.duration); + if (enabled) { + marks.clear(); + counts.clear(); + durations.clear(); + performanceImpl = undefined; + enabled = false; } } + performance.disable = disable; })(performance = ts.performance || (ts.performance = {})); })(ts || (ts = {})); /* @internal */ @@ -3636,40 +3726,35 @@ var ts; /** Performance logger that will generate ETW events if possible - check for `logEvent` member, as `etwModule` will be `{}` when browserified */ ts.perfLogger = etwModule && etwModule.logEvent ? etwModule : nullLogger; })(ts || (ts = {})); +/* Tracing events for the compiler. */ /*@internal*/ -/** Tracing events for the compiler. */ var ts; (function (ts) { - var tracing; - (function (tracing) { - var Mode; - (function (Mode) { - Mode[Mode["Project"] = 0] = "Project"; - Mode[Mode["Build"] = 1] = "Build"; - Mode[Mode["Server"] = 2] = "Server"; - })(Mode = tracing.Mode || (tracing.Mode = {})); + // enable the above using startTracing() + // `tracingEnabled` should never be used directly, only through the above + var tracingEnabled; + (function (tracingEnabled) { var fs; var traceCount = 0; - var traceFd; + var traceFd = 0; var mode; + var typeCatalog = []; // NB: id is index + 1 var legendPath; var legend = []; ; - /** Starts tracing for the given project (unless the `fs` module is unavailable). */ + /** Starts tracing for the given project. */ function startTracing(tracingMode, traceDir, configFilePath) { - ts.Debug.assert(!traceFd, "Tracing already started"); + ts.Debug.assert(!ts.tracing, "Tracing already started"); if (fs === undefined) { try { fs = require("fs"); } - catch (_a) { - fs = false; + catch (e) { + throw new Error("tracing requires having fs\n(original error: " + (e.message || e) + ")"); } } - if (!fs) { - return; - } mode = tracingMode; + typeCatalog.length = 0; if (legendPath === undefined) { legendPath = ts.combinePaths(traceDir, "legend.json"); } @@ -3677,9 +3762,9 @@ var ts; if (!fs.existsSync(traceDir)) { fs.mkdirSync(traceDir, { recursive: true }); } - var countPart = mode === 1 /* Build */ ? "." + process.pid + "-" + ++traceCount : - mode === 2 /* Server */ ? "." + process.pid : - ""; + var countPart = mode === "build" ? "." + process.pid + "-" + ++traceCount + : mode === "server" ? "." + process.pid + : ""; var tracePath = ts.combinePaths(traceDir, "trace" + countPart + ".json"); var typesPath = ts.combinePaths(traceDir, "types" + countPart + ".json"); legend.push({ @@ -3688,25 +3773,22 @@ var ts; typesPath: typesPath, }); traceFd = fs.openSync(tracePath, "w"); + ts.tracing = tracingEnabled; // only when traceFd is properly set // Start with a prefix that contains some metadata that the devtools profiler expects (also avoids a warning on import) var meta = { cat: "__metadata", ph: "M", ts: 1000 * ts.timestamp(), pid: 1, tid: 1 }; fs.writeSync(traceFd, "[\n" + [__assign({ name: "process_name", args: { name: "tsc" } }, meta), __assign({ name: "thread_name", args: { name: "Main" } }, meta), __assign(__assign({ name: "TracingStartedInBrowser" }, meta), { cat: "disabled-by-default-devtools.timeline" })] .map(function (v) { return JSON.stringify(v); }).join(",\n")); } - tracing.startTracing = startTracing; - /** Stops tracing for the in-progress project and dumps the type catalog (unless the `fs` module is unavailable). */ - function stopTracing(typeCatalog) { - if (!traceFd) { - ts.Debug.assert(!fs, "Tracing is not in progress"); - return; - } - ts.Debug.assert(fs); - ts.Debug.assert(!!typeCatalog === (mode !== 2 /* Server */)); // Have a type catalog iff not in server mode + tracingEnabled.startTracing = startTracing; + /** Stops tracing for the in-progress project and dumps the type catalog. */ + function stopTracing() { + ts.Debug.assert(ts.tracing, "Tracing is not in progress"); + ts.Debug.assert(!!typeCatalog.length === (mode !== "server")); // Have a type catalog iff not in server mode fs.writeSync(traceFd, "\n]\n"); fs.closeSync(traceFd); - traceFd = undefined; - if (typeCatalog) { + ts.tracing = undefined; + if (typeCatalog.length) { dumpTypes(typeCatalog); } else { @@ -3715,11 +3797,13 @@ var ts; legend[legend.length - 1].typesPath = undefined; } } - tracing.stopTracing = stopTracing; - function isTracing() { - return !!traceFd; + tracingEnabled.stopTracing = stopTracing; + function recordType(type) { + if (mode !== "server") { + typeCatalog.push(type); + } } - tracing.isTracing = isTracing; + tracingEnabled.recordType = recordType; var Phase; (function (Phase) { Phase["Parse"] = "parse"; @@ -3729,13 +3813,11 @@ var ts; Phase["CheckTypes"] = "checkTypes"; Phase["Emit"] = "emit"; Phase["Session"] = "session"; - })(Phase = tracing.Phase || (tracing.Phase = {})); + })(Phase = tracingEnabled.Phase || (tracingEnabled.Phase = {})); function instant(phase, name, args) { - if (!traceFd) - return; writeEvent("I", phase, name, args, "\"s\":\"g\""); } - tracing.instant = instant; + tracingEnabled.instant = instant; var eventStack = []; /** * @param separateBeginAndEnd - used for special cases where we need the trace point even if the event @@ -3745,47 +3827,42 @@ var ts; */ function push(phase, name, args, separateBeginAndEnd) { if (separateBeginAndEnd === void 0) { separateBeginAndEnd = false; } - if (!traceFd) - return; if (separateBeginAndEnd) { writeEvent("B", phase, name, args); } eventStack.push({ phase: phase, name: name, args: args, time: 1000 * ts.timestamp(), separateBeginAndEnd: separateBeginAndEnd }); } - tracing.push = push; + tracingEnabled.push = push; function pop() { - if (!traceFd) - return; ts.Debug.assert(eventStack.length > 0); writeStackEvent(eventStack.length - 1, 1000 * ts.timestamp()); eventStack.length--; } - tracing.pop = pop; + tracingEnabled.pop = pop; function popAll() { - if (!traceFd) - return; var endTime = 1000 * ts.timestamp(); for (var i = eventStack.length - 1; i >= 0; i--) { writeStackEvent(i, endTime); } eventStack.length = 0; } - tracing.popAll = popAll; + tracingEnabled.popAll = popAll; + // sample every 10ms + var sampleInterval = 1000 * 10; function writeStackEvent(index, endTime) { var _a = eventStack[index], phase = _a.phase, name = _a.name, args = _a.args, time = _a.time, separateBeginAndEnd = _a.separateBeginAndEnd; if (separateBeginAndEnd) { writeEvent("E", phase, name, args, /*extras*/ undefined, endTime); } - else { + // test if [time,endTime) straddles a sampling point + else if (sampleInterval - (time % sampleInterval) <= endTime - time) { writeEvent("X", phase, name, args, "\"dur\":" + (endTime - time), time); } } function writeEvent(eventType, phase, name, args, extras, time) { if (time === void 0) { time = 1000 * ts.timestamp(); } - ts.Debug.assert(traceFd); - ts.Debug.assert(fs); // In server mode, there's no easy way to dump type information, so we drop events that would require it. - if (mode === 2 /* Server */ && phase === "checkTypes" /* CheckTypes */) + if (mode === "server" && phase === "checkTypes" /* CheckTypes */) return; ts.performance.mark("beginTracing"); fs.writeSync(traceFd, ",\n{\"pid\":1,\"tid\":1,\"ph\":\"" + eventType + "\",\"cat\":\"" + phase + "\",\"ts\":" + time + ",\"name\":\"" + name + "\""); @@ -3797,15 +3874,24 @@ var ts; ts.performance.mark("endTracing"); ts.performance.measure("Tracing", "beginTracing", "endTracing"); } - function indexFromOne(lc) { - return { - line: lc.line + 1, - character: lc.character + 1, - }; + function getLocation(node) { + var file = ts.getSourceFileOfNode(node); + return !file + ? undefined + : { + path: file.path, + start: indexFromOne(ts.getLineAndCharacterOfPosition(file, node.pos)), + end: indexFromOne(ts.getLineAndCharacterOfPosition(file, node.end)), + }; + function indexFromOne(lc) { + return { + line: lc.line + 1, + character: lc.character + 1, + }; + } } function dumpTypes(types) { - var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r; - ts.Debug.assert(fs); + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x; ts.performance.mark("beginDumpTypes"); var typesPath = legend[legend.length - 1].typesPath; var typesFd = fs.openSync(typesPath, "w"); @@ -3817,15 +3903,13 @@ var ts; var type = types[i]; var objectFlags = type.objectFlags; var symbol = (_a = type.aliasSymbol) !== null && _a !== void 0 ? _a : type.symbol; - var firstDeclaration = (_b = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _b === void 0 ? void 0 : _b[0]; - var firstFile = firstDeclaration && ts.getSourceFileOfNode(firstDeclaration); // 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 */)) { try { - display = (_c = type.checker) === null || _c === void 0 ? void 0 : _c.typeToString(type); + display = (_b = type.checker) === null || _b === void 0 ? void 0 : _b.typeToString(type); } - catch (_s) { + catch (_y) { display = undefined; } } @@ -3833,26 +3917,52 @@ var ts; if (type.flags & 8388608 /* IndexedAccess */) { var indexedAccessType = type; indexedAccessProperties = { - indexedAccessObjectType: (_d = indexedAccessType.objectType) === null || _d === void 0 ? void 0 : _d.id, - indexedAccessIndexType: (_e = indexedAccessType.indexType) === null || _e === void 0 ? void 0 : _e.id, + indexedAccessObjectType: (_c = indexedAccessType.objectType) === null || _c === void 0 ? void 0 : _c.id, + indexedAccessIndexType: (_d = indexedAccessType.indexType) === null || _d === void 0 ? void 0 : _d.id, }; } var referenceProperties = {}; if (objectFlags & 4 /* Reference */) { var referenceType = type; referenceProperties = { - instantiatedType: (_f = referenceType.target) === null || _f === void 0 ? void 0 : _f.id, - typeArguments: (_g = referenceType.resolvedTypeArguments) === null || _g === void 0 ? void 0 : _g.map(function (t) { return t.id; }), + instantiatedType: (_e = referenceType.target) === null || _e === void 0 ? void 0 : _e.id, + typeArguments: (_f = referenceType.resolvedTypeArguments) === null || _f === void 0 ? void 0 : _f.map(function (t) { return t.id; }), + referenceLocation: getLocation(referenceType.node), }; } var conditionalProperties = {}; if (type.flags & 16777216 /* Conditional */) { var conditionalType = type; conditionalProperties = { - conditionalCheckType: (_h = conditionalType.checkType) === null || _h === void 0 ? void 0 : _h.id, - conditionalExtendsType: (_j = conditionalType.extendsType) === null || _j === void 0 ? void 0 : _j.id, - conditionalTrueType: (_l = (_k = conditionalType.resolvedTrueType) === null || _k === void 0 ? void 0 : _k.id) !== null && _l !== void 0 ? _l : -1, - conditionalFalseType: (_o = (_m = conditionalType.resolvedFalseType) === null || _m === void 0 ? void 0 : _m.id) !== null && _o !== void 0 ? _o : -1, + conditionalCheckType: (_g = conditionalType.checkType) === null || _g === void 0 ? void 0 : _g.id, + conditionalExtendsType: (_h = conditionalType.extendsType) === null || _h === void 0 ? void 0 : _h.id, + conditionalTrueType: (_k = (_j = conditionalType.resolvedTrueType) === null || _j === void 0 ? void 0 : _j.id) !== null && _k !== void 0 ? _k : -1, + conditionalFalseType: (_m = (_l = conditionalType.resolvedFalseType) === null || _l === void 0 ? void 0 : _l.id) !== null && _m !== void 0 ? _m : -1, + }; + } + var substitutionProperties = {}; + if (type.flags & 33554432 /* Substitution */) { + var substitutionType = type; + substitutionProperties = { + substitutionBaseType: (_o = substitutionType.baseType) === null || _o === void 0 ? void 0 : _o.id, + substituteType: (_p = substitutionType.substitute) === null || _p === void 0 ? void 0 : _p.id, + }; + } + var reverseMappedProperties = {}; + if (objectFlags & 1024 /* ReverseMapped */) { + var reverseMappedType = type; + reverseMappedProperties = { + reverseMappedSourceType: (_q = reverseMappedType.source) === null || _q === void 0 ? void 0 : _q.id, + reverseMappedMappedType: (_r = reverseMappedType.mappedType) === null || _r === void 0 ? void 0 : _r.id, + reverseMappedConstraintType: (_s = reverseMappedType.constraintType) === null || _s === void 0 ? void 0 : _s.id, + }; + } + var evolvingArrayProperties = {}; + if (objectFlags & 256 /* EvolvingArray */) { + var evolvingArrayType = type; + evolvingArrayProperties = { + evolvingArrayElementType: evolvingArrayType.elementType.id, + evolvingArrayFinalType: (_t = evolvingArrayType.finalArrayType) === null || _t === void 0 ? void 0 : _t.id, }; } // We can't print out an arbitrary object, so just assign each one a unique number. @@ -3866,11 +3976,7 @@ var ts; recursionIdentityMap.set(recursionIdentity, recursionToken); } } - var descriptor = __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, unionTypes: (type.flags & 1048576 /* Union */) ? (_p = type.types) === null || _p === void 0 ? void 0 : _p.map(function (t) { return t.id; }) : undefined, intersectionTypes: (type.flags & 2097152 /* Intersection */) ? type.types.map(function (t) { return t.id; }) : undefined, aliasTypeArguments: (_q = type.aliasTypeArguments) === null || _q === void 0 ? void 0 : _q.map(function (t) { return t.id; }), keyofType: (type.flags & 4194304 /* Index */) ? (_r = type.type) === null || _r === void 0 ? void 0 : _r.id : undefined }, indexedAccessProperties), referenceProperties), conditionalProperties), { firstDeclaration: firstDeclaration && { - path: firstFile.path, - start: indexFromOne(ts.getLineAndCharacterOfPosition(firstFile, firstDeclaration.pos)), - end: indexFromOne(ts.getLineAndCharacterOfPosition(ts.getSourceFileOfNode(firstDeclaration), firstDeclaration.end)), - }, 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 /* 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 }); fs.writeSync(typesFd, JSON.stringify(descriptor)); if (i < numTypes - 1) { fs.writeSync(typesFd, ",\n"); @@ -3885,11 +3991,13 @@ var ts; if (!legendPath) { return; } - ts.Debug.assert(fs); fs.writeFileSync(legendPath, JSON.stringify(legend)); } - tracing.dumpLegend = dumpLegend; - })(tracing = ts.tracing || (ts.tracing = {})); + tracingEnabled.dumpLegend = dumpLegend; + })(tracingEnabled || (tracingEnabled = {})); + // define after tracingEnabled is initialized + ts.startTracing = tracingEnabled.startTracing; + ts.dumpTracingLegend = tracingEnabled.dumpLegend; })(ts || (ts = {})); var ts; (function (ts) { @@ -3966,331 +4074,337 @@ var ts; SyntaxKind[SyntaxKind["QuestionQuestionToken"] = 60] = "QuestionQuestionToken"; /** Only the JSDoc scanner produces BacktickToken. The normal scanner produces NoSubstitutionTemplateLiteral and related kinds. */ SyntaxKind[SyntaxKind["BacktickToken"] = 61] = "BacktickToken"; + /** Only the JSDoc scanner produces HashToken. The normal scanner produces PrivateIdentifier. */ + SyntaxKind[SyntaxKind["HashToken"] = 62] = "HashToken"; // Assignments - SyntaxKind[SyntaxKind["EqualsToken"] = 62] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 63] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 64] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 65] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 66] = "AsteriskAsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 67] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 68] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 69] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 70] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 71] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 72] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 73] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["BarBarEqualsToken"] = 74] = "BarBarEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandEqualsToken"] = 75] = "AmpersandAmpersandEqualsToken"; - SyntaxKind[SyntaxKind["QuestionQuestionEqualsToken"] = 76] = "QuestionQuestionEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 77] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 63] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 64] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 65] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 66] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 67] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 68] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 69] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 70] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 71] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 72] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 73] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 74] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["BarBarEqualsToken"] = 75] = "BarBarEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandEqualsToken"] = 76] = "AmpersandAmpersandEqualsToken"; + SyntaxKind[SyntaxKind["QuestionQuestionEqualsToken"] = 77] = "QuestionQuestionEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 78] = "CaretEqualsToken"; // Identifiers and PrivateIdentifiers - SyntaxKind[SyntaxKind["Identifier"] = 78] = "Identifier"; - SyntaxKind[SyntaxKind["PrivateIdentifier"] = 79] = "PrivateIdentifier"; + SyntaxKind[SyntaxKind["Identifier"] = 79] = "Identifier"; + SyntaxKind[SyntaxKind["PrivateIdentifier"] = 80] = "PrivateIdentifier"; // Reserved words - SyntaxKind[SyntaxKind["BreakKeyword"] = 80] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 81] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 82] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 83] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 84] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 85] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 86] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 87] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 88] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 89] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 90] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 91] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 92] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 93] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 94] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 95] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 96] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 97] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 98] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 99] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 100] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 101] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 102] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 103] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 104] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 105] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 106] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 107] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 108] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 109] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 110] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 111] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 112] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 113] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 114] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 115] = "WithKeyword"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 81] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 82] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 83] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 84] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 85] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 86] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 87] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 88] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 89] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 90] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 91] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 92] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 93] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 94] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 95] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 96] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 97] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 98] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 99] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 100] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 101] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 102] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 103] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 104] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 105] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 106] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 107] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 108] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 109] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 110] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 111] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 112] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 113] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 114] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 115] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 116] = "WithKeyword"; // Strict mode reserved words - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 116] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 117] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 118] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 119] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 120] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 121] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 122] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 123] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 124] = "YieldKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 117] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 118] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 119] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 120] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 121] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 122] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 123] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 124] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 125] = "YieldKeyword"; // Contextual keywords - SyntaxKind[SyntaxKind["AbstractKeyword"] = 125] = "AbstractKeyword"; - SyntaxKind[SyntaxKind["AsKeyword"] = 126] = "AsKeyword"; - SyntaxKind[SyntaxKind["AssertsKeyword"] = 127] = "AssertsKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 128] = "AnyKeyword"; - SyntaxKind[SyntaxKind["AsyncKeyword"] = 129] = "AsyncKeyword"; - SyntaxKind[SyntaxKind["AwaitKeyword"] = 130] = "AwaitKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 131] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 132] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 133] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 134] = "GetKeyword"; - SyntaxKind[SyntaxKind["InferKeyword"] = 135] = "InferKeyword"; - SyntaxKind[SyntaxKind["IntrinsicKeyword"] = 136] = "IntrinsicKeyword"; - SyntaxKind[SyntaxKind["IsKeyword"] = 137] = "IsKeyword"; - SyntaxKind[SyntaxKind["KeyOfKeyword"] = 138] = "KeyOfKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 139] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["NamespaceKeyword"] = 140] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["NeverKeyword"] = 141] = "NeverKeyword"; - SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 142] = "ReadonlyKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 143] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 144] = "NumberKeyword"; - SyntaxKind[SyntaxKind["ObjectKeyword"] = 145] = "ObjectKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 146] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 147] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 148] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 149] = "TypeKeyword"; - SyntaxKind[SyntaxKind["UndefinedKeyword"] = 150] = "UndefinedKeyword"; - SyntaxKind[SyntaxKind["UniqueKeyword"] = 151] = "UniqueKeyword"; - SyntaxKind[SyntaxKind["UnknownKeyword"] = 152] = "UnknownKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 153] = "FromKeyword"; - SyntaxKind[SyntaxKind["GlobalKeyword"] = 154] = "GlobalKeyword"; - SyntaxKind[SyntaxKind["BigIntKeyword"] = 155] = "BigIntKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 156] = "OfKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 126] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 127] = "AsKeyword"; + SyntaxKind[SyntaxKind["AssertsKeyword"] = 128] = "AssertsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 129] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 130] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 131] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 132] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 133] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 134] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 135] = "GetKeyword"; + SyntaxKind[SyntaxKind["InferKeyword"] = 136] = "InferKeyword"; + SyntaxKind[SyntaxKind["IntrinsicKeyword"] = 137] = "IntrinsicKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 138] = "IsKeyword"; + SyntaxKind[SyntaxKind["KeyOfKeyword"] = 139] = "KeyOfKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 140] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 141] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 142] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 143] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 144] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 145] = "NumberKeyword"; + SyntaxKind[SyntaxKind["ObjectKeyword"] = 146] = "ObjectKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 147] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 148] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 149] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 150] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 151] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["UniqueKeyword"] = 152] = "UniqueKeyword"; + SyntaxKind[SyntaxKind["UnknownKeyword"] = 153] = "UnknownKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 154] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 155] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["BigIntKeyword"] = 156] = "BigIntKeyword"; + SyntaxKind[SyntaxKind["OverrideKeyword"] = 157] = "OverrideKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 158] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 157] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 158] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 159] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 160] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 159] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 160] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 161] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 161] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 162] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 163] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 162] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 163] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 164] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 165] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 166] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 167] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 168] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 169] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 170] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 171] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 164] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 165] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 166] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 167] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 168] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 169] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 170] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 171] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 172] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 173] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 172] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 173] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 174] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 175] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 176] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 177] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 178] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 179] = "TupleType"; - SyntaxKind[SyntaxKind["OptionalType"] = 180] = "OptionalType"; - SyntaxKind[SyntaxKind["RestType"] = 181] = "RestType"; - SyntaxKind[SyntaxKind["UnionType"] = 182] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 183] = "IntersectionType"; - SyntaxKind[SyntaxKind["ConditionalType"] = 184] = "ConditionalType"; - SyntaxKind[SyntaxKind["InferType"] = 185] = "InferType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 186] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 187] = "ThisType"; - SyntaxKind[SyntaxKind["TypeOperator"] = 188] = "TypeOperator"; - SyntaxKind[SyntaxKind["IndexedAccessType"] = 189] = "IndexedAccessType"; - SyntaxKind[SyntaxKind["MappedType"] = 190] = "MappedType"; - SyntaxKind[SyntaxKind["LiteralType"] = 191] = "LiteralType"; - SyntaxKind[SyntaxKind["NamedTupleMember"] = 192] = "NamedTupleMember"; - SyntaxKind[SyntaxKind["TemplateLiteralType"] = 193] = "TemplateLiteralType"; - SyntaxKind[SyntaxKind["TemplateLiteralTypeSpan"] = 194] = "TemplateLiteralTypeSpan"; - SyntaxKind[SyntaxKind["ImportType"] = 195] = "ImportType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 174] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 175] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 176] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 177] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 178] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 179] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 180] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 181] = "TupleType"; + SyntaxKind[SyntaxKind["OptionalType"] = 182] = "OptionalType"; + SyntaxKind[SyntaxKind["RestType"] = 183] = "RestType"; + SyntaxKind[SyntaxKind["UnionType"] = 184] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 185] = "IntersectionType"; + SyntaxKind[SyntaxKind["ConditionalType"] = 186] = "ConditionalType"; + SyntaxKind[SyntaxKind["InferType"] = 187] = "InferType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 188] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 189] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 190] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 191] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 192] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 193] = "LiteralType"; + SyntaxKind[SyntaxKind["NamedTupleMember"] = 194] = "NamedTupleMember"; + SyntaxKind[SyntaxKind["TemplateLiteralType"] = 195] = "TemplateLiteralType"; + SyntaxKind[SyntaxKind["TemplateLiteralTypeSpan"] = 196] = "TemplateLiteralTypeSpan"; + SyntaxKind[SyntaxKind["ImportType"] = 197] = "ImportType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 196] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 197] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 198] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 198] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 199] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 200] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 199] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 200] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 201] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 202] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 203] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 204] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 205] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 206] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 207] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 208] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 209] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 210] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 211] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 212] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 213] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 214] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 215] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 216] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 217] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 218] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 219] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElement"] = 220] = "SpreadElement"; - SyntaxKind[SyntaxKind["ClassExpression"] = 221] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 222] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 223] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 224] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 225] = "NonNullExpression"; - SyntaxKind[SyntaxKind["MetaProperty"] = 226] = "MetaProperty"; - SyntaxKind[SyntaxKind["SyntheticExpression"] = 227] = "SyntheticExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 201] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 202] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 203] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 204] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 205] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 206] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 207] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 208] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 209] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 210] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 211] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 212] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 213] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 214] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 215] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 216] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 217] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 218] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 219] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 220] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 221] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 222] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 223] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 224] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 225] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 226] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 227] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 228] = "MetaProperty"; + SyntaxKind[SyntaxKind["SyntheticExpression"] = 229] = "SyntheticExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 228] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 229] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 230] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 231] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 230] = "Block"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 231] = "EmptyStatement"; - SyntaxKind[SyntaxKind["VariableStatement"] = 232] = "VariableStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 233] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 234] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 235] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 236] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 237] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 238] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 239] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 240] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 241] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 242] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 243] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 244] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 245] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 246] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 247] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 248] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 249] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 250] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 251] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 252] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 253] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 254] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 255] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 256] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 257] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 258] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 259] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 260] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 261] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 262] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 263] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 264] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 265] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 266] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 267] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 268] = "NamedExports"; - SyntaxKind[SyntaxKind["NamespaceExport"] = 269] = "NamespaceExport"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 270] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 271] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 232] = "Block"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 233] = "EmptyStatement"; + SyntaxKind[SyntaxKind["VariableStatement"] = 234] = "VariableStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 235] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 236] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 237] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 238] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 239] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 240] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 241] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 242] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 243] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 244] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 245] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 246] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 247] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 248] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 249] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 250] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 251] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 252] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 253] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 254] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 255] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 256] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 257] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 258] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 259] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 260] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 261] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 262] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 263] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 264] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 265] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 266] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 267] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 268] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 269] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 270] = "NamedExports"; + SyntaxKind[SyntaxKind["NamespaceExport"] = 271] = "NamespaceExport"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 272] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 273] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 272] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 274] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 273] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 274] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 275] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 276] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxFragment"] = 277] = "JsxFragment"; - SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 278] = "JsxOpeningFragment"; - SyntaxKind[SyntaxKind["JsxClosingFragment"] = 279] = "JsxClosingFragment"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 280] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxAttributes"] = 281] = "JsxAttributes"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 282] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 283] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 275] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 276] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 277] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 278] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxFragment"] = 279] = "JsxFragment"; + SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 280] = "JsxOpeningFragment"; + SyntaxKind[SyntaxKind["JsxClosingFragment"] = 281] = "JsxClosingFragment"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 282] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 283] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 284] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 285] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 284] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 285] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 286] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 287] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 286] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 287] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 288] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 289] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 288] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 289] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 290] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 290] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 291] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 292] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 291] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 293] = "EnumMember"; // Unparsed - SyntaxKind[SyntaxKind["UnparsedPrologue"] = 292] = "UnparsedPrologue"; - SyntaxKind[SyntaxKind["UnparsedPrepend"] = 293] = "UnparsedPrepend"; - SyntaxKind[SyntaxKind["UnparsedText"] = 294] = "UnparsedText"; - SyntaxKind[SyntaxKind["UnparsedInternalText"] = 295] = "UnparsedInternalText"; - SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 296] = "UnparsedSyntheticReference"; + SyntaxKind[SyntaxKind["UnparsedPrologue"] = 294] = "UnparsedPrologue"; + SyntaxKind[SyntaxKind["UnparsedPrepend"] = 295] = "UnparsedPrepend"; + SyntaxKind[SyntaxKind["UnparsedText"] = 296] = "UnparsedText"; + SyntaxKind[SyntaxKind["UnparsedInternalText"] = 297] = "UnparsedInternalText"; + SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 298] = "UnparsedSyntheticReference"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 297] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 298] = "Bundle"; - SyntaxKind[SyntaxKind["UnparsedSource"] = 299] = "UnparsedSource"; - SyntaxKind[SyntaxKind["InputFiles"] = 300] = "InputFiles"; + SyntaxKind[SyntaxKind["SourceFile"] = 299] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 300] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 301] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 302] = "InputFiles"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 301] = "JSDocTypeExpression"; - SyntaxKind[SyntaxKind["JSDocNameReference"] = 302] = "JSDocNameReference"; - // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 303] = "JSDocAllType"; - // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 304] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 305] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 306] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 307] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 308] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 309] = "JSDocVariadicType"; - // https://jsdoc.app/about-namepaths.html - SyntaxKind[SyntaxKind["JSDocNamepathType"] = 310] = "JSDocNamepathType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 311] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 312] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocSignature"] = 313] = "JSDocSignature"; - SyntaxKind[SyntaxKind["JSDocTag"] = 314] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 315] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocImplementsTag"] = 316] = "JSDocImplementsTag"; - SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 317] = "JSDocAuthorTag"; - SyntaxKind[SyntaxKind["JSDocDeprecatedTag"] = 318] = "JSDocDeprecatedTag"; - SyntaxKind[SyntaxKind["JSDocClassTag"] = 319] = "JSDocClassTag"; - SyntaxKind[SyntaxKind["JSDocPublicTag"] = 320] = "JSDocPublicTag"; - SyntaxKind[SyntaxKind["JSDocPrivateTag"] = 321] = "JSDocPrivateTag"; - SyntaxKind[SyntaxKind["JSDocProtectedTag"] = 322] = "JSDocProtectedTag"; - SyntaxKind[SyntaxKind["JSDocReadonlyTag"] = 323] = "JSDocReadonlyTag"; - SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 324] = "JSDocCallbackTag"; - SyntaxKind[SyntaxKind["JSDocEnumTag"] = 325] = "JSDocEnumTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 326] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 327] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocThisTag"] = 328] = "JSDocThisTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 329] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 330] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 331] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocSeeTag"] = 332] = "JSDocSeeTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 333] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 303] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocNameReference"] = 304] = "JSDocNameReference"; + SyntaxKind[SyntaxKind["JSDocMemberName"] = 305] = "JSDocMemberName"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 306] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 307] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 308] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 309] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 310] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 311] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 312] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocNamepathType"] = 313] = "JSDocNamepathType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 314] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocText"] = 315] = "JSDocText"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 316] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 317] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocLink"] = 318] = "JSDocLink"; + SyntaxKind[SyntaxKind["JSDocLinkCode"] = 319] = "JSDocLinkCode"; + SyntaxKind[SyntaxKind["JSDocLinkPlain"] = 320] = "JSDocLinkPlain"; + SyntaxKind[SyntaxKind["JSDocTag"] = 321] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 322] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocImplementsTag"] = 323] = "JSDocImplementsTag"; + SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 324] = "JSDocAuthorTag"; + SyntaxKind[SyntaxKind["JSDocDeprecatedTag"] = 325] = "JSDocDeprecatedTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 326] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocPublicTag"] = 327] = "JSDocPublicTag"; + SyntaxKind[SyntaxKind["JSDocPrivateTag"] = 328] = "JSDocPrivateTag"; + SyntaxKind[SyntaxKind["JSDocProtectedTag"] = 329] = "JSDocProtectedTag"; + SyntaxKind[SyntaxKind["JSDocReadonlyTag"] = 330] = "JSDocReadonlyTag"; + SyntaxKind[SyntaxKind["JSDocOverrideTag"] = 331] = "JSDocOverrideTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 332] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocEnumTag"] = 333] = "JSDocEnumTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 334] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 335] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocThisTag"] = 336] = "JSDocThisTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 337] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 338] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 339] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocSeeTag"] = 340] = "JSDocSeeTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 341] = "JSDocPropertyTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 334] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 342] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 335] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 336] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["CommaListExpression"] = 337] = "CommaListExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 338] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 339] = "EndOfDeclarationMarker"; - SyntaxKind[SyntaxKind["SyntheticReferenceExpression"] = 340] = "SyntheticReferenceExpression"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 343] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 344] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 345] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 346] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 347] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["SyntheticReferenceExpression"] = 348] = "SyntheticReferenceExpression"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 341] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 349] = "Count"; // Markers - SyntaxKind[SyntaxKind["FirstAssignment"] = 62] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 77] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 63] = "FirstCompoundAssignment"; - SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 77] = "LastCompoundAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 80] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 115] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 80] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 156] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 116] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 124] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 172] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 195] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 63] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 78] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 64] = "FirstCompoundAssignment"; + SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 78] = "LastCompoundAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 81] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 116] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 81] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 158] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 117] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 125] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 174] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 197] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 18] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 77] = "LastPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 78] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 156] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 158] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; @@ -4298,16 +4412,16 @@ var ts; SyntaxKind[SyntaxKind["FirstTemplateToken"] = 14] = "FirstTemplateToken"; SyntaxKind[SyntaxKind["LastTemplateToken"] = 17] = "LastTemplateToken"; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 29] = "FirstBinaryOperator"; - SyntaxKind[SyntaxKind["LastBinaryOperator"] = 77] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstStatement"] = 232] = "FirstStatement"; - SyntaxKind[SyntaxKind["LastStatement"] = 248] = "LastStatement"; - SyntaxKind[SyntaxKind["FirstNode"] = 157] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 301] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 333] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 314] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 333] = "LastJSDocTagNode"; - /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 125] = "FirstContextualKeyword"; - /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 156] = "LastContextualKeyword"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 78] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstStatement"] = 234] = "FirstStatement"; + SyntaxKind[SyntaxKind["LastStatement"] = 250] = "LastStatement"; + SyntaxKind[SyntaxKind["FirstNode"] = 159] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 303] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 341] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 321] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 341] = "LastJSDocTagNode"; + /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 126] = "FirstContextualKeyword"; + /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 158] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); var NodeFlags; (function (NodeFlags) { @@ -4377,14 +4491,15 @@ var ts; ModifierFlags[ModifierFlags["Const"] = 2048] = "Const"; ModifierFlags[ModifierFlags["HasComputedJSDocModifiers"] = 4096] = "HasComputedJSDocModifiers"; ModifierFlags[ModifierFlags["Deprecated"] = 8192] = "Deprecated"; + ModifierFlags[ModifierFlags["Override"] = 16384] = "Override"; ModifierFlags[ModifierFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; ModifierFlags[ModifierFlags["AccessibilityModifier"] = 28] = "AccessibilityModifier"; // Accessibility modifiers and 'readonly' can be attached to a parameter in a constructor to make it a property. - ModifierFlags[ModifierFlags["ParameterPropertyModifier"] = 92] = "ParameterPropertyModifier"; + ModifierFlags[ModifierFlags["ParameterPropertyModifier"] = 16476] = "ParameterPropertyModifier"; ModifierFlags[ModifierFlags["NonPublicAccessibilityModifier"] = 24] = "NonPublicAccessibilityModifier"; - ModifierFlags[ModifierFlags["TypeScriptModifier"] = 2270] = "TypeScriptModifier"; + ModifierFlags[ModifierFlags["TypeScriptModifier"] = 18654] = "TypeScriptModifier"; ModifierFlags[ModifierFlags["ExportDefault"] = 513] = "ExportDefault"; - ModifierFlags[ModifierFlags["All"] = 11263] = "All"; + ModifierFlags[ModifierFlags["All"] = 27647] = "All"; })(ModifierFlags = ts.ModifierFlags || (ts.ModifierFlags = {})); var JsxFlags; (function (JsxFlags) { @@ -4565,6 +4680,8 @@ var ts; NodeBuilderFlags[NodeBuilderFlags["NoUndefinedOptionalParameterType"] = 1073741824] = "NoUndefinedOptionalParameterType"; // Error handling NodeBuilderFlags[NodeBuilderFlags["AllowThisInObjectLiteral"] = 32768] = "AllowThisInObjectLiteral"; + NodeBuilderFlags[NodeBuilderFlags["AllowQualifiedNameInPlaceOfIdentifier"] = 65536] = "AllowQualifiedNameInPlaceOfIdentifier"; + /** @deprecated AllowQualifedNameInPlaceOfIdentifier. Use AllowQualifiedNameInPlaceOfIdentifier instead. */ NodeBuilderFlags[NodeBuilderFlags["AllowQualifedNameInPlaceOfIdentifier"] = 65536] = "AllowQualifedNameInPlaceOfIdentifier"; NodeBuilderFlags[NodeBuilderFlags["AllowAnonymousIdentifier"] = 131072] = "AllowAnonymousIdentifier"; NodeBuilderFlags[NodeBuilderFlags["AllowEmptyUnionOrIntersection"] = 262144] = "AllowEmptyUnionOrIntersection"; @@ -4579,7 +4696,6 @@ var ts; NodeBuilderFlags[NodeBuilderFlags["InObjectTypeLiteral"] = 4194304] = "InObjectTypeLiteral"; NodeBuilderFlags[NodeBuilderFlags["InTypeAlias"] = 8388608] = "InTypeAlias"; NodeBuilderFlags[NodeBuilderFlags["InInitialEntityName"] = 16777216] = "InInitialEntityName"; - NodeBuilderFlags[NodeBuilderFlags["InReverseMappedType"] = 33554432] = "InReverseMappedType"; })(NodeBuilderFlags = ts.NodeBuilderFlags || (ts.NodeBuilderFlags = {})); // Ensure the shared flags between this and `NodeBuilderFlags` stay in alignment var TypeFormatFlags; @@ -4884,10 +5000,6 @@ var ts; TypeFlags[TypeFlags["Unit"] = 109440] = "Unit"; TypeFlags[TypeFlags["StringOrNumberLiteral"] = 384] = "StringOrNumberLiteral"; /* @internal */ - TypeFlags[TypeFlags["StringLikeLiteral"] = 134217856] = "StringLikeLiteral"; - /* @internal */ - TypeFlags[TypeFlags["FreshableLiteral"] = 134220672] = "FreshableLiteral"; - /* @internal */ TypeFlags[TypeFlags["StringOrNumberLiteralOrUnique"] = 8576] = "StringOrNumberLiteralOrUnique"; /* @internal */ TypeFlags[TypeFlags["DefinitelyFalsy"] = 117632] = "DefinitelyFalsy"; @@ -4936,6 +5048,9 @@ var ts; /* @internal */ TypeFlags[TypeFlags["IncludesEmptyObject"] = 16777216] = "IncludesEmptyObject"; })(TypeFlags = ts.TypeFlags || (ts.TypeFlags = {})); + // Types included in TypeFlags.ObjectFlagsType have an objectFlags property. Some ObjectFlags + // are specific to certain types and reuse the same bit position. Those ObjectFlags require a check + // for a certain TypeFlags value to determine their meaning. var ObjectFlags; (function (ObjectFlags) { ObjectFlags[ObjectFlags["Class"] = 1] = "Class"; @@ -4948,50 +5063,59 @@ var ts; ObjectFlags[ObjectFlags["ObjectLiteral"] = 128] = "ObjectLiteral"; ObjectFlags[ObjectFlags["EvolvingArray"] = 256] = "EvolvingArray"; ObjectFlags[ObjectFlags["ObjectLiteralPatternWithComputedProperties"] = 512] = "ObjectLiteralPatternWithComputedProperties"; - ObjectFlags[ObjectFlags["ContainsSpread"] = 1024] = "ContainsSpread"; - ObjectFlags[ObjectFlags["ReverseMapped"] = 2048] = "ReverseMapped"; - ObjectFlags[ObjectFlags["JsxAttributes"] = 4096] = "JsxAttributes"; - ObjectFlags[ObjectFlags["MarkerType"] = 8192] = "MarkerType"; - ObjectFlags[ObjectFlags["JSLiteral"] = 16384] = "JSLiteral"; - ObjectFlags[ObjectFlags["FreshLiteral"] = 32768] = "FreshLiteral"; - ObjectFlags[ObjectFlags["ArrayLiteral"] = 65536] = "ArrayLiteral"; - ObjectFlags[ObjectFlags["ObjectRestType"] = 131072] = "ObjectRestType"; + ObjectFlags[ObjectFlags["ReverseMapped"] = 1024] = "ReverseMapped"; + ObjectFlags[ObjectFlags["JsxAttributes"] = 2048] = "JsxAttributes"; + ObjectFlags[ObjectFlags["MarkerType"] = 4096] = "MarkerType"; + ObjectFlags[ObjectFlags["JSLiteral"] = 8192] = "JSLiteral"; + ObjectFlags[ObjectFlags["FreshLiteral"] = 16384] = "FreshLiteral"; + ObjectFlags[ObjectFlags["ArrayLiteral"] = 32768] = "ArrayLiteral"; /* @internal */ - ObjectFlags[ObjectFlags["PrimitiveUnion"] = 262144] = "PrimitiveUnion"; + ObjectFlags[ObjectFlags["PrimitiveUnion"] = 65536] = "PrimitiveUnion"; /* @internal */ - ObjectFlags[ObjectFlags["ContainsWideningType"] = 524288] = "ContainsWideningType"; + ObjectFlags[ObjectFlags["ContainsWideningType"] = 131072] = "ContainsWideningType"; /* @internal */ - ObjectFlags[ObjectFlags["ContainsObjectOrArrayLiteral"] = 1048576] = "ContainsObjectOrArrayLiteral"; + ObjectFlags[ObjectFlags["ContainsObjectOrArrayLiteral"] = 262144] = "ContainsObjectOrArrayLiteral"; /* @internal */ - ObjectFlags[ObjectFlags["NonInferrableType"] = 2097152] = "NonInferrableType"; + ObjectFlags[ObjectFlags["NonInferrableType"] = 524288] = "NonInferrableType"; /* @internal */ - ObjectFlags[ObjectFlags["IsGenericObjectTypeComputed"] = 4194304] = "IsGenericObjectTypeComputed"; + ObjectFlags[ObjectFlags["CouldContainTypeVariablesComputed"] = 1048576] = "CouldContainTypeVariablesComputed"; /* @internal */ - ObjectFlags[ObjectFlags["IsGenericObjectType"] = 8388608] = "IsGenericObjectType"; + ObjectFlags[ObjectFlags["CouldContainTypeVariables"] = 2097152] = "CouldContainTypeVariables"; + ObjectFlags[ObjectFlags["ClassOrInterface"] = 3] = "ClassOrInterface"; /* @internal */ - ObjectFlags[ObjectFlags["IsGenericIndexTypeComputed"] = 16777216] = "IsGenericIndexTypeComputed"; + ObjectFlags[ObjectFlags["RequiresWidening"] = 393216] = "RequiresWidening"; /* @internal */ - ObjectFlags[ObjectFlags["IsGenericIndexType"] = 33554432] = "IsGenericIndexType"; + ObjectFlags[ObjectFlags["PropagatingFlags"] = 917504] = "PropagatingFlags"; + // Object flags that uniquely identify the kind of ObjectType /* @internal */ - ObjectFlags[ObjectFlags["CouldContainTypeVariablesComputed"] = 67108864] = "CouldContainTypeVariablesComputed"; + ObjectFlags[ObjectFlags["ObjectTypeKindMask"] = 1343] = "ObjectTypeKindMask"; + // Flags that require TypeFlags.Object + ObjectFlags[ObjectFlags["ContainsSpread"] = 4194304] = "ContainsSpread"; + ObjectFlags[ObjectFlags["ObjectRestType"] = 8388608] = "ObjectRestType"; /* @internal */ - ObjectFlags[ObjectFlags["CouldContainTypeVariables"] = 134217728] = "CouldContainTypeVariables"; + ObjectFlags[ObjectFlags["IsClassInstanceClone"] = 16777216] = "IsClassInstanceClone"; + // Flags that require TypeFlags.Object and ObjectFlags.Reference /* @internal */ - ObjectFlags[ObjectFlags["ContainsIntersections"] = 268435456] = "ContainsIntersections"; + ObjectFlags[ObjectFlags["IdenticalBaseTypeCalculated"] = 33554432] = "IdenticalBaseTypeCalculated"; /* @internal */ - ObjectFlags[ObjectFlags["IsNeverIntersectionComputed"] = 268435456] = "IsNeverIntersectionComputed"; + ObjectFlags[ObjectFlags["IdenticalBaseTypeExists"] = 67108864] = "IdenticalBaseTypeExists"; + // Flags that require TypeFlags.UnionOrIntersection or TypeFlags.Substitution /* @internal */ - ObjectFlags[ObjectFlags["IsNeverIntersection"] = 536870912] = "IsNeverIntersection"; + ObjectFlags[ObjectFlags["IsGenericObjectTypeComputed"] = 4194304] = "IsGenericObjectTypeComputed"; /* @internal */ - ObjectFlags[ObjectFlags["IsClassInstanceClone"] = 1073741824] = "IsClassInstanceClone"; - ObjectFlags[ObjectFlags["ClassOrInterface"] = 3] = "ClassOrInterface"; + ObjectFlags[ObjectFlags["IsGenericObjectType"] = 8388608] = "IsGenericObjectType"; /* @internal */ - ObjectFlags[ObjectFlags["RequiresWidening"] = 1572864] = "RequiresWidening"; + ObjectFlags[ObjectFlags["IsGenericIndexTypeComputed"] = 16777216] = "IsGenericIndexTypeComputed"; /* @internal */ - ObjectFlags[ObjectFlags["PropagatingFlags"] = 3670016] = "PropagatingFlags"; - // Object flags that uniquely identify the kind of ObjectType + ObjectFlags[ObjectFlags["IsGenericIndexType"] = 33554432] = "IsGenericIndexType"; + // Flags that require TypeFlags.Union /* @internal */ - ObjectFlags[ObjectFlags["ObjectTypeKindMask"] = 2367] = "ObjectTypeKindMask"; + ObjectFlags[ObjectFlags["ContainsIntersections"] = 67108864] = "ContainsIntersections"; + // Flags that require TypeFlags.Intersection + /* @internal */ + ObjectFlags[ObjectFlags["IsNeverIntersectionComputed"] = 67108864] = "IsNeverIntersectionComputed"; + /* @internal */ + ObjectFlags[ObjectFlags["IsNeverIntersection"] = 134217728] = "IsNeverIntersection"; })(ObjectFlags = ts.ObjectFlags || (ts.ObjectFlags = {})); /* @internal */ var VarianceFlags; @@ -5018,6 +5142,21 @@ var ts; ElementFlags[ElementFlags["NonRest"] = 11] = "NonRest"; })(ElementFlags = ts.ElementFlags || (ts.ElementFlags = {})); /* @internal */ + var AccessFlags; + (function (AccessFlags) { + AccessFlags[AccessFlags["None"] = 0] = "None"; + AccessFlags[AccessFlags["IncludeUndefined"] = 1] = "IncludeUndefined"; + AccessFlags[AccessFlags["NoIndexSignatures"] = 2] = "NoIndexSignatures"; + AccessFlags[AccessFlags["Writing"] = 4] = "Writing"; + AccessFlags[AccessFlags["CacheSymbol"] = 8] = "CacheSymbol"; + AccessFlags[AccessFlags["NoTupleBoundsCheck"] = 16] = "NoTupleBoundsCheck"; + AccessFlags[AccessFlags["ExpressionPosition"] = 32] = "ExpressionPosition"; + AccessFlags[AccessFlags["ReportDeprecated"] = 64] = "ReportDeprecated"; + AccessFlags[AccessFlags["SuppressNoImplicitAnyError"] = 128] = "SuppressNoImplicitAnyError"; + AccessFlags[AccessFlags["Contextual"] = 256] = "Contextual"; + AccessFlags[AccessFlags["Persistent"] = 1] = "Persistent"; + })(AccessFlags = ts.AccessFlags || (ts.AccessFlags = {})); + /* @internal */ var JsxReferenceKind; (function (JsxReferenceKind) { JsxReferenceKind[JsxReferenceKind["Component"] = 0] = "Component"; @@ -5065,16 +5204,17 @@ var ts; (function (InferencePriority) { InferencePriority[InferencePriority["NakedTypeVariable"] = 1] = "NakedTypeVariable"; InferencePriority[InferencePriority["SpeculativeTuple"] = 2] = "SpeculativeTuple"; - InferencePriority[InferencePriority["HomomorphicMappedType"] = 4] = "HomomorphicMappedType"; - InferencePriority[InferencePriority["PartialHomomorphicMappedType"] = 8] = "PartialHomomorphicMappedType"; - InferencePriority[InferencePriority["MappedTypeConstraint"] = 16] = "MappedTypeConstraint"; - InferencePriority[InferencePriority["ContravariantConditional"] = 32] = "ContravariantConditional"; - InferencePriority[InferencePriority["ReturnType"] = 64] = "ReturnType"; - InferencePriority[InferencePriority["LiteralKeyof"] = 128] = "LiteralKeyof"; - InferencePriority[InferencePriority["NoConstraints"] = 256] = "NoConstraints"; - InferencePriority[InferencePriority["AlwaysStrict"] = 512] = "AlwaysStrict"; - InferencePriority[InferencePriority["MaxValue"] = 1024] = "MaxValue"; - InferencePriority[InferencePriority["PriorityImpliesCombination"] = 208] = "PriorityImpliesCombination"; + InferencePriority[InferencePriority["SubstituteSource"] = 4] = "SubstituteSource"; + InferencePriority[InferencePriority["HomomorphicMappedType"] = 8] = "HomomorphicMappedType"; + InferencePriority[InferencePriority["PartialHomomorphicMappedType"] = 16] = "PartialHomomorphicMappedType"; + InferencePriority[InferencePriority["MappedTypeConstraint"] = 32] = "MappedTypeConstraint"; + InferencePriority[InferencePriority["ContravariantConditional"] = 64] = "ContravariantConditional"; + InferencePriority[InferencePriority["ReturnType"] = 128] = "ReturnType"; + InferencePriority[InferencePriority["LiteralKeyof"] = 256] = "LiteralKeyof"; + InferencePriority[InferencePriority["NoConstraints"] = 512] = "NoConstraints"; + InferencePriority[InferencePriority["AlwaysStrict"] = 1024] = "AlwaysStrict"; + InferencePriority[InferencePriority["MaxValue"] = 2048] = "MaxValue"; + InferencePriority[InferencePriority["PriorityImpliesCombination"] = 416] = "PriorityImpliesCombination"; InferencePriority[InferencePriority["Circularity"] = -1] = "Circularity"; })(InferencePriority = ts.InferencePriority || (ts.InferencePriority = {})); /* @internal */ @@ -5152,20 +5292,23 @@ var ts; WatchFileKind[WatchFileKind["FixedPollingInterval"] = 0] = "FixedPollingInterval"; WatchFileKind[WatchFileKind["PriorityPollingInterval"] = 1] = "PriorityPollingInterval"; WatchFileKind[WatchFileKind["DynamicPriorityPolling"] = 2] = "DynamicPriorityPolling"; - WatchFileKind[WatchFileKind["UseFsEvents"] = 3] = "UseFsEvents"; - WatchFileKind[WatchFileKind["UseFsEventsOnParentDirectory"] = 4] = "UseFsEventsOnParentDirectory"; + WatchFileKind[WatchFileKind["FixedChunkSizePolling"] = 3] = "FixedChunkSizePolling"; + WatchFileKind[WatchFileKind["UseFsEvents"] = 4] = "UseFsEvents"; + WatchFileKind[WatchFileKind["UseFsEventsOnParentDirectory"] = 5] = "UseFsEventsOnParentDirectory"; })(WatchFileKind = ts.WatchFileKind || (ts.WatchFileKind = {})); var WatchDirectoryKind; (function (WatchDirectoryKind) { WatchDirectoryKind[WatchDirectoryKind["UseFsEvents"] = 0] = "UseFsEvents"; WatchDirectoryKind[WatchDirectoryKind["FixedPollingInterval"] = 1] = "FixedPollingInterval"; WatchDirectoryKind[WatchDirectoryKind["DynamicPriorityPolling"] = 2] = "DynamicPriorityPolling"; + WatchDirectoryKind[WatchDirectoryKind["FixedChunkSizePolling"] = 3] = "FixedChunkSizePolling"; })(WatchDirectoryKind = ts.WatchDirectoryKind || (ts.WatchDirectoryKind = {})); var PollingWatchKind; (function (PollingWatchKind) { PollingWatchKind[PollingWatchKind["FixedInterval"] = 0] = "FixedInterval"; PollingWatchKind[PollingWatchKind["PriorityInterval"] = 1] = "PriorityInterval"; PollingWatchKind[PollingWatchKind["DynamicPriority"] = 2] = "DynamicPriority"; + PollingWatchKind[PollingWatchKind["FixedChunkSize"] = 3] = "FixedChunkSize"; })(PollingWatchKind = ts.PollingWatchKind || (ts.PollingWatchKind = {})); var ModuleKind; (function (ModuleKind) { @@ -5226,6 +5369,7 @@ var ts; ScriptTarget[ScriptTarget["ES2018"] = 5] = "ES2018"; ScriptTarget[ScriptTarget["ES2019"] = 6] = "ES2019"; ScriptTarget[ScriptTarget["ES2020"] = 7] = "ES2020"; + ScriptTarget[ScriptTarget["ES2021"] = 8] = "ES2021"; ScriptTarget[ScriptTarget["ESNext"] = 99] = "ESNext"; ScriptTarget[ScriptTarget["JSON"] = 100] = "JSON"; ScriptTarget[ScriptTarget["Latest"] = 99] = "Latest"; @@ -5388,29 +5532,30 @@ var ts; TransformFlags[TransformFlags["ContainsTypeScript"] = 1] = "ContainsTypeScript"; TransformFlags[TransformFlags["ContainsJsx"] = 2] = "ContainsJsx"; TransformFlags[TransformFlags["ContainsESNext"] = 4] = "ContainsESNext"; - TransformFlags[TransformFlags["ContainsES2020"] = 8] = "ContainsES2020"; - TransformFlags[TransformFlags["ContainsES2019"] = 16] = "ContainsES2019"; - TransformFlags[TransformFlags["ContainsES2018"] = 32] = "ContainsES2018"; - TransformFlags[TransformFlags["ContainsES2017"] = 64] = "ContainsES2017"; - TransformFlags[TransformFlags["ContainsES2016"] = 128] = "ContainsES2016"; - TransformFlags[TransformFlags["ContainsES2015"] = 256] = "ContainsES2015"; - TransformFlags[TransformFlags["ContainsGenerator"] = 512] = "ContainsGenerator"; - TransformFlags[TransformFlags["ContainsDestructuringAssignment"] = 1024] = "ContainsDestructuringAssignment"; + TransformFlags[TransformFlags["ContainsES2021"] = 8] = "ContainsES2021"; + TransformFlags[TransformFlags["ContainsES2020"] = 16] = "ContainsES2020"; + TransformFlags[TransformFlags["ContainsES2019"] = 32] = "ContainsES2019"; + TransformFlags[TransformFlags["ContainsES2018"] = 64] = "ContainsES2018"; + TransformFlags[TransformFlags["ContainsES2017"] = 128] = "ContainsES2017"; + TransformFlags[TransformFlags["ContainsES2016"] = 256] = "ContainsES2016"; + TransformFlags[TransformFlags["ContainsES2015"] = 512] = "ContainsES2015"; + TransformFlags[TransformFlags["ContainsGenerator"] = 1024] = "ContainsGenerator"; + TransformFlags[TransformFlags["ContainsDestructuringAssignment"] = 2048] = "ContainsDestructuringAssignment"; // Markers // - Flags used to indicate that a subtree contains a specific transformation. - TransformFlags[TransformFlags["ContainsTypeScriptClassSyntax"] = 2048] = "ContainsTypeScriptClassSyntax"; - TransformFlags[TransformFlags["ContainsLexicalThis"] = 4096] = "ContainsLexicalThis"; - TransformFlags[TransformFlags["ContainsRestOrSpread"] = 8192] = "ContainsRestOrSpread"; - TransformFlags[TransformFlags["ContainsObjectRestOrSpread"] = 16384] = "ContainsObjectRestOrSpread"; - TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 32768] = "ContainsComputedPropertyName"; - TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 65536] = "ContainsBlockScopedBinding"; - TransformFlags[TransformFlags["ContainsBindingPattern"] = 131072] = "ContainsBindingPattern"; - TransformFlags[TransformFlags["ContainsYield"] = 262144] = "ContainsYield"; - TransformFlags[TransformFlags["ContainsAwait"] = 524288] = "ContainsAwait"; - TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 1048576] = "ContainsHoistedDeclarationOrCompletion"; - TransformFlags[TransformFlags["ContainsDynamicImport"] = 2097152] = "ContainsDynamicImport"; - TransformFlags[TransformFlags["ContainsClassFields"] = 4194304] = "ContainsClassFields"; - TransformFlags[TransformFlags["ContainsPossibleTopLevelAwait"] = 8388608] = "ContainsPossibleTopLevelAwait"; + TransformFlags[TransformFlags["ContainsTypeScriptClassSyntax"] = 4096] = "ContainsTypeScriptClassSyntax"; + TransformFlags[TransformFlags["ContainsLexicalThis"] = 8192] = "ContainsLexicalThis"; + TransformFlags[TransformFlags["ContainsRestOrSpread"] = 16384] = "ContainsRestOrSpread"; + TransformFlags[TransformFlags["ContainsObjectRestOrSpread"] = 32768] = "ContainsObjectRestOrSpread"; + TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 65536] = "ContainsComputedPropertyName"; + TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 131072] = "ContainsBlockScopedBinding"; + TransformFlags[TransformFlags["ContainsBindingPattern"] = 262144] = "ContainsBindingPattern"; + TransformFlags[TransformFlags["ContainsYield"] = 524288] = "ContainsYield"; + TransformFlags[TransformFlags["ContainsAwait"] = 1048576] = "ContainsAwait"; + TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 2097152] = "ContainsHoistedDeclarationOrCompletion"; + TransformFlags[TransformFlags["ContainsDynamicImport"] = 4194304] = "ContainsDynamicImport"; + TransformFlags[TransformFlags["ContainsClassFields"] = 8388608] = "ContainsClassFields"; + TransformFlags[TransformFlags["ContainsPossibleTopLevelAwait"] = 16777216] = "ContainsPossibleTopLevelAwait"; // 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 @@ -5420,37 +5565,38 @@ var ts; TransformFlags[TransformFlags["AssertTypeScript"] = 1] = "AssertTypeScript"; TransformFlags[TransformFlags["AssertJsx"] = 2] = "AssertJsx"; TransformFlags[TransformFlags["AssertESNext"] = 4] = "AssertESNext"; - TransformFlags[TransformFlags["AssertES2020"] = 8] = "AssertES2020"; - TransformFlags[TransformFlags["AssertES2019"] = 16] = "AssertES2019"; - TransformFlags[TransformFlags["AssertES2018"] = 32] = "AssertES2018"; - TransformFlags[TransformFlags["AssertES2017"] = 64] = "AssertES2017"; - TransformFlags[TransformFlags["AssertES2016"] = 128] = "AssertES2016"; - TransformFlags[TransformFlags["AssertES2015"] = 256] = "AssertES2015"; - TransformFlags[TransformFlags["AssertGenerator"] = 512] = "AssertGenerator"; - TransformFlags[TransformFlags["AssertDestructuringAssignment"] = 1024] = "AssertDestructuringAssignment"; + TransformFlags[TransformFlags["AssertES2021"] = 8] = "AssertES2021"; + TransformFlags[TransformFlags["AssertES2020"] = 16] = "AssertES2020"; + TransformFlags[TransformFlags["AssertES2019"] = 32] = "AssertES2019"; + TransformFlags[TransformFlags["AssertES2018"] = 64] = "AssertES2018"; + TransformFlags[TransformFlags["AssertES2017"] = 128] = "AssertES2017"; + TransformFlags[TransformFlags["AssertES2016"] = 256] = "AssertES2016"; + TransformFlags[TransformFlags["AssertES2015"] = 512] = "AssertES2015"; + TransformFlags[TransformFlags["AssertGenerator"] = 1024] = "AssertGenerator"; + TransformFlags[TransformFlags["AssertDestructuringAssignment"] = 2048] = "AssertDestructuringAssignment"; // 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"] = 547309568] = "ArrowFunctionExcludes"; - TransformFlags[TransformFlags["FunctionExcludes"] = 547313664] = "FunctionExcludes"; - TransformFlags[TransformFlags["ConstructorExcludes"] = 547311616] = "ConstructorExcludes"; - TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 538923008] = "MethodOrAccessorExcludes"; - TransformFlags[TransformFlags["PropertyExcludes"] = 536875008] = "PropertyExcludes"; - TransformFlags[TransformFlags["ClassExcludes"] = 536905728] = "ClassExcludes"; - TransformFlags[TransformFlags["ModuleExcludes"] = 546379776] = "ModuleExcludes"; + TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 557748224] = "ArrowFunctionExcludes"; + TransformFlags[TransformFlags["FunctionExcludes"] = 557756416] = "FunctionExcludes"; + TransformFlags[TransformFlags["ConstructorExcludes"] = 557752320] = "ConstructorExcludes"; + TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 540975104] = "MethodOrAccessorExcludes"; + TransformFlags[TransformFlags["PropertyExcludes"] = 536879104] = "PropertyExcludes"; + TransformFlags[TransformFlags["ClassExcludes"] = 536940544] = "ClassExcludes"; + TransformFlags[TransformFlags["ModuleExcludes"] = 555888640] = "ModuleExcludes"; TransformFlags[TransformFlags["TypeExcludes"] = -2] = "TypeExcludes"; - TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 536922112] = "ObjectLiteralExcludes"; - TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 536879104] = "ArrayLiteralOrCallOrNewExcludes"; - TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 537018368] = "VariableDeclarationListExcludes"; + TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 536973312] = "ObjectLiteralExcludes"; + TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 536887296] = "ArrayLiteralOrCallOrNewExcludes"; + TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 537165824] = "VariableDeclarationListExcludes"; TransformFlags[TransformFlags["ParameterExcludes"] = 536870912] = "ParameterExcludes"; - TransformFlags[TransformFlags["CatchClauseExcludes"] = 536887296] = "CatchClauseExcludes"; - TransformFlags[TransformFlags["BindingPatternExcludes"] = 536879104] = "BindingPatternExcludes"; + TransformFlags[TransformFlags["CatchClauseExcludes"] = 536903680] = "CatchClauseExcludes"; + TransformFlags[TransformFlags["BindingPatternExcludes"] = 536887296] = "BindingPatternExcludes"; // Propagating flags // - Bitmasks for flags that should propagate from a child - TransformFlags[TransformFlags["PropertyNamePropagatingFlags"] = 4096] = "PropertyNamePropagatingFlags"; + TransformFlags[TransformFlags["PropertyNamePropagatingFlags"] = 8192] = "PropertyNamePropagatingFlags"; // Masks // - Additional bitmasks })(TransformFlags = ts.TransformFlags || (ts.TransformFlags = {})); @@ -6048,6 +6194,11 @@ var ts; * Normalize path separators, converting `\` into `/`. */ function normalizeSlashes(path) { + var index = path.indexOf("\\"); + if (index === -1) { + return path; + } + backslashRegExp.lastIndex = index; // prime regex with known position return path.replace(backslashRegExp, ts.directorySeparator); } ts.normalizeSlashes = normalizeSlashes; @@ -6158,6 +6309,19 @@ var ts; ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath; function normalizePath(path) { path = normalizeSlashes(path); + // Most paths don't require normalization + if (!relativePathSegmentRegExp.test(path)) { + return path; + } + // Some paths only require cleanup of `/./` or leading `./` + var simplified = path.replace(/\/\.\//g, "/").replace(/^\.\//, ""); + if (simplified !== path) { + path = simplified; + if (!relativePathSegmentRegExp.test(path)) { + return path; + } + } + // Other paths require full normalization var normalized = getPathFromPathComponents(reducePathComponents(getPathComponents(path))); return normalized && hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalized) : normalized; } @@ -6226,7 +6390,7 @@ var ts; ts.changeAnyExtension = changeAnyExtension; //// Path Comparisons // check path for these segments: '', '.'. '..' - var relativePathSegmentRegExp = /(^|\/)\.{0,2}($|\/)/; + var relativePathSegmentRegExp = /(?:\/\/)|(?:^|\/)\.\.?(?:$|\/)/; function comparePathsWorker(a, b, componentComparer) { if (a === b) return 0 /* EqualTo */; @@ -6318,7 +6482,7 @@ var ts; * Determines whether `fileName` starts with the specified `directoryName` using the provided path canonicalization callback. * Comparison is case-sensitive between the canonical paths. * - * @deprecated Use `containsPath` if possible. + * Use `containsPath` if file names are not already reduced and absolute. */ function startsWithDirectory(fileName, directoryName, getCanonicalFileName) { var canonicalFileName = getCanonicalFileName(fileName); @@ -6438,6 +6602,11 @@ var ts; })(PollingInterval = ts.PollingInterval || (ts.PollingInterval = {})); /* @internal */ ts.missingFileModifiedTime = new Date(0); // Any subsequent modification will occur after this time + /* @internal */ + function getModifiedTime(host, fileName) { + return host.getModifiedTime(fileName) || ts.missingFileModifiedTime; + } + ts.getModifiedTime = getModifiedTime; function createPollingIntervalBasedLevels(levels) { var _a; return _a = {}, @@ -6494,6 +6663,51 @@ var ts; } } ts.setCustomPollingValues = setCustomPollingValues; + function pollWatchedFileQueue(host, queue, pollIndex, chunkSize, callbackOnWatchFileStat) { + var definedValueCopyToIndex = pollIndex; + // Max visit would be all elements of the queue + for (var canVisit = queue.length; chunkSize && canVisit; nextPollIndex(), canVisit--) { + var watchedFile = queue[pollIndex]; + if (!watchedFile) { + continue; + } + else if (watchedFile.isClosed) { + queue[pollIndex] = undefined; + continue; + } + // Only files polled count towards chunkSize + chunkSize--; + var fileChanged = onWatchedFileStat(watchedFile, getModifiedTime(host, watchedFile.fileName)); + if (watchedFile.isClosed) { + // Closed watcher as part of callback + queue[pollIndex] = undefined; + continue; + } + callbackOnWatchFileStat === null || callbackOnWatchFileStat === void 0 ? void 0 : callbackOnWatchFileStat(watchedFile, pollIndex, fileChanged); + // Defragment the queue while we are at it + if (queue[pollIndex]) { + // Copy this file to the non hole location + if (definedValueCopyToIndex < pollIndex) { + queue[definedValueCopyToIndex] = watchedFile; + queue[pollIndex] = undefined; + } + definedValueCopyToIndex++; + } + } + // Return next poll index + return pollIndex; + function nextPollIndex() { + pollIndex++; + if (pollIndex === queue.length) { + if (definedValueCopyToIndex < pollIndex) { + // There are holes from definedValueCopyToIndex to end of queue, change queue size + queue.length = definedValueCopyToIndex; + } + pollIndex = 0; + definedValueCopyToIndex = 0; + } + } + } /* @internal */ function createDynamicPriorityPollingWatchFile(host) { var watchedFiles = []; @@ -6507,7 +6721,7 @@ var ts; fileName: fileName, callback: callback, unchangedPolls: 0, - mtime: getModifiedTime(fileName) + mtime: getModifiedTime(host, fileName) }; watchedFiles.push(file); addToPollingIntervalQueue(file, defaultPollingInterval); @@ -6550,25 +6764,9 @@ var ts; } } function pollQueue(queue, pollingInterval, pollIndex, chunkSize) { - // Max visit would be all elements of the queue - var needsVisit = queue.length; - var definedValueCopyToIndex = pollIndex; - for (var polled = 0; polled < chunkSize && needsVisit > 0; nextPollIndex(), needsVisit--) { - var watchedFile = queue[pollIndex]; - if (!watchedFile) { - continue; - } - else if (watchedFile.isClosed) { - queue[pollIndex] = undefined; - continue; - } - polled++; - var fileChanged = onWatchedFileStat(watchedFile, getModifiedTime(watchedFile.fileName)); - if (watchedFile.isClosed) { - // Closed watcher as part of callback - queue[pollIndex] = undefined; - } - else if (fileChanged) { + return pollWatchedFileQueue(host, queue, pollIndex, chunkSize, onWatchFileStat); + function onWatchFileStat(watchedFile, pollIndex, fileChanged) { + if (fileChanged) { watchedFile.unchangedPolls = 0; // Changed files go to changedFilesInLastPoll queue if (queue !== changedFilesInLastPoll) { @@ -6590,27 +6788,6 @@ var ts; queue[pollIndex] = undefined; addToPollingIntervalQueue(watchedFile, pollingInterval === PollingInterval.Low ? PollingInterval.Medium : PollingInterval.High); } - if (queue[pollIndex]) { - // Copy this file to the non hole location - if (definedValueCopyToIndex < pollIndex) { - queue[definedValueCopyToIndex] = watchedFile; - queue[pollIndex] = undefined; - } - definedValueCopyToIndex++; - } - } - // Return next poll index - return pollIndex; - function nextPollIndex() { - pollIndex++; - if (pollIndex === queue.length) { - if (definedValueCopyToIndex < pollIndex) { - // There are holes from nextDefinedValueIndex to end of queue, change queue size - queue.length = definedValueCopyToIndex; - } - pollIndex = 0; - definedValueCopyToIndex = 0; - } } } function pollingIntervalQueue(pollingInterval) { @@ -6639,9 +6816,6 @@ var ts; function scheduleNextPoll(pollingInterval) { pollingIntervalQueue(pollingInterval).pollScheduled = host.setTimeout(pollingInterval === PollingInterval.Low ? pollLowPollingIntervalQueue : pollPollingIntervalQueue, pollingInterval, pollingIntervalQueue(pollingInterval)); } - function getModifiedTime(fileName) { - return host.getModifiedTime(fileName) || ts.missingFileModifiedTime; - } } ts.createDynamicPriorityPollingWatchFile = createDynamicPriorityPollingWatchFile; function createUseFsEventsOnParentDirectoryWatchFile(fsWatch, useCaseSensitiveFileNames) { @@ -6692,6 +6866,37 @@ var ts; return watcher; } } + function createFixedChunkSizePollingWatchFile(host) { + var watchedFiles = []; + var pollIndex = 0; + var pollScheduled; + return watchFile; + function watchFile(fileName, callback) { + var file = { + fileName: fileName, + callback: callback, + mtime: getModifiedTime(host, fileName) + }; + watchedFiles.push(file); + scheduleNextPoll(); + return { + close: function () { + file.isClosed = true; + ts.unorderedRemoveItem(watchedFiles, file); + } + }; + } + function pollQueue() { + pollScheduled = undefined; + pollIndex = pollWatchedFileQueue(host, watchedFiles, pollIndex, pollingChunkSize[PollingInterval.Low]); + scheduleNextPoll(); + } + function scheduleNextPoll() { + if (!watchedFiles.length || pollScheduled) + return; + pollScheduled = host.setTimeout(pollQueue, PollingInterval.High); + } + } /* @internal */ function createSingleFileWatcherPerName(watchFile, useCaseSensitiveFileNames) { var cache = new ts.Map(); @@ -7014,8 +7219,9 @@ var ts; } /*@internal*/ function createSystemWatchFunctions(_a) { - var pollingWatchFile = _a.pollingWatchFile, getModifiedTime = _a.getModifiedTime, setTimeout = _a.setTimeout, clearTimeout = _a.clearTimeout, fsWatch = _a.fsWatch, fileExists = _a.fileExists, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, getCurrentDirectory = _a.getCurrentDirectory, fsSupportsRecursiveFsWatch = _a.fsSupportsRecursiveFsWatch, directoryExists = _a.directoryExists, getAccessibleSortedChildDirectories = _a.getAccessibleSortedChildDirectories, realpath = _a.realpath, tscWatchFile = _a.tscWatchFile, useNonPollingWatchers = _a.useNonPollingWatchers, tscWatchDirectory = _a.tscWatchDirectory; + var pollingWatchFile = _a.pollingWatchFile, getModifiedTime = _a.getModifiedTime, setTimeout = _a.setTimeout, clearTimeout = _a.clearTimeout, fsWatch = _a.fsWatch, fileExists = _a.fileExists, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, getCurrentDirectory = _a.getCurrentDirectory, fsSupportsRecursiveFsWatch = _a.fsSupportsRecursiveFsWatch, directoryExists = _a.directoryExists, getAccessibleSortedChildDirectories = _a.getAccessibleSortedChildDirectories, realpath = _a.realpath, tscWatchFile = _a.tscWatchFile, useNonPollingWatchers = _a.useNonPollingWatchers, tscWatchDirectory = _a.tscWatchDirectory, defaultWatchFileKind = _a.defaultWatchFileKind; var dynamicPollingWatchFile; + var fixedChunkSizePollingWatchFile; var nonPollingWatchFile; var hostRecursiveDirectoryWatcher; return { @@ -7032,6 +7238,8 @@ var ts; return pollingWatchFile(fileName, callback, pollingInterval, /*options*/ undefined); case ts.WatchFileKind.DynamicPriorityPolling: return ensureDynamicPollingWatchFile()(fileName, callback, pollingInterval, /*options*/ undefined); + case ts.WatchFileKind.FixedChunkSizePolling: + return ensureFixedChunkSizePollingWatchFile()(fileName, callback, /* pollingInterval */ undefined, /*options*/ undefined); case ts.WatchFileKind.UseFsEvents: return fsWatch(fileName, 0 /* File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists), /*recursive*/ false, pollingInterval, ts.getFallbackOptions(options)); @@ -7045,8 +7253,10 @@ var ts; } } function ensureDynamicPollingWatchFile() { - return dynamicPollingWatchFile || - (dynamicPollingWatchFile = createDynamicPriorityPollingWatchFile({ getModifiedTime: getModifiedTime, setTimeout: setTimeout })); + return dynamicPollingWatchFile || (dynamicPollingWatchFile = createDynamicPriorityPollingWatchFile({ getModifiedTime: getModifiedTime, setTimeout: setTimeout })); + } + function ensureFixedChunkSizePollingWatchFile() { + return fixedChunkSizePollingWatchFile || (fixedChunkSizePollingWatchFile = createFixedChunkSizePollingWatchFile({ getModifiedTime: getModifiedTime, setTimeout: setTimeout })); } function updateOptionsForWatchFile(options, useNonPollingWatchers) { if (options && options.watchFile !== undefined) @@ -7072,7 +7282,7 @@ var ts; // Use notifications from FS to watch with falling back to fs.watchFile generateWatchFileOptions(ts.WatchFileKind.UseFsEventsOnParentDirectory, ts.PollingWatchKind.PriorityInterval, options) : // Default to do not use fixed polling interval - { watchFile: ts.WatchFileKind.FixedPollingInterval }; + { watchFile: (defaultWatchFileKind === null || defaultWatchFileKind === void 0 ? void 0 : defaultWatchFileKind()) || ts.WatchFileKind.FixedPollingInterval }; } } function generateWatchFileOptions(watchFile, fallbackPolling, options) { @@ -7113,6 +7323,10 @@ var ts; case ts.WatchDirectoryKind.DynamicPriorityPolling: return ensureDynamicPollingWatchFile()(directoryName, function () { return callback(directoryName); }, PollingInterval.Medium, /*options*/ undefined); + case ts.WatchDirectoryKind.FixedChunkSizePolling: + return ensureFixedChunkSizePollingWatchFile()(directoryName, function () { return callback(directoryName); }, + /* 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)); default: @@ -7191,13 +7405,13 @@ var ts; } var activeSession; var profilePath = "./profile.cpuprofile"; - var realpathSync = (_a = _fs.realpathSync.native) !== null && _a !== void 0 ? _a : _fs.realpathSync; var Buffer = require("buffer").Buffer; var nodeVersion = getNodeMajorVersion(); var isNode4OrLater = nodeVersion >= 4; var isLinuxOrMacOs = process.platform === "linux" || process.platform === "darwin"; var platform = _os.platform(); var useCaseSensitiveFileNames = isFileSystemCaseSensitive(); + var realpathSync = useCaseSensitiveFileNames ? ((_a = _fs.realpathSync.native) !== null && _a !== void 0 ? _a : _fs.realpathSync) : _fs.realpathSync; var fsSupportsRecursiveFsWatch = isNode4OrLater && (process.platform === "win32" || process.platform === "darwin"); var getCurrentDirectory = ts.memoize(function () { return process.cwd(); }); var _c = createSystemWatchFunctions({ @@ -7218,6 +7432,7 @@ var ts; tscWatchFile: process.env.TSC_WATCHFILE, useNonPollingWatchers: process.env.TSC_NONPOLLING_WATCHER, tscWatchDirectory: process.env.TSC_WATCHDIRECTORY, + defaultWatchFileKind: function () { var _a, _b; return (_b = (_a = sys).defaultWatchFileKind) === null || _b === void 0 ? void 0 : _b.call(_a); }, }), watchFile = _c.watchFile, watchDirectory = _c.watchDirectory; var nodeSystem = { args: process.argv.slice(2), @@ -7286,6 +7501,7 @@ var ts; }, enableCPUProfiler: enableCPUProfiler, disableCPUProfiler: disableCPUProfiler, + cpuProfilingEnabled: function () { return !!activeSession || ts.contains(process.execArgv, "--cpu-prof") || ts.contains(process.execArgv, "--prof"); }, realpath: realpath, debugMode: !!process.env.NODE_INSPECTOR_IPC || !!process.env.VSCODE_INSPECTOR_OPTIONS || ts.some(process.execArgv, function (arg) { return /^--(inspect|debug)(-brk)?(=\d+)?$/i.test(arg); }), tryEnableSourceMapsForHost: function () { @@ -7535,7 +7751,7 @@ var ts; return event === "rename" && (!relativeName || relativeName === lastDirectoryPart || - relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length) && + (relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) !== -1 && relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length)) && !fileSystemEntryExists(fileOrDirectory, entryKind) ? invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry) : callback(event, relativeName); @@ -7845,9 +8061,10 @@ var ts; Invalid_use_of_0_in_strict_mode: diag(1100, ts.DiagnosticCategory.Error, "Invalid_use_of_0_in_strict_mode_1100", "Invalid use of '{0}' in strict mode."), with_statements_are_not_allowed_in_strict_mode: diag(1101, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_strict_mode_1101", "'with' statements are not allowed in strict mode."), delete_cannot_be_called_on_an_identifier_in_strict_mode: diag(1102, ts.DiagnosticCategory.Error, "delete_cannot_be_called_on_an_identifier_in_strict_mode_1102", "'delete' cannot be called on an identifier in strict mode."), - A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator: diag(1103, ts.DiagnosticCategory.Error, "A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator_1103", "A 'for-await-of' statement is only allowed within an async function or async generator."), + for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1103, ts.DiagnosticCategory.Error, "for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1103", "'for await' loops are only allowed within async functions and at the top levels of modules."), A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: diag(1104, ts.DiagnosticCategory.Error, "A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement_1104", "A 'continue' statement can only be used within an enclosing iteration statement."), A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: diag(1105, ts.DiagnosticCategory.Error, "A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement_1105", "A 'break' statement can only be used within an enclosing iteration or switch statement."), + The_left_hand_side_of_a_for_of_statement_may_not_be_async: diag(1106, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_of_statement_may_not_be_async_1106", "The left-hand side of a 'for...of' statement may not be 'async'."), Jump_target_cannot_cross_function_boundary: diag(1107, ts.DiagnosticCategory.Error, "Jump_target_cannot_cross_function_boundary_1107", "Jump target cannot cross function boundary."), A_return_statement_can_only_be_used_within_a_function_body: diag(1108, ts.DiagnosticCategory.Error, "A_return_statement_can_only_be_used_within_a_function_body_1108", "A 'return' statement can only be used within a function body."), Expression_expected: diag(1109, ts.DiagnosticCategory.Error, "Expression_expected_1109", "Expression expected."), @@ -7894,7 +8111,7 @@ var ts; A_yield_expression_is_only_allowed_in_a_generator_body: diag(1163, ts.DiagnosticCategory.Error, "A_yield_expression_is_only_allowed_in_a_generator_body_1163", "A 'yield' expression is only allowed in a generator body."), Computed_property_names_are_not_allowed_in_enums: diag(1164, ts.DiagnosticCategory.Error, "Computed_property_names_are_not_allowed_in_enums_1164", "Computed property names are not allowed in enums."), A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1165, ts.DiagnosticCategory.Error, "A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_t_1165", "A computed property name in an ambient context must refer to an expression whose type is a literal type or a 'unique symbol' type."), - A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1166, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_1166", "A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type."), + A_computed_property_name_in_a_class_property_declaration_must_have_a_simple_literal_type_or_a_unique_symbol_type: diag(1166, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_class_property_declaration_must_have_a_simple_literal_type_or_a_unique_1166", "A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type."), A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1168, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_ty_1168", "A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type."), A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1169, ts.DiagnosticCategory.Error, "A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_1169", "A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type."), A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1170, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type__1170", "A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type."), @@ -7954,7 +8171,7 @@ var ts; A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: diag(1228, ts.DiagnosticCategory.Error, "A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods_1228", "A type predicate is only allowed in return type position for functions and methods."), A_type_predicate_cannot_reference_a_rest_parameter: diag(1229, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_a_rest_parameter_1229", "A type predicate cannot reference a rest parameter."), A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: diag(1230, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_element_0_in_a_binding_pattern_1230", "A type predicate cannot reference element '{0}' in a binding pattern."), - An_export_assignment_can_only_be_used_in_a_module: diag(1231, ts.DiagnosticCategory.Error, "An_export_assignment_can_only_be_used_in_a_module_1231", "An export assignment can only be used in a module."), + An_export_assignment_must_be_at_the_top_level_of_a_file_or_module_declaration: diag(1231, ts.DiagnosticCategory.Error, "An_export_assignment_must_be_at_the_top_level_of_a_file_or_module_declaration_1231", "An export assignment must be at the top level of a file or module declaration."), An_import_declaration_can_only_be_used_in_a_namespace_or_module: diag(1232, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_in_a_namespace_or_module_1232", "An import declaration can only be used in a namespace or module."), An_export_declaration_can_only_be_used_in_a_module: diag(1233, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_in_a_module_1233", "An export declaration can only be used in a module."), An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: diag(1234, ts.DiagnosticCategory.Error, "An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file_1234", "An ambient module declaration is only allowed at the top level in a file."), @@ -7980,6 +8197,7 @@ var ts; A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_reference: diag(1254, ts.DiagnosticCategory.Error, "A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_refere_1254", "A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference."), A_definite_assignment_assertion_is_not_permitted_in_this_context: diag(1255, ts.DiagnosticCategory.Error, "A_definite_assignment_assertion_is_not_permitted_in_this_context_1255", "A definite assignment assertion '!' is not permitted in this context."), A_required_element_cannot_follow_an_optional_element: diag(1257, ts.DiagnosticCategory.Error, "A_required_element_cannot_follow_an_optional_element_1257", "A required element cannot follow an optional element."), + A_default_export_must_be_at_the_top_level_of_a_file_or_module_declaration: diag(1258, ts.DiagnosticCategory.Error, "A_default_export_must_be_at_the_top_level_of_a_file_or_module_declaration_1258", "A default export must be at the top level of a file or module declaration."), Module_0_can_only_be_default_imported_using_the_1_flag: diag(1259, ts.DiagnosticCategory.Error, "Module_0_can_only_be_default_imported_using_the_1_flag_1259", "Module '{0}' can only be default-imported using the '{1}' flag"), Keywords_cannot_contain_escape_characters: diag(1260, ts.DiagnosticCategory.Error, "Keywords_cannot_contain_escape_characters_1260", "Keywords cannot contain escape characters."), Already_included_file_name_0_differs_from_file_name_1_only_in_casing: diag(1261, ts.DiagnosticCategory.Error, "Already_included_file_name_0_differs_from_file_name_1_only_in_casing_1261", "Already included file name '{0}' differs from file name '{1}' only in casing."), @@ -7988,6 +8206,7 @@ var ts; Declarations_with_definite_assignment_assertions_must_also_have_type_annotations: diag(1264, ts.DiagnosticCategory.Error, "Declarations_with_definite_assignment_assertions_must_also_have_type_annotations_1264", "Declarations with definite assignment assertions must also have type annotations."), A_rest_element_cannot_follow_another_rest_element: diag(1265, ts.DiagnosticCategory.Error, "A_rest_element_cannot_follow_another_rest_element_1265", "A rest element cannot follow another rest element."), An_optional_element_cannot_follow_a_rest_element: diag(1266, ts.DiagnosticCategory.Error, "An_optional_element_cannot_follow_a_rest_element_1266", "An optional element cannot follow a rest element."), + Property_0_cannot_have_an_initializer_because_it_is_marked_abstract: diag(1267, ts.DiagnosticCategory.Error, "Property_0_cannot_have_an_initializer_because_it_is_marked_abstract_1267", "Property '{0}' cannot have an initializer because it is marked abstract."), with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1308, ts.DiagnosticCategory.Error, "await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1308", "'await' expressions are only allowed within async functions and at the top levels of modules."), 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: diag(1312, ts.DiagnosticCategory.Error, "Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_1312", "Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern."), @@ -8066,7 +8285,7 @@ var ts; Constructor_type_notation_must_be_parenthesized_when_used_in_an_intersection_type: diag(1388, ts.DiagnosticCategory.Error, "Constructor_type_notation_must_be_parenthesized_when_used_in_an_intersection_type_1388", "Constructor type notation must be parenthesized when used in an intersection type."), _0_is_not_allowed_as_a_variable_declaration_name: diag(1389, ts.DiagnosticCategory.Error, "_0_is_not_allowed_as_a_variable_declaration_name_1389", "'{0}' is not allowed as a variable declaration name."), Provides_a_root_package_name_when_using_outFile_with_declarations: diag(1390, ts.DiagnosticCategory.Message, "Provides_a_root_package_name_when_using_outFile_with_declarations_1390", "Provides a root package name when using outFile with declarations."), - The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_declaration_emit: diag(1391, ts.DiagnosticCategory.Error, "The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_de_1391", "The `bundledPackageName` option must be provided when using outFile and node module resolution with declaration emit."), + The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_declaration_emit: diag(1391, ts.DiagnosticCategory.Error, "The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_de_1391", "The 'bundledPackageName' option must be provided when using outFile and node module resolution with declaration emit."), An_import_alias_cannot_use_import_type: diag(1392, ts.DiagnosticCategory.Error, "An_import_alias_cannot_use_import_type_1392", "An import alias cannot use 'import type'"), Imported_via_0_from_file_1: diag(1393, ts.DiagnosticCategory.Message, "Imported_via_0_from_file_1_1393", "Imported via {0} from file '{1}'"), Imported_via_0_from_file_1_with_packageId_2: diag(1394, ts.DiagnosticCategory.Message, "Imported_via_0_from_file_1_with_packageId_2_1394", "Imported via {0} from file '{1}' with packageId '{2}'"), @@ -8106,6 +8325,9 @@ var ts; File_is_output_of_project_reference_source_0: diag(1428, ts.DiagnosticCategory.Message, "File_is_output_of_project_reference_source_0_1428", "File is output of project reference source '{0}'"), File_redirects_to_file_0: diag(1429, ts.DiagnosticCategory.Message, "File_redirects_to_file_0_1429", "File redirects to file '{0}'"), The_file_is_in_the_program_because_Colon: diag(1430, ts.DiagnosticCategory.Message, "The_file_is_in_the_program_because_Colon_1430", "The file is in the program because:"), + for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module: diag(1431, ts.DiagnosticCategory.Error, "for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_1431", "'for await' loops are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module."), + Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher: diag(1432, ts.DiagnosticCategory.Error, "Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_1432", "Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher."), + Decorators_may_not_be_applied_to_this_parameters: diag(1433, ts.DiagnosticCategory.Error, "Decorators_may_not_be_applied_to_this_parameters_1433", "Decorators may not be applied to 'this' parameters."), 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), @@ -8173,7 +8395,7 @@ var ts; The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2358, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter."), The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: diag(2359, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type."), The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: diag(2360, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol_2360", "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'."), - The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2361, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter_2361", "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter."), + The_right_hand_side_of_an_in_expression_must_not_be_a_primitive: diag(2361, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_in_expression_must_not_be_a_primitive_2361", "The right-hand side of an 'in' expression must not be a primitive."), The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2362, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2362", "The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."), The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2363, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2363", "The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."), The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: diag(2364, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", "The left-hand side of an assignment expression must be a variable or a property access."), @@ -8191,8 +8413,7 @@ var ts; A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_parameter_properties_or_private_identifiers: diag(2376, ts.DiagnosticCategory.Error, "A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_proper_2376", "A 'super' call must be the first statement in the constructor when a class contains initialized properties, parameter properties, or private identifiers."), Constructors_for_derived_classes_must_contain_a_super_call: diag(2377, ts.DiagnosticCategory.Error, "Constructors_for_derived_classes_must_contain_a_super_call_2377", "Constructors for derived classes must contain a 'super' call."), A_get_accessor_must_return_a_value: diag(2378, ts.DiagnosticCategory.Error, "A_get_accessor_must_return_a_value_2378", "A 'get' accessor must return a value."), - Getter_and_setter_accessors_do_not_agree_in_visibility: diag(2379, ts.DiagnosticCategory.Error, "Getter_and_setter_accessors_do_not_agree_in_visibility_2379", "Getter and setter accessors do not agree in visibility."), - get_and_set_accessor_must_have_the_same_type: diag(2380, ts.DiagnosticCategory.Error, "get_and_set_accessor_must_have_the_same_type_2380", "'get' and 'set' accessor must have the same type."), + The_return_type_of_a_get_accessor_must_be_assignable_to_its_set_accessor_type: diag(2380, ts.DiagnosticCategory.Error, "The_return_type_of_a_get_accessor_must_be_assignable_to_its_set_accessor_type_2380", "The return type of a 'get' accessor must be assignable to its 'set' accessor type"), A_signature_with_an_implementation_cannot_use_a_string_literal_type: diag(2381, ts.DiagnosticCategory.Error, "A_signature_with_an_implementation_cannot_use_a_string_literal_type_2381", "A signature with an implementation cannot use a string literal type."), Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: diag(2382, ts.DiagnosticCategory.Error, "Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature_2382", "Specialized overload signature is not assignable to any non-specialized signature."), Overload_signatures_must_all_be_exported_or_non_exported: diag(2383, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_exported_or_non_exported_2383", "Overload signatures must all be exported or non-exported."), @@ -8255,7 +8476,7 @@ var ts; Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2: diag(2443, ts.DiagnosticCategory.Error, "Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2_2443", "Property '{0}' is protected but type '{1}' is not a class derived from '{2}'."), Property_0_is_protected_in_type_1_but_public_in_type_2: diag(2444, ts.DiagnosticCategory.Error, "Property_0_is_protected_in_type_1_but_public_in_type_2_2444", "Property '{0}' is protected in type '{1}' but public in type '{2}'."), Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses: diag(2445, ts.DiagnosticCategory.Error, "Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses_2445", "Property '{0}' is protected and only accessible within class '{1}' and its subclasses."), - Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: diag(2446, ts.DiagnosticCategory.Error, "Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_2446", "Property '{0}' is protected and only accessible through an instance of class '{1}'."), + Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_This_is_an_instance_of_class_2: diag(2446, ts.DiagnosticCategory.Error, "Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_This_is_an_instance_of_cl_2446", "Property '{0}' is protected and only accessible through an instance of class '{1}'. This is an instance of class '{2}'."), The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: diag(2447, ts.DiagnosticCategory.Error, "The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead_2447", "The '{0}' operator is not allowed for boolean types. Consider using '{1}' instead."), Block_scoped_variable_0_used_before_its_declaration: diag(2448, ts.DiagnosticCategory.Error, "Block_scoped_variable_0_used_before_its_declaration_2448", "Block-scoped variable '{0}' used before its declaration."), Class_0_used_before_its_declaration: diag(2449, ts.DiagnosticCategory.Error, "Class_0_used_before_its_declaration_2449", "Class '{0}' used before its declaration."), @@ -8355,14 +8576,13 @@ var ts; The_type_returned_by_the_0_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_property: diag(2547, ts.DiagnosticCategory.Error, "The_type_returned_by_the_0_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_pro_2547", "The type returned by the '{0}()' method of an async iterator must be a promise for a type with a 'value' property."), Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator: diag(2548, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator_2548", "Type '{0}' is not an array type or does not have a '[Symbol.iterator]()' method that returns an iterator."), Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator: diag(2549, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns__2549", "Type '{0}' is not an array type or a string type or does not have a '[Symbol.iterator]()' method that returns an iterator."), - Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2_or_later: diag(2550, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_c_2550", "Property '{0}' does not exist on type '{1}'. Do you need to change your target library? Try changing the `lib` compiler option to '{2}' or later."), + Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2_or_later: diag(2550, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_c_2550", "Property '{0}' does not exist on type '{1}'. Do you need to change your target library? Try changing the 'lib' compiler option to '{2}' or later."), Property_0_does_not_exist_on_type_1_Did_you_mean_2: diag(2551, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Did_you_mean_2_2551", "Property '{0}' does not exist on type '{1}'. Did you mean '{2}'?"), Cannot_find_name_0_Did_you_mean_1: diag(2552, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Did_you_mean_1_2552", "Cannot find name '{0}'. Did you mean '{1}'?"), Computed_values_are_not_permitted_in_an_enum_with_string_valued_members: diag(2553, ts.DiagnosticCategory.Error, "Computed_values_are_not_permitted_in_an_enum_with_string_valued_members_2553", "Computed values are not permitted in an enum with string valued members."), Expected_0_arguments_but_got_1: diag(2554, ts.DiagnosticCategory.Error, "Expected_0_arguments_but_got_1_2554", "Expected {0} arguments, but got {1}."), Expected_at_least_0_arguments_but_got_1: diag(2555, ts.DiagnosticCategory.Error, "Expected_at_least_0_arguments_but_got_1_2555", "Expected at least {0} arguments, but got {1}."), - Expected_0_arguments_but_got_1_or_more: diag(2556, ts.DiagnosticCategory.Error, "Expected_0_arguments_but_got_1_or_more_2556", "Expected {0} arguments, but got {1} or more."), - Expected_at_least_0_arguments_but_got_1_or_more: diag(2557, ts.DiagnosticCategory.Error, "Expected_at_least_0_arguments_but_got_1_or_more_2557", "Expected at least {0} arguments, but got {1} or more."), + A_spread_argument_must_either_have_a_tuple_type_or_be_passed_to_a_rest_parameter: diag(2556, ts.DiagnosticCategory.Error, "A_spread_argument_must_either_have_a_tuple_type_or_be_passed_to_a_rest_parameter_2556", "A spread argument must either have a tuple type or be passed to a rest parameter."), Expected_0_type_arguments_but_got_1: diag(2558, ts.DiagnosticCategory.Error, "Expected_0_type_arguments_but_got_1_2558", "Expected {0} type arguments, but got {1}."), Type_0_has_no_properties_in_common_with_type_1: diag(2559, ts.DiagnosticCategory.Error, "Type_0_has_no_properties_in_common_with_type_1_2559", "Type '{0}' has no properties in common with type '{1}'."), Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it: diag(2560, ts.DiagnosticCategory.Error, "Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it_2560", "Value of type '{0}' has no properties in common with type '{1}'. Did you mean to call it?"), @@ -8385,17 +8605,17 @@ var ts; Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode: diag(2580, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashno_2580", "Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`."), Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery: diag(2581, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slash_2581", "Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i --save-dev @types/jquery`."), Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_types_Slashjest_or_npm_i_save_dev_types_Slashmocha: diag(2582, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_type_2582", "Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`."), - Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_1_or_later: diag(2583, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2583", "Cannot find name '{0}'. Do you need to change your target library? Try changing the `lib` compiler option to '{1}' or later."), - Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_include_dom: diag(2584, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2584", "Cannot find name '{0}'. Do you need to change your target library? Try changing the `lib` compiler option to include 'dom'."), - _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: diag(2585, ts.DiagnosticCategory.Error, "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_2585", "'{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."), + Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_1_or_later: diag(2583, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2583", "Cannot find name '{0}'. Do you need to change your target library? Try changing the 'lib' compiler option to '{1}' or later."), + Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_include_dom: diag(2584, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2584", "Cannot find name '{0}'. Do you need to change your target library? Try changing the 'lib' compiler option to include 'dom'."), + _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: diag(2585, ts.DiagnosticCategory.Error, "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_2585", "'{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."), Enum_type_0_circularly_references_itself: diag(2586, ts.DiagnosticCategory.Error, "Enum_type_0_circularly_references_itself_2586", "Enum type '{0}' circularly references itself."), JSDoc_type_0_circularly_references_itself: diag(2587, ts.DiagnosticCategory.Error, "JSDoc_type_0_circularly_references_itself_2587", "JSDoc type '{0}' circularly references itself."), Cannot_assign_to_0_because_it_is_a_constant: diag(2588, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_a_constant_2588", "Cannot assign to '{0}' because it is a constant."), Type_instantiation_is_excessively_deep_and_possibly_infinite: diag(2589, ts.DiagnosticCategory.Error, "Type_instantiation_is_excessively_deep_and_possibly_infinite_2589", "Type instantiation is excessively deep and possibly infinite."), Expression_produces_a_union_type_that_is_too_complex_to_represent: diag(2590, ts.DiagnosticCategory.Error, "Expression_produces_a_union_type_that_is_too_complex_to_represent_2590", "Expression produces a union type that is too complex to represent."), - Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode_and_then_add_node_to_the_types_field_in_your_tsconfig: diag(2591, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashno_2591", "Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node` and then add `node` to the types field in your tsconfig."), - Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery_and_then_add_jquery_to_the_types_field_in_your_tsconfig: diag(2592, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slash_2592", "Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i --save-dev @types/jquery` and then add `jquery` to the types field in your tsconfig."), - Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_types_Slashjest_or_npm_i_save_dev_types_Slashmocha_and_then_add_jest_or_mocha_to_the_types_field_in_your_tsconfig: diag(2593, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_type_2593", "Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode_and_then_add_node_to_the_types_field_in_your_tsconfig: diag(2591, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashno_2591", "Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node` and then add 'node' to the types field in your tsconfig."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery_and_then_add_jquery_to_the_types_field_in_your_tsconfig: diag(2592, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slash_2592", "Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i --save-dev @types/jquery` and then add 'jquery' to the types field in your tsconfig."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_types_Slashjest_or_npm_i_save_dev_types_Slashmocha_and_then_add_jest_or_mocha_to_the_types_field_in_your_tsconfig: diag(2593, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_type_2593", "Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig."), This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag: diag(2594, ts.DiagnosticCategory.Error, "This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the__2594", "This module is declared with using 'export =', and can only be used with a default import when using the '{0}' flag."), _0_can_only_be_imported_by_using_a_default_import: diag(2595, ts.DiagnosticCategory.Error, "_0_can_only_be_imported_by_using_a_default_import_2595", "'{0}' can only be imported by using a default import."), _0_can_only_be_imported_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import: diag(2596, ts.DiagnosticCategory.Error, "_0_can_only_be_imported_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import_2596", "'{0}' can only be imported by turning on the 'esModuleInterop' flag and using a default import."), @@ -8428,6 +8648,12 @@ var ts; Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target: diag(2625, ts.DiagnosticCategory.Error, "Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target_2625", "Variadic element at position {0} in source does not match element at position {1} in target."), Type_at_position_0_in_source_is_not_compatible_with_type_at_position_1_in_target: diag(2626, ts.DiagnosticCategory.Error, "Type_at_position_0_in_source_is_not_compatible_with_type_at_position_1_in_target_2626", "Type at position {0} in source is not compatible with type at position {1} in target."), Type_at_positions_0_through_1_in_source_is_not_compatible_with_type_at_position_2_in_target: diag(2627, ts.DiagnosticCategory.Error, "Type_at_positions_0_through_1_in_source_is_not_compatible_with_type_at_position_2_in_target_2627", "Type at positions {0} through {1} in source is not compatible with type at position {2} in target."), + Cannot_assign_to_0_because_it_is_an_enum: diag(2628, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_an_enum_2628", "Cannot assign to '{0}' because it is an enum."), + Cannot_assign_to_0_because_it_is_a_class: diag(2629, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_a_class_2629", "Cannot assign to '{0}' because it is a class."), + Cannot_assign_to_0_because_it_is_a_function: diag(2630, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_a_function_2630", "Cannot assign to '{0}' because it is a function."), + Cannot_assign_to_0_because_it_is_a_namespace: diag(2631, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_a_namespace_2631", "Cannot assign to '{0}' because it is a namespace."), + Cannot_assign_to_0_because_it_is_an_import: diag(2632, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_an_import_2632", "Cannot assign to '{0}' because it is an import."), + JSX_property_access_expressions_cannot_include_JSX_namespace_names: diag(2633, ts.DiagnosticCategory.Error, "JSX_property_access_expressions_cannot_include_JSX_namespace_names_2633", "JSX property access expressions cannot include JSX namespace names"), Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: diag(2649, ts.DiagnosticCategory.Error, "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", "Cannot augment module '{0}' with value exports because it resolves to a non-module entity."), A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: diag(2651, ts.DiagnosticCategory.Error, "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums."), Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: diag(2652, ts.DiagnosticCategory.Error, "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead."), @@ -8474,7 +8700,7 @@ var ts; Namespace_0_has_no_exported_member_1: diag(2694, ts.DiagnosticCategory.Error, "Namespace_0_has_no_exported_member_1_2694", "Namespace '{0}' has no exported member '{1}'."), Left_side_of_comma_operator_is_unused_and_has_no_side_effects: diag(2695, ts.DiagnosticCategory.Error, "Left_side_of_comma_operator_is_unused_and_has_no_side_effects_2695", "Left side of comma operator is unused and has no side effects.", /*reportsUnnecessary*/ true), The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead: diag(2696, ts.DiagnosticCategory.Error, "The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead_2696", "The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?"), - An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: diag(2697, ts.DiagnosticCategory.Error, "An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_in_2697", "An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option."), + An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: diag(2697, ts.DiagnosticCategory.Error, "An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_in_2697", "An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your '--lib' option."), Spread_types_may_only_be_created_from_object_types: diag(2698, ts.DiagnosticCategory.Error, "Spread_types_may_only_be_created_from_object_types_2698", "Spread types may only be created from object types."), Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1: diag(2699, ts.DiagnosticCategory.Error, "Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1_2699", "Static property '{0}' conflicts with built-in property 'Function.{0}' of constructor function '{1}'."), Rest_types_may_only_be_created_from_object_types: diag(2700, ts.DiagnosticCategory.Error, "Rest_types_may_only_be_created_from_object_types_2700", "Rest types may only be created from object types."), @@ -8482,14 +8708,14 @@ var ts; _0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here: diag(2702, ts.DiagnosticCategory.Error, "_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here_2702", "'{0}' only refers to a type, but is being used as a namespace here."), The_operand_of_a_delete_operator_must_be_a_property_reference: diag(2703, ts.DiagnosticCategory.Error, "The_operand_of_a_delete_operator_must_be_a_property_reference_2703", "The operand of a 'delete' operator must be a property reference."), The_operand_of_a_delete_operator_cannot_be_a_read_only_property: diag(2704, ts.DiagnosticCategory.Error, "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704", "The operand of a 'delete' operator cannot be a read-only property."), - 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: diag(2705, ts.DiagnosticCategory.Error, "An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_de_2705", "An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option."), + 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: diag(2705, ts.DiagnosticCategory.Error, "An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_de_2705", "An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option."), Required_type_parameters_may_not_follow_optional_type_parameters: diag(2706, ts.DiagnosticCategory.Error, "Required_type_parameters_may_not_follow_optional_type_parameters_2706", "Required type parameters may not follow optional type parameters."), Generic_type_0_requires_between_1_and_2_type_arguments: diag(2707, ts.DiagnosticCategory.Error, "Generic_type_0_requires_between_1_and_2_type_arguments_2707", "Generic type '{0}' requires between {1} and {2} type arguments."), Cannot_use_namespace_0_as_a_value: diag(2708, ts.DiagnosticCategory.Error, "Cannot_use_namespace_0_as_a_value_2708", "Cannot use namespace '{0}' as a value."), Cannot_use_namespace_0_as_a_type: diag(2709, ts.DiagnosticCategory.Error, "Cannot_use_namespace_0_as_a_type_2709", "Cannot use namespace '{0}' as a type."), _0_are_specified_twice_The_attribute_named_0_will_be_overwritten: diag(2710, ts.DiagnosticCategory.Error, "_0_are_specified_twice_The_attribute_named_0_will_be_overwritten_2710", "'{0}' are specified twice. The attribute named '{0}' will be overwritten."), - A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: diag(2711, ts.DiagnosticCategory.Error, "A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES20_2711", "A dynamic import call returns a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option."), - A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option: diag(2712, ts.DiagnosticCategory.Error, "A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declarat_2712", "A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option."), + A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: diag(2711, ts.DiagnosticCategory.Error, "A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES20_2711", "A dynamic import call returns a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your '--lib' option."), + A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option: diag(2712, ts.DiagnosticCategory.Error, "A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declarat_2712", "A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option."), 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: diag(2713, ts.DiagnosticCategory.Error, "Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_p_2713", "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}\"]'?"), The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context: diag(2714, ts.DiagnosticCategory.Error, "The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context_2714", "The expression of an export assignment must be an identifier or qualified name in an ambient context."), Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor: diag(2715, ts.DiagnosticCategory.Error, "Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor_2715", "Abstract property '{0}' in class '{1}' cannot be accessed in the constructor."), @@ -8551,7 +8777,7 @@ var ts; The_last_overload_is_declared_here: diag(2771, ts.DiagnosticCategory.Error, "The_last_overload_is_declared_here_2771", "The last overload is declared here."), Overload_0_of_1_2_gave_the_following_error: diag(2772, ts.DiagnosticCategory.Error, "Overload_0_of_1_2_gave_the_following_error_2772", "Overload {0} of {1}, '{2}', gave the following error."), Did_you_forget_to_use_await: diag(2773, ts.DiagnosticCategory.Error, "Did_you_forget_to_use_await_2773", "Did you forget to use 'await'?"), - This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead: diag(2774, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it__2774", "This condition will always return true since the function is always defined. Did you mean to call it instead?"), + This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_instead: diag(2774, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_2774", "This condition will always return true since this function is always defined. Did you mean to call it instead?"), Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation: diag(2775, ts.DiagnosticCategory.Error, "Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation_2775", "Assertions require every name in the call target to be declared with an explicit type annotation."), Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name: diag(2776, ts.DiagnosticCategory.Error, "Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name_2776", "Assertions require the call target to be an identifier or qualified name."), The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access: diag(2777, ts.DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access_2777", "The operand of an increment or decrement operator may not be an optional property access."), @@ -8575,6 +8801,23 @@ var ts; The_intrinsic_keyword_can_only_be_used_to_declare_compiler_provided_intrinsic_types: diag(2795, ts.DiagnosticCategory.Error, "The_intrinsic_keyword_can_only_be_used_to_declare_compiler_provided_intrinsic_types_2795", "The 'intrinsic' keyword can only be used to declare compiler provided intrinsic types."), It_is_likely_that_you_are_missing_a_comma_to_separate_these_two_template_expressions_They_form_a_tagged_template_expression_which_cannot_be_invoked: diag(2796, ts.DiagnosticCategory.Error, "It_is_likely_that_you_are_missing_a_comma_to_separate_these_two_template_expressions_They_form_a_tag_2796", "It is likely that you are missing a comma to separate these two template expressions. They form a tagged template expression which cannot be invoked."), A_mixin_class_that_extends_from_a_type_variable_containing_an_abstract_construct_signature_must_also_be_declared_abstract: diag(2797, ts.DiagnosticCategory.Error, "A_mixin_class_that_extends_from_a_type_variable_containing_an_abstract_construct_signature_must_also_2797", "A mixin class that extends from a type variable containing an abstract construct signature must also be declared 'abstract'."), + The_declaration_was_marked_as_deprecated_here: diag(2798, ts.DiagnosticCategory.Error, "The_declaration_was_marked_as_deprecated_here_2798", "The declaration was marked as deprecated here."), + Type_produces_a_tuple_type_that_is_too_large_to_represent: diag(2799, ts.DiagnosticCategory.Error, "Type_produces_a_tuple_type_that_is_too_large_to_represent_2799", "Type produces a tuple type that is too large to represent."), + Expression_produces_a_tuple_type_that_is_too_large_to_represent: diag(2800, ts.DiagnosticCategory.Error, "Expression_produces_a_tuple_type_that_is_too_large_to_represent_2800", "Expression produces a tuple type that is too large to represent."), + This_condition_will_always_return_true_since_this_0_is_always_defined: diag(2801, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_this_0_is_always_defined_2801", "This condition will always return true since this '{0}' is always defined."), + Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher: diag(2802, ts.DiagnosticCategory.Error, "Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es201_2802", "Type '{0}' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher."), + Cannot_assign_to_private_method_0_Private_methods_are_not_writable: diag(2803, ts.DiagnosticCategory.Error, "Cannot_assign_to_private_method_0_Private_methods_are_not_writable_2803", "Cannot assign to private method '{0}'. Private methods are not writable."), + Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name: diag(2804, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name_2804", "Duplicate identifier '{0}'. Static and instance elements cannot share the same private name."), + Static_fields_with_private_names_can_t_have_initializers_when_the_useDefineForClassFields_flag_is_not_specified_with_a_target_of_esnext_Consider_adding_the_useDefineForClassFields_flag: diag(2805, ts.DiagnosticCategory.Error, "Static_fields_with_private_names_can_t_have_initializers_when_the_useDefineForClassFields_flag_is_no_2805", "Static fields with private names can't have initializers when the '--useDefineForClassFields' flag is not specified with a '--target' of 'esnext'. Consider adding the '--useDefineForClassFields' flag."), + Private_accessor_was_defined_without_a_getter: diag(2806, ts.DiagnosticCategory.Error, "Private_accessor_was_defined_without_a_getter_2806", "Private accessor was defined without a getter."), + 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: diag(2807, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807", "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}'."), + A_get_accessor_must_be_at_least_as_accessible_as_the_setter: diag(2808, ts.DiagnosticCategory.Error, "A_get_accessor_must_be_at_least_as_accessible_as_the_setter_2808", "A get accessor must be at least as accessible as the setter"), + 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: diag(2809, ts.DiagnosticCategory.Error, "Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_d_2809", "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."), + Property_0_may_not_be_used_in_a_static_property_s_initializer_in_the_same_class_when_target_is_esnext_and_useDefineForClassFields_is_false: diag(2810, ts.DiagnosticCategory.Error, "Property_0_may_not_be_used_in_a_static_property_s_initializer_in_the_same_class_when_target_is_esnex_2810", "Property '{0}' may not be used in a static property's initializer in the same class when 'target' is 'esnext' and 'useDefineForClassFields' is 'false'."), + Initializer_for_property_0: diag(2811, ts.DiagnosticCategory.Error, "Initializer_for_property_0_2811", "Initializer for property '{0}'"), + Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom: diag(2812, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom_2812", "Property '{0}' does not exist on type '{1}'. Try changing the 'lib' compiler option to include 'dom'."), + Class_declaration_cannot_implement_overload_list_for_0: diag(2813, ts.DiagnosticCategory.Error, "Class_declaration_cannot_implement_overload_list_for_0_2813", "Class declaration cannot implement overload list for '{0}'."), + Function_with_bodies_can_only_merge_with_classes_that_are_ambient: diag(2814, ts.DiagnosticCategory.Error, "Function_with_bodies_can_only_merge_with_classes_that_are_ambient_2814", "Function with bodies can only merge with classes that are ambient."), 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}'."), @@ -8647,6 +8890,7 @@ var ts; Exported_type_alias_0_has_or_is_using_private_name_1: diag(4081, ts.DiagnosticCategory.Error, "Exported_type_alias_0_has_or_is_using_private_name_1_4081", "Exported type alias '{0}' has or is using private name '{1}'."), Default_export_of_the_module_has_or_is_using_private_name_0: diag(4082, ts.DiagnosticCategory.Error, "Default_export_of_the_module_has_or_is_using_private_name_0_4082", "Default export of the module has or is using private name '{0}'."), Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1: diag(4083, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1_4083", "Type parameter '{0}' of exported type alias has or is using private name '{1}'."), + Exported_type_alias_0_has_or_is_using_private_name_1_from_module_2: diag(4084, ts.DiagnosticCategory.Error, "Exported_type_alias_0_has_or_is_using_private_name_1_from_module_2_4084", "Exported type alias '{0}' has or is using private name '{1}' from module {2}."), Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict: diag(4090, ts.DiagnosticCategory.Error, "Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_librar_4090", "Conflicting definitions for '{0}' found at '{1}' and '{2}'. Consider installing a specific version of this library to resolve the conflict."), Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: diag(4091, ts.DiagnosticCategory.Error, "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4091", "Parameter '{0}' of index signature from exported interface has or is using name '{1}' from private module '{2}'."), Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1: diag(4092, ts.DiagnosticCategory.Error, "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1_4092", "Parameter '{0}' of index signature from exported interface has or is using private name '{1}'."), @@ -8668,6 +8912,12 @@ var ts; Type_arguments_for_0_circularly_reference_themselves: diag(4109, ts.DiagnosticCategory.Error, "Type_arguments_for_0_circularly_reference_themselves_4109", "Type arguments for '{0}' circularly reference themselves."), Tuple_type_arguments_circularly_reference_themselves: diag(4110, ts.DiagnosticCategory.Error, "Tuple_type_arguments_circularly_reference_themselves_4110", "Tuple type arguments circularly reference themselves."), Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0: diag(4111, ts.DiagnosticCategory.Error, "Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0_4111", "Property '{0}' comes from an index signature, so it must be accessed with ['{0}']."), + This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class: diag(4112, ts.DiagnosticCategory.Error, "This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another__4112", "This member cannot have an 'override' modifier because its containing class '{0}' does not extend another class."), + This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0: diag(4113, ts.DiagnosticCategory.Error, "This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0_4113", "This member cannot have an 'override' modifier because it is not declared in the base class '{0}'."), + This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0: diag(4114, ts.DiagnosticCategory.Error, "This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0_4114", "This member must have an 'override' modifier because it overrides a member in the base class '{0}'."), + This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0: diag(4115, ts.DiagnosticCategory.Error, "This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0_4115", "This parameter property must have an 'override' modifier because it overrides a member in base class '{0}'."), + This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0: diag(4116, ts.DiagnosticCategory.Error, "This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared__4116", "This member must have an 'override' modifier because it overrides an abstract method that is declared in the base class '{0}'."), + This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1: diag(4117, ts.DiagnosticCategory.Error, "This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0_Did_you__4117", "This member cannot have an 'override' modifier because it is not declared in the base class '{0}'. Did you mean '{1}'?"), The_current_host_does_not_support_the_0_option: diag(5001, ts.DiagnosticCategory.Error, "The_current_host_does_not_support_the_0_option_5001", "The current host does not support the '{0}' option."), Cannot_find_the_common_subdirectory_path_for_the_input_files: diag(5009, ts.DiagnosticCategory.Error, "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", "Cannot find the common subdirectory path for the input files."), File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5010, ts.DiagnosticCategory.Error, "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", "File specification cannot end in a recursive directory wildcard ('**'): '{0}'."), @@ -8702,7 +8952,7 @@ var ts; Option_resolveJsonModule_can_only_be_specified_when_module_code_generation_is_commonjs_amd_es2015_or_esNext: diag(5071, ts.DiagnosticCategory.Error, "Option_resolveJsonModule_can_only_be_specified_when_module_code_generation_is_commonjs_amd_es2015_or_5071", "Option '--resolveJsonModule' can only be specified when module code generation is 'commonjs', 'amd', 'es2015' or 'esNext'."), Unknown_build_option_0: diag(5072, ts.DiagnosticCategory.Error, "Unknown_build_option_0_5072", "Unknown build option '{0}'."), Build_option_0_requires_a_value_of_type_1: diag(5073, ts.DiagnosticCategory.Error, "Build_option_0_requires_a_value_of_type_1_5073", "Build option '{0}' requires a value of type {1}."), - Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified: diag(5074, ts.DiagnosticCategory.Error, "Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBui_5074", "Option '--incremental' can only be specified using tsconfig, emitting to single file or when option `--tsBuildInfoFile` is specified."), + Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified: diag(5074, ts.DiagnosticCategory.Error, "Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBui_5074", "Option '--incremental' can only be specified using tsconfig, emitting to single file or when option '--tsBuildInfoFile' is specified."), _0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2: diag(5075, ts.DiagnosticCategory.Error, "_0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_5075", "'{0}' is assignable to the constraint of type '{1}', but '{1}' could be instantiated with a different subtype of constraint '{2}'."), _0_and_1_operations_cannot_be_mixed_without_parentheses: diag(5076, ts.DiagnosticCategory.Error, "_0_and_1_operations_cannot_be_mixed_without_parentheses_5076", "'{0}' and '{1}' operations cannot be mixed without parentheses."), Unknown_build_option_0_Did_you_mean_1: diag(5077, ts.DiagnosticCategory.Error, "Unknown_build_option_0_Did_you_mean_1_5077", "Unknown build option '{0}'. Did you mean '{1}'?"), @@ -8715,10 +8965,14 @@ var ts; Tuple_members_must_all_have_names_or_all_not_have_names: diag(5084, ts.DiagnosticCategory.Error, "Tuple_members_must_all_have_names_or_all_not_have_names_5084", "Tuple members must all have names or all not have names."), A_tuple_member_cannot_be_both_optional_and_rest: diag(5085, ts.DiagnosticCategory.Error, "A_tuple_member_cannot_be_both_optional_and_rest_5085", "A tuple member cannot be both optional and rest."), A_labeled_tuple_element_is_declared_as_optional_with_a_question_mark_after_the_name_and_before_the_colon_rather_than_after_the_type: diag(5086, ts.DiagnosticCategory.Error, "A_labeled_tuple_element_is_declared_as_optional_with_a_question_mark_after_the_name_and_before_the_c_5086", "A labeled tuple element is declared as optional with a question mark after the name and before the colon, rather than after the type."), - A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type: diag(5087, ts.DiagnosticCategory.Error, "A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type_5087", "A labeled tuple element is declared as rest with a `...` before the name, rather than before the type."), + A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type: diag(5087, ts.DiagnosticCategory.Error, "A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type_5087", "A labeled tuple element is declared as rest with a '...' before the name, rather than before the type."), The_inferred_type_of_0_references_a_type_with_a_cyclic_structure_which_cannot_be_trivially_serialized_A_type_annotation_is_necessary: diag(5088, ts.DiagnosticCategory.Error, "The_inferred_type_of_0_references_a_type_with_a_cyclic_structure_which_cannot_be_trivially_serialize_5088", "The inferred type of '{0}' references a type with a cyclic structure which cannot be trivially serialized. A type annotation is necessary."), Option_0_cannot_be_specified_when_option_jsx_is_1: diag(5089, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_when_option_jsx_is_1_5089", "Option '{0}' cannot be specified when option 'jsx' is '{1}'."), Non_relative_paths_are_not_allowed_when_baseUrl_is_not_set_Did_you_forget_a_leading_Slash: diag(5090, ts.DiagnosticCategory.Error, "Non_relative_paths_are_not_allowed_when_baseUrl_is_not_set_Did_you_forget_a_leading_Slash_5090", "Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?"), + Option_preserveConstEnums_cannot_be_disabled_when_isolatedModules_is_enabled: diag(5091, ts.DiagnosticCategory.Error, "Option_preserveConstEnums_cannot_be_disabled_when_isolatedModules_is_enabled_5091", "Option 'preserveConstEnums' cannot be disabled when 'isolatedModules' is enabled."), + The_root_value_of_a_0_file_must_be_an_object: diag(5092, ts.DiagnosticCategory.Error, "The_root_value_of_a_0_file_must_be_an_object_5092", "The root value of a '{0}' file must be an object."), + Compiler_option_0_may_only_be_used_with_build: diag(5093, ts.DiagnosticCategory.Error, "Compiler_option_0_may_only_be_used_with_build_5093", "Compiler option '--{0}' may only be used with '--build'."), + Compiler_option_0_may_not_be_used_with_build: diag(5094, ts.DiagnosticCategory.Error, "Compiler_option_0_may_not_be_used_with_build_5094", "Compiler option '--{0}' may not be used with '--build'."), Generates_a_sourcemap_for_each_corresponding_d_ts_file: diag(6000, ts.DiagnosticCategory.Message, "Generates_a_sourcemap_for_each_corresponding_d_ts_file_6000", "Generates a sourcemap for each corresponding '.d.ts' file."), Concatenate_and_emit_output_to_single_file: diag(6001, ts.DiagnosticCategory.Message, "Concatenate_and_emit_output_to_single_file_6001", "Concatenate and emit output to single file."), Generates_corresponding_d_ts_file: diag(6002, ts.DiagnosticCategory.Message, "Generates_corresponding_d_ts_file_6002", "Generates corresponding '.d.ts' file."), @@ -8734,7 +8988,7 @@ var ts; Skip_type_checking_of_declaration_files: diag(6012, ts.DiagnosticCategory.Message, "Skip_type_checking_of_declaration_files_6012", "Skip type checking of declaration files."), Do_not_resolve_the_real_path_of_symlinks: diag(6013, ts.DiagnosticCategory.Message, "Do_not_resolve_the_real_path_of_symlinks_6013", "Do not resolve the real path of symlinks."), Only_emit_d_ts_declaration_files: diag(6014, ts.DiagnosticCategory.Message, "Only_emit_d_ts_declaration_files_6014", "Only emit '.d.ts' declaration files."), - Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_or_ESNEXT: diag(6015, ts.DiagnosticCategory.Message, "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_or_6015", "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'."), + Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_ES2021_or_ESNEXT: diag(6015, ts.DiagnosticCategory.Message, "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_ES_6015", "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'."), Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_es2020_or_ESNext: diag(6016, ts.DiagnosticCategory.Message, "Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_es2020_or_ESNext_6016", "Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'."), Print_this_message: diag(6017, ts.DiagnosticCategory.Message, "Print_this_message_6017", "Print this message."), Print_the_compiler_s_version: diag(6019, ts.DiagnosticCategory.Message, "Print_the_compiler_s_version_6019", "Print the compiler's version."), @@ -8877,19 +9131,12 @@ var ts; Show_all_compiler_options: diag(6169, ts.DiagnosticCategory.Message, "Show_all_compiler_options_6169", "Show all compiler options."), Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file: diag(6170, ts.DiagnosticCategory.Message, "Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file_6170", "[Deprecated] Use '--outFile' instead. Concatenate and emit output to single file"), Command_line_Options: diag(6171, ts.DiagnosticCategory.Message, "Command_line_Options_6171", "Command-line Options"), - Basic_Options: diag(6172, ts.DiagnosticCategory.Message, "Basic_Options_6172", "Basic Options"), - Strict_Type_Checking_Options: diag(6173, ts.DiagnosticCategory.Message, "Strict_Type_Checking_Options_6173", "Strict Type-Checking Options"), - Module_Resolution_Options: diag(6174, ts.DiagnosticCategory.Message, "Module_Resolution_Options_6174", "Module Resolution Options"), - Source_Map_Options: diag(6175, ts.DiagnosticCategory.Message, "Source_Map_Options_6175", "Source Map Options"), - Additional_Checks: diag(6176, ts.DiagnosticCategory.Message, "Additional_Checks_6176", "Additional Checks"), - Experimental_Options: diag(6177, ts.DiagnosticCategory.Message, "Experimental_Options_6177", "Experimental Options"), - Advanced_Options: diag(6178, ts.DiagnosticCategory.Message, "Advanced_Options_6178", "Advanced Options"), Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3: diag(6179, ts.DiagnosticCategory.Message, "Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3_6179", "Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'."), Enable_all_strict_type_checking_options: diag(6180, ts.DiagnosticCategory.Message, "Enable_all_strict_type_checking_options_6180", "Enable all strict type-checking options."), List_of_language_service_plugins: diag(6181, ts.DiagnosticCategory.Message, "List_of_language_service_plugins_6181", "List of language service plugins."), Scoped_package_detected_looking_in_0: diag(6182, ts.DiagnosticCategory.Message, "Scoped_package_detected_looking_in_0_6182", "Scoped package detected, looking in '{0}'"), - Reusing_resolution_of_module_0_to_file_1_from_old_program: diag(6183, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_to_file_1_from_old_program_6183", "Reusing resolution of module '{0}' to file '{1}' from old program."), - Reusing_module_resolutions_originating_in_0_since_resolutions_are_unchanged_from_old_program: diag(6184, ts.DiagnosticCategory.Message, "Reusing_module_resolutions_originating_in_0_since_resolutions_are_unchanged_from_old_program_6184", "Reusing module resolutions originating in '{0}' since resolutions are unchanged from old program."), + Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2: diag(6183, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_6183", "Reusing resolution of module '{0}' from '{1}' of old program, it was successfully resolved to '{2}'."), + Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3: diag(6184, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package__6184", "Reusing resolution of module '{0}' from '{1}' of old program, it was successfully resolved to '{2}' with Package ID '{3}'."), Disable_strict_checking_of_generic_signatures_in_function_types: diag(6185, ts.DiagnosticCategory.Message, "Disable_strict_checking_of_generic_signatures_in_function_types_6185", "Disable strict checking of generic signatures in function types."), Enable_strict_checking_of_function_types: diag(6186, ts.DiagnosticCategory.Message, "Enable_strict_checking_of_function_types_6186", "Enable strict checking of function types."), Enable_strict_checking_of_property_initialization_in_classes: diag(6187, ts.DiagnosticCategory.Message, "Enable_strict_checking_of_property_initialization_in_classes_6187", "Enable strict checking of property initialization in classes."), @@ -8929,9 +9176,9 @@ var ts; Emit_class_fields_with_Define_instead_of_Set: diag(6222, ts.DiagnosticCategory.Message, "Emit_class_fields_with_Define_instead_of_Set_6222", "Emit class fields with Define instead of Set."), Generates_a_CPU_profile: diag(6223, ts.DiagnosticCategory.Message, "Generates_a_CPU_profile_6223", "Generates a CPU profile."), Disable_solution_searching_for_this_project: diag(6224, ts.DiagnosticCategory.Message, "Disable_solution_searching_for_this_project_6224", "Disable solution searching for this project."), - Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_DynamicPriorityPolling_UseFsEvents_UseFsEventsOnParentDirectory: diag(6225, ts.DiagnosticCategory.Message, "Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_Dynami_6225", "Specify strategy for watching file: 'FixedPollingInterval' (default), 'PriorityPollingInterval', 'DynamicPriorityPolling', 'UseFsEvents', 'UseFsEventsOnParentDirectory'."), - Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling: diag(6226, ts.DiagnosticCategory.Message, "Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively__6226", "Specify strategy for watching directory on platforms that don't support recursive watching natively: 'UseFsEvents' (default), 'FixedPollingInterval', 'DynamicPriorityPolling'."), - Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority: diag(6227, ts.DiagnosticCategory.Message, "Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_6227", "Specify strategy for creating a polling watch when it fails to create using file system events: 'FixedInterval' (default), 'PriorityInterval', 'DynamicPriority'."), + Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_DynamicPriorityPolling_FixedChunkSizePolling_UseFsEvents_UseFsEventsOnParentDirectory: diag(6225, ts.DiagnosticCategory.Message, "Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_Dynami_6225", "Specify strategy for watching file: 'FixedPollingInterval' (default), 'PriorityPollingInterval', 'DynamicPriorityPolling', 'FixedChunkSizePolling', 'UseFsEvents', 'UseFsEventsOnParentDirectory'."), + Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling_FixedChunkSizePolling: diag(6226, ts.DiagnosticCategory.Message, "Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively__6226", "Specify strategy for watching directory on platforms that don't support recursive watching natively: 'UseFsEvents' (default), 'FixedPollingInterval', 'DynamicPriorityPolling', 'FixedChunkSizePolling'."), + Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority_FixedChunkSize: diag(6227, ts.DiagnosticCategory.Message, "Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_6227", "Specify strategy for creating a polling watch when it fails to create using file system events: 'FixedInterval' (default), 'PriorityInterval', 'DynamicPriority', 'FixedChunkSize'."), Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively: diag(6228, ts.DiagnosticCategory.Message, "Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_supp_6228", "Synchronously call callbacks and update the state of directory watchers on platforms that don't support recursive watching natively."), Tag_0_expects_at_least_1_arguments_but_the_JSX_factory_2_provides_at_most_3: diag(6229, ts.DiagnosticCategory.Error, "Tag_0_expects_at_least_1_arguments_but_the_JSX_factory_2_provides_at_most_3_6229", "Tag '{0}' expects at least '{1}' arguments, but the JSX factory '{2}' provides at most '{3}'."), Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line: diag(6230, ts.DiagnosticCategory.Error, "Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line_6230", "Option '{0}' can only be specified in 'tsconfig.json' file or set to 'false' or 'null' on command line."), @@ -8942,7 +9189,26 @@ var ts; Disable_loading_referenced_projects: diag(6235, ts.DiagnosticCategory.Message, "Disable_loading_referenced_projects_6235", "Disable loading referenced projects."), Arguments_for_the_rest_parameter_0_were_not_provided: diag(6236, ts.DiagnosticCategory.Error, "Arguments_for_the_rest_parameter_0_were_not_provided_6236", "Arguments for the rest parameter '{0}' were not provided."), Generates_an_event_trace_and_a_list_of_types: diag(6237, ts.DiagnosticCategory.Message, "Generates_an_event_trace_and_a_list_of_types_6237", "Generates an event trace and a list of types."), - Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react: diag(6238, ts.DiagnosticCategory.Error, "Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react_6238", "Specify the module specifier to be used to import the `jsx` and `jsxs` factory functions from. eg, react"), + Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react: diag(6238, ts.DiagnosticCategory.Error, "Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react_6238", "Specify the module specifier to be used to import the 'jsx' and 'jsxs' factory functions from. eg, react"), + File_0_exists_according_to_earlier_cached_lookups: diag(6239, ts.DiagnosticCategory.Message, "File_0_exists_according_to_earlier_cached_lookups_6239", "File '{0}' exists according to earlier cached lookups."), + File_0_does_not_exist_according_to_earlier_cached_lookups: diag(6240, ts.DiagnosticCategory.Message, "File_0_does_not_exist_according_to_earlier_cached_lookups_6240", "File '{0}' does not exist according to earlier cached lookups."), + Resolution_for_type_reference_directive_0_was_found_in_cache_from_location_1: diag(6241, ts.DiagnosticCategory.Message, "Resolution_for_type_reference_directive_0_was_found_in_cache_from_location_1_6241", "Resolution for type reference directive '{0}' was found in cache from location '{1}'."), + Resolving_type_reference_directive_0_containing_file_1: diag(6242, ts.DiagnosticCategory.Message, "Resolving_type_reference_directive_0_containing_file_1_6242", "======== Resolving type reference directive '{0}', containing file '{1}'. ========"), + Enable_strict_checking_of_optional_properties: diag(6243, ts.DiagnosticCategory.Message, "Enable_strict_checking_of_optional_properties_6243", "Enable strict checking of optional properties."), + Modules: diag(6244, ts.DiagnosticCategory.Message, "Modules_6244", "Modules"), + File_Management: diag(6245, ts.DiagnosticCategory.Message, "File_Management_6245", "File Management"), + Emit: diag(6246, ts.DiagnosticCategory.Message, "Emit_6246", "Emit"), + JavaScript_Support: diag(6247, ts.DiagnosticCategory.Message, "JavaScript_Support_6247", "JavaScript Support"), + Type_Checking: diag(6248, ts.DiagnosticCategory.Message, "Type_Checking_6248", "Type Checking"), + Editor_Support: diag(6249, ts.DiagnosticCategory.Message, "Editor_Support_6249", "Editor Support"), + Watch_and_Build_Modes: diag(6250, ts.DiagnosticCategory.Message, "Watch_and_Build_Modes_6250", "Watch and Build Modes"), + Compiler_Diagnostics: diag(6251, ts.DiagnosticCategory.Message, "Compiler_Diagnostics_6251", "Compiler Diagnostics"), + Interop_Constraints: diag(6252, ts.DiagnosticCategory.Message, "Interop_Constraints_6252", "Interop Constraints"), + Backwards_Compatibility: diag(6253, ts.DiagnosticCategory.Message, "Backwards_Compatibility_6253", "Backwards Compatibility"), + Language_and_Environment: diag(6254, ts.DiagnosticCategory.Message, "Language_and_Environment_6254", "Language and Environment"), + Projects: diag(6255, ts.DiagnosticCategory.Message, "Projects_6255", "Projects"), + Output_Formatting: diag(6256, ts.DiagnosticCategory.Message, "Output_Formatting_6256", "Output Formatting"), + Completeness: diag(6257, ts.DiagnosticCategory.Message, "Completeness_6257", "Completeness"), Projects_to_reference: diag(6300, ts.DiagnosticCategory.Message, "Projects_to_reference_6300", "Projects to reference"), Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"), Composite_projects_may_not_disable_declaration_emit: diag(6304, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_declaration_emit_6304", "Composite projects may not disable declaration emit."), @@ -8987,16 +9253,31 @@ var ts; Skipping_build_of_project_0_because_its_dependency_1_was_not_built: diag(6382, ts.DiagnosticCategory.Message, "Skipping_build_of_project_0_because_its_dependency_1_was_not_built_6382", "Skipping build of project '{0}' because its dependency '{1}' was not built"), Project_0_can_t_be_built_because_its_dependency_1_was_not_built: diag(6383, ts.DiagnosticCategory.Message, "Project_0_can_t_be_built_because_its_dependency_1_was_not_built_6383", "Project '{0}' can't be built because its dependency '{1}' was not built"), Have_recompiles_in_incremental_and_watch_assume_that_changes_within_a_file_will_only_affect_files_directly_depending_on_it: diag(6384, ts.DiagnosticCategory.Message, "Have_recompiles_in_incremental_and_watch_assume_that_changes_within_a_file_will_only_affect_files_di_6384", "Have recompiles in '--incremental' and '--watch' assume that changes within a file will only affect files directly depending on it."), - _0_is_deprecated: diag(6385, ts.DiagnosticCategory.Suggestion, "_0_is_deprecated_6385", "'{0}' is deprecated", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ undefined, /*reportsDeprecated*/ true), + _0_is_deprecated: diag(6385, ts.DiagnosticCategory.Suggestion, "_0_is_deprecated_6385", "'{0}' is deprecated.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ undefined, /*reportsDeprecated*/ true), Performance_timings_for_diagnostics_or_extendedDiagnostics_are_not_available_in_this_session_A_native_implementation_of_the_Web_Performance_API_could_not_be_found: diag(6386, ts.DiagnosticCategory.Message, "Performance_timings_for_diagnostics_or_extendedDiagnostics_are_not_available_in_this_session_A_nativ_6386", "Performance timings for '--diagnostics' or '--extendedDiagnostics' are not available in this session. A native implementation of the Web Performance API could not be found."), + The_signature_0_of_1_is_deprecated: diag(6387, ts.DiagnosticCategory.Suggestion, "The_signature_0_of_1_is_deprecated_6387", "The signature '{0}' of '{1}' is deprecated.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ undefined, /*reportsDeprecated*/ true), + Project_0_is_being_forcibly_rebuilt: diag(6388, ts.DiagnosticCategory.Message, "Project_0_is_being_forcibly_rebuilt_6388", "Project '{0}' is being forcibly rebuilt"), + Reusing_resolution_of_module_0_from_1_of_old_program_it_was_not_resolved: diag(6389, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_of_old_program_it_was_not_resolved_6389", "Reusing resolution of module '{0}' from '{1}' of old program, it was not resolved."), + Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2: diag(6390, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved__6390", "Reusing resolution of type reference directive '{0}' from '{1}' of old program, it was successfully resolved to '{2}'."), + Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3: diag(6391, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved__6391", "Reusing resolution of type reference directive '{0}' from '{1}' of old program, it was successfully resolved to '{2}' with Package ID '{3}'."), + Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_not_resolved: diag(6392, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_not_resolved_6392", "Reusing resolution of type reference directive '{0}' from '{1}' of old program, it was not resolved."), + Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3: diag(6393, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_6393", "Reusing resolution of module '{0}' from '{1}' found in cache from location '{2}', it was successfully resolved to '{3}'."), + Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4: diag(6394, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_6394", "Reusing resolution of module '{0}' from '{1}' found in cache from location '{2}', it was successfully resolved to '{3}' with Package ID '{4}'."), + Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_not_resolved: diag(6395, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_not_resolved_6395", "Reusing resolution of module '{0}' from '{1}' found in cache from location '{2}', it was not resolved."), + Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3: diag(6396, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_succes_6396", "Reusing resolution of type reference directive '{0}' from '{1}' found in cache from location '{2}', it was successfully resolved to '{3}'."), + Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4: diag(6397, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_succes_6397", "Reusing resolution of type reference directive '{0}' from '{1}' found in cache from location '{2}', it was successfully resolved to '{3}' with Package ID '{4}'."), + Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_not_resolved: diag(6398, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_not_re_6398", "Reusing resolution of type reference directive '{0}' from '{1}' found in cache from location '{2}', it was not resolved."), The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"), The_expected_type_comes_from_this_index_signature: diag(6501, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."), The_expected_type_comes_from_the_return_type_of_this_signature: diag(6502, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_the_return_type_of_this_signature_6502", "The expected type comes from the return type of this signature."), Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing: diag(6503, ts.DiagnosticCategory.Message, "Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing_6503", "Print names of files that are part of the compilation and then stop processing."), File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option: diag(6504, ts.DiagnosticCategory.Error, "File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option_6504", "File '{0}' is a JavaScript file. Did you mean to enable the 'allowJs' option?"), Print_names_of_files_and_the_reason_they_are_part_of_the_compilation: diag(6505, ts.DiagnosticCategory.Message, "Print_names_of_files_and_the_reason_they_are_part_of_the_compilation_6505", "Print names of files and the reason they are part of the compilation."), - Require_undeclared_properties_from_index_signatures_to_use_element_accesses: diag(6803, ts.DiagnosticCategory.Error, "Require_undeclared_properties_from_index_signatures_to_use_element_accesses_6803", "Require undeclared properties from index signatures to use element accesses."), + Consider_adding_a_declare_modifier_to_this_class: diag(6506, ts.DiagnosticCategory.Message, "Consider_adding_a_declare_modifier_to_this_class_6506", "Consider adding a 'declare' modifier to this class."), Include_undefined_in_index_signature_results: diag(6800, ts.DiagnosticCategory.Message, "Include_undefined_in_index_signature_results_6800", "Include 'undefined' in index signature results"), + Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier: diag(6801, ts.DiagnosticCategory.Message, "Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier_6801", "Ensure overriding members in derived classes are marked with an 'override' modifier."), + Require_undeclared_properties_from_index_signatures_to_use_element_accesses: diag(6802, ts.DiagnosticCategory.Message, "Require_undeclared_properties_from_index_signatures_to_use_element_accesses_6802", "Require undeclared properties from index signatures to use element accesses."), + Type_catch_clause_variables_as_unknown_instead_of_any: diag(6803, ts.DiagnosticCategory.Message, "Type_catch_clause_variables_as_unknown_instead_of_any_6803", "Type catch clause variables as 'unknown' instead of 'any'."), Variable_0_implicitly_has_an_1_type: diag(7005, ts.DiagnosticCategory.Error, "Variable_0_implicitly_has_an_1_type_7005", "Variable '{0}' implicitly has an '{1}' type."), Parameter_0_implicitly_has_an_1_type: diag(7006, ts.DiagnosticCategory.Error, "Parameter_0_implicitly_has_an_1_type_7006", "Parameter '{0}' implicitly has an '{1}' type."), Member_0_implicitly_has_an_1_type: diag(7008, ts.DiagnosticCategory.Error, "Member_0_implicitly_has_an_1_type_7008", "Member '{0}' implicitly has an '{1}' type."), @@ -9029,7 +9310,7 @@ var ts; Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for_all_imports_Implies_allowSyntheticDefaultImports: diag(7037, ts.DiagnosticCategory.Message, "Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for__7037", "Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'."), Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead: diag(7038, ts.DiagnosticCategory.Message, "Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cau_7038", "Type originates at this import. A namespace-style import cannot be called or constructed, and will cause a failure at runtime. Consider using a default import or import require here instead."), Mapped_object_type_implicitly_has_an_any_template_type: diag(7039, ts.DiagnosticCategory.Error, "Mapped_object_type_implicitly_has_an_any_template_type_7039", "Mapped object type implicitly has an 'any' template type."), - If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_1: diag(7040, ts.DiagnosticCategory.Error, "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040", "If the '{0}' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}`"), + If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_1: diag(7040, ts.DiagnosticCategory.Error, "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040", "If the '{0}' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}'"), The_containing_arrow_function_captures_the_global_value_of_this: diag(7041, ts.DiagnosticCategory.Error, "The_containing_arrow_function_captures_the_global_value_of_this_7041", "The containing arrow function captures the global value of 'this'."), Module_0_was_resolved_to_1_but_resolveJsonModule_is_not_used: diag(7042, ts.DiagnosticCategory.Error, "Module_0_was_resolved_to_1_but_resolveJsonModule_is_not_used_7042", "Module '{0}' was resolved to '{1}', but '--resolveJsonModule' is not used."), Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage: diag(7043, ts.DiagnosticCategory.Suggestion, "Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7043", "Variable '{0}' implicitly has an '{1}' type, but a better type may be inferred from usage."), @@ -9069,7 +9350,7 @@ var ts; JSDoc_0_is_not_attached_to_a_class: diag(8022, ts.DiagnosticCategory.Error, "JSDoc_0_is_not_attached_to_a_class_8022", "JSDoc '@{0}' is not attached to a class."), JSDoc_0_1_does_not_match_the_extends_2_clause: diag(8023, ts.DiagnosticCategory.Error, "JSDoc_0_1_does_not_match_the_extends_2_clause_8023", "JSDoc '@{0} {1}' does not match the 'extends {2}' clause."), JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name: diag(8024, ts.DiagnosticCategory.Error, "JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_8024", "JSDoc '@param' tag has name '{0}', but there is no parameter with that name."), - Class_declarations_cannot_have_more_than_one_augments_or_extends_tag: diag(8025, ts.DiagnosticCategory.Error, "Class_declarations_cannot_have_more_than_one_augments_or_extends_tag_8025", "Class declarations cannot have more than one `@augments` or `@extends` tag."), + Class_declarations_cannot_have_more_than_one_augments_or_extends_tag: diag(8025, ts.DiagnosticCategory.Error, "Class_declarations_cannot_have_more_than_one_augments_or_extends_tag_8025", "Class declarations cannot have more than one '@augments' or '@extends' tag."), Expected_0_type_arguments_provide_these_with_an_extends_tag: diag(8026, ts.DiagnosticCategory.Error, "Expected_0_type_arguments_provide_these_with_an_extends_tag_8026", "Expected {0} type arguments; provide these with an '@extends' tag."), Expected_0_1_type_arguments_provide_these_with_an_extends_tag: diag(8027, ts.DiagnosticCategory.Error, "Expected_0_1_type_arguments_provide_these_with_an_extends_tag_8027", "Expected {0}-{1} type arguments; provide these with an '@extends' tag."), JSDoc_may_only_appear_in_the_last_parameter_of_a_signature: diag(8028, ts.DiagnosticCategory.Error, "JSDoc_may_only_appear_in_the_last_parameter_of_a_signature_8028", "JSDoc '...' may only appear in the last parameter of a signature."), @@ -9314,6 +9595,11 @@ var ts; Add_all_missing_function_declarations: diag(95157, ts.DiagnosticCategory.Message, "Add_all_missing_function_declarations_95157", "Add all missing function declarations"), Method_not_implemented: diag(95158, ts.DiagnosticCategory.Message, "Method_not_implemented_95158", "Method not implemented."), Function_not_implemented: diag(95159, ts.DiagnosticCategory.Message, "Function_not_implemented_95159", "Function not implemented."), + Add_override_modifier: diag(95160, ts.DiagnosticCategory.Message, "Add_override_modifier_95160", "Add 'override' modifier"), + Remove_override_modifier: diag(95161, ts.DiagnosticCategory.Message, "Remove_override_modifier_95161", "Remove 'override' modifier"), + Add_all_missing_override_modifiers: diag(95162, ts.DiagnosticCategory.Message, "Add_all_missing_override_modifiers_95162", "Add all missing 'override' modifiers"), + Remove_all_unnecessary_override_modifiers: diag(95163, ts.DiagnosticCategory.Message, "Remove_all_unnecessary_override_modifiers_95163", "Remove all unnecessary 'override' modifiers"), + Can_only_convert_named_export: diag(95164, ts.DiagnosticCategory.Message, "Can_only_convert_named_export_95164", "Can only convert named export"), No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, ts.DiagnosticCategory.Error, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."), Classes_may_not_have_a_field_named_constructor: diag(18006, ts.DiagnosticCategory.Error, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."), JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, ts.DiagnosticCategory.Error, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"), @@ -9328,8 +9614,6 @@ var ts; The_shadowing_declaration_of_0_is_defined_here: diag(18017, ts.DiagnosticCategory.Error, "The_shadowing_declaration_of_0_is_defined_here_18017", "The shadowing declaration of '{0}' is defined here"), The_declaration_of_0_that_you_probably_intended_to_use_is_defined_here: diag(18018, ts.DiagnosticCategory.Error, "The_declaration_of_0_that_you_probably_intended_to_use_is_defined_here_18018", "The declaration of '{0}' that you probably intended to use is defined here"), _0_modifier_cannot_be_used_with_a_private_identifier: diag(18019, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_with_a_private_identifier_18019", "'{0}' modifier cannot be used with a private identifier."), - A_method_cannot_be_named_with_a_private_identifier: diag(18022, ts.DiagnosticCategory.Error, "A_method_cannot_be_named_with_a_private_identifier_18022", "A method cannot be named with a private identifier."), - An_accessor_cannot_be_named_with_a_private_identifier: diag(18023, ts.DiagnosticCategory.Error, "An_accessor_cannot_be_named_with_a_private_identifier_18023", "An accessor cannot be named with a private identifier."), An_enum_member_cannot_be_named_with_a_private_identifier: diag(18024, ts.DiagnosticCategory.Error, "An_enum_member_cannot_be_named_with_a_private_identifier_18024", "An enum member cannot be named with a private identifier."), can_only_be_used_at_the_start_of_a_file: diag(18026, ts.DiagnosticCategory.Error, "can_only_be_used_at_the_start_of_a_file_18026", "'#!' can only be used at the start of a file."), Compiler_reserves_name_0_when_emitting_private_identifier_downlevel: diag(18027, ts.DiagnosticCategory.Error, "Compiler_reserves_name_0_when_emitting_private_identifier_downlevel_18027", "Compiler reserves name '{0}' when emitting private identifier downlevel."), @@ -9341,6 +9625,7 @@ var ts; 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: diag(18033, ts.DiagnosticCategory.Error, "Only_numeric_enums_can_have_computed_members_but_this_expression_has_type_0_If_you_do_not_need_exhau_18033", "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."), Specify_the_JSX_fragment_factory_function_to_use_when_targeting_react_JSX_emit_with_jsxFactory_compiler_option_is_specified_e_g_Fragment: diag(18034, ts.DiagnosticCategory.Message, "Specify_the_JSX_fragment_factory_function_to_use_when_targeting_react_JSX_emit_with_jsxFactory_compi_18034", "Specify the JSX fragment factory function to use when targeting 'react' JSX emit with 'jsxFactory' compiler option is specified, e.g. 'Fragment'."), Invalid_value_for_jsxFragmentFactory_0_is_not_a_valid_identifier_or_qualified_name: diag(18035, ts.DiagnosticCategory.Error, "Invalid_value_for_jsxFragmentFactory_0_is_not_a_valid_identifier_or_qualified_name_18035", "Invalid value for 'jsxFragmentFactory'. '{0}' is not a valid identifier or qualified-name."), + Class_decorators_can_t_be_used_with_static_private_identifier_Consider_removing_the_experimental_decorator: diag(18036, ts.DiagnosticCategory.Error, "Class_decorators_can_t_be_used_with_static_private_identifier_Consider_removing_the_experimental_dec_18036", "Class decorators can't be used with static private identifier. Consider removing the experimental decorator."), }; })(ts || (ts = {})); var ts; @@ -9348,7 +9633,7 @@ var ts; var _a; /* @internal */ function tokenIsIdentifierOrKeyword(token) { - return token >= 78 /* Identifier */; + return token >= 79 /* Identifier */; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; /* @internal */ @@ -9357,87 +9642,88 @@ var ts; } ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan; var textToKeywordObj = (_a = { - abstract: 125 /* AbstractKeyword */, - any: 128 /* AnyKeyword */, - as: 126 /* AsKeyword */, - asserts: 127 /* AssertsKeyword */, - bigint: 155 /* BigIntKeyword */, - boolean: 131 /* BooleanKeyword */, - break: 80 /* BreakKeyword */, - case: 81 /* CaseKeyword */, - catch: 82 /* CatchKeyword */, - class: 83 /* ClassKeyword */, - continue: 85 /* ContinueKeyword */, - const: 84 /* ConstKeyword */ + abstract: 126 /* AbstractKeyword */, + any: 129 /* AnyKeyword */, + as: 127 /* AsKeyword */, + asserts: 128 /* AssertsKeyword */, + bigint: 156 /* BigIntKeyword */, + boolean: 132 /* BooleanKeyword */, + break: 81 /* BreakKeyword */, + case: 82 /* CaseKeyword */, + catch: 83 /* CatchKeyword */, + class: 84 /* ClassKeyword */, + continue: 86 /* ContinueKeyword */, + const: 85 /* ConstKeyword */ }, - _a["" + "constructor"] = 132 /* ConstructorKeyword */, - _a.debugger = 86 /* DebuggerKeyword */, - _a.declare = 133 /* DeclareKeyword */, - _a.default = 87 /* DefaultKeyword */, - _a.delete = 88 /* DeleteKeyword */, - _a.do = 89 /* DoKeyword */, - _a.else = 90 /* ElseKeyword */, - _a.enum = 91 /* EnumKeyword */, - _a.export = 92 /* ExportKeyword */, - _a.extends = 93 /* ExtendsKeyword */, - _a.false = 94 /* FalseKeyword */, - _a.finally = 95 /* FinallyKeyword */, - _a.for = 96 /* ForKeyword */, - _a.from = 153 /* FromKeyword */, - _a.function = 97 /* FunctionKeyword */, - _a.get = 134 /* GetKeyword */, - _a.if = 98 /* IfKeyword */, - _a.implements = 116 /* ImplementsKeyword */, - _a.import = 99 /* ImportKeyword */, - _a.in = 100 /* InKeyword */, - _a.infer = 135 /* InferKeyword */, - _a.instanceof = 101 /* InstanceOfKeyword */, - _a.interface = 117 /* InterfaceKeyword */, - _a.intrinsic = 136 /* IntrinsicKeyword */, - _a.is = 137 /* IsKeyword */, - _a.keyof = 138 /* KeyOfKeyword */, - _a.let = 118 /* LetKeyword */, - _a.module = 139 /* ModuleKeyword */, - _a.namespace = 140 /* NamespaceKeyword */, - _a.never = 141 /* NeverKeyword */, - _a.new = 102 /* NewKeyword */, - _a.null = 103 /* NullKeyword */, - _a.number = 144 /* NumberKeyword */, - _a.object = 145 /* ObjectKeyword */, - _a.package = 119 /* PackageKeyword */, - _a.private = 120 /* PrivateKeyword */, - _a.protected = 121 /* ProtectedKeyword */, - _a.public = 122 /* PublicKeyword */, - _a.readonly = 142 /* ReadonlyKeyword */, - _a.require = 143 /* RequireKeyword */, - _a.global = 154 /* GlobalKeyword */, - _a.return = 104 /* ReturnKeyword */, - _a.set = 146 /* SetKeyword */, - _a.static = 123 /* StaticKeyword */, - _a.string = 147 /* StringKeyword */, - _a.super = 105 /* SuperKeyword */, - _a.switch = 106 /* SwitchKeyword */, - _a.symbol = 148 /* SymbolKeyword */, - _a.this = 107 /* ThisKeyword */, - _a.throw = 108 /* ThrowKeyword */, - _a.true = 109 /* TrueKeyword */, - _a.try = 110 /* TryKeyword */, - _a.type = 149 /* TypeKeyword */, - _a.typeof = 111 /* TypeOfKeyword */, - _a.undefined = 150 /* UndefinedKeyword */, - _a.unique = 151 /* UniqueKeyword */, - _a.unknown = 152 /* UnknownKeyword */, - _a.var = 112 /* VarKeyword */, - _a.void = 113 /* VoidKeyword */, - _a.while = 114 /* WhileKeyword */, - _a.with = 115 /* WithKeyword */, - _a.yield = 124 /* YieldKeyword */, - _a.async = 129 /* AsyncKeyword */, - _a.await = 130 /* AwaitKeyword */, - _a.of = 156 /* OfKeyword */, + _a["" + "constructor"] = 133 /* ConstructorKeyword */, + _a.debugger = 87 /* DebuggerKeyword */, + _a.declare = 134 /* 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 = 154 /* FromKeyword */, + _a.function = 98 /* FunctionKeyword */, + _a.get = 135 /* GetKeyword */, + _a.if = 99 /* IfKeyword */, + _a.implements = 117 /* ImplementsKeyword */, + _a.import = 100 /* ImportKeyword */, + _a.in = 101 /* InKeyword */, + _a.infer = 136 /* InferKeyword */, + _a.instanceof = 102 /* InstanceOfKeyword */, + _a.interface = 118 /* InterfaceKeyword */, + _a.intrinsic = 137 /* IntrinsicKeyword */, + _a.is = 138 /* IsKeyword */, + _a.keyof = 139 /* KeyOfKeyword */, + _a.let = 119 /* LetKeyword */, + _a.module = 140 /* ModuleKeyword */, + _a.namespace = 141 /* NamespaceKeyword */, + _a.never = 142 /* NeverKeyword */, + _a.new = 103 /* NewKeyword */, + _a.null = 104 /* NullKeyword */, + _a.number = 145 /* NumberKeyword */, + _a.object = 146 /* ObjectKeyword */, + _a.package = 120 /* PackageKeyword */, + _a.private = 121 /* PrivateKeyword */, + _a.protected = 122 /* ProtectedKeyword */, + _a.public = 123 /* PublicKeyword */, + _a.override = 157 /* OverrideKeyword */, + _a.readonly = 143 /* ReadonlyKeyword */, + _a.require = 144 /* RequireKeyword */, + _a.global = 155 /* GlobalKeyword */, + _a.return = 105 /* ReturnKeyword */, + _a.set = 147 /* SetKeyword */, + _a.static = 124 /* StaticKeyword */, + _a.string = 148 /* StringKeyword */, + _a.super = 106 /* SuperKeyword */, + _a.switch = 107 /* SwitchKeyword */, + _a.symbol = 149 /* SymbolKeyword */, + _a.this = 108 /* ThisKeyword */, + _a.throw = 109 /* ThrowKeyword */, + _a.true = 110 /* TrueKeyword */, + _a.try = 111 /* TryKeyword */, + _a.type = 150 /* TypeKeyword */, + _a.typeof = 112 /* TypeOfKeyword */, + _a.undefined = 151 /* UndefinedKeyword */, + _a.unique = 152 /* UniqueKeyword */, + _a.unknown = 153 /* UnknownKeyword */, + _a.var = 113 /* VarKeyword */, + _a.void = 114 /* VoidKeyword */, + _a.while = 115 /* WhileKeyword */, + _a.with = 116 /* WithKeyword */, + _a.yield = 125 /* YieldKeyword */, + _a.async = 130 /* AsyncKeyword */, + _a.await = 131 /* AwaitKeyword */, + _a.of = 158 /* OfKeyword */, _a); var textToKeyword = new ts.Map(ts.getEntries(textToKeywordObj)); - var textToToken = new ts.Map(ts.getEntries(__assign(__assign({}, 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 */, "=": 62 /* EqualsToken */, "+=": 63 /* PlusEqualsToken */, "-=": 64 /* MinusEqualsToken */, "*=": 65 /* AsteriskEqualsToken */, "**=": 66 /* AsteriskAsteriskEqualsToken */, "/=": 67 /* SlashEqualsToken */, "%=": 68 /* PercentEqualsToken */, "<<=": 69 /* LessThanLessThanEqualsToken */, ">>=": 70 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 72 /* AmpersandEqualsToken */, "|=": 73 /* BarEqualsToken */, "^=": 77 /* CaretEqualsToken */, "||=": 74 /* BarBarEqualsToken */, "&&=": 75 /* AmpersandAmpersandEqualsToken */, "??=": 76 /* QuestionQuestionEqualsToken */, "@": 59 /* AtToken */, "`": 61 /* BacktickToken */ }))); + var textToToken = new ts.Map(ts.getEntries(__assign(__assign({}, 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 */ }))); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers IdentifierStart :: @@ -9493,13 +9779,13 @@ var ts; var unicodeESNextIdentifierStart = [65, 90, 97, 122, 170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 895, 895, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1327, 1329, 1366, 1369, 1369, 1376, 1416, 1488, 1514, 1519, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2144, 2154, 2208, 2228, 2230, 2237, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2432, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2556, 2556, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2809, 2809, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3129, 3133, 3133, 3160, 3162, 3168, 3169, 3200, 3200, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3412, 3414, 3423, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3718, 3722, 3724, 3747, 3749, 3749, 3751, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5109, 5112, 5117, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5880, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6264, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6430, 6480, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7296, 7304, 7312, 7354, 7357, 7359, 7401, 7404, 7406, 7411, 7413, 7414, 7418, 7418, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8472, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12443, 12447, 12449, 12538, 12540, 12543, 12549, 12591, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40943, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42653, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42943, 42946, 42950, 42999, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43261, 43262, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43488, 43492, 43494, 43503, 43514, 43518, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43646, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43824, 43866, 43868, 43879, 43888, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 65536, 65547, 65549, 65574, 65576, 65594, 65596, 65597, 65599, 65613, 65616, 65629, 65664, 65786, 65856, 65908, 66176, 66204, 66208, 66256, 66304, 66335, 66349, 66378, 66384, 66421, 66432, 66461, 66464, 66499, 66504, 66511, 66513, 66517, 66560, 66717, 66736, 66771, 66776, 66811, 66816, 66855, 66864, 66915, 67072, 67382, 67392, 67413, 67424, 67431, 67584, 67589, 67592, 67592, 67594, 67637, 67639, 67640, 67644, 67644, 67647, 67669, 67680, 67702, 67712, 67742, 67808, 67826, 67828, 67829, 67840, 67861, 67872, 67897, 67968, 68023, 68030, 68031, 68096, 68096, 68112, 68115, 68117, 68119, 68121, 68149, 68192, 68220, 68224, 68252, 68288, 68295, 68297, 68324, 68352, 68405, 68416, 68437, 68448, 68466, 68480, 68497, 68608, 68680, 68736, 68786, 68800, 68850, 68864, 68899, 69376, 69404, 69415, 69415, 69424, 69445, 69600, 69622, 69635, 69687, 69763, 69807, 69840, 69864, 69891, 69926, 69956, 69956, 69968, 70002, 70006, 70006, 70019, 70066, 70081, 70084, 70106, 70106, 70108, 70108, 70144, 70161, 70163, 70187, 70272, 70278, 70280, 70280, 70282, 70285, 70287, 70301, 70303, 70312, 70320, 70366, 70405, 70412, 70415, 70416, 70419, 70440, 70442, 70448, 70450, 70451, 70453, 70457, 70461, 70461, 70480, 70480, 70493, 70497, 70656, 70708, 70727, 70730, 70751, 70751, 70784, 70831, 70852, 70853, 70855, 70855, 71040, 71086, 71128, 71131, 71168, 71215, 71236, 71236, 71296, 71338, 71352, 71352, 71424, 71450, 71680, 71723, 71840, 71903, 71935, 71935, 72096, 72103, 72106, 72144, 72161, 72161, 72163, 72163, 72192, 72192, 72203, 72242, 72250, 72250, 72272, 72272, 72284, 72329, 72349, 72349, 72384, 72440, 72704, 72712, 72714, 72750, 72768, 72768, 72818, 72847, 72960, 72966, 72968, 72969, 72971, 73008, 73030, 73030, 73056, 73061, 73063, 73064, 73066, 73097, 73112, 73112, 73440, 73458, 73728, 74649, 74752, 74862, 74880, 75075, 77824, 78894, 82944, 83526, 92160, 92728, 92736, 92766, 92880, 92909, 92928, 92975, 92992, 92995, 93027, 93047, 93053, 93071, 93760, 93823, 93952, 94026, 94032, 94032, 94099, 94111, 94176, 94177, 94179, 94179, 94208, 100343, 100352, 101106, 110592, 110878, 110928, 110930, 110948, 110951, 110960, 111355, 113664, 113770, 113776, 113788, 113792, 113800, 113808, 113817, 119808, 119892, 119894, 119964, 119966, 119967, 119970, 119970, 119973, 119974, 119977, 119980, 119982, 119993, 119995, 119995, 119997, 120003, 120005, 120069, 120071, 120074, 120077, 120084, 120086, 120092, 120094, 120121, 120123, 120126, 120128, 120132, 120134, 120134, 120138, 120144, 120146, 120485, 120488, 120512, 120514, 120538, 120540, 120570, 120572, 120596, 120598, 120628, 120630, 120654, 120656, 120686, 120688, 120712, 120714, 120744, 120746, 120770, 120772, 120779, 123136, 123180, 123191, 123197, 123214, 123214, 123584, 123627, 124928, 125124, 125184, 125251, 125259, 125259, 126464, 126467, 126469, 126495, 126497, 126498, 126500, 126500, 126503, 126503, 126505, 126514, 126516, 126519, 126521, 126521, 126523, 126523, 126530, 126530, 126535, 126535, 126537, 126537, 126539, 126539, 126541, 126543, 126545, 126546, 126548, 126548, 126551, 126551, 126553, 126553, 126555, 126555, 126557, 126557, 126559, 126559, 126561, 126562, 126564, 126564, 126567, 126570, 126572, 126578, 126580, 126583, 126585, 126588, 126590, 126590, 126592, 126601, 126603, 126619, 126625, 126627, 126629, 126633, 126635, 126651, 131072, 173782, 173824, 177972, 177984, 178205, 178208, 183969, 183984, 191456, 194560, 195101]; var unicodeESNextIdentifierPart = [48, 57, 65, 90, 95, 95, 97, 122, 170, 170, 181, 181, 183, 183, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 895, 895, 902, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1327, 1329, 1366, 1369, 1369, 1376, 1416, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1519, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2045, 2045, 2048, 2093, 2112, 2139, 2144, 2154, 2208, 2228, 2230, 2237, 2259, 2273, 2275, 2403, 2406, 2415, 2417, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2556, 2556, 2558, 2558, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2809, 2815, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3072, 3084, 3086, 3088, 3090, 3112, 3114, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3162, 3168, 3171, 3174, 3183, 3200, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3328, 3331, 3333, 3340, 3342, 3344, 3346, 3396, 3398, 3400, 3402, 3406, 3412, 3415, 3423, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3558, 3567, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3718, 3722, 3724, 3747, 3749, 3749, 3751, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4969, 4977, 4992, 5007, 5024, 5109, 5112, 5117, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5880, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6264, 6272, 6314, 6320, 6389, 6400, 6430, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6618, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6832, 6845, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7296, 7304, 7312, 7354, 7357, 7359, 7376, 7378, 7380, 7418, 7424, 7673, 7675, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8472, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12447, 12449, 12538, 12540, 12543, 12549, 12591, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40943, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42737, 42775, 42783, 42786, 42888, 42891, 42943, 42946, 42950, 42999, 43047, 43072, 43123, 43136, 43205, 43216, 43225, 43232, 43255, 43259, 43259, 43261, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43488, 43518, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43824, 43866, 43868, 43879, 43888, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65071, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 65536, 65547, 65549, 65574, 65576, 65594, 65596, 65597, 65599, 65613, 65616, 65629, 65664, 65786, 65856, 65908, 66045, 66045, 66176, 66204, 66208, 66256, 66272, 66272, 66304, 66335, 66349, 66378, 66384, 66426, 66432, 66461, 66464, 66499, 66504, 66511, 66513, 66517, 66560, 66717, 66720, 66729, 66736, 66771, 66776, 66811, 66816, 66855, 66864, 66915, 67072, 67382, 67392, 67413, 67424, 67431, 67584, 67589, 67592, 67592, 67594, 67637, 67639, 67640, 67644, 67644, 67647, 67669, 67680, 67702, 67712, 67742, 67808, 67826, 67828, 67829, 67840, 67861, 67872, 67897, 67968, 68023, 68030, 68031, 68096, 68099, 68101, 68102, 68108, 68115, 68117, 68119, 68121, 68149, 68152, 68154, 68159, 68159, 68192, 68220, 68224, 68252, 68288, 68295, 68297, 68326, 68352, 68405, 68416, 68437, 68448, 68466, 68480, 68497, 68608, 68680, 68736, 68786, 68800, 68850, 68864, 68903, 68912, 68921, 69376, 69404, 69415, 69415, 69424, 69456, 69600, 69622, 69632, 69702, 69734, 69743, 69759, 69818, 69840, 69864, 69872, 69881, 69888, 69940, 69942, 69951, 69956, 69958, 69968, 70003, 70006, 70006, 70016, 70084, 70089, 70092, 70096, 70106, 70108, 70108, 70144, 70161, 70163, 70199, 70206, 70206, 70272, 70278, 70280, 70280, 70282, 70285, 70287, 70301, 70303, 70312, 70320, 70378, 70384, 70393, 70400, 70403, 70405, 70412, 70415, 70416, 70419, 70440, 70442, 70448, 70450, 70451, 70453, 70457, 70459, 70468, 70471, 70472, 70475, 70477, 70480, 70480, 70487, 70487, 70493, 70499, 70502, 70508, 70512, 70516, 70656, 70730, 70736, 70745, 70750, 70751, 70784, 70853, 70855, 70855, 70864, 70873, 71040, 71093, 71096, 71104, 71128, 71133, 71168, 71232, 71236, 71236, 71248, 71257, 71296, 71352, 71360, 71369, 71424, 71450, 71453, 71467, 71472, 71481, 71680, 71738, 71840, 71913, 71935, 71935, 72096, 72103, 72106, 72151, 72154, 72161, 72163, 72164, 72192, 72254, 72263, 72263, 72272, 72345, 72349, 72349, 72384, 72440, 72704, 72712, 72714, 72758, 72760, 72768, 72784, 72793, 72818, 72847, 72850, 72871, 72873, 72886, 72960, 72966, 72968, 72969, 72971, 73014, 73018, 73018, 73020, 73021, 73023, 73031, 73040, 73049, 73056, 73061, 73063, 73064, 73066, 73102, 73104, 73105, 73107, 73112, 73120, 73129, 73440, 73462, 73728, 74649, 74752, 74862, 74880, 75075, 77824, 78894, 82944, 83526, 92160, 92728, 92736, 92766, 92768, 92777, 92880, 92909, 92912, 92916, 92928, 92982, 92992, 92995, 93008, 93017, 93027, 93047, 93053, 93071, 93760, 93823, 93952, 94026, 94031, 94087, 94095, 94111, 94176, 94177, 94179, 94179, 94208, 100343, 100352, 101106, 110592, 110878, 110928, 110930, 110948, 110951, 110960, 111355, 113664, 113770, 113776, 113788, 113792, 113800, 113808, 113817, 113821, 113822, 119141, 119145, 119149, 119154, 119163, 119170, 119173, 119179, 119210, 119213, 119362, 119364, 119808, 119892, 119894, 119964, 119966, 119967, 119970, 119970, 119973, 119974, 119977, 119980, 119982, 119993, 119995, 119995, 119997, 120003, 120005, 120069, 120071, 120074, 120077, 120084, 120086, 120092, 120094, 120121, 120123, 120126, 120128, 120132, 120134, 120134, 120138, 120144, 120146, 120485, 120488, 120512, 120514, 120538, 120540, 120570, 120572, 120596, 120598, 120628, 120630, 120654, 120656, 120686, 120688, 120712, 120714, 120744, 120746, 120770, 120772, 120779, 120782, 120831, 121344, 121398, 121403, 121452, 121461, 121461, 121476, 121476, 121499, 121503, 121505, 121519, 122880, 122886, 122888, 122904, 122907, 122913, 122915, 122916, 122918, 122922, 123136, 123180, 123184, 123197, 123200, 123209, 123214, 123214, 123584, 123641, 124928, 125124, 125136, 125142, 125184, 125259, 125264, 125273, 126464, 126467, 126469, 126495, 126497, 126498, 126500, 126500, 126503, 126503, 126505, 126514, 126516, 126519, 126521, 126521, 126523, 126523, 126530, 126530, 126535, 126535, 126537, 126537, 126539, 126539, 126541, 126543, 126545, 126546, 126548, 126548, 126551, 126551, 126553, 126553, 126555, 126555, 126557, 126557, 126559, 126559, 126561, 126562, 126564, 126564, 126567, 126570, 126572, 126578, 126580, 126583, 126585, 126588, 126590, 126590, 126592, 126601, 126603, 126619, 126625, 126627, 126629, 126633, 126635, 126651, 131072, 173782, 173824, 177972, 177984, 178205, 178208, 183969, 183984, 191456, 194560, 195101, 917760, 917999]; /** - * Test for whether a single line comment's text contains a directive. + * Test for whether a single line comment with leading whitespace trimmed's text contains a directive. */ - var commentDirectiveRegExSingleLine = /^\s*\/\/\/?\s*@(ts-expect-error|ts-ignore)/; + var commentDirectiveRegExSingleLine = /^\/\/\/?\s*@(ts-expect-error|ts-ignore)/; /** - * Test for whether a multi-line comment's last line contains a directive. + * Test for whether a multi-line comment with leading whitespace trimmed's last line contains a directive. */ - var commentDirectiveRegExMultiLine = /^\s*(?:\/|\*)*\s*@(ts-expect-error|ts-ignore)/; + var commentDirectiveRegExMultiLine = /^(?:\/|\*)*\s*@(ts-expect-error|ts-ignore)/; function lookupInUnicodeMap(code, map) { // Bail out quickly if it couldn't possibly be in the map. if (code < map[0]) { @@ -9750,11 +10036,11 @@ var ts; } ts.couldStartTrivia = couldStartTrivia; /* @internal */ - function skipTrivia(text, pos, stopAfterLineBreak, stopAtComments) { - if (stopAtComments === void 0) { stopAtComments = false; } + function skipTrivia(text, pos, stopAfterLineBreak, stopAtComments, inJSDoc) { if (ts.positionIsSynthesized(pos)) { return pos; } + var canConsumeStar = false; // Keep in sync with couldStartTrivia while (true) { var ch = text.charCodeAt(pos); @@ -9769,6 +10055,7 @@ var ts; if (stopAfterLineBreak) { return pos; } + canConsumeStar = !!inJSDoc; continue; case 9 /* tab */: case 11 /* verticalTab */: @@ -9788,6 +10075,7 @@ var ts; } pos++; } + canConsumeStar = false; continue; } if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { @@ -9799,6 +10087,7 @@ var ts; } pos++; } + canConsumeStar = false; continue; } break; @@ -9808,12 +10097,21 @@ var ts; case 62 /* greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos); + canConsumeStar = false; continue; } break; case 35 /* hash */: if (pos === 0 && isShebangTrivia(text, pos)) { pos = scanShebangTrivia(text, pos); + canConsumeStar = false; + continue; + } + break; + case 42 /* asterisk */: + if (canConsumeStar) { + pos++; + canConsumeStar = false; continue; } break; @@ -10101,8 +10399,8 @@ var ts; 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 === 78 /* Identifier */ || token > 115 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 80 /* FirstReservedWord */ && token <= 115 /* LastReservedWord */; }, + 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; }, getCommentDirectives: function () { return commentDirectives; }, getNumericLiteralFlags: function () { return tokenFlags & 1008 /* NumericLiteralFlags */; }, @@ -10117,7 +10415,9 @@ var ts; reScanJsxAttributeValue: reScanJsxAttributeValue, reScanJsxToken: reScanJsxToken, reScanLessThanToken: reScanLessThanToken, + reScanHashToken: reScanHashToken, reScanQuestionToken: reScanQuestionToken, + reScanInvalidIdentifier: reScanInvalidIdentifier, scanJsxToken: scanJsxToken, scanJsDocToken: scanJsDocToken, scan: scan, @@ -10626,7 +10926,7 @@ var ts; } } } - return token = 78 /* Identifier */; + return token = 79 /* Identifier */; } function scanBinaryOrOctalDigits(base) { var value = ""; @@ -10775,19 +11075,19 @@ var ts; return token = scanTemplateAndSetTokenValue(/* isTaggedTemplate */ false); case 37 /* percent */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 68 /* PercentEqualsToken */; + return pos += 2, token = 69 /* 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 = 75 /* AmpersandAmpersandEqualsToken */; + return pos += 3, token = 76 /* AmpersandAmpersandEqualsToken */; } return pos += 2, token = 55 /* AmpersandAmpersandToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 72 /* AmpersandEqualsToken */; + return pos += 2, token = 73 /* AmpersandEqualsToken */; } pos++; return token = 50 /* AmpersandToken */; @@ -10799,11 +11099,11 @@ var ts; return token = 21 /* CloseParenToken */; case 42 /* asterisk */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 65 /* AsteriskEqualsToken */; + return pos += 2, token = 66 /* AsteriskEqualsToken */; } if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 66 /* AsteriskAsteriskEqualsToken */; + return pos += 3, token = 67 /* AsteriskAsteriskEqualsToken */; } return pos += 2, token = 42 /* AsteriskAsteriskToken */; } @@ -10819,7 +11119,7 @@ var ts; return pos += 2, token = 45 /* PlusPlusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 63 /* PlusEqualsToken */; + return pos += 2, token = 64 /* PlusEqualsToken */; } pos++; return token = 39 /* PlusToken */; @@ -10831,7 +11131,7 @@ var ts; return pos += 2, token = 46 /* MinusMinusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 64 /* MinusEqualsToken */; + return pos += 2, token = 65 /* MinusEqualsToken */; } pos++; return token = 40 /* MinusToken */; @@ -10899,7 +11199,7 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 67 /* SlashEqualsToken */; + return pos += 2, token = 68 /* SlashEqualsToken */; } pos++; return token = 43 /* SlashToken */; @@ -10976,7 +11276,7 @@ var ts; } if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 69 /* LessThanLessThanEqualsToken */; + return pos += 3, token = 70 /* LessThanLessThanEqualsToken */; } return pos += 2, token = 47 /* LessThanLessThanToken */; } @@ -11010,7 +11310,7 @@ var ts; return pos += 2, token = 38 /* EqualsGreaterThanToken */; } pos++; - return token = 62 /* EqualsToken */; + return token = 63 /* EqualsToken */; case 62 /* greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -11029,7 +11329,7 @@ var ts; } if (text.charCodeAt(pos + 1) === 63 /* question */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 76 /* QuestionQuestionEqualsToken */; + return pos += 3, token = 77 /* QuestionQuestionEqualsToken */; } return pos += 2, token = 60 /* QuestionQuestionToken */; } @@ -11043,7 +11343,7 @@ var ts; return token = 23 /* CloseBracketToken */; case 94 /* caret */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 77 /* CaretEqualsToken */; + return pos += 2, token = 78 /* CaretEqualsToken */; } pos++; return token = 52 /* CaretToken */; @@ -11062,12 +11362,12 @@ var ts; } if (text.charCodeAt(pos + 1) === 124 /* bar */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 74 /* BarBarEqualsToken */; + return pos += 3, token = 75 /* BarBarEqualsToken */; } return pos += 2, token = 56 /* BarBarToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 73 /* BarEqualsToken */; + return pos += 2, token = 74 /* BarEqualsToken */; } pos++; return token = 51 /* BarToken */; @@ -11105,30 +11405,12 @@ var ts; return token = 0 /* Unknown */; } pos++; - if (isIdentifierStart(ch = text.charCodeAt(pos), languageVersion)) { - pos++; - while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion)) - pos++; - tokenValue = text.substring(tokenPos, pos); - if (ch === 92 /* backslash */) { - tokenValue += scanIdentifierParts(); - } - } - else { - tokenValue = "#"; - error(ts.Diagnostics.Invalid_character); - } - return token = 79 /* PrivateIdentifier */; + scanIdentifier(codePointAt(text, pos), languageVersion); + return token = 80 /* PrivateIdentifier */; default: - if (isIdentifierStart(ch, languageVersion)) { - pos += charSize(ch); - while (pos < end && isIdentifierPart(ch = codePointAt(text, pos), languageVersion)) - pos += charSize(ch); - tokenValue = text.substring(tokenPos, pos); - if (ch === 92 /* backslash */) { - tokenValue += scanIdentifierParts(); - } - return token = getIdentifierToken(); + var identifierKind = scanIdentifier(ch, languageVersion); + if (identifierKind) { + return token = identifierKind; } else if (isWhiteSpaceSingleLine(ch)) { pos += charSize(ch); @@ -11145,17 +11427,42 @@ var ts; } } } + function reScanInvalidIdentifier() { + ts.Debug.assert(token === 0 /* 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 */); + if (identifierKind) { + return token = identifierKind; + } + pos += charSize(ch); + return token; // Still `SyntaKind.Unknown` + } + function scanIdentifier(startCharacter, languageVersion) { + var ch = startCharacter; + if (isIdentifierStart(ch, languageVersion)) { + pos += charSize(ch); + while (pos < end && isIdentifierPart(ch = codePointAt(text, pos), languageVersion)) + pos += charSize(ch); + tokenValue = text.substring(tokenPos, pos); + if (ch === 92 /* 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 = 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + return pos += 3, token = 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */; } return pos += 2, token = 49 /* GreaterThanGreaterThanGreaterThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 70 /* GreaterThanGreaterThanEqualsToken */; + return pos += 2, token = 71 /* GreaterThanGreaterThanEqualsToken */; } pos++; return token = 48 /* GreaterThanGreaterThanToken */; @@ -11168,12 +11475,12 @@ var ts; return token; } function reScanAsteriskEqualsToken() { - ts.Debug.assert(token === 65 /* AsteriskEqualsToken */, "'reScanAsteriskEqualsToken' should only be called on a '*='"); + ts.Debug.assert(token === 66 /* AsteriskEqualsToken */, "'reScanAsteriskEqualsToken' should only be called on a '*='"); pos = tokenPos + 1; - return token = 62 /* EqualsToken */; + return token = 63 /* EqualsToken */; } function reScanSlashToken() { - if (token === 43 /* SlashToken */ || token === 67 /* SlashEqualsToken */) { + if (token === 43 /* SlashToken */ || token === 68 /* SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -11223,7 +11530,7 @@ var ts; return token; } function appendIfCommentDirective(commentDirectives, text, commentDirectiveRegEx, lineStart) { - var type = getDirectiveFromComment(text, commentDirectiveRegEx); + var type = getDirectiveFromComment(ts.trimStringStart(text), commentDirectiveRegEx); if (type === undefined) { return commentDirectives; } @@ -11257,9 +11564,10 @@ var ts; pos = tokenPos; return token = scanTemplateAndSetTokenValue(/* isTaggedTemplate */ true); } - function reScanJsxToken() { + function reScanJsxToken(allowMultilineJsxText) { + if (allowMultilineJsxText === void 0) { allowMultilineJsxText = true; } pos = tokenPos = startPos; - return token = scanJsxToken(); + return token = scanJsxToken(allowMultilineJsxText); } function reScanLessThanToken() { if (token === 47 /* LessThanLessThanToken */) { @@ -11268,12 +11576,20 @@ var ts; } return token; } + function reScanHashToken() { + if (token === 80 /* PrivateIdentifier */) { + pos = tokenPos + 1; + return token = 62 /* HashToken */; + } + return token; + } function reScanQuestionToken() { ts.Debug.assert(token === 60 /* QuestionQuestionToken */, "'reScanQuestionToken' should only be called on a '??'"); pos = tokenPos + 1; return token = 57 /* QuestionToken */; } - function scanJsxToken() { + function scanJsxToken(allowMultilineJsxText) { + if (allowMultilineJsxText === void 0) { allowMultilineJsxText = true; } startPos = tokenPos = pos; if (pos >= end) { return token = 1 /* EndOfFileToken */; @@ -11293,15 +11609,9 @@ var ts; } // First non-whitespace character on this line. var firstNonWhitespace = 0; - var lastNonWhitespace = -1; // These initial values are special because the first line is: // firstNonWhitespace = 0 to indicate that we want leading whitespace, while (pos < end) { - // We want to keep track of the last non-whitespace (but including - // newlines character for hitting the end of the JSX Text region) - if (!isWhiteSpaceSingleLine(char)) { - lastNonWhitespace = pos; - } char = text.charCodeAt(pos); if (char === 123 /* openBrace */) { break; @@ -11319,8 +11629,6 @@ var ts; if (char === 125 /* closeBrace */) { error(ts.Diagnostics.Unexpected_token_Did_you_mean_or_rbrace, pos, 1); } - if (lastNonWhitespace > 0) - lastNonWhitespace++; // FirstNonWhitespace is 0, then we only see whitespaces so far. If we see a linebreak, we want to ignore that whitespaces. // i.e (- : whitespace) //
---- @@ -11330,13 +11638,17 @@ var ts; if (isLineBreak(char) && firstNonWhitespace === 0) { firstNonWhitespace = -1; } + else if (!allowMultilineJsxText && isLineBreak(char) && firstNonWhitespace > 0) { + // Stop JsxText on each line during formatting. This allows the formatter to + // indent each line correctly. + break; + } else if (!isWhiteSpaceLike(char)) { firstNonWhitespace = pos; } pos++; } - var endPosition = lastNonWhitespace === -1 ? pos : lastNonWhitespace; - tokenValue = text.substring(startPos, endPosition); + tokenValue = text.substring(startPos, pos); return firstNonWhitespace === -1 ? 12 /* JsxTextAllWhiteSpaces */ : 11 /* JsxText */; } // Scans a JSX identifier; these differ from normal identifiers in that @@ -11359,6 +11671,7 @@ var ts; tokenValue += ":"; pos++; namespaceSeparator = true; + token = 79 /* Identifier */; // swap from keyword kind to identifier kind continue; } var oldPos = pos; @@ -11433,13 +11746,15 @@ var ts; case 62 /* greaterThan */: return token = 31 /* GreaterThanToken */; case 61 /* equals */: - return token = 62 /* EqualsToken */; + 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 */: pos--; var extendedCookedChar = peekExtendedUnicodeEscape(); @@ -11615,6 +11930,8 @@ var ts; switch (options.target) { case 99 /* ESNext */: return "lib.esnext.full.d.ts"; + case 8 /* ES2021 */: + return "lib.es2021.full.d.ts"; case 7 /* ES2020 */: return "lib.es2020.full.d.ts"; case 6 /* ES2019 */: @@ -11833,9 +12150,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 159 /* TypeParameter */) { + if (d && d.kind === 161 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (isFunctionLike(current) || isClassLike(current) || current.kind === 253 /* InterfaceDeclaration */) { + if (isFunctionLike(current) || isClassLike(current) || current.kind === 255 /* InterfaceDeclaration */) { return current; } } @@ -11843,7 +12160,7 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node, parent) { - return ts.hasSyntacticModifier(node, 92 /* ParameterPropertyModifier */) && parent.kind === 166 /* Constructor */; + return ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */) && parent.kind === 168 /* Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -11873,14 +12190,14 @@ var ts; node = walkUpBindingElementsAndPatterns(node); } var flags = getFlags(node); - if (node.kind === 249 /* VariableDeclaration */) { + if (node.kind === 251 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 250 /* VariableDeclarationList */) { + if (node && node.kind === 252 /* VariableDeclarationList */) { flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 232 /* VariableStatement */) { + if (node && node.kind === 234 /* VariableStatement */) { flags |= getFlags(node); } return flags; @@ -11898,19 +12215,22 @@ var ts; // nodes like variable declarations and binding elements can returned a view of their flags // that includes the modifiers from their container. i.e. flags like export/declare aren't // stored on the variable declaration directly, but on the containing variable statement - // (if it has one). Similarly, flags for let/const are store on the variable declaration + // (if it has one). Similarly, flags for let/const are stored on the variable declaration // list. By calling this function, all those flags are combined so that the client can treat // the node as if it actually had those flags. function getCombinedNodeFlags(node) { return getCombinedFlags(node, function (n) { return n.flags; }); } ts.getCombinedNodeFlags = getCombinedNodeFlags; + /* @internal */ + ts.supportedLocaleDirectories = ["cs", "de", "es", "fr", "it", "ja", "ko", "pl", "pt-br", "ru", "tr", "zh-cn", "zh-tw"]; /** * Checks to see if the locale is in the appropriate format, * and if it is, attempts to set the appropriate language. */ function validateLocaleAndSetLanguage(locale, sys, errors) { - var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase()); + var lowerCaseLocale = locale.toLowerCase(); + var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(lowerCaseLocale); if (!matchResult) { if (errors) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1, "en", "ja-jp")); @@ -11921,7 +12241,7 @@ var ts; var territory = matchResult[3]; // First try the entire locale, then fall back to just language if that's all we have. // Either ways do not fail, and fallback to the English diagnostic strings. - if (!trySetLanguageAndTerritory(language, territory, errors)) { + if (ts.contains(ts.supportedLocaleDirectories, lowerCaseLocale) && !trySetLanguageAndTerritory(language, territory, errors)) { trySetLanguageAndTerritory(language, /*territory*/ undefined, errors); } // Set the UI locale for string collation @@ -12028,7 +12348,7 @@ var ts; } ts.idText = idText; function symbolName(symbol) { - if (symbol.valueDeclaration && isPrivateIdentifierPropertyDeclaration(symbol.valueDeclaration)) { + if (symbol.valueDeclaration && isPrivateIdentifierClassElementDeclaration(symbol.valueDeclaration)) { return idText(symbol.valueDeclaration.name); } return unescapeLeadingUnderscores(symbol.escapedName); @@ -12050,30 +12370,30 @@ var ts; } // Covers remaining cases (returning undefined if none match). switch (hostNode.kind) { - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } break; - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: var expr = hostNode.expression; - if (expr.kind === 216 /* BinaryExpression */ && expr.operatorToken.kind === 62 /* EqualsToken */) { + if (expr.kind === 218 /* BinaryExpression */ && expr.operatorToken.kind === 63 /* EqualsToken */) { expr = expr.left; } switch (expr.kind) { - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return expr.name; - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; } } break; - case 207 /* ParenthesizedExpression */: { + case 209 /* ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 245 /* LabeledStatement */: { + case 247 /* LabeledStatement */: { if (isDeclaration(hostNode.statement) || isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -12108,18 +12428,18 @@ var ts; /** @internal */ function getNonAssignedNameOfDeclaration(declaration) { switch (declaration.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return declaration; - case 333 /* JSDocPropertyTag */: - case 326 /* JSDocParameterTag */: { + case 341 /* JSDocPropertyTag */: + case 334 /* JSDocParameterTag */: { var name = declaration.name; - if (name.kind === 157 /* QualifiedName */) { + if (name.kind === 159 /* QualifiedName */) { return name.right; } break; } - case 203 /* CallExpression */: - case 216 /* BinaryExpression */: { + case 205 /* CallExpression */: + case 218 /* BinaryExpression */: { var expr_1 = declaration; switch (ts.getAssignmentDeclarationKind(expr_1)) { case 1 /* ExportsProperty */: @@ -12135,15 +12455,15 @@ var ts; return undefined; } } - case 331 /* JSDocTypedefTag */: + case 339 /* JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 325 /* JSDocEnumTag */: + case 333 /* JSDocEnumTag */: return nameForNamelessJSDocTypedef(declaration); - case 266 /* ExportAssignment */: { + case 268 /* ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: var expr = declaration; if (ts.isBindableStaticElementAccessExpression(expr)) { return expr.argumentExpression; @@ -12156,7 +12476,7 @@ var ts; if (declaration === undefined) return undefined; return getNonAssignedNameOfDeclaration(declaration) || - (ts.isFunctionExpression(declaration) || ts.isClassExpression(declaration) ? getAssignedName(declaration) : undefined); + (ts.isFunctionExpression(declaration) || ts.isArrowFunction(declaration) || ts.isClassExpression(declaration) ? getAssignedName(declaration) : undefined); } ts.getNameOfDeclaration = getNameOfDeclaration; /*@internal*/ @@ -12309,6 +12629,10 @@ var ts; return getFirstJSDocTag(node, ts.isJSDocReadonlyTag, /*noCache*/ true); } ts.getJSDocReadonlyTagNoCache = getJSDocReadonlyTagNoCache; + function getJSDocOverrideTagNoCache(node) { + return getFirstJSDocTag(node, ts.isJSDocOverrideTag, /*noCache*/ true); + } + ts.getJSDocOverrideTagNoCache = getJSDocOverrideTagNoCache; /** Gets the JSDoc deprecated tag for the node if present */ function getJSDocDeprecatedTag(node) { return getFirstJSDocTag(node, ts.isJSDocDeprecatedTag); @@ -12429,6 +12753,15 @@ var ts; return getJSDocTags(node).filter(function (doc) { return doc.kind === kind; }); } ts.getAllJSDocTagsOfKind = getAllJSDocTagsOfKind; + /** 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) { + // TODO: Other kinds here + return c.kind === 315 /* JSDocText */ ? c.text : "{@link " + (c.name ? ts.entityNameToString(c.name) + " " : "") + c.text + "}"; + }).join(""); + } + ts.getTextOfJSDocComment = getTextOfJSDocComment; /** * Gets the effective type parameters. If the node was parsed in a * JavaScript file, gets the type parameters from the `@template` tag from JSDoc. @@ -12438,7 +12771,7 @@ var ts; return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 311 /* JSDocComment */); + ts.Debug.assert(node.parent.kind === 314 /* JSDocComment */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -12464,13 +12797,13 @@ var ts; } ts.getEffectiveConstraintOfTypeParameter = getEffectiveConstraintOfTypeParameter; // #region - function isIdentifierOrPrivateIdentifier(node) { - return node.kind === 78 /* Identifier */ || node.kind === 79 /* PrivateIdentifier */; + function isMemberName(node) { + return node.kind === 79 /* Identifier */ || node.kind === 80 /* PrivateIdentifier */; } - ts.isIdentifierOrPrivateIdentifier = isIdentifierOrPrivateIdentifier; + ts.isMemberName = isMemberName; /* @internal */ function isGetOrSetAccessorDeclaration(node) { - return node.kind === 168 /* SetAccessor */ || node.kind === 167 /* GetAccessor */; + return node.kind === 170 /* SetAccessor */ || node.kind === 169 /* GetAccessor */; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; function isPropertyAccessChain(node) { @@ -12488,10 +12821,10 @@ var ts; function isOptionalChain(node) { var kind = node.kind; return !!(node.flags & 32 /* OptionalChain */) && - (kind === 201 /* PropertyAccessExpression */ - || kind === 202 /* ElementAccessExpression */ - || kind === 203 /* CallExpression */ - || kind === 225 /* NonNullExpression */); + (kind === 203 /* PropertyAccessExpression */ + || kind === 204 /* ElementAccessExpression */ + || kind === 205 /* CallExpression */ + || kind === 227 /* NonNullExpression */); } ts.isOptionalChain = isOptionalChain; /* @internal */ @@ -12526,7 +12859,7 @@ var ts; } ts.isOutermostOptionalChain = isOutermostOptionalChain; function isNullishCoalesce(node) { - return node.kind === 216 /* BinaryExpression */ && node.operatorToken.kind === 60 /* QuestionQuestionToken */; + return node.kind === 218 /* BinaryExpression */ && node.operatorToken.kind === 60 /* QuestionQuestionToken */; } ts.isNullishCoalesce = isNullishCoalesce; function isConstTypeReference(node) { @@ -12543,17 +12876,17 @@ var ts; } ts.isNonNullChain = isNonNullChain; function isBreakOrContinueStatement(node) { - return node.kind === 241 /* BreakStatement */ || node.kind === 240 /* ContinueStatement */; + return node.kind === 243 /* BreakStatement */ || node.kind === 242 /* ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isNamedExportBindings(node) { - return node.kind === 269 /* NamespaceExport */ || node.kind === 268 /* NamedExports */; + return node.kind === 271 /* NamespaceExport */ || node.kind === 270 /* NamedExports */; } ts.isNamedExportBindings = isNamedExportBindings; function isUnparsedTextLike(node) { switch (node.kind) { - case 294 /* UnparsedText */: - case 295 /* UnparsedInternalText */: + case 296 /* UnparsedText */: + case 297 /* UnparsedInternalText */: return true; default: return false; @@ -12562,12 +12895,12 @@ var ts; ts.isUnparsedTextLike = isUnparsedTextLike; function isUnparsedNode(node) { return isUnparsedTextLike(node) || - node.kind === 292 /* UnparsedPrologue */ || - node.kind === 296 /* UnparsedSyntheticReference */; + node.kind === 294 /* UnparsedPrologue */ || + node.kind === 298 /* UnparsedSyntheticReference */; } ts.isUnparsedNode = isUnparsedNode; function isJSDocPropertyLikeTag(node) { - return node.kind === 333 /* JSDocPropertyTag */ || node.kind === 326 /* JSDocParameterTag */; + return node.kind === 341 /* JSDocPropertyTag */ || node.kind === 334 /* JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; // #endregion @@ -12583,16 +12916,25 @@ var ts; ts.isNode = isNode; /* @internal */ function isNodeKind(kind) { - return kind >= 157 /* FirstNode */; + return kind >= 159 /* FirstNode */; } ts.isNodeKind = isNodeKind; + /** + * True if kind is of some token syntax kind. + * For example, this is true for an IfKeyword but not for an IfStatement. + * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. + */ + function isTokenKind(kind) { + return kind >= 0 /* FirstToken */ && kind <= 158 /* LastToken */; + } + ts.isTokenKind = isTokenKind; /** * True if node is of some token syntax kind. * For example, this is true for an IfKeyword but not for an IfStatement. * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. */ function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 156 /* LastToken */; + return isTokenKind(n.kind); } ts.isToken = isToken; // Node Arrays @@ -12633,13 +12975,13 @@ var ts; ts.isImportOrExportSpecifier = isImportOrExportSpecifier; function isTypeOnlyImportOrExportDeclaration(node) { switch (node.kind) { - case 265 /* ImportSpecifier */: - case 270 /* ExportSpecifier */: + case 267 /* ImportSpecifier */: + case 272 /* ExportSpecifier */: return node.parent.parent.isTypeOnly; - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: return node.parent.isTypeOnly; - case 262 /* ImportClause */: - case 260 /* ImportEqualsDeclaration */: + case 264 /* ImportClause */: + case 262 /* ImportEqualsDeclaration */: return node.isTypeOnly; default: return false; @@ -12658,10 +13000,10 @@ var ts; ts.isGeneratedIdentifier = isGeneratedIdentifier; // Private Identifiers /*@internal*/ - function isPrivateIdentifierPropertyDeclaration(node) { - return ts.isPropertyDeclaration(node) && ts.isPrivateIdentifier(node.name); + function isPrivateIdentifierClassElementDeclaration(node) { + return (ts.isPropertyDeclaration(node) || isMethodOrAccessor(node)) && ts.isPrivateIdentifier(node.name); } - ts.isPrivateIdentifierPropertyDeclaration = isPrivateIdentifierPropertyDeclaration; + ts.isPrivateIdentifierClassElementDeclaration = isPrivateIdentifierClassElementDeclaration; /*@internal*/ function isPrivateIdentifierPropertyAccessExpression(node) { return ts.isPropertyAccessExpression(node) && ts.isPrivateIdentifier(node.name); @@ -12671,17 +13013,18 @@ var ts; /* @internal */ function isModifierKind(token) { switch (token) { - case 125 /* AbstractKeyword */: - case 129 /* AsyncKeyword */: - case 84 /* ConstKeyword */: - case 133 /* DeclareKeyword */: - case 87 /* DefaultKeyword */: - case 92 /* ExportKeyword */: - case 122 /* PublicKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 142 /* ReadonlyKeyword */: - case 123 /* StaticKeyword */: + case 126 /* AbstractKeyword */: + case 130 /* AsyncKeyword */: + case 85 /* ConstKeyword */: + case 134 /* DeclareKeyword */: + case 88 /* DefaultKeyword */: + case 93 /* ExportKeyword */: + case 123 /* PublicKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + case 143 /* ReadonlyKeyword */: + case 124 /* StaticKeyword */: + case 157 /* OverrideKeyword */: return true; } return false; @@ -12689,12 +13032,12 @@ var ts; ts.isModifierKind = isModifierKind; /* @internal */ function isParameterPropertyModifier(kind) { - return !!(ts.modifierToFlag(kind) & 92 /* ParameterPropertyModifier */); + return !!(ts.modifierToFlag(kind) & 16476 /* ParameterPropertyModifier */); } ts.isParameterPropertyModifier = isParameterPropertyModifier; /* @internal */ function isClassMemberModifier(idToken) { - return isParameterPropertyModifier(idToken) || idToken === 123 /* StaticKeyword */; + return isParameterPropertyModifier(idToken) || idToken === 124 /* StaticKeyword */ || idToken === 157 /* OverrideKeyword */; } ts.isClassMemberModifier = isClassMemberModifier; function isModifier(node) { @@ -12703,29 +13046,29 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 157 /* QualifiedName */ - || kind === 78 /* Identifier */; + return kind === 159 /* QualifiedName */ + || kind === 79 /* Identifier */; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 78 /* Identifier */ - || kind === 79 /* PrivateIdentifier */ + return kind === 79 /* Identifier */ + || kind === 80 /* PrivateIdentifier */ || kind === 10 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 158 /* ComputedPropertyName */; + || kind === 160 /* ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; - return kind === 78 /* Identifier */ - || kind === 196 /* ObjectBindingPattern */ - || kind === 197 /* ArrayBindingPattern */; + return kind === 79 /* Identifier */ + || kind === 198 /* ObjectBindingPattern */ + || kind === 199 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions function isFunctionLike(node) { - return node && isFunctionLikeKind(node.kind); + return !!node && isFunctionLikeKind(node.kind); } ts.isFunctionLike = isFunctionLike; /* @internal */ @@ -12735,13 +13078,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 251 /* FunctionDeclaration */: - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 253 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return true; default: return false; @@ -12750,14 +13093,14 @@ var ts; /* @internal */ function isFunctionLikeKind(kind) { switch (kind) { - case 164 /* MethodSignature */: - case 169 /* CallSignature */: - case 313 /* JSDocSignature */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: - case 174 /* FunctionType */: - case 308 /* JSDocFunctionType */: - case 175 /* ConstructorType */: + case 166 /* MethodSignature */: + case 171 /* CallSignature */: + case 317 /* JSDocSignature */: + case 172 /* ConstructSignature */: + case 173 /* IndexSignature */: + case 176 /* FunctionType */: + case 311 /* JSDocFunctionType */: + case 177 /* ConstructorType */: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -12772,29 +13115,29 @@ var ts; // Classes function isClassElement(node) { var kind = node.kind; - return kind === 166 /* Constructor */ - || kind === 163 /* PropertyDeclaration */ - || kind === 165 /* MethodDeclaration */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */ - || kind === 171 /* IndexSignature */ - || kind === 229 /* SemicolonClassElement */; + return kind === 168 /* Constructor */ + || kind === 165 /* PropertyDeclaration */ + || kind === 167 /* MethodDeclaration */ + || kind === 169 /* GetAccessor */ + || kind === 170 /* SetAccessor */ + || kind === 173 /* IndexSignature */ + || kind === 231 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 252 /* ClassDeclaration */ || node.kind === 221 /* ClassExpression */); + return node && (node.kind === 254 /* ClassDeclaration */ || node.kind === 223 /* ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 167 /* GetAccessor */ || node.kind === 168 /* SetAccessor */); + return node && (node.kind === 169 /* GetAccessor */ || node.kind === 170 /* SetAccessor */); } ts.isAccessor = isAccessor; /* @internal */ function isMethodOrAccessor(node) { switch (node.kind) { - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return true; default: return false; @@ -12804,11 +13147,11 @@ var ts; // Type members function isTypeElement(node) { var kind = node.kind; - return kind === 170 /* ConstructSignature */ - || kind === 169 /* CallSignature */ - || kind === 162 /* PropertySignature */ - || kind === 164 /* MethodSignature */ - || kind === 171 /* IndexSignature */; + return kind === 172 /* ConstructSignature */ + || kind === 171 /* CallSignature */ + || kind === 164 /* PropertySignature */ + || kind === 166 /* MethodSignature */ + || kind === 173 /* IndexSignature */; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -12817,12 +13160,12 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 288 /* PropertyAssignment */ - || kind === 289 /* ShorthandPropertyAssignment */ - || kind === 290 /* SpreadAssignment */ - || kind === 165 /* MethodDeclaration */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */; + return kind === 290 /* PropertyAssignment */ + || kind === 291 /* ShorthandPropertyAssignment */ + || kind === 292 /* SpreadAssignment */ + || kind === 167 /* MethodDeclaration */ + || kind === 169 /* GetAccessor */ + || kind === 170 /* SetAccessor */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type @@ -12837,8 +13180,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 174 /* FunctionType */: - case 175 /* ConstructorType */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: return true; } return false; @@ -12849,8 +13192,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 197 /* ArrayBindingPattern */ - || kind === 196 /* ObjectBindingPattern */; + return kind === 199 /* ArrayBindingPattern */ + || kind === 198 /* ObjectBindingPattern */; } return false; } @@ -12858,15 +13201,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 199 /* ArrayLiteralExpression */ - || kind === 200 /* ObjectLiteralExpression */; + return kind === 201 /* ArrayLiteralExpression */ + || kind === 202 /* ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 198 /* BindingElement */ - || kind === 222 /* OmittedExpression */; + return kind === 200 /* BindingElement */ + || kind === 224 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -12875,9 +13218,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 249 /* VariableDeclaration */: - case 160 /* Parameter */: - case 198 /* BindingElement */: + case 251 /* VariableDeclaration */: + case 162 /* Parameter */: + case 200 /* BindingElement */: return true; } return false; @@ -12898,8 +13241,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 196 /* ObjectBindingPattern */: - case 200 /* ObjectLiteralExpression */: + case 198 /* ObjectBindingPattern */: + case 202 /* ObjectLiteralExpression */: return true; } return false; @@ -12911,8 +13254,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 197 /* ArrayBindingPattern */: - case 199 /* ArrayLiteralExpression */: + case 199 /* ArrayBindingPattern */: + case 201 /* ArrayLiteralExpression */: return true; } return false; @@ -12921,26 +13264,26 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 201 /* PropertyAccessExpression */ - || kind === 157 /* QualifiedName */ - || kind === 195 /* ImportType */; + return kind === 203 /* PropertyAccessExpression */ + || kind === 159 /* QualifiedName */ + || kind === 197 /* ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 201 /* PropertyAccessExpression */ - || kind === 157 /* QualifiedName */; + return kind === 203 /* PropertyAccessExpression */ + || kind === 159 /* QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 275 /* JsxOpeningElement */: - case 274 /* JsxSelfClosingElement */: - case 203 /* CallExpression */: - case 204 /* NewExpression */: - case 205 /* TaggedTemplateExpression */: - case 161 /* Decorator */: + case 277 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: + case 207 /* TaggedTemplateExpression */: + case 163 /* Decorator */: return true; default: return false; @@ -12948,12 +13291,12 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 203 /* CallExpression */ || node.kind === 204 /* NewExpression */; + return node.kind === 205 /* CallExpression */ || node.kind === 206 /* NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 218 /* TemplateExpression */ + return kind === 220 /* TemplateExpression */ || kind === 14 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; @@ -12964,34 +13307,34 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: - case 204 /* NewExpression */: - case 203 /* CallExpression */: - case 273 /* JsxElement */: - case 274 /* JsxSelfClosingElement */: - case 277 /* JsxFragment */: - case 205 /* TaggedTemplateExpression */: - case 199 /* ArrayLiteralExpression */: - case 207 /* ParenthesizedExpression */: - case 200 /* ObjectLiteralExpression */: - case 221 /* ClassExpression */: - case 208 /* FunctionExpression */: - case 78 /* Identifier */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: + case 206 /* NewExpression */: + case 205 /* CallExpression */: + case 275 /* JsxElement */: + case 276 /* JsxSelfClosingElement */: + case 279 /* JsxFragment */: + case 207 /* TaggedTemplateExpression */: + case 201 /* ArrayLiteralExpression */: + case 209 /* ParenthesizedExpression */: + case 202 /* ObjectLiteralExpression */: + case 223 /* ClassExpression */: + case 210 /* FunctionExpression */: + case 79 /* Identifier */: case 13 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 218 /* TemplateExpression */: - case 94 /* FalseKeyword */: - case 103 /* NullKeyword */: - case 107 /* ThisKeyword */: - case 109 /* TrueKeyword */: - case 105 /* SuperKeyword */: - case 225 /* NonNullExpression */: - case 226 /* MetaProperty */: - case 99 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression + case 220 /* TemplateExpression */: + case 95 /* FalseKeyword */: + case 104 /* NullKeyword */: + case 108 /* ThisKeyword */: + case 110 /* TrueKeyword */: + case 106 /* SuperKeyword */: + case 227 /* NonNullExpression */: + case 228 /* MetaProperty */: + case 100 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: return false; @@ -13004,13 +13347,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 214 /* PrefixUnaryExpression */: - case 215 /* PostfixUnaryExpression */: - case 210 /* DeleteExpression */: - case 211 /* TypeOfExpression */: - case 212 /* VoidExpression */: - case 213 /* AwaitExpression */: - case 206 /* TypeAssertionExpression */: + case 216 /* PrefixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: + case 212 /* DeleteExpression */: + case 213 /* TypeOfExpression */: + case 214 /* VoidExpression */: + case 215 /* AwaitExpression */: + case 208 /* TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -13019,9 +13362,9 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: return true; - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return expr.operator === 45 /* PlusPlusToken */ || expr.operator === 46 /* MinusMinusToken */; default: @@ -13040,15 +13383,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 217 /* ConditionalExpression */: - case 219 /* YieldExpression */: - case 209 /* ArrowFunction */: - case 216 /* BinaryExpression */: - case 220 /* SpreadElement */: - case 224 /* AsExpression */: - case 222 /* OmittedExpression */: - case 337 /* CommaListExpression */: - case 336 /* PartiallyEmittedExpression */: + case 219 /* ConditionalExpression */: + case 221 /* YieldExpression */: + case 211 /* ArrowFunction */: + case 218 /* BinaryExpression */: + case 222 /* SpreadElement */: + case 226 /* AsExpression */: + case 224 /* OmittedExpression */: + case 345 /* CommaListExpression */: + case 344 /* PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -13056,8 +13399,8 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 206 /* TypeAssertionExpression */ - || kind === 224 /* AsExpression */; + return kind === 208 /* TypeAssertionExpression */ + || kind === 226 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ @@ -13068,13 +13411,13 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: return true; - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -13103,7 +13446,7 @@ var ts; ts.isExternalModuleIndicator = isExternalModuleIndicator; /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 238 /* ForInStatement */ || node.kind === 239 /* ForOfStatement */; + return node.kind === 240 /* ForInStatement */ || node.kind === 241 /* ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -13127,114 +13470,114 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 257 /* ModuleBlock */ - || kind === 256 /* ModuleDeclaration */ - || kind === 78 /* Identifier */; + return kind === 259 /* ModuleBlock */ + || kind === 258 /* ModuleDeclaration */ + || kind === 79 /* Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 257 /* ModuleBlock */ - || kind === 256 /* ModuleDeclaration */; + return kind === 259 /* ModuleBlock */ + || kind === 258 /* ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; - return kind === 78 /* Identifier */ - || kind === 256 /* ModuleDeclaration */; + return kind === 79 /* Identifier */ + || kind === 258 /* ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 264 /* NamedImports */ - || kind === 263 /* NamespaceImport */; + return kind === 266 /* NamedImports */ + || kind === 265 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 256 /* ModuleDeclaration */ || node.kind === 255 /* EnumDeclaration */; + return node.kind === 258 /* ModuleDeclaration */ || node.kind === 257 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 209 /* ArrowFunction */ - || kind === 198 /* BindingElement */ - || kind === 252 /* ClassDeclaration */ - || kind === 221 /* ClassExpression */ - || kind === 166 /* Constructor */ - || kind === 255 /* EnumDeclaration */ - || kind === 291 /* EnumMember */ - || kind === 270 /* ExportSpecifier */ - || kind === 251 /* FunctionDeclaration */ - || kind === 208 /* FunctionExpression */ - || kind === 167 /* GetAccessor */ - || kind === 262 /* ImportClause */ - || kind === 260 /* ImportEqualsDeclaration */ - || kind === 265 /* ImportSpecifier */ - || kind === 253 /* InterfaceDeclaration */ - || kind === 280 /* JsxAttribute */ - || kind === 165 /* MethodDeclaration */ - || kind === 164 /* MethodSignature */ - || kind === 256 /* ModuleDeclaration */ - || kind === 259 /* NamespaceExportDeclaration */ - || kind === 263 /* NamespaceImport */ - || kind === 269 /* NamespaceExport */ - || kind === 160 /* Parameter */ - || kind === 288 /* PropertyAssignment */ - || kind === 163 /* PropertyDeclaration */ - || kind === 162 /* PropertySignature */ - || kind === 168 /* SetAccessor */ - || kind === 289 /* ShorthandPropertyAssignment */ - || kind === 254 /* TypeAliasDeclaration */ - || kind === 159 /* TypeParameter */ - || kind === 249 /* VariableDeclaration */ - || kind === 331 /* JSDocTypedefTag */ - || kind === 324 /* JSDocCallbackTag */ - || kind === 333 /* JSDocPropertyTag */; + return kind === 211 /* ArrowFunction */ + || kind === 200 /* BindingElement */ + || kind === 254 /* ClassDeclaration */ + || kind === 223 /* ClassExpression */ + || kind === 168 /* Constructor */ + || kind === 257 /* EnumDeclaration */ + || kind === 293 /* EnumMember */ + || kind === 272 /* ExportSpecifier */ + || kind === 253 /* FunctionDeclaration */ + || kind === 210 /* FunctionExpression */ + || kind === 169 /* GetAccessor */ + || kind === 264 /* ImportClause */ + || kind === 262 /* ImportEqualsDeclaration */ + || kind === 267 /* ImportSpecifier */ + || kind === 255 /* InterfaceDeclaration */ + || kind === 282 /* JsxAttribute */ + || kind === 167 /* MethodDeclaration */ + || kind === 166 /* MethodSignature */ + || kind === 258 /* ModuleDeclaration */ + || kind === 261 /* NamespaceExportDeclaration */ + || kind === 265 /* NamespaceImport */ + || kind === 271 /* NamespaceExport */ + || kind === 162 /* Parameter */ + || kind === 290 /* PropertyAssignment */ + || kind === 165 /* PropertyDeclaration */ + || kind === 164 /* PropertySignature */ + || kind === 170 /* SetAccessor */ + || kind === 291 /* ShorthandPropertyAssignment */ + || kind === 256 /* TypeAliasDeclaration */ + || kind === 161 /* TypeParameter */ + || kind === 251 /* VariableDeclaration */ + || kind === 339 /* JSDocTypedefTag */ + || kind === 332 /* JSDocCallbackTag */ + || kind === 341 /* JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - return kind === 251 /* FunctionDeclaration */ - || kind === 271 /* MissingDeclaration */ - || kind === 252 /* ClassDeclaration */ - || kind === 253 /* InterfaceDeclaration */ - || kind === 254 /* TypeAliasDeclaration */ - || kind === 255 /* EnumDeclaration */ - || kind === 256 /* ModuleDeclaration */ - || kind === 261 /* ImportDeclaration */ - || kind === 260 /* ImportEqualsDeclaration */ - || kind === 267 /* ExportDeclaration */ - || kind === 266 /* ExportAssignment */ - || kind === 259 /* NamespaceExportDeclaration */; + return kind === 253 /* FunctionDeclaration */ + || kind === 273 /* MissingDeclaration */ + || kind === 254 /* ClassDeclaration */ + || kind === 255 /* InterfaceDeclaration */ + || kind === 256 /* TypeAliasDeclaration */ + || kind === 257 /* EnumDeclaration */ + || kind === 258 /* ModuleDeclaration */ + || kind === 263 /* ImportDeclaration */ + || kind === 262 /* ImportEqualsDeclaration */ + || kind === 269 /* ExportDeclaration */ + || kind === 268 /* ExportAssignment */ + || kind === 261 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 241 /* BreakStatement */ - || kind === 240 /* ContinueStatement */ - || kind === 248 /* DebuggerStatement */ - || kind === 235 /* DoStatement */ - || kind === 233 /* ExpressionStatement */ - || kind === 231 /* EmptyStatement */ - || kind === 238 /* ForInStatement */ - || kind === 239 /* ForOfStatement */ - || kind === 237 /* ForStatement */ - || kind === 234 /* IfStatement */ - || kind === 245 /* LabeledStatement */ - || kind === 242 /* ReturnStatement */ - || kind === 244 /* SwitchStatement */ - || kind === 246 /* ThrowStatement */ - || kind === 247 /* TryStatement */ - || kind === 232 /* VariableStatement */ - || kind === 236 /* WhileStatement */ - || kind === 243 /* WithStatement */ - || kind === 335 /* NotEmittedStatement */ - || kind === 339 /* EndOfDeclarationMarker */ - || kind === 338 /* MergeDeclarationMarker */; + return kind === 243 /* BreakStatement */ + || kind === 242 /* ContinueStatement */ + || kind === 250 /* DebuggerStatement */ + || kind === 237 /* DoStatement */ + || kind === 235 /* ExpressionStatement */ + || kind === 233 /* EmptyStatement */ + || kind === 240 /* ForInStatement */ + || kind === 241 /* ForOfStatement */ + || kind === 239 /* ForStatement */ + || kind === 236 /* IfStatement */ + || kind === 247 /* LabeledStatement */ + || kind === 244 /* ReturnStatement */ + || kind === 246 /* SwitchStatement */ + || kind === 248 /* ThrowStatement */ + || kind === 249 /* TryStatement */ + || kind === 234 /* VariableStatement */ + || kind === 238 /* WhileStatement */ + || kind === 245 /* WithStatement */ + || kind === 343 /* NotEmittedStatement */ + || kind === 347 /* EndOfDeclarationMarker */ + || kind === 346 /* MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { - if (node.kind === 159 /* TypeParameter */) { - return (node.parent && node.parent.kind !== 330 /* JSDocTemplateTag */) || ts.isInJSFile(node); + if (node.kind === 161 /* TypeParameter */) { + return (node.parent && node.parent.kind !== 338 /* JSDocTemplateTag */) || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -13261,10 +13604,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 230 /* Block */) + if (node.kind !== 232 /* Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 247 /* TryStatement */ || node.parent.kind === 287 /* CatchClause */) { + if (node.parent.kind === 249 /* TryStatement */ || node.parent.kind === 289 /* CatchClause */) { return false; } } @@ -13278,88 +13621,94 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 230 /* Block */; + || kind === 232 /* Block */; } ts.isStatementOrBlock = isStatementOrBlock; // Module references /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 272 /* ExternalModuleReference */ - || kind === 157 /* QualifiedName */ - || kind === 78 /* Identifier */; + return kind === 274 /* ExternalModuleReference */ + || kind === 159 /* QualifiedName */ + || kind === 79 /* Identifier */; } ts.isModuleReference = isModuleReference; // JSX /* @internal */ function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 107 /* ThisKeyword */ - || kind === 78 /* Identifier */ - || kind === 201 /* PropertyAccessExpression */; + return kind === 108 /* ThisKeyword */ + || kind === 79 /* Identifier */ + || kind === 203 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 273 /* JsxElement */ - || kind === 283 /* JsxExpression */ - || kind === 274 /* JsxSelfClosingElement */ + return kind === 275 /* JsxElement */ + || kind === 285 /* JsxExpression */ + || kind === 276 /* JsxSelfClosingElement */ || kind === 11 /* JsxText */ - || kind === 277 /* JsxFragment */; + || kind === 279 /* JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 280 /* JsxAttribute */ - || kind === 282 /* JsxSpreadAttribute */; + return kind === 282 /* JsxAttribute */ + || kind === 284 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 10 /* StringLiteral */ - || kind === 283 /* JsxExpression */; + || kind === 285 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 275 /* JsxOpeningElement */ - || kind === 274 /* JsxSelfClosingElement */; + return kind === 277 /* JsxOpeningElement */ + || kind === 276 /* JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 284 /* CaseClause */ - || kind === 285 /* DefaultClause */; + return kind === 286 /* CaseClause */ + || kind === 287 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 301 /* FirstJSDocNode */ && node.kind <= 333 /* LastJSDocNode */; + return node.kind >= 303 /* FirstJSDocNode */ && node.kind <= 341 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 311 /* JSDocComment */ || node.kind === 310 /* JSDocNamepathType */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 314 /* JSDocComment */ + || node.kind === 313 /* JSDocNamepathType */ + || node.kind === 315 /* JSDocText */ + || isJSDocLinkLike(node) + || isJSDocTag(node) + || ts.isJSDocTypeLiteral(node) + || ts.isJSDocSignature(node); } ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode; // TODO: determine what this does before making it public. /* @internal */ function isJSDocTag(node) { - return node.kind >= 314 /* FirstJSDocTagNode */ && node.kind <= 333 /* LastJSDocTagNode */; + return node.kind >= 321 /* FirstJSDocTagNode */ && node.kind <= 341 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 168 /* SetAccessor */; + return node.kind === 170 /* SetAccessor */; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 167 /* GetAccessor */; + return node.kind === 169 /* GetAccessor */; } ts.isGetAccessor = isGetAccessor; /** True if has jsdoc nodes attached to it. */ @@ -13385,13 +13734,13 @@ var ts; /** True if has initializer node attached to it. */ function hasOnlyExpressionInitializer(node) { switch (node.kind) { - case 249 /* VariableDeclaration */: - case 160 /* Parameter */: - case 198 /* BindingElement */: - case 162 /* PropertySignature */: - case 163 /* PropertyDeclaration */: - case 288 /* PropertyAssignment */: - case 291 /* EnumMember */: + case 251 /* VariableDeclaration */: + case 162 /* Parameter */: + case 200 /* BindingElement */: + case 164 /* PropertySignature */: + case 165 /* PropertyDeclaration */: + case 290 /* PropertyAssignment */: + case 293 /* EnumMember */: return true; default: return false; @@ -13399,12 +13748,12 @@ var ts; } ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { - return node.kind === 280 /* JsxAttribute */ || node.kind === 282 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); + return node.kind === 282 /* JsxAttribute */ || node.kind === 284 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); } ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 173 /* TypeReference */ || node.kind === 223 /* ExpressionWithTypeArguments */; + return node.kind === 175 /* TypeReference */ || node.kind === 225 /* ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -13436,6 +13785,10 @@ var ts; return node.kind === 10 /* StringLiteral */ || node.kind === 14 /* NoSubstitutionTemplateLiteral */; } ts.isStringLiteralLike = isStringLiteralLike; + function isJSDocLinkLike(node) { + return node.kind === 318 /* JSDocLink */ || node.kind === 319 /* JSDocLinkCode */ || node.kind === 320 /* JSDocLinkPlain */; + } + ts.isJSDocLinkLike = isJSDocLinkLike; // #endregion })(ts || (ts = {})); /* @internal */ @@ -13520,7 +13873,7 @@ var ts; increaseIndent: ts.noop, decreaseIndent: ts.noop, clear: function () { return str = ""; }, - trackSymbol: ts.noop, + trackSymbol: function () { return false; }, reportInaccessibleThisError: ts.noop, reportInaccessibleUniqueSymbolError: ts.noop, reportPrivateInBaseOfClassExpression: ts.noop, @@ -13532,11 +13885,19 @@ var ts; } ts.changesAffectModuleResolution = changesAffectModuleResolution; function optionsHaveModuleResolutionChanges(oldOptions, newOptions) { - return ts.moduleResolutionOptionDeclarations.some(function (o) { + return optionsHaveChanges(oldOptions, newOptions, ts.moduleResolutionOptionDeclarations); + } + ts.optionsHaveModuleResolutionChanges = optionsHaveModuleResolutionChanges; + function changesAffectingProgramStructure(oldOptions, newOptions) { + return optionsHaveChanges(oldOptions, newOptions, ts.optionsAffectingProgramStructure); + } + ts.changesAffectingProgramStructure = changesAffectingProgramStructure; + function optionsHaveChanges(oldOptions, newOptions, optionDeclarations) { + return oldOptions !== newOptions && optionDeclarations.some(function (o) { return !isJsonEqual(getCompilerOptionValue(oldOptions, o), getCompilerOptionValue(newOptions, o)); }); } - ts.optionsHaveModuleResolutionChanges = optionsHaveModuleResolutionChanges; + ts.optionsHaveChanges = optionsHaveChanges; function forEachAncestor(node, callback) { while (true) { var res = callback(node); @@ -13643,7 +14004,9 @@ var ts; } ts.packageIdToString = packageIdToString; function typeDirectiveIsEqualTo(oldResolution, newResolution) { - return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.primary === newResolution.primary; + return oldResolution.resolvedFileName === newResolution.resolvedFileName + && oldResolution.primary === newResolution.primary + && oldResolution.originalPath === newResolution.originalPath; } ts.typeDirectiveIsEqualTo = typeDirectiveIsEqualTo; function hasChangesInResolutions(names, newResolutions, oldResolutions, comparer) { @@ -13685,7 +14048,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 297 /* SourceFile */) { + while (node && node.kind !== 299 /* SourceFile */) { node = node.parent; } return node; @@ -13693,11 +14056,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 230 /* Block */: - case 258 /* CaseBlock */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: + case 232 /* Block */: + case 260 /* CaseBlock */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: return true; } return false; @@ -13835,10 +14198,10 @@ var ts; commentPos + 2 < commentEnd && text.charCodeAt(commentPos + 2) === 47 /* slash */) { var textSubStr = text.substring(commentPos, commentEnd); - return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) || - textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) || - textSubStr.match(fullTripleSlashReferenceTypeReferenceDirectiveRegEx) || - textSubStr.match(defaultLibReferenceRegEx) ? + return ts.fullTripleSlashReferencePathRegEx.test(textSubStr) || + ts.fullTripleSlashAMDReferencePathRegEx.test(textSubStr) || + fullTripleSlashReferenceTypeReferenceDirectiveRegEx.test(textSubStr) || + defaultLibReferenceRegEx.test(textSubStr) ? true : false; } return false; @@ -13893,10 +14256,12 @@ 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 === 334 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 342 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } - return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); + return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, + /*stopAfterLineBreak*/ false, + /*stopAtComments*/ false, isInJSDoc(node)); } ts.getTokenPosOfNode = getTokenPosOfNode; function getNonDecoratorTokenPosOfNode(node, sourceFile) { @@ -13926,7 +14291,7 @@ var ts; var text = sourceText.substring(includeTrivia ? node.pos : ts.skipTrivia(sourceText, node.pos), node.end); if (isJSDocTypeExpressionOrChild(node)) { // strip space + asterisk at line start - text = text.replace(/(^|\r?\n|\r)\s*\*\s*/g, "$1"); + text = text.split(/\r\n|\n|\r/).map(function (line) { return ts.trimStringStart(line.replace(/^\s*\*/, "")); }).join("\n"); } return text; } @@ -14015,9 +14380,11 @@ var ts; DataView: ["setBigInt64", "setBigUint64", "getBigInt64", "getBigUint64"], RelativeTimeFormat: ["format", "formatToParts", "resolvedOptions"] }, - esnext: { + es2021: { PromiseConstructor: ["any"], - String: ["replaceAll"], + String: ["replaceAll"] + }, + esnext: { NumberFormat: ["formatToParts"] } }; @@ -14110,7 +14477,7 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 249 /* VariableDeclaration */ && node.parent.kind === 287 /* CatchClause */; + return node.kind === 251 /* VariableDeclaration */ && node.parent.kind === 289 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { @@ -14142,11 +14509,11 @@ 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 === 256 /* ModuleDeclaration */ && (!node.body); + return !!node && node.kind === 258 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 297 /* SourceFile */ || - node.kind === 256 /* ModuleDeclaration */ || + return node.kind === 299 /* SourceFile */ || + node.kind === 258 /* ModuleDeclaration */ || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -14163,16 +14530,17 @@ 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 297 /* SourceFile */: + case 299 /* SourceFile */: return ts.isExternalModule(node.parent); - case 257 /* ModuleBlock */: + case 259 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; } ts.isModuleAugmentationExternal = isModuleAugmentationExternal; function getNonAugmentationDeclaration(symbol) { - return ts.find(symbol.declarations, function (d) { return !isExternalModuleAugmentation(d) && !(ts.isModuleDeclaration(d) && isGlobalScopeAugmentation(d)); }); + var _a; + return (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return !isExternalModuleAugmentation(d) && !(ts.isModuleDeclaration(d) && isGlobalScopeAugmentation(d)); }); } ts.getNonAugmentationDeclaration = getNonAugmentationDeclaration; function isEffectiveExternalModule(node, compilerOptions) { @@ -14218,22 +14586,22 @@ var ts; ts.isEffectiveStrictModeSourceFile = isEffectiveStrictModeSourceFile; function isBlockScope(node, parentNode) { switch (node.kind) { - case 297 /* SourceFile */: - case 258 /* CaseBlock */: - case 287 /* CatchClause */: - case 256 /* ModuleDeclaration */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 166 /* Constructor */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 299 /* SourceFile */: + case 260 /* CaseBlock */: + case 289 /* CatchClause */: + case 258 /* ModuleDeclaration */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 168 /* Constructor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return true; - case 230 /* Block */: + case 232 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return !ts.isFunctionLike(parentNode); @@ -14243,9 +14611,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 324 /* JSDocCallbackTag */: - case 331 /* JSDocTypedefTag */: - case 313 /* JSDocSignature */: + case 332 /* JSDocCallbackTag */: + case 339 /* JSDocTypedefTag */: + case 317 /* JSDocSignature */: return true; default: ts.assertType(node); @@ -14255,25 +14623,25 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isDeclarationWithTypeParameterChildren(node) { switch (node.kind) { - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 164 /* MethodSignature */: - case 171 /* IndexSignature */: - case 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 308 /* JSDocFunctionType */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 330 /* JSDocTemplateTag */: - case 251 /* FunctionDeclaration */: - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 166 /* MethodSignature */: + case 173 /* IndexSignature */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: + case 311 /* JSDocFunctionType */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 338 /* JSDocTemplateTag */: + case 253 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return true; default: ts.assertType(node); @@ -14283,8 +14651,8 @@ var ts; ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren; function isAnyImportSyntax(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: - case 260 /* ImportEqualsDeclaration */: + case 263 /* ImportDeclaration */: + case 262 /* ImportEqualsDeclaration */: return true; default: return false; @@ -14293,15 +14661,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: - case 260 /* ImportEqualsDeclaration */: - case 232 /* VariableStatement */: - case 252 /* ClassDeclaration */: - case 251 /* FunctionDeclaration */: - case 256 /* ModuleDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: + case 263 /* ImportDeclaration */: + case 262 /* ImportEqualsDeclaration */: + case 234 /* VariableStatement */: + case 254 /* ClassDeclaration */: + case 253 /* FunctionDeclaration */: + case 258 /* ModuleDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 255 /* InterfaceDeclaration */: + case 257 /* EnumDeclaration */: return true; default: return false; @@ -14334,19 +14702,19 @@ var ts; } ts.getNameFromIndexInfo = getNameFromIndexInfo; function isComputedNonLiteralName(name) { - return name.kind === 158 /* ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression); + return name.kind === 160 /* ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression); } ts.isComputedNonLiteralName = isComputedNonLiteralName; function getTextOfPropertyName(name) { switch (name.kind) { - case 78 /* Identifier */: - case 79 /* PrivateIdentifier */: + case 79 /* Identifier */: + case 80 /* PrivateIdentifier */: return name.escapedText; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: if (isStringOrNumericLiteralLike(name.expression)) return ts.escapeLeadingUnderscores(name.expression.text); return ts.Debug.fail("Text of property name cannot be read from non-literal-valued ComputedPropertyNames"); @@ -14357,20 +14725,22 @@ var ts; ts.getTextOfPropertyName = getTextOfPropertyName; function entityNameToString(name) { switch (name.kind) { - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: return "this"; - case 79 /* PrivateIdentifier */: - case 78 /* Identifier */: + case 80 /* PrivateIdentifier */: + case 79 /* Identifier */: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 157 /* QualifiedName */: + case 159 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 201 /* PropertyAccessExpression */: + case 203 /* 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 305 /* JSDocMemberName */: + return entityNameToString(name.left) + entityNameToString(name.right); default: return ts.Debug.assertNever(name); } @@ -14450,7 +14820,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 230 /* Block */) { + if (node.body && node.body.kind === 232 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -14464,7 +14834,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 297 /* SourceFile */: + case 299 /* 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 @@ -14473,28 +14843,28 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 249 /* VariableDeclaration */: - case 198 /* BindingElement */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 256 /* ModuleDeclaration */: - case 255 /* EnumDeclaration */: - case 291 /* EnumMember */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 254 /* TypeAliasDeclaration */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 251 /* VariableDeclaration */: + case 200 /* BindingElement */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: + case 258 /* ModuleDeclaration */: + case 257 /* EnumDeclaration */: + case 293 /* EnumMember */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 256 /* TypeAliasDeclaration */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: errorNode = node.name; break; - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); - case 284 /* CaseClause */: - case 285 /* DefaultClause */: + case 286 /* CaseClause */: + case 287 /* 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); @@ -14546,16 +14916,16 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 203 /* CallExpression */ && n.expression.kind === 105 /* SuperKeyword */; + return n.kind === 205 /* CallExpression */ && n.expression.kind === 106 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 203 /* CallExpression */ && n.expression.kind === 99 /* ImportKeyword */; + return n.kind === 205 /* CallExpression */ && n.expression.kind === 100 /* ImportKeyword */; } ts.isImportCall = isImportCall; function isImportMeta(n) { return ts.isMetaProperty(n) - && n.keywordToken === 99 /* ImportKeyword */ + && n.keywordToken === 100 /* ImportKeyword */ && n.name.escapedText === "meta"; } ts.isImportMeta = isImportMeta; @@ -14564,7 +14934,7 @@ var ts; } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 233 /* ExpressionStatement */ + return node.kind === 235 /* ExpressionStatement */ && node.expression.kind === 10 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; @@ -14592,11 +14962,12 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 160 /* Parameter */ || - node.kind === 159 /* TypeParameter */ || - node.kind === 208 /* FunctionExpression */ || - node.kind === 209 /* ArrowFunction */ || - node.kind === 207 /* ParenthesizedExpression */) ? + var commentRanges = (node.kind === 162 /* Parameter */ || + node.kind === 161 /* TypeParameter */ || + node.kind === 210 /* FunctionExpression */ || + node.kind === 211 /* ArrowFunction */ || + node.kind === 209 /* ParenthesizedExpression */ || + node.kind === 251 /* VariableDeclaration */) ? 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 '/**/' @@ -14607,53 +14978,53 @@ var ts; }); } ts.getJSDocCommentRanges = getJSDocCommentRanges; - ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; - var fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; - ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; - var defaultLibReferenceRegEx = /^(\/\/\/\s*/; + ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; + var fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; + ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; + var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (172 /* FirstTypeNode */ <= node.kind && node.kind <= 195 /* LastTypeNode */) { + if (174 /* FirstTypeNode */ <= node.kind && node.kind <= 197 /* LastTypeNode */) { return true; } switch (node.kind) { - case 128 /* AnyKeyword */: - case 152 /* UnknownKeyword */: - case 144 /* NumberKeyword */: - case 155 /* BigIntKeyword */: - case 147 /* StringKeyword */: - case 131 /* BooleanKeyword */: - case 148 /* SymbolKeyword */: - case 145 /* ObjectKeyword */: - case 150 /* UndefinedKeyword */: - case 141 /* NeverKeyword */: + case 129 /* AnyKeyword */: + case 153 /* UnknownKeyword */: + case 145 /* NumberKeyword */: + case 156 /* BigIntKeyword */: + case 148 /* StringKeyword */: + case 132 /* BooleanKeyword */: + case 149 /* SymbolKeyword */: + case 146 /* ObjectKeyword */: + case 151 /* UndefinedKeyword */: + case 142 /* NeverKeyword */: return true; - case 113 /* VoidKeyword */: - return node.parent.kind !== 212 /* VoidExpression */; - case 223 /* ExpressionWithTypeArguments */: + case 114 /* VoidKeyword */: + return node.parent.kind !== 214 /* VoidExpression */; + case 225 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 159 /* TypeParameter */: - return node.parent.kind === 190 /* MappedType */ || node.parent.kind === 185 /* InferType */; + case 161 /* TypeParameter */: + return node.parent.kind === 192 /* MappedType */ || node.parent.kind === 187 /* InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container - case 78 /* Identifier */: + case 79 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 157 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 159 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 201 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 203 /* 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 === 78 /* Identifier */ || node.kind === 157 /* QualifiedName */ || node.kind === 201 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 79 /* Identifier */ || node.kind === 159 /* QualifiedName */ || node.kind === 203 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through - case 157 /* QualifiedName */: - case 201 /* PropertyAccessExpression */: - case 107 /* ThisKeyword */: { + case 159 /* QualifiedName */: + case 203 /* PropertyAccessExpression */: + case 108 /* ThisKeyword */: { var parent = node.parent; - if (parent.kind === 176 /* TypeQuery */) { + if (parent.kind === 178 /* TypeQuery */) { return false; } - if (parent.kind === 195 /* ImportType */) { + if (parent.kind === 197 /* ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -14662,40 +15033,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 (172 /* FirstTypeNode */ <= parent.kind && parent.kind <= 195 /* LastTypeNode */) { + if (174 /* FirstTypeNode */ <= parent.kind && parent.kind <= 197 /* LastTypeNode */) { return true; } switch (parent.kind) { - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 159 /* TypeParameter */: + case 161 /* TypeParameter */: return node === parent.constraint; - case 330 /* JSDocTemplateTag */: + case 338 /* JSDocTemplateTag */: return node === parent.constraint; - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 160 /* Parameter */: - case 249 /* VariableDeclaration */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 162 /* Parameter */: + case 251 /* VariableDeclaration */: return node === parent.type; - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 166 /* Constructor */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 168 /* Constructor */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return node === parent.type; - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 173 /* IndexSignature */: return node === parent.type; - case 206 /* TypeAssertionExpression */: + case 208 /* TypeAssertionExpression */: return node === parent.type; - case 203 /* CallExpression */: - case 204 /* NewExpression */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: return ts.contains(parent.typeArguments, node); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -14720,23 +15091,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: return visitor(node); - case 258 /* CaseBlock */: - case 230 /* Block */: - case 234 /* IfStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 243 /* WithStatement */: - case 244 /* SwitchStatement */: - case 284 /* CaseClause */: - case 285 /* DefaultClause */: - case 245 /* LabeledStatement */: - case 247 /* TryStatement */: - case 287 /* CatchClause */: + case 260 /* CaseBlock */: + case 232 /* Block */: + case 236 /* IfStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 245 /* WithStatement */: + case 246 /* SwitchStatement */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: + case 247 /* LabeledStatement */: + case 249 /* TryStatement */: + case 289 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -14746,23 +15117,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 255 /* EnumDeclaration */: - case 253 /* InterfaceDeclaration */: - case 256 /* ModuleDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 257 /* EnumDeclaration */: + case 255 /* InterfaceDeclaration */: + case 258 /* ModuleDeclaration */: + case 256 /* 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 === 158 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 160 /* 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); @@ -14785,10 +15156,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 178 /* ArrayType */) { + if (node && node.kind === 180 /* ArrayType */) { return node.elementType; } - else if (node && node.kind === 173 /* TypeReference */) { + else if (node && node.kind === 175 /* TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -14798,12 +15169,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 253 /* InterfaceDeclaration */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 177 /* TypeLiteral */: + case 255 /* InterfaceDeclaration */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 179 /* TypeLiteral */: return node.members; - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return node.properties; } } @@ -14811,14 +15182,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 198 /* BindingElement */: - case 291 /* EnumMember */: - case 160 /* Parameter */: - case 288 /* PropertyAssignment */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 289 /* ShorthandPropertyAssignment */: - case 249 /* VariableDeclaration */: + case 200 /* BindingElement */: + case 293 /* EnumMember */: + case 162 /* Parameter */: + case 290 /* PropertyAssignment */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 291 /* ShorthandPropertyAssignment */: + case 251 /* VariableDeclaration */: return true; } } @@ -14830,8 +15201,8 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 250 /* VariableDeclarationList */ - && node.parent.parent.kind === 232 /* VariableStatement */; + return node.parent.kind === 252 /* VariableDeclarationList */ + && node.parent.parent.kind === 234 /* VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { @@ -14842,13 +15213,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: return true; } return false; @@ -14859,7 +15230,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 245 /* LabeledStatement */) { + if (node.statement.kind !== 247 /* LabeledStatement */) { return node.statement; } node = node.statement; @@ -14867,17 +15238,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 230 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 232 /* Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 165 /* MethodDeclaration */ && node.parent.kind === 200 /* ObjectLiteralExpression */; + return node && node.kind === 167 /* MethodDeclaration */ && node.parent.kind === 202 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 165 /* MethodDeclaration */ && - (node.parent.kind === 200 /* ObjectLiteralExpression */ || - node.parent.kind === 221 /* ClassExpression */); + return node.kind === 167 /* MethodDeclaration */ && + (node.parent.kind === 202 /* ObjectLiteralExpression */ || + node.parent.kind === 223 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -14890,7 +15261,7 @@ var ts; ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 288 /* PropertyAssignment */) { + if (property.kind === 290 /* PropertyAssignment */) { var propName = getTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -14939,14 +15310,14 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 297 /* SourceFile */); + ts.Debug.assert(node.kind !== 299 /* 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 158 /* ComputedPropertyName */: + case 160 /* 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 @@ -14961,9 +15332,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 161 /* Decorator */: + case 163 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 160 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 162 /* 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; @@ -14974,26 +15345,26 @@ var ts; node = node.parent; } break; - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 256 /* ModuleDeclaration */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: - case 255 /* EnumDeclaration */: - case 297 /* SourceFile */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 258 /* ModuleDeclaration */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 173 /* IndexSignature */: + case 257 /* EnumDeclaration */: + case 299 /* SourceFile */: return node; } } @@ -15012,9 +15383,9 @@ var ts; var container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { switch (container.kind) { - case 166 /* Constructor */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: + case 168 /* Constructor */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: return container; } } @@ -15036,27 +15407,27 @@ var ts; return node; } switch (node.kind) { - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: node = node.parent; break; - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: if (!stopOnFunctions) { continue; } // falls through - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return node; - case 161 /* Decorator */: + case 163 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 160 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 162 /* 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; @@ -15072,21 +15443,21 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 208 /* FunctionExpression */ || func.kind === 209 /* ArrowFunction */) { + if (func.kind === 210 /* FunctionExpression */ || func.kind === 211 /* ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 207 /* ParenthesizedExpression */) { + while (parent.kind === 209 /* ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 203 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 205 /* CallExpression */ && parent.expression === prev) { return parent; } } } ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperOrSuperProperty(node) { - return node.kind === 105 /* SuperKeyword */ + return node.kind === 106 /* SuperKeyword */ || isSuperProperty(node); } ts.isSuperOrSuperProperty = isSuperOrSuperProperty; @@ -15095,8 +15466,8 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 201 /* PropertyAccessExpression */ || kind === 202 /* ElementAccessExpression */) - && node.expression.kind === 105 /* SuperKeyword */; + return (kind === 203 /* PropertyAccessExpression */ || kind === 204 /* ElementAccessExpression */) + && node.expression.kind === 106 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; /** @@ -15104,26 +15475,34 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 201 /* PropertyAccessExpression */ || kind === 202 /* ElementAccessExpression */) - && node.expression.kind === 107 /* ThisKeyword */; + return (kind === 203 /* PropertyAccessExpression */ || kind === 204 /* ElementAccessExpression */) + && node.expression.kind === 108 /* 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) === 107 /* ThisKeyword */; + return !!node && ts.isVariableDeclaration(node) && ((_a = node.initializer) === null || _a === void 0 ? void 0 : _a.kind) === 108 /* 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 */; + } + ts.isThisInitializedObjectBindingExpression = isThisInitializedObjectBindingExpression; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 173 /* TypeReference */: + case 175 /* TypeReference */: return node.typeName; - case 223 /* ExpressionWithTypeArguments */: + case 225 /* 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 78 /* Identifier */: - case 157 /* QualifiedName */: + case 79 /* Identifier */: + case 159 /* QualifiedName */: return node; } return undefined; @@ -15131,10 +15510,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return node.tag; - case 275 /* JsxOpeningElement */: - case 274 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -15147,25 +15526,25 @@ var ts; return false; } switch (node.kind) { - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: // classes are valid targets return true; - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 252 /* ClassDeclaration */; - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 165 /* MethodDeclaration */: + return parent.kind === 254 /* ClassDeclaration */; + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 167 /* 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 === 252 /* ClassDeclaration */; - case 160 /* Parameter */: + && parent.kind === 254 /* ClassDeclaration */; + case 162 /* 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 === 166 /* Constructor */ - || parent.kind === 165 /* MethodDeclaration */ - || parent.kind === 168 /* SetAccessor */) - && grandparent.kind === 252 /* ClassDeclaration */; + && (parent.kind === 168 /* Constructor */ + || parent.kind === 167 /* MethodDeclaration */ + || parent.kind === 170 /* SetAccessor */) + && grandparent.kind === 254 /* ClassDeclaration */; } return false; } @@ -15181,10 +15560,10 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 - case 165 /* MethodDeclaration */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 170 /* SetAccessor */: return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); // TODO: GH#18217 default: return false; @@ -15193,9 +15572,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 275 /* JsxOpeningElement */ || - parent.kind === 274 /* JsxSelfClosingElement */ || - parent.kind === 276 /* JsxClosingElement */) { + if (parent.kind === 277 /* JsxOpeningElement */ || + parent.kind === 276 /* JsxSelfClosingElement */ || + parent.kind === 278 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -15203,49 +15582,54 @@ var ts; ts.isJSXTagName = isJSXTagName; function isExpressionNode(node) { switch (node.kind) { - case 105 /* SuperKeyword */: - case 103 /* NullKeyword */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: + case 106 /* SuperKeyword */: + case 104 /* NullKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: case 13 /* RegularExpressionLiteral */: - case 199 /* ArrayLiteralExpression */: - case 200 /* ObjectLiteralExpression */: - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: - case 203 /* CallExpression */: - case 204 /* NewExpression */: - case 205 /* TaggedTemplateExpression */: - case 224 /* AsExpression */: - case 206 /* TypeAssertionExpression */: - case 225 /* NonNullExpression */: - case 207 /* ParenthesizedExpression */: - case 208 /* FunctionExpression */: - case 221 /* ClassExpression */: - case 209 /* ArrowFunction */: - case 212 /* VoidExpression */: - case 210 /* DeleteExpression */: - case 211 /* TypeOfExpression */: - case 214 /* PrefixUnaryExpression */: - case 215 /* PostfixUnaryExpression */: - case 216 /* BinaryExpression */: - case 217 /* ConditionalExpression */: - case 220 /* SpreadElement */: - case 218 /* TemplateExpression */: - case 222 /* OmittedExpression */: - case 273 /* JsxElement */: - case 274 /* JsxSelfClosingElement */: - case 277 /* JsxFragment */: - case 219 /* YieldExpression */: - case 213 /* AwaitExpression */: - case 226 /* MetaProperty */: + case 201 /* ArrayLiteralExpression */: + case 202 /* ObjectLiteralExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: + case 207 /* TaggedTemplateExpression */: + case 226 /* AsExpression */: + case 208 /* TypeAssertionExpression */: + case 227 /* NonNullExpression */: + case 209 /* ParenthesizedExpression */: + case 210 /* FunctionExpression */: + case 223 /* ClassExpression */: + case 211 /* ArrowFunction */: + case 214 /* VoidExpression */: + case 212 /* DeleteExpression */: + case 213 /* TypeOfExpression */: + case 216 /* PrefixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: + case 218 /* BinaryExpression */: + case 219 /* ConditionalExpression */: + case 222 /* SpreadElement */: + case 220 /* TemplateExpression */: + case 224 /* OmittedExpression */: + case 275 /* JsxElement */: + case 276 /* JsxSelfClosingElement */: + case 279 /* JsxFragment */: + case 221 /* YieldExpression */: + case 215 /* AwaitExpression */: + case 228 /* MetaProperty */: return true; - case 157 /* QualifiedName */: - while (node.parent.kind === 157 /* QualifiedName */) { + case 159 /* QualifiedName */: + while (node.parent.kind === 159 /* QualifiedName */) { + node = node.parent; + } + return node.parent.kind === 178 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); + case 305 /* JSDocMemberName */: + while (ts.isJSDocMemberName(node.parent)) { node = node.parent; } - return node.parent.kind === 176 /* TypeQuery */ || isJSXTagName(node); - case 78 /* Identifier */: - if (node.parent.kind === 176 /* TypeQuery */ || isJSXTagName(node)) { + return node.parent.kind === 178 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); + case 79 /* Identifier */: + if (node.parent.kind === 178 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node)) { return true; } // falls through @@ -15253,7 +15637,7 @@ var ts; case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: return isInExpressionContext(node); default: return false; @@ -15263,49 +15647,49 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 249 /* VariableDeclaration */: - case 160 /* Parameter */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 291 /* EnumMember */: - case 288 /* PropertyAssignment */: - case 198 /* BindingElement */: + case 251 /* VariableDeclaration */: + case 162 /* Parameter */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 293 /* EnumMember */: + case 290 /* PropertyAssignment */: + case 200 /* BindingElement */: return parent.initializer === node; - case 233 /* ExpressionStatement */: - case 234 /* IfStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: - case 242 /* ReturnStatement */: - case 243 /* WithStatement */: - case 244 /* SwitchStatement */: - case 284 /* CaseClause */: - case 246 /* ThrowStatement */: + case 235 /* ExpressionStatement */: + case 236 /* IfStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: + case 244 /* ReturnStatement */: + case 245 /* WithStatement */: + case 246 /* SwitchStatement */: + case 286 /* CaseClause */: + case 248 /* ThrowStatement */: return parent.expression === node; - case 237 /* ForStatement */: + case 239 /* ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 250 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 252 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 250 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 252 /* VariableDeclarationList */) || forInStatement.expression === node; - case 206 /* TypeAssertionExpression */: - case 224 /* AsExpression */: + case 208 /* TypeAssertionExpression */: + case 226 /* AsExpression */: return node === parent.expression; - case 228 /* TemplateSpan */: + case 230 /* TemplateSpan */: return node === parent.expression; - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return node === parent.expression; - case 161 /* Decorator */: - case 283 /* JsxExpression */: - case 282 /* JsxSpreadAttribute */: - case 290 /* SpreadAssignment */: + case 163 /* Decorator */: + case 285 /* JsxExpression */: + case 284 /* JsxSpreadAttribute */: + case 292 /* SpreadAssignment */: return true; - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return parent.objectAssignmentInitializer === node; default: return isExpressionNode(parent); @@ -15313,14 +15697,18 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isPartOfTypeQuery(node) { - while (node.kind === 157 /* QualifiedName */ || node.kind === 78 /* Identifier */) { + while (node.kind === 159 /* QualifiedName */ || node.kind === 79 /* Identifier */) { node = node.parent; } - return node.kind === 176 /* TypeQuery */; + return node.kind === 178 /* TypeQuery */; } ts.isPartOfTypeQuery = isPartOfTypeQuery; + function isNamespaceReexportDeclaration(node) { + return ts.isNamespaceExport(node) && !!node.parent.moduleSpecifier; + } + ts.isNamespaceReexportDeclaration = isNamespaceReexportDeclaration; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 260 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 272 /* ExternalModuleReference */; + return node.kind === 262 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 274 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -15329,12 +15717,11 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function getExternalModuleRequireArgument(node) { - return isRequireVariableDeclaration(node, /*requireStringLiteralLikeArgument*/ true) - && getLeftmostAccessExpression(node.initializer).arguments[0]; + return isRequireVariableDeclaration(node) && getLeftmostAccessExpression(node.initializer).arguments[0]; } ts.getExternalModuleRequireArgument = getExternalModuleRequireArgument; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 260 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 272 /* ExternalModuleReference */; + return node.kind === 262 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 274 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJS(file) { @@ -15366,15 +15753,15 @@ var ts; ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && node.typeArguments && node.typeArguments.length === 2 && - (node.typeArguments[0].kind === 147 /* StringKeyword */ || node.typeArguments[0].kind === 144 /* NumberKeyword */); + (node.typeArguments[0].kind === 148 /* StringKeyword */ || node.typeArguments[0].kind === 145 /* NumberKeyword */); } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, requireStringLiteralLikeArgument) { - if (callExpression.kind !== 203 /* CallExpression */) { + if (callExpression.kind !== 205 /* CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; - if (expression.kind !== 78 /* Identifier */ || expression.escapedText !== "require") { + if (expression.kind !== 79 /* Identifier */ || expression.escapedText !== "require") { return false; } if (args.length !== 1) { @@ -15384,18 +15771,21 @@ var ts; return !requireStringLiteralLikeArgument || ts.isStringLiteralLike(arg); } ts.isRequireCall = isRequireCall; - function isRequireVariableDeclaration(node, requireStringLiteralLikeArgument) { - if (node.kind === 198 /* BindingElement */) { + /** + * Returns true if the node is a VariableDeclaration initialized to a require call (see `isRequireCall`). + * This function does not test if the node is in a JavaScript file or not. + */ + function isRequireVariableDeclaration(node) { + if (node.kind === 200 /* BindingElement */) { node = node.parent.parent; } - return ts.isVariableDeclaration(node) && !!node.initializer && isRequireCall(getLeftmostAccessExpression(node.initializer), requireStringLiteralLikeArgument); + return ts.isVariableDeclaration(node) && !!node.initializer && isRequireCall(getLeftmostAccessExpression(node.initializer), /*requireStringLiteralLikeArgument*/ true); } ts.isRequireVariableDeclaration = isRequireVariableDeclaration; - function isRequireVariableStatement(node, requireStringLiteralLikeArgument) { - if (requireStringLiteralLikeArgument === void 0) { requireStringLiteralLikeArgument = true; } + function isRequireVariableStatement(node) { return ts.isVariableStatement(node) && node.declarationList.declarations.length > 0 - && ts.every(node.declarationList.declarations, function (decl) { return isRequireVariableDeclaration(decl, requireStringLiteralLikeArgument); }); + && ts.every(node.declarationList.declarations, function (decl) { return isRequireVariableDeclaration(decl); }); } ts.isRequireVariableStatement = isRequireVariableStatement; function isSingleOrDoubleQuote(charCode) { @@ -15441,7 +15831,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 === 62 /* EqualsToken */) { + if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* EqualsToken */) { var isPrototypeAssignment = isPrototypeAccess(node.parent.left); return getExpandoInitializer(node.parent.right, isPrototypeAssignment) || getDefaultedExpandoInitializer(node.parent.left, node.parent.right, isPrototypeAssignment); @@ -15467,11 +15857,11 @@ var ts; function getExpandoInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 208 /* FunctionExpression */ || e.kind === 209 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 210 /* FunctionExpression */ || e.kind === 211 /* ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 208 /* FunctionExpression */ || - initializer.kind === 221 /* ClassExpression */ || - initializer.kind === 209 /* ArrowFunction */) { + if (initializer.kind === 210 /* FunctionExpression */ || + initializer.kind === 223 /* ClassExpression */ || + initializer.kind === 211 /* ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -15497,7 +15887,7 @@ var ts; } function isDefaultedExpandoInitializer(node) { var name = ts.isVariableDeclaration(node.parent) ? node.parent.name : - ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 /* EqualsToken */ ? node.parent.left : + ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* EqualsToken */ ? node.parent.left : undefined; return name && getExpandoInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left); } @@ -15506,7 +15896,7 @@ var ts; 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 === 62 /* EqualsToken */ && ts.isIdentifier(parent.left)) { + if (parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isIdentifier(parent.left)) { return parent.left; } } @@ -15529,7 +15919,7 @@ var ts; return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(initializer); } if (ts.isIdentifier(name) && isLiteralLikeAccess(initializer) && - (initializer.expression.kind === 107 /* ThisKeyword */ || + (initializer.expression.kind === 108 /* ThisKeyword */ || ts.isIdentifier(initializer.expression) && (initializer.expression.escapedText === "window" || initializer.expression.escapedText === "self" || @@ -15592,20 +15982,19 @@ var ts; ts.isLiteralLikeAccess = isLiteralLikeAccess; /** x[0] OR x['a'] OR x[Symbol.y] */ function isLiteralLikeElementAccess(node) { - return ts.isElementAccessExpression(node) && (isStringOrNumericLiteralLike(node.argumentExpression) || - isWellKnownSymbolSyntactically(node.argumentExpression)); + return ts.isElementAccessExpression(node) && isStringOrNumericLiteralLike(node.argumentExpression); } ts.isLiteralLikeElementAccess = isLiteralLikeElementAccess; /** Any series of property and element accesses. */ function isBindableStaticAccessExpression(node, excludeThisKeyword) { - return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 107 /* ThisKeyword */ || ts.isIdentifier(node.name) && isBindableStaticNameExpression(node.expression, /*excludeThisKeyword*/ true)) + return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 108 /* 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 === 107 /* ThisKeyword */) || + && ((!excludeThisKeyword && node.expression.kind === 108 /* ThisKeyword */) || isEntityNameExpression(node.expression) || isBindableStaticAccessExpression(node.expression, /*excludeThisKeyword*/ true)); } @@ -15635,7 +16024,7 @@ var ts; } return 7 /* ObjectDefinePropertyValue */; } - if (expr.operatorToken.kind !== 62 /* EqualsToken */ || !isAccessExpression(expr.left) || isVoidZero(getRightMostAssignedExpression(expr))) { + if (expr.operatorToken.kind !== 63 /* EqualsToken */ || !isAccessExpression(expr.left) || isVoidZero(getRightMostAssignedExpression(expr))) { return 0 /* None */; } if (isBindableStaticNameExpression(expr.left.expression, /*excludeThisKeyword*/ true) && getElementOrPropertyAccessName(expr.left) === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { @@ -15673,14 +16062,11 @@ var ts; return ts.escapeLeadingUnderscores(name.text); } } - if (ts.isElementAccessExpression(node) && isWellKnownSymbolSyntactically(node.argumentExpression)) { - return getPropertyNameForKnownSymbolName(ts.idText(node.argumentExpression.name)); - } return undefined; } ts.getElementOrPropertyAccessName = getElementOrPropertyAccessName; function getAssignmentDeclarationPropertyAccessKind(lhs) { - if (lhs.expression.kind === 107 /* ThisKeyword */) { + if (lhs.expression.kind === 108 /* ThisKeyword */) { return 4 /* ThisProperty */; } else if (isModuleExportsAccessExpression(lhs)) { @@ -15725,7 +16111,7 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJSFile(expr) && - expr.parent && expr.parent.kind === 233 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 235 /* ExpressionStatement */ && (!ts.isElementAccessExpression(expr) || isLiteralLikeElementAccess(expr)) && !!ts.getJSDocTypeTag(expr.parent); } @@ -15746,23 +16132,37 @@ var ts; return false; } var decl = symbol.valueDeclaration; - return decl.kind === 251 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); + return decl.kind === 253 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); } ts.isFunctionSymbol = isFunctionSymbol; + function tryGetModuleSpecifierFromDeclaration(node) { + var _a, _b, _c; + switch (node.kind) { + case 251 /* VariableDeclaration */: + return node.initializer.arguments[0].text; + case 263 /* ImportDeclaration */: + return (_a = ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike)) === null || _a === void 0 ? void 0 : _a.text; + case 262 /* ImportEqualsDeclaration */: + return (_c = ts.tryCast((_b = ts.tryCast(node.moduleReference, ts.isExternalModuleReference)) === null || _b === void 0 ? void 0 : _b.expression, ts.isStringLiteralLike)) === null || _c === void 0 ? void 0 : _c.text; + default: + ts.Debug.assertNever(node); + } + } + ts.tryGetModuleSpecifierFromDeclaration = tryGetModuleSpecifierFromDeclaration; function importFromModuleSpecifier(node) { return tryGetImportFromModuleSpecifier(node) || ts.Debug.failBadSyntaxKind(node.parent); } ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 261 /* ImportDeclaration */: - case 267 /* ExportDeclaration */: + case 263 /* ImportDeclaration */: + case 269 /* ExportDeclaration */: return node.parent; - case 272 /* ExternalModuleReference */: + case 274 /* ExternalModuleReference */: return node.parent.parent; - case 203 /* CallExpression */: + case 205 /* CallExpression */: return isImportCall(node.parent) || isRequireCall(node.parent, /*checkArg*/ false) ? node.parent : undefined; - case 191 /* LiteralType */: + case 193 /* LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -15772,15 +16172,17 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: - case 267 /* ExportDeclaration */: + case 263 /* ImportDeclaration */: + case 269 /* ExportDeclaration */: return node.moduleSpecifier; - case 260 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 272 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 195 /* ImportType */: + case 262 /* ImportEqualsDeclaration */: + return node.moduleReference.kind === 274 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 197 /* ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; - case 203 /* CallExpression */: + case 205 /* CallExpression */: return node.arguments[0]; + case 258 /* ModuleDeclaration */: + return node.name.kind === 10 /* StringLiteral */ ? node.name : undefined; default: return ts.Debug.assertNever(node); } @@ -15788,11 +16190,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return node; - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: return node.exportClause && ts.tryCast(node.exportClause, ts.isNamespaceExport); default: return ts.Debug.assertNever(node); @@ -15800,7 +16202,7 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 261 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 263 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function forEachImportClauseDeclaration(node, action) { @@ -15821,13 +16223,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 160 /* Parameter */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 289 /* ShorthandPropertyAssignment */: - case 288 /* PropertyAssignment */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 162 /* Parameter */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 291 /* ShorthandPropertyAssignment */: + case 290 /* PropertyAssignment */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -15841,7 +16243,7 @@ var ts; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 331 /* JSDocTypedefTag */ || node.kind === 324 /* JSDocCallbackTag */ || node.kind === 325 /* JSDocEnumTag */; + return node.kind === 339 /* JSDocTypedefTag */ || node.kind === 332 /* JSDocCallbackTag */ || node.kind === 333 /* JSDocEnumTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -15851,7 +16253,7 @@ var ts; function getSourceOfAssignment(node) { return ts.isExpressionStatement(node) && ts.isBinaryExpression(node.expression) && - node.expression.operatorToken.kind === 62 /* EqualsToken */ + node.expression.operatorToken.kind === 63 /* EqualsToken */ ? getRightMostAssignedExpression(node.expression) : undefined; } @@ -15866,12 +16268,12 @@ var ts; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return node.initializer; - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: return node.initializer; } } @@ -15883,7 +16285,7 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 256 /* ModuleDeclaration */ + node.body.kind === 258 /* ModuleDeclaration */ ? node.body : undefined; } @@ -15898,11 +16300,11 @@ var ts; if (ts.hasJSDocNodes(node)) { result = ts.append(result, ts.last(node.jsDoc)); } - if (node.kind === 160 /* Parameter */) { + if (node.kind === 162 /* Parameter */) { result = ts.addRange(result, (noCache ? ts.getJSDocParameterTagsNoCache : ts.getJSDocParameterTags)(node)); break; } - if (node.kind === 159 /* TypeParameter */) { + if (node.kind === 161 /* TypeParameter */) { result = ts.addRange(result, (noCache ? ts.getJSDocTypeParameterTagsNoCache : ts.getJSDocTypeParameterTags)(node)); break; } @@ -15913,12 +16315,13 @@ var ts; ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; function getNextJSDocCommentLocation(node) { var parent = node.parent; - if (parent.kind === 288 /* PropertyAssignment */ || - parent.kind === 266 /* ExportAssignment */ || - parent.kind === 163 /* PropertyDeclaration */ || - parent.kind === 233 /* ExpressionStatement */ && node.kind === 201 /* PropertyAccessExpression */ || + if (parent.kind === 290 /* PropertyAssignment */ || + parent.kind === 268 /* ExportAssignment */ || + parent.kind === 165 /* PropertyDeclaration */ || + parent.kind === 235 /* ExpressionStatement */ && node.kind === 203 /* PropertyAccessExpression */ || + parent.kind === 244 /* ReturnStatement */ || getNestedModuleDeclaration(parent) || - ts.isBinaryExpression(node) && node.operatorToken.kind === 62 /* EqualsToken */) { + ts.isBinaryExpression(node) && node.operatorToken.kind === 63 /* EqualsToken */) { return parent; } // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. @@ -15929,7 +16332,7 @@ var ts; // var x = function(name) { return name.length; } else if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node || - ts.isBinaryExpression(parent) && parent.operatorToken.kind === 62 /* EqualsToken */)) { + ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */)) { return parent.parent; } else if (parent.parent && parent.parent.parent && @@ -15953,7 +16356,7 @@ var ts; if (!decl) { return undefined; } - var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 78 /* Identifier */ && p.name.escapedText === name; }); + var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 79 /* Identifier */ && p.name.escapedText === name; }); return parameter && parameter.symbol; } ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc; @@ -16003,7 +16406,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 === 309 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 312 /* JSDocVariadicType */; } ts.isRestParameter = isRestParameter; function hasTypeArguments(node) { @@ -16020,31 +16423,34 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 62 /* EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* Definite */ : 2 /* Compound */ : + binaryOperator === 63 /* EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; - case 214 /* PrefixUnaryExpression */: - case 215 /* PostfixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; return unaryOperator === 45 /* PlusPlusToken */ || unaryOperator === 46 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 207 /* ParenthesizedExpression */: - case 199 /* ArrayLiteralExpression */: - case 220 /* SpreadElement */: - case 225 /* NonNullExpression */: + case 209 /* ParenthesizedExpression */: + case 201 /* ArrayLiteralExpression */: + case 222 /* SpreadElement */: + case 227 /* NonNullExpression */: node = parent; break; - case 289 /* ShorthandPropertyAssignment */: + case 292 /* SpreadAssignment */: + node = parent.parent; + break; + case 291 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } node = parent.parent; break; - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: if (parent.name === node) { return 0 /* None */; } @@ -16071,22 +16477,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 230 /* Block */: - case 232 /* VariableStatement */: - case 243 /* WithStatement */: - case 234 /* IfStatement */: - case 244 /* SwitchStatement */: - case 258 /* CaseBlock */: - case 284 /* CaseClause */: - case 285 /* DefaultClause */: - case 245 /* LabeledStatement */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: - case 247 /* TryStatement */: - case 287 /* CatchClause */: + case 232 /* Block */: + case 234 /* VariableStatement */: + case 245 /* WithStatement */: + case 236 /* IfStatement */: + case 246 /* SwitchStatement */: + case 260 /* CaseBlock */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: + case 247 /* LabeledStatement */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: + case 249 /* TryStatement */: + case 289 /* CatchClause */: return true; } return false; @@ -16103,11 +16509,11 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 186 /* ParenthesizedType */); + return walkUp(node, 188 /* ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 207 /* ParenthesizedExpression */); + return walkUp(node, 209 /* ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; /** @@ -16117,7 +16523,7 @@ var ts; */ function walkUpParenthesizedTypesAndGetParentAndChild(node) { var child; - while (node && node.kind === 186 /* ParenthesizedType */) { + while (node && node.kind === 188 /* ParenthesizedType */) { child = node; node = node.parent; } @@ -16128,19 +16534,13 @@ var ts; return ts.skipOuterExpressions(node, 1 /* Parentheses */); } ts.skipParentheses = skipParentheses; - function skipParenthesesUp(node) { - while (node.kind === 207 /* ParenthesizedExpression */) { - node = node.parent; - } - return node; - } // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped function isDeleteTarget(node) { - if (node.kind !== 201 /* PropertyAccessExpression */ && node.kind !== 202 /* ElementAccessExpression */) { + if (node.kind !== 203 /* PropertyAccessExpression */ && node.kind !== 204 /* ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 210 /* DeleteExpression */; + return node && node.kind === 212 /* DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -16167,7 +16567,7 @@ var ts; if (ts.isComputedPropertyName(parent)) return parent.parent; // falls through - case 78 /* Identifier */: + case 79 /* Identifier */: if (ts.isDeclaration(parent)) { return parent.name === name ? parent : undefined; } @@ -16184,7 +16584,7 @@ var ts; ? binExp : undefined; } - case 79 /* PrivateIdentifier */: + case 80 /* PrivateIdentifier */: return ts.isDeclaration(parent) && parent.name === name ? parent : undefined; default: return undefined; @@ -16193,7 +16593,7 @@ var ts; ts.getDeclarationFromName = getDeclarationFromName; function isLiteralComputedPropertyDeclarationName(node) { return isStringOrNumericLiteralLike(node) && - node.parent.kind === 158 /* ComputedPropertyName */ && + node.parent.kind === 160 /* ComputedPropertyName */ && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -16201,26 +16601,26 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 291 /* EnumMember */: - case 288 /* PropertyAssignment */: - case 201 /* PropertyAccessExpression */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 293 /* EnumMember */: + case 290 /* PropertyAssignment */: + case 203 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 157 /* QualifiedName */: + case 159 /* QualifiedName */: // Name on right hand side of dot in a type query or type reference return parent.right === node; - case 198 /* BindingElement */: - case 265 /* ImportSpecifier */: + case 200 /* BindingElement */: + case 267 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 270 /* ExportSpecifier */: - case 280 /* JsxAttribute */: + case 272 /* ExportSpecifier */: + case 282 /* JsxAttribute */: // Any name in an export specifier or JSX Attribute return true; } @@ -16240,33 +16640,33 @@ var ts; // {} // {name: } function isAliasSymbolDeclaration(node) { - return node.kind === 260 /* ImportEqualsDeclaration */ || - node.kind === 259 /* NamespaceExportDeclaration */ || - node.kind === 262 /* ImportClause */ && !!node.name || - node.kind === 263 /* NamespaceImport */ || - node.kind === 269 /* NamespaceExport */ || - node.kind === 265 /* ImportSpecifier */ || - node.kind === 270 /* ExportSpecifier */ || - node.kind === 266 /* ExportAssignment */ && exportAssignmentIsAlias(node) || + return node.kind === 262 /* ImportEqualsDeclaration */ || + node.kind === 261 /* NamespaceExportDeclaration */ || + node.kind === 264 /* ImportClause */ && !!node.name || + node.kind === 265 /* NamespaceImport */ || + node.kind === 271 /* NamespaceExport */ || + node.kind === 267 /* ImportSpecifier */ || + node.kind === 272 /* ExportSpecifier */ || + node.kind === 268 /* ExportAssignment */ && exportAssignmentIsAlias(node) || ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) || - ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62 /* EqualsToken */ && isAliasableExpression(node.parent.right) || - node.kind === 289 /* ShorthandPropertyAssignment */ || - node.kind === 288 /* PropertyAssignment */ && isAliasableExpression(node.initializer); + ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* EqualsToken */ && isAliasableExpression(node.parent.right) || + node.kind === 291 /* ShorthandPropertyAssignment */ || + node.kind === 290 /* PropertyAssignment */ && isAliasableExpression(node.initializer); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getAliasDeclarationFromName(node) { switch (node.parent.kind) { - case 262 /* ImportClause */: - case 265 /* ImportSpecifier */: - case 263 /* NamespaceImport */: - case 270 /* ExportSpecifier */: - case 266 /* ExportAssignment */: - case 260 /* ImportEqualsDeclaration */: + case 264 /* ImportClause */: + case 267 /* ImportSpecifier */: + case 265 /* NamespaceImport */: + case 272 /* ExportSpecifier */: + case 268 /* ExportAssignment */: + case 262 /* ImportEqualsDeclaration */: return node.parent; - case 157 /* QualifiedName */: + case 159 /* QualifiedName */: do { node = node.parent; - } while (node.parent.kind === 157 /* QualifiedName */); + } while (node.parent.kind === 159 /* QualifiedName */); return getAliasDeclarationFromName(node); } } @@ -16285,7 +16685,7 @@ var ts; } ts.getExportAssignmentExpression = getExportAssignmentExpression; function getPropertyAssignmentAliasLikeExpression(node) { - return node.kind === 289 /* ShorthandPropertyAssignment */ ? node.name : node.kind === 288 /* PropertyAssignment */ ? node.initializer : + return node.kind === 291 /* ShorthandPropertyAssignment */ ? node.name : node.kind === 290 /* PropertyAssignment */ ? node.initializer : node.parent.right; } ts.getPropertyAssignmentAliasLikeExpression = getPropertyAssignmentAliasLikeExpression; @@ -16302,7 +16702,7 @@ var ts; } ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode; function getClassExtendsHeritageElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 93 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 94 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement; @@ -16311,7 +16711,7 @@ var ts; return ts.getJSDocImplementsTags(node).map(function (n) { return n.class; }); } else { - var heritageClause = getHeritageClause(node.heritageClauses, 116 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 117 /* ImplementsKeyword */); return heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.types; } } @@ -16324,7 +16724,7 @@ var ts; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 93 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 94 /* ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -16351,11 +16751,11 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 80 /* FirstKeyword */ <= token && token <= 156 /* LastKeyword */; + return 81 /* FirstKeyword */ <= token && token <= 158 /* LastKeyword */; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 125 /* FirstContextualKeyword */ <= token && token <= 156 /* LastContextualKeyword */; + return 126 /* FirstContextualKeyword */ <= token && token <= 158 /* LastContextualKeyword */; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { @@ -16363,7 +16763,7 @@ var ts; } ts.isNonContextualKeyword = isNonContextualKeyword; function isFutureReservedKeyword(token) { - return 116 /* FirstFutureReservedWord */ <= token && token <= 124 /* LastFutureReservedWord */; + return 117 /* FirstFutureReservedWord */ <= token && token <= 125 /* LastFutureReservedWord */; } ts.isFutureReservedKeyword = isFutureReservedKeyword; function isStringANonContextualKeyword(name) { @@ -16399,14 +16799,14 @@ var ts; } var flags = 0 /* Normal */; switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 165 /* MethodDeclaration */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 167 /* MethodDeclaration */: if (node.asteriskToken) { flags |= 1 /* Generator */; } // falls through - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: if (hasSyntacticModifier(node, 256 /* Async */)) { flags |= 2 /* Async */; } @@ -16420,10 +16820,10 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 167 /* MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined && hasSyntacticModifier(node, 256 /* Async */); @@ -16446,9 +16846,6 @@ var ts; * 3. The computed name is *not* expressed as a NumericLiteral. * 4. The computed name is *not* expressed as a PlusToken or MinusToken * immediately followed by a NumericLiteral. - * 5. The computed name is *not* expressed as `Symbol.`, where `` - * is a property of the Symbol constructor that denotes a built-in - * Symbol. */ function hasDynamicName(declaration) { var name = ts.getNameOfDeclaration(declaration); @@ -16456,38 +16853,25 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - if (!(name.kind === 158 /* ComputedPropertyName */ || name.kind === 202 /* ElementAccessExpression */)) { + if (!(name.kind === 160 /* ComputedPropertyName */ || name.kind === 204 /* ElementAccessExpression */)) { return false; } var expr = ts.isElementAccessExpression(name) ? skipParentheses(name.argumentExpression) : name.expression; return !isStringOrNumericLiteralLike(expr) && - !isSignedNumericLiteral(expr) && - !isWellKnownSymbolSyntactically(expr); + !isSignedNumericLiteral(expr); } ts.isDynamicName = isDynamicName; - /** - * Checks if the expression is of the form: - * Symbol.name - * where Symbol is literally the word "Symbol", and name is any identifierName - */ - function isWellKnownSymbolSyntactically(node) { - return ts.isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression); - } - ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { switch (name.kind) { - case 78 /* Identifier */: - case 79 /* PrivateIdentifier */: + case 79 /* Identifier */: + case 80 /* PrivateIdentifier */: return name.escapedText; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: var nameExpression = name.expression; - if (isWellKnownSymbolSyntactically(nameExpression)) { - return getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); - } - else if (isStringOrNumericLiteralLike(nameExpression)) { + if (isStringOrNumericLiteralLike(nameExpression)) { return ts.escapeLeadingUnderscores(nameExpression.text); } else if (isSignedNumericLiteral(nameExpression)) { @@ -16504,7 +16888,7 @@ var ts; ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; function isPropertyNameLiteral(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: @@ -16515,21 +16899,17 @@ var ts; } ts.isPropertyNameLiteral = isPropertyNameLiteral; function getTextOfIdentifierOrLiteral(node) { - return ts.isIdentifierOrPrivateIdentifier(node) ? ts.idText(node) : node.text; + return ts.isMemberName(node) ? ts.idText(node) : node.text; } ts.getTextOfIdentifierOrLiteral = getTextOfIdentifierOrLiteral; function getEscapedTextOfIdentifierOrLiteral(node) { - return ts.isIdentifierOrPrivateIdentifier(node) ? node.escapedText : ts.escapeLeadingUnderscores(node.text); + return ts.isMemberName(node) ? node.escapedText : ts.escapeLeadingUnderscores(node.text); } ts.getEscapedTextOfIdentifierOrLiteral = getEscapedTextOfIdentifierOrLiteral; function getPropertyNameForUniqueESSymbol(symbol) { return "__@" + ts.getSymbolId(symbol) + "@" + symbol.escapedName; } ts.getPropertyNameForUniqueESSymbol = getPropertyNameForUniqueESSymbol; - function getPropertyNameForKnownSymbolName(symbolName) { - return "__@" + symbolName; - } - ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; function getSymbolNameForPrivateIdentifier(containingClassSymbol, description) { return "__#" + ts.getSymbolId(containingClassSymbol) + "@" + description; } @@ -16542,7 +16922,7 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 78 /* Identifier */ && node.escapedText === "Symbol"; + return node.kind === 79 /* Identifier */ && node.escapedText === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isPushOrUnshiftIdentifier(node) { @@ -16551,11 +16931,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 160 /* Parameter */; + return root.kind === 162 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 198 /* BindingElement */) { + while (node.kind === 200 /* BindingElement */) { node = node.parent.parent; } return node; @@ -16563,15 +16943,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 166 /* Constructor */ - || kind === 208 /* FunctionExpression */ - || kind === 251 /* FunctionDeclaration */ - || kind === 209 /* ArrowFunction */ - || kind === 165 /* MethodDeclaration */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */ - || kind === 256 /* ModuleDeclaration */ - || kind === 297 /* SourceFile */; + return kind === 168 /* Constructor */ + || kind === 210 /* FunctionExpression */ + || kind === 253 /* FunctionDeclaration */ + || kind === 211 /* ArrowFunction */ + || kind === 167 /* MethodDeclaration */ + || kind === 169 /* GetAccessor */ + || kind === 170 /* SetAccessor */ + || kind === 258 /* ModuleDeclaration */ + || kind === 299 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -16590,41 +16970,41 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 204 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 206 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 204 /* NewExpression */: + case 206 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 214 /* PrefixUnaryExpression */: - case 211 /* TypeOfExpression */: - case 212 /* VoidExpression */: - case 210 /* DeleteExpression */: - case 213 /* AwaitExpression */: - case 217 /* ConditionalExpression */: - case 219 /* YieldExpression */: + case 216 /* PrefixUnaryExpression */: + case 213 /* TypeOfExpression */: + case 214 /* VoidExpression */: + case 212 /* DeleteExpression */: + case 215 /* AwaitExpression */: + case 219 /* ConditionalExpression */: + case 221 /* YieldExpression */: return 1 /* Right */; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: switch (operator) { case 42 /* AsteriskAsteriskToken */: - case 62 /* EqualsToken */: - case 63 /* PlusEqualsToken */: - case 64 /* MinusEqualsToken */: - case 66 /* AsteriskAsteriskEqualsToken */: - case 65 /* AsteriskEqualsToken */: - case 67 /* SlashEqualsToken */: - case 68 /* PercentEqualsToken */: - case 69 /* LessThanLessThanEqualsToken */: - case 70 /* GreaterThanGreaterThanEqualsToken */: - case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 72 /* AmpersandEqualsToken */: - case 77 /* CaretEqualsToken */: - case 73 /* BarEqualsToken */: - case 74 /* BarBarEqualsToken */: - case 75 /* AmpersandAmpersandEqualsToken */: - case 76 /* QuestionQuestionEqualsToken */: + 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 */; } } @@ -16633,15 +17013,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 204 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 206 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 216 /* BinaryExpression */) { + if (expression.kind === 218 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 214 /* PrefixUnaryExpression */ || expression.kind === 215 /* PostfixUnaryExpression */) { + else if (expression.kind === 216 /* PrefixUnaryExpression */ || expression.kind === 217 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -16820,81 +17200,82 @@ var ts; })(OperatorPrecedence = ts.OperatorPrecedence || (ts.OperatorPrecedence = {})); function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 337 /* CommaListExpression */: + case 345 /* CommaListExpression */: return 0 /* Comma */; - case 220 /* SpreadElement */: + case 222 /* SpreadElement */: return 1 /* Spread */; - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: return 2 /* Yield */; - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: return 4 /* Conditional */; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: switch (operatorKind) { case 27 /* CommaToken */: return 0 /* Comma */; - case 62 /* EqualsToken */: - case 63 /* PlusEqualsToken */: - case 64 /* MinusEqualsToken */: - case 66 /* AsteriskAsteriskEqualsToken */: - case 65 /* AsteriskEqualsToken */: - case 67 /* SlashEqualsToken */: - case 68 /* PercentEqualsToken */: - case 69 /* LessThanLessThanEqualsToken */: - case 70 /* GreaterThanGreaterThanEqualsToken */: - case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 72 /* AmpersandEqualsToken */: - case 77 /* CaretEqualsToken */: - case 73 /* BarEqualsToken */: - case 74 /* BarBarEqualsToken */: - case 75 /* AmpersandAmpersandEqualsToken */: - case 76 /* QuestionQuestionEqualsToken */: + 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 */; default: return getBinaryOperatorPrecedence(operatorKind); } // TODO: Should prefix `++` and `--` be moved to the `Update` precedence? - case 206 /* TypeAssertionExpression */: - case 225 /* NonNullExpression */: - case 214 /* PrefixUnaryExpression */: - case 211 /* TypeOfExpression */: - case 212 /* VoidExpression */: - case 210 /* DeleteExpression */: - case 213 /* AwaitExpression */: + case 208 /* TypeAssertionExpression */: + case 227 /* NonNullExpression */: + case 216 /* PrefixUnaryExpression */: + case 213 /* TypeOfExpression */: + case 214 /* VoidExpression */: + case 212 /* DeleteExpression */: + case 215 /* AwaitExpression */: return 16 /* Unary */; - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: return 17 /* Update */; - case 203 /* CallExpression */: + case 205 /* CallExpression */: return 18 /* LeftHandSide */; - case 204 /* NewExpression */: + case 206 /* NewExpression */: return hasArguments ? 19 /* Member */ : 18 /* LeftHandSide */; - case 205 /* TaggedTemplateExpression */: - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 207 /* TaggedTemplateExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: + case 228 /* MetaProperty */: return 19 /* Member */; - case 224 /* AsExpression */: + case 226 /* AsExpression */: return 11 /* Relational */; - case 107 /* ThisKeyword */: - case 105 /* SuperKeyword */: - case 78 /* Identifier */: - case 103 /* NullKeyword */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: + case 108 /* ThisKeyword */: + case 106 /* SuperKeyword */: + case 79 /* Identifier */: + case 104 /* NullKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: - case 199 /* ArrayLiteralExpression */: - case 200 /* ObjectLiteralExpression */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 221 /* ClassExpression */: + case 201 /* ArrayLiteralExpression */: + case 202 /* ObjectLiteralExpression */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 223 /* ClassExpression */: case 13 /* RegularExpressionLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 218 /* TemplateExpression */: - case 207 /* ParenthesizedExpression */: - case 222 /* OmittedExpression */: - case 273 /* JsxElement */: - case 274 /* JsxSelfClosingElement */: - case 277 /* JsxFragment */: + case 220 /* TemplateExpression */: + case 209 /* ParenthesizedExpression */: + case 224 /* OmittedExpression */: + case 275 /* JsxElement */: + case 276 /* JsxSelfClosingElement */: + case 279 /* JsxFragment */: return 20 /* Primary */; default: return -1 /* Invalid */; @@ -16924,9 +17305,9 @@ var ts; case 31 /* GreaterThanToken */: case 32 /* LessThanEqualsToken */: case 33 /* GreaterThanEqualsToken */: - case 101 /* InstanceOfKeyword */: - case 100 /* InKeyword */: - case 126 /* AsKeyword */: + case 102 /* InstanceOfKeyword */: + case 101 /* InKeyword */: + case 127 /* AsKeyword */: return 11 /* Relational */; case 47 /* LessThanLessThanToken */: case 48 /* GreaterThanGreaterThanToken */: @@ -16950,7 +17331,7 @@ var ts; function getSemanticJsxChildren(children) { return ts.filter(children, function (i) { switch (i.kind) { - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: return !!i.expression; case 11 /* JsxText */: return !i.containsOnlyTriviaWhiteSpaces; @@ -17252,7 +17633,7 @@ var ts; reportInaccessibleThisError: ts.noop, reportPrivateInBaseOfClassExpression: ts.noop, reportInaccessibleUniqueSymbolError: ts.noop, - trackSymbol: ts.noop, + trackSymbol: function () { return false; }, writeKeyword: write, writeOperator: write, writeParameter: write, @@ -17344,11 +17725,20 @@ var ts; return file.moduleName || getExternalModuleNameFromPath(host, file.fileName, referenceFile && referenceFile.fileName); } ts.getResolvedExternalModuleName = getResolvedExternalModuleName; + function getCanonicalAbsolutePath(host, path) { + return host.getCanonicalFileName(ts.getNormalizedAbsolutePath(path, host.getCurrentDirectory())); + } function getExternalModuleNameFromDeclaration(host, resolver, declaration) { var file = resolver.getExternalModuleFileFromDeclaration(declaration); if (!file || file.isDeclarationFile) { return undefined; } + // If the declaration already uses a non-relative name, and is outside the common source directory, continue to use it + var specifier = getExternalModuleName(declaration); + if (specifier && ts.isStringLiteralLike(specifier) && !ts.pathIsRelative(specifier.text) && + getCanonicalAbsolutePath(host, file.path).indexOf(getCanonicalAbsolutePath(host, ts.ensureTrailingDirectorySeparator(host.getCommonSourceDirectory()))) === -1) { + return undefined; + } return getResolvedExternalModuleName(host, file); } ts.getExternalModuleNameFromDeclaration = getExternalModuleNameFromDeclaration; @@ -17432,8 +17822,8 @@ var ts; return !(options.noEmitForJsFiles && isSourceFileJS(sourceFile)) && !sourceFile.isDeclarationFile && !host.isSourceFileFromExternalLibrary(sourceFile) && - !(isJsonSourceFile(sourceFile) && host.getResolvedProjectReferenceToRedirect(sourceFile.fileName)) && - (forceDtsEmit || !host.isSourceOfProjectReferenceRedirect(sourceFile.fileName)); + (forceDtsEmit || (!(isJsonSourceFile(sourceFile) && host.getResolvedProjectReferenceToRedirect(sourceFile.fileName)) && + !host.isSourceOfProjectReferenceRedirect(sourceFile.fileName))); } ts.sourceFileMayBeEmitted = sourceFileMayBeEmitted; function getSourceFilePathInNewDir(fileName, host, newDirPath) { @@ -17513,11 +17903,11 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return !!node && node.kind === 78 /* Identifier */ && identifierIsThisKeyword(node); + return !!node && node.kind === 79 /* Identifier */ && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 107 /* ThisKeyword */; + return id.originalKeywordKind === 108 /* ThisKeyword */; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -17528,10 +17918,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 167 /* GetAccessor */) { + if (accessor.kind === 169 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 168 /* SetAccessor */) { + else if (accessor.kind === 170 /* SetAccessor */) { setAccessor = accessor; } else { @@ -17551,10 +17941,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 167 /* GetAccessor */ && !getAccessor) { + if (member.kind === 169 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 168 /* SetAccessor */ && !setAccessor) { + if (member.kind === 170 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -17603,7 +17993,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 === 311 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 314 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -17779,7 +18169,7 @@ var ts; ts.writeCommentRange = writeCommentRange; function writeTrimmedCurrentLine(text, commentEnd, writer, newLine, pos, nextLineStart) { var end = Math.min(commentEnd, nextLineStart - 1); - var currentLineText = text.substring(pos, end).replace(/^\s+|\s+$/g, ""); + var currentLineText = ts.trimString(text.substring(pos, end)); if (currentLineText) { // trimmed forward and ending spaces text writer.writeComment(currentLineText); @@ -17826,6 +18216,18 @@ var ts; return hasSyntacticModifier(node, 32 /* Static */); } ts.hasStaticModifier = hasStaticModifier; + function hasOverrideModifier(node) { + return hasEffectiveModifier(node, 16384 /* Override */); + } + ts.hasOverrideModifier = hasOverrideModifier; + function hasAbstractModifier(node) { + return hasSyntacticModifier(node, 128 /* Abstract */); + } + ts.hasAbstractModifier = hasAbstractModifier; + function hasAmbientModifier(node) { + return hasSyntacticModifier(node, 2 /* Ambient */); + } + ts.hasAmbientModifier = hasAmbientModifier; function hasEffectiveReadonlyModifier(node) { return hasEffectiveModifier(node, 64 /* Readonly */); } @@ -17839,7 +18241,7 @@ var ts; } ts.getSelectedSyntacticModifierFlags = getSelectedSyntacticModifierFlags; function getModifierFlagsWorker(node, includeJSDoc, alwaysIncludeJSDoc) { - if (node.kind >= 0 /* FirstToken */ && node.kind <= 156 /* LastToken */) { + if (node.kind >= 0 /* FirstToken */ && node.kind <= 158 /* LastToken */) { return 0 /* None */; } if (!(node.modifierFlagsCache & 536870912 /* HasComputedFlags */)) { @@ -17884,6 +18286,8 @@ var ts; flags |= 16 /* Protected */; if (ts.getJSDocReadonlyTagNoCache(node)) flags |= 64 /* Readonly */; + if (ts.getJSDocOverrideTagNoCache(node)) + flags |= 16384 /* Override */; } if (ts.getJSDocDeprecatedTagNoCache(node)) flags |= 8192 /* Deprecated */; @@ -17906,7 +18310,7 @@ var ts; */ function getSyntacticModifierFlagsNoCache(node) { var flags = modifiersToFlags(node.modifiers); - if (node.flags & 4 /* NestedNamespace */ || (node.kind === 78 /* Identifier */ && node.isInJSDocNamespace)) { + if (node.flags & 4 /* NestedNamespace */ || (node.kind === 79 /* Identifier */ && node.isInJSDocNamespace)) { flags |= 1 /* Export */; } return flags; @@ -17925,21 +18329,26 @@ var ts; ts.modifiersToFlags = modifiersToFlags; function modifierToFlag(token) { switch (token) { - case 123 /* StaticKeyword */: return 32 /* Static */; - case 122 /* PublicKeyword */: return 4 /* Public */; - case 121 /* ProtectedKeyword */: return 16 /* Protected */; - case 120 /* PrivateKeyword */: return 8 /* Private */; - case 125 /* AbstractKeyword */: return 128 /* Abstract */; - case 92 /* ExportKeyword */: return 1 /* Export */; - case 133 /* DeclareKeyword */: return 2 /* Ambient */; - case 84 /* ConstKeyword */: return 2048 /* Const */; - case 87 /* DefaultKeyword */: return 512 /* Default */; - case 129 /* AsyncKeyword */: return 256 /* Async */; - case 142 /* ReadonlyKeyword */: return 64 /* Readonly */; + 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 134 /* DeclareKeyword */: return 2 /* Ambient */; + case 85 /* ConstKeyword */: return 2048 /* Const */; + case 88 /* DefaultKeyword */: return 512 /* Default */; + case 130 /* AsyncKeyword */: return 256 /* Async */; + case 143 /* ReadonlyKeyword */: return 64 /* Readonly */; + case 157 /* OverrideKeyword */: return 16384 /* Override */; } return 0 /* None */; } ts.modifierToFlag = modifierToFlag; + function createModifiers(modifierFlags) { + return modifierFlags ? ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(modifierFlags)) : undefined; + } + ts.createModifiers = createModifiers; function isLogicalOperator(token) { return token === 56 /* BarBarToken */ || token === 55 /* AmpersandAmpersandToken */ @@ -17947,9 +18356,9 @@ var ts; } ts.isLogicalOperator = isLogicalOperator; function isLogicalOrCoalescingAssignmentOperator(token) { - return token === 74 /* BarBarEqualsToken */ - || token === 75 /* AmpersandAmpersandEqualsToken */ - || token === 76 /* QuestionQuestionEqualsToken */; + return token === 75 /* BarBarEqualsToken */ + || token === 76 /* AmpersandAmpersandEqualsToken */ + || token === 77 /* QuestionQuestionEqualsToken */; } ts.isLogicalOrCoalescingAssignmentOperator = isLogicalOrCoalescingAssignmentOperator; function isLogicalOrCoalescingAssignmentExpression(expr) { @@ -17957,7 +18366,7 @@ var ts; } ts.isLogicalOrCoalescingAssignmentExpression = isLogicalOrCoalescingAssignmentExpression; function isAssignmentOperator(token) { - return token >= 62 /* FirstAssignment */ && token <= 77 /* LastAssignment */; + return token >= 63 /* FirstAssignment */ && token <= 78 /* LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ @@ -17970,23 +18379,27 @@ var ts; return ts.isExpressionWithTypeArguments(node) && ts.isHeritageClause(node.parent) && ts.isClassLike(node.parent.parent) - ? { class: node.parent.parent, isImplements: node.parent.token === 116 /* ImplementsKeyword */ } + ? { class: node.parent.parent, isImplements: node.parent.token === 117 /* ImplementsKeyword */ } : undefined; } ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments = tryGetClassImplementingOrExtendingExpressionWithTypeArguments; function isAssignmentExpression(node, excludeCompoundAssignment) { return ts.isBinaryExpression(node) && (excludeCompoundAssignment - ? node.operatorToken.kind === 62 /* EqualsToken */ + ? node.operatorToken.kind === 63 /* EqualsToken */ : isAssignmentOperator(node.operatorToken.kind)) && ts.isLeftHandSideExpression(node.left); } ts.isAssignmentExpression = isAssignmentExpression; + function isLeftHandSideOfAssignment(node) { + return isAssignmentExpression(node.parent) && node.parent.left === node; + } + ts.isLeftHandSideOfAssignment = isLeftHandSideOfAssignment; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 200 /* ObjectLiteralExpression */ - || kind === 199 /* ArrayLiteralExpression */; + return kind === 202 /* ObjectLiteralExpression */ + || kind === 201 /* ArrayLiteralExpression */; } return false; } @@ -17996,30 +18409,33 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { - return node.kind === 78 /* Identifier */ || isPropertyAccessEntityNameExpression(node); + return node.kind === 79 /* Identifier */ || isPropertyAccessEntityNameExpression(node); } ts.isEntityNameExpression = isEntityNameExpression; function getFirstIdentifier(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return node; - case 157 /* QualifiedName */: + case 159 /* QualifiedName */: do { node = node.left; - } while (node.kind !== 78 /* Identifier */); + } while (node.kind !== 79 /* Identifier */); return node; - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: do { node = node.expression; - } while (node.kind !== 78 /* Identifier */); + } while (node.kind !== 79 /* Identifier */); return node; } } ts.getFirstIdentifier = getFirstIdentifier; function isDottedName(node) { - return node.kind === 78 /* Identifier */ || node.kind === 107 /* ThisKeyword */ || node.kind === 105 /* SuperKeyword */ || - node.kind === 201 /* PropertyAccessExpression */ && isDottedName(node.expression) || - node.kind === 207 /* ParenthesizedExpression */ && isDottedName(node.expression); + return node.kind === 79 /* Identifier */ + || node.kind === 108 /* ThisKeyword */ + || node.kind === 106 /* SuperKeyword */ + || node.kind === 228 /* MetaProperty */ + || node.kind === 203 /* PropertyAccessExpression */ && isDottedName(node.expression) + || node.kind === 209 /* ParenthesizedExpression */ && isDottedName(node.expression); } ts.isDottedName = isDottedName; function isPropertyAccessEntityNameExpression(node) { @@ -18033,6 +18449,12 @@ var ts; return baseStr + "." + entityNameToString(expr.name); } } + else if (ts.isElementAccessExpression(expr)) { + var baseStr = tryGetPropertyAccessOrIdentifierToString(expr.expression); + if (baseStr !== undefined && ts.isPropertyName(expr.argumentExpression)) { + return baseStr + "." + getPropertyNameForPropertyNameNode(expr.argumentExpression); + } + } else if (ts.isIdentifier(expr)) { return ts.unescapeLeadingUnderscores(expr.escapedText); } @@ -18044,22 +18466,28 @@ var ts; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 157 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 201 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 159 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 203 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; + function isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName(node) { + return ts.isQualifiedName(node.parent) && node.parent.right === node + || ts.isPropertyAccessExpression(node.parent) && node.parent.name === node + || ts.isJSDocMemberName(node.parent) && node.parent.right === node; + } + ts.isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName = isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName; function isEmptyObjectLiteral(expression) { - return expression.kind === 200 /* ObjectLiteralExpression */ && + return expression.kind === 202 /* ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 199 /* ArrayLiteralExpression */ && + return expression.kind === 201 /* ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; function getLocalSymbolForExportDefault(symbol) { - if (!isExportDefaultSymbol(symbol)) + if (!isExportDefaultSymbol(symbol) || !symbol.declarations) return undefined; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; @@ -18386,8 +18814,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 255 /* EnumDeclaration */: - case 256 /* ModuleDeclaration */: + case 257 /* EnumDeclaration */: + case 258 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -18414,9 +18842,11 @@ var ts; return symbol.flags & 33554432 /* Transient */ ? symbol.checkFlags : 0; } ts.getCheckFlags = getCheckFlags; - function getDeclarationModifierFlagsFromSymbol(s) { + function getDeclarationModifierFlagsFromSymbol(s, isWrite) { + if (isWrite === void 0) { isWrite = false; } if (s.valueDeclaration) { - var flags = ts.getCombinedModifierFlags(s.valueDeclaration); + var declaration = (isWrite && s.declarations && ts.find(s.declarations, function (d) { return d.kind === 170 /* SetAccessor */; })) || s.valueDeclaration; + var flags = ts.getCombinedModifierFlags(declaration); return s.parent && s.parent.flags & 32 /* Class */ ? flags : flags & ~28 /* AccessibilityModifier */; } if (getCheckFlags(s) & 6 /* Synthetic */) { @@ -18464,35 +18894,35 @@ var ts; if (!parent) return 0 /* Read */; switch (parent.kind) { - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return accessKind(parent); - case 215 /* PostfixUnaryExpression */: - case 214 /* PrefixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: var operator = parent.operator; return operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? - operatorToken.kind === 62 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() + operatorToken.kind === 63 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() : 0 /* Read */; - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return parent.name !== node ? 0 /* Read */ : accessKind(parent); - case 288 /* PropertyAssignment */: { + case 290 /* 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 289 /* ShorthandPropertyAssignment */: + case 291 /* 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 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return accessKind(parent); default: return 0 /* 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 && skipParenthesesUp(parent.parent).kind === 233 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && walkUpParenthesizedExpressions(parent.parent).kind === 235 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; } } function reverseAccessKind(a) { @@ -18580,7 +19010,8 @@ var ts; } ts.isAbstractConstructorSymbol = isAbstractConstructorSymbol; function getClassLikeDeclarationOfSymbol(symbol) { - return ts.find(symbol.declarations, ts.isClassLike); + var _a; + return (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isClassLike); } ts.getClassLikeDeclarationOfSymbol = getClassLikeDeclarationOfSymbol; function getObjectFlags(type) { @@ -18623,7 +19054,6 @@ var ts; ts.getLastChild = getLastChild; function addToSeen(seen, key, value) { if (value === void 0) { value = true; } - key = String(key); if (seen.has(key)) { return false; } @@ -18636,37 +19066,37 @@ var ts; } ts.isObjectTypeDeclaration = isObjectTypeDeclaration; function isTypeNodeKind(kind) { - return (kind >= 172 /* FirstTypeNode */ && kind <= 195 /* LastTypeNode */) - || kind === 128 /* AnyKeyword */ - || kind === 152 /* UnknownKeyword */ - || kind === 144 /* NumberKeyword */ - || kind === 155 /* BigIntKeyword */ - || kind === 145 /* ObjectKeyword */ - || kind === 131 /* BooleanKeyword */ - || kind === 147 /* StringKeyword */ - || kind === 148 /* SymbolKeyword */ - || kind === 113 /* VoidKeyword */ - || kind === 150 /* UndefinedKeyword */ - || kind === 141 /* NeverKeyword */ - || kind === 223 /* ExpressionWithTypeArguments */ - || kind === 303 /* JSDocAllType */ - || kind === 304 /* JSDocUnknownType */ - || kind === 305 /* JSDocNullableType */ - || kind === 306 /* JSDocNonNullableType */ - || kind === 307 /* JSDocOptionalType */ - || kind === 308 /* JSDocFunctionType */ - || kind === 309 /* JSDocVariadicType */; + return (kind >= 174 /* FirstTypeNode */ && kind <= 197 /* LastTypeNode */) + || kind === 129 /* AnyKeyword */ + || kind === 153 /* UnknownKeyword */ + || kind === 145 /* NumberKeyword */ + || kind === 156 /* BigIntKeyword */ + || kind === 146 /* ObjectKeyword */ + || kind === 132 /* BooleanKeyword */ + || kind === 148 /* StringKeyword */ + || kind === 149 /* SymbolKeyword */ + || kind === 114 /* VoidKeyword */ + || kind === 151 /* UndefinedKeyword */ + || kind === 142 /* NeverKeyword */ + || kind === 225 /* ExpressionWithTypeArguments */ + || kind === 306 /* JSDocAllType */ + || kind === 307 /* JSDocUnknownType */ + || kind === 308 /* JSDocNullableType */ + || kind === 309 /* JSDocNonNullableType */ + || kind === 310 /* JSDocOptionalType */ + || kind === 311 /* JSDocFunctionType */ + || kind === 312 /* JSDocVariadicType */; } ts.isTypeNodeKind = isTypeNodeKind; function isAccessExpression(node) { - return node.kind === 201 /* PropertyAccessExpression */ || node.kind === 202 /* ElementAccessExpression */; + return node.kind === 203 /* PropertyAccessExpression */ || node.kind === 204 /* ElementAccessExpression */; } ts.isAccessExpression = isAccessExpression; function getNameOfAccessExpression(node) { - if (node.kind === 201 /* PropertyAccessExpression */) { + if (node.kind === 203 /* PropertyAccessExpression */) { return node.name; } - ts.Debug.assert(node.kind === 202 /* ElementAccessExpression */); + ts.Debug.assert(node.kind === 204 /* ElementAccessExpression */); return node.argumentExpression; } ts.getNameOfAccessExpression = getNameOfAccessExpression; @@ -18681,7 +19111,7 @@ var ts; } ts.isBundleFileTextLike = isBundleFileTextLike; function isNamedImportsOrExports(node) { - return node.kind === 264 /* NamedImports */ || node.kind === 268 /* NamedExports */; + return node.kind === 266 /* NamedImports */ || node.kind === 270 /* NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function getLeftmostAccessExpression(expr) { @@ -18694,28 +19124,28 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: node = node.operand; continue; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: node = node.left; continue; - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: node = node.condition; continue; - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: node = node.tag; continue; - case 203 /* CallExpression */: + case 205 /* CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 224 /* AsExpression */: - case 202 /* ElementAccessExpression */: - case 201 /* PropertyAccessExpression */: - case 225 /* NonNullExpression */: - case 336 /* PartiallyEmittedExpression */: + case 226 /* AsExpression */: + case 204 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 227 /* NonNullExpression */: + case 344 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -18734,7 +19164,7 @@ var ts; } function Type(checker, flags) { this.flags = flags; - if (ts.Debug.isDebugging || ts.tracing.isTracing()) { + if (ts.Debug.isDebugging || ts.tracing) { this.checker = checker; } } @@ -19078,6 +19508,10 @@ var ts; return !!(compilerOptions.declaration || compilerOptions.composite); } ts.getEmitDeclarations = getEmitDeclarations; + function shouldPreserveConstEnums(compilerOptions) { + return !!(compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); + } + ts.shouldPreserveConstEnums = shouldPreserveConstEnums; function isIncrementalCompilation(options) { return !!(options.incremental || options.composite); } @@ -19090,14 +19524,16 @@ var ts; return compilerOptions.allowJs === undefined ? !!compilerOptions.checkJs : compilerOptions.allowJs; } ts.getAllowJSCompilerOption = getAllowJSCompilerOption; + function getUseDefineForClassFields(compilerOptions) { + return compilerOptions.useDefineForClassFields === undefined ? compilerOptions.target === 99 /* ESNext */ : compilerOptions.useDefineForClassFields; + } + ts.getUseDefineForClassFields = getUseDefineForClassFields; function compilerOptionsAffectSemanticDiagnostics(newOptions, oldOptions) { - return oldOptions !== newOptions && - ts.semanticDiagnosticsOptionDeclarations.some(function (option) { return !isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); }); + return optionsHaveChanges(oldOptions, newOptions, ts.semanticDiagnosticsOptionDeclarations); } ts.compilerOptionsAffectSemanticDiagnostics = compilerOptionsAffectSemanticDiagnostics; function compilerOptionsAffectEmit(newOptions, oldOptions) { - return oldOptions !== newOptions && - ts.affectsEmitOptionDeclarations.some(function (option) { return !isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); }); + return optionsHaveChanges(oldOptions, newOptions, ts.affectsEmitOptionDeclarations); } ts.compilerOptionsAffectEmit = compilerOptionsAffectEmit; function getCompilerOptionValue(options, option) { @@ -19111,7 +19547,7 @@ var ts; 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[0] : jsxImportSourcePragmas; + var jsxImportSourcePragma = ts.isArray(jsxImportSourcePragmas) ? jsxImportSourcePragmas[jsxImportSourcePragmas.length - 1] : jsxImportSourcePragmas; return compilerOptions.jsx === 4 /* ReactJSX */ || compilerOptions.jsx === 5 /* ReactJSXDev */ || compilerOptions.jsxImportSource || @@ -19140,37 +19576,65 @@ var ts; return true; } ts.hasZeroOrOneAsteriskCharacter = hasZeroOrOneAsteriskCharacter; - function createSymlinkCache() { + function createSymlinkCache(cwd, getCanonicalFileName) { var symlinkedDirectories; + var symlinkedDirectoriesByRealpath; var symlinkedFiles; return { getSymlinkedFiles: function () { return symlinkedFiles; }, getSymlinkedDirectories: function () { return symlinkedDirectories; }, + getSymlinkedDirectoriesByRealpath: function () { return symlinkedDirectoriesByRealpath; }, setSymlinkedFile: function (path, real) { return (symlinkedFiles || (symlinkedFiles = new ts.Map())).set(path, real); }, - setSymlinkedDirectory: function (path, directory) { return (symlinkedDirectories || (symlinkedDirectories = new ts.Map())).set(path, directory); }, + setSymlinkedDirectory: function (symlink, real) { + // Large, interconnected dependency graphs in pnpm will have a huge number of symlinks + // where both the realpath and the symlink path are inside node_modules/.pnpm. Since + // this path is never a candidate for a module specifier, we can ignore it entirely. + var symlinkPath = ts.toPath(symlink, cwd, getCanonicalFileName); + if (!containsIgnoredPath(symlinkPath)) { + symlinkPath = ts.ensureTrailingDirectorySeparator(symlinkPath); + if (real !== false && !(symlinkedDirectories === null || symlinkedDirectories === void 0 ? void 0 : symlinkedDirectories.has(symlinkPath))) { + (symlinkedDirectoriesByRealpath || (symlinkedDirectoriesByRealpath = ts.createMultiMap())).add(ts.ensureTrailingDirectorySeparator(real.realPath), symlink); + } + (symlinkedDirectories || (symlinkedDirectories = new ts.Map())).set(symlinkPath, real); + } + }, + setSymlinkedDirectoryFromSymlinkedFile: function (symlink, real) { + this.setSymlinkedFile(ts.toPath(symlink, cwd, getCanonicalFileName), real); + var _a = guessDirectorySymlink(real, symlink, cwd, getCanonicalFileName) || ts.emptyArray, commonResolved = _a[0], commonOriginal = _a[1]; + if (commonResolved && commonOriginal) { + this.setSymlinkedDirectory(commonOriginal, { + real: commonResolved, + realPath: ts.toPath(commonResolved, cwd, getCanonicalFileName), + }); + } + }, }; } ts.createSymlinkCache = createSymlinkCache; function discoverProbableSymlinks(files, getCanonicalFileName, cwd) { - var cache = createSymlinkCache(); - var symlinks = ts.flatten(ts.mapDefined(files, function (sf) { - return sf.resolvedModules && ts.compact(ts.arrayFrom(ts.mapIterator(sf.resolvedModules.values(), function (res) { - return res && res.originalPath && res.resolvedFileName !== res.originalPath ? [res.resolvedFileName, res.originalPath] : undefined; + var cache = createSymlinkCache(cwd, getCanonicalFileName); + var symlinks = ts.flatMap(files, function (sf) { + var pairs = sf.resolvedModules && ts.arrayFrom(ts.mapDefinedIterator(sf.resolvedModules.values(), function (res) { + return (res === null || res === void 0 ? void 0 : res.originalPath) ? [res.resolvedFileName, res.originalPath] : undefined; + })); + return ts.concatenate(pairs, sf.resolvedTypeReferenceDirectiveNames && ts.arrayFrom(ts.mapDefinedIterator(sf.resolvedTypeReferenceDirectiveNames.values(), function (res) { + return (res === null || res === void 0 ? void 0 : res.originalPath) && res.resolvedFileName ? [res.resolvedFileName, res.originalPath] : undefined; }))); - })); + }); for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) { var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1]; + cache.setSymlinkedFile(ts.toPath(originalPath, cwd, getCanonicalFileName), resolvedPath); var _b = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName) || ts.emptyArray, commonResolved = _b[0], commonOriginal = _b[1]; if (commonResolved && commonOriginal) { - cache.setSymlinkedDirectory(ts.toPath(commonOriginal, cwd, getCanonicalFileName), { real: commonResolved, realPath: ts.toPath(commonResolved, cwd, getCanonicalFileName) }); + cache.setSymlinkedDirectory(commonOriginal, { real: commonResolved, realPath: ts.toPath(commonResolved, cwd, getCanonicalFileName) }); } } return cache; } ts.discoverProbableSymlinks = discoverProbableSymlinks; function guessDirectorySymlink(a, b, cwd, getCanonicalFileName) { - var aParts = ts.getPathComponents(ts.toPath(a, cwd, getCanonicalFileName)); - var bParts = ts.getPathComponents(ts.toPath(b, cwd, getCanonicalFileName)); + var aParts = ts.getPathComponents(ts.getNormalizedAbsolutePath(a, cwd)); + var bParts = ts.getPathComponents(ts.getNormalizedAbsolutePath(b, cwd)); var isDirectory = false; while (!isNodeModulesOrScopedPackageDirectory(aParts[aParts.length - 2], getCanonicalFileName) && !isNodeModulesOrScopedPackageDirectory(bParts[bParts.length - 2], getCanonicalFileName) && @@ -19554,6 +20018,14 @@ var ts; return false; } ts.isSupportedSourceFileName = isSupportedSourceFileName; + function numberOfDirectorySeparators(str) { + var match = str.match(/\//g); + return match ? match.length : 0; + } + function compareNumberOfDirectorySeparators(path1, path2) { + return ts.compareValues(numberOfDirectorySeparators(path1), numberOfDirectorySeparators(path2)); + } + ts.compareNumberOfDirectorySeparators = compareNumberOfDirectorySeparators; /** * Extension boundaries by priority. Lower numbers indicate higher priorities, and are * aligned to the offset of the highest priority extension in the @@ -19628,16 +20100,27 @@ var ts; return ts.changeAnyExtension(path, newExtension, extensionsToRemove, /*ignoreCase*/ false); } ts.changeExtension = changeExtension; + /** + * Returns the input if there are no stars, a pattern if there is exactly one, + * and undefined if there are more. + */ function tryParsePattern(pattern) { - // This should be verified outside of here and a proper error thrown. - ts.Debug.assert(hasZeroOrOneAsteriskCharacter(pattern)); var indexOfStar = pattern.indexOf("*"); - return indexOfStar === -1 ? undefined : { - prefix: pattern.substr(0, indexOfStar), - suffix: pattern.substr(indexOfStar + 1) - }; + if (indexOfStar === -1) { + return pattern; + } + return pattern.indexOf("*", indexOfStar + 1) !== -1 + ? undefined + : { + prefix: pattern.substr(0, indexOfStar), + suffix: pattern.substr(indexOfStar + 1) + }; } ts.tryParsePattern = tryParsePattern; + function tryParsePatterns(paths) { + return ts.mapDefined(ts.getOwnKeys(paths), function (path) { return tryParsePattern(path); }); + } + ts.tryParsePatterns = tryParsePatterns; function positionIsSynthesized(pos) { // This is a fast way of testing the following conditions: // pos === undefined || pos === null || isNaN(pos) || pos < 0; @@ -19679,23 +20162,19 @@ var ts; directories: ts.emptyArray }; /** - * patternStrings contains both pattern strings (containing "*") and regular strings. + * patternOrStrings contains both patterns (containing "*") and regular strings. * Return an exact match if possible, or a pattern match, or undefined. * (These are verified by verifyCompilerOptions to have 0 or 1 "*" characters.) */ - function matchPatternOrExact(patternStrings, candidate) { + function matchPatternOrExact(patternOrStrings, candidate) { var patterns = []; - for (var _i = 0, patternStrings_1 = patternStrings; _i < patternStrings_1.length; _i++) { - var patternString = patternStrings_1[_i]; - if (!hasZeroOrOneAsteriskCharacter(patternString)) - continue; - var pattern = tryParsePattern(patternString); - if (pattern) { - patterns.push(pattern); + for (var _i = 0, patternOrStrings_1 = patternOrStrings; _i < patternOrStrings_1.length; _i++) { + var patternOrString = patternOrStrings_1[_i]; + if (patternOrString === candidate) { + return candidate; } - else if (patternString === candidate) { - // pattern was matched as is - no need to search further - return patternString; + if (!ts.isString(patternOrString)) { + patterns.push(patternOrString); } } return ts.findBestPatternMatch(patterns, function (_) { return _; }, candidate); @@ -19850,38 +20329,38 @@ var ts; } ts.isValidTypeOnlyAliasUseSite = isValidTypeOnlyAliasUseSite; function typeOnlyDeclarationIsExport(typeOnlyDeclaration) { - return typeOnlyDeclaration.kind === 270 /* ExportSpecifier */; + return typeOnlyDeclaration.kind === 272 /* ExportSpecifier */; } ts.typeOnlyDeclarationIsExport = typeOnlyDeclarationIsExport; function isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(node) { - while (node.kind === 78 /* Identifier */ || node.kind === 201 /* PropertyAccessExpression */) { + while (node.kind === 79 /* Identifier */ || node.kind === 203 /* PropertyAccessExpression */) { node = node.parent; } - if (node.kind !== 158 /* ComputedPropertyName */) { + if (node.kind !== 160 /* ComputedPropertyName */) { return false; } if (hasSyntacticModifier(node.parent, 128 /* Abstract */)) { return true; } var containerKind = node.parent.parent.kind; - return containerKind === 253 /* InterfaceDeclaration */ || containerKind === 177 /* TypeLiteral */; + return containerKind === 255 /* InterfaceDeclaration */ || containerKind === 179 /* 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 !== 78 /* Identifier */) + if (node.kind !== 79 /* Identifier */) return false; var heritageClause = ts.findAncestor(node.parent, function (parent) { switch (parent.kind) { - case 286 /* HeritageClause */: + case 288 /* HeritageClause */: return true; - case 201 /* PropertyAccessExpression */: - case 223 /* ExpressionWithTypeArguments */: + case 203 /* PropertyAccessExpression */: + case 225 /* ExpressionWithTypeArguments */: return false; default: return "quit"; } }); - return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 116 /* ImplementsKeyword */ || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 253 /* InterfaceDeclaration */; + return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 117 /* ImplementsKeyword */ || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 255 /* InterfaceDeclaration */; } function isIdentifierTypeReference(node) { return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName); @@ -20034,6 +20513,76 @@ var ts; } } ts.expressionResultIsUnused = expressionResultIsUnused; + function containsIgnoredPath(path) { + return ts.some(ts.ignoredPaths, function (p) { return ts.stringContains(path, p); }); + } + ts.containsIgnoredPath = containsIgnoredPath; + function getContainingNodeArray(node) { + if (!node.parent) + return undefined; + switch (node.kind) { + case 161 /* TypeParameter */: + var parent_1 = node.parent; + return parent_1.kind === 187 /* InferType */ ? undefined : parent_1.typeParameters; + case 162 /* Parameter */: + return node.parent.parameters; + case 196 /* TemplateLiteralTypeSpan */: + return node.parent.templateSpans; + case 230 /* TemplateSpan */: + return node.parent.templateSpans; + case 163 /* Decorator */: + return node.parent.decorators; + case 288 /* HeritageClause */: + return node.parent.heritageClauses; + } + var parent = node.parent; + if (ts.isJSDocTag(node)) { + return ts.isJSDocTypeLiteral(node.parent) ? undefined : node.parent.tags; + } + switch (parent.kind) { + case 179 /* TypeLiteral */: + case 255 /* InterfaceDeclaration */: + return ts.isTypeElement(node) ? parent.members : undefined; + case 184 /* UnionType */: + case 185 /* IntersectionType */: + return parent.types; + case 181 /* TupleType */: + case 201 /* ArrayLiteralExpression */: + case 345 /* CommaListExpression */: + case 266 /* NamedImports */: + case 270 /* NamedExports */: + return parent.elements; + case 202 /* ObjectLiteralExpression */: + case 283 /* JsxAttributes */: + return parent.properties; + case 205 /* CallExpression */: + case 206 /* NewExpression */: + return ts.isTypeNode(node) ? parent.typeArguments : + parent.expression === node ? undefined : + parent.arguments; + case 275 /* JsxElement */: + case 279 /* JsxFragment */: + return ts.isJsxChild(node) ? parent.children : undefined; + case 277 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: + return ts.isTypeNode(node) ? parent.typeArguments : undefined; + case 232 /* Block */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: + case 259 /* ModuleBlock */: + return parent.statements; + case 260 /* CaseBlock */: + return parent.clauses; + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + return ts.isClassElement(node) ? parent.members : undefined; + case 257 /* EnumDeclaration */: + return ts.isEnumMember(node) ? parent.members : undefined; + case 299 /* SourceFile */: + return parent.statements; + } + } + ts.getContainingNodeArray = getContainingNodeArray; })(ts || (ts = {})); /* @internal */ var ts; @@ -20078,7 +20627,11 @@ var ts; var ts; (function (ts) { function createParenthesizerRules(factory) { + var binaryLeftOperandParenthesizerCache; + var binaryRightOperandParenthesizerCache; return { + getParenthesizeLeftSideOfBinaryForOperator: getParenthesizeLeftSideOfBinaryForOperator, + getParenthesizeRightSideOfBinaryForOperator: getParenthesizeRightSideOfBinaryForOperator, parenthesizeLeftSideOfBinary: parenthesizeLeftSideOfBinary, parenthesizeRightSideOfBinary: parenthesizeRightSideOfBinary, parenthesizeExpressionOfComputedPropertyName: parenthesizeExpressionOfComputedPropertyName, @@ -20099,6 +20652,24 @@ var ts; parenthesizeConstituentTypesOfUnionOrIntersectionType: parenthesizeConstituentTypesOfUnionOrIntersectionType, parenthesizeTypeArguments: parenthesizeTypeArguments, }; + function getParenthesizeLeftSideOfBinaryForOperator(operatorKind) { + binaryLeftOperandParenthesizerCache || (binaryLeftOperandParenthesizerCache = new ts.Map()); + var parenthesizerRule = binaryLeftOperandParenthesizerCache.get(operatorKind); + if (!parenthesizerRule) { + parenthesizerRule = function (node) { return parenthesizeLeftSideOfBinary(operatorKind, node); }; + binaryLeftOperandParenthesizerCache.set(operatorKind, parenthesizerRule); + } + return parenthesizerRule; + } + function getParenthesizeRightSideOfBinaryForOperator(operatorKind) { + binaryRightOperandParenthesizerCache || (binaryRightOperandParenthesizerCache = new ts.Map()); + var parenthesizerRule = binaryRightOperandParenthesizerCache.get(operatorKind); + if (!parenthesizerRule) { + parenthesizerRule = function (node) { return parenthesizeRightSideOfBinary(operatorKind, /*leftSide*/ undefined, node); }; + binaryRightOperandParenthesizerCache.set(operatorKind, parenthesizerRule); + } + return parenthesizerRule; + } /** * Determines whether the operand to a BinaryExpression needs to be parenthesized. * @@ -20125,10 +20696,10 @@ 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(216 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(216 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(218 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(218 /* BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); - if (!isLeftSideOfBinary && operand.kind === 209 /* ArrowFunction */ && binaryOperatorPrecedence > 3 /* Assignment */) { + if (!isLeftSideOfBinary && operand.kind === 211 /* ArrowFunction */ && binaryOperatorPrecedence > 3 /* Assignment */) { // We need to parenthesize arrow functions on the right side to avoid it being // parsed as parenthesized expression: `a && (() => {})` return true; @@ -20140,7 +20711,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 219 /* YieldExpression */) { + && operand.kind === 221 /* YieldExpression */) { return false; } return true; @@ -20228,7 +20799,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 216 /* BinaryExpression */ && node.operatorToken.kind === 39 /* PlusToken */) { + if (node.kind === 218 /* BinaryExpression */ && node.operatorToken.kind === 39 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -20254,7 +20825,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 === 207 /* ParenthesizedExpression */) { + if (skipped.kind === 209 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -20271,7 +20842,7 @@ var ts; return ts.isCommaSequence(expression) ? factory.createParenthesizedExpression(expression) : expression; } function parenthesizeConditionOfConditionalExpression(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(217 /* ConditionalExpression */, 57 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(219 /* ConditionalExpression */, 57 /* QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) !== 1 /* GreaterThan */) { @@ -20304,8 +20875,8 @@ var ts; var needsParens = ts.isCommaSequence(check); if (!needsParens) { switch (ts.getLeftmostExpression(check, /*stopAtCallExpression*/ false).kind) { - case 221 /* ClassExpression */: - case 208 /* FunctionExpression */: + case 223 /* ClassExpression */: + case 210 /* FunctionExpression */: needsParens = true; } } @@ -20318,9 +20889,9 @@ var ts; function parenthesizeExpressionOfNew(expression) { var leftmostExpr = ts.getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 203 /* CallExpression */: + case 205 /* CallExpression */: return factory.createParenthesizedExpression(expression); - case 204 /* NewExpression */: + case 206 /* NewExpression */: return !leftmostExpr.arguments ? factory.createParenthesizedExpression(expression) : expression; // TODO(rbuckton): Verify this assertion holds @@ -20340,7 +20911,7 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 204 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 206 /* NewExpression */ || emittedExpression.arguments)) { // TODO(rbuckton): Verify whether this assertion holds. return expression; } @@ -20362,7 +20933,7 @@ var ts; function parenthesizeExpressionForDisallowedComma(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(216 /* BinaryExpression */, 27 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(218 /* BinaryExpression */, 27 /* CommaToken */); // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(factory.createParenthesizedExpression(expression), expression); } @@ -20371,44 +20942,44 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 208 /* FunctionExpression */ || kind === 209 /* ArrowFunction */) { + if (kind === 210 /* FunctionExpression */ || kind === 211 /* 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 */); } } var leftmostExpressionKind = ts.getLeftmostExpression(emittedExpression, /*stopAtCallExpressions*/ false).kind; - if (leftmostExpressionKind === 200 /* ObjectLiteralExpression */ || leftmostExpressionKind === 208 /* FunctionExpression */) { + if (leftmostExpressionKind === 202 /* ObjectLiteralExpression */ || leftmostExpressionKind === 210 /* 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 === 200 /* ObjectLiteralExpression */)) { + if (!ts.isBlock(body) && (ts.isCommaSequence(body) || ts.getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 202 /* ObjectLiteralExpression */)) { // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return ts.setTextRange(factory.createParenthesizedExpression(body), body); } return body; } function parenthesizeMemberOfConditionalType(member) { - return member.kind === 184 /* ConditionalType */ ? factory.createParenthesizedType(member) : member; + return member.kind === 186 /* ConditionalType */ ? factory.createParenthesizedType(member) : member; } function parenthesizeMemberOfElementType(member) { switch (member.kind) { - case 182 /* UnionType */: - case 183 /* IntersectionType */: - case 174 /* FunctionType */: - case 175 /* ConstructorType */: + case 184 /* UnionType */: + case 185 /* IntersectionType */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: return factory.createParenthesizedType(member); } return parenthesizeMemberOfConditionalType(member); } function parenthesizeElementTypeOfArrayType(member) { switch (member.kind) { - case 176 /* TypeQuery */: - case 188 /* TypeOperator */: - case 185 /* InferType */: + case 178 /* TypeQuery */: + case 190 /* TypeOperator */: + case 187 /* InferType */: return factory.createParenthesizedType(member); } return parenthesizeMemberOfElementType(member); @@ -20427,6 +20998,8 @@ var ts; } ts.createParenthesizerRules = createParenthesizerRules; ts.nullParenthesizerRules = { + getParenthesizeLeftSideOfBinaryForOperator: function (_) { return ts.identity; }, + getParenthesizeRightSideOfBinaryForOperator: function (_) { return ts.identity; }, parenthesizeLeftSideOfBinary: function (_binaryOperator, leftSide) { return leftSide; }, parenthesizeRightSideOfBinary: function (_binaryOperator, _leftSide, rightSide) { return rightSide; }, parenthesizeExpressionOfComputedPropertyName: ts.identity, @@ -20512,11 +21085,11 @@ var ts; } function convertToAssignmentPattern(node) { switch (node.kind) { - case 197 /* ArrayBindingPattern */: - case 199 /* ArrayLiteralExpression */: + case 199 /* ArrayBindingPattern */: + case 201 /* ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 196 /* ObjectBindingPattern */: - case 200 /* ObjectLiteralExpression */: + case 198 /* ObjectBindingPattern */: + case 202 /* ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -20857,18 +21430,18 @@ var ts; createExternalModuleReference: createExternalModuleReference, updateExternalModuleReference: updateExternalModuleReference, // lazily load factory members for JSDoc types with similar structure - get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(303 /* JSDocAllType */); }, - get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(304 /* JSDocUnknownType */); }, - get createJSDocNonNullableType() { return getJSDocUnaryTypeCreateFunction(306 /* JSDocNonNullableType */); }, - get updateJSDocNonNullableType() { return getJSDocUnaryTypeUpdateFunction(306 /* JSDocNonNullableType */); }, - get createJSDocNullableType() { return getJSDocUnaryTypeCreateFunction(305 /* JSDocNullableType */); }, - get updateJSDocNullableType() { return getJSDocUnaryTypeUpdateFunction(305 /* JSDocNullableType */); }, - get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(307 /* JSDocOptionalType */); }, - get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(307 /* JSDocOptionalType */); }, - get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(309 /* JSDocVariadicType */); }, - get updateJSDocVariadicType() { return getJSDocUnaryTypeUpdateFunction(309 /* JSDocVariadicType */); }, - get createJSDocNamepathType() { return getJSDocUnaryTypeCreateFunction(310 /* JSDocNamepathType */); }, - get updateJSDocNamepathType() { return getJSDocUnaryTypeUpdateFunction(310 /* JSDocNamepathType */); }, + get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(306 /* JSDocAllType */); }, + get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(307 /* JSDocUnknownType */); }, + get createJSDocNonNullableType() { return getJSDocUnaryTypeCreateFunction(309 /* JSDocNonNullableType */); }, + get updateJSDocNonNullableType() { return getJSDocUnaryTypeUpdateFunction(309 /* JSDocNonNullableType */); }, + get createJSDocNullableType() { return getJSDocUnaryTypeCreateFunction(308 /* JSDocNullableType */); }, + get updateJSDocNullableType() { return getJSDocUnaryTypeUpdateFunction(308 /* JSDocNullableType */); }, + get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(310 /* JSDocOptionalType */); }, + get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(310 /* JSDocOptionalType */); }, + get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(312 /* JSDocVariadicType */); }, + get updateJSDocVariadicType() { return getJSDocUnaryTypeUpdateFunction(312 /* JSDocVariadicType */); }, + get createJSDocNamepathType() { return getJSDocUnaryTypeCreateFunction(313 /* JSDocNamepathType */); }, + get updateJSDocNamepathType() { return getJSDocUnaryTypeUpdateFunction(313 /* JSDocNamepathType */); }, createJSDocFunctionType: createJSDocFunctionType, updateJSDocFunctionType: updateJSDocFunctionType, createJSDocTypeLiteral: createJSDocTypeLiteral, @@ -20895,31 +21468,43 @@ var ts; updateJSDocSeeTag: updateJSDocSeeTag, createJSDocNameReference: createJSDocNameReference, updateJSDocNameReference: updateJSDocNameReference, + createJSDocMemberName: createJSDocMemberName, + updateJSDocMemberName: updateJSDocMemberName, + createJSDocLink: createJSDocLink, + updateJSDocLink: updateJSDocLink, + createJSDocLinkCode: createJSDocLinkCode, + updateJSDocLinkCode: updateJSDocLinkCode, + createJSDocLinkPlain: createJSDocLinkPlain, + updateJSDocLinkPlain: updateJSDocLinkPlain, // lazily load factory members for JSDoc tags with similar structure - get createJSDocTypeTag() { return getJSDocTypeLikeTagCreateFunction(329 /* JSDocTypeTag */); }, - get updateJSDocTypeTag() { return getJSDocTypeLikeTagUpdateFunction(329 /* JSDocTypeTag */); }, - get createJSDocReturnTag() { return getJSDocTypeLikeTagCreateFunction(327 /* JSDocReturnTag */); }, - get updateJSDocReturnTag() { return getJSDocTypeLikeTagUpdateFunction(327 /* JSDocReturnTag */); }, - get createJSDocThisTag() { return getJSDocTypeLikeTagCreateFunction(328 /* JSDocThisTag */); }, - get updateJSDocThisTag() { return getJSDocTypeLikeTagUpdateFunction(328 /* JSDocThisTag */); }, - get createJSDocEnumTag() { return getJSDocTypeLikeTagCreateFunction(325 /* JSDocEnumTag */); }, - get updateJSDocEnumTag() { return getJSDocTypeLikeTagUpdateFunction(325 /* JSDocEnumTag */); }, - get createJSDocAuthorTag() { return getJSDocSimpleTagCreateFunction(317 /* JSDocAuthorTag */); }, - get updateJSDocAuthorTag() { return getJSDocSimpleTagUpdateFunction(317 /* JSDocAuthorTag */); }, - get createJSDocClassTag() { return getJSDocSimpleTagCreateFunction(319 /* JSDocClassTag */); }, - get updateJSDocClassTag() { return getJSDocSimpleTagUpdateFunction(319 /* JSDocClassTag */); }, - get createJSDocPublicTag() { return getJSDocSimpleTagCreateFunction(320 /* JSDocPublicTag */); }, - get updateJSDocPublicTag() { return getJSDocSimpleTagUpdateFunction(320 /* JSDocPublicTag */); }, - get createJSDocPrivateTag() { return getJSDocSimpleTagCreateFunction(321 /* JSDocPrivateTag */); }, - get updateJSDocPrivateTag() { return getJSDocSimpleTagUpdateFunction(321 /* JSDocPrivateTag */); }, - get createJSDocProtectedTag() { return getJSDocSimpleTagCreateFunction(322 /* JSDocProtectedTag */); }, - get updateJSDocProtectedTag() { return getJSDocSimpleTagUpdateFunction(322 /* JSDocProtectedTag */); }, - get createJSDocReadonlyTag() { return getJSDocSimpleTagCreateFunction(323 /* JSDocReadonlyTag */); }, - get updateJSDocReadonlyTag() { return getJSDocSimpleTagUpdateFunction(323 /* JSDocReadonlyTag */); }, - get createJSDocDeprecatedTag() { return getJSDocSimpleTagCreateFunction(318 /* JSDocDeprecatedTag */); }, - get updateJSDocDeprecatedTag() { return getJSDocSimpleTagUpdateFunction(318 /* JSDocDeprecatedTag */); }, + get createJSDocTypeTag() { return getJSDocTypeLikeTagCreateFunction(337 /* JSDocTypeTag */); }, + get updateJSDocTypeTag() { return getJSDocTypeLikeTagUpdateFunction(337 /* JSDocTypeTag */); }, + get createJSDocReturnTag() { return getJSDocTypeLikeTagCreateFunction(335 /* JSDocReturnTag */); }, + get updateJSDocReturnTag() { return getJSDocTypeLikeTagUpdateFunction(335 /* JSDocReturnTag */); }, + get createJSDocThisTag() { return getJSDocTypeLikeTagCreateFunction(336 /* JSDocThisTag */); }, + get updateJSDocThisTag() { return getJSDocTypeLikeTagUpdateFunction(336 /* JSDocThisTag */); }, + get createJSDocEnumTag() { return getJSDocTypeLikeTagCreateFunction(333 /* JSDocEnumTag */); }, + get updateJSDocEnumTag() { return getJSDocTypeLikeTagUpdateFunction(333 /* JSDocEnumTag */); }, + get createJSDocAuthorTag() { return getJSDocSimpleTagCreateFunction(324 /* JSDocAuthorTag */); }, + get updateJSDocAuthorTag() { return getJSDocSimpleTagUpdateFunction(324 /* JSDocAuthorTag */); }, + get createJSDocClassTag() { return getJSDocSimpleTagCreateFunction(326 /* JSDocClassTag */); }, + get updateJSDocClassTag() { return getJSDocSimpleTagUpdateFunction(326 /* JSDocClassTag */); }, + get createJSDocPublicTag() { return getJSDocSimpleTagCreateFunction(327 /* JSDocPublicTag */); }, + get updateJSDocPublicTag() { return getJSDocSimpleTagUpdateFunction(327 /* JSDocPublicTag */); }, + get createJSDocPrivateTag() { return getJSDocSimpleTagCreateFunction(328 /* JSDocPrivateTag */); }, + get updateJSDocPrivateTag() { return getJSDocSimpleTagUpdateFunction(328 /* JSDocPrivateTag */); }, + get createJSDocProtectedTag() { return getJSDocSimpleTagCreateFunction(329 /* JSDocProtectedTag */); }, + get updateJSDocProtectedTag() { return getJSDocSimpleTagUpdateFunction(329 /* JSDocProtectedTag */); }, + get createJSDocReadonlyTag() { return getJSDocSimpleTagCreateFunction(330 /* JSDocReadonlyTag */); }, + get updateJSDocReadonlyTag() { return getJSDocSimpleTagUpdateFunction(330 /* JSDocReadonlyTag */); }, + get createJSDocOverrideTag() { return getJSDocSimpleTagCreateFunction(331 /* JSDocOverrideTag */); }, + get updateJSDocOverrideTag() { return getJSDocSimpleTagUpdateFunction(331 /* JSDocOverrideTag */); }, + get createJSDocDeprecatedTag() { return getJSDocSimpleTagCreateFunction(325 /* JSDocDeprecatedTag */); }, + get updateJSDocDeprecatedTag() { return getJSDocSimpleTagUpdateFunction(325 /* JSDocDeprecatedTag */); }, createJSDocUnknownTag: createJSDocUnknownTag, updateJSDocUnknownTag: updateJSDocUnknownTag, + createJSDocText: createJSDocText, + updateJSDocText: updateJSDocText, createJSDocComment: createJSDocComment, updateJSDocComment: updateJSDocComment, createJsxElement: createJsxElement, @@ -20984,7 +21569,7 @@ var ts; cloneNode: cloneNode, // Lazily load factory methods for common operator factories and utilities get createComma() { return getBinaryCreateFunction(27 /* CommaToken */); }, - get createAssignment() { return getBinaryCreateFunction(62 /* EqualsToken */); }, + get createAssignment() { return getBinaryCreateFunction(63 /* EqualsToken */); }, get createLogicalOr() { return getBinaryCreateFunction(56 /* BarBarToken */); }, get createLogicalAnd() { return getBinaryCreateFunction(55 /* AmpersandAmpersandToken */); }, get createBitwiseOr() { return getBinaryCreateFunction(51 /* BarToken */); }, @@ -21103,11 +21688,11 @@ var ts; // don't propagate child flags. if (name) { switch (node.kind) { - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 163 /* PropertyDeclaration */: - case 288 /* PropertyAssignment */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 290 /* PropertyAssignment */: if (ts.isIdentifier(name)) { node.transformFlags |= propagateIdentifierNameFlags(name); break; @@ -21148,7 +21733,7 @@ var ts; function createBaseFunctionLikeDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type, body) { var node = createBaseSignatureDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type); node.body = body; - node.transformFlags |= propagateChildFlags(node.body) & ~8388608 /* ContainsPossibleTopLevelAwait */; + node.transformFlags |= propagateChildFlags(node.body) & ~16777216 /* ContainsPossibleTopLevelAwait */; if (!body) node.transformFlags |= 1 /* ContainsTypeScript */; return node; @@ -21201,7 +21786,7 @@ var ts; var node = createBaseLiteral(8 /* NumericLiteral */, typeof value === "number" ? value + "" : value); node.numericLiteralFlags = numericLiteralFlags; if (numericLiteralFlags & 384 /* BinaryOrOctalSpecifier */) - node.transformFlags |= 256 /* ContainsES2015 */; + node.transformFlags |= 512 /* ContainsES2015 */; return node; } // @api @@ -21220,7 +21805,7 @@ var ts; var node = createBaseStringLiteral(text, isSingleQuote); node.hasExtendedUnicodeEscape = hasExtendedUnicodeEscape; if (hasExtendedUnicodeEscape) - node.transformFlags |= 256 /* ContainsES2015 */; + node.transformFlags |= 512 /* ContainsES2015 */; return node; } // @api @@ -21253,10 +21838,10 @@ var ts; if (originalKeywordKind === undefined && text) { originalKeywordKind = ts.stringToToken(text); } - if (originalKeywordKind === 78 /* Identifier */) { + if (originalKeywordKind === 79 /* Identifier */) { originalKeywordKind = undefined; } - var node = baseFactory.createBaseIdentifierNode(78 /* Identifier */); + var node = baseFactory.createBaseIdentifierNode(79 /* Identifier */); node.originalKeywordKind = originalKeywordKind; node.escapedText = ts.escapeLeadingUnderscores(text); return node; @@ -21275,8 +21860,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 === 130 /* AwaitKeyword */) { - node.transformFlags |= 8388608 /* ContainsPossibleTopLevelAwait */; + if (node.originalKeywordKind === 131 /* AwaitKeyword */) { + node.transformFlags |= 16777216 /* ContainsPossibleTopLevelAwait */; } return node; } @@ -21299,8 +21884,11 @@ var ts; } /** Create a unique temporary variable for use in a loop. */ // @api - function createLoopVariable() { - return createBaseGeneratedIdentifier("", 2 /* Loop */); + function createLoopVariable(reservedInNestedScopes) { + var flags = 2 /* Loop */; + if (reservedInNestedScopes) + flags |= 8 /* ReservedInNestedScopes */; + return createBaseGeneratedIdentifier("", flags); } /** Create a unique name based on the supplied text. */ // @api @@ -21323,9 +21911,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(79 /* PrivateIdentifier */); + var node = baseFactory.createBasePrivateIdentifierNode(80 /* PrivateIdentifier */); node.escapedText = ts.escapeLeadingUnderscores(text); - node.transformFlags |= 4194304 /* ContainsClassFields */; + node.transformFlags |= 8388608 /* ContainsClassFields */; return node; } // @@ -21335,46 +21923,47 @@ var ts; return baseFactory.createBaseTokenNode(kind); } function createToken(token) { - ts.Debug.assert(token >= 0 /* FirstToken */ && token <= 156 /* LastToken */, "Invalid token"); + ts.Debug.assert(token >= 0 /* FirstToken */ && token <= 158 /* 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 !== 78 /* Identifier */, "Invalid token. Use 'createIdentifier' to create identifiers"); + ts.Debug.assert(token !== 79 /* Identifier */, "Invalid token. Use 'createIdentifier' to create identifiers"); var node = createBaseToken(token); var transformFlags = 0 /* None */; switch (token) { - case 129 /* AsyncKeyword */: + case 130 /* AsyncKeyword */: // 'async' modifier is ES2017 (async functions) or ES2018 (async generators) transformFlags = - 64 /* ContainsES2017 */ | - 32 /* ContainsES2018 */; + 128 /* ContainsES2017 */ | + 64 /* ContainsES2018 */; break; - case 122 /* PublicKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 142 /* ReadonlyKeyword */: - case 125 /* AbstractKeyword */: - case 133 /* DeclareKeyword */: - case 84 /* ConstKeyword */: - case 128 /* AnyKeyword */: - case 144 /* NumberKeyword */: - case 155 /* BigIntKeyword */: - case 141 /* NeverKeyword */: - case 145 /* ObjectKeyword */: - case 147 /* StringKeyword */: - case 131 /* BooleanKeyword */: - case 148 /* SymbolKeyword */: - case 113 /* VoidKeyword */: - case 152 /* UnknownKeyword */: - case 150 /* UndefinedKeyword */: // `undefined` is an Identifier in the expression case. + case 123 /* PublicKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + case 143 /* ReadonlyKeyword */: + case 126 /* AbstractKeyword */: + case 134 /* DeclareKeyword */: + case 85 /* ConstKeyword */: + case 129 /* AnyKeyword */: + case 145 /* NumberKeyword */: + case 156 /* BigIntKeyword */: + case 142 /* NeverKeyword */: + case 146 /* ObjectKeyword */: + case 157 /* OverrideKeyword */: + case 148 /* StringKeyword */: + case 132 /* BooleanKeyword */: + case 149 /* SymbolKeyword */: + case 114 /* VoidKeyword */: + case 153 /* UnknownKeyword */: + case 151 /* UndefinedKeyword */: // `undefined` is an Identifier in the expression case. transformFlags = 1 /* ContainsTypeScript */; break; - case 123 /* StaticKeyword */: - case 105 /* SuperKeyword */: - transformFlags = 256 /* ContainsES2015 */; + case 124 /* StaticKeyword */: + case 106 /* SuperKeyword */: + transformFlags = 512 /* ContainsES2015 */; break; - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: // 'this' indicates a lexical 'this' - transformFlags = 4096 /* ContainsLexicalThis */; + transformFlags = 8192 /* ContainsLexicalThis */; break; } if (transformFlags) { @@ -21387,23 +21976,23 @@ var ts; // // @api function createSuper() { - return createToken(105 /* SuperKeyword */); + return createToken(106 /* SuperKeyword */); } // @api function createThis() { - return createToken(107 /* ThisKeyword */); + return createToken(108 /* ThisKeyword */); } // @api function createNull() { - return createToken(103 /* NullKeyword */); + return createToken(104 /* NullKeyword */); } // @api function createTrue() { - return createToken(109 /* TrueKeyword */); + return createToken(110 /* TrueKeyword */); } // @api function createFalse() { - return createToken(94 /* FalseKeyword */); + return createToken(95 /* FalseKeyword */); } // // Modifiers @@ -21416,37 +22005,40 @@ var ts; function createModifiersFromModifierFlags(flags) { var result = []; if (flags & 1 /* Export */) { - result.push(createModifier(92 /* ExportKeyword */)); + result.push(createModifier(93 /* ExportKeyword */)); } if (flags & 2 /* Ambient */) { - result.push(createModifier(133 /* DeclareKeyword */)); + result.push(createModifier(134 /* DeclareKeyword */)); } if (flags & 512 /* Default */) { - result.push(createModifier(87 /* DefaultKeyword */)); + result.push(createModifier(88 /* DefaultKeyword */)); } if (flags & 2048 /* Const */) { - result.push(createModifier(84 /* ConstKeyword */)); + result.push(createModifier(85 /* ConstKeyword */)); } if (flags & 4 /* Public */) { - result.push(createModifier(122 /* PublicKeyword */)); + result.push(createModifier(123 /* PublicKeyword */)); } if (flags & 8 /* Private */) { - result.push(createModifier(120 /* PrivateKeyword */)); + result.push(createModifier(121 /* PrivateKeyword */)); } if (flags & 16 /* Protected */) { - result.push(createModifier(121 /* ProtectedKeyword */)); + result.push(createModifier(122 /* ProtectedKeyword */)); } if (flags & 128 /* Abstract */) { - result.push(createModifier(125 /* AbstractKeyword */)); + result.push(createModifier(126 /* AbstractKeyword */)); } if (flags & 32 /* Static */) { - result.push(createModifier(123 /* StaticKeyword */)); + result.push(createModifier(124 /* StaticKeyword */)); + } + if (flags & 16384 /* Override */) { + result.push(createModifier(157 /* OverrideKeyword */)); } if (flags & 64 /* Readonly */) { - result.push(createModifier(142 /* ReadonlyKeyword */)); + result.push(createModifier(143 /* ReadonlyKeyword */)); } if (flags & 256 /* Async */) { - result.push(createModifier(129 /* AsyncKeyword */)); + result.push(createModifier(130 /* AsyncKeyword */)); } return result; } @@ -21455,7 +22047,7 @@ var ts; // // @api function createQualifiedName(left, right) { - var node = createBaseNode(157 /* QualifiedName */); + var node = createBaseNode(159 /* QualifiedName */); node.left = left; node.right = asName(right); node.transformFlags |= @@ -21472,12 +22064,12 @@ var ts; } // @api function createComputedPropertyName(expression) { - var node = createBaseNode(158 /* ComputedPropertyName */); + var node = createBaseNode(160 /* ComputedPropertyName */); node.expression = parenthesizerRules().parenthesizeExpressionOfComputedPropertyName(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 256 /* ContainsES2015 */ | - 32768 /* ContainsComputedPropertyName */; + 512 /* ContainsES2015 */ | + 65536 /* ContainsComputedPropertyName */; return node; } // @api @@ -21491,7 +22083,7 @@ var ts; // // @api function createTypeParameterDeclaration(name, constraint, defaultType) { - var node = createBaseNamedDeclaration(159 /* TypeParameter */, + var node = createBaseNamedDeclaration(161 /* TypeParameter */, /*decorators*/ undefined, /*modifiers*/ undefined, name); node.constraint = constraint; @@ -21509,7 +22101,7 @@ var ts; } // @api function createParameterDeclaration(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(160 /* Parameter */, decorators, modifiers, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); + var node = createBaseVariableLikeDeclaration(162 /* Parameter */, decorators, modifiers, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.dotDotDotToken = dotDotDotToken; node.questionToken = questionToken; if (ts.isThisIdentifier(node.name)) { @@ -21521,10 +22113,10 @@ var ts; propagateChildFlags(node.questionToken); if (questionToken) node.transformFlags |= 1 /* ContainsTypeScript */; - if (ts.modifiersToFlags(node.modifiers) & 92 /* ParameterPropertyModifier */) - node.transformFlags |= 2048 /* ContainsTypeScriptClassSyntax */; + if (ts.modifiersToFlags(node.modifiers) & 16476 /* ParameterPropertyModifier */) + node.transformFlags |= 4096 /* ContainsTypeScriptClassSyntax */; if (initializer || dotDotDotToken) - node.transformFlags |= 256 /* ContainsES2015 */; + node.transformFlags |= 512 /* ContainsES2015 */; } return node; } @@ -21542,12 +22134,12 @@ var ts; } // @api function createDecorator(expression) { - var node = createBaseNode(161 /* Decorator */); + var node = createBaseNode(163 /* Decorator */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= propagateChildFlags(node.expression) | 1 /* ContainsTypeScript */ | - 2048 /* ContainsTypeScriptClassSyntax */; + 4096 /* ContainsTypeScriptClassSyntax */; return node; } // @api @@ -21561,7 +22153,7 @@ var ts; // // @api function createPropertySignature(modifiers, name, questionToken, type) { - var node = createBaseNamedDeclaration(162 /* PropertySignature */, + var node = createBaseNamedDeclaration(164 /* PropertySignature */, /*decorators*/ undefined, modifiers, name); node.type = type; node.questionToken = questionToken; @@ -21579,15 +22171,15 @@ var ts; } // @api function createPropertyDeclaration(decorators, modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(163 /* PropertyDeclaration */, decorators, modifiers, name, type, initializer); + var node = createBaseVariableLikeDeclaration(165 /* PropertyDeclaration */, decorators, 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) | - 4194304 /* ContainsClassFields */; + 8388608 /* ContainsClassFields */; if (ts.isComputedPropertyName(node.name) || (ts.hasStaticModifier(node) && node.initializer)) { - node.transformFlags |= 2048 /* ContainsTypeScriptClassSyntax */; + node.transformFlags |= 4096 /* ContainsTypeScriptClassSyntax */; } if (questionOrExclamationToken || ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { node.transformFlags |= 1 /* ContainsTypeScript */; @@ -21608,7 +22200,7 @@ var ts; } // @api function createMethodSignature(modifiers, name, questionToken, typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(164 /* MethodSignature */, + var node = createBaseSignatureDeclaration(166 /* MethodSignature */, /*decorators*/ undefined, modifiers, name, typeParameters, parameters, type); node.questionToken = questionToken; node.transformFlags = 1 /* ContainsTypeScript */; @@ -21627,26 +22219,26 @@ var ts; } // @api function createMethodDeclaration(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(165 /* MethodDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(167 /* MethodDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; node.questionToken = questionToken; node.transformFlags |= propagateChildFlags(node.asteriskToken) | propagateChildFlags(node.questionToken) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; if (questionToken) { node.transformFlags |= 1 /* ContainsTypeScript */; } if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { if (asteriskToken) { - node.transformFlags |= 32 /* ContainsES2018 */; + node.transformFlags |= 64 /* ContainsES2018 */; } else { - node.transformFlags |= 64 /* ContainsES2017 */; + node.transformFlags |= 128 /* ContainsES2017 */; } } else if (asteriskToken) { - node.transformFlags |= 512 /* ContainsGenerator */; + node.transformFlags |= 1024 /* ContainsGenerator */; } return node; } @@ -21666,11 +22258,11 @@ var ts; } // @api function createConstructorDeclaration(decorators, modifiers, parameters, body) { - var node = createBaseFunctionLikeDeclaration(166 /* Constructor */, decorators, modifiers, + var node = createBaseFunctionLikeDeclaration(168 /* Constructor */, decorators, modifiers, /*name*/ undefined, /*typeParameters*/ undefined, parameters, /*type*/ undefined, body); - node.transformFlags |= 256 /* ContainsES2015 */; + node.transformFlags |= 512 /* ContainsES2015 */; return node; } // @api @@ -21684,7 +22276,7 @@ var ts; } // @api function createGetAccessorDeclaration(decorators, modifiers, name, parameters, type, body) { - return createBaseFunctionLikeDeclaration(167 /* GetAccessor */, decorators, modifiers, name, + return createBaseFunctionLikeDeclaration(169 /* GetAccessor */, decorators, modifiers, name, /*typeParameters*/ undefined, parameters, type, body); } // @api @@ -21700,7 +22292,7 @@ var ts; } // @api function createSetAccessorDeclaration(decorators, modifiers, name, parameters, body) { - return createBaseFunctionLikeDeclaration(168 /* SetAccessor */, decorators, modifiers, name, + return createBaseFunctionLikeDeclaration(170 /* SetAccessor */, decorators, modifiers, name, /*typeParameters*/ undefined, parameters, /*type*/ undefined, body); } @@ -21716,7 +22308,7 @@ var ts; } // @api function createCallSignature(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(169 /* CallSignature */, + var node = createBaseSignatureDeclaration(171 /* CallSignature */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); @@ -21733,7 +22325,7 @@ var ts; } // @api function createConstructSignature(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(170 /* ConstructSignature */, + var node = createBaseSignatureDeclaration(172 /* ConstructSignature */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); @@ -21750,7 +22342,7 @@ var ts; } // @api function createIndexSignature(decorators, modifiers, parameters, type) { - var node = createBaseSignatureDeclaration(171 /* IndexSignature */, decorators, modifiers, + var node = createBaseSignatureDeclaration(173 /* IndexSignature */, decorators, modifiers, /*name*/ undefined, /*typeParameters*/ undefined, parameters, type); node.transformFlags = 1 /* ContainsTypeScript */; @@ -21767,7 +22359,7 @@ var ts; } // @api function createTemplateLiteralTypeSpan(type, literal) { - var node = createBaseNode(194 /* TemplateLiteralTypeSpan */); + var node = createBaseNode(196 /* TemplateLiteralTypeSpan */); node.type = type; node.literal = literal; node.transformFlags = 1 /* ContainsTypeScript */; @@ -21789,7 +22381,7 @@ var ts; } // @api function createTypePredicateNode(assertsModifier, parameterName, type) { - var node = createBaseNode(172 /* TypePredicate */); + var node = createBaseNode(174 /* TypePredicate */); node.assertsModifier = assertsModifier; node.parameterName = asName(parameterName); node.type = type; @@ -21806,7 +22398,7 @@ var ts; } // @api function createTypeReferenceNode(typeName, typeArguments) { - var node = createBaseNode(173 /* TypeReference */); + var node = createBaseNode(175 /* TypeReference */); node.typeName = asName(typeName); node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(createNodeArray(typeArguments)); node.transformFlags = 1 /* ContainsTypeScript */; @@ -21821,7 +22413,7 @@ var ts; } // @api function createFunctionTypeNode(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(174 /* FunctionType */, + var node = createBaseSignatureDeclaration(176 /* FunctionType */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); @@ -21847,7 +22439,7 @@ var ts; ts.Debug.fail("Incorrect number of arguments specified."); } function createConstructorTypeNode1(modifiers, typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(175 /* ConstructorType */, + var node = createBaseSignatureDeclaration(177 /* ConstructorType */, /*decorators*/ undefined, modifiers, /*name*/ undefined, typeParameters, parameters, type); node.transformFlags = 1 /* ContainsTypeScript */; @@ -21881,7 +22473,7 @@ var ts; } // @api function createTypeQueryNode(exprName) { - var node = createBaseNode(176 /* TypeQuery */); + var node = createBaseNode(178 /* TypeQuery */); node.exprName = exprName; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -21894,7 +22486,7 @@ var ts; } // @api function createTypeLiteralNode(members) { - var node = createBaseNode(177 /* TypeLiteral */); + var node = createBaseNode(179 /* TypeLiteral */); node.members = createNodeArray(members); node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -21907,7 +22499,7 @@ var ts; } // @api function createArrayTypeNode(elementType) { - var node = createBaseNode(178 /* ArrayType */); + var node = createBaseNode(180 /* ArrayType */); node.elementType = parenthesizerRules().parenthesizeElementTypeOfArrayType(elementType); node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -21920,7 +22512,7 @@ var ts; } // @api function createTupleTypeNode(elements) { - var node = createBaseNode(179 /* TupleType */); + var node = createBaseNode(181 /* TupleType */); node.elements = createNodeArray(elements); node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -21933,7 +22525,7 @@ var ts; } // @api function createNamedTupleMember(dotDotDotToken, name, questionToken, type) { - var node = createBaseNode(192 /* NamedTupleMember */); + var node = createBaseNode(194 /* NamedTupleMember */); node.dotDotDotToken = dotDotDotToken; node.name = name; node.questionToken = questionToken; @@ -21952,7 +22544,7 @@ var ts; } // @api function createOptionalTypeNode(type) { - var node = createBaseNode(180 /* OptionalType */); + var node = createBaseNode(182 /* OptionalType */); node.type = parenthesizerRules().parenthesizeElementTypeOfArrayType(type); node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -21965,7 +22557,7 @@ var ts; } // @api function createRestTypeNode(type) { - var node = createBaseNode(181 /* RestType */); + var node = createBaseNode(183 /* RestType */); node.type = type; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -21989,7 +22581,7 @@ var ts; } // @api function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(182 /* UnionType */, types); + return createUnionOrIntersectionTypeNode(184 /* UnionType */, types); } // @api function updateUnionTypeNode(node, types) { @@ -21997,7 +22589,7 @@ var ts; } // @api function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(183 /* IntersectionType */, types); + return createUnionOrIntersectionTypeNode(185 /* IntersectionType */, types); } // @api function updateIntersectionTypeNode(node, types) { @@ -22005,7 +22597,7 @@ var ts; } // @api function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createBaseNode(184 /* ConditionalType */); + var node = createBaseNode(186 /* ConditionalType */); node.checkType = parenthesizerRules().parenthesizeMemberOfConditionalType(checkType); node.extendsType = parenthesizerRules().parenthesizeMemberOfConditionalType(extendsType); node.trueType = trueType; @@ -22024,7 +22616,7 @@ var ts; } // @api function createInferTypeNode(typeParameter) { - var node = createBaseNode(185 /* InferType */); + var node = createBaseNode(187 /* InferType */); node.typeParameter = typeParameter; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -22037,7 +22629,7 @@ var ts; } // @api function createTemplateLiteralType(head, templateSpans) { - var node = createBaseNode(193 /* TemplateLiteralType */); + var node = createBaseNode(195 /* TemplateLiteralType */); node.head = head; node.templateSpans = createNodeArray(templateSpans); node.transformFlags = 1 /* ContainsTypeScript */; @@ -22053,7 +22645,7 @@ var ts; // @api function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { if (isTypeOf === void 0) { isTypeOf = false; } - var node = createBaseNode(195 /* ImportType */); + var node = createBaseNode(197 /* ImportType */); node.argument = argument; node.qualifier = qualifier; node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); @@ -22073,7 +22665,7 @@ var ts; } // @api function createParenthesizedType(type) { - var node = createBaseNode(186 /* ParenthesizedType */); + var node = createBaseNode(188 /* ParenthesizedType */); node.type = type; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -22086,13 +22678,13 @@ var ts; } // @api function createThisTypeNode() { - var node = createBaseNode(187 /* ThisType */); + var node = createBaseNode(189 /* ThisType */); node.transformFlags = 1 /* ContainsTypeScript */; return node; } // @api function createTypeOperatorNode(operator, type) { - var node = createBaseNode(188 /* TypeOperator */); + var node = createBaseNode(190 /* TypeOperator */); node.operator = operator; node.type = parenthesizerRules().parenthesizeMemberOfElementType(type); node.transformFlags = 1 /* ContainsTypeScript */; @@ -22106,7 +22698,7 @@ var ts; } // @api function createIndexedAccessTypeNode(objectType, indexType) { - var node = createBaseNode(189 /* IndexedAccessType */); + var node = createBaseNode(191 /* IndexedAccessType */); node.objectType = parenthesizerRules().parenthesizeMemberOfElementType(objectType); node.indexType = indexType; node.transformFlags = 1 /* ContainsTypeScript */; @@ -22121,7 +22713,7 @@ var ts; } // @api function createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type) { - var node = createBaseNode(190 /* MappedType */); + var node = createBaseNode(192 /* MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.nameType = nameType; @@ -22142,7 +22734,7 @@ var ts; } // @api function createLiteralTypeNode(literal) { - var node = createBaseNode(191 /* LiteralType */); + var node = createBaseNode(193 /* LiteralType */); node.literal = literal; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -22158,16 +22750,16 @@ var ts; // // @api function createObjectBindingPattern(elements) { - var node = createBaseNode(196 /* ObjectBindingPattern */); + var node = createBaseNode(198 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements) | - 256 /* ContainsES2015 */ | - 131072 /* ContainsBindingPattern */; - if (node.transformFlags & 8192 /* ContainsRestOrSpread */) { + 512 /* ContainsES2015 */ | + 262144 /* ContainsBindingPattern */; + if (node.transformFlags & 16384 /* ContainsRestOrSpread */) { node.transformFlags |= - 32 /* ContainsES2018 */ | - 16384 /* ContainsObjectRestOrSpread */; + 64 /* ContainsES2018 */ | + 32768 /* ContainsObjectRestOrSpread */; } return node; } @@ -22179,12 +22771,12 @@ var ts; } // @api function createArrayBindingPattern(elements) { - var node = createBaseNode(197 /* ArrayBindingPattern */); + var node = createBaseNode(199 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements) | - 256 /* ContainsES2015 */ | - 131072 /* ContainsBindingPattern */; + 512 /* ContainsES2015 */ | + 262144 /* ContainsBindingPattern */; return node; } // @api @@ -22195,21 +22787,21 @@ var ts; } // @api function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createBaseBindingLikeDeclaration(198 /* BindingElement */, + var node = createBaseBindingLikeDeclaration(200 /* BindingElement */, /*decorators*/ undefined, - /*modifiers*/ undefined, name, initializer); + /*modifiers*/ undefined, name, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.propertyName = asName(propertyName); node.dotDotDotToken = dotDotDotToken; node.transformFlags |= propagateChildFlags(node.dotDotDotToken) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; if (node.propertyName) { node.transformFlags |= ts.isIdentifier(node.propertyName) ? propagateIdentifierNameFlags(node.propertyName) : propagateChildFlags(node.propertyName); } if (dotDotDotToken) - node.transformFlags |= 8192 /* ContainsRestOrSpread */; + node.transformFlags |= 16384 /* ContainsRestOrSpread */; return node; } // @api @@ -22231,7 +22823,7 @@ var ts; } // @api function createArrayLiteralExpression(elements, multiLine) { - var node = createBaseExpression(199 /* ArrayLiteralExpression */); + var node = createBaseExpression(201 /* ArrayLiteralExpression */); node.elements = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(elements)); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.elements); @@ -22245,7 +22837,7 @@ var ts; } // @api function createObjectLiteralExpression(properties, multiLine) { - var node = createBaseExpression(200 /* ObjectLiteralExpression */); + var node = createBaseExpression(202 /* ObjectLiteralExpression */); node.properties = createNodeArray(properties); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.properties); @@ -22259,7 +22851,7 @@ var ts; } // @api function createPropertyAccessExpression(expression, name) { - var node = createBaseExpression(201 /* PropertyAccessExpression */); + var node = createBaseExpression(203 /* PropertyAccessExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.name = asName(name); node.transformFlags = @@ -22271,8 +22863,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 |= - 64 /* ContainsES2017 */ | - 32 /* ContainsES2018 */; + 128 /* ContainsES2017 */ | + 64 /* ContainsES2018 */; } return node; } @@ -22288,13 +22880,13 @@ var ts; } // @api function createPropertyAccessChain(expression, questionDotToken, name) { - var node = createBaseExpression(201 /* PropertyAccessExpression */); + var node = createBaseExpression(203 /* PropertyAccessExpression */); node.flags |= 32 /* OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.questionDotToken = questionDotToken; node.name = asName(name); node.transformFlags |= - 8 /* ContainsES2020 */ | + 16 /* ContainsES2020 */ | propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | (ts.isIdentifier(node.name) ? @@ -22315,7 +22907,7 @@ var ts; } // @api function createElementAccessExpression(expression, index) { - var node = createBaseExpression(202 /* ElementAccessExpression */); + var node = createBaseExpression(204 /* ElementAccessExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.argumentExpression = asExpression(index); node.transformFlags |= @@ -22325,8 +22917,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 |= - 64 /* ContainsES2017 */ | - 32 /* ContainsES2018 */; + 128 /* ContainsES2017 */ | + 64 /* ContainsES2018 */; } return node; } @@ -22342,7 +22934,7 @@ var ts; } // @api function createElementAccessChain(expression, questionDotToken, index) { - var node = createBaseExpression(202 /* ElementAccessExpression */); + var node = createBaseExpression(204 /* ElementAccessExpression */); node.flags |= 32 /* OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.questionDotToken = questionDotToken; @@ -22351,7 +22943,7 @@ var ts; propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | propagateChildFlags(node.argumentExpression) | - 8 /* ContainsES2020 */; + 16 /* ContainsES2020 */; return node; } // @api @@ -22367,7 +22959,7 @@ var ts; } // @api function createCallExpression(expression, typeArguments, argumentsArray) { - var node = createBaseExpression(203 /* CallExpression */); + var node = createBaseExpression(205 /* CallExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray)); @@ -22379,10 +22971,10 @@ var ts; node.transformFlags |= 1 /* ContainsTypeScript */; } if (ts.isImportKeyword(node.expression)) { - node.transformFlags |= 2097152 /* ContainsDynamicImport */; + node.transformFlags |= 4194304 /* ContainsDynamicImport */; } else if (ts.isSuperProperty(node.expression)) { - node.transformFlags |= 4096 /* ContainsLexicalThis */; + node.transformFlags |= 8192 /* ContainsLexicalThis */; } return node; } @@ -22399,7 +22991,7 @@ var ts; } // @api function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) { - var node = createBaseExpression(203 /* CallExpression */); + var node = createBaseExpression(205 /* CallExpression */); node.flags |= 32 /* OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.questionDotToken = questionDotToken; @@ -22410,12 +23002,12 @@ var ts; propagateChildFlags(node.questionDotToken) | propagateChildrenFlags(node.typeArguments) | propagateChildrenFlags(node.arguments) | - 8 /* ContainsES2020 */; + 16 /* ContainsES2020 */; if (node.typeArguments) { node.transformFlags |= 1 /* ContainsTypeScript */; } if (ts.isSuperProperty(node.expression)) { - node.transformFlags |= 4096 /* ContainsLexicalThis */; + node.transformFlags |= 8192 /* ContainsLexicalThis */; } return node; } @@ -22431,7 +23023,7 @@ var ts; } // @api function createNewExpression(expression, typeArguments, argumentsArray) { - var node = createBaseExpression(204 /* NewExpression */); + var node = createBaseExpression(206 /* NewExpression */); node.expression = parenthesizerRules().parenthesizeExpressionOfNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(argumentsArray) : undefined; @@ -22439,7 +23031,7 @@ var ts; propagateChildFlags(node.expression) | propagateChildrenFlags(node.typeArguments) | propagateChildrenFlags(node.arguments) | - 8 /* ContainsES2020 */; + 16 /* ContainsES2020 */; if (node.typeArguments) { node.transformFlags |= 1 /* ContainsTypeScript */; } @@ -22455,7 +23047,7 @@ var ts; } // @api function createTaggedTemplateExpression(tag, typeArguments, template) { - var node = createBaseExpression(205 /* TaggedTemplateExpression */); + var node = createBaseExpression(207 /* TaggedTemplateExpression */); node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag); node.typeArguments = asNodeArray(typeArguments); node.template = template; @@ -22463,12 +23055,12 @@ var ts; propagateChildFlags(node.tag) | propagateChildrenFlags(node.typeArguments) | propagateChildFlags(node.template) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; if (node.typeArguments) { node.transformFlags |= 1 /* ContainsTypeScript */; } if (ts.hasInvalidEscape(node.template)) { - node.transformFlags |= 32 /* ContainsES2018 */; + node.transformFlags |= 64 /* ContainsES2018 */; } return node; } @@ -22482,7 +23074,7 @@ var ts; } // @api function createTypeAssertion(type, expression) { - var node = createBaseExpression(206 /* TypeAssertionExpression */); + var node = createBaseExpression(208 /* TypeAssertionExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.type = type; node.transformFlags |= @@ -22500,7 +23092,7 @@ var ts; } // @api function createParenthesizedExpression(expression) { - var node = createBaseExpression(207 /* ParenthesizedExpression */); + var node = createBaseExpression(209 /* ParenthesizedExpression */); node.expression = expression; node.transformFlags = propagateChildFlags(node.expression); return node; @@ -22513,7 +23105,7 @@ var ts; } // @api function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(208 /* FunctionExpression */, + var node = createBaseFunctionLikeDeclaration(210 /* FunctionExpression */, /*decorators*/ undefined, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; node.transformFlags |= propagateChildFlags(node.asteriskToken); @@ -22522,14 +23114,14 @@ var ts; } if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { if (node.asteriskToken) { - node.transformFlags |= 32 /* ContainsES2018 */; + node.transformFlags |= 64 /* ContainsES2018 */; } else { - node.transformFlags |= 64 /* ContainsES2017 */; + node.transformFlags |= 128 /* ContainsES2017 */; } } else if (node.asteriskToken) { - node.transformFlags |= 512 /* ContainsGenerator */; + node.transformFlags |= 1024 /* ContainsGenerator */; } return node; } @@ -22547,15 +23139,15 @@ var ts; } // @api function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createBaseFunctionLikeDeclaration(209 /* ArrowFunction */, + var node = createBaseFunctionLikeDeclaration(211 /* ArrowFunction */, /*decorators*/ undefined, modifiers, /*name*/ undefined, typeParameters, parameters, type, parenthesizerRules().parenthesizeConciseBodyOfArrowFunction(body)); node.equalsGreaterThanToken = equalsGreaterThanToken !== null && equalsGreaterThanToken !== void 0 ? equalsGreaterThanToken : createToken(38 /* EqualsGreaterThanToken */); node.transformFlags |= propagateChildFlags(node.equalsGreaterThanToken) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { - node.transformFlags |= 64 /* ContainsES2017 */; + node.transformFlags |= 128 /* ContainsES2017 */; } return node; } @@ -22572,7 +23164,7 @@ var ts; } // @api function createDeleteExpression(expression) { - var node = createBaseExpression(210 /* DeleteExpression */); + var node = createBaseExpression(212 /* DeleteExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -22585,7 +23177,7 @@ var ts; } // @api function createTypeOfExpression(expression) { - var node = createBaseExpression(211 /* TypeOfExpression */); + var node = createBaseExpression(213 /* TypeOfExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -22598,7 +23190,7 @@ var ts; } // @api function createVoidExpression(expression) { - var node = createBaseExpression(212 /* VoidExpression */); + var node = createBaseExpression(214 /* VoidExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -22611,13 +23203,13 @@ var ts; } // @api function createAwaitExpression(expression) { - var node = createBaseExpression(213 /* AwaitExpression */); + var node = createBaseExpression(215 /* AwaitExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 64 /* ContainsES2017 */ | - 32 /* ContainsES2018 */ | - 524288 /* ContainsAwait */; + 128 /* ContainsES2017 */ | + 64 /* ContainsES2018 */ | + 1048576 /* ContainsAwait */; return node; } // @api @@ -22628,7 +23220,7 @@ var ts; } // @api function createPrefixUnaryExpression(operator, operand) { - var node = createBaseExpression(214 /* PrefixUnaryExpression */); + var node = createBaseExpression(216 /* PrefixUnaryExpression */); node.operator = operator; node.operand = parenthesizerRules().parenthesizeOperandOfPrefixUnary(operand); node.transformFlags |= propagateChildFlags(node.operand); @@ -22642,7 +23234,7 @@ var ts; } // @api function createPostfixUnaryExpression(operand, operator) { - var node = createBaseExpression(215 /* PostfixUnaryExpression */); + var node = createBaseExpression(217 /* PostfixUnaryExpression */); node.operator = operator; node.operand = parenthesizerRules().parenthesizeOperandOfPostfixUnary(operand); node.transformFlags = propagateChildFlags(node.operand); @@ -22656,7 +23248,7 @@ var ts; } // @api function createBinaryExpression(left, operator, right) { - var node = createBaseExpression(216 /* BinaryExpression */); + var node = createBaseExpression(218 /* BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = parenthesizerRules().parenthesizeLeftSideOfBinary(operatorKind, left); @@ -22667,45 +23259,45 @@ var ts; propagateChildFlags(node.operatorToken) | propagateChildFlags(node.right); if (operatorKind === 60 /* QuestionQuestionToken */) { - node.transformFlags |= 8 /* ContainsES2020 */; + node.transformFlags |= 16 /* ContainsES2020 */; } - else if (operatorKind === 62 /* EqualsToken */) { + else if (operatorKind === 63 /* EqualsToken */) { if (ts.isObjectLiteralExpression(node.left)) { node.transformFlags |= - 256 /* ContainsES2015 */ | - 32 /* ContainsES2018 */ | - 1024 /* ContainsDestructuringAssignment */ | + 512 /* ContainsES2015 */ | + 64 /* ContainsES2018 */ | + 2048 /* ContainsDestructuringAssignment */ | propagateAssignmentPatternFlags(node.left); } else if (ts.isArrayLiteralExpression(node.left)) { node.transformFlags |= - 256 /* ContainsES2015 */ | - 1024 /* ContainsDestructuringAssignment */ | + 512 /* ContainsES2015 */ | + 2048 /* ContainsDestructuringAssignment */ | propagateAssignmentPatternFlags(node.left); } } - else if (operatorKind === 42 /* AsteriskAsteriskToken */ || operatorKind === 66 /* AsteriskAsteriskEqualsToken */) { - node.transformFlags |= 128 /* ContainsES2016 */; + else if (operatorKind === 42 /* AsteriskAsteriskToken */ || operatorKind === 67 /* AsteriskAsteriskEqualsToken */) { + node.transformFlags |= 256 /* ContainsES2016 */; } else if (ts.isLogicalOrCoalescingAssignmentOperator(operatorKind)) { - node.transformFlags |= 4 /* ContainsESNext */; + node.transformFlags |= 8 /* ContainsES2021 */; } return node; } function propagateAssignmentPatternFlags(node) { - if (node.transformFlags & 16384 /* ContainsObjectRestOrSpread */) - return 16384 /* ContainsObjectRestOrSpread */; - if (node.transformFlags & 32 /* ContainsES2018 */) { + if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) + return 32768 /* ContainsObjectRestOrSpread */; + if (node.transformFlags & 64 /* 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 & 16384 /* ContainsObjectRestOrSpread */) { - return 16384 /* ContainsObjectRestOrSpread */; + if (target.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { + return 32768 /* ContainsObjectRestOrSpread */; } - if (target.transformFlags & 32 /* ContainsES2018 */) { + if (target.transformFlags & 64 /* ContainsES2018 */) { var flags_1 = propagateAssignmentPatternFlags(target); if (flags_1) return flags_1; @@ -22725,7 +23317,7 @@ var ts; } // @api function createConditionalExpression(condition, questionToken, whenTrue, colonToken, whenFalse) { - var node = createBaseExpression(217 /* ConditionalExpression */); + var node = createBaseExpression(219 /* ConditionalExpression */); node.condition = parenthesizerRules().parenthesizeConditionOfConditionalExpression(condition); node.questionToken = questionToken !== null && questionToken !== void 0 ? questionToken : createToken(57 /* QuestionToken */); node.whenTrue = parenthesizerRules().parenthesizeBranchOfConditionalExpression(whenTrue); @@ -22751,13 +23343,13 @@ var ts; } // @api function createTemplateExpression(head, templateSpans) { - var node = createBaseExpression(218 /* TemplateExpression */); + var node = createBaseExpression(220 /* TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); node.transformFlags |= propagateChildFlags(node.head) | propagateChildrenFlags(node.templateSpans) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; return node; } // @api @@ -22796,9 +23388,9 @@ var ts; node.text = text; node.rawText = rawText; node.templateFlags = templateFlags & 2048 /* TemplateLiteralLikeFlags */; - node.transformFlags |= 256 /* ContainsES2015 */; + node.transformFlags |= 512 /* ContainsES2015 */; if (node.templateFlags) { - node.transformFlags |= 32 /* ContainsES2018 */; + node.transformFlags |= 64 /* ContainsES2018 */; } return node; } @@ -22821,15 +23413,15 @@ var ts; // @api function createYieldExpression(asteriskToken, expression) { ts.Debug.assert(!asteriskToken || !!expression, "A `YieldExpression` with an asteriskToken must have an expression."); - var node = createBaseExpression(219 /* YieldExpression */); + var node = createBaseExpression(221 /* YieldExpression */); node.expression = expression && parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.asteriskToken = asteriskToken; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.asteriskToken) | - 256 /* ContainsES2015 */ | - 32 /* ContainsES2018 */ | - 262144 /* ContainsYield */; + 512 /* ContainsES2015 */ | + 64 /* ContainsES2018 */ | + 524288 /* ContainsYield */; return node; } // @api @@ -22841,12 +23433,12 @@ var ts; } // @api function createSpreadElement(expression) { - var node = createBaseExpression(220 /* SpreadElement */); + var node = createBaseExpression(222 /* SpreadElement */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 256 /* ContainsES2015 */ | - 8192 /* ContainsRestOrSpread */; + 512 /* ContainsES2015 */ | + 16384 /* ContainsRestOrSpread */; return node; } // @api @@ -22857,8 +23449,8 @@ var ts; } // @api function createClassExpression(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseClassLikeDeclaration(221 /* ClassExpression */, decorators, modifiers, name, typeParameters, heritageClauses, members); - node.transformFlags |= 256 /* ContainsES2015 */; + var node = createBaseClassLikeDeclaration(223 /* ClassExpression */, decorators, modifiers, name, typeParameters, heritageClauses, members); + node.transformFlags |= 512 /* ContainsES2015 */; return node; } // @api @@ -22874,17 +23466,17 @@ var ts; } // @api function createOmittedExpression() { - return createBaseExpression(222 /* OmittedExpression */); + return createBaseExpression(224 /* OmittedExpression */); } // @api function createExpressionWithTypeArguments(expression, typeArguments) { - var node = createBaseNode(223 /* ExpressionWithTypeArguments */); + var node = createBaseNode(225 /* ExpressionWithTypeArguments */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); node.transformFlags |= propagateChildFlags(node.expression) | propagateChildrenFlags(node.typeArguments) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; return node; } // @api @@ -22896,7 +23488,7 @@ var ts; } // @api function createAsExpression(expression, type) { - var node = createBaseExpression(224 /* AsExpression */); + var node = createBaseExpression(226 /* AsExpression */); node.expression = expression; node.type = type; node.transformFlags |= @@ -22914,7 +23506,7 @@ var ts; } // @api function createNonNullExpression(expression) { - var node = createBaseExpression(225 /* NonNullExpression */); + var node = createBaseExpression(227 /* NonNullExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= propagateChildFlags(node.expression) | @@ -22932,7 +23524,7 @@ var ts; } // @api function createNonNullChain(expression) { - var node = createBaseExpression(225 /* NonNullExpression */); + var node = createBaseExpression(227 /* NonNullExpression */); node.flags |= 32 /* OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= @@ -22949,15 +23541,15 @@ var ts; } // @api function createMetaProperty(keywordToken, name) { - var node = createBaseExpression(226 /* MetaProperty */); + var node = createBaseExpression(228 /* MetaProperty */); node.keywordToken = keywordToken; node.name = name; node.transformFlags |= propagateChildFlags(node.name); switch (keywordToken) { - case 102 /* NewKeyword */: - node.transformFlags |= 256 /* ContainsES2015 */; + case 103 /* NewKeyword */: + node.transformFlags |= 512 /* ContainsES2015 */; break; - case 99 /* ImportKeyword */: + case 100 /* ImportKeyword */: node.transformFlags |= 4 /* ContainsESNext */; break; default: @@ -22976,13 +23568,13 @@ var ts; // // @api function createTemplateSpan(expression, literal) { - var node = createBaseNode(228 /* TemplateSpan */); + var node = createBaseNode(230 /* TemplateSpan */); node.expression = expression; node.literal = literal; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.literal) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; return node; } // @api @@ -22994,8 +23586,8 @@ var ts; } // @api function createSemicolonClassElement() { - var node = createBaseNode(229 /* SemicolonClassElement */); - node.transformFlags |= 256 /* ContainsES2015 */; + var node = createBaseNode(231 /* SemicolonClassElement */); + node.transformFlags |= 512 /* ContainsES2015 */; return node; } // @@ -23003,7 +23595,7 @@ var ts; // // @api function createBlock(statements, multiLine) { - var node = createBaseNode(230 /* Block */); + var node = createBaseNode(232 /* Block */); node.statements = createNodeArray(statements); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.statements); @@ -23017,7 +23609,7 @@ var ts; } // @api function createVariableStatement(modifiers, declarationList) { - var node = createBaseDeclaration(232 /* VariableStatement */, /*decorators*/ undefined, modifiers); + var node = createBaseDeclaration(234 /* VariableStatement */, /*decorators*/ undefined, modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; node.transformFlags |= propagateChildFlags(node.declarationList); @@ -23035,11 +23627,11 @@ var ts; } // @api function createEmptyStatement() { - return createBaseNode(231 /* EmptyStatement */); + return createBaseNode(233 /* EmptyStatement */); } // @api function createExpressionStatement(expression) { - var node = createBaseNode(233 /* ExpressionStatement */); + var node = createBaseNode(235 /* ExpressionStatement */); node.expression = parenthesizerRules().parenthesizeExpressionOfExpressionStatement(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -23052,7 +23644,7 @@ var ts; } // @api function createIfStatement(expression, thenStatement, elseStatement) { - var node = createBaseNode(234 /* IfStatement */); + var node = createBaseNode(236 /* IfStatement */); node.expression = expression; node.thenStatement = asEmbeddedStatement(thenStatement); node.elseStatement = asEmbeddedStatement(elseStatement); @@ -23072,7 +23664,7 @@ var ts; } // @api function createDoStatement(statement, expression) { - var node = createBaseNode(235 /* DoStatement */); + var node = createBaseNode(237 /* DoStatement */); node.statement = asEmbeddedStatement(statement); node.expression = expression; node.transformFlags |= @@ -23089,7 +23681,7 @@ var ts; } // @api function createWhileStatement(expression, statement) { - var node = createBaseNode(236 /* WhileStatement */); + var node = createBaseNode(238 /* WhileStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -23106,7 +23698,7 @@ var ts; } // @api function createForStatement(initializer, condition, incrementor, statement) { - var node = createBaseNode(237 /* ForStatement */); + var node = createBaseNode(239 /* ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -23129,7 +23721,7 @@ var ts; } // @api function createForInStatement(initializer, expression, statement) { - var node = createBaseNode(238 /* ForInStatement */); + var node = createBaseNode(240 /* ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = asEmbeddedStatement(statement); @@ -23149,7 +23741,7 @@ var ts; } // @api function createForOfStatement(awaitModifier, initializer, expression, statement) { - var node = createBaseNode(239 /* ForOfStatement */); + var node = createBaseNode(241 /* ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); @@ -23159,9 +23751,9 @@ var ts; propagateChildFlags(node.initializer) | propagateChildFlags(node.expression) | propagateChildFlags(node.statement) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; if (awaitModifier) - node.transformFlags |= 32 /* ContainsES2018 */; + node.transformFlags |= 64 /* ContainsES2018 */; return node; } // @api @@ -23175,11 +23767,11 @@ var ts; } // @api function createContinueStatement(label) { - var node = createBaseNode(240 /* ContinueStatement */); + var node = createBaseNode(242 /* ContinueStatement */); node.label = asName(label); node.transformFlags |= propagateChildFlags(node.label) | - 1048576 /* ContainsHoistedDeclarationOrCompletion */; + 2097152 /* ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -23190,11 +23782,11 @@ var ts; } // @api function createBreakStatement(label) { - var node = createBaseNode(241 /* BreakStatement */); + var node = createBaseNode(243 /* BreakStatement */); node.label = asName(label); node.transformFlags |= propagateChildFlags(node.label) | - 1048576 /* ContainsHoistedDeclarationOrCompletion */; + 2097152 /* ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -23205,13 +23797,13 @@ var ts; } // @api function createReturnStatement(expression) { - var node = createBaseNode(242 /* ReturnStatement */); + var node = createBaseNode(244 /* ReturnStatement */); node.expression = expression; // return in an ES2018 async generator must be awaited node.transformFlags |= propagateChildFlags(node.expression) | - 32 /* ContainsES2018 */ | - 1048576 /* ContainsHoistedDeclarationOrCompletion */; + 64 /* ContainsES2018 */ | + 2097152 /* ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -23222,7 +23814,7 @@ var ts; } // @api function createWithStatement(expression, statement) { - var node = createBaseNode(243 /* WithStatement */); + var node = createBaseNode(245 /* WithStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -23239,7 +23831,7 @@ var ts; } // @api function createSwitchStatement(expression, caseBlock) { - var node = createBaseNode(244 /* SwitchStatement */); + var node = createBaseNode(246 /* SwitchStatement */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.caseBlock = caseBlock; node.transformFlags |= @@ -23256,7 +23848,7 @@ var ts; } // @api function createLabeledStatement(label, statement) { - var node = createBaseNode(245 /* LabeledStatement */); + var node = createBaseNode(247 /* LabeledStatement */); node.label = asName(label); node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -23273,7 +23865,7 @@ var ts; } // @api function createThrowStatement(expression) { - var node = createBaseNode(246 /* ThrowStatement */); + var node = createBaseNode(248 /* ThrowStatement */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -23286,7 +23878,7 @@ var ts; } // @api function createTryStatement(tryBlock, catchClause, finallyBlock) { - var node = createBaseNode(247 /* TryStatement */); + var node = createBaseNode(249 /* TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -23306,11 +23898,11 @@ var ts; } // @api function createDebuggerStatement() { - return createBaseNode(248 /* DebuggerStatement */); + return createBaseNode(250 /* DebuggerStatement */); } // @api function createVariableDeclaration(name, exclamationToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(249 /* VariableDeclaration */, + var node = createBaseVariableLikeDeclaration(251 /* VariableDeclaration */, /*decorators*/ undefined, /*modifiers*/ undefined, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.exclamationToken = exclamationToken; @@ -23332,16 +23924,16 @@ var ts; // @api function createVariableDeclarationList(declarations, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createBaseNode(250 /* VariableDeclarationList */); + var node = createBaseNode(252 /* VariableDeclarationList */); node.flags |= flags & 3 /* BlockScoped */; node.declarations = createNodeArray(declarations); node.transformFlags |= propagateChildrenFlags(node.declarations) | - 1048576 /* ContainsHoistedDeclarationOrCompletion */; + 2097152 /* ContainsHoistedDeclarationOrCompletion */; if (flags & 3 /* BlockScoped */) { node.transformFlags |= - 256 /* ContainsES2015 */ | - 65536 /* ContainsBlockScopedBinding */; + 512 /* ContainsES2015 */ | + 131072 /* ContainsBlockScopedBinding */; } return node; } @@ -23353,7 +23945,7 @@ var ts; } // @api function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(251 /* FunctionDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(253 /* FunctionDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; if (!node.body || ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { node.transformFlags = 1 /* ContainsTypeScript */; @@ -23361,17 +23953,17 @@ var ts; else { node.transformFlags |= propagateChildFlags(node.asteriskToken) | - 1048576 /* ContainsHoistedDeclarationOrCompletion */; + 2097152 /* ContainsHoistedDeclarationOrCompletion */; if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { if (node.asteriskToken) { - node.transformFlags |= 32 /* ContainsES2018 */; + node.transformFlags |= 64 /* ContainsES2018 */; } else { - node.transformFlags |= 64 /* ContainsES2017 */; + node.transformFlags |= 128 /* ContainsES2017 */; } } else if (node.asteriskToken) { - node.transformFlags |= 512 /* ContainsGenerator */; + node.transformFlags |= 1024 /* ContainsGenerator */; } } return node; @@ -23391,13 +23983,13 @@ var ts; } // @api function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseClassLikeDeclaration(252 /* ClassDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses, members); + var node = createBaseClassLikeDeclaration(254 /* ClassDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses, members); if (ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { node.transformFlags = 1 /* ContainsTypeScript */; } else { - node.transformFlags |= 256 /* ContainsES2015 */; - if (node.transformFlags & 2048 /* ContainsTypeScriptClassSyntax */) { + node.transformFlags |= 512 /* ContainsES2015 */; + if (node.transformFlags & 4096 /* ContainsTypeScriptClassSyntax */) { node.transformFlags |= 1 /* ContainsTypeScript */; } } @@ -23416,7 +24008,7 @@ var ts; } // @api function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseInterfaceOrClassLikeDeclaration(253 /* InterfaceDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses); + var node = createBaseInterfaceOrClassLikeDeclaration(255 /* InterfaceDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses); node.members = createNodeArray(members); node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -23434,7 +24026,7 @@ var ts; } // @api function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createBaseGenericNamedDeclaration(254 /* TypeAliasDeclaration */, decorators, modifiers, name, typeParameters); + var node = createBaseGenericNamedDeclaration(256 /* TypeAliasDeclaration */, decorators, modifiers, name, typeParameters); node.type = type; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -23451,12 +24043,12 @@ var ts; } // @api function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createBaseNamedDeclaration(255 /* EnumDeclaration */, decorators, modifiers, name); + var node = createBaseNamedDeclaration(257 /* EnumDeclaration */, decorators, modifiers, name); node.members = createNodeArray(members); node.transformFlags |= propagateChildrenFlags(node.members) | 1 /* ContainsTypeScript */; - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await` + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await` return node; } // @api @@ -23471,7 +24063,7 @@ var ts; // @api function createModuleDeclaration(decorators, modifiers, name, body, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createBaseDeclaration(256 /* ModuleDeclaration */, decorators, modifiers); + var node = createBaseDeclaration(258 /* ModuleDeclaration */, decorators, modifiers); node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 1024 /* GlobalAugmentation */); node.name = name; node.body = body; @@ -23484,7 +24076,7 @@ var ts; propagateChildFlags(node.body) | 1 /* ContainsTypeScript */; } - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`. + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`. return node; } // @api @@ -23498,7 +24090,7 @@ var ts; } // @api function createModuleBlock(statements) { - var node = createBaseNode(257 /* ModuleBlock */); + var node = createBaseNode(259 /* ModuleBlock */); node.statements = createNodeArray(statements); node.transformFlags |= propagateChildrenFlags(node.statements); return node; @@ -23511,7 +24103,7 @@ var ts; } // @api function createCaseBlock(clauses) { - var node = createBaseNode(258 /* CaseBlock */); + var node = createBaseNode(260 /* CaseBlock */); node.clauses = createNodeArray(clauses); node.transformFlags |= propagateChildrenFlags(node.clauses); return node; @@ -23524,7 +24116,7 @@ var ts; } // @api function createNamespaceExportDeclaration(name) { - var node = createBaseNamedDeclaration(259 /* NamespaceExportDeclaration */, + var node = createBaseNamedDeclaration(261 /* NamespaceExportDeclaration */, /*decorators*/ undefined, /*modifiers*/ undefined, name); node.transformFlags = 1 /* ContainsTypeScript */; @@ -23538,13 +24130,13 @@ var ts; } // @api function createImportEqualsDeclaration(decorators, modifiers, isTypeOnly, name, moduleReference) { - var node = createBaseNamedDeclaration(260 /* ImportEqualsDeclaration */, decorators, modifiers, name); + var node = createBaseNamedDeclaration(262 /* ImportEqualsDeclaration */, decorators, modifiers, name); node.isTypeOnly = isTypeOnly; node.moduleReference = moduleReference; node.transformFlags |= propagateChildFlags(node.moduleReference); if (!ts.isExternalModuleReference(node.moduleReference)) node.transformFlags |= 1 /* ContainsTypeScript */; - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // Import= declaration is always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Import= declaration is always parsed in an Await context return node; } // @api @@ -23559,13 +24151,13 @@ var ts; } // @api function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createBaseDeclaration(261 /* ImportDeclaration */, decorators, modifiers); + var node = createBaseDeclaration(263 /* ImportDeclaration */, decorators, modifiers); node.importClause = importClause; node.moduleSpecifier = moduleSpecifier; node.transformFlags |= propagateChildFlags(node.importClause) | propagateChildFlags(node.moduleSpecifier); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23579,7 +24171,7 @@ var ts; } // @api function createImportClause(isTypeOnly, name, namedBindings) { - var node = createBaseNode(262 /* ImportClause */); + var node = createBaseNode(264 /* ImportClause */); node.isTypeOnly = isTypeOnly; node.name = name; node.namedBindings = namedBindings; @@ -23589,7 +24181,7 @@ var ts; if (isTypeOnly) { node.transformFlags |= 1 /* ContainsTypeScript */; } - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23602,10 +24194,10 @@ var ts; } // @api function createNamespaceImport(name) { - var node = createBaseNode(263 /* NamespaceImport */); + var node = createBaseNode(265 /* NamespaceImport */); node.name = name; node.transformFlags |= propagateChildFlags(node.name); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23616,12 +24208,12 @@ var ts; } // @api function createNamespaceExport(name) { - var node = createBaseNode(269 /* NamespaceExport */); + var node = createBaseNode(271 /* NamespaceExport */); node.name = name; node.transformFlags |= propagateChildFlags(node.name) | 4 /* ContainsESNext */; - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23632,10 +24224,10 @@ var ts; } // @api function createNamedImports(elements) { - var node = createBaseNode(264 /* NamedImports */); + var node = createBaseNode(266 /* NamedImports */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23646,13 +24238,13 @@ var ts; } // @api function createImportSpecifier(propertyName, name) { - var node = createBaseNode(265 /* ImportSpecifier */); + var node = createBaseNode(267 /* ImportSpecifier */); node.propertyName = propertyName; node.name = name; node.transformFlags |= propagateChildFlags(node.propertyName) | propagateChildFlags(node.name); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23664,13 +24256,13 @@ var ts; } // @api function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createBaseDeclaration(266 /* ExportAssignment */, decorators, modifiers); + var node = createBaseDeclaration(268 /* ExportAssignment */, decorators, modifiers); node.isExportEquals = isExportEquals; node.expression = isExportEquals - ? parenthesizerRules().parenthesizeRightSideOfBinary(62 /* EqualsToken */, /*leftSide*/ undefined, expression) + ? parenthesizerRules().parenthesizeRightSideOfBinary(63 /* EqualsToken */, /*leftSide*/ undefined, expression) : parenthesizerRules().parenthesizeExpressionOfExportDefault(expression); node.transformFlags |= propagateChildFlags(node.expression); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23683,14 +24275,14 @@ var ts; } // @api function createExportDeclaration(decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier) { - var node = createBaseDeclaration(267 /* ExportDeclaration */, decorators, modifiers); + var node = createBaseDeclaration(269 /* ExportDeclaration */, decorators, modifiers); node.isTypeOnly = isTypeOnly; node.exportClause = exportClause; node.moduleSpecifier = moduleSpecifier; node.transformFlags |= propagateChildFlags(node.exportClause) | propagateChildFlags(node.moduleSpecifier); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23705,10 +24297,10 @@ var ts; } // @api function createNamedExports(elements) { - var node = createBaseNode(268 /* NamedExports */); + var node = createBaseNode(270 /* NamedExports */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23719,13 +24311,13 @@ var ts; } // @api function createExportSpecifier(propertyName, name) { - var node = createBaseNode(270 /* ExportSpecifier */); + var node = createBaseNode(272 /* ExportSpecifier */); node.propertyName = asName(propertyName); node.name = asName(name); node.transformFlags |= propagateChildFlags(node.propertyName) | propagateChildFlags(node.name); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23737,7 +24329,7 @@ var ts; } // @api function createMissingDeclaration() { - var node = createBaseDeclaration(271 /* MissingDeclaration */, + var node = createBaseDeclaration(273 /* MissingDeclaration */, /*decorators*/ undefined, /*modifiers*/ undefined); return node; @@ -23747,10 +24339,10 @@ var ts; // // @api function createExternalModuleReference(expression) { - var node = createBaseNode(272 /* ExternalModuleReference */); + var node = createBaseNode(274 /* ExternalModuleReference */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23792,7 +24384,7 @@ var ts; } // @api function createJSDocFunctionType(parameters, type) { - var node = createBaseSignatureDeclaration(308 /* JSDocFunctionType */, + var node = createBaseSignatureDeclaration(311 /* JSDocFunctionType */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, @@ -23809,7 +24401,7 @@ var ts; // @api function createJSDocTypeLiteral(propertyTags, isArrayType) { if (isArrayType === void 0) { isArrayType = false; } - var node = createBaseNode(312 /* JSDocTypeLiteral */); + var node = createBaseNode(316 /* JSDocTypeLiteral */); node.jsDocPropertyTags = asNodeArray(propertyTags); node.isArrayType = isArrayType; return node; @@ -23823,7 +24415,7 @@ var ts; } // @api function createJSDocTypeExpression(type) { - var node = createBaseNode(301 /* JSDocTypeExpression */); + var node = createBaseNode(303 /* JSDocTypeExpression */); node.type = type; return node; } @@ -23835,7 +24427,7 @@ var ts; } // @api function createJSDocSignature(typeParameters, parameters, type) { - var node = createBaseNode(313 /* JSDocSignature */); + var node = createBaseNode(317 /* JSDocSignature */); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; @@ -23864,7 +24456,7 @@ var ts; } // @api function createJSDocTemplateTag(tagName, constraint, typeParameters, comment) { - var node = createBaseJSDocTag(330 /* JSDocTemplateTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("template"), comment); + var node = createBaseJSDocTag(338 /* JSDocTemplateTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("template"), comment); node.constraint = constraint; node.typeParameters = createNodeArray(typeParameters); return node; @@ -23881,7 +24473,7 @@ var ts; } // @api function createJSDocTypedefTag(tagName, typeExpression, fullName, comment) { - var node = createBaseJSDocTag(331 /* JSDocTypedefTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("typedef"), comment); + var node = createBaseJSDocTag(339 /* JSDocTypedefTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("typedef"), comment); node.typeExpression = typeExpression; node.fullName = fullName; node.name = ts.getJSDocTypeAliasName(fullName); @@ -23899,7 +24491,7 @@ var ts; } // @api function createJSDocParameterTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) { - var node = createBaseJSDocTag(326 /* JSDocParameterTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("param"), comment); + var node = createBaseJSDocTag(334 /* JSDocParameterTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("param"), comment); node.typeExpression = typeExpression; node.name = name; node.isNameFirst = !!isNameFirst; @@ -23920,7 +24512,7 @@ var ts; } // @api function createJSDocPropertyTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) { - var node = createBaseJSDocTag(333 /* JSDocPropertyTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("prop"), comment); + var node = createBaseJSDocTag(341 /* JSDocPropertyTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("prop"), comment); node.typeExpression = typeExpression; node.name = name; node.isNameFirst = !!isNameFirst; @@ -23941,7 +24533,7 @@ var ts; } // @api function createJSDocCallbackTag(tagName, typeExpression, fullName, comment) { - var node = createBaseJSDocTag(324 /* JSDocCallbackTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("callback"), comment); + var node = createBaseJSDocTag(332 /* JSDocCallbackTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("callback"), comment); node.typeExpression = typeExpression; node.fullName = fullName; node.name = ts.getJSDocTypeAliasName(fullName); @@ -23959,7 +24551,7 @@ var ts; } // @api function createJSDocAugmentsTag(tagName, className, comment) { - var node = createBaseJSDocTag(315 /* JSDocAugmentsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("augments"), comment); + var node = createBaseJSDocTag(322 /* JSDocAugmentsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("augments"), comment); node.class = className; return node; } @@ -23974,13 +24566,13 @@ var ts; } // @api function createJSDocImplementsTag(tagName, className, comment) { - var node = createBaseJSDocTag(316 /* JSDocImplementsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("implements"), comment); + var node = createBaseJSDocTag(323 /* JSDocImplementsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("implements"), comment); node.class = className; return node; } // @api function createJSDocSeeTag(tagName, name, comment) { - var node = createBaseJSDocTag(332 /* JSDocSeeTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("see"), comment); + var node = createBaseJSDocTag(340 /* JSDocSeeTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("see"), comment); node.name = name; return node; } @@ -23994,7 +24586,7 @@ var ts; } // @api function createJSDocNameReference(name) { - var node = createBaseNode(302 /* JSDocNameReference */); + var node = createBaseNode(304 /* JSDocNameReference */); node.name = name; return node; } @@ -24005,6 +24597,62 @@ var ts; : node; } // @api + function createJSDocMemberName(left, right) { + var node = createBaseNode(305 /* JSDocMemberName */); + node.left = left; + node.right = right; + node.transformFlags |= + propagateChildFlags(node.left) | + propagateChildFlags(node.right); + return node; + } + // @api + function updateJSDocMemberName(node, left, right) { + return node.left !== left + || node.right !== right + ? update(createJSDocMemberName(left, right), node) + : node; + } + // @api + function createJSDocLink(name, text) { + var node = createBaseNode(318 /* JSDocLink */); + node.name = name; + node.text = text; + return node; + } + // @api + function updateJSDocLink(node, name, text) { + return node.name !== name + ? update(createJSDocLink(name, text), node) + : node; + } + // @api + function createJSDocLinkCode(name, text) { + var node = createBaseNode(319 /* JSDocLinkCode */); + node.name = name; + node.text = text; + return node; + } + // @api + function updateJSDocLinkCode(node, name, text) { + return node.name !== name + ? update(createJSDocLinkCode(name, text), node) + : node; + } + // @api + function createJSDocLinkPlain(name, text) { + var node = createBaseNode(320 /* JSDocLinkPlain */); + node.name = name; + node.text = text; + return node; + } + // @api + function updateJSDocLinkPlain(node, name, text) { + return node.name !== name + ? update(createJSDocLinkPlain(name, text), node) + : node; + } + // @api function updateJSDocImplementsTag(node, tagName, className, comment) { if (tagName === void 0) { tagName = getDefaultTagName(node); } return node.tagName !== tagName @@ -24065,7 +24713,7 @@ var ts; } // @api function createJSDocUnknownTag(tagName, comment) { - var node = createBaseJSDocTag(314 /* JSDocTag */, tagName, comment); + var node = createBaseJSDocTag(321 /* JSDocTag */, tagName, comment); return node; } // @api @@ -24076,8 +24724,20 @@ var ts; : node; } // @api + function createJSDocText(text) { + var node = createBaseNode(315 /* JSDocText */); + node.text = text; + return node; + } + // @api + function updateJSDocText(node, text) { + return node.text !== text + ? update(createJSDocText(text), node) + : node; + } + // @api function createJSDocComment(comment, tags) { - var node = createBaseNode(311 /* JSDocComment */); + var node = createBaseNode(314 /* JSDocComment */); node.comment = comment; node.tags = asNodeArray(tags); return node; @@ -24094,7 +24754,7 @@ var ts; // // @api function createJsxElement(openingElement, children, closingElement) { - var node = createBaseNode(273 /* JsxElement */); + var node = createBaseNode(275 /* JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -24115,7 +24775,7 @@ var ts; } // @api function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createBaseNode(274 /* JsxSelfClosingElement */); + var node = createBaseNode(276 /* JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -24139,7 +24799,7 @@ var ts; } // @api function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createBaseNode(275 /* JsxOpeningElement */); + var node = createBaseNode(277 /* JsxOpeningElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -24163,7 +24823,7 @@ var ts; } // @api function createJsxClosingElement(tagName) { - var node = createBaseNode(276 /* JsxClosingElement */); + var node = createBaseNode(278 /* JsxClosingElement */); node.tagName = tagName; node.transformFlags |= propagateChildFlags(node.tagName) | @@ -24178,7 +24838,7 @@ var ts; } // @api function createJsxFragment(openingFragment, children, closingFragment) { - var node = createBaseNode(277 /* JsxFragment */); + var node = createBaseNode(279 /* JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -24214,19 +24874,19 @@ var ts; } // @api function createJsxOpeningFragment() { - var node = createBaseNode(278 /* JsxOpeningFragment */); + var node = createBaseNode(280 /* JsxOpeningFragment */); node.transformFlags |= 2 /* ContainsJsx */; return node; } // @api function createJsxJsxClosingFragment() { - var node = createBaseNode(279 /* JsxClosingFragment */); + var node = createBaseNode(281 /* JsxClosingFragment */); node.transformFlags |= 2 /* ContainsJsx */; return node; } // @api function createJsxAttribute(name, initializer) { - var node = createBaseNode(280 /* JsxAttribute */); + var node = createBaseNode(282 /* JsxAttribute */); node.name = name; node.initializer = initializer; node.transformFlags |= @@ -24244,7 +24904,7 @@ var ts; } // @api function createJsxAttributes(properties) { - var node = createBaseNode(281 /* JsxAttributes */); + var node = createBaseNode(283 /* JsxAttributes */); node.properties = createNodeArray(properties); node.transformFlags |= propagateChildrenFlags(node.properties) | @@ -24259,7 +24919,7 @@ var ts; } // @api function createJsxSpreadAttribute(expression) { - var node = createBaseNode(282 /* JsxSpreadAttribute */); + var node = createBaseNode(284 /* JsxSpreadAttribute */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression) | @@ -24274,7 +24934,7 @@ var ts; } // @api function createJsxExpression(dotDotDotToken, expression) { - var node = createBaseNode(283 /* JsxExpression */); + var node = createBaseNode(285 /* JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; node.transformFlags |= @@ -24294,7 +24954,7 @@ var ts; // // @api function createCaseClause(expression, statements) { - var node = createBaseNode(284 /* CaseClause */); + var node = createBaseNode(286 /* CaseClause */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.statements = createNodeArray(statements); node.transformFlags |= @@ -24311,7 +24971,7 @@ var ts; } // @api function createDefaultClause(statements) { - var node = createBaseNode(285 /* DefaultClause */); + var node = createBaseNode(287 /* DefaultClause */); node.statements = createNodeArray(statements); node.transformFlags = propagateChildrenFlags(node.statements); return node; @@ -24324,15 +24984,15 @@ var ts; } // @api function createHeritageClause(token, types) { - var node = createBaseNode(286 /* HeritageClause */); + var node = createBaseNode(288 /* HeritageClause */); node.token = token; node.types = createNodeArray(types); node.transformFlags |= propagateChildrenFlags(node.types); switch (token) { - case 93 /* ExtendsKeyword */: - node.transformFlags |= 256 /* ContainsES2015 */; + case 94 /* ExtendsKeyword */: + node.transformFlags |= 512 /* ContainsES2015 */; break; - case 116 /* ImplementsKeyword */: + case 117 /* ImplementsKeyword */: node.transformFlags |= 1 /* ContainsTypeScript */; break; default: @@ -24348,7 +25008,7 @@ var ts; } // @api function createCatchClause(variableDeclaration, block) { - var node = createBaseNode(287 /* CatchClause */); + var node = createBaseNode(289 /* CatchClause */); variableDeclaration = !ts.isString(variableDeclaration) ? variableDeclaration : createVariableDeclaration(variableDeclaration, /*exclamationToken*/ undefined, /*type*/ undefined, @@ -24359,7 +25019,7 @@ var ts; propagateChildFlags(node.variableDeclaration) | propagateChildFlags(node.block); if (!variableDeclaration) - node.transformFlags |= 16 /* ContainsES2019 */; + node.transformFlags |= 32 /* ContainsES2019 */; return node; } // @api @@ -24374,7 +25034,7 @@ var ts; // // @api function createPropertyAssignment(name, initializer) { - var node = createBaseNamedDeclaration(288 /* PropertyAssignment */, + var node = createBaseNamedDeclaration(290 /* PropertyAssignment */, /*decorators*/ undefined, /*modifiers*/ undefined, name); node.initializer = parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); @@ -24404,13 +25064,13 @@ var ts; } // @api function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createBaseNamedDeclaration(289 /* ShorthandPropertyAssignment */, + var node = createBaseNamedDeclaration(291 /* ShorthandPropertyAssignment */, /*decorators*/ undefined, /*modifiers*/ undefined, name); node.objectAssignmentInitializer = objectAssignmentInitializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(objectAssignmentInitializer); node.transformFlags |= propagateChildFlags(node.objectAssignmentInitializer) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; return node; } function finishUpdateShorthandPropertyAssignment(updated, original) { @@ -24436,12 +25096,12 @@ var ts; } // @api function createSpreadAssignment(expression) { - var node = createBaseNode(290 /* SpreadAssignment */); + var node = createBaseNode(292 /* SpreadAssignment */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 32 /* ContainsES2018 */ | - 16384 /* ContainsObjectRestOrSpread */; + 64 /* ContainsES2018 */ | + 32768 /* ContainsObjectRestOrSpread */; return node; } // @api @@ -24455,7 +25115,7 @@ var ts; // // @api function createEnumMember(name, initializer) { - var node = createBaseNode(291 /* EnumMember */); + var node = createBaseNode(293 /* EnumMember */); node.name = asName(name); node.initializer = initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); node.transformFlags |= @@ -24476,7 +25136,7 @@ var ts; // // @api function createSourceFile(statements, endOfFileToken, flags) { - var node = baseFactory.createBaseSourceFileNode(297 /* SourceFile */); + var node = baseFactory.createBaseSourceFileNode(299 /* SourceFile */); node.statements = createNodeArray(statements); node.endOfFileToken = endOfFileToken; node.flags |= flags; @@ -24493,7 +25153,7 @@ var ts; return node; } function cloneSourceFileWithChanges(source, statements, isDeclarationFile, referencedFiles, typeReferences, hasNoDefaultLib, libReferences) { - var node = baseFactory.createBaseSourceFileNode(297 /* SourceFile */); + var node = baseFactory.createBaseSourceFileNode(299 /* SourceFile */); for (var p in source) { if (p === "emitNode" || ts.hasProperty(node, p) || !ts.hasProperty(source, p)) continue; @@ -24531,7 +25191,7 @@ var ts; // @api function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = createBaseNode(298 /* Bundle */); + var node = createBaseNode(300 /* Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; @@ -24546,7 +25206,7 @@ var ts; } // @api function createUnparsedSource(prologues, syntheticReferences, texts) { - var node = createBaseNode(299 /* UnparsedSource */); + var node = createBaseNode(301 /* UnparsedSource */); node.prologues = prologues; node.syntheticReferences = syntheticReferences; node.texts = texts; @@ -24564,28 +25224,28 @@ var ts; } // @api function createUnparsedPrologue(data) { - return createBaseUnparsedNode(292 /* UnparsedPrologue */, data); + return createBaseUnparsedNode(294 /* UnparsedPrologue */, data); } // @api function createUnparsedPrepend(data, texts) { - var node = createBaseUnparsedNode(293 /* UnparsedPrepend */, data); + var node = createBaseUnparsedNode(295 /* UnparsedPrepend */, data); node.texts = texts; return node; } // @api function createUnparsedTextLike(data, internal) { - return createBaseUnparsedNode(internal ? 295 /* UnparsedInternalText */ : 294 /* UnparsedText */, data); + return createBaseUnparsedNode(internal ? 297 /* UnparsedInternalText */ : 296 /* UnparsedText */, data); } // @api function createUnparsedSyntheticReference(section) { - var node = createBaseNode(296 /* UnparsedSyntheticReference */); + var node = createBaseNode(298 /* UnparsedSyntheticReference */); node.data = section.data; node.section = section; return node; } // @api function createInputFiles() { - var node = createBaseNode(300 /* InputFiles */); + var node = createBaseNode(302 /* InputFiles */); node.javascriptText = ""; node.declarationText = ""; return node; @@ -24596,7 +25256,7 @@ var ts; // @api function createSyntheticExpression(type, isSpread, tupleNameSource) { if (isSpread === void 0) { isSpread = false; } - var node = createBaseNode(227 /* SyntheticExpression */); + var node = createBaseNode(229 /* SyntheticExpression */); node.type = type; node.isSpread = isSpread; node.tupleNameSource = tupleNameSource; @@ -24604,7 +25264,7 @@ var ts; } // @api function createSyntaxList(children) { - var node = createBaseNode(334 /* SyntaxList */); + var node = createBaseNode(342 /* SyntaxList */); node._children = children; return node; } @@ -24619,7 +25279,7 @@ var ts; */ // @api function createNotEmittedStatement(original) { - var node = createBaseNode(335 /* NotEmittedStatement */); + var node = createBaseNode(343 /* NotEmittedStatement */); node.original = original; ts.setTextRange(node, original); return node; @@ -24633,7 +25293,7 @@ var ts; */ // @api function createPartiallyEmittedExpression(expression, original) { - var node = createBaseNode(336 /* PartiallyEmittedExpression */); + var node = createBaseNode(344 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; node.transformFlags |= @@ -24661,7 +25321,7 @@ var ts; } // @api function createCommaListExpression(elements) { - var node = createBaseNode(337 /* CommaListExpression */); + var node = createBaseNode(345 /* CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); node.transformFlags |= propagateChildrenFlags(node.elements); return node; @@ -24678,7 +25338,7 @@ var ts; */ // @api function createEndOfDeclarationMarker(original) { - var node = createBaseNode(339 /* EndOfDeclarationMarker */); + var node = createBaseNode(347 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -24689,14 +25349,14 @@ var ts; */ // @api function createMergeDeclarationMarker(original) { - var node = createBaseNode(338 /* MergeDeclarationMarker */); + var node = createBaseNode(346 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; } // @api function createSyntheticReferenceExpression(expression, thisArg) { - var node = createBaseNode(340 /* SyntheticReferenceExpression */); + var node = createBaseNode(348 /* SyntheticReferenceExpression */); node.expression = expression; node.thisArg = thisArg; node.transformFlags |= @@ -24718,9 +25378,9 @@ var ts; if (node === undefined) { return node; } - var clone = ts.isSourceFile(node) ? baseFactory.createBaseSourceFileNode(297 /* SourceFile */) : - ts.isIdentifier(node) ? baseFactory.createBaseIdentifierNode(78 /* Identifier */) : - ts.isPrivateIdentifier(node) ? baseFactory.createBasePrivateIdentifierNode(79 /* PrivateIdentifier */) : + var clone = ts.isSourceFile(node) ? baseFactory.createBaseSourceFileNode(299 /* SourceFile */) : + ts.isIdentifier(node) ? baseFactory.createBaseIdentifierNode(79 /* Identifier */) : + ts.isPrivateIdentifier(node) ? baseFactory.createBasePrivateIdentifierNode(80 /* PrivateIdentifier */) : !ts.isNodeKind(node.kind) ? baseFactory.createBaseTokenNode(node.kind) : baseFactory.createBaseNode(node.kind); clone.flags |= (node.flags & ~8 /* Synthesized */); @@ -24825,11 +25485,11 @@ var ts; } function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 207 /* ParenthesizedExpression */: return updateParenthesizedExpression(outerExpression, expression); - case 206 /* TypeAssertionExpression */: return updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 224 /* AsExpression */: return updateAsExpression(outerExpression, expression, outerExpression.type); - case 225 /* NonNullExpression */: return updateNonNullExpression(outerExpression, expression); - case 336 /* PartiallyEmittedExpression */: return updatePartiallyEmittedExpression(outerExpression, expression); + case 209 /* ParenthesizedExpression */: return updateParenthesizedExpression(outerExpression, expression); + case 208 /* TypeAssertionExpression */: return updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 226 /* AsExpression */: return updateAsExpression(outerExpression, expression, outerExpression.type); + case 227 /* NonNullExpression */: return updateNonNullExpression(outerExpression, expression); + case 344 /* PartiallyEmittedExpression */: return updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -24876,20 +25536,20 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = ts.skipParentheses(node); switch (target.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return cacheIdentifiers; - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: return false; - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -25292,23 +25952,24 @@ var ts; } function getDefaultTagNameForKind(kind) { switch (kind) { - case 329 /* JSDocTypeTag */: return "type"; - case 327 /* JSDocReturnTag */: return "returns"; - case 328 /* JSDocThisTag */: return "this"; - case 325 /* JSDocEnumTag */: return "enum"; - case 317 /* JSDocAuthorTag */: return "author"; - case 319 /* JSDocClassTag */: return "class"; - case 320 /* JSDocPublicTag */: return "public"; - case 321 /* JSDocPrivateTag */: return "private"; - case 322 /* JSDocProtectedTag */: return "protected"; - case 323 /* JSDocReadonlyTag */: return "readonly"; - case 330 /* JSDocTemplateTag */: return "template"; - case 331 /* JSDocTypedefTag */: return "typedef"; - case 326 /* JSDocParameterTag */: return "param"; - case 333 /* JSDocPropertyTag */: return "prop"; - case 324 /* JSDocCallbackTag */: return "callback"; - case 315 /* JSDocAugmentsTag */: return "augments"; - case 316 /* JSDocImplementsTag */: return "implements"; + case 337 /* JSDocTypeTag */: return "type"; + case 335 /* JSDocReturnTag */: return "returns"; + case 336 /* JSDocThisTag */: return "this"; + case 333 /* JSDocEnumTag */: return "enum"; + case 324 /* JSDocAuthorTag */: return "author"; + case 326 /* JSDocClassTag */: return "class"; + case 327 /* JSDocPublicTag */: return "public"; + case 328 /* JSDocPrivateTag */: return "private"; + case 329 /* JSDocProtectedTag */: return "protected"; + case 330 /* JSDocReadonlyTag */: return "readonly"; + case 331 /* JSDocOverrideTag */: return "override"; + case 338 /* JSDocTemplateTag */: return "template"; + case 339 /* JSDocTypedefTag */: return "typedef"; + case 334 /* JSDocParameterTag */: return "param"; + case 341 /* JSDocPropertyTag */: return "prop"; + case 332 /* JSDocCallbackTag */: return "callback"; + case 322 /* JSDocAugmentsTag */: return "augments"; + case 323 /* JSDocImplementsTag */: return "implements"; default: return ts.Debug.fail("Unsupported kind: " + ts.Debug.formatSyntaxKind(kind)); } @@ -25361,10 +26022,10 @@ var ts; } function propagateIdentifierNameFlags(node) { // An IdentifierName is allowed to be `await` - return propagateChildFlags(node) & ~8388608 /* ContainsPossibleTopLevelAwait */; + return propagateChildFlags(node) & ~16777216 /* ContainsPossibleTopLevelAwait */; } function propagatePropertyNameFlagsOfChild(node, transformFlags) { - return transformFlags | (node.transformFlags & 4096 /* PropertyNamePropagatingFlags */); + return transformFlags | (node.transformFlags & 8192 /* PropertyNamePropagatingFlags */); } function propagateChildFlags(child) { if (!child) @@ -25388,69 +26049,69 @@ var ts; */ /* @internal */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 172 /* FirstTypeNode */ && kind <= 195 /* LastTypeNode */) { + if (kind >= 174 /* FirstTypeNode */ && kind <= 197 /* LastTypeNode */) { return -2 /* TypeExcludes */; } switch (kind) { - case 203 /* CallExpression */: - case 204 /* NewExpression */: - case 199 /* ArrayLiteralExpression */: - return 536879104 /* ArrayLiteralOrCallOrNewExcludes */; - case 256 /* ModuleDeclaration */: - return 546379776 /* ModuleExcludes */; - case 160 /* Parameter */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: + case 201 /* ArrayLiteralExpression */: + return 536887296 /* ArrayLiteralOrCallOrNewExcludes */; + case 258 /* ModuleDeclaration */: + return 555888640 /* ModuleExcludes */; + case 162 /* Parameter */: return 536870912 /* ParameterExcludes */; - case 209 /* ArrowFunction */: - return 547309568 /* ArrowFunctionExcludes */; - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: - return 547313664 /* FunctionExcludes */; - case 250 /* VariableDeclarationList */: - return 537018368 /* VariableDeclarationListExcludes */; - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - return 536905728 /* ClassExcludes */; - case 166 /* Constructor */: - return 547311616 /* ConstructorExcludes */; - case 163 /* PropertyDeclaration */: - return 536875008 /* PropertyExcludes */; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - return 538923008 /* MethodOrAccessorExcludes */; - case 128 /* AnyKeyword */: - case 144 /* NumberKeyword */: - case 155 /* BigIntKeyword */: - case 141 /* NeverKeyword */: - case 147 /* StringKeyword */: - case 145 /* ObjectKeyword */: - case 131 /* BooleanKeyword */: - case 148 /* SymbolKeyword */: - case 113 /* VoidKeyword */: - case 159 /* TypeParameter */: - case 162 /* PropertySignature */: - case 164 /* MethodSignature */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 211 /* ArrowFunction */: + return 557748224 /* ArrowFunctionExcludes */; + case 210 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + return 557756416 /* FunctionExcludes */; + case 252 /* VariableDeclarationList */: + return 537165824 /* VariableDeclarationListExcludes */; + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + return 536940544 /* ClassExcludes */; + case 168 /* Constructor */: + return 557752320 /* ConstructorExcludes */; + case 165 /* PropertyDeclaration */: + return 536879104 /* PropertyExcludes */; + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + return 540975104 /* MethodOrAccessorExcludes */; + case 129 /* AnyKeyword */: + case 145 /* NumberKeyword */: + case 156 /* BigIntKeyword */: + case 142 /* NeverKeyword */: + case 148 /* StringKeyword */: + case 146 /* ObjectKeyword */: + case 132 /* BooleanKeyword */: + case 149 /* SymbolKeyword */: + case 114 /* VoidKeyword */: + case 161 /* TypeParameter */: + case 164 /* PropertySignature */: + case 166 /* MethodSignature */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 173 /* IndexSignature */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: return -2 /* TypeExcludes */; - case 200 /* ObjectLiteralExpression */: - return 536922112 /* ObjectLiteralExcludes */; - case 287 /* CatchClause */: - return 536887296 /* CatchClauseExcludes */; - case 196 /* ObjectBindingPattern */: - case 197 /* ArrayBindingPattern */: - return 536879104 /* BindingPatternExcludes */; - case 206 /* TypeAssertionExpression */: - case 224 /* AsExpression */: - case 336 /* PartiallyEmittedExpression */: - case 207 /* ParenthesizedExpression */: - case 105 /* SuperKeyword */: + case 202 /* ObjectLiteralExpression */: + return 536973312 /* ObjectLiteralExcludes */; + case 289 /* CatchClause */: + return 536903680 /* CatchClauseExcludes */; + case 198 /* ObjectBindingPattern */: + case 199 /* ArrayBindingPattern */: + return 536887296 /* BindingPatternExcludes */; + case 208 /* TypeAssertionExpression */: + case 226 /* AsExpression */: + case 344 /* PartiallyEmittedExpression */: + case 209 /* ParenthesizedExpression */: + case 106 /* SuperKeyword */: return 536870912 /* OuterExpressionExcludes */; - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: return 536870912 /* PropertyAccessExcludes */; default: return 536870912 /* NodeExcludes */; @@ -25749,7 +26410,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 === 297 /* SourceFile */) { + if (node.kind === 299 /* 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."); @@ -26236,13 +26897,27 @@ var ts; /*typeArguments*/ undefined, [moduleExpression, exportsExpression]); } // Class Fields Helpers - function createClassPrivateFieldGetHelper(receiver, privateField) { + function createClassPrivateFieldGetHelper(receiver, state, kind, f) { context.requestEmitHelper(ts.classPrivateFieldGetHelper); - return factory.createCallExpression(getUnscopedHelperName("__classPrivateFieldGet"), /*typeArguments*/ undefined, [receiver, privateField]); + var args; + if (!f) { + args = [receiver, state, factory.createStringLiteral(kind)]; + } + else { + args = [receiver, state, factory.createStringLiteral(kind), f]; + } + return factory.createCallExpression(getUnscopedHelperName("__classPrivateFieldGet"), /*typeArguments*/ undefined, args); } - function createClassPrivateFieldSetHelper(receiver, privateField, value) { + function createClassPrivateFieldSetHelper(receiver, state, value, kind, f) { context.requestEmitHelper(ts.classPrivateFieldSetHelper); - return factory.createCallExpression(getUnscopedHelperName("__classPrivateFieldSet"), /*typeArguments*/ undefined, [receiver, privateField, value]); + var args; + if (!f) { + args = [receiver, state, value, factory.createStringLiteral(kind)]; + } + else { + args = [receiver, state, value, factory.createStringLiteral(kind), f]; + } + return factory.createCallExpression(getUnscopedHelperName("__classPrivateFieldSet"), /*typeArguments*/ undefined, args); } } ts.createEmitHelperFactory = createEmitHelperFactory; @@ -26482,7 +27157,6 @@ var ts; scoped: false, text: "\n var __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n };" }; - // emit output for the __export helper function ts.exportStarHelper = { name: "typescript:export-star", importName: "__exportStar", @@ -26491,18 +27165,116 @@ var ts; priority: 2, text: "\n var __exportStar = (this && this.__exportStar) || function(m, exports) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\n };" }; - // Class fields helpers + /** + * Parameters: + * @param receiver — The object from which the private member will be read. + * @param state — One of the following: + * - A WeakMap used to read a private instance field. + * - A WeakSet used as an instance brand for private instance methods and accessors. + * - A function value that should be the undecorated class constructor used to brand check private static fields, methods, and accessors. + * @param kind — (optional pre TS 4.3, required for TS 4.3+) One of the following values: + * - undefined — Indicates a private instance field (pre TS 4.3). + * - "f" — Indicates a private field (instance or static). + * - "m" — Indicates a private method (instance or static). + * - "a" — Indicates a private accessor (instance or static). + * @param f — (optional pre TS 4.3) Depends on the arguments for state and kind: + * - If kind is "m", this should be the function corresponding to the static or instance method. + * - If kind is "a", this should be the function corresponding to the getter method, or undefined if the getter was not defined. + * - If kind is "f" and state is a function, this should be an object holding the value of a static field, or undefined if the static field declaration has not yet been evaluated. + * Usage: + * This helper will only ever be used by the compiler in the following ways: + * + * Reading from a private instance field (pre TS 4.3): + * __classPrivateFieldGet(, ) + * + * Reading from a private instance field (TS 4.3+): + * __classPrivateFieldGet(, , "f") + * + * Reading from a private instance get accessor (when defined, TS 4.3+): + * __classPrivateFieldGet(, , "a", ) + * + * Reading from a private instance get accessor (when not defined, TS 4.3+): + * __classPrivateFieldGet(, , "a", void 0) + * NOTE: This always results in a runtime error. + * + * Reading from a private instance method (TS 4.3+): + * __classPrivateFieldGet(, , "m", ) + * + * Reading from a private static field (TS 4.3+): + * __classPrivateFieldGet(, , "f", <{ value: any }>) + * + * Reading from a private static get accessor (when defined, TS 4.3+): + * __classPrivateFieldGet(, , "a", ) + * + * Reading from a private static get accessor (when not defined, TS 4.3+): + * __classPrivateFieldGet(, , "a", void 0) + * NOTE: This always results in a runtime error. + * + * Reading from a private static method (TS 4.3+): + * __classPrivateFieldGet(, , "m", ) + */ ts.classPrivateFieldGetHelper = { name: "typescript:classPrivateFieldGet", importName: "__classPrivateFieldGet", scoped: false, - text: "\n var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, privateMap) {\n if (!privateMap.has(receiver)) {\n throw new TypeError(\"attempted to get private field on non-instance\");\n }\n return privateMap.get(receiver);\n };" + text: "\n var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n };" }; + /** + * Parameters: + * @param receiver — The object on which the private member will be set. + * @param state — One of the following: + * - A WeakMap used to store a private instance field. + * - A WeakSet used as an instance brand for private instance methods and accessors. + * - A function value that should be the undecorated class constructor used to brand check private static fields, methods, and accessors. + * @param value — The value to set. + * @param kind — (optional pre TS 4.3, required for TS 4.3+) One of the following values: + * - undefined — Indicates a private instance field (pre TS 4.3). + * - "f" — Indicates a private field (instance or static). + * - "m" — Indicates a private method (instance or static). + * - "a" — Indicates a private accessor (instance or static). + * @param f — (optional pre TS 4.3) Depends on the arguments for state and kind: + * - If kind is "m", this should be the function corresponding to the static or instance method. + * - If kind is "a", this should be the function corresponding to the setter method, or undefined if the setter was not defined. + * - If kind is "f" and state is a function, this should be an object holding the value of a static field, or undefined if the static field declaration has not yet been evaluated. + * Usage: + * This helper will only ever be used by the compiler in the following ways: + * + * Writing to a private instance field (pre TS 4.3): + * __classPrivateFieldSet(, , ) + * + * Writing to a private instance field (TS 4.3+): + * __classPrivateFieldSet(, , , "f") + * + * Writing to a private instance set accessor (when defined, TS 4.3+): + * __classPrivateFieldSet(, , , "a", ) + * + * Writing to a private instance set accessor (when not defined, TS 4.3+): + * __classPrivateFieldSet(, , , "a", void 0) + * NOTE: This always results in a runtime error. + * + * Writing to a private instance method (TS 4.3+): + * __classPrivateFieldSet(, , , "m", ) + * NOTE: This always results in a runtime error. + * + * Writing to a private static field (TS 4.3+): + * __classPrivateFieldSet(, , , "f", <{ value: any }>) + * + * Writing to a private static set accessor (when defined, TS 4.3+): + * __classPrivateFieldSet(, , , "a", ) + * + * Writing to a private static set accessor (when not defined, TS 4.3+): + * __classPrivateFieldSet(, , , "a", void 0) + * NOTE: This always results in a runtime error. + * + * Writing to a private static method (TS 4.3+): + * __classPrivateFieldSet(, , , "m", ) + * NOTE: This always results in a runtime error. + */ ts.classPrivateFieldSetHelper = { name: "typescript:classPrivateFieldSet", importName: "__classPrivateFieldSet", scoped: false, - text: "\n var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, privateMap, value) {\n if (!privateMap.has(receiver)) {\n throw new TypeError(\"attempted to set private field on non-instance\");\n }\n privateMap.set(receiver, value);\n return value;\n };" + text: "\n var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\n };" }; var allUnscopedEmitHelpers; function getAllUnscopedEmitHelpers() { @@ -26591,626 +27363,688 @@ var ts; return node.kind === 17 /* TemplateTail */; } ts.isTemplateTail = isTemplateTail; + // Punctuation + function isDotDotDotToken(node) { + return node.kind === 25 /* DotDotDotToken */; + } + ts.isDotDotDotToken = isDotDotDotToken; + /*@internal*/ + function isCommaToken(node) { + return node.kind === 27 /* CommaToken */; + } + ts.isCommaToken = isCommaToken; + function isPlusToken(node) { + return node.kind === 39 /* PlusToken */; + } + ts.isPlusToken = isPlusToken; + function isMinusToken(node) { + return node.kind === 40 /* MinusToken */; + } + ts.isMinusToken = isMinusToken; + function isAsteriskToken(node) { + return node.kind === 41 /* AsteriskToken */; + } + ts.isAsteriskToken = isAsteriskToken; + /*@internal*/ + function isExclamationToken(node) { + return node.kind === 53 /* ExclamationToken */; + } + ts.isExclamationToken = isExclamationToken; + /*@internal*/ + function isQuestionToken(node) { + return node.kind === 57 /* QuestionToken */; + } + ts.isQuestionToken = isQuestionToken; + /*@internal*/ + function isColonToken(node) { + return node.kind === 58 /* ColonToken */; + } + ts.isColonToken = isColonToken; + /*@internal*/ + function isQuestionDotToken(node) { + return node.kind === 28 /* QuestionDotToken */; + } + ts.isQuestionDotToken = isQuestionDotToken; + /*@internal*/ + function isEqualsGreaterThanToken(node) { + return node.kind === 38 /* EqualsGreaterThanToken */; + } + ts.isEqualsGreaterThanToken = isEqualsGreaterThanToken; // Identifiers function isIdentifier(node) { - return node.kind === 78 /* Identifier */; + return node.kind === 79 /* Identifier */; } ts.isIdentifier = isIdentifier; - // Names - function isQualifiedName(node) { - return node.kind === 157 /* QualifiedName */; - } - ts.isQualifiedName = isQualifiedName; - function isComputedPropertyName(node) { - return node.kind === 158 /* ComputedPropertyName */; - } - ts.isComputedPropertyName = isComputedPropertyName; function isPrivateIdentifier(node) { - return node.kind === 79 /* PrivateIdentifier */; + return node.kind === 80 /* PrivateIdentifier */; } ts.isPrivateIdentifier = isPrivateIdentifier; - // Tokens + // Reserved Words + /* @internal */ + function isExportModifier(node) { + return node.kind === 93 /* ExportKeyword */; + } + ts.isExportModifier = isExportModifier; + /* @internal */ + function isAsyncModifier(node) { + return node.kind === 130 /* AsyncKeyword */; + } + ts.isAsyncModifier = isAsyncModifier; + /* @internal */ + function isAssertsKeyword(node) { + return node.kind === 128 /* AssertsKeyword */; + } + ts.isAssertsKeyword = isAssertsKeyword; + /* @internal */ + function isAwaitKeyword(node) { + return node.kind === 131 /* AwaitKeyword */; + } + ts.isAwaitKeyword = isAwaitKeyword; + /* @internal */ + function isReadonlyKeyword(node) { + return node.kind === 143 /* ReadonlyKeyword */; + } + ts.isReadonlyKeyword = isReadonlyKeyword; + /* @internal */ + function isStaticModifier(node) { + return node.kind === 124 /* StaticKeyword */; + } + ts.isStaticModifier = isStaticModifier; /*@internal*/ function isSuperKeyword(node) { - return node.kind === 105 /* SuperKeyword */; + return node.kind === 106 /* SuperKeyword */; } ts.isSuperKeyword = isSuperKeyword; /*@internal*/ function isImportKeyword(node) { - return node.kind === 99 /* ImportKeyword */; + return node.kind === 100 /* ImportKeyword */; } ts.isImportKeyword = isImportKeyword; - /*@internal*/ - function isCommaToken(node) { - return node.kind === 27 /* CommaToken */; - } - ts.isCommaToken = isCommaToken; - /*@internal*/ - function isQuestionToken(node) { - return node.kind === 57 /* QuestionToken */; + // Names + function isQualifiedName(node) { + return node.kind === 159 /* QualifiedName */; } - ts.isQuestionToken = isQuestionToken; - /*@internal*/ - function isExclamationToken(node) { - return node.kind === 53 /* ExclamationToken */; + ts.isQualifiedName = isQualifiedName; + function isComputedPropertyName(node) { + return node.kind === 160 /* ComputedPropertyName */; } - ts.isExclamationToken = isExclamationToken; + ts.isComputedPropertyName = isComputedPropertyName; // Signature elements function isTypeParameterDeclaration(node) { - return node.kind === 159 /* TypeParameter */; + return node.kind === 161 /* TypeParameter */; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; // TODO(rbuckton): Rename to 'isParameterDeclaration' function isParameter(node) { - return node.kind === 160 /* Parameter */; + return node.kind === 162 /* Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 161 /* Decorator */; + return node.kind === 163 /* Decorator */; } ts.isDecorator = isDecorator; // TypeMember function isPropertySignature(node) { - return node.kind === 162 /* PropertySignature */; + return node.kind === 164 /* PropertySignature */; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 163 /* PropertyDeclaration */; + return node.kind === 165 /* PropertyDeclaration */; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 164 /* MethodSignature */; + return node.kind === 166 /* MethodSignature */; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 165 /* MethodDeclaration */; + return node.kind === 167 /* MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isConstructorDeclaration(node) { - return node.kind === 166 /* Constructor */; + return node.kind === 168 /* Constructor */; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 167 /* GetAccessor */; + return node.kind === 169 /* GetAccessor */; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 168 /* SetAccessor */; + return node.kind === 170 /* SetAccessor */; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 169 /* CallSignature */; + return node.kind === 171 /* CallSignature */; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 170 /* ConstructSignature */; + return node.kind === 172 /* ConstructSignature */; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 171 /* IndexSignature */; + return node.kind === 173 /* IndexSignature */; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; // Type function isTypePredicateNode(node) { - return node.kind === 172 /* TypePredicate */; + return node.kind === 174 /* TypePredicate */; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 173 /* TypeReference */; + return node.kind === 175 /* TypeReference */; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 174 /* FunctionType */; + return node.kind === 176 /* FunctionType */; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 175 /* ConstructorType */; + return node.kind === 177 /* ConstructorType */; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 176 /* TypeQuery */; + return node.kind === 178 /* TypeQuery */; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 177 /* TypeLiteral */; + return node.kind === 179 /* TypeLiteral */; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 178 /* ArrayType */; + return node.kind === 180 /* ArrayType */; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 179 /* TupleType */; + return node.kind === 181 /* TupleType */; } ts.isTupleTypeNode = isTupleTypeNode; function isNamedTupleMember(node) { - return node.kind === 192 /* NamedTupleMember */; + return node.kind === 194 /* NamedTupleMember */; } ts.isNamedTupleMember = isNamedTupleMember; function isOptionalTypeNode(node) { - return node.kind === 180 /* OptionalType */; + return node.kind === 182 /* OptionalType */; } ts.isOptionalTypeNode = isOptionalTypeNode; function isRestTypeNode(node) { - return node.kind === 181 /* RestType */; + return node.kind === 183 /* RestType */; } ts.isRestTypeNode = isRestTypeNode; function isUnionTypeNode(node) { - return node.kind === 182 /* UnionType */; + return node.kind === 184 /* UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 183 /* IntersectionType */; + return node.kind === 185 /* IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 184 /* ConditionalType */; + return node.kind === 186 /* ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 185 /* InferType */; + return node.kind === 187 /* InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 186 /* ParenthesizedType */; + return node.kind === 188 /* ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 187 /* ThisType */; + return node.kind === 189 /* ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 188 /* TypeOperator */; + return node.kind === 190 /* TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 189 /* IndexedAccessType */; + return node.kind === 191 /* IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 190 /* MappedType */; + return node.kind === 192 /* MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 191 /* LiteralType */; + return node.kind === 193 /* LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 195 /* ImportType */; + return node.kind === 197 /* ImportType */; } ts.isImportTypeNode = isImportTypeNode; function isTemplateLiteralTypeSpan(node) { - return node.kind === 194 /* TemplateLiteralTypeSpan */; + return node.kind === 196 /* TemplateLiteralTypeSpan */; } ts.isTemplateLiteralTypeSpan = isTemplateLiteralTypeSpan; function isTemplateLiteralTypeNode(node) { - return node.kind === 193 /* TemplateLiteralType */; + return node.kind === 195 /* TemplateLiteralType */; } ts.isTemplateLiteralTypeNode = isTemplateLiteralTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 196 /* ObjectBindingPattern */; + return node.kind === 198 /* ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 197 /* ArrayBindingPattern */; + return node.kind === 199 /* ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 198 /* BindingElement */; + return node.kind === 200 /* BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 199 /* ArrayLiteralExpression */; + return node.kind === 201 /* ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 200 /* ObjectLiteralExpression */; + return node.kind === 202 /* ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 201 /* PropertyAccessExpression */; + return node.kind === 203 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 202 /* ElementAccessExpression */; + return node.kind === 204 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 203 /* CallExpression */; + return node.kind === 205 /* CallExpression */; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 204 /* NewExpression */; + return node.kind === 206 /* NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 205 /* TaggedTemplateExpression */; + return node.kind === 207 /* TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertionExpression(node) { - return node.kind === 206 /* TypeAssertionExpression */; + return node.kind === 208 /* TypeAssertionExpression */; } ts.isTypeAssertionExpression = isTypeAssertionExpression; function isParenthesizedExpression(node) { - return node.kind === 207 /* ParenthesizedExpression */; + return node.kind === 209 /* ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function isFunctionExpression(node) { - return node.kind === 208 /* FunctionExpression */; + return node.kind === 210 /* FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 209 /* ArrowFunction */; + return node.kind === 211 /* ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 210 /* DeleteExpression */; + return node.kind === 212 /* DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 211 /* TypeOfExpression */; + return node.kind === 213 /* TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 212 /* VoidExpression */; + return node.kind === 214 /* VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 213 /* AwaitExpression */; + return node.kind === 215 /* AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 214 /* PrefixUnaryExpression */; + return node.kind === 216 /* PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 215 /* PostfixUnaryExpression */; + return node.kind === 217 /* PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 216 /* BinaryExpression */; + return node.kind === 218 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 217 /* ConditionalExpression */; + return node.kind === 219 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 218 /* TemplateExpression */; + return node.kind === 220 /* TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 219 /* YieldExpression */; + return node.kind === 221 /* YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 220 /* SpreadElement */; + return node.kind === 222 /* SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 221 /* ClassExpression */; + return node.kind === 223 /* ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 222 /* OmittedExpression */; + return node.kind === 224 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 223 /* ExpressionWithTypeArguments */; + return node.kind === 225 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 224 /* AsExpression */; + return node.kind === 226 /* AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 225 /* NonNullExpression */; + return node.kind === 227 /* NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 226 /* MetaProperty */; + return node.kind === 228 /* MetaProperty */; } ts.isMetaProperty = isMetaProperty; function isSyntheticExpression(node) { - return node.kind === 227 /* SyntheticExpression */; + return node.kind === 229 /* SyntheticExpression */; } ts.isSyntheticExpression = isSyntheticExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 336 /* PartiallyEmittedExpression */; + return node.kind === 344 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isCommaListExpression(node) { - return node.kind === 337 /* CommaListExpression */; + return node.kind === 345 /* CommaListExpression */; } ts.isCommaListExpression = isCommaListExpression; // Misc function isTemplateSpan(node) { - return node.kind === 228 /* TemplateSpan */; + return node.kind === 230 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 229 /* SemicolonClassElement */; + return node.kind === 231 /* SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Elements function isBlock(node) { - return node.kind === 230 /* Block */; + return node.kind === 232 /* Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 232 /* VariableStatement */; + return node.kind === 234 /* VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 231 /* EmptyStatement */; + return node.kind === 233 /* EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 233 /* ExpressionStatement */; + return node.kind === 235 /* ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 234 /* IfStatement */; + return node.kind === 236 /* IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 235 /* DoStatement */; + return node.kind === 237 /* DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 236 /* WhileStatement */; + return node.kind === 238 /* WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 237 /* ForStatement */; + return node.kind === 239 /* ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 238 /* ForInStatement */; + return node.kind === 240 /* ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 239 /* ForOfStatement */; + return node.kind === 241 /* ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 240 /* ContinueStatement */; + return node.kind === 242 /* ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 241 /* BreakStatement */; + return node.kind === 243 /* BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isReturnStatement(node) { - return node.kind === 242 /* ReturnStatement */; + return node.kind === 244 /* ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 243 /* WithStatement */; + return node.kind === 245 /* WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 244 /* SwitchStatement */; + return node.kind === 246 /* SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 245 /* LabeledStatement */; + return node.kind === 247 /* LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 246 /* ThrowStatement */; + return node.kind === 248 /* ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 247 /* TryStatement */; + return node.kind === 249 /* TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 248 /* DebuggerStatement */; + return node.kind === 250 /* DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 249 /* VariableDeclaration */; + return node.kind === 251 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 250 /* VariableDeclarationList */; + return node.kind === 252 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 251 /* FunctionDeclaration */; + return node.kind === 253 /* FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 252 /* ClassDeclaration */; + return node.kind === 254 /* ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 253 /* InterfaceDeclaration */; + return node.kind === 255 /* InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 254 /* TypeAliasDeclaration */; + return node.kind === 256 /* TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 255 /* EnumDeclaration */; + return node.kind === 257 /* EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 256 /* ModuleDeclaration */; + return node.kind === 258 /* ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 257 /* ModuleBlock */; + return node.kind === 259 /* ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 258 /* CaseBlock */; + return node.kind === 260 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 259 /* NamespaceExportDeclaration */; + return node.kind === 261 /* NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 260 /* ImportEqualsDeclaration */; + return node.kind === 262 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 261 /* ImportDeclaration */; + return node.kind === 263 /* ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 262 /* ImportClause */; + return node.kind === 264 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 263 /* NamespaceImport */; + return node.kind === 265 /* NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamespaceExport(node) { - return node.kind === 269 /* NamespaceExport */; + return node.kind === 271 /* NamespaceExport */; } ts.isNamespaceExport = isNamespaceExport; function isNamedImports(node) { - return node.kind === 264 /* NamedImports */; + return node.kind === 266 /* NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 265 /* ImportSpecifier */; + return node.kind === 267 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 266 /* ExportAssignment */; + return node.kind === 268 /* ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 267 /* ExportDeclaration */; + return node.kind === 269 /* ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 268 /* NamedExports */; + return node.kind === 270 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 270 /* ExportSpecifier */; + return node.kind === 272 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 271 /* MissingDeclaration */; + return node.kind === 273 /* MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; function isNotEmittedStatement(node) { - return node.kind === 335 /* NotEmittedStatement */; + return node.kind === 343 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ function isSyntheticReference(node) { - return node.kind === 340 /* SyntheticReferenceExpression */; + return node.kind === 348 /* SyntheticReferenceExpression */; } ts.isSyntheticReference = isSyntheticReference; /* @internal */ function isMergeDeclarationMarker(node) { - return node.kind === 338 /* MergeDeclarationMarker */; + return node.kind === 346 /* MergeDeclarationMarker */; } ts.isMergeDeclarationMarker = isMergeDeclarationMarker; /* @internal */ function isEndOfDeclarationMarker(node) { - return node.kind === 339 /* EndOfDeclarationMarker */; + return node.kind === 347 /* EndOfDeclarationMarker */; } ts.isEndOfDeclarationMarker = isEndOfDeclarationMarker; // Module References function isExternalModuleReference(node) { - return node.kind === 272 /* ExternalModuleReference */; + return node.kind === 274 /* ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 273 /* JsxElement */; + return node.kind === 275 /* JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 274 /* JsxSelfClosingElement */; + return node.kind === 276 /* JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 275 /* JsxOpeningElement */; + return node.kind === 277 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 276 /* JsxClosingElement */; + return node.kind === 278 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 277 /* JsxFragment */; + return node.kind === 279 /* JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 278 /* JsxOpeningFragment */; + return node.kind === 280 /* JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 279 /* JsxClosingFragment */; + return node.kind === 281 /* JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 280 /* JsxAttribute */; + return node.kind === 282 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 281 /* JsxAttributes */; + return node.kind === 283 /* JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 282 /* JsxSpreadAttribute */; + return node.kind === 284 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 283 /* JsxExpression */; + return node.kind === 285 /* JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 284 /* CaseClause */; + return node.kind === 286 /* CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 285 /* DefaultClause */; + return node.kind === 287 /* DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 286 /* HeritageClause */; + return node.kind === 288 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 287 /* CatchClause */; + return node.kind === 289 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 288 /* PropertyAssignment */; + return node.kind === 290 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 289 /* ShorthandPropertyAssignment */; + return node.kind === 291 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 290 /* SpreadAssignment */; + return node.kind === 292 /* SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 291 /* EnumMember */; + return node.kind === 293 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Unparsed // TODO(rbuckton): isUnparsedPrologue function isUnparsedPrepend(node) { - return node.kind === 293 /* UnparsedPrepend */; + return node.kind === 295 /* UnparsedPrepend */; } ts.isUnparsedPrepend = isUnparsedPrepend; // TODO(rbuckton): isUnparsedText @@ -27218,156 +28052,176 @@ var ts; // TODO(rbuckton): isUnparsedSyntheticReference // Top-level nodes function isSourceFile(node) { - return node.kind === 297 /* SourceFile */; + return node.kind === 299 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 298 /* Bundle */; + return node.kind === 300 /* Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 299 /* UnparsedSource */; + return node.kind === 301 /* UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; // TODO(rbuckton): isInputFiles // JSDoc Elements function isJSDocTypeExpression(node) { - return node.kind === 301 /* JSDocTypeExpression */; + return node.kind === 303 /* JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocNameReference(node) { - return node.kind === 302 /* JSDocNameReference */; + return node.kind === 304 /* JSDocNameReference */; } ts.isJSDocNameReference = isJSDocNameReference; + function isJSDocMemberName(node) { + return node.kind === 305 /* JSDocMemberName */; + } + ts.isJSDocMemberName = isJSDocMemberName; + function isJSDocLink(node) { + return node.kind === 318 /* JSDocLink */; + } + ts.isJSDocLink = isJSDocLink; + function isJSDocLinkCode(node) { + return node.kind === 319 /* JSDocLinkCode */; + } + ts.isJSDocLinkCode = isJSDocLinkCode; + function isJSDocLinkPlain(node) { + return node.kind === 320 /* JSDocLinkPlain */; + } + ts.isJSDocLinkPlain = isJSDocLinkPlain; function isJSDocAllType(node) { - return node.kind === 303 /* JSDocAllType */; + return node.kind === 306 /* JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 304 /* JSDocUnknownType */; + return node.kind === 307 /* JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 305 /* JSDocNullableType */; + return node.kind === 308 /* JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 306 /* JSDocNonNullableType */; + return node.kind === 309 /* JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 307 /* JSDocOptionalType */; + return node.kind === 310 /* JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 308 /* JSDocFunctionType */; + return node.kind === 311 /* JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 309 /* JSDocVariadicType */; + return node.kind === 312 /* JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDocNamepathType(node) { - return node.kind === 310 /* JSDocNamepathType */; + return node.kind === 313 /* JSDocNamepathType */; } ts.isJSDocNamepathType = isJSDocNamepathType; function isJSDoc(node) { - return node.kind === 311 /* JSDocComment */; + return node.kind === 314 /* JSDocComment */; } ts.isJSDoc = isJSDoc; function isJSDocTypeLiteral(node) { - return node.kind === 312 /* JSDocTypeLiteral */; + return node.kind === 316 /* JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocSignature(node) { - return node.kind === 313 /* JSDocSignature */; + return node.kind === 317 /* JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; // JSDoc Tags function isJSDocAugmentsTag(node) { - return node.kind === 315 /* JSDocAugmentsTag */; + return node.kind === 322 /* JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocAuthorTag(node) { - return node.kind === 317 /* JSDocAuthorTag */; + return node.kind === 324 /* JSDocAuthorTag */; } ts.isJSDocAuthorTag = isJSDocAuthorTag; function isJSDocClassTag(node) { - return node.kind === 319 /* JSDocClassTag */; + return node.kind === 326 /* JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocCallbackTag(node) { - return node.kind === 324 /* JSDocCallbackTag */; + return node.kind === 332 /* JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocPublicTag(node) { - return node.kind === 320 /* JSDocPublicTag */; + return node.kind === 327 /* JSDocPublicTag */; } ts.isJSDocPublicTag = isJSDocPublicTag; function isJSDocPrivateTag(node) { - return node.kind === 321 /* JSDocPrivateTag */; + return node.kind === 328 /* JSDocPrivateTag */; } ts.isJSDocPrivateTag = isJSDocPrivateTag; function isJSDocProtectedTag(node) { - return node.kind === 322 /* JSDocProtectedTag */; + return node.kind === 329 /* JSDocProtectedTag */; } ts.isJSDocProtectedTag = isJSDocProtectedTag; function isJSDocReadonlyTag(node) { - return node.kind === 323 /* JSDocReadonlyTag */; + return node.kind === 330 /* JSDocReadonlyTag */; } ts.isJSDocReadonlyTag = isJSDocReadonlyTag; + function isJSDocOverrideTag(node) { + return node.kind === 331 /* JSDocOverrideTag */; + } + ts.isJSDocOverrideTag = isJSDocOverrideTag; function isJSDocDeprecatedTag(node) { - return node.kind === 318 /* JSDocDeprecatedTag */; + return node.kind === 325 /* JSDocDeprecatedTag */; } ts.isJSDocDeprecatedTag = isJSDocDeprecatedTag; function isJSDocSeeTag(node) { - return node.kind === 332 /* JSDocSeeTag */; + return node.kind === 340 /* JSDocSeeTag */; } ts.isJSDocSeeTag = isJSDocSeeTag; function isJSDocEnumTag(node) { - return node.kind === 325 /* JSDocEnumTag */; + return node.kind === 333 /* JSDocEnumTag */; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocParameterTag(node) { - return node.kind === 326 /* JSDocParameterTag */; + return node.kind === 334 /* JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 327 /* JSDocReturnTag */; + return node.kind === 335 /* JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocThisTag(node) { - return node.kind === 328 /* JSDocThisTag */; + return node.kind === 336 /* JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocTypeTag(node) { - return node.kind === 329 /* JSDocTypeTag */; + return node.kind === 337 /* JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 330 /* JSDocTemplateTag */; + return node.kind === 338 /* JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 331 /* JSDocTypedefTag */; + return node.kind === 339 /* JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocUnknownTag(node) { - return node.kind === 314 /* JSDocTag */; + return node.kind === 321 /* JSDocTag */; } ts.isJSDocUnknownTag = isJSDocUnknownTag; function isJSDocPropertyTag(node) { - return node.kind === 333 /* JSDocPropertyTag */; + return node.kind === 341 /* JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocImplementsTag(node) { - return node.kind === 316 /* JSDocImplementsTag */; + return node.kind === 323 /* JSDocImplementsTag */; } ts.isJSDocImplementsTag = isJSDocImplementsTag; // Synthesized list /* @internal */ function isSyntaxList(n) { - return n.kind === 334 /* SyntaxList */; + return n.kind === 342 /* SyntaxList */; } ts.isSyntaxList = isSyntaxList; })(ts || (ts = {})); @@ -27384,7 +28238,7 @@ var ts; return ts.setTextRange(factory.createElementAccessExpression(target, memberName.expression), location); } else { - var expression = ts.setTextRange(ts.isIdentifierOrPrivateIdentifier(memberName) + var expression = ts.setTextRange(ts.isMemberName(memberName) ? factory.createPropertyAccessExpression(target, memberName) : factory.createElementAccessExpression(target, memberName), memberName); ts.getOrCreateEmitNode(expression).flags |= 64 /* NoNestedSourceMaps */; @@ -27566,14 +28420,14 @@ var ts; ts.Debug.failBadSyntaxKind(property.name, "Private identifiers are not allowed in object literals."); } switch (property.kind) { - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return createExpressionForAccessorDeclaration(factory, node.properties, property, receiver, !!node.multiLine); - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: return createExpressionForPropertyAssignment(factory, property, receiver); - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(factory, property, receiver); - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: return createExpressionForMethodDeclaration(factory, property, receiver); } } @@ -27626,21 +28480,21 @@ var ts; } ts.startsWithUseStrict = startsWithUseStrict; function isCommaSequence(node) { - return node.kind === 216 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || - node.kind === 337 /* CommaListExpression */; + return node.kind === 218 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || + node.kind === 345 /* CommaListExpression */; } ts.isCommaSequence = isCommaSequence; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 15 /* All */; } switch (node.kind) { - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return (kinds & 1 /* Parentheses */) !== 0; - case 206 /* TypeAssertionExpression */: - case 224 /* AsExpression */: + case 208 /* TypeAssertionExpression */: + case 226 /* AsExpression */: return (kinds & 2 /* TypeAssertions */) !== 0; - case 225 /* NonNullExpression */: + case 227 /* NonNullExpression */: return (kinds & 4 /* NonNullAssertions */) !== 0; - case 336 /* PartiallyEmittedExpression */: + case 344 /* PartiallyEmittedExpression */: return (kinds & 8 /* PartiallyEmittedExpressions */) !== 0; } return false; @@ -27761,10 +28615,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : factory.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 261 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 263 /* ImportDeclaration */ && node.importClause) { return factory.getGeneratedNameForNode(node); } - if (node.kind === 267 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 269 /* ExportDeclaration */ && node.moduleSpecifier) { return factory.getGeneratedNameForNode(node); } return undefined; @@ -27883,7 +28737,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -27895,11 +28749,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 290 /* SpreadAssignment */: + case 292 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -27931,12 +28785,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 160 /* Parameter */: - case 198 /* BindingElement */: + case 162 /* Parameter */: + case 200 /* BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 220 /* SpreadElement */: - case 290 /* SpreadAssignment */: + case 222 /* SpreadElement */: + case 292 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -27954,7 +28808,7 @@ var ts; ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement; function tryGetPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 198 /* BindingElement */: + case 200 /* BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -27969,7 +28823,7 @@ var ts; : propertyName; } break; - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -27984,7 +28838,7 @@ var ts; : propertyName; } break; - case 290 /* SpreadAssignment */: + case 292 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` if (bindingElement.name && ts.isPrivateIdentifier(bindingElement.name)) { return ts.Debug.failBadSyntaxKind(bindingElement.name); @@ -28007,13 +28861,13 @@ var ts; */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 196 /* ObjectBindingPattern */: - case 197 /* ArrayBindingPattern */: - case 199 /* ArrayLiteralExpression */: + case 198 /* ObjectBindingPattern */: + case 199 /* ArrayBindingPattern */: + case 201 /* ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -28034,46 +28888,294 @@ var ts; ts.getJSDocTypeAliasName = getJSDocTypeAliasName; function canHaveModifiers(node) { var kind = node.kind; - return kind === 160 /* Parameter */ - || kind === 162 /* PropertySignature */ - || kind === 163 /* PropertyDeclaration */ - || kind === 164 /* MethodSignature */ - || kind === 165 /* MethodDeclaration */ - || kind === 166 /* Constructor */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */ - || kind === 171 /* IndexSignature */ - || kind === 208 /* FunctionExpression */ - || kind === 209 /* ArrowFunction */ - || kind === 221 /* ClassExpression */ - || kind === 232 /* VariableStatement */ - || kind === 251 /* FunctionDeclaration */ - || kind === 252 /* ClassDeclaration */ - || kind === 253 /* InterfaceDeclaration */ - || kind === 254 /* TypeAliasDeclaration */ - || kind === 255 /* EnumDeclaration */ - || kind === 256 /* ModuleDeclaration */ - || kind === 260 /* ImportEqualsDeclaration */ - || kind === 261 /* ImportDeclaration */ - || kind === 266 /* ExportAssignment */ - || kind === 267 /* ExportDeclaration */; + return kind === 162 /* Parameter */ + || kind === 164 /* PropertySignature */ + || kind === 165 /* PropertyDeclaration */ + || kind === 166 /* MethodSignature */ + || kind === 167 /* MethodDeclaration */ + || kind === 168 /* Constructor */ + || kind === 169 /* GetAccessor */ + || kind === 170 /* SetAccessor */ + || kind === 173 /* IndexSignature */ + || kind === 210 /* FunctionExpression */ + || kind === 211 /* ArrowFunction */ + || kind === 223 /* ClassExpression */ + || kind === 234 /* VariableStatement */ + || kind === 253 /* FunctionDeclaration */ + || kind === 254 /* ClassDeclaration */ + || kind === 255 /* InterfaceDeclaration */ + || kind === 256 /* TypeAliasDeclaration */ + || kind === 257 /* EnumDeclaration */ + || kind === 258 /* ModuleDeclaration */ + || kind === 262 /* ImportEqualsDeclaration */ + || kind === 263 /* ImportDeclaration */ + || kind === 268 /* ExportAssignment */ + || kind === 269 /* ExportDeclaration */; } ts.canHaveModifiers = canHaveModifiers; - /* @internal */ - function isExportModifier(node) { - return node.kind === 92 /* ExportKeyword */; - } - ts.isExportModifier = isExportModifier; - /* @internal */ - function isAsyncModifier(node) { - return node.kind === 129 /* AsyncKeyword */; - } - ts.isAsyncModifier = isAsyncModifier; - /* @internal */ - function isStaticModifier(node) { - return node.kind === 123 /* StaticKeyword */; + ts.isTypeNodeOrTypeParameterDeclaration = ts.or(ts.isTypeNode, ts.isTypeParameterDeclaration); + ts.isQuestionOrExclamationToken = ts.or(ts.isQuestionToken, ts.isExclamationToken); + ts.isIdentifierOrThisTypeNode = ts.or(ts.isIdentifier, ts.isThisTypeNode); + ts.isReadonlyKeywordOrPlusOrMinusToken = ts.or(ts.isReadonlyKeyword, ts.isPlusToken, ts.isMinusToken); + ts.isQuestionOrPlusOrMinusToken = ts.or(ts.isQuestionToken, ts.isPlusToken, ts.isMinusToken); + 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 */ + || ts.isLiteralExpression(node) + || ts.isPrefixUnaryExpression(node); + } + ts.isLiteralTypeLikeExpression = isLiteralTypeLikeExpression; + function isExponentiationOperator(kind) { + return kind === 42 /* AsteriskAsteriskToken */; + } + function isMultiplicativeOperator(kind) { + return kind === 41 /* AsteriskToken */ + || kind === 43 /* SlashToken */ + || kind === 44 /* PercentToken */; + } + function isMultiplicativeOperatorOrHigher(kind) { + return isExponentiationOperator(kind) + || isMultiplicativeOperator(kind); + } + function isAdditiveOperator(kind) { + return kind === 39 /* PlusToken */ + || kind === 40 /* MinusToken */; + } + function isAdditiveOperatorOrHigher(kind) { + return isAdditiveOperator(kind) + || isMultiplicativeOperatorOrHigher(kind); + } + function isShiftOperator(kind) { + return kind === 47 /* LessThanLessThanToken */ + || kind === 48 /* GreaterThanGreaterThanToken */ + || kind === 49 /* 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 */; + } + function isRelationalOperatorOrHigher(kind) { + return isRelationalOperator(kind) + || isShiftOperatorOrHigher(kind); + } + function isEqualityOperator(kind) { + return kind === 34 /* EqualsEqualsToken */ + || kind === 36 /* EqualsEqualsEqualsToken */ + || kind === 35 /* ExclamationEqualsToken */ + || kind === 37 /* ExclamationEqualsEqualsToken */; + } + function isEqualityOperatorOrHigher(kind) { + return isEqualityOperator(kind) + || isRelationalOperatorOrHigher(kind); + } + function isBitwiseOperator(kind) { + return kind === 50 /* AmpersandToken */ + || kind === 51 /* BarToken */ + || kind === 52 /* CaretToken */; + } + function isBitwiseOperatorOrHigher(kind) { + return isBitwiseOperator(kind) + || isEqualityOperatorOrHigher(kind); + } + // NOTE: The version in utilities includes ExclamationToken, which is not a binary operator. + function isLogicalOperator(kind) { + return kind === 55 /* AmpersandAmpersandToken */ + || kind === 56 /* BarBarToken */; + } + function isLogicalOperatorOrHigher(kind) { + return isLogicalOperator(kind) + || isBitwiseOperatorOrHigher(kind); + } + function isAssignmentOperatorOrHigher(kind) { + return kind === 60 /* QuestionQuestionToken */ + || isLogicalOperatorOrHigher(kind) + || ts.isAssignmentOperator(kind); + } + function isBinaryOperator(kind) { + return isAssignmentOperatorOrHigher(kind) + || kind === 27 /* CommaToken */; + } + function isBinaryOperatorToken(node) { + return isBinaryOperator(node.kind); + } + ts.isBinaryOperatorToken = isBinaryOperatorToken; + var BinaryExpressionState; + (function (BinaryExpressionState) { + /** + * Handles walking into a `BinaryExpression`. + * @param machine State machine handler functions + * @param frame The current frame + * @returns The new frame + */ + function enter(machine, stackIndex, stateStack, nodeStack, userStateStack, _resultHolder, outerState) { + var prevUserState = stackIndex > 0 ? userStateStack[stackIndex - 1] : undefined; + ts.Debug.assertEqual(stateStack[stackIndex], enter); + userStateStack[stackIndex] = machine.onEnter(nodeStack[stackIndex], prevUserState, outerState); + stateStack[stackIndex] = nextState(machine, enter); + return stackIndex; + } + BinaryExpressionState.enter = enter; + /** + * Handles walking the `left` side of a `BinaryExpression`. + * @param machine State machine handler functions + * @param frame The current frame + * @returns The new frame + */ + function left(machine, stackIndex, stateStack, nodeStack, userStateStack, _resultHolder, _outerState) { + ts.Debug.assertEqual(stateStack[stackIndex], left); + ts.Debug.assertIsDefined(machine.onLeft); + stateStack[stackIndex] = nextState(machine, left); + var nextNode = machine.onLeft(nodeStack[stackIndex].left, userStateStack[stackIndex], nodeStack[stackIndex]); + if (nextNode) { + checkCircularity(stackIndex, nodeStack, nextNode); + return pushStack(stackIndex, stateStack, nodeStack, userStateStack, nextNode); + } + return stackIndex; + } + BinaryExpressionState.left = left; + /** + * Handles walking the `operatorToken` of a `BinaryExpression`. + * @param machine State machine handler functions + * @param frame The current frame + * @returns The new frame + */ + function operator(machine, stackIndex, stateStack, nodeStack, userStateStack, _resultHolder, _outerState) { + ts.Debug.assertEqual(stateStack[stackIndex], operator); + ts.Debug.assertIsDefined(machine.onOperator); + stateStack[stackIndex] = nextState(machine, operator); + machine.onOperator(nodeStack[stackIndex].operatorToken, userStateStack[stackIndex], nodeStack[stackIndex]); + return stackIndex; + } + BinaryExpressionState.operator = operator; + /** + * Handles walking the `right` side of a `BinaryExpression`. + * @param machine State machine handler functions + * @param frame The current frame + * @returns The new frame + */ + function right(machine, stackIndex, stateStack, nodeStack, userStateStack, _resultHolder, _outerState) { + ts.Debug.assertEqual(stateStack[stackIndex], right); + ts.Debug.assertIsDefined(machine.onRight); + stateStack[stackIndex] = nextState(machine, right); + var nextNode = machine.onRight(nodeStack[stackIndex].right, userStateStack[stackIndex], nodeStack[stackIndex]); + if (nextNode) { + checkCircularity(stackIndex, nodeStack, nextNode); + return pushStack(stackIndex, stateStack, nodeStack, userStateStack, nextNode); + } + return stackIndex; + } + BinaryExpressionState.right = right; + /** + * Handles walking out of a `BinaryExpression`. + * @param machine State machine handler functions + * @param frame The current frame + * @returns The new frame + */ + function exit(machine, stackIndex, stateStack, nodeStack, userStateStack, resultHolder, _outerState) { + ts.Debug.assertEqual(stateStack[stackIndex], exit); + stateStack[stackIndex] = nextState(machine, exit); + var result = machine.onExit(nodeStack[stackIndex], userStateStack[stackIndex]); + if (stackIndex > 0) { + stackIndex--; + if (machine.foldState) { + var side = stateStack[stackIndex] === exit ? "right" : "left"; + userStateStack[stackIndex] = machine.foldState(userStateStack[stackIndex], result, side); + } + } + else { + resultHolder.value = result; + } + return stackIndex; + } + BinaryExpressionState.exit = exit; + /** + * Handles a frame that is already done. + * @returns The `done` state. + */ + function done(_machine, stackIndex, stateStack, _nodeStack, _userStateStack, _resultHolder, _outerState) { + ts.Debug.assertEqual(stateStack[stackIndex], done); + return stackIndex; + } + BinaryExpressionState.done = done; + function nextState(machine, currentState) { + switch (currentState) { + case enter: + if (machine.onLeft) + return left; + // falls through + case left: + if (machine.onOperator) + return operator; + // falls through + case operator: + if (machine.onRight) + return right; + // falls through + case right: return exit; + case exit: return done; + case done: return done; + default: ts.Debug.fail("Invalid state"); + } + } + BinaryExpressionState.nextState = nextState; + function pushStack(stackIndex, stateStack, nodeStack, userStateStack, node) { + stackIndex++; + stateStack[stackIndex] = enter; + nodeStack[stackIndex] = node; + userStateStack[stackIndex] = undefined; + return stackIndex; + } + function checkCircularity(stackIndex, nodeStack, node) { + if (ts.Debug.shouldAssert(2 /* Aggressive */)) { + while (stackIndex >= 0) { + ts.Debug.assert(nodeStack[stackIndex] !== node, "Circular traversal detected."); + stackIndex--; + } + } + } + })(BinaryExpressionState || (BinaryExpressionState = {})); + /** + * Holds state machine handler functions + */ + var BinaryExpressionStateMachine = /** @class */ (function () { + function BinaryExpressionStateMachine(onEnter, onLeft, onOperator, onRight, onExit, foldState) { + this.onEnter = onEnter; + this.onLeft = onLeft; + this.onOperator = onOperator; + this.onRight = onRight; + this.onExit = onExit; + this.foldState = foldState; + } + return BinaryExpressionStateMachine; + }()); + function createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, foldState) { + var machine = new BinaryExpressionStateMachine(onEnter, onLeft, onOperator, onRight, onExit, foldState); + return trampoline; + function trampoline(node, outerState) { + var resultHolder = { value: undefined }; + var stateStack = [BinaryExpressionState.enter]; + var nodeStack = [node]; + var userStateStack = [undefined]; + var stackIndex = 0; + while (stateStack[stackIndex] !== BinaryExpressionState.done) { + stackIndex = stateStack[stackIndex](machine, stackIndex, stateStack, nodeStack, userStateStack, resultHolder, outerState); + } + ts.Debug.assertEqual(stackIndex, 0); + return resultHolder.value; + } } - ts.isStaticModifier = isStaticModifier; + ts.createBinaryExpressionTrampoline = createBinaryExpressionTrampoline; })(ts || (ts = {})); var ts; (function (ts) { @@ -28155,19 +29257,19 @@ 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 <= 156 /* LastToken */) { + if (!node || node.kind <= 158 /* LastToken */) { return; } switch (node.kind) { - case 157 /* QualifiedName */: + case 159 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 159 /* TypeParameter */: + case 161 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -28175,9 +29277,9 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 290 /* SpreadAssignment */: + case 292 /* SpreadAssignment */: return visitNode(cbNode, node.expression); - case 160 /* Parameter */: + case 162 /* Parameter */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -28185,7 +29287,7 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -28193,51 +29295,51 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 162 /* PropertySignature */: + case 164 /* PropertySignature */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.initializer); - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 198 /* BindingElement */: + case 200 /* BindingElement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 173 /* 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 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: - case 209 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 210 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 211 /* ArrowFunction */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -28249,374 +29351,395 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 173 /* TypeReference */: + case 175 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 172 /* TypePredicate */: + case 174 /* TypePredicate */: return visitNode(cbNode, node.assertsModifier) || visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 176 /* TypeQuery */: + case 178 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 177 /* TypeLiteral */: + case 179 /* TypeLiteral */: return visitNodes(cbNode, cbNodes, node.members); - case 178 /* ArrayType */: + case 180 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 179 /* TupleType */: + case 181 /* TupleType */: return visitNodes(cbNode, cbNodes, node.elements); - case 182 /* UnionType */: - case 183 /* IntersectionType */: + case 184 /* UnionType */: + case 185 /* IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 184 /* ConditionalType */: + case 186 /* ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 185 /* InferType */: + case 187 /* InferType */: return visitNode(cbNode, node.typeParameter); - case 195 /* ImportType */: + case 197 /* ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 186 /* ParenthesizedType */: - case 188 /* TypeOperator */: + case 188 /* ParenthesizedType */: + case 190 /* TypeOperator */: return visitNode(cbNode, node.type); - case 189 /* IndexedAccessType */: + case 191 /* IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 190 /* MappedType */: + case 192 /* MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.nameType) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 191 /* LiteralType */: + case 193 /* LiteralType */: return visitNode(cbNode, node.literal); - case 192 /* NamedTupleMember */: + case 194 /* NamedTupleMember */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 196 /* ObjectBindingPattern */: - case 197 /* ArrayBindingPattern */: + case 198 /* ObjectBindingPattern */: + case 199 /* ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.name); - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.argumentExpression); - case 203 /* CallExpression */: - case 204 /* NewExpression */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 206 /* TypeAssertionExpression */: + case 208 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 210 /* DeleteExpression */: + case 212 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 211 /* TypeOfExpression */: + case 213 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 212 /* VoidExpression */: + case 214 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 213 /* AwaitExpression */: + case 215 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 224 /* AsExpression */: + case 226 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 225 /* NonNullExpression */: + case 227 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 226 /* MetaProperty */: + case 228 /* MetaProperty */: return visitNode(cbNode, node.name); - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 220 /* SpreadElement */: + case 222 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 230 /* Block */: - case 257 /* ModuleBlock */: + case 232 /* Block */: + case 259 /* ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 297 /* SourceFile */: + case 299 /* SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 250 /* VariableDeclarationList */: + case 252 /* VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 234 /* IfStatement */: + case 236 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 235 /* DoStatement */: + case 237 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 236 /* WhileStatement */: + case 238 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 240 /* ContinueStatement */: - case 241 /* BreakStatement */: + case 242 /* ContinueStatement */: + case 243 /* BreakStatement */: return visitNode(cbNode, node.label); - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 243 /* WithStatement */: + case 245 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 258 /* CaseBlock */: + case 260 /* CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 284 /* CaseClause */: + case 286 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 285 /* DefaultClause */: + case 287 /* DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 246 /* ThrowStatement */: + case 248 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 247 /* TryStatement */: + case 249 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 161 /* Decorator */: + case 163 /* Decorator */: return visitNode(cbNode, node.expression); - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: 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 253 /* InterfaceDeclaration */: + case 255 /* 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 254 /* TypeAliasDeclaration */: + case 256 /* 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 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 291 /* EnumMember */: + case 293 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 262 /* ImportClause */: + case 264 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 259 /* NamespaceExportDeclaration */: + case 261 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 269 /* NamespaceExport */: + case 271 /* NamespaceExport */: return visitNode(cbNode, node.name); - case 264 /* NamedImports */: - case 268 /* NamedExports */: + case 266 /* NamedImports */: + case 270 /* NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 265 /* ImportSpecifier */: - case 270 /* ExportSpecifier */: + case 267 /* ImportSpecifier */: + case 272 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 218 /* TemplateExpression */: + case 220 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 228 /* TemplateSpan */: + case 230 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 193 /* TemplateLiteralType */: + case 195 /* TemplateLiteralType */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 194 /* TemplateLiteralTypeSpan */: + case 196 /* TemplateLiteralTypeSpan */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.literal); - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 286 /* HeritageClause */: + case 288 /* HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 272 /* ExternalModuleReference */: + case 274 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 271 /* MissingDeclaration */: + case 273 /* MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 337 /* CommaListExpression */: + case 345 /* CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 273 /* JsxElement */: + case 275 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 277 /* JsxFragment */: + case 279 /* JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 274 /* JsxSelfClosingElement */: - case 275 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 281 /* JsxAttributes */: + case 283 /* JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 280 /* JsxAttribute */: + case 282 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 282 /* JsxSpreadAttribute */: + case 284 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 276 /* JsxClosingElement */: + case 278 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 180 /* OptionalType */: - case 181 /* RestType */: - case 301 /* JSDocTypeExpression */: - case 306 /* JSDocNonNullableType */: - case 305 /* JSDocNullableType */: - case 307 /* JSDocOptionalType */: - case 309 /* JSDocVariadicType */: + case 182 /* OptionalType */: + case 183 /* RestType */: + case 303 /* JSDocTypeExpression */: + case 309 /* JSDocNonNullableType */: + case 308 /* JSDocNullableType */: + case 310 /* JSDocOptionalType */: + case 312 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 308 /* JSDocFunctionType */: + case 311 /* JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 311 /* JSDocComment */: - return visitNodes(cbNode, cbNodes, node.tags); - case 332 /* JSDocSeeTag */: + case 314 /* JSDocComment */: + return (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) + || visitNodes(cbNode, cbNodes, node.tags); + case 340 /* JSDocSeeTag */: return visitNode(cbNode, node.tagName) || - visitNode(cbNode, node.name); - case 302 /* JSDocNameReference */: + visitNode(cbNode, node.name) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 304 /* JSDocNameReference */: return visitNode(cbNode, node.name); - case 326 /* JSDocParameterTag */: - case 333 /* JSDocPropertyTag */: + case 305 /* JSDocMemberName */: + return visitNode(cbNode, node.left) || + visitNode(cbNode, node.right); + case 334 /* JSDocParameterTag */: + case 341 /* JSDocPropertyTag */: return visitNode(cbNode, node.tagName) || (node.isNameFirst ? visitNode(cbNode, node.name) || - visitNode(cbNode, node.typeExpression) + visitNode(cbNode, node.typeExpression) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) : visitNode(cbNode, node.typeExpression) || - visitNode(cbNode, node.name)); - case 317 /* JSDocAuthorTag */: - return visitNode(cbNode, node.tagName); - case 316 /* JSDocImplementsTag */: + visitNode(cbNode, node.name)) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 324 /* JSDocAuthorTag */: + return visitNode(cbNode, node.tagName) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 323 /* JSDocImplementsTag */: return visitNode(cbNode, node.tagName) || - visitNode(cbNode, node.class); - case 315 /* JSDocAugmentsTag */: + visitNode(cbNode, node.class) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 322 /* JSDocAugmentsTag */: return visitNode(cbNode, node.tagName) || - visitNode(cbNode, node.class); - case 330 /* JSDocTemplateTag */: + visitNode(cbNode, node.class) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 338 /* JSDocTemplateTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.constraint) || - visitNodes(cbNode, cbNodes, node.typeParameters); - case 331 /* JSDocTypedefTag */: + visitNodes(cbNode, cbNodes, node.typeParameters) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 339 /* JSDocTypedefTag */: return visitNode(cbNode, node.tagName) || (node.typeExpression && - node.typeExpression.kind === 301 /* JSDocTypeExpression */ + node.typeExpression.kind === 303 /* JSDocTypeExpression */ ? visitNode(cbNode, node.typeExpression) || - visitNode(cbNode, node.fullName) + visitNode(cbNode, node.fullName) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) : visitNode(cbNode, node.fullName) || - visitNode(cbNode, node.typeExpression)); - case 324 /* JSDocCallbackTag */: + visitNode(cbNode, node.typeExpression)) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 332 /* JSDocCallbackTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.fullName) || - visitNode(cbNode, node.typeExpression); - case 327 /* JSDocReturnTag */: - case 329 /* JSDocTypeTag */: - case 328 /* JSDocThisTag */: - case 325 /* JSDocEnumTag */: + visitNode(cbNode, node.typeExpression) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 335 /* JSDocReturnTag */: + case 337 /* JSDocTypeTag */: + case 336 /* JSDocThisTag */: + case 333 /* JSDocEnumTag */: return visitNode(cbNode, node.tagName) || - visitNode(cbNode, node.typeExpression); - case 313 /* JSDocSignature */: + visitNode(cbNode, node.typeExpression) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 317 /* JSDocSignature */: return ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 312 /* JSDocTypeLiteral */: + case 318 /* JSDocLink */: + case 319 /* JSDocLinkCode */: + case 320 /* JSDocLinkPlain */: + return visitNode(cbNode, node.name); + case 316 /* JSDocTypeLiteral */: return ts.forEach(node.jsDocPropertyTags, cbNode); - case 314 /* JSDocTag */: - case 319 /* JSDocClassTag */: - case 320 /* JSDocPublicTag */: - case 321 /* JSDocPrivateTag */: - case 322 /* JSDocProtectedTag */: - case 323 /* JSDocReadonlyTag */: - return visitNode(cbNode, node.tagName); - case 336 /* PartiallyEmittedExpression */: + case 321 /* JSDocTag */: + case 326 /* JSDocClassTag */: + case 327 /* JSDocPublicTag */: + case 328 /* JSDocPrivateTag */: + case 329 /* JSDocProtectedTag */: + case 330 /* JSDocReadonlyTag */: + case 325 /* JSDocDeprecatedTag */: + return visitNode(cbNode, node.tagName) + || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 344 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -28636,62 +29759,58 @@ var ts; * and while doing so, handles traversing the structure without relying on the callstack to encode the tree structure. */ function forEachChildRecursively(rootNode, cbNode, cbNodes) { - var stack = [rootNode]; - while (stack.length) { - var parent = stack.pop(); - var res = visitAllPossibleChildren(parent, gatherPossibleChildren(parent)); - if (res) { - return res; - } - } - return; - function gatherPossibleChildren(node) { - var children = []; - forEachChild(node, addWorkItem, addWorkItem); // By using a stack above and `unshift` here, we emulate a depth-first preorder traversal - return children; - function addWorkItem(n) { - children.unshift(n); - } - } - function visitAllPossibleChildren(parent, children) { - for (var _i = 0, children_5 = children; _i < children_5.length; _i++) { - var child = children_5[_i]; - if (ts.isArray(child)) { - if (cbNodes) { - var res = cbNodes(child, parent); - if (res) { - if (res === "skip") - continue; - return res; - } - } - for (var i = child.length - 1; i >= 0; i--) { - var realChild = child[i]; - var res = cbNode(realChild, parent); - if (res) { - if (res === "skip") - continue; - return res; - } - stack.push(realChild); - } - } - else { - stack.push(child); - var res = cbNode(child, parent); + var queue = gatherPossibleChildren(rootNode); + var parents = []; // tracks parent references for elements in queue + while (parents.length < queue.length) { + parents.push(rootNode); + } + while (queue.length !== 0) { + var current = queue.pop(); + var parent = parents.pop(); + if (ts.isArray(current)) { + if (cbNodes) { + var res = cbNodes(current, parent); if (res) { if (res === "skip") continue; return res; } } + for (var i = current.length - 1; i >= 0; --i) { + queue.push(current[i]); + parents.push(parent); + } + } + else { + var res = cbNode(current, parent); + if (res) { + if (res === "skip") + continue; + return res; + } + if (current.kind >= 159 /* 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]; + queue.push(child); + parents.push(current); + } + } } } } ts.forEachChildRecursively = forEachChildRecursively; + function gatherPossibleChildren(node) { + var children = []; + forEachChild(node, addWorkItem, addWorkItem); // By using a stack above and `unshift` here, we emulate a depth-first preorder traversal + return children; + function addWorkItem(n) { + children.unshift(n); + } + } function createSourceFile(fileName, sourceText, languageVersion, setParentNodes, scriptKind) { if (setParentNodes === void 0) { setParentNodes = false; } - ts.tracing.push("parse" /* Parse */, "createSourceFile", { path: fileName }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* Parse */, "createSourceFile", { path: fileName }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeParse"); var result; ts.perfLogger.logStartParseSourceFile(fileName); @@ -28704,7 +29823,7 @@ var ts; ts.perfLogger.logStopParseSourceFile(); ts.performance.mark("afterParse"); ts.performance.measure("Parse", "beforeParse", "afterParse"); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; } ts.createSourceFile = createSourceFile; @@ -28886,11 +30005,12 @@ var ts; // attached to the EOF token. var parseErrorBeforeNextFinishedNode = false; function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes, scriptKind) { + var _a; if (setParentNodes === void 0) { setParentNodes = false; } scriptKind = ts.ensureScriptKind(fileName, scriptKind); if (scriptKind === 6 /* JSON */) { var result_3 = parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes); - ts.convertToObjectWorker(result_3, result_3.parseDiagnostics, /*returnValue*/ false, /*knownRootOptions*/ undefined, /*jsonConversionNotifier*/ undefined); + 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; result_3.typeReferenceDirectives = ts.emptyArray; result_3.libReferenceDirectives = ts.emptyArray; @@ -28930,35 +30050,54 @@ var ts; endOfFileToken = parseTokenNode(); } else { - var expression = void 0; - switch (token()) { - case 22 /* OpenBracketToken */: - expression = parseArrayLiteralExpression(); - break; - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: - case 103 /* NullKeyword */: - expression = parseTokenNode(); - break; - case 40 /* MinusToken */: - if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 58 /* ColonToken */; })) { - expression = parsePrefixUnaryExpression(); - } - else { - expression = parseObjectLiteralExpression(); - } - break; - case 8 /* NumericLiteral */: - case 10 /* StringLiteral */: - if (lookAhead(function () { return nextToken() !== 58 /* ColonToken */; })) { - expression = parseLiteralNode(); + // 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 */) { + var expression_1 = void 0; + switch (token()) { + case 22 /* OpenBracketToken */: + expression_1 = parseArrayLiteralExpression(); + break; + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: + case 104 /* NullKeyword */: + expression_1 = parseTokenNode(); break; + case 40 /* MinusToken */: + if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 58 /* ColonToken */; })) { + expression_1 = parsePrefixUnaryExpression(); + } + else { + expression_1 = parseObjectLiteralExpression(); + } + break; + case 8 /* NumericLiteral */: + case 10 /* StringLiteral */: + if (lookAhead(function () { return nextToken() !== 58 /* ColonToken */; })) { + expression_1 = parseLiteralNode(); + break; + } + // falls through + default: + expression_1 = parseObjectLiteralExpression(); + break; + } + // Error recovery: collect multiple top-level expressions + if (expressions && ts.isArray(expressions)) { + expressions.push(expression_1); + } + else if (expressions) { + expressions = [expressions, expression_1]; + } + else { + expressions = expression_1; + if (token() !== 1 /* EndOfFileToken */) { + parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token); } - // falls through - default: - expression = parseObjectLiteralExpression(); - break; + } } + var expression = ts.isArray(expressions) ? finishNode(factory.createArrayLiteralExpression(expressions), pos) : ts.Debug.checkDefined(expressions); var statement = factory.createExpressionStatement(expression); finishNode(statement, pos); statements = createNodeArray([statement], pos); @@ -29153,7 +30292,7 @@ var ts; return factory.updateSourceFile(sourceFile, ts.setTextRange(factory.createNodeArray(statements), sourceFile.statements)); function containsPossibleTopLevelAwait(node) { return !(node.flags & 32768 /* AwaitContext */) - && !!(node.transformFlags & 8388608 /* ContainsPossibleTopLevelAwait */); + && !!(node.transformFlags & 16777216 /* ContainsPossibleTopLevelAwait */); } function findNextStatementWithAwait(statements, start) { for (var i = start; i < statements.length; i++) { @@ -29194,7 +30333,7 @@ var ts; ts.setTextRangePosWidth(sourceFile, 0, sourceText.length); setExternalModuleIndicator(sourceFile); // If we parsed this as an external module, it may contain top-level await - if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 8388608 /* ContainsPossibleTopLevelAwait */) { + if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 16777216 /* ContainsPossibleTopLevelAwait */) { sourceFile = reparseTopLevelAwait(sourceFile); } sourceFile.text = sourceText; @@ -29374,6 +30513,9 @@ var ts; function reScanLessThanToken() { return currentToken = scanner.reScanLessThanToken(); } + function reScanHashToken() { + return currentToken = scanner.reScanHashToken(); + } function scanJsxIdentifier() { return currentToken = scanner.scanJsxIdentifier(); } @@ -29428,27 +30570,27 @@ var ts; return speculationHelper(callback, 0 /* TryParse */); } function isBindingIdentifier() { - if (token() === 78 /* Identifier */) { + if (token() === 79 /* Identifier */) { return true; } - return token() > 115 /* LastReservedWord */; + return token() > 116 /* LastReservedWord */; } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token() === 78 /* Identifier */) { + if (token() === 79 /* 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() === 124 /* YieldKeyword */ && inYieldContext()) { + if (token() === 125 /* 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() === 130 /* AwaitKeyword */ && inAwaitContext()) { + if (token() === 131 /* AwaitKeyword */ && inAwaitContext()) { return false; } - return token() > 115 /* LastReservedWord */; + return token() > 116 /* LastReservedWord */; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -29561,11 +30703,11 @@ var ts; parseErrorAtCurrentToken(diagnosticMessage, arg0); } var pos = getNodePos(); - var result = kind === 78 /* Identifier */ ? factory.createIdentifier("", /*typeArguments*/ undefined, /*originalKeywordKind*/ undefined) : + var result = kind === 79 /* 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 === 271 /* MissingDeclaration */ ? factory.createMissingDeclaration() : + kind === 273 /* MissingDeclaration */ ? factory.createMissingDeclaration() : factory.createToken(kind); return finishNode(result, pos); } @@ -29580,8 +30722,8 @@ var ts; // with magic property names like '__proto__'. The 'identifiers' object is used to share a single string instance for // each identifier in order to reduce memory consumption. function createIdentifier(isIdentifier, diagnosticMessage, privateIdentifierDiagnosticMessage) { - identifierCount++; if (isIdentifier) { + identifierCount++; var pos = getNodePos(); // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker var originalKeywordKind = token(); @@ -29589,10 +30731,15 @@ var ts; nextTokenWithoutCheck(); return finishNode(factory.createIdentifier(text, /*typeArguments*/ undefined, originalKeywordKind), pos); } - if (token() === 79 /* PrivateIdentifier */) { + if (token() === 80 /* 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 */; })) { + // 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 isReservedWord = scanner.isReservedWord(); @@ -29600,7 +30747,7 @@ var ts; var defaultMessage = isReservedWord ? ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here : ts.Diagnostics.Identifier_expected; - return createMissingNode(78 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg); + return createMissingNode(79 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg); } function parseBindingIdentifier(privateIdentifierDiagnosticMessage) { return createIdentifier(isBindingIdentifier(), /*diagnosticMessage*/ undefined, privateIdentifierDiagnosticMessage); @@ -29625,7 +30772,7 @@ var ts; if (allowComputedPropertyNames && token() === 22 /* OpenBracketToken */) { return parseComputedPropertyName(); } - if (token() === 79 /* PrivateIdentifier */) { + if (token() === 80 /* PrivateIdentifier */) { return parsePrivateIdentifier(); } return parseIdentifierName(); @@ -29671,24 +30818,24 @@ var ts; } function nextTokenCanFollowModifier() { switch (token()) { - case 84 /* ConstKeyword */: + case 85 /* ConstKeyword */: // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 91 /* EnumKeyword */; - case 92 /* ExportKeyword */: + return nextToken() === 92 /* EnumKeyword */; + case 93 /* ExportKeyword */: nextToken(); - if (token() === 87 /* DefaultKeyword */) { + if (token() === 88 /* DefaultKeyword */) { return lookAhead(nextTokenCanFollowDefaultKeyword); } - if (token() === 149 /* TypeKeyword */) { + if (token() === 150 /* TypeKeyword */) { return lookAhead(nextTokenCanFollowExportModifier); } return canFollowExportModifier(); - case 87 /* DefaultKeyword */: + case 88 /* DefaultKeyword */: return nextTokenCanFollowDefaultKeyword(); - case 123 /* StaticKeyword */: + case 124 /* StaticKeyword */: return nextTokenIsOnSameLineAndCanFollowModifier(); - case 134 /* GetKeyword */: - case 146 /* SetKeyword */: + case 135 /* GetKeyword */: + case 147 /* SetKeyword */: nextToken(); return canFollowModifier(); default: @@ -29697,7 +30844,7 @@ var ts; } function canFollowExportModifier() { return token() !== 41 /* AsteriskToken */ - && token() !== 126 /* AsKeyword */ + && token() !== 127 /* AsKeyword */ && token() !== 18 /* OpenBraceToken */ && canFollowModifier(); } @@ -29717,10 +30864,10 @@ var ts; } function nextTokenCanFollowDefaultKeyword() { nextToken(); - return token() === 83 /* ClassKeyword */ || token() === 97 /* FunctionKeyword */ || - token() === 117 /* InterfaceKeyword */ || - (token() === 125 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || - (token() === 129 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 84 /* ClassKeyword */ || token() === 98 /* FunctionKeyword */ || + token() === 118 /* InterfaceKeyword */ || + (token() === 126 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || + (token() === 130 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -29740,7 +30887,7 @@ var ts; // outer module. We just want to consume and move on. return !(token() === 26 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); case 2 /* SwitchClauses */: - return token() === 81 /* CaseKeyword */ || token() === 87 /* DefaultKeyword */; + return token() === 82 /* CaseKeyword */ || token() === 88 /* DefaultKeyword */; case 4 /* TypeMembers */: return lookAhead(isTypeMemberStart); case 5 /* ClassMembers */: @@ -29826,7 +30973,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 93 /* ExtendsKeyword */ || next === 116 /* ImplementsKeyword */; + return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 94 /* ExtendsKeyword */ || next === 117 /* ImplementsKeyword */; } return true; } @@ -29843,8 +30990,8 @@ var ts; return ts.tokenIsIdentifierOrKeywordOrGreaterThan(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 116 /* ImplementsKeyword */ || - token() === 93 /* ExtendsKeyword */) { + if (token() === 117 /* ImplementsKeyword */ || + token() === 94 /* ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -29874,14 +31021,14 @@ var ts; case 23 /* ImportOrExportSpecifiers */: return token() === 19 /* CloseBraceToken */; case 3 /* SwitchClauseStatements */: - return token() === 19 /* CloseBraceToken */ || token() === 81 /* CaseKeyword */ || token() === 87 /* DefaultKeyword */; + return token() === 19 /* CloseBraceToken */ || token() === 82 /* CaseKeyword */ || token() === 88 /* DefaultKeyword */; case 7 /* HeritageClauseElement */: - return token() === 18 /* OpenBraceToken */ || token() === 93 /* ExtendsKeyword */ || token() === 116 /* ImplementsKeyword */; + return token() === 18 /* OpenBraceToken */ || token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; case 8 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); case 19 /* TypeParameters */: // Tokens other than '>' are here for better error recovery - return token() === 31 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 93 /* ExtendsKeyword */ || token() === 116 /* ImplementsKeyword */; + return token() === 31 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; case 11 /* ArgumentExpressions */: // Tokens other than ')' are here for better error recovery return token() === 21 /* CloseParenToken */ || token() === 26 /* SemicolonToken */; @@ -29947,8 +31094,7 @@ var ts; var listPos = getNodePos(); while (!isListTerminator(kind)) { if (isListElement(kind, /*inErrorRecovery*/ false)) { - var element = parseListElement(kind, parseElement); - list.push(element); + list.push(parseListElement(kind, parseElement)); continue; } if (abortParsingListOrMoveToNextToken(kind)) { @@ -30098,20 +31244,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 166 /* Constructor */: - case 171 /* IndexSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 163 /* PropertyDeclaration */: - case 229 /* SemicolonClassElement */: + case 168 /* Constructor */: + case 173 /* IndexSignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 231 /* SemicolonClassElement */: return true; - case 165 /* MethodDeclaration */: + case 167 /* 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 === 78 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 132 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 79 /* Identifier */ && + methodDeclaration.name.originalKeywordKind === 133 /* ConstructorKeyword */; return !nameIsConstructor; } } @@ -30120,8 +31266,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 284 /* CaseClause */: - case 285 /* DefaultClause */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: return true; } } @@ -30130,58 +31276,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 232 /* VariableStatement */: - case 230 /* Block */: - case 234 /* IfStatement */: - case 233 /* ExpressionStatement */: - case 246 /* ThrowStatement */: - case 242 /* ReturnStatement */: - case 244 /* SwitchStatement */: - case 241 /* BreakStatement */: - case 240 /* ContinueStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 237 /* ForStatement */: - case 236 /* WhileStatement */: - case 243 /* WithStatement */: - case 231 /* EmptyStatement */: - case 247 /* TryStatement */: - case 245 /* LabeledStatement */: - case 235 /* DoStatement */: - case 248 /* DebuggerStatement */: - case 261 /* ImportDeclaration */: - case 260 /* ImportEqualsDeclaration */: - case 267 /* ExportDeclaration */: - case 266 /* ExportAssignment */: - case 256 /* ModuleDeclaration */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 253 /* FunctionDeclaration */: + case 234 /* VariableStatement */: + case 232 /* Block */: + case 236 /* IfStatement */: + case 235 /* ExpressionStatement */: + case 248 /* ThrowStatement */: + case 244 /* ReturnStatement */: + case 246 /* SwitchStatement */: + case 243 /* BreakStatement */: + case 242 /* ContinueStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 239 /* ForStatement */: + case 238 /* WhileStatement */: + case 245 /* WithStatement */: + case 233 /* EmptyStatement */: + case 249 /* TryStatement */: + case 247 /* LabeledStatement */: + case 237 /* DoStatement */: + case 250 /* DebuggerStatement */: + case 263 /* ImportDeclaration */: + case 262 /* ImportEqualsDeclaration */: + case 269 /* ExportDeclaration */: + case 268 /* ExportAssignment */: + case 258 /* ModuleDeclaration */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 257 /* EnumDeclaration */: + case 256 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 291 /* EnumMember */; + return node.kind === 293 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 170 /* ConstructSignature */: - case 164 /* MethodSignature */: - case 171 /* IndexSignature */: - case 162 /* PropertySignature */: - case 169 /* CallSignature */: + case 172 /* ConstructSignature */: + case 166 /* MethodSignature */: + case 173 /* IndexSignature */: + case 164 /* PropertySignature */: + case 171 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 249 /* VariableDeclaration */) { + if (node.kind !== 251 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -30202,7 +31348,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 160 /* Parameter */) { + if (node.kind !== 162 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -30369,12 +31515,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(78 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } } - if (token() === 79 /* PrivateIdentifier */) { + if (token() === 80 /* PrivateIdentifier */) { var node = parsePrivateIdentifier(); - return allowPrivateIdentifiers ? node : createMissingNode(78 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return allowPrivateIdentifiers ? node : createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } @@ -30483,14 +31629,14 @@ var ts; // If true, we should abort parsing an error function. function typeHasArrowFunctionBlockingParseError(node) { switch (node.kind) { - case 173 /* TypeReference */: + case 175 /* TypeReference */: return ts.nodeIsMissing(node.typeName); - case 174 /* FunctionType */: - case 175 /* ConstructorType */: { + case 176 /* FunctionType */: + case 177 /* ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 186 /* ParenthesizedType */: + case 188 /* ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -30532,7 +31678,7 @@ var ts; token() === 19 /* CloseBraceToken */ || token() === 21 /* CloseParenToken */ || token() === 31 /* GreaterThanToken */ || - token() === 62 /* EqualsToken */ || + token() === 63 /* EqualsToken */ || token() === 51 /* BarToken */) { return finishNode(factory.createJSDocUnknownType(), pos); } @@ -30554,7 +31700,7 @@ var ts; function parseJSDocParameter() { var pos = getNodePos(); var name; - if (token() === 107 /* ThisKeyword */ || token() === 102 /* NewKeyword */) { + if (token() === 108 /* ThisKeyword */ || token() === 103 /* NewKeyword */) { name = parseIdentifierName(); parseExpected(58 /* ColonToken */); } @@ -30570,7 +31716,7 @@ var ts; function parseJSDocType() { scanner.setInJSDocType(true); var pos = getNodePos(); - if (parseOptional(139 /* ModuleKeyword */)) { + if (parseOptional(140 /* 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) { @@ -30593,7 +31739,7 @@ var ts; if (hasDotDotDot) { type = finishNode(factory.createJSDocVariadicType(type), pos); } - if (token() === 62 /* EqualsToken */) { + if (token() === 63 /* EqualsToken */) { nextToken(); return finishNode(factory.createJSDocOptionalType(type), pos); } @@ -30601,7 +31747,7 @@ var ts; } function parseTypeQuery() { var pos = getNodePos(); - parseExpected(111 /* TypeOfKeyword */); + parseExpected(112 /* TypeOfKeyword */); return finishNode(factory.createTypeQueryNode(parseEntityName(/*allowReservedWords*/ true)), pos); } function parseTypeParameter() { @@ -30609,7 +31755,7 @@ var ts; var name = parseIdentifier(); var constraint; var expression; - if (parseOptional(93 /* ExtendsKeyword */)) { + if (parseOptional(94 /* 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 @@ -30628,7 +31774,7 @@ var ts; expression = parseUnaryExpressionOrHigher(); } } - var defaultType = parseOptional(62 /* EqualsToken */) ? parseType() : undefined; + var defaultType = parseOptional(63 /* EqualsToken */) ? parseType() : undefined; var node = factory.createTypeParameterDeclaration(name, constraint, defaultType); node.expression = expression; return finishNode(node, pos); @@ -30671,19 +31817,21 @@ var ts; function parseParameterWorker(inOuterAwaitContext) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - if (token() === 107 /* ThisKeyword */) { - var node_1 = factory.createParameterDeclaration( - /*decorators*/ undefined, + // 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 node_1 = factory.createParameterDeclaration(decorators, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, createIdentifier(/*isIdentifier*/ true), /*questionToken*/ undefined, parseTypeAnnotation(), /*initializer*/ undefined); + if (decorators) { + parseErrorAtRange(decorators[0], ts.Diagnostics.Decorators_may_not_be_applied_to_this_parameters); + } return withJSDoc(finishNode(node_1, pos), hasJSDoc); } - // 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(); var savedTopLevel = topLevel; topLevel = false; var modifiers = parseModifiers(); @@ -30770,14 +31918,14 @@ var ts; function parseSignatureMember(kind) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - if (kind === 170 /* ConstructSignature */) { - parseExpected(102 /* NewKeyword */); + if (kind === 172 /* ConstructSignature */) { + parseExpected(103 /* NewKeyword */); } var typeParameters = parseTypeParameters(); var parameters = parseParameters(4 /* Type */); var type = parseReturnType(58 /* ColonToken */, /*isType*/ true); parseTypeMemberSemicolon(); - var node = kind === 169 /* CallSignature */ + var node = kind === 171 /* CallSignature */ ? factory.createCallSignature(typeParameters, parameters, type) : factory.createConstructSignature(typeParameters, parameters, type); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -30860,7 +32008,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() === 62 /* EqualsToken */) + if (token() === 63 /* EqualsToken */) node.initializer = parseInitializer(); } parseTypeMemberSemicolon(); @@ -30868,7 +32016,10 @@ var ts; } function isTypeMemberStart() { // Return true if we have the start of a signature member - if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + if (token() === 20 /* OpenParenToken */ || + token() === 29 /* LessThanToken */ || + token() === 135 /* GetKeyword */ || + token() === 147 /* SetKeyword */) { return true; } var idToken = false; @@ -30900,14 +32051,20 @@ var ts; } function parseTypeMember() { if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { - return parseSignatureMember(169 /* CallSignature */); + return parseSignatureMember(171 /* CallSignature */); } - if (token() === 102 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(170 /* ConstructSignature */); + if (token() === 103 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { + return parseSignatureMember(172 /* ConstructSignature */); } var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiers(); + if (parseContextualModifier(135 /* GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 169 /* GetAccessor */); + } + if (parseContextualModifier(147 /* SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 170 /* SetAccessor */); + } if (isIndexSignature()) { return parseIndexSignatureDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers); } @@ -30947,17 +32104,17 @@ var ts; function isStartOfMappedType() { nextToken(); if (token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { - return nextToken() === 142 /* ReadonlyKeyword */; + return nextToken() === 143 /* ReadonlyKeyword */; } - if (token() === 142 /* ReadonlyKeyword */) { + if (token() === 143 /* ReadonlyKeyword */) { nextToken(); } - return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 100 /* InKeyword */; + return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 101 /* InKeyword */; } function parseMappedTypeParameter() { var pos = getNodePos(); var name = parseIdentifierName(); - parseExpected(100 /* InKeyword */); + parseExpected(101 /* InKeyword */); var type = parseType(); return finishNode(factory.createTypeParameterDeclaration(name, type, /*defaultType*/ undefined), pos); } @@ -30965,15 +32122,15 @@ var ts; var pos = getNodePos(); parseExpected(18 /* OpenBraceToken */); var readonlyToken; - if (token() === 142 /* ReadonlyKeyword */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { + if (token() === 143 /* ReadonlyKeyword */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { readonlyToken = parseTokenNode(); - if (readonlyToken.kind !== 142 /* ReadonlyKeyword */) { - parseExpected(142 /* ReadonlyKeyword */); + if (readonlyToken.kind !== 143 /* ReadonlyKeyword */) { + parseExpected(143 /* ReadonlyKeyword */); } } parseExpected(22 /* OpenBracketToken */); var typeParameter = parseMappedTypeParameter(); - var nameType = parseOptional(126 /* AsKeyword */) ? parseType() : undefined; + var nameType = parseOptional(127 /* AsKeyword */) ? parseType() : undefined; parseExpected(23 /* CloseBracketToken */); var questionToken; if (token() === 57 /* QuestionToken */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { @@ -31037,10 +32194,10 @@ var ts; } function parseModifiersForConstructorType() { var modifiers; - if (token() === 125 /* AbstractKeyword */) { + if (token() === 126 /* AbstractKeyword */) { var pos = getNodePos(); nextToken(); - var modifier = finishNode(factory.createToken(125 /* AbstractKeyword */), pos); + var modifier = finishNode(factory.createToken(126 /* AbstractKeyword */), pos); modifiers = createNodeArray([modifier], pos); } return modifiers; @@ -31049,7 +32206,7 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiersForConstructorType(); - var isConstructorType = parseOptional(102 /* NewKeyword */); + var isConstructorType = parseOptional(103 /* NewKeyword */); var typeParameters = parseTypeParameters(); var parameters = parseParameters(4 /* Type */); var type = parseReturnType(38 /* EqualsGreaterThanToken */, /*isType*/ false); @@ -31069,7 +32226,7 @@ var ts; if (negative) { nextToken(); } - var expression = token() === 109 /* TrueKeyword */ || token() === 94 /* FalseKeyword */ || token() === 103 /* NullKeyword */ ? + var expression = token() === 110 /* TrueKeyword */ || token() === 95 /* FalseKeyword */ || token() === 104 /* NullKeyword */ ? parseTokenNode() : parseLiteralLikeNode(token()); if (negative) { @@ -31079,13 +32236,13 @@ var ts; } function isStartOfTypeOfImportType() { nextToken(); - return token() === 99 /* ImportKeyword */; + return token() === 100 /* ImportKeyword */; } function parseImportType() { sourceFlags |= 1048576 /* PossiblyContainsDynamicImport */; var pos = getNodePos(); - var isTypeOf = parseOptional(111 /* TypeOfKeyword */); - parseExpected(99 /* ImportKeyword */); + var isTypeOf = parseOptional(112 /* TypeOfKeyword */); + parseExpected(100 /* ImportKeyword */); parseExpected(20 /* OpenParenToken */); var type = parseType(); parseExpected(21 /* CloseParenToken */); @@ -31099,19 +32256,19 @@ var ts; } function parseNonArrayType() { switch (token()) { - case 128 /* AnyKeyword */: - case 152 /* UnknownKeyword */: - case 147 /* StringKeyword */: - case 144 /* NumberKeyword */: - case 155 /* BigIntKeyword */: - case 148 /* SymbolKeyword */: - case 131 /* BooleanKeyword */: - case 150 /* UndefinedKeyword */: - case 141 /* NeverKeyword */: - case 145 /* ObjectKeyword */: + case 129 /* AnyKeyword */: + case 153 /* UnknownKeyword */: + case 148 /* StringKeyword */: + case 145 /* NumberKeyword */: + case 156 /* BigIntKeyword */: + case 149 /* SymbolKeyword */: + case 132 /* BooleanKeyword */: + case 151 /* UndefinedKeyword */: + case 142 /* NeverKeyword */: + case 146 /* ObjectKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. return tryParse(parseKeywordAndNoDot) || parseTypeReference(); - case 65 /* AsteriskEqualsToken */: + case 66 /* AsteriskEqualsToken */: // If there is '*=', treat it as * followed by postfix = scanner.reScanAsteriskEqualsToken(); // falls through @@ -31123,7 +32280,7 @@ var ts; // falls through case 57 /* QuestionToken */: return parseJSDocUnknownOrNullableType(); - case 97 /* FunctionKeyword */: + case 98 /* FunctionKeyword */: return parseJSDocFunctionType(); case 53 /* ExclamationToken */: return parseJSDocNonNullableType(); @@ -31131,24 +32288,24 @@ var ts; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: - case 103 /* NullKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: + case 104 /* NullKeyword */: return parseLiteralTypeNode(); case 40 /* MinusToken */: return lookAhead(nextTokenIsNumericOrBigIntLiteral) ? parseLiteralTypeNode(/*negative*/ true) : parseTypeReference(); - case 113 /* VoidKeyword */: + case 114 /* VoidKeyword */: return parseTokenNode(); - case 107 /* ThisKeyword */: { + case 108 /* ThisKeyword */: { var thisKeyword = parseThisTypeNode(); - if (token() === 137 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 138 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 111 /* TypeOfKeyword */: + case 112 /* TypeOfKeyword */: return lookAhead(isStartOfTypeOfImportType) ? parseImportType() : parseTypeQuery(); case 18 /* OpenBraceToken */: return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral(); @@ -31156,9 +32313,9 @@ var ts; return parseTupleType(); case 20 /* OpenParenToken */: return parseParenthesizedType(); - case 99 /* ImportKeyword */: + case 100 /* ImportKeyword */: return parseImportType(); - case 127 /* AssertsKeyword */: + case 128 /* AssertsKeyword */: return lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? parseAssertsTypePredicate() : parseTypeReference(); case 15 /* TemplateHead */: return parseTemplateType(); @@ -31168,44 +32325,44 @@ var ts; } function isStartOfType(inStartOfParameter) { switch (token()) { - case 128 /* AnyKeyword */: - case 152 /* UnknownKeyword */: - case 147 /* StringKeyword */: - case 144 /* NumberKeyword */: - case 155 /* BigIntKeyword */: - case 131 /* BooleanKeyword */: - case 142 /* ReadonlyKeyword */: - case 148 /* SymbolKeyword */: - case 151 /* UniqueKeyword */: - case 113 /* VoidKeyword */: - case 150 /* UndefinedKeyword */: - case 103 /* NullKeyword */: - case 107 /* ThisKeyword */: - case 111 /* TypeOfKeyword */: - case 141 /* NeverKeyword */: + case 129 /* AnyKeyword */: + case 153 /* UnknownKeyword */: + case 148 /* StringKeyword */: + case 145 /* NumberKeyword */: + case 156 /* BigIntKeyword */: + case 132 /* BooleanKeyword */: + case 143 /* ReadonlyKeyword */: + case 149 /* SymbolKeyword */: + case 152 /* UniqueKeyword */: + case 114 /* VoidKeyword */: + case 151 /* UndefinedKeyword */: + case 104 /* NullKeyword */: + case 108 /* ThisKeyword */: + case 112 /* TypeOfKeyword */: + case 142 /* NeverKeyword */: case 18 /* OpenBraceToken */: case 22 /* OpenBracketToken */: case 29 /* LessThanToken */: case 51 /* BarToken */: case 50 /* AmpersandToken */: - case 102 /* NewKeyword */: + case 103 /* NewKeyword */: case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: - case 145 /* ObjectKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: + case 146 /* ObjectKeyword */: case 41 /* AsteriskToken */: case 57 /* QuestionToken */: case 53 /* ExclamationToken */: case 25 /* DotDotDotToken */: - case 135 /* InferKeyword */: - case 99 /* ImportKeyword */: - case 127 /* AssertsKeyword */: + case 136 /* InferKeyword */: + case 100 /* ImportKeyword */: + case 128 /* AssertsKeyword */: case 14 /* NoSubstitutionTemplateLiteral */: case 15 /* TemplateHead */: return true; - case 97 /* FunctionKeyword */: + case 98 /* FunctionKeyword */: return !inStartOfParameter; case 40 /* MinusToken */: return !inStartOfParameter && lookAhead(nextTokenIsNumericOrBigIntLiteral); @@ -31269,17 +32426,17 @@ var ts; } function parseInferType() { var pos = getNodePos(); - parseExpected(135 /* InferKeyword */); + parseExpected(136 /* InferKeyword */); return finishNode(factory.createInferTypeNode(parseTypeParameterOfInferType()), pos); } function parseTypeOperatorOrHigher() { var operator = token(); switch (operator) { - case 138 /* KeyOfKeyword */: - case 151 /* UniqueKeyword */: - case 142 /* ReadonlyKeyword */: + case 139 /* KeyOfKeyword */: + case 152 /* UniqueKeyword */: + case 143 /* ReadonlyKeyword */: return parseTypeOperator(operator); - case 135 /* InferKeyword */: + case 136 /* InferKeyword */: return parseInferType(); } return parsePostfixTypeOrHigher(); @@ -31329,7 +32486,7 @@ var ts; } function nextTokenIsNewKeyword() { nextToken(); - return token() === 102 /* NewKeyword */; + return token() === 103 /* NewKeyword */; } function isStartOfFunctionTypeOrConstructorType() { if (token() === 29 /* LessThanToken */) { @@ -31338,15 +32495,15 @@ var ts; if (token() === 20 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType)) { return true; } - return token() === 102 /* NewKeyword */ || - token() === 125 /* AbstractKeyword */ && lookAhead(nextTokenIsNewKeyword); + return token() === 103 /* NewKeyword */ || + token() === 126 /* AbstractKeyword */ && lookAhead(nextTokenIsNewKeyword); } function skipParameterStart() { if (ts.isModifierKind(token())) { // Skip modifiers parseModifiers(); } - if (isIdentifier() || token() === 107 /* ThisKeyword */) { + if (isIdentifier() || token() === 108 /* ThisKeyword */) { nextToken(); return true; } @@ -31369,7 +32526,7 @@ var ts; // 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() === 62 /* EqualsToken */) { + token() === 57 /* QuestionToken */ || token() === 63 /* EqualsToken */) { // ( xxx : // ( xxx , // ( xxx ? @@ -31399,16 +32556,16 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 137 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 138 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } } function parseAssertsTypePredicate() { var pos = getNodePos(); - var assertsModifier = parseExpectedToken(127 /* AssertsKeyword */); - var parameterName = token() === 107 /* ThisKeyword */ ? parseThisTypeNode() : parseIdentifier(); - var type = parseOptional(137 /* IsKeyword */) ? parseType() : undefined; + var assertsModifier = parseExpectedToken(128 /* AssertsKeyword */); + var parameterName = token() === 108 /* ThisKeyword */ ? parseThisTypeNode() : parseIdentifier(); + var type = parseOptional(138 /* IsKeyword */) ? parseType() : undefined; return finishNode(factory.createTypePredicateNode(assertsModifier, parameterName, type), pos); } function parseType() { @@ -31422,7 +32579,7 @@ var ts; } var pos = getNodePos(); var type = parseUnionTypeOrHigher(); - if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(93 /* ExtendsKeyword */)) { + if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(94 /* ExtendsKeyword */)) { // The type following 'extends' is not permitted to be another conditional type var extendsType = parseTypeWorker(/*noConditionalTypes*/ true); parseExpected(57 /* QuestionToken */); @@ -31439,11 +32596,11 @@ var ts; // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token()) { - case 107 /* ThisKeyword */: - case 105 /* SuperKeyword */: - case 103 /* NullKeyword */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: + case 108 /* ThisKeyword */: + case 106 /* SuperKeyword */: + case 104 /* NullKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: @@ -31452,14 +32609,14 @@ var ts; case 20 /* OpenParenToken */: case 22 /* OpenBracketToken */: case 18 /* OpenBraceToken */: - case 97 /* FunctionKeyword */: - case 83 /* ClassKeyword */: - case 102 /* NewKeyword */: + case 98 /* FunctionKeyword */: + case 84 /* ClassKeyword */: + case 103 /* NewKeyword */: case 43 /* SlashToken */: - case 67 /* SlashEqualsToken */: - case 78 /* Identifier */: + case 68 /* SlashEqualsToken */: + case 79 /* Identifier */: return true; - case 99 /* ImportKeyword */: + case 100 /* ImportKeyword */: return lookAhead(nextTokenIsOpenParenOrLessThanOrDot); default: return isIdentifier(); @@ -31474,15 +32631,15 @@ var ts; case 40 /* MinusToken */: case 54 /* TildeToken */: case 53 /* ExclamationToken */: - case 88 /* DeleteKeyword */: - case 111 /* TypeOfKeyword */: - case 113 /* VoidKeyword */: + case 89 /* DeleteKeyword */: + case 112 /* TypeOfKeyword */: + case 114 /* VoidKeyword */: case 45 /* PlusPlusToken */: case 46 /* MinusMinusToken */: case 29 /* LessThanToken */: - case 130 /* AwaitKeyword */: - case 124 /* YieldKeyword */: - case 79 /* PrivateIdentifier */: + case 131 /* AwaitKeyword */: + case 125 /* YieldKeyword */: + case 80 /* 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. @@ -31501,8 +32658,8 @@ var ts; function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. return token() !== 18 /* OpenBraceToken */ && - token() !== 97 /* FunctionKeyword */ && - token() !== 83 /* ClassKeyword */ && + token() !== 98 /* FunctionKeyword */ && + token() !== 84 /* ClassKeyword */ && token() !== 59 /* AtToken */ && isStartOfExpression(); } @@ -31527,7 +32684,7 @@ var ts; return expr; } function parseInitializer() { - return parseOptional(62 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; + return parseOptional(63 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; } function parseAssignmentExpressionOrHigher() { // AssignmentExpression[in,yield]: @@ -31573,7 +32730,7 @@ var ts; // 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 === 78 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { + if (expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(pos, expr, /*asyncModifier*/ undefined); } // Now see if we might be in cases '2' or '3'. @@ -31589,7 +32746,7 @@ var ts; return parseConditionalExpressionRest(expr, pos); } function isYieldExpression() { - if (token() === 124 /* YieldKeyword */) { + if (token() === 125 /* 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()) { @@ -31669,7 +32826,7 @@ 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() === 129 /* AsyncKeyword */) { + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */ || token() === 130 /* AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } if (token() === 38 /* EqualsGreaterThanToken */) { @@ -31682,7 +32839,7 @@ var ts; return 0 /* False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 129 /* AsyncKeyword */) { + if (token() === 130 /* AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0 /* False */; @@ -31726,13 +32883,13 @@ var ts; // 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 !== 129 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { + if (ts.isModifierKind(second) && second !== 130 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { return 1 /* 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 !== 107 /* ThisKeyword */) { + if (!isIdentifier() && second !== 108 /* ThisKeyword */) { return 0 /* False */; } switch (nextToken()) { @@ -31743,13 +32900,13 @@ var ts; case 57 /* 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() === 62 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { + if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 63 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { return 1 /* True */; } // Otherwise it is definitely not a lambda. return 0 /* False */; case 27 /* CommaToken */: - case 62 /* EqualsToken */: + case 63 /* EqualsToken */: case 21 /* CloseParenToken */: // If we have "(a," or "(a=" or "(a)" this *could* be an arrow function return 2 /* Unknown */; @@ -31768,10 +32925,10 @@ var ts; if (languageVariant === 1 /* JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 93 /* ExtendsKeyword */) { + if (third === 94 /* ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 62 /* EqualsToken */: + case 63 /* EqualsToken */: case 31 /* GreaterThanToken */: return false; default: @@ -31805,7 +32962,7 @@ var ts; } function tryParseAsyncSimpleArrowFunctionExpression() { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" - if (token() === 129 /* AsyncKeyword */) { + if (token() === 130 /* AsyncKeyword */) { if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) { var pos = getNodePos(); var asyncModifier = parseModifiersForArrowFunction(); @@ -31819,7 +32976,7 @@ 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() === 129 /* AsyncKeyword */) { + if (token() === 130 /* 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" @@ -31828,7 +32985,7 @@ var ts; } // Check for un-parenthesized AsyncArrowFunction var expr = parseBinaryExpressionOrHigher(0 /* Lowest */); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 78 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { + if (!scanner.hasPrecedingLineBreak() && expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { return 1 /* True */; } } @@ -31893,8 +33050,8 @@ var ts; return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */); } if (token() !== 26 /* SemicolonToken */ && - token() !== 97 /* FunctionKeyword */ && - token() !== 83 /* ClassKeyword */ && + token() !== 98 /* FunctionKeyword */ && + token() !== 84 /* ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -31932,7 +33089,7 @@ var ts; var colonToken; return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher), colonToken = parseExpectedToken(58 /* ColonToken */), ts.nodeIsPresent(colonToken) ? parseAssignmentExpressionOrHigher() - : createMissingNode(78 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */))), pos); + : createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */))), pos); } function parseBinaryExpressionOrHigher(precedence) { var pos = getNodePos(); @@ -31940,7 +33097,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand, pos); } function isInOrOfKeyword(t) { - return t === 100 /* InKeyword */ || t === 156 /* OfKeyword */; + return t === 101 /* InKeyword */ || t === 158 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand, pos) { while (true) { @@ -31975,10 +33132,10 @@ var ts; if (!consumeCurrentOperator) { break; } - if (token() === 100 /* InKeyword */ && inDisallowInContext()) { + if (token() === 101 /* InKeyword */ && inDisallowInContext()) { break; } - if (token() === 126 /* AsKeyword */) { + if (token() === 127 /* AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -31999,7 +33156,7 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 100 /* InKeyword */) { + if (inDisallowInContext() && token() === 101 /* InKeyword */) { return false; } return ts.getBinaryOperatorPrecedence(token()) > 0; @@ -32027,7 +33184,7 @@ var ts; return finishNode(factory.createVoidExpression(nextTokenAnd(parseSimpleUnaryExpression)), pos); } function isAwaitExpression() { - if (token() === 130 /* AwaitKeyword */) { + if (token() === 131 /* AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -32080,7 +33237,7 @@ var ts; if (token() === 42 /* AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 206 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 208 /* 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 { @@ -32110,18 +33267,18 @@ var ts; case 54 /* TildeToken */: case 53 /* ExclamationToken */: return parsePrefixUnaryExpression(); - case 88 /* DeleteKeyword */: + case 89 /* DeleteKeyword */: return parseDeleteExpression(); - case 111 /* TypeOfKeyword */: + case 112 /* TypeOfKeyword */: return parseTypeOfExpression(); - case 113 /* VoidKeyword */: + case 114 /* VoidKeyword */: return parseVoidExpression(); case 29 /* LessThanToken */: // This is modified UnaryExpression grammar in TypeScript // UnaryExpression (modified): // < type > UnaryExpression return parseTypeAssertion(); - case 130 /* AwaitKeyword */: + case 131 /* AwaitKeyword */: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -32148,10 +33305,10 @@ var ts; case 40 /* MinusToken */: case 54 /* TildeToken */: case 53 /* ExclamationToken */: - case 88 /* DeleteKeyword */: - case 111 /* TypeOfKeyword */: - case 113 /* VoidKeyword */: - case 130 /* AwaitKeyword */: + case 89 /* DeleteKeyword */: + case 112 /* TypeOfKeyword */: + case 114 /* VoidKeyword */: + case 131 /* AwaitKeyword */: return false; case 29 /* LessThanToken */: // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression @@ -32227,7 +33384,7 @@ var ts; // or starts the beginning of the first four CallExpression productions. var pos = getNodePos(); var expression; - if (token() === 99 /* ImportKeyword */) { + if (token() === 100 /* 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: @@ -32241,7 +33398,7 @@ var ts; // This is an 'import.*' metaproperty (i.e. 'import.meta') nextToken(); // advance past the 'import' nextToken(); // advance past the dot - expression = finishNode(factory.createMetaProperty(99 /* ImportKeyword */, parseIdentifierName()), pos); + expression = finishNode(factory.createMetaProperty(100 /* ImportKeyword */, parseIdentifierName()), pos); sourceFlags |= 2097152 /* PossiblyContainsImportMeta */; } else { @@ -32249,7 +33406,7 @@ var ts; } } else { - expression = token() === 105 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); + expression = token() === 106 /* 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 @@ -32327,23 +33484,45 @@ var ts; // 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); } - function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext, topInvalidNodePosition) { + function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext, topInvalidNodePosition, openingTag) { var pos = getNodePos(); var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 275 /* JsxOpeningElement */) { + if (opening.kind === 277 /* JsxOpeningElement */) { var children = parseJsxChildren(opening); - var closingElement = parseJsxClosingElement(inExpressionContext); - if (!tagNamesAreEquivalent(opening.tagName, closingElement.tagName)) { - parseErrorAtRange(closingElement, ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNodeFromSourceText(sourceText, opening.tagName)); + var closingElement = void 0; + var lastChild = children[children.length - 1]; + if ((lastChild === null || lastChild === void 0 ? void 0 : lastChild.kind) === 275 /* JsxElement */ + && !tagNamesAreEquivalent(lastChild.openingElement.tagName, lastChild.closingElement.tagName) + && tagNamesAreEquivalent(opening.tagName, lastChild.closingElement.tagName)) { + // when an unclosed JsxOpeningElement incorrectly parses its parent's JsxClosingElement, + // restructure (
(...
)) --> (
(...)
) + // (no need to error; the parent will error) + var end = lastChild.openingElement.end; // newly-created children and closing are both zero-width end/end + var newLast = finishNode(factory.createJsxElement(lastChild.openingElement, createNodeArray([], end, end), finishNode(factory.createJsxClosingElement(finishNode(factory.createIdentifier(""), end, end)), end, end)), lastChild.openingElement.pos, end); + children = createNodeArray(__spreadArray(__spreadArray([], children.slice(0, children.length - 1)), [newLast]), children.pos, end); + closingElement = lastChild.closingElement; + } + else { + closingElement = parseJsxClosingElement(opening, inExpressionContext); + if (!tagNamesAreEquivalent(opening.tagName, closingElement.tagName)) { + if (openingTag && ts.isJsxOpeningElement(openingTag) && tagNamesAreEquivalent(closingElement.tagName, openingTag.tagName)) { + // opening incorrectly matched with its parent's closing -- put error on opening + parseErrorAtRange(opening.tagName, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, opening.tagName)); + } + else { + // other opening/closing mismatches -- put error on closing + parseErrorAtRange(closingElement.tagName, ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNodeFromSourceText(sourceText, opening.tagName)); + } + } } result = finishNode(factory.createJsxElement(opening, children, closingElement), pos); } - else if (opening.kind === 278 /* JsxOpeningFragment */) { + else if (opening.kind === 280 /* JsxOpeningFragment */) { result = finishNode(factory.createJsxFragment(opening, parseJsxChildren(opening), parseJsxClosingFragment(inExpressionContext)), pos); } else { - ts.Debug.assert(opening.kind === 274 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 276 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -32397,7 +33576,7 @@ var ts; case 18 /* OpenBraceToken */: return parseJsxExpression(/*inExpressionContext*/ false); case 29 /* LessThanToken */: - return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ false); + return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ false, /*topInvalidNodePosition*/ undefined, openingTag); default: return ts.Debug.assertNever(token); } @@ -32412,6 +33591,13 @@ var ts; if (!child) break; list.push(child); + if (ts.isJsxOpeningElement(openingTag) + && (child === null || child === void 0 ? void 0 : child.kind) === 275 /* 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 + break; + } } parsingContext = saveParsingContext; return createNodeArray(list, listPos); @@ -32441,12 +33627,14 @@ var ts; } else { parseExpected(43 /* SlashToken */); - if (inExpressionContext) { - parseExpected(31 /* GreaterThanToken */); - } - else { - parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); - scanJsxText(); + if (parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { + // manually advance the scanner in order to look for jsx text inside jsx + if (inExpressionContext) { + nextToken(); + } + else { + scanJsxText(); + } } node = factory.createJsxSelfClosingElement(tagName, typeArguments, attributes); } @@ -32460,7 +33648,7 @@ 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() === 107 /* ThisKeyword */ ? + var expression = token() === 108 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); while (parseOptional(24 /* DotToken */)) { expression = finishNode(factory.createPropertyAccessExpression(expression, parseRightSideOfDot(/*allowIdentifierNames*/ true, /*allowPrivateIdentifiers*/ false)), pos); @@ -32497,7 +33685,7 @@ var ts; } scanJsxIdentifier(); var pos = getNodePos(); - return finishNode(factory.createJsxAttribute(parseIdentifierName(), token() !== 62 /* EqualsToken */ ? undefined : + return finishNode(factory.createJsxAttribute(parseIdentifierName(), token() !== 63 /* EqualsToken */ ? undefined : scanJsxAttributeValue() === 10 /* StringLiteral */ ? parseLiteralNode() : parseJsxExpression(/*inExpressionContext*/ true)), pos); } @@ -32509,16 +33697,18 @@ var ts; parseExpected(19 /* CloseBraceToken */); return finishNode(factory.createJsxSpreadAttribute(expression), pos); } - function parseJsxClosingElement(inExpressionContext) { + function parseJsxClosingElement(open, inExpressionContext) { var pos = getNodePos(); parseExpected(30 /* LessThanSlashToken */); var tagName = parseJsxElementName(); - if (inExpressionContext) { - parseExpected(31 /* GreaterThanToken */); - } - else { - parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); - scanJsxText(); + if (parseExpected(31 /* 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(); + } + else { + scanJsxText(); + } } return finishNode(factory.createJsxClosingElement(tagName), pos); } @@ -32528,12 +33718,14 @@ var ts; if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); } - if (inExpressionContext) { - parseExpected(31 /* GreaterThanToken */); - } - else { - parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); - scanJsxText(); + if (parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { + // manually advance the scanner in order to look for jsx text inside jsx + if (inExpressionContext) { + nextToken(); + } + else { + scanJsxText(); + } } return finishNode(factory.createJsxJsxClosingFragment(), pos); } @@ -32590,7 +33782,7 @@ var ts; function parseElementAccessExpressionRest(pos, expression, questionDotToken) { var argumentExpression; if (token() === 23 /* CloseBracketToken */) { - argumentExpression = createMissingNode(78 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); + argumentExpression = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); } else { var argument = allowInAnd(parseExpression); @@ -32685,7 +33877,7 @@ var ts; } if (questionDotToken) { // We failed to parse anything, so report a missing identifier here. - var name = createMissingNode(78 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected); + var name = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected); expression = finishNode(factory.createPropertyAccessChain(expression, questionDotToken, name), pos); } break; @@ -32766,11 +33958,11 @@ var ts; case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 107 /* ThisKeyword */: - case 105 /* SuperKeyword */: - case 103 /* NullKeyword */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: + case 108 /* ThisKeyword */: + case 106 /* SuperKeyword */: + case 104 /* NullKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: return parseTokenNode(); case 20 /* OpenParenToken */: return parseParenthesizedExpression(); @@ -32778,7 +33970,7 @@ var ts; return parseArrayLiteralExpression(); case 18 /* OpenBraceToken */: return parseObjectLiteralExpression(); - case 129 /* AsyncKeyword */: + case 130 /* 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. @@ -32786,14 +33978,14 @@ var ts; break; } return parseFunctionExpression(); - case 83 /* ClassKeyword */: + case 84 /* ClassKeyword */: return parseClassExpression(); - case 97 /* FunctionKeyword */: + case 98 /* FunctionKeyword */: return parseFunctionExpression(); - case 102 /* NewKeyword */: + case 103 /* NewKeyword */: return parseNewExpressionOrNewDotTarget(); case 43 /* SlashToken */: - case 67 /* SlashEqualsToken */: + case 68 /* SlashEqualsToken */: if (reScanSlashToken() === 13 /* RegularExpressionLiteral */) { return parseLiteralNode(); } @@ -32842,11 +34034,11 @@ var ts; } var decorators = parseDecorators(); var modifiers = parseModifiers(); - if (parseContextualModifier(134 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 167 /* GetAccessor */); + if (parseContextualModifier(135 /* GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 169 /* GetAccessor */); } - if (parseContextualModifier(146 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 168 /* SetAccessor */); + if (parseContextualModifier(147 /* SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 170 /* SetAccessor */); } var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); @@ -32865,7 +34057,7 @@ var ts; var node; var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* ColonToken */); if (isShorthandPropertyAssignment) { - var equalsToken = parseOptionalToken(62 /* EqualsToken */); + var equalsToken = parseOptionalToken(63 /* EqualsToken */); var objectAssignmentInitializer = equalsToken ? allowInAnd(parseAssignmentExpressionOrHigher) : undefined; node = factory.createShorthandPropertyAssignment(name, objectAssignmentInitializer); // Save equals token for error reporting. @@ -32911,7 +34103,7 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiers(); - parseExpected(97 /* FunctionKeyword */); + 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 */; @@ -32934,10 +34126,10 @@ var ts; } function parseNewExpressionOrNewDotTarget() { var pos = getNodePos(); - parseExpected(102 /* NewKeyword */); + parseExpected(103 /* NewKeyword */); if (parseOptional(24 /* DotToken */)) { var name = parseIdentifierName(); - return finishNode(factory.createMetaProperty(102 /* NewKeyword */, name), pos); + return finishNode(factory.createMetaProperty(103 /* NewKeyword */, name), pos); } var expressionPos = getNodePos(); var expression = parsePrimaryExpression(); @@ -32964,6 +34156,7 @@ var ts; // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { var pos = getNodePos(); + var hasJSDoc = hasPrecedingJSDocComment(); var openBracePosition = scanner.getTokenPos(); if (parseExpected(18 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { var multiLine = scanner.hasPrecedingLineBreak(); @@ -32974,11 +34167,16 @@ var ts; ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here)); } } - return finishNode(factory.createBlock(statements, multiLine), pos); + var result = withJSDoc(finishNode(factory.createBlock(statements, multiLine), pos), hasJSDoc); + if (token() === 63 /* 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(); + } + return result; } else { var statements = createMissingList(); - return finishNode(factory.createBlock(statements, /*multiLine*/ undefined), pos); + return withJSDoc(finishNode(factory.createBlock(statements, /*multiLine*/ undefined), pos), hasJSDoc); } } function parseFunctionBlock(flags, diagnosticMessage) { @@ -33005,24 +34203,27 @@ var ts; } function parseEmptyStatement() { var pos = getNodePos(); + var hasJSDoc = hasPrecedingJSDocComment(); parseExpected(26 /* SemicolonToken */); - return finishNode(factory.createEmptyStatement(), pos); + return withJSDoc(finishNode(factory.createEmptyStatement(), pos), hasJSDoc); } function parseIfStatement() { var pos = getNodePos(); - parseExpected(98 /* IfKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(99 /* IfKeyword */); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); var thenStatement = parseStatement(); - var elseStatement = parseOptional(90 /* ElseKeyword */) ? parseStatement() : undefined; - return finishNode(factory.createIfStatement(expression, thenStatement, elseStatement), pos); + var elseStatement = parseOptional(91 /* ElseKeyword */) ? parseStatement() : undefined; + return withJSDoc(finishNode(factory.createIfStatement(expression, thenStatement, elseStatement), pos), hasJSDoc); } function parseDoStatement() { var pos = getNodePos(); - parseExpected(89 /* DoKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(90 /* DoKeyword */); var statement = parseStatement(); - parseExpected(114 /* WhileKeyword */); + parseExpected(115 /* WhileKeyword */); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); @@ -33031,25 +34232,27 @@ var ts; // 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 */); - return finishNode(factory.createDoStatement(statement, expression), pos); + return withJSDoc(finishNode(factory.createDoStatement(statement, expression), pos), hasJSDoc); } function parseWhileStatement() { var pos = getNodePos(); - parseExpected(114 /* WhileKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(115 /* WhileKeyword */); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); var statement = parseStatement(); - return finishNode(factory.createWhileStatement(expression, statement), pos); + return withJSDoc(finishNode(factory.createWhileStatement(expression, statement), pos), hasJSDoc); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(96 /* ForKeyword */); - var awaitToken = parseOptionalToken(130 /* AwaitKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(97 /* ForKeyword */); + var awaitToken = parseOptionalToken(131 /* AwaitKeyword */); parseExpected(20 /* OpenParenToken */); var initializer; if (token() !== 26 /* SemicolonToken */) { - if (token() === 112 /* VarKeyword */ || token() === 118 /* LetKeyword */ || token() === 84 /* ConstKeyword */) { + if (token() === 113 /* VarKeyword */ || token() === 119 /* LetKeyword */ || token() === 85 /* ConstKeyword */) { initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { @@ -33057,12 +34260,12 @@ var ts; } } var node; - if (awaitToken ? parseExpected(156 /* OfKeyword */) : parseOptional(156 /* OfKeyword */)) { + if (awaitToken ? parseExpected(158 /* OfKeyword */) : parseOptional(158 /* OfKeyword */)) { var expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(21 /* CloseParenToken */); node = factory.createForOfStatement(awaitToken, initializer, expression, parseStatement()); } - else if (parseOptional(100 /* InKeyword */)) { + else if (parseOptional(101 /* InKeyword */)) { var expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); node = factory.createForInStatement(initializer, expression, parseStatement()); @@ -33079,37 +34282,40 @@ var ts; parseExpected(21 /* CloseParenToken */); node = factory.createForStatement(initializer, condition, incrementor, parseStatement()); } - return finishNode(node, pos); + return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseBreakOrContinueStatement(kind) { var pos = getNodePos(); - parseExpected(kind === 241 /* BreakStatement */ ? 80 /* BreakKeyword */ : 85 /* ContinueKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(kind === 243 /* BreakStatement */ ? 81 /* BreakKeyword */ : 86 /* ContinueKeyword */); var label = canParseSemicolon() ? undefined : parseIdentifier(); parseSemicolon(); - var node = kind === 241 /* BreakStatement */ + var node = kind === 243 /* BreakStatement */ ? factory.createBreakStatement(label) : factory.createContinueStatement(label); - return finishNode(node, pos); + return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseReturnStatement() { var pos = getNodePos(); - parseExpected(104 /* ReturnKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(105 /* ReturnKeyword */); var expression = canParseSemicolon() ? undefined : allowInAnd(parseExpression); parseSemicolon(); - return finishNode(factory.createReturnStatement(expression), pos); + return withJSDoc(finishNode(factory.createReturnStatement(expression), pos), hasJSDoc); } function parseWithStatement() { var pos = getNodePos(); - parseExpected(115 /* WithKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(116 /* WithKeyword */); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); var statement = doInsideOfContext(16777216 /* InWithStatement */, parseStatement); - return finishNode(factory.createWithStatement(expression, statement), pos); + return withJSDoc(finishNode(factory.createWithStatement(expression, statement), pos), hasJSDoc); } function parseCaseClause() { var pos = getNodePos(); - parseExpected(81 /* CaseKeyword */); + parseExpected(82 /* CaseKeyword */); var expression = allowInAnd(parseExpression); parseExpected(58 /* ColonToken */); var statements = parseList(3 /* SwitchClauseStatements */, parseStatement); @@ -33117,13 +34323,13 @@ var ts; } function parseDefaultClause() { var pos = getNodePos(); - parseExpected(87 /* DefaultKeyword */); + parseExpected(88 /* DefaultKeyword */); parseExpected(58 /* ColonToken */); var statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(factory.createDefaultClause(statements), pos); } function parseCaseOrDefaultClause() { - return token() === 81 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token() === 82 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseCaseBlock() { var pos = getNodePos(); @@ -33134,18 +34340,20 @@ var ts; } function parseSwitchStatement() { var pos = getNodePos(); - parseExpected(106 /* SwitchKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(107 /* SwitchKeyword */); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); var caseBlock = parseCaseBlock(); - return finishNode(factory.createSwitchStatement(expression, caseBlock), pos); + return withJSDoc(finishNode(factory.createSwitchStatement(expression, caseBlock), pos), hasJSDoc); } function parseThrowStatement() { // ThrowStatement[Yield] : // throw [no LineTerminator here]Expression[In, ?Yield]; var pos = getNodePos(); - parseExpected(108 /* ThrowKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(109 /* 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. @@ -33157,26 +34365,27 @@ var ts; expression = finishNode(factory.createIdentifier(""), getNodePos()); } parseSemicolon(); - return finishNode(factory.createThrowStatement(expression), pos); + return withJSDoc(finishNode(factory.createThrowStatement(expression), pos), hasJSDoc); } // TODO: Review for error recovery function parseTryStatement() { var pos = getNodePos(); - parseExpected(110 /* TryKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(111 /* TryKeyword */); var tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); - var catchClause = token() === 82 /* CatchKeyword */ ? parseCatchClause() : undefined; + var catchClause = token() === 83 /* 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() === 95 /* FinallyKeyword */) { - parseExpected(95 /* FinallyKeyword */); + if (!catchClause || token() === 96 /* FinallyKeyword */) { + parseExpected(96 /* FinallyKeyword */); finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } - return finishNode(factory.createTryStatement(tryBlock, catchClause, finallyBlock), pos); + return withJSDoc(finishNode(factory.createTryStatement(tryBlock, catchClause, finallyBlock), pos), hasJSDoc); } function parseCatchClause() { var pos = getNodePos(); - parseExpected(82 /* CatchKeyword */); + parseExpected(83 /* CatchKeyword */); var variableDeclaration; if (parseOptional(20 /* OpenParenToken */)) { variableDeclaration = parseVariableDeclaration(); @@ -33191,9 +34400,10 @@ var ts; } function parseDebuggerStatement() { var pos = getNodePos(); - parseExpected(86 /* DebuggerKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(87 /* DebuggerKeyword */); parseSemicolon(); - return finishNode(factory.createDebuggerStatement(), pos); + return withJSDoc(finishNode(factory.createDebuggerStatement(), pos), hasJSDoc); } function parseExpressionOrLabeledStatement() { // Avoiding having to do the lookahead for a labeled statement by just trying to parse @@ -33223,11 +34433,11 @@ var ts; } function nextTokenIsClassKeywordOnSameLine() { nextToken(); - return token() === 83 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 84 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 97 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 98 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine() { nextToken(); @@ -33236,12 +34446,12 @@ var ts; function isDeclaration() { while (true) { switch (token()) { - case 112 /* VarKeyword */: - case 118 /* LetKeyword */: - case 84 /* ConstKeyword */: - case 97 /* FunctionKeyword */: - case 83 /* ClassKeyword */: - case 91 /* EnumKeyword */: + case 113 /* VarKeyword */: + case 119 /* LetKeyword */: + case 85 /* ConstKeyword */: + case 98 /* FunctionKeyword */: + case 84 /* ClassKeyword */: + case 92 /* 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 @@ -33264,44 +34474,44 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 117 /* InterfaceKeyword */: - case 149 /* TypeKeyword */: + case 118 /* InterfaceKeyword */: + case 150 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 139 /* ModuleKeyword */: - case 140 /* NamespaceKeyword */: + case 140 /* ModuleKeyword */: + case 141 /* NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 125 /* AbstractKeyword */: - case 129 /* AsyncKeyword */: - case 133 /* DeclareKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 122 /* PublicKeyword */: - case 142 /* ReadonlyKeyword */: + case 126 /* AbstractKeyword */: + case 130 /* AsyncKeyword */: + case 134 /* DeclareKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + case 123 /* PublicKeyword */: + case 143 /* ReadonlyKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 154 /* GlobalKeyword */: + case 155 /* GlobalKeyword */: nextToken(); - return token() === 18 /* OpenBraceToken */ || token() === 78 /* Identifier */ || token() === 92 /* ExportKeyword */; - case 99 /* ImportKeyword */: + return token() === 18 /* OpenBraceToken */ || token() === 79 /* Identifier */ || token() === 93 /* ExportKeyword */; + case 100 /* ImportKeyword */: nextToken(); return token() === 10 /* StringLiteral */ || token() === 41 /* AsteriskToken */ || token() === 18 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); - case 92 /* ExportKeyword */: + case 93 /* ExportKeyword */: var currentToken_1 = nextToken(); - if (currentToken_1 === 149 /* TypeKeyword */) { + if (currentToken_1 === 150 /* TypeKeyword */) { currentToken_1 = lookAhead(nextToken); } - if (currentToken_1 === 62 /* EqualsToken */ || currentToken_1 === 41 /* AsteriskToken */ || - currentToken_1 === 18 /* OpenBraceToken */ || currentToken_1 === 87 /* DefaultKeyword */ || - currentToken_1 === 126 /* AsKeyword */) { + if (currentToken_1 === 63 /* EqualsToken */ || currentToken_1 === 41 /* AsteriskToken */ || + currentToken_1 === 18 /* OpenBraceToken */ || currentToken_1 === 88 /* DefaultKeyword */ || + currentToken_1 === 127 /* AsKeyword */) { return true; } continue; - case 123 /* StaticKeyword */: + case 124 /* StaticKeyword */: nextToken(); continue; default: @@ -33317,48 +34527,48 @@ var ts; case 59 /* AtToken */: case 26 /* SemicolonToken */: case 18 /* OpenBraceToken */: - case 112 /* VarKeyword */: - case 118 /* LetKeyword */: - case 97 /* FunctionKeyword */: - case 83 /* ClassKeyword */: - case 91 /* EnumKeyword */: - case 98 /* IfKeyword */: - case 89 /* DoKeyword */: - case 114 /* WhileKeyword */: - case 96 /* ForKeyword */: - case 85 /* ContinueKeyword */: - case 80 /* BreakKeyword */: - case 104 /* ReturnKeyword */: - case 115 /* WithKeyword */: - case 106 /* SwitchKeyword */: - case 108 /* ThrowKeyword */: - case 110 /* TryKeyword */: - case 86 /* DebuggerKeyword */: + 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 */: // '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 82 /* CatchKeyword */: - case 95 /* FinallyKeyword */: + case 83 /* CatchKeyword */: + case 96 /* FinallyKeyword */: return true; - case 99 /* ImportKeyword */: + case 100 /* ImportKeyword */: return isStartOfDeclaration() || lookAhead(nextTokenIsOpenParenOrLessThanOrDot); - case 84 /* ConstKeyword */: - case 92 /* ExportKeyword */: + case 85 /* ConstKeyword */: + case 93 /* ExportKeyword */: return isStartOfDeclaration(); - case 129 /* AsyncKeyword */: - case 133 /* DeclareKeyword */: - case 117 /* InterfaceKeyword */: - case 139 /* ModuleKeyword */: - case 140 /* NamespaceKeyword */: - case 149 /* TypeKeyword */: - case 154 /* GlobalKeyword */: + case 130 /* AsyncKeyword */: + case 134 /* DeclareKeyword */: + case 118 /* InterfaceKeyword */: + case 140 /* ModuleKeyword */: + case 141 /* NamespaceKeyword */: + case 150 /* TypeKeyword */: + case 155 /* GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 122 /* PublicKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 123 /* StaticKeyword */: - case 142 /* ReadonlyKeyword */: + case 123 /* PublicKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + case 124 /* StaticKeyword */: + case 143 /* 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); @@ -33381,64 +34591,64 @@ var ts; return parseEmptyStatement(); case 18 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); - case 112 /* VarKeyword */: + case 113 /* VarKeyword */: return parseVariableStatement(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 118 /* LetKeyword */: + case 119 /* LetKeyword */: if (isLetDeclaration()) { return parseVariableStatement(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); } break; - case 97 /* FunctionKeyword */: + case 98 /* FunctionKeyword */: return parseFunctionDeclaration(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 83 /* ClassKeyword */: + case 84 /* ClassKeyword */: return parseClassDeclaration(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 98 /* IfKeyword */: + case 99 /* IfKeyword */: return parseIfStatement(); - case 89 /* DoKeyword */: + case 90 /* DoKeyword */: return parseDoStatement(); - case 114 /* WhileKeyword */: + case 115 /* WhileKeyword */: return parseWhileStatement(); - case 96 /* ForKeyword */: + case 97 /* ForKeyword */: return parseForOrForInOrForOfStatement(); - case 85 /* ContinueKeyword */: - return parseBreakOrContinueStatement(240 /* ContinueStatement */); - case 80 /* BreakKeyword */: - return parseBreakOrContinueStatement(241 /* BreakStatement */); - case 104 /* ReturnKeyword */: + case 86 /* ContinueKeyword */: + return parseBreakOrContinueStatement(242 /* ContinueStatement */); + case 81 /* BreakKeyword */: + return parseBreakOrContinueStatement(243 /* BreakStatement */); + case 105 /* ReturnKeyword */: return parseReturnStatement(); - case 115 /* WithKeyword */: + case 116 /* WithKeyword */: return parseWithStatement(); - case 106 /* SwitchKeyword */: + case 107 /* SwitchKeyword */: return parseSwitchStatement(); - case 108 /* ThrowKeyword */: + case 109 /* ThrowKeyword */: return parseThrowStatement(); - case 110 /* TryKeyword */: + case 111 /* TryKeyword */: // Include 'catch' and 'finally' for error recovery. // falls through - case 82 /* CatchKeyword */: - case 95 /* FinallyKeyword */: + case 83 /* CatchKeyword */: + case 96 /* FinallyKeyword */: return parseTryStatement(); - case 86 /* DebuggerKeyword */: + case 87 /* DebuggerKeyword */: return parseDebuggerStatement(); case 59 /* AtToken */: return parseDeclaration(); - case 129 /* AsyncKeyword */: - case 117 /* InterfaceKeyword */: - case 149 /* TypeKeyword */: - case 139 /* ModuleKeyword */: - case 140 /* NamespaceKeyword */: - case 133 /* DeclareKeyword */: - case 84 /* ConstKeyword */: - case 91 /* EnumKeyword */: - case 92 /* ExportKeyword */: - case 99 /* ImportKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 122 /* PublicKeyword */: - case 125 /* AbstractKeyword */: - case 123 /* StaticKeyword */: - case 142 /* ReadonlyKeyword */: - case 154 /* GlobalKeyword */: + case 130 /* AsyncKeyword */: + case 118 /* InterfaceKeyword */: + case 150 /* TypeKeyword */: + case 140 /* ModuleKeyword */: + case 141 /* NamespaceKeyword */: + case 134 /* 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 143 /* ReadonlyKeyword */: + case 155 /* GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -33447,7 +34657,7 @@ var ts; return parseExpressionOrLabeledStatement(); } function isDeclareModifier(modifier) { - return modifier.kind === 133 /* DeclareKeyword */; + return modifier.kind === 134 /* DeclareKeyword */; } function parseDeclaration() { // TODO: Can we hold onto the parsed decorators/modifiers and advance the scanner @@ -33488,33 +34698,33 @@ var ts; } function parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers) { switch (token()) { - case 112 /* VarKeyword */: - case 118 /* LetKeyword */: - case 84 /* ConstKeyword */: + case 113 /* VarKeyword */: + case 119 /* LetKeyword */: + case 85 /* ConstKeyword */: return parseVariableStatement(pos, hasJSDoc, decorators, modifiers); - case 97 /* FunctionKeyword */: + case 98 /* FunctionKeyword */: return parseFunctionDeclaration(pos, hasJSDoc, decorators, modifiers); - case 83 /* ClassKeyword */: + case 84 /* ClassKeyword */: return parseClassDeclaration(pos, hasJSDoc, decorators, modifiers); - case 117 /* InterfaceKeyword */: + case 118 /* InterfaceKeyword */: return parseInterfaceDeclaration(pos, hasJSDoc, decorators, modifiers); - case 149 /* TypeKeyword */: + case 150 /* TypeKeyword */: return parseTypeAliasDeclaration(pos, hasJSDoc, decorators, modifiers); - case 91 /* EnumKeyword */: + case 92 /* EnumKeyword */: return parseEnumDeclaration(pos, hasJSDoc, decorators, modifiers); - case 154 /* GlobalKeyword */: - case 139 /* ModuleKeyword */: - case 140 /* NamespaceKeyword */: + case 155 /* GlobalKeyword */: + case 140 /* ModuleKeyword */: + case 141 /* NamespaceKeyword */: return parseModuleDeclaration(pos, hasJSDoc, decorators, modifiers); - case 99 /* ImportKeyword */: + case 100 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers); - case 92 /* ExportKeyword */: + case 93 /* ExportKeyword */: nextToken(); switch (token()) { - case 87 /* DefaultKeyword */: - case 62 /* EqualsToken */: + case 88 /* DefaultKeyword */: + case 63 /* EqualsToken */: return parseExportAssignment(pos, hasJSDoc, decorators, modifiers); - case 126 /* AsKeyword */: + case 127 /* AsKeyword */: return parseNamespaceExportDeclaration(pos, hasJSDoc, decorators, modifiers); default: return parseExportDeclaration(pos, hasJSDoc, decorators, modifiers); @@ -33523,7 +34733,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(271 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(273 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); ts.setTextRangePos(missing, pos); missing.decorators = decorators; missing.modifiers = modifiers; @@ -33588,7 +34798,7 @@ var ts; function isBindingIdentifierOrPrivateIdentifierOrPattern() { return token() === 18 /* OpenBraceToken */ || token() === 22 /* OpenBracketToken */ - || token() === 79 /* PrivateIdentifier */ + || token() === 80 /* PrivateIdentifier */ || isBindingIdentifier(); } function parseIdentifierOrPattern(privateIdentifierDiagnosticMessage) { @@ -33605,27 +34815,28 @@ var ts; } function parseVariableDeclaration(allowExclamation) { var pos = getNodePos(); + var hasJSDoc = hasPrecedingJSDocComment(); var name = parseIdentifierOrPattern(ts.Diagnostics.Private_identifiers_are_not_allowed_in_variable_declarations); var exclamationToken; - if (allowExclamation && name.kind === 78 /* Identifier */ && + if (allowExclamation && name.kind === 79 /* Identifier */ && token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { exclamationToken = parseTokenNode(); } var type = parseTypeAnnotation(); var initializer = isInOrOfKeyword(token()) ? undefined : parseInitializer(); var node = factory.createVariableDeclaration(name, exclamationToken, type, initializer); - return finishNode(node, pos); + return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseVariableDeclarationList(inForStatementInitializer) { var pos = getNodePos(); var flags = 0; switch (token()) { - case 112 /* VarKeyword */: + case 113 /* VarKeyword */: break; - case 118 /* LetKeyword */: + case 119 /* LetKeyword */: flags |= 1 /* Let */; break; - case 84 /* ConstKeyword */: + case 85 /* ConstKeyword */: flags |= 2 /* Const */; break; default: @@ -33642,7 +34853,7 @@ var ts; // this context. // The checker will then give an error that there is an empty declaration list. var declarations; - if (token() === 156 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 158 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { declarations = createMissingList(); } else { @@ -33667,7 +34878,7 @@ var ts; function parseFunctionDeclaration(pos, hasJSDoc, decorators, modifiers) { var savedAwaitContext = inAwaitContext(); var modifierFlags = ts.modifiersToFlags(modifiers); - parseExpected(97 /* FunctionKeyword */); + parseExpected(98 /* FunctionKeyword */); var asteriskToken = parseOptionalToken(41 /* 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(); @@ -33684,8 +34895,8 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseConstructorName() { - if (token() === 132 /* ConstructorKeyword */) { - return parseExpected(132 /* ConstructorKeyword */); + if (token() === 133 /* ConstructorKeyword */) { + return parseExpected(133 /* ConstructorKeyword */); } if (token() === 10 /* StringLiteral */ && lookAhead(nextToken) === 20 /* OpenParenToken */) { return tryParse(function () { @@ -33746,12 +34957,12 @@ var ts; var parameters = parseParameters(0 /* None */); var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); var body = parseFunctionBlockOrSemicolon(0 /* None */); - var node = kind === 167 /* GetAccessor */ + var node = kind === 169 /* GetAccessor */ ? factory.createGetAccessorDeclaration(decorators, modifiers, name, parameters, type, body) : factory.createSetAccessorDeclaration(decorators, modifiers, name, parameters, body); // Keep track of `typeParameters` (for both) and `type` (for setters) if they were parsed those indicate grammar errors node.typeParameters = typeParameters; - if (type && node.kind === 168 /* SetAccessor */) + if (type && node.kind === 170 /* SetAccessor */) node.type = type; return withJSDoc(finishNode(node, pos), hasJSDoc); } @@ -33790,7 +35001,7 @@ var ts; // 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 === 146 /* SetKeyword */ || idToken === 134 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 147 /* SetKeyword */ || idToken === 135 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along @@ -33800,7 +35011,7 @@ var ts; case 29 /* LessThanToken */: // Generic Method declaration case 53 /* ExclamationToken */: // Non-null assertion on property name case 58 /* ColonToken */: // Type Annotation for declaration - case 62 /* EqualsToken */: // Initializer for declaration + case 63 /* EqualsToken */: // Initializer for declaration case 57 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. return true; default: @@ -33815,7 +35026,7 @@ var ts; return false; } function parseDecoratorExpression() { - if (inAwaitContext() && token() === 130 /* AwaitKeyword */) { + if (inAwaitContext() && token() === 131 /* 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(); @@ -33845,7 +35056,7 @@ var ts; function tryParseModifier(permitInvalidConstAsModifier) { var pos = getNodePos(); var kind = token(); - if (token() === 84 /* ConstKeyword */ && permitInvalidConstAsModifier) { + if (token() === 85 /* 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)) { @@ -33876,10 +35087,10 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 129 /* AsyncKeyword */) { + if (token() === 130 /* AsyncKeyword */) { var pos = getNodePos(); nextToken(); - var modifier = finishNode(factory.createToken(129 /* AsyncKeyword */), pos); + var modifier = finishNode(factory.createToken(130 /* AsyncKeyword */), pos); modifiers = createNodeArray([modifier], pos); } return modifiers; @@ -33893,13 +35104,13 @@ var ts; var hasJSDoc = hasPrecedingJSDocComment(); var decorators = parseDecorators(); var modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true); - if (parseContextualModifier(134 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 167 /* GetAccessor */); + if (parseContextualModifier(135 /* GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 169 /* GetAccessor */); } - if (parseContextualModifier(146 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 168 /* SetAccessor */); + if (parseContextualModifier(147 /* SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 170 /* SetAccessor */); } - if (token() === 132 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { + if (token() === 133 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { var constructorDeclaration = tryParseConstructorDeclaration(pos, hasJSDoc, decorators, modifiers); if (constructorDeclaration) { return constructorDeclaration; @@ -33929,21 +35140,21 @@ var ts; } if (decorators || modifiers) { // treat this as a property declaration with a missing name. - var name = createMissingNode(78 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var name = createMissingNode(79 /* 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, 221 /* ClassExpression */); + return parseClassDeclarationOrExpression(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined, 223 /* ClassExpression */); } function parseClassDeclaration(pos, hasJSDoc, decorators, modifiers) { - return parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, 252 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, 254 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, kind) { var savedAwaitContext = inAwaitContext(); - parseExpected(83 /* ClassKeyword */); + parseExpected(84 /* 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(); @@ -33961,7 +35172,7 @@ var ts; members = createMissingList(); } setAwaitContext(savedAwaitContext); - var node = kind === 252 /* ClassDeclaration */ + var node = kind === 254 /* ClassDeclaration */ ? factory.createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) : factory.createClassExpression(decorators, modifiers, name, typeParameters, heritageClauses, members); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -33977,7 +35188,7 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 116 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 117 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); } function parseHeritageClauses() { // ClassTail[Yield,Await] : (Modified) See 14.5 @@ -33990,7 +35201,7 @@ var ts; function parseHeritageClause() { var pos = getNodePos(); var tok = token(); - ts.Debug.assert(tok === 93 /* ExtendsKeyword */ || tok === 116 /* ImplementsKeyword */); // isListElement() should ensure this. + ts.Debug.assert(tok === 94 /* ExtendsKeyword */ || tok === 117 /* ImplementsKeyword */); // isListElement() should ensure this. nextToken(); var types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(factory.createHeritageClause(tok, types), pos); @@ -34006,13 +35217,13 @@ var ts; parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */) : undefined; } function isHeritageClause() { - return token() === 93 /* ExtendsKeyword */ || token() === 116 /* ImplementsKeyword */; + return token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; } function parseClassMembers() { return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(117 /* InterfaceKeyword */); + parseExpected(118 /* InterfaceKeyword */); var name = parseIdentifier(); var typeParameters = parseTypeParameters(); var heritageClauses = parseHeritageClauses(); @@ -34021,11 +35232,11 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseTypeAliasDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(149 /* TypeKeyword */); + parseExpected(150 /* TypeKeyword */); var name = parseIdentifier(); var typeParameters = parseTypeParameters(); - parseExpected(62 /* EqualsToken */); - var type = token() === 136 /* IntrinsicKeyword */ && tryParse(parseKeywordAndNoDot) || parseType(); + parseExpected(63 /* EqualsToken */); + var type = token() === 137 /* IntrinsicKeyword */ && tryParse(parseKeywordAndNoDot) || parseType(); parseSemicolon(); var node = factory.createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -34042,7 +35253,7 @@ var ts; return withJSDoc(finishNode(factory.createEnumMember(name, initializer), pos), hasJSDoc); } function parseEnumDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(91 /* EnumKeyword */); + parseExpected(92 /* EnumKeyword */); var name = parseIdentifier(); var members; if (parseExpected(18 /* OpenBraceToken */)) { @@ -34081,7 +35292,7 @@ var ts; function parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers) { var flags = 0; var name; - if (token() === 154 /* GlobalKeyword */) { + if (token() === 155 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation name = parseIdentifier(); flags |= 1024 /* GlobalAugmentation */; @@ -34102,15 +35313,15 @@ var ts; } function parseModuleDeclaration(pos, hasJSDoc, decorators, modifiers) { var flags = 0; - if (token() === 154 /* GlobalKeyword */) { + if (token() === 155 /* GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers); } - else if (parseOptional(140 /* NamespaceKeyword */)) { + else if (parseOptional(141 /* NamespaceKeyword */)) { flags |= 16 /* Namespace */; } else { - parseExpected(139 /* ModuleKeyword */); + parseExpected(140 /* ModuleKeyword */); if (token() === 10 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers); } @@ -34118,7 +35329,7 @@ var ts; return parseModuleOrNamespaceDeclaration(pos, hasJSDoc, decorators, modifiers, flags); } function isExternalModuleReference() { - return token() === 143 /* RequireKeyword */ && + return token() === 144 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { @@ -34128,8 +35339,8 @@ var ts; return nextToken() === 43 /* SlashToken */; } function parseNamespaceExportDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(126 /* AsKeyword */); - parseExpected(140 /* NamespaceKeyword */); + parseExpected(127 /* AsKeyword */); + parseExpected(141 /* NamespaceKeyword */); var name = parseIdentifier(); parseSemicolon(); var node = factory.createNamespaceExportDeclaration(name); @@ -34139,7 +35350,7 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseImportDeclarationOrImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(99 /* ImportKeyword */); + parseExpected(100 /* 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; @@ -34147,7 +35358,7 @@ var ts; identifier = parseIdentifier(); } var isTypeOnly = false; - if (token() !== 153 /* FromKeyword */ && + if (token() !== 154 /* FromKeyword */ && (identifier === null || identifier === void 0 ? void 0 : identifier.escapedText) === "type" && (isIdentifier() || tokenAfterImportDefinitelyProducesImportDeclaration())) { isTypeOnly = true; @@ -34165,7 +35376,7 @@ var ts; token() === 18 /* OpenBraceToken */ // import { ) { importClause = parseImportClause(identifier, afterImportPos, isTypeOnly); - parseExpected(153 /* FromKeyword */); + parseExpected(154 /* FromKeyword */); } var moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -34178,10 +35389,10 @@ var ts; function tokenAfterImportedIdentifierDefinitelyProducesImportDeclaration() { // In `import id ___`, the current token decides whether to produce // an ImportDeclaration or ImportEqualsDeclaration. - return token() === 27 /* CommaToken */ || token() === 153 /* FromKeyword */; + return token() === 27 /* CommaToken */ || token() === 154 /* FromKeyword */; } function parseImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers, identifier, isTypeOnly) { - parseExpected(62 /* EqualsToken */); + parseExpected(63 /* EqualsToken */); var moduleReference = parseModuleReference(); parseSemicolon(); var node = factory.createImportEqualsDeclaration(decorators, modifiers, isTypeOnly, identifier, moduleReference); @@ -34200,7 +35411,7 @@ var ts; var namedBindings; if (!identifier || parseOptional(27 /* CommaToken */)) { - namedBindings = token() === 41 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(264 /* NamedImports */); + namedBindings = token() === 41 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(266 /* NamedImports */); } return finishNode(factory.createImportClause(isTypeOnly, identifier, namedBindings), pos); } @@ -34211,7 +35422,7 @@ var ts; } function parseExternalModuleReference() { var pos = getNodePos(); - parseExpected(143 /* RequireKeyword */); + parseExpected(144 /* RequireKeyword */); parseExpected(20 /* OpenParenToken */); var expression = parseModuleSpecifier(); parseExpected(21 /* CloseParenToken */); @@ -34235,7 +35446,7 @@ var ts; // * as ImportedBinding var pos = getNodePos(); parseExpected(41 /* AsteriskToken */); - parseExpected(126 /* AsKeyword */); + parseExpected(127 /* AsKeyword */); var name = parseIdentifier(); return finishNode(factory.createNamespaceImport(name), pos); } @@ -34248,16 +35459,16 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - var node = kind === 264 /* NamedImports */ + var node = kind === 266 /* NamedImports */ ? factory.createNamedImports(parseBracketedList(23 /* ImportOrExportSpecifiers */, parseImportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */)) : factory.createNamedExports(parseBracketedList(23 /* ImportOrExportSpecifiers */, parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */)); return finishNode(node, pos); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(270 /* ExportSpecifier */); + return parseImportOrExportSpecifier(272 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(265 /* ImportSpecifier */); + return parseImportOrExportSpecifier(267 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var pos = getNodePos(); @@ -34273,9 +35484,9 @@ var ts; var identifierName = parseIdentifierName(); var propertyName; var name; - if (token() === 126 /* AsKeyword */) { + if (token() === 127 /* AsKeyword */) { propertyName = identifierName; - parseExpected(126 /* AsKeyword */); + parseExpected(127 /* AsKeyword */); checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -34284,10 +35495,10 @@ var ts; else { name = identifierName; } - if (kind === 265 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 267 /* ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } - var node = kind === 265 /* ImportSpecifier */ + var node = kind === 267 /* ImportSpecifier */ ? factory.createImportSpecifier(propertyName, name) : factory.createExportSpecifier(propertyName, name); return finishNode(node, pos); @@ -34300,22 +35511,22 @@ var ts; setAwaitContext(/*value*/ true); var exportClause; var moduleSpecifier; - var isTypeOnly = parseOptional(149 /* TypeKeyword */); + var isTypeOnly = parseOptional(150 /* TypeKeyword */); var namespaceExportPos = getNodePos(); if (parseOptional(41 /* AsteriskToken */)) { - if (parseOptional(126 /* AsKeyword */)) { + if (parseOptional(127 /* AsKeyword */)) { exportClause = parseNamespaceExport(namespaceExportPos); } - parseExpected(153 /* FromKeyword */); + parseExpected(154 /* FromKeyword */); moduleSpecifier = parseModuleSpecifier(); } else { - exportClause = parseNamedImportsOrExports(268 /* NamedExports */); + exportClause = parseNamedImportsOrExports(270 /* 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() === 153 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(153 /* FromKeyword */); + if (token() === 154 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(154 /* FromKeyword */); moduleSpecifier = parseModuleSpecifier(); } } @@ -34328,11 +35539,11 @@ var ts; var savedAwaitContext = inAwaitContext(); setAwaitContext(/*value*/ true); var isExportEquals; - if (parseOptional(62 /* EqualsToken */)) { + if (parseOptional(63 /* EqualsToken */)) { isExportEquals = true; } else { - parseExpected(87 /* DefaultKeyword */); + parseExpected(88 /* DefaultKeyword */); } var expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -34348,7 +35559,7 @@ var ts; getImportMetaIfNecessary(sourceFile); } function isAnExternalModuleIndicatorNode(node) { - return hasModifierOfKind(node, 92 /* ExportKeyword */) + return hasModifierOfKind(node, 93 /* ExportKeyword */) || ts.isImportEqualsDeclaration(node) && ts.isExternalModuleReference(node.moduleReference) || ts.isImportDeclaration(node) || ts.isExportAssignment(node) @@ -34367,7 +35578,7 @@ var ts; return ts.some(node.modifiers, function (m) { return m.kind === kind; }); } function isImportMeta(node) { - return ts.isMetaProperty(node) && node.keywordToken === 99 /* ImportKeyword */ && node.name.escapedText === "meta"; + return ts.isMetaProperty(node) && node.keywordToken === 100 /* ImportKeyword */ && node.name.escapedText === "meta"; } var ParsingContext; (function (ParsingContext) { @@ -34435,7 +35646,13 @@ var ts; function parseJSDocNameReference() { var pos = getNodePos(); var hasBrace = parseOptional(18 /* OpenBraceToken */); + var p2 = getNodePos(); var entityName = parseEntityName(/* allowReservedWords*/ false); + while (token() === 80 /* PrivateIdentifier */) { + reScanHashToken(); // rescan #id as # id + nextTokenJSDoc(); // then skip the # + entityName = finishNode(factory.createJSDocMemberName(entityName, parseIdentifier()), p2); + } if (hasBrace) { parseExpectedJSDoc(19 /* CloseBraceToken */); } @@ -34499,7 +35716,10 @@ var ts; var tags; var tagsPos; var tagsEnd; + var linkEnd; + var commentsPos; var comments = []; + var parts = []; // + 3 for leading /**, - 5 in total for /** */ return scanner.scanRange(start + 3, length - 5, function () { // Initially we can parse out a tag. We also have seen a starting asterisk. @@ -34528,6 +35748,8 @@ var ts; case 59 /* AtToken */: if (state === 0 /* BeginningOfLine */ || state === 1 /* SawAsterisk */) { removeTrailingWhitespace(comments); + if (!commentsPos) + commentsPos = getNodePos(); addTag(parseTag(indent)); // 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 @@ -34570,6 +35792,22 @@ var ts; break; case 1 /* EndOfFileToken */: break loop; + case 18 /* OpenBraceToken */: + state = 2 /* SavingComments */; + var commentEnd = scanner.getStartPos(); + var linkStart = scanner.getTextPos() - 1; + var link = parseJSDocLink(linkStart); + if (link) { + if (!linkEnd) { + removeLeadingNewlines(comments); + } + parts.push(finishNode(factory.createJSDocText(comments.join("")), linkEnd !== null && linkEnd !== void 0 ? linkEnd : start, commentEnd)); + parts.push(link); + comments = []; + linkEnd = scanner.getTextPos(); + break; + } + // fallthrough if it's not a {@link sequence default: // 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 @@ -34580,9 +35818,14 @@ var ts; } nextTokenJSDoc(); } - removeLeadingNewlines(comments); removeTrailingWhitespace(comments); - return createJSDocComment(); + if (parts.length && comments.length) { + parts.push(finishNode(factory.createJSDocText(comments.join("")), linkEnd !== null && linkEnd !== void 0 ? linkEnd : start, commentsPos)); + } + if (parts.length && tags) + ts.Debug.assertIsDefined(commentsPos, "having parsed tags implies that the end of the comment span should be set"); + var tagsArray = tags && createNodeArray(tags, tagsPos, tagsEnd); + return finishNode(factory.createJSDocComment(parts.length ? createNodeArray(parts, start, commentsPos) : comments.length ? comments.join("") : undefined, tagsArray), start, end); }); function removeLeadingNewlines(comments) { while (comments.length && (comments[0] === "\n" || comments[0] === "\r")) { @@ -34594,11 +35837,6 @@ var ts; comments.pop(); } } - function createJSDocComment() { - var comment = comments.length ? comments.join("") : undefined; - var tagsArray = tags && createNodeArray(tags, tagsPos, tagsEnd); - return finishNode(factory.createJSDocComment(comment, tagsArray), start, end); - } function isNextNonwhitespaceTokenEndOfFile() { // We must use infinite lookahead, as there could be any number of newlines :( while (true) { @@ -34678,6 +35916,9 @@ var ts; case "readonly": tag = parseSimpleTag(start, factory.createJSDocReadonlyTag, tagName, margin, indentText); break; + case "override": + tag = parseSimpleTag(start, factory.createJSDocOverrideTag, tagName, margin, indentText); + break; case "deprecated": hasDeprecatedTag = true; tag = parseSimpleTag(start, factory.createJSDocDeprecatedTag, tagName, margin, indentText); @@ -34725,8 +35966,12 @@ var ts; return parseTagComments(margin, indentText.slice(margin)); } function parseTagComments(indent, initialMargin) { + var commentsPos = getNodePos(); var comments = []; + var parts = []; + var linkEnd; var state = 0 /* BeginningOfLine */; + var previousWhitespace = true; var margin; function pushComment(text) { if (!margin) { @@ -34752,7 +35997,9 @@ var ts; indent = 0; break; case 59 /* AtToken */: - if (state === 3 /* SavingBackticks */) { + if (state === 3 /* SavingBackticks */ + || state === 2 /* 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; } @@ -34776,13 +36023,18 @@ var ts; break; case 18 /* OpenBraceToken */: state = 2 /* SavingComments */; - if (lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenText() === "link"; })) { - pushComment(scanner.getTokenText()); - nextTokenJSDoc(); + var commentEnd = scanner.getStartPos(); + var linkStart = scanner.getTextPos() - 1; + var link = parseJSDocLink(linkStart); + if (link) { + parts.push(finishNode(factory.createJSDocText(comments.join("")), linkEnd !== null && linkEnd !== void 0 ? linkEnd : commentsPos, commentEnd)); + parts.push(link); + comments = []; + linkEnd = scanner.getTextPos(); + } + else { pushComment(scanner.getTokenText()); - nextTokenJSDoc(); } - pushComment(scanner.getTokenText()); break; case 61 /* BacktickToken */: if (state === 3 /* SavingBackticks */) { @@ -34809,15 +36061,67 @@ var ts; pushComment(scanner.getTokenText()); break; } + previousWhitespace = token() === 5 /* WhitespaceTrivia */; tok = nextTokenJSDoc(); } removeLeadingNewlines(comments); removeTrailingWhitespace(comments); - return comments.length === 0 ? undefined : comments.join(""); + if (parts.length) { + if (comments.length) { + parts.push(finishNode(factory.createJSDocText(comments.join("")), linkEnd !== null && linkEnd !== void 0 ? linkEnd : commentsPos)); + } + return createNodeArray(parts, commentsPos, scanner.getTextPos()); + } + else if (comments.length) { + return comments.join(""); + } + } + function isNextJSDocTokenWhitespace() { + var next = nextTokenJSDoc(); + return next === 5 /* WhitespaceTrivia */ || next === 4 /* NewLineTrivia */; + } + function parseJSDocLink(start) { + var linkType = tryParse(parseJSDocLinkPrefix); + if (!linkType) { + return undefined; + } + nextTokenJSDoc(); // start at token after link, then skip any whitespace + skipWhitespace(); + // parseEntityName logs an error for non-identifier, so create a MissingNode ourselves to avoid the error + var p2 = getNodePos(); + var name = ts.tokenIsIdentifierOrKeyword(token()) + ? parseEntityName(/*allowReservedWords*/ true) + : undefined; + if (name) { + while (token() === 80 /* 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 */) { + text.push(scanner.getTokenText()); + nextTokenJSDoc(); + } + var create = linkType === "link" ? factory.createJSDocLink + : linkType === "linkcode" ? factory.createJSDocLinkCode + : factory.createJSDocLinkPlain; + return finishNode(create(name, text.join("")), start, scanner.getTextPos()); + } + function parseJSDocLinkPrefix() { + skipWhitespaceOrAsterisk(); + if (token() === 18 /* OpenBraceToken */ + && nextTokenJSDoc() === 59 /* AtToken */ + && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc())) { + var kind = scanner.getTokenValue(); + if (kind === "link" || kind === "linkcode" || kind === "linkplain") { + return kind; + } + } } function parseUnknownTag(start, tagName, indent, indentText) { - var end = getNodePos(); - return finishNode(factory.createJSDocUnknownTag(tagName, parseTrailingTagComments(start, end, indent, indentText)), start, end); + return finishNode(factory.createJSDocUnknownTag(tagName, parseTrailingTagComments(start, getNodePos(), indent, indentText)), start); } function addTag(tag) { if (!tag) { @@ -34851,7 +36155,7 @@ var ts; if (isBracketed) { skipWhitespace(); // May have an optional default, e.g. '[foo = 42]' - if (parseOptionalToken(62 /* EqualsToken */)) { + if (parseOptionalToken(63 /* EqualsToken */)) { parseExpression(); } parseExpected(23 /* CloseBracketToken */); @@ -34860,9 +36164,9 @@ var ts; } function isObjectOrObjectArrayTypeReference(node) { switch (node.kind) { - case 145 /* ObjectKeyword */: + case 146 /* ObjectKeyword */: return true; - case 178 /* ArrayType */: + case 180 /* ArrayType */: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && !node.typeArguments; @@ -34873,11 +36177,11 @@ var ts; var isNameFirst = !typeExpression; skipWhitespaceOrAsterisk(); var _a = parseBracketNameInPropertyAndParamTag(), name = _a.name, isBracketed = _a.isBracketed; - skipWhitespace(); - if (isNameFirst) { + var indentText = skipWhitespaceOrAsterisk(); + if (isNameFirst && !lookAhead(parseJSDocLinkPrefix)) { typeExpression = tryParseTypeExpression(); } - var comment = parseTagComments(indent + scanner.getStartPos() - start); + var comment = parseTrailingTagComments(start, getNodePos(), indent, indentText); var nestedTypeLiteral = target !== 4 /* CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { typeExpression = nestedTypeLiteral; @@ -34894,12 +36198,12 @@ var ts; var child = void 0; var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 326 /* JSDocParameterTag */ || child.kind === 333 /* JSDocPropertyTag */) { + if (child.kind === 334 /* JSDocParameterTag */ || child.kind === 341 /* JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - var literal = finishNode(factory.createJSDocTypeLiteral(children, typeExpression.type.kind === 178 /* ArrayType */), pos); + var literal = finishNode(factory.createJSDocTypeLiteral(children, typeExpression.type.kind === 180 /* ArrayType */), pos); return finishNode(factory.createJSDocTypeExpression(literal), pos); } } @@ -34909,27 +36213,34 @@ var ts; parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } var typeExpression = tryParseTypeExpression(); - var end = getNodePos(); - return finishNode(factory.createJSDocReturnTag(tagName, typeExpression, parseTrailingTagComments(start, end, indent, indentText)), start, end); + return finishNode(factory.createJSDocReturnTag(tagName, typeExpression, parseTrailingTagComments(start, getNodePos(), indent, indentText)), start); } function parseTypeTag(start, tagName, indent, indentText) { if (ts.some(tags, ts.isJSDocTypeTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } var typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); - var end = getNodePos(); - var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, end, indent, indentText) : undefined; - return finishNode(factory.createJSDocTypeTag(tagName, typeExpression, comments), start, end); + var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, getNodePos(), indent, indentText) : undefined; + return finishNode(factory.createJSDocTypeTag(tagName, typeExpression, comments), start); } function parseSeeTag(start, tagName, indent, indentText) { - var nameExpression = parseJSDocNameReference(); - var end = getNodePos(); - var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, end, indent, indentText) : undefined; - return finishNode(factory.createJSDocSeeTag(tagName, nameExpression, comments), start, end); + var isLink = lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenValue() === "link"; }); + var nameExpression = isLink ? undefined : parseJSDocNameReference(); + var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, getNodePos(), indent, indentText) : undefined; + return finishNode(factory.createJSDocSeeTag(tagName, nameExpression, comments), start); } function parseAuthorTag(start, tagName, indent, indentText) { - var comments = parseAuthorNameAndEmail() + (parseTrailingTagComments(start, end, indent, indentText) || ""); - return finishNode(factory.createJSDocAuthorTag(tagName, comments || undefined), start); + var commentStart = getNodePos(); + var textOnly = parseAuthorNameAndEmail(); + var commentEnd = scanner.getStartPos(); + var comments = parseTrailingTagComments(start, commentEnd, indent, indentText); + if (!comments) { + commentEnd = scanner.getStartPos(); + } + var allParts = typeof comments !== "string" + ? createNodeArray(ts.concatenate([finishNode(textOnly, commentStart, commentEnd)], comments), commentStart) // cast away readonly + : textOnly.text + comments; + return finishNode(factory.createJSDocAuthorTag(tagName, allParts), start); } function parseAuthorNameAndEmail() { var comments = []; @@ -34950,17 +36261,15 @@ var ts; comments.push(scanner.getTokenText()); token = nextTokenJSDoc(); } - return comments.join(""); + return factory.createJSDocText(comments.join("")); } function parseImplementsTag(start, tagName, margin, indentText) { var className = parseExpressionWithTypeArgumentsForAugments(); - var end = getNodePos(); - return finishNode(factory.createJSDocImplementsTag(tagName, className, parseTrailingTagComments(start, end, margin, indentText)), start, end); + return finishNode(factory.createJSDocImplementsTag(tagName, className, parseTrailingTagComments(start, getNodePos(), margin, indentText)), start); } function parseAugmentsTag(start, tagName, margin, indentText) { var className = parseExpressionWithTypeArgumentsForAugments(); - var end = getNodePos(); - return finishNode(factory.createJSDocAugmentsTag(tagName, className, parseTrailingTagComments(start, end, margin, indentText)), start, end); + return finishNode(factory.createJSDocAugmentsTag(tagName, className, parseTrailingTagComments(start, getNodePos(), margin, indentText)), start); } function parseExpressionWithTypeArgumentsForAugments() { var usedBrace = parseOptional(18 /* OpenBraceToken */); @@ -34984,20 +36293,17 @@ var ts; return node; } function parseSimpleTag(start, createTag, tagName, margin, indentText) { - var end = getNodePos(); - return finishNode(createTag(tagName, parseTrailingTagComments(start, end, margin, indentText)), start, end); + return finishNode(createTag(tagName, parseTrailingTagComments(start, getNodePos(), margin, indentText)), start); } function parseThisTag(start, tagName, margin, indentText) { var typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); - var end = getNodePos(); - return finishNode(factory.createJSDocThisTag(tagName, typeExpression, parseTrailingTagComments(start, end, margin, indentText)), start, end); + return finishNode(factory.createJSDocThisTag(tagName, typeExpression, parseTrailingTagComments(start, getNodePos(), margin, indentText)), start); } function parseEnumTag(start, tagName, margin, indentText) { var typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); - var end = getNodePos(); - return finishNode(factory.createJSDocEnumTag(tagName, typeExpression, parseTrailingTagComments(start, end, margin, indentText)), start, end); + return finishNode(factory.createJSDocEnumTag(tagName, typeExpression, parseTrailingTagComments(start, getNodePos(), margin, indentText)), start); } function parseTypedefTag(start, tagName, indent, indentText) { var _a; @@ -35014,7 +36320,7 @@ var ts; var hasChildren = false; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { hasChildren = true; - if (child.kind === 329 /* JSDocTypeTag */) { + if (child.kind === 337 /* JSDocTypeTag */) { if (childTypeTag) { parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags); var lastError = ts.lastOrUndefined(parseDiagnostics); @@ -35032,7 +36338,7 @@ var ts; } } if (hasChildren) { - var isArrayType = typeExpression && typeExpression.type.kind === 178 /* ArrayType */; + var isArrayType = typeExpression && typeExpression.type.kind === 180 /* ArrayType */; var jsdocTypeLiteral = factory.createJSDocTypeLiteral(jsDocPropertyTags, isArrayType); typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? childTypeTag.typeExpression : @@ -35085,17 +36391,16 @@ var ts; var returnTag = tryParse(function () { if (parseOptionalJsdoc(59 /* AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 327 /* JSDocReturnTag */) { + if (tag && tag.kind === 335 /* JSDocReturnTag */) { return tag; } } }); var typeExpression = finishNode(factory.createJSDocSignature(/*typeParameters*/ undefined, parameters, returnTag), start); - var end = getNodePos(); if (!comment) { - comment = parseTrailingTagComments(start, end, indent, indentText); + comment = parseTrailingTagComments(start, getNodePos(), indent, indentText); } - return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start, end); + return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start); } function escapedTextsEqual(a, b) { while (!ts.isIdentifier(a) || !ts.isIdentifier(b)) { @@ -35120,7 +36425,7 @@ var ts; case 59 /* AtToken */: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 326 /* JSDocParameterTag */ || child.kind === 333 /* JSDocPropertyTag */) && + if (child && (child.kind === 334 /* JSDocParameterTag */ || child.kind === 341 /* JSDocPropertyTag */) && target !== 4 /* CallbackParameter */ && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; @@ -35139,7 +36444,7 @@ var ts; } seenAsterisk = true; break; - case 78 /* Identifier */: + case 79 /* Identifier */: canParseTag = false; break; case 1 /* EndOfFileToken */: @@ -35177,6 +36482,9 @@ var ts; function parseTemplateTagTypeParameter() { var typeParameterPos = getNodePos(); var name = parseJSDocIdentifierName(ts.Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces); + if (ts.nodeIsMissing(name)) { + return undefined; + } return finishNode(factory.createTypeParameterDeclaration(name, /*constraint*/ undefined, /*defaultType*/ undefined), typeParameterPos); } function parseTemplateTagTypeParameters() { @@ -35184,7 +36492,10 @@ var ts; var typeParameters = []; do { skipWhitespace(); - typeParameters.push(parseTemplateTagTypeParameter()); + var node = parseTemplateTagTypeParameter(); + if (node !== undefined) { + typeParameters.push(node); + } skipWhitespaceOrAsterisk(); } while (parseOptionalJsdoc(27 /* CommaToken */)); return createNodeArray(typeParameters, pos); @@ -35203,8 +36514,7 @@ var ts; // TODO: Consider only parsing a single type parameter if there is a constraint. var constraint = token() === 18 /* OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; var typeParameters = parseTemplateTagTypeParameters(); - var end = getNodePos(); - return finishNode(factory.createJSDocTemplateTag(tagName, constraint, typeParameters, parseTrailingTagComments(start, end, indent, indentText)), start, end); + return finishNode(factory.createJSDocTemplateTag(tagName, constraint, typeParameters, parseTrailingTagComments(start, getNodePos(), indent, indentText)), start); } function parseOptionalJsdoc(t) { if (token() === t) { @@ -35232,7 +36542,7 @@ var ts; } function parseJSDocIdentifierName(message) { if (!ts.tokenIsIdentifierOrKeyword(token())) { - return createMissingNode(78 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); + return createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); } identifierCount++; var pos = scanner.getTokenPos(); @@ -35405,7 +36715,7 @@ var ts; switch (node.kind) { case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - case 78 /* Identifier */: + case 79 /* Identifier */: return true; } return false; @@ -35879,7 +37189,7 @@ var ts; if (namedArgRegExCache.has(name)) { return namedArgRegExCache.get(name); } - var result = new RegExp("(\\s" + name + "\\s*=\\s*)('|\")(.+?)\\2", "im"); + var result = new RegExp("(\\s" + name + "\\s*=\\s*)(?:(?:'([^']*)')|(?:\"([^\"]*)\"))", "im"); namedArgRegExCache.set(name, result); return result; } @@ -35903,16 +37213,17 @@ var ts; return; // Missing required argument, don't parse } else if (matchResult) { + var value = matchResult[2] || matchResult[3]; if (arg.captureSpan) { - var startPos = range.pos + matchResult.index + matchResult[1].length + matchResult[2].length; + var startPos = range.pos + matchResult.index + matchResult[1].length + 1; argument[arg.name] = { - value: matchResult[3], + value: value, pos: startPos, - end: startPos + matchResult[3].length + end: startPos + value.length }; } else { - argument[arg.name] = matchResult[3]; + argument[arg.name] = value; } } } @@ -35928,7 +37239,7 @@ var ts; return addPragmaForMatch(pragmas, range, 2 /* SingleLine */, singleLine); } if (range.kind === 3 /* MultiLineCommentTrivia */) { - var multiLinePragmaRegEx = /\s*@(\S+)\s*(.*)\s*$/gim; // Defined inline since it uses the "g" flag, which keeps a persistent index (for iterating) + 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); @@ -35955,7 +37266,7 @@ var ts; return {}; if (!pragma.args) return {}; - var args = text.split(/\s+/); + var args = ts.trimString(text).split(/\s+/); var argMap = {}; for (var i = 0; i < pragma.args.length; i++) { var argument = pragma.args[i]; @@ -35974,10 +37285,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 78 /* Identifier */) { + if (lhs.kind === 79 /* Identifier */) { return lhs.escapedText === rhs.escapedText; } - if (lhs.kind === 107 /* ThisKeyword */) { + if (lhs.kind === 108 /* ThisKeyword */) { return true; } // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only @@ -36019,6 +37330,7 @@ var ts; ["es2018", "lib.es2018.d.ts"], ["es2019", "lib.es2019.d.ts"], ["es2020", "lib.es2020.d.ts"], + ["es2021", "lib.es2021.d.ts"], ["esnext", "lib.esnext.d.ts"], // Host only ["dom", "lib.dom.d.ts"], @@ -36058,14 +37370,17 @@ var ts; ["es2020.string", "lib.es2020.string.d.ts"], ["es2020.symbol.wellknown", "lib.es2020.symbol.wellknown.d.ts"], ["es2020.intl", "lib.es2020.intl.d.ts"], + ["es2021.promise", "lib.es2021.promise.d.ts"], + ["es2021.string", "lib.es2021.string.d.ts"], + ["es2021.weakref", "lib.es2021.weakref.d.ts"], ["esnext.array", "lib.es2019.array.d.ts"], ["esnext.symbol", "lib.es2019.symbol.d.ts"], ["esnext.asynciterable", "lib.es2018.asynciterable.d.ts"], ["esnext.intl", "lib.esnext.intl.d.ts"], ["esnext.bigint", "lib.es2020.bigint.d.ts"], - ["esnext.string", "lib.esnext.string.d.ts"], - ["esnext.promise", "lib.esnext.promise.d.ts"], - ["esnext.weakref", "lib.esnext.weakref.d.ts"] + ["esnext.string", "lib.es2021.string.d.ts"], + ["esnext.promise", "lib.es2021.promise.d.ts"], + ["esnext.weakref", "lib.es2021.weakref.d.ts"] ]; /** * An array of supported "lib" reference file names used to determine the order for inclusion @@ -36089,11 +37404,12 @@ var ts; fixedpollinginterval: ts.WatchFileKind.FixedPollingInterval, prioritypollinginterval: ts.WatchFileKind.PriorityPollingInterval, dynamicprioritypolling: ts.WatchFileKind.DynamicPriorityPolling, + fixedchunksizepolling: ts.WatchFileKind.FixedChunkSizePolling, usefsevents: ts.WatchFileKind.UseFsEvents, usefseventsonparentdirectory: ts.WatchFileKind.UseFsEventsOnParentDirectory, })), - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_DynamicPriorityPolling_UseFsEvents_UseFsEventsOnParentDirectory, + category: ts.Diagnostics.Watch_and_Build_Modes, + description: ts.Diagnostics.Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_DynamicPriorityPolling_FixedChunkSizePolling_UseFsEvents_UseFsEventsOnParentDirectory, }, { name: "watchDirectory", @@ -36101,9 +37417,10 @@ var ts; usefsevents: ts.WatchDirectoryKind.UseFsEvents, fixedpollinginterval: ts.WatchDirectoryKind.FixedPollingInterval, dynamicprioritypolling: ts.WatchDirectoryKind.DynamicPriorityPolling, + fixedchunksizepolling: ts.WatchDirectoryKind.FixedChunkSizePolling, })), - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling, + category: ts.Diagnostics.Watch_and_Build_Modes, + description: ts.Diagnostics.Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling_FixedChunkSizePolling, }, { name: "fallbackPolling", @@ -36111,14 +37428,15 @@ var ts; fixedinterval: ts.PollingWatchKind.FixedInterval, priorityinterval: ts.PollingWatchKind.PriorityInterval, dynamicpriority: ts.PollingWatchKind.DynamicPriority, + fixedchunksize: ts.PollingWatchKind.FixedChunkSize, })), - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority, + category: ts.Diagnostics.Watch_and_Build_Modes, + description: ts.Diagnostics.Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority_FixedChunkSize, }, { name: "synchronousWatchDirectory", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Watch_and_Build_Modes, description: ts.Diagnostics.Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively, }, { @@ -36130,7 +37448,7 @@ var ts; isFilePath: true, extraValidation: specToDiagnostic }, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Watch_and_Build_Modes, description: ts.Diagnostics.Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively, }, { @@ -36142,7 +37460,7 @@ var ts; isFilePath: true, extraValidation: specToDiagnostic }, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Watch_and_Build_Modes, description: ts.Diagnostics.Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively, }, ]; @@ -36166,6 +37484,7 @@ var ts; shortName: "w", type: "boolean", showInSimplifiedHelpView: true, + isCommandLineOnly: true, category: ts.Diagnostics.Command_line_Options, description: ts.Diagnostics.Watch_input_files, }, @@ -36173,49 +37492,50 @@ var ts; name: "preserveWatchOutput", type: "boolean", showInSimplifiedHelpView: false, - category: ts.Diagnostics.Command_line_Options, + category: ts.Diagnostics.Output_Formatting, description: ts.Diagnostics.Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen, }, { name: "listFiles", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Print_names_of_files_part_of_the_compilation }, { name: "explainFiles", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Print_names_of_files_and_the_reason_they_are_part_of_the_compilation - }, { + }, + { name: "listEmittedFiles", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Print_names_of_generated_files_part_of_the_compilation }, { name: "pretty", type: "boolean", showInSimplifiedHelpView: true, - category: ts.Diagnostics.Command_line_Options, + category: ts.Diagnostics.Output_Formatting, description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental }, { name: "traceResolution", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Enable_tracing_of_the_name_resolution_process }, { name: "diagnostics", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Show_diagnostic_information }, { name: "extendedDiagnostics", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Show_verbose_diagnostic_information }, { @@ -36223,7 +37543,7 @@ var ts; type: "string", isFilePath: true, paramType: ts.Diagnostics.FILE_OR_DIRECTORY, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Generates_a_CPU_profile }, { @@ -36232,14 +37552,14 @@ var ts; isFilePath: true, isCommandLineOnly: true, paramType: ts.Diagnostics.DIRECTORY, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Generates_an_event_trace_and_a_list_of_types }, { name: "incremental", shortName: "i", type: "boolean", - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Projects, description: ts.Diagnostics.Enable_incremental_compilation, transpileOptionValue: undefined }, @@ -36248,13 +37568,14 @@ var ts; type: "boolean", affectsSemanticDiagnostics: true, affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Watch_and_Build_Modes, description: ts.Diagnostics.Have_recompiles_in_incremental_and_watch_assume_that_changes_within_a_file_will_only_affect_files_directly_depending_on_it }, { name: "locale", type: "string", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Command_line_Options, + isCommandLineOnly: true, description: ts.Diagnostics.The_locale_used_when_displaying_messages_to_the_user_e_g_en_us }, ]; @@ -36272,6 +37593,7 @@ var ts; es2018: 5 /* ES2018 */, es2019: 6 /* ES2019 */, es2020: 7 /* ES2020 */, + es2021: 8 /* ES2021 */, esnext: 99 /* ESNext */, })), affectsSourceFile: true, @@ -36279,11 +37601,11 @@ var ts; affectsEmit: true, paramType: ts.Diagnostics.VERSION, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_or_ESNEXT, + category: ts.Diagnostics.Language_and_Environment, + description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_ES2021_or_ESNEXT, }; - /* @internal */ - ts.optionDeclarations = __spreadArray(__spreadArray([], ts.commonOptionsWithBuild), [ + var commandOptionsWithoutBuild = [ + // CommandLine only options { name: "all", type: "boolean", @@ -36360,7 +37682,7 @@ var ts; affectsEmit: true, paramType: ts.Diagnostics.KIND, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_es2020_or_ESNext, }, { @@ -36370,9 +37692,9 @@ var ts; name: "lib", type: ts.libMap }, - affectsModuleResolution: true, + affectsProgramStructure: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation, transpileOptionValue: undefined }, @@ -36381,13 +37703,13 @@ var ts; type: "boolean", affectsModuleResolution: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.JavaScript_Support, description: ts.Diagnostics.Allow_javascript_files_to_be_compiled }, { name: "checkJs", type: "boolean", - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.JavaScript_Support, description: ts.Diagnostics.Report_errors_in_js_files }, { @@ -36398,7 +37720,7 @@ var ts; affectsModuleResolution: true, paramType: ts.Diagnostics.KIND, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_react_react_jsx_or_react_jsxdev, }, { @@ -36407,7 +37729,7 @@ var ts; type: "boolean", affectsEmit: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Generates_corresponding_d_ts_file, transpileOptionValue: undefined }, @@ -36416,7 +37738,7 @@ var ts; type: "boolean", affectsEmit: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Generates_a_sourcemap_for_each_corresponding_d_ts_file, transpileOptionValue: undefined }, @@ -36424,7 +37746,7 @@ var ts; name: "emitDeclarationOnly", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Only_emit_d_ts_declaration_files, transpileOptionValue: undefined }, @@ -36433,7 +37755,7 @@ var ts; type: "boolean", affectsEmit: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Generates_corresponding_map_file, }, { @@ -36443,7 +37765,7 @@ var ts; isFilePath: true, paramType: ts.Diagnostics.FILE, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, transpileOptionValue: undefined }, @@ -36454,7 +37776,7 @@ var ts; isFilePath: true, paramType: ts.Diagnostics.DIRECTORY, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Redirect_output_structure_to_the_directory, }, { @@ -36463,7 +37785,7 @@ var ts; affectsEmit: true, isFilePath: true, paramType: ts.Diagnostics.LOCATION, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, }, { @@ -36471,7 +37793,7 @@ var ts; type: "boolean", affectsEmit: true, isTSConfigOnly: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Projects, description: ts.Diagnostics.Enable_project_compilation, transpileOptionValue: undefined }, @@ -36481,7 +37803,7 @@ var ts; affectsEmit: true, isFilePath: true, paramType: ts.Diagnostics.FILE, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Projects, description: ts.Diagnostics.Specify_file_to_store_incremental_compilation_information, transpileOptionValue: undefined }, @@ -36490,14 +37812,14 @@ var ts; type: "boolean", affectsEmit: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Do_not_emit_comments_to_output, }, { name: "noEmit", type: "boolean", showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Do_not_emit_outputs, transpileOptionValue: undefined }, @@ -36505,7 +37827,7 @@ var ts; name: "importHelpers", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Import_emit_helpers_from_tslib }, { @@ -36517,20 +37839,20 @@ var ts; })), affectsEmit: true, affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types }, { name: "downlevelIteration", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3 }, { name: "isolatedModules", type: "boolean", - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Interop_Constraints, description: ts.Diagnostics.Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule, transpileOptionValue: true }, @@ -36539,7 +37861,7 @@ var ts; name: "strict", type: "boolean", showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Enable_all_strict_type_checking_options }, { @@ -36548,7 +37870,7 @@ var ts; affectsSemanticDiagnostics: true, strictFlag: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type }, { @@ -36557,7 +37879,7 @@ var ts; affectsSemanticDiagnostics: true, strictFlag: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Enable_strict_null_checks }, { @@ -36566,7 +37888,7 @@ var ts; affectsSemanticDiagnostics: true, strictFlag: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Enable_strict_checking_of_function_types }, { @@ -36574,7 +37896,7 @@ var ts; type: "boolean", strictFlag: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Enable_strict_bind_call_and_apply_methods_on_functions }, { @@ -36583,25 +37905,43 @@ var ts; affectsSemanticDiagnostics: true, strictFlag: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Enable_strict_checking_of_property_initialization_in_classes }, + { + name: "strictOptionalProperties", + type: "boolean", + affectsSemanticDiagnostics: true, + strictFlag: true, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Type_Checking, + description: ts.Diagnostics.Enable_strict_checking_of_optional_properties + }, { name: "noImplicitThis", type: "boolean", affectsSemanticDiagnostics: true, strictFlag: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, }, + { + name: "useUnknownInCatchVariables", + type: "boolean", + affectsSemanticDiagnostics: true, + strictFlag: true, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Type_Checking, + description: ts.Diagnostics.Type_catch_clause_variables_as_unknown_instead_of_any, + }, { name: "alwaysStrict", type: "boolean", affectsSourceFile: true, strictFlag: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file }, // Additional Checks @@ -36610,7 +37950,7 @@ var ts; type: "boolean", affectsSemanticDiagnostics: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Additional_Checks, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Report_errors_on_unused_locals, }, { @@ -36618,7 +37958,7 @@ var ts; type: "boolean", affectsSemanticDiagnostics: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Additional_Checks, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Report_errors_on_unused_parameters, }, { @@ -36626,7 +37966,7 @@ var ts; type: "boolean", affectsSemanticDiagnostics: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Additional_Checks, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value }, { @@ -36635,7 +37975,7 @@ var ts; affectsBindDiagnostics: true, affectsSemanticDiagnostics: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Additional_Checks, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement }, { @@ -36643,14 +37983,22 @@ var ts; type: "boolean", affectsSemanticDiagnostics: true, showInSimplifiedHelpView: false, - category: ts.Diagnostics.Additional_Checks, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Include_undefined_in_index_signature_results }, + { + name: "noImplicitOverride", + type: "boolean", + affectsSemanticDiagnostics: true, + showInSimplifiedHelpView: false, + category: ts.Diagnostics.Type_Checking, + description: ts.Diagnostics.Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier + }, { name: "noPropertyAccessFromIndexSignature", type: "boolean", showInSimplifiedHelpView: false, - category: ts.Diagnostics.Additional_Checks, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Require_undeclared_properties_from_index_signatures_to_use_element_accesses }, // Module Resolution @@ -36662,7 +38010,7 @@ var ts; })), affectsModuleResolution: true, paramType: ts.Diagnostics.STRATEGY, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, }, { @@ -36670,7 +38018,7 @@ var ts; type: "string", affectsModuleResolution: true, isFilePath: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Base_directory_to_resolve_non_absolute_module_names }, { @@ -36680,7 +38028,7 @@ var ts; type: "object", affectsModuleResolution: true, isTSConfigOnly: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl, transpileOptionValue: undefined }, @@ -36696,7 +38044,7 @@ var ts; isFilePath: true }, affectsModuleResolution: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime, transpileOptionValue: undefined }, @@ -36709,7 +38057,7 @@ var ts; isFilePath: true }, affectsModuleResolution: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.List_of_folders_to_include_type_definitions_from }, { @@ -36719,9 +38067,9 @@ var ts; name: "types", type: "string" }, - affectsModuleResolution: true, + affectsProgramStructure: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation, transpileOptionValue: undefined }, @@ -36729,7 +38077,7 @@ var ts; name: "allowSyntheticDefaultImports", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Interop_Constraints, description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking }, { @@ -36738,20 +38086,20 @@ var ts; affectsSemanticDiagnostics: true, affectsEmit: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Interop_Constraints, description: ts.Diagnostics.Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for_all_imports_Implies_allowSyntheticDefaultImports }, { name: "preserveSymlinks", type: "boolean", - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Interop_Constraints, description: ts.Diagnostics.Do_not_resolve_the_real_path_of_symlinks, }, { name: "allowUmdGlobalAccess", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Allow_accessing_UMD_globals_from_modules, }, // Source Maps @@ -36760,7 +38108,7 @@ var ts; type: "string", affectsEmit: true, paramType: ts.Diagnostics.LOCATION, - category: ts.Diagnostics.Source_Map_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, }, { @@ -36768,21 +38116,21 @@ var ts; type: "string", affectsEmit: true, paramType: ts.Diagnostics.LOCATION, - category: ts.Diagnostics.Source_Map_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, }, { name: "inlineSourceMap", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Source_Map_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file }, { name: "inlineSources", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Source_Map_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap_to_be_set }, // Experimental @@ -36790,7 +38138,7 @@ var ts; name: "experimentalDecorators", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Experimental_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators }, { @@ -36798,20 +38146,20 @@ var ts; type: "boolean", affectsSemanticDiagnostics: true, affectsEmit: true, - category: ts.Diagnostics.Experimental_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators }, // Advanced { name: "jsxFactory", type: "string", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h }, { name: "jsxFragmentFactory", type: "string", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Specify_the_JSX_fragment_factory_function_to_use_when_targeting_react_JSX_emit_with_jsxFactory_compiler_option_is_specified_e_g_Fragment }, { @@ -36820,14 +38168,14 @@ var ts; affectsSemanticDiagnostics: true, affectsEmit: true, affectsModuleResolution: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react }, { name: "resolveJsonModule", type: "boolean", affectsModuleResolution: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Include_modules_imported_with_json_extension }, { @@ -36836,7 +38184,7 @@ var ts; affectsEmit: true, isFilePath: false, // for correct behaviour, please use outFile - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Backwards_Compatibility, paramType: ts.Diagnostics.FILE, description: ts.Diagnostics.Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file, transpileOptionValue: undefined @@ -36845,26 +38193,26 @@ var ts; name: "reactNamespace", type: "string", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react_JSX_emit }, { name: "skipDefaultLibCheck", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Completeness, description: ts.Diagnostics.Deprecated_Use_skipLibCheck_instead_Skip_type_checking_of_default_library_declaration_files }, { name: "charset", type: "string", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Backwards_Compatibility, description: ts.Diagnostics.The_character_set_of_the_input_files }, { name: "emitBOM", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files }, { @@ -36875,21 +38223,21 @@ var ts; })), affectsEmit: true, paramType: ts.Diagnostics.NEWLINE, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, }, { name: "noErrorTruncation", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Output_Formatting, description: ts.Diagnostics.Do_not_truncate_error_messages }, { name: "noLib", type: "boolean", - affectsModuleResolution: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Language_and_Environment, + affectsProgramStructure: true, description: ts.Diagnostics.Do_not_include_the_default_library_file_lib_d_ts, // We are not returning a sourceFile for lib file when asked by the program, // so pass --noLib to avoid reporting a file not found error. @@ -36899,7 +38247,7 @@ var ts; name: "noResolve", type: "boolean", affectsModuleResolution: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files, // We are not doing a full typecheck, we are not resolving the whole context, // so pass --noResolve to avoid reporting missing file errors. @@ -36909,56 +38257,56 @@ var ts; name: "stripInternal", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation, }, { name: "disableSizeLimit", type: "boolean", - affectsSourceFile: true, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Disable_size_limitations_on_JavaScript_projects + affectsProgramStructure: true, + category: ts.Diagnostics.Editor_Support, + description: ts.Diagnostics.JavaScript_Support }, { name: "disableSourceOfProjectReferenceRedirect", type: "boolean", isTSConfigOnly: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Projects, description: ts.Diagnostics.Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects }, { name: "disableSolutionSearching", type: "boolean", isTSConfigOnly: true, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Disable_solution_searching_for_this_project + category: ts.Diagnostics.Projects, + description: ts.Diagnostics.Projects }, { name: "disableReferencedProjectLoad", type: "boolean", isTSConfigOnly: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Projects, description: ts.Diagnostics.Disable_loading_referenced_projects }, { name: "noImplicitUseStrict", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Backwards_Compatibility, description: ts.Diagnostics.Do_not_emit_use_strict_directives_in_module_output }, { name: "noEmitHelpers", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Do_not_generate_custom_helper_functions_like_extends_in_compiled_output }, { name: "noEmitOnError", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, transpileOptionValue: undefined }, @@ -36966,7 +38314,7 @@ var ts; name: "preserveConstEnums", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code }, { @@ -36975,14 +38323,14 @@ var ts; affectsEmit: true, isFilePath: true, paramType: ts.Diagnostics.DIRECTORY, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Output_directory_for_generated_declaration_files, transpileOptionValue: undefined }, { name: "skipLibCheck", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Completeness, description: ts.Diagnostics.Skip_type_checking_of_declaration_files, }, { @@ -36990,7 +38338,7 @@ var ts; type: "boolean", affectsBindDiagnostics: true, affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Do_not_report_errors_on_unused_labels }, { @@ -36998,42 +38346,42 @@ var ts; type: "boolean", affectsBindDiagnostics: true, affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Do_not_report_errors_on_unreachable_code }, { name: "suppressExcessPropertyErrors", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Backwards_Compatibility, description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals, }, { name: "suppressImplicitAnyIndexErrors", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Backwards_Compatibility, description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, }, { name: "forceConsistentCasingInFileNames", type: "boolean", affectsModuleResolution: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Interop_Constraints, description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file }, { name: "maxNodeModuleJsDepth", type: "number", affectsModuleResolution: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.JavaScript_Support, description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files }, { name: "noStrictGenericChecks", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Backwards_Compatibility, description: ts.Diagnostics.Disable_strict_checking_of_generic_signatures_in_function_types, }, { @@ -37041,13 +38389,13 @@ var ts; type: "boolean", affectsSemanticDiagnostics: true, affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Emit_class_fields_with_Define_instead_of_Set, }, { name: "keyofStringsOnly", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Backwards_Compatibility, description: ts.Diagnostics.Resolve_keyof_to_string_valued_property_names_only_no_numbers_or_symbols, }, { @@ -37059,9 +38407,12 @@ var ts; name: "plugin", type: "object" }, - description: ts.Diagnostics.List_of_language_service_plugins + description: ts.Diagnostics.List_of_language_service_plugins, + category: ts.Diagnostics.Editor_Support, }, - ]); + ]; + /* @internal */ + ts.optionDeclarations = __spreadArray(__spreadArray([], ts.commonOptionsWithBuild), commandOptionsWithoutBuild); /* @internal */ ts.semanticDiagnosticsOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsSemanticDiagnostics; }); /* @internal */ @@ -37073,11 +38424,12 @@ var ts; return !!option.affectsSourceFile || !!option.affectsModuleResolution || !!option.affectsBindDiagnostics; }); /* @internal */ + ts.optionsAffectingProgramStructure = ts.optionDeclarations.filter(function (option) { return !!option.affectsProgramStructure; }); + /* @internal */ ts.transpileOptionValueCompilerOptions = ts.optionDeclarations.filter(function (option) { return ts.hasProperty(option, "transpileOptionValue"); }); - /* @internal */ - ts.buildOpts = __spreadArray(__spreadArray([], ts.commonOptionsWithBuild), [ + var commandOptionsOnlyBuild = [ { name: "verbose", shortName: "v", @@ -37105,7 +38457,9 @@ var ts; description: ts.Diagnostics.Delete_the_outputs_of_all_projects, type: "boolean" } - ]); + ]; + /* @internal */ + ts.buildOpts = __spreadArray(__spreadArray([], ts.commonOptionsWithBuild), commandOptionsOnlyBuild); /* @internal */ ts.typeAcquisitionDeclarations = [ { @@ -37159,6 +38513,10 @@ var ts; return optionsNameMapCache || (optionsNameMapCache = createOptionNameMap(ts.optionDeclarations)); } ts.getOptionsNameMap = getOptionsNameMap; + var compilerOptionsAlternateMode = { + diagnostic: ts.Diagnostics.Compiler_option_0_may_only_be_used_with_build, + getOptionsNameMap: getBuildOptionsNameMap + }; /* @internal */ ts.defaultInitCompilerOptions = { module: ts.ModuleKind.CommonJS, @@ -37192,13 +38550,13 @@ var ts; } /* @internal */ function parseCustomTypeOption(opt, value, errors) { - return convertJsonOptionOfCustomType(opt, trimString(value || ""), errors); + return convertJsonOptionOfCustomType(opt, ts.trimString(value || ""), errors); } ts.parseCustomTypeOption = parseCustomTypeOption; /* @internal */ function parseListTypeOption(opt, value, errors) { if (value === void 0) { value = ""; } - value = trimString(value); + value = ts.trimString(value); if (ts.startsWith(value, "-")) { return undefined; } @@ -37220,6 +38578,10 @@ var ts; return option.name; } function createUnknownOptionError(unknownOption, diagnostics, createDiagnostics, unknownOptionErrorText) { + var _a; + if ((_a = diagnostics.alternateMode) === null || _a === void 0 ? void 0 : _a.getOptionsNameMap().optionsNameMap.has(unknownOption.toLowerCase())) { + return createDiagnostics(diagnostics.alternateMode.diagnostic, unknownOption); + } var possibleOption = ts.getSpellingSuggestion(unknownOption, diagnostics.optionDeclarations, getOptionName); return possibleOption ? createDiagnostics(diagnostics.unknownDidYouMeanDiagnostic, unknownOptionErrorText || unknownOption, possibleOption.name) : @@ -37374,6 +38736,7 @@ var ts; } /*@internal*/ ts.compilerOptionsDidYouMeanDiagnostics = { + alternateMode: compilerOptionsAlternateMode, getOptionsNameMap: getOptionsNameMap, optionDeclarations: ts.optionDeclarations, unknownOptionDiagnostic: ts.Diagnostics.Unknown_compiler_option_0, @@ -37406,7 +38769,12 @@ var ts; function getBuildOptionsNameMap() { return buildOptionsNameMapCache || (buildOptionsNameMapCache = createOptionNameMap(ts.buildOpts)); } + var buildOptionsAlternateMode = { + diagnostic: ts.Diagnostics.Compiler_option_0_may_not_be_used_with_build, + getOptionsNameMap: getOptionsNameMap + }; var buildOptionsDidYouMeanDiagnostics = { + alternateMode: buildOptionsAlternateMode, getOptionsNameMap: getBuildOptionsNameMap, optionDeclarations: ts.buildOpts, unknownOptionDiagnostic: ts.Diagnostics.Unknown_build_option_0, @@ -37482,7 +38850,7 @@ var ts; function parseConfigFileTextToJson(fileName, jsonText) { var jsonSourceFile = ts.parseJsonText(fileName, jsonText); return { - config: convertToObject(jsonSourceFile, jsonSourceFile.parseDiagnostics), + config: convertConfigFileToObject(jsonSourceFile, jsonSourceFile.parseDiagnostics, /*reportOptionsErrors*/ false, /*optionsIterator*/ undefined), error: jsonSourceFile.parseDiagnostics.length ? jsonSourceFile.parseDiagnostics[0] : undefined }; } @@ -37572,7 +38940,8 @@ var ts; }, { name: "extends", - type: "string" + type: "string", + category: ts.Diagnostics.File_Management, }, { name: "references", @@ -37580,7 +38949,8 @@ var ts; element: { name: "references", type: "object" - } + }, + category: ts.Diagnostics.Projects, }, { name: "files", @@ -37588,7 +38958,8 @@ var ts; element: { name: "files", type: "string" - } + }, + category: ts.Diagnostics.File_Management, }, { name: "include", @@ -37596,7 +38967,8 @@ var ts; element: { name: "include", type: "string" - } + }, + category: ts.Diagnostics.File_Management, }, { name: "exclude", @@ -37604,7 +38976,8 @@ var ts; element: { name: "exclude", type: "string" - } + }, + category: ts.Diagnostics.File_Management, }, ts.compileOnSaveCommandLineOption ]) @@ -37612,11 +38985,31 @@ var ts; } return _tsconfigRootOptions; } + function convertConfigFileToObject(sourceFile, errors, reportOptionsErrors, optionsIterator) { + 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 !== 202 /* 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 + // array is a well-formed configuration object, made into an array element by stray characters. + if (ts.isArrayLiteralExpression(rootExpression)) { + var firstObject = ts.find(rootExpression.elements, ts.isObjectLiteralExpression); + if (firstObject) { + return convertToObjectWorker(sourceFile, firstObject, errors, /*returnValue*/ true, knownRootOptions, optionsIterator); + } + } + return {}; + } + return convertToObjectWorker(sourceFile, rootExpression, errors, /*returnValue*/ true, knownRootOptions, optionsIterator); + } /** * Convert the json syntax tree into the json value */ function convertToObject(sourceFile, errors) { - return convertToObjectWorker(sourceFile, errors, /*returnValue*/ true, /*knownRootOptions*/ undefined, /*jsonConversionNotifier*/ undefined); + var _a; + return convertToObjectWorker(sourceFile, (_a = sourceFile.statements[0]) === null || _a === void 0 ? void 0 : _a.expression, errors, /*returnValue*/ true, /*knownRootOptions*/ undefined, /*jsonConversionNotifier*/ undefined); } ts.convertToObject = convertToObject; /** @@ -37625,18 +39018,18 @@ var ts; * Otherwise it just checks the errors and returns undefined */ /*@internal*/ - function convertToObjectWorker(sourceFile, errors, returnValue, knownRootOptions, jsonConversionNotifier) { - if (!sourceFile.statements.length) { + function convertToObjectWorker(sourceFile, rootExpression, errors, returnValue, knownRootOptions, jsonConversionNotifier) { + if (!rootExpression) { return returnValue ? {} : undefined; } - return convertPropertyValueToJson(sourceFile.statements[0].expression, knownRootOptions); + return convertPropertyValueToJson(rootExpression, knownRootOptions); function isRootOptionMap(knownOptions) { return knownRootOptions && knownRootOptions.elementOptions === knownOptions; } function convertObjectLiteralExpressionToJson(node, knownOptions, extraKeyDiagnostics, parentOption) { var result = returnValue ? {} : undefined; var _loop_4 = function (element) { - if (element.kind !== 288 /* PropertyAssignment */) { + if (element.kind !== 290 /* PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); return "continue"; } @@ -37703,13 +39096,13 @@ var ts; function convertPropertyValueToJson(valueExpression, option) { var invalidReported; switch (valueExpression.kind) { - case 109 /* TrueKeyword */: + case 110 /* TrueKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return validateValue(/*value*/ true); - case 94 /* FalseKeyword */: + case 95 /* FalseKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return validateValue(/*value*/ false); - case 103 /* NullKeyword */: + case 104 /* 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 */: @@ -37730,13 +39123,13 @@ var ts; case 8 /* NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return validateValue(Number(valueExpression.text)); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: if (valueExpression.operator !== 40 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { break; // not valid JSON syntax } reportInvalidOptionValue(option && option.type !== "number"); return validateValue(-Number(valueExpression.operand.text)); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -37753,7 +39146,7 @@ var ts; return validateValue(convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined)); } - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return validateValue(convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element)); } @@ -37891,7 +39284,7 @@ var ts; if (ts.hasProperty(options, name)) { // tsconfig only options cannot be specified via command line, // so we can assume that only types that can appear here string | number | boolean - if (optionsNameMap.has(name) && optionsNameMap.get(name).category === ts.Diagnostics.Command_line_Options) { + if (optionsNameMap.has(name) && (optionsNameMap.get(name).category === ts.Diagnostics.Command_line_Options || optionsNameMap.get(name).category === ts.Diagnostics.Output_Formatting)) { return "continue"; } var value = options[name]; @@ -37957,13 +39350,11 @@ var ts; function makePadding(paddingLength) { return Array(paddingLength + 1).join(" "); } - function isAllowedOption(_a) { - var category = _a.category, name = _a.name; - // Skip options which do not have a category or have category `Command_line_Options` - // Exclude all possible `Advanced_Options` in tsconfig.json which were NOT defined in command line - return category !== undefined - && category !== ts.Diagnostics.Command_line_Options - && (category !== ts.Diagnostics.Advanced_Options || compilerOptionsMap.has(name)); + function isAllowedOptionForOutput(_a) { + var category = _a.category, name = _a.name, isCommandLineOnly = _a.isCommandLineOnly; + // Skip options which do not have a category or have categories which are more niche + var categoriesToSkip = [ts.Diagnostics.Command_line_Options, ts.Diagnostics.Editor_Support, ts.Diagnostics.Compiler_Diagnostics, ts.Diagnostics.Backwards_Compatibility, ts.Diagnostics.Watch_and_Build_Modes, ts.Diagnostics.Output_Formatting]; + return !isCommandLineOnly && category !== undefined && (!categoriesToSkip.includes(category) || compilerOptionsMap.has(name)); } function writeConfigurations() { // Filter applicable options to place in the file @@ -37971,7 +39362,7 @@ var ts; for (var _i = 0, optionDeclarations_1 = ts.optionDeclarations; _i < optionDeclarations_1.length; _i++) { var option = optionDeclarations_1[_i]; var category = option.category; - if (isAllowedOption(option)) { + if (isAllowedOptionForOutput(option)) { categorizedOptions.add(ts.getLocaleSpecificMessage(category), option); } } @@ -38188,6 +39579,7 @@ var ts; validatedFilesSpec: ts.filter(filesSpecs, ts.isString), validatedIncludeSpecs: validatedIncludeSpecs, validatedExcludeSpecs: validatedExcludeSpecs, + pathPatterns: undefined, // Initialized on first use }; } function getFileNames(basePath) { @@ -38301,14 +39693,14 @@ var ts; if (ownConfig.extendedConfigPath) { // copy the resolution stack so it is never reused between branches in potential diamond-problem scenarios. resolutionStack = resolutionStack.concat([resolvedPath]); - var extendedConfig = getExtendedConfig(sourceFile, ownConfig.extendedConfigPath, host, basePath, resolutionStack, errors, extendedConfigCache); + var extendedConfig = getExtendedConfig(sourceFile, ownConfig.extendedConfigPath, host, resolutionStack, errors, extendedConfigCache); if (extendedConfig && isSuccessfulParsedTsconfig(extendedConfig)) { var baseRaw_1 = extendedConfig.raw; var raw_1 = ownConfig.raw; + var relativeDifference_1; var setPropertyInRawIfNotUndefined = function (propertyName) { - var value = raw_1[propertyName] || baseRaw_1[propertyName]; - if (value) { - raw_1[propertyName] = value; + if (!raw_1[propertyName] && baseRaw_1[propertyName]) { + raw_1[propertyName] = ts.map(baseRaw_1[propertyName], function (path) { return ts.isRootedDiskPath(path) ? path : ts.combinePaths(relativeDifference_1 || (relativeDifference_1 = ts.convertToRelativePath(ts.getDirectoryPath(ownConfig.extendedConfigPath), basePath, ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames))), path); }); } }; setPropertyInRawIfNotUndefined("include"); @@ -38390,7 +39782,7 @@ var ts; } } }; - var json = convertToObjectWorker(sourceFile, errors, /*returnValue*/ true, getTsconfigRootOptionsMap(), optionsIterator); + var json = convertConfigFileToObject(sourceFile, errors, /*reportOptionsErrors*/ true, optionsIterator); if (!typeAcquisition) { if (typingOptionstypeAcquisition) { typeAcquisition = (typingOptionstypeAcquisition.enableAutoDiscovery !== undefined) ? @@ -38428,7 +39820,7 @@ var ts; errors.push(createDiagnostic(ts.Diagnostics.File_0_not_found, extendedConfig)); return undefined; } - function getExtendedConfig(sourceFile, extendedConfigPath, host, basePath, resolutionStack, errors, extendedConfigCache) { + function getExtendedConfig(sourceFile, extendedConfigPath, host, resolutionStack, errors, extendedConfigCache) { var _a; var path = host.useCaseSensitiveFileNames ? extendedConfigPath : ts.toFileNameLowerCase(extendedConfigPath); var value; @@ -38440,22 +39832,7 @@ var ts; else { extendedResult = readJsonConfigFile(extendedConfigPath, function (path) { return host.readFile(path); }); if (!extendedResult.parseDiagnostics.length) { - var extendedDirname = ts.getDirectoryPath(extendedConfigPath); - extendedConfig = parseConfig(/*json*/ undefined, extendedResult, host, extendedDirname, ts.getBaseFileName(extendedConfigPath), resolutionStack, errors, extendedConfigCache); - if (isSuccessfulParsedTsconfig(extendedConfig)) { - // Update the paths to reflect base path - var relativeDifference_1 = ts.convertToRelativePath(extendedDirname, basePath, ts.identity); - var updatePath_1 = function (path) { return ts.isRootedDiskPath(path) ? path : ts.combinePaths(relativeDifference_1, path); }; - var mapPropertiesInRawIfNotUndefined = function (propertyName) { - if (raw_2[propertyName]) { - raw_2[propertyName] = ts.map(raw_2[propertyName], updatePath_1); - } - }; - var raw_2 = extendedConfig.raw; - mapPropertiesInRawIfNotUndefined("include"); - mapPropertiesInRawIfNotUndefined("exclude"); - mapPropertiesInRawIfNotUndefined("files"); - } + extendedConfig = parseConfig(/*json*/ undefined, extendedResult, host, ts.getDirectoryPath(extendedConfigPath), ts.getBaseFileName(extendedConfigPath), resolutionStack, errors, extendedConfigCache); } if (extendedConfigCache) { extendedConfigCache.set(path, { extendedResult: extendedResult, extendedConfig: extendedConfig }); @@ -38600,9 +39977,6 @@ var ts; function convertJsonOptionOfListType(option, values, basePath, errors) { return ts.filter(ts.map(values, function (v) { return convertJsonOption(option.element, v, basePath, errors); }), function (v) { return !!v; }); } - function trimString(s) { - return typeof s.trim === "function" ? s.trim() : s.replace(/^[\s]+|[\s]+$/g, ""); - } /** * Tests for a path that ends in a recursive directory wildcard. * Matches **, \**, **\, and \**\, but not a**b. @@ -38615,34 +39989,6 @@ var ts; * \/?$ # matches an optional trailing directory separator at the end of the string. */ var invalidTrailingRecursionPattern = /(^|\/)\*\*\/?$/; - /** - * Tests for a path where .. appears after a recursive directory wildcard. - * Matches **\..\*, **\a\..\*, and **\.., but not ..\**\* - * - * NOTE: used \ in place of / above to avoid issues with multiline comments. - * - * Breakdown: - * (^|\/) # matches either the beginning of the string or a directory separator. - * \*\*\/ # matches a recursive directory wildcard "**" followed by a directory separator. - * (.*\/)? # optionally matches any number of characters followed by a directory separator. - * \.\. # matches a parent directory path component ".." - * ($|\/) # matches either the end of the string or a directory separator. - */ - var invalidDotDotAfterRecursiveWildcardPattern = /(^|\/)\*\*\/(.*\/)?\.\.($|\/)/; - /** - * Tests for a path containing a wildcard character in a directory component of the path. - * Matches \*\, \?\, and \a*b\, but not \a\ or \a\*. - * - * NOTE: used \ in place of / above to avoid issues with multiline comments. - * - * Breakdown: - * \/ # matches a directory separator. - * [^/]*? # matches any number of characters excluding directory separators (non-greedy). - * [*?] # matches either a wildcard character (* or ?) - * [^/]* # matches any number of characters excluding directory separators (greedy). - * \/ # matches a directory separator. - */ - var watchRecursivePattern = /\/[^/]*?[*?][^/]*\//; /** * Matches the portion of a wildcard path that does not contain wildcards. * Matches \a of \a\*, or \a\b\c of \a\b\c\?\d. @@ -38683,7 +40029,7 @@ var ts; // via wildcard of *.json kind var wildCardJsonFileMap = new ts.Map(); var validatedFilesSpec = configFileSpecs.validatedFilesSpec, validatedIncludeSpecs = configFileSpecs.validatedIncludeSpecs, validatedExcludeSpecs = configFileSpecs.validatedExcludeSpecs; - // Rather than requery this for each file and filespec, we query the supported extensions + // Rather than re-query this for each file and filespec, we query the supported extensions // once and store it on the expansion context. var supportedExtensions = ts.getSupportedExtensions(options, extraFileExtensions); var supportedExtensionsWithJsonIfResolveJsonModule = ts.getSuppoertedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions); @@ -38761,9 +40107,22 @@ var ts; return matchesExcludeWorker(pathToCheck, validatedExcludeSpecs, useCaseSensitiveFileNames, currentDirectory, basePath); } ts.isExcludedFile = isExcludedFile; + function invalidDotDotAfterRecursiveWildcard(s) { + // We used to use the regex /(^|\/)\*\*\/(.*\/)?\.\.($|\/)/ to check for this case, but + // in v8, that has polynomial performance because the recursive wildcard match - **/ - + // can be matched in many arbitrary positions when multiple are present, resulting + // in bad backtracking (and we don't care which is matched - just that some /.. segment + // comes after some **/ segment). + var wildcardIndex = ts.startsWith(s, "**/") ? 0 : s.indexOf("/**/"); + if (wildcardIndex === -1) { + return false; + } + var lastDotIndex = ts.endsWith(s, "/..") ? s.length : s.lastIndexOf("/../"); + return lastDotIndex > wildcardIndex; + } /* @internal */ function matchesExclude(pathToCheck, excludeSpecs, useCaseSensitiveFileNames, currentDirectory) { - return matchesExcludeWorker(pathToCheck, ts.filter(excludeSpecs, function (spec) { return !invalidDotDotAfterRecursiveWildcardPattern.test(spec); }), useCaseSensitiveFileNames, currentDirectory); + return matchesExcludeWorker(pathToCheck, ts.filter(excludeSpecs, function (spec) { return !invalidDotDotAfterRecursiveWildcard(spec); }), useCaseSensitiveFileNames, currentDirectory); } ts.matchesExclude = matchesExclude; function matchesExcludeWorker(pathToCheck, excludeSpecs, useCaseSensitiveFileNames, currentDirectory, basePath) { @@ -38796,7 +40155,7 @@ var ts; if (disallowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) { return [ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec]; } - else if (invalidDotDotAfterRecursiveWildcardPattern.test(spec)) { + else if (invalidDotDotAfterRecursiveWildcard(spec)) { return [ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec]; } } @@ -38857,9 +40216,18 @@ var ts; function getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames) { var match = wildcardDirectoryPattern.exec(spec); if (match) { + // We check this with a few `indexOf` calls because 3 `indexOf`/`lastIndexOf` calls is + // less algorithmically complex (roughly O(3n) worst-case) than the regex we used to use, + // \/[^/]*?[*?][^/]*\/ which was polynominal in v8, since arbitrary sequences of wildcard + // characters could match any of the central patterns, resulting in bad backtracking. + var questionWildcardIndex = spec.indexOf("?"); + var starWildcardIndex = spec.indexOf("*"); + var lastDirectorySeperatorIndex = spec.lastIndexOf(ts.directorySeparator); return { key: useCaseSensitiveFileNames ? match[0] : ts.toFileNameLowerCase(match[0]), - flags: watchRecursivePattern.test(spec) ? 1 /* Recursive */ : 0 /* None */ + flags: (questionWildcardIndex !== -1 && questionWildcardIndex < lastDirectorySeperatorIndex) + || (starWildcardIndex !== -1 && starWildcardIndex < lastDirectorySeperatorIndex) + ? 1 /* Recursive */ : 0 /* None */ }; } if (ts.isImplicitGlob(spec)) { @@ -39152,13 +40520,24 @@ var ts; * This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups * is assumed to be the same as root directory of the project. */ - function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference) { + function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, cache) { var traceEnabled = isTraceEnabled(options, host); if (redirectedReference) { options = redirectedReference.commandLine.options; } - var failedLookupLocations = []; - var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations }; + var containingDirectory = containingFile ? ts.getDirectoryPath(containingFile) : undefined; + var perFolderCache = containingDirectory ? cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference) : undefined; + var result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName); + if (result) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1, typeReferenceDirectiveName, containingFile); + if (redirectedReference) + trace(host, ts.Diagnostics.Using_compiler_options_of_project_reference_redirect_0, redirectedReference.sourceFile.fileName); + trace(host, ts.Diagnostics.Resolution_for_type_reference_directive_0_was_found_in_cache_from_location_1, typeReferenceDirectiveName, containingDirectory); + traceResult(result); + } + return result; + } var typeRoots = getEffectiveTypeRoots(options, host); if (traceEnabled) { if (containingFile === undefined) { @@ -39181,6 +40560,8 @@ var ts; trace(host, ts.Diagnostics.Using_compiler_options_of_project_reference_redirect_0, redirectedReference.sourceFile.fileName); } } + var failedLookupLocations = []; + var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache }; var resolved = primaryLookup(); var primary = true; if (!resolved) { @@ -39191,17 +40572,31 @@ var ts; if (resolved) { var fileName = resolved.fileName, packageId = resolved.packageId; var resolvedFileName = options.preserveSymlinks ? fileName : realPath(fileName, host, traceEnabled); - if (traceEnabled) { - if (packageId) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3, typeReferenceDirectiveName, resolvedFileName, ts.packageIdToString(packageId), primary); - } - else { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFileName, primary); - } + resolvedTypeReferenceDirective = { + primary: primary, + resolvedFileName: resolvedFileName, + originalPath: fileName === resolvedFileName ? undefined : fileName, + packageId: packageId, + isExternalLibraryImport: pathContainsNodeModules(fileName), + }; + } + result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations }; + perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, result); + if (traceEnabled) + traceResult(result); + return result; + function traceResult(result) { + var _a; + if (!((_a = result.resolvedTypeReferenceDirective) === null || _a === void 0 ? void 0 : _a.resolvedFileName)) { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); + } + else if (result.resolvedTypeReferenceDirective.packageId) { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3, typeReferenceDirectiveName, result.resolvedTypeReferenceDirective.resolvedFileName, ts.packageIdToString(result.resolvedTypeReferenceDirective.packageId), result.resolvedTypeReferenceDirective.primary); + } + else { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, result.resolvedTypeReferenceDirective.resolvedFileName, result.resolvedTypeReferenceDirective.primary); } - resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolvedFileName, packageId: packageId, isExternalLibraryImport: pathContainsNodeModules(fileName) }; } - return { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations }; function primaryLookup() { // Check primary library paths if (typeRoots && typeRoots.length) { @@ -39231,20 +40626,16 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); } - var result = void 0; + var result_4; if (!ts.isExternalModuleNameRelative(typeReferenceDirectiveName)) { var searchResult = loadModuleFromNearestNodeModulesDirectory(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, moduleResolutionState, /*cache*/ undefined, /*redirectedReference*/ undefined); - result = searchResult && searchResult.value; + result_4 = searchResult && searchResult.value; } else { var candidate = ts.normalizePathAndParts(ts.combinePaths(initialLocationForSecondaryLookup, typeReferenceDirectiveName)).path; - result = nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, /*onlyRecordFailures*/ false, moduleResolutionState, /*considerPackageJson*/ true); + result_4 = nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, /*onlyRecordFailures*/ false, moduleResolutionState, /*considerPackageJson*/ true); } - var resolvedFile = resolvedTypeScriptOnly(result); - if (!resolvedFile && traceEnabled) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); - } - return resolvedFile; + return resolvedTypeScriptOnly(result_4); } else { if (traceEnabled) { @@ -39299,22 +40690,21 @@ var ts; return result; } ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; - function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options) { - return createModuleResolutionCacheWithMaps(createCacheWithRedirects(options), createCacheWithRedirects(options), currentDirectory, getCanonicalFileName); - } - ts.createModuleResolutionCache = createModuleResolutionCache; /*@internal*/ function createCacheWithRedirects(options) { var ownMap = new ts.Map(); var redirectsMap = new ts.Map(); return { - ownMap: ownMap, + getOwnMap: getOwnMap, redirectsMap: redirectsMap, getOrCreateMapOfCacheRedirects: getOrCreateMapOfCacheRedirects, clear: clear, setOwnOptions: setOwnOptions, setOwnMap: setOwnMap }; + function getOwnMap() { + return ownMap; + } function setOwnOptions(newOptions) { options = newOptions; } @@ -39340,26 +40730,88 @@ var ts; } } ts.createCacheWithRedirects = createCacheWithRedirects; - /*@internal*/ - function createModuleResolutionCacheWithMaps(directoryToModuleNameMap, moduleNameToDirectoryMap, currentDirectory, getCanonicalFileName) { - return { getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, directoryToModuleNameMap: directoryToModuleNameMap, moduleNameToDirectoryMap: moduleNameToDirectoryMap }; + function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName) { + var cache; + return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear }; + function getPackageJsonInfo(packageJsonPath) { + return cache === null || cache === void 0 ? void 0 : cache.get(ts.toPath(packageJsonPath, currentDirectory, getCanonicalFileName)); + } + function setPackageJsonInfo(packageJsonPath, info) { + (cache || (cache = new ts.Map())).set(ts.toPath(packageJsonPath, currentDirectory, getCanonicalFileName), info); + } + function clear() { + cache = undefined; + } + } + function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) { + var cache = cacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference); + var result = cache.get(key); + if (!result) { + result = create(); + cache.set(key, result); + } + return result; + } + function updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap) { + if (!options.configFile) + return; + if (directoryToModuleNameMap.redirectsMap.size === 0) { + // The own map will be for projectCompilerOptions + ts.Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.redirectsMap.size === 0); + ts.Debug.assert(directoryToModuleNameMap.getOwnMap().size === 0); + ts.Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.getOwnMap().size === 0); + directoryToModuleNameMap.redirectsMap.set(options.configFile.path, directoryToModuleNameMap.getOwnMap()); + moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.redirectsMap.set(options.configFile.path, moduleNameToDirectoryMap.getOwnMap()); + } + else { + // Set correct own map + ts.Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.redirectsMap.size > 0); + var ref = { + sourceFile: options.configFile, + commandLine: { options: options } + }; + directoryToModuleNameMap.setOwnMap(directoryToModuleNameMap.getOrCreateMapOfCacheRedirects(ref)); + moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.setOwnMap(moduleNameToDirectoryMap.getOrCreateMapOfCacheRedirects(ref)); + } + directoryToModuleNameMap.setOwnOptions(options); + moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.setOwnOptions(options); + } + function createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap) { + return { + getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, + clear: clear, + update: update, + }; + function clear() { + directoryToModuleNameMap.clear(); + } + function update(options) { + updateRedirectsMap(options, directoryToModuleNameMap); + } function getOrCreateCacheForDirectory(directoryName, redirectedReference) { var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName); return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, function () { return new ts.Map(); }); } + } + function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options, directoryToModuleNameMap, moduleNameToDirectoryMap) { + var preDirectoryResolutionCache = 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; } }); + function clear() { + preDirectoryResolutionCache.clear(); + moduleNameToDirectoryMap.clear(); + packageJsonInfoCache.clear(); + } + function update(options) { + updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap); + } function getOrCreateCacheForModuleName(nonRelativeModuleName, redirectedReference) { ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName)); return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, nonRelativeModuleName, createPerModuleNameCache); } - function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) { - var cache = cacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference); - var result = cache.get(key); - if (!result) { - result = create(); - cache.set(key, result); - } - return result; - } function createPerModuleNameCache() { var directoryPathMap = new ts.Map(); return { get: get, set: set }; @@ -39426,7 +40878,17 @@ var ts; } } } - ts.createModuleResolutionCacheWithMaps = createModuleResolutionCacheWithMaps; + ts.createModuleResolutionCache = createModuleResolutionCache; + function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache, directoryToModuleNameMap) { + var preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options))); + packageJsonInfoCache || (packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName)); + return __assign(__assign(__assign({}, packageJsonInfoCache), preDirectoryResolutionCache), { clear: clear }); + function clear() { + preDirectoryResolutionCache.clear(); + packageJsonInfoCache.clear(); + } + } + ts.createTypeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache; function resolveModuleNameFromCache(moduleName, containingFile, cache) { var containingDirectory = ts.getDirectoryPath(containingFile); var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); @@ -39575,7 +41037,8 @@ var ts; } } function tryLoadModuleUsingPathsIfEligible(extensions, moduleName, loader, state) { - var _a = state.compilerOptions, baseUrl = _a.baseUrl, paths = _a.paths; + var _a; + var _b = state.compilerOptions, baseUrl = _b.baseUrl, paths = _b.paths, configFile = _b.configFile; if (paths && !ts.pathIsRelative(moduleName)) { if (state.traceEnabled) { if (baseUrl) { @@ -39584,7 +41047,8 @@ var ts; trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); } var baseDirectory = ts.getPathsBasePath(state.compilerOptions, state.host); // Always defined when 'paths' is defined - return tryLoadModuleUsingPaths(extensions, moduleName, baseDirectory, paths, loader, /*onlyRecordFailures*/ false, state); + var pathPatterns = (configFile === null || configFile === void 0 ? void 0 : configFile.configFileSpecs) ? (_a = configFile.configFileSpecs).pathPatterns || (_a.pathPatterns = ts.tryParsePatterns(paths)) : undefined; + return tryLoadModuleUsingPaths(extensions, moduleName, baseDirectory, paths, pathPatterns, loader, /*onlyRecordFailures*/ false, state); } } function tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, state) { @@ -39704,7 +41168,7 @@ var ts; var _a, _b; var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations }; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache }; var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); }); return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, state.resultFromCache); function tryResolve(extensions) { @@ -39764,7 +41228,7 @@ var ts; } var resolvedFromFile = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state); if (resolvedFromFile) { - var packageDirectory = considerPackageJson ? parseNodeModuleFromPath(resolvedFromFile) : undefined; + var packageDirectory = considerPackageJson ? parseNodeModuleFromPath(resolvedFromFile.path) : undefined; var packageInfo = packageDirectory ? getPackageJsonInfo(packageDirectory, /*onlyRecordFailures*/ false, state) : undefined; return withPackageId(packageInfo, resolvedFromFile); } @@ -39797,8 +41261,9 @@ var ts; * For `/node_modules/@types/foo/bar/index.d.ts` this is packageDirectory: "@types/foo" * For `/node_modules/foo/bar/index.d.ts` this is packageDirectory: "foo" */ + /* @internal */ function parseNodeModuleFromPath(resolved) { - var path = ts.normalizePath(resolved.path); + var path = ts.normalizePath(resolved); var idx = path.lastIndexOf(ts.nodeModulesPathPart); if (idx === -1) { return undefined; @@ -39810,6 +41275,7 @@ var ts; } return path.slice(0, indexAfterPackageName); } + ts.parseNodeModuleFromPath = parseNodeModuleFromPath; function moveToNextDirectorySeparatorIfAvailable(path, prevSeparatorIndex) { var nextSeparatorIndex = path.indexOf(ts.directorySeparator, prevSeparatorIndex + 1); return nextSeparatorIndex === -1 ? prevSeparatorIndex : nextSeparatorIndex; @@ -39893,21 +41359,43 @@ var ts; return withPackageId(packageInfo, loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJsonContent, versionPaths)); } function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) { + var _a, _b, _c; var host = state.host, traceEnabled = state.traceEnabled; - var directoryExists = !onlyRecordFailures && ts.directoryProbablyExists(packageDirectory, host); var packageJsonPath = ts.combinePaths(packageDirectory, "package.json"); + if (onlyRecordFailures) { + state.failedLookupLocations.push(packageJsonPath); + return undefined; + } + var existing = (_a = state.packageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.getPackageJsonInfo(packageJsonPath); + if (existing !== undefined) { + if (typeof existing !== "boolean") { + if (traceEnabled) + trace(host, ts.Diagnostics.File_0_exists_according_to_earlier_cached_lookups, packageJsonPath); + return existing; + } + else { + if (existing && traceEnabled) + trace(host, ts.Diagnostics.File_0_does_not_exist_according_to_earlier_cached_lookups, packageJsonPath); + state.failedLookupLocations.push(packageJsonPath); + return undefined; + } + } + var directoryExists = ts.directoryProbablyExists(packageDirectory, host); if (directoryExists && host.fileExists(packageJsonPath)) { var packageJsonContent = ts.readJson(packageJsonPath, host); if (traceEnabled) { trace(host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); } var versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state); - return { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths }; + var result = { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths }; + (_b = state.packageJsonInfoCache) === null || _b === void 0 ? void 0 : _b.setPackageJsonInfo(packageJsonPath, result); + return result; } else { if (directoryExists && traceEnabled) { trace(host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); } + (_c = state.packageJsonInfoCache) === null || _c === void 0 ? void 0 : _c.setPackageJsonInfo(packageJsonPath, directoryExists); // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results state.failedLookupLocations.push(packageJsonPath); } @@ -39958,7 +41446,7 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2, versionPaths.version, ts.version, moduleName); } - var result = tryLoadModuleUsingPaths(extensions, moduleName, candidate, versionPaths.paths, loader, onlyRecordFailuresForPackageFile || onlyRecordFailuresForIndex, state); + var result = tryLoadModuleUsingPaths(extensions, moduleName, candidate, versionPaths.paths, /*pathPatterns*/ undefined, loader, onlyRecordFailuresForPackageFile || onlyRecordFailuresForIndex, state); if (result) { return removeIgnoredPackageId(result.value); } @@ -40065,7 +41553,7 @@ var ts; trace(state.host, ts.Diagnostics.package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2, packageInfo.versionPaths.version, ts.version, rest); } var packageDirectoryExists = nodeModulesDirectoryExists && ts.directoryProbablyExists(packageDirectory, state.host); - var fromPaths = tryLoadModuleUsingPaths(extensions, rest, packageDirectory, packageInfo.versionPaths.paths, loader, !packageDirectoryExists, state); + var fromPaths = tryLoadModuleUsingPaths(extensions, rest, packageDirectory, packageInfo.versionPaths.paths, /*pathPatterns*/ undefined, loader, !packageDirectoryExists, state); if (fromPaths) { return fromPaths.value; } @@ -40073,8 +41561,9 @@ var ts; } return loader(extensions, candidate, !nodeModulesDirectoryExists, state); } - function tryLoadModuleUsingPaths(extensions, moduleName, baseDirectory, paths, loader, onlyRecordFailures, state) { - var matchedPattern = ts.matchPatternOrExact(ts.getOwnKeys(paths), moduleName); + function tryLoadModuleUsingPaths(extensions, moduleName, baseDirectory, paths, pathPatterns, loader, onlyRecordFailures, state) { + pathPatterns || (pathPatterns = ts.tryParsePatterns(paths)); + var matchedPattern = ts.matchPatternOrExact(pathPatterns, moduleName); if (matchedPattern) { var matchedStar_1 = ts.isString(matchedPattern) ? undefined : ts.matchedText(matchedPattern, moduleName); var matchedPatternText = ts.isString(matchedPattern) ? matchedPattern : ts.patternText(matchedPattern); @@ -40156,7 +41645,7 @@ var ts; function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) { var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations }; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache }; var containingDirectory = ts.getDirectoryPath(containingFile); var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); // No originalPath because classic resolution doesn't resolve realPath @@ -40197,13 +41686,13 @@ var ts; * This is the minumum code needed to expose that functionality; the rest is in the host. */ /* @internal */ - function loadModuleFromGlobalCache(moduleName, projectName, compilerOptions, host, globalCache) { + function loadModuleFromGlobalCache(moduleName, projectName, compilerOptions, host, globalCache, packageJsonInfoCache) { var traceEnabled = isTraceEnabled(compilerOptions, host); if (traceEnabled) { trace(host, ts.Diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2, projectName, moduleName, globalCache); } var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations }; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: packageJsonInfoCache }; var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, /*typesScopeOnly*/ false); return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, state.resultFromCache); } @@ -40249,26 +41738,26 @@ var ts; // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: return 0 /* NonInstantiated */; // 2. const enum declarations - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: if (ts.isEnumConst(node)) { return 2 /* ConstEnumOnly */; } break; // 3. non-exported import declarations - case 261 /* ImportDeclaration */: - case 260 /* ImportEqualsDeclaration */: + case 263 /* ImportDeclaration */: + case 262 /* ImportEqualsDeclaration */: if (!(ts.hasSyntacticModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } break; // 4. Export alias declarations pointing at only uninstantiated modules or things uninstantiated modules contain - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: var exportDeclaration = node; - if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 268 /* NamedExports */) { + if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 270 /* NamedExports */) { var state = 0 /* NonInstantiated */; for (var _i = 0, _a = exportDeclaration.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; @@ -40284,7 +41773,7 @@ var ts; } break; // 5. other uninstantiated module declarations. - case 257 /* ModuleBlock */: { + case 259 /* ModuleBlock */: { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateCached(n, visited); @@ -40306,9 +41795,9 @@ var ts; }); return state_1; } - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return getModuleInstanceState(node, visited); - case 78 /* Identifier */: + case 79 /* Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should // be considered the same as type alias if (node.isInJSDocNamespace) { @@ -40378,14 +41867,14 @@ var ts; } var binder = createBinder(); function bindSourceFile(file, options) { - ts.tracing.push("bind" /* Bind */, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("bind" /* Bind */, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeBind"); ts.perfLogger.logStartBindFile("" + file.fileName); binder(file, options); ts.perfLogger.logStopBindFile(); ts.performance.mark("afterBind"); ts.performance.measure("Bind", "beforeBind", "afterBind"); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } ts.bindSourceFile = bindSourceFile; function createBinder() { @@ -40424,6 +41913,7 @@ var ts; var classifiableNames; var unreachableFlow = { flags: 1 /* Unreachable */ }; var reportedUnreachableFlow = { flags: 1 /* 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) * If so, the node _must_ be in the current file (as that's the only way anything could have traversed to it to yield it as the error node) @@ -40506,7 +41996,7 @@ var ts; // 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 === 266 /* ExportAssignment */) { + if (node.kind === 268 /* ExportAssignment */) { return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; } var name = ts.getNameOfDeclaration(node); @@ -40515,7 +42005,7 @@ var ts; var moduleName = ts.getTextOfIdentifierOrLiteral(name); return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); } - if (name.kind === 158 /* ComputedPropertyName */) { + if (name.kind === 160 /* ComputedPropertyName */) { var nameExpression = name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteralLike(nameExpression)) { @@ -40524,11 +42014,9 @@ var ts; if (ts.isSignedNumericLiteral(nameExpression)) { return ts.tokenToString(nameExpression.operator) + nameExpression.operand.text; } - ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); - return ts.getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); - } - if (ts.isWellKnownSymbolSyntactically(name)) { - return ts.getPropertyNameForKnownSymbolName(ts.idText(name.name)); + else { + ts.Debug.fail("Only computed properties with literal names have declaration names"); + } } if (ts.isPrivateIdentifier(name)) { // containingClass exists because private names only allowed inside classes @@ -40543,36 +42031,36 @@ var ts; return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 166 /* Constructor */: + case 168 /* Constructor */: return "__constructor" /* Constructor */; - case 174 /* FunctionType */: - case 169 /* CallSignature */: - case 313 /* JSDocSignature */: + case 176 /* FunctionType */: + case 171 /* CallSignature */: + case 317 /* JSDocSignature */: return "__call" /* Call */; - case 175 /* ConstructorType */: - case 170 /* ConstructSignature */: + case 177 /* ConstructorType */: + case 172 /* ConstructSignature */: return "__new" /* New */; - case 171 /* IndexSignature */: + case 173 /* IndexSignature */: return "__index" /* Index */; - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: return "__export" /* ExportStar */; - case 297 /* SourceFile */: + case 299 /* SourceFile */: // json file should behave as // module.exports = ... return "export=" /* ExportEquals */; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */) { // module.exports = ... return "export=" /* ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 308 /* JSDocFunctionType */: + case 311 /* JSDocFunctionType */: return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); - case 160 /* Parameter */: + case 162 /* 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 === 308 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); + ts.Debug.assert(node.parent.kind === 311 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); var functionType = node.parent; var index = functionType.parameters.indexOf(node); return "arg" + index; @@ -40672,7 +42160,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 === 266 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 268 /* ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; messageNeedsName_1 = false; multipleDefaultExports_1 = true; @@ -40711,7 +42199,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = !!(ts.getCombinedModifierFlags(node) & 1 /* Export */) || jsdocTreatAsExported(node); if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 270 /* ExportSpecifier */ || (node.kind === 260 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 272 /* ExportSpecifier */ || (node.kind === 262 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -40800,7 +42288,7 @@ var ts; // 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 !== 209 /* ArrowFunction */) { + if (node.kind !== 211 /* ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -40833,7 +42321,7 @@ var ts; } // We create a return control flow graph for IIFEs and constructors. For constructors // we use the return control flow graph in strict property initialization checks. - currentReturnTarget = isIIFE || node.kind === 166 /* Constructor */ || (ts.isInJSFile(node) && (node.kind === 251 /* FunctionDeclaration */ || node.kind === 208 /* FunctionExpression */)) ? createBranchLabel() : undefined; + currentReturnTarget = isIIFE || node.kind === 168 /* Constructor */ || (ts.isInJSFile(node) && (node.kind === 253 /* FunctionDeclaration */ || node.kind === 210 /* FunctionExpression */)) ? createBranchLabel() : undefined; currentExceptionTarget = undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; @@ -40848,13 +42336,14 @@ var ts; node.flags |= 512 /* HasExplicitReturn */; node.endFlowNode = currentFlow; } - if (node.kind === 297 /* SourceFile */) { + if (node.kind === 299 /* SourceFile */) { node.flags |= emitFlags; + node.endFlowNode = currentFlow; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 166 /* Constructor */ || (ts.isInJSFile(node) && (node.kind === 251 /* FunctionDeclaration */ || node.kind === 208 /* FunctionExpression */))) { + if (node.kind === 168 /* Constructor */ || (ts.isInJSFile(node) && (node.kind === 253 /* FunctionDeclaration */ || node.kind === 210 /* FunctionExpression */))) { node.returnFlowNode = currentFlow; } } @@ -40881,8 +42370,8 @@ var ts; blockScopeContainer = savedBlockScopeContainer; } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 251 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 251 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 253 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 253 /* FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -40905,59 +42394,59 @@ var ts; inAssignmentPattern = saveInAssignmentPattern; return; } - if (node.kind >= 232 /* FirstStatement */ && node.kind <= 248 /* LastStatement */ && !options.allowUnreachableCode) { + if (node.kind >= 234 /* FirstStatement */ && node.kind <= 250 /* LastStatement */ && !options.allowUnreachableCode) { node.flowNode = currentFlow; } switch (node.kind) { - case 236 /* WhileStatement */: + case 238 /* WhileStatement */: bindWhileStatement(node); break; - case 235 /* DoStatement */: + case 237 /* DoStatement */: bindDoStatement(node); break; - case 237 /* ForStatement */: + case 239 /* ForStatement */: bindForStatement(node); break; - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 234 /* IfStatement */: + case 236 /* IfStatement */: bindIfStatement(node); break; - case 242 /* ReturnStatement */: - case 246 /* ThrowStatement */: + case 244 /* ReturnStatement */: + case 248 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 241 /* BreakStatement */: - case 240 /* ContinueStatement */: + case 243 /* BreakStatement */: + case 242 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 247 /* TryStatement */: + case 249 /* TryStatement */: bindTryStatement(node); break; - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: bindSwitchStatement(node); break; - case 258 /* CaseBlock */: + case 260 /* CaseBlock */: bindCaseBlock(node); break; - case 284 /* CaseClause */: + case 286 /* CaseClause */: bindCaseClause(node); break; - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: bindExpressionStatement(node); break; - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: bindLabeledStatement(node); break; - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: if (ts.isDestructuringAssignment(node)) { // Carry over whether we are in an assignment pattern to // binary expressions that could actually be an initializer @@ -40967,47 +42456,47 @@ var ts; } bindBinaryExpressionFlow(node); break; - case 210 /* DeleteExpression */: + case 212 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: bindAccessExpressionFlow(node); break; - case 203 /* CallExpression */: + case 205 /* CallExpression */: bindCallExpressionFlow(node); break; - case 225 /* NonNullExpression */: + case 227 /* NonNullExpression */: bindNonNullExpressionFlow(node); break; - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 325 /* JSDocEnumTag */: + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + case 333 /* JSDocEnumTag */: bindJSDocTypeAlias(node); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 297 /* SourceFile */: { + case 299 /* SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; } - case 230 /* Block */: - case 257 /* ModuleBlock */: + case 232 /* Block */: + case 259 /* ModuleBlock */: bindEachFunctionsFirst(node.statements); break; - case 198 /* BindingElement */: + case 200 /* BindingElement */: bindBindingElementFlow(node); break; - case 200 /* ObjectLiteralExpression */: - case 199 /* ArrayLiteralExpression */: - case 288 /* PropertyAssignment */: - case 220 /* SpreadElement */: + case 202 /* ObjectLiteralExpression */: + case 201 /* ArrayLiteralExpression */: + case 290 /* PropertyAssignment */: + case 222 /* 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; @@ -41021,32 +42510,32 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 78 /* Identifier */: - case 79 /* PrivateIdentifier */: - case 107 /* ThisKeyword */: - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 79 /* Identifier */: + case 80 /* PrivateIdentifier */: + case 108 /* ThisKeyword */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: return containsNarrowableReference(expr); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return hasNarrowableArgument(expr); - case 207 /* ParenthesizedExpression */: - case 225 /* NonNullExpression */: + case 209 /* ParenthesizedExpression */: + case 227 /* NonNullExpression */: return isNarrowingExpression(expr.expression); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return expr.operator === 53 /* ExclamationToken */ && isNarrowingExpression(expr.operand); - case 211 /* TypeOfExpression */: + case 213 /* TypeOfExpression */: return isNarrowingExpression(expr.expression); } return false; } function isNarrowableReference(expr) { - return expr.kind === 78 /* Identifier */ || expr.kind === 79 /* PrivateIdentifier */ || expr.kind === 107 /* ThisKeyword */ || expr.kind === 105 /* SuperKeyword */ || - (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) || - ts.isBinaryExpression(expr) && expr.operatorToken.kind === 27 /* CommaToken */ && isNarrowableReference(expr.right) || - ts.isElementAccessExpression(expr) && ts.isStringOrNumericLiteralLike(expr.argumentExpression) && isNarrowableReference(expr.expression) || - ts.isAssignmentExpression(expr) && isNarrowableReference(expr.left); + 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.isElementAccessExpression(expr) && ts.isStringOrNumericLiteralLike(expr.argumentExpression) && isNarrowableReference(expr.expression) + || ts.isAssignmentExpression(expr) && isNarrowableReference(expr.left); } function containsNarrowableReference(expr) { return isNarrowableReference(expr) || ts.isOptionalChain(expr) && containsNarrowableReference(expr.expression); @@ -41060,7 +42549,7 @@ var ts; } } } - if (expr.expression.kind === 201 /* PropertyAccessExpression */ && + if (expr.expression.kind === 203 /* PropertyAccessExpression */ && containsNarrowableReference(expr.expression.expression)) { return true; } @@ -41074,10 +42563,10 @@ var ts; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 62 /* EqualsToken */: - case 74 /* BarBarEqualsToken */: - case 75 /* AmpersandAmpersandEqualsToken */: - case 76 /* QuestionQuestionEqualsToken */: + case 63 /* EqualsToken */: + case 75 /* BarBarEqualsToken */: + case 76 /* AmpersandAmpersandEqualsToken */: + case 77 /* QuestionQuestionEqualsToken */: return containsNarrowableReference(expr.left); case 34 /* EqualsEqualsToken */: case 35 /* ExclamationEqualsToken */: @@ -41085,9 +42574,9 @@ var ts; case 37 /* ExclamationEqualsEqualsToken */: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 101 /* InstanceOfKeyword */: + case 102 /* InstanceOfKeyword */: return isNarrowableOperand(expr.left); - case 100 /* InKeyword */: + case 101 /* InKeyword */: return isNarrowableInOperands(expr.left, expr.right); case 27 /* CommaToken */: return isNarrowingExpression(expr.right); @@ -41096,11 +42585,11 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: switch (expr.operatorToken.kind) { - case 62 /* EqualsToken */: + case 63 /* EqualsToken */: return isNarrowableOperand(expr.left); case 27 /* CommaToken */: return isNarrowableOperand(expr.right); @@ -41134,8 +42623,8 @@ var ts; if (!expression) { return flags & 32 /* TrueCondition */ ? antecedent : unreachableFlow; } - if ((expression.kind === 109 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || - expression.kind === 94 /* FalseKeyword */ && flags & 32 /* TrueCondition */) && + if ((expression.kind === 110 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || + expression.kind === 95 /* FalseKeyword */ && flags & 32 /* TrueCondition */) && !ts.isExpressionOfOptionalChainRoot(expression) && !ts.isNullishCoalesce(expression.parent)) { return unreachableFlow; } @@ -41174,26 +42663,26 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 234 /* IfStatement */: - case 236 /* WhileStatement */: - case 235 /* DoStatement */: + case 236 /* IfStatement */: + case 238 /* WhileStatement */: + case 237 /* DoStatement */: return parent.expression === node; - case 237 /* ForStatement */: - case 217 /* ConditionalExpression */: + case 239 /* ForStatement */: + case 219 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 207 /* ParenthesizedExpression */) { + if (node.kind === 209 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 214 /* PrefixUnaryExpression */ && node.operator === 53 /* ExclamationToken */) { + else if (node.kind === 216 /* PrefixUnaryExpression */ && node.operator === 53 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 216 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || + return node.kind === 218 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 56 /* BarBarToken */ || node.operatorToken.kind === 60 /* QuestionQuestionToken */); } @@ -41240,7 +42729,7 @@ var ts; } function setContinueTarget(node, target) { var label = activeLabelList; - while (label && node.parent.kind === 245 /* LabeledStatement */) { + while (label && node.parent.kind === 247 /* LabeledStatement */) { label.continueTarget = target; label = label.next; node = node.parent; @@ -41291,12 +42780,12 @@ var ts; bind(node.expression); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 239 /* ForOfStatement */) { + if (node.kind === 241 /* ForOfStatement */) { bind(node.awaitModifier); } addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 250 /* VariableDeclarationList */) { + if (node.initializer.kind !== 252 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -41318,7 +42807,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 242 /* ReturnStatement */) { + if (node.kind === 244 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -41335,7 +42824,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 241 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 243 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -41440,7 +42929,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 285 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 287 /* 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. @@ -41488,9 +42977,9 @@ var ts; function maybeBindExpressionFlowIfCall(node) { // A top level or LHS of 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 === 203 /* CallExpression */) { + if (node.kind === 205 /* CallExpression */) { var call = node; - if (ts.isDottedName(call.expression) && call.expression.kind !== 105 /* SuperKeyword */) { + if (call.expression.kind !== 106 /* SuperKeyword */ && ts.isDottedName(call.expression)) { currentFlow = createFlowCall(currentFlow, call); } } @@ -41514,7 +43003,7 @@ var ts; currentFlow = finishFlowLabel(postStatementLabel); } function bindDestructuringTargetFlow(node) { - if (node.kind === 216 /* BinaryExpression */ && node.operatorToken.kind === 62 /* EqualsToken */) { + if (node.kind === 218 /* BinaryExpression */ && node.operatorToken.kind === 63 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -41525,10 +43014,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowMutation(16 /* Assignment */, currentFlow, node); } - else if (node.kind === 199 /* ArrayLiteralExpression */) { + else if (node.kind === 201 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 220 /* SpreadElement */) { + if (e.kind === 222 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -41536,16 +43025,16 @@ var ts; } } } - else if (node.kind === 200 /* ObjectLiteralExpression */) { + else if (node.kind === 202 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 288 /* PropertyAssignment */) { + if (p.kind === 290 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 289 /* ShorthandPropertyAssignment */) { + else if (p.kind === 291 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 290 /* SpreadAssignment */) { + else if (p.kind === 292 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -41553,7 +43042,7 @@ var ts; } function bindLogicalLikeExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 75 /* AmpersandAmpersandEqualsToken */) { + if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 76 /* AmpersandAmpersandEqualsToken */) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -41610,128 +43099,102 @@ var ts; } bindAssignmentTargetFlow(node.left); } - var BindBinaryExpressionFlowState; - (function (BindBinaryExpressionFlowState) { - BindBinaryExpressionFlowState[BindBinaryExpressionFlowState["BindThenBindChildren"] = 0] = "BindThenBindChildren"; - BindBinaryExpressionFlowState[BindBinaryExpressionFlowState["MaybeBindLeft"] = 1] = "MaybeBindLeft"; - BindBinaryExpressionFlowState[BindBinaryExpressionFlowState["BindToken"] = 2] = "BindToken"; - BindBinaryExpressionFlowState[BindBinaryExpressionFlowState["BindRight"] = 3] = "BindRight"; - BindBinaryExpressionFlowState[BindBinaryExpressionFlowState["FinishBind"] = 4] = "FinishBind"; - })(BindBinaryExpressionFlowState || (BindBinaryExpressionFlowState = {})); - function bindBinaryExpressionFlow(node) { - var workStacks = { - expr: [node], - state: [1 /* MaybeBindLeft */], - inStrictMode: [undefined], - parent: [undefined], - }; - var stackIndex = 0; - while (stackIndex >= 0) { - node = workStacks.expr[stackIndex]; - switch (workStacks.state[stackIndex]) { - case 0 /* BindThenBindChildren */: { - // This state is used only when recuring, to emulate the work that `bind` does before - // reaching `bindChildren`. A normal call to `bindBinaryExpressionFlow` will already have done this work. - ts.setParent(node, parent); - var saveInStrictMode = inStrictMode; - bindWorker(node); - var saveParent = parent; - parent = node; - advanceState(1 /* MaybeBindLeft */, saveInStrictMode, saveParent); - break; - } - case 1 /* MaybeBindLeft */: { - var operator = node.operatorToken.kind; - // TODO: bindLogicalExpression is recursive - if we want to handle deeply nested `&&` expressions - // 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 - if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */ || - ts.isLogicalOrCoalescingAssignmentOperator(operator)) { - if (isTopLevelLogicalExpression(node)) { - var postExpressionLabel = createBranchLabel(); - bindLogicalLikeExpression(node, postExpressionLabel, postExpressionLabel); - currentFlow = finishFlowLabel(postExpressionLabel); - } - else { - bindLogicalLikeExpression(node, currentTrueTarget, currentFalseTarget); - } - completeNode(); - } - else { - advanceState(2 /* BindToken */); - maybeBind(node.left); - } - break; + function createBindBinaryExpressionFlow() { + return ts.createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, /*foldState*/ undefined); + function onEnter(node, state) { + if (state) { + state.stackIndex++; + // Emulate the work that `bind` does before reaching `bindChildren`. A normal call to + // `bindBinaryExpressionFlow` will already have done this work. + ts.setParent(node, parent); + var saveInStrictMode = inStrictMode; + bindWorker(node); + var saveParent = parent; + parent = node; + state.skip = false; + state.inStrictModeStack[state.stackIndex] = saveInStrictMode; + state.parentStack[state.stackIndex] = saveParent; + } + else { + state = { + stackIndex: 0, + skip: false, + inStrictModeStack: [undefined], + parentStack: [undefined] + }; + } + // TODO: bindLogicalExpression is recursive - if we want to handle deeply nested `&&` expressions + // 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 */ || + ts.isLogicalOrCoalescingAssignmentOperator(operator)) { + if (isTopLevelLogicalExpression(node)) { + var postExpressionLabel = createBranchLabel(); + bindLogicalLikeExpression(node, postExpressionLabel, postExpressionLabel); + currentFlow = finishFlowLabel(postExpressionLabel); } - case 2 /* BindToken */: { - if (node.operatorToken.kind === 27 /* CommaToken */) { - maybeBindExpressionFlowIfCall(node.left); - } - advanceState(3 /* BindRight */); - maybeBind(node.operatorToken); - break; + else { + bindLogicalLikeExpression(node, currentTrueTarget, currentFalseTarget); } - case 3 /* BindRight */: { - advanceState(4 /* FinishBind */); - maybeBind(node.right); - break; + state.skip = true; + } + return state; + } + function onLeft(left, state, _node) { + if (!state.skip) { + return maybeBind(left); + } + } + function onOperator(operatorToken, state, node) { + if (!state.skip) { + if (operatorToken.kind === 27 /* CommaToken */) { + maybeBindExpressionFlowIfCall(node.left); } - case 4 /* FinishBind */: { - var operator = node.operatorToken.kind; - if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { - bindAssignmentTargetFlow(node.left); - if (operator === 62 /* EqualsToken */ && node.left.kind === 202 /* ElementAccessExpression */) { - var elementAccess = node.left; - if (isNarrowableOperand(elementAccess.expression)) { - currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node); - } + bind(operatorToken); + } + } + function onRight(right, state, _node) { + if (!state.skip) { + return maybeBind(right); + } + } + function onExit(node, state) { + if (!state.skip) { + var operator = node.operatorToken.kind; + if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { + bindAssignmentTargetFlow(node.left); + if (operator === 63 /* EqualsToken */ && node.left.kind === 204 /* ElementAccessExpression */) { + var elementAccess = node.left; + if (isNarrowableOperand(elementAccess.expression)) { + currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node); } } - completeNode(); - break; } - default: return ts.Debug.fail("Invalid state " + workStacks.state[stackIndex] + " for bindBinaryExpressionFlow"); } - } - /** - * Note that `advanceState` sets the _current_ head state, and that `maybeBind` potentially pushes on a new - * head state; so `advanceState` must be called before any `maybeBind` during a state's execution. - */ - function advanceState(state, isInStrictMode, parent) { - workStacks.state[stackIndex] = state; - if (isInStrictMode !== undefined) { - workStacks.inStrictMode[stackIndex] = isInStrictMode; + var savedInStrictMode = state.inStrictModeStack[state.stackIndex]; + var savedParent = state.parentStack[state.stackIndex]; + if (savedInStrictMode !== undefined) { + inStrictMode = savedInStrictMode; } - if (parent !== undefined) { - workStacks.parent[stackIndex] = parent; + if (savedParent !== undefined) { + parent = savedParent; } + state.skip = false; + state.stackIndex--; } - function completeNode() { - if (workStacks.inStrictMode[stackIndex] !== undefined) { - inStrictMode = workStacks.inStrictMode[stackIndex]; - parent = workStacks.parent[stackIndex]; - } - stackIndex--; - } - /** - * If `node` is a BinaryExpression, adds it to the local work stack, otherwise recursively binds it - */ function maybeBind(node) { if (node && ts.isBinaryExpression(node) && !ts.isDestructuringAssignment(node)) { - stackIndex++; - workStacks.expr[stackIndex] = node; - workStacks.state[stackIndex] = 0 /* BindThenBindChildren */; - workStacks.inStrictMode[stackIndex] = undefined; - workStacks.parent[stackIndex] = undefined; - } - else { - bind(node); + return node; } + bind(node); } } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 201 /* PropertyAccessExpression */) { + if (node.expression.kind === 203 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -41788,7 +43251,7 @@ var ts; } function bindJSDocTypeAlias(node) { ts.setParent(node.tagName, node); - if (node.kind !== 325 /* JSDocEnumTag */ && node.fullName) { + if (node.kind !== 333 /* JSDocEnumTag */ && node.fullName) { ts.setParent(node.fullName, node); ts.setParentRecursive(node.fullName, /*incremental*/ false); } @@ -41796,7 +43259,7 @@ var ts; function bindJSDocClassTag(node) { bindEachChild(node); var host = ts.getHostSignatureFromJSDoc(node); - if (host && host.kind !== 165 /* MethodDeclaration */) { + if (host && host.kind !== 167 /* MethodDeclaration */) { addDeclarationToSymbol(host.symbol, host, 32 /* Class */); } } @@ -41809,15 +43272,15 @@ var ts; } function bindOptionalChainRest(node) { switch (node.kind) { - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: bind(node.questionDotToken); bind(node.name); break; - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: bind(node.questionDotToken); bind(node.argumentExpression); break; - case 203 /* CallExpression */: + case 205 /* CallExpression */: bind(node.questionDotToken); bindEach(node.typeArguments); bindEach(node.arguments); @@ -41882,19 +43345,19 @@ 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 === 208 /* FunctionExpression */ || expr.kind === 209 /* ArrowFunction */) { + if (expr.kind === 210 /* FunctionExpression */ || expr.kind === 211 /* ArrowFunction */) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); } else { bindEachChild(node); - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { currentFlow = createFlowCall(currentFlow, node); } } } - if (node.expression.kind === 201 /* PropertyAccessExpression */) { + if (node.expression.kind === 203 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (ts.isIdentifier(propertyAccess.name) && isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node); @@ -41903,54 +43366,54 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 221 /* ClassExpression */: - case 252 /* ClassDeclaration */: - case 255 /* EnumDeclaration */: - case 200 /* ObjectLiteralExpression */: - case 177 /* TypeLiteral */: - case 312 /* JSDocTypeLiteral */: - case 281 /* JsxAttributes */: + case 223 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 257 /* EnumDeclaration */: + case 202 /* ObjectLiteralExpression */: + case 179 /* TypeLiteral */: + case 316 /* JSDocTypeLiteral */: + case 283 /* JsxAttributes */: return 1 /* IsContainer */; - case 253 /* InterfaceDeclaration */: + case 255 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 256 /* ModuleDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 190 /* MappedType */: + case 258 /* ModuleDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 192 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 297 /* SourceFile */: + case 299 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } // falls through - case 166 /* Constructor */: - case 251 /* FunctionDeclaration */: - case 164 /* MethodSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 169 /* CallSignature */: - case 313 /* JSDocSignature */: - case 308 /* JSDocFunctionType */: - case 174 /* FunctionType */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: - case 175 /* ConstructorType */: + case 168 /* Constructor */: + case 253 /* FunctionDeclaration */: + case 166 /* MethodSignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 171 /* CallSignature */: + case 317 /* JSDocSignature */: + case 311 /* JSDocFunctionType */: + case 176 /* FunctionType */: + case 172 /* ConstructSignature */: + case 173 /* IndexSignature */: + case 177 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 257 /* ModuleBlock */: + case 259 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 287 /* CatchClause */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 258 /* CaseBlock */: + case 289 /* CatchClause */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 260 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 230 /* Block */: + case 232 /* 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 @@ -41983,45 +43446,45 @@ 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 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 297 /* SourceFile */: + case 299 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 221 /* ClassExpression */: - case 252 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 254 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 177 /* TypeLiteral */: - case 312 /* JSDocTypeLiteral */: - case 200 /* ObjectLiteralExpression */: - case 253 /* InterfaceDeclaration */: - case 281 /* JsxAttributes */: + case 179 /* TypeLiteral */: + case 316 /* JSDocTypeLiteral */: + case 202 /* ObjectLiteralExpression */: + case 255 /* InterfaceDeclaration */: + case 283 /* 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 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 313 /* JSDocSignature */: - case 171 /* IndexSignature */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 308 /* JSDocFunctionType */: - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 254 /* TypeAliasDeclaration */: - case 190 /* MappedType */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 317 /* JSDocSignature */: + case 173 /* IndexSignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 311 /* JSDocFunctionType */: + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + case 256 /* TypeAliasDeclaration */: + case 192 /* 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 @@ -42068,15 +43531,13 @@ var ts; var pattern = void 0; if (node.name.kind === 10 /* StringLiteral */) { var text = node.name.text; - if (ts.hasZeroOrOneAsteriskCharacter(text)) { - pattern = ts.tryParsePattern(text); - } - else { + 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 */); - file.patternAmbientModules = ts.append(file.patternAmbientModules, pattern && { pattern: pattern, symbol: symbol }); + file.patternAmbientModules = ts.append(file.patternAmbientModules, pattern && !ts.isString(pattern) ? { pattern: pattern, symbol: symbol } : undefined); } } else { @@ -42122,7 +43583,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 === 290 /* SpreadAssignment */ || prop.name.kind !== 78 /* Identifier */) { + if (prop.kind === 292 /* SpreadAssignment */ || prop.name.kind !== 79 /* Identifier */) { continue; } var identifier = prop.name; @@ -42134,7 +43595,7 @@ var ts; // 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 === 288 /* PropertyAssignment */ || prop.kind === 289 /* ShorthandPropertyAssignment */ || prop.kind === 165 /* MethodDeclaration */ + var currentKind = prop.kind === 290 /* PropertyAssignment */ || prop.kind === 291 /* ShorthandPropertyAssignment */ || prop.kind === 167 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.escapedText); @@ -42166,10 +43627,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 297 /* SourceFile */: + case 299 /* SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -42194,9 +43655,9 @@ var ts; var saveCurrentFlow = currentFlow; for (var _i = 0, delayedTypeAliases_1 = delayedTypeAliases; _i < delayedTypeAliases_1.length; _i++) { var typeAlias = delayedTypeAliases_1[_i]; - var host = ts.getJSDocHost(typeAlias); - container = (host && ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1 /* IsContainer */); })) || file; - blockScopeContainer = (host && ts.getEnclosingBlockScopeContainer(host)) || file; + var host = typeAlias.parent.parent; + container = ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1 /* IsContainer */); }) || file; + blockScopeContainer = ts.getEnclosingBlockScopeContainer(host) || file; currentFlow = initFlowNode({ flags: 2 /* Start */ }); parent = typeAlias; bind(typeAlias.typeExpression); @@ -42237,7 +43698,7 @@ var ts; container = oldContainer; } } - else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 78 /* Identifier */) { + else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 79 /* Identifier */) { parent = typeAlias.parent; bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); } @@ -42262,11 +43723,11 @@ var ts; !ts.isIdentifierName(node)) { // strict mode identifiers if (inStrictMode && - node.originalKeywordKind >= 116 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 124 /* LastFutureReservedWord */) { + node.originalKeywordKind >= 117 /* FirstFutureReservedWord */ && + node.originalKeywordKind <= 125 /* LastFutureReservedWord */) { file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); } - else if (node.originalKeywordKind === 130 /* AwaitKeyword */) { + else if (node.originalKeywordKind === 131 /* 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))); } @@ -42274,7 +43735,7 @@ var ts; 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 === 124 /* YieldKeyword */ && node.flags & 8192 /* YieldContext */) { + else if (node.originalKeywordKind === 125 /* YieldKeyword */ && node.flags & 8192 /* YieldContext */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node))); } } @@ -42316,7 +43777,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 78 /* Identifier */) { + if (inStrictMode && node.expression.kind === 79 /* 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); @@ -42327,7 +43788,7 @@ var ts; return ts.isIdentifier(node) && (node.escapedText === "eval" || node.escapedText === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 78 /* Identifier */) { + if (name && name.kind === 79 /* 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 @@ -42368,8 +43829,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 297 /* SourceFile */ && - blockScopeContainer.kind !== 256 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 299 /* SourceFile */ && + blockScopeContainer.kind !== 258 /* ModuleDeclaration */ && !ts.isFunctionLike(blockScopeContainer)) { // We check first if the name is inside class declaration or class expression; if so give explicit message // otherwise report generic error message. @@ -42464,7 +43925,7 @@ 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 > 156 /* LastToken */) { + if (node.kind > 158 /* LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -42526,7 +43987,7 @@ var ts; function bindWorker(node) { switch (node.kind) { /* Strict mode checks */ - case 78 /* Identifier */: + case 79 /* 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. @@ -42539,18 +44000,24 @@ var ts; break; } // falls through - case 107 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 289 /* ShorthandPropertyAssignment */)) { + case 108 /* ThisKeyword */: + if (currentFlow && (ts.isExpression(node) || parent.kind === 291 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkContextualIdentifier(node); - case 105 /* SuperKeyword */: + case 159 /* QualifiedName */: + if (currentFlow && ts.isPartOfTypeQuery(node)) { + node.flowNode = currentFlow; + } + break; + case 228 /* MetaProperty */: + case 106 /* SuperKeyword */: node.flowNode = currentFlow; break; - case 79 /* PrivateIdentifier */: + case 80 /* PrivateIdentifier */: return checkPrivateIdentifier(node); - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: var expr = node; if (currentFlow && isNarrowableReference(expr)) { expr.flowNode = currentFlow; @@ -42565,7 +44032,7 @@ var ts; declareSymbol(file.locals, /*parent*/ undefined, expr.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 111550 /* FunctionScopedVariableExcludes */); } break; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: var specialKind = ts.getAssignmentDeclarationKind(node); switch (specialKind) { case 1 /* ExportsProperty */: @@ -42601,78 +44068,78 @@ var ts; ts.Debug.fail("Unknown binary expression special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return checkStrictModeCatchClause(node); - case 210 /* DeleteExpression */: + case 212 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 243 /* WithStatement */: + case 245 /* WithStatement */: return checkStrictModeWithStatement(node); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return checkStrictModeLabeledStatement(node); - case 187 /* ThisType */: + case 189 /* ThisType */: seenThisKeyword = true; return; - case 172 /* TypePredicate */: + case 174 /* TypePredicate */: break; // Binding the children will handle everything - case 159 /* TypeParameter */: + case 161 /* TypeParameter */: return bindTypeParameter(node); - case 160 /* Parameter */: + case 162 /* Parameter */: return bindParameter(node); - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 198 /* BindingElement */: + case 200 /* BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: return bindPropertyWorker(node); - case 288 /* PropertyAssignment */: - case 289 /* ShorthandPropertyAssignment */: + case 290 /* PropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 291 /* EnumMember */: + case 293 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 173 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 167 /* MethodDeclaration */: + case 166 /* 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 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return bindFunctionDeclaration(node); - case 166 /* Constructor */: + case 168 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 167 /* GetAccessor */: + case 169 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 46015 /* GetAccessorExcludes */); - case 168 /* SetAccessor */: + case 170 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 78783 /* SetAccessorExcludes */); - case 174 /* FunctionType */: - case 308 /* JSDocFunctionType */: - case 313 /* JSDocSignature */: - case 175 /* ConstructorType */: + case 176 /* FunctionType */: + case 311 /* JSDocFunctionType */: + case 317 /* JSDocSignature */: + case 177 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 177 /* TypeLiteral */: - case 312 /* JSDocTypeLiteral */: - case 190 /* MappedType */: + case 179 /* TypeLiteral */: + case 316 /* JSDocTypeLiteral */: + case 192 /* MappedType */: return bindAnonymousTypeWorker(node); - case 319 /* JSDocClassTag */: + case 326 /* JSDocClassTag */: return bindJSDocClassTag(node); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return bindFunctionExpression(node); - case 203 /* CallExpression */: + case 205 /* CallExpression */: var assignmentKind = ts.getAssignmentDeclarationKind(node); switch (assignmentKind) { case 7 /* ObjectDefinePropertyValue */: @@ -42691,65 +44158,65 @@ var ts; } break; // Members of classes, interfaces, and modules - case 221 /* ClassExpression */: - case 252 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 254 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 253 /* InterfaceDeclaration */: + case 255 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 788872 /* InterfaceExcludes */); - case 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 281 /* JsxAttributes */: + case 283 /* JsxAttributes */: return bindJsxAttributes(node); - case 280 /* JsxAttribute */: + case 282 /* JsxAttribute */: return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); // Imports and exports - case 260 /* ImportEqualsDeclaration */: - case 263 /* NamespaceImport */: - case 265 /* ImportSpecifier */: - case 270 /* ExportSpecifier */: + case 262 /* ImportEqualsDeclaration */: + case 265 /* NamespaceImport */: + case 267 /* ImportSpecifier */: + case 272 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 259 /* NamespaceExportDeclaration */: + case 261 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 262 /* ImportClause */: + case 264 /* ImportClause */: return bindImportClause(node); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: return bindExportDeclaration(node); - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return bindExportAssignment(node); - case 297 /* SourceFile */: + case 299 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 230 /* Block */: + case 232 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // falls through - case 257 /* ModuleBlock */: + case 259 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 326 /* JSDocParameterTag */: - if (node.parent.kind === 313 /* JSDocSignature */) { + case 334 /* JSDocParameterTag */: + if (node.parent.kind === 317 /* JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 312 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 316 /* JSDocTypeLiteral */) { break; } // falls through - case 333 /* JSDocPropertyTag */: + case 341 /* JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 307 /* JSDocOptionalType */ ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 310 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 325 /* JSDocEnumTag */: + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + case 333 /* JSDocEnumTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -42777,8 +44244,8 @@ var ts; } function bindExportAssignment(node) { if (!container.symbol || !container.symbol.exports) { - // Export assignment in some sort of block construct - bindAnonymousDeclaration(node, 2097152 /* Alias */, getDeclarationName(node)); + // Incorrect export assignment in some sort of block construct + bindAnonymousDeclaration(node, 111551 /* Value */, getDeclarationName(node)); } else { var flags = ts.exportAssignmentIsAlias(node) @@ -42912,11 +44379,11 @@ var ts; } var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 210 /* 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 === 62 /* EqualsToken */) { + if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 63 /* EqualsToken */) { var l = thisContainer.parent.left; if (ts.isBindableStaticAccessExpression(l) && ts.isPrototypeAccess(l.expression)) { constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer); @@ -42935,11 +44402,11 @@ var ts; addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* Class */); } break; - case 166 /* Constructor */: - case 163 /* PropertyDeclaration */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 168 /* Constructor */: + case 165 /* PropertyDeclaration */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: // this.foo assignment in a JavaScript class // Bind this property to the containing class var containingClass = thisContainer.parent; @@ -42951,7 +44418,7 @@ var ts; declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* None */, /*isReplaceableByMethod*/ true); } break; - case 297 /* SourceFile */: + case 299 /* 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; @@ -42977,10 +44444,10 @@ var ts; } } function bindSpecialPropertyDeclaration(node) { - if (node.expression.kind === 107 /* ThisKeyword */) { + if (node.expression.kind === 108 /* ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 297 /* SourceFile */) { + else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 299 /* SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -43020,7 +44487,7 @@ var ts; } function bindObjectDefinePropertyAssignment(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); - var isToplevel = node.parent.parent.kind === 297 /* SourceFile */; + var isToplevel = node.parent.parent.kind === 299 /* SourceFile */; namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ false); } @@ -43129,8 +44596,8 @@ var ts; } function isTopLevelNamespaceAssignment(propertyAccess) { return ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 297 /* SourceFile */ - : propertyAccess.parent.parent.kind === 297 /* SourceFile */; + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 299 /* SourceFile */ + : propertyAccess.parent.parent.kind === 299 /* SourceFile */; } function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) { var namespaceSymbol = lookupSymbolForPropertyAccess(name, container) || lookupSymbolForPropertyAccess(name, blockScopeContainer); @@ -43209,7 +44676,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 252 /* ClassDeclaration */) { + if (node.kind === 254 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899503 /* ClassExcludes */); } else { @@ -43251,7 +44718,7 @@ var ts; checkStrictModeEvalOrArguments(node, node.name); } if (!ts.isBindingPattern(node.name)) { - if (ts.isInJSFile(node) && ts.isRequireVariableDeclaration(node, /*requireStringLiteralLikeArgument*/ true) && !ts.getJSDocTypeTag(node)) { + if (ts.isInJSFile(node) && ts.isRequireVariableDeclaration(node) && !ts.getJSDocTypeTag(node)) { declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); } else if (ts.isBlockOrCatchScoped(node)) { @@ -43275,7 +44742,7 @@ var ts; } } function bindParameter(node) { - if (node.kind === 326 /* JSDocParameterTag */ && container.kind !== 313 /* JSDocSignature */) { + if (node.kind === 334 /* JSDocParameterTag */ && container.kind !== 317 /* JSDocSignature */) { return; } if (inStrictMode && !(node.flags & 8388608 /* Ambient */)) { @@ -43352,7 +44819,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } } - else if (node.parent.kind === 185 /* InferType */) { + else if (node.parent.kind === 187 /* InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { @@ -43371,7 +44838,7 @@ var ts; // reachability checks function shouldReportErrorOnModuleDeclaration(node) { var instanceState = getModuleInstanceState(node); - return instanceState === 1 /* Instantiated */ || (instanceState === 2 /* ConstEnumOnly */ && !!options.preserveConstEnums); + return instanceState === 1 /* Instantiated */ || (instanceState === 2 /* ConstEnumOnly */ && ts.shouldPreserveConstEnums(options)); } function checkUnreachable(node) { if (!(currentFlow.flags & 1 /* Unreachable */)) { @@ -43380,11 +44847,11 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 231 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 233 /* EmptyStatement */) || // report error on class declarations - node.kind === 252 /* ClassDeclaration */ || + node.kind === 254 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 256 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); + (node.kind === 258 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -43428,12 +44895,12 @@ var ts; } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: return true; - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return getModuleInstanceState(s) !== 1 /* Instantiated */; - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: return ts.hasSyntacticModifier(s, 2048 /* Const */); default: return false; @@ -43633,7 +45100,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 === 176 /* TypeQuery */) { + if (d.type && d.type.kind === 178 /* TypeQuery */) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); @@ -43803,15 +45270,6 @@ var ts; CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions"; CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp"; })(CheckMode || (CheckMode = {})); - var AccessFlags; - (function (AccessFlags) { - AccessFlags[AccessFlags["None"] = 0] = "None"; - AccessFlags[AccessFlags["NoIndexSignatures"] = 1] = "NoIndexSignatures"; - AccessFlags[AccessFlags["Writing"] = 2] = "Writing"; - AccessFlags[AccessFlags["CacheSymbol"] = 4] = "CacheSymbol"; - AccessFlags[AccessFlags["NoTupleBoundsCheck"] = 8] = "NoTupleBoundsCheck"; - AccessFlags[AccessFlags["ExpressionPosition"] = 16] = "ExpressionPosition"; - })(AccessFlags || (AccessFlags = {})); var SignatureCheckMode; (function (SignatureCheckMode) { SignatureCheckMode[SignatureCheckMode["BivariantCallback"] = 1] = "BivariantCallback"; @@ -43860,6 +45318,7 @@ var ts; DeclarationMeaning[DeclarationMeaning["SetAccessor"] = 2] = "SetAccessor"; DeclarationMeaning[DeclarationMeaning["PropertyAssignment"] = 4] = "PropertyAssignment"; DeclarationMeaning[DeclarationMeaning["Method"] = 8] = "Method"; + DeclarationMeaning[DeclarationMeaning["PrivateStatic"] = 16] = "PrivateStatic"; DeclarationMeaning[DeclarationMeaning["GetOrSetAccessor"] = 3] = "GetOrSetAccessor"; DeclarationMeaning[DeclarationMeaning["PropertyAssignmentOrMethod"] = 12] = "PropertyAssignmentOrMethod"; })(DeclarationMeaning || (DeclarationMeaning = {})); @@ -43951,21 +45410,24 @@ var ts; var instantiationCount = 0; var instantiationDepth = 0; var currentNode; - var typeCatalog = []; // NB: id is index + 1 var emptySymbols = ts.createSymbolTable(); var arrayVariances = [1 /* Covariant */]; var compilerOptions = host.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var moduleKind = ts.getEmitModuleKind(compilerOptions); + var useDefineForClassFields = ts.getUseDefineForClassFields(compilerOptions); var allowSyntheticDefaultImports = ts.getAllowSyntheticDefaultImports(compilerOptions); var strictNullChecks = ts.getStrictOptionValue(compilerOptions, "strictNullChecks"); var strictFunctionTypes = ts.getStrictOptionValue(compilerOptions, "strictFunctionTypes"); var strictBindCallApply = ts.getStrictOptionValue(compilerOptions, "strictBindCallApply"); var strictPropertyInitialization = ts.getStrictOptionValue(compilerOptions, "strictPropertyInitialization"); + var strictOptionalProperties = ts.getStrictOptionValue(compilerOptions, "strictOptionalProperties"); var noImplicitAny = ts.getStrictOptionValue(compilerOptions, "noImplicitAny"); var noImplicitThis = ts.getStrictOptionValue(compilerOptions, "noImplicitThis"); + var useUnknownInCatchVariables = ts.getStrictOptionValue(compilerOptions, "useUnknownInCatchVariables"); var keyofStringsOnly = !!compilerOptions.keyofStringsOnly; - var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 32768 /* FreshLiteral */; + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 16384 /* FreshLiteral */; + var checkBinaryExpression = createCheckBinaryExpression(); var emitResolver = createResolver(); var nodeBuilder = createNodeBuilder(); var globals = ts.createSymbolTable(); @@ -43988,7 +45450,6 @@ var ts; getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); }, getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); }, getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount") + symbolCount; }, - getTypeCatalog: function () { return typeCatalog; }, getTypeCount: function () { return typeCount; }, getInstantiationCount: function () { return totalInstantiationCount; }, getRelationCacheSizes: function () { return ({ @@ -44152,6 +45613,7 @@ var ts; return node && getContextualTypeForJsxAttribute(node); }, isContextSensitive: isContextSensitive, + getTypeOfPropertyOfContextualType: getTypeOfPropertyOfContextualType, getFullyQualifiedName: getFullyQualifiedName, getResolvedSignature: function (node, candidatesOutArray, argumentCount) { return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 0 /* Normal */); @@ -44195,6 +45657,7 @@ var ts; }, tryGetMemberInModuleExports: function (name, symbol) { return tryGetMemberInModuleExports(ts.escapeLeadingUnderscores(name), symbol); }, tryGetMemberInModuleExportsAndProperties: function (name, symbol) { return tryGetMemberInModuleExportsAndProperties(ts.escapeLeadingUnderscores(name), symbol); }, + tryFindAmbientModule: function (moduleName) { return tryFindAmbientModule(moduleName, /*withAugmentations*/ true); }, tryFindAmbientModuleWithoutAugmentations: function (moduleName) { // we deliberately exclude augmentations // since we are only interested in declarations of the module itself @@ -44313,6 +45776,7 @@ var ts; var templateLiteralTypes = new ts.Map(); var stringMappingTypes = new ts.Map(); var substitutionTypes = new ts.Map(); + var subtypeReductionCache = new ts.Map(); var evolvingArrayTypes = []; var undefinedProperties = new ts.Map(); var unknownSymbol = createSymbol(4 /* Property */, "unknown"); @@ -44321,14 +45785,15 @@ var ts; var autoType = createIntrinsicType(1 /* Any */, "any"); var wildcardType = createIntrinsicType(1 /* Any */, "any"); var errorType = createIntrinsicType(1 /* Any */, "error"); - var nonInferrableAnyType = createIntrinsicType(1 /* Any */, "any", 524288 /* ContainsWideningType */); + var nonInferrableAnyType = createIntrinsicType(1 /* Any */, "any", 131072 /* ContainsWideningType */); var intrinsicMarkerType = createIntrinsicType(1 /* Any */, "intrinsic"); var unknownType = createIntrinsicType(2 /* Unknown */, "unknown"); var undefinedType = createIntrinsicType(32768 /* Undefined */, "undefined"); - var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* Undefined */, "undefined", 524288 /* ContainsWideningType */); + var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* Undefined */, "undefined", 131072 /* ContainsWideningType */); var optionalType = createIntrinsicType(32768 /* Undefined */, "undefined"); + var missingType = strictOptionalProperties ? createIntrinsicType(32768 /* Undefined */, "undefined") : undefinedType; var nullType = createIntrinsicType(65536 /* Null */, "null"); - var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* Null */, "null", 524288 /* ContainsWideningType */); + var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* Null */, "null", 131072 /* ContainsWideningType */); var stringType = createIntrinsicType(4 /* String */, "string"); var numberType = createIntrinsicType(8 /* Number */, "number"); var bigintType = createIntrinsicType(64 /* BigInt */, "bigint"); @@ -44354,7 +45819,7 @@ var ts; var voidType = createIntrinsicType(16384 /* Void */, "void"); var neverType = createIntrinsicType(131072 /* Never */, "never"); var silentNeverType = createIntrinsicType(131072 /* Never */, "never"); - var nonInferrableType = createIntrinsicType(131072 /* Never */, "never", 2097152 /* NonInferrableType */); + var nonInferrableType = createIntrinsicType(131072 /* Never */, "never", 524288 /* NonInferrableType */); var implicitNeverType = createIntrinsicType(131072 /* Never */, "never"); var unreachableNeverType = createIntrinsicType(131072 /* Never */, "never"); var nonPrimitiveType = createIntrinsicType(67108864 /* NonPrimitive */, "object"); @@ -44366,7 +45831,7 @@ var ts; var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? wildcardType : t; }); var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var emptyJsxObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); - emptyJsxObjectType.objectFlags |= 4096 /* JsxAttributes */; + emptyJsxObjectType.objectFlags |= 2048 /* JsxAttributes */; var emptyTypeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); emptyTypeLiteralSymbol.members = ts.createSymbolTable(); var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); @@ -44375,7 +45840,7 @@ var ts; var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); // The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated // in getPropagatingFlagsOfTypes, and it is checked in inferFromTypes. - anyFunctionType.objectFlags |= 2097152 /* NonInferrableType */; + anyFunctionType.objectFlags |= 524288 /* NonInferrableType */; var noConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var circularConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var resolvingDefaultType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); @@ -44455,6 +45920,7 @@ var ts; // This allows users to just specify library files they want to used through --lib // and they will not get an error from not having unrelated library files var deferredGlobalESSymbolConstructorSymbol; + var deferredGlobalESSymbolConstructorTypeSymbol; var deferredGlobalESSymbolType; var deferredGlobalTypedPropertyDescriptorType; var deferredGlobalPromiseType; @@ -44506,7 +45972,7 @@ var ts; var flowNodePostSuper = []; var potentialThisCollisions = []; var potentialNewTargetCollisions = []; - var potentialWeakMapCollisions = []; + var potentialWeakMapSetCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); var suggestionDiagnostics = ts.createDiagnosticCollection(); @@ -44653,9 +46119,28 @@ var ts; } return diagnostic; } + function addDeprecatedSuggestionWorker(declarations, diagnostic) { + var deprecatedTag = Array.isArray(declarations) ? ts.forEach(declarations, ts.getJSDocDeprecatedTag) : ts.getJSDocDeprecatedTag(declarations); + if (deprecatedTag) { + ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(deprecatedTag, ts.Diagnostics.The_declaration_was_marked_as_deprecated_here)); + } + // We call `addRelatedInfo()` before adding the diagnostic to prevent duplicates. + suggestionDiagnostics.add(diagnostic); + return diagnostic; + } + function addDeprecatedSuggestion(location, declarations, deprecatedEntity) { + var diagnostic = ts.createDiagnosticForNode(location, ts.Diagnostics._0_is_deprecated, deprecatedEntity); + return addDeprecatedSuggestionWorker(declarations, diagnostic); + } + function addDeprecatedSuggestionWithSignature(location, declaration, deprecatedEntity, signatureString) { + var diagnostic = deprecatedEntity + ? ts.createDiagnosticForNode(location, ts.Diagnostics.The_signature_0_of_1_is_deprecated, signatureString, deprecatedEntity) + : ts.createDiagnosticForNode(location, ts.Diagnostics._0_is_deprecated, signatureString); + return addDeprecatedSuggestionWorker(declaration, diagnostic); + } function createSymbol(flags, name, checkFlags) { symbolCount++; - var symbol = (new Symbol(flags | 33554432 /* Transient */, name)); + var symbol = new Symbol(flags | 33554432 /* Transient */, name); symbol.checkFlags = checkFlags || 0; return symbol; } @@ -44766,7 +46251,7 @@ var ts; // as we will already report a "Declaration name conflicts..." error, and this error // won't make much sense. if (target !== globalThisSymbol) { - error(ts.getNameOfDeclaration(source.declarations[0]), ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); + error(source.declarations && ts.getNameOfDeclaration(source.declarations[0]), ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); } } else { // error @@ -44800,9 +46285,11 @@ var ts; } return target; function addDuplicateLocations(locs, symbol) { - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - ts.pushIfUnique(locs, decl); + if (symbol.declarations) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + ts.pushIfUnique(locs, decl); + } } } } @@ -44848,9 +46335,9 @@ var ts; }); } function mergeModuleAugmentation(moduleName) { - var _a, _b; + var _a, _b, _c; var moduleAugmentation = moduleName.parent; - if (moduleAugmentation.symbol.declarations[0] !== moduleAugmentation) { + if (((_a = moduleAugmentation.symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]) !== moduleAugmentation) { // this is a combined symbol for multiple augmentations within the same file. // its symbol already has accumulated information for all declarations // so we need to add it just once - do the work only for first declaration @@ -44887,11 +46374,11 @@ var ts; patternAmbientModuleAugmentations.set(moduleName.text, merged); } else { - if (((_a = mainModule_1.exports) === null || _a === void 0 ? void 0 : _a.get("__export" /* ExportStar */)) && ((_b = moduleAugmentation.symbol.exports) === null || _b === void 0 ? void 0 : _b.size)) { + 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)) { // 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 */); - for (var _i = 0, _c = ts.arrayFrom(moduleAugmentation.symbol.exports.entries()); _i < _c.length; _i++) { - var _d = _c[_i], key = _d[0], value = _d[1]; + 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)) { mergeSymbol(resolvedExports.get(key), value); } @@ -44932,7 +46419,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = new NodeLinks()); } function isGlobalSourceFile(node) { - return node.kind === 297 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 299 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -44991,17 +46478,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 === 198 /* BindingElement */) { + if (declaration.kind === 200 /* 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, 198 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 200 /* 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, 249 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 251 /* VariableDeclaration */), usage); } - else if (declaration.kind === 249 /* VariableDeclaration */) { + else if (declaration.kind === 251 /* VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -45015,7 +46502,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 !(compilerOptions.target === 99 /* ESNext */ && !!compilerOptions.useDefineForClassFields + return !(compilerOptions.target === 99 /* ESNext */ && useDefineForClassFields && ts.getContainingClass(declaration) === ts.getContainingClass(usage) && isUsedInFunctionOrInstanceProperty(usage, declaration)); } @@ -45031,19 +46518,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 === 270 /* ExportSpecifier */ || (usage.parent.kind === 266 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 272 /* ExportSpecifier */ || (usage.parent.kind === 268 /* 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 === 266 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 268 /* ExportAssignment */ && usage.isExportEquals) { return true; } if (!!(usage.flags & 4194304 /* JSDoc */) || isInTypeQuery(usage) || usageInTypeDeclaration()) { return true; } if (isUsedInFunctionOrInstanceProperty(usage, declaration)) { - if (compilerOptions.target === 99 /* ESNext */ && !!compilerOptions.useDefineForClassFields + if (compilerOptions.target === 99 /* ESNext */ && useDefineForClassFields && ts.getContainingClass(declaration) && (ts.isPropertyDeclaration(declaration) || ts.isParameterPropertyDeclaration(declaration, declaration.parent))) { return !isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, /*stopAtAnyPropertyDeclaration*/ true); @@ -45058,9 +46545,9 @@ var ts; } function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { switch (declaration.parent.parent.kind) { - case 232 /* VariableStatement */: - case 237 /* ForStatement */: - case 239 /* ForOfStatement */: + case 234 /* VariableStatement */: + case 239 /* ForStatement */: + case 241 /* 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)) { @@ -45081,16 +46568,16 @@ var ts; return true; } var initializerOfProperty = current.parent && - current.parent.kind === 163 /* PropertyDeclaration */ && + current.parent.kind === 165 /* PropertyDeclaration */ && current.parent.initializer === current; if (initializerOfProperty) { if (ts.hasSyntacticModifier(current.parent, 32 /* Static */)) { - if (declaration.kind === 165 /* MethodDeclaration */) { + if (declaration.kind === 167 /* MethodDeclaration */) { return true; } } else { - var isDeclarationInstanceProperty = declaration.kind === 163 /* PropertyDeclaration */ && !ts.hasSyntacticModifier(declaration, 32 /* Static */); + var isDeclarationInstanceProperty = declaration.kind === 165 /* PropertyDeclaration */ && !ts.hasSyntacticModifier(declaration, 32 /* Static */); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -45112,19 +46599,19 @@ var ts; return "quit"; } switch (node.kind) { - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return true; - case 163 /* PropertyDeclaration */: + case 165 /* 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 230 /* Block */: + case 232 /* Block */: switch (node.parent.kind) { - case 167 /* GetAccessor */: - case 165 /* MethodDeclaration */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 167 /* MethodDeclaration */: + case 170 /* SetAccessor */: return true; default: return false; @@ -45139,7 +46626,11 @@ var ts; function useOuterVariableScopeInParameter(result, location, lastLocation) { var target = ts.getEmitScriptTarget(compilerOptions); var functionLocation = location; - if (ts.isParameter(lastLocation) && functionLocation.body && result.valueDeclaration.pos >= functionLocation.body.pos && result.valueDeclaration.end <= functionLocation.body.end) { + if (ts.isParameter(lastLocation) + && functionLocation.body + && result.valueDeclaration + && result.valueDeclaration.pos >= functionLocation.body.pos + && result.valueDeclaration.end <= functionLocation.body.end) { // check for several cases where we introduce temporaries that require moving the name/initializer of the parameter to the body // - static field in a class expression // - optional chaining pre-es2020 @@ -45160,21 +46651,21 @@ var ts; } function requiresScopeChangeWorker(node) { switch (node.kind) { - case 209 /* ArrowFunction */: - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: - case 166 /* Constructor */: + case 211 /* ArrowFunction */: + case 210 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 168 /* Constructor */: // do not descend into these return false; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 288 /* PropertyAssignment */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 290 /* PropertyAssignment */: return requiresScopeChangeWorker(node.name); - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: // static properties in classes introduce temporary variables if (ts.hasStaticModifier(node)) { - return target < 99 /* ESNext */ || !compilerOptions.useDefineForClassFields; + return target < 99 /* ESNext */ || !useDefineForClassFields; } return requiresScopeChangeWorker(node.name); default: @@ -45203,6 +46694,7 @@ var ts; return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSymbol, suggestedNameNotFoundMessage); } function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, lookup, suggestedNameNotFoundMessage) { + var _a; var originalLocation = location; // needed for did-you-mean error reporting, which gathers candidates starting from the original location var result; var lastLocation; @@ -45225,12 +46717,12 @@ 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 !== 311 /* JSDocComment */) { + if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 314 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || - lastLocation.kind === 160 /* Parameter */ || - lastLocation.kind === 159 /* TypeParameter */ + lastLocation.kind === 162 /* Parameter */ || + lastLocation.kind === 161 /* TypeParameter */ // local types not visible outside the function body : false; } @@ -45245,13 +46737,13 @@ var ts; // however it is detected separately when checking initializers of parameters // to make sure that they reference no variables declared after them. useResult = - lastLocation.kind === 160 /* Parameter */ || + lastLocation.kind === 162 /* Parameter */ || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } } - else if (location.kind === 184 /* ConditionalType */) { + else if (location.kind === 186 /* 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; @@ -45266,14 +46758,14 @@ var ts; } withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation); switch (location.kind) { - case 297 /* SourceFile */: + case 299 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports || emptySymbols; - if (location.kind === 297 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 8388608 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) { + if (location.kind === 299 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 8388608 /* 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 */)) { @@ -45297,13 +46789,13 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 /* Alias */ && - (ts.getDeclarationOfKind(moduleExport, 270 /* ExportSpecifier */) || ts.getDeclarationOfKind(moduleExport, 269 /* NamespaceExport */))) { + (ts.getDeclarationOfKind(moduleExport, 272 /* ExportSpecifier */) || ts.getDeclarationOfKind(moduleExport, 271 /* 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 (ts.isSourceFile(location) && location.commonJsModuleIndicator && !result.declarations.some(ts.isJSDocTypeAlias)) { + if (ts.isSourceFile(location) && location.commonJsModuleIndicator && !((_a = result.declarations) === null || _a === void 0 ? void 0 : _a.some(ts.isJSDocTypeAlias))) { result = undefined; } else { @@ -45311,12 +46803,12 @@ var ts; } } break; - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 163 /* PropertyDeclaration */: + case 165 /* 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 @@ -45333,9 +46825,9 @@ var ts; } } break; - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* 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! @@ -45354,7 +46846,7 @@ var ts; } break loop; } - if (location.kind === 221 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 223 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -45362,9 +46854,9 @@ var ts; } } break; - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: // The type parameters of a class are not in scope in the base class expression. - if (lastLocation === location.expression && location.parent.token === 93 /* ExtendsKeyword */) { + if (lastLocation === location.expression && location.parent.token === 94 /* ExtendsKeyword */) { var container = location.parent.parent; if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968 /* Type */))) { if (nameNotFoundMessage) { @@ -45382,9 +46874,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 253 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 255 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -45392,24 +46884,24 @@ var ts; } } break; - case 209 /* ArrowFunction */: + case 211 /* 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 (compilerOptions.target >= 2 /* ES2015 */) { break; } // falls through - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 251 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 253 /* FunctionDeclaration */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -45422,7 +46914,7 @@ var ts; } } break; - case 161 /* Decorator */: + case 163 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -45431,7 +46923,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 === 160 /* Parameter */) { + if (location.parent && location.parent.kind === 162 /* Parameter */) { location = location.parent; } // @@ -45446,20 +46938,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 === 252 /* ClassDeclaration */)) { + if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 254 /* ClassDeclaration */)) { location = location.parent; } break; - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 325 /* JSDocEnumTag */: + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + case 333 /* 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 160 /* Parameter */: + case 162 /* Parameter */: if (lastLocation && (lastLocation === location.initializer || lastLocation === location.name && ts.isBindingPattern(lastLocation))) { if (!associatedDeclarationForContainingInitializerOrBindingName) { @@ -45467,7 +46959,7 @@ var ts; } } break; - case 198 /* BindingElement */: + case 200 /* BindingElement */: if (lastLocation && (lastLocation === location.initializer || lastLocation === location.name && ts.isBindingPattern(lastLocation))) { if (ts.isParameterDeclaration(location) && !associatedDeclarationForContainingInitializerOrBindingName) { @@ -45475,7 +46967,7 @@ var ts; } } break; - case 185 /* InferType */: + case 187 /* InferType */: if (meaning & 262144 /* TypeParameter */) { var parameterName = location.typeParameter.name; if (parameterName && name === parameterName.escapedText) { @@ -45499,7 +46991,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 297 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 299 /* SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -45528,6 +47020,10 @@ var ts; var suggestion = void 0; if (suggestedNameNotFoundMessage && suggestionCount < maximumSuggestionCount) { suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning); + var isGlobalScopeAugmentationDeclaration = suggestion && suggestion.valueDeclaration && ts.isAmbientModule(suggestion.valueDeclaration) && ts.isGlobalScopeAugmentation(suggestion.valueDeclaration); + if (isGlobalScopeAugmentationDeclaration) { + suggestion = undefined; + } if (suggestion) { var suggestionName = symbolToString(suggestion); var diagnostic = error(errorLocation, suggestedNameNotFoundMessage, diagnosticName(nameArg), suggestionName); @@ -45554,7 +47050,7 @@ var ts; } // Perform extra checks only if error reporting was requested if (nameNotFoundMessage) { - if (propertyWithInvalidInitializer && !(compilerOptions.target === 99 /* ESNext */ && compilerOptions.useDefineForClassFields)) { + if (propertyWithInvalidInitializer && !(compilerOptions.target === 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. @@ -45624,10 +47120,10 @@ var ts; } } function getIsDeferredContext(location, lastLocation) { - if (location.kind !== 209 /* ArrowFunction */ && location.kind !== 208 /* FunctionExpression */) { + if (location.kind !== 211 /* ArrowFunction */ && location.kind !== 210 /* 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 === 163 /* PropertyDeclaration */ && !ts.hasSyntacticModifier(location, 32 /* Static */))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred + (location.kind === 165 /* PropertyDeclaration */ && !ts.hasSyntacticModifier(location, 32 /* Static */))) && (!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; @@ -45640,12 +47136,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 256 /* ModuleDeclaration */: // For `namespace N { N; }` + case 253 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 257 /* EnumDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 258 /* ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -45655,12 +47151,14 @@ var ts; return ts.isString(nameArg) ? ts.unescapeLeadingUnderscores(nameArg) : ts.declarationNameToString(nameArg); } function isTypeParameterSymbolDeclaredInContainer(symbol, container) { - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - if (decl.kind === 159 /* 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)); // TODO: GH#18217 + if (symbol.declarations) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + if (decl.kind === 161 /* 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)); // TODO: GH#18217 + } } } } @@ -45712,10 +47210,10 @@ var ts; */ function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 78 /* Identifier */: - case 201 /* PropertyAccessExpression */: + case 79 /* Identifier */: + case 203 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -45759,7 +47257,7 @@ 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 === 270 /* ExportSpecifier */) { + if (isPrimitiveTypeName(name) && errorLocation.parent.kind === 272 /* ExportSpecifier */) { error(errorLocation, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, name); return true; } @@ -45828,13 +47326,14 @@ var ts; return false; } 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 */) { // constructor functions aren't block scoped return; } // Block-scoped variables cannot be used before their definition - var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 255 /* 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 === 257 /* EnumDeclaration */); }); if (declaration === undefined) return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration"); if (!(declaration.flags & 8388608 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { @@ -45851,7 +47350,7 @@ var ts; } else { ts.Debug.assert(!!(result.flags & 128 /* ConstEnum */)); - if (compilerOptions.preserveConstEnums) { + if (ts.shouldPreserveConstEnums(compilerOptions)) { diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName); } } @@ -45869,20 +47368,20 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return node; - case 262 /* ImportClause */: + case 264 /* ImportClause */: return node.parent; - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: return node.parent.parent; - case 265 /* ImportSpecifier */: + case 267 /* ImportSpecifier */: return node.parent.parent.parent; default: return undefined; } } function getDeclarationOfAliasSymbol(symbol) { - return ts.find(symbol.declarations, isAliasSymbolDeclaration); + return symbol.declarations && ts.findLast(symbol.declarations, isAliasSymbolDeclaration); } /** * An alias symbol is created by one of the following declarations: @@ -45897,25 +47396,26 @@ var ts; * module.exports = * {} * {name: } + * const { x } = require ... */ function isAliasSymbolDeclaration(node) { - return node.kind === 260 /* ImportEqualsDeclaration */ - || node.kind === 259 /* NamespaceExportDeclaration */ - || node.kind === 262 /* ImportClause */ && !!node.name - || node.kind === 263 /* NamespaceImport */ - || node.kind === 269 /* NamespaceExport */ - || node.kind === 265 /* ImportSpecifier */ - || node.kind === 270 /* ExportSpecifier */ - || node.kind === 266 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) + return node.kind === 262 /* ImportEqualsDeclaration */ + || node.kind === 261 /* NamespaceExportDeclaration */ + || node.kind === 264 /* ImportClause */ && !!node.name + || node.kind === 265 /* NamespaceImport */ + || node.kind === 271 /* NamespaceExport */ + || node.kind === 267 /* ImportSpecifier */ + || node.kind === 272 /* ExportSpecifier */ + || node.kind === 268 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) || ts.isBinaryExpression(node) && ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && ts.exportAssignmentIsAlias(node) || ts.isAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node - && node.parent.operatorToken.kind === 62 /* EqualsToken */ + && node.parent.operatorToken.kind === 63 /* EqualsToken */ && isAliasableOrJsExpression(node.parent.right) - || node.kind === 289 /* ShorthandPropertyAssignment */ - || node.kind === 288 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer) - || ts.isRequireVariableDeclaration(node, /*requireStringLiteralLikeArgument*/ true); + || node.kind === 291 /* ShorthandPropertyAssignment */ + || node.kind === 290 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer) + || ts.isRequireVariableDeclaration(node); } function isAliasableOrJsExpression(e) { return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e); @@ -45928,7 +47428,7 @@ var ts; ? resolveSymbol(getPropertyOfType(resolveExternalModuleTypeByLiteral(name), commonJSPropertyAccess.name.escapedText)) : undefined; } - if (ts.isVariableDeclaration(node) || node.moduleReference.kind === 272 /* ExternalModuleReference */) { + if (ts.isVariableDeclaration(node) || node.moduleReference.kind === 274 /* ExternalModuleReference */) { var immediate = resolveExternalModuleName(node, ts.getExternalModuleRequireArgument(node) || ts.getExternalModuleImportEqualsDeclarationExpression(node)); var resolved_4 = resolveExternalModuleSymbol(immediate); markSymbolOfAliasDeclarationIfTypeOnly(node, immediate, resolved_4, /*overwriteEmpty*/ false); @@ -45995,6 +47495,7 @@ var ts; return !file.externalModuleIndicator && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), /*sourceNode*/ undefined, dontResolveAlias); } function getTargetOfImportClause(node, dontResolveAlias) { + var _a; var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier); if (moduleSymbol) { var exportDefaultSymbol = void 0; @@ -46004,7 +47505,7 @@ var ts; else { exportDefaultSymbol = resolveExportByName(moduleSymbol, "default" /* Default */, node, dontResolveAlias); } - var file = ts.find(moduleSymbol.declarations, ts.isSourceFile); + var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); var hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias); if (!exportDefaultSymbol && !hasSyntheticDefault) { if (hasExportAssignmentSymbol(moduleSymbol)) { @@ -46012,7 +47513,9 @@ var ts; var exportEqualsSymbol = moduleSymbol.exports.get("export=" /* 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); - ts.addRelatedInfo(err, ts.createDiagnosticForNode(exportAssignment, ts.Diagnostics.This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag, compilerOptionName)); + if (exportAssignment) { + ts.addRelatedInfo(err, ts.createDiagnosticForNode(exportAssignment, ts.Diagnostics.This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag, compilerOptionName)); + } } else { reportNonDefaultExport(moduleSymbol, node); @@ -46029,7 +47532,7 @@ var ts; } } function reportNonDefaultExport(moduleSymbol, node) { - var _a, _b; + var _a, _b, _c; if ((_a = moduleSymbol.exports) === null || _a === void 0 ? void 0 : _a.has(node.symbol.escapedName)) { error(node.name, ts.Diagnostics.Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead, symbolToString(moduleSymbol), symbolToString(node.symbol)); } @@ -46037,7 +47540,7 @@ var ts; 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 */); if (exportStar) { - var defaultExport = ts.find(exportStar.declarations, function (decl) { + 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 */))); @@ -46115,7 +47618,7 @@ var ts; } } function getExternalModuleMember(node, specifier, dontResolveAlias) { - var _a; + var _a, _b; if (dontResolveAlias === void 0) { dontResolveAlias = false; } var moduleSpecifier = ts.getExternalModuleRequireArgument(node) || node.moduleSpecifier; var moduleSymbol = resolveExternalModuleName(node, moduleSpecifier); // TODO: GH#18217 @@ -46124,7 +47627,7 @@ var ts; return undefined; } var suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || compilerOptions.esModuleInterop); - var targetSymbol = resolveESModuleSymbol(moduleSymbol, moduleSpecifier, dontResolveAlias, suppressInteropError); + var targetSymbol = resolveESModuleSymbol(moduleSymbol, moduleSpecifier, /*dontResolveAlias*/ false, suppressInteropError); if (targetSymbol) { if (name.escapedText) { if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { @@ -46142,7 +47645,7 @@ var ts; symbolFromVariable = resolveSymbol(symbolFromVariable, dontResolveAlias); var symbolFromModule = getExportOfModule(targetSymbol, name, specifier, dontResolveAlias); if (symbolFromModule === undefined && name.escapedText === "default" /* Default */) { - var file = ts.find(moduleSymbol.declarations, ts.isSourceFile); + var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); if (canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias)) { symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias); } @@ -46162,7 +47665,7 @@ var ts; } } else { - if ((_a = moduleSymbol.exports) === null || _a === void 0 ? void 0 : _a.has("default" /* Default */)) { + if ((_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* 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 { @@ -46175,8 +47678,8 @@ var ts; } } function reportNonExportedMember(node, name, declarationName, moduleSymbol, moduleName) { - var _a; - var localSymbol = (_a = moduleSymbol.valueDeclaration.locals) === null || _a === void 0 ? void 0 : _a.get(name.escapedText); + var _a, _b; + 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 */); @@ -46188,9 +47691,11 @@ var ts; var exportedSymbol = exports ? ts.find(symbolsToArray(exports), function (symbol) { return !!getSymbolIfSameReference(symbol, localSymbol); }) : undefined; var diagnostic = exportedSymbol ? error(name, ts.Diagnostics.Module_0_declares_1_locally_but_it_is_exported_as_2, moduleName, declarationName, symbolToString(exportedSymbol)) : error(name, ts.Diagnostics.Module_0_declares_1_locally_but_it_is_not_exported, moduleName, declarationName); - ts.addRelatedInfo.apply(void 0, __spreadArray([diagnostic], ts.map(localSymbol.declarations, function (decl, index) { - return ts.createDiagnosticForNode(decl, index === 0 ? ts.Diagnostics._0_is_declared_here : ts.Diagnostics.and_here, declarationName); - }))); + if (localSymbol.declarations) { + ts.addRelatedInfo.apply(void 0, __spreadArray([diagnostic], ts.map(localSymbol.declarations, function (decl, index) { + return ts.createDiagnosticForNode(decl, index === 0 ? ts.Diagnostics._0_is_declared_here : ts.Diagnostics.and_here, declarationName); + }))); + } } } else { @@ -46269,7 +47774,7 @@ var ts; return getTargetOfAliasLikeExpression(expression, dontRecursivelyResolve); } function getTargetOfAccessExpression(node, dontRecursivelyResolve) { - if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62 /* EqualsToken */)) { + if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* EqualsToken */)) { return undefined; } return getTargetOfAliasLikeExpression(node.parent.right, dontRecursivelyResolve); @@ -46277,31 +47782,31 @@ var ts; function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 260 /* ImportEqualsDeclaration */: - case 249 /* VariableDeclaration */: + case 262 /* ImportEqualsDeclaration */: + case 251 /* VariableDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 262 /* ImportClause */: + case 264 /* ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 269 /* NamespaceExport */: + case 271 /* NamespaceExport */: return getTargetOfNamespaceExport(node, dontRecursivelyResolve); - case 265 /* ImportSpecifier */: - case 198 /* BindingElement */: + case 267 /* ImportSpecifier */: + case 200 /* BindingElement */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 270 /* ExportSpecifier */: + case 272 /* ExportSpecifier */: return getTargetOfExportSpecifier(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 266 /* ExportAssignment */: - case 216 /* BinaryExpression */: + case 268 /* ExportAssignment */: + case 218 /* BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 259 /* NamespaceExportDeclaration */: + case 261 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return resolveEntityName(node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve); - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: return getTargetOfPropertyAssignment(node, dontRecursivelyResolve); - case 202 /* ElementAccessExpression */: - case 201 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: return getTargetOfAccessExpression(node, dontRecursivelyResolve); default: return ts.Debug.fail(); @@ -46449,17 +47954,17 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 78 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 79 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 78 /* Identifier */ || entityName.parent.kind === 157 /* QualifiedName */) { + if (entityName.kind === 79 /* Identifier */ || entityName.parent.kind === 159 /* QualifiedName */) { return resolveEntityName(entityName, 1920 /* 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 === 260 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 262 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } @@ -46475,7 +47980,7 @@ var ts; } var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 111551 /* Value */ : 0); var symbol; - if (name.kind === 78 /* Identifier */) { + if (name.kind === 79 /* 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)); @@ -46483,9 +47988,9 @@ var ts; return getMergedSymbol(symbolFromJSPrototype); } } - else if (name.kind === 157 /* QualifiedName */ || name.kind === 201 /* PropertyAccessExpression */) { - var left = name.kind === 157 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 157 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 159 /* QualifiedName */ || name.kind === 203 /* PropertyAccessExpression */) { + var left = name.kind === 159 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 159 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -46493,18 +47998,17 @@ var ts; else if (namespace === unknownSymbol) { return namespace; } - if (ts.isInJSFile(name)) { - if (namespace.valueDeclaration && - ts.isVariableDeclaration(namespace.valueDeclaration) && - namespace.valueDeclaration.initializer && - isCommonJsRequire(namespace.valueDeclaration.initializer)) { - var moduleName = namespace.valueDeclaration.initializer.arguments[0]; - var moduleSym = resolveExternalModuleName(moduleName, moduleName); - if (moduleSym) { - var resolvedModuleSymbol = resolveExternalModuleSymbol(moduleSym); - if (resolvedModuleSymbol) { - namespace = resolvedModuleSymbol; - } + if (namespace.valueDeclaration && + ts.isInJSFile(namespace.valueDeclaration) && + ts.isVariableDeclaration(namespace.valueDeclaration) && + namespace.valueDeclaration.initializer && + isCommonJsRequire(namespace.valueDeclaration.initializer)) { + var moduleName = namespace.valueDeclaration.initializer.arguments[0]; + var moduleSym = resolveExternalModuleName(moduleName, moduleName); + if (moduleSym) { + var resolvedModuleSymbol = resolveExternalModuleSymbol(moduleSym); + if (resolvedModuleSymbol) { + namespace = resolvedModuleSymbol; } } } @@ -46525,7 +48029,7 @@ var ts; 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 === 266 /* ExportAssignment */)) { + if (!ts.nodeIsSynthesized(name) && ts.isEntityName(name) && (symbol.flags & 2097152 /* Alias */ || name.parent.kind === 268 /* ExportAssignment */)) { markSymbolOfAliasDeclarationIfTypeOnly(ts.getAliasDeclarationFromName(name), symbol, /*finalTarget*/ undefined, /*overwriteEmpty*/ true); } return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol); @@ -46762,7 +48266,7 @@ var ts; function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias, suppressInteropError) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!suppressInteropError && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 297 /* SourceFile */)) { + if (!suppressInteropError && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 299 /* SourceFile */)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; @@ -46813,7 +48317,10 @@ var ts; var exports = getExportsOfModuleAsArray(moduleSymbol); var exportEquals = resolveExternalModuleSymbol(moduleSymbol); if (exportEquals !== moduleSymbol) { - ts.addRange(exports, getPropertiesOfType(getTypeOfSymbol(exportEquals))); + var type = getTypeOfSymbol(exportEquals); + if (shouldTreatPropertiesOfExternalModuleAsExports(type)) { + ts.addRange(exports, getPropertiesOfType(type)); + } } return exports; } @@ -46833,11 +48340,14 @@ var ts; return undefined; } var type = getTypeOfSymbol(exportEquals); - return type.flags & 131068 /* Primitive */ || - ts.getObjectFlags(type) & 1 /* Class */ || - isArrayOrTupleLikeType(type) - ? undefined - : getPropertyOfType(type, memberName); + return shouldTreatPropertiesOfExternalModuleAsExports(type) ? getPropertyOfType(type, memberName) : undefined; + } + function shouldTreatPropertiesOfExternalModuleAsExports(resolvedExternalModuleType) { + return !(resolvedExternalModuleType.flags & 131068 /* Primitive */ || + ts.getObjectFlags(resolvedExternalModuleType) & 1 /* 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 */) : @@ -46895,11 +48405,13 @@ var ts; if (exportStars) { var nestedSymbols = ts.createSymbolTable(); var lookupTable_1 = new ts.Map(); - for (var _i = 0, _a = exportStars.declarations; _i < _a.length; _i++) { - var node = _a[_i]; - var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); - var exportedSymbols = visit(resolvedModule); - extendExportSymbols(nestedSymbols, exportedSymbols, lookupTable_1, node); + if (exportStars.declarations) { + for (var _i = 0, _a = exportStars.declarations; _i < _a.length; _i++) { + var node = _a[_i]; + var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); + var exportedSymbols = visit(resolvedModule); + extendExportSymbols(nestedSymbols, exportedSymbols, lookupTable_1, node); + } } lookupTable_1.forEach(function (_a, id) { var exportsWithDuplicate = _a.exportsWithDuplicate; @@ -46982,17 +48494,34 @@ var ts; var additionalContainers = ts.mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer); var reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration); var objectLiteralContainer = getVariableDeclarationOfObjectLiteral(container, meaning); - if (enclosingDeclaration && getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* Namespace */, /*externalOnly*/ false)) { + if (enclosingDeclaration && + container.flags & getQualifiedLeftMeaning(meaning) && + getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* 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 } - var res = ts.append(ts.append(additionalContainers, container), objectLiteralContainer); - return ts.concatenate(res, reexportContainers); + // 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 */ + ? forEachSymbolTableInScope(enclosingDeclaration, function (t) { + return ts.forEachEntry(t, function (s) { + if (s.flags & getQualifiedLeftMeaning(meaning) && getTypeOfSymbol(s) === getDeclaredTypeOfSymbol(container)) { + return s; + } + }); + }) : undefined; + var res = firstVariableMatch ? __spreadArray(__spreadArray([firstVariableMatch], additionalContainers), [container]) : __spreadArray(__spreadArray([], additionalContainers), [container]); + res = ts.append(res, objectLiteralContainer); + res = ts.addRange(res, reexportContainers); + return res; } var candidates = ts.mapDefined(symbol.declarations, function (d) { if (!ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent)) { return getSymbolOfNode(d.parent); } - if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 62 /* 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 /* 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)); } @@ -47064,7 +48593,7 @@ var ts; var members = node.members; for (var _i = 0, members_3 = members; _i < members_3.length; _i++) { var member = members_3[_i]; - if (member.kind === 166 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 168 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -47073,7 +48602,9 @@ var ts; var result = new Type(checker, flags); typeCount++; result.id = typeCount; - typeCatalog.push(result); + if (produceDiagnostics) { // Only record types from one checker + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.recordType(result); + } return result; } function createOriginType(flags) { @@ -47133,14 +48664,23 @@ var ts; }); return result || ts.emptyArray; } + function getNamedOrIndexSignatureMembers(members) { + var result = getNamedMembers(members); + var index = getIndexSymbolFromSymbolTable(members); + return index ? ts.concatenate(result, [index]) : result; + } function setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { - type.members = members; - type.properties = members === emptySymbols ? ts.emptyArray : getNamedMembers(members); - type.callSignatures = callSignatures; - type.constructSignatures = constructSignatures; - type.stringIndexInfo = stringIndexInfo; - type.numberIndexInfo = numberIndexInfo; - return type; + var resolved = type; + resolved.members = members; + resolved.properties = ts.emptyArray; + resolved.callSignatures = callSignatures; + resolved.constructSignatures = constructSignatures; + resolved.stringIndexInfo = stringIndexInfo; + resolved.numberIndexInfo = numberIndexInfo; + // This can loop back to getPropertyOfType() which would crash if `callSignatures` & `constructSignatures` are not initialized. + if (members !== emptySymbols) + resolved.properties = getNamedMembers(members); + return resolved; } function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { return setStructuredTypeMembers(createObjectType(16 /* Anonymous */, symbol), members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); @@ -47163,28 +48703,28 @@ var ts; var _loop_8 = function (location) { // Locals of a source file are not in scope (because they get merged into the global symbol table) if (location.locals && !isGlobalSourceFile(location)) { - if (result = callback(location.locals)) { + if (result = callback(location.locals, /*ignoreQualification*/ undefined, /*isLocalNameLookup*/ true, location)) { return { value: result }; } } switch (location.kind) { - case 297 /* SourceFile */: + case 299 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 256 /* ModuleDeclaration */: + case 258 /* 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 // to one another anyway) - if (result = callback((sym === null || sym === void 0 ? void 0 : sym.exports) || emptySymbols)) { + if (result = callback((sym === null || sym === void 0 ? void 0 : sym.exports) || emptySymbols, /*ignoreQualification*/ undefined, /*isLocalNameLookup*/ true, location)) { return { value: result }; } break; - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* 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 @@ -47199,7 +48739,7 @@ var ts; (table_1 || (table_1 = ts.createSymbolTable())).set(key, memberSymbol); } }); - if (table_1 && (result = callback(table_1))) { + if (table_1 && (result = callback(table_1, /*ignoreQualification*/ undefined, /*isLocalNameLookup*/ false, location))) { return { value: result }; } break; @@ -47210,7 +48750,7 @@ var ts; if (typeof state_2 === "object") return state_2.value; } - return callback(globals); + return callback(globals, /*ignoreQualification*/ undefined, /*isLocalNameLookup*/ true); } function getQualifiedLeftMeaning(rightMeaning) { // If we are looking in value space, the parent meaning is value, other wise it is namespace @@ -47221,20 +48761,30 @@ var ts; if (!(symbol && !isPropertyOrMethodDeclarationSymbol(symbol))) { return undefined; } + var links = getSymbolLinks(symbol); + 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; + if (cache.has(key)) { + return cache.get(key); + } var id = getSymbolId(symbol); var visitedSymbolTables = visitedSymbolTablesMap.get(id); if (!visitedSymbolTables) { visitedSymbolTablesMap.set(id, visitedSymbolTables = []); } - return forEachSymbolTableInScope(enclosingDeclaration, getAccessibleSymbolChainFromSymbolTable); + var result = forEachSymbolTableInScope(enclosingDeclaration, getAccessibleSymbolChainFromSymbolTable); + cache.set(key, result); + return result; /** * @param {ignoreQualification} boolean Set when a symbol is being looked for through the exports of another symbol (meaning we have a route to qualify it already) */ - function getAccessibleSymbolChainFromSymbolTable(symbols, ignoreQualification) { + function getAccessibleSymbolChainFromSymbolTable(symbols, ignoreQualification, isLocalNameLookup) { if (!ts.pushIfUnique(visitedSymbolTables, symbols)) { return undefined; } - var result = trySymbolTable(symbols, ignoreQualification); + var result = trySymbolTable(symbols, ignoreQualification, isLocalNameLookup); visitedSymbolTables.pop(); return result; } @@ -47252,7 +48802,7 @@ var ts; !ts.some(symbolFromSymbolTable.declarations, hasNonGlobalAugmentationExternalModuleSymbol) && (ignoreQualification || canQualifySymbol(getMergedSymbol(symbolFromSymbolTable), meaning)); } - function trySymbolTable(symbols, ignoreQualification) { + function trySymbolTable(symbols, ignoreQualification, isLocalNameLookup) { // If symbol is directly available by its name in the symbol table if (isAccessible(symbols.get(symbol.escapedName), /*resolvedAliasSymbol*/ undefined, ignoreQualification)) { return [symbol]; @@ -47265,9 +48815,11 @@ var ts; && !(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)) + // If we're looking up a local name to reference directly, omit namespace reexports, otherwise when we're trawling through an export list to make a dotted name, we can keep it + && (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, 270 /* ExportSpecifier */))) { + && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 272 /* ExportSpecifier */))) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); var candidate = getCandidateListForSymbol(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification); if (candidate) { @@ -47311,7 +48863,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, 270 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 272 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -47326,10 +48878,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 163 /* PropertyDeclaration */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: continue; default: return false; @@ -47367,7 +48919,7 @@ var ts; return hasAccessibleDeclarations; } } - else if (allowModules) { + if (allowModules) { if (ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { if (shouldComputeAliasesToMakeVisible) { earlyModuleBail = true; @@ -47441,7 +48993,8 @@ var ts; return { accessibility: 2 /* CannotBeNamed */, errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning), - errorModuleName: symbolToString(symbolExternalModule) + errorModuleName: symbolToString(symbolExternalModule), + errorNode: ts.isInJSFile(enclosingDeclaration) ? enclosingDeclaration : undefined, }; } } @@ -47458,14 +49011,14 @@ var ts; return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 297 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 299 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 297 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 299 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; - if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 78 /* Identifier */; }), getIsDeclarationVisible)) { + if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 79 /* Identifier */; }), getIsDeclarationVisible)) { return undefined; } return { accessibility: 0 /* Accessible */, aliasesToMakeVisible: aliasesToMakeVisible }; @@ -47517,14 +49070,14 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 176 /* TypeQuery */ || + if (entityName.parent.kind === 178 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) || - entityName.parent.kind === 158 /* ComputedPropertyName */) { + entityName.parent.kind === 160 /* ComputedPropertyName */) { // Typeof value meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 157 /* QualifiedName */ || entityName.kind === 201 /* PropertyAccessExpression */ || - entityName.parent.kind === 260 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 159 /* QualifiedName */ || entityName.kind === 203 /* PropertyAccessExpression */ || + entityName.parent.kind === 262 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -47565,7 +49118,7 @@ var ts; 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) === 297 /* SourceFile */ ? ts.createPrinter({ removeComments: true, neverAsciiEscape: true }) : ts.createPrinter({ removeComments: true }); + var printer = (enclosingDeclaration === null || enclosingDeclaration === void 0 ? void 0 : enclosingDeclaration.kind) === 299 /* 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); return writer; @@ -47577,10 +49130,10 @@ var ts; function signatureToStringWorker(writer) { var sigOutput; if (flags & 262144 /* WriteArrowStyleSignature */) { - sigOutput = kind === 1 /* Construct */ ? 175 /* ConstructorType */ : 174 /* FunctionType */; + sigOutput = kind === 1 /* Construct */ ? 177 /* ConstructorType */ : 176 /* FunctionType */; } else { - sigOutput = kind === 1 /* Construct */ ? 170 /* ConstructSignature */ : 169 /* CallSignature */; + sigOutput = kind === 1 /* Construct */ ? 172 /* ConstructSignature */ : 171 /* CallSignature */; } var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); @@ -47620,14 +49173,14 @@ var ts; return typeToString(type, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */); } function symbolValueDeclarationIsContextSensitive(symbol) { - return symbol && symbol.valueDeclaration && ts.isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration); + 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 */; } function isClassInstanceSide(type) { - return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || !!(ts.getObjectFlags(type) & 1073741824 /* IsClassInstanceClone */)); + return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288 /* Object */) && !!(ts.getObjectFlags(type) & 16777216 /* IsClassInstanceClone */))); } function createNodeBuilder() { return { @@ -47666,7 +49219,7 @@ var ts; enclosingDeclaration: enclosingDeclaration, flags: flags || 0 /* None */, // If no full tracker is provided, fake up a dummy one with a basic limited-functionality moduleResolverHost - tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: ts.noop, moduleResolverHost: flags & 134217728 /* DoNotIncludeSymbolChain */ ? { + tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: function () { return false; }, moduleResolverHost: flags & 134217728 /* DoNotIncludeSymbolChain */ ? { getCommonSourceDirectory: !!host.getCommonSourceDirectory ? function () { return host.getCommonSourceDirectory(); } : function () { return ""; }, getSourceFiles: function () { return host.getSourceFiles(); }, getCurrentDirectory: function () { return host.getCurrentDirectory(); }, @@ -47679,17 +49232,46 @@ var ts; getFileIncludeReasons: function () { return host.getFileIncludeReasons(); }, } : undefined }, encounteredError: false, + reportedDiagnostic: false, visitedTypes: undefined, symbolDepth: undefined, inferTypeParameters: undefined, approximateLength: 0 }; + context.tracker = wrapSymbolTrackerToReportForContext(context, context.tracker); var resultingNode = cb(context); if (context.truncating && context.flags & 1 /* 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; } + function wrapSymbolTrackerToReportForContext(context, tracker) { + var oldTrackSymbol = tracker.trackSymbol; + return __assign(__assign({}, tracker), { reportCyclicStructureError: wrapReportedDiagnostic(tracker.reportCyclicStructureError), reportInaccessibleThisError: wrapReportedDiagnostic(tracker.reportInaccessibleThisError), reportInaccessibleUniqueSymbolError: wrapReportedDiagnostic(tracker.reportInaccessibleUniqueSymbolError), reportLikelyUnsafeImportRequiredError: wrapReportedDiagnostic(tracker.reportLikelyUnsafeImportRequiredError), reportNonlocalAugmentation: wrapReportedDiagnostic(tracker.reportNonlocalAugmentation), reportPrivateInBaseOfClassExpression: wrapReportedDiagnostic(tracker.reportPrivateInBaseOfClassExpression), trackSymbol: oldTrackSymbol && (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var result = oldTrackSymbol.apply(void 0, args); + if (result) { + context.reportedDiagnostic = true; + } + return result; + }) }); + function wrapReportedDiagnostic(method) { + if (!method) { + return method; + } + return (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + context.reportedDiagnostic = true; + return method.apply(void 0, args); + }); + } + } function checkTruncationLength(context) { if (context.truncating) return context.truncating; @@ -47707,33 +49289,33 @@ var ts; return undefined; // TODO: GH#18217 } context.approximateLength += 3; - return ts.factory.createKeywordTypeNode(128 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(129 /* AnyKeyword */); } if (!(context.flags & 536870912 /* NoTypeReduction */)) { type = getReducedType(type); } if (type.flags & 1 /* Any */) { context.approximateLength += 3; - return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 136 /* IntrinsicKeyword */ : 128 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 137 /* IntrinsicKeyword */ : 129 /* AnyKeyword */); } if (type.flags & 2 /* Unknown */) { - return ts.factory.createKeywordTypeNode(152 /* UnknownKeyword */); + return ts.factory.createKeywordTypeNode(153 /* UnknownKeyword */); } if (type.flags & 4 /* String */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(147 /* StringKeyword */); + return ts.factory.createKeywordTypeNode(148 /* StringKeyword */); } if (type.flags & 8 /* Number */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(144 /* NumberKeyword */); + return ts.factory.createKeywordTypeNode(145 /* NumberKeyword */); } if (type.flags & 64 /* BigInt */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(155 /* BigIntKeyword */); + return ts.factory.createKeywordTypeNode(156 /* BigIntKeyword */); } if (type.flags & 16 /* Boolean */) { context.approximateLength += 7; - return ts.factory.createKeywordTypeNode(131 /* BooleanKeyword */); + return ts.factory.createKeywordTypeNode(132 /* BooleanKeyword */); } if (type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */)) { var parentSymbol = getParentOfSymbol(type.symbol); @@ -47787,15 +49369,15 @@ var ts; } } context.approximateLength += 13; - return ts.factory.createTypeOperatorNode(151 /* UniqueKeyword */, ts.factory.createKeywordTypeNode(148 /* SymbolKeyword */)); + return ts.factory.createTypeOperatorNode(152 /* UniqueKeyword */, ts.factory.createKeywordTypeNode(149 /* SymbolKeyword */)); } if (type.flags & 16384 /* Void */) { context.approximateLength += 4; - return ts.factory.createKeywordTypeNode(113 /* VoidKeyword */); + return ts.factory.createKeywordTypeNode(114 /* VoidKeyword */); } if (type.flags & 32768 /* Undefined */) { context.approximateLength += 9; - return ts.factory.createKeywordTypeNode(150 /* UndefinedKeyword */); + return ts.factory.createKeywordTypeNode(151 /* UndefinedKeyword */); } if (type.flags & 65536 /* Null */) { context.approximateLength += 4; @@ -47803,15 +49385,15 @@ var ts; } if (type.flags & 131072 /* Never */) { context.approximateLength += 5; - return ts.factory.createKeywordTypeNode(141 /* NeverKeyword */); + return ts.factory.createKeywordTypeNode(142 /* NeverKeyword */); } if (type.flags & 4096 /* ESSymbol */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(148 /* SymbolKeyword */); + return ts.factory.createKeywordTypeNode(149 /* SymbolKeyword */); } if (type.flags & 67108864 /* NonPrimitive */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(145 /* ObjectKeyword */); + return ts.factory.createKeywordTypeNode(146 /* ObjectKeyword */); } if (isThisTypeParameter(type)) { if (context.flags & 4194304 /* InObjectTypeLiteral */) { @@ -47881,7 +49463,7 @@ var ts; var indexedType = type.type; context.approximateLength += 6; var indexTypeNode = typeToTypeNodeHelper(indexedType, context); - return ts.factory.createTypeOperatorNode(138 /* KeyOfKeyword */, indexTypeNode); + return ts.factory.createTypeOperatorNode(139 /* KeyOfKeyword */, indexTypeNode); } if (type.flags & 134217728 /* TemplateLiteral */) { var texts_1 = type.texts; @@ -47938,14 +49520,14 @@ 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` - appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(138 /* KeyOfKeyword */, typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context)); + appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(139 /* KeyOfKeyword */, 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(getTemplateTypeFromMappedType(type), context); + var templateTypeNode = typeToTypeNodeHelper(removeMissingType(getTemplateTypeFromMappedType(type), !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), context); var mappedTypeNode = ts.factory.createMappedTypeNode(readonlyToken, typeParameterNode, nameTypeNode, questionToken, templateTypeNode); context.approximateLength += 10; return ts.setEmitFlags(mappedTypeNode, 1 /* SingleLine */); @@ -47961,7 +49543,9 @@ var ts; return symbolToTypeNode(symbol, context, isInstanceType); } // Always use 'typeof T' for type of class, enum, and module objects - else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 221 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || + else if (symbol.flags & 32 /* Class */ + && !getBaseTypeVariableOfClass(symbol) + && !(symbol.valueDeclaration && symbol.valueDeclaration.kind === 223 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, isInstanceType); @@ -47992,7 +49576,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 297 /* SourceFile */ || declaration.parent.kind === 257 /* ModuleBlock */; + return declaration.parent.kind === 299 /* SourceFile */ || declaration.parent.kind === 259 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -48002,6 +49586,7 @@ var ts; } } 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) : @@ -48015,6 +49600,19 @@ var ts; if (id && !context.symbolDepth) { context.symbolDepth = new ts.Map(); } + var links = context.enclosingDeclaration && getNodeLinks(context.enclosingDeclaration); + var key = getTypeId(type) + "|" + context.flags; + if (links) { + links.serializedTypes || (links.serializedTypes = new ts.Map()); + } + var cachedResult = (_a = links === null || links === void 0 ? void 0 : links.serializedTypes) === null || _a === void 0 ? void 0 : _a.get(key); + if (cachedResult) { + if (cachedResult.truncating) { + context.truncating = true; + } + context.approximateLength += cachedResult.addedLength; + return deepCloneOrReuseNode(cachedResult); + } var depth; if (id) { depth = context.symbolDepth.get(id) || 0; @@ -48024,12 +49622,27 @@ var ts; context.symbolDepth.set(id, depth + 1); } context.visitedTypes.add(typeId); + var startLength = context.approximateLength; var result = transform(type); + var addedLength = context.approximateLength - startLength; + if (!context.reportedDiagnostic && !context.encounteredError) { + if (context.truncating) { + result.truncating = true; + } + result.addedLength = addedLength; + (_b = links === null || links === void 0 ? void 0 : links.serializedTypes) === null || _b === void 0 ? void 0 : _b.set(key, result); + } context.visitedTypes.delete(typeId); if (id) { context.symbolDepth.set(id, depth); } return result; + function deepCloneOrReuseNode(node) { + if (!ts.nodeIsSynthesized(node) && ts.getParseTreeNode(node) === node) { + return node; + } + return ts.setTextRange(ts.factory.cloneNode(ts.visitEachChild(node, deepCloneOrReuseNode, ts.nullTransformationContext)), node); + } } function createTypeNodeFromObjectType(type) { if (isGenericMappedType(type) || type.containsError) { @@ -48043,12 +49656,12 @@ var ts; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 174 /* FunctionType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 176 /* FunctionType */, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 175 /* ConstructorType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 177 /* ConstructorType */, context); return signatureNode; } } @@ -48092,9 +49705,10 @@ var ts; } var elementType = typeToTypeNodeHelper(typeArguments[0], context); var arrayType = ts.factory.createArrayTypeNode(elementType); - return type.target === globalArrayType ? arrayType : ts.factory.createTypeOperatorNode(142 /* ReadonlyKeyword */, arrayType); + return type.target === globalArrayType ? arrayType : ts.factory.createTypeOperatorNode(143 /* 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 */)); }); if (typeArguments.length > 0) { var arity = getTypeReferenceArity(type); var tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, arity), context); @@ -48116,12 +49730,12 @@ var ts; } } var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode(tupleConstituentNodes), 1 /* SingleLine */); - return type.target.readonly ? ts.factory.createTypeOperatorNode(142 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + return type.target.readonly ? ts.factory.createTypeOperatorNode(143 /* 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(142 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + return type.target.readonly ? ts.factory.createTypeOperatorNode(143 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } context.encounteredError = true; return undefined; // TODO: GH#18217 @@ -48228,17 +49842,17 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 169 /* CallSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 171 /* CallSignature */, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; if (signature.flags & 4 /* Abstract */) continue; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 170 /* ConstructSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 172 /* ConstructSignature */, context)); } if (resolvedType.stringIndexInfo) { var indexSignature = void 0; - if (resolvedType.objectFlags & 2048 /* ReverseMapped */) { + if (resolvedType.objectFlags & 1024 /* ReverseMapped */) { indexSignature = indexInfoToIndexSignatureDeclarationHelper(createIndexInfo(anyType, resolvedType.stringIndexInfo.isReadonly, resolvedType.stringIndexInfo.declaration), 0 /* String */, context, createElidedInformationPlaceholder(context)); } else { @@ -48280,17 +49894,31 @@ var ts; if (!(context.flags & 1 /* NoTruncation */)) { return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier("..."), /*typeArguments*/ undefined); } - return ts.factory.createKeywordTypeNode(128 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(129 /* AnyKeyword */); + } + function shouldUsePlaceholderForProperty(propertySymbol, context) { + var _a; + // Use placeholders for reverse mapped types we've either already descended into, or which + // are nested reverse mappings within a mapping over a non-anonymous type. The later is a restriction mostly just to + // reduce the blowup in printback size from doing, eg, a deep reverse mapping over `Window`. + // 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 */) + && (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 */))); } function addPropertyToElementList(propertySymbol, context, typeElements) { + var _a; var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */); - var propertyType = propertyIsReverseMapped && context.flags & 33554432 /* InReverseMappedType */ ? - anyType : getTypeOfSymbol(propertySymbol); + var propertyType = shouldUsePlaceholderForProperty(propertySymbol, context) ? + anyType : getNonMissingTypeOfSymbol(propertySymbol); var saveEnclosingDeclaration = context.enclosingDeclaration; context.enclosingDeclaration = undefined; if (context.tracker.trackSymbol && ts.getCheckFlags(propertySymbol) & 4096 /* Late */ && isLateBoundName(propertySymbol.escapedName)) { var decl = ts.first(propertySymbol.declarations); - if (hasLateBindableName(decl)) { + if (propertySymbol.declarations && hasLateBindableName(decl)) { if (ts.isBinaryExpression(decl)) { var name = ts.getNameOfDeclaration(decl); if (name && ts.isElementAccessExpression(name) && ts.isPropertyAccessEntityNameExpression(name.argumentExpression)) { @@ -48302,30 +49930,35 @@ var ts; } } } - context.enclosingDeclaration = saveEnclosingDeclaration; + context.enclosingDeclaration = propertySymbol.valueDeclaration || ((_a = propertySymbol.declarations) === null || _a === void 0 ? void 0 : _a[0]) || saveEnclosingDeclaration; 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 */); for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { var signature = signatures_1[_i]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 164 /* MethodSignature */, context, { name: propertyName, questionToken: optionalToken }); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 166 /* MethodSignature */, context, { name: propertyName, questionToken: optionalToken }); typeElements.push(preserveCommentsOn(methodDeclaration)); } } else { - var savedFlags = context.flags; - context.flags |= propertyIsReverseMapped ? 33554432 /* InReverseMappedType */ : 0; var propertyTypeNode = void 0; - if (propertyIsReverseMapped && !!(savedFlags & 33554432 /* InReverseMappedType */)) { + if (shouldUsePlaceholderForProperty(propertySymbol, context)) { propertyTypeNode = createElidedInformationPlaceholder(context); } else { - propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.factory.createKeywordTypeNode(128 /* AnyKeyword */); + if (propertyIsReverseMapped) { + context.reverseMappedStack || (context.reverseMappedStack = []); + context.reverseMappedStack.push(propertySymbol); + } + propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.factory.createKeywordTypeNode(129 /* AnyKeyword */); + if (propertyIsReverseMapped) { + context.reverseMappedStack.pop(); + } } - context.flags = savedFlags; - var modifiers = isReadonlySymbol(propertySymbol) ? [ts.factory.createToken(142 /* ReadonlyKeyword */)] : undefined; + var modifiers = isReadonlySymbol(propertySymbol) ? [ts.factory.createToken(143 /* ReadonlyKeyword */)] : undefined; if (modifiers) { context.approximateLength += 9; } @@ -48333,9 +49966,10 @@ var ts; typeElements.push(preserveCommentsOn(propertySignature)); } function preserveCommentsOn(node) { - if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 333 /* JSDocPropertyTag */; })) { - var d = ts.find(propertySymbol.declarations, function (d) { return d.kind === 333 /* JSDocPropertyTag */; }); - var commentText = d.comment; + var _a; + if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 341 /* JSDocPropertyTag */; })) { + var d = (_a = propertySymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 341 /* 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 }]); } @@ -48364,25 +49998,25 @@ var ts; var mayHaveNameCollisions = !(context.flags & 64 /* 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_4 = []; + var result_5 = []; var i = 0; for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { var type = types_2[_i]; i++; if (checkTruncationLength(context) && (i + 2 < types.length - 1)) { - result_4.push(ts.factory.createTypeReferenceNode("... " + (types.length - i) + " more ...", /*typeArguments*/ undefined)); + result_5.push(ts.factory.createTypeReferenceNode("... " + (types.length - i) + " more ...", /*typeArguments*/ undefined)); var typeNode_1 = typeToTypeNodeHelper(types[types.length - 1], context); if (typeNode_1) { - result_4.push(typeNode_1); + result_5.push(typeNode_1); } break; } context.approximateLength += 2; // Account for whitespace + separator var typeNode = typeToTypeNodeHelper(type, context); if (typeNode) { - result_4.push(typeNode); + result_5.push(typeNode); if (seenNames && ts.isIdentifierTypeReference(typeNode)) { - seenNames.add(typeNode.typeName.escapedText, [type, result_4.length - 1]); + seenNames.add(typeNode.typeName.escapedText, [type, result_5.length - 1]); } } } @@ -48404,13 +50038,13 @@ var ts; })) { for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { var _a = types_3[_i], type = _a[0], resultIndex = _a[1]; - result_4[resultIndex] = typeToTypeNodeHelper(type, context); + result_5[resultIndex] = typeToTypeNodeHelper(type, context); } } }); context.flags = saveContextFlags; } - return result_4; + return result_5; } } function typesAreSameReference(a, b) { @@ -48420,7 +50054,7 @@ var ts; } function indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context, typeNode) { var name = ts.getNameFromIndexInfo(indexInfo) || "x"; - var indexerTypeNode = ts.factory.createKeywordTypeNode(kind === 0 /* String */ ? 147 /* StringKeyword */ : 144 /* NumberKeyword */); + var indexerTypeNode = ts.factory.createKeywordTypeNode(kind === 0 /* String */ ? 148 /* StringKeyword */ : 145 /* NumberKeyword */); var indexingParameter = ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -48435,13 +50069,14 @@ var ts; } context.approximateLength += (name.length + 4); return ts.factory.createIndexSignature( - /*decorators*/ undefined, indexInfo.isReadonly ? [ts.factory.createToken(142 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); + /*decorators*/ undefined, indexInfo.isReadonly ? [ts.factory.createToken(143 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); } function signatureToSignatureDeclarationHelper(signature, kind, context, options) { var _a, _b, _c, _d; var suppressAny = context.flags & 256 /* SuppressAnyReturnType */; if (suppressAny) context.flags &= ~256 /* 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) { @@ -48452,7 +50087,7 @@ 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 === 166 /* Constructor */, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); }); + 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 === 168 /* Constructor */, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -48461,7 +50096,7 @@ var ts; var typePredicate = getTypePredicateOfSignature(signature); if (typePredicate) { var assertsModifier = typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? - ts.factory.createToken(127 /* AssertsKeyword */) : + ts.factory.createToken(128 /* AssertsKeyword */) : undefined; var parameterName = typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.setEmitFlags(ts.factory.createIdentifier(typePredicate.parameterName), 16777216 /* NoAsciiEscaping */) : @@ -48475,29 +50110,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(128 /* AnyKeyword */); + returnTypeNode = ts.factory.createKeywordTypeNode(129 /* AnyKeyword */); } } var modifiers = options === null || options === void 0 ? void 0 : options.modifiers; - if ((kind === 175 /* ConstructorType */) && signature.flags & 4 /* Abstract */) { + if ((kind === 177 /* ConstructorType */) && signature.flags & 4 /* Abstract */) { var flags = ts.modifiersToFlags(modifiers); modifiers = ts.factory.createModifiersFromModifierFlags(flags | 128 /* Abstract */); } - context.approximateLength += 3; // Usually a signature contributes a few more characters than this, but 3 is the minimum - var node = kind === 169 /* CallSignature */ ? ts.factory.createCallSignature(typeParameters, parameters, returnTypeNode) : - kind === 170 /* ConstructSignature */ ? ts.factory.createConstructSignature(typeParameters, parameters, returnTypeNode) : - kind === 164 /* 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 === 165 /* MethodDeclaration */ ? ts.factory.createMethodDeclaration(/*decorators*/ undefined, 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 === 166 /* Constructor */ ? ts.factory.createConstructorDeclaration(/*decorators*/ undefined, modifiers, parameters, /*body*/ undefined) : - kind === 167 /* GetAccessor */ ? ts.factory.createGetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_c = options === null || options === void 0 ? void 0 : options.name) !== null && _c !== void 0 ? _c : ts.factory.createIdentifier(""), parameters, returnTypeNode, /*body*/ undefined) : - kind === 168 /* SetAccessor */ ? ts.factory.createSetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_d = options === null || options === void 0 ? void 0 : options.name) !== null && _d !== void 0 ? _d : ts.factory.createIdentifier(""), parameters, /*body*/ undefined) : - kind === 171 /* IndexSignature */ ? ts.factory.createIndexSignature(/*decorators*/ undefined, modifiers, parameters, returnTypeNode) : - kind === 308 /* JSDocFunctionType */ ? ts.factory.createJSDocFunctionType(parameters, returnTypeNode) : - kind === 174 /* FunctionType */ ? ts.factory.createFunctionTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : - kind === 175 /* ConstructorType */ ? ts.factory.createConstructorTypeNode(modifiers, typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : - kind === 251 /* FunctionDeclaration */ ? ts.factory.createFunctionDeclaration(/*decorators*/ undefined, 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 === 208 /* 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 === 209 /* ArrowFunction */ ? ts.factory.createArrowFunction(modifiers, typeParameters, parameters, returnTypeNode, /*equalsGreaterThanToken*/ undefined, ts.factory.createBlock([])) : + var node = kind === 171 /* CallSignature */ ? ts.factory.createCallSignature(typeParameters, parameters, returnTypeNode) : + kind === 172 /* ConstructSignature */ ? ts.factory.createConstructSignature(typeParameters, parameters, returnTypeNode) : + kind === 166 /* 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 === 167 /* MethodDeclaration */ ? ts.factory.createMethodDeclaration(/*decorators*/ undefined, 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 === 168 /* Constructor */ ? ts.factory.createConstructorDeclaration(/*decorators*/ undefined, modifiers, parameters, /*body*/ undefined) : + kind === 169 /* GetAccessor */ ? ts.factory.createGetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_c = options === null || options === void 0 ? void 0 : options.name) !== null && _c !== void 0 ? _c : ts.factory.createIdentifier(""), parameters, returnTypeNode, /*body*/ undefined) : + kind === 170 /* SetAccessor */ ? ts.factory.createSetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_d = options === null || options === void 0 ? void 0 : options.name) !== null && _d !== void 0 ? _d : ts.factory.createIdentifier(""), parameters, /*body*/ undefined) : + kind === 173 /* IndexSignature */ ? ts.factory.createIndexSignature(/*decorators*/ undefined, modifiers, parameters, returnTypeNode) : + kind === 311 /* JSDocFunctionType */ ? ts.factory.createJSDocFunctionType(parameters, returnTypeNode) : + kind === 176 /* FunctionType */ ? ts.factory.createFunctionTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : + kind === 177 /* ConstructorType */ ? ts.factory.createConstructorTypeNode(modifiers, typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : + kind === 253 /* FunctionDeclaration */ ? ts.factory.createFunctionDeclaration(/*decorators*/ undefined, 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 === 210 /* 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 === 211 /* 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); @@ -48519,9 +50153,9 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags, privateSymbolVisitor, bundledImports) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 160 /* Parameter */); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 162 /* Parameter */); if (!parameterDeclaration && !ts.isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 326 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 334 /* JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -48535,8 +50169,8 @@ var ts; var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* RestParameter */; var dotDotDotToken = isRest ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined; var name = parameterDeclaration ? parameterDeclaration.name ? - parameterDeclaration.name.kind === 78 /* Identifier */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : - parameterDeclaration.name.kind === 157 /* QualifiedName */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 79 /* Identifier */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 159 /* QualifiedName */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : cloneBindingName(parameterDeclaration.name) : ts.symbolName(parameterSymbol) : ts.symbolName(parameterSymbol); @@ -48701,11 +50335,11 @@ var ts; } function getSpecifierForModuleSymbol(symbol, context) { var _a; - var file = ts.getDeclarationOfKind(symbol, 297 /* SourceFile */); + var file = ts.getDeclarationOfKind(symbol, 299 /* SourceFile */); if (!file) { var equivalentFileSymbol = ts.firstDefined(symbol.declarations, function (d) { return getFileSymbolIfFileSymbolExportEqualsContainer(d, symbol); }); if (equivalentFileSymbol) { - file = ts.getDeclarationOfKind(equivalentFileSymbol, 297 /* SourceFile */); + file = ts.getDeclarationOfKind(equivalentFileSymbol, 299 /* SourceFile */); } } if (file && file.moduleName !== undefined) { @@ -48716,8 +50350,8 @@ var ts; if (context.tracker.trackReferencedAmbientModule) { var ambientDecls = ts.filter(symbol.declarations, ts.isAmbientModule); if (ts.length(ambientDecls)) { - for (var _i = 0, ambientDecls_1 = ambientDecls; _i < ambientDecls_1.length; _i++) { - var decl = ambientDecls_1[_i]; + for (var _i = 0, _b = ambientDecls; _i < _b.length; _i++) { + var decl = _b[_i]; context.tracker.trackReferencedAmbientModule(decl, symbol); } } @@ -48744,7 +50378,7 @@ var ts; // specifier preference var moduleResolverHost = context.tracker.moduleResolverHost; var specifierCompilerOptions = isBundle_1 ? __assign(__assign({}, compilerOptions), { baseUrl: moduleResolverHost.getCommonSourceDirectory() }) : compilerOptions; - specifier = ts.first(ts.moduleSpecifiers.getModuleSpecifiers(symbol, checker, specifierCompilerOptions, contextFile, moduleResolverHost, { importModuleSpecifierPreference: isBundle_1 ? "non-relative" : "relative", importModuleSpecifierEnding: isBundle_1 ? "minimal" : undefined })); + specifier = ts.first(ts.moduleSpecifiers.getModuleSpecifiers(symbol, checker, specifierCompilerOptions, contextFile, moduleResolverHost, { importModuleSpecifierPreference: isBundle_1 ? "non-relative" : "project-relative", importModuleSpecifierEnding: isBundle_1 ? "minimal" : undefined })); (_a = links.specifierCache) !== null && _a !== void 0 ? _a : (links.specifierCache = new ts.Map()); links.specifierCache.set(contextFile.path, specifier); } @@ -48857,7 +50491,7 @@ var ts; return false; } function typeParameterToName(type, context) { - var _a; + var _a, _b; if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && context.typeParameterNames) { var cached = context.typeParameterNames.get(getTypeId(type)); if (cached) { @@ -48865,22 +50499,25 @@ var ts; } } var result = symbolToName(type.symbol, context, 788968 /* Type */, /*expectsIdentifier*/ true); - if (!(result.kind & 78 /* Identifier */)) { + if (!(result.kind & 79 /* Identifier */)) { return ts.factory.createIdentifier("(Missing type parameter)"); } if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { var rawtext = result.escapedText; - var i = 0; + var i = ((_a = context.typeParameterNamesByTextNextNameCount) === null || _a === void 0 ? void 0 : _a.get(rawtext)) || 0; var text = rawtext; - while (((_a = context.typeParameterNamesByText) === null || _a === void 0 ? void 0 : _a.has(text)) || typeParameterShadowsNameInScope(text, context, type)) { + while (((_b = context.typeParameterNamesByText) === null || _b === void 0 ? void 0 : _b.has(text)) || typeParameterShadowsNameInScope(text, context, type)) { i++; text = rawtext + "_" + i; } if (text !== rawtext) { result = ts.factory.createIdentifier(text, result.typeArguments); } + // avoiding iterations of the above loop turns out to be worth it when `i` starts to get large, so we cache the max + // `i` we've used thus far, to save work later + (context.typeParameterNamesByTextNextNameCount || (context.typeParameterNamesByTextNextNameCount = new ts.Map())).set(rawtext, i); (context.typeParameterNames || (context.typeParameterNames = new ts.Map())).set(getTypeId(type), result); - (context.typeParameterNamesByText || (context.typeParameterNamesByText = new ts.Set())).add(result.escapedText); + (context.typeParameterNamesByText || (context.typeParameterNamesByText = new ts.Set())).add(rawtext); } return result; } @@ -48888,7 +50525,7 @@ var ts; var chain = lookupSymbolChain(symbol, context, meaning); if (expectsIdentifier && chain.length !== 1 && !context.encounteredError - && !(context.flags & 65536 /* AllowQualifedNameInPlaceOfIdentifier */)) { + && !(context.flags & 65536 /* AllowQualifiedNameInPlaceOfIdentifier */)) { context.encounteredError = true; } return createEntityNameFromSymbolChain(chain, chain.length - 1); @@ -48968,9 +50605,6 @@ var ts; if (fromNameType) { return fromNameType; } - if (ts.isKnownSymbol(symbol)) { - return ts.factory.createComputedPropertyName(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("Symbol"), symbol.escapedName.substr(3))); - } var rawName = ts.unescapeLeadingUnderscores(symbol.escapedName); var stringNamed = !!ts.length(symbol.declarations) && ts.every(symbol.declarations, isStringNamed); return createPropertyNameNodeForIdentifierOrLiteral(rawName, stringNamed, singleQuote); @@ -49022,6 +50656,7 @@ var ts; if (initial.typeParameterSymbolList) { initial.typeParameterSymbolList = new ts.Set(initial.typeParameterSymbolList); } + initial.tracker = wrapSymbolTrackerToReportForContext(initial, initial.tracker); return initial; } function getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration) { @@ -49037,13 +50672,13 @@ var ts; function serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled) { if (type !== errorType && enclosingDeclaration) { var declWithExistingAnnotation = getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration); - if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation)) { + if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation) && !ts.isGetAccessorDeclaration(declWithExistingAnnotation)) { // try to reuse the existing annotation var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation); if (getTypeFromTypeNode(existing) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) { - var result_5 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled); - if (result_5) { - return result_5; + var result_6 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled); + if (result_6) { + return result_6; } } } @@ -49060,10 +50695,14 @@ var ts; function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) { if (type !== errorType && context.enclosingDeclaration) { var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); - if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation && instantiateType(getTypeFromTypeNode(annotation), signature.mapper) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) { - var result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled); - if (result) { - return result; + 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; + if (thisInstantiated === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) { + var result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled); + if (result) { + return result; + } } } } @@ -49107,17 +50746,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 === 310 /* JSDocNamepathType */) { - return ts.factory.createKeywordTypeNode(128 /* AnyKeyword */); + if (ts.isJSDocAllType(node) || node.kind === 313 /* JSDocNamepathType */) { + return ts.factory.createKeywordTypeNode(129 /* AnyKeyword */); } if (ts.isJSDocUnknownType(node)) { - return ts.factory.createKeywordTypeNode(152 /* UnknownKeyword */); + return ts.factory.createKeywordTypeNode(153 /* 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(150 /* UndefinedKeyword */)]); + return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createKeywordTypeNode(151 /* UndefinedKeyword */)]); } if (ts.isJSDocNonNullableType(node)) { return ts.visitNode(node.type, visitExistingNodeTreeSymbols); @@ -49131,11 +50770,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(128 /* AnyKeyword */)); + /*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(129 /* AnyKeyword */)); })); } if (ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "") { - return ts.setOriginalNode(ts.factory.createKeywordTypeNode(128 /* AnyKeyword */), node); + return ts.setOriginalNode(ts.factory.createKeywordTypeNode(129 /* AnyKeyword */), node); } if ((ts.isExpressionWithTypeArguments(node) || ts.isTypeReferenceNode(node)) && ts.isJSDocIndexSignature(node)) { return ts.factory.createTypeLiteralNode([ts.factory.createIndexSignature( @@ -49152,13 +50791,13 @@ var ts; return ts.factory.createConstructorTypeNode(node.modifiers, 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( /*decorators*/ undefined, /*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(128 /* AnyKeyword */)); + /*initializer*/ undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(129 /* AnyKeyword */)); } else { return ts.factory.createFunctionTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.map(node.parameters, function (p, i) { return ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, getEffectiveDotDotDotForParameter(p), getNameForJSDocFunctionParameter(p, i), p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), - /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(128 /* AnyKeyword */)); + /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(129 /* AnyKeyword */)); } } if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(getTypeReferenceName(node), 788968 /* Type */, /*ignoreErrors*/ true))) { @@ -49226,8 +50865,8 @@ var ts; } } function symbolTableToDeclarationStatements(symbolTable, context, bundled) { - var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.factory.createPropertyDeclaration, 165 /* MethodDeclaration */, /*useAcessors*/ true); - var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type) { return ts.factory.createPropertySignature(mods, name, question, type); }, 164 /* MethodSignature */, /*useAcessors*/ false); + var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.factory.createPropertyDeclaration, 167 /* MethodDeclaration */, /*useAcessors*/ true); + var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type) { return ts.factory.createPropertySignature(mods, name, question, type); }, 166 /* 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 @@ -49239,7 +50878,7 @@ var ts; var deferredPrivatesStack = []; 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); + var accessibleResult = isSymbolAccessible(sym, decl, meaning, /*computeAliases*/ false); if (accessibleResult.accessibility === 0 /* 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); @@ -49248,9 +50887,11 @@ var ts; } } else if (oldcontext.tracker && oldcontext.tracker.trackSymbol) { - oldcontext.tracker.trackSymbol(sym, decl, meaning); + return oldcontext.tracker.trackSymbol(sym, decl, meaning); } + return false; } }) }); + context.tracker = wrapSymbolTrackerToReportForContext(context, context.tracker); ts.forEachEntry(symbolTable, function (symbol, name) { var baseName = ts.unescapeLeadingUnderscores(name); void getInternalSymbolName(symbol, baseName); // Called to cache values into `usedSymbolNames` and `remappedSymbolNames` @@ -49265,7 +50906,7 @@ var ts; visitSymbolTable(symbolTable); return mergeRedundantStatements(results); function isIdentifierAndNotUndefined(node) { - return !!node && node.kind === 78 /* Identifier */; + return !!node && node.kind === 79 /* Identifier */; } function getNamesOfDeclaration(statement) { if (ts.isVariableStatement(statement)) { @@ -49434,6 +51075,9 @@ var ts; var oldContext = context; context = cloneNodeBuilderContext(context); var result = serializeSymbolWorker(symbol, isPrivate, propertyAsAlias); + if (context.reportedDiagnostic) { + oldcontext.reportedDiagnostic = context.reportedDiagnostic; // hoist diagnostic result into outer context + } context = oldContext; return result; } @@ -49448,6 +51092,7 @@ var ts; // If it's a class/interface/function: emit a class/interface/function with a `default` modifier // These forms can merge, eg (`export default 12; export default interface A {}`) function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias) { + var _a, _b; var symbolName = ts.unescapeLeadingUnderscores(symbol.escapedName); var isDefault = symbol.escapedName === "default" /* Default */; if (isPrivate && !(context.flags & 131072 /* AllowAnonymousIdentifier */) && ts.isStringANonContextualKeyword(symbolName) && !isDefault) { @@ -49506,9 +51151,9 @@ var ts; if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) { textRange = textRange.parent.parent; } - var propertyAccessRequire = ts.find(symbol.declarations, ts.isPropertyAccessExpression); + var propertyAccessRequire = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isPropertyAccessExpression); if (propertyAccessRequire && ts.isBinaryExpression(propertyAccessRequire.parent) && ts.isIdentifier(propertyAccessRequire.parent.right) - && type.symbol && ts.isSourceFile(type.symbol.valueDeclaration)) { + && ((_b = type.symbol) === null || _b === void 0 ? void 0 : _b.valueDeclaration) && ts.isSourceFile(type.symbol.valueDeclaration)) { var alias = localName === propertyAccessRequire.parent.right.escapedText ? undefined : propertyAccessRequire.parent.right; addResult(ts.factory.createExportDeclaration( /*decorators*/ undefined, @@ -49558,7 +51203,10 @@ var ts; serializeEnum(symbol, symbolName, modifierFlags); } if (symbol.flags & 32 /* Class */) { - if (symbol.flags & 4 /* Property */ && ts.isBinaryExpression(symbol.valueDeclaration.parent) && ts.isClassExpression(symbol.valueDeclaration.parent.right)) { + if (symbol.flags & 4 /* Property */ + && symbol.valueDeclaration + && ts.isBinaryExpression(symbol.valueDeclaration.parent) + && ts.isClassExpression(symbol.valueDeclaration.parent.right)) { // Looks like a `module.exports.Sub = class {}` - if we serialize `symbol` as a class, the result will have no members, // since the classiness is actually from the target of the effective alias the symbol is. yes. A BlockScopedVariable|Class|Property // _really_ acts like an Alias, and none of a BlockScopedVariable, Class, or Property. This is the travesty of JS binding today. @@ -49584,12 +51232,14 @@ var ts; if (symbol.flags & 8388608 /* ExportStar */) { // synthesize export * from "moduleReference" // Straightforward - only one thing to do - make an export declaration - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var node = _a[_i]; - var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); - if (!resolvedModule) - continue; - addResult(ts.factory.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, /*exportClause*/ undefined, ts.factory.createStringLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0 /* None */); + if (symbol.declarations) { + for (var _i = 0, _c = symbol.declarations; _i < _c.length; _i++) { + var node = _c[_i]; + var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); + if (!resolvedModule) + continue; + addResult(ts.factory.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, /*exportClause*/ undefined, ts.factory.createStringLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0 /* None */); + } } } if (needsPostExportDefault) { @@ -49627,15 +51277,16 @@ var ts; function addResult(node, additionalModifierFlags) { if (ts.canHaveModifiers(node)) { var newModifierFlags = 0 /* None */; + var enclosingDeclaration_1 = context.enclosingDeclaration && + (ts.isJSDocTypeAlias(context.enclosingDeclaration) ? ts.getSourceFileOfNode(context.enclosingDeclaration) : context.enclosingDeclaration); if (additionalModifierFlags & 1 /* Export */ && - context.enclosingDeclaration && - (isExportingScope(context.enclosingDeclaration) || ts.isModuleDeclaration(context.enclosingDeclaration)) && + 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 */; } if (addingDeclare && !(newModifierFlags & 1 /* Export */) && - (!context.enclosingDeclaration || !(context.enclosingDeclaration.flags & 8388608 /* Ambient */)) && + (!enclosingDeclaration_1 || !(enclosingDeclaration_1.flags & 8388608 /* 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 */; @@ -49650,19 +51301,23 @@ var ts; results.push(node); } function serializeTypeAlias(symbol, symbolName, modifierFlags) { + var _a; var aliasType = getDeclaredTypeOfTypeAlias(symbol); var typeParams = getSymbolLinks(symbol).typeParameters; var typeParamDecls = ts.map(typeParams, function (p) { return typeParameterToDeclaration(p, context); }); - var jsdocAliasDecl = ts.find(symbol.declarations, ts.isJSDocTypeAlias); - var commentText = jsdocAliasDecl ? jsdocAliasDecl.comment || jsdocAliasDecl.parent.comment : undefined; + 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 */; + 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(/*decorators*/ undefined, /*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); context.flags = oldFlags; + context.enclosingDeclaration = oldEnclosingDecl; } function serializeInterface(symbol, symbolName, modifierFlags) { var interfaceType = getDeclaredTypeOfClassOrInterface(symbol); @@ -49671,10 +51326,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, 169 /* CallSignature */); - var constructSignatures = serializeSignatures(1 /* Construct */, interfaceType, baseType, 170 /* ConstructSignature */); + var callSignatures = serializeSignatures(0 /* Call */, interfaceType, baseType, 171 /* CallSignature */); + var constructSignatures = serializeSignatures(1 /* Construct */, interfaceType, baseType, 172 /* ConstructSignature */); var indexSignatures = serializeIndexSignatures(interfaceType, baseType); - var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.factory.createHeritageClause(93 /* ExtendsKeyword */, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b, 111551 /* Value */); }))]; + var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.factory.createHeritageClause(94 /* ExtendsKeyword */, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b, 111551 /* Value */); }))]; addResult(ts.factory.createInterfaceDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, heritageClauses, __spreadArray(__spreadArray(__spreadArray(__spreadArray([], indexSignatures), constructSignatures), callSignatures), members)), modifierFlags); @@ -49741,9 +51396,8 @@ var ts; 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, 251 /* FunctionDeclaration */, context, { name: ts.factory.createIdentifier(localName), privateSymbolVisitor: includePrivateSymbol, bundledImports: bundled }); - // for expressions assigned to `var`s, use the `var` as the text range - addResult(ts.setTextRange(decl, sig.declaration && ts.isVariableDeclaration(sig.declaration.parent) && sig.declaration.parent.parent || sig.declaration), modifierFlags); + var decl = signatureToSignatureDeclarationHelper(sig, 253 /* 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)) { @@ -49751,6 +51405,18 @@ var ts; 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 */) { + return signature.declaration.parent; + } + // for expressions assigned to `var`s, use the `var` as the text range + if (ts.isVariableDeclaration(signature.declaration.parent) && signature.declaration.parent.parent) { + return signature.declaration.parent.parent; + } + } + return signature.declaration; + } function serializeAsNamespaceDeclaration(props, localName, modifierFlags, suppressNewPrivateContext) { if (ts.length(props)) { var localVsRemoteMap = ts.arrayToMultiMap(props, function (p) { @@ -49837,8 +51503,8 @@ var ts; return undefined; } function serializeAsClass(symbol, localName, modifierFlags) { - var _a; - var originalDecl = ts.find(symbol.declarations, ts.isClassLike); + var _a, _b; + var originalDecl = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isClassLike); var oldEnclosing = context.enclosingDeclaration; context.enclosingDeclaration = originalDecl || oldEnclosing; var localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -49849,25 +51515,25 @@ var ts; var implementsExpressions = originalImplements && sanitizeJSDocImplements(originalImplements) || ts.mapDefined(getImplementsTypes(classType), serializeImplementedType); var staticType = getTypeOfSymbol(symbol); - var isClass = !!((_a = staticType.symbol) === null || _a === void 0 ? void 0 : _a.valueDeclaration) && ts.isClassLike(staticType.symbol.valueDeclaration); + var isClass = !!((_b = staticType.symbol) === null || _b === void 0 ? void 0 : _b.valueDeclaration) && ts.isClassLike(staticType.symbol.valueDeclaration); var staticBaseType = isClass ? getBaseConstructorTypeOfClass(staticType) : anyType; - var heritageClauses = __spreadArray(__spreadArray([], !ts.length(baseTypes) ? [] : [ts.factory.createHeritageClause(93 /* ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))]), !ts.length(implementsExpressions) ? [] : [ts.factory.createHeritageClause(116 /* ImplementsKeyword */, implementsExpressions)]); + var heritageClauses = __spreadArray(__spreadArray([], !ts.length(baseTypes) ? [] : [ts.factory.createHeritageClause(94 /* ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))]), !ts.length(implementsExpressions) ? [] : [ts.factory.createHeritageClause(117 /* ImplementsKeyword */, implementsExpressions)]); var symbolProps = getNonInterhitedProperties(classType, baseTypes, getPropertiesOfType(classType)); var publicSymbolProps = ts.filter(symbolProps, function (s) { // `valueDeclaration` could be undefined if inherited from // a union/intersection base type, but inherited properties // don't matter here. var valueDecl = s.valueDeclaration; - return valueDecl && !(ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name)); + return !!valueDecl && !(ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name)); }); var hasPrivateIdentifier = ts.some(symbolProps, function (s) { // `valueDeclaration` could be undefined if inherited from // a union/intersection base type, but inherited properties // don't matter here. var valueDecl = s.valueDeclaration; - return valueDecl && ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name); + return !!valueDecl && ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name); }); // Boil down all private properties into a single one. var privateProperties = hasPrivateIdentifier ? @@ -49890,7 +51556,7 @@ var ts; !ts.some(getSignaturesOfType(staticType, 1 /* Construct */)); var constructors = isNonConstructableClassLikeInJsFile ? [ts.factory.createConstructorDeclaration(/*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(8 /* Private */), [], /*body*/ undefined)] : - serializeSignatures(1 /* Construct */, staticType, staticBaseType, 166 /* Constructor */); + serializeSignatures(1 /* Construct */, staticType, staticBaseType, 168 /* Constructor */); var indexSignatures = serializeIndexSignatures(classType, baseTypes[0]); context.enclosingDeclaration = oldEnclosing; addResult(ts.setTextRange(ts.factory.createClassDeclaration( @@ -49917,8 +51583,8 @@ var ts; var targetName = getInternalSymbolName(target, verbatimTargetName); includePrivateSymbol(target); // the target may be within the same scope - attempt to serialize it first switch (node.kind) { - case 198 /* BindingElement */: - if (((_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.kind) === 249 /* VariableDeclaration */) { + case 200 /* BindingElement */: + if (((_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.kind) === 251 /* VariableDeclaration */) { // const { SomeClass } = require('./lib'); var specifier_1 = getSpecifierForModuleSymbol(target.parent || target, context); // './lib' var propertyName = node.propertyName; @@ -49930,13 +51596,13 @@ var ts; // 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 289 /* ShorthandPropertyAssignment */: - if (((_e = (_d = node.parent) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.kind) === 216 /* BinaryExpression */) { + case 291 /* ShorthandPropertyAssignment */: + if (((_e = (_d = node.parent) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.kind) === 218 /* BinaryExpression */) { // module.exports = { SomeClass } serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), targetName); } break; - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: // commonjs require: const x = require('y') if (ts.isPropertyAccessExpression(node.initializer)) { // const x = require('y').z @@ -49956,7 +51622,7 @@ var ts; break; } // else fall through and treat commonjs require just like import= - case 260 /* ImportEqualsDeclaration */: + case 262 /* 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)) { @@ -49973,13 +51639,13 @@ var ts; ? symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false) : ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)))), isLocalImport ? modifierFlags : 0 /* None */); break; - case 259 /* NamespaceExportDeclaration */: + case 261 /* 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 */); break; - case 262 /* ImportClause */: + case 264 /* ImportClause */: addResult(ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, ts.factory.createIdentifier(localName), /*namedBindings*/ undefined), @@ -49988,18 +51654,18 @@ var ts; // In such cases, the `target` refers to the module itself already ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context))), 0 /* None */); break; - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: addResult(ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*importClause*/ undefined, ts.factory.createNamespaceImport(ts.factory.createIdentifier(localName))), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* None */); break; - case 269 /* NamespaceExport */: + case 271 /* NamespaceExport */: addResult(ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, ts.factory.createNamespaceExport(ts.factory.createIdentifier(localName)), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* None */); break; - case 265 /* ImportSpecifier */: + case 267 /* ImportSpecifier */: addResult(ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause( @@ -50008,7 +51674,7 @@ var ts; ts.factory.createImportSpecifier(localName !== verbatimTargetName ? ts.factory.createIdentifier(verbatimTargetName) : undefined, ts.factory.createIdentifier(localName)) ])), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context))), 0 /* None */); break; - case 270 /* ExportSpecifier */: + case 272 /* 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; @@ -50016,12 +51682,12 @@ var ts; // another file serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), specifier ? verbatimTargetName : targetName, specifier && ts.isStringLiteralLike(specifier) ? ts.factory.createStringLiteral(specifier.text) : undefined); break; - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: serializeMaybeAliasAssignment(symbol); break; - case 216 /* BinaryExpression */: - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 218 /* BinaryExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* 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 @@ -50076,7 +51742,7 @@ var ts; // a visibility error here (as they're not visible within any scope), but we want to hoist them // into the containing scope anyway, so we want to skip the visibility checks. var oldTrack = context.tracker.trackSymbol; - context.tracker.trackSymbol = ts.noop; + context.tracker.trackSymbol = function () { return false; }; if (isExportAssignmentCompatibleSymbolName) { results.push(ts.factory.createExportAssignment( /*decorators*/ undefined, @@ -50155,6 +51821,7 @@ var ts; } function makeSerializePropertySymbol(createProperty, methodKind, useAccessors) { 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 */))) { @@ -50171,7 +51838,7 @@ var ts; } var flag = (modifierFlags & ~256 /* Async */) | (isStatic ? 32 /* Static */ : 0); var name = getPropertyNameNodeForSymbol(p, context); - var firstPropertyLikeDecl = ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isAccessor, ts.isVariableDeclaration, ts.isPropertySignature, ts.isBinaryExpression, ts.isPropertyAccessExpression)); + 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) { var result = []; if (p.flags & 65536 /* SetAccessor */) { @@ -50181,13 +51848,13 @@ var ts; /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "arg", /*questionToken*/ undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled))], - /*body*/ undefined), ts.find(p.declarations, ts.isSetAccessor) || firstPropertyLikeDecl)); + /*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 */; result.push(ts.setTextRange(ts.factory.createGetAccessorDeclaration( /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(flag), name, [], isPrivate_1 ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), - /*body*/ undefined), ts.find(p.declarations, ts.isGetAccessor) || firstPropertyLikeDecl)); + /*body*/ undefined), ((_c = p.declarations) === null || _c === void 0 ? void 0 : _c.find(ts.isGetAccessor)) || firstPropertyLikeDecl)); } return result; } @@ -50198,7 +51865,7 @@ var ts; /*decorators*/ undefined, 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), // TODO: https://github.com/microsoft/TypeScript/pull/32372#discussion_r328386357 // interface members can't have initializers, however class members _can_ - /*initializer*/ undefined), ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isVariableDeclaration)) || firstPropertyLikeDecl); + /*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 */)) { var type = getTypeOfSymbol(p); @@ -50207,7 +51874,7 @@ var ts; return ts.setTextRange(createProperty( /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | flag), name, p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, /*type*/ undefined, - /*initializer*/ undefined), ts.find(p.declarations, ts.isFunctionLikeDeclaration) || signatures[0] && signatures[0].declaration || p.declarations[0]); + /*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]); } var results_1 = []; for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { @@ -50218,7 +51885,8 @@ var ts; questionToken: p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, modifiers: flag ? ts.factory.createModifiersFromModifierFlags(flag) : undefined }); - results_1.push(ts.setTextRange(decl, sig.declaration)); + var location = sig.declaration && ts.isPrototypePropertyAssignment(sig.declaration.parent) ? sig.declaration.parent : sig.declaration; + results_1.push(ts.setTextRange(decl, location)); } return results_1; } @@ -50389,7 +52057,7 @@ var ts; if (flags === void 0) { flags = 16384 /* 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(127 /* 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 /* 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 printer = ts.createPrinter({ removeComments: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); @@ -50434,9 +52102,9 @@ var ts; return "public"; } function getTypeAliasForTypeLiteral(type) { - if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { + if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */ && type.symbol.declarations) { var node = ts.walkUpParenthesizedTypes(type.symbol.declarations[0].parent); - if (node.kind === 254 /* TypeAliasDeclaration */) { + if (node.kind === 256 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -50444,11 +52112,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 257 /* ModuleBlock */ && + node.parent.kind === 259 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 297 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 299 /* SourceFile */ || ts.isAmbientModule(location); } function getNameOfSymbolFromNameType(symbol, context) { var nameType = getSymbolLinks(symbol).nameType; @@ -50507,17 +52175,17 @@ var ts; if (!declaration) { declaration = symbol.declarations[0]; // Declaration may be nameless, but we'll try anyway } - if (declaration.parent && declaration.parent.kind === 249 /* VariableDeclaration */) { + if (declaration.parent && declaration.parent.kind === 251 /* VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } switch (declaration.kind) { - case 221 /* ClassExpression */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 223 /* ClassExpression */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { context.encounteredError = true; } - return declaration.kind === 221 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; + return declaration.kind === 223 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var name = getNameOfSymbolFromNameType(symbol, context); @@ -50534,28 +52202,28 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 324 /* JSDocCallbackTag */: - case 331 /* JSDocTypedefTag */: - case 325 /* JSDocEnumTag */: + case 332 /* JSDocCallbackTag */: + case 339 /* JSDocTypedefTag */: + case 333 /* 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 198 /* BindingElement */: + case 200 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 249 /* VariableDeclaration */: + case 251 /* 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 256 /* ModuleDeclaration */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 251 /* FunctionDeclaration */: - case 255 /* EnumDeclaration */: - case 260 /* ImportEqualsDeclaration */: + case 258 /* ModuleDeclaration */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 253 /* FunctionDeclaration */: + case 257 /* EnumDeclaration */: + case 262 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; @@ -50563,55 +52231,55 @@ var ts; 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 !== 260 /* ImportEqualsDeclaration */ && parent.kind !== 297 /* SourceFile */ && parent.flags & 8388608 /* Ambient */)) { + !(node.kind !== 262 /* ImportEqualsDeclaration */ && parent.kind !== 299 /* SourceFile */ && parent.flags & 8388608 /* Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent); - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: if (ts.hasEffectiveModifier(node, 8 /* Private */ | 16 /* Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so: // falls through - case 166 /* Constructor */: - case 170 /* ConstructSignature */: - case 169 /* CallSignature */: - case 171 /* IndexSignature */: - case 160 /* Parameter */: - case 257 /* ModuleBlock */: - case 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 177 /* TypeLiteral */: - case 173 /* TypeReference */: - case 178 /* ArrayType */: - case 179 /* TupleType */: - case 182 /* UnionType */: - case 183 /* IntersectionType */: - case 186 /* ParenthesizedType */: - case 192 /* NamedTupleMember */: + case 168 /* Constructor */: + case 172 /* ConstructSignature */: + case 171 /* CallSignature */: + case 173 /* IndexSignature */: + case 162 /* Parameter */: + case 259 /* ModuleBlock */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: + case 179 /* TypeLiteral */: + case 175 /* TypeReference */: + case 180 /* ArrayType */: + case 181 /* TupleType */: + case 184 /* UnionType */: + case 185 /* IntersectionType */: + case 188 /* ParenthesizedType */: + case 194 /* 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 262 /* ImportClause */: - case 263 /* NamespaceImport */: - case 265 /* ImportSpecifier */: + case 264 /* ImportClause */: + case 265 /* NamespaceImport */: + case 267 /* ImportSpecifier */: return false; // Type parameters are always visible - case 159 /* TypeParameter */: + case 161 /* TypeParameter */: // Source file and namespace export are always visible // falls through - case 297 /* SourceFile */: - case 259 /* NamespaceExportDeclaration */: + case 299 /* SourceFile */: + case 261 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return false; default: return false; @@ -50620,10 +52288,10 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 266 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 268 /* ExportAssignment */) { exportSymbol = resolveName(node, node.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 270 /* ExportSpecifier */) { + else if (node.parent.kind === 272 /* ExportSpecifier */) { exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } var result; @@ -50728,12 +52396,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 249 /* VariableDeclaration */: - case 250 /* VariableDeclarationList */: - case 265 /* ImportSpecifier */: - case 264 /* NamedImports */: - case 263 /* NamespaceImport */: - case 262 /* ImportClause */: + case 251 /* VariableDeclaration */: + case 252 /* VariableDeclarationList */: + case 267 /* ImportSpecifier */: + case 266 /* NamedImports */: + case 265 /* NamespaceImport */: + case 264 /* ImportClause */: return false; default: return true; @@ -50796,9 +52464,16 @@ var ts; var stringIndexInfo = getIndexInfoOfType(source, 0 /* String */); var numberIndexInfo = getIndexInfoOfType(source, 1 /* Number */); var result = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); - result.objectFlags |= 131072 /* ObjectRestType */; + result.objectFlags |= 8388608 /* ObjectRestType */; return result; } + function isGenericTypeWithUndefinedConstraint(type) { + return !!(type.flags & 465829888 /* Instantiable */) && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 32768 /* 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 */); + } // Determine the control flow type associated with a destructuring declaration or assignment. The following // forms of destructuring are possible: // let { x } = obj; // BindingElement @@ -50833,23 +52508,23 @@ var ts; function getParentElementAccess(node) { var ancestor = node.parent.parent; switch (ancestor.kind) { - case 198 /* BindingElement */: - case 288 /* PropertyAssignment */: + case 200 /* BindingElement */: + case 290 /* PropertyAssignment */: return getSyntheticElementAccess(ancestor); - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return getSyntheticElementAccess(node.parent); - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return ancestor.initializer; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return ancestor.right; } } function getDestructuringPropertyName(node) { var parent = node.parent; - if (node.kind === 198 /* BindingElement */ && parent.kind === 196 /* ObjectBindingPattern */) { + if (node.kind === 200 /* BindingElement */ && parent.kind === 198 /* ObjectBindingPattern */) { return getLiteralPropertyNameText(node.propertyName || node.name); } - if (node.kind === 288 /* PropertyAssignment */ || node.kind === 289 /* ShorthandPropertyAssignment */) { + if (node.kind === 290 /* PropertyAssignment */ || node.kind === 291 /* ShorthandPropertyAssignment */) { return getLiteralPropertyNameText(node.name); } return "" + parent.elements.indexOf(node); @@ -50875,7 +52550,7 @@ var ts; parentType = getTypeWithFacts(parentType, 524288 /* NEUndefined */); } var type; - if (pattern.kind === 196 /* ObjectBindingPattern */) { + if (pattern.kind === 198 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { parentType = getReducedType(parentType); if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { @@ -50895,7 +52570,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 = getConstraintForLocation(getIndexedAccessType(parentType, indexType, /*noUncheckedIndexedAccessCandidate*/ undefined, name, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, 16 /* ExpressionPosition */), declaration.name); + var declaredType = getIndexedAccessType(parentType, indexType, 32 /* ExpressionPosition */, name); type = getFlowTypeOfDestructuring(declaration, declaredType); } } @@ -50915,8 +52590,8 @@ var ts; } else if (isArrayLikeType(parentType)) { var indexType = getLiteralType(index_2); - var accessFlags = hasDefaultValue(declaration) ? 8 /* NoTupleBoundsCheck */ : 0; - var declaredType = getConstraintForLocation(getIndexedAccessTypeOrUndefined(parentType, indexType, /*noUncheckedIndexedAccessCandidate*/ undefined, declaration.name, accessFlags | 16 /* ExpressionPosition */) || errorType, declaration.name); + var accessFlags = 32 /* ExpressionPosition */ | (hasDefaultValue(declaration) ? 16 /* NoTupleBoundsCheck */ : 0); + var declaredType = getIndexedAccessTypeOrUndefined(parentType, indexType, accessFlags, declaration.name) || errorType; type = getFlowTypeOfDestructuring(declaration, declaredType); } else { @@ -50929,11 +52604,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 && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 32768 /* Undefined */) ? - getTypeWithFacts(type, 524288 /* NEUndefined */) : - type; + return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 32768 /* Undefined */) ? getNonUndefinedType(type) : type; } - return widenTypeInferredFromInitializer(declaration, getUnionType([getTypeWithFacts(type, 524288 /* NEUndefined */), checkDeclarationInitializer(declaration)], 2 /* Subtype */)); + return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration)], 2 /* Subtype */)); } function getTypeForDeclarationFromJSDocComment(declaration) { var jsdocType = ts.getJSDocType(declaration); @@ -50944,25 +52617,26 @@ var ts; } function isNullOrUndefined(node) { var expr = ts.skipParentheses(node); - return expr.kind === 103 /* NullKeyword */ || expr.kind === 78 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; + return expr.kind === 104 /* NullKeyword */ || expr.kind === 79 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 199 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 201 /* ArrayLiteralExpression */ && expr.elements.length === 0; } - function addOptionality(type, optional) { - if (optional === void 0) { optional = true; } - return strictNullChecks && optional ? getOptionalType(type) : type; + function addOptionality(type, isProperty, isOptional) { + if (isProperty === void 0) { isProperty = false; } + if (isOptional === void 0) { isOptional = true; } + return strictNullChecks && isOptional ? getOptionalType(type, isProperty) : type; } // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { // 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 === 238 /* ForInStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 240 /* ForInStatement */) { var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression))); return indexType.flags & (262144 /* TypeParameter */ | 4194304 /* Index */) ? getExtractStringType(indexType) : stringType; } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 239 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 241 /* 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, @@ -50973,13 +52647,14 @@ var ts; if (ts.isBindingPattern(declaration.parent)) { return getTypeForBindingElement(declaration); } - var isOptional = includeOptionality && (ts.isParameter(declaration) && isJSDocOptionalParameter(declaration) - || isOptionalJSDocPropertyLikeTag(declaration) - || !ts.isBindingElement(declaration) && !ts.isVariableDeclaration(declaration) && !!declaration.questionToken); + var isProperty = ts.isPropertyDeclaration(declaration) || ts.isPropertySignature(declaration); + var isOptional = includeOptionality && (isProperty && !!declaration.questionToken || + ts.isParameter(declaration) && (!!declaration.questionToken || isJSDocOptionalParameter(declaration)) || + isOptionalJSDocPropertyLikeTag(declaration)); // Use type from type annotation if one is present var declaredType = tryGetTypeFromEffectiveTypeNode(declaration); if (declaredType) { - return addOptionality(declaredType, isOptional); + return addOptionality(declaredType, isProperty, isOptional); } if ((noImplicitAny || ts.isInJSFile(declaration)) && ts.isVariableDeclaration(declaration) && !ts.isBindingPattern(declaration.name) && @@ -50999,8 +52674,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 === 168 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 167 /* GetAccessor */); + if (func.kind === 170 /* SetAccessor */ && hasBindableName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 169 /* GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -51023,7 +52698,7 @@ var ts; // Use contextual parameter type if one is available var type = declaration.symbol.escapedName === "this" /* This */ ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration); if (type) { - return addOptionality(type, isOptional); + return addOptionality(type, /*isProperty*/ false, isOptional); } } // Use the type of the initializer expression if one is present and the declaration is @@ -51036,7 +52711,7 @@ var ts; } } var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration)); - return addOptionality(type, isOptional); + return addOptionality(type, isProperty, isOptional); } if (ts.isPropertyDeclaration(declaration) && !ts.hasStaticModifier(declaration) && (noImplicitAny || ts.isInJSFile(declaration))) { // We have a property declaration with no type annotation or initializer, in noImplicitAny mode or a .js file. @@ -51045,7 +52720,7 @@ var ts; var type = constructor ? getFlowTypeInConstructor(declaration.symbol, constructor) : ts.getEffectiveModifierFlags(declaration) & 2 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : undefined; - return type && addOptionality(type, isOptional); + return type && addOptionality(type, /*isProperty*/ true, isOptional); } if (ts.isJsxAttribute(declaration)) { // if JSX attribute doesn't have initializer, by default the attribute will have boolean value of true. @@ -51071,7 +52746,7 @@ var ts; links.isConstructorDeclaredProperty = !!getDeclaringConstructor(symbol) && ts.every(symbol.declarations, function (declaration) { return ts.isBinaryExpression(declaration) && isPossiblyAliasedThisProperty(declaration) && - (declaration.left.kind !== 202 /* ElementAccessExpression */ || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) && + (declaration.left.kind !== 204 /* ElementAccessExpression */ || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) && !getAnnotatedTypeForAssignmentDeclaration(/*declaredType*/ undefined, declaration, symbol, declaration); }); } @@ -51087,13 +52762,33 @@ var ts; !declaration.initializer && (noImplicitAny || ts.isInJSFile(declaration)); } function getDeclaringConstructor(symbol) { + if (!symbol.declarations) { + return; + } 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 === 166 /* Constructor */ || isJSConstructor(container))) { + if (container && (container.kind === 168 /* Constructor */ || isJSConstructor(container))) { return container; } } + ; + } + /** Create a synthetic property access flow node after the last statement of the file */ + function getFlowTypeFromCommonJSExport(symbol) { + var file = ts.getSourceFileOfNode(symbol.declarations[0]); + var accessName = ts.unescapeLeadingUnderscores(symbol.escapedName); + var areAllModuleExports = symbol.declarations.every(function (d) { return ts.isInJSFile(d) && ts.isAccessExpression(d) && ts.isModuleExportsAccessExpression(d.expression); }); + var reference = areAllModuleExports + ? ts.factory.createPropertyAccessExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("module"), ts.factory.createIdentifier("exports")), accessName) + : ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("exports"), accessName); + if (areAllModuleExports) { + ts.setParent(reference.expression.expression, reference.expression); + } + ts.setParent(reference.expression, reference); + ts.setParent(reference, file); + reference.flowNode = file.endFlowNode; + return getFlowTypeOfReference(reference, autoType, undefinedType); } function getFlowTypeInConstructor(symbol, constructor) { var accessName = ts.startsWith(symbol.escapedName, "__#") @@ -51111,7 +52806,10 @@ var ts; return everyType(flowType, isNullableType) ? undefined : convertAutoToAny(flowType); } function getFlowTypeOfProperty(reference, prop) { - var initialType = prop && (!isAutoTypedProperty(prop) || ts.getEffectiveModifierFlags(prop.valueDeclaration) & 2 /* Ambient */) && getTypeOfPropertyInBaseClass(prop) || undefinedType; + var initialType = (prop === null || prop === void 0 ? void 0 : prop.valueDeclaration) + && (!isAutoTypedProperty(prop) || ts.getEffectiveModifierFlags(prop.valueDeclaration) & 2 /* Ambient */) + && getTypeOfPropertyInBaseClass(prop) + || undefinedType; return getFlowTypeOfReference(reference, autoType, initialType); } function getWidenedTypeForAssignmentDeclaration(symbol, resolvedSymbol) { @@ -51122,7 +52820,7 @@ var ts; if (tag && tag.typeExpression) { return getTypeFromTypeNode(tag.typeExpression); } - var containerObjectType = getJSContainerObjectType(symbol.valueDeclaration, symbol, container); + var containerObjectType = symbol.valueDeclaration && getJSContainerObjectType(symbol.valueDeclaration, symbol, container); return containerObjectType || getWidenedLiteralType(checkExpressionCached(container)); } var type; @@ -51134,40 +52832,42 @@ var ts; type = getFlowTypeInConstructor(symbol, getDeclaringConstructor(symbol)); } if (!type) { - var jsdocType = void 0; var types = void 0; - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration : - ts.isAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : - undefined; - if (!expression) { - continue; // Non-assignment declaration merged in (eg, an Identifier to mark the thing as a namespace) - skip over it and pull type info from elsewhere - } - var kind = ts.isAccessExpression(expression) - ? ts.getAssignmentDeclarationPropertyAccessKind(expression) - : ts.getAssignmentDeclarationKind(expression); - if (kind === 4 /* ThisProperty */ || ts.isBinaryExpression(expression) && isPossiblyAliasedThisProperty(expression, kind)) { - if (isDeclarationInConstructor(expression)) { - definedInConstructor = true; + if (symbol.declarations) { + var jsdocType = void 0; + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration : + ts.isAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : + undefined; + if (!expression) { + continue; // Non-assignment declaration merged in (eg, an Identifier to mark the thing as a namespace) - skip over it and pull type info from elsewhere } - else { - definedInMethod = true; + var kind = ts.isAccessExpression(expression) + ? ts.getAssignmentDeclarationPropertyAccessKind(expression) + : ts.getAssignmentDeclarationKind(expression); + if (kind === 4 /* ThisProperty */ || ts.isBinaryExpression(expression) && isPossiblyAliasedThisProperty(expression, kind)) { + if (isDeclarationInConstructor(expression)) { + definedInConstructor = true; + } + else { + definedInMethod = true; + } + } + if (!ts.isCallExpression(expression)) { + jsdocType = getAnnotatedTypeForAssignmentDeclaration(jsdocType, expression, symbol, declaration); + } + if (!jsdocType) { + (types || (types = [])).push((ts.isBinaryExpression(expression) || ts.isCallExpression(expression)) ? getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) : neverType); } } - if (!ts.isCallExpression(expression)) { - jsdocType = getAnnotatedTypeForAssignmentDeclaration(jsdocType, expression, symbol, declaration); - } - if (!jsdocType) { - (types || (types = [])).push((ts.isBinaryExpression(expression) || ts.isCallExpression(expression)) ? getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) : neverType); - } + type = jsdocType; } - type = jsdocType; if (!type) { if (!ts.length(types)) { return errorType; // No types from any declarations :( } - var constructorTypes = definedInConstructor ? getConstructorDefinedThisAssignmentTypes(types, symbol.declarations) : undefined; + var constructorTypes = definedInConstructor && symbol.declarations ? getConstructorDefinedThisAssignmentTypes(types, symbol.declarations) : undefined; // use only the constructor types unless they were only assigned null | undefined (including widening variants) if (definedInMethod) { var propType = getTypeOfPropertyInBaseClass(symbol); @@ -51180,8 +52880,8 @@ var ts; type = getUnionType(sourceTypes, 2 /* Subtype */); } } - var widened = getWidenedType(addOptionality(type, definedInMethod && !definedInConstructor)); - if (filterType(widened, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) === neverType) { + var widened = getWidenedType(addOptionality(type, /*isProperty*/ false, definedInMethod && !definedInConstructor)); + if (symbol.valueDeclaration && filterType(widened, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) === neverType) { reportImplicitAny(symbol.valueDeclaration, anyType); return anyType; } @@ -51205,10 +52905,11 @@ var ts; mergeSymbolTable(exports, s.exports); } var type = createAnonymousType(symbol, exports, ts.emptyArray, ts.emptyArray, undefined, undefined); - type.objectFlags |= 16384 /* JSLiteral */; + type.objectFlags |= 8192 /* JSLiteral */; return type; } function getAnnotatedTypeForAssignmentDeclaration(declaredType, expression, symbol, declaration) { + var _a; var typeNode = ts.getEffectiveTypeAnnotationNode(expression.parent); if (typeNode) { var type = getWidenedType(getTypeFromTypeNode(typeNode)); @@ -51219,10 +52920,13 @@ var ts; errorNextVariableOrPropertyDeclarationMustHaveSameType(/*firstDeclaration*/ undefined, declaredType, declaration, type); } } - if (symbol.parent) { + if ((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.valueDeclaration) { var typeNode_2 = ts.getEffectiveTypeAnnotationNode(symbol.parent.valueDeclaration); if (typeNode_2) { - return getTypeOfPropertyOfType(getTypeFromTypeNode(typeNode_2), symbol.escapedName); + var annotationSymbol = getPropertyOfType(getTypeFromTypeNode(typeNode_2), symbol.escapedName); + if (annotationSymbol) { + return getNonMissingTypeOfSymbol(annotationSymbol); + } } } return declaredType; @@ -51283,7 +52987,7 @@ var ts; // but we may have a JS file with `module.exports = { a: true }` along with a TypeScript module augmentation // declaring an `export const a: number`. In that case, we issue a duplicate identifier error, because // it's unclear what that's supposed to mean, so it's probably a mistake. - if (ts.getSourceFileOfNode(s.valueDeclaration) !== ts.getSourceFileOfNode(exportedMember.valueDeclaration)) { + if (s.valueDeclaration && exportedMember.valueDeclaration && ts.getSourceFileOfNode(s.valueDeclaration) !== ts.getSourceFileOfNode(exportedMember.valueDeclaration)) { var unescapedName = ts.unescapeLeadingUnderscores(s.escapedName); var exportedMemberName = ((_a = ts.tryCast(exportedMember.valueDeclaration, ts.isNamedDeclaration)) === null || _a === void 0 ? void 0 : _a.name) || exportedMember.valueDeclaration; ts.addRelatedInfo(error(s.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0, unescapedName), ts.createDiagnosticForNode(exportedMemberName, ts.Diagnostics._0_was_also_declared_here, unescapedName)); @@ -51305,9 +53009,9 @@ var ts; }); var result = createAnonymousType(initialSize !== members_4.size ? undefined : exportedType.symbol, // Only set the type's symbol if it looks to be the same as the original type members_4, exportedType.callSignatures, exportedType.constructSignatures, exportedType.stringIndexInfo, exportedType.numberIndexInfo); - result.objectFlags |= (ts.getObjectFlags(type) & 16384 /* JSLiteral */); // Propagate JSLiteral flag + result.objectFlags |= (ts.getObjectFlags(type) & 8192 /* JSLiteral */); // Propagate JSLiteral flag if (result.symbol && result.symbol.flags & 32 /* Class */ && type === getDeclaredTypeOfClassOrInterface(result.symbol)) { - result.objectFlags |= 1073741824 /* IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type + result.objectFlags |= 16777216 /* IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type } return result; } @@ -51319,16 +53023,16 @@ var ts; } function containsSameNamedThisProperty(thisProperty, expression) { return ts.isPropertyAccessExpression(thisProperty) - && thisProperty.expression.kind === 107 /* ThisKeyword */ + && thisProperty.expression.kind === 108 /* 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 === 166 /* Constructor */ || - thisContainer.kind === 251 /* FunctionDeclaration */ || - (thisContainer.kind === 208 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + return thisContainer.kind === 168 /* Constructor */ || + thisContainer.kind === 253 /* FunctionDeclaration */ || + (thisContainer.kind === 210 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); } function getConstructorDefinedThisAssignmentTypes(types, declarations) { ts.Debug.assert(types.length === declarations.length); @@ -51366,7 +53070,7 @@ var ts; function getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) { var members = ts.createSymbolTable(); var stringIndexInfo; - var objectFlags = 128 /* ObjectLiteral */ | 1048576 /* ContainsObjectOrArrayLiteral */; + var objectFlags = 128 /* ObjectLiteral */ | 262144 /* ContainsObjectOrArrayLiteral */; ts.forEach(pattern.elements, function (e) { var name = e.propertyName || e.name; if (e.dotDotDotToken) { @@ -51390,7 +53094,7 @@ var ts; result.objectFlags |= objectFlags; if (includePatternInType) { result.pattern = pattern; - result.objectFlags |= 1048576 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= 262144 /* ContainsObjectOrArrayLiteral */; } return result; } @@ -51398,7 +53102,7 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - var restElement = lastElement && lastElement.kind === 198 /* BindingElement */ && lastElement.dotDotDotToken ? lastElement : undefined; + var restElement = lastElement && lastElement.kind === 200 /* BindingElement */ && lastElement.dotDotDotToken ? lastElement : undefined; if (elements.length === 0 || elements.length === 1 && restElement) { return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; } @@ -51409,7 +53113,7 @@ var ts; if (includePatternInType) { result = cloneTypeReference(result); result.pattern = pattern; - result.objectFlags |= 1048576 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= 262144 /* ContainsObjectOrArrayLiteral */; } return result; } @@ -51423,7 +53127,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 196 /* ObjectBindingPattern */ + return pattern.kind === 198 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -51439,8 +53143,17 @@ var ts; function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) { return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true), declaration, reportErrors); } + function isGlobalSymbolConstructor(node) { + var symbol = getSymbolOfNode(node); + var globalSymbol = getGlobalESSymbolConstructorTypeSymbol(/*reportErrors*/ false); + return globalSymbol && symbol && symbol === globalSymbol; + } 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)) { + type = getESSymbolLikeTypeForNode(declaration); + } if (reportErrors) { reportErrorsFromWidening(declaration, type); } @@ -51462,7 +53175,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 160 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 162 /* Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(declaration) { @@ -51493,19 +53206,31 @@ var ts; if (symbol === requireSymbol) { return anyType; } - if (symbol.flags & 134217728 /* ModuleExports */) { + if (symbol.flags & 134217728 /* ModuleExports */ && symbol.valueDeclaration) { var fileSymbol = getSymbolOfNode(ts.getSourceFileOfNode(symbol.valueDeclaration)); + var result = createSymbol(fileSymbol.flags, "exports"); + result.declarations = fileSymbol.declarations ? fileSymbol.declarations.slice() : []; + result.parent = symbol; + result.target = fileSymbol; + if (fileSymbol.valueDeclaration) + result.valueDeclaration = fileSymbol.valueDeclaration; + if (fileSymbol.members) + result.members = new ts.Map(fileSymbol.members); + if (fileSymbol.exports) + result.exports = new ts.Map(fileSymbol.exports); var members = ts.createSymbolTable(); - members.set("exports", fileSymbol); + members.set("exports", result); return createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, undefined, undefined); } // Handle catch clause variables + ts.Debug.assertIsDefined(symbol.valueDeclaration); var declaration = symbol.valueDeclaration; if (ts.isCatchClauseVariableDeclarationOrBindingElement(declaration)) { - var decl = declaration; - if (!decl.type) - return anyType; - var type_1 = getTypeOfNode(decl.type); + var typeNode = ts.getEffectiveTypeAnnotationNode(declaration); + if (typeNode === undefined) { + return useUnknownInCatchVariables ? unknownType : anyType; + } + var type_1 = getTypeOfNode(typeNode); // an errorType will make `checkTryStatement` issue an error return isTypeAny(type_1) || type_1 === unknownType ? type_1 : errorType; } @@ -51525,7 +53250,7 @@ var ts; return reportCircularityError(symbol); } var type; - if (declaration.kind === 266 /* ExportAssignment */) { + if (declaration.kind === 268 /* ExportAssignment */) { type = widenTypeForVariableLikeDeclaration(checkExpressionCached(declaration.expression), declaration); } else if (ts.isBinaryExpression(declaration) || @@ -51580,7 +53305,7 @@ var ts; type = getTypeOfEnumMember(symbol); } else if (ts.isAccessor(declaration)) { - type = resolveTypeOfAccessors(symbol); + type = resolveTypeOfAccessors(symbol) || ts.Debug.fail("Non-write accessor resolution must always produce a type"); } else { return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.formatSyntaxKind(declaration.kind) + " for " + ts.Debug.formatSymbol(symbol)); @@ -51596,7 +53321,7 @@ var ts; } function getAnnotatedAccessorTypeNode(accessor) { if (accessor) { - if (accessor.kind === 167 /* GetAccessor */) { + if (accessor.kind === 169 /* GetAccessor */) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation; } @@ -51620,63 +53345,78 @@ var ts; } function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); - return links.type || (links.type = getTypeOfAccessorsWorker(symbol)); + return links.type || (links.type = getTypeOfAccessorsWorker(symbol) || ts.Debug.fail("Read type of accessor must always produce a type")); + } + function getTypeOfSetAccessor(symbol) { + var links = getSymbolLinks(symbol); + return links.writeType || (links.writeType = getTypeOfAccessorsWorker(symbol, /*writing*/ true)); } - function getTypeOfAccessorsWorker(symbol) { + function getTypeOfAccessorsWorker(symbol, writing) { + if (writing === void 0) { writing = false; } if (!pushTypeResolution(symbol, 0 /* Type */)) { return errorType; } - var type = resolveTypeOfAccessors(symbol); + var type = resolveTypeOfAccessors(symbol, writing); if (!popTypeResolution()) { type = anyType; if (noImplicitAny) { - var getter = ts.getDeclarationOfKind(symbol, 167 /* GetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 169 /* GetAccessor */); error(getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } return type; } - function resolveTypeOfAccessors(symbol) { - var getter = ts.getDeclarationOfKind(symbol, 167 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 168 /* SetAccessor */); + function resolveTypeOfAccessors(symbol, writing) { + if (writing === void 0) { writing = false; } + var getter = ts.getDeclarationOfKind(symbol, 169 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 170 /* SetAccessor */); + var setterType = getAnnotatedAccessorType(setter); + // For write operations, prioritize type annotations on the setter + if (writing && setterType) { + return instantiateTypeIfNeeded(setterType, symbol); + } + // Else defer to the getter type if (getter && ts.isInJSFile(getter)) { var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { - return jsDocType; + return instantiateTypeIfNeeded(jsDocType, symbol); } } - // First try to see if the user specified a return type on the get-accessor. - var getterReturnType = getAnnotatedAccessorType(getter); - if (getterReturnType) { - return getterReturnType; + // Try to see if the user specified a return type on the get-accessor. + var getterType = getAnnotatedAccessorType(getter); + if (getterType) { + return instantiateTypeIfNeeded(getterType, symbol); } - else { - // If the user didn't specify a return type, try to use the set-accessor's parameter type. - var setterParameterType = getAnnotatedAccessorType(setter); - if (setterParameterType) { - return setterParameterType; + // If the user didn't specify a return type, try to use the set-accessor's parameter type. + if (setterType) { + return setterType; + } + // If there are no specified types, try to infer it from the body of the get accessor if it exists. + if (getter && getter.body) { + var returnTypeFromBody = getReturnTypeFromBody(getter); + return instantiateTypeIfNeeded(returnTypeFromBody, symbol); + } + // Otherwise, fall back to 'any'. + if (setter) { + if (!isPrivateWithinAmbient(setter)) { + errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol)); } - else { - // If there are no specified types, try to infer it from the body of the get accessor if it exists. - if (getter && getter.body) { - return getReturnTypeFromBody(getter); - } - // Otherwise, fall back to 'any'. - else { - if (setter) { - if (!isPrivateWithinAmbient(setter)) { - errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol)); - } - } - else { - ts.Debug.assert(!!getter, "there must exist a getter as we are current checking either setter or getter in this function"); - if (!isPrivateWithinAmbient(getter)) { - errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol)); - } - } - return anyType; - } + return anyType; + } + else if (getter) { + ts.Debug.assert(!!getter, "there must exist a getter as we are current checking either setter or getter in this function"); + if (!isPrivateWithinAmbient(getter)) { + errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol)); } + return anyType; + } + return undefined; + function instantiateTypeIfNeeded(type, symbol) { + if (ts.getCheckFlags(symbol) & 1 /* Instantiated */) { + var links = getSymbolLinks(symbol); + return instantiateType(type, links.mapper); + } + return type; } } function getBaseTypeVariableOfClass(symbol) { @@ -51706,9 +53446,9 @@ var ts; if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { return anyType; } - else if (declaration && (declaration.kind === 216 /* BinaryExpression */ || + else if (declaration && (declaration.kind === 218 /* BinaryExpression */ || ts.isAccessExpression(declaration) && - declaration.parent.kind === 216 /* BinaryExpression */)) { + declaration.parent.kind === 218 /* BinaryExpression */)) { return getWidenedTypeForAssignmentDeclaration(symbol); } else if (symbol.flags & 512 /* ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { @@ -51742,14 +53482,16 @@ var ts; var links = getSymbolLinks(symbol); if (!links.type) { var targetSymbol = resolveAlias(symbol); + var exportSymbol = symbol.declarations && getTargetOfAliasDeclaration(getDeclarationOfAliasSymbol(symbol), /*dontResolveAlias*/ true); // It only makes sense to get the type of a value symbol. If the result of resolving // the alias is not a value, then it has no type. To get the type associated with a // type symbol, call getDeclaredTypeOfSymbol. // This check is important because without it, a call to getTypeOfSymbol could end // up recursively calling getTypeOfAlias, causing a stack overflow. - links.type = targetSymbol.flags & 111551 /* Value */ - ? getTypeOfSymbol(targetSymbol) - : errorType; + links.type = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.declarations) && isDuplicatedCommonJSExport(exportSymbol.declarations) && symbol.declarations.length ? getFlowTypeFromCommonJSExport(exportSymbol) + : isDuplicatedCommonJSExport(symbol.declarations) ? autoType + : targetSymbol.flags & 111551 /* Value */ ? getTypeOfSymbol(targetSymbol) + : errorType; } return links.type; } @@ -51775,7 +53517,7 @@ var ts; return errorType; } // Check if variable has initializer that circularly references the variable itself - if (noImplicitAny && (declaration.kind !== 160 /* Parameter */ || declaration.initializer)) { + if (noImplicitAny && (declaration.kind !== 162 /* 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 @@ -51792,6 +53534,15 @@ var ts; } return links.type; } + function getSetAccessorTypeOfSymbol(symbol) { + if (symbol.flags & 98304 /* Accessor */) { + var type = getTypeOfSetAccessor(symbol); + if (type) { + return type; + } + } + return getTypeOfSymbol(symbol); + } function getTypeOfSymbol(symbol) { var checkFlags = ts.getCheckFlags(symbol); if (checkFlags & 65536 /* DeferredType */) { @@ -51823,6 +53574,9 @@ var ts; } return errorType; } + function getNonMissingTypeOfSymbol(symbol) { + return removeMissingType(getTypeOfSymbol(symbol), !!(symbol.flags & 16777216 /* Optional */)); + } function isReferenceToType(type, target) { return type !== undefined && target !== undefined @@ -51874,66 +53628,72 @@ var ts; return undefined; } switch (node.kind) { - case 232 /* VariableStatement */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 164 /* MethodSignature */: - case 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 308 /* JSDocFunctionType */: - case 251 /* FunctionDeclaration */: - case 165 /* MethodDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 254 /* TypeAliasDeclaration */: - case 330 /* JSDocTemplateTag */: - case 331 /* JSDocTypedefTag */: - case 325 /* JSDocEnumTag */: - case 324 /* JSDocCallbackTag */: - case 190 /* MappedType */: - case 184 /* ConditionalType */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 166 /* MethodSignature */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: + case 311 /* JSDocFunctionType */: + case 253 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 256 /* TypeAliasDeclaration */: + case 338 /* JSDocTemplateTag */: + case 339 /* JSDocTypedefTag */: + case 333 /* JSDocEnumTag */: + case 332 /* JSDocCallbackTag */: + case 192 /* MappedType */: + case 186 /* ConditionalType */: { var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 190 /* MappedType */) { + if (node.kind === 192 /* MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 184 /* ConditionalType */) { + else if (node.kind === 186 /* ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } - else if (node.kind === 232 /* VariableStatement */ && !ts.isInJSFile(node)) { - break; - } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 252 /* ClassDeclaration */ || node.kind === 221 /* ClassExpression */ || node.kind === 253 /* InterfaceDeclaration */ || isJSConstructor(node)) && + (node.kind === 254 /* ClassDeclaration */ || node.kind === 223 /* ClassExpression */ || node.kind === 255 /* InterfaceDeclaration */ || isJSConstructor(node)) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; - case 326 /* JSDocParameterTag */: + } + case 334 /* JSDocParameterTag */: var paramSymbol = ts.getParameterSymbolFromJSDoc(node); if (paramSymbol) { node = paramSymbol.valueDeclaration; } break; + case 314 /* JSDocComment */: { + var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); + return node.tags + ? appendTypeParameters(outerTypeParameters, ts.flatMap(node.tags, function (t) { return ts.isJSDocTemplateTag(t) ? t.typeParameters : undefined; })) + : outerTypeParameters; + } } } } // 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, 253 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 255 /* InterfaceDeclaration */); ts.Debug.assert(!!declaration, "Class was missing valueDeclaration -OR- non-class had no interface declarations"); return getOuterTypeParameters(declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, // interface, or type alias. function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { + if (!symbol.declarations) { + return; + } var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 253 /* InterfaceDeclaration */ || - node.kind === 252 /* ClassDeclaration */ || - node.kind === 221 /* ClassExpression */ || + if (node.kind === 255 /* InterfaceDeclaration */ || + node.kind === 254 /* ClassDeclaration */ || + node.kind === 223 /* ClassExpression */ || isJSConstructor(node) || ts.isTypeAlias(node)) { var declaration = node; @@ -52027,7 +53787,9 @@ var ts; ctorReturn = getReturnTypeOfSignature(ctorSig[0]); } } - ts.addRelatedInfo(err, ts.createDiagnosticForNode(baseConstructorType.symbol.declarations[0], ts.Diagnostics.Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1, symbolToString(baseConstructorType.symbol), typeToString(ctorReturn))); + if (baseConstructorType.symbol.declarations) { + ts.addRelatedInfo(err, ts.createDiagnosticForNode(baseConstructorType.symbol.declarations[0], ts.Diagnostics.Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1, symbolToString(baseConstructorType.symbol), typeToString(ctorReturn))); + } } return type.resolvedBaseConstructorType = errorType; } @@ -52037,20 +53799,22 @@ var ts; } function getImplementsTypes(type) { var resolvedImplementsTypes = ts.emptyArray; - for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - var implementsTypeNodes = ts.getEffectiveImplementsTypeNodes(declaration); - if (!implementsTypeNodes) - continue; - for (var _b = 0, implementsTypeNodes_1 = implementsTypeNodes; _b < implementsTypeNodes_1.length; _b++) { - var node = implementsTypeNodes_1[_b]; - var implementsType = getTypeFromTypeNode(node); - if (implementsType !== errorType) { - if (resolvedImplementsTypes === ts.emptyArray) { - resolvedImplementsTypes = [implementsType]; - } - else { - resolvedImplementsTypes.push(implementsType); + if (type.symbol.declarations) { + for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + var implementsTypeNodes = ts.getEffectiveImplementsTypeNodes(declaration); + if (!implementsTypeNodes) + continue; + for (var _b = 0, implementsTypeNodes_1 = implementsTypeNodes; _b < implementsTypeNodes_1.length; _b++) { + var node = implementsTypeNodes_1[_b]; + var implementsType = getTypeFromTypeNode(node); + if (implementsType !== errorType) { + if (resolvedImplementsTypes === ts.emptyArray) { + resolvedImplementsTypes = [implementsType]; + } + else { + resolvedImplementsTypes.push(implementsType); + } } } } @@ -52077,10 +53841,10 @@ var ts; else { ts.Debug.fail("type must be class or interface"); } - if (!popTypeResolution()) { + if (!popTypeResolution() && type.symbol.declarations) { for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 252 /* ClassDeclaration */ || declaration.kind === 253 /* InterfaceDeclaration */) { + if (declaration.kind === 254 /* ClassDeclaration */ || declaration.kind === 255 /* InterfaceDeclaration */) { reportCircularBaseType(declaration, type); } } @@ -52173,29 +53937,31 @@ var ts; } function resolveBaseTypesOfInterface(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray; - for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 253 /* 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)); - if (baseType !== errorType) { - if (isValidBaseType(baseType)) { - if (type !== baseType && !hasBaseType(baseType, type)) { - if (type.resolvedBaseTypes === ts.emptyArray) { - type.resolvedBaseTypes = [baseType]; + if (type.symbol.declarations) { + for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 255 /* 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)); + if (baseType !== errorType) { + if (isValidBaseType(baseType)) { + if (type !== baseType && !hasBaseType(baseType, type)) { + if (type.resolvedBaseTypes === ts.emptyArray) { + type.resolvedBaseTypes = [baseType]; + } + else { + type.resolvedBaseTypes.push(baseType); + } } else { - type.resolvedBaseTypes.push(baseType); + reportCircularBaseType(declaration, type); } } else { - reportCircularBaseType(declaration, type); + error(node, ts.Diagnostics.An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_members); } } - else { - error(node, ts.Diagnostics.An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_members); - } } } } @@ -52209,9 +53975,12 @@ var ts; * and if none of the base interfaces have a "this" type. */ function isThislessInterface(symbol) { + if (!symbol.declarations) { + return true; + } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 253 /* InterfaceDeclaration */) { + if (declaration.kind === 255 /* InterfaceDeclaration */) { if (declaration.flags & 128 /* ContainsThis */) { return false; } @@ -52236,7 +54005,7 @@ var ts; var originalLinks = links; if (!links.declaredType) { var kind = symbol.flags & 32 /* Class */ ? 1 /* Class */ : 2 /* Interface */; - var merged = mergeJSSymbols(symbol, getAssignedClassSymbol(symbol.valueDeclaration)); + var merged = mergeJSSymbols(symbol, symbol.valueDeclaration && getAssignedClassSymbol(symbol.valueDeclaration)); if (merged) { // note:we overwrite links because we just cloned the symbol symbol = links = merged; @@ -52266,6 +54035,7 @@ var ts; return links.declaredType; } function getDeclaredTypeOfTypeAlias(symbol) { + var _a; var links = getSymbolLinks(symbol); if (!links.declaredType) { // Note that we use the links object as the target here because the symbol object is used as the unique @@ -52273,7 +54043,7 @@ var ts; if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { return errorType; } - var declaration = ts.Debug.checkDefined(ts.find(symbol.declarations, ts.isTypeAlias), "Type alias symbol with no valid declaration found"); + 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"); var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type; // If typeNode is missing, we will error in checkJSDocTypedefTag. var type = typeNode ? getTypeFromTypeNode(typeNode) : errorType; @@ -52289,7 +54059,12 @@ var ts; } else { type = errorType; - error(ts.isNamedDeclaration(declaration) ? declaration.name : declaration || declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); + if (declaration.kind === 333 /* 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)); + } } links.declaredType = type; } @@ -52299,7 +54074,7 @@ var ts; if (ts.isStringLiteralLike(expr)) { return true; } - else if (expr.kind === 216 /* BinaryExpression */) { + else if (expr.kind === 218 /* BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -52314,12 +54089,12 @@ var ts; case 8 /* NumericLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return true; - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return expr.operator === 40 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; - case 78 /* Identifier */: + case 79 /* Identifier */: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -52331,16 +54106,18 @@ var ts; return links.enumKind; } var hasNonLiteralMember = false; - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 255 /* 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 */; - } - if (!isLiteralEnumMember(member)) { - hasNonLiteralMember = true; + if (symbol.declarations) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 257 /* 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 */; + } + if (!isLiteralEnumMember(member)) { + hasNonLiteralMember = true; + } } } } @@ -52358,15 +54135,17 @@ var ts; if (getEnumKind(symbol) === 1 /* Literal */) { enumCount++; var memberTypeList = []; - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 255 /* EnumDeclaration */) { - for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { - var member = _c[_b]; - var value = getEnumMemberValue(member); - var memberType = getFreshTypeOfLiteralType(getLiteralType(value !== undefined ? value : 0, enumCount, getSymbolOfNode(member))); - getSymbolLinks(getSymbolOfNode(member)).declaredType = memberType; - memberTypeList.push(getRegularTypeOfLiteralType(memberType)); + if (symbol.declarations) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 257 /* EnumDeclaration */) { + for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { + var member = _c[_b]; + var value = getEnumMemberValue(member); + var memberType = getFreshTypeOfLiteralType(getLiteralType(value !== undefined ? value : 0, enumCount, getSymbolOfNode(member))); + getSymbolLinks(getSymbolOfNode(member)).declaredType = memberType; + memberTypeList.push(getRegularTypeOfLiteralType(memberType)); + } } } } @@ -52432,22 +54211,22 @@ var ts; */ function isThislessType(node) { switch (node.kind) { - case 128 /* AnyKeyword */: - case 152 /* UnknownKeyword */: - case 147 /* StringKeyword */: - case 144 /* NumberKeyword */: - case 155 /* BigIntKeyword */: - case 131 /* BooleanKeyword */: - case 148 /* SymbolKeyword */: - case 145 /* ObjectKeyword */: - case 113 /* VoidKeyword */: - case 150 /* UndefinedKeyword */: - case 141 /* NeverKeyword */: - case 191 /* LiteralType */: + case 129 /* AnyKeyword */: + case 153 /* UnknownKeyword */: + case 148 /* StringKeyword */: + case 145 /* NumberKeyword */: + case 156 /* BigIntKeyword */: + case 132 /* BooleanKeyword */: + case 149 /* SymbolKeyword */: + case 146 /* ObjectKeyword */: + case 114 /* VoidKeyword */: + case 151 /* UndefinedKeyword */: + case 142 /* NeverKeyword */: + case 193 /* LiteralType */: return true; - case 178 /* ArrayType */: + case 180 /* ArrayType */: return isThislessType(node.elementType); - case 173 /* TypeReference */: + case 175 /* TypeReference */: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -52473,7 +54252,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 166 /* Constructor */ || (!!returnType && isThislessType(returnType))) && + return (node.kind === 168 /* Constructor */ || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -52489,14 +54268,14 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: return isThislessVariableLikeDeclaration(declaration); - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return isThislessFunctionLikeDeclaration(declaration); } } @@ -52522,7 +54301,7 @@ var ts; } } function isStaticPrivateIdentifierProperty(s) { - return !!s.valueDeclaration && ts.isPrivateIdentifierPropertyDeclaration(s.valueDeclaration) && ts.hasSyntacticModifier(s.valueDeclaration, 32 /* Static */); + return !!s.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(s.valueDeclaration) && ts.hasSyntacticModifier(s.valueDeclaration, 32 /* Static */); } function resolveDeclaredMembers(type) { if (!type.declaredProperties) { @@ -52574,10 +54353,10 @@ var ts; return !!name && isLateBindableName(name); } /** - * Indicates whether a declaration has a dynamic name that cannot be late-bound. + * Indicates whether a declaration has an early-bound name or a dynamic name that can be late-bound. */ - function hasNonBindableDynamicName(node) { - return ts.hasDynamicName(node) && !hasLateBindableName(node); + function hasBindableName(node) { + return !ts.hasDynamicName(node) || hasLateBindableName(node); } /** * Indicates whether a declaration name is a dynamic name that cannot be late-bound. @@ -52847,7 +54626,8 @@ var ts; sig.resolvedMinArgumentCount = undefined; sig.target = undefined; sig.mapper = undefined; - sig.unionSignatures = undefined; + sig.compositeSignatures = undefined; + sig.compositeKind = undefined; return sig; } function cloneSignature(sig) { @@ -52855,12 +54635,14 @@ var ts; /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* PropagatingFlags */); result.target = sig.target; result.mapper = sig.mapper; - result.unionSignatures = sig.unionSignatures; + result.compositeSignatures = sig.compositeSignatures; + result.compositeKind = sig.compositeKind; return result; } function createUnionSignature(signature, unionSignatures) { var result = cloneSignature(signature); - result.unionSignatures = unionSignatures; + result.compositeSignatures = unionSignatures; + result.compositeKind = 1048576 /* Union */; result.target = undefined; result.mapper = undefined; return result; @@ -53019,7 +54801,7 @@ var ts; if (signatures !== masterList) { var signature_1 = signatures[0]; ts.Debug.assert(!!signature_1, "getUnionSignatures bails early on empty signature lists and should not have empty lists on second pass"); - results = signature_1.typeParameters && ts.some(results, function (s) { return !!s.typeParameters && !compareTypeParametersIdentical(signature_1.typeParameters, s.typeParameters); }) ? undefined : ts.map(results, function (sig) { return combineSignaturesOfUnionMembers(sig, signature_1); }); + results = !!signature_1.typeParameters && ts.some(results, function (s) { return !!s.typeParameters && !compareTypeParametersIdentical(signature_1.typeParameters, s.typeParameters); }) ? undefined : ts.map(results, function (sig) { return combineSignaturesOfUnionMembers(sig, signature_1); }); if (!results) { return "break"; } @@ -53036,9 +54818,12 @@ var ts; return result || ts.emptyArray; } function compareTypeParametersIdentical(sourceParams, targetParams) { - if (sourceParams.length !== targetParams.length) { + if (ts.length(sourceParams) !== ts.length(targetParams)) { return false; } + if (!sourceParams || !targetParams) { + return true; + } var mapper = createTypeMapper(targetParams, sourceParams); for (var i = 0; i < sourceParams.length; i++) { var source = sourceParams[i]; @@ -53120,9 +54905,10 @@ var ts; var result = createSignature(declaration, typeParams, thisParam, params, /*resolvedReturnType*/ undefined, /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* PropagatingFlags */); - result.unionSignatures = ts.concatenate(left.unionSignatures || [left], [right]); + result.compositeKind = 1048576 /* Union */; + result.compositeSignatures = ts.concatenate(left.compositeKind !== 2097152 /* Intersection */ && left.compositeSignatures || [left], [right]); if (paramMapper) { - result.mapper = left.mapper && left.unionSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; + result.mapper = left.compositeKind !== 2097152 /* Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; } return result; } @@ -53255,6 +55041,7 @@ var ts; // Combinations of function, class, enum and module var members = emptySymbols; var stringIndexInfo = void 0; + var numberIndexInfo = void 0; if (symbol.exports) { members = getExportsOfSymbol(symbol); if (symbol === globalThisSymbol) { @@ -53267,20 +55054,31 @@ var ts; members = varsOnly_1; } } + var baseConstructorIndexInfo = void 0; setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, undefined, undefined); if (symbol.flags & 32 /* Class */) { var classType = getDeclaredTypeOfClassOrInterface(symbol); var baseConstructorType = getBaseConstructorTypeOfClass(classType); if (baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 8650752 /* TypeVariable */)) { - members = ts.createSymbolTable(getNamedMembers(members)); + members = ts.createSymbolTable(getNamedOrIndexSignatureMembers(members)); addInheritedMembers(members, getPropertiesOfType(baseConstructorType)); } else if (baseConstructorType === anyType) { - stringIndexInfo = createIndexInfo(anyType, /*isReadonly*/ false); + baseConstructorIndexInfo = createIndexInfo(anyType, /*isReadonly*/ false); + } + } + var indexSymbol = getIndexSymbolFromSymbolTable(members); + if (indexSymbol) { + stringIndexInfo = getIndexInfoOfIndexSymbol(indexSymbol, 0 /* String */); + numberIndexInfo = getIndexInfoOfIndexSymbol(indexSymbol, 1 /* Number */); + } + else { + stringIndexInfo = baseConstructorIndexInfo; + if (symbol.flags & 384 /* Enum */ && (getDeclaredTypeOfSymbol(symbol).flags & 32 /* Enum */ || + ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296 /* NumberLike */); }))) { + numberIndexInfo = enumNumberIndexInfo; } } - var numberIndexInfo = symbol.flags & 384 /* Enum */ && (getDeclaredTypeOfSymbol(symbol).flags & 32 /* Enum */ || - ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296 /* NumberLike */); })) ? enumNumberIndexInfo : undefined; setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); // We resolve the members before computing the signatures because a signature may use // typeof with a qualified name expression that circularly references the type we are @@ -53305,6 +55103,18 @@ var ts; } } } + function replaceIndexedAccess(instantiable, type, replacement) { + // map type.indexType to 0 + // map type.objectType to `[TReplacement]` + // thus making the indexed access `[TReplacement][0]` or `TReplacement` + return instantiateType(instantiable, createTypeMapper([type.indexType, type.objectType], [getLiteralType(0), createTupleType([replacement])])); + } + function getIndexInfoOfIndexSymbol(indexSymbol, indexKind) { + var declaration = getIndexDeclarationOfIndexSymbol(indexSymbol, indexKind); + if (!declaration) + return undefined; + return createIndexInfo(declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasEffectiveModifier(declaration, 64 /* Readonly */), declaration); + } function resolveReverseMappedTypeMembers(type) { var indexInfo = getIndexInfoOfType(type.source, 0 /* String */); var modifiers = getMappedTypeModifiers(type.mappedType); @@ -53319,8 +55129,21 @@ var ts; inferredProp.declarations = prop.declarations; inferredProp.nameType = getSymbolLinks(prop).nameType; inferredProp.propertyType = getTypeOfSymbol(prop); - inferredProp.mappedType = type.mappedType; - inferredProp.constraintType = type.constraintType; + if (type.constraintType.type.flags & 8388608 /* IndexedAccess */ + && type.constraintType.type.objectType.flags & 262144 /* TypeParameter */ + && type.constraintType.type.indexType.flags & 262144 /* 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 + var newTypeParam = type.constraintType.type.objectType; + var newMappedType = replaceIndexedAccess(type.mappedType, type.constraintType.type, newTypeParam); + inferredProp.mappedType = newMappedType; + inferredProp.constraintType = getIndexType(newTypeParam); + } + else { + inferredProp.mappedType = type.mappedType; + inferredProp.constraintType = type.constraintType; + } members.set(prop.escapedName, inferredProp); } setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, undefined); @@ -53447,7 +55270,7 @@ 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) : + var type = strictNullChecks && symbol.flags & 16777216 /* Optional */ && !maybeTypeOfKind(propType, 32768 /* Undefined */ | 16384 /* Void */) ? getOptionalType(propType, /*isProperty*/ true) : symbol.checkFlags & 524288 /* StripOptional */ ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : propType; if (!popTypeResolution()) { @@ -53474,7 +55297,7 @@ var ts; function getTemplateTypeFromMappedType(type) { return type.templateType || (type.templateType = type.declaration.type ? - instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), type.mapper) : + instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), /*isProperty*/ true, !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), type.mapper) : errorType); } function getConstraintDeclarationForMappedType(type) { @@ -53482,8 +55305,8 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 188 /* TypeOperator */ && - constraintDeclaration.operator === 138 /* KeyOfKeyword */; + return constraintDeclaration.kind === 190 /* TypeOperator */ && + constraintDeclaration.operator === 139 /* KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { @@ -53534,7 +55357,7 @@ var ts; else if (type.objectFlags & 3 /* ClassOrInterface */) { resolveClassOrInterfaceMembers(type); } - else if (type.objectFlags & 2048 /* ReverseMapped */) { + else if (type.objectFlags & 1024 /* ReverseMapped */) { resolveReverseMappedTypeMembers(type); } else if (type.objectFlags & 16 /* Anonymous */) { @@ -53650,14 +55473,14 @@ var ts; function getConstraintFromIndexedAccess(type) { var indexConstraint = getSimplifiedTypeOrConstraint(type.indexType); if (indexConstraint && indexConstraint !== type.indexType) { - var indexedAccess = getIndexedAccessTypeOrUndefined(type.objectType, indexConstraint, type.noUncheckedIndexedAccessCandidate); + var indexedAccess = getIndexedAccessTypeOrUndefined(type.objectType, indexConstraint, type.accessFlags); if (indexedAccess) { return indexedAccess; } } var objectConstraint = getSimplifiedTypeOrConstraint(type.objectType); if (objectConstraint && objectConstraint !== type.objectType) { - return getIndexedAccessTypeOrUndefined(objectConstraint, type.indexType, type.noUncheckedIndexedAccessCandidate); + return getIndexedAccessTypeOrUndefined(objectConstraint, type.indexType, type.accessFlags); } return undefined; } @@ -53818,12 +55641,22 @@ var ts; if (t.flags & 3145728 /* UnionOrIntersection */) { var types = t.types; var baseTypes = []; + var different = false; for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { var type_3 = types_8[_i]; var baseType = getBaseConstraint(type_3); if (baseType) { + if (baseType !== type_3) { + different = true; + } baseTypes.push(baseType); } + else { + different = true; + } + } + if (!different) { + return t; } return t.flags & 1048576 /* Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) : t.flags & 2097152 /* Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) : @@ -53844,7 +55677,7 @@ var ts; if (t.flags & 8388608 /* IndexedAccess */) { var baseObjectType = getBaseConstraint(t.objectType); var baseIndexType = getBaseConstraint(t.indexType); - var baseIndexedAccess = baseObjectType && baseIndexType && getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, t.noUncheckedIndexedAccessCandidate); + var baseIndexedAccess = baseObjectType && baseIndexType && getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, t.accessFlags); return baseIndexedAccess && getBaseConstraint(baseIndexedAccess); } if (t.flags & 16777216 /* Conditional */) { @@ -53943,6 +55776,7 @@ var ts; return getReducedType(getApparentType(getReducedType(type))); } function createUnionOrIntersectionProperty(containingType, name, skipObjectFunctionPropertyAugment) { + var _a, _b; var singleProp; var propSet; var indexTypes; @@ -53951,8 +55785,9 @@ var ts; var optionalFlag = isUnion ? 0 /* None */ : 16777216 /* Optional */; var syntheticFlag = 4 /* SyntheticMethod */; var checkFlags = 0; - for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { - var current = _a[_i]; + var mergedInstantiations = false; + for (var _i = 0, _c = containingType.types; _i < _c.length; _i++) { + var current = _c[_i]; var type = getApparentType(current); if (!(type === errorType || type.flags & 131072 /* Never */)) { var prop = getPropertyOfType(type, name, skipObjectFunctionPropertyAugment); @@ -53968,13 +55803,25 @@ var ts; singleProp = prop; } else if (prop !== singleProp) { - if (!propSet) { - propSet = new ts.Map(); - propSet.set(getSymbolId(singleProp), singleProp); + var isInstantiation = (getTargetSymbol(prop) || prop) === (getTargetSymbol(singleProp) || singleProp); + // 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 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[]` + mergedInstantiations = !!singleProp.parent && !!ts.length(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(singleProp.parent)); } - var id = getSymbolId(prop); - if (!propSet.has(id)) { - propSet.set(id, prop); + else { + if (!propSet) { + propSet = new ts.Map(); + propSet.set(getSymbolId(singleProp), singleProp); + } + var id = getSymbolId(prop); + if (!propSet.has(id)) { + propSet.set(id, prop); + } } } checkFlags |= (isReadonlySymbol(prop) ? 8 /* Readonly */ : 0) | @@ -53992,7 +55839,7 @@ var ts; checkFlags |= 32 /* WritePartial */ | (indexInfo.isReadonly ? 8 /* Readonly */ : 0); indexTypes = ts.append(indexTypes, isTupleType(type) ? getRestTypeOfTupleType(type) || undefinedType : indexInfo.type); } - else if (isObjectLiteralType(type)) { + else if (isObjectLiteralType(type) && !(ts.getObjectFlags(type) & 4194304 /* ContainsSpread */)) { checkFlags |= 32 /* WritePartial */; indexTypes = ts.append(indexTypes, undefinedType); } @@ -54008,7 +55855,19 @@ var ts; return undefined; } if (!propSet && !(checkFlags & 16 /* ReadPartial */) && !indexTypes) { - return singleProp; + 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!) + // They also have a `.containingType` set, which affects some services endpoints behavior, like `getRootSymbol` + var clone_1 = createSymbolWithType(singleProp, singleProp.type); + clone_1.parent = (_b = (_a = singleProp.valueDeclaration) === null || _a === void 0 ? void 0 : _a.symbol) === null || _b === void 0 ? void 0 : _b.parent; + clone_1.containingType = containingType; + clone_1.mapper = singleProp.mapper; + return clone_1; + } + else { + return singleProp; + } } var props = propSet ? ts.arrayFrom(propSet.values()) : [singleProp]; var declarations; @@ -54017,8 +55876,8 @@ var ts; var propTypes = []; var firstValueDeclaration; var hasNonUniformValueDeclaration = false; - for (var _b = 0, props_1 = props; _b < props_1.length; _b++) { - var prop = props_1[_b]; + for (var _d = 0, props_1 = props; _d < props_1.length; _d++) { + var prop = props_1[_d]; if (!firstValueDeclaration) { firstValueDeclaration = prop.valueDeclaration; } @@ -54095,15 +55954,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 & 268435456 /* ContainsIntersections */) { + if (type.flags & 1048576 /* Union */ && type.objectFlags & 67108864 /* ContainsIntersections */) { return type.resolvedReducedType || (type.resolvedReducedType = getReducedUnionType(type)); } else if (type.flags & 2097152 /* Intersection */) { - if (!(type.objectFlags & 268435456 /* IsNeverIntersectionComputed */)) { - type.objectFlags |= 268435456 /* IsNeverIntersectionComputed */ | - (ts.some(getPropertiesOfUnionOrIntersectionType(type), isNeverReducedProperty) ? 536870912 /* IsNeverIntersection */ : 0); + if (!(type.objectFlags & 67108864 /* IsNeverIntersectionComputed */)) { + type.objectFlags |= 67108864 /* IsNeverIntersectionComputed */ | + (ts.some(getPropertiesOfUnionOrIntersectionType(type), isNeverReducedProperty) ? 134217728 /* IsNeverIntersection */ : 0); } - return type.objectFlags & 536870912 /* IsNeverIntersection */ ? neverType : type; + return type.objectFlags & 134217728 /* IsNeverIntersection */ ? neverType : type; } return type; } @@ -54133,7 +55992,7 @@ var ts; return !prop.valueDeclaration && !!(ts.getCheckFlags(prop) & 1024 /* ContainsPrivate */); } function elaborateNeverIntersection(errorInfo, type) { - if (ts.getObjectFlags(type) & 536870912 /* IsNeverIntersection */) { + if (type.flags & 2097152 /* Intersection */ && ts.getObjectFlags(type) & 134217728 /* 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)); @@ -54220,7 +56079,8 @@ var ts; for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) { var prop = _a[_i]; if (kind === 0 /* String */ || isNumericLiteralName(prop.escapedName)) { - propTypes.push(getTypeOfSymbol(prop)); + var propType = getTypeOfSymbol(prop); + propTypes.push(prop.flags & 16777216 /* Optional */ ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : propType); } } if (kind === 0 /* String */) { @@ -54254,10 +56114,10 @@ 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 === 307 /* JSDocOptionalType */ + node.type && node.type.kind === 310 /* JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 307 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 310 /* JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -54289,12 +56149,15 @@ var ts; } return false; } + function isOptionalPropertyDeclaration(node) { + return ts.isPropertyDeclaration(node) && node.questionToken; + } function isOptionalJSDocPropertyLikeTag(node) { if (!ts.isJSDocPropertyLikeTag(node)) { return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 307 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 310 /* JSDocOptionalType */; } function createTypePredicate(kind, parameterName, parameterIndex, type) { return { kind: kind, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; @@ -54376,7 +56239,7 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 191 /* LiteralType */) { + if (type && type.kind === 193 /* LiteralType */) { flags |= 2 /* HasLiteralTypes */; } // Record a new minimum argument count if this is not an optional parameter @@ -54389,16 +56252,16 @@ 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 === 167 /* GetAccessor */ || declaration.kind === 168 /* SetAccessor */) && - !hasNonBindableDynamicName(declaration) && + if ((declaration.kind === 169 /* GetAccessor */ || declaration.kind === 170 /* SetAccessor */) && + hasBindableName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 167 /* GetAccessor */ ? 168 /* SetAccessor */ : 167 /* GetAccessor */; + var otherKind = declaration.kind === 169 /* GetAccessor */ ? 170 /* SetAccessor */ : 169 /* GetAccessor */; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 166 /* Constructor */ ? + var classType = declaration.kind === 168 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); @@ -54443,8 +56306,7 @@ var ts; if (!(ts.isInJSFile(node) && ts.isFunctionLikeDeclaration(node))) return undefined; var typeTag = ts.getJSDocTypeTag(node); - var signature = typeTag && typeTag.typeExpression && getSingleCallSignature(getTypeFromTypeNode(typeTag.typeExpression)); - return signature && getErasedSignature(signature); + return (typeTag === null || typeTag === void 0 ? void 0 : typeTag.typeExpression) && getSingleCallSignature(getTypeFromTypeNode(typeTag.typeExpression)); } function getReturnTypeOfTypeTag(node) { var signature = getSignatureOfTypeTag(node); @@ -54465,16 +56327,16 @@ var ts; if (!node) return false; switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return node.escapedText === argumentsSymbol.escapedName && getResolvedSymbol(node) === argumentsSymbol; - case 163 /* PropertyDeclaration */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - return node.name.kind === 158 /* ComputedPropertyName */ + case 165 /* PropertyDeclaration */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + return node.name.kind === 160 /* ComputedPropertyName */ && traverse(node.name); - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: return traverse(node.expression); default: return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); @@ -54482,7 +56344,7 @@ var ts; } } function getSignaturesOfSymbol(symbol) { - if (!symbol) + if (!symbol || !symbol.declarations) return ts.emptyArray; var result = []; for (var i = 0; i < symbol.declarations.length; i++) { @@ -54523,8 +56385,8 @@ var ts; var targetTypePredicate = getTypePredicateOfSignature(signature.target); signature.resolvedTypePredicate = targetTypePredicate ? instantiateTypePredicate(targetTypePredicate, signature.mapper) : noTypePredicate; } - else if (signature.unionSignatures) { - signature.resolvedTypePredicate = getUnionTypePredicate(signature.unionSignatures) || noTypePredicate; + else if (signature.compositeSignatures) { + signature.resolvedTypePredicate = getUnionOrIntersectionTypePredicate(signature.compositeSignatures, signature.compositeKind) || noTypePredicate; } else { var type = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); @@ -54546,17 +56408,20 @@ var ts; function createTypePredicateFromTypePredicateNode(node, signature) { var parameterName = node.parameterName; var type = node.type && getTypeFromTypeNode(node.type); - return parameterName.kind === 187 /* ThisType */ ? + return parameterName.kind === 189 /* 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); } + function getUnionOrIntersectionType(types, kind, unionReduction) { + return kind !== 2097152 /* Intersection */ ? getUnionType(types, unionReduction) : getIntersectionType(types); + } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { if (!pushTypeResolution(signature, 3 /* ResolvedReturnType */)) { return errorType; } var type = signature.target ? instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper) : - signature.unionSignatures ? instantiateType(getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature), 2 /* Subtype */), signature.mapper) : + signature.compositeSignatures ? instantiateType(getUnionOrIntersectionType(ts.map(signature.compositeSignatures, getReturnTypeOfSignature), signature.compositeKind, 2 /* Subtype */), signature.mapper) : getReturnTypeFromAnnotation(signature.declaration) || (ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration)); if (signature.flags & 8 /* IsInnerCallChain */) { @@ -54589,7 +56454,7 @@ var ts; return signature.resolvedReturnType; } function getReturnTypeFromAnnotation(declaration) { - if (declaration.kind === 166 /* Constructor */) { + if (declaration.kind === 168 /* Constructor */) { return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)); } if (ts.isJSDocConstructSignature(declaration)) { @@ -54599,12 +56464,12 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 167 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { + if (declaration.kind === 169 /* GetAccessor */ && hasBindableName(declaration)) { var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration); if (jsDocType) { return jsDocType; } - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 168 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 170 /* SetAccessor */); var setterType = getAnnotatedAccessorType(setter); if (setterType) { return setterType; @@ -54681,9 +56546,20 @@ var ts; function getBaseSignature(signature) { var typeParameters = signature.typeParameters; if (typeParameters) { - var typeEraser_1 = createTypeEraser(typeParameters); - var baseConstraints = ts.map(typeParameters, function (tp) { return instantiateType(getBaseConstraintOfType(tp), typeEraser_1) || unknownType; }); - return instantiateSignature(signature, createTypeMapper(typeParameters, baseConstraints), /*eraseTypeParameters*/ true); + if (signature.baseSignatureCache) { + return signature.baseSignatureCache; + } + var typeEraser = createTypeEraser(typeParameters); + var baseConstraintMapper_1 = createTypeMapper(typeParameters, ts.map(typeParameters, function (tp) { return getConstraintOfTypeParameter(tp) || unknownType; })); + var baseConstraints = ts.map(typeParameters, function (tp) { return instantiateType(tp, baseConstraintMapper_1) || unknownType; }); + // Run N type params thru the immediate constraint mapper up to N times + // This way any noncircular interdependent type parameters are definitely resolved to their external dependencies + for (var i = 0; i < typeParameters.length - 1; i++) { + baseConstraints = instantiateTypes(baseConstraints, baseConstraintMapper_1); + } + // and then apply a type eraser to remove any remaining circularly dependent type parameters + baseConstraints = instantiateTypes(baseConstraints, typeEraser); + return signature.baseSignatureCache = instantiateSignature(signature, createTypeMapper(typeParameters, baseConstraints), /*eraseTypeParameters*/ true); } return signature; } @@ -54694,7 +56570,7 @@ var ts; // will result in a different declaration kind. if (!signature.isolatedSignatureType) { var kind = signature.declaration ? signature.declaration.kind : 0 /* Unknown */; - var isConstructor = kind === 166 /* Constructor */ || kind === 170 /* ConstructSignature */ || kind === 175 /* ConstructorType */; + var isConstructor = kind === 168 /* Constructor */ || kind === 172 /* ConstructSignature */ || kind === 177 /* ConstructorType */; var type = createObjectType(16 /* Anonymous */); type.members = emptySymbols; type.properties = ts.emptyArray; @@ -54705,12 +56581,22 @@ var ts; return signature.isolatedSignatureType; } function getIndexSymbol(symbol) { - return symbol.members.get("__index" /* Index */); + return symbol.members ? getIndexSymbolFromSymbolTable(symbol.members) : undefined; + } + function getIndexSymbolFromSymbolTable(symbolTable) { + return symbolTable.get("__index" /* Index */); } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 144 /* NumberKeyword */ : 147 /* StringKeyword */; - var indexSymbol = getIndexSymbol(symbol); - if (indexSymbol) { + var indexSymbol = symbol && getIndexSymbol(symbol); + return indexSymbol && getIndexDeclarationOfIndexSymbol(indexSymbol, kind); + } + function getIndexDeclarationOfSymbolTable(symbolTable, kind) { + var indexSymbol = symbolTable && getIndexSymbolFromSymbolTable(symbolTable); + return indexSymbol && getIndexDeclarationOfIndexSymbol(indexSymbol, kind); + } + function getIndexDeclarationOfIndexSymbol(indexSymbol, kind) { + var syntaxKind = kind === 1 /* Number */ ? 145 /* NumberKeyword */ : 148 /* StringKeyword */; + if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; var node = ts.cast(decl, ts.isIndexSignatureDeclaration); @@ -54738,17 +56624,18 @@ var ts; return ts.mapDefined(ts.filter(type.symbol && type.symbol.declarations, ts.isTypeParameterDeclaration), ts.getEffectiveConstraintOfTypeParameter)[0]; } function getInferredTypeParameterConstraint(typeParameter) { + var _a; var inferences; - if (typeParameter.symbol) { - for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.parent.kind === 185 /* InferType */) { + 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 === 187 /* 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 _b = ts.walkUpParenthesizedTypesAndGetParentAndChild(declaration.parent.parent), _c = _b[0], childTypeParameter = _c === void 0 ? declaration.parent : _c, grandParent = _b[1]; - if (grandParent.kind === 173 /* TypeReference */) { + var _c = ts.walkUpParenthesizedTypesAndGetParentAndChild(declaration.parent.parent), _d = _c[0], childTypeParameter = _d === void 0 ? declaration.parent : _d, grandParent = _c[1]; + if (grandParent.kind === 175 /* TypeReference */) { var typeReference = grandParent; var typeParameters = getTypeParametersForTypeReference(typeReference); if (typeParameters) { @@ -54773,21 +56660,32 @@ 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 === 160 /* Parameter */ && grandParent.dotDotDotToken || - grandParent.kind === 181 /* RestType */ || - grandParent.kind === 192 /* NamedTupleMember */ && grandParent.dotDotDotToken) { + else if (grandParent.kind === 162 /* Parameter */ && grandParent.dotDotDotToken || + grandParent.kind === 183 /* RestType */ || + grandParent.kind === 194 /* 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 === 194 /* TemplateLiteralTypeSpan */) { + else if (grandParent.kind === 196 /* 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 === 159 /* TypeParameter */ && grandParent.parent.kind === 190 /* MappedType */) { + else if (grandParent.kind === 161 /* TypeParameter */ && grandParent.parent.kind === 192 /* 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 === 192 /* MappedType */ && grandParent.type && + ts.skipParentheses(grandParent.type) === declaration.parent && grandParent.parent.kind === 186 /* ConditionalType */ && + grandParent.parent.extendsType === grandParent && grandParent.parent.checkType.kind === 192 /* 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))); + } } } } @@ -54810,7 +56708,7 @@ var ts; if (type.flags & 1 /* Any */ && type !== errorType) { // 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 === 190 /* MappedType */ ? keyofConstraintType : unknownType; + type = constraintDeclaration.parent.parent.kind === 192 /* MappedType */ ? keyofConstraintType : unknownType; } typeParameter.constraint = type; } @@ -54819,7 +56717,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - var tp = ts.getDeclarationOfKind(typeParameter.symbol, 159 /* TypeParameter */); + var tp = ts.getDeclarationOfKind(typeParameter.symbol, 161 /* TypeParameter */); var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getHostSignatureFromJSDoc(tp.parent) : tp.parent; return host && getSymbolOfNode(host); } @@ -54846,6 +56744,9 @@ var ts; } return result; } + function getAliasId(aliasSymbol, aliasTypeArguments) { + return aliasSymbol ? "@" + getSymbolId(aliasSymbol) + (aliasTypeArguments ? ":" + 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 @@ -54858,7 +56759,7 @@ var ts; result |= ts.getObjectFlags(type); } } - return result & 3670016 /* PropagatingFlags */; + return result & 917504 /* PropagatingFlags */; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); @@ -54880,15 +56781,18 @@ var ts; type.resolvedTypeArguments = source.resolvedTypeArguments; return type; } - function createDeferredTypeReference(target, node, mapper) { - var aliasSymbol = getAliasSymbolForTypeNode(node); - var aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); + function createDeferredTypeReference(target, node, mapper, aliasSymbol, aliasTypeArguments) { + if (!aliasSymbol) { + aliasSymbol = getAliasSymbolForTypeNode(node); + var localAliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); + aliasTypeArguments = mapper ? instantiateTypes(localAliasTypeArguments, mapper) : localAliasTypeArguments; + } var type = createObjectType(4 /* Reference */, target.symbol); type.target = target; type.node = node; type.mapper = mapper; type.aliasSymbol = aliasSymbol; - type.aliasTypeArguments = mapper ? instantiateTypes(aliasTypeArguments, mapper) : aliasTypeArguments; + type.aliasTypeArguments = aliasTypeArguments; return type; } function getTypeArguments(type) { @@ -54899,8 +56803,8 @@ var ts; } var node = type.node; var typeArguments = !node ? ts.emptyArray : - node.kind === 173 /* TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : - node.kind === 178 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : + node.kind === 175 /* TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : + node.kind === 180 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); if (popTypeResolution()) { type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments; @@ -54942,7 +56846,7 @@ var ts; return errorType; } } - if (node.kind === 173 /* TypeReference */ && isDeferredTypeReferenceNode(node, ts.length(node.typeArguments) !== typeParameters.length)) { + if (node.kind === 175 /* 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 @@ -54953,17 +56857,17 @@ var ts; } return checkNoTypeArguments(node, symbol) ? type : errorType; } - function getTypeAliasInstantiation(symbol, typeArguments) { + function getTypeAliasInstantiation(symbol, typeArguments, aliasSymbol, aliasTypeArguments) { var type = getDeclaredTypeOfSymbol(symbol); if (type === intrinsicMarkerType && intrinsicTypeKinds.has(symbol.escapedName) && typeArguments && typeArguments.length === 1) { return getStringMappingType(symbol, typeArguments[0]); } var links = getSymbolLinks(symbol); var typeParameters = links.typeParameters; - var id = getTypeListId(typeArguments); + var id = getTypeListId(typeArguments) + getAliasId(aliasSymbol, aliasTypeArguments); var instantiation = links.instantiations.get(id); if (!instantiation) { - links.instantiations.set(id, instantiation = instantiateType(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters), ts.isInJSFile(symbol.valueDeclaration))))); + links.instantiations.set(id, instantiation = instantiateTypeWithAlias(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters), ts.isInJSFile(symbol.valueDeclaration))), aliasSymbol, aliasTypeArguments)); } return instantiation; } @@ -54984,15 +56888,26 @@ var ts; ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); return errorType; } - return getTypeAliasInstantiation(symbol, typeArgumentsFromTypeReferenceNode(node)); + // We refrain from associating a local type alias with an instantiation of a top-level type alias + // because the local alias may end up being referenced in an inferred return type where it is not + // accessible--which in turn may lead to a large structural expansion of the type when generating + // a .d.ts file. See #43622 for an example. + var aliasSymbol = getAliasSymbolForTypeNode(node); + var newAliasSymbol = aliasSymbol && (isLocalTypeAlias(symbol) || !isLocalTypeAlias(aliasSymbol)) ? aliasSymbol : undefined; + return getTypeAliasInstantiation(symbol, typeArgumentsFromTypeReferenceNode(node), newAliasSymbol, getTypeArgumentsForAliasSymbol(newAliasSymbol)); } return checkNoTypeArguments(node, symbol) ? type : errorType; } + function isLocalTypeAlias(symbol) { + var _a; + var declaration = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isTypeAlias); + return !!(declaration && ts.getContainingFunction(declaration)); + } function getTypeReferenceName(node) { switch (node.kind) { - case 173 /* TypeReference */: + case 175 /* TypeReference */: return node.typeName; - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -55048,7 +56963,7 @@ var ts; var valueType = getTypeOfSymbol(symbol); var typeType = valueType; if (symbol.valueDeclaration) { - var isImportTypeWithQualifier = node.kind === 195 /* ImportType */ && node.qualifier; + var isImportTypeWithQualifier = node.kind === 197 /* 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); @@ -55074,7 +56989,7 @@ var ts; return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 179 /* TupleType */ && node.elements.length === 1; + return node.kind === 181 /* TupleType */ && node.elements.length === 1; } function getImpliedConstraint(type, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(type, checkNode.elements[0], extendsNode.elements[0]) : @@ -55083,9 +56998,17 @@ var ts; } function getConditionalFlowTypeOfType(type, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 311 /* JSDocComment */) { + var covariant = true; + while (node && !ts.isStatement(node) && node.kind !== 314 /* JSDocComment */) { var parent = node.parent; - if (parent.kind === 184 /* ConditionalType */ && node === parent.trueType) { + // 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 === 162 /* 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 === 186 /* ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(type, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -55096,7 +57019,7 @@ var ts; return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type; } function isJSDocTypeReference(node) { - return !!(node.flags & 4194304 /* JSDoc */) && (node.kind === 173 /* TypeReference */ || node.kind === 195 /* ImportType */); + return !!(node.flags & 4194304 /* JSDoc */) && (node.kind === 175 /* TypeReference */ || node.kind === 197 /* ImportType */); } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -55206,13 +57129,15 @@ var ts; function getTypeOfGlobalSymbol(symbol, arity) { function getTypeDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { - var declaration = declarations_3[_i]; - switch (declaration.kind) { - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - return declaration; + if (declarations) { + for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { + var declaration = declarations_3[_i]; + switch (declaration.kind) { + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 257 /* EnumDeclaration */: + return declaration; + } } } } @@ -55256,6 +57181,9 @@ var ts; function getGlobalESSymbolConstructorSymbol(reportErrors) { return deferredGlobalESSymbolConstructorSymbol || (deferredGlobalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol", reportErrors)); } + function getGlobalESSymbolConstructorTypeSymbol(reportErrors) { + return deferredGlobalESSymbolConstructorTypeSymbol || (deferredGlobalESSymbolConstructorTypeSymbol = getGlobalTypeSymbol("SymbolConstructor", reportErrors)); + } function getGlobalESSymbolType(reportErrors) { return deferredGlobalESSymbolType || (deferredGlobalESSymbolType = getGlobalType("Symbol", /*arity*/ 0, reportErrors)) || emptyObjectType; } @@ -55332,11 +57260,11 @@ var ts; } function getTupleElementFlags(node) { switch (node.kind) { - case 180 /* OptionalType */: + case 182 /* OptionalType */: return 2 /* Optional */; - case 181 /* RestType */: + case 183 /* RestType */: return getRestTypeElementFlags(node); - case 192 /* NamedTupleMember */: + case 194 /* NamedTupleMember */: return node.questionToken ? 2 /* Optional */ : node.dotDotDotToken ? getRestTypeElementFlags(node) : 1 /* Required */; @@ -55354,14 +57282,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 !== 192 /* NamedTupleMember */; }); + var missingName = ts.some(node.elements, function (e) { return e.kind !== 194 /* 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 === 178 /* ArrayType */ ? mayResolveTypeAlias(node.elementType) : - node.kind === 179 /* TupleType */ ? ts.some(node.elements, mayResolveTypeAlias) : + return !!getAliasSymbolForTypeNode(node) || isResolvedByTypeAlias(node) && (node.kind === 180 /* ArrayType */ ? mayResolveTypeAlias(node.elementType) : + node.kind === 181 /* 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 @@ -55370,18 +57298,18 @@ var ts; function isResolvedByTypeAlias(node) { var parent = node.parent; switch (parent.kind) { - case 186 /* ParenthesizedType */: - case 192 /* NamedTupleMember */: - case 173 /* TypeReference */: - case 182 /* UnionType */: - case 183 /* IntersectionType */: - case 189 /* IndexedAccessType */: - case 184 /* ConditionalType */: - case 188 /* TypeOperator */: - case 178 /* ArrayType */: - case 179 /* TupleType */: + case 188 /* ParenthesizedType */: + case 194 /* NamedTupleMember */: + case 175 /* TypeReference */: + case 184 /* UnionType */: + case 185 /* IntersectionType */: + case 191 /* IndexedAccessType */: + case 186 /* ConditionalType */: + case 190 /* TypeOperator */: + case 180 /* ArrayType */: + case 181 /* TupleType */: return isResolvedByTypeAlias(parent); - case 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: return true; } return false; @@ -55390,28 +57318,28 @@ var ts; // of a type alias. function mayResolveTypeAlias(node) { switch (node.kind) { - case 173 /* TypeReference */: + case 175 /* TypeReference */: return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node.typeName, 788968 /* Type */).flags & 524288 /* TypeAlias */); - case 176 /* TypeQuery */: + case 178 /* TypeQuery */: return true; - case 188 /* TypeOperator */: - return node.operator !== 151 /* UniqueKeyword */ && mayResolveTypeAlias(node.type); - case 186 /* ParenthesizedType */: - case 180 /* OptionalType */: - case 192 /* NamedTupleMember */: - case 307 /* JSDocOptionalType */: - case 305 /* JSDocNullableType */: - case 306 /* JSDocNonNullableType */: - case 301 /* JSDocTypeExpression */: + case 190 /* TypeOperator */: + return node.operator !== 152 /* UniqueKeyword */ && mayResolveTypeAlias(node.type); + case 188 /* ParenthesizedType */: + case 182 /* OptionalType */: + case 194 /* NamedTupleMember */: + case 310 /* JSDocOptionalType */: + case 308 /* JSDocNullableType */: + case 309 /* JSDocNonNullableType */: + case 303 /* JSDocTypeExpression */: return mayResolveTypeAlias(node.type); - case 181 /* RestType */: - return node.type.kind !== 178 /* ArrayType */ || mayResolveTypeAlias(node.type.elementType); - case 182 /* UnionType */: - case 183 /* IntersectionType */: + case 183 /* RestType */: + return node.type.kind !== 180 /* ArrayType */ || mayResolveTypeAlias(node.type.elementType); + case 184 /* UnionType */: + case 185 /* IntersectionType */: return ts.some(node.types, mayResolveTypeAlias); - case 189 /* IndexedAccessType */: + case 191 /* IndexedAccessType */: return mayResolveTypeAlias(node.objectType) || mayResolveTypeAlias(node.indexType); - case 184 /* ConditionalType */: + case 186 /* ConditionalType */: return mayResolveTypeAlias(node.checkType) || mayResolveTypeAlias(node.extendsType) || mayResolveTypeAlias(node.trueType) || mayResolveTypeAlias(node.falseType); } @@ -55424,19 +57352,19 @@ var ts; if (target === emptyGenericType) { links.resolvedType = emptyObjectType; } - else if (!(node.kind === 179 /* TupleType */ && ts.some(node.elements, function (e) { return !!(getTupleElementFlags(e) & 8 /* Variadic */); })) && isDeferredTypeReferenceNode(node)) { - links.resolvedType = node.kind === 179 /* TupleType */ && node.elements.length === 0 ? target : + else if (!(node.kind === 181 /* TupleType */ && ts.some(node.elements, function (e) { return !!(getTupleElementFlags(e) & 8 /* Variadic */); })) && isDeferredTypeReferenceNode(node)) { + links.resolvedType = node.kind === 181 /* TupleType */ && node.elements.length === 0 ? target : createDeferredTypeReference(target, node, /*mapper*/ undefined); } else { - var elementTypes = node.kind === 178 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); + var elementTypes = node.kind === 180 /* 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 === 142 /* ReadonlyKeyword */; + return ts.isTypeOperatorNode(node) && node.operator === 143 /* ReadonlyKeyword */; } function createTupleType(elementTypes, elementFlags, readonly, namedMemberDeclarations) { if (readonly === void 0) { readonly = false; } @@ -55561,8 +57489,15 @@ var ts; addElement(type, 8 /* Variadic */, (_a = target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]); } else if (isTupleType(type)) { + var elements = getTypeArguments(type); + if (elements.length + expandedTypes.length >= 10000) { + error(currentNode, ts.isPartOfTypeNode(currentNode) + ? ts.Diagnostics.Type_produces_a_tuple_type_that_is_too_large_to_represent + : ts.Diagnostics.Expression_produces_a_tuple_type_that_is_too_large_to_represent); + return { value: errorType }; + } // Spread variadic elements with tuple types into the resulting tuple. - ts.forEach(getTypeArguments(type), function (t, n) { var _a; return addElement(t, type.target.elementFlags[n], (_a = type.target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[n]); }); + ts.forEach(elements, function (t, n) { var _a; return addElement(t, type.target.elementFlags[n], (_a = type.target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[n]); }); } else { // Treat everything else as an array type and create a rest element. @@ -55575,7 +57510,9 @@ var ts; } }; for (var i = 0; i < elementTypes.length; i++) { - _loop_13(i); + var state_4 = _loop_13(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++) { @@ -55634,8 +57571,7 @@ var ts; return type.elementFlags.length - ts.findLastIndex(type.elementFlags, function (f) { return !(f & flags); }) - 1; } function getTypeFromOptionalTypeNode(node) { - var type = getTypeFromTypeNode(node.type); - return strictNullChecks ? getOptionalType(type) : type; + return addOptionality(getTypeFromTypeNode(node.type), /*isProperty*/ true); } function getTypeId(type) { return type.id; @@ -55664,7 +57600,7 @@ var ts; if (type === wildcardType) includes |= 8388608 /* IncludesWildcard */; if (!strictNullChecks && flags & 98304 /* Nullable */) { - if (!(ts.getObjectFlags(type) & 524288 /* ContainsWideningType */)) + if (!(ts.getObjectFlags(type) & 131072 /* ContainsWideningType */)) includes |= 4194304 /* IncludesNonWideningType */; } else { @@ -55686,67 +57622,76 @@ var ts; } return includes; } - function isSetOfLiteralsFromSameEnum(types) { - var first = types[0]; - if (first.flags & 1024 /* EnumLiteral */) { - var firstEnum = getParentOfSymbol(first.symbol); - for (var i = 1; i < types.length; i++) { - var other = types[i]; - if (!(other.flags & 1024 /* EnumLiteral */) || (firstEnum !== getParentOfSymbol(other.symbol))) { - return false; - } - } - return true; + function removeSubtypes(types, hasObjectTypes) { + var id = getTypeListId(types); + var match = subtypeReductionCache.get(id); + if (match) { + return match; } - return false; - } - function removeSubtypes(types, primitivesOnly) { + // 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 len = types.length; - if (len === 0 || isSetOfLiteralsFromSameEnum(types)) { - return true; - } var i = len; var count = 0; while (i > 0) { i--; var source = types[i]; - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var target = types_11[_i]; - if (source !== target) { - if (count === 100000) { - // After 100000 subtype checks we estimate the remaining amount of work by assuming the - // same ratio of checks per element. If the estimated number of remaining type checks is - // greater than an upper limit we deem the union type too complex to represent. The - // upper limit is 25M for unions of primitives only, and 1M otherwise. This for example - // caps union types at 5000 unique literal types and 1000 unique object types. - var estimatedCount = (count / (len - i)) * len; - if (estimatedCount > (primitivesOnly ? 25000000 : 1000000)) { - ts.tracing.instant("checkTypes" /* 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 false; + if (hasEmptyObject || source.flags & 469499904 /* 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 */) ? + ts.find(getPropertiesOfType(source), function (p) { return isUnitType(getTypeOfSymbol(p)); }) : + undefined; + var keyPropertyType = keyProperty && getRegularTypeOfLiteralType(getTypeOfSymbol(keyProperty)); + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var target = types_11[_i]; + if (source !== target) { + if (count === 100000) { + // After 100000 subtype checks we estimate the remaining amount of work by assuming the + // same ratio of checks per element. If the estimated number of remaining type checks is + // greater than 1M we deem the union type too complex to represent. This for example + // 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; }) }); + 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 */)) { + 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 */) || + isTypeDerivedFrom(source, target))) { + ts.orderedRemoveItemAt(types, i); + break; } - } - count++; - if (isTypeRelatedTo(source, target, strictSubtypeRelation) && (!(ts.getObjectFlags(getTargetType(source)) & 1 /* Class */) || - !(ts.getObjectFlags(getTargetType(target)) & 1 /* Class */) || - isTypeDerivedFrom(source, target))) { - ts.orderedRemoveItemAt(types, i); - break; } } } } - return true; + subtypeReductionCache.set(id, types); + return types; } - function removeRedundantLiteralTypes(types, includes) { + function removeRedundantLiteralTypes(types, includes, reduceVoidUndefined) { var i = types.length; while (i > 0) { i--; var t = types[i]; - var remove = t.flags & 134217856 /* StringLikeLiteral */ && includes & 4 /* String */ || - t.flags & 256 /* NumberLiteral */ && includes & 8 /* Number */ || - t.flags & 2048 /* BigIntLiteral */ && includes & 64 /* BigInt */ || - t.flags & 8192 /* UniqueESSymbol */ && includes & 4096 /* ESSymbol */ || + var flags = t.flags; + var remove = flags & 128 /* StringLiteral */ && 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 */ || isFreshLiteralType(t) && containsType(types, t.regularType); if (remove) { ts.orderedRemoveItemAt(types, i); @@ -55778,7 +57723,7 @@ var ts; if (t.flags & 1048576 /* Union */) { var origin = t.origin; if (t.aliasSymbol || origin && !(origin.flags & 1048576 /* Union */)) { - namedUnions.push(t); + ts.pushIfUnique(namedUnions, t); } else if (origin && origin.flags & 1048576 /* Union */) { addNamedUnions(namedUnions, origin.types); @@ -55812,20 +57757,23 @@ var ts; if (includes & 3 /* AnyOrUnknown */) { return includes & 1 /* Any */ ? includes & 8388608 /* IncludesWildcard */ ? wildcardType : anyType : unknownType; } - switch (unionReduction) { - case 1 /* Literal */: - if (includes & (134220672 /* FreshableLiteral */ | 8192 /* UniqueESSymbol */)) { - removeRedundantLiteralTypes(typeSet, includes); - } - if (includes & 128 /* StringLiteral */ && includes & 134217728 /* TemplateLiteral */) { - removeStringLiteralsMatchedByTemplateLiterals(typeSet); - } - break; - case 2 /* Subtype */: - if (!removeSubtypes(typeSet, !(includes & 262144 /* IncludesStructuredOrInstantiable */))) { - return errorType; - } - break; + if (strictOptionalProperties && includes & 32768 /* 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 */) || includes & 16384 /* Void */ && includes & 32768 /* Undefined */) { + removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2 /* Subtype */)); + } + if (includes & 128 /* StringLiteral */ && includes & 134217728 /* TemplateLiteral */) { + removeStringLiteralsMatchedByTemplateLiterals(typeSet); + } + if (unionReduction === 2 /* Subtype */) { + typeSet = removeSubtypes(typeSet, !!(includes & 524288 /* Object */)); + if (!typeSet) { + return errorType; + } } if (typeSet.length === 0) { return includes & 65536 /* Null */ ? includes & 4194304 /* IncludesNonWideningType */ ? nullType : nullWideningType : @@ -55860,18 +57808,23 @@ var ts; origin = createOriginUnionOrIntersectionType(1048576 /* Union */, reducedTypes); } } - var objectFlags = (includes & 468598819 /* NotPrimitiveUnion */ ? 0 : 262144 /* PrimitiveUnion */) | - (includes & 2097152 /* Intersection */ ? 268435456 /* ContainsIntersections */ : 0); + var objectFlags = (includes & 468598819 /* NotPrimitiveUnion */ ? 0 : 65536 /* PrimitiveUnion */) | + (includes & 2097152 /* Intersection */ ? 67108864 /* ContainsIntersections */ : 0); return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin); } - function getUnionTypePredicate(signatures) { + function getUnionOrIntersectionTypePredicate(signatures, kind) { var first; var types = []; 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 */) { - continue; + if (kind !== 2097152 /* Intersection */) { + continue; + } + else { + return; // intersections demand all members be type predicates for the result to have a predicate + } } if (first) { if (!typePredicateKindsMatch(first, pred)) { @@ -55885,11 +57838,11 @@ var ts; types.push(pred.type); } if (!first) { - // No union signatures had a type predicate. + // No signatures had a type predicate. return undefined; } - var unionType = getUnionType(types); - return createTypePredicate(first.kind, first.parameterName, first.parameterIndex, unionType); + var compositeType = getUnionOrIntersectionType(types, kind); + return createTypePredicate(first.kind, first.parameterName, first.parameterIndex, compositeType); } function typePredicateKindsMatch(a, b) { return a.kind === b.kind && a.parameterIndex === b.parameterIndex; @@ -55914,8 +57867,8 @@ var ts; var typeKey = !origin ? getTypeListId(types) : origin.flags & 1048576 /* Union */ ? "|" + getTypeListId(origin.types) : origin.flags & 2097152 /* Intersection */ ? "&" + getTypeListId(origin.types) : - "#" + origin.type.id; - var id = typeKey + (aliasSymbol ? "@" + getSymbolId(aliasSymbol) : ""); + "#" + 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 + var id = typeKey + getAliasId(aliasSymbol, aliasTypeArguments); var type = unionTypes.get(id); if (!type) { type = createUnionType(types, aliasSymbol, aliasTypeArguments, origin); @@ -56041,7 +57994,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) & 262144 /* PrimitiveUnion */); }); + var index = ts.findIndex(types, function (t) { return !!(ts.getObjectFlags(t) & 65536 /* PrimitiveUnion */); }); if (index < 0) { return false; } @@ -56050,7 +58003,7 @@ var ts; // the unionTypes array. while (i < types.length) { var t = types[i]; - if (ts.getObjectFlags(t) & 262144 /* PrimitiveUnion */) { + if (ts.getObjectFlags(t) & 65536 /* PrimitiveUnion */) { (unionTypes || (unionTypes = [types[index]])).push(t); ts.orderedRemoveItemAt(types, i); } @@ -56079,14 +58032,14 @@ var ts; } } // Finally replace the first union with the result - types[index] = getUnionTypeFromSortedList(result, 262144 /* PrimitiveUnion */); + types[index] = getUnionTypeFromSortedList(result, 65536 /* PrimitiveUnion */); return true; } function createIntersectionType(types, aliasSymbol, aliasTypeArguments) { var result = createType(2097152 /* Intersection */); result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */); result.types = types; - result.aliasSymbol = aliasSymbol; // See comment in `getUnionTypeFromSortedList`. + result.aliasSymbol = aliasSymbol; result.aliasTypeArguments = aliasTypeArguments; return result; } @@ -56147,7 +58100,7 @@ var ts; if (typeSet.length === 1) { return typeSet[0]; } - var id = getTypeListId(typeSet) + (aliasSymbol ? "@" + getSymbolId(aliasSymbol) : ""); + var id = getTypeListId(typeSet) + getAliasId(aliasSymbol, aliasTypeArguments); var result = intersectionTypes.get(id); if (!result) { if (includes & 1048576 /* Union */) { @@ -56190,7 +58143,7 @@ var ts; function checkCrossProductUnion(types) { var size = getCrossProductUnionSize(types); if (size >= 100000) { - 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" /* 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; } @@ -56240,23 +58193,36 @@ var ts; type.resolvedStringIndexType || (type.resolvedStringIndexType = createIndexType(type, /*stringsOnly*/ true)) : type.resolvedIndexType || (type.resolvedIndexType = createIndexType(type, /*stringsOnly*/ false)); } + function instantiateTypeAsMappedNameType(nameType, type, t) { + return instantiateType(nameType, appendTypeMapping(type.mapper, getTypeParameterFromMappedType(type), t)); + } function getIndexTypeForMappedType(type, noIndexSignatures) { var constraint = filterType(getConstraintTypeFromMappedType(type), function (t) { return !(noIndexSignatures && t.flags & (1 /* Any */ | 4 /* String */)); }); var nameType = type.declaration.nameType && getTypeFromTypeNode(type.declaration.nameType); + // If the constraint is exclusively string/number/never type(s), we need to pull the property names from the modified type and run them through the `nameType` mapper as well + // since they won't appear in the constraint, due to subtype reducing with the string/number index types + var properties = nameType && everyType(constraint, function (t) { return !!(t.flags & (4 /* String */ | 8 /* Number */ | 131072 /* Never */)); }) && getPropertiesOfType(getApparentType(getModifiersTypeFromMappedType(type))); return nameType ? - mapType(constraint, function (t) { return instantiateType(nameType, appendTypeMapping(type.mapper, getTypeParameterFromMappedType(type), t)); }) : + getUnionType([mapType(constraint, function (t) { return instantiateTypeAsMappedNameType(nameType, type, t); }), mapType(getUnionType(ts.map(properties || ts.emptyArray, function (p) { return getLiteralTypeFromProperty(p, 8576 /* StringOrNumberLiteralOrUnique */); })), function (t) { return instantiateTypeAsMappedNameType(nameType, type, t); })]) : constraint; } // Ordinarily we reduce a keyof M, where M is a mapped type { [P in K as N

]: X }, to simply N. This however presumes - // that N distributes over union types, i.e. that N is equivalent to N | N | N. That presumption may not - // be true when N is a non-distributive conditional type or an instantiable type with a non-distributive conditional type as - // a constituent. In those cases, we cannot reduce keyof M and need to preserve it as is. - function maybeNonDistributiveNameType(type) { - return !!(type && (type.flags & 16777216 /* Conditional */ && (!type.root.isDistributive || maybeNonDistributiveNameType(type.checkType)) || - type.flags & (3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */) && ts.some(type.types, maybeNonDistributiveNameType) || - type.flags & (4194304 /* Index */ | 268435456 /* StringMapping */) && maybeNonDistributiveNameType(type.type) || - type.flags & 8388608 /* IndexedAccess */ && maybeNonDistributiveNameType(type.indexType) || - type.flags & 33554432 /* Substitution */ && maybeNonDistributiveNameType(type.substitute))); + // that N distributes over union types, i.e. that N is equivalent to N | N | N. Specifically, we only + // want to perform the reduction when the name type of a mapped type is distributive with respect to the type variable + // introduced by the 'in' clause of the mapped type. Note that non-generic types are considered to be distributive because + // they're the same type regardless of what's being distributed over. + function hasDistributiveNameType(mappedType) { + 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) : + false; + } } function getLiteralTypeFromPropertyName(name) { if (ts.isPrivateIdentifier(name)) { @@ -56274,13 +58240,13 @@ var ts; function getLiteralTypeFromProperty(prop, include) { if (!(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24 /* NonPublicAccessibilityModifier */)) { var type = getSymbolLinks(getLateBoundSymbol(prop)).nameType; - if (!type && !ts.isKnownSymbol(prop)) { + if (!type) { if (prop.escapedName === "default" /* Default */) { type = getLiteralType("default"); } else { var name = prop.valueDeclaration && ts.getNameOfDeclaration(prop.valueDeclaration); - type = name && getLiteralTypeFromPropertyName(name) || getLiteralType(ts.symbolName(prop)); + type = name && getLiteralTypeFromPropertyName(name) || (!ts.isKnownSymbol(prop) ? getLiteralType(ts.symbolName(prop)) : undefined); } } if (type && type.flags & include) { @@ -56304,7 +58270,7 @@ var ts; type = getReducedType(type); return type.flags & 1048576 /* Union */ ? 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) && maybeNonDistributiveNameType(getNameTypeFromMappedType(type)) ? getIndexTypeForGenericType(type, stringsOnly) : + type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) ? getIndexTypeForGenericType(type, stringsOnly) : ts.getObjectFlags(type) & 32 /* Mapped */ ? getIndexTypeForMappedType(type, noIndexSignatures) : type === wildcardType ? wildcardType : type.flags & 2 /* Unknown */ ? neverType : @@ -56329,15 +58295,15 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { switch (node.operator) { - case 138 /* KeyOfKeyword */: + case 139 /* KeyOfKeyword */: links.resolvedType = getIndexType(getTypeFromTypeNode(node.type)); break; - case 151 /* UniqueKeyword */: - links.resolvedType = node.type.kind === 148 /* SymbolKeyword */ + case 152 /* UniqueKeyword */: + links.resolvedType = node.type.kind === 149 /* SymbolKeyword */ ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent)) : errorType; break; - case 142 /* ReadonlyKeyword */: + case 143 /* ReadonlyKeyword */: links.resolvedType = getTypeFromTypeNode(node.type); break; default: @@ -56380,7 +58346,6 @@ var ts; var type = templateLiteralTypes.get(id); if (!type) { templateLiteralTypes.set(id, type = createTemplateLiteralType(newTexts, newTypes)); - type.regularType = type; } return type; function addSpans(texts, types) { @@ -56412,10 +58377,8 @@ var ts; 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 */ ? type.intrinsicName : - type.flags & 65536 /* Null */ ? "null" : - type.flags & 32768 /* Undefined */ ? "undefined" : - undefined; + type.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) ? type.intrinsicName : + undefined; } function createTemplateLiteralType(texts, types) { var type = createType(134217728 /* TemplateLiteral */); @@ -56452,13 +58415,13 @@ var ts; result.type = type; return result; } - function createIndexedAccessType(objectType, indexType, aliasSymbol, aliasTypeArguments, shouldIncludeUndefined) { + function createIndexedAccessType(objectType, indexType, accessFlags, aliasSymbol, aliasTypeArguments) { var type = createType(8388608 /* IndexedAccess */); type.objectType = objectType; type.indexType = indexType; + type.accessFlags = accessFlags; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; - type.noUncheckedIndexedAccessCandidate = shouldIncludeUndefined; return type; } /** @@ -56474,7 +58437,7 @@ var ts; if (noImplicitAny) { return false; // Flag is meaningless under `noImplicitAny` mode } - if (ts.getObjectFlags(type) & 16384 /* JSLiteral */) { + if (ts.getObjectFlags(type) & 8192 /* JSLiteral */) { return true; } if (type.flags & 1048576 /* Union */) { @@ -56484,20 +58447,18 @@ var ts; return ts.some(type.types, isJSLiteralType); } if (type.flags & 465829888 /* Instantiable */) { - return isJSLiteralType(getResolvedBaseConstraint(type)); + var constraint = getResolvedBaseConstraint(type); + return constraint !== type && isJSLiteralType(constraint); } return false; } function getPropertyNameFromIndex(indexType, accessNode) { - var accessExpression = accessNode && accessNode.kind === 202 /* ElementAccessExpression */ ? accessNode : undefined; return isTypeUsableAsPropertyName(indexType) ? getPropertyNameFromType(indexType) : - accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? - ts.getPropertyNameForKnownSymbolName(ts.idText(accessExpression.argumentExpression.name)) : - accessNode && ts.isPropertyName(accessNode) ? - // late bound names are handled in the first branch, so here we only need to handle normal names - ts.getPropertyNameForPropertyNameNode(accessNode) : - undefined; + accessNode && ts.isPropertyName(accessNode) ? + // late bound names are handled in the first branch, so here we only need to handle normal names + ts.getPropertyNameForPropertyNameNode(accessNode) : + undefined; } function isUncalledFunctionReference(node, symbol) { if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { @@ -56509,24 +58470,27 @@ var ts; } return true; } - function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, suppressNoImplicitAnyError, accessNode, accessFlags, noUncheckedIndexedAccessCandidate, reportDeprecated) { + function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, accessNode, accessFlags) { var _a; - var accessExpression = accessNode && accessNode.kind === 202 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 204 /* ElementAccessExpression */ ? accessNode : undefined; var propName = accessNode && ts.isPrivateIdentifier(accessNode) ? undefined : getPropertyNameFromIndex(indexType, accessNode); if (propName !== undefined) { + if (accessFlags & 256 /* Contextual */) { + return getTypeOfPropertyOfContextualType(objectType, propName) || anyType; + } var prop = getPropertyOfType(objectType, propName); if (prop) { - if (reportDeprecated && accessNode && getDeclarationNodeFlagsFromSymbol(prop) & 134217728 /* Deprecated */ && isUncalledFunctionReference(accessNode, prop)) { + if (accessFlags & 64 /* ReportDeprecated */ && accessNode && prop.declarations && getDeclarationNodeFlagsFromSymbol(prop) & 134217728 /* Deprecated */ && 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); - errorOrSuggestion(/* isError */ false, deprecatedNode, ts.Diagnostics._0_is_deprecated, propName); + addDeprecatedSuggestion(deprecatedNode, prop.declarations, propName); } if (accessExpression) { - markPropertyAsReferenced(prop, accessExpression, /*isThisAccess*/ accessExpression.expression.kind === 107 /* ThisKeyword */); + markPropertyAsReferenced(prop, accessExpression, isSelfTypeAccess(accessExpression.expression, objectType.symbol)); if (isAssignmentToReadonlyEntity(accessExpression, prop, ts.getAssignmentTargetKind(accessExpression))) { error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(prop)); return undefined; } - if (accessFlags & 4 /* CacheSymbol */) { + if (accessFlags & 8 /* CacheSymbol */) { getNodeLinks(accessNode).resolvedSymbol = prop; } if (isThisPropertyAccessInConstructor(accessExpression, prop)) { @@ -56539,7 +58503,7 @@ var ts; propType; } if (everyType(objectType, isTupleType) && isNumericLiteralName(propName) && +propName >= 0) { - if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 8 /* NoTupleBoundsCheck */)) { + if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 16 /* NoTupleBoundsCheck */)) { var indexNode = getIndexNodeForAccessExpression(accessNode); if (isTupleType(objectType)) { error(indexNode, ts.Diagnostics.Tuple_type_0_of_length_1_has_no_element_at_index_2, typeToString(objectType), getTypeReferenceArity(objectType), ts.unescapeLeadingUnderscores(propName)); @@ -56551,7 +58515,7 @@ var ts; errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, 1 /* Number */)); return mapType(objectType, function (t) { var restType = getRestTypeOfTupleType(t) || undefinedType; - return noUncheckedIndexedAccessCandidate ? getUnionType([restType, undefinedType]) : restType; + return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([restType, undefinedType]) : restType; }); } } @@ -56562,7 +58526,7 @@ var ts; var stringIndexInfo = getIndexInfoOfType(objectType, 0 /* String */); var indexInfo = isTypeAssignableToKind(indexType, 296 /* NumberLike */) && getIndexInfoOfType(objectType, 1 /* Number */) || stringIndexInfo; if (indexInfo) { - if (accessFlags & 1 /* NoIndexSignatures */ && indexInfo === stringIndexInfo) { + if (accessFlags & 2 /* NoIndexSignatures */ && indexInfo === stringIndexInfo) { if (accessExpression) { error(accessExpression, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(originalObjectType)); } @@ -56571,10 +58535,10 @@ var ts; if (accessNode && !isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) { var indexNode = getIndexNodeForAccessExpression(accessNode); error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); - return noUncheckedIndexedAccessCandidate ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; + return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; } errorIfWritingToReadonlyIndex(indexInfo); - return noUncheckedIndexedAccessCandidate ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; + return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; } if (indexType.flags & 131072 /* Never */) { return neverType; @@ -56598,7 +58562,7 @@ var ts; if (objectType.symbol === globalThisSymbol && propName !== undefined && globalThisSymbol.exports.has(propName) && (globalThisSymbol.exports.get(propName).flags & 418 /* BlockScoped */)) { error(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType)); } - else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !suppressNoImplicitAnyError) { + else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !(accessFlags & 128 /* 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) + "]"); @@ -56671,13 +58635,13 @@ var ts; } } function getIndexNodeForAccessExpression(accessNode) { - return accessNode.kind === 202 /* ElementAccessExpression */ ? accessNode.argumentExpression : - accessNode.kind === 189 /* IndexedAccessType */ ? accessNode.indexType : - accessNode.kind === 158 /* ComputedPropertyName */ ? accessNode.expression : + return accessNode.kind === 204 /* ElementAccessExpression */ ? accessNode.argumentExpression : + accessNode.kind === 191 /* IndexedAccessType */ ? accessNode.indexType : + accessNode.kind === 160 /* ComputedPropertyName */ ? accessNode.expression : accessNode; } function isPatternLiteralPlaceholderType(type) { - return templateConstraintType.types.indexOf(type) !== -1 || !!(type.flags & 1 /* Any */); + return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */)); } function isPatternLiteralType(type) { return !!(type.flags & 134217728 /* TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType); @@ -56690,6 +58654,13 @@ var ts; } return !!(type.objectFlags & 8388608 /* IsGenericObjectType */); } + if (type.flags & 33554432 /* Substitution */) { + if (!(type.objectFlags & 4194304 /* IsGenericObjectTypeComputed */)) { + type.objectFlags |= 4194304 /* IsGenericObjectTypeComputed */ | + (isGenericObjectType(type.substitute) || isGenericObjectType(type.baseType) ? 8388608 /* IsGenericObjectType */ : 0); + } + return !!(type.objectFlags & 8388608 /* IsGenericObjectType */); + } return !!(type.flags & 58982400 /* InstantiableNonPrimitive */) || isGenericMappedType(type) || isGenericTupleType(type); } function isGenericIndexType(type) { @@ -56700,6 +58671,13 @@ var ts; } return !!(type.objectFlags & 33554432 /* IsGenericIndexType */); } + if (type.flags & 33554432 /* Substitution */) { + if (!(type.objectFlags & 16777216 /* IsGenericIndexTypeComputed */)) { + type.objectFlags |= 16777216 /* IsGenericIndexTypeComputed */ | + (isGenericIndexType(type.substitute) || isGenericIndexType(type.baseType) ? 33554432 /* IsGenericIndexType */ : 0); + } + return !!(type.objectFlags & 33554432 /* IsGenericIndexType */); + } return !!(type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */)) && !isPatternLiteralType(type); } function isThisTypeParameter(type) { @@ -56775,6 +58753,12 @@ var ts; } return type[cache] = type; } + function isConditionalTypeAlwaysTrueDisregardingInferTypes(type) { + var extendsInferParamMapper = type.root.inferTypeParameters && createTypeMapper(type.root.inferTypeParameters, ts.map(type.root.inferTypeParameters, function () { return wildcardType; })); + var checkType = type.checkType; + var extendsType = type.extendsType; + return isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(instantiateType(extendsType, extendsInferParamMapper))); + } function getSimplifiedConditionalType(type, writing) { var checkType = type.checkType; var extendsType = type.extendsType; @@ -56810,9 +58794,9 @@ var ts; var templateMapper = combineTypeMappers(objectType.mapper, mapper); return instantiateType(getTemplateTypeFromMappedType(objectType), templateMapper); } - function getIndexedAccessType(objectType, indexType, noUncheckedIndexedAccessCandidate, accessNode, aliasSymbol, aliasTypeArguments, accessFlags) { + function getIndexedAccessType(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) { if (accessFlags === void 0) { accessFlags = 0 /* None */; } - return getIndexedAccessTypeOrUndefined(objectType, indexType, noUncheckedIndexedAccessCandidate, accessNode, accessFlags, aliasSymbol, aliasTypeArguments) || (accessNode ? errorType : unknownType); + return getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) || (accessNode ? errorType : unknownType); } function indexTypeLessThan(indexType, limit) { return everyType(indexType, function (t) { @@ -56826,36 +58810,38 @@ var ts; return false; }); } - function getIndexedAccessTypeOrUndefined(objectType, indexType, noUncheckedIndexedAccessCandidate, accessNode, accessFlags, aliasSymbol, aliasTypeArguments) { + function getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) { if (accessFlags === void 0) { accessFlags = 0 /* None */; } if (objectType === wildcardType || indexType === wildcardType) { return wildcardType; } - var shouldIncludeUndefined = noUncheckedIndexedAccessCandidate || - (!!compilerOptions.noUncheckedIndexedAccess && - (accessFlags & (2 /* Writing */ | 16 /* ExpressionPosition */)) === 16 /* ExpressionPosition */); // 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 */)) { 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 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 !== 189 /* IndexedAccessType */ ? + if (isGenericIndexType(indexType) || (accessNode && accessNode.kind !== 191 /* IndexedAccessType */ ? isGenericTupleType(objectType) && !indexTypeLessThan(indexType, objectType.target.fixedLength) : isGenericObjectType(objectType) && !(isTupleType(objectType) && indexTypeLessThan(indexType, objectType.target.fixedLength)))) { if (objectType.flags & 3 /* AnyOrUnknown */) { return objectType; } // Defer the operation by creating an indexed access type. - var id = objectType.id + "," + indexType.id + (shouldIncludeUndefined ? "?" : "") + (aliasSymbol ? "@" + getSymbolId(aliasSymbol) : ""); + var persistentAccessFlags = accessFlags & 1 /* Persistent */; + var id = objectType.id + "," + indexType.id + "," + persistentAccessFlags + getAliasId(aliasSymbol, aliasTypeArguments); var type = indexedAccessTypes.get(id); if (!type) { - indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType, aliasSymbol, aliasTypeArguments, shouldIncludeUndefined)); + indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType, persistentAccessFlags, aliasSymbol, aliasTypeArguments)); } return type; } @@ -56868,7 +58854,7 @@ var ts; 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, wasMissingProp, accessNode, accessFlags, shouldIncludeUndefined); + var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, indexType, accessNode, accessFlags | (wasMissingProp ? 128 /* SuppressNoImplicitAnyError */ : 0)); if (propType) { propTypes.push(propType); } @@ -56884,11 +58870,11 @@ var ts; if (wasMissingProp) { return undefined; } - return accessFlags & 2 /* Writing */ + return accessFlags & 4 /* Writing */ ? getIntersectionType(propTypes, aliasSymbol, aliasTypeArguments) : getUnionType(propTypes, 1 /* Literal */, aliasSymbol, aliasTypeArguments); } - return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, /* supressNoImplicitAnyError */ false, accessNode, accessFlags | 4 /* CacheSymbol */, shouldIncludeUndefined, /* reportDeprecated */ true); + return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, accessNode, accessFlags | 8 /* CacheSymbol */ | 64 /* ReportDeprecated */); } function getTypeFromIndexedAccessTypeNode(node) { var links = getNodeLinks(node); @@ -56896,7 +58882,7 @@ var ts; var objectType = getTypeFromTypeNode(node.objectType); var indexType = getTypeFromTypeNode(node.indexType); var potentialAlias = getAliasSymbolForTypeNode(node); - var resolved = getIndexedAccessType(objectType, indexType, /*noUncheckedIndexedAccessCandidate*/ undefined, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias)); + var resolved = getIndexedAccessType(objectType, indexType, 0 /* None */, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias)); links.resolvedType = resolved.flags & 8388608 /* IndexedAccess */ && resolved.objectType === objectType && resolved.indexType === indexType ? @@ -56928,16 +58914,32 @@ var ts; } return type; } - function getConditionalType(root, mapper) { + function isTypicalNondistributiveConditional(root) { + return !root.isDistributive + && root.node.checkType.kind === 181 /* TupleType */ + && ts.length(root.node.checkType.elements) === 1 + && root.node.extendsType.kind === 181 /* TupleType */ + && ts.length(root.node.extendsType.elements) === 1; + } + /** + * We syntactually check for common nondistributive conditional shapes and unwrap them into + * the intended comparison - we do this so we can check if the unwrapped types are generic or + * not and appropriately defer condition calculation + */ + function unwrapNondistributiveConditionalTuple(root, type) { + return isTypicalNondistributiveConditional(root) && isTupleType(type) ? getTypeArguments(type)[0] : type; + } + function getConditionalType(root, mapper, aliasSymbol, aliasTypeArguments) { var result; var extraTypes; // We loop here for an immediately nested conditional type in the false position, effectively treating // types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for // purposes of resolution. This means such types aren't subject to the instatiation depth limiter. while (true) { - var checkType = instantiateType(root.checkType, mapper); + var isUnwrapped = isTypicalNondistributiveConditional(root); + var checkType = instantiateType(unwrapNondistributiveConditionalTuple(root, getActualTypeVariable(root.checkType)), mapper); var checkTypeInstantiable = isGenericObjectType(checkType) || isGenericIndexType(checkType); - var extendsType = instantiateType(root.extendsType, mapper); + var extendsType = instantiateType(unwrapNondistributiveConditionalTuple(root, root.extendsType), mapper); if (checkType === wildcardType || extendsType === wildcardType) { return wildcardType; } @@ -56948,21 +58950,24 @@ 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, extendsType, 256 /* NoConstraints */ | 512 /* AlwaysStrict */); + inferTypes(context.inferences, checkType, extendsType, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */); } - combinedMapper = mergeTypeMappers(mapper, context.mapper); + // It's possible for 'infer T' type paramteters to be given uninstantiated constraints when the + // those type parameters are used in type references (see getInferredTypeParameterConstraint). For + // that reason we need context.mapper to be first in the combined mapper. See #42636 for examples. + combinedMapper = mapper ? combineTypeMappers(context.mapper, mapper) : context.mapper; } // Instantiate the extends type including inferences for 'infer T' type parameters - var inferredExtendsType = combinedMapper ? instantiateType(root.extendsType, combinedMapper) : extendsType; + var inferredExtendsType = combinedMapper ? instantiateType(unwrapNondistributiveConditionalTuple(root, root.extendsType), combinedMapper) : extendsType; // We attempt to resolve the conditional type only when the check and extends types are non-generic if (!checkTypeInstantiable && !isGenericObjectType(inferredExtendsType) && !isGenericIndexType(inferredExtendsType)) { // Return falseType for a definitely false extends check. We check an instantiations of the two // 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 */ || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) { + if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && ((checkType.flags & 1 /* Any */ && !isUnwrapped) || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) { // Return union of trueType and falseType for 'any' since it matches anything - if (checkType.flags & 1 /* Any */) { + if (checkType.flags & 1 /* 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 @@ -56991,12 +58996,12 @@ var ts; // Return a deferred type for a check that is neither definitely true nor definitely false result = createType(16777216 /* Conditional */); result.root = root; - result.checkType = checkType; - result.extendsType = extendsType; + result.checkType = instantiateType(root.checkType, mapper); + result.extendsType = instantiateType(root.extendsType, mapper); result.mapper = mapper; result.combinedMapper = combinedMapper; - result.aliasSymbol = root.aliasSymbol; - result.aliasTypeArguments = instantiateTypes(root.aliasTypeArguments, mapper); // TODO: GH#18217 + result.aliasSymbol = aliasSymbol || root.aliasSymbol; + result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(root.aliasTypeArguments, mapper); // TODO: GH#18217 break; } return extraTypes ? getUnionType(ts.append(extraTypes, result)) : result; @@ -57155,7 +59160,7 @@ var ts; } function getAliasSymbolForTypeNode(node) { var host = node.parent; - while (ts.isParenthesizedTypeNode(host) || ts.isJSDocTypeExpression(host) || ts.isTypeOperatorNode(host) && host.operator === 142 /* ReadonlyKeyword */) { + while (ts.isParenthesizedTypeNode(host) || ts.isJSDocTypeExpression(host) || ts.isTypeOperatorNode(host) && host.operator === 143 /* ReadonlyKeyword */) { host = host.parent; } return ts.isTypeAlias(host) ? getSymbolOfNode(host) : undefined; @@ -57194,7 +59199,7 @@ var ts; 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)); - result.type = isSetonlyAccessor ? undefinedType : getUnionType([getTypeOfSymbol(prop), undefinedType]); + result.type = isSetonlyAccessor ? undefinedType : addOptionality(getTypeOfSymbol(prop), /*isProperty*/ true); result.declarations = prop.declarations; result.nameType = getSymbolLinks(prop).nameType; result.syntheticOrigin = prop; @@ -57202,7 +59207,7 @@ var ts; } } var spread = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfoOfType(type, 0 /* String */), getIndexInfoOfType(type, 1 /* Number */)); - spread.objectFlags |= 128 /* ObjectLiteral */ | 1048576 /* ContainsObjectOrArrayLiteral */; + spread.objectFlags |= 128 /* ObjectLiteral */ | 262144 /* ContainsObjectOrArrayLiteral */; return spread; } } @@ -57308,14 +59313,15 @@ var ts; } } var spread = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfoWithReadonly(stringIndexInfo, readonly), getIndexInfoWithReadonly(numberIndexInfo, readonly)); - spread.objectFlags |= 128 /* ObjectLiteral */ | 1048576 /* ContainsObjectOrArrayLiteral */ | 1024 /* ContainsSpread */ | objectFlags; + spread.objectFlags |= 128 /* ObjectLiteral */ | 262144 /* ContainsObjectOrArrayLiteral */ | 4194304 /* ContainsSpread */ | objectFlags; return spread; } /** We approximate own properties as non-methods plus methods that are inside the object literal */ function isSpreadableProperty(prop) { - return !ts.some(prop.declarations, ts.isPrivateIdentifierPropertyDeclaration) && + var _a; + return !ts.some(prop.declarations, ts.isPrivateIdentifierClassElementDeclaration) && (!(prop.flags & (8192 /* Method */ | 32768 /* GetAccessor */ | 65536 /* SetAccessor */)) || - !prop.declarations.some(function (decl) { return ts.isClassLike(decl.parent); })); + !((_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 */); @@ -57340,11 +59346,9 @@ var ts; return type; } function getFreshTypeOfLiteralType(type) { - if (type.flags & 134220672 /* FreshableLiteral */) { + if (type.flags & 2944 /* Literal */) { if (!type.freshType) { - var freshType = type.flags & 134217728 /* TemplateLiteral */ ? - createTemplateLiteralType(type.texts, type.types) : - createLiteralType(type.flags, type.value, type.symbol); + var freshType = createLiteralType(type.flags, type.value, type.symbol); freshType.regularType = type; freshType.freshType = freshType; type.freshType = freshType; @@ -57354,12 +59358,12 @@ var ts; return type; } function getRegularTypeOfLiteralType(type) { - return type.flags & 134220672 /* FreshableLiteral */ ? type.regularType : + return type.flags & 2944 /* Literal */ ? type.regularType : type.flags & 1048576 /* Union */ ? (type.regularType || (type.regularType = mapType(type, getRegularTypeOfLiteralType))) : type; } function isFreshLiteralType(type) { - return !!(type.flags & 134220672 /* FreshableLiteral */) && type.freshType === type; + return !!(type.flags & 2944 /* Literal */) && type.freshType === type; } function getLiteralType(value, enumId, symbol) { // We store all literal types in a single map with keys of the form '#NNN' and '@SSS', @@ -57379,7 +59383,7 @@ var ts; return type; } function getTypeFromLiteralTypeNode(node) { - if (node.literal.kind === 103 /* NullKeyword */) { + if (node.literal.kind === 104 /* NullKeyword */) { return nullType; } var links = getNodeLinks(node); @@ -57405,7 +59409,7 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 253 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 255 /* InterfaceDeclaration */)) { if (!ts.hasSyntacticModifier(container, 32 /* Static */) && (!ts.isConstructorDeclaration(container) || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; @@ -57440,17 +59444,17 @@ var ts; } function getArrayElementTypeNode(node) { switch (node.kind) { - case 186 /* ParenthesizedType */: + case 188 /* ParenthesizedType */: return getArrayElementTypeNode(node.type); - case 179 /* TupleType */: + case 181 /* TupleType */: if (node.elements.length === 1) { node = node.elements[0]; - if (node.kind === 181 /* RestType */ || node.kind === 192 /* NamedTupleMember */ && node.dotDotDotToken) { + if (node.kind === 183 /* RestType */ || node.kind === 194 /* NamedTupleMember */ && node.dotDotDotToken) { return getArrayElementTypeNode(node.type); } } break; - case 178 /* ArrayType */: + case 180 /* ArrayType */: return node.elementType; } return undefined; @@ -57459,107 +59463,106 @@ var ts; var links = getNodeLinks(node); return links.resolvedType || (links.resolvedType = node.dotDotDotToken ? getTypeFromRestTypeNode(node) : - node.questionToken && strictNullChecks ? getOptionalType(getTypeFromTypeNode(node.type)) : - getTypeFromTypeNode(node.type)); + addOptionality(getTypeFromTypeNode(node.type), /*isProperty*/ true, !!node.questionToken)); } function getTypeFromTypeNode(node) { return getConditionalFlowTypeOfType(getTypeFromTypeNodeWorker(node), node); } function getTypeFromTypeNodeWorker(node) { switch (node.kind) { - case 128 /* AnyKeyword */: - case 303 /* JSDocAllType */: - case 304 /* JSDocUnknownType */: + case 129 /* AnyKeyword */: + case 306 /* JSDocAllType */: + case 307 /* JSDocUnknownType */: return anyType; - case 152 /* UnknownKeyword */: + case 153 /* UnknownKeyword */: return unknownType; - case 147 /* StringKeyword */: + case 148 /* StringKeyword */: return stringType; - case 144 /* NumberKeyword */: + case 145 /* NumberKeyword */: return numberType; - case 155 /* BigIntKeyword */: + case 156 /* BigIntKeyword */: return bigintType; - case 131 /* BooleanKeyword */: + case 132 /* BooleanKeyword */: return booleanType; - case 148 /* SymbolKeyword */: + case 149 /* SymbolKeyword */: return esSymbolType; - case 113 /* VoidKeyword */: + case 114 /* VoidKeyword */: return voidType; - case 150 /* UndefinedKeyword */: + case 151 /* UndefinedKeyword */: return undefinedType; - case 103 /* NullKeyword */: + case 104 /* 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 141 /* NeverKeyword */: + case 142 /* NeverKeyword */: return neverType; - case 145 /* ObjectKeyword */: + case 146 /* ObjectKeyword */: return node.flags & 131072 /* JavaScriptFile */ && !noImplicitAny ? anyType : nonPrimitiveType; - case 136 /* IntrinsicKeyword */: + case 137 /* IntrinsicKeyword */: return intrinsicMarkerType; - case 187 /* ThisType */: - case 107 /* ThisKeyword */: + case 189 /* ThisType */: + case 108 /* 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 191 /* LiteralType */: + case 193 /* LiteralType */: return getTypeFromLiteralTypeNode(node); - case 173 /* TypeReference */: + case 175 /* TypeReference */: return getTypeFromTypeReference(node); - case 172 /* TypePredicate */: + case 174 /* TypePredicate */: return node.assertsModifier ? voidType : booleanType; - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 176 /* TypeQuery */: + case 178 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 178 /* ArrayType */: - case 179 /* TupleType */: + case 180 /* ArrayType */: + case 181 /* TupleType */: return getTypeFromArrayOrTupleTypeNode(node); - case 180 /* OptionalType */: + case 182 /* OptionalType */: return getTypeFromOptionalTypeNode(node); - case 182 /* UnionType */: + case 184 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 183 /* IntersectionType */: + case 185 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 305 /* JSDocNullableType */: + case 308 /* JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 307 /* JSDocOptionalType */: + case 310 /* JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 192 /* NamedTupleMember */: + case 194 /* NamedTupleMember */: return getTypeFromNamedTupleTypeNode(node); - case 186 /* ParenthesizedType */: - case 306 /* JSDocNonNullableType */: - case 301 /* JSDocTypeExpression */: + case 188 /* ParenthesizedType */: + case 309 /* JSDocNonNullableType */: + case 303 /* JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 181 /* RestType */: + case 183 /* RestType */: return getTypeFromRestTypeNode(node); - case 309 /* JSDocVariadicType */: + case 312 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); - case 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 177 /* TypeLiteral */: - case 312 /* JSDocTypeLiteral */: - case 308 /* JSDocFunctionType */: - case 313 /* JSDocSignature */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: + case 179 /* TypeLiteral */: + case 316 /* JSDocTypeLiteral */: + case 311 /* JSDocFunctionType */: + case 317 /* JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 188 /* TypeOperator */: + case 190 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 189 /* IndexedAccessType */: + case 191 /* IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 190 /* MappedType */: + case 192 /* MappedType */: return getTypeFromMappedTypeNode(node); - case 184 /* ConditionalType */: + case 186 /* ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 185 /* InferType */: + case 187 /* InferType */: return getTypeFromInferTypeNode(node); - case 193 /* TemplateLiteralType */: + case 195 /* TemplateLiteralType */: return getTypeFromTemplateTypeNode(node); - case 195 /* ImportType */: + case 197 /* 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 78 /* Identifier */: - case 157 /* QualifiedName */: - case 201 /* PropertyAccessExpression */: + case 79 /* Identifier */: + case 159 /* QualifiedName */: + case 203 /* PropertyAccessExpression */: var symbol = getSymbolAtLocation(node); return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType; default: @@ -57712,7 +59715,7 @@ var ts; } return result; } - function getObjectTypeInstantiation(type, mapper) { + function getObjectTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) { var declaration = type.objectFlags & 4 /* Reference */ ? type.node : type.symbol.declarations[0]; var links = getNodeLinks(declaration); var target = type.objectFlags & 4 /* Reference */ ? links.resolvedType : @@ -57729,8 +59732,9 @@ var ts; outerTypeParameters = ts.addRange(outerTypeParameters, templateTagParameters); } typeParameters = outerTypeParameters || ts.emptyArray; - typeParameters = (target.objectFlags & 4 /* Reference */ || target.symbol.flags & 2048 /* TypeLiteral */) && !target.aliasTypeArguments ? - ts.filter(typeParameters, function (tp) { return isTypeParameterPossiblyReferenced(tp, declaration); }) : + var allDeclarations_1 = type.objectFlags & 4 /* Reference */ ? [declaration] : type.symbol.declarations; + typeParameters = (target.objectFlags & 4 /* Reference */ || target.symbol.flags & 8192 /* Method */ || target.symbol.flags & 2048 /* TypeLiteral */) && !target.aliasTypeArguments ? + ts.filter(typeParameters, function (tp) { return ts.some(allDeclarations_1, function (d) { return isTypeParameterPossiblyReferenced(tp, d); }); }) : typeParameters; links.outerTypeParameters = typeParameters; } @@ -57740,17 +59744,19 @@ var ts; // instantiation cache key from the type IDs of the type arguments. var combinedMapper_1 = combineTypeMappers(type.mapper, mapper); var typeArguments = ts.map(typeParameters, function (t) { return getMappedType(t, combinedMapper_1); }); - var id = getTypeListId(typeArguments); + var newAliasSymbol = aliasSymbol || type.aliasSymbol; + var newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper); + var id = getTypeListId(typeArguments) + getAliasId(newAliasSymbol, newAliasTypeArguments); if (!target.instantiations) { target.instantiations = new ts.Map(); - target.instantiations.set(getTypeListId(typeParameters), target); + target.instantiations.set(getTypeListId(typeParameters) + getAliasId(target.aliasSymbol, target.aliasTypeArguments), target); } var result = target.instantiations.get(id); if (!result) { var newMapper = createTypeMapper(typeParameters, typeArguments); - result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper) : - target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper) : - instantiateAnonymousType(target, newMapper); + result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : + target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : + instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments); target.instantiations.set(id, result); } return result; @@ -57758,9 +59764,8 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 157 /* QualifiedName */ || - node.parent.kind === 173 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || - node.parent.kind === 195 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); + return !(node.parent.kind === 175 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || + node.parent.kind === 197 /* 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 @@ -57769,22 +59774,28 @@ 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 === 230 /* Block */ || n.kind === 184 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { + if (!n || n.kind === 232 /* Block */ || n.kind === 186 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { return true; } } - return !!ts.forEachChild(node, containsReference); + return containsReference(node); } return true; function containsReference(node) { switch (node.kind) { - case 187 /* ThisType */: + case 189 /* ThisType */: return !!tp.isThisType; - case 78 /* Identifier */: + case 79 /* Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNodeWorker(node) === tp; // use worker because we're looking for === equality - case 176 /* TypeQuery */: + case 178 /* TypeQuery */: return true; + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + return !node.type && !!node.body || + ts.some(node.typeParameters, containsReference) || + ts.some(node.parameters, containsReference) || + !!node.type && containsReference(node.type); } return !!ts.forEachChild(node, containsReference); } @@ -57799,7 +59810,7 @@ var ts; } return undefined; } - function instantiateMappedType(type, mapper) { + function instantiateMappedType(type, mapper, aliasSymbol, aliasTypeArguments) { // For a homomorphic mapped type { [P in keyof T]: X }, where T is some type variable, the mapping // operation depends on T as follows: // * If T is a primitive type no mapping is performed and the result is simply T. @@ -57814,7 +59825,7 @@ var ts; if (typeVariable) { var mappedTypeVariable = instantiateType(typeVariable, mapper); if (typeVariable !== mappedTypeVariable) { - return mapType(getReducedType(mappedTypeVariable), function (t) { + return mapTypeWithAlias(getReducedType(mappedTypeVariable), function (t) { if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && t !== errorType) { if (!type.declaration.nameType) { if (isArrayType(t)) { @@ -57830,11 +59841,11 @@ var ts; return instantiateAnonymousType(type, prependTypeMapping(typeVariable, t, mapper)); } return t; - }); + }, aliasSymbol, aliasTypeArguments); } } // If the constraint type of the instantiation is the wildcard type, return the wildcard type. - return instantiateType(getConstraintTypeFromMappedType(type), mapper) === wildcardType ? wildcardType : instantiateAnonymousType(type, mapper); + 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; @@ -57877,11 +59888,11 @@ 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) : + return strictNullChecks && modifiers & 4 /* IncludeOptional */ && !maybeTypeOfKind(propType, 32768 /* Undefined */ | 16384 /* Void */) ? getOptionalType(propType, /*isProperty*/ true) : strictNullChecks && modifiers & 8 /* ExcludeOptional */ && isOptional ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : propType; } - function instantiateAnonymousType(type, mapper) { + function instantiateAnonymousType(type, mapper, aliasSymbol, aliasTypeArguments) { var result = createObjectType(type.objectFlags | 64 /* Instantiated */, type.symbol); if (type.objectFlags & 32 /* Mapped */) { result.declaration = type.declaration; @@ -57894,29 +59905,29 @@ var ts; } result.target = type; result.mapper = mapper; - result.aliasSymbol = type.aliasSymbol; - result.aliasTypeArguments = instantiateTypes(type.aliasTypeArguments, mapper); + result.aliasSymbol = aliasSymbol || type.aliasSymbol; + result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper); return result; } - function getConditionalTypeInstantiation(type, mapper) { + function getConditionalTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) { var root = type.root; if (root.outerTypeParameters) { // We are instantiating a conditional type that has one or more type parameters in scope. Apply the // mapper to the type parameters to produce the effective list of type arguments, and compute the // instantiation cache key from the type IDs of the type arguments. var typeArguments = ts.map(root.outerTypeParameters, function (t) { return getMappedType(t, mapper); }); - var id = getTypeListId(typeArguments); + var id = getTypeListId(typeArguments) + getAliasId(aliasSymbol, aliasTypeArguments); var result = root.instantiations.get(id); if (!result) { var newMapper = createTypeMapper(root.outerTypeParameters, typeArguments); - result = instantiateConditionalType(root, newMapper); + result = instantiateConditionalType(root, newMapper, aliasSymbol, aliasTypeArguments); root.instantiations.set(id, result); } return result; } return type; } - function instantiateConditionalType(root, mapper) { + function instantiateConditionalType(root, mapper, aliasSymbol, aliasTypeArguments) { // Check if we have a conditional type where the check type is a naked type parameter. If so, // the conditional type is distributive over union types and when T is instantiated to a union // type A | B, we produce (A extends U ? X : Y) | (B extends U ? X : Y). @@ -57924,31 +59935,34 @@ var ts; var checkType_1 = root.checkType; var instantiatedType = getMappedType(checkType_1, mapper); if (checkType_1 !== instantiatedType && instantiatedType.flags & (1048576 /* Union */ | 131072 /* Never */)) { - return mapType(instantiatedType, function (t) { return getConditionalType(root, prependTypeMapping(checkType_1, t, mapper)); }); + return mapTypeWithAlias(instantiatedType, function (t) { return getConditionalType(root, prependTypeMapping(checkType_1, t, mapper)); }, aliasSymbol, aliasTypeArguments); } } - return getConditionalType(root, mapper); + return getConditionalType(root, mapper, aliasSymbol, aliasTypeArguments); } function instantiateType(type, mapper) { - if (!(type && mapper && couldContainTypeVariables(type))) { + return type && mapper ? instantiateTypeWithAlias(type, mapper, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined) : type; + } + function instantiateTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments) { + if (!couldContainTypeVariables(type)) { return type; } if (instantiationDepth === 50 || instantiationCount >= 5000000) { // We have reached 50 recursive type instantiations and there is a very high likelyhood we're dealing // with a combination of infinite generic types that perpetually generate new type identities. We stop // the recursion here by yielding the error type. - 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" /* CheckTypes */, "instantiateType_DepthLimit", { typeId: type.id, instantiationDepth: instantiationDepth, instantiationCount: instantiationCount }); error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite); return errorType; } totalInstantiationCount++; instantiationCount++; instantiationDepth++; - var result = instantiateTypeWorker(type, mapper); + var result = instantiateTypeWorker(type, mapper, aliasSymbol, aliasTypeArguments); instantiationDepth--; return result; } - function instantiateTypeWorker(type, mapper) { + function instantiateTypeWorker(type, mapper, aliasSymbol, aliasTypeArguments) { var flags = type.flags; if (flags & 262144 /* TypeParameter */) { return getMappedType(type, mapper); @@ -57956,12 +59970,15 @@ var ts; if (flags & 524288 /* Object */) { var objectFlags = type.objectFlags; if (objectFlags & (4 /* Reference */ | 16 /* Anonymous */ | 32 /* Mapped */)) { - if (objectFlags & 4 /* Reference */ && !(type.node)) { + if (objectFlags & 4 /* Reference */ && !type.node) { var resolvedTypeArguments = type.resolvedTypeArguments; var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper); return newTypeArguments !== resolvedTypeArguments ? createNormalizedTypeReference(type.target, newTypeArguments) : type; } - return getObjectTypeInstantiation(type, mapper); + if (objectFlags & 1024 /* ReverseMapped */) { + return instantiateReverseMappedType(type, mapper); + } + return getObjectTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments); } return type; } @@ -57969,10 +59986,14 @@ var ts; var origin = type.flags & 1048576 /* Union */ ? type.origin : undefined; var types = origin && origin.flags & 3145728 /* UnionOrIntersection */ ? origin.types : type.types; var newTypes = instantiateTypes(types, mapper); - return newTypes === types ? type : - flags & 2097152 /* Intersection */ || origin && origin.flags & 2097152 /* Intersection */ ? - getIntersectionType(newTypes, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) : - getUnionType(newTypes, 1 /* Literal */, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, 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 */ ? + getIntersectionType(newTypes, newAliasSymbol, newAliasTypeArguments) : + getUnionType(newTypes, 1 /* Literal */, newAliasSymbol, newAliasTypeArguments); } if (flags & 4194304 /* Index */) { return getIndexType(instantiateType(type.type, mapper)); @@ -57984,10 +60005,12 @@ var ts; return getStringMappingType(type.symbol, instantiateType(type.type, mapper)); } if (flags & 8388608 /* IndexedAccess */) { - return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper), type.noUncheckedIndexedAccessCandidate, /*accessNode*/ undefined, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); + 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 */) { - return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper)); + return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper), aliasSymbol, aliasTypeArguments); } if (flags & 33554432 /* Substitution */) { var maybeVariable = instantiateType(type.baseType, mapper); @@ -58004,6 +60027,21 @@ var ts; } return type; } + function instantiateReverseMappedType(type, mapper) { + var innerMappedType = instantiateType(type.mappedType, mapper); + if (!(ts.getObjectFlags(innerMappedType) & 32 /* Mapped */)) { + return type; + } + var innerIndexType = instantiateType(type.constraintType, mapper); + if (!(innerIndexType.flags & 4194304 /* Index */)) { + return type; + } + var instantiated = inferTypeForHomomorphicMappedType(instantiateType(type.source, mapper), innerMappedType, innerIndexType); + if (instantiated) { + return instantiated; + } + return type; // Nested invocation of `inferTypeForHomomorphicMappedType` or the `source` instantiated into something unmappable + } function getPermissiveInstantiation(type) { return type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */) ? type : type.permissiveInstantiation || (type.permissiveInstantiation = instantiateType(type, permissiveMapper)); @@ -58030,35 +60068,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 !== 165 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 167 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: - case 251 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 253 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type return isContextSensitiveFunctionLikeDeclaration(node); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return (node.operatorToken.kind === 56 /* BarBarToken */ || node.operatorToken.kind === 60 /* QuestionQuestionToken */) && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return isContextSensitive(node.expression); - case 281 /* JsxAttributes */: + case 283 /* JsxAttributes */: return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive); - case 280 /* JsxAttribute */: { + case 282 /* 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 283 /* JsxExpression */: { + case 285 /* JsxExpression */: { // It is possible to that node.expression is undefined (e.g

) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -58077,7 +60115,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 209 /* ArrowFunction */) { + if (node.kind !== 211 /* 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); @@ -58090,7 +60128,7 @@ 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 !== 230 /* Block */ && isContextSensitive(node.body); + return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 232 /* Block */ && isContextSensitive(node.body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && @@ -58193,23 +60231,23 @@ var ts; return true; } switch (node.kind) { - case 283 /* JsxExpression */: - case 207 /* ParenthesizedExpression */: + case 285 /* JsxExpression */: + case 209 /* ParenthesizedExpression */: return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 62 /* EqualsToken */: + case 63 /* EqualsToken */: case 27 /* CommaToken */: return elaborateError(node.right, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); } break; - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 281 /* JsxAttributes */: + case 283 /* JsxAttributes */: return elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer); } return false; @@ -58310,7 +60348,14 @@ var ts; if (!targetPropType || targetPropType.flags & 8388608 /* IndexedAccess */) continue; // Don't elaborate on indexes on generic variables var sourcePropType = getIndexedAccessTypeOrUndefined(source, nameType); - if (sourcePropType && !checkTypeRelatedTo(sourcePropType, targetPropType, relation, /*errorNode*/ undefined)) { + if (!sourcePropType) + continue; + var propName = getPropertyNameFromIndex(nameType, /*accessNode*/ undefined); + var targetIsOptional = !!(propName && (getPropertyOfType(target, propName) || unknownSymbol).flags & 16777216 /* Optional */); + var sourceIsOptional = !!(propName && (getPropertyOfType(source, propName) || unknownSymbol).flags & 16777216 /* Optional */); + targetPropType = removeMissingType(targetPropType, targetIsOptional); + sourcePropType = removeMissingType(sourcePropType, targetIsOptional && sourceIsOptional); + if (!checkTypeRelatedTo(sourcePropType, targetPropType, relation, /*errorNode*/ undefined)) { var elaborated = next && elaborateError(next, sourcePropType, targetPropType, relation, /*headMessage*/ undefined, containingMessageChain, errorOutputContainer); if (elaborated) { reportedError = true; @@ -58409,7 +60454,7 @@ var ts; } function getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic) { switch (child.kind) { - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: // child is of the type of the expression return { errorNode: child, innerExpression: child.expression, nameType: nameType }; case 11 /* JsxText */: @@ -58418,9 +60463,9 @@ var ts; } // child is a string return { errorNode: child, innerExpression: undefined, nameType: nameType, errorMessage: getInvalidTextDiagnostic() }; - case 273 /* JsxElement */: - case 274 /* JsxSelfClosingElement */: - case 277 /* JsxFragment */: + case 275 /* JsxElement */: + case 276 /* JsxSelfClosingElement */: + case 279 /* JsxFragment */: // child is of type JSX.Element return { errorNode: child, innerExpression: child, nameType: nameType }; default: @@ -58568,11 +60613,11 @@ var ts; } _b = prop.kind; switch (_b) { - case 168 /* SetAccessor */: return [3 /*break*/, 2]; - case 167 /* GetAccessor */: return [3 /*break*/, 2]; - case 165 /* MethodDeclaration */: return [3 /*break*/, 2]; - case 289 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; - case 288 /* PropertyAssignment */: return [3 /*break*/, 4]; + case 170 /* SetAccessor */: return [3 /*break*/, 2]; + case 169 /* GetAccessor */: return [3 /*break*/, 2]; + case 167 /* MethodDeclaration */: return [3 /*break*/, 2]; + case 291 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 290 /* PropertyAssignment */: return [3 /*break*/, 4]; } return [3 /*break*/, 6]; case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; @@ -58649,8 +60694,8 @@ var ts; return 0 /* False */; } var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - var strictVariance = !(checkMode & 3 /* Callback */) && strictFunctionTypes && kind !== 165 /* MethodDeclaration */ && - kind !== 164 /* MethodSignature */ && kind !== 166 /* Constructor */; + var strictVariance = !(checkMode & 3 /* Callback */) && strictFunctionTypes && kind !== 167 /* MethodDeclaration */ && + kind !== 166 /* MethodSignature */ && kind !== 168 /* Constructor */; var result = -1 /* True */; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { @@ -58883,7 +60928,7 @@ var ts; // 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 */ || t & 256 /* NumberLiteral */ && t & 1024 /* EnumLiteral */)) + if (s & (8 /* Number */ | 256 /* NumberLiteral */) && !(s & 1024 /* EnumLiteral */) && (t & 32 /* Enum */ || relation === assignableRelation && t & 256 /* NumberLiteral */ && t & 1024 /* EnumLiteral */)) return true; } return false; @@ -58920,7 +60965,7 @@ var ts; return false; } function isIgnoredJsxProperty(source, sourceProp) { - return ts.getObjectFlags(source) & 4096 /* JsxAttributes */ && !isUnhyphenatedJsxName(sourceProp.escapedName); + return ts.getObjectFlags(source) & 2048 /* JsxAttributes */ && !isUnhyphenatedJsxName(sourceProp.escapedName); } function getNormalizedType(type, writing) { while (true) { @@ -58930,6 +60975,7 @@ var ts; type.flags & 33554432 /* Substitution */ ? writing ? type.baseType : type.substitute : type.flags & 25165824 /* Simplifiable */ ? getSimplifiedType(type, writing) : type; + t = getSingleBaseForNonAugmentingSubtype(t) || t; if (t === type) break; type = t; @@ -58967,7 +61013,7 @@ var ts; reportIncompatibleStack(); } if (overflow) { - ts.tracing.instant("checkTypes" /* CheckTypes */, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: depth }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: depth }); 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); @@ -59103,6 +61149,14 @@ var ts; } break; } + case ts.Diagnostics.Type_at_position_0_in_source_is_not_compatible_with_type_at_position_1_in_target.code: { + secondaryRootErrors.unshift([ts.Diagnostics.Type_at_position_0_in_source_is_not_compatible_with_type_at_position_1_in_target, args[0], args[1]]); + break; + } + case ts.Diagnostics.Type_at_positions_0_through_1_in_source_is_not_compatible_with_type_at_position_2_in_target.code: { + secondaryRootErrors.unshift([ts.Diagnostics.Type_at_positions_0_through_1_in_source_is_not_compatible_with_type_at_position_2_in_target, args[0], args[1], args[2]]); + break; + } default: return ts.Debug.fail("Unhandled Diagnostic: " + msg.code); } @@ -59163,6 +61217,7 @@ var ts; reportError(ts.Diagnostics._0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2, needsOriginalSource ? sourceType : generalizedSourceType, targetType, typeToString(constraint)); } else { + errorInfo = undefined; reportError(ts.Diagnostics._0_could_be_instantiated_with_an_arbitrary_type_which_could_be_unrelated_to_1, targetType, generalizedSourceType); } } @@ -59238,7 +61293,7 @@ var ts; if (isSimpleTypeRelatedTo(originalSource, originalTarget, relation, reportErrors ? reportError : undefined)) { return -1 /* True */; } - reportErrorResults(originalSource, originalTarget, 0 /* False */, !!(ts.getObjectFlags(originalSource) & 4096 /* JsxAttributes */)); + reportErrorResults(originalSource, originalTarget, 0 /* False */, !!(ts.getObjectFlags(originalSource) & 2048 /* JsxAttributes */)); return 0 /* False */; } // Normalize the source and target types: Turn fresh literal types into regular literal types, @@ -59273,16 +61328,16 @@ var ts; target.types.length <= 3 && maybeTypeOfKind(target, 98304 /* Nullable */)) { var nullStrippedTarget = extractTypesOfKind(target, ~98304 /* Nullable */); if (!(nullStrippedTarget.flags & (1048576 /* Union */ | 131072 /* Never */))) { - if (source === nullStrippedTarget) - return -1 /* True */; - target = nullStrippedTarget; + target = getNormalizedType(nullStrippedTarget, /*writing*/ true); } + if (source === nullStrippedTarget) + return -1 /* True */; } if (relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return -1 /* True */; - var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096 /* JsxAttributes */); - var isPerformingExcessPropertyChecks = !(intersectionState & 2 /* Target */) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 32768 /* FreshLiteral */); + var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* JsxAttributes */); + var isPerformingExcessPropertyChecks = !(intersectionState & 2 /* Target */) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 16384 /* FreshLiteral */); if (isPerformingExcessPropertyChecks) { if (hasExcessProperties(source, target, reportErrors)) { if (reportErrors) { @@ -59367,7 +61422,7 @@ var ts; // We suppress recursive intersection property checks because they can generate lots of work when relating // recursive intersections that are structurally similar but not exactly identical. See #37854. if (result && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) || - isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 2097152 /* NonInferrableType */); }))) { + isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 524288 /* NonInferrableType */); }))) { inPropertyCheck = true; result &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */); inPropertyCheck = false; @@ -59376,8 +61431,10 @@ var ts; return result; function reportErrorResults(source, target, result, isComparingJsxAttributes) { if (!result && reportErrors) { - source = originalSource.aliasSymbol ? originalSource : source; - target = originalTarget.aliasSymbol ? originalTarget : target; + var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource); + var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget); + source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source; + target = (originalTarget.aliasSymbol || targetHasBase) ? originalTarget : target; var maybeSuppress = overrideNextErrorInfo > 0; if (maybeSuppress) { overrideNextErrorInfo--; @@ -59418,13 +61475,13 @@ var ts; } } function traceUnionsOrIntersectionsTooLarge(source, target) { - if (!ts.tracing.isTracing()) { + if (!ts.tracing) { return; } if ((source.flags & 3145728 /* UnionOrIntersection */) && (target.flags & 3145728 /* UnionOrIntersection */)) { var sourceUnionOrIntersection = source; var targetUnionOrIntersection = target; - if (sourceUnionOrIntersection.objectFlags & targetUnionOrIntersection.objectFlags & 262144 /* PrimitiveUnion */) { + if (sourceUnionOrIntersection.objectFlags & targetUnionOrIntersection.objectFlags & 65536 /* PrimitiveUnion */) { // There's a fast path for comparing primitive unions return; } @@ -59449,11 +61506,11 @@ var ts; } traceUnionsOrIntersectionsTooLarge(source, target); if (flags & 3145728 /* UnionOrIntersection */) { - var result_6 = eachTypeRelatedToSomeType(source, target); - if (result_6) { - result_6 &= eachTypeRelatedToSomeType(target, source); + var result_7 = eachTypeRelatedToSomeType(source, target); + if (result_7) { + result_7 &= eachTypeRelatedToSomeType(target, source); } - return result_6; + return result_7; } return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None */); } @@ -59467,10 +61524,11 @@ var ts; return getUnionType(ts.reduceLeft(types, appendPropType, /*initial*/ undefined) || ts.emptyArray); } function hasExcessProperties(source, target, reportErrors) { - if (!isExcessPropertyCheckTarget(target) || !noImplicitAny && ts.getObjectFlags(target) & 16384 /* JSLiteral */) { + var _a; + if (!isExcessPropertyCheckTarget(target) || !noImplicitAny && ts.getObjectFlags(target) & 8192 /* 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) & 4096 /* JsxAttributes */); + var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* JsxAttributes */); if ((relation === assignableRelation || relation === comparableRelation) && (isTypeSubsetOf(globalObjectType, target) || (!isComparingJsxAttributes && isEmptyObjectType(target)))) { return false; @@ -59513,7 +61571,7 @@ var ts; } else { // use the property's value declaration if the property is assigned inside the literal itself - var objectLiteralDeclaration_1 = source.symbol && ts.firstOrUndefined(source.symbol.declarations); + var objectLiteralDeclaration_1 = ((_a = source.symbol) === null || _a === void 0 ? void 0 : _a.declarations) && ts.firstOrUndefined(source.symbol.declarations); var suggestion = void 0; if (prop.valueDeclaration && ts.findAncestor(prop.valueDeclaration, function (d) { return d === objectLiteralDeclaration_1; }) && ts.getSourceFileOfNode(objectLiteralDeclaration_1) === ts.getSourceFileOfNode(errorNode)) { var propDeclaration = prop.valueDeclaration; @@ -59542,11 +61600,11 @@ var ts; } } }; - for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) { - var prop = _a[_i]; - var state_4 = _loop_16(prop); - if (typeof state_4 === "object") - return state_4.value; + for (var _i = 0, _b = getPropertiesOfType(source); _i < _b.length; _i++) { + var prop = _b[_i]; + var state_5 = _loop_16(prop); + if (typeof state_5 === "object") + return state_5.value; } return false; } @@ -59568,8 +61626,17 @@ var ts; } function typeRelatedToSomeType(source, target, reportErrors) { var targetTypes = target.types; - if (target.flags & 1048576 /* Union */ && containsType(targetTypes, source)) { - return -1 /* True */; + if (target.flags & 1048576 /* Union */) { + if (containsType(targetTypes, source)) { + return -1 /* True */; + } + var match = getMatchingUnionConstituentForType(target, source); + if (match) { + var related = isRelatedTo(source, match, /*reportErrors*/ false); + if (related) { + return related; + } + } } for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { var type = targetTypes_1[_i]; @@ -59743,9 +61810,16 @@ var ts; targetStack = []; } else { + // generate a key where all type parameter id positions are replaced with unconstrained type parameter ids + // this isn't perfect - nested type references passed as type arguments will muck up the indexes and thus + // prevent finding matches- but it should hit up the common cases + var broadestEquivalentId = id.split(",").map(function (i) { return i.replace(/-\d+/g, function (_match, offset) { + var index = ts.length(id.slice(0, offset).match(/[-=]/g) || undefined); + return "=" + index; + }); }).join(","); for (var i = 0; i < maybeCount; i++) { // If source and target are already being compared, consider them related with assumptions - if (id === maybeKeys[i]) { + if (id === maybeKeys[i] || broadestEquivalentId === maybeKeys[i]) { return 3 /* Maybe */; } } @@ -59775,7 +61849,7 @@ var ts; }; } if (expandingFlags === 3 /* Both */) { - ts.tracing.instant("checkTypes" /* CheckTypes */, "recursiveTypeRelatedTo_DepthLimit", { + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "recursiveTypeRelatedTo_DepthLimit", { sourceId: source.id, sourceIdStack: sourceStack.map(function (t) { return t.id; }), targetId: target.id, @@ -59810,9 +61884,9 @@ var ts; return result; } function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) { - 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" /* CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id }); var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; } function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState) { @@ -59834,8 +61908,21 @@ var ts; if (target.flags & 2097152 /* Intersection */) { return typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2 /* Target */); } - // Source is an intersection. Check to see if any constituents of the intersection are immediately related - // to the 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 */) { + var constraints = ts.sameMap(source.types, function (t) { return t.flags & 131068 /* Primitive */ ? t : getBaseConstraintOfType(t) || unknownType; }); + if (constraints !== source.types) { + source = getIntersectionType(constraints); + if (!(source.flags & 2097152 /* Intersection */)) { + return isRelatedTo(source, target, /*reportErrors*/ false); + } + } + } + // Check to see if any constituents of the intersection are immediately related to the target. // // Don't report errors though. Checking whether a constituent is related to the source is not actually // useful and leads to some confusing error messages. Instead it is better to let the below checks @@ -59855,21 +61942,21 @@ var ts; if (flags & 4194304 /* Index */) { return isRelatedTo(source.type, target.type, /*reportErrors*/ false); } - var result_7 = 0 /* False */; + var result_8 = 0 /* False */; if (flags & 8388608 /* IndexedAccess */) { - if (result_7 = isRelatedTo(source.objectType, target.objectType, /*reportErrors*/ false)) { - if (result_7 &= isRelatedTo(source.indexType, target.indexType, /*reportErrors*/ false)) { - return result_7; + if (result_8 = isRelatedTo(source.objectType, target.objectType, /*reportErrors*/ false)) { + if (result_8 &= isRelatedTo(source.indexType, target.indexType, /*reportErrors*/ false)) { + return result_8; } } } if (flags & 16777216 /* Conditional */) { if (source.root.isDistributive === target.root.isDistributive) { - if (result_7 = isRelatedTo(source.checkType, target.checkType, /*reportErrors*/ false)) { - if (result_7 &= isRelatedTo(source.extendsType, target.extendsType, /*reportErrors*/ false)) { - if (result_7 &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), /*reportErrors*/ false)) { - if (result_7 &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), /*reportErrors*/ false)) { - return result_7; + if (result_8 = isRelatedTo(source.checkType, target.checkType, /*reportErrors*/ false)) { + if (result_8 &= isRelatedTo(source.extendsType, target.extendsType, /*reportErrors*/ false)) { + if (result_8 &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), /*reportErrors*/ false)) { + if (result_8 &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), /*reportErrors*/ false)) { + return result_8; } } } @@ -59949,6 +62036,20 @@ var ts; } } else if (target.flags & 8388608 /* IndexedAccess */) { + if (source.flags & 8388608 /* 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, reportErrors)) { + result &= isRelatedTo(source.indexType, target.indexType, reportErrors); + } + if (result) { + resetErrorInfo(saveErrorInfo); + return result; + } + if (reportErrors) { + originalErrorInfo = errorInfo; + } + } // A type S is related to a type T[K] if S is related to C, where C is the base // constraint of T[K] for writing. if (relation === assignableRelation || relation === comparableRelation) { @@ -59957,13 +62058,26 @@ var ts; var baseObjectType = getBaseConstraintOfType(objectType) || objectType; var baseIndexType = getBaseConstraintOfType(indexType) || indexType; if (!isGenericObjectType(baseObjectType) && !isGenericIndexType(baseIndexType)) { - var accessFlags = 2 /* Writing */ | (baseObjectType !== objectType ? 1 /* NoIndexSignatures */ : 0); - var constraint = getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, target.noUncheckedIndexedAccessCandidate, /*accessNode*/ undefined, accessFlags); - if (constraint && (result = isRelatedTo(source, constraint, reportErrors))) { - return result; + var accessFlags = 4 /* Writing */ | (baseObjectType !== objectType ? 2 /* 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, reportErrors)) { + return result; + } + // prefer the shorter chain of the constraint comparison chain, and the direct comparison chain + if (reportErrors && originalErrorInfo && errorInfo) { + errorInfo = countMessageChainBreadth([originalErrorInfo]) <= countMessageChainBreadth([errorInfo]) ? originalErrorInfo : errorInfo; + } } } } + if (reportErrors) { + originalErrorInfo = undefined; + } } else if (isGenericMappedType(target) && !target.declaration.nameType) { // A source type T is related to a target type { [P in X]: T[P] } @@ -60007,27 +62121,48 @@ var ts; } } } - else if (target.flags & 134217728 /* TemplateLiteral */ && source.flags & 128 /* StringLiteral */) { - if (isPatternLiteralType(target)) { - // match all non-`string` segments - var result_8 = inferLiteralsFromTemplateLiteralType(source, target); - if (result_8 && ts.every(result_8, function (r, i) { return isStringLiteralTypeValueParsableAsType(r, target.types[i]); })) { - return -1 /* True */; - } + else if (target.flags & 16777216 /* Conditional */) { + var c = target; + // Check if the conditional is always true or always false but still deferred for distribution purposes + var skipTrue = !isTypeAssignableTo(getPermissiveInstantiation(c.checkType), getPermissiveInstantiation(c.extendsType)); + var skipFalse = !skipTrue && isConditionalTypeAlwaysTrueDisregardingInferTypes(c); + // Instantiate with a replacement mapper if the conditional is distributive, replacing the check type with a clone of itself, + // this way {x: string | number, y: string | number} -> (T extends T ? { x: T, y: T } : never) appropriately _fails_ when + // T = string | number (since that will end up distributing and producing `{x: string, y: string} | {x: number, y: number}`, + // to which `{x: string | number, y: string | number}` isn't assignable) + var distributionMapper = void 0; + var checkVar = getActualTypeVariable(c.root.checkType); + if (c.root.isDistributive && checkVar.flags & 262144 /* TypeParameter */) { + var newParam = cloneTypeParameter(checkVar); + distributionMapper = prependTypeMapping(checkVar, newParam, c.mapper); + newParam.mapper = distributionMapper; + } + // TODO: Find a nice way to include potential conditional type breakdowns in error output, if they seem good (they usually don't) + var localResult = void 0; + if (skipTrue || (localResult = isRelatedTo(source, distributionMapper ? instantiateType(getTypeFromTypeNode(c.root.node.trueType), distributionMapper) : getTrueTypeFromConditionalType(c), /*reportErrors*/ false))) { + if (!skipFalse) { + localResult = (localResult || 3 /* Maybe */) & isRelatedTo(source, distributionMapper ? instantiateType(getTypeFromTypeNode(c.root.node.falseType), distributionMapper) : getFalseTypeFromConditionalType(c), /*reportErrors*/ false); + } + } + if (localResult) { + resetErrorInfo(saveErrorInfo); + return localResult; } } - if (source.flags & 8650752 /* TypeVariable */) { - if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) { - // 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, reportErrors)) { - result &= isRelatedTo(source.indexType, target.indexType, reportErrors); - } - if (result) { - resetErrorInfo(saveErrorInfo); - return result; - } + else if (target.flags & 134217728 /* TemplateLiteral */) { + if (source.flags & 134217728 /* TemplateLiteral */) { + // 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)); } - else { + var result_9 = inferTypesFromTemplateLiteralType(source, target); + if (result_9 && ts.every(result_9, function (r, i) { return isValidTypeForTemplateLiteralPlaceholder(r, target.types[i]); })) { + return -1 /* True */; + } + } + if (source.flags & 8650752 /* TypeVariable */) { + // IndexedAccess comparisons are handled above in the `target.flags & TypeFlage.IndexedAccess` branch + if (!(source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */)) { var constraint = getConstraintOfType(source); if (!constraint || (source.flags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) { // A type variable with no constraint is not related to the non-primitive object type. @@ -60042,7 +62177,7 @@ var ts; 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, reportErrors, /*headMessage*/ undefined, intersectionState)) { + else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, reportErrors && !(target.flags & source.flags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) { resetErrorInfo(saveErrorInfo); return result; } @@ -60055,17 +62190,10 @@ var ts; } } else if (source.flags & 134217728 /* TemplateLiteral */) { - if (target.flags & 134217728 /* TemplateLiteral */) { - if (source.texts.length === target.texts.length && - source.types.length === target.types.length && - ts.every(source.texts, function (t, i) { return t === target.texts[i]; }) && - ts.every(instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)).types, function (t, i) { return !!(target.types[i].flags & (1 /* Any */ | 4 /* String */)) || !!isRelatedTo(t, target.types[i], /*reportErrors*/ false); })) { - return -1 /* True */; - } - } - else { - var constraint = getBaseConstraintOfType(source); - if (result = isRelatedTo(constraint && constraint !== source ? constraint : stringType, target, reportErrors)) { + if (!(target.flags & 134217728 /* TemplateLiteral */)) { + var baseConstraint = getBaseConstraintOfType(source); + var constraint = baseConstraint && baseConstraint !== source ? baseConstraint : stringType; + if (result = isRelatedTo(constraint, target, reportErrors)) { resetErrorInfo(saveErrorInfo); return result; } @@ -60097,7 +62225,7 @@ var ts; 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 */, isRelatedTo); - inferTypes(ctx.inferences, target.extendsType, sourceExtends, 256 /* NoConstraints */ | 512 /* AlwaysStrict */); + inferTypes(ctx.inferences, target.extendsType, sourceExtends, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */); sourceExtends = instantiateType(sourceExtends, ctx.mapper); mapper = ctx.mapper; } @@ -60155,7 +62283,7 @@ var ts; return 0 /* False */; } if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && source.target === target.target && - !(ts.getObjectFlags(source) & 8192 /* MarkerType */ || ts.getObjectFlags(target) & 8192 /* MarkerType */)) { + !(ts.getObjectFlags(source) & 4096 /* MarkerType */ || ts.getObjectFlags(target) & 4096 /* MarkerType */)) { // 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 // information for the type parameters and relate the type arguments accordingly. @@ -60183,7 +62311,7 @@ var ts; } // 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) & 32768 /* FreshLiteral */ && !isEmptyObjectType(source)) { + else if ((relation === subtypeRelation || relation === strictSubtypeRelation) && isEmptyObjectType(target) && ts.getObjectFlags(target) & 16384 /* FreshLiteral */ && !isEmptyObjectType(source)) { return 0 /* False */; } // Even if relationship doesn't hold for unions, intersections, or generic type references, @@ -60221,14 +62349,19 @@ var ts; if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */) && target.flags & 1048576 /* Union */) { var objectOnlyTarget = extractTypesOfKind(target, 524288 /* Object */ | 2097152 /* Intersection */ | 33554432 /* Substitution */); if (objectOnlyTarget.flags & 1048576 /* Union */) { - var result_9 = typeRelatedToDiscriminatedType(source, objectOnlyTarget); - if (result_9) { - return result_9; + var result_10 = typeRelatedToDiscriminatedType(source, objectOnlyTarget); + if (result_10) { + return result_10; } } } } return 0 /* False */; + function countMessageChainBreadth(info) { + if (!info) + return 0; + return ts.reduceLeft(info, function (value, chain) { return value + 1 + countMessageChainBreadth(chain.next); }, 0); + } function relateVariances(sourceTypeArguments, targetTypeArguments, variances, intersectionState) { if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors, intersectionState)) { return result; @@ -60290,13 +62423,13 @@ var ts; var modifiersRelated = relation === comparableRelation || (relation === identityRelation ? getMappedTypeModifiers(source) === getMappedTypeModifiers(target) : getCombinedMappedTypeOptionality(source) <= getCombinedMappedTypeOptionality(target)); if (modifiersRelated) { - var result_10; + var result_11; var targetConstraint = getConstraintTypeFromMappedType(target); var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), makeFunctionTypeMapper(getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMarkers : reportUnreliableMarkers)); - if (result_10 = isRelatedTo(targetConstraint, sourceConstraint, reportErrors)) { + if (result_11 = isRelatedTo(targetConstraint, sourceConstraint, 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), reportErrors); + return result_11 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), reportErrors); } } } @@ -60324,10 +62457,10 @@ var ts; var numCombinations = 1; for (var _i = 0, sourcePropertiesFiltered_1 = sourcePropertiesFiltered; _i < sourcePropertiesFiltered_1.length; _i++) { var sourceProperty = sourcePropertiesFiltered_1[_i]; - numCombinations *= countTypes(getTypeOfSymbol(sourceProperty)); + numCombinations *= countTypes(getNonMissingTypeOfSymbol(sourceProperty)); if (numCombinations > 25) { // We've reached the complexity limit. - ts.tracing.instant("checkTypes" /* CheckTypes */, "typeRelatedToDiscriminatedType_DepthLimit", { sourceId: source.id, targetId: target.id, numCombinations: numCombinations }); + 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 */; } } @@ -60336,7 +62469,7 @@ var ts; var excludedProperties = new ts.Set(); for (var i = 0; i < sourcePropertiesFiltered.length; i++) { var sourceProperty = sourcePropertiesFiltered[i]; - var sourcePropertyType = getTypeOfSymbol(sourceProperty); + var sourcePropertyType = getNonMissingTypeOfSymbol(sourceProperty); sourceDiscriminantTypes[i] = sourcePropertyType.flags & 1048576 /* Union */ ? sourcePropertyType.types : [sourcePropertyType]; @@ -60366,8 +62499,8 @@ var ts; } }; for (var i = 0; i < sourcePropertiesFiltered.length; i++) { - var state_6 = _loop_18(i); - switch (state_6) { + var state_7 = _loop_18(i); + switch (state_7) { case "continue-outer": continue outer; } } @@ -60380,9 +62513,9 @@ var ts; }; for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) { var combination = discriminantCombinations_1[_a]; - var state_5 = _loop_17(combination); - if (typeof state_5 === "object") - return state_5.value; + var state_6 = _loop_17(combination); + if (typeof state_6 === "object") + return state_6.value; } // Compare the remaining non-discriminant properties of each match. var result = -1 /* True */; @@ -60429,46 +62562,9 @@ var ts; } function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState) { var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* Partial */); - var source = getTypeOfSourceProperty(sourceProp); - if (ts.getCheckFlags(targetProp) & 65536 /* DeferredType */ && !getSymbolLinks(targetProp).type) { - // Rather than resolving (and normalizing) the type, relate constituent-by-constituent without performing normalization or seconadary passes - var links = getSymbolLinks(targetProp); - ts.Debug.assertIsDefined(links.deferralParent); - ts.Debug.assertIsDefined(links.deferralConstituents); - var unionParent = !!(links.deferralParent.flags & 1048576 /* Union */); - var result_11 = unionParent ? 0 /* False */ : -1 /* True */; - var targetTypes = links.deferralConstituents; - for (var _i = 0, targetTypes_3 = targetTypes; _i < targetTypes_3.length; _i++) { - var targetType = targetTypes_3[_i]; - var related = isRelatedTo(source, targetType, /*reportErrors*/ false, /*headMessage*/ undefined, unionParent ? 0 : 2 /* Target */); - if (!unionParent) { - if (!related) { - // Can't assign to a target individually - have to fallback to assigning to the _whole_ intersection (which forces normalization) - return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); - } - result_11 &= related; - } - else { - if (related) { - return related; - } - } - } - if (unionParent && !result_11 && targetIsOptional) { - result_11 = isRelatedTo(source, undefinedType); - } - if (unionParent && !result_11 && reportErrors) { - // The easiest way to get the right errors here is to un-defer (which may be costly) - // If it turns out this is too costly too often, we can replicate the error handling logic within - // typeRelatedToSomeType without the discriminatable type branch (as that requires a manifest union - // type on which to hand discriminable properties, which we are expressly trying to avoid here) - return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); - } - return result_11; - } - else { - return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors, /*headMessage*/ undefined, intersectionState); - } + var effectiveTarget = addOptionality(getNonMissingTypeOfSymbol(targetProp), /*isProperty*/ false, targetIsOptional); + var effectiveSource = getTypeOfSourceProperty(sourceProp); + return isRelatedTo(effectiveSource, effectiveTarget, reportErrors, /*headMessage*/ undefined, intersectionState); } function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState, skipOptional) { var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp); @@ -60597,7 +62693,7 @@ var ts; } return 0 /* False */; } - if (!targetRestFlag && sourceRestFlag) { + if (!targetRestFlag && (sourceRestFlag || targetArity < sourceArity)) { if (reportErrors) { if (sourceMinLength < targetMinLength) { reportError(ts.Diagnostics.Target_requires_0_element_s_but_source_may_have_fewer, targetMinLength); @@ -60645,10 +62741,11 @@ var ts; } } var sourceType = !isTupleType(source) ? sourceTypeArguments[0] : - i < startCount || i >= targetArity - endCount ? sourceTypeArguments[sourceIndex] : + i < startCount || i >= targetArity - endCount ? removeMissingType(sourceTypeArguments[sourceIndex], !!(sourceFlags & targetFlags & 2 /* Optional */)) : getElementTypeOfSliceOfTupleType(source, startCount, endCount) || neverType; var targetType = targetTypeArguments[i]; - var targetCheckType = sourceFlags & 8 /* Variadic */ && targetFlags & 4 /* Rest */ ? createArrayType(targetType) : targetType; + var targetCheckType = sourceFlags & 8 /* Variadic */ && targetFlags & 4 /* Rest */ ? createArrayType(targetType) : + removeMissingType(targetType, !!(targetFlags & 2 /* Optional */)); var related = isRelatedTo(sourceType, targetCheckType, reportErrors, /*headMessage*/ undefined, intersectionState); if (!related) { if (reportErrors) { @@ -60682,7 +62779,7 @@ var ts; var sourceProp = _a[_i]; if (!getPropertyOfObjectType(target, sourceProp.escapedName)) { var sourceType = getTypeOfSymbol(sourceProp); - if (!(sourceType === undefinedType || sourceType === undefinedWideningType || sourceType === optionalType)) { + if (!(sourceType.flags & 32768 /* Undefined */)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(sourceProp), typeToString(target)); } @@ -60701,7 +62798,7 @@ var ts; if (!(targetProp.flags & 4194304 /* Prototype */) && (!numericNamesOnly || isNumericLiteralName(name) || name === "length")) { var sourceProp = getPropertyOfType(source, name); if (sourceProp && sourceProp !== targetProp) { - var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, intersectionState, relation === comparableRelation); + var related = propertyRelatedTo(source, target, sourceProp, targetProp, getNonMissingTypeOfSymbol, reportErrors, intersectionState, relation === comparableRelation); if (!related) { return 0 /* False */; } @@ -60795,7 +62892,7 @@ var ts; 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) === 166 /* Constructor */ || ((_b = sourceSignature.declaration) === null || _b === void 0 ? void 0 : _b.kind) === 166 /* Constructor */)) { + (((_a = targetSignature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 168 /* Constructor */ || ((_b = sourceSignature.declaration) === null || _b === void 0 ? void 0 : _b.kind) === 168 /* Constructor */)) { var constructSignatureToString = function (signature) { return signatureToString(signature, /*enclosingDeclaration*/ undefined, 262144 /* WriteArrowStyleSignature */, kind); }; @@ -60903,10 +63000,17 @@ var ts; return indexTypesIdenticalTo(source, target, kind); } var targetType = getIndexTypeOfType(target, kind); - if (!targetType || targetType.flags & 1 /* Any */ && !sourceIsPrimitive) { - // Index signature of type any permits assignment from everything but primitives + if (!targetType) { return -1 /* True */; } + if (targetType.flags & 1 /* Any */ && !sourceIsPrimitive) { + // An index signature of type `any` permits assignment from everything but primitives, + // provided that there is also a `string` index signature of type `any`. + var stringIndexType = kind === 0 /* String */ ? targetType : getIndexTypeOfType(target, 0 /* String */); + if (stringIndexType && stringIndexType.flags & 1 /* Any */) { + return -1 /* True */; + } + } if (isGenericMappedType(source)) { // A generic mapped type { [P in K]: T } is related to a type with an index signature // { [x: string]: U }, and optionally with an index signature { [x: number]: V }, @@ -61061,7 +63165,7 @@ var ts; // type, and flag the result as a marker type reference. function getMarkerTypeReference(type, source, target) { var result = createTypeReference(type, ts.map(type.typeParameters, function (t) { return t === source ? target : t; })); - result.objectFlags |= 8192 /* MarkerType */; + result.objectFlags |= 4096 /* MarkerType */; return result; } function getAliasVariances(symbol) { @@ -61082,7 +63186,7 @@ var ts; if (typeParameters === void 0) { typeParameters = ts.emptyArray; } var variances = cache.variances; if (!variances) { - ts.tracing.push("checkTypes" /* CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: (_c = (_a = cache.id) !== null && _a !== void 0 ? _a : (_b = cache.declaredType) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : -1 }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: (_c = (_a = cache.id) !== null && _a !== void 0 ? _a : (_b = cache.declaredType) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : -1 }); // The emptyArray singleton is used to signal a recursive invocation. cache.variances = ts.emptyArray; variances = []; @@ -61121,7 +63225,7 @@ var ts; _loop_19(tp); } cache.variances = variances; - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } return variances; } @@ -61149,7 +63253,7 @@ var ts; return !!(ts.getObjectFlags(type) & 4 /* Reference */) && !type.node; } function isTypeReferenceWithGenericArguments(type) { - return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); + return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return !!(t.flags & 262144 /* TypeParameter */) || isTypeReferenceWithGenericArguments(t); }); } /** * getTypeReferenceId(A) returns "111=0-12=1" @@ -61235,8 +63339,8 @@ var ts; } // 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) { - return forEachProperty(prop, function (p) { return ts.getDeclarationModifierFlagsFromSymbol(p) & 16 /* Protected */ ? + function isClassDerivedFromDeclaringClasses(checkClass, prop, writing) { + return forEachProperty(prop, function (p) { return ts.getDeclarationModifierFlagsFromSymbol(p, writing) & 16 /* 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 @@ -61254,23 +63358,26 @@ var ts; function isDeeplyNestedType(type, stack, depth) { if (depth >= 5) { var identity_1 = getRecursionIdentity(type); - if (identity_1) { - var count = 0; - for (var i = 0; i < depth; i++) { - if (getRecursionIdentity(stack[i]) === identity_1) { - count++; - if (count >= 5) { - return true; - } + var count = 0; + for (var i = 0; i < depth; i++) { + if (getRecursionIdentity(stack[i]) === identity_1) { + count++; + if (count >= 5) { + return true; } } } } return false; } - // Types with constituents that could circularly reference the type have a recursion identity. The recursion - // identity is some object that is common to instantiations of the type with the same origin. + // The recursion identity of a type is an object identity that is shared among multiple instantiations of the type. + // We track recursion identities in order to identify deeply nested and possibly infinite type instantiations with + // the same origin. For example, when type parameters are in scope in an object type such as { x: T }, all + // instantiations of that type have the same recursion identity. The default recursion identity is the object + // identity of the type, meaning that every type is unique. Generally, types with constituents that could circularly + // 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) { // Deferred type references are tracked through their associated AST node. This gives us finer @@ -61288,6 +63395,9 @@ var ts; return type.target; } } + if (type.flags & 262144 /* TypeParameter */) { + return type.symbol; + } if (type.flags & 8388608 /* IndexedAccess */) { // Identity is the leftmost object type in a chain of indexed accesses, eg, in A[P][Q] it is A do { @@ -61299,7 +63409,7 @@ var ts; // The root object represents the origin of the conditional type return type.root; } - return undefined; + return type; } function isPropertyIdenticalTo(sourceProp, targetProp) { return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0 /* False */; @@ -61438,6 +63548,9 @@ var ts; // 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; }); @@ -61472,9 +63585,35 @@ var ts; // 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); } + function getSingleBaseForNonAugmentingSubtype(type) { + if (!(ts.getObjectFlags(type) & 4 /* Reference */) || !(ts.getObjectFlags(type.target) & 3 /* ClassOrInterface */)) { + return undefined; + } + if (ts.getObjectFlags(type) & 33554432 /* IdenticalBaseTypeCalculated */) { + return ts.getObjectFlags(type) & 67108864 /* IdenticalBaseTypeExists */ ? type.cachedEquivalentBaseType : undefined; + } + type.objectFlags |= 33554432 /* IdenticalBaseTypeCalculated */; + var target = type.target; + var bases = getBaseTypes(target); + if (bases.length !== 1) { + return undefined; + } + if (getMembersOfSymbol(type.symbol).size) { + return undefined; // If the interface has any members, they may subtype members in the base, so we should do a full structural comparison + } + var instantiatedBase = !ts.length(target.typeParameters) ? bases[0] : instantiateType(bases[0], createTypeMapper(target.typeParameters, getTypeArguments(type).slice(0, target.typeParameters.length))); + if (ts.length(getTypeArguments(type)) > ts.length(target.typeParameters)) { + instantiatedBase = getTypeWithThisArgument(instantiatedBase, ts.last(getTypeArguments(type))); + } + type.objectFlags |= 67108864 /* IdenticalBaseTypeExists */; + return type.cachedEquivalentBaseType = instantiatedBase; + } + function isEmptyLiteralType(type) { + return strictNullChecks ? type === implicitNeverType : type === undefinedWideningType; + } function isEmptyArrayLiteralType(type) { - var elementType = isArrayType(type) ? getTypeArguments(type)[0] : undefined; - return elementType === undefinedWideningType || elementType === implicitNeverType; + var elementType = getElementTypeOfArrayType(type); + return !!elementType && isEmptyLiteralType(elementType); } function isTupleLikeType(type) { return isTupleType(type) || !!getPropertyOfType(type, "0"); @@ -61498,6 +63637,13 @@ var ts; function isUnitType(type) { return !!(type.flags & 109440 /* Unit */); } + function isUnitLikeType(type) { + return type.flags & 2097152 /* Intersection */ ? ts.some(type.types, isUnitType) : + !!(type.flags & 109440 /* Unit */); + } + function extractUnitType(type) { + return type.flags & 2097152 /* 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) : @@ -61505,7 +63651,7 @@ var ts; } function getBaseTypeOfLiteralType(type) { return type.flags & 1024 /* EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : - type.flags & 134217856 /* StringLikeLiteral */ ? stringType : + type.flags & 128 /* StringLiteral */ ? stringType : type.flags & 256 /* NumberLiteral */ ? numberType : type.flags & 2048 /* BigIntLiteral */ ? bigintType : type.flags & 512 /* BooleanLiteral */ ? booleanType : @@ -61514,7 +63660,7 @@ var ts; } function getWidenedLiteralType(type) { return type.flags & 1024 /* EnumLiteral */ && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(type) : - type.flags & 134217856 /* StringLikeLiteral */ && isFreshLiteralType(type) ? stringType : + 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 : @@ -61643,19 +63789,23 @@ var ts; missing === 65536 /* Null */ ? getUnionType([type, nullType]) : getUnionType([type, undefinedType, nullType]); } - function getOptionalType(type) { + function getOptionalType(type, isProperty) { + if (isProperty === void 0) { isProperty = false; } ts.Debug.assert(strictNullChecks); - return type.flags & 32768 /* Undefined */ ? type : getUnionType([type, undefinedType]); + return type.flags & 32768 /* Undefined */ ? type : getUnionType([type, isProperty ? missingType : undefinedType]); } function getGlobalNonNullableTypeInstantiation(type) { + // First reduce away any constituents that are assignable to 'undefined' or 'null'. This not only eliminates + // 'undefined' and 'null', but also higher-order types such as a type parameter 'U extends undefined | null' + // that isn't eliminated by a NonNullable instantiation. + var reducedType = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); if (!deferredGlobalNonNullableTypeAlias) { deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288 /* TypeAlias */, /*diagnostic*/ undefined) || unknownSymbol; } - // Use NonNullable global type alias if available to improve quick info/declaration emit - if (deferredGlobalNonNullableTypeAlias !== unknownSymbol) { - return getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]); - } - return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); // Type alias unavailable, fall back to non-higher-order behavior + // If the NonNullable type is available, return an instantiation. Otherwise just return the reduced type. + return deferredGlobalNonNullableTypeAlias !== unknownSymbol ? + getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [reducedType]) : + reducedType; } function getNonNullableType(type) { return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type; @@ -61677,6 +63827,12 @@ var ts; ts.isOptionalChain(expression) ? removeOptionalTypeMarker(exprType) : exprType; } + function removeMissingType(type, isOptional) { + return strictOptionalProperties && isOptional ? filterType(type, function (t) { return t !== missingType; }) : type; + } + function containsMissingType(type) { + return strictOptionalProperties && (type === missingType || type.flags & 1048576 /* Union */ && containsType(type.types, missingType)); + } /** * Is source potentially coercible to target type under `==`. * Assumes that `source` is a constituent of a union, hence @@ -61708,7 +63864,7 @@ var ts; function isObjectTypeWithInferableIndex(type) { return type.flags & 2097152 /* Intersection */ ? ts.every(type.types, isObjectTypeWithInferableIndex) : !!(type.symbol && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 && - !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 2048 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); + !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 1024 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); } function createSymbolWithType(source, type) { var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */); @@ -61741,7 +63897,7 @@ var ts; * Leave signatures alone since they are not subject to the check. */ function getRegularTypeOfObjectLiteral(type) { - if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 32768 /* FreshLiteral */)) { + if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 16384 /* FreshLiteral */)) { return type; } var regularType = type.regularType; @@ -61752,7 +63908,7 @@ var ts; var members = transformTypeOfMembers(type, getRegularTypeOfObjectLiteral); var regularNew = createAnonymousType(resolved.symbol, members, resolved.callSignatures, resolved.constructSignatures, resolved.stringIndexInfo, resolved.numberIndexInfo); regularNew.flags = resolved.flags; - regularNew.objectFlags |= resolved.objectFlags & ~32768 /* FreshLiteral */; + regularNew.objectFlags |= resolved.objectFlags & ~16384 /* FreshLiteral */; type.regularType = regularNew; return regularNew; } @@ -61782,7 +63938,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) & 1024 /* ContainsSpread */)) { + if (isObjectLiteralType(t) && !(ts.getObjectFlags(t) & 4194304 /* ContainsSpread */)) { for (var _b = 0, _c = getPropertiesOfType(t); _b < _c.length; _b++) { var prop = _c[_b]; names.set(prop.escapedName, prop); @@ -61809,7 +63965,7 @@ var ts; if (cached) { return cached; } - var result = createSymbolWithType(prop, undefinedType); + var result = createSymbolWithType(prop, missingType); result.flags |= 16777216 /* Optional */; undefinedProperties.set(prop.escapedName, result); return result; @@ -61831,14 +63987,14 @@ var ts; var stringIndexInfo = getIndexInfoOfType(type, 0 /* String */); var numberIndexInfo = getIndexInfoOfType(type, 1 /* Number */); var result = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, stringIndexInfo && createIndexInfo(getWidenedType(stringIndexInfo.type), stringIndexInfo.isReadonly), numberIndexInfo && createIndexInfo(getWidenedType(numberIndexInfo.type), numberIndexInfo.isReadonly)); - result.objectFlags |= (ts.getObjectFlags(type) & (16384 /* JSLiteral */ | 2097152 /* NonInferrableType */)); // Retain js literal flag through widening + result.objectFlags |= (ts.getObjectFlags(type) & (8192 /* JSLiteral */ | 524288 /* 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) & 1572864 /* RequiresWidening */) { + if (ts.getObjectFlags(type) & 393216 /* RequiresWidening */) { if (context === undefined && type.widened) { return type.widened; } @@ -61883,7 +64039,7 @@ var ts; */ function reportWideningErrorsInType(type) { var errorReported = false; - if (ts.getObjectFlags(type) & 524288 /* ContainsWideningType */) { + if (ts.getObjectFlags(type) & 131072 /* ContainsWideningType */) { if (type.flags & 1048576 /* Union */) { if (ts.some(type.types, isEmptyObjectType)) { errorReported = true; @@ -61909,7 +64065,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) & 524288 /* ContainsWideningType */) { + if (ts.getObjectFlags(t) & 131072 /* ContainsWideningType */) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, symbolToString(p), typeToString(getWidenedType(t))); } @@ -61928,12 +64084,12 @@ var ts; } var diagnostic; switch (declaration.kind) { - case 216 /* BinaryExpression */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 218 /* BinaryExpression */: + case 165 /* PropertyDeclaration */: + case 164 /* 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 160 /* Parameter */: + case 162 /* Parameter */: var param = declaration; if (ts.isIdentifier(param.name) && (ts.isCallSignatureDeclaration(param.parent) || ts.isMethodSignature(param.parent) || ts.isFunctionTypeNode(param.parent)) && @@ -61948,23 +64104,23 @@ 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 198 /* BindingElement */: + case 200 /* 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 308 /* JSDocFunctionType */: + case 311 /* JSDocFunctionType */: error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; - case 251 /* FunctionDeclaration */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 253 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: if (noImplicitAny && !declaration.name) { if (wideningKind === 3 /* 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); @@ -61978,7 +64134,7 @@ var ts; wideningKind === 3 /* 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 190 /* MappedType */: + case 192 /* MappedType */: if (noImplicitAny) { error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); } @@ -61989,7 +64145,7 @@ var ts; errorOrSuggestion(noImplicitAny, declaration, diagnostic, ts.declarationNameToString(ts.getNameOfDeclaration(declaration)), typeAsString); } function reportErrorsFromWidening(declaration, type, wideningKind) { - if (produceDiagnostics && noImplicitAny && ts.getObjectFlags(type) & 524288 /* ContainsWideningType */ && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) { + if (produceDiagnostics && noImplicitAny && ts.getObjectFlags(type) & 131072 /* ContainsWideningType */ && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) { // Report implicit any error within type if possible, otherwise report error on declaration if (!reportWideningErrorsInType(type)) { reportImplicitAny(declaration, type, wideningKind); @@ -62105,23 +64261,23 @@ var ts; // results for union and intersection types for performance reasons. function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); - if (objectFlags & 67108864 /* CouldContainTypeVariablesComputed */) { - return !!(objectFlags & 134217728 /* CouldContainTypeVariables */); + if (objectFlags & 1048576 /* CouldContainTypeVariablesComputed */) { + return !!(objectFlags & 2097152 /* 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 */ | 131072 /* ObjectRestType */)) || + objectFlags & (32 /* Mapped */ | 1024 /* ReverseMapped */ | 8388608 /* ObjectRestType */)) || type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && !isNonGenericTopLevelType(type) && ts.some(type.types, couldContainTypeVariables)); if (type.flags & 3899393 /* ObjectFlagsType */) { - type.objectFlags |= 67108864 /* CouldContainTypeVariablesComputed */ | (result ? 134217728 /* CouldContainTypeVariables */ : 0); + type.objectFlags |= 1048576 /* CouldContainTypeVariablesComputed */ | (result ? 2097152 /* CouldContainTypeVariables */ : 0); } return result; } function isNonGenericTopLevelType(type) { if (type.aliasSymbol && !type.aliasTypeArguments) { - var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 254 /* TypeAliasDeclaration */); - return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 297 /* SourceFile */ ? true : n.kind === 256 /* ModuleDeclaration */ ? false : "quit"; })); + var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 256 /* TypeAliasDeclaration */); + return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 299 /* SourceFile */ ? true : n.kind === 258 /* ModuleDeclaration */ ? false : "quit"; })); } return false; } @@ -62174,7 +64330,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) & 2097152 /* NonInferrableType */) || + return !(ts.getObjectFlags(type) & 524288 /* NonInferrableType */) || isObjectLiteralType(type) && ts.some(getPropertiesOfType(type), function (prop) { return isPartiallyInferableType(getTypeOfSymbol(prop)); }) || isTupleType(type) && ts.some(getTypeArguments(type), isPartiallyInferableType); } @@ -62198,14 +64354,18 @@ var ts; } // 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(2048 /* ReverseMapped */ | 16 /* Anonymous */, /*symbol*/ undefined); + var reversed = createObjectType(1024 /* ReverseMapped */ | 16 /* Anonymous */, /*symbol*/ undefined); reversed.source = source; reversed.mappedType = target; reversed.constraintType = constraint; return reversed; } function getTypeOfReverseMappedSymbol(symbol) { - return inferReverseMappedType(symbol.propertyType, symbol.mappedType, symbol.constraintType); + var links = getSymbolLinks(symbol); + if (!links.type) { + links.type = inferReverseMappedType(symbol.propertyType, symbol.mappedType, symbol.constraintType); + } + return links.type; } function inferReverseMappedType(sourceType, target, constraint) { var typeParameter = getIndexedAccessType(constraint.type, getTypeParameterFromMappedType(target)); @@ -62297,51 +64457,113 @@ var ts; // * 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 */); } - function isStringLiteralTypeValueParsableAsType(s, target) { - if (target.flags & 1048576 /* Union */) { - return !!forEachType(target, function (t) { return isStringLiteralTypeValueParsableAsType(s, t); }); - } - switch (target) { - case stringType: return true; - case numberType: return s.value !== "" && isFinite(+(s.value)); - case bigintType: return s.value !== "" && isValidBigIntString(s.value); - // the next 4 should be handled in `getTemplateLiteralType`, as they are all exactly one value, but are here for completeness, just in case - // this function is ever used on types which don't come from template literal holes - case trueType: return s.value === "true"; - case falseType: return s.value === "false"; - case undefinedType: return s.value === "undefined"; - case nullType: return s.value === "null"; - default: return !!(target.flags & 1 /* Any */); - } - } - function inferLiteralsFromTemplateLiteralType(source, target) { - var value = source.value; - var texts = target.texts; - var lastIndex = texts.length - 1; - var startText = texts[0]; - var endText = texts[lastIndex]; - if (!(value.startsWith(startText) && value.slice(startText.length).endsWith(endText))) + function isValidTypeForTemplateLiteralPlaceholder(source, target) { + if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) { + return true; + } + if (source.flags & 128 /* StringLiteral */) { + var value = source.value; + return !!(target.flags & 8 /* Number */ && value !== "" && isFinite(+value) || + target.flags & 64 /* BigInt */ && value !== "" && isValidBigIntString(value) || + target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName); + } + if (source.flags & 134217728 /* 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 */ ? + ts.arraysEqual(source.texts, target.texts) ? ts.map(source.types, getStringLikeTypeForType) : + inferFromLiteralPartsToTemplateLiteral(source.texts, source.types, target) : + undefined; + } + function getStringLikeTypeForType(type) { + return type.flags & (1 /* Any */ | 402653316 /* 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 + // with one text part and zero type parts. The function returns an array of inferred string or template literal types + // corresponding to the placeholders in the target template literal, or undefined if the source doesn't match the target. + // + // We first check that the starting source text part matches the starting target text part, and that the ending source + // text part ends matches the ending target text part. We then iterate through the remaining target text parts, finding + // a match for each in the source and inferring string or template literal types created from the segments of the source + // that occur between the matches. During this iteration, seg holds the index of the current text part in the sourceTexts + // array and pos holds the current character position in the current text part. + // + // Consider inference from type `<<${string}>.<${number}-${number}>>` to type `<${string}.${string}>`, i.e. + // sourceTexts = ['<<', '>.<', '-', '>>'] + // sourceTypes = [string, number, number] + // target.texts = ['<', '.', '>'] + // We first match '<' in the target to the start of '<<' in the source and '>' in the target to the end of '>>' in + // the source. The first match for the '.' in target occurs at character 1 in the source text part at index 1, and thus + // the first inference is the template literal type `<${string}>`. The remainder of the source makes up the second + // inference, the template literal type `<${number}-${number}>`. + function inferFromLiteralPartsToTemplateLiteral(sourceTexts, sourceTypes, target) { + var lastSourceIndex = sourceTexts.length - 1; + var sourceStartText = sourceTexts[0]; + var sourceEndText = sourceTexts[lastSourceIndex]; + var targetTexts = target.texts; + var lastTargetIndex = targetTexts.length - 1; + var targetStartText = targetTexts[0]; + var targetEndText = targetTexts[lastTargetIndex]; + if (lastSourceIndex === 0 && sourceStartText.length < targetStartText.length + targetEndText.length || + !sourceStartText.startsWith(targetStartText) || !sourceEndText.endsWith(targetEndText)) return undefined; + var remainingEndText = sourceEndText.slice(0, sourceEndText.length - targetEndText.length); var matches = []; - var str = value.slice(startText.length, value.length - endText.length); - var pos = 0; - for (var i = 1; i < lastIndex; i++) { - var delim = texts[i]; - var delimPos = delim.length > 0 ? str.indexOf(delim, pos) : pos < str.length ? pos + 1 : -1; - if (delimPos < 0) + var seg = 0; + var pos = targetStartText.length; + for (var i = 1; i < lastTargetIndex; i++) { + var delim = targetTexts[i]; + if (delim.length > 0) { + var s = seg; + var p = pos; + while (true) { + p = getSourceText(s).indexOf(delim, p); + if (p >= 0) + break; + s++; + if (s === sourceTexts.length) + return undefined; + p = 0; + } + addMatch(s, p); + pos += delim.length; + } + else if (pos < getSourceText(seg).length) { + addMatch(seg, pos + 1); + } + else if (seg < lastSourceIndex) { + addMatch(seg + 1, 0); + } + else { return undefined; - matches.push(getLiteralType(str.slice(pos, delimPos))); - pos = delimPos + delim.length; + } } - matches.push(getLiteralType(str.slice(pos))); + addMatch(lastSourceIndex, getSourceText(lastSourceIndex).length); return matches; + function getSourceText(index) { + return index < lastSourceIndex ? sourceTexts[index] : remainingEndText; + } + function addMatch(s, p) { + var matchType = s === seg ? + getLiteralType(getSourceText(s).slice(pos, p)) : + getTemplateLiteralType(__spreadArray(__spreadArray([sourceTexts[seg].slice(pos)], sourceTexts.slice(seg + 1, s)), [getSourceText(s).slice(0, p)]), sourceTypes.slice(seg, s)); + matches.push(matchType); + seg = s; + pos = p; + } } function inferTypes(inferences, originalSource, originalTarget, priority, contravariant) { if (priority === void 0) { priority = 0; } if (contravariant === void 0) { contravariant = false; } var bivariant = false; var propagationType; - var inferencePriority = 1024 /* MaxValue */; + var inferencePriority = 2048 /* MaxValue */; var allowComplexConstraintInference = true; var visited; var sourceStack; @@ -62428,8 +64650,8 @@ var ts; // 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 (ts.getObjectFlags(source) & 2097152 /* NonInferrableType */ || source === nonInferrableAnyType || source === silentNeverType || - (priority & 64 /* ReturnType */ && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) { + if (ts.getObjectFlags(source) & 524288 /* NonInferrableType */ || source === nonInferrableAnyType || source === silentNeverType || + (priority & 128 /* ReturnType */ && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) { return; } var inference = getInferenceInfoForType(target); @@ -62456,7 +64678,7 @@ var ts; clearCachedInferences(inferences); } } - if (!(priority & 64 /* ReturnType */) && target.flags & 262144 /* TypeParameter */ && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) { + if (!(priority & 128 /* ReturnType */) && target.flags & 262144 /* TypeParameter */ && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) { inference.topLevel = false; clearCachedInferences(inferences); } @@ -62496,7 +64718,7 @@ var ts; else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 4194304 /* Index */) { var empty = createEmptyObjectTypeFromStringLiteral(source); contravariant = !contravariant; - inferWithPriority(empty, target.type, 128 /* LiteralKeyof */); + inferWithPriority(empty, target.type, 256 /* LiteralKeyof */); contravariant = !contravariant; } else if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) { @@ -62508,6 +64730,13 @@ var ts; inferFromTypes(source.type, target.type); } } + else if (source.flags & 33554432 /* Substitution */) { + inferFromTypes(source.baseType, target); + var oldPriority = priority; + priority |= 4 /* SubstituteSource */; + inferFromTypes(source.substitute, target); // Make substitute inference at a lower priority + priority = oldPriority; + } else if (target.flags & 16777216 /* Conditional */) { invokeOnce(source, target, inferToConditionalType); } @@ -62527,7 +64756,7 @@ var ts; } else { source = getReducedType(source); - if (!(priority & 256 /* NoConstraints */ && source.flags & (2097152 /* Intersection */ | 465829888 /* Instantiable */))) { + if (!(priority & 512 /* NoConstraints */ && source.flags & (2097152 /* Intersection */ | 465829888 /* 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` @@ -62565,26 +64794,22 @@ var ts; } (visited || (visited = new ts.Map())).set(key, -1 /* Circularity */); var saveInferencePriority = inferencePriority; - inferencePriority = 1024 /* MaxValue */; + inferencePriority = 2048 /* 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) || source; - var targetIdentity = getRecursionIdentity(target) || target; - if (sourceIdentity && ts.contains(sourceStack, sourceIdentity)) + var sourceIdentity = getRecursionIdentity(source); + var targetIdentity = getRecursionIdentity(target); + if (ts.contains(sourceStack, sourceIdentity)) expandingFlags |= 1 /* Source */; - if (targetIdentity && ts.contains(targetStack, targetIdentity)) + if (ts.contains(targetStack, targetIdentity)) expandingFlags |= 2 /* Target */; if (expandingFlags !== 3 /* Both */) { - if (sourceIdentity) - (sourceStack || (sourceStack = [])).push(sourceIdentity); - if (targetIdentity) - (targetStack || (targetStack = [])).push(targetIdentity); + (sourceStack || (sourceStack = [])).push(sourceIdentity); + (targetStack || (targetStack = [])).push(targetIdentity); action(source, target); - if (targetIdentity) - targetStack.pop(); - if (sourceIdentity) - sourceStack.pop(); + targetStack.pop(); + sourceStack.pop(); } else { inferencePriority = -1 /* Circularity */; @@ -62624,7 +64849,7 @@ var ts; } } function inferFromContravariantTypes(source, target) { - if (strictFunctionTypes || priority & 512 /* AlwaysStrict */) { + if (strictFunctionTypes || priority & 1024 /* AlwaysStrict */) { contravariant = !contravariant; inferFromTypes(source, target); contravariant = !contravariant; @@ -62676,7 +64901,7 @@ var ts; else { for (var i = 0; i < sources.length; i++) { var saveInferencePriority = inferencePriority; - inferencePriority = 1024 /* MaxValue */; + inferencePriority = 2048 /* MaxValue */; inferFromTypes(sources[i], t); if (inferencePriority === priority) matched_1[i] = true; @@ -62755,9 +64980,9 @@ 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) & 2097152 /* NonInferrableType */ ? - 8 /* PartialHomomorphicMappedType */ : - 4 /* HomomorphicMappedType */); + inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 524288 /* NonInferrableType */ ? + 16 /* PartialHomomorphicMappedType */ : + 8 /* HomomorphicMappedType */); } } return true; @@ -62765,7 +64990,7 @@ var ts; if (constraintType.flags & 262144 /* 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, 16 /* MappedTypeConstraint */); + inferWithPriority(getIndexType(source), constraintType, 32 /* 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 @@ -62794,16 +65019,14 @@ var ts; } else { var savePriority = priority; - priority |= contravariant ? 32 /* ContravariantConditional */ : 0; + priority |= contravariant ? 64 /* ContravariantConditional */ : 0; var targetTypes = [getTrueTypeFromConditionalType(target), getFalseTypeFromConditionalType(target)]; inferToMultipleTypes(source, targetTypes, target.flags); priority = savePriority; } } function inferToTemplateLiteralType(source, target) { - var matches = source.flags & 128 /* StringLiteral */ ? inferLiteralsFromTemplateLiteralType(source, target) : - source.flags & 134217728 /* TemplateLiteral */ && ts.arraysEqual(source.texts, target.texts) ? source.types : - undefined; + var matches = inferTypesFromTemplateLiteralType(source, target); var types = target.types; for (var i = 0; i < types.length; i++) { inferFromTypes(matches ? matches[i] : neverType, types[i]); @@ -62919,7 +65142,7 @@ var ts; var sourceLen = sourceSignatures.length; var targetLen = targetSignatures.length; var len = sourceLen < targetLen ? sourceLen : targetLen; - var skipParameters = !!(ts.getObjectFlags(source) & 2097152 /* NonInferrableType */); + var skipParameters = !!(ts.getObjectFlags(source) & 524288 /* NonInferrableType */); for (var i = 0; i < len; i++) { inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i]), skipParameters); } @@ -62929,19 +65152,21 @@ var ts; 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 === 165 /* MethodDeclaration */ || kind === 164 /* MethodSignature */ || kind === 166 /* Constructor */; + bivariant = bivariant || kind === 167 /* MethodDeclaration */ || kind === 166 /* MethodSignature */ || kind === 168 /* Constructor */; applyToParameterTypes(source, target, inferFromContravariantTypes); 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 targetStringIndexType = getIndexTypeOfType(target, 0 /* String */); if (targetStringIndexType) { var sourceIndexType = getIndexTypeOfType(source, 0 /* String */) || getImplicitIndexTypeOfType(source, 0 /* String */); if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetStringIndexType); + inferWithPriority(sourceIndexType, targetStringIndexType, priority); } } var targetNumberIndexType = getIndexTypeOfType(target, 1 /* Number */); @@ -62950,13 +65175,13 @@ var ts; getIndexTypeOfType(source, 0 /* String */) || getImplicitIndexTypeOfType(source, 1 /* Number */); if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetNumberIndexType); + inferWithPriority(sourceIndexType, targetNumberIndexType, priority); } } } } function isTypeOrBaseIdenticalTo(s, t) { - return isTypeIdenticalTo(s, t) || !!(t.flags & 4 /* String */ && s.flags & 134217856 /* StringLikeLiteral */ || t.flags & 8 /* Number */ && s.flags & 256 /* NumberLiteral */); + return isTypeIdenticalTo(s, t) || !!(t.flags & 4 /* String */ && s.flags & 128 /* StringLiteral */ || t.flags & 8 /* Number */ && s.flags & 256 /* NumberLiteral */); } function isTypeCloselyMatchedBy(s, t) { return !!(s.flags & 524288 /* Object */ && t.flags & 524288 /* Object */ && s.symbol && s.symbol === t.symbol || @@ -62970,7 +65195,7 @@ var ts; return !!(ts.getObjectFlags(type) & 128 /* ObjectLiteral */); } function isObjectOrArrayLiteralType(type) { - return !!(ts.getObjectFlags(type) & (128 /* ObjectLiteral */ | 65536 /* ArrayLiteral */)); + return !!(ts.getObjectFlags(type) & (128 /* ObjectLiteral */ | 32768 /* ArrayLiteral */)); } function unionObjectAndArrayLiteralCandidates(candidates) { if (candidates.length > 1) { @@ -62983,7 +65208,7 @@ var ts; return candidates; } function getContravariantInference(inference) { - return inference.priority & 208 /* PriorityImpliesCombination */ ? getIntersectionType(inference.contraCandidates) : getCommonSubtype(inference.contraCandidates); + return inference.priority & 416 /* 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. @@ -63000,7 +65225,7 @@ 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 & 208 /* PriorityImpliesCombination */ ? + var unwidenedType = inference.priority & 416 /* PriorityImpliesCombination */ ? getUnionType(baseCandidates, 2 /* Subtype */) : getCommonSupertype(baseCandidates); return getWidenedType(unwidenedType); @@ -63109,7 +65334,7 @@ var ts; case "BigUint64Array": return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_1_or_later; default: - if (node.parent.kind === 289 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 291 /* ShorthandPropertyAssignment */) { return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer; } else { @@ -63130,26 +65355,27 @@ 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 === 176 /* TypeQuery */ ? true : n.kind === 78 /* Identifier */ || n.kind === 157 /* QualifiedName */ ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 178 /* TypeQuery */ ? true : n.kind === 79 /* Identifier */ || n.kind === 159 /* 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 // leftmost identifier followed by zero or more property names separated by dots. - // The result is undefined if the reference isn't a dotted name. We prefix nodes - // occurring in an apparent type position with '@' because the control flow type - // of such nodes may be based on the apparent type instead of the declared type. + // The result is undefined if the reference isn't a dotted name. function getFlowCacheKey(node, declaredType, initialType, flowContainer) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: var symbol = getResolvedSymbol(node); - return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + (isConstraintPosition(node) ? "@" : "") + getSymbolId(symbol) : undefined; - case 107 /* ThisKeyword */: + return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + getSymbolId(symbol) : undefined; + case 108 /* ThisKeyword */: return "0|" + (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType); - case 225 /* NonNullExpression */: - case 207 /* ParenthesizedExpression */: + case 227 /* NonNullExpression */: + case 209 /* ParenthesizedExpression */: return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 159 /* QualifiedName */: + var left = getFlowCacheKey(node.left, declaredType, initialType, flowContainer); + return left && left + "." + node.right.escapedText; + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: var propName = getAccessedPropertyName(node); if (propName !== undefined) { var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); @@ -63160,32 +65386,40 @@ var ts; } function isMatchingReference(source, target) { switch (target.kind) { - case 207 /* ParenthesizedExpression */: - case 225 /* NonNullExpression */: + case 209 /* ParenthesizedExpression */: + case 227 /* NonNullExpression */: return isMatchingReference(source, target.expression); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return (ts.isAssignmentExpression(target) && isMatchingReference(source, target.left)) || (ts.isBinaryExpression(target) && target.operatorToken.kind === 27 /* CommaToken */ && isMatchingReference(source, target.right)); } switch (source.kind) { - case 78 /* Identifier */: - case 79 /* PrivateIdentifier */: - return target.kind === 78 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 249 /* VariableDeclaration */ || target.kind === 198 /* BindingElement */) && + case 228 /* MetaProperty */: + return target.kind === 228 /* MetaProperty */ + && source.keywordToken === target.keywordToken + && source.name.escapedText === target.name.escapedText; + case 79 /* Identifier */: + case 80 /* PrivateIdentifier */: + return target.kind === 79 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 251 /* VariableDeclaration */ || target.kind === 200 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 107 /* ThisKeyword */: - return target.kind === 107 /* ThisKeyword */; - case 105 /* SuperKeyword */: - return target.kind === 105 /* SuperKeyword */; - case 225 /* NonNullExpression */: - case 207 /* ParenthesizedExpression */: + case 108 /* ThisKeyword */: + return target.kind === 108 /* ThisKeyword */; + case 106 /* SuperKeyword */: + return target.kind === 106 /* SuperKeyword */; + case 227 /* NonNullExpression */: + case 209 /* ParenthesizedExpression */: return isMatchingReference(source.expression, target); - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: return ts.isAccessExpression(target) && getAccessedPropertyName(source) === getAccessedPropertyName(target) && isMatchingReference(source.expression, target.expression); - case 216 /* BinaryExpression */: + case 159 /* QualifiedName */: + return ts.isAccessExpression(target) && + source.right.escapedText === getAccessedPropertyName(target) && + isMatchingReference(source.left, target.expression); + case 218 /* BinaryExpression */: return (ts.isBinaryExpression(source) && source.operatorToken.kind === 27 /* CommaToken */ && isMatchingReference(source.right, target)); } return false; @@ -63193,11 +65427,11 @@ var ts; // Given a source x, check if target matches x or is an && operation with an operand that matches x. function containsTruthyCheck(source, target) { return isMatchingReference(source, target) || - (target.kind === 216 /* BinaryExpression */ && target.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && + (target.kind === 218 /* BinaryExpression */ && target.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && (containsTruthyCheck(source, target.left) || containsTruthyCheck(source, target.right))); } function getAccessedPropertyName(access) { - return access.kind === 201 /* PropertyAccessExpression */ ? access.name.escapedText : + return access.kind === 203 /* PropertyAccessExpression */ ? access.name.escapedText : ts.isStringOrNumericLiteralLike(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) : undefined; } @@ -63247,6 +65481,86 @@ var ts; } return result; } + // Given a set of constituent types and a property name, create and return a map keyed by the literal + // types of the property by that name in each constituent type. No map is returned if some key property + // has a non-literal type or if less than 10 or less than 50% of the constituents have a unique key. + // Entries with duplicate keys have unknownType as the value. + function mapTypesByKeyProperty(types, name) { + var map = new ts.Map(); + var count = 0; + var _loop_20 = function (type) { + if (type.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) { + var discriminant = getTypeOfPropertyOfType(type, name); + if (discriminant) { + if (!isLiteralType(discriminant)) { + return { value: undefined }; + } + var duplicate_1 = false; + forEachType(discriminant, function (t) { + var id = getTypeId(getRegularTypeOfLiteralType(t)); + var existing = map.get(id); + if (!existing) { + map.set(id, type); + } + else if (existing !== unknownType) { + map.set(id, unknownType); + duplicate_1 = true; + } + }); + if (!duplicate_1) + count++; + } + } + }; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var type = types_17[_i]; + var state_8 = _loop_20(type); + if (typeof state_8 === "object") + return state_8.value; + } + return count >= 10 && count * 2 >= types.length ? map : undefined; + } + // Return the name of a discriminant property for which it was possible and feasible to construct a map of + // constituent types keyed by the literal types of the property by that name in each constituent type. + function getKeyPropertyName(unionType) { + var types = unionType.types; + // We only construct maps for large unions with non-primitive constituents. + if (types.length < 10 || ts.getObjectFlags(unionType) & 65536 /* PrimitiveUnion */) { + 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 */) ? + ts.forEach(getPropertiesOfType(t), function (p) { return isUnitType(getTypeOfSymbol(p)) ? p.escapedName : undefined; }) : + undefined; + }); + var mapByKeyProperty = keyPropertyName && mapTypesByKeyProperty(types, keyPropertyName); + unionType.keyPropertyName = mapByKeyProperty ? keyPropertyName : ""; + unionType.constituentMap = mapByKeyProperty; + } + return unionType.keyPropertyName.length ? unionType.keyPropertyName : undefined; + } + // Given a union type for which getKeyPropertyName returned a non-undefined result, return the constituent + // that corresponds to the given key type for that property name. + function getConstituentTypeForKeyType(unionType, keyType) { + var _a; + var result = (_a = unionType.constituentMap) === null || _a === void 0 ? void 0 : _a.get(getTypeId(getRegularTypeOfLiteralType(keyType))); + return result !== unknownType ? result : undefined; + } + function getMatchingUnionConstituentForType(unionType, type) { + var keyPropertyName = getKeyPropertyName(unionType); + var propType = keyPropertyName && getTypeOfPropertyOfType(type, keyPropertyName); + return propType && getConstituentTypeForKeyType(unionType, propType); + } + function getMatchingUnionConstituentForObjectLiteral(unionType, node) { + var keyPropertyName = getKeyPropertyName(unionType); + var propNode = keyPropertyName && ts.find(node.properties, function (p) { return p.symbol && p.kind === 290 /* PropertyAssignment */ && + p.symbol.escapedName === keyPropertyName && isPossiblyDiscriminantValue(p.initializer); }); + var propType = propNode && getTypeOfExpression(propNode.initializer); + return propType && getConstituentTypeForKeyType(unionType, propType); + } function isOrContainsMatchingReference(source, target) { return isMatchingReference(source, target) || containsMatchingReference(source, target); } @@ -63259,7 +65573,7 @@ var ts; } } } - if (expression.expression.kind === 201 /* PropertyAccessExpression */ && + if (expression.expression.kind === 203 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, expression.expression.expression)) { return true; } @@ -63306,14 +65620,6 @@ var ts; } return declaredType; } - function getTypeFactsOfTypes(types) { - var result = 0 /* None */; - for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { - var t = types_17[_i]; - result |= getTypeFacts(t); - } - return result; - } function isFunctionObjectType(type) { // We do a quick check for a "bind" property before performing the more expensive subtype // check. This gives us a quicker out in the common case where an object type is not a function. @@ -63321,7 +65627,8 @@ var ts; return !!(resolved.callSignatures.length || resolved.constructSignatures.length || resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType)); } - function getTypeFacts(type) { + function getTypeFacts(type, ignoreObjects) { + if (ignoreObjects === void 0) { ignoreObjects = false; } var flags = type.flags; if (flags & 4 /* String */) { return strictNullChecks ? 16317953 /* StringStrictFacts */ : 16776705 /* StringFacts */; @@ -63358,7 +65665,7 @@ var ts; (type === falseType || type === regularFalseType) ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ : (type === falseType || type === regularFalseType) ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */; } - if (flags & 524288 /* Object */) { + if (flags & 524288 /* Object */ && !ignoreObjects) { return ts.getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type) ? strictNullChecks ? 16318463 /* EmptyObjectStrictFacts */ : 16777215 /* EmptyObjectFacts */ : isFunctionObjectType(type) ? @@ -63381,11 +65688,17 @@ var ts; return 0 /* None */; } if (flags & 465829888 /* Instantiable */) { - return !isPatternLiteralType(type) ? getTypeFacts(getBaseConstraintOfType(type) || unknownType) : + return !isPatternLiteralType(type) ? getTypeFacts(getBaseConstraintOfType(type) || unknownType, ignoreObjects) : strictNullChecks ? 7929345 /* NonEmptyStringStrictFacts */ : 16776705 /* NonEmptyStringFacts */; } - if (flags & 3145728 /* UnionOrIntersection */) { - return getTypeFactsOfTypes(type.types); + if (flags & 1048576 /* Union */) { + return ts.reduceLeft(type.types, function (facts, t) { return facts | getTypeFacts(t, ignoreObjects); }, 0 /* None */); + } + if (flags & 2097152 /* Intersection */) { + // 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. + ignoreObjects || (ignoreObjects = maybeTypeOfKind(type, 131068 /* Primitive */)); + return ts.reduceLeft(type.types, function (facts, t) { return facts & getTypeFacts(t, ignoreObjects); }, 16777215 /* All */); } return 16777215 /* All */; } @@ -63393,18 +65706,16 @@ var ts; return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; }); } function getTypeWithDefault(type, defaultExpression) { - if (defaultExpression) { - var defaultType = getTypeOfExpression(defaultExpression); - return getUnionType([getTypeWithFacts(type, 524288 /* NEUndefined */), defaultType]); - } - return type; + return defaultExpression ? + getUnionType([getNonUndefinedType(type), getTypeOfExpression(defaultExpression)]) : + type; } function getTypeOfDestructuredProperty(type, name) { var nameType = getLiteralTypeFromPropertyName(name); if (!isTypeUsableAsPropertyName(nameType)) return errorType; var text = getPropertyNameFromType(nameType); - return getConstraintForLocation(getTypeOfPropertyOfType(type, text), name) || + return getTypeOfPropertyOfType(type, text) || isNumericLiteralName(text) && includeUndefinedInIndexSignature(getIndexTypeOfType(type, 1 /* Number */)) || includeUndefinedInIndexSignature(getIndexTypeOfType(type, 0 /* String */)) || errorType; @@ -63425,15 +65736,15 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 199 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 288 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 201 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 290 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 216 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 239 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 218 /* BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 241 /* ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -63450,21 +65761,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return stringType; - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: return checkRightHandSideOfForOf(parent) || errorType; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 210 /* DeleteExpression */: + case 212 /* DeleteExpression */: return undefinedType; - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 220 /* SpreadElement */: + case 222 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -63472,7 +65783,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 196 /* ObjectBindingPattern */ ? + var type = pattern.kind === 198 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -63490,35 +65801,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 238 /* ForInStatement */) { + if (node.parent.parent.kind === 240 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 239 /* ForOfStatement */) { + if (node.parent.parent.kind === 241 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 249 /* VariableDeclaration */ ? + return node.kind === 251 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function isEmptyArrayAssignment(node) { - return node.kind === 249 /* VariableDeclaration */ && node.initializer && + return node.kind === 251 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 198 /* BindingElement */ && node.parent.kind === 216 /* BinaryExpression */ && + node.kind !== 200 /* BindingElement */ && node.parent.kind === 218 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 62 /* EqualsToken */: - case 74 /* BarBarEqualsToken */: - case 75 /* AmpersandAmpersandEqualsToken */: - case 76 /* QuestionQuestionEqualsToken */: + case 63 /* EqualsToken */: + case 75 /* BarBarEqualsToken */: + case 76 /* AmpersandAmpersandEqualsToken */: + case 77 /* QuestionQuestionEqualsToken */: return getReferenceCandidate(node.left); case 27 /* CommaToken */: return getReferenceCandidate(node.right); @@ -63528,13 +65839,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 207 /* ParenthesizedExpression */ || - parent.kind === 216 /* BinaryExpression */ && parent.operatorToken.kind === 62 /* EqualsToken */ && parent.left === node || - parent.kind === 216 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? + return parent.kind === 209 /* ParenthesizedExpression */ || + parent.kind === 218 /* BinaryExpression */ && parent.operatorToken.kind === 63 /* EqualsToken */ && parent.left === node || + parent.kind === 218 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 284 /* CaseClause */) { + if (clause.kind === 286 /* CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -63554,7 +65865,7 @@ var ts; var witnesses = []; for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) { var clause = _a[_i]; - if (clause.kind === 284 /* CaseClause */) { + if (clause.kind === 286 /* CaseClause */) { if (ts.isStringLiteralLike(clause.expression)) { witnesses.push(clause.expression.text); continue; @@ -63590,14 +65901,40 @@ var ts; function forEachType(type, f) { return type.flags & 1048576 /* Union */ ? ts.forEach(type.types, f) : f(type); } + function someType(type, f) { + return type.flags & 1048576 /* Union */ ? ts.some(type.types, f) : f(type); + } function everyType(type, f) { return type.flags & 1048576 /* Union */ ? ts.every(type.types, f) : f(type); } + function everyContainedType(type, f) { + return type.flags & 3145728 /* UnionOrIntersection */ ? ts.every(type.types, f) : f(type); + } function filterType(type, f) { if (type.flags & 1048576 /* Union */) { var types = type.types; var filtered = ts.filter(types, f); - return filtered === types ? type : getUnionTypeFromSortedList(filtered, type.objectFlags); + if (filtered === types) { + return type; + } + var origin = type.origin; + var newOrigin = void 0; + if (origin && origin.flags & 1048576 /* 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); }); + if (originTypes.length - originFiltered.length === types.length - filtered.length) { + if (originFiltered.length === 1) { + return originFiltered[0]; + } + newOrigin = createOriginUnionOrIntersectionType(1048576 /* Union */, originFiltered); + } + } + return getUnionTypeFromSortedList(filtered, type.objectFlags, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, newOrigin); } return type.flags & 131072 /* Never */ || f(type) ? type : neverType; } @@ -63630,6 +65967,11 @@ var ts; } return changed ? mappedTypes && getUnionType(mappedTypes, noReductions ? 0 /* None */ : 1 /* Literal */) : type; } + function mapTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments) { + return type.flags & 1048576 /* Union */ && aliasSymbol ? + getUnionType(ts.map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments) : + mapType(type, mapper); + } function getConstituentCount(type) { return type.flags & 3145728 /* UnionOrIntersection */ ? type.types.length : 1; } @@ -63715,21 +66057,21 @@ var ts; var root = getReferenceRoot(node); var parent = root.parent; var isLengthPushOrUnshift = ts.isPropertyAccessExpression(parent) && (parent.name.escapedText === "length" || - parent.parent.kind === 203 /* CallExpression */ + parent.parent.kind === 205 /* CallExpression */ && ts.isIdentifier(parent.name) && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 202 /* ElementAccessExpression */ && + var isElementAssignment = parent.kind === 204 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 216 /* BinaryExpression */ && - parent.parent.operatorToken.kind === 62 /* EqualsToken */ && + parent.parent.kind === 218 /* BinaryExpression */ && + parent.parent.operatorToken.kind === 63 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* NumberLike */); return isLengthPushOrUnshift || isElementAssignment; } function isDeclarationWithExplicitTypeAnnotation(declaration) { - return (declaration.kind === 249 /* VariableDeclaration */ || declaration.kind === 160 /* Parameter */ || - declaration.kind === 163 /* PropertyDeclaration */ || declaration.kind === 162 /* PropertySignature */) && + return (declaration.kind === 251 /* VariableDeclaration */ || declaration.kind === 162 /* Parameter */ || + declaration.kind === 165 /* PropertyDeclaration */ || declaration.kind === 164 /* PropertySignature */) && !!ts.getEffectiveTypeAnnotationNode(declaration); } function getExplicitTypeOfSymbol(symbol, diagnostic) { @@ -63748,7 +66090,7 @@ var ts; if (isDeclarationWithExplicitTypeAnnotation(declaration)) { return getTypeOfSymbol(symbol); } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 239 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 241 /* ForOfStatement */) { var statement = declaration.parent.parent; var expressionType = getTypeOfDottedName(statement.expression, /*diagnostic*/ undefined); if (expressionType) { @@ -63769,18 +66111,32 @@ var ts; function getTypeOfDottedName(node, diagnostic) { if (!(node.flags & 16777216 /* InWithStatement */)) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node)); return getExplicitTypeOfSymbol(symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol, diagnostic); - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: return getExplicitThisType(node); - case 105 /* SuperKeyword */: + case 106 /* SuperKeyword */: return checkSuperExpression(node); - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: { var type = getTypeOfDottedName(node.expression, diagnostic); - var prop = type && getPropertyOfType(type, node.name.escapedText); - return prop && getExplicitTypeOfSymbol(prop, diagnostic); - case 207 /* ParenthesizedExpression */: + if (type) { + var name = node.name; + var prop = void 0; + if (ts.isPrivateIdentifier(name)) { + if (!type.symbol) { + return undefined; + } + prop = getPropertyOfType(type, ts.getSymbolNameForPrivateIdentifier(type.symbol, name.escapedText)); + } + else { + prop = getPropertyOfType(type, name.escapedText); + } + return prop && getExplicitTypeOfSymbol(prop, diagnostic); + } + return undefined; + } + case 209 /* ParenthesizedExpression */: return getTypeOfDottedName(node.expression, diagnostic); } } @@ -63794,10 +66150,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 === 233 /* ExpressionStatement */) { + if (node.parent.kind === 235 /* ExpressionStatement */) { funcType = getTypeOfDottedName(node.expression, /*diagnostic*/ undefined); } - else if (node.expression.kind !== 105 /* SuperKeyword */) { + else if (node.expression.kind !== 106 /* SuperKeyword */) { if (ts.isOptionalChain(node)) { funcType = checkNonNullType(getOptionalExpressionType(checkExpression(node.expression), node.expression), node.expression); } @@ -63838,7 +66194,7 @@ var ts; } function isFalseExpression(expr) { var node = ts.skipParentheses(expr); - return node.kind === 94 /* FalseKeyword */ || node.kind === 216 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && (isFalseExpression(node.left) || isFalseExpression(node.right)) || + return node.kind === 95 /* FalseKeyword */ || node.kind === 218 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && (isFalseExpression(node.left) || isFalseExpression(node.right)) || node.operatorToken.kind === 56 /* BarBarToken */ && isFalseExpression(node.left) && isFalseExpression(node.right)); } function isReachableFlowNodeWorker(flow, noCacheCheck) { @@ -63926,7 +66282,7 @@ var ts; flow = flow.antecedent; } else if (flags & 512 /* Call */) { - if (flow.node.expression.kind === 105 /* SuperKeyword */) { + if (flow.node.expression.kind === 106 /* SuperKeyword */) { return true; } flow = flow.antecedent; @@ -63973,7 +66329,7 @@ var ts; // 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 === 225 /* NonNullExpression */ && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { + if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 227 /* NonNullExpression */ && !(resultType.flags & 131072 /* Never */) && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { return declaredType; } return resultType; @@ -63988,7 +66344,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.instant("checkTypes" /* CheckTypes */, "getTypeAtFlowNode_DepthLimit", { flowId: flow.id }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "getTypeAtFlowNode_DepthLimit", { flowId: flow.id }); flowAnalysisDisabled = true; reportFlowControlError(reference); return errorType; @@ -64057,9 +66413,9 @@ var ts; // Check if we should continue with the control flow of the containing function. var container = flow.node; if (container && container !== flowContainer && - reference.kind !== 201 /* PropertyAccessExpression */ && - reference.kind !== 202 /* ElementAccessExpression */ && - reference.kind !== 107 /* ThisKeyword */) { + reference.kind !== 203 /* PropertyAccessExpression */ && + reference.kind !== 204 /* ElementAccessExpression */ && + reference.kind !== 108 /* ThisKeyword */) { flow = container.flowNode; continue; } @@ -64083,7 +66439,7 @@ var ts; } function getInitialOrAssignedType(flow) { var node = flow.node; - return getConstraintForLocation(node.kind === 249 /* VariableDeclaration */ || node.kind === 198 /* BindingElement */ ? + return getNarrowableTypeForReference(node.kind === 251 /* VariableDeclaration */ || node.kind === 200 /* BindingElement */ ? getInitialType(node) : getAssignedType(node), reference); } @@ -64123,14 +66479,14 @@ 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 === 208 /* FunctionExpression */ || init.kind === 209 /* ArrowFunction */)) { + if (init && (init.kind === 210 /* FunctionExpression */ || init.kind === 211 /* 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 === 238 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { + if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 240 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); } // Assignment doesn't affect reference @@ -64138,10 +66494,10 @@ var ts; } function narrowTypeByAssertion(type, expr) { var node = ts.skipParentheses(expr); - if (node.kind === 94 /* FalseKeyword */) { + if (node.kind === 95 /* FalseKeyword */) { return unreachableNeverType; } - if (node.kind === 216 /* BinaryExpression */) { + if (node.kind === 218 /* BinaryExpression */) { if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { return narrowTypeByAssertion(narrowTypeByAssertion(type, node.left), node.right); } @@ -64172,7 +66528,7 @@ var ts; function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 203 /* CallExpression */ ? + var expr = node.kind === 205 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -64180,7 +66536,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 203 /* CallExpression */) { + if (node.kind === 205 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -64228,7 +66584,7 @@ var ts; if (isMatchingReference(reference, expr)) { type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } - else if (expr.kind === 211 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { + else if (expr.kind === 213 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } else { @@ -64236,12 +66592,12 @@ var ts; if (optionalChainContainsReference(expr, reference)) { type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & (32768 /* Undefined */ | 131072 /* Never */)); }); } - else if (expr.kind === 211 /* TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) { + else if (expr.kind === 213 /* 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"); }); } } if (isMatchingReferenceDiscriminant(expr, type)) { - type = narrowTypeByDiscriminant(type, expr, function (t) { return narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd); }); + type = narrowTypeBySwitchOnDiscriminantProperty(type, expr, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } } return createFlowType(type, isIncomplete(flowType)); @@ -64412,16 +66768,42 @@ var ts; if (propName === undefined) { return type; } - var propType = getTypeOfPropertyOfType(type, propName); + var removeNullable = strictNullChecks && ts.isOptionalChain(access) && maybeTypeOfKind(type, 98304 /* Nullable */); + var propType = getTypeOfPropertyOfType(removeNullable ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type, propName); if (!propType) { return type; } + propType = removeNullable ? getOptionalType(propType) : propType; var narrowedPropType = narrowType(propType); return filterType(type, function (t) { var discriminantType = getTypeOfPropertyOrIndexSignature(t, propName); return !(discriminantType.flags & 131072 /* Never */) && isTypeComparableTo(discriminantType, narrowedPropType); }); } + function narrowTypeByDiscriminantProperty(type, access, operator, value, assumeTrue) { + if ((operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) && type.flags & 1048576 /* Union */) { + var keyPropertyName = getKeyPropertyName(type); + if (keyPropertyName && keyPropertyName === getAccessedPropertyName(access)) { + var candidate_2 = getConstituentTypeForKeyType(type, getTypeOfExpression(value)); + if (candidate_2) { + return operator === (assumeTrue ? 36 /* EqualsEqualsEqualsToken */ : 37 /* ExclamationEqualsEqualsToken */) ? candidate_2 : + isUnitType(getTypeOfPropertyOfType(candidate_2, keyPropertyName) || unknownType) ? filterType(type, function (t) { return t !== candidate_2; }) : + type; + } + } + } + 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)) { + var clauseTypes = getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd); + var candidate = getUnionType(ts.map(clauseTypes, function (t) { return getConstituentTypeForKeyType(type, t) || unknownType; })); + if (candidate !== unknownType) { + return candidate; + } + } + return narrowTypeByDiscriminant(type, access, function (t) { return narrowTypeBySwitchOnDiscriminant(t, switchStatement, clauseStart, clauseEnd); }); + } function narrowTypeByTruthiness(type, expr, assumeTrue) { if (isMatchingReference(reference, expr)) { return getTypeWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); @@ -64445,7 +66827,8 @@ var ts; return !assumeTrue; } function narrowByInKeyword(type, literal, assumeTrue) { - if (type.flags & (1048576 /* Union */ | 524288 /* Object */) + if (type.flags & 1048576 /* Union */ + || type.flags & 524288 /* Object */ && declaredType !== type || isThisTypeParameter(type) || type.flags & 2097152 /* Intersection */ && ts.every(type.types, function (t) { return t.symbol !== globalThisSymbol; })) { var propName_1 = ts.escapeLeadingUnderscores(literal.text); @@ -64455,57 +66838,63 @@ var ts; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 62 /* EqualsToken */: - case 74 /* BarBarEqualsToken */: - case 75 /* AmpersandAmpersandEqualsToken */: - case 76 /* QuestionQuestionEqualsToken */: + case 63 /* EqualsToken */: + case 75 /* BarBarEqualsToken */: + case 76 /* AmpersandAmpersandEqualsToken */: + case 77 /* QuestionQuestionEqualsToken */: return narrowTypeByTruthiness(narrowType(type, expr.right, assumeTrue), expr.left, assumeTrue); case 34 /* EqualsEqualsToken */: case 35 /* ExclamationEqualsToken */: case 36 /* EqualsEqualsEqualsToken */: case 37 /* ExclamationEqualsEqualsToken */: - var operator_1 = expr.operatorToken.kind; - var left_1 = getReferenceCandidate(expr.left); - var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 211 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { - return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); + var operator = expr.operatorToken.kind; + var left = getReferenceCandidate(expr.left); + var right = getReferenceCandidate(expr.right); + if (left.kind === 213 /* TypeOfExpression */ && ts.isStringLiteralLike(right)) { + return narrowTypeByTypeof(type, left, operator, right, assumeTrue); } - if (right_1.kind === 211 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { - return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); + if (right.kind === 213 /* TypeOfExpression */ && ts.isStringLiteralLike(left)) { + return narrowTypeByTypeof(type, right, operator, left, assumeTrue); } - if (isMatchingReference(reference, left_1)) { - return narrowTypeByEquality(type, operator_1, right_1, assumeTrue); + if (isMatchingReference(reference, left)) { + return narrowTypeByEquality(type, operator, right, assumeTrue); } - if (isMatchingReference(reference, right_1)) { - return narrowTypeByEquality(type, operator_1, left_1, assumeTrue); + if (isMatchingReference(reference, right)) { + return narrowTypeByEquality(type, operator, left, assumeTrue); } if (strictNullChecks) { - if (optionalChainContainsReference(left_1, reference)) { - type = narrowTypeByOptionalChainContainment(type, operator_1, right_1, assumeTrue); + if (optionalChainContainsReference(left, reference)) { + type = narrowTypeByOptionalChainContainment(type, operator, right, assumeTrue); } - else if (optionalChainContainsReference(right_1, reference)) { - type = narrowTypeByOptionalChainContainment(type, operator_1, left_1, assumeTrue); + else if (optionalChainContainsReference(right, reference)) { + type = narrowTypeByOptionalChainContainment(type, operator, left, assumeTrue); } } - if (isMatchingReferenceDiscriminant(left_1, type)) { - return narrowTypeByDiscriminant(type, left_1, function (t) { return narrowTypeByEquality(t, operator_1, right_1, assumeTrue); }); + if (isMatchingReferenceDiscriminant(left, type)) { + return narrowTypeByDiscriminantProperty(type, left, operator, right, assumeTrue); } - if (isMatchingReferenceDiscriminant(right_1, type)) { - return narrowTypeByDiscriminant(type, right_1, function (t) { return narrowTypeByEquality(t, operator_1, left_1, assumeTrue); }); + if (isMatchingReferenceDiscriminant(right, type)) { + return narrowTypeByDiscriminantProperty(type, right, operator, left, assumeTrue); } - if (isMatchingConstructorReference(left_1)) { - return narrowTypeByConstructor(type, operator_1, right_1, assumeTrue); + if (isMatchingConstructorReference(left)) { + return narrowTypeByConstructor(type, operator, right, assumeTrue); } - if (isMatchingConstructorReference(right_1)) { - return narrowTypeByConstructor(type, operator_1, left_1, assumeTrue); + if (isMatchingConstructorReference(right)) { + return narrowTypeByConstructor(type, operator, left, assumeTrue); } break; - case 101 /* InstanceOfKeyword */: + case 102 /* InstanceOfKeyword */: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 100 /* InKeyword */: + case 101 /* InKeyword */: var target = getReferenceCandidate(expr.right); - if (ts.isStringLiteralLike(expr.left) && isMatchingReference(reference, target)) { - return narrowByInKeyword(type, expr.left, assumeTrue); + if (ts.isStringLiteralLike(expr.left)) { + if (containsMissingType(type) && ts.isAccessExpression(reference) && isMatchingReference(reference.expression, target) && + getAccessedPropertyName(reference) === ts.escapeLeadingUnderscores(expr.left.text)) { + return getTypeWithFacts(type, assumeTrue ? 524288 /* NEUndefined */ : 65536 /* EQUndefined */); + } + if (isMatchingReference(reference, target)) { + return narrowByInKeyword(type, expr.left, assumeTrue); + } } break; case 27 /* CommaToken */: @@ -64562,13 +66951,12 @@ var ts; } if (assumeTrue) { var filterFn = operator === 34 /* EqualsEqualsToken */ ? - (function (t) { return areTypesComparable(t, valueType) || isCoercibleUnderDoubleEquals(t, valueType); }) : + function (t) { return areTypesComparable(t, valueType) || isCoercibleUnderDoubleEquals(t, valueType); } : function (t) { return areTypesComparable(t, valueType); }; return replacePrimitivesWithLiterals(filterType(type, filterFn), valueType); } if (isUnitType(valueType)) { - var regularType_1 = getRegularTypeOfLiteralType(valueType); - return filterType(type, function (t) { return isUnitType(t) ? !areTypesComparable(t, valueType) : getRegularTypeOfLiteralType(t) !== regularType_1; }); + return filterType(type, function (t) { return !(isUnitLikeType(t) && areTypesComparable(t, valueType)); }); } return type; } @@ -64590,7 +66978,7 @@ var ts; if (assumeTrue && type.flags & 2 /* Unknown */ && literal.text === "object") { // The pattern x && typeof x === 'object', where x is of type unknown, narrows x to type object. We don't // need to check for the reverse typeof x === 'object' && x since that already narrows correctly. - if (typeOfExpr.parent.parent.kind === 216 /* BinaryExpression */) { + if (typeOfExpr.parent.parent.kind === 218 /* BinaryExpression */) { var expr = typeOfExpr.parent.parent; if (expr.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && expr.right === typeOfExpr.parent && containsTruthyCheck(reference, expr.left)) { return nonPrimitiveType; @@ -64646,7 +67034,7 @@ var ts; if (!hasDefaultClause) { return caseType; } - var defaultType = filterType(type, function (t) { return !(isUnitType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(t))); }); + var defaultType = filterType(type, function (t) { return !(isUnitLikeType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(extractUnitType(t)))); }); return caseType.flags & 131072 /* Never */ ? defaultType : getUnionType([caseType, defaultType]); } function getImpliedTypeFromTypeofGuard(type, text) { @@ -64828,7 +67216,16 @@ var ts; } function getNarrowedType(type, candidate, assumeTrue, isRelated) { if (!assumeTrue) { - return filterType(type, function (t) { return !isRelated(t, candidate); }); + return filterType(type, function (t) { + if (!isRelated(t, candidate)) { + return true; + } + var constraint = getBaseConstraintOfType(t); + if (constraint && constraint !== t) { + return !isRelated(constraint, candidate); + } + return false; + }); } // 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. @@ -64838,10 +67235,15 @@ var ts; return assignableType; } } - // If the candidate type is a subtype of the target type, narrow to the candidate type, - // if the target type is a subtype of the candidate type, narrow to the target type, - // otherwise, narrow to an intersection of the two types. - return isTypeSubtypeOf(candidate, type) ? candidate : isTypeSubtypeOf(type, candidate) ? type : getIntersectionType([type, 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]); } function narrowTypeByCallExpression(type, callExpression, assumeTrue) { if (hasMatchingArgument(callExpression, reference)) { @@ -64851,6 +67253,16 @@ var ts; return narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue); } } + if (containsMissingType(type) && ts.isAccessExpression(reference) && ts.isPropertyAccessExpression(callExpression.expression)) { + var callAccess = callExpression.expression; + if (isMatchingReference(reference.expression, getReferenceCandidate(callAccess.expression)) && + 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 type; } function narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue) { @@ -64881,20 +67293,20 @@ var ts; return narrowTypeByOptionality(type, expr, assumeTrue); } switch (expr.kind) { - case 78 /* Identifier */: - case 107 /* ThisKeyword */: - case 105 /* SuperKeyword */: - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 79 /* Identifier */: + case 108 /* ThisKeyword */: + case 106 /* SuperKeyword */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return narrowTypeByCallExpression(type, expr, assumeTrue); - case 207 /* ParenthesizedExpression */: - case 225 /* NonNullExpression */: + case 209 /* ParenthesizedExpression */: + case 227 /* NonNullExpression */: return narrowType(type, expr.expression, assumeTrue); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: if (expr.operator === 53 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } @@ -64918,34 +67330,40 @@ 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 === 78 /* Identifier */) { + if (location.kind === 79 /* Identifier */ || location.kind === 80 /* PrivateIdentifier */) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } - if (ts.isExpressionNode(location) && !ts.isAssignmentTarget(location)) { + if (ts.isExpressionNode(location) && (!ts.isAssignmentTarget(location) || ts.isWriteAccess(location))) { var type = getTypeOfExpression(location); if (getExportSymbolOfValueSymbolIfExported(getNodeLinks(location).resolvedSymbol) === symbol) { return type; } } } + if (ts.isDeclarationName(location) && ts.isSetAccessor(location.parent) && getAnnotatedAccessorTypeNode(location.parent)) { + return resolveTypeOfAccessors(location.parent.symbol, /*writing*/ true); + } // The location isn't a reference to the given symbol, meaning we're being asked // a hypothetical question of what type the symbol would have if there was a reference // to it at the given location. Since we have no control flow information for the // hypothetical reference (control flow information is created and attached by the // binder), we simply return the declared type of the symbol. - return getTypeOfSymbol(symbol); + return getNonMissingTypeOfSymbol(symbol); } function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 257 /* ModuleBlock */ || - node.kind === 297 /* SourceFile */ || - node.kind === 163 /* PropertyDeclaration */; + node.kind === 259 /* ModuleBlock */ || + node.kind === 299 /* SourceFile */ || + node.kind === 165 /* PropertyDeclaration */; }); } // Check if a parameter is assigned anywhere within its declaring function. function isParameterAssigned(symbol) { + if (!symbol.valueDeclaration) { + return false; + } var func = ts.getRootDeclaration(symbol.valueDeclaration).parent; var links = getNodeLinks(func); if (!(links.flags & 8388608 /* AssignmentsMarked */)) { @@ -64960,10 +67378,10 @@ var ts; return !!ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !!(getNodeLinks(node).flags & 8388608 /* AssignmentsMarked */); }); } function markParameterAssignments(node) { - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 160 /* Parameter */) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 162 /* Parameter */) { symbol.isAssigned = true; } } @@ -64979,7 +67397,7 @@ var ts; function removeOptionalityFromDeclaredType(declaredType, declaration) { if (pushTypeResolution(declaration.symbol, 2 /* DeclaredType */)) { var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 160 /* Parameter */ && + declaration.kind === 162 /* Parameter */ && declaration.initializer && getFalsyFlags(declaredType) & 32768 /* Undefined */ && !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* Undefined */); @@ -64993,23 +67411,40 @@ var ts; } function isConstraintPosition(node) { var parent = node.parent; - return parent.kind === 201 /* PropertyAccessExpression */ || - parent.kind === 203 /* CallExpression */ && parent.expression === node || - parent.kind === 202 /* ElementAccessExpression */ && parent.expression === node || - parent.kind === 198 /* BindingElement */ && parent.name === node && !!parent.initializer; - } - function typeHasNullableConstraint(type) { - return type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 98304 /* Nullable */); - } - function getConstraintForLocation(type, node) { - // When a node is the left hand expression of a property access, element access, or call expression, - // and the type of the node includes type variables with constraints that are nullable, we fetch the - // apparent type of the node *before* performing control flow analysis such that narrowings apply to - // the constraint type. - if (type && isConstraintPosition(node) && forEachType(type, typeHasNullableConstraint)) { - return mapType(getWidenedType(type), getBaseConstraintOrType); - } - return type; + // In an element access obj[x], we consider obj to be in a constraint position only when x is not + // of 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 === 203 /* PropertyAccessExpression */ || + parent.kind === 205 /* CallExpression */ && parent.expression === node || + parent.kind === 204 /* ElementAccessExpression */ && parent.expression === node && + !isGenericIndexType(getTypeOfExpression(parent.argumentExpression)); + } + function isGenericTypeWithUnionConstraint(type) { + return !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */)); + } + function containsGenericType(type) { + return !!(type.flags & 465829888 /* Instantiable */ || type.flags & 3145728 /* UnionOrIntersection */ && ts.some(type.types, containsGenericType)); + } + function hasNonBindingPatternContextualTypeWithNoGenericTypes(node) { + // Computing the contextual type for a child of a JSX element involves resolving the type of the + // element's tag name, so we exclude that here to avoid circularities. + var contextualType = (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) && + !((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && + getContextualType(node, 8 /* SkipBindingPatterns */); + return contextualType && !someType(contextualType, containsGenericType); + } + function getNarrowableTypeForReference(type, reference, checkMode) { + // When the type of a reference is or contains an instantiable type with a union type constraint, and + // when the reference is in a constraint position (where it is known we'll obtain the apparent type) or + // has a contextual type containing no top-level instantiables (meaning constraints will determine + // assignability), we substitute constraints for all instantiables in the type of the reference to give + // 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 */) && + someType(type, isGenericTypeWithUnionConstraint) && + (isConstraintPosition(reference) || hasNonBindingPatternContextualTypeWithNoGenericTypes(reference)); + return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type; } function isExportOrExportExpression(location) { return !!ts.findAncestor(location, function (e) { return e.parent && ts.isExportAssignment(e.parent) && e.parent.expression === e && ts.isEntityNameExpression(e); }); @@ -65018,7 +67453,12 @@ var ts; if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) { var target = resolveAlias(symbol); if (target.flags & 111551 /* Value */) { - if (compilerOptions.preserveConstEnums && isExportOrExportExpression(location) || !isConstEnumOrConstEnumOnlyModule(target)) { + // 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. + if (compilerOptions.isolatedModules || + ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(location) || + !isConstEnumOrConstEnumOnlyModule(target)) { markAliasSymbolAsReferenced(symbol); } else { @@ -65027,7 +67467,7 @@ var ts; } } } - function checkIdentifier(node) { + function checkIdentifier(node, checkMode) { var symbol = getResolvedSymbol(node); if (symbol === unknownSymbol) { return errorType; @@ -65041,7 +67481,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 209 /* ArrowFunction */) { + if (container.kind === 211 /* 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 */)) { @@ -65058,15 +67498,15 @@ var ts; } var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); var sourceSymbol = localOrExportSymbol.flags & 2097152 /* Alias */ ? resolveAlias(localOrExportSymbol) : localOrExportSymbol; - if (getDeclarationNodeFlagsFromSymbol(sourceSymbol) & 134217728 /* Deprecated */ && isUncalledFunctionReference(node, sourceSymbol)) { - errorOrSuggestion(/* isError */ false, node, ts.Diagnostics._0_is_deprecated, node.escapedText); + if (sourceSymbol.declarations && getDeclarationNodeFlagsFromSymbol(sourceSymbol) & 134217728 /* Deprecated */ && isUncalledFunctionReference(node, sourceSymbol)) { + addDeprecatedSuggestion(node, sourceSymbol.declarations, node.escapedText); } var declaration = localOrExportSymbol.valueDeclaration; - if (localOrExportSymbol.flags & 32 /* Class */) { + if (declaration && localOrExportSymbol.flags & 32 /* 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 === 252 /* ClassDeclaration */ + if (declaration.kind === 254 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -65078,14 +67518,14 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 221 /* ClassExpression */) { + else if (declaration.kind === 223 /* 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 !== 297 /* SourceFile */) { + while (container.kind !== 299 /* SourceFile */) { if (container.parent === declaration) { - if (container.kind === 163 /* PropertyDeclaration */ && ts.hasSyntacticModifier(container, 32 /* Static */)) { + if (container.kind === 165 /* PropertyDeclaration */ && ts.hasSyntacticModifier(container, 32 /* Static */)) { getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; } @@ -65096,12 +67536,18 @@ var ts; } } checkNestedBlockScopedBinding(node, symbol); - var type = getConstraintForLocation(getTypeOfSymbol(localOrExportSymbol), node); + var type = getTypeOfSymbol(localOrExportSymbol); var assignmentKind = ts.getAssignmentTargetKind(node); if (assignmentKind) { if (!(localOrExportSymbol.flags & 3 /* Variable */) && !(ts.isInJSFile(node) && localOrExportSymbol.flags & 512 /* ValueModule */)) { - error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_not_a_variable, symbolToString(symbol)); + 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 + : ts.Diagnostics.Cannot_assign_to_0_because_it_is_not_a_variable; + error(node, assignmentError, symbolToString(symbol)); return errorType; } if (isReadonlySymbol(localOrExportSymbol)) { @@ -65123,7 +67569,7 @@ var ts; } } else if (isAlias) { - declaration = ts.find(symbol.declarations, isSomeImportDeclaration); + declaration = getDeclarationOfAliasSymbol(symbol); } else { return type; @@ -65131,10 +67577,11 @@ var ts; if (!declaration) { return type; } + type = getNarrowableTypeForReference(type, node, checkMode); // 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 === 160 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 162 /* Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; @@ -65143,8 +67590,8 @@ var ts; // 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 === 208 /* FunctionExpression */ || - flowContainer.kind === 209 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 210 /* FunctionExpression */ || + flowContainer.kind === 211 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -65153,9 +67600,9 @@ var ts; // 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 === 270 /* ExportSpecifier */) || - node.parent.kind === 225 /* NonNullExpression */ || - declaration.kind === 249 /* VariableDeclaration */ && declaration.exclamationToken || + isInTypeQuery(node) || node.parent.kind === 272 /* ExportSpecifier */) || + node.parent.kind === 227 /* NonNullExpression */ || + declaration.kind === 251 /* VariableDeclaration */ && declaration.exclamationToken || declaration.flags & 8388608 /* Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : @@ -65180,17 +67627,21 @@ var ts; } return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } - function isInsideFunction(node, threshold) { - return !!ts.findAncestor(node, function (n) { return n === threshold ? "quit" : ts.isFunctionLike(n); }); + 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); }); } function getPartOfForStatementContainingNode(node, container) { return ts.findAncestor(node, function (n) { return n === container ? "quit" : n === container.initializer || n === container.condition || n === container.incrementor || n === container.statement; }); } + function getEnclosingIterationStatement(node) { + 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 || + !symbol.valueDeclaration || ts.isSourceFile(symbol.valueDeclaration) || - symbol.valueDeclaration.parent.kind === 287 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 289 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -65198,22 +67649,14 @@ var ts; // 2. walk from the declaration up to the boundary of lexical environment and check // if there is an iteration statement in between declaration and boundary (is binding/class declared inside iteration statement) var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); - var usedInFunction = isInsideFunction(node.parent, container); - var current = container; - var containedInIterationStatement = false; - while (current && !ts.nodeStartsNewLexicalEnvironment(current)) { - if (ts.isIterationStatement(current, /*lookInLabeledStatements*/ false)) { - containedInIterationStatement = true; - break; - } - current = current.parent; - } - if (containedInIterationStatement) { - if (usedInFunction) { + var isCaptured = isInsideFunctionOrInstancePropertyInitializer(node, container); + var enclosingIterationStatement = getEnclosingIterationStatement(container); + if (enclosingIterationStatement) { + if (isCaptured) { // 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, 250 /* VariableDeclarationList */); + var varDeclList = ts.getAncestor(symbol.valueDeclaration, 252 /* VariableDeclarationList */); if (varDeclList && varDeclList.parent === container) { var part = getPartOfForStatementContainingNode(node.parent, container); if (part) { @@ -65228,13 +67671,13 @@ var ts; } } if (capturesBlockScopeBindingInLoopBody) { - getNodeLinks(current).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */; + getNodeLinks(enclosingIterationStatement).flags |= 65536 /* 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, 250 /* VariableDeclarationList */); + var varDeclList = ts.getAncestor(symbol.valueDeclaration, 252 /* VariableDeclarationList */); if (varDeclList && varDeclList.parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NeedsLoopOutParameter */; } @@ -65242,7 +67685,7 @@ var ts; // set 'declared inside loop' bit on the block-scoped binding getNodeLinks(symbol.valueDeclaration).flags |= 524288 /* BlockScopedBindingInLoop */; } - if (usedInFunction) { + if (isCaptured) { getNodeLinks(symbol.valueDeclaration).flags |= 262144 /* CapturedBlockScopedBinding */; } } @@ -65253,7 +67696,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 207 /* ParenthesizedExpression */) { + while (current.parent.kind === 209 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -65261,7 +67704,7 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 214 /* PrefixUnaryExpression */ || current.parent.kind === 215 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 216 /* PrefixUnaryExpression */ || current.parent.kind === 217 /* PostfixUnaryExpression */)) { var expr = current.parent; isAssigned = expr.operator === 45 /* PlusPlusToken */ || expr.operator === 46 /* MinusMinusToken */; } @@ -65274,7 +67717,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 163 /* PropertyDeclaration */ || container.kind === 166 /* Constructor */) { + if (container.kind === 165 /* PropertyDeclaration */ || container.kind === 168 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -65314,37 +67757,37 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var capturedByArrowFunction = false; - if (container.kind === 166 /* Constructor */) { + if (container.kind === 168 /* 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 === 209 /* ArrowFunction */) { + if (container.kind === 211 /* ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); capturedByArrowFunction = true; } switch (container.kind) { - case 256 /* ModuleDeclaration */: + case 258 /* 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 255 /* EnumDeclaration */: + case 257 /* 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 166 /* Constructor */: + case 168 /* 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 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - if (ts.hasSyntacticModifier(container, 32 /* Static */) && !(compilerOptions.target === 99 /* ESNext */ && compilerOptions.useDefineForClassFields)) { + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + if (ts.hasSyntacticModifier(container, 32 /* Static */) && !(compilerOptions.target === 99 /* ESNext */ && useDefineForClassFields)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } break; - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -65432,7 +67875,7 @@ var ts; } function getClassNameFromPrototypeMethod(container) { // Check if it's the RHS of a x.prototype.y = function [name]() { .... } - if (container.kind === 208 /* FunctionExpression */ && + if (container.kind === 210 /* FunctionExpression */ && ts.isBinaryExpression(container.parent) && ts.getAssignmentDeclarationKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = container' @@ -65442,16 +67885,16 @@ var ts; .expression; // x } // x.prototype = { method() { } } - else if (container.kind === 165 /* MethodDeclaration */ && - container.parent.kind === 200 /* ObjectLiteralExpression */ && + else if (container.kind === 167 /* MethodDeclaration */ && + container.parent.kind === 202 /* ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent) === 6 /* Prototype */) { return container.parent.parent.left.expression; } // x.prototype = { method: function() { } } - else if (container.kind === 208 /* FunctionExpression */ && - container.parent.kind === 288 /* PropertyAssignment */ && - container.parent.parent.kind === 200 /* ObjectLiteralExpression */ && + else if (container.kind === 210 /* FunctionExpression */ && + container.parent.kind === 290 /* PropertyAssignment */ && + container.parent.parent.kind === 202 /* ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* Prototype */) { return container.parent.parent.parent.left.expression; @@ -65459,7 +67902,7 @@ var ts; // Object.defineProperty(x, "method", { value: function() { } }); // Object.defineProperty(x, "method", { set: (x: () => void) => void }); // Object.defineProperty(x, "method", { get: () => function() { }) }); - else if (container.kind === 208 /* FunctionExpression */ && + else if (container.kind === 210 /* 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") && @@ -65484,7 +67927,7 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 308 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 311 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -65498,16 +67941,16 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 160 /* Parameter */ && n.parent === constructorDecl; }); + return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 162 /* Parameter */ && n.parent === constructorDecl; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 203 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 205 /* 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 === 209 /* ArrowFunction */) { + while (container && container.kind === 211 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -65520,14 +67963,14 @@ var ts; // class B { // [super.foo()]() {} // } - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 158 /* ComputedPropertyName */; }); - if (current && current.kind === 158 /* ComputedPropertyName */) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 160 /* ComputedPropertyName */; }); + if (current && current.kind === 160 /* 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 === 200 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 202 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -65535,7 +67978,7 @@ var ts; } return errorType; } - if (!isCallExpression && immediateContainer.kind === 166 /* Constructor */) { + if (!isCallExpression && immediateContainer.kind === 168 /* 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.hasSyntacticModifier(container, 32 /* Static */) || isCallExpression) { @@ -65604,7 +68047,7 @@ 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 === 165 /* MethodDeclaration */ && ts.hasSyntacticModifier(container, 256 /* Async */)) { + if (container.kind === 167 /* MethodDeclaration */ && ts.hasSyntacticModifier(container, 256 /* Async */)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; } @@ -65618,7 +68061,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 200 /* ObjectLiteralExpression */) { + if (container.parent.kind === 202 /* ObjectLiteralExpression */) { if (languageVersion < 2 /* ES2015 */) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return errorType; @@ -65639,7 +68082,7 @@ var ts; if (!baseClassType) { return errorType; } - if (container.kind === 166 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 168 /* 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; @@ -65654,7 +68097,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 === 166 /* Constructor */; + return container.kind === 168 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -65662,21 +68105,21 @@ 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 === 200 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 202 /* ObjectLiteralExpression */) { if (ts.hasSyntacticModifier(container, 32 /* Static */)) { - return container.kind === 165 /* MethodDeclaration */ || - container.kind === 164 /* MethodSignature */ || - container.kind === 167 /* GetAccessor */ || - container.kind === 168 /* SetAccessor */; + return container.kind === 167 /* MethodDeclaration */ || + container.kind === 166 /* MethodSignature */ || + container.kind === 169 /* GetAccessor */ || + container.kind === 170 /* SetAccessor */; } else { - return container.kind === 165 /* MethodDeclaration */ || - container.kind === 164 /* MethodSignature */ || - container.kind === 167 /* GetAccessor */ || - container.kind === 168 /* SetAccessor */ || - container.kind === 163 /* PropertyDeclaration */ || - container.kind === 162 /* PropertySignature */ || - container.kind === 166 /* Constructor */; + return container.kind === 167 /* MethodDeclaration */ || + container.kind === 166 /* MethodSignature */ || + container.kind === 169 /* GetAccessor */ || + container.kind === 170 /* SetAccessor */ || + container.kind === 165 /* PropertyDeclaration */ || + container.kind === 164 /* PropertySignature */ || + container.kind === 168 /* Constructor */; } } } @@ -65684,10 +68127,10 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 165 /* MethodDeclaration */ || - func.kind === 167 /* GetAccessor */ || - func.kind === 168 /* SetAccessor */) && func.parent.kind === 200 /* ObjectLiteralExpression */ ? func.parent : - func.kind === 208 /* FunctionExpression */ && func.parent.kind === 288 /* PropertyAssignment */ ? func.parent.parent : + return (func.kind === 167 /* MethodDeclaration */ || + func.kind === 169 /* GetAccessor */ || + func.kind === 170 /* SetAccessor */) && func.parent.kind === 202 /* ObjectLiteralExpression */ ? func.parent : + func.kind === 210 /* FunctionExpression */ && func.parent.kind === 290 /* PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { @@ -65699,7 +68142,7 @@ var ts; }); } function getContextualThisParameterType(func) { - if (func.kind === 209 /* ArrowFunction */) { + if (func.kind === 211 /* ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -65726,7 +68169,7 @@ var ts; if (thisType) { return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral))); } - if (literal.parent.kind !== 288 /* PropertyAssignment */) { + if (literal.parent.kind !== 290 /* PropertyAssignment */) { break; } literal = literal.parent.parent; @@ -65740,7 +68183,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 === 216 /* BinaryExpression */ && parent.operatorToken.kind === 62 /* EqualsToken */) { + if (parent.kind === 218 /* BinaryExpression */ && parent.operatorToken.kind === 63 /* EqualsToken */) { var target = parent.left; if (ts.isAccessExpression(target)) { var expression = target.expression; @@ -65793,11 +68236,11 @@ var ts; return getTypeFromTypeNode(typeNode); } switch (declaration.kind) { - case 160 /* Parameter */: + case 162 /* Parameter */: return getContextuallyTypedParameterType(declaration); - case 198 /* BindingElement */: + case 200 /* BindingElement */: return getContextualTypeForBindingElement(declaration); - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: if (ts.hasSyntacticModifier(declaration, 32 /* Static */)) { return getContextualTypeForStaticPropertyDeclaration(declaration); } @@ -65808,10 +68251,10 @@ var ts; var parent = declaration.parent.parent; var name = declaration.propertyName || declaration.name; var parentType = getContextualTypeForVariableLikeDeclaration(parent) || - parent.kind !== 198 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent); + parent.kind !== 200 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent); if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name)) return undefined; - if (parent.name.kind === 197 /* ArrayBindingPattern */) { + if (parent.name.kind === 199 /* ArrayBindingPattern */) { var index = ts.indexOfNode(declaration.parent.elements, declaration); if (index < 0) return undefined; @@ -65945,10 +68388,13 @@ var ts; if (ts.isJsxOpeningLikeElement(callTarget) && argIndex === 0) { return getEffectiveFirstArgumentForJsxSignature(signature, callTarget); } - return getTypeAtPosition(signature, argIndex); + var restIndex = signature.parameters.length - 1; + return signatureHasRestParameter(signature) && argIndex >= restIndex ? + getIndexedAccessType(getTypeOfSymbol(signature.parameters[restIndex]), getLiteralType(argIndex - restIndex), 256 /* Contextual */) : + getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 205 /* TaggedTemplateExpression */) { + if (template.parent.kind === 207 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -65957,10 +68403,10 @@ var ts; var binaryExpression = node.parent; var left = binaryExpression.left, operatorToken = binaryExpression.operatorToken, right = binaryExpression.right; switch (operatorToken.kind) { - case 62 /* EqualsToken */: - case 75 /* AmpersandAmpersandEqualsToken */: - case 74 /* BarBarEqualsToken */: - case 76 /* QuestionQuestionEqualsToken */: + case 63 /* EqualsToken */: + case 76 /* AmpersandAmpersandEqualsToken */: + case 75 /* BarBarEqualsToken */: + case 77 /* QuestionQuestionEqualsToken */: return node === right ? getContextualTypeForAssignmentDeclaration(binaryExpression) : undefined; case 56 /* BarBarToken */: case 60 /* QuestionQuestionToken */: @@ -65982,16 +68428,16 @@ var ts; // In an assignment expression, the right operand is contextually typed by the type of the left operand. // Don't do this for assignment declarations unless there is a type tag on the assignment, to avoid circularity from checking the right operand. function getContextualTypeForAssignmentDeclaration(binaryExpression) { + var _a, _b; var kind = ts.getAssignmentDeclarationKind(binaryExpression); switch (kind) { case 0 /* None */: return getTypeOfExpression(binaryExpression.left); + case 4 /* ThisProperty */: + return getContextualTypeForThisPropertyAssignment(binaryExpression); case 5 /* Property */: - case 1 /* ExportsProperty */: - case 6 /* Prototype */: - case 3 /* PrototypeProperty */: if (isPossiblyAliasedThisProperty(binaryExpression, kind)) { - return getContextualTypeForThisPropertyAssignment(binaryExpression, kind); + return getContextualTypeForThisPropertyAssignment(binaryExpression); } // If `binaryExpression.left` was assigned a symbol, then this is a new declaration; otherwise it is an assignment to an existing declaration. // See `bindStaticPropertyAssignment` in `binder.ts`. @@ -66012,11 +68458,11 @@ var ts; var id = lhs.expression; var parentSymbol = resolveName(id, id.escapedText, 111551 /* Value */, undefined, id.escapedText, /*isUse*/ true); if (parentSymbol) { - var annotated = parentSymbol.valueDeclaration && ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration); - if (annotated) { + var annotated_1 = parentSymbol.valueDeclaration && ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration); + if (annotated_1) { var nameStr = ts.getElementOrPropertyAccessName(lhs); if (nameStr !== undefined) { - return getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated), nameStr); + return getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated_1), nameStr); } } return undefined; @@ -66024,9 +68470,15 @@ var ts; } return ts.isInJSFile(decl) ? undefined : getTypeOfExpression(binaryExpression.left); } + case 1 /* ExportsProperty */: + case 6 /* Prototype */: + case 3 /* PrototypeProperty */: + var valueDeclaration = (_a = binaryExpression.left.symbol) === null || _a === void 0 ? void 0 : _a.valueDeclaration; + // falls through case 2 /* ModuleExports */: - case 4 /* ThisProperty */: - return getContextualTypeForThisPropertyAssignment(binaryExpression, kind); + 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 */: @@ -66047,7 +68499,7 @@ var ts; var symbol = resolveName(declaration.left, name, 111551 /* Value */, undefined, undefined, /*isUse*/ true, /*excludeGlobals*/ true); return ts.isThisInitializedDeclaration(symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration); } - function getContextualTypeForThisPropertyAssignment(binaryExpression, kind) { + function getContextualTypeForThisPropertyAssignment(binaryExpression) { if (!binaryExpression.symbol) return getTypeOfExpression(binaryExpression.left); if (binaryExpression.symbol.valueDeclaration) { @@ -66059,8 +68511,6 @@ var ts; } } } - if (kind === 2 /* ModuleExports */) - return undefined; var thisAccess = ts.cast(binaryExpression.left, ts.isAccessExpression); if (!ts.isObjectLiteralMethod(ts.getThisContainer(thisAccess.expression, /*includeArrowFunctions*/ false))) { return undefined; @@ -66115,9 +68565,13 @@ var ts; } function getContextualTypeForObjectLiteralElement(element, contextFlags) { var objectLiteral = element.parent; + var propertyAssignmentType = ts.isPropertyAssignment(element) && getContextualTypeForVariableLikeDeclaration(element); + if (propertyAssignmentType) { + return propertyAssignmentType; + } var type = getApparentTypeOfContextualType(objectLiteral, contextFlags); if (type) { - if (!hasNonBindableDynamicName(element)) { + if (hasBindableName(element)) { // For a (non-symbol) computed property, there is no reason to look up the name // in the type. It will just be "__computed", which does not appear in any // SymbolTable. @@ -66197,25 +68651,25 @@ var ts; case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: - case 103 /* NullKeyword */: - case 78 /* Identifier */: - case 150 /* UndefinedKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: + case 104 /* NullKeyword */: + case 79 /* Identifier */: + case 151 /* UndefinedKeyword */: return true; - case 201 /* PropertyAccessExpression */: - case 207 /* ParenthesizedExpression */: + case 203 /* PropertyAccessExpression */: + case 209 /* ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: return !node.expression || isPossiblyDiscriminantValue(node.expression); } return false; } function discriminateContextualTypeByObjectMembers(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 288 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); + return getMatchingUnionConstituentForObjectLiteral(contextualType, node) || discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 290 /* 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); } function discriminateContextualTypeByJSXAttributes(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 280 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return checkExpression(prop.initializer); }), prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 282 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return checkExpression(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 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. @@ -66226,15 +68680,9 @@ var ts; var instantiatedType = instantiateContextualType(contextualType, node, contextFlags); if (instantiatedType && !(contextFlags && contextFlags & 2 /* NoConstraints */ && instantiatedType.flags & 8650752 /* TypeVariable */)) { var apparentType = mapType(instantiatedType, getApparentType, /*noReductions*/ true); - if (apparentType.flags & 1048576 /* Union */) { - if (ts.isObjectLiteralExpression(node)) { - return discriminateContextualTypeByObjectMembers(node, apparentType); - } - else if (ts.isJsxAttributes(node)) { - return discriminateContextualTypeByJSXAttributes(node, apparentType); - } - } - return apparentType; + return apparentType.flags & 1048576 /* Union */ && ts.isObjectLiteralExpression(node) ? discriminateContextualTypeByObjectMembers(node, apparentType) : + apparentType.flags & 1048576 /* Union */ && ts.isJsxAttributes(node) ? discriminateContextualTypeByJSXAttributes(node, apparentType) : + apparentType; } } // If the given contextual type contains instantiable types and if a mapper representing @@ -66301,58 +68749,60 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 249 /* VariableDeclaration */: - case 160 /* Parameter */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 198 /* BindingElement */: + case 251 /* VariableDeclaration */: + case 162 /* Parameter */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 200 /* BindingElement */: return getContextualTypeForInitializerExpression(node, contextFlags); - case 209 /* ArrowFunction */: - case 242 /* ReturnStatement */: + case 211 /* ArrowFunction */: + case 244 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 213 /* AwaitExpression */: + case 215 /* AwaitExpression */: return getContextualTypeForAwaitOperand(parent, contextFlags); - case 203 /* CallExpression */: - if (parent.expression.kind === 99 /* ImportKeyword */) { + case 205 /* CallExpression */: + if (parent.expression.kind === 100 /* ImportKeyword */) { return stringType; } /* falls through */ - case 204 /* NewExpression */: + case 206 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 206 /* TypeAssertionExpression */: - case 224 /* AsExpression */: + case 208 /* TypeAssertionExpression */: + case 226 /* AsExpression */: return ts.isConstTypeReference(parent.type) ? tryFindWhenConstTypeReference(parent) : getTypeFromTypeNode(parent.type); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node, contextFlags); - case 288 /* PropertyAssignment */: - case 289 /* ShorthandPropertyAssignment */: + case 290 /* PropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent, contextFlags); - case 290 /* SpreadAssignment */: - return getApparentTypeOfContextualType(parent.parent, contextFlags); - case 199 /* ArrayLiteralExpression */: { + case 292 /* SpreadAssignment */: + return getContextualType(parent.parent, contextFlags); + case 201 /* ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral, contextFlags); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node, contextFlags); - case 228 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 218 /* TemplateExpression */); + case 230 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 220 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 207 /* ParenthesizedExpression */: { + case 209 /* 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 ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent, contextFlags); } - case 283 /* JsxExpression */: + case 227 /* NonNullExpression */: + return getContextualType(parent, contextFlags); + case 285 /* JsxExpression */: return getContextualTypeForJsxExpression(parent); - case 280 /* JsxAttribute */: - case 282 /* JsxSpreadAttribute */: + case 282 /* JsxAttribute */: + case 284 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 275 /* JsxOpeningElement */: - case 274 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent, contextFlags); } return undefined; @@ -66388,14 +68838,14 @@ var ts; return propsType; } function getJsxPropsTypeForSignatureFromMember(sig, forcedLookupLocation) { - if (sig.unionSignatures) { + if (sig.compositeSignatures) { // JSX Elements using the legacy `props`-field based lookup (eg, react class components) need to treat the `props` member as an input // instead of an output position when resolving the signature. We need to go back to the input signatures of the composite signature, // get the type of `props` on each return type individually, and then _intersect them_, rather than union them (as would normally occur // for a union signature). It's an unfortunate quirk of looking in the output of the signature for the type we want to use for the input. // The default behavior of `getTypeOfFirstParameterOfSignatureWithFallback` when no `props` member name is defined is much more sane. var results = []; - for (var _i = 0, _a = sig.unionSignatures; _i < _a.length; _i++) { + for (var _i = 0, _a = sig.compositeSignatures; _i < _a.length; _i++) { var signature = _a[_i]; var instance = getReturnTypeOfSignature(signature); if (isTypeAny(instance)) { @@ -66407,7 +68857,7 @@ var ts; } results.push(propType); } - return getIntersectionType(results); + return getIntersectionType(results); // Same result for both union and intersection signatures } var instanceType = getReturnTypeOfSignature(sig); return isTypeAny(instanceType) ? instanceType : getTypeOfPropertyOfType(instanceType, forcedLookupLocation); @@ -66432,16 +68882,19 @@ var ts; function getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType) { var managedSym = getJsxLibraryManagedAttributes(ns); if (managedSym) { - var declaredManagedType = getDeclaredTypeOfSymbol(managedSym); + var declaredManagedType = getDeclaredTypeOfSymbol(managedSym); // fetches interface type, or initializes symbol links type parmaeters var ctorType = getStaticTypeOfReferencedJsxConstructor(context); + if (managedSym.flags & 524288 /* TypeAlias */) { + var params = getSymbolLinks(managedSym).typeParameters; + if (ts.length(params) >= 2) { + var args = fillMissingTypeArguments([ctorType, attributesType], params, 2, ts.isInJSFile(context)); + return getTypeAliasInstantiation(managedSym, args); + } + } if (ts.length(declaredManagedType.typeParameters) >= 2) { var args = fillMissingTypeArguments([ctorType, attributesType], declaredManagedType.typeParameters, 2, ts.isInJSFile(context)); return createTypeReference(declaredManagedType, args); } - else if (ts.length(declaredManagedType.aliasTypeArguments) >= 2) { - var args = fillMissingTypeArguments([ctorType, attributesType], declaredManagedType.aliasTypeArguments, 2, ts.isInJSFile(context)); - return getTypeAliasInstantiation(declaredManagedType.aliasSymbol, args); - } } return attributesType; } @@ -66486,16 +68939,93 @@ var ts; return apparentAttributesType; } } + function getIntersectedSignatures(signatures) { + return ts.getStrictOptionValue(compilerOptions, "noImplicitAny") + ? ts.reduceLeft(signatures, function (left, right) { + return left === right || !left ? left + : compareTypeParametersIdentical(left.typeParameters, right.typeParameters) ? combineSignaturesOfIntersectionMembers(left, right) + : undefined; + }) + : undefined; + } + function combineIntersectionThisParam(left, right, mapper) { + if (!left || !right) { + return left || right; + } + // A signature `this` type might be a read or a write position... It's very possible that it should be invariant + // and we should refuse to merge signatures if there are `this` types and they do not match. However, so as to be + // pessimistic when contextual typing, for now, we'll union the `this` types. + var thisType = getUnionType([getTypeOfSymbol(left), instantiateType(getTypeOfSymbol(right), mapper)]); + return createSymbolWithType(left, thisType); + } + function combineIntersectionParameters(left, right, mapper) { + var leftCount = getParameterCount(left); + var rightCount = getParameterCount(right); + var longest = leftCount >= rightCount ? left : right; + var shorter = longest === left ? right : left; + var longestCount = longest === left ? leftCount : rightCount; + var eitherHasEffectiveRest = (hasEffectiveRestParameter(left) || hasEffectiveRestParameter(right)); + var needsExtraRestElement = eitherHasEffectiveRest && !hasEffectiveRestParameter(longest); + var params = new Array(longestCount + (needsExtraRestElement ? 1 : 0)); + for (var i = 0; i < longestCount; i++) { + var longestParamType = tryGetTypeAtPosition(longest, i); + if (longest === right) { + longestParamType = instantiateType(longestParamType, mapper); + } + var shorterParamType = tryGetTypeAtPosition(shorter, i) || unknownType; + if (shorter === right) { + shorterParamType = instantiateType(shorterParamType, mapper); + } + var unionParamType = getUnionType([longestParamType, shorterParamType]); + var isRestParam = eitherHasEffectiveRest && !needsExtraRestElement && i === (longestCount - 1); + var isOptional = i >= getMinArgumentCount(longest) && i >= getMinArgumentCount(shorter); + var leftName = i >= leftCount ? undefined : getParameterNameAtPosition(left, i); + var rightName = i >= rightCount ? undefined : getParameterNameAtPosition(right, i); + var paramName = leftName === rightName ? leftName : + !leftName ? rightName : + !rightName ? leftName : + undefined; + var paramSymbol = createSymbol(1 /* FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* Optional */ : 0), paramName || "arg" + i); + paramSymbol.type = isRestParam ? createArrayType(unionParamType) : unionParamType; + params[i] = paramSymbol; + } + if (needsExtraRestElement) { + var restParamSymbol = createSymbol(1 /* FunctionScopedVariable */, "args"); + restParamSymbol.type = createArrayType(getTypeAtPosition(shorter, longestCount)); + if (shorter === right) { + restParamSymbol.type = instantiateType(restParamSymbol.type, mapper); + } + params[longestCount] = restParamSymbol; + } + return params; + } + function combineSignaturesOfIntersectionMembers(left, right) { + var typeParams = left.typeParameters || right.typeParameters; + var paramMapper; + if (left.typeParameters && right.typeParameters) { + paramMapper = createTypeMapper(right.typeParameters, left.typeParameters); + // We just use the type parameter defaults from the first signature + } + var declaration = left.declaration; + var params = combineIntersectionParameters(left, right, paramMapper); + var thisParam = combineIntersectionThisParam(left.thisParameter, right.thisParameter, paramMapper); + 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]); + if (paramMapper) { + result.mapper = left.compositeKind === 2097152 /* 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 */); - if (signatures.length === 1) { - var signature = signatures[0]; - if (!isAritySmaller(signature, node)) { - return signature; - } - } + var applicableByArity = ts.filter(signatures, function (s) { return !isAritySmaller(s, node); }); + return applicableByArity.length === 1 ? applicableByArity[0] : getIntersectedSignatures(applicableByArity); } /** If the contextual signature has fewer parameters than the function expression, do not use it */ function isAritySmaller(signature, target) { @@ -66512,7 +69042,7 @@ var ts; return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 208 /* FunctionExpression */ || node.kind === 209 /* ArrowFunction */; + return node.kind === 210 /* FunctionExpression */ || node.kind === 211 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -66526,7 +69056,7 @@ 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 !== 165 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 167 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var typeTagSignature = getSignatureOfTypeTag(node); if (typeTagSignature) { return typeTagSignature; @@ -66574,8 +69104,8 @@ var ts; return node.isSpread ? getIndexedAccessType(node.type, numberType) : node.type; } function hasDefaultValue(node) { - return (node.kind === 198 /* BindingElement */ && !!node.initializer) || - (node.kind === 216 /* BinaryExpression */ && node.operatorToken.kind === 62 /* EqualsToken */); + return (node.kind === 200 /* BindingElement */ && !!node.initializer) || + (node.kind === 218 /* BinaryExpression */ && node.operatorToken.kind === 63 /* EqualsToken */); } function checkArrayLiteral(node, checkMode, forceTuple) { var elements = node.elements; @@ -66585,9 +69115,10 @@ var ts; var contextualType = getApparentTypeOfContextualType(node); 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 === 220 /* SpreadElement */) { + if (e.kind === 222 /* SpreadElement */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(e, compilerOptions.downlevelIteration ? 1536 /* SpreadIncludes */ : 1024 /* SpreadArray */); } @@ -66620,17 +69151,22 @@ var ts; elementFlags.push(4 /* Rest */); } } + else if (strictOptionalProperties && e.kind === 224 /* OmittedExpression */) { + hasOmittedExpression = true; + elementTypes.push(missingType); + elementFlags.push(2 /* Optional */); + } else { var elementContextualType = getContextualTypeForElementExpression(contextualType, elementTypes.length); var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple); - elementTypes.push(type); - elementFlags.push(1 /* Required */); + elementTypes.push(addOptionality(type, /*isProperty*/ true, hasOmittedExpression)); + elementFlags.push(hasOmittedExpression ? 2 /* Optional */ : 1 /* Required */); } } if (inDestructuringPattern) { return createTupleType(elementTypes, elementFlags); } - if (forceTuple || inConstContext || contextualType && forEachType(contextualType, isTupleLikeType)) { + if (forceTuple || inConstContext || contextualType && someType(contextualType, isTupleLikeType)) { return createArrayLiteralType(createTupleType(elementTypes, elementFlags, /*readonly*/ inConstContext)); } return createArrayLiteralType(createArrayType(elementTypes.length ? @@ -66644,15 +69180,15 @@ var ts; var literalType = type.literalType; if (!literalType) { literalType = type.literalType = cloneTypeReference(type); - literalType.objectFlags |= 65536 /* ArrayLiteral */ | 1048576 /* ContainsObjectOrArrayLiteral */; + literalType.objectFlags |= 32768 /* ArrayLiteral */ | 262144 /* ContainsObjectOrArrayLiteral */; } return literalType; } function isNumericName(name) { switch (name.kind) { - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return isNumericComputedName(name); - case 78 /* Identifier */: + case 79 /* Identifier */: return isNumericLiteralName(name.escapedText); case 8 /* NumericLiteral */: case 10 /* StringLiteral */: @@ -66697,6 +69233,20 @@ var ts; var links = getNodeLinks(node.expression); if (!links.resolvedType) { links.resolvedType = checkExpression(node.expression); + // The computed property name of a non-static class field within a loop must be stored in a block-scoped binding. + // (It needs to be bound at class evaluation time.) + if (ts.isPropertyDeclaration(node.parent) && !ts.hasStaticModifier(node.parent) && ts.isClassExpression(node.parent.parent)) { + var container = ts.getEnclosingBlockScopeContainer(node.parent.parent); + 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 */; + // The generated variable which stores the computed field name must be block-scoped. + getNodeLinks(node).flags |= 524288 /* BlockScopedBindingInLoop */; + // The generated variable which stores the class must be block-scoped. + getNodeLinks(node.parent.parent).flags |= 524288 /* 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 */ || @@ -66704,9 +69254,6 @@ var ts; !isTypeAssignableTo(links.resolvedType, stringNumberSymbolType)) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } - else { - checkThatExpressionIsProperSymbolReference(node.expression, links.resolvedType, /*reportError*/ true); - } } return links.resolvedType; } @@ -66746,7 +69293,7 @@ var ts; var spread = emptyObjectType; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 196 /* ObjectBindingPattern */ || contextualType.pattern.kind === 200 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 198 /* ObjectBindingPattern */ || contextualType.pattern.kind === 202 /* ObjectLiteralExpression */); var inConstContext = isConstContext(node); var checkFlags = inConstContext ? 8 /* Readonly */ : 0; var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node); @@ -66761,7 +69308,7 @@ var ts; // which may never occur. for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; - if (elem.name && ts.isComputedPropertyName(elem.name) && !ts.isWellKnownSymbolSyntactically(elem.name)) { + if (elem.name && ts.isComputedPropertyName(elem.name)) { checkComputedPropertyName(elem.name); } } @@ -66769,16 +69316,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 === 158 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 160 /* ComputedPropertyName */ ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 288 /* PropertyAssignment */ || - memberDecl.kind === 289 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 290 /* PropertyAssignment */ || + memberDecl.kind === 291 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 288 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + var type = memberDecl.kind === 290 /* 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 === 289 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : + memberDecl.kind === 291 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJavascript) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -66790,7 +69337,7 @@ var ts; checkTypeAssignableTo(type, getTypeFromTypeNode(enumTag.typeExpression), memberDecl); } } - objectFlags |= ts.getObjectFlags(type) & 3670016 /* PropagatingFlags */; + objectFlags |= ts.getObjectFlags(type) & 917504 /* PropagatingFlags */; var nameType = computedNameType && isTypeUsableAsPropertyName(computedNameType) ? computedNameType : undefined; var prop = nameType ? createSymbol(4 /* Property */ | member.flags, getPropertyNameFromType(nameType), checkFlags | 4096 /* Late */) : @@ -66801,8 +69348,8 @@ var ts; 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 === 288 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 289 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 290 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 291 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216 /* Optional */; } @@ -66828,7 +69375,7 @@ var ts; member = prop; allPropertiesTable === null || allPropertiesTable === void 0 ? void 0 : allPropertiesTable.set(prop.escapedName, prop); } - else if (memberDecl.kind === 290 /* SpreadAssignment */) { + else if (memberDecl.kind === 292 /* SpreadAssignment */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } @@ -66840,15 +69387,20 @@ var ts; hasComputedNumberProperty = false; } var type = getReducedType(checkExpression(memberDecl.expression)); - if (!isValidSpreadType(type)) { - error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); - return errorType; + if (isValidSpreadType(type)) { + if (allPropertiesTable) { + checkSpreadPropOverrides(type, allPropertiesTable, memberDecl); + } + offset = propertiesArray.length; + if (spread === errorType) { + continue; + } + spread = getSpreadType(spread, type, node.symbol, objectFlags, inConstContext); } - if (allPropertiesTable) { - checkSpreadPropOverrides(type, allPropertiesTable, memberDecl); + else { + error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); + spread = errorType; } - spread = getSpreadType(spread, type, node.symbol, objectFlags, inConstContext); - offset = propertiesArray.length; continue; } else { @@ -66857,7 +69409,7 @@ 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 === 167 /* GetAccessor */ || memberDecl.kind === 168 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 169 /* GetAccessor */ || memberDecl.kind === 170 /* SetAccessor */); checkNodeDeferred(memberDecl); } if (computedNameType && !(computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */)) { @@ -66882,7 +69434,7 @@ 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 !== 290 /* SpreadAssignment */) { + if (contextualTypeHasPattern && node.parent.kind !== 292 /* 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)) { @@ -66894,6 +69446,9 @@ var ts; } } } + if (spread === errorType) { + return errorType; + } if (spread !== emptyObjectType) { if (propertiesArray.length > 0) { spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, objectFlags, inConstContext); @@ -66910,9 +69465,9 @@ var ts; var stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node, offset, propertiesArray, 0 /* String */) : undefined; var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, offset, propertiesArray, 1 /* Number */) : undefined; var result = createAnonymousType(node.symbol, propertiesTable, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); - result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 1048576 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 262144 /* ContainsObjectOrArrayLiteral */; if (isJSObjectLiteral) { - result.objectFlags |= 16384 /* JSLiteral */; + result.objectFlags |= 8192 /* JSLiteral */; } if (patternWithComputedProperties) { result.objectFlags |= 512 /* ObjectLiteralPatternWithComputedProperties */; @@ -66978,7 +69533,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 === 78 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); + return tagName.kind === 79 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); } function checkJsxAttribute(node, checkMode) { return node.initializer @@ -67002,14 +69557,14 @@ var ts; var hasSpreadAnyType = false; var typeToIntersect; var explicitlySpecifyChildrenAttribute = false; - var objectFlags = 4096 /* JsxAttributes */; + var objectFlags = 2048 /* 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) & 3670016 /* PropagatingFlags */; + objectFlags |= ts.getObjectFlags(exprType) & 917504 /* PropagatingFlags */; var attributeSymbol = createSymbol(4 /* Property */ | member.flags, member.escapedName); attributeSymbol.declarations = member.declarations; attributeSymbol.parent = member.parent; @@ -67025,7 +69580,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 282 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 284 /* JsxSpreadAttribute */); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, /*readonly*/ false); attributesTable = ts.createSymbolTable(); @@ -67051,7 +69606,7 @@ var ts; } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 273 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 275 /* 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); @@ -67067,7 +69622,7 @@ var ts; // 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); childrenPropSymbol.type = childrenTypes.length === 1 ? childrenTypes[0] : - childrenContextualType && forEachType(childrenContextualType, isTupleLikeType) ? createTupleType(childrenTypes) : + childrenContextualType && someType(childrenContextualType, isTupleLikeType) ? createTupleType(childrenTypes) : createArrayType(getUnionType(childrenTypes)); // Fake up a property declaration for the children childrenPropSymbol.valueDeclaration = ts.factory.createPropertySignature(/*modifiers*/ undefined, ts.unescapeLeadingUnderscores(jsxChildrenPropertyName), /*questionToken*/ undefined, /*type*/ undefined); @@ -67093,7 +69648,7 @@ var ts; function createJsxAttributesType() { objectFlags |= freshObjectLiteralFlag; var result = createAnonymousType(attributes.symbol, attributesTable, ts.emptyArray, ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); - result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 1048576 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 262144 /* ContainsObjectOrArrayLiteral */; return result; } } @@ -67108,7 +69663,7 @@ var ts; childrenTypes.push(stringType); } } - else if (child.kind === 283 /* JsxExpression */ && !child.expression) { + else if (child.kind === 285 /* JsxExpression */ && !child.expression) { continue; // empty jsx expressions don't *really* count as present children } else { @@ -67259,7 +69814,7 @@ var ts; else if (propertiesOfJsxElementAttribPropInterface.length === 1) { return propertiesOfJsxElementAttribPropInterface[0].escapedName; } - else if (propertiesOfJsxElementAttribPropInterface.length > 1) { + else if (propertiesOfJsxElementAttribPropInterface.length > 1 && jsxElementAttribPropInterfaceSym.declarations) { // More than one property on ElementAttributesProperty is an error error(jsxElementAttribPropInterfaceSym.declarations[0], ts.Diagnostics.The_global_type_JSX_0_may_not_have_more_than_one_property, ts.unescapeLeadingUnderscores(nameOfAttribPropContainer)); } @@ -67369,11 +69924,11 @@ var ts; if (!links.resolvedJsxElementAttributesType) { var symbol = getIntrinsicTagSymbol(node); if (links.jsxFlags & 1 /* IntrinsicNamedElement */) { - return links.resolvedJsxElementAttributesType = getTypeOfSymbol(symbol); + return links.resolvedJsxElementAttributesType = getTypeOfSymbol(symbol) || errorType; } else if (links.jsxFlags & 2 /* IntrinsicIndexedElement */) { return links.resolvedJsxElementAttributesType = - getIndexTypeOfType(getDeclaredTypeOfSymbol(symbol), 0 /* String */); + getIndexTypeOfType(getJsxType(JsxNames.IntrinsicElements, node), 0 /* String */) || errorType; } else { return links.resolvedJsxElementAttributesType = errorType; @@ -67526,9 +70081,12 @@ var ts; * @param type The type of the object whose property is being accessed. (Not the type of the property.) * @param prop The symbol for the property being accessed. */ - function checkPropertyAccessibility(node, isSuper, type, prop) { - var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 157 /* QualifiedName */ ? node.right : node.kind === 195 /* ImportType */ ? node : node.name; + function checkPropertyAccessibility(node, isSuper, writing, type, prop, reportError) { + if (reportError === void 0) { reportError = true; } + var flags = ts.getDeclarationModifierFlagsFromSymbol(prop, writing); + var errorNode = node.kind === 159 /* QualifiedName */ ? node.right : + node.kind === 197 /* ImportType */ ? node : + node.kind === 200 /* BindingElement */ && node.propertyName ? node.propertyName : node.name; if (isSuper) { // TS 1.0 spec (April 2014): 4.8.2 // - In a constructor, instance member function, instance member accessor, or @@ -67539,7 +70097,9 @@ var ts; // a super property access is permitted and must specify a public static member function of the base class. if (languageVersion < 2 /* ES2015 */) { if (symbolHasNonMethodDeclaration(prop)) { - error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); + if (reportError) { + error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); + } return false; } } @@ -67548,24 +70108,22 @@ var ts; // This error could mask a private property access error. But, a member // cannot simultaneously be private and abstract, so this will trigger an // additional error elsewhere. - error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(getDeclaringClass(prop))); + if (reportError) { + error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(getDeclaringClass(prop))); + } return false; } } // Referencing abstract properties within their own constructors is not allowed - if ((flags & 128 /* Abstract */) && ts.isThisProperty(node) && symbolHasNonMethodDeclaration(prop)) { + if ((flags & 128 /* Abstract */) && symbolHasNonMethodDeclaration(prop) && + (ts.isThisProperty(node) || ts.isThisInitializedObjectBindingExpression(node) || ts.isObjectBindingPattern(node.parent) && ts.isThisInitializedDeclaration(node.parent.parent))) { var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (declaringClassDeclaration && isNodeUsedDuringClassInitialization(node)) { - error(errorNode, ts.Diagnostics.Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor, symbolToString(prop), ts.getTextOfIdentifierOrLiteral(declaringClassDeclaration.name)); // TODO: GH#18217 - return false; - } - } - if (ts.isPropertyAccessExpression(node) && ts.isPrivateIdentifier(node.name)) { - if (!ts.getContainingClass(node)) { - error(errorNode, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); + if (reportError) { + error(errorNode, ts.Diagnostics.Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor, symbolToString(prop), ts.getTextOfIdentifierOrLiteral(declaringClassDeclaration.name)); // TODO: GH#18217 + } return false; } - return true; } // Public properties are otherwise accessible. if (!(flags & 24 /* NonPublicAccessibilityModifier */)) { @@ -67576,7 +70134,9 @@ var ts; if (flags & 8 /* Private */) { var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (!isNodeWithinClass(node, declaringClassDeclaration)) { - error(errorNode, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(getDeclaringClass(prop))); + if (reportError) { + error(errorNode, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(getDeclaringClass(prop))); + } return false; } return true; @@ -67590,7 +70150,7 @@ var ts; // of the property as base classes var enclosingClass = forEachEnclosingClass(node, function (enclosingDeclaration) { var enclosingClass = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingDeclaration)); - return isClassDerivedFromDeclaringClasses(enclosingClass, prop) ? enclosingClass : undefined; + return isClassDerivedFromDeclaringClasses(enclosingClass, prop, writing) ? enclosingClass : undefined; }); // A protected property is accessible if the property is within the declaring class or classes derived from it if (!enclosingClass) { @@ -67598,7 +70158,9 @@ var ts; // static member access is disallow var thisParameter = void 0; if (flags & 32 /* Static */ || !(thisParameter = getThisParameterFromNodeContext(node)) || !thisParameter.type) { - error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || type)); + if (reportError) { + error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || type)); + } return false; } var thisType = getTypeFromTypeNode(thisParameter.type); @@ -67613,7 +70175,9 @@ var ts; type = type.isThisType ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(type); // TODO: GH#18217 Use a different variable that's allowed to be undefined } if (!type || !hasBaseType(type, enclosingClass)) { - error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); + if (reportError) { + error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_This_is_an_instance_of_class_2, symbolToString(prop), typeToString(enclosingClass), typeToString(type)); + } return false; } return true; @@ -67669,20 +70233,20 @@ var ts; } return nonNullType; } - function checkPropertyAccessExpression(node) { - return node.flags & 32 /* OptionalChain */ ? checkPropertyAccessChain(node) : - checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullExpression(node.expression), node.name); + function checkPropertyAccessExpression(node, checkMode) { + return node.flags & 32 /* OptionalChain */ ? checkPropertyAccessChain(node, checkMode) : + checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullExpression(node.expression), node.name, checkMode); } - function checkPropertyAccessChain(node) { + function checkPropertyAccessChain(node, checkMode) { var leftType = checkExpression(node.expression); var nonOptionalType = getOptionalExpressionType(leftType, node.expression); - return propagateOptionalTypeMarker(checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullType(nonOptionalType, node.expression), node.name), node, nonOptionalType !== leftType); + return propagateOptionalTypeMarker(checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullType(nonOptionalType, node.expression), node.name, checkMode), node, nonOptionalType !== leftType); } - function checkQualifiedName(node) { - return checkPropertyAccessExpressionOrQualifiedName(node, node.left, checkNonNullExpression(node.left), node.right); + function checkQualifiedName(node, checkMode) { + return checkPropertyAccessExpressionOrQualifiedName(node, node.left, checkNonNullExpression(node.left), node.right, checkMode); } function isMethodAccessForCall(node) { - while (node.parent.kind === 207 /* ParenthesizedExpression */) { + while (node.parent.kind === 209 /* ParenthesizedExpression */) { node = node.parent; } return ts.isCallOrNewExpression(node.parent) && node.parent.expression === node; @@ -67717,14 +70281,13 @@ var ts; } var diagName = diagnosticName(right); if (propertyOnType) { - var typeValueDecl = propertyOnType.valueDeclaration; - var typeClass_1 = ts.getContainingClass(typeValueDecl); - ts.Debug.assert(!!typeClass_1); + var typeValueDecl = ts.Debug.checkDefined(propertyOnType.valueDeclaration); + var typeClass_1 = ts.Debug.checkDefined(ts.getContainingClass(typeValueDecl)); // We found a private identifier property with the same description. // Either: // - There is a lexically scoped private identifier AND it shadows the one we found on the type. // - It is an attempt to access the private identifier outside of the class. - if (lexicallyScopedIdentifier) { + if (lexicallyScopedIdentifier === null || lexicallyScopedIdentifier === void 0 ? void 0 : lexicallyScopedIdentifier.valueDeclaration) { var lexicalValueDecl = lexicallyScopedIdentifier.valueDeclaration; var lexicalClass = ts.getContainingClass(lexicalValueDecl); ts.Debug.assert(!!lexicalClass); @@ -67743,17 +70306,42 @@ var ts; return (isConstructorDeclaredProperty(prop) || ts.isThisProperty(node) && isAutoTypedProperty(prop)) && ts.getThisContainer(node, /*includeArrowFunctions*/ true) === getDeclaringConstructor(prop); } - function checkPropertyAccessExpressionOrQualifiedName(node, left, leftType, right) { + 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); - if (ts.isPrivateIdentifier(right)) { - checkExternalEmitHelpers(node, 524288 /* ClassPrivateFieldGet */); - } 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 (assignmentKind !== 1 /* Definite */) { + checkExternalEmitHelpers(node, 524288 /* ClassPrivateFieldGet */); + } + } var lexicallyScopedSymbol = lookupSymbolForPrivateIdentifierDeclaration(right.escapedText, right); + if (assignmentKind && lexicallyScopedSymbol && lexicallyScopedSymbol.valueDeclaration && ts.isMethodDeclaration(lexicallyScopedSymbol.valueDeclaration)) { + grammarErrorOnNode(right, ts.Diagnostics.Cannot_assign_to_private_method_0_Private_methods_are_not_writable, ts.idText(right)); + } + if ((lexicallyScopedSymbol === null || lexicallyScopedSymbol === void 0 ? void 0 : lexicallyScopedSymbol.valueDeclaration) && (compilerOptions.target === 99 /* ESNext */ && !useDefineForClassFields)) { + var lexicalClass_1 = ts.getContainingClass(lexicallyScopedSymbol.valueDeclaration); + var parentStaticFieldInitializer = ts.findAncestor(node, function (n) { + if (n === lexicalClass_1) + return "quit"; + if (ts.isPropertyDeclaration(n.parent) && ts.hasStaticModifier(n.parent) && n.parent.initializer === n && n.parent.parent === lexicalClass_1) { + return true; + } + return false; + }); + if (parentStaticFieldInitializer) { + var parentStaticFieldInitializerSymbol = getSymbolOfNode(parentStaticFieldInitializer.parent); + ts.Debug.assert(parentStaticFieldInitializerSymbol, "Initializer without declaration symbol"); + var diagnostic = error(node, ts.Diagnostics.Property_0_may_not_be_used_in_a_static_property_s_initializer_in_the_same_class_when_target_is_esnext_and_useDefineForClassFields_is_false, ts.symbolName(lexicallyScopedSymbol)); + ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(parentStaticFieldInitializer.parent, ts.Diagnostics.Initializer_for_property_0, ts.symbolName(parentStaticFieldInitializerSymbol))); + } + } if (isAnyLike) { if (lexicallyScopedSymbol) { return apparentType; @@ -67768,6 +70356,12 @@ var ts; if (!prop && checkPrivateIdentifierPropertyAccess(leftType, right, lexicallyScopedSymbol)) { return errorType; } + else { + var isSetonlyAccessor = prop && prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); + if (isSetonlyAccessor && assignmentKind !== 1 /* Definite */) { + error(node, ts.Diagnostics.Private_accessor_was_defined_without_a_getter); + } + } } else { if (isAnyLike) { @@ -67778,7 +70372,11 @@ var ts; } prop = getPropertyOfType(apparentType, right.escapedText); } - if (ts.isIdentifier(left) && parentSymbol && !(prop && isConstEnumOrConstEnumOnlyModule(prop))) { + // In `Foo.Bar.Baz`, 'Foo' is not referenced if 'Bar' is a const enum or a module containing only const enums. + // The exceptions are: + // 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)) || ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(node))) { markAliasReferenced(parentSymbol, node); } var propType; @@ -67811,44 +70409,50 @@ var ts; } } else { - if (getDeclarationNodeFlagsFromSymbol(prop) & 134217728 /* Deprecated */ && isUncalledFunctionReference(node, prop)) { - errorOrSuggestion(/* isError */ false, right, ts.Diagnostics._0_is_deprecated, right.escapedText); + if (prop.declarations && getDeclarationNodeFlagsFromSymbol(prop) & 134217728 /* Deprecated */ && isUncalledFunctionReference(node, prop)) { + addDeprecatedSuggestion(right, prop.declarations, right.escapedText); } checkPropertyNotUsedBeforeDeclaration(prop, node, right); - markPropertyAsReferenced(prop, node, left.kind === 107 /* ThisKeyword */); + markPropertyAsReferenced(prop, node, isSelfTypeAccess(left, parentSymbol)); getNodeLinks(node).resolvedSymbol = prop; - checkPropertyAccessibility(node, left.kind === 105 /* SuperKeyword */, apparentType, prop); + var writing = ts.isWriteAccess(node); + checkPropertyAccessibility(node, left.kind === 106 /* 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; } - propType = isThisPropertyAccessInConstructor(node, prop) ? autoType : getConstraintForLocation(getTypeOfSymbol(prop), node); + propType = isThisPropertyAccessInConstructor(node, prop) ? autoType : writing ? getSetAccessorTypeOfSymbol(prop) : getTypeOfSymbol(prop); } - return getFlowTypeOfAccessExpression(node, prop, propType, right); + return getFlowTypeOfAccessExpression(node, prop, propType, right, checkMode); } - function getFlowTypeOfAccessExpression(node, prop, propType, errorNode) { + function getFlowTypeOfAccessExpression(node, prop, propType, errorNode, checkMode) { // Only compute control flow type if this is a property access expression that isn't an // assignment target, and the referenced property was declared as a variable, property, // accessor, or optional method. var assignmentKind = ts.getAssignmentTargetKind(node); - if (!ts.isAccessExpression(node) || - assignmentKind === 1 /* Definite */ || - prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */)) { + if (assignmentKind === 1 /* Definite */) { + return removeMissingType(propType, !!(prop && prop.flags & 16777216 /* Optional */)); + } + if (prop && + !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) + && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */) + && !isDuplicatedCommonJSExport(prop.declarations)) { return propType; } if (propType === autoType) { return getFlowTypeOfProperty(node, prop); } + propType = getNarrowableTypeForReference(propType, node, checkMode); // If strict null checks and strict property initialization checks are enabled, if we have // a this.xxx property access, if the property is an instance property without an initializer, // and if we are in a constructor of the same class as the property declaration, assume that // the property is uninitialized at the top of the control flow. var assumeUninitialized = false; - if (strictNullChecks && strictPropertyInitialization && node.expression.kind === 107 /* ThisKeyword */) { + if (strictNullChecks && strictPropertyInitialization && ts.isAccessExpression(node) && node.expression.kind === 108 /* ThisKeyword */) { var declaration = prop && prop.valueDeclaration; if (declaration && isInstancePropertyWithoutInitializer(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 166 /* Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 8388608 /* Ambient */)) { + if (flowContainer.kind === 168 /* Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 8388608 /* Ambient */)) { assumeUninitialized = true; } } @@ -67875,13 +70479,14 @@ var ts; var diagnosticMessage; var declarationName = ts.idText(right); if (isInPropertyInitializer(node) + && !isOptionalPropertyDeclaration(valueDeclaration) && !(ts.isAccessExpression(node) && ts.isAccessExpression(node.expression)) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) - && !isPropertyDeclaredInAncestorClass(prop)) { + && (compilerOptions.useDefineForClassFields || !isPropertyDeclaredInAncestorClass(prop))) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 252 /* ClassDeclaration */ && - node.parent.kind !== 173 /* TypeReference */ && + else if (valueDeclaration.kind === 254 /* ClassDeclaration */ && + node.parent.kind !== 175 /* TypeReference */ && !(valueDeclaration.flags & 8388608 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); @@ -67893,22 +70498,22 @@ var ts; function isInPropertyInitializer(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return true; - case 288 /* PropertyAssignment */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 290 /* SpreadAssignment */: - case 158 /* ComputedPropertyName */: - case 228 /* TemplateSpan */: - case 283 /* JsxExpression */: - case 280 /* JsxAttribute */: - case 281 /* JsxAttributes */: - case 282 /* JsxSpreadAttribute */: - case 275 /* JsxOpeningElement */: - case 223 /* ExpressionWithTypeArguments */: - case 286 /* HeritageClause */: + case 290 /* PropertyAssignment */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 292 /* SpreadAssignment */: + case 160 /* ComputedPropertyName */: + case 230 /* TemplateSpan */: + case 285 /* JsxExpression */: + case 282 /* JsxAttribute */: + case 283 /* JsxAttributes */: + case 284 /* JsxSpreadAttribute */: + case 277 /* JsxOpeningElement */: + case 225 /* ExpressionWithTypeArguments */: + case 288 /* HeritageClause */: return false; default: return ts.isExpressionNode(node) ? false : "quit"; @@ -67980,7 +70585,10 @@ var ts; relatedInfo = suggestion.valueDeclaration && ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestedName); } else { - errorInfo = ts.chainDiagnosticMessages(elaborateNeverIntersection(errorInfo, containingType), ts.Diagnostics.Property_0_does_not_exist_on_type_1, missingProperty, container); + var diagnostic = containerSeemsToBeEmptyDomElement(containingType) + ? ts.Diagnostics.Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom + : ts.Diagnostics.Property_0_does_not_exist_on_type_1; + errorInfo = ts.chainDiagnosticMessages(elaborateNeverIntersection(errorInfo, containingType), diagnostic, missingProperty, container); } } } @@ -67991,9 +70599,14 @@ var ts; } diagnostics.add(resultDiagnostic); } + function containerSeemsToBeEmptyDomElement(containingType) { + return (compilerOptions.lib && !compilerOptions.lib.includes("dom")) && + everyContainedType(containingType, function (type) { return type.symbol && /^(EventTarget|Node|((HTML[a-zA-Z]*)?Element))$/.test(ts.unescapeLeadingUnderscores(type.symbol.escapedName)); }) && + isEmptyObjectType(containingType); + } function typeHasStaticProperty(propName, containingType) { var prop = containingType.symbol && getPropertyOfType(getTypeOfSymbol(containingType.symbol), propName); - return prop !== undefined && prop.valueDeclaration && ts.hasSyntacticModifier(prop.valueDeclaration, 32 /* Static */); + return prop !== undefined && !!prop.valueDeclaration && ts.hasSyntacticModifier(prop.valueDeclaration, 32 /* Static */); } function getSuggestedLibForNonExistentName(name) { var missingName = diagnosticName(name); @@ -68024,7 +70637,15 @@ var ts; } } function getSuggestedSymbolForNonexistentProperty(name, containingType) { - return getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 111551 /* Value */); + var props = getPropertiesOfType(containingType); + if (typeof name !== "string") { + var parent_2 = name.parent; + if (ts.isPropertyAccessExpression(parent_2)) { + props = ts.filter(props, function (prop) { return isValidPropertyAccessForCompletions(parent_2, containingType, prop); }); + } + name = ts.idText(name); + } + return getSpellingSuggestionForName(name, props, 111551 /* Value */); } function getSuggestedSymbolForNonexistentJSXAttribute(name, containingType) { var strName = ts.isString(name) ? name : ts.idText(name); @@ -68119,20 +70740,20 @@ var ts; return undefined; } } - function markPropertyAsReferenced(prop, nodeForCheckWriteOnly, isThisAccess) { + function markPropertyAsReferenced(prop, nodeForCheckWriteOnly, isSelfTypeAccess) { var valueDeclaration = prop && (prop.flags & 106500 /* ClassMember */) && prop.valueDeclaration; if (!valueDeclaration) { return; } var hasPrivateModifier = ts.hasEffectiveModifier(valueDeclaration, 8 /* Private */); - var hasPrivateIdentifier = ts.isNamedDeclaration(prop.valueDeclaration) && ts.isPrivateIdentifier(prop.valueDeclaration.name); + 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 */)) { return; } - if (isThisAccess) { + if (isSelfTypeAccess) { // Find any FunctionLikeDeclaration because those create a new 'this' binding. But this should only matter for methods (or getters/setters). var containingMethod = ts.findAncestor(nodeForCheckWriteOnly, ts.isFunctionLikeDeclaration); if (containingMethod && containingMethod.symbol === prop) { @@ -68141,18 +70762,22 @@ var ts; } (ts.getCheckFlags(prop) & 1 /* Instantiated */ ? getSymbolLinks(prop).target : prop).isReferenced = 67108863 /* All */; } + function isSelfTypeAccess(name, parent) { + return name.kind === 108 /* ThisKeyword */ + || !!parent && ts.isEntityNameExpression(name) && parent === getResolvedSymbol(ts.getFirstIdentifier(name)); + } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 201 /* PropertyAccessExpression */: - return isValidPropertyAccessWithType(node, node.expression.kind === 105 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); - case 157 /* QualifiedName */: + case 203 /* PropertyAccessExpression */: + return isValidPropertyAccessWithType(node, node.expression.kind === 106 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); + case 159 /* QualifiedName */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getWidenedType(checkExpression(node.left))); - case 195 /* ImportType */: + case 197 /* ImportType */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind === 201 /* PropertyAccessExpression */ && node.expression.kind === 105 /* SuperKeyword */, property.escapedName, type); + return isValidPropertyAccessWithType(node, node.kind === 203 /* PropertyAccessExpression */ && node.expression.kind === 106 /* SuperKeyword */, property.escapedName, type); // Previously we validated the 'this' type of methods but this adversely affected performance. See #31377 for more context. } function isValidPropertyAccessWithType(node, isSuper, propertyName, type) { @@ -68161,11 +70786,11 @@ var ts; } var prop = getPropertyOfType(type, propertyName); if (prop) { - if (ts.isPropertyAccessExpression(node) && prop.valueDeclaration && ts.isPrivateIdentifierPropertyDeclaration(prop.valueDeclaration)) { + if (prop.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(prop.valueDeclaration)) { var declClass_1 = ts.getContainingClass(prop.valueDeclaration); return !ts.isOptionalChain(node) && !!ts.findAncestor(node, function (parent) { return parent === declClass_1; }); } - return checkPropertyAccessibility(node, isSuper, type, prop); + return checkPropertyAccessibility(node, isSuper, /*writing*/ false, type, prop, /* reportError */ false); } // In js files properties of unions are allowed in completion return ts.isInJSFile(node) && (type.flags & 1048576 /* Union */) !== 0 && type.types.some(function (elementType) { return isValidPropertyAccessWithType(node, isSuper, propertyName, elementType); }); @@ -68175,13 +70800,13 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 250 /* VariableDeclarationList */) { + if (initializer.kind === 252 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 78 /* Identifier */) { + else if (initializer.kind === 79 /* Identifier */) { return getResolvedSymbol(initializer); } return undefined; @@ -68198,13 +70823,13 @@ var ts; */ function isForInVariableForNumericPropertyNames(expr) { var e = ts.skipParentheses(expr); - if (e.kind === 78 /* Identifier */) { + if (e.kind === 79 /* Identifier */) { var symbol = getResolvedSymbol(e); if (symbol.flags & 3 /* Variable */) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 238 /* ForInStatement */ && + if (node.kind === 240 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -68217,16 +70842,16 @@ var ts; } return false; } - function checkIndexedAccess(node) { - return node.flags & 32 /* OptionalChain */ ? checkElementAccessChain(node) : - checkElementAccessExpression(node, checkNonNullExpression(node.expression)); + function checkIndexedAccess(node, checkMode) { + return node.flags & 32 /* OptionalChain */ ? checkElementAccessChain(node, checkMode) : + checkElementAccessExpression(node, checkNonNullExpression(node.expression), checkMode); } - function checkElementAccessChain(node) { + function checkElementAccessChain(node, checkMode) { var exprType = checkExpression(node.expression); var nonOptionalType = getOptionalExpressionType(exprType, node.expression); - return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression)), node, nonOptionalType !== exprType); + return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression), checkMode), node, nonOptionalType !== exprType); } - function checkElementAccessExpression(node, exprType) { + function checkElementAccessExpression(node, exprType, checkMode) { var objectType = ts.getAssignmentTargetKind(node) !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; var indexExpression = node.argumentExpression; var indexType = checkExpression(indexExpression); @@ -68239,45 +70864,10 @@ var ts; } var effectiveIndexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType; var accessFlags = ts.isAssignmentTarget(node) ? - 2 /* Writing */ | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 1 /* NoIndexSignatures */ : 0) : - 0 /* None */; - var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, /*noUncheckedIndexedAccessCandidate*/ undefined, node, accessFlags | 16 /* ExpressionPosition */) || errorType; - return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, indexedAccessType.symbol, indexedAccessType, indexExpression), node); - } - function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) { - if (expressionType === errorType) { - // There is already an error, so no need to report one. - return false; - } - if (!ts.isWellKnownSymbolSyntactically(expression)) { - return false; - } - // Make sure the property type is the primitive symbol type - if ((expressionType.flags & 12288 /* ESSymbolLike */) === 0) { - if (reportError) { - error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression)); - } - return false; - } - // The name is Symbol., so make sure Symbol actually resolves to the - // global Symbol object - var leftHandSide = expression.expression; - var leftHandSideSymbol = getResolvedSymbol(leftHandSide); - if (!leftHandSideSymbol) { - return false; - } - var globalESSymbol = getGlobalESSymbolConstructorSymbol(/*reportErrors*/ true); - if (!globalESSymbol) { - // Already errored when we tried to look up the symbol - return false; - } - if (leftHandSideSymbol !== globalESSymbol) { - if (reportError) { - error(leftHandSide, ts.Diagnostics.Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object); - } - return false; - } - return true; + 4 /* Writing */ | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 2 /* NoIndexSignatures */ : 0) : + 32 /* ExpressionPosition */; + var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, accessFlags, node) || errorType; + return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, getNodeLinks(node).resolvedSymbol, indexedAccessType, indexExpression, checkMode), node); } function callLikeExpressionMayHaveTypeArguments(node) { return ts.isCallOrNewExpression(node) || ts.isTaggedTemplateExpression(node) || ts.isJsxOpeningLikeElement(node); @@ -68288,13 +70878,13 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 205 /* TaggedTemplateExpression */) { + if (node.kind === 207 /* TaggedTemplateExpression */) { checkExpression(node.template); } else if (ts.isJsxOpeningLikeElement(node)) { checkExpression(node.attributes); } - else if (node.kind !== 161 /* Decorator */) { + else if (node.kind !== 163 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -68358,7 +70948,7 @@ var ts; } } function isSpreadArgument(arg) { - return !!arg && (arg.kind === 220 /* SpreadElement */ || arg.kind === 227 /* SyntheticExpression */ && arg.isSpread); + return !!arg && (arg.kind === 222 /* SpreadElement */ || arg.kind === 229 /* SyntheticExpression */ && arg.isSpread); } function getSpreadArgumentIndex(args) { return ts.findIndex(args, isSpreadArgument); @@ -68375,9 +70965,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 === 205 /* TaggedTemplateExpression */) { + if (node.kind === 207 /* TaggedTemplateExpression */) { argCount = args.length; - if (node.template.kind === 218 /* TemplateExpression */) { + if (node.template.kind === 220 /* 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. @@ -68392,7 +70982,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 161 /* Decorator */) { + else if (node.kind === 163 /* Decorator */) { argCount = getDecoratorArgumentCount(node, signature); } else if (ts.isJsxOpeningLikeElement(node)) { @@ -68406,7 +70996,7 @@ var ts; } else if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 204 /* NewExpression */); + ts.Debug.assert(node.kind === 206 /* NewExpression */); return getMinArgumentCount(signature) === 0; } else { @@ -68481,7 +71071,7 @@ var ts; }); if (!inferenceContext) { applyToReturnTypes(contextualSignature, signature, function (source, target) { - inferTypes(context.inferences, source, target, 64 /* ReturnType */); + inferTypes(context.inferences, source, target, 128 /* ReturnType */); }); } return getSignatureInstantiation(signature, getInferredTypes(context), ts.isInJSFile(contextualSignature.declaration)); @@ -68492,6 +71082,15 @@ var ts; inferTypes(context.inferences, checkAttrType, paramType); return getInferredTypes(context); } + function getThisArgumentType(thisArgumentNode) { + if (!thisArgumentNode) { + return voidType; + } + var thisArgumentType = checkExpression(thisArgumentNode); + return ts.isOptionalChainRoot(thisArgumentNode.parent) ? getNonNullableType(thisArgumentType) : + ts.isOptionalChain(thisArgumentNode.parent) ? removeOptionalTypeMarker(thisArgumentType) : + thisArgumentType; + } function inferTypeArguments(node, signature, args, checkMode, context) { if (ts.isJsxOpeningLikeElement(node)) { return inferJsxTypeArguments(node, signature, checkMode, context); @@ -68500,7 +71099,7 @@ 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 !== 161 /* Decorator */) { + if (node.kind !== 163 /* Decorator */) { var contextualType = getContextualType(node, ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }) ? 8 /* SkipBindingPatterns */ : 0 /* None */); if (contextualType) { // We clone the inference context to avoid disturbing a resolution in progress for an @@ -68522,7 +71121,7 @@ var ts; instantiatedType; var inferenceTargetType = getReturnTypeOfSignature(signature); // Inferences made from return types have lower priority than all other inferences. - inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 64 /* ReturnType */); + inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* 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 // the source type uses the outer context's return mapper (which excludes inferences made from @@ -68544,12 +71143,11 @@ var ts; var thisType = getThisTypeOfSignature(signature); if (thisType) { var thisArgumentNode = getThisArgumentOfCall(node); - var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; - inferTypes(context.inferences, thisArgumentType, thisType); + inferTypes(context.inferences, getThisArgumentType(thisArgumentNode), thisType); } for (var i = 0; i < argCount; i++) { var arg = args[i]; - if (arg.kind !== 222 /* OmittedExpression */) { + if (arg.kind !== 224 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode); inferTypes(context.inferences, argType, paramType); @@ -68573,7 +71171,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 === 227 /* SyntheticExpression */ ? arg.type : + return getMutableArrayOrTupleType(arg.kind === 229 /* SyntheticExpression */ ? arg.type : checkExpressionWithContextualType(arg.expression, restType, context, checkMode)); } } @@ -68583,24 +71181,24 @@ var ts; for (var i = index; i < argCount; i++) { var arg = args[i]; if (isSpreadArgument(arg)) { - var spreadType = arg.kind === 227 /* SyntheticExpression */ ? arg.type : checkExpression(arg.expression); + var spreadType = arg.kind === 229 /* SyntheticExpression */ ? arg.type : checkExpression(arg.expression); if (isArrayLikeType(spreadType)) { types.push(spreadType); flags.push(8 /* Variadic */); } else { - types.push(checkIteratedTypeOrElementType(33 /* Spread */, spreadType, undefinedType, arg.kind === 220 /* SpreadElement */ ? arg.expression : arg)); + types.push(checkIteratedTypeOrElementType(33 /* Spread */, spreadType, undefinedType, arg.kind === 222 /* SpreadElement */ ? arg.expression : arg)); flags.push(4 /* Rest */); } } else { - var contextualType = getIndexedAccessType(restType, getLiteralType(i - index)); + var contextualType = getIndexedAccessType(restType, getLiteralType(i - index), 256 /* Contextual */); var argType = checkExpressionWithContextualType(arg, contextualType, context, checkMode); var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 131068 /* Primitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */); types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType)); flags.push(1 /* Required */); } - if (arg.kind === 227 /* SyntheticExpression */ && arg.tupleNameSource) { + if (arg.kind === 229 /* SyntheticExpression */ && arg.tupleNameSource) { names.push(arg.tupleNameSource); } } @@ -68744,24 +71342,12 @@ var ts; return undefined; } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 204 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 206 /* 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. var thisArgumentNode = getThisArgumentOfCall(node); - var thisArgumentType = void 0; - if (thisArgumentNode) { - thisArgumentType = checkExpression(thisArgumentNode); - if (ts.isOptionalChainRoot(thisArgumentNode.parent)) { - thisArgumentType = getNonNullableType(thisArgumentType); - } - else if (ts.isOptionalChain(thisArgumentNode.parent)) { - thisArgumentType = removeOptionalTypeMarker(thisArgumentType); - } - } - else { - thisArgumentType = voidType; - } + var thisArgumentType = getThisArgumentType(thisArgumentNode); var errorNode = reportErrors ? (thisArgumentNode || node) : undefined; var headMessage_1 = ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1; if (!checkTypeRelatedTo(thisArgumentType, thisType, relation, errorNode, headMessage_1, containingMessageChain, errorOutputContainer)) { @@ -68774,7 +71360,7 @@ 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 !== 222 /* OmittedExpression */) { + if (arg.kind !== 224 /* 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), @@ -68819,7 +71405,7 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 203 /* CallExpression */) { + if (node.kind === 205 /* CallExpression */) { var callee = ts.skipOuterExpressions(node.expression); if (ts.isAccessExpression(callee)) { return callee.expression; @@ -68836,17 +71422,17 @@ var ts; * Returns the effective arguments for an expression that works like a function invocation. */ function getEffectiveCallArguments(node) { - if (node.kind === 205 /* TaggedTemplateExpression */) { + if (node.kind === 207 /* TaggedTemplateExpression */) { var template = node.template; var args_3 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())]; - if (template.kind === 218 /* TemplateExpression */) { + if (template.kind === 220 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_3.push(span.expression); }); } return args_3; } - if (node.kind === 161 /* Decorator */) { + if (node.kind === 163 /* Decorator */) { return getEffectiveDecoratorArguments(node); } if (ts.isJsxOpeningLikeElement(node)) { @@ -68857,10 +71443,10 @@ var ts; if (spreadIndex >= 0) { // Create synthetic arguments from spreads of tuple types. var effectiveArgs_1 = args.slice(0, spreadIndex); - var _loop_20 = function (i) { + var _loop_21 = function (i) { var arg = args[i]; // We can call checkExpressionCached because spread expressions never have a contextual type. - var spreadType = arg.kind === 220 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression)); + var spreadType = arg.kind === 222 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression)); if (spreadType && isTupleType(spreadType)) { ts.forEach(getTypeArguments(spreadType), function (t, i) { var _a; @@ -68874,7 +71460,7 @@ var ts; } }; for (var i = spreadIndex; i < args.length; i++) { - _loop_20(i); + _loop_21(i); } return effectiveArgs_1; } @@ -68887,30 +71473,30 @@ var ts; var parent = node.parent; var expr = node.expression; switch (parent.kind) { - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* 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 160 /* Parameter */: + case 162 /* 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 === 166 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), + createSyntheticExpression(expr, parent.parent.kind === 168 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), createSyntheticExpression(expr, anyType), createSyntheticExpression(expr, numberType) ]; - case 163 /* PropertyDeclaration */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* 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 !== 163 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; + var hasPropDesc = parent.kind !== 165 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; return [ createSyntheticExpression(expr, getParentTypeOfClassElement(parent)), createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)), @@ -68924,17 +71510,17 @@ var ts; */ function getDecoratorArgumentCount(node, signature) { switch (node.parent.kind) { - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: return 1; - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return 2; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* 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 160 /* Parameter */: + case 162 /* Parameter */: return 3; default: return ts.Debug.fail(); @@ -68980,77 +71566,66 @@ var ts; return constructorSymbol === globalPromiseSymbol; } function getArgumentArityError(node, signatures, args) { - var min = Number.POSITIVE_INFINITY; - var max = Number.NEGATIVE_INFINITY; - var belowArgCount = Number.NEGATIVE_INFINITY; - var aboveArgCount = Number.POSITIVE_INFINITY; - var argCount = args.length; + var _a; + var spreadIndex = getSpreadArgumentIndex(args); + if (spreadIndex > -1) { + return ts.createDiagnosticForNode(args[spreadIndex], ts.Diagnostics.A_spread_argument_must_either_have_a_tuple_type_or_be_passed_to_a_rest_parameter); + } + var min = Number.POSITIVE_INFINITY; // smallest parameter count + var max = Number.NEGATIVE_INFINITY; // largest parameter count + var maxBelow = Number.NEGATIVE_INFINITY; // largest parameter count that is smaller than the number of arguments + var minAbove = Number.POSITIVE_INFINITY; // smallest parameter count that is larger than the number of arguments var closestSignature; for (var _i = 0, signatures_8 = signatures; _i < signatures_8.length; _i++) { var sig = signatures_8[_i]; - var minCount = getMinArgumentCount(sig); - var maxCount = getParameterCount(sig); - if (minCount < argCount && minCount > belowArgCount) - belowArgCount = minCount; - if (argCount < maxCount && maxCount < aboveArgCount) - aboveArgCount = maxCount; - if (minCount < min) { - min = minCount; + var minParameter = getMinArgumentCount(sig); + var maxParameter = getParameterCount(sig); + // smallest/largest parameter counts + if (minParameter < min) { + min = minParameter; closestSignature = sig; } - max = Math.max(max, maxCount); + max = Math.max(max, maxParameter); + // shortest parameter count *longer than the call*/longest parameter count *shorter than the call* + if (minParameter < args.length && minParameter > maxBelow) + maxBelow = minParameter; + if (args.length < maxParameter && maxParameter < minAbove) + minAbove = maxParameter; } var hasRestParameter = ts.some(signatures, hasEffectiveRestParameter); - var paramRange = hasRestParameter ? min : - min < max ? min + "-" + max : - min; - var hasSpreadArgument = getSpreadArgumentIndex(args) > -1; - if (argCount <= max && hasSpreadArgument) { - argCount--; - } - var spanArray; - var related; - var error = hasRestParameter || hasSpreadArgument ? - hasRestParameter && hasSpreadArgument ? - ts.Diagnostics.Expected_at_least_0_arguments_but_got_1_or_more : - hasRestParameter ? - ts.Diagnostics.Expected_at_least_0_arguments_but_got_1 : - ts.Diagnostics.Expected_0_arguments_but_got_1_or_more : - paramRange === 1 && argCount === 0 && isPromiseResolveArityError(node) ? - ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise : - ts.Diagnostics.Expected_0_arguments_but_got_1; - if (closestSignature && getMinArgumentCount(closestSignature) > argCount && closestSignature.declaration) { - var paramDecl = closestSignature.declaration.parameters[closestSignature.thisParameter ? argCount + 1 : argCount]; - if (paramDecl) { - related = ts.createDiagnosticForNode(paramDecl, ts.isBindingPattern(paramDecl.name) ? ts.Diagnostics.An_argument_matching_this_binding_pattern_was_not_provided : - ts.isRestParameter(paramDecl) ? ts.Diagnostics.Arguments_for_the_rest_parameter_0_were_not_provided : ts.Diagnostics.An_argument_for_0_was_not_provided, !paramDecl.name ? argCount : !ts.isBindingPattern(paramDecl.name) ? ts.idText(ts.getFirstIdentifier(paramDecl.name)) : undefined); - } - } - if (min < argCount && argCount < max) { - return getDiagnosticForCallNode(node, ts.Diagnostics.No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments, argCount, belowArgCount, aboveArgCount); - } - if (!hasSpreadArgument && argCount < min) { - var diagnostic_1 = getDiagnosticForCallNode(node, error, paramRange, argCount); - return related ? ts.addRelatedInfo(diagnostic_1, related) : diagnostic_1; - } - if (hasRestParameter || hasSpreadArgument) { - spanArray = ts.factory.createNodeArray(args); - if (hasSpreadArgument && argCount) { - var nextArg = ts.elementAt(args, getSpreadArgumentIndex(args) + 1) || undefined; - spanArray = ts.factory.createNodeArray(args.slice(max > argCount && nextArg ? args.indexOf(nextArg) : Math.min(max, args.length - 1))); + var parameterRange = hasRestParameter ? min + : min < max ? min + "-" + max + : min; + var error = hasRestParameter ? ts.Diagnostics.Expected_at_least_0_arguments_but_got_1 + : parameterRange === 1 && args.length === 0 && isPromiseResolveArityError(node) ? ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise + : ts.Diagnostics.Expected_0_arguments_but_got_1; + if (min < args.length && args.length < max) { + // between min and max, but with no matching overload + return getDiagnosticForCallNode(node, ts.Diagnostics.No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments, args.length, maxBelow, minAbove); + } + else if (args.length < min) { + // too short: put the error span on the call expression, not any of the args + var diagnostic = getDiagnosticForCallNode(node, error, parameterRange, args.length); + var parameter = (_a = closestSignature === null || closestSignature === void 0 ? void 0 : closestSignature.declaration) === null || _a === void 0 ? void 0 : _a.parameters[closestSignature.thisParameter ? args.length + 1 : args.length]; + if (parameter) { + var parameterError = ts.createDiagnosticForNode(parameter, ts.isBindingPattern(parameter.name) ? ts.Diagnostics.An_argument_matching_this_binding_pattern_was_not_provided + : ts.isRestParameter(parameter) ? ts.Diagnostics.Arguments_for_the_rest_parameter_0_were_not_provided + : ts.Diagnostics.An_argument_for_0_was_not_provided, !parameter.name ? args.length : !ts.isBindingPattern(parameter.name) ? ts.idText(ts.getFirstIdentifier(parameter.name)) : undefined); + return ts.addRelatedInfo(diagnostic, parameterError); } + return diagnostic; } else { - spanArray = ts.factory.createNodeArray(args.slice(max)); - } - var pos = ts.first(spanArray).pos; - var end = ts.last(spanArray).end; - if (end === pos) { - end++; + // too long; error goes on the excess parameters + var errorSpan = ts.factory.createNodeArray(args.slice(max)); + var pos = ts.first(errorSpan).pos; + var end = ts.last(errorSpan).end; + if (end === pos) { + end++; + } + ts.setTextRangePosEnd(errorSpan, pos, end); + return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), errorSpan, error, parameterRange, args.length); } - ts.setTextRangePosEnd(spanArray, pos, end); - var diagnostic = ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), spanArray, error, paramRange, argCount); - return related ? ts.addRelatedInfo(diagnostic, related) : diagnostic; } function getTypeArgumentArityError(node, signatures, typeArguments) { var argCount = typeArguments.length; @@ -69081,15 +71656,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 === 205 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 161 /* Decorator */; + var isTaggedTemplate = node.kind === 207 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 163 /* Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var reportErrors = !candidatesOutArray && produceDiagnostics; var typeArguments; if (!isDecorator) { typeArguments = node.typeArguments; // We already perform checking on the type arguments on the class declaration itself. - if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 105 /* SuperKeyword */) { + if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 106 /* SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } @@ -69144,7 +71719,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 === 203 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 205 /* 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 @@ -69198,7 +71773,7 @@ var ts; var min_3 = Number.MAX_VALUE; var minIndex = 0; var i_1 = 0; - var _loop_21 = function (c) { + var _loop_22 = 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); if (diags_2) { @@ -69216,7 +71791,7 @@ var ts; }; for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) { var c = candidatesForArgumentError_1[_a]; - _loop_21(c); + _loop_22(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"); @@ -69374,7 +71949,7 @@ var ts; } var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max; var parameters = []; - var _loop_22 = function (i) { + var _loop_23 = 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; }); @@ -69382,7 +71957,7 @@ var ts; parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); }))); }; for (var i = 0; i < maxNonRestParam; i++) { - _loop_22(i); + _loop_23(i); } var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; }); var flags = 0 /* None */; @@ -69463,7 +72038,7 @@ var ts; return maxParamsIndex; } function resolveCallExpression(node, candidatesOutArray, checkMode) { - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (isTypeAny(superType)) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { @@ -69574,7 +72149,7 @@ 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 */ | 131072 /* Never */)) && isTypeAssignableTo(funcType, globalFunctionType); + !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & 1048576 /* Union */) && !(getReducedType(apparentFuncType).flags & 131072 /* Never */) && isTypeAssignableTo(funcType, globalFunctionType); } function resolveNewExpression(node, candidatesOutArray, checkMode) { if (node.arguments && languageVersion < 1 /* ES5 */) { @@ -69689,7 +72264,7 @@ var ts; var declaration = signature.declaration; var modifiers = ts.getSelectedEffectiveModifierFlags(declaration, 24 /* NonPublicAccessibilityModifier */); // (1) Public constructors and (2) constructor functions are always accessible. - if (!modifiers || declaration.kind !== 166 /* Constructor */) { + if (!modifiers || declaration.kind !== 168 /* Constructor */) { return true; } var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(declaration.parent.symbol); @@ -69833,16 +72408,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 160 /* Parameter */: + case 162 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; default: return ts.Debug.fail(); @@ -69888,7 +72463,7 @@ var ts; // 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(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.factory.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.factory.createKeywordTypeNode(128 /* AnyKeyword */)); + var declaration = ts.factory.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.factory.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.factory.createKeywordTypeNode(129 /* AnyKeyword */)); var parameterSymbol = createSymbol(1 /* FunctionScopedVariable */, "props"); parameterSymbol.type = result; return createSignature(declaration, @@ -69937,16 +72512,16 @@ var ts; } function resolveSignature(node, candidatesOutArray, checkMode) { switch (node.kind) { - case 203 /* CallExpression */: + case 205 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray, checkMode); - case 204 /* NewExpression */: + case 206 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray, checkMode); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode); - case 161 /* Decorator */: + case 163 /* Decorator */: return resolveDecorator(node, candidatesOutArray, checkMode); - case 275 /* JsxOpeningElement */: - case 274 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode); } throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); @@ -70046,7 +72621,7 @@ var ts; else if (ts.isBinaryExpression(node.parent)) { var parentNode = node.parent; var parentNodeOperator = node.parent.operatorToken.kind; - if (parentNodeOperator === 62 /* EqualsToken */ && (allowDeclaration || parentNode.right === node)) { + if (parentNodeOperator === 63 /* EqualsToken */ && (allowDeclaration || parentNode.right === node)) { name = parentNode.left; decl = name; } @@ -70055,7 +72630,7 @@ var ts; name = parentNode.parent.name; decl = parentNode.parent; } - else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 62 /* EqualsToken */ && (allowDeclaration || parentNode.parent.right === parentNode)) { + else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 63 /* EqualsToken */ && (allowDeclaration || parentNode.parent.right === parentNode)) { name = parentNode.parent.left; decl = name; } @@ -70078,10 +72653,10 @@ var ts; return false; } var parent = node.parent; - while (parent && parent.kind === 201 /* PropertyAccessExpression */) { + while (parent && parent.kind === 203 /* PropertyAccessExpression */) { parent = parent.parent; } - if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 62 /* EqualsToken */) { + if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 63 /* EqualsToken */) { var right = ts.getInitializerOfBinaryExpression(parent); return ts.isObjectLiteralExpression(right) && right; } @@ -70102,15 +72677,15 @@ var ts; return nonInferrableType; } checkDeprecatedSignature(signature, node); - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { return voidType; } - if (node.kind === 204 /* NewExpression */) { + if (node.kind === 206 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 166 /* Constructor */ && - declaration.kind !== 170 /* ConstructSignature */ && - declaration.kind !== 175 /* ConstructorType */ && + declaration.kind !== 168 /* Constructor */ && + declaration.kind !== 172 /* ConstructSignature */ && + declaration.kind !== 177 /* ConstructorType */ && !ts.isJSDocConstructSignature(declaration) && !isJSConstructor(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any @@ -70130,7 +72705,7 @@ var ts; if (returnType.flags & 12288 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent)); } - if (node.kind === 203 /* CallExpression */ && node.parent.kind === 233 /* ExpressionStatement */ && + if (node.kind === 205 /* CallExpression */ && !node.questionDotToken && node.parent.kind === 235 /* ExpressionStatement */ && returnType.flags & 16384 /* 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); @@ -70144,7 +72719,7 @@ 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, undefined, undefined); - jsAssignmentType.objectFlags |= 16384 /* JSLiteral */; + jsAssignmentType.objectFlags |= 8192 /* JSLiteral */; return getIntersectionType([returnType, jsAssignmentType]); } } @@ -70153,26 +72728,27 @@ var ts; function checkDeprecatedSignature(signature, node) { if (signature.declaration && signature.declaration.flags & 134217728 /* Deprecated */) { var suggestionNode = getDeprecatedSuggestionNode(node); - errorOrSuggestion(/*isError*/ false, suggestionNode, ts.Diagnostics._0_is_deprecated, signatureToString(signature)); + var name = ts.tryGetPropertyAccessOrIdentifierToString(ts.getInvokedExpression(node)); + addDeprecatedSuggestionWithSignature(suggestionNode, signature.declaration, name, signatureToString(signature)); } } function getDeprecatedSuggestionNode(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 203 /* CallExpression */: - case 161 /* Decorator */: - case 204 /* NewExpression */: + case 205 /* CallExpression */: + case 163 /* Decorator */: + case 206 /* NewExpression */: return getDeprecatedSuggestionNode(node.expression); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return getDeprecatedSuggestionNode(node.tag); - case 275 /* JsxOpeningElement */: - case 274 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: return getDeprecatedSuggestionNode(node.tagName); - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: return node.argumentExpression; - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return node.name; - case 173 /* TypeReference */: + case 175 /* TypeReference */: var typeReference = node; return ts.isQualifiedName(typeReference.typeName) ? typeReference.typeName.right : typeReference; default: @@ -70223,10 +72799,11 @@ var ts; return createPromiseReturnType(node, anyType); } function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol) { + var _a; if (allowSyntheticDefaultImports && type && type !== errorType) { var synthType = type; if (!synthType.syntheticType) { - var file = ts.find(originalSymbol.declarations, ts.isSourceFile); + var file = (_a = originalSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, /*dontResolveAlias*/ false); if (hasSyntheticDefault) { var memberTable = ts.createSymbolTable(); @@ -70264,9 +72841,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 251 /* FunctionDeclaration */ + ? 253 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 249 /* VariableDeclaration */ + ? 251 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -70294,21 +72871,21 @@ var ts; case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: - case 199 /* ArrayLiteralExpression */: - case 200 /* ObjectLiteralExpression */: - case 218 /* TemplateExpression */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: + case 201 /* ArrayLiteralExpression */: + case 202 /* ObjectLiteralExpression */: + case 220 /* TemplateExpression */: return true; - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return isValidConstAssertionArgument(node.expression); - case 214 /* PrefixUnaryExpression */: + case 216 /* 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 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: var expr = node.expression; if (ts.isIdentifier(expr)) { var symbol = getSymbolAtLocation(expr); @@ -70350,10 +72927,10 @@ var ts; } function checkMetaProperty(node) { checkGrammarMetaProperty(node); - if (node.keywordToken === 102 /* NewKeyword */) { + if (node.keywordToken === 103 /* NewKeyword */) { return checkNewTargetMetaProperty(node); } - if (node.keywordToken === 99 /* ImportKeyword */) { + if (node.keywordToken === 100 /* ImportKeyword */) { return checkImportMetaProperty(node); } return ts.Debug.assertNever(node.keywordToken); @@ -70364,7 +72941,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 === 166 /* Constructor */) { + else if (container.kind === 168 /* Constructor */) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -70411,7 +72988,7 @@ var ts; return restParameter.escapedName; } function isValidDeclarationForTupleLabel(d) { - return d.kind === 192 /* NamedTupleMember */ || (ts.isParameter(d) && d.name && ts.isIdentifier(d.name)); + return d.kind === 194 /* NamedTupleMember */ || (ts.isParameter(d) && d.name && ts.isIdentifier(d.name)); } function getNameableDeclarationAtPosition(signature, pos) { var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); @@ -70576,7 +73153,14 @@ var ts; } } function assignContextualParameterTypes(signature, context) { - signature.typeParameters = context.typeParameters; + if (context.typeParameters) { + if (!signature.typeParameters) { + signature.typeParameters = context.typeParameters; + } + else { + return; // This signature has already has a contextual inference performed and cached on it! + } + } if (context.thisParameter) { var parameter = signature.thisParameter; if (!parameter || parameter.valueDeclaration && !parameter.valueDeclaration.type) { @@ -70617,7 +73201,7 @@ var ts; if (!links.type) { var declaration = parameter.valueDeclaration; links.type = type || getWidenedTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true); - if (declaration.name.kind !== 78 /* Identifier */) { + if (declaration.name.kind !== 79 /* 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); @@ -70632,7 +73216,7 @@ var ts; for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { var element = _a[_i]; if (!ts.isOmittedExpression(element)) { - if (element.name.kind === 78 /* Identifier */) { + if (element.name.kind === 79 /* Identifier */) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } else { @@ -70687,7 +73271,7 @@ var ts; var yieldType; var nextType; var fallbackReturnType = voidType; - if (func.body.kind !== 230 /* Block */) { // Async or normal arrow function + if (func.body.kind !== 232 /* Block */) { // Async or normal arrow function returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8 /* SkipGenericFunctions */); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any @@ -70872,7 +73456,7 @@ var ts; return links.isExhaustive !== undefined ? links.isExhaustive : (links.isExhaustive = computeExhaustiveSwitchStatement(node)); } function computeExhaustiveSwitchStatement(node) { - if (node.expression.kind === 211 /* TypeOfExpression */) { + if (node.expression.kind === 213 /* TypeOfExpression */) { var operandType = getTypeOfExpression(node.expression.expression); var witnesses = getSwitchClauseTypeOfWitnesses(node, /*retainDefault*/ false); // notEqualFacts states that the type of the switched value is not equal to every type in the switch. @@ -70935,11 +73519,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return true; - case 165 /* MethodDeclaration */: - return func.parent.kind === 200 /* ObjectLiteralExpression */; + case 167 /* MethodDeclaration */: + return func.parent.kind === 202 /* ObjectLiteralExpression */; default: return false; } @@ -70965,21 +73549,21 @@ var ts; } // 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 === 164 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 230 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 166 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 232 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 512 /* HasExplicitReturn */; + var errorNode = ts.getEffectiveReturnTypeNode(func) || func; if (type && type.flags & 131072 /* Never */) { - error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); + error(errorNode, ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); } else if (type && !hasExplicitReturn) { // minimal check: function has syntactic return type annotation and no explicit return statements in the body // this function does not conform to the specification. - // NOTE: having returnType !== undefined is a precondition for entering this branch so func.type will always be present - error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value); + error(errorNode, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value); } else if (type && strictNullChecks && !isTypeAssignableTo(undefinedType, type)) { - error(ts.getEffectiveReturnTypeNode(func) || func, ts.Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined); + error(errorNode, ts.Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined); } else if (compilerOptions.noImplicitReturns) { if (!type) { @@ -70994,11 +73578,11 @@ var ts; return; } } - error(ts.getEffectiveReturnTypeNode(func) || func, ts.Diagnostics.Not_all_code_paths_return_a_value); + error(errorNode, ts.Diagnostics.Not_all_code_paths_return_a_value); } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 165 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 167 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); checkNodeDeferred(node); // The identityMapper object is used to indicate that function expressions are wildcards if (checkMode && checkMode & 4 /* SkipContextSensitive */ && isContextSensitive(node)) { @@ -71014,7 +73598,7 @@ var ts; var returnType = getReturnTypeFromBody(node, checkMode); var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); var returnOnlyType = createAnonymousType(node.symbol, emptySymbols, [returnOnlySignature], ts.emptyArray, undefined, undefined); - returnOnlyType.objectFlags |= 2097152 /* NonInferrableType */; + returnOnlyType.objectFlags |= 524288 /* NonInferrableType */; return links.contextFreeType = returnOnlyType; } } @@ -71022,7 +73606,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 208 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 210 /* FunctionExpression */) { checkGrammarForGenerator(node); } contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -71068,7 +73652,7 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 165 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 167 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnType = getReturnTypeFromAnnotation(node); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); @@ -71081,7 +73665,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 230 /* Block */) { + if (node.body.kind === 232 /* Block */) { checkSourceElement(node.body); } else { @@ -71168,10 +73752,10 @@ var ts; // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && ts.isAccessExpression(expr) && - expr.expression.kind === 107 /* ThisKeyword */) { + expr.expression.kind === 108 /* 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 === 166 /* Constructor */ || isJSConstructor(ctor)))) { + if (!(ctor && (ctor.kind === 168 /* Constructor */ || isJSConstructor(ctor)))) { return true; } if (symbol.valueDeclaration) { @@ -71192,11 +73776,11 @@ var ts; if (ts.isAccessExpression(expr)) { // references through namespace import should be readonly var node = ts.skipParentheses(expr.expression); - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { var symbol_2 = getNodeLinks(node).resolvedSymbol; if (symbol_2.flags & 2097152 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol_2); - return !!declaration && declaration.kind === 263 /* NamespaceImport */; + return !!declaration && declaration.kind === 265 /* NamespaceImport */; } } } @@ -71205,7 +73789,7 @@ 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 !== 78 /* Identifier */ && !ts.isAccessExpression(node)) { + if (node.kind !== 79 /* Identifier */ && !ts.isAccessExpression(node)) { error(expr, invalidReferenceMessage); return false; } @@ -71277,7 +73861,7 @@ var ts; 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); var func = ts.getContainingFunction(node); - if (func && func.kind !== 166 /* Constructor */ && (ts.getFunctionFlags(func) & 2 /* Async */) === 0) { + if (func && func.kind !== 168 /* Constructor */ && (ts.getFunctionFlags(func) & 2 /* Async */) === 0) { var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); } @@ -71444,14 +74028,33 @@ var ts; rightType = checkNonNullType(rightType, right); // TypeScript 1.0 spec (April 2014): 4.15.5 // The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, - // and the right operand to be of type Any, an object type, or a type parameter type. + // and the right operand to be + // + // 1. assignable to the non-primitive type, + // 2. an unconstrained type parameter, + // 3. a union or intersection including one or more type parameters, whose constituents are all assignable to the + // the non-primitive type, or are unconstrainted type parameters, or have constraints assignable to the + // non-primitive type, or + // 4. a type parameter whose constraint is + // i. an object type, + // ii. the non-primitive type, or + // iii. a union or intersection with at least one constituent assignable to an object or non-primitive type. + // + // The divergent behavior for type parameters and unions containing type parameters is a workaround for type + // parameters not being narrowable. If the right operand is a concrete type, we can error if there is any chance + // it is a primitive. But if the operand is a type parameter, it cannot be narrowed, so we don't issue an error + // unless *all* instantiations would result in an error. + // // The result is always of the Boolean primitive type. if (!(allTypesAssignableToKind(leftType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) || isTypeAssignableToKind(leftType, 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 262144 /* TypeParameter */))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } - if (!allTypesAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */)) { - error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); + 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 */))) { + error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_not_be_a_primitive); } return booleanType; } @@ -71470,7 +74073,7 @@ var ts; if (rightIsThis === void 0) { rightIsThis = false; } var properties = node.properties; var property = properties[propertyIndex]; - if (property.kind === 288 /* PropertyAssignment */ || property.kind === 289 /* ShorthandPropertyAssignment */) { + if (property.kind === 290 /* PropertyAssignment */ || property.kind === 291 /* ShorthandPropertyAssignment */) { var name = property.name; var exprType = getLiteralTypeFromPropertyName(name); if (isTypeUsableAsPropertyName(exprType)) { @@ -71478,14 +74081,14 @@ var ts; var prop = getPropertyOfType(objectLiteralType, text); if (prop) { markPropertyAsReferenced(prop, property, rightIsThis); - checkPropertyAccessibility(property, /*isSuper*/ false, objectLiteralType, prop); + checkPropertyAccessibility(property, /*isSuper*/ false, /*writing*/ true, objectLiteralType, prop); } } - var elementType = getIndexedAccessType(objectLiteralType, exprType, /*noUncheckedIndexedAccessCandidate*/ undefined, name, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, 16 /* ExpressionPosition */); + var elementType = getIndexedAccessType(objectLiteralType, exprType, 32 /* ExpressionPosition */, name); var type = getFlowTypeOfDestructuring(property, elementType); - return checkDestructuringAssignment(property.kind === 289 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); + return checkDestructuringAssignment(property.kind === 291 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); } - else if (property.kind === 290 /* SpreadAssignment */) { + else if (property.kind === 292 /* SpreadAssignment */) { if (propertyIndex < properties.length - 1) { error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } @@ -71523,7 +74126,7 @@ var ts; var inBoundsType = compilerOptions.noUncheckedIndexedAccess ? undefined : possiblyOutOfBoundsType; for (var i = 0; i < elements.length; i++) { var type = possiblyOutOfBoundsType; - if (node.elements[i].kind === 220 /* SpreadElement */) { + if (node.elements[i].kind === 222 /* SpreadElement */) { type = inBoundsType = inBoundsType !== null && inBoundsType !== void 0 ? inBoundsType : (checkIteratedTypeOrElementType(65 /* Destructuring */, sourceType, undefinedType, node) || errorType); } checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, type, checkMode); @@ -71533,14 +74136,14 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 222 /* OmittedExpression */) { - if (element.kind !== 220 /* SpreadElement */) { + if (element.kind !== 224 /* OmittedExpression */) { + if (element.kind !== 222 /* SpreadElement */) { var indexType = getLiteralType(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 = 16 /* ExpressionPosition */ | (hasDefaultValue(element) ? 8 /* NoTupleBoundsCheck */ : 0); - var elementType_2 = getIndexedAccessTypeOrUndefined(sourceType, indexType, /*noUncheckedIndexedAccessCandidate*/ undefined, createSyntheticExpression(element, indexType), accessFlags) || errorType; + var accessFlags = 32 /* ExpressionPosition */ | (hasDefaultValue(element) ? 16 /* 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 type = getFlowTypeOfDestructuring(element, assignedType); return checkDestructuringAssignment(element, type, checkMode); @@ -71552,7 +74155,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 216 /* BinaryExpression */ && restExpression.operatorToken.kind === 62 /* EqualsToken */) { + if (restExpression.kind === 218 /* BinaryExpression */ && restExpression.operatorToken.kind === 63 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -71568,7 +74171,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) { var target; - if (exprOrAssignment.kind === 289 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 291 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove @@ -71584,24 +74187,24 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 216 /* BinaryExpression */ && target.operatorToken.kind === 62 /* EqualsToken */) { + if (target.kind === 218 /* BinaryExpression */ && target.operatorToken.kind === 63 /* EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 200 /* ObjectLiteralExpression */) { + if (target.kind === 202 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, rightIsThis); } - if (target.kind === 199 /* ArrayLiteralExpression */) { + if (target.kind === 201 /* 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 === 290 /* SpreadAssignment */ ? + var error = target.parent.kind === 292 /* 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 === 290 /* SpreadAssignment */ ? + var optionalError = target.parent.kind === 292 /* 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)) { @@ -71623,39 +74226,39 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: case 10 /* StringLiteral */: case 13 /* RegularExpressionLiteral */: - case 205 /* TaggedTemplateExpression */: - case 218 /* TemplateExpression */: + case 207 /* TaggedTemplateExpression */: + case 220 /* TemplateExpression */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: - case 103 /* NullKeyword */: - case 150 /* UndefinedKeyword */: - case 208 /* FunctionExpression */: - case 221 /* ClassExpression */: - case 209 /* ArrowFunction */: - case 199 /* ArrayLiteralExpression */: - case 200 /* ObjectLiteralExpression */: - case 211 /* TypeOfExpression */: - case 225 /* NonNullExpression */: - case 274 /* JsxSelfClosingElement */: - case 273 /* JsxElement */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: + case 104 /* NullKeyword */: + case 151 /* UndefinedKeyword */: + case 210 /* FunctionExpression */: + case 223 /* ClassExpression */: + case 211 /* ArrowFunction */: + case 201 /* ArrayLiteralExpression */: + case 202 /* ObjectLiteralExpression */: + case 213 /* TypeOfExpression */: + case 227 /* NonNullExpression */: + case 276 /* JsxSelfClosingElement */: + case 275 /* JsxElement */: return true; - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 214 /* PrefixUnaryExpression */: - case 215 /* PostfixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { @@ -71667,9 +74270,9 @@ var ts; } return false; // Some forms listed here for clarity - case 212 /* VoidExpression */: // Explicit opt-out - case 206 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 224 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 214 /* VoidExpression */: // Explicit opt-out + case 208 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 226 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } @@ -71677,84 +74280,111 @@ var ts; function isTypeEqualityComparableTo(source, target) { return (target.flags & 98304 /* Nullable */) !== 0 || isTypeComparableTo(source, target); } - var CheckBinaryExpressionState; - (function (CheckBinaryExpressionState) { - CheckBinaryExpressionState[CheckBinaryExpressionState["MaybeCheckLeft"] = 0] = "MaybeCheckLeft"; - CheckBinaryExpressionState[CheckBinaryExpressionState["CheckRight"] = 1] = "CheckRight"; - CheckBinaryExpressionState[CheckBinaryExpressionState["FinishCheck"] = 2] = "FinishCheck"; - })(CheckBinaryExpressionState || (CheckBinaryExpressionState = {})); - function checkBinaryExpression(node, checkMode) { - var workStacks = { - expr: [node], - state: [0 /* MaybeCheckLeft */], - leftType: [undefined] + function createCheckBinaryExpression() { + var trampoline = ts.createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, foldState); + return function (node, checkMode) { + var result = trampoline(node, checkMode); + ts.Debug.assertIsDefined(result); + return result; }; - var stackIndex = 0; - var lastResult; - while (stackIndex >= 0) { - node = workStacks.expr[stackIndex]; - switch (workStacks.state[stackIndex]) { - case 0 /* MaybeCheckLeft */: { - if (ts.isInJSFile(node) && ts.getAssignedExpandoInitializer(node)) { - finishInvocation(checkExpression(node.right, checkMode)); - break; - } - checkGrammarNullishCoalesceWithLogicalExpression(node); - var operator = node.operatorToken.kind; - if (operator === 62 /* EqualsToken */ && (node.left.kind === 200 /* ObjectLiteralExpression */ || node.left.kind === 199 /* ArrayLiteralExpression */)) { - finishInvocation(checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 107 /* ThisKeyword */)); - break; - } - advanceState(1 /* CheckRight */); - maybeCheckExpression(node.left); - break; - } - case 1 /* CheckRight */: { - var leftType = lastResult; - workStacks.leftType[stackIndex] = leftType; - var operator = node.operatorToken.kind; - if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { - if (operator === 55 /* AmpersandAmpersandToken */) { - var parent = ts.walkUpParenthesizedExpressions(node.parent); - checkTestingKnownTruthyCallableType(node.left, leftType, ts.isIfStatement(parent) ? parent.thenStatement : undefined); - } - checkTruthinessOfType(leftType, node.left); + function onEnter(node, state, checkMode) { + if (state) { + state.stackIndex++; + state.skip = false; + setLeftType(state, /*type*/ undefined); + setLastResult(state, /*type*/ undefined); + } + else { + state = { + checkMode: checkMode, + skip: false, + stackIndex: 0, + typeStack: [undefined, undefined], + }; + } + if (ts.isInJSFile(node) && ts.getAssignedExpandoInitializer(node)) { + state.skip = true; + setLastResult(state, checkExpression(node.right, checkMode)); + return state; + } + checkGrammarNullishCoalesceWithLogicalExpression(node); + var operator = node.operatorToken.kind; + if (operator === 63 /* EqualsToken */ && (node.left.kind === 202 /* ObjectLiteralExpression */ || node.left.kind === 201 /* ArrayLiteralExpression */)) { + state.skip = true; + setLastResult(state, checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 108 /* ThisKeyword */)); + return state; + } + return state; + } + function onLeft(left, state, _node) { + if (!state.skip) { + return maybeCheckExpression(state, left); + } + } + function onOperator(operatorToken, state, node) { + if (!state.skip) { + var leftType = getLastResult(state); + ts.Debug.assertIsDefined(leftType); + 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); + checkTestingKnownTruthyCallableOrAwaitableType(node.left, leftType, ts.isIfStatement(parent) ? parent.thenStatement : undefined); } - advanceState(2 /* FinishCheck */); - maybeCheckExpression(node.right); - break; + checkTruthinessOfType(leftType, node.left); } - case 2 /* FinishCheck */: { - var leftType = workStacks.leftType[stackIndex]; - var rightType = lastResult; - finishInvocation(checkBinaryLikeExpressionWorker(node.left, node.operatorToken, node.right, leftType, rightType, node)); - break; - } - default: return ts.Debug.fail("Invalid state " + workStacks.state[stackIndex] + " for checkBinaryExpression"); } } - return lastResult; - function finishInvocation(result) { - lastResult = result; - stackIndex--; - } - /** - * Note that `advanceState` sets the _current_ head state, and that `maybeCheckExpression` potentially pushes on a new - * head state; so `advanceState` must be called before any `maybeCheckExpression` during a state's execution. - */ - function advanceState(nextState) { - workStacks.state[stackIndex] = nextState; + function onRight(right, state, _node) { + if (!state.skip) { + return maybeCheckExpression(state, right); + } } - function maybeCheckExpression(node) { - if (ts.isBinaryExpression(node)) { - stackIndex++; - workStacks.expr[stackIndex] = node; - workStacks.state[stackIndex] = 0 /* MaybeCheckLeft */; - workStacks.leftType[stackIndex] = undefined; + function onExit(node, state) { + var result; + if (state.skip) { + result = getLastResult(state); } else { - lastResult = checkExpression(node, checkMode); + var leftType = getLeftType(state); + ts.Debug.assertIsDefined(leftType); + var rightType = getLastResult(state); + ts.Debug.assertIsDefined(rightType); + result = checkBinaryLikeExpressionWorker(node.left, node.operatorToken, node.right, leftType, rightType, node); + } + state.skip = false; + setLeftType(state, /*type*/ undefined); + setLastResult(state, /*type*/ undefined); + state.stackIndex--; + return result; + } + function foldState(state, result, _side) { + setLastResult(state, result); + return state; + } + function maybeCheckExpression(state, node) { + if (ts.isBinaryExpression(node)) { + return node; } + setLastResult(state, checkExpression(node, state.checkMode)); + } + function getLeftType(state) { + return state.typeStack[state.stackIndex]; + } + function setLeftType(state, type) { + state.typeStack[state.stackIndex] = type; + } + function getLastResult(state) { + return state.typeStack[state.stackIndex + 1]; + } + function setLastResult(state, type) { + // To reduce overhead, reuse the next stack entry to store the + // last result. This avoids the overhead of an additional property + // on `WorkArea` and reuses empty stack entries as we walk back up + // the stack. + state.typeStack[state.stackIndex + 1] = type; } } function checkGrammarNullishCoalesceWithLogicalExpression(node) { @@ -71772,8 +74402,8 @@ 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 === 62 /* EqualsToken */ && (left.kind === 200 /* ObjectLiteralExpression */ || left.kind === 199 /* ArrayLiteralExpression */)) { - return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 107 /* ThisKeyword */); + if (operator === 63 /* EqualsToken */ && (left.kind === 202 /* ObjectLiteralExpression */ || left.kind === 201 /* ArrayLiteralExpression */)) { + return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 108 /* ThisKeyword */); } var leftType; if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { @@ -71790,26 +74420,26 @@ var ts; switch (operator) { case 41 /* AsteriskToken */: case 42 /* AsteriskAsteriskToken */: - case 65 /* AsteriskEqualsToken */: - case 66 /* AsteriskAsteriskEqualsToken */: + case 66 /* AsteriskEqualsToken */: + case 67 /* AsteriskAsteriskEqualsToken */: case 43 /* SlashToken */: - case 67 /* SlashEqualsToken */: + case 68 /* SlashEqualsToken */: case 44 /* PercentToken */: - case 68 /* PercentEqualsToken */: + case 69 /* PercentEqualsToken */: case 40 /* MinusToken */: - case 64 /* MinusEqualsToken */: + case 65 /* MinusEqualsToken */: case 47 /* LessThanLessThanToken */: - case 69 /* LessThanLessThanEqualsToken */: + case 70 /* LessThanLessThanEqualsToken */: case 48 /* GreaterThanGreaterThanToken */: - case 70 /* GreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanEqualsToken */: case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: case 51 /* BarToken */: - case 73 /* BarEqualsToken */: + case 74 /* BarEqualsToken */: case 52 /* CaretToken */: - case 77 /* CaretEqualsToken */: + case 78 /* CaretEqualsToken */: case 50 /* AmpersandToken */: - case 72 /* AmpersandEqualsToken */: + case 73 /* AmpersandEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -71839,11 +74469,11 @@ var ts; else if (bothAreBigIntLike(leftType, rightType)) { switch (operator) { case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: reportOperatorError(); break; case 42 /* AsteriskAsteriskToken */: - case 66 /* AsteriskAsteriskEqualsToken */: + case 67 /* AsteriskAsteriskEqualsToken */: if (languageVersion < 3 /* ES2016 */) { error(errorNode, ts.Diagnostics.Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_later); } @@ -71861,7 +74491,7 @@ var ts; return resultType_1; } case 39 /* PlusToken */: - case 63 /* PlusEqualsToken */: + case 64 /* PlusEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -71904,7 +74534,7 @@ var ts; }); return anyType; } - if (operator === 63 /* PlusEqualsToken */) { + if (operator === 64 /* PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; @@ -71926,41 +74556,41 @@ var ts; case 37 /* ExclamationEqualsEqualsToken */: reportOperatorErrorUnless(function (left, right) { return isTypeEqualityComparableTo(left, right) || isTypeEqualityComparableTo(right, left); }); return booleanType; - case 101 /* InstanceOfKeyword */: + case 102 /* InstanceOfKeyword */: return checkInstanceOfExpression(left, right, leftType, rightType); - case 100 /* InKeyword */: + case 101 /* InKeyword */: return checkInExpression(left, right, leftType, rightType); case 55 /* AmpersandAmpersandToken */: - case 75 /* AmpersandAmpersandEqualsToken */: { + case 76 /* AmpersandAmpersandEqualsToken */: { var resultType_2 = getTypeFacts(leftType) & 4194304 /* Truthy */ ? getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) : leftType; - if (operator === 75 /* AmpersandAmpersandEqualsToken */) { + if (operator === 76 /* AmpersandAmpersandEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_2; } case 56 /* BarBarToken */: - case 74 /* BarBarEqualsToken */: { + case 75 /* BarBarEqualsToken */: { var resultType_3 = getTypeFacts(leftType) & 8388608 /* Falsy */ ? getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2 /* Subtype */) : leftType; - if (operator === 74 /* BarBarEqualsToken */) { + if (operator === 75 /* BarBarEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_3; } case 60 /* QuestionQuestionToken */: - case 76 /* QuestionQuestionEqualsToken */: { + case 77 /* QuestionQuestionEqualsToken */: { var resultType_4 = getTypeFacts(leftType) & 262144 /* EQUndefinedOrNull */ ? getUnionType([getNonNullableType(leftType), rightType], 2 /* Subtype */) : leftType; - if (operator === 76 /* QuestionQuestionEqualsToken */) { + if (operator === 77 /* QuestionQuestionEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_4; } - case 62 /* EqualsToken */: + case 63 /* EqualsToken */: var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0 /* None */; checkAssignmentDeclaration(declKind, rightType); if (isAssignmentDeclaration(declKind)) { @@ -72007,7 +74637,7 @@ var ts; if (propType.symbol && propType.symbol.flags & 32 /* Class */) { var name = prop.escapedName; var symbol = resolveName(prop.valueDeclaration, name, 788968 /* Type */, undefined, name, /*isUse*/ false); - if (symbol && symbol.declarations.some(ts.isJSDocTypedefTag)) { + 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); } @@ -72016,7 +74646,7 @@ var ts; } } function isEvalNode(node) { - return node.kind === 78 /* Identifier */ && node.escapedText === "eval"; + return node.kind === 79 /* Identifier */ && node.escapedText === "eval"; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { @@ -72032,13 +74662,13 @@ var ts; function getSuggestedBooleanOperator(operator) { switch (operator) { case 51 /* BarToken */: - case 73 /* BarEqualsToken */: + case 74 /* BarEqualsToken */: return 56 /* BarBarToken */; case 52 /* CaretToken */: - case 77 /* CaretEqualsToken */: + case 78 /* CaretEqualsToken */: return 37 /* ExclamationEqualsEqualsToken */; case 50 /* AmpersandToken */: - case 72 /* AmpersandEqualsToken */: + case 73 /* AmpersandEqualsToken */: return 55 /* AmpersandAmpersandToken */; default: return undefined; @@ -72202,7 +74832,7 @@ var ts; } function checkConditionalExpression(node, checkMode) { var type = checkTruthinessExpression(node.condition); - checkTestingKnownTruthyCallableType(node.condition, type, node.whenTrue); + checkTestingKnownTruthyCallableOrAwaitableType(node.condition, type, node.whenTrue); var type1 = checkExpression(node.whenTrue, checkMode); var type2 = checkExpression(node.whenFalse, checkMode); return getUnionType([type1, type2], 2 /* Subtype */); @@ -72219,10 +74849,14 @@ var ts; texts.push(span.literal.text); types.push(isTypeAssignableTo(type, templateConstraintType) ? type : stringType); } - return getFreshTypeOfLiteralType(getTemplateLiteralType(texts, types)); + return isConstContext(node) || someType(getContextualType(node) || 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 */)); } function getContextNode(node) { - if (node.kind === 281 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { + if (node.kind === 283 /* 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; @@ -72238,7 +74872,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, 134220672 /* FreshableLiteral */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ? + var result = maybeTypeOfKind(type, 2944 /* Literal */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ? getRegularTypeOfLiteralType(type) : type; return result; } @@ -72271,13 +74905,13 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 206 /* TypeAssertionExpression */ || node.kind === 224 /* AsExpression */; + return node.kind === 208 /* TypeAssertionExpression */ || node.kind === 226 /* AsExpression */; } function checkDeclarationInitializer(declaration, contextualType) { var initializer = ts.getEffectiveInitializer(declaration); var type = getQuickTypeOfExpression(initializer) || (contextualType ? checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, 0 /* Normal */) : checkExpressionCached(initializer)); - return ts.isParameter(declaration) && declaration.name.kind === 197 /* ArrayBindingPattern */ && + return ts.isParameter(declaration) && declaration.name.kind === 199 /* ArrayBindingPattern */ && isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ? padTupleType(type, declaration.name) : type; } @@ -72287,7 +74921,7 @@ 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 === 198 /* BindingElement */ && e.dotDotDotToken)) { + if (i < patternElements.length - 1 || !(e.kind === 200 /* BindingElement */ && e.dotDotDotToken)) { elementTypes.push(!ts.isOmittedExpression(e) && hasDefaultValue(e) ? getTypeFromBindingElement(e, /*includePatternInType*/ false, /*reportErrors*/ false) : anyType); elementFlags.push(2 /* Optional */); if (!ts.isOmittedExpression(e) && !hasDefaultValue(e)) { @@ -72300,7 +74934,7 @@ var ts; function widenTypeInferredFromInitializer(declaration, type) { var widened = ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || ts.isDeclarationReadonly(declaration) ? type : getWidenedLiteralType(type); if (ts.isInJSFile(declaration)) { - if (widened.flags & 98304 /* Nullable */) { + if (isEmptyLiteralType(widened)) { reportImplicitAny(declaration, anyType); return anyType; } @@ -72322,7 +74956,7 @@ var ts; // 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, 134217856 /* StringLikeLiteral */) || + 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 */) || @@ -72330,7 +74964,7 @@ var ts; } // 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 & (134217856 /* StringLikeLiteral */ | 4194304 /* Index */ | 268435456 /* StringMapping */) && maybeTypeOfKind(candidateType, 134217856 /* StringLikeLiteral */) || + 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 */) || @@ -72354,7 +74988,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 === 158 /* ComputedPropertyName */) { + if (node.name.kind === 160 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); @@ -72365,7 +74999,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 === 158 /* ComputedPropertyName */) { + if (node.name.kind === 160 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -72492,7 +75126,7 @@ var ts; len--; var s = baseName.slice(0, len); for (var index = 1; true; index++) { - var augmentedName = (s + index); + var augmentedName = s + index; if (!hasTypeParameterByName(typeParameters, augmentedName)) { return augmentedName; } @@ -72541,7 +75175,7 @@ var ts; var 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 !== 105 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { + if (ts.isCallExpression(expr) && expr.expression.kind !== 106 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { var type = ts.isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) : getReturnTypeOfSingleNonGenericCallSignature(checkNonNullExpression(expr.expression)); if (type) { @@ -72552,7 +75186,7 @@ var ts; return getTypeFromTypeNode(expr.type); } else if (node.kind === 8 /* NumericLiteral */ || node.kind === 10 /* StringLiteral */ || - node.kind === 109 /* TrueKeyword */ || node.kind === 94 /* FalseKeyword */) { + node.kind === 110 /* TrueKeyword */ || node.kind === 95 /* FalseKeyword */) { return checkExpression(node); } return undefined; @@ -72583,7 +75217,7 @@ var ts; } } function checkExpression(node, checkMode, forceTuple) { - ts.tracing.push("check" /* Check */, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end }); var saveCurrentNode = currentNode; currentNode = node; instantiationCount = 0; @@ -72593,7 +75227,7 @@ var ts; checkConstEnumAccess(node, type); } currentNode = saveCurrentNode; - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return type; } function checkConstEnumAccess(node, type) { @@ -72601,11 +75235,11 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 201 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 202 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 78 /* Identifier */ || node.kind === 157 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 176 /* TypeQuery */ && node.parent.exprName === node)) || - (node.parent.kind === 270 /* ExportSpecifier */); // We allow reexporting const enums + var ok = (node.parent.kind === 203 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 204 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 79 /* Identifier */ || node.kind === 159 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 178 /* TypeQuery */ && node.parent.exprName === node)) || + (node.parent.kind === 272 /* 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); } @@ -72620,7 +75254,7 @@ var ts; function checkParenthesizedExpression(node, checkMode) { var tag = ts.isInJSFile(node) ? ts.getJSDocTypeTag(node) : undefined; if (tag) { - return checkAssertionWorker(tag, tag.typeExpression.type, node.expression, checkMode); + return checkAssertionWorker(tag.typeExpression.type, tag.typeExpression.type, node.expression, checkMode); } return checkExpression(node.expression, checkMode); } @@ -72630,20 +75264,20 @@ 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 221 /* ClassExpression */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 223 /* ClassExpression */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 78 /* Identifier */: - return checkIdentifier(node); - case 107 /* ThisKeyword */: + case 79 /* Identifier */: + return checkIdentifier(node, checkMode); + case 108 /* ThisKeyword */: return checkThisExpression(node); - case 105 /* SuperKeyword */: + case 106 /* SuperKeyword */: return checkSuperExpression(node); - case 103 /* NullKeyword */: + case 104 /* NullKeyword */: return nullWideningType; case 14 /* NoSubstitutionTemplateLiteral */: case 10 /* StringLiteral */: @@ -72654,82 +75288,82 @@ var ts; case 9 /* BigIntLiteral */: checkGrammarBigIntLiteral(node); return getFreshTypeOfLiteralType(getBigIntLiteralType(node)); - case 109 /* TrueKeyword */: + case 110 /* TrueKeyword */: return trueType; - case 94 /* FalseKeyword */: + case 95 /* FalseKeyword */: return falseType; - case 218 /* TemplateExpression */: + case 220 /* TemplateExpression */: return checkTemplateExpression(node); case 13 /* RegularExpressionLiteral */: return globalRegExpType; - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode, forceTuple); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 201 /* PropertyAccessExpression */: - return checkPropertyAccessExpression(node); - case 157 /* QualifiedName */: - return checkQualifiedName(node); - case 202 /* ElementAccessExpression */: - return checkIndexedAccess(node); - case 203 /* CallExpression */: - if (node.expression.kind === 99 /* ImportKeyword */) { + case 203 /* PropertyAccessExpression */: + return checkPropertyAccessExpression(node, checkMode); + case 159 /* QualifiedName */: + return checkQualifiedName(node, checkMode); + case 204 /* ElementAccessExpression */: + return checkIndexedAccess(node, checkMode); + case 205 /* CallExpression */: + if (node.expression.kind === 100 /* ImportKeyword */) { return checkImportCallExpression(node); } // falls through - case 204 /* NewExpression */: + case 206 /* NewExpression */: return checkCallExpression(node, checkMode); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: return checkClassExpression(node); - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 211 /* TypeOfExpression */: + case 213 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 206 /* TypeAssertionExpression */: - case 224 /* AsExpression */: + case 208 /* TypeAssertionExpression */: + case 226 /* AsExpression */: return checkAssertion(node); - case 225 /* NonNullExpression */: + case 227 /* NonNullExpression */: return checkNonNullAssertion(node); - case 226 /* MetaProperty */: + case 228 /* MetaProperty */: return checkMetaProperty(node); - case 210 /* DeleteExpression */: + case 212 /* DeleteExpression */: return checkDeleteExpression(node); - case 212 /* VoidExpression */: + case 214 /* VoidExpression */: return checkVoidExpression(node); - case 213 /* AwaitExpression */: + case 215 /* AwaitExpression */: return checkAwaitExpression(node); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 220 /* SpreadElement */: + case 222 /* SpreadElement */: return checkSpreadExpression(node, checkMode); - case 222 /* OmittedExpression */: + case 224 /* OmittedExpression */: return undefinedWideningType; - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: return checkYieldExpression(node); - case 227 /* SyntheticExpression */: + case 229 /* SyntheticExpression */: return checkSyntheticExpression(node); - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: return checkJsxExpression(node, checkMode); - case 273 /* JsxElement */: + case 275 /* JsxElement */: return checkJsxElement(node, checkMode); - case 274 /* JsxSelfClosingElement */: + case 276 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 277 /* JsxFragment */: + case 279 /* JsxFragment */: return checkJsxFragment(node); - case 281 /* JsxAttributes */: + case 283 /* JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 275 /* JsxOpeningElement */: + case 277 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -72765,11 +75399,11 @@ var ts; checkGrammarDecoratorsAndModifiers(node); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); - if (ts.hasSyntacticModifier(node, 92 /* ParameterPropertyModifier */)) { - if (!(func.kind === 166 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */)) { + if (!(func.kind === 168 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } - if (func.kind === 166 /* Constructor */ && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") { + if (func.kind === 168 /* Constructor */ && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") { error(node.name, ts.Diagnostics.constructor_cannot_be_used_as_a_parameter_property_name); } } @@ -72780,13 +75414,13 @@ var ts; if (func.parameters.indexOf(node) !== 0) { error(node, ts.Diagnostics.A_0_parameter_must_be_the_first_parameter, node.name.escapedText); } - if (func.kind === 166 /* Constructor */ || func.kind === 170 /* ConstructSignature */ || func.kind === 175 /* ConstructorType */) { + if (func.kind === 168 /* Constructor */ || func.kind === 172 /* ConstructSignature */ || func.kind === 177 /* ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } - if (func.kind === 209 /* ArrowFunction */) { + if (func.kind === 211 /* ArrowFunction */) { error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter); } - if (func.kind === 167 /* GetAccessor */ || func.kind === 168 /* SetAccessor */) { + if (func.kind === 169 /* GetAccessor */ || func.kind === 170 /* SetAccessor */) { error(node, ts.Diagnostics.get_and_set_accessors_cannot_declare_this_parameters); } } @@ -72844,13 +75478,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 209 /* ArrowFunction */: - case 169 /* CallSignature */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 174 /* FunctionType */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 211 /* ArrowFunction */: + case 171 /* CallSignature */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 176 /* FunctionType */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: var parent = node.parent; if (node === parent.type) { return parent; @@ -72864,11 +75498,11 @@ var ts; continue; } var name = element.name; - if (name.kind === 78 /* Identifier */ && name.escapedText === predicateVariableName) { + if (name.kind === 79 /* 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 === 197 /* ArrayBindingPattern */ || name.kind === 196 /* ObjectBindingPattern */) { + else if (name.kind === 199 /* ArrayBindingPattern */ || name.kind === 198 /* ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -72877,13 +75511,13 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 171 /* IndexSignature */) { + if (node.kind === 173 /* 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 === 174 /* FunctionType */ || node.kind === 251 /* FunctionDeclaration */ || node.kind === 175 /* ConstructorType */ || - node.kind === 169 /* CallSignature */ || node.kind === 166 /* Constructor */ || - node.kind === 170 /* ConstructSignature */) { + else if (node.kind === 176 /* FunctionType */ || node.kind === 253 /* FunctionDeclaration */ || node.kind === 177 /* ConstructorType */ || + node.kind === 171 /* CallSignature */ || node.kind === 168 /* Constructor */ || + node.kind === 172 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); @@ -72913,10 +75547,10 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 170 /* ConstructSignature */: + case 172 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 169 /* CallSignature */: + case 171 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -72946,7 +75580,7 @@ var ts; checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 171 /* IndexSignature */ && node.kind !== 308 /* JSDocFunctionType */) { + if (node.kind !== 173 /* IndexSignature */ && node.kind !== 311 /* JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } @@ -72958,7 +75592,7 @@ 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 === 166 /* Constructor */) { + if (member.kind === 168 /* 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)) { @@ -72970,25 +75604,27 @@ var ts; var isStatic = ts.hasSyntacticModifier(member, 32 /* Static */); var name = member.name; if (!name) { - return; + continue; } - var names = ts.isPrivateIdentifier(name) ? privateIdentifiers : + var isPrivate = ts.isPrivateIdentifier(name); + var privateStaticFlags = isPrivate && isStatic ? 16 /* PrivateStatic */ : 0; + var names = isPrivate ? privateIdentifiers : isStatic ? staticNames : instanceNames; var memberName = name && ts.getPropertyNameForPropertyNameNode(name); if (memberName) { switch (member.kind) { - case 167 /* GetAccessor */: - addName(names, name, memberName, 1 /* GetAccessor */); + case 169 /* GetAccessor */: + addName(names, name, memberName, 1 /* GetAccessor */ | privateStaticFlags); break; - case 168 /* SetAccessor */: - addName(names, name, memberName, 2 /* SetAccessor */); + case 170 /* SetAccessor */: + addName(names, name, memberName, 2 /* SetAccessor */ | privateStaticFlags); break; - case 163 /* PropertyDeclaration */: - addName(names, name, memberName, 3 /* GetOrSetAccessor */); + case 165 /* PropertyDeclaration */: + addName(names, name, memberName, 3 /* GetOrSetAccessor */ | privateStaticFlags); break; - case 165 /* MethodDeclaration */: - addName(names, name, memberName, 8 /* Method */); + case 167 /* MethodDeclaration */: + addName(names, name, memberName, 8 /* Method */ | privateStaticFlags); break; } } @@ -72997,16 +75633,25 @@ var ts; function addName(names, location, name, meaning) { var prev = names.get(name); if (prev) { - if (prev & 8 /* Method */) { - if (meaning !== 8 /* Method */) { - error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); - } - } - else if (prev & meaning) { - error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); + // For private identifiers, do not allow mixing of static and instance members with the same name + if ((prev & 16 /* PrivateStatic */) !== (meaning & 16 /* PrivateStatic */)) { + error(location, ts.Diagnostics.Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name, ts.getTextOfNode(location)); } else { - names.set(name, prev | meaning); + var prevIsMethod = !!(prev & 8 /* Method */); + var isMethod = !!(meaning & 8 /* 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 */) { + error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); + } + else { + names.set(name, prev | meaning); + } } } else { @@ -73050,7 +75695,7 @@ 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 === 162 /* PropertySignature */) { + if (member.kind === 164 /* PropertySignature */) { var memberName = void 0; var name = member.name; switch (name.kind) { @@ -73058,7 +75703,7 @@ var ts; case 8 /* NumericLiteral */: memberName = name.text; break; - case 78 /* Identifier */: + case 79 /* Identifier */: memberName = ts.idText(name); break; default: @@ -73075,11 +75720,11 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 253 /* InterfaceDeclaration */) { + if (node.kind === 255 /* 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 - if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { + if (nodeSymbol.declarations && nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; } } @@ -73087,7 +75732,7 @@ var ts; // 3.7.4: An object type can contain at most one string index signature and one numeric index signature. // 8.5: A class declaration can have at most one string index member declaration and one numeric index member declaration var indexSymbol = getIndexSymbol(getSymbolOfNode(node)); - if (indexSymbol) { + if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) { var seenNumericIndexer = false; var seenStringIndexer = false; for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -73095,7 +75740,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 147 /* StringKeyword */: + case 148 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -73103,7 +75748,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 144 /* NumberKeyword */: + case 145 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -73121,11 +75766,13 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && !checkGrammarProperty(node)) checkGrammarComputedPropertyName(node.name); checkVariableLikeDeclaration(node); - // Private class fields transformation relies on WeakMaps. - if (ts.isPrivateIdentifier(node.name) && languageVersion < 99 /* ESNext */) { - for (var lexicalScope = ts.getEnclosingBlockScopeContainer(node); !!lexicalScope; lexicalScope = ts.getEnclosingBlockScopeContainer(lexicalScope)) { - getNodeLinks(lexicalScope).flags |= 67108864 /* ContainsClassWithPrivateIdentifiers */; - } + setNodeLinksForPrivateIdentifierScope(node); + if (ts.isPrivateIdentifier(node.name) && ts.hasStaticModifier(node) && node.initializer && languageVersion === 99 /* ESNext */ && !compilerOptions.useDefineForClassFields) { + error(node.initializer, ts.Diagnostics.Static_fields_with_private_names_can_t_have_initializers_when_the_useDefineForClassFields_flag_is_not_specified_with_a_target_of_esnext_Consider_adding_the_useDefineForClassFields_flag); + } + // property signatures already report "initializer not allowed in ambient context" elsewhere + if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 165 /* PropertyDeclaration */ && node.initializer) { + error(node, ts.Diagnostics.Property_0_cannot_have_an_initializer_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } function checkPropertySignature(node) { @@ -73138,16 +75785,34 @@ var ts; // Grammar checking if (!checkGrammarMethod(node)) checkGrammarComputedPropertyName(node.name); - if (ts.isPrivateIdentifier(node.name)) { - error(node, ts.Diagnostics.A_method_cannot_be_named_with_a_private_identifier); - } // Grammar checking for modifiers is done inside the function checkGrammarFunctionLikeDeclaration checkFunctionOrMethodDeclaration(node); - // Abstract methods cannot have an implementation. - // Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node. - if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 165 /* MethodDeclaration */ && node.body) { + // method signatures already report "implementation not allowed in ambient context" elsewhere + if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 167 /* 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 + if (ts.isPrivateIdentifier(node.name) && !ts.getContainingClass(node)) { + error(node, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); + } + setNodeLinksForPrivateIdentifierScope(node); + } + function setNodeLinksForPrivateIdentifierScope(node) { + if (ts.isPrivateIdentifier(node.name) && languageVersion < 99 /* ESNext */) { + for (var lexicalScope = ts.getEnclosingBlockScopeContainer(node); !!lexicalScope; lexicalScope = ts.getEnclosingBlockScopeContainer(lexicalScope)) { + getNodeLinks(lexicalScope).flags |= 67108864 /* 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 + // to transform private elements. + if (ts.isClassExpression(node.parent)) { + var enclosingIterationStatement = getEnclosingIterationStatement(node.parent); + if (enclosingIterationStatement) { + getNodeLinks(node.name).flags |= 524288 /* BlockScopedBindingInLoop */; + getNodeLinks(enclosingIterationStatement).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */; + } + } + } } function checkConstructorDeclaration(node) { // Grammar check on signature of constructor and modifier of the constructor is done in checkSignatureDeclaration function. @@ -73170,10 +75835,10 @@ var ts; return; } function isInstancePropertyWithInitializerOrPrivateIdentifierProperty(n) { - if (ts.isPrivateIdentifierPropertyDeclaration(n)) { + if (ts.isPrivateIdentifierClassElementDeclaration(n)) { return true; } - return n.kind === 163 /* PropertyDeclaration */ && + return n.kind === 165 /* PropertyDeclaration */ && !ts.hasSyntacticModifier(n, 32 /* Static */) && !!n.initializer; } @@ -73194,9 +75859,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 superCallShouldBeFirst = (compilerOptions.target !== 99 /* ESNext */ || !compilerOptions.useDefineForClassFields) && + var superCallShouldBeFirst = (compilerOptions.target !== 99 /* ESNext */ || !useDefineForClassFields) && (ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) || - ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 92 /* ParameterPropertyModifier */); })); + ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476 /* ParameterPropertyModifier */); })); // Skip past any prologue directives to find the first statement // to ensure that it was a super call. if (superCallShouldBeFirst) { @@ -73204,7 +75869,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_4 = statements; _i < statements_4.length; _i++) { var statement = statements_4[_i]; - if (statement.kind === 233 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 235 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -73229,7 +75894,7 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 167 /* GetAccessor */) { + if (node.kind === 169 /* GetAccessor */) { if (!(node.flags & 8388608 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* HasImplicitReturn */)) { if (!(node.flags & 512 /* HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); @@ -73239,45 +75904,42 @@ 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 === 158 /* ComputedPropertyName */) { + if (node.name.kind === 160 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } - if (ts.isPrivateIdentifier(node.name)) { - error(node.name, ts.Diagnostics.An_accessor_cannot_be_named_with_a_private_identifier); - } - if (!hasNonBindableDynamicName(node)) { + if (hasBindableName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. - var otherKind = node.kind === 167 /* GetAccessor */ ? 168 /* SetAccessor */ : 167 /* GetAccessor */; - var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); - if (otherAccessor) { - var nodeFlags = ts.getEffectiveModifierFlags(node); - var otherFlags = ts.getEffectiveModifierFlags(otherAccessor); - if ((nodeFlags & 28 /* AccessibilityModifier */) !== (otherFlags & 28 /* AccessibilityModifier */)) { - error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); + var symbol = getSymbolOfNode(node); + var getter = ts.getDeclarationOfKind(symbol, 169 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 170 /* SetAccessor */); + if (getter && setter && !(getNodeCheckFlags(getter) & 1 /* TypeChecked */)) { + getNodeLinks(getter).flags |= 1 /* TypeChecked */; + var getterFlags = ts.getEffectiveModifierFlags(getter); + var setterFlags = ts.getEffectiveModifierFlags(setter); + if ((getterFlags & 128 /* Abstract */) !== (setterFlags & 128 /* 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 */))) { + 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); } - if ((nodeFlags & 128 /* Abstract */) !== (otherFlags & 128 /* Abstract */)) { - error(node.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); + var getterType = getAnnotatedAccessorType(getter); + var setterType = getAnnotatedAccessorType(setter); + if (getterType && setterType) { + checkTypeAssignableTo(getterType, setterType, getter, ts.Diagnostics.The_return_type_of_a_get_accessor_must_be_assignable_to_its_set_accessor_type); } - // TypeScript 1.0 spec (April 2014): 4.5 - // If both accessors include type annotations, the specified types must be identical. - checkAccessorDeclarationTypesIdentical(node, otherAccessor, getAnnotatedAccessorType, ts.Diagnostics.get_and_set_accessor_must_have_the_same_type); - checkAccessorDeclarationTypesIdentical(node, otherAccessor, getThisTypeOfDeclaration, ts.Diagnostics.get_and_set_accessor_must_have_the_same_this_type); } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 167 /* GetAccessor */) { + if (node.kind === 169 /* GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } checkSourceElement(node.body); - } - function checkAccessorDeclarationTypesIdentical(first, second, getAnnotatedType, message) { - var firstType = getAnnotatedType(first); - var secondType = getAnnotatedType(second); - if (firstType && secondType && !isTypeIdenticalTo(firstType, secondType)) { - error(first, message); - } + setNodeLinksForPrivateIdentifierScope(node); } function checkMissingDeclaration(node) { checkDecorators(node); @@ -73314,7 +75976,7 @@ var ts; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 173 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 175 /* 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); @@ -73329,7 +75991,7 @@ var ts; var symbol = getNodeLinks(node).resolvedSymbol; if (symbol) { if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 134217728 /* Deprecated */); })) { - errorOrSuggestion(/* isError */ false, getDeprecatedSuggestionNode(node), ts.Diagnostics._0_is_deprecated, symbol.escapedName); + addDeprecatedSuggestion(getDeprecatedSuggestionNode(node), symbol.declarations, symbol.escapedName); } if (type.flags & 32 /* Enum */ && symbol.flags & 8 /* EnumMember */) { error(node, ts.Diagnostics.Enum_type_0_has_members_with_initializers_that_are_not_literals, typeToString(type)); @@ -73367,7 +76029,7 @@ 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 !== 192 /* NamedTupleMember */ && hasNamedElement) { + if (e.kind !== 194 /* NamedTupleMember */ && hasNamedElement) { grammarErrorOnNode(e, ts.Diagnostics.Tuple_members_must_all_have_names_or_all_not_have_names); break; } @@ -73416,7 +76078,7 @@ var ts; var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, /*stringsOnly*/ false))) { - if (accessNode.kind === 202 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 204 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && ts.getObjectFlags(objectType) & 32 /* Mapped */ && getMappedTypeModifiers(objectType) & 1 /* IncludeReadonly */) { error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); } @@ -73474,7 +76136,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 184 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 186 /* 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); @@ -73497,25 +76159,25 @@ var ts; if (node.dotDotDotToken && node.questionToken) { grammarErrorOnNode(node, ts.Diagnostics.A_tuple_member_cannot_be_both_optional_and_rest); } - if (node.type.kind === 180 /* OptionalType */) { + if (node.type.kind === 182 /* 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 === 181 /* RestType */) { + if (node.type.kind === 183 /* 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.isPrivateIdentifierPropertyDeclaration(node)) && !!(node.flags & 8388608 /* Ambient */); + return (ts.hasEffectiveModifier(node, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 8388608 /* 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 !== 253 /* InterfaceDeclaration */ && - n.parent.kind !== 252 /* ClassDeclaration */ && - n.parent.kind !== 221 /* ClassExpression */ && + if (n.parent.kind !== 255 /* InterfaceDeclaration */ && + n.parent.kind !== 254 /* ClassDeclaration */ && + n.parent.kind !== 223 /* ClassExpression */ && n.flags & 8388608 /* Ambient */) { if (!(flags & 2 /* 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 @@ -73611,7 +76273,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 === 165 /* MethodDeclaration */ || node.kind === 164 /* MethodSignature */) && + var reportError = (node.kind === 167 /* MethodDeclaration */ || node.kind === 166 /* MethodSignature */) && ts.hasSyntacticModifier(node, 32 /* Static */) !== ts.hasSyntacticModifier(subsequentNode, 32 /* Static */); // we can get here in two cases // 1. mixed static and instance class members @@ -73648,55 +76310,57 @@ var ts; var multipleConstructorImplementation = false; var hasNonAmbientClass = false; var functionDeclarations = []; - for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { - var current = declarations_4[_i]; - var node = current; - var inAmbientContext = node.flags & 8388608 /* Ambient */; - var inAmbientContextOrInterface = node.parent && (node.parent.kind === 253 /* InterfaceDeclaration */ || node.parent.kind === 177 /* TypeLiteral */) || inAmbientContext; - if (inAmbientContextOrInterface) { - // check if declarations are consecutive only if they are non-ambient - // 1. ambient declarations can be interleaved - // i.e. this is legal - // declare function foo(); - // declare function bar(); - // declare function foo(); - // 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 === 252 /* ClassDeclaration */ || node.kind === 221 /* ClassExpression */) && !inAmbientContext) { - hasNonAmbientClass = true; - } - if (node.kind === 251 /* FunctionDeclaration */ || node.kind === 165 /* MethodDeclaration */ || node.kind === 164 /* MethodSignature */ || node.kind === 166 /* Constructor */) { - functionDeclarations.push(node); - var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); - someNodeFlags |= currentNodeFlags; - allNodeFlags &= currentNodeFlags; - someHaveQuestionToken = someHaveQuestionToken || ts.hasQuestionToken(node); - allHaveQuestionToken = allHaveQuestionToken && ts.hasQuestionToken(node); - var bodyIsPresent = ts.nodeIsPresent(node.body); - if (bodyIsPresent && bodyDeclaration) { - if (isConstructor) { - multipleConstructorImplementation = true; + if (declarations) { + for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { + var current = declarations_4[_i]; + var node = current; + var inAmbientContext = node.flags & 8388608 /* Ambient */; + var inAmbientContextOrInterface = node.parent && (node.parent.kind === 255 /* InterfaceDeclaration */ || node.parent.kind === 179 /* TypeLiteral */) || inAmbientContext; + if (inAmbientContextOrInterface) { + // check if declarations are consecutive only if they are non-ambient + // 1. ambient declarations can be interleaved + // i.e. this is legal + // declare function foo(); + // declare function bar(); + // declare function foo(); + // 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 === 254 /* ClassDeclaration */ || node.kind === 223 /* ClassExpression */) && !inAmbientContext) { + hasNonAmbientClass = true; + } + if (node.kind === 253 /* FunctionDeclaration */ || node.kind === 167 /* MethodDeclaration */ || node.kind === 166 /* MethodSignature */ || node.kind === 168 /* Constructor */) { + functionDeclarations.push(node); + var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); + someNodeFlags |= currentNodeFlags; + allNodeFlags &= currentNodeFlags; + someHaveQuestionToken = someHaveQuestionToken || ts.hasQuestionToken(node); + allHaveQuestionToken = allHaveQuestionToken && ts.hasQuestionToken(node); + var bodyIsPresent = ts.nodeIsPresent(node.body); + if (bodyIsPresent && bodyDeclaration) { + if (isConstructor) { + multipleConstructorImplementation = true; + } + else { + duplicateFunctionDeclaration = true; + } + } + else if ((previousDeclaration === null || previousDeclaration === void 0 ? void 0 : previousDeclaration.parent) === node.parent && previousDeclaration.end !== node.pos) { + reportImplementationExpectedError(previousDeclaration); + } + if (bodyIsPresent) { + if (!bodyDeclaration) { + bodyDeclaration = node; + } } else { - duplicateFunctionDeclaration = true; + hasOverloads = true; } - } - else if ((previousDeclaration === null || previousDeclaration === void 0 ? void 0 : previousDeclaration.parent) === node.parent && previousDeclaration.end !== node.pos) { - reportImplementationExpectedError(previousDeclaration); - } - if (bodyIsPresent) { - if (!bodyDeclaration) { - bodyDeclaration = node; + previousDeclaration = node; + if (!inAmbientContextOrInterface) { + lastSeenNonAmbientDeclaration = node; } } - else { - hasOverloads = true; - } - previousDeclaration = node; - if (!inAmbientContextOrInterface) { - lastSeenNonAmbientDeclaration = node; - } } } if (multipleConstructorImplementation) { @@ -73709,13 +76373,18 @@ var ts; error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Duplicate_function_implementation); }); } - if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 /* Function */) { - // A non-ambient class cannot be an implementation for a non-constructor function/class merge - // TODO: The below just replicates our older error from when classes and functions were - // entirely unable to merge - a more helpful message like "Class declaration cannot implement overload list" - // might be warranted. :shrug: + if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 /* Function */ && declarations) { + var relatedDiagnostics_1 = ts.filter(declarations, function (d) { return d.kind === 254 /* ClassDeclaration */; }) + .map(function (d) { return ts.createDiagnosticForNode(d, ts.Diagnostics.Consider_adding_a_declare_modifier_to_this_class); }); ts.forEach(declarations, function (declaration) { - addDuplicateDeclarationError(declaration, ts.Diagnostics.Duplicate_identifier_0, ts.symbolName(symbol), declarations); + var diagnostic = declaration.kind === 254 /* ClassDeclaration */ + ? ts.Diagnostics.Class_declaration_cannot_implement_overload_list_for_0 + : declaration.kind === 253 /* FunctionDeclaration */ + ? ts.Diagnostics.Function_with_bodies_can_only_merge_with_classes_that_are_ambient + : undefined; + if (diagnostic) { + ts.addRelatedInfo.apply(void 0, __spreadArray([error(ts.getNameOfDeclaration(declaration) || declaration, diagnostic, ts.symbolName(symbol))], relatedDiagnostics_1)); + } }); } // Abstract methods can't have an implementation -- in particular, they don't need one. @@ -73724,8 +76393,10 @@ var ts; reportImplementationExpectedError(lastSeenNonAmbientDeclaration); } if (hasOverloads) { - checkFlagAgreementBetweenOverloads(declarations, bodyDeclaration, flagsToCheck, someNodeFlags, allNodeFlags); - checkQuestionTokenAgreementBetweenOverloads(declarations, bodyDeclaration, someHaveQuestionToken, allHaveQuestionToken); + if (declarations) { + checkFlagAgreementBetweenOverloads(declarations, bodyDeclaration, flagsToCheck, someNodeFlags, allNodeFlags); + checkQuestionTokenAgreementBetweenOverloads(declarations, bodyDeclaration, someHaveQuestionToken, allHaveQuestionToken); + } if (bodyDeclaration) { var signatures = getSignaturesOfSymbol(symbol); var bodySignature = getSignatureFromDeclaration(bodyDeclaration); @@ -73799,44 +76470,47 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: // A jsdoc typedef and callback are, by definition, type aliases. // falls through - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 325 /* JSDocEnumTag */: + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + case 333 /* JSDocEnumTag */: return 2 /* ExportType */; - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4 /* ExportNamespace */ | 1 /* ExportValue */ : 4 /* ExportNamespace */; - case 252 /* ClassDeclaration */: - case 255 /* EnumDeclaration */: - case 291 /* EnumMember */: + case 254 /* ClassDeclaration */: + case 257 /* EnumDeclaration */: + case 293 /* EnumMember */: return 2 /* ExportType */ | 1 /* ExportValue */; - case 297 /* SourceFile */: + case 299 /* SourceFile */: return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: + case 218 /* 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(d.expression)) { + if (!ts.isEntityNameExpression(expression)) { return 1 /* ExportValue */; } - d = d.expression; + d = expression; // The below options all declare an Alias, which is allowed to merge with other values within the importing module. // falls through - case 260 /* ImportEqualsDeclaration */: - case 263 /* NamespaceImport */: - case 262 /* ImportClause */: + case 262 /* ImportEqualsDeclaration */: + case 265 /* NamespaceImport */: + case 264 /* ImportClause */: var result_12 = 0 /* None */; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_12 |= getDeclarationSpaces(d); }); return result_12; - case 249 /* VariableDeclaration */: - case 198 /* BindingElement */: - case 251 /* FunctionDeclaration */: - case 265 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 - case 78 /* Identifier */: // https://github.com/microsoft/TypeScript/issues/36098 + case 251 /* VariableDeclaration */: + case 200 /* BindingElement */: + case 253 /* FunctionDeclaration */: + case 267 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 79 /* 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) @@ -74088,7 +76762,7 @@ var ts; var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* Value */, /*ignoreErrors*/ true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; if (promiseConstructorType === errorType) { - if (promiseConstructorName.kind === 78 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { + if (promiseConstructorName.kind === 79 /* 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 { @@ -74128,24 +76802,24 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 160 /* Parameter */: + case 162 /* Parameter */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages( /*details*/ undefined, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages( /*details*/ undefined, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -74166,7 +76840,7 @@ var ts; if (!typeName) return; var rootName = ts.getFirstIdentifier(typeName); - var meaning = (typeName.kind === 78 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; + var meaning = (typeName.kind === 79 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isRefernce*/ true); if (rootSymbol && rootSymbol.flags & 2097152 /* Alias */ @@ -74192,15 +76866,15 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 183 /* IntersectionType */: - case 182 /* UnionType */: + case 185 /* IntersectionType */: + case 184 /* UnionType */: return getEntityNameForDecoratorMetadataFromTypeList(node.types); - case 184 /* ConditionalType */: + case 186 /* ConditionalType */: return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]); - case 186 /* ParenthesizedType */: - case 192 /* NamedTupleMember */: + case 188 /* ParenthesizedType */: + case 194 /* NamedTupleMember */: return getEntityNameForDecoratorMetadata(node.type); - case 173 /* TypeReference */: + case 175 /* TypeReference */: return node.typeName; } } @@ -74209,13 +76883,13 @@ var ts; var commonEntityName; for (var _i = 0, types_23 = types; _i < types_23.length; _i++) { var typeNode = types_23[_i]; - while (typeNode.kind === 186 /* ParenthesizedType */ || typeNode.kind === 192 /* NamedTupleMember */) { + while (typeNode.kind === 188 /* ParenthesizedType */ || typeNode.kind === 194 /* NamedTupleMember */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 141 /* NeverKeyword */) { + if (typeNode.kind === 142 /* NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 191 /* LiteralType */ && typeNode.literal.kind === 103 /* NullKeyword */ || typeNode.kind === 150 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 193 /* LiteralType */ && typeNode.literal.kind === 104 /* NullKeyword */ || typeNode.kind === 151 /* 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); @@ -74261,14 +76935,14 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 160 /* Parameter */) { + if (node.kind === 162 /* Parameter */) { checkExternalEmitHelpers(firstDecorator, 32 /* Param */); } if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16 /* 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 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -74277,23 +76951,23 @@ var ts; } } break; - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - var otherKind = node.kind === 167 /* GetAccessor */ ? 168 /* SetAccessor */ : 167 /* GetAccessor */; + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + var otherKind = node.kind === 169 /* GetAccessor */ ? 170 /* SetAccessor */ : 169 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); break; - case 165 /* MethodDeclaration */: + case 167 /* 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 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 160 /* Parameter */: + case 162 /* Parameter */: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -74356,7 +77030,7 @@ var ts; else if (ts.findLast(ts.getJSDocTags(decl), ts.isJSDocParameterTag) === node && node.typeExpression && node.typeExpression.type && !isArrayType(getTypeFromTypeNode(node.typeExpression.type))) { - error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 157 /* QualifiedName */ ? node.name.right : node.name)); + error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 159 /* QualifiedName */ ? node.name.right : node.name)); } } } @@ -74398,27 +77072,28 @@ var ts; } function getIdentifierFromEntityNameExpression(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return node; - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return node.name; default: return undefined; } } function checkFunctionOrMethodDeclaration(node) { + var _a; checkDecorators(node); checkSignatureDeclaration(node); var functionFlags = ts.getFunctionFlags(node); // 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 === 158 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 160 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); } - if (!hasNonBindableDynamicName(node)) { + if (hasBindableName(node)) { // first we want to check the local symbol that contain this declaration // - if node.localSymbol !== undefined - this is current declaration is exported and localSymbol points to the local symbol // - if node.localSymbol === undefined - this node is non-exported so we can just pick the result of getSymbolOfNode @@ -74427,7 +77102,7 @@ var ts; // Since the javascript won't do semantic analysis like typescript, // if the javascript file comes before the typescript file and both contain same name functions, // checkFunctionOrConstructorSymbol wouldn't be called if we didnt ignore javascript function. - var firstDeclaration = ts.find(localSymbol.declarations, + 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 & 131072 /* JavaScriptFile */); }); // Only type check the symbol once @@ -74439,7 +77114,7 @@ var ts; checkFunctionOrConstructorSymbol(symbol); } } - var body = node.kind === 164 /* MethodSignature */ ? undefined : node.body; + var body = node.kind === 166 /* MethodSignature */ ? undefined : node.body; checkSourceElement(body); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node)); if (produceDiagnostics && !ts.getEffectiveReturnTypeNode(node)) { @@ -74481,42 +77156,42 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 297 /* SourceFile */: - case 256 /* ModuleDeclaration */: - case 230 /* Block */: - case 258 /* CaseBlock */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: + case 299 /* SourceFile */: + case 258 /* ModuleDeclaration */: + case 232 /* Block */: + case 260 /* CaseBlock */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 166 /* Constructor */: - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 168 /* Constructor */: + case 210 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 211 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: if (node.body) { // Don't report unused parameters in overloads checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 164 /* MethodSignature */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 254 /* TypeAliasDeclaration */: - case 253 /* InterfaceDeclaration */: + case 166 /* MethodSignature */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: + case 256 /* TypeAliasDeclaration */: + case 255 /* InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 185 /* InferType */: + case 187 /* InferType */: checkUnusedInferTypeParameter(node, addDiagnostic); break; default: @@ -74536,11 +77211,11 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 165 /* MethodDeclaration */: - case 163 /* PropertyDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - if (member.kind === 168 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { + case 167 /* MethodDeclaration */: + case 165 /* PropertyDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + if (member.kind === 170 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { // Already would have reported an error on the getter. break; } @@ -74551,7 +77226,7 @@ var ts; addDiagnostic(member, 0 /* Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); } break; - case 166 /* Constructor */: + case 168 /* 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 */)) { @@ -74559,8 +77234,8 @@ var ts; } } break; - case 171 /* IndexSignature */: - case 229 /* SemicolonClassElement */: + case 173 /* IndexSignature */: + case 231 /* SemicolonClassElement */: // Can't be private break; default: @@ -74577,7 +77252,8 @@ var ts; function checkUnusedTypeParameters(node, addDiagnostic) { // Only report errors on the last declaration for the type parameter container; // this ensures that all uses have been accounted for. - if (ts.last(getSymbolOfNode(node).declarations) !== node) + var declarations = getSymbolOfNode(node).declarations; + if (!declarations || ts.last(declarations) !== node) return; var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); var seenParentsWithEveryUnused = new ts.Set(); @@ -74587,7 +77263,7 @@ var ts; continue; var name = ts.idText(typeParameter.name); var parent = typeParameter.parent; - if (parent.kind !== 185 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { + if (parent.kind !== 187 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { if (ts.tryAddToSet(seenParentsWithEveryUnused, parent)) { var sourceFile = ts.getSourceFileOfNode(parent); var range = ts.isJSDocTemplateTag(parent) @@ -74596,12 +77272,14 @@ var ts; // Include the `<>` in the error message : ts.rangeOfTypeParameters(sourceFile, parent.typeParameters); var only = parent.typeParameters.length === 1; + //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)); } } 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)); } } @@ -74623,11 +77301,15 @@ var ts; return ts.tryCast(ts.getRootDeclaration(node), ts.isParameter); } function isValidUnusedLocalDeclaration(declaration) { - if (ts.isBindingElement(declaration) && isIdentifierThatStartsWithUnderscore(declaration.name)) { - return !!ts.findAncestor(declaration.parent, function (ancestor) { - return ts.isArrayBindingPattern(ancestor) || ts.isVariableDeclaration(ancestor) || ts.isVariableDeclarationList(ancestor) ? false : - ts.isForOfStatement(ancestor) ? true : "quit"; - }); + if (ts.isBindingElement(declaration)) { + if (ts.isObjectBindingPattern(declaration.parent)) { + /** + * ignore starts with underscore names _ + * const { a: _a } = { a: 1 } + */ + return !!(declaration.propertyName && isIdentifierThatStartsWithUnderscore(declaration.name)); + } + return isIdentifierThatStartsWithUnderscore(declaration.name); } return ts.isAmbientModule(declaration) || (ts.isVariableDeclaration(declaration) && ts.isForInOrOfStatement(declaration.parent.parent) || isImportedDeclaration(declaration)) && isIdentifierThatStartsWithUnderscore(declaration.name); @@ -74643,39 +77325,41 @@ var ts; if (local.flags & 262144 /* TypeParameter */ ? !(local.flags & 3 /* Variable */ && !(local.isReferenced & 3 /* Variable */)) : local.isReferenced || local.exportSymbol) { return; } - for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (isValidUnusedLocalDeclaration(declaration)) { - continue; - } - if (isImportedDeclaration(declaration)) { - addToGroup(unusedImports, importClauseFromImported(declaration), declaration, getNodeId); - } - else if (ts.isBindingElement(declaration) && ts.isObjectBindingPattern(declaration.parent)) { - // In `{ a, ...b }, `a` is considered used since it removes a property from `b`. `b` may still be unused though. - var lastElement = ts.last(declaration.parent.elements); - if (declaration === lastElement || !ts.last(declaration.parent.elements).dotDotDotToken) { - addToGroup(unusedDestructures, declaration.parent, declaration, getNodeId); + if (local.declarations) { + for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (isValidUnusedLocalDeclaration(declaration)) { + continue; } - } - else if (ts.isVariableDeclaration(declaration)) { - addToGroup(unusedVariables, declaration.parent, declaration, getNodeId); - } - else { - var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); - var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration); - if (parameter && name) { - if (!ts.isParameterPropertyDeclaration(parameter, parameter.parent) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { - if (ts.isBindingElement(declaration) && ts.isArrayBindingPattern(declaration.parent)) { - 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))); - } + if (isImportedDeclaration(declaration)) { + addToGroup(unusedImports, importClauseFromImported(declaration), declaration, getNodeId); + } + else if (ts.isBindingElement(declaration) && ts.isObjectBindingPattern(declaration.parent)) { + // In `{ a, ...b }, `a` is considered used since it removes a property from `b`. `b` may still be unused though. + var lastElement = ts.last(declaration.parent.elements); + if (declaration === lastElement || !ts.last(declaration.parent.elements).dotDotDotToken) { + addToGroup(unusedDestructures, declaration.parent, declaration, getNodeId); } } + else if (ts.isVariableDeclaration(declaration)) { + addToGroup(unusedVariables, declaration.parent, declaration, getNodeId); + } else { - errorUnusedLocal(declaration, ts.symbolName(local), addDiagnostic); + var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); + var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration); + if (parameter && name) { + if (!ts.isParameterPropertyDeclaration(parameter, parameter.parent) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { + if (ts.isBindingElement(declaration) && ts.isArrayBindingPattern(declaration.parent)) { + 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))); + } + } + } + else { + errorUnusedLocal(declaration, ts.symbolName(local), addDiagnostic); + } } } } @@ -74685,7 +77369,7 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 263 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 265 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { addDiagnostic(importDecl, 0 /* Local */, unuseds.length === 1 @@ -74703,7 +77387,7 @@ var ts; var bindingPattern = _a[0], bindingElements = _a[1]; var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* Parameter */ : 0 /* Local */; if (bindingPattern.elements.length === bindingElements.length) { - if (bindingElements.length === 1 && bindingPattern.parent.kind === 249 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 250 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 251 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 252 /* VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -74724,7 +77408,7 @@ var ts; if (declarationList.declarations.length === declarations.length) { addDiagnostic(declarationList, 0 /* 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 === 232 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 234 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { @@ -74736,24 +77420,24 @@ var ts; } function bindingNameText(name) { switch (name.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return ts.idText(name); - case 197 /* ArrayBindingPattern */: - case 196 /* ObjectBindingPattern */: + case 199 /* ArrayBindingPattern */: + case 198 /* ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 262 /* ImportClause */ || node.kind === 265 /* ImportSpecifier */ || node.kind === 263 /* NamespaceImport */; + return node.kind === 264 /* ImportClause */ || node.kind === 267 /* ImportSpecifier */ || node.kind === 265 /* NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 262 /* ImportClause */ ? decl : decl.kind === 263 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 264 /* ImportClause */ ? decl : decl.kind === 265 /* NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 230 /* Block */) { + if (node.kind === 232 /* Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -74783,12 +77467,12 @@ var ts; if (!(identifier && identifier.escapedText === name)) { return false; } - if (node.kind === 163 /* PropertyDeclaration */ || - node.kind === 162 /* PropertySignature */ || - node.kind === 165 /* MethodDeclaration */ || - node.kind === 164 /* MethodSignature */ || - node.kind === 167 /* GetAccessor */ || - node.kind === 168 /* SetAccessor */) { + if (node.kind === 165 /* PropertyDeclaration */ || + node.kind === 164 /* PropertySignature */ || + node.kind === 167 /* MethodDeclaration */ || + node.kind === 166 /* MethodSignature */ || + node.kind === 169 /* GetAccessor */ || + node.kind === 170 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -74797,7 +77481,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 160 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 162 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -74807,7 +77491,7 @@ var ts; function checkIfThisIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 78 /* Identifier */; + var isDeclaration_1 = node.kind !== 79 /* Identifier */; if (isDeclaration_1) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -74822,7 +77506,7 @@ var ts; function checkIfNewTargetIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 8 /* CaptureNewTarget */) { - var isDeclaration_2 = node.kind !== 78 /* Identifier */; + var isDeclaration_2 = node.kind !== 79 /* 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); } @@ -74834,10 +77518,11 @@ var ts; return false; }); } - function checkWeakMapCollision(node) { + function checkWeakMapSetCollision(node) { var enclosingBlockScope = ts.getEnclosingBlockScopeContainer(node); if (getNodeCheckFlags(enclosingBlockScope) & 67108864 /* ContainsClassWithPrivateIdentifiers */) { - errorSkippedOn("noEmit", node, ts.Diagnostics.Compiler_reserves_name_0_when_emitting_private_identifier_downlevel, "WeakMap"); + 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 checkCollisionWithRequireExportsInGeneratedCode(node, name) { @@ -74854,7 +77539,7 @@ var ts; } // 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 === 297 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 299 /* 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)); } @@ -74869,7 +77554,7 @@ var ts; } // 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 === 297 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* HasAsyncFunctions */) { + if (parent.kind === 299 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* 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)); } @@ -74904,7 +77589,7 @@ var ts; // 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 === 249 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 251 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -74916,17 +77601,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 250 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 232 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 252 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 234 /* 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 === 230 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 257 /* ModuleBlock */ || - container.kind === 256 /* ModuleDeclaration */ || - container.kind === 297 /* SourceFile */); + (container.kind === 232 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 259 /* ModuleBlock */ || + container.kind === 258 /* ModuleDeclaration */ || + container.kind === 299 /* 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 @@ -74957,18 +77642,18 @@ 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 === 158 /* ComputedPropertyName */) { + if (node.name.kind === 160 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 198 /* BindingElement */) { - if (node.parent.kind === 196 /* ObjectBindingPattern */ && languageVersion < 99 /* ESNext */) { + if (ts.isBindingElement(node)) { + if (ts.isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ES2018 */) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 158 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 160 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access @@ -74981,15 +77666,15 @@ var ts; var nameText = getPropertyNameFromType(exprType); var property = getPropertyOfType(parentType, nameText); if (property) { - markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined, /*isThisAccess*/ false); // A destructuring is never a write-only reference. - checkPropertyAccessibility(parent, !!parent.initializer && parent.initializer.kind === 105 /* SuperKeyword */, parentType, 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); } } } } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 197 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + if (node.name.kind === 199 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, 512 /* Read */); } ts.forEach(node.name.elements, checkSourceElement); @@ -75001,7 +77686,7 @@ var ts; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { - var needCheckInitializer = node.initializer && node.parent.parent.kind !== 238 /* ForInStatement */; + var needCheckInitializer = node.initializer && node.parent.parent.kind !== 240 /* ForInStatement */; var needCheckWidenedType = node.name.elements.length === 0; if (needCheckInitializer || needCheckWidenedType) { // Don't validate for-in initializer as it is already an error @@ -75029,7 +77714,7 @@ var ts; } // For a commonjs `const x = require`, validate the alias and exit var symbol = getSymbolOfNode(node); - if (symbol.flags & 2097152 /* Alias */ && ts.isRequireVariableDeclaration(node, /*requireStringLiteralLikeArgument*/ true)) { + if (symbol.flags & 2097152 /* Alias */ && ts.isRequireVariableDeclaration(node)) { checkAliasSymbol(node); return; } @@ -75043,11 +77728,11 @@ 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 !== 238 /* ForInStatement */) { + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 240 /* ForInStatement */) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); } } - if (symbol.declarations.length > 1) { + if (symbol.declarations && symbol.declarations.length > 1) { if (ts.some(symbol.declarations, function (d) { return d !== node && ts.isVariableLike(d) && !areDeclarationFlagsIdentical(d, node); })) { error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } @@ -75065,26 +77750,27 @@ var ts; if (node.initializer) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(node.initializer), declarationType, node, node.initializer, /*headMessage*/ undefined); } - if (!areDeclarationFlagsIdentical(node, symbol.valueDeclaration)) { + if (symbol.valueDeclaration && !areDeclarationFlagsIdentical(node, symbol.valueDeclaration)) { error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 163 /* PropertyDeclaration */ && node.kind !== 162 /* PropertySignature */) { + if (node.kind !== 165 /* PropertyDeclaration */ && node.kind !== 164 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 249 /* VariableDeclaration */ || node.kind === 198 /* BindingElement */) { + if (node.kind === 251 /* VariableDeclaration */ || node.kind === 200 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); - if (languageVersion < 99 /* ESNext */ && needCollisionCheckForIdentifier(node, node.name, "WeakMap")) { - potentialWeakMapCollisions.push(node); + if (languageVersion < 99 /* ESNext */ + && (needCollisionCheckForIdentifier(node, node.name, "WeakMap") || needCollisionCheckForIdentifier(node, node.name, "WeakSet"))) { + potentialWeakMapSetCollisions.push(node); } } } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 163 /* PropertyDeclaration */ || nextDeclaration.kind === 162 /* PropertySignature */ + var message = nextDeclaration.kind === 165 /* PropertyDeclaration */ || nextDeclaration.kind === 164 /* 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); @@ -75094,8 +77780,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 160 /* Parameter */ && right.kind === 249 /* VariableDeclaration */) || - (left.kind === 249 /* VariableDeclaration */ && right.kind === 160 /* Parameter */)) { + if ((left.kind === 162 /* Parameter */ && right.kind === 251 /* VariableDeclaration */) || + (left.kind === 251 /* VariableDeclaration */ && right.kind === 162 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -75111,10 +77797,10 @@ var ts; return ts.getSelectedEffectiveModifierFlags(left, interestingFlags) === ts.getSelectedEffectiveModifierFlags(right, interestingFlags); } function checkVariableDeclaration(node) { - ts.tracing.push("check" /* Check */, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end }); checkGrammarVariableDeclaration(node); checkVariableLikeDeclaration(node); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } function checkBindingElement(node) { checkGrammarBindingElement(node); @@ -75135,49 +77821,55 @@ var ts; // Grammar checking checkGrammarStatementInAmbientContext(node); var type = checkTruthinessExpression(node.expression); - checkTestingKnownTruthyCallableType(node.expression, type, node.thenStatement); + checkTestingKnownTruthyCallableOrAwaitableType(node.expression, type, node.thenStatement); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 231 /* EmptyStatement */) { + if (node.thenStatement.kind === 233 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); } - function checkTestingKnownTruthyCallableType(condExpr, type, body) { - if (!strictNullChecks) { + function checkTestingKnownTruthyCallableOrAwaitableType(condExpr, type, body) { + if (!strictNullChecks) + return; + if (getFalsyFlags(type)) return; - } var location = ts.isBinaryExpression(condExpr) ? condExpr.right : condExpr; var testedNode = ts.isIdentifier(location) ? location : ts.isPropertyAccessExpression(location) ? location.name : ts.isBinaryExpression(location) && ts.isIdentifier(location.right) ? location.right : undefined; - if (!testedNode) { - return; - } - var possiblyFalsy = getFalsyFlags(type); - if (possiblyFalsy) { + var isPropertyExpressionCast = ts.isPropertyAccessExpression(location) + && ts.isAssertionExpression(ts.skipParentheses(location.expression)); + if (!testedNode || isPropertyExpressionCast) { return; } // While it technically should be invalid for any known-truthy value - // to be tested, we de-scope to functions unrefenced 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. + // 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 */); - if (callSignatures.length === 0) { + var isPromise = !!getAwaitedTypeOfPromise(type); + if (callSignatures.length === 0 && !isPromise) { return; } var testedSymbol = getSymbolAtLocation(testedNode); if (!testedSymbol) { return; } - var isUsed = ts.isBinaryExpression(condExpr.parent) && isFunctionUsedInBinaryExpressionChain(condExpr.parent, testedSymbol) - || body && isFunctionUsedInConditionBody(condExpr, body, testedNode, testedSymbol); + var isUsed = ts.isBinaryExpression(condExpr.parent) && isSymbolUsedInBinaryExpressionChain(condExpr.parent, testedSymbol) + || body && isSymbolUsedInConditionBody(condExpr, body, testedNode, testedSymbol); if (!isUsed) { - error(location, ts.Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead); + if (isPromise) { + errorAndMaybeSuggestAwait(location, + /*maybeMissingAwait*/ true, ts.Diagnostics.This_condition_will_always_return_true_since_this_0_is_always_defined, getTypeNameForErrorDisplay(type)); + } + else { + error(location, ts.Diagnostics.This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_instead); + } } } - function isFunctionUsedInConditionBody(expr, body, testedNode, testedSymbol) { + function isSymbolUsedInConditionBody(expr, body, testedNode, testedSymbol) { return !!ts.forEachChild(body, function check(childNode) { if (ts.isIdentifier(childNode)) { var childSymbol = getSymbolAtLocation(childNode); @@ -75191,7 +77883,7 @@ var ts; var childExpression = childNode.parent; while (testedExpression && childExpression) { if (ts.isIdentifier(testedExpression) && ts.isIdentifier(childExpression) || - testedExpression.kind === 107 /* ThisKeyword */ && childExpression.kind === 107 /* ThisKeyword */) { + testedExpression.kind === 108 /* ThisKeyword */ && childExpression.kind === 108 /* ThisKeyword */) { return getSymbolAtLocation(testedExpression) === getSymbolAtLocation(childExpression); } else if (ts.isPropertyAccessExpression(testedExpression) && ts.isPropertyAccessExpression(childExpression)) { @@ -75214,7 +77906,7 @@ var ts; return ts.forEachChild(childNode, check); }); } - function isFunctionUsedInBinaryExpressionChain(node, testedSymbol) { + function isSymbolUsedInBinaryExpressionChain(node, testedSymbol) { while (ts.isBinaryExpression(node) && node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { var isUsed = ts.forEachChild(node.right, function visit(child) { if (ts.isIdentifier(child)) { @@ -75256,12 +77948,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 250 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 252 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 250 /* VariableDeclarationList */) { + if (node.initializer.kind === 252 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -75295,14 +77987,14 @@ var ts; // 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 === 250 /* VariableDeclarationList */) { + if (node.initializer.kind === 252 /* 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 === 199 /* ArrayLiteralExpression */ || varExpr.kind === 200 /* ObjectLiteralExpression */) { + if (varExpr.kind === 201 /* ArrayLiteralExpression */ || varExpr.kind === 202 /* 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. @@ -75334,7 +78026,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 === 250 /* VariableDeclarationList */) { + if (node.initializer.kind === 252 /* 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); @@ -75348,7 +78040,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 === 199 /* ArrayLiteralExpression */ || varExpr.kind === 200 /* ObjectLiteralExpression */) { + if (varExpr.kind === 201 /* ArrayLiteralExpression */ || varExpr.kind === 202 /* 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)) { @@ -75464,18 +78156,8 @@ 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 yieldType = getIterationTypeOfIterable(use, 0 /* Yield */, inputType, /*errorNode*/ undefined); - var _a = !(use & 4 /* AllowsStringInputFlag */) || hasStringConstituent - ? downlevelIteration - ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true] - : yieldType - ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false] - : [ts.Diagnostics.Type_0_is_not_an_array_type, true] - : downlevelIteration - ? [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] - : yieldType - ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false] - : [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type, true], defaultDiagnostic = _a[0], maybeMissingAwait = _a[1]; + var allowsStrings = !!(use & 4 /* AllowsStringInputFlag */) && !hasStringConstituent; + var _a = getIterationDiagnosticDetails(allowsStrings, downlevelIteration), defaultDiagnostic = _a[0], maybeMissingAwait = _a[1]; errorAndMaybeSuggestAwait(errorNode, maybeMissingAwait && !!getAwaitedTypeOfPromise(arrayType), defaultDiagnostic, typeToString(arrayType)); } return hasStringConstituent ? possibleOutOfBounds ? includeUndefinedInIndexSignature(stringType) : stringType : undefined; @@ -75489,6 +78171,40 @@ var ts; return getUnionType(possibleOutOfBounds ? [arrayElementType, stringType, undefinedType] : [arrayElementType, stringType], 2 /* Subtype */); } return (use & 128 /* PossiblyOutOfBounds */) ? includeUndefinedInIndexSignature(arrayElementType) : arrayElementType; + function getIterationDiagnosticDetails(allowsStrings, downlevelIteration) { + var _a; + if (downlevelIteration) { + return allowsStrings + ? [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); + if (yieldType) { + return [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false]; + } + if (isES2015OrLaterIterable((_a = inputType.symbol) === null || _a === void 0 ? void 0 : _a.escapedName)) { + return [ts.Diagnostics.Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher, true]; + } + return allowsStrings + ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type, true] + : [ts.Diagnostics.Type_0_is_not_an_array_type, true]; + } + } + function isES2015OrLaterIterable(n) { + switch (n) { + case "Float32Array": + case "Float64Array": + case "Int16Array": + case "Int32Array": + case "Int8Array": + case "NodeList": + case "Uint16Array": + case "Uint32Array": + case "Uint8Array": + case "Uint8ClampedArray": + return true; + } + return false; } /** * Gets the requested "iteration type" from an `Iterable`-like or `AsyncIterable`-like type. @@ -75732,6 +78448,11 @@ var ts; return setCachedIterationTypes(type, resolver.iterableCacheKey, createIterationTypes(yieldType, returnType, nextType)); } } + function getPropertyNameForKnownSymbolName(symbolName) { + var ctorType = getGlobalESSymbolConstructorSymbol(/*reportErrors*/ false); + var uniqueType = ctorType && getTypeOfPropertyOfType(getTypeOfSymbol(ctorType), ts.escapeLeadingUnderscores(symbolName)); + return uniqueType && isTypeUsableAsPropertyName(uniqueType) ? getPropertyNameFromType(uniqueType) : "__@" + symbolName; + } /** * Gets the *yield*, *return*, and *next* types of an `Iterable`-like or `AsyncIterable`-like * type from its members. @@ -75744,7 +78465,7 @@ var ts; */ function getIterationTypesOfIterableSlow(type, resolver, errorNode) { var _a; - var method = getPropertyOfType(type, ts.getPropertyNameForKnownSymbolName(resolver.iteratorSymbolName)); + var method = getPropertyOfType(type, getPropertyNameForKnownSymbolName(resolver.iteratorSymbolName)); var methodType = method && !(method.flags & 16777216 /* Optional */) ? getTypeOfSymbol(method) : undefined; if (isTypeAny(methodType)) { return setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes); @@ -76043,12 +78764,12 @@ var ts; var functionFlags = ts.getFunctionFlags(func); if (strictNullChecks || node.expression || returnType.flags & 131072 /* Never */) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; - if (func.kind === 168 /* SetAccessor */) { + if (func.kind === 170 /* SetAccessor */) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 166 /* Constructor */) { + else if (func.kind === 168 /* 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); } @@ -76066,7 +78787,7 @@ var ts; } } } - else if (func.kind !== 166 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 168 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, 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); } @@ -76095,7 +78816,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 === 285 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 287 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -76104,7 +78825,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 284 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 286 /* CaseClause */) { // TypeScript 1.0 spec (April 2014): 5.9 // In a 'switch' statement, each 'case' expression must be of a type that is comparable // to or from the type of the 'switch' expression. @@ -76136,7 +78857,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 245 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 247 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -76166,10 +78887,11 @@ var ts; // Grammar checking if (catchClause.variableDeclaration) { var declaration = catchClause.variableDeclaration; - if (declaration.type) { + var typeNode = ts.getEffectiveTypeAnnotationNode(ts.getRootDeclaration(declaration)); + if (typeNode) { var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false); if (type && !(type.flags & 3 /* AnyOrUnknown */)) { - grammarErrorOnFirstToken(declaration.type, ts.Diagnostics.Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified); + grammarErrorOnFirstToken(typeNode, ts.Diagnostics.Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified); } } else if (declaration.initializer) { @@ -76180,7 +78902,7 @@ var ts; if (blockLocals_1) { ts.forEachKey(catchClause.locals, function (caughtName) { var blockLocal = blockLocals_1.get(caughtName); - if (blockLocal && (blockLocal.flags & 2 /* BlockScopedVariable */) !== 0) { + if ((blockLocal === null || blockLocal === void 0 ? void 0 : blockLocal.valueDeclaration) && (blockLocal.flags & 2 /* BlockScopedVariable */) !== 0) { grammarErrorOnNode(blockLocal.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, caughtName); } }); @@ -76193,27 +78915,30 @@ var ts; checkBlock(node.finallyBlock); } } - function checkIndexConstraints(type) { - var declaredNumberIndexer = getIndexDeclarationOfSymbol(type.symbol, 1 /* Number */); - var declaredStringIndexer = getIndexDeclarationOfSymbol(type.symbol, 0 /* String */); + function checkIndexConstraints(type, isStatic) { + var _a, _b, _c, _d; + var declaredNumberIndexer = getIndexDeclarationOfSymbolTable(isStatic ? (_a = type.symbol) === null || _a === void 0 ? void 0 : _a.exports : (_b = type.symbol) === null || _b === void 0 ? void 0 : _b.members, 1 /* Number */); + var declaredStringIndexer = getIndexDeclarationOfSymbolTable(isStatic ? (_c = type.symbol) === null || _c === void 0 ? void 0 : _c.exports : (_d = type.symbol) === null || _d === void 0 ? void 0 : _d.members, 0 /* String */); var stringIndexType = getIndexTypeOfType(type, 0 /* String */); var numberIndexType = getIndexTypeOfType(type, 1 /* Number */); if (stringIndexType || numberIndexType) { ts.forEach(getPropertiesOfObjectType(type), function (prop) { - var propType = getTypeOfSymbol(prop); + if (isStatic && prop.flags & 4194304 /* Prototype */) + return; + var propType = getNonMissingTypeOfSymbol(prop); checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */); checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */); }); var classDeclaration = type.symbol.valueDeclaration; - if (ts.getObjectFlags(type) & 1 /* Class */ && ts.isClassLike(classDeclaration)) { - for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) { - var member = _a[_i]; + if (ts.getObjectFlags(type) & 1 /* Class */ && classDeclaration && ts.isClassLike(classDeclaration)) { + for (var _i = 0, _e = classDeclaration.members; _i < _e.length; _i++) { + var member = _e[_i]; // Only process instance properties with computed names here. // Static properties cannot be in conflict with indexers, // and properties with literal names were already checked. - if (!ts.hasSyntacticModifier(member, 32 /* Static */) && hasNonBindableDynamicName(member)) { + if (!ts.hasSyntacticModifier(member, 32 /* Static */) && !hasBindableName(member)) { var symbol = getSymbolOfNode(member); - var propType = getTypeOfSymbol(symbol); + var propType = getNonMissingTypeOfSymbol(symbol); checkIndexConstraintForProperty(symbol, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */); checkIndexConstraintForProperty(symbol, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */); } @@ -76226,7 +78951,7 @@ var ts; // condition 'errorNode === undefined' may appear if types does not declare nor string neither number indexer if (!errorNode && (ts.getObjectFlags(type) & 2 /* Interface */)) { var someBaseTypeHasBothIndexers = ts.forEach(getBaseTypes(type), function (base) { return getIndexTypeOfType(base, 0 /* String */) && getIndexTypeOfType(base, 1 /* Number */); }); - errorNode = someBaseTypeHasBothIndexers ? undefined : type.symbol.declarations[0]; + errorNode = someBaseTypeHasBothIndexers || !type.symbol.declarations ? undefined : type.symbol.declarations[0]; } } if (errorNode && !isTypeAssignableTo(numberIndexType, stringIndexType)) { // TODO: GH#18217 @@ -76250,8 +78975,8 @@ var ts; // this allows us to rule out cases when both property and indexer are inherited from the base class var errorNode; if (propDeclaration && name && - (propDeclaration.kind === 216 /* BinaryExpression */ || - name.kind === 158 /* ComputedPropertyName */ || + (propDeclaration.kind === 218 /* BinaryExpression */ || + name.kind === 160 /* ComputedPropertyName */ || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -76263,7 +78988,7 @@ var ts; // check if any base class already has both property and indexer. // check should be performed only if 'type' is the first type that brings property\indexer together var someBaseClassHasBothPropertyAndIndexer = ts.forEach(getBaseTypes(containingType), function (base) { return getPropertyOfObjectType(base, prop.escapedName) && getIndexTypeOfType(base, indexKind); }); - errorNode = someBaseClassHasBothPropertyAndIndexer ? undefined : containingType.symbol.declarations[0]; + errorNode = someBaseClassHasBothPropertyAndIndexer || !containingType.symbol.declarations ? undefined : containingType.symbol.declarations[0]; } if (errorNode && !isTypeAssignableTo(propertyType, indexType)) { var errorMessage = indexKind === 0 /* String */ @@ -76279,6 +79004,7 @@ var ts; switch (name.escapedText) { case "any": case "unknown": + case "never": case "number": case "bigint": case "boolean": @@ -76328,7 +79054,7 @@ var ts; function checkTypeParametersNotReferenced(root, typeParameters, index) { visit(root); function visit(node) { - if (node.kind === 173 /* TypeReference */) { + if (node.kind === 175 /* TypeReference */) { var type = getTypeFromTypeReference(node); if (type.flags & 262144 /* TypeParameter */) { for (var i = index; i < typeParameters.length; i++) { @@ -76343,14 +79069,14 @@ var ts; } /** Check that type parameter lists are identical across multiple declarations */ function checkTypeParameterListsIdentical(symbol) { - if (symbol.declarations.length === 1) { + if (symbol.declarations && symbol.declarations.length === 1) { return; } var links = getSymbolLinks(symbol); if (!links.typeParametersChecked) { links.typeParametersChecked = true; var declarations = getClassOrInterfaceDeclarationsOfSymbol(symbol); - if (declarations.length <= 1) { + if (!declarations || declarations.length <= 1) { return; } var type = getDeclaredTypeOfSymbol(symbol); @@ -76414,6 +79140,9 @@ var ts; registerForUnusedIdentifiersCheck(node); } function checkClassDeclaration(node) { + if (ts.some(node.decorators) && ts.some(node.members, function (p) { return ts.hasStaticModifier(p) && ts.isPrivateIdentifierClassElementDeclaration(p); })) { + grammarErrorOnNode(node.decorators[0], 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 */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } @@ -76442,7 +79171,8 @@ var ts; checkFunctionOrConstructorSymbol(symbol); checkClassForDuplicateDeclarations(node); // Only check for reserved static identifiers on non-ambient context. - if (!(node.flags & 8388608 /* Ambient */)) { + var nodeInAmbientContext = !!(node.flags & 8388608 /* Ambient */); + if (!nodeInAmbientContext) { checkClassForStaticPropertyNameConflicts(node); } var baseTypeNode = ts.getEffectiveBaseTypeNode(node); @@ -76502,6 +79232,7 @@ var ts; checkKindsOfPropertyMemberOverrides(type, baseType_1); } } + checkMembersForMissingOverrideModifier(node, type, typeWithThis, staticType); var implementedTypeNodes = ts.getEffectiveImplementsTypeNodes(node); if (implementedTypeNodes) { for (var _b = 0, implementedTypeNodes_1 = implementedTypeNodes; _b < implementedTypeNodes_1.length; _b++) { @@ -76531,14 +79262,79 @@ var ts; } if (produceDiagnostics) { checkIndexConstraints(type); + checkIndexConstraints(staticType, /*isStatic*/ true); checkTypeForDuplicateIndexSignatures(node); checkPropertyInitialization(node); } } + function checkMembersForMissingOverrideModifier(node, type, typeWithThis, staticType) { + var nodeInAmbientContext = !!(node.flags & 8388608 /* Ambient */); + var baseTypeNode = ts.getEffectiveBaseTypeNode(node); + 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_24 = function (member) { + if (ts.hasAmbientModifier(member)) { + return "continue"; + } + if (ts.isConstructorDeclaration(member)) { + ts.forEach(member.parameters, function (param) { + if (ts.isParameterPropertyDeclaration(param, member)) { + checkClassMember(param, /*memberIsParameterProperty*/ true); + } + }); + } + checkClassMember(member); + }; + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + _loop_24(member); + } + function checkClassMember(member, memberIsParameterProperty) { + var hasOverride = ts.hasOverrideModifier(member); + var hasStatic = ts.hasStaticModifier(member); + if (baseWithThis && (hasOverride || compilerOptions.noImplicitOverride)) { + var declaredProp = member.name && getSymbolAtLocation(member.name) || getSymbolAtLocation(member); + if (!declaredProp) { + return; + } + var thisType = hasStatic ? staticType : typeWithThis; + var baseType = hasStatic ? baseStaticType : baseWithThis; + var prop = getPropertyOfType(thisType, declaredProp.escapedName); + var baseProp = getPropertyOfType(baseType, declaredProp.escapedName); + var baseClassName = typeToString(baseWithThis); + if (prop && !baseProp && hasOverride) { + var suggestion = getSpellingSuggestionForName(ts.symbolName(declaredProp), ts.arrayFrom(getMembersOfSymbol(baseType.symbol).values()), 106500 /* ClassMember */); + suggestion ? + error(member, ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1, baseClassName, symbolToString(suggestion)) : + error(member, ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0, baseClassName); + } + else if (prop && (baseProp === null || baseProp === void 0 ? void 0 : baseProp.valueDeclaration) && compilerOptions.noImplicitOverride && !nodeInAmbientContext) { + var baseHasAbstract = ts.hasAbstractModifier(baseProp.valueDeclaration); + if (hasOverride) { + return; + } + if (!baseHasAbstract) { + var diag = memberIsParameterProperty ? + ts.Diagnostics.This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0 : + ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0; + error(member, diag, baseClassName); + } + else if (ts.hasAbstractModifier(member) && baseHasAbstract) { + error(member, ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0, baseClassName); + } + } + } + else if (hasOverride) { + var className = typeToString(type); + error(member, ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class, className); + } + } + } 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_23 = function (member) { + var _loop_25 = function (member) { if (ts.hasStaticModifier(member)) { return "continue"; } @@ -76557,7 +79353,7 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_23(member); + _loop_25(member); } if (!issuedMemberError) { // check again with diagnostics to generate a less-specific error @@ -76583,7 +79379,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 252 /* ClassDeclaration */ || d.kind === 253 /* InterfaceDeclaration */; + return d.kind === 254 /* ClassDeclaration */ || d.kind === 255 /* InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -76600,6 +79396,7 @@ var ts; // but not by other kinds of members. // Base class instance member variables and accessors can be overridden by // derived class instance member variables and accessors, but not by other kinds of members. + var _a, _b; // NOTE: assignability is checked in checkClassDeclaration var baseProperties = getPropertiesOfType(baseType); basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { @@ -76628,8 +79425,8 @@ var ts; // 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.) - for (var _a = 0, _b = getBaseTypes(type); _a < _b.length; _a++) { - var otherBaseType = _b[_a]; + for (var _c = 0, _d = getBaseTypes(type); _c < _d.length; _c++) { + var otherBaseType = _d[_c]; if (otherBaseType === baseType) continue; var baseSymbol_1 = getPropertyOfObjectType(otherBaseType, base.escapedName); @@ -76638,7 +79435,7 @@ var ts; continue basePropertyCheck; } } - if (derivedClassDecl.kind === 221 /* ClassExpression */) { + if (derivedClassDecl.kind === 223 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -76659,7 +79456,7 @@ var ts; if (basePropertyFlags && derivedPropertyFlags) { // property/accessor is overridden with property/accessor if (baseDeclarationFlags & 128 /* Abstract */ && !(base.valueDeclaration && ts.isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer) - || base.valueDeclaration && base.valueDeclaration.parent.kind === 253 /* InterfaceDeclaration */ + || base.valueDeclaration && base.valueDeclaration.parent.kind === 255 /* InterfaceDeclaration */ || derived.valueDeclaration && ts.isBinaryExpression(derived.valueDeclaration)) { // when the base property is abstract or from an interface, base/derived flags don't need to match // same when the derived property is from an assignment @@ -76673,13 +79470,13 @@ var ts; ts.Diagnostics._0_is_defined_as_a_property_in_class_1_but_is_overridden_here_in_2_as_an_accessor; error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_1, symbolToString(base), typeToString(baseType), typeToString(type)); } - else if (compilerOptions.useDefineForClassFields) { - var uninitialized = ts.find(derived.declarations, function (d) { return d.kind === 163 /* PropertyDeclaration */ && !d.initializer; }); + else if (useDefineForClassFields) { + var uninitialized = (_a = derived.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 165 /* PropertyDeclaration */ && !d.initializer; }); if (uninitialized && !(derived.flags & 33554432 /* Transient */) && !(baseDeclarationFlags & 128 /* Abstract */) && !(derivedDeclarationFlags & 128 /* Abstract */) - && !derived.declarations.some(function (d) { return !!(d.flags & 8388608 /* Ambient */); })) { + && !((_b = derived.declarations) === null || _b === void 0 ? void 0 : _b.some(function (d) { return !!(d.flags & 8388608 /* Ambient */); }))) { var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol)); var propName = uninitialized.name; if (uninitialized.exclamationToken @@ -76790,7 +79587,7 @@ var ts; } } function isInstancePropertyWithoutInitializer(node) { - return node.kind === 163 /* PropertyDeclaration */ && + return node.kind === 165 /* PropertyDeclaration */ && !ts.hasSyntacticModifier(node, 32 /* Static */ | 128 /* Abstract */) && !node.exclamationToken && !node.initializer; @@ -76814,7 +79611,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 253 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 255 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -76847,7 +79644,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0); checkExportsOnMergedDeclarations(node); checkTypeParameters(node.typeParameters); - if (node.type.kind === 136 /* IntrinsicKeyword */) { + if (node.type.kind === 137 /* 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); } @@ -76933,7 +79730,7 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { @@ -76943,7 +79740,7 @@ var ts; } } break; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { @@ -76972,22 +79769,22 @@ var ts; case 8 /* NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return evaluate(expr.expression); - case 78 /* Identifier */: + case 79 /* Identifier */: var identifier = expr; if (isInfinityOrNaNString(identifier.escapedText)) { return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 202 /* ElementAccessExpression */: - case 201 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: var ex = expr; if (isConstantMemberAccess(ex)) { var type = getTypeOfExpression(ex.expression); if (type.symbol && type.symbol.flags & 384 /* Enum */) { var name = void 0; - if (ex.kind === 201 /* PropertyAccessExpression */) { + if (ex.kind === 203 /* PropertyAccessExpression */) { name = ex.name.escapedText; } else { @@ -77005,7 +79802,7 @@ var ts; if (memberSymbol) { var declaration = memberSymbol.valueDeclaration; if (declaration !== member) { - if (isBlockScopedNameDeclaredBeforeUse(declaration, member)) { + if (declaration && isBlockScopedNameDeclaredBeforeUse(declaration, member)) { return getEnumMemberValue(declaration); } error(expr, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums); @@ -77019,9 +79816,9 @@ var ts; } } function isConstantMemberAccess(node) { - return node.kind === 78 /* Identifier */ || - node.kind === 201 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 202 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + return node.kind === 79 /* Identifier */ || + node.kind === 203 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 204 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && ts.isStringLiteralLike(node.argumentExpression); } function checkEnumDeclaration(node) { @@ -77045,7 +79842,7 @@ var ts; var enumSymbol = getSymbolOfNode(node); var firstDeclaration = ts.getDeclarationOfKind(enumSymbol, node.kind); if (node === firstDeclaration) { - if (enumSymbol.declarations.length > 1) { + if (enumSymbol.declarations && enumSymbol.declarations.length > 1) { var enumIsConst_1 = ts.isEnumConst(node); // check that const is placed\omitted on all enum declarations ts.forEach(enumSymbol.declarations, function (decl) { @@ -77057,7 +79854,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 !== 255 /* EnumDeclaration */) { + if (declaration.kind !== 257 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -77083,12 +79880,14 @@ var ts; } function getFirstNonAmbientClassOrFunctionDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { - var declaration = declarations_8[_i]; - if ((declaration.kind === 252 /* ClassDeclaration */ || - (declaration.kind === 251 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && - !(declaration.flags & 8388608 /* Ambient */)) { - return declaration; + if (declarations) { + for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { + var declaration = declarations_8[_i]; + if ((declaration.kind === 254 /* ClassDeclaration */ || + (declaration.kind === 253 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + !(declaration.flags & 8388608 /* Ambient */)) { + return declaration; + } } } return undefined; @@ -77136,8 +79935,9 @@ var ts; // The following checks only apply on a non-ambient instantiated module declaration. if (symbol.flags & 512 /* ValueModule */ && !inAmbientContext + && symbol.declarations && symbol.declarations.length > 1 - && isInstantiatedModule(node, !!compilerOptions.preserveConstEnums || !!compilerOptions.isolatedModules)) { + && isInstantiatedModule(node, ts.shouldPreserveConstEnums(compilerOptions))) { var firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol); if (firstNonAmbientClassOrFunc) { if (ts.getSourceFileOfNode(node) !== ts.getSourceFileOfNode(firstNonAmbientClassOrFunc)) { @@ -77149,7 +79949,7 @@ 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, 252 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 254 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -77198,40 +79998,41 @@ var ts; } } function checkModuleAugmentationElement(node, isGlobalAugmentation) { + var _a; switch (node.kind) { - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: // error each individual name in variable statement instead of marking the entire variable statement - for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; + for (var _i = 0, _b = node.declarationList.declarations; _i < _b.length; _i++) { + var decl = _b[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 266 /* ExportAssignment */: - case 267 /* ExportDeclaration */: + case 268 /* ExportAssignment */: + case 269 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 260 /* ImportEqualsDeclaration */: - case 261 /* ImportDeclaration */: + case 262 /* ImportEqualsDeclaration */: + case 263 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 198 /* BindingElement */: - case 249 /* VariableDeclaration */: + case 200 /* BindingElement */: + case 251 /* VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { - for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { - var el = _c[_b]; + for (var _c = 0, _d = name.elements; _c < _d.length; _c++) { + var el = _d[_c]; // mark individual names in binding pattern checkModuleAugmentationElement(el, isGlobalAugmentation); } break; } // falls through - case 252 /* ClassDeclaration */: - case 255 /* EnumDeclaration */: - case 251 /* FunctionDeclaration */: - case 253 /* InterfaceDeclaration */: - case 256 /* ModuleDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 254 /* ClassDeclaration */: + case 257 /* EnumDeclaration */: + case 253 /* FunctionDeclaration */: + case 255 /* InterfaceDeclaration */: + case 258 /* ModuleDeclaration */: + case 256 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -77244,7 +80045,7 @@ var ts; var reportError = !(symbol.flags & 33554432 /* Transient */); if (!reportError) { // symbol should not originate in augmentation - reportError = !!symbol.parent && ts.isExternalModuleAugmentation(symbol.parent.declarations[0]); + reportError = !!((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.declarations) && ts.isExternalModuleAugmentation(symbol.parent.declarations[0]); } } break; @@ -77252,20 +80053,20 @@ var ts; } function getFirstNonModuleExportsIdentifier(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return node; - case 157 /* QualifiedName */: + case 159 /* QualifiedName */: do { node = node.left; - } while (node.kind !== 78 /* Identifier */); + } while (node.kind !== 79 /* Identifier */); return node; - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: do { if (ts.isModuleExportsAccessExpression(node.expression) && !ts.isPrivateIdentifier(node.name)) { return node.name; } node = node.expression; - } while (node.kind !== 78 /* Identifier */); + } while (node.kind !== 79 /* Identifier */); return node; } } @@ -77279,9 +80080,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 257 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 297 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 267 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 259 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 299 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 269 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -77301,6 +80102,7 @@ var ts; return true; } function checkAliasSymbol(node) { + var _a; var symbol = getSymbolOfNode(node); var target = resolveAlias(symbol); if (target !== unknownSymbol) { @@ -77315,21 +80117,21 @@ var ts; (symbol.flags & 788968 /* Type */ ? 788968 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 270 /* ExportSpecifier */ ? + var message = node.kind === 272 /* 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)); } // Don't allow to re-export something with no value side when `--isolatedModules` is set. if (compilerOptions.isolatedModules - && node.kind === 270 /* ExportSpecifier */ + && node.kind === 272 /* ExportSpecifier */ && !node.parent.parent.isTypeOnly && !(target.flags & 111551 /* Value */) && !(node.flags & 8388608 /* Ambient */)) { error(node, ts.Diagnostics.Re_exporting_a_type_when_the_isolatedModules_flag_is_provided_requires_using_export_type); } - if (ts.isImportSpecifier(node) && ts.every(target.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 134217728 /* Deprecated */); })) { - errorOrSuggestion(/* isError */ false, node.name, ts.Diagnostics._0_is_deprecated, symbol.escapedName); + if (ts.isImportSpecifier(node) && ((_a = target.declarations) === null || _a === void 0 ? void 0 : _a.every(function (d) { return !!(ts.getCombinedNodeFlags(d) & 134217728 /* Deprecated */); }))) { + addDeprecatedSuggestion(node.name, target.declarations, symbol.escapedName); } } } @@ -77337,7 +80139,7 @@ var ts; checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); checkAliasSymbol(node); - if (node.kind === 265 /* ImportSpecifier */ && + if (node.kind === 267 /* ImportSpecifier */ && ts.idText(node.propertyName || node.name) === "default" && compilerOptions.esModuleInterop && moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015) { @@ -77359,7 +80161,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 263 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 265 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); if (moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015 && compilerOptions.esModuleInterop) { // import * as ns from "foo"; @@ -77387,7 +80189,7 @@ var ts; if (ts.hasSyntacticModifier(node, 1 /* Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 272 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 274 /* ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { if (target.flags & 111551 /* Value */) { @@ -77430,10 +80232,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 257 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 257 /* ModuleBlock */ && + var inAmbientExternalModule = node.parent.kind === 259 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 259 /* ModuleBlock */ && !node.moduleSpecifier && node.flags & 8388608 /* Ambient */; - if (node.parent.kind !== 297 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 299 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -77466,14 +80268,14 @@ var ts; } function checkGrammarExportDeclaration(node) { var _a; - var isTypeOnlyExportStar = node.isTypeOnly && ((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) !== 268 /* NamedExports */; + var isTypeOnlyExportStar = node.isTypeOnly && ((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) !== 270 /* NamedExports */; if (isTypeOnlyExportStar) { grammarErrorOnNode(node, ts.Diagnostics.Only_named_exports_may_use_export_type); } return !isTypeOnlyExportStar; } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 297 /* SourceFile */ || node.parent.kind === 257 /* ModuleBlock */ || node.parent.kind === 256 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 299 /* SourceFile */ || node.parent.kind === 259 /* ModuleBlock */ || node.parent.kind === 258 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -77523,7 +80325,7 @@ var ts; // 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 */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); - if (symbol && (symbol === undefinedSymbol || symbol === globalThisSymbol || isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { + 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 { @@ -77544,12 +80346,15 @@ var ts; } } function checkExportAssignment(node) { - if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { + var illegalContextMessage = node.isExportEquals + ? ts.Diagnostics.An_export_assignment_must_be_at_the_top_level_of_a_file_or_module_declaration + : ts.Diagnostics.A_default_export_must_be_at_the_top_level_of_a_file_or_module_declaration; + if (checkGrammarModuleElementContext(node, illegalContextMessage)) { // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 297 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 256 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 299 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 258 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -77562,7 +80367,7 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasEffectiveModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 78 /* Identifier */) { + if (node.expression.kind === 79 /* Identifier */) { var id = node.expression; var sym = resolveEntityName(id, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node); if (sym) { @@ -77609,7 +80414,7 @@ var ts; var exportEqualsSymbol = moduleSymbol.exports.get("export="); if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) { var declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration; - if (!isTopLevelInExternalModuleAugmentation(declaration) && !ts.isInJSFile(declaration)) { + if (declaration && !isTopLevelInExternalModuleAugmentation(declaration) && !ts.isInJSFile(declaration)) { error(declaration, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); } } @@ -77633,10 +80438,12 @@ var ts; return; } if (exportedDeclarationsCount > 1) { - for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { - var declaration = declarations_9[_i]; - if (isNotOverload(declaration)) { - diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Cannot_redeclare_exported_variable_0, ts.unescapeLeadingUnderscores(id))); + if (!isDuplicatedCommonJSExport(declarations)) { + for (var _i = 0, _b = declarations; _i < _b.length; _i++) { + var declaration = _b[_i]; + if (isNotOverload(declaration)) { + diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Cannot_redeclare_exported_variable_0, ts.unescapeLeadingUnderscores(id))); + } } } } @@ -77645,6 +80452,11 @@ var ts; links.exportsChecked = true; } } + function isDuplicatedCommonJSExport(declarations) { + return declarations + && declarations.length > 1 + && declarations.every(function (d) { return ts.isInJSFile(d) && ts.isAccessExpression(d) && (ts.isExportsIdentifier(d.expression) || ts.isModuleExportsAccessExpression(d.expression)); }); + } function checkSourceElement(node) { if (node) { var saveCurrentNode = currentNode; @@ -77666,171 +80478,171 @@ 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 256 /* ModuleDeclaration */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 251 /* FunctionDeclaration */: + case 258 /* ModuleDeclaration */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 253 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } - if (kind >= 232 /* FirstStatement */ && kind <= 248 /* LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { + if (kind >= 234 /* FirstStatement */ && kind <= 250 /* LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { errorOrSuggestion(compilerOptions.allowUnreachableCode === false, node, ts.Diagnostics.Unreachable_code_detected); } switch (kind) { - case 159 /* TypeParameter */: + case 161 /* TypeParameter */: return checkTypeParameter(node); - case 160 /* Parameter */: + case 162 /* Parameter */: return checkParameter(node); - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return checkPropertyDeclaration(node); - case 162 /* PropertySignature */: + case 164 /* PropertySignature */: return checkPropertySignature(node); - case 175 /* ConstructorType */: - case 174 /* FunctionType */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: + case 177 /* ConstructorType */: + case 176 /* FunctionType */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 173 /* IndexSignature */: return checkSignatureDeclaration(node); - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: return checkMethodDeclaration(node); - case 166 /* Constructor */: + case 168 /* Constructor */: return checkConstructorDeclaration(node); - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return checkAccessorDeclaration(node); - case 173 /* TypeReference */: + case 175 /* TypeReference */: return checkTypeReferenceNode(node); - case 172 /* TypePredicate */: + case 174 /* TypePredicate */: return checkTypePredicate(node); - case 176 /* TypeQuery */: + case 178 /* TypeQuery */: return checkTypeQuery(node); - case 177 /* TypeLiteral */: + case 179 /* TypeLiteral */: return checkTypeLiteral(node); - case 178 /* ArrayType */: + case 180 /* ArrayType */: return checkArrayType(node); - case 179 /* TupleType */: + case 181 /* TupleType */: return checkTupleType(node); - case 182 /* UnionType */: - case 183 /* IntersectionType */: + case 184 /* UnionType */: + case 185 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 186 /* ParenthesizedType */: - case 180 /* OptionalType */: - case 181 /* RestType */: + case 188 /* ParenthesizedType */: + case 182 /* OptionalType */: + case 183 /* RestType */: return checkSourceElement(node.type); - case 187 /* ThisType */: + case 189 /* ThisType */: return checkThisType(node); - case 188 /* TypeOperator */: + case 190 /* TypeOperator */: return checkTypeOperator(node); - case 184 /* ConditionalType */: + case 186 /* ConditionalType */: return checkConditionalType(node); - case 185 /* InferType */: + case 187 /* InferType */: return checkInferType(node); - case 193 /* TemplateLiteralType */: + case 195 /* TemplateLiteralType */: return checkTemplateLiteralType(node); - case 195 /* ImportType */: + case 197 /* ImportType */: return checkImportType(node); - case 192 /* NamedTupleMember */: + case 194 /* NamedTupleMember */: return checkNamedTupleMember(node); - case 315 /* JSDocAugmentsTag */: + case 322 /* JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 316 /* JSDocImplementsTag */: + case 323 /* JSDocImplementsTag */: return checkJSDocImplementsTag(node); - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 325 /* JSDocEnumTag */: + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + case 333 /* JSDocEnumTag */: return checkJSDocTypeAliasTag(node); - case 330 /* JSDocTemplateTag */: + case 338 /* JSDocTemplateTag */: return checkJSDocTemplateTag(node); - case 329 /* JSDocTypeTag */: + case 337 /* JSDocTypeTag */: return checkJSDocTypeTag(node); - case 326 /* JSDocParameterTag */: + case 334 /* JSDocParameterTag */: return checkJSDocParameterTag(node); - case 333 /* JSDocPropertyTag */: + case 341 /* JSDocPropertyTag */: return checkJSDocPropertyTag(node); - case 308 /* JSDocFunctionType */: + case 311 /* JSDocFunctionType */: checkJSDocFunctionType(node); // falls through - case 306 /* JSDocNonNullableType */: - case 305 /* JSDocNullableType */: - case 303 /* JSDocAllType */: - case 304 /* JSDocUnknownType */: - case 312 /* JSDocTypeLiteral */: + case 309 /* JSDocNonNullableType */: + case 308 /* JSDocNullableType */: + case 306 /* JSDocAllType */: + case 307 /* JSDocUnknownType */: + case 316 /* JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 309 /* JSDocVariadicType */: + case 312 /* JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 301 /* JSDocTypeExpression */: + case 303 /* JSDocTypeExpression */: return checkSourceElement(node.type); - case 189 /* IndexedAccessType */: + case 191 /* IndexedAccessType */: return checkIndexedAccessType(node); - case 190 /* MappedType */: + case 192 /* MappedType */: return checkMappedType(node); - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 230 /* Block */: - case 257 /* ModuleBlock */: + case 232 /* Block */: + case 259 /* ModuleBlock */: return checkBlock(node); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return checkVariableStatement(node); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: return checkExpressionStatement(node); - case 234 /* IfStatement */: + case 236 /* IfStatement */: return checkIfStatement(node); - case 235 /* DoStatement */: + case 237 /* DoStatement */: return checkDoStatement(node); - case 236 /* WhileStatement */: + case 238 /* WhileStatement */: return checkWhileStatement(node); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return checkForStatement(node); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return checkForInStatement(node); - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: return checkForOfStatement(node); - case 240 /* ContinueStatement */: - case 241 /* BreakStatement */: + case 242 /* ContinueStatement */: + case 243 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: return checkReturnStatement(node); - case 243 /* WithStatement */: + case 245 /* WithStatement */: return checkWithStatement(node); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: return checkSwitchStatement(node); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return checkLabeledStatement(node); - case 246 /* ThrowStatement */: + case 248 /* ThrowStatement */: return checkThrowStatement(node); - case 247 /* TryStatement */: + case 249 /* TryStatement */: return checkTryStatement(node); - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 198 /* BindingElement */: + case 200 /* BindingElement */: return checkBindingElement(node); - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: return checkClassDeclaration(node); - case 253 /* InterfaceDeclaration */: + case 255 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return checkImportDeclaration(node); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: return checkExportDeclaration(node); - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return checkExportAssignment(node); - case 231 /* EmptyStatement */: - case 248 /* DebuggerStatement */: + case 233 /* EmptyStatement */: + case 250 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 271 /* MissingDeclaration */: + case 273 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -77875,7 +80687,8 @@ var ts; if (ts.isJSDocTypeExpression(node.parent) && ts.isJSDocParameterTag(paramTag)) { // Else we will add a diagnostic, see `checkJSDocVariadicType`. var host_1 = ts.getHostSignatureFromJSDoc(paramTag); - if (host_1) { + var isCallbackTag = ts.isJSDocCallbackTag(paramTag.parent.parent); + if (host_1 || isCallbackTag) { /* Only return an array type if the corresponding parameter is marked as a rest parameter, or if there are no parameters. So in the following situation we will not create an array type: @@ -77883,7 +80696,9 @@ var ts; function f(a) {} Because `a` will just be of type `number | undefined`. A synthetic `...args` will also be added, which *will* get an array type. */ - var lastParamDeclaration = ts.lastOrUndefined(host_1.parameters); + var lastParamDeclaration = isCallbackTag + ? ts.lastOrUndefined(paramTag.parent.parent.typeExpression.parameters) + : ts.lastOrUndefined(host_1.parameters); var symbol = ts.getParameterSymbolFromJSDoc(paramTag); if (!lastParamDeclaration || symbol && lastParamDeclaration.symbol === symbol && ts.isRestParameter(lastParamDeclaration)) { @@ -77921,51 +80736,51 @@ var ts; } } function checkDeferredNode(node) { - ts.tracing.push("check" /* Check */, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end }); var saveCurrentNode = currentNode; currentNode = node; instantiationCount = 0; switch (node.kind) { - case 203 /* CallExpression */: - case 204 /* NewExpression */: - case 205 /* TaggedTemplateExpression */: - case 161 /* Decorator */: - case 275 /* JsxOpeningElement */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: + case 207 /* TaggedTemplateExpression */: + case 163 /* Decorator */: + case 277 /* 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 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: checkAccessorDeclaration(node); break; - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: checkClassExpressionDeferred(node); break; - case 274 /* JsxSelfClosingElement */: + case 276 /* JsxSelfClosingElement */: checkJsxSelfClosingElementDeferred(node); break; - case 273 /* JsxElement */: + case 275 /* JsxElement */: checkJsxElementDeferred(node); break; } currentNode = saveCurrentNode; - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } function checkSourceFile(node) { - ts.tracing.push("check" /* Check */, "checkSourceFile", { path: node.path }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkSourceFile", { path: node.path }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeCheck"); checkSourceFileWorker(node); ts.performance.mark("afterCheck"); ts.performance.measure("Check", "beforeCheck", "afterCheck"); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } function unusedIsError(kind, isAmbient) { if (isAmbient) { @@ -77994,7 +80809,7 @@ var ts; checkGrammarSourceFile(node); ts.clear(potentialThisCollisions); ts.clear(potentialNewTargetCollisions); - ts.clear(potentialWeakMapCollisions); + ts.clear(potentialWeakMapSetCollisions); ts.forEach(node.statements, checkSourceElement); checkSourceElement(node.endOfFileToken); checkDeferredNodes(node); @@ -78024,9 +80839,9 @@ var ts; ts.forEach(potentialNewTargetCollisions, checkIfNewTargetIsCapturedInEnclosingScope); ts.clear(potentialNewTargetCollisions); } - if (potentialWeakMapCollisions.length) { - ts.forEach(potentialWeakMapCollisions, checkWeakMapCollision); - ts.clear(potentialWeakMapCollisions); + if (potentialWeakMapSetCollisions.length) { + ts.forEach(potentialWeakMapSetCollisions, checkWeakMapSetCollision); + ts.clear(potentialWeakMapSetCollisions); } links.flags |= 1 /* TypeChecked */; } @@ -78098,17 +80913,17 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 297 /* SourceFile */: - if (!ts.isExternalOrCommonJsModule(location)) + case 299 /* SourceFile */: + if (!ts.isExternalModule(location)) break; // falls through - case 256 /* ModuleDeclaration */: - copySymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); + case 258 /* ModuleDeclaration */: + copyLocallyVisibleExportSymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); break; - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); @@ -78116,8 +80931,8 @@ 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 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: + case 254 /* ClassDeclaration */: + case 255 /* 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. @@ -78126,7 +80941,7 @@ var ts; copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* Type */); } break; - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -78166,27 +80981,37 @@ var ts; }); } } + function copyLocallyVisibleExportSymbols(source, meaning) { + if (meaning) { + source.forEach(function (symbol) { + // Similar condition as in `resolveNameHelper` + if (!ts.getDeclarationOfKind(symbol, 272 /* ExportSpecifier */) && !ts.getDeclarationOfKind(symbol, 271 /* NamespaceExport */)) { + copySymbol(symbol, meaning); + } + }); + } + } } function isTypeDeclarationName(name) { - return name.kind === 78 /* Identifier */ && + return name.kind === 79 /* Identifier */ && isTypeDeclaration(name.parent) && ts.getNameOfDeclaration(name.parent) === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 159 /* TypeParameter */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 255 /* EnumDeclaration */: - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 325 /* JSDocEnumTag */: + case 161 /* TypeParameter */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 257 /* EnumDeclaration */: + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + case 333 /* JSDocEnumTag */: return true; - case 262 /* ImportClause */: + case 264 /* ImportClause */: return node.isTypeOnly; - case 265 /* ImportSpecifier */: - case 270 /* ExportSpecifier */: + case 267 /* ImportSpecifier */: + case 272 /* ExportSpecifier */: return node.parent.parent.isTypeOnly; default: return false; @@ -78194,25 +81019,16 @@ var ts; } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(node) { - while (node.parent.kind === 157 /* QualifiedName */) { + while (node.parent.kind === 159 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 173 /* TypeReference */; + return node.parent.kind === 175 /* TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 201 /* PropertyAccessExpression */) { - node = node.parent; - } - return node.parent.kind === 223 /* ExpressionWithTypeArguments */; - } - function isJSDocEntryNameReference(node) { - while (node.parent.kind === 157 /* QualifiedName */) { + while (node.parent.kind === 203 /* PropertyAccessExpression */) { node = node.parent; } - while (node.parent.kind === 201 /* PropertyAccessExpression */) { - node = node.parent; - } - return node.parent.kind === 302 /* JSDocNameReference */; + return node.parent.kind === 225 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -78240,13 +81056,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 157 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 159 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 260 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 262 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 266 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 268 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -78272,7 +81088,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 195 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 197 /* ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -78282,17 +81098,17 @@ var ts; return getSymbolOfNode(name.parent); } if (ts.isInJSFile(name) && - name.parent.kind === 201 /* PropertyAccessExpression */ && + name.parent.kind === 203 /* PropertyAccessExpression */ && name.parent === name.parent.parent.left) { // Check if this is a special property assignment - if (!ts.isPrivateIdentifier(name)) { + if (!ts.isPrivateIdentifier(name) && !ts.isJSDocMemberName(name)) { var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(name); if (specialPropertyAssignmentSymbol) { return specialPropertyAssignmentSymbol; } } } - if (name.parent.kind === 266 /* ExportAssignment */ && ts.isEntityNameExpression(name)) { + if (name.parent.kind === 268 /* 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); @@ -78300,13 +81116,13 @@ var ts; return success; } } - else if (!ts.isPropertyAccessExpression(name) && !ts.isPrivateIdentifier(name) && isInRightSideOfImportOrExportAssignment(name)) { + 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, 260 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(name, 262 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(name, /*dontResolveAlias*/ true); } - if (!ts.isPropertyAccessExpression(name) && !ts.isPrivateIdentifier(name)) { + if (ts.isEntityName(name)) { var possibleImportNode = isImportTypeQualifierPart(name); if (possibleImportNode) { getTypeFromTypeNode(possibleImportNode); @@ -78314,13 +81130,13 @@ var ts; return sym === unknownSymbol ? undefined : sym; } } - while (ts.isRightSideOfQualifiedNameOrPropertyAccess(name)) { + while (ts.isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName(name)) { name = name.parent; } if (isHeritageClauseElementIdentifier(name)) { var meaning = 0 /* None */; // In an interface or class, we're definitely interested in a type. - if (name.parent.kind === 223 /* ExpressionWithTypeArguments */) { + if (name.parent.kind === 225 /* ExpressionWithTypeArguments */) { meaning = 788968 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(name.parent)) { @@ -78336,10 +81152,10 @@ var ts; return entityNameSymbol; } } - if (name.parent.kind === 326 /* JSDocParameterTag */) { + if (name.parent.kind === 334 /* JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(name.parent); } - if (name.parent.kind === 159 /* TypeParameter */ && name.parent.parent.kind === 330 /* JSDocTemplateTag */) { + if (name.parent.kind === 161 /* TypeParameter */ && name.parent.parent.kind === 338 /* JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJSFile(name)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(name.parent); return typeParameter && typeParameter.symbol; @@ -78349,43 +81165,81 @@ var ts; // Missing entity name. return undefined; } - if (name.kind === 78 /* Identifier */) { + 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 */) { if (ts.isJSXTagName(name) && isJsxIntrinsicIdentifier(name)) { var symbol = getIntrinsicTagSymbol(name.parent); return symbol === unknownSymbol ? undefined : symbol; } - return resolveEntityName(name, 111551 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); + var result = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ !isJSDoc_1, ts.getHostSignatureFromJSDoc(name)); + if (!result && isJSDoc_1) { + var container = ts.findAncestor(name, ts.or(ts.isClassLike, ts.isInterfaceDeclaration)); + if (container) { + return resolveJSDocMemberName(name, getSymbolOfNode(container)); + } + } + return result; } - else if (name.kind === 201 /* PropertyAccessExpression */ || name.kind === 157 /* QualifiedName */) { + else if (name.kind === 203 /* PropertyAccessExpression */ || name.kind === 159 /* QualifiedName */) { var links = getNodeLinks(name); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (name.kind === 201 /* PropertyAccessExpression */) { - checkPropertyAccessExpression(name); + if (name.kind === 203 /* PropertyAccessExpression */) { + checkPropertyAccessExpression(name, 0 /* Normal */); } else { - checkQualifiedName(name); + checkQualifiedName(name, 0 /* Normal */); + } + if (!links.resolvedSymbol && isJSDoc_1 && ts.isQualifiedName(name)) { + return resolveJSDocMemberName(name); } return links.resolvedSymbol; } + else if (ts.isJSDocMemberName(name)) { + return resolveJSDocMemberName(name); + } } else if (isTypeReferenceIdentifier(name)) { - var meaning = name.parent.kind === 173 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; + var meaning = name.parent.kind === 175 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; return resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (isJSDocEntryNameReference(name)) { - var meaning = 788968 /* Type */ | 1920 /* Namespace */ | 111551 /* Value */; - return resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true, ts.getHostSignatureFromJSDoc(name)); - } - if (name.parent.kind === 172 /* TypePredicate */) { + if (name.parent.kind === 174 /* TypePredicate */) { return resolveEntityName(name, /*meaning*/ 1 /* FunctionScopedVariable */); } - // Do we want to return undefined here? return undefined; } + /** + * Recursively resolve entity names and jsdoc instance references: + * 1. K#m as K.prototype.m for a class (or other value) K + * 2. K.m as K.prototype.m + * 3. I.m as I.m for a type I, or any other I.m that fails to resolve in (1) or (2) + * + * For unqualified names, a container K may be provided as a second argument. + */ + function resolveJSDocMemberName(name, container) { + if (ts.isEntityName(name)) { + // resolve static values first + var meaning = 788968 /* Type */ | 1920 /* Namespace */ | 111551 /* Value */; + var symbol = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true, ts.getHostSignatureFromJSDoc(name)); + if (!symbol && ts.isIdentifier(name) && container) { + symbol = getMergedSymbol(getSymbol(getExportsOfSymbol(container), name.escapedText, meaning)); + } + if (symbol) { + return symbol; + } + } + var left = ts.isIdentifier(name) ? container : resolveJSDocMemberName(name.left); + var right = ts.isIdentifier(name) ? name.escapedText : name.right.escapedText; + if (left) { + var proto = left.flags & 111551 /* Value */ && getPropertyOfType(getTypeOfSymbol(left), "prototype"); + var t = proto ? getTypeOfSymbol(proto) : getDeclaredTypeOfSymbol(left); + return getPropertyOfType(t, right); + } + } function getSymbolAtLocation(node, ignoreErrors) { - if (node.kind === 297 /* SourceFile */) { + if (node.kind === 299 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; @@ -78404,12 +81258,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(parent.parent); } - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfNameOrPropertyAccessExpression(node); } - else if (parent.kind === 198 /* BindingElement */ && - grandParent.kind === 196 /* ObjectBindingPattern */ && + else if (parent.kind === 200 /* BindingElement */ && + grandParent.kind === 198 /* ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText); @@ -78419,12 +81273,12 @@ var ts; } } switch (node.kind) { - case 78 /* Identifier */: - case 79 /* PrivateIdentifier */: - case 201 /* PropertyAccessExpression */: - case 157 /* QualifiedName */: + case 79 /* Identifier */: + case 80 /* PrivateIdentifier */: + case 203 /* PropertyAccessExpression */: + case 159 /* QualifiedName */: return getSymbolOfNameOrPropertyAccessExpression(node); - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -78436,14 +81290,14 @@ var ts; return checkExpression(node).symbol; } // falls through - case 187 /* ThisType */: + case 189 /* ThisType */: return getTypeFromThisTypeNode(node).symbol; - case 105 /* SuperKeyword */: + case 106 /* SuperKeyword */: return checkExpression(node).symbol; - case 132 /* ConstructorKeyword */: + case 133 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 166 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 168 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -78454,7 +81308,7 @@ var ts; // 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 === 261 /* ImportDeclaration */ || node.parent.kind === 267 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 263 /* ImportDeclaration */ || node.parent.kind === 269 /* 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); @@ -78471,21 +81325,21 @@ var ts; ? getTypeFromTypeNode(grandParent.objectType) : undefined; return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text)); - case 87 /* DefaultKeyword */: - case 97 /* FunctionKeyword */: + case 88 /* DefaultKeyword */: + case 98 /* FunctionKeyword */: case 38 /* EqualsGreaterThanToken */: - case 83 /* ClassKeyword */: + case 84 /* ClassKeyword */: return getSymbolOfNode(node.parent); - case 195 /* ImportType */: + case 197 /* ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal, ignoreErrors) : undefined; - case 92 /* ExportKeyword */: + case 93 /* ExportKeyword */: return ts.isExportAssignment(node.parent) ? ts.Debug.checkDefined(node.parent.symbol) : undefined; default: return undefined; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 289 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 291 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 111551 /* Value */ | 2097152 /* Alias */); } return undefined; @@ -78564,27 +81418,27 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfAssignmentPattern(expr) { - ts.Debug.assert(expr.kind === 200 /* ObjectLiteralExpression */ || expr.kind === 199 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 202 /* ObjectLiteralExpression */ || expr.kind === 201 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 239 /* ForOfStatement */) { + if (expr.parent.kind === 241 /* 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 === 216 /* BinaryExpression */) { + if (expr.parent.kind === 218 /* 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 === 288 /* PropertyAssignment */) { - var node_2 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); - var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_2) || errorType; - var propertyIndex = ts.indexOfNode(node_2.properties, expr.parent); - return checkObjectLiteralDestructuringPropertyAssignment(node_2, typeOfParentObjectLiteral, propertyIndex); + if (expr.parent.kind === 290 /* 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); + return checkObjectLiteralDestructuringPropertyAssignment(node_3, typeOfParentObjectLiteral, propertyIndex); } // Array literal assignment - array destructuring pattern var node = ts.cast(expr.parent, ts.isArrayLiteralExpression); @@ -78623,12 +81477,12 @@ var ts; function getClassElementPropertyKeyType(element) { var name = element.name; switch (name.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return getLiteralType(ts.idText(name)); case 8 /* NumericLiteral */: case 10 /* StringLiteral */: return getLiteralType(name.text); - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(name); return isTypeAssignableToKind(nameType, 12288 /* ESSymbolLike */) ? nameType : stringType; default: @@ -78725,6 +81579,7 @@ var ts; // When resolved as an expression identifier, if the given node references an exported entity, return the declaration // node of the exported entity's container. Otherwise, return undefined. function getReferencedExportContainer(nodeIn, prefixLocals) { + var _a; var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { // When resolving the export container for the name of a module or enum @@ -78745,7 +81600,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 297 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && ((_a = parentSymbol_1.valueDeclaration) === null || _a === void 0 ? void 0 : _a.kind) === 299 /* 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. @@ -78775,11 +81630,12 @@ var ts; return undefined; } function isSymbolOfDestructuredElementOfCatchBinding(symbol) { - return ts.isBindingElement(symbol.valueDeclaration) - && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 287 /* CatchClause */; + return symbol.valueDeclaration + && ts.isBindingElement(symbol.valueDeclaration) + && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 289 /* CatchClause */; } function isSymbolOfDeclarationWithCollidingName(symbol) { - if (symbol.flags & 418 /* BlockScoped */ && !ts.isSourceFile(symbol.valueDeclaration)) { + if (symbol.flags & 418 /* BlockScoped */ && symbol.valueDeclaration && !ts.isSourceFile(symbol.valueDeclaration)) { var links = getSymbolLinks(symbol); if (links.isDeclarationWithCollidingName === undefined) { var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); @@ -78807,7 +81663,7 @@ var ts; // they will not collide with anything var isDeclaredInLoop = nodeLinks_1.flags & 524288 /* BlockScopedBindingInLoop */; var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false); - var inLoopBodyBlock = container.kind === 230 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 232 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -78848,20 +81704,20 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 262 /* ImportClause */: - case 263 /* NamespaceImport */: - case 265 /* ImportSpecifier */: - case 270 /* ExportSpecifier */: + case 264 /* ImportClause */: + case 265 /* NamespaceImport */: + case 267 /* ImportSpecifier */: + case 272 /* ExportSpecifier */: var symbol = getSymbolOfNode(node) || unknownSymbol; return isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && (ts.isNamespaceExport(exportClause) || ts.some(exportClause.elements, isValueAliasDeclaration)); - case 266 /* ExportAssignment */: - return node.expression && node.expression.kind === 78 /* Identifier */ ? + case 268 /* ExportAssignment */: + return node.expression && node.expression.kind === 79 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : true; } @@ -78869,7 +81725,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 297 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 299 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -78884,7 +81740,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 */) && - (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target)); + (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target)); } function isConstEnumOrConstEnumOnlyModule(s) { return isConstEnumSymbol(s) || !!s.constEnumOnlyModule; @@ -78892,13 +81748,14 @@ var ts; function isReferencedAliasDeclaration(node, checkChildren) { if (isAliasSymbolDeclaration(node)) { var symbol = getSymbolOfNode(node); - if (symbol && getSymbolLinks(symbol).referenced) { + var links = symbol && getSymbolLinks(symbol); + if (links === null || links === void 0 ? void 0 : links.referenced) { return true; } var target = getSymbolLinks(symbol).target; // TODO: GH#18217 if (target && ts.getEffectiveModifierFlags(node) & 1 /* Export */ && target.flags & 111551 /* Value */ && - (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) { + (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) { // An `export import ... =` of a value symbol is always considered referenced return true; } @@ -78935,13 +81792,13 @@ var ts; !isOptionalParameter(parameter) && !ts.isJSDocParameterTag(parameter) && !!parameter.initializer && - !ts.hasSyntacticModifier(parameter, 92 /* ParameterPropertyModifier */); + !ts.hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */); } function isOptionalUninitializedParameterProperty(parameter) { return strictNullChecks && isOptionalParameter(parameter) && !parameter.initializer && - ts.hasSyntacticModifier(parameter, 92 /* ParameterPropertyModifier */); + ts.hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */); } function isOptionalUninitializedParameter(parameter) { return !!strictNullChecks && @@ -78976,15 +81833,15 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 291 /* EnumMember */: - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 293 /* EnumMember */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 291 /* EnumMember */) { + if (node.kind === 293 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -79072,7 +81929,7 @@ var ts; function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) { var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor); if (!declaration) { - return ts.factory.createToken(128 /* AnyKeyword */); + return ts.factory.createToken(129 /* AnyKeyword */); } // Get type of the symbol if this is the valid symbol otherwise get type at location var symbol = getSymbolOfNode(declaration); @@ -79091,7 +81948,7 @@ var ts; function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) { var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike); if (!signatureDeclaration) { - return ts.factory.createToken(128 /* AnyKeyword */); + return ts.factory.createToken(129 /* AnyKeyword */); } var signature = getSignatureFromDeclaration(signatureDeclaration); return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); @@ -79099,7 +81956,7 @@ var ts; function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) { var expr = ts.getParseTreeNode(exprIn, ts.isExpression); if (!expr) { - return ts.factory.createToken(128 /* AnyKeyword */); + return ts.factory.createToken(129 /* AnyKeyword */); } var type = getWidenedType(getRegularTypeOfExpression(expr)); return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); @@ -79137,8 +81994,7 @@ var ts; } function isLiteralConstDeclaration(node) { if (ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node)) { - var type = getTypeOfSymbol(getSymbolOfNode(node)); - return !!(type.flags & 2944 /* Literal */) && isFreshLiteralType(type); + return isFreshLiteralType(getTypeOfSymbol(getSymbolOfNode(node))); } return false; } @@ -79257,12 +82113,12 @@ var ts; getJsxFragmentFactoryEntity: getJsxFragmentFactoryEntity, getAllAccessorDeclarations: function (accessor) { accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); // TODO: GH#18217 - var otherKind = accessor.kind === 168 /* SetAccessor */ ? 167 /* GetAccessor */ : 168 /* SetAccessor */; + var otherKind = accessor.kind === 170 /* SetAccessor */ ? 169 /* GetAccessor */ : 170 /* 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 === 168 /* SetAccessor */ ? accessor : otherAccessor; - var getAccessor = accessor.kind === 167 /* GetAccessor */ ? accessor : otherAccessor; + var setAccessor = accessor.kind === 170 /* SetAccessor */ ? accessor : otherAccessor; + var getAccessor = accessor.kind === 169 /* GetAccessor */ ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -79278,7 +82134,7 @@ var ts; }, getDeclarationStatementsForSourceFile: function (node, flags, tracker, bundled) { var n = ts.getParseTreeNode(node); - ts.Debug.assert(n && n.kind === 297 /* SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); + ts.Debug.assert(n && n.kind === 299 /* SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); var sym = getSymbolOfNode(node); if (!sym) { return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker, bundled); @@ -79301,11 +82157,13 @@ var ts; var s = _a[_i]; if (s.mergeId) { var merged = getMergedSymbol(s); - for (var _b = 0, _c = merged.declarations; _b < _c.length; _b++) { - var d = _c[_b]; - var declFile = ts.getSourceFileOfNode(d); - if (declFile === importTarget) { - return true; + if (merged.declarations) { + for (var _b = 0, _c = merged.declarations; _b < _c.length; _b++) { + var d = _c[_b]; + var declFile = ts.getSourceFileOfNode(d); + if (declFile === importTarget) { + return true; + } } } } @@ -79313,7 +82171,7 @@ var ts; return false; } function isInHeritageClause(node) { - return node.parent && node.parent.kind === 223 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 286 /* HeritageClause */; + return node.parent && node.parent.kind === 225 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 288 /* HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -79325,7 +82183,7 @@ var ts; // 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 === 78 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 201 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { + if ((node.kind === 79 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 203 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); @@ -79334,10 +82192,7 @@ var ts; // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForSymbol(symbol, meaning) { // program does not have any files with type reference directives - bail out - if (!fileToDirective) { - return undefined; - } - if (!isSymbolFromTypeDeclarationFile(symbol)) { + if (!fileToDirective || !isSymbolFromTypeDeclarationFile(symbol)) { return undefined; } // check what declarations in the symbol can contribute to the target meaning @@ -79376,7 +82231,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 297 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 299 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -79404,12 +82259,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 256 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 258 /* 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, 297 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 299 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -79429,7 +82284,7 @@ var ts; // It is an error for a non-external-module (i.e. script) to declare its own `globalThis`. // We can't use `builtinGlobals` for this due to synthetic expando-namespace generation in JS files. var fileGlobalThisSymbol = file.locals.get("globalThis"); - if (fileGlobalThisSymbol) { + if (fileGlobalThisSymbol === null || fileGlobalThisSymbol === void 0 ? void 0 : fileGlobalThisSymbol.declarations) { for (var _d = 0, _e = fileGlobalThisSymbol.declarations; _d < _e.length; _d++) { var declaration = _e[_d]; diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0, "globalThis")); @@ -79553,6 +82408,16 @@ var ts; 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 */) { + 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 */) { + 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); + } + } } } } @@ -79602,14 +82467,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 165 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 167 /* 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 === 167 /* GetAccessor */ || node.kind === 168 /* SetAccessor */) { + else if (node.kind === 169 /* GetAccessor */ || node.kind === 170 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -79622,31 +82487,51 @@ var ts; if (quickResult !== undefined) { return quickResult; } - var lastStatic, lastDeclare, lastAsync, lastReadonly; + var lastStatic, lastDeclare, lastAsync, lastReadonly, lastOverride; var flags = 0 /* None */; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 142 /* ReadonlyKeyword */) { - if (node.kind === 162 /* PropertySignature */ || node.kind === 164 /* MethodSignature */) { + if (modifier.kind !== 143 /* ReadonlyKeyword */) { + if (node.kind === 164 /* PropertySignature */ || node.kind === 166 /* MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 171 /* IndexSignature */) { + if (node.kind === 173 /* IndexSignature */ && (modifier.kind !== 124 /* StaticKeyword */ || !ts.isClassLike(node.parent))) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 84 /* ConstKeyword */: - if (node.kind !== 255 /* EnumDeclaration */) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(84 /* ConstKeyword */)); + case 85 /* ConstKeyword */: + if (node.kind !== 257 /* EnumDeclaration */) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(85 /* ConstKeyword */)); } break; - case 122 /* PublicKeyword */: - case 121 /* ProtectedKeyword */: - case 120 /* PrivateKeyword */: + case 157 /* OverrideKeyword */: + // If node.kind === SyntaxKind.Parameter, checkParameter reports an error if it's not a parameter property. + if (flags & 16384 /* Override */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "override"); + } + else if (flags & 2 /* Ambient */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "override", "declare"); + } + else if (flags & 64 /* Readonly */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "override", "readonly"); + } + else if (flags & 256 /* Async */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "override", "async"); + } + flags |= 16384 /* Override */; + lastOverride = modifier; + break; + case 123 /* PublicKeyword */: + case 122 /* ProtectedKeyword */: + case 121 /* PrivateKeyword */: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); if (flags & 28 /* AccessibilityModifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); } + else if (flags & 16384 /* Override */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "override"); + } else if (flags & 32 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } @@ -79656,23 +82541,23 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 257 /* ModuleBlock */ || node.parent.kind === 297 /* SourceFile */) { + else if (node.parent.kind === 259 /* ModuleBlock */ || node.parent.kind === 299 /* 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 === 120 /* PrivateKeyword */) { + if (modifier.kind === 121 /* PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "abstract"); } } - else if (ts.isPrivateIdentifierPropertyDeclaration(node)) { + else if (ts.isPrivateIdentifierClassElementDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics.An_accessibility_modifier_cannot_be_used_with_a_private_identifier); } flags |= ts.modifierToFlag(modifier.kind); break; - case 123 /* StaticKeyword */: + case 124 /* StaticKeyword */: if (flags & 32 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } @@ -79682,33 +82567,33 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 257 /* ModuleBlock */ || node.parent.kind === 297 /* SourceFile */) { + else if (node.parent.kind === 259 /* ModuleBlock */ || node.parent.kind === 299 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 160 /* Parameter */) { + else if (node.kind === 162 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - else if (ts.isPrivateIdentifierPropertyDeclaration(node)) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "static"); + else if (flags & 16384 /* Override */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "override"); } flags |= 32 /* Static */; lastStatic = modifier; break; - case 142 /* ReadonlyKeyword */: + case 143 /* ReadonlyKeyword */: if (flags & 64 /* Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 163 /* PropertyDeclaration */ && node.kind !== 162 /* PropertySignature */ && node.kind !== 171 /* IndexSignature */ && node.kind !== 160 /* Parameter */) { - // If node.kind === SyntaxKind.Parameter, checkParameter report an error if it's not a parameter property. + else if (node.kind !== 165 /* PropertyDeclaration */ && node.kind !== 164 /* PropertySignature */ && node.kind !== 173 /* IndexSignature */ && node.kind !== 162 /* 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 */; lastReadonly = modifier; break; - case 92 /* ExportKeyword */: + case 93 /* ExportKeyword */: if (flags & 1 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -79724,53 +82609,56 @@ var ts; 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 === 160 /* Parameter */) { + else if (node.kind === 162 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; - case 87 /* DefaultKeyword */: - var container = node.parent.kind === 297 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 256 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + case 88 /* DefaultKeyword */: + var container = node.parent.kind === 299 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 258 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } flags |= 512 /* Default */; break; - case 133 /* DeclareKeyword */: + case 134 /* DeclareKeyword */: if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } + else if (flags & 16384 /* 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 === 160 /* Parameter */) { + else if (node.kind === 162 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 8388608 /* Ambient */) && node.parent.kind === 257 /* ModuleBlock */) { + else if ((node.parent.flags & 8388608 /* Ambient */) && node.parent.kind === 259 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } - else if (ts.isPrivateIdentifierPropertyDeclaration(node)) { + else if (ts.isPrivateIdentifierClassElementDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "declare"); } flags |= 2 /* Ambient */; lastDeclare = modifier; break; - case 125 /* AbstractKeyword */: + case 126 /* AbstractKeyword */: if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 252 /* ClassDeclaration */ && - node.kind !== 175 /* ConstructorType */) { - if (node.kind !== 165 /* MethodDeclaration */ && - node.kind !== 163 /* PropertyDeclaration */ && - node.kind !== 167 /* GetAccessor */ && - node.kind !== 168 /* SetAccessor */) { + if (node.kind !== 254 /* ClassDeclaration */ && + node.kind !== 177 /* ConstructorType */) { + if (node.kind !== 167 /* MethodDeclaration */ && + node.kind !== 165 /* PropertyDeclaration */ && + node.kind !== 169 /* GetAccessor */ && + node.kind !== 170 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 252 /* ClassDeclaration */ && ts.hasSyntacticModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 254 /* ClassDeclaration */ && ts.hasSyntacticModifier(node.parent, 128 /* Abstract */))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32 /* Static */) { @@ -79782,20 +82670,23 @@ var ts; if (flags & 256 /* Async */ && lastAsync) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "async", "abstract"); } + if (flags & 16384 /* Override */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "abstract", "override"); + } } - if (ts.isNamedDeclaration(node) && node.name.kind === 79 /* PrivateIdentifier */) { + if (ts.isNamedDeclaration(node) && node.name.kind === 80 /* PrivateIdentifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "abstract"); } flags |= 128 /* Abstract */; break; - case 129 /* AsyncKeyword */: + case 130 /* AsyncKeyword */: if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } else if (flags & 2 /* Ambient */ || node.parent.flags & 8388608 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 160 /* Parameter */) { + else if (node.kind === 162 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } if (flags & 128 /* Abstract */) { @@ -79806,13 +82697,16 @@ var ts; break; } } - if (node.kind === 166 /* Constructor */) { + if (node.kind === 168 /* Constructor */) { if (flags & 32 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } if (flags & 128 /* Abstract */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract"); // TODO: GH#18217 } + if (flags & 16384 /* Override */) { + return grammarErrorOnNode(lastOverride, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "override"); // TODO: GH#18217 + } else if (flags & 256 /* Async */) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); } @@ -79821,13 +82715,13 @@ var ts; } return false; } - else if ((node.kind === 261 /* ImportDeclaration */ || node.kind === 260 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 263 /* ImportDeclaration */ || node.kind === 262 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 160 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 162 /* Parameter */ && (flags & 16476 /* 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 === 160 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 162 /* Parameter */ && (flags & 16476 /* ParameterPropertyModifier */) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256 /* Async */) { @@ -79848,39 +82742,39 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 166 /* Constructor */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 171 /* IndexSignature */: - case 256 /* ModuleDeclaration */: - case 261 /* ImportDeclaration */: - case 260 /* ImportEqualsDeclaration */: - case 267 /* ExportDeclaration */: - case 266 /* ExportAssignment */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 160 /* Parameter */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 168 /* Constructor */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 173 /* IndexSignature */: + case 258 /* ModuleDeclaration */: + case 263 /* ImportDeclaration */: + case 262 /* ImportEqualsDeclaration */: + case 269 /* ExportDeclaration */: + case 268 /* ExportAssignment */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 162 /* Parameter */: return false; default: - if (node.parent.kind === 257 /* ModuleBlock */ || node.parent.kind === 297 /* SourceFile */) { + if (node.parent.kind === 259 /* ModuleBlock */ || node.parent.kind === 299 /* SourceFile */) { return false; } switch (node.kind) { - case 251 /* FunctionDeclaration */: - return nodeHasAnyModifiersExcept(node, 129 /* AsyncKeyword */); - case 252 /* ClassDeclaration */: - case 175 /* ConstructorType */: - return nodeHasAnyModifiersExcept(node, 125 /* AbstractKeyword */); - case 253 /* InterfaceDeclaration */: - case 232 /* VariableStatement */: - case 254 /* TypeAliasDeclaration */: + case 253 /* FunctionDeclaration */: + return nodeHasAnyModifiersExcept(node, 130 /* AsyncKeyword */); + case 254 /* ClassDeclaration */: + case 177 /* ConstructorType */: + return nodeHasAnyModifiersExcept(node, 126 /* AbstractKeyword */); + case 255 /* InterfaceDeclaration */: + case 234 /* VariableStatement */: + case 256 /* TypeAliasDeclaration */: return true; - case 255 /* EnumDeclaration */: - return nodeHasAnyModifiersExcept(node, 84 /* ConstKeyword */); + case 257 /* EnumDeclaration */: + return nodeHasAnyModifiersExcept(node, 85 /* ConstKeyword */); default: ts.Debug.fail(); } @@ -79891,10 +82785,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 165 /* MethodDeclaration */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -80013,7 +82907,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 147 /* StringKeyword */ && parameter.type.kind !== 144 /* NumberKeyword */) { + if (parameter.type.kind !== 148 /* StringKeyword */ && parameter.type.kind !== 145 /* NumberKeyword */) { var type = getTypeFromTypeNode(parameter.type); if (type.flags & 4 /* String */ || type.flags & 8 /* Number */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead, ts.getTextOfNode(parameter.name), typeToString(type), typeToString(node.type ? getTypeFromTypeNode(node.type) : anyType)); @@ -80055,7 +82949,7 @@ var ts; if (args) { for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 222 /* OmittedExpression */) { + if (arg.kind === 224 /* OmittedExpression */) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -80085,7 +82979,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 === 93 /* ExtendsKeyword */) { + if (heritageClause.token === 94 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -80098,7 +82992,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 116 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 117 /* ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -80114,14 +83008,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 93 /* ExtendsKeyword */) { + if (heritageClause.token === 94 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 116 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 117 /* ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -80132,20 +83026,20 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 158 /* ComputedPropertyName */) { + if (node.kind !== 160 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 216 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* CommaToken */) { + if (computedPropertyName.expression.kind === 218 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* 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 === 251 /* FunctionDeclaration */ || - node.kind === 208 /* FunctionExpression */ || - node.kind === 165 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 253 /* FunctionDeclaration */ || + node.kind === 210 /* FunctionExpression */ || + node.kind === 167 /* MethodDeclaration */); if (node.flags & 8388608 /* Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -80164,7 +83058,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 === 290 /* SpreadAssignment */) { + if (prop.kind === 292 /* SpreadAssignment */) { if (inDestructuring) { // a rest property cannot be destructured any further var expression = ts.skipParentheses(prop.expression); @@ -80175,24 +83069,24 @@ var ts; continue; } var name = prop.name; - if (name.kind === 158 /* ComputedPropertyName */) { + if (name.kind === 160 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 289 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 291 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern // outside of destructuring it is a syntax error return 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 === 79 /* PrivateIdentifier */) { - return grammarErrorOnNode(name, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); + if (name.kind === 80 /* 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 (prop.modifiers) { // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { // TODO: GH#19955 var mod = _c[_b]; - if (mod.kind !== 129 /* AsyncKeyword */ || prop.kind !== 165 /* MethodDeclaration */) { + if (mod.kind !== 130 /* AsyncKeyword */ || prop.kind !== 167 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -80207,10 +83101,10 @@ 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 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); // falls through - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8 /* NumericLiteral */) { @@ -80218,13 +83112,13 @@ var ts; } currentKind = 4 /* PropertyAssignment */; break; - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: currentKind = 8 /* Method */; break; - case 167 /* GetAccessor */: + case 169 /* GetAccessor */: currentKind = 1 /* GetAccessor */; break; - case 168 /* SetAccessor */: + case 170 /* SetAccessor */: currentKind = 2 /* SetAccessor */; break; default: @@ -80259,11 +83153,12 @@ var ts; } } function checkGrammarJsxElement(node) { + checkGrammarJsxName(node.tagName); checkGrammarTypeArguments(node, node.typeArguments); var seen = new ts.Map(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 282 /* JsxSpreadAttribute */) { + if (attr.kind === 284 /* JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -80273,11 +83168,32 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 283 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 285 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } } + function checkGrammarJsxName(node) { + if (ts.isPropertyAccessExpression(node)) { + var propName = node; + do { + var check_1 = checkGrammarJsxNestedIdentifier(propName.name); + if (check_1) { + return check_1; + } + propName = propName.expression; + } while (ts.isPropertyAccessExpression(propName)); + var check = checkGrammarJsxNestedIdentifier(propName); + if (check) { + return check; + } + } + function checkGrammarJsxNestedIdentifier(name) { + if (ts.isIdentifier(name) && ts.idText(name).indexOf(":") !== -1) { + return grammarErrorOnNode(name, ts.Diagnostics.JSX_property_access_expressions_cannot_include_JSX_namespace_names); + } + } + } function checkGrammarJsxExpression(node) { if (node.expression && ts.isCommaSequence(node.expression)) { return grammarErrorOnNode(node.expression, ts.Diagnostics.JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array); @@ -80287,25 +83203,42 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 239 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { - if ((forInOrOfStatement.flags & 32768 /* AwaitContext */) === 0 /* None */) { - // use of 'for-await-of' in non-async function + if (forInOrOfStatement.kind === 241 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if (!(forInOrOfStatement.flags & 32768 /* AwaitContext */)) { var sourceFile = ts.getSourceFileOfNode(forInOrOfStatement); - if (!hasParseDiagnostics(sourceFile)) { - var diagnostic = ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); - var func = ts.getContainingFunction(forInOrOfStatement); - if (func && func.kind !== 166 /* Constructor */) { - ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* 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); - } - diagnostics.add(diagnostic); - return true; + if (ts.isInTopLevelContext(forInOrOfStatement)) { + if (!hasParseDiagnostics(sourceFile)) { + if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) { + diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module)); + } + if ((moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) || languageVersion < 4 /* ES2017 */) { + diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher)); + } + } + } + else { + // use of 'for-await-of' in non-async function + 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 !== 168 /* Constructor */) { + ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* 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); + } + diagnostics.add(diagnostic); + return true; + } } return false; } } - if (forInOrOfStatement.initializer.kind === 250 /* VariableDeclarationList */) { + if (ts.isForOfStatement(forInOrOfStatement) && !(forInOrOfStatement.flags & 32768 /* 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 === 252 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -80320,20 +83253,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 238 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 240 /* 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 === 238 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 240 /* 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 === 238 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 240 /* 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); @@ -80343,26 +83276,34 @@ var ts; return false; } function checkGrammarAccessor(accessor) { - if (!(accessor.flags & 8388608 /* Ambient */)) { + if (!(accessor.flags & 8388608 /* Ambient */) && (accessor.parent.kind !== 179 /* TypeLiteral */) && (accessor.parent.kind !== 255 /* InterfaceDeclaration */)) { if (languageVersion < 1 /* 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)) { + 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 */)) { return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } } - if (accessor.body && ts.hasSyntacticModifier(accessor, 128 /* Abstract */)) { - return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation); + if (accessor.body) { + if (ts.hasSyntacticModifier(accessor, 128 /* Abstract */)) { + return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation); + } + if (accessor.parent.kind === 179 /* TypeLiteral */ || accessor.parent.kind === 255 /* InterfaceDeclaration */) { + return grammarErrorOnNode(accessor.body, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); + } } if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, accessor.kind === 167 /* GetAccessor */ ? + return grammarErrorOnNode(accessor.name, accessor.kind === 169 /* GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - if (accessor.kind === 168 /* SetAccessor */) { + if (accessor.kind === 170 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -80384,17 +83325,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 === 167 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 169 /* GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 167 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 169 /* GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } function checkGrammarTypeOperatorNode(node) { - if (node.operator === 151 /* UniqueKeyword */) { - if (node.type.kind !== 148 /* SymbolKeyword */) { - return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(148 /* SymbolKeyword */)); + if (node.operator === 152 /* UniqueKeyword */) { + if (node.type.kind !== 149 /* SymbolKeyword */) { + return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(149 /* SymbolKeyword */)); } var parent = ts.walkUpParenthesizedTypes(node.parent); if (ts.isInJSFile(parent) && ts.isJSDocTypeExpression(parent)) { @@ -80405,9 +83346,9 @@ var ts; } } switch (parent.kind) { - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: var decl = parent; - if (decl.name.kind !== 78 /* Identifier */) { + if (decl.name.kind !== 79 /* 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)) { @@ -80417,13 +83358,13 @@ var ts; return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: if (!ts.hasSyntacticModifier(parent, 32 /* Static */) || !ts.hasEffectiveModifier(parent, 64 /* Readonly */)) { 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 162 /* PropertySignature */: + case 164 /* PropertySignature */: if (!ts.hasSyntacticModifier(parent, 64 /* 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); } @@ -80432,9 +83373,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_not_allowed_here); } } - else if (node.operator === 142 /* ReadonlyKeyword */) { - if (node.type.kind !== 178 /* ArrayType */ && node.type.kind !== 179 /* TupleType */) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(148 /* SymbolKeyword */)); + else if (node.operator === 143 /* ReadonlyKeyword */) { + if (node.type.kind !== 180 /* ArrayType */ && node.type.kind !== 181 /* TupleType */) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(149 /* SymbolKeyword */)); } } } @@ -80447,10 +83388,10 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 165 /* MethodDeclaration */) { - if (node.parent.kind === 200 /* ObjectLiteralExpression */) { + if (node.kind === 167 /* MethodDeclaration */) { + if (node.parent.kind === 202 /* 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 === 129 /* AsyncKeyword */)) { + if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 130 /* AsyncKeyword */)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } else if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { @@ -80468,6 +83409,9 @@ var ts; } } if (ts.isClassLike(node.parent)) { + if (languageVersion < 2 /* 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 // for property declarations and accessors too, not just methods. // However, property declarations disallow computed names in general, @@ -80476,14 +83420,14 @@ var ts; if (node.flags & 8388608 /* 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 === 165 /* MethodDeclaration */ && !node.body) { + else if (node.kind === 167 /* 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 === 253 /* InterfaceDeclaration */) { + else if (node.parent.kind === 255 /* 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 === 177 /* TypeLiteral */) { + else if (node.parent.kind === 179 /* 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); } } @@ -80494,11 +83438,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 245 /* LabeledStatement */: + case 247 /* 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 === 240 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 242 /* 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); @@ -80506,8 +83450,8 @@ var ts; return false; } break; - case 244 /* SwitchStatement */: - if (node.kind === 241 /* BreakStatement */ && !node.label) { + case 246 /* SwitchStatement */: + if (node.kind === 243 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -80522,13 +83466,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 241 /* BreakStatement */ + var message = node.kind === 243 /* 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 === 241 /* BreakStatement */ + var message = node.kind === 243 /* 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); @@ -80552,12 +83496,12 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return ts.isStringOrNumericLiteralLike(expr) || - expr.kind === 214 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && + expr.kind === 216 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function isBigIntLiteralExpression(expr) { return expr.kind === 9 /* BigIntLiteral */ || - expr.kind === 214 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && + expr.kind === 216 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && expr.operand.kind === 9 /* BigIntLiteral */; } function isSimpleLiteralEnumReference(expr) { @@ -80571,7 +83515,7 @@ var ts; if (initializer) { var isInvalidInitializer = !(isStringOrNumberLiteralExpression(initializer) || isSimpleLiteralEnumReference(initializer) || - initializer.kind === 109 /* TrueKeyword */ || initializer.kind === 94 /* FalseKeyword */ || + initializer.kind === 110 /* TrueKeyword */ || initializer.kind === 95 /* FalseKeyword */ || isBigIntLiteralExpression(initializer)); var isConstOrReadonly = ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node); if (isConstOrReadonly && !node.type) { @@ -80588,7 +83532,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 238 /* ForInStatement */ && node.parent.parent.kind !== 239 /* ForOfStatement */) { + if (node.parent.parent.kind !== 240 /* ForInStatement */ && node.parent.parent.kind !== 241 /* ForOfStatement */) { if (node.flags & 8388608 /* Ambient */) { checkAmbientInitializer(node); } @@ -80601,7 +83545,7 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 232 /* VariableStatement */ || !node.type || node.initializer || node.flags & 8388608 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 234 /* VariableStatement */ || !node.type || node.initializer || node.flags & 8388608 /* Ambient */)) { var message = node.initializer ? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions : !node.type @@ -80624,7 +83568,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkESModuleMarker(name) { - if (name.kind === 78 /* Identifier */) { + if (name.kind === 79 /* 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); } @@ -80641,8 +83585,8 @@ var ts; return false; } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 78 /* Identifier */) { - if (name.originalKeywordKind === 118 /* LetKeyword */) { + if (name.kind === 79 /* Identifier */) { + if (name.originalKeywordKind === 119 /* LetKeyword */) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -80669,15 +83613,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 234 /* IfStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: - case 243 /* WithStatement */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: + case 236 /* IfStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: + case 245 /* WithStatement */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: return false; - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -80695,12 +83639,12 @@ var ts; function checkGrammarMetaProperty(node) { var escapedText = node.name.escapedText; switch (node.keywordToken) { - case 102 /* NewKeyword */: + case 103 /* 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 99 /* ImportKeyword */: + case 100 /* 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"); } @@ -80762,14 +83706,14 @@ var ts; if (ts.isStringLiteral(node.name) && node.name.text === "constructor") { return grammarErrorOnNode(node.name, ts.Diagnostics.Classes_may_not_have_a_field_named_constructor); } - if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { + 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)) { return grammarErrorOnNode(node.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher); } } - else if (node.parent.kind === 253 /* InterfaceDeclaration */) { + else if (node.parent.kind === 255 /* 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; } @@ -80777,7 +83721,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 177 /* TypeLiteral */) { + else if (node.parent.kind === 179 /* TypeLiteral */) { if (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)) { return true; } @@ -80811,13 +83755,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 253 /* InterfaceDeclaration */ || - node.kind === 254 /* TypeAliasDeclaration */ || - node.kind === 261 /* ImportDeclaration */ || - node.kind === 260 /* ImportEqualsDeclaration */ || - node.kind === 267 /* ExportDeclaration */ || - node.kind === 266 /* ExportAssignment */ || - node.kind === 259 /* NamespaceExportDeclaration */ || + if (node.kind === 255 /* InterfaceDeclaration */ || + node.kind === 256 /* TypeAliasDeclaration */ || + node.kind === 263 /* ImportDeclaration */ || + node.kind === 262 /* ImportEqualsDeclaration */ || + node.kind === 269 /* ExportDeclaration */ || + node.kind === 268 /* ExportAssignment */ || + node.kind === 261 /* NamespaceExportDeclaration */ || ts.hasSyntacticModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -80826,7 +83770,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 === 232 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 234 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -80849,7 +83793,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 === 230 /* Block */ || node.parent.kind === 257 /* ModuleBlock */ || node.parent.kind === 297 /* SourceFile */) { + if (node.parent.kind === 232 /* Block */ || node.parent.kind === 259 /* ModuleBlock */ || node.parent.kind === 299 /* SourceFile */) { var links_2 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_2.hasReportedStatementInAmbientContext) { @@ -80871,10 +83815,10 @@ var ts; if (languageVersion >= 1 /* ES5 */) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 191 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 193 /* LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 291 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 293 /* EnumMember */)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { @@ -80980,7 +83924,7 @@ var ts; } } function findBestTypeForObjectLiteral(source, unionTarget) { - if (ts.getObjectFlags(source) & 128 /* ObjectLiteral */ && forEachType(unionTarget, isArrayLikeType)) { + if (ts.getObjectFlags(source) & 128 /* ObjectLiteral */ && someType(unionTarget, isArrayLikeType)) { return ts.find(unionTarget.types, function (t) { return !isArrayLikeType(t); }); } } @@ -81032,6 +83976,10 @@ 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 */)) { + var match = getMatchingUnionConstituentForType(target, source); + if (match) { + return match; + } var sourceProperties = getPropertiesOfType(source); if (sourceProperties) { var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target); @@ -81049,33 +83997,19 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 251 /* FunctionDeclaration */ && declaration.kind !== 165 /* MethodDeclaration */) || + return (declaration.kind !== 253 /* FunctionDeclaration */ && declaration.kind !== 167 /* 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 265 /* ImportSpecifier */: - case 270 /* ExportSpecifier */: + case 267 /* ImportSpecifier */: + case 272 /* ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); } } - function isSomeImportDeclaration(decl) { - switch (decl.kind) { - case 262 /* ImportClause */: // For default import - case 260 /* ImportEqualsDeclaration */: - case 263 /* NamespaceImport */: - case 265 /* ImportSpecifier */: // For rename import `x as y` - return true; - case 78 /* Identifier */: - // For regular import, `decl` is an Identifier under the ImportSpecifier. - return decl.parent.kind === 265 /* ImportSpecifier */; - default: - return false; - } - } var JsxNames; (function (JsxNames) { JsxNames.JSX = "JSX"; @@ -81106,7 +84040,6 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var isTypeNodeOrTypeParameterDeclaration = ts.or(ts.isTypeNode, ts.isTypeParameterDeclaration); function visitNode(node, visitor, test, lift) { if (node === undefined || visitor === undefined) { return node; @@ -81295,6 +84228,24 @@ var ts; return updated; } ts.visitFunctionBody = visitFunctionBody; + /** + * Visits an iteration body, adding any block-scoped variables required by the transformation. + */ + function visitIterationBody(body, visitor, context) { + context.startBlockScope(); + var updated = visitNode(body, visitor, ts.isStatement, context.factory.liftToBlock); + var declarations = context.endBlockScope(); + if (ts.some(declarations)) { + if (ts.isBlock(updated)) { + declarations.push.apply(declarations, updated.statements); + return context.factory.updateBlock(updated, declarations); + } + declarations.push(updated); + return context.factory.createBlock(declarations); + } + return updated; + } + ts.visitIterationBody = visitIterationBody; function visitEachChild(node, visitor, context, nodesVisitor, tokenVisitor, nodeVisitor) { if (nodesVisitor === void 0) { nodesVisitor = visitNodes; } if (nodeVisitor === void 0) { nodeVisitor = visitNode; } @@ -81303,299 +84254,433 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 156 /* LastToken */) || kind === 187 /* ThisType */) { + if ((kind > 0 /* FirstToken */ && kind <= 158 /* LastToken */) || kind === 189 /* ThisType */) { return node; } var factory = context.factory; switch (kind) { // Names - case 78 /* Identifier */: - return factory.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration)); - case 157 /* QualifiedName */: + case 79 /* Identifier */: + ts.Debug.type(node); + return factory.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNodeOrTypeParameterDeclaration)); + case 159 /* QualifiedName */: + ts.Debug.type(node); return factory.updateQualifiedName(node, nodeVisitor(node.left, visitor, ts.isEntityName), nodeVisitor(node.right, visitor, ts.isIdentifier)); - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: + ts.Debug.type(node); return factory.updateComputedPropertyName(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Signature elements - case 159 /* TypeParameter */: + case 161 /* TypeParameter */: + ts.Debug.type(node); return factory.updateTypeParameterDeclaration(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.constraint, visitor, ts.isTypeNode), nodeVisitor(node.default, visitor, ts.isTypeNode)); - case 160 /* Parameter */: - return factory.updateParameterDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isToken), nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 161 /* Decorator */: + case 162 /* Parameter */: + ts.Debug.type(node); + return factory.updateParameterDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), 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 163 /* Decorator */: + ts.Debug.type(node); return factory.updateDecorator(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Type elements - case 162 /* PropertySignature */: - return factory.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isToken), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 163 /* PropertyDeclaration */: + case 164 /* 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 165 /* PropertyDeclaration */: + ts.Debug.type(node); return factory.updatePropertyDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), 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.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 164 /* MethodSignature */: - return factory.updateMethodSignature(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 165 /* MethodDeclaration */: - return factory.updateMethodDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isToken), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), 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 166 /* Constructor */: + nodeVisitor(node.questionToken || node.exclamationToken, tokenVisitor, ts.isQuestionOrExclamationToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); + case 166 /* 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 167 /* MethodDeclaration */: + ts.Debug.type(node); + return factory.updateMethodDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), 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 168 /* Constructor */: + ts.Debug.type(node); return factory.updateConstructorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 167 /* GetAccessor */: + case 169 /* GetAccessor */: + ts.Debug.type(node); return factory.updateGetAccessorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), 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 168 /* SetAccessor */: + case 170 /* SetAccessor */: + ts.Debug.type(node); return factory.updateSetAccessorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 169 /* CallSignature */: + case 171 /* 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 170 /* ConstructSignature */: + case 172 /* 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 171 /* IndexSignature */: + case 173 /* IndexSignature */: + ts.Debug.type(node); return factory.updateIndexSignature(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); // Types - case 172 /* TypePredicate */: - return factory.updateTypePredicateNode(node, nodeVisitor(node.assertsModifier, visitor), nodeVisitor(node.parameterName, visitor), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 173 /* TypeReference */: + case 174 /* 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 175 /* TypeReference */: + ts.Debug.type(node); return factory.updateTypeReferenceNode(node, nodeVisitor(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 174 /* FunctionType */: + case 176 /* 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 175 /* ConstructorType */: + case 177 /* 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 176 /* TypeQuery */: + case 178 /* TypeQuery */: + ts.Debug.type(node); return factory.updateTypeQueryNode(node, nodeVisitor(node.exprName, visitor, ts.isEntityName)); - case 177 /* TypeLiteral */: + case 179 /* TypeLiteral */: + ts.Debug.type(node); return factory.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 178 /* ArrayType */: + case 180 /* ArrayType */: + ts.Debug.type(node); return factory.updateArrayTypeNode(node, nodeVisitor(node.elementType, visitor, ts.isTypeNode)); - case 179 /* TupleType */: + case 181 /* TupleType */: + ts.Debug.type(node); return factory.updateTupleTypeNode(node, nodesVisitor(node.elements, visitor, ts.isTypeNode)); - case 180 /* OptionalType */: + case 182 /* OptionalType */: + ts.Debug.type(node); return factory.updateOptionalTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 181 /* RestType */: + case 183 /* RestType */: + ts.Debug.type(node); return factory.updateRestTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 182 /* UnionType */: + case 184 /* UnionType */: + ts.Debug.type(node); return factory.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 183 /* IntersectionType */: + case 185 /* IntersectionType */: + ts.Debug.type(node); return factory.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 184 /* ConditionalType */: + case 186 /* 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 185 /* InferType */: + case 187 /* InferType */: + ts.Debug.type(node); return factory.updateInferTypeNode(node, nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 195 /* ImportType */: + case 197 /* ImportType */: + ts.Debug.type(node); return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); - case 192 /* NamedTupleMember */: - return factory.updateNamedTupleMember(node, visitNode(node.dotDotDotToken, visitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode)); - case 186 /* ParenthesizedType */: + case 194 /* 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 188 /* ParenthesizedType */: + ts.Debug.type(node); return factory.updateParenthesizedType(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 188 /* TypeOperator */: + case 190 /* TypeOperator */: + ts.Debug.type(node); return factory.updateTypeOperatorNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 189 /* IndexedAccessType */: + case 191 /* IndexedAccessType */: + ts.Debug.type(node); return factory.updateIndexedAccessTypeNode(node, nodeVisitor(node.objectType, visitor, ts.isTypeNode), nodeVisitor(node.indexType, visitor, ts.isTypeNode)); - case 190 /* MappedType */: - return factory.updateMappedTypeNode(node, nodeVisitor(node.readonlyToken, tokenVisitor, ts.isToken), nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration), nodeVisitor(node.nameType, visitor, ts.isTypeNode), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 191 /* LiteralType */: + case 192 /* 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)); + case 193 /* LiteralType */: + ts.Debug.type(node); return factory.updateLiteralTypeNode(node, nodeVisitor(node.literal, visitor, ts.isExpression)); - case 193 /* TemplateLiteralType */: + case 195 /* TemplateLiteralType */: + ts.Debug.type(node); return factory.updateTemplateLiteralType(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateLiteralTypeSpan)); - case 194 /* TemplateLiteralTypeSpan */: + case 196 /* TemplateLiteralTypeSpan */: + ts.Debug.type(node); return factory.updateTemplateLiteralTypeSpan(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Binding patterns - case 196 /* ObjectBindingPattern */: + case 198 /* ObjectBindingPattern */: + ts.Debug.type(node); return factory.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 197 /* ArrayBindingPattern */: + case 199 /* ArrayBindingPattern */: + ts.Debug.type(node); return factory.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 198 /* BindingElement */: - return factory.updateBindingElement(node, nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isToken), nodeVisitor(node.propertyName, visitor, ts.isPropertyName), nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.initializer, visitor, ts.isExpression)); + case 200 /* 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 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: + ts.Debug.type(node); return factory.updateArrayLiteralExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: + ts.Debug.type(node); return factory.updateObjectLiteralExpression(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: if (node.flags & 32 /* OptionalChain */) { - return factory.updatePropertyAccessChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isToken), nodeVisitor(node.name, visitor, ts.isIdentifier)); + 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)); } - return factory.updatePropertyAccessExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.name, visitor, ts.isIdentifierOrPrivateIdentifier)); - case 202 /* ElementAccessExpression */: + ts.Debug.type(node); + return factory.updatePropertyAccessExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.name, visitor, ts.isMemberName)); + case 204 /* ElementAccessExpression */: if (node.flags & 32 /* OptionalChain */) { - return factory.updateElementAccessChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isToken), nodeVisitor(node.argumentExpression, visitor, ts.isExpression)); + 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 203 /* CallExpression */: + case 205 /* CallExpression */: if (node.flags & 32 /* OptionalChain */) { - return factory.updateCallChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); + 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 204 /* NewExpression */: + case 206 /* 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 205 /* TaggedTemplateExpression */: - return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), nodeVisitor(node.template, visitor, ts.isTemplateLiteral)); - case 206 /* TypeAssertionExpression */: + case 207 /* 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 208 /* TypeAssertionExpression */: + ts.Debug.type(node); return factory.updateTypeAssertion(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: + ts.Debug.type(node); return factory.updateParenthesizedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 208 /* FunctionExpression */: - return factory.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isToken), 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 209 /* ArrowFunction */: - 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.isToken), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 210 /* DeleteExpression */: + case 210 /* 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 211 /* 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 212 /* DeleteExpression */: + ts.Debug.type(node); return factory.updateDeleteExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 211 /* TypeOfExpression */: + case 213 /* TypeOfExpression */: + ts.Debug.type(node); return factory.updateTypeOfExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 212 /* VoidExpression */: + case 214 /* VoidExpression */: + ts.Debug.type(node); return factory.updateVoidExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 213 /* AwaitExpression */: + case 215 /* AwaitExpression */: + ts.Debug.type(node); return factory.updateAwaitExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: + ts.Debug.type(node); return factory.updatePrefixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression)); - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: + ts.Debug.type(node); return factory.updatePostfixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression)); - case 216 /* BinaryExpression */: - return factory.updateBinaryExpression(node, nodeVisitor(node.left, visitor, ts.isExpression), nodeVisitor(node.operatorToken, tokenVisitor, ts.isToken), nodeVisitor(node.right, visitor, ts.isExpression)); - case 217 /* ConditionalExpression */: - return factory.updateConditionalExpression(node, nodeVisitor(node.condition, visitor, ts.isExpression), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.whenTrue, visitor, ts.isExpression), nodeVisitor(node.colonToken, tokenVisitor, ts.isToken), nodeVisitor(node.whenFalse, visitor, ts.isExpression)); - case 218 /* TemplateExpression */: + case 218 /* 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 219 /* 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 220 /* TemplateExpression */: + ts.Debug.type(node); return factory.updateTemplateExpression(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 219 /* YieldExpression */: - return factory.updateYieldExpression(node, nodeVisitor(node.asteriskToken, tokenVisitor, ts.isToken), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 220 /* SpreadElement */: + case 221 /* YieldExpression */: + ts.Debug.type(node); + return factory.updateYieldExpression(node, nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.expression, visitor, ts.isExpression)); + case 222 /* SpreadElement */: + ts.Debug.type(node); return factory.updateSpreadElement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: + ts.Debug.type(node); return factory.updateClassExpression(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), 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.isClassElement)); - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: + ts.Debug.type(node); return factory.updateExpressionWithTypeArguments(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 224 /* AsExpression */: + case 226 /* AsExpression */: + ts.Debug.type(node); return factory.updateAsExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 225 /* NonNullExpression */: + case 227 /* NonNullExpression */: if (node.flags & 32 /* 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 226 /* MetaProperty */: + case 228 /* MetaProperty */: + ts.Debug.type(node); return factory.updateMetaProperty(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); // Misc - case 228 /* TemplateSpan */: + case 230 /* TemplateSpan */: + ts.Debug.type(node); return factory.updateTemplateSpan(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 230 /* Block */: + case 232 /* Block */: + ts.Debug.type(node); return factory.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: + ts.Debug.type(node); return factory.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: + ts.Debug.type(node); return factory.updateExpressionStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 234 /* IfStatement */: + case 236 /* 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 235 /* DoStatement */: - return factory.updateDoStatement(node, nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 236 /* WhileStatement */: - return factory.updateWhileStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 237 /* ForStatement */: - return factory.updateForStatement(node, nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.condition, visitor, ts.isExpression), nodeVisitor(node.incrementor, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 238 /* ForInStatement */: - return factory.updateForInStatement(node, nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 239 /* ForOfStatement */: - return factory.updateForOfStatement(node, nodeVisitor(node.awaitModifier, tokenVisitor, ts.isToken), nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 240 /* ContinueStatement */: + case 237 /* DoStatement */: + ts.Debug.type(node); + return factory.updateDoStatement(node, visitIterationBody(node.statement, visitor, context), nodeVisitor(node.expression, visitor, ts.isExpression)); + case 238 /* WhileStatement */: + ts.Debug.type(node); + return factory.updateWhileStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); + case 239 /* 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 240 /* 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 241 /* 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 242 /* ContinueStatement */: + ts.Debug.type(node); return factory.updateContinueStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier)); - case 241 /* BreakStatement */: + case 243 /* BreakStatement */: + ts.Debug.type(node); return factory.updateBreakStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier)); - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: + ts.Debug.type(node); return factory.updateReturnStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 243 /* WithStatement */: + case 245 /* WithStatement */: + ts.Debug.type(node); return factory.updateWithStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: + ts.Debug.type(node); return factory.updateSwitchStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.caseBlock, visitor, ts.isCaseBlock)); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: + ts.Debug.type(node); return factory.updateLabeledStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 246 /* ThrowStatement */: + case 248 /* ThrowStatement */: + ts.Debug.type(node); return factory.updateThrowStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 247 /* TryStatement */: + case 249 /* 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 249 /* VariableDeclaration */: - return factory.updateVariableDeclaration(node, nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.exclamationToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 250 /* VariableDeclarationList */: + case 251 /* 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 252 /* VariableDeclarationList */: + ts.Debug.type(node); return factory.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 251 /* FunctionDeclaration */: - return factory.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isToken), 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 252 /* ClassDeclaration */: + case 253 /* FunctionDeclaration */: + ts.Debug.type(node); + return factory.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), 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 254 /* ClassDeclaration */: + ts.Debug.type(node); return factory.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), 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.isClassElement)); - case 253 /* InterfaceDeclaration */: + case 255 /* InterfaceDeclaration */: + ts.Debug.type(node); return factory.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), 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 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: + ts.Debug.type(node); return factory.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), 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 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: + ts.Debug.type(node); return factory.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); - case 256 /* ModuleDeclaration */: - return factory.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.body, visitor, ts.isModuleBody)); - case 257 /* ModuleBlock */: + case 258 /* ModuleDeclaration */: + ts.Debug.type(node); + return factory.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isModuleName), nodeVisitor(node.body, visitor, ts.isModuleBody)); + case 259 /* ModuleBlock */: + ts.Debug.type(node); return factory.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 258 /* CaseBlock */: + case 260 /* CaseBlock */: + ts.Debug.type(node); return factory.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 259 /* NamespaceExportDeclaration */: + case 261 /* NamespaceExportDeclaration */: + ts.Debug.type(node); return factory.updateNamespaceExportDeclaration(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: + ts.Debug.type(node); return factory.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.moduleReference, visitor, ts.isModuleReference)); - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: + ts.Debug.type(node); return factory.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.importClause, visitor, ts.isImportClause), nodeVisitor(node.moduleSpecifier, visitor, ts.isExpression)); - case 262 /* ImportClause */: + case 264 /* ImportClause */: + ts.Debug.type(node); return factory.updateImportClause(node, node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: + ts.Debug.type(node); return factory.updateNamespaceImport(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 269 /* NamespaceExport */: + case 271 /* NamespaceExport */: + ts.Debug.type(node); return factory.updateNamespaceExport(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 264 /* NamedImports */: + case 266 /* NamedImports */: + ts.Debug.type(node); return factory.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 265 /* ImportSpecifier */: + case 267 /* ImportSpecifier */: + ts.Debug.type(node); return factory.updateImportSpecifier(node, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: + ts.Debug.type(node); return factory.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: + ts.Debug.type(node); return factory.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), node.isTypeOnly, nodeVisitor(node.exportClause, visitor, ts.isNamedExportBindings), nodeVisitor(node.moduleSpecifier, visitor, ts.isExpression)); - case 268 /* NamedExports */: + case 270 /* NamedExports */: + ts.Debug.type(node); return factory.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 270 /* ExportSpecifier */: + case 272 /* ExportSpecifier */: + ts.Debug.type(node); return factory.updateExportSpecifier(node, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier)); // Module references - case 272 /* ExternalModuleReference */: + case 274 /* ExternalModuleReference */: + ts.Debug.type(node); return factory.updateExternalModuleReference(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // JSX - case 273 /* JsxElement */: + case 275 /* 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 274 /* JsxSelfClosingElement */: + case 276 /* 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 275 /* JsxOpeningElement */: + case 277 /* 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 276 /* JsxClosingElement */: + case 278 /* JsxClosingElement */: + ts.Debug.type(node); return factory.updateJsxClosingElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 277 /* JsxFragment */: + case 279 /* 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 280 /* JsxAttribute */: + case 282 /* JsxAttribute */: + ts.Debug.type(node); return factory.updateJsxAttribute(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 281 /* JsxAttributes */: + case 283 /* JsxAttributes */: + ts.Debug.type(node); return factory.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 282 /* JsxSpreadAttribute */: + case 284 /* JsxSpreadAttribute */: + ts.Debug.type(node); return factory.updateJsxSpreadAttribute(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: + ts.Debug.type(node); return factory.updateJsxExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Clauses - case 284 /* CaseClause */: + case 286 /* CaseClause */: + ts.Debug.type(node); return factory.updateCaseClause(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 285 /* DefaultClause */: + case 287 /* DefaultClause */: + ts.Debug.type(node); return factory.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 286 /* HeritageClause */: + case 288 /* HeritageClause */: + ts.Debug.type(node); return factory.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 287 /* CatchClause */: + case 289 /* CatchClause */: + ts.Debug.type(node); return factory.updateCatchClause(node, nodeVisitor(node.variableDeclaration, visitor, ts.isVariableDeclaration), nodeVisitor(node.block, visitor, ts.isBlock)); // Property assignments - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: + ts.Debug.type(node); return factory.updatePropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: + ts.Debug.type(node); return factory.updateShorthandPropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 290 /* SpreadAssignment */: + case 292 /* SpreadAssignment */: + ts.Debug.type(node); return factory.updateSpreadAssignment(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Enum - case 291 /* EnumMember */: + case 293 /* 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 297 /* SourceFile */: + case 299 /* SourceFile */: + ts.Debug.type(node); return factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 336 /* PartiallyEmittedExpression */: + case 344 /* PartiallyEmittedExpression */: + ts.Debug.type(node); return factory.updatePartiallyEmittedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 337 /* CommaListExpression */: + case 345 /* CommaListExpression */: + ts.Debug.type(node); return factory.updateCommaListExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: // No need to visit nodes with no children. @@ -81627,6 +84712,7 @@ var ts; var sourcesContent; var names = []; var nameToNameIndexMap; + var mappingCharCodes = []; var mappings = ""; // Last recorded and encoded mappings var lastGeneratedLine = 0; @@ -81801,6 +84887,14 @@ var ts; || lastSourceCharacter !== pendingSourceCharacter || lastNameIndex !== pendingNameIndex; } + function appendMappingCharCode(charCode) { + mappingCharCodes.push(charCode); + // String.fromCharCode accepts its arguments on the stack, so we have to chunk the input, + // otherwise we can get stack overflows for large source maps + if (mappingCharCodes.length >= 1024) { + flushMappingBuffer(); + } + } function commitPendingMapping() { if (!hasPending || !shouldCommitMapping()) { return; @@ -81810,42 +84904,50 @@ var ts; if (lastGeneratedLine < pendingGeneratedLine) { // Emit line delimiters do { - mappings += ";"; + appendMappingCharCode(59 /* semicolon */); lastGeneratedLine++; - lastGeneratedCharacter = 0; } while (lastGeneratedLine < pendingGeneratedLine); + // Only need to set this once + lastGeneratedCharacter = 0; } else { ts.Debug.assertEqual(lastGeneratedLine, pendingGeneratedLine, "generatedLine cannot backtrack"); // Emit comma to separate the entry if (hasLast) { - mappings += ","; + appendMappingCharCode(44 /* comma */); } } // 1. Relative generated character - mappings += base64VLQFormatEncode(pendingGeneratedCharacter - lastGeneratedCharacter); + appendBase64VLQ(pendingGeneratedCharacter - lastGeneratedCharacter); lastGeneratedCharacter = pendingGeneratedCharacter; if (hasPendingSource) { // 2. Relative sourceIndex - mappings += base64VLQFormatEncode(pendingSourceIndex - lastSourceIndex); + appendBase64VLQ(pendingSourceIndex - lastSourceIndex); lastSourceIndex = pendingSourceIndex; // 3. Relative source line - mappings += base64VLQFormatEncode(pendingSourceLine - lastSourceLine); + appendBase64VLQ(pendingSourceLine - lastSourceLine); lastSourceLine = pendingSourceLine; // 4. Relative source character - mappings += base64VLQFormatEncode(pendingSourceCharacter - lastSourceCharacter); + appendBase64VLQ(pendingSourceCharacter - lastSourceCharacter); lastSourceCharacter = pendingSourceCharacter; if (hasPendingName) { // 5. Relative nameIndex - mappings += base64VLQFormatEncode(pendingNameIndex - lastNameIndex); + appendBase64VLQ(pendingNameIndex - lastNameIndex); lastNameIndex = pendingNameIndex; } } hasLast = true; exit(); } + function flushMappingBuffer() { + if (mappingCharCodes.length > 0) { + mappings += String.fromCharCode.apply(undefined, mappingCharCodes); + mappingCharCodes.length = 0; + } + } function toJSON() { commitPendingMapping(); + flushMappingBuffer(); return { version: 3, file: file, @@ -81856,10 +84958,33 @@ var ts; sourcesContent: sourcesContent, }; } + function appendBase64VLQ(inValue) { + // Add a new least significant bit that has the sign of the value. + // if negative number the least significant bit that gets added to the number has value 1 + // else least significant bit value that gets added is 0 + // eg. -1 changes to binary : 01 [1] => 3 + // +1 changes to binary : 01 [0] => 2 + if (inValue < 0) { + inValue = ((-inValue) << 1) + 1; + } + else { + inValue = inValue << 1; + } + // Encode 5 bits at a time starting from least significant bits + do { + var currentDigit = inValue & 31; // 11111 + inValue = inValue >> 5; + if (inValue > 0) { + // There are still more digits to decode, set the msb (6th bit) + currentDigit = currentDigit | 32; + } + appendMappingCharCode(base64FormatEncode(currentDigit)); + } while (inValue > 0); + } } ts.createSourceMapGenerator = createSourceMapGenerator; // Sometimes tools can see the following line as a source mapping url comment, so we mangle it a bit (the [M]) - var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)\s*$/; + var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)$/; var whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/; function getLineInfo(text, lineStarts) { return { @@ -81876,7 +85001,7 @@ var ts; var line = lineInfo.getLineText(index); var comment = sourceMapCommentRegExp.exec(line); if (comment) { - return comment[1]; + return ts.trimStringEnd(comment[1]); } // If we see a non-whitespace/map comment-like line, break, to avoid scanning up the entire file else if (!line.match(whitespaceOrMapCommentRegExp)) { @@ -82082,31 +85207,6 @@ var ts; ch === 47 /* slash */ ? 63 : -1; } - function base64VLQFormatEncode(inValue) { - // Add a new least significant bit that has the sign of the value. - // if negative number the least significant bit that gets added to the number has value 1 - // else least significant bit value that gets added is 0 - // eg. -1 changes to binary : 01 [1] => 3 - // +1 changes to binary : 01 [0] => 2 - if (inValue < 0) { - inValue = ((-inValue) << 1) + 1; - } - else { - inValue = inValue << 1; - } - // Encode 5 bits at a time starting from least significant bits - var encodedStr = ""; - do { - var currentDigit = inValue & 31; // 11111 - inValue = inValue >> 5; - if (inValue > 0) { - // There are still more digits to decode, set the msb (6th bit) - currentDigit = currentDigit | 32; - } - encodedStr = encodedStr + String.fromCharCode(base64FormatEncode(currentDigit)); - } while (inValue > 0); - return encodedStr; - } function isSourceMappedPosition(value) { return value.sourceIndex !== undefined && value.sourcePosition !== undefined; @@ -82270,7 +85370,7 @@ var ts; function chainBundle(context, transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 297 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 299 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return context.factory.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -82321,7 +85421,7 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" @@ -82334,13 +85434,13 @@ var ts; hasImportDefault = true; } break; - case 260 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 272 /* ExternalModuleReference */) { + case 262 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 274 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -82371,13 +85471,13 @@ var ts; addExportedNamesForExportDeclaration(node); } break; - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: if (ts.hasSyntacticModifier(node, 1 /* Export */)) { for (var _b = 0, _c = node.declarationList.declarations; _b < _c.length; _b++) { var decl = _c[_b]; @@ -82385,7 +85485,7 @@ var ts; } } break; - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: if (ts.hasSyntacticModifier(node, 1 /* Export */)) { if (ts.hasSyntacticModifier(node, 512 /* Default */)) { // export default function() { } @@ -82405,7 +85505,7 @@ var ts; } } break; - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: if (ts.hasSyntacticModifier(node, 1 /* Export */)) { if (ts.hasSyntacticModifier(node, 512 /* Default */)) { // export default class { } @@ -82499,32 +85599,31 @@ var ts; * any such locations */ function isSimpleInlineableExpression(expression) { - return !ts.isIdentifier(expression) && isSimpleCopiableExpression(expression) || - ts.isWellKnownSymbolSyntactically(expression); + return !ts.isIdentifier(expression) && isSimpleCopiableExpression(expression); } ts.isSimpleInlineableExpression = isSimpleInlineableExpression; function isCompoundAssignment(kind) { - return kind >= 63 /* FirstCompoundAssignment */ - && kind <= 77 /* LastCompoundAssignment */; + return kind >= 64 /* FirstCompoundAssignment */ + && kind <= 78 /* LastCompoundAssignment */; } ts.isCompoundAssignment = isCompoundAssignment; function getNonAssignmentOperatorForCompoundAssignment(kind) { switch (kind) { - case 63 /* PlusEqualsToken */: return 39 /* PlusToken */; - case 64 /* MinusEqualsToken */: return 40 /* MinusToken */; - case 65 /* AsteriskEqualsToken */: return 41 /* AsteriskToken */; - case 66 /* AsteriskAsteriskEqualsToken */: return 42 /* AsteriskAsteriskToken */; - case 67 /* SlashEqualsToken */: return 43 /* SlashToken */; - case 68 /* PercentEqualsToken */: return 44 /* PercentToken */; - case 69 /* LessThanLessThanEqualsToken */: return 47 /* LessThanLessThanToken */; - case 70 /* GreaterThanGreaterThanEqualsToken */: return 48 /* GreaterThanGreaterThanToken */; - case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 49 /* GreaterThanGreaterThanGreaterThanToken */; - case 72 /* AmpersandEqualsToken */: return 50 /* AmpersandToken */; - case 73 /* BarEqualsToken */: return 51 /* BarToken */; - case 77 /* CaretEqualsToken */: return 52 /* CaretToken */; - case 74 /* BarBarEqualsToken */: return 56 /* BarBarToken */; - case 75 /* AmpersandAmpersandEqualsToken */: return 55 /* AmpersandAmpersandToken */; - case 76 /* QuestionQuestionEqualsToken */: return 60 /* QuestionQuestionToken */; + 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 */; } } ts.getNonAssignmentOperatorForCompoundAssignment = getNonAssignmentOperatorForCompoundAssignment; @@ -82579,10 +85678,19 @@ var ts; * @param isStatic A value indicating whether the member should be a static or instance member. */ function isInitializedProperty(member) { - return member.kind === 163 /* PropertyDeclaration */ + return member.kind === 165 /* PropertyDeclaration */ && member.initializer !== undefined; } ts.isInitializedProperty = isInitializedProperty; + /** + * Gets a value indicating whether a class element is a private instance method or accessor. + * + * @param member The class element node. + */ + function isNonStaticMethodOrAccessorWithPrivateName(member) { + return !ts.hasStaticModifier(member) && ts.isMethodOrAccessor(member) && ts.isPrivateIdentifier(member.name); + } + ts.isNonStaticMethodOrAccessorWithPrivateName = isNonStaticMethodOrAccessorWithPrivateName; })(ts || (ts = {})); /*@internal*/ var ts; @@ -82856,8 +85964,8 @@ var ts; if (!ts.getRestIndicatorOfBindingOrAssignmentElement(element)) { var propertyName = ts.getPropertyNameOfBindingOrAssignmentElement(element); if (flattenContext.level >= 1 /* ObjectRest */ - && !(element.transformFlags & (8192 /* ContainsRestOrSpread */ | 16384 /* ContainsObjectRestOrSpread */)) - && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (8192 /* ContainsRestOrSpread */ | 16384 /* ContainsObjectRestOrSpread */)) + && !(element.transformFlags & (16384 /* ContainsRestOrSpread */ | 32768 /* ContainsObjectRestOrSpread */)) + && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (16384 /* ContainsRestOrSpread */ | 32768 /* ContainsObjectRestOrSpread */)) && !ts.isComputedPropertyName(propertyName)) { bindingElements = ts.append(bindingElements, ts.visitNode(element, flattenContext.visitor)); } @@ -82923,7 +86031,7 @@ var ts; if (flattenContext.level >= 1 /* 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 & 16384 /* ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) { + if (element.transformFlags & 32768 /* ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) { flattenContext.hasTransformedPriorElement = true; var temp = flattenContext.context.factory.createTempVariable(/*recordTempVariable*/ undefined); if (flattenContext.hoistTempVariables) { @@ -83181,8 +86289,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(201 /* PropertyAccessExpression */); - context.enableSubstitution(202 /* ElementAccessExpression */); + context.enableSubstitution(203 /* PropertyAccessExpression */); + context.enableSubstitution(204 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -83208,14 +86316,14 @@ var ts; var applicableSubstitutions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 298 /* Bundle */) { + if (node.kind === 300 /* 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 === 300 /* InputFiles */) { + if (prepend.kind === 302 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend, "js"); } return prepend; @@ -83266,16 +86374,16 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 297 /* SourceFile */: - case 258 /* CaseBlock */: - case 257 /* ModuleBlock */: - case 230 /* Block */: + case 299 /* SourceFile */: + case 260 /* CaseBlock */: + case 259 /* ModuleBlock */: + case 232 /* Block */: currentLexicalScope = node; currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 252 /* ClassDeclaration */: - case 251 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: + case 253 /* FunctionDeclaration */: if (ts.hasSyntacticModifier(node, 2 /* Ambient */)) { break; } @@ -83287,7 +86395,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 === 252 /* ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 254 /* ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* Default */)); } if (ts.isClassDeclaration(node)) { // XXX: should probably also cover interfaces and type aliases that can have type variables? @@ -83330,10 +86438,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: - case 260 /* ImportEqualsDeclaration */: - case 266 /* ExportAssignment */: - case 267 /* ExportDeclaration */: + case 263 /* ImportDeclaration */: + case 262 /* ImportEqualsDeclaration */: + case 268 /* ExportAssignment */: + case 269 /* ExportDeclaration */: return visitElidableStatement(node); default: return visitorWorker(node); @@ -83354,13 +86462,13 @@ var ts; return node; } switch (node.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return visitImportDeclaration(node); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return visitExportAssignment(node); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -83380,11 +86488,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 267 /* ExportDeclaration */ || - node.kind === 261 /* ImportDeclaration */ || - node.kind === 262 /* ImportClause */ || - (node.kind === 260 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 272 /* ExternalModuleReference */)) { + if (node.kind === 269 /* ExportDeclaration */ || + node.kind === 263 /* ImportDeclaration */ || + node.kind === 264 /* ImportClause */ || + (node.kind === 262 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 274 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -83408,29 +86516,29 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 166 /* Constructor */: + case 168 /* Constructor */: return visitConstructor(node); - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: // Property declarations are not TypeScript syntax, but they must be visited // for the decorator transformation. return visitPropertyDeclaration(node); - case 171 /* IndexSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 165 /* MethodDeclaration */: + case 173 /* IndexSignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 167 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 229 /* SemicolonClassElement */: + case 231 /* SemicolonClassElement */: return node; default: return ts.Debug.failBadSyntaxKind(node); } } function modifierVisitor(node) { - if (ts.modifierToFlag(node.kind) & 2270 /* TypeScriptModifier */) { + if (ts.modifierToFlag(node.kind) & 18654 /* TypeScriptModifier */) { return undefined; } - else if (currentNamespace && node.kind === 92 /* ExportKeyword */) { + else if (currentNamespace && node.kind === 93 /* ExportKeyword */) { return undefined; } return node; @@ -83447,71 +86555,71 @@ var ts; return factory.createNotEmittedStatement(node); } switch (node.kind) { - case 92 /* ExportKeyword */: - case 87 /* DefaultKeyword */: + case 93 /* ExportKeyword */: + case 88 /* DefaultKeyword */: // ES6 export and default modifiers are elided when inside a namespace. return currentNamespace ? undefined : node; - case 122 /* PublicKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 125 /* AbstractKeyword */: - case 84 /* ConstKeyword */: - case 133 /* DeclareKeyword */: - case 142 /* ReadonlyKeyword */: + case 123 /* PublicKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + case 126 /* AbstractKeyword */: + case 85 /* ConstKeyword */: + case 134 /* DeclareKeyword */: + case 143 /* ReadonlyKeyword */: // TypeScript accessibility and readonly modifiers are elided // falls through - case 178 /* ArrayType */: - case 179 /* TupleType */: - case 180 /* OptionalType */: - case 181 /* RestType */: - case 177 /* TypeLiteral */: - case 172 /* TypePredicate */: - case 159 /* TypeParameter */: - case 128 /* AnyKeyword */: - case 152 /* UnknownKeyword */: - case 131 /* BooleanKeyword */: - case 147 /* StringKeyword */: - case 144 /* NumberKeyword */: - case 141 /* NeverKeyword */: - case 113 /* VoidKeyword */: - case 148 /* SymbolKeyword */: - case 175 /* ConstructorType */: - case 174 /* FunctionType */: - case 176 /* TypeQuery */: - case 173 /* TypeReference */: - case 182 /* UnionType */: - case 183 /* IntersectionType */: - case 184 /* ConditionalType */: - case 186 /* ParenthesizedType */: - case 187 /* ThisType */: - case 188 /* TypeOperator */: - case 189 /* IndexedAccessType */: - case 190 /* MappedType */: - case 191 /* LiteralType */: + case 180 /* ArrayType */: + case 181 /* TupleType */: + case 182 /* OptionalType */: + case 183 /* RestType */: + case 179 /* TypeLiteral */: + case 174 /* TypePredicate */: + case 161 /* TypeParameter */: + case 129 /* AnyKeyword */: + case 153 /* UnknownKeyword */: + case 132 /* BooleanKeyword */: + case 148 /* StringKeyword */: + case 145 /* NumberKeyword */: + case 142 /* NeverKeyword */: + case 114 /* VoidKeyword */: + case 149 /* SymbolKeyword */: + case 177 /* ConstructorType */: + case 176 /* FunctionType */: + case 178 /* TypeQuery */: + case 175 /* TypeReference */: + case 184 /* UnionType */: + case 185 /* IntersectionType */: + case 186 /* ConditionalType */: + case 188 /* ParenthesizedType */: + case 189 /* ThisType */: + case 190 /* TypeOperator */: + case 191 /* IndexedAccessType */: + case 192 /* MappedType */: + case 193 /* LiteralType */: // TypeScript type nodes are elided. // falls through - case 171 /* IndexSignature */: + case 173 /* IndexSignature */: // TypeScript index signatures are elided. // falls through - case 161 /* Decorator */: + case 163 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. // falls through - case 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return undefined; - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: // TypeScript property declarations are elided. However their names are still visited, and can potentially be retained if they could have sideeffects return visitPropertyDeclaration(node); - case 259 /* NamespaceExportDeclaration */: + case 261 /* NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; - case 166 /* Constructor */: + case 168 /* Constructor */: return visitConstructor(node); - case 253 /* InterfaceDeclaration */: + case 255 /* 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 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: // This may be a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -83521,7 +86629,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: // This may be a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -83531,35 +86639,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 286 /* HeritageClause */: + case 288 /* HeritageClause */: // This may be a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 167 /* GetAccessor */: + case 169 /* GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 168 /* SetAccessor */: + case 170 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 160 /* Parameter */: + case 162 /* Parameter */: // This may be a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -83569,40 +86677,40 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 206 /* TypeAssertionExpression */: - case 224 /* AsExpression */: + case 208 /* TypeAssertionExpression */: + case 226 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return visitCallExpression(node); - case 204 /* NewExpression */: + case 206 /* NewExpression */: return visitNewExpression(node); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 225 /* NonNullExpression */: + case 227 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); - case 274 /* JsxSelfClosingElement */: + case 276 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node); - case 275 /* JsxOpeningElement */: + case 277 /* JsxOpeningElement */: return visitJsxJsxOpeningElement(node); default: // node contains some other TypeScript syntax @@ -83639,7 +86747,7 @@ var ts; if (ts.some(staticProperties)) facts |= 1 /* HasStaticInitializedProperties */; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 103 /* NullKeyword */) + if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */) facts |= 64 /* IsDerivedClass */; if (shouldEmitDecorateCallForClass(node)) facts |= 2 /* HasConstructorDecorators */; @@ -83656,7 +86764,7 @@ var ts; return facts; } function hasTypeScriptClassSyntax(node) { - return !!(node.transformFlags & 2048 /* ContainsTypeScriptClassSyntax */); + return !!(node.transformFlags & 4096 /* ContainsTypeScriptClassSyntax */); } function isClassLikeDeclarationWithTypeScriptSyntax(node) { return ts.some(node.decorators) @@ -84011,12 +87119,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -84169,7 +87277,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ true); var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 163 /* PropertyDeclaration */ + ? member.kind === 165 /* 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() @@ -84293,10 +87401,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 165 /* MethodDeclaration */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */ - || kind === 163 /* PropertyDeclaration */; + return kind === 167 /* MethodDeclaration */ + || kind === 169 /* GetAccessor */ + || kind === 170 /* SetAccessor */ + || kind === 165 /* PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -84306,7 +87414,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 165 /* MethodDeclaration */; + return node.kind === 167 /* MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -84317,12 +87425,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return true; } return false; @@ -84339,15 +87447,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 163 /* PropertyDeclaration */: - case 160 /* Parameter */: + case 165 /* PropertyDeclaration */: + case 162 /* Parameter */: return serializeTypeNode(node.type); - case 168 /* SetAccessor */: - case 167 /* GetAccessor */: + case 170 /* SetAccessor */: + case 169 /* GetAccessor */: return serializeTypeNode(getAccessorTypeNode(node)); - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 165 /* MethodDeclaration */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 167 /* MethodDeclaration */: return factory.createIdentifier("Function"); default: return factory.createVoidZero(); @@ -84384,7 +87492,7 @@ var ts; return factory.createArrayLiteralExpression(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 167 /* GetAccessor */) { + if (container && node.kind === 169 /* GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -84429,82 +87537,82 @@ var ts; return factory.createIdentifier("Object"); } switch (node.kind) { - case 113 /* VoidKeyword */: - case 150 /* UndefinedKeyword */: - case 141 /* NeverKeyword */: + case 114 /* VoidKeyword */: + case 151 /* UndefinedKeyword */: + case 142 /* NeverKeyword */: return factory.createVoidZero(); - case 186 /* ParenthesizedType */: + case 188 /* ParenthesizedType */: return serializeTypeNode(node.type); - case 174 /* FunctionType */: - case 175 /* ConstructorType */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: return factory.createIdentifier("Function"); - case 178 /* ArrayType */: - case 179 /* TupleType */: + case 180 /* ArrayType */: + case 181 /* TupleType */: return factory.createIdentifier("Array"); - case 172 /* TypePredicate */: - case 131 /* BooleanKeyword */: + case 174 /* TypePredicate */: + case 132 /* BooleanKeyword */: return factory.createIdentifier("Boolean"); - case 147 /* StringKeyword */: + case 148 /* StringKeyword */: return factory.createIdentifier("String"); - case 145 /* ObjectKeyword */: + case 146 /* ObjectKeyword */: return factory.createIdentifier("Object"); - case 191 /* LiteralType */: + case 193 /* LiteralType */: switch (node.literal.kind) { case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return factory.createIdentifier("String"); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: case 8 /* NumericLiteral */: return factory.createIdentifier("Number"); case 9 /* BigIntLiteral */: return getGlobalBigIntNameWithFallback(); - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: return factory.createIdentifier("Boolean"); - case 103 /* NullKeyword */: + case 104 /* NullKeyword */: return factory.createVoidZero(); default: return ts.Debug.failBadSyntaxKind(node.literal); } - case 144 /* NumberKeyword */: + case 145 /* NumberKeyword */: return factory.createIdentifier("Number"); - case 155 /* BigIntKeyword */: + case 156 /* BigIntKeyword */: return getGlobalBigIntNameWithFallback(); - case 148 /* SymbolKeyword */: + case 149 /* SymbolKeyword */: return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : factory.createIdentifier("Symbol"); - case 173 /* TypeReference */: + case 175 /* TypeReference */: return serializeTypeReferenceNode(node); - case 183 /* IntersectionType */: - case 182 /* UnionType */: + case 185 /* IntersectionType */: + case 184 /* UnionType */: return serializeTypeList(node.types); - case 184 /* ConditionalType */: + case 186 /* ConditionalType */: return serializeTypeList([node.trueType, node.falseType]); - case 188 /* TypeOperator */: - if (node.operator === 142 /* ReadonlyKeyword */) { + case 190 /* TypeOperator */: + if (node.operator === 143 /* ReadonlyKeyword */) { return serializeTypeNode(node.type); } break; - case 176 /* TypeQuery */: - case 189 /* IndexedAccessType */: - case 190 /* MappedType */: - case 177 /* TypeLiteral */: - case 128 /* AnyKeyword */: - case 152 /* UnknownKeyword */: - case 187 /* ThisType */: - case 195 /* ImportType */: + case 178 /* TypeQuery */: + case 191 /* IndexedAccessType */: + case 192 /* MappedType */: + case 179 /* TypeLiteral */: + case 129 /* AnyKeyword */: + case 153 /* UnknownKeyword */: + case 189 /* ThisType */: + case 197 /* ImportType */: break; // handle JSDoc types from an invalid parse - case 303 /* JSDocAllType */: - case 304 /* JSDocUnknownType */: - case 308 /* JSDocFunctionType */: - case 309 /* JSDocVariadicType */: - case 310 /* JSDocNamepathType */: + case 306 /* JSDocAllType */: + case 307 /* JSDocUnknownType */: + case 311 /* JSDocFunctionType */: + case 312 /* JSDocVariadicType */: + case 313 /* JSDocNamepathType */: break; - case 305 /* JSDocNullableType */: - case 306 /* JSDocNonNullableType */: - case 307 /* JSDocOptionalType */: + case 308 /* JSDocNullableType */: + case 309 /* JSDocNonNullableType */: + case 310 /* JSDocOptionalType */: return serializeTypeNode(node.type); default: return ts.Debug.failBadSyntaxKind(node); @@ -84517,13 +87625,13 @@ var ts; var serializedUnion; for (var _i = 0, types_24 = types; _i < types_24.length; _i++) { var typeNode = types_24[_i]; - while (typeNode.kind === 186 /* ParenthesizedType */) { + while (typeNode.kind === 188 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 141 /* NeverKeyword */) { + if (typeNode.kind === 142 /* NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 191 /* LiteralType */ && typeNode.literal.kind === 103 /* NullKeyword */ || typeNode.kind === 150 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 193 /* LiteralType */ && typeNode.literal.kind === 104 /* NullKeyword */ || typeNode.kind === 151 /* UndefinedKeyword */)) { continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks } var serializedIndividual = serializeTypeNode(typeNode); @@ -84605,12 +87713,12 @@ var ts; * @param node The entity name to serialize. */ function serializeEntityNameAsExpressionFallback(node) { - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { // A -> typeof A !== undefined && A var copied = serializeEntityNameAsExpression(node); return createCheckedValue(copied, copied); } - if (node.left.kind === 78 /* Identifier */) { + if (node.left.kind === 79 /* Identifier */) { // A.B -> typeof A !== undefined && A.B return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node)); } @@ -84626,14 +87734,14 @@ var ts; */ function serializeEntityNameAsExpression(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* 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 157 /* QualifiedName */: + case 159 /* QualifiedName */: return serializeQualifiedNameAsExpression(node); } } @@ -84724,7 +87832,7 @@ var ts; * @param node The HeritageClause to transform. */ function visitHeritageClause(node) { - if (node.token === 116 /* ImplementsKeyword */) { + if (node.token === 117 /* ImplementsKeyword */) { // implements clauses are elided return undefined; } @@ -85021,8 +88129,7 @@ var ts; */ function shouldEmitEnumDeclaration(node) { return !ts.isEnumConst(node) - || compilerOptions.preserveConstEnums - || compilerOptions.isolatedModules; + || ts.shouldPreserveConstEnums(compilerOptions); } /** * Visits an enum declaration. @@ -85156,7 +88263,7 @@ var ts; // If we can't find a parse tree node, assume the node is instantiated. return true; } - return ts.isInstantiatedModule(node, !!compilerOptions.preserveConstEnums || !!compilerOptions.isolatedModules); + return ts.isInstantiatedModule(node, ts.shouldPreserveConstEnums(compilerOptions)); } /** * Determines whether an exported declaration will have a qualified export name (e.g. `f.x` @@ -85207,12 +88314,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 === 297 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 299 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { // Adjust the source map emit to match the old emitter. - if (node.kind === 255 /* EnumDeclaration */) { + if (node.kind === 257 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -85337,7 +88444,7 @@ var ts; var statementsLocation; var blockLocation; if (node.body) { - if (node.body.kind === 257 /* ModuleBlock */) { + if (node.body.kind === 259 /* ModuleBlock */) { saveStateAndInvoke(node.body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = node.body.statements; blockLocation = node.body; @@ -85384,13 +88491,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 !== 257 /* ModuleBlock */) { + if (!node.body || node.body.kind !== 259 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 256 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 258 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -85440,7 +88547,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 263 /* NamespaceImport */) { + if (node.kind === 265 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -85674,7 +88781,7 @@ var ts; function enableSubstitutionForNonQualifiedEnumMembers() { if ((enabledSubstitutions & 8 /* NonQualifiedEnumMembers */) === 0) { enabledSubstitutions |= 8 /* NonQualifiedEnumMembers */; - context.enableSubstitution(78 /* Identifier */); + context.enableSubstitution(79 /* Identifier */); } } function enableSubstitutionForClassAliases() { @@ -85682,7 +88789,7 @@ var ts; enabledSubstitutions |= 1 /* ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(78 /* Identifier */); + context.enableSubstitution(79 /* Identifier */); // Keep track of class aliases. classAliases = []; } @@ -85692,17 +88799,17 @@ var ts; enabledSubstitutions |= 2 /* 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(78 /* Identifier */); - context.enableSubstitution(289 /* ShorthandPropertyAssignment */); + context.enableSubstitution(79 /* Identifier */); + context.enableSubstitution(291 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(256 /* ModuleDeclaration */); + context.enableEmitNotification(258 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 256 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 258 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 255 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 257 /* EnumDeclaration */; } /** * Hook for node emit. @@ -85761,11 +88868,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return substituteExpressionIdentifier(node); - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -85787,10 +88894,10 @@ var ts; if (declaration) { var classAlias = classAliases[declaration.id]; // TODO: GH#18217 if (classAlias) { - var clone_1 = factory.cloneNode(classAlias); - ts.setSourceMapRange(clone_1, node); - ts.setCommentRange(clone_1, node); - return clone_1; + var clone_2 = factory.cloneNode(classAlias); + ts.setSourceMapRange(clone_2, node); + ts.setCommentRange(clone_2, node); + return clone_2; } } } @@ -85803,9 +88910,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 !== 297 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 256 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 255 /* EnumDeclaration */); + if (container && container.kind !== 299 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 258 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 257 /* EnumDeclaration */); if (substitute) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(container), node), /*location*/ node); @@ -85857,10 +88964,12 @@ var ts; */ ClassPropertySubstitutionFlags[ClassPropertySubstitutionFlags["ClassAliases"] = 1] = "ClassAliases"; })(ClassPropertySubstitutionFlags || (ClassPropertySubstitutionFlags = {})); - var PrivateIdentifierPlacement; - (function (PrivateIdentifierPlacement) { - PrivateIdentifierPlacement[PrivateIdentifierPlacement["InstanceField"] = 0] = "InstanceField"; - })(PrivateIdentifierPlacement || (PrivateIdentifierPlacement = {})); + var PrivateIdentifierKind; + (function (PrivateIdentifierKind) { + PrivateIdentifierKind["Field"] = "f"; + PrivateIdentifierKind["Method"] = "m"; + PrivateIdentifierKind["Accessor"] = "a"; + })(PrivateIdentifierKind = ts.PrivateIdentifierKind || (ts.PrivateIdentifierKind = {})); /** * Transforms ECMAScript Class Syntax. * TypeScript parameter property syntax is transformed in the TypeScript transformer. @@ -85869,11 +88978,12 @@ var ts; * When --useDefineForClassFields is on, this transforms to ECMAScript semantics, with Object.defineProperty. */ function transformClassFields(context) { - var factory = context.factory, hoistVariableDeclaration = context.hoistVariableDeclaration, endLexicalEnvironment = context.endLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment; + var factory = context.factory, hoistVariableDeclaration = context.hoistVariableDeclaration, endLexicalEnvironment = context.endLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, addBlockScopedVariable = context.addBlockScopedVariable; var resolver = context.getEmitResolver(); var compilerOptions = context.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); - var shouldTransformPrivateFields = languageVersion < 99 /* ESNext */; + var useDefineForClassFields = ts.getUseDefineForClassFields(compilerOptions); + var shouldTransformPrivateElements = languageVersion < 99 /* ESNext */; var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; var enabledSubstitutions; @@ -85894,7 +89004,7 @@ var ts; function transformSourceFile(node) { var options = context.getCompilerOptions(); if (node.isDeclarationFile - || options.useDefineForClassFields && options.target === 99 /* ESNext */) { + || useDefineForClassFields && options.target === 99 /* ESNext */) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -85902,41 +89012,41 @@ var ts; return visited; } function visitor(node) { - if (!(node.transformFlags & 4194304 /* ContainsClassFields */)) + if (!(node.transformFlags & 8388608 /* ContainsClassFields */)) return node; switch (node.kind) { - case 221 /* ClassExpression */: - case 252 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 254 /* ClassDeclaration */: return visitClassLike(node); - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return visitPropertyDeclaration(node); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return visitVariableStatement(node); - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return visitPropertyAccessExpression(node); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return visitPrefixUnaryExpression(node); - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: return visitPostfixUnaryExpression(node, /*valueIsDiscarded*/ false); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return visitCallExpression(node); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return visitBinaryExpression(node); - case 79 /* PrivateIdentifier */: + case 80 /* PrivateIdentifier */: return visitPrivateIdentifier(node); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: return visitExpressionStatement(node); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return visitForStatement(node); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); } return ts.visitEachChild(node, visitor, context); } function visitorDestructuringTarget(node) { switch (node.kind) { - case 200 /* ObjectLiteralExpression */: - case 199 /* ArrayLiteralExpression */: + case 202 /* ObjectLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return visitAssignmentPattern(node); default: return visitor(node); @@ -85947,7 +89057,7 @@ var ts; * Replace it with an empty identifier to indicate a problem with the code. */ function visitPrivateIdentifier(node) { - if (!shouldTransformPrivateFields) { + if (!shouldTransformPrivateElements) { return node; } return ts.setOriginalNode(factory.createIdentifier(""), node); @@ -85959,20 +89069,19 @@ var ts; */ function classElementVisitor(node) { switch (node.kind) { - case 166 /* Constructor */: + case 168 /* Constructor */: // Constructors for classes using class fields are transformed in // `visitClassDeclaration` or `visitClassExpression`. return undefined; - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 165 /* MethodDeclaration */: - // Visit the name of the member (if it's a computed property name). - return ts.visitEachChild(node, classElementVisitor, context); - case 163 /* PropertyDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 167 /* MethodDeclaration */: + return visitMethodOrAccessorDeclaration(node); + case 165 /* PropertyDeclaration */: return visitPropertyDeclaration(node); - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 229 /* SemicolonClassElement */: + case 231 /* SemicolonClassElement */: return node; default: return visitor(node); @@ -85997,44 +89106,96 @@ var ts; } return node; } + function visitMethodOrAccessorDeclaration(node) { + ts.Debug.assert(!ts.some(node.decorators)); + if (!shouldTransformPrivateElements || !ts.isPrivateIdentifier(node.name)) { + return ts.visitEachChild(node, classElementVisitor, context); + } + // leave invalid code untransformed + var info = accessPrivateIdentifier(node.name); + ts.Debug.assert(info, "Undeclared private name for property declaration."); + if (!info.isValid) { + return node; + } + var functionName = getHoistedFunctionName(node); + if (functionName) { + getPendingExpressions().push(factory.createAssignment(functionName, factory.createFunctionExpression(ts.filter(node.modifiers, function (m) { return !ts.isStaticModifier(m); }), node.asteriskToken, functionName, + /* typeParameters */ undefined, ts.visitParameterList(node.parameters, classElementVisitor, context), + /* type */ undefined, ts.visitFunctionBody(node.body, classElementVisitor, context)))); + } + // remove method declaration from class + return undefined; + } + function getHoistedFunctionName(node) { + 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 */) { + return info.methodName; + } + if (info.kind === "a" /* Accessor */) { + if (ts.isGetAccessor(node)) { + return info.getterName; + } + if (ts.isSetAccessor(node)) { + return info.setterName; + } + } + } function visitPropertyDeclaration(node) { ts.Debug.assert(!ts.some(node.decorators)); - if (!shouldTransformPrivateFields && ts.isPrivateIdentifier(node.name)) { - // Initializer is elided as the field is initialized in transformConstructor. - return factory.updatePropertyDeclaration(node, - /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name, - /*questionOrExclamationToken*/ undefined, - /*type*/ undefined, - /*initializer*/ undefined); + if (ts.isPrivateIdentifier(node.name)) { + if (!shouldTransformPrivateElements) { + // Initializer is elided as the field is initialized in transformConstructor. + return factory.updatePropertyDeclaration(node, + /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name, + /*questionOrExclamationToken*/ undefined, + /*type*/ undefined, + /*initializer*/ undefined); + } + // leave invalid code untransformed + var info = accessPrivateIdentifier(node.name); + ts.Debug.assert(info, "Undeclared private name for property declaration."); + if (!info.isValid) { + return node; + } } // Create a temporary variable to store a computed property name (if necessary). // If it's not inlineable, then we emit an expression after the class which assigns // the property name to the temporary variable. - var expr = getPropertyNameExpressionIfNeeded(node.name, !!node.initializer || !!context.getCompilerOptions().useDefineForClassFields); + var expr = getPropertyNameExpressionIfNeeded(node.name, !!node.initializer || useDefineForClassFields); if (expr && !ts.isSimpleInlineableExpression(expr)) { getPendingExpressions().push(expr); } return undefined; } function createPrivateIdentifierAccess(info, receiver) { - receiver = ts.visitNode(receiver, visitor, ts.isExpression); - switch (info.placement) { - case 0 /* InstanceField */: - return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(ts.nodeIsSynthesized(receiver) ? receiver : factory.cloneNode(receiver), info.weakMapName); - default: return ts.Debug.fail("Unexpected private identifier placement"); + return createPrivateIdentifierAccessHelper(info, ts.visitNode(receiver, visitor, ts.isExpression)); + } + function createPrivateIdentifierAccessHelper(info, receiver) { + ts.setCommentRange(receiver, ts.moveRangePos(receiver, -1)); + switch (info.kind) { + case "a" /* Accessor */: + return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.getterName); + case "m" /* Method */: + return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.methodName); + case "f" /* Field */: + return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.variableName); + default: + ts.Debug.assertNever(info, "Unknown private element type"); } } function visitPropertyAccessExpression(node) { - if (shouldTransformPrivateFields && ts.isPrivateIdentifier(node.name)) { + if (shouldTransformPrivateElements && ts.isPrivateIdentifier(node.name)) { var privateIdentifierInfo = accessPrivateIdentifier(node.name); if (privateIdentifierInfo) { - return ts.setOriginalNode(createPrivateIdentifierAccess(privateIdentifierInfo, node.expression), node); + return ts.setTextRange(ts.setOriginalNode(createPrivateIdentifierAccess(privateIdentifierInfo, node.expression), node), node); } } return ts.visitEachChild(node, visitor, context); } function visitPrefixUnaryExpression(node) { - if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { + if (shouldTransformPrivateElements && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { var operator = node.operator === 45 /* PlusPlusToken */ ? 39 /* PlusToken */ : node.operator === 46 /* MinusMinusToken */ ? 40 /* MinusToken */ : undefined; @@ -86043,13 +89204,13 @@ var ts; var receiver = ts.visitNode(node.operand.expression, visitor, ts.isExpression); var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression; var existingValue = factory.createPrefixUnaryExpression(39 /* PlusToken */, createPrivateIdentifierAccess(info, readExpression)); - return ts.setOriginalNode(createPrivateIdentifierAssignment(info, initializeExpression || readExpression, factory.createBinaryExpression(existingValue, operator, factory.createNumericLiteral(1)), 62 /* EqualsToken */), node); + return ts.setOriginalNode(createPrivateIdentifierAssignment(info, initializeExpression || readExpression, factory.createBinaryExpression(existingValue, operator, factory.createNumericLiteral(1)), 63 /* EqualsToken */), node); } } return ts.visitEachChild(node, visitor, context); } function visitPostfixUnaryExpression(node, valueIsDiscarded) { - if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { + if (shouldTransformPrivateElements && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { var operator = node.operator === 45 /* PlusPlusToken */ ? 39 /* PlusToken */ : node.operator === 46 /* MinusMinusToken */ ? 40 /* MinusToken */ : undefined; @@ -86061,7 +89222,7 @@ var ts; // Create a temporary variable to store the value returned by the expression. var returnValue = valueIsDiscarded ? undefined : factory.createTempVariable(hoistVariableDeclaration); return ts.setOriginalNode(factory.inlineExpressions(ts.compact([ - createPrivateIdentifierAssignment(info, initializeExpression || readExpression, factory.createBinaryExpression(returnValue ? factory.createAssignment(returnValue, existingValue) : existingValue, operator, factory.createNumericLiteral(1)), 62 /* EqualsToken */), + createPrivateIdentifierAssignment(info, initializeExpression || readExpression, factory.createBinaryExpression(returnValue ? factory.createAssignment(returnValue, existingValue) : existingValue, operator, factory.createNumericLiteral(1)), 63 /* EqualsToken */), returnValue ])), node); } @@ -86070,7 +89231,7 @@ var ts; } function visitForStatement(node) { if (node.incrementor && ts.isPostfixUnaryExpression(node.incrementor)) { - return factory.updateForStatement(node, ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), visitPostfixUnaryExpression(node.incrementor, /*valueIsDiscarded*/ true), ts.visitNode(node.statement, visitor, ts.isStatement)); + return factory.updateForStatement(node, ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), visitPostfixUnaryExpression(node.incrementor, /*valueIsDiscarded*/ true), ts.visitIterationBody(node.statement, visitor, context)); } return ts.visitEachChild(node, visitor, context); } @@ -86090,16 +89251,21 @@ var ts; return { readExpression: readExpression, initializeExpression: initializeExpression }; } function visitCallExpression(node) { - if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.expression)) { + if (shouldTransformPrivateElements && ts.isPrivateIdentifierPropertyAccessExpression(node.expression)) { // Transform call expressions of private names to properly bind the `this` parameter. var _a = factory.createCallBinding(node.expression, hoistVariableDeclaration, languageVersion), thisArg = _a.thisArg, target = _a.target; + if (ts.isCallChain(node)) { + return factory.updateCallChain(node, factory.createPropertyAccessChain(ts.visitNode(target, visitor), node.questionDotToken, "call"), + /*questionDotToken*/ undefined, + /*typeArguments*/ undefined, __spreadArray([ts.visitNode(thisArg, visitor, ts.isExpression)], ts.visitNodes(node.arguments, visitor, ts.isExpression))); + } return factory.updateCallExpression(node, factory.createPropertyAccessExpression(ts.visitNode(target, visitor), "call"), /*typeArguments*/ undefined, __spreadArray([ts.visitNode(thisArg, visitor, ts.isExpression)], ts.visitNodes(node.arguments, visitor, ts.isExpression))); } return ts.visitEachChild(node, visitor, context); } function visitTaggedTemplateExpression(node) { - if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.tag)) { + if (shouldTransformPrivateElements && ts.isPrivateIdentifierPropertyAccessExpression(node.tag)) { // Bind the `this` correctly for tagged template literals when the tag is a private identifier property access. var _a = factory.createCallBinding(node.tag, hoistVariableDeclaration, languageVersion), thisArg = _a.thisArg, target = _a.target; return factory.updateTaggedTemplateExpression(node, factory.createCallExpression(factory.createPropertyAccessExpression(ts.visitNode(target, visitor), "bind"), @@ -86109,7 +89275,7 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitBinaryExpression(node) { - if (shouldTransformPrivateFields) { + if (shouldTransformPrivateElements) { if (ts.isDestructuringAssignment(node)) { var savedPendingExpressions = pendingExpressions; pendingExpressions = undefined; @@ -86123,29 +89289,31 @@ var ts; if (ts.isAssignmentExpression(node) && ts.isPrivateIdentifierPropertyAccessExpression(node.left)) { var info = accessPrivateIdentifier(node.left.name); if (info) { - return ts.setOriginalNode(createPrivateIdentifierAssignment(info, node.left.expression, node.right, node.operatorToken.kind), node); + return ts.setTextRange(ts.setOriginalNode(createPrivateIdentifierAssignment(info, node.left.expression, node.right, node.operatorToken.kind), node), node); } } } return ts.visitEachChild(node, visitor, context); } function createPrivateIdentifierAssignment(info, receiver, right, operator) { - switch (info.placement) { - case 0 /* InstanceField */: { - return createPrivateIdentifierInstanceFieldAssignment(info, receiver, right, operator); - } - default: return ts.Debug.fail("Unexpected private identifier placement"); - } - } - function createPrivateIdentifierInstanceFieldAssignment(info, receiver, right, operator) { receiver = ts.visitNode(receiver, visitor, ts.isExpression); right = ts.visitNode(right, visitor, ts.isExpression); if (ts.isCompoundAssignment(operator)) { var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression; - return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(initializeExpression || readExpression, info.weakMapName, factory.createBinaryExpression(context.getEmitHelperFactory().createClassPrivateFieldGetHelper(readExpression, info.weakMapName), ts.getNonAssignmentOperatorForCompoundAssignment(operator), right)); - } - else { - return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.weakMapName, right); + receiver = initializeExpression || readExpression; + right = factory.createBinaryExpression(createPrivateIdentifierAccessHelper(info, readExpression), ts.getNonAssignmentOperatorForCompoundAssignment(operator), right); + } + ts.setCommentRange(receiver, ts.moveRangePos(receiver, -1)); + switch (info.kind) { + case "a" /* Accessor */: + return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, info.setterName); + case "m" /* Method */: + return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, + /* f */ undefined); + case "f" /* Field */: + return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, info.variableName); + default: + ts.Debug.assertNever(info, "Unknown private element type"); } } /** @@ -86154,32 +89322,53 @@ var ts; function visitClassLike(node) { var savedPendingExpressions = pendingExpressions; pendingExpressions = undefined; - if (shouldTransformPrivateFields) { + if (shouldTransformPrivateElements) { startPrivateIdentifierEnvironment(); + var name = ts.getNameOfDeclaration(node); + if (name && ts.isIdentifier(name)) { + getPrivateIdentifierEnvironment().className = ts.idText(name); + } + var privateInstanceMethodsAndAccessors = getPrivateInstanceMethodsAndAccessors(node); + if (ts.some(privateInstanceMethodsAndAccessors)) { + getPrivateIdentifierEnvironment().weakSetName = createHoistedVariableForClass("instances", privateInstanceMethodsAndAccessors[0].name); + } } var result = ts.isClassDeclaration(node) ? visitClassDeclaration(node) : visitClassExpression(node); - if (shouldTransformPrivateFields) { + if (shouldTransformPrivateElements) { endPrivateIdentifierEnvironment(); } pendingExpressions = savedPendingExpressions; return result; } function doesClassElementNeedTransform(node) { - return ts.isPropertyDeclaration(node) || (shouldTransformPrivateFields && node.name && ts.isPrivateIdentifier(node.name)); + return ts.isPropertyDeclaration(node) || (shouldTransformPrivateElements && node.name && ts.isPrivateIdentifier(node.name)); + } + function getPrivateInstanceMethodsAndAccessors(node) { + return ts.filter(node.members, ts.isNonStaticMethodOrAccessorWithPrivateName); } function visitClassDeclaration(node) { if (!ts.forEach(node.members, doesClassElementNeedTransform)) { return ts.visitEachChild(node, visitor, context); } + var staticProperties = ts.getProperties(node, /*requireInitializer*/ false, /*isStatic*/ true); + var pendingPrivateStateAssignment; + if (shouldTransformPrivateElements && ts.some(node.members, function (m) { return ts.hasStaticModifier(m) && !!m.name && ts.isPrivateIdentifier(m.name); })) { + var temp = factory.createTempVariable(hoistVariableDeclaration, /* reservedInNestedScopes */ true); + getPrivateIdentifierEnvironment().classConstructor = factory.cloneNode(temp); + pendingPrivateStateAssignment = factory.createAssignment(temp, factory.getInternalName(node)); + } var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 103 /* NullKeyword */); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */); var statements = [ factory.updateClassDeclaration(node, /*decorators*/ undefined, node.modifiers, node.name, /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass)) ]; + if (pendingPrivateStateAssignment) { + getPendingExpressions().unshift(pendingPrivateStateAssignment); + } // Write any pending expressions from elided or moved computed property names if (ts.some(pendingExpressions)) { statements.push(factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))); @@ -86189,7 +89378,6 @@ var ts; // From ES6 specification: // HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using // a lexical declaration such as a LexicalDeclaration or a ClassDeclaration. - var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); if (ts.some(staticProperties)) { addPropertyStatements(statements, staticProperties, factory.getInternalName(node)); } @@ -86207,12 +89395,25 @@ var ts; // class declaration transformation. The VariableStatement visitor will insert // these statements after the class expression variable statement. var isDecoratedClassDeclaration = ts.isClassDeclaration(ts.getOriginalNode(node)); - var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); + var staticProperties = ts.getProperties(node, /*requireInitializer*/ false, /*isStatic*/ true); var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 103 /* NullKeyword */); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */); + var isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */; + var temp; + function createClassTempVar() { + var classCheckFlags = resolver.getNodeCheckFlags(node); + var isClassWithConstructorReference = classCheckFlags & 16777216 /* ClassWithConstructorReference */; + var requiresBlockScopedVar = classCheckFlags & 524288 /* BlockScopedBindingInLoop */; + return factory.createTempVariable(requiresBlockScopedVar ? addBlockScopedVariable : hoistVariableDeclaration, !!isClassWithConstructorReference); + } + if (shouldTransformPrivateElements && ts.some(node.members, function (m) { return ts.hasStaticModifier(m) && !!m.name && ts.isPrivateIdentifier(m.name); })) { + temp = createClassTempVar(); + getPrivateIdentifierEnvironment().classConstructor = factory.cloneNode(temp); + } var classExpression = factory.updateClassExpression(node, ts.visitNodes(node.decorators, visitor, ts.isDecorator), node.modifiers, node.name, /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass)); - if (ts.some(staticProperties) || ts.some(pendingExpressions)) { + var hasTransformableStatics = ts.some(staticProperties, function (p) { return !!p.initializer || (shouldTransformPrivateElements && ts.isPrivateIdentifier(p.name)); }); + if (hasTransformableStatics || ts.some(pendingExpressions)) { if (isDecoratedClassDeclaration) { ts.Debug.assertIsDefined(pendingStatements, "Decorated classes transformed by TypeScript are expected to be within a variable declaration."); // Write any pending expressions from elided or moved computed property names @@ -86222,12 +89423,14 @@ var ts; if (pendingStatements && ts.some(staticProperties)) { addPropertyStatements(pendingStatements, staticProperties, factory.getInternalName(node)); } + if (temp) { + return factory.inlineExpressions([factory.createAssignment(temp, classExpression), temp]); + } return classExpression; } else { var expressions = []; - var isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */; - var temp = factory.createTempVariable(hoistVariableDeclaration, !!isClassWithConstructorReference); + temp || (temp = createClassTempVar()); if (isClassWithConstructorReference) { // record an alias as the class name is not in scope for statics. enableSubstitutionForClassAliases(); @@ -86249,14 +89452,17 @@ var ts; return classExpression; } function transformClassMembers(node, isDerivedClass) { - if (shouldTransformPrivateFields) { + if (shouldTransformPrivateElements) { // Declare private names. for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (ts.isPrivateIdentifierPropertyDeclaration(member)) { - addPrivateIdentifierToEnvironment(member.name); + if (ts.isPrivateIdentifierClassElementDeclaration(member)) { + addPrivateIdentifierToEnvironment(member); } } + if (ts.some(getPrivateInstanceMethodsAndAccessors(node))) { + createBrandCheckWeakSetForPrivateMethods(); + } } var members = []; var constructor = transformConstructor(node, isDerivedClass); @@ -86266,21 +89472,27 @@ var ts; ts.addRange(members, ts.visitNodes(node.members, classElementVisitor, ts.isClassElement)); return ts.setTextRange(factory.createNodeArray(members), /*location*/ node.members); } - function isPropertyDeclarationThatRequiresConstructorStatement(member) { - if (!ts.isPropertyDeclaration(member) || ts.hasStaticModifier(member) || ts.hasSyntacticModifier(ts.getOriginalNode(member), 128 /* Abstract */)) { + function createBrandCheckWeakSetForPrivateMethods() { + var weakSetName = getPrivateIdentifierEnvironment().weakSetName; + ts.Debug.assert(weakSetName, "weakSetName should be set in private identifier environment"); + getPendingExpressions().push(factory.createAssignment(weakSetName, factory.createNewExpression(factory.createIdentifier("WeakSet"), + /*typeArguments*/ undefined, []))); + } + function isClassElementThatRequiresConstructorStatement(member) { + if (ts.hasStaticModifier(member) || ts.hasSyntacticModifier(ts.getOriginalNode(member), 128 /* Abstract */)) { return false; } - if (context.getCompilerOptions().useDefineForClassFields) { + 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 < 99 /* ESNext */; } - return ts.isInitializedProperty(member) || shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyDeclaration(member); + return ts.isInitializedProperty(member) || shouldTransformPrivateElements && ts.isPrivateIdentifierClassElementDeclaration(member); } function transformConstructor(node, isDerivedClass) { var constructor = ts.visitNode(ts.getFirstConstructorWithBody(node), visitor, ts.isConstructorDeclaration); - var properties = node.members.filter(isPropertyDeclarationThatRequiresConstructorStatement); - if (!ts.some(properties)) { + var elements = node.members.filter(isClassElementThatRequiresConstructorStatement); + if (!ts.some(elements)) { return constructor; } var parameters = ts.visitParameterList(constructor ? constructor.parameters : undefined, visitor, context); @@ -86293,13 +89505,14 @@ var ts; /*modifiers*/ undefined, parameters !== null && parameters !== void 0 ? parameters : [], body), constructor || node), constructor)); } function transformConstructorBody(node, constructor, isDerivedClass) { - var useDefineForClassFields = context.getCompilerOptions().useDefineForClassFields; var properties = ts.getProperties(node, /*requireInitializer*/ false, /*isStatic*/ false); if (!useDefineForClassFields) { properties = ts.filter(properties, function (property) { return !!property.initializer || ts.isPrivateIdentifier(property.name); }); } + var privateMethodsAndAccessors = getPrivateInstanceMethodsAndAccessors(node); + var needsConstructorBody = ts.some(properties) || ts.some(privateMethodsAndAccessors); // Only generate synthetic constructor when there are property initializers to move. - if (!constructor && !ts.some(properties)) { + if (!constructor && !needsConstructorBody) { return ts.visitFunctionBody(/*node*/ undefined, visitor, context); } resumeLexicalEnvironment(); @@ -86338,7 +89551,10 @@ var ts; indexOfFirstStatement = afterParameterProperties; } } - addPropertyStatements(statements, properties, factory.createThis()); + var receiver = factory.createThis(); + // private methods can be called in property initializers, they should execute first. + addMethodStatements(statements, privateMethodsAndAccessors, receiver); + addPropertyStatements(statements, properties, receiver); // Add existing statements, skipping the initial super call. if (constructor) { ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement)); @@ -86400,27 +89616,30 @@ var ts; function transformProperty(property, receiver) { var _a; // We generate a name here in order to reuse the value cached by the relocated computed name expression (which uses the same generated name) - var emitAssignment = !context.getCompilerOptions().useDefineForClassFields; + var emitAssignment = !useDefineForClassFields; var propertyName = ts.isComputedPropertyName(property.name) && !ts.isSimpleInlineableExpression(property.name.expression) ? factory.updateComputedPropertyName(property.name, factory.getGeneratedNameForNode(property.name)) : property.name; - if (shouldTransformPrivateFields && ts.isPrivateIdentifier(propertyName)) { + if (shouldTransformPrivateElements && ts.isPrivateIdentifier(propertyName)) { var privateIdentifierInfo = accessPrivateIdentifier(propertyName); if (privateIdentifierInfo) { - switch (privateIdentifierInfo.placement) { - case 0 /* InstanceField */: { - return createPrivateInstanceFieldInitializer(receiver, ts.visitNode(property.initializer, visitor, ts.isExpression), privateIdentifierInfo.weakMapName); + if (privateIdentifierInfo.kind === "f" /* Field */) { + if (!privateIdentifierInfo.isStatic) { + return createPrivateInstanceFieldInitializer(receiver, ts.visitNode(property.initializer, visitor, ts.isExpression), privateIdentifierInfo.brandCheckIdentifier); + } + else { + return createPrivateStaticFieldInitializer(privateIdentifierInfo.variableName, ts.visitNode(property.initializer, visitor, ts.isExpression)); } } + else { + return undefined; + } } else { ts.Debug.fail("Undeclared private name for property declaration."); } } - if (ts.isPrivateIdentifier(propertyName) && !property.initializer) { - return undefined; - } - if (ts.isPrivateIdentifier(propertyName) && !property.initializer) { + if ((ts.isPrivateIdentifier(propertyName) || ts.hasStaticModifier(property)) && !property.initializer) { return undefined; } var propertyOriginalNode = ts.getOriginalNode(property); @@ -86447,11 +89666,26 @@ var ts; enabledSubstitutions |= 1 /* ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(78 /* Identifier */); + context.enableSubstitution(79 /* Identifier */); // Keep track of class aliases. classAliases = []; } } + /** + * Generates brand-check initializer for private methods. + * + * @param statements Statement list that should be used to append new statements. + * @param methods An array of method declarations. + * @param receiver The receiver on which each method should be assigned. + */ + function addMethodStatements(statements, methods, receiver) { + if (!shouldTransformPrivateElements || !ts.some(methods)) { + return; + } + var weakSetName = getPrivateIdentifierEnvironment().weakSetName; + ts.Debug.assert(weakSetName, "weakSetName should be set in private identifier environment"); + statements.push(factory.createExpressionStatement(createPrivateInstanceMethodInitializer(receiver, weakSetName))); + } /** * Hooks node substitutions. * @@ -86467,7 +89701,7 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return substituteExpressionIdentifier(node); } return node; @@ -86487,10 +89721,10 @@ var ts; if (declaration) { var classAlias = classAliases[declaration.id]; // TODO: GH#18217 if (classAlias) { - var clone_2 = factory.cloneNode(classAlias); - ts.setSourceMapRange(clone_2, node); - ts.setCommentRange(clone_2, node); - return clone_2; + var clone_3 = factory.cloneNode(classAlias); + ts.setSourceMapRange(clone_3, node); + ts.setCommentRange(clone_3, node); + return clone_3; } } } @@ -86510,7 +89744,12 @@ var ts; var alreadyTransformed = ts.isAssignmentExpression(innerExpression) && ts.isGeneratedIdentifier(innerExpression.left); if (!alreadyTransformed && !inlinable && shouldHoist) { var generatedName = factory.getGeneratedNameForNode(name); - hoistVariableDeclaration(generatedName); + if (resolver.getNodeCheckFlags(name) & 524288 /* BlockScopedBindingInLoop */) { + addBlockScopedVariable(generatedName); + } + else { + hoistVariableDeclaration(generatedName); + } return factory.createAssignment(generatedName, expression); } return (inlinable || ts.isIdentifier(innerExpression)) ? undefined : expression; @@ -86524,22 +89763,164 @@ var ts; currentPrivateIdentifierEnvironment = privateIdentifierEnvironmentStack.pop(); } function getPrivateIdentifierEnvironment() { - return currentPrivateIdentifierEnvironment || (currentPrivateIdentifierEnvironment = new ts.Map()); + if (!currentPrivateIdentifierEnvironment) { + currentPrivateIdentifierEnvironment = { + className: "", + identifiers: new ts.Map() + }; + } + return currentPrivateIdentifierEnvironment; } function getPendingExpressions() { return pendingExpressions || (pendingExpressions = []); } - function addPrivateIdentifierToEnvironment(name) { - var text = ts.getTextOfPropertyName(name); - var weakMapName = factory.createUniqueName("_" + text.substring(1), 16 /* Optimistic */ | 8 /* ReservedInNestedScopes */); - hoistVariableDeclaration(weakMapName); - getPrivateIdentifierEnvironment().set(name.escapedText, { placement: 0 /* InstanceField */, weakMapName: weakMapName }); - getPendingExpressions().push(factory.createAssignment(weakMapName, factory.createNewExpression(factory.createIdentifier("WeakMap"), - /*typeArguments*/ undefined, []))); + function addPrivateIdentifierToEnvironment(node) { + var _a; + var text = ts.getTextOfPropertyName(node.name); + var env = getPrivateIdentifierEnvironment(); + var weakSetName = env.weakSetName, classConstructor = env.classConstructor; + var assignmentExpressions = []; + var privateName = node.name.escapedText; + var previousInfo = env.identifiers.get(privateName); + var isValid = !isReservedPrivateName(node.name) && previousInfo === undefined; + if (ts.hasStaticModifier(node)) { + ts.Debug.assert(classConstructor, "weakSetName should be set in private identifier environment"); + if (ts.isPropertyDeclaration(node)) { + var variableName = createHoistedVariableForPrivateName(text, node); + env.identifiers.set(privateName, { + kind: "f" /* Field */, + variableName: variableName, + brandCheckIdentifier: classConstructor, + isStatic: true, + isValid: isValid, + }); + } + else if (ts.isMethodDeclaration(node)) { + var functionName = createHoistedVariableForPrivateName(text, node); + env.identifiers.set(privateName, { + kind: "m" /* Method */, + methodName: functionName, + brandCheckIdentifier: classConstructor, + isStatic: true, + isValid: isValid, + }); + } + 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) { + previousInfo.getterName = getterName; + } + else { + env.identifiers.set(privateName, { + kind: "a" /* Accessor */, + getterName: getterName, + setterName: undefined, + brandCheckIdentifier: classConstructor, + isStatic: true, + isValid: isValid, + }); + } + } + 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) { + previousInfo.setterName = setterName; + } + else { + env.identifiers.set(privateName, { + kind: "a" /* Accessor */, + getterName: undefined, + setterName: setterName, + brandCheckIdentifier: classConstructor, + isStatic: true, + isValid: isValid, + }); + } + } + else { + ts.Debug.assertNever(node, "Unknown class element type."); + } + } + else if (ts.isPropertyDeclaration(node)) { + var weakMapName = createHoistedVariableForPrivateName(text, node); + env.identifiers.set(privateName, { + kind: "f" /* Field */, + brandCheckIdentifier: weakMapName, + isStatic: false, + variableName: undefined, + isValid: isValid, + }); + assignmentExpressions.push(factory.createAssignment(weakMapName, factory.createNewExpression(factory.createIdentifier("WeakMap"), + /*typeArguments*/ undefined, []))); + } + else if (ts.isMethodDeclaration(node)) { + ts.Debug.assert(weakSetName, "weakSetName should be set in private identifier environment"); + env.identifiers.set(privateName, { + kind: "m" /* Method */, + methodName: createHoistedVariableForPrivateName(text, node), + brandCheckIdentifier: weakSetName, + isStatic: false, + isValid: isValid, + }); + } + else if (ts.isAccessor(node)) { + 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) { + previousInfo.getterName = getterName; + } + else { + env.identifiers.set(privateName, { + kind: "a" /* Accessor */, + getterName: getterName, + setterName: undefined, + brandCheckIdentifier: weakSetName, + isStatic: false, + isValid: isValid, + }); + } + } + else { + var setterName = createHoistedVariableForPrivateName(text + "_set", node); + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && !previousInfo.isStatic && !previousInfo.setterName) { + previousInfo.setterName = setterName; + } + else { + env.identifiers.set(privateName, { + kind: "a" /* Accessor */, + getterName: undefined, + setterName: setterName, + brandCheckIdentifier: weakSetName, + isStatic: false, + isValid: isValid, + }); + } + } + } + else { + ts.Debug.assertNever(node, "Unknown class element type."); + } + (_a = getPendingExpressions()).push.apply(_a, assignmentExpressions); + } + 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 */) { + addBlockScopedVariable(identifier); + } + else { + hoistVariableDeclaration(identifier); + } + return identifier; + } + function createHoistedVariableForPrivateName(privateName, node) { + return createHoistedVariableForClass(privateName.substring(1), node.name); } function accessPrivateIdentifier(name) { if (currentPrivateIdentifierEnvironment) { - var info = currentPrivateIdentifierEnvironment.get(name.escapedText); + var info = currentPrivateIdentifierEnvironment.identifiers.get(name.escapedText); if (info) { return info; } @@ -86549,7 +89930,7 @@ var ts; if (!env) { continue; } - var info = env.get(name.escapedText); + var info = env.identifiers.get(name.escapedText); if (info) { return info; } @@ -86567,7 +89948,7 @@ 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, 62 /* EqualsToken */, node.expression)); + getPendingExpressions().push(factory.createBinaryExpression(receiver, 63 /* EqualsToken */, node.expression)); } return factory.createPropertyAccessExpression( // Explicit parens required because of v8 regression (https://bugs.chromium.org/p/v8/issues/detail?id=9560) @@ -86580,7 +89961,7 @@ var ts; /*dotDotDotToken*/ undefined, parameter, /*questionToken*/ undefined, /*type*/ undefined, - /*initializer*/ undefined)], factory.createBlock([factory.createExpressionStatement(createPrivateIdentifierAssignment(info, receiver, parameter, 62 /* EqualsToken */))])) + /*initializer*/ undefined)], factory.createBlock([factory.createExpressionStatement(createPrivateIdentifierAssignment(info, receiver, parameter, 63 /* EqualsToken */))])) ])), "value"); } function visitArrayAssignmentTarget(node) { @@ -86635,10 +90016,22 @@ var ts; } } ts.transformClassFields = transformClassFields; + function createPrivateStaticFieldInitializer(variableName, initializer) { + return ts.factory.createAssignment(variableName, ts.factory.createObjectLiteralExpression([ + ts.factory.createPropertyAssignment("value", initializer || ts.factory.createVoidZero()) + ])); + } function createPrivateInstanceFieldInitializer(receiver, initializer, weakMapName) { return ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(weakMapName, "set"), /*typeArguments*/ undefined, [receiver, initializer || ts.factory.createVoidZero()]); } + function createPrivateInstanceMethodInitializer(receiver, weakSetName) { + return ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(weakSetName, "add"), + /*typeArguments*/ undefined, [receiver]); + } + function isReservedPrivateName(node) { + return node.escapedText === "#constructor"; + } })(ts || (ts = {})); /*@internal*/ var ts; @@ -86721,38 +90114,38 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 64 /* ContainsES2017 */) === 0) { + if ((node.transformFlags & 128 /* ContainsES2017 */) === 0) { return node; } switch (node.kind) { - case 129 /* AsyncKeyword */: + case 130 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 213 /* AwaitExpression */: + case 215 /* AwaitExpression */: return visitAwaitExpression(node); - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitMethodDeclaration, node); - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitFunctionDeclaration, node); - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitFunctionExpression, node); - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return doWithContext(1 /* NonTopLevel */, visitArrowFunction, node); - case 201 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 105 /* SuperKeyword */) { + case 203 /* PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SuperKeyword */) { capturedSuperProperties.add(node.name.escapedText); } return ts.visitEachChild(node, visitor, context); - case 202 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 105 /* SuperKeyword */) { + case 204 /* ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 106 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 166 /* Constructor */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 168 /* Constructor */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitDefault, node); default: return ts.visitEachChild(node, visitor, context); @@ -86761,27 +90154,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return visitForStatementInAsyncBody(node); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return visitForInStatementInAsyncBody(node); - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return visitCatchClauseInAsyncBody(node); - case 230 /* Block */: - case 244 /* SwitchStatement */: - case 258 /* CaseBlock */: - case 284 /* CaseClause */: - case 285 /* DefaultClause */: - case 247 /* TryStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: - case 234 /* IfStatement */: - case 243 /* WithStatement */: - case 245 /* LabeledStatement */: + case 232 /* Block */: + case 246 /* SwitchStatement */: + case 260 /* CaseBlock */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: + case 249 /* TryStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: + case 236 /* IfStatement */: + case 245 /* WithStatement */: + case 247 /* LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -86823,18 +90216,18 @@ var ts; function visitForInStatementInAsyncBody(node) { return factory.updateForInStatement(node, isVariableDeclarationListWithCollidingName(node.initializer) ? visitVariableDeclarationListWithCollidingNames(node.initializer, /*hasReceiver*/ true) - : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, asyncBodyVisitor, ts.isStatement, factory.liftToBlock)); + : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitIterationBody(node.statement, asyncBodyVisitor, context)); } function visitForOfStatementInAsyncBody(node) { return factory.updateForOfStatement(node, ts.visitNode(node.awaitModifier, visitor, ts.isToken), isVariableDeclarationListWithCollidingName(node.initializer) ? visitVariableDeclarationListWithCollidingNames(node.initializer, /*hasReceiver*/ true) - : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, asyncBodyVisitor, ts.isStatement, factory.liftToBlock)); + : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitIterationBody(node.statement, asyncBodyVisitor, context)); } function visitForStatementInAsyncBody(node) { var initializer = node.initializer; // TODO: GH#18217 return factory.updateForStatement(node, isVariableDeclarationListWithCollidingName(initializer) ? visitVariableDeclarationListWithCollidingNames(initializer, /*hasReceiver*/ false) - : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitor, ts.isExpression), ts.visitNode(node.statement, asyncBodyVisitor, ts.isStatement, factory.liftToBlock)); + : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitor, ts.isExpression), ts.visitIterationBody(node.statement, asyncBodyVisitor, context)); } /** * Visits an AwaitExpression node. @@ -86986,7 +90379,7 @@ var ts; var original = ts.getOriginalNode(node, ts.isFunctionLike); var nodeType = original.type; var promiseConstructor = languageVersion < 2 /* ES2015 */ ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 209 /* ArrowFunction */; + var isArrowFunction = node.kind === 211 /* ArrowFunction */; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* 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 @@ -87077,17 +90470,17 @@ var ts; enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(203 /* CallExpression */); - context.enableSubstitution(201 /* PropertyAccessExpression */); - context.enableSubstitution(202 /* ElementAccessExpression */); + context.enableSubstitution(205 /* CallExpression */); + context.enableSubstitution(203 /* PropertyAccessExpression */); + context.enableSubstitution(204 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(252 /* ClassDeclaration */); - context.enableEmitNotification(165 /* MethodDeclaration */); - context.enableEmitNotification(167 /* GetAccessor */); - context.enableEmitNotification(168 /* SetAccessor */); - context.enableEmitNotification(166 /* Constructor */); + context.enableEmitNotification(254 /* ClassDeclaration */); + context.enableEmitNotification(167 /* MethodDeclaration */); + context.enableEmitNotification(169 /* GetAccessor */); + context.enableEmitNotification(170 /* SetAccessor */); + context.enableEmitNotification(168 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(232 /* VariableStatement */); + context.enableEmitNotification(234 /* VariableStatement */); } } /** @@ -87135,23 +90528,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -87171,11 +90564,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 252 /* ClassDeclaration */ - || kind === 166 /* Constructor */ - || kind === 165 /* MethodDeclaration */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */; + return kind === 254 /* ClassDeclaration */ + || kind === 168 /* Constructor */ + || kind === 167 /* MethodDeclaration */ + || kind === 169 /* GetAccessor */ + || kind === 170 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -87332,7 +90725,7 @@ var ts; return visitorWorker(node, /*expressionResultIsUnused*/ true); } function visitorNoAsyncModifier(node) { - if (node.kind === 129 /* AsyncKeyword */) { + if (node.kind === 130 /* AsyncKeyword */) { return undefined; } return node; @@ -87354,74 +90747,74 @@ var ts; * expression of an `ExpressionStatement`). */ function visitorWorker(node, expressionResultIsUnused) { - if ((node.transformFlags & 32 /* ContainsES2018 */) === 0) { + if ((node.transformFlags & 64 /* ContainsES2018 */) === 0) { return node; } switch (node.kind) { - case 213 /* AwaitExpression */: + case 215 /* AwaitExpression */: return visitAwaitExpression(node); - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: return visitYieldExpression(node); - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: return visitReturnStatement(node); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return visitLabeledStatement(node); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return visitBinaryExpression(node, expressionResultIsUnused); - case 337 /* CommaListExpression */: + case 345 /* CommaListExpression */: return visitCommaListExpression(node, expressionResultIsUnused); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return visitCatchClause(node); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return visitVariableStatement(node); - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 235 /* DoStatement */: - case 236 /* WhileStatement */: - case 238 /* ForInStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: + case 240 /* ForInStatement */: return doWithHierarchyFacts(visitDefault, node, 0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return doWithHierarchyFacts(visitForStatement, node, 0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - case 212 /* VoidExpression */: + case 214 /* VoidExpression */: return visitVoidExpression(node); - case 166 /* Constructor */: + case 168 /* Constructor */: return doWithHierarchyFacts(visitConstructorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: return doWithHierarchyFacts(visitMethodDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 167 /* GetAccessor */: + case 169 /* GetAccessor */: return doWithHierarchyFacts(visitGetAccessorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 168 /* SetAccessor */: + case 170 /* SetAccessor */: return doWithHierarchyFacts(visitSetAccessorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return doWithHierarchyFacts(visitFunctionDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: return doWithHierarchyFacts(visitFunctionExpression, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return doWithHierarchyFacts(visitArrowFunction, node, 2 /* ArrowFunctionExcludes */, 0 /* ArrowFunctionIncludes */); - case 160 /* Parameter */: + case 162 /* Parameter */: return visitParameter(node); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: return visitExpressionStatement(node); - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, expressionResultIsUnused); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 201 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 105 /* SuperKeyword */) { + case 203 /* PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SuperKeyword */) { capturedSuperProperties.add(node.name.escapedText); } return ts.visitEachChild(node, visitor, context); - case 202 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 105 /* SuperKeyword */) { + case 204 /* ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 106 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: return doWithHierarchyFacts(visitDefault, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); default: return ts.visitEachChild(node, visitor, context); @@ -87457,7 +90850,7 @@ var ts; function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2 /* Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 239 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 241 /* ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return factory.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement, factory.liftToBlock), node); @@ -87469,7 +90862,7 @@ var ts; var objects = []; for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) { var e = elements_4[_i]; - if (e.kind === 290 /* SpreadAssignment */) { + if (e.kind === 292 /* SpreadAssignment */) { if (chunkObject) { objects.push(factory.createObjectLiteralExpression(chunkObject)); chunkObject = undefined; @@ -87478,7 +90871,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 288 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 290 /* PropertyAssignment */ ? factory.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -87489,7 +90882,7 @@ var ts; return objects; } function visitObjectLiteralExpression(node) { - if (node.transformFlags & 16384 /* ContainsObjectRestOrSpread */) { + if (node.transformFlags & 32768 /* 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}); @@ -87512,7 +90905,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 !== 200 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 202 /* ObjectLiteralExpression */) { objects.unshift(factory.createObjectLiteralExpression()); } var expression = objects[0]; @@ -87562,7 +90955,7 @@ var ts; * expression of an `ExpressionStatement`). */ function visitBinaryExpression(node, expressionResultIsUnused) { - if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 16384 /* ContainsObjectRestOrSpread */) { + if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { return ts.flattenDestructuringAssignment(node, visitor, context, 1 /* ObjectRest */, !expressionResultIsUnused); } if (node.operatorToken.kind === 27 /* CommaToken */) { @@ -87593,7 +90986,7 @@ var ts; function visitCatchClause(node) { if (node.variableDeclaration && ts.isBindingPattern(node.variableDeclaration.name) && - node.variableDeclaration.name.transformFlags & 16384 /* ContainsObjectRestOrSpread */) { + node.variableDeclaration.name.transformFlags & 32768 /* 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 */); @@ -87634,14 +91027,14 @@ 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 & 16384 /* ContainsObjectRestOrSpread */) { + if (ts.isBindingPattern(node.name) && node.name.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { return ts.flattenDestructuringBinding(node, visitor, context, 1 /* ObjectRest */, /*rval*/ undefined, exportedVariableStatement); } return ts.visitEachChild(node, visitor, context); } function visitForStatement(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)); + 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.visitIterationBody(node.statement, visitor, context)); } function visitVoidExpression(node) { return ts.visitEachChild(node, visitorWithUnusedExpressionResult, context); @@ -87653,7 +91046,7 @@ var ts; */ function visitForOfStatement(node, outermostLabeledStatement) { var ancestorFacts = enterSubtree(0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - if (node.initializer.transformFlags & 16384 /* ContainsObjectRestOrSpread */) { + if (node.initializer.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { node = transformForOfStatementWithObjectRest(node); } var result = node.awaitModifier ? @@ -87691,7 +91084,7 @@ var ts; var bodyLocation; var statementsLocation; var statements = [ts.visitNode(binding, visitor, ts.isStatement)]; - var statement = ts.visitNode(node.statement, visitor, ts.isStatement); + var statement = ts.visitIterationBody(node.statement, visitor, context); if (ts.isBlock(statement)) { ts.addRange(statements, statement.statements); bodyLocation = statement; @@ -87753,7 +91146,7 @@ var ts; ])); } function visitParameter(node) { - if (node.transformFlags & 16384 /* ContainsObjectRestOrSpread */) { + if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { // Binding patterns are converted into a generated name and are // evaluated inside the function body. return factory.updateParameterDeclaration(node, @@ -87905,7 +91298,7 @@ var ts; function appendObjectRestAssignmentsIfNeeded(statements, node) { for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { var parameter = _a[_i]; - if (parameter.transformFlags & 16384 /* ContainsObjectRestOrSpread */) { + if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { var temp = factory.getGeneratedNameForNode(parameter); var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* ObjectRest */, temp, /*doNotRecordTempVariablesInLine*/ false, @@ -87925,17 +91318,17 @@ var ts; enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(203 /* CallExpression */); - context.enableSubstitution(201 /* PropertyAccessExpression */); - context.enableSubstitution(202 /* ElementAccessExpression */); + context.enableSubstitution(205 /* CallExpression */); + context.enableSubstitution(203 /* PropertyAccessExpression */); + context.enableSubstitution(204 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(252 /* ClassDeclaration */); - context.enableEmitNotification(165 /* MethodDeclaration */); - context.enableEmitNotification(167 /* GetAccessor */); - context.enableEmitNotification(168 /* SetAccessor */); - context.enableEmitNotification(166 /* Constructor */); + context.enableEmitNotification(254 /* ClassDeclaration */); + context.enableEmitNotification(167 /* MethodDeclaration */); + context.enableEmitNotification(169 /* GetAccessor */); + context.enableEmitNotification(170 /* SetAccessor */); + context.enableEmitNotification(168 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(232 /* VariableStatement */); + context.enableEmitNotification(234 /* VariableStatement */); } } /** @@ -87983,23 +91376,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -88019,11 +91412,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 252 /* ClassDeclaration */ - || kind === 166 /* Constructor */ - || kind === 165 /* MethodDeclaration */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */; + return kind === 254 /* ClassDeclaration */ + || kind === 168 /* Constructor */ + || kind === 167 /* MethodDeclaration */ + || kind === 169 /* GetAccessor */ + || kind === 170 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -88051,11 +91444,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 16 /* ContainsES2019 */) === 0) { + if ((node.transformFlags & 32 /* ContainsES2019 */) === 0) { return node; } switch (node.kind) { - case 287 /* CatchClause */: + case 289 /* CatchClause */: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -88083,25 +91476,29 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 8 /* ContainsES2020 */) === 0) { + if ((node.transformFlags & 16 /* ContainsES2020 */) === 0) { return node; } switch (node.kind) { - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: - case 203 /* CallExpression */: - if (node.flags & 32 /* OptionalChain */) { + case 205 /* CallExpression */: { + var updated = visitNonOptionalCallExpression(node, /*captureThisArg*/ false); + ts.Debug.assertNotNode(updated, ts.isSyntheticReference); + return updated; + } + case 203 /* PropertyAccessExpression */: + case 204 /* 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 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: if (node.operatorToken.kind === 60 /* QuestionQuestionToken */) { return transformNullishCoalescingExpression(node); } return ts.visitEachChild(node, visitor, context); - case 210 /* DeleteExpression */: + case 212 /* DeleteExpression */: return visitDeleteExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -88143,7 +91540,7 @@ var ts; thisArg = expression; } } - expression = node.kind === 201 /* PropertyAccessExpression */ + expression = node.kind === 203 /* 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; @@ -88153,14 +91550,23 @@ var ts; // If `node` is an optional chain, then it is the outermost chain of an optional expression. return visitOptionalExpression(node, captureThisArg, /*isDelete*/ false); } + if (ts.isParenthesizedExpression(node.expression) && ts.isOptionalChain(ts.skipParentheses(node.expression))) { + // capture thisArg for calls of parenthesized optional chains like `(foo?.bar)()` + var expression = visitNonOptionalParenthesizedExpression(node.expression, /*captureThisArg*/ true, /*isDelete*/ false); + var args = ts.visitNodes(node.arguments, visitor, ts.isExpression); + if (ts.isSyntheticReference(expression)) { + return ts.setTextRange(factory.createFunctionCallCall(expression.expression, expression.thisArg, args), node); + } + return factory.updateCallExpression(node, expression, /*typeArguments*/ undefined, args); + } return ts.visitEachChild(node, visitor, context); } function visitNonOptionalExpression(node, captureThisArg, isDelete) { switch (node.kind) { - case 207 /* ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete); - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete); - case 203 /* CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); + case 209 /* ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete); + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete); + case 205 /* CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); default: return ts.visitNode(node, visitor, ts.isExpression); } } @@ -88179,8 +91585,8 @@ var ts; for (var i = 0; i < chain.length; i++) { var segment = chain[i]; switch (segment.kind) { - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: if (i === chain.length - 1 && captureThisArg) { if (!ts.isSimpleCopiableExpression(rightExpression)) { thisArg = factory.createTempVariable(hoistVariableDeclaration); @@ -88190,13 +91596,13 @@ var ts; thisArg = rightExpression; } } - rightExpression = segment.kind === 201 /* PropertyAccessExpression */ + rightExpression = segment.kind === 203 /* PropertyAccessExpression */ ? factory.createPropertyAccessExpression(rightExpression, ts.visitNode(segment.name, visitor, ts.isIdentifier)) : factory.createElementAccessExpression(rightExpression, ts.visitNode(segment.argumentExpression, visitor, ts.isExpression)); break; - case 203 /* CallExpression */: + case 205 /* CallExpression */: if (i === 0 && leftThisArg) { - rightExpression = factory.createFunctionCallCall(rightExpression, leftThisArg.kind === 105 /* SuperKeyword */ ? factory.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); + rightExpression = factory.createFunctionCallCall(rightExpression, leftThisArg.kind === 106 /* SuperKeyword */ ? factory.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); } else { rightExpression = factory.createCallExpression(rightExpression, @@ -88237,7 +91643,7 @@ var ts; /*@internal*/ var ts; (function (ts) { - function transformESNext(context) { + function transformES2021(context) { var hoistVariableDeclaration = context.hoistVariableDeclaration, factory = context.factory; return ts.chainBundle(context, transformSourceFile); function transformSourceFile(node) { @@ -88247,11 +91653,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 4 /* ContainsESNext */) === 0) { + if ((node.transformFlags & 8 /* ContainsES2021 */) === 0) { return node; } switch (node.kind) { - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: var binaryExpression = node; if (ts.isLogicalOrCoalescingAssignmentExpression(binaryExpression)) { return transformLogicalAssignment(binaryExpression); @@ -88287,6 +91693,29 @@ var ts; return factory.createBinaryExpression(left, nonAssignmentOperator, factory.createParenthesizedExpression(factory.createAssignment(assignmentTarget, right))); } } + ts.transformES2021 = transformES2021; +})(ts || (ts = {})); +/*@internal*/ +var ts; +(function (ts) { + function transformESNext(context) { + return ts.chainBundle(context, transformSourceFile); + function transformSourceFile(node) { + if (node.isDeclarationFile) { + return node; + } + return ts.visitEachChild(node, visitor, context); + } + function visitor(node) { + if ((node.transformFlags & 4 /* ContainsESNext */) === 0) { + return node; + } + switch (node.kind) { + default: + return ts.visitEachChild(node, visitor, context); + } + } + } ts.transformESNext = transformESNext; })(ts || (ts = {})); /*@internal*/ @@ -88397,13 +91826,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 273 /* JsxElement */: + case 275 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 274 /* JsxSelfClosingElement */: + case 276 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 277 /* JsxFragment */: + case 279 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -88413,13 +91842,13 @@ var ts; switch (node.kind) { case 11 /* JsxText */: return visitJsxText(node); - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: return visitJsxExpression(node); - case 273 /* JsxElement */: + case 275 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 274 /* JsxSelfClosingElement */: + case 276 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 277 /* JsxFragment */: + case 279 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -88537,21 +91966,29 @@ var ts; // When there are no attributes, React wants "null" } else { - // Map spans of JsxAttribute nodes into object literals and spans - // of JsxSpreadAttribute nodes into expressions. - var segments = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread - ? ts.map(attrs, transformJsxSpreadAttributeToExpression) - : factory.createObjectLiteralExpression(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); })); - if (ts.isJsxSpreadAttribute(attrs[0])) { - // We must always emit at least one object literal before a spread - // argument.factory.createObjectLiteral - segments.unshift(factory.createObjectLiteralExpression()); + var target = compilerOptions.target; + if (target && target >= 5 /* ES2018 */) { + objectProperties = factory.createObjectLiteralExpression(ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { + return isSpread ? ts.map(attrs, transformJsxSpreadAttributeToSpreadAssignment) : ts.map(attrs, transformJsxAttributeToObjectLiteralElement); + }))); } - // Either emit one big object literal (no spread attribs), or - // a call to the __assign helper. - objectProperties = ts.singleOrUndefined(segments); - if (!objectProperties) { - objectProperties = emitHelpers().createAssignHelper(segments); + else { + // Map spans of JsxAttribute nodes into object literals and spans + // of JsxSpreadAttribute nodes into expressions. + var segments = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread + ? ts.map(attrs, transformJsxSpreadAttributeToExpression) + : factory.createObjectLiteralExpression(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); })); + if (ts.isJsxSpreadAttribute(attrs[0])) { + // We must always emit at least one object literal before a spread + // argument.factory.createObjectLiteral + segments.unshift(factory.createObjectLiteralExpression()); + } + // Either emit one big object literal (no spread attribs), or + // a call to the __assign helper. + objectProperties = ts.singleOrUndefined(segments); + if (!objectProperties) { + objectProperties = emitHelpers().createAssignHelper(segments); + } } } var callee = currentFileState.importSpecifier === undefined @@ -88583,6 +92020,9 @@ var ts; } return element; } + function transformJsxSpreadAttributeToSpreadAssignment(node) { + return factory.createSpreadAssignment(ts.visitNode(node.expression, visitor, ts.isExpression)); + } function transformJsxSpreadAttributeToExpression(node) { return ts.visitNode(node.expression, visitor, ts.isExpression); } @@ -88602,7 +92042,7 @@ var ts; var literal = factory.createStringLiteral(tryDecodeEntities(node.text) || node.text, singleQuote); return ts.setTextRange(literal, node); } - else if (node.kind === 283 /* JsxExpression */) { + else if (node.kind === 285 /* JsxExpression */) { if (node.expression === undefined) { return factory.createTrue(); } @@ -88696,7 +92136,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 273 /* JsxElement */) { + if (node.kind === 275 /* JsxElement */) { return getTagName(node.openingElement); } else { @@ -88998,11 +92438,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 128 /* ContainsES2016 */) === 0) { + if ((node.transformFlags & 256 /* ContainsES2016 */) === 0) { return node; } switch (node.kind) { - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -89010,7 +92450,7 @@ var ts; } function visitBinaryExpression(node) { switch (node.operatorToken.kind) { - case 66 /* AsteriskAsteriskEqualsToken */: + case 67 /* AsteriskAsteriskEqualsToken */: return visitExponentiationAssignmentExpression(node); case 42 /* AsteriskAsteriskToken */: return visitExponentiationExpression(node); @@ -89215,11 +92655,11 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 242 /* ReturnStatement */ + && node.kind === 244 /* ReturnStatement */ && !node.expression; } function isOrMayContainReturnCompletion(node) { - return node.transformFlags & 1048576 /* ContainsHoistedDeclarationOrCompletion */ + return node.transformFlags & 2097152 /* ContainsHoistedDeclarationOrCompletion */ && (ts.isReturnStatement(node) || ts.isIfStatement(node) || ts.isWithStatement(node) @@ -89234,7 +92674,7 @@ var ts; || ts.isBlock(node)); } function shouldVisitNode(node) { - return (node.transformFlags & 256 /* ContainsES2015 */) !== 0 + return (node.transformFlags & 512 /* ContainsES2015 */) !== 0 || convertedLoopState !== undefined || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && isOrMayContainReturnCompletion(node)) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatement(node)) @@ -89247,74 +92687,74 @@ var ts; return shouldVisitNode(node) ? visitorWorker(node, /*expressionResultIsUnused*/ true) : node; } function callExpressionVisitor(node) { - if (node.kind === 105 /* SuperKeyword */) { + if (node.kind === 106 /* SuperKeyword */) { return visitSuperKeyword(/*isExpressionOfCall*/ true); } return visitor(node); } function visitorWorker(node, expressionResultIsUnused) { switch (node.kind) { - case 123 /* StaticKeyword */: + case 124 /* StaticKeyword */: return undefined; // elide static keyword - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: return visitClassDeclaration(node); - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: return visitClassExpression(node); - case 160 /* Parameter */: + case 162 /* Parameter */: return visitParameter(node); - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return visitArrowFunction(node); - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: return visitFunctionExpression(node); - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 78 /* Identifier */: + case 79 /* Identifier */: return visitIdentifier(node); - case 250 /* VariableDeclarationList */: + case 252 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: return visitSwitchStatement(node); - case 258 /* CaseBlock */: + case 260 /* CaseBlock */: return visitCaseBlock(node); - case 230 /* Block */: + case 232 /* Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 241 /* BreakStatement */: - case 240 /* ContinueStatement */: + case 243 /* BreakStatement */: + case 242 /* ContinueStatement */: return visitBreakOrContinueStatement(node); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return visitLabeledStatement(node); - case 235 /* DoStatement */: - case 236 /* WhileStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: return visitExpressionStatement(node); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return visitCatchClause(node); - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return visitCallExpression(node); - case 204 /* NewExpression */: + case 206 /* NewExpression */: return visitNewExpression(node); - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, expressionResultIsUnused); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return visitBinaryExpression(node, expressionResultIsUnused); - case 337 /* CommaListExpression */: + case 345 /* CommaListExpression */: return visitCommaListExpression(node, expressionResultIsUnused); case 14 /* NoSubstitutionTemplateLiteral */: case 15 /* TemplateHead */: @@ -89325,30 +92765,30 @@ var ts; return visitStringLiteral(node); case 8 /* NumericLiteral */: return visitNumericLiteral(node); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 218 /* TemplateExpression */: + case 220 /* TemplateExpression */: return visitTemplateExpression(node); - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: return visitYieldExpression(node); - case 220 /* SpreadElement */: + case 222 /* SpreadElement */: return visitSpreadElement(node); - case 105 /* SuperKeyword */: + case 106 /* SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: return visitThisKeyword(node); - case 226 /* MetaProperty */: + case 228 /* MetaProperty */: return visitMetaProperty(node); - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return visitAccessorDeclaration(node); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return visitVariableStatement(node); - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: return visitReturnStatement(node); - case 212 /* VoidExpression */: + case 214 /* VoidExpression */: return visitVoidExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -89438,14 +92878,14 @@ 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 === 241 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 243 /* BreakStatement */ ? 2 /* Break */ : 4 /* 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 === 241 /* BreakStatement */) { + if (node.kind === 243 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -89456,7 +92896,7 @@ var ts; } } else { - if (node.kind === 241 /* BreakStatement */) { + if (node.kind === 243 /* BreakStatement */) { labelMarker = "break-" + label.escapedText; setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } @@ -89716,7 +93156,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 !== 103 /* NullKeyword */; + var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */; // When the subclass does not have a constructor, we synthesize a *default* constructor using the following // representation: // @@ -89768,7 +93208,7 @@ var ts; factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment()); insertCaptureNewTargetIfNeeded(prologue, constructor, /*copyOnWrite*/ false); if (isDerivedClass) { - if (superCallExpression && statementOffset === constructor.body.statements.length && !(constructor.body.transformFlags & 4096 /* ContainsLexicalThis */)) { + if (superCallExpression && statementOffset === constructor.body.statements.length && !(constructor.body.transformFlags & 8192 /* ContainsLexicalThis */)) { // If the subclass constructor does *not* contain `this` and *ends* with a `super()` call, we will use the // following representation: // @@ -89854,11 +93294,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 242 /* ReturnStatement */) { + if (statement.kind === 244 /* ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 234 /* IfStatement */) { + else if (statement.kind === 236 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -89866,7 +93306,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 230 /* Block */) { + else if (statement.kind === 232 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -90024,10 +93464,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 === 78 /* Identifier */ ? ts.setParent(ts.setTextRange(factory.cloneNode(parameter.name), parameter.name), parameter.name.parent) : factory.createTempVariable(/*recordTempVariable*/ undefined); + 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 */); // `expressionName` is the name of the parameter used in expressions. - var expressionName = parameter.name.kind === 78 /* Identifier */ ? factory.cloneNode(parameter.name) : declarationName; + var expressionName = parameter.name.kind === 79 /* Identifier */ ? factory.cloneNode(parameter.name) : declarationName; var restIndex = node.parameters.length - 1; var temp = factory.createLoopVariable(); // var param = []; @@ -90052,7 +93492,7 @@ var ts; ts.setEmitFlags(forStatement, 1048576 /* CustomPrologue */); ts.startOnNewLine(forStatement); prologueStatements.push(forStatement); - if (parameter.name.kind !== 78 /* Identifier */) { + if (parameter.name.kind !== 79 /* 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 */)); @@ -90068,7 +93508,7 @@ var ts; * @param node A node. */ function insertCaptureThisForNodeIfNeeded(statements, node) { - if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 209 /* ArrowFunction */) { + if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 211 /* ArrowFunction */) { insertCaptureThisForNode(statements, node, factory.createThis()); return true; } @@ -90090,25 +93530,25 @@ var ts; if (hierarchyFacts & 16384 /* NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return statements; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: // Methods and accessors cannot be constructors, so 'new.target' will // always return 'undefined'. newTarget = factory.createVoidZero(); break; - case 166 /* Constructor */: + case 168 /* 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"); break; - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 210 /* 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 */), 101 /* InstanceOfKeyword */, factory.getLocalName(node))), + 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"), /*colonToken*/ undefined, factory.createVoidZero()); break; @@ -90140,20 +93580,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 229 /* SemicolonClassElement */: + case 231 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 166 /* Constructor */: + case 168 /* Constructor */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -90182,7 +93622,7 @@ var ts; var memberFunction = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined, container); var propertyName = ts.visitNode(member.name, visitor, ts.isPropertyName); var e; - if (!ts.isPrivateIdentifier(propertyName) && context.getCompilerOptions().useDefineForClassFields) { + if (!ts.isPrivateIdentifier(propertyName) && ts.getUseDefineForClassFields(context.getCompilerOptions())) { var name = ts.isComputedPropertyName(propertyName) ? propertyName.expression : ts.isIdentifier(propertyName) ? factory.createStringLiteral(ts.unescapeLeadingUnderscores(propertyName.escapedText)) : propertyName; @@ -90274,7 +93714,7 @@ var ts; * @param node An ArrowFunction node. */ function visitArrowFunction(node) { - if (node.transformFlags & 4096 /* ContainsLexicalThis */) { + if (node.transformFlags & 8192 /* ContainsLexicalThis */) { hierarchyFacts |= 32768 /* CapturedLexicalThis */; } var savedConvertedLoopState = convertedLoopState; @@ -90356,7 +93796,7 @@ var ts; : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 251 /* FunctionDeclaration */ || node.kind === 208 /* FunctionExpression */)) { + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 253 /* FunctionDeclaration */ || node.kind === 210 /* FunctionExpression */)) { name = factory.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */); @@ -90402,7 +93842,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 209 /* ArrowFunction */); + ts.Debug.assert(node.kind === 211 /* 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 @@ -90537,7 +93977,7 @@ var ts; assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0 /* All */); } else { - assignment = factory.createBinaryExpression(decl.name, 62 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + assignment = factory.createBinaryExpression(decl.name, 63 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); ts.setTextRange(assignment, decl); } assignments = ts.append(assignments, assignment); @@ -90563,7 +94003,7 @@ var ts; * @param node A VariableDeclarationList node. */ function visitVariableDeclarationList(node) { - if (node.flags & 3 /* BlockScoped */ || node.transformFlags & 131072 /* ContainsBindingPattern */) { + if (node.flags & 3 /* BlockScoped */ || node.transformFlags & 262144 /* ContainsBindingPattern */) { if (node.flags & 3 /* BlockScoped */) { enableSubstitutionsForBlockScopedBindings(); } @@ -90576,7 +94016,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 & 131072 /* ContainsBindingPattern */ + if (node.transformFlags & 262144 /* ContainsBindingPattern */ && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.last(node.declarations).name))) { ts.setSourceMapRange(declarationList, getRangeUnion(declarations)); } @@ -90588,8 +94028,8 @@ var ts; // declarations may not be sorted by position. // pos should be the minimum* position over all nodes (that's not -1), end should be the maximum end over all nodes. var pos = -1, end = -1; - for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) { - var node = declarations_10[_i]; + for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { + var node = declarations_9[_i]; pos = pos === -1 ? node.pos : node.pos === -1 ? pos : Math.min(pos, node.pos); end = Math.max(end, node.end); } @@ -90709,14 +94149,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 235 /* DoStatement */: - case 236 /* WhileStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -90900,9 +94340,9 @@ var ts; var numInitialProperties = -1, hasComputed = false; for (var i = 0; i < properties.length; i++) { var property = properties[i]; - if ((property.transformFlags & 262144 /* ContainsYield */ && + if ((property.transformFlags & 524288 /* ContainsYield */ && hierarchyFacts & 4 /* AsyncFunctionBody */) - || (hasComputed = ts.Debug.checkDefined(property.name).kind === 158 /* ComputedPropertyName */)) { + || (hasComputed = ts.Debug.checkDefined(property.name).kind === 160 /* ComputedPropertyName */)) { numInitialProperties = i; break; } @@ -90954,7 +94394,7 @@ var ts; } visit(node.name); function visit(node) { - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { state.hoistedLocalVariables.push(node); } else { @@ -91005,24 +94445,24 @@ var ts; loop = convert(node, outermostLabeledStatement, bodyFunction.part, ancestorFacts); } else { - var clone_3 = convertIterationStatementCore(node, initializerFunction, factory.createBlock(bodyFunction.part, /*multiLine*/ true)); - loop = factory.restoreEnclosingLabel(clone_3, outermostLabeledStatement, convertedLoopState && resetLabel); + var clone_4 = convertIterationStatementCore(node, initializerFunction, factory.createBlock(bodyFunction.part, /*multiLine*/ true)); + loop = factory.restoreEnclosingLabel(clone_4, outermostLabeledStatement, convertedLoopState && resetLabel); } } else { - var clone_4 = convertIterationStatementCore(node, initializerFunction, ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - loop = factory.restoreEnclosingLabel(clone_4, outermostLabeledStatement, convertedLoopState && resetLabel); + var clone_5 = convertIterationStatementCore(node, initializerFunction, ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock)); + loop = factory.restoreEnclosingLabel(clone_5, outermostLabeledStatement, convertedLoopState && resetLabel); } statements.push(loop); return statements; } function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) { switch (node.kind) { - case 237 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); - case 238 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); - case 239 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); - case 235 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); - case 236 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); + case 239 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); + case 240 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); + case 241 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); + case 237 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); + case 238 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected"); } } @@ -91047,11 +94487,11 @@ var ts; function createConvertedLoopState(node) { var loopInitializer; switch (node.kind) { - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 250 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 252 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -91171,7 +94611,7 @@ var ts; */ function createFunctionForInitializerOfForStatement(node, currentState) { var functionName = factory.createUniqueName("_loop_init"); - var containsYield = (node.initializer.transformFlags & 262144 /* ContainsYield */) !== 0; + var containsYield = (node.initializer.transformFlags & 524288 /* ContainsYield */) !== 0; var emitFlags = 0 /* None */; if (currentState.containsLexicalThis) emitFlags |= 8 /* CapturesThis */; @@ -91286,7 +94726,7 @@ var ts; var loopBody = factory.createBlock(statements, /*multiLine*/ true); if (ts.isBlock(statement)) ts.setOriginalNode(loopBody, statement); - var containsYield = (node.statement.transformFlags & 262144 /* ContainsYield */) !== 0; + var containsYield = (node.statement.transformFlags & 524288 /* ContainsYield */) !== 0; var emitFlags = 524288 /* ReuseTempVariableScope */; if (currentState.containsLexicalThis) emitFlags |= 8 /* CapturesThis */; @@ -91322,7 +94762,7 @@ var ts; 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, 62 /* EqualsToken */, source); + return factory.createBinaryExpression(target, 63 /* EqualsToken */, source); } function copyOutParameters(outParams, partFlags, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { @@ -91459,20 +94899,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -91579,7 +95019,7 @@ var ts; var updated; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (node.kind === 167 /* GetAccessor */) { + if (node.kind === 169 /* GetAccessor */) { updated = factory.updateGetAccessorDeclaration(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); } else { @@ -91632,7 +95072,7 @@ var ts; return visitTypeScriptClassWrapper(node); } var expression = ts.skipOuterExpressions(node.expression); - if (expression.kind === 105 /* SuperKeyword */ || + if (expression.kind === 106 /* SuperKeyword */ || ts.isSuperProperty(expression) || ts.some(node.arguments, ts.isSpreadElement)) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); @@ -91759,15 +95199,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 & 8192 /* ContainsRestOrSpread */ || - node.expression.kind === 105 /* SuperKeyword */ || + if (node.transformFlags & 16384 /* ContainsRestOrSpread */ || + node.expression.kind === 106 /* SuperKeyword */ || ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) { var _a = factory.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { ts.setEmitFlags(thisArg, 4 /* NoSubstitution */); } var resultingCall = void 0; - if (node.transformFlags & 8192 /* ContainsRestOrSpread */) { + if (node.transformFlags & 16384 /* ContainsRestOrSpread */) { // [source] // f(...a, b) // x.m(...a, b) @@ -91781,7 +95221,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 === 105 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); + resultingCall = factory.createFunctionApplyCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); } else { // [source] @@ -91793,9 +95233,9 @@ 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 === 105 /* 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 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression)), node); } - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { var initializer = factory.createLogicalOr(resultingCall, createActualThis()); resultingCall = assignToCapturedThis ? factory.createAssignment(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), initializer) @@ -92042,7 +95482,7 @@ var ts; : factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */); } function visitMetaProperty(node) { - if (node.keywordToken === 102 /* NewKeyword */ && node.name.escapedText === "target") { + if (node.keywordToken === 103 /* NewKeyword */ && node.name.escapedText === "target") { hierarchyFacts |= 16384 /* NewTarget */; return factory.createUniqueName("_newTarget", 16 /* Optimistic */ | 32 /* FileLevel */); } @@ -92074,7 +95514,7 @@ var ts; function enableSubstitutionsForBlockScopedBindings() { if ((enabledSubstitutions & 2 /* BlockScopedBindings */) === 0) { enabledSubstitutions |= 2 /* BlockScopedBindings */; - context.enableSubstitution(78 /* Identifier */); + context.enableSubstitution(79 /* Identifier */); } } /** @@ -92084,14 +95524,14 @@ var ts; function enableSubstitutionsForCapturedThis() { if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { enabledSubstitutions |= 1 /* CapturedThis */; - context.enableSubstitution(107 /* ThisKeyword */); - context.enableEmitNotification(166 /* Constructor */); - context.enableEmitNotification(165 /* MethodDeclaration */); - context.enableEmitNotification(167 /* GetAccessor */); - context.enableEmitNotification(168 /* SetAccessor */); - context.enableEmitNotification(209 /* ArrowFunction */); - context.enableEmitNotification(208 /* FunctionExpression */); - context.enableEmitNotification(251 /* FunctionDeclaration */); + context.enableSubstitution(108 /* ThisKeyword */); + context.enableEmitNotification(168 /* Constructor */); + context.enableEmitNotification(167 /* MethodDeclaration */); + context.enableEmitNotification(169 /* GetAccessor */); + context.enableEmitNotification(170 /* SetAccessor */); + context.enableEmitNotification(211 /* ArrowFunction */); + context.enableEmitNotification(210 /* FunctionExpression */); + context.enableEmitNotification(253 /* FunctionDeclaration */); } } /** @@ -92132,10 +95572,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 198 /* BindingElement */: - case 252 /* ClassDeclaration */: - case 255 /* EnumDeclaration */: - case 249 /* VariableDeclaration */: + case 200 /* BindingElement */: + case 254 /* ClassDeclaration */: + case 257 /* EnumDeclaration */: + case 251 /* VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -92148,9 +95588,9 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return substituteExpressionIdentifier(node); - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: return substituteThisKeyword(node); } return node; @@ -92217,19 +95657,19 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 233 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 235 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 203 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 205 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 105 /* SuperKeyword */) { + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 106 /* SuperKeyword */) { return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 220 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 222 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -92255,15 +95695,15 @@ var ts; if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(275 /* JsxOpeningElement */); - context.enableEmitNotification(276 /* JsxClosingElement */); - context.enableEmitNotification(274 /* JsxSelfClosingElement */); + context.enableEmitNotification(277 /* JsxOpeningElement */); + context.enableEmitNotification(278 /* JsxClosingElement */); + context.enableEmitNotification(276 /* JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(201 /* PropertyAccessExpression */); - context.enableSubstitution(288 /* PropertyAssignment */); + context.enableSubstitution(203 /* PropertyAccessExpression */); + context.enableSubstitution(290 /* PropertyAssignment */); return ts.chainBundle(context, transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -92282,9 +95722,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 275 /* JsxOpeningElement */: - case 276 /* JsxClosingElement */: - case 274 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: + case 278 /* JsxClosingElement */: + case 276 /* JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -92344,7 +95784,7 @@ var ts; */ function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined); - if (token !== undefined && token >= 80 /* FirstReservedWord */ && token <= 115 /* LastReservedWord */) { + if (token !== undefined && token >= 81 /* FirstReservedWord */ && token <= 116 /* LastReservedWord */) { return ts.setTextRange(factory.createStringLiteralFromNode(name), name); } return undefined; @@ -92582,7 +96022,7 @@ var ts; var withBlockStack; // A stack containing `with` blocks. return ts.chainBundle(context, transformSourceFile); function transformSourceFile(node) { - if (node.isDeclarationFile || (node.transformFlags & 512 /* ContainsGenerator */) === 0) { + if (node.isDeclarationFile || (node.transformFlags & 1024 /* ContainsGenerator */) === 0) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -92605,7 +96045,7 @@ var ts; else if (ts.isFunctionLikeDeclaration(node) && node.asteriskToken) { return visitGenerator(node); } - else if (transformFlags & 512 /* ContainsGenerator */) { + else if (transformFlags & 1024 /* ContainsGenerator */) { return ts.visitEachChild(node, visitor, context); } else { @@ -92619,13 +96059,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 235 /* DoStatement */: + case 237 /* DoStatement */: return visitDoStatement(node); - case 236 /* WhileStatement */: + case 238 /* WhileStatement */: return visitWhileStatement(node); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: return visitSwitchStatement(node); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -92638,30 +96078,30 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: return visitFunctionExpression(node); - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return visitAccessorDeclaration(node); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return visitVariableStatement(node); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return visitForStatement(node); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return visitForInStatement(node); - case 241 /* BreakStatement */: + case 243 /* BreakStatement */: return visitBreakStatement(node); - case 240 /* ContinueStatement */: + case 242 /* ContinueStatement */: return visitContinueStatement(node); - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: return visitReturnStatement(node); default: - if (node.transformFlags & 262144 /* ContainsYield */) { + if (node.transformFlags & 524288 /* ContainsYield */) { return visitJavaScriptContainingYield(node); } - else if (node.transformFlags & (512 /* ContainsGenerator */ | 1048576 /* ContainsHoistedDeclarationOrCompletion */)) { + else if (node.transformFlags & (1024 /* ContainsGenerator */ | 2097152 /* ContainsHoistedDeclarationOrCompletion */)) { return ts.visitEachChild(node, visitor, context); } else { @@ -92676,23 +96116,23 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return visitBinaryExpression(node); - case 337 /* CommaListExpression */: + case 345 /* CommaListExpression */: return visitCommaListExpression(node); - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: return visitConditionalExpression(node); - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: return visitYieldExpression(node); - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return visitCallExpression(node); - case 204 /* NewExpression */: + case 206 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -92705,9 +96145,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -92866,7 +96306,7 @@ var ts; * @param node The node to visit. */ function visitVariableStatement(node) { - if (node.transformFlags & 262144 /* ContainsYield */) { + if (node.transformFlags & 524288 /* ContainsYield */) { transformAndEmitVariableDeclarationList(node.declarationList); return undefined; } @@ -92915,7 +96355,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -92927,7 +96367,7 @@ var ts; // _a.b = %sent%; target = factory.updatePropertyAccessExpression(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -93321,35 +96761,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 230 /* Block */: + case 232 /* Block */: return transformAndEmitBlock(node); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 234 /* IfStatement */: + case 236 /* IfStatement */: return transformAndEmitIfStatement(node); - case 235 /* DoStatement */: + case 237 /* DoStatement */: return transformAndEmitDoStatement(node); - case 236 /* WhileStatement */: + case 238 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return transformAndEmitForStatement(node); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 240 /* ContinueStatement */: + case 242 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 241 /* BreakStatement */: + case 243 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 243 /* WithStatement */: + case 245 /* WithStatement */: return transformAndEmitWithStatement(node); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 246 /* ThrowStatement */: + case 248 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 247 /* TryStatement */: + case 249 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -93569,7 +97009,7 @@ var ts; var variables = ts.getInitializedVariables(initializer); node = factory.updateForStatement(node, variables.length > 0 ? factory.inlineExpressions(ts.map(variables, transformInitializedVariable)) - : undefined, ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitor, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock)); + : undefined, ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitor, ts.isExpression), ts.visitIterationBody(node.statement, visitor, context)); } else { node = ts.visitEachChild(node, visitor, context); @@ -93779,7 +97219,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 285 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 287 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -93792,7 +97232,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 284 /* CaseClause */) { + if (clause.kind === 286 /* CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -93924,7 +97364,7 @@ var ts; } } function containsYield(node) { - return !!node && (node.transformFlags & 262144 /* ContainsYield */) !== 0; + return !!node && (node.transformFlags & 524288 /* ContainsYield */) !== 0; } function countInitialNodesWithoutYield(nodes) { var numNodes = nodes.length; @@ -93957,10 +97397,10 @@ var ts; var name = renamedCatchVariableDeclarations[ts.getOriginalNodeId(declaration)]; if (name) { // TODO(rbuckton): Does this need to be parented? - var clone_5 = ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent); - ts.setSourceMapRange(clone_5, node); - ts.setCommentRange(clone_5, node); - return clone_5; + var clone_6 = ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent); + ts.setSourceMapRange(clone_6, node); + ts.setCommentRange(clone_6, node); + return clone_6; } } } @@ -94106,7 +97546,7 @@ var ts; if (!renamedCatchVariables) { renamedCatchVariables = new ts.Map(); renamedCatchVariableDeclarations = []; - context.enableSubstitution(78 /* Identifier */); + context.enableSubstitution(79 /* Identifier */); } renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; @@ -94952,12 +98392,12 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(78 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(216 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(214 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(215 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(289 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(297 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(79 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. + context.enableSubstitution(218 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(216 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(217 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(291 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(299 /* 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. @@ -94973,7 +98413,7 @@ var ts; function transformSourceFile(node) { if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || - node.transformFlags & 2097152 /* ContainsDynamicImport */ || + node.transformFlags & 4194304 /* ContainsDynamicImport */ || (ts.isJsonSourceFile(node) && ts.hasJsonModuleEmitEnabled(compilerOptions) && ts.outFile(compilerOptions)))) { return node; } @@ -95285,23 +98725,23 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return visitImportDeclaration(node); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: return visitExportDeclaration(node); - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return visitExportAssignment(node); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return visitVariableStatement(node); - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: return visitClassDeclaration(node); - case 338 /* MergeDeclarationMarker */: + case 346 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 339 /* EndOfDeclarationMarker */: + case 347 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -95310,7 +98750,7 @@ var ts; function moduleExpressionElementVisitor(node) { // This visitor does not need to descend into the tree if there is no dynamic import or destructuring assignment, // as export/import statements are only transformed at the top level of a file. - if (!(node.transformFlags & 2097152 /* ContainsDynamicImport */) && !(node.transformFlags & 1024 /* ContainsDestructuringAssignment */)) { + if (!(node.transformFlags & 4194304 /* ContainsDynamicImport */) && !(node.transformFlags & 2048 /* ContainsDestructuringAssignment */)) { return node; } if (ts.isImportCall(node)) { @@ -95328,24 +98768,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 290 /* SpreadAssignment */: + case 292 /* SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -95380,7 +98820,7 @@ var ts; var firstArgument = ts.visitNode(ts.firstOrUndefined(node.arguments), moduleExpressionElementVisitor); // 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 & 4096 /* ContainsLexicalThis */); + var containsLexicalThis = !!(node.transformFlags & 8192 /* ContainsLexicalThis */); switch (compilerOptions.module) { case ts.ModuleKind.AMD: return createImportCallExpressionAMD(argument, containsLexicalThis); @@ -95873,7 +99313,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 232 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 234 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -95928,10 +99368,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 264 /* NamedImports */: + case 266 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding, /* liveBinding */ true); @@ -96127,8 +99567,8 @@ var ts; function modifierVisitor(node) { // Elide module-specific modifiers. switch (node.kind) { - case 92 /* ExportKeyword */: - case 87 /* DefaultKeyword */: + case 93 /* ExportKeyword */: + case 88 /* DefaultKeyword */: return undefined; } return node; @@ -96144,7 +99584,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 297 /* SourceFile */) { + if (node.kind === 299 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -96206,12 +99646,12 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return substituteExpressionIdentifier(node); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return substituteBinaryExpression(node); - case 215 /* PostfixUnaryExpression */: - case 214 /* PrefixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -96231,9 +99671,9 @@ var ts; } return node; } - if (!(ts.isGeneratedIdentifier(node) && !(node.autoGenerateFlags & 64 /* AllowNameSubstitution */)) && !ts.isLocalName(node)) { + else if (!(ts.isGeneratedIdentifier(node) && !(node.autoGenerateFlags & 64 /* AllowNameSubstitution */)) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 297 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 299 /* SourceFile */) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.cloneNode(node)), /*location*/ node); } @@ -96308,8 +99748,8 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 215 /* PostfixUnaryExpression */ - ? ts.setTextRange(factory.createBinaryExpression(node.operand, factory.createToken(node.operator === 45 /* PlusPlusToken */ ? 63 /* PlusEqualsToken */ : 64 /* MinusEqualsToken */), factory.createNumericLiteral(1)), + var expression = node.kind === 217 /* PostfixUnaryExpression */ + ? ts.setTextRange(factory.createPrefixUnaryExpression(node.operator, node.operand), /*location*/ node) : node; for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) { @@ -96318,6 +99758,12 @@ var ts; noSubstitution[ts.getNodeId(expression)] = true; expression = createExportExpression(exportName, expression); } + if (node.kind === 217 /* PostfixUnaryExpression */) { + noSubstitution[ts.getNodeId(expression)] = true; + expression = node.operator === 45 /* PlusPlusToken */ + ? factory.createSubtract(expression, factory.createNumericLiteral(1)) + : factory.createAdd(expression, factory.createNumericLiteral(1)); + } return expression; } } @@ -96359,13 +99805,13 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(78 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(289 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols - context.enableSubstitution(216 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(214 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(215 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(226 /* MetaProperty */); // Substitutes 'import.meta' - context.enableEmitNotification(297 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(79 /* Identifier */); // Substitutes expression identifiers for imported symbols. + context.enableSubstitution(291 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(218 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(216 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(217 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(228 /* MetaProperty */); // Substitutes 'import.meta' + context.enableEmitNotification(299 /* 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. @@ -96385,7 +99831,7 @@ var ts; * @param node The SourceFile node. */ function transformSourceFile(node) { - if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 2097152 /* ContainsDynamicImport */)) { + if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 4194304 /* ContainsDynamicImport */)) { return node; } var id = ts.getOriginalNodeId(node); @@ -96554,7 +100000,7 @@ 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 & 524288 /* ContainsAwait */ ? + var modifiers = node.transformFlags & 1048576 /* ContainsAwait */ ? factory.createModifiersFromModifierFlags(256 /* Async */) : undefined; var moduleObject = factory.createObjectLiteralExpression([ @@ -96589,7 +100035,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 267 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 269 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -96679,19 +100125,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(factory, entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(factory.createExpressionStatement(factory.createAssignment(importVariableName, parameterName))); break; - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { if (ts.isNamedExports(entry.exportClause)) { @@ -96750,13 +100196,13 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return visitImportDeclaration(node); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: return visitExportDeclaration(node); - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -96936,7 +100382,7 @@ 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 === 297 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 299 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -97000,7 +100446,7 @@ 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 === 232 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 234 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasSyntacticModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -97062,10 +100508,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 264 /* NamedImports */: + case 266 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -97245,43 +100691,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return visitVariableStatement(node); - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: return visitClassDeclaration(node); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return visitForStatement(node); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return visitForInStatement(node); - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: return visitForOfStatement(node); - case 235 /* DoStatement */: + case 237 /* DoStatement */: return visitDoStatement(node); - case 236 /* WhileStatement */: + case 238 /* WhileStatement */: return visitWhileStatement(node); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return visitLabeledStatement(node); - case 243 /* WithStatement */: + case 245 /* WithStatement */: return visitWithStatement(node); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: return visitSwitchStatement(node); - case 258 /* CaseBlock */: + case 260 /* CaseBlock */: return visitCaseBlock(node); - case 284 /* CaseClause */: + case 286 /* CaseClause */: return visitCaseClause(node); - case 285 /* DefaultClause */: + case 287 /* DefaultClause */: return visitDefaultClause(node); - case 247 /* TryStatement */: + case 249 /* TryStatement */: return visitTryStatement(node); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return visitCatchClause(node); - case 230 /* Block */: + case 232 /* Block */: return visitBlock(node); - case 338 /* MergeDeclarationMarker */: + case 346 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 339 /* EndOfDeclarationMarker */: + case 347 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -97295,7 +100741,7 @@ var ts; function visitForStatement(node) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = factory.updateForStatement(node, node.initializer && visitForInitializer(node.initializer), ts.visitNode(node.condition, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.incrementor, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement)); + node = factory.updateForStatement(node, node.initializer && visitForInitializer(node.initializer), ts.visitNode(node.condition, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.incrementor, destructuringAndImportCallVisitor, ts.isExpression), ts.visitIterationBody(node.statement, nestedElementVisitor, context)); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } @@ -97307,7 +100753,7 @@ var ts; function visitForInStatement(node) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = factory.updateForInStatement(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock)); + node = factory.updateForInStatement(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitIterationBody(node.statement, nestedElementVisitor, context)); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } @@ -97319,7 +100765,7 @@ var ts; function visitForOfStatement(node) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = factory.updateForOfStatement(node, node.awaitModifier, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock)); + node = factory.updateForOfStatement(node, node.awaitModifier, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitIterationBody(node.statement, nestedElementVisitor, context)); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } @@ -97360,7 +100806,7 @@ var ts; * @param node The node to visit. */ function visitDoStatement(node) { - return factory.updateDoStatement(node, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression)); + return factory.updateDoStatement(node, ts.visitIterationBody(node.statement, nestedElementVisitor, context), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression)); } /** * Visits the body of a WhileStatement to hoist declarations. @@ -97368,7 +100814,7 @@ var ts; * @param node The node to visit. */ function visitWhileStatement(node) { - return factory.updateWhileStatement(node, ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock)); + return factory.updateWhileStatement(node, ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitIterationBody(node.statement, nestedElementVisitor, context)); } /** * Visits the body of a LabeledStatement to hoist declarations. @@ -97469,7 +100915,7 @@ var ts; else if (ts.isImportCall(node)) { return visitImportCallExpression(node); } - else if ((node.transformFlags & 1024 /* ContainsDestructuringAssignment */) || (node.transformFlags & 2097152 /* ContainsDynamicImport */)) { + else if ((node.transformFlags & 2048 /* ContainsDestructuringAssignment */) || (node.transformFlags & 4194304 /* ContainsDynamicImport */)) { return ts.visitEachChild(node, destructuringAndImportCallVisitor, context); } else { @@ -97507,7 +100953,7 @@ var ts; return ts.visitEachChild(node, destructuringAndImportCallVisitor, context); } /** - * Determines whether the target of a destructuring assigment refers to an exported symbol. + * Determines whether the target of a destructuring assignment refers to an exported symbol. * * @param node The destructuring target. */ @@ -97532,7 +100978,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 297 /* SourceFile */; + return container !== undefined && container.kind === 299 /* SourceFile */; } else { return false; @@ -97548,8 +100994,8 @@ var ts; */ function modifierVisitor(node) { switch (node.kind) { - case 92 /* ExportKeyword */: - case 87 /* DefaultKeyword */: + case 93 /* ExportKeyword */: + case 88 /* DefaultKeyword */: return undefined; } return node; @@ -97565,7 +101011,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 297 /* SourceFile */) { + if (node.kind === 299 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -97615,7 +101061,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -97650,14 +101096,14 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return substituteExpressionIdentifier(node); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return substituteBinaryExpression(node); - case 214 /* PrefixUnaryExpression */: - case 215 /* PostfixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: return substituteUnaryExpression(node); - case 226 /* MetaProperty */: + case 228 /* MetaProperty */: return substituteMetaProperty(node); } return node; @@ -97751,14 +101197,14 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 215 /* PostfixUnaryExpression */ + var expression = node.kind === 217 /* PostfixUnaryExpression */ ? ts.setTextRange(factory.createPrefixUnaryExpression(node.operator, node.operand), node) : node; for (var _i = 0, exportedNames_5 = exportedNames; _i < exportedNames_5.length; _i++) { var exportName = exportedNames_5[_i]; expression = createExportExpression(exportName, preventSubstitution(expression)); } - if (node.kind === 215 /* PostfixUnaryExpression */) { + if (node.kind === 217 /* PostfixUnaryExpression */) { expression = node.operator === 45 /* PlusPlusToken */ ? factory.createSubtract(preventSubstitution(expression), factory.createNumericLiteral(1)) : factory.createAdd(preventSubstitution(expression), factory.createNumericLiteral(1)); @@ -97786,7 +101232,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 297 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 299 /* SourceFile */) { exportedNames = ts.append(exportedNames, factory.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -97826,8 +101272,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(297 /* SourceFile */); - context.enableSubstitution(78 /* Identifier */); + context.enableEmitNotification(299 /* SourceFile */); + context.enableSubstitution(79 /* Identifier */); var helperNameSubstitutions; return ts.chainBundle(context, transformSourceFile); function transformSourceFile(node) { @@ -97858,12 +101304,12 @@ var ts; } function visitor(node) { switch (node.kind) { - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: // Elide `import=` as it is not legal with --module ES6 return undefined; - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return visitExportAssignment(node); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: var exportDecl = node; return visitExportDeclaration(exportDecl); } @@ -97968,7 +101414,8 @@ var ts; ts.isTypeAliasDeclaration(node) || ts.isConstructorDeclaration(node) || ts.isIndexSignatureDeclaration(node) || - ts.isPropertyAccessExpression(node); + ts.isPropertyAccessExpression(node) || + ts.isJSDocTypeAlias(node); } ts.canProduceDiagnostics = canProduceDiagnostics; function createGetSymbolAccessibilityDiagnosticForNodeName(node) { @@ -97997,7 +101444,7 @@ var ts; 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 === 252 /* ClassDeclaration */) { + else if (node.parent.kind === 254 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -98026,7 +101473,7 @@ var ts; 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 === 252 /* ClassDeclaration */) { + else if (node.parent.kind === 254 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -98066,14 +101513,14 @@ var ts; else if (ts.isImportEqualsDeclaration(node)) { return getImportEntityNameVisibilityError; } - else if (ts.isTypeAliasDeclaration(node)) { + else if (ts.isTypeAliasDeclaration(node) || ts.isJSDocTypeAlias(node)) { return getTypeAliasDeclarationVisibilityError; } else { return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]); } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 249 /* VariableDeclaration */ || node.kind === 198 /* BindingElement */) { + if (node.kind === 251 /* VariableDeclaration */ || node.kind === 200 /* BindingElement */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -98082,8 +101529,8 @@ var ts; } // 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 === 163 /* PropertyDeclaration */ || node.kind === 201 /* PropertyAccessExpression */ || node.kind === 162 /* PropertySignature */ || - (node.kind === 160 /* Parameter */ && ts.hasSyntacticModifier(node.parent, 8 /* Private */))) { + else if (node.kind === 165 /* PropertyDeclaration */ || node.kind === 203 /* PropertyAccessExpression */ || node.kind === 164 /* PropertySignature */ || + (node.kind === 162 /* Parameter */ && ts.hasSyntacticModifier(node.parent, 8 /* Private */))) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.hasSyntacticModifier(node, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? @@ -98092,7 +101539,7 @@ var ts; 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 === 252 /* ClassDeclaration */ || node.kind === 160 /* Parameter */) { + else if (node.parent.kind === 254 /* ClassDeclaration */ || node.kind === 162 /* Parameter */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -98117,7 +101564,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 168 /* SetAccessor */) { + if (node.kind === 170 /* 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.hasSyntacticModifier(node, 32 /* Static */)) { @@ -98156,26 +101603,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 170 /* ConstructSignature */: + case 172 /* 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 169 /* CallSignature */: + case 171 /* 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 171 /* IndexSignature */: + case 173 /* 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 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: if (ts.hasSyntacticModifier(node, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -98183,7 +101630,7 @@ var ts; 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 === 252 /* ClassDeclaration */) { + else if (node.parent.kind === 254 /* ClassDeclaration */) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* 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 : @@ -98197,7 +101644,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -98222,30 +101669,30 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 166 /* Constructor */: + case 168 /* Constructor */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* 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 170 /* ConstructSignature */: - case 175 /* ConstructorType */: + case 172 /* ConstructSignature */: + case 177 /* 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 169 /* CallSignature */: + case 171 /* 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 171 /* IndexSignature */: + case 173 /* 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 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: if (ts.hasSyntacticModifier(node.parent, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -98253,7 +101700,7 @@ var ts; 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 === 252 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 254 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* 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 : @@ -98266,15 +101713,15 @@ 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 251 /* FunctionDeclaration */: - case 174 /* FunctionType */: + case 253 /* FunctionDeclaration */: + case 176 /* FunctionType */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* 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 168 /* SetAccessor */: - case 167 /* GetAccessor */: + case 170 /* SetAccessor */: + case 169 /* GetAccessor */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -98288,39 +101735,39 @@ var ts; // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 253 /* InterfaceDeclaration */: + case 255 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 190 /* MappedType */: + case 192 /* MappedType */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1; break; - case 175 /* ConstructorType */: - case 170 /* ConstructSignature */: + case 177 /* ConstructorType */: + case 172 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 169 /* CallSignature */: + case 171 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: if (ts.hasSyntacticModifier(node.parent, 32 /* Static */)) { 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 === 252 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 254 /* 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 174 /* FunctionType */: - case 251 /* FunctionDeclaration */: + case 176 /* FunctionType */: + case 253 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -98337,7 +101784,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 === 116 /* ImplementsKeyword */ ? + diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 117 /* 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; @@ -98359,11 +101806,13 @@ var ts; typeName: node.name }; } - function getTypeAliasDeclarationVisibilityError() { + function getTypeAliasDeclarationVisibilityError(symbolAccessibilityResult) { return { - diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, - errorNode: node.type, - typeName: node.name + diagnosticMessage: symbolAccessibilityResult.errorModuleName + ? ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1_from_module_2 + : ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, + errorNode: ts.isJSDocTypeAlias(node) ? ts.Debug.checkDefined(node.typeExpression) : node.type, + typeName: ts.isJSDocTypeAlias(node) ? ts.getNameOfDeclaration(node) : node.name, }; } } @@ -98384,7 +101833,7 @@ var ts; } function isInternalDeclaration(node, currentSourceFile) { var parseTreeNode = ts.getParseTreeNode(node); - if (parseTreeNode && parseTreeNode.kind === 160 /* Parameter */) { + if (parseTreeNode && parseTreeNode.kind === 162 /* Parameter */) { var paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode); var previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : undefined; var text = currentSourceFile.text; @@ -98446,6 +101895,7 @@ var ts; reportNonlocalAugmentation: reportNonlocalAugmentation }; var errorNameNode; + var errorFallbackNode; var currentSourceFile; var refs; var libs; @@ -98500,8 +101950,10 @@ var ts; else { context.addDiagnostic(ts.createDiagnosticForNode(symbolAccessibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, symbolAccessibilityResult.errorSymbolName, symbolAccessibilityResult.errorModuleName)); } + return true; } } + return false; } function trackExternalModuleSymbolOfImportTypeNode(symbol) { if (!isBundledEmit) { @@ -98510,13 +101962,14 @@ var ts; } function trackSymbol(symbol, enclosingDeclaration, meaning) { if (symbol.flags & 262144 /* TypeParameter */) - return; - handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, /*shouldComputeAliasesToMakeVisible*/ true)); + return false; + var issuedDiagnostic = handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, /*shouldComputeAliasesToMakeVisible*/ true)); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForSymbol(symbol, meaning)); + return issuedDiagnostic; } function reportPrivateInBaseOfClassExpression(propertyName) { - if (errorNameNode) { - context.addDiagnostic(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.Property_0_of_exported_class_expression_may_not_be_private_or_protected, propertyName)); + if (errorNameNode || errorFallbackNode) { + context.addDiagnostic(ts.createDiagnosticForNode((errorNameNode || errorFallbackNode), ts.Diagnostics.Property_0_of_exported_class_expression_may_not_be_private_or_protected, propertyName)); } } function reportInaccessibleUniqueSymbolError() { @@ -98540,35 +101993,38 @@ var ts; } } function reportTruncationError() { - if (errorNameNode) { - context.addDiagnostic(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_this_node_exceeds_the_maximum_length_the_compiler_will_serialize_An_explicit_type_annotation_is_needed)); + if (errorNameNode || errorFallbackNode) { + context.addDiagnostic(ts.createDiagnosticForNode((errorNameNode || errorFallbackNode), ts.Diagnostics.The_inferred_type_of_this_node_exceeds_the_maximum_length_the_compiler_will_serialize_An_explicit_type_annotation_is_needed)); } } function reportNonlocalAugmentation(containingFile, parentSymbol, symbol) { - var primaryDeclaration = ts.find(parentSymbol.declarations, function (d) { return ts.getSourceFileOfNode(d) === containingFile; }); + var _a; + var primaryDeclaration = (_a = parentSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.getSourceFileOfNode(d) === containingFile; }); var augmentingDeclarations = ts.filter(symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== containingFile; }); - for (var _i = 0, augmentingDeclarations_1 = augmentingDeclarations; _i < augmentingDeclarations_1.length; _i++) { - var augmentations = augmentingDeclarations_1[_i]; - context.addDiagnostic(ts.addRelatedInfo(ts.createDiagnosticForNode(augmentations, ts.Diagnostics.Declaration_augments_declaration_in_another_file_This_cannot_be_serialized), ts.createDiagnosticForNode(primaryDeclaration, ts.Diagnostics.This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_file))); + if (augmentingDeclarations) { + for (var _i = 0, augmentingDeclarations_1 = augmentingDeclarations; _i < augmentingDeclarations_1.length; _i++) { + var augmentations = augmentingDeclarations_1[_i]; + context.addDiagnostic(ts.addRelatedInfo(ts.createDiagnosticForNode(augmentations, ts.Diagnostics.Declaration_augments_declaration_in_another_file_This_cannot_be_serialized), ts.createDiagnosticForNode(primaryDeclaration, ts.Diagnostics.This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_file))); + } } } function transformDeclarationsForJS(sourceFile, bundled) { var oldDiag = getSymbolAccessibilityDiagnostic; - getSymbolAccessibilityDiagnostic = function (s) { return ({ + getSymbolAccessibilityDiagnostic = function (s) { return (s.errorNode && ts.canProduceDiagnostics(s.errorNode) ? ts.createGetSymbolAccessibilityDiagnosticForNode(s.errorNode)(s) : ({ diagnosticMessage: s.errorModuleName ? ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit : ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit, errorNode: s.errorNode || sourceFile - }); }; + })); }; var result = resolver.getDeclarationStatementsForSourceFile(sourceFile, declarationEmitNodeBuilderFlags, symbolTracker, bundled); getSymbolAccessibilityDiagnostic = oldDiag; return result; } function transformRoot(node) { - if (node.kind === 297 /* SourceFile */ && node.isDeclarationFile) { + if (node.kind === 299 /* SourceFile */ && node.isDeclarationFile) { return node; } - if (node.kind === 298 /* Bundle */) { + if (node.kind === 300 /* Bundle */) { isBundledEmit = true; refs = new ts.Map(); libs = new ts.Map(); @@ -98591,14 +102047,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(133 /* 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(134 /* 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 === 300 /* InputFiles */) { + if (prepend.kind === 302 /* InputFiles */) { var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal); hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib; collectReferences(sourceFile, refs); @@ -98690,7 +102146,7 @@ var ts; declFileName = paths.declarationFilePath || paths.jsFilePath || file.fileName; } if (declFileName) { - var specifier = ts.moduleSpecifiers.getModuleSpecifier(__assign(__assign({}, options), { baseUrl: options.baseUrl && ts.toPath(options.baseUrl, host.getCurrentDirectory(), host.getCanonicalFileName) }), currentSourceFile, ts.toPath(outputFilePath, host.getCurrentDirectory(), host.getCanonicalFileName), ts.toPath(declFileName, host.getCurrentDirectory(), host.getCanonicalFileName), host, + var specifier = ts.moduleSpecifiers.getModuleSpecifier(options, currentSourceFile, ts.toPath(outputFilePath, host.getCurrentDirectory(), host.getCanonicalFileName), ts.toPath(declFileName, host.getCurrentDirectory(), host.getCanonicalFileName), host, /*preferences*/ undefined); if (!ts.pathIsRelative(specifier)) { // If some compiler option/symlink/whatever allows access to the file containing the ambient module declaration @@ -98735,11 +102191,11 @@ var ts; return ret; } function filterBindingPatternInitializers(name) { - if (name.kind === 78 /* Identifier */) { + if (name.kind === 79 /* Identifier */) { return name; } else { - if (name.kind === 197 /* ArrayBindingPattern */) { + if (name.kind === 199 /* ArrayBindingPattern */) { return factory.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -98747,7 +102203,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 222 /* OmittedExpression */) { + if (elem.kind === 224 /* OmittedExpression */) { return elem; } return factory.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); @@ -98785,19 +102241,19 @@ var ts; // Literal const declarations will have an initializer ensured rather than a type return; } - var shouldUseResolverType = node.kind === 160 /* Parameter */ && + var shouldUseResolverType = node.kind === 162 /* 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(128 /* AnyKeyword */); + return type ? ts.visitNode(type, visitDeclarationSubtree) : factory.createKeywordTypeNode(129 /* AnyKeyword */); } - if (node.kind === 168 /* SetAccessor */) { + if (node.kind === 170 /* 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(128 /* AnyKeyword */); + return factory.createKeywordTypeNode(129 /* AnyKeyword */); } errorNameNode = node.name; var oldDiag; @@ -98805,12 +102261,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 249 /* VariableDeclaration */ || node.kind === 198 /* BindingElement */) { + if (node.kind === 251 /* VariableDeclaration */ || node.kind === 200 /* BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 160 /* Parameter */ - || node.kind === 163 /* PropertyDeclaration */ - || node.kind === 162 /* PropertySignature */) { + if (node.kind === 162 /* Parameter */ + || node.kind === 165 /* PropertyDeclaration */ + || node.kind === 164 /* PropertySignature */) { if (!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)); @@ -98821,30 +102277,39 @@ var ts; if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } - return returnValue || factory.createKeywordTypeNode(128 /* AnyKeyword */); + return returnValue || factory.createKeywordTypeNode(129 /* AnyKeyword */); } } function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 256 /* ModuleDeclaration */: - case 253 /* InterfaceDeclaration */: - case 252 /* ClassDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 255 /* EnumDeclaration */: + case 253 /* FunctionDeclaration */: + case 258 /* ModuleDeclaration */: + case 255 /* InterfaceDeclaration */: + case 254 /* ClassDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 257 /* EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return !getBindingNameVisible(node); - case 260 /* ImportEqualsDeclaration */: - case 261 /* ImportDeclaration */: - case 267 /* ExportDeclaration */: - case 266 /* ExportAssignment */: + case 262 /* ImportEqualsDeclaration */: + case 263 /* ImportDeclaration */: + case 269 /* ExportDeclaration */: + case 268 /* ExportAssignment */: return false; } return false; } + // If the ExpandoFunctionDeclaration have multiple overloads, then we only need to emit properties for the last one. + function shouldEmitFunctionProperties(input) { + var _a; + if (input.body) { + return true; + } + var overloadSignatures = (_a = input.symbol.declarations) === null || _a === void 0 ? void 0 : _a.filter(function (decl) { return ts.isFunctionDeclaration(decl) && !decl.body; }); + return !overloadSignatures || overloadSignatures.indexOf(input) === overloadSignatures.length - 1; + } function getBindingNameVisible(elem) { if (ts.isOmittedExpression(elem)) { return false; @@ -98921,7 +102386,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 256 /* ModuleDeclaration */ && parent.kind !== 195 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 258 /* ModuleDeclaration */ && parent.kind !== 197 /* ImportType */); if (ts.isStringLiteralLike(input)) { if (isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); @@ -98941,7 +102406,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 272 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 274 /* ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return factory.updateImportEqualsDeclaration(decl, @@ -98968,7 +102433,7 @@ var ts; return visibleDefaultBinding && factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier)); } - if (decl.importClause.namedBindings.kind === 263 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 265 /* 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, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier)) : undefined; @@ -99063,7 +102528,7 @@ var ts; // We'd see a TDZ violation at runtime var canProduceDiagnostic = ts.canProduceDiagnostics(input); var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 177 /* TypeLiteral */ || input.kind === 190 /* MappedType */) && input.parent.kind !== 254 /* TypeAliasDeclaration */); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 179 /* TypeLiteral */ || input.kind === 192 /* MappedType */) && input.parent.kind !== 256 /* 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 */)) { @@ -99084,21 +102549,21 @@ var ts; } if (isProcessedComponent(input)) { switch (input.kind) { - case 223 /* ExpressionWithTypeArguments */: { + case 225 /* 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 173 /* TypeReference */: { + case 175 /* TypeReference */: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(factory.updateTypeReferenceNode(node, node.typeName, node.typeArguments)); } - case 170 /* ConstructSignature */: + case 172 /* ConstructSignature */: return cleanup(factory.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 166 /* Constructor */: { + case 168 /* Constructor */: { // A constructor declaration may not have a type annotation var ctor = factory.createConstructorDeclaration( /*decorators*/ undefined, @@ -99106,7 +102571,7 @@ var ts; /*body*/ undefined); return cleanup(ctor); } - case 165 /* MethodDeclaration */: { + case 167 /* MethodDeclaration */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } @@ -99116,7 +102581,7 @@ var ts; /*body*/ undefined); return cleanup(sig); } - case 167 /* GetAccessor */: { + case 169 /* GetAccessor */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } @@ -99125,7 +102590,7 @@ var ts; /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* Private */)), ensureType(input, accessorType), /*body*/ undefined)); } - case 168 /* SetAccessor */: { + case 170 /* SetAccessor */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } @@ -99133,31 +102598,31 @@ var ts; /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* Private */)), /*body*/ undefined)); } - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } return cleanup(factory.updatePropertyDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type), ensureNoInitializer(input))); - case 162 /* PropertySignature */: + case 164 /* 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 164 /* MethodSignature */: { + case 166 /* 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 169 /* CallSignature */: { + case 171 /* CallSignature */: { return cleanup(factory.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 171 /* IndexSignature */: { + case 173 /* IndexSignature */: { return cleanup(factory.updateIndexSignature(input, - /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || factory.createKeywordTypeNode(128 /* AnyKeyword */))); + /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || factory.createKeywordTypeNode(129 /* AnyKeyword */))); } - case 249 /* VariableDeclaration */: { + case 251 /* VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -99165,13 +102630,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 159 /* TypeParameter */: { + case 161 /* TypeParameter */: { if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) { return cleanup(factory.updateTypeParameterDeclaration(input, input.name, /*constraint*/ undefined, /*defaultType*/ undefined)); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 184 /* ConditionalType */: { + case 186 /* 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); @@ -99183,13 +102648,13 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(factory.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 174 /* FunctionType */: { + case 176 /* FunctionType */: { return cleanup(factory.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 175 /* ConstructorType */: { + case 177 /* ConstructorType */: { return cleanup(factory.updateConstructorTypeNode(input, ensureModifiers(input), ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 195 /* ImportType */: { + case 197 /* ImportType */: { if (!ts.isLiteralImportTypeNode(input)) return cleanup(input); return cleanup(factory.updateImportTypeNode(input, factory.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); @@ -99221,7 +102686,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 165 /* MethodDeclaration */ && ts.hasEffectiveModifier(node.parent, 8 /* Private */); + return node.parent.kind === 167 /* MethodDeclaration */ && ts.hasEffectiveModifier(node.parent, 8 /* Private */); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -99231,7 +102696,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 267 /* ExportDeclaration */: { + case 269 /* ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } @@ -99241,13 +102706,13 @@ var ts; return factory.updateExportDeclaration(input, /*decorators*/ undefined, input.modifiers, input.isTypeOnly, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 266 /* ExportAssignment */: { + case 268 /* 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 === 78 /* Identifier */) { + if (input.expression.kind === 79 /* Identifier */) { return input; } else { @@ -99256,8 +102721,10 @@ var ts; diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0, errorNode: input }); }; + errorFallbackNode = input; var varDecl = factory.createVariableDeclaration(newId, /*exclamationToken*/ undefined, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); - var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(133 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); + errorFallbackNode = undefined; + var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(134 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); return [statement, factory.updateExportAssignment(input, input.decorators, input.modifiers, newId)]; } } @@ -99273,17 +102740,17 @@ var ts; // 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) & (11263 /* All */ ^ 1 /* Export */)); + var modifiers = factory.createModifiersFromModifierFlags(ts.getEffectiveModifierFlags(statement) & (27647 /* All */ ^ 1 /* Export */)); return factory.updateModifiers(statement, modifiers); } function transformTopLevelDeclaration(input) { if (shouldStripInternal(input)) return; switch (input.kind) { - case 260 /* ImportEqualsDeclaration */: { + case 262 /* ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 261 /* ImportDeclaration */: { + case 263 /* ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -99304,20 +102771,20 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 254 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 256 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all return cleanup(factory.updateTypeAliasDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 253 /* InterfaceDeclaration */: { + case 255 /* InterfaceDeclaration */: { return cleanup(factory.updateInterfaceDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 251 /* FunctionDeclaration */: { + case 253 /* FunctionDeclaration */: { // Generators lose their generator-ness, excepting their return type var clean = cleanup(factory.updateFunctionDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), /*asteriskToken*/ undefined, input.name, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), /*body*/ undefined)); - if (clean && resolver.isExpandoFunctionDeclaration(input)) { + 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(/*decorators*/ undefined, /*modifiers*/ undefined, clean.name || factory.createIdentifier("_default"), factory.createModuleBlock([]), 16 /* Namespace */); @@ -99326,7 +102793,7 @@ var ts; fakespace_1.symbol = props[0].parent; var exportMappings_1 = []; var declarations = ts.mapDefined(props, function (p) { - if (!ts.isPropertyAccessExpression(p.valueDeclaration)) { + if (!p.valueDeclaration || !ts.isPropertyAccessExpression(p.valueDeclaration)) { return undefined; // TODO GH#33569: Handle element access expressions that created late bound names (rather than silently omitting them) } getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p.valueDeclaration); @@ -99339,7 +102806,7 @@ var ts; exportMappings_1.push([name, nameStr]); } var varDecl = factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, type, /*initializer*/ undefined); - return factory.createVariableStatement(isNonContextualKeywordName ? undefined : [factory.createToken(92 /* ExportKeyword */)], factory.createVariableDeclarationList([varDecl])); + return factory.createVariableStatement(isNonContextualKeywordName ? undefined : [factory.createToken(93 /* ExportKeyword */)], factory.createVariableDeclarationList([varDecl])); }); if (!exportMappings_1.length) { declarations = ts.mapDefined(declarations, function (declaration) { return factory.updateModifiers(declaration, 0 /* None */); }); @@ -99378,10 +102845,10 @@ var ts; return clean; } } - case 256 /* ModuleDeclaration */: { + case 258 /* ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 257 /* ModuleBlock */) { + if (inner && inner.kind === 259 /* ModuleBlock */) { var oldNeedsScopeFix = needsScopeFixMarker; var oldHasScopeFix = resultHasScopeMarker; resultHasScopeMarker = false; @@ -99424,7 +102891,9 @@ var ts; /*decorators*/ undefined, mods, input.name, body)); } } - case 252 /* ClassDeclaration */: { + case 254 /* ClassDeclaration */: { + errorNameNode = input.name; + errorFallbackNode = input; var modifiers = factory.createNodeArray(ensureModifiers(input)); var typeParameters = ensureTypeParams(input, input.typeParameters); var ctor = ts.getFirstConstructorWithBody(input); @@ -99432,10 +102901,10 @@ var ts; if (ctor) { var oldDiag_1 = getSymbolAccessibilityDiagnostic; parameterProperties = ts.compact(ts.flatMap(ctor.parameters, function (param) { - if (!ts.hasSyntacticModifier(param, 92 /* ParameterPropertyModifier */) || shouldStripInternal(param)) + if (!ts.hasSyntacticModifier(param, 16476 /* ParameterPropertyModifier */) || shouldStripInternal(param)) return; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(param); - if (param.name.kind === 78 /* Identifier */) { + if (param.name.kind === 79 /* Identifier */) { return preserveJsDoc(factory.createPropertyDeclaration( /*decorators*/ undefined, ensureModifiers(param), param.name, param.questionToken, ensureType(param, param.type), ensureNoInitializer(param)), param); } @@ -99477,7 +102946,7 @@ 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 !== 103 /* NullKeyword */) { + if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 104 /* 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 */); @@ -99487,16 +102956,16 @@ var ts; 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(133 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(134 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); var heritageClauses = factory.createNodeArray(ts.map(input.heritageClauses, function (clause) { - if (clause.token === 93 /* ExtendsKeyword */) { + if (clause.token === 94 /* 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 === 103 /* 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 /* NullKeyword */; })), visitDeclarationSubtree)); })); return [statement, cleanup(factory.updateClassDeclaration(input, /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members))]; // TODO: GH#18217 @@ -99507,10 +102976,10 @@ var ts; /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 232 /* VariableStatement */: { + case 234 /* VariableStatement */: { return cleanup(transformVariableStatement(input)); } - case 255 /* EnumDeclaration */: { + case 257 /* EnumDeclaration */: { return cleanup(factory.updateEnumDeclaration(input, /*decorators*/ undefined, factory.createNodeArray(ensureModifiers(input)), input.name, factory.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -99529,12 +102998,14 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 256 /* ModuleDeclaration */) { + if (input.kind === 258 /* ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { return node; } + errorFallbackNode = undefined; + errorNameNode = undefined; return node && ts.setOriginalNode(preserveJsDoc(node, input), input); } } @@ -99550,7 +103021,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 222 /* OmittedExpression */) { + if (e.kind === 224 /* OmittedExpression */) { return; } if (e.name) { @@ -99598,9 +103069,9 @@ var ts; return factory.createModifiersFromModifierFlags(newFlags); } function ensureModifierFlags(node) { - var mask = 11263 /* All */ ^ (4 /* Public */ | 256 /* Async */); // No async modifiers in declaration files + var mask = 27647 /* 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 === 297 /* SourceFile */; + var parentIsFile = node.parent.kind === 299 /* SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= 2 /* Ambient */; additions = 0 /* None */; @@ -99623,13 +103094,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 === 93 /* ExtendsKeyword */ && t.expression.kind === 103 /* NullKeyword */); + return ts.isEntityNameExpression(t.expression) || (clause.token === 94 /* ExtendsKeyword */ && t.expression.kind === 104 /* NullKeyword */); })), visitDeclarationSubtree)); }), function (clause) { return clause.types && !!clause.types.length; })); } } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 253 /* InterfaceDeclaration */) { + if (node.kind === 255 /* InterfaceDeclaration */) { return true; } return false; @@ -99639,7 +103110,7 @@ var ts; return ts.factory.createModifiersFromModifierFlags(maskModifierFlags(node, modifierMask, modifierAdditions)); } function maskModifierFlags(node, modifierMask, modifierAdditions) { - if (modifierMask === void 0) { modifierMask = 11263 /* All */ ^ 4 /* Public */; } + if (modifierMask === void 0) { modifierMask = 27647 /* All */ ^ 4 /* Public */; } if (modifierAdditions === void 0) { modifierAdditions = 0 /* None */; } var flags = (ts.getEffectiveModifierFlags(node) & modifierMask) | modifierAdditions; if (flags & 512 /* Default */ && !(flags & 1 /* Export */)) { @@ -99654,7 +103125,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 167 /* GetAccessor */ + return accessor.kind === 169 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -99663,52 +103134,52 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: return !ts.hasEffectiveModifier(node, 8 /* Private */); - case 160 /* Parameter */: - case 249 /* VariableDeclaration */: + case 162 /* Parameter */: + case 251 /* VariableDeclaration */: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 256 /* ModuleDeclaration */: - case 260 /* ImportEqualsDeclaration */: - case 253 /* InterfaceDeclaration */: - case 252 /* ClassDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 255 /* EnumDeclaration */: - case 232 /* VariableStatement */: - case 261 /* ImportDeclaration */: - case 267 /* ExportDeclaration */: - case 266 /* ExportAssignment */: + case 253 /* FunctionDeclaration */: + case 258 /* ModuleDeclaration */: + case 262 /* ImportEqualsDeclaration */: + case 255 /* InterfaceDeclaration */: + case 254 /* ClassDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 257 /* EnumDeclaration */: + case 234 /* VariableStatement */: + case 263 /* ImportDeclaration */: + case 269 /* ExportDeclaration */: + case 268 /* ExportAssignment */: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { - case 170 /* ConstructSignature */: - case 166 /* Constructor */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 164 /* MethodSignature */: - case 169 /* CallSignature */: - case 171 /* IndexSignature */: - case 249 /* VariableDeclaration */: - case 159 /* TypeParameter */: - case 223 /* ExpressionWithTypeArguments */: - case 173 /* TypeReference */: - case 184 /* ConditionalType */: - case 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 195 /* ImportType */: + case 172 /* ConstructSignature */: + case 168 /* Constructor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 166 /* MethodSignature */: + case 171 /* CallSignature */: + case 173 /* IndexSignature */: + case 251 /* VariableDeclaration */: + case 161 /* TypeParameter */: + case 225 /* ExpressionWithTypeArguments */: + case 175 /* TypeReference */: + case 186 /* ConditionalType */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: + case 197 /* ImportType */: return true; } return false; @@ -99764,6 +103235,9 @@ var ts; if (languageVersion < 99 /* ESNext */) { transformers.push(ts.transformESNext); } + if (languageVersion < 8 /* ES2021 */) { + transformers.push(ts.transformES2021); + } if (languageVersion < 7 /* ES2020 */) { transformers.push(ts.transformES2020); } @@ -99840,7 +103314,7 @@ 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(341 /* Count */); + var enabledSyntaxKindFeatures = new Array(349 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentStatements; @@ -99851,6 +103325,9 @@ var ts; var lexicalEnvironmentFlagsStack = []; var lexicalEnvironmentStackOffset = 0; var lexicalEnvironmentSuspended = false; + var blockScopedVariableDeclarationsStack = []; + var blockScopeStackOffset = 0; + var blockScopedVariableDeclarations; var emitHelpers; var onSubstituteNode = noEmitSubstitution; var onEmitNode = noEmitNotification; @@ -99873,6 +103350,9 @@ var ts; hoistVariableDeclaration: hoistVariableDeclaration, hoistFunctionDeclaration: hoistFunctionDeclaration, addInitializationStatement: addInitializationStatement, + startBlockScope: startBlockScope, + endBlockScope: endBlockScope, + addBlockScopedVariable: addBlockScopedVariable, requestEmitHelper: requestEmitHelper, readEmitHelpers: readEmitHelpers, enableSubstitution: enableSubstitution, @@ -99916,9 +103396,9 @@ var ts; var transformed = []; for (var _a = 0, nodes_3 = nodes; _a < nodes_3.length; _a++) { var node = nodes_3[_a]; - ts.tracing.push("emit" /* Emit */, "transformNodes", node.kind === 297 /* 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" /* Emit */, "transformNodes", node.kind === 299 /* SourceFile */ ? { path: node.path } : { kind: node.kind, pos: node.pos, end: node.end }); transformed.push((allowDtsFiles ? transformation : transformRoot)(node)); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } // prevent modification of the lexical environment. state = 2 /* Completed */; @@ -100133,6 +103613,38 @@ var ts; function getLexicalEnvironmentFlags() { return lexicalEnvironmentFlags; } + /** + * 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."); + blockScopedVariableDeclarationsStack[blockScopeStackOffset] = blockScopedVariableDeclarations; + blockScopeStackOffset++; + blockScopedVariableDeclarations = undefined; + } + /** + * 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."); + var statements = ts.some(blockScopedVariableDeclarations) ? + [ + factory.createVariableStatement( + /*modifiers*/ undefined, factory.createVariableDeclarationList(blockScopedVariableDeclarations.map(function (identifier) { return factory.createVariableDeclaration(identifier); }), 1 /* Let */)) + ] : undefined; + blockScopeStackOffset--; + blockScopedVariableDeclarations = blockScopedVariableDeclarationsStack[blockScopeStackOffset]; + if (blockScopeStackOffset === 0) { + blockScopedVariableDeclarationsStack = []; + } + return statements; + } + function addBlockScopedVariable(name) { + ts.Debug.assert(blockScopeStackOffset > 0, "Cannot add a block scoped variable outside of an iteration body."); + (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."); @@ -100174,35 +103686,37 @@ var ts; } ts.transformNodes = transformNodes; ts.nullTransformationContext = { - get factory() { return ts.factory; }, - enableEmitNotification: ts.noop, - enableSubstitution: ts.noop, - endLexicalEnvironment: ts.returnUndefined, + factory: ts.factory, getCompilerOptions: function () { return ({}); }, - getEmitHost: ts.notImplemented, getEmitResolver: ts.notImplemented, + getEmitHost: ts.notImplemented, getEmitHelperFactory: ts.notImplemented, + startLexicalEnvironment: ts.noop, + resumeLexicalEnvironment: ts.noop, + suspendLexicalEnvironment: ts.noop, + endLexicalEnvironment: ts.returnUndefined, setLexicalEnvironmentFlags: ts.noop, getLexicalEnvironmentFlags: function () { return 0; }, - hoistFunctionDeclaration: ts.noop, hoistVariableDeclaration: ts.noop, + hoistFunctionDeclaration: ts.noop, addInitializationStatement: ts.noop, - isEmitNotificationEnabled: ts.notImplemented, - isSubstitutionEnabled: ts.notImplemented, - onEmitNode: ts.noop, - onSubstituteNode: ts.notImplemented, - readEmitHelpers: ts.notImplemented, + startBlockScope: ts.noop, + endBlockScope: ts.returnUndefined, + addBlockScopedVariable: ts.noop, requestEmitHelper: ts.noop, - resumeLexicalEnvironment: ts.noop, - startLexicalEnvironment: ts.noop, - suspendLexicalEnvironment: ts.noop, + readEmitHelpers: ts.notImplemented, + enableSubstitution: ts.noop, + enableEmitNotification: ts.noop, + isSubstitutionEnabled: ts.notImplemented, + isEmitNotificationEnabled: ts.notImplemented, + onSubstituteNode: noEmitSubstitution, + onEmitNode: noEmitNotification, addDiagnostic: ts.noop, }; })(ts || (ts = {})); var ts; (function (ts) { var brackets = createBracketsMap(); - var syntheticParent = { pos: -1, end: -1 }; /*@internal*/ function isBuildInfoFile(file) { return ts.fileExtensionIs(file, ".tsbuildinfo" /* TsBuildInfo */); @@ -100288,7 +103802,7 @@ var ts; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 298 /* Bundle */) { + if (sourceFile.kind === 300 /* Bundle */) { return getOutputPathsForBundle(options, forceDtsPaths); } else { @@ -100514,15 +104028,15 @@ var ts; sourceFiles: sourceFileOrBundle.sourceFiles.map(function (file) { return relativeToBuildInfo(ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory())); }) }; } - ts.tracing.push("emit" /* Emit */, "emitJsFileOrBundle", { jsFilePath: jsFilePath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitJsFileOrBundle", { jsFilePath: jsFilePath }); emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo); - ts.tracing.pop(); - ts.tracing.push("emit" /* Emit */, "emitDeclarationFileOrBundle", { declarationFilePath: declarationFilePath }); + 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 }); emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo); - ts.tracing.pop(); - ts.tracing.push("emit" /* Emit */, "emitBuildInfo", { buildInfoPath: buildInfoPath }); + 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 }); emitBuildInfo(bundleBuildInfo, buildInfoPath); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); if (!emitSkipped && emittedFilesList) { if (!emitOnlyDtsFiles) { if (jsFilePath) { @@ -100649,13 +104163,13 @@ var ts; 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: compilerOptions.declarationMap, + sourceMap: !forceDtsEmit && compilerOptions.declarationMap, sourceRoot: compilerOptions.sourceRoot, mapRoot: compilerOptions.mapRoot, extendedDiagnostics: compilerOptions.extendedDiagnostics, // Explicitly do not passthru either `inline` option }); - if (forceDtsEmit && declarationTransform.transformed[0].kind === 297 /* SourceFile */) { + if (forceDtsEmit && declarationTransform.transformed[0].kind === 299 /* SourceFile */) { var sourceFile = declarationTransform.transformed[0]; exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; } @@ -100666,7 +104180,7 @@ var ts; } function collectLinkedAliases(node) { if (ts.isExportAssignment(node)) { - if (node.expression.kind === 78 /* Identifier */) { + if (node.expression.kind === 79 /* Identifier */) { resolver.collectLinkedAliases(node.expression, /*setVisibility*/ true); } return; @@ -100678,8 +104192,8 @@ var ts; ts.forEachChild(node, collectLinkedAliases); } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) { - var bundle = sourceFileOrBundle.kind === 298 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 297 /* SourceFile */ ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 300 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 299 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; var sourceMapGenerator; if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { @@ -100720,7 +104234,7 @@ var ts; } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { return (mapOptions.sourceMap || mapOptions.inlineSourceMap) - && (sourceFileOrBundle.kind !== 297 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); + && (sourceFileOrBundle.kind !== 299 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); } function getSourceRoot(mapOptions) { // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the @@ -100779,7 +104293,7 @@ var ts; ts.emitFiles = emitFiles; /*@internal*/ function getBuildInfoText(buildInfo) { - return JSON.stringify(buildInfo, undefined, 2); + return JSON.stringify(buildInfo); } ts.getBuildInfoText = getBuildInfoText; /*@internal*/ @@ -100960,7 +104474,7 @@ var ts; function createPrinter(printerOptions, handlers) { if (printerOptions === void 0) { printerOptions = {}; } if (handlers === void 0) { handlers = {}; } - var hasGlobalName = handlers.hasGlobalName, _a = handlers.onEmitNode, onEmitNode = _a === void 0 ? ts.noEmitNotification : _a, isEmitNotificationEnabled = handlers.isEmitNotificationEnabled, _b = handlers.substituteNode, substituteNode = _b === void 0 ? ts.noEmitSubstitution : _b, onBeforeEmitNodeArray = handlers.onBeforeEmitNodeArray, onAfterEmitNodeArray = handlers.onAfterEmitNodeArray, onBeforeEmitToken = handlers.onBeforeEmitToken, onAfterEmitToken = handlers.onAfterEmitToken; + var hasGlobalName = handlers.hasGlobalName, _a = handlers.onEmitNode, onEmitNode = _a === void 0 ? ts.noEmitNotification : _a, isEmitNotificationEnabled = handlers.isEmitNotificationEnabled, _b = handlers.substituteNode, substituteNode = _b === void 0 ? ts.noEmitSubstitution : _b, onBeforeEmitNode = handlers.onBeforeEmitNode, onAfterEmitNode = handlers.onAfterEmitNode, onBeforeEmitNodeArray = handlers.onBeforeEmitNodeArray, onAfterEmitNodeArray = handlers.onAfterEmitNodeArray, onBeforeEmitToken = handlers.onBeforeEmitToken, onAfterEmitToken = handlers.onAfterEmitToken; var extendedDiagnostics = !!printerOptions.extendedDiagnostics; var newLine = ts.getNewLineCharacter(printerOptions); var moduleKind = ts.getEmitModuleKind(printerOptions); @@ -100999,9 +104513,11 @@ var ts; var detachedCommentsInfo; var hasWrittenComment = false; var commentsDisabled = !!printerOptions.removeComments; - var lastNode; var lastSubstitution; + var currentParenthesizerRule; var _c = ts.performance.createTimerIf(extendedDiagnostics, "commentTime", "beforeComment", "afterComment"), enterComment = _c.enter, exitComment = _c.exit; + var parenthesizer = ts.factory.parenthesizer; + var emitBinaryExpression = createEmitBinaryExpression(); reset(); return { // public API @@ -101029,9 +104545,9 @@ var ts; break; } switch (node.kind) { - case 297 /* SourceFile */: return printFile(node); - case 298 /* Bundle */: return printBundle(node); - case 299 /* UnparsedSource */: return printUnparsedSource(node); + case 299 /* SourceFile */: return printFile(node); + case 300 /* Bundle */: return printBundle(node); + case 301 /* UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -101065,7 +104581,7 @@ var ts; if (sourceFile) { setSourceFile(sourceFile); } - emitList(syntheticParent, nodes, format); + emitList(/*parentNode*/ undefined, nodes, format); reset(); writer = previousWriter; } @@ -101200,7 +104716,7 @@ var ts; if (sourceFile) { setSourceFile(sourceFile); } - pipelineEmit(hint, node); + pipelineEmit(hint, node, /*parenthesizerRule*/ undefined); } function setSourceFile(sourceFile) { currentSourceFile = sourceFile; @@ -101228,51 +104744,54 @@ var ts; currentSourceFile = undefined; currentLineMap = undefined; detachedCommentsInfo = undefined; - lastNode = undefined; - lastSubstitution = undefined; setWriter(/*output*/ undefined, /*_sourceMapGenerator*/ undefined); } function getCurrentLineMap() { return currentLineMap || (currentLineMap = ts.getLineStarts(currentSourceFile)); } - function emit(node) { + function emit(node, parenthesizerRule) { if (node === undefined) return; var prevSourceFileTextKind = recordBundleFileInternalSectionStart(node); - var substitute = pipelineEmit(4 /* Unspecified */, node); + pipelineEmit(4 /* Unspecified */, node, parenthesizerRule); recordBundleFileInternalSectionEnd(prevSourceFileTextKind); - return substitute; } function emitIdentifierName(node) { if (node === undefined) return; - return pipelineEmit(2 /* IdentifierName */, node); + pipelineEmit(2 /* IdentifierName */, node, /*parenthesizerRule*/ undefined); } - function emitExpression(node) { + function emitExpression(node, parenthesizerRule) { if (node === undefined) return; - return pipelineEmit(1 /* Expression */, node); + pipelineEmit(1 /* Expression */, node, parenthesizerRule); } function emitJsxAttributeValue(node) { - return pipelineEmit(ts.isStringLiteral(node) ? 6 /* JsxAttributeValue */ : 4 /* Unspecified */, node); + pipelineEmit(ts.isStringLiteral(node) ? 6 /* JsxAttributeValue */ : 4 /* Unspecified */, node); } - function pipelineEmit(emitHint, node) { - var savedLastNode = lastNode; - var savedLastSubstitution = lastSubstitution; - var savedPreserveSourceNewlines = preserveSourceNewlines; - lastNode = node; - lastSubstitution = undefined; - if (preserveSourceNewlines && !!(ts.getEmitFlags(node) & 134217728 /* IgnoreSourceNewlines */)) { + function beforeEmitNode(node) { + if (preserveSourceNewlines && (ts.getEmitFlags(node) & 134217728 /* IgnoreSourceNewlines */)) { preserveSourceNewlines = false; } + } + function afterEmitNode(savedPreserveSourceNewlines) { + preserveSourceNewlines = savedPreserveSourceNewlines; + } + function pipelineEmit(emitHint, node, parenthesizerRule) { + currentParenthesizerRule = parenthesizerRule; var pipelinePhase = getPipelinePhase(0 /* Notification */, emitHint, node); pipelinePhase(emitHint, node); - ts.Debug.assert(lastNode === node); - var substitute = lastSubstitution; - lastNode = savedLastNode; - lastSubstitution = savedLastSubstitution; - preserveSourceNewlines = savedPreserveSourceNewlines; - return substitute || node; + currentParenthesizerRule = undefined; + } + function shouldEmitComments(node) { + return !commentsDisabled && !ts.isSourceFile(node); + } + function shouldEmitSourceMaps(node) { + return !sourceMapsDisabled && + !ts.isSourceFile(node) && + !ts.isInJsonFile(node) && + !ts.isUnparsedSource(node) && + !ts.isUnparsedPrepend(node); } function getPipelinePhase(phase, emitHint, node) { switch (phase) { @@ -101282,18 +104801,21 @@ var ts; } // falls through case 1 /* Substitution */: - if (substituteNode !== ts.noEmitSubstitution && (lastSubstitution = substituteNode(emitHint, node)) !== node) { + if (substituteNode !== ts.noEmitSubstitution && (lastSubstitution = substituteNode(emitHint, node) || node) !== node) { + if (currentParenthesizerRule) { + lastSubstitution = currentParenthesizerRule(lastSubstitution); + } return pipelineEmitWithSubstitution; } // falls through case 2 /* Comments */: - if (!commentsDisabled && node.kind !== 297 /* SourceFile */) { + if (shouldEmitComments(node)) { return pipelineEmitWithComments; } // falls through case 3 /* SourceMaps */: - if (!sourceMapsDisabled && node.kind !== 297 /* SourceFile */ && !ts.isInJsonFile(node)) { - return pipelineEmitWithSourceMap; + if (shouldEmitSourceMaps(node)) { + return pipelineEmitWithSourceMaps; } // falls through case 4 /* Emit */: @@ -101306,13 +104828,25 @@ var ts; return getPipelinePhase(currentPhase + 1, emitHint, node); } function pipelineEmitWithNotification(hint, node) { - ts.Debug.assert(lastNode === node); var pipelinePhase = getNextPipelinePhase(0 /* Notification */, hint, node); onEmitNode(hint, node, pipelinePhase); - ts.Debug.assert(lastNode === node); } function pipelineEmitWithHint(hint, node) { - ts.Debug.assert(lastNode === node || lastSubstitution === node); + onBeforeEmitNode === null || onBeforeEmitNode === void 0 ? void 0 : onBeforeEmitNode(node); + if (preserveSourceNewlines) { + var savedPreserveSourceNewlines = preserveSourceNewlines; + beforeEmitNode(node); + pipelineEmitWithHintWorker(hint, node); + afterEmitNode(savedPreserveSourceNewlines); + } + else { + pipelineEmitWithHintWorker(hint, node); + } + onAfterEmitNode === null || onAfterEmitNode === void 0 ? void 0 : onAfterEmitNode(node); + // clear the parenthesizer rule as we ascend + currentParenthesizerRule = undefined; + } + function pipelineEmitWithHintWorker(hint, node) { if (hint === 0 /* SourceFile */) return emitSourceFile(ts.cast(node, ts.isSourceFile)); if (hint === 2 /* IdentifierName */) @@ -101326,308 +104860,337 @@ var ts; return emitEmptyStatement(/*isEmbeddedStatement*/ true); } if (hint === 4 /* Unspecified */) { - if (ts.isKeyword(node.kind)) - return writeTokenNode(node, writeKeyword); switch (node.kind) { // Pseudo-literals case 15 /* TemplateHead */: case 16 /* TemplateMiddle */: case 17 /* TemplateTail */: return emitLiteral(node, /*jsxAttributeEscape*/ false); - case 299 /* UnparsedSource */: - case 293 /* UnparsedPrepend */: - return emitUnparsedSourceOrPrepend(node); - case 292 /* UnparsedPrologue */: - return writeUnparsedNode(node); - case 294 /* UnparsedText */: - case 295 /* UnparsedInternalText */: - return emitUnparsedTextLike(node); - case 296 /* UnparsedSyntheticReference */: - return emitUnparsedSyntheticReference(node); // Identifiers - case 78 /* Identifier */: + case 79 /* Identifier */: return emitIdentifier(node); // PrivateIdentifiers - case 79 /* PrivateIdentifier */: + case 80 /* PrivateIdentifier */: return emitPrivateIdentifier(node); // Parse tree nodes // Names - case 157 /* QualifiedName */: + case 159 /* QualifiedName */: return emitQualifiedName(node); - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 159 /* TypeParameter */: + case 161 /* TypeParameter */: return emitTypeParameter(node); - case 160 /* Parameter */: + case 162 /* Parameter */: return emitParameter(node); - case 161 /* Decorator */: + case 163 /* Decorator */: return emitDecorator(node); // Type members - case 162 /* PropertySignature */: + case 164 /* PropertySignature */: return emitPropertySignature(node); - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return emitPropertyDeclaration(node); - case 164 /* MethodSignature */: + case 166 /* MethodSignature */: return emitMethodSignature(node); - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: return emitMethodDeclaration(node); - case 166 /* Constructor */: + case 168 /* Constructor */: return emitConstructor(node); - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return emitAccessorDeclaration(node); - case 169 /* CallSignature */: + case 171 /* CallSignature */: return emitCallSignature(node); - case 170 /* ConstructSignature */: + case 172 /* ConstructSignature */: return emitConstructSignature(node); - case 171 /* IndexSignature */: + case 173 /* IndexSignature */: return emitIndexSignature(node); - case 194 /* TemplateLiteralTypeSpan */: - return emitTemplateTypeSpan(node); // Types - case 172 /* TypePredicate */: + case 174 /* TypePredicate */: return emitTypePredicate(node); - case 173 /* TypeReference */: + case 175 /* TypeReference */: return emitTypeReference(node); - case 174 /* FunctionType */: + case 176 /* FunctionType */: return emitFunctionType(node); - case 308 /* JSDocFunctionType */: - return emitJSDocFunctionType(node); - case 175 /* ConstructorType */: + case 177 /* ConstructorType */: return emitConstructorType(node); - case 176 /* TypeQuery */: + case 178 /* TypeQuery */: return emitTypeQuery(node); - case 177 /* TypeLiteral */: + case 179 /* TypeLiteral */: return emitTypeLiteral(node); - case 178 /* ArrayType */: + case 180 /* ArrayType */: return emitArrayType(node); - case 179 /* TupleType */: + case 181 /* TupleType */: return emitTupleType(node); - case 180 /* OptionalType */: + case 182 /* OptionalType */: return emitOptionalType(node); - case 182 /* UnionType */: + // SyntaxKind.RestType is handled below + case 184 /* UnionType */: return emitUnionType(node); - case 183 /* IntersectionType */: + case 185 /* IntersectionType */: return emitIntersectionType(node); - case 184 /* ConditionalType */: + case 186 /* ConditionalType */: return emitConditionalType(node); - case 185 /* InferType */: + case 187 /* InferType */: return emitInferType(node); - case 186 /* ParenthesizedType */: + case 188 /* ParenthesizedType */: return emitParenthesizedType(node); - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 187 /* ThisType */: + case 189 /* ThisType */: return emitThisType(); - case 188 /* TypeOperator */: + case 190 /* TypeOperator */: return emitTypeOperator(node); - case 189 /* IndexedAccessType */: + case 191 /* IndexedAccessType */: return emitIndexedAccessType(node); - case 190 /* MappedType */: + case 192 /* MappedType */: return emitMappedType(node); - case 191 /* LiteralType */: + case 193 /* LiteralType */: return emitLiteralType(node); - case 193 /* TemplateLiteralType */: + case 194 /* NamedTupleMember */: + return emitNamedTupleMember(node); + case 195 /* TemplateLiteralType */: return emitTemplateType(node); - case 195 /* ImportType */: + case 196 /* TemplateLiteralTypeSpan */: + return emitTemplateTypeSpan(node); + case 197 /* ImportType */: return emitImportTypeNode(node); - case 303 /* JSDocAllType */: - writePunctuation("*"); - return; - case 304 /* JSDocUnknownType */: - writePunctuation("?"); - return; - case 305 /* JSDocNullableType */: - return emitJSDocNullableType(node); - case 306 /* JSDocNonNullableType */: - return emitJSDocNonNullableType(node); - case 307 /* JSDocOptionalType */: - return emitJSDocOptionalType(node); - case 181 /* RestType */: - case 309 /* JSDocVariadicType */: - return emitRestOrJSDocVariadicType(node); - case 192 /* NamedTupleMember */: - return emitNamedTupleMember(node); // Binding patterns - case 196 /* ObjectBindingPattern */: + case 198 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 197 /* ArrayBindingPattern */: + case 199 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 198 /* BindingElement */: + case 200 /* BindingElement */: return emitBindingElement(node); // Misc - case 228 /* TemplateSpan */: + case 230 /* TemplateSpan */: return emitTemplateSpan(node); - case 229 /* SemicolonClassElement */: + case 231 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 230 /* Block */: + case 232 /* Block */: return emitBlock(node); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return emitVariableStatement(node); - case 231 /* EmptyStatement */: + case 233 /* EmptyStatement */: return emitEmptyStatement(/*isEmbeddedStatement*/ false); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: return emitExpressionStatement(node); - case 234 /* IfStatement */: + case 236 /* IfStatement */: return emitIfStatement(node); - case 235 /* DoStatement */: + case 237 /* DoStatement */: return emitDoStatement(node); - case 236 /* WhileStatement */: + case 238 /* WhileStatement */: return emitWhileStatement(node); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return emitForStatement(node); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return emitForInStatement(node); - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: return emitForOfStatement(node); - case 240 /* ContinueStatement */: + case 242 /* ContinueStatement */: return emitContinueStatement(node); - case 241 /* BreakStatement */: + case 243 /* BreakStatement */: return emitBreakStatement(node); - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: return emitReturnStatement(node); - case 243 /* WithStatement */: + case 245 /* WithStatement */: return emitWithStatement(node); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: return emitSwitchStatement(node); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return emitLabeledStatement(node); - case 246 /* ThrowStatement */: + case 248 /* ThrowStatement */: return emitThrowStatement(node); - case 247 /* TryStatement */: + case 249 /* TryStatement */: return emitTryStatement(node); - case 248 /* DebuggerStatement */: + case 250 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 250 /* VariableDeclarationList */: + case 252 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: return emitClassDeclaration(node); - case 253 /* InterfaceDeclaration */: + case 255 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 257 /* ModuleBlock */: + case 259 /* ModuleBlock */: return emitModuleBlock(node); - case 258 /* CaseBlock */: + case 260 /* CaseBlock */: return emitCaseBlock(node); - case 259 /* NamespaceExportDeclaration */: + case 261 /* NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return emitImportDeclaration(node); - case 262 /* ImportClause */: + case 264 /* ImportClause */: return emitImportClause(node); - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: return emitNamespaceImport(node); - case 269 /* NamespaceExport */: + case 271 /* NamespaceExport */: return emitNamespaceExport(node); - case 264 /* NamedImports */: + case 266 /* NamedImports */: return emitNamedImports(node); - case 265 /* ImportSpecifier */: + case 267 /* ImportSpecifier */: return emitImportSpecifier(node); - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return emitExportAssignment(node); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: return emitExportDeclaration(node); - case 268 /* NamedExports */: + case 270 /* NamedExports */: return emitNamedExports(node); - case 270 /* ExportSpecifier */: + case 272 /* ExportSpecifier */: return emitExportSpecifier(node); - case 271 /* MissingDeclaration */: + case 273 /* MissingDeclaration */: return; // Module references - case 272 /* ExternalModuleReference */: + case 274 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 11 /* JsxText */: return emitJsxText(node); - case 275 /* JsxOpeningElement */: - case 278 /* JsxOpeningFragment */: + case 277 /* JsxOpeningElement */: + case 280 /* JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 276 /* JsxClosingElement */: - case 279 /* JsxClosingFragment */: + case 278 /* JsxClosingElement */: + case 281 /* JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 280 /* JsxAttribute */: + case 282 /* JsxAttribute */: return emitJsxAttribute(node); - case 281 /* JsxAttributes */: + case 283 /* JsxAttributes */: return emitJsxAttributes(node); - case 282 /* JsxSpreadAttribute */: + case 284 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 284 /* CaseClause */: + case 286 /* CaseClause */: return emitCaseClause(node); - case 285 /* DefaultClause */: + case 287 /* DefaultClause */: return emitDefaultClause(node); - case 286 /* HeritageClause */: + case 288 /* HeritageClause */: return emitHeritageClause(node); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 290 /* SpreadAssignment */: + case 292 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 291 /* EnumMember */: + case 293 /* EnumMember */: return emitEnumMember(node); + // Unparsed + case 294 /* UnparsedPrologue */: + return writeUnparsedNode(node); + case 301 /* UnparsedSource */: + case 295 /* UnparsedPrepend */: + return emitUnparsedSourceOrPrepend(node); + case 296 /* UnparsedText */: + case 297 /* UnparsedInternalText */: + return emitUnparsedTextLike(node); + case 298 /* UnparsedSyntheticReference */: + return emitUnparsedSyntheticReference(node); + // Top-level nodes + case 299 /* SourceFile */: + return emitSourceFile(node); + case 300 /* Bundle */: + return ts.Debug.fail("Bundles should be printed using printBundle"); + // SyntaxKind.UnparsedSource (handled above) + case 302 /* InputFiles */: + return ts.Debug.fail("InputFiles should not be printed"); // JSDoc nodes (only used in codefixes currently) - case 326 /* JSDocParameterTag */: - case 333 /* JSDocPropertyTag */: + case 303 /* JSDocTypeExpression */: + return emitJSDocTypeExpression(node); + case 304 /* JSDocNameReference */: + return emitJSDocNameReference(node); + case 306 /* JSDocAllType */: + return writePunctuation("*"); + case 307 /* JSDocUnknownType */: + return writePunctuation("?"); + case 308 /* JSDocNullableType */: + return emitJSDocNullableType(node); + case 309 /* JSDocNonNullableType */: + return emitJSDocNonNullableType(node); + case 310 /* JSDocOptionalType */: + return emitJSDocOptionalType(node); + case 311 /* JSDocFunctionType */: + return emitJSDocFunctionType(node); + case 183 /* RestType */: + case 312 /* JSDocVariadicType */: + return emitRestOrJSDocVariadicType(node); + case 313 /* JSDocNamepathType */: + return; + case 314 /* JSDocComment */: + return emitJSDoc(node); + case 316 /* JSDocTypeLiteral */: + return emitJSDocTypeLiteral(node); + case 317 /* JSDocSignature */: + return emitJSDocSignature(node); + case 321 /* JSDocTag */: + case 326 /* JSDocClassTag */: + return emitJSDocSimpleTag(node); + case 322 /* JSDocAugmentsTag */: + case 323 /* JSDocImplementsTag */: + return emitJSDocHeritageTag(node); + case 324 /* JSDocAuthorTag */: + case 325 /* JSDocDeprecatedTag */: + return; + // SyntaxKind.JSDocClassTag (see JSDocTag, above) + case 327 /* JSDocPublicTag */: + case 328 /* JSDocPrivateTag */: + case 329 /* JSDocProtectedTag */: + case 330 /* JSDocReadonlyTag */: + case 331 /* JSDocOverrideTag */: + return; + case 332 /* JSDocCallbackTag */: + return emitJSDocCallbackTag(node); + // SyntaxKind.JSDocEnumTag (see below) + case 334 /* JSDocParameterTag */: + case 341 /* JSDocPropertyTag */: return emitJSDocPropertyLikeTag(node); - case 327 /* JSDocReturnTag */: - case 329 /* JSDocTypeTag */: - case 328 /* JSDocThisTag */: - case 325 /* JSDocEnumTag */: + case 333 /* JSDocEnumTag */: + case 335 /* JSDocReturnTag */: + case 336 /* JSDocThisTag */: + case 337 /* JSDocTypeTag */: return emitJSDocSimpleTypedTag(node); - case 316 /* JSDocImplementsTag */: - case 315 /* JSDocAugmentsTag */: - return emitJSDocHeritageTag(node); - case 330 /* JSDocTemplateTag */: + case 338 /* JSDocTemplateTag */: return emitJSDocTemplateTag(node); - case 331 /* JSDocTypedefTag */: + case 339 /* JSDocTypedefTag */: return emitJSDocTypedefTag(node); - case 324 /* JSDocCallbackTag */: - return emitJSDocCallbackTag(node); - case 313 /* JSDocSignature */: - return emitJSDocSignature(node); - case 312 /* JSDocTypeLiteral */: - return emitJSDocTypeLiteral(node); - case 319 /* JSDocClassTag */: - case 314 /* JSDocTag */: - return emitJSDocSimpleTag(node); - case 332 /* JSDocSeeTag */: + case 340 /* JSDocSeeTag */: return emitJSDocSeeTag(node); - case 302 /* JSDocNameReference */: - return emitJSDocNameReference(node); - case 311 /* JSDocComment */: - return emitJSDoc(node); - // Transformation nodes (ignored) + // SyntaxKind.JSDocPropertyTag (see JSDocParameterTag, above) + // Transformation nodes + case 343 /* NotEmittedStatement */: + case 347 /* EndOfDeclarationMarker */: + case 346 /* MergeDeclarationMarker */: + return; } if (ts.isExpression(node)) { hint = 1 /* Expression */; if (substituteNode !== ts.noEmitSubstitution) { - lastSubstitution = node = substituteNode(hint, node); + var substitute = substituteNode(hint, node) || node; + if (substitute !== node) { + node = substitute; + if (currentParenthesizerRule) { + node = currentParenthesizerRule(node); + } + } } } - else if (ts.isToken(node)) { - return writeTokenNode(node, writePunctuation); - } } if (hint === 1 /* Expression */) { switch (node.kind) { @@ -101640,86 +105203,94 @@ var ts; case 14 /* NoSubstitutionTemplateLiteral */: return emitLiteral(node, /*jsxAttributeEscape*/ false); // Identifiers - case 78 /* Identifier */: + case 79 /* Identifier */: return emitIdentifier(node); - // Reserved words - case 94 /* FalseKeyword */: - case 103 /* NullKeyword */: - case 105 /* SuperKeyword */: - case 109 /* TrueKeyword */: - case 107 /* ThisKeyword */: - case 99 /* ImportKeyword */: - writeTokenNode(node, writeKeyword); - return; // Expressions - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return emitCallExpression(node); - case 204 /* NewExpression */: + case 206 /* NewExpression */: return emitNewExpression(node); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 206 /* TypeAssertionExpression */: + case 208 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: return emitFunctionExpression(node); - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return emitArrowFunction(node); - case 210 /* DeleteExpression */: + case 212 /* DeleteExpression */: return emitDeleteExpression(node); - case 211 /* TypeOfExpression */: + case 213 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 212 /* VoidExpression */: + case 214 /* VoidExpression */: return emitVoidExpression(node); - case 213 /* AwaitExpression */: + case 215 /* AwaitExpression */: return emitAwaitExpression(node); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return emitBinaryExpression(node); - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: return emitConditionalExpression(node); - case 218 /* TemplateExpression */: + case 220 /* TemplateExpression */: return emitTemplateExpression(node); - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: return emitYieldExpression(node); - case 220 /* SpreadElement */: - return emitSpreadExpression(node); - case 221 /* ClassExpression */: + case 222 /* SpreadElement */: + return emitSpreadElement(node); + case 223 /* ClassExpression */: return emitClassExpression(node); - case 222 /* OmittedExpression */: + case 224 /* OmittedExpression */: return; - case 224 /* AsExpression */: + case 226 /* AsExpression */: return emitAsExpression(node); - case 225 /* NonNullExpression */: + case 227 /* NonNullExpression */: return emitNonNullExpression(node); - case 226 /* MetaProperty */: + case 228 /* MetaProperty */: return emitMetaProperty(node); + case 229 /* SyntheticExpression */: + return ts.Debug.fail("SyntheticExpression should never be printed."); // JSX - case 273 /* JsxElement */: + case 275 /* JsxElement */: return emitJsxElement(node); - case 274 /* JsxSelfClosingElement */: + case 276 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 277 /* JsxFragment */: + case 279 /* JsxFragment */: return emitJsxFragment(node); + // Synthesized list + case 342 /* SyntaxList */: + return ts.Debug.fail("SyntaxList should not be printed"); // Transformation nodes - case 336 /* PartiallyEmittedExpression */: + case 343 /* NotEmittedStatement */: + return; + case 344 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 337 /* CommaListExpression */: + case 345 /* CommaListExpression */: return emitCommaList(node); + case 346 /* MergeDeclarationMarker */: + case 347 /* EndOfDeclarationMarker */: + return; + case 348 /* SyntheticReferenceExpression */: + return ts.Debug.fail("SyntheticReferenceExpression should not be printed"); } } + if (ts.isKeyword(node.kind)) + return writeTokenNode(node, writeKeyword); + if (ts.isTokenKind(node.kind)) + return writeTokenNode(node, writePunctuation); + ts.Debug.fail("Unhandled SyntaxKind: " + ts.Debug.formatSyntaxKind(node.kind) + "."); } function emitMappedTypeParameter(node) { emit(node.name); @@ -101729,10 +105300,11 @@ var ts; emit(node.constraint); } function pipelineEmitWithSubstitution(hint, node) { - ts.Debug.assert(lastNode === node || lastSubstitution === node); var pipelinePhase = getNextPipelinePhase(1 /* Substitution */, hint, node); - pipelinePhase(hint, lastSubstitution); - ts.Debug.assert(lastNode === node || lastSubstitution === node); + ts.Debug.assertIsDefined(lastSubstitution); + node = lastSubstitution; + lastSubstitution = undefined; + pipelinePhase(hint, node); } function getHelpersFromBundledSourceFiles(bundle) { var result; @@ -101758,7 +105330,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 298 /* Bundle */ ? node : undefined; + var bundle = node.kind === 300 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -101858,7 +105430,7 @@ var ts; var pos = getTextPosWithWriteLine(); writeUnparsedNode(unparsed); if (bundleFileInfo) { - updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 294 /* UnparsedText */ ? + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 296 /* UnparsedText */ ? "text" /* Text */ : "internal" /* Internal */); } @@ -101895,7 +105467,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { emitExpression(node); } else { @@ -101904,7 +105476,7 @@ var ts; } function emitComputedPropertyName(node) { writePunctuation("["); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfComputedPropertyName); writePunctuation("]"); } // @@ -101931,18 +105503,18 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 308 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 311 /* JSDocFunctionType */ && !node.name) { emit(node.type); } else { emitTypeAnnotation(node.type); } // The comment position has to fallback to any present node within the parameterdeclaration because as it turns out, the parser can make parameter declarations with _just_ an initializer. - emitInitializer(node.initializer, node.type ? node.type.end : node.questionToken ? node.questionToken.end : node.name ? node.name.end : node.modifiers ? node.modifiers.end : node.decorators ? node.decorators.end : node.pos, node); + emitInitializer(node.initializer, node.type ? node.type.end : node.questionToken ? node.questionToken.end : node.name ? node.name.end : node.modifiers ? node.modifiers.end : node.decorators ? node.decorators.end : node.pos, node, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitDecorator(decorator) { writePunctuation("@"); - emitExpression(decorator.expression); + emitExpression(decorator.expression, parenthesizer.parenthesizeLeftSideOfAccess); } // // Type members @@ -101993,7 +105565,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeKeyword(node.kind === 167 /* GetAccessor */ ? "get" : "set"); + writeKeyword(node.kind === 169 /* GetAccessor */ ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -102107,7 +105679,7 @@ var ts; writePunctuation("}"); } function emitArrayType(node) { - emit(node.elementType); + emit(node.elementType, parenthesizer.parenthesizeElementTypeOfArrayType); writePunctuation("["); writePunctuation("]"); } @@ -102130,21 +105702,21 @@ var ts; emit(node.type); } function emitOptionalType(node) { - emit(node.type); + emit(node.type, parenthesizer.parenthesizeElementTypeOfArrayType); writePunctuation("?"); } function emitUnionType(node) { - emitList(node, node.types, 516 /* UnionTypeConstituents */); + emitList(node, node.types, 516 /* UnionTypeConstituents */, parenthesizer.parenthesizeMemberOfElementType); } function emitIntersectionType(node) { - emitList(node, node.types, 520 /* IntersectionTypeConstituents */); + emitList(node, node.types, 520 /* IntersectionTypeConstituents */, parenthesizer.parenthesizeMemberOfElementType); } function emitConditionalType(node) { - emit(node.checkType); + emit(node.checkType, parenthesizer.parenthesizeMemberOfConditionalType); writeSpace(); writeKeyword("extends"); writeSpace(); - emit(node.extendsType); + emit(node.extendsType, parenthesizer.parenthesizeMemberOfConditionalType); writeSpace(); writePunctuation("?"); writeSpace(); @@ -102170,10 +105742,10 @@ var ts; function emitTypeOperator(node) { writeTokenText(node.operator, writeKeyword); writeSpace(); - emit(node.type); + emit(node.type, parenthesizer.parenthesizeMemberOfElementType); } function emitIndexedAccessType(node) { - emit(node.objectType); + emit(node.objectType, parenthesizer.parenthesizeMemberOfElementType); writePunctuation("["); emit(node.indexType); writePunctuation("]"); @@ -102190,7 +105762,7 @@ var ts; } if (node.readonlyToken) { emit(node.readonlyToken); - if (node.readonlyToken.kind !== 142 /* ReadonlyKeyword */) { + if (node.readonlyToken.kind !== 143 /* ReadonlyKeyword */) { writeKeyword("readonly"); } writeSpace(); @@ -102266,7 +105838,7 @@ var ts; writeSpace(); } emit(node.name); - emitInitializer(node.initializer, node.name.end, node); + emitInitializer(node.initializer, node.name.end, node, parenthesizer.parenthesizeExpressionForDisallowedComma); } // // Expressions @@ -102274,7 +105846,7 @@ var ts; function emitArrayLiteralExpression(node) { var elements = node.elements; var preferNewLine = node.multiLine ? 65536 /* PreferNewLine */ : 0 /* None */; - emitExpressionList(node, elements, 8914 /* ArrayLiteralExpressionElements */ | preferNewLine); + emitExpressionList(node, elements, 8914 /* ArrayLiteralExpressionElements */ | preferNewLine, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitObjectLiteralExpression(node) { ts.forEach(node.properties, generateMemberNames); @@ -102290,13 +105862,13 @@ var ts; } } function emitPropertyAccessExpression(node) { - var expression = ts.cast(emitExpression(node.expression), ts.isExpression); + emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); var token = node.questionDotToken || ts.setTextRangePosEnd(ts.factory.createToken(24 /* 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 */ && - mayNeedDotDotForPropertyAccess(expression) && + mayNeedDotDotForPropertyAccess(node.expression) && !writer.hasTrailingComment() && !writer.hasTrailingWhitespace(); if (shouldEmitDotDot) { @@ -102332,27 +105904,27 @@ var ts; } } function emitElementAccessExpression(node) { - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); emit(node.questionDotToken); emitTokenWithComment(22 /* OpenBracketToken */, node.expression.end, writePunctuation, node); emitExpression(node.argumentExpression); emitTokenWithComment(23 /* CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); } function emitCallExpression(node) { - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); emit(node.questionDotToken); emitTypeArguments(node, node.typeArguments); - emitExpressionList(node, node.arguments, 2576 /* CallExpressionArguments */); + emitExpressionList(node, node.arguments, 2576 /* CallExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitNewExpression(node) { - emitTokenWithComment(102 /* NewKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(103 /* NewKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfNew); emitTypeArguments(node, node.typeArguments); - emitExpressionList(node, node.arguments, 18960 /* NewExpressionArguments */); + emitExpressionList(node, node.arguments, 18960 /* NewExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitTaggedTemplateExpression(node) { - emitExpression(node.tag); + emitExpression(node.tag, parenthesizer.parenthesizeLeftSideOfAccess); emitTypeArguments(node, node.typeArguments); writeSpace(); emitExpression(node.template); @@ -102361,12 +105933,12 @@ var ts; writePunctuation("<"); emit(node.type); writePunctuation(">"); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitParenthesizedExpression(node) { var openParenPos = emitTokenWithComment(20 /* OpenParenToken */, node.pos, writePunctuation, node); var indented = writeLineSeparatorsAndIndentBefore(node.expression, node); - emitExpression(node.expression); + emitExpression(node.expression, /*parenthesizerRules*/ undefined); writeLineSeparatorsAfter(node.expression, node); decreaseIndentIf(indented); emitTokenWithComment(21 /* CloseParenToken */, node.expression ? node.expression.end : openParenPos, writePunctuation, node); @@ -102388,31 +105960,31 @@ var ts; emit(node.equalsGreaterThanToken); } function emitDeleteExpression(node) { - emitTokenWithComment(88 /* DeleteKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(89 /* DeleteKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitTypeOfExpression(node) { - emitTokenWithComment(111 /* TypeOfKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(112 /* TypeOfKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitVoidExpression(node) { - emitTokenWithComment(113 /* VoidKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(114 /* VoidKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitAwaitExpression(node) { - emitTokenWithComment(130 /* AwaitKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(131 /* AwaitKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitPrefixUnaryExpression(node) { writeTokenText(node.operator, writeOperator); if (shouldEmitWhitespaceBeforeOperand(node)) { writeSpace(); } - emitExpression(node.operand); + emitExpression(node.operand, parenthesizer.parenthesizeOperandOfPrefixUnary); } function shouldEmitWhitespaceBeforeOperand(node) { // In some cases, we need to emit a space between the operator and the operand. One obvious case @@ -102428,84 +106000,101 @@ 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 === 214 /* PrefixUnaryExpression */ + return operand.kind === 216 /* 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 */))); } function emitPostfixUnaryExpression(node) { - emitExpression(node.operand); + emitExpression(node.operand, parenthesizer.parenthesizeOperandOfPostfixUnary); writeTokenText(node.operator, writeOperator); } - var EmitBinaryExpressionState; - (function (EmitBinaryExpressionState) { - EmitBinaryExpressionState[EmitBinaryExpressionState["EmitLeft"] = 0] = "EmitLeft"; - EmitBinaryExpressionState[EmitBinaryExpressionState["EmitRight"] = 1] = "EmitRight"; - EmitBinaryExpressionState[EmitBinaryExpressionState["FinishEmit"] = 2] = "FinishEmit"; - })(EmitBinaryExpressionState || (EmitBinaryExpressionState = {})); - /** - * emitBinaryExpression includes an embedded work stack to attempt to handle as many nested binary expressions - * as possible without creating any additional stack frames. This can only be done when the emit pipeline does - * not require notification/substitution/comment/sourcemap decorations. - */ - function emitBinaryExpression(node) { - var nodeStack = [node]; - var stateStack = [0 /* EmitLeft */]; - var stackIndex = 0; - while (stackIndex >= 0) { - node = nodeStack[stackIndex]; - switch (stateStack[stackIndex]) { - case 0 /* EmitLeft */: { - maybePipelineEmitExpression(node.left); - break; - } - case 1 /* EmitRight */: { - var isCommaOperator = node.operatorToken.kind !== 27 /* CommaToken */; - var linesBeforeOperator = getLinesBetweenNodes(node, node.left, node.operatorToken); - var linesAfterOperator = getLinesBetweenNodes(node, node.operatorToken, node.right); - writeLinesAndIndent(linesBeforeOperator, isCommaOperator); - emitLeadingCommentsOfPosition(node.operatorToken.pos); - writeTokenNode(node.operatorToken, node.operatorToken.kind === 100 /* InKeyword */ ? writeKeyword : writeOperator); - emitTrailingCommentsOfPosition(node.operatorToken.end, /*prefixSpace*/ true); // Binary operators should have a space before the comment starts - writeLinesAndIndent(linesAfterOperator, /*writeSpaceIfNotIndenting*/ true); - maybePipelineEmitExpression(node.right); - break; - } - case 2 /* FinishEmit */: { - var linesBeforeOperator = getLinesBetweenNodes(node, node.left, node.operatorToken); - var linesAfterOperator = getLinesBetweenNodes(node, node.operatorToken, node.right); - decreaseIndentIf(linesBeforeOperator, linesAfterOperator); - stackIndex--; - break; - } - default: return ts.Debug.fail("Invalid state " + stateStack[stackIndex] + " for emitBinaryExpressionWorker"); + function createEmitBinaryExpression() { + return ts.createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, /*foldState*/ undefined); + function onEnter(node, state) { + if (state) { + state.stackIndex++; + state.preserveSourceNewlinesStack[state.stackIndex] = preserveSourceNewlines; + state.containerPosStack[state.stackIndex] = containerPos; + state.containerEndStack[state.stackIndex] = containerEnd; + state.declarationListContainerEndStack[state.stackIndex] = declarationListContainerEnd; + var emitComments_1 = state.shouldEmitCommentsStack[state.stackIndex] = shouldEmitComments(node); + var emitSourceMaps = state.shouldEmitSourceMapsStack[state.stackIndex] = shouldEmitSourceMaps(node); + onBeforeEmitNode === null || onBeforeEmitNode === void 0 ? void 0 : onBeforeEmitNode(node); + if (emitComments_1) + emitCommentsBeforeNode(node); + if (emitSourceMaps) + emitSourceMapsBeforeNode(node); + beforeEmitNode(node); } - } - function maybePipelineEmitExpression(next) { - // Advance the state of this unit of work, - stateStack[stackIndex]++; - // Then actually do the work of emitting the node `next` returned by the prior state - // The following section should be identical to `pipelineEmit` save it assumes EmitHint.Expression and offloads - // binary expression handling, where possible, to the contained work queue - // #region trampolinePipelineEmit - var savedLastNode = lastNode; - var savedLastSubstitution = lastSubstitution; - lastNode = next; - lastSubstitution = undefined; + else { + state = { + stackIndex: 0, + preserveSourceNewlinesStack: [undefined], + containerPosStack: [-1], + containerEndStack: [-1], + declarationListContainerEndStack: [-1], + shouldEmitCommentsStack: [false], + shouldEmitSourceMapsStack: [false], + }; + } + return state; + } + function onLeft(next, _workArea, parent) { + return maybeEmitExpression(next, parent, "left"); + } + function onOperator(operatorToken, _state, node) { + var isCommaOperator = operatorToken.kind !== 27 /* 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); + emitTrailingCommentsOfPosition(operatorToken.end, /*prefixSpace*/ true); // Binary operators should have a space before the comment starts + writeLinesAndIndent(linesAfterOperator, /*writeSpaceIfNotIndenting*/ true); + } + function onRight(next, _workArea, parent) { + return maybeEmitExpression(next, parent, "right"); + } + function onExit(node, state) { + var linesBeforeOperator = getLinesBetweenNodes(node, node.left, node.operatorToken); + var linesAfterOperator = getLinesBetweenNodes(node, node.operatorToken, node.right); + decreaseIndentIf(linesBeforeOperator, linesAfterOperator); + if (state.stackIndex > 0) { + var savedPreserveSourceNewlines = state.preserveSourceNewlinesStack[state.stackIndex]; + var savedContainerPos = state.containerPosStack[state.stackIndex]; + var savedContainerEnd = state.containerEndStack[state.stackIndex]; + var savedDeclarationListContainerEnd = state.declarationListContainerEndStack[state.stackIndex]; + var shouldEmitComments_1 = state.shouldEmitCommentsStack[state.stackIndex]; + var shouldEmitSourceMaps_1 = state.shouldEmitSourceMapsStack[state.stackIndex]; + afterEmitNode(savedPreserveSourceNewlines); + if (shouldEmitSourceMaps_1) + emitSourceMapsAfterNode(node); + if (shouldEmitComments_1) + emitCommentsAfterNode(node, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd); + onAfterEmitNode === null || onAfterEmitNode === void 0 ? void 0 : onAfterEmitNode(node); + state.stackIndex--; + } + } + function maybeEmitExpression(next, parent, side) { + var parenthesizerRule = side === "left" ? + parenthesizer.getParenthesizeLeftSideOfBinaryForOperator(parent.operatorToken.kind) : + parenthesizer.getParenthesizeRightSideOfBinaryForOperator(parent.operatorToken.kind); var pipelinePhase = getPipelinePhase(0 /* Notification */, 1 /* Expression */, next); - if (pipelinePhase === pipelineEmitWithHint && ts.isBinaryExpression(next)) { - // If the target pipeline phase is emit directly, and the next node's also a binary expression, - // skip all the intermediate indirection and push the expression directly onto the work stack - stackIndex++; - stateStack[stackIndex] = 0 /* EmitLeft */; - nodeStack[stackIndex] = next; + if (pipelinePhase === pipelineEmitWithSubstitution) { + ts.Debug.assertIsDefined(lastSubstitution); + next = parenthesizerRule(ts.cast(lastSubstitution, ts.isExpression)); + pipelinePhase = getNextPipelinePhase(1 /* Substitution */, 1 /* Expression */, next); + lastSubstitution = undefined; } - else { - pipelinePhase(1 /* Expression */, next); + if (pipelinePhase === pipelineEmitWithComments || + pipelinePhase === pipelineEmitWithSourceMaps || + pipelinePhase === pipelineEmitWithHint) { + if (ts.isBinaryExpression(next)) { + return next; + } } - ts.Debug.assert(lastNode === next); - lastNode = savedLastNode; - lastSubstitution = savedLastSubstitution; - // #endregion trampolinePipelineEmit + currentParenthesizerRule = parenthesizerRule; + pipelinePhase(1 /* Expression */, next); } } function emitConditionalExpression(node) { @@ -102513,16 +106102,16 @@ var ts; var linesAfterQuestion = getLinesBetweenNodes(node, node.questionToken, node.whenTrue); var linesBeforeColon = getLinesBetweenNodes(node, node.whenTrue, node.colonToken); var linesAfterColon = getLinesBetweenNodes(node, node.colonToken, node.whenFalse); - emitExpression(node.condition); + emitExpression(node.condition, parenthesizer.parenthesizeConditionOfConditionalExpression); writeLinesAndIndent(linesBeforeQuestion, /*writeSpaceIfNotIndenting*/ true); emit(node.questionToken); writeLinesAndIndent(linesAfterQuestion, /*writeSpaceIfNotIndenting*/ true); - emitExpression(node.whenTrue); + emitExpression(node.whenTrue, parenthesizer.parenthesizeBranchOfConditionalExpression); decreaseIndentIf(linesBeforeQuestion, linesAfterQuestion); writeLinesAndIndent(linesBeforeColon, /*writeSpaceIfNotIndenting*/ true); emit(node.colonToken); writeLinesAndIndent(linesAfterColon, /*writeSpaceIfNotIndenting*/ true); - emitExpression(node.whenFalse); + emitExpression(node.whenFalse, parenthesizer.parenthesizeBranchOfConditionalExpression); decreaseIndentIf(linesBeforeColon, linesAfterColon); } function emitTemplateExpression(node) { @@ -102530,24 +106119,24 @@ var ts; emitList(node, node.templateSpans, 262144 /* TemplateExpressionSpans */); } function emitYieldExpression(node) { - emitTokenWithComment(124 /* YieldKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(125 /* YieldKeyword */, node.pos, writeKeyword, node); emit(node.asteriskToken); - emitExpressionWithLeadingSpace(node.expression); + emitExpressionWithLeadingSpace(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); } - function emitSpreadExpression(node) { + function emitSpreadElement(node) { emitTokenWithComment(25 /* DotDotDotToken */, node.pos, writePunctuation, node); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitClassExpression(node) { generateNameIfNeeded(node.name); emitClassDeclarationOrExpression(node); } function emitExpressionWithTypeArguments(node) { - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); emitTypeArguments(node, node.typeArguments); } function emitAsExpression(node) { - emitExpression(node.expression); + emitExpression(node.expression, /*parenthesizerRules*/ undefined); if (node.type) { writeSpace(); writeKeyword("as"); @@ -102556,7 +106145,7 @@ var ts; } } function emitNonNullExpression(node) { - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); writeOperator("!"); } function emitMetaProperty(node) { @@ -102599,7 +106188,7 @@ var ts; } } function emitExpressionStatement(node) { - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfExpressionStatement); // Emit semicolon in non json files // or if json file that created synthesized expression(eg.define expression statement when --out and amd code generation) if (!ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) { @@ -102607,7 +106196,7 @@ var ts; } } function emitIfStatement(node) { - var openParenPos = emitTokenWithComment(98 /* IfKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(99 /* IfKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -102615,8 +106204,8 @@ var ts; emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { writeLineOrSpace(node, node.thenStatement, node.elseStatement); - emitTokenWithComment(90 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 234 /* IfStatement */) { + emitTokenWithComment(91 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); + if (node.elseStatement.kind === 236 /* IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -102626,14 +106215,14 @@ var ts; } } function emitWhileClause(node, startPos) { - var openParenPos = emitTokenWithComment(114 /* WhileKeyword */, startPos, writeKeyword, node); + var openParenPos = emitTokenWithComment(115 /* WhileKeyword */, startPos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); } function emitDoStatement(node) { - emitTokenWithComment(89 /* DoKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(90 /* DoKeyword */, node.pos, writeKeyword, node); emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement) && !preserveSourceNewlines) { writeSpace(); @@ -102649,7 +106238,7 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { - var openParenPos = emitTokenWithComment(96 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); var pos = emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node); emitForBinding(node.initializer); @@ -102661,25 +106250,25 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { - var openParenPos = emitTokenWithComment(96 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(100 /* InKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(101 /* InKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { - var openParenPos = emitTokenWithComment(96 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitWithTrailingSpace(node.awaitModifier); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(156 /* OfKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(158 /* OfKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); @@ -102687,7 +106276,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 250 /* VariableDeclarationList */) { + if (node.kind === 252 /* VariableDeclarationList */) { emit(node); } else { @@ -102696,12 +106285,12 @@ var ts; } } function emitContinueStatement(node) { - emitTokenWithComment(85 /* ContinueKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(86 /* ContinueKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } function emitBreakStatement(node) { - emitTokenWithComment(80 /* BreakKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(81 /* BreakKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } @@ -102724,18 +106313,18 @@ var ts; } pos = writeTokenText(token, writer, pos); if (isSimilarNode && contextNode.end !== pos) { - var isJsxExprContext = contextNode.kind === 283 /* JsxExpression */; + var isJsxExprContext = contextNode.kind === 285 /* JsxExpression */; emitTrailingCommentsOfPosition(pos, /*prefixSpace*/ !isJsxExprContext, /*forceNoNewline*/ isJsxExprContext); } return pos; } function emitReturnStatement(node) { - emitTokenWithComment(104 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); + emitTokenWithComment(105 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); emitExpressionWithLeadingSpace(node.expression); writeTrailingSemicolon(); } function emitWithStatement(node) { - var openParenPos = emitTokenWithComment(115 /* WithKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(116 /* WithKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -102743,7 +106332,7 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { - var openParenPos = emitTokenWithComment(106 /* SwitchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(107 /* SwitchKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -102758,12 +106347,12 @@ var ts; emit(node.statement); } function emitThrowStatement(node) { - emitTokenWithComment(108 /* ThrowKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(109 /* ThrowKeyword */, node.pos, writeKeyword, node); emitExpressionWithLeadingSpace(node.expression); writeTrailingSemicolon(); } function emitTryStatement(node) { - emitTokenWithComment(110 /* TryKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(111 /* TryKeyword */, node.pos, writeKeyword, node); writeSpace(); emit(node.tryBlock); if (node.catchClause) { @@ -102772,13 +106361,13 @@ var ts; } if (node.finallyBlock) { writeLineOrSpace(node, node.catchClause || node.tryBlock, node.finallyBlock); - emitTokenWithComment(95 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); + emitTokenWithComment(96 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); writeSpace(); emit(node.finallyBlock); } } function emitDebuggerStatement(node) { - writeToken(86 /* DebuggerKeyword */, node.pos, writeKeyword); + writeToken(87 /* DebuggerKeyword */, node.pos, writeKeyword); writeTrailingSemicolon(); } // @@ -102788,7 +106377,7 @@ var ts; emit(node.name); emit(node.exclamationToken); emitTypeAnnotation(node.type); - emitInitializer(node.initializer, node.type ? node.type.end : node.name.end, node); + emitInitializer(node.initializer, node.type ? node.type.end : node.name.end, node, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitVariableDeclarationList(node) { writeKeyword(ts.isLet(node) ? "let" : ts.isVarConst(node) ? "const" : "var"); @@ -102807,9 +106396,6 @@ var ts; emitIdentifierName(node.name); emitSignatureAndBody(node, emitSignatureHead); } - function emitBlockCallback(_hint, body) { - emitBlockFunctionBody(body); - } function emitSignatureAndBody(node, emitSignatureHead) { var body = node.body; if (body) { @@ -102822,12 +106408,7 @@ var ts; ts.forEach(node.parameters, generateNames); generateNames(node.body); emitSignatureHead(node); - if (onEmitNode) { - onEmitNode(4 /* Unspecified */, body, emitBlockCallback); - } - else { - emitBlockFunctionBody(body); - } + emitBlockFunctionBody(body); popNameGenerationScope(node); if (indentedFlag) { decreaseIndent(); @@ -102836,7 +106417,7 @@ var ts; else { emitSignatureHead(node); writeSpace(); - emitExpression(body); + emitExpression(body, parenthesizer.parenthesizeConciseBodyOfArrowFunction); } } else { @@ -102880,6 +106461,7 @@ var ts; return true; } function emitBlockFunctionBody(body) { + onBeforeEmitNode === null || onBeforeEmitNode === void 0 ? void 0 : onBeforeEmitNode(body); writeSpace(); writePunctuation("{"); increaseIndent(); @@ -102894,6 +106476,7 @@ var ts; } decreaseIndent(); writeToken(19 /* CloseBraceToken */, body.statements.end, writePunctuation, body); + onAfterEmitNode === null || onAfterEmitNode === void 0 ? void 0 : onAfterEmitNode(body); } function emitBlockFunctionBodyOnSingleLine(body) { emitBlockFunctionBodyWorker(body, /*emitBlockFunctionBodyOnSingleLine*/ true); @@ -102909,7 +106492,7 @@ var ts; increaseIndent(); } else { - emitList(body, body.statements, 1 /* MultiLineFunctionBodyStatements */, statementOffset); + emitList(body, body.statements, 1 /* MultiLineFunctionBodyStatements */, /*parenthesizerRule*/ undefined, statementOffset); } } function emitClassDeclaration(node) { @@ -102984,7 +106567,7 @@ var ts; var body = node.body; if (!body) return writeTrailingSemicolon(); - while (body.kind === 256 /* ModuleDeclaration */) { + while (body && ts.isModuleDeclaration(body)) { writePunctuation("."); emit(body.name); body = body.body; @@ -103005,21 +106588,21 @@ var ts; } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(99 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(100 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.isTypeOnly) { - emitTokenWithComment(149 /* TypeKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(150 /* TypeKeyword */, node.pos, writeKeyword, node); writeSpace(); } emit(node.name); writeSpace(); - emitTokenWithComment(62 /* EqualsToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(63 /* EqualsToken */, node.name.end, writePunctuation, node); writeSpace(); emitModuleReference(node.moduleReference); writeTrailingSemicolon(); } function emitModuleReference(node) { - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { emitExpression(node); } else { @@ -103028,12 +106611,12 @@ var ts; } function emitImportDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(99 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(100 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.importClause) { emit(node.importClause); writeSpace(); - emitTokenWithComment(153 /* FromKeyword */, node.importClause.end, writeKeyword, node); + emitTokenWithComment(154 /* FromKeyword */, node.importClause.end, writeKeyword, node); writeSpace(); } emitExpression(node.moduleSpecifier); @@ -103041,7 +106624,7 @@ var ts; } function emitImportClause(node) { if (node.isTypeOnly) { - emitTokenWithComment(149 /* TypeKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(150 /* TypeKeyword */, node.pos, writeKeyword, node); writeSpace(); } emit(node.name); @@ -103054,7 +106637,7 @@ var ts; function emitNamespaceImport(node) { var asPos = emitTokenWithComment(41 /* AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(126 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(127 /* AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -103065,23 +106648,25 @@ var ts; emitImportOrExportSpecifier(node); } function emitExportAssignment(node) { - var nextPos = emitTokenWithComment(92 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isExportEquals) { - emitTokenWithComment(62 /* EqualsToken */, nextPos, writeOperator, node); + emitTokenWithComment(63 /* EqualsToken */, nextPos, writeOperator, node); } else { - emitTokenWithComment(87 /* DefaultKeyword */, nextPos, writeKeyword, node); + emitTokenWithComment(88 /* DefaultKeyword */, nextPos, writeKeyword, node); } writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, node.isExportEquals ? + parenthesizer.getParenthesizeRightSideOfBinaryForOperator(63 /* EqualsToken */) : + parenthesizer.parenthesizeExpressionOfExportDefault); writeTrailingSemicolon(); } function emitExportDeclaration(node) { - var nextPos = emitTokenWithComment(92 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isTypeOnly) { - nextPos = emitTokenWithComment(149 /* TypeKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(150 /* TypeKeyword */, nextPos, writeKeyword, node); writeSpace(); } if (node.exportClause) { @@ -103093,18 +106678,18 @@ var ts; if (node.moduleSpecifier) { writeSpace(); var fromPos = node.exportClause ? node.exportClause.end : nextPos; - emitTokenWithComment(153 /* FromKeyword */, fromPos, writeKeyword, node); + emitTokenWithComment(154 /* FromKeyword */, fromPos, writeKeyword, node); writeSpace(); emitExpression(node.moduleSpecifier); } writeTrailingSemicolon(); } function emitNamespaceExportDeclaration(node) { - var nextPos = emitTokenWithComment(92 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(126 /* AsKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(127 /* AsKeyword */, nextPos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(140 /* NamespaceKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(141 /* NamespaceKeyword */, nextPos, writeKeyword, node); writeSpace(); emit(node.name); writeTrailingSemicolon(); @@ -103112,7 +106697,7 @@ var ts; function emitNamespaceExport(node) { var asPos = emitTokenWithComment(41 /* AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(126 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(127 /* AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -103131,7 +106716,7 @@ var ts; if (node.propertyName) { emit(node.propertyName); writeSpace(); - emitTokenWithComment(126 /* AsKeyword */, node.propertyName.end, writeKeyword, node); + emitTokenWithComment(127 /* AsKeyword */, node.propertyName.end, writeKeyword, node); writeSpace(); } emit(node.name); @@ -103233,7 +106818,7 @@ var ts; } } function emitJsxTagName(node) { - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { emitExpression(node); } else { @@ -103244,13 +106829,13 @@ var ts; // Clauses // function emitCaseClause(node) { - emitTokenWithComment(81 /* CaseKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(82 /* CaseKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); emitCaseOrDefaultClauseRest(node, node.statements, node.expression.end); } function emitDefaultClause(node) { - var pos = emitTokenWithComment(87 /* DefaultKeyword */, node.pos, writeKeyword, node); + var pos = emitTokenWithComment(88 /* DefaultKeyword */, node.pos, writeKeyword, node); emitCaseOrDefaultClauseRest(node, node.statements, pos); } function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) { @@ -103278,7 +106863,7 @@ var ts; emitList(node, node.types, 528 /* HeritageClauseTypes */); } function emitCatchClause(node) { - var openParenPos = emitTokenWithComment(82 /* CatchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(83 /* CatchKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.variableDeclaration) { emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); @@ -103307,7 +106892,7 @@ var ts; var commentRange = ts.getCommentRange(initializer); emitTrailingCommentsOfPosition(commentRange.pos); } - emitExpression(initializer); + emitExpression(initializer, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitShorthandPropertyAssignment(node) { emit(node.name); @@ -103315,13 +106900,13 @@ var ts; writeSpace(); writePunctuation("="); writeSpace(); - emitExpression(node.objectAssignmentInitializer); + emitExpression(node.objectAssignmentInitializer, parenthesizer.parenthesizeExpressionForDisallowedComma); } } function emitSpreadAssignment(node) { if (node.expression) { emitTokenWithComment(25 /* DotDotDotToken */, node.pos, writePunctuation, node); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); } } // @@ -103329,7 +106914,7 @@ var ts; // function emitEnumMember(node) { emit(node.name); - emitInitializer(node.initializer, node.name.end, node); + emitInitializer(node.initializer, node.name.end, node, parenthesizer.parenthesizeExpressionForDisallowedComma); } // // JSDoc @@ -103337,18 +106922,21 @@ var ts; function emitJSDoc(node) { write("/**"); if (node.comment) { - var lines = node.comment.split(/\r\n?|\n/g); - for (var _a = 0, lines_2 = lines; _a < lines_2.length; _a++) { - var line = lines_2[_a]; - writeLine(); - writeSpace(); - writePunctuation("*"); - writeSpace(); - write(line); + var text = ts.getTextOfJSDocComment(node.comment); + if (text) { + var lines = text.split(/\r\n?|\n/g); + for (var _a = 0, lines_2 = lines; _a < lines_2.length; _a++) { + var line = lines_2[_a]; + writeLine(); + writeSpace(); + writePunctuation("*"); + writeSpace(); + write(line); + } } } if (node.tags) { - if (node.tags.length === 1 && node.tags[0].kind === 329 /* JSDocTypeTag */ && !node.comment) { + if (node.tags.length === 1 && node.tags[0].kind === 337 /* JSDocTypeTag */ && !node.comment) { writeSpace(); emit(node.tags[0]); } @@ -103393,7 +106981,7 @@ var ts; function emitJSDocTypedefTag(tag) { emitJSDocTagName(tag.tagName); if (tag.typeExpression) { - if (tag.typeExpression.kind === 301 /* JSDocTypeExpression */) { + if (tag.typeExpression.kind === 303 /* JSDocTypeExpression */) { emitJSDocTypeExpression(tag.typeExpression); } else { @@ -103412,7 +107000,7 @@ var ts; emit(tag.fullName); } emitJSDocComment(tag.comment); - if (tag.typeExpression && tag.typeExpression.kind === 312 /* JSDocTypeLiteral */) { + if (tag.typeExpression && tag.typeExpression.kind === 316 /* JSDocTypeLiteral */) { emitJSDocTypeLiteral(tag.typeExpression); } } @@ -103465,9 +107053,10 @@ var ts; emit(tagName); } function emitJSDocComment(comment) { - if (comment) { + var text = ts.getTextOfJSDocComment(comment); + if (text) { writeSpace(); - write(comment); + write(text); } } function emitJSDocTypeExpression(typeExpression) { @@ -103570,7 +107159,7 @@ var ts; emitHelpers(node); var index = ts.findIndex(statements, function (statement) { return !ts.isPrologueDirective(statement); }); emitTripleSlashDirectivesIfNeeded(node); - emitList(node, statements, 1 /* MultiLine */, index === -1 ? statements.length : index); + emitList(node, statements, 1 /* MultiLine */, /*parenthesizerRule*/ undefined, index === -1 ? statements.length : index); popNameGenerationScope(node); } // Transformation nodes @@ -103578,7 +107167,7 @@ var ts; emitExpression(node.expression); } function emitCommaList(node) { - emitExpressionList(node, node.elements, 528 /* CommaListElements */); + emitExpressionList(node, node.elements, 528 /* CommaListElements */, /*parenthesizerRule*/ undefined); } /** * Emits any prologue directives at the start of a Statement list, returning the @@ -103724,12 +107313,12 @@ var ts; emit(node); } } - function emitInitializer(node, equalCommentStartPos, container) { + function emitInitializer(node, equalCommentStartPos, container, parenthesizerRule) { if (node) { writeSpace(); - emitTokenWithComment(62 /* EqualsToken */, equalCommentStartPos, writeOperator, container); + emitTokenWithComment(63 /* EqualsToken */, equalCommentStartPos, writeOperator, container); writeSpace(); - emitExpression(node); + emitExpression(node, parenthesizerRule); } } function emitNodeWithPrefix(prefix, prefixWriter, node, emit) { @@ -103744,10 +107333,10 @@ var ts; emit(node); } } - function emitExpressionWithLeadingSpace(node) { + function emitExpressionWithLeadingSpace(node, parenthesizerRule) { if (node) { writeSpace(); - emitExpression(node); + emitExpression(node, parenthesizerRule); } } function emitWithTrailingSpace(node) { @@ -103777,7 +107366,7 @@ var ts; emitList(parentNode, decorators, 2146305 /* Decorators */); } function emitTypeArguments(parentNode, typeArguments) { - emitList(parentNode, typeArguments, 53776 /* TypeArguments */); + emitList(parentNode, typeArguments, 53776 /* TypeArguments */, parenthesizer.parenthesizeMemberOfElementType); } function emitTypeParameters(parentNode, typeParameters) { if (ts.isFunctionLike(parentNode) && parentNode.typeArguments) { // Quick info uses type arguments in place of type parameters on instantiated signatures @@ -103816,12 +107405,6 @@ var ts; function emitParametersForIndexSignature(parentNode, parameters) { emitList(parentNode, parameters, 8848 /* IndexSignatureParameters */); } - function emitList(parentNode, children, format, start, count) { - emitNodeList(emit, parentNode, children, format, start, count); - } - function emitExpressionList(parentNode, children, format, start, count) { - emitNodeList(emitExpression, parentNode, children, format, start, count); // TODO: GH#18217 - } function writeDelimiter(format) { switch (format & 60 /* DelimitersMask */) { case 0 /* None */: @@ -103844,7 +107427,13 @@ var ts; break; } } - function emitNodeList(emit, parentNode, children, format, start, count) { + function emitList(parentNode, children, format, parenthesizerRule, start, count) { + emitNodeList(emit, parentNode, children, format, parenthesizerRule, start, count); + } + function emitExpressionList(parentNode, children, format, parenthesizerRule, start, count) { + emitNodeList(emitExpression, parentNode, children, format, parenthesizerRule, start, count); + } + function emitNodeList(emit, parentNode, children, format, parenthesizerRule, start, count) { if (start === void 0) { start = 0; } if (count === void 0) { count = children ? children.length - start : 0; } var isUndefined = children === undefined; @@ -103863,8 +107452,7 @@ var ts; } if (format & 15360 /* BracketsMask */) { writePunctuation(getOpeningBracket(format)); - if (isEmpty && !isUndefined) { - // TODO: GH#18217 + if (isEmpty && children) { emitTrailingCommentsOfPosition(children.pos, /*prefixSpace*/ true); // Emit comments within empty bracketed lists } } @@ -103873,7 +107461,7 @@ var ts; } if (isEmpty) { // Write a line terminator if the parent node was multi-line - if (format & 1 /* MultiLine */ && !(preserveSourceNewlines && ts.rangeIsOnSingleLine(parentNode, currentSourceFile))) { + if (format & 1 /* MultiLine */ && !(preserveSourceNewlines && (!parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) { writeLine(); } else if (format & 256 /* SpaceBetweenBraces */ && !(format & 524288 /* NoSpaceIfEmpty */)) { @@ -103881,6 +107469,7 @@ var ts; } } else { + ts.Debug.type(children); // Write the opening line terminator or leading whitespace. var mayEmitInterveningComments = (format & 262144 /* NoInterveningComments */) === 0; var shouldEmitInterveningComments = mayEmitInterveningComments; @@ -103915,7 +107504,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.end) { + if (format & 60 /* DelimitersMask */ && previousSibling.end !== (parentNode ? parentNode.end : -1)) { emitLeadingCommentsOfPosition(previousSibling.end); } writeDelimiter(format); @@ -103948,7 +107537,12 @@ var ts; shouldEmitInterveningComments = mayEmitInterveningComments; } nextListElementPos = child.pos; - emit(child); + if (emit.length === 1) { + emit(child); + } + else { + emit(child, parenthesizerRule); + } if (shouldDecreaseIndentAfterEmit) { decreaseIndent(); shouldDecreaseIndentAfterEmit = false; @@ -103973,7 +107567,7 @@ var ts; // 2 // /* end of element 2 */ // ]; - if (previousSibling && parentNode.end !== previousSibling.end && (format & 60 /* DelimitersMask */) && !skipTrailingComments) { + if (previousSibling && (parentNode ? parentNode.end : -1) !== previousSibling.end && (format & 60 /* DelimitersMask */) && !skipTrailingComments) { emitLeadingCommentsOfPosition(hasTrailingComma && (children === null || children === void 0 ? void 0 : children.end) ? children.end : previousSibling.end); } // Decrease the indent, if requested. @@ -103994,8 +107588,7 @@ var ts; onAfterEmitNodeArray(children); } if (format & 15360 /* BracketsMask */) { - if (isEmpty && !isUndefined) { - // TODO: GH#18217 + if (isEmpty && children) { emitLeadingCommentsOfPosition(children.end); // Emit leading comments within empty lists } writePunctuation(getClosingBracket(format)); @@ -104126,7 +107719,7 @@ var ts; } var firstChild_1 = children[0]; if (firstChild_1 === undefined) { - return ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; + return !parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; } if (firstChild_1.pos === nextListElementPos) { // If this child starts at the beginning of a list item in a parent list, its leading @@ -104150,7 +107743,8 @@ var ts; // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } - if (!ts.positionIsSynthesized(parentNode.pos) && + if (parentNode && + !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(firstChild_1) && (!firstChild_1.parent || ts.getOriginalNode(firstChild_1.parent) === ts.getOriginalNode(parentNode))) { if (preserveSourceNewlines) { @@ -104173,10 +107767,10 @@ var ts; // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } - else if (!ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode) && previousNode.parent === nextNode.parent) { - if (preserveSourceNewlines) { - return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); - } + else if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) { + return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); + } + else if (!preserveSourceNewlines && !ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) { return ts.rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile) ? 0 : 1; } else if (synthesizedNodeStartsOnNewLine(previousNode, format) || synthesizedNodeStartsOnNewLine(nextNode, format)) { @@ -104195,9 +107789,9 @@ var ts; } var lastChild = ts.lastOrUndefined(children); if (lastChild === undefined) { - return ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; + return !parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; } - if (!ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) { + if (parentNode && !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) { if (preserveSourceNewlines) { var end_1 = ts.isNodeArray(children) && !ts.positionIsSynthesized(children.end) ? children.end : lastChild.end; return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenPositionAndNextNonWhitespaceCharacter(end_1, parentNode.end, currentSourceFile, includeComments); }); @@ -104283,7 +107877,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 207 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 209 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -104353,84 +107947,84 @@ var ts; if (!node) return; switch (node.kind) { - case 230 /* Block */: + case 232 /* Block */: ts.forEach(node.statements, generateNames); break; - case 245 /* LabeledStatement */: - case 243 /* WithStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: + case 247 /* LabeledStatement */: + case 245 /* WithStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: generateNames(node.statement); break; - case 234 /* IfStatement */: + case 236 /* IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 237 /* ForStatement */: - case 239 /* ForOfStatement */: - case 238 /* ForInStatement */: + case 239 /* ForStatement */: + case 241 /* ForOfStatement */: + case 240 /* ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: generateNames(node.caseBlock); break; - case 258 /* CaseBlock */: + case 260 /* CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 284 /* CaseClause */: - case 285 /* DefaultClause */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 247 /* TryStatement */: + case 249 /* TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 287 /* CatchClause */: + case 289 /* CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: generateNames(node.declarationList); break; - case 250 /* VariableDeclarationList */: + case 252 /* VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 249 /* VariableDeclaration */: - case 160 /* Parameter */: - case 198 /* BindingElement */: - case 252 /* ClassDeclaration */: + case 251 /* VariableDeclaration */: + case 162 /* Parameter */: + case 200 /* BindingElement */: + case 254 /* ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 196 /* ObjectBindingPattern */: - case 197 /* ArrayBindingPattern */: + case 198 /* ObjectBindingPattern */: + case 199 /* ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: generateNames(node.importClause); break; - case 262 /* ImportClause */: + case 264 /* ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: generateNameIfNeeded(node.name); break; - case 269 /* NamespaceExport */: + case 271 /* NamespaceExport */: generateNameIfNeeded(node.name); break; - case 264 /* NamedImports */: + case 266 /* NamedImports */: ts.forEach(node.elements, generateNames); break; - case 265 /* ImportSpecifier */: + case 267 /* ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -104439,12 +108033,12 @@ var ts; if (!node) return; switch (node.kind) { - case 288 /* PropertyAssignment */: - case 289 /* ShorthandPropertyAssignment */: - case 163 /* PropertyDeclaration */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 290 /* PropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: + case 165 /* PropertyDeclaration */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: generateNameIfNeeded(node.name); break; } @@ -104624,25 +108218,25 @@ var ts; */ function generateNameForNode(node, flags) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 256 /* ModuleDeclaration */: - case 255 /* EnumDeclaration */: + case 258 /* ModuleDeclaration */: + case 257 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 261 /* ImportDeclaration */: - case 267 /* ExportDeclaration */: + case 263 /* ImportDeclaration */: + case 269 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 251 /* FunctionDeclaration */: - case 252 /* ClassDeclaration */: - case 266 /* ExportAssignment */: + case 253 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: + case 268 /* ExportAssignment */: return generateNameForExportDefault(); - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: return generateNameForClassExpression(); - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return generateNameForMethodOrAccessor(node); - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return makeTempVariableName(0 /* Auto */, /*reserveInNestedScopes*/ true); default: return makeTempVariableName(0 /* Auto */); @@ -104685,25 +108279,45 @@ var ts; } // Comments function pipelineEmitWithComments(hint, node) { - ts.Debug.assert(lastNode === node || lastSubstitution === node); + var pipelinePhase = getNextPipelinePhase(2 /* Comments */, hint, node); + var savedContainerPos = containerPos; + var savedContainerEnd = containerEnd; + var savedDeclarationListContainerEnd = declarationListContainerEnd; + emitCommentsBeforeNode(node); + pipelinePhase(hint, node); + emitCommentsAfterNode(node, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd); + } + function emitCommentsBeforeNode(node) { + var emitFlags = ts.getEmitFlags(node); + var commentRange = ts.getCommentRange(node); + // Emit leading comments + emitLeadingCommentsOfNode(node, emitFlags, commentRange.pos, commentRange.end); + if (emitFlags & 2048 /* NoNestedComments */) { + commentsDisabled = true; + } + } + function emitCommentsAfterNode(node, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd) { + var emitFlags = ts.getEmitFlags(node); + var commentRange = ts.getCommentRange(node); + // Emit trailing comments + if (emitFlags & 2048 /* NoNestedComments */) { + commentsDisabled = false; + } + emitTrailingCommentsOfNode(node, emitFlags, commentRange.pos, commentRange.end, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd); + } + function emitLeadingCommentsOfNode(node, emitFlags, pos, end) { enterComment(); hasWrittenComment = false; - var emitFlags = ts.getEmitFlags(node); - var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; - var isEmittedNode = node.kind !== 335 /* NotEmittedStatement */; // 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 */; // Save current container state on the stack. - var savedContainerPos = containerPos; - var savedContainerEnd = containerEnd; - var savedDeclarationListContainerEnd = declarationListContainerEnd; 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); + emitLeadingComments(pos, /*isEmittedNode*/ node.kind !== 343 /* NotEmittedStatement */); } if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512 /* NoLeadingComments */) !== 0)) { // Advance the container position if comments get emitted or if they've been disabled explicitly using NoLeadingComments. @@ -104714,23 +108328,17 @@ var ts; 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 === 250 /* VariableDeclarationList */) { + if (node.kind === 252 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } } ts.forEach(ts.getSyntheticLeadingComments(node), emitLeadingSynthesizedComment); exitComment(); - var pipelinePhase = getNextPipelinePhase(2 /* Comments */, hint, node); - if (emitFlags & 2048 /* NoNestedComments */) { - commentsDisabled = true; - pipelinePhase(hint, node); - commentsDisabled = false; - } - else { - pipelinePhase(hint, node); - } + } + function emitTrailingCommentsOfNode(node, emitFlags, pos, end, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd) { enterComment(); + var skipTrailingComments = end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0 || node.kind === 11 /* JsxText */; ts.forEach(ts.getSyntheticTrailingComments(node), emitTrailingSynthesizedComment); if ((pos > 0 || end > 0) && pos !== end) { // Restore previous container state. @@ -104739,12 +108347,11 @@ 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 && isEmittedNode) { + if (!skipTrailingComments && node.kind !== 343 /* NotEmittedStatement */) { emitTrailingComments(end); } } exitComment(); - ts.Debug.assert(lastNode === node || lastSubstitution === node); } function emitLeadingSynthesizedComment(comment) { if (comment.hasLeadingNewline || comment.kind === 2 /* SingleLineCommentTrivia */) { @@ -104804,6 +108411,23 @@ var ts; } exitComment(); } + function siblingNodePositionsAreComparable(previousNode, nextNode) { + if (ts.nodeIsSynthesized(previousNode) || ts.nodeIsSynthesized(nextNode)) { + return false; + } + if (nextNode.pos < previousNode.end) { + return false; + } + previousNode = ts.getOriginalNode(previousNode); + nextNode = ts.getOriginalNode(nextNode); + var parent = previousNode.parent; + if (!parent || parent !== nextNode.parent) { + return false; + } + var parentNodeArray = ts.getContainingNodeArray(previousNode); + var prevNodeIndex = parentNodeArray === null || parentNodeArray === void 0 ? void 0 : parentNodeArray.indexOf(previousNode); + return prevNodeIndex !== undefined && prevNodeIndex > -1 && parentNodeArray.indexOf(nextNode) === prevNodeIndex + 1; + } function emitLeadingComments(pos, isEmittedNode) { hasWrittenComment = false; if (isEmittedNode) { @@ -104976,42 +108600,49 @@ var ts; } return node.parsedSourceMap || undefined; } - function pipelineEmitWithSourceMap(hint, node) { - ts.Debug.assert(lastNode === node || lastSubstitution === node); + function pipelineEmitWithSourceMaps(hint, node) { var pipelinePhase = getNextPipelinePhase(3 /* SourceMaps */, hint, node); - if (ts.isUnparsedSource(node) || ts.isUnparsedPrepend(node)) { - pipelinePhase(hint, node); - } - else if (ts.isUnparsedNode(node)) { + emitSourceMapsBeforeNode(node); + pipelinePhase(hint, node); + emitSourceMapsAfterNode(node); + } + function emitSourceMapsBeforeNode(node) { + var emitFlags = ts.getEmitFlags(node); + var sourceMapRange = ts.getSourceMapRange(node); + // Emit leading sourcemap + if (ts.isUnparsedNode(node)) { + ts.Debug.assertIsDefined(node.parent, "UnparsedNodes must have parent pointers"); var parsed = getParsedSourceMap(node.parent); if (parsed && sourceMapGenerator) { sourceMapGenerator.appendSourceMap(writer.getLine(), writer.getColumn(), parsed, node.parent.sourceMapPath, node.parent.getLineAndCharacterOfPosition(node.pos), node.parent.getLineAndCharacterOfPosition(node.end)); } - pipelinePhase(hint, node); } else { - var _a = ts.getSourceMapRange(node), pos = _a.pos, end = _a.end, _b = _a.source, source = _b === void 0 ? sourceMapSource : _b; - var emitFlags = ts.getEmitFlags(node); - if (node.kind !== 335 /* NotEmittedStatement */ + var source = sourceMapRange.source || sourceMapSource; + if (node.kind !== 343 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 - && pos >= 0) { - emitSourcePos(source, skipSourceTrivia(source, pos)); + && sourceMapRange.pos >= 0) { + emitSourcePos(sourceMapRange.source || sourceMapSource, skipSourceTrivia(source, sourceMapRange.pos)); } if (emitFlags & 64 /* NoNestedSourceMaps */) { sourceMapsDisabled = true; - pipelinePhase(hint, node); - sourceMapsDisabled = false; } - else { - pipelinePhase(hint, node); + } + } + function emitSourceMapsAfterNode(node) { + var emitFlags = ts.getEmitFlags(node); + var sourceMapRange = ts.getSourceMapRange(node); + // Emit trailing sourcemap + if (!ts.isUnparsedNode(node)) { + if (emitFlags & 64 /* NoNestedSourceMaps */) { + sourceMapsDisabled = false; } - if (node.kind !== 335 /* NotEmittedStatement */ + if (node.kind !== 343 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 - && end >= 0) { - emitSourcePos(source, end); + && sourceMapRange.end >= 0) { + emitSourcePos(sourceMapRange.source || sourceMapSource, sourceMapRange.end); } } - ts.Debug.assert(lastNode === node || lastSubstitution === node); } /** * Skips trivia such as comments and white-space that can be optionally overridden by the source-map source @@ -105163,12 +108794,22 @@ var ts; return ts.getBaseFileName(ts.normalizePath(fileName)); } function createCachedFileSystemEntries(rootDir, rootDirPath) { - var resultFromHost = { - files: ts.map(host.readDirectory(rootDir, /*extensions*/ undefined, /*exclude*/ undefined, /*include*/ ["*.*"]), getBaseNameOfFileName) || [], - directories: host.getDirectories(rootDir) || [] - }; - cachedReadDirectoryResult.set(ts.ensureTrailingDirectorySeparator(rootDirPath), resultFromHost); - return resultFromHost; + var _a; + if (!host.realpath || ts.ensureTrailingDirectorySeparator(toPath(host.realpath(rootDir))) === rootDirPath) { + var resultFromHost = { + files: ts.map(host.readDirectory(rootDir, /*extensions*/ undefined, /*exclude*/ undefined, /*include*/ ["*.*"]), getBaseNameOfFileName) || [], + directories: host.getDirectories(rootDir) || [] + }; + cachedReadDirectoryResult.set(ts.ensureTrailingDirectorySeparator(rootDirPath), resultFromHost); + return resultFromHost; + } + // If the directory is symlink do not cache the result + if ((_a = host.directoryExists) === null || _a === void 0 ? void 0 : _a.call(host, rootDir)) { + cachedReadDirectoryResult.set(rootDirPath, false); + return false; + } + // Non existing directory + return undefined; } /** * If the readDirectory result was already cached, it returns that @@ -105243,17 +108884,32 @@ var ts; } function readDirectory(rootDir, extensions, excludes, includes, depth) { var rootDirPath = toPath(rootDir); - var result = tryReadDirectory(rootDir, rootDirPath); - if (result) { + var rootResult = tryReadDirectory(rootDir, rootDirPath); + var rootSymLinkResult; + if (rootResult !== undefined) { return ts.matchFiles(rootDir, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, depth, getFileSystemEntries, realpath); } return host.readDirectory(rootDir, extensions, excludes, includes, depth); function getFileSystemEntries(dir) { var path = toPath(dir); if (path === rootDirPath) { - return result; + return rootResult || getFileSystemEntriesFromHost(dir, path); } - return tryReadDirectory(dir, path) || ts.emptyFileSystemEntries; + var result = tryReadDirectory(dir, path); + return result !== undefined ? + result || getFileSystemEntriesFromHost(dir, path) : + ts.emptyFileSystemEntries; + } + function getFileSystemEntriesFromHost(dir, path) { + if (rootSymLinkResult && path === rootDirPath) + return rootSymLinkResult; + var result = { + files: ts.map(host.readDirectory(dir, /*extensions*/ undefined, /*exclude*/ undefined, /*include*/ ["*.*"]), getBaseNameOfFileName) || ts.emptyArray, + directories: host.getDirectories(dir) || ts.emptyArray + }; + if (path === rootDirPath) + rootSymLinkResult = result; + return result; } } function realpath(s) { @@ -105261,7 +108917,7 @@ var ts; } function addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath) { var existingResult = getCachedFileSystemEntries(fileOrDirectoryPath); - if (existingResult) { + if (existingResult !== undefined) { // Just clear the cache for now // For now just clear the cache, since this could mean that multiple level entries might need to be re-evaluated clearCache(); @@ -105321,9 +108977,9 @@ var ts; /** * Updates the map of shared extended config file watches with a new set of extended config files from a base config file of the project */ - function updateSharedExtendedConfigFileWatcher(projectPath, parsed, extendedConfigFilesMap, createExtendedConfigFileWatch, toPath) { + function updateSharedExtendedConfigFileWatcher(projectPath, options, extendedConfigFilesMap, createExtendedConfigFileWatch, toPath) { var _a; - var extendedConfigs = ts.arrayToMap(((_a = parsed === null || parsed === void 0 ? void 0 : parsed.options.configFile) === null || _a === void 0 ? void 0 : _a.extendedSourceFiles) || ts.emptyArray, toPath); + var extendedConfigs = ts.arrayToMap(((_a = options === null || options === void 0 ? void 0 : options.configFile) === null || _a === void 0 ? void 0 : _a.extendedSourceFiles) || ts.emptyArray, toPath); // remove project from all unrelated watchers extendedConfigFilesMap.forEach(function (watcher, extendedConfigFilePath) { if (!extendedConfigs.has(extendedConfigFilePath)) { @@ -105341,12 +108997,12 @@ var ts; // start watching previously unseen extended config extendedConfigFilesMap.set(extendedConfigFilePath, { projects: new ts.Set([projectPath]), - fileWatcher: createExtendedConfigFileWatch(extendedConfigFileName, extendedConfigFilePath), + watcher: createExtendedConfigFileWatch(extendedConfigFileName, extendedConfigFilePath), close: function () { var existing = extendedConfigFilesMap.get(extendedConfigFilePath); if (!existing || existing.projects.size !== 0) return; - existing.fileWatcher.close(); + existing.watcher.close(); extendedConfigFilesMap.delete(extendedConfigFilePath); }, }); @@ -105354,6 +109010,31 @@ var ts; }); } ts.updateSharedExtendedConfigFileWatcher = updateSharedExtendedConfigFileWatcher; + /** + * Remove the project from the extended config file watchers and close not needed watches + */ + function clearSharedExtendedConfigFileWatcher(projectPath, extendedConfigFilesMap) { + extendedConfigFilesMap.forEach(function (watcher) { + if (watcher.projects.delete(projectPath)) + watcher.close(); + }); + } + ts.clearSharedExtendedConfigFileWatcher = clearSharedExtendedConfigFileWatcher; + /** + * Clean the extendsConfigCache when extended config file has changed + */ + function cleanExtendedConfigCache(extendedConfigCache, extendedConfigFilePath, toPath) { + if (!extendedConfigCache.delete(extendedConfigFilePath)) + return; + extendedConfigCache.forEach(function (_a, key) { + var _b; + var extendedResult = _a.extendedResult; + if ((_b = extendedResult.extendedSourceFiles) === null || _b === void 0 ? void 0 : _b.some(function (extendedFile) { return toPath(extendedFile) === extendedConfigFilePath; })) { + cleanExtendedConfigCache(extendedConfigCache, key, toPath); + } + }); + } + ts.cleanExtendedConfigCache = cleanExtendedConfigCache; /** * Updates the existing missing file watches with the new set of missing files after new program is created */ @@ -105405,7 +109086,7 @@ var ts; ts.updateWatchingWildcardDirectories = updateWatchingWildcardDirectories; /* @internal */ function isIgnoredFileFromWildCardWatching(_a) { - 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; + 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); @@ -105428,7 +109109,7 @@ var ts; return false; // We want to ignore emit file check if file is not going to be emitted next to source file // In that case we follow config file inclusion rules - if (options.outFile || options.outDir) + if (ts.outFile(options) || options.outDir) return false; // File if emitted next to input needs to be ignored if (ts.fileExtensionIs(fileOrDirectoryPath, ".d.ts" /* Dts */)) { @@ -105441,7 +109122,8 @@ var ts; } // just check if sourceFile with the name exists var filePathWithoutExtension = ts.removeFileExtension(fileOrDirectoryPath); - var realProgram = isBuilderProgram(program) ? program.getProgramOrUndefined() : program; + 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); @@ -105451,7 +109133,9 @@ var ts; function hasSourceFile(file) { return realProgram ? !!realProgram.getSourceFileByPath(file) : - program.getState().fileInfos.has(file); + builderProgram ? + builderProgram.getState().fileInfos.has(file) : + !!ts.find(program, function (rootFile) { return toPath(rootFile) === file; }); } } ts.isIgnoredFileFromWildCardWatching = isIgnoredFileFromWildCardWatching; @@ -105924,8 +109608,8 @@ var ts; var lineStart = ts.getPositionOfLineAndCharacter(file, i, 0); var lineEnd = i < lastLineInFile ? ts.getPositionOfLineAndCharacter(file, i + 1, 0) : file.text.length; var lineContent = file.text.slice(lineStart, lineEnd); - lineContent = lineContent.replace(/\s+$/g, ""); // trim from end - lineContent = lineContent.replace("\t", " "); // convert tabs to single spaces + lineContent = ts.trimStringEnd(lineContent); // trim from end + lineContent = lineContent.replace(/\t/g, " "); // convert tabs to single spaces // Output the gutter and the actual contents of the line. context += indent + formatColorAndReset(ts.padLeft(i + 1 + "", gutterWidth), gutterStyleSequence) + gutterSeparator; context += lineContent + host.getNewLine(); @@ -106130,38 +109814,31 @@ var ts; * Determines if program structure is upto date or needs to be recreated */ /* @internal */ - function isProgramUptoDate(program, rootFileNames, newOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, projectReferences) { + function isProgramUptoDate(program, rootFileNames, newOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences) { // If we haven't created a program yet or have changed automatic type directives, then it is not up-to-date - if (!program || (hasChangedAutomaticTypeDirectiveNames === null || hasChangedAutomaticTypeDirectiveNames === void 0 ? void 0 : hasChangedAutomaticTypeDirectiveNames())) { + if (!program || (hasChangedAutomaticTypeDirectiveNames === null || hasChangedAutomaticTypeDirectiveNames === void 0 ? void 0 : hasChangedAutomaticTypeDirectiveNames())) return false; - } // If root file names don't match - if (!ts.arrayIsEqualTo(program.getRootFileNames(), rootFileNames)) { + if (!ts.arrayIsEqualTo(program.getRootFileNames(), rootFileNames)) return false; - } var seenResolvedRefs; // If project references don't match - if (!ts.arrayIsEqualTo(program.getProjectReferences(), projectReferences, projectReferenceUptoDate)) { + if (!ts.arrayIsEqualTo(program.getProjectReferences(), projectReferences, projectReferenceUptoDate)) return false; - } // If any file is not up-to-date, then the whole program is not up-to-date - if (program.getSourceFiles().some(sourceFileNotUptoDate)) { + if (program.getSourceFiles().some(sourceFileNotUptoDate)) return false; - } // If any of the missing file paths are now created - if (program.getMissingFilePaths().some(fileExists)) { + if (program.getMissingFilePaths().some(fileExists)) return false; - } var currentOptions = program.getCompilerOptions(); // If the compilation settings do no match, then the program is not up-to-date - if (!ts.compareDataObjects(currentOptions, newOptions)) { + if (!ts.compareDataObjects(currentOptions, newOptions)) return false; - } // If everything matches but the text of config file is changed, // error locations can change for program options, so update the program - if (currentOptions.configFile && newOptions.configFile) { + if (currentOptions.configFile && newOptions.configFile) return currentOptions.configFile.text === newOptions.configFile.text; - } return true; function sourceFileNotUptoDate(sourceFile) { return !sourceFileVersionUptoDate(sourceFile) || @@ -106171,21 +109848,25 @@ var ts; return sourceFile.version === getSourceVersion(sourceFile.resolvedPath, sourceFile.fileName); } function projectReferenceUptoDate(oldRef, newRef, index) { - if (!ts.projectReferenceIsEqualTo(oldRef, newRef)) { - return false; - } - return resolvedProjectReferenceUptoDate(program.getResolvedProjectReferences()[index], oldRef); + return ts.projectReferenceIsEqualTo(oldRef, newRef) && + resolvedProjectReferenceUptoDate(program.getResolvedProjectReferences()[index], oldRef); } function resolvedProjectReferenceUptoDate(oldResolvedRef, oldRef) { if (oldResolvedRef) { - if (ts.contains(seenResolvedRefs, oldResolvedRef)) { - // Assume true + // Assume true + if (ts.contains(seenResolvedRefs, oldResolvedRef)) return true; - } - // If sourceFile for the oldResolvedRef existed, check the version for uptodate - if (!sourceFileVersionUptoDate(oldResolvedRef.sourceFile)) { + var refPath_1 = resolveProjectReferencePath(oldRef); + var newParsedCommandLine = getParsedCommandLine(refPath_1); + // Check if config file exists + if (!newParsedCommandLine) + return false; + // If change in source file + if (oldResolvedRef.commandLine.options.configFile !== newParsedCommandLine.options.configFile) + return false; + // check file names + if (!ts.arrayIsEqualTo(oldResolvedRef.commandLine.fileNames, newParsedCommandLine.fileNames)) return false; - } // Add to seen before checking the referenced paths of this config file (seenResolvedRefs || (seenResolvedRefs = [])).push(oldResolvedRef); // If child project references are upto date, this project reference is uptodate @@ -106195,7 +109876,8 @@ var ts; } // In old program, not able to resolve project reference path, // so if config file doesnt exist, it is uptodate. - return !fileExists(resolveProjectReferencePath(oldRef)); + var refPath = resolveProjectReferencePath(oldRef); + return !getParsedCommandLine(refPath); } } ts.isProgramUptoDate = isProgramUptoDate; @@ -106212,10 +109894,7 @@ var ts; return false; // If any compiler options change, we can't reuse old source file even if version match // The change in options like these could result in change in syntax tree or `sourceFile.bindDiagnostics`. - var oldOptions = program.getCompilerOptions(); - return !!ts.sourceFileAffectingCompilerOptions.some(function (option) { - return !ts.isJsonEqual(ts.getCompilerOptionValue(oldOptions, option), ts.getCompilerOptionValue(newOptions, option)); - }); + return ts.optionsHaveChanges(program.getCompilerOptions(), newOptions, ts.sourceFileAffectingCompilerOptions); } function createCreateProgramOptions(rootNames, options, host, oldProgram, configFileParsingDiagnostics) { return { @@ -106259,7 +109938,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.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" /* Program */, "createProgram", { configFilePath: options.configFilePath, rootDir: options.rootDir }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeProgram"); var host = createProgramOptions.host || createCompilerHost(options); var configParsingHost = parseConfigHostFromCompilerHostLike(host); @@ -106274,6 +109953,7 @@ var ts; var hasEmitBlockingDiagnostics = new ts.Map(); var _compilerOptionsObjectLiteralSyntax; var moduleResolutionCache; + var typeReferenceDirectiveResolutionCache; var actualResolveModuleNamesWorker; var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse; if (host.resolveModuleNames) { @@ -106288,7 +109968,7 @@ var ts; }); }; } else { - moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, function (x) { return host.getCanonicalFileName(x); }, options); + moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName, options); var loader_1 = function (moduleName, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache, redirectedReference).resolvedModule; }; // TODO: GH#18217 actualResolveModuleNamesWorker = function (moduleNames, containingFile, _reusedNames, redirectedReference) { return loadWithLocalCache(ts.Debug.checkEachDefined(moduleNames), containingFile, redirectedReference, loader_1); }; } @@ -106297,7 +109977,8 @@ var ts; actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options); }; } else { - var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference).resolvedTypeReferenceDirective; }; // TODO: GH#18217 + typeReferenceDirectiveResolutionCache = ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, /*options*/ undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache()); + var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache).resolvedTypeReferenceDirective; }; // TODO: GH#18217 actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { return loadWithLocalCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, loader_2); }; } // Map from a stringified PackageId to the source file with that id. @@ -106335,15 +110016,15 @@ var ts; getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect, forEachResolvedProjectReference: forEachResolvedProjectReference }), onProgramCreateComplete = _d.onProgramCreateComplete, fileExists = _d.fileExists, directoryExists = _d.directoryExists; - ts.tracing.push("program" /* Program */, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram }); var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options); - ts.tracing.pop(); + 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.push("program" /* Program */, "tryReuseStructureFromOldProgram", {}); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "tryReuseStructureFromOldProgram", {}); structureIsReused = tryReuseStructureFromOldProgram(); // eslint-disable-line prefer-const - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); if (structureIsReused !== 2 /* Completely */) { processingDefaultLibFiles = []; processingOtherFiles = []; @@ -106381,13 +110062,13 @@ var ts; }); } } - ts.tracing.push("program" /* Program */, "processRootFiles", { count: rootNames.length }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* 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.pop(); + 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.push("program" /* Program */, "processTypeReferences", { count: typeReferences.length }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* 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); @@ -106395,7 +110076,7 @@ var ts; for (var i = 0; i < typeReferences.length; i++) { processTypeReferenceDirective(typeReferences[i], resolutions[i], { kind: ts.FileIncludeKind.AutomaticTypeDirectiveFile, typeReference: typeReferences[i], packageId: (_b = resolutions[i]) === null || _b === void 0 ? void 0 : _b.packageId }); } - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } // Do not process the default library if: // - The '--noLib' flag is used. @@ -106436,12 +110117,25 @@ var ts; host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path)); } } - oldProgram.forEachResolvedProjectReference(function (resolvedProjectReference) { - if (!getResolvedProjectReferenceByPath(resolvedProjectReference.sourceFile.path)) { - host.onReleaseOldSourceFile(resolvedProjectReference.sourceFile, oldProgram.getCompilerOptions(), /*hasSourceFileByPath*/ false); + if (!host.getParsedCommandLine) { + oldProgram.forEachResolvedProjectReference(function (resolvedProjectReference) { + if (!getResolvedProjectReferenceByPath(resolvedProjectReference.sourceFile.path)) { + host.onReleaseOldSourceFile(resolvedProjectReference.sourceFile, oldProgram.getCompilerOptions(), /*hasSourceFileByPath*/ false); + } + }); + } + } + // Release commandlines that new program does not use + if (oldProgram && host.onReleaseParsedCommandLine) { + forEachProjectReference(oldProgram.getProjectReferences(), oldProgram.getResolvedProjectReferences(), function (oldResolvedRef, parent, index) { + var oldReference = (parent === null || parent === void 0 ? void 0 : parent.commandLine.projectReferences[index]) || oldProgram.getProjectReferences()[index]; + var oldRefPath = resolveProjectReferencePath(oldReference); + if (!(projectReferenceRedirects === null || projectReferenceRedirects === void 0 ? void 0 : projectReferenceRedirects.has(toPath(oldRefPath)))) { + host.onReleaseParsedCommandLine(oldRefPath, oldResolvedRef, oldProgram.getCompilerOptions()); } }); } + typeReferenceDirectiveResolutionCache = undefined; // unconditionally set oldProgram to undefined to prevent it from being captured in closure oldProgram = undefined; var program = { @@ -106470,7 +110164,6 @@ var ts; getNodeCount: function () { return getDiagnosticsProducingTypeChecker().getNodeCount(); }, getIdentifierCount: function () { return getDiagnosticsProducingTypeChecker().getIdentifierCount(); }, getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); }, - getTypeCatalog: function () { return getDiagnosticsProducingTypeChecker().getTypeCatalog(); }, getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); }, getInstantiationCount: function () { return getDiagnosticsProducingTypeChecker().getInstantiationCount(); }, getRelationCacheSizes: function () { return getDiagnosticsProducingTypeChecker().getRelationCacheSizes(); }, @@ -106518,19 +110211,19 @@ var ts; verifyCompilerOptions(); ts.performance.mark("afterProgram"); ts.performance.measure("Program", "beforeProgram", "afterProgram"); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return program; function resolveModuleNamesWorker(moduleNames, containingFile, reusedNames) { if (!moduleNames.length) return ts.emptyArray; var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory); var redirectedReference = getRedirectReferenceForResolution(containingFile); - ts.tracing.push("program" /* Program */, "resolveModuleNamesWorker", { containingFileName: containingFileName }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveModuleNamesWorker", { containingFileName: containingFileName }); ts.performance.mark("beforeResolveModule"); var result = actualResolveModuleNamesWorker(moduleNames, containingFileName, reusedNames, redirectedReference); ts.performance.mark("afterResolveModule"); ts.performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule"); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; } function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile) { @@ -106538,12 +110231,12 @@ var ts; return []; var containingFileName = !ts.isString(containingFile) ? ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile; var redirectedReference = !ts.isString(containingFile) ? getRedirectReferenceForResolution(containingFile) : undefined; - ts.tracing.push("program" /* Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName }); ts.performance.mark("beforeResolveTypeReference"); var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference); ts.performance.mark("afterResolveTypeReference"); ts.performance.measure("ResolveTypeReference", "beforeResolveTypeReference", "afterResolveTypeReference"); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; } function getRedirectReferenceForResolution(file) { @@ -106670,7 +110363,9 @@ var ts; var oldResolvedModule = ts.getResolvedModule(oldSourceFile, moduleName); if (oldResolvedModule) { if (ts.isTraceEnabled(options, host)) { - ts.trace(host, ts.Diagnostics.Reusing_resolution_of_module_0_to_file_1_from_old_program, moduleName, ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory)); + ts.trace(host, oldResolvedModule.packageId ? + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 : + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2, moduleName, ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory), oldResolvedModule.resolvedFileName, oldResolvedModule.packageId && ts.packageIdToString(oldResolvedModule.packageId)); } (result || (result = new Array(moduleNames.length)))[i] = oldResolvedModule; (reusedNames || (reusedNames = [])).push(moduleName); @@ -106753,7 +110448,9 @@ var ts; var newResolvedRef = parseProjectReferenceConfigFile(newRef); if (oldResolvedRef) { // Resolved project reference has gone missing or changed - return !newResolvedRef || newResolvedRef.sourceFile !== oldResolvedRef.sourceFile; + return !newResolvedRef || + newResolvedRef.sourceFile !== oldResolvedRef.sourceFile || + !ts.arrayIsEqualTo(oldResolvedRef.commandLine.fileNames, newResolvedRef.commandLine.fileNames); } else { // A previously-unresolved reference may be resolved now @@ -106781,9 +110478,6 @@ var ts; if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) { return 0 /* Not */; } - if (!ts.arrayIsEqualTo(options.types, oldOptions.types)) { - return 0 /* Not */; - } // Check if any referenced project tsconfig files are different if (!canReuseProjectReferences()) { return 0 /* Not */; @@ -106858,7 +110552,7 @@ var ts; // The `newSourceFile` object was created for the new program. if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) { // 'lib' references has changed. Matches behavior in changesAffectModuleResolution - return 0 /* Not */; + structureIsReused = 1 /* SafeModules */; } if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { // value of no-default-lib has changed @@ -106943,7 +110637,7 @@ var ts; if (structureIsReused !== 2 /* Completely */) { return structureIsReused; } - if ((_a = host.hasChangedAutomaticTypeDirectiveNames) === null || _a === void 0 ? void 0 : _a.call(host)) { + if (ts.changesAffectingProgramStructure(oldOptions, options) || ((_a = host.hasChangedAutomaticTypeDirectiveNames) === null || _a === void 0 ? void 0 : _a.call(host))) { return 1 /* SafeModules */; } missingFilePaths = oldProgram.getMissingFilePaths(); @@ -107015,7 +110709,7 @@ var ts; } function emitBuildInfo(writeFileCallback) { ts.Debug.assert(!ts.outFile(options)); - ts.tracing.push("emit" /* Emit */, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeEmit"); var emitResult = ts.emitFiles(ts.notImplementedResolver, getEmitHost(writeFileCallback), /*targetSourceFile*/ undefined, @@ -107024,7 +110718,7 @@ var ts; /*onlyBuildInfo*/ true); ts.performance.mark("afterEmit"); ts.performance.measure("Emit", "beforeEmit", "afterEmit"); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return emitResult; } function getResolvedProjectReferences() { @@ -107070,9 +110764,9 @@ var ts; return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ false)); } function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) { - 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" /* 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.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; } function isEmitBlocked(emitFileName) { @@ -107276,22 +110970,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 160 /* Parameter */: - case 163 /* PropertyDeclaration */: - case 165 /* MethodDeclaration */: + case 162 /* Parameter */: + case 165 /* PropertyDeclaration */: + case 167 /* 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 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: - case 209 /* ArrowFunction */: - case 249 /* VariableDeclaration */: + case 166 /* MethodSignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 210 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 211 /* ArrowFunction */: + case 251 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files)); @@ -107299,58 +110993,58 @@ var ts; } } switch (node.kind) { - case 262 /* ImportClause */: + case 264 /* 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 267 /* ExportDeclaration */: + case 269 /* 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 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_TypeScript_files)); return "skip"; - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 286 /* HeritageClause */: + case 288 /* HeritageClause */: var heritageClause = node; - if (heritageClause.token === 116 /* ImplementsKeyword */) { + if (heritageClause.token === 117 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 253 /* InterfaceDeclaration */: - var interfaceKeyword = ts.tokenToString(117 /* InterfaceKeyword */); + case 255 /* InterfaceDeclaration */: + var interfaceKeyword = ts.tokenToString(118 /* InterfaceKeyword */); ts.Debug.assertIsDefined(interfaceKeyword); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, interfaceKeyword)); return "skip"; - case 256 /* ModuleDeclaration */: - var moduleKeyword = node.flags & 16 /* Namespace */ ? ts.tokenToString(140 /* NamespaceKeyword */) : ts.tokenToString(139 /* ModuleKeyword */); + case 258 /* ModuleDeclaration */: + var moduleKeyword = node.flags & 16 /* Namespace */ ? ts.tokenToString(141 /* NamespaceKeyword */) : ts.tokenToString(140 /* ModuleKeyword */); ts.Debug.assertIsDefined(moduleKeyword); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, moduleKeyword)); return "skip"; - case 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_aliases_can_only_be_used_in_TypeScript_files)); return "skip"; - case 255 /* EnumDeclaration */: - var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(91 /* EnumKeyword */)); + case 257 /* EnumDeclaration */: + var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(92 /* EnumKeyword */)); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, enumKeyword)); return "skip"; - case 225 /* NonNullExpression */: + case 227 /* NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Non_null_assertions_can_only_be_used_in_TypeScript_files)); return "skip"; - case 224 /* AsExpression */: + case 226 /* AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.Type_assertion_expressions_can_only_be_used_in_TypeScript_files)); return "skip"; - case 206 /* TypeAssertionExpression */: + case 208 /* TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } } @@ -107359,53 +111053,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 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: - case 209 /* ArrowFunction */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 167 /* MethodDeclaration */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 210 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 211 /* 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 232 /* VariableStatement */: + case 234 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - checkModifiers(parent.modifiers, parent.kind === 232 /* VariableStatement */); + checkModifiers(parent.modifiers, parent.kind === 234 /* VariableStatement */); return "skip"; } break; - case 163 /* PropertyDeclaration */: + case 165 /* 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 (modifier.kind !== 123 /* StaticKeyword */) { + if (modifier.kind !== 124 /* 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 160 /* Parameter */: + case 162 /* Parameter */: // Check modifiers of parameter declaration if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Parameter_modifiers_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 203 /* CallExpression */: - case 204 /* NewExpression */: - case 223 /* ExpressionWithTypeArguments */: - case 274 /* JsxSelfClosingElement */: - case 275 /* JsxOpeningElement */: - case 205 /* TaggedTemplateExpression */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: + case 225 /* ExpressionWithTypeArguments */: + case 276 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: + case 207 /* TaggedTemplateExpression */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_arguments_can_only_be_used_in_TypeScript_files)); @@ -107418,24 +111112,25 @@ var ts; for (var _i = 0, modifiers_2 = modifiers; _i < modifiers_2.length; _i++) { var modifier = modifiers_2[_i]; switch (modifier.kind) { - case 84 /* ConstKeyword */: + case 85 /* ConstKeyword */: if (isConstValid) { continue; } // to report error, // falls through - case 122 /* PublicKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 142 /* ReadonlyKeyword */: - case 133 /* DeclareKeyword */: - case 125 /* AbstractKeyword */: + case 123 /* PublicKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + case 143 /* ReadonlyKeyword */: + case 134 /* DeclareKeyword */: + case 126 /* AbstractKeyword */: + case 157 /* OverrideKeyword */: 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 123 /* StaticKeyword */: - case 92 /* ExportKeyword */: - case 87 /* DefaultKeyword */: + case 124 /* StaticKeyword */: + case 93 /* ExportKeyword */: + case 88 /* DefaultKeyword */: } } } @@ -107506,8 +111201,8 @@ var ts; return a.fileName === b.fileName; } function moduleNameIsEqualTo(a, b) { - return a.kind === 78 /* Identifier */ - ? b.kind === 78 /* Identifier */ && a.escapedText === b.escapedText + return a.kind === 79 /* Identifier */ + ? b.kind === 79 /* Identifier */ && a.escapedText === b.escapedText : b.kind === 10 /* StringLiteral */ && a.text === b.text; } function createSyntheticImport(text, file) { @@ -107733,13 +111428,13 @@ var ts; } // Get source file from normalized fileName function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, reason, packageId) { - ts.tracing.push("program" /* Program */, "findSourceFile", { + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "findSourceFile", { fileName: fileName, isDefaultLib: isDefaultLib || undefined, fileIncludeKind: ts.FileIncludeKind[reason.kind], }); var result = findSourceFileWorker(fileName, path, isDefaultLib, ignoreNoDefaultLib, reason, packageId); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; } function findSourceFileWorker(fileName, path, isDefaultLib, ignoreNoDefaultLib, reason, packageId) { @@ -107998,9 +111693,9 @@ var ts; } } function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, reason) { - 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" /* Program */, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolveModuleNamesReusingOldState, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined }); processTypeReferenceDirectiveWorker(typeReferenceDirective, resolvedTypeReferenceDirective, reason); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } function processTypeReferenceDirectiveWorker(typeReferenceDirective, resolvedTypeReferenceDirective, reason) { // If we already found this library as a primary reference - nothing to do @@ -108071,12 +111766,14 @@ var ts; return host.getCanonicalFileName(fileName); } function processImportedModules(file) { + var _a; collectExternalModuleReferences(file); if (file.imports.length || file.moduleAugmentations.length) { // Because global augmentation doesn't have string literal name, we can check for global augmentation as such. var moduleNames = getModuleNames(file); var resolutions = resolveModuleNamesReusingOldState(moduleNames, file); ts.Debug.assert(resolutions.length === moduleNames.length); + var optionsForFile = (useSourceOfProjectReferenceRedirect ? (_a = getRedirectReferenceForResolution(file)) === null || _a === void 0 ? void 0 : _a.commandLine.options : undefined) || options; for (var index = 0; index < moduleNames.length; index++) { var resolution = resolutions[index]; ts.setResolvedModule(file, moduleNames[index], resolution); @@ -108099,11 +111796,11 @@ var ts; // Don't add the file if it has a bad extension (e.g. 'tsx' if we don't have '--allowJs') // This may still end up being an untyped module -- the file won't be included but imports will be allowed. var shouldAddFile = resolvedFileName - && !getResolutionDiagnostic(options, resolution) - && !options.noResolve + && !getResolutionDiagnostic(optionsForFile, resolution) + && !optionsForFile.noResolve && index < file.imports.length && !elideImport - && !(isJsFile && !ts.getAllowJSCompilerOption(options)) + && !(isJsFile && !ts.getAllowJSCompilerOption(optionsForFile)) && (ts.isInJSFile(file.imports[index]) || !(file.imports[index].flags & 4194304 /* JSDoc */)); if (elideImport) { modulesWithElidedImports.set(file.path, true); @@ -108189,6 +111886,9 @@ var ts; if (options.strictPropertyInitialization && !ts.getStrictOptionValue(options, "strictNullChecks")) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictPropertyInitialization", "strictNullChecks"); } + if (options.strictOptionalProperties && !ts.getStrictOptionValue(options, "strictNullChecks")) { + createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictOptionalProperties", "strictNullChecks"); + } if (options.isolatedModules) { if (options.out) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules"); @@ -108306,6 +112006,9 @@ var ts; if (options.module === ts.ModuleKind.None && languageVersion < 2 /* 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 */; }); if (firstNonExternalModuleSourceFile) { var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); @@ -108336,9 +112039,10 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Option_resolveJsonModule_can_only_be_specified_when_module_code_generation_is_commonjs_amd_es2015_or_esNext, "resolveJsonModule", "module"); } } - // there has to be common source directory if user specified --outdir || --sourceRoot + // there has to be common source directory if user specified --outdir || --rootDir || --sourceRoot // if user specified --mapRoot, there needs to be common source directory if there would be multiple files being emitted if (options.outDir || // there is --outDir specified + options.rootDir || // there is --rootDir specified options.sourceRoot || // there is --sourceRoot specified options.mapRoot) { // there is --mapRoot specified // Precalculate and cache the common source directory @@ -108835,7 +112539,7 @@ var ts; } function handleDirectoryCouldBeSymlink(directory) { var _a; - if (!host.getResolvedProjectReferences()) + if (!host.getResolvedProjectReferences() || ts.containsIgnoredPath(directory)) return; // Because we already watch node_modules, handle symlinks in there if (!originalRealpath || !ts.stringContains(directory, ts.nodeModulesPathPart)) @@ -108852,7 +112556,7 @@ var ts; symlinkCache.setSymlinkedDirectory(directoryPath, false); return; } - symlinkCache.setSymlinkedDirectory(directoryPath, { + symlinkCache.setSymlinkedDirectory(directory, { real: ts.ensureTrailingDirectorySeparator(real), realPath: realPath }); @@ -109128,12 +112832,15 @@ var ts; // From ambient modules for (var _f = 0, _g = program.getTypeChecker().getAmbientModules(); _f < _g.length; _f++) { var ambientModule = _g[_f]; - if (ambientModule.declarations.length > 1) { + if (ambientModule.declarations && ambientModule.declarations.length > 1) { addReferenceFromAmbientModule(ambientModule); } } return referencedFiles; function addReferenceFromAmbientModule(symbol) { + if (!symbol.declarations) { + return; + } // Add any file other than our own as reference for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; @@ -109158,7 +112865,7 @@ var ts; /** * Creates the state of file references and signature for the new program from oldState if it is safe */ - function create(newProgram, getCanonicalFileName, oldState) { + function create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) { var fileInfos = new ts.Map(); var referencedMap = newProgram.getCompilerOptions().module !== ts.ModuleKind.None ? new ts.Map() : undefined; var exportedModulesMap = referencedMap ? new ts.Map() : undefined; @@ -109184,13 +112891,14 @@ var ts; } } } - fileInfos.set(sourceFile.resolvedPath, { version: version_2, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) }); + fileInfos.set(sourceFile.resolvedPath, { version: version_2, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) || undefined }); } return { fileInfos: fileInfos, referencedMap: referencedMap, exportedModulesMap: exportedModulesMap, - hasCalledUpdateShapeSignature: hasCalledUpdateShapeSignature + hasCalledUpdateShapeSignature: hasCalledUpdateShapeSignature, + useFileVersionAsSignature: !disableUseFileVersionAsSignature && !useOldState }; } BuilderState.create = create; @@ -109212,6 +112920,7 @@ var ts; referencedMap: state.referencedMap && new ts.Map(state.referencedMap), exportedModulesMap: state.exportedModulesMap && new ts.Map(state.exportedModulesMap), hasCalledUpdateShapeSignature: new ts.Set(state.hasCalledUpdateShapeSignature), + useFileVersionAsSignature: state.useFileVersionAsSignature, }; } BuilderState.clone = clone; @@ -109267,23 +112976,12 @@ var ts; return ts.Debug.fail(); var prevSignature = info.signature; var latestSignature; - if (sourceFile.isDeclarationFile) { - latestSignature = sourceFile.version; - if (exportedModulesMapCache && latestSignature !== prevSignature) { - // All the references in this file are exported - var references = state.referencedMap ? state.referencedMap.get(sourceFile.resolvedPath) : undefined; - exportedModulesMapCache.set(sourceFile.resolvedPath, references || false); - } - } - else { + if (!sourceFile.isDeclarationFile && !state.useFileVersionAsSignature) { var emitOutput_1 = getFileEmitOutput(programOfThisState, sourceFile, /*emitOnlyDtsFiles*/ true, cancellationToken, /*customTransformers*/ undefined, /*forceDtsEmit*/ true); - var firstDts_1 = emitOutput_1.outputFiles && - programOfThisState.getCompilerOptions().declarationMap ? - emitOutput_1.outputFiles.length > 1 ? emitOutput_1.outputFiles[1] : undefined : - emitOutput_1.outputFiles.length > 0 ? emitOutput_1.outputFiles[0] : undefined; + var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles); if (firstDts_1) { ts.Debug.assert(ts.fileExtensionIs(firstDts_1.name, ".d.ts" /* Dts */), "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 = (computeHash || ts.generateDjb2Hash)(firstDts_1.text); @@ -109291,12 +112989,18 @@ var ts; updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache); } } - else { - latestSignature = prevSignature; // TODO: GH#18217 + } + // Default is to use file version as signature + if (latestSignature === undefined) { + latestSignature = sourceFile.version; + if (exportedModulesMapCache && latestSignature !== prevSignature) { + // All the references in this file are exported + var references = state.referencedMap ? state.referencedMap.get(sourceFile.resolvedPath) : undefined; + exportedModulesMapCache.set(sourceFile.resolvedPath, references || false); } } cacheToUpdateSignature.set(sourceFile.resolvedPath, latestSignature); - return !prevSignature || latestSignature !== prevSignature; + return latestSignature !== prevSignature; } BuilderState.updateShapeSignature = updateShapeSignature; /** @@ -109416,7 +113120,7 @@ var ts; */ function isFileAffectingGlobalScope(sourceFile) { return containsGlobalScopeAugmentation(sourceFile) || - !ts.isExternalModule(sourceFile) && !containsOnlyAmbientModules(sourceFile); + !ts.isExternalOrCommonJsModule(sourceFile) && !containsOnlyAmbientModules(sourceFile); } /** * Gets all files of the program excluding the default library file @@ -109504,8 +113208,8 @@ var ts; /** * Create the state so that we can iterate on changedFiles/affected files */ - function createBuilderProgramState(newProgram, getCanonicalFileName, oldState) { - var state = ts.BuilderState.create(newProgram, getCanonicalFileName, oldState); + function createBuilderProgramState(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) { + var state = ts.BuilderState.create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature); state.program = newProgram; var compilerOptions = newProgram.getCompilerOptions(); state.compilerOptions = compilerOptions; @@ -109743,6 +113447,7 @@ var ts; * 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) { + var _a; removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath); // If affected files is everything except default library, then nothing more to do if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) { @@ -109756,8 +113461,15 @@ var ts; removeSemanticDiagnosticsOf(state, f.resolvedPath); }); } + // 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, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap); return; } + else { + ts.Debug.assert(state.hasCalledUpdateShapeSignature.has(affectedFile.resolvedPath) || ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.has(affectedFile.resolvedPath)), "Signature not updated for affected file: " + affectedFile.fileName); + } if (!state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) { forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash); }); } @@ -109969,83 +113681,116 @@ var ts; return undefined; var currentDirectory = ts.Debug.checkDefined(state.program).getCurrentDirectory(); var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory)); - var fileInfos = {}; - state.fileInfos.forEach(function (value, key) { + var fileNames = []; + var fileNameToFileId = new ts.Map(); + var fileIdsList; + var fileNamesToFileIdListId; + var fileInfos = ts.arrayFrom(state.fileInfos.entries(), function (_a) { + var key = _a[0], value = _a[1]; + // Ensure fileId + var fileId = toFileId(key); + ts.Debug.assert(fileNames[fileId - 1] === relativeToBuildInfo(key)); var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key); - fileInfos[relativeToBuildInfo(key)] = signature === undefined ? value : { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope }; + var actualSignature = signature !== null && signature !== void 0 ? signature : value.signature; + return value.version === actualSignature ? + value.affectsGlobalScope ? + { version: value.version, signature: undefined, affectsGlobalScope: true } : + value.version : + actualSignature !== undefined ? + signature === undefined ? + value : + { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope } : + { version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope }; }); - var result = { - fileInfos: fileInfos, - options: convertToReusableCompilerOptions(state.compilerOptions, relativeToBuildInfoEnsuringAbsolutePath) - }; + var referencedMap; if (state.referencedMap) { - var referencedMap = {}; - for (var _i = 0, _a = ts.arrayFrom(state.referencedMap.keys()).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) { - var key = _a[_i]; - referencedMap[relativeToBuildInfo(key)] = ts.arrayFrom(state.referencedMap.get(key).keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive); - } - result.referencedMap = referencedMap; + referencedMap = ts.arrayFrom(state.referencedMap.keys()).sort(ts.compareStringsCaseSensitive).map(function (key) { return [ + toFileId(key), + toFileIdListId(state.referencedMap.get(key)) + ]; }); } + var exportedModulesMap; if (state.exportedModulesMap) { - var exportedModulesMap = {}; - for (var _b = 0, _c = ts.arrayFrom(state.exportedModulesMap.keys()).sort(ts.compareStringsCaseSensitive); _b < _c.length; _b++) { - var key = _c[_b]; + exportedModulesMap = ts.mapDefined(ts.arrayFrom(state.exportedModulesMap.keys()).sort(ts.compareStringsCaseSensitive), function (key) { var newValue = state.currentAffectedFilesExportedModulesMap && state.currentAffectedFilesExportedModulesMap.get(key); // Not in temporary cache, use existing value if (newValue === undefined) - exportedModulesMap[relativeToBuildInfo(key)] = ts.arrayFrom(state.exportedModulesMap.get(key).keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive); + return [toFileId(key), toFileIdListId(state.exportedModulesMap.get(key))]; // Value in cache and has updated value map, use that else if (newValue) - exportedModulesMap[relativeToBuildInfo(key)] = ts.arrayFrom(newValue.keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive); - } - result.exportedModulesMap = exportedModulesMap; + return [toFileId(key), toFileIdListId(newValue)]; + }); } + var semanticDiagnosticsPerFile; if (state.semanticDiagnosticsPerFile) { - var semanticDiagnosticsPerFile = []; - for (var _d = 0, _e = ts.arrayFrom(state.semanticDiagnosticsPerFile.keys()).sort(ts.compareStringsCaseSensitive); _d < _e.length; _d++) { - var key = _e[_d]; + for (var _i = 0, _a = ts.arrayFrom(state.semanticDiagnosticsPerFile.keys()).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) { + var key = _a[_i]; var value = state.semanticDiagnosticsPerFile.get(key); - semanticDiagnosticsPerFile.push(value.length ? + (semanticDiagnosticsPerFile || (semanticDiagnosticsPerFile = [])).push(value.length ? [ - relativeToBuildInfo(key), + toFileId(key), state.hasReusableDiagnostic ? value : convertToReusableDiagnostics(value, relativeToBuildInfo) ] : - relativeToBuildInfo(key)); + toFileId(key)); } - result.semanticDiagnosticsPerFile = semanticDiagnosticsPerFile; } + var affectedFilesPendingEmit; if (state.affectedFilesPendingEmit) { - var affectedFilesPendingEmit = []; var seenFiles = new ts.Set(); - for (var _f = 0, _g = state.affectedFilesPendingEmit.slice(state.affectedFilesPendingEmitIndex).sort(ts.compareStringsCaseSensitive); _f < _g.length; _f++) { - var path = _g[_f]; + for (var _b = 0, _c = state.affectedFilesPendingEmit.slice(state.affectedFilesPendingEmitIndex).sort(ts.compareStringsCaseSensitive); _b < _c.length; _b++) { + var path = _c[_b]; if (ts.tryAddToSet(seenFiles, path)) { - affectedFilesPendingEmit.push([relativeToBuildInfo(path), state.affectedFilesPendingEmitKind.get(path)]); + (affectedFilesPendingEmit || (affectedFilesPendingEmit = [])).push([toFileId(path), state.affectedFilesPendingEmitKind.get(path)]); } } - result.affectedFilesPendingEmit = affectedFilesPendingEmit; } - return result; + return { + fileNames: fileNames, + fileInfos: fileInfos, + options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, relativeToBuildInfoEnsuringAbsolutePath), + fileIdsList: fileIdsList, + referencedMap: referencedMap, + exportedModulesMap: exportedModulesMap, + semanticDiagnosticsPerFile: semanticDiagnosticsPerFile, + affectedFilesPendingEmit: affectedFilesPendingEmit, + }; function relativeToBuildInfoEnsuringAbsolutePath(path) { return relativeToBuildInfo(ts.getNormalizedAbsolutePath(path, currentDirectory)); } function relativeToBuildInfo(path) { return ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(buildInfoDirectory, path, getCanonicalFileName)); } + function toFileId(path) { + var fileId = fileNameToFileId.get(path); + if (fileId === undefined) { + fileNames.push(relativeToBuildInfo(path)); + fileNameToFileId.set(path, fileId = fileNames.length); + } + return fileId; + } + function toFileIdListId(set) { + var fileIds = ts.arrayFrom(set.keys(), toFileId).sort(ts.compareValues); + var key = fileIds.join(); + var fileIdListId = fileNamesToFileIdListId === null || fileNamesToFileIdListId === void 0 ? void 0 : fileNamesToFileIdListId.get(key); + if (fileIdListId === undefined) { + (fileIdsList || (fileIdsList = [])).push(fileIds); + (fileNamesToFileIdListId || (fileNamesToFileIdListId = new ts.Map())).set(key, fileIdListId = fileIdsList.length); + } + return fileIdListId; + } } - function convertToReusableCompilerOptions(options, relativeToBuildInfo) { - var result = {}; + function convertToProgramBuildInfoCompilerOptions(options, relativeToBuildInfo) { + var result; var optionsNameMap = ts.getOptionsNameMap().optionsNameMap; - for (var name in options) { - if (ts.hasProperty(options, name)) { - result[name] = convertToReusableCompilerOptionValue(optionsNameMap.get(name.toLowerCase()), options[name], relativeToBuildInfo); + for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) { + var name = _a[_i]; + var optionInfo = optionsNameMap.get(name.toLowerCase()); + if ((optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsEmit) || (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsSemanticDiagnostics) || name === "skipLibCheck" || name === "skipDefaultLibCheck") { + (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfo); } } - if (result.configFilePath) { - result.configFilePath = relativeToBuildInfo(result.configFilePath); - } return result; } function convertToReusableCompilerOptionValue(option, value, relativeToBuildInfo) { @@ -110137,15 +113882,16 @@ var ts; * Computing hash to for signature verification */ var computeHash = ts.maybeBind(host, host.createHash); - var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState); + var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState, host.disableUseFileVersionAsSignature); var backupState; 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; oldState = undefined; - var builderProgram = createRedirectedBuilderProgram(state, configFileParsingDiagnostics); - builderProgram.getState = function () { return state; }; + var getState = function () { return state; }; + var builderProgram = createRedirectedBuilderProgram(getState, configFileParsingDiagnostics); + builderProgram.getState = getState; builderProgram.backupState = function () { ts.Debug.assert(backupState === undefined); backupState = cloneBuilderProgramState(state); @@ -110361,37 +114107,31 @@ var ts; state.affectedFilesPendingEmitIndex = 0; } } - function getMapOfReferencedSet(mapLike, toPath) { - if (!mapLike) - return undefined; - var map = new ts.Map(); - // Copies keys/values from template. Note that for..in will not throw if - // template is undefined, and instead will just exit the loop. - for (var key in mapLike) { - if (ts.hasProperty(mapLike, key)) { - map.set(toPath(key), new ts.Set(mapLike[key].map(toPath))); - } - } - return map; + function toBuilderStateFileInfo(fileInfo) { + return ts.isString(fileInfo) ? + { version: fileInfo, signature: fileInfo, affectsGlobalScope: undefined } : + ts.isString(fileInfo.signature) ? + fileInfo : + { version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope }; } + ts.toBuilderStateFileInfo = toBuilderStateFileInfo; function createBuildProgramUsingProgramBuildInfo(program, buildInfoPath, host) { + var _a; var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory())); var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames()); + var filePaths = program.fileNames.map(toPath); + var filePathsSetList = (_a = program.fileIdsList) === null || _a === void 0 ? void 0 : _a.map(function (fileIds) { return new ts.Set(fileIds.map(toFilePath)); }); var fileInfos = new ts.Map(); - for (var key in program.fileInfos) { - if (ts.hasProperty(program.fileInfos, key)) { - fileInfos.set(toPath(key), program.fileInfos[key]); - } - } + program.fileInfos.forEach(function (fileInfo, index) { return fileInfos.set(toFilePath(index + 1), toBuilderStateFileInfo(fileInfo)); }); var state = { fileInfos: fileInfos, - compilerOptions: ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath), - referencedMap: getMapOfReferencedSet(program.referencedMap, toPath), - exportedModulesMap: getMapOfReferencedSet(program.exportedModulesMap, toPath), - semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, function (value) { return toPath(ts.isString(value) ? value : value[0]); }, function (value) { return ts.isString(value) ? ts.emptyArray : value[1]; }), + compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {}, + referencedMap: toMapOfReferencedSet(program.referencedMap), + exportedModulesMap: toMapOfReferencedSet(program.exportedModulesMap), + semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, function (value) { return toFilePath(ts.isNumber(value) ? value : value[0]); }, function (value) { return ts.isNumber(value) ? ts.emptyArray : value[1]; }), hasReusableDiagnostic: true, - affectedFilesPendingEmit: ts.map(program.affectedFilesPendingEmit, function (value) { return toPath(value[0]); }), - affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toPath(value[0]); }, function (value) { return value[1]; }), + affectedFilesPendingEmit: ts.map(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }), + affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }, function (value) { return value[1]; }), affectedFilesPendingEmitIndex: program.affectedFilesPendingEmit && 0, }; return { @@ -110424,17 +114164,26 @@ var ts; function toAbsolutePath(path) { return ts.getNormalizedAbsolutePath(path, buildInfoDirectory); } + function toFilePath(fileId) { + return filePaths[fileId - 1]; + } + function toFilePathsSet(fileIdsListId) { + return filePathsSetList[fileIdsListId - 1]; + } + function toMapOfReferencedSet(referenceMap) { + return referenceMap && ts.arrayToMap(referenceMap, function (value) { return toFilePath(value[0]); }, function (value) { return toFilePathsSet(value[1]); }); + } } ts.createBuildProgramUsingProgramBuildInfo = createBuildProgramUsingProgramBuildInfo; - function createRedirectedBuilderProgram(state, configFileParsingDiagnostics) { + function createRedirectedBuilderProgram(getState, configFileParsingDiagnostics) { return { getState: ts.notImplemented, backupState: ts.noop, restoreState: ts.noop, getProgram: getProgram, - getProgramOrUndefined: function () { return state.program; }, - releaseProgram: function () { return state.program = undefined; }, - getCompilerOptions: function () { return state.compilerOptions; }, + getProgramOrUndefined: function () { return getState().program; }, + releaseProgram: function () { return getState().program = undefined; }, + getCompilerOptions: function () { return getState().compilerOptions; }, getSourceFile: function (fileName) { return getProgram().getSourceFile(fileName); }, getSourceFiles: function () { return getProgram().getSourceFiles(); }, getOptionsDiagnostics: function (cancellationToken) { return getProgram().getOptionsDiagnostics(cancellationToken); }, @@ -110450,7 +114199,7 @@ var ts; close: ts.noop, }; function getProgram() { - return ts.Debug.checkDefined(state.program); + return ts.Debug.checkDefined(getState().program); } } ts.createRedirectedBuilderProgram = createRedirectedBuilderProgram; @@ -110467,7 +114216,7 @@ var ts; ts.createEmitAndSemanticDiagnosticsBuilderProgram = createEmitAndSemanticDiagnosticsBuilderProgram; function createAbstractBuilder(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences) { var _a = ts.getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences), newProgram = _a.newProgram, newConfigFileParsingDiagnostics = _a.configFileParsingDiagnostics; - return ts.createRedirectedBuilderProgram({ program: newProgram, compilerOptions: newProgram.getCompilerOptions() }, newConfigFileParsingDiagnostics); + return ts.createRedirectedBuilderProgram(function () { return ({ program: newProgram, compilerOptions: newProgram.getCompilerOptions() }); }, newConfigFileParsingDiagnostics); } ts.createAbstractBuilder = createAbstractBuilder; })(ts || (ts = {})); @@ -110536,9 +114285,9 @@ var ts; var resolutionsWithFailedLookups = []; var resolvedFileToResolution = ts.createMultiMap(); var hasChangedAutomaticTypeDirectiveNames = false; - var failedLookupChecks = []; - var startsWithPathChecks = []; - var isInDirectoryChecks = []; + var failedLookupChecks; + var startsWithPathChecks; + var isInDirectoryChecks; var getCurrentDirectory = ts.memoize(function () { return resolutionHost.getCurrentDirectory(); }); // TODO: GH#18217 var cachedDirectoryStructureHost = resolutionHost.getCachedDirectoryStructureHost(); // The resolvedModuleNames and resolvedTypeReferenceDirectives are the cache of resolutions per file. @@ -110547,9 +114296,12 @@ var ts; var resolvedModuleNames = new ts.Map(); var perDirectoryResolvedModuleNames = ts.createCacheWithRedirects(); var nonRelativeModuleNameCache = ts.createCacheWithRedirects(); - var moduleResolutionCache = ts.createModuleResolutionCacheWithMaps(perDirectoryResolvedModuleNames, nonRelativeModuleNameCache, getCurrentDirectory(), resolutionHost.getCanonicalFileName); + var moduleResolutionCache = ts.createModuleResolutionCache(getCurrentDirectory(), resolutionHost.getCanonicalFileName, + /*options*/ undefined, perDirectoryResolvedModuleNames, nonRelativeModuleNameCache); var resolvedTypeReferenceDirectives = new ts.Map(); var perDirectoryResolvedTypeReferenceDirectives = ts.createCacheWithRedirects(); + var typeReferenceDirectiveResolutionCache = ts.createTypeReferenceDirectiveResolutionCache(getCurrentDirectory(), resolutionHost.getCanonicalFileName, + /*options*/ undefined, moduleResolutionCache.getPackageJsonInfoCache(), perDirectoryResolvedTypeReferenceDirectives); /** * These are the extensions that failed lookup files will have by default, * any other extension of failed lookup will be store that path in custom failed lookup path @@ -110581,6 +114333,7 @@ var ts; invalidateResolutionsOfFailedLookupLocations: invalidateResolutionsOfFailedLookupLocations, setFilesWithInvalidatedNonRelativeUnresolvedImports: setFilesWithInvalidatedNonRelativeUnresolvedImports, createHasInvalidatedResolution: createHasInvalidatedResolution, + isFileWithInvalidatedNonRelativeUnresolvedImports: isFileWithInvalidatedNonRelativeUnresolvedImports, updateTypeRootsWatch: updateTypeRootsWatch, closeTypeRootsWatch: closeTypeRootsWatch, clear: clear @@ -110606,9 +114359,9 @@ var ts; resolvedTypeReferenceDirectives.clear(); resolvedFileToResolution.clear(); resolutionsWithFailedLookups.length = 0; - failedLookupChecks.length = 0; - startsWithPathChecks.length = 0; - isInDirectoryChecks.length = 0; + failedLookupChecks = undefined; + startsWithPathChecks = undefined; + isInDirectoryChecks = undefined; // perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update // (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution) clearPerDirectoryResolutions(); @@ -110644,9 +114397,8 @@ var ts; isFileWithInvalidatedNonRelativeUnresolvedImports(path); }; } function clearPerDirectoryResolutions() { - perDirectoryResolvedModuleNames.clear(); - nonRelativeModuleNameCache.clear(); - perDirectoryResolvedTypeReferenceDirectives.clear(); + moduleResolutionCache.clear(); + typeReferenceDirectiveResolutionCache.clear(); nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions); nonRelativeExternalModuleResolutions.clear(); } @@ -110673,7 +114425,7 @@ var ts; if (globalCache !== undefined && !ts.isExternalModuleNameRelative(moduleName) && !(primaryResult.resolvedModule && ts.extensionIsTS(primaryResult.resolvedModule.extension))) { // create different collection of failed lookup locations for second pass // if it will fail and we've already found something during the first pass - we don't want to pollute its results - var _b = ts.loadModuleFromGlobalCache(ts.Debug.checkDefined(resolutionHost.globalCacheResolutionModuleName)(moduleName), resolutionHost.projectName, compilerOptions, host, globalCache), resolvedModule = _b.resolvedModule, failedLookupLocations = _b.failedLookupLocations; + var _b = ts.loadModuleFromGlobalCache(ts.Debug.checkDefined(resolutionHost.globalCacheResolutionModuleName)(moduleName), resolutionHost.projectName, compilerOptions, host, globalCache, moduleResolutionCache), resolvedModule = _b.resolvedModule, failedLookupLocations = _b.failedLookupLocations; if (resolvedModule) { // Modify existing resolution so its saved in the directory cache as well primaryResult.resolvedModule = resolvedModule; @@ -110684,8 +114436,11 @@ var ts; // Default return the result from the first pass return primaryResult; } + function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference) { + return ts.resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache); + } function resolveNamesWithLocalCache(_a) { - var _b; + var _b, _c, _d; var names = _a.names, containingFile = _a.containingFile, redirectedReference = _a.redirectedReference, cache = _a.cache, perDirectoryCacheWithRedirects = _a.perDirectoryCacheWithRedirects, loader = _a.loader, getResolutionWithResolvedFileName = _a.getResolutionWithResolvedFileName, shouldRetryResolution = _a.shouldRetryResolution, reusedNames = _a.reusedNames, logChanges = _a.logChanges; var path = resolutionHost.toPath(containingFile); var resolutionsInFile = cache.get(path) || cache.set(path, new ts.Map()).get(path); @@ -110718,9 +114473,24 @@ var ts; var resolutionInDirectory = perDirectoryResolution.get(name); if (resolutionInDirectory) { resolution = resolutionInDirectory; + var host = ((_b = resolutionHost.getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(resolutionHost)) || resolutionHost; + if (ts.isTraceEnabled(compilerOptions, host)) { + var resolved = getResolutionWithResolvedFileName(resolution); + ts.trace(host, loader === resolveModuleName ? + (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ? + resolved.packagetId ? + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4 : + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3 : + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_not_resolved : + (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ? + resolved.packagetId ? + ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4 : + ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3 : + ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_not_resolved, name, containingFile, ts.getDirectoryPath(containingFile), resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName, (resolved === null || resolved === void 0 ? void 0 : resolved.packagetId) && ts.packageIdToString(resolved.packagetId)); + } } else { - resolution = loader(name, containingFile, compilerOptions, ((_b = resolutionHost.getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(resolutionHost)) || resolutionHost, redirectedReference); + resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference); perDirectoryResolution.set(name, resolution); } resolutionsInFile.set(name, resolution); @@ -110734,6 +114504,23 @@ var ts; logChanges = false; } } + else { + var host = ((_d = resolutionHost.getCompilerHost) === null || _d === void 0 ? void 0 : _d.call(resolutionHost)) || resolutionHost; + if (ts.isTraceEnabled(compilerOptions, host) && !seenNamesInFile.has(name)) { + var resolved = getResolutionWithResolvedFileName(resolution); + ts.trace(host, loader === resolveModuleName ? + (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ? + resolved.packagetId ? + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 : + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2 : + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_not_resolved : + (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ? + resolved.packagetId ? + ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 : + ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2 : + ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_not_resolved, name, containingFile, resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName, (resolved === null || resolved === void 0 ? void 0 : resolved.packagetId) && ts.packageIdToString(resolved.packagetId)); + } + } ts.Debug.assert(resolution !== undefined && !resolution.isInvalidated); seenNamesInFile.set(name, true); resolvedModules.push(getResolutionWithResolvedFileName(resolution)); @@ -110771,7 +114558,7 @@ var ts; redirectedReference: redirectedReference, cache: resolvedTypeReferenceDirectives, perDirectoryCacheWithRedirects: perDirectoryResolvedTypeReferenceDirectives, - loader: ts.resolveTypeReferenceDirective, + loader: resolveTypeReferenceDirective, getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective, shouldRetryResolution: function (resolution) { return resolution.resolvedTypeReferenceDirective === undefined; }, }); @@ -111046,7 +114833,7 @@ var ts; if (isCreatingWatchedDirectory) { // Watching directory is created // Invalidate any resolution has failed lookup in this directory - isInDirectoryChecks.push(fileOrDirectoryPath); + (isInDirectoryChecks || (isInDirectoryChecks = [])).push(fileOrDirectoryPath); } else { // If something to do with folder/file starting with "." in node_modules folder, skip it @@ -111064,8 +114851,8 @@ var ts; if (isNodeModulesAtTypesDirectory(fileOrDirectoryPath) || ts.isNodeModulesDirectory(fileOrDirectoryPath) || isNodeModulesAtTypesDirectory(dirOfFileOrDirectory) || ts.isNodeModulesDirectory(dirOfFileOrDirectory)) { // Invalidate any resolution from this directory - failedLookupChecks.push(fileOrDirectoryPath); - startsWithPathChecks.push(fileOrDirectoryPath); + (failedLookupChecks || (failedLookupChecks = [])).push(fileOrDirectoryPath); + (startsWithPathChecks || (startsWithPathChecks = new ts.Set())).add(fileOrDirectoryPath); } else { if (!isPathWithDefaultFailedLookupExtension(fileOrDirectoryPath) && !customFailedLookupPaths.has(fileOrDirectoryPath)) { @@ -111076,27 +114863,33 @@ var ts; return false; } // Resolution need to be invalidated if failed lookup location is same as the file or directory getting created - failedLookupChecks.push(fileOrDirectoryPath); + (failedLookupChecks || (failedLookupChecks = [])).push(fileOrDirectoryPath); + // If the invalidated file is from a node_modules package, invalidate everything else + // in the package since we might not get notifications for other files in the package. + // This hardens our logic against unreliable file watchers. + var packagePath = ts.parseNodeModuleFromPath(fileOrDirectoryPath); + if (packagePath) + (startsWithPathChecks || (startsWithPathChecks = new ts.Set())).add(packagePath); } } resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations(); } function invalidateResolutionsOfFailedLookupLocations() { - if (!failedLookupChecks.length && !startsWithPathChecks.length && !isInDirectoryChecks.length) { + if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks) { return false; } var invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution); - failedLookupChecks.length = 0; - startsWithPathChecks.length = 0; - isInDirectoryChecks.length = 0; + failedLookupChecks = undefined; + startsWithPathChecks = undefined; + isInDirectoryChecks = undefined; return invalidated; } function canInvalidateFailedLookupResolution(resolution) { return resolution.failedLookupLocations.some(function (location) { var locationPath = resolutionHost.toPath(location); return ts.contains(failedLookupChecks, locationPath) || - startsWithPathChecks.some(function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath); }) || - isInDirectoryChecks.some(function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath); }); + ts.firstDefinedIterator((startsWithPathChecks === null || startsWithPathChecks === void 0 ? void 0 : startsWithPathChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath) ? true : undefined; }) || + (isInDirectoryChecks === null || isInDirectoryChecks === void 0 ? void 0 : isInDirectoryChecks.some(function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath); })); }); } function closeTypeRootsWatch() { @@ -111247,6 +115040,9 @@ var ts; return [ambient]; var info = getInfo(importingSourceFile.path, host); var moduleSourceFile = ts.getSourceFileOfNode(moduleSymbol.valueDeclaration || ts.getNonAugmentationDeclaration(moduleSymbol)); + if (!moduleSourceFile) { + return []; + } var modulePaths = getAllModulePaths(importingSourceFile.path, moduleSourceFile.originalFileName, host); var preferences = getPreferences(userPreferences, compilerOptions, importingSourceFile); var existingSpecifier = ts.forEach(modulePaths, function (modulePath) { return ts.forEach(host.getFileIncludeReasons().get(ts.toPath(modulePath.path, host.getCurrentDirectory(), info.getCanonicalFileName)), function (reason) { @@ -111317,7 +115113,7 @@ var ts; if (!baseUrl && !paths || relativePreference === 0 /* Relative */) { return relativePath; } - var baseDirectory = ts.getPathsBasePath(compilerOptions, host) || baseUrl; + var baseDirectory = ts.getNormalizedAbsolutePath(ts.getPathsBasePath(compilerOptions, host) || baseUrl, host.getCurrentDirectory()); var relativeToBaseUrl = getRelativePathIfInDirectory(moduleFileName, baseDirectory, getCanonicalFileName); if (!relativeToBaseUrl) { return relativePath; @@ -111332,7 +115128,9 @@ var ts; return nonRelative; } if (relativePreference === 3 /* ExternalNonRelative */) { - var projectDirectory = host.getCurrentDirectory(); + var projectDirectory = compilerOptions.configFilePath ? + ts.toPath(ts.getDirectoryPath(compilerOptions.configFilePath), host.getCurrentDirectory(), info.getCanonicalFileName) : + info.getCanonicalFileName(host.getCurrentDirectory()); var modulePath = ts.toPath(moduleFileName, projectDirectory, getCanonicalFileName); var sourceIsInternal = ts.startsWith(sourceDirectory, projectDirectory); var targetIsInternal = ts.startsWith(modulePath, projectDirectory); @@ -111384,12 +115182,8 @@ var ts; return ts.pathIsRelative(text) ? ts.hasJSFileExtension(text) : undefined; }) || false; } - function numberOfDirectorySeparators(str) { - var match = str.match(/\//g); - return match ? match.length : 0; - } function comparePathsByRedirectAndNumberOfDirectorySeparators(a, b) { - return ts.compareBooleans(b.isRedirect, a.isRedirect) || ts.compareValues(numberOfDirectorySeparators(a.path), numberOfDirectorySeparators(b.path)); + return ts.compareBooleans(b.isRedirect, a.isRedirect) || ts.compareNumberOfDirectorySeparators(a.path, b.path); } function getNearestAncestorDirectoryWithPackageJson(host, fileName) { if (host.getNearestAncestorDirectoryWithPackageJson) { @@ -111403,40 +115197,49 @@ var ts; var getCanonicalFileName = ts.hostGetCanonicalFileName(host); var cwd = host.getCurrentDirectory(); var referenceRedirect = host.isSourceOfProjectReferenceRedirect(importedFileName) ? host.getProjectReferenceRedirect(importedFileName) : undefined; - var redirects = host.redirectTargetsMap.get(ts.toPath(importedFileName, cwd, getCanonicalFileName)) || ts.emptyArray; + var importedPath = ts.toPath(importedFileName, cwd, getCanonicalFileName); + var redirects = host.redirectTargetsMap.get(importedPath) || ts.emptyArray; var importedFileNames = __spreadArray(__spreadArray(__spreadArray([], (referenceRedirect ? [referenceRedirect] : ts.emptyArray)), [importedFileName]), redirects); var targets = importedFileNames.map(function (f) { return ts.getNormalizedAbsolutePath(f, cwd); }); + var shouldFilterIgnoredPaths = !ts.every(targets, ts.containsIgnoredPath); if (!preferSymlinks) { - var result_15 = ts.forEach(targets, function (p) { return cb(p, referenceRedirect === p); }); + // Symlinks inside ignored paths are already filtered out of the symlink cache, + // so we only need to remove them from the realpath filenames. + var result_15 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); }); if (result_15) return result_15; } var links = host.getSymlinkCache ? host.getSymlinkCache() : ts.discoverProbableSymlinks(host.getSourceFiles(), getCanonicalFileName, cwd); - var symlinkedDirectories = links.getSymlinkedDirectories(); - var useCaseSensitiveFileNames = !host.useCaseSensitiveFileNames || host.useCaseSensitiveFileNames(); - var result = symlinkedDirectories && ts.forEachEntry(symlinkedDirectories, function (resolved, path) { - if (resolved === false) - return undefined; - if (ts.startsWithDirectory(importingFileName, resolved.realPath, getCanonicalFileName)) { - return undefined; // Don't want to a package to globally import from itself + var symlinkedDirectories = links.getSymlinkedDirectoriesByRealpath(); + var fullImportedFileName = ts.getNormalizedAbsolutePath(importedFileName, cwd); + var result = symlinkedDirectories && ts.forEachAncestorDirectory(ts.getDirectoryPath(fullImportedFileName), function (realPathDirectory) { + var symlinkDirectories = symlinkedDirectories.get(ts.ensureTrailingDirectorySeparator(ts.toPath(realPathDirectory, cwd, getCanonicalFileName))); + if (!symlinkDirectories) + return undefined; // Continue to ancestor directory + // Don't want to a package to globally import from itself (importNameCodeFix_symlink_own_package.ts) + if (ts.startsWithDirectory(importingFileName, realPathDirectory, getCanonicalFileName)) { + return false; // Stop search, each ancestor directory will also hit this condition } return ts.forEach(targets, function (target) { - if (!ts.containsPath(resolved.real, target, !useCaseSensitiveFileNames)) { + if (!ts.startsWithDirectory(target, realPathDirectory, getCanonicalFileName)) { return; } - var relative = ts.getRelativePathFromDirectory(resolved.real, target, getCanonicalFileName); - var option = ts.resolvePath(path, relative); - if (!host.fileExists || host.fileExists(option)) { + var relative = ts.getRelativePathFromDirectory(realPathDirectory, target, getCanonicalFileName); + for (var _i = 0, symlinkDirectories_1 = symlinkDirectories; _i < symlinkDirectories_1.length; _i++) { + var symlinkDirectory = symlinkDirectories_1[_i]; + var option = ts.resolvePath(symlinkDirectory, relative); var result_16 = cb(option, target === referenceRedirect); + shouldFilterIgnoredPaths = true; // We found a non-ignored path in symlinks, so we can reject ignored-path realpaths if (result_16) return result_16; } }); }); - return result || - (preferSymlinks ? ts.forEach(targets, function (p) { return cb(p, p === referenceRedirect); }) : undefined); + return result || (preferSymlinks + ? ts.forEach(targets, function (p) { return shouldFilterIgnoredPaths && ts.containsIgnoredPath(p) ? undefined : cb(p, p === referenceRedirect); }) + : undefined); } moduleSpecifiers.forEachFileNameOfModule = forEachFileNameOfModule; /** @@ -111444,8 +115247,14 @@ var ts; * Symlinks will be returned first so they are preferred over the real path. */ function getAllModulePaths(importingFileName, importedFileName, host) { - var cwd = host.getCurrentDirectory(); + var _a; + var cache = (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host); var getCanonicalFileName = ts.hostGetCanonicalFileName(host); + if (cache) { + var cached = cache.get(importingFileName, ts.toPath(importedFileName, host.getCurrentDirectory(), getCanonicalFileName)); + if (typeof cached === "object") + return cached; + } var allFileNames = new ts.Map(); var importedFileFromNodeModules = false; forEachFileNameOfModule(importingFileName, importedFileName, host, @@ -111457,7 +115266,7 @@ var ts; }); // Sort by paths closest to importing file Name directory var sortedPaths = []; - var _loop_24 = function (directory) { + var _loop_26 = function (directory) { var directoryStart = ts.ensureTrailingDirectorySeparator(directory); var pathsInDirectory; allFileNames.forEach(function (_a, fileName) { @@ -111480,10 +115289,10 @@ var ts; out_directory_1 = directory; }; var out_directory_1; - for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0;) { - var state_7 = _loop_24(directory); + for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) { + var state_9 = _loop_26(directory); directory = out_directory_1; - if (state_7 === "break") + if (state_9 === "break") break; } if (allFileNames.size) { @@ -111492,10 +115301,14 @@ var ts; remainingPaths.sort(comparePathsByRedirectAndNumberOfDirectorySeparators); sortedPaths.push.apply(sortedPaths, remainingPaths); } + if (cache) { + cache.set(importingFileName, ts.toPath(importedFileName, host.getCurrentDirectory(), getCanonicalFileName), sortedPaths); + } return sortedPaths; } function tryGetModuleNameFromAmbientModule(moduleSymbol, checker) { - var decl = ts.find(moduleSymbol.declarations, function (d) { return ts.isNonGlobalAmbientModule(d) && (!ts.isExternalModuleAugmentation(d) || !ts.isExternalModuleNameRelative(ts.getTextOfIdentifierOrLiteral(d.name))); }); + var _a; + var decl = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.isNonGlobalAmbientModule(d) && (!ts.isExternalModuleAugmentation(d) || !ts.isExternalModuleNameRelative(ts.getTextOfIdentifierOrLiteral(d.name))); }); if (decl) { return decl.name.text; } @@ -111551,7 +115364,7 @@ var ts; ts.startsWith(relativeToBaseUrl, prefix) && ts.endsWith(relativeToBaseUrl, suffix) || !suffix && relativeToBaseUrl === ts.removeTrailingDirectorySeparator(prefix)) { - var matchedStar = relativeToBaseUrl.substr(prefix.length, relativeToBaseUrl.length - suffix.length); + var matchedStar = relativeToBaseUrl.substr(prefix.length, relativeToBaseUrl.length - suffix.length - prefix.length); return key.replace("*", matchedStar); } } @@ -111855,10 +115668,10 @@ var ts; } ts.createWatchStatusReporter = createWatchStatusReporter; /** Parses config file using System interface */ - function parseConfigFileWithSystem(configFileName, optionsToExtend, watchOptionsToExtend, system, reportDiagnostic) { + function parseConfigFileWithSystem(configFileName, optionsToExtend, extendedConfigCache, watchOptionsToExtend, system, reportDiagnostic) { var host = system; host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(system, reportDiagnostic, diagnostic); }; - var result = ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtend, host, /*extendedConfigCache*/ undefined, watchOptionsToExtend); + var result = ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtend, host, extendedConfigCache, watchOptionsToExtend); host.onUnRecoverableConfigFileDiagnostic = undefined; // TODO: GH#18217 return result; } @@ -112126,7 +115939,10 @@ var ts; MissingFile: "Missing file", WildcardDirectory: "Wild card directory", FailedLookupLocations: "Failed Lookup Locations", - TypeRoots: "Type roots" + TypeRoots: "Type roots", + ConfigFileOfReferencedProject: "Config file of referened project", + ExtendedConfigOfReferencedProject: "Extended config file of referenced project", + WildcardDirectoryOfReferencedProject: "Wild card directory of referenced project", }; function createWatchFactory(host, options) { var watchLogLevel = host.trace ? options.extendedDiagnostics ? ts.WatchLogLevel.Verbose : options.diagnostics ? ts.WatchLogLevel.TriggerOnly : ts.WatchLogLevel.None : ts.WatchLogLevel.None; @@ -112173,6 +115989,7 @@ var ts; getEnvironmentVariable: ts.maybeBind(host, host.getEnvironmentVariable) || (function () { return ""; }), createHash: ts.maybeBind(host, host.createHash), readDirectory: ts.maybeBind(host, host.readDirectory), + disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature, }; function writeFile(fileName, text, writeByteOrderMark, onError) { try { @@ -112230,7 +116047,8 @@ var ts; createDirectory: function (path) { return system.createDirectory(path); }, writeFile: function (path, data, writeByteOrderMark) { return system.writeFile(path, data, writeByteOrderMark); }, createHash: ts.maybeBind(system, system.createHash), - createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram + createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram, + disableUseFileVersionAsSignature: system.disableUseFileVersionAsSignature, }; } ts.createProgramHost = createProgramHost; @@ -112318,6 +116136,7 @@ var ts; if (system === void 0) { system = ts.sys; } var host = ts.createCompilerHostWorker(options, /*setParentNodes*/ undefined, system); host.createHash = ts.maybeBind(system, system.createHash); + host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature; ts.setGetSourceFileAsHashVersioned(host, system); ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); }); return host; @@ -112361,11 +116180,13 @@ var ts; function createWatchProgram(host) { var builderProgram; var reloadLevel; // level to indicate if the program needs to be reloaded from config file/just filenames etc - var extendedConfigFilesMap; // Map of file watchers for the extended config files var missingFilesMap; // Map of file watchers for the missing files var watchedWildcardDirectories; // map of watchers for the wild card directories in the config file var timerToUpdateProgram; // timer callback to recompile the program var timerToInvalidateFailedLookupResolutions; // timer callback to invalidate resolutions for changes in failed lookup locations + 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 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 var hasChangedCompilerOptions = false; // True if the compiler options have changed between compilations @@ -112415,6 +116236,7 @@ var ts; compilerHost.getNewLine = function () { return newLine; }; compilerHost.fileExists = fileExists; compilerHost.onReleaseOldSourceFile = onReleaseOldSourceFile; + compilerHost.onReleaseParsedCommandLine = onReleaseParsedCommandLine; // Members for ResolutionCacheHost compilerHost.toPath = toPath; compilerHost.getCompilationSettings = function () { return compilerOptions; }; @@ -112428,6 +116250,7 @@ var ts; compilerHost.fileIsOpen = ts.returnFalse; compilerHost.getCurrentProgram = getCurrentProgram; compilerHost.writeLog = writeLog; + compilerHost.getParsedCommandLine = getParsedCommandLine; // Cache for the module resolution var resolutionCache = ts.createResolutionCache(compilerHost, configFileName ? ts.getDirectoryPath(ts.getNormalizedAbsolutePath(configFileName, currentDirectory)) : @@ -112458,7 +116281,8 @@ var ts; // Update the wild card directory watch watchConfigFileWildCardDirectories(); // Update extended config file watch - watchExtendedConfigFiles(); + if (configFileName) + updateExtendedConfigFilesWatches(toPath(configFileName), compilerOptions, watchOptions, ts.WatchType.ExtendedConfigFile); return configFileName ? { getCurrentProgram: getCurrentBuilderProgram, getProgram: updateProgram, close: close } : { getCurrentProgram: getCurrentBuilderProgram, getProgram: updateProgram, updateRootFileNames: updateRootFileNames, close: close }; @@ -112475,9 +116299,11 @@ var ts; configFileWatcher.close(); configFileWatcher = undefined; } - if (extendedConfigFilesMap) { - ts.clearMap(extendedConfigFilesMap, ts.closeFileWatcher); - extendedConfigFilesMap = undefined; + extendedConfigCache === null || extendedConfigCache === void 0 ? void 0 : extendedConfigCache.clear(); + extendedConfigCache = undefined; + if (sharedExtendedConfigFileWatchers) { + ts.clearMap(sharedExtendedConfigFileWatchers, ts.closeFileWatcherOf); + sharedExtendedConfigFileWatchers = undefined; } if (watchedWildcardDirectories) { ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcherOf); @@ -112487,6 +116313,17 @@ var ts; ts.clearMap(missingFilesMap, ts.closeFileWatcher); missingFilesMap = undefined; } + if (parsedConfigs) { + ts.clearMap(parsedConfigs, function (config) { + var _a; + (_a = config.watcher) === null || _a === void 0 ? void 0 : _a.close(); + config.watcher = undefined; + if (config.watchedDirectories) + ts.clearMap(config.watchedDirectories, ts.closeFileWatcherOf); + config.watchedDirectories = undefined; + }); + parsedConfigs = undefined; + } } function getCurrentBuilderProgram() { return builderProgram; @@ -112506,7 +116343,7 @@ var ts; } // All resolutions are invalid if user provided resolutions var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution); - if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, projectReferences)) { + if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) { if (hasChangedConfigFileParsingErrors) { builderProgram = createProgram(/*rootNames*/ undefined, /*options*/ undefined, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences); hasChangedConfigFileParsingErrors = false; @@ -112525,6 +116362,8 @@ var ts; writeLog("CreatingProgramWith::"); writeLog(" roots: " + JSON.stringify(rootFileNames)); writeLog(" options: " + JSON.stringify(compilerOptions)); + if (projectReferences) + writeLog(" projectReferences: " + JSON.stringify(projectReferences)); var needsUpdateInTypeRootWatch = hasChangedCompilerOptions || !getCurrentProgram(); hasChangedCompilerOptions = false; hasChangedConfigFileParsingErrors = false; @@ -112747,10 +116586,10 @@ var ts; // Update the wild card directory watch watchConfigFileWildCardDirectories(); // Update extended config file watch - watchExtendedConfigFiles(); + updateExtendedConfigFilesWatches(toPath(configFileName), compilerOptions, watchOptions, ts.WatchType.ExtendedConfigFile); } function parseConfigFile() { - setConfigFileParsingResult(ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtendForConfigFile, parseConfigFileHost, /*extendedConfigCache*/ undefined, watchOptionsToExtend, extraFileExtensions)); // TODO: GH#18217 + setConfigFileParsingResult(ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtendForConfigFile, parseConfigFileHost, extendedConfigCache || (extendedConfigCache = new ts.Map()), watchOptionsToExtend, extraFileExtensions)); // TODO: GH#18217 } function setConfigFileParsingResult(configFileParseResult) { rootFileNames = configFileParseResult.fileNames; @@ -112762,6 +116601,56 @@ var ts; canConfigFileJsonReportNoInputFiles = ts.canJsonReportNoInputFiles(configFileParseResult.raw); hasChangedConfigFileParsingErrors = true; } + function getParsedCommandLine(configFileName) { + var configPath = toPath(configFileName); + var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(configPath); + if (config) { + if (!config.reloadLevel) + return config.parsedCommandLine; + // With host implementing getParsedCommandLine we cant just update file names + if (config.parsedCommandLine && config.reloadLevel === ts.ConfigFileProgramReloadLevel.Partial && !host.getParsedCommandLine) { + writeLog("Reloading new file names and options"); + var fileNames = ts.getFileNamesFromConfigSpecs(config.parsedCommandLine.options.configFile.configFileSpecs, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), compilerOptions, parseConfigFileHost); + config.parsedCommandLine = __assign(__assign({}, config.parsedCommandLine), { fileNames: fileNames }); + config.reloadLevel = undefined; + return config.parsedCommandLine; + } + } + writeLog("Loading config file: " + configFileName); + var parsedCommandLine = host.getParsedCommandLine ? + host.getParsedCommandLine(configFileName) : + getParsedCommandLineFromConfigFileHost(configFileName); + if (config) { + config.parsedCommandLine = parsedCommandLine; + config.reloadLevel = undefined; + } + else { + (parsedConfigs || (parsedConfigs = new ts.Map())).set(configPath, config = { parsedCommandLine: parsedCommandLine }); + } + watchReferencedProject(configFileName, configPath, config); + return parsedCommandLine; + } + function getParsedCommandLineFromConfigFileHost(configFileName) { + // Ignore the file absent errors + var onUnRecoverableConfigFileDiagnostic = parseConfigFileHost.onUnRecoverableConfigFileDiagnostic; + parseConfigFileHost.onUnRecoverableConfigFileDiagnostic = ts.noop; + var parsedCommandLine = ts.getParsedCommandLineOfConfigFile(configFileName, + /*optionsToExtend*/ undefined, parseConfigFileHost, extendedConfigCache || (extendedConfigCache = new ts.Map()), watchOptionsToExtend); + parseConfigFileHost.onUnRecoverableConfigFileDiagnostic = onUnRecoverableConfigFileDiagnostic; + return parsedCommandLine; + } + function onReleaseParsedCommandLine(fileName) { + var _a; + var path = toPath(fileName); + var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(path); + if (!config) + return; + parsedConfigs.delete(path); + if (config.watchedDirectories) + ts.clearMap(config.watchedDirectories, ts.closeFileWatcherOf); + (_a = config.watcher) === null || _a === void 0 ? void 0 : _a.close(); + ts.clearSharedExtendedConfigFileWatcher(path, sharedExtendedConfigFileWatchers); + } function watchFilePath(path, file, callback, pollingInterval, options, watchType) { return watchFile(file, function (fileName, eventKind) { return callback(fileName, eventKind, path); }, pollingInterval, options, watchType); } @@ -112771,7 +116660,6 @@ var ts; if (eventKind === ts.FileWatcherEventKind.Deleted && sourceFilesCache.has(path)) { resolutionCache.invalidateResolutionOfFile(path); } - resolutionCache.removeResolutionsFromProjectReferenceRedirects(path); nextSourceFileVersion(path); // Update the program scheduleProgramUpdate(); @@ -112782,7 +116670,10 @@ var ts; } } function watchMissingFilePath(missingFilePath) { - return watchFilePath(missingFilePath, missingFilePath, onMissingFileChange, ts.PollingInterval.Medium, watchOptions, ts.WatchType.MissingFile); + // If watching missing referenced config file, we are already watching it so no need for separate watcher + return (parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.has(missingFilePath)) ? + ts.noopFileWatcher : + watchFilePath(missingFilePath, missingFilePath, onMissingFileChange, ts.PollingInterval.Medium, watchOptions, ts.WatchType.MissingFile); } function onMissingFileChange(fileName, eventKind, missingFilePath) { updateCachedSystemWithFile(fileName, missingFilePath, eventKind); @@ -112819,10 +116710,11 @@ var ts; configFileName: configFileName, extraFileExtensions: extraFileExtensions, options: compilerOptions, - program: getCurrentBuilderProgram(), + program: getCurrentBuilderProgram() || rootFileNames, currentDirectory: currentDirectory, useCaseSensitiveFileNames: useCaseSensitiveFileNames, - writeLog: writeLog + writeLog: writeLog, + toPath: toPath, })) return; // Reload is pending, do the reload @@ -112833,18 +116725,87 @@ var ts; } }, flags, watchOptions, ts.WatchType.WildcardDirectory); } - function watchExtendedConfigFiles() { - var _a; - // Update the extended config files watcher - ts.mutateMap(extendedConfigFilesMap || (extendedConfigFilesMap = new ts.Map()), ts.arrayToMap(((_a = compilerOptions.configFile) === null || _a === void 0 ? void 0 : _a.extendedSourceFiles) || ts.emptyArray, toPath), { - // Watch the extended config files - createNewValue: watchExtendedConfigFile, - // Config files that are no longer extended should no longer be watched. - onDeleteValue: ts.closeFileWatcher - }); + function updateExtendedConfigFilesWatches(forProjectPath, options, watchOptions, watchType) { + ts.updateSharedExtendedConfigFileWatcher(forProjectPath, options, sharedExtendedConfigFileWatchers || (sharedExtendedConfigFileWatchers = new ts.Map()), function (extendedConfigFileName, extendedConfigFilePath) { return watchFile(extendedConfigFileName, function (_fileName, eventKind) { + var _a; + updateCachedSystemWithFile(extendedConfigFileName, extendedConfigFilePath, eventKind); + // Update extended config cache + if (extendedConfigCache) + ts.cleanExtendedConfigCache(extendedConfigCache, extendedConfigFilePath, toPath); + // Update projects + var projects = (_a = sharedExtendedConfigFileWatchers.get(extendedConfigFilePath)) === null || _a === void 0 ? void 0 : _a.projects; + // If there are no referenced projects this extended config file watcher depend on ignore + if (!(projects === null || projects === void 0 ? void 0 : projects.size)) + return; + projects.forEach(function (projectPath) { + if (toPath(configFileName) === projectPath) { + // If this is the config file of the project, reload completely + reloadLevel = ts.ConfigFileProgramReloadLevel.Full; + } + else { + // Reload config for the referenced projects and remove the resolutions from referenced projects since the config file changed + var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(projectPath); + if (config) + config.reloadLevel = ts.ConfigFileProgramReloadLevel.Full; + resolutionCache.removeResolutionsFromProjectReferenceRedirects(projectPath); + } + scheduleProgramUpdate(); + }); + }, ts.PollingInterval.High, watchOptions, watchType); }, toPath); } - function watchExtendedConfigFile(extendedConfigFile) { - return watchFile(extendedConfigFile, scheduleProgramReload, ts.PollingInterval.High, watchOptions, ts.WatchType.ExtendedConfigFile); + function watchReferencedProject(configFileName, configPath, commandLine) { + var _a, _b, _c, _d, _e; + // Watch file + commandLine.watcher || (commandLine.watcher = watchFile(configFileName, function (_fileName, eventKind) { + updateCachedSystemWithFile(configFileName, configPath, eventKind); + var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(configPath); + if (config) + config.reloadLevel = ts.ConfigFileProgramReloadLevel.Full; + resolutionCache.removeResolutionsFromProjectReferenceRedirects(configPath); + scheduleProgramUpdate(); + }, ts.PollingInterval.High, ((_a = commandLine.parsedCommandLine) === null || _a === void 0 ? void 0 : _a.watchOptions) || watchOptions, ts.WatchType.ConfigFileOfReferencedProject)); + // Watch Wild card + if ((_b = commandLine.parsedCommandLine) === null || _b === void 0 ? void 0 : _b.wildcardDirectories) { + ts.updateWatchingWildcardDirectories(commandLine.watchedDirectories || (commandLine.watchedDirectories = new ts.Map()), new ts.Map(ts.getEntries((_c = commandLine.parsedCommandLine) === null || _c === void 0 ? void 0 : _c.wildcardDirectories)), function (directory, flags) { + var _a; + return watchDirectory(directory, function (fileOrDirectory) { + var fileOrDirectoryPath = toPath(fileOrDirectory); + // Since the file existence changed, update the sourceFiles cache + if (cachedDirectoryStructureHost) { + cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); + } + nextSourceFileVersion(fileOrDirectoryPath); + var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(configPath); + if (!(config === null || config === void 0 ? void 0 : config.parsedCommandLine)) + return; + if (ts.isIgnoredFileFromWildCardWatching({ + watchedDirPath: toPath(directory), + fileOrDirectory: fileOrDirectory, + fileOrDirectoryPath: fileOrDirectoryPath, + configFileName: configFileName, + options: config.parsedCommandLine.options, + program: config.parsedCommandLine.fileNames, + currentDirectory: currentDirectory, + useCaseSensitiveFileNames: useCaseSensitiveFileNames, + writeLog: writeLog, + toPath: toPath, + })) + return; + // Reload is pending, do the reload + if (config.reloadLevel !== ts.ConfigFileProgramReloadLevel.Full) { + config.reloadLevel = ts.ConfigFileProgramReloadLevel.Partial; + // Schedule Update the program + scheduleProgramUpdate(); + } + }, flags, ((_a = commandLine.parsedCommandLine) === null || _a === void 0 ? void 0 : _a.watchOptions) || watchOptions, ts.WatchType.WildcardDirectoryOfReferencedProject); + }); + } + else if (commandLine.watchedDirectories) { + ts.clearMap(commandLine.watchedDirectories, ts.closeFileWatcherOf); + commandLine.watchedDirectories = undefined; + } + // Watch extended config files + updateExtendedConfigFilesWatches(configPath, (_d = commandLine.parsedCommandLine) === null || _d === void 0 ? void 0 : _d.options, ((_e = commandLine.parsedCommandLine) === null || _e === void 0 ? void 0 : _e.watchOptions) || watchOptions, ts.WatchType.ExtendedConfigOfReferencedProject); } } ts.createWatchProgram = createWatchProgram; @@ -113004,12 +116965,19 @@ var ts; compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames); compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives); 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) { var loader_3 = function (moduleName, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference).resolvedModule; }; compilerHost.resolveModuleNames = function (moduleNames, containingFile, _reusedNames, redirectedReference) { return ts.loadWithLocalCache(ts.Debug.checkEachDefined(moduleNames), containingFile, redirectedReference, loader_3); }; } + if (!compilerHost.resolveTypeReferenceDirectives) { + var loader_4 = function (moduleName, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache).resolvedTypeReferenceDirective; }; + compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { + return ts.loadWithLocalCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, loader_4); + }; + } var _a = ts.createWatchFactory(hostWithWatch, options), watchFile = _a.watchFile, watchDirectory = _a.watchDirectory, writeLog = _a.writeLog; var state = { host: host, @@ -113034,6 +117002,7 @@ var ts; projectErrorsReported: new ts.Map(), compilerHost: compilerHost, moduleResolutionCache: moduleResolutionCache, + typeReferenceDirectiveResolutionCache: typeReferenceDirectiveResolutionCache, // Mutable state buildOrder: undefined, readFileWithCache: function (f) { return host.readFile(f); }, @@ -113072,6 +117041,10 @@ var ts; function isParsedCommandLine(entry) { return !!entry.options; } + function getCachedParsedConfigFile(state, configFilePath) { + var value = state.configFileCache.get(configFilePath); + return value && isParsedCommandLine(value) ? value : undefined; + } function parseConfigFile(state, configFileName, configFilePath) { var configFileCache = state.configFileCache; var value = configFileCache.get(configFilePath); @@ -113217,7 +117190,7 @@ var ts; function disableCache(state) { if (!state.cache) return; - var cache = state.cache, host = state.host, compilerHost = state.compilerHost, extendedConfigCache = state.extendedConfigCache, moduleResolutionCache = state.moduleResolutionCache; + var cache = state.cache, host = state.host, compilerHost = state.compilerHost, extendedConfigCache = state.extendedConfigCache, moduleResolutionCache = state.moduleResolutionCache, typeReferenceDirectiveResolutionCache = state.typeReferenceDirectiveResolutionCache; host.readFile = cache.originalReadFile; host.fileExists = cache.originalFileExists; host.directoryExists = cache.originalDirectoryExists; @@ -113226,10 +117199,8 @@ var ts; compilerHost.getSourceFile = cache.originalGetSourceFile; state.readFileWithCache = cache.originalReadFileWithCache; extendedConfigCache.clear(); - if (moduleResolutionCache) { - moduleResolutionCache.directoryToModuleNameMap.clear(); - moduleResolutionCache.moduleNameToDirectoryMap.clear(); - } + moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.clear(); + typeReferenceDirectiveResolutionCache === null || typeReferenceDirectiveResolutionCache === void 0 ? void 0 : typeReferenceDirectiveResolutionCache.clear(); state.cache = undefined; } function clearProjectStatus(state, resolved) { @@ -113396,6 +117367,7 @@ var ts; return withProgramOrUndefined(action) || ts.emptyArray; } function createProgram() { + var _a, _b; ts.Debug.assert(program === undefined); if (state.options.dry) { reportStatus(state, ts.Diagnostics.A_non_dry_build_would_build_project_0, project); @@ -113415,7 +117387,8 @@ var ts; var host = state.host, compilerHost = state.compilerHost; state.projectCompilerOptions = config.options; // Update module resolution cache if needed - updateModuleResolutionCache(state, project, config); + (_a = state.moduleResolutionCache) === null || _a === void 0 ? void 0 : _a.update(config.options); + (_b = state.typeReferenceDirectiveResolutionCache) === null || _b === void 0 ? void 0 : _b.update(config.options); // Create program program = host.createProgram(config.fileNames, config.options, compilerHost, getOldProgram(state, projectPath, config), ts.getConfigFileParsingDiagnostics(config), config.projectReferences); if (state.watch) { @@ -113590,7 +117563,7 @@ var ts; emitBundle(writeFile, customTransformers); break; case BuildStep.BuildInvalidatedProjectOfBundle: - ts.Debug.checkDefined(invalidatedProjectOfBundle).done(cancellationToken); + ts.Debug.checkDefined(invalidatedProjectOfBundle).done(cancellationToken, writeFile, customTransformers); step = BuildStep.Done; break; case BuildStep.QueueReferencingProjects: @@ -113732,34 +117705,9 @@ var ts; afterProgramDone(state, program, config); return { buildResult: buildResult, step: BuildStep.QueueReferencingProjects }; } - function updateModuleResolutionCache(state, proj, config) { - if (!state.moduleResolutionCache) - return; - // Update module resolution cache if needed - var moduleResolutionCache = state.moduleResolutionCache; - var projPath = toPath(state, proj); - if (moduleResolutionCache.directoryToModuleNameMap.redirectsMap.size === 0) { - // The own map will be for projectCompilerOptions - ts.Debug.assert(moduleResolutionCache.moduleNameToDirectoryMap.redirectsMap.size === 0); - moduleResolutionCache.directoryToModuleNameMap.redirectsMap.set(projPath, moduleResolutionCache.directoryToModuleNameMap.ownMap); - moduleResolutionCache.moduleNameToDirectoryMap.redirectsMap.set(projPath, moduleResolutionCache.moduleNameToDirectoryMap.ownMap); - } - else { - // Set correct own map - ts.Debug.assert(moduleResolutionCache.moduleNameToDirectoryMap.redirectsMap.size > 0); - var ref = { - sourceFile: config.options.configFile, - commandLine: config - }; - moduleResolutionCache.directoryToModuleNameMap.setOwnMap(moduleResolutionCache.directoryToModuleNameMap.getOrCreateMapOfCacheRedirects(ref)); - moduleResolutionCache.moduleNameToDirectoryMap.setOwnMap(moduleResolutionCache.moduleNameToDirectoryMap.getOrCreateMapOfCacheRedirects(ref)); - } - moduleResolutionCache.directoryToModuleNameMap.setOwnOptions(config.options); - moduleResolutionCache.moduleNameToDirectoryMap.setOwnOptions(config.options); - } function checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName) { // Check tsconfig time - var tsconfigTime = state.host.getModifiedTime(configFile) || ts.missingFileModifiedTime; + var tsconfigTime = ts.getModifiedTime(state.host, configFile); if (oldestOutputFileTime < tsconfigTime) { return { type: ts.UpToDateStatusType.OutOfDateWithSelf, @@ -113769,6 +117717,7 @@ var ts; } } function getUpToDateStatusWorker(state, project, resolvedPath) { + var force = !!state.options.force; var newestInputFileName = undefined; var newestInputFileTime = minimumDate; var host = state.host; @@ -113781,10 +117730,13 @@ var ts; reason: inputFile + " does not exist" }; } - var inputTime = host.getModifiedTime(inputFile) || ts.missingFileModifiedTime; - if (inputTime > newestInputFileTime) { - newestInputFileName = inputFile; - newestInputFileTime = inputTime; + if (!force) { + var inputTime = ts.getModifiedTime(host, inputFile); + host.getModifiedTime(inputFile); + if (inputTime > newestInputFileTime) { + newestInputFileName = inputFile; + newestInputFileTime = inputTime; + } } } // Container if no files are specified in the project @@ -113803,36 +117755,38 @@ var ts; var missingOutputFileName; var newestDeclarationFileContentChangedTime = minimumDate; var isOutOfDateWithInputs = false; - for (var _b = 0, outputs_1 = outputs; _b < outputs_1.length; _b++) { - var output = outputs_1[_b]; - // Output is missing; can stop checking - // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status - if (!host.fileExists(output)) { - missingOutputFileName = output; - break; - } - var outputTime = host.getModifiedTime(output) || ts.missingFileModifiedTime; - if (outputTime < oldestOutputFileTime) { - oldestOutputFileTime = outputTime; - oldestOutputFileName = output; - } - // If an output is older than the newest input, we can stop checking - // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status - if (outputTime < newestInputFileTime) { - isOutOfDateWithInputs = true; - break; - } - if (outputTime > newestOutputFileTime) { - newestOutputFileTime = outputTime; - newestOutputFileName = output; - } - // Keep track of when the most recent time a .d.ts file was changed. - // In addition to file timestamps, we also keep track of when a .d.ts file - // had its file touched but not had its contents changed - this allows us - // to skip a downstream typecheck - if (isDeclarationFile(output)) { - var outputModifiedTime = host.getModifiedTime(output) || ts.missingFileModifiedTime; - newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime); + if (!force) { + for (var _b = 0, outputs_1 = outputs; _b < outputs_1.length; _b++) { + var output = outputs_1[_b]; + // Output is missing; can stop checking + // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status + if (!host.fileExists(output)) { + missingOutputFileName = output; + break; + } + var outputTime = ts.getModifiedTime(host, output); + if (outputTime < oldestOutputFileTime) { + oldestOutputFileTime = outputTime; + oldestOutputFileName = output; + } + // If an output is older than the newest input, we can stop checking + // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status + if (outputTime < newestInputFileTime) { + isOutOfDateWithInputs = true; + break; + } + if (outputTime > newestOutputFileTime) { + newestOutputFileTime = outputTime; + newestOutputFileName = output; + } + // Keep track of when the most recent time a .d.ts file was changed. + // In addition to file timestamps, we also keep track of when a .d.ts file + // had its file touched but not had its contents changed - this allows us + // to skip a downstream typecheck + if (isDeclarationFile(output)) { + var outputModifiedTime = ts.getModifiedTime(host, output); + newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime); + } } } var pseudoUpToDate = false; @@ -113868,7 +117822,8 @@ var ts; }; } // Check oldest output file name only if there is no missing output file name - if (!missingOutputFileName) { + // (a check we will have skipped if this is a forced build) + if (!force && !missingOutputFileName) { // If the upstream project's newest file is older than our oldest output, we // can't be out of date because of it if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) { @@ -113914,7 +117869,7 @@ var ts; if (extendedConfigStatus) return extendedConfigStatus; } - if (!state.buildInfoChecked.has(resolvedPath)) { + if (!force && !state.buildInfoChecked.has(resolvedPath)) { state.buildInfoChecked.set(resolvedPath, true); var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options); if (buildInfoPath) { @@ -113959,6 +117914,8 @@ var ts; return actual; } function updateOutputTimestampsWorker(state, proj, priorNewestUpdateTime, verboseMessage, skipOutputs) { + if (proj.options.noEmit) + return priorNewestUpdateTime; var host = state.host; var outputs = ts.getAllProjectOutputs(proj, !host.useCaseSensitiveFileNames()); if (!skipOutputs || outputs.length !== skipOutputs.size) { @@ -113974,7 +117931,7 @@ var ts; reportStatus(state, verboseMessage, proj.options.configFilePath); } if (isDeclarationFile(file)) { - priorNewestUpdateTime = newer(priorNewestUpdateTime, host.getModifiedTime(file) || ts.missingFileModifiedTime); + priorNewestUpdateTime = newer(priorNewestUpdateTime, ts.getModifiedTime(host, file)); } host.setModifiedTime(file, now); } @@ -114056,7 +118013,7 @@ var ts; } } } - function build(state, project, cancellationToken, onlyReferences) { + function build(state, project, cancellationToken, writeFile, getCustomTransformers, onlyReferences) { var buildOrder = getBuildOrderFor(state, project, onlyReferences); if (!buildOrder) return ts.ExitStatus.InvalidProject_OutputsSkipped; @@ -114068,7 +118025,7 @@ var ts; if (!invalidatedProject) break; reportQueue = false; - invalidatedProject.done(cancellationToken); + invalidatedProject.done(cancellationToken, writeFile, getCustomTransformers === null || getCustomTransformers === void 0 ? void 0 : getCustomTransformers(invalidatedProject.project)); if (!state.diagnostics.has(invalidatedProject.projectPath)) successfulProjects++; } @@ -114103,8 +118060,14 @@ var ts; continue; } var outputs = ts.getAllProjectOutputs(parsed, !host.useCaseSensitiveFileNames()); + if (!outputs.length) + continue; + var inputFileNames = new ts.Set(parsed.fileNames.map(function (f) { return toPath(state, f); })); for (var _a = 0, outputs_3 = outputs; _a < outputs_3.length; _a++) { var output = outputs_3[_a]; + // If output name is same as input file name, do not delete and ignore the error + if (inputFileNames.has(toPath(state, output))) + continue; if (host.fileExists(output)) { if (filesToDelete) { filesToDelete.push(output); @@ -114180,7 +118143,7 @@ var ts; }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.ConfigFile, resolved)); } function watchExtendedConfigFiles(state, resolvedPath, parsed) { - ts.updateSharedExtendedConfigFileWatcher(resolvedPath, parsed, state.allWatchedExtendedConfigFiles, function (extendedConfigFileName, extendedConfigFilePath) { return state.watchFile(extendedConfigFileName, function () { + ts.updateSharedExtendedConfigFileWatcher(resolvedPath, parsed === null || parsed === void 0 ? void 0 : parsed.options, state.allWatchedExtendedConfigFiles, function (extendedConfigFileName, extendedConfigFilePath) { return state.watchFile(extendedConfigFileName, function () { var _a; return (_a = state.allWatchedExtendedConfigFiles.get(extendedConfigFilePath)) === null || _a === void 0 ? void 0 : _a.projects.forEach(function (projectConfigFilePath) { return invalidateProjectAndScheduleBuilds(state, projectConfigFilePath, ts.ConfigFileProgramReloadLevel.Full); @@ -114191,6 +118154,7 @@ var ts; if (!state.watch) return; ts.updateWatchingWildcardDirectories(getOrCreateValueMapFromConfigFileMap(state.allWatchedWildcardDirectories, resolvedPath), new ts.Map(ts.getEntries(parsed.wildcardDirectories)), function (dir, flags) { return state.watchDirectory(dir, function (fileOrDirectory) { + var _a; if (ts.isIgnoredFileFromWildCardWatching({ watchedDirPath: toPath(state, dir), fileOrDirectory: fileOrDirectory, @@ -114198,9 +118162,10 @@ var ts; configFileName: resolved, currentDirectory: state.currentDirectory, options: parsed.options, - program: state.builderPrograms.get(resolvedPath), + program: state.builderPrograms.get(resolvedPath) || ((_a = getCachedParsedConfigFile(state, resolvedPath)) === null || _a === void 0 ? void 0 : _a.fileNames), useCaseSensitiveFileNames: state.parseConfigFileHost.useCaseSensitiveFileNames, - writeLog: function (s) { return state.writeLog(s); } + writeLog: function (s) { return state.writeLog(s); }, + toPath: function (fileName) { return toPath(state, fileName); } })) return; invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.Partial); @@ -114235,19 +118200,16 @@ var ts; } function stopWatching(state) { ts.clearMap(state.allWatchedConfigFiles, ts.closeFileWatcher); - ts.clearMap(state.allWatchedExtendedConfigFiles, function (watcher) { - watcher.projects.clear(); - watcher.close(); - }); + ts.clearMap(state.allWatchedExtendedConfigFiles, ts.closeFileWatcherOf); ts.clearMap(state.allWatchedWildcardDirectories, function (watchedWildcardDirectories) { return ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcherOf); }); ts.clearMap(state.allWatchedInputFiles, function (watchedWildcardDirectories) { return ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcher); }); } function createSolutionBuilderWorker(watch, hostOrHostWithWatch, rootNames, options, baseWatchOptions) { var state = createSolutionBuilderState(watch, hostOrHostWithWatch, rootNames, options, baseWatchOptions); return { - build: function (project, cancellationToken) { return build(state, project, cancellationToken); }, + build: function (project, cancellationToken, writeFile, getCustomTransformers) { return build(state, project, cancellationToken, writeFile, getCustomTransformers); }, clean: function (project) { return clean(state, project); }, - buildReferences: function (project, cancellationToken) { return build(state, project, cancellationToken, /*onlyReferences*/ true); }, + buildReferences: function (project, cancellationToken, writeFile, getCustomTransformers) { return build(state, project, cancellationToken, writeFile, getCustomTransformers, /*onlyReferences*/ true); }, cleanReferences: function (project) { return clean(state, project, /*onlyReferences*/ true); }, getNextInvalidatedProject: function (cancellationToken) { setupInitialBuild(state, cancellationToken); @@ -114337,6 +118299,9 @@ var ts; } } function reportUpToDateStatus(state, configFileName, status) { + if (state.options.force && (status.type === ts.UpToDateStatusType.UpToDate || status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes)) { + return reportStatus(state, ts.Diagnostics.Project_0_is_being_forcibly_rebuilt, relName(state, configFileName)); + } switch (status.type) { case ts.UpToDateStatusType.OutOfDateWithSelf: return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, relName(state, configFileName), relName(state, status.outOfDateOutputFileName), relName(state, status.newerInputFileName)); @@ -114886,6 +118851,9 @@ var ts; SymbolDisplayPartKind[SymbolDisplayPartKind["enumMemberName"] = 19] = "enumMemberName"; SymbolDisplayPartKind[SymbolDisplayPartKind["functionName"] = 20] = "functionName"; SymbolDisplayPartKind[SymbolDisplayPartKind["regularExpressionLiteral"] = 21] = "regularExpressionLiteral"; + SymbolDisplayPartKind[SymbolDisplayPartKind["link"] = 22] = "link"; + SymbolDisplayPartKind[SymbolDisplayPartKind["linkName"] = 23] = "linkName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["linkText"] = 24] = "linkText"; })(SymbolDisplayPartKind = ts.SymbolDisplayPartKind || (ts.SymbolDisplayPartKind = {})); var OutliningSpanKind; (function (OutliningSpanKind) { @@ -114996,6 +118964,12 @@ var ts; ScriptElementKind["jsxAttribute"] = "JSX attribute"; /** String literal */ ScriptElementKind["string"] = "string"; + /** Jsdoc @link: in `{@link C link text}`, the before and after text "{@link " and "}" */ + ScriptElementKind["link"] = "link"; + /** Jsdoc @link: in `{@link C link text}`, the entity name "C" */ + ScriptElementKind["linkName"] = "link name"; + /** Jsdoc @link: in `{@link C link text}`, the link text "link text" */ + ScriptElementKind["linkText"] = "link text"; })(ScriptElementKind = ts.ScriptElementKind || (ts.ScriptElementKind = {})); var ScriptElementKindModifier; (function (ScriptElementKindModifier) { @@ -115088,37 +119062,37 @@ var ts; })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return ts.isInJSFile(node) && ts.getJSDocEnumTag(node) ? 7 /* All */ : 1 /* Value */; - case 160 /* Parameter */: - case 198 /* BindingElement */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 288 /* PropertyAssignment */: - case 289 /* ShorthandPropertyAssignment */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 287 /* CatchClause */: - case 280 /* JsxAttribute */: + case 162 /* Parameter */: + case 200 /* BindingElement */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 290 /* PropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 289 /* CatchClause */: + case 282 /* JsxAttribute */: return 1 /* Value */; - case 159 /* TypeParameter */: - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 177 /* TypeLiteral */: + case 161 /* TypeParameter */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 179 /* TypeLiteral */: return 2 /* Type */; - case 331 /* JSDocTypedefTag */: + case 339 /* 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 291 /* EnumMember */: - case 252 /* ClassDeclaration */: + case 293 /* EnumMember */: + case 254 /* ClassDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -115128,16 +119102,16 @@ var ts; else { return 4 /* Namespace */; } - case 255 /* EnumDeclaration */: - case 264 /* NamedImports */: - case 265 /* ImportSpecifier */: - case 260 /* ImportEqualsDeclaration */: - case 261 /* ImportDeclaration */: - case 266 /* ExportAssignment */: - case 267 /* ExportDeclaration */: + case 257 /* EnumDeclaration */: + case 266 /* NamedImports */: + case 267 /* ImportSpecifier */: + case 262 /* ImportEqualsDeclaration */: + case 263 /* ImportDeclaration */: + case 268 /* ExportAssignment */: + case 269 /* ExportDeclaration */: return 7 /* All */; // An external module can be a Value - case 297 /* SourceFile */: + case 299 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 7 /* All */; @@ -115145,13 +119119,13 @@ var ts; ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { node = getAdjustedReferenceLocation(node); - if (node.kind === 297 /* SourceFile */) { + if (node.kind === 299 /* SourceFile */) { return 1 /* Value */; } - else if (node.parent.kind === 266 /* ExportAssignment */ - || node.parent.kind === 272 /* ExternalModuleReference */ - || node.parent.kind === 265 /* ImportSpecifier */ - || node.parent.kind === 262 /* ImportClause */ + else if (node.parent.kind === 268 /* ExportAssignment */ + || node.parent.kind === 274 /* ExternalModuleReference */ + || node.parent.kind === 267 /* ImportSpecifier */ + || node.parent.kind === 264 /* ImportClause */ || ts.isImportEqualsDeclaration(node.parent) && node === node.parent.name) { return 7 /* All */; } @@ -115161,7 +119135,7 @@ var ts; else if (ts.isDeclarationName(node)) { return getMeaningFromDeclaration(node.parent); } - else if (ts.isEntityName(node) && ts.isJSDocNameReference(node.parent)) { + else if (ts.isEntityName(node) && ts.findAncestor(node, ts.or(ts.isJSDocNameReference, ts.isJSDocLinkLike, ts.isJSDocMemberName))) { return 7 /* All */; } else if (isTypeReference(node)) { @@ -115187,11 +119161,11 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - var name = node.kind === 157 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; - return name && name.parent.kind === 260 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; + var name = node.kind === 159 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; + return name && name.parent.kind === 262 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; } function isInRightSideOfInternalImportEqualsDeclaration(node) { - while (node.parent.kind === 157 /* QualifiedName */) { + while (node.parent.kind === 159 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -115203,27 +119177,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 157 /* QualifiedName */) { - while (root.parent && root.parent.kind === 157 /* QualifiedName */) { + if (root.parent.kind === 159 /* QualifiedName */) { + while (root.parent && root.parent.kind === 159 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 173 /* TypeReference */ && !isLastClause; + return root.parent.kind === 175 /* TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 201 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 201 /* PropertyAccessExpression */) { + if (root.parent.kind === 203 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 203 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 223 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 286 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 225 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 288 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 252 /* ClassDeclaration */ && root.parent.parent.token === 116 /* ImplementsKeyword */) || - (decl.kind === 253 /* InterfaceDeclaration */ && root.parent.parent.token === 93 /* ExtendsKeyword */); + return (decl.kind === 254 /* ClassDeclaration */ && root.parent.parent.token === 117 /* ImplementsKeyword */) || + (decl.kind === 255 /* InterfaceDeclaration */ && root.parent.parent.token === 94 /* ExtendsKeyword */); } return false; } @@ -115232,17 +119206,17 @@ var ts; node = node.parent; } switch (node.kind) { - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: return !ts.isExpressionNode(node); - case 187 /* ThisType */: + case 189 /* ThisType */: return true; } switch (node.parent.kind) { - case 173 /* TypeReference */: + case 175 /* TypeReference */: return true; - case 195 /* ImportType */: + case 197 /* ImportType */: return !node.parent.isTypeOf; - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: return !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent); } return false; @@ -115309,7 +119283,7 @@ var ts; ts.climbPastPropertyOrElementAccess = climbPastPropertyOrElementAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 245 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { + if (referenceNode.kind === 247 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -115370,22 +119344,22 @@ var ts; ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { switch (node.parent.kind) { - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 288 /* PropertyAssignment */: - case 291 /* EnumMember */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 256 /* ModuleDeclaration */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 290 /* PropertyAssignment */: + case 293 /* EnumMember */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 258 /* ModuleDeclaration */: return ts.getNameOfDeclaration(node.parent) === node; - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: return node.parent.argumentExpression === node; - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return true; - case 191 /* LiteralType */: - return node.parent.parent.kind === 189 /* IndexedAccessType */; + case 193 /* LiteralType */: + return node.parent.parent.kind === 191 /* IndexedAccessType */; default: return false; } @@ -115409,17 +119383,17 @@ var ts; return undefined; } switch (node.kind) { - case 297 /* SourceFile */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - case 256 /* ModuleDeclaration */: + case 299 /* SourceFile */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 257 /* EnumDeclaration */: + case 258 /* ModuleDeclaration */: return node; } } @@ -115427,54 +119401,54 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 297 /* SourceFile */: + case 299 /* SourceFile */: return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return "module" /* moduleElement */; - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: return "class" /* classElement */; - case 253 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; - case 254 /* TypeAliasDeclaration */: - case 324 /* JSDocCallbackTag */: - case 331 /* JSDocTypedefTag */: + case 255 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; + case 256 /* TypeAliasDeclaration */: + case 332 /* JSDocCallbackTag */: + case 339 /* JSDocTypedefTag */: return "type" /* typeElement */; - case 255 /* EnumDeclaration */: return "enum" /* enumElement */; - case 249 /* VariableDeclaration */: + case 257 /* EnumDeclaration */: return "enum" /* enumElement */; + case 251 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 198 /* BindingElement */: + case 200 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 209 /* ArrowFunction */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: return "function" /* functionElement */; - case 167 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; - case 168 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 169 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; + case 170 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: return "method" /* memberFunctionElement */; - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: var initializer = node.initializer; return ts.isFunctionLike(initializer) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */; - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 289 /* ShorthandPropertyAssignment */: - case 290 /* SpreadAssignment */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 291 /* ShorthandPropertyAssignment */: + case 292 /* SpreadAssignment */: return "property" /* memberVariableElement */; - case 171 /* IndexSignature */: return "index" /* indexSignatureElement */; - case 170 /* ConstructSignature */: return "construct" /* constructSignatureElement */; - case 169 /* CallSignature */: return "call" /* callSignatureElement */; - case 166 /* Constructor */: return "constructor" /* constructorImplementationElement */; - case 159 /* TypeParameter */: return "type parameter" /* typeParameterElement */; - case 291 /* EnumMember */: return "enum member" /* enumMemberElement */; - case 160 /* Parameter */: return ts.hasSyntacticModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; - case 260 /* ImportEqualsDeclaration */: - case 265 /* ImportSpecifier */: - case 270 /* ExportSpecifier */: - case 263 /* NamespaceImport */: - case 269 /* NamespaceExport */: + case 173 /* IndexSignature */: return "index" /* indexSignatureElement */; + case 172 /* ConstructSignature */: return "construct" /* constructSignatureElement */; + case 171 /* CallSignature */: return "call" /* callSignatureElement */; + case 168 /* Constructor */: return "constructor" /* constructorImplementationElement */; + case 161 /* TypeParameter */: return "type parameter" /* typeParameterElement */; + case 293 /* EnumMember */: return "enum member" /* enumMemberElement */; + case 162 /* Parameter */: return ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; + case 262 /* ImportEqualsDeclaration */: + case 267 /* ImportSpecifier */: + case 272 /* ExportSpecifier */: + case 265 /* NamespaceImport */: + case 271 /* NamespaceExport */: return "alias" /* alias */; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: var kind = ts.getAssignmentDeclarationKind(node); var right = node.right; switch (kind) { @@ -115501,9 +119475,9 @@ var ts; return "" /* unknown */; } } - case 78 /* Identifier */: + case 79 /* Identifier */: return ts.isImportClause(node.parent) ? "alias" /* alias */ : "" /* unknown */; - case 266 /* ExportAssignment */: + case 268 /* 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; @@ -115521,12 +119495,12 @@ var ts; ts.getNodeKind = getNodeKind; function isThis(node) { switch (node.kind) { - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: // case SyntaxKind.ThisType: TODO: GH#9267 return true; - case 78 /* Identifier */: + case 79 /* Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 160 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 162 /* Parameter */; default: return false; } @@ -115591,42 +119565,42 @@ var ts; return false; } switch (n.kind) { - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - case 200 /* ObjectLiteralExpression */: - case 196 /* ObjectBindingPattern */: - case 177 /* TypeLiteral */: - case 230 /* Block */: - case 257 /* ModuleBlock */: - case 258 /* CaseBlock */: - case 264 /* NamedImports */: - case 268 /* NamedExports */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 257 /* EnumDeclaration */: + case 202 /* ObjectLiteralExpression */: + case 198 /* ObjectBindingPattern */: + case 179 /* TypeLiteral */: + case 232 /* Block */: + case 259 /* ModuleBlock */: + case 260 /* CaseBlock */: + case 266 /* NamedImports */: + case 270 /* NamedExports */: return nodeEndsWith(n, 19 /* CloseBraceToken */, sourceFile); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 204 /* NewExpression */: + case 206 /* NewExpression */: if (!n.arguments) { return true; } // falls through - case 203 /* CallExpression */: - case 207 /* ParenthesizedExpression */: - case 186 /* ParenthesizedType */: + case 205 /* CallExpression */: + case 209 /* ParenthesizedExpression */: + case 188 /* ParenthesizedType */: return nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile); - case 174 /* FunctionType */: - case 175 /* ConstructorType */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 170 /* ConstructSignature */: - case 169 /* CallSignature */: - case 209 /* ArrowFunction */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 172 /* ConstructSignature */: + case 171 /* CallSignature */: + case 211 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -115636,65 +119610,65 @@ 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 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return !!n.body && isCompletedNode(n.body, sourceFile); - case 234 /* IfStatement */: + case 236 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 26 /* SemicolonToken */, sourceFile); - case 199 /* ArrayLiteralExpression */: - case 197 /* ArrayBindingPattern */: - case 202 /* ElementAccessExpression */: - case 158 /* ComputedPropertyName */: - case 179 /* TupleType */: + case 201 /* ArrayLiteralExpression */: + case 199 /* ArrayBindingPattern */: + case 204 /* ElementAccessExpression */: + case 160 /* ComputedPropertyName */: + case 181 /* TupleType */: return nodeEndsWith(n, 23 /* CloseBracketToken */, sourceFile); - case 171 /* IndexSignature */: + case 173 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 23 /* CloseBracketToken */, sourceFile); - case 284 /* CaseClause */: - case 285 /* DefaultClause */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 236 /* WhileStatement */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 238 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 235 /* DoStatement */: + case 237 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; - return hasChildOfKind(n, 114 /* WhileKeyword */, sourceFile) + return hasChildOfKind(n, 115 /* WhileKeyword */, sourceFile) ? nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile) : isCompletedNode(n.statement, sourceFile); - case 176 /* TypeQuery */: + case 178 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 211 /* TypeOfExpression */: - case 210 /* DeleteExpression */: - case 212 /* VoidExpression */: - case 219 /* YieldExpression */: - case 220 /* SpreadElement */: + case 213 /* TypeOfExpression */: + case 212 /* DeleteExpression */: + case 214 /* VoidExpression */: + case 221 /* YieldExpression */: + case 222 /* SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 218 /* TemplateExpression */: + case 220 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 228 /* TemplateSpan */: + case 230 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 267 /* ExportDeclaration */: - case 261 /* ImportDeclaration */: + case 269 /* ExportDeclaration */: + case 263 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -115754,13 +119728,13 @@ var ts; } ts.findContainingList = findContainingList; function isDefaultModifier(node) { - return node.kind === 87 /* DefaultKeyword */; + return node.kind === 88 /* DefaultKeyword */; } function isClassKeyword(node) { - return node.kind === 83 /* ClassKeyword */; + return node.kind === 84 /* ClassKeyword */; } function isFunctionKeyword(node) { - return node.kind === 97 /* FunctionKeyword */; + return node.kind === 98 /* FunctionKeyword */; } function getAdjustedLocationForClass(node) { if (ts.isNamedDeclaration(node)) { @@ -115820,11 +119794,11 @@ var ts; function getAdjustedLocationForDeclaration(node, forRename) { if (!forRename) { switch (node.kind) { - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: return getAdjustedLocationForClass(node); - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: return getAdjustedLocationForFunction(node); } } @@ -115914,30 +119888,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 !== 87 /* DefaultKeyword */) ? ts.contains(parent.modifiers, node) : - node.kind === 83 /* ClassKeyword */ ? ts.isClassDeclaration(parent) || ts.isClassExpression(node) : - node.kind === 97 /* FunctionKeyword */ ? ts.isFunctionDeclaration(parent) || ts.isFunctionExpression(node) : - node.kind === 117 /* InterfaceKeyword */ ? ts.isInterfaceDeclaration(parent) : - node.kind === 91 /* EnumKeyword */ ? ts.isEnumDeclaration(parent) : - node.kind === 149 /* TypeKeyword */ ? ts.isTypeAliasDeclaration(parent) : - node.kind === 140 /* NamespaceKeyword */ || node.kind === 139 /* ModuleKeyword */ ? ts.isModuleDeclaration(parent) : - node.kind === 99 /* ImportKeyword */ ? ts.isImportEqualsDeclaration(parent) : - node.kind === 134 /* GetKeyword */ ? ts.isGetAccessorDeclaration(parent) : - node.kind === 146 /* SetKeyword */ && ts.isSetAccessorDeclaration(parent)) { + if (ts.isModifier(node) && (forRename || node.kind !== 88 /* DefaultKeyword */) ? 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 === 150 /* TypeKeyword */ ? ts.isTypeAliasDeclaration(parent) : + node.kind === 141 /* NamespaceKeyword */ || node.kind === 140 /* ModuleKeyword */ ? ts.isModuleDeclaration(parent) : + node.kind === 100 /* ImportKeyword */ ? ts.isImportEqualsDeclaration(parent) : + node.kind === 135 /* GetKeyword */ ? ts.isGetAccessorDeclaration(parent) : + node.kind === 147 /* SetKeyword */ && ts.isSetAccessorDeclaration(parent)) { var location = getAdjustedLocationForDeclaration(parent, forRename); if (location) { return location; } } // /**/ [|name|] ... - if ((node.kind === 112 /* VarKeyword */ || node.kind === 84 /* ConstKeyword */ || node.kind === 118 /* LetKeyword */) && + if ((node.kind === 113 /* VarKeyword */ || node.kind === 85 /* ConstKeyword */ || node.kind === 119 /* LetKeyword */) && ts.isVariableDeclarationList(parent) && parent.declarations.length === 1) { var decl = parent.declarations[0]; if (ts.isIdentifier(decl.name)) { return decl.name; } } - if (node.kind === 149 /* TypeKeyword */) { + if (node.kind === 150 /* TypeKeyword */) { // import /**/type [|name|] from ...; // import /**/type { [|name|] } from ...; // import /**/type { propertyName as [|name|] } from ...; @@ -115963,7 +119937,7 @@ var ts; // import * /**/as [|name|] ... // export { propertyName /**/as [|name|] } ... // export * /**/as [|name|] ... - if (node.kind === 126 /* AsKeyword */) { + if (node.kind === 127 /* AsKeyword */) { if (ts.isImportSpecifier(parent) && parent.propertyName || ts.isExportSpecifier(parent) && parent.propertyName || ts.isNamespaceImport(parent) || @@ -115979,13 +119953,13 @@ var ts; // /**/import { propertyName as [|name|] } from ...; // /**/import ... from "[|module|]"; // /**/import "[|module|]"; - if (node.kind === 99 /* ImportKeyword */ && ts.isImportDeclaration(parent)) { + if (node.kind === 100 /* ImportKeyword */ && ts.isImportDeclaration(parent)) { var location = getAdjustedLocationForImportDeclaration(parent, forRename); if (location) { return location; } } - if (node.kind === 92 /* ExportKeyword */) { + if (node.kind === 93 /* ExportKeyword */) { // /**/export { [|name|] } ...; // /**/export { propertyName as [|name|] } ...; // /**/export * from "[|module|]"; @@ -116004,12 +119978,12 @@ var ts; } } // import name = /**/require("[|module|]"); - if (node.kind === 143 /* RequireKeyword */ && ts.isExternalModuleReference(parent)) { + if (node.kind === 144 /* RequireKeyword */ && ts.isExternalModuleReference(parent)) { return parent.expression; } // import ... /**/from "[|module|]"; // export ... /**/from "[|module|]"; - if (node.kind === 153 /* FromKeyword */ && (ts.isImportDeclaration(parent) || ts.isExportDeclaration(parent)) && parent.moduleSpecifier) { + if (node.kind === 154 /* FromKeyword */ && (ts.isImportDeclaration(parent) || ts.isExportDeclaration(parent)) && parent.moduleSpecifier) { return parent.moduleSpecifier; } // class ... /**/extends [|name|] ... @@ -116017,13 +119991,13 @@ var ts; // class ... /**/implements name1, name2 ... // interface ... /**/extends [|name|] ... // interface ... /**/extends name1, name2 ... - if ((node.kind === 93 /* ExtendsKeyword */ || node.kind === 116 /* ImplementsKeyword */) && ts.isHeritageClause(parent) && parent.token === node.kind) { + if ((node.kind === 94 /* ExtendsKeyword */ || node.kind === 117 /* ImplementsKeyword */) && ts.isHeritageClause(parent) && parent.token === node.kind) { var location = getAdjustedLocationForHeritageClause(parent); if (location) { return location; } } - if (node.kind === 93 /* ExtendsKeyword */) { + if (node.kind === 94 /* ExtendsKeyword */) { // ... ... if (ts.isTypeParameterDeclaration(parent) && parent.constraint && ts.isTypeReferenceNode(parent.constraint)) { return parent.constraint.typeName; @@ -116034,20 +120008,20 @@ var ts; } } // ... T extends /**/infer [|U|] ? ... - if (node.kind === 135 /* InferKeyword */ && ts.isInferTypeNode(parent)) { + if (node.kind === 136 /* InferKeyword */ && ts.isInferTypeNode(parent)) { return parent.typeParameter.name; } // { [ [|K|] /**/in keyof T]: ... } - if (node.kind === 100 /* InKeyword */ && ts.isTypeParameterDeclaration(parent) && ts.isMappedTypeNode(parent.parent)) { + if (node.kind === 101 /* InKeyword */ && ts.isTypeParameterDeclaration(parent) && ts.isMappedTypeNode(parent.parent)) { return parent.name; } // /**/keyof [|T|] - if (node.kind === 138 /* KeyOfKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 138 /* KeyOfKeyword */ && + if (node.kind === 139 /* KeyOfKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 139 /* KeyOfKeyword */ && ts.isTypeReferenceNode(parent.type)) { return parent.type.typeName; } // /**/readonly [|name|][] - if (node.kind === 142 /* ReadonlyKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 142 /* ReadonlyKeyword */ && + if (node.kind === 143 /* ReadonlyKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 143 /* ReadonlyKeyword */ && ts.isArrayTypeNode(parent.type) && ts.isTypeReferenceNode(parent.type.elementType)) { return parent.type.elementType.typeName; } @@ -116062,29 +120036,29 @@ var ts; // /**/yield [|name|] // /**/yield obj.[|name|] // /**/delete obj.[|name|] - if (node.kind === 102 /* NewKeyword */ && ts.isNewExpression(parent) || - node.kind === 113 /* VoidKeyword */ && ts.isVoidExpression(parent) || - node.kind === 111 /* TypeOfKeyword */ && ts.isTypeOfExpression(parent) || - node.kind === 130 /* AwaitKeyword */ && ts.isAwaitExpression(parent) || - node.kind === 124 /* YieldKeyword */ && ts.isYieldExpression(parent) || - node.kind === 88 /* DeleteKeyword */ && ts.isDeleteExpression(parent)) { + if (node.kind === 103 /* NewKeyword */ && ts.isNewExpression(parent) || + node.kind === 114 /* VoidKeyword */ && ts.isVoidExpression(parent) || + node.kind === 112 /* TypeOfKeyword */ && ts.isTypeOfExpression(parent) || + node.kind === 131 /* AwaitKeyword */ && ts.isAwaitExpression(parent) || + node.kind === 125 /* YieldKeyword */ && ts.isYieldExpression(parent) || + node.kind === 89 /* DeleteKeyword */ && ts.isDeleteExpression(parent)) { if (parent.expression) { return ts.skipOuterExpressions(parent.expression); } } // left /**/in [|name|] // left /**/instanceof [|name|] - if ((node.kind === 100 /* InKeyword */ || node.kind === 101 /* InstanceOfKeyword */) && ts.isBinaryExpression(parent) && parent.operatorToken === node) { + if ((node.kind === 101 /* InKeyword */ || node.kind === 102 /* InstanceOfKeyword */) && ts.isBinaryExpression(parent) && parent.operatorToken === node) { return ts.skipOuterExpressions(parent.right); } // left /**/as [|name|] - if (node.kind === 126 /* AsKeyword */ && ts.isAsExpression(parent) && ts.isTypeReferenceNode(parent.type)) { + if (node.kind === 127 /* AsKeyword */ && ts.isAsExpression(parent) && ts.isTypeReferenceNode(parent.type)) { return parent.type.typeName; } // for (... /**/in [|name|]) // for (... /**/of [|name|]) - if (node.kind === 100 /* InKeyword */ && ts.isForInStatement(parent) || - node.kind === 156 /* OfKeyword */ && ts.isForOfStatement(parent)) { + if (node.kind === 101 /* InKeyword */ && ts.isForInStatement(parent) || + node.kind === 158 /* OfKeyword */ && ts.isForOfStatement(parent)) { return ts.skipOuterExpressions(parent.expression); } } @@ -116153,6 +120127,21 @@ var ts; return current; } } + /** + * Returns the first token where position is in [start, end), + * excluding `JsxText` tokens containing only whitespace. + */ + function findFirstNonJsxWhitespaceToken(sourceFile, position) { + var tokenAtPosition = getTokenAtPosition(sourceFile, position); + while (isWhiteSpaceOnlyJsxText(tokenAtPosition)) { + var nextToken = findNextToken(tokenAtPosition, tokenAtPosition.parent, sourceFile); + if (!nextToken) + return; + tokenAtPosition = nextToken; + } + return tokenAtPosition; + } + ts.findFirstNonJsxWhitespaceToken = findFirstNonJsxWhitespaceToken; /** * The token on the left of the position is the token that strictly includes the position * or sits to the left of the cursor if it is on a boundary. For example @@ -116239,7 +120228,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 297 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); + ts.Debug.assert(startNode !== undefined || n.kind === 299 /* SourceFile */ || n.kind === 1 /* 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. @@ -116312,17 +120301,17 @@ var ts; return true; } //
{ |
or
- if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 283 /* JsxExpression */) { + if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 285 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 283 /* JsxExpression */) { + if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 285 /* JsxExpression */) { return true; } //
|
- if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 276 /* JsxClosingElement */) { + if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 278 /* JsxClosingElement */) { return true; } return false; @@ -116353,17 +120342,17 @@ var ts; function isInsideJsxElement(sourceFile, position) { function isInsideJsxElementTraversal(node) { while (node) { - if (node.kind >= 274 /* JsxSelfClosingElement */ && node.kind <= 283 /* JsxExpression */ + if (node.kind >= 276 /* JsxSelfClosingElement */ && node.kind <= 285 /* JsxExpression */ || node.kind === 11 /* JsxText */ || node.kind === 29 /* LessThanToken */ || node.kind === 31 /* GreaterThanToken */ - || node.kind === 78 /* Identifier */ + || node.kind === 79 /* Identifier */ || node.kind === 19 /* CloseBraceToken */ || node.kind === 18 /* OpenBraceToken */ || node.kind === 43 /* SlashToken */) { node = node.parent; } - else if (node.kind === 273 /* JsxElement */) { + else if (node.kind === 275 /* JsxElement */) { if (position > node.getStart(sourceFile)) return true; node = node.parent; @@ -116502,16 +120491,16 @@ var ts; break; case 38 /* EqualsGreaterThanToken */: // falls through - case 78 /* Identifier */: + case 79 /* Identifier */: case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: // falls through - case 111 /* TypeOfKeyword */: - case 93 /* ExtendsKeyword */: - case 138 /* KeyOfKeyword */: + case 112 /* TypeOfKeyword */: + case 94 /* ExtendsKeyword */: + case 139 /* KeyOfKeyword */: case 24 /* DotToken */: case 51 /* BarToken */: case 57 /* QuestionToken */: @@ -116571,16 +120560,16 @@ var ts; result.push("deprecated" /* deprecatedModifier */); if (node.flags & 8388608 /* Ambient */) result.push("declare" /* ambientModifier */); - if (node.kind === 266 /* ExportAssignment */) + if (node.kind === 268 /* ExportAssignment */) result.push("export" /* exportedModifier */); return result.length > 0 ? result.join(",") : "" /* none */; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 173 /* TypeReference */ || node.kind === 203 /* CallExpression */) { + if (node.kind === 175 /* TypeReference */ || node.kind === 205 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 252 /* ClassDeclaration */ || node.kind === 253 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 254 /* ClassDeclaration */ || node.kind === 255 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; @@ -116600,7 +120589,7 @@ var ts; } ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; function isPunctuation(kind) { - return 18 /* FirstPunctuation */ <= kind && kind <= 77 /* LastPunctuation */; + return 18 /* FirstPunctuation */ <= kind && kind <= 78 /* LastPunctuation */; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position, sourceFile) { @@ -116610,9 +120599,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 122 /* PublicKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: + case 123 /* PublicKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: return true; } return false; @@ -116625,18 +120614,18 @@ var ts; } ts.cloneCompilerOptions = cloneCompilerOptions; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 199 /* ArrayLiteralExpression */ || - node.kind === 200 /* ObjectLiteralExpression */) { + if (node.kind === 201 /* ArrayLiteralExpression */ || + node.kind === 202 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 216 /* BinaryExpression */ && + if (node.parent.kind === 218 /* BinaryExpression */ && node.parent.left === node && - node.parent.operatorToken.kind === 62 /* EqualsToken */) { + node.parent.operatorToken.kind === 63 /* EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 239 /* ForOfStatement */ && + if (node.parent.kind === 241 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -116644,7 +120633,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 288 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 290 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -116706,32 +120695,32 @@ var ts; } ts.createTextChange = createTextChange; ts.typeKeywords = [ - 128 /* AnyKeyword */, - 127 /* AssertsKeyword */, - 155 /* BigIntKeyword */, - 131 /* BooleanKeyword */, - 94 /* FalseKeyword */, - 135 /* InferKeyword */, - 138 /* KeyOfKeyword */, - 141 /* NeverKeyword */, - 103 /* NullKeyword */, - 144 /* NumberKeyword */, - 145 /* ObjectKeyword */, - 142 /* ReadonlyKeyword */, - 147 /* StringKeyword */, - 148 /* SymbolKeyword */, - 109 /* TrueKeyword */, - 113 /* VoidKeyword */, - 150 /* UndefinedKeyword */, - 151 /* UniqueKeyword */, - 152 /* UnknownKeyword */, + 129 /* AnyKeyword */, + 128 /* AssertsKeyword */, + 156 /* BigIntKeyword */, + 132 /* BooleanKeyword */, + 95 /* FalseKeyword */, + 136 /* InferKeyword */, + 139 /* KeyOfKeyword */, + 142 /* NeverKeyword */, + 104 /* NullKeyword */, + 145 /* NumberKeyword */, + 146 /* ObjectKeyword */, + 143 /* ReadonlyKeyword */, + 148 /* StringKeyword */, + 149 /* SymbolKeyword */, + 110 /* TrueKeyword */, + 114 /* VoidKeyword */, + 151 /* UndefinedKeyword */, + 152 /* UniqueKeyword */, + 153 /* UnknownKeyword */, ]; function isTypeKeyword(kind) { return ts.contains(ts.typeKeywords, kind); } ts.isTypeKeyword = isTypeKeyword; function isTypeKeywordToken(node) { - return node.kind === 149 /* TypeKeyword */; + return node.kind === 150 /* TypeKeyword */; } ts.isTypeKeywordToken = isTypeKeywordToken; /** True if the symbol is for an external module, as opposed to a namespace. */ @@ -116764,7 +120753,7 @@ var ts; } ts.skipConstraint = skipConstraint; function getNameFromPropertyName(name) { - return name.kind === 158 /* ComputedPropertyName */ + return name.kind === 160 /* 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); @@ -116783,7 +120772,7 @@ var ts; } ts.compilerOptionsIndicateEs6Modules = compilerOptionsIndicateEs6Modules; function createModuleSpecifierResolutionHost(program, host) { - // Mix in `getProbableSymlinks` from Program when host doesn't have it + // Mix in `getSymlinkCache` from Program when host doesn't have it // in order for non-Project hosts to have a symlinks cache. return { fileExists: function (fileName) { return program.fileExists(fileName); }, @@ -116791,6 +120780,7 @@ var ts; readFile: ts.maybeBind(host, host.readFile), useCaseSensitiveFileNames: ts.maybeBind(host, host.useCaseSensitiveFileNames), getSymlinkCache: ts.maybeBind(host, host.getSymlinkCache) || program.getSymlinkCache, + getModuleSpecifierCache: ts.maybeBind(host, host.getModuleSpecifierCache), getGlobalTypingsCacheLocation: ts.maybeBind(host, host.getGlobalTypingsCacheLocation), getSourceFiles: function () { return program.getSourceFiles(); }, redirectTargetsMap: program.redirectTargetsMap, @@ -116861,10 +120851,17 @@ var ts; } return ts.firstDefined(symbol.declarations, function (decl) { var name = ts.getNameOfDeclaration(decl); - return name && name.kind === 78 /* Identifier */ ? name.escapedText : undefined; + return name && name.kind === 79 /* Identifier */ ? name.escapedText : undefined; }); } ts.symbolEscapedNameNoDefault = symbolEscapedNameNoDefault; + function isModuleSpecifierLike(node) { + return ts.isStringLiteralLike(node) && (ts.isExternalModuleReference(node.parent) || + ts.isImportDeclaration(node.parent) || + ts.isRequireCall(node.parent, /*requireStringLiteralLikeArgument*/ false) && node.parent.arguments[0] === node || + ts.isImportCall(node.parent) && node.parent.arguments[0] === node); + } + ts.isModuleSpecifierLike = isModuleSpecifierLike; function isObjectBindingElementWithoutPropertyName(bindingElement) { return ts.isBindingElement(bindingElement) && ts.isObjectBindingPattern(bindingElement.parent) && @@ -116898,7 +120895,7 @@ var ts; ts.findModifier = findModifier; function insertImports(changes, sourceFile, imports, blankLineBetween) { var decl = ts.isArray(imports) ? imports[0] : imports; - var importKindPredicate = decl.kind === 232 /* VariableStatement */ ? ts.isRequireVariableStatement : ts.isAnyImportSyntax; + var importKindPredicate = decl.kind === 234 /* 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) { @@ -116976,7 +120973,7 @@ var ts; // Display-part writer helpers // #region function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 160 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 162 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -117024,7 +121021,7 @@ var ts; increaseIndent: function () { indent++; }, decreaseIndent: function () { indent--; }, clear: resetWriter, - trackSymbol: ts.noop, + trackSymbol: function () { return false; }, reportInaccessibleThisError: ts.noop, reportInaccessibleUniqueSymbolError: ts.noop, reportPrivateInBaseOfClassExpression: ts.noop, @@ -117139,6 +121136,14 @@ var ts; return displayPart(ts.tokenToString(kind), ts.SymbolDisplayPartKind.operator); } ts.operatorPart = operatorPart; + function parameterNamePart(text) { + return displayPart(text, ts.SymbolDisplayPartKind.parameterName); + } + ts.parameterNamePart = parameterNamePart; + function propertyNamePart(text) { + return displayPart(text, ts.SymbolDisplayPartKind.propertyName); + } + ts.propertyNamePart = propertyNamePart; function textOrKeywordPart(text) { var kind = ts.stringToToken(text); return kind === undefined @@ -117150,6 +121155,61 @@ var ts; return displayPart(text, ts.SymbolDisplayPartKind.text); } ts.textPart = textPart; + function typeAliasNamePart(text) { + return displayPart(text, ts.SymbolDisplayPartKind.aliasName); + } + ts.typeAliasNamePart = typeAliasNamePart; + function typeParameterNamePart(text) { + return displayPart(text, ts.SymbolDisplayPartKind.typeParameterName); + } + ts.typeParameterNamePart = typeParameterNamePart; + function linkTextPart(text) { + return displayPart(text, ts.SymbolDisplayPartKind.linkText); + } + ts.linkTextPart = linkTextPart; + function linkNamePart(name, target) { + return { + text: ts.getTextOfNode(name), + kind: ts.SymbolDisplayPartKind[ts.SymbolDisplayPartKind.linkName], + target: { + fileName: ts.getSourceFileOfNode(target).fileName, + textSpan: createTextSpanFromNode(target), + }, + }; + } + ts.linkNamePart = linkNamePart; + function linkPart(text) { + return displayPart(text, ts.SymbolDisplayPartKind.link); + } + ts.linkPart = linkPart; + function buildLinkParts(link, checker) { + var _a; + var prefix = ts.isJSDocLink(link) ? "link" + : ts.isJSDocLinkCode(link) ? "linkcode" + : "linkplain"; + var parts = [linkPart("{@" + prefix + " ")]; + if (!link.name) { + if (link.text) { + parts.push(linkTextPart(link.text)); + } + } + else { + var symbol = checker === null || checker === void 0 ? void 0 : checker.getSymbolAtLocation(link.name); + var decl = (symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration) || ((_a = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]); + if (decl) { + parts.push(linkNamePart(link.name, decl)); + if (link.text) { + parts.push(linkTextPart(link.text)); + } + } + else { + parts.push(linkTextPart(ts.getTextOfNode(link.name) + " " + link.text)); + } + } + parts.push(linkPart("}")); + return parts; + } + ts.buildLinkParts = buildLinkParts; var carriageReturnLineFeed = "\r\n"; /** * The default is CRLF. @@ -117435,21 +121495,23 @@ var ts; } /* @internal */ function needsParentheses(expression) { - return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 27 /* CommaToken */ || ts.isObjectLiteralExpression(expression); + return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 27 /* CommaToken */ + || ts.isObjectLiteralExpression(expression) + || ts.isAsExpression(expression) && ts.isObjectLiteralExpression(expression.expression); } ts.needsParentheses = needsParentheses; function getContextualTypeFromParent(node, checker) { var parent = node.parent; switch (parent.kind) { - case 204 /* NewExpression */: + case 206 /* NewExpression */: return checker.getContextualType(parent); - case 216 /* BinaryExpression */: { + case 218 /* 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 284 /* CaseClause */: + case 286 /* CaseClause */: return parent.expression === node ? getSwitchedType(parent, checker) : undefined; default: return checker.getContextualType(node); @@ -117460,7 +121522,7 @@ 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("'", "\\'").replace('\\"', '"') + "'" : quoted; + return quotePreference === 0 /* Single */ ? "'" + ts.stripQuotes(quoted).replace(/'/g, "\\'").replace(/\\"/g, '"') + "'" : quoted; } ts.quote = quote; function isEqualityOperatorKind(kind) { @@ -117479,8 +121541,8 @@ var ts; switch (node.kind) { case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 218 /* TemplateExpression */: - case 205 /* TaggedTemplateExpression */: + case 220 /* TemplateExpression */: + case 207 /* TaggedTemplateExpression */: return true; default: return false; @@ -117503,6 +121565,7 @@ var ts; var res = checker.typeToTypeNode(type, enclosingScope, 1 /* NoTruncation */, { trackSymbol: function (symbol, declaration, meaning) { typeIsAccessible = typeIsAccessible && checker.isSymbolAccessible(symbol, declaration, meaning, /*shouldComputeAliasToMarkVisible*/ false).accessibility === 0 /* Accessible */; + return !typeIsAccessible; }, reportInaccessibleThisError: notAccessible, reportPrivateInBaseOfClassExpression: notAccessible, @@ -117513,41 +121576,41 @@ var ts; } ts.getTypeNodeIfAccessible = getTypeNodeIfAccessible; function syntaxRequiresTrailingCommaOrSemicolonOrASI(kind) { - return kind === 169 /* CallSignature */ - || kind === 170 /* ConstructSignature */ - || kind === 171 /* IndexSignature */ - || kind === 162 /* PropertySignature */ - || kind === 164 /* MethodSignature */; + return kind === 171 /* CallSignature */ + || kind === 172 /* ConstructSignature */ + || kind === 173 /* IndexSignature */ + || kind === 164 /* PropertySignature */ + || kind === 166 /* MethodSignature */; } ts.syntaxRequiresTrailingCommaOrSemicolonOrASI = syntaxRequiresTrailingCommaOrSemicolonOrASI; function syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI(kind) { - return kind === 251 /* FunctionDeclaration */ - || kind === 166 /* Constructor */ - || kind === 165 /* MethodDeclaration */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */; + return kind === 253 /* FunctionDeclaration */ + || kind === 168 /* Constructor */ + || kind === 167 /* MethodDeclaration */ + || kind === 169 /* GetAccessor */ + || kind === 170 /* SetAccessor */; } ts.syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI = syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI; function syntaxRequiresTrailingModuleBlockOrSemicolonOrASI(kind) { - return kind === 256 /* ModuleDeclaration */; + return kind === 258 /* ModuleDeclaration */; } ts.syntaxRequiresTrailingModuleBlockOrSemicolonOrASI = syntaxRequiresTrailingModuleBlockOrSemicolonOrASI; function syntaxRequiresTrailingSemicolonOrASI(kind) { - return kind === 232 /* VariableStatement */ - || kind === 233 /* ExpressionStatement */ - || kind === 235 /* DoStatement */ - || kind === 240 /* ContinueStatement */ - || kind === 241 /* BreakStatement */ - || kind === 242 /* ReturnStatement */ - || kind === 246 /* ThrowStatement */ - || kind === 248 /* DebuggerStatement */ - || kind === 163 /* PropertyDeclaration */ - || kind === 254 /* TypeAliasDeclaration */ - || kind === 261 /* ImportDeclaration */ - || kind === 260 /* ImportEqualsDeclaration */ - || kind === 267 /* ExportDeclaration */ - || kind === 259 /* NamespaceExportDeclaration */ - || kind === 266 /* ExportAssignment */; + return kind === 234 /* VariableStatement */ + || kind === 235 /* ExpressionStatement */ + || kind === 237 /* DoStatement */ + || kind === 242 /* ContinueStatement */ + || kind === 243 /* BreakStatement */ + || kind === 244 /* ReturnStatement */ + || kind === 248 /* ThrowStatement */ + || kind === 250 /* DebuggerStatement */ + || kind === 165 /* PropertyDeclaration */ + || kind === 256 /* TypeAliasDeclaration */ + || kind === 263 /* ImportDeclaration */ + || kind === 262 /* ImportEqualsDeclaration */ + || kind === 269 /* ExportDeclaration */ + || kind === 261 /* NamespaceExportDeclaration */ + || kind === 268 /* ExportAssignment */; } ts.syntaxRequiresTrailingSemicolonOrASI = syntaxRequiresTrailingSemicolonOrASI; ts.syntaxMayBeASICandidate = ts.or(syntaxRequiresTrailingCommaOrSemicolonOrASI, syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI, syntaxRequiresTrailingModuleBlockOrSemicolonOrASI, syntaxRequiresTrailingSemicolonOrASI); @@ -117577,7 +121640,7 @@ var ts; return false; } // See comment in parser’s `parseDoStatement` - if (node.kind === 235 /* DoStatement */) { + if (node.kind === 237 /* DoStatement */) { return true; } var topNode = ts.findAncestor(node, function (ancestor) { return !ancestor.parent; }); @@ -117751,6 +121814,94 @@ var ts; } } ts.createPackageJsonInfo = createPackageJsonInfo; + function createPackageJsonImportFilter(fromFile, host) { + var packageJsons = ((host.getPackageJsonsVisibleToFile && host.getPackageJsonsVisibleToFile(fromFile.fileName)) || getPackageJsonsVisibleToFile(fromFile.fileName, host)).filter(function (p) { return p.parseable; }); + var usesNodeCoreModules; + return { allowsImportingAmbientModule: allowsImportingAmbientModule, allowsImportingSourceFile: allowsImportingSourceFile, allowsImportingSpecifier: allowsImportingSpecifier }; + function moduleSpecifierIsCoveredByPackageJson(specifier) { + var packageName = getNodeModuleRootSpecifier(specifier); + for (var _i = 0, packageJsons_1 = packageJsons; _i < packageJsons_1.length; _i++) { + var packageJson = packageJsons_1[_i]; + if (packageJson.has(packageName) || packageJson.has(ts.getTypesPackageName(packageName))) { + return true; + } + } + return false; + } + function allowsImportingAmbientModule(moduleSymbol, moduleSpecifierResolutionHost) { + if (!packageJsons.length || !moduleSymbol.valueDeclaration) { + return true; + } + var declaringSourceFile = moduleSymbol.valueDeclaration.getSourceFile(); + var declaringNodeModuleName = getNodeModulesPackageNameFromFileName(declaringSourceFile.fileName, moduleSpecifierResolutionHost); + if (typeof declaringNodeModuleName === "undefined") { + return true; + } + var declaredModuleSpecifier = ts.stripQuotes(moduleSymbol.getName()); + if (isAllowedCoreNodeModulesImport(declaredModuleSpecifier)) { + return true; + } + return moduleSpecifierIsCoveredByPackageJson(declaringNodeModuleName) + || moduleSpecifierIsCoveredByPackageJson(declaredModuleSpecifier); + } + function allowsImportingSourceFile(sourceFile, moduleSpecifierResolutionHost) { + if (!packageJsons.length) { + return true; + } + var moduleSpecifier = getNodeModulesPackageNameFromFileName(sourceFile.fileName, moduleSpecifierResolutionHost); + if (!moduleSpecifier) { + return true; + } + return moduleSpecifierIsCoveredByPackageJson(moduleSpecifier); + } + function allowsImportingSpecifier(moduleSpecifier) { + if (!packageJsons.length || isAllowedCoreNodeModulesImport(moduleSpecifier)) { + return true; + } + if (ts.pathIsRelative(moduleSpecifier) || ts.isRootedDiskPath(moduleSpecifier)) { + return true; + } + return moduleSpecifierIsCoveredByPackageJson(moduleSpecifier); + } + function isAllowedCoreNodeModulesImport(moduleSpecifier) { + // If we’re in JavaScript, it can be difficult to tell whether the user wants to import + // from Node core modules or not. We can start by seeing if the user is actually using + // any node core modules, as opposed to simply having @types/node accidentally as a + // dependency of a dependency. + if (ts.isSourceFileJS(fromFile) && ts.JsTyping.nodeCoreModules.has(moduleSpecifier)) { + if (usesNodeCoreModules === undefined) { + usesNodeCoreModules = consumesNodeCoreModules(fromFile); + } + if (usesNodeCoreModules) { + return true; + } + } + return false; + } + function getNodeModulesPackageNameFromFileName(importedFileName, moduleSpecifierResolutionHost) { + if (!ts.stringContains(importedFileName, "node_modules")) { + return undefined; + } + var specifier = ts.moduleSpecifiers.getNodeModulesPackageName(host.getCompilationSettings(), fromFile.path, importedFileName, moduleSpecifierResolutionHost); + if (!specifier) { + return undefined; + } + // Paths here are not node_modules, so we don’t care about them; + // returning anything will trigger a lookup in package.json. + if (!ts.pathIsRelative(specifier) && !ts.isRootedDiskPath(specifier)) { + return getNodeModuleRootSpecifier(specifier); + } + } + function getNodeModuleRootSpecifier(fullSpecifier) { + var components = ts.getPathComponents(ts.getPackageNameFromTypesPackageName(fullSpecifier)).slice(1); + // Scoped packages + if (ts.startsWith(components[0], "@")) { + return components[0] + "/" + components[1]; + } + return components[0]; + } + } + ts.createPackageJsonImportFilter = createPackageJsonImportFilter; function tryParseJson(text) { try { return JSON.parse(text); @@ -117827,9 +121978,9 @@ var ts; } ts.firstOrOnly = firstOrOnly; function getNameForExportedSymbol(symbol, scriptTarget) { - if (symbol.escapedName === "export=" /* ExportEquals */ || symbol.escapedName === "default" /* Default */) { + if (!(symbol.flags & 33554432 /* Transient */) && (symbol.escapedName === "export=" /* ExportEquals */ || symbol.escapedName === "default" /* Default */)) { // Name of "export default foo;" is "foo". Name of "export default 0" is the filename converted to camelCase. - return ts.firstDefined(symbol.declarations, function (d) { return ts.isExportAssignment(d) && ts.isIdentifier(d.expression) ? d.expression.text : undefined; }) + 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; }) || ts.codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget); } return symbol.name; @@ -117893,6 +122044,188 @@ var ts; return ts.isInJSFile(declaration) || !ts.findAncestor(declaration, ts.isGlobalScopeAugmentation); } ts.isNonGlobalDeclaration = isNonGlobalDeclaration; + var ImportKind; + (function (ImportKind) { + ImportKind[ImportKind["Named"] = 0] = "Named"; + ImportKind[ImportKind["Default"] = 1] = "Default"; + ImportKind[ImportKind["Namespace"] = 2] = "Namespace"; + ImportKind[ImportKind["CommonJS"] = 3] = "CommonJS"; + })(ImportKind = ts.ImportKind || (ts.ImportKind = {})); + var ExportKind; + (function (ExportKind) { + ExportKind[ExportKind["Named"] = 0] = "Named"; + ExportKind[ExportKind["Default"] = 1] = "Default"; + ExportKind[ExportKind["ExportEquals"] = 2] = "ExportEquals"; + ExportKind[ExportKind["UMD"] = 3] = "UMD"; + })(ExportKind = ts.ExportKind || (ts.ExportKind = {})); + function createExportMapCache() { + var cache; + var projectVersion; + var usableByFileName; + var wrapped = { + isEmpty: function () { + return !cache; + }, + clear: function () { + cache = undefined; + projectVersion = undefined; + }, + set: function (suggestions, version) { + cache = suggestions; + if (version) { + projectVersion = version; + } + }, + get: function (file, checker, version) { + if (usableByFileName && file !== usableByFileName) { + return undefined; + } + if (version && projectVersion === version) { + return cache; + } + cache === null || cache === void 0 ? void 0 : cache.forEach(function (infos) { + var _a, _b, _c; + for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) { + var info = infos_1[_i]; + // If the symbol/moduleSymbol was a merged symbol, it will have a new identity + // in the checker, even though the symbols to merge are the same (guaranteed by + // cache invalidation in synchronizeHostData). + if ((_a = info.symbol.declarations) === null || _a === void 0 ? void 0 : _a.length) { + info.symbol = checker.getMergedSymbol(info.exportKind === 1 /* Default */ + ? (_b = info.symbol.declarations[0].localSymbol) !== null && _b !== void 0 ? _b : info.symbol.declarations[0].symbol + : info.symbol.declarations[0].symbol); + } + if ((_c = info.moduleSymbol.declarations) === null || _c === void 0 ? void 0 : _c.length) { + info.moduleSymbol = checker.getMergedSymbol(info.moduleSymbol.declarations[0].symbol); + } + } + }); + return cache; + }, + onFileChanged: function (oldSourceFile, newSourceFile, typeAcquisitionEnabled) { + if (fileIsGlobalOnly(oldSourceFile) && fileIsGlobalOnly(newSourceFile)) { + // File is purely global; doesn't affect export map + return false; + } + if (usableByFileName && usableByFileName !== newSourceFile.path || + // If ATA is enabled, auto-imports uses existing imports to guess whether you want auto-imports from node. + // Adding or removing imports from node could change the outcome of that guess, so could change the suggestions list. + typeAcquisitionEnabled && consumesNodeCoreModules(oldSourceFile) !== consumesNodeCoreModules(newSourceFile) || + // Module agumentation and ambient module changes can add or remove exports available to be auto-imported. + // Changes elsewhere in the file can change the *type* of an export in a module augmentation, + // but type info is gathered in getCompletionEntryDetails, which doesn’t use the cache. + !ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations) || + !ambientModuleDeclarationsAreEqual(oldSourceFile, newSourceFile)) { + this.clear(); + return true; + } + usableByFileName = newSourceFile.path; + return false; + }, + }; + if (ts.Debug.isDebugging) { + Object.defineProperty(wrapped, "__cache", { get: function () { return cache; } }); + } + return wrapped; + function fileIsGlobalOnly(file) { + return !file.commonJsModuleIndicator && !file.externalModuleIndicator && !file.moduleAugmentations && !file.ambientModuleNames; + } + function ambientModuleDeclarationsAreEqual(oldSourceFile, newSourceFile) { + if (!ts.arrayIsEqualTo(oldSourceFile.ambientModuleNames, newSourceFile.ambientModuleNames)) { + return false; + } + var oldFileStatementIndex = -1; + var newFileStatementIndex = -1; + var _loop_1 = function (ambientModuleName) { + var isMatchingModuleDeclaration = function (node) { return ts.isNonGlobalAmbientModule(node) && node.name.text === ambientModuleName; }; + oldFileStatementIndex = ts.findIndex(oldSourceFile.statements, isMatchingModuleDeclaration, oldFileStatementIndex + 1); + newFileStatementIndex = ts.findIndex(newSourceFile.statements, isMatchingModuleDeclaration, newFileStatementIndex + 1); + if (oldSourceFile.statements[oldFileStatementIndex] !== newSourceFile.statements[newFileStatementIndex]) { + return { value: false }; + } + }; + for (var _i = 0, _a = newSourceFile.ambientModuleNames; _i < _a.length; _i++) { + var ambientModuleName = _a[_i]; + var state_1 = _loop_1(ambientModuleName); + if (typeof state_1 === "object") + return state_1.value; + } + return true; + } + } + ts.createExportMapCache = createExportMapCache; + function createModuleSpecifierCache() { + var cache; + var importingFileName; + var wrapped = { + get: function (fromFileName, toFileName) { + if (!cache || fromFileName !== importingFileName) + return undefined; + return cache.get(toFileName); + }, + set: function (fromFileName, toFileName, moduleSpecifiers) { + if (cache && fromFileName !== importingFileName) { + cache.clear(); + } + importingFileName = fromFileName; + (cache || (cache = new ts.Map())).set(toFileName, moduleSpecifiers); + }, + clear: function () { + cache = undefined; + importingFileName = undefined; + }, + count: function () { + return cache ? cache.size : 0; + } + }; + if (ts.Debug.isDebugging) { + Object.defineProperty(wrapped, "__cache", { get: function () { return cache; } }); + } + return wrapped; + } + ts.createModuleSpecifierCache = createModuleSpecifierCache; + function isImportableFile(program, from, to, packageJsonFilter, moduleSpecifierResolutionHost, moduleSpecifierCache) { + var _a; + if (from === to) + return false; + var cachedResult = moduleSpecifierCache === null || moduleSpecifierCache === void 0 ? void 0 : moduleSpecifierCache.get(from.path, to.path); + if (cachedResult !== undefined) { + return !!cachedResult; + } + var getCanonicalFileName = ts.hostGetCanonicalFileName(moduleSpecifierResolutionHost); + var globalTypingsCache = (_a = moduleSpecifierResolutionHost.getGlobalTypingsCacheLocation) === null || _a === void 0 ? void 0 : _a.call(moduleSpecifierResolutionHost); + var hasImportablePath = !!ts.moduleSpecifiers.forEachFileNameOfModule(from.fileName, to.fileName, moduleSpecifierResolutionHost, + /*preferSymlinks*/ false, function (toPath) { + var toFile = program.getSourceFile(toPath); + // Determine to import using toPath only if toPath is what we were looking at + // or there doesnt exist the file in the program by the symlink + return (toFile === to || !toFile) && + isImportablePath(from.fileName, toPath, getCanonicalFileName, globalTypingsCache); + }); + if (packageJsonFilter) { + var isImportable = hasImportablePath && packageJsonFilter.allowsImportingSourceFile(to, moduleSpecifierResolutionHost); + moduleSpecifierCache === null || moduleSpecifierCache === void 0 ? void 0 : moduleSpecifierCache.set(from.path, to.path, isImportable); + return isImportable; + } + return hasImportablePath; + } + ts.isImportableFile = isImportableFile; + /** + * Don't include something from a `node_modules` that isn't actually reachable by a global import. + * A relative import to node_modules is usually a bad idea. + */ + function isImportablePath(fromPath, toPath, getCanonicalFileName, globalCachePath) { + // If it's in a `node_modules` but is not reachable from here via a global import, don't bother. + var toNodeModules = ts.forEachAncestorDirectory(toPath, function (ancestor) { return ts.getBaseFileName(ancestor) === "node_modules" ? ancestor : undefined; }); + var toNodeModulesParent = toNodeModules && ts.getDirectoryPath(getCanonicalFileName(toNodeModules)); + return toNodeModulesParent === undefined + || ts.startsWith(getCanonicalFileName(fromPath), toNodeModulesParent) + || (!!globalCachePath && ts.startsWith(getCanonicalFileName(globalCachePath), toNodeModulesParent)); + } + function isDeprecatedDeclaration(decl) { + return !!(ts.getCombinedNodeFlagsAlwaysIncludeJSDoc(decl) & 8192 /* Deprecated */); + } + ts.isDeprecatedDeclaration = isDeprecatedDeclaration; // #endregion })(ts || (ts = {})); var ts; @@ -117976,13 +122309,13 @@ var ts; function handleToken() { switch (token) { case 43 /* SlashToken */: - case 67 /* SlashEqualsToken */: + case 68 /* SlashEqualsToken */: if (!noRegexTable[lastNonTriviaToken] && scanner.reScanSlashToken() === 13 /* RegularExpressionLiteral */) { token = 13 /* RegularExpressionLiteral */; } break; case 29 /* LessThanToken */: - if (lastNonTriviaToken === 78 /* Identifier */) { + if (lastNonTriviaToken === 79 /* 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++; @@ -117995,16 +122328,16 @@ var ts; angleBracketStack--; } break; - case 128 /* AnyKeyword */: - case 147 /* StringKeyword */: - case 144 /* NumberKeyword */: - case 131 /* BooleanKeyword */: - case 148 /* SymbolKeyword */: + case 129 /* AnyKeyword */: + case 148 /* StringKeyword */: + case 145 /* NumberKeyword */: + case 132 /* BooleanKeyword */: + case 149 /* 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 = 78 /* Identifier */; + token = 79 /* Identifier */; } break; case 15 /* TemplateHead */: @@ -118043,14 +122376,14 @@ var ts; break; } if (lastNonTriviaToken === 24 /* DotToken */) { - token = 78 /* Identifier */; + token = 79 /* 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 = 78 /* Identifier */; + token = 79 /* Identifier */; } } } @@ -118064,19 +122397,19 @@ 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([ - 78 /* Identifier */, + 79 /* Identifier */, 10 /* StringLiteral */, 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 13 /* RegularExpressionLiteral */, - 107 /* ThisKeyword */, + 108 /* ThisKeyword */, 45 /* PlusPlusToken */, 46 /* MinusMinusToken */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 19 /* CloseBraceToken */, - 109 /* TrueKeyword */, - 94 /* FalseKeyword */, + 110 /* TrueKeyword */, + 95 /* FalseKeyword */, ], function (token) { return token; }, function () { return true; }); function getNewEndOfLineState(scanner, token, lastOnTemplateStack) { switch (token) { @@ -118188,10 +122521,10 @@ var ts; return true; } switch (keyword2) { - case 134 /* GetKeyword */: - case 146 /* SetKeyword */: - case 132 /* ConstructorKeyword */: - case 123 /* StaticKeyword */: + case 135 /* GetKeyword */: + case 147 /* SetKeyword */: + case 133 /* ConstructorKeyword */: + case 124 /* 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. @@ -118236,9 +122569,9 @@ var ts; case 31 /* GreaterThanToken */: case 32 /* LessThanEqualsToken */: case 33 /* GreaterThanEqualsToken */: - case 101 /* InstanceOfKeyword */: - case 100 /* InKeyword */: - case 126 /* AsKeyword */: + case 102 /* InstanceOfKeyword */: + case 101 /* InKeyword */: + case 127 /* AsKeyword */: case 34 /* EqualsEqualsToken */: case 35 /* ExclamationEqualsToken */: case 36 /* EqualsEqualsEqualsToken */: @@ -118248,23 +122581,23 @@ var ts; case 51 /* BarToken */: case 55 /* AmpersandAmpersandToken */: case 56 /* BarBarToken */: - case 73 /* BarEqualsToken */: - case 72 /* AmpersandEqualsToken */: - case 77 /* CaretEqualsToken */: - case 69 /* LessThanLessThanEqualsToken */: - case 70 /* GreaterThanGreaterThanEqualsToken */: - case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 63 /* PlusEqualsToken */: - case 64 /* MinusEqualsToken */: - case 65 /* AsteriskEqualsToken */: - case 67 /* SlashEqualsToken */: - case 68 /* PercentEqualsToken */: - case 62 /* EqualsToken */: + 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 74 /* BarBarEqualsToken */: - case 75 /* AmpersandAmpersandEqualsToken */: - case 76 /* QuestionQuestionEqualsToken */: + case 75 /* BarBarEqualsToken */: + case 76 /* AmpersandAmpersandEqualsToken */: + case 77 /* QuestionQuestionEqualsToken */: return true; default: return false; @@ -118290,7 +122623,7 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5 /* operator */; } - else if (token >= 18 /* FirstPunctuation */ && token <= 77 /* LastPunctuation */) { + else if (token >= 18 /* FirstPunctuation */ && token <= 78 /* LastPunctuation */) { return 10 /* punctuation */; } switch (token) { @@ -118309,7 +122642,7 @@ var ts; case 5 /* WhitespaceTrivia */: case 4 /* NewLineTrivia */: return 8 /* whiteSpace */; - case 78 /* Identifier */: + case 79 /* Identifier */: default: if (ts.isTemplateLiteralKind(token)) { return 6 /* stringLiteral */; @@ -118334,13 +122667,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 256 /* ModuleDeclaration */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 251 /* FunctionDeclaration */: - case 221 /* ClassExpression */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 258 /* ModuleDeclaration */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 253 /* FunctionDeclaration */: + case 223 /* ClassExpression */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } } @@ -118547,10 +122880,11 @@ var ts; pushClassification(start, width, 1 /* comment */); } function classifyJSDocComment(docComment) { + var _a, _b, _c, _d, _e, _f, _g; var pos = docComment.pos; if (docComment.tags) { - for (var _i = 0, _a = docComment.tags; _i < _a.length; _i++) { - var tag = _a[_i]; + for (var _i = 0, _h = docComment.tags; _i < _h.length; _i++) { + var tag = _h[_i]; // As we walk through each tag, classify the portion of text from the end of // the last tag (or the start of the entire doc comment) as 'comment'. if (tag.pos !== pos) { @@ -118559,22 +122893,56 @@ var ts; pushClassification(tag.pos, 1, 10 /* punctuation */); // "@" pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); // e.g. "param" pos = tag.tagName.end; + var commentStart = tag.tagName.end; switch (tag.kind) { - case 326 /* JSDocParameterTag */: - processJSDocParameterTag(tag); + case 334 /* 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 341 /* JSDocPropertyTag */: + var prop = tag; + commentStart = prop.isNameFirst && ((_b = prop.typeExpression) === null || _b === void 0 ? void 0 : _b.end) || prop.name.end; break; - case 330 /* JSDocTemplateTag */: + case 338 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); pos = tag.end; + commentStart = tag.typeParameters.end; + break; + case 339 /* JSDocTypedefTag */: + var type = tag; + commentStart = ((_c = type.typeExpression) === null || _c === void 0 ? void 0 : _c.kind) === 303 /* 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 329 /* JSDocTypeTag */: + case 332 /* JSDocCallbackTag */: + commentStart = tag.typeExpression.end; + break; + case 337 /* JSDocTypeTag */: processElement(tag.typeExpression); pos = tag.end; + commentStart = tag.typeExpression.end; + break; + case 336 /* JSDocThisTag */: + case 333 /* JSDocEnumTag */: + commentStart = tag.typeExpression.end; break; - case 327 /* JSDocReturnTag */: + case 335 /* JSDocReturnTag */: processElement(tag.typeExpression); pos = tag.end; + commentStart = ((_f = tag.typeExpression) === null || _f === void 0 ? void 0 : _f.end) || commentStart; break; + case 340 /* JSDocSeeTag */: + commentStart = ((_g = tag.name) === null || _g === void 0 ? void 0 : _g.end) || commentStart; + break; + case 322 /* JSDocAugmentsTag */: + case 323 /* JSDocImplementsTag */: + commentStart = tag.class.end; + break; + } + if (typeof tag.comment === "object") { + pushCommentRange(tag.comment.pos, tag.comment.end - tag.comment.pos); + } + else if (typeof tag.comment === "string") { + pushCommentRange(commentStart, tag.end - commentStart); } } } @@ -118602,7 +122970,8 @@ var ts; } function tryClassifyTripleSlashComment(start, width) { var tripleSlashXMLCommentRegEx = /^(\/\/\/\s*)(<)(?:(\S+)((?:[^/]|\/[^>])*)(\/>)?)?/im; - var attributeRegex = /(\S+)(\s*)(=)(\s*)('[^']+'|"[^"]+")/img; + // Require a leading whitespace character (the parser already does) to prevent terrible backtracking performance + var attributeRegex = /(\s)(\S+)(\s*)(=)(\s*)('[^']+'|"[^"]+")/img; var text = sourceFile.text.substr(start, width); var match = tripleSlashXMLCommentRegEx.exec(text); if (!match) { @@ -118630,25 +122999,25 @@ var ts; if (!attrMatch) { break; } - var newAttrPos = pos + attrMatch.index; + var newAttrPos = pos + attrMatch.index + attrMatch[1].length; // whitespace if (newAttrPos > attrPos) { pushCommentRange(attrPos, newAttrPos - attrPos); attrPos = newAttrPos; } - pushClassification(attrPos, attrMatch[1].length, 22 /* jsxAttribute */); // attribute name - attrPos += attrMatch[1].length; - if (attrMatch[2].length) { - pushCommentRange(attrPos, attrMatch[2].length); // whitespace - attrPos += attrMatch[2].length; + pushClassification(attrPos, attrMatch[2].length, 22 /* jsxAttribute */); // attribute name + attrPos += attrMatch[2].length; + if (attrMatch[3].length) { + pushCommentRange(attrPos, attrMatch[3].length); // whitespace + attrPos += attrMatch[3].length; } - pushClassification(attrPos, attrMatch[3].length, 5 /* operator */); // = - attrPos += attrMatch[3].length; - if (attrMatch[4].length) { - pushCommentRange(attrPos, attrMatch[4].length); // whitespace - attrPos += attrMatch[4].length; + pushClassification(attrPos, attrMatch[4].length, 5 /* operator */); // = + attrPos += attrMatch[4].length; + if (attrMatch[5].length) { + pushCommentRange(attrPos, attrMatch[5].length); // whitespace + attrPos += attrMatch[5].length; } - pushClassification(attrPos, attrMatch[5].length, 24 /* jsxAttributeStringLiteralValue */); // attribute value - attrPos += attrMatch[5].length; + pushClassification(attrPos, attrMatch[6].length, 24 /* jsxAttributeStringLiteralValue */); // attribute value + attrPos += attrMatch[6].length; } pos += match[4].length; if (pos > attrPos) { @@ -118722,22 +123091,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 275 /* JsxOpeningElement */: + case 277 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 276 /* JsxClosingElement */: + case 278 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 274 /* JsxSelfClosingElement */: + case 276 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 280 /* JsxAttribute */: + case 282 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -118764,19 +123133,19 @@ var ts; if (ts.isPunctuation(tokenKind)) { if (token) { var parent = token.parent; - if (tokenKind === 62 /* EqualsToken */) { + if (tokenKind === 63 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (parent.kind === 249 /* VariableDeclaration */ || - parent.kind === 163 /* PropertyDeclaration */ || - parent.kind === 160 /* Parameter */ || - parent.kind === 280 /* JsxAttribute */) { + if (parent.kind === 251 /* VariableDeclaration */ || + parent.kind === 165 /* PropertyDeclaration */ || + parent.kind === 162 /* Parameter */ || + parent.kind === 282 /* JsxAttribute */) { return 5 /* operator */; } } - if (parent.kind === 216 /* BinaryExpression */ || - parent.kind === 214 /* PrefixUnaryExpression */ || - parent.kind === 215 /* PostfixUnaryExpression */ || - parent.kind === 217 /* ConditionalExpression */) { + if (parent.kind === 218 /* BinaryExpression */ || + parent.kind === 216 /* PrefixUnaryExpression */ || + parent.kind === 217 /* PostfixUnaryExpression */ || + parent.kind === 219 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -118789,7 +123158,7 @@ var ts; return 25 /* bigintLiteral */; } else if (tokenKind === 10 /* StringLiteral */) { - return token && token.parent.kind === 280 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + return token && token.parent.kind === 282 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } else if (tokenKind === 13 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. @@ -118802,35 +123171,35 @@ var ts; else if (tokenKind === 11 /* JsxText */) { return 23 /* jsxText */; } - else if (tokenKind === 78 /* Identifier */) { + else if (tokenKind === 79 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 159 /* TypeParameter */: + case 161 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 253 /* InterfaceDeclaration */: + case 255 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 160 /* Parameter */: + case 162 /* Parameter */: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; } @@ -118932,13 +123301,13 @@ var ts; var inJSXElement = false; function visit(node) { switch (node.kind) { - case 256 /* ModuleDeclaration */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 251 /* FunctionDeclaration */: - case 221 /* ClassExpression */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 258 /* ModuleDeclaration */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 253 /* FunctionDeclaration */: + case 223 /* ClassExpression */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } if (!node || !ts.textSpanIntersectsWith(span, node.pos, node.getFullWidth()) || node.getFullWidth() === 0) { @@ -119084,25 +123453,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([ - [249 /* VariableDeclaration */, 7 /* variable */], - [160 /* Parameter */, 6 /* parameter */], - [163 /* PropertyDeclaration */, 9 /* property */], - [256 /* ModuleDeclaration */, 3 /* namespace */], - [255 /* EnumDeclaration */, 1 /* enum */], - [291 /* EnumMember */, 8 /* enumMember */], - [252 /* ClassDeclaration */, 0 /* class */], - [165 /* MethodDeclaration */, 11 /* member */], - [251 /* FunctionDeclaration */, 10 /* function */], - [208 /* FunctionExpression */, 10 /* function */], - [164 /* MethodSignature */, 11 /* member */], - [167 /* GetAccessor */, 9 /* property */], - [168 /* SetAccessor */, 9 /* property */], - [162 /* PropertySignature */, 9 /* property */], - [253 /* InterfaceDeclaration */, 2 /* interface */], - [254 /* TypeAliasDeclaration */, 5 /* type */], - [159 /* TypeParameter */, 4 /* typeParameter */], - [288 /* PropertyAssignment */, 9 /* property */], - [289 /* ShorthandPropertyAssignment */, 9 /* property */] + [251 /* VariableDeclaration */, 7 /* variable */], + [162 /* Parameter */, 6 /* parameter */], + [165 /* PropertyDeclaration */, 9 /* property */], + [258 /* ModuleDeclaration */, 3 /* namespace */], + [257 /* EnumDeclaration */, 1 /* enum */], + [293 /* EnumMember */, 8 /* enumMember */], + [254 /* ClassDeclaration */, 0 /* class */], + [167 /* MethodDeclaration */, 11 /* member */], + [253 /* FunctionDeclaration */, 10 /* function */], + [210 /* FunctionExpression */, 10 /* function */], + [166 /* MethodSignature */, 11 /* member */], + [169 /* GetAccessor */, 9 /* property */], + [170 /* SetAccessor */, 9 /* property */], + [164 /* PropertySignature */, 9 /* property */], + [255 /* InterfaceDeclaration */, 2 /* interface */], + [256 /* TypeAliasDeclaration */, 5 /* type */], + [161 /* TypeParameter */, 4 /* typeParameter */], + [290 /* PropertyAssignment */, 9 /* property */], + [291 /* ShorthandPropertyAssignment */, 9 /* property */] ]); })(v2020 = classifier.v2020 || (classifier.v2020 = {})); })(classifier = ts.classifier || (ts.classifier = {})); @@ -119122,12 +123491,12 @@ var ts; if (ts.isInString(sourceFile, position, contextToken)) { if (!contextToken || !ts.isStringLiteralLike(contextToken)) return undefined; - var entries = getStringLiteralCompletionEntries(sourceFile, contextToken, position, checker, options, host); - return convertStringLiteralCompletions(entries, contextToken, sourceFile, checker, log, preferences); + var entries = getStringLiteralCompletionEntries(sourceFile, contextToken, position, checker, options, host, preferences); + return convertStringLiteralCompletions(entries, contextToken, sourceFile, checker, log, options, preferences); } } StringCompletions.getStringLiteralCompletions = getStringLiteralCompletions; - function convertStringLiteralCompletions(completion, contextToken, sourceFile, checker, log, preferences) { + function convertStringLiteralCompletions(completion, contextToken, sourceFile, checker, log, options, preferences) { if (completion === undefined) { return undefined; } @@ -119137,7 +123506,7 @@ var ts; return convertPathCompletions(completion.paths); case 1 /* Properties */: { var entries = []; - Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, sourceFile, sourceFile, checker, 99 /* ESNext */, log, 4 /* String */, preferences); // Target will not be used, so arbitrary + Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, sourceFile, sourceFile, checker, 99 /* ESNext */, log, 4 /* String */, preferences, options); // Target will not be used, so arbitrary return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: completion.hasIndexSignature, optionalReplacementSpan: optionalReplacementSpan, entries: entries }; } case 2 /* Types */: { @@ -119154,10 +123523,10 @@ var ts; return ts.Debug.assertNever(completion); } } - function getStringLiteralCompletionDetails(name, sourceFile, position, contextToken, checker, options, host, cancellationToken) { + function getStringLiteralCompletionDetails(name, sourceFile, position, contextToken, checker, options, host, cancellationToken, preferences) { if (!contextToken || !ts.isStringLiteralLike(contextToken)) return undefined; - var completions = getStringLiteralCompletionEntries(sourceFile, contextToken, position, checker, options, host); + var completions = getStringLiteralCompletionEntries(sourceFile, contextToken, position, checker, options, host, preferences); return completions && stringLiteralCompletionDetails(name, contextToken, completions, sourceFile, checker, cancellationToken); } StringCompletions.getStringLiteralCompletionDetails = getStringLiteralCompletionDetails; @@ -119206,13 +123575,13 @@ var ts; StringLiteralCompletionKind[StringLiteralCompletionKind["Properties"] = 1] = "Properties"; StringLiteralCompletionKind[StringLiteralCompletionKind["Types"] = 2] = "Types"; })(StringLiteralCompletionKind || (StringLiteralCompletionKind = {})); - function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host) { + function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host, preferences) { var parent = walkUpParentheses(node.parent); switch (parent.kind) { - case 191 /* LiteralType */: { + case 193 /* LiteralType */: { var grandParent = walkUpParentheses(parent.parent); switch (grandParent.kind) { - case 173 /* TypeReference */: { + case 175 /* TypeReference */: { var typeReference_1 = grandParent; var typeArgument = ts.findAncestor(parent, function (n) { return n.parent === typeReference_1; }); if (typeArgument) { @@ -119220,7 +123589,7 @@ var ts; } return undefined; } - case 189 /* IndexedAccessType */: + case 191 /* IndexedAccessType */: // Get all apparent property names // i.e. interface Foo { // foo: string; @@ -119232,9 +123601,9 @@ var ts; return undefined; } return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(objectType)); - case 195 /* ImportType */: - return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) }; - case 182 /* UnionType */: { + case 197 /* ImportType */: + return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) }; + case 184 /* UnionType */: { if (!ts.isTypeReferenceNode(grandParent.parent)) { return undefined; } @@ -119246,7 +123615,7 @@ var ts; return undefined; } } - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: if (ts.isObjectLiteralExpression(parent.parent) && parent.name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { @@ -119263,7 +123632,7 @@ var ts; return stringLiteralCompletionsForObjectLiteral(typeChecker, parent.parent); } return fromContextualType(); - case 202 /* ElementAccessExpression */: { + case 204 /* ElementAccessExpression */: { var _b = parent, expression = _b.expression, argumentExpression = _b.argumentExpression; if (node === ts.skipParentheses(argumentExpression)) { // Get all names of properties on the expression @@ -119276,8 +123645,8 @@ var ts; } return undefined; } - case 203 /* CallExpression */: - case 204 /* NewExpression */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: if (!ts.isRequireCall(parent, /*checkArgumentIsStringLiteralLike*/ false) && !ts.isImportCall(parent)) { var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(node, position, sourceFile); // Get string literal completions from specialized signatures of the target @@ -119286,16 +123655,16 @@ var ts; return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo, typeChecker) : fromContextualType(); } // falls through (is `require("")` or `import("")`) - case 261 /* ImportDeclaration */: - case 267 /* ExportDeclaration */: - case 272 /* ExternalModuleReference */: + case 263 /* ImportDeclaration */: + case 269 /* ExportDeclaration */: + case 274 /* 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) }; + return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) }; default: return fromContextualType(); } @@ -119307,9 +123676,9 @@ var ts; } function walkUpParentheses(node) { switch (node.kind) { - case 186 /* ParenthesizedType */: + case 188 /* ParenthesizedType */: return ts.walkUpParenthesizedTypes(node); - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return ts.walkUpParenthesizedExpressions(node); default: return node; @@ -119337,7 +123706,7 @@ var ts; function stringLiteralCompletionsFromProperties(type) { return type && { kind: 1 /* Properties */, - symbols: ts.filter(type.getApparentProperties(), function (prop) { return !(prop.valueDeclaration && ts.isPrivateIdentifierPropertyDeclaration(prop.valueDeclaration)); }), + symbols: ts.filter(type.getApparentProperties(), function (prop) { return !(prop.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(prop.valueDeclaration)); }), hasIndexSignature: ts.hasIndexSignature(type) }; } @@ -119375,23 +123744,23 @@ var ts; return Math.max(name.indexOf(ts.directorySeparator), name.indexOf(ts.altDirectorySeparator)) !== -1 ? { name: name, kind: kind, extension: extension, span: wholeSpan } : { name: name, kind: kind, extension: extension, span: span }; }); } - function getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) { - return addReplacementSpans(node.text, node.getStart(sourceFile) + 1, getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker)); + function getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) { + return addReplacementSpans(node.text, node.getStart(sourceFile) + 1, getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker, preferences)); } - function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker) { + function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker, preferences) { var literalValue = ts.normalizeSlashes(node.text); 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) + ? getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, preferences) : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, compilerOptions, host, typeChecker); } function getExtensionOptions(compilerOptions, includeExtensions) { if (includeExtensions === void 0) { includeExtensions = false; } return { extensions: getSupportedExtensionsForModuleResolution(compilerOptions), includeExtensions: includeExtensions }; } - function getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath) { - var extensionOptions = getExtensionOptions(compilerOptions); + function getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, preferences) { + var extensionOptions = getExtensionOptions(compilerOptions, preferences.importModuleSpecifierEnding === "js"); if (compilerOptions.rootDirs) { return getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, extensionOptions, compilerOptions, host, scriptPath); } @@ -119508,7 +123877,7 @@ var ts; continue; var patterns = paths[path]; if (patterns) { - var _loop_1 = function (name, kind, extension) { + var _loop_2 = function (name, kind, extension) { // Path mappings may provide a duplicate way to get to something we've already added, so don't add again. if (!result.some(function (entry) { return entry.name === name; })) { result.push(nameAndKind(name, kind, extension)); @@ -119516,7 +123885,7 @@ var ts; }; for (var _i = 0, _a = getCompletionsForPathMapping(path, patterns, fragment, baseDirectory, fileExtensions, host); _i < _a.length; _i++) { var _b = _a[_i], name = _b.name, kind = _b.kind, extension = _b.extension; - _loop_1(name, kind, extension); + _loop_2(name, kind, extension); } } } @@ -119551,7 +123920,7 @@ var ts; // (But do if we didn't find anything, e.g. 'package.json' missing.) var foundGlobal = false; if (fragmentDirectory === undefined) { - var _loop_2 = function (moduleName) { + 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)); @@ -119559,7 +123928,7 @@ var ts; }; for (var _b = 0, _c = enumerateNodeModulesVisibleToScript(host, scriptPath); _b < _c.length; _b++) { var moduleName = _c[_b]; - _loop_2(moduleName); + _loop_3(moduleName); } } if (!foundGlobal) { @@ -119594,8 +123963,8 @@ var ts; if (!host.readDirectory) { return undefined; } - var parsed = ts.hasZeroOrOneAsteriskCharacter(pattern) ? ts.tryParsePattern(pattern) : undefined; - if (!parsed) { + var parsed = ts.tryParsePattern(pattern); + if (parsed === undefined || ts.isString(parsed)) { return undefined; } // The prefix has two effective parts: the directory path and the base component after the filepath that is not a @@ -119782,7 +124151,26 @@ var ts; SortText["GlobalsOrKeywords"] = "5"; SortText["AutoImportSuggestions"] = "6"; SortText["JavascriptIdentifiers"] = "7"; + SortText["DeprecatedLocalDeclarationPriority"] = "8"; + SortText["DeprecatedLocationPriority"] = "9"; + SortText["DeprecatedOptionalMember"] = "10"; + SortText["DeprecatedMemberDeclaredBySpreadAssignment"] = "11"; + SortText["DeprecatedSuggestedClassMembers"] = "12"; + SortText["DeprecatedGlobalsOrKeywords"] = "13"; + SortText["DeprecatedAutoImportSuggestions"] = "14"; })(SortText = Completions.SortText || (Completions.SortText = {})); + var SortTextId; + (function (SortTextId) { + SortTextId[SortTextId["LocalDeclarationPriority"] = 0] = "LocalDeclarationPriority"; + SortTextId[SortTextId["LocationPriority"] = 1] = "LocationPriority"; + SortTextId[SortTextId["OptionalMember"] = 2] = "OptionalMember"; + SortTextId[SortTextId["MemberDeclaredBySpreadAssignment"] = 3] = "MemberDeclaredBySpreadAssignment"; + SortTextId[SortTextId["SuggestedClassMembers"] = 4] = "SuggestedClassMembers"; + SortTextId[SortTextId["GlobalsOrKeywords"] = 5] = "GlobalsOrKeywords"; + SortTextId[SortTextId["AutoImportSuggestions"] = 6] = "AutoImportSuggestions"; + })(SortTextId || (SortTextId = {})); + // for JavaScript identifiers since they are preferred over deprecated symbols + var DeprecatedSortTextStart = SortTextId.AutoImportSuggestions + 2; /** * Special values for `CompletionInfo['source']` used to disambiguate * completion items with the same `name`. (Each completion item must @@ -119806,6 +124194,7 @@ var ts; SymbolOriginInfoKind[SymbolOriginInfoKind["Export"] = 4] = "Export"; SymbolOriginInfoKind[SymbolOriginInfoKind["Promise"] = 8] = "Promise"; SymbolOriginInfoKind[SymbolOriginInfoKind["Nullable"] = 16] = "Nullable"; + SymbolOriginInfoKind[SymbolOriginInfoKind["ResolvedExport"] = 32] = "ResolvedExport"; SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberNoExport"] = 2] = "SymbolMemberNoExport"; SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberExport"] = 6] = "SymbolMemberExport"; })(SymbolOriginInfoKind || (SymbolOriginInfoKind = {})); @@ -119818,8 +124207,14 @@ var ts; function originIsExport(origin) { return !!(origin && origin.kind & 4 /* Export */); } + function originIsResolvedExport(origin) { + return !!(origin && origin.kind === 32 /* ResolvedExport */); + } + function originIncludesSymbolName(origin) { + return originIsExport(origin) || originIsResolvedExport(origin); + } function originIsPackageJsonImport(origin) { - return originIsExport(origin) && !!origin.isFromPackageJson; + return (originIsExport(origin) || originIsResolvedExport(origin)) && !!origin.isFromPackageJson; } function originIsPromise(origin) { return !!(origin.kind & 8 /* Promise */); @@ -119845,52 +124240,6 @@ var ts; GlobalsSearch[GlobalsSearch["Success"] = 1] = "Success"; GlobalsSearch[GlobalsSearch["Fail"] = 2] = "Fail"; })(GlobalsSearch || (GlobalsSearch = {})); - function createImportSuggestionsForFileCache() { - var cache; - var projectVersion; - var fileName; - return { - isEmpty: function () { - return !cache; - }, - clear: function () { - cache = undefined; - fileName = undefined; - projectVersion = undefined; - }, - set: function (file, suggestions, version) { - cache = suggestions; - fileName = file; - if (version) { - projectVersion = version; - } - }, - get: function (file, checker, version) { - if (file !== fileName) { - return undefined; - } - if (version) { - return projectVersion === version ? cache : undefined; - } - ts.forEach(cache, function (suggestion) { - var _a, _b, _c; - // If the symbol/moduleSymbol was a merged symbol, it will have a new identity - // in the checker, even though the symbols to merge are the same (guaranteed by - // cache invalidation in synchronizeHostData). - if ((_a = suggestion.symbol.declarations) === null || _a === void 0 ? void 0 : _a.length) { - suggestion.symbol = checker.getMergedSymbol(suggestion.origin.isDefaultExport - ? (_b = suggestion.symbol.declarations[0].localSymbol) !== null && _b !== void 0 ? _b : suggestion.symbol.declarations[0].symbol - : suggestion.symbol.declarations[0].symbol); - } - if ((_c = suggestion.origin.moduleSymbol.declarations) === null || _c === void 0 ? void 0 : _c.length) { - suggestion.origin.moduleSymbol = checker.getMergedSymbol(suggestion.origin.moduleSymbol.declarations[0].symbol); - } - }); - return cache; - }, - }; - } - Completions.createImportSuggestionsForFileCache = createImportSuggestionsForFileCache; function getCompletionsAtPosition(host, program, log, sourceFile, position, preferences, triggerCharacter) { var typeChecker = program.getTypeChecker(); var compilerOptions = program.getCompilerOptions(); @@ -119898,12 +124247,19 @@ var ts; if (triggerCharacter && !ts.isInString(sourceFile, position, contextToken) && !isValidTrigger(sourceFile, triggerCharacter, contextToken, position)) { return undefined; } + if (triggerCharacter === " ") { + // `isValidTrigger` ensures we are at `import |` + if (preferences.includeCompletionsForImportStatements && preferences.includeCompletionsWithInsertText) { + return { isGlobalCompletion: true, isMemberCompletion: false, isNewIdentifierLocation: true, isIncomplete: true, entries: [] }; + } + return undefined; + } var stringCompletions = Completions.StringCompletions.getStringLiteralCompletions(sourceFile, position, contextToken, typeChecker, compilerOptions, host, log, preferences); if (stringCompletions) { return stringCompletions; } if (contextToken && ts.isBreakOrContinueStatement(contextToken.parent) - && (contextToken.kind === 80 /* BreakKeyword */ || contextToken.kind === 85 /* ContinueKeyword */ || contextToken.kind === 78 /* Identifier */)) { + && (contextToken.kind === 81 /* BreakKeyword */ || contextToken.kind === 86 /* ContinueKeyword */ || contextToken.kind === 79 /* Identifier */)) { return getLabelCompletionAtPosition(contextToken.parent); } var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, preferences, /*detailsEntryId*/ undefined, host); @@ -119921,6 +124277,8 @@ var ts; return jsdocCompletionInfo(ts.JsDoc.getJSDocTagCompletions()); case 3 /* JsDocParameterName */: return jsdocCompletionInfo(ts.JsDoc.getJSDocParameterNameCompletions(completionData.tag)); + case 4 /* Keywords */: + return specificKeywordCompletionInfo(completionData.keywords); default: return ts.Debug.assertNever(completionData); } @@ -119929,33 +124287,36 @@ var ts; function jsdocCompletionInfo(entries) { return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: entries }; } + function specificKeywordCompletionInfo(keywords) { + return { + isGlobalCompletion: false, + isMemberCompletion: false, + isNewIdentifierLocation: false, + entries: keywords.map(function (k) { return ({ + name: ts.tokenToString(k), + kind: "keyword" /* keyword */, + kindModifiers: "" /* none */, + sortText: SortText.GlobalsOrKeywords, + }); }), + }; + } function getOptionalReplacementSpan(location) { // StringLiteralLike locations are handled separately in stringCompletions.ts - return (location === null || location === void 0 ? void 0 : location.kind) === 78 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined; + return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined; } function completionInfoFromData(sourceFile, typeChecker, compilerOptions, log, completionData, preferences) { - var symbols = completionData.symbols, 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, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextMap = completionData.symbolToSortTextMap; - if (location && location.parent && ts.isJsxClosingElement(location.parent)) { - // In the TypeScript JSX element, if such element is not defined. When users query for completion at closing tag, - // instead of simply giving unknown value, the completion will return the tag-name of an associated opening-element. - // For example: - // var x =
" with type any - // And at `
` (with a closing `>`), the completion list will contain "div". - var tagName = location.parent.parent.openingElement.tagName; - var hasClosingAngleBracket = !!ts.findChildOfKind(location.parent, 31 /* GreaterThanToken */, sourceFile); - var entry = { - name: tagName.getFullText(sourceFile) + (hasClosingAngleBracket ? "" : ">"), - kind: "class" /* classElement */, - kindModifiers: undefined, - sortText: SortText.LocationPriority, - }; - return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: false, optionalReplacementSpan: getOptionalReplacementSpan(location), entries: [entry] }; + var symbols = completionData.symbols, 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, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextIdMap = completionData.symbolToSortTextIdMap; + // Verify if the file is JSX language variant + if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) { + var completionInfo = getJsxClosingTagCompletion(location, sourceFile); + if (completionInfo) { + return completionInfo; + } } var entries = []; if (isUncheckedFile(sourceFile, compilerOptions)) { var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, - /* contextToken */ undefined, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, propertyAccessToConvert, completionData.isJsxIdentifierExpected, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap); + /* contextToken */ undefined, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap); getJSCompletionEntries(sourceFile, location.pos, uniqueNames, compilerOptions.target, entries); // TODO: GH#18217 } else { @@ -119963,7 +124324,7 @@ var ts; return undefined; } getCompletionEntriesFromSymbols(symbols, entries, - /* contextToken */ undefined, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, propertyAccessToConvert, completionData.isJsxIdentifierExpected, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap); + /* contextToken */ undefined, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap); } if (keywordFilters !== 0 /* None */) { var entryNames = new ts.Set(entries.map(function (e) { return e.name; })); @@ -119999,6 +124360,49 @@ var ts; return false; } } + function getJsxClosingTagCompletion(location, sourceFile) { + // We wanna walk up the tree till we find a JSX closing element + var jsxClosingElement = ts.findAncestor(location, function (node) { + switch (node.kind) { + case 278 /* JsxClosingElement */: + return true; + case 43 /* SlashToken */: + case 31 /* GreaterThanToken */: + case 79 /* Identifier */: + case 203 /* PropertyAccessExpression */: + return false; + default: + return "quit"; + } + }); + if (jsxClosingElement) { + // In the TypeScript JSX element, if such element is not defined. When users query for completion at closing tag, + // instead of simply giving unknown value, the completion will return the tag-name of an associated opening-element. + // For example: + // var x =
" with type any + // And at `
` (with a closing `>`), the completion list will contain "div". + // And at property access expressions ` ` the completion will + // return full closing tag with an optional replacement span + // For example: + // 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 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 */, + kindModifiers: undefined, + sortText: SortText.LocationPriority, + }; + return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: false, optionalReplacementSpan: replacementSpan, entries: [entry] }; + } + return; + } function getJSCompletionEntries(sourceFile, position, uniqueNames, target, entries) { ts.getNameTable(sourceFile).forEach(function (pos, name) { // Skip identifiers produced only from the current location @@ -120025,9 +124429,13 @@ var ts; function createCompletionEntryForLiteral(sourceFile, preferences, literal) { return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority }; } - function createCompletionEntry(symbol, sortText, contextToken, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, preferences) { + function createCompletionEntry(symbol, sortText, contextToken, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences) { + var _a; var insertText; var replacementSpan = ts.getReplacementSpanForContextToken(contextToken); + var data; + var isSnippet; + var sourceDisplay; var insertQuestionDot = origin && originIsNullableMember(origin); var useBraces = origin && originIsSymbolMember(origin) || needsConvertPropertyAccess; if (origin && originIsThisType(origin)) { @@ -120071,9 +124479,24 @@ var ts; insertText = needsConvertPropertyAccess ? "" + awaitText + insertText : "" + awaitText + (insertQuestionDot ? "?." : ".") + insertText; replacementSpan = ts.createTextSpanFromBounds(propertyAccessToConvert.getStart(sourceFile), propertyAccessToConvert.end); } + if (originIsResolvedExport(origin)) { + ts.Debug.assertIsDefined(importCompletionNode); + (_a = getInsertTextAndReplacementSpanForImportCompletion(name, importCompletionNode, origin, useSemicolons, options, preferences), insertText = _a.insertText, replacementSpan = _a.replacementSpan); + sourceDisplay = [ts.textPart(origin.moduleSpecifier)]; + isSnippet = preferences.includeCompletionsWithSnippetText ? true : undefined; + } if (insertText !== undefined && !preferences.includeCompletionsWithInsertText) { return undefined; } + if (originIsExport(origin) || originIsResolvedExport(origin)) { + data = { + exportName: origin.exportName, + fileName: origin.fileName, + ambientModuleName: origin.fileName ? undefined : ts.stripQuotes(origin.moduleSymbol.name), + isPackageJsonImport: origin.isFromPackageJson ? true : undefined, + moduleSpecifier: originIsResolvedExport(origin) ? origin.moduleSpecifier : undefined, + }; + } // TODO(drosen): Right now we just permit *all* semantic meanings when calling // 'getSymbolKind' which is permissible given that it is backwards compatible; but // really we should consider passing the meaning for the node so that we don't report @@ -120091,8 +124514,29 @@ var ts; isRecommended: isRecommendedCompletionMatch(symbol, recommendedCompletion, typeChecker) || undefined, insertText: insertText, replacementSpan: replacementSpan, + sourceDisplay: sourceDisplay, + isSnippet: isSnippet, isPackageJsonImport: originIsPackageJsonImport(origin) || undefined, - }; + isImportStatementCompletion: originIsResolvedExport(origin) || undefined, + data: data, + }; + } + function getInsertTextAndReplacementSpanForImportCompletion(name, importCompletionNode, origin, useSemicolons, options, preferences) { + var sourceFile = importCompletionNode.getSourceFile(); + var replacementSpan = ts.createTextSpanFromNode(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 tabStop = preferences.includeCompletionsWithSnippetText ? "$1" : ""; + var importKind = ts.codefix.getImportKind(sourceFile, exportKind, options); + var suffix = useSemicolons ? ";" : ""; + switch (importKind) { + case 3 /* CommonJS */: return { replacementSpan: replacementSpan, insertText: "import " + name + tabStop + " = require(" + quotedModuleSpecifier + ")" + suffix }; + case 1 /* Default */: return { replacementSpan: replacementSpan, insertText: "import " + name + tabStop + " from " + quotedModuleSpecifier + suffix }; + case 2 /* Namespace */: return { replacementSpan: replacementSpan, insertText: "import * as " + name + tabStop + " from " + quotedModuleSpecifier + suffix }; + case 0 /* Named */: return { replacementSpan: replacementSpan, insertText: "import { " + name + tabStop + " } from " + quotedModuleSpecifier + suffix }; + } } function quotePropertyName(sourceFile, preferences, name) { if (/^\d+$/.test(name)) { @@ -120108,29 +124552,34 @@ var ts; if (originIsExport(origin)) { return ts.stripQuotes(origin.moduleSymbol.name); } + if (originIsResolvedExport(origin)) { + return origin.moduleSpecifier; + } if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 1 /* ThisType */) { return CompletionSource.ThisProperty; } } - function getCompletionEntriesFromSymbols(symbols, entries, contextToken, location, sourceFile, typeChecker, target, log, kind, preferences, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap) { + function getCompletionEntriesFromSymbols(symbols, entries, contextToken, location, sourceFile, typeChecker, target, log, kind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap) { + var _a; var start = ts.timestamp(); + var variableDeclaration = getVariableDeclaration(location); + var useSemicolons = ts.probablyUsesSemicolons(sourceFile); // Tracks unique names. // Value is set to false for global variables or completions from external module exports, because we can have multiple of those; // true otherwise. Based on the order we add things we will always see locals first, then globals, then module exports. // So adding a completion for a local will prevent us from adding completions for external module exports sharing the same name. var uniques = new ts.Map(); - for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) { - var symbol = symbols_1[_i]; - var origin = symbolToOriginInfoMap ? symbolToOriginInfoMap[ts.getSymbolId(symbol)] : undefined; + for (var i = 0; i < symbols.length; i++) { + 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) { + if (!info || uniques.get(info.name) || kind === 1 /* Global */ && symbolToSortTextIdMap && !shouldIncludeSymbol(symbol, symbolToSortTextIdMap)) { continue; } var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess; - if (uniques.get(name)) { - continue; - } - var entry = createCompletionEntry(symbol, symbolToSortTextMap && symbolToSortTextMap[ts.getSymbolId(symbol)] || SortText.LocationPriority, contextToken, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, preferences); + var sortTextId = (_a = symbolToSortTextIdMap === null || symbolToSortTextIdMap === void 0 ? void 0 : symbolToSortTextIdMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : SortTextId.LocationPriority; + var sortText = (isDeprecated(symbol, typeChecker) ? DeprecatedSortTextStart + sortTextId : sortTextId).toString(); + var entry = createCompletionEntry(symbol, sortText, contextToken, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences); if (!entry) { continue; } @@ -120147,6 +124596,46 @@ var ts; has: function (name) { return uniques.has(name); }, add: function (name) { return uniques.set(name, true); }, }; + function shouldIncludeSymbol(symbol, symbolToSortTextIdMap) { + if (!ts.isSourceFile(location)) { + // export = /**/ here we want to get all meanings, so any symbol is ok + if (ts.isExportAssignment(location.parent)) { + return true; + } + // Filter out variables from their own initializers + // `const a = /* no 'a' here */` + if (variableDeclaration && symbol.valueDeclaration === variableDeclaration) { + return false; + } + // External modules can have global export declarations that will be + // available as global keywords in all scopes. But if the external module + // already has an explicit export and user only wants to user explicit + // module imports then the global keywords will be filtered out so auto + // import suggestions will win in the completion + var symbolOrigin = ts.skipAlias(symbol, typeChecker); + // We only want to filter out the global keywords + // Auto Imports are not available for scripts so this conditional is always false + if (!!sourceFile.externalModuleIndicator + && !compilerOptions.allowUmdGlobalAccess + && symbolToSortTextIdMap[ts.getSymbolId(symbol)] === SortTextId.GlobalsOrKeywords + && (symbolToSortTextIdMap[ts.getSymbolId(symbolOrigin)] === SortTextId.AutoImportSuggestions + || symbolToSortTextIdMap[ts.getSymbolId(symbolOrigin)] === SortTextId.LocationPriority)) { + return false; + } + // Continue with origin symbol + symbol = 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 !!(symbol.flags & 1920 /* Namespace */); + } + if (isTypeOnlyLocation) { + // It's a type, but you can reach it by namespace.type as well + return symbolCanBeReferencedAtTypeLocation(symbol, typeChecker); + } + } + // expressions are value space (which includes the value namespaces) + return !!(ts.getCombinedLocalAndExportSymbolFlags(symbol) & 111551 /* Value */); + } } Completions.getCompletionEntriesFromSymbols = getCompletionEntriesFromSymbols; function getLabelCompletionAtPosition(node) { @@ -120180,6 +124669,20 @@ var ts; return entries; } function getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host, preferences) { + if (entryId.data) { + var autoImport = getAutoImportSymbolFromCompletionEntryData(entryId.name, entryId.data, program, host); + if (autoImport) { + return { + type: "symbol", + symbol: autoImport.symbol, + location: ts.getTouchingPropertyName(sourceFile, position), + previousToken: ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined), + isJsxInitializer: false, + isTypeOnlyLocation: false, + origin: autoImport.origin, + }; + } + } var compilerOptions = program.getCompilerOptions(); var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId, host); if (!completionData) { @@ -120196,11 +124699,11 @@ var ts; // We don't need to perform character checks here because we're only comparing the // name against 'entryName' (which is known to be good), not building a new // completion entry. - return ts.firstDefined(symbols, function (symbol) { - var origin = symbolToOriginInfoMap[ts.getSymbolId(symbol)]; + return ts.firstDefined(symbols, function (symbol, index) { + var origin = symbolToOriginInfoMap[index]; var info = getCompletionEntryDisplayNameForSymbol(symbol, compilerOptions.target, origin, completionKind, completionData.isJsxIdentifierExpected); return info && info.name === entryId.name && getSourceFromOrigin(origin) === entryId.source - ? { type: "symbol", symbol: symbol, location: location, symbolToOriginInfoMap: symbolToOriginInfoMap, previousToken: previousToken, isJsxInitializer: isJsxInitializer, isTypeOnlyLocation: isTypeOnlyLocation } + ? { type: "symbol", symbol: symbol, location: location, origin: origin, previousToken: previousToken, isJsxInitializer: isJsxInitializer, isTypeOnlyLocation: isTypeOnlyLocation } : undefined; }) || { type: "none" }; } @@ -120210,7 +124713,7 @@ var ts; var name = entryId.name; var contextToken = ts.findPrecedingToken(position, sourceFile); if (ts.isInString(sourceFile, position, contextToken)) { - return Completions.StringCompletions.getStringLiteralCompletionDetails(name, sourceFile, position, contextToken, typeChecker, compilerOptions, host, cancellationToken); + return Completions.StringCompletions.getStringLiteralCompletionDetails(name, sourceFile, position, contextToken, typeChecker, compilerOptions, host, cancellationToken, preferences); } // Compute all the completion symbols again. var symbolCompletion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host, preferences); @@ -120224,13 +124727,15 @@ var ts; return ts.JsDoc.getJSDocTagCompletionDetails(name); case 3 /* JsDocParameterName */: return ts.JsDoc.getJSDocParameterNameCompletionDetails(name); + case 4 /* Keywords */: + return request.keywords.indexOf(ts.stringToToken(name)) > -1 ? createSimpleDetails(name, "keyword" /* keyword */, ts.SymbolDisplayPartKind.keyword) : undefined; default: return ts.Debug.assertNever(request); } } case "symbol": { - var symbol = symbolCompletion.symbol, location = symbolCompletion.location, symbolToOriginInfoMap = symbolCompletion.symbolToOriginInfoMap, previousToken = symbolCompletion.previousToken; - var _a = getCompletionEntryCodeActionsAndSourceDisplay(symbolToOriginInfoMap, symbol, program, typeChecker, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences), codeActions = _a.codeActions, sourceDisplay = _a.sourceDisplay; + var symbol = symbolCompletion.symbol, location = symbolCompletion.location, origin = symbolCompletion.origin, previousToken = symbolCompletion.previousToken; + var _a = getCompletionEntryCodeActionsAndSourceDisplay(origin, symbol, program, typeChecker, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, entryId.data), codeActions = _a.codeActions, sourceDisplay = _a.sourceDisplay; return createCompletionDetailsForSymbol(symbol, typeChecker, sourceFile, location, cancellationToken, codeActions, sourceDisplay); // TODO: GH#18217 } case "literal": { @@ -120256,15 +124761,17 @@ var ts; } Completions.createCompletionDetailsForSymbol = createCompletionDetailsForSymbol; function createCompletionDetails(name, kindModifiers, kind, displayParts, documentation, tags, codeActions, source) { - return { name: name, kindModifiers: kindModifiers, kind: kind, displayParts: displayParts, documentation: documentation, tags: tags, codeActions: codeActions, source: source }; + return { name: name, kindModifiers: kindModifiers, kind: kind, displayParts: displayParts, documentation: documentation, tags: tags, codeActions: codeActions, source: source, sourceDisplay: source }; } Completions.createCompletionDetails = createCompletionDetails; - function getCompletionEntryCodeActionsAndSourceDisplay(symbolToOriginInfoMap, symbol, program, checker, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences) { - var symbolOriginInfo = symbolToOriginInfoMap[ts.getSymbolId(symbol)]; - if (!symbolOriginInfo || !originIsExport(symbolOriginInfo)) { + function getCompletionEntryCodeActionsAndSourceDisplay(origin, symbol, program, checker, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, data) { + if (data === null || data === void 0 ? void 0 : data.moduleSpecifier) { + return { codeActions: undefined, sourceDisplay: [ts.textPart(data.moduleSpecifier)] }; + } + if (!origin || !originIsExport(origin)) { return { codeActions: undefined, sourceDisplay: undefined }; } - var moduleSymbol = symbolOriginInfo.moduleSymbol; + var moduleSymbol = origin.moduleSymbol; var exportedSymbol = checker.getMergedSymbol(ts.skipAlias(symbol.exportSymbol || symbol, checker)); var _a = ts.codefix.getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, ts.getNameForExportedSymbol(symbol, compilerOptions.target), host, program, formatContext, previousToken && ts.isIdentifier(previousToken) ? previousToken.getStart(sourceFile) : position, preferences), moduleSpecifier = _a.moduleSpecifier, codeAction = _a.codeAction; return { sourceDisplay: [ts.textPart(moduleSpecifier)], codeActions: [codeAction] }; @@ -120280,6 +124787,7 @@ var ts; CompletionDataKind[CompletionDataKind["JsDocTagName"] = 1] = "JsDocTagName"; CompletionDataKind[CompletionDataKind["JsDocTag"] = 2] = "JsDocTag"; CompletionDataKind[CompletionDataKind["JsDocParameterName"] = 3] = "JsDocParameterName"; + CompletionDataKind[CompletionDataKind["Keywords"] = 4] = "Keywords"; })(CompletionDataKind || (CompletionDataKind = {})); var CompletionKind; (function (CompletionKind) { @@ -120303,25 +124811,25 @@ var ts; function getContextualType(previousToken, position, sourceFile, checker) { var parent = previousToken.parent; switch (previousToken.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return ts.getContextualTypeFromParent(previousToken, checker); - case 62 /* EqualsToken */: + case 63 /* EqualsToken */: switch (parent.kind) { - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return checker.getContextualType(parent.initializer); // TODO: GH#18217 - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return checker.getTypeAtLocation(parent.left); - case 280 /* JsxAttribute */: + case 282 /* JsxAttribute */: return checker.getContextualTypeForJsxAttribute(parent); default: return undefined; } - case 102 /* NewKeyword */: + case 103 /* NewKeyword */: return checker.getContextualType(parent); - case 81 /* CaseKeyword */: + case 82 /* CaseKeyword */: return ts.getSwitchedType(ts.cast(parent, ts.isCaseClause), checker); case 18 /* OpenBraceToken */: - return ts.isJsxExpression(parent) && parent.parent.kind !== 273 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; + return ts.isJsxExpression(parent) && parent.parent.kind !== 275 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; default: var argInfo = ts.SignatureHelp.getArgumentInfoForCompletions(previousToken, position, sourceFile); return argInfo ? @@ -120340,7 +124848,8 @@ var ts; return symbol.parent && (isModuleSymbol(symbol.parent) ? symbol : getFirstSymbolInChain(symbol.parent, enclosingDeclaration, checker)); } function isModuleSymbol(symbol) { - return symbol.declarations.some(function (d) { return d.kind === 297 /* SourceFile */; }); + var _a; + return !!((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d.kind === 299 /* SourceFile */; })); } function getCompletionData(program, log, sourceFile, isUncheckedFile, position, preferences, detailsEntryId, host) { var typeChecker = program.getTypeChecker(); @@ -120391,11 +124900,11 @@ var ts; if (tag.tagName.pos <= position && position <= tag.tagName.end) { return { kind: 1 /* JsDocTagName */ }; } - if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 301 /* JSDocTypeExpression */) { + if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 303 /* JSDocTypeExpression */) { currentToken = ts.getTokenAtPosition(sourceFile, position); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 333 /* JSDocPropertyTag */ || + (currentToken.parent.kind !== 341 /* JSDocPropertyTag */ || currentToken.parent.name !== currentToken))) { // Use as type location if inside tag's type expression insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression); @@ -120420,7 +124929,7 @@ var ts; var contextToken = previousToken; // Check if the caret is at the end of an identifier; this is a partial identifier that we want to complete: e.g. a.toS| // Skip this partial identifier and adjust the contextToken to the token that precedes it. - if (contextToken && position <= contextToken.end && (ts.isIdentifierOrPrivateIdentifier(contextToken) || ts.isKeyword(contextToken.kind))) { + if (contextToken && position <= contextToken.end && (ts.isMemberName(contextToken) || ts.isKeyword(contextToken.kind))) { var start_1 = ts.timestamp(); contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile, /*startNode*/ undefined); // TODO: GH#18217 log("getCompletionData: Get previous token 2: " + (ts.timestamp() - start_1)); @@ -120436,10 +124945,22 @@ var ts; var isStartingCloseTag = false; var isJsxInitializer = false; var isJsxIdentifierExpected = false; + var importCompletionNode; var location = ts.getTouchingPropertyName(sourceFile, position); if (contextToken) { + var importCompletionCandidate = getImportCompletionNode(contextToken); + if (importCompletionCandidate === 154 /* FromKeyword */) { + return { kind: 4 /* Keywords */, keywords: [154 /* FromKeyword */] }; + } + // Import statement completions use `insertText`, and also require the `data` property of `CompletionEntryIdentifier` + // added in TypeScript 4.3 to be sent back from the client during `getCompletionEntryDetails`. Since this feature + // 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. + if (importCompletionCandidate && preferences.includeCompletionsForImportStatements && preferences.includeCompletionsWithInsertText) { + importCompletionNode = importCompletionCandidate; + } // Bail out if this is a known invalid completion location - if (isCompletionListBlocker(contextToken)) { + if (!importCompletionNode && isCompletionListBlocker(contextToken)) { log("Returning an empty list because completion was requested in an invalid position."); return undefined; } @@ -120448,7 +124969,7 @@ var ts; isRightOfDot = contextToken.kind === 24 /* DotToken */; isRightOfQuestionDot = contextToken.kind === 28 /* QuestionDotToken */; switch (parent.kind) { - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: propertyAccessToConvert = parent; node = propertyAccessToConvert.expression; if ((ts.isCallExpression(node) || ts.isFunctionLike(node)) && @@ -120461,14 +124982,14 @@ var ts; return undefined; } break; - case 157 /* QualifiedName */: + case 159 /* QualifiedName */: node = parent.left; break; - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: node = parent.name; break; - case 195 /* ImportType */: - case 226 /* MetaProperty */: + case 197 /* ImportType */: + case 228 /* MetaProperty */: node = parent; break; default: @@ -120477,11 +124998,11 @@ var ts; return undefined; } } - else if (sourceFile.languageVariant === 1 /* JSX */) { + else if (!importCompletionNode && sourceFile.languageVariant === 1 /* 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 === 201 /* PropertyAccessExpression */) { + if (parent && parent.kind === 203 /* PropertyAccessExpression */) { contextToken = parent; parent = parent.parent; } @@ -120489,45 +125010,45 @@ var ts; if (currentToken.parent === location) { switch (currentToken.kind) { case 31 /* GreaterThanToken */: - if (currentToken.parent.kind === 273 /* JsxElement */ || currentToken.parent.kind === 275 /* JsxOpeningElement */) { + if (currentToken.parent.kind === 275 /* JsxElement */ || currentToken.parent.kind === 277 /* JsxOpeningElement */) { location = currentToken; } break; case 43 /* SlashToken */: - if (currentToken.parent.kind === 274 /* JsxSelfClosingElement */) { + if (currentToken.parent.kind === 276 /* JsxSelfClosingElement */) { location = currentToken; } break; } } switch (parent.kind) { - case 276 /* JsxClosingElement */: + case 278 /* JsxClosingElement */: if (contextToken.kind === 43 /* SlashToken */) { isStartingCloseTag = true; location = contextToken; } break; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: if (!binaryExpressionMayBeOpenTag(parent)) { break; } // falls through - case 274 /* JsxSelfClosingElement */: - case 273 /* JsxElement */: - case 275 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: + case 275 /* JsxElement */: + case 277 /* JsxOpeningElement */: isJsxIdentifierExpected = true; if (contextToken.kind === 29 /* LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } break; - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: // For `
`, `parent` will be `{true}` and `previousToken` will be `}` if (previousToken.kind === 19 /* CloseBraceToken */ && currentToken.kind === 31 /* GreaterThanToken */) { isJsxIdentifierExpected = true; } break; - case 280 /* JsxAttribute */: + case 282 /* JsxAttribute */: // For `
`, `parent` will be JsxAttribute and `previousToken` will be its initializer if (parent.initializer === previousToken && previousToken.end < position) { @@ -120535,16 +125056,16 @@ var ts; break; } switch (previousToken.kind) { - case 62 /* EqualsToken */: + case 63 /* EqualsToken */: isJsxInitializer = true; break; - case 78 /* Identifier */: + case 79 /* 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, 62 /* EqualsToken */, sourceFile)) { + ts.findChildOfKind(parent, 63 /* EqualsToken */, sourceFile)) { isJsxInitializer = previousToken; } } @@ -120560,9 +125081,12 @@ var ts; // This also gets mutated in nested-functions after the return var symbols = []; var symbolToOriginInfoMap = []; - var symbolToSortTextMap = []; - var importSuggestionsCache = host.getImportSuggestionsCache && host.getImportSuggestionsCache(); + var symbolToSortTextIdMap = []; + var seenPropertySymbols = new ts.Map(); var isTypeOnly = isTypeOnlyCompletion(); + var getModuleSpecifierResolutionHost = ts.memoizeOne(function (isFromPackageJson) { + return ts.createModuleSpecifierResolutionHost(isFromPackageJson ? host.getPackageJsonAutoImportProvider() : program, host); + }); if (isRightOfDot || isRightOfQuestionDot) { getTypeScriptMemberSymbols(); } @@ -120571,7 +125095,7 @@ var ts; ts.Debug.assertEachIsDefined(tagSymbols, "getJsxIntrinsicTagNames() should all be defined"); tryGetGlobalSymbols(); symbols = tagSymbols.concat(symbols); - completionKind = 3 /* MemberLike */; + completionKind = 1 /* Global */; keywordFilters = 0 /* None */; } else if (isStartingCloseTag) { @@ -120580,7 +125104,7 @@ var ts; if (tagSymbol) { symbols = [tagSymbol]; } - completionKind = 3 /* MemberLike */; + completionKind = 1 /* Global */; keywordFilters = 0 /* None */; } else { @@ -120610,17 +125134,18 @@ var ts; previousToken: previousToken, isJsxInitializer: isJsxInitializer, insideJsDocTagTypeExpression: insideJsDocTagTypeExpression, - symbolToSortTextMap: symbolToSortTextMap, + symbolToSortTextIdMap: symbolToSortTextIdMap, isTypeOnlyLocation: isTypeOnly, isJsxIdentifierExpected: isJsxIdentifierExpected, + importCompletionNode: importCompletionNode, }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 326 /* JSDocParameterTag */: - case 333 /* JSDocPropertyTag */: - case 327 /* JSDocReturnTag */: - case 329 /* JSDocTypeTag */: - case 331 /* JSDocTypedefTag */: + case 334 /* JSDocParameterTag */: + case 341 /* JSDocPropertyTag */: + case 335 /* JSDocReturnTag */: + case 337 /* JSDocTypeTag */: + case 339 /* JSDocTypedefTag */: return true; default: return false; @@ -120647,11 +125172,11 @@ var ts; // Extract module or enum members var exportedSymbols = typeChecker.getExportsOfModule(symbol); ts.Debug.assertEachIsDefined(exportedSymbols, "getExportsOfModule() should all be defined"); - var isValidValueAccess_1 = function (symbol) { return typeChecker.isValidPropertyAccess(isImportType ? node : (node.parent), symbol.name); }; - var isValidTypeAccess_1 = function (symbol) { return symbolCanBeReferencedAtTypeLocation(symbol); }; + var isValidValueAccess_1 = function (symbol) { return typeChecker.isValidPropertyAccess(isImportType ? node : node.parent, symbol.name); }; + 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) { return !!(symbol.flags & 1920 /* Namespace */) && !symbol.declarations.every(function (d) { return d.parent === node.parent; }); } + ? 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; })); } : isRhsOfImportDeclaration ? // Any kind is allowed when dotting off namespace in internal import equals declaration function (symbol) { return isValidTypeAccess_1(symbol) || isValidValueAccess_1(symbol); } : @@ -120665,7 +125190,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 !== 297 /* SourceFile */ && d.kind !== 256 /* ModuleDeclaration */ && d.kind !== 255 /* EnumDeclaration */; })) { + symbol.declarations.some(function (d) { return d.kind !== 299 /* SourceFile */ && d.kind !== 258 /* ModuleDeclaration */ && d.kind !== 257 /* EnumDeclaration */; })) { var type = typeChecker.getTypeOfSymbolAtLocation(symbol, node).getNonOptionalType(); var insertQuestionDot = false; if (type.isNullableType()) { @@ -120685,8 +125210,8 @@ var ts; } } } - if (ts.isMetaProperty(node) && (node.keywordToken === 102 /* NewKeyword */ || node.keywordToken === 99 /* ImportKeyword */) && contextToken === node.getChildAt(1)) { - var completion = (node.keywordToken === 102 /* NewKeyword */) ? "target" : "meta"; + if (ts.isMetaProperty(node) && (node.keywordToken === 103 /* NewKeyword */ || node.keywordToken === 100 /* ImportKeyword */) && contextToken === node.getChildAt(1)) { + var completion = (node.keywordToken === 103 /* NewKeyword */) ? "target" : "meta"; symbols.push(typeChecker.createSymbol(4 /* Property */, ts.escapeLeadingUnderscores(completion))); return; } @@ -120712,7 +125237,7 @@ var ts; if (isRightOfQuestionDot && ts.some(type.getCallSignatures())) { isNewIdentifierLocation = true; } - var propertyAccess = node.kind === 195 /* ImportType */ ? node : node.parent; + var propertyAccess = node.kind === 197 /* ImportType */ ? node : node.parent; if (isUncheckedFile) { // 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 @@ -120751,13 +125276,24 @@ var ts; var nameSymbol = leftMostName && typeChecker.getSymbolAtLocation(leftMostName); // If this is nested like for `namespace N { export const sym = Symbol(); }`, we'll add the completion for `N`. var firstAccessibleSymbol = nameSymbol && getFirstSymbolInChain(nameSymbol, contextToken, typeChecker); - if (firstAccessibleSymbol && !symbolToOriginInfoMap[ts.getSymbolId(firstAccessibleSymbol)]) { + if (firstAccessibleSymbol && ts.addToSeen(seenPropertySymbols, ts.getSymbolId(firstAccessibleSymbol))) { + var index = symbols.length; symbols.push(firstAccessibleSymbol); var moduleSymbol = firstAccessibleSymbol.parent; - symbolToOriginInfoMap[ts.getSymbolId(firstAccessibleSymbol)] = - !moduleSymbol || !ts.isExternalModuleSymbol(moduleSymbol) - ? { kind: getNullableSymbolOriginInfoKind(2 /* SymbolMemberNoExport */) } - : { kind: getNullableSymbolOriginInfoKind(6 /* SymbolMemberExport */), moduleSymbol: moduleSymbol, isDefaultExport: false }; + if (!moduleSymbol || !ts.isExternalModuleSymbol(moduleSymbol)) { + symbolToOriginInfoMap[index] = { kind: getNullableSymbolOriginInfoKind(2 /* SymbolMemberNoExport */) }; + } + else { + var origin = { + kind: getNullableSymbolOriginInfoKind(6 /* SymbolMemberExport */), + moduleSymbol: moduleSymbol, + isDefaultExport: false, + symbolName: firstAccessibleSymbol.name, + exportName: firstAccessibleSymbol.name, + fileName: ts.isExternalModuleNameRelative(ts.stripQuotes(moduleSymbol.name)) ? ts.cast(moduleSymbol.valueDeclaration, ts.isSourceFile).fileName : undefined, + }; + symbolToOriginInfoMap[index] = origin; + } } else if (preferences.includeCompletionsWithInsertText) { addSymbolOriginInfo(symbol); @@ -120772,16 +125308,16 @@ var ts; } function addSymbolSortInfo(symbol) { if (isStaticProperty(symbol)) { - symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.LocalDeclarationPriority; + symbolToSortTextIdMap[ts.getSymbolId(symbol)] = SortTextId.LocalDeclarationPriority; } } function addSymbolOriginInfo(symbol) { if (preferences.includeCompletionsWithInsertText) { - if (insertAwait && !symbolToOriginInfoMap[ts.getSymbolId(symbol)]) { - symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: getNullableSymbolOriginInfoKind(8 /* Promise */) }; + if (insertAwait && ts.addToSeen(seenPropertySymbols, ts.getSymbolId(symbol))) { + symbolToOriginInfoMap[symbols.length] = { kind: getNullableSymbolOriginInfoKind(8 /* Promise */) }; } else if (insertQuestionDot) { - symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: 16 /* Nullable */ }; + symbolToOriginInfoMap[symbols.length] = { kind: 16 /* Nullable */ }; } } } @@ -120794,7 +125330,9 @@ var ts; return ts.isIdentifier(e) ? e : ts.isPropertyAccessExpression(e) ? getLeftMostName(e.expression) : undefined; } function tryGetGlobalSymbols() { - var result = tryGetObjectLikeCompletionSymbols() + var result = tryGetObjectTypeLiteralInTypeArgumentCompletionSymbols() + || tryGetObjectLikeCompletionSymbols() + || tryGetImportCompletionSymbols() || tryGetImportOrExportClauseCompletionSymbols() || tryGetLocalNamedExportCompletionSymbols() || tryGetConstructorCompletion() @@ -120827,11 +125365,17 @@ var ts; isNewIdentifierLocation = false; return 1 /* Success */; } + function tryGetImportCompletionSymbols() { + if (!importCompletionNode) + return 0 /* Continue */; + collectAutoImports(/*resolveModuleSpecifiers*/ true); + return 1 /* Success */; + } function getGlobalCompletions() { keywordFilters = tryGetFunctionLikeBodyCompletionContainer(contextToken) ? 5 /* FunctionLikeBodyKeywords */ : 1 /* All */; // Get all entities in the current scope. completionKind = 1 /* Global */; - isNewIdentifierLocation = isNewIdentifierDefinitionLocation(contextToken); + isNewIdentifierLocation = isNewIdentifierDefinitionLocation(); if (previousToken !== contextToken) { ts.Debug.assert(!!previousToken, "Expected 'contextToken' to be defined when different from 'previousToken'."); } @@ -120868,50 +125412,36 @@ var ts; var symbolMeanings = (isTypeOnly ? 0 /* None */ : 111551 /* Value */) | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */; symbols = typeChecker.getSymbolsInScope(scopeNode, symbolMeanings); ts.Debug.assertEachIsDefined(symbols, "getSymbolsInScope() should all be defined"); - for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) { - var symbol = symbols_2[_i]; + for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) { + var symbol = symbols_1[_i]; if (!typeChecker.isArgumentsSymbol(symbol) && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === sourceFile; })) { - symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.GlobalsOrKeywords; + symbolToSortTextIdMap[ts.getSymbolId(symbol)] = SortTextId.GlobalsOrKeywords; } } // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions` - if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 297 /* SourceFile */) { + if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 299 /* SourceFile */) { var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false); if (thisType && !isProbablyGlobalType(thisType, sourceFile, typeChecker)) { for (var _a = 0, _b = getPropertiesForCompletion(thisType, typeChecker); _a < _b.length; _a++) { var symbol = _b[_a]; - symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: 1 /* ThisType */ }; + symbolToOriginInfoMap[symbols.length] = { kind: 1 /* ThisType */ }; symbols.push(symbol); - symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.SuggestedClassMembers; + symbolToSortTextIdMap[ts.getSymbolId(symbol)] = SortTextId.SuggestedClassMembers; } } } - if (shouldOfferImportCompletions()) { - var lowerCaseTokenText_1 = previousToken && ts.isIdentifier(previousToken) ? previousToken.text.toLowerCase() : ""; - var autoImportSuggestions = getSymbolsFromOtherSourceFileExports(program.getCompilerOptions().target, host); - if (!detailsEntryId && importSuggestionsCache) { - importSuggestionsCache.set(sourceFile.fileName, autoImportSuggestions, host.getProjectVersion && host.getProjectVersion()); - } - autoImportSuggestions.forEach(function (_a) { - var symbol = _a.symbol, symbolName = _a.symbolName, skipFilter = _a.skipFilter, origin = _a.origin; - if (detailsEntryId) { - if (detailsEntryId.source && ts.stripQuotes(origin.moduleSymbol.name) !== detailsEntryId.source) { - return; - } - } - else if (!skipFilter && !stringContainsCharactersInOrder(symbolName.toLowerCase(), lowerCaseTokenText_1)) { - return; - } - var symbolId = ts.getSymbolId(symbol); - symbols.push(symbol); - symbolToOriginInfoMap[symbolId] = origin; - symbolToSortTextMap[symbolId] = SortText.AutoImportSuggestions; - }); + collectAutoImports(/*resolveModuleSpecifier*/ false); + if (isTypeOnly) { + keywordFilters = contextToken && ts.isAssertionExpression(contextToken.parent) + ? 6 /* TypeAssertionKeywords */ + : 7 /* TypeKeywords */; } - filterGlobalCompletion(symbols); } function shouldOfferImportCompletions() { + // If already typing an import statement, provide completions for it. + if (importCompletionNode) + return true; // If current completion is for non-contextual Object literal shortahands, ignore auto-import symbols if (isNonContextualObjectLiteral) return false; @@ -120929,42 +125459,15 @@ var ts; } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { - case 297 /* SourceFile */: - case 218 /* TemplateExpression */: - case 283 /* JsxExpression */: - case 230 /* Block */: + case 299 /* SourceFile */: + case 220 /* TemplateExpression */: + case 285 /* JsxExpression */: + case 232 /* Block */: return true; default: return ts.isStatement(scopeNode); } } - function filterGlobalCompletion(symbols) { - var isTypeOnly = isTypeOnlyCompletion(); - if (isTypeOnly) { - keywordFilters = contextToken && ts.isAssertionExpression(contextToken.parent) - ? 6 /* TypeAssertionKeywords */ - : 7 /* TypeKeywords */; - } - ts.filterMutate(symbols, function (symbol) { - if (!ts.isSourceFile(location)) { - // export = /**/ here we want to get all meanings, so any symbol is ok - if (ts.isExportAssignment(location.parent)) { - return true; - } - symbol = ts.skipAlias(symbol, typeChecker); - // import m = /**/ <-- It can only access namespace (if typing import = x. this would get member symbols and not namespace) - if (ts.isInRightSideOfInternalImportEqualsDeclaration(location)) { - return !!(symbol.flags & 1920 /* Namespace */); - } - if (isTypeOnly) { - // It's a type, but you can reach it by namespace.type as well - return symbolCanBeReferencedAtTypeLocation(symbol); - } - } - // expressions are value space (which includes the value namespaces) - return !!(ts.getCombinedLocalAndExportSymbolFlags(symbol) & 111551 /* Value */); - }); - } function isTypeOnlyCompletion() { return insideJsDocTagTypeExpression || !isContextTokenValueLocation(contextToken) && @@ -120974,191 +125477,105 @@ var ts; } function isContextTokenValueLocation(contextToken) { return contextToken && - contextToken.kind === 111 /* TypeOfKeyword */ && - (contextToken.parent.kind === 176 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent)); + ((contextToken.kind === 112 /* TypeOfKeyword */ && + (contextToken.parent.kind === 178 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent))) || + (contextToken.kind === 128 /* AssertsKeyword */ && contextToken.parent.kind === 174 /* TypePredicate */)); } function isContextTokenTypeLocation(contextToken) { if (contextToken) { var parentKind = contextToken.parent.kind; switch (contextToken.kind) { case 58 /* ColonToken */: - return parentKind === 163 /* PropertyDeclaration */ || - parentKind === 162 /* PropertySignature */ || - parentKind === 160 /* Parameter */ || - parentKind === 249 /* VariableDeclaration */ || + return parentKind === 165 /* PropertyDeclaration */ || + parentKind === 164 /* PropertySignature */ || + parentKind === 162 /* Parameter */ || + parentKind === 251 /* VariableDeclaration */ || ts.isFunctionLikeKind(parentKind); - case 62 /* EqualsToken */: - return parentKind === 254 /* TypeAliasDeclaration */; - case 126 /* AsKeyword */: - return parentKind === 224 /* AsExpression */; + case 63 /* EqualsToken */: + return parentKind === 256 /* TypeAliasDeclaration */; + case 127 /* AsKeyword */: + return parentKind === 226 /* AsExpression */; case 29 /* LessThanToken */: - return parentKind === 173 /* TypeReference */ || - parentKind === 206 /* TypeAssertionExpression */; - case 93 /* ExtendsKeyword */: - return parentKind === 159 /* TypeParameter */; + return parentKind === 175 /* TypeReference */ || + parentKind === 208 /* TypeAssertionExpression */; + case 94 /* ExtendsKeyword */: + return parentKind === 161 /* TypeParameter */; } } return false; } - /** True if symbol is a type or a module containing at least one type. */ - function symbolCanBeReferencedAtTypeLocation(symbol, seenModules) { - if (seenModules === void 0) { seenModules = new ts.Map(); } - var sym = ts.skipAlias(symbol.exportSymbol || symbol, typeChecker); - return !!(sym.flags & 788968 /* Type */) || - !!(sym.flags & 1536 /* Module */) && - ts.addToSeen(seenModules, ts.getSymbolId(sym)) && - typeChecker.getExportsOfModule(sym).some(function (e) { return symbolCanBeReferencedAtTypeLocation(e, seenModules); }); - } - /** - * Gathers symbols that can be imported from other files, de-duplicating along the way. Symbols can be "duplicates" - * if re-exported from another module, e.g. `export { foo } from "./a"`. That syntax creates a fresh symbol, but - * it’s just an alias to the first, and both have the same name, so we generally want to filter those aliases out, - * if and only if the the first can be imported (it may be excluded due to package.json filtering in - * `codefix.forEachExternalModuleToImportFrom`). - * - * Example. Imagine a chain of node_modules re-exporting one original symbol: - * - * ```js - * node_modules/x/index.js node_modules/y/index.js node_modules/z/index.js - * +-----------------------+ +--------------------------+ +--------------------------+ - * | | | | | | - * | export const foo = 0; | <--- | export { foo } from 'x'; | <--- | export { foo } from 'y'; | - * | | | | | | - * +-----------------------+ +--------------------------+ +--------------------------+ - * ``` - * - * Also imagine three buckets, which we’ll reference soon: - * - * ```md - * | | | | | | - * | **Bucket A** | | **Bucket B** | | **Bucket C** | - * | Symbols to | | Aliases to symbols | | Symbols to return | - * | definitely | | in Buckets A or C | | if nothing better | - * | return | | (don’t return these) | | comes along | - * |__________________| |______________________| |___________________| - * ``` - * - * We _probably_ want to show `foo` from 'x', but not from 'y' or 'z'. However, if 'x' is not in a package.json, it - * will not appear in a `forEachExternalModuleToImportFrom` iteration. Furthermore, the order of iterations is not - * guaranteed, as it is host-dependent. Therefore, when presented with the symbol `foo` from module 'y' alone, we - * may not be sure whether or not it should go in the list. So, we’ll take the following steps: - * - * 1. Resolve alias `foo` from 'y' to the export declaration in 'x', get the symbol there, and see if that symbol is - * already in Bucket A (symbols we already know will be returned). If it is, put `foo` from 'y' in Bucket B - * (symbols that are aliases to symbols in Bucket A). If it’s not, put it in Bucket C. - * 2. Next, imagine we see `foo` from module 'z'. Again, we resolve the alias to the nearest export, which is in 'y'. - * At this point, if that nearest export from 'y' is in _any_ of the three buckets, we know the symbol in 'z' - * should never be returned in the final list, so put it in Bucket B. - * 3. Next, imagine we see `foo` from module 'x', the original. Syntactically, it doesn’t look like a re-export, so - * we can just check Bucket C to see if we put any aliases to the original in there. If they exist, throw them out. - * Put this symbol in Bucket A. - * 4. After we’ve iterated through every symbol of every module, any symbol left in Bucket C means that step 3 didn’t - * occur for that symbol---that is, the original symbol is not in Bucket A, so we should include the alias. Move - * everything from Bucket C to Bucket A. - */ - function getSymbolsFromOtherSourceFileExports(target, host) { - var cached = importSuggestionsCache && importSuggestionsCache.get(sourceFile.fileName, typeChecker, detailsEntryId && host.getProjectVersion ? host.getProjectVersion() : undefined); - if (cached) { - log("getSymbolsFromOtherSourceFileExports: Using cached list"); - return cached; - } - var startTime = ts.timestamp(); - log("getSymbolsFromOtherSourceFileExports: Recomputing list" + (detailsEntryId ? " for details entry" : "")); - var seenResolvedModules = new ts.Map(); - var seenExports = new ts.Map(); - /** Bucket B */ - var aliasesToAlreadyIncludedSymbols = new ts.Map(); - /** Bucket C */ - var aliasesToReturnIfOriginalsAreMissing = new ts.Map(); - /** Bucket A */ - var results = []; - /** Ids present in `results` for faster lookup */ - var resultSymbolIds = new ts.Map(); - ts.codefix.forEachExternalModuleToImportFrom(program, host, sourceFile, !detailsEntryId, /*useAutoImportProvider*/ true, function (moduleSymbol, _, program, isFromPackageJson) { - // Perf -- ignore other modules if this is a request for details - if (detailsEntryId && detailsEntryId.source && ts.stripQuotes(moduleSymbol.name) !== detailsEntryId.source) { - return; - } - var typeChecker = program.getTypeChecker(); - var resolvedModuleSymbol = typeChecker.resolveExternalModuleSymbol(moduleSymbol); - // resolvedModuleSymbol may be a namespace. A namespace may be `export =` by multiple module declarations, but only keep the first one. - if (!ts.addToSeen(seenResolvedModules, ts.getSymbolId(resolvedModuleSymbol))) { + /** Mutates `symbols`, `symbolToOriginInfoMap`, and `symbolToSortTextIdMap` */ + function collectAutoImports(resolveModuleSpecifiers) { + var _a, _b, _c, _d, _e; + if (!shouldOfferImportCompletions()) + return; + ts.Debug.assert(!(detailsEntryId === null || detailsEntryId === void 0 ? void 0 : detailsEntryId.data)); + var start = ts.timestamp(); + var moduleSpecifierCache = (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host); + (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, "collectAutoImports: starting, " + (resolveModuleSpecifiers ? "" : "not ") + "resolving module specifiers"); + if (moduleSpecifierCache) { + (_c = host.log) === null || _c === void 0 ? void 0 : _c.call(host, "collectAutoImports: module specifier cache size: " + moduleSpecifierCache.count()); + } + var lowerCaseTokenText = previousToken && ts.isIdentifier(previousToken) ? previousToken.text.toLowerCase() : ""; + var exportInfo = ts.codefix.getSymbolToExportInfoMap(sourceFile, host, program); + var packageJsonAutoImportProvider = (_d = host.getPackageJsonAutoImportProvider) === null || _d === void 0 ? void 0 : _d.call(host); + var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, host); + exportInfo.forEach(function (info, key) { + var symbolName = key.substring(0, key.indexOf("|")); + if (!detailsEntryId && ts.isStringANonContextualKeyword(symbolName)) return; - } - // Don't add another completion for `export =` of a symbol that's already global. - // So in `declare namespace foo {} declare module "foo" { export = foo; }`, there will just be the global completion for `foo`. - if (resolvedModuleSymbol !== moduleSymbol && ts.every(resolvedModuleSymbol.declarations, ts.isNonGlobalDeclaration)) { - pushSymbol(resolvedModuleSymbol, moduleSymbol, isFromPackageJson, /*skipFilter*/ true); - } - for (var _i = 0, _a = typeChecker.getExportsAndPropertiesOfModule(moduleSymbol); _i < _a.length; _i++) { - var symbol = _a[_i]; - var symbolId = ts.getSymbolId(symbol).toString(); - // `getExportsAndPropertiesOfModule` can include duplicates - if (!ts.addToSeen(seenExports, symbolId)) { - continue; - } - // If this is `export { _break as break };` (a keyword) -- skip this and prefer the keyword completion. - if (ts.some(symbol.declarations, function (d) { return ts.isExportSpecifier(d) && !!d.propertyName && ts.isIdentifierANonContextualKeyword(d.name); })) { - continue; - } - // If `symbol.parent !== moduleSymbol`, this is an `export * from "foo"` re-export. Those don't create new symbols. - var isExportStarFromReExport = typeChecker.getMergedSymbol(symbol.parent) !== resolvedModuleSymbol; - // If `!!d.parent.parent.moduleSpecifier`, this is `export { foo } from "foo"` re-export, which creates a new symbol (thus isn't caught by the first check). - if (isExportStarFromReExport || ts.some(symbol.declarations, function (d) { return ts.isExportSpecifier(d) && !d.propertyName && !!d.parent.parent.moduleSpecifier; })) { - // Walk the export chain back one module (step 1 or 2 in diagrammed example). - // Or, in the case of `export * from "foo"`, `symbol` already points to the original export, so just use that. - var nearestExportSymbol = isExportStarFromReExport ? symbol : getNearestExportSymbol(symbol); - if (!nearestExportSymbol) - continue; - var nearestExportSymbolId = ts.getSymbolId(nearestExportSymbol).toString(); - var symbolHasBeenSeen = resultSymbolIds.has(nearestExportSymbolId) || aliasesToAlreadyIncludedSymbols.has(nearestExportSymbolId); - if (!symbolHasBeenSeen) { - aliasesToReturnIfOriginalsAreMissing.set(nearestExportSymbolId, { alias: symbol, moduleSymbol: moduleSymbol, isFromPackageJson: isFromPackageJson }); - aliasesToAlreadyIncludedSymbols.set(symbolId, true); - } - else { - // Perf - we know this symbol is an alias to one that’s already covered in `symbols`, so store it here - // in case another symbol re-exports this one; that way we can short-circuit as soon as we see this symbol id. - ts.addToSeen(aliasesToAlreadyIncludedSymbols, symbolId); - } - } - else { - // This is not a re-export, so see if we have any aliases pending and remove them (step 3 in diagrammed example) - aliasesToReturnIfOriginalsAreMissing.delete(symbolId); - pushSymbol(symbol, moduleSymbol, isFromPackageJson, /*skipFilter*/ false); - } + var isCompletionDetailsMatch = detailsEntryId && ts.some(info, function (i) { return detailsEntryId.source === ts.stripQuotes(i.moduleSymbol.name); }); + if (isCompletionDetailsMatch || isNameMatch(symbolName)) { + // If we don't need to resolve module specifiers, we can use any re-export that is importable at all + // (We need to ensure that at least one is importable to show a completion.) + var _a = resolveModuleSpecifiers + ? ts.codefix.getModuleSpecifierForBestExportInfo(info, sourceFile, program, host, preferences) + : { moduleSpecifier: undefined, exportInfo: ts.find(info, isImportableExportInfo) }, moduleSpecifier = _a.moduleSpecifier, exportInfo_1 = _a.exportInfo; + if (!exportInfo_1) + return; + var moduleFile = ts.tryCast(exportInfo_1.moduleSymbol.valueDeclaration, ts.isSourceFile); + var isDefaultExport = exportInfo_1.exportKind === 1 /* Default */; + var symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(exportInfo_1.symbol) || exportInfo_1.symbol; + pushAutoImportSymbol(symbol, { + kind: resolveModuleSpecifiers ? 32 /* ResolvedExport */ : 4 /* Export */, + moduleSpecifier: moduleSpecifier, + symbolName: symbolName, + exportName: exportInfo_1.exportKind === 2 /* ExportEquals */ ? "export=" /* ExportEquals */ : exportInfo_1.symbol.name, + fileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName, + isDefaultExport: isDefaultExport, + moduleSymbol: exportInfo_1.moduleSymbol, + isFromPackageJson: exportInfo_1.isFromPackageJson, + }); } }); - // By this point, any potential duplicates that were actually duplicates have been - // removed, so the rest need to be added. (Step 4 in diagrammed example) - aliasesToReturnIfOriginalsAreMissing.forEach(function (_a) { - var alias = _a.alias, moduleSymbol = _a.moduleSymbol, isFromPackageJson = _a.isFromPackageJson; - return pushSymbol(alias, moduleSymbol, isFromPackageJson, /*skipFilter*/ false); - }); - log("getSymbolsFromOtherSourceFileExports: " + (ts.timestamp() - startTime)); - return results; - function pushSymbol(symbol, moduleSymbol, isFromPackageJson, skipFilter) { - var isDefaultExport = symbol.escapedName === "default" /* Default */; - if (isDefaultExport) { - symbol = ts.getLocalSymbolForExportDefault(symbol) || symbol; + (_e = host.log) === null || _e === void 0 ? void 0 : _e.call(host, "collectAutoImports: done in " + (ts.timestamp() - start) + " ms"); + function isNameMatch(symbolName) { + var lowerCaseSymbolName = symbolName.toLowerCase(); + if (resolveModuleSpecifiers && lowerCaseTokenText) { + // Use a more restrictive filter if resolving module specifiers since resolving module specifiers is expensive. + return lowerCaseTokenText[0] === lowerCaseSymbolName[0] && stringContainsCharactersInOrder(lowerCaseSymbolName, lowerCaseTokenText); } - if (typeChecker.isUndefinedSymbol(symbol)) { - return; + return stringContainsCharactersInOrder(lowerCaseSymbolName, lowerCaseTokenText); + } + function isImportableExportInfo(info) { + var moduleFile = ts.tryCast(info.moduleSymbol.valueDeclaration, ts.isSourceFile); + if (!moduleFile) { + return packageJsonFilter + ? packageJsonFilter.allowsImportingAmbientModule(info.moduleSymbol, getModuleSpecifierResolutionHost(info.isFromPackageJson)) + : true; } - ts.addToSeen(resultSymbolIds, ts.getSymbolId(symbol)); - var origin = { kind: 4 /* Export */, moduleSymbol: moduleSymbol, isDefaultExport: isDefaultExport, isFromPackageJson: isFromPackageJson }; - results.push({ - symbol: symbol, - symbolName: ts.getNameForExportedSymbol(symbol, target), - origin: origin, - skipFilter: skipFilter, - }); + return ts.isImportableFile(info.isFromPackageJson ? packageJsonAutoImportProvider : program, sourceFile, moduleFile, packageJsonFilter, getModuleSpecifierResolutionHost(info.isFromPackageJson), moduleSpecifierCache); } } - function getNearestExportSymbol(fromSymbol) { - return findAlias(typeChecker, fromSymbol, function (alias) { - return ts.some(alias.declarations, function (d) { return ts.isExportSpecifier(d) || !!d.localSymbol; }); - }); + function pushAutoImportSymbol(symbol, origin) { + var symbolId = ts.getSymbolId(symbol); + if (symbolToSortTextIdMap[symbolId] === SortTextId.GlobalsOrKeywords) { + // If an auto-importable symbol is available as a global, don't add the auto import + return; + } + symbolToOriginInfoMap[symbols.length] = origin; + symbolToSortTextIdMap[symbolId] = importCompletionNode ? SortTextId.LocationPriority : SortTextId.AutoImportSuggestions; + symbols.push(symbol); } /** * True if you could remove some characters in `a` to get `b`. @@ -121170,7 +125587,8 @@ var ts; return true; } var characterIndex = 0; - for (var strIndex = 0; strIndex < str.length; strIndex++) { + var len = str.length; + for (var strIndex = 0; strIndex < len; strIndex++) { if (str.charCodeAt(strIndex) === characters.charCodeAt(characterIndex)) { characterIndex++; if (characterIndex === characters.length) { @@ -121206,7 +125624,7 @@ var ts; return true; } if (contextToken.kind === 31 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 275 /* JsxOpeningElement */) { + if (contextToken.parent.kind === 277 /* JsxOpeningElement */) { // Two possibilities: // 1.
/**/ // - contextToken: GreaterThanToken (before cursor) @@ -121216,54 +125634,56 @@ var ts; // - contextToken: GreaterThanToken (before cursor) // - location: GreaterThanToken (after cursor) // - same parent (JSXOpeningElement) - return location.parent.kind !== 275 /* JsxOpeningElement */; + return location.parent.kind !== 277 /* JsxOpeningElement */; } - if (contextToken.parent.kind === 276 /* JsxClosingElement */ || contextToken.parent.kind === 274 /* JsxSelfClosingElement */) { - return !!contextToken.parent.parent && contextToken.parent.parent.kind === 273 /* JsxElement */; + if (contextToken.parent.kind === 278 /* JsxClosingElement */ || contextToken.parent.kind === 276 /* JsxSelfClosingElement */) { + return !!contextToken.parent.parent && contextToken.parent.parent.kind === 275 /* JsxElement */; } } return false; } - function isNewIdentifierDefinitionLocation(previousToken) { - if (previousToken) { - var containingNodeKind = previousToken.parent.kind; + function isNewIdentifierDefinitionLocation() { + if (contextToken) { + var containingNodeKind = contextToken.parent.kind; // Previous token may have been a keyword that was converted to an identifier. - switch (keywordForNode(previousToken)) { + switch (keywordForNode(contextToken)) { case 27 /* CommaToken */: - return containingNodeKind === 203 /* CallExpression */ // func( a, | - || containingNodeKind === 166 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 204 /* NewExpression */ // new C(a, | - || containingNodeKind === 199 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 216 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 174 /* FunctionType */; // var x: (s: string, list| + return containingNodeKind === 205 /* CallExpression */ // func( a, | + || containingNodeKind === 168 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 206 /* NewExpression */ // new C(a, | + || containingNodeKind === 201 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 218 /* BinaryExpression */ // const x = (a, | + || containingNodeKind === 176 /* FunctionType */ // var x: (s: string, list| + || containingNodeKind === 202 /* ObjectLiteralExpression */; // const obj = { x, | case 20 /* OpenParenToken */: - return containingNodeKind === 203 /* CallExpression */ // func( | - || containingNodeKind === 166 /* Constructor */ // constructor( | - || containingNodeKind === 204 /* NewExpression */ // new C(a| - || containingNodeKind === 207 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 186 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + return containingNodeKind === 205 /* CallExpression */ // func( | + || containingNodeKind === 168 /* Constructor */ // constructor( | + || containingNodeKind === 206 /* NewExpression */ // new C(a| + || containingNodeKind === 209 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 188 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case 22 /* OpenBracketToken */: - return containingNodeKind === 199 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 171 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 158 /* ComputedPropertyName */; // [ | /* this can become an index signature */ - case 139 /* ModuleKeyword */: // module | - case 140 /* NamespaceKeyword */: // namespace | + return containingNodeKind === 201 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 173 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 160 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + case 140 /* ModuleKeyword */: // module | + case 141 /* NamespaceKeyword */: // namespace | return true; case 24 /* DotToken */: - return containingNodeKind === 256 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 258 /* ModuleDeclaration */; // module A.| case 18 /* OpenBraceToken */: - return containingNodeKind === 252 /* ClassDeclaration */; // class A{ | - case 62 /* EqualsToken */: - return containingNodeKind === 249 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 216 /* BinaryExpression */; // x = a| + return containingNodeKind === 254 /* ClassDeclaration */ // class A { | + || containingNodeKind === 202 /* ObjectLiteralExpression */; // const obj = { | + case 63 /* EqualsToken */: + return containingNodeKind === 251 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 218 /* BinaryExpression */; // x = a| case 15 /* TemplateHead */: - return containingNodeKind === 218 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 220 /* TemplateExpression */; // `aa ${| case 16 /* TemplateMiddle */: - return containingNodeKind === 228 /* TemplateSpan */; // `aa ${10} dd ${| - case 122 /* PublicKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - return containingNodeKind === 163 /* PropertyDeclaration */; // class A{ public | + return containingNodeKind === 230 /* TemplateSpan */; // `aa ${10} dd ${| + case 123 /* PublicKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + return containingNodeKind === 165 /* PropertyDeclaration */; // class A{ public | } } return false; @@ -121276,6 +125696,25 @@ var ts; return (ts.isRegularExpressionLiteral(contextToken) || ts.isStringTextContainingNode(contextToken)) && (ts.rangeContainsPositionExclusive(ts.createTextRangeFromSpan(ts.createTextSpanFromNode(contextToken)), position) || position === contextToken.end && (!!contextToken.isUnterminated || ts.isRegularExpressionLiteral(contextToken))); } + function tryGetObjectTypeLiteralInTypeArgumentCompletionSymbols() { + var typeLiteralNode = tryGetTypeLiteralNode(contextToken); + if (!typeLiteralNode) + return 0 /* Continue */; + var intersectionTypeNode = ts.isIntersectionTypeNode(typeLiteralNode.parent) ? typeLiteralNode.parent : undefined; + var containerTypeNode = intersectionTypeNode || typeLiteralNode; + var containerExpectedType = getConstraintOfTypeArgumentProperty(containerTypeNode, typeChecker); + if (!containerExpectedType) + return 0 /* 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.filter(members, function (s) { return !existingMemberEscapedNames.has(s.escapedName); }); + completionKind = 0 /* ObjectPropertyDeclaration */; + isNewIdentifierLocation = true; + return 1 /* Success */; + } /** * Aggregates relevant symbols for completion in object literals and object binding patterns. * Relevant symbols are stored in the captured 'symbols' variable. @@ -121290,7 +125729,7 @@ var ts; completionKind = 0 /* ObjectPropertyDeclaration */; var typeMembers; var existingMembers; - if (objectLikeContainer.kind === 200 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 202 /* ObjectLiteralExpression */) { var instantiatedType = tryGetObjectLiteralContextualType(objectLikeContainer, typeChecker); // Check completions for Object property value shorthand if (instantiatedType === undefined) { @@ -121315,7 +125754,7 @@ var ts; } } else { - ts.Debug.assert(objectLikeContainer.kind === 196 /* ObjectBindingPattern */); + ts.Debug.assert(objectLikeContainer.kind === 198 /* ObjectBindingPattern */); // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -121326,12 +125765,12 @@ 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.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 239 /* ForOfStatement */; - if (!canGetType && rootDeclaration.kind === 160 /* Parameter */) { + var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 241 /* ForOfStatement */; + if (!canGetType && rootDeclaration.kind === 162 /* Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 165 /* MethodDeclaration */ || rootDeclaration.parent.kind === 168 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 167 /* MethodDeclaration */ || rootDeclaration.parent.kind === 170 /* SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -121378,9 +125817,9 @@ var ts; if (!namedImportsOrExports) return 0 /* Continue */; // try to show exported member for imported/re-exported module - var moduleSpecifier = (namedImportsOrExports.kind === 264 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; + var moduleSpecifier = (namedImportsOrExports.kind === 266 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; if (!moduleSpecifier) - return namedImportsOrExports.kind === 264 /* NamedImports */ ? 2 /* Fail */ : 0 /* Continue */; + return namedImportsOrExports.kind === 266 /* NamedImports */ ? 2 /* Fail */ : 0 /* Continue */; var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); // TODO: GH#18217 if (!moduleSpecifierSymbol) return 2 /* Fail */; @@ -121415,7 +125854,7 @@ var ts; var _a, _b; symbols.push(symbol); if ((_b = (_a = localsContainer.symbol) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.has(name)) { - symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.OptionalMember; + symbolToSortTextIdMap[ts.getSymbolId(symbol)] = SortTextId.OptionalMember; } }); return 1 /* Success */; @@ -121440,7 +125879,7 @@ var ts; var classElement = contextToken.kind === 26 /* SemicolonToken */ ? contextToken.parent.parent : contextToken.parent; var classElementModifierFlags = ts.isClassElement(classElement) ? ts.getEffectiveModifierFlags(classElement) : 0 /* None */; // If this is context token is not something we are editing now, consider if this would lead to be modifier - if (contextToken.kind === 78 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { + if (contextToken.kind === 79 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { switch (contextToken.getText()) { case "private": classElementModifierFlags = classElementModifierFlags | 8 /* Private */; @@ -121448,12 +125887,16 @@ var ts; case "static": classElementModifierFlags = classElementModifierFlags | 32 /* Static */; break; + case "override": + classElementModifierFlags = classElementModifierFlags | 16384 /* Override */; + break; } } // No member list for private methods if (!(classElementModifierFlags & 8 /* Private */)) { // List of property symbols of base type that are not private and already implemented - var baseSymbols = ts.flatMap(ts.getAllSuperTypeNodes(decl), function (baseTypeNode) { + var baseTypeNodes = ts.isClassLike(decl) && classElementModifierFlags & 16384 /* 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 */ ? (type === null || type === void 0 ? void 0 : type.symbol) && typeChecker.getPropertiesOfType(typeChecker.getTypeOfSymbolAtLocation(type.symbol, decl)) : @@ -121479,7 +125922,7 @@ var ts; break; case 41 /* AsteriskToken */: return ts.isMethodDeclaration(parent) ? ts.tryCast(parent.parent, ts.isObjectLiteralExpression) : undefined; - case 78 /* Identifier */: + case 79 /* Identifier */: return contextToken.text === "async" && ts.isShorthandPropertyAssignment(contextToken.parent) ? contextToken.parent.parent : undefined; } @@ -121532,12 +125975,12 @@ var ts; case 31 /* GreaterThanToken */: // End of a type argument list case 30 /* LessThanSlashToken */: case 43 /* SlashToken */: - case 78 /* Identifier */: - case 201 /* PropertyAccessExpression */: - case 281 /* JsxAttributes */: - case 280 /* JsxAttribute */: - case 282 /* JsxSpreadAttribute */: - if (parent && (parent.kind === 274 /* JsxSelfClosingElement */ || parent.kind === 275 /* JsxOpeningElement */)) { + case 79 /* Identifier */: + case 203 /* PropertyAccessExpression */: + case 283 /* JsxAttributes */: + case 282 /* JsxAttribute */: + case 284 /* JsxSpreadAttribute */: + if (parent && (parent.kind === 276 /* JsxSelfClosingElement */ || parent.kind === 277 /* JsxOpeningElement */)) { if (contextToken.kind === 31 /* GreaterThanToken */) { var precedingToken = ts.findPrecedingToken(contextToken.pos, sourceFile, /*startNode*/ undefined); if (!parent.typeArguments || (precedingToken && precedingToken.kind === 43 /* SlashToken */)) @@ -121545,7 +125988,7 @@ var ts; } return parent; } - else if (parent.kind === 280 /* JsxAttribute */) { + else if (parent.kind === 282 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -121557,7 +126000,7 @@ var ts; // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement case 10 /* StringLiteral */: - if (parent && ((parent.kind === 280 /* JsxAttribute */) || (parent.kind === 282 /* JsxSpreadAttribute */))) { + if (parent && ((parent.kind === 282 /* JsxAttribute */) || (parent.kind === 284 /* JsxSpreadAttribute */))) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -121567,8 +126010,8 @@ var ts; break; case 19 /* CloseBraceToken */: if (parent && - parent.kind === 283 /* JsxExpression */ && - parent.parent && parent.parent.kind === 280 /* JsxAttribute */) { + parent.kind === 285 /* JsxExpression */ && + parent.parent && parent.parent.kind === 282 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -121576,7 +126019,7 @@ var ts; // each JsxAttribute can have initializer as JsxExpression return parent.parent.parent.parent; } - if (parent && parent.kind === 282 /* JsxSpreadAttribute */) { + if (parent && parent.kind === 284 /* JsxSpreadAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -121596,67 +126039,67 @@ var ts; var containingNodeKind = parent.kind; switch (contextToken.kind) { case 27 /* CommaToken */: - return containingNodeKind === 249 /* VariableDeclaration */ || + return containingNodeKind === 251 /* VariableDeclaration */ || isVariableDeclarationListButNotTypeArgument(contextToken) || - containingNodeKind === 232 /* VariableStatement */ || - containingNodeKind === 255 /* EnumDeclaration */ || // enum a { foo, | + containingNodeKind === 234 /* VariableStatement */ || + containingNodeKind === 257 /* EnumDeclaration */ || // enum a { foo, | isFunctionLikeButNotConstructor(containingNodeKind) || - containingNodeKind === 253 /* InterfaceDeclaration */ || // interface A= contextToken.pos); case 24 /* DotToken */: - return containingNodeKind === 197 /* ArrayBindingPattern */; // var [.| + return containingNodeKind === 199 /* ArrayBindingPattern */; // var [.| case 58 /* ColonToken */: - return containingNodeKind === 198 /* BindingElement */; // var {x :html| + return containingNodeKind === 200 /* BindingElement */; // var {x :html| case 22 /* OpenBracketToken */: - return containingNodeKind === 197 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 199 /* ArrayBindingPattern */; // var [x| case 20 /* OpenParenToken */: - return containingNodeKind === 287 /* CatchClause */ || + return containingNodeKind === 289 /* CatchClause */ || isFunctionLikeButNotConstructor(containingNodeKind); case 18 /* OpenBraceToken */: - return containingNodeKind === 255 /* EnumDeclaration */; // enum a { | + return containingNodeKind === 257 /* EnumDeclaration */; // enum a { | case 29 /* LessThanToken */: - return containingNodeKind === 252 /* ClassDeclaration */ || // class A< | - containingNodeKind === 221 /* ClassExpression */ || // var C = class D< | - containingNodeKind === 253 /* InterfaceDeclaration */ || // interface A< | - containingNodeKind === 254 /* TypeAliasDeclaration */ || // type List< | + return containingNodeKind === 254 /* ClassDeclaration */ || // class A< | + containingNodeKind === 223 /* ClassExpression */ || // var C = class D< | + containingNodeKind === 255 /* InterfaceDeclaration */ || // interface A< | + containingNodeKind === 256 /* TypeAliasDeclaration */ || // type List< | ts.isFunctionLikeKind(containingNodeKind); - case 123 /* StaticKeyword */: - return containingNodeKind === 163 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); + case 124 /* StaticKeyword */: + return containingNodeKind === 165 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); case 25 /* DotDotDotToken */: - return containingNodeKind === 160 /* Parameter */ || - (!!parent.parent && parent.parent.kind === 197 /* ArrayBindingPattern */); // var [...z| - case 122 /* PublicKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - return containingNodeKind === 160 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); - case 126 /* AsKeyword */: - return containingNodeKind === 265 /* ImportSpecifier */ || - containingNodeKind === 270 /* ExportSpecifier */ || - containingNodeKind === 263 /* NamespaceImport */; - case 134 /* GetKeyword */: - case 146 /* SetKeyword */: + return containingNodeKind === 162 /* Parameter */ || + (!!parent.parent && parent.parent.kind === 199 /* ArrayBindingPattern */); // var [...z| + case 123 /* PublicKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + return containingNodeKind === 162 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); + case 127 /* AsKeyword */: + return containingNodeKind === 267 /* ImportSpecifier */ || + containingNodeKind === 272 /* ExportSpecifier */ || + containingNodeKind === 265 /* NamespaceImport */; + case 135 /* GetKeyword */: + case 147 /* SetKeyword */: return !isFromObjectTypeDeclaration(contextToken); - case 83 /* ClassKeyword */: - case 91 /* EnumKeyword */: - case 117 /* InterfaceKeyword */: - case 97 /* FunctionKeyword */: - case 112 /* VarKeyword */: - case 99 /* ImportKeyword */: - case 118 /* LetKeyword */: - case 84 /* ConstKeyword */: - case 135 /* InferKeyword */: - case 149 /* TypeKeyword */: // type htm| + 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 136 /* InferKeyword */: + case 150 /* TypeKeyword */: // type htm| return true; case 41 /* AsteriskToken */: return ts.isFunctionLike(contextToken.parent) && !ts.isMethodDeclaration(contextToken.parent); } - // If the previous token is keyword correspoding to class member completion keyword + // If the previous token is keyword corresponding to class member completion keyword // there will be completion available here if (isClassMemberCompletionKeyword(keywordForNode(contextToken)) && isFromObjectTypeDeclaration(contextToken)) { return false; @@ -121674,23 +126117,48 @@ var ts; } // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(contextToken)) { - case 125 /* AbstractKeyword */: - case 83 /* ClassKeyword */: - case 84 /* ConstKeyword */: - case 133 /* DeclareKeyword */: - case 91 /* EnumKeyword */: - case 97 /* FunctionKeyword */: - case 117 /* InterfaceKeyword */: - case 118 /* LetKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 122 /* PublicKeyword */: - case 123 /* StaticKeyword */: - case 112 /* VarKeyword */: + case 126 /* AbstractKeyword */: + case 84 /* ClassKeyword */: + case 85 /* ConstKeyword */: + case 134 /* 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 */: return true; - case 129 /* AsyncKeyword */: + case 130 /* AsyncKeyword */: return ts.isPropertyDeclaration(contextToken.parent); } + // If we are inside a class declaration, and `constructor` is totally not present, + // but we request a completion manually at a whitespace... + var ancestorClassLike = ts.findAncestor(contextToken.parent, ts.isClassLike); + if (ancestorClassLike && contextToken === previousToken && isPreviousPropertyDeclarationTerminated(contextToken, position)) { + return false; // Don't block completions. + } + var ancestorPropertyDeclaraion = ts.getAncestor(contextToken.parent, 165 /* PropertyDeclaration */); + // If we are inside a class declaration and typing `constructor` after property declaration... + if (ancestorPropertyDeclaraion + && contextToken !== previousToken + && ts.isClassLike(previousToken.parent.parent) + // And the cursor is at the token... + && position <= previousToken.end) { + // If we are sure that the previous property declaration is terminated according to newline or semicolon... + if (isPreviousPropertyDeclarationTerminated(contextToken, previousToken.end)) { + return false; // Don't block completions. + } + else if (contextToken.kind !== 63 /* 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) + || ts.hasType(ancestorPropertyDeclaraion))) { + return true; + } + } return ts.isDeclarationName(contextToken) && !ts.isShorthandPropertyAssignment(contextToken.parent) && !ts.isJsxAttribute(contextToken.parent) @@ -121698,8 +126166,13 @@ var ts; // If `contextToken !== previousToken`, this is `class C ex/**/`. && !(ts.isClassLike(contextToken.parent) && (contextToken !== previousToken || position > previousToken.end)); } + function isPreviousPropertyDeclarationTerminated(contextToken, position) { + return contextToken.kind !== 63 /* EqualsToken */ && + (contextToken.kind === 26 /* SemicolonToken */ + || !ts.positionsAreOnSameLine(contextToken.end, position, sourceFile)); + } function isFunctionLikeButNotConstructor(kind) { - return ts.isFunctionLikeKind(kind) && kind !== 166 /* Constructor */; + return ts.isFunctionLikeKind(kind) && kind !== 168 /* Constructor */; } function isDotOfNumericLiteral(contextToken) { if (contextToken.kind === 8 /* NumericLiteral */) { @@ -121709,7 +126182,7 @@ var ts; return false; } function isVariableDeclarationListButNotTypeArgument(node) { - return node.parent.kind === 250 /* VariableDeclarationList */ + return node.parent.kind === 252 /* VariableDeclarationList */ && !ts.isPossiblyTypeArgumentPosition(node, sourceFile, typeChecker); } /** @@ -121727,13 +126200,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 !== 288 /* PropertyAssignment */ && - m.kind !== 289 /* ShorthandPropertyAssignment */ && - m.kind !== 198 /* BindingElement */ && - m.kind !== 165 /* MethodDeclaration */ && - m.kind !== 167 /* GetAccessor */ && - m.kind !== 168 /* SetAccessor */ && - m.kind !== 290 /* SpreadAssignment */) { + if (m.kind !== 290 /* PropertyAssignment */ && + m.kind !== 291 /* ShorthandPropertyAssignment */ && + m.kind !== 200 /* BindingElement */ && + m.kind !== 167 /* MethodDeclaration */ && + m.kind !== 169 /* GetAccessor */ && + m.kind !== 170 /* SetAccessor */ && + m.kind !== 292 /* SpreadAssignment */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -121746,7 +126219,7 @@ var ts; } else if (ts.isBindingElement(m) && m.propertyName) { // include only identifiers in completion list - if (m.propertyName.kind === 78 /* Identifier */) { + if (m.propertyName.kind === 79 /* Identifier */) { existingName = m.propertyName.escapedText; } } @@ -121779,8 +126252,10 @@ var ts; // Set SortText to OptionalMember if it is an optional member function setSortTextToOptionalMember() { symbols.forEach(function (m) { + var _a; if (m.flags & 16777216 /* Optional */) { - symbolToSortTextMap[ts.getSymbolId(m)] = symbolToSortTextMap[ts.getSymbolId(m)] || SortText.OptionalMember; + var symbolId = ts.getSymbolId(m); + symbolToSortTextIdMap[symbolId] = (_a = symbolToSortTextIdMap[symbolId]) !== null && _a !== void 0 ? _a : SortTextId.OptionalMember; } }); } @@ -121792,7 +126267,7 @@ var ts; for (var _i = 0, contextualMemberSymbols_1 = contextualMemberSymbols; _i < contextualMemberSymbols_1.length; _i++) { var contextualMemberSymbol = contextualMemberSymbols_1[_i]; if (membersDeclaredBySpreadAssignment.has(contextualMemberSymbol.name)) { - symbolToSortTextMap[ts.getSymbolId(contextualMemberSymbol)] = SortText.MemberDeclaredBySpreadAssignment; + symbolToSortTextIdMap[ts.getSymbolId(contextualMemberSymbol)] = SortTextId.MemberDeclaredBySpreadAssignment; } } } @@ -121806,10 +126281,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 !== 163 /* PropertyDeclaration */ && - m.kind !== 165 /* MethodDeclaration */ && - m.kind !== 167 /* GetAccessor */ && - m.kind !== 168 /* SetAccessor */) { + if (m.kind !== 165 /* PropertyDeclaration */ && + m.kind !== 167 /* MethodDeclaration */ && + m.kind !== 169 /* GetAccessor */ && + m.kind !== 170 /* SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -121833,7 +126308,7 @@ var ts; return !existingMemberNames.has(propertySymbol.escapedName) && !!propertySymbol.declarations && !(ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 8 /* Private */) && - !(propertySymbol.valueDeclaration && ts.isPrivateIdentifierPropertyDeclaration(propertySymbol.valueDeclaration)); + !(propertySymbol.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(propertySymbol.valueDeclaration)); }); } /** @@ -121851,7 +126326,7 @@ var ts; if (isCurrentlyEditingNode(attr)) { continue; } - if (attr.kind === 280 /* JsxAttribute */) { + if (attr.kind === 282 /* JsxAttribute */) { seenNames.add(attr.name.escapedText); } else if (ts.isJsxSpreadAttribute(attr)) { @@ -121866,8 +126341,35 @@ var ts; return node.getStart(sourceFile) <= position && position <= node.getEnd(); } } + function getAutoImportSymbolFromCompletionEntryData(name, data, program, host) { + var containingProgram = data.isPackageJsonImport ? host.getPackageJsonAutoImportProvider() : program; + var checker = containingProgram.getTypeChecker(); + var moduleSymbol = data.ambientModuleName ? checker.tryFindAmbientModule(data.ambientModuleName) : + data.fileName ? checker.getMergedSymbol(ts.Debug.checkDefined(containingProgram.getSourceFile(data.fileName)).symbol) : + undefined; + if (!moduleSymbol) + return undefined; + var symbol = data.exportName === "export=" /* ExportEquals */ + ? checker.resolveExternalModuleSymbol(moduleSymbol) + : checker.tryGetMemberInModuleExportsAndProperties(data.exportName, moduleSymbol); + if (!symbol) + return undefined; + var isDefaultExport = data.exportName === "default" /* Default */; + symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(symbol) || symbol; + return { + symbol: symbol, + origin: { + kind: data.moduleSpecifier ? 32 /* ResolvedExport */ : 4 /* Export */, + moduleSymbol: moduleSymbol, + symbolName: name, + isDefaultExport: isDefaultExport, + exportName: data.exportName, + fileName: data.fileName, + } + }; + } function getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind, jsxIdentifierExpected) { - var name = originIsExport(origin) ? ts.getNameForExportedSymbol(symbol, target) : symbol.name; + var name = originIncludesSymbolName(origin) ? origin.symbolName : symbol.name; 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) @@ -121877,7 +126379,7 @@ var ts; return undefined; } var validNameResult = { name: name, needsConvertPropertyAccess: false }; - if (ts.isIdentifierText(name, target, jsxIdentifierExpected ? 1 /* JSX */ : 0 /* Standard */) || symbol.valueDeclaration && ts.isPrivateIdentifierPropertyDeclaration(symbol.valueDeclaration)) { + if (ts.isIdentifierText(name, target, jsxIdentifierExpected ? 1 /* JSX */ : 0 /* Standard */) || symbol.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(symbol.valueDeclaration)) { return validNameResult; } switch (kind) { @@ -121901,7 +126403,7 @@ var ts; var _keywordCompletions = []; var allKeywordsCompletions = ts.memoize(function () { var res = []; - for (var i = 80 /* FirstKeyword */; i <= 156 /* LastKeyword */; i++) { + for (var i = 81 /* FirstKeyword */; i <= 158 /* LastKeyword */; i++) { res.push({ name: ts.tokenToString(i), kind: "keyword" /* keyword */, @@ -121927,11 +126429,11 @@ var ts; return false; case 1 /* All */: return isFunctionLikeBodyKeyword(kind) - || kind === 133 /* DeclareKeyword */ - || kind === 139 /* ModuleKeyword */ - || kind === 149 /* TypeKeyword */ - || kind === 140 /* NamespaceKeyword */ - || ts.isTypeKeyword(kind) && kind !== 150 /* UndefinedKeyword */; + || kind === 134 /* DeclareKeyword */ + || kind === 140 /* ModuleKeyword */ + || kind === 150 /* TypeKeyword */ + || kind === 141 /* NamespaceKeyword */ + || ts.isTypeKeyword(kind) && kind !== 151 /* UndefinedKeyword */; case 5 /* FunctionLikeBodyKeywords */: return isFunctionLikeBodyKeyword(kind); case 2 /* ClassElementKeywords */: @@ -121941,7 +126443,7 @@ var ts; case 4 /* ConstructorParameterKeywords */: return ts.isParameterPropertyModifier(kind); case 6 /* TypeAssertionKeywords */: - return ts.isTypeKeyword(kind) || kind === 84 /* ConstKeyword */; + return ts.isTypeKeyword(kind) || kind === 85 /* ConstKeyword */; case 7 /* TypeKeywords */: return ts.isTypeKeyword(kind); default: @@ -121951,57 +126453,59 @@ var ts; } function isTypeScriptOnlyKeyword(kind) { switch (kind) { - case 125 /* AbstractKeyword */: - case 128 /* AnyKeyword */: - case 155 /* BigIntKeyword */: - case 131 /* BooleanKeyword */: - case 133 /* DeclareKeyword */: - case 91 /* EnumKeyword */: - case 154 /* GlobalKeyword */: - case 116 /* ImplementsKeyword */: - case 135 /* InferKeyword */: - case 117 /* InterfaceKeyword */: - case 137 /* IsKeyword */: - case 138 /* KeyOfKeyword */: - case 139 /* ModuleKeyword */: - case 140 /* NamespaceKeyword */: - case 141 /* NeverKeyword */: - case 144 /* NumberKeyword */: - case 145 /* ObjectKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 122 /* PublicKeyword */: - case 142 /* ReadonlyKeyword */: - case 147 /* StringKeyword */: - case 148 /* SymbolKeyword */: - case 149 /* TypeKeyword */: - case 151 /* UniqueKeyword */: - case 152 /* UnknownKeyword */: + case 126 /* AbstractKeyword */: + case 129 /* AnyKeyword */: + case 156 /* BigIntKeyword */: + case 132 /* BooleanKeyword */: + case 134 /* DeclareKeyword */: + case 92 /* EnumKeyword */: + case 155 /* GlobalKeyword */: + case 117 /* ImplementsKeyword */: + case 136 /* InferKeyword */: + case 118 /* InterfaceKeyword */: + case 138 /* IsKeyword */: + case 139 /* KeyOfKeyword */: + case 140 /* ModuleKeyword */: + case 141 /* NamespaceKeyword */: + case 142 /* NeverKeyword */: + case 145 /* NumberKeyword */: + case 146 /* ObjectKeyword */: + case 157 /* OverrideKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + case 123 /* PublicKeyword */: + case 143 /* ReadonlyKeyword */: + case 148 /* StringKeyword */: + case 149 /* SymbolKeyword */: + case 150 /* TypeKeyword */: + case 152 /* UniqueKeyword */: + case 153 /* UnknownKeyword */: return true; default: return false; } } function isInterfaceOrTypeLiteralCompletionKeyword(kind) { - return kind === 142 /* ReadonlyKeyword */; + return kind === 143 /* ReadonlyKeyword */; } function isClassMemberCompletionKeyword(kind) { switch (kind) { - case 125 /* AbstractKeyword */: - case 132 /* ConstructorKeyword */: - case 134 /* GetKeyword */: - case 146 /* SetKeyword */: - case 129 /* AsyncKeyword */: - case 133 /* DeclareKeyword */: + case 126 /* AbstractKeyword */: + case 133 /* ConstructorKeyword */: + case 135 /* GetKeyword */: + case 147 /* SetKeyword */: + case 130 /* AsyncKeyword */: + case 134 /* DeclareKeyword */: + case 157 /* OverrideKeyword */: return true; default: return ts.isClassMemberModifier(kind); } } function isFunctionLikeBodyKeyword(kind) { - return kind === 129 /* AsyncKeyword */ - || kind === 130 /* AwaitKeyword */ - || kind === 126 /* AsKeyword */ + return kind === 130 /* AsyncKeyword */ + || kind === 131 /* AwaitKeyword */ + || kind === 127 /* AsKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind); } function keywordForNode(node) { @@ -122053,7 +126557,7 @@ var ts; function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location, position) { // class c { method() { } | method2() { } } switch (location.kind) { - case 334 /* SyntaxList */: + case 342 /* SyntaxList */: return ts.tryCast(location.parent, ts.isObjectTypeDeclaration); case 1 /* EndOfFileToken */: var cls = ts.tryCast(ts.lastOrUndefined(ts.cast(location.parent, ts.isSourceFile).statements), ts.isObjectTypeDeclaration); @@ -122061,7 +126565,7 @@ var ts; return cls; } break; - case 78 /* Identifier */: { + case 79 /* Identifier */: { // class c { public prop = c| } if (ts.isPropertyDeclaration(location.parent) && location.parent.initializer === location) { return undefined; @@ -122074,8 +126578,14 @@ var ts; } if (!contextToken) return undefined; + // class C { blah; constructor/**/ } and so on + if (location.kind === 133 /* 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 62 /* EqualsToken */: // class c { public prop = | /* global completions */ } + case 63 /* EqualsToken */: // class c { public prop = | /* global completions */ } return undefined; case 26 /* SemicolonToken */: // class c {getValue(): number; | } case 19 /* CloseBraceToken */: // class c { method() { } | } @@ -122099,6 +126609,44 @@ var ts; ? contextToken.parent.parent : undefined; } } + function tryGetTypeLiteralNode(node) { + if (!node) + return undefined; + var parent = node.parent; + switch (node.kind) { + case 18 /* OpenBraceToken */: + if (ts.isTypeLiteralNode(parent)) { + return parent; + } + break; + case 26 /* SemicolonToken */: + case 27 /* CommaToken */: + case 79 /* Identifier */: + if (parent.kind === 164 /* PropertySignature */ && ts.isTypeLiteralNode(parent.parent)) { + return parent.parent; + } + break; + } + return undefined; + } + function getConstraintOfTypeArgumentProperty(node, checker) { + if (!node) + return undefined; + if (ts.isTypeNode(node) && ts.isTypeReferenceType(node.parent)) { + return checker.getTypeArgumentConstraint(node); + } + var t = getConstraintOfTypeArgumentProperty(node.parent, checker); + if (!t) + return undefined; + switch (node.kind) { + case 164 /* PropertySignature */: + return checker.getTypeOfPropertyOfContextualType(t, node.symbol.escapedName); + case 185 /* IntersectionType */: + case 179 /* TypeLiteral */: + case 184 /* UnionType */: + return t; + } + } // TODO: GH#19856 Would like to return `node is Node & { parent: (ClassElement | TypeElement) & { parent: ObjectTypeDeclaration } }` but then compilation takes > 10 minutes function isFromObjectTypeDeclaration(node) { return node.parent && ts.isClassOrTypeElement(node.parent) && ts.isObjectTypeDeclaration(node.parent.parent); @@ -122122,6 +126670,8 @@ var ts; return !!contextToken && (ts.isStringLiteralLike(contextToken) ? !!ts.tryGetImportFromModuleSpecifier(contextToken) : contextToken.kind === 43 /* SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); + case " ": + return !!contextToken && ts.isImportKeyword(contextToken) && contextToken.parent.kind === 299 /* SourceFile */; default: return ts.Debug.assertNever(triggerCharacter); } @@ -122130,14 +126680,6 @@ var ts; var left = _a.left; return ts.nodeIsMissing(left); } - function findAlias(typeChecker, symbol, predicate) { - var currentAlias = symbol; - while (currentAlias.flags & 2097152 /* Alias */ && (currentAlias = typeChecker.getImmediateAliasedSymbol(currentAlias))) { - if (predicate(currentAlias)) { - return currentAlias; - } - } - } /** Determines if a type is exactly the same type resolved by the global 'self', 'global', or 'globalThis'. */ 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 @@ -122164,11 +126706,71 @@ var ts; if (type) { return type; } - if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 /* EqualsToken */) { + if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* EqualsToken */ && node === node.parent.left) { + // Object literal is assignment pattern: ({ | } = x) return typeChecker.getTypeAtLocation(node.parent); } return undefined; } + function getImportCompletionNode(contextToken) { + var candidate = getCandidate(); + return candidate === 154 /* FromKeyword */ || candidate && ts.rangeIsOnSingleLine(candidate, candidate.getSourceFile()) ? candidate : undefined; + function getCandidate() { + var parent = contextToken.parent; + if (ts.isImportEqualsDeclaration(parent)) { + return isModuleSpecifierMissingOrEmpty(parent.moduleReference) ? parent : undefined; + } + if (ts.isNamedImports(parent) || ts.isNamespaceImport(parent)) { + if (isModuleSpecifierMissingOrEmpty(parent.parent.parent.moduleSpecifier) && (ts.isNamespaceImport(parent) || parent.elements.length < 2) && !parent.parent.name) { + // At `import { ... } |` or `import * as Foo |`, the only possible completion is `from` + return contextToken.kind === 19 /* CloseBraceToken */ || contextToken.kind === 79 /* Identifier */ + ? 154 /* FromKeyword */ + : parent.parent.parent; + } + return undefined; + } + if (ts.isImportKeyword(contextToken) && ts.isSourceFile(parent)) { + // A lone import keyword with nothing following it does not parse as a statement at all + return contextToken; + } + if (ts.isImportKeyword(contextToken) && ts.isImportDeclaration(parent)) { + // `import s| from` + return isModuleSpecifierMissingOrEmpty(parent.moduleSpecifier) ? parent : undefined; + } + return undefined; + } + } + function isModuleSpecifierMissingOrEmpty(specifier) { + var _a; + if (ts.nodeIsMissing(specifier)) + return true; + return !((_a = ts.tryCast(ts.isExternalModuleReference(specifier) ? specifier.expression : specifier, ts.isStringLiteralLike)) === null || _a === void 0 ? void 0 : _a.text); + } + function getVariableDeclaration(property) { + var variableDeclaration = ts.findAncestor(property, function (node) { + return ts.isFunctionBlock(node) || isArrowFunctionBody(node) || ts.isBindingPattern(node) + ? "quit" + : ts.isVariableDeclaration(node); + }); + return variableDeclaration; + } + function isArrowFunctionBody(node) { + return node.parent && ts.isArrowFunction(node.parent) && node.parent.body === node; + } + ; + /** True if symbol is a type or a module containing at least one type. */ + function symbolCanBeReferencedAtTypeLocation(symbol, checker, seenModules) { + if (seenModules === void 0) { seenModules = new ts.Map(); } + var sym = ts.skipAlias(symbol.exportSymbol || symbol, checker); + return !!(sym.flags & 788968 /* Type */) || + !!(sym.flags & 1536 /* Module */) && + ts.addToSeen(seenModules, ts.getSymbolId(sym)) && + checker.getExportsOfModule(sym).some(function (e) { return symbolCanBeReferencedAtTypeLocation(e, checker, seenModules); }); + } + function isDeprecated(symbol, checker) { + var declarations = ts.skipAlias(symbol, checker).declarations; + return !!ts.length(declarations) && ts.every(declarations, ts.isDeprecatedDeclaration); + } })(Completions = ts.Completions || (ts.Completions = {})); })(ts || (ts = {})); var ts; @@ -122203,10 +126805,13 @@ var ts; if (!referenceEntries) return undefined; var map = ts.arrayToMultiMap(referenceEntries.map(ts.FindAllReferences.toHighlightSpan), function (e) { return e.fileName; }, function (e) { return e.span; }); - return ts.arrayFrom(map.entries(), function (_a) { + var getCanonicalFileName = ts.createGetCanonicalFileName(program.useCaseSensitiveFileNames()); + return ts.mapDefined(ts.arrayFrom(map.entries()), function (_a) { var fileName = _a[0], highlightSpans = _a[1]; if (!sourceFilesSet.has(fileName)) { - ts.Debug.assert(program.redirectTargetsMap.has(fileName)); + if (!program.redirectTargetsMap.has(ts.toPath(fileName, program.getCurrentDirectory(), getCanonicalFileName))) { + return undefined; + } var redirectTarget_1 = program.getSourceFile(fileName); var redirect = ts.find(sourceFilesToSearch, function (f) { return !!f.redirectInfo && f.redirectInfo.redirectTarget === redirectTarget_1; }); fileName = redirect.fileName; @@ -122221,44 +126826,44 @@ var ts; } function getHighlightSpans(node, sourceFile) { switch (node.kind) { - case 98 /* IfKeyword */: - case 90 /* ElseKeyword */: + case 99 /* IfKeyword */: + case 91 /* ElseKeyword */: return ts.isIfStatement(node.parent) ? getIfElseOccurrences(node.parent, sourceFile) : undefined; - case 104 /* ReturnKeyword */: + case 105 /* ReturnKeyword */: return useParent(node.parent, ts.isReturnStatement, getReturnOccurrences); - case 108 /* ThrowKeyword */: + case 109 /* ThrowKeyword */: return useParent(node.parent, ts.isThrowStatement, getThrowOccurrences); - case 110 /* TryKeyword */: - case 82 /* CatchKeyword */: - case 95 /* FinallyKeyword */: - var tryStatement = node.kind === 82 /* CatchKeyword */ ? node.parent.parent : node.parent; + case 111 /* TryKeyword */: + case 83 /* CatchKeyword */: + case 96 /* FinallyKeyword */: + var tryStatement = node.kind === 83 /* CatchKeyword */ ? node.parent.parent : node.parent; return useParent(tryStatement, ts.isTryStatement, getTryCatchFinallyOccurrences); - case 106 /* SwitchKeyword */: + case 107 /* SwitchKeyword */: return useParent(node.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); - case 81 /* CaseKeyword */: - case 87 /* DefaultKeyword */: { + case 82 /* CaseKeyword */: + case 88 /* DefaultKeyword */: { if (ts.isDefaultClause(node.parent) || ts.isCaseClause(node.parent)) { return useParent(node.parent.parent.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); } return undefined; } - case 80 /* BreakKeyword */: - case 85 /* ContinueKeyword */: + case 81 /* BreakKeyword */: + case 86 /* ContinueKeyword */: return useParent(node.parent, ts.isBreakOrContinueStatement, getBreakOrContinueStatementOccurrences); - case 96 /* ForKeyword */: - case 114 /* WhileKeyword */: - case 89 /* DoKeyword */: + case 97 /* ForKeyword */: + case 115 /* WhileKeyword */: + case 90 /* DoKeyword */: return useParent(node.parent, function (n) { return ts.isIterationStatement(n, /*lookInLabeledStatements*/ true); }, getLoopBreakContinueOccurrences); - case 132 /* ConstructorKeyword */: - return getFromAllDeclarations(ts.isConstructorDeclaration, [132 /* ConstructorKeyword */]); - case 134 /* GetKeyword */: - case 146 /* SetKeyword */: - return getFromAllDeclarations(ts.isAccessor, [134 /* GetKeyword */, 146 /* SetKeyword */]); - case 130 /* AwaitKeyword */: + case 133 /* ConstructorKeyword */: + return getFromAllDeclarations(ts.isConstructorDeclaration, [133 /* ConstructorKeyword */]); + case 135 /* GetKeyword */: + case 147 /* SetKeyword */: + return getFromAllDeclarations(ts.isAccessor, [135 /* GetKeyword */, 147 /* SetKeyword */]); + case 131 /* AwaitKeyword */: return useParent(node.parent, ts.isAwaitExpression, getAsyncAndAwaitOccurrences); - case 129 /* AsyncKeyword */: + case 130 /* AsyncKeyword */: return highlightSpans(getAsyncAndAwaitOccurrences(node)); - case 124 /* YieldKeyword */: + case 125 /* YieldKeyword */: return highlightSpans(getYieldOccurrences(node)); default: return ts.isModifierKind(node.kind) && (ts.isDeclaration(node.parent) || ts.isVariableStatement(node.parent)) @@ -122301,7 +126906,7 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (ts.isFunctionBlock(parent) || parent.kind === 297 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 299 /* SourceFile */) { return parent; } // A throw-statement is only owned by a try-statement if the try-statement has @@ -122333,16 +126938,16 @@ var ts; function getBreakOrContinueOwner(statement) { return ts.findAncestor(statement, function (node) { switch (node.kind) { - case 244 /* SwitchStatement */: - if (statement.kind === 240 /* ContinueStatement */) { + case 246 /* SwitchStatement */: + if (statement.kind === 242 /* ContinueStatement */) { return false; } // falls through - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 236 /* WhileStatement */: - case 235 /* DoStatement */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 238 /* WhileStatement */: + case 237 /* DoStatement */: return !statement.label || isLabeledBy(node, statement.label.escapedText); default: // Don't cross function boundaries. @@ -122358,11 +126963,11 @@ var ts; // Types of node whose children might have modifiers. var container = declaration.parent; switch (container.kind) { - case 257 /* ModuleBlock */: - case 297 /* SourceFile */: - case 230 /* Block */: - case 284 /* CaseClause */: - case 285 /* DefaultClause */: + case 259 /* ModuleBlock */: + case 299 /* SourceFile */: + case 232 /* Block */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 128 /* Abstract */ && ts.isClassDeclaration(declaration)) { return __spreadArray(__spreadArray([], declaration.members), [declaration]); @@ -122370,14 +126975,14 @@ var ts; else { return container.statements; } - case 166 /* Constructor */: - case 165 /* MethodDeclaration */: - case 251 /* FunctionDeclaration */: + case 168 /* Constructor */: + case 167 /* MethodDeclaration */: + case 253 /* FunctionDeclaration */: return __spreadArray(__spreadArray([], container.parameters), (ts.isClassLike(container.parent) ? container.parent.members : [])); - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 177 /* TypeLiteral */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: + case 179 /* 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. @@ -122392,7 +126997,7 @@ var ts; } return nodes; // Syntactically invalid positions that the parser might produce anyway - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return undefined; default: ts.Debug.assertNever(container, "Invalid container kind."); @@ -122411,12 +127016,12 @@ var ts; } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 96 /* ForKeyword */, 114 /* WhileKeyword */, 89 /* DoKeyword */)) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 97 /* ForKeyword */, 115 /* WhileKeyword */, 90 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 235 /* DoStatement */) { + if (loopNode.kind === 237 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 114 /* WhileKeyword */)) { + if (pushKeywordIf(keywords, loopTokens[i], 115 /* WhileKeyword */)) { break; } } @@ -122424,7 +127029,7 @@ var ts; } ts.forEach(aggregateAllBreakAndContinueStatements(loopNode.statement), function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 80 /* BreakKeyword */, 85 /* ContinueKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 81 /* BreakKeyword */, 86 /* ContinueKeyword */); } }); return keywords; @@ -122433,13 +127038,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -122447,13 +127052,13 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 106 /* SwitchKeyword */); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 107 /* 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(), 81 /* CaseKeyword */, 87 /* DefaultKeyword */); + pushKeywordIf(keywords, clause.getFirstToken(), 82 /* CaseKeyword */, 88 /* DefaultKeyword */); ts.forEach(aggregateAllBreakAndContinueStatements(clause), function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 80 /* BreakKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 81 /* BreakKeyword */); } }); }); @@ -122461,13 +127066,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement, sourceFile) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 110 /* TryKeyword */); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 111 /* TryKeyword */); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 82 /* CatchKeyword */); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 83 /* CatchKeyword */); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 95 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 95 /* FinallyKeyword */); + var finallyKeyword = ts.findChildOfKind(tryStatement, 96 /* FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 96 /* FinallyKeyword */); } return keywords; } @@ -122478,13 +127083,13 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - keywords.push(ts.findChildOfKind(throwStatement, 108 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 109 /* 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, 104 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 105 /* ReturnKeyword */, sourceFile)); }); } return keywords; @@ -122496,11 +127101,11 @@ var ts; } var keywords = []; ts.forEachReturnStatement(ts.cast(func.body, ts.isBlock), function (returnStatement) { - keywords.push(ts.findChildOfKind(returnStatement, 104 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 105 /* 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, 108 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 109 /* ThrowKeyword */, sourceFile)); }); return keywords; } @@ -122512,13 +127117,13 @@ var ts; var keywords = []; if (func.modifiers) { func.modifiers.forEach(function (modifier) { - pushKeywordIf(keywords, modifier, 129 /* AsyncKeyword */); + pushKeywordIf(keywords, modifier, 130 /* AsyncKeyword */); }); } ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isAwaitExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 130 /* AwaitKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 131 /* AwaitKeyword */); } }); }); @@ -122533,7 +127138,7 @@ var ts; ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isYieldExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 124 /* YieldKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 125 /* YieldKeyword */); } }); }); @@ -122552,7 +127157,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 === 90 /* ElseKeyword */ && i < keywords.length - 1) { + if (keywords[i].kind === 91 /* ElseKeyword */ && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. var shouldCombineElseAndIf = true; @@ -122587,10 +127192,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], 98 /* IfKeyword */); + pushKeywordIf(keywords, children[0], 99 /* 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], 90 /* ElseKeyword */)) { + if (pushKeywordIf(keywords, children[i], 91 /* ElseKeyword */)) { break; } } @@ -122612,6 +127217,9 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + function isDocumentRegistryEntry(entry) { + return !!entry.sourceFile; + } function createDocumentRegistry(useCaseSensitiveFileNames, currentDirectory) { return createDocumentRegistryInternal(useCaseSensitiveFileNames, currentDirectory); } @@ -122628,10 +127236,16 @@ var ts; var entries = buckets.get(name); var sourceFiles = []; entries.forEach(function (entry, name) { - sourceFiles.push({ - name: name, - refCount: entry.languageServiceRefCount - }); + if (isDocumentRegistryEntry(entry)) { + sourceFiles.push({ + name: name, + scriptKind: entry.sourceFile.scriptKind, + refCount: entry.languageServiceRefCount + }); + } + else { + entry.forEach(function (value, scriptKind) { return sourceFiles.push({ name: name, scriptKind: scriptKind, refCount: value.languageServiceRefCount }); }); + } }); sourceFiles.sort(function (x, y) { return y.refCount - x.refCount; }); return { @@ -122657,10 +127271,17 @@ var ts; function updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind) { return acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, /*acquiring*/ false, scriptKind); } + 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); + return entry; + } function acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, acquiring, scriptKind) { - var bucket = ts.getOrUpdate(buckets, key, function () { return new ts.Map(); }); - var entry = bucket.get(path); + scriptKind = ts.ensureScriptKind(fileName, scriptKind); var scriptTarget = scriptKind === 6 /* JSON */ ? 100 /* JSON */ : compilationSettings.target || 1 /* ES5 */; + var bucket = ts.getOrUpdate(buckets, key, function () { return new ts.Map(); }); + var bucketEntry = bucket.get(path); + var entry = bucketEntry && getDocumentRegistryEntry(bucketEntry, scriptKind); if (!entry && externalCache) { var sourceFile = externalCache.getDocument(key, path); if (sourceFile) { @@ -122669,7 +127290,7 @@ var ts; sourceFile: sourceFile, languageServiceRefCount: 0 }; - bucket.set(path, entry); + setBucketEntry(); } } if (!entry) { @@ -122682,7 +127303,7 @@ var ts; sourceFile: sourceFile, languageServiceRefCount: 1, }; - bucket.set(path, entry); + setBucketEntry(); } else { // We have an entry for this file. However, it may be for a different version of @@ -122705,25 +127326,49 @@ var ts; } ts.Debug.assert(entry.languageServiceRefCount !== 0); return entry.sourceFile; + function setBucketEntry() { + if (!bucketEntry) { + bucket.set(path, entry); + } + else if (isDocumentRegistryEntry(bucketEntry)) { + var scriptKindMap = new ts.Map(); + scriptKindMap.set(bucketEntry.sourceFile.scriptKind, bucketEntry); + scriptKindMap.set(scriptKind, entry); + bucket.set(path, scriptKindMap); + } + else { + bucketEntry.set(scriptKind, entry); + } + } } - function releaseDocument(fileName, compilationSettings) { + function releaseDocument(fileName, compilationSettings, scriptKind) { var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); var key = getKeyForCompilationSettings(compilationSettings); - return releaseDocumentWithKey(path, key); + return releaseDocumentWithKey(path, key, scriptKind); } - function releaseDocumentWithKey(path, key) { + function releaseDocumentWithKey(path, key, scriptKind) { var bucket = ts.Debug.checkDefined(buckets.get(key)); - var entry = bucket.get(path); + var bucketEntry = bucket.get(path); + var entry = getDocumentRegistryEntry(bucketEntry, scriptKind); entry.languageServiceRefCount--; ts.Debug.assert(entry.languageServiceRefCount >= 0); if (entry.languageServiceRefCount === 0) { - bucket.delete(path); + if (isDocumentRegistryEntry(bucketEntry)) { + bucket.delete(path); + } + else { + bucketEntry.delete(scriptKind); + if (bucketEntry.size === 1) { + bucket.set(path, ts.firstDefinedIterator(bucketEntry.values(), ts.identity)); + } + } } } - function getLanguageServiceRefCounts(path) { + function getLanguageServiceRefCounts(path, scriptKind) { return ts.arrayFrom(buckets.entries(), function (_a) { var key = _a[0], bucket = _a[1]; - var entry = bucket.get(path); + var bucketEntry = bucket.get(path); + var entry = bucketEntry && getDocumentRegistryEntry(bucketEntry, scriptKind); return [key, entry && entry.languageServiceRefCount]; }); } @@ -122786,10 +127431,12 @@ var ts; return sourceFiles; } // Module augmentations may use this module's exports without importing it. - for (var _i = 0, _a = exportingModuleSymbol.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - if (ts.isExternalModuleAugmentation(decl) && sourceFilesSet.has(decl.getSourceFile().fileName)) { - addIndirectUser(decl); + if (exportingModuleSymbol.declarations) { + for (var _i = 0, _a = exportingModuleSymbol.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + if (ts.isExternalModuleAugmentation(decl) && sourceFilesSet.has(decl.getSourceFile().fileName)) { + addIndirectUser(decl); + } } } // This may return duplicates (if there are multiple module declarations in a single source file, all importing the same thing as a namespace), but `State.markSearchedSymbol` will handle that. @@ -122806,43 +127453,43 @@ var ts; if (cancellationToken) cancellationToken.throwIfCancellationRequested(); switch (direct.kind) { - case 203 /* CallExpression */: + case 205 /* CallExpression */: if (ts.isImportCall(direct)) { handleImportCall(direct); break; } if (!isAvailableThroughGlobal) { var parent = direct.parent; - if (exportKind === 2 /* ExportEquals */ && parent.kind === 249 /* VariableDeclaration */) { + if (exportKind === 2 /* ExportEquals */ && parent.kind === 251 /* VariableDeclaration */) { var name = parent.name; - if (name.kind === 78 /* Identifier */) { + if (name.kind === 79 /* Identifier */) { directImports.push(name); break; } } } break; - case 78 /* Identifier */: // for 'const x = require("y"); + case 79 /* Identifier */: // for 'const x = require("y"); break; // TODO: GH#23879 - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: handleNamespaceImport(direct, direct.name, ts.hasSyntacticModifier(direct, 1 /* Export */), /*alreadyAddedDirect*/ false); break; - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: directImports.push(direct); var namedBindings = direct.importClause && direct.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 263 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 265 /* 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 267 /* ExportDeclaration */: + case 269 /* 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 === 269 /* NamespaceExport */) { + else if (direct.exportClause.kind === 271 /* NamespaceExport */) { // `export * as foo from "foo"` add to indirect uses addIndirectUser(getSourceFileLikeForImportDeclaration(direct), /** addTransitiveDependencies */ true); } @@ -122851,7 +127498,7 @@ var ts; directImports.push(direct); } break; - case 195 /* ImportType */: + case 197 /* ImportType */: // Only check for typeof import('xyz') if (direct.isTypeOf && !direct.qualifier && isExported(direct)) { addIndirectUser(direct.getSourceFile(), /** addTransitiveDependencies */ true); @@ -122873,7 +127520,7 @@ var ts; return ts.findAncestor(node, function (node) { if (stopAtAmbientModule && isAmbientModuleDeclaration(node)) return "quit"; - return ts.some(node.modifiers, function (mod) { return mod.kind === 92 /* ExportKeyword */; }); + return ts.some(node.modifiers, function (mod) { return mod.kind === 93 /* ExportKeyword */; }); }); } function handleNamespaceImport(importDeclaration, name, isReExport, alreadyAddedDirect) { @@ -122884,7 +127531,7 @@ var ts; } else if (!isAvailableThroughGlobal) { var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); - ts.Debug.assert(sourceFileLike.kind === 297 /* SourceFile */ || sourceFileLike.kind === 256 /* ModuleDeclaration */); + ts.Debug.assert(sourceFileLike.kind === 299 /* SourceFile */ || sourceFileLike.kind === 258 /* ModuleDeclaration */); if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { addIndirectUser(sourceFileLike, /** addTransitiveDependencies */ true); } @@ -122940,17 +127587,17 @@ var ts; } return { importSearches: importSearches, singleReferences: singleReferences }; function handleImport(decl) { - if (decl.kind === 260 /* ImportEqualsDeclaration */) { + if (decl.kind === 262 /* ImportEqualsDeclaration */) { if (isExternalModuleImportEquals(decl)) { handleNamespaceImportLike(decl.name); } return; } - if (decl.kind === 78 /* Identifier */) { + if (decl.kind === 79 /* Identifier */) { handleNamespaceImportLike(decl); return; } - if (decl.kind === 195 /* ImportType */) { + if (decl.kind === 197 /* ImportType */) { if (decl.qualifier) { var firstIdentifier = ts.getFirstIdentifier(decl.qualifier); if (firstIdentifier.escapedText === ts.symbolName(exportSymbol)) { @@ -122966,7 +127613,7 @@ var ts; if (decl.moduleSpecifier.kind !== 10 /* StringLiteral */) { return; } - if (decl.kind === 267 /* ExportDeclaration */) { + if (decl.kind === 269 /* ExportDeclaration */) { if (decl.exportClause && ts.isNamedExports(decl.exportClause)) { searchForNamedImport(decl.exportClause); } @@ -122975,10 +127622,10 @@ var ts; var _a = decl.importClause || { name: undefined, namedBindings: undefined }, name = _a.name, namedBindings = _a.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: handleNamespaceImportLike(namedBindings.name); break; - case 264 /* NamedImports */: + case 266 /* NamedImports */: // 'default' might be accessed as a named import `{ default as foo }`. if (exportKind === 0 /* Named */ || exportKind === 1 /* Default */) { searchForNamedImport(namedBindings); @@ -123028,7 +127675,7 @@ var ts; } } else { - var localSymbol = element.kind === 270 /* ExportSpecifier */ && element.propertyName + var localSymbol = element.kind === 272 /* 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); @@ -123057,7 +127704,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.kind === 297 /* SourceFile */) { + if ((searchSourceFile === null || searchSourceFile === void 0 ? void 0 : searchSourceFile.kind) === 299 /* SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { var ref = _b[_a]; if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) { @@ -123105,7 +127752,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 === 297 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return ts.forEach(sourceFileLike.kind === 299 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); }); } @@ -123120,15 +127767,15 @@ var ts; else { forEachPossibleImportOrExportStatement(sourceFile, function (statement) { switch (statement.kind) { - case 267 /* ExportDeclaration */: - case 261 /* ImportDeclaration */: { + case 269 /* ExportDeclaration */: + case 263 /* ImportDeclaration */: { var decl = statement; if (decl.moduleSpecifier && ts.isStringLiteral(decl.moduleSpecifier)) { action(decl, decl.moduleSpecifier); } break; } - case 260 /* ImportEqualsDeclaration */: { + case 262 /* ImportEqualsDeclaration */: { var decl = statement; if (isExternalModuleImportEquals(decl)) { action(decl, decl.moduleReference.expression); @@ -123149,14 +127796,15 @@ var ts; function getImportOrExportSymbol(node, symbol, checker, comingFromExport) { return comingFromExport ? getExport() : getExport() || getImport(); function getExport() { + var _a; var parent = node.parent; - var grandParent = parent.parent; + var grandparent = parent.parent; if (symbol.exportSymbol) { - if (parent.kind === 201 /* PropertyAccessExpression */) { + if (parent.kind === 203 /* 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 symbol.declarations.some(function (d) { return d === parent; }) && ts.isBinaryExpression(grandParent) - ? getSpecialPropertyExport(grandParent, /*useLhsSymbol*/ false) + return ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d === parent; })) && ts.isBinaryExpression(grandparent) + ? getSpecialPropertyExport(grandparent, /*useLhsSymbol*/ false) : undefined; } else { @@ -123186,15 +127834,15 @@ var ts; return getExportAssignmentExport(parent); } // If we are in `export = class A {};` (or `export = class A {};`) at `A`, `parent.parent` is the export assignment. - else if (ts.isExportAssignment(grandParent)) { - return getExportAssignmentExport(grandParent); + else if (ts.isExportAssignment(grandparent)) { + return getExportAssignmentExport(grandparent); } // Similar for `module.exports =` and `exports.A =`. else if (ts.isBinaryExpression(parent)) { return getSpecialPropertyExport(parent, /*useLhsSymbol*/ true); } - else if (ts.isBinaryExpression(grandParent)) { - return getSpecialPropertyExport(grandParent, /*useLhsSymbol*/ true); + else if (ts.isBinaryExpression(grandparent)) { + return getSpecialPropertyExport(grandparent, /*useLhsSymbol*/ true); } else if (ts.isJSDocTypedefTag(parent)) { return exportInfo(symbol, 0 /* Named */); @@ -123202,9 +127850,10 @@ var ts; } function getExportAssignmentExport(ex) { // Get the symbol for the `export =` node; its parent is the module it's the export of. - var exportingModuleSymbol = ts.Debug.checkDefined(ex.symbol.parent, "Expected export symbol to have a parent"); + if (!ex.symbol.parent) + return undefined; var exportKind = ex.isExportEquals ? 2 /* ExportEquals */ : 1 /* Default */; - return { kind: 1 /* Export */, symbol: symbol, exportInfo: { exportingModuleSymbol: exportingModuleSymbol, exportKind: exportKind } }; + return { kind: 1 /* Export */, symbol: symbol, exportInfo: { exportingModuleSymbol: ex.symbol.parent, exportKind: exportKind } }; } function getSpecialPropertyExport(node, useLhsSymbol) { var kind; @@ -123258,7 +127907,7 @@ var ts; if (importedSymbol.flags & 2097152 /* Alias */) { return ts.Debug.checkDefined(checker.getImmediateAliasedSymbol(importedSymbol)); } - var decl = importedSymbol.valueDeclaration; + var decl = ts.Debug.checkDefined(importedSymbol.valueDeclaration); if (ts.isExportAssignment(decl)) { // `export = class {}` return ts.Debug.checkDefined(decl.expression.symbol); } @@ -123285,17 +127934,17 @@ var ts; function isNodeImport(node) { var parent = node.parent; switch (parent.kind) { - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return parent.name === node && isExternalModuleImportEquals(parent); - case 265 /* ImportSpecifier */: + case 267 /* 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 262 /* ImportClause */: - case 263 /* NamespaceImport */: + case 264 /* ImportClause */: + case 265 /* NamespaceImport */: ts.Debug.assert(parent.name === node); return true; - case 198 /* BindingElement */: - return ts.isInJSFile(node) && ts.isRequireVariableDeclaration(parent, /*requireStringLiteralLikeArgument*/ true); + case 200 /* BindingElement */: + return ts.isInJSFile(node) && ts.isRequireVariableDeclaration(parent); default: return false; } @@ -123319,7 +127968,8 @@ var ts; return checker.getExportSpecifierLocalTargetSymbol(declaration); } else if (ts.isPropertyAccessExpression(declaration) && ts.isModuleExportsAccessExpression(declaration.expression) && !ts.isPrivateIdentifier(declaration.name)) { - return checker.getExportSpecifierLocalTargetSymbol(declaration.name); + // Export of form 'module.exports.propName = expr'; + return checker.getSymbolAtLocation(declaration); } else if (ts.isShorthandPropertyAssignment(declaration) && ts.isBinaryExpression(declaration.parent.parent) @@ -123334,21 +127984,21 @@ var ts; return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol); } function getSourceFileLikeForImportDeclaration(node) { - if (node.kind === 203 /* CallExpression */) { + if (node.kind === 205 /* CallExpression */) { return node.getSourceFile(); } var parent = node.parent; - if (parent.kind === 297 /* SourceFile */) { + if (parent.kind === 299 /* SourceFile */) { return parent; } - ts.Debug.assert(parent.kind === 257 /* ModuleBlock */); + ts.Debug.assert(parent.kind === 259 /* ModuleBlock */); return ts.cast(parent.parent, isAmbientModuleDeclaration); } function isAmbientModuleDeclaration(node) { - return node.kind === 256 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; + return node.kind === 258 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; } function isExternalModuleImportEquals(eq) { - return eq.moduleReference.kind === 272 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; + return eq.moduleReference.kind === 274 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); @@ -123442,7 +128092,7 @@ var ts; ((ts.isImportOrExportSpecifier(node.parent) || ts.isBindingElement(node.parent)) && node.parent.propertyName === node) || // Is default export - (node.kind === 87 /* DefaultKeyword */ && ts.hasSyntacticModifier(node.parent, 513 /* ExportDefault */))) { + (node.kind === 88 /* DefaultKeyword */ && ts.hasSyntacticModifier(node.parent, 513 /* ExportDefault */))) { return getContextNode(node.parent); } return undefined; @@ -123451,7 +128101,7 @@ var ts; if (!node) return undefined; switch (node.kind) { - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return !ts.isVariableDeclarationList(node.parent) || node.parent.declarations.length !== 1 ? node : ts.isVariableStatement(node.parent.parent) ? @@ -123459,28 +128109,28 @@ var ts; ts.isForInOrOfStatement(node.parent.parent) ? getContextNode(node.parent.parent) : node.parent; - case 198 /* BindingElement */: + case 200 /* BindingElement */: return getContextNode(node.parent.parent); - case 265 /* ImportSpecifier */: + case 267 /* ImportSpecifier */: return node.parent.parent.parent; - case 270 /* ExportSpecifier */: - case 263 /* NamespaceImport */: + case 272 /* ExportSpecifier */: + case 265 /* NamespaceImport */: return node.parent.parent; - case 262 /* ImportClause */: - case 269 /* NamespaceExport */: + case 264 /* ImportClause */: + case 271 /* NamespaceExport */: return node.parent; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return ts.isExpressionStatement(node.parent) ? node.parent : node; - case 239 /* ForOfStatement */: - case 238 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 240 /* ForInStatement */: return { start: node.initializer, end: node.expression }; - case 288 /* PropertyAssignment */: - case 289 /* ShorthandPropertyAssignment */: + case 290 /* PropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent) ? getContextNode(ts.findAncestor(node.parent, function (node) { return ts.isBinaryExpression(node) || ts.isForInOrOfStatement(node); @@ -123537,10 +128187,10 @@ var ts; var node = ts.getTouchingPropertyName(sourceFile, position); var referenceEntries; var entries = getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position); - if (node.parent.kind === 201 /* PropertyAccessExpression */ - || node.parent.kind === 198 /* BindingElement */ - || node.parent.kind === 202 /* ElementAccessExpression */ - || node.kind === 105 /* SuperKeyword */) { + if (node.parent.kind === 203 /* PropertyAccessExpression */ + || node.parent.kind === 200 /* BindingElement */ + || node.parent.kind === 204 /* ElementAccessExpression */ + || node.kind === 106 /* SuperKeyword */) { referenceEntries = entries && __spreadArray([], entries); } else { @@ -123563,18 +128213,18 @@ var ts; } FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) { - if (node.kind === 297 /* SourceFile */) { + if (node.kind === 299 /* 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 === 289 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 291 /* ShorthandPropertyAssignment */) { var result_1 = []; Core.getReferenceEntriesForShorthandPropertyAssignment(node, checker, function (node) { return result_1.push(nodeEntry(node)); }); return result_1; } - else if (node.kind === 105 /* SuperKeyword */ || ts.isSuperProperty(node.parent)) { + else if (node.kind === 106 /* 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); @@ -123744,13 +128394,13 @@ var ts; if (symbol) { return getDefinitionKindAndDisplayParts(symbol, checker, node); } - else if (node.kind === 200 /* ObjectLiteralExpression */) { + else if (node.kind === 202 /* ObjectLiteralExpression */) { return { kind: "interface" /* interfaceElement */, displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(21 /* CloseParenToken */)] }; } - else if (node.kind === 221 /* ClassExpression */) { + else if (node.kind === 223 /* ClassExpression */) { return { kind: "local class" /* localClassElement */, displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(21 /* CloseParenToken */)] @@ -123794,13 +128444,13 @@ var ts; /** 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 === 87 /* DefaultKeyword */ || ts.isWriteAccess(node); + return !!decl && declarationIsWriteAccess(decl) || node.kind === 88 /* DefaultKeyword */ || ts.isWriteAccess(node); } function isDefinitionForReference(node) { - return node.kind === 87 /* DefaultKeyword */ + return node.kind === 88 /* DefaultKeyword */ || !!ts.getDeclarationFromName(node) || ts.isLiteralComputedPropertyDeclarationName(node) - || (node.kind === 132 /* ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent)); + || (node.kind === 133 /* ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent)); } /** * True if 'decl' provides a value, as in `function f() {}`; @@ -123811,47 +128461,47 @@ var ts; if (!!(decl.flags & 8388608 /* Ambient */)) return true; switch (decl.kind) { - case 216 /* BinaryExpression */: - case 198 /* BindingElement */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 87 /* DefaultKeyword */: - case 255 /* EnumDeclaration */: - case 291 /* EnumMember */: - case 270 /* ExportSpecifier */: - case 262 /* ImportClause */: // default import - case 260 /* ImportEqualsDeclaration */: - case 265 /* ImportSpecifier */: - case 253 /* InterfaceDeclaration */: - case 324 /* JSDocCallbackTag */: - case 331 /* JSDocTypedefTag */: - case 280 /* JsxAttribute */: - case 256 /* ModuleDeclaration */: - case 259 /* NamespaceExportDeclaration */: - case 263 /* NamespaceImport */: - case 269 /* NamespaceExport */: - case 160 /* Parameter */: - case 289 /* ShorthandPropertyAssignment */: - case 254 /* TypeAliasDeclaration */: - case 159 /* TypeParameter */: + case 218 /* BinaryExpression */: + case 200 /* BindingElement */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 88 /* DefaultKeyword */: + case 257 /* EnumDeclaration */: + case 293 /* EnumMember */: + case 272 /* ExportSpecifier */: + case 264 /* ImportClause */: // default import + case 262 /* ImportEqualsDeclaration */: + case 267 /* ImportSpecifier */: + case 255 /* InterfaceDeclaration */: + case 332 /* JSDocCallbackTag */: + case 339 /* JSDocTypedefTag */: + case 282 /* JsxAttribute */: + case 258 /* ModuleDeclaration */: + case 261 /* NamespaceExportDeclaration */: + case 265 /* NamespaceImport */: + case 271 /* NamespaceExport */: + case 162 /* Parameter */: + case 291 /* ShorthandPropertyAssignment */: + case 256 /* TypeAliasDeclaration */: + case 161 /* TypeParameter */: return true; - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: // In `({ x: y } = 0);`, `x` is not a write access. (Won't call this function for `y`.) return !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(decl.parent); - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 166 /* Constructor */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 168 /* Constructor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return !!decl.body; - case 249 /* VariableDeclaration */: - case 163 /* PropertyDeclaration */: + case 251 /* VariableDeclaration */: + case 165 /* PropertyDeclaration */: return !!decl.initializer || ts.isCatchClause(decl.parent); - case 164 /* MethodSignature */: - case 162 /* PropertySignature */: - case 333 /* JSDocPropertyTag */: - case 326 /* JSDocParameterTag */: + case 166 /* MethodSignature */: + case 164 /* PropertySignature */: + case 341 /* JSDocPropertyTag */: + case 334 /* JSDocParameterTag */: return false; default: return ts.Debug.failBadSyntaxKind(decl); @@ -123873,7 +128523,7 @@ var ts; } if (ts.isSourceFile(node)) { var resolvedRef = ts.GoToDefinition.getReferenceAtPosition(node, position, program); - if (!resolvedRef) { + if (!(resolvedRef === null || resolvedRef === void 0 ? void 0 : resolvedRef.file)) { return undefined; } var moduleSymbol = program.getTypeChecker().getMergedSymbol(resolvedRef.file.symbol); @@ -123902,7 +128552,7 @@ var ts; if (!symbol) { // String literal might be a property (and thus have a symbol), so do this here rather than in getReferencedSymbolsSpecial. if (!options.implementations && ts.isStringLiteralLike(node)) { - if (ts.isRequireCall(node.parent, /*requireStringLiteralLikeArgument*/ true) || ts.isExternalModuleReference(node.parent) || ts.isImportDeclaration(node.parent) || ts.isImportCall(node.parent)) { + if (ts.isModuleSpecifierLike(node)) { var fileIncludeReasons = program.getFileIncludeReasons(); var referencedFileName = (_b = (_a = node.getSourceFile().resolvedModules) === null || _a === void 0 ? void 0 : _a.get(node.text)) === null || _b === void 0 ? void 0 : _b.resolvedFileName; var referencedFile = referencedFileName ? program.getSourceFile(referencedFileName) : undefined; @@ -124003,7 +128653,7 @@ var ts; result = references; continue; } - var _loop_3 = function (entry) { + var _loop_4 = function (entry) { if (!entry.definition || entry.definition.type !== 0 /* Symbol */) { result.push(entry); return "continue"; @@ -124035,7 +128685,7 @@ var ts; }; for (var _b = 0, references_2 = references; _b < references_2.length; _b++) { var entry = references_2[_b]; - _loop_3(entry); + _loop_4(entry); } } return result; @@ -124072,10 +128722,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; switch (decl.kind) { - case 297 /* SourceFile */: + case 299 /* 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 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: if (sourceFilesSet.has(decl.getSourceFile().fileName)) { references.push(nodeEntry(decl.name)); } @@ -124087,14 +128737,14 @@ var ts; } } var exported = symbol.exports.get("export=" /* ExportEquals */); - if (exported) { + 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]; var sourceFile = decl.getSourceFile(); 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, 92 /* ExportKeyword */, sourceFile)) : + ts.isExportAssignment(decl) ? ts.Debug.checkDefined(ts.findChildOfKind(decl, 93 /* ExportKeyword */, sourceFile)) : ts.getNameOfDeclaration(decl) || decl; references.push(nodeEntry(node)); } @@ -124104,25 +128754,25 @@ var ts; } /** As in a `readonly prop: any` or `constructor(readonly prop: any)`, not a `readonly any[]`. */ function isReadonlyTypeOperator(node) { - return node.kind === 142 /* ReadonlyKeyword */ + return node.kind === 143 /* ReadonlyKeyword */ && ts.isTypeOperatorNode(node.parent) - && node.parent.operator === 142 /* ReadonlyKeyword */; + && node.parent.operator === 143 /* 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 === 113 /* VoidKeyword */ && ts.isVoidExpression(node.parent)) { + if (node.kind === 114 /* 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 === 142 /* ReadonlyKeyword */ && !isReadonlyTypeOperator(node)) { + if (node.kind === 143 /* 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 === 142 /* ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined); + return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken, node.kind === 143 /* ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined); } // Labels if (ts.isJumpStatementTarget(node)) { @@ -124138,7 +128788,7 @@ var ts; if (ts.isThis(node)) { return getReferencesForThisKeyword(node, sourceFiles, cancellationToken); } - if (node.kind === 105 /* SuperKeyword */) { + if (node.kind === 106 /* SuperKeyword */) { return getReferencesForSuperKeyword(node); } return undefined; @@ -124150,14 +128800,14 @@ var ts; var searchMeaning = node ? getIntersectingMeaningFromDeclarations(node, symbol) : 7 /* All */; var result = []; var state = new State(sourceFiles, sourceFilesSet, node ? getSpecialSearchKind(node) : 0 /* None */, checker, cancellationToken, searchMeaning, options, result); - var exportSpecifier = !isForRenameWithPrefixAndSuffixText(options) ? undefined : ts.find(symbol.declarations, ts.isExportSpecifier); + 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 === 87 /* DefaultKeyword */) { + else if (node && node.kind === 88 /* DefaultKeyword */ && symbol.escapedName === "default" /* Default */ && symbol.parent) { addReference(node, symbol, state); - searchForImportsOfExport(node, symbol, { exportingModuleSymbol: ts.Debug.checkDefined(symbol.parent, "Expected export symbol to have a parent"), exportKind: 1 /* Default */ }, state); + searchForImportsOfExport(node, symbol, { exportingModuleSymbol: symbol.parent, exportKind: 1 /* 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] }); @@ -124183,10 +128833,10 @@ var ts; } function getSpecialSearchKind(node) { switch (node.kind) { - case 166 /* Constructor */: - case 132 /* ConstructorKeyword */: + case 168 /* Constructor */: + case 133 /* ConstructorKeyword */: return 1 /* Constructor */; - case 78 /* Identifier */: + case 79 /* Identifier */: if (ts.isClassLike(node.parent)) { ts.Debug.assert(node.parent.name === node); return 2 /* Class */; @@ -124314,8 +128964,8 @@ var ts; var sourceId = ts.getNodeId(sourceFile); var seenSymbols = this.sourceFileToSeenSymbols[sourceId] || (this.sourceFileToSeenSymbols[sourceId] = new ts.Set()); var anyNewSymbols = false; - for (var _i = 0, symbols_3 = symbols; _i < symbols_3.length; _i++) { - var sym = symbols_3[_i]; + for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) { + var sym = symbols_2[_i]; anyNewSymbols = ts.tryAddToSet(seenSymbols, ts.getSymbolId(sym)) || anyNewSymbols; } return anyNewSymbols; @@ -124372,7 +129022,9 @@ var ts; for (var _c = 0, _d = getPossibleSymbolReferenceNodes(indirectUser, isDefaultExport ? "default" : exportName); _c < _d.length; _c++) { var node = _d[_c]; // Import specifiers should be handled by importSearches - if (ts.isIdentifier(node) && !ts.isImportOrExportSpecifier(node.parent) && checker.getSymbolAtLocation(node) === exportSymbol) { + var symbol = checker.getSymbolAtLocation(node); + var hasExportAssignmentDeclaration = ts.some(symbol === null || symbol === void 0 ? void 0 : symbol.declarations, function (d) { return ts.tryCast(d, ts.isExportAssignment) ? true : false; }); + if (ts.isIdentifier(node) && !ts.isImportOrExportSpecifier(node.parent) && (symbol === exportSymbol || hasExportAssignmentDeclaration)) { cb(node); } } @@ -124424,7 +129076,7 @@ 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 === 208 /* FunctionExpression */ || valueDeclaration.kind === 221 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 210 /* FunctionExpression */ || valueDeclaration.kind === 223 /* ClassExpression */)) { return valueDeclaration; } if (!declarations) { @@ -124432,9 +129084,9 @@ var ts; } // 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.isPrivateIdentifierPropertyDeclaration(d); }); + var privateDeclaration = ts.find(declarations, function (d) { return ts.hasEffectiveModifier(d, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(d); }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 252 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 254 /* ClassDeclaration */); } // Else this is a public property and could be accessed from anywhere. return undefined; @@ -124463,7 +129115,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (!container || container.kind === 297 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { + if (!container || container.kind === 299 /* 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; @@ -124579,8 +129231,12 @@ var ts; function isValidReferencePosition(node, searchSymbolName) { // Compare the length so we filter out strict superstrings of the symbol we are looking for switch (node.kind) { - case 79 /* PrivateIdentifier */: - case 78 /* Identifier */: + case 80 /* PrivateIdentifier */: + if (ts.isJSDocMemberName(node.parent)) { + return true; + } + // falls through I guess + case 79 /* Identifier */: return node.text.length === searchSymbolName.length; case 14 /* NoSubstitutionTemplateLiteral */: case 10 /* StringLiteral */: { @@ -124590,7 +129246,7 @@ var ts; } case 8 /* NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.text.length === searchSymbolName.length; - case 87 /* DefaultKeyword */: + case 88 /* DefaultKeyword */: return "default".length === searchSymbolName.length; default: return false; @@ -124656,7 +129312,7 @@ var ts; return; } if (ts.isExportSpecifier(parent)) { - ts.Debug.assert(referenceLocation.kind === 78 /* Identifier */); + ts.Debug.assert(referenceLocation.kind === 79 /* Identifier */); getReferencesAtExportSpecifier(referenceLocation, referenceSymbol, parent, search, state, addReferencesHere); return; } @@ -124679,6 +129335,10 @@ var ts; default: ts.Debug.assertNever(state.specialSearchKind); } + // Use the parent symbol if the location is commonjs require syntax on javascript files only. + referenceSymbol = ts.isInJSFile(referenceLocation) && referenceLocation.parent.kind === 200 /* BindingElement */ && ts.isRequireVariableDeclaration(referenceLocation.parent) + ? referenceLocation.parent.symbol + : referenceSymbol; getImportOrExportReferences(referenceLocation, referenceSymbol, search, state); } function getReferencesAtExportSpecifier(referenceLocation, referenceSymbol, exportSpecifier, search, state, addReferencesHere, alwaysGetReferences) { @@ -124712,8 +129372,8 @@ var ts; } // For `export { foo as bar }`, rename `foo`, but not `bar`. if (!isForRenameWithPrefixAndSuffixText(state.options) || alwaysGetReferences) { - var isDefaultExport = referenceLocation.originalKeywordKind === 87 /* DefaultKeyword */ - || exportSpecifier.name.originalKeywordKind === 87 /* DefaultKeyword */; + var isDefaultExport = referenceLocation.originalKeywordKind === 88 /* DefaultKeyword */ + || exportSpecifier.name.originalKeywordKind === 88 /* DefaultKeyword */; var exportKind = isDefaultExport ? 1 /* Default */ : 0 /* Named */; var exportSymbol = ts.Debug.checkDefined(exportSpecifier.symbol); var exportInfo = FindAllReferences.getExportInfo(exportSymbol, exportKind, state.checker); @@ -124794,7 +129454,7 @@ var ts; } var pusher = function () { return state.referenceAdder(search.symbol); }; if (ts.isClassLike(referenceLocation.parent)) { - ts.Debug.assert(referenceLocation.kind === 87 /* DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); + ts.Debug.assert(referenceLocation.kind === 88 /* DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); // This is the class declaration containing the constructor. findOwnConstructorReferences(search.symbol, sourceFile, pusher()); } @@ -124821,7 +129481,7 @@ var ts; } if (member.body) { member.body.forEachChild(function cb(node) { - if (node.kind === 107 /* ThisKeyword */) { + if (node.kind === 108 /* ThisKeyword */) { addRef(node); } else if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) { @@ -124840,18 +129500,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, 132 /* ConstructorKeyword */, sourceFile); - ts.Debug.assert(decl.kind === 166 /* Constructor */ && !!ctrKeyword); + var ctrKeyword = ts.findChildOfKind(decl, 133 /* ConstructorKeyword */, sourceFile); + ts.Debug.assert(decl.kind === 168 /* Constructor */ && !!ctrKeyword); addNode(ctrKeyword); } } if (classSymbol.exports) { classSymbol.exports.forEach(function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 165 /* MethodDeclaration */) { + if (decl && decl.kind === 167 /* MethodDeclaration */) { var body = decl.body; if (body) { - forEachDescendantOfKind(body, 107 /* ThisKeyword */, function (thisKeyword) { + forEachDescendantOfKind(body, 108 /* ThisKeyword */, function (thisKeyword) { if (ts.isNewExpressionTarget(thisKeyword)) { addNode(thisKeyword); } @@ -124872,10 +129532,10 @@ var ts; } for (var _i = 0, _a = constructor.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 166 /* Constructor */); + ts.Debug.assert(decl.kind === 168 /* Constructor */); var body = decl.body; if (body) { - forEachDescendantOfKind(body, 105 /* SuperKeyword */, function (node) { + forEachDescendantOfKind(body, 106 /* SuperKeyword */, function (node) { if (ts.isCallExpressionTarget(node)) { addNode(node); } @@ -124899,10 +129559,10 @@ var ts; addReference(refNode); return; } - if (refNode.kind !== 78 /* Identifier */) { + if (refNode.kind !== 79 /* Identifier */) { return; } - if (refNode.parent.kind === 289 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 291 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference); } @@ -124922,7 +129582,7 @@ var ts; } else if (ts.isFunctionLike(typeHavingNode) && typeHavingNode.body) { var body = typeHavingNode.body; - if (body.kind === 230 /* Block */) { + if (body.kind === 232 /* Block */) { ts.forEachReturnStatement(body, function (returnStatement) { if (returnStatement.expression) addIfImplementation(returnStatement.expression); @@ -124950,13 +129610,13 @@ var ts; */ function isImplementationExpression(node) { switch (node.kind) { - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return isImplementationExpression(node.expression); - case 209 /* ArrowFunction */: - case 208 /* FunctionExpression */: - case 200 /* ObjectLiteralExpression */: - case 221 /* ClassExpression */: - case 199 /* ArrayLiteralExpression */: + case 211 /* ArrowFunction */: + case 210 /* FunctionExpression */: + case 202 /* ObjectLiteralExpression */: + case 223 /* ClassExpression */: + case 201 /* ArrayLiteralExpression */: return true; default: return false; @@ -125009,13 +129669,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -125024,7 +129684,7 @@ var ts; } var sourceFile = searchSpaceNode.getSourceFile(); var references = ts.mapDefined(getPossibleSymbolReferenceNodes(sourceFile, "super", searchSpaceNode), function (node) { - if (node.kind !== 105 /* SuperKeyword */) { + if (node.kind !== 106 /* SuperKeyword */) { return; } var container = ts.getSuperContainer(node, /*stopOnFunctions*/ false); @@ -125036,41 +129696,43 @@ var ts; return [{ definition: { type: 0 /* Symbol */, symbol: searchSpaceNode.symbol }, references: references }]; } function isParameterName(node) { - return node.kind === 78 /* Identifier */ && node.parent.kind === 160 /* Parameter */ && node.parent.name === node; + return node.kind === 79 /* Identifier */ && node.parent.kind === 162 /* 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 */; switch (searchSpaceNode.kind) { - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { + staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); + searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning object literals break; } // falls through - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 297 /* SourceFile */: + case 299 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode) || isParameterName(thisOrSuperKeyword)) { return undefined; } // falls through - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 210 /* 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 === 297 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { + var references = ts.flatMap(searchSpaceNode.kind === 299 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { if (!ts.isThis(node)) { @@ -125078,19 +129740,20 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: return searchSpaceNode.symbol === container.symbol; - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: return ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol; - case 221 /* ClassExpression */: - case 252 /* ClassDeclaration */: - // Make sure the container belongs to the same class + case 223 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 202 /* 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.getSyntacticModifierFlags(container) & 32 /* Static */) === staticFlag; - case 297 /* SourceFile */: - return container.kind === 297 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); + case 299 /* SourceFile */: + return container.kind === 299 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); } }); }).map(function (n) { return nodeEntry(n); }); @@ -125200,7 +129863,7 @@ var ts; 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]); } - var exportSpecifier = ts.getDeclarationOfKind(symbol, 270 /* ExportSpecifier */); + var exportSpecifier = ts.getDeclarationOfKind(symbol, 272 /* ExportSpecifier */); if (!isForRenamePopulateSearchSymbolSet || exportSpecifier && !exportSpecifier.propertyName) { var localSymbol = exportSpecifier && checker.getExportSpecifierLocalTargetSymbol(exportSpecifier); if (localSymbol) { @@ -125245,7 +129908,7 @@ var ts; }); } function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker) { - var bindingElement = ts.getDeclarationOfKind(symbol, 198 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 200 /* BindingElement */); if (bindingElement && ts.isObjectBindingElementWithoutPropertyName(bindingElement)) { return ts.getPropertySymbolFromBindingElement(checker, bindingElement); } @@ -125449,7 +130112,7 @@ var ts; return ts.Debug.checkDefined(node.modifiers && ts.find(node.modifiers, isDefaultModifier)); } function isDefaultModifier(node) { - return node.kind === 87 /* DefaultKeyword */; + return node.kind === 88 /* DefaultKeyword */; } /** Gets the symbol for a call hierarchy declaration. */ function getSymbolOfCallHierarchyDeclaration(typeChecker, node) { @@ -125498,16 +130161,16 @@ var ts; return; } switch (node.kind) { - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 165 /* MethodDeclaration */: - if (node.parent.kind === 200 /* ObjectLiteralExpression */) { + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 167 /* MethodDeclaration */: + if (node.parent.kind === 202 /* 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 251 /* FunctionDeclaration */: - case 252 /* ClassDeclaration */: - case 256 /* ModuleDeclaration */: + case 253 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: + case 258 /* ModuleDeclaration */: if (ts.isModuleBlock(node.parent) && ts.isIdentifier(node.parent.parent.name)) { return node.parent.parent.name.getText(); } @@ -125712,56 +130375,56 @@ var ts; return; } switch (node.kind) { - case 78 /* Identifier */: - case 260 /* ImportEqualsDeclaration */: - case 261 /* ImportDeclaration */: - case 267 /* ExportDeclaration */: - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 79 /* Identifier */: + case 262 /* ImportEqualsDeclaration */: + case 263 /* ImportDeclaration */: + case 269 /* ExportDeclaration */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: // do not descend into nodes that cannot contain callable nodes return; - case 206 /* TypeAssertionExpression */: - case 224 /* AsExpression */: + case 208 /* TypeAssertionExpression */: + case 226 /* AsExpression */: // do not descend into the type side of an assertion collect(node.expression); return; - case 249 /* VariableDeclaration */: - case 160 /* Parameter */: + case 251 /* VariableDeclaration */: + case 162 /* Parameter */: // do not descend into the type of a variable or parameter declaration collect(node.name); collect(node.initializer); return; - case 203 /* CallExpression */: + case 205 /* CallExpression */: // do not descend into the type arguments of a call expression recordCallSite(node); collect(node.expression); ts.forEach(node.arguments, collect); return; - case 204 /* NewExpression */: + case 206 /* NewExpression */: // do not descend into the type arguments of a new expression recordCallSite(node); collect(node.expression); ts.forEach(node.arguments, collect); return; - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: // do not descend into the type arguments of a tagged template expression recordCallSite(node); collect(node.tag); collect(node.template); return; - case 275 /* JsxOpeningElement */: - case 274 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: // do not descend into the type arguments of a JsxOpeningLikeElement recordCallSite(node); collect(node.tagName); collect(node.attributes); return; - case 161 /* Decorator */: + case 163 /* Decorator */: recordCallSite(node); collect(node.expression); return; - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: recordCallSite(node); ts.forEachChild(node, collect); break; @@ -125811,22 +130474,22 @@ var ts; var callSites = []; var collect = createCallSiteCollector(program, callSites); switch (node.kind) { - case 297 /* SourceFile */: + case 299 /* SourceFile */: collectCallSitesOfSourceFile(node, collect); break; - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: collectCallSitesOfModuleDeclaration(node, collect); break; - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: collectCallSitesOfFunctionLikeDeclaration(program.getTypeChecker(), node, collect); break; - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: collectCallSitesOfClassLikeDeclaration(node, collect); break; default: @@ -125959,7 +130622,7 @@ var ts; } function updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName) { var allFiles = program.getSourceFiles(); - var _loop_4 = function (sourceFile) { + var _loop_5 = function (sourceFile) { var newFromOld = oldToNew(sourceFile.fileName); var newImportFromPath = newFromOld !== null && newFromOld !== void 0 ? newFromOld : sourceFile.fileName; var newImportFromDirectory = ts.getDirectoryPath(newImportFromPath); @@ -125976,7 +130639,7 @@ var ts; }, function (importLiteral) { var importedModuleSymbol = program.getTypeChecker().getSymbolAtLocation(importLiteral); // No need to update if it's an ambient module^M - if (importedModuleSymbol && importedModuleSymbol.declarations.some(function (d) { return ts.isAmbientModule(d); })) + if ((importedModuleSymbol === null || importedModuleSymbol === void 0 ? void 0 : importedModuleSymbol.declarations) && importedModuleSymbol.declarations.some(function (d) { return ts.isAmbientModule(d); })) return undefined; var toImport = oldFromNew !== undefined // If we're at the new location (file was already renamed), need to redo module resolution starting from the old location. @@ -125991,7 +130654,7 @@ var ts; }; for (var _i = 0, allFiles_1 = allFiles; _i < allFiles_1.length; _i++) { var sourceFile = allFiles_1[_i]; - _loop_4(sourceFile); + _loop_5(sourceFile); } } function combineNormal(pathA, pathB) { @@ -126082,8 +130745,10 @@ var ts; (function (GoToDefinition) { function getDefinitionAtPosition(program, sourceFile, position) { var resolvedRef = getReferenceAtPosition(sourceFile, position, program); - if (resolvedRef) { - return [getDefinitionInfoForFileReference(resolvedRef.reference.fileName, resolvedRef.file.fileName)]; + var fileReferenceDefinition = resolvedRef && [getDefinitionInfoForFileReference(resolvedRef.reference.fileName, resolvedRef.fileName, resolvedRef.unverified)] || ts.emptyArray; + if (resolvedRef === null || resolvedRef === void 0 ? void 0 : resolvedRef.file) { + // If `file` is missing, do a symbol-based lookup as well + return fileReferenceDefinition; } var node = ts.getTouchingPropertyName(sourceFile, position); if (node === sourceFile) { @@ -126100,7 +130765,7 @@ var ts; // Could not find a symbol e.g. node is string or number keyword, // or the symbol was an internal symbol and does not have a declaration e.g. undefined symbol if (!symbol) { - return getDefinitionInfoForIndexSignatures(node, typeChecker); + return ts.concatenate(fileReferenceDefinition, getDefinitionInfoForIndexSignatures(node, typeChecker)); } var calledDeclaration = tryGetSignatureDeclaration(typeChecker, node); // Don't go to the component constructor definition for a JSX element, just go to the component definition. @@ -126114,7 +130779,7 @@ var ts; else { var defs = getDefinitionFromSymbol(typeChecker, symbol, node, calledDeclaration) || ts.emptyArray; // For a 'super()' call, put the signature first, else put the variable first. - return node.kind === 105 /* SuperKeyword */ ? __spreadArray([sigInfo], defs) : __spreadArray(__spreadArray([], defs), [sigInfo]); + return node.kind === 106 /* SuperKeyword */ ? __spreadArray([sigInfo], defs) : __spreadArray(__spreadArray([], defs), [sigInfo]); } } // Because name in short-hand property assignment has two different meanings: property name and property value, @@ -126122,9 +130787,10 @@ 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 === 289 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 291 /* ShorthandPropertyAssignment */) { var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); - return shorthandSymbol_1 ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node); }) : []; + 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); }) : ts.emptyArray; + return ts.concatenate(definitions, getDefinitionFromObjectLiteralElement(typeChecker, node) || ts.emptyArray); } // If the node is the name of a BindingElement within an ObjectBindingPattern instead of just returning the // declaration the symbol (which is itself), we should try to get to the original type of the ObjectBindingPattern @@ -126146,25 +130812,7 @@ var ts; return prop && getDefinitionFromSymbol(typeChecker, prop, node); }); } - // If the current location we want to find its definition is in an object literal, try to get the contextual type for the - // object literal, lookup the property symbol in the contextual type, and use this for goto-definition. - // For example - // interface Props{ - // /*first*/prop1: number - // prop2: boolean - // } - // function Foo(arg: Props) {} - // Foo( { pr/*1*/op1: 10, prop2: true }) - var element = ts.getContainingObjectLiteralElement(node); - if (element) { - var contextualType = element && typeChecker.getContextualType(element.parent); - if (contextualType) { - return ts.flatMap(ts.getPropertySymbolsFromContextualType(element, typeChecker, contextualType, /*unionSymbolOk*/ false), function (propertySymbol) { - return getDefinitionFromSymbol(typeChecker, propertySymbol, node); - }); - } - } - return getDefinitionFromSymbol(typeChecker, symbol, node); + return ts.concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node)); } GoToDefinition.getDefinitionAtPosition = getDefinitionAtPosition; /** @@ -126178,22 +130826,60 @@ var ts; || ts.isAssignmentExpression(calledDeclaration.parent) || (!ts.isCallLikeExpression(calledDeclaration.parent) && s === calledDeclaration.parent.symbol); } + // If the current location we want to find its definition is in an object literal, try to get the contextual type for the + // object literal, lookup the property symbol in the contextual type, and use this for goto-definition. + // For example + // interface Props{ + // /*first*/prop1: number + // prop2: boolean + // } + // function Foo(arg: Props) {} + // Foo( { pr/*1*/op1: 10, prop2: true }) + function getDefinitionFromObjectLiteralElement(typeChecker, node) { + var element = ts.getContainingObjectLiteralElement(node); + if (element) { + var contextualType = element && typeChecker.getContextualType(element.parent); + if (contextualType) { + return ts.flatMap(ts.getPropertySymbolsFromContextualType(element, typeChecker, contextualType, /*unionSymbolOk*/ false), function (propertySymbol) { + return getDefinitionFromSymbol(typeChecker, propertySymbol, node); + }); + } + } + } function getReferenceAtPosition(sourceFile, position, program) { + var _a, _b; var referencePath = findReferenceInPosition(sourceFile.referencedFiles, position); if (referencePath) { var file = program.getSourceFileFromReference(sourceFile, referencePath); - return file && { reference: referencePath, file: file }; + return file && { reference: referencePath, fileName: file.fileName, file: file, unverified: false }; } var typeReferenceDirective = findReferenceInPosition(sourceFile.typeReferenceDirectives, position); if (typeReferenceDirective) { var reference = program.getResolvedTypeReferenceDirectives().get(typeReferenceDirective.fileName); var file = reference && program.getSourceFile(reference.resolvedFileName); // TODO:GH#18217 - return file && { reference: typeReferenceDirective, file: file }; + return file && { reference: typeReferenceDirective, fileName: file.fileName, file: file, unverified: false }; } var libReferenceDirective = findReferenceInPosition(sourceFile.libReferenceDirectives, position); if (libReferenceDirective) { var file = program.getLibFileFromReference(libReferenceDirective); - return file && { reference: libReferenceDirective, file: file }; + return file && { reference: libReferenceDirective, fileName: file.fileName, file: file, unverified: false }; + } + if ((_a = sourceFile.resolvedModules) === null || _a === void 0 ? void 0 : _a.size) { + var node = ts.getTokenAtPosition(sourceFile, position); + if (ts.isModuleSpecifierLike(node) && ts.isExternalModuleNameRelative(node.text) && sourceFile.resolvedModules.has(node.text)) { + var verifiedFileName = (_b = sourceFile.resolvedModules.get(node.text)) === null || _b === void 0 ? void 0 : _b.resolvedFileName; + var fileName = verifiedFileName || ts.resolvePath(ts.getDirectoryPath(sourceFile.fileName), node.text); + return { + file: program.getSourceFile(fileName), + fileName: fileName, + reference: { + pos: node.getStart(), + end: node.getEnd(), + fileName: node.text + }, + unverified: !verifiedFileName, + }; + } } return undefined; } @@ -126264,7 +130950,7 @@ var ts; // get the aliased symbol instead. This allows for goto def on an import e.g. // import {A, B} from "mod"; // to jump to the implementation directly. - if (symbol && symbol.flags & 2097152 /* Alias */ && shouldSkipAlias(node, symbol.declarations[0])) { + if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.flags & 2097152 /* Alias */ && shouldSkipAlias(node, symbol.declarations[0])) { var aliased = checker.getAliasedSymbol(symbol); if (aliased.declarations) { return aliased; @@ -126278,21 +130964,21 @@ var ts; // (2) when the aliased symbol is originating from an import. // function shouldSkipAlias(node, declaration) { - if (node.kind !== 78 /* Identifier */) { + if (node.kind !== 79 /* Identifier */) { return false; } if (node.parent === declaration) { return true; } switch (declaration.kind) { - case 262 /* ImportClause */: - case 260 /* ImportEqualsDeclaration */: + case 264 /* ImportClause */: + case 262 /* ImportEqualsDeclaration */: return true; - case 265 /* ImportSpecifier */: - return declaration.parent.kind === 264 /* NamedImports */; - case 198 /* BindingElement */: - case 249 /* VariableDeclaration */: - return ts.isInJSFile(declaration) && ts.isRequireVariableDeclaration(declaration, /*requireStringLiteralLikeArgument*/ true); + case 267 /* ImportSpecifier */: + return declaration.parent.kind === 266 /* NamedImports */; + case 200 /* BindingElement */: + case 251 /* VariableDeclaration */: + return ts.isInJSFile(declaration) && ts.isRequireVariableDeclaration(declaration); default: return false; } @@ -126307,7 +130993,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 === 132 /* ConstructorKeyword */)) { + if (symbol.flags & 32 /* Class */ && !(symbol.flags & (16 /* Function */ | 3 /* Variable */)) && (ts.isNewExpressionTarget(node) || node.kind === 133 /* 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); } @@ -126344,7 +131030,38 @@ var ts; var sourceFile = name.getSourceFile(); var 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: !checker.isDeclarationVisible(declaration) }); + containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration) }); + } + function isDefinitionVisible(checker, declaration) { + if (checker.isDeclarationVisible(declaration)) + return true; + if (!declaration.parent) + return false; + // Variable initializers are visible if variable is visible + if (ts.hasInitializer(declaration.parent) && declaration.parent.initializer === declaration) + 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 165 /* PropertyDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 167 /* MethodDeclaration */: + // Private/protected properties/methods are not visible + if (ts.hasEffectiveModifier(declaration, 8 /* Private */)) + return false; + // Public properties/methods are visible if its parents are visible, so: + // falls through + case 168 /* Constructor */: + case 290 /* PropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: + case 202 /* ObjectLiteralExpression */: + case 223 /* ClassExpression */: + case 211 /* ArrowFunction */: + case 210 /* FunctionExpression */: + return isDefinitionVisible(checker, declaration.parent); + default: + return false; + } } function createDefinitionFromSignatureDeclaration(typeChecker, decl) { return createDefinitionInfo(decl, typeChecker, decl.symbol, decl); @@ -126353,14 +131070,15 @@ var ts; return ts.find(refs, function (ref) { return ts.textRangeContainsPositionInclusive(ref, pos); }); } GoToDefinition.findReferenceInPosition = findReferenceInPosition; - function getDefinitionInfoForFileReference(name, targetFileName) { + function getDefinitionInfoForFileReference(name, targetFileName, unverified) { return { fileName: targetFileName, textSpan: ts.createTextSpanFromBounds(0, 0), kind: "script" /* scriptElement */, name: name, containerName: undefined, - containerKind: undefined, // TODO: GH#18217 + containerKind: undefined, + unverified: unverified, }; } /** Returns a CallLikeExpression where `node` is the target being invoked. */ @@ -126377,9 +131095,9 @@ var ts; } function isConstructorLike(node) { switch (node.kind) { - case 166 /* Constructor */: - case 175 /* ConstructorType */: - case 170 /* ConstructSignature */: + case 168 /* Constructor */: + case 177 /* ConstructorType */: + case 172 /* ConstructSignature */: return true; default: return false; @@ -126436,6 +131154,7 @@ var ts; "kind", "lends", "license", + "link", "listens", "member", "memberof", @@ -126473,78 +131192,115 @@ var ts; ]; var jsDocTagNameCompletionEntries; var jsDocTagCompletionEntries; - function getJsDocCommentsFromDeclarations(declarations) { + function getJsDocCommentsFromDeclarations(declarations, checker) { // Only collect doc comments from duplicate declarations once: // In case of a union property there might be same declaration multiple times // which only varies in type parameter // Eg. const a: Array | Array; a.length // The property length will have two declarations of property length coming // from Array - Array and Array - var documentationComment = []; + var parts = []; ts.forEachUnique(declarations, function (declaration) { for (var _i = 0, _a = getCommentHavingNodes(declaration); _i < _a.length; _i++) { var comment = _a[_i].comment; if (comment === undefined) continue; - ts.pushIfUnique(documentationComment, comment); + var newparts = getDisplayPartsFromComment(comment, checker); + if (!ts.contains(parts, newparts, isIdenticalListOfDisplayParts)) { + parts.push(newparts); + } } }); - return ts.intersperse(ts.map(documentationComment, ts.textPart), ts.lineBreakPart()); + return ts.flatten(ts.intersperse(parts, [ts.lineBreakPart()])); } JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; + function isIdenticalListOfDisplayParts(parts1, parts2) { + return ts.arraysEqual(parts1, parts2, function (p1, p2) { return p1.kind === p2.kind && p1.text === p2.text; }); + } function getCommentHavingNodes(declaration) { switch (declaration.kind) { - case 326 /* JSDocParameterTag */: - case 333 /* JSDocPropertyTag */: + case 334 /* JSDocParameterTag */: + case 341 /* JSDocPropertyTag */: return [declaration]; - case 324 /* JSDocCallbackTag */: - case 331 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + case 339 /* JSDocTypedefTag */: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); } } - function getJsDocTagsFromDeclarations(declarations) { + function getJsDocTagsFromDeclarations(declarations, checker) { // Only collect doc comments from duplicate declarations once. var tags = []; ts.forEachUnique(declarations, function (declaration) { for (var _i = 0, _a = ts.getJSDocTags(declaration); _i < _a.length; _i++) { var tag = _a[_i]; - tags.push({ name: tag.tagName.text, text: getCommentText(tag) }); + tags.push({ name: tag.tagName.text, text: getCommentDisplayParts(tag, checker) }); } }); return tags; } JsDoc.getJsDocTagsFromDeclarations = getJsDocTagsFromDeclarations; - function getCommentText(tag) { - var comment = tag.comment; - switch (tag.kind) { - case 316 /* JSDocImplementsTag */: + function getDisplayPartsFromComment(comment, checker) { + if (typeof comment === "string") { + return [ts.textPart(comment)]; + } + return ts.flatMap(comment, function (node) { return node.kind === 315 /* 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 323 /* JSDocImplementsTag */: return withNode(tag.class); - case 315 /* JSDocAugmentsTag */: + case 322 /* JSDocAugmentsTag */: return withNode(tag.class); - case 330 /* JSDocTemplateTag */: - return withList(tag.typeParameters); - case 329 /* JSDocTypeTag */: + case 338 /* JSDocTemplateTag */: + return addComment(tag.typeParameters.map(function (tp) { return tp.getText(); }).join(", ")); + case 337 /* JSDocTypeTag */: return withNode(tag.typeExpression); - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 333 /* JSDocPropertyTag */: - case 326 /* JSDocParameterTag */: - case 332 /* JSDocSeeTag */: + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + case 341 /* JSDocPropertyTag */: + case 334 /* JSDocParameterTag */: + case 340 /* JSDocSeeTag */: var name = tag.name; - return name ? withNode(name) : comment; + return name ? withNode(name) + : comment === undefined ? undefined + : getDisplayPartsFromComment(comment, checker); default: - return comment; + return comment === undefined ? undefined : getDisplayPartsFromComment(comment, checker); } function withNode(node) { return addComment(node.getText()); } - function withList(list) { - return addComment(list.map(function (x) { return x.getText(); }).join(", ")); - } function addComment(s) { - return comment === undefined ? s : s + " " + comment; + if (comment) { + if (s.match(/^https?$/)) { + return __spreadArray([ts.textPart(s)], getDisplayPartsFromComment(comment, checker)); + } + else { + return __spreadArray([namePart(s), ts.spacePart()], getDisplayPartsFromComment(comment, checker)); + } + } + else { + return [ts.textPart(s)]; + } + } + } + function getTagNameDisplayPart(kind) { + switch (kind) { + case 334 /* JSDocParameterTag */: + return ts.parameterNamePart; + case 341 /* JSDocPropertyTag */: + return ts.propertyNamePart; + case 338 /* JSDocTemplateTag */: + return ts.typeParameterNamePart; + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + return ts.typeAliasNamePart; + default: + return ts.textPart; } } function getJSDocTagNameCompletions() { @@ -126638,7 +131394,7 @@ var ts; * @param position The (character-indexed) position in the file where the check should * be performed. */ - function getDocCommentTemplateAtPosition(newLine, sourceFile, position) { + function getDocCommentTemplateAtPosition(newLine, sourceFile, position, options) { var tokenAtPos = ts.getTokenAtPosition(sourceFile, position); var existingDocComment = ts.findAncestor(tokenAtPos, ts.isJSDoc); if (existingDocComment && (existingDocComment.comment !== undefined || ts.length(existingDocComment.tags))) { @@ -126650,7 +131406,7 @@ var ts; if (!existingDocComment && tokenStart < position) { return undefined; } - var commentOwnerInfo = getCommentOwnerInfo(tokenAtPos); + var commentOwnerInfo = getCommentOwnerInfo(tokenAtPos, options); if (!commentOwnerInfo) { return undefined; } @@ -126692,7 +131448,7 @@ 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 === 78 /* Identifier */ ? name.text : "param" + i; + var paramName = name.kind === 79 /* Identifier */ ? name.text : "param" + i; var type = isJavaScriptFile ? (dotDotDotToken ? "{...any} " : "{any} ") : ""; return indentationStr + " * @param " + type + paramName + newLine; }).join(""); @@ -126700,76 +131456,77 @@ var ts; function returnsDocComment(indentationStr, newLine) { return indentationStr + " * @returns" + newLine; } - function getCommentOwnerInfo(tokenAtPos) { - return ts.forEachAncestor(tokenAtPos, getCommentOwnerInfoWorker); + function getCommentOwnerInfo(tokenAtPos, options) { + return ts.forEachAncestor(tokenAtPos, function (n) { return getCommentOwnerInfoWorker(n, options); }); } - function getCommentOwnerInfoWorker(commentOwner) { + function getCommentOwnerInfoWorker(commentOwner, options) { switch (commentOwner.kind) { - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: - case 164 /* MethodSignature */: - case 209 /* ArrowFunction */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 167 /* MethodDeclaration */: + case 168 /* Constructor */: + case 166 /* MethodSignature */: + case 211 /* ArrowFunction */: var host = commentOwner; - return { commentOwner: commentOwner, parameters: host.parameters, hasReturn: hasReturn(host) }; - case 288 /* PropertyAssignment */: - return getCommentOwnerInfoWorker(commentOwner.initializer); - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 162 /* PropertySignature */: - case 255 /* EnumDeclaration */: - case 291 /* EnumMember */: - case 254 /* TypeAliasDeclaration */: + return { commentOwner: commentOwner, parameters: host.parameters, hasReturn: hasReturn(host, options) }; + case 290 /* PropertyAssignment */: + return getCommentOwnerInfoWorker(commentOwner.initializer, options); + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 164 /* PropertySignature */: + case 257 /* EnumDeclaration */: + case 293 /* EnumMember */: + case 256 /* TypeAliasDeclaration */: return { commentOwner: commentOwner }; - case 232 /* VariableStatement */: { + case 234 /* VariableStatement */: { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; var host_1 = varDeclarations.length === 1 && varDeclarations[0].initializer ? getRightHandSideOfAssignment(varDeclarations[0].initializer) : undefined; return host_1 - ? { commentOwner: commentOwner, parameters: host_1.parameters, hasReturn: hasReturn(host_1) } + ? { commentOwner: commentOwner, parameters: host_1.parameters, hasReturn: hasReturn(host_1, options) } : { commentOwner: commentOwner }; } - case 297 /* SourceFile */: + case 299 /* SourceFile */: return "quit"; - case 256 /* ModuleDeclaration */: + case 258 /* 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 === 256 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; - case 233 /* ExpressionStatement */: - return getCommentOwnerInfoWorker(commentOwner.expression); - case 216 /* BinaryExpression */: { + return commentOwner.parent.kind === 258 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; + case 235 /* ExpressionStatement */: + return getCommentOwnerInfoWorker(commentOwner.expression, options); + case 218 /* BinaryExpression */: { var be = commentOwner; if (ts.getAssignmentDeclarationKind(be) === 0 /* None */) { return "quit"; } return ts.isFunctionLike(be.right) - ? { commentOwner: commentOwner, parameters: be.right.parameters, hasReturn: hasReturn(be.right) } + ? { commentOwner: commentOwner, parameters: be.right.parameters, hasReturn: hasReturn(be.right, options) } : { commentOwner: commentOwner }; } - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: var init = commentOwner.initializer; if (init && (ts.isFunctionExpression(init) || ts.isArrowFunction(init))) { - return { commentOwner: commentOwner, parameters: init.parameters, hasReturn: hasReturn(init) }; + return { commentOwner: commentOwner, parameters: init.parameters, hasReturn: hasReturn(init, options) }; } } } - function hasReturn(node) { - return ts.isArrowFunction(node) && ts.isExpression(node.body) - || ts.isFunctionLikeDeclaration(node) && node.body && ts.isBlock(node.body) && !!ts.forEachReturnStatement(node.body, function (n) { return n; }); + function hasReturn(node, options) { + return !!(options === null || options === void 0 ? void 0 : options.generateReturnInDocTemplate) && + (ts.isArrowFunction(node) && ts.isExpression(node.body) + || ts.isFunctionLikeDeclaration(node) && node.body && ts.isBlock(node.body) && !!ts.forEachReturnStatement(node.body, function (n) { return n; })); } function getRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 207 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 209 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return rightHandSide; - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: return ts.find(rightHandSide.members, ts.isConstructorDeclaration); } } @@ -126785,7 +131542,7 @@ var ts; if (!patternMatcher) return ts.emptyArray; var rawItems = []; - var _loop_5 = function (sourceFile) { + var _loop_6 = function (sourceFile) { cancellationToken.throwIfCancellationRequested(); if (excludeDtsFiles && sourceFile.isDeclarationFile) { return "continue"; @@ -126797,7 +131554,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_5(sourceFile); + _loop_6(sourceFile); } rawItems.sort(compareNavigateToItems); return (maxResultCount === undefined ? rawItems : rawItems.slice(0, maxResultCount)).map(createNavigateToItem); @@ -126828,9 +131585,9 @@ var ts; } function shouldKeepItem(declaration, checker) { switch (declaration.kind) { - case 262 /* ImportClause */: - case 265 /* ImportSpecifier */: - case 260 /* ImportEqualsDeclaration */: + case 264 /* ImportClause */: + case 267 /* ImportSpecifier */: + case 262 /* ImportEqualsDeclaration */: var importer = checker.getSymbolAtLocation(declaration.name); // TODO: GH#18217 var imported = checker.getAliasedSymbol(importer); return importer.escapedName !== imported.escapedName; @@ -126840,7 +131597,7 @@ var ts; } function tryAddSingleDeclarationName(declaration, containers) { var name = ts.getNameOfDeclaration(declaration); - return !!name && (pushLiteral(name, containers) || name.kind === 158 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); + return !!name && (pushLiteral(name, containers) || name.kind === 160 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); } // Only added the names of computed properties if they're simple dotted expressions, like: // @@ -126857,7 +131614,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 === 158 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { + if (name && name.kind === 160 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { return ts.emptyArray; } // Don't include the last portion. @@ -127057,6 +131814,28 @@ var ts; addChildrenRecursively(child); endNode(); } + function addNodeWithRecursiveInitializer(node) { + if (node.initializer && isFunctionOrClassExpression(node.initializer)) { + startNode(node); + ts.forEachChild(node.initializer, addChildrenRecursively); + endNode(); + } + else { + addNodeWithRecursiveChild(node, node.initializer); + } + } + /** + * Historically, we've elided dynamic names from the nav tree (including late bound names), + * but included certain "well known" symbol names. While we no longer distinguish those well-known + * symbols from other unique symbols, we do the below to retain those members in the nav tree. + */ + function hasNavigationBarName(node) { + return !ts.hasDynamicName(node) || + (node.kind !== 218 /* BinaryExpression */ && + ts.isPropertyAccessExpression(node.name.expression) && + ts.isIdentifier(node.name.expression.expression) && + ts.idText(node.name.expression.expression) === "Symbol"); + } /** Look for navigation bar items in node's subtree, adding them to the current `parent`. */ function addChildrenRecursively(node) { var _a; @@ -127065,7 +131844,7 @@ var ts; return; } switch (node.kind) { - case 166 /* Constructor */: + case 168 /* 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); @@ -127077,21 +131856,25 @@ var ts; } } break; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 164 /* MethodSignature */: - if (!ts.hasDynamicName(node)) { + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 166 /* MethodSignature */: + if (hasNavigationBarName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - if (!ts.hasDynamicName(node)) { + case 165 /* PropertyDeclaration */: + if (hasNavigationBarName(node)) { + addNodeWithRecursiveInitializer(node); + } + break; + case 164 /* PropertySignature */: + if (hasNavigationBarName(node)) { addLeafNode(node); } break; - case 262 /* ImportClause */: + case 264 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -127103,7 +131886,7 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 263 /* NamespaceImport */) { + if (namedBindings.kind === 265 /* NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -127114,32 +131897,27 @@ var ts; } } break; - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: addNodeWithRecursiveChild(node, node.name); break; - case 290 /* SpreadAssignment */: + case 292 /* 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 198 /* BindingElement */: - case 288 /* PropertyAssignment */: - case 249 /* VariableDeclaration */: - var _e = node, name = _e.name, initializer = _e.initializer; - if (ts.isBindingPattern(name)) { - addChildrenRecursively(name); - } - else if (initializer && isFunctionOrClassExpression(initializer)) { - // Add a node for the VariableDeclaration, but not for the initializer. - startNode(node); - ts.forEachChild(initializer, addChildrenRecursively); - endNode(); + case 200 /* BindingElement */: + case 290 /* PropertyAssignment */: + case 251 /* VariableDeclaration */: { + var child = node; + if (ts.isBindingPattern(child.name)) { + addChildrenRecursively(child.name); } else { - addNodeWithRecursiveChild(node, initializer); + addNodeWithRecursiveInitializer(child); } break; - case 251 /* FunctionDeclaration */: + } + case 253 /* FunctionDeclaration */: var nameNode = node.name; // If we see a function declaration track as a possible ES5 class if (nameNode && ts.isIdentifier(nameNode)) { @@ -127147,34 +131925,34 @@ var ts; } addNodeWithRecursiveChild(node, node.body); break; - case 209 /* ArrowFunction */: - case 208 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 210 /* FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: startNode(node); - for (var _f = 0, _g = node.members; _f < _g.length; _f++) { - var member = _g[_f]; + for (var _e = 0, _f = node.members; _e < _f.length; _e++) { + var member = _f[_e]; if (!isComputedProperty(member)) { addLeafNode(member); } } endNode(); break; - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: startNode(node); - for (var _h = 0, _j = node.members; _h < _j.length; _h++) { - var member = _j[_h]; + for (var _g = 0, _h = node.members; _g < _h.length; _g++) { + var member = _h[_g]; addChildrenRecursively(member); } endNode(); break; - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 266 /* ExportAssignment */: { + case 268 /* 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; @@ -127188,16 +131966,16 @@ var ts; } break; } - case 270 /* ExportSpecifier */: - case 260 /* ImportEqualsDeclaration */: - case 171 /* IndexSignature */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 254 /* TypeAliasDeclaration */: + case 272 /* ExportSpecifier */: + case 262 /* ImportEqualsDeclaration */: + case 173 /* IndexSignature */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 256 /* TypeAliasDeclaration */: addLeafNode(node); break; - case 203 /* CallExpression */: - case 216 /* BinaryExpression */: { + case 205 /* CallExpression */: + case 218 /* BinaryExpression */: { var special = ts.getAssignmentDeclarationKind(node); switch (special) { case 1 /* ExportsProperty */: @@ -127249,7 +132027,7 @@ var ts; defineCall.arguments[0] : defineCall.arguments[0].expression; var memberName = defineCall.arguments[1]; - var _k = startNestedNodes(node, className), depth = _k[0], classNameIdentifier = _k[1]; + var _j = startNestedNodes(node, className), depth = _j[0], classNameIdentifier = _j[1]; startNode(node, classNameIdentifier); startNode(node, ts.setTextRange(ts.factory.createIdentifier(memberName.text), memberName)); addChildrenRecursively(node.arguments[2]); @@ -127439,13 +132217,14 @@ var ts; return false; } switch (a.kind) { - case 163 /* PropertyDeclaration */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return ts.hasSyntacticModifier(a, 32 /* Static */) === ts.hasSyntacticModifier(b, 32 /* Static */); - case 256 /* ModuleDeclaration */: - return areSameModule(a, b); + case 258 /* ModuleDeclaration */: + return areSameModule(a, b) + && getFullyQualifiedModuleName(a) === getFullyQualifiedModuleName(b); default: return true; } @@ -127462,8 +132241,7 @@ var ts; // We use 1 NavNode to represent 'A.B.C', but there are multiple source nodes. // Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'! function areSameModule(a, b) { - // TODO: GH#18217 - return a.body.kind === b.body.kind && (a.body.kind !== 256 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); + return a.body.kind === b.body.kind && (a.body.kind !== 258 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); } /** Merge source into target. Source should be thrown away after this is called. */ function merge(target, source) { @@ -127493,7 +132271,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 256 /* ModuleDeclaration */) { + if (node.kind === 258 /* ModuleDeclaration */) { return getModuleName(node); } var declName = ts.getNameOfDeclaration(node); @@ -127502,16 +132280,16 @@ var ts; return propertyName && ts.unescapeLeadingUnderscores(propertyName); } switch (node.kind) { - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 221 /* ClassExpression */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 223 /* ClassExpression */: return getFunctionOrClassName(node); default: return undefined; } } function getItemName(node, name) { - if (node.kind === 256 /* ModuleDeclaration */) { + if (node.kind === 258 /* ModuleDeclaration */) { return cleanText(getModuleName(node)); } if (name) { @@ -127523,18 +132301,18 @@ var ts; } } switch (node.kind) { - case 297 /* SourceFile */: + case 299 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return ts.isExportAssignment(node) && node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; - case 209 /* ArrowFunction */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 211 /* ArrowFunction */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: if (ts.getSyntacticModifierFlags(node) & 512 /* Default */) { return "default"; } @@ -127542,13 +132320,13 @@ var ts; // (eg: "app\n.onactivated"), so we should remove the whitespace for readability in the // navigation bar. return getFunctionOrClassName(node); - case 166 /* Constructor */: + case 168 /* Constructor */: return "constructor"; - case 170 /* ConstructSignature */: + case 172 /* ConstructSignature */: return "new()"; - case 169 /* CallSignature */: + case 171 /* CallSignature */: return "()"; - case 171 /* IndexSignature */: + case 173 /* IndexSignature */: return "[]"; default: return ""; @@ -127581,19 +132359,19 @@ var ts; } // Some nodes are otherwise important enough to always include in the primary navigation menu. switch (navigationBarNodeKind(item)) { - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 255 /* EnumDeclaration */: - case 253 /* InterfaceDeclaration */: - case 256 /* ModuleDeclaration */: - case 297 /* SourceFile */: - case 254 /* TypeAliasDeclaration */: - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 257 /* EnumDeclaration */: + case 255 /* InterfaceDeclaration */: + case 258 /* ModuleDeclaration */: + case 299 /* SourceFile */: + case 256 /* TypeAliasDeclaration */: + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: return true; - case 209 /* ArrowFunction */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -127603,10 +132381,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 257 /* ModuleBlock */: - case 297 /* SourceFile */: - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: + case 259 /* ModuleBlock */: + case 299 /* SourceFile */: + case 167 /* MethodDeclaration */: + case 168 /* Constructor */: return true; default: return false; @@ -127663,9 +132441,12 @@ var ts; if (ts.isAmbientModule(moduleDeclaration)) { return ts.getTextOfNode(moduleDeclaration.name); } + return getFullyQualifiedModuleName(moduleDeclaration); + } + 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 === 256 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 258 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); } @@ -127679,13 +132460,13 @@ var ts; return decl.body && ts.isModuleDeclaration(decl.body) ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 158 /* ComputedPropertyName */; + return !member.name || member.name.kind === 160 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 297 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); + return node.kind === 299 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { - if (node.parent && node.parent.kind === 249 /* VariableDeclaration */) { + if (node.parent && node.parent.kind === 251 /* VariableDeclaration */) { node = node.parent; } return ts.getNodeModifiers(node); @@ -127700,7 +132481,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 === 62 /* EqualsToken */) { + else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */) { return nodeText(parent.left).replace(whiteSpaceRegex, ""); } // See if it is a property assignment, and if so use the property name @@ -127743,9 +132524,9 @@ var ts; } function isFunctionOrClassExpression(node) { switch (node.kind) { - case 209 /* ArrowFunction */: - case 208 /* FunctionExpression */: - case 221 /* ClassExpression */: + case 211 /* ArrowFunction */: + case 210 /* FunctionExpression */: + case 223 /* ClassExpression */: return true; default: return false; @@ -127774,9 +132555,9 @@ var ts; * 2) Coalescing imports from the same module * 3) Sorting imports */ - function organizeImports(sourceFile, formatContext, host, program, preferences) { + function organizeImports(sourceFile, formatContext, host, program, preferences, skipDestructiveCodeActions) { var changeTracker = ts.textChanges.ChangeTracker.fromContext({ host: host, formatContext: formatContext, preferences: preferences }); - var coalesceAndOrganizeImports = function (importGroup) { return ts.stableSort(coalesceImports(removeUnusedImports(importGroup, sourceFile, program)), function (s1, s2) { return compareImportsOrRequireStatements(s1, s2); }); }; + var coalesceAndOrganizeImports = function (importGroup) { return ts.stableSort(coalesceImports(removeUnusedImports(importGroup, sourceFile, program, skipDestructiveCodeActions)), function (s1, s2) { return compareImportsOrRequireStatements(s1, s2); }); }; // All of the old ImportDeclarations in the file, in syntactic order. var topLevelImportDecls = sourceFile.statements.filter(ts.isImportDeclaration); organizeImportsWorker(topLevelImportDecls, coalesceAndOrganizeImports); @@ -127811,26 +132592,35 @@ var ts; ? coalesce(importGroup) : importGroup; }); - // Delete or replace the first import. + // Delete all nodes if there are no imports. if (newImportDecls.length === 0) { - changeTracker.delete(sourceFile, oldImportDecls[0]); + // Consider the first node to have trailingTrivia as we want to exclude the + // "header" comment. + changeTracker.deleteNodes(sourceFile, oldImportDecls, { + trailingTriviaOption: ts.textChanges.TrailingTriviaOption.Include, + }, /*hasTrailingComment*/ true); } else { // Note: Delete the surrounding trivia because it will have been retained in newImportDecls. - changeTracker.replaceNodeWithNodes(sourceFile, oldImportDecls[0], newImportDecls, { + var replaceOptions = { leadingTriviaOption: ts.textChanges.LeadingTriviaOption.Exclude, trailingTriviaOption: ts.textChanges.TrailingTriviaOption.Include, suffix: ts.getNewLineOrDefaultFromHost(host, formatContext.options), - }); - } - // Delete any subsequent imports. - for (var i = 1; i < oldImportDecls.length; i++) { - changeTracker.deleteNode(sourceFile, oldImportDecls[i]); + }; + changeTracker.replaceNodeWithNodes(sourceFile, oldImportDecls[0], newImportDecls, replaceOptions); + var hasTrailingComment = changeTracker.nodeHasTrailingComment(sourceFile, oldImportDecls[0], replaceOptions); + changeTracker.deleteNodes(sourceFile, oldImportDecls.slice(1), { + trailingTriviaOption: ts.textChanges.TrailingTriviaOption.Include, + }, hasTrailingComment); } } } OrganizeImports.organizeImports = organizeImports; - function removeUnusedImports(oldImports, sourceFile, program) { + function removeUnusedImports(oldImports, sourceFile, program, skipDestructiveCodeActions) { + // As a precaution, consider unused import detection to be destructive (GH #43051) + if (skipDestructiveCodeActions) { + return oldImports; + } var typeChecker = program.getTypeChecker(); var jsxNamespace = typeChecker.getJsxNamespace(sourceFile); var jsxFragmentFactory = typeChecker.getJsxFragmentFactory(sourceFile); @@ -128101,11 +132891,11 @@ var ts; function getModuleSpecifierExpression(declaration) { var _a; switch (declaration.kind) { - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return (_a = ts.tryCast(declaration.moduleReference, ts.isExternalModuleReference)) === null || _a === void 0 ? void 0 : _a.expression; - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return declaration.moduleSpecifier; - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return declaration.declarationList.declarations[0].initializer.arguments[0]; } } @@ -128144,19 +132934,19 @@ var ts; function getImportKindOrder(s1) { var _a; switch (s1.kind) { - case 261 /* ImportDeclaration */: + case 263 /* 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) === 263 /* NamespaceImport */) + if (((_a = s1.importClause.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 265 /* NamespaceImport */) return 2; if (s1.importClause.name) return 3; return 4; - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return 5; - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return 6; } } @@ -128194,7 +132984,7 @@ var ts; } var lastImport = current - 1; if (lastImport !== firstImport) { - out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 99 /* ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* Imports */)); + out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 100 /* ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* Imports */)); } } function visitNonImportNode(n) { @@ -128258,8 +133048,15 @@ var ts; } } } - var regionDelimiterRegExp = /^\s*\/\/\s*#(end)?region(?:\s+(.*))?(?:\r)?$/; + var regionDelimiterRegExp = /^#(end)?region(?:\s+(.*))?(?:\r)?$/; function isRegionDelimiter(lineText) { + // We trim the leading whitespace and // without the regex since the + // multiple potential whitespace matches can make for some gnarly backtracking behavior + lineText = ts.trimStringStart(lineText); + if (!ts.startsWith(lineText, "\/\/")) { + return null; // eslint-disable-line no-null/no-null + } + lineText = ts.trimString(lineText.slice(2)); return regionDelimiterRegExp.exec(lineText); } function addOutliningForLeadingCommentsForNode(n, sourceFile, cancellationToken, out) { @@ -128312,7 +133109,7 @@ var ts; } function getOutliningSpanForNode(n, sourceFile) { switch (n.kind) { - case 230 /* Block */: + case 232 /* Block */: if (ts.isFunctionLike(n.parent)) { return functionSpan(n.parent, n, sourceFile); } @@ -128320,23 +133117,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 235 /* DoStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 237 /* ForStatement */: - case 234 /* IfStatement */: - case 236 /* WhileStatement */: - case 243 /* WithStatement */: - case 287 /* CatchClause */: + case 237 /* DoStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 239 /* ForStatement */: + case 236 /* IfStatement */: + case 238 /* WhileStatement */: + case 245 /* WithStatement */: + case 289 /* CatchClause */: return spanForNode(n.parent); - case 247 /* TryStatement */: + case 249 /* 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, 95 /* FinallyKeyword */, sourceFile); + var node = ts.findChildOfKind(tryStatement, 96 /* FinallyKeyword */, sourceFile); if (node) return spanForNode(node); } @@ -128346,40 +133143,40 @@ var ts; // the span of the block, independent of any parent span. return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* Code */); } - case 257 /* ModuleBlock */: + case 259 /* ModuleBlock */: return spanForNode(n.parent); - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - case 258 /* CaseBlock */: - case 177 /* TypeLiteral */: - case 196 /* ObjectBindingPattern */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: + case 257 /* EnumDeclaration */: + case 260 /* CaseBlock */: + case 179 /* TypeLiteral */: + case 198 /* ObjectBindingPattern */: return spanForNode(n); - case 179 /* TupleType */: + case 181 /* TupleType */: return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isTupleTypeNode(n.parent), 22 /* OpenBracketToken */); - case 284 /* CaseClause */: - case 285 /* DefaultClause */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: return spanForNodeArray(n.statements); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return spanForObjectOrArrayLiteral(n); - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return spanForObjectOrArrayLiteral(n, 22 /* OpenBracketToken */); - case 273 /* JsxElement */: + case 275 /* JsxElement */: return spanForJSXElement(n); - case 277 /* JsxFragment */: + case 279 /* JsxFragment */: return spanForJSXFragment(n); - case 274 /* JsxSelfClosingElement */: - case 275 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: return spanForJSXAttributes(n.attributes); - case 218 /* TemplateExpression */: + case 220 /* TemplateExpression */: case 14 /* NoSubstitutionTemplateLiteral */: return spanForTemplateLiteral(n); - case 197 /* ArrayBindingPattern */: + case 199 /* ArrayBindingPattern */: return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isBindingElement(n.parent), 22 /* OpenBracketToken */); - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return spanForArrowFunction(n); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return spanForCallExpression(n); } function spanForCallExpression(node) { @@ -128446,7 +133243,7 @@ var ts; 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 !== 209 /* ArrowFunction */); + return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 211 /* ArrowFunction */); } function spanBetweenTokens(openToken, closeToken, hintSpanNode, sourceFile, autoCollapse, useFullStart) { if (autoCollapse === void 0) { autoCollapse = false; } @@ -128749,15 +133546,15 @@ var ts; // Assumes 'value' is already lowercase. function indexOfIgnoringCase(str, value) { var n = str.length - value.length; - var _loop_6 = function (start) { + var _loop_7 = 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_1 = _loop_6(start); - if (typeof state_1 === "object") - return state_1.value; + var state_2 = _loop_7(start); + if (typeof state_2 === "object") + return state_2.value; } return -1; } @@ -128990,10 +133787,10 @@ var ts; */ function tryConsumeDeclare() { var token = ts.scanner.getToken(); - if (token === 133 /* DeclareKeyword */) { + if (token === 134 /* DeclareKeyword */) { // declare module "mod" token = nextToken(); - if (token === 139 /* ModuleKeyword */) { + if (token === 140 /* ModuleKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { recordAmbientExternalModule(); @@ -129011,7 +133808,7 @@ var ts; return false; } var token = ts.scanner.getToken(); - if (token === 99 /* ImportKeyword */) { + if (token === 100 /* ImportKeyword */) { token = nextToken(); if (token === 20 /* OpenParenToken */) { token = nextToken(); @@ -129027,21 +133824,21 @@ var ts; return true; } else { - if (token === 149 /* TypeKeyword */) { + if (token === 150 /* TypeKeyword */) { var skipTypeKeyword = ts.scanner.lookAhead(function () { var token = ts.scanner.scan(); - return token !== 153 /* FromKeyword */ && (token === 41 /* AsteriskToken */ || + return token !== 154 /* FromKeyword */ && (token === 41 /* AsteriskToken */ || token === 18 /* OpenBraceToken */ || - token === 78 /* Identifier */ || + token === 79 /* Identifier */ || ts.isKeyword(token)); }); if (skipTypeKeyword) { token = nextToken(); } } - if (token === 78 /* Identifier */ || ts.isKeyword(token)) { + if (token === 79 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 153 /* FromKeyword */) { + if (token === 154 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // import d from "mod"; @@ -129049,7 +133846,7 @@ var ts; return true; } } - else if (token === 62 /* EqualsToken */) { + else if (token === 63 /* EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } @@ -129072,7 +133869,7 @@ var ts; } if (token === 19 /* CloseBraceToken */) { token = nextToken(); - if (token === 153 /* FromKeyword */) { + if (token === 154 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // import {a as A} from "mod"; @@ -129084,11 +133881,11 @@ var ts; } else if (token === 41 /* AsteriskToken */) { token = nextToken(); - if (token === 126 /* AsKeyword */) { + if (token === 127 /* AsKeyword */) { token = nextToken(); - if (token === 78 /* Identifier */ || ts.isKeyword(token)) { + if (token === 79 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 153 /* FromKeyword */) { + if (token === 154 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // import * as NS from "mod" @@ -129106,10 +133903,10 @@ var ts; } function tryConsumeExport() { var token = ts.scanner.getToken(); - if (token === 92 /* ExportKeyword */) { + if (token === 93 /* ExportKeyword */) { markAsExternalModuleIfTopLevel(); token = nextToken(); - if (token === 149 /* TypeKeyword */) { + if (token === 150 /* TypeKeyword */) { var skipTypeKeyword = ts.scanner.lookAhead(function () { var token = ts.scanner.scan(); return token === 41 /* AsteriskToken */ || @@ -129128,7 +133925,7 @@ var ts; } if (token === 19 /* CloseBraceToken */) { token = nextToken(); - if (token === 153 /* FromKeyword */) { + if (token === 154 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // export {a as A} from "mod"; @@ -129140,7 +133937,7 @@ var ts; } else if (token === 41 /* AsteriskToken */) { token = nextToken(); - if (token === 153 /* FromKeyword */) { + if (token === 154 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // export * from "mod" @@ -129148,21 +133945,21 @@ var ts; } } } - else if (token === 99 /* ImportKeyword */) { + else if (token === 100 /* ImportKeyword */) { token = nextToken(); - if (token === 149 /* TypeKeyword */) { + if (token === 150 /* TypeKeyword */) { var skipTypeKeyword = ts.scanner.lookAhead(function () { var token = ts.scanner.scan(); - return token === 78 /* Identifier */ || + return token === 79 /* Identifier */ || ts.isKeyword(token); }); if (skipTypeKeyword) { token = nextToken(); } } - if (token === 78 /* Identifier */ || ts.isKeyword(token)) { + if (token === 79 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 62 /* EqualsToken */) { + if (token === 63 /* EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } @@ -129176,7 +133973,7 @@ var ts; function tryConsumeRequireCall(skipCurrentToken, allowTemplateLiterals) { if (allowTemplateLiterals === void 0) { allowTemplateLiterals = false; } var token = skipCurrentToken ? nextToken() : ts.scanner.getToken(); - if (token === 143 /* RequireKeyword */) { + if (token === 144 /* RequireKeyword */) { token = nextToken(); if (token === 20 /* OpenParenToken */) { token = nextToken(); @@ -129192,7 +133989,7 @@ var ts; } function tryConsumeDefine() { var token = ts.scanner.getToken(); - if (token === 78 /* Identifier */ && ts.scanner.getTokenValue() === "define") { + if (token === 79 /* Identifier */ && ts.scanner.getTokenValue() === "define") { token = nextToken(); if (token !== 20 /* OpenParenToken */) { return true; @@ -129309,7 +134106,7 @@ var ts; function getRenameInfo(program, sourceFile, position, options) { var node = ts.getAdjustedRenameLocation(ts.getTouchingPropertyName(sourceFile, position)); if (nodeIsEligibleForRename(node)) { - var renameInfo = getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, function (declaration) { return program.isSourceFileDefaultLibrary(declaration.getSourceFile()); }, options); + var renameInfo = getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, program, options); if (renameInfo) { return renameInfo; } @@ -129317,7 +134114,7 @@ var ts; return getRenameInfoError(ts.Diagnostics.You_cannot_rename_this_element); } Rename.getRenameInfo = getRenameInfo; - function getRenameInfoForNode(node, typeChecker, sourceFile, isDefinedInLibraryFile, options) { + function getRenameInfoForNode(node, typeChecker, sourceFile, program, options) { var symbol = typeChecker.getSymbolAtLocation(node); if (!symbol) { if (ts.isStringLiteralLike(node)) { @@ -129337,29 +134134,33 @@ var ts; if (!declarations || declarations.length === 0) return; // Disallow rename for elements that are defined in the standard TypeScript library. - if (declarations.some(isDefinedInLibraryFile)) { + if (declarations.some(function (declaration) { return isDefinedInLibraryFile(program, declaration); })) { 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 === 87 /* DefaultKeyword */ && symbol.parent && symbol.parent.flags & 1536 /* Module */) { + if (ts.isIdentifier(node) && node.originalKeywordKind === 88 /* DefaultKeyword */ && symbol.parent && symbol.parent.flags & 1536 /* Module */) { return undefined; } if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) { return options && options.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined; } var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); - var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 158 /* ComputedPropertyName */) + var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 160 /* ComputedPropertyName */) ? ts.stripQuotes(ts.getTextOfIdentifierOrLiteral(node)) : undefined; var displayName = specifierName || typeChecker.symbolToString(symbol); var fullDisplayName = specifierName || typeChecker.getFullyQualifiedName(symbol); return getRenameInfoSuccess(displayName, fullDisplayName, kind, ts.SymbolDisplay.getSymbolModifiers(typeChecker, symbol), node, sourceFile); } + function isDefinedInLibraryFile(program, declaration) { + var sourceFile = declaration.getSourceFile(); + return program.isSourceFileDefaultLibrary(sourceFile) && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Dts */); + } function getRenameInfoForModule(node, sourceFile, moduleSymbol) { if (!ts.isExternalModuleNameRelative(node.text)) { return getRenameInfoError(ts.Diagnostics.You_cannot_rename_a_module_via_a_global_import); } - var moduleSourceFile = ts.find(moduleSymbol.declarations, ts.isSourceFile); + var moduleSourceFile = moduleSymbol.declarations && ts.find(moduleSymbol.declarations, ts.isSourceFile); if (!moduleSourceFile) return undefined; var withoutIndex = ts.endsWith(node.text, "/index") || ts.endsWith(node.text, "/index.js") ? undefined : ts.tryRemoveSuffix(ts.removeFileExtension(moduleSourceFile.fileName), "/index"); @@ -129404,11 +134205,11 @@ var ts; } function nodeIsEligibleForRename(node) { switch (node.kind) { - case 78 /* Identifier */: - case 79 /* PrivateIdentifier */: + case 79 /* Identifier */: + case 80 /* PrivateIdentifier */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: return true; case 8 /* NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node); @@ -129440,6 +134241,10 @@ var ts; if (ts.getTokenPosOfNode(node, sourceFile, /*includeJsDoc*/ true) > pos) { break outer; } + var comment = ts.singleOrUndefined(ts.getTrailingCommentRanges(sourceFile.text, node.end)); + if (comment && comment.kind === 2 /* SingleLineCommentTrivia */) { + pushSelectionCommentRange(comment.pos, comment.end); + } if (positionShouldSnapToNode(sourceFile, pos, node)) { // 1. Blocks are effectively redundant with SyntaxLists. // 2. TemplateSpans, along with the SyntaxLists containing them, are a somewhat unintuitive grouping @@ -129502,6 +134307,14 @@ var ts; } } } + function pushSelectionCommentRange(start, end) { + pushSelectionRange(start, end); + var pos = start; + while (sourceFile.text.charCodeAt(pos) === 47 /* slash */) { + pos++; + } + pushSelectionRange(pos, end); + } } SmartSelectionRange.getSmartSelectionRange = getSmartSelectionRange; /** @@ -129558,14 +134371,14 @@ var ts; ts.Debug.assertEqual(closeBraceToken.kind, 19 /* CloseBraceToken */); // Group `-/+readonly` and `-/+?` var groupedWithPlusMinusTokens = groupChildren(children, function (child) { - return child === node.readonlyToken || child.kind === 142 /* ReadonlyKeyword */ || + return child === node.readonlyToken || child.kind === 143 /* ReadonlyKeyword */ || child === node.questionToken || child.kind === 57 /* QuestionToken */; }); // Group type parameter with surrounding brackets var groupedWithBrackets = groupChildren(groupedWithPlusMinusTokens, function (_a) { var kind = _a.kind; return kind === 22 /* OpenBracketToken */ || - kind === 159 /* TypeParameter */ || + kind === 161 /* TypeParameter */ || kind === 23 /* CloseBracketToken */; }); return [ @@ -129598,14 +134411,14 @@ var ts; }); return splitChildren(groupedWithQuestionToken, function (_a) { var kind = _a.kind; - return kind === 62 /* EqualsToken */; + return kind === 63 /* EqualsToken */; }); } // Pivot on '=' if (ts.isBindingElement(node)) { return splitChildren(node.getChildren(), function (_a) { var kind = _a.kind; - return kind === 62 /* EqualsToken */; + return kind === 63 /* EqualsToken */; }); } return node.getChildren(); @@ -129679,22 +134492,22 @@ var ts; return kind === 18 /* OpenBraceToken */ || kind === 22 /* OpenBracketToken */ || kind === 20 /* OpenParenToken */ - || kind === 275 /* JsxOpeningElement */; + || kind === 277 /* JsxOpeningElement */; } function isListCloser(token) { var kind = token && token.kind; return kind === 19 /* CloseBraceToken */ || kind === 23 /* CloseBracketToken */ || kind === 21 /* CloseParenToken */ - || kind === 276 /* JsxClosingElement */; + || kind === 278 /* JsxClosingElement */; } function getEndPos(sourceFile, node) { switch (node.kind) { - case 326 /* JSDocParameterTag */: - case 324 /* JSDocCallbackTag */: - case 333 /* JSDocPropertyTag */: - case 331 /* JSDocTypedefTag */: - case 328 /* JSDocThisTag */: + case 334 /* JSDocParameterTag */: + case 332 /* JSDocCallbackTag */: + case 341 /* JSDocPropertyTag */: + case 339 /* JSDocTypedefTag */: + case 336 /* JSDocThisTag */: return sourceFile.getLineEndOfPosition(node.getStart()); default: return node.getEnd(); @@ -129904,10 +134717,10 @@ var ts; } return undefined; } - else if (ts.isTemplateHead(node) && parent.parent.kind === 205 /* TaggedTemplateExpression */) { + else if (ts.isTemplateHead(node) && parent.parent.kind === 207 /* TaggedTemplateExpression */) { var templateExpression = parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 218 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 220 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position, sourceFile) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } @@ -129976,17 +134789,17 @@ var ts; return undefined; var parent = startingToken.parent; switch (parent.kind) { - case 207 /* ParenthesizedExpression */: - case 165 /* MethodDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 209 /* ParenthesizedExpression */: + case 167 /* MethodDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: var info = getArgumentOrParameterListInfo(startingToken, 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 216 /* BinaryExpression */: { + case 218 /* BinaryExpression */: { var highestBinary = getHighestBinary(parent); var contextualType_1 = checker.getContextualType(highestBinary); var argumentIndex_1 = startingToken.kind === 20 /* OpenParenToken */ ? 0 : countBinaryExpressionParameters(parent) - 1; @@ -130110,7 +134923,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 === 218 /* TemplateExpression */) { + if (template.kind === 220 /* TemplateExpression */) { var lastSpan = ts.last(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -130119,7 +134932,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node, position, sourceFile, checker, isManuallyInvoked) { - var _loop_7 = function (n) { + var _loop_8 = 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); }); @@ -130129,9 +134942,9 @@ var ts; } }; for (var n = node; !ts.isSourceFile(n) && (isManuallyInvoked || !ts.isBlock(n)); n = n.parent) { - var state_2 = _loop_7(n); - if (typeof state_2 === "object") - return state_2.value; + var state_3 = _loop_8(n); + if (typeof state_3 === "object") + return state_3.value; } return undefined; } @@ -130181,7 +134994,19 @@ var ts; itemsSeen += item.length; } ts.Debug.assert(selectedItemIndex !== -1); // If candidates is non-empty it should always include bestSignature. We check for an empty candidates before calling this function. - return { items: ts.flatMapToMutable(items, ts.identity), applicableSpan: applicableSpan, selectedItemIndex: selectedItemIndex, argumentIndex: argumentIndex, argumentCount: argumentCount }; + var help = { items: ts.flatMapToMutable(items, ts.identity), applicableSpan: applicableSpan, selectedItemIndex: selectedItemIndex, argumentIndex: argumentIndex, argumentCount: argumentCount }; + var selected = help.items[selectedItemIndex]; + if (selected.isVariadic) { + var firstRest = ts.findIndex(selected.parameters, function (p) { return !!p.isRest; }); + if (-1 < firstRest && firstRest < selected.parameters.length - 1) { + // We don't have any code to get this correct; instead, don't highlight a current parameter AT ALL + help.argumentIndex = selected.parameters.length; + } + else { + help.argumentIndex = Math.min(help.argumentIndex, selected.parameters.length - 1); + } + } + return help; } function createTypeHelpItems(symbol, _a, sourceFile, checker) { var argumentCount = _a.argumentCount, applicableSpan = _a.argumentsSpan, invocation = _a.invocation, argumentIndex = _a.argumentIndex; @@ -130196,7 +135021,7 @@ var ts; var printer = ts.createPrinter({ removeComments: true }); var parameters = typeParameters.map(function (t) { return createSignatureHelpParameterForTypeParameter(t, checker, enclosingDeclaration, sourceFile, printer); }); var documentation = symbol.getDocumentationComment(checker); - var tags = symbol.getJsDocTags(); + var tags = symbol.getJsDocTags(checker); var prefixDisplayParts = __spreadArray(__spreadArray([], typeSymbolDisplay), [ts.punctuationPart(29 /* LessThanToken */)]); return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(31 /* GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; } @@ -130239,7 +135064,6 @@ var ts; }); } function itemInfoForParameters(candidateSignature, checker, enclosingDeclaration, sourceFile) { - var isVariadic = checker.hasEffectiveRestParameter(candidateSignature); var printer = ts.createPrinter({ removeComments: true }); var typeParameterParts = ts.mapToDisplayParts(function (writer) { if (candidateSignature.typeParameters && candidateSignature.typeParameters.length) { @@ -130248,14 +135072,15 @@ var ts; } }); var lists = checker.getExpandedParameters(candidateSignature); - return lists.map(function (parameterList) { - return { - isVariadic: isVariadic && (lists.length === 1 || !!(parameterList[parameterList.length - 1].checkFlags & 32768 /* RestParameter */)), - parameters: parameterList.map(function (p) { return createSignatureHelpParameterForParameter(p, checker, enclosingDeclaration, sourceFile, printer); }), - prefix: __spreadArray(__spreadArray([], typeParameterParts), [ts.punctuationPart(20 /* OpenParenToken */)]), - suffix: [ts.punctuationPart(21 /* CloseParenToken */)] - }; - }); + 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 */); }; + 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), [ts.punctuationPart(20 /* OpenParenToken */)]), + suffix: [ts.punctuationPart(21 /* CloseParenToken */)] + }); }); } function createSignatureHelpParameterForParameter(parameter, checker, enclosingDeclaration, sourceFile, printer) { var displayParts = ts.mapToDisplayParts(function (writer) { @@ -130263,14 +135088,15 @@ var ts; printer.writeNode(4 /* Unspecified */, param, sourceFile, writer); }); var isOptional = checker.isOptionalParameter(parameter.valueDeclaration); - return { name: parameter.name, documentation: parameter.getDocumentationComment(checker), displayParts: displayParts, isOptional: isOptional }; + var isRest = !!(parameter.checkFlags & 32768 /* 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); }); - return { name: typeParameter.symbol.name, documentation: typeParameter.symbol.getDocumentationComment(checker), displayParts: displayParts, isOptional: false }; + return { name: typeParameter.symbol.name, documentation: typeParameter.symbol.getDocumentationComment(checker), displayParts: displayParts, isOptional: false, isRest: false }; } })(SignatureHelp = ts.SignatureHelp || (ts.SignatureHelp = {})); })(ts || (ts = {})); @@ -130480,7 +135306,7 @@ var ts; diags.push(ts.createDiagnosticForNode(node.name || node, ts.Diagnostics.JSDoc_types_may_be_moved_to_TypeScript_types)); } } - if (ts.isFunctionLikeDeclaration(node)) { + if (canBeConvertedToAsync(node)) { addConvertToAsyncFunctionDiagnostics(node, checker, diags); } node.forEachChild(check); @@ -130491,11 +135317,11 @@ var ts; function containsTopLevelCommonjs(sourceFile) { return sourceFile.statements.some(function (statement) { switch (statement.kind) { - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return statement.declarationList.declarations.some(function (decl) { return !!decl.initializer && ts.isRequireCall(propertyAccessLeftHandSide(decl.initializer), /*checkArgumentIsStringLiteralLike*/ true); }); - case 233 /* ExpressionStatement */: { + case 235 /* ExpressionStatement */: { var expression = statement.expression; if (!ts.isBinaryExpression(expression)) return ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true); @@ -130512,12 +135338,12 @@ var ts; } function importNameForConvertToDefaultImport(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: var importClause = node.importClause, moduleSpecifier = node.moduleSpecifier; - return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 263 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) + return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 265 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) ? importClause.namedBindings.name : undefined; - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return node.name; default: return undefined; @@ -130533,35 +135359,35 @@ var ts; return !ts.isAsyncFunction(node) && node.body && ts.isBlock(node.body) && - hasReturnStatementWithPromiseHandler(node.body) && + hasReturnStatementWithPromiseHandler(node.body, checker) && returnsPromise(node, checker); } function returnsPromise(node, checker) { - var functionType = checker.getTypeAtLocation(node); - var callSignatures = checker.getSignaturesOfType(functionType, 0 /* Call */); - var returnType = callSignatures.length ? checker.getReturnTypeOfSignature(callSignatures[0]) : undefined; + var signature = checker.getSignatureFromDeclaration(node); + var returnType = signature ? checker.getReturnTypeOfSignature(signature) : undefined; return !!returnType && !!checker.getPromisedTypeOfPromise(returnType); } + ts.returnsPromise = returnsPromise; function getErrorNodeFromCommonJsIndicator(commonJsModuleIndicator) { return ts.isBinaryExpression(commonJsModuleIndicator) ? commonJsModuleIndicator.left : commonJsModuleIndicator; } - function hasReturnStatementWithPromiseHandler(body) { - return !!ts.forEachReturnStatement(body, isReturnStatementWithFixablePromiseHandler); + function hasReturnStatementWithPromiseHandler(body, checker) { + return !!ts.forEachReturnStatement(body, function (statement) { return isReturnStatementWithFixablePromiseHandler(statement, checker); }); } - function isReturnStatementWithFixablePromiseHandler(node) { - return ts.isReturnStatement(node) && !!node.expression && isFixablePromiseHandler(node.expression); + function isReturnStatementWithFixablePromiseHandler(node, checker) { + return ts.isReturnStatement(node) && !!node.expression && isFixablePromiseHandler(node.expression, checker); } ts.isReturnStatementWithFixablePromiseHandler = isReturnStatementWithFixablePromiseHandler; // Should be kept up to date with transformExpression in convertToAsyncFunction.ts - function isFixablePromiseHandler(node) { + function isFixablePromiseHandler(node, checker) { // ensure outermost call exists and is a promise handler - if (!isPromiseHandler(node) || !node.arguments.every(isFixablePromiseArgument)) { + if (!isPromiseHandler(node) || !node.arguments.every(function (arg) { return isFixablePromiseArgument(arg, checker); })) { return false; } // ensure all chained calls are valid var currentNode = node.expression; while (isPromiseHandler(currentNode) || ts.isPropertyAccessExpression(currentNode)) { - if (ts.isCallExpression(currentNode) && !currentNode.arguments.every(isFixablePromiseArgument)) { + if (ts.isCallExpression(currentNode) && !currentNode.arguments.every(function (arg) { return isFixablePromiseArgument(arg, checker); })) { return false; } currentNode = currentNode.expression; @@ -130579,21 +135405,34 @@ var ts; if (node.arguments.length < 2) return true; return ts.some(node.arguments, function (arg) { - return arg.kind === 103 /* NullKeyword */ || + return arg.kind === 104 /* NullKeyword */ || ts.isIdentifier(arg) && arg.text === "undefined"; }); } // should be kept up to date with getTransformationBody in convertToAsyncFunction.ts - function isFixablePromiseArgument(arg) { + function isFixablePromiseArgument(arg, checker) { switch (arg.kind) { - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + var functionFlags = ts.getFunctionFlags(arg); + if (functionFlags & 1 /* Generator */) { + return false; + } + // falls through + case 211 /* ArrowFunction */: visitedNestedConvertibleFunctions.set(getKeyFromNode(arg), true); // falls through - case 103 /* NullKeyword */: - case 78 /* Identifier */: // identifier includes undefined + case 104 /* NullKeyword */: return true; + case 79 /* Identifier */: + case 203 /* PropertyAccessExpression */: { + var symbol = checker.getSymbolAtLocation(arg); + if (!symbol) { + return false; + } + return checker.isUndefinedSymbol(symbol) || + ts.some(ts.skipAlias(symbol, checker).declarations, function (d) { return ts.isFunctionLike(d) || ts.hasInitializer(d) && !!d.initializer && ts.isFunctionLike(d.initializer); }); + } default: return false; } @@ -130603,18 +135442,30 @@ var ts; } function canBeConvertedToClass(node, checker) { var _a, _b, _c, _d; - if (node.kind === 208 /* FunctionExpression */) { + if (node.kind === 210 /* 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 === 251 /* FunctionDeclaration */) { + if (node.kind === 253 /* FunctionDeclaration */) { return !!((_d = node.symbol.members) === null || _d === void 0 ? void 0 : _d.size); } return false; } + function canBeConvertedToAsync(node) { + switch (node.kind) { + case 253 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + return true; + default: + return false; + } + } + ts.canBeConvertedToAsync = canBeConvertedToAsync; })(ts || (ts = {})); /* @internal */ var ts; @@ -130630,7 +135481,7 @@ var ts; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); if (flags & 32 /* Class */) { - return ts.getDeclarationOfKind(symbol, 221 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 223 /* ClassExpression */) ? "local class" /* localClassElement */ : "class" /* classElement */; } if (flags & 384 /* Enum */) @@ -130665,7 +135516,7 @@ var ts; if (typeChecker.isArgumentsSymbol(symbol)) { return "local var" /* localVariableElement */; } - if (location.kind === 107 /* ThisKeyword */ && ts.isExpression(location)) { + if (location.kind === 108 /* ThisKeyword */ && ts.isExpression(location)) { return "parameter" /* parameterElement */; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); @@ -130714,11 +135565,11 @@ var ts; // If we requested completions after `x.` at the top-level, we may be at a source file location. switch (location.parent && location.parent.kind) { // If we've typed a character of the attribute name, will be 'JsxAttribute', else will be 'JsxOpeningElement'. - case 275 /* JsxOpeningElement */: - case 273 /* JsxElement */: - case 274 /* JsxSelfClosingElement */: - return location.kind === 78 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; - case 280 /* JsxAttribute */: + case 277 /* JsxOpeningElement */: + case 275 /* JsxElement */: + case 276 /* JsxSelfClosingElement */: + return location.kind === 79 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; + case 282 /* JsxAttribute */: return "JSX attribute" /* jsxAttribute */; default: return "property" /* memberVariableElement */; @@ -130726,14 +135577,11 @@ var ts; } return "" /* unknown */; } - function isDeprecatedDeclaration(decl) { - return !!(ts.getCombinedNodeFlagsAlwaysIncludeJSDoc(decl) & 8192 /* Deprecated */); - } 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) && isDeprecatedDeclaration(declaration) && ts.some(declarations, function (d) { return !isDeprecatedDeclaration(d); }) + var excludeFlags = ts.length(declarations) && ts.isDeprecatedDeclaration(declaration) && ts.some(declarations, function (d) { return !ts.isDeprecatedDeclaration(d); }) ? 8192 /* Deprecated */ : 0 /* None */; var modifiers = ts.getNodeModifiers(declaration, excludeFlags); @@ -130764,6 +135612,7 @@ var ts; SymbolDisplay.getSymbolModifiers = getSymbolModifiers; // TODO(drosen): Currently completion entry details passes the SemanticMeaning.All instead of using semanticMeaning of location function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, enclosingDeclaration, location, semanticMeaning, alias) { + var _a; if (semanticMeaning === void 0) { semanticMeaning = ts.getMeaningFromLocation(location); } var displayParts = []; var documentation = []; @@ -130771,14 +135620,14 @@ var ts; var symbolFlags = ts.getCombinedLocalAndExportSymbolFlags(symbol); var symbolKind = semanticMeaning & 1 /* Value */ ? getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) : "" /* unknown */; var hasAddedSymbolInfo = false; - var isThisExpression = location.kind === 107 /* ThisKeyword */ && ts.isInExpressionContext(location); + var isThisExpression = location.kind === 108 /* ThisKeyword */ && ts.isInExpressionContext(location); var type; var printer; var documentationFromAlias; var tagsFromAlias; var hasMultipleSignatures = false; - if (location.kind === 107 /* ThisKeyword */ && !isThisExpression) { - return { displayParts: [ts.keywordPart(107 /* ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* primitiveType */, tags: undefined }; + if (location.kind === 108 /* ThisKeyword */ && !isThisExpression) { + return { displayParts: [ts.keywordPart(108 /* ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* 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 */) { @@ -130787,8 +135636,8 @@ var ts; symbolKind = "property" /* memberVariableElement */; } var signature = void 0; - type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol.exportSymbol || symbol, location); - if (location.parent && location.parent.kind === 201 /* PropertyAccessExpression */) { + type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); + if (location.parent && location.parent.kind === 203 /* 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)) { @@ -130808,9 +135657,9 @@ var ts; } if (callExpressionLike) { signature = typeChecker.getResolvedSignature(callExpressionLike); // TODO: GH#18217 - var useConstructSignatures = callExpressionLike.kind === 204 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 105 /* SuperKeyword */); + var useConstructSignatures = callExpressionLike.kind === 206 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 106 /* SuperKeyword */); var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); - if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { + if (signature && !ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { // Get the first signature if there is one -- allSignatures may contain // either the original signature or its target, so check for either signature = allSignatures.length ? allSignatures[0] : undefined; @@ -130827,10 +135676,10 @@ var ts; displayParts.push(ts.spacePart()); if (useConstructSignatures) { if (signature.flags & 4 /* Abstract */) { - displayParts.push(ts.keywordPart(125 /* AbstractKeyword */)); + displayParts.push(ts.keywordPart(126 /* AbstractKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(102 /* NewKeyword */)); + displayParts.push(ts.keywordPart(103 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -130855,10 +135704,10 @@ var ts; } if (useConstructSignatures) { if (signature.flags & 4 /* Abstract */) { - displayParts.push(ts.keywordPart(125 /* AbstractKeyword */)); + displayParts.push(ts.keywordPart(126 /* AbstractKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(102 /* NewKeyword */)); + displayParts.push(ts.keywordPart(103 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addSignatureDisplayParts(signature, allSignatures, 262144 /* WriteArrowStyleSignature */); @@ -130872,32 +135721,34 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* Accessor */)) || // name of function declaration - (location.kind === 132 /* ConstructorKeyword */ && location.parent.kind === 166 /* Constructor */)) { // At constructor keyword of constructor declaration + (location.kind === 133 /* ConstructorKeyword */ && location.parent.kind === 168 /* 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 === 132 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); + return declaration === (location.kind === 133 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); }); if (locationIsSymbolDeclaration) { - var allSignatures = functionDeclaration_1.kind === 166 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration_1.kind === 168 /* 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 === 166 /* Constructor */) { + if (functionDeclaration_1.kind === 168 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = "constructor" /* constructorImplementationElement */; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 169 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 171 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } - addSignatureDisplayParts(signature, allSignatures); + if (signature) { + addSignatureDisplayParts(signature, allSignatures); + } hasAddedSymbolInfo = true; hasMultipleSignatures = allSignatures.length > 1; } @@ -130905,7 +135756,7 @@ var ts; } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { addAliasPrefixIfNecessary(); - if (ts.getDeclarationOfKind(symbol, 221 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 223 /* 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 @@ -130913,7 +135764,7 @@ var ts; } else { // Class declaration has name which is not local. - displayParts.push(ts.keywordPart(83 /* ClassKeyword */)); + displayParts.push(ts.keywordPart(84 /* ClassKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); @@ -130921,37 +135772,37 @@ var ts; } if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(117 /* InterfaceKeyword */)); + displayParts.push(ts.keywordPart(118 /* InterfaceKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if ((symbolFlags & 524288 /* TypeAlias */) && (semanticMeaning & 2 /* Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(149 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(150 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(62 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* EqualsToken */)); displayParts.push(ts.spacePart()); ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 8388608 /* InTypeAlias */)); } if (symbolFlags & 384 /* Enum */) { prefixNextMeaning(); if (ts.some(symbol.declarations, function (d) { return ts.isEnumDeclaration(d) && ts.isEnumConst(d); })) { - displayParts.push(ts.keywordPart(84 /* ConstKeyword */)); + displayParts.push(ts.keywordPart(85 /* ConstKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(91 /* EnumKeyword */)); + displayParts.push(ts.keywordPart(92 /* EnumKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536 /* Module */ && !isThisExpression) { prefixNextMeaning(); - var declaration = ts.getDeclarationOfKind(symbol, 256 /* ModuleDeclaration */); - var isNamespace = declaration && declaration.name && declaration.name.kind === 78 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 140 /* NamespaceKeyword */ : 139 /* ModuleKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 258 /* ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 79 /* Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 141 /* NamespaceKeyword */ : 140 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } @@ -130970,7 +135821,7 @@ var ts; } else { // Method/function type parameter - var decl = ts.getDeclarationOfKind(symbol, 159 /* TypeParameter */); + var decl = ts.getDeclarationOfKind(symbol, 161 /* TypeParameter */); if (decl === undefined) return ts.Debug.fail(); var declaration = decl.parent; @@ -130978,21 +135829,21 @@ var ts; if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); var signature = typeChecker.getSignatureFromDeclaration(declaration); // TODO: GH#18217 - if (declaration.kind === 170 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(102 /* NewKeyword */)); + if (declaration.kind === 172 /* ConstructSignature */) { + displayParts.push(ts.keywordPart(103 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 169 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 171 /* CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 254 /* TypeAliasDeclaration */) { + else if (declaration.kind === 256 /* TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path addInPrefix(); - displayParts.push(ts.keywordPart(149 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(150 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -131003,12 +135854,12 @@ var ts; if (symbolFlags & 8 /* EnumMember */) { symbolKind = "enum member" /* enumMemberElement */; addPrefixForAnyFunctionOrVar(symbol, "enum member"); - var declaration = symbol.declarations[0]; - if (declaration.kind === 291 /* EnumMember */) { + var declaration = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]; + if ((declaration === null || declaration === void 0 ? void 0 : declaration.kind) === 293 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(62 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* EqualsToken */)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(ts.getTextOfConstantValue(constantValue), typeof constantValue === "number" ? ts.SymbolDisplayPartKind.numericLiteral : ts.SymbolDisplayPartKind.stringLiteral)); } @@ -131034,37 +135885,39 @@ var ts; } else { documentationFromAlias = resolvedSymbol.getContextualDocumentationComment(resolvedNode, typeChecker); - tagsFromAlias = resolvedSymbol.getJsDocTags(); + tagsFromAlias = resolvedSymbol.getJsDocTags(typeChecker); } } } - switch (symbol.declarations[0].kind) { - case 259 /* NamespaceExportDeclaration */: - displayParts.push(ts.keywordPart(92 /* ExportKeyword */)); - displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(140 /* NamespaceKeyword */)); - break; - case 266 /* ExportAssignment */: - displayParts.push(ts.keywordPart(92 /* ExportKeyword */)); - displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 62 /* EqualsToken */ : 87 /* DefaultKeyword */)); - break; - case 270 /* ExportSpecifier */: - displayParts.push(ts.keywordPart(92 /* ExportKeyword */)); - break; - default: - displayParts.push(ts.keywordPart(99 /* ImportKeyword */)); + if (symbol.declarations) { + switch (symbol.declarations[0].kind) { + case 261 /* NamespaceExportDeclaration */: + displayParts.push(ts.keywordPart(93 /* ExportKeyword */)); + displayParts.push(ts.spacePart()); + displayParts.push(ts.keywordPart(141 /* NamespaceKeyword */)); + break; + case 268 /* ExportAssignment */: + displayParts.push(ts.keywordPart(93 /* ExportKeyword */)); + displayParts.push(ts.spacePart()); + displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 63 /* EqualsToken */ : 88 /* DefaultKeyword */)); + break; + case 272 /* ExportSpecifier */: + displayParts.push(ts.keywordPart(93 /* ExportKeyword */)); + break; + default: + displayParts.push(ts.keywordPart(100 /* ImportKeyword */)); + } } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 260 /* ImportEqualsDeclaration */) { + if (declaration.kind === 262 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(62 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(143 /* RequireKeyword */)); + displayParts.push(ts.keywordPart(144 /* RequireKeyword */)); displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); @@ -131073,7 +135926,7 @@ var ts; var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(62 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* EqualsToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -131087,7 +135940,7 @@ var ts; if (type) { if (isThisExpression) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(107 /* ThisKeyword */)); + displayParts.push(ts.keywordPart(108 /* ThisKeyword */)); } else { addPrefixForAnyFunctionOrVar(symbol, symbolKind); @@ -131145,10 +135998,10 @@ var ts; // 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 && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 297 /* SourceFile */; })) { - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 216 /* BinaryExpression */) { + if (symbol.parent && symbol.declarations && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 299 /* SourceFile */; })) { + for (var _i = 0, _b = symbol.declarations; _i < _b.length; _i++) { + var declaration = _b[_i]; + if (!declaration.parent || declaration.parent.kind !== 218 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -131156,7 +136009,7 @@ var ts; continue; } documentation = rhsSymbol.getDocumentationComment(typeChecker); - tags = rhsSymbol.getJsDocTags(); + tags = rhsSymbol.getJsDocTags(typeChecker); if (documentation.length > 0) { break; } @@ -131164,7 +136017,7 @@ var ts; } } if (tags.length === 0 && !hasMultipleSignatures) { - tags = symbol.getJsDocTags(); + tags = symbol.getJsDocTags(typeChecker); } if (documentation.length === 0 && documentationFromAlias) { documentation = documentationFromAlias; @@ -131193,7 +136046,7 @@ var ts; } function addInPrefix() { displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(100 /* InKeyword */)); + displayParts.push(ts.keywordPart(101 /* InKeyword */)); displayParts.push(ts.spacePart()); } function addFullSymbolName(symbolToDisplay, enclosingDeclaration) { @@ -131266,16 +136119,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 208 /* FunctionExpression */) { + if (declaration.kind === 210 /* FunctionExpression */) { return true; } - if (declaration.kind !== 249 /* VariableDeclaration */ && declaration.kind !== 251 /* FunctionDeclaration */) { + if (declaration.kind !== 251 /* VariableDeclaration */ && declaration.kind !== 253 /* 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 === 297 /* SourceFile */ || parent.kind === 257 /* ModuleBlock */) { + if (parent.kind === 299 /* SourceFile */ || parent.kind === 259 /* ModuleBlock */) { return false; } } @@ -131377,11 +136230,10 @@ var ts; /*@internal*/ function fixupCompilerOptions(options, diagnostics) { // Lazily create this value to fix module loading errors. - commandLineOptionsStringToEnum = commandLineOptionsStringToEnum || ts.filter(ts.optionDeclarations, function (o) { - return typeof o.type === "object" && !ts.forEachEntry(o.type, function (v) { return typeof v !== "number"; }); - }); + 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_8 = function (opt) { + var _loop_9 = function (opt) { if (!ts.hasProperty(options, opt.name)) { return "continue"; } @@ -131400,7 +136252,7 @@ var ts; }; for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) { var opt = commandLineOptionsStringToEnum_1[_i]; - _loop_8(opt); + _loop_9(opt); } return options; } @@ -131565,8 +136417,8 @@ var ts; function shouldRescanGreaterThanToken(node) { switch (node.kind) { case 33 /* GreaterThanEqualsToken */: - case 70 /* GreaterThanGreaterThanEqualsToken */: - case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanEqualsToken */: + case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: case 49 /* GreaterThanGreaterThanGreaterThanToken */: case 48 /* GreaterThanGreaterThanToken */: return true; @@ -131576,25 +136428,18 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 280 /* JsxAttribute */: - case 275 /* JsxOpeningElement */: - case 276 /* JsxClosingElement */: - case 274 /* JsxSelfClosingElement */: + case 282 /* JsxAttribute */: + case 277 /* JsxOpeningElement */: + case 278 /* JsxClosingElement */: + case 276 /* 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 === 78 /* Identifier */; + return ts.isKeyword(node.kind) || node.kind === 79 /* Identifier */; } } return false; } function shouldRescanJsxText(node) { - var isJSXText = ts.isJsxText(node); - if (isJSXText) { - var containingElement = ts.findAncestor(node.parent, function (p) { return ts.isJsxElement(p); }); - if (!containingElement) - return false; // should never happen - return !ts.isParenthesizedExpression(containingElement.parent); - } - return false; + return ts.isJsxText(node); } function shouldRescanSlashToken(container) { return container.kind === 13 /* RegularExpressionLiteral */; @@ -131607,7 +136452,7 @@ var ts; return node.parent && ts.isJsxAttribute(node.parent) && node.parent.initializer === node; } function startsWithSlashToken(t) { - return t === 43 /* SlashToken */ || t === 67 /* SlashEqualsToken */; + return t === 43 /* SlashToken */ || t === 68 /* SlashEqualsToken */; } function readTokenInfo(n) { ts.Debug.assert(isOnToken()); @@ -131691,7 +136536,7 @@ var ts; return scanner.scanJsxIdentifier(); case 5 /* RescanJsxText */: lastScanAction = 5 /* RescanJsxText */; - return scanner.reScanJsxToken(); + return scanner.reScanJsxToken(/* allowMultilineJsxText */ false); case 6 /* RescanJsxAttributeValue */: lastScanAction = 6 /* RescanJsxAttributeValue */; return scanner.reScanJsxAttributeValue(); @@ -131780,7 +136625,7 @@ var ts; (function (formatting) { function getAllRules() { var allTokens = []; - for (var token = 0 /* FirstToken */; token <= 156 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 158 /* LastToken */; token++) { if (token !== 1 /* EndOfFileToken */) { allTokens.push(token); } @@ -131795,27 +136640,27 @@ var ts; var anyToken = { tokens: allTokens, isSpecific: false }; var anyTokenIncludingMultilineComments = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens), [3 /* MultiLineCommentTrivia */])); var anyTokenIncludingEOF = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens), [1 /* EndOfFileToken */])); - var keywords = tokenRangeFromRange(80 /* FirstKeyword */, 156 /* LastKeyword */); - var binaryOperators = tokenRangeFromRange(29 /* FirstBinaryOperator */, 77 /* LastBinaryOperator */); - var binaryKeywordOperators = [100 /* InKeyword */, 101 /* InstanceOfKeyword */, 156 /* OfKeyword */, 126 /* AsKeyword */, 137 /* IsKeyword */]; + var keywords = tokenRangeFromRange(81 /* FirstKeyword */, 158 /* LastKeyword */); + var binaryOperators = tokenRangeFromRange(29 /* FirstBinaryOperator */, 78 /* LastBinaryOperator */); + var binaryKeywordOperators = [101 /* InKeyword */, 102 /* InstanceOfKeyword */, 158 /* OfKeyword */, 127 /* AsKeyword */, 138 /* IsKeyword */]; var unaryPrefixOperators = [45 /* PlusPlusToken */, 46 /* MinusMinusToken */, 54 /* TildeToken */, 53 /* ExclamationToken */]; var unaryPrefixExpressions = [ - 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 78 /* Identifier */, 20 /* OpenParenToken */, - 22 /* OpenBracketToken */, 18 /* OpenBraceToken */, 107 /* ThisKeyword */, 102 /* NewKeyword */ + 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 79 /* Identifier */, 20 /* OpenParenToken */, + 22 /* OpenBracketToken */, 18 /* OpenBraceToken */, 108 /* ThisKeyword */, 103 /* NewKeyword */ ]; - var unaryPreincrementExpressions = [78 /* Identifier */, 20 /* OpenParenToken */, 107 /* ThisKeyword */, 102 /* NewKeyword */]; - var unaryPostincrementExpressions = [78 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 102 /* NewKeyword */]; - var unaryPredecrementExpressions = [78 /* Identifier */, 20 /* OpenParenToken */, 107 /* ThisKeyword */, 102 /* NewKeyword */]; - var unaryPostdecrementExpressions = [78 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 102 /* 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([78 /* Identifier */], ts.typeKeywords); + var typeNames = __spreadArray([79 /* Identifier */], ts.typeKeywords); // 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([78 /* Identifier */, 3 /* MultiLineCommentTrivia */, 83 /* ClassKeyword */, 92 /* ExportKeyword */, 99 /* ImportKeyword */]); + var typeScriptOpenBraceLeftTokenRange = tokenRangeFrom([79 /* Identifier */, 3 /* MultiLineCommentTrivia */, 84 /* ClassKeyword */, 93 /* ExportKeyword */, 100 /* ImportKeyword */]); // Place a space before open brace in a control flow construct - var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 89 /* DoKeyword */, 110 /* TryKeyword */, 95 /* FinallyKeyword */, 90 /* ElseKeyword */]); + var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 90 /* DoKeyword */, 111 /* TryKeyword */, 96 /* FinallyKeyword */, 91 /* ElseKeyword */]); // These rules are higher in priority than user-configurable var highPriorityCommonRules = [ // Leave comments alone @@ -131830,7 +136675,7 @@ var ts; 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", 99 /* ImportKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 16 /* DeleteSpace */), + rule("NoSpaceBetweenImportParenInImportType", 100 /* ImportKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 16 /* DeleteSpace */), // Special handling of unary operators. // Prefix operators generally shouldn't have a space between // them and their target unary expression. @@ -131857,79 +136702,79 @@ var ts; rule("SpaceAfterCloseBrace", 19 /* CloseBraceToken */, anyTokenExcept(21 /* CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 4 /* 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 */, 90 /* ElseKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBetweenCloseBraceAndWhile", 19 /* CloseBraceToken */, 114 /* WhileKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + 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 */), // 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", 97 /* FunctionKeyword */, 41 /* AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 16 /* DeleteSpace */), - rule("SpaceAfterStarInGeneratorDeclaration", 41 /* AsteriskToken */, 78 /* Identifier */, [isFunctionDeclarationOrFunctionExpressionContext], 4 /* InsertSpace */), - rule("SpaceAfterFunctionInFuncDecl", 97 /* FunctionKeyword */, anyToken, [isFunctionDeclContext], 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 */), // Insert new line after { and before } in multi-line contexts. rule("NewLineAfterOpenBraceInBlockContext", 18 /* OpenBraceToken */, anyToken, [isMultilineBlockContext], 8 /* 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", [134 /* GetKeyword */, 146 /* SetKeyword */], 78 /* Identifier */, [isFunctionDeclContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenYieldKeywordAndStar", 124 /* YieldKeyword */, 41 /* AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 16 /* DeleteSpace */), - rule("SpaceBetweenYieldOrYieldStarAndOperand", [124 /* YieldKeyword */, 41 /* AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 4 /* InsertSpace */), - rule("NoSpaceBetweenReturnAndSemicolon", 104 /* ReturnKeyword */, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("SpaceAfterCertainKeywords", [112 /* VarKeyword */, 108 /* ThrowKeyword */, 102 /* NewKeyword */, 88 /* DeleteKeyword */, 104 /* ReturnKeyword */, 111 /* TypeOfKeyword */, 130 /* AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceAfterLetConstInVariableDeclaration", [118 /* LetKeyword */, 84 /* ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 4 /* InsertSpace */), + rule("SpaceAfterGetSetInMember", [135 /* GetKeyword */, 147 /* 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 */, 131 /* 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 */), // 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", 113 /* VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 4 /* InsertSpace */), + rule("SpaceAfterVoidOperator", 114 /* VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 4 /* InsertSpace */), // Async-await - rule("SpaceBetweenAsyncAndOpenParen", 129 /* AsyncKeyword */, 20 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBetweenAsyncAndFunctionKeyword", 129 /* AsyncKeyword */, [97 /* FunctionKeyword */, 78 /* Identifier */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenAsyncAndOpenParen", 130 /* AsyncKeyword */, 20 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenAsyncAndFunctionKeyword", 130 /* AsyncKeyword */, [98 /* FunctionKeyword */, 79 /* Identifier */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Template string - rule("NoSpaceBetweenTagAndTemplateString", [78 /* Identifier */, 21 /* CloseParenToken */], [14 /* NoSubstitutionTemplateLiteral */, 15 /* TemplateHead */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBetweenTagAndTemplateString", [79 /* Identifier */, 21 /* CloseParenToken */], [14 /* NoSubstitutionTemplateLiteral */, 15 /* TemplateHead */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // JSX opening elements - rule("SpaceBeforeJsxAttribute", anyToken, 78 /* Identifier */, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + 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, 62 /* EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterEqualInJsxAttribute", 62 /* EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeEqualInJsxAttribute", anyToken, 63 /* EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterEqualInJsxAttribute", 63 /* EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // TypeScript-specific rules // Use of module as a function call. e.g.: import m2 = module("m2"); - rule("NoSpaceAfterModuleImport", [139 /* ModuleKeyword */, 143 /* RequireKeyword */], 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterModuleImport", [140 /* ModuleKeyword */, 144 /* RequireKeyword */], 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Add a space around certain TypeScript keywords rule("SpaceAfterCertainTypeScriptKeywords", [ - 125 /* AbstractKeyword */, - 83 /* ClassKeyword */, - 133 /* DeclareKeyword */, - 87 /* DefaultKeyword */, - 91 /* EnumKeyword */, - 92 /* ExportKeyword */, - 93 /* ExtendsKeyword */, - 134 /* GetKeyword */, - 116 /* ImplementsKeyword */, - 99 /* ImportKeyword */, - 117 /* InterfaceKeyword */, - 139 /* ModuleKeyword */, - 140 /* NamespaceKeyword */, - 120 /* PrivateKeyword */, - 122 /* PublicKeyword */, - 121 /* ProtectedKeyword */, - 142 /* ReadonlyKeyword */, - 146 /* SetKeyword */, - 123 /* StaticKeyword */, - 149 /* TypeKeyword */, - 153 /* FromKeyword */, - 138 /* KeyOfKeyword */, - 135 /* InferKeyword */, + 126 /* AbstractKeyword */, + 84 /* ClassKeyword */, + 134 /* DeclareKeyword */, + 88 /* DefaultKeyword */, + 92 /* EnumKeyword */, + 93 /* ExportKeyword */, + 94 /* ExtendsKeyword */, + 135 /* GetKeyword */, + 117 /* ImplementsKeyword */, + 100 /* ImportKeyword */, + 118 /* InterfaceKeyword */, + 140 /* ModuleKeyword */, + 141 /* NamespaceKeyword */, + 121 /* PrivateKeyword */, + 123 /* PublicKeyword */, + 122 /* ProtectedKeyword */, + 143 /* ReadonlyKeyword */, + 147 /* SetKeyword */, + 124 /* StaticKeyword */, + 150 /* TypeKeyword */, + 154 /* FromKeyword */, + 139 /* KeyOfKeyword */, + 136 /* InferKeyword */, ], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [93 /* ExtendsKeyword */, 116 /* ImplementsKeyword */, 153 /* FromKeyword */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [94 /* ExtendsKeyword */, 117 /* ImplementsKeyword */, 154 /* FromKeyword */], [isNonJsxSameLineTokenContext], 4 /* 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 */), // Lambda expressions rule("SpaceBeforeArrow", anyToken, 38 /* EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), rule("SpaceAfterArrow", 38 /* EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Optional parameters and let args - rule("NoSpaceAfterEllipsis", 25 /* DotDotDotToken */, 78 /* Identifier */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterEllipsis", 25 /* DotDotDotToken */, 79 /* Identifier */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), rule("NoSpaceAfterOptionalParameters", 57 /* QuestionToken */, [21 /* CloseParenToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */), // Remove spaces in empty interface literals. e.g.: x: {} rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 16 /* DeleteSpace */), @@ -131940,38 +136785,38 @@ var ts; 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 */), // decorators - rule("SpaceBeforeAt", [21 /* CloseParenToken */, 78 /* Identifier */], 59 /* AtToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeAt", [21 /* CloseParenToken */, 79 /* Identifier */], 59 /* AtToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), rule("NoSpaceAfterAt", 59 /* AtToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Insert space after @ in decorator rule("SpaceAfterDecorator", anyToken, [ - 125 /* AbstractKeyword */, - 78 /* Identifier */, - 92 /* ExportKeyword */, - 87 /* DefaultKeyword */, - 83 /* ClassKeyword */, - 123 /* StaticKeyword */, - 122 /* PublicKeyword */, - 120 /* PrivateKeyword */, - 121 /* ProtectedKeyword */, - 134 /* GetKeyword */, - 146 /* SetKeyword */, + 126 /* AbstractKeyword */, + 79 /* Identifier */, + 93 /* ExportKeyword */, + 88 /* DefaultKeyword */, + 84 /* ClassKeyword */, + 124 /* StaticKeyword */, + 123 /* PublicKeyword */, + 121 /* PrivateKeyword */, + 122 /* ProtectedKeyword */, + 135 /* GetKeyword */, + 147 /* SetKeyword */, 22 /* OpenBracketToken */, 41 /* AsteriskToken */, ], [isEndOfDecoratorContextOnSameLine], 4 /* InsertSpace */), rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 53 /* ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterNewKeywordOnConstructorSignature", 102 /* NewKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterNewKeywordOnConstructorSignature", 103 /* NewKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 16 /* DeleteSpace */), rule("SpaceLessThanAndNonJSXTypeAnnotation", 29 /* LessThanToken */, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext], 4 /* 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", 132 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceAfterConstructor", 132 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterConstructor", 133 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceAfterConstructor", 133 /* 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 */), // Insert space after function keyword for anonymous functions - rule("SpaceAfterAnonymousFunctionKeyword", [97 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 4 /* InsertSpace */), - rule("NoSpaceAfterAnonymousFunctionKeyword", [97 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 16 /* DeleteSpace */), + 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 */), // 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 */), @@ -132040,16 +136885,16 @@ var ts; rule("SpaceBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), rule("NoSpaceBeforeComma", anyToken, 27 /* CommaToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // No space before and after indexer `x[]` - rule("NoSpaceBeforeOpenBracket", anyTokenExcept(129 /* AsyncKeyword */, 81 /* CaseKeyword */), 22 /* OpenBracketToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeOpenBracket", anyTokenExcept(130 /* 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 */), // Remove extra space between for and await - rule("SpaceBetweenForAndAwaitKeyword", 96 /* ForKeyword */, 130 /* AwaitKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenForAndAwaitKeyword", 97 /* ForKeyword */, 131 /* AwaitKeyword */, [isNonJsxSameLineTokenContext], 4 /* 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 */, 89 /* DoKeyword */, 90 /* ElseKeyword */, 81 /* CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 4 /* InsertSpace */), + rule("SpaceBetweenStatements", [21 /* CloseParenToken */, 90 /* DoKeyword */, 91 /* ElseKeyword */, 82 /* CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 4 /* InsertSpace */), // This low-pri rule takes care of "try {", "catch {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. - rule("SpaceAfterTryCatchFinally", [110 /* TryKeyword */, 82 /* CatchKeyword */, 95 /* FinallyKeyword */], 18 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceAfterTryCatchFinally", [111 /* TryKeyword */, 83 /* CatchKeyword */, 96 /* FinallyKeyword */], 18 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), ]; return __spreadArray(__spreadArray(__spreadArray([], highPriorityCommonRules), userConfigurableRules), lowPriorityCommonRules); } @@ -132108,51 +136953,51 @@ var ts; return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; }; } function isForContext(context) { - return context.contextNode.kind === 237 /* ForStatement */; + return context.contextNode.kind === 239 /* ForStatement */; } function isNotForContext(context) { return !isForContext(context); } function isBinaryOpContext(context) { switch (context.contextNode.kind) { - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return context.contextNode.operatorToken.kind !== 27 /* CommaToken */; - case 217 /* ConditionalExpression */: - case 184 /* ConditionalType */: - case 224 /* AsExpression */: - case 270 /* ExportSpecifier */: - case 265 /* ImportSpecifier */: - case 172 /* TypePredicate */: - case 182 /* UnionType */: - case 183 /* IntersectionType */: + case 219 /* ConditionalExpression */: + case 186 /* ConditionalType */: + case 226 /* AsExpression */: + case 272 /* ExportSpecifier */: + case 267 /* ImportSpecifier */: + case 174 /* TypePredicate */: + case 184 /* UnionType */: + case 185 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 198 /* BindingElement */: + case 200 /* BindingElement */: // equals in type X = ... // falls through - case 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: // equal in import a = module('a'); // falls through - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: // equal in let a = 0 // falls through - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: // equal in p = 0 // falls through - case 160 /* Parameter */: - case 291 /* EnumMember */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - return context.currentTokenSpan.kind === 62 /* EqualsToken */ || context.nextTokenSpan.kind === 62 /* EqualsToken */; + case 162 /* Parameter */: + case 293 /* EnumMember */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + return context.currentTokenSpan.kind === 63 /* EqualsToken */ || context.nextTokenSpan.kind === 63 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: // "in" keyword in [P in keyof T]: T[P] // falls through - case 159 /* TypeParameter */: - return context.currentTokenSpan.kind === 100 /* InKeyword */ || context.nextTokenSpan.kind === 100 /* InKeyword */ || context.currentTokenSpan.kind === 62 /* EqualsToken */ || context.nextTokenSpan.kind === 62 /* EqualsToken */; + case 161 /* TypeParameter */: + return context.currentTokenSpan.kind === 101 /* InKeyword */ || context.nextTokenSpan.kind === 101 /* InKeyword */ || context.currentTokenSpan.kind === 63 /* EqualsToken */ || context.nextTokenSpan.kind === 63 /* EqualsToken */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 239 /* ForOfStatement */: - return context.currentTokenSpan.kind === 156 /* OfKeyword */ || context.nextTokenSpan.kind === 156 /* OfKeyword */; + case 241 /* ForOfStatement */: + return context.currentTokenSpan.kind === 158 /* OfKeyword */ || context.nextTokenSpan.kind === 158 /* OfKeyword */; } return false; } @@ -132164,22 +137009,22 @@ var ts; } function isTypeAnnotationContext(context) { var contextKind = context.contextNode.kind; - return contextKind === 163 /* PropertyDeclaration */ || - contextKind === 162 /* PropertySignature */ || - contextKind === 160 /* Parameter */ || - contextKind === 249 /* VariableDeclaration */ || + return contextKind === 165 /* PropertyDeclaration */ || + contextKind === 164 /* PropertySignature */ || + contextKind === 162 /* Parameter */ || + contextKind === 251 /* VariableDeclaration */ || ts.isFunctionLikeKind(contextKind); } function isConditionalOperatorContext(context) { - return context.contextNode.kind === 217 /* ConditionalExpression */ || - context.contextNode.kind === 184 /* ConditionalType */; + return context.contextNode.kind === 219 /* ConditionalExpression */ || + context.contextNode.kind === 186 /* ConditionalType */; } function isSameLineTokenOrBeforeBlockContext(context) { return context.TokensAreOnSameLine() || isBeforeBlockContext(context); } function isBraceWrappedContext(context) { - return context.contextNode.kind === 196 /* ObjectBindingPattern */ || - context.contextNode.kind === 190 /* MappedType */ || + return context.contextNode.kind === 198 /* ObjectBindingPattern */ || + context.contextNode.kind === 192 /* MappedType */ || isSingleLineBlockContext(context); } // This check is done before an open brace in a control construct, a function, or a typescript block declaration @@ -132205,34 +137050,34 @@ var ts; return true; } switch (node.kind) { - case 230 /* Block */: - case 258 /* CaseBlock */: - case 200 /* ObjectLiteralExpression */: - case 257 /* ModuleBlock */: + case 232 /* Block */: + case 260 /* CaseBlock */: + case 202 /* ObjectLiteralExpression */: + case 259 /* ModuleBlock */: return true; } return false; } function isFunctionDeclContext(context) { switch (context.contextNode.kind) { - case 251 /* FunctionDeclaration */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 253 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: // falls through - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: // case SyntaxKind.MethodSignature: // falls through - case 169 /* CallSignature */: - case 208 /* FunctionExpression */: - case 166 /* Constructor */: - case 209 /* ArrowFunction */: + case 171 /* CallSignature */: + case 210 /* FunctionExpression */: + case 168 /* Constructor */: + case 211 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: // falls through - case 253 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one + case 255 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one return true; } return false; @@ -132241,40 +137086,40 @@ var ts; return !isFunctionDeclContext(context); } function isFunctionDeclarationOrFunctionExpressionContext(context) { - return context.contextNode.kind === 251 /* FunctionDeclaration */ || context.contextNode.kind === 208 /* FunctionExpression */; + return context.contextNode.kind === 253 /* FunctionDeclaration */ || context.contextNode.kind === 210 /* FunctionExpression */; } function isTypeScriptDeclWithBlockContext(context) { return nodeIsTypeScriptDeclWithBlockContext(context.contextNode); } function nodeIsTypeScriptDeclWithBlockContext(node) { switch (node.kind) { - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - case 177 /* TypeLiteral */: - case 256 /* ModuleDeclaration */: - case 267 /* ExportDeclaration */: - case 268 /* NamedExports */: - case 261 /* ImportDeclaration */: - case 264 /* NamedImports */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: + case 257 /* EnumDeclaration */: + case 179 /* TypeLiteral */: + case 258 /* ModuleDeclaration */: + case 269 /* ExportDeclaration */: + case 270 /* NamedExports */: + case 263 /* ImportDeclaration */: + case 266 /* NamedImports */: return true; } return false; } function isAfterCodeBlockContext(context) { switch (context.currentTokenParent.kind) { - case 252 /* ClassDeclaration */: - case 256 /* ModuleDeclaration */: - case 255 /* EnumDeclaration */: - case 287 /* CatchClause */: - case 257 /* ModuleBlock */: - case 244 /* SwitchStatement */: + case 254 /* ClassDeclaration */: + case 258 /* ModuleDeclaration */: + case 257 /* EnumDeclaration */: + case 289 /* CatchClause */: + case 259 /* ModuleBlock */: + case 246 /* SwitchStatement */: return true; - case 230 /* Block */: { + case 232 /* 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 !== 209 /* ArrowFunction */ && blockParent.kind !== 208 /* FunctionExpression */) { + if (!blockParent || blockParent.kind !== 211 /* ArrowFunction */ && blockParent.kind !== 210 /* FunctionExpression */) { return true; } } @@ -132283,32 +137128,32 @@ var ts; } function isControlDeclContext(context) { switch (context.contextNode.kind) { - case 234 /* IfStatement */: - case 244 /* SwitchStatement */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 236 /* WhileStatement */: - case 247 /* TryStatement */: - case 235 /* DoStatement */: - case 243 /* WithStatement */: + case 236 /* IfStatement */: + case 246 /* SwitchStatement */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 238 /* WhileStatement */: + case 249 /* TryStatement */: + case 237 /* DoStatement */: + case 245 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: // falls through - case 287 /* CatchClause */: + case 289 /* CatchClause */: return true; default: return false; } } function isObjectContext(context) { - return context.contextNode.kind === 200 /* ObjectLiteralExpression */; + return context.contextNode.kind === 202 /* ObjectLiteralExpression */; } function isFunctionCallContext(context) { - return context.contextNode.kind === 203 /* CallExpression */; + return context.contextNode.kind === 205 /* CallExpression */; } function isNewContext(context) { - return context.contextNode.kind === 204 /* NewExpression */; + return context.contextNode.kind === 206 /* NewExpression */; } function isFunctionCallOrNewContext(context) { return isFunctionCallContext(context) || isNewContext(context); @@ -132323,10 +137168,10 @@ var ts; return context.nextTokenSpan.kind !== 21 /* CloseParenToken */; } function isArrowFunctionContext(context) { - return context.contextNode.kind === 209 /* ArrowFunction */; + return context.contextNode.kind === 211 /* ArrowFunction */; } function isImportTypeContext(context) { - return context.contextNode.kind === 195 /* ImportType */; + return context.contextNode.kind === 197 /* ImportType */; } function isNonJsxSameLineTokenContext(context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 11 /* JsxText */; @@ -132335,19 +137180,19 @@ var ts; return context.contextNode.kind !== 11 /* JsxText */; } function isNonJsxElementOrFragmentContext(context) { - return context.contextNode.kind !== 273 /* JsxElement */ && context.contextNode.kind !== 277 /* JsxFragment */; + return context.contextNode.kind !== 275 /* JsxElement */ && context.contextNode.kind !== 279 /* JsxFragment */; } function isJsxExpressionContext(context) { - return context.contextNode.kind === 283 /* JsxExpression */ || context.contextNode.kind === 282 /* JsxSpreadAttribute */; + return context.contextNode.kind === 285 /* JsxExpression */ || context.contextNode.kind === 284 /* JsxSpreadAttribute */; } function isNextTokenParentJsxAttribute(context) { - return context.nextTokenParent.kind === 280 /* JsxAttribute */; + return context.nextTokenParent.kind === 282 /* JsxAttribute */; } function isJsxAttributeContext(context) { - return context.contextNode.kind === 280 /* JsxAttribute */; + return context.contextNode.kind === 282 /* JsxAttribute */; } function isJsxSelfClosingElementContext(context) { - return context.contextNode.kind === 274 /* JsxSelfClosingElement */; + return context.contextNode.kind === 276 /* JsxSelfClosingElement */; } function isNotBeforeBlockInFunctionDeclarationContext(context) { return !isFunctionDeclContext(context) && !isBeforeBlockContext(context); @@ -132362,45 +137207,45 @@ var ts; while (ts.isExpressionNode(node)) { node = node.parent; } - return node.kind === 161 /* Decorator */; + return node.kind === 163 /* Decorator */; } function isStartOfVariableDeclarationList(context) { - return context.currentTokenParent.kind === 250 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 252 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; } function isNotFormatOnEnter(context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; } function isModuleDeclContext(context) { - return context.contextNode.kind === 256 /* ModuleDeclaration */; + return context.contextNode.kind === 258 /* ModuleDeclaration */; } function isObjectTypeContext(context) { - return context.contextNode.kind === 177 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 179 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; } function isConstructorSignatureContext(context) { - return context.contextNode.kind === 170 /* ConstructSignature */; + return context.contextNode.kind === 172 /* ConstructSignature */; } function isTypeArgumentOrParameterOrAssertion(token, parent) { if (token.kind !== 29 /* LessThanToken */ && token.kind !== 31 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 173 /* TypeReference */: - case 206 /* TypeAssertionExpression */: - case 254 /* TypeAliasDeclaration */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 203 /* CallExpression */: - case 204 /* NewExpression */: - case 223 /* ExpressionWithTypeArguments */: + case 175 /* TypeReference */: + case 208 /* TypeAssertionExpression */: + case 256 /* TypeAliasDeclaration */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: + case 225 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -132411,28 +137256,28 @@ var ts; isTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); } function isTypeAssertionContext(context) { - return context.contextNode.kind === 206 /* TypeAssertionExpression */; + return context.contextNode.kind === 208 /* TypeAssertionExpression */; } function isVoidOpContext(context) { - return context.currentTokenSpan.kind === 113 /* VoidKeyword */ && context.currentTokenParent.kind === 212 /* VoidExpression */; + return context.currentTokenSpan.kind === 114 /* VoidKeyword */ && context.currentTokenParent.kind === 214 /* VoidExpression */; } function isYieldOrYieldStarWithOperand(context) { - return context.contextNode.kind === 219 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 221 /* YieldExpression */ && context.contextNode.expression !== undefined; } function isNonNullAssertionContext(context) { - return context.contextNode.kind === 225 /* NonNullExpression */; + return context.contextNode.kind === 227 /* NonNullExpression */; } function isNotStatementConditionContext(context) { return !isStatementConditionContext(context); } function isStatementConditionContext(context) { switch (context.contextNode.kind) { - case 234 /* IfStatement */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: + case 236 /* IfStatement */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: return true; default: return false; @@ -132457,12 +137302,12 @@ var ts; return nextTokenKind === 19 /* CloseBraceToken */ || nextTokenKind === 1 /* EndOfFileToken */; } - if (nextTokenKind === 229 /* SemicolonClassElement */ || + if (nextTokenKind === 231 /* SemicolonClassElement */ || nextTokenKind === 26 /* SemicolonToken */) { return false; } - if (context.contextNode.kind === 253 /* InterfaceDeclaration */ || - context.contextNode.kind === 254 /* TypeAliasDeclaration */) { + if (context.contextNode.kind === 255 /* InterfaceDeclaration */ || + context.contextNode.kind === 256 /* TypeAliasDeclaration */) { // Can’t remove semicolon after `foo`; it would parse as a method declaration: // // interface I { @@ -132476,9 +137321,9 @@ var ts; if (ts.isPropertyDeclaration(context.currentTokenParent)) { return !context.currentTokenParent.initializer; } - return context.currentTokenParent.kind !== 237 /* ForStatement */ - && context.currentTokenParent.kind !== 231 /* EmptyStatement */ - && context.currentTokenParent.kind !== 229 /* SemicolonClassElement */ + return context.currentTokenParent.kind !== 239 /* ForStatement */ + && context.currentTokenParent.kind !== 233 /* EmptyStatement */ + && context.currentTokenParent.kind !== 231 /* SemicolonClassElement */ && nextTokenKind !== 22 /* OpenBracketToken */ && nextTokenKind !== 20 /* OpenParenToken */ && nextTokenKind !== 39 /* PlusToken */ @@ -132486,7 +137331,7 @@ var ts; && nextTokenKind !== 43 /* SlashToken */ && nextTokenKind !== 13 /* RegularExpressionLiteral */ && nextTokenKind !== 27 /* CommaToken */ - && nextTokenKind !== 218 /* TemplateExpression */ + && nextTokenKind !== 220 /* TemplateExpression */ && nextTokenKind !== 15 /* TemplateHead */ && nextTokenKind !== 14 /* NoSubstitutionTemplateLiteral */ && nextTokenKind !== 24 /* DotToken */; @@ -132577,12 +137422,12 @@ var ts; return map; } function getRuleBucketIndex(row, column) { - ts.Debug.assert(row <= 156 /* LastKeyword */ && column <= 156 /* LastKeyword */, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 158 /* LastKeyword */ && column <= 158 /* LastKeyword */, "Must compute formatting context from tokens"); return (row * mapRowLength) + column; } var maskBitSize = 5; var mask = 31; // MaskBitSize bits - var mapRowLength = 156 /* LastToken */ + 1; + var mapRowLength = 158 /* LastToken */ + 1; var RulesPosition; (function (RulesPosition) { RulesPosition[RulesPosition["StopRulesSpecific"] = 0] = "StopRulesSpecific"; @@ -132770,17 +137615,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 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: var body = parent.body; - return !!body && body.kind === 257 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 297 /* SourceFile */: - case 230 /* Block */: - case 257 /* ModuleBlock */: + return !!body && body.kind === 259 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 299 /* SourceFile */: + case 232 /* Block */: + case 259 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -132934,14 +137779,17 @@ var ts; processNode(enclosingNode, enclosingNode, startLine, undecoratedStartLine, initialIndentation, delta); } if (!formattingScanner.isOnToken()) { + var indentation = formatting.SmartIndenter.nodeWillIndentChild(options, enclosingNode, /*child*/ undefined, sourceFile, /*indentByDefault*/ false) + ? initialIndentation + options.indentSize + : initialIndentation; var leadingTrivia = formattingScanner.getCurrentLeadingTrivia(); if (leadingTrivia) { - indentTriviaItems(leadingTrivia, initialIndentation, /*indentNextTokenOrTrivia*/ false, function (item) { return processRange(item, sourceFile.getLineAndCharacterOfPosition(item.pos), enclosingNode, enclosingNode, /*dynamicIndentation*/ undefined); }); - if (options.trimTrailingWhitespace !== false) { - trimTrailingWhitespacesForRemainingRange(); - } + indentTriviaItems(leadingTrivia, indentation, /*indentNextTokenOrTrivia*/ false, function (item) { return processRange(item, sourceFile.getLineAndCharacterOfPosition(item.pos), enclosingNode, enclosingNode, /*dynamicIndentation*/ undefined); }); } } + if (options.trimTrailingWhitespace !== false) { + trimTrailingWhitespacesForRemainingRange(); + } return edits; // local functions /** Tries to compute the indentation for a list element. @@ -132988,10 +137836,9 @@ var ts; // - we need to get the indentation on last line and the delta of parent return { indentation: indentationOnLastIndentedLine, delta: parentDynamicIndentation.getDelta(node) }; } - else if (formatting.SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement(parent, node, startLine, sourceFile)) { - return { indentation: parentDynamicIndentation.getIndentation(), delta: delta }; - } - else if (formatting.SmartIndenter.argumentStartsOnSameLineAsPreviousArgument(parent, node, startLine, sourceFile)) { + else if (formatting.SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement(parent, node, startLine, sourceFile) || + formatting.SmartIndenter.childIsUnindentedBranchOfConditionalExpression(parent, node, startLine, sourceFile) || + formatting.SmartIndenter.argumentStartsOnSameLineAsPreviousArgument(parent, node, startLine, sourceFile)) { return { indentation: parentDynamicIndentation.getIndentation(), delta: delta }; } else { @@ -133007,19 +137854,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 252 /* ClassDeclaration */: return 83 /* ClassKeyword */; - case 253 /* InterfaceDeclaration */: return 117 /* InterfaceKeyword */; - case 251 /* FunctionDeclaration */: return 97 /* FunctionKeyword */; - case 255 /* EnumDeclaration */: return 255 /* EnumDeclaration */; - case 167 /* GetAccessor */: return 134 /* GetKeyword */; - case 168 /* SetAccessor */: return 146 /* SetKeyword */; - case 165 /* MethodDeclaration */: + case 254 /* ClassDeclaration */: return 84 /* ClassKeyword */; + case 255 /* InterfaceDeclaration */: return 118 /* InterfaceKeyword */; + case 253 /* FunctionDeclaration */: return 98 /* FunctionKeyword */; + case 257 /* EnumDeclaration */: return 257 /* EnumDeclaration */; + case 169 /* GetAccessor */: return 135 /* GetKeyword */; + case 170 /* SetAccessor */: return 147 /* SetKeyword */; + case 167 /* MethodDeclaration */: if (node.asteriskToken) { return 41 /* AsteriskToken */; } // falls through - case 163 /* PropertyDeclaration */: - case 160 /* Parameter */: + case 165 /* PropertyDeclaration */: + case 162 /* Parameter */: var name = ts.getNameOfDeclaration(node); if (name) { return name.kind; @@ -133069,22 +137916,23 @@ var ts; case 18 /* OpenBraceToken */: case 19 /* CloseBraceToken */: case 21 /* CloseParenToken */: - case 90 /* ElseKeyword */: - case 114 /* WhileKeyword */: + case 91 /* ElseKeyword */: + case 115 /* WhileKeyword */: case 59 /* AtToken */: return false; case 43 /* SlashToken */: case 31 /* GreaterThanToken */: switch (container.kind) { - case 275 /* JsxOpeningElement */: - case 276 /* JsxClosingElement */: - case 274 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: + case 278 /* JsxClosingElement */: + case 276 /* JsxSelfClosingElement */: + case 225 /* ExpressionWithTypeArguments */: return false; } break; case 22 /* OpenBracketToken */: case 23 /* CloseBracketToken */: - if (container.kind !== 190 /* MappedType */) { + if (container.kind !== 192 /* MappedType */) { return false; } break; @@ -133129,11 +137977,6 @@ var ts; if (tokenInfo.token.end > node.end) { break; } - if (node.kind === 11 /* JsxText */) { - // Intentation rules for jsx text are handled by `indentMultilineCommentOrJsxText` inside `processChildNode`; just fastforward past it here - formattingScanner.advance(); - continue; - } consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation, node); } if (!node.parent && formattingScanner.isOnEOF()) { @@ -133192,27 +138035,11 @@ var ts; return inheritedIndentation; } } - var effectiveParentStartLine = child.kind === 161 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 163 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); - if (child.kind === 11 /* JsxText */) { - var range = { pos: child.getStart(), end: child.getEnd() }; - if (range.pos !== range.end) { // don't indent zero-width jsx text - var siblings = parent.getChildren(sourceFile); - var currentIndex = ts.findIndex(siblings, function (arg) { return arg.pos === child.pos; }); - var previousNode = siblings[currentIndex - 1]; - if (previousNode) { - // The jsx text needs no indentation whatsoever if it ends on the same line the previous sibling ends on - if (sourceFile.getLineAndCharacterOfPosition(range.end).line !== sourceFile.getLineAndCharacterOfPosition(previousNode.end).line) { - // The first line is (already) "indented" if the text starts on the same line as the previous sibling element ends on - var firstLineIsIndented = sourceFile.getLineAndCharacterOfPosition(range.pos).line === sourceFile.getLineAndCharacterOfPosition(previousNode.end).line; - indentMultilineCommentOrJsxText(range, childIndentation.indentation, firstLineIsIndented, /*indentFinalLine*/ false, /*jsxStyle*/ true); - } - } - } - } childContextNode = node; - if (isFirstListItem && parent.kind === 199 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 201 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -133336,7 +138163,7 @@ var ts; switch (triviaItem.kind) { case 3 /* MultiLineCommentTrivia */: if (triviaInRange) { - indentMultilineCommentOrJsxText(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia); + indentMultilineComment(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia); } indentNextTokenOrTrivia = false; break; @@ -133453,7 +138280,7 @@ var ts; function indentationIsDifferent(indentationString, startLinePosition) { return indentationString !== sourceFile.text.substr(startLinePosition, indentationString.length); } - function indentMultilineCommentOrJsxText(commentRange, indentation, firstLineIsIndented, indentFinalLine, jsxTextStyleIndent) { + function indentMultilineComment(commentRange, indentation, firstLineIsIndented, indentFinalLine) { if (indentFinalLine === void 0) { indentFinalLine = true; } // split comment in lines var startLine = sourceFile.getLineAndCharacterOfPosition(commentRange.pos).line; @@ -133491,13 +138318,6 @@ var ts; var nonWhitespaceCharacterAndColumn = i === 0 ? nonWhitespaceColumnInFirstPart : formatting.SmartIndenter.findFirstNonWhitespaceCharacterAndColumn(parts[i].pos, parts[i].end, sourceFile, options); - if (jsxTextStyleIndent) { - // skip adding indentation to blank lines - if (ts.isLineBreak(sourceFile.text.charCodeAt(ts.getStartPositionOfLine(startLine, sourceFile)))) - continue; - // reset delta on every line - delta = indentation - nonWhitespaceCharacterAndColumn.column; - } var newIndentation = nonWhitespaceCharacterAndColumn.column + delta; if (newIndentation > 0) { var indentationString = getIndentationString(newIndentation, options); @@ -133652,12 +138472,12 @@ var ts; formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment; function getOpenTokenForList(node, list) { switch (node.kind) { - case 166 /* Constructor */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 209 /* ArrowFunction */: + case 168 /* Constructor */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 211 /* ArrowFunction */: if (node.typeParameters === list) { return 29 /* LessThanToken */; } @@ -133665,8 +138485,8 @@ var ts; return 20 /* OpenParenToken */; } break; - case 203 /* CallExpression */: - case 204 /* NewExpression */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: if (node.typeArguments === list) { return 29 /* LessThanToken */; } @@ -133674,12 +138494,12 @@ var ts; return 20 /* OpenParenToken */; } break; - case 173 /* TypeReference */: + case 175 /* TypeReference */: if (node.typeArguments === list) { return 29 /* LessThanToken */; } break; - case 177 /* TypeLiteral */: + case 179 /* TypeLiteral */: return 18 /* OpenBraceToken */; } return 0 /* Unknown */; @@ -133797,7 +138617,7 @@ var ts; if (options.indentStyle === ts.IndentStyle.Block) { return getBlockIndent(sourceFile, position, options); } - if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 216 /* BinaryExpression */) { + if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 218 /* 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 */) { @@ -133880,6 +138700,7 @@ var ts; } SmartIndenter.getBaseIndentation = getBaseIndentation; function getIndentationForNodeWorker(current, currentStart, ignoreActualIndentationRange, indentationDelta, sourceFile, isNextChild, options) { + var _a; var parent = current.parent; // Walk up the tree and collect indentation for parent-child node pairs. Indentation is not added if // * parent and child nodes start on the same line, or @@ -133895,7 +138716,25 @@ var ts; childStartsOnTheSameLineWithElseInIfStatement(parent, current, currentStart.line, sourceFile); if (useActualIndentation) { // check if current node is a list item - if yes, take indentation from it - var actualIndentation = getActualIndentationForListItem(current, sourceFile, options, !parentAndChildShareLine); + var firstListChild = (_a = getContainingList(current, sourceFile)) === null || _a === void 0 ? void 0 : _a[0]; + // A list indents its children if the children begin on a later line than the list itself: + // + // f1( L0 - List start + // { L1 - First child start: indented, along with all other children + // prop: 0 + // }, + // { + // prop: 1 + // } + // ) + // + // f2({ L0 - List start and first child start: children are not indented. + // prop: 0 Object properties are indented only one level, because the list + // }, { itself contributes nothing. + // prop: 1 L3 - The indentation of the second object literal is best understood by + // }) 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 */) { return actualIndentation + indentationDelta; } @@ -133951,7 +138790,7 @@ 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 === 297 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 299 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -133999,8 +138838,8 @@ var ts; } SmartIndenter.isArgumentAndStartLineOverlapsExpressionBeingCalled = isArgumentAndStartLineOverlapsExpressionBeingCalled; function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 234 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 90 /* ElseKeyword */, sourceFile); + if (parent.kind === 236 /* IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 91 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -134008,6 +138847,49 @@ var ts; return false; } SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement = childStartsOnTheSameLineWithElseInIfStatement; + // A multiline conditional typically increases the indentation of its whenTrue and whenFalse children: + // + // condition + // ? whenTrue + // : whenFalse; + // + // However, that indentation does not apply if the subexpressions themselves span multiple lines, + // applying their own indentation: + // + // (() => { + // return complexCalculationForCondition(); + // })() ? { + // whenTrue: 'multiline object literal' + // } : ( + // whenFalse('multiline parenthesized expression') + // ); + // + // In these cases, we must discard the indentation increase that would otherwise be applied to the + // whenTrue and whenFalse children to avoid double-indenting their contents. To identify this scenario, + // we check for the whenTrue branch beginning on the line that the condition ends, and the whenFalse + // branch beginning on the line that the whenTrue branch ends. + function childIsUnindentedBranchOfConditionalExpression(parent, child, childStartLine, sourceFile) { + if (ts.isConditionalExpression(parent) && (child === parent.whenTrue || child === parent.whenFalse)) { + var conditionEndLine = ts.getLineAndCharacterOfPosition(sourceFile, parent.condition.end).line; + if (child === parent.whenTrue) { + return childStartLine === conditionEndLine; + } + else { + // On the whenFalse side, we have to look at the whenTrue side, because if that one was + // indented, whenFalse must also be indented: + // + // const y = true + // ? 1 : ( L1: whenTrue indented because it's on a new line + // 0 L2: indented two stops, one because whenTrue was indented + // ); and one because of the parentheses spanning multiple lines + var trueStartLine = getStartLineAndCharacterForNode(parent.whenTrue, sourceFile).line; + var trueEndLine = ts.getLineAndCharacterOfPosition(sourceFile, parent.whenTrue.end).line; + return conditionEndLine === trueStartLine && trueEndLine === childStartLine; + } + } + return false; + } + SmartIndenter.childIsUnindentedBranchOfConditionalExpression = childIsUnindentedBranchOfConditionalExpression; function argumentStartsOnSameLineAsPreviousArgument(parent, child, childStartLine, sourceFile) { if (ts.isCallOrNewExpression(parent)) { if (!parent.arguments) @@ -134037,40 +138919,40 @@ var ts; } function getListByRange(start, end, node, sourceFile) { switch (node.kind) { - case 173 /* TypeReference */: + case 175 /* TypeReference */: return getList(node.typeArguments); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return getList(node.properties); - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return getList(node.elements); - case 177 /* TypeLiteral */: + case 179 /* TypeLiteral */: return getList(node.members); - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 169 /* CallSignature */: - case 166 /* Constructor */: - case 175 /* ConstructorType */: - case 170 /* ConstructSignature */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 171 /* CallSignature */: + case 168 /* Constructor */: + case 177 /* ConstructorType */: + case 172 /* ConstructSignature */: return getList(node.typeParameters) || getList(node.parameters); - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 330 /* JSDocTemplateTag */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 338 /* JSDocTemplateTag */: return getList(node.typeParameters); - case 204 /* NewExpression */: - case 203 /* CallExpression */: + case 206 /* NewExpression */: + case 205 /* CallExpression */: return getList(node.typeArguments) || getList(node.arguments); - case 250 /* VariableDeclarationList */: + case 252 /* VariableDeclarationList */: return getList(node.declarations); - case 264 /* NamedImports */: - case 268 /* NamedExports */: + case 266 /* NamedImports */: + case 270 /* NamedExports */: return getList(node.elements); - case 196 /* ObjectBindingPattern */: - case 197 /* ArrayBindingPattern */: + case 198 /* ObjectBindingPattern */: + case 199 /* ArrayBindingPattern */: return getList(node.elements); } function getList(list) { @@ -134093,7 +138975,7 @@ var ts; return findColumnForFirstNonWhitespaceCharacterInLine(sourceFile.getLineAndCharacterOfPosition(list.pos), sourceFile, options); } function getActualIndentationForListItem(node, sourceFile, options, listIndentsChild) { - if (node.parent && node.parent.kind === 250 /* VariableDeclarationList */) { + if (node.parent && node.parent.kind === 252 /* VariableDeclarationList */) { // VariableDeclarationList has no wrapping tokens return -1 /* Unknown */; } @@ -134166,94 +139048,94 @@ var ts; function nodeWillIndentChild(settings, parent, child, sourceFile, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 233 /* ExpressionStatement */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 199 /* ArrayLiteralExpression */: - case 230 /* Block */: - case 257 /* ModuleBlock */: - case 200 /* ObjectLiteralExpression */: - case 177 /* TypeLiteral */: - case 190 /* MappedType */: - case 179 /* TupleType */: - case 258 /* CaseBlock */: - case 285 /* DefaultClause */: - case 284 /* CaseClause */: - case 207 /* ParenthesizedExpression */: - case 201 /* PropertyAccessExpression */: - case 203 /* CallExpression */: - case 204 /* NewExpression */: - case 232 /* VariableStatement */: - case 266 /* ExportAssignment */: - case 242 /* ReturnStatement */: - case 217 /* ConditionalExpression */: - case 197 /* ArrayBindingPattern */: - case 196 /* ObjectBindingPattern */: - case 275 /* JsxOpeningElement */: - case 278 /* JsxOpeningFragment */: - case 274 /* JsxSelfClosingElement */: - case 283 /* JsxExpression */: - case 164 /* MethodSignature */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 160 /* Parameter */: - case 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 186 /* ParenthesizedType */: - case 205 /* TaggedTemplateExpression */: - case 213 /* AwaitExpression */: - case 268 /* NamedExports */: - case 264 /* NamedImports */: - case 270 /* ExportSpecifier */: - case 265 /* ImportSpecifier */: - case 163 /* PropertyDeclaration */: + case 235 /* ExpressionStatement */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: + case 257 /* EnumDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 201 /* ArrayLiteralExpression */: + case 232 /* Block */: + case 259 /* ModuleBlock */: + case 202 /* ObjectLiteralExpression */: + case 179 /* TypeLiteral */: + case 192 /* MappedType */: + case 181 /* TupleType */: + case 260 /* CaseBlock */: + case 287 /* DefaultClause */: + case 286 /* CaseClause */: + case 209 /* ParenthesizedExpression */: + case 203 /* PropertyAccessExpression */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: + case 234 /* VariableStatement */: + case 268 /* ExportAssignment */: + case 244 /* ReturnStatement */: + case 219 /* ConditionalExpression */: + case 199 /* ArrayBindingPattern */: + case 198 /* ObjectBindingPattern */: + case 277 /* JsxOpeningElement */: + case 280 /* JsxOpeningFragment */: + case 276 /* JsxSelfClosingElement */: + case 285 /* JsxExpression */: + case 166 /* MethodSignature */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 162 /* Parameter */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: + case 188 /* ParenthesizedType */: + case 207 /* TaggedTemplateExpression */: + case 215 /* AwaitExpression */: + case 270 /* NamedExports */: + case 266 /* NamedImports */: + case 272 /* ExportSpecifier */: + case 267 /* ImportSpecifier */: + case 165 /* PropertyDeclaration */: return true; - case 249 /* VariableDeclaration */: - case 288 /* PropertyAssignment */: - case 216 /* BinaryExpression */: - if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 200 /* ObjectLiteralExpression */) { // TODO: GH#18217 + case 251 /* VariableDeclaration */: + case 290 /* PropertyAssignment */: + case 218 /* BinaryExpression */: + if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 202 /* ObjectLiteralExpression */) { // TODO: GH#18217 return rangeIsOnOneLine(sourceFile, child); } - if (parent.kind !== 216 /* BinaryExpression */) { + if (parent.kind !== 218 /* BinaryExpression */) { return true; } break; - case 235 /* DoStatement */: - case 236 /* WhileStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 237 /* ForStatement */: - case 234 /* IfStatement */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - return childKind !== 230 /* Block */; - case 209 /* ArrowFunction */: - if (sourceFile && childKind === 207 /* ParenthesizedExpression */) { + case 237 /* DoStatement */: + case 238 /* WhileStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 239 /* ForStatement */: + case 236 /* IfStatement */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 167 /* MethodDeclaration */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + return childKind !== 232 /* Block */; + case 211 /* ArrowFunction */: + if (sourceFile && childKind === 209 /* ParenthesizedExpression */) { return rangeIsOnOneLine(sourceFile, child); } - return childKind !== 230 /* Block */; - case 267 /* ExportDeclaration */: - return childKind !== 268 /* NamedExports */; - case 261 /* ImportDeclaration */: - return childKind !== 262 /* ImportClause */ || - (!!child.namedBindings && child.namedBindings.kind !== 264 /* NamedImports */); - case 273 /* JsxElement */: - return childKind !== 276 /* JsxClosingElement */; - case 277 /* JsxFragment */: - return childKind !== 279 /* JsxClosingFragment */; - case 183 /* IntersectionType */: - case 182 /* UnionType */: - if (childKind === 177 /* TypeLiteral */ || childKind === 179 /* TupleType */) { + return childKind !== 232 /* Block */; + case 269 /* ExportDeclaration */: + return childKind !== 270 /* NamedExports */; + case 263 /* ImportDeclaration */: + return childKind !== 264 /* ImportClause */ || + (!!child.namedBindings && child.namedBindings.kind !== 266 /* NamedImports */); + case 275 /* JsxElement */: + return childKind !== 278 /* JsxClosingElement */; + case 279 /* JsxFragment */: + return childKind !== 281 /* JsxClosingFragment */; + case 185 /* IntersectionType */: + case 184 /* UnionType */: + if (childKind === 179 /* TypeLiteral */ || childKind === 181 /* TupleType */) { return false; } - // falls through + break; } // No explicit rule for given nodes so the result will follow the default value argument return indentByDefault; @@ -134261,11 +139143,11 @@ var ts; SmartIndenter.nodeWillIndentChild = nodeWillIndentChild; function isControlFlowEndingStatement(kind, parent) { switch (kind) { - case 242 /* ReturnStatement */: - case 246 /* ThrowStatement */: - case 240 /* ContinueStatement */: - case 241 /* BreakStatement */: - return parent.kind !== 230 /* Block */; + case 244 /* ReturnStatement */: + case 248 /* ThrowStatement */: + case 242 /* ContinueStatement */: + case 243 /* BreakStatement */: + return parent.kind !== 232 /* Block */; default: return false; } @@ -134373,7 +139255,9 @@ var ts; function getAdjustedRange(sourceFile, startNode, endNode, options) { return { pos: getAdjustedStartPosition(sourceFile, startNode, options), end: getAdjustedEndPosition(sourceFile, endNode, options) }; } - function getAdjustedStartPosition(sourceFile, node, options) { + function getAdjustedStartPosition(sourceFile, node, options, hasTrailingComment) { + var _a, _b; + if (hasTrailingComment === void 0) { hasTrailingComment = false; } var leadingTriviaOption = options.leadingTriviaOption; if (leadingTriviaOption === LeadingTriviaOption.Exclude) { return node.getStart(sourceFile); @@ -134404,6 +139288,15 @@ var ts; // when b is deleted - we delete it return leadingTriviaOption === LeadingTriviaOption.IncludeAll ? fullStart : start; } + // if node has a trailing comments, use comment end position as the text has already been included. + if (hasTrailingComment) { + // Check first for leading comments as if the node is the first import, we want to exclude the trivia; + // otherwise we get the trailing comments. + var comment = ((_a = ts.getLeadingCommentRanges(sourceFile.text, fullStart)) === null || _a === void 0 ? void 0 : _a[0]) || ((_b = ts.getTrailingCommentRanges(sourceFile.text, fullStart)) === null || _b === void 0 ? void 0 : _b[0]); + if (comment) { + return ts.skipTrivia(sourceFile.text, comment.end, /*stopAfterLineBreak*/ true, /*stopAtComments*/ true); + } + } // get start position of the line following the line that contains fullstart position // (but only if the fullstart isn't the very beginning of the file) var nextLineStart = fullStart > 0 ? 1 : 0; @@ -134412,6 +139305,35 @@ var ts; adjustedStartPosition = skipWhitespacesAndLineBreaks(sourceFile.text, adjustedStartPosition); return ts.getStartPositionOfLine(ts.getLineOfLocalPosition(sourceFile, adjustedStartPosition), sourceFile); } + /** Return the end position of a multiline comment of it is on another line; otherwise returns `undefined`; */ + function getEndPositionOfMultilineTrailingComment(sourceFile, node, options) { + var end = node.end; + var trailingTriviaOption = options.trailingTriviaOption; + if (trailingTriviaOption === TrailingTriviaOption.Include) { + // If the trailing comment is a multiline comment that extends to the next lines, + // return the end of the comment and track it for the next nodes to adjust. + var comments = ts.getTrailingCommentRanges(sourceFile.text, end); + if (comments) { + var nodeEndLine = ts.getLineOfLocalPosition(sourceFile, node.end); + for (var _i = 0, comments_2 = comments; _i < comments_2.length; _i++) { + 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) { + break; + } + // Get the end line of the comment and compare against the end line of the node. + // If the comment end line position and the multiline comment extends to multiple lines, + // then is safe to return the end position. + var commentEndLine = ts.getLineOfLocalPosition(sourceFile, comment.end); + if (commentEndLine > nodeEndLine) { + return ts.skipTrivia(sourceFile.text, comment.end, /*stopAfterLineBreak*/ true, /*stopAtComments*/ true); + } + } + } + } + return undefined; + } function getAdjustedEndPosition(sourceFile, node, options) { var _a; var end = node.end; @@ -134427,6 +139349,10 @@ var ts; } return end; } + var multilineEndPosition = getEndPositionOfMultilineTrailingComment(sourceFile, node, options); + if (multilineEndPosition) { + return multilineEndPosition; + } var newEnd = ts.skipTrivia(sourceFile.text, end, /*stopAfterLineBreak*/ true); return newEnd !== end && (trailingTriviaOption === TrailingTriviaOption.Include || ts.isLineBreak(sourceFile.text.charCodeAt(newEnd - 1))) ? newEnd @@ -134436,14 +139362,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 === 200 /* ObjectLiteralExpression */)); - } - function spaces(count) { - var s = ""; - for (var i = 0; i < count; i++) { - s += " "; - } - return s; + return !!candidate && !!node.parent && (candidate.kind === 27 /* CommaToken */ || (candidate.kind === 26 /* SemicolonToken */ && node.parent.kind === 202 /* ObjectLiteralExpression */)); } function isThisTypeAnnotatable(containingFunction) { return ts.isFunctionExpression(containingFunction) || ts.isFunctionDeclaration(containingFunction); @@ -134489,6 +139408,17 @@ var ts; if (options === void 0) { options = { leadingTriviaOption: LeadingTriviaOption.IncludeAll }; } this.deleteRange(sourceFile, getAdjustedRange(sourceFile, node, node, options)); }; + ChangeTracker.prototype.deleteNodes = function (sourceFile, nodes, options, hasTrailingComment) { + if (options === void 0) { options = { leadingTriviaOption: LeadingTriviaOption.IncludeAll }; } + // When deleting multiple nodes we need to track if the end position is including multiline trailing comments. + for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { + var node = nodes_1[_i]; + var pos = getAdjustedStartPosition(sourceFile, node, options, hasTrailingComment); + var end = getAdjustedEndPosition(sourceFile, node, options); + this.deleteRange(sourceFile, { pos: pos, end: end }); + hasTrailingComment = !!getEndPositionOfMultilineTrailingComment(sourceFile, node, options); + } + }; ChangeTracker.prototype.deleteModifier = function (sourceFile, modifier) { this.deleteRange(sourceFile, { pos: modifier.getStart(sourceFile), end: ts.skipTrivia(sourceFile.text, modifier.end, /*stopAfterLineBreak*/ true) }); }; @@ -134531,6 +139461,10 @@ var ts; if (options === void 0) { options = useNonAdjustedPositions; } this.replaceRangeWithNodes(sourceFile, getAdjustedRange(sourceFile, startNode, endNode, options), newNodes, options); }; + ChangeTracker.prototype.nodeHasTrailingComment = function (sourceFile, oldNode, configurableEnd) { + if (configurableEnd === void 0) { configurableEnd = useNonAdjustedPositions; } + return !!getEndPositionOfMultilineTrailingComment(sourceFile, oldNode, configurableEnd); + }; ChangeTracker.prototype.nextCommaToken = function (sourceFile, node) { var next = ts.findNextToken(node, node.parent, sourceFile); return next && next.kind === 27 /* CommaToken */ ? next : undefined; @@ -134635,7 +139569,7 @@ var ts; } } else { - endNode = (_a = (node.kind === 249 /* VariableDeclaration */ ? node.exclamationToken : node.questionToken)) !== null && _a !== void 0 ? _a : node.name; + endNode = (_a = (node.kind === 251 /* VariableDeclaration */ ? node.exclamationToken : node.questionToken)) !== null && _a !== void 0 ? _a : node.name; } this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " }); return true; @@ -134677,6 +139611,15 @@ var ts; this.insertNodeBefore(sourceFile, firstStatement, newStatement); } }; + ChangeTracker.prototype.insertNodeAtConstructorStartAfterSuperCall = function (sourceFile, ctr, newStatement) { + var superCallStatement = ts.find(ctr.body.statements, function (stmt) { return ts.isExpressionStatement(stmt) && ts.isSuperCall(stmt.expression); }); + if (!superCallStatement || !ctr.body.multiLine) { + this.replaceConstructorBody(sourceFile, ctr, __spreadArray(__spreadArray([], ctr.body.statements), [newStatement])); + } + else { + this.insertNodeAfter(sourceFile, superCallStatement, newStatement); + } + }; ChangeTracker.prototype.insertNodeAtConstructorEnd = function (sourceFile, ctr, newStatement) { var lastStatement = ts.lastOrUndefined(ctr.body.statements); if (!lastStatement || !ctr.body.multiLine) { @@ -134792,18 +139735,18 @@ var ts; }; ChangeTracker.prototype.getInsertNodeAfterOptionsWorker = function (node) { switch (node.kind) { - case 252 /* ClassDeclaration */: - case 256 /* ModuleDeclaration */: + case 254 /* ClassDeclaration */: + case 258 /* ModuleDeclaration */: return { prefix: this.newLineCharacter, suffix: this.newLineCharacter }; - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: case 10 /* StringLiteral */: - case 78 /* Identifier */: + case 79 /* Identifier */: return { prefix: ", " }; - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: return { suffix: "," + this.newLineCharacter }; - case 92 /* ExportKeyword */: + case 93 /* ExportKeyword */: return { prefix: " " }; - case 160 /* Parameter */: + case 162 /* Parameter */: return {}; default: ts.Debug.assert(ts.isStatement(node) || ts.isClassOrTypeElement(node)); // Else we haven't handled this kind of node yet -- add it @@ -134812,12 +139755,12 @@ var ts; }; ChangeTracker.prototype.insertName = function (sourceFile, node, name) { ts.Debug.assert(!node.name); - if (node.kind === 209 /* ArrowFunction */) { + if (node.kind === 211 /* ArrowFunction */) { var arrow = ts.findChildOfKind(node, 38 /* EqualsGreaterThanToken */, sourceFile); var lparen = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); if (lparen) { // `() => {}` --> `function f() {}` - this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.factory.createToken(97 /* FunctionKeyword */), ts.factory.createIdentifier(name)], { joiner: " " }); + this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.factory.createToken(98 /* FunctionKeyword */), ts.factory.createIdentifier(name)], { joiner: " " }); deleteNode(this, sourceFile, arrow); } else { @@ -134826,14 +139769,14 @@ var ts; // Replacing full range of arrow to get rid of the leading space -- replace ` =>` with `)` this.replaceRange(sourceFile, arrow, ts.factory.createToken(21 /* CloseParenToken */)); } - if (node.body.kind !== 230 /* Block */) { + if (node.body.kind !== 232 /* Block */) { // `() => 0` => `function f() { return 0; }` - this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.factory.createToken(18 /* OpenBraceToken */), ts.factory.createToken(104 /* ReturnKeyword */)], { joiner: " ", suffix: " " }); + 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: " " }); } } else { - var pos = ts.findChildOfKind(node, node.kind === 208 /* FunctionExpression */ ? 97 /* FunctionKeyword */ : 83 /* ClassKeyword */, sourceFile).end; + var pos = ts.findChildOfKind(node, node.kind === 210 /* FunctionExpression */ ? 98 /* FunctionKeyword */ : 84 /* ClassKeyword */, sourceFile).end; this.insertNodeAt(sourceFile, pos, ts.factory.createIdentifier(name), { prefix: " " }); } }; @@ -134865,47 +139808,22 @@ var ts; // a, b, c // create change for adding 'e' after 'a' as // - find start of next element after a (it is b) - // - use this start as start and end position in final change - // - build text of change by formatting the text of node + separator + whitespace trivia of b + // - use next element start as start and end position in final change + // - build text of change by formatting the text of node + whitespace trivia of b // in multiline case it will work as // a, // b, // c, // result - '*' denotes leading trivia that will be inserted after new text (displayed as '#') - // a,* - // ***insertedtext# + // a, + // insertedtext# // ###b, // c, - // find line and character of the next element - var lineAndCharOfNextElement = ts.getLineAndCharacterOfPosition(sourceFile, skipWhitespacesAndLineBreaks(sourceFile.text, containingList[index + 1].getFullStart())); - // find line and character of the token that precedes next element (usually it is separator) - var lineAndCharOfNextToken = ts.getLineAndCharacterOfPosition(sourceFile, nextToken.end); - var prefix = void 0; - var startPos = void 0; - if (lineAndCharOfNextToken.line === lineAndCharOfNextElement.line) { - // next element is located on the same line with separator: - // a,$$$$b - // ^ ^ - // | |-next element - // |-separator - // where $$$ is some leading trivia - // for a newly inserted node we'll maintain the same relative position comparing to separator and replace leading trivia with spaces - // a, x,$$$$b - // ^ ^ ^ - // | | |-next element - // | |-new inserted node padded with spaces - // |-separator - startPos = nextToken.end; - prefix = spaces(lineAndCharOfNextElement.character - lineAndCharOfNextToken.character); - } - else { - // next element is located on different line that separator - // let insert position be the beginning of the line that contains next element - startPos = ts.getStartPositionOfLine(lineAndCharOfNextElement.line, sourceFile); - } + 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, containingList[index + 1].getStart(sourceFile)); - this.replaceRange(sourceFile, ts.createRange(startPos, containingList[index + 1].getStart(sourceFile)), newNode, { prefix: prefix, suffix: suffix }); + var suffix = "" + ts.tokenToString(nextToken.kind) + sourceFile.text.substring(nextToken.end, startPos); + this.insertNodesAt(sourceFile, startPos, [newNode], { suffix: suffix }); } } else { @@ -134977,7 +139895,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_9 = function (sourceFile, node) { + var _loop_10 = 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)); @@ -134990,7 +139908,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_9(sourceFile, node); + _loop_10(sourceFile, node); } deletedNodesInLists.forEach(function (node) { var sourceFile = node.getSourceFile(); @@ -135049,14 +139967,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_10 = function (i) { + var _loop_11 = 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); }); }; // verify that change intervals do not overlap, except possibly at end points. for (var i = 0; i < normalized.length - 1; i++) { - _loop_10(i); + _loop_11(i); } var textChanges = ts.mapDefined(normalized, function (c) { var span = ts.createTextSpanFromRange(c.range); @@ -135170,11 +140088,12 @@ var ts; function createWriter(newLine) { var lastNonTriviaPosition = 0; var writer = ts.createTextWriter(newLine); - var onEmitNode = function (hint, node, printCallback) { + var onBeforeEmitNode = function (node) { if (node) { setPos(node, lastNonTriviaPosition); } - printCallback(hint, node); + }; + var onAfterEmitNode = function (node) { if (node) { setEnd(node, lastNonTriviaPosition); } @@ -135293,7 +140212,8 @@ var ts; lastNonTriviaPosition = 0; } return { - onEmitNode: onEmitNode, + onBeforeEmitNode: onBeforeEmitNode, + onAfterEmitNode: onAfterEmitNode, onBeforeEmitNodeArray: onBeforeEmitNodeArray, onAfterEmitNodeArray: onAfterEmitNodeArray, onBeforeEmitToken: onBeforeEmitToken, @@ -135408,14 +140328,14 @@ var ts; } textChanges_3.isValidLocationToAddComment = isValidLocationToAddComment; function needSemicolonBetween(a, b) { - return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 158 /* ComputedPropertyName */ + return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 160 /* 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 160 /* Parameter */: { + case 162 /* Parameter */: { var oldFunction = node.parent; if (ts.isArrowFunction(oldFunction) && oldFunction.parameters.length === 1 && @@ -135430,15 +140350,17 @@ var ts; } break; } - case 261 /* ImportDeclaration */: - case 260 /* ImportEqualsDeclaration */: + case 263 /* ImportDeclaration */: + case 262 /* 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 }); + deleteNode(changes, sourceFile, node, { + leadingTriviaOption: isFirstImport ? LeadingTriviaOption.Exclude : ts.hasJSDocNodes(node) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine, + }); break; - case 198 /* BindingElement */: + case 200 /* BindingElement */: var pattern = node.parent; - var preserveComma = pattern.kind === 197 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); + var preserveComma = pattern.kind === 199 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); if (preserveComma) { deleteNode(changes, sourceFile, node); } @@ -135446,13 +140368,13 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node); break; - case 159 /* TypeParameter */: + case 161 /* TypeParameter */: deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); break; - case 265 /* ImportSpecifier */: + case 267 /* ImportSpecifier */: var namedImports = node.parent; if (namedImports.elements.length === 1) { deleteImportBinding(changes, sourceFile, namedImports); @@ -135461,21 +140383,25 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: deleteImportBinding(changes, sourceFile, node); break; case 26 /* SemicolonToken */: deleteNode(changes, sourceFile, node, { trailingTriviaOption: TrailingTriviaOption.Exclude }); break; - case 97 /* FunctionKeyword */: + case 98 /* FunctionKeyword */: deleteNode(changes, sourceFile, node, { leadingTriviaOption: LeadingTriviaOption.Exclude }); break; - case 252 /* ClassDeclaration */: - case 251 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: + case 253 /* FunctionDeclaration */: deleteNode(changes, sourceFile, node, { leadingTriviaOption: ts.hasJSDocNodes(node) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine }); break; default: - if (ts.isImportClause(node.parent) && node.parent.name === node) { + if (!node.parent) { + // a misbehaving client can reach here with the SourceFile node + deleteNode(changes, sourceFile, node); + } + else if (ts.isImportClause(node.parent) && node.parent.name === node) { deleteDefaultImport(changes, sourceFile, node.parent); } else if (ts.isCallExpression(node.parent) && ts.contains(node.parent.arguments, node)) { @@ -135518,13 +140444,13 @@ var ts; // Delete the entire import declaration // |import * as ns from './file'| // |import { a } from './file'| - var importDecl = ts.getAncestor(node, 261 /* ImportDeclaration */); + var importDecl = ts.getAncestor(node, 263 /* ImportDeclaration */); deleteNode(changes, sourceFile, importDecl); } } function deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node) { var parent = node.parent; - if (parent.kind === 287 /* CatchClause */) { + if (parent.kind === 289 /* 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)); return; @@ -135535,14 +140461,14 @@ var ts; } var gp = parent.parent; switch (gp.kind) { - case 239 /* ForOfStatement */: - case 238 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 240 /* ForInStatement */: changes.replaceNode(sourceFile, node, ts.factory.createObjectLiteralExpression()); break; - case 237 /* ForStatement */: + case 239 /* ForStatement */: deleteNode(changes, sourceFile, parent); break; - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: deleteNode(changes, sourceFile, gp, { leadingTriviaOption: ts.hasJSDocNodes(gp) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine }); break; default: @@ -135598,6 +140524,10 @@ var ts; return createCodeFixActionWorker(fixName, diagnosticToString(description), changes, fixId, diagnosticToString(fixAllDescription), command); } codefix.createCodeFixAction = createCodeFixAction; + function createCodeFixActionMaybeFixAll(fixName, changes, description, fixId, fixAllDescription, command) { + return createCodeFixActionWorker(fixName, diagnosticToString(description), changes, fixId, fixAllDescription && diagnosticToString(fixAllDescription), command); + } + codefix.createCodeFixActionMaybeFixAll = createCodeFixActionMaybeFixAll; function createCodeFixActionWorker(fixName, description, changes, fixId, fixAllDescription, command) { return { fixName: fixName, description: description, changes: changes, fixId: fixId, fixAllDescription: fixAllDescription, commands: command ? [command] : undefined }; } @@ -135724,8 +140654,8 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, pos); var assertion = ts.Debug.checkDefined(ts.findAncestor(token, function (n) { return ts.isAsExpression(n) || ts.isTypeAssertionExpression(n); }), "Expected to find an assertion expression"); var replacement = ts.isAsExpression(assertion) - ? ts.factory.createAsExpression(assertion.expression, ts.factory.createKeywordTypeNode(152 /* UnknownKeyword */)) - : ts.factory.createTypeAssertion(ts.factory.createKeywordTypeNode(152 /* UnknownKeyword */), assertion.expression); + ? ts.factory.createAsExpression(assertion.expression, ts.factory.createKeywordTypeNode(153 /* UnknownKeyword */)) + : ts.factory.createTypeAssertion(ts.factory.createKeywordTypeNode(153 /* UnknownKeyword */), assertion.expression); changeTracker.replaceNode(sourceFile, assertion.expression, replacement); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -135736,7 +140666,10 @@ var ts; var codefix; (function (codefix) { codefix.registerCodeFix({ - errorCodes: [ts.Diagnostics.await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module.code], + errorCodes: [ + ts.Diagnostics.await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module.code, + ts.Diagnostics.for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module.code, + ], getCodeActions: function (context) { var sourceFile = context.sourceFile; var changes = ts.textChanges.ChangeTracker.with(context, function (changes) { @@ -135849,6 +140782,7 @@ var ts; ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1.code, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2.code, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap.code, + ts.Diagnostics.This_condition_will_always_return_true_since_this_0_is_always_defined.code, ts.Diagnostics.Type_0_is_not_an_array_type.code, ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type.code, ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators.code, @@ -135947,14 +140881,14 @@ var ts; } var isCompleteFix = identifiers.isCompleteFix; var initializers; - var _loop_11 = function (identifier) { + var _loop_12 = 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, 232 /* VariableStatement */); + var variableStatement = ts.getAncestor(declaration, 234 /* VariableStatement */); if (!declaration || !variableStatement || declaration.type || !declaration.initializer || @@ -135980,7 +140914,7 @@ var ts; }; for (var _i = 0, _a = identifiers.identifiers; _i < _a.length; _i++) { var identifier = _a[_i]; - _loop_11(identifier); + _loop_12(identifier); } return initializers && { initializers: initializers, @@ -136032,10 +140966,10 @@ var ts; function isInsideAwaitableBody(node) { return node.kind & 32768 /* AwaitContext */ || !!ts.findAncestor(node, function (ancestor) { return ancestor.parent && ts.isArrowFunction(ancestor.parent) && ancestor.parent.body === ancestor || - ts.isBlock(ancestor) && (ancestor.parent.kind === 251 /* FunctionDeclaration */ || - ancestor.parent.kind === 208 /* FunctionExpression */ || - ancestor.parent.kind === 209 /* ArrowFunction */ || - ancestor.parent.kind === 165 /* MethodDeclaration */); + ts.isBlock(ancestor) && (ancestor.parent.kind === 253 /* FunctionDeclaration */ || + ancestor.parent.kind === 210 /* FunctionExpression */ || + ancestor.parent.kind === 211 /* ArrowFunction */ || + ancestor.parent.kind === 167 /* MethodDeclaration */); }); } function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite, fixedDeclarations) { @@ -136124,7 +141058,7 @@ var ts; if (forInitializer) return applyChange(changeTracker, forInitializer, sourceFile, fixedNodes); var parent = token.parent; - if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 62 /* EqualsToken */ && ts.isExpressionStatement(parent.parent)) { + if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isExpressionStatement(parent.parent)) { return applyChange(changeTracker, token, sourceFile, fixedNodes); } if (ts.isArrayLiteralExpression(parent)) { @@ -136148,16 +141082,16 @@ var ts; } function applyChange(changeTracker, initializer, sourceFile, fixedNodes) { if (!fixedNodes || ts.tryAddToSet(fixedNodes, initializer)) { - changeTracker.insertModifierBefore(sourceFile, 84 /* ConstKeyword */, initializer); + changeTracker.insertModifierBefore(sourceFile, 85 /* ConstKeyword */, initializer); } } function isPossiblyPartOfDestructuring(node) { switch (node.kind) { - case 78 /* Identifier */: - case 199 /* ArrayLiteralExpression */: - case 200 /* ObjectLiteralExpression */: - case 288 /* PropertyAssignment */: - case 289 /* ShorthandPropertyAssignment */: + case 79 /* Identifier */: + case 201 /* ArrayLiteralExpression */: + case 202 /* ObjectLiteralExpression */: + case 290 /* PropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return true; default: return false; @@ -136171,8 +141105,8 @@ var ts; } function isPossiblyPartOfCommaSeperatedInitializer(node) { switch (node.kind) { - case 78 /* Identifier */: - case 216 /* BinaryExpression */: + case 79 /* Identifier */: + case 218 /* BinaryExpression */: case 27 /* CommaToken */: return true; default: @@ -136186,7 +141120,7 @@ var ts; if (expression.operatorToken.kind === 27 /* CommaToken */) { return ts.every([expression.left, expression.right], function (expression) { return expressionCouldBeVariableDeclaration(expression, checker); }); } - return expression.operatorToken.kind === 62 /* EqualsToken */ + return expression.operatorToken.kind === 63 /* EqualsToken */ && ts.isIdentifier(expression.left) && !checker.getSymbolAtLocation(expression.left); } @@ -136221,9 +141155,9 @@ var ts; return; } var declaration = token.parent; - if (declaration.kind === 163 /* PropertyDeclaration */ && + if (declaration.kind === 165 /* PropertyDeclaration */ && (!fixedNodes || ts.tryAddToSet(fixedNodes, declaration))) { - changeTracker.insertModifierBefore(sourceFile, 133 /* DeclareKeyword */, declaration); + changeTracker.insertModifierBefore(sourceFile, 134 /* DeclareKeyword */, declaration); } } })(codefix = ts.codefix || (ts.codefix = {})); @@ -136358,26 +141292,26 @@ var ts; } function isDeclarationWithType(node) { return ts.isFunctionLikeDeclaration(node) || - node.kind === 249 /* VariableDeclaration */ || - node.kind === 162 /* PropertySignature */ || - node.kind === 163 /* PropertyDeclaration */; + node.kind === 251 /* VariableDeclaration */ || + node.kind === 164 /* PropertySignature */ || + node.kind === 165 /* PropertyDeclaration */; } function transformJSDocType(node) { switch (node.kind) { - case 303 /* JSDocAllType */: - case 304 /* JSDocUnknownType */: + case 306 /* JSDocAllType */: + case 307 /* JSDocUnknownType */: return ts.factory.createTypeReferenceNode("any", ts.emptyArray); - case 307 /* JSDocOptionalType */: + case 310 /* JSDocOptionalType */: return transformJSDocOptionalType(node); - case 306 /* JSDocNonNullableType */: + case 309 /* JSDocNonNullableType */: return transformJSDocType(node.type); - case 305 /* JSDocNullableType */: + case 308 /* JSDocNullableType */: return transformJSDocNullableType(node); - case 309 /* JSDocVariadicType */: + case 312 /* JSDocVariadicType */: return transformJSDocVariadicType(node); - case 308 /* JSDocFunctionType */: + case 311 /* JSDocFunctionType */: return transformJSDocFunctionType(node); - case 173 /* TypeReference */: + case 175 /* TypeReference */: return transformJSDocTypeReference(node); default: var visited = ts.visitEachChild(node, transformJSDocType, ts.nullTransformationContext); @@ -136398,11 +141332,11 @@ 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(128 /* AnyKeyword */)); + return ts.factory.createFunctionTypeNode(ts.emptyArray, node.parameters.map(transformJSDocParameter), (_a = node.type) !== null && _a !== void 0 ? _a : ts.factory.createKeywordTypeNode(129 /* AnyKeyword */)); } function transformJSDocParameter(node) { var index = node.parent.parameters.indexOf(node); - var isRest = node.type.kind === 309 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 + var isRest = node.type.kind === 312 /* 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; return ts.factory.createParameterDeclaration(node.decorators, node.modifiers, dotdotdot, name, node.questionToken, ts.visitNode(node.type, transformJSDocType), node.initializer); @@ -136442,8 +141376,8 @@ var ts; var index = ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 144 /* NumberKeyword */ ? "n" : "s", - /*questionToken*/ undefined, ts.factory.createTypeReferenceNode(node.typeArguments[0].kind === 144 /* NumberKeyword */ ? "number" : "string", []), + /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 145 /* NumberKeyword */ ? "n" : "s", + /*questionToken*/ undefined, ts.factory.createTypeReferenceNode(node.typeArguments[0].kind === 145 /* NumberKeyword */ ? "number" : "string", []), /*initializer*/ undefined); var indexSignature = ts.factory.createTypeLiteralNode([ts.factory.createIndexSignature(/*decorators*/ undefined, /*modifiers*/ undefined, [index], node.typeArguments[1])]); ts.setEmitFlags(indexSignature, 1 /* SingleLine */); @@ -136473,7 +141407,7 @@ var ts; }); function doChange(changes, sourceFile, position, checker, preferences, compilerOptions) { var ctorSymbol = checker.getSymbolAtLocation(ts.getTokenAtPosition(sourceFile, position)); - if (!ctorSymbol || !(ctorSymbol.flags & (16 /* Function */ | 3 /* Variable */))) { + if (!ctorSymbol || !ctorSymbol.valueDeclaration || !(ctorSymbol.flags & (16 /* Function */ | 3 /* Variable */))) { // Bad input return undefined; } @@ -136500,7 +141434,7 @@ var ts; // all instance members are stored in the "member" array of symbol if (symbol.members) { symbol.members.forEach(function (member, key) { - if (key === "constructor") { + if (key === "constructor" && member.valueDeclaration) { // fn.prototype.constructor = fn changes.delete(sourceFile, member.valueDeclaration.parent); return; @@ -136514,13 +141448,13 @@ var ts; // all static members are stored in the "exports" array of symbol if (symbol.exports) { symbol.exports.forEach(function (member) { - if (member.name === "prototype") { + if (member.name === "prototype" && member.declarations) { var firstDeclaration = member.declarations[0]; // only one "x.prototype = { ... }" will pass if (member.declarations.length === 1 && ts.isPropertyAccessExpression(firstDeclaration) && ts.isBinaryExpression(firstDeclaration.parent) && - firstDeclaration.parent.operatorToken.kind === 62 /* EqualsToken */ && + firstDeclaration.parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isObjectLiteralExpression(firstDeclaration.parent.right)) { var prototypes = firstDeclaration.parent.right; var memberElement = createClassElement(prototypes.symbol, /** modifiers */ undefined); @@ -136530,7 +141464,7 @@ var ts; } } else { - var memberElement = createClassElement(member, [ts.factory.createToken(123 /* StaticKeyword */)]); + var memberElement = createClassElement(member, [ts.factory.createToken(124 /* StaticKeyword */)]); if (memberElement) { memberElements.push.apply(memberElements, memberElement); } @@ -136576,7 +141510,7 @@ var ts; return members; } // delete the entire statement if this expression is the sole expression to take care of the semicolon at the end - var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 233 /* ExpressionStatement */ + var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 235 /* ExpressionStatement */ ? assignmentBinaryExpression.parent : assignmentBinaryExpression; changes.delete(sourceFile, nodeToDelete); if (!assignmentExpr) { @@ -136627,7 +141561,7 @@ var ts; return createArrowFunctionExpressionMember(members, expression, name); } function createFunctionExpressionMember(members, functionExpression, name) { - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 129 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 130 /* AsyncKeyword */)); var method = ts.factory.createMethodDeclaration(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined, /*typeParameters*/ undefined, functionExpression.parameters, /*type*/ undefined, functionExpression.body); ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); @@ -136637,14 +141571,14 @@ var ts; var arrowFunctionBody = arrowFunction.body; var bodyBlock; // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 230 /* Block */) { + if (arrowFunctionBody.kind === 232 /* Block */) { bodyBlock = arrowFunctionBody; } // case 2: () => [1,2,3] else { bodyBlock = ts.factory.createBlock([ts.factory.createReturnStatement(arrowFunctionBody)]); } - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 129 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 130 /* AsyncKeyword */)); var method = ts.factory.createMethodDeclaration(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined, /*typeParameters*/ undefined, arrowFunction.parameters, /*type*/ undefined, bodyBlock); ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); @@ -136661,7 +141595,7 @@ var ts; if (initializer.body) { memberElements.unshift(ts.factory.createConstructorDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, initializer.parameters, initializer.body)); } - var modifiers = getModifierKindFromSource(node.parent.parent, 92 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(node.parent.parent, 93 /* ExportKeyword */); var cls = ts.factory.createClassDeclaration(/*decorators*/ undefined, modifiers, node.name, /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); // Don't call copyComments here because we'll already leave them in place @@ -136672,7 +141606,7 @@ var ts; if (node.body) { memberElements.unshift(ts.factory.createConstructorDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, node.parameters, node.body)); } - var modifiers = getModifierKindFromSource(node, 92 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(node, 93 /* ExportKeyword */); var cls = ts.factory.createClassDeclaration(/*decorators*/ undefined, modifiers, node.name, /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); // Don't call copyComments here because we'll already leave them in place @@ -136739,7 +141673,7 @@ var ts; functionToConvert = tokenAtPosition.parent.initializer; } else { - functionToConvert = ts.tryCast(ts.getContainingFunction(ts.getTokenAtPosition(sourceFile, position)), ts.isFunctionLikeDeclaration); + functionToConvert = ts.tryCast(ts.getContainingFunction(ts.getTokenAtPosition(sourceFile, position)), ts.canBeConvertedToAsync); } if (!functionToConvert) { return; @@ -136748,7 +141682,10 @@ var ts; var isInJavascript = ts.isInJSFile(functionToConvert); var setOfExpressionsToReturn = getAllPromiseExpressionsToReturn(functionToConvert, checker); var functionToConvertRenamed = renameCollidingVarNames(functionToConvert, checker, synthNamesMap); - var returnStatements = functionToConvertRenamed.body && ts.isBlock(functionToConvertRenamed.body) ? getReturnStatementsWithPromiseHandlers(functionToConvertRenamed.body) : ts.emptyArray; + if (!ts.returnsPromise(functionToConvertRenamed, checker)) { + return; + } + var returnStatements = functionToConvertRenamed.body && ts.isBlock(functionToConvertRenamed.body) ? getReturnStatementsWithPromiseHandlers(functionToConvertRenamed.body, checker) : ts.emptyArray; var transformer = { checker: checker, synthNamesMap: synthNamesMap, setOfExpressionsToReturn: setOfExpressionsToReturn, isInJSFile: isInJavascript }; if (!returnStatements.length) { return; @@ -136757,8 +141694,8 @@ var ts; functionToConvert.decorators ? ts.skipTrivia(sourceFile.text, functionToConvert.decorators.end) : functionToConvert.getStart(sourceFile); var options = functionToConvert.modifiers ? { prefix: " " } : { suffix: " " }; - changes.insertModifierAt(sourceFile, pos, 129 /* AsyncKeyword */, options); - var _loop_12 = function (returnStatement) { + changes.insertModifierAt(sourceFile, pos, 130 /* AsyncKeyword */, options); + var _loop_13 = function (returnStatement) { ts.forEachChild(returnStatement, function visit(node) { if (ts.isCallExpression(node)) { var newNodes = transformExpression(node, transformer); @@ -136771,13 +141708,13 @@ var ts; }; for (var _i = 0, returnStatements_1 = returnStatements; _i < returnStatements_1.length; _i++) { var returnStatement = returnStatements_1[_i]; - _loop_12(returnStatement); + _loop_13(returnStatement); } } - function getReturnStatementsWithPromiseHandlers(body) { + function getReturnStatementsWithPromiseHandlers(body, checker) { var res = []; ts.forEachReturnStatement(body, function (ret) { - if (ts.isReturnStatementWithFixablePromiseHandler(ret)) + if (ts.isReturnStatementWithFixablePromiseHandler(ret, checker)) res.push(ret); }); return res; @@ -136848,7 +141785,10 @@ var ts; // so we push an entry for 'response'. if (lastCallSignature && !ts.isParameter(node.parent) && !ts.isFunctionLikeDeclaration(node.parent) && !synthNamesMap.has(symbolIdString)) { var firstParameter = ts.firstOrUndefined(lastCallSignature.parameters); - var ident = firstParameter && ts.isParameter(firstParameter.valueDeclaration) && ts.tryCast(firstParameter.valueDeclaration.name, ts.isIdentifier) || ts.factory.createUniqueName("result", 16 /* Optimistic */); + 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 */); var synthName = getNewNameIfConflict(ident, collidingSymbolMap); synthNamesMap.set(symbolIdString, synthName); collidingSymbolMap.add(ident.text, symbol); @@ -137023,10 +141963,11 @@ var ts; function getTransformationBody(func, prevArgName, argName, parent, transformer) { var _a, _b, _c, _d, _e; switch (func.kind) { - case 103 /* NullKeyword */: + case 104 /* NullKeyword */: // do not produce a transformed statement for a null argument break; - case 78 /* Identifier */: // identifier includes undefined + case 203 /* PropertyAccessExpression */: + case 79 /* Identifier */: // identifier includes undefined if (!argName) { // undefined was argument passed to promise handler break; @@ -137047,8 +141988,8 @@ var ts; prevArgName.types.push(returnType); } return varDeclOrAssignment; - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: { + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: { var funcBody = func.body; var returnType_1 = (_c = getLastCallSignature(transformer.checker.getTypeAtLocation(func), transformer.checker)) === null || _c === void 0 ? void 0 : _c.getReturnType(); // Arrow functions with block bodies { } will enter this control flow @@ -137059,7 +142000,7 @@ var ts; var statement = _f[_i]; if (ts.isReturnStatement(statement)) { seenReturnStatement = true; - if (ts.isReturnStatementWithFixablePromiseHandler(statement)) { + if (ts.isReturnStatementWithFixablePromiseHandler(statement, transformer.checker)) { refactoredStmts = refactoredStmts.concat(getInnerTransformationBody(transformer, [statement], prevArgName)); } else { @@ -137076,7 +142017,7 @@ var ts; : removeReturns(refactoredStmts, prevArgName, transformer, seenReturnStatement); } else { - var innerRetStmts = ts.isFixablePromiseHandler(funcBody) ? [ts.factory.createReturnStatement(funcBody)] : ts.emptyArray; + var innerRetStmts = ts.isFixablePromiseHandler(funcBody, transformer.checker) ? [ts.factory.createReturnStatement(funcBody)] : ts.emptyArray; var innerCbBody = getInnerTransformationBody(transformer, innerRetStmts, prevArgName); if (innerCbBody.length > 0) { return innerCbBody; @@ -137169,6 +142110,9 @@ var ts; else if (ts.isIdentifier(funcNode)) { name = getMapEntryOrDefault(funcNode); } + else if (ts.isPropertyAccessExpression(funcNode) && ts.isIdentifier(funcNode.name)) { + name = getMapEntryOrDefault(funcNode.name); + } // return undefined argName when arg is null or undefined // eslint-disable-next-line no-in-operator if (!name || "identifier" in name && name.identifier.text === "undefined") { @@ -137264,10 +142208,10 @@ var ts; } var importNode = ts.importFromModuleSpecifier(moduleSpecifier); switch (importNode.kind) { - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier, quotePreference)); break; - case 203 /* CallExpression */: + case 205 /* CallExpression */: if (ts.isRequireCall(importNode, /*checkArgumentIsStringLiteralLike*/ false)) { changes.replaceNode(importingFile, importNode, ts.factory.createPropertyAccessExpression(ts.getSynthesizedDeepClone(importNode), "default")); } @@ -137327,29 +142271,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 === 62 /* EqualsToken */); + cb(node, ts.isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === 63 /* EqualsToken */); } node.forEachChild(recur); }); } function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, useSitesToUnqualify, quotePreference) { switch (statement.kind) { - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, quotePreference); return false; - case 233 /* ExpressionStatement */: { + case 235 /* ExpressionStatement */: { var expression = statement.expression; switch (expression.kind) { - case 203 /* CallExpression */: { + case 205 /* 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 216 /* BinaryExpression */: { + case 218 /* BinaryExpression */: { var operatorToken = expression.operatorToken; - return operatorToken.kind === 62 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports, useSitesToUnqualify); + return operatorToken.kind === 63 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports, useSitesToUnqualify); } } } @@ -137396,8 +142340,8 @@ var ts; /** Converts `const name = require("moduleSpecifier").propertyName` */ function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers, quotePreference) { switch (name.kind) { - case 196 /* ObjectBindingPattern */: - case 197 /* ArrayBindingPattern */: { + case 198 /* ObjectBindingPattern */: + case 199 /* ArrayBindingPattern */: { // `const [a, b] = require("c").d` --> `import { d } from "c"; const [a, b] = d;` var tmp = makeUniqueName(propertyName, identifiers); return convertedImports([ @@ -137405,7 +142349,7 @@ var ts; makeConst(/*modifiers*/ undefined, name, ts.factory.createIdentifier(tmp)), ]); } - case 78 /* Identifier */: + case 79 /* Identifier */: // `const a = require("b").c` --> `import { c as a } from "./b"; return convertedImports([makeSingleImport(name.text, propertyName, moduleSpecifier, quotePreference)]); default: @@ -137448,17 +142392,17 @@ var ts; function tryChangeModuleExportsObject(object, useSitesToUnqualify) { var statements = ts.mapAllOrFail(object.properties, function (prop) { switch (prop.kind) { - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: // TODO: Maybe we should handle this? See fourslash test `refactorConvertToEs6Module_export_object_shorthand.ts`. // falls through - case 289 /* ShorthandPropertyAssignment */: - case 290 /* SpreadAssignment */: + case 291 /* ShorthandPropertyAssignment */: + case 292 /* SpreadAssignment */: return undefined; - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: return !ts.isIdentifier(prop.name) ? undefined : convertExportsDotXEquals_replaceNode(prop.name.text, prop.initializer, useSitesToUnqualify); - case 165 /* MethodDeclaration */: - return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.factory.createToken(92 /* ExportKeyword */)], prop, useSitesToUnqualify); + case 167 /* MethodDeclaration */: + return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.factory.createToken(93 /* ExportKeyword */)], prop, useSitesToUnqualify); default: ts.Debug.assertNever(prop, "Convert to ES6 got invalid prop kind " + prop.kind); } @@ -137505,7 +142449,7 @@ 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(92 /* ExportKeyword */), { suffix: " " }); + changes.replaceRange(sourceFile, { pos: left.getStart(sourceFile), end: right.getStart(sourceFile) }, ts.factory.createToken(93 /* ExportKeyword */), { suffix: " " }); if (!right.name) changes.insertName(sourceFile, right, name); var semi = ts.findChildOfKind(parent, 26 /* SemicolonToken */, sourceFile); @@ -137514,14 +142458,14 @@ var ts; } 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(92 /* ExportKeyword */), ts.factory.createToken(84 /* ConstKeyword */)], { joiner: " ", suffix: " " }); + changes.replaceNodeRangeWithNodes(sourceFile, left.expression, ts.findChildOfKind(left, 24 /* DotToken */, sourceFile), [ts.factory.createToken(93 /* ExportKeyword */), ts.factory.createToken(85 /* 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(92 /* ExportKeyword */)]; + var modifiers = [ts.factory.createToken(93 /* ExportKeyword */)]; switch (exported.kind) { - case 208 /* FunctionExpression */: { + case 210 /* FunctionExpression */: { var expressionName = exported.name; if (expressionName && expressionName.text !== name) { // `exports.f = function g() {}` -> `export const f = function g() {}` @@ -137529,10 +142473,10 @@ var ts; } } // falls through - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: // `exports.f = function() {}` --> `export function f() {}` return functionExpressionToDeclaration(name, modifiers, exported, useSitesToUnqualify); - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: // `exports.C = class {}` --> `export class C {}` return classExpressionToDeclaration(name, modifiers, exported, useSitesToUnqualify); default: @@ -137552,7 +142496,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 === 201 /* PropertyAccessExpression */) { + if (original.kind === 203 /* 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); @@ -137567,7 +142511,7 @@ var ts; */ function convertSingleImport(name, moduleSpecifier, checker, identifiers, target, quotePreference) { switch (name.kind) { - case 196 /* ObjectBindingPattern */: { + case 198 /* 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 @@ -137580,7 +142524,7 @@ var ts; } } // falls through -- object destructuring has an interesting pattern and must be a variable declaration - case 197 /* ArrayBindingPattern */: { + case 199 /* ArrayBindingPattern */: { /* import x from "x"; const [a, b, c] = x; @@ -137591,7 +142535,7 @@ var ts; makeConst(/*modifiers*/ undefined, ts.getSynthesizedDeepClone(name), ts.factory.createIdentifier(tmp)), ]); } - case 78 /* Identifier */: + case 79 /* Identifier */: return convertSingleIdentifierImport(name, moduleSpecifier, checker, identifiers, quotePreference); default: return ts.Debug.assertNever(name, "Convert to ES6 module got invalid name kind " + name.kind); @@ -137599,7 +142543,9 @@ var ts; } /** * Convert `import x = require("x").` - * Also converts uses like `x.y()` to `y()` and uses a named import. + * Also: + * - Convert `x.default()` to `x()` to handle ES6 default export + * - Converts uses like `x.y()` to `y()` and uses a named import. */ function convertSingleIdentifierImport(name, moduleSpecifier, checker, identifiers, quotePreference) { var nameSymbol = checker.getSymbolAtLocation(name); @@ -137616,14 +142562,21 @@ var ts; } var parent = use.parent; if (ts.isPropertyAccessExpression(parent)) { - var expression = parent.expression, propertyName = parent.name.text; - ts.Debug.assert(expression === use, "Didn't expect expression === use"); // Else shouldn't have been in `collectIdentifiers` - var idName = namedBindingsNames.get(propertyName); - if (idName === undefined) { - idName = makeUniqueName(propertyName, identifiers); - namedBindingsNames.set(propertyName, idName); + var propertyName = parent.name.text; + if (propertyName === "default") { + needDefaultImport = true; + var importDefaultName = use.getText(); + (useSitesToUnqualify !== null && useSitesToUnqualify !== void 0 ? useSitesToUnqualify : (useSitesToUnqualify = new ts.Map())).set(parent, ts.factory.createIdentifier(importDefaultName)); + } + else { + ts.Debug.assert(parent.expression === use, "Didn't expect expression === use"); // Else shouldn't have been in `collectIdentifiers` + var idName = namedBindingsNames.get(propertyName); + if (idName === undefined) { + idName = makeUniqueName(propertyName, identifiers); + namedBindingsNames.set(propertyName, idName); + } + (useSitesToUnqualify !== null && useSitesToUnqualify !== void 0 ? useSitesToUnqualify : (useSitesToUnqualify = new ts.Map())).set(parent, ts.factory.createIdentifier(idName)); } - (useSitesToUnqualify !== null && useSitesToUnqualify !== void 0 ? useSitesToUnqualify : (useSitesToUnqualify = new ts.Map())).set(parent, ts.factory.createIdentifier(idName)); } else { needDefaultImport = true; @@ -137664,11 +142617,11 @@ var ts; function isFreeIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return parent.name !== node; - case 198 /* BindingElement */: + case 200 /* BindingElement */: return parent.propertyName !== node; - case 265 /* ImportSpecifier */: + case 267 /* ImportSpecifier */: return parent.propertyName !== node; default: return true; @@ -137782,7 +142735,7 @@ var ts; var exportDeclaration = exportClause.parent; var typeExportSpecifiers = getTypeExportSpecifiers(exportSpecifier, context); if (typeExportSpecifiers.length === exportClause.elements.length) { - changes.insertModifierBefore(context.sourceFile, 149 /* TypeKeyword */, exportClause); + changes.insertModifierBefore(context.sourceFile, 150 /* TypeKeyword */, exportClause); } else { var valueExportDeclaration = ts.factory.updateExportDeclaration(exportDeclaration, exportDeclaration.decorators, exportDeclaration.modifiers, @@ -138145,87 +143098,138 @@ var ts; ImportFixKind[ImportFixKind["AddToExisting"] = 2] = "AddToExisting"; ImportFixKind[ImportFixKind["AddNew"] = 3] = "AddNew"; })(ImportFixKind || (ImportFixKind = {})); - var ImportKind; - (function (ImportKind) { - ImportKind[ImportKind["Named"] = 0] = "Named"; - ImportKind[ImportKind["Default"] = 1] = "Default"; - ImportKind[ImportKind["Namespace"] = 2] = "Namespace"; - ImportKind[ImportKind["CommonJS"] = 3] = "CommonJS"; - })(ImportKind || (ImportKind = {})); function getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, symbolName, host, program, formatContext, position, preferences) { var compilerOptions = program.getCompilerOptions(); var exportInfos = ts.pathIsBareSpecifier(ts.stripQuotes(moduleSymbol.name)) - ? [getSymbolExportInfoForSymbol(exportedSymbol, moduleSymbol, sourceFile, program, host)] + ? [getSymbolExportInfoForSymbol(exportedSymbol, moduleSymbol, program, host)] : getAllReExportingModules(sourceFile, exportedSymbol, moduleSymbol, symbolName, host, program, /*useAutoImportProvider*/ true); var useRequire = shouldUseRequire(sourceFile, program); var preferTypeOnlyImport = compilerOptions.importsNotUsedAsValues === 2 /* Error */ && !ts.isSourceFileJS(sourceFile) && ts.isValidTypeOnlyAliasUseSite(ts.getTokenAtPosition(sourceFile, position)); - var moduleSpecifier = ts.first(getNewImportInfos(program, sourceFile, position, preferTypeOnlyImport, useRequire, exportInfos, host, preferences)).moduleSpecifier; var fix = getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, preferTypeOnlyImport, useRequire, host, preferences); - return { moduleSpecifier: moduleSpecifier, codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, ts.getQuotePreference(sourceFile, preferences))) }; + return { moduleSpecifier: fix.moduleSpecifier, codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, ts.getQuotePreference(sourceFile, preferences))) }; } codefix.getImportCompletionAction = getImportCompletionAction; function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, preferTypeOnlyImport, useRequire, host, preferences) { ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol"); - // We sort the best codefixes first, so taking `first` is best. - return ts.first(getFixForImport(exportInfos, symbolName, position, preferTypeOnlyImport, useRequire, program, sourceFile, host, preferences)); + return getBestFix(getImportFixes(exportInfos, symbolName, position, preferTypeOnlyImport, useRequire, program, sourceFile, host, preferences), sourceFile, host); } function codeFixActionToCodeAction(_a) { var description = _a.description, changes = _a.changes, commands = _a.commands; return { description: description, changes: changes, commands: commands }; } - function getSymbolExportInfoForSymbol(symbol, moduleSymbol, importingFile, program, host) { + function getSymbolExportInfoForSymbol(symbol, moduleSymbol, program, host) { var _a, _b; var compilerOptions = program.getCompilerOptions(); - var mainProgramInfo = getInfoWithChecker(program.getTypeChecker()); + var mainProgramInfo = getInfoWithChecker(program.getTypeChecker(), /*isFromPackageJson*/ false); if (mainProgramInfo) { return mainProgramInfo; } var autoImportProvider = (_b = (_a = host.getPackageJsonAutoImportProvider) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getTypeChecker(); - return ts.Debug.checkDefined(autoImportProvider && getInfoWithChecker(autoImportProvider), "Could not find symbol in specified module for code actions"); - function getInfoWithChecker(checker) { - var defaultInfo = getDefaultLikeExportInfo(importingFile, moduleSymbol, checker, compilerOptions); + return ts.Debug.checkDefined(autoImportProvider && getInfoWithChecker(autoImportProvider, /*isFromPackageJson*/ true), "Could not find symbol in specified module for code actions"); + function getInfoWithChecker(checker, isFromPackageJson) { + var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); if (defaultInfo && ts.skipAlias(defaultInfo.symbol, checker) === symbol) { - return { moduleSymbol: moduleSymbol, importKind: defaultInfo.kind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(symbol, checker) }; + return { symbol: defaultInfo.symbol, moduleSymbol: moduleSymbol, exportKind: defaultInfo.exportKind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(symbol, checker), isFromPackageJson: isFromPackageJson }; } var named = checker.tryGetMemberInModuleExportsAndProperties(symbol.name, moduleSymbol); if (named && ts.skipAlias(named, checker) === symbol) { - return { moduleSymbol: moduleSymbol, importKind: 0 /* Named */, exportedSymbolIsTypeOnly: isTypeOnlySymbol(symbol, checker) }; + return { symbol: named, moduleSymbol: moduleSymbol, exportKind: 0 /* Named */, exportedSymbolIsTypeOnly: isTypeOnlySymbol(symbol, checker), isFromPackageJson: isFromPackageJson }; } } } function getAllReExportingModules(importingFile, exportedSymbol, exportingModuleSymbol, symbolName, host, program, useAutoImportProvider) { var result = []; var compilerOptions = program.getCompilerOptions(); - forEachExternalModuleToImportFrom(program, host, importingFile, /*filterByPackageJson*/ false, useAutoImportProvider, function (moduleSymbol, moduleFile, program) { + var getModuleSpecifierResolutionHost = ts.memoizeOne(function (isFromPackageJson) { + return ts.createModuleSpecifierResolutionHost(isFromPackageJson ? host.getPackageJsonAutoImportProvider() : program, host); + }); + forEachExternalModuleToImportFrom(program, host, useAutoImportProvider, function (moduleSymbol, moduleFile, program, isFromPackageJson) { var checker = program.getTypeChecker(); // Don't import from a re-export when looking "up" like to `./index` or `../index`. if (moduleFile && moduleSymbol !== exportingModuleSymbol && ts.startsWith(importingFile.fileName, ts.getDirectoryPath(moduleFile.fileName))) { return; } - var defaultInfo = getDefaultLikeExportInfo(importingFile, moduleSymbol, checker, compilerOptions); - if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, compilerOptions.target) === symbolName) && ts.skipAlias(defaultInfo.symbol, checker) === exportedSymbol) { - result.push({ moduleSymbol: moduleSymbol, importKind: defaultInfo.kind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(defaultInfo.symbol, checker) }); + var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); + if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, compilerOptions.target) === symbolName) && ts.skipAlias(defaultInfo.symbol, checker) === exportedSymbol && isImportable(program, moduleFile, isFromPackageJson)) { + result.push({ symbol: defaultInfo.symbol, moduleSymbol: moduleSymbol, exportKind: defaultInfo.exportKind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(defaultInfo.symbol, checker), isFromPackageJson: isFromPackageJson }); + } + for (var _i = 0, _a = checker.getExportsAndPropertiesOfModule(moduleSymbol); _i < _a.length; _i++) { + var exported = _a[_i]; + if (exported.name === symbolName && ts.skipAlias(exported, checker) === exportedSymbol && isImportable(program, moduleFile, isFromPackageJson)) { + result.push({ symbol: exported, moduleSymbol: moduleSymbol, exportKind: 0 /* Named */, exportedSymbolIsTypeOnly: isTypeOnlySymbol(exported, checker), isFromPackageJson: isFromPackageJson }); + } + } + }); + return result; + function isImportable(program, moduleFile, isFromPackageJson) { + var _a; + return !moduleFile || ts.isImportableFile(program, importingFile, moduleFile, /*packageJsonFilter*/ undefined, getModuleSpecifierResolutionHost(isFromPackageJson), (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host)); + } + } + function getModuleSpecifierForBestExportInfo(exportInfo, importingFile, program, host, preferences) { + return getBestFix(getNewImportFixes(program, importingFile, /*position*/ undefined, /*preferTypeOnlyImport*/ false, /*useRequire*/ false, exportInfo, host, preferences), importingFile, host); + } + codefix.getModuleSpecifierForBestExportInfo = getModuleSpecifierForBestExportInfo; + function getSymbolToExportInfoMap(importingFile, host, program) { + var _a, _b, _c, _d, _e, _f, _g, _h; + var start = ts.timestamp(); + // Pulling the AutoImportProvider project will trigger its updateGraph if pending, + // which will invalidate the export map cache if things change, so pull it before + // checking the cache. + (_a = host.getPackageJsonAutoImportProvider) === null || _a === void 0 ? void 0 : _a.call(host); + var cache = (_b = host.getExportMapCache) === null || _b === void 0 ? void 0 : _b.call(host); + if (cache) { + var cached = cache.get(importingFile.path, program.getTypeChecker(), (_c = host.getProjectVersion) === null || _c === void 0 ? void 0 : _c.call(host)); + if (cached) { + (_d = host.log) === null || _d === void 0 ? void 0 : _d.call(host, "getSymbolToExportInfoMap: cache hit"); + return cached; + } + else { + (_e = host.log) === null || _e === void 0 ? void 0 : _e.call(host, "getSymbolToExportInfoMap: cache miss or empty; calculating new results"); + } + } + var result = ts.createMultiMap(); + var compilerOptions = program.getCompilerOptions(); + var target = ts.getEmitScriptTarget(compilerOptions); + forEachExternalModuleToImportFrom(program, host, /*useAutoImportProvider*/ true, function (moduleSymbol, _moduleFile, program, isFromPackageJson) { + var checker = program.getTypeChecker(); + var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); + if (defaultInfo) { + var name = ts.getNameForExportedSymbol(ts.getLocalSymbolForExportDefault(defaultInfo.symbol) || defaultInfo.symbol, target); + result.add(key(name, defaultInfo.symbol, moduleSymbol, checker), { symbol: defaultInfo.symbol, moduleSymbol: moduleSymbol, exportKind: defaultInfo.exportKind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(defaultInfo.symbol, checker), isFromPackageJson: isFromPackageJson }); } + var seenExports = new ts.Map(); for (var _i = 0, _a = checker.getExportsAndPropertiesOfModule(moduleSymbol); _i < _a.length; _i++) { var exported = _a[_i]; - if (exported.name === symbolName && ts.skipAlias(exported, checker) === exportedSymbol) { - result.push({ moduleSymbol: moduleSymbol, importKind: 0 /* Named */, exportedSymbolIsTypeOnly: isTypeOnlySymbol(exported, checker) }); + if (exported !== (defaultInfo === null || defaultInfo === void 0 ? void 0 : defaultInfo.symbol) && ts.addToSeen(seenExports, exported)) { + result.add(key(ts.getNameForExportedSymbol(exported, target), exported, moduleSymbol, checker), { symbol: exported, moduleSymbol: moduleSymbol, exportKind: 0 /* Named */, exportedSymbolIsTypeOnly: isTypeOnlySymbol(exported, checker), isFromPackageJson: isFromPackageJson }); } } }); + if (cache) { + (_f = host.log) === null || _f === void 0 ? void 0 : _f.call(host, "getSymbolToExportInfoMap: caching results"); + cache.set(result, (_g = host.getProjectVersion) === null || _g === void 0 ? void 0 : _g.call(host)); + } + (_h = host.log) === null || _h === void 0 ? void 0 : _h.call(host, "getSymbolToExportInfoMap: done in " + (ts.timestamp() - start) + " ms"); return result; + function key(name, alias, moduleSymbol, checker) { + var moduleName = ts.stripQuotes(moduleSymbol.name); + var moduleKey = ts.isExternalModuleNameRelative(moduleName) ? "/" : moduleName; + return name + "|" + ts.getSymbolId(ts.skipAlias(alias, checker)) + "|" + moduleKey; + } } + codefix.getSymbolToExportInfoMap = getSymbolToExportInfoMap; function isTypeOnlySymbol(s, checker) { return !(ts.skipAlias(s, checker).flags & 111551 /* Value */); } function isTypeOnlyPosition(sourceFile, position) { return ts.isValidTypeOnlyAliasUseSite(ts.getTokenAtPosition(sourceFile, position)); } - function getFixForImport(exportInfos, symbolName, + function getImportFixes(exportInfos, symbolName, /** undefined only for missing JSX namespace */ position, preferTypeOnlyImport, useRequire, program, sourceFile, host, preferences) { var checker = program.getTypeChecker(); - var existingImports = ts.flatMap(exportInfos, function (info) { return getExistingImportDeclarations(info, checker, sourceFile); }); + var existingImports = ts.flatMap(exportInfos, function (info) { return getExistingImportDeclarations(info, checker, sourceFile, program.getCompilerOptions()); }); var useNamespace = position === undefined ? undefined : tryUseExistingNamespaceImport(existingImports, symbolName, position, checker); var addToExisting = tryAddToExistingImport(existingImports, position !== undefined && isTypeOnlyPosition(sourceFile, position)); // Don't bother providing an action to add a new import if we can add to an existing one. @@ -138248,10 +143252,11 @@ var ts; return ts.firstDefined(existingImports, function (_a) { var declaration = _a.declaration; var namespacePrefix = getNamespaceLikeImportText(declaration); - if (namespacePrefix) { + var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration); + if (namespacePrefix && moduleSpecifier) { var moduleSymbol = getTargetModuleFromNamespaceLikeImport(declaration, checker); if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(symbolName))) { - return { kind: 0 /* UseNamespace */, namespacePrefix: namespacePrefix, position: position }; + return { kind: 0 /* UseNamespace */, namespacePrefix: namespacePrefix, position: position, moduleSpecifier: moduleSpecifier }; } } }); @@ -138259,11 +143264,11 @@ var ts; function getTargetModuleFromNamespaceLikeImport(declaration, checker) { var _a; switch (declaration.kind) { - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return checker.resolveExternalModuleName(declaration.initializer.arguments[0]); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return checker.getAliasedSymbol(declaration.symbol); - case 261 /* ImportDeclaration */: + case 263 /* 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: @@ -138273,11 +143278,11 @@ var ts; function getNamespaceLikeImportText(declaration) { var _a, _b, _c; switch (declaration.kind) { - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return (_a = ts.tryCast(declaration.name, ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text; - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return declaration.name.text; - case 261 /* ImportDeclaration */: + case 263 /* 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); @@ -138286,31 +143291,38 @@ var ts; function tryAddToExistingImport(existingImports, canUseTypeOnlyImport) { return ts.firstDefined(existingImports, function (_a) { var declaration = _a.declaration, importKind = _a.importKind; - if (declaration.kind === 260 /* ImportEqualsDeclaration */) + if (declaration.kind === 262 /* ImportEqualsDeclaration */) return undefined; - if (declaration.kind === 249 /* VariableDeclaration */) { - return (importKind === 0 /* Named */ || importKind === 1 /* Default */) && declaration.name.kind === 196 /* ObjectBindingPattern */ + if (declaration.kind === 251 /* VariableDeclaration */) { + return (importKind === 0 /* Named */ || importKind === 1 /* Default */) && declaration.name.kind === 198 /* ObjectBindingPattern */ ? { kind: 2 /* AddToExisting */, importClauseOrBindingPattern: declaration.name, importKind: importKind, moduleSpecifier: declaration.initializer.arguments[0].text, canUseTypeOnlyImport: false } : undefined; } var importClause = declaration.importClause; - if (!importClause) + if (!importClause || !ts.isStringLiteralLike(declaration.moduleSpecifier)) return undefined; var name = importClause.name, namedBindings = importClause.namedBindings; - return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 264 /* NamedImports */) - ? { kind: 2 /* AddToExisting */, importClauseOrBindingPattern: importClause, importKind: importKind, moduleSpecifier: declaration.moduleSpecifier.getText(), canUseTypeOnlyImport: canUseTypeOnlyImport } + // 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)) + return undefined; + return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 266 /* NamedImports */) + ? { kind: 2 /* AddToExisting */, importClauseOrBindingPattern: importClause, importKind: importKind, moduleSpecifier: declaration.moduleSpecifier.text, canUseTypeOnlyImport: canUseTypeOnlyImport } : undefined; }); } - function getExistingImportDeclarations(_a, checker, sourceFile) { - var moduleSymbol = _a.moduleSymbol, importKind = _a.importKind, exportedSymbolIsTypeOnly = _a.exportedSymbolIsTypeOnly; + function getExistingImportDeclarations(_a, checker, importingFile, compilerOptions) { + var moduleSymbol = _a.moduleSymbol, exportKind = _a.exportKind, exportedSymbolIsTypeOnly = _a.exportedSymbolIsTypeOnly; // Can't use an es6 import for a type in JS. - return exportedSymbolIsTypeOnly && ts.isSourceFileJS(sourceFile) ? ts.emptyArray : ts.mapDefined(sourceFile.imports, function (moduleSpecifier) { + if (exportedSymbolIsTypeOnly && ts.isSourceFileJS(importingFile)) + return ts.emptyArray; + var importKind = getImportKind(importingFile, exportKind, compilerOptions); + return ts.mapDefined(importingFile.imports, function (moduleSpecifier) { var i = ts.importFromModuleSpecifier(moduleSpecifier); - if (ts.isRequireVariableDeclaration(i.parent, /*requireStringLiteralLikeArgument*/ true)) { + if (ts.isRequireVariableDeclaration(i.parent)) { return checker.resolveExternalModuleName(moduleSpecifier) === moduleSymbol ? { declaration: i.parent, importKind: importKind } : undefined; } - if (i.kind === 261 /* ImportDeclaration */ || i.kind === 260 /* ImportEqualsDeclaration */) { + if (i.kind === 263 /* ImportDeclaration */ || i.kind === 262 /* ImportEqualsDeclaration */) { return checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind } : undefined; } }); @@ -138343,45 +143355,29 @@ var ts; // 5. Literally nothing to go on return true; } - function getNewImportInfos(program, sourceFile, position, preferTypeOnlyImport, useRequire, moduleSymbols, host, preferences) { + function getNewImportFixes(program, sourceFile, position, preferTypeOnlyImport, useRequire, moduleSymbols, host, preferences) { var isJs = ts.isSourceFileJS(sourceFile); var compilerOptions = program.getCompilerOptions(); - var allowsImportingSpecifier = createAutoImportFilter(sourceFile, program, host).allowsImportingSpecifier; - var choicesForEachExportingModule = ts.flatMap(moduleSymbols, function (_a) { - var moduleSymbol = _a.moduleSymbol, importKind = _a.importKind, exportedSymbolIsTypeOnly = _a.exportedSymbolIsTypeOnly; - return ts.moduleSpecifiers.getModuleSpecifiers(moduleSymbol, program.getTypeChecker(), compilerOptions, sourceFile, ts.createModuleSpecifierResolutionHost(program, host), preferences) + var moduleSpecifierResolutionHost = ts.createModuleSpecifierResolutionHost(program, host); + return ts.flatMap(moduleSymbols, function (exportInfo) { + return ts.moduleSpecifiers.getModuleSpecifiers(exportInfo.moduleSymbol, program.getTypeChecker(), compilerOptions, sourceFile, moduleSpecifierResolutionHost, preferences) .map(function (moduleSpecifier) { // `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types. - return exportedSymbolIsTypeOnly && isJs - ? { kind: 1 /* ImportType */, moduleSpecifier: moduleSpecifier, position: ts.Debug.checkDefined(position, "position should be defined") } - : { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind, useRequire: useRequire, typeOnly: preferTypeOnlyImport }; + return exportInfo.exportedSymbolIsTypeOnly && isJs && position !== undefined + ? { kind: 1 /* ImportType */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo } + : { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: getImportKind(sourceFile, exportInfo.exportKind, compilerOptions), useRequire: useRequire, typeOnly: preferTypeOnlyImport, exportInfo: exportInfo }; }); }); - // Sort by presence in package.json, then shortest paths first - return ts.sort(choicesForEachExportingModule, function (a, b) { - var allowsImportingA = allowsImportingSpecifier(a.moduleSpecifier); - var allowsImportingB = allowsImportingSpecifier(b.moduleSpecifier); - if (allowsImportingA && !allowsImportingB) { - return -1; - } - if (allowsImportingB && !allowsImportingA) { - return 1; - } - return a.moduleSpecifier.length - b.moduleSpecifier.length; - }); } function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, preferTypeOnlyImport, useRequire, host, preferences) { var existingDeclaration = ts.firstDefined(existingImports, function (info) { return newImportInfoFromExistingSpecifier(info, preferTypeOnlyImport, useRequire); }); - return existingDeclaration ? [existingDeclaration] : getNewImportInfos(program, sourceFile, position, preferTypeOnlyImport, useRequire, exportInfos, host, preferences); + return existingDeclaration ? [existingDeclaration] : getNewImportFixes(program, sourceFile, position, preferTypeOnlyImport, useRequire, exportInfos, host, preferences); } function newImportInfoFromExistingSpecifier(_a, preferTypeOnlyImport, useRequire) { var declaration = _a.declaration, importKind = _a.importKind; - var moduleSpecifier = declaration.kind === 261 /* ImportDeclaration */ ? declaration.moduleSpecifier : - declaration.kind === 249 /* VariableDeclaration */ ? declaration.initializer.arguments[0] : - declaration.moduleReference.kind === 272 /* ExternalModuleReference */ ? declaration.moduleReference.expression : - undefined; - return moduleSpecifier && ts.isStringLiteral(moduleSpecifier) - ? { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier.text, importKind: importKind, typeOnly: preferTypeOnlyImport, useRequire: useRequire } + var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration); + return moduleSpecifier + ? { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind, typeOnly: preferTypeOnlyImport, useRequire: useRequire } : undefined; } function getFixesInfo(context, errorCode, pos, useAutoImportProvider) { @@ -138389,7 +143385,28 @@ var ts; var info = errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code ? getFixesInfoForUMDImport(context, symbolToken) : ts.isIdentifier(symbolToken) ? getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider) : undefined; - return info && __assign(__assign({}, info), { fixes: ts.sort(info.fixes, function (a, b) { return a.kind - b.kind; }) }); + return info && __assign(__assign({}, info), { fixes: sortFixes(info.fixes, context.sourceFile, context.host) }); + } + function sortFixes(fixes, sourceFile, host) { + var allowsImportingSpecifier = ts.createPackageJsonImportFilter(sourceFile, host).allowsImportingSpecifier; + return ts.sort(fixes, function (a, b) { return ts.compareValues(a.kind, b.kind) || compareModuleSpecifiers(a, b, allowsImportingSpecifier); }); + } + function getBestFix(fixes, sourceFile, host) { + // 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 */) { + return fixes[0]; + } + var allowsImportingSpecifier = ts.createPackageJsonImportFilter(sourceFile, host).allowsImportingSpecifier; + return fixes.reduce(function (best, fix) { + return compareModuleSpecifiers(fix, best, allowsImportingSpecifier) === -1 /* LessThan */ ? fix : best; + }); + } + function compareModuleSpecifiers(a, b, allowsImportingSpecifier) { + if (a.kind !== 0 /* UseNamespace */ && b.kind !== 0 /* UseNamespace */) { + return ts.compareBooleans(allowsImportingSpecifier(a.moduleSpecifier), allowsImportingSpecifier(b.moduleSpecifier)) + || ts.compareNumberOfDirectorySeparators(a.moduleSpecifier, b.moduleSpecifier); + } + return 0 /* EqualTo */; } function getFixesInfoForUMDImport(_a, token) { var sourceFile = _a.sourceFile, program = _a.program, host = _a.host, preferences = _a.preferences; @@ -138399,9 +143416,9 @@ var ts; return undefined; var symbol = checker.getAliasedSymbol(umdSymbol); var symbolName = umdSymbol.name; - var exportInfos = [{ moduleSymbol: symbol, importKind: getUmdImportKind(sourceFile, program.getCompilerOptions()), exportedSymbolIsTypeOnly: false }]; + var exportInfos = [{ symbol: umdSymbol, moduleSymbol: symbol, exportKind: 3 /* UMD */, exportedSymbolIsTypeOnly: false, isFromPackageJson: false }]; var useRequire = shouldUseRequire(sourceFile, program); - var fixes = getFixForImport(exportInfos, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, /*preferTypeOnlyImport*/ false, useRequire, program, sourceFile, host, preferences); + var fixes = getImportFixes(exportInfos, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, /*preferTypeOnlyImport*/ false, useRequire, program, sourceFile, host, preferences); return { fixes: fixes, symbolName: symbolName }; } function getUmdSymbol(token, checker) { @@ -138415,6 +143432,16 @@ var ts; ? ts.tryCast(checker.resolveName(checker.getJsxNamespace(parent), ts.isJsxOpeningLikeElement(parent) ? token : parent, 111551 /* Value */, /*excludeGlobals*/ false), ts.isUMDExportSymbol) : undefined; } + function getImportKind(importingFile, exportKind, compilerOptions) { + switch (exportKind) { + case 0 /* Named */: return 0 /* Named */; + case 1 /* Default */: return 1 /* Default */; + case 2 /* ExportEquals */: return getExportEqualsImportKind(importingFile, compilerOptions); + case 3 /* UMD */: return getUmdImportKind(importingFile, compilerOptions); + default: return ts.Debug.assertNever(exportKind); + } + } + codefix.getImportKind = getImportKind; function getUmdImportKind(importingFile, compilerOptions) { // Import a synthetic `default` if enabled. if (ts.getAllowSyntheticDefaultImports(compilerOptions)) { @@ -138444,22 +143471,22 @@ var ts; function getFixesInfoForNonUMDImport(_a, symbolToken, useAutoImportProvider) { var sourceFile = _a.sourceFile, program = _a.program, cancellationToken = _a.cancellationToken, host = _a.host, preferences = _a.preferences; var checker = program.getTypeChecker(); - var symbolName = getSymbolName(sourceFile, checker, symbolToken); + var compilerOptions = program.getCompilerOptions(); + var symbolName = getSymbolName(sourceFile, checker, symbolToken, compilerOptions); // "default" is a keyword and not a legal identifier for the import, so we don't expect it here ts.Debug.assert(symbolName !== "default" /* Default */, "'default' isn't a legal identifier and couldn't occur here"); - var compilerOptions = program.getCompilerOptions(); var preferTypeOnlyImport = compilerOptions.importsNotUsedAsValues === 2 /* Error */ && ts.isValidTypeOnlyAliasUseSite(symbolToken); var useRequire = shouldUseRequire(sourceFile, program); var exportInfos = getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host); var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfos.entries(), function (_a) { var _ = _a[0], exportInfos = _a[1]; - return getFixForImport(exportInfos, symbolName, symbolToken.getStart(sourceFile), preferTypeOnlyImport, useRequire, program, sourceFile, host, preferences); + return getImportFixes(exportInfos, symbolName, symbolToken.getStart(sourceFile), preferTypeOnlyImport, useRequire, program, sourceFile, host, preferences); })); return { fixes: fixes, symbolName: symbolName }; } - function getSymbolName(sourceFile, checker, symbolToken) { + function getSymbolName(sourceFile, checker, symbolToken, compilerOptions) { var parent = symbolToken.parent; - if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken) { + if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken && compilerOptions.jsx !== 4 /* ReactJSX */ && compilerOptions.jsx !== 5 /* ReactJSXDev */) { var jsxNamespace = checker.getJsxNamespace(sourceFile); if (ts.isIntrinsicJsxName(symbolToken.text) || !checker.resolveName(jsxNamespace, parent, 111551 /* Value */, /*excludeGlobals*/ true)) { return jsxNamespace; @@ -138468,43 +143495,55 @@ var ts; return symbolToken.text; } // Returns a map from an exported symbol's ID to a list of every way it's (re-)exported. - function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, sourceFile, program, useAutoImportProvider, host) { + function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, fromFile, program, useAutoImportProvider, host) { + var _a; // For each original symbol, keep all re-exports of that symbol together so we can call `getCodeActionsForImport` on the whole group at once. // Maps symbol id to info for modules providing that symbol (original export + re-exports). var originalSymbolToExportInfos = ts.createMultiMap(); - function addSymbol(moduleSymbol, exportedSymbol, importKind, checker) { - originalSymbolToExportInfos.add(ts.getUniqueSymbolId(exportedSymbol, checker).toString(), { moduleSymbol: moduleSymbol, importKind: importKind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(exportedSymbol, checker) }); + var packageJsonFilter = ts.createPackageJsonImportFilter(fromFile, host); + var moduleSpecifierCache = (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host); + var getModuleSpecifierResolutionHost = ts.memoizeOne(function (isFromPackageJson) { + return ts.createModuleSpecifierResolutionHost(isFromPackageJson ? host.getPackageJsonAutoImportProvider() : program, host); + }); + function addSymbol(moduleSymbol, toFile, exportedSymbol, exportKind, program, isFromPackageJson) { + var moduleSpecifierResolutionHost = getModuleSpecifierResolutionHost(isFromPackageJson); + if (toFile && ts.isImportableFile(program, fromFile, toFile, packageJsonFilter, moduleSpecifierResolutionHost, moduleSpecifierCache) || + !toFile && packageJsonFilter.allowsImportingAmbientModule(moduleSymbol, moduleSpecifierResolutionHost)) { + var checker = program.getTypeChecker(); + originalSymbolToExportInfos.add(ts.getUniqueSymbolId(exportedSymbol, checker).toString(), { symbol: exportedSymbol, moduleSymbol: moduleSymbol, exportKind: exportKind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(exportedSymbol, checker), isFromPackageJson: isFromPackageJson }); + } } - forEachExternalModuleToImportFrom(program, host, sourceFile, /*filterByPackageJson*/ true, useAutoImportProvider, function (moduleSymbol, _, program) { + forEachExternalModuleToImportFrom(program, host, useAutoImportProvider, function (moduleSymbol, sourceFile, program, isFromPackageJson) { var checker = program.getTypeChecker(); cancellationToken.throwIfCancellationRequested(); var compilerOptions = program.getCompilerOptions(); - var defaultInfo = getDefaultLikeExportInfo(sourceFile, moduleSymbol, checker, compilerOptions); + var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, compilerOptions.target) === symbolName) && symbolHasMeaning(defaultInfo.symbolForMeaning, currentTokenMeaning)) { - addSymbol(moduleSymbol, defaultInfo.symbol, defaultInfo.kind, checker); + addSymbol(moduleSymbol, sourceFile, defaultInfo.symbol, defaultInfo.exportKind, program, isFromPackageJson); } // check exports with the same name var exportSymbolWithIdenticalName = checker.tryGetMemberInModuleExportsAndProperties(symbolName, moduleSymbol); if (exportSymbolWithIdenticalName && symbolHasMeaning(exportSymbolWithIdenticalName, currentTokenMeaning)) { - addSymbol(moduleSymbol, exportSymbolWithIdenticalName, 0 /* Named */, checker); + addSymbol(moduleSymbol, sourceFile, exportSymbolWithIdenticalName, 0 /* Named */, program, isFromPackageJson); } }); return originalSymbolToExportInfos; } - function getDefaultLikeExportInfo(importingFile, moduleSymbol, checker, compilerOptions) { - var exported = getDefaultLikeExportWorker(importingFile, moduleSymbol, checker, compilerOptions); + function getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions) { + var exported = getDefaultLikeExportWorker(moduleSymbol, checker); if (!exported) return undefined; - var symbol = exported.symbol, kind = exported.kind; - var info = getDefaultExportInfoWorker(symbol, moduleSymbol, checker, compilerOptions); - return info && __assign({ symbol: symbol, kind: kind }, info); + var symbol = exported.symbol, exportKind = exported.exportKind; + var info = getDefaultExportInfoWorker(symbol, checker, compilerOptions); + return info && __assign({ symbol: symbol, exportKind: exportKind }, info); } - function getDefaultLikeExportWorker(importingFile, moduleSymbol, checker, compilerOptions) { + 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); if (defaultExport) - return { symbol: defaultExport, kind: 1 /* Default */ }; - var exportEquals = checker.resolveExternalModuleSymbol(moduleSymbol); - return exportEquals === moduleSymbol ? undefined : { symbol: exportEquals, kind: getExportEqualsImportKind(importingFile, compilerOptions) }; + return { symbol: defaultExport, exportKind: 1 /* Default */ }; } function getExportEqualsImportKind(importingFile, compilerOptions) { var allowSyntheticDefaults = ts.getAllowSyntheticDefaultImports(compilerOptions); @@ -138523,7 +143562,8 @@ var ts; // on how to handle it. for (var _i = 0, _a = importingFile.statements; _i < _a.length; _i++) { var statement = _a[_i]; - if (ts.isImportEqualsDeclaration(statement)) { + // `import foo` parses as an ImportEqualsDeclaration even though it could be an ImportDeclaration + if (ts.isImportEqualsDeclaration(statement) && !ts.nodeIsMissing(statement.moduleReference)) { return 3 /* CommonJS */; } } @@ -138531,7 +143571,7 @@ var ts; // allowSyntheticDefaultImports/esModuleInterop is enabled. return allowSyntheticDefaults ? 1 /* Default */ : 3 /* CommonJS */; } - function getDefaultExportInfoWorker(defaultExport, moduleSymbol, checker, compilerOptions) { + function getDefaultExportInfoWorker(defaultExport, checker, compilerOptions) { var localSymbol = ts.getLocalSymbolForExportDefault(defaultExport); if (localSymbol) return { symbolForMeaning: localSymbol, name: localSymbol.name }; @@ -138545,21 +143585,20 @@ var ts; // but we can still offer completions for it. // - `aliased.parent` will be undefined if the module is exporting `globalThis.something`, // or another expression that resolves to a global. - return getDefaultExportInfoWorker(aliased, aliased.parent, checker, compilerOptions); + return getDefaultExportInfoWorker(aliased, checker, compilerOptions); } } if (defaultExport.escapedName !== "default" /* Default */ && defaultExport.escapedName !== "export=" /* ExportEquals */) { return { symbolForMeaning: defaultExport, name: defaultExport.getName() }; } - return { symbolForMeaning: defaultExport, name: moduleSymbolToValidIdentifier(moduleSymbol, compilerOptions.target) }; + return { symbolForMeaning: defaultExport, name: ts.getNameForExportedSymbol(defaultExport, compilerOptions.target) }; } function getNameForExportDefault(symbol) { return symbol.declarations && ts.firstDefined(symbol.declarations, function (declaration) { + var _a; if (ts.isExportAssignment(declaration)) { - if (ts.isIdentifier(declaration.expression)) { - return declaration.expression.text; - } + 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"); @@ -138602,7 +143641,7 @@ var ts; } } function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports, canUseTypeOnlyImport) { - if (clause.kind === 196 /* ObjectBindingPattern */) { + if (clause.kind === 198 /* ObjectBindingPattern */) { if (defaultImport) { addElementToBindingPattern(clause, defaultImport, "default"); } @@ -138729,48 +143768,23 @@ var ts; var declarations = _a.declarations; return ts.some(declarations, function (decl) { return !!(ts.getMeaningFromDeclaration(decl) & meaning); }); } - function forEachExternalModuleToImportFrom(program, host, from, filterByPackageJson, useAutoImportProvider, cb) { + function forEachExternalModuleToImportFrom(program, host, useAutoImportProvider, cb) { var _a, _b; - forEachExternalModuleToImportFromInProgram(program, host, from, filterByPackageJson, function (module, file) { return cb(module, file, program, /*isFromPackageJson*/ false); }); + forEachExternalModule(program.getTypeChecker(), program.getSourceFiles(), function (module, file) { return cb(module, file, program, /*isFromPackageJson*/ false); }); var autoImportProvider = useAutoImportProvider && ((_a = host.getPackageJsonAutoImportProvider) === null || _a === void 0 ? void 0 : _a.call(host)); if (autoImportProvider) { var start = ts.timestamp(); - forEachExternalModuleToImportFromInProgram(autoImportProvider, host, from, filterByPackageJson, function (module, file) { return cb(module, file, autoImportProvider, /*isFromPackageJson*/ true); }); + forEachExternalModule(autoImportProvider.getTypeChecker(), autoImportProvider.getSourceFiles(), 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)); } } codefix.forEachExternalModuleToImportFrom = forEachExternalModuleToImportFrom; - function forEachExternalModuleToImportFromInProgram(program, host, from, filterByPackageJson, cb) { - var _a; - var filteredCount = 0; - var moduleSpecifierResolutionHost = ts.createModuleSpecifierResolutionHost(program, host); - var packageJson = filterByPackageJson && createAutoImportFilter(from, program, host, moduleSpecifierResolutionHost); - forEachExternalModule(program.getTypeChecker(), program.getSourceFiles(), function (module, sourceFile) { - if (sourceFile === undefined) { - if (!packageJson || packageJson.allowsImportingAmbientModule(module)) { - cb(module, sourceFile); - } - else if (packageJson) { - filteredCount++; - } - } - else if (sourceFile && - sourceFile !== from && - isImportableFile(program, from, sourceFile, moduleSpecifierResolutionHost)) { - if (!packageJson || packageJson.allowsImportingSourceFile(sourceFile)) { - cb(module, sourceFile); - } - else if (packageJson) { - filteredCount++; - } - } - }); - (_a = host.log) === null || _a === void 0 ? void 0 : _a.call(host, "forEachExternalModuleToImportFrom: filtered out " + filteredCount + " modules by package.json contents"); - } function forEachExternalModule(checker, allSourceFiles, cb) { for (var _i = 0, _a = checker.getAmbientModules(); _i < _a.length; _i++) { var ambient = _a[_i]; - cb(ambient, /*sourceFile*/ undefined); + if (!ts.stringContains(ambient.name, "*")) { + cb(ambient, /*sourceFile*/ undefined); + } } for (var _b = 0, allSourceFiles_1 = allSourceFiles; _b < allSourceFiles_1.length; _b++) { var sourceFile = allSourceFiles_1[_b]; @@ -138779,31 +143793,6 @@ var ts; } } } - function isImportableFile(program, from, to, moduleSpecifierResolutionHost) { - var _a; - var getCanonicalFileName = ts.hostGetCanonicalFileName(moduleSpecifierResolutionHost); - var globalTypingsCache = (_a = moduleSpecifierResolutionHost.getGlobalTypingsCacheLocation) === null || _a === void 0 ? void 0 : _a.call(moduleSpecifierResolutionHost); - return !!ts.moduleSpecifiers.forEachFileNameOfModule(from.fileName, to.fileName, moduleSpecifierResolutionHost, - /*preferSymlinks*/ false, function (toPath) { - var toFile = program.getSourceFile(toPath); - // Determine to import using toPath only if toPath is what we were looking at - // or there doesnt exist the file in the program by the symlink - return (toFile === to || !toFile) && - isImportablePath(from.fileName, toPath, getCanonicalFileName, globalTypingsCache); - }); - } - /** - * Don't include something from a `node_modules` that isn't actually reachable by a global import. - * A relative import to node_modules is usually a bad idea. - */ - function isImportablePath(fromPath, toPath, getCanonicalFileName, globalCachePath) { - // If it's in a `node_modules` but is not reachable from here via a global import, don't bother. - var toNodeModules = ts.forEachAncestorDirectory(toPath, function (ancestor) { return ts.getBaseFileName(ancestor) === "node_modules" ? ancestor : undefined; }); - var toNodeModulesParent = toNodeModules && ts.getDirectoryPath(getCanonicalFileName(toNodeModules)); - return toNodeModulesParent === undefined - || ts.startsWith(getCanonicalFileName(fromPath), toNodeModulesParent) - || (!!globalCachePath && ts.startsWith(getCanonicalFileName(globalCachePath), toNodeModulesParent)); - } function moduleSymbolToValidIdentifier(moduleSymbol, target) { return moduleSpecifierToValidIdentifier(ts.removeFileExtension(ts.stripQuotes(moduleSymbol.name)), target); } @@ -138835,99 +143824,122 @@ var ts; return !ts.isStringANonContextualKeyword(res) ? res || "_" : "_" + res; } codefix.moduleSpecifierToValidIdentifier = moduleSpecifierToValidIdentifier; - function createAutoImportFilter(fromFile, program, host, moduleSpecifierResolutionHost) { - if (moduleSpecifierResolutionHost === void 0) { moduleSpecifierResolutionHost = ts.createModuleSpecifierResolutionHost(program, host); } - var packageJsons = ((host.getPackageJsonsVisibleToFile && host.getPackageJsonsVisibleToFile(fromFile.fileName)) || ts.getPackageJsonsVisibleToFile(fromFile.fileName, host)).filter(function (p) { return p.parseable; }); - var usesNodeCoreModules; - return { allowsImportingAmbientModule: allowsImportingAmbientModule, allowsImportingSourceFile: allowsImportingSourceFile, allowsImportingSpecifier: allowsImportingSpecifier, moduleSpecifierResolutionHost: moduleSpecifierResolutionHost }; - function moduleSpecifierIsCoveredByPackageJson(specifier) { - var packageName = getNodeModuleRootSpecifier(specifier); - for (var _i = 0, packageJsons_1 = packageJsons; _i < packageJsons_1.length; _i++) { - var packageJson = packageJsons_1[_i]; - if (packageJson.has(packageName) || packageJson.has(ts.getTypesPackageName(packageName))) { - return true; + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var codefix; + (function (codefix) { + var _a; + var fixName = "fixOverrideModifier"; + var fixAddOverrideId = "fixAddOverrideModifier"; + var fixRemoveOverrideId = "fixRemoveOverrideModifier"; + var errorCodes = [ + ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0.code, + ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class.code, + ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0.code, + ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0.code, + ts.Diagnostics.This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0.code + ]; + var errorCodeFixIdMap = (_a = {}, + _a[ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0.code] = [ + ts.Diagnostics.Add_override_modifier, fixAddOverrideId, ts.Diagnostics.Add_all_missing_override_modifiers, + ], + _a[ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class.code] = [ + ts.Diagnostics.Remove_override_modifier, fixRemoveOverrideId, ts.Diagnostics.Remove_all_unnecessary_override_modifiers + ], + _a[ts.Diagnostics.This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0.code] = [ + ts.Diagnostics.Add_override_modifier, fixAddOverrideId, ts.Diagnostics.Add_all_missing_override_modifiers, + ], + _a[ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0.code] = [ + ts.Diagnostics.Add_override_modifier, fixAddOverrideId, ts.Diagnostics.Remove_all_unnecessary_override_modifiers + ], + _a[ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0.code] = [ + ts.Diagnostics.Remove_override_modifier, fixRemoveOverrideId, ts.Diagnostics.Remove_all_unnecessary_override_modifiers + ], + _a); + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var errorCode = context.errorCode, span = context.span, sourceFile = context.sourceFile; + var info = errorCodeFixIdMap[errorCode]; + if (!info) + return ts.emptyArray; + var descriptions = info[0], fixId = info[1], fixAllDescriptions = info[2]; + if (ts.isSourceFileJS(sourceFile)) + return ts.emptyArray; + var changes = ts.textChanges.ChangeTracker.with(context, function (changes) { return dispatchChanges(changes, context, errorCode, span.start); }); + return [ + codefix.createCodeFixActionMaybeFixAll(fixName, changes, descriptions, fixId, fixAllDescriptions) + ]; + }, + fixIds: [fixName, fixAddOverrideId, fixRemoveOverrideId], + getAllCodeActions: function (context) { + return codefix.codeFixAll(context, errorCodes, function (changes, diag) { + var code = diag.code, start = diag.start, file = diag.file; + var info = errorCodeFixIdMap[code]; + if (!info || info[1] !== context.fixId || ts.isSourceFileJS(file)) { + return; } - } - return false; - } - function allowsImportingAmbientModule(moduleSymbol) { - if (!packageJsons.length) { - return true; - } - var declaringSourceFile = moduleSymbol.valueDeclaration.getSourceFile(); - var declaringNodeModuleName = getNodeModulesPackageNameFromFileName(declaringSourceFile.fileName); - if (typeof declaringNodeModuleName === "undefined") { - return true; - } - var declaredModuleSpecifier = ts.stripQuotes(moduleSymbol.getName()); - if (isAllowedCoreNodeModulesImport(declaredModuleSpecifier)) { - return true; - } - return moduleSpecifierIsCoveredByPackageJson(declaringNodeModuleName) - || moduleSpecifierIsCoveredByPackageJson(declaredModuleSpecifier); - } - function allowsImportingSourceFile(sourceFile) { - if (!packageJsons.length) { - return true; - } - var moduleSpecifier = getNodeModulesPackageNameFromFileName(sourceFile.fileName); - if (!moduleSpecifier) { - return true; - } - return moduleSpecifierIsCoveredByPackageJson(moduleSpecifier); + dispatchChanges(changes, context, code, start); + }); } - /** - * Use for a specific module specifier that has already been resolved. - * Use `allowsImportingAmbientModule` or `allowsImportingSourceFile` to resolve - * the best module specifier for a given module _and_ determine if it’s importable. - */ - function allowsImportingSpecifier(moduleSpecifier) { - if (!packageJsons.length || isAllowedCoreNodeModulesImport(moduleSpecifier)) { - return true; - } - if (ts.pathIsRelative(moduleSpecifier) || ts.isRootedDiskPath(moduleSpecifier)) { + }); + function dispatchChanges(changeTracker, context, errorCode, pos) { + switch (errorCode) { + case ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0.code: + case ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0.code: + case ts.Diagnostics.This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0.code: + return doAddOverrideModifierChange(changeTracker, context.sourceFile, pos); + case ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0.code: + case ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class.code: + return doRemoveOverrideModifierChange(changeTracker, context.sourceFile, pos); + default: + ts.Debug.fail("Unexpected error code: " + errorCode); + } + } + function doAddOverrideModifierChange(changeTracker, sourceFile, pos) { + var classElement = findContainerClassElementLike(sourceFile, pos); + var modifiers = classElement.modifiers || ts.emptyArray; + var staticModifier = ts.find(modifiers, ts.isStaticModifier); + var accessibilityModifier = ts.find(modifiers, function (m) { return ts.isAccessibilityModifier(m.kind); }); + var modifierPos = staticModifier ? staticModifier.end : + accessibilityModifier ? accessibilityModifier.end : + classElement.decorators ? ts.skipTrivia(sourceFile.text, classElement.decorators.end) : classElement.getStart(sourceFile); + var options = accessibilityModifier || staticModifier ? { prefix: " " } : { suffix: " " }; + changeTracker.insertModifierAt(sourceFile, modifierPos, 157 /* OverrideKeyword */, options); + } + function doRemoveOverrideModifierChange(changeTracker, sourceFile, pos) { + var classElement = findContainerClassElementLike(sourceFile, pos); + var overrideModifier = classElement.modifiers && ts.find(classElement.modifiers, function (modifier) { return modifier.kind === 157 /* OverrideKeyword */; }); + ts.Debug.assertIsDefined(overrideModifier); + changeTracker.deleteModifier(sourceFile, overrideModifier); + } + function isClassElementLikeHasJSDoc(node) { + switch (node.kind) { + case 168 /* Constructor */: + case 165 /* PropertyDeclaration */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return true; - } - return moduleSpecifierIsCoveredByPackageJson(moduleSpecifier); - } - function isAllowedCoreNodeModulesImport(moduleSpecifier) { - // If we’re in JavaScript, it can be difficult to tell whether the user wants to import - // from Node core modules or not. We can start by seeing if the user is actually using - // any node core modules, as opposed to simply having @types/node accidentally as a - // dependency of a dependency. - if (ts.isSourceFileJS(fromFile) && ts.JsTyping.nodeCoreModules.has(moduleSpecifier)) { - if (usesNodeCoreModules === undefined) { - usesNodeCoreModules = ts.consumesNodeCoreModules(fromFile); - } - if (usesNodeCoreModules) { - return true; - } - } - return false; - } - function getNodeModulesPackageNameFromFileName(importedFileName) { - if (!ts.stringContains(importedFileName, "node_modules")) { - return undefined; - } - var specifier = ts.moduleSpecifiers.getNodeModulesPackageName(host.getCompilationSettings(), fromFile.path, importedFileName, moduleSpecifierResolutionHost); - if (!specifier) { - return undefined; - } - // Paths here are not node_modules, so we don’t care about them; - // returning anything will trigger a lookup in package.json. - if (!ts.pathIsRelative(specifier) && !ts.isRootedDiskPath(specifier)) { - return getNodeModuleRootSpecifier(specifier); - } - } - function getNodeModuleRootSpecifier(fullSpecifier) { - var components = ts.getPathComponents(ts.getPackageNameFromTypesPackageName(fullSpecifier)).slice(1); - // Scoped packages - if (ts.startsWith(components[0], "@")) { - return components[0] + "/" + components[1]; - } - return components[0]; + case 162 /* Parameter */: + return ts.isParameterPropertyDeclaration(node, node.parent); + default: + return false; } } + function findContainerClassElementLike(sourceFile, pos) { + var token = ts.getTokenAtPosition(sourceFile, pos); + var classElement = ts.findAncestor(token, function (node) { + if (ts.isClassLike(node)) + return "quit"; + return isClassElementLikeHasJSDoc(node); + }); + ts.Debug.assert(classElement && isClassElementLikeHasJSDoc(classElement)); + return classElement; + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -138988,12 +144000,12 @@ var ts; }); function doChange(changes, sourceFile, pos, checker) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 107 /* ThisKeyword */); + ts.Debug.assert(token.kind === 108 /* ThisKeyword */); var fn = ts.getThisContainer(token, /*includeArrowFunctions*/ false); 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.assertDefined(ts.findChildOfKind(fn, 97 /* FunctionKeyword */, sourceFile)); + var fnKeyword = ts.Debug.assertDefined(ts.findChildOfKind(fn, 98 /* FunctionKeyword */, sourceFile)); var name = fn.name; var body = ts.Debug.assertDefined(fn.body); // Should be defined because the function contained a 'this' expression if (ts.isFunctionExpression(fn)) { @@ -139012,7 +144024,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(84 /* ConstKeyword */)); + changes.replaceNode(sourceFile, fnKeyword, ts.factory.createToken(85 /* ConstKeyword */)); changes.insertText(sourceFile, name.end, " = "); changes.insertText(sourceFile, body.pos, " =>"); return [ts.Diagnostics.Convert_function_declaration_0_to_arrow_function, name.text]; @@ -139043,7 +144055,7 @@ var ts; }); function getNamedTupleMember(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - return ts.findAncestor(token, function (t) { return t.kind === 192 /* NamedTupleMember */; }); + return ts.findAncestor(token, function (t) { return t.kind === 194 /* NamedTupleMember */; }); } function doChange(changes, sourceFile, namedTupleMember) { if (!namedTupleMember) { @@ -139052,11 +144064,11 @@ var ts; var unwrappedType = namedTupleMember.type; var sawOptional = false; var sawRest = false; - while (unwrappedType.kind === 180 /* OptionalType */ || unwrappedType.kind === 181 /* RestType */ || unwrappedType.kind === 186 /* ParenthesizedType */) { - if (unwrappedType.kind === 180 /* OptionalType */) { + while (unwrappedType.kind === 182 /* OptionalType */ || unwrappedType.kind === 183 /* RestType */ || unwrappedType.kind === 188 /* ParenthesizedType */) { + if (unwrappedType.kind === 182 /* OptionalType */) { sawOptional = true; } - else if (unwrappedType.kind === 181 /* RestType */) { + else if (unwrappedType.kind === 183 /* RestType */) { sawRest = true; } unwrappedType = unwrappedType.type; @@ -139120,7 +144132,7 @@ var ts; var checker = context.program.getTypeChecker(); var suggestedSymbol; if (ts.isPropertyAccessExpression(parent) && parent.name === node) { - ts.Debug.assert(ts.isIdentifierOrPrivateIdentifier(node), "Expected an identifier for spelling (property access)"); + ts.Debug.assert(ts.isMemberName(node), "Expected an identifier for spelling (property access)"); var containingType = checker.getTypeAtLocation(parent.expression); if (parent.flags & 32 /* OptionalChain */) { containingType = checker.getNonNullableType(containingType); @@ -139159,7 +144171,7 @@ var ts; var suggestion = ts.symbolName(suggestedSymbol); if (!ts.isIdentifierText(suggestion, target) && ts.isPropertyAccessExpression(node.parent)) { var valDecl = suggestedSymbol.valueDeclaration; - if (ts.isNamedDeclaration(valDecl) && ts.isPrivateIdentifier(valDecl.name)) { + if (valDecl && ts.isNamedDeclaration(valDecl) && ts.isPrivateIdentifier(valDecl.name)) { changes.replaceNode(sourceFile, node, ts.factory.createIdentifier(suggestion)); } else { @@ -139356,19 +144368,19 @@ var ts; } function getVariableLikeInitializer(declaration) { switch (declaration.kind) { - case 249 /* VariableDeclaration */: - case 160 /* Parameter */: - case 198 /* BindingElement */: - case 163 /* PropertyDeclaration */: - case 288 /* PropertyAssignment */: + case 251 /* VariableDeclaration */: + case 162 /* Parameter */: + case 200 /* BindingElement */: + case 165 /* PropertyDeclaration */: + case 290 /* PropertyAssignment */: return declaration.initializer; - case 280 /* JsxAttribute */: + case 282 /* JsxAttribute */: return declaration.initializer && (ts.isJsxExpression(declaration.initializer) ? declaration.initializer.expression : undefined); - case 289 /* ShorthandPropertyAssignment */: - case 162 /* PropertySignature */: - case 291 /* EnumMember */: - case 333 /* JSDocPropertyTag */: - case 326 /* JSDocParameterTag */: + case 291 /* ShorthandPropertyAssignment */: + case 164 /* PropertySignature */: + case 293 /* EnumMember */: + case 341 /* JSDocPropertyTag */: + case 334 /* JSDocParameterTag */: return undefined; } } @@ -139469,7 +144481,7 @@ var ts; }); typeDeclToMembers.forEach(function (infos, classDeclaration) { var supers = codefix.getAllSupers(classDeclaration, checker); - var _loop_13 = function (info) { + var _loop_14 = function (info) { // If some superclass added this property, don't add it again. if (supers.some(function (superClassOrInterface) { var superInfos = typeDeclToMembers.get(superClassOrInterface); @@ -139494,9 +144506,9 @@ var ts; } } }; - for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) { - var info = infos_1[_i]; - _loop_13(info); + for (var _i = 0, infos_2 = infos; _i < infos_2.length; _i++) { + var info = infos_2[_i]; + _loop_14(info); } }); })); @@ -139586,7 +144598,7 @@ var ts; function addMissingMemberInJs(changeTracker, declSourceFile, classDeclaration, token, makeStatic) { var tokenName = token.text; if (makeStatic) { - if (classDeclaration.kind === 221 /* ClassExpression */) { + if (classDeclaration.kind === 223 /* ClassExpression */) { return; } var className = classDeclaration.name.getText(); @@ -139638,17 +144650,17 @@ var ts; } function getTypeNode(checker, classDeclaration, token) { var typeNode; - if (token.parent.parent.kind === 216 /* BinaryExpression */) { + if (token.parent.parent.kind === 218 /* 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, classDeclaration, /*flags*/ undefined); + typeNode = checker.typeToTypeNode(widenedType, classDeclaration, 1 /* NoTruncation */); } else { var contextualType = checker.getContextualType(token.parent); - typeNode = contextualType ? checker.typeToTypeNode(contextualType, /*enclosingDeclaration*/ undefined, /*flags*/ undefined) : undefined; + typeNode = contextualType ? checker.typeToTypeNode(contextualType, /*enclosingDeclaration*/ undefined, 1 /* NoTruncation */) : undefined; } - return typeNode || ts.factory.createKeywordTypeNode(128 /* AnyKeyword */); + return typeNode || ts.factory.createKeywordTypeNode(129 /* AnyKeyword */); } function addPropertyDeclaration(changeTracker, declSourceFile, classDeclaration, tokenName, typeNode, modifierFlags) { var property = ts.factory.createPropertyDeclaration( @@ -139677,7 +144689,7 @@ var ts; } function createAddIndexSignatureAction(context, declSourceFile, classDeclaration, tokenName, typeNode) { // Index signatures cannot have the static modifier. - var stringTypeNode = ts.factory.createKeywordTypeNode(147 /* StringKeyword */); + var stringTypeNode = ts.factory.createKeywordTypeNode(148 /* StringKeyword */); var indexingParameter = ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -139710,7 +144722,7 @@ var ts; } function addMethodDeclaration(context, changes, callExpression, name, modifierFlags, parentDeclaration, sourceFile) { var importAdder = codefix.createImportAdder(sourceFile, context.program, context.preferences, context.host); - var methodDeclaration = codefix.createSignatureDeclarationFromCallExpression(165 /* MethodDeclaration */, context, importAdder, callExpression, name, modifierFlags, parentDeclaration); + var methodDeclaration = codefix.createSignatureDeclarationFromCallExpression(167 /* MethodDeclaration */, context, importAdder, callExpression, name, modifierFlags, parentDeclaration); var containingMethodDeclaration = ts.findAncestor(callExpression, function (n) { return ts.isMethodDeclaration(n) || ts.isConstructorDeclaration(n); }); if (containingMethodDeclaration && containingMethodDeclaration.parent === parentDeclaration) { changes.insertNodeAfter(sourceFile, containingMethodDeclaration, methodDeclaration); @@ -139739,7 +144751,7 @@ var ts; } function addFunctionDeclaration(changes, context, info) { var importAdder = codefix.createImportAdder(context.sourceFile, context.program, context.preferences, context.host); - var functionDeclaration = codefix.createSignatureDeclarationFromCallExpression(251 /* FunctionDeclaration */, context, importAdder, info.call, info.token, info.modifierFlags, info.parentDeclaration); + var functionDeclaration = codefix.createSignatureDeclarationFromCallExpression(253 /* FunctionDeclaration */, context, importAdder, info.call, ts.idText(info.token), info.modifierFlags, info.parentDeclaration); changes.insertNodeAtEndOfScope(info.sourceFile, info.parentDeclaration, functionDeclaration); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -139826,7 +144838,10 @@ var ts; return { type: "install package", file: fileName, packageName: packageName }; } function tryGetImportedPackageName(sourceFile, pos) { - var moduleName = ts.cast(ts.getTokenAtPosition(sourceFile, pos), ts.isStringLiteral).text; + var moduleSpecifierText = ts.tryCast(ts.getTokenAtPosition(sourceFile, pos), ts.isStringLiteral); + if (!moduleSpecifierText) + return undefined; + var moduleName = moduleSpecifierText.text; var packageName = ts.parsePackageName(moduleName).packageName; return ts.isExternalModuleNameRelative(packageName) ? undefined : packageName; } @@ -139932,7 +144947,7 @@ var ts; } function getNodes(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - if (token.kind !== 107 /* ThisKeyword */) + if (token.kind !== 108 /* ThisKeyword */) return undefined; var constructor = ts.getContainingFunction(token); var superCall = findSuperCall(constructor.body); @@ -140056,7 +145071,10 @@ var ts; var codefix; (function (codefix) { codefix.registerCodeFix({ - errorCodes: [ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher.code], + errorCodes: [ + ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher.code, + ts.Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher.code, + ], getCodeActions: function (context) { var compilerOptions = context.program.getCompilerOptions(); var configFile = compilerOptions.configFile; @@ -140152,14 +145170,14 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, pos); var heritageClauses = ts.getContainingClass(token).heritageClauses; var extendsToken = heritageClauses[0].getFirstToken(); - return extendsToken.kind === 93 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; + return extendsToken.kind === 94 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; } function doChanges(changes, sourceFile, extendsToken, heritageClauses) { - changes.replaceNode(sourceFile, extendsToken, ts.factory.createToken(116 /* ImplementsKeyword */)); + changes.replaceNode(sourceFile, extendsToken, ts.factory.createToken(117 /* ImplementsKeyword */)); // If there is already an implements clause, replace the implements keyword with a comma. if (heritageClauses.length === 2 && - heritageClauses[0].token === 93 /* ExtendsKeyword */ && - heritageClauses[1].token === 116 /* ImplementsKeyword */) { + heritageClauses[0].token === 94 /* ExtendsKeyword */ && + heritageClauses[1].token === 117 /* ImplementsKeyword */) { var implementsToken = heritageClauses[1].getFirstToken(); var implementsFullStart = implementsToken.getFullStart(); changes.replaceRange(sourceFile, { pos: implementsFullStart, end: implementsFullStart }, ts.factory.createToken(27 /* CommaToken */)); @@ -140335,7 +145353,7 @@ var ts; ]; } var result = []; - if (token.kind === 135 /* InferKeyword */) { + if (token.kind === 136 /* 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)); @@ -140377,7 +145395,7 @@ var ts; break; } case fixIdDelete: { - if (token.kind === 135 /* InferKeyword */ || isImport(token)) { + if (token.kind === 136 /* InferKeyword */ || isImport(token)) { break; // Can't delete } else if (ts.isJSDocTemplateTag(token)) { @@ -140406,7 +145424,7 @@ var ts; break; } case fixIdInfer: - if (token.kind === 135 /* InferKeyword */) { + if (token.kind === 136 /* InferKeyword */) { changeInferToUnknown(changes, sourceFile, token); } break; @@ -140417,7 +145435,7 @@ var ts; }, }); function changeInferToUnknown(changes, sourceFile, token) { - changes.replaceNode(sourceFile, token.parent, ts.factory.createKeywordTypeNode(152 /* UnknownKeyword */)); + changes.replaceNode(sourceFile, token.parent, ts.factory.createKeywordTypeNode(153 /* UnknownKeyword */)); } function createDeleteFix(changes, diag) { return codefix.createCodeFixAction(fixName, changes, diag, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations); @@ -140426,18 +145444,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 === 99 /* ImportKeyword */ - || token.kind === 78 /* Identifier */ && (token.parent.kind === 265 /* ImportSpecifier */ || token.parent.kind === 262 /* ImportClause */); + return token.kind === 100 /* ImportKeyword */ + || token.kind === 79 /* Identifier */ && (token.parent.kind === 267 /* ImportSpecifier */ || token.parent.kind === 264 /* ImportClause */); } /** Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing. */ function tryGetFullImport(token) { - return token.kind === 99 /* ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; + return token.kind === 100 /* 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 === 232 /* VariableStatement */ ? node.parent : node); + changes.delete(sourceFile, node.parent.kind === 234 /* VariableStatement */ ? node.parent : node); } function deleteDestructuringElements(changes, sourceFile, node) { ts.forEach(node.elements, function (n) { return changes.delete(sourceFile, n); }); @@ -140446,7 +145464,7 @@ 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 === 135 /* InferKeyword */) { + if (token.kind === 136 /* InferKeyword */) { token = ts.cast(token.parent, ts.isInferTypeNode).typeParameter.name; } if (ts.isIdentifier(token) && canPrefix(token)) { @@ -140462,14 +145480,14 @@ var ts; } function canPrefix(token) { switch (token.parent.kind) { - case 160 /* Parameter */: - case 159 /* TypeParameter */: + case 162 /* Parameter */: + case 161 /* TypeParameter */: return true; - case 249 /* VariableDeclaration */: { + case 251 /* VariableDeclaration */: { var varDecl = token.parent; switch (varDecl.parent.parent.kind) { - case 239 /* ForOfStatement */: - case 238 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 240 /* ForInStatement */: return true; } } @@ -140493,8 +145511,10 @@ var ts; if (ts.isParameter(parent)) { tryDeleteParameter(changes, sourceFile, parent, checker, sourceFiles, program, cancellationToken, isFixAll); } - else if (!isFixAll || !(ts.isIdentifier(token) && ts.FindAllReferences.Core.isSymbolReferencedInFile(token, checker, sourceFile))) { - changes.delete(sourceFile, ts.isImportClause(parent) ? token : ts.isComputedPropertyName(parent) ? parent.parent : parent); + else if (!(isFixAll && ts.isIdentifier(token) && ts.FindAllReferences.Core.isSymbolReferencedInFile(token, checker, sourceFile))) { + var node = ts.isImportClause(parent) ? token : ts.isComputedPropertyName(parent) ? parent.parent : parent; + ts.Debug.assert(node !== sourceFile, "should not delete whole source file"); + changes.delete(sourceFile, node); } } function tryDeleteParameter(changes, sourceFile, parameter, checker, sourceFiles, program, cancellationToken, isFixAll) { @@ -140517,8 +145537,8 @@ var ts; function mayDeleteParameter(checker, sourceFile, parameter, sourceFiles, program, cancellationToken, isFixAll) { var parent = parameter.parent; switch (parent.kind) { - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: + case 167 /* MethodDeclaration */: + case 168 /* 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); @@ -140548,17 +145568,17 @@ var ts; } } return true; - case 251 /* FunctionDeclaration */: { + case 253 /* FunctionDeclaration */: { if (parent.name && isCallbackLike(checker, sourceFile, parent.name)) { return isLastParameter(parent, parameter, isFixAll); } return true; } - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 210 /* FunctionExpression */: + case 211 /* 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 168 /* SetAccessor */: + case 170 /* SetAccessor */: // Setter must have a parameter return false; default: @@ -140616,7 +145636,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 234 /* IfStatement */: + case 236 /* IfStatement */: if (container.elseStatement) { if (ts.isBlock(statement.parent)) { break; @@ -140627,8 +145647,8 @@ var ts; return; } // falls through - case 236 /* WhileStatement */: - case 237 /* ForStatement */: + case 238 /* WhileStatement */: + case 239 /* ForStatement */: changes.delete(sourceFile, container); return; } @@ -140701,7 +145721,7 @@ 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 === 305 /* JSDocNullableType */) { + if (typeNode.kind === 308 /* 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)); @@ -140721,7 +145741,7 @@ var ts; if (!info) return; var typeNode = info.typeNode, type = info.type; - var fixedType = typeNode.kind === 305 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; + var fixedType = typeNode.kind === 308 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; doChange(changes, sourceFile, typeNode, fixedType, checker); }); } @@ -140738,22 +145758,22 @@ var ts; // NOTE: Some locations are not handled yet: // MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments switch (node.kind) { - case 224 /* AsExpression */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 251 /* FunctionDeclaration */: - case 167 /* GetAccessor */: - case 171 /* IndexSignature */: - case 190 /* MappedType */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 160 /* Parameter */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 168 /* SetAccessor */: - case 254 /* TypeAliasDeclaration */: - case 206 /* TypeAssertionExpression */: - case 249 /* VariableDeclaration */: + case 226 /* AsExpression */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 253 /* FunctionDeclaration */: + case 169 /* GetAccessor */: + case 173 /* IndexSignature */: + case 192 /* MappedType */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 162 /* Parameter */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 170 /* SetAccessor */: + case 256 /* TypeAliasDeclaration */: + case 208 /* TypeAssertionExpression */: + case 251 /* VariableDeclaration */: return true; default: return false; @@ -140768,7 +145788,7 @@ var ts; (function (codefix) { var fixId = "fixMissingCallParentheses"; var errorCodes = [ - ts.Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead.code, + ts.Diagnostics.This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_instead.code, ]; codefix.registerCodeFix({ errorCodes: errorCodes, @@ -140814,7 +145834,7 @@ var ts; var fixId = "fixAwaitInSyncFunction"; var errorCodes = [ ts.Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code, - ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator.code, + ts.Diagnostics.for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code, ]; codefix.registerCodeFix({ errorCodes: errorCodes, @@ -140855,14 +145875,14 @@ var ts; } var insertBefore; switch (containingFunction.kind) { - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: insertBefore = containingFunction.name; break; - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - insertBefore = ts.findChildOfKind(containingFunction, 97 /* FunctionKeyword */, sourceFile); + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + insertBefore = ts.findChildOfKind(containingFunction, 98 /* FunctionKeyword */, sourceFile); break; - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: insertBefore = ts.findChildOfKind(containingFunction, 20 /* OpenParenToken */, sourceFile) || ts.first(containingFunction.parameters); break; default: @@ -140877,11 +145897,11 @@ var ts; var insertBefore = _a.insertBefore, returnType = _a.returnType; if (returnType) { var entityName = ts.getEntityNameFromTypeNode(returnType); - if (!entityName || entityName.kind !== 78 /* Identifier */ || entityName.text !== "Promise") { + if (!entityName || entityName.kind !== 79 /* Identifier */ || entityName.text !== "Promise") { changes.replaceNode(sourceFile, returnType, ts.factory.createTypeReferenceNode("Promise", ts.factory.createNodeArray([returnType]))); } } - changes.insertModifierBefore(sourceFile, 129 /* AsyncKeyword */, insertBefore); + changes.insertModifierBefore(sourceFile, 130 /* AsyncKeyword */, insertBefore); } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -141041,7 +146061,7 @@ var ts; return errorCode; } function doChange(changes, sourceFile, token, errorCode, program, cancellationToken, markSeen, host, preferences) { - if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 78 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 107 /* ThisKeyword */) { + if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 79 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 108 /* ThisKeyword */) { return undefined; } var parent = token.parent; @@ -141061,7 +146081,7 @@ var ts; var typeNode = ts.getTypeNodeIfAccessible(type, parent, program, host); if (typeNode) { // Note that the codefix will never fire with an existing `@type` tag, so there is no need to merge tags - var typeTag = ts.factory.createJSDocTypeTag(/*tagName*/ undefined, ts.factory.createJSDocTypeExpression(typeNode), /*comment*/ ""); + var typeTag = ts.factory.createJSDocTypeTag(/*tagName*/ undefined, ts.factory.createJSDocTypeExpression(typeNode), /*comment*/ undefined); addJSDocTags(changes, sourceFile, ts.cast(parent.parent.parent, ts.isExpressionStatement), [typeTag]); } importAdder.writeFixes(changes); @@ -141195,13 +146215,13 @@ 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 !== 162 /* PropertySignature */) { + if (ts.isInJSFile(sourceFile) && declaration.kind !== 164 /* PropertySignature */) { var parent = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : declaration; if (!parent) { return; } var typeExpression = ts.factory.createJSDocTypeExpression(typeNode); - var typeTag = ts.isGetAccessorDeclaration(declaration) ? ts.factory.createJSDocReturnTag(/*tagName*/ undefined, typeExpression, "") : ts.factory.createJSDocTypeTag(/*tagName*/ undefined, typeExpression, ""); + var typeTag = ts.isGetAccessorDeclaration(declaration) ? ts.factory.createJSDocReturnTag(/*tagName*/ undefined, typeExpression, /*comment*/ undefined) : ts.factory.createJSDocTypeTag(/*tagName*/ undefined, typeExpression, /*comment*/ undefined); addJSDocTags(changes, sourceFile, parent, [typeTag]); } else if (!tryReplaceImportTypeNodeWithAutoImport(typeNode, declaration, sourceFile, changes, importAdder, ts.getEmitScriptTarget(program.getCompilerOptions()))) { @@ -141256,13 +146276,13 @@ var ts; else { var paramTags = ts.map(inferences, function (_a) { var name = _a.name, typeNode = _a.typeNode, isOptional = _a.isOptional; - return ts.factory.createJSDocParameterTag(/*tagName*/ undefined, name, /*isBracketed*/ !!isOptional, ts.factory.createJSDocTypeExpression(typeNode), /* isNameFirst */ false, ""); + return ts.factory.createJSDocParameterTag(/*tagName*/ undefined, name, /*isBracketed*/ !!isOptional, ts.factory.createJSDocTypeExpression(typeNode), /* isNameFirst */ false, /*comment*/ undefined); }); addJSDocTags(changes, sourceFile, signature, paramTags); } } function addJSDocTags(changes, sourceFile, parent, newTags) { - var comments = ts.mapDefined(parent.jsDoc, function (j) { return j.comment; }); + var comments = ts.flatMap(parent.jsDoc, function (j) { return typeof j.comment === "string" ? ts.factory.createJSDocText(j.comment) : j.comment; }); var oldTags = ts.flatMapToMutable(parent.jsDoc, function (j) { return j.tags; }); var unmergedNewTags = newTags.filter(function (newTag) { return !oldTags || !oldTags.some(function (tag, i) { var merged = tryMergeJsdocTags(tag, newTag); @@ -141270,15 +146290,15 @@ var ts; oldTags[i] = merged; return !!merged; }); }); - var tag = ts.factory.createJSDocComment(comments.join("\n"), ts.factory.createNodeArray(__spreadArray(__spreadArray([], (oldTags || ts.emptyArray)), unmergedNewTags))); - var jsDocNode = parent.kind === 209 /* ArrowFunction */ ? getJsDocNodeForArrowFunction(parent) : parent; + var tag = ts.factory.createJSDocComment(ts.factory.createNodeArray(ts.intersperse(comments, ts.factory.createJSDocText("\n"))), ts.factory.createNodeArray(__spreadArray(__spreadArray([], (oldTags || ts.emptyArray)), unmergedNewTags))); + var jsDocNode = parent.kind === 211 /* ArrowFunction */ ? getJsDocNodeForArrowFunction(parent) : parent; jsDocNode.jsDoc = parent.jsDoc; jsDocNode.jsDocCache = parent.jsDocCache; changes.insertJsdocCommentBefore(sourceFile, jsDocNode, tag); } codefix.addJSDocTags = addJSDocTags; function getJsDocNodeForArrowFunction(signature) { - if (signature.parent.kind === 163 /* PropertyDeclaration */) { + if (signature.parent.kind === 165 /* PropertyDeclaration */) { return signature.parent; } return signature.parent.parent; @@ -141288,14 +146308,14 @@ var ts; return undefined; } switch (oldTag.kind) { - case 326 /* JSDocParameterTag */: { + case 334 /* 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 327 /* JSDocReturnTag */: + case 335 /* JSDocReturnTag */: return ts.factory.createJSDocReturnTag(/*tagName*/ undefined, newTag.typeExpression, oldTag.comment); } } @@ -141320,19 +146340,19 @@ var ts; function getFunctionReferences(containingFunction, sourceFile, program, cancellationToken) { var searchToken; switch (containingFunction.kind) { - case 166 /* Constructor */: - searchToken = ts.findChildOfKind(containingFunction, 132 /* ConstructorKeyword */, sourceFile); + case 168 /* Constructor */: + searchToken = ts.findChildOfKind(containingFunction, 133 /* ConstructorKeyword */, sourceFile); break; - case 209 /* ArrowFunction */: - case 208 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 210 /* FunctionExpression */: var parent = containingFunction.parent; searchToken = (ts.isVariableDeclaration(parent) || ts.isPropertyDeclaration(parent)) && ts.isIdentifier(parent.name) ? parent.name : containingFunction.name; break; - case 251 /* FunctionDeclaration */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 253 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: searchToken = containingFunction.name; break; } @@ -141474,24 +146494,24 @@ var ts; node = node.parent; } switch (node.parent.kind) { - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: inferTypeFromExpressionStatement(node, usage); break; - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: usage.isNumber = true; break; - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: inferTypeFromPrefixUnaryExpression(node.parent, usage); break; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: inferTypeFromBinaryExpression(node, node.parent, usage); break; - case 284 /* CaseClause */: - case 285 /* DefaultClause */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: inferTypeFromSwitchStatementLabel(node.parent, usage); break; - case 203 /* CallExpression */: - case 204 /* NewExpression */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: if (node.parent.expression === node) { inferTypeFromCallExpression(node.parent, usage); } @@ -141499,20 +146519,20 @@ var ts; inferTypeFromContextualType(node, usage); } break; - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: inferTypeFromPropertyAccessExpression(node.parent, usage); break; - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: inferTypeFromPropertyElementExpression(node.parent, node, usage); break; - case 288 /* PropertyAssignment */: - case 289 /* ShorthandPropertyAssignment */: + case 290 /* PropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: inferTypeFromPropertyAssignment(node.parent, usage); break; - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: inferTypeFromPropertyDeclaration(node.parent, usage); break; - case 249 /* VariableDeclaration */: { + case 251 /* 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. @@ -141570,17 +146590,17 @@ var ts; case 52 /* CaretToken */: // CompoundAssignmentOperator // falls through - case 64 /* MinusEqualsToken */: - case 66 /* AsteriskAsteriskEqualsToken */: - case 65 /* AsteriskEqualsToken */: - case 67 /* SlashEqualsToken */: - case 68 /* PercentEqualsToken */: - case 72 /* AmpersandEqualsToken */: - case 73 /* BarEqualsToken */: - case 77 /* CaretEqualsToken */: - case 69 /* LessThanLessThanEqualsToken */: - case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 70 /* GreaterThanGreaterThanEqualsToken */: + 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 */: // AdditiveOperator // falls through case 40 /* MinusToken */: @@ -141598,7 +146618,7 @@ var ts; usage.isNumber = true; } break; - case 63 /* PlusEqualsToken */: + case 64 /* PlusEqualsToken */: case 39 /* PlusToken */: var otherOperandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); if (otherOperandType.flags & 1056 /* EnumLike */) { @@ -141618,14 +146638,14 @@ var ts; } break; // AssignmentOperators - case 62 /* EqualsToken */: + case 63 /* EqualsToken */: case 34 /* EqualsEqualsToken */: case 36 /* EqualsEqualsEqualsToken */: case 37 /* ExclamationEqualsEqualsToken */: case 35 /* ExclamationEqualsToken */: addCandidateType(usage, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); break; - case 100 /* InKeyword */: + case 101 /* InKeyword */: if (node === parent.left) { usage.isString = true; } @@ -141634,7 +146654,7 @@ var ts; case 56 /* BarBarToken */: case 60 /* QuestionQuestionToken */: if (node === parent.left && - (node.parent.parent.kind === 249 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { + (node.parent.parent.kind === 251 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { // var x = x || {}; // TODO: use getFalsyflagsOfType addCandidateType(usage, checker.getTypeAtLocation(parent.right)); @@ -141642,7 +146662,7 @@ var ts; break; case 55 /* AmpersandAmpersandToken */: case 27 /* CommaToken */: - case 101 /* InstanceOfKeyword */: + case 102 /* InstanceOfKeyword */: // nothing to infer here break; } @@ -141662,7 +146682,7 @@ var ts; } } calculateUsageOfNode(parent, call.return_); - if (parent.kind === 203 /* CallExpression */) { + if (parent.kind === 205 /* CallExpression */) { (usage.calls || (usage.calls = [])).push(call); } else { @@ -141765,7 +146785,7 @@ var ts; var anon = anons_1[_i]; for (var _a = 0, _b = checker.getPropertiesOfType(anon); _a < _b.length; _a++) { var p = _b[_a]; - props.add(p.name, checker.getTypeOfSymbolAtLocation(p, p.valueDeclaration)); + 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 */)); @@ -141906,12 +146926,13 @@ var ts; if (!usageParam) { break; } - var genericParamType = checker.getTypeOfSymbolAtLocation(genericParam, genericParam.valueDeclaration); + var genericParamType = genericParam.valueDeclaration ? checker.getTypeOfSymbolAtLocation(genericParam, genericParam.valueDeclaration) : checker.getAnyType(); var elementType = isRest && checker.getElementTypeOfArrayType(genericParamType); if (elementType) { genericParamType = elementType; } - var targetType = usageParam.type || checker.getTypeOfSymbolAtLocation(usageParam, usageParam.valueDeclaration); + var targetType = usageParam.type + || (usageParam.valueDeclaration ? checker.getTypeOfSymbolAtLocation(usageParam, usageParam.valueDeclaration) : checker.getAnyType()); types.push.apply(types, inferTypeParameters(genericParamType, targetType, typeParameter)); } var genericReturn = checker.getReturnTypeOfSignature(genericSig); @@ -141925,7 +146946,7 @@ var ts; function getSignatureFromCalls(calls) { var parameters = []; var length = Math.max.apply(Math, calls.map(function (c) { return c.argumentTypes.length; })); - var _loop_14 = function (i) { + var _loop_15 = function (i) { var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i)); symbol.type = combineTypes(calls.map(function (call) { return call.argumentTypes[i] || checker.getUndefinedType(); })); if (calls.some(function (call) { return call.argumentTypes[i] === undefined; })) { @@ -141934,10 +146955,9 @@ var ts; parameters.push(symbol); }; for (var i = 0; i < length; i++) { - _loop_14(i); + _loop_15(i); } var returnType = combineFromUsage(combineUsages(calls.map(function (call) { return call.return_; }))); - // TODO: GH#18217 return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, 0 /* None */); } function addCandidateType(usage, type) { @@ -142081,7 +147101,7 @@ var ts; codefix.createMissingMemberNodes = createMissingMemberNodes; function getNoopSymbolTrackerWithResolver(context) { return { - trackSymbol: ts.noop, + trackSymbol: function () { return false; }, moduleResolverHost: ts.getModuleSpecifierResolverHost(context.program, context.host), }; } @@ -142105,8 +147125,8 @@ var ts; var ambient = !!(enclosingDeclaration.flags & 8388608 /* Ambient */); var quotePreference = ts.getQuotePreference(sourceFile, preferences); switch (declaration.kind) { - case 162 /* PropertySignature */: - case 163 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 165 /* PropertyDeclaration */: var flags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : undefined; var typeNode = checker.typeToTypeNode(type, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context)); if (importAdder) { @@ -142120,8 +147140,8 @@ var ts; /*decorators*/ undefined, modifiers, name, optional ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeNode, /*initializer*/ undefined)); break; - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: { + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: { var typeNode_1 = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); var allAccessors = ts.getAllAccessorDeclarations(declarations, declaration); var orderedAccessors = allAccessors.secondAccessor @@ -142150,8 +147170,8 @@ var ts; } break; } - case 164 /* MethodSignature */: - case 165 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 167 /* 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 @@ -142181,7 +147201,7 @@ var ts; } else { ts.Debug.assert(declarations.length === signatures.length, "Declarations and signatures should match count"); - addClassElement(createMethodImplementingSignatures(signatures, name, optional, modifiers, quotePreference)); + addClassElement(createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional, modifiers, quotePreference)); } } break; @@ -142197,7 +147217,7 @@ var ts; var checker = program.getTypeChecker(); var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions()); var flags = 1 /* NoTruncation */ | 1073741824 /* NoUndefinedOptionalParameterType */ | 256 /* SuppressAnyReturnType */ | (quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : 0); - var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, 165 /* MethodDeclaration */, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context)); + var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, 167 /* MethodDeclaration */, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context)); if (!signatureDeclaration) { return undefined; } @@ -142281,7 +147301,7 @@ var ts; var type = isJs || contextualType === undefined ? undefined : checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker); - if (kind === 165 /* MethodDeclaration */) { + if (kind === 167 /* MethodDeclaration */) { return ts.factory.createMethodDeclaration( /*decorators*/ undefined, modifiers, asteriskToken, name, /*questionToken*/ undefined, typeParameters, parameters, type, ts.isInterfaceDeclaration(contextNode) ? undefined : createStubbedMethodBody(quotePreference)); @@ -142311,13 +147331,13 @@ var ts; /*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(128 /* AnyKeyword */), + /*type*/ inJs ? undefined : types && types[i] || ts.factory.createKeywordTypeNode(129 /* AnyKeyword */), /*initializer*/ undefined); parameters.push(newParameter); } return parameters; } - function createMethodImplementingSignatures(signatures, name, optional, modifiers, quotePreference) { + function createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional, modifiers, quotePreference) { /** This is *a* signature with the maximal number of arguments, * such that if there is a "maximal" signature without rest arguments, * this is one of them. @@ -142339,7 +147359,7 @@ var ts; var maxArgsParameterSymbolNames = maxArgsSignature.parameters.map(function (symbol) { return symbol.name; }); var parameters = createDummyParameters(maxNonRestArgs, maxArgsParameterSymbolNames, /* types */ undefined, minArgumentCount, /*inJs*/ false); if (someSigHasRestParameter) { - var anyArrayType = ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(128 /* AnyKeyword */)); + var anyArrayType = ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(129 /* AnyKeyword */)); var restParameter = ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createToken(25 /* DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest", @@ -142348,8 +147368,13 @@ var ts; parameters.push(restParameter); } return createStubbedMethod(modifiers, name, optional, - /*typeParameters*/ undefined, parameters, - /*returnType*/ undefined, quotePreference); + /*typeParameters*/ undefined, parameters, getReturnTypeFromSignatures(signatures, checker, context, enclosingDeclaration), quotePreference); + } + function getReturnTypeFromSignatures(signatures, checker, context, enclosingDeclaration) { + if (ts.length(signatures)) { + var type = checker.getUnionType(ts.map(signatures, checker.getReturnTypeOfSignature)); + return checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); + } } function createStubbedMethod(modifiers, name, optional, typeParameters, parameters, returnType, quotePreference) { return ts.factory.createMethodDeclaration( @@ -142369,10 +147394,10 @@ var ts; codefix.createStubbedBody = createStubbedBody; function createVisibilityModifier(flags) { if (flags & 4 /* Public */) { - return ts.factory.createToken(122 /* PublicKeyword */); + return ts.factory.createToken(123 /* PublicKeyword */); } else if (flags & 16 /* Protected */) { - return ts.factory.createToken(121 /* ProtectedKeyword */); + return ts.factory.createToken(122 /* ProtectedKeyword */); } return undefined; } @@ -142445,7 +147470,7 @@ var ts; } codefix.tryGetAutoImportableReferenceFromTypeNode = tryGetAutoImportableReferenceFromTypeNode; function replaceFirstIdentifierOfEntityName(name, newIdentifier) { - if (name.kind === 78 /* Identifier */) { + if (name.kind === 79 /* Identifier */) { return newIdentifier; } return ts.factory.createQualifiedName(replaceFirstIdentifierOfEntityName(name.left, newIdentifier), name.right); @@ -142476,13 +147501,13 @@ var ts; if (ts.isClassLike(container)) { var modifierFlags = ts.getEffectiveModifierFlags(declaration); if (ts.isSourceFileJS(file)) { - var modifiers = createModifiers(modifierFlags); + var modifiers = ts.createModifiers(modifierFlags); accessorModifiers = modifiers; fieldModifiers = modifiers; } else { - accessorModifiers = createModifiers(prepareModifierFlagsForAccessor(modifierFlags)); - fieldModifiers = createModifiers(prepareModifierFlagsForField(modifierFlags)); + accessorModifiers = ts.createModifiers(prepareModifierFlagsForAccessor(modifierFlags)); + fieldModifiers = ts.createModifiers(prepareModifierFlagsForField(modifierFlags)); } } updateFieldDeclaration(changeTracker, file, declaration, type, fieldName, fieldModifiers); @@ -142517,9 +147542,6 @@ var ts; var leftHead = isStatic ? container.name : ts.factory.createThis(); // TODO: GH#18217 return ts.isIdentifier(fieldName) ? ts.factory.createPropertyAccessExpression(leftHead, fieldName) : ts.factory.createElementAccessExpression(leftHead, ts.factory.createStringLiteralFromNode(fieldName)); } - function createModifiers(modifierFlags) { - return modifierFlags ? ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(modifierFlags)) : undefined; - } function prepareModifierFlagsForAccessor(modifierFlags) { modifierFlags &= ~64 /* Readonly */; // avoid Readonly modifier because it will convert to get accessor modifierFlags &= ~8 /* Private */; @@ -142564,7 +147586,7 @@ var ts; isStatic: ts.hasStaticModifier(declaration), isReadonly: ts.hasEffectiveReadonlyModifier(declaration), type: getDeclarationType(declaration, program), - container: declaration.kind === 160 /* Parameter */ ? declaration.parent.parent : declaration.parent, + container: declaration.kind === 162 /* Parameter */ ? declaration.parent.parent : declaration.parent, originalName: declaration.name.text, declaration: declaration, fieldName: fieldName, @@ -142620,13 +147642,13 @@ var ts; return; constructor.body.forEachChild(function recur(node) { if (ts.isElementAccessExpression(node) && - node.expression.kind === 107 /* ThisKeyword */ && + node.expression.kind === 108 /* 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 === 107 /* ThisKeyword */ && node.name.text === originalName && ts.isWriteAccess(node)) { + if (ts.isPropertyAccessExpression(node) && node.expression.kind === 108 /* ThisKeyword */ && node.name.text === originalName && ts.isWriteAccess(node)) { changeTracker.replaceNode(file, node.name, ts.factory.createIdentifier(fieldName)); } if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) { @@ -142641,7 +147663,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), [ts.factory.createKeywordTypeNode(150 /* UndefinedKeyword */)])); + return ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], types), [ts.factory.createKeywordTypeNode(151 /* UndefinedKeyword */)])); } } return typeNode; @@ -142654,7 +147676,7 @@ var ts; if (!superSymbol) break; var symbol = superSymbol.flags & 2097152 /* Alias */ ? checker.getAliasedSymbol(superSymbol) : superSymbol; - var superDecl = ts.find(symbol.declarations, ts.isClassLike); + var superDecl = symbol.declarations && ts.find(symbol.declarations, ts.isClassLike); if (!superDecl) break; res.push(superDecl); @@ -142700,7 +147722,7 @@ var ts; }); function getActionsForUsageOfInvalidImport(context) { var sourceFile = context.sourceFile; - var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 203 /* CallExpression */ : 204 /* NewExpression */; + var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 205 /* CallExpression */ : 206 /* NewExpression */; var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start), function (a) { return a.kind === targetKind; }); if (!node) { return []; @@ -142819,7 +147841,7 @@ var ts; return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_undefined_type_to_property_0, propertyDeclaration.name.getText()], fixIdAddUndefinedType, ts.Diagnostics.Add_undefined_type_to_all_uninitialized_properties); } function addUndefinedType(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) { - var undefinedTypeNode = ts.factory.createKeywordTypeNode(150 /* UndefinedKeyword */); + var undefinedTypeNode = ts.factory.createKeywordTypeNode(151 /* UndefinedKeyword */); var type = propertyDeclaration.type; // TODO: GH#18217 var types = ts.isUnionTypeNode(type) ? type.types.concat(undefinedTypeNode) : [type, undefinedTypeNode]; changeTracker.replaceNode(propertyDeclarationSourceFile, type, ts.factory.createUnionTypeNode(types)); @@ -143033,8 +148055,8 @@ var ts; }); function getImportTypeNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 99 /* ImportKeyword */, "This token should be an ImportKeyword"); - ts.Debug.assert(token.parent.kind === 195 /* ImportType */, "Token parent should be an ImportType"); + ts.Debug.assert(token.kind === 100 /* ImportKeyword */, "This token should be an ImportKeyword"); + ts.Debug.assert(token.parent.kind === 197 /* ImportType */, "Token parent should be an ImportType"); return token.parent; } function doChange(changes, sourceFile, importType) { @@ -143053,10 +148075,6 @@ var ts; codefix.registerCodeFix({ errorCodes: errorCodes, getCodeActions: function (context) { - var jsx = context.program.getCompilerOptions().jsx; - if (jsx !== 2 /* React */ && jsx !== 3 /* ReactNative */) { - return undefined; - } var sourceFile = context.sourceFile, span = context.span; var node = findNodeToFix(sourceFile, span.start); if (!node) @@ -143166,7 +148184,7 @@ var ts; var otherMembers = members.filter(function (member) { return !ts.isIndexSignatureDeclaration(member); }); var parameter = ts.first(indexSignature.parameters); var mappedTypeParameter = ts.factory.createTypeParameterDeclaration(ts.cast(parameter.name, ts.isIdentifier), parameter.type); - var mappedIntersectionType = ts.factory.createMappedTypeNode(ts.hasEffectiveReadonlyModifier(indexSignature) ? ts.factory.createModifier(142 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, + var mappedIntersectionType = ts.factory.createMappedTypeNode(ts.hasEffectiveReadonlyModifier(indexSignature) ? ts.factory.createModifier(143 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, /*nameType*/ undefined, indexSignature.questionToken, indexSignature.type); var intersectionType = ts.factory.createIntersectionTypeNode(__spreadArray(__spreadArray(__spreadArray([], ts.getAllSuperTypeNodes(container)), [ mappedIntersectionType @@ -143223,7 +148241,7 @@ var ts; }, }); function makeChange(changeTracker, sourceFile, span) { - var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 130 /* AwaitKeyword */; }); + var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 131 /* AwaitKeyword */; }); var awaitExpression = awaitKeyword && ts.tryCast(awaitKeyword.parent, ts.isAwaitExpression); if (!awaitExpression) { return; @@ -143234,7 +148252,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 !== 102 /* NewKeyword */) { + if (precedingToken && precedingToken.kind !== 103 /* NewKeyword */) { expressionToReplace = awaitExpression.parent; } } @@ -143301,7 +148319,7 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, pos); var checker = program.getTypeChecker(); var symbol = checker.getSymbolAtLocation(token); - if (symbol) { + if (symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration) { return symbol.valueDeclaration.parent.parent; } } @@ -143396,7 +148414,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(113 /* VoidKeyword */)]).types[0]); + ts.isParenthesizedTypeNode(ts.factory.createUnionTypeNode([typeArgument, ts.factory.createKeywordTypeNode(114 /* VoidKeyword */)]).types[0]); if (needsParens) { changes.insertText(sourceFile, typeArgument.pos, "("); } @@ -143488,7 +148506,7 @@ var ts; ; function getInfo(context, considerPartialSpans) { if (considerPartialSpans === void 0) { considerPartialSpans = true; } - var file = context.file; + 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); @@ -143496,23 +148514,31 @@ var ts; return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_export_statement) }; } var exportingModuleSymbol = ts.isSourceFile(exportNode.parent) ? exportNode.parent.symbol : exportNode.parent.parent.symbol; - var flags = ts.getSyntacticModifierFlags(exportNode); + var flags = ts.getSyntacticModifierFlags(exportNode) || ((ts.isExportAssignment(exportNode) && !exportNode.isExportEquals) ? 513 /* ExportDefault */ : 0 /* None */); var wasDefault = !!(flags & 512 /* Default */); // If source file already has a default export, don't offer refactor. if (!(flags & 1 /* Export */) || !wasDefault && exportingModuleSymbol.exports.has("default" /* Default */)) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.This_file_already_has_a_default_export) }; } + var checker = program.getTypeChecker(); + var noSymbolError = function (id) { + return (ts.isIdentifier(id) && checker.getSymbolAtLocation(id)) ? undefined + : { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Can_only_convert_named_export) }; + }; switch (exportNode.kind) { - case 251 /* FunctionDeclaration */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 256 /* ModuleDeclaration */: { + case 253 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 257 /* EnumDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 258 /* ModuleDeclaration */: { var node = exportNode; - return node.name && ts.isIdentifier(node.name) ? { exportNode: node, exportName: node.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; + if (!node.name) + return undefined; + return noSymbolError(node.name) + || { exportNode: node, exportName: node.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol }; } - case 232 /* VariableStatement */: { + case 234 /* VariableStatement */: { var vs = exportNode; // Must be `export const x = something;`. if (!(vs.declarationList.flags & 2 /* Const */) || vs.declarationList.declarations.length !== 1) { @@ -143522,7 +148548,15 @@ var ts; if (!decl.initializer) return undefined; ts.Debug.assert(!wasDefault, "Can't have a default flag here"); - return ts.isIdentifier(decl.name) ? { exportNode: vs, exportName: decl.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; + return noSymbolError(decl.name) + || { exportNode: vs, exportName: decl.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol }; + } + case 268 /* ExportAssignment */: { + var node = exportNode; + if (node.isExportEquals) + return undefined; + return noSymbolError(node.expression) + || { exportNode: node, exportName: node.expression, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol }; } default: return undefined; @@ -143535,17 +148569,24 @@ var ts; function changeExport(exportingSourceFile, _a, changes, checker) { var wasDefault = _a.wasDefault, exportNode = _a.exportNode, exportName = _a.exportName; if (wasDefault) { - changes.delete(exportingSourceFile, ts.Debug.checkDefined(ts.findModifier(exportNode, 87 /* DefaultKeyword */), "Should find a default keyword in modifier list")); + if (ts.isExportAssignment(exportNode) && !exportNode.isExportEquals) { + var exp = exportNode.expression; + var spec = makeExportSpecifier(exp.text, exp.text); + changes.replaceNode(exportingSourceFile, exportNode, ts.factory.createExportDeclaration(/*decorators*/ undefined, /*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")); + } } else { - var exportKeyword = ts.Debug.checkDefined(ts.findModifier(exportNode, 92 /* ExportKeyword */), "Should find an export keyword in modifier list"); + var exportKeyword = ts.Debug.checkDefined(ts.findModifier(exportNode, 93 /* ExportKeyword */), "Should find an export keyword in modifier list"); switch (exportNode.kind) { - case 251 /* FunctionDeclaration */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.factory.createToken(87 /* DefaultKeyword */)); + case 253 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.factory.createToken(88 /* DefaultKeyword */)); break; - case 232 /* VariableStatement */: + case 234 /* 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) { @@ -143554,15 +148595,15 @@ var ts; break; } // falls through - case 255 /* EnumDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 256 /* ModuleDeclaration */: + case 257 /* EnumDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 258 /* 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.assertNever(exportNode, "Unexpected exportNode kind " + exportNode.kind); + ts.Debug.fail("Unexpected exportNode kind " + exportNode.kind); } } } @@ -143583,18 +148624,18 @@ var ts; function changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName) { var parent = ref.parent; switch (parent.kind) { - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: // `a.default` --> `a.foo` changes.replaceNode(importingSourceFile, ref, ts.factory.createIdentifier(exportName)); break; - case 265 /* ImportSpecifier */: - case 270 /* ExportSpecifier */: { + case 267 /* ImportSpecifier */: + case 272 /* 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 262 /* ImportClause */: { + case 264 /* ImportClause */: { var clause = parent; ts.Debug.assert(clause.name === ref, "Import clause name should match provided ref"); var spec = makeImportSpecifier(exportName, ref.text); @@ -143603,7 +148644,7 @@ var ts; // `import foo from "./a";` --> `import { foo } from "./a";` changes.replaceNode(importingSourceFile, ref, ts.factory.createNamedImports([spec])); } - else if (namedBindings.kind === 263 /* NamespaceImport */) { + else if (namedBindings.kind === 265 /* 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 */; @@ -143624,11 +148665,11 @@ var ts; function changeNamedToDefaultImport(importingSourceFile, ref, changes) { var parent = ref.parent; switch (parent.kind) { - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: // `a.foo` --> `a.default` changes.replaceNode(importingSourceFile, ref, ts.factory.createIdentifier("default")); break; - case 265 /* ImportSpecifier */: { + case 267 /* 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); @@ -143641,7 +148682,7 @@ var ts; } break; } - case 270 /* ExportSpecifier */: { + case 272 /* 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";` @@ -143687,7 +148728,7 @@ var ts; if (!info) return ts.emptyArray; if (!refactor.isRefactorErrorInfo(info)) { - var namespaceImport = info.kind === 263 /* NamespaceImport */; + var namespaceImport = info.kind === 265 /* NamespaceImport */; var action = namespaceImport ? namespaceToNamedAction : namedToNamespaceAction; return [{ name: refactorName, description: action.description, actions: [action] }]; } @@ -143729,7 +148770,7 @@ var ts; } function doChange(sourceFile, program, changes, toConvert) { var checker = program.getTypeChecker(); - if (toConvert.kind === 263 /* NamespaceImport */) { + if (toConvert.kind === 265 /* NamespaceImport */) { doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())); } else { @@ -143794,7 +148835,7 @@ var ts; }); var namespaceImportName = namespaceNameConflicts ? ts.getUniqueName(preferredName, sourceFile) : preferredName; var neededNamedImports = []; - var _loop_15 = function (element) { + var _loop_16 = 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); @@ -143813,7 +148854,7 @@ var ts; }; for (var _i = 0, _a = toConvert.elements; _i < _a.length; _i++) { var element = _a[_i]; - _loop_15(element); + _loop_16(element); } changes.replaceNode(sourceFile, toConvert, ts.factory.createNamespaceImport(ts.factory.createIdentifier(namespaceImportName))); if (neededNamedImports.length) { @@ -144130,27 +149171,27 @@ var ts; var lastDeclaration = signatureDecls[signatureDecls.length - 1]; var updated = lastDeclaration; switch (lastDeclaration.kind) { - case 164 /* MethodSignature */: { + case 166 /* MethodSignature */: { updated = ts.factory.updateMethodSignature(lastDeclaration, lastDeclaration.modifiers, lastDeclaration.name, lastDeclaration.questionToken, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 165 /* MethodDeclaration */: { + case 167 /* MethodDeclaration */: { updated = ts.factory.updateMethodDeclaration(lastDeclaration, lastDeclaration.decorators, lastDeclaration.modifiers, lastDeclaration.asteriskToken, lastDeclaration.name, lastDeclaration.questionToken, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type, lastDeclaration.body); break; } - case 169 /* CallSignature */: { + case 171 /* CallSignature */: { updated = ts.factory.updateCallSignature(lastDeclaration, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 166 /* Constructor */: { + case 168 /* Constructor */: { updated = ts.factory.updateConstructorDeclaration(lastDeclaration, lastDeclaration.decorators, lastDeclaration.modifiers, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.body); break; } - case 170 /* ConstructSignature */: { + case 172 /* ConstructSignature */: { updated = ts.factory.updateConstructSignature(lastDeclaration, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 251 /* FunctionDeclaration */: { + case 253 /* FunctionDeclaration */: { updated = ts.factory.updateFunctionDeclaration(lastDeclaration, lastDeclaration.decorators, lastDeclaration.modifiers, lastDeclaration.asteriskToken, lastDeclaration.name, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type, lastDeclaration.body); break; } @@ -144182,7 +149223,7 @@ var ts; } 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(128 /* AnyKeyword */)), p); + var result = ts.setTextRange(ts.factory.createNamedTupleMember(p.dotDotDotToken, p.name, p.questionToken, p.type || ts.factory.createKeywordTypeNode(129 /* AnyKeyword */)), p); var parameterDocComment = p.symbol && p.symbol.getDocumentationComment(checker); if (parameterDocComment) { var newComment = ts.displayPartsToString(parameterDocComment); @@ -144202,12 +149243,12 @@ var ts; } function isConvertableSignatureDeclaration(d) { switch (d.kind) { - case 164 /* MethodSignature */: - case 165 /* MethodDeclaration */: - case 169 /* CallSignature */: - case 166 /* Constructor */: - case 170 /* ConstructSignature */: - case 251 /* FunctionDeclaration */: + case 166 /* MethodSignature */: + case 167 /* MethodDeclaration */: + case 171 /* CallSignature */: + case 168 /* Constructor */: + case 172 /* ConstructSignature */: + case 253 /* FunctionDeclaration */: return true; } return false; @@ -144347,7 +149388,6 @@ var ts; }; } } - // Skip these since we don't have a way to report errors yet if (refactor.refactorKindBeginsWith(extractConstantAction.kind, requestedRefactor)) { if (constantExtraction.errors.length === 0) { // Don't issue refactorings with duplicated names. @@ -144479,24 +149519,28 @@ var ts; /** * getRangeToExtract takes a span inside a text file and returns either an expression or an array * of statements representing the minimum set of nodes needed to extract the entire span. This - * process may fail, in which case a set of errors is returned instead (these are currently - * not shown to the user, but can be used by us diagnostically) + * process may fail, in which case a set of errors is returned instead. These errors are shown to + * users if they have the provideRefactorNotApplicableReason option set. */ // exported only for tests - function getRangeToExtract(sourceFile, span, considerEmptySpans) { - if (considerEmptySpans === void 0) { considerEmptySpans = true; } + function getRangeToExtract(sourceFile, span, invoked) { + if (invoked === void 0) { invoked = true; } var length = span.length; - if (length === 0 && !considerEmptySpans) { + if (length === 0 && !invoked) { return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractEmpty)] }; } - var cursorRequest = length === 0 && considerEmptySpans; + var cursorRequest = length === 0 && invoked; + var startToken = ts.findFirstNonJsxWhitespaceToken(sourceFile, span.start); + var endToken = ts.findTokenOnLeftOfPosition(sourceFile, ts.textSpanEnd(span)); + /* If the refactoring command is invoked through a keyboard action it's safe to assume that the user is actively looking for + refactoring actions at the span location. As they may not know the exact range that will trigger a refactoring, we expand the + searched span to cover a real node range making it more likely that something useful will show up. */ + var adjustedSpan = startToken && endToken && invoked ? getAdjustedSpanFromNodes(startToken, endToken, sourceFile) : span; // Walk up starting from the the start position until we find a non-SourceFile node that subsumes the selected span. // This may fail (e.g. you select two statements in the root of a source file) - var startToken = ts.getTokenAtPosition(sourceFile, span.start); - var start = cursorRequest ? getExtractableParent(startToken) : ts.getParentNodeInSpan(startToken, sourceFile, span); + var start = cursorRequest ? getExtractableParent(startToken) : ts.getParentNodeInSpan(startToken, sourceFile, adjustedSpan); // Do the same for the ending position - var endToken = ts.findTokenOnLeftOfPosition(sourceFile, ts.textSpanEnd(span)); - var end = cursorRequest ? start : ts.getParentNodeInSpan(endToken, sourceFile, span); + var end = cursorRequest ? start : ts.getParentNodeInSpan(endToken, sourceFile, adjustedSpan); var declarations = []; // We'll modify these flags as we walk the tree to collect data // about what things need to be done as part of the extraction. @@ -144505,6 +149549,9 @@ var ts; // cannot find either start or end node return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] }; } + if (ts.isJSDoc(start)) { + return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractJSDoc)] }; + } if (start.parent !== end.parent) { // start and end nodes belong to different subtrees return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] }; @@ -144539,9 +149586,6 @@ var ts; } return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations } }; } - if (ts.isJSDoc(start)) { - return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractJSDoc)] }; - } if (ts.isReturnStatement(start) && !start.expression) { // Makes no sense to extract an expression-less return statement. return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] }; @@ -144594,20 +149638,20 @@ var ts; function checkForStaticContext(nodeToCheck, containingClass) { var current = nodeToCheck; while (current !== containingClass) { - if (current.kind === 163 /* PropertyDeclaration */) { + if (current.kind === 165 /* PropertyDeclaration */) { if (ts.hasSyntacticModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 160 /* Parameter */) { + else if (current.kind === 162 /* Parameter */) { var ctorOrMethod = ts.getContainingFunction(current); - if (ctorOrMethod.kind === 166 /* Constructor */) { + if (ctorOrMethod.kind === 168 /* Constructor */) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 165 /* MethodDeclaration */) { + else if (current.kind === 167 /* MethodDeclaration */) { if (ts.hasSyntacticModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } @@ -144650,7 +149694,7 @@ var ts; return true; } if (ts.isDeclaration(node)) { - var declaringNode = (node.kind === 249 /* VariableDeclaration */) ? node.parent.parent : node; + var declaringNode = (node.kind === 251 /* VariableDeclaration */) ? node.parent.parent : node; if (ts.hasSyntacticModifier(declaringNode, 1 /* 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`! @@ -144662,16 +149706,16 @@ var ts; } // Some things can't be extracted in certain situations switch (node.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractImport)); return true; - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractExportedEntity)); return true; - case 105 /* SuperKeyword */: + case 106 /* 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 === 203 /* CallExpression */) { + if (node.parent.kind === 205 /* CallExpression */) { // Super constructor call var containingClass_1 = ts.getContainingClass(node); // TODO:GH#18217 if (containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) { @@ -144683,7 +149727,7 @@ var ts; rangeFacts |= RangeFacts.UsesThis; } break; - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: // check if arrow function uses this ts.forEachChild(node, function check(n) { if (ts.isThis(n)) { @@ -144697,39 +149741,39 @@ var ts; } }); // falls through - case 252 /* ClassDeclaration */: - case 251 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: + case 253 /* 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 221 /* ClassExpression */: - case 208 /* FunctionExpression */: - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 223 /* ClassExpression */: + case 210 /* FunctionExpression */: + case 167 /* MethodDeclaration */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: // do not dive into functions or classes return false; } var savedPermittedJumps = permittedJumps; switch (node.kind) { - case 234 /* IfStatement */: + case 236 /* IfStatement */: permittedJumps = 0 /* None */; break; - case 247 /* TryStatement */: + case 249 /* TryStatement */: // forbid all jumps inside try blocks permittedJumps = 0 /* None */; break; - case 230 /* Block */: - if (node.parent && node.parent.kind === 247 /* TryStatement */ && node.parent.finallyBlock === node) { + case 232 /* Block */: + if (node.parent && node.parent.kind === 249 /* TryStatement */ && node.parent.finallyBlock === node) { // allow unconditional returns from finally blocks permittedJumps = 4 /* Return */; } break; - case 285 /* DefaultClause */: - case 284 /* CaseClause */: + case 287 /* DefaultClause */: + case 286 /* CaseClause */: // allow unlabeled break inside case clauses permittedJumps |= 1 /* Break */; break; @@ -144741,19 +149785,19 @@ var ts; break; } switch (node.kind) { - case 187 /* ThisType */: - case 107 /* ThisKeyword */: + case 189 /* ThisType */: + case 108 /* ThisKeyword */: rangeFacts |= RangeFacts.UsesThis; break; - case 245 /* LabeledStatement */: { + case 247 /* LabeledStatement */: { var label = node.label; (seenLabels || (seenLabels = [])).push(label.escapedText); ts.forEachChild(node, visit); seenLabels.pop(); break; } - case 241 /* BreakStatement */: - case 240 /* ContinueStatement */: { + case 243 /* BreakStatement */: + case 242 /* ContinueStatement */: { var label = node.label; if (label) { if (!ts.contains(seenLabels, label.escapedText)) { @@ -144762,20 +149806,20 @@ var ts; } } else { - if (!(permittedJumps & (node.kind === 241 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { + if (!(permittedJumps & (node.kind === 243 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { // attempt to break or continue in a forbidden context (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractRangeContainingConditionalBreakOrContinueStatements)); } } break; } - case 213 /* AwaitExpression */: + case 215 /* AwaitExpression */: rangeFacts |= RangeFacts.IsAsyncFunction; break; - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: rangeFacts |= RangeFacts.IsGenerator; break; - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: if (permittedJumps & 4 /* Return */) { rangeFacts |= RangeFacts.HasReturn; } @@ -144792,6 +149836,18 @@ var ts; } } extractSymbol.getRangeToExtract = getRangeToExtract; + /** + * Includes the final semicolon so that the span covers statements in cases where it would otherwise + * only cover the declaration list. + */ + function getAdjustedSpanFromNodes(startNode, endNode, sourceFile) { + var start = startNode.getStart(sourceFile); + var end = endNode.getEnd(); + if (sourceFile.text.charCodeAt(end) === 59 /* semicolon */) { + end++; + } + return { start: start, length: end - start }; + } function getStatementOrExpressionRange(node) { if (ts.isStatement(node)) { return [node]; @@ -144829,7 +149885,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 === 160 /* Parameter */) { + if (current.kind === 162 /* 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; } @@ -144840,7 +149896,7 @@ var ts; // * Module/namespace or source file if (isScope(current)) { scopes.push(current); - if (current.kind === 297 /* SourceFile */) { + if (current.kind === 299 /* SourceFile */) { return scopes; } } @@ -144930,32 +149986,32 @@ var ts; } function getDescriptionForFunctionLikeDeclaration(scope) { switch (scope.kind) { - case 166 /* Constructor */: + case 168 /* Constructor */: return "constructor"; - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: return scope.name ? "function '" + scope.name.text + "'" : ts.ANONYMOUS; - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return "arrow function"; - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: return "method '" + scope.name.getText() + "'"; - case 167 /* GetAccessor */: + case 169 /* GetAccessor */: return "'get " + scope.name.getText() + "'"; - case 168 /* SetAccessor */: + case 170 /* SetAccessor */: return "'set " + scope.name.getText() + "'"; default: throw ts.Debug.assertNever(scope, "Unexpected scope kind " + scope.kind); } } function getDescriptionForClassLikeDeclaration(scope) { - return scope.kind === 252 /* ClassDeclaration */ + return scope.kind === 254 /* ClassDeclaration */ ? scope.name ? "class '" + scope.name.text + "'" : "anonymous class declaration" : scope.name ? "class expression '" + scope.name.text + "'" : "anonymous class expression"; } function getDescriptionForModuleLikeDeclaration(scope) { - return scope.kind === 257 /* ModuleBlock */ + return scope.kind === 259 /* ModuleBlock */ ? "namespace '" + scope.parent.name.getText() + "'" : scope.externalModuleIndicator ? 0 /* Module */ : 1 /* Global */; } @@ -145023,12 +150079,12 @@ var ts; var newFunction; if (ts.isClassLike(scope)) { // always create private method in TypeScript files - var modifiers = isJS ? [] : [ts.factory.createModifier(120 /* PrivateKeyword */)]; + var modifiers = isJS ? [] : [ts.factory.createModifier(121 /* PrivateKeyword */)]; if (range.facts & RangeFacts.InStaticRegion) { - modifiers.push(ts.factory.createModifier(123 /* StaticKeyword */)); + modifiers.push(ts.factory.createModifier(124 /* StaticKeyword */)); } if (range.facts & RangeFacts.IsAsyncFunction) { - modifiers.push(ts.factory.createModifier(129 /* AsyncKeyword */)); + modifiers.push(ts.factory.createModifier(130 /* AsyncKeyword */)); } newFunction = ts.factory.createMethodDeclaration( /*decorators*/ undefined, modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* AsteriskToken */) : undefined, functionName, @@ -145036,7 +150092,7 @@ var ts; } else { newFunction = ts.factory.createFunctionDeclaration( - /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.factory.createToken(129 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body); + /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.factory.createToken(130 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* 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; @@ -145181,9 +150237,9 @@ var ts; while (ts.isParenthesizedTypeNode(withoutParens)) { withoutParens = withoutParens.type; } - return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 150 /* UndefinedKeyword */; }) + return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 151 /* UndefinedKeyword */; }) ? clone - : ts.factory.createUnionTypeNode([clone, ts.factory.createKeywordTypeNode(150 /* UndefinedKeyword */)]); + : ts.factory.createUnionTypeNode([clone, ts.factory.createKeywordTypeNode(151 /* UndefinedKeyword */)]); } } /** @@ -145208,11 +150264,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(120 /* PrivateKeyword */)); + modifiers.push(ts.factory.createModifier(121 /* PrivateKeyword */)); if (rangeFacts & RangeFacts.InStaticRegion) { - modifiers.push(ts.factory.createModifier(123 /* StaticKeyword */)); + modifiers.push(ts.factory.createModifier(124 /* StaticKeyword */)); } - modifiers.push(ts.factory.createModifier(142 /* ReadonlyKeyword */)); + modifiers.push(ts.factory.createModifier(143 /* ReadonlyKeyword */)); var newVariable = ts.factory.createPropertyDeclaration( /*decorators*/ undefined, modifiers, localNameText, /*questionToken*/ undefined, variableType, initializer); @@ -145244,7 +150300,7 @@ var ts; var localReference = ts.factory.createIdentifier(localNameText); changeTracker.replaceNode(context.file, node, localReference); } - else if (node.parent.kind === 233 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { + else if (node.parent.kind === 235 /* 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( @@ -145263,7 +150319,7 @@ var ts; changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariableStatement, /*blankLineBetween*/ false); } // Consume - if (node.parent.kind === 233 /* ExpressionStatement */) { + if (node.parent.kind === 235 /* ExpressionStatement */) { // If the parent is an expression statement, delete it. changeTracker.delete(context.file, node.parent); } @@ -145590,7 +150646,7 @@ var ts; var scope = scopes_1[_i]; usagesPerScope.push({ usages: new ts.Map(), typeParameterUsages: new ts.Map(), substitutions: new ts.Map() }); substitutionsPerScope.push(new ts.Map()); - functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 251 /* FunctionDeclaration */ + functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 253 /* FunctionDeclaration */ ? [ts.createDiagnosticForNode(scope, Messages.cannotExtractToOtherFunctionLike)] : []); var constantErrors = []; @@ -145653,7 +150709,7 @@ var ts; : ts.getEnclosingBlockScopeContainer(scopes[0]); ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations); } - var _loop_16 = function (i) { + var _loop_17 = 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 @@ -145693,7 +150749,7 @@ var ts; } }; for (var i = 0; i < scopes.length; i++) { - _loop_16(i); + _loop_17(i); } return { target: target, usagesPerScope: usagesPerScope, functionErrorsPerScope: functionErrorsPerScope, constantErrorsPerScope: constantErrorsPerScope, exposedVariableDeclarations: exposedVariableDeclarations }; function isInGenericContext(node) { @@ -145909,37 +150965,37 @@ var ts; function isExtractableExpression(node) { var parent = node.parent; switch (parent.kind) { - case 291 /* EnumMember */: + case 293 /* EnumMember */: return false; } switch (node.kind) { case 10 /* StringLiteral */: - return parent.kind !== 261 /* ImportDeclaration */ && - parent.kind !== 265 /* ImportSpecifier */; - case 220 /* SpreadElement */: - case 196 /* ObjectBindingPattern */: - case 198 /* BindingElement */: + return parent.kind !== 263 /* ImportDeclaration */ && + parent.kind !== 267 /* ImportSpecifier */; + case 222 /* SpreadElement */: + case 198 /* ObjectBindingPattern */: + case 200 /* BindingElement */: return false; - case 78 /* Identifier */: - return parent.kind !== 198 /* BindingElement */ && - parent.kind !== 265 /* ImportSpecifier */ && - parent.kind !== 270 /* ExportSpecifier */; + case 79 /* Identifier */: + return parent.kind !== 200 /* BindingElement */ && + parent.kind !== 267 /* ImportSpecifier */ && + parent.kind !== 272 /* ExportSpecifier */; } return true; } function isBlockLike(node) { switch (node.kind) { - case 230 /* Block */: - case 297 /* SourceFile */: - case 257 /* ModuleBlock */: - case 284 /* CaseClause */: + case 232 /* Block */: + case 299 /* SourceFile */: + case 259 /* ModuleBlock */: + case 286 /* CaseClause */: return true; default: return false; } } function isInJSXContent(node) { - return (ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node) || ts.isJsxFragment(node)) && ts.isJsxElement(node.parent); + return (ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node) || ts.isJsxFragment(node)) && (ts.isJsxElement(node.parent) || ts.isJsxFragment(node.parent)); } })(extractSymbol = refactor.extractSymbol || (refactor.extractSymbol = {})); })(refactor = ts.refactor || (ts.refactor = {})); @@ -146074,7 +151130,7 @@ var ts; if (ts.isTypeReferenceNode(node)) { if (ts.isIdentifier(node.typeName)) { var symbol = checker.resolveName(node.typeName.text, node.typeName, 262144 /* TypeParameter */, /* excludeGlobals */ true); - if (symbol) { + if (symbol === null || symbol === void 0 ? void 0 : symbol.declarations) { var declaration = ts.cast(ts.first(symbol.declarations), ts.isTypeParameterDeclaration); if (rangeContainsSkipTrivia(statement, declaration, file) && !rangeContainsSkipTrivia(selection, declaration, file)) { ts.pushIfUnique(result, declaration); @@ -146097,7 +151153,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); - if (symbol && rangeContainsSkipTrivia(statement, symbol.valueDeclaration, file) && !rangeContainsSkipTrivia(selection, symbol.valueDeclaration, file)) { + if ((symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration) && rangeContainsSkipTrivia(statement, symbol.valueDeclaration, file) && !rangeContainsSkipTrivia(selection, symbol.valueDeclaration, file)) { return true; } } @@ -146317,11 +151373,11 @@ var ts; } function isPureImport(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return true; - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return !ts.hasSyntacticModifier(node, 1 /* Export */); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return node.declarationList.declarations.every(function (d) { return !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); }); default: return false; @@ -146382,10 +151438,10 @@ var ts; } function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) { var checker = program.getTypeChecker(); - var _loop_17 = function (sourceFile) { + var _loop_18 = function (sourceFile) { if (sourceFile === oldFile) return "continue"; - var _loop_18 = function (statement) { + var _loop_19 = function (statement) { forEachImportInStatement(statement, function (importNode) { if (checker.getSymbolAtLocation(moduleSpecifierFromImport(importNode)) !== oldFile.symbol) return; @@ -146407,22 +151463,22 @@ var ts; }; for (var _b = 0, _c = sourceFile.statements; _b < _c.length; _b++) { var statement = _c[_b]; - _loop_18(statement); + _loop_19(statement); } }; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; - _loop_17(sourceFile); + _loop_18(sourceFile); } } function getNamespaceLikeImport(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: - return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 263 /* NamespaceImport */ ? + case 263 /* ImportDeclaration */: + return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 265 /* NamespaceImport */ ? node.importClause.namedBindings.name : undefined; - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return node.name; - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return ts.tryCast(node.name, ts.isIdentifier); default: return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); @@ -146453,20 +151509,20 @@ var ts; var newNamespaceId = ts.factory.createIdentifier(newNamespaceName); var newModuleString = ts.factory.createStringLiteral(newModuleSpecifier); switch (node.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, ts.factory.createNamespaceImport(newNamespaceId)), newModuleString); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return ts.factory.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, newNamespaceId, ts.factory.createExternalModuleReference(newModuleString)); - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return ts.factory.createVariableDeclaration(newNamespaceId, /*exclamationToken*/ undefined, /*type*/ undefined, createRequireCall(newModuleString)); default: return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); } } function moduleSpecifierFromImport(i) { - return (i.kind === 261 /* ImportDeclaration */ ? i.moduleSpecifier - : i.kind === 260 /* ImportEqualsDeclaration */ ? i.moduleReference.expression + return (i.kind === 263 /* ImportDeclaration */ ? i.moduleSpecifier + : i.kind === 262 /* ImportEqualsDeclaration */ ? i.moduleReference.expression : i.initializer.arguments[0]); } function forEachImportInStatement(statement, cb) { @@ -146536,15 +151592,15 @@ var ts; } function deleteUnusedImports(sourceFile, importDecl, changes, isUnused) { switch (importDecl.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused); break; - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: if (isUnused(importDecl.name)) { changes.delete(sourceFile, importDecl); } break; - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: deleteUnusedImportsInVariableDeclaration(sourceFile, importDecl, changes, isUnused); break; default: @@ -146557,7 +151613,7 @@ var ts; var _a = importDecl.importClause, name = _a.name, namedBindings = _a.namedBindings; var defaultUnused = !name || isUnused(name); var namedBindingsUnused = !namedBindings || - (namedBindings.kind === 263 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); + (namedBindings.kind === 265 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); if (defaultUnused && namedBindingsUnused) { changes.delete(sourceFile, importDecl); } @@ -146569,7 +151625,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 === 264 /* NamedImports */) { + else if (namedBindings.kind === 266 /* NamedImports */) { for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) { var element = _b[_i]; if (isUnused(element.name)) @@ -146582,14 +151638,14 @@ var ts; function deleteUnusedImportsInVariableDeclaration(sourceFile, varDecl, changes, isUnused) { var name = varDecl.name; switch (name.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: if (isUnused(name)) { changes.delete(sourceFile, name); } break; - case 197 /* ArrayBindingPattern */: + case 199 /* ArrayBindingPattern */: break; - case 196 /* ObjectBindingPattern */: + case 198 /* 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); } @@ -146617,6 +151673,9 @@ var ts; var oldFileNamedImports = []; var markSeenTop = ts.nodeSeenTracker(); // Needed because multiple declarations may appear in `const x = 0, y = 1;`. newFileImportsFromOldFile.forEach(function (symbol) { + if (!symbol.declarations) { + return; + } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; if (!isTopLevelDeclaration(decl)) @@ -146716,14 +151775,14 @@ var ts; // Below should all be utilities function isInImport(decl) { switch (decl.kind) { - case 260 /* ImportEqualsDeclaration */: - case 265 /* ImportSpecifier */: - case 262 /* ImportClause */: - case 263 /* NamespaceImport */: + case 262 /* ImportEqualsDeclaration */: + case 267 /* ImportSpecifier */: + case 264 /* ImportClause */: + case 265 /* NamespaceImport */: return true; - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return isVariableDeclarationInImport(decl); - case 198 /* BindingElement */: + case 200 /* BindingElement */: return ts.isVariableDeclaration(decl.parent.parent) && isVariableDeclarationInImport(decl.parent.parent); default: return false; @@ -146735,7 +151794,7 @@ var ts; } function filterImport(i, moduleSpecifier, keep) { switch (i.kind) { - case 261 /* ImportDeclaration */: { + case 263 /* ImportDeclaration */: { var clause = i.importClause; if (!clause) return undefined; @@ -146745,9 +151804,9 @@ var ts; ? ts.factory.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, defaultImport, namedBindings), moduleSpecifier) : undefined; } - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return keep(i.name) ? i : undefined; - case 249 /* VariableDeclaration */: { + case 251 /* VariableDeclaration */: { var name = filterBindingName(i.name, keep); return name ? makeVariableStatement(name, i.type, createRequireCall(moduleSpecifier), i.parent.flags) : undefined; } @@ -146756,7 +151815,7 @@ var ts; } } function filterNamedBindings(namedBindings, keep) { - if (namedBindings.kind === 263 /* NamespaceImport */) { + if (namedBindings.kind === 265 /* NamespaceImport */) { return keep(namedBindings.name) ? namedBindings : undefined; } else { @@ -146766,11 +151825,11 @@ var ts; } function filterBindingName(name, keep) { switch (name.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return keep(name) ? name : undefined; - case 197 /* ArrayBindingPattern */: + case 199 /* ArrayBindingPattern */: return name; - case 196 /* ObjectBindingPattern */: { + case 198 /* 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; @@ -146827,13 +151886,13 @@ var ts; } function isNonVariableTopLevelDeclaration(node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 252 /* ClassDeclaration */: - case 256 /* ModuleDeclaration */: - case 255 /* EnumDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 253 /* InterfaceDeclaration */: - case 260 /* ImportEqualsDeclaration */: + case 253 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: + case 258 /* ModuleDeclaration */: + case 257 /* EnumDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 255 /* InterfaceDeclaration */: + case 262 /* ImportEqualsDeclaration */: return true; default: return false; @@ -146841,17 +151900,17 @@ var ts; } function forEachTopLevelDeclaration(statement, cb) { switch (statement.kind) { - case 251 /* FunctionDeclaration */: - case 252 /* ClassDeclaration */: - case 256 /* ModuleDeclaration */: - case 255 /* EnumDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 253 /* InterfaceDeclaration */: - case 260 /* ImportEqualsDeclaration */: + case 253 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: + case 258 /* ModuleDeclaration */: + case 257 /* EnumDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 255 /* InterfaceDeclaration */: + case 262 /* ImportEqualsDeclaration */: return cb(statement); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return ts.firstDefined(statement.declarationList.declarations, function (decl) { return forEachTopLevelDeclarationInBindingName(decl.name, cb); }); - case 233 /* ExpressionStatement */: { + case 235 /* ExpressionStatement */: { var expression = statement.expression; return ts.isBinaryExpression(expression) && ts.getAssignmentDeclarationKind(expression) === 1 /* ExportsProperty */ ? cb(statement) @@ -146861,10 +151920,10 @@ var ts; } function forEachTopLevelDeclarationInBindingName(name, cb) { switch (name.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return cb(ts.cast(name.parent, function (x) { return ts.isVariableDeclaration(x) || ts.isBindingElement(x); })); - case 197 /* ArrayBindingPattern */: - case 196 /* ObjectBindingPattern */: + case 199 /* ArrayBindingPattern */: + case 198 /* 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); @@ -146875,9 +151934,9 @@ var ts; } function getTopLevelDeclarationStatement(d) { switch (d.kind) { - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return d.parent.parent; - case 198 /* BindingElement */: + case 200 /* BindingElement */: return getTopLevelDeclarationStatement(ts.cast(d.parent.parent, function (p) { return ts.isVariableDeclaration(p) || ts.isBindingElement(p); })); default: return d; @@ -146908,25 +151967,25 @@ var ts; return useEs6Exports ? [addEs6Export(decl)] : addCommonjsExport(decl); } function addEs6Export(d) { - var modifiers = ts.concatenate([ts.factory.createModifier(92 /* ExportKeyword */)], d.modifiers); + var modifiers = ts.concatenate([ts.factory.createModifier(93 /* ExportKeyword */)], d.modifiers); switch (d.kind) { - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return ts.factory.updateFunctionDeclaration(d, d.decorators, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body); - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: return ts.factory.updateClassDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return ts.factory.updateVariableStatement(d, modifiers, d.declarationList); - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return ts.factory.updateModuleDeclaration(d, d.decorators, modifiers, d.name, d.body); - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: return ts.factory.updateEnumDeclaration(d, d.decorators, modifiers, d.name, d.members); - case 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: return ts.factory.updateTypeAliasDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.type); - case 253 /* InterfaceDeclaration */: + case 255 /* InterfaceDeclaration */: return ts.factory.updateInterfaceDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return ts.factory.updateImportEqualsDeclaration(d, d.decorators, modifiers, d.isTypeOnly, d.name, d.moduleReference); - case 233 /* ExpressionStatement */: + case 235 /* 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); @@ -146937,18 +151996,18 @@ var ts; } function getNamesToExportInCommonJS(decl) { switch (decl.kind) { - case 251 /* FunctionDeclaration */: - case 252 /* ClassDeclaration */: + case 253 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: return [decl.name.text]; // TODO: GH#18217 - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return ts.mapDefined(decl.declarationList.declarations, function (d) { return ts.isIdentifier(d.name) ? d.name.text : undefined; }); - case 256 /* ModuleDeclaration */: - case 255 /* EnumDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 253 /* InterfaceDeclaration */: - case 260 /* ImportEqualsDeclaration */: + case 258 /* ModuleDeclaration */: + case 257 /* EnumDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 255 /* InterfaceDeclaration */: + case 262 /* ImportEqualsDeclaration */: return ts.emptyArray; - case 233 /* ExpressionStatement */: + case 235 /* 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); @@ -146956,7 +152015,7 @@ var ts; } /** 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)), 62 /* EqualsToken */, ts.factory.createIdentifier(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))); } })(refactor = ts.refactor || (ts.refactor = {})); })(ts || (ts = {})); @@ -147117,13 +152176,13 @@ var ts; return { edits: [] }; // TODO: GH#30113 } function doChange(sourceFile, program, host, changes, functionDeclaration, groupedReferences) { - var newParamDeclaration = ts.map(createNewParameters(functionDeclaration, program, host), function (param) { return ts.getSynthesizedDeepClone(param); }); - changes.replaceNodeRangeWithNodes(sourceFile, ts.first(functionDeclaration.parameters), ts.last(functionDeclaration.parameters), newParamDeclaration, { joiner: ", ", - // indentation is set to 0 because otherwise the object parameter will be indented if there is a `this` parameter - indentation: 0, - leadingTriviaOption: ts.textChanges.LeadingTriviaOption.IncludeAll, - trailingTriviaOption: ts.textChanges.TrailingTriviaOption.Include - }); + var signature = groupedReferences.signature; + var newFunctionDeclarationParams = ts.map(createNewParameters(functionDeclaration, program, host), function (param) { return ts.getSynthesizedDeepClone(param); }); + if (signature) { + var newSignatureParams = ts.map(createNewParameters(signature, program, host), function (param) { return ts.getSynthesizedDeepClone(param); }); + replaceParameters(signature, newSignatureParams); + } + replaceParameters(functionDeclaration, newFunctionDeclarationParams); var functionCalls = ts.sortAndDeduplicate(groupedReferences.functionCalls, /*comparer*/ function (a, b) { return ts.compareValues(a.pos, b.pos); }); for (var _i = 0, functionCalls_1 = functionCalls; _i < functionCalls_1.length; _i++) { var call = functionCalls_1[_i]; @@ -147132,6 +152191,15 @@ var ts; changes.replaceNodeRange(ts.getSourceFileOfNode(call), ts.first(call.arguments), ts.last(call.arguments), newArgument, { leadingTriviaOption: ts.textChanges.LeadingTriviaOption.IncludeAll, trailingTriviaOption: ts.textChanges.TrailingTriviaOption.Include }); } } + function replaceParameters(declarationOrSignature, parameterDeclarations) { + changes.replaceNodeRangeWithNodes(sourceFile, ts.first(declarationOrSignature.parameters), ts.last(declarationOrSignature.parameters), parameterDeclarations, { + joiner: ", ", + // indentation is set to 0 because otherwise the object parameter will be indented if there is a `this` parameter + indentation: 0, + leadingTriviaOption: ts.textChanges.LeadingTriviaOption.IncludeAll, + trailingTriviaOption: ts.textChanges.TrailingTriviaOption.Include + }); + } } function getGroupedReferences(functionDeclaration, program, cancellationToken) { var functionNames = getFunctionNames(functionDeclaration); @@ -147150,12 +152218,38 @@ var ts; var functionSymbols = ts.map(functionNames, getSymbolTargetAtLocation); var classSymbols = ts.map(classNames, getSymbolTargetAtLocation); var isConstructor = ts.isConstructorDeclaration(functionDeclaration); + 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 !== 1 /* Node */) { + if (entry.kind === 0 /* Span */) { groupedReferences.valid = false; continue; } + /* Declarations in object literals may be implementations of method signatures which have a different symbol from the declaration + For example: + interface IFoo { m(a: number): void } + const foo: IFoo = { m(a: number): void {} } + In these cases we get the symbol for the signature from the contextual type. + */ + if (ts.contains(contextualSymbols, getSymbolTargetAtLocation(entry.node))) { + if (isValidMethodSignature(entry.node.parent)) { + groupedReferences.signature = entry.node.parent; + continue; + } + var call = entryToFunctionCall(entry); + if (call) { + groupedReferences.functionCalls.push(call); + continue; + } + } + var contextualSymbol = getSymbolForContextualType(entry.node, checker); + if (contextualSymbol && ts.contains(contextualSymbols, contextualSymbol)) { + var decl = entryToDeclaration(entry); + if (decl) { + groupedReferences.declarations.push(decl); + continue; + } + } /* We compare symbols because in some cases find all references wil return a reference that may or may not be to the refactored function. Example from the refactorConvertParamsToDestructuredObject_methodCallUnion.ts test: class A { foo(a: number, b: number) { return a + b; } } @@ -147218,6 +152312,19 @@ var ts; return symbol && ts.getSymbolTarget(symbol, checker); } } + /** + * Gets the symbol for the contextual type of the node if it is not a union or intersection. + */ + function getSymbolForContextualType(node, checker) { + var element = ts.getContainingObjectLiteralElement(node); + 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 */)) { + return symbol; + } + } + } function entryToImportOrExport(entry) { var node = entry.node; if (ts.isImportSpecifier(node.parent) @@ -147243,15 +152350,15 @@ var ts; var parent = functionReference.parent; switch (parent.kind) { // foo(...) or super(...) or new Foo(...) - case 203 /* CallExpression */: - case 204 /* NewExpression */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: var callOrNewExpression = ts.tryCast(parent, ts.isCallOrNewExpression); if (callOrNewExpression && callOrNewExpression.expression === functionReference) { return callOrNewExpression; } break; // x.foo(...) - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.parent && propertyAccessExpression.name === functionReference) { var callOrNewExpression_1 = ts.tryCast(propertyAccessExpression.parent, ts.isCallOrNewExpression); @@ -147261,7 +152368,7 @@ var ts; } break; // x["foo"](...) - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.parent && elementAccessExpression.argumentExpression === functionReference) { var callOrNewExpression_2 = ts.tryCast(elementAccessExpression.parent, ts.isCallOrNewExpression); @@ -147280,14 +152387,14 @@ var ts; var parent = reference.parent; switch (parent.kind) { // `C.foo` - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.expression === reference) { return propertyAccessExpression; } break; // `C["foo"]` - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.expression === reference) { return elementAccessExpression; @@ -147325,15 +152432,24 @@ var ts; } return false; } + function isValidMethodSignature(node) { + return ts.isMethodSignature(node) && (ts.isInterfaceDeclaration(node.parent) || ts.isTypeLiteralNode(node.parent)); + } function isValidFunctionDeclaration(functionDeclaration, checker) { + var _a; if (!isValidParameterNodeArray(functionDeclaration.parameters, checker)) return false; switch (functionDeclaration.kind) { - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return hasNameOrDefault(functionDeclaration) && isSingleImplementation(functionDeclaration, checker); - case 165 /* MethodDeclaration */: + case 167 /* 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 166 /* Constructor */: + case 168 /* Constructor */: if (ts.isClassDeclaration(functionDeclaration.parent)) { return hasNameOrDefault(functionDeclaration.parent) && isSingleImplementation(functionDeclaration, checker); } @@ -147341,8 +152457,8 @@ var ts; return isValidVariableDeclaration(functionDeclaration.parent.parent) && isSingleImplementation(functionDeclaration, checker); } - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return isValidVariableDeclaration(functionDeclaration.parent); } return false; @@ -147352,7 +152468,7 @@ var ts; } function hasNameOrDefault(functionOrClassDeclaration) { if (!functionOrClassDeclaration.name) { - var defaultKeyword = ts.findModifier(functionOrClassDeclaration, 87 /* DefaultKeyword */); + var defaultKeyword = ts.findModifier(functionOrClassDeclaration, 88 /* DefaultKeyword */); return !!defaultKeyword; } return true; @@ -147492,15 +152608,15 @@ var ts; } function getClassNames(constructorDeclaration) { switch (constructorDeclaration.parent.kind) { - case 252 /* ClassDeclaration */: + case 254 /* 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, 87 /* DefaultKeyword */), "Nameless class declaration should be a default export"); + var defaultModifier = ts.Debug.checkDefined(ts.findModifier(classDeclaration, 88 /* DefaultKeyword */), "Nameless class declaration should be a default export"); return [defaultModifier]; - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: var classExpression = constructorDeclaration.parent; var variableDeclaration = constructorDeclaration.parent.parent; var className = classExpression.name; @@ -147511,25 +152627,25 @@ var ts; } function getFunctionNames(functionDeclaration) { switch (functionDeclaration.kind) { - case 251 /* FunctionDeclaration */: + case 253 /* 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, 87 /* DefaultKeyword */), "Nameless function declaration should be a default export"); + var defaultModifier = ts.Debug.checkDefined(ts.findModifier(functionDeclaration, 88 /* DefaultKeyword */), "Nameless function declaration should be a default export"); return [defaultModifier]; - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: return [functionDeclaration.name]; - case 166 /* Constructor */: - var ctrKeyword = ts.Debug.checkDefined(ts.findChildOfKind(functionDeclaration, 132 /* ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); - if (functionDeclaration.parent.kind === 221 /* ClassExpression */) { + case 168 /* Constructor */: + var ctrKeyword = ts.Debug.checkDefined(ts.findChildOfKind(functionDeclaration, 133 /* ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); + if (functionDeclaration.parent.kind === 223 /* ClassExpression */) { var variableDeclaration = functionDeclaration.parent.parent; return [variableDeclaration.name, ctrKeyword]; } return [ctrKeyword]; - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return [functionDeclaration.parent.name]; - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: if (functionDeclaration.name) return [functionDeclaration.name, functionDeclaration.parent.name]; return [functionDeclaration.parent.name]; @@ -147615,16 +152731,16 @@ var ts; } } function isNotEqualsOperator(node) { - return node.operatorToken.kind !== 62 /* EqualsToken */; + return node.operatorToken.kind !== 63 /* EqualsToken */; } function getParentBinaryExpression(expr) { var container = ts.findAncestor(expr.parent, function (n) { switch (n.kind) { - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: return false; - case 218 /* TemplateExpression */: - case 216 /* BinaryExpression */: + case 220 /* TemplateExpression */: + case 218 /* BinaryExpression */: return !(ts.isBinaryExpression(n.parent) && isNotEqualsOperator(n.parent)); default: return "quit"; @@ -147701,7 +152817,7 @@ var ts; var templateSpans = []; var templateHead = ts.factory.createTemplateHead(headText); copyCommentFromStringLiterals(headIndexes, templateHead); - var _loop_19 = function (i) { + var _loop_20 = function (i) { var currentNode = getExpressionFromParenthesesOrExpression(nodes[i]); copyOperatorComments(i, currentNode); var _c = concatConsecutiveString(i + 1, nodes), newIndex = _c[0], subsequentText = _c[1], stringIndexes = _c[2]; @@ -147725,7 +152841,7 @@ var ts; }; var out_i_1; for (var i = begin; i < nodes.length; i++) { - _loop_19(i); + _loop_20(i); i = out_i_1; } return ts.factory.createTemplateExpression(templateHead, templateSpans); @@ -147925,7 +153041,9 @@ var ts; var body = convertToBlock(func.body); var variableDeclaration = variableInfo.variableDeclaration, variableDeclarationList = variableInfo.variableDeclarationList, statement = variableInfo.statement, name = variableInfo.name; ts.suppressLeadingTrivia(statement); - var newNode = ts.factory.createFunctionDeclaration(func.decorators, statement.modifiers, func.asteriskToken, name, func.typeParameters, func.parameters, func.type, body); + var modifiersFlags = (ts.getCombinedModifierFlags(variableDeclaration) & 1 /* Export */) | ts.getEffectiveModifierFlags(func); + var modifiers = ts.factory.createModifiersFromModifierFlags(modifiersFlags); + var newNode = ts.factory.createFunctionDeclaration(func.decorators, ts.length(modifiers) ? modifiers : undefined, func.asteriskToken, name, func.typeParameters, func.parameters, func.type, body); if (variableDeclarationList.declarations.length === 1) { return ts.textChanges.ChangeTracker.with(context, function (t) { return t.replaceNode(file, statement, newNode); }); } @@ -147983,9 +153101,7 @@ var ts; function getEditsForAction(context) { var info = getInfo(context); if (info && !refactor.isRefactorErrorInfo(info)) { - var edits = ts.textChanges.ChangeTracker.with(context, function (t) { - return t.tryInsertTypeAnnotation(context.file, info.declaration, info.returnTypeNode); - }); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, t, info.declaration, info.returnTypeNode); }); return { renameFilename: undefined, renameLocation: undefined, edits: edits }; } return undefined; @@ -148010,11 +153126,26 @@ var ts; } return ts.emptyArray; } + function doChange(sourceFile, changes, declaration, typeNode) { + var closeParen = ts.findChildOfKind(declaration, 21 /* 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.insertNodeAt(sourceFile, endNode.end, typeNode, { prefix: ": " }); + } + } function getInfo(context) { if (ts.isInJSFile(context.file) || !refactor.refactorKindBeginsWith(inferReturnTypeAction.kind, context.kind)) return; var token = ts.getTokenAtPosition(context.file, context.startPosition); - var declaration = ts.findAncestor(token, isConvertibleDeclaration); + 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" : + isConvertibleDeclaration(n); + }); if (!declaration || !declaration.body || declaration.type) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Return_type_must_be_inferred_from_a_function) }; } @@ -148023,7 +153154,6 @@ var ts; if (!returnType) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_determine_function_return_type) }; } - ; var returnTypeNode = typeChecker.typeToTypeNode(returnType, declaration, 1 /* NoTruncation */); if (returnTypeNode) { return { declaration: declaration, returnTypeNode: returnTypeNode }; @@ -148031,10 +153161,10 @@ var ts; } function isConvertibleDeclaration(node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 167 /* MethodDeclaration */: return true; default: return false; @@ -148061,8 +153191,8 @@ var ts; ts.servicesVersion = "0.8"; function createNode(kind, pos, end, parent) { var node = ts.isNodeKind(kind) ? new NodeObject(kind, pos, end) : - kind === 78 /* Identifier */ ? new IdentifierObject(78 /* Identifier */, pos, end) : - kind === 79 /* PrivateIdentifier */ ? new PrivateIdentifierObject(79 /* PrivateIdentifier */, pos, end) : + kind === 79 /* Identifier */ ? new IdentifierObject(79 /* Identifier */, pos, end) : + kind === 80 /* PrivateIdentifier */ ? new PrivateIdentifierObject(80 /* PrivateIdentifier */, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; node.flags = parent.flags & 25358336 /* ContextFlags */; @@ -148136,8 +153266,8 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 301 /* FirstJSDocNode */ || kid.kind > 333 /* LastJSDocNode */; }); - return child.kind < 157 /* FirstNode */ ? + var child = ts.find(children, function (kid) { return kid.kind < 303 /* FirstJSDocNode */ || kid.kind > 341 /* LastJSDocNode */; }); + return child.kind < 159 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; @@ -148148,7 +153278,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 157 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 159 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; NodeObject.prototype.forEachChild = function (cbNode, cbNodeArray) { return ts.forEachChild(this, cbNode, cbNodeArray); @@ -148194,7 +153324,7 @@ var ts; var token = ts.scanner.scan(); var textPos = ts.scanner.getTextPos(); if (textPos <= end) { - if (token === 78 /* Identifier */) { + if (token === 79 /* Identifier */) { ts.Debug.fail("Did not expect " + ts.Debug.formatSyntaxKind(parent.kind) + " to have an Identifier in its trivia"); } nodes.push(createNode(token, pos, textPos, parent)); @@ -148206,11 +153336,11 @@ var ts; } } function createSyntaxList(nodes, parent) { - var list = createNode(334 /* SyntaxList */, nodes.pos, nodes.end, parent); + var list = createNode(342 /* SyntaxList */, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; - for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { - var node = nodes_1[_i]; + for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) { + var node = nodes_2[_i]; addSyntheticNodes(list._children, pos, node.pos, parent); list._children.push(node); pos = node.end; @@ -148317,13 +153447,13 @@ var ts; }; SymbolObject.prototype.getContextualDocumentationComment = function (context, checker) { switch (context === null || context === void 0 ? void 0 : context.kind) { - case 167 /* GetAccessor */: + case 169 /* GetAccessor */: if (!this.contextualGetAccessorDocumentationComment) { this.contextualGetAccessorDocumentationComment = ts.emptyArray; this.contextualGetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isGetAccessor), checker); } return this.contextualGetAccessorDocumentationComment; - case 168 /* SetAccessor */: + case 170 /* SetAccessor */: if (!this.contextualSetAccessorDocumentationComment) { this.contextualSetAccessorDocumentationComment = ts.emptyArray; this.contextualSetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isSetAccessor), checker); @@ -148333,9 +153463,9 @@ var ts; return this.getDocumentationComment(checker); } }; - SymbolObject.prototype.getJsDocTags = function () { + SymbolObject.prototype.getJsDocTags = function (checker) { if (this.tags === undefined) { - this.tags = ts.JsDoc.getJsDocTagsFromDeclarations(this.declarations); + this.tags = ts.JsDoc.getJsDocTagsFromDeclarations(this.declarations, checker); } return this.tags; }; @@ -148354,7 +153484,7 @@ var ts; __extends(IdentifierObject, _super); function IdentifierObject(_kind, pos, end) { var _this = _super.call(this, pos, end) || this; - _this.kind = 78 /* Identifier */; + _this.kind = 79 /* Identifier */; return _this; } Object.defineProperty(IdentifierObject.prototype, "text", { @@ -148366,7 +153496,7 @@ var ts; }); return IdentifierObject; }(TokenOrIdentifierObject)); - IdentifierObject.prototype.kind = 78 /* Identifier */; + IdentifierObject.prototype.kind = 79 /* Identifier */; var PrivateIdentifierObject = /** @class */ (function (_super) { __extends(PrivateIdentifierObject, _super); function PrivateIdentifierObject(_kind, pos, end) { @@ -148381,7 +153511,7 @@ var ts; }); return PrivateIdentifierObject; }(TokenOrIdentifierObject)); - PrivateIdentifierObject.prototype.kind = 79 /* PrivateIdentifier */; + PrivateIdentifierObject.prototype.kind = 80 /* PrivateIdentifier */; var TypeObject = /** @class */ (function () { function TypeObject(checker, flags) { this.checker = checker; @@ -148496,7 +153626,7 @@ var ts; }; SignatureObject.prototype.getJsDocTags = function () { if (this.jsDocTags === undefined) { - this.jsDocTags = this.declaration ? getJsDocTags([this.declaration], this.checker) : []; + this.jsDocTags = this.declaration ? getJsDocTagsOfSignature(this.declaration, this.checker) : []; } return this.jsDocTags; }; @@ -148510,29 +153640,34 @@ var ts; function hasJSDocInheritDocTag(node) { return ts.getJSDocTags(node).some(function (tag) { return tag.tagName.text === "inheritDoc"; }); } - function getJsDocTags(declarations, checker) { - var tags = ts.JsDoc.getJsDocTagsFromDeclarations(declarations); - if (tags.length === 0 || declarations.some(hasJSDocInheritDocTag)) { - ts.forEachUnique(declarations, function (declaration) { - var inheritedTags = findBaseOfDeclaration(checker, declaration, function (symbol) { return symbol.getJsDocTags(); }); - if (inheritedTags) { - tags = __spreadArray(__spreadArray([], inheritedTags), tags); - } - }); + function getJsDocTagsOfSignature(declaration, checker) { + var tags = ts.JsDoc.getJsDocTagsFromDeclarations([declaration], checker); + if (tags.length === 0 || hasJSDocInheritDocTag(declaration)) { + var inheritedTags = findBaseOfDeclaration(checker, declaration, function (symbol) { var _a; return ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.length) === 1 ? symbol.getJsDocTags() : undefined; }); + if (inheritedTags) { + tags = __spreadArray(__spreadArray([], inheritedTags), tags); + } } return tags; } function getDocumentationComment(declarations, checker) { if (!declarations) return ts.emptyArray; - var doc = ts.JsDoc.getJsDocCommentsFromDeclarations(declarations); + var doc = ts.JsDoc.getJsDocCommentsFromDeclarations(declarations, checker); if (checker && (doc.length === 0 || declarations.some(hasJSDocInheritDocTag))) { - ts.forEachUnique(declarations, function (declaration) { - var inheritedDocs = findBaseOfDeclaration(checker, declaration, function (symbol) { return symbol.getDocumentationComment(checker); }); + var seenSymbols_1 = new ts.Set(); + for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { + var declaration = declarations_4[_i]; + var inheritedDocs = findBaseOfDeclaration(checker, declaration, function (symbol) { + if (!seenSymbols_1.has(symbol)) { + seenSymbols_1.add(symbol); + return symbol.getDocumentationComment(checker); + } + }); // TODO: GH#16312 Return a ReadonlyArray, avoid copying inheritedDocs if (inheritedDocs) doc = doc.length === 0 ? inheritedDocs.slice() : inheritedDocs.concat(ts.lineBreakPart(), doc); - }); + } } return doc; } @@ -148546,7 +153681,7 @@ var ts; __extends(SourceFileObject, _super); function SourceFileObject(kind, pos, end) { var _this = _super.call(this, kind, pos, end) || this; - _this.kind = 297 /* SourceFile */; + _this.kind = 299 /* SourceFile */; return _this; } SourceFileObject.prototype.update = function (newText, textChangeRange) { @@ -148605,10 +153740,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -148628,31 +153763,31 @@ var ts; } ts.forEachChild(node, visit); break; - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 255 /* EnumDeclaration */: - case 256 /* ModuleDeclaration */: - case 260 /* ImportEqualsDeclaration */: - case 270 /* ExportSpecifier */: - case 265 /* ImportSpecifier */: - case 262 /* ImportClause */: - case 263 /* NamespaceImport */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 177 /* TypeLiteral */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 257 /* EnumDeclaration */: + case 258 /* ModuleDeclaration */: + case 262 /* ImportEqualsDeclaration */: + case 272 /* ExportSpecifier */: + case 267 /* ImportSpecifier */: + case 264 /* ImportClause */: + case 265 /* NamespaceImport */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 179 /* TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 160 /* Parameter */: + case 162 /* Parameter */: // Only consider parameter properties - if (!ts.hasSyntacticModifier(node, 92 /* ParameterPropertyModifier */)) { + if (!ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */)) { break; } // falls through - case 249 /* VariableDeclaration */: - case 198 /* BindingElement */: { + case 251 /* VariableDeclaration */: + case 200 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -148663,12 +153798,12 @@ var ts; } } // falls through - case 291 /* EnumMember */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 293 /* EnumMember */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: addDeclaration(node); break; - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; var exportDeclaration = node; @@ -148681,7 +153816,7 @@ var ts; } } break; - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -148693,7 +153828,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 263 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 265 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -148702,7 +153837,7 @@ var ts; } } break; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) !== 0 /* None */) { addDeclaration(node); } @@ -148796,15 +153931,7 @@ var ts; var fileName = rootFileNames_1[_i]; this.createEntry(fileName, ts.toPath(fileName, this.currentDirectory, getCanonicalFileName)); } - // store the compilation settings - this._compilationSettings = host.getCompilationSettings() || getDefaultCompilerOptions(); } - HostCache.prototype.compilationSettings = function () { - return this._compilationSettings; - }; - HostCache.prototype.getProjectReferences = function () { - return this.host.getProjectReferences && this.host.getProjectReferences(); - }; HostCache.prototype.createEntry = function (fileName, path) { var entry; var scriptSnapshot = this.host.getScriptSnapshot(fileName); @@ -148954,7 +154081,7 @@ var ts; }; CancellationTokenObject.prototype.throwIfCancellationRequested = function () { if (this.isCancellationRequested()) { - ts.tracing.instant("session" /* Session */, "cancellationThrown", { kind: "CancellationTokenObject" }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "cancellationThrown", { kind: "CancellationTokenObject" }); throw new ts.OperationCanceledException(); } }; @@ -148984,7 +154111,7 @@ var ts; }; ThrottledCancellationToken.prototype.throwIfCancellationRequested = function () { if (this.isCancellationRequested()) { - ts.tracing.instant("session" /* Session */, "cancellationThrown", { kind: "ThrottledCancellationToken" }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "cancellationThrown", { kind: "ThrottledCancellationToken" }); throw new ts.OperationCanceledException(); } }; @@ -149084,7 +154211,7 @@ var ts; return sourceFile; } function synchronizeHostData() { - var _a, _b; + var _a, _b, _c; ts.Debug.assert(languageServiceMode !== ts.LanguageServiceMode.Syntactic); // perform fast check if host supports it if (host.getProjectVersion) { @@ -149105,11 +154232,22 @@ var ts; // Get a fresh cache of the host information var hostCache = new HostCache(host, getCanonicalFileName); var rootFileNames = hostCache.getRootFileNames(); + var newSettings = host.getCompilationSettings() || getDefaultCompilerOptions(); var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse; var hasChangedAutomaticTypeDirectiveNames = ts.maybeBind(host, host.hasChangedAutomaticTypeDirectiveNames); - var projectReferences = hostCache.getProjectReferences(); + var projectReferences = (_b = host.getProjectReferences) === null || _b === void 0 ? void 0 : _b.call(host); + var parsedCommandLines; + var parseConfigHost = { + useCaseSensitiveFileNames: useCaseSensitiveFileNames, + fileExists: fileExists, + readFile: readFile, + readDirectory: readDirectory, + trace: ts.maybeBind(host, host.trace), + getCurrentDirectory: function () { return currentDirectory; }, + onUnRecoverableConfigFileDiagnostic: ts.noop, + }; // If the program is already up-to-date, we can reuse it - if (ts.isProgramUptoDate(program, rootFileNames, hostCache.compilationSettings(), function (_path, fileName) { return host.getScriptVersion(fileName); }, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, projectReferences)) { + if (ts.isProgramUptoDate(program, rootFileNames, newSettings, function (_path, fileName) { return host.getScriptVersion(fileName); }, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) { return; } // IMPORTANT - It is critical from this moment onward that we do not check @@ -149117,7 +154255,6 @@ var ts; // instance. If we cancel midway through, we may end up in an inconsistent state where // the program points to old source files that have been invalidated because of // incremental parsing. - var newSettings = hostCache.compilationSettings(); // Now create a new compiler var compilerHost = { getSourceFile: getOrCreateSourceFile, @@ -149139,19 +154276,18 @@ var ts; getDirectories: function (path) { return host.getDirectories ? host.getDirectories(path) : []; }, - readDirectory: function (path, extensions, exclude, include, depth) { - ts.Debug.checkDefined(host.readDirectory, "'LanguageServiceHost.readDirectory' must be implemented to correctly process 'projectReferences'"); - return host.readDirectory(path, extensions, exclude, include, depth); - }, + readDirectory: readDirectory, onReleaseOldSourceFile: onReleaseOldSourceFile, + onReleaseParsedCommandLine: onReleaseParsedCommandLine, hasInvalidatedResolution: hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames: hasChangedAutomaticTypeDirectiveNames, - trace: ts.maybeBind(host, host.trace), + trace: parseConfigHost.trace, resolveModuleNames: ts.maybeBind(host, host.resolveModuleNames), resolveTypeReferenceDirectives: ts.maybeBind(host, host.resolveTypeReferenceDirectives), useSourceOfProjectReferenceRedirect: ts.maybeBind(host, host.useSourceOfProjectReferenceRedirect), + getParsedCommandLine: getParsedCommandLine, }; - (_b = host.setCompilerHost) === null || _b === void 0 ? void 0 : _b.call(host, compilerHost); + (_c = host.setCompilerHost) === null || _c === void 0 ? void 0 : _c.call(host, compilerHost); var documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings); var options = { rootNames: rootFileNames, @@ -149164,6 +154300,7 @@ var ts; // hostCache is captured in the closure for 'getOrCreateSourceFile' but it should not be used past this point. // It needs to be cleared to allow all collected snapshots to be released hostCache = undefined; + parsedCommandLines = undefined; // We reset this cache on structure invalidation so we don't hold on to outdated files for long; however we can't use the `compilerHost` above, // Because it only functions until `hostCache` is cleared, while we'll potentially need the functionality to lazily read sourcemap files during // the course of whatever called `synchronizeHostData` @@ -149172,6 +154309,36 @@ var ts; // pointers set property. program.getTypeChecker(); return; + function getParsedCommandLine(fileName) { + var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); + var existing = parsedCommandLines === null || parsedCommandLines === void 0 ? void 0 : parsedCommandLines.get(path); + if (existing !== undefined) + return existing || undefined; + var result = host.getParsedCommandLine ? + host.getParsedCommandLine(fileName) : + getParsedCommandLineOfConfigFileUsingSourceFile(fileName); + (parsedCommandLines || (parsedCommandLines = new ts.Map())).set(path, result || false); + return result; + } + function getParsedCommandLineOfConfigFileUsingSourceFile(configFileName) { + var result = getOrCreateSourceFile(configFileName, 100 /* JSON */); + if (!result) + return undefined; + result.path = ts.toPath(configFileName, currentDirectory, getCanonicalFileName); + result.resolvedPath = result.path; + result.originalFileName = result.fileName; + return ts.parseJsonSourceFileConfigFileContent(result, parseConfigHost, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), + /*optionsToExtend*/ undefined, ts.getNormalizedAbsolutePath(configFileName, currentDirectory)); + } + function onReleaseParsedCommandLine(configFileName, oldResolvedRef, oldOptions) { + var _a; + if (host.getParsedCommandLine) { + (_a = host.onReleaseParsedCommandLine) === null || _a === void 0 ? void 0 : _a.call(host, configFileName, oldResolvedRef, oldOptions); + } + else if (oldResolvedRef) { + onReleaseOldSourceFile(oldResolvedRef.sourceFile, oldOptions); + } + } function fileExists(fileName) { var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); var entry = hostCache && hostCache.getEntryByPath(path); @@ -149188,11 +154355,15 @@ var ts; } return host.readFile && host.readFile(fileName); } + function readDirectory(path, extensions, exclude, include, depth) { + ts.Debug.checkDefined(host.readDirectory, "'LanguageServiceHost.readDirectory' must be implemented to correctly process 'projectReferences'"); + return host.readDirectory(path, extensions, exclude, include, depth); + } // Release any files we have acquired in the old program but are // not part of the new program. function onReleaseOldSourceFile(oldSourceFile, oldOptions) { var oldSettingsKey = documentRegistry.getKeyForCompilationSettings(oldOptions); - documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, oldSettingsKey); + documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, oldSettingsKey, oldSourceFile.scriptKind); } function getOrCreateSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile) { return getOrCreateSourceFileByPath(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), languageVersion, onError, shouldCreateNewSourceFile); @@ -149237,8 +154408,13 @@ var ts; // We do not support the scenario where a host can modify a registered // file's script kind, i.e. in one project some file is treated as ".ts" // and in another as ".js" - ts.Debug.assertEqual(hostFileInformation.scriptKind, oldSourceFile.scriptKind, "Registered script kind should match new script kind."); - return documentRegistry.updateDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind); + if (hostFileInformation.scriptKind === oldSourceFile.scriptKind) { + return documentRegistry.updateDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind); + } + 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); + } } // We didn't already have the file. Fall through and acquire it from the registry. } @@ -149267,7 +154443,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); + return documentRegistry.releaseDocumentWithKey(f.resolvedPath, key_1, f.scriptKind); }); program = undefined; // TODO: GH#18217 } @@ -149310,10 +154486,10 @@ var ts; synchronizeHostData(); return ts.Completions.getCompletionsAtPosition(host, program, log, getValidSourceFile(fileName), position, fullPreferences, options.triggerCharacter); } - function getCompletionEntryDetails(fileName, position, name, formattingOptions, source, preferences) { + function getCompletionEntryDetails(fileName, position, name, formattingOptions, source, preferences, data) { if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); - return ts.Completions.getCompletionEntryDetails(program, log, getValidSourceFile(fileName), position, { name: name, source: source }, host, (formattingOptions && ts.formatting.getFormatContext(formattingOptions, host)), // TODO: GH#18217 + return ts.Completions.getCompletionEntryDetails(program, log, getValidSourceFile(fileName), position, { name: name, source: source, data: data }, host, (formattingOptions && ts.formatting.getFormatContext(formattingOptions, host)), // TODO: GH#18217 preferences, cancellationToken); } function getCompletionEntrySymbol(fileName, position, name, source, preferences) { @@ -149340,7 +154516,7 @@ var ts; 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, - tags: type_2.symbol ? type_2.symbol.getJsDocTags() : undefined + tags: type_2.symbol ? type_2.symbol.getJsDocTags(typeChecker) : undefined }; } var _a = typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { @@ -149359,19 +154535,23 @@ var ts; if (ts.isNewExpression(node.parent) && node.pos === node.parent.pos) { return node.parent.expression; } + if (ts.isNamedTupleMember(node.parent) && node.pos === node.parent.pos) { + return node.parent; + } return node; } function shouldGetType(sourceFile, node, position) { switch (node.kind) { - case 78 /* Identifier */: - return !ts.isLabelName(node) && !ts.isTagName(node); - case 201 /* PropertyAccessExpression */: - case 157 /* QualifiedName */: + case 79 /* Identifier */: + return !ts.isLabelName(node) && !ts.isTagName(node) && !ts.isConstTypeReference(node.parent); + case 203 /* PropertyAccessExpression */: + case 159 /* QualifiedName */: // Don't return quickInfo if inside the comment in `a/**/.b` return !ts.isInComment(sourceFile, position); - case 107 /* ThisKeyword */: - case 187 /* ThisType */: - case 105 /* SuperKeyword */: + case 108 /* ThisKeyword */: + case 189 /* ThisType */: + case 106 /* SuperKeyword */: + case 194 /* NamedTupleMember */: return true; default: return false; @@ -149476,16 +154656,16 @@ var ts; return undefined; } switch (node.kind) { - case 201 /* PropertyAccessExpression */: - case 157 /* QualifiedName */: + case 203 /* PropertyAccessExpression */: + case 159 /* QualifiedName */: case 10 /* StringLiteral */: - case 94 /* FalseKeyword */: - case 109 /* TrueKeyword */: - case 103 /* NullKeyword */: - case 105 /* SuperKeyword */: - case 107 /* ThisKeyword */: - case 187 /* ThisType */: - case 78 /* Identifier */: + case 95 /* FalseKeyword */: + case 110 /* TrueKeyword */: + case 104 /* NullKeyword */: + case 106 /* SuperKeyword */: + case 108 /* ThisKeyword */: + case 189 /* ThisType */: + case 79 /* Identifier */: break; // Cant create the text span default: @@ -149501,7 +154681,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 === 256 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 258 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -149529,15 +154709,7 @@ var ts; function getNavigationTree(fileName) { return ts.NavigationBar.getNavigationTree(syntaxTreeCache.getCurrentSourceFile(fileName), cancellationToken); } - function isTsOrTsxFile(fileName) { - var kind = ts.getScriptKind(fileName, host); - return kind === 3 /* TS */ || kind === 4 /* TSX */; - } function getSemanticClassifications(fileName, span, format) { - if (!isTsOrTsxFile(fileName)) { - // do not run semantic classification on non-ts-or-tsx files - return []; - } synchronizeHostData(); var responseFormat = format || "original" /* Original */; if (responseFormat === "2020" /* TwentyTwenty */) { @@ -149548,10 +154720,6 @@ var ts; } } function getEncodedSemanticClassifications(fileName, span, format) { - if (!isTsOrTsxFile(fileName)) { - // do not run semantic classification on non-ts-or-tsx files - return { spans: [], endOfLineState: 0 /* None */ }; - } synchronizeHostData(); var responseFormat = format || "original" /* Original */; if (responseFormat === "original" /* Original */) { @@ -149642,13 +154810,13 @@ var ts; var formatContext = ts.formatting.getFormatContext(formatOptions, host); return ts.codefix.getAllFixes({ fixId: fixId, sourceFile: sourceFile, program: program, host: host, cancellationToken: cancellationToken, formatContext: formatContext, preferences: preferences }); } - function organizeImports(scope, formatOptions, preferences) { + function organizeImports(args, formatOptions, preferences) { if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); - ts.Debug.assert(scope.type === "file"); - var sourceFile = getValidSourceFile(scope.fileName); + ts.Debug.assert(args.type === "file"); + var sourceFile = getValidSourceFile(args.fileName); var formatContext = ts.formatting.getFormatContext(formatOptions, host); - return ts.OrganizeImports.organizeImports(sourceFile, formatContext, host, program, preferences); + return ts.OrganizeImports.organizeImports(sourceFile, formatContext, host, program, preferences, args.skipDestructiveCodeActions); } function getEditsForFileRename(oldFilePath, newFilePath, formatOptions, preferences) { if (preferences === void 0) { preferences = ts.emptyOptions; } @@ -149665,8 +154833,8 @@ var ts; ? host.installPackage({ fileName: getPath(action.file), packageName: action.packageName }) : Promise.reject("Host does not implement `installPackage`"); } - function getDocCommentTemplateAtPosition(fileName, position) { - return ts.JsDoc.getDocCommentTemplateAtPosition(ts.getNewLineOrDefaultFromHost(host), syntaxTreeCache.getCurrentSourceFile(fileName), position); + function getDocCommentTemplateAtPosition(fileName, position, options) { + return ts.JsDoc.getDocCommentTemplateAtPosition(ts.getNewLineOrDefaultFromHost(host), syntaxTreeCache.getCurrentSourceFile(fileName), position, options); } function isValidBraceCompletionAtPosition(fileName, position, openingBrace) { // '<' is currently not supported, figuring out if we're in a Generic Type vs. a comparison is too @@ -150081,6 +155249,16 @@ var ts; var file = getValidSourceFile(fileName); return ts.refactor.getEditsForRefactor(getRefactorContext(file, positionOrRange, preferences, formatOptions), refactorName, actionName); } + function toLineColumnOffset(fileName, position) { + // Go to Definition supports returning a zero-length span at position 0 for + // non-existent files. We need to special-case the conversion of position 0 + // to avoid a crash trying to get the text for that file, since this function + // otherwise assumes that 'fileName' is the name of a file that exists. + if (position === 0) { + return { line: 0, character: 0 }; + } + return sourceMapper.toLineColumnOffset(fileName, position); + } function prepareCallHierarchy(fileName, position) { synchronizeHostData(); var declarations = ts.CallHierarchy.resolveCallHierarchyDeclaration(program, ts.getTouchingPropertyName(getValidSourceFile(fileName), position)); @@ -150153,7 +155331,7 @@ var ts; getAutoImportProvider: getAutoImportProvider, getApplicableRefactors: getApplicableRefactors, getEditsForRefactor: getEditsForRefactor, - toLineColumnOffset: sourceMapper.toLineColumnOffset, + toLineColumnOffset: toLineColumnOffset, getSourceMapper: function () { return sourceMapper; }, clearSourceMapperCache: function () { return sourceMapper.clearCache(); }, prepareCallHierarchy: prepareCallHierarchy, @@ -150224,7 +155402,7 @@ var ts; */ function literalIsName(node) { return ts.isDeclarationName(node) || - node.parent.kind === 272 /* ExternalModuleReference */ || + node.parent.kind === 274 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node); } @@ -150242,13 +155420,13 @@ var ts; case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: - if (node.parent.kind === 158 /* ComputedPropertyName */) { + if (node.parent.kind === 160 /* ComputedPropertyName */) { return ts.isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; } // falls through - case 78 /* Identifier */: + case 79 /* Identifier */: return ts.isObjectLiteralElement(node.parent) && - (node.parent.parent.kind === 200 /* ObjectLiteralExpression */ || node.parent.parent.kind === 281 /* JsxAttributes */) && + (node.parent.parent.kind === 202 /* ObjectLiteralExpression */ || node.parent.parent.kind === 283 /* JsxAttributes */) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -150290,7 +155468,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 202 /* ElementAccessExpression */ && + node.parent.kind === 204 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -150370,114 +155548,114 @@ var ts; if (node) { var parent = node.parent; switch (node.kind) { - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 249 /* VariableDeclaration */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 251 /* VariableDeclaration */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: return spanInVariableDeclaration(node); - case 160 /* Parameter */: + case 162 /* Parameter */: return spanInParameterDeclaration(node); - case 251 /* FunctionDeclaration */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 166 /* Constructor */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 253 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 168 /* Constructor */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 230 /* Block */: + case 232 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // falls through - case 257 /* ModuleBlock */: + case 259 /* ModuleBlock */: return spanInBlock(node); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return spanInBlock(node.block); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 236 /* WhileStatement */: + case 238 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 235 /* DoStatement */: + case 237 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 248 /* DebuggerStatement */: + case 250 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 234 /* IfStatement */: + case 236 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 241 /* BreakStatement */: - case 240 /* ContinueStatement */: + case 243 /* BreakStatement */: + case 242 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return spanInForStatement(node); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 284 /* CaseClause */: - case 285 /* DefaultClause */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 247 /* TryStatement */: + case 249 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 246 /* ThrowStatement */: + case 248 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } // falls through - case 252 /* ClassDeclaration */: - case 255 /* EnumDeclaration */: - case 291 /* EnumMember */: - case 198 /* BindingElement */: + case 254 /* ClassDeclaration */: + case 257 /* EnumDeclaration */: + case 293 /* EnumMember */: + case 200 /* BindingElement */: // span on complete node return textSpan(node); - case 243 /* WithStatement */: + case 245 /* WithStatement */: // span in statement return spanInNode(node.statement); - case 161 /* Decorator */: + case 163 /* Decorator */: return spanInNodeArray(parent.decorators); - case 196 /* ObjectBindingPattern */: - case 197 /* ArrayBindingPattern */: + case 198 /* ObjectBindingPattern */: + case 199 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: return undefined; // Tokens: case 26 /* SemicolonToken */: @@ -150501,13 +155679,13 @@ var ts; case 29 /* LessThanToken */: return spanInGreaterThanOrLessThanToken(node); // Keywords: - case 114 /* WhileKeyword */: + case 115 /* WhileKeyword */: return spanInWhileKeyword(node); - case 90 /* ElseKeyword */: - case 82 /* CatchKeyword */: - case 95 /* FinallyKeyword */: + case 91 /* ElseKeyword */: + case 83 /* CatchKeyword */: + case 96 /* FinallyKeyword */: return spanInNextNode(node); - case 156 /* OfKeyword */: + case 158 /* OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -150519,14 +155697,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 === 78 /* Identifier */ || - node.kind === 220 /* SpreadElement */ || - node.kind === 288 /* PropertyAssignment */ || - node.kind === 289 /* ShorthandPropertyAssignment */) && + if ((node.kind === 79 /* Identifier */ || + node.kind === 222 /* SpreadElement */ || + node.kind === 290 /* PropertyAssignment */ || + node.kind === 291 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(parent)) { return textSpan(node); } - if (node.kind === 216 /* BinaryExpression */) { + if (node.kind === 218 /* 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 @@ -150535,7 +155713,7 @@ var ts; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(left); } - if (operatorToken.kind === 62 /* EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { + if (operatorToken.kind === 63 /* EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { // Set breakpoint on assignment expression element of destructuring pattern // a = expression of // [a = expression, b, c] = someExpression or @@ -150548,22 +155726,22 @@ var ts; } if (ts.isExpressionNode(node)) { switch (parent.kind) { - case 235 /* DoStatement */: + case 237 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 161 /* Decorator */: + case 163 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 237 /* ForStatement */: - case 239 /* ForOfStatement */: + case 239 /* ForStatement */: + case 241 /* ForOfStatement */: return textSpan(node); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: if (node.parent.operatorToken.kind === 27 /* CommaToken */) { // If this is a comma expression, the breakpoint is possible in this expression return textSpan(node); } break; - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -150572,21 +155750,21 @@ var ts; } } switch (node.parent.kind) { - case 288 /* PropertyAssignment */: + case 290 /* 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 206 /* TypeAssertionExpression */: + case 208 /* TypeAssertionExpression */: // Breakpoint in type assertion goes to its operand if (node.parent.type === node) { return spanInNextNode(node.parent.type); } break; - case 249 /* VariableDeclaration */: - case 160 /* Parameter */: { + case 251 /* VariableDeclaration */: + case 162 /* 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)) { @@ -150594,7 +155772,7 @@ var ts; } break; } - case 216 /* BinaryExpression */: { + case 218 /* BinaryExpression */: { var left = node.parent.left; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left) && node !== left) { // If initializer of destructuring assignment move to previous token @@ -150624,7 +155802,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 238 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 240 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } var parent = variableDeclaration.parent; @@ -150636,7 +155814,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasSyntacticModifier(variableDeclaration, 1 /* Export */) || - parent.parent.kind === 239 /* ForOfStatement */) { + parent.parent.kind === 241 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } if (ts.isVariableDeclarationList(variableDeclaration.parent) && @@ -150677,7 +155855,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasSyntacticModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 252 /* ClassDeclaration */ && functionDeclaration.kind !== 166 /* Constructor */); + (functionDeclaration.parent.kind === 254 /* ClassDeclaration */ && functionDeclaration.kind !== 168 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -150700,26 +155878,26 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement // falls through - case 236 /* WhileStatement */: - case 234 /* IfStatement */: - case 238 /* ForInStatement */: + case 238 /* WhileStatement */: + case 236 /* IfStatement */: + case 240 /* 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 237 /* ForStatement */: - case 239 /* ForOfStatement */: + case 239 /* ForStatement */: + case 241 /* 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 === 250 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 252 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -150744,21 +155922,21 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 222 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 224 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 198 /* BindingElement */) { + if (bindingPattern.parent.kind === 200 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 197 /* ArrayBindingPattern */ && node.kind !== 196 /* ObjectBindingPattern */); - var elements = node.kind === 199 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 222 /* OmittedExpression */ ? element : undefined; }); + ts.Debug.assert(node.kind !== 199 /* ArrayBindingPattern */ && node.kind !== 198 /* ObjectBindingPattern */); + var elements = node.kind === 201 /* ArrayLiteralExpression */ ? node.elements : node.properties; + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 224 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -150766,18 +155944,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 === 216 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 218 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 258 /* CaseBlock */: + case 260 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -150785,25 +155963,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 257 /* ModuleBlock */: + case 259 /* ModuleBlock */: // If this is not an instantiated module block, no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } // falls through - case 255 /* EnumDeclaration */: - case 252 /* ClassDeclaration */: + case 257 /* EnumDeclaration */: + case 254 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 230 /* Block */: + case 232 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // falls through - case 287 /* CatchClause */: + case 289 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 258 /* CaseBlock */: + case 260 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -150811,7 +155989,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 196 /* ObjectBindingPattern */: + case 198 /* 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); @@ -150827,7 +156005,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 197 /* ArrayBindingPattern */: + case 199 /* 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); @@ -150842,12 +156020,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 235 /* DoStatement */ || // Go to while keyword and do action instead - node.parent.kind === 203 /* CallExpression */ || - node.parent.kind === 204 /* NewExpression */) { + if (node.parent.kind === 237 /* DoStatement */ || // Go to while keyword and do action instead + node.parent.kind === 205 /* CallExpression */ || + node.parent.kind === 206 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 207 /* ParenthesizedExpression */) { + if (node.parent.kind === 209 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -150856,21 +156034,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 166 /* Constructor */: - case 236 /* WhileStatement */: - case 235 /* DoStatement */: - case 237 /* ForStatement */: - case 239 /* ForOfStatement */: - case 203 /* CallExpression */: - case 204 /* NewExpression */: - case 207 /* ParenthesizedExpression */: + case 210 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 211 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 168 /* Constructor */: + case 238 /* WhileStatement */: + case 237 /* DoStatement */: + case 239 /* ForStatement */: + case 241 /* ForOfStatement */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: + case 209 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -150880,20 +156058,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 288 /* PropertyAssignment */ || - node.parent.kind === 160 /* Parameter */) { + node.parent.kind === 290 /* PropertyAssignment */ || + node.parent.kind === 162 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 206 /* TypeAssertionExpression */) { + if (node.parent.kind === 208 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 235 /* DoStatement */) { + if (node.parent.kind === 237 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -150901,7 +156079,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 239 /* ForOfStatement */) { + if (node.parent.kind === 241 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -151442,11 +156620,11 @@ var ts; return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ", " + preferences + ")", function () { return _this.languageService.getCompletionsAtPosition(fileName, position, preferences); }); }; /** Get a string based representation of a completion list entry details */ - LanguageServiceShimObject.prototype.getCompletionEntryDetails = function (fileName, position, entryName, formatOptions, source, preferences) { + LanguageServiceShimObject.prototype.getCompletionEntryDetails = function (fileName, position, entryName, formatOptions, source, preferences, data) { var _this = this; return this.forwardJSONCall("getCompletionEntryDetails('" + fileName + "', " + position + ", '" + entryName + "')", function () { var localOptions = formatOptions === undefined ? undefined : JSON.parse(formatOptions); - return _this.languageService.getCompletionEntryDetails(fileName, position, entryName, localOptions, source, preferences); + return _this.languageService.getCompletionEntryDetails(fileName, position, entryName, localOptions, source, preferences, data); }); }; LanguageServiceShimObject.prototype.getFormattingEditsForRange = function (fileName, start, end, options /*Services.FormatCodeOptions*/) { @@ -151470,9 +156648,9 @@ var ts; return _this.languageService.getFormattingEditsAfterKeystroke(fileName, position, key, localOptions); }); }; - LanguageServiceShimObject.prototype.getDocCommentTemplateAtPosition = function (fileName, position) { + LanguageServiceShimObject.prototype.getDocCommentTemplateAtPosition = function (fileName, position, options) { var _this = this; - return this.forwardJSONCall("getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position); }); + return this.forwardJSONCall("getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position, options); }); }; /// NAVIGATE TO /** Return a list of symbols that are interesting to navigate to */ @@ -152179,6 +157357,7 @@ var ts; WatchFileKind["FixedPollingInterval"] = "FixedPollingInterval"; WatchFileKind["PriorityPollingInterval"] = "PriorityPollingInterval"; WatchFileKind["DynamicPriorityPolling"] = "DynamicPriorityPolling"; + WatchFileKind["FixedChunkSizePolling"] = "FixedChunkSizePolling"; WatchFileKind["UseFsEvents"] = "UseFsEvents"; WatchFileKind["UseFsEventsOnParentDirectory"] = "UseFsEventsOnParentDirectory"; })(WatchFileKind = protocol.WatchFileKind || (protocol.WatchFileKind = {})); @@ -152187,12 +157366,14 @@ var ts; WatchDirectoryKind["UseFsEvents"] = "UseFsEvents"; WatchDirectoryKind["FixedPollingInterval"] = "FixedPollingInterval"; WatchDirectoryKind["DynamicPriorityPolling"] = "DynamicPriorityPolling"; + WatchDirectoryKind["FixedChunkSizePolling"] = "FixedChunkSizePolling"; })(WatchDirectoryKind = protocol.WatchDirectoryKind || (protocol.WatchDirectoryKind = {})); var PollingWatchKind; (function (PollingWatchKind) { PollingWatchKind["FixedInterval"] = "FixedInterval"; PollingWatchKind["PriorityInterval"] = "PriorityInterval"; PollingWatchKind["DynamicPriority"] = "DynamicPriority"; + PollingWatchKind["FixedChunkSize"] = "FixedChunkSize"; })(PollingWatchKind = protocol.PollingWatchKind || (protocol.PollingWatchKind = {})); var IndentStyle; (function (IndentStyle) { @@ -152245,8 +157426,37 @@ var ts; ScriptTarget["ES2018"] = "ES2018"; ScriptTarget["ES2019"] = "ES2019"; ScriptTarget["ES2020"] = "ES2020"; + ScriptTarget["ES2021"] = "ES2021"; ScriptTarget["ESNext"] = "ESNext"; })(ScriptTarget = protocol.ScriptTarget || (protocol.ScriptTarget = {})); + var ClassificationType; + (function (ClassificationType) { + ClassificationType[ClassificationType["comment"] = 1] = "comment"; + ClassificationType[ClassificationType["identifier"] = 2] = "identifier"; + ClassificationType[ClassificationType["keyword"] = 3] = "keyword"; + ClassificationType[ClassificationType["numericLiteral"] = 4] = "numericLiteral"; + ClassificationType[ClassificationType["operator"] = 5] = "operator"; + ClassificationType[ClassificationType["stringLiteral"] = 6] = "stringLiteral"; + ClassificationType[ClassificationType["regularExpressionLiteral"] = 7] = "regularExpressionLiteral"; + ClassificationType[ClassificationType["whiteSpace"] = 8] = "whiteSpace"; + ClassificationType[ClassificationType["text"] = 9] = "text"; + ClassificationType[ClassificationType["punctuation"] = 10] = "punctuation"; + ClassificationType[ClassificationType["className"] = 11] = "className"; + ClassificationType[ClassificationType["enumName"] = 12] = "enumName"; + ClassificationType[ClassificationType["interfaceName"] = 13] = "interfaceName"; + ClassificationType[ClassificationType["moduleName"] = 14] = "moduleName"; + ClassificationType[ClassificationType["typeParameterName"] = 15] = "typeParameterName"; + ClassificationType[ClassificationType["typeAliasName"] = 16] = "typeAliasName"; + ClassificationType[ClassificationType["parameterName"] = 17] = "parameterName"; + ClassificationType[ClassificationType["docCommentTagName"] = 18] = "docCommentTagName"; + ClassificationType[ClassificationType["jsxOpenTagName"] = 19] = "jsxOpenTagName"; + ClassificationType[ClassificationType["jsxCloseTagName"] = 20] = "jsxCloseTagName"; + ClassificationType[ClassificationType["jsxSelfClosingTagName"] = 21] = "jsxSelfClosingTagName"; + ClassificationType[ClassificationType["jsxAttribute"] = 22] = "jsxAttribute"; + ClassificationType[ClassificationType["jsxText"] = 23] = "jsxText"; + ClassificationType[ClassificationType["jsxAttributeStringLiteralValue"] = 24] = "jsxAttributeStringLiteralValue"; + ClassificationType[ClassificationType["bigintLiteral"] = 25] = "bigintLiteral"; + })(ClassificationType = protocol.ClassificationType || (protocol.ClassificationType = {})); })(protocol = server.protocol || (server.protocol = {})); })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); @@ -152442,7 +157652,7 @@ var ts; if (this.pendingReloadFromDisk) { this.reloadWithFileText(); } - // At this point if svc is present its valid + // At this point if svc is present it's valid return this.svc; }; TextStorage.prototype.getOrLoadText = function () { @@ -152558,16 +157768,24 @@ var ts; ScriptInfo.prototype.getRealpathIfDifferent = function () { return this.realpath && this.realpath !== this.path ? this.realpath : undefined; }; + /** + * @internal + * Does not compute realpath; uses precomputed result. Use `ensureRealPath` + * first if a definite result is needed. + */ + ScriptInfo.prototype.isSymlink = function () { + return this.realpath && this.realpath !== this.path; + }; ScriptInfo.prototype.getFormatCodeSettings = function () { return this.formatSettings; }; ScriptInfo.prototype.getPreferences = function () { return this.preferences; }; ScriptInfo.prototype.attachToProject = function (project) { var isNew = !this.isAttached(project); if (isNew) { this.containingProjects.push(project); - project.onFileAddedOrRemoved(); if (!project.getCompilerOptions().preserveSymlinks) { this.ensureRealPath(); } + project.onFileAddedOrRemoved(this.isSymlink()); } return isNew; }; @@ -152587,23 +157805,23 @@ var ts; return; case 1: if (this.containingProjects[0] === project) { - project.onFileAddedOrRemoved(); + project.onFileAddedOrRemoved(this.isSymlink()); this.containingProjects.pop(); } break; case 2: if (this.containingProjects[0] === project) { - project.onFileAddedOrRemoved(); + project.onFileAddedOrRemoved(this.isSymlink()); this.containingProjects[0] = this.containingProjects.pop(); } else if (this.containingProjects[1] === project) { - project.onFileAddedOrRemoved(); + project.onFileAddedOrRemoved(this.isSymlink()); this.containingProjects.pop(); } break; default: if (ts.unorderedRemoveItem(this.containingProjects, project)) { - project.onFileAddedOrRemoved(); + project.onFileAddedOrRemoved(this.isSymlink()); } break; } @@ -152617,6 +157835,7 @@ var ts; var existingRoot = p.getRootFilesMap().get(this.path); // detach is unnecessary since we'll clean the list of containing projects anyways p.removeFile(this, /*fileExists*/ false, /*detachFromProjects*/ false); + p.onFileAddedOrRemoved(this.isSymlink()); // If the info was for the external or configured project's root, // add missing file as the root if (existingRoot && !server.isInferredProject(p)) { @@ -153013,6 +158232,8 @@ var ts; this.cachedUnresolvedImportsPerFile = new ts.Map(); /*@internal*/ this.hasAddedorRemovedFiles = false; + /*@internal*/ + this.hasAddedOrRemovedSymlinks = false; /** * Last version that was reported. */ @@ -153035,7 +158256,9 @@ var ts; /*@internal*/ this.typingFiles = server.emptyArray; /*@internal*/ - this.importSuggestionsCache = ts.Completions.createImportSuggestionsForFileCache(); + this.exportMapCache = ts.createExportMapCache(); + /*@internal*/ + this.moduleSpecifierCache = ts.createModuleSpecifierCache(); /*@internal*/ this.globalCacheResolutionModuleName = ts.JsTyping.nonRelativeModuleNameForTypingCache; this.directoryStructureHost = directoryStructureHost; @@ -153358,7 +158581,7 @@ var ts; return []; } server.updateProjectIfDirty(this); - this.builderState = ts.BuilderState.create(this.program, this.projectService.toCanonicalFileName, this.builderState); + 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; }); }; /** @@ -153661,8 +158884,8 @@ var ts; /*@internal*/ Project.prototype.markFileAsDirty = function (changedFile) { this.markAsDirty(); - if (!this.importSuggestionsCache.isEmpty()) { - (this.dirtyFilesForSuggestions || (this.dirtyFilesForSuggestions = new ts.Set())).add(changedFile); + if (!this.exportMapCache.isEmpty()) { + (this.changedFilesForExportMapCache || (this.changedFilesForExportMapCache = new ts.Set())).add(changedFile); } }; Project.prototype.markAsDirty = function () { @@ -153672,17 +158895,31 @@ var ts; } }; /*@internal*/ - Project.prototype.markAutoImportProviderAsDirty = function () { + Project.prototype.onAutoImportProviderSettingsChanged = function () { var _a; if (this.autoImportProviderHost === false) { this.autoImportProviderHost = undefined; } - (_a = this.autoImportProviderHost) === null || _a === void 0 ? void 0 : _a.markAsDirty(); - this.importSuggestionsCache.clear(); + else { + (_a = this.autoImportProviderHost) === null || _a === void 0 ? void 0 : _a.markAsDirty(); + } + }; + /*@internal*/ + Project.prototype.onPackageJsonChange = function (packageJsonPath) { + var _a; + if ((_a = this.packageJsonsForAutoImport) === null || _a === void 0 ? void 0 : _a.has(packageJsonPath)) { + this.moduleSpecifierCache.clear(); + if (this.autoImportProviderHost) { + this.autoImportProviderHost.markAsDirty(); + } + } }; /* @internal */ - Project.prototype.onFileAddedOrRemoved = function () { + Project.prototype.onFileAddedOrRemoved = function (isSymlink) { this.hasAddedorRemovedFiles = true; + if (isSymlink) { + this.hasAddedOrRemovedSymlinks = true; + } }; /** * Updates set of files that contribute to this project @@ -153695,6 +158932,7 @@ var ts; var hasNewProgram = this.updateGraphWorker(); var hasAddedorRemovedFiles = this.hasAddedorRemovedFiles; this.hasAddedorRemovedFiles = false; + this.hasAddedOrRemovedSymlinks = false; var changedFiles = this.resolutionCache.finishRecordingFilesWithChangedResolutions() || server.emptyArray; for (var _i = 0, changedFiles_1 = changedFiles; _i < changedFiles_1.length; _i++) { var file = changedFiles_1[_i]; @@ -153737,11 +158975,14 @@ var ts; /*@internal*/ Project.prototype.updateTypingFiles = function (typingFiles) { var _this = this; - ts.enumerateInsertsAndDeletes(typingFiles, this.typingFiles, ts.getStringComparer(!this.useCaseSensitiveFileNames()), - /*inserted*/ ts.noop, function (removed) { return _this.detachScriptInfoFromProject(removed); }); - this.typingFiles = typingFiles; - // Invalidate files with unresolved imports - this.resolutionCache.setFilesWithInvalidatedNonRelativeUnresolvedImports(this.cachedUnresolvedImportsPerFile); + if (ts.enumerateInsertsAndDeletes(typingFiles, this.typingFiles, ts.getStringComparer(!this.useCaseSensitiveFileNames()), + /*inserted*/ ts.noop, function (removed) { return _this.detachScriptInfoFromProject(removed); })) { + // If typing files changed, then only schedule project update + this.typingFiles = typingFiles; + // Invalidate files with unresolved imports + this.resolutionCache.setFilesWithInvalidatedNonRelativeUnresolvedImports(this.cachedUnresolvedImportsPerFile); + this.projectService.delayUpdateProjectGraphAndEnsureProjectStructureForOpenFiles(this); + } }; /* @internal */ Project.prototype.getCurrentProgram = function () { @@ -153766,8 +159007,9 @@ var ts; // 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 = this.program && (!oldProgram || (this.program !== oldProgram && !(this.program.structureIsReused & 2 /* Completely */))); - if (hasNewProgram) { + var hasNewProgram = false; + if (this.program && (!oldProgram || (this.program !== oldProgram && this.program.structureIsReused !== 2 /* Completely */))) { + hasNewProgram = true; if (oldProgram) { for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { var f = _a[_i]; @@ -153819,26 +159061,29 @@ var ts; this.resolutionCache.updateTypeRootsWatch(); } } - if (!this.importSuggestionsCache.isEmpty()) { + if (!this.exportMapCache.isEmpty()) { if (this.hasAddedorRemovedFiles || oldProgram && !this.program.structureIsReused) { - this.importSuggestionsCache.clear(); - } - else if (this.dirtyFilesForSuggestions && oldProgram && this.program) { - ts.forEachKey(this.dirtyFilesForSuggestions, function (fileName) { - var oldSourceFile = oldProgram.getSourceFile(fileName); - var sourceFile = _this.program.getSourceFile(fileName); - if (_this.sourceFileHasChangedOwnImportSuggestions(oldSourceFile, sourceFile)) { - _this.importSuggestionsCache.clear(); + this.exportMapCache.clear(); + } + else if (this.changedFilesForExportMapCache && oldProgram && this.program) { + ts.forEachKey(this.changedFilesForExportMapCache, function (fileName) { + var oldSourceFile = oldProgram.getSourceFileByPath(fileName); + var sourceFile = _this.program.getSourceFileByPath(fileName); + if (!oldSourceFile || !sourceFile) { + _this.exportMapCache.clear(); return true; } + return _this.exportMapCache.onFileChanged(oldSourceFile, sourceFile, !!_this.getTypeAcquisition().enable); }); } } - if (this.dirtyFilesForSuggestions) { - this.dirtyFilesForSuggestions.clear(); + if (this.changedFilesForExportMapCache) { + this.changedFilesForExportMapCache.clear(); } - if (this.hasAddedorRemovedFiles) { + if (this.hasAddedOrRemovedSymlinks || this.program && !this.program.structureIsReused && this.getCompilerOptions().preserveSymlinks) { + // With --preserveSymlinks, we may not determine that a file is a symlink, so we never set `hasAddedOrRemovedSymlinks` this.symlinks = undefined; + this.moduleSpecifierCache.clear(); } var oldExternalFiles = this.externalFiles || server.emptyArray; this.externalFiles = this.getExternalFiles(); @@ -153852,12 +159097,12 @@ 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 + " Elapsed: " + elapsed + "ms"); + this.writeLog("Finishing updateGraphWorker: Project: " + this.getProjectName() + " Version: " + this.getProjectVersion() + " structureChanged: " + hasNewProgram + (this.program ? " structureIsReused:: " + ts.StructureIsReused[this.program.structureIsReused] : "") + " Elapsed: " + elapsed + "ms"); if (this.hasAddedorRemovedFiles) { this.print(/*writeProjectFileNames*/ true); } else if (this.program !== oldProgram) { - this.writeLog("Different program with same set of files:: structureIsReused:: " + this.program.structureIsReused); + this.writeLog("Different program with same set of files"); } return hasNewProgram; }; @@ -153865,54 +159110,6 @@ var ts; Project.prototype.sendPerformanceEvent = function (kind, durationMs) { this.projectService.sendPerformanceEvent(kind, durationMs); }; - /*@internal*/ - Project.prototype.sourceFileHasChangedOwnImportSuggestions = function (oldSourceFile, newSourceFile) { - if (!oldSourceFile && !newSourceFile) { - return false; - } - // Probably shouldn’t get this far, but on the off chance the file was added or removed, - // we can’t reliably tell anything about it. - if (!oldSourceFile || !newSourceFile) { - return true; - } - ts.Debug.assertEqual(oldSourceFile.fileName, newSourceFile.fileName); - // If ATA is enabled, auto-imports uses existing imports to guess whether you want auto-imports from node. - // Adding or removing imports from node could change the outcome of that guess, so could change the suggestions list. - if (this.getTypeAcquisition().enable && ts.consumesNodeCoreModules(oldSourceFile) !== ts.consumesNodeCoreModules(newSourceFile)) { - return true; - } - // Module agumentation and ambient module changes can add or remove exports available to be auto-imported. - // Changes elsewhere in the file can change the *type* of an export in a module augmentation, - // but type info is gathered in getCompletionEntryDetails, which doesn’t use the cache. - if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations) || - !this.ambientModuleDeclarationsAreEqual(oldSourceFile, newSourceFile)) { - return true; - } - return false; - }; - /*@internal*/ - Project.prototype.ambientModuleDeclarationsAreEqual = function (oldSourceFile, newSourceFile) { - if (!ts.arrayIsEqualTo(oldSourceFile.ambientModuleNames, newSourceFile.ambientModuleNames)) { - return false; - } - var oldFileStatementIndex = -1; - var newFileStatementIndex = -1; - var _loop_1 = function (ambientModuleName) { - var isMatchingModuleDeclaration = function (node) { return ts.isNonGlobalAmbientModule(node) && node.name.text === ambientModuleName; }; - oldFileStatementIndex = ts.findIndex(oldSourceFile.statements, isMatchingModuleDeclaration, oldFileStatementIndex + 1); - newFileStatementIndex = ts.findIndex(newSourceFile.statements, isMatchingModuleDeclaration, newFileStatementIndex + 1); - if (oldSourceFile.statements[oldFileStatementIndex] !== newSourceFile.statements[newFileStatementIndex]) { - return { value: false }; - } - }; - for (var _i = 0, _a = newSourceFile.ambientModuleNames; _i < _a.length; _i++) { - var ambientModuleName = _a[_i]; - var state_1 = _loop_1(ambientModuleName); - if (typeof state_1 === "object") - return state_1.value; - } - return true; - }; Project.prototype.detachScriptInfoFromProject = function (uncheckedFileName, noRemoveResolution) { var scriptInfoToDetach = this.projectService.getScriptInfo(uncheckedFileName); if (scriptInfoToDetach) { @@ -153924,6 +159121,13 @@ var ts; }; Project.prototype.addMissingFileWatcher = function (missingFilePath) { var _this = this; + var _a; + if (isConfiguredProject(this)) { + // If this file is referenced config file, we are already watching it, no need to watch again + var configFileExistenceInfo = this.projectService.configFileExistenceInfoCache.get(missingFilePath); + if ((_a = configFileExistenceInfo === null || configFileExistenceInfo === void 0 ? void 0 : configFileExistenceInfo.config) === null || _a === void 0 ? void 0 : _a.projects.has(this.canonicalConfigFilePath)) + return ts.noopFileWatcher; + } var fileWatcher = this.projectService.watchFactory.watchFile(missingFilePath, function (fileName, eventKind) { if (isConfiguredProject(_this)) { _this.getCachedDirectoryStructureHost().addOrDeleteFile(fileName, missingFilePath, eventKind); @@ -154171,7 +159375,7 @@ var ts; ts.combinePaths(this.projectService.getExecutingFilePath(), "../../.."), ]); if (this.projectService.globalPlugins) { - var _loop_2 = function (globalPluginName) { + var _loop_1 = function (globalPluginName) { // Skip empty names from odd commandline parses if (!globalPluginName) return "continue"; @@ -154186,13 +159390,17 @@ var ts; // Enable global plugins with synthetic configuration entries for (var _i = 0, _a = this.projectService.globalPlugins; _i < _a.length; _i++) { var globalPluginName = _a[_i]; - _loop_2(globalPluginName); + _loop_1(globalPluginName); } } }; Project.prototype.enablePlugin = function (pluginConfigEntry, searchPaths, pluginConfigOverrides) { var _this = this; this.projectService.logger.info("Enabling plugin " + pluginConfigEntry.name + " from candidate paths: " + searchPaths.join(",")); + if (!pluginConfigEntry.name || ts.parsePackageName(pluginConfigEntry.name).rest) { + this.projectService.logger.info("Skipped loading plugin " + (pluginConfigEntry.name || JSON.stringify(pluginConfigEntry)) + " because only package name is allowed plugin name"); + return; + } var log = function (message) { return _this.projectService.logger.info(message); }; var errorLogs; var logError = function (message) { (errorLogs || (errorLogs = [])).push(message); }; @@ -154237,7 +159445,7 @@ var ts; newLS[k] = this.languageService[k]; } } - this.projectService.logger.info("Plugin validation succeded"); + this.projectService.logger.info("Plugin validation succeeded"); this.languageService = newLS; this.plugins.push({ name: configEntry.name, module: pluginModule }); } @@ -154274,8 +159482,12 @@ var ts; return packageJsons; }; /*@internal*/ - Project.prototype.getImportSuggestionsCache = function () { - return this.importSuggestionsCache; + Project.prototype.getExportMapCache = function () { + return this.exportMapCache; + }; + /*@internal*/ + Project.prototype.getModuleSpecifierCache = function () { + return this.moduleSpecifierCache; }; /*@internal*/ Project.prototype.includePackageJsonAutoImports = function () { @@ -154362,10 +159574,6 @@ var ts; return unresolvedImports || server.emptyArray; }); } - function createProjectNameFactoryWithCounter(nameFactory) { - var nextId = 1; - return function () { return nameFactory(nextId++); }; - } /** * If a file is opened and no tsconfig (or jsconfig) is found, * the file and its imports/references are put into an InferredProject. @@ -154374,7 +159582,7 @@ var ts; __extends(InferredProject, _super); /*@internal*/ function InferredProject(projectService, documentRegistry, compilerOptions, watchOptions, projectRootPath, currentDirectory, pluginConfigOverrides, typeAcquisition) { - var _this = _super.call(this, InferredProject.newName(), ProjectKind.Inferred, projectService, documentRegistry, + var _this = _super.call(this, projectService.newInferredProjectName(), ProjectKind.Inferred, projectService, documentRegistry, // TODO: GH#18217 /*files*/ undefined, /*lastFileExceededProgramSize*/ undefined, compilerOptions, @@ -154449,7 +159657,6 @@ var ts; exclude: ts.emptyArray }; }; - InferredProject.newName = createProjectNameFactoryWithCounter(server.makeInferredProjectName); return InferredProject; }(Project)); server.InferredProject = InferredProject; @@ -154457,17 +159664,19 @@ var ts; __extends(AutoImportProviderProject, _super); /*@internal*/ function AutoImportProviderProject(hostProject, initialRootNames, documentRegistry, compilerOptions) { - var _this = _super.call(this, AutoImportProviderProject.newName(), ProjectKind.AutoImportProvider, hostProject.projectService, documentRegistry, + var _this = _super.call(this, hostProject.projectService.newAutoImportProviderProjectName(), ProjectKind.AutoImportProvider, hostProject.projectService, documentRegistry, /*hasExplicitListOfFiles*/ false, /*lastFileExceededProgramSize*/ undefined, compilerOptions, /*compileOnSaveEnabled*/ false, hostProject.getWatchOptions(), hostProject.projectService.host, hostProject.currentDirectory) || this; _this.hostProject = hostProject; _this.rootFileNames = initialRootNames; + _this.useSourceOfProjectReferenceRedirect = ts.maybeBind(_this.hostProject, _this.hostProject.useSourceOfProjectReferenceRedirect); + _this.getParsedCommandLine = ts.maybeBind(_this.hostProject, _this.hostProject.getParsedCommandLine); return _this; } /*@internal*/ AutoImportProviderProject.getRootFileNames = function (dependencySelection, hostProject, moduleResolutionHost, compilerOptions) { - var _a, _b, _c, _d; + var _a, _b, _c; if (!dependencySelection) { return ts.emptyArray; } @@ -154482,18 +159691,22 @@ var ts; } if (dependencyNames) { var resolutions = ts.map(ts.arrayFrom(dependencyNames.keys()), function (name) { return ts.resolveTypeReferenceDirective(name, rootFileName, compilerOptions, moduleResolutionHost); }); - for (var _e = 0, resolutions_1 = resolutions; _e < resolutions_1.length; _e++) { - var resolution = resolutions_1[_e]; + var program = hostProject.getCurrentProgram(); + var symlinkCache = hostProject.getSymlinkCache(); + for (var _d = 0, resolutions_1 = resolutions; _d < resolutions_1.length; _d++) { + var resolution = resolutions_1[_d]; if (!((_c = resolution.resolvedTypeReferenceDirective) === null || _c === void 0 ? void 0 : _c.resolvedFileName)) continue; - var resolvedFileName = resolution.resolvedTypeReferenceDirective.resolvedFileName; - var fileName = ((_d = moduleResolutionHost.realpath) === null || _d === void 0 ? void 0 : _d.call(moduleResolutionHost, resolvedFileName)) || resolvedFileName; - if (!hostProject.getCurrentProgram().getSourceFile(fileName) && !hostProject.getCurrentProgram().getSourceFile(resolvedFileName)) { - rootNames = ts.append(rootNames, fileName); + var _e = resolution.resolvedTypeReferenceDirective, resolvedFileName = _e.resolvedFileName, originalPath = _e.originalPath; + if (!program.getSourceFile(resolvedFileName) && (!originalPath || !program.getSourceFile(originalPath))) { + rootNames = ts.append(rootNames, resolvedFileName); // Avoid creating a large project that would significantly slow down time to editor interactivity if (dependencySelection === 2 /* Auto */ && rootNames.length > this.maxDependencies) { return ts.emptyArray; } + if (originalPath) { + symlinkCache.setSymlinkedDirectoryFromSymlinkedFile(originalPath, resolvedFileName); + } } } } @@ -154509,7 +159722,7 @@ var ts; if (dependencySelection === 0 /* Off */) { return undefined; } - var compilerOptions = __assign(__assign({}, hostProject.getCompilerOptions()), { noLib: true, diagnostics: false, skipLibCheck: true, types: ts.emptyArray, lib: ts.emptyArray, sourceMap: false }); + var compilerOptions = __assign(__assign({}, hostProject.getCompilerOptions()), this.compilerOptionsOverrides); var rootNames = this.getRootFileNames(dependencySelection, hostProject, moduleResolutionHost, compilerOptions); if (!rootNames.length) { return undefined; @@ -154530,8 +159743,12 @@ var ts; } this.projectService.setFileNamesOfAutoImportProviderProject(this, rootFileNames); this.rootFileNames = rootFileNames; - this.hostProject.getImportSuggestionsCache().clear(); - return _super.prototype.updateGraph.call(this); + var oldProgram = this.getCurrentProgram(); + var hasSameSetOfFiles = _super.prototype.updateGraph.call(this); + if (oldProgram && oldProgram !== this.getCurrentProgram()) { + this.hostProject.getExportMapCache().clear(); + } + return hasSameSetOfFiles; }; AutoImportProviderProject.prototype.hasRoots = function () { var _a; @@ -154547,18 +159764,20 @@ var ts; AutoImportProviderProject.prototype.getLanguageService = function () { throw new Error("AutoImportProviderProject language service should never be used. To get the program, use `project.getCurrentProgram()`."); }; - AutoImportProviderProject.prototype.markAutoImportProviderAsDirty = function () { + /*@internal*/ + AutoImportProviderProject.prototype.onAutoImportProviderSettingsChanged = function () { throw new Error("AutoImportProviderProject is an auto import provider; use `markAsDirty()` instead."); }; + /*@internal*/ + AutoImportProviderProject.prototype.onPackageJsonChange = function () { + throw new Error("package.json changes should be notified on an AutoImportProvider's host project"); + }; AutoImportProviderProject.prototype.getModuleResolutionHostForAutoImportProvider = function () { throw new Error("AutoImportProviderProject cannot provide its own host; use `hostProject.getModuleResolutionHostForAutomImportProvider()` instead."); }; AutoImportProviderProject.prototype.getProjectReferences = function () { return this.hostProject.getProjectReferences(); }; - AutoImportProviderProject.prototype.useSourceOfProjectReferenceRedirect = function () { - return true; - }; /*@internal*/ AutoImportProviderProject.prototype.includePackageJsonAutoImports = function () { return 0 /* Off */; @@ -154570,9 +159789,17 @@ var ts; AutoImportProviderProject.prototype.getSymlinkCache = function () { return this.hostProject.getSymlinkCache(); }; - AutoImportProviderProject.newName = createProjectNameFactoryWithCounter(server.makeAutoImportProviderProjectName); /*@internal*/ AutoImportProviderProject.maxDependencies = 10; + /*@internal*/ + AutoImportProviderProject.compilerOptionsOverrides = { + diagnostics: false, + skipLibCheck: true, + sourceMap: false, + types: ts.emptyArray, + lib: ts.emptyArray, + noLib: true, + }; return AutoImportProviderProject; }(Project)); server.AutoImportProviderProject = AutoImportProviderProject; @@ -154584,13 +159811,14 @@ var ts; var ConfiguredProject = /** @class */ (function (_super) { __extends(ConfiguredProject, _super); /*@internal*/ - function ConfiguredProject(configFileName, projectService, documentRegistry, cachedDirectoryStructureHost) { + function ConfiguredProject(configFileName, canonicalConfigFilePath, projectService, documentRegistry, cachedDirectoryStructureHost) { var _this = _super.call(this, configFileName, ProjectKind.Configured, projectService, documentRegistry, /*hasExplicitListOfFiles*/ false, /*lastFileExceededProgramSize*/ undefined, /*compilerOptions*/ {}, /*compileOnSaveEnabled*/ false, /*watchOptions*/ undefined, cachedDirectoryStructureHost, ts.getDirectoryPath(configFileName)) || this; + _this.canonicalConfigFilePath = canonicalConfigFilePath; /* @internal */ _this.openFileWatchTriggered = new ts.Map(); /*@internal*/ @@ -154601,7 +159829,6 @@ var ts; _this.isInitialLoadPending = ts.returnTrue; /*@internal*/ _this.sendLoadingProjectFinish = false; - _this.canonicalConfigFilePath = server.asNormalizedPath(projectService.toCanonicalFileName(configFileName)); return _this; } /* @internal */ @@ -154617,22 +159844,30 @@ var ts; return this.languageServiceEnabled; }; /* @internal */ - ConfiguredProject.prototype.setWatchOptions = function (watchOptions) { - var oldOptions = this.getWatchOptions(); - _super.prototype.setWatchOptions.call(this, watchOptions); - // If watch options different than older options - if (this.isInitialLoadPending() && - !ts.isJsonEqual(oldOptions, this.getWatchOptions())) { - var oldWatcher = this.configFileWatcher; - this.createConfigFileWatcher(); - if (oldWatcher) - oldWatcher.close(); + ConfiguredProject.prototype.getParsedCommandLine = function (fileName) { + var configFileName = server.asNormalizedPath(ts.normalizePath(fileName)); + var canonicalConfigFilePath = server.asNormalizedPath(this.projectService.toCanonicalFileName(configFileName)); + // Ensure the config file existience info is cached + var configFileExistenceInfo = this.projectService.configFileExistenceInfoCache.get(canonicalConfigFilePath); + if (!configFileExistenceInfo) { + this.projectService.configFileExistenceInfoCache.set(canonicalConfigFilePath, configFileExistenceInfo = { exists: this.projectService.host.fileExists(configFileName) }); + } + // Ensure we have upto date parsed command line + this.projectService.ensureParsedConfigUptoDate(configFileName, canonicalConfigFilePath, configFileExistenceInfo, this); + // Watch wild cards if LS is enabled + if (this.languageServiceEnabled && this.projectService.serverMode === ts.LanguageServiceMode.Semantic) { + this.projectService.watchWildcards(configFileName, configFileExistenceInfo, this); } + return configFileExistenceInfo.exists ? configFileExistenceInfo.config.parsedCommandLine : undefined; }; /* @internal */ - ConfiguredProject.prototype.createConfigFileWatcher = function () { - var _this = this; - this.configFileWatcher = this.projectService.watchFactory.watchFile(this.getConfigFilePath(), function (_fileName, eventKind) { return _this.projectService.onConfigChangedForConfiguredProject(_this, eventKind); }, ts.PollingInterval.High, this.projectService.getWatchOptions(this), ts.WatchType.ConfigFile, this); + ConfiguredProject.prototype.onReleaseParsedCommandLine = function (fileName) { + this.releaseParsedConfig(server.asNormalizedPath(this.projectService.toCanonicalFileName(server.asNormalizedPath(ts.normalizePath(fileName))))); + }; + /* @internal */ + ConfiguredProject.prototype.releaseParsedConfig = function (canonicalConfigFilePath) { + this.projectService.stopWatchingWildCards(canonicalConfigFilePath, this); + this.projectService.releaseParsedConfig(canonicalConfigFilePath, this); }; /** * If the project has reload from disk pending, it reloads (and then updates graph as part of that) instead of just updating the graph @@ -154732,27 +159967,11 @@ var ts; ConfiguredProject.prototype.setProjectErrors = function (projectErrors) { this.projectErrors = projectErrors; }; - /*@internal*/ - ConfiguredProject.prototype.watchWildcards = function (wildcardDirectories) { - var _this = this; - ts.updateWatchingWildcardDirectories(this.directoriesWatchedForWildcards || (this.directoriesWatchedForWildcards = new ts.Map()), wildcardDirectories, - // Create new directory watcher - function (directory, flags) { return _this.projectService.watchWildcardDirectory(directory, flags, _this); }); - }; - /*@internal*/ - ConfiguredProject.prototype.stopWatchingWildCards = function () { - if (this.directoriesWatchedForWildcards) { - ts.clearMap(this.directoriesWatchedForWildcards, ts.closeFileWatcherOf); - this.directoriesWatchedForWildcards = undefined; - } - }; ConfiguredProject.prototype.close = function () { - if (this.configFileWatcher) { - this.configFileWatcher.close(); - this.configFileWatcher = undefined; - } - this.stopWatchingWildCards(); - this.projectService.removeProjectFromSharedExtendedConfigFileMap(this); + var _this = this; + this.projectService.configFileExistenceInfoCache.forEach(function (_configFileExistenceInfo, canonicalConfigFilePath) { + return _this.releaseParsedConfig(canonicalConfigFilePath); + }); this.projectErrors = undefined; this.openFileWatchTriggered.clear(); this.compilerHost = undefined; @@ -154782,6 +160001,7 @@ var ts; /* @internal */ ConfiguredProject.prototype.hasOpenRef = function () { var _this = this; + var _a; if (!!this.externalProjectRefCount) { return true; } @@ -154789,17 +160009,17 @@ var ts; if (this.isClosed()) { return false; } - var configFileExistenceInfo = this.projectService.getConfigFileExistenceInfo(this); + var configFileExistenceInfo = this.projectService.configFileExistenceInfoCache.get(this.canonicalConfigFilePath); if (this.projectService.hasPendingProjectUpdate(this)) { // If there is pending update for this project, // we dont know if this project would be needed by any of the open files impacted by this config file // In that case keep the project alive if there are open files impacted by this project - return !!configFileExistenceInfo.openFilesImpactedByConfigFile.size; + return !!((_a = configFileExistenceInfo.openFilesImpactedByConfigFile) === null || _a === void 0 ? void 0 : _a.size); } // If there is no pending update for this project, // We know exact set of open files that get impacted by this configured project as the files in the project // The project is referenced only if open files impacted by this project are present in this project - return ts.forEachEntry(configFileExistenceInfo.openFilesImpactedByConfigFile, function (_value, infoPath) { + return !!configFileExistenceInfo.openFilesImpactedByConfigFile && ts.forEachEntry(configFileExistenceInfo.openFilesImpactedByConfigFile, function (_value, infoPath) { var info = _this.projectService.getScriptInfoForPath(infoPath); return _this.containsScriptInfo(info) || !!server.forEachResolvedProjectReferenceProject(_this, info.path, function (child) { return child.containsScriptInfo(info); }, server.ProjectReferenceProjectLoadKind.Find); @@ -154922,7 +160142,7 @@ var ts; var defaultTypeSafeList = { "jquery": { // jquery files can have names like "jquery-1.10.2.min.js" (or "jquery.intellisense.js") - match: /jquery(-(\.?\d+)+)?(\.intellisense)?(\.min)?\.js$/i, + match: /jquery(-[\d\.]+)?(\.intellisense)?(\.min)?\.js$/i, types: ["jquery"] }, "WinJS": { @@ -155050,16 +160270,7 @@ var ts; } } } - var ConfigFileWatcherStatus; - (function (ConfigFileWatcherStatus) { - ConfigFileWatcherStatus["ReloadingFiles"] = "Reloading configured projects for files"; - ConfigFileWatcherStatus["ReloadingInferredRootFiles"] = "Reloading configured projects for only inferred root files"; - ConfigFileWatcherStatus["UpdatedCallback"] = "Updated the callback"; - ConfigFileWatcherStatus["OpenFilesImpactedByConfigFileAdd"] = "File added to open files impacted by this config file"; - ConfigFileWatcherStatus["OpenFilesImpactedByConfigFileRemove"] = "File removed from open files impacted by this config file"; - ConfigFileWatcherStatus["RootOfInferredProjectTrue"] = "Open file was set as Inferred root"; - ConfigFileWatcherStatus["RootOfInferredProjectFalse"] = "Open file was set as not inferred root"; - })(ConfigFileWatcherStatus || (ConfigFileWatcherStatus = {})); + var noopConfigFileWatcher = { close: ts.noop }; function isOpenScriptInfo(infoOrFileNameOrConfig) { return !!infoOrFileNameOrConfig.containingProjects; } @@ -155155,7 +160366,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 "Project: " + (project ? project.getProjectName() : "") + " WatchType: " + watchType; + return (ts.isString(project) ? "Config: " + project + " " : project ? "Project: " + project.getProjectName() + " " : "") + "WatchType: " + watchType; } function isScriptInfoWatchedFromNodeModules(info) { return !info.isScriptOpen() && info.mTime !== undefined; @@ -155178,6 +160389,10 @@ var ts; project.projectOptions = true; } } + function createProjectNameFactoryWithCounter(nameFactory) { + var nextId = 1; + return function () { return nameFactory(nextId++); }; + } var ProjectService = /** @class */ (function () { function ProjectService(opts) { var _this = this; @@ -155211,6 +160426,10 @@ var ts; * projects specified by a tsconfig.json file */ this.configuredProjects = new ts.Map(); + /*@internal*/ + this.newInferredProjectName = createProjectNameFactoryWithCounter(server.makeInferredProjectName); + /*@internal*/ + this.newAutoImportProviderProjectName = createProjectNameFactoryWithCounter(server.makeAutoImportProviderProjectName); /** * Open files: with value being project root path, and key being Path of the file that is open */ @@ -155235,7 +160454,7 @@ var ts; * - Or it is present if we have configured project open with config file at that location * In this case the exists property is always true */ - this.configFileExistenceInfoCache = new ts.Map(); + /*@internal*/ this.configFileExistenceInfoCache = new ts.Map(); this.safelist = defaultTypeSafeList; this.legacySafelist = new ts.Map(); this.pendingProjectUpdates = new ts.Map(); @@ -155245,6 +160464,8 @@ var ts; this.seenProjects = new ts.Map(); /*@internal*/ this.sharedExtendedConfigFileWatchers = new ts.Map(); + /*@internal*/ + this.extendedConfigCache = new ts.Map(); this.host = opts.host; this.logger = opts.logger; this.cancellationToken = opts.cancellationToken; @@ -155381,13 +160602,12 @@ var ts; case server.ActionSet: // Update the typing files and update the project project.updateTypingFiles(this.typingsCache.updateTypingsForProject(response.projectName, response.compilerOptions, response.typeAcquisition, response.unresolvedImports, response.typings)); - break; + return; case server.ActionInvalidate: // Do not clear resolution cache, there was changes detected in typings, so enque typing request and let it get us correct results this.typingsCache.enqueueInstallTypingsForProject(project, project.lastCachedUnresolvedImportsList, /*forceRefresh*/ true); return; } - this.delayUpdateProjectGraphAndEnsureProjectStructureForOpenFiles(project); }; /*@internal*/ ProjectService.prototype.delayEnsureProjectForOpenFiles = function () { @@ -155618,9 +160838,6 @@ var ts; return this.hostConfiguration.preferences; }; ProjectService.prototype.onSourceFileChanged = function (info, eventKind) { - if (info.containingProjects) { - info.containingProjects.forEach(function (project) { return project.resolutionCache.removeResolutionsFromProjectReferenceRedirects(info.path); }); - } if (eventKind === ts.FileWatcherEventKind.Deleted) { // File was deleted this.handleDeletedFile(info); @@ -155686,18 +160903,17 @@ var ts; * This is to watch whenever files are added or removed to the wildcard directories */ /*@internal*/ - ProjectService.prototype.watchWildcardDirectory = function (directory, flags, project) { + ProjectService.prototype.watchWildcardDirectory = function (directory, flags, configFileName, config) { var _this = this; - var watchOptions = this.getWatchOptions(project); return this.watchFactory.watchDirectory(directory, function (fileOrDirectory) { var fileOrDirectoryPath = _this.toPath(fileOrDirectory); - var fsResult = project.getCachedDirectoryStructureHost().addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); - var configFileName = project.getConfigFilePath(); + 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("Project: " + configFileName + " Detected new package.json: " + fileOrDirectory); + _this.logger.info("Config: " + configFileName + " Detected new package.json: " + fileOrDirectory); _this.onAddPackageJson(fileOrDirectoryPath); } + var configuredProjectForConfig = _this.findConfiguredProjectByProjectName(configFileName); if (ts.isIgnoredFileFromWildCardWatching({ watchedDirPath: directory, fileOrDirectory: fileOrDirectory, @@ -155705,109 +160921,111 @@ var ts; configFileName: configFileName, extraFileExtensions: _this.hostConfiguration.extraFileExtensions, currentDirectory: _this.currentDirectory, - options: project.getCompilationSettings(), - program: project.getCurrentProgram(), + options: config.parsedCommandLine.options, + program: (configuredProjectForConfig === null || configuredProjectForConfig === void 0 ? void 0 : configuredProjectForConfig.getCurrentProgram()) || config.parsedCommandLine.fileNames, useCaseSensitiveFileNames: _this.host.useCaseSensitiveFileNames, - writeLog: function (s) { return _this.logger.info(s); } + writeLog: function (s) { return _this.logger.info(s); }, + toPath: function (s) { return _this.toPath(s); } })) return; - // don't trigger callback on open, existing files - if (project.fileIsOpen(fileOrDirectoryPath)) { - if (project.pendingReload !== ts.ConfigFileProgramReloadLevel.Full) { + // Reload is pending, do the reload + if (config.reloadLevel !== ts.ConfigFileProgramReloadLevel.Full) + config.reloadLevel = ts.ConfigFileProgramReloadLevel.Partial; + config.projects.forEach(function (watchWildcardDirectories, projectCanonicalPath) { + if (!watchWildcardDirectories) + return; + var project = _this.getConfiguredProjectByCanonicalConfigFilePath(projectCanonicalPath); + if (!project) + return; + // Load root file names for configured project with the config file name + // But only schedule update if project references this config file + var reloadLevel = configuredProjectForConfig === project ? ts.ConfigFileProgramReloadLevel.Partial : ts.ConfigFileProgramReloadLevel.None; + if (project.pendingReload !== undefined && project.pendingReload > reloadLevel) + return; + // don't trigger callback on open, existing files + if (_this.openFiles.has(fileOrDirectoryPath)) { var info = ts.Debug.checkDefined(_this.getScriptInfoForPath(fileOrDirectoryPath)); if (info.isAttached(project)) { - project.openFileWatchTriggered.set(fileOrDirectoryPath, true); + var loadLevelToSet = Math.max(reloadLevel, project.openFileWatchTriggered.get(fileOrDirectoryPath) || ts.ConfigFileProgramReloadLevel.None); + project.openFileWatchTriggered.set(fileOrDirectoryPath, loadLevelToSet); } else { - project.pendingReload = ts.ConfigFileProgramReloadLevel.Partial; + project.pendingReload = reloadLevel; _this.delayUpdateProjectGraphAndEnsureProjectStructureForOpenFiles(project); } } + else { + project.pendingReload = reloadLevel; + _this.delayUpdateProjectGraphAndEnsureProjectStructureForOpenFiles(project); + } + }); + }, flags, this.getWatchOptionsFromProjectWatchOptions(config.parsedCommandLine.watchOptions), ts.WatchType.WildcardDirectory, configFileName); + }; + /*@internal*/ + ProjectService.prototype.delayUpdateProjectsFromParsedConfigOnConfigFileChange = function (canonicalConfigFilePath, reloadReason) { + var _this = this; + var configFileExistenceInfo = this.configFileExistenceInfoCache.get(canonicalConfigFilePath); + if (!(configFileExistenceInfo === null || configFileExistenceInfo === void 0 ? void 0 : configFileExistenceInfo.config)) + return false; + var scheduledAnyProjectUpdate = false; + // Update projects watching cached config + configFileExistenceInfo.config.reloadLevel = ts.ConfigFileProgramReloadLevel.Full; + configFileExistenceInfo.config.projects.forEach(function (_watchWildcardDirectories, projectCanonicalPath) { + var project = _this.getConfiguredProjectByCanonicalConfigFilePath(projectCanonicalPath); + if (!project) return; + scheduledAnyProjectUpdate = true; + if (projectCanonicalPath === canonicalConfigFilePath) { + // Skip refresh if project is not yet loaded + if (project.isInitialLoadPending()) + return; + project.pendingReload = ts.ConfigFileProgramReloadLevel.Full; + project.pendingReloadReason = reloadReason; + _this.delayUpdateProjectGraph(project); } - // Reload is pending, do the reload - if (project.pendingReload !== ts.ConfigFileProgramReloadLevel.Full) { - project.pendingReload = ts.ConfigFileProgramReloadLevel.Partial; - _this.delayUpdateProjectGraphAndEnsureProjectStructureForOpenFiles(project); + else { + // Change in referenced project config file + project.resolutionCache.removeResolutionsFromProjectReferenceRedirects(_this.toPath(canonicalConfigFilePath)); + _this.delayUpdateProjectGraph(project); } - }, flags, watchOptions, ts.WatchType.WildcardDirectory, project); - }; - /** Gets the config file existence info for the configured project */ - /*@internal*/ - ProjectService.prototype.getConfigFileExistenceInfo = function (project) { - return this.configFileExistenceInfoCache.get(project.canonicalConfigFilePath); + }); + return scheduledAnyProjectUpdate; }; /*@internal*/ - ProjectService.prototype.onConfigChangedForConfiguredProject = function (project, eventKind) { - var configFileExistenceInfo = this.getConfigFileExistenceInfo(project); + ProjectService.prototype.onConfigFileChanged = function (canonicalConfigFilePath, eventKind) { + var _a; + var configFileExistenceInfo = this.configFileExistenceInfoCache.get(canonicalConfigFilePath); if (eventKind === ts.FileWatcherEventKind.Deleted) { // Update the cached status // We arent updating or removing the cached config file presence info as that will be taken care of by - // setConfigFilePresenceByClosedConfigFile when the project is closed (depending on tracking open files) + // releaseParsedConfig when the project is closed or doesnt need this config any more (depending on tracking open files) configFileExistenceInfo.exists = false; - this.removeProject(project); - // Reload the configured projects for the open files in the map as they are affected by this config file - // Since the configured project was deleted, we want to reload projects for all the open files including files - // that are not root of the inferred project - this.logConfigFileWatchUpdate(project.getConfigFilePath(), project.canonicalConfigFilePath, configFileExistenceInfo, "Reloading configured projects for files" /* ReloadingFiles */); - this.delayReloadConfiguredProjectForFiles(configFileExistenceInfo, /*ignoreIfNotInferredProjectRoot*/ false); + // Remove the configured project for this config file + var project = ((_a = configFileExistenceInfo.config) === null || _a === void 0 ? void 0 : _a.projects.has(canonicalConfigFilePath)) ? + this.getConfiguredProjectByCanonicalConfigFilePath(canonicalConfigFilePath) : + undefined; + if (project) + this.removeProject(project); } else { - this.logConfigFileWatchUpdate(project.getConfigFilePath(), project.canonicalConfigFilePath, configFileExistenceInfo, "Reloading configured projects for only inferred root files" /* ReloadingInferredRootFiles */); - // Skip refresh if project is not yet loaded - if (project.isInitialLoadPending()) - return; - project.pendingReload = ts.ConfigFileProgramReloadLevel.Full; - project.pendingReloadReason = "Change in config file detected"; - this.delayUpdateProjectGraph(project); - // As we scheduled the update on configured project graph, - // we would need to schedule the project reload for only the root of inferred projects - this.delayReloadConfiguredProjectForFiles(configFileExistenceInfo, /*ignoreIfNotInferredProjectRoot*/ true); + // Update the cached status + configFileExistenceInfo.exists = true; } - }; - /*@internal*/ - ProjectService.prototype.updateSharedExtendedConfigFileMap = function (_a, parsedCommandLine) { - var _this = this; - var canonicalConfigFilePath = _a.canonicalConfigFilePath; - ts.updateSharedExtendedConfigFileWatcher(canonicalConfigFilePath, parsedCommandLine, this.sharedExtendedConfigFileWatchers, function (extendedConfigFileName, extendedConfigFilePath) { return _this.watchFactory.watchFile(extendedConfigFileName, function () { - var _a; - var ensureProjectsForOpenFiles = false; - (_a = _this.sharedExtendedConfigFileWatchers.get(extendedConfigFilePath)) === null || _a === void 0 ? void 0 : _a.projects.forEach(function (canonicalPath) { - var project = _this.configuredProjects.get(canonicalPath); - // Skip refresh if project is not yet loaded - if (!project || project.isInitialLoadPending()) - return; - project.pendingReload = ts.ConfigFileProgramReloadLevel.Full; - project.pendingReloadReason = "Change in extended config file " + extendedConfigFileName + " detected"; - _this.delayUpdateProjectGraph(project); - ensureProjectsForOpenFiles = true; - }); - if (ensureProjectsForOpenFiles) - _this.delayEnsureProjectForOpenFiles(); - }, ts.PollingInterval.High, _this.hostConfiguration.watchOptions, ts.WatchType.ExtendedConfigFile); }, function (fileName) { return _this.toPath(fileName); }); - }; - /*@internal*/ - ProjectService.prototype.removeProjectFromSharedExtendedConfigFileMap = function (project) { - this.sharedExtendedConfigFileWatchers.forEach(function (watcher) { - watcher.projects.delete(project.canonicalConfigFilePath); - watcher.close(); - }); - }; - /** - * This is the callback function for the config file add/remove/change at any location - * that matters to open script info but doesnt have configured project open - * for the config file - */ - ProjectService.prototype.onConfigFileChangeForOpenScriptInfo = function (configFileName, eventKind) { - // This callback is called only if we dont have config file project for this config file - var canonicalConfigPath = server.normalizedPathToPath(configFileName, this.currentDirectory, this.toCanonicalFileName); - var configFileExistenceInfo = this.configFileExistenceInfoCache.get(canonicalConfigPath); - configFileExistenceInfo.exists = (eventKind !== ts.FileWatcherEventKind.Deleted); - this.logConfigFileWatchUpdate(configFileName, canonicalConfigPath, configFileExistenceInfo, "Reloading configured projects for files" /* ReloadingFiles */); - // Because there is no configured project open for the config file, the tracking open files map - // will only have open files that need the re-detection of the project and hence - // reload projects for all the tracking open files in the map - this.delayReloadConfiguredProjectForFiles(configFileExistenceInfo, /*ignoreIfNotInferredProjectRoot*/ false); + // Update projects watching config + this.delayUpdateProjectsFromParsedConfigOnConfigFileChange(canonicalConfigFilePath, "Change in config file detected"); + // Reload the configured projects for the open files in the map as they are affected by this config file + // If the configured project was deleted, we want to reload projects for all the open files including files + // that are not root of the inferred project + // Otherwise, we scheduled the update on configured project graph, + // we would need to schedule the project reload for only the root of inferred projects + // Get open files to reload projects for + this.reloadConfiguredProjectForFiles(configFileExistenceInfo.openFilesImpactedByConfigFile, + /*clearSemanticCache*/ false, + /*delayReload*/ true, eventKind !== ts.FileWatcherEventKind.Deleted ? + ts.identity : // Reload open files if they are root of inferred project + ts.returnTrue, // Reload all the open files impacted by config file + "Change in config file detected"); + this.delayEnsureProjectForOpenFiles(); }; ProjectService.prototype.removeProject = function (project) { var _this = this; @@ -155833,7 +161051,6 @@ var ts; case server.ProjectKind.Configured: this.configuredProjects.delete(project.canonicalConfigFilePath); this.projectToSizeMap.delete(project.canonicalConfigFilePath); - this.setConfigFileExistenceInfoByClosedConfiguredProject(project); break; case server.ProjectKind.Inferred: ts.unorderedRemoveItem(this.inferredProjects, project); @@ -155860,7 +161077,7 @@ var ts; } project.updateGraph(); if (!this.useSingleInferredProject && !project.projectRootPath) { - var _loop_3 = function (inferredProject) { + var _loop_2 = function (inferredProject) { if (inferredProject === project || inferredProject.isOrphan()) { return "continue"; } @@ -155881,7 +161098,7 @@ var ts; // Note that we need to create a copy of the array since the list of project can change for (var _i = 0, _a = this.inferredProjects; _i < _a.length; _i++) { var inferredProject = _a[_i]; - _loop_3(inferredProject); + _loop_2(inferredProject); } } return project; @@ -155924,10 +161141,11 @@ var ts; // if it would need to be re-created with next file open // If project had open file affecting // Reload the root Files from config if its not already scheduled - if (p.openFileWatchTriggered.has(info.path)) { + var reloadLevel = p.openFileWatchTriggered.get(info.path); + if (reloadLevel !== undefined) { p.openFileWatchTriggered.delete(info.path); - if (!p.pendingReload) { - p.pendingReload = ts.ConfigFileProgramReloadLevel.Partial; + if (p.pendingReload !== undefined && p.pendingReload < reloadLevel) { + p.pendingReload = reloadLevel; p.markFileAsDirty(info.path); } } @@ -155975,13 +161193,13 @@ var ts; } }; ProjectService.prototype.configFileExists = function (configFileName, canonicalConfigFilePath, info) { + var _a; var configFileExistenceInfo = this.configFileExistenceInfoCache.get(canonicalConfigFilePath); if (configFileExistenceInfo) { // By default the info would get impacted by presence of config file since its in the detection path // Only adding the info as a root to inferred project will need the existence to be watched by file watcher - if (isOpenScriptInfo(info) && !configFileExistenceInfo.openFilesImpactedByConfigFile.has(info.path)) { - configFileExistenceInfo.openFilesImpactedByConfigFile.set(info.path, false); - this.logConfigFileWatchUpdate(configFileName, canonicalConfigFilePath, configFileExistenceInfo, "File added to open files impacted by this config file" /* OpenFilesImpactedByConfigFileAdd */); + if (isOpenScriptInfo(info) && !((_a = configFileExistenceInfo.openFilesImpactedByConfigFile) === null || _a === void 0 ? void 0 : _a.has(info.path))) { + (configFileExistenceInfo.openFilesImpactedByConfigFile || (configFileExistenceInfo.openFilesImpactedByConfigFile = new ts.Map())).set(info.path, false); } return configFileExistenceInfo.exists; } @@ -155994,104 +161212,82 @@ var ts; // Or the whole chain of config files for the roots of the inferred projects // Cache the host value of file exists and add the info to map of open files impacted by this config file var exists = this.host.fileExists(configFileName); - var openFilesImpactedByConfigFile = new ts.Map(); + var openFilesImpactedByConfigFile; if (isOpenScriptInfo(info)) { - openFilesImpactedByConfigFile.set(info.path, false); + (openFilesImpactedByConfigFile || (openFilesImpactedByConfigFile = new ts.Map())).set(info.path, false); } configFileExistenceInfo = { exists: exists, openFilesImpactedByConfigFile: openFilesImpactedByConfigFile }; this.configFileExistenceInfoCache.set(canonicalConfigFilePath, configFileExistenceInfo); - this.logConfigFileWatchUpdate(configFileName, canonicalConfigFilePath, configFileExistenceInfo, "File added to open files impacted by this config file" /* OpenFilesImpactedByConfigFileAdd */); return exists; }; - ProjectService.prototype.setConfigFileExistenceByNewConfiguredProject = function (project) { - var configFileExistenceInfo = this.getConfigFileExistenceInfo(project); - if (configFileExistenceInfo) { - // The existence might not be set if the file watcher is not invoked by the time config project is created by external project - configFileExistenceInfo.exists = true; - // close existing watcher - if (configFileExistenceInfo.configFileWatcherForRootOfInferredProject) { - var configFileName = project.getConfigFilePath(); - configFileExistenceInfo.configFileWatcherForRootOfInferredProject.close(); - configFileExistenceInfo.configFileWatcherForRootOfInferredProject = undefined; - this.logConfigFileWatchUpdate(configFileName, project.canonicalConfigFilePath, configFileExistenceInfo, "Updated the callback" /* UpdatedCallback */); - } - } - else { - // We could be in this scenario if project is the configured project tracked by external project - // Since that route doesnt check if the config file is present or not - this.configFileExistenceInfoCache.set(project.canonicalConfigFilePath, { - exists: true, - openFilesImpactedByConfigFile: new ts.Map() - }); + /*@internal*/ + ProjectService.prototype.createConfigFileWatcherForParsedConfig = function (configFileName, canonicalConfigFilePath, forProject) { + var _this = this; + var _a, _b; + var configFileExistenceInfo = this.configFileExistenceInfoCache.get(canonicalConfigFilePath); + // When watching config file for parsed config, remove the noopFileWatcher that can be created for open files impacted by config file and watch for real + if (!configFileExistenceInfo.watcher || configFileExistenceInfo.watcher === noopConfigFileWatcher) { + configFileExistenceInfo.watcher = this.watchFactory.watchFile(configFileName, function (_fileName, eventKind) { return _this.onConfigFileChanged(canonicalConfigFilePath, eventKind); }, ts.PollingInterval.High, this.getWatchOptionsFromProjectWatchOptions((_b = (_a = configFileExistenceInfo === null || configFileExistenceInfo === void 0 ? void 0 : configFileExistenceInfo.config) === null || _a === void 0 ? void 0 : _a.parsedCommandLine) === null || _b === void 0 ? void 0 : _b.watchOptions), ts.WatchType.ConfigFile, forProject); } + // Watching config file for project, update the map + var projects = configFileExistenceInfo.config.projects; + projects.set(forProject.canonicalConfigFilePath, projects.get(forProject.canonicalConfigFilePath) || false); }; /** * Returns true if the configFileExistenceInfo is needed/impacted by open files that are root of inferred project */ ProjectService.prototype.configFileExistenceImpactsRootOfInferredProject = function (configFileExistenceInfo) { - return ts.forEachEntry(configFileExistenceInfo.openFilesImpactedByConfigFile, function (isRootOfInferredProject) { return isRootOfInferredProject; }); + return configFileExistenceInfo.openFilesImpactedByConfigFile && + ts.forEachEntry(configFileExistenceInfo.openFilesImpactedByConfigFile, ts.identity); }; - ProjectService.prototype.setConfigFileExistenceInfoByClosedConfiguredProject = function (closedProject) { - var configFileExistenceInfo = this.getConfigFileExistenceInfo(closedProject); - ts.Debug.assert(!!configFileExistenceInfo); - if (configFileExistenceInfo.openFilesImpactedByConfigFile.size) { - var configFileName = closedProject.getConfigFilePath(); + /* @internal */ + ProjectService.prototype.releaseParsedConfig = function (canonicalConfigFilePath, forProject) { + var _a, _b, _c; + var configFileExistenceInfo = this.configFileExistenceInfoCache.get(canonicalConfigFilePath); + if (!((_a = configFileExistenceInfo.config) === null || _a === void 0 ? void 0 : _a.projects.delete(forProject.canonicalConfigFilePath))) + return; + // If there are still projects watching this config file existence and config, there is nothing to do + if ((_b = configFileExistenceInfo.config) === null || _b === void 0 ? void 0 : _b.projects.size) + return; + configFileExistenceInfo.config = undefined; + ts.clearSharedExtendedConfigFileWatcher(canonicalConfigFilePath, this.sharedExtendedConfigFileWatchers); + ts.Debug.checkDefined(configFileExistenceInfo.watcher); + if ((_c = configFileExistenceInfo.openFilesImpactedByConfigFile) === null || _c === void 0 ? void 0 : _c.size) { // If there are open files that are impacted by this config file existence // but none of them are root of inferred project, the config file watcher will be // created when any of the script infos are added as root of inferred project if (this.configFileExistenceImpactsRootOfInferredProject(configFileExistenceInfo)) { - ts.Debug.assert(!configFileExistenceInfo.configFileWatcherForRootOfInferredProject); - this.createConfigFileWatcherOfConfigFileExistence(configFileName, closedProject.canonicalConfigFilePath, configFileExistenceInfo); + // If we cannot watch config file existence without configured project, close the configured file watcher + if (!ts.canWatchDirectory(ts.getDirectoryPath(canonicalConfigFilePath))) { + configFileExistenceInfo.watcher.close(); + configFileExistenceInfo.watcher = noopConfigFileWatcher; + } + } + else { + // Close existing watcher + configFileExistenceInfo.watcher.close(); + configFileExistenceInfo.watcher = undefined; } } else { // There is not a single file open thats tracking the status of this config file. Remove from cache - this.configFileExistenceInfoCache.delete(closedProject.canonicalConfigFilePath); - } - }; - ProjectService.prototype.logConfigFileWatchUpdate = function (configFileName, canonicalConfigFilePath, configFileExistenceInfo, status) { - var _this = this; - if (!this.logger.hasLevel(server.LogLevel.verbose)) { - return; - } - var inferredRoots = []; - var otherFiles = []; - configFileExistenceInfo.openFilesImpactedByConfigFile.forEach(function (isRootOfInferredProject, key) { - var info = _this.getScriptInfoForPath(key); - (isRootOfInferredProject ? inferredRoots : otherFiles).push(info.fileName); - }); - var watches = []; - if (configFileExistenceInfo.configFileWatcherForRootOfInferredProject) { - watches.push(configFileExistenceInfo.configFileWatcherForRootOfInferredProject === ts.noopFileWatcher ? - ts.WatchType.NoopConfigFileForInferredRoot : - ts.WatchType.ConfigFileForInferredRoot); - } - if (this.configuredProjects.has(canonicalConfigFilePath)) { - watches.push(ts.WatchType.ConfigFile); + configFileExistenceInfo.watcher.close(); + this.configFileExistenceInfoCache.delete(canonicalConfigFilePath); } - this.logger.info("ConfigFilePresence:: Current Watches: " + watches + ":: File: " + configFileName + " Currently impacted open files: RootsOfInferredProjects: " + inferredRoots + " OtherOpenFiles: " + otherFiles + " Status: " + status); - }; - /** - * Create the watcher for the configFileExistenceInfo - */ - ProjectService.prototype.createConfigFileWatcherOfConfigFileExistence = function (configFileName, canonicalConfigFilePath, configFileExistenceInfo) { - var _this = this; - configFileExistenceInfo.configFileWatcherForRootOfInferredProject = - ts.canWatchDirectory(ts.getDirectoryPath(canonicalConfigFilePath)) ? - this.watchFactory.watchFile(configFileName, function (_filename, eventKind) { return _this.onConfigFileChangeForOpenScriptInfo(configFileName, eventKind); }, ts.PollingInterval.High, this.hostConfiguration.watchOptions, ts.WatchType.ConfigFileForInferredRoot) : - ts.noopFileWatcher; - this.logConfigFileWatchUpdate(configFileName, canonicalConfigFilePath, configFileExistenceInfo, "Updated the callback" /* UpdatedCallback */); }; /** * Close the config file watcher in the cached ConfigFileExistenceInfo - * if there arent any open files that are root of inferred project + * if there arent any open files that are root of inferred project and there is no parsed config held by any project */ - ProjectService.prototype.closeConfigFileWatcherOfConfigFileExistenceInfo = function (configFileExistenceInfo) { + /*@internal*/ + ProjectService.prototype.closeConfigFileWatcherOnReleaseOfOpenFile = function (configFileExistenceInfo) { // Close the config file watcher if there are no more open files that are root of inferred project - if (configFileExistenceInfo.configFileWatcherForRootOfInferredProject && + // or if there are no projects that need to watch this config file existence info + if (configFileExistenceInfo.watcher && + !configFileExistenceInfo.config && !this.configFileExistenceImpactsRootOfInferredProject(configFileExistenceInfo)) { - configFileExistenceInfo.configFileWatcherForRootOfInferredProject.close(); - configFileExistenceInfo.configFileWatcherForRootOfInferredProject = undefined; + configFileExistenceInfo.watcher.close(); + configFileExistenceInfo.watcher = undefined; } }; /** @@ -156100,25 +161296,26 @@ var ts; ProjectService.prototype.stopWatchingConfigFilesForClosedScriptInfo = function (info) { var _this = this; ts.Debug.assert(!info.isScriptOpen()); - this.forEachConfigFileLocation(info, function (configFileName, canonicalConfigFilePath) { + this.forEachConfigFileLocation(info, function (canonicalConfigFilePath) { + var _a, _b, _c; var configFileExistenceInfo = _this.configFileExistenceInfoCache.get(canonicalConfigFilePath); if (configFileExistenceInfo) { - var infoIsRootOfInferredProject = configFileExistenceInfo.openFilesImpactedByConfigFile.get(info.path); + var infoIsRootOfInferredProject = (_a = configFileExistenceInfo.openFilesImpactedByConfigFile) === null || _a === void 0 ? void 0 : _a.get(info.path); // Delete the info from map, since this file is no more open - configFileExistenceInfo.openFilesImpactedByConfigFile.delete(info.path); - _this.logConfigFileWatchUpdate(configFileName, canonicalConfigFilePath, configFileExistenceInfo, "File removed from open files impacted by this config file" /* OpenFilesImpactedByConfigFileRemove */); + (_b = configFileExistenceInfo.openFilesImpactedByConfigFile) === null || _b === void 0 ? void 0 : _b.delete(info.path); // If the script info was not root of inferred project, // there wont be config file watch open because of this script info if (infoIsRootOfInferredProject) { // But if it is a root, it could be the last script info that is root of inferred project // and hence we would need to close the config file watcher - _this.closeConfigFileWatcherOfConfigFileExistenceInfo(configFileExistenceInfo); + _this.closeConfigFileWatcherOnReleaseOfOpenFile(configFileExistenceInfo); } // If there are no open files that are impacted by configFileExistenceInfo after closing this script info - // there is no configured project present, remove the cached existence info - if (!configFileExistenceInfo.openFilesImpactedByConfigFile.size && - !_this.getConfiguredProjectByCanonicalConfigFilePath(canonicalConfigFilePath)) { - ts.Debug.assert(!configFileExistenceInfo.configFileWatcherForRootOfInferredProject); + // and there is are no projects that need the config file existence or parsed config, + // remove the cached existence info + if (!((_c = configFileExistenceInfo.openFilesImpactedByConfigFile) === null || _c === void 0 ? void 0 : _c.size) && + !configFileExistenceInfo.config) { + ts.Debug.assert(!configFileExistenceInfo.watcher); _this.configFileExistenceInfoCache.delete(canonicalConfigFilePath); } } @@ -156131,24 +161328,19 @@ var ts; ProjectService.prototype.startWatchingConfigFilesForInferredProjectRoot = function (info) { var _this = this; ts.Debug.assert(info.isScriptOpen()); - this.forEachConfigFileLocation(info, function (configFileName, canonicalConfigFilePath) { + this.forEachConfigFileLocation(info, function (canonicalConfigFilePath, configFileName) { var configFileExistenceInfo = _this.configFileExistenceInfoCache.get(canonicalConfigFilePath); if (!configFileExistenceInfo) { // Create the cache - configFileExistenceInfo = { - exists: _this.host.fileExists(configFileName), - openFilesImpactedByConfigFile: new ts.Map() - }; + configFileExistenceInfo = { exists: _this.host.fileExists(configFileName) }; _this.configFileExistenceInfoCache.set(canonicalConfigFilePath, configFileExistenceInfo); } // Set this file as the root of inferred project - configFileExistenceInfo.openFilesImpactedByConfigFile.set(info.path, true); - _this.logConfigFileWatchUpdate(configFileName, canonicalConfigFilePath, configFileExistenceInfo, "Open file was set as Inferred root" /* RootOfInferredProjectTrue */); + (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 - if (!configFileExistenceInfo.configFileWatcherForRootOfInferredProject && - !_this.getConfiguredProjectByCanonicalConfigFilePath(canonicalConfigFilePath)) { - _this.createConfigFileWatcherOfConfigFileExistence(configFileName, canonicalConfigFilePath, configFileExistenceInfo); - } + configFileExistenceInfo.watcher || (configFileExistenceInfo.watcher = ts.canWatchDirectory(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); }); }; /** @@ -156157,15 +161349,15 @@ var ts; /* @internal */ ProjectService.prototype.stopWatchingConfigFilesForInferredProjectRoot = function (info) { var _this = this; - this.forEachConfigFileLocation(info, function (configFileName, canonicalConfigFilePath) { + this.forEachConfigFileLocation(info, function (canonicalConfigFilePath) { + var _a; var configFileExistenceInfo = _this.configFileExistenceInfoCache.get(canonicalConfigFilePath); - if (configFileExistenceInfo && configFileExistenceInfo.openFilesImpactedByConfigFile.has(info.path)) { + if ((_a = configFileExistenceInfo === null || configFileExistenceInfo === void 0 ? void 0 : configFileExistenceInfo.openFilesImpactedByConfigFile) === null || _a === void 0 ? void 0 : _a.has(info.path)) { ts.Debug.assert(info.isScriptOpen()); // Info is not root of inferred project any more configFileExistenceInfo.openFilesImpactedByConfigFile.set(info.path, false); - _this.logConfigFileWatchUpdate(configFileName, canonicalConfigFilePath, configFileExistenceInfo, "Open file was set as not inferred root" /* RootOfInferredProjectFalse */); // Close the config file watcher - _this.closeConfigFileWatcherOfConfigFileExistenceInfo(configFileExistenceInfo); + _this.closeConfigFileWatcherOnReleaseOfOpenFile(configFileExistenceInfo); } }); }; @@ -156197,11 +161389,11 @@ var ts; if (searchInDirectory) { var canonicalSearchPath = server.normalizedPathToPath(searchPath, this.currentDirectory, this.toCanonicalFileName); var tsconfigFileName = server.asNormalizedPath(ts.combinePaths(searchPath, "tsconfig.json")); - var result = action(tsconfigFileName, ts.combinePaths(canonicalSearchPath, "tsconfig.json")); + var result = action(ts.combinePaths(canonicalSearchPath, "tsconfig.json"), tsconfigFileName); if (result) return tsconfigFileName; var jsconfigFileName = server.asNormalizedPath(ts.combinePaths(searchPath, "jsconfig.json")); - result = action(jsconfigFileName, ts.combinePaths(canonicalSearchPath, "jsconfig.json")); + result = action(ts.combinePaths(canonicalSearchPath, "jsconfig.json"), jsconfigFileName); if (result) return jsconfigFileName; // If we started within node_modules, don't look outside node_modules. @@ -156249,7 +161441,7 @@ var ts; return result || undefined; } this.logger.info("Search path: " + ts.getDirectoryPath(info.fileName)); - var configFileName = this.forEachConfigFileLocation(info, function (configFileName, canonicalConfigFilePath) { + var configFileName = this.forEachConfigFileLocation(info, function (canonicalConfigFilePath, configFileName) { return _this.configFileExists(configFileName, canonicalConfigFilePath, info); }); if (configFileName) { @@ -156294,6 +161486,7 @@ var ts; }; /** Get a filename if the language service exceeds the maximum allowed program size; otherwise returns undefined. */ ProjectService.prototype.getFilenameForExceededTotalSizeLimitForNonTsFiles = function (name, options, fileNames, propertyReader) { + var _this = this; if (options && options.disableSizeLimit || !this.host.getFileSize) { return; } @@ -156309,25 +161502,17 @@ var ts; } totalNonTsFileSize += this.host.getFileSize(fileName); if (totalNonTsFileSize > server.maxProgramSizeForNonTsFiles || totalNonTsFileSize > availableSpace) { - this.logger.info(getExceedLimitMessage({ propertyReader: propertyReader, hasTSFileExtension: ts.hasTSFileExtension, host: this.host }, totalNonTsFileSize)); // eslint-disable-line @typescript-eslint/no-unnecessary-qualifier + var top5LargestFiles = fileNames.map(function (f) { return propertyReader.getFileName(f); }) + .filter(function (name) { return !ts.hasTSFileExtension(name); }) + .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(", ")); // Keep the size as zero since it's disabled return fileName; } } this.projectToSizeMap.set(name, totalNonTsFileSize); - return; - function getExceedLimitMessage(context, totalNonTsFileSize) { - var files = getTop5LargestFiles(context); - return "Non TS file size exceeded limit (" + totalNonTsFileSize + "). Largest files: " + files.map(function (file) { return file.name + ":" + file.size; }).join(", "); - } - function getTop5LargestFiles(_a) { - var propertyReader = _a.propertyReader, hasTSFileExtension = _a.hasTSFileExtension, host = _a.host; - return fileNames.map(function (f) { return propertyReader.getFileName(f); }) - .filter(function (name) { return hasTSFileExtension(name); }) - .map(function (name) { return ({ name: name, size: host.getFileSize(name) }); }) // TODO: GH#18217 - .sort(function (a, b) { return b.size - a.size; }) - .slice(0, 5); - } }; ProjectService.prototype.createExternalProject = function (projectFileName, files, options, typeAcquisition, excludedFiles) { var compilerOptions = convertCompilerOptions(options); @@ -156391,12 +161576,27 @@ var ts; }; /* @internal */ ProjectService.prototype.createConfiguredProject = function (configFileName) { - var cachedDirectoryStructureHost = ts.createCachedDirectoryStructureHost(this.host, this.host.getCurrentDirectory(), this.host.useCaseSensitiveFileNames); // TODO: GH#18217 - this.logger.info("Opened configuration file " + configFileName); - var project = new server.ConfiguredProject(configFileName, this, this.documentRegistry, cachedDirectoryStructureHost); - project.createConfigFileWatcher(); - this.configuredProjects.set(project.canonicalConfigFilePath, project); - this.setConfigFileExistenceByNewConfiguredProject(project); + this.logger.info("Creating configuration project " + 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 + // Since that route doesnt check if the config file is present or not + if (!configFileExistenceInfo) { + this.configFileExistenceInfoCache.set(canonicalConfigFilePath, configFileExistenceInfo = { exists: true }); + } + else { + configFileExistenceInfo.exists = true; + } + if (!configFileExistenceInfo.config) { + configFileExistenceInfo.config = { + cachedDirectoryStructureHost: ts.createCachedDirectoryStructureHost(this.host, this.host.getCurrentDirectory(), this.host.useCaseSensitiveFileNames), + projects: new ts.Map(), + reloadLevel: ts.ConfigFileProgramReloadLevel.Full + }; + } + var project = new server.ConfiguredProject(configFileName, canonicalConfigFilePath, this, this.documentRegistry, configFileExistenceInfo.config.cachedDirectoryStructureHost); + this.configuredProjects.set(canonicalConfigFilePath, project); + this.createConfigFileWatcherForParsedConfig(configFileName, canonicalConfigFilePath, project); return project; }; /* @internal */ @@ -156426,24 +161626,9 @@ var ts; var _this = this; this.sendProjectLoadingStartEvent(project, reason); // Read updated contents from disk - var configFilename = ts.normalizePath(project.getConfigFilePath()); - var configFileContent = ts.tryReadFile(configFilename, function (fileName) { return _this.host.readFile(fileName); }); - var result = ts.parseJsonText(configFilename, ts.isString(configFileContent) ? configFileContent : ""); - var configFileErrors = result.parseDiagnostics; - if (!ts.isString(configFileContent)) - configFileErrors.push(configFileContent); - var parsedCommandLine = ts.parseJsonSourceFileConfigFileContent(result, project.getCachedDirectoryStructureHost(), ts.getDirectoryPath(configFilename), - /*existingOptions*/ {}, configFilename, - /*resolutionStack*/ [], this.hostConfiguration.extraFileExtensions, - /*extendedConfigCache*/ undefined); - if (parsedCommandLine.errors.length) { - configFileErrors.push.apply(configFileErrors, parsedCommandLine.errors); - } - this.logger.info("Config: " + configFilename + " : " + JSON.stringify({ - rootNames: parsedCommandLine.fileNames, - options: parsedCommandLine.options, - projectReferences: parsedCommandLine.projectReferences - }, /*replacer*/ undefined, " ")); + var configFilename = server.asNormalizedPath(ts.normalizePath(project.getConfigFilePath())); + var configFileExistenceInfo = this.ensureParsedConfigUptoDate(configFilename, project.canonicalConfigFilePath, this.configFileExistenceInfoCache.get(project.canonicalConfigFilePath), project); + var parsedCommandLine = configFileExistenceInfo.config.parsedCommandLine; ts.Debug.assert(!!parsedCommandLine.fileNames); var compilerOptions = parsedCommandLine.options; // Update the project @@ -156456,25 +161641,131 @@ var ts; }; } project.canConfigFileJsonReportNoInputFiles = ts.canJsonReportNoInputFiles(parsedCommandLine.raw); - project.setProjectErrors(configFileErrors); + project.setProjectErrors(parsedCommandLine.options.configFile.parseDiagnostics); project.updateReferences(parsedCommandLine.projectReferences); var lastFileExceededProgramSize = this.getFilenameForExceededTotalSizeLimitForNonTsFiles(project.canonicalConfigFilePath, compilerOptions, parsedCommandLine.fileNames, fileNamePropertyReader); if (lastFileExceededProgramSize) { project.disableLanguageService(lastFileExceededProgramSize); - project.stopWatchingWildCards(); - this.removeProjectFromSharedExtendedConfigFileMap(project); + this.configFileExistenceInfoCache.forEach(function (_configFileExistenceInfo, canonicalConfigFilePath) { + return _this.stopWatchingWildCards(canonicalConfigFilePath, project); + }); } else { project.setCompilerOptions(compilerOptions); project.setWatchOptions(parsedCommandLine.watchOptions); project.enableLanguageService(); - project.watchWildcards(new ts.Map(ts.getEntries(parsedCommandLine.wildcardDirectories))); // TODO: GH#18217 - this.updateSharedExtendedConfigFileMap(project, parsedCommandLine); + this.watchWildcards(configFilename, configFileExistenceInfo, project); } project.enablePluginsWithOptions(compilerOptions, this.currentPluginConfigOverrides); var filesToAdd = parsedCommandLine.fileNames.concat(project.getExternalFiles()); this.updateRootAndOptionsOfNonInferredProject(project, filesToAdd, fileNamePropertyReader, compilerOptions, parsedCommandLine.typeAcquisition, parsedCommandLine.compileOnSave, parsedCommandLine.watchOptions); }; + /*@internal*/ + ProjectService.prototype.ensureParsedConfigUptoDate = function (configFilename, canonicalConfigFilePath, configFileExistenceInfo, forProject) { + var _this = this; + var _a, _b, _c; + if (configFileExistenceInfo.config) { + if (!configFileExistenceInfo.config.reloadLevel) + return configFileExistenceInfo; + if (configFileExistenceInfo.config.reloadLevel === ts.ConfigFileProgramReloadLevel.Partial) { + this.reloadFileNamesOfParsedConfig(configFilename, configFileExistenceInfo.config); + return configFileExistenceInfo; + } + } + // Parse the config file and ensure its cached + var cachedDirectoryStructureHost = ((_a = configFileExistenceInfo.config) === null || _a === void 0 ? void 0 : _a.cachedDirectoryStructureHost) || + ts.createCachedDirectoryStructureHost(this.host, this.host.getCurrentDirectory(), this.host.useCaseSensitiveFileNames); + // Read updated contents from disk + var configFileContent = ts.tryReadFile(configFilename, function (fileName) { return _this.host.readFile(fileName); }); + var configFile = ts.parseJsonText(configFilename, ts.isString(configFileContent) ? configFileContent : ""); + var configFileErrors = configFile.parseDiagnostics; + if (!ts.isString(configFileContent)) + configFileErrors.push(configFileContent); + var parsedCommandLine = ts.parseJsonSourceFileConfigFileContent(configFile, cachedDirectoryStructureHost, ts.getDirectoryPath(configFilename), + /*existingOptions*/ {}, configFilename, + /*resolutionStack*/ [], this.hostConfiguration.extraFileExtensions, this.extendedConfigCache); + if (parsedCommandLine.errors.length) { + configFileErrors.push.apply(configFileErrors, parsedCommandLine.errors); + } + this.logger.info("Config: " + configFilename + " : " + JSON.stringify({ + rootNames: parsedCommandLine.fileNames, + options: parsedCommandLine.options, + watchOptions: parsedCommandLine.watchOptions, + projectReferences: parsedCommandLine.projectReferences + }, /*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() }; + } + else { + configFileExistenceInfo.config.parsedCommandLine = parsedCommandLine; + configFileExistenceInfo.config.watchedDirectoriesStale = true; + configFileExistenceInfo.config.reloadLevel = undefined; + } + // If watch options different than older options when setting for the first time, update the config file watcher + if (!oldCommandLine && !ts.isJsonEqual( + // Old options + this.getWatchOptionsFromProjectWatchOptions(/*projectOptions*/ undefined), + // New options + this.getWatchOptionsFromProjectWatchOptions(parsedCommandLine.watchOptions))) { + // Reset the config file watcher + (_c = configFileExistenceInfo.watcher) === null || _c === void 0 ? void 0 : _c.close(); + configFileExistenceInfo.watcher = undefined; + } + // Ensure there is watcher for this config file + this.createConfigFileWatcherForParsedConfig(configFilename, canonicalConfigFilePath, forProject); + // Watch extended config files + ts.updateSharedExtendedConfigFileWatcher(canonicalConfigFilePath, parsedCommandLine.options, this.sharedExtendedConfigFileWatchers, function (extendedConfigFileName, extendedConfigFilePath) { return _this.watchFactory.watchFile(extendedConfigFileName, function () { + var _a; + // Update extended config cache + ts.cleanExtendedConfigCache(_this.extendedConfigCache, extendedConfigFilePath, function (fileName) { return _this.toPath(fileName); }); + // 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; + }); + if (ensureProjectsForOpenFiles) + _this.delayEnsureProjectForOpenFiles(); + }, ts.PollingInterval.High, _this.hostConfiguration.watchOptions, ts.WatchType.ExtendedConfigFile, configFilename); }, function (fileName) { return _this.toPath(fileName); }); + return configFileExistenceInfo; + }; + /*@internal*/ + ProjectService.prototype.watchWildcards = function (configFileName, _a, forProject) { + var _this = this; + var _b; + var exists = _a.exists, config = _a.config; + config.projects.set(forProject.canonicalConfigFilePath, true); + if (exists) { + if (config.watchedDirectories && !config.watchedDirectoriesStale) + return; + config.watchedDirectoriesStale = false; + ts.updateWatchingWildcardDirectories((_b = config).watchedDirectories || (_b.watchedDirectories = new ts.Map()), new ts.Map(ts.getEntries(config.parsedCommandLine.wildcardDirectories)), + // Create new directory watcher + function (directory, flags) { return _this.watchWildcardDirectory(directory, flags, configFileName, config); }); + } + else { + config.watchedDirectoriesStale = false; + if (!config.watchedDirectories) + return; + ts.clearMap(config.watchedDirectories, ts.closeFileWatcherOf); + config.watchedDirectories = undefined; + } + }; + /*@internal*/ + ProjectService.prototype.stopWatchingWildCards = function (canonicalConfigFilePath, forProject) { + var configFileExistenceInfo = this.configFileExistenceInfoCache.get(canonicalConfigFilePath); + if (!configFileExistenceInfo.config || + !configFileExistenceInfo.config.projects.get(forProject.canonicalConfigFilePath)) { + return; + } + configFileExistenceInfo.config.projects.set(forProject.canonicalConfigFilePath, false); + // If any of the project is still watching wild cards dont close the watcher + if (ts.forEachEntry(configFileExistenceInfo.config.projects, ts.identity)) + return; + ts.clearMap(configFileExistenceInfo.config.watchedDirectories, ts.closeFileWatcherOf); + configFileExistenceInfo.config.watchedDirectories = undefined; + configFileExistenceInfo.config.watchedDirectoriesStale = undefined; + }; ProjectService.prototype.updateNonInferredProjectFiles = function (project, files, propertyReader) { var projectRootFilesMap = project.getRootFilesMap(); var newRootScriptInfoMap = new ts.Map(); @@ -156554,14 +161845,22 @@ var ts; */ /*@internal*/ ProjectService.prototype.reloadFileNamesOfConfiguredProject = function (project) { - var configFileSpecs = project.getCompilerOptions().configFile.configFileSpecs; - var configFileName = project.getConfigFilePath(); - var fileNames = ts.getFileNamesFromConfigSpecs(configFileSpecs, ts.getDirectoryPath(configFileName), project.getCompilationSettings(), project.getCachedDirectoryStructureHost(), this.hostConfiguration.extraFileExtensions); + var fileNames = this.reloadFileNamesOfParsedConfig(project.getConfigFilePath(), this.configFileExistenceInfoCache.get(project.canonicalConfigFilePath).config); project.updateErrorOnNoInputFiles(fileNames); this.updateNonInferredProjectFiles(project, fileNames.concat(project.getExternalFiles()), fileNamePropertyReader); return project.updateGraph(); }; /*@internal*/ + ProjectService.prototype.reloadFileNamesOfParsedConfig = function (configFileName, config) { + if (config.reloadLevel === undefined) + return config.parsedCommandLine.fileNames; + ts.Debug.assert(config.reloadLevel === ts.ConfigFileProgramReloadLevel.Partial); + var configFileSpecs = config.parsedCommandLine.options.configFile.configFileSpecs; + var fileNames = ts.getFileNamesFromConfigSpecs(configFileSpecs, ts.getDirectoryPath(configFileName), config.parsedCommandLine.options, config.cachedDirectoryStructureHost, this.hostConfiguration.extraFileExtensions); + config.parsedCommandLine = __assign(__assign({}, config.parsedCommandLine), { fileNames: fileNames }); + return fileNames; + }; + /*@internal*/ ProjectService.prototype.setFileNamesOfAutoImportProviderProject = function (project, fileNames) { this.updateNonInferredProjectFiles(project, fileNames, fileNamePropertyReader); }; @@ -156735,7 +162034,7 @@ var ts; return projects; function combineProjects(toAddInfo) { if (toAddInfo !== info) { - var _loop_4 = function (project) { + var _loop_3 = function (project) { // Add the projects only if they can use symLink targets and not already in the list if (project.languageServiceEnabled && !project.isOrphan() && @@ -156752,7 +162051,7 @@ var ts; }; for (var _i = 0, _a = toAddInfo.containingProjects; _i < _a.length; _i++) { var project = _a[_i]; - _loop_4(project); + _loop_3(project); } } } @@ -156960,7 +162259,7 @@ var ts; var snap = mapInfo.getSnapshot(); if (mapInfo.documentPositionMapper !== undefined) return mapInfo.documentPositionMapper; - return snap.getText(0, snap.getLength()); + return ts.getSnapshotText(snap); }; var projectName = project.projectName; var documentPositionMapper = ts.getDocumentPositionMapper({ getCanonicalFileName: this.toCanonicalFileName, log: function (s) { return _this.logger.info(s); }, getSourceFileLike: function (f) { return _this.getSourceFileLike(f, projectName, declarationInfo); } }, declarationInfo.fileName, declarationInfo.getLineInfo(), readMapFile); @@ -157081,7 +162380,7 @@ var ts; }); } if (includePackageJsonAutoImports !== args.preferences.includePackageJsonAutoImports) { - this.invalidateProjectAutoImports(/*packageJsonPath*/ undefined); + this.invalidateProjectPackageJson(/*packageJsonPath*/ undefined); } } if (args.extraFileExtensions) { @@ -157099,7 +162398,10 @@ var ts; }; /*@internal*/ ProjectService.prototype.getWatchOptions = function (project) { - var projectOptions = project.getWatchOptions(); + return this.getWatchOptionsFromProjectWatchOptions(project.getWatchOptions()); + }; + /*@internal*/ + ProjectService.prototype.getWatchOptionsFromProjectWatchOptions = function (projectOptions) { return projectOptions && this.hostConfiguration.watchOptions ? __assign(__assign({}, this.hostConfiguration.watchOptions), projectOptions) : projectOptions || this.hostConfiguration.watchOptions; }; @@ -157133,6 +162435,11 @@ var ts; }); this.throttledOperations.cancel(ensureProjectForOpenFileSchedule); this.pendingEnsureProjectForOpenFiles = false; + // Ensure everything is reloaded for cached configs + this.configFileExistenceInfoCache.forEach(function (info) { + if (info.config) + info.config.reloadLevel = ts.ConfigFileProgramReloadLevel.Full; + }); // Reload Projects this.reloadConfiguredProjectForFiles(this.openFiles, /*clearSemanticCache*/ true, /*delayReload*/ false, ts.returnTrue, "User requested reload projects"); this.externalProjects.forEach(function (project) { @@ -157142,21 +162449,11 @@ var ts; this.inferredProjects.forEach(function (project) { return _this.clearSemanticCache(project); }); this.ensureProjectForOpenFiles(); }; - ProjectService.prototype.delayReloadConfiguredProjectForFiles = function (configFileExistenceInfo, ignoreIfNotRootOfInferredProject) { - // Get open files to reload projects for - this.reloadConfiguredProjectForFiles(configFileExistenceInfo.openFilesImpactedByConfigFile, - /*clearSemanticCache*/ false, - /*delayReload*/ true, ignoreIfNotRootOfInferredProject ? - function (isRootOfInferredProject) { return isRootOfInferredProject; } : // Reload open files if they are root of inferred project - ts.returnTrue, // Reload all the open files impacted by config file - "Change in config file detected"); - this.delayEnsureProjectForOpenFiles(); - }; /** * This function goes through all the openFiles and tries to file the config file for them. * If the config file is found and it refers to existing project, it reloads it either immediately * or schedules it for reload depending on delayReload option - * If the there is no existing project it just opens the configured project for the config file + * If there is no existing project it just opens the configured project for the config file * reloadForInfo provides a way to filter out files to reload configured project for */ ProjectService.prototype.reloadConfiguredProjectForFiles = function (openFiles, clearSemanticCache, delayReload, shouldReloadProjectFor, reason) { @@ -157169,7 +162466,7 @@ var ts; } }; // try to reload config file for all open files - openFiles.forEach(function (openFileValue, path) { + openFiles === null || openFiles === void 0 ? void 0 : openFiles.forEach(function (openFileValue, path) { // Invalidate default config file name for open file _this.configFileForOpenFiles.delete(path); // Filter out the files that need to be ignored @@ -157641,13 +162938,13 @@ var ts; return result; }; ProjectService.prototype.collectChanges = function (lastKnownProjectVersions, currentProjects, includeProjectReferenceRedirectInfo, result) { - var _loop_5 = function (proj) { + var _loop_4 = function (proj) { var knownProject = ts.find(lastKnownProjectVersions, function (p) { return p.projectName === proj.getProjectName(); }); result.push(proj.getChangesSinceVersion(knownProject && knownProject.version, includeProjectReferenceRedirectInfo)); }; for (var _i = 0, currentProjects_1 = currentProjects; _i < currentProjects_1.length; _i++) { var proj = currentProjects_1[_i]; - _loop_5(proj); + _loop_4(proj); } }; /* @internal */ @@ -157787,7 +163084,7 @@ var ts; var excludeRules = []; var normalizedNames = rootFiles.map(function (f) { return ts.normalizeSlashes(f.fileName); }); var excludedFiles = []; - var _loop_6 = function (name) { + var _loop_5 = function (name) { var rule = this_2.safelist[name]; for (var _b = 0, normalizedNames_1 = normalizedNames; _b < normalizedNames_1.length; _b++) { var root = normalizedNames_1[_b]; @@ -157805,7 +163102,7 @@ var ts; } } if (rule.exclude) { - var _loop_8 = function (exclude) { + var _loop_7 = function (exclude) { var processedRule = root.replace(rule.match, function () { var groups = []; for (var _i = 0; _i < arguments.length; _i++) { @@ -157832,7 +163129,7 @@ var ts; }; for (var _e = 0, _f = rule.exclude; _e < _f.length; _e++) { var exclude = _f[_e]; - _loop_8(exclude); + _loop_7(exclude); } } else { @@ -157848,11 +163145,11 @@ var ts; var this_2 = this; for (var _i = 0, _a = Object.keys(this.safelist); _i < _a.length; _i++) { var name = _a[_i]; - _loop_6(name); + _loop_5(name); } var excludeRegexes = excludeRules.map(function (e) { return new RegExp(e, "i"); }); var filesToKeep = []; - var _loop_7 = function (i) { + var _loop_6 = function (i) { if (excludeRegexes.some(function (re) { return re.test(normalizedNames[i]); })) { excludedFiles.push(normalizedNames[i]); } @@ -157890,7 +163187,7 @@ var ts; }; var this_3 = this; for (var i = 0; i < proj.rootFiles.length; i++) { - _loop_7(i); + _loop_6(i); } proj.rootFiles = filesToKeep; return excludedFiles; @@ -158077,7 +163374,7 @@ var ts; var _this = this; var watchers = this.packageJsonFilesMap || (this.packageJsonFilesMap = new ts.Map()); if (!watchers.has(path)) { - this.invalidateProjectAutoImports(path); + this.invalidateProjectPackageJson(path); watchers.set(path, this.watchFactory.watchFile(path, function (fileName, eventKind) { var path = _this.toPath(fileName); switch (eventKind) { @@ -158085,11 +163382,11 @@ var ts; return ts.Debug.fail(); case ts.FileWatcherEventKind.Changed: _this.packageJsonCache.addOrUpdate(path); - _this.invalidateProjectAutoImports(path); + _this.invalidateProjectPackageJson(path); break; case ts.FileWatcherEventKind.Deleted: _this.packageJsonCache.delete(path); - _this.invalidateProjectAutoImports(path); + _this.invalidateProjectPackageJson(path); watchers.get(path).close(); watchers.delete(path); } @@ -158110,16 +163407,16 @@ var ts; } }; /*@internal*/ - ProjectService.prototype.invalidateProjectAutoImports = function (packageJsonPath) { - if (this.includePackageJsonAutoImports()) { - this.configuredProjects.forEach(invalidate); - this.inferredProjects.forEach(invalidate); - this.externalProjects.forEach(invalidate); - } + ProjectService.prototype.invalidateProjectPackageJson = function (packageJsonPath) { + this.configuredProjects.forEach(invalidate); + this.inferredProjects.forEach(invalidate); + this.externalProjects.forEach(invalidate); function invalidate(project) { - var _a; - if (!packageJsonPath || ((_a = project.packageJsonsForAutoImport) === null || _a === void 0 ? void 0 : _a.has(packageJsonPath))) { - project.markAutoImportProviderAsDirty(); + if (packageJsonPath) { + project.onPackageJsonChange(packageJsonPath); + } + else { + project.onAutoImportProviderSettingsChanged(); } } }; @@ -158338,24 +163635,24 @@ var ts; try { if (this.operationHost.isCancellationRequested()) { stop = true; - ts.tracing.instant("session" /* Session */, "stepCanceled", { seq: this.requestId, early: true }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "stepCanceled", { seq: this.requestId, early: true }); } else { - ts.tracing.push("session" /* Session */, "stepAction", { seq: this.requestId }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "stepAction", { seq: this.requestId }); action(this); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } } catch (e) { // Cancellation or an error may have left incomplete events on the tracing stack. - ts.tracing.popAll(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.popAll(); stop = true; // ignore cancellation request if (e instanceof ts.OperationCanceledException) { - ts.tracing.instant("session" /* Session */, "stepCanceled", { seq: this.requestId }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "stepCanceled", { seq: this.requestId }); } else { - ts.tracing.instant("session" /* Session */, "stepError", { seq: this.requestId, message: e.message }); + 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); } } @@ -158457,7 +163754,7 @@ var ts; function combineProjectOutputForReferences(projects, defaultProject, initialLocation) { var outputs = []; combineProjectOutputWorker(projects, defaultProject, initialLocation, function (project, location, getMappedLocation) { - var _loop_9 = function (outputReferencedSymbol) { + var _loop_8 = function (outputReferencedSymbol) { var mappedDefinitionFile = getMappedLocation(project, documentSpanLocation(outputReferencedSymbol.definition)); var definition = mappedDefinitionFile === undefined ? outputReferencedSymbol.definition : __assign(__assign({}, outputReferencedSymbol.definition), { textSpan: ts.createTextSpan(mappedDefinitionFile.pos, outputReferencedSymbol.definition.textSpan.length), fileName: mappedDefinitionFile.fileName, contextSpan: getMappedContextSpan(outputReferencedSymbol.definition, project) }); @@ -158476,7 +163773,7 @@ var ts; }; for (var _i = 0, _a = project.getLanguageService().findReferences(location.fileName, location.pos) || server.emptyArray; _i < _a.length; _i++) { var outputReferencedSymbol = _a[_i]; - _loop_9(outputReferencedSymbol); + _loop_8(outputReferencedSymbol); } }); return outputs.filter(function (o) { return o.references.length !== 0; }); @@ -158889,10 +164186,10 @@ var ts; return _this.requiredResponse(_this.getCompletions(request.arguments, server.CommandNames.CompletionsFull)); }, _a[server.CommandNames.CompletionDetails] = function (request) { - return _this.requiredResponse(_this.getCompletionEntryDetails(request.arguments, /*simplifiedResult*/ true)); + return _this.requiredResponse(_this.getCompletionEntryDetails(request.arguments, /*fullResult*/ false)); }, _a[server.CommandNames.CompletionDetailsFull] = function (request) { - return _this.requiredResponse(_this.getCompletionEntryDetails(request.arguments, /*simplifiedResult*/ false)); + return _this.requiredResponse(_this.getCompletionEntryDetails(request.arguments, /*fullResult*/ true)); }, _a[server.CommandNames.CompileOnSaveAffectedFileList] = function (request) { return _this.requiredResponse(_this.getCompileOnSaveAffectedFileList(request.arguments)); @@ -159285,7 +164582,7 @@ var ts; this.host.write(msgText); }; Session.prototype.event = function (body, eventName) { - ts.tracing.instant("session" /* Session */, "event", { eventName: eventName }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "event", { eventName: eventName }); this.send(toEvent(eventName, body)); }; // For backwards-compatibility only. @@ -159436,7 +164733,8 @@ var ts; }; Session.prototype.getEncodedSemanticClassifications = function (args) { var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - return project.getLanguageService().getEncodedSemanticClassifications(file, args); + var format = args.format === "2020" ? "2020" /* TwentyTwenty */ : "original" /* Original */; + return project.getLanguageService().getEncodedSemanticClassifications(file, args, format); }; Session.prototype.getProject = function (projectFileName) { return projectFileName === undefined ? undefined : this.projectService.findProject(projectFileName); @@ -159517,7 +164815,7 @@ var ts; Session.prototype.mapDefinitionInfoLocations = function (definitions, project) { return definitions.map(function (info) { var newDocumentSpan = getMappedDocumentSpan(info, project); - return !newDocumentSpan ? info : __assign(__assign({}, newDocumentSpan), { containerKind: info.containerKind, containerName: info.containerName, kind: info.kind, name: info.name }); + return !newDocumentSpan ? info : __assign(__assign(__assign({}, newDocumentSpan), { containerKind: info.containerKind, containerName: info.containerName, kind: info.kind, name: info.name }), info.unverified && { unverified: info.unverified }); }); }; Session.prototype.getDefinitionAndBoundSpan = function (args, simplifiedResult) { @@ -159555,9 +164853,27 @@ var ts; result.diagnostics.map(function (d) { return formatDiagnosticToProtocol(d, /*includeFileName*/ true); }) }) : result; }; + Session.prototype.mapJSDocTagInfo = function (tags, project, richResponse) { + var _this = this; + return tags ? tags.map(function (tag) { + var _a; + return (__assign(__assign({}, tag), { text: richResponse ? _this.mapDisplayParts(tag.text, project) : (_a = tag.text) === null || _a === void 0 ? void 0 : _a.map(function (part) { return part.text; }).join("") })); + }) : []; + }; + Session.prototype.mapDisplayParts = function (parts, project) { + var _this = this; + if (!parts) { + return []; + } + return parts.map(function (part) { return part.kind !== "linkName" ? part : __assign(__assign({}, part), { target: _this.toFileSpan(part.target.fileName, part.target.textSpan, project) }); }); + }; + Session.prototype.mapSignatureHelpItems = function (items, project, richResponse) { + var _this = this; + return items.map(function (item) { return (__assign(__assign({}, item), { documentation: _this.mapDisplayParts(item.documentation, project), parameters: item.parameters.map(function (p) { return (__assign(__assign({}, p), { documentation: _this.mapDisplayParts(p.documentation, project) })); }), tags: _this.mapJSDocTagInfo(item.tags, project, richResponse) })); }); + }; Session.prototype.mapDefinitionInfo = function (definitions, project) { var _this = this; - return definitions.map(function (def) { return _this.toFileSpanWithContext(def.fileName, def.textSpan, def.contextSpan, project); }); + return definitions.map(function (def) { return (__assign(__assign({}, _this.toFileSpanWithContext(def.fileName, def.textSpan, def.contextSpan, project)), def.unverified && { unverified: def.unverified })); }); }; /* * When we map a .d.ts location to .ts, Visual Studio gets confused because there's no associated Roslyn Document in @@ -159864,7 +165180,7 @@ var ts; Session.prototype.getDocCommentTemplate = function (args) { var _a = this.getFileAndLanguageServiceForSyntacticOperation(args), file = _a.file, languageService = _a.languageService; var position = this.getPositionInFile(args, file); - return languageService.getDocCommentTemplateAtPosition(file, position); + return languageService.getDocCommentTemplateAtPosition(file, position, this.getPreferences(file)); }; Session.prototype.getSpanOfEnclosingComment = function (args) { var _a = this.getFileAndLanguageServiceForSyntacticOperation(args), file = _a.file, languageService = _a.languageService; @@ -159901,21 +165217,21 @@ var ts; if (!quickInfo) { return undefined; } + var useDisplayParts = !!this.getPreferences(file).displayPartsForJSDoc; if (simplifiedResult) { var displayString = ts.displayPartsToString(quickInfo.displayParts); - var docString = ts.displayPartsToString(quickInfo.documentation); return { kind: quickInfo.kind, kindModifiers: quickInfo.kindModifiers, start: scriptInfo.positionToLineOffset(quickInfo.textSpan.start), end: scriptInfo.positionToLineOffset(ts.textSpanEnd(quickInfo.textSpan)), displayString: displayString, - documentation: docString, - tags: quickInfo.tags || [] + documentation: useDisplayParts ? this.mapDisplayParts(quickInfo.documentation, project) : ts.displayPartsToString(quickInfo.documentation), + tags: this.mapJSDocTagInfo(quickInfo.tags, project, useDisplayParts), }; } else { - return quickInfo; + return useDisplayParts ? quickInfo : __assign(__assign({}, quickInfo), { tags: this.mapJSDocTagInfo(quickInfo.tags, project, /*useDisplayParts*/ false) }); } }; Session.prototype.getFormattingEditsForRange = function (args) { @@ -160006,14 +165322,14 @@ var ts; if (kind === "completions-full" /* CompletionsFull */) return completions; var prefix = args.prefix || ""; - var entries = ts.mapDefined(completions.entries, function (entry) { + var entries = ts.stableSort(ts.mapDefined(completions.entries, function (entry) { if (completions.isMemberCompletion || ts.startsWith(entry.name.toLowerCase(), prefix.toLowerCase())) { - var name = entry.name, kind_1 = entry.kind, kindModifiers = entry.kindModifiers, sortText = entry.sortText, insertText = entry.insertText, replacementSpan = entry.replacementSpan, hasAction = entry.hasAction, source = entry.source, isRecommended = entry.isRecommended, isPackageJsonImport = entry.isPackageJsonImport; + var name = entry.name, kind_1 = entry.kind, kindModifiers = entry.kindModifiers, sortText = entry.sortText, insertText = entry.insertText, replacementSpan = entry.replacementSpan, hasAction = entry.hasAction, source = entry.source, sourceDisplay = entry.sourceDisplay, isSnippet = entry.isSnippet, isRecommended = entry.isRecommended, isPackageJsonImport = entry.isPackageJsonImport, isImportStatementCompletion = entry.isImportStatementCompletion, data = entry.data; var convertedSpan = replacementSpan ? toProtocolTextSpan(replacementSpan, scriptInfo) : undefined; // Use `hasAction || undefined` to avoid serializing `false`. - return { name: name, kind: kind_1, kindModifiers: kindModifiers, sortText: sortText, insertText: insertText, replacementSpan: convertedSpan, hasAction: hasAction || undefined, source: source, isRecommended: isRecommended, isPackageJsonImport: isPackageJsonImport }; + return { name: name, kind: kind_1, kindModifiers: kindModifiers, sortText: sortText, insertText: insertText, replacementSpan: convertedSpan, isSnippet: isSnippet, hasAction: hasAction || undefined, source: source, sourceDisplay: sourceDisplay, isRecommended: isRecommended, isPackageJsonImport: isPackageJsonImport, isImportStatementCompletion: isImportStatementCompletion, data: data }; } - }).sort(function (a, b) { return ts.compareStringsCaseSensitiveUI(a.name, b.name); }); + }), function (a, b) { return ts.compareStringsCaseSensitiveUI(a.name, b.name); }); if (kind === "completions" /* Completions */) { if (completions.metadata) entries.metadata = completions.metadata; @@ -160022,19 +165338,20 @@ var ts; var res = __assign(__assign({}, completions), { optionalReplacementSpan: completions.optionalReplacementSpan && toProtocolTextSpan(completions.optionalReplacementSpan, scriptInfo), entries: entries }); return res; }; - Session.prototype.getCompletionEntryDetails = function (args, simplifiedResult) { + Session.prototype.getCompletionEntryDetails = function (args, fullResult) { var _this = this; var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; var scriptInfo = this.projectService.getScriptInfoForNormalizedPath(file); var position = this.getPosition(args, scriptInfo); var formattingOptions = project.projectService.getFormatCodeOptions(file); + var useDisplayParts = !!this.getPreferences(file).displayPartsForJSDoc; var result = ts.mapDefined(args.entryNames, function (entryName) { - var _a = typeof entryName === "string" ? { name: entryName, source: undefined } : entryName, name = _a.name, source = _a.source; - return project.getLanguageService().getCompletionEntryDetails(file, position, name, formattingOptions, source, _this.getPreferences(file)); + var _a = typeof entryName === "string" ? { name: entryName, source: undefined, data: undefined } : entryName, name = _a.name, source = _a.source, data = _a.data; + return project.getLanguageService().getCompletionEntryDetails(file, position, name, formattingOptions, source, _this.getPreferences(file), data ? ts.cast(data, isCompletionEntryData) : undefined); }); - return simplifiedResult - ? result.map(function (details) { return (__assign(__assign({}, details), { codeActions: ts.map(details.codeActions, function (action) { return _this.mapCodeAction(action); }) })); }) - : result; + return fullResult + ? (useDisplayParts ? result : result.map(function (details) { return (__assign(__assign({}, details), { tags: _this.mapJSDocTagInfo(details.tags, project, /*richResponse*/ false) })); })) + : result.map(function (details) { return (__assign(__assign({}, details), { codeActions: ts.map(details.codeActions, function (action) { return _this.mapCodeAction(action); }), documentation: _this.mapDisplayParts(details.documentation, project), tags: _this.mapJSDocTagInfo(details.tags, project, useDisplayParts) })); }); }; Session.prototype.getCompileOnSaveAffectedFileList = function (args) { var _this = this; @@ -160080,29 +165397,25 @@ var ts; !emitSkipped; }; Session.prototype.getSignatureHelpItems = function (args, simplifiedResult) { + var _this = this; var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; var scriptInfo = this.projectService.getScriptInfoForNormalizedPath(file); var position = this.getPosition(args, scriptInfo); var helpItems = project.getLanguageService().getSignatureHelpItems(file, position, args); - if (!helpItems) { - return undefined; - } - if (simplifiedResult) { + var useDisplayParts = !!this.getPreferences(file).displayPartsForJSDoc; + if (helpItems && simplifiedResult) { var span = helpItems.applicableSpan; - return { - items: helpItems.items, - applicableSpan: { + return __assign(__assign({}, helpItems), { applicableSpan: { start: scriptInfo.positionToLineOffset(span.start), end: scriptInfo.positionToLineOffset(span.start + span.length) - }, - selectedItemIndex: helpItems.selectedItemIndex, - argumentIndex: helpItems.argumentIndex, - argumentCount: helpItems.argumentCount, - }; + }, items: this.mapSignatureHelpItems(helpItems.items, project, useDisplayParts) }); } - else { + else if (useDisplayParts || !helpItems) { return helpItems; } + else { + return __assign(__assign({}, helpItems), { items: helpItems.items.map(function (item) { return (__assign(__assign({}, item), { tags: _this.mapJSDocTagInfo(item.tags, project, /*richResponse*/ false) })); }) }); + } }; Session.prototype.toPendingErrorCheck = function (uncheckedFileName) { var fileName = server.toNormalizedPath(uncheckedFileName); @@ -160308,11 +165621,14 @@ var ts; return result; } }; - Session.prototype.organizeImports = function (_a, simplifiedResult) { - var scope = _a.scope; - ts.Debug.assert(scope.type === "file"); - var _b = this.getFileAndProject(scope.args), file = _b.file, project = _b.project; - var changes = project.getLanguageService().organizeImports({ type: "file", fileName: file }, this.getFormatOptions(file), this.getPreferences(file)); + Session.prototype.organizeImports = function (args, simplifiedResult) { + ts.Debug.assert(args.scope.type === "file"); + var _a = this.getFileAndProject(args.scope.args), file = _a.file, project = _a.project; + var changes = project.getLanguageService().organizeImports({ + fileName: file, + skipDestructiveCodeActions: args.skipDestructiveCodeActions, + type: "file", + }, this.getFormatOptions(file), this.getPreferences(file)); if (simplifiedResult) { return this.mapTextChangesToCodeEdits(changes); } @@ -160334,7 +165650,22 @@ var ts; var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; var scriptInfo = project.getScriptInfoForNormalizedPath(file); var _b = this.getStartAndEndPosition(args, scriptInfo), startPosition = _b.startPosition, endPosition = _b.endPosition; - var codeActions = project.getLanguageService().getCodeFixesAtPosition(file, startPosition, endPosition, args.errorCodes, this.getFormatOptions(file), this.getPreferences(file)); + var codeActions; + try { + codeActions = project.getLanguageService().getCodeFixesAtPosition(file, startPosition, endPosition, args.errorCodes, this.getFormatOptions(file), this.getPreferences(file)); + } + catch (e) { + var ls = project.getLanguageService(); + var existingDiagCodes_1 = __spreadArray(__spreadArray(__spreadArray([], ls.getSyntacticDiagnostics(file)), ls.getSemanticDiagnostics(file)), ls.getSuggestionDiagnostics(file)).map(function (d) { + return ts.decodedTextSpanIntersectsWith(startPosition, endPosition - startPosition, d.start, d.length) + && d.code; + }); + 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; + } + throw e; + } return simplifiedResult ? codeActions.map(function (codeAction) { return _this.mapCodeFixAction(codeAction); }) : codeActions; }; Session.prototype.getCombinedCodeFix = function (_a, simplifiedResult) { @@ -160657,11 +165988,11 @@ var ts; try { request = this.parseMessage(message); relevantFile = request.arguments && request.arguments.file ? request.arguments : undefined; - 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" /* Session */, "request", { seq: request.seq, command: request.command }); ts.perfLogger.logStartCommand("" + request.command, this.toStringMessage(message).substring(0, 100)); - 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" /* Session */, "executeCommand", { seq: request.seq, command: request.command }, /*separateBeginAndEnd*/ true); var _a = this.executeCommand(request), response = _a.response, responseRequired = _a.responseRequired; - ts.tracing.pop(); + 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) { @@ -160673,7 +166004,7 @@ var ts; } // 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.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" /* Session */, "response", { seq: request.seq, command: request.command, success: !!response }); if (response) { this.doOutput(response, request.command, request.seq, /*success*/ true); } @@ -160683,17 +166014,17 @@ var ts; } catch (err) { // Cancellation or an error may have left incomplete events on the tracing stack. - ts.tracing.popAll(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.popAll(); if (err instanceof ts.OperationCanceledException) { // Handle cancellation exceptions ts.perfLogger.logStopCommand("" + (request && request.command), "Canceled: " + err); - 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" /* 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.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" /* 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); @@ -160777,6 +166108,13 @@ var ts; isWriteAccess: isWriteAccess, isDefinition: isDefinition }); } + function isCompletionEntryData(data) { + return data === undefined || data && typeof data === "object" + && typeof data.exportName === "string" + && (data.fileName === undefined || typeof data.fileName === "string") + && (data.ambientModuleName === undefined || typeof data.ambientModuleName === "string" + && (data.isPackageJsonImport === undefined || typeof data.isPackageJsonImport === "boolean")); + } })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); /*@internal*/ @@ -162228,7 +167566,7 @@ var ts; } else { type = operatorOrType; - operator = 138 /* KeyOfKeyword */; + operator = 139 /* KeyOfKeyword */; } return ts.factory.createTypeOperatorNode(operator, type); }, factoryDeprecation); @@ -162356,7 +167694,7 @@ var ts; }, factoryDeprecation); /** @deprecated Use `factory.createJSDocParameterTag` or the factory supplied by your transformation context instead. */ ts.createJSDocParamTag = ts.Debug.deprecate(function createJSDocParamTag(name, isBracketed, typeExpression, comment) { - return ts.factory.createJSDocParameterTag(/*tagName*/ undefined, name, isBracketed, typeExpression, /*isNameFirst*/ false, comment); + return ts.factory.createJSDocParameterTag(/*tagName*/ undefined, name, isBracketed, typeExpression, /*isNameFirst*/ false, comment ? ts.factory.createNodeArray([ts.factory.createJSDocText(comment)]) : undefined); }, factoryDeprecation); /** @deprecated Use `factory.createComma` or the factory supplied by your transformation context instead. */ ts.createComma = ts.Debug.deprecate(function createComma(left, right) { @@ -162406,9 +167744,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 === 297 /* SourceFile */ ? ts.parseBaseNodeFactory.createBaseSourceFileNode(kind) : - kind === 78 /* Identifier */ ? ts.parseBaseNodeFactory.createBaseIdentifierNode(kind) : - kind === 79 /* PrivateIdentifier */ ? ts.parseBaseNodeFactory.createBasePrivateIdentifierNode(kind) : + return ts.setTextRangePosEnd(kind === 299 /* SourceFile */ ? ts.parseBaseNodeFactory.createBaseSourceFileNode(kind) : + kind === 79 /* Identifier */ ? ts.parseBaseNodeFactory.createBaseIdentifierNode(kind) : + kind === 80 /* 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." }); @@ -162435,13 +167773,30 @@ var ts; // #region Renamed node Tests /** @deprecated Use `isTypeAssertionExpression` instead. */ ts.isTypeAssertion = ts.Debug.deprecate(function isTypeAssertion(node) { - return node.kind === 206 /* TypeAssertionExpression */; + return node.kind === 208 /* TypeAssertionExpression */; }, { since: "4.0", warnAfter: "4.1", message: "Use `isTypeAssertionExpression` instead." }); // #endregion + // DEPRECATION: Renamed node tests + // DEPRECATION PLAN: + // - soft: 4.2 + // - warn: 4.3 + // - error: TBD + // #region Renamed node Tests + /** + * @deprecated Use `isMemberName` instead. + */ + ts.isIdentifierOrPrivateIdentifier = ts.Debug.deprecate(function isIdentifierOrPrivateIdentifier(node) { + return ts.isMemberName(node); + }, { + since: "4.2", + warnAfter: "4.3", + message: "Use `isMemberName` instead." + }); + // #endregion Renamed node Tests })(ts || (ts = {})); //# sourceMappingURL=tsserverlibrary.js.map diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index f8f86d5b88fb2..ea5e5d3eeefd4 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -14,7 +14,7 @@ and limitations under the License. ***************************************************************************** */ declare namespace ts { - const versionMajorMinor = "4.2"; + const versionMajorMinor = "4.4"; /** The version of the TypeScript compiler release */ const version: string; /** @@ -166,302 +166,311 @@ declare namespace ts { QuestionQuestionToken = 60, /** Only the JSDoc scanner produces BacktickToken. The normal scanner produces NoSubstitutionTemplateLiteral and related kinds. */ BacktickToken = 61, - EqualsToken = 62, - PlusEqualsToken = 63, - MinusEqualsToken = 64, - AsteriskEqualsToken = 65, - AsteriskAsteriskEqualsToken = 66, - SlashEqualsToken = 67, - PercentEqualsToken = 68, - LessThanLessThanEqualsToken = 69, - GreaterThanGreaterThanEqualsToken = 70, - GreaterThanGreaterThanGreaterThanEqualsToken = 71, - AmpersandEqualsToken = 72, - BarEqualsToken = 73, - BarBarEqualsToken = 74, - AmpersandAmpersandEqualsToken = 75, - QuestionQuestionEqualsToken = 76, - CaretEqualsToken = 77, - Identifier = 78, - PrivateIdentifier = 79, - BreakKeyword = 80, - CaseKeyword = 81, - CatchKeyword = 82, - ClassKeyword = 83, - ConstKeyword = 84, - ContinueKeyword = 85, - DebuggerKeyword = 86, - DefaultKeyword = 87, - DeleteKeyword = 88, - DoKeyword = 89, - ElseKeyword = 90, - EnumKeyword = 91, - ExportKeyword = 92, - ExtendsKeyword = 93, - FalseKeyword = 94, - FinallyKeyword = 95, - ForKeyword = 96, - FunctionKeyword = 97, - IfKeyword = 98, - ImportKeyword = 99, - InKeyword = 100, - InstanceOfKeyword = 101, - NewKeyword = 102, - NullKeyword = 103, - ReturnKeyword = 104, - SuperKeyword = 105, - SwitchKeyword = 106, - ThisKeyword = 107, - ThrowKeyword = 108, - TrueKeyword = 109, - TryKeyword = 110, - TypeOfKeyword = 111, - VarKeyword = 112, - VoidKeyword = 113, - WhileKeyword = 114, - WithKeyword = 115, - ImplementsKeyword = 116, - InterfaceKeyword = 117, - LetKeyword = 118, - PackageKeyword = 119, - PrivateKeyword = 120, - ProtectedKeyword = 121, - PublicKeyword = 122, - StaticKeyword = 123, - YieldKeyword = 124, - AbstractKeyword = 125, - AsKeyword = 126, - AssertsKeyword = 127, - AnyKeyword = 128, - AsyncKeyword = 129, - AwaitKeyword = 130, - BooleanKeyword = 131, - ConstructorKeyword = 132, - DeclareKeyword = 133, - GetKeyword = 134, - InferKeyword = 135, - IntrinsicKeyword = 136, - IsKeyword = 137, - KeyOfKeyword = 138, - ModuleKeyword = 139, - NamespaceKeyword = 140, - NeverKeyword = 141, - ReadonlyKeyword = 142, - RequireKeyword = 143, - NumberKeyword = 144, - ObjectKeyword = 145, - SetKeyword = 146, - StringKeyword = 147, - SymbolKeyword = 148, - TypeKeyword = 149, - UndefinedKeyword = 150, - UniqueKeyword = 151, - UnknownKeyword = 152, - FromKeyword = 153, - GlobalKeyword = 154, - BigIntKeyword = 155, - OfKeyword = 156, - QualifiedName = 157, - ComputedPropertyName = 158, - TypeParameter = 159, - Parameter = 160, - Decorator = 161, - PropertySignature = 162, - PropertyDeclaration = 163, - MethodSignature = 164, - MethodDeclaration = 165, - Constructor = 166, - GetAccessor = 167, - SetAccessor = 168, - CallSignature = 169, - ConstructSignature = 170, - IndexSignature = 171, - TypePredicate = 172, - TypeReference = 173, - FunctionType = 174, - ConstructorType = 175, - TypeQuery = 176, - TypeLiteral = 177, - ArrayType = 178, - TupleType = 179, - OptionalType = 180, - RestType = 181, - UnionType = 182, - IntersectionType = 183, - ConditionalType = 184, - InferType = 185, - ParenthesizedType = 186, - ThisType = 187, - TypeOperator = 188, - IndexedAccessType = 189, - MappedType = 190, - LiteralType = 191, - NamedTupleMember = 192, - TemplateLiteralType = 193, - TemplateLiteralTypeSpan = 194, - ImportType = 195, - ObjectBindingPattern = 196, - ArrayBindingPattern = 197, - BindingElement = 198, - ArrayLiteralExpression = 199, - ObjectLiteralExpression = 200, - PropertyAccessExpression = 201, - ElementAccessExpression = 202, - CallExpression = 203, - NewExpression = 204, - TaggedTemplateExpression = 205, - TypeAssertionExpression = 206, - ParenthesizedExpression = 207, - FunctionExpression = 208, - ArrowFunction = 209, - DeleteExpression = 210, - TypeOfExpression = 211, - VoidExpression = 212, - AwaitExpression = 213, - PrefixUnaryExpression = 214, - PostfixUnaryExpression = 215, - BinaryExpression = 216, - ConditionalExpression = 217, - TemplateExpression = 218, - YieldExpression = 219, - SpreadElement = 220, - ClassExpression = 221, - OmittedExpression = 222, - ExpressionWithTypeArguments = 223, - AsExpression = 224, - NonNullExpression = 225, - MetaProperty = 226, - SyntheticExpression = 227, - TemplateSpan = 228, - SemicolonClassElement = 229, - Block = 230, - EmptyStatement = 231, - VariableStatement = 232, - ExpressionStatement = 233, - IfStatement = 234, - DoStatement = 235, - WhileStatement = 236, - ForStatement = 237, - ForInStatement = 238, - ForOfStatement = 239, - ContinueStatement = 240, - BreakStatement = 241, - ReturnStatement = 242, - WithStatement = 243, - SwitchStatement = 244, - LabeledStatement = 245, - ThrowStatement = 246, - TryStatement = 247, - DebuggerStatement = 248, - VariableDeclaration = 249, - VariableDeclarationList = 250, - FunctionDeclaration = 251, - ClassDeclaration = 252, - InterfaceDeclaration = 253, - TypeAliasDeclaration = 254, - EnumDeclaration = 255, - ModuleDeclaration = 256, - ModuleBlock = 257, - CaseBlock = 258, - NamespaceExportDeclaration = 259, - ImportEqualsDeclaration = 260, - ImportDeclaration = 261, - ImportClause = 262, - NamespaceImport = 263, - NamedImports = 264, - ImportSpecifier = 265, - ExportAssignment = 266, - ExportDeclaration = 267, - NamedExports = 268, - NamespaceExport = 269, - ExportSpecifier = 270, - MissingDeclaration = 271, - ExternalModuleReference = 272, - JsxElement = 273, - JsxSelfClosingElement = 274, - JsxOpeningElement = 275, - JsxClosingElement = 276, - JsxFragment = 277, - JsxOpeningFragment = 278, - JsxClosingFragment = 279, - JsxAttribute = 280, - JsxAttributes = 281, - JsxSpreadAttribute = 282, - JsxExpression = 283, - CaseClause = 284, - DefaultClause = 285, - HeritageClause = 286, - CatchClause = 287, - PropertyAssignment = 288, - ShorthandPropertyAssignment = 289, - SpreadAssignment = 290, - EnumMember = 291, - UnparsedPrologue = 292, - UnparsedPrepend = 293, - UnparsedText = 294, - UnparsedInternalText = 295, - UnparsedSyntheticReference = 296, - SourceFile = 297, - Bundle = 298, - UnparsedSource = 299, - InputFiles = 300, - JSDocTypeExpression = 301, - JSDocNameReference = 302, - JSDocAllType = 303, - JSDocUnknownType = 304, - JSDocNullableType = 305, - JSDocNonNullableType = 306, - JSDocOptionalType = 307, - JSDocFunctionType = 308, - JSDocVariadicType = 309, - JSDocNamepathType = 310, - JSDocComment = 311, - JSDocTypeLiteral = 312, - JSDocSignature = 313, - JSDocTag = 314, - JSDocAugmentsTag = 315, - JSDocImplementsTag = 316, - JSDocAuthorTag = 317, - JSDocDeprecatedTag = 318, - JSDocClassTag = 319, - JSDocPublicTag = 320, - JSDocPrivateTag = 321, - JSDocProtectedTag = 322, - JSDocReadonlyTag = 323, - JSDocCallbackTag = 324, - JSDocEnumTag = 325, - JSDocParameterTag = 326, - JSDocReturnTag = 327, - JSDocThisTag = 328, - JSDocTypeTag = 329, - JSDocTemplateTag = 330, - JSDocTypedefTag = 331, - JSDocSeeTag = 332, - JSDocPropertyTag = 333, - SyntaxList = 334, - NotEmittedStatement = 335, - PartiallyEmittedExpression = 336, - CommaListExpression = 337, - MergeDeclarationMarker = 338, - EndOfDeclarationMarker = 339, - SyntheticReferenceExpression = 340, - Count = 341, - FirstAssignment = 62, - LastAssignment = 77, - FirstCompoundAssignment = 63, - LastCompoundAssignment = 77, - FirstReservedWord = 80, - LastReservedWord = 115, - FirstKeyword = 80, - LastKeyword = 156, - FirstFutureReservedWord = 116, - LastFutureReservedWord = 124, - FirstTypeNode = 172, - LastTypeNode = 195, + /** Only the JSDoc scanner produces HashToken. The normal scanner produces PrivateIdentifier. */ + HashToken = 62, + EqualsToken = 63, + PlusEqualsToken = 64, + MinusEqualsToken = 65, + AsteriskEqualsToken = 66, + AsteriskAsteriskEqualsToken = 67, + SlashEqualsToken = 68, + PercentEqualsToken = 69, + LessThanLessThanEqualsToken = 70, + GreaterThanGreaterThanEqualsToken = 71, + GreaterThanGreaterThanGreaterThanEqualsToken = 72, + AmpersandEqualsToken = 73, + BarEqualsToken = 74, + BarBarEqualsToken = 75, + AmpersandAmpersandEqualsToken = 76, + QuestionQuestionEqualsToken = 77, + CaretEqualsToken = 78, + Identifier = 79, + PrivateIdentifier = 80, + BreakKeyword = 81, + CaseKeyword = 82, + CatchKeyword = 83, + ClassKeyword = 84, + ConstKeyword = 85, + ContinueKeyword = 86, + DebuggerKeyword = 87, + DefaultKeyword = 88, + DeleteKeyword = 89, + DoKeyword = 90, + ElseKeyword = 91, + EnumKeyword = 92, + ExportKeyword = 93, + ExtendsKeyword = 94, + FalseKeyword = 95, + FinallyKeyword = 96, + ForKeyword = 97, + FunctionKeyword = 98, + IfKeyword = 99, + ImportKeyword = 100, + InKeyword = 101, + InstanceOfKeyword = 102, + NewKeyword = 103, + NullKeyword = 104, + ReturnKeyword = 105, + SuperKeyword = 106, + SwitchKeyword = 107, + ThisKeyword = 108, + ThrowKeyword = 109, + TrueKeyword = 110, + TryKeyword = 111, + TypeOfKeyword = 112, + VarKeyword = 113, + VoidKeyword = 114, + WhileKeyword = 115, + WithKeyword = 116, + ImplementsKeyword = 117, + InterfaceKeyword = 118, + LetKeyword = 119, + PackageKeyword = 120, + PrivateKeyword = 121, + ProtectedKeyword = 122, + PublicKeyword = 123, + StaticKeyword = 124, + YieldKeyword = 125, + AbstractKeyword = 126, + AsKeyword = 127, + AssertsKeyword = 128, + AnyKeyword = 129, + AsyncKeyword = 130, + AwaitKeyword = 131, + BooleanKeyword = 132, + ConstructorKeyword = 133, + DeclareKeyword = 134, + GetKeyword = 135, + InferKeyword = 136, + IntrinsicKeyword = 137, + IsKeyword = 138, + KeyOfKeyword = 139, + ModuleKeyword = 140, + NamespaceKeyword = 141, + NeverKeyword = 142, + ReadonlyKeyword = 143, + RequireKeyword = 144, + NumberKeyword = 145, + ObjectKeyword = 146, + SetKeyword = 147, + StringKeyword = 148, + SymbolKeyword = 149, + TypeKeyword = 150, + UndefinedKeyword = 151, + UniqueKeyword = 152, + UnknownKeyword = 153, + FromKeyword = 154, + GlobalKeyword = 155, + BigIntKeyword = 156, + OverrideKeyword = 157, + OfKeyword = 158, + QualifiedName = 159, + ComputedPropertyName = 160, + TypeParameter = 161, + Parameter = 162, + Decorator = 163, + PropertySignature = 164, + PropertyDeclaration = 165, + MethodSignature = 166, + MethodDeclaration = 167, + Constructor = 168, + GetAccessor = 169, + SetAccessor = 170, + CallSignature = 171, + ConstructSignature = 172, + IndexSignature = 173, + TypePredicate = 174, + TypeReference = 175, + FunctionType = 176, + ConstructorType = 177, + TypeQuery = 178, + TypeLiteral = 179, + ArrayType = 180, + TupleType = 181, + OptionalType = 182, + RestType = 183, + UnionType = 184, + IntersectionType = 185, + ConditionalType = 186, + InferType = 187, + ParenthesizedType = 188, + ThisType = 189, + TypeOperator = 190, + IndexedAccessType = 191, + MappedType = 192, + LiteralType = 193, + NamedTupleMember = 194, + TemplateLiteralType = 195, + TemplateLiteralTypeSpan = 196, + ImportType = 197, + ObjectBindingPattern = 198, + ArrayBindingPattern = 199, + BindingElement = 200, + ArrayLiteralExpression = 201, + ObjectLiteralExpression = 202, + PropertyAccessExpression = 203, + ElementAccessExpression = 204, + CallExpression = 205, + NewExpression = 206, + TaggedTemplateExpression = 207, + TypeAssertionExpression = 208, + ParenthesizedExpression = 209, + FunctionExpression = 210, + ArrowFunction = 211, + DeleteExpression = 212, + TypeOfExpression = 213, + VoidExpression = 214, + AwaitExpression = 215, + PrefixUnaryExpression = 216, + PostfixUnaryExpression = 217, + BinaryExpression = 218, + ConditionalExpression = 219, + TemplateExpression = 220, + YieldExpression = 221, + SpreadElement = 222, + ClassExpression = 223, + OmittedExpression = 224, + ExpressionWithTypeArguments = 225, + AsExpression = 226, + NonNullExpression = 227, + MetaProperty = 228, + SyntheticExpression = 229, + TemplateSpan = 230, + SemicolonClassElement = 231, + Block = 232, + EmptyStatement = 233, + VariableStatement = 234, + ExpressionStatement = 235, + IfStatement = 236, + DoStatement = 237, + WhileStatement = 238, + ForStatement = 239, + ForInStatement = 240, + ForOfStatement = 241, + ContinueStatement = 242, + BreakStatement = 243, + ReturnStatement = 244, + WithStatement = 245, + SwitchStatement = 246, + LabeledStatement = 247, + ThrowStatement = 248, + TryStatement = 249, + DebuggerStatement = 250, + VariableDeclaration = 251, + VariableDeclarationList = 252, + FunctionDeclaration = 253, + ClassDeclaration = 254, + InterfaceDeclaration = 255, + TypeAliasDeclaration = 256, + EnumDeclaration = 257, + ModuleDeclaration = 258, + ModuleBlock = 259, + CaseBlock = 260, + NamespaceExportDeclaration = 261, + ImportEqualsDeclaration = 262, + ImportDeclaration = 263, + ImportClause = 264, + NamespaceImport = 265, + NamedImports = 266, + ImportSpecifier = 267, + ExportAssignment = 268, + ExportDeclaration = 269, + NamedExports = 270, + NamespaceExport = 271, + ExportSpecifier = 272, + MissingDeclaration = 273, + ExternalModuleReference = 274, + JsxElement = 275, + JsxSelfClosingElement = 276, + JsxOpeningElement = 277, + JsxClosingElement = 278, + JsxFragment = 279, + JsxOpeningFragment = 280, + JsxClosingFragment = 281, + JsxAttribute = 282, + JsxAttributes = 283, + JsxSpreadAttribute = 284, + JsxExpression = 285, + CaseClause = 286, + DefaultClause = 287, + HeritageClause = 288, + CatchClause = 289, + PropertyAssignment = 290, + ShorthandPropertyAssignment = 291, + SpreadAssignment = 292, + EnumMember = 293, + UnparsedPrologue = 294, + UnparsedPrepend = 295, + UnparsedText = 296, + UnparsedInternalText = 297, + UnparsedSyntheticReference = 298, + SourceFile = 299, + Bundle = 300, + UnparsedSource = 301, + InputFiles = 302, + JSDocTypeExpression = 303, + JSDocNameReference = 304, + JSDocMemberName = 305, + JSDocAllType = 306, + JSDocUnknownType = 307, + JSDocNullableType = 308, + JSDocNonNullableType = 309, + JSDocOptionalType = 310, + JSDocFunctionType = 311, + JSDocVariadicType = 312, + JSDocNamepathType = 313, + JSDocComment = 314, + JSDocText = 315, + JSDocTypeLiteral = 316, + JSDocSignature = 317, + JSDocLink = 318, + JSDocLinkCode = 319, + JSDocLinkPlain = 320, + JSDocTag = 321, + JSDocAugmentsTag = 322, + JSDocImplementsTag = 323, + JSDocAuthorTag = 324, + JSDocDeprecatedTag = 325, + JSDocClassTag = 326, + JSDocPublicTag = 327, + JSDocPrivateTag = 328, + JSDocProtectedTag = 329, + JSDocReadonlyTag = 330, + JSDocOverrideTag = 331, + JSDocCallbackTag = 332, + JSDocEnumTag = 333, + JSDocParameterTag = 334, + JSDocReturnTag = 335, + JSDocThisTag = 336, + JSDocTypeTag = 337, + JSDocTemplateTag = 338, + JSDocTypedefTag = 339, + JSDocSeeTag = 340, + JSDocPropertyTag = 341, + SyntaxList = 342, + NotEmittedStatement = 343, + PartiallyEmittedExpression = 344, + CommaListExpression = 345, + MergeDeclarationMarker = 346, + EndOfDeclarationMarker = 347, + SyntheticReferenceExpression = 348, + Count = 349, + FirstAssignment = 63, + LastAssignment = 78, + FirstCompoundAssignment = 64, + LastCompoundAssignment = 78, + FirstReservedWord = 81, + LastReservedWord = 116, + FirstKeyword = 81, + LastKeyword = 158, + FirstFutureReservedWord = 117, + LastFutureReservedWord = 125, + FirstTypeNode = 174, + LastTypeNode = 197, FirstPunctuation = 18, - LastPunctuation = 77, + LastPunctuation = 78, FirstToken = 0, - LastToken = 156, + LastToken = 158, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -469,25 +478,25 @@ declare namespace ts { FirstTemplateToken = 14, LastTemplateToken = 17, FirstBinaryOperator = 29, - LastBinaryOperator = 77, - FirstStatement = 232, - LastStatement = 248, - FirstNode = 157, - FirstJSDocNode = 301, - LastJSDocNode = 333, - FirstJSDocTagNode = 314, - LastJSDocTagNode = 333, + LastBinaryOperator = 78, + FirstStatement = 234, + LastStatement = 250, + FirstNode = 159, + FirstJSDocNode = 303, + LastJSDocNode = 341, + FirstJSDocTagNode = 321, + LastJSDocTagNode = 341, } export type TriviaSyntaxKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia; export type LiteralSyntaxKind = SyntaxKind.NumericLiteral | SyntaxKind.BigIntLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral; export type PseudoLiteralSyntaxKind = SyntaxKind.TemplateHead | SyntaxKind.TemplateMiddle | SyntaxKind.TemplateTail; - export type PunctuationSyntaxKind = SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.OpenParenToken | SyntaxKind.CloseParenToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.DotToken | SyntaxKind.DotDotDotToken | SyntaxKind.SemicolonToken | SyntaxKind.CommaToken | SyntaxKind.QuestionDotToken | SyntaxKind.LessThanToken | SyntaxKind.LessThanSlashToken | SyntaxKind.GreaterThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.EqualsEqualsToken | SyntaxKind.ExclamationEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.EqualsGreaterThanToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.AsteriskToken | SyntaxKind.AsteriskAsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken | SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken | SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken | SyntaxKind.ExclamationToken | SyntaxKind.TildeToken | SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken | SyntaxKind.QuestionQuestionToken | SyntaxKind.QuestionToken | SyntaxKind.ColonToken | SyntaxKind.AtToken | SyntaxKind.BacktickToken | SyntaxKind.EqualsToken | SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken; - export type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.AssertsKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InferKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.OfKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword; - export type ModifierSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.ConstKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.ExportKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.StaticKeyword; + export type PunctuationSyntaxKind = SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.OpenParenToken | SyntaxKind.CloseParenToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.DotToken | SyntaxKind.DotDotDotToken | SyntaxKind.SemicolonToken | SyntaxKind.CommaToken | SyntaxKind.QuestionDotToken | SyntaxKind.LessThanToken | SyntaxKind.LessThanSlashToken | SyntaxKind.GreaterThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.EqualsEqualsToken | SyntaxKind.ExclamationEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.EqualsGreaterThanToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.AsteriskToken | SyntaxKind.AsteriskAsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken | SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken | SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken | SyntaxKind.ExclamationToken | SyntaxKind.TildeToken | SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken | SyntaxKind.QuestionQuestionToken | SyntaxKind.QuestionToken | SyntaxKind.ColonToken | SyntaxKind.AtToken | SyntaxKind.BacktickToken | SyntaxKind.HashToken | SyntaxKind.EqualsToken | SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken; + export type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.AssertsKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InferKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.OfKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.RequireKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword; + export type ModifierSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.ConstKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.ExportKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.StaticKeyword; export type KeywordTypeSyntaxKind = SyntaxKind.AnyKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VoidKeyword; export type TokenSyntaxKind = SyntaxKind.Unknown | SyntaxKind.EndOfFileToken | TriviaSyntaxKind | LiteralSyntaxKind | PseudoLiteralSyntaxKind | PunctuationSyntaxKind | SyntaxKind.Identifier | KeywordSyntaxKind; export type JsxTokenSyntaxKind = SyntaxKind.LessThanSlashToken | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken; - export type JSDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.GreaterThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.BacktickToken | SyntaxKind.Unknown | KeywordSyntaxKind; + export type JSDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.GreaterThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.BacktickToken | SyntaxKind.HashToken | SyntaxKind.Unknown | KeywordSyntaxKind; export enum NodeFlags { None = 0, Let = 1, @@ -533,13 +542,14 @@ declare namespace ts { Const = 2048, HasComputedJSDocModifiers = 4096, Deprecated = 8192, + Override = 16384, HasComputedFlags = 536870912, AccessibilityModifier = 28, - ParameterPropertyModifier = 92, + ParameterPropertyModifier = 16476, NonPublicAccessibilityModifier = 24, - TypeScriptModifier = 2270, + TypeScriptModifier = 18654, ExportDefault = 513, - All = 11263 + All = 27647 } export enum JsxFlags { None = 0, @@ -558,7 +568,7 @@ declare namespace ts { } export interface JSDocContainer { } - export type HasJSDoc = ParameterDeclaration | CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | PropertySignature | ArrowFunction | ParenthesizedExpression | SpreadAssignment | ShorthandPropertyAssignment | PropertyAssignment | FunctionExpression | LabeledStatement | ExpressionStatement | VariableStatement | FunctionDeclaration | ConstructorDeclaration | MethodDeclaration | PropertyDeclaration | AccessorDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | EnumMember | EnumDeclaration | ModuleDeclaration | ImportEqualsDeclaration | ImportDeclaration | NamespaceExportDeclaration | ExportAssignment | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | ExportDeclaration | NamedTupleMember | EndOfFileToken; + export type HasJSDoc = ParameterDeclaration | CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | PropertySignature | ArrowFunction | ParenthesizedExpression | SpreadAssignment | ShorthandPropertyAssignment | PropertyAssignment | FunctionExpression | EmptyStatement | DebuggerStatement | Block | VariableStatement | ExpressionStatement | IfStatement | DoStatement | WhileStatement | ForStatement | ForInStatement | ForOfStatement | BreakStatement | ContinueStatement | ReturnStatement | WithStatement | SwitchStatement | LabeledStatement | ThrowStatement | TryStatement | FunctionDeclaration | ConstructorDeclaration | MethodDeclaration | VariableDeclaration | PropertyDeclaration | AccessorDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | EnumMember | EnumDeclaration | ModuleDeclaration | ImportEqualsDeclaration | ImportDeclaration | NamespaceExportDeclaration | ExportAssignment | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | ExportDeclaration | NamedTupleMember | EndOfFileToken; export type HasType = SignatureDeclaration | VariableDeclaration | ParameterDeclaration | PropertySignature | PropertyDeclaration | TypePredicateNode | ParenthesizedTypeNode | TypeOperatorNode | MappedTypeNode | AssertionExpression | TypeAliasDeclaration | JSDocTypeExpression | JSDocNonNullableType | JSDocNullableType | JSDocOptionalType | JSDocVariadicType; export type HasTypeArguments = CallExpression | NewExpression | TaggedTemplateExpression | JsxOpeningElement | JsxSelfClosingElement; export type HasInitializer = HasExpressionInitializer | ForStatement | ForInStatement | ForOfStatement | JsxAttribute; @@ -603,10 +613,11 @@ declare namespace ts { export type ProtectedKeyword = ModifierToken; export type PublicKeyword = ModifierToken; export type ReadonlyKeyword = ModifierToken; + export type OverrideKeyword = ModifierToken; export type StaticKeyword = ModifierToken; /** @deprecated Use `ReadonlyKeyword` instead. */ export type ReadonlyToken = ReadonlyKeyword; - export type Modifier = AbstractKeyword | AsyncKeyword | ConstKeyword | DeclareKeyword | DefaultKeyword | ExportKeyword | PrivateKeyword | ProtectedKeyword | PublicKeyword | ReadonlyKeyword | StaticKeyword; + export type Modifier = AbstractKeyword | AsyncKeyword | ConstKeyword | DeclareKeyword | DefaultKeyword | ExportKeyword | PrivateKeyword | ProtectedKeyword | PublicKeyword | OverrideKeyword | ReadonlyKeyword | StaticKeyword; export type AccessibilityModifier = PublicKeyword | PrivateKeyword | ProtectedKeyword; export type ParameterPropertyModifier = AccessibilityModifier | ReadonlyKeyword; export type ClassMemberModifier = AccessibilityModifier | ReadonlyKeyword | StaticKeyword; @@ -638,6 +649,7 @@ declare namespace ts { } export type EntityName = Identifier | QualifiedName; export type PropertyName = Identifier | StringLiteral | NumericLiteral | ComputedPropertyName | PrivateIdentifier; + export type MemberName = Identifier | PrivateIdentifier; export type DeclarationName = Identifier | PrivateIdentifier | StringLiteralLike | NumericLiteral | ComputedPropertyName | ElementAccessExpression | BindingPattern | EntityNameExpression; export interface Declaration extends Node { _declarationBrand: any; @@ -686,7 +698,7 @@ declare namespace ts { readonly kind: SyntaxKind.ConstructSignature; } export type BindingName = Identifier | BindingPattern; - export interface VariableDeclaration extends NamedDeclaration { + export interface VariableDeclaration extends NamedDeclaration, JSDocContainer { readonly kind: SyntaxKind.VariableDeclaration; readonly parent: VariableDeclarationList | CatchClause; readonly name: BindingName; @@ -820,15 +832,15 @@ declare namespace ts { readonly kind: SyntaxKind.SemicolonClassElement; readonly parent: ClassLikeDeclaration; } - export interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { + export interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, TypeElement, ObjectLiteralElement, JSDocContainer { readonly kind: SyntaxKind.GetAccessor; - readonly parent: ClassLikeDeclaration | ObjectLiteralExpression; + readonly parent: ClassLikeDeclaration | ObjectLiteralExpression | TypeLiteralNode | InterfaceDeclaration; readonly name: PropertyName; readonly body?: FunctionBody; } - export interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { + export interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, TypeElement, ObjectLiteralElement, JSDocContainer { readonly kind: SyntaxKind.SetAccessor; - readonly parent: ClassLikeDeclaration | ObjectLiteralExpression; + readonly parent: ClassLikeDeclaration | ObjectLiteralExpression | TypeLiteralNode | InterfaceDeclaration; readonly name: PropertyName; readonly body?: FunctionBody; } @@ -1216,11 +1228,11 @@ declare namespace ts { readonly kind: SyntaxKind.PropertyAccessExpression; readonly expression: LeftHandSideExpression; readonly questionDotToken?: QuestionDotToken; - readonly name: Identifier | PrivateIdentifier; + readonly name: MemberName; } export interface PropertyAccessChain extends PropertyAccessExpression { _optionalChainBrand: any; - readonly name: Identifier | PrivateIdentifier; + readonly name: MemberName; } export interface SuperPropertyAccessExpression extends PropertyAccessExpression { readonly expression: SuperExpression; @@ -1373,7 +1385,7 @@ declare namespace ts { readonly containsOnlyTriviaWhiteSpaces: boolean; } export type JsxChild = JsxText | JsxExpression | JsxElement | JsxSelfClosingElement | JsxFragment; - export interface Statement extends Node { + export interface Statement extends Node, JSDocContainer { _statementBrand: any; } export interface NotEmittedStatement extends Statement { @@ -1401,11 +1413,11 @@ declare namespace ts { readonly kind: SyntaxKind.Block; readonly statements: NodeArray; } - export interface VariableStatement extends Statement, JSDocContainer { + export interface VariableStatement extends Statement { readonly kind: SyntaxKind.VariableStatement; readonly declarationList: VariableDeclarationList; } - export interface ExpressionStatement extends Statement, JSDocContainer { + export interface ExpressionStatement extends Statement { readonly kind: SyntaxKind.ExpressionStatement; readonly expression: Expression; } @@ -1486,7 +1498,7 @@ declare namespace ts { readonly statements: NodeArray; } export type CaseOrDefaultClause = CaseClause | DefaultClause; - export interface LabeledStatement extends Statement, JSDocContainer { + export interface LabeledStatement extends Statement { readonly kind: SyntaxKind.LabeledStatement; readonly label: Identifier; readonly statement: Statement; @@ -1606,7 +1618,7 @@ declare namespace ts { readonly parent: ImportEqualsDeclaration; readonly expression: Expression; } - export interface ImportDeclaration extends Statement, JSDocContainer { + export interface ImportDeclaration extends Statement { readonly kind: SyntaxKind.ImportDeclaration; readonly parent: SourceFile | ModuleBlock; readonly importClause?: ImportClause; @@ -1703,7 +1715,13 @@ declare namespace ts { } export interface JSDocNameReference extends Node { readonly kind: SyntaxKind.JSDocNameReference; - readonly name: EntityName; + readonly name: EntityName | JSDocMemberName; + } + /** Class#method reference in JSDoc */ + export interface JSDocMemberName extends Node { + readonly kind: SyntaxKind.JSDocMemberName; + readonly left: EntityName | JSDocMemberName; + readonly right: Identifier; } export interface JSDocType extends TypeNode { _jsDocTypeBrand: any; @@ -1742,12 +1760,32 @@ declare namespace ts { readonly kind: SyntaxKind.JSDocComment; readonly parent: HasJSDoc; readonly tags?: NodeArray; - readonly comment?: string; + readonly comment?: string | NodeArray; } export interface JSDocTag extends Node { readonly parent: JSDoc | JSDocTypeLiteral; readonly tagName: Identifier; - readonly comment?: string; + readonly comment?: string | NodeArray; + } + export interface JSDocLink extends Node { + readonly kind: SyntaxKind.JSDocLink; + readonly name?: EntityName | JSDocMemberName; + text: string; + } + export interface JSDocLinkCode extends Node { + readonly kind: SyntaxKind.JSDocLinkCode; + readonly name?: EntityName | JSDocMemberName; + text: string; + } + export interface JSDocLinkPlain extends Node { + readonly kind: SyntaxKind.JSDocLinkPlain; + readonly name?: EntityName | JSDocMemberName; + text: string; + } + export type JSDocComment = JSDocText | JSDocLink | JSDocLinkCode | JSDocLinkPlain; + export interface JSDocText extends Node { + readonly kind: SyntaxKind.JSDocText; + text: string; } export interface JSDocUnknownTag extends JSDocTag { readonly kind: SyntaxKind.JSDocTag; @@ -1789,6 +1827,9 @@ declare namespace ts { export interface JSDocReadonlyTag extends JSDocTag { readonly kind: SyntaxKind.JSDocReadonlyTag; } + export interface JSDocOverrideTag extends JSDocTag { + readonly kind: SyntaxKind.JSDocOverrideTag; + } export interface JSDocEnumTag extends JSDocTag, Declaration { readonly kind: SyntaxKind.JSDocEnumTag; readonly parent: JSDoc; @@ -2080,7 +2121,6 @@ declare namespace ts { * Gets a type checker that can be used to semantically analyze source files in the program. */ getTypeChecker(): TypeChecker; - getTypeCatalog(): readonly Type[]; getNodeCount(): number; getIdentifierCount(): number; getSymbolCount(): number; @@ -2186,7 +2226,7 @@ declare namespace ts { * The function returns the value (local variable) symbol of an identifier in the short-hand property assignment. * This is necessary as an identifier in short-hand property assignment can contains two meaning: property name and property value. */ - getShorthandAssignmentValueSymbol(location: Node): Symbol | undefined; + getShorthandAssignmentValueSymbol(location: Node | undefined): Symbol | undefined; getExportSpecifierLocalTargetSymbol(location: ExportSpecifier | Identifier): Symbol | undefined; /** * If a symbol is a local symbol with an associated exported symbol, returns the exported symbol. @@ -2261,6 +2301,8 @@ declare namespace ts { NoTypeReduction = 536870912, NoUndefinedOptionalParameterType = 1073741824, AllowThisInObjectLiteral = 32768, + AllowQualifiedNameInPlaceOfIdentifier = 65536, + /** @deprecated AllowQualifedNameInPlaceOfIdentifier. Use AllowQualifiedNameInPlaceOfIdentifier instead. */ AllowQualifedNameInPlaceOfIdentifier = 65536, AllowAnonymousIdentifier = 131072, AllowEmptyUnionOrIntersection = 262144, @@ -2271,8 +2313,7 @@ declare namespace ts { IgnoreErrors = 70221824, InObjectTypeLiteral = 4194304, InTypeAlias = 8388608, - InInitialEntityName = 16777216, - InReverseMappedType = 33554432 + InInitialEntityName = 16777216 } export enum TypeFormatFlags { None = 0, @@ -2405,8 +2446,8 @@ declare namespace ts { export interface Symbol { flags: SymbolFlags; escapedName: __String; - declarations: Declaration[]; - valueDeclaration: Declaration; + declarations?: Declaration[]; + valueDeclaration?: Declaration; members?: SymbolTable; exports?: SymbolTable; globalExports?: SymbolTable; @@ -2540,15 +2581,15 @@ declare namespace ts { ObjectLiteral = 128, EvolvingArray = 256, ObjectLiteralPatternWithComputedProperties = 512, - ContainsSpread = 1024, - ReverseMapped = 2048, - JsxAttributes = 4096, - MarkerType = 8192, - JSLiteral = 16384, - FreshLiteral = 32768, - ArrayLiteral = 65536, - ObjectRestType = 131072, + ReverseMapped = 1024, + JsxAttributes = 2048, + MarkerType = 4096, + JSLiteral = 8192, + FreshLiteral = 16384, + ArrayLiteral = 32768, ClassOrInterface = 3, + ContainsSpread = 4194304, + ObjectRestType = 8388608, } export interface ObjectType extends Type { objectFlags: ObjectFlags; @@ -2656,14 +2697,13 @@ declare namespace ts { export interface TemplateLiteralType extends InstantiableType { texts: readonly string[]; types: readonly Type[]; - freshType: TemplateLiteralType; - regularType: TemplateLiteralType; } export interface StringMappingType extends InstantiableType { symbol: Symbol; type: Type; } export interface SubstitutionType extends InstantiableType { + objectFlags: ObjectFlags; baseType: Type; substitute: Type; } @@ -2688,16 +2728,17 @@ declare namespace ts { export enum InferencePriority { NakedTypeVariable = 1, SpeculativeTuple = 2, - HomomorphicMappedType = 4, - PartialHomomorphicMappedType = 8, - MappedTypeConstraint = 16, - ContravariantConditional = 32, - ReturnType = 64, - LiteralKeyof = 128, - NoConstraints = 256, - AlwaysStrict = 512, - MaxValue = 1024, - PriorityImpliesCombination = 208, + SubstituteSource = 4, + HomomorphicMappedType = 8, + PartialHomomorphicMappedType = 16, + MappedTypeConstraint = 32, + ContravariantConditional = 64, + ReturnType = 128, + LiteralKeyof = 256, + NoConstraints = 512, + AlwaysStrict = 1024, + MaxValue = 2048, + PriorityImpliesCombination = 416, Circularity = -1 } /** @deprecated Use FileExtensionInfo instead. */ @@ -2774,18 +2815,21 @@ declare namespace ts { FixedPollingInterval = 0, PriorityPollingInterval = 1, DynamicPriorityPolling = 2, - UseFsEvents = 3, - UseFsEventsOnParentDirectory = 4 + FixedChunkSizePolling = 3, + UseFsEvents = 4, + UseFsEventsOnParentDirectory = 5 } export enum WatchDirectoryKind { UseFsEvents = 0, FixedPollingInterval = 1, - DynamicPriorityPolling = 2 + DynamicPriorityPolling = 2, + FixedChunkSizePolling = 3 } export enum PollingWatchKind { FixedInterval = 0, PriorityInterval = 1, - DynamicPriority = 2 + DynamicPriority = 2, + FixedChunkSize = 3 } export type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[] | ProjectReference[] | null | undefined; export interface CompilerOptions { @@ -2847,6 +2891,7 @@ declare namespace ts { outFile?: string; paths?: MapLike; preserveConstEnums?: boolean; + noImplicitOverride?: boolean; preserveSymlinks?: boolean; project?: string; reactNamespace?: string; @@ -2868,11 +2913,13 @@ declare namespace ts { strictBindCallApply?: boolean; strictNullChecks?: boolean; strictPropertyInitialization?: boolean; + strictOptionalProperties?: boolean; stripInternal?: boolean; suppressExcessPropertyErrors?: boolean; suppressImplicitAnyIndexErrors?: boolean; target?: ScriptTarget; traceResolution?: boolean; + useUnknownInCatchVariables?: boolean; resolveJsonModule?: boolean; types?: string[]; /** Paths used to compute primary types search locations */ @@ -2957,6 +3004,7 @@ declare namespace ts { ES2018 = 5, ES2019 = 6, ES2020 = 7, + ES2021 = 8, ESNext = 99, JSON = 100, Latest = 99 @@ -3130,17 +3178,21 @@ declare namespace ts { Iterator = 8388608, NoAsciiEscaping = 16777216, } - export interface EmitHelper { + export interface EmitHelperBase { readonly name: string; readonly scoped: boolean; readonly text: string | ((node: EmitHelperUniqueNameCallback) => string); readonly priority?: number; readonly dependencies?: EmitHelper[]; } - export interface UnscopedEmitHelper extends EmitHelper { + export interface ScopedEmitHelper extends EmitHelperBase { + readonly scoped: true; + } + export interface UnscopedEmitHelper extends EmitHelperBase { readonly scoped: false; readonly text: string; } + export type EmitHelper = ScopedEmitHelper | UnscopedEmitHelper; export type EmitHelperUniqueNameCallback = (name: string) => string; export enum EmitHint { SourceFile = 0, @@ -3168,14 +3220,27 @@ declare namespace ts { createStringLiteralFromNode(sourceNode: PropertyNameLiteral, isSingleQuote?: boolean): StringLiteral; createRegularExpressionLiteral(text: string): RegularExpressionLiteral; createIdentifier(text: string): Identifier; - /** Create a unique temporary variable. */ - createTempVariable(recordTempVariable: ((node: Identifier) => void) | undefined): Identifier; - /** Create a unique temporary variable for use in a loop. */ - createLoopVariable(): Identifier; + /** + * Create a unique temporary variable. + * @param recordTempVariable An optional callback used to record the temporary variable name. This + * should usually be a reference to `hoistVariableDeclaration` from a `TransformationContext`, but + * can be `undefined` if you plan to record the temporary variable manually. + * @param reservedInNestedScopes When `true`, reserves the temporary variable name in all nested scopes + * during emit so that the variable can be referenced in a nested function body. This is an alternative to + * setting `EmitFlags.ReuseTempVariableScope` on the nested function itself. + */ + createTempVariable(recordTempVariable: ((node: Identifier) => void) | undefined, reservedInNestedScopes?: boolean): Identifier; + /** + * Create a unique temporary variable for use in a loop. + * @param reservedInNestedScopes When `true`, reserves the temporary variable name in all nested scopes + * during emit so that the variable can be referenced in a nested function body. This is an alternative to + * setting `EmitFlags.ReuseTempVariableScope` on the nested function itself. + */ + createLoopVariable(reservedInNestedScopes?: boolean): Identifier; /** Create a unique name based on the supplied text. */ createUniqueName(text: string, flags?: GeneratedIdentifierFlags): Identifier; /** Create a unique name generated for a node. */ - getGeneratedNameForNode(node: Node | undefined): Identifier; + getGeneratedNameForNode(node: Node | undefined, flags?: GeneratedIdentifierFlags): Identifier; createPrivateIdentifier(text: string): PrivateIdentifier; createToken(token: SyntaxKind.SuperKeyword): SuperExpression; createToken(token: SyntaxKind.ThisKeyword): ThisExpression; @@ -3286,10 +3351,10 @@ declare namespace ts { updateArrayLiteralExpression(node: ArrayLiteralExpression, elements: readonly Expression[]): ArrayLiteralExpression; createObjectLiteralExpression(properties?: readonly ObjectLiteralElementLike[], multiLine?: boolean): ObjectLiteralExpression; updateObjectLiteralExpression(node: ObjectLiteralExpression, properties: readonly ObjectLiteralElementLike[]): ObjectLiteralExpression; - createPropertyAccessExpression(expression: Expression, name: string | Identifier | PrivateIdentifier): PropertyAccessExpression; - updatePropertyAccessExpression(node: PropertyAccessExpression, expression: Expression, name: Identifier | PrivateIdentifier): PropertyAccessExpression; - createPropertyAccessChain(expression: Expression, questionDotToken: QuestionDotToken | undefined, name: string | Identifier | PrivateIdentifier): PropertyAccessChain; - updatePropertyAccessChain(node: PropertyAccessChain, expression: Expression, questionDotToken: QuestionDotToken | undefined, name: Identifier | PrivateIdentifier): PropertyAccessChain; + createPropertyAccessExpression(expression: Expression, name: string | MemberName): PropertyAccessExpression; + updatePropertyAccessExpression(node: PropertyAccessExpression, expression: Expression, name: MemberName): PropertyAccessExpression; + createPropertyAccessChain(expression: Expression, questionDotToken: QuestionDotToken | undefined, name: string | MemberName): PropertyAccessChain; + updatePropertyAccessChain(node: PropertyAccessChain, expression: Expression, questionDotToken: QuestionDotToken | undefined, name: MemberName): PropertyAccessChain; createElementAccessExpression(expression: Expression, index: number | Expression): ElementAccessExpression; updateElementAccessExpression(node: ElementAccessExpression, expression: Expression, argumentExpression: Expression): ElementAccessExpression; createElementAccessChain(expression: Expression, questionDotToken: QuestionDotToken | undefined, index: number | Expression): ElementAccessChain; @@ -3455,54 +3520,66 @@ declare namespace ts { updateJSDocNamepathType(node: JSDocNamepathType, type: TypeNode): JSDocNamepathType; createJSDocTypeExpression(type: TypeNode): JSDocTypeExpression; updateJSDocTypeExpression(node: JSDocTypeExpression, type: TypeNode): JSDocTypeExpression; - createJSDocNameReference(name: EntityName): JSDocNameReference; - updateJSDocNameReference(node: JSDocNameReference, name: EntityName): JSDocNameReference; + createJSDocNameReference(name: EntityName | JSDocMemberName): JSDocNameReference; + updateJSDocNameReference(node: JSDocNameReference, name: EntityName | JSDocMemberName): JSDocNameReference; + createJSDocMemberName(left: EntityName | JSDocMemberName, right: Identifier): JSDocMemberName; + updateJSDocMemberName(node: JSDocMemberName, left: EntityName | JSDocMemberName, right: Identifier): JSDocMemberName; + createJSDocLink(name: EntityName | JSDocMemberName | undefined, text: string): JSDocLink; + updateJSDocLink(node: JSDocLink, name: EntityName | JSDocMemberName | undefined, text: string): JSDocLink; + createJSDocLinkCode(name: EntityName | JSDocMemberName | undefined, text: string): JSDocLinkCode; + updateJSDocLinkCode(node: JSDocLinkCode, name: EntityName | JSDocMemberName | undefined, text: string): JSDocLinkCode; + createJSDocLinkPlain(name: EntityName | JSDocMemberName | undefined, text: string): JSDocLinkPlain; + updateJSDocLinkPlain(node: JSDocLinkPlain, name: EntityName | JSDocMemberName | undefined, text: string): JSDocLinkPlain; createJSDocTypeLiteral(jsDocPropertyTags?: readonly JSDocPropertyLikeTag[], isArrayType?: boolean): JSDocTypeLiteral; updateJSDocTypeLiteral(node: JSDocTypeLiteral, jsDocPropertyTags: readonly JSDocPropertyLikeTag[] | undefined, isArrayType: boolean | undefined): JSDocTypeLiteral; createJSDocSignature(typeParameters: readonly JSDocTemplateTag[] | undefined, parameters: readonly JSDocParameterTag[], type?: JSDocReturnTag): JSDocSignature; updateJSDocSignature(node: JSDocSignature, typeParameters: readonly JSDocTemplateTag[] | undefined, parameters: readonly JSDocParameterTag[], type: JSDocReturnTag | undefined): JSDocSignature; - createJSDocTemplateTag(tagName: Identifier | undefined, constraint: JSDocTypeExpression | undefined, typeParameters: readonly TypeParameterDeclaration[], comment?: string): JSDocTemplateTag; - updateJSDocTemplateTag(node: JSDocTemplateTag, tagName: Identifier | undefined, constraint: JSDocTypeExpression | undefined, typeParameters: readonly TypeParameterDeclaration[], comment: string | undefined): JSDocTemplateTag; - createJSDocTypedefTag(tagName: Identifier | undefined, typeExpression?: JSDocTypeExpression | JSDocTypeLiteral, fullName?: Identifier | JSDocNamespaceDeclaration, comment?: string): JSDocTypedefTag; - updateJSDocTypedefTag(node: JSDocTypedefTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression | JSDocTypeLiteral | undefined, fullName: Identifier | JSDocNamespaceDeclaration | undefined, comment: string | undefined): JSDocTypedefTag; - createJSDocParameterTag(tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression, isNameFirst?: boolean, comment?: string): JSDocParameterTag; - updateJSDocParameterTag(node: JSDocParameterTag, tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression: JSDocTypeExpression | undefined, isNameFirst: boolean, comment: string | undefined): JSDocParameterTag; - createJSDocPropertyTag(tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression, isNameFirst?: boolean, comment?: string): JSDocPropertyTag; - updateJSDocPropertyTag(node: JSDocPropertyTag, tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression: JSDocTypeExpression | undefined, isNameFirst: boolean, comment: string | undefined): JSDocPropertyTag; - createJSDocTypeTag(tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string): JSDocTypeTag; - updateJSDocTypeTag(node: JSDocTypeTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment: string | undefined): JSDocTypeTag; - createJSDocSeeTag(tagName: Identifier | undefined, nameExpression: JSDocNameReference | undefined, comment?: string): JSDocSeeTag; - updateJSDocSeeTag(node: JSDocSeeTag, tagName: Identifier | undefined, nameExpression: JSDocNameReference | undefined, comment?: string): JSDocSeeTag; - createJSDocReturnTag(tagName: Identifier | undefined, typeExpression?: JSDocTypeExpression, comment?: string): JSDocReturnTag; - updateJSDocReturnTag(node: JSDocReturnTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression | undefined, comment: string | undefined): JSDocReturnTag; - createJSDocThisTag(tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string): JSDocThisTag; - updateJSDocThisTag(node: JSDocThisTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression | undefined, comment: string | undefined): JSDocThisTag; - createJSDocEnumTag(tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string): JSDocEnumTag; - updateJSDocEnumTag(node: JSDocEnumTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment: string | undefined): JSDocEnumTag; - createJSDocCallbackTag(tagName: Identifier | undefined, typeExpression: JSDocSignature, fullName?: Identifier | JSDocNamespaceDeclaration, comment?: string): JSDocCallbackTag; - updateJSDocCallbackTag(node: JSDocCallbackTag, tagName: Identifier | undefined, typeExpression: JSDocSignature, fullName: Identifier | JSDocNamespaceDeclaration | undefined, comment: string | undefined): JSDocCallbackTag; - createJSDocAugmentsTag(tagName: Identifier | undefined, className: JSDocAugmentsTag["class"], comment?: string): JSDocAugmentsTag; - updateJSDocAugmentsTag(node: JSDocAugmentsTag, tagName: Identifier | undefined, className: JSDocAugmentsTag["class"], comment: string | undefined): JSDocAugmentsTag; - createJSDocImplementsTag(tagName: Identifier | undefined, className: JSDocImplementsTag["class"], comment?: string): JSDocImplementsTag; - updateJSDocImplementsTag(node: JSDocImplementsTag, tagName: Identifier | undefined, className: JSDocImplementsTag["class"], comment: string | undefined): JSDocImplementsTag; - createJSDocAuthorTag(tagName: Identifier | undefined, comment?: string): JSDocAuthorTag; - updateJSDocAuthorTag(node: JSDocAuthorTag, tagName: Identifier | undefined, comment: string | undefined): JSDocAuthorTag; - createJSDocClassTag(tagName: Identifier | undefined, comment?: string): JSDocClassTag; - updateJSDocClassTag(node: JSDocClassTag, tagName: Identifier | undefined, comment: string | undefined): JSDocClassTag; - createJSDocPublicTag(tagName: Identifier | undefined, comment?: string): JSDocPublicTag; - updateJSDocPublicTag(node: JSDocPublicTag, tagName: Identifier | undefined, comment: string | undefined): JSDocPublicTag; - createJSDocPrivateTag(tagName: Identifier | undefined, comment?: string): JSDocPrivateTag; - updateJSDocPrivateTag(node: JSDocPrivateTag, tagName: Identifier | undefined, comment: string | undefined): JSDocPrivateTag; - createJSDocProtectedTag(tagName: Identifier | undefined, comment?: string): JSDocProtectedTag; - updateJSDocProtectedTag(node: JSDocProtectedTag, tagName: Identifier | undefined, comment: string | undefined): JSDocProtectedTag; - createJSDocReadonlyTag(tagName: Identifier | undefined, comment?: string): JSDocReadonlyTag; - updateJSDocReadonlyTag(node: JSDocReadonlyTag, tagName: Identifier | undefined, comment: string | undefined): JSDocReadonlyTag; - createJSDocUnknownTag(tagName: Identifier, comment?: string): JSDocUnknownTag; - updateJSDocUnknownTag(node: JSDocUnknownTag, tagName: Identifier, comment: string | undefined): JSDocUnknownTag; - createJSDocDeprecatedTag(tagName: Identifier, comment?: string): JSDocDeprecatedTag; - updateJSDocDeprecatedTag(node: JSDocDeprecatedTag, tagName: Identifier, comment?: string): JSDocDeprecatedTag; - createJSDocComment(comment?: string | undefined, tags?: readonly JSDocTag[] | undefined): JSDoc; - updateJSDocComment(node: JSDoc, comment: string | undefined, tags: readonly JSDocTag[] | undefined): JSDoc; + createJSDocTemplateTag(tagName: Identifier | undefined, constraint: JSDocTypeExpression | undefined, typeParameters: readonly TypeParameterDeclaration[], comment?: string | NodeArray): JSDocTemplateTag; + updateJSDocTemplateTag(node: JSDocTemplateTag, tagName: Identifier | undefined, constraint: JSDocTypeExpression | undefined, typeParameters: readonly TypeParameterDeclaration[], comment: string | NodeArray | undefined): JSDocTemplateTag; + createJSDocTypedefTag(tagName: Identifier | undefined, typeExpression?: JSDocTypeExpression | JSDocTypeLiteral, fullName?: Identifier | JSDocNamespaceDeclaration, comment?: string | NodeArray): JSDocTypedefTag; + updateJSDocTypedefTag(node: JSDocTypedefTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression | JSDocTypeLiteral | undefined, fullName: Identifier | JSDocNamespaceDeclaration | undefined, comment: string | NodeArray | undefined): JSDocTypedefTag; + createJSDocParameterTag(tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression, isNameFirst?: boolean, comment?: string | NodeArray): JSDocParameterTag; + updateJSDocParameterTag(node: JSDocParameterTag, tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression: JSDocTypeExpression | undefined, isNameFirst: boolean, comment: string | NodeArray | undefined): JSDocParameterTag; + createJSDocPropertyTag(tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression, isNameFirst?: boolean, comment?: string | NodeArray): JSDocPropertyTag; + updateJSDocPropertyTag(node: JSDocPropertyTag, tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression: JSDocTypeExpression | undefined, isNameFirst: boolean, comment: string | NodeArray | undefined): JSDocPropertyTag; + createJSDocTypeTag(tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | NodeArray): JSDocTypeTag; + updateJSDocTypeTag(node: JSDocTypeTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment: string | NodeArray | undefined): JSDocTypeTag; + createJSDocSeeTag(tagName: Identifier | undefined, nameExpression: JSDocNameReference | undefined, comment?: string | NodeArray): JSDocSeeTag; + updateJSDocSeeTag(node: JSDocSeeTag, tagName: Identifier | undefined, nameExpression: JSDocNameReference | undefined, comment?: string | NodeArray): JSDocSeeTag; + createJSDocReturnTag(tagName: Identifier | undefined, typeExpression?: JSDocTypeExpression, comment?: string | NodeArray): JSDocReturnTag; + updateJSDocReturnTag(node: JSDocReturnTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression | undefined, comment: string | NodeArray | undefined): JSDocReturnTag; + createJSDocThisTag(tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | NodeArray): JSDocThisTag; + updateJSDocThisTag(node: JSDocThisTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression | undefined, comment: string | NodeArray | undefined): JSDocThisTag; + createJSDocEnumTag(tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | NodeArray): JSDocEnumTag; + updateJSDocEnumTag(node: JSDocEnumTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment: string | NodeArray | undefined): JSDocEnumTag; + createJSDocCallbackTag(tagName: Identifier | undefined, typeExpression: JSDocSignature, fullName?: Identifier | JSDocNamespaceDeclaration, comment?: string | NodeArray): JSDocCallbackTag; + updateJSDocCallbackTag(node: JSDocCallbackTag, tagName: Identifier | undefined, typeExpression: JSDocSignature, fullName: Identifier | JSDocNamespaceDeclaration | undefined, comment: string | NodeArray | undefined): JSDocCallbackTag; + createJSDocAugmentsTag(tagName: Identifier | undefined, className: JSDocAugmentsTag["class"], comment?: string | NodeArray): JSDocAugmentsTag; + updateJSDocAugmentsTag(node: JSDocAugmentsTag, tagName: Identifier | undefined, className: JSDocAugmentsTag["class"], comment: string | NodeArray | undefined): JSDocAugmentsTag; + createJSDocImplementsTag(tagName: Identifier | undefined, className: JSDocImplementsTag["class"], comment?: string | NodeArray): JSDocImplementsTag; + updateJSDocImplementsTag(node: JSDocImplementsTag, tagName: Identifier | undefined, className: JSDocImplementsTag["class"], comment: string | NodeArray | undefined): JSDocImplementsTag; + createJSDocAuthorTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocAuthorTag; + updateJSDocAuthorTag(node: JSDocAuthorTag, tagName: Identifier | undefined, comment: string | NodeArray | undefined): JSDocAuthorTag; + createJSDocClassTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocClassTag; + updateJSDocClassTag(node: JSDocClassTag, tagName: Identifier | undefined, comment: string | NodeArray | undefined): JSDocClassTag; + createJSDocPublicTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocPublicTag; + updateJSDocPublicTag(node: JSDocPublicTag, tagName: Identifier | undefined, comment: string | NodeArray | undefined): JSDocPublicTag; + createJSDocPrivateTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocPrivateTag; + updateJSDocPrivateTag(node: JSDocPrivateTag, tagName: Identifier | undefined, comment: string | NodeArray | undefined): JSDocPrivateTag; + createJSDocProtectedTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocProtectedTag; + updateJSDocProtectedTag(node: JSDocProtectedTag, tagName: Identifier | undefined, comment: string | NodeArray | undefined): JSDocProtectedTag; + createJSDocReadonlyTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocReadonlyTag; + updateJSDocReadonlyTag(node: JSDocReadonlyTag, tagName: Identifier | undefined, comment: string | NodeArray | undefined): JSDocReadonlyTag; + createJSDocUnknownTag(tagName: Identifier, comment?: string | NodeArray): JSDocUnknownTag; + updateJSDocUnknownTag(node: JSDocUnknownTag, tagName: Identifier, comment: string | NodeArray | undefined): JSDocUnknownTag; + createJSDocDeprecatedTag(tagName: Identifier, comment?: string | NodeArray): JSDocDeprecatedTag; + updateJSDocDeprecatedTag(node: JSDocDeprecatedTag, tagName: Identifier, comment?: string | NodeArray): JSDocDeprecatedTag; + createJSDocOverrideTag(tagName: Identifier, comment?: string | NodeArray): JSDocOverrideTag; + updateJSDocOverrideTag(node: JSDocOverrideTag, tagName: Identifier, comment?: string | NodeArray): JSDocOverrideTag; + createJSDocText(text: string): JSDocText; + updateJSDocText(node: JSDocText, text: string): JSDocText; + createJSDocComment(comment?: string | NodeArray | undefined, tags?: readonly JSDocTag[] | undefined): JSDoc; + updateJSDocComment(node: JSDoc, comment: string | NodeArray | undefined, tags: readonly JSDocTag[] | undefined): JSDoc; createJsxElement(openingElement: JsxOpeningElement, children: readonly JsxChild[], closingElement: JsxClosingElement): JsxElement; updateJsxElement(node: JsxElement, openingElement: JsxOpeningElement, children: readonly JsxChild[], closingElement: JsxClosingElement): JsxElement; createJsxSelfClosingElement(tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxSelfClosingElement; @@ -3750,12 +3827,12 @@ declare namespace ts { * }); * ``` */ - onEmitNode?(hint: EmitHint, node: Node | undefined, emitCallback: (hint: EmitHint, node: Node | undefined) => void): void; + onEmitNode?(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void): void; /** * A hook used to check if an emit notification is required for a node. * @param node The node to emit. */ - isEmitNotificationEnabled?(node: Node | undefined): boolean; + isEmitNotificationEnabled?(node: Node): boolean; /** * A hook used by the Printer to perform just-in-time substitution of a node. This is * primarily used by node transformations that need to substitute one node for another, @@ -3869,6 +3946,8 @@ declare namespace ts { readonly disableSuggestions?: boolean; readonly quotePreference?: "auto" | "double" | "single"; readonly includeCompletionsForModuleExports?: boolean; + readonly includeCompletionsForImportStatements?: boolean; + readonly includeCompletionsWithSnippetText?: boolean; readonly includeAutomaticOptionalChainCompletions?: boolean; readonly includeCompletionsWithInsertText?: boolean; readonly importModuleSpecifierPreference?: "shortest" | "project-relative" | "relative" | "non-relative"; @@ -3967,9 +4046,11 @@ declare namespace ts { scanJsxIdentifier(): SyntaxKind; scanJsxAttributeValue(): SyntaxKind; reScanJsxAttributeValue(): SyntaxKind; - reScanJsxToken(): JsxTokenSyntaxKind; + reScanJsxToken(allowMultilineJsxText?: boolean): JsxTokenSyntaxKind; reScanLessThanToken(): SyntaxKind; + reScanHashToken(): SyntaxKind; reScanQuestionToken(): SyntaxKind; + reScanInvalidIdentifier(): SyntaxKind; scanJsxToken(): JsxTokenSyntaxKind; scanJsDocToken(): JSDocSyntaxKind; scan(): SyntaxKind; @@ -4101,7 +4182,7 @@ declare namespace ts { function idText(identifierOrPrivateName: Identifier | PrivateIdentifier): string; function symbolName(symbol: Symbol): string; function getNameOfJSDocTypedef(declaration: JSDocTypedefTag): Identifier | PrivateIdentifier | undefined; - function getNameOfDeclaration(declaration: Declaration | Expression): DeclarationName | undefined; + function getNameOfDeclaration(declaration: Declaration | Expression | undefined): DeclarationName | undefined; /** * Gets the JSDoc parameter tags for the node if present. * @@ -4147,6 +4228,7 @@ declare namespace ts { function getJSDocProtectedTag(node: Node): JSDocProtectedTag | undefined; /** Gets the JSDoc protected tag for the node if present */ function getJSDocReadonlyTag(node: Node): JSDocReadonlyTag | undefined; + function getJSDocOverrideTagNoCache(node: Node): JSDocOverrideTag | undefined; /** Gets the JSDoc deprecated tag for the node if present */ function getJSDocDeprecatedTag(node: Node): JSDocDeprecatedTag | undefined; /** Gets the JSDoc enum tag for the node if present */ @@ -4184,13 +4266,15 @@ declare namespace ts { function getAllJSDocTags(node: Node, predicate: (tag: JSDocTag) => tag is T): readonly T[]; /** Gets all JSDoc tags of a specified kind */ function getAllJSDocTagsOfKind(node: Node, kind: SyntaxKind): readonly JSDocTag[]; + /** Gets the text of a jsdoc comment, flattening links to their text. */ + function getTextOfJSDocComment(comment?: string | NodeArray): string | undefined; /** * Gets the effective type parameters. If the node was parsed in a * JavaScript file, gets the type parameters from the `@template` tag from JSDoc. */ function getEffectiveTypeParameterDeclarations(node: DeclarationWithTypeParameters): readonly TypeParameterDeclaration[]; function getEffectiveConstraintOfTypeParameter(node: TypeParameterDeclaration): TypeNode | undefined; - function isIdentifierOrPrivateIdentifier(node: Node): node is Identifier | PrivateIdentifier; + function isMemberName(node: Node): node is MemberName; function isPropertyAccessChain(node: Node): node is PropertyAccessChain; function isElementAccessChain(node: Node): node is ElementAccessChain; function isCallChain(node: Node): node is CallChain; @@ -4205,6 +4289,12 @@ declare namespace ts { function isUnparsedTextLike(node: Node): node is UnparsedTextLike; function isUnparsedNode(node: Node): node is UnparsedNode; function isJSDocPropertyLikeTag(node: Node): node is JSDocPropertyLikeTag; + /** + * True if kind is of some token syntax kind. + * For example, this is true for an IfKeyword but not for an IfStatement. + * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. + */ + function isTokenKind(kind: SyntaxKind): boolean; /** * True if node is of some token syntax kind. * For example, this is true for an IfKeyword but not for an IfStatement. @@ -4221,7 +4311,7 @@ declare namespace ts { function isEntityName(node: Node): node is EntityName; function isPropertyName(node: Node): node is PropertyName; function isBindingName(node: Node): node is BindingName; - function isFunctionLike(node: Node): node is SignatureDeclaration; + function isFunctionLike(node: Node | undefined): node is SignatureDeclaration; function isClassElement(node: Node): node is ClassElement; function isClassLike(node: Node): node is ClassLikeDeclaration; function isAccessor(node: Node): node is AccessorDeclaration; @@ -4252,6 +4342,7 @@ declare namespace ts { function hasOnlyExpressionInitializer(node: Node): node is HasExpressionInitializer; function isObjectLiteralElement(node: Node): node is ObjectLiteralElement; function isStringLiteralLike(node: Node): node is StringLiteralLike; + function isJSDocLinkLike(node: Node): node is JSDocLink | JSDocLinkCode | JSDocLinkPlain; } declare namespace ts { const factory: NodeFactory; @@ -4347,10 +4438,14 @@ declare namespace ts { function isTemplateHead(node: Node): node is TemplateHead; function isTemplateMiddle(node: Node): node is TemplateMiddle; function isTemplateTail(node: Node): node is TemplateTail; + function isDotDotDotToken(node: Node): node is DotDotDotToken; + function isPlusToken(node: Node): node is PlusToken; + function isMinusToken(node: Node): node is MinusToken; + function isAsteriskToken(node: Node): node is AsteriskToken; function isIdentifier(node: Node): node is Identifier; + function isPrivateIdentifier(node: Node): node is PrivateIdentifier; function isQualifiedName(node: Node): node is QualifiedName; function isComputedPropertyName(node: Node): node is ComputedPropertyName; - function isPrivateIdentifier(node: Node): node is PrivateIdentifier; function isTypeParameterDeclaration(node: Node): node is TypeParameterDeclaration; function isParameter(node: Node): node is ParameterDeclaration; function isDecorator(node: Node): node is Decorator; @@ -4493,6 +4588,10 @@ declare namespace ts { function isUnparsedSource(node: Node): node is UnparsedSource; function isJSDocTypeExpression(node: Node): node is JSDocTypeExpression; function isJSDocNameReference(node: Node): node is JSDocNameReference; + function isJSDocMemberName(node: Node): node is JSDocMemberName; + function isJSDocLink(node: Node): node is JSDocLink; + function isJSDocLinkCode(node: Node): node is JSDocLinkCode; + function isJSDocLinkPlain(node: Node): node is JSDocLinkPlain; function isJSDocAllType(node: Node): node is JSDocAllType; function isJSDocUnknownType(node: Node): node is JSDocUnknownType; function isJSDocNullableType(node: Node): node is JSDocNullableType; @@ -4512,6 +4611,7 @@ declare namespace ts { function isJSDocPrivateTag(node: Node): node is JSDocPrivateTag; function isJSDocProtectedTag(node: Node): node is JSDocProtectedTag; function isJSDocReadonlyTag(node: Node): node is JSDocReadonlyTag; + function isJSDocOverrideTag(node: Node): node is JSDocOverrideTag; function isJSDocDeprecatedTag(node: Node): node is JSDocDeprecatedTag; function isJSDocSeeTag(node: Node): node is JSDocSeeTag; function isJSDocEnumTag(node: Node): node is JSDocEnumTag; @@ -4576,7 +4676,7 @@ declare namespace ts { /** * Reads the config file, reports errors if any and exits if the config file cannot be found */ - export function getParsedCommandLineOfConfigFile(configFileName: string, optionsToExtend: CompilerOptions, host: ParseConfigFileHost, extendedConfigCache?: Map, watchOptionsToExtend?: WatchOptions, extraFileExtensions?: readonly FileExtensionInfo[]): ParsedCommandLine | undefined; + export function getParsedCommandLineOfConfigFile(configFileName: string, optionsToExtend: CompilerOptions | undefined, host: ParseConfigFileHost, extendedConfigCache?: Map, watchOptionsToExtend?: WatchOptions, extraFileExtensions?: readonly FileExtensionInfo[]): ParsedCommandLine | undefined; /** * Read tsconfig.json file * @param fileName The path to the config file @@ -4644,13 +4744,13 @@ declare namespace ts { export {}; } declare namespace ts { - function getEffectiveTypeRoots(options: CompilerOptions, host: GetEffectiveTypeRootsHost): string[] | undefined; + export function getEffectiveTypeRoots(options: CompilerOptions, host: GetEffectiveTypeRootsHost): string[] | undefined; /** * @param {string | undefined} containingFile - file that contains type reference directive, can be undefined if containing file is unknown. * This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups * is assumed to be the same as root directory of the project. */ - function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string | undefined, options: CompilerOptions, host: ModuleResolutionHost, redirectedReference?: ResolvedProjectReference): ResolvedTypeReferenceDirectiveWithFailedLookupLocations; + export function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string | undefined, options: CompilerOptions, host: ModuleResolutionHost, redirectedReference?: ResolvedProjectReference, cache?: TypeReferenceDirectiveResolutionCache): ResolvedTypeReferenceDirectiveWithFailedLookupLocations; /** * Given a set of options, returns the set of type directive names * that should be included for this program automatically. @@ -4659,30 +4759,46 @@ declare namespace ts { * More type directives might appear in the program later as a result of loading actual source files; * this list is only the set of defaults that are implicitly included. */ - function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[]; + export function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[]; + export interface TypeReferenceDirectiveResolutionCache extends PerDirectoryResolutionCache, PackageJsonInfoCache { + } /** - * Cached module resolutions per containing directory. + * Cached resolutions per containing directory. * This assumes that any module id will have the same resolution for sibling files located in the same folder. */ - interface ModuleResolutionCache extends NonRelativeModuleNameResolutionCache { - getOrCreateCacheForDirectory(directoryName: string, redirectedReference?: ResolvedProjectReference): Map; + export interface PerDirectoryResolutionCache { + getOrCreateCacheForDirectory(directoryName: string, redirectedReference?: ResolvedProjectReference): Map; + clear(): void; + /** + * Updates with the current compilerOptions the cache will operate with. + * This updates the redirects map as well if needed so module resolutions are cached if they can across the projects + */ + update(options: CompilerOptions): void; + } + export interface ModuleResolutionCache extends PerDirectoryResolutionCache, NonRelativeModuleNameResolutionCache, PackageJsonInfoCache { + getPackageJsonInfoCache(): PackageJsonInfoCache; } /** * Stored map from non-relative module name to a table: directory -> result of module lookup in this directory * We support only non-relative module names because resolution of relative module names is usually more deterministic and thus less expensive. */ - interface NonRelativeModuleNameResolutionCache { + export interface NonRelativeModuleNameResolutionCache extends PackageJsonInfoCache { getOrCreateCacheForModuleName(nonRelativeModuleName: string, redirectedReference?: ResolvedProjectReference): PerModuleNameCache; } - interface PerModuleNameCache { + export interface PackageJsonInfoCache { + clear(): void; + } + export interface PerModuleNameCache { get(directory: string): ResolvedModuleWithFailedLookupLocations | undefined; set(directory: string, result: ResolvedModuleWithFailedLookupLocations): void; } - function createModuleResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string, options?: CompilerOptions): ModuleResolutionCache; - function resolveModuleNameFromCache(moduleName: string, containingFile: string, cache: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations | undefined; - function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; - function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; - function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; + export function createModuleResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string, options?: CompilerOptions): ModuleResolutionCache; + export function createTypeReferenceDirectiveResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string, options?: CompilerOptions, packageJsonInfoCache?: PackageJsonInfoCache): TypeReferenceDirectiveResolutionCache; + export function resolveModuleNameFromCache(moduleName: string, containingFile: string, cache: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations | undefined; + export function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; + export function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; + export function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; + export {}; } declare namespace ts { /** @@ -4749,6 +4865,10 @@ declare namespace ts { * environment and merging hoisted declarations upon completion. */ function visitFunctionBody(node: ConciseBody, visitor: Visitor, context: TransformationContext): ConciseBody; + /** + * Visits an iteration body, adding any block-scoped variables required by the transformation. + */ + function visitIterationBody(body: Statement, visitor: Visitor, context: TransformationContext): Statement; /** * Visits each child of a Node using the supplied visitor, possibly returning a new Node of the same kind in its place. * @@ -5037,6 +5157,8 @@ declare namespace ts { interface WatchCompilerHost extends ProgramHost, WatchHost { /** Instead of using output d.ts file from project reference, use its source file */ useSourceOfProjectReferenceRedirect?(): boolean; + /** If provided, use this method to get parsed command lines for referenced projects */ + getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined; /** If provided, callback to invoke after every new program creation */ afterProgramCreate?(program: T): void; } @@ -5132,9 +5254,9 @@ declare namespace ts { interface SolutionBuilderWithWatchHost extends SolutionBuilderHostBase, WatchHost { } interface SolutionBuilder { - build(project?: string, cancellationToken?: CancellationToken): ExitStatus; + build(project?: string, cancellationToken?: CancellationToken, writeFile?: WriteFileCallback, getCustomTransformers?: (project: string) => CustomTransformers): ExitStatus; clean(project?: string): ExitStatus; - buildReferences(project: string, cancellationToken?: CancellationToken): ExitStatus; + buildReferences(project: string, cancellationToken?: CancellationToken, writeFile?: WriteFileCallback, getCustomTransformers?: (project: string) => CustomTransformers): ExitStatus; cleanReferences(project?: string): ExitStatus; getNextInvalidatedProject(cancellationToken?: CancellationToken): InvalidatedProject | undefined; } @@ -5292,7 +5414,7 @@ declare namespace ts { getName(): string; getDeclarations(): Declaration[] | undefined; getDocumentationComment(typeChecker: TypeChecker | undefined): SymbolDisplayPart[]; - getJsDocTags(): JSDocTagInfo[]; + getJsDocTags(checker?: TypeChecker): JSDocTagInfo[]; } interface Type { getFlags(): TypeFlags; @@ -5423,6 +5545,7 @@ declare namespace ts { isKnownTypesPackageName?(name: string): boolean; installPackage?(options: InstallPackageOptions): Promise; writeFile?(fileName: string, content: string): void; + getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined; } type WithMetadata = T & { metadata?: unknown; @@ -5512,12 +5635,13 @@ declare namespace ts { * * @param fileName The path to the file * @param position A zero based index of the character where you want the entries - * @param entryName The name from an existing completion which came from `getCompletionsAtPosition` + * @param entryName The `name` from an existing completion which came from `getCompletionsAtPosition` * @param formatOptions How should code samples in the completions be formatted, can be undefined for backwards compatibility - * @param source Source code for the current file, can be undefined for backwards compatibility + * @param source `source` property from the completion entry * @param preferences User settings, can be undefined for backwards compatibility + * @param data `data` property from the completion entry */ - getCompletionEntryDetails(fileName: string, position: number, entryName: string, formatOptions: FormatCodeOptions | FormatCodeSettings | undefined, source: string | undefined, preferences: UserPreferences | undefined): CompletionEntryDetails | undefined; + getCompletionEntryDetails(fileName: string, position: number, entryName: string, formatOptions: FormatCodeOptions | FormatCodeSettings | undefined, source: string | undefined, preferences: UserPreferences | undefined, data: CompletionEntryData | undefined): CompletionEntryDetails | undefined; getCompletionEntrySymbol(fileName: string, position: number, name: string, source: string | undefined): Symbol | undefined; /** * Gets semantic information about the identifier at a particular position in a @@ -5556,7 +5680,7 @@ declare namespace ts { getFormattingEditsForRange(fileName: string, start: number, end: number, options: FormatCodeOptions | FormatCodeSettings): TextChange[]; getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions | FormatCodeSettings): TextChange[]; getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions | FormatCodeSettings): TextChange[]; - getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion | undefined; + getDocCommentTemplateAtPosition(fileName: string, position: number, options?: DocCommentTemplateOptions): TextInsertion | undefined; isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean; /** * This will return a defined result if the position is after the `>` of the opening tag, or somewhere in the text, of a JSXElement with no closing tag. @@ -5578,7 +5702,7 @@ declare namespace ts { applyCodeActionCommand(fileName: string, action: CodeActionCommand | CodeActionCommand[]): Promise; getApplicableRefactors(fileName: string, positionOrRange: number | TextRange, preferences: UserPreferences | undefined, triggerReason?: RefactorTriggerReason, kind?: string): ApplicableRefactorInfo[]; getEditsForRefactor(fileName: string, formatOptions: FormatCodeSettings, positionOrRange: number | TextRange, refactorName: string, actionName: string, preferences: UserPreferences | undefined): RefactorEditInfo | undefined; - organizeImports(scope: OrganizeImportsScope, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): readonly FileTextChanges[]; + organizeImports(args: OrganizeImportsArgs, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): readonly FileTextChanges[]; getEditsForFileRename(oldFilePath: string, newFilePath: string, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): readonly FileTextChanges[]; getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean, forceDtsEmit?: boolean): EmitOutput; getProgram(): Program | undefined; @@ -5595,8 +5719,10 @@ declare namespace ts { type: "file"; fileName: string; } - type OrganizeImportsScope = CombinedCodeFixScope; - type CompletionsTriggerCharacter = "." | '"' | "'" | "`" | "/" | "@" | "<" | "#"; + interface OrganizeImportsArgs extends CombinedCodeFixScope { + skipDestructiveCodeActions?: boolean; + } + type CompletionsTriggerCharacter = "." | '"' | "'" | "`" | "/" | "@" | "<" | "#" | " "; interface GetCompletionsAtPositionOptions extends UserPreferences { /** * If the editor is asking for completions because a certain character was typed @@ -5948,6 +6074,7 @@ declare namespace ts { name: string; containerKind: ScriptElementKind; containerName: string; + unverified?: boolean; } interface DefinitionInfoAndBoundSpan { definitions?: readonly DefinitionInfo[]; @@ -5982,15 +6109,21 @@ declare namespace ts { typeParameterName = 18, enumMemberName = 19, functionName = 20, - regularExpressionLiteral = 21 + regularExpressionLiteral = 21, + link = 22, + linkName = 23, + linkText = 24 } interface SymbolDisplayPart { text: string; kind: string; } + interface JSDocLinkDisplayPart extends SymbolDisplayPart { + target: DocumentSpan; + } interface JSDocTagInfo { name: string; - text?: string; + text?: SymbolDisplayPart[]; } interface QuickInfo { kind: ScriptElementKind; @@ -6021,11 +6154,15 @@ declare namespace ts { interface RenameInfoOptions { readonly allowRenameOfImportPath?: boolean; } + interface DocCommentTemplateOptions { + readonly generateReturnInDocTemplate?: boolean; + } interface SignatureHelpParameter { name: string; documentation: SymbolDisplayPart[]; displayParts: SymbolDisplayPart[]; isOptional: boolean; + isRest?: boolean; } interface SelectionRange { textSpan: TextSpan; @@ -6071,14 +6208,36 @@ declare namespace ts { * true when the current location also allows for a new identifier */ isNewIdentifierLocation: boolean; + /** + * Indicates to client to continue requesting completions on subsequent keystrokes. + */ + isIncomplete?: true; entries: CompletionEntry[]; } + interface CompletionEntryData { + /** The file name declaring the export's module symbol, if it was an external module */ + fileName?: string; + /** The module name (with quotes stripped) of the export's module symbol, if it was an ambient module */ + ambientModuleName?: string; + /** True if the export was found in the package.json AutoImportProvider */ + isPackageJsonImport?: true; + /** + * The name of the property or export in the module's symbol table. Differs from the completion name + * in the case of InternalSymbolName.ExportEquals and InternalSymbolName.Default. + */ + exportName: string; + /** + * Set for auto imports with eagerly resolved module specifiers. + */ + moduleSpecifier?: string; + } interface CompletionEntry { name: string; kind: ScriptElementKind; kindModifiers?: string; sortText: string; insertText?: string; + isSnippet?: true; /** * An optional span that indicates the text to be replaced by this completion item. * If present, this span should be used instead of the default one. @@ -6087,9 +6246,20 @@ declare namespace ts { replacementSpan?: TextSpan; hasAction?: true; source?: string; + sourceDisplay?: SymbolDisplayPart[]; isRecommended?: true; isFromUncheckedFile?: true; isPackageJsonImport?: true; + isImportStatementCompletion?: true; + /** + * A property to be sent back to TS Server in the CompletionDetailsRequest, along with `name`, + * that allows TS Server to look up the symbol represented by the completion item, disambiguating + * items with the same name. Currently only defined for auto-import completions, but the type is + * `unknown` in the protocol, so it can be changed as needed to support other kinds of completions. + * The presence of this property should generally not be used to assume that this completion entry + * is an auto-import. + */ + data?: CompletionEntryData; } interface CompletionEntryDetails { name: string; @@ -6099,7 +6269,9 @@ declare namespace ts { documentation?: SymbolDisplayPart[]; tags?: JSDocTagInfo[]; codeActions?: CodeAction[]; + /** @deprecated Use `sourceDisplay` instead. */ source?: SymbolDisplayPart[]; + sourceDisplay?: SymbolDisplayPart[]; } interface OutliningSpan { /** The span of the document to actually collapse. */ @@ -6253,7 +6425,13 @@ declare namespace ts { */ jsxAttribute = "JSX attribute", /** String literal */ - string = "string" + string = "string", + /** Jsdoc @link: in `{@link C link text}`, the before and after text "{@link " and "}" */ + link = "link", + /** Jsdoc @link: in `{@link C link text}`, the entity name "C" */ + linkName = "link name", + /** Jsdoc @link: in `{@link C link text}`, the link text "link text" */ + linkText = "link text" } enum ScriptElementKindModifier { none = "", @@ -6394,8 +6572,23 @@ declare namespace ts { * @param fileName The name of the file to be released * @param compilationSettings The compilation settings used to acquire the file */ + /**@deprecated pass scriptKind for correctness */ releaseDocument(fileName: string, compilationSettings: CompilerOptions): void; + /** + * Informs the DocumentRegistry that a file is not needed any longer. + * + * Note: It is not allowed to call release on a SourceFile that was not acquired from + * this registry originally. + * + * @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 + */ + releaseDocument(fileName: string, compilationSettings: CompilerOptions, scriptKind: ScriptKind): void; + /** + * @deprecated pass scriptKind for correctness */ releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey): void; + releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey, scriptKind: ScriptKind): void; reportStats(): string; } type DocumentRegistryBucketKey = string & { @@ -6466,7 +6659,7 @@ declare namespace ts { /** @deprecated Use `factory.createRegularExpressionLiteral` or the factory supplied by your transformation context instead. */ const createRegularExpressionLiteral: (text: string) => RegularExpressionLiteral; /** @deprecated Use `factory.createLoopVariable` or the factory supplied by your transformation context instead. */ - const createLoopVariable: () => Identifier; + const createLoopVariable: (reservedInNestedScopes?: boolean | undefined) => Identifier; /** @deprecated Use `factory.createUniqueName` or the factory supplied by your transformation context instead. */ const createUniqueName: (text: string, flags?: GeneratedIdentifierFlags | undefined) => Identifier; /** @deprecated Use `factory.createPrivateIdentifier` or the factory supplied by your transformation context instead. */ @@ -6638,13 +6831,13 @@ declare namespace ts { /** @deprecated Use `factory.updateObjectLiteralExpression` or the factory supplied by your transformation context instead. */ const updateObjectLiteral: (node: ObjectLiteralExpression, properties: readonly ObjectLiteralElementLike[]) => ObjectLiteralExpression; /** @deprecated Use `factory.createPropertyAccessExpression` or the factory supplied by your transformation context instead. */ - const createPropertyAccess: (expression: Expression, name: string | Identifier | PrivateIdentifier) => PropertyAccessExpression; + const createPropertyAccess: (expression: Expression, name: string | MemberName) => PropertyAccessExpression; /** @deprecated Use `factory.updatePropertyAccessExpression` or the factory supplied by your transformation context instead. */ - const updatePropertyAccess: (node: PropertyAccessExpression, expression: Expression, name: Identifier | PrivateIdentifier) => PropertyAccessExpression; + const updatePropertyAccess: (node: PropertyAccessExpression, expression: Expression, name: MemberName) => PropertyAccessExpression; /** @deprecated Use `factory.createPropertyAccessChain` or the factory supplied by your transformation context instead. */ - const createPropertyAccessChain: (expression: Expression, questionDotToken: QuestionDotToken | undefined, name: string | Identifier | PrivateIdentifier) => PropertyAccessChain; + const createPropertyAccessChain: (expression: Expression, questionDotToken: QuestionDotToken | undefined, name: string | MemberName) => PropertyAccessChain; /** @deprecated Use `factory.updatePropertyAccessChain` or the factory supplied by your transformation context instead. */ - const updatePropertyAccessChain: (node: PropertyAccessChain, expression: Expression, questionDotToken: QuestionDotToken | undefined, name: Identifier | PrivateIdentifier) => PropertyAccessChain; + const updatePropertyAccessChain: (node: PropertyAccessChain, expression: Expression, questionDotToken: QuestionDotToken | undefined, name: MemberName) => PropertyAccessChain; /** @deprecated Use `factory.createElementAccessExpression` or the factory supplied by your transformation context instead. */ const createElementAccess: (expression: Expression, index: number | Expression) => ElementAccessExpression; /** @deprecated Use `factory.updateElementAccessExpression` or the factory supplied by your transformation context instead. */ @@ -6914,51 +7107,51 @@ declare namespace ts { /** @deprecated Use `factory.createJSDocTypeExpression` or the factory supplied by your transformation context instead. */ const createJSDocTypeExpression: (type: TypeNode) => JSDocTypeExpression; /** @deprecated Use `factory.createJSDocTypeTag` or the factory supplied by your transformation context instead. */ - const createJSDocTypeTag: (tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | undefined) => JSDocTypeTag; + const createJSDocTypeTag: (tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | NodeArray | undefined) => JSDocTypeTag; /** @deprecated Use `factory.createJSDocReturnTag` or the factory supplied by your transformation context instead. */ - const createJSDocReturnTag: (tagName: Identifier | undefined, typeExpression?: JSDocTypeExpression | undefined, comment?: string | undefined) => JSDocReturnTag; + const createJSDocReturnTag: (tagName: Identifier | undefined, typeExpression?: JSDocTypeExpression | undefined, comment?: string | NodeArray | undefined) => JSDocReturnTag; /** @deprecated Use `factory.createJSDocThisTag` or the factory supplied by your transformation context instead. */ - const createJSDocThisTag: (tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | undefined) => JSDocThisTag; + const createJSDocThisTag: (tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | NodeArray | undefined) => JSDocThisTag; /** @deprecated Use `factory.createJSDocComment` or the factory supplied by your transformation context instead. */ - const createJSDocComment: (comment?: string | undefined, tags?: readonly JSDocTag[] | undefined) => JSDoc; + const createJSDocComment: (comment?: string | NodeArray | undefined, tags?: readonly JSDocTag[] | undefined) => JSDoc; /** @deprecated Use `factory.createJSDocParameterTag` or the factory supplied by your transformation context instead. */ - const createJSDocParameterTag: (tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression | undefined, isNameFirst?: boolean | undefined, comment?: string | undefined) => JSDocParameterTag; + const createJSDocParameterTag: (tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression | undefined, isNameFirst?: boolean | undefined, comment?: string | NodeArray | undefined) => JSDocParameterTag; /** @deprecated Use `factory.createJSDocClassTag` or the factory supplied by your transformation context instead. */ - const createJSDocClassTag: (tagName: Identifier | undefined, comment?: string | undefined) => JSDocClassTag; + const createJSDocClassTag: (tagName: Identifier | undefined, comment?: string | NodeArray | undefined) => JSDocClassTag; /** @deprecated Use `factory.createJSDocAugmentsTag` or the factory supplied by your transformation context instead. */ const createJSDocAugmentsTag: (tagName: Identifier | undefined, className: ExpressionWithTypeArguments & { readonly expression: Identifier | PropertyAccessEntityNameExpression; - }, comment?: string | undefined) => JSDocAugmentsTag; + }, comment?: string | NodeArray | undefined) => JSDocAugmentsTag; /** @deprecated Use `factory.createJSDocEnumTag` or the factory supplied by your transformation context instead. */ - const createJSDocEnumTag: (tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | undefined) => JSDocEnumTag; + const createJSDocEnumTag: (tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | NodeArray | undefined) => JSDocEnumTag; /** @deprecated Use `factory.createJSDocTemplateTag` or the factory supplied by your transformation context instead. */ - const createJSDocTemplateTag: (tagName: Identifier | undefined, constraint: JSDocTypeExpression | undefined, typeParameters: readonly TypeParameterDeclaration[], comment?: string | undefined) => JSDocTemplateTag; + const createJSDocTemplateTag: (tagName: Identifier | undefined, constraint: JSDocTypeExpression | undefined, typeParameters: readonly TypeParameterDeclaration[], comment?: string | NodeArray | undefined) => JSDocTemplateTag; /** @deprecated Use `factory.createJSDocTypedefTag` or the factory supplied by your transformation context instead. */ - const createJSDocTypedefTag: (tagName: Identifier | undefined, typeExpression?: JSDocTypeLiteral | JSDocTypeExpression | undefined, fullName?: Identifier | JSDocNamespaceDeclaration | undefined, comment?: string | undefined) => JSDocTypedefTag; + const createJSDocTypedefTag: (tagName: Identifier | undefined, typeExpression?: JSDocTypeLiteral | JSDocTypeExpression | undefined, fullName?: Identifier | JSDocNamespaceDeclaration | undefined, comment?: string | NodeArray | undefined) => JSDocTypedefTag; /** @deprecated Use `factory.createJSDocCallbackTag` or the factory supplied by your transformation context instead. */ - const createJSDocCallbackTag: (tagName: Identifier | undefined, typeExpression: JSDocSignature, fullName?: Identifier | JSDocNamespaceDeclaration | undefined, comment?: string | undefined) => JSDocCallbackTag; + const createJSDocCallbackTag: (tagName: Identifier | undefined, typeExpression: JSDocSignature, fullName?: Identifier | JSDocNamespaceDeclaration | undefined, comment?: string | NodeArray | undefined) => JSDocCallbackTag; /** @deprecated Use `factory.createJSDocSignature` or the factory supplied by your transformation context instead. */ const createJSDocSignature: (typeParameters: readonly JSDocTemplateTag[] | undefined, parameters: readonly JSDocParameterTag[], type?: JSDocReturnTag | undefined) => JSDocSignature; /** @deprecated Use `factory.createJSDocPropertyTag` or the factory supplied by your transformation context instead. */ - const createJSDocPropertyTag: (tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression | undefined, isNameFirst?: boolean | undefined, comment?: string | undefined) => JSDocPropertyTag; + const createJSDocPropertyTag: (tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression | undefined, isNameFirst?: boolean | undefined, comment?: string | NodeArray | undefined) => JSDocPropertyTag; /** @deprecated Use `factory.createJSDocTypeLiteral` or the factory supplied by your transformation context instead. */ const createJSDocTypeLiteral: (jsDocPropertyTags?: readonly JSDocPropertyLikeTag[] | undefined, isArrayType?: boolean | undefined) => JSDocTypeLiteral; /** @deprecated Use `factory.createJSDocImplementsTag` or the factory supplied by your transformation context instead. */ const createJSDocImplementsTag: (tagName: Identifier | undefined, className: ExpressionWithTypeArguments & { readonly expression: Identifier | PropertyAccessEntityNameExpression; - }, comment?: string | undefined) => JSDocImplementsTag; + }, comment?: string | NodeArray | undefined) => JSDocImplementsTag; /** @deprecated Use `factory.createJSDocAuthorTag` or the factory supplied by your transformation context instead. */ - const createJSDocAuthorTag: (tagName: Identifier | undefined, comment?: string | undefined) => JSDocAuthorTag; + const createJSDocAuthorTag: (tagName: Identifier | undefined, comment?: string | NodeArray | undefined) => JSDocAuthorTag; /** @deprecated Use `factory.createJSDocPublicTag` or the factory supplied by your transformation context instead. */ - const createJSDocPublicTag: (tagName: Identifier | undefined, comment?: string | undefined) => JSDocPublicTag; + const createJSDocPublicTag: (tagName: Identifier | undefined, comment?: string | NodeArray | undefined) => JSDocPublicTag; /** @deprecated Use `factory.createJSDocPrivateTag` or the factory supplied by your transformation context instead. */ - const createJSDocPrivateTag: (tagName: Identifier | undefined, comment?: string | undefined) => JSDocPrivateTag; + const createJSDocPrivateTag: (tagName: Identifier | undefined, comment?: string | NodeArray | undefined) => JSDocPrivateTag; /** @deprecated Use `factory.createJSDocProtectedTag` or the factory supplied by your transformation context instead. */ - const createJSDocProtectedTag: (tagName: Identifier | undefined, comment?: string | undefined) => JSDocProtectedTag; + const createJSDocProtectedTag: (tagName: Identifier | undefined, comment?: string | NodeArray | undefined) => JSDocProtectedTag; /** @deprecated Use `factory.createJSDocReadonlyTag` or the factory supplied by your transformation context instead. */ - const createJSDocReadonlyTag: (tagName: Identifier | undefined, comment?: string | undefined) => JSDocReadonlyTag; + const createJSDocReadonlyTag: (tagName: Identifier | undefined, comment?: string | NodeArray | undefined) => JSDocReadonlyTag; /** @deprecated Use `factory.createJSDocUnknownTag` or the factory supplied by your transformation context instead. */ - const createJSDocTag: (tagName: Identifier, comment?: string | undefined) => JSDocUnknownTag; + const createJSDocTag: (tagName: Identifier, comment?: string | NodeArray | undefined) => JSDocUnknownTag; /** @deprecated Use `factory.createJsxElement` or the factory supplied by your transformation context instead. */ const createJsxElement: (openingElement: JsxOpeningElement, children: readonly JsxChild[], closingElement: JsxClosingElement) => JsxElement; /** @deprecated Use `factory.updateJsxElement` or the factory supplied by your transformation context instead. */ @@ -7214,6 +7407,10 @@ declare namespace ts { */ interface Map extends ESMap { } + /** + * @deprecated Use `isMemberName` instead. + */ + const isIdentifierOrPrivateIdentifier: (node: Node) => node is MemberName; } export = ts; \ No newline at end of file diff --git a/lib/typescript.js b/lib/typescript.js index 48c2fc2c63cea..51b8edf11749c 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -286,7 +286,7 @@ var ts; (function (ts) { // WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values. // If changing the text in this section, be sure to test `configurePrerelease` too. - ts.versionMajorMinor = "4.2"; + ts.versionMajorMinor = "4.4"; // 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 @@ -2133,10 +2133,46 @@ var ts; * Takes a string like "jquery-min.4.2.3" and returns "jquery" */ function removeMinAndVersionNumbers(fileName) { - // Match a "." or "-" followed by a version number or 'min' at the end of the name - var trailingMinOrVersion = /[.-]((min)|(\d+(\.\d+)*))$/; - // The "min" or version may both be present, in either order, so try applying the above twice. - return fileName.replace(trailingMinOrVersion, "").replace(trailingMinOrVersion, ""); + // We used to use the regex /[.-]((min)|(\d+(\.\d+)*))$/ and would just .replace it twice. + // Unfortunately, that regex has O(n^2) performance because v8 doesn't match from the end of the string. + // Instead, we now essentially scan the filename (backwards) ourselves. + var end = fileName.length; + for (var pos = end - 1; pos > 0; pos--) { + var ch = fileName.charCodeAt(pos); + if (ch >= 48 /* _0 */ && ch <= 57 /* _9 */) { + // Match a \d+ segment + do { + --pos; + ch = fileName.charCodeAt(pos); + } while (pos > 0 && ch >= 48 /* _0 */ && ch <= 57 /* _9 */); + } + else if (pos > 4 && (ch === 110 /* n */ || ch === 78 /* N */)) { + // Looking for "min" or "min" + // Already matched the 'n' + --pos; + ch = fileName.charCodeAt(pos); + if (ch !== 105 /* i */ && ch !== 73 /* I */) { + break; + } + --pos; + ch = fileName.charCodeAt(pos); + if (ch !== 109 /* m */ && ch !== 77 /* M */) { + break; + } + --pos; + ch = fileName.charCodeAt(pos); + } + else { + // This character is not part of either suffix pattern + break; + } + if (ch !== 45 /* minus */ && ch !== 46 /* dot */) { + break; + } + end = pos; + } + // end might be fileName.length, in which case this should internally no-op + return end === fileName.length ? fileName : fileName.slice(0, end); } ts.removeMinAndVersionNumbers = removeMinAndVersionNumbers; /** Remove an item from an array, moving everything to its right one space left. */ @@ -2377,6 +2413,33 @@ var ts; return array.slice(0, index); } ts.takeWhile = takeWhile; + /** + * Removes the leading and trailing white space and line terminator characters from a string. + */ + ts.trimString = !!String.prototype.trim ? (function (s) { return s.trim(); }) : function (s) { return ts.trimStringEnd(ts.trimStringStart(s)); }; + /** + * Returns a copy with trailing whitespace removed. + */ + ts.trimStringEnd = !!String.prototype.trimEnd ? (function (s) { return s.trimEnd(); }) : trimEndImpl; + /** + * Returns a copy with leading whitespace removed. + */ + ts.trimStringStart = !!String.prototype.trimStart ? (function (s) { return s.trimStart(); }) : function (s) { return s.replace(/^\s+/g, ""); }; + /** + * https://jsbench.me/gjkoxld4au/1 + * The simple regex for this, /\s+$/g is O(n^2) in v8. + * The native .trimEnd method is by far best, but since that's technically ES2019, + * we provide a (still much faster than the simple regex) fallback. + */ + function trimEndImpl(s) { + var end = s.length - 1; + while (end >= 0) { + if (!ts.isWhiteSpaceLike(s.charCodeAt(end))) + break; + end--; + } + return s.slice(0, end + 1); + } })(ts || (ts = {})); /* @internal */ var ts; @@ -2594,6 +2657,8 @@ var ts; } } Debug.assertMissingNode = assertMissingNode; + function type(_value) { } + Debug.type = type; function getFunctionName(func) { if (typeof func !== "function") { return ""; @@ -2771,6 +2836,9 @@ var ts; // An `Array` with extra properties is rendered as `[A, B, prop1: 1, prop2: 2]`. Most of // these aren't immediately useful so we trim off the `prop1: ..., prop2: ...` part from the // formatted string. + // This regex can trigger slow backtracking because of overlapping potential captures. + // 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; } @@ -2855,11 +2923,11 @@ var ts; this.objectFlags & 8 /* Tuple */ ? "TupleType" : this.objectFlags & 16 /* Anonymous */ ? "AnonymousType" : this.objectFlags & 32 /* Mapped */ ? "MappedType" : - this.objectFlags & 2048 /* ReverseMapped */ ? "ReverseMappedType" : + this.objectFlags & 1024 /* ReverseMapped */ ? "ReverseMappedType" : this.objectFlags & 256 /* EvolvingArray */ ? "EvolvingArrayType" : "ObjectType" : "Type"; - var remainingObjectFlags = this.flags & 524288 /* Object */ ? this.objectFlags & ~2367 /* ObjectTypeKindMask */ : 0; + var remainingObjectFlags = this.flags & 524288 /* Object */ ? this.objectFlags & ~1343 /* ObjectTypeKindMask */ : 0; return "" + typeHeader + (this.symbol ? " '" + ts.symbolName(this.symbol) + "'" : "") + (remainingObjectFlags ? " (" + formatObjectFlags(remainingObjectFlags) + ")" : ""); } }, @@ -3219,7 +3287,7 @@ var ts; // range-set ::= range ( logical-or range ) * // range ::= hyphen | simple ( ' ' simple ) * | '' // logical-or ::= ( ' ' ) * '||' ( ' ' ) * - var logicalOrRegExp = /\s*\|\|\s*/g; + var logicalOrRegExp = /\|\|/g; var whitespaceRegExp = /\s+/g; // https://github.com/npm/node-semver#range-grammar // @@ -3242,14 +3310,15 @@ var ts; // primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial // tilde ::= '~' partial // caret ::= '^' partial - var rangeRegExp = /^\s*(~|\^|<|<=|>|>=|=)?\s*([a-z0-9-+.*]+)$/i; + var rangeRegExp = /^(~|\^|<|<=|>|>=|=)?\s*([a-z0-9-+.*]+)$/i; function parseRange(text) { var alternatives = []; - for (var _i = 0, _a = text.trim().split(logicalOrRegExp); _i < _a.length; _i++) { + for (var _i = 0, _a = ts.trimString(text).split(logicalOrRegExp); _i < _a.length; _i++) { var range = _a[_i]; if (!range) continue; var comparators = []; + range = ts.trimString(range); var match = hyphenRegExp.exec(range); if (match) { if (!parseHyphen(match[1], match[2], comparators)) @@ -3258,7 +3327,7 @@ var ts; else { for (var _b = 0, _c = range.split(whitespaceRegExp); _b < _c.length; _b++) { var simple = _c[_b]; - var match_1 = rangeRegExp.exec(simple); + var match_1 = rangeRegExp.exec(ts.trimString(simple)); if (!match_1 || !parseComparator(match_1[1], match_1[2], comparators)) return undefined; } @@ -3405,16 +3474,22 @@ var ts; typeof PerformanceObserver === "function" && hasRequiredAPI(performance, PerformanceObserver)) { return { + // For now we always write native performance events when running in the browser. We may + // make this conditional in the future if we find that native web performance hooks + // in the browser also slow down compilation. + shouldWriteNativeEvents: true, performance: performance, PerformanceObserver: PerformanceObserver }; } } function tryGetNodePerformanceHooks() { - if (typeof module === "object" && typeof require === "function") { + if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof module === "object" && typeof require === "function") { try { - var _a = require("perf_hooks"), performance_1 = _a.performance, PerformanceObserver_1 = _a.PerformanceObserver; - if (hasRequiredAPI(performance_1, PerformanceObserver_1)) { + var performance_1; + var _a = require("perf_hooks"), nodePerformance_1 = _a.performance, PerformanceObserver_1 = _a.PerformanceObserver; + if (hasRequiredAPI(nodePerformance_1, PerformanceObserver_1)) { + performance_1 = nodePerformance_1; // There is a bug in Node's performance.measure prior to 12.16.3/13.13.0 that does not // match the Web Performance API specification. Node's implementation did not allow // optional `start` and `end` arguments for `performance.measure`. @@ -3422,27 +3497,26 @@ var ts; var version_1 = new ts.Version(process.versions.node); var range = new ts.VersionRange("<12.16.3 || 13 <13.13"); if (range.test(version_1)) { - return { - performance: { - get timeOrigin() { return performance_1.timeOrigin; }, - now: function () { return performance_1.now(); }, - mark: function (name) { return performance_1.mark(name); }, - measure: function (name, start, end) { - if (start === void 0) { start = "nodeStart"; } - if (end === undefined) { - end = "__performance.measure-fix__"; - performance_1.mark(end); - } - performance_1.measure(name, start, end); - if (end === "__performance.measure-fix__") { - performance_1.clearMarks("__performance.measure-fix__"); - } + performance_1 = { + get timeOrigin() { return nodePerformance_1.timeOrigin; }, + now: function () { return nodePerformance_1.now(); }, + mark: function (name) { return nodePerformance_1.mark(name); }, + measure: function (name, start, end) { + if (start === void 0) { start = "nodeStart"; } + if (end === undefined) { + end = "__performance.measure-fix__"; + nodePerformance_1.mark(end); + } + nodePerformance_1.measure(name, start, end); + if (end === "__performance.measure-fix__") { + nodePerformance_1.clearMarks("__performance.measure-fix__"); } - }, - PerformanceObserver: PerformanceObserver_1 + } }; } return { + // By default, only write native events when generating a cpu profile or using the v8 profiler. + shouldWriteNativeEvents: false, performance: performance_1, PerformanceObserver: PerformanceObserver_1 }; @@ -3473,7 +3547,6 @@ var ts; var performance; (function (performance) { var perfHooks; - var perfObserver; // when set, indicates the implementation of `Performance` to use for user timing. // when unset, indicates user timing is unavailable or disabled. var performanceImpl; @@ -3504,6 +3577,9 @@ var ts; } performance.createTimer = createTimer; performance.nullTimer = { enter: ts.noop, exit: ts.noop }; + var enabled = false; + var timeorigin = ts.timestamp(); + var marks = new ts.Map(); var counts = new ts.Map(); var durations = new ts.Map(); /** @@ -3512,7 +3588,13 @@ var ts; * @param markName The name of the mark. */ function mark(markName) { - performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.mark(markName); + var _a; + if (enabled) { + var count = (_a = counts.get(markName)) !== null && _a !== void 0 ? _a : 0; + counts.set(markName, count + 1); + marks.set(markName, ts.timestamp()); + performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.mark(markName); + } } performance.mark = mark; /** @@ -3525,7 +3607,14 @@ var ts; * used. */ function measure(measureName, startMarkName, endMarkName) { - performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.measure(measureName, startMarkName, endMarkName); + var _a, _b; + if (enabled) { + var end = (_a = (endMarkName !== undefined ? marks.get(endMarkName) : undefined)) !== null && _a !== void 0 ? _a : ts.timestamp(); + var start = (_b = (startMarkName !== undefined ? marks.get(startMarkName) : undefined)) !== null && _b !== void 0 ? _b : timeorigin; + var previousDuration = durations.get(measureName) || 0; + durations.set(measureName, previousDuration + (end - start)); + performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.measure(measureName, startMarkName, endMarkName); + } } performance.measure = measure; /** @@ -3559,40 +3648,41 @@ var ts; * Indicates whether the performance API is enabled. */ function isEnabled() { - return !!performanceImpl; + return enabled; } performance.isEnabled = isEnabled; /** Enables (and resets) performance measurements for the compiler. */ - function enable() { - if (!performanceImpl) { + function enable(system) { + var _a; + if (system === void 0) { system = ts.sys; } + if (!enabled) { + enabled = true; perfHooks || (perfHooks = ts.tryGetNativePerformanceHooks()); - if (!perfHooks) - return false; - perfObserver || (perfObserver = new perfHooks.PerformanceObserver(updateStatisticsFromList)); - perfObserver.observe({ entryTypes: ["mark", "measure"] }); - performanceImpl = perfHooks.performance; + if (perfHooks) { + timeorigin = perfHooks.performance.timeOrigin; + // NodeJS's Web Performance API is currently slower than expected, but we'd still like + // to be able to leverage native trace events when node is run with either `--cpu-prof` + // or `--prof`, if we're running with our own `--generateCpuProfile` flag, or when + // running in debug mode (since its possible to generate a cpu profile while debugging). + if (perfHooks.shouldWriteNativeEvents || ((_a = system === null || system === void 0 ? void 0 : system.cpuProfilingEnabled) === null || _a === void 0 ? void 0 : _a.call(system)) || (system === null || system === void 0 ? void 0 : system.debugMode)) { + performanceImpl = perfHooks.performance; + } + } } return true; } performance.enable = enable; /** Disables performance measurements for the compiler. */ function disable() { - perfObserver === null || perfObserver === void 0 ? void 0 : perfObserver.disconnect(); - performanceImpl = undefined; - counts.clear(); - durations.clear(); - } - performance.disable = disable; - function updateStatisticsFromList(list) { - for (var _i = 0, _a = list.getEntriesByType("mark"); _i < _a.length; _i++) { - var mark_1 = _a[_i]; - counts.set(mark_1.name, (counts.get(mark_1.name) || 0) + 1); - } - for (var _b = 0, _c = list.getEntriesByType("measure"); _b < _c.length; _b++) { - var measure_1 = _c[_b]; - durations.set(measure_1.name, (durations.get(measure_1.name) || 0) + measure_1.duration); + if (enabled) { + marks.clear(); + counts.clear(); + durations.clear(); + performanceImpl = undefined; + enabled = false; } } + performance.disable = disable; })(performance = ts.performance || (ts.performance = {})); })(ts || (ts = {})); /* @internal */ @@ -3636,40 +3726,35 @@ var ts; /** Performance logger that will generate ETW events if possible - check for `logEvent` member, as `etwModule` will be `{}` when browserified */ ts.perfLogger = etwModule && etwModule.logEvent ? etwModule : nullLogger; })(ts || (ts = {})); +/* Tracing events for the compiler. */ /*@internal*/ -/** Tracing events for the compiler. */ var ts; (function (ts) { - var tracing; - (function (tracing) { - var Mode; - (function (Mode) { - Mode[Mode["Project"] = 0] = "Project"; - Mode[Mode["Build"] = 1] = "Build"; - Mode[Mode["Server"] = 2] = "Server"; - })(Mode = tracing.Mode || (tracing.Mode = {})); + // enable the above using startTracing() + // `tracingEnabled` should never be used directly, only through the above + var tracingEnabled; + (function (tracingEnabled) { var fs; var traceCount = 0; - var traceFd; + var traceFd = 0; var mode; + var typeCatalog = []; // NB: id is index + 1 var legendPath; var legend = []; ; - /** Starts tracing for the given project (unless the `fs` module is unavailable). */ + /** Starts tracing for the given project. */ function startTracing(tracingMode, traceDir, configFilePath) { - ts.Debug.assert(!traceFd, "Tracing already started"); + ts.Debug.assert(!ts.tracing, "Tracing already started"); if (fs === undefined) { try { fs = require("fs"); } - catch (_a) { - fs = false; + catch (e) { + throw new Error("tracing requires having fs\n(original error: " + (e.message || e) + ")"); } } - if (!fs) { - return; - } mode = tracingMode; + typeCatalog.length = 0; if (legendPath === undefined) { legendPath = ts.combinePaths(traceDir, "legend.json"); } @@ -3677,9 +3762,9 @@ var ts; if (!fs.existsSync(traceDir)) { fs.mkdirSync(traceDir, { recursive: true }); } - var countPart = mode === 1 /* Build */ ? "." + process.pid + "-" + ++traceCount : - mode === 2 /* Server */ ? "." + process.pid : - ""; + var countPart = mode === "build" ? "." + process.pid + "-" + ++traceCount + : mode === "server" ? "." + process.pid + : ""; var tracePath = ts.combinePaths(traceDir, "trace" + countPart + ".json"); var typesPath = ts.combinePaths(traceDir, "types" + countPart + ".json"); legend.push({ @@ -3688,25 +3773,22 @@ var ts; typesPath: typesPath, }); traceFd = fs.openSync(tracePath, "w"); + ts.tracing = tracingEnabled; // only when traceFd is properly set // Start with a prefix that contains some metadata that the devtools profiler expects (also avoids a warning on import) var meta = { cat: "__metadata", ph: "M", ts: 1000 * ts.timestamp(), pid: 1, tid: 1 }; fs.writeSync(traceFd, "[\n" + [__assign({ name: "process_name", args: { name: "tsc" } }, meta), __assign({ name: "thread_name", args: { name: "Main" } }, meta), __assign(__assign({ name: "TracingStartedInBrowser" }, meta), { cat: "disabled-by-default-devtools.timeline" })] .map(function (v) { return JSON.stringify(v); }).join(",\n")); } - tracing.startTracing = startTracing; - /** Stops tracing for the in-progress project and dumps the type catalog (unless the `fs` module is unavailable). */ - function stopTracing(typeCatalog) { - if (!traceFd) { - ts.Debug.assert(!fs, "Tracing is not in progress"); - return; - } - ts.Debug.assert(fs); - ts.Debug.assert(!!typeCatalog === (mode !== 2 /* Server */)); // Have a type catalog iff not in server mode + tracingEnabled.startTracing = startTracing; + /** Stops tracing for the in-progress project and dumps the type catalog. */ + function stopTracing() { + ts.Debug.assert(ts.tracing, "Tracing is not in progress"); + ts.Debug.assert(!!typeCatalog.length === (mode !== "server")); // Have a type catalog iff not in server mode fs.writeSync(traceFd, "\n]\n"); fs.closeSync(traceFd); - traceFd = undefined; - if (typeCatalog) { + ts.tracing = undefined; + if (typeCatalog.length) { dumpTypes(typeCatalog); } else { @@ -3715,11 +3797,13 @@ var ts; legend[legend.length - 1].typesPath = undefined; } } - tracing.stopTracing = stopTracing; - function isTracing() { - return !!traceFd; + tracingEnabled.stopTracing = stopTracing; + function recordType(type) { + if (mode !== "server") { + typeCatalog.push(type); + } } - tracing.isTracing = isTracing; + tracingEnabled.recordType = recordType; var Phase; (function (Phase) { Phase["Parse"] = "parse"; @@ -3729,13 +3813,11 @@ var ts; Phase["CheckTypes"] = "checkTypes"; Phase["Emit"] = "emit"; Phase["Session"] = "session"; - })(Phase = tracing.Phase || (tracing.Phase = {})); + })(Phase = tracingEnabled.Phase || (tracingEnabled.Phase = {})); function instant(phase, name, args) { - if (!traceFd) - return; writeEvent("I", phase, name, args, "\"s\":\"g\""); } - tracing.instant = instant; + tracingEnabled.instant = instant; var eventStack = []; /** * @param separateBeginAndEnd - used for special cases where we need the trace point even if the event @@ -3745,47 +3827,42 @@ var ts; */ function push(phase, name, args, separateBeginAndEnd) { if (separateBeginAndEnd === void 0) { separateBeginAndEnd = false; } - if (!traceFd) - return; if (separateBeginAndEnd) { writeEvent("B", phase, name, args); } eventStack.push({ phase: phase, name: name, args: args, time: 1000 * ts.timestamp(), separateBeginAndEnd: separateBeginAndEnd }); } - tracing.push = push; + tracingEnabled.push = push; function pop() { - if (!traceFd) - return; ts.Debug.assert(eventStack.length > 0); writeStackEvent(eventStack.length - 1, 1000 * ts.timestamp()); eventStack.length--; } - tracing.pop = pop; + tracingEnabled.pop = pop; function popAll() { - if (!traceFd) - return; var endTime = 1000 * ts.timestamp(); for (var i = eventStack.length - 1; i >= 0; i--) { writeStackEvent(i, endTime); } eventStack.length = 0; } - tracing.popAll = popAll; + tracingEnabled.popAll = popAll; + // sample every 10ms + var sampleInterval = 1000 * 10; function writeStackEvent(index, endTime) { var _a = eventStack[index], phase = _a.phase, name = _a.name, args = _a.args, time = _a.time, separateBeginAndEnd = _a.separateBeginAndEnd; if (separateBeginAndEnd) { writeEvent("E", phase, name, args, /*extras*/ undefined, endTime); } - else { + // test if [time,endTime) straddles a sampling point + else if (sampleInterval - (time % sampleInterval) <= endTime - time) { writeEvent("X", phase, name, args, "\"dur\":" + (endTime - time), time); } } function writeEvent(eventType, phase, name, args, extras, time) { if (time === void 0) { time = 1000 * ts.timestamp(); } - ts.Debug.assert(traceFd); - ts.Debug.assert(fs); // In server mode, there's no easy way to dump type information, so we drop events that would require it. - if (mode === 2 /* Server */ && phase === "checkTypes" /* CheckTypes */) + if (mode === "server" && phase === "checkTypes" /* CheckTypes */) return; ts.performance.mark("beginTracing"); fs.writeSync(traceFd, ",\n{\"pid\":1,\"tid\":1,\"ph\":\"" + eventType + "\",\"cat\":\"" + phase + "\",\"ts\":" + time + ",\"name\":\"" + name + "\""); @@ -3797,15 +3874,24 @@ var ts; ts.performance.mark("endTracing"); ts.performance.measure("Tracing", "beginTracing", "endTracing"); } - function indexFromOne(lc) { - return { - line: lc.line + 1, - character: lc.character + 1, - }; + function getLocation(node) { + var file = ts.getSourceFileOfNode(node); + return !file + ? undefined + : { + path: file.path, + start: indexFromOne(ts.getLineAndCharacterOfPosition(file, node.pos)), + end: indexFromOne(ts.getLineAndCharacterOfPosition(file, node.end)), + }; + function indexFromOne(lc) { + return { + line: lc.line + 1, + character: lc.character + 1, + }; + } } function dumpTypes(types) { - var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r; - ts.Debug.assert(fs); + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x; ts.performance.mark("beginDumpTypes"); var typesPath = legend[legend.length - 1].typesPath; var typesFd = fs.openSync(typesPath, "w"); @@ -3817,15 +3903,13 @@ var ts; var type = types[i]; var objectFlags = type.objectFlags; var symbol = (_a = type.aliasSymbol) !== null && _a !== void 0 ? _a : type.symbol; - var firstDeclaration = (_b = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _b === void 0 ? void 0 : _b[0]; - var firstFile = firstDeclaration && ts.getSourceFileOfNode(firstDeclaration); // 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 */)) { try { - display = (_c = type.checker) === null || _c === void 0 ? void 0 : _c.typeToString(type); + display = (_b = type.checker) === null || _b === void 0 ? void 0 : _b.typeToString(type); } - catch (_s) { + catch (_y) { display = undefined; } } @@ -3833,26 +3917,52 @@ var ts; if (type.flags & 8388608 /* IndexedAccess */) { var indexedAccessType = type; indexedAccessProperties = { - indexedAccessObjectType: (_d = indexedAccessType.objectType) === null || _d === void 0 ? void 0 : _d.id, - indexedAccessIndexType: (_e = indexedAccessType.indexType) === null || _e === void 0 ? void 0 : _e.id, + indexedAccessObjectType: (_c = indexedAccessType.objectType) === null || _c === void 0 ? void 0 : _c.id, + indexedAccessIndexType: (_d = indexedAccessType.indexType) === null || _d === void 0 ? void 0 : _d.id, }; } var referenceProperties = {}; if (objectFlags & 4 /* Reference */) { var referenceType = type; referenceProperties = { - instantiatedType: (_f = referenceType.target) === null || _f === void 0 ? void 0 : _f.id, - typeArguments: (_g = referenceType.resolvedTypeArguments) === null || _g === void 0 ? void 0 : _g.map(function (t) { return t.id; }), + instantiatedType: (_e = referenceType.target) === null || _e === void 0 ? void 0 : _e.id, + typeArguments: (_f = referenceType.resolvedTypeArguments) === null || _f === void 0 ? void 0 : _f.map(function (t) { return t.id; }), + referenceLocation: getLocation(referenceType.node), }; } var conditionalProperties = {}; if (type.flags & 16777216 /* Conditional */) { var conditionalType = type; conditionalProperties = { - conditionalCheckType: (_h = conditionalType.checkType) === null || _h === void 0 ? void 0 : _h.id, - conditionalExtendsType: (_j = conditionalType.extendsType) === null || _j === void 0 ? void 0 : _j.id, - conditionalTrueType: (_l = (_k = conditionalType.resolvedTrueType) === null || _k === void 0 ? void 0 : _k.id) !== null && _l !== void 0 ? _l : -1, - conditionalFalseType: (_o = (_m = conditionalType.resolvedFalseType) === null || _m === void 0 ? void 0 : _m.id) !== null && _o !== void 0 ? _o : -1, + conditionalCheckType: (_g = conditionalType.checkType) === null || _g === void 0 ? void 0 : _g.id, + conditionalExtendsType: (_h = conditionalType.extendsType) === null || _h === void 0 ? void 0 : _h.id, + conditionalTrueType: (_k = (_j = conditionalType.resolvedTrueType) === null || _j === void 0 ? void 0 : _j.id) !== null && _k !== void 0 ? _k : -1, + conditionalFalseType: (_m = (_l = conditionalType.resolvedFalseType) === null || _l === void 0 ? void 0 : _l.id) !== null && _m !== void 0 ? _m : -1, + }; + } + var substitutionProperties = {}; + if (type.flags & 33554432 /* Substitution */) { + var substitutionType = type; + substitutionProperties = { + substitutionBaseType: (_o = substitutionType.baseType) === null || _o === void 0 ? void 0 : _o.id, + substituteType: (_p = substitutionType.substitute) === null || _p === void 0 ? void 0 : _p.id, + }; + } + var reverseMappedProperties = {}; + if (objectFlags & 1024 /* ReverseMapped */) { + var reverseMappedType = type; + reverseMappedProperties = { + reverseMappedSourceType: (_q = reverseMappedType.source) === null || _q === void 0 ? void 0 : _q.id, + reverseMappedMappedType: (_r = reverseMappedType.mappedType) === null || _r === void 0 ? void 0 : _r.id, + reverseMappedConstraintType: (_s = reverseMappedType.constraintType) === null || _s === void 0 ? void 0 : _s.id, + }; + } + var evolvingArrayProperties = {}; + if (objectFlags & 256 /* EvolvingArray */) { + var evolvingArrayType = type; + evolvingArrayProperties = { + evolvingArrayElementType: evolvingArrayType.elementType.id, + evolvingArrayFinalType: (_t = evolvingArrayType.finalArrayType) === null || _t === void 0 ? void 0 : _t.id, }; } // We can't print out an arbitrary object, so just assign each one a unique number. @@ -3866,11 +3976,7 @@ var ts; recursionIdentityMap.set(recursionIdentity, recursionToken); } } - var descriptor = __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, unionTypes: (type.flags & 1048576 /* Union */) ? (_p = type.types) === null || _p === void 0 ? void 0 : _p.map(function (t) { return t.id; }) : undefined, intersectionTypes: (type.flags & 2097152 /* Intersection */) ? type.types.map(function (t) { return t.id; }) : undefined, aliasTypeArguments: (_q = type.aliasTypeArguments) === null || _q === void 0 ? void 0 : _q.map(function (t) { return t.id; }), keyofType: (type.flags & 4194304 /* Index */) ? (_r = type.type) === null || _r === void 0 ? void 0 : _r.id : undefined }, indexedAccessProperties), referenceProperties), conditionalProperties), { firstDeclaration: firstDeclaration && { - path: firstFile.path, - start: indexFromOne(ts.getLineAndCharacterOfPosition(firstFile, firstDeclaration.pos)), - end: indexFromOne(ts.getLineAndCharacterOfPosition(ts.getSourceFileOfNode(firstDeclaration), firstDeclaration.end)), - }, 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 /* 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 }); fs.writeSync(typesFd, JSON.stringify(descriptor)); if (i < numTypes - 1) { fs.writeSync(typesFd, ",\n"); @@ -3885,11 +3991,13 @@ var ts; if (!legendPath) { return; } - ts.Debug.assert(fs); fs.writeFileSync(legendPath, JSON.stringify(legend)); } - tracing.dumpLegend = dumpLegend; - })(tracing = ts.tracing || (ts.tracing = {})); + tracingEnabled.dumpLegend = dumpLegend; + })(tracingEnabled || (tracingEnabled = {})); + // define after tracingEnabled is initialized + ts.startTracing = tracingEnabled.startTracing; + ts.dumpTracingLegend = tracingEnabled.dumpLegend; })(ts || (ts = {})); var ts; (function (ts) { @@ -3966,331 +4074,337 @@ var ts; SyntaxKind[SyntaxKind["QuestionQuestionToken"] = 60] = "QuestionQuestionToken"; /** Only the JSDoc scanner produces BacktickToken. The normal scanner produces NoSubstitutionTemplateLiteral and related kinds. */ SyntaxKind[SyntaxKind["BacktickToken"] = 61] = "BacktickToken"; + /** Only the JSDoc scanner produces HashToken. The normal scanner produces PrivateIdentifier. */ + SyntaxKind[SyntaxKind["HashToken"] = 62] = "HashToken"; // Assignments - SyntaxKind[SyntaxKind["EqualsToken"] = 62] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 63] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 64] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 65] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 66] = "AsteriskAsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 67] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 68] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 69] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 70] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 71] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 72] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 73] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["BarBarEqualsToken"] = 74] = "BarBarEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandEqualsToken"] = 75] = "AmpersandAmpersandEqualsToken"; - SyntaxKind[SyntaxKind["QuestionQuestionEqualsToken"] = 76] = "QuestionQuestionEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 77] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 63] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 64] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 65] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 66] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 67] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 68] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 69] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 70] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 71] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 72] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 73] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 74] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["BarBarEqualsToken"] = 75] = "BarBarEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandEqualsToken"] = 76] = "AmpersandAmpersandEqualsToken"; + SyntaxKind[SyntaxKind["QuestionQuestionEqualsToken"] = 77] = "QuestionQuestionEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 78] = "CaretEqualsToken"; // Identifiers and PrivateIdentifiers - SyntaxKind[SyntaxKind["Identifier"] = 78] = "Identifier"; - SyntaxKind[SyntaxKind["PrivateIdentifier"] = 79] = "PrivateIdentifier"; + SyntaxKind[SyntaxKind["Identifier"] = 79] = "Identifier"; + SyntaxKind[SyntaxKind["PrivateIdentifier"] = 80] = "PrivateIdentifier"; // Reserved words - SyntaxKind[SyntaxKind["BreakKeyword"] = 80] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 81] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 82] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 83] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 84] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 85] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 86] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 87] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 88] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 89] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 90] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 91] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 92] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 93] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 94] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 95] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 96] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 97] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 98] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 99] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 100] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 101] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 102] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 103] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 104] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 105] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 106] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 107] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 108] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 109] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 110] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 111] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 112] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 113] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 114] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 115] = "WithKeyword"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 81] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 82] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 83] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 84] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 85] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 86] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 87] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 88] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 89] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 90] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 91] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 92] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 93] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 94] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 95] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 96] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 97] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 98] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 99] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 100] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 101] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 102] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 103] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 104] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 105] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 106] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 107] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 108] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 109] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 110] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 111] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 112] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 113] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 114] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 115] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 116] = "WithKeyword"; // Strict mode reserved words - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 116] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 117] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 118] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 119] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 120] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 121] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 122] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 123] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 124] = "YieldKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 117] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 118] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 119] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 120] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 121] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 122] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 123] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 124] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 125] = "YieldKeyword"; // Contextual keywords - SyntaxKind[SyntaxKind["AbstractKeyword"] = 125] = "AbstractKeyword"; - SyntaxKind[SyntaxKind["AsKeyword"] = 126] = "AsKeyword"; - SyntaxKind[SyntaxKind["AssertsKeyword"] = 127] = "AssertsKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 128] = "AnyKeyword"; - SyntaxKind[SyntaxKind["AsyncKeyword"] = 129] = "AsyncKeyword"; - SyntaxKind[SyntaxKind["AwaitKeyword"] = 130] = "AwaitKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 131] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 132] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 133] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 134] = "GetKeyword"; - SyntaxKind[SyntaxKind["InferKeyword"] = 135] = "InferKeyword"; - SyntaxKind[SyntaxKind["IntrinsicKeyword"] = 136] = "IntrinsicKeyword"; - SyntaxKind[SyntaxKind["IsKeyword"] = 137] = "IsKeyword"; - SyntaxKind[SyntaxKind["KeyOfKeyword"] = 138] = "KeyOfKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 139] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["NamespaceKeyword"] = 140] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["NeverKeyword"] = 141] = "NeverKeyword"; - SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 142] = "ReadonlyKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 143] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 144] = "NumberKeyword"; - SyntaxKind[SyntaxKind["ObjectKeyword"] = 145] = "ObjectKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 146] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 147] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 148] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 149] = "TypeKeyword"; - SyntaxKind[SyntaxKind["UndefinedKeyword"] = 150] = "UndefinedKeyword"; - SyntaxKind[SyntaxKind["UniqueKeyword"] = 151] = "UniqueKeyword"; - SyntaxKind[SyntaxKind["UnknownKeyword"] = 152] = "UnknownKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 153] = "FromKeyword"; - SyntaxKind[SyntaxKind["GlobalKeyword"] = 154] = "GlobalKeyword"; - SyntaxKind[SyntaxKind["BigIntKeyword"] = 155] = "BigIntKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 156] = "OfKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 126] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 127] = "AsKeyword"; + SyntaxKind[SyntaxKind["AssertsKeyword"] = 128] = "AssertsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 129] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 130] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 131] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 132] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 133] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 134] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 135] = "GetKeyword"; + SyntaxKind[SyntaxKind["InferKeyword"] = 136] = "InferKeyword"; + SyntaxKind[SyntaxKind["IntrinsicKeyword"] = 137] = "IntrinsicKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 138] = "IsKeyword"; + SyntaxKind[SyntaxKind["KeyOfKeyword"] = 139] = "KeyOfKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 140] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 141] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 142] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 143] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 144] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 145] = "NumberKeyword"; + SyntaxKind[SyntaxKind["ObjectKeyword"] = 146] = "ObjectKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 147] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 148] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 149] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 150] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 151] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["UniqueKeyword"] = 152] = "UniqueKeyword"; + SyntaxKind[SyntaxKind["UnknownKeyword"] = 153] = "UnknownKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 154] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 155] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["BigIntKeyword"] = 156] = "BigIntKeyword"; + SyntaxKind[SyntaxKind["OverrideKeyword"] = 157] = "OverrideKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 158] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 157] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 158] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 159] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 160] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 159] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 160] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 161] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 161] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 162] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 163] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 162] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 163] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 164] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 165] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 166] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 167] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 168] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 169] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 170] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 171] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 164] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 165] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 166] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 167] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 168] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 169] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 170] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 171] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 172] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 173] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 172] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 173] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 174] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 175] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 176] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 177] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 178] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 179] = "TupleType"; - SyntaxKind[SyntaxKind["OptionalType"] = 180] = "OptionalType"; - SyntaxKind[SyntaxKind["RestType"] = 181] = "RestType"; - SyntaxKind[SyntaxKind["UnionType"] = 182] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 183] = "IntersectionType"; - SyntaxKind[SyntaxKind["ConditionalType"] = 184] = "ConditionalType"; - SyntaxKind[SyntaxKind["InferType"] = 185] = "InferType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 186] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 187] = "ThisType"; - SyntaxKind[SyntaxKind["TypeOperator"] = 188] = "TypeOperator"; - SyntaxKind[SyntaxKind["IndexedAccessType"] = 189] = "IndexedAccessType"; - SyntaxKind[SyntaxKind["MappedType"] = 190] = "MappedType"; - SyntaxKind[SyntaxKind["LiteralType"] = 191] = "LiteralType"; - SyntaxKind[SyntaxKind["NamedTupleMember"] = 192] = "NamedTupleMember"; - SyntaxKind[SyntaxKind["TemplateLiteralType"] = 193] = "TemplateLiteralType"; - SyntaxKind[SyntaxKind["TemplateLiteralTypeSpan"] = 194] = "TemplateLiteralTypeSpan"; - SyntaxKind[SyntaxKind["ImportType"] = 195] = "ImportType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 174] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 175] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 176] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 177] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 178] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 179] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 180] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 181] = "TupleType"; + SyntaxKind[SyntaxKind["OptionalType"] = 182] = "OptionalType"; + SyntaxKind[SyntaxKind["RestType"] = 183] = "RestType"; + SyntaxKind[SyntaxKind["UnionType"] = 184] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 185] = "IntersectionType"; + SyntaxKind[SyntaxKind["ConditionalType"] = 186] = "ConditionalType"; + SyntaxKind[SyntaxKind["InferType"] = 187] = "InferType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 188] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 189] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 190] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 191] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 192] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 193] = "LiteralType"; + SyntaxKind[SyntaxKind["NamedTupleMember"] = 194] = "NamedTupleMember"; + SyntaxKind[SyntaxKind["TemplateLiteralType"] = 195] = "TemplateLiteralType"; + SyntaxKind[SyntaxKind["TemplateLiteralTypeSpan"] = 196] = "TemplateLiteralTypeSpan"; + SyntaxKind[SyntaxKind["ImportType"] = 197] = "ImportType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 196] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 197] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 198] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 198] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 199] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 200] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 199] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 200] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 201] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 202] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 203] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 204] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 205] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 206] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 207] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 208] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 209] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 210] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 211] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 212] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 213] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 214] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 215] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 216] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 217] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 218] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 219] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElement"] = 220] = "SpreadElement"; - SyntaxKind[SyntaxKind["ClassExpression"] = 221] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 222] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 223] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 224] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 225] = "NonNullExpression"; - SyntaxKind[SyntaxKind["MetaProperty"] = 226] = "MetaProperty"; - SyntaxKind[SyntaxKind["SyntheticExpression"] = 227] = "SyntheticExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 201] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 202] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 203] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 204] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 205] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 206] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 207] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 208] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 209] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 210] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 211] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 212] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 213] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 214] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 215] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 216] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 217] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 218] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 219] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 220] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 221] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 222] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 223] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 224] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 225] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 226] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 227] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 228] = "MetaProperty"; + SyntaxKind[SyntaxKind["SyntheticExpression"] = 229] = "SyntheticExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 228] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 229] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 230] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 231] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 230] = "Block"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 231] = "EmptyStatement"; - SyntaxKind[SyntaxKind["VariableStatement"] = 232] = "VariableStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 233] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 234] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 235] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 236] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 237] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 238] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 239] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 240] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 241] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 242] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 243] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 244] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 245] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 246] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 247] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 248] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 249] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 250] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 251] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 252] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 253] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 254] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 255] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 256] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 257] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 258] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 259] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 260] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 261] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 262] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 263] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 264] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 265] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 266] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 267] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 268] = "NamedExports"; - SyntaxKind[SyntaxKind["NamespaceExport"] = 269] = "NamespaceExport"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 270] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 271] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 232] = "Block"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 233] = "EmptyStatement"; + SyntaxKind[SyntaxKind["VariableStatement"] = 234] = "VariableStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 235] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 236] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 237] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 238] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 239] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 240] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 241] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 242] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 243] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 244] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 245] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 246] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 247] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 248] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 249] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 250] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 251] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 252] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 253] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 254] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 255] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 256] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 257] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 258] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 259] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 260] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 261] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 262] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 263] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 264] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 265] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 266] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 267] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 268] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 269] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 270] = "NamedExports"; + SyntaxKind[SyntaxKind["NamespaceExport"] = 271] = "NamespaceExport"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 272] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 273] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 272] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 274] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 273] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 274] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 275] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 276] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxFragment"] = 277] = "JsxFragment"; - SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 278] = "JsxOpeningFragment"; - SyntaxKind[SyntaxKind["JsxClosingFragment"] = 279] = "JsxClosingFragment"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 280] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxAttributes"] = 281] = "JsxAttributes"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 282] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 283] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 275] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 276] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 277] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 278] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxFragment"] = 279] = "JsxFragment"; + SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 280] = "JsxOpeningFragment"; + SyntaxKind[SyntaxKind["JsxClosingFragment"] = 281] = "JsxClosingFragment"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 282] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 283] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 284] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 285] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 284] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 285] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 286] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 287] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 286] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 287] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 288] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 289] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 288] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 289] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 290] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 290] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 291] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 292] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 291] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 293] = "EnumMember"; // Unparsed - SyntaxKind[SyntaxKind["UnparsedPrologue"] = 292] = "UnparsedPrologue"; - SyntaxKind[SyntaxKind["UnparsedPrepend"] = 293] = "UnparsedPrepend"; - SyntaxKind[SyntaxKind["UnparsedText"] = 294] = "UnparsedText"; - SyntaxKind[SyntaxKind["UnparsedInternalText"] = 295] = "UnparsedInternalText"; - SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 296] = "UnparsedSyntheticReference"; + SyntaxKind[SyntaxKind["UnparsedPrologue"] = 294] = "UnparsedPrologue"; + SyntaxKind[SyntaxKind["UnparsedPrepend"] = 295] = "UnparsedPrepend"; + SyntaxKind[SyntaxKind["UnparsedText"] = 296] = "UnparsedText"; + SyntaxKind[SyntaxKind["UnparsedInternalText"] = 297] = "UnparsedInternalText"; + SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 298] = "UnparsedSyntheticReference"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 297] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 298] = "Bundle"; - SyntaxKind[SyntaxKind["UnparsedSource"] = 299] = "UnparsedSource"; - SyntaxKind[SyntaxKind["InputFiles"] = 300] = "InputFiles"; + SyntaxKind[SyntaxKind["SourceFile"] = 299] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 300] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 301] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 302] = "InputFiles"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 301] = "JSDocTypeExpression"; - SyntaxKind[SyntaxKind["JSDocNameReference"] = 302] = "JSDocNameReference"; - // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 303] = "JSDocAllType"; - // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 304] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 305] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 306] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 307] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 308] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 309] = "JSDocVariadicType"; - // https://jsdoc.app/about-namepaths.html - SyntaxKind[SyntaxKind["JSDocNamepathType"] = 310] = "JSDocNamepathType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 311] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 312] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocSignature"] = 313] = "JSDocSignature"; - SyntaxKind[SyntaxKind["JSDocTag"] = 314] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 315] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocImplementsTag"] = 316] = "JSDocImplementsTag"; - SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 317] = "JSDocAuthorTag"; - SyntaxKind[SyntaxKind["JSDocDeprecatedTag"] = 318] = "JSDocDeprecatedTag"; - SyntaxKind[SyntaxKind["JSDocClassTag"] = 319] = "JSDocClassTag"; - SyntaxKind[SyntaxKind["JSDocPublicTag"] = 320] = "JSDocPublicTag"; - SyntaxKind[SyntaxKind["JSDocPrivateTag"] = 321] = "JSDocPrivateTag"; - SyntaxKind[SyntaxKind["JSDocProtectedTag"] = 322] = "JSDocProtectedTag"; - SyntaxKind[SyntaxKind["JSDocReadonlyTag"] = 323] = "JSDocReadonlyTag"; - SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 324] = "JSDocCallbackTag"; - SyntaxKind[SyntaxKind["JSDocEnumTag"] = 325] = "JSDocEnumTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 326] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 327] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocThisTag"] = 328] = "JSDocThisTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 329] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 330] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 331] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocSeeTag"] = 332] = "JSDocSeeTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 333] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 303] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocNameReference"] = 304] = "JSDocNameReference"; + SyntaxKind[SyntaxKind["JSDocMemberName"] = 305] = "JSDocMemberName"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 306] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 307] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 308] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 309] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 310] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 311] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 312] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocNamepathType"] = 313] = "JSDocNamepathType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 314] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocText"] = 315] = "JSDocText"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 316] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 317] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocLink"] = 318] = "JSDocLink"; + SyntaxKind[SyntaxKind["JSDocLinkCode"] = 319] = "JSDocLinkCode"; + SyntaxKind[SyntaxKind["JSDocLinkPlain"] = 320] = "JSDocLinkPlain"; + SyntaxKind[SyntaxKind["JSDocTag"] = 321] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 322] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocImplementsTag"] = 323] = "JSDocImplementsTag"; + SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 324] = "JSDocAuthorTag"; + SyntaxKind[SyntaxKind["JSDocDeprecatedTag"] = 325] = "JSDocDeprecatedTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 326] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocPublicTag"] = 327] = "JSDocPublicTag"; + SyntaxKind[SyntaxKind["JSDocPrivateTag"] = 328] = "JSDocPrivateTag"; + SyntaxKind[SyntaxKind["JSDocProtectedTag"] = 329] = "JSDocProtectedTag"; + SyntaxKind[SyntaxKind["JSDocReadonlyTag"] = 330] = "JSDocReadonlyTag"; + SyntaxKind[SyntaxKind["JSDocOverrideTag"] = 331] = "JSDocOverrideTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 332] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocEnumTag"] = 333] = "JSDocEnumTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 334] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 335] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocThisTag"] = 336] = "JSDocThisTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 337] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 338] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 339] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocSeeTag"] = 340] = "JSDocSeeTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 341] = "JSDocPropertyTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 334] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 342] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 335] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 336] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["CommaListExpression"] = 337] = "CommaListExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 338] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 339] = "EndOfDeclarationMarker"; - SyntaxKind[SyntaxKind["SyntheticReferenceExpression"] = 340] = "SyntheticReferenceExpression"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 343] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 344] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 345] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 346] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 347] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["SyntheticReferenceExpression"] = 348] = "SyntheticReferenceExpression"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 341] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 349] = "Count"; // Markers - SyntaxKind[SyntaxKind["FirstAssignment"] = 62] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 77] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 63] = "FirstCompoundAssignment"; - SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 77] = "LastCompoundAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 80] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 115] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 80] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 156] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 116] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 124] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 172] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 195] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 63] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 78] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 64] = "FirstCompoundAssignment"; + SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 78] = "LastCompoundAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 81] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 116] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 81] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 158] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 117] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 125] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 174] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 197] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 18] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 77] = "LastPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 78] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 156] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 158] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; @@ -4298,16 +4412,16 @@ var ts; SyntaxKind[SyntaxKind["FirstTemplateToken"] = 14] = "FirstTemplateToken"; SyntaxKind[SyntaxKind["LastTemplateToken"] = 17] = "LastTemplateToken"; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 29] = "FirstBinaryOperator"; - SyntaxKind[SyntaxKind["LastBinaryOperator"] = 77] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstStatement"] = 232] = "FirstStatement"; - SyntaxKind[SyntaxKind["LastStatement"] = 248] = "LastStatement"; - SyntaxKind[SyntaxKind["FirstNode"] = 157] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 301] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 333] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 314] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 333] = "LastJSDocTagNode"; - /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 125] = "FirstContextualKeyword"; - /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 156] = "LastContextualKeyword"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 78] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstStatement"] = 234] = "FirstStatement"; + SyntaxKind[SyntaxKind["LastStatement"] = 250] = "LastStatement"; + SyntaxKind[SyntaxKind["FirstNode"] = 159] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 303] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 341] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 321] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 341] = "LastJSDocTagNode"; + /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 126] = "FirstContextualKeyword"; + /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 158] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); var NodeFlags; (function (NodeFlags) { @@ -4377,14 +4491,15 @@ var ts; ModifierFlags[ModifierFlags["Const"] = 2048] = "Const"; ModifierFlags[ModifierFlags["HasComputedJSDocModifiers"] = 4096] = "HasComputedJSDocModifiers"; ModifierFlags[ModifierFlags["Deprecated"] = 8192] = "Deprecated"; + ModifierFlags[ModifierFlags["Override"] = 16384] = "Override"; ModifierFlags[ModifierFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; ModifierFlags[ModifierFlags["AccessibilityModifier"] = 28] = "AccessibilityModifier"; // Accessibility modifiers and 'readonly' can be attached to a parameter in a constructor to make it a property. - ModifierFlags[ModifierFlags["ParameterPropertyModifier"] = 92] = "ParameterPropertyModifier"; + ModifierFlags[ModifierFlags["ParameterPropertyModifier"] = 16476] = "ParameterPropertyModifier"; ModifierFlags[ModifierFlags["NonPublicAccessibilityModifier"] = 24] = "NonPublicAccessibilityModifier"; - ModifierFlags[ModifierFlags["TypeScriptModifier"] = 2270] = "TypeScriptModifier"; + ModifierFlags[ModifierFlags["TypeScriptModifier"] = 18654] = "TypeScriptModifier"; ModifierFlags[ModifierFlags["ExportDefault"] = 513] = "ExportDefault"; - ModifierFlags[ModifierFlags["All"] = 11263] = "All"; + ModifierFlags[ModifierFlags["All"] = 27647] = "All"; })(ModifierFlags = ts.ModifierFlags || (ts.ModifierFlags = {})); var JsxFlags; (function (JsxFlags) { @@ -4565,6 +4680,8 @@ var ts; NodeBuilderFlags[NodeBuilderFlags["NoUndefinedOptionalParameterType"] = 1073741824] = "NoUndefinedOptionalParameterType"; // Error handling NodeBuilderFlags[NodeBuilderFlags["AllowThisInObjectLiteral"] = 32768] = "AllowThisInObjectLiteral"; + NodeBuilderFlags[NodeBuilderFlags["AllowQualifiedNameInPlaceOfIdentifier"] = 65536] = "AllowQualifiedNameInPlaceOfIdentifier"; + /** @deprecated AllowQualifedNameInPlaceOfIdentifier. Use AllowQualifiedNameInPlaceOfIdentifier instead. */ NodeBuilderFlags[NodeBuilderFlags["AllowQualifedNameInPlaceOfIdentifier"] = 65536] = "AllowQualifedNameInPlaceOfIdentifier"; NodeBuilderFlags[NodeBuilderFlags["AllowAnonymousIdentifier"] = 131072] = "AllowAnonymousIdentifier"; NodeBuilderFlags[NodeBuilderFlags["AllowEmptyUnionOrIntersection"] = 262144] = "AllowEmptyUnionOrIntersection"; @@ -4579,7 +4696,6 @@ var ts; NodeBuilderFlags[NodeBuilderFlags["InObjectTypeLiteral"] = 4194304] = "InObjectTypeLiteral"; NodeBuilderFlags[NodeBuilderFlags["InTypeAlias"] = 8388608] = "InTypeAlias"; NodeBuilderFlags[NodeBuilderFlags["InInitialEntityName"] = 16777216] = "InInitialEntityName"; - NodeBuilderFlags[NodeBuilderFlags["InReverseMappedType"] = 33554432] = "InReverseMappedType"; })(NodeBuilderFlags = ts.NodeBuilderFlags || (ts.NodeBuilderFlags = {})); // Ensure the shared flags between this and `NodeBuilderFlags` stay in alignment var TypeFormatFlags; @@ -4884,10 +5000,6 @@ var ts; TypeFlags[TypeFlags["Unit"] = 109440] = "Unit"; TypeFlags[TypeFlags["StringOrNumberLiteral"] = 384] = "StringOrNumberLiteral"; /* @internal */ - TypeFlags[TypeFlags["StringLikeLiteral"] = 134217856] = "StringLikeLiteral"; - /* @internal */ - TypeFlags[TypeFlags["FreshableLiteral"] = 134220672] = "FreshableLiteral"; - /* @internal */ TypeFlags[TypeFlags["StringOrNumberLiteralOrUnique"] = 8576] = "StringOrNumberLiteralOrUnique"; /* @internal */ TypeFlags[TypeFlags["DefinitelyFalsy"] = 117632] = "DefinitelyFalsy"; @@ -4936,6 +5048,9 @@ var ts; /* @internal */ TypeFlags[TypeFlags["IncludesEmptyObject"] = 16777216] = "IncludesEmptyObject"; })(TypeFlags = ts.TypeFlags || (ts.TypeFlags = {})); + // Types included in TypeFlags.ObjectFlagsType have an objectFlags property. Some ObjectFlags + // are specific to certain types and reuse the same bit position. Those ObjectFlags require a check + // for a certain TypeFlags value to determine their meaning. var ObjectFlags; (function (ObjectFlags) { ObjectFlags[ObjectFlags["Class"] = 1] = "Class"; @@ -4948,50 +5063,59 @@ var ts; ObjectFlags[ObjectFlags["ObjectLiteral"] = 128] = "ObjectLiteral"; ObjectFlags[ObjectFlags["EvolvingArray"] = 256] = "EvolvingArray"; ObjectFlags[ObjectFlags["ObjectLiteralPatternWithComputedProperties"] = 512] = "ObjectLiteralPatternWithComputedProperties"; - ObjectFlags[ObjectFlags["ContainsSpread"] = 1024] = "ContainsSpread"; - ObjectFlags[ObjectFlags["ReverseMapped"] = 2048] = "ReverseMapped"; - ObjectFlags[ObjectFlags["JsxAttributes"] = 4096] = "JsxAttributes"; - ObjectFlags[ObjectFlags["MarkerType"] = 8192] = "MarkerType"; - ObjectFlags[ObjectFlags["JSLiteral"] = 16384] = "JSLiteral"; - ObjectFlags[ObjectFlags["FreshLiteral"] = 32768] = "FreshLiteral"; - ObjectFlags[ObjectFlags["ArrayLiteral"] = 65536] = "ArrayLiteral"; - ObjectFlags[ObjectFlags["ObjectRestType"] = 131072] = "ObjectRestType"; + ObjectFlags[ObjectFlags["ReverseMapped"] = 1024] = "ReverseMapped"; + ObjectFlags[ObjectFlags["JsxAttributes"] = 2048] = "JsxAttributes"; + ObjectFlags[ObjectFlags["MarkerType"] = 4096] = "MarkerType"; + ObjectFlags[ObjectFlags["JSLiteral"] = 8192] = "JSLiteral"; + ObjectFlags[ObjectFlags["FreshLiteral"] = 16384] = "FreshLiteral"; + ObjectFlags[ObjectFlags["ArrayLiteral"] = 32768] = "ArrayLiteral"; /* @internal */ - ObjectFlags[ObjectFlags["PrimitiveUnion"] = 262144] = "PrimitiveUnion"; + ObjectFlags[ObjectFlags["PrimitiveUnion"] = 65536] = "PrimitiveUnion"; /* @internal */ - ObjectFlags[ObjectFlags["ContainsWideningType"] = 524288] = "ContainsWideningType"; + ObjectFlags[ObjectFlags["ContainsWideningType"] = 131072] = "ContainsWideningType"; /* @internal */ - ObjectFlags[ObjectFlags["ContainsObjectOrArrayLiteral"] = 1048576] = "ContainsObjectOrArrayLiteral"; + ObjectFlags[ObjectFlags["ContainsObjectOrArrayLiteral"] = 262144] = "ContainsObjectOrArrayLiteral"; /* @internal */ - ObjectFlags[ObjectFlags["NonInferrableType"] = 2097152] = "NonInferrableType"; + ObjectFlags[ObjectFlags["NonInferrableType"] = 524288] = "NonInferrableType"; /* @internal */ - ObjectFlags[ObjectFlags["IsGenericObjectTypeComputed"] = 4194304] = "IsGenericObjectTypeComputed"; + ObjectFlags[ObjectFlags["CouldContainTypeVariablesComputed"] = 1048576] = "CouldContainTypeVariablesComputed"; /* @internal */ - ObjectFlags[ObjectFlags["IsGenericObjectType"] = 8388608] = "IsGenericObjectType"; + ObjectFlags[ObjectFlags["CouldContainTypeVariables"] = 2097152] = "CouldContainTypeVariables"; + ObjectFlags[ObjectFlags["ClassOrInterface"] = 3] = "ClassOrInterface"; /* @internal */ - ObjectFlags[ObjectFlags["IsGenericIndexTypeComputed"] = 16777216] = "IsGenericIndexTypeComputed"; + ObjectFlags[ObjectFlags["RequiresWidening"] = 393216] = "RequiresWidening"; /* @internal */ - ObjectFlags[ObjectFlags["IsGenericIndexType"] = 33554432] = "IsGenericIndexType"; + ObjectFlags[ObjectFlags["PropagatingFlags"] = 917504] = "PropagatingFlags"; + // Object flags that uniquely identify the kind of ObjectType /* @internal */ - ObjectFlags[ObjectFlags["CouldContainTypeVariablesComputed"] = 67108864] = "CouldContainTypeVariablesComputed"; + ObjectFlags[ObjectFlags["ObjectTypeKindMask"] = 1343] = "ObjectTypeKindMask"; + // Flags that require TypeFlags.Object + ObjectFlags[ObjectFlags["ContainsSpread"] = 4194304] = "ContainsSpread"; + ObjectFlags[ObjectFlags["ObjectRestType"] = 8388608] = "ObjectRestType"; /* @internal */ - ObjectFlags[ObjectFlags["CouldContainTypeVariables"] = 134217728] = "CouldContainTypeVariables"; + ObjectFlags[ObjectFlags["IsClassInstanceClone"] = 16777216] = "IsClassInstanceClone"; + // Flags that require TypeFlags.Object and ObjectFlags.Reference /* @internal */ - ObjectFlags[ObjectFlags["ContainsIntersections"] = 268435456] = "ContainsIntersections"; + ObjectFlags[ObjectFlags["IdenticalBaseTypeCalculated"] = 33554432] = "IdenticalBaseTypeCalculated"; /* @internal */ - ObjectFlags[ObjectFlags["IsNeverIntersectionComputed"] = 268435456] = "IsNeverIntersectionComputed"; + ObjectFlags[ObjectFlags["IdenticalBaseTypeExists"] = 67108864] = "IdenticalBaseTypeExists"; + // Flags that require TypeFlags.UnionOrIntersection or TypeFlags.Substitution /* @internal */ - ObjectFlags[ObjectFlags["IsNeverIntersection"] = 536870912] = "IsNeverIntersection"; + ObjectFlags[ObjectFlags["IsGenericObjectTypeComputed"] = 4194304] = "IsGenericObjectTypeComputed"; /* @internal */ - ObjectFlags[ObjectFlags["IsClassInstanceClone"] = 1073741824] = "IsClassInstanceClone"; - ObjectFlags[ObjectFlags["ClassOrInterface"] = 3] = "ClassOrInterface"; + ObjectFlags[ObjectFlags["IsGenericObjectType"] = 8388608] = "IsGenericObjectType"; /* @internal */ - ObjectFlags[ObjectFlags["RequiresWidening"] = 1572864] = "RequiresWidening"; + ObjectFlags[ObjectFlags["IsGenericIndexTypeComputed"] = 16777216] = "IsGenericIndexTypeComputed"; /* @internal */ - ObjectFlags[ObjectFlags["PropagatingFlags"] = 3670016] = "PropagatingFlags"; - // Object flags that uniquely identify the kind of ObjectType + ObjectFlags[ObjectFlags["IsGenericIndexType"] = 33554432] = "IsGenericIndexType"; + // Flags that require TypeFlags.Union + /* @internal */ + ObjectFlags[ObjectFlags["ContainsIntersections"] = 67108864] = "ContainsIntersections"; + // Flags that require TypeFlags.Intersection /* @internal */ - ObjectFlags[ObjectFlags["ObjectTypeKindMask"] = 2367] = "ObjectTypeKindMask"; + ObjectFlags[ObjectFlags["IsNeverIntersectionComputed"] = 67108864] = "IsNeverIntersectionComputed"; + /* @internal */ + ObjectFlags[ObjectFlags["IsNeverIntersection"] = 134217728] = "IsNeverIntersection"; })(ObjectFlags = ts.ObjectFlags || (ts.ObjectFlags = {})); /* @internal */ var VarianceFlags; @@ -5018,6 +5142,21 @@ var ts; ElementFlags[ElementFlags["NonRest"] = 11] = "NonRest"; })(ElementFlags = ts.ElementFlags || (ts.ElementFlags = {})); /* @internal */ + var AccessFlags; + (function (AccessFlags) { + AccessFlags[AccessFlags["None"] = 0] = "None"; + AccessFlags[AccessFlags["IncludeUndefined"] = 1] = "IncludeUndefined"; + AccessFlags[AccessFlags["NoIndexSignatures"] = 2] = "NoIndexSignatures"; + AccessFlags[AccessFlags["Writing"] = 4] = "Writing"; + AccessFlags[AccessFlags["CacheSymbol"] = 8] = "CacheSymbol"; + AccessFlags[AccessFlags["NoTupleBoundsCheck"] = 16] = "NoTupleBoundsCheck"; + AccessFlags[AccessFlags["ExpressionPosition"] = 32] = "ExpressionPosition"; + AccessFlags[AccessFlags["ReportDeprecated"] = 64] = "ReportDeprecated"; + AccessFlags[AccessFlags["SuppressNoImplicitAnyError"] = 128] = "SuppressNoImplicitAnyError"; + AccessFlags[AccessFlags["Contextual"] = 256] = "Contextual"; + AccessFlags[AccessFlags["Persistent"] = 1] = "Persistent"; + })(AccessFlags = ts.AccessFlags || (ts.AccessFlags = {})); + /* @internal */ var JsxReferenceKind; (function (JsxReferenceKind) { JsxReferenceKind[JsxReferenceKind["Component"] = 0] = "Component"; @@ -5065,16 +5204,17 @@ var ts; (function (InferencePriority) { InferencePriority[InferencePriority["NakedTypeVariable"] = 1] = "NakedTypeVariable"; InferencePriority[InferencePriority["SpeculativeTuple"] = 2] = "SpeculativeTuple"; - InferencePriority[InferencePriority["HomomorphicMappedType"] = 4] = "HomomorphicMappedType"; - InferencePriority[InferencePriority["PartialHomomorphicMappedType"] = 8] = "PartialHomomorphicMappedType"; - InferencePriority[InferencePriority["MappedTypeConstraint"] = 16] = "MappedTypeConstraint"; - InferencePriority[InferencePriority["ContravariantConditional"] = 32] = "ContravariantConditional"; - InferencePriority[InferencePriority["ReturnType"] = 64] = "ReturnType"; - InferencePriority[InferencePriority["LiteralKeyof"] = 128] = "LiteralKeyof"; - InferencePriority[InferencePriority["NoConstraints"] = 256] = "NoConstraints"; - InferencePriority[InferencePriority["AlwaysStrict"] = 512] = "AlwaysStrict"; - InferencePriority[InferencePriority["MaxValue"] = 1024] = "MaxValue"; - InferencePriority[InferencePriority["PriorityImpliesCombination"] = 208] = "PriorityImpliesCombination"; + InferencePriority[InferencePriority["SubstituteSource"] = 4] = "SubstituteSource"; + InferencePriority[InferencePriority["HomomorphicMappedType"] = 8] = "HomomorphicMappedType"; + InferencePriority[InferencePriority["PartialHomomorphicMappedType"] = 16] = "PartialHomomorphicMappedType"; + InferencePriority[InferencePriority["MappedTypeConstraint"] = 32] = "MappedTypeConstraint"; + InferencePriority[InferencePriority["ContravariantConditional"] = 64] = "ContravariantConditional"; + InferencePriority[InferencePriority["ReturnType"] = 128] = "ReturnType"; + InferencePriority[InferencePriority["LiteralKeyof"] = 256] = "LiteralKeyof"; + InferencePriority[InferencePriority["NoConstraints"] = 512] = "NoConstraints"; + InferencePriority[InferencePriority["AlwaysStrict"] = 1024] = "AlwaysStrict"; + InferencePriority[InferencePriority["MaxValue"] = 2048] = "MaxValue"; + InferencePriority[InferencePriority["PriorityImpliesCombination"] = 416] = "PriorityImpliesCombination"; InferencePriority[InferencePriority["Circularity"] = -1] = "Circularity"; })(InferencePriority = ts.InferencePriority || (ts.InferencePriority = {})); /* @internal */ @@ -5152,20 +5292,23 @@ var ts; WatchFileKind[WatchFileKind["FixedPollingInterval"] = 0] = "FixedPollingInterval"; WatchFileKind[WatchFileKind["PriorityPollingInterval"] = 1] = "PriorityPollingInterval"; WatchFileKind[WatchFileKind["DynamicPriorityPolling"] = 2] = "DynamicPriorityPolling"; - WatchFileKind[WatchFileKind["UseFsEvents"] = 3] = "UseFsEvents"; - WatchFileKind[WatchFileKind["UseFsEventsOnParentDirectory"] = 4] = "UseFsEventsOnParentDirectory"; + WatchFileKind[WatchFileKind["FixedChunkSizePolling"] = 3] = "FixedChunkSizePolling"; + WatchFileKind[WatchFileKind["UseFsEvents"] = 4] = "UseFsEvents"; + WatchFileKind[WatchFileKind["UseFsEventsOnParentDirectory"] = 5] = "UseFsEventsOnParentDirectory"; })(WatchFileKind = ts.WatchFileKind || (ts.WatchFileKind = {})); var WatchDirectoryKind; (function (WatchDirectoryKind) { WatchDirectoryKind[WatchDirectoryKind["UseFsEvents"] = 0] = "UseFsEvents"; WatchDirectoryKind[WatchDirectoryKind["FixedPollingInterval"] = 1] = "FixedPollingInterval"; WatchDirectoryKind[WatchDirectoryKind["DynamicPriorityPolling"] = 2] = "DynamicPriorityPolling"; + WatchDirectoryKind[WatchDirectoryKind["FixedChunkSizePolling"] = 3] = "FixedChunkSizePolling"; })(WatchDirectoryKind = ts.WatchDirectoryKind || (ts.WatchDirectoryKind = {})); var PollingWatchKind; (function (PollingWatchKind) { PollingWatchKind[PollingWatchKind["FixedInterval"] = 0] = "FixedInterval"; PollingWatchKind[PollingWatchKind["PriorityInterval"] = 1] = "PriorityInterval"; PollingWatchKind[PollingWatchKind["DynamicPriority"] = 2] = "DynamicPriority"; + PollingWatchKind[PollingWatchKind["FixedChunkSize"] = 3] = "FixedChunkSize"; })(PollingWatchKind = ts.PollingWatchKind || (ts.PollingWatchKind = {})); var ModuleKind; (function (ModuleKind) { @@ -5226,6 +5369,7 @@ var ts; ScriptTarget[ScriptTarget["ES2018"] = 5] = "ES2018"; ScriptTarget[ScriptTarget["ES2019"] = 6] = "ES2019"; ScriptTarget[ScriptTarget["ES2020"] = 7] = "ES2020"; + ScriptTarget[ScriptTarget["ES2021"] = 8] = "ES2021"; ScriptTarget[ScriptTarget["ESNext"] = 99] = "ESNext"; ScriptTarget[ScriptTarget["JSON"] = 100] = "JSON"; ScriptTarget[ScriptTarget["Latest"] = 99] = "Latest"; @@ -5388,29 +5532,30 @@ var ts; TransformFlags[TransformFlags["ContainsTypeScript"] = 1] = "ContainsTypeScript"; TransformFlags[TransformFlags["ContainsJsx"] = 2] = "ContainsJsx"; TransformFlags[TransformFlags["ContainsESNext"] = 4] = "ContainsESNext"; - TransformFlags[TransformFlags["ContainsES2020"] = 8] = "ContainsES2020"; - TransformFlags[TransformFlags["ContainsES2019"] = 16] = "ContainsES2019"; - TransformFlags[TransformFlags["ContainsES2018"] = 32] = "ContainsES2018"; - TransformFlags[TransformFlags["ContainsES2017"] = 64] = "ContainsES2017"; - TransformFlags[TransformFlags["ContainsES2016"] = 128] = "ContainsES2016"; - TransformFlags[TransformFlags["ContainsES2015"] = 256] = "ContainsES2015"; - TransformFlags[TransformFlags["ContainsGenerator"] = 512] = "ContainsGenerator"; - TransformFlags[TransformFlags["ContainsDestructuringAssignment"] = 1024] = "ContainsDestructuringAssignment"; + TransformFlags[TransformFlags["ContainsES2021"] = 8] = "ContainsES2021"; + TransformFlags[TransformFlags["ContainsES2020"] = 16] = "ContainsES2020"; + TransformFlags[TransformFlags["ContainsES2019"] = 32] = "ContainsES2019"; + TransformFlags[TransformFlags["ContainsES2018"] = 64] = "ContainsES2018"; + TransformFlags[TransformFlags["ContainsES2017"] = 128] = "ContainsES2017"; + TransformFlags[TransformFlags["ContainsES2016"] = 256] = "ContainsES2016"; + TransformFlags[TransformFlags["ContainsES2015"] = 512] = "ContainsES2015"; + TransformFlags[TransformFlags["ContainsGenerator"] = 1024] = "ContainsGenerator"; + TransformFlags[TransformFlags["ContainsDestructuringAssignment"] = 2048] = "ContainsDestructuringAssignment"; // Markers // - Flags used to indicate that a subtree contains a specific transformation. - TransformFlags[TransformFlags["ContainsTypeScriptClassSyntax"] = 2048] = "ContainsTypeScriptClassSyntax"; - TransformFlags[TransformFlags["ContainsLexicalThis"] = 4096] = "ContainsLexicalThis"; - TransformFlags[TransformFlags["ContainsRestOrSpread"] = 8192] = "ContainsRestOrSpread"; - TransformFlags[TransformFlags["ContainsObjectRestOrSpread"] = 16384] = "ContainsObjectRestOrSpread"; - TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 32768] = "ContainsComputedPropertyName"; - TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 65536] = "ContainsBlockScopedBinding"; - TransformFlags[TransformFlags["ContainsBindingPattern"] = 131072] = "ContainsBindingPattern"; - TransformFlags[TransformFlags["ContainsYield"] = 262144] = "ContainsYield"; - TransformFlags[TransformFlags["ContainsAwait"] = 524288] = "ContainsAwait"; - TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 1048576] = "ContainsHoistedDeclarationOrCompletion"; - TransformFlags[TransformFlags["ContainsDynamicImport"] = 2097152] = "ContainsDynamicImport"; - TransformFlags[TransformFlags["ContainsClassFields"] = 4194304] = "ContainsClassFields"; - TransformFlags[TransformFlags["ContainsPossibleTopLevelAwait"] = 8388608] = "ContainsPossibleTopLevelAwait"; + TransformFlags[TransformFlags["ContainsTypeScriptClassSyntax"] = 4096] = "ContainsTypeScriptClassSyntax"; + TransformFlags[TransformFlags["ContainsLexicalThis"] = 8192] = "ContainsLexicalThis"; + TransformFlags[TransformFlags["ContainsRestOrSpread"] = 16384] = "ContainsRestOrSpread"; + TransformFlags[TransformFlags["ContainsObjectRestOrSpread"] = 32768] = "ContainsObjectRestOrSpread"; + TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 65536] = "ContainsComputedPropertyName"; + TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 131072] = "ContainsBlockScopedBinding"; + TransformFlags[TransformFlags["ContainsBindingPattern"] = 262144] = "ContainsBindingPattern"; + TransformFlags[TransformFlags["ContainsYield"] = 524288] = "ContainsYield"; + TransformFlags[TransformFlags["ContainsAwait"] = 1048576] = "ContainsAwait"; + TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 2097152] = "ContainsHoistedDeclarationOrCompletion"; + TransformFlags[TransformFlags["ContainsDynamicImport"] = 4194304] = "ContainsDynamicImport"; + TransformFlags[TransformFlags["ContainsClassFields"] = 8388608] = "ContainsClassFields"; + TransformFlags[TransformFlags["ContainsPossibleTopLevelAwait"] = 16777216] = "ContainsPossibleTopLevelAwait"; // 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 @@ -5420,37 +5565,38 @@ var ts; TransformFlags[TransformFlags["AssertTypeScript"] = 1] = "AssertTypeScript"; TransformFlags[TransformFlags["AssertJsx"] = 2] = "AssertJsx"; TransformFlags[TransformFlags["AssertESNext"] = 4] = "AssertESNext"; - TransformFlags[TransformFlags["AssertES2020"] = 8] = "AssertES2020"; - TransformFlags[TransformFlags["AssertES2019"] = 16] = "AssertES2019"; - TransformFlags[TransformFlags["AssertES2018"] = 32] = "AssertES2018"; - TransformFlags[TransformFlags["AssertES2017"] = 64] = "AssertES2017"; - TransformFlags[TransformFlags["AssertES2016"] = 128] = "AssertES2016"; - TransformFlags[TransformFlags["AssertES2015"] = 256] = "AssertES2015"; - TransformFlags[TransformFlags["AssertGenerator"] = 512] = "AssertGenerator"; - TransformFlags[TransformFlags["AssertDestructuringAssignment"] = 1024] = "AssertDestructuringAssignment"; + TransformFlags[TransformFlags["AssertES2021"] = 8] = "AssertES2021"; + TransformFlags[TransformFlags["AssertES2020"] = 16] = "AssertES2020"; + TransformFlags[TransformFlags["AssertES2019"] = 32] = "AssertES2019"; + TransformFlags[TransformFlags["AssertES2018"] = 64] = "AssertES2018"; + TransformFlags[TransformFlags["AssertES2017"] = 128] = "AssertES2017"; + TransformFlags[TransformFlags["AssertES2016"] = 256] = "AssertES2016"; + TransformFlags[TransformFlags["AssertES2015"] = 512] = "AssertES2015"; + TransformFlags[TransformFlags["AssertGenerator"] = 1024] = "AssertGenerator"; + TransformFlags[TransformFlags["AssertDestructuringAssignment"] = 2048] = "AssertDestructuringAssignment"; // 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"] = 547309568] = "ArrowFunctionExcludes"; - TransformFlags[TransformFlags["FunctionExcludes"] = 547313664] = "FunctionExcludes"; - TransformFlags[TransformFlags["ConstructorExcludes"] = 547311616] = "ConstructorExcludes"; - TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 538923008] = "MethodOrAccessorExcludes"; - TransformFlags[TransformFlags["PropertyExcludes"] = 536875008] = "PropertyExcludes"; - TransformFlags[TransformFlags["ClassExcludes"] = 536905728] = "ClassExcludes"; - TransformFlags[TransformFlags["ModuleExcludes"] = 546379776] = "ModuleExcludes"; + TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 557748224] = "ArrowFunctionExcludes"; + TransformFlags[TransformFlags["FunctionExcludes"] = 557756416] = "FunctionExcludes"; + TransformFlags[TransformFlags["ConstructorExcludes"] = 557752320] = "ConstructorExcludes"; + TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 540975104] = "MethodOrAccessorExcludes"; + TransformFlags[TransformFlags["PropertyExcludes"] = 536879104] = "PropertyExcludes"; + TransformFlags[TransformFlags["ClassExcludes"] = 536940544] = "ClassExcludes"; + TransformFlags[TransformFlags["ModuleExcludes"] = 555888640] = "ModuleExcludes"; TransformFlags[TransformFlags["TypeExcludes"] = -2] = "TypeExcludes"; - TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 536922112] = "ObjectLiteralExcludes"; - TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 536879104] = "ArrayLiteralOrCallOrNewExcludes"; - TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 537018368] = "VariableDeclarationListExcludes"; + TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 536973312] = "ObjectLiteralExcludes"; + TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 536887296] = "ArrayLiteralOrCallOrNewExcludes"; + TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 537165824] = "VariableDeclarationListExcludes"; TransformFlags[TransformFlags["ParameterExcludes"] = 536870912] = "ParameterExcludes"; - TransformFlags[TransformFlags["CatchClauseExcludes"] = 536887296] = "CatchClauseExcludes"; - TransformFlags[TransformFlags["BindingPatternExcludes"] = 536879104] = "BindingPatternExcludes"; + TransformFlags[TransformFlags["CatchClauseExcludes"] = 536903680] = "CatchClauseExcludes"; + TransformFlags[TransformFlags["BindingPatternExcludes"] = 536887296] = "BindingPatternExcludes"; // Propagating flags // - Bitmasks for flags that should propagate from a child - TransformFlags[TransformFlags["PropertyNamePropagatingFlags"] = 4096] = "PropertyNamePropagatingFlags"; + TransformFlags[TransformFlags["PropertyNamePropagatingFlags"] = 8192] = "PropertyNamePropagatingFlags"; // Masks // - Additional bitmasks })(TransformFlags = ts.TransformFlags || (ts.TransformFlags = {})); @@ -6048,6 +6194,11 @@ var ts; * Normalize path separators, converting `\` into `/`. */ function normalizeSlashes(path) { + var index = path.indexOf("\\"); + if (index === -1) { + return path; + } + backslashRegExp.lastIndex = index; // prime regex with known position return path.replace(backslashRegExp, ts.directorySeparator); } ts.normalizeSlashes = normalizeSlashes; @@ -6158,6 +6309,19 @@ var ts; ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath; function normalizePath(path) { path = normalizeSlashes(path); + // Most paths don't require normalization + if (!relativePathSegmentRegExp.test(path)) { + return path; + } + // Some paths only require cleanup of `/./` or leading `./` + var simplified = path.replace(/\/\.\//g, "/").replace(/^\.\//, ""); + if (simplified !== path) { + path = simplified; + if (!relativePathSegmentRegExp.test(path)) { + return path; + } + } + // Other paths require full normalization var normalized = getPathFromPathComponents(reducePathComponents(getPathComponents(path))); return normalized && hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalized) : normalized; } @@ -6226,7 +6390,7 @@ var ts; ts.changeAnyExtension = changeAnyExtension; //// Path Comparisons // check path for these segments: '', '.'. '..' - var relativePathSegmentRegExp = /(^|\/)\.{0,2}($|\/)/; + var relativePathSegmentRegExp = /(?:\/\/)|(?:^|\/)\.\.?(?:$|\/)/; function comparePathsWorker(a, b, componentComparer) { if (a === b) return 0 /* EqualTo */; @@ -6318,7 +6482,7 @@ var ts; * Determines whether `fileName` starts with the specified `directoryName` using the provided path canonicalization callback. * Comparison is case-sensitive between the canonical paths. * - * @deprecated Use `containsPath` if possible. + * Use `containsPath` if file names are not already reduced and absolute. */ function startsWithDirectory(fileName, directoryName, getCanonicalFileName) { var canonicalFileName = getCanonicalFileName(fileName); @@ -6438,6 +6602,11 @@ var ts; })(PollingInterval = ts.PollingInterval || (ts.PollingInterval = {})); /* @internal */ ts.missingFileModifiedTime = new Date(0); // Any subsequent modification will occur after this time + /* @internal */ + function getModifiedTime(host, fileName) { + return host.getModifiedTime(fileName) || ts.missingFileModifiedTime; + } + ts.getModifiedTime = getModifiedTime; function createPollingIntervalBasedLevels(levels) { var _a; return _a = {}, @@ -6494,6 +6663,51 @@ var ts; } } ts.setCustomPollingValues = setCustomPollingValues; + function pollWatchedFileQueue(host, queue, pollIndex, chunkSize, callbackOnWatchFileStat) { + var definedValueCopyToIndex = pollIndex; + // Max visit would be all elements of the queue + for (var canVisit = queue.length; chunkSize && canVisit; nextPollIndex(), canVisit--) { + var watchedFile = queue[pollIndex]; + if (!watchedFile) { + continue; + } + else if (watchedFile.isClosed) { + queue[pollIndex] = undefined; + continue; + } + // Only files polled count towards chunkSize + chunkSize--; + var fileChanged = onWatchedFileStat(watchedFile, getModifiedTime(host, watchedFile.fileName)); + if (watchedFile.isClosed) { + // Closed watcher as part of callback + queue[pollIndex] = undefined; + continue; + } + callbackOnWatchFileStat === null || callbackOnWatchFileStat === void 0 ? void 0 : callbackOnWatchFileStat(watchedFile, pollIndex, fileChanged); + // Defragment the queue while we are at it + if (queue[pollIndex]) { + // Copy this file to the non hole location + if (definedValueCopyToIndex < pollIndex) { + queue[definedValueCopyToIndex] = watchedFile; + queue[pollIndex] = undefined; + } + definedValueCopyToIndex++; + } + } + // Return next poll index + return pollIndex; + function nextPollIndex() { + pollIndex++; + if (pollIndex === queue.length) { + if (definedValueCopyToIndex < pollIndex) { + // There are holes from definedValueCopyToIndex to end of queue, change queue size + queue.length = definedValueCopyToIndex; + } + pollIndex = 0; + definedValueCopyToIndex = 0; + } + } + } /* @internal */ function createDynamicPriorityPollingWatchFile(host) { var watchedFiles = []; @@ -6507,7 +6721,7 @@ var ts; fileName: fileName, callback: callback, unchangedPolls: 0, - mtime: getModifiedTime(fileName) + mtime: getModifiedTime(host, fileName) }; watchedFiles.push(file); addToPollingIntervalQueue(file, defaultPollingInterval); @@ -6550,25 +6764,9 @@ var ts; } } function pollQueue(queue, pollingInterval, pollIndex, chunkSize) { - // Max visit would be all elements of the queue - var needsVisit = queue.length; - var definedValueCopyToIndex = pollIndex; - for (var polled = 0; polled < chunkSize && needsVisit > 0; nextPollIndex(), needsVisit--) { - var watchedFile = queue[pollIndex]; - if (!watchedFile) { - continue; - } - else if (watchedFile.isClosed) { - queue[pollIndex] = undefined; - continue; - } - polled++; - var fileChanged = onWatchedFileStat(watchedFile, getModifiedTime(watchedFile.fileName)); - if (watchedFile.isClosed) { - // Closed watcher as part of callback - queue[pollIndex] = undefined; - } - else if (fileChanged) { + return pollWatchedFileQueue(host, queue, pollIndex, chunkSize, onWatchFileStat); + function onWatchFileStat(watchedFile, pollIndex, fileChanged) { + if (fileChanged) { watchedFile.unchangedPolls = 0; // Changed files go to changedFilesInLastPoll queue if (queue !== changedFilesInLastPoll) { @@ -6590,27 +6788,6 @@ var ts; queue[pollIndex] = undefined; addToPollingIntervalQueue(watchedFile, pollingInterval === PollingInterval.Low ? PollingInterval.Medium : PollingInterval.High); } - if (queue[pollIndex]) { - // Copy this file to the non hole location - if (definedValueCopyToIndex < pollIndex) { - queue[definedValueCopyToIndex] = watchedFile; - queue[pollIndex] = undefined; - } - definedValueCopyToIndex++; - } - } - // Return next poll index - return pollIndex; - function nextPollIndex() { - pollIndex++; - if (pollIndex === queue.length) { - if (definedValueCopyToIndex < pollIndex) { - // There are holes from nextDefinedValueIndex to end of queue, change queue size - queue.length = definedValueCopyToIndex; - } - pollIndex = 0; - definedValueCopyToIndex = 0; - } } } function pollingIntervalQueue(pollingInterval) { @@ -6639,9 +6816,6 @@ var ts; function scheduleNextPoll(pollingInterval) { pollingIntervalQueue(pollingInterval).pollScheduled = host.setTimeout(pollingInterval === PollingInterval.Low ? pollLowPollingIntervalQueue : pollPollingIntervalQueue, pollingInterval, pollingIntervalQueue(pollingInterval)); } - function getModifiedTime(fileName) { - return host.getModifiedTime(fileName) || ts.missingFileModifiedTime; - } } ts.createDynamicPriorityPollingWatchFile = createDynamicPriorityPollingWatchFile; function createUseFsEventsOnParentDirectoryWatchFile(fsWatch, useCaseSensitiveFileNames) { @@ -6692,6 +6866,37 @@ var ts; return watcher; } } + function createFixedChunkSizePollingWatchFile(host) { + var watchedFiles = []; + var pollIndex = 0; + var pollScheduled; + return watchFile; + function watchFile(fileName, callback) { + var file = { + fileName: fileName, + callback: callback, + mtime: getModifiedTime(host, fileName) + }; + watchedFiles.push(file); + scheduleNextPoll(); + return { + close: function () { + file.isClosed = true; + ts.unorderedRemoveItem(watchedFiles, file); + } + }; + } + function pollQueue() { + pollScheduled = undefined; + pollIndex = pollWatchedFileQueue(host, watchedFiles, pollIndex, pollingChunkSize[PollingInterval.Low]); + scheduleNextPoll(); + } + function scheduleNextPoll() { + if (!watchedFiles.length || pollScheduled) + return; + pollScheduled = host.setTimeout(pollQueue, PollingInterval.High); + } + } /* @internal */ function createSingleFileWatcherPerName(watchFile, useCaseSensitiveFileNames) { var cache = new ts.Map(); @@ -7014,8 +7219,9 @@ var ts; } /*@internal*/ function createSystemWatchFunctions(_a) { - var pollingWatchFile = _a.pollingWatchFile, getModifiedTime = _a.getModifiedTime, setTimeout = _a.setTimeout, clearTimeout = _a.clearTimeout, fsWatch = _a.fsWatch, fileExists = _a.fileExists, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, getCurrentDirectory = _a.getCurrentDirectory, fsSupportsRecursiveFsWatch = _a.fsSupportsRecursiveFsWatch, directoryExists = _a.directoryExists, getAccessibleSortedChildDirectories = _a.getAccessibleSortedChildDirectories, realpath = _a.realpath, tscWatchFile = _a.tscWatchFile, useNonPollingWatchers = _a.useNonPollingWatchers, tscWatchDirectory = _a.tscWatchDirectory; + var pollingWatchFile = _a.pollingWatchFile, getModifiedTime = _a.getModifiedTime, setTimeout = _a.setTimeout, clearTimeout = _a.clearTimeout, fsWatch = _a.fsWatch, fileExists = _a.fileExists, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, getCurrentDirectory = _a.getCurrentDirectory, fsSupportsRecursiveFsWatch = _a.fsSupportsRecursiveFsWatch, directoryExists = _a.directoryExists, getAccessibleSortedChildDirectories = _a.getAccessibleSortedChildDirectories, realpath = _a.realpath, tscWatchFile = _a.tscWatchFile, useNonPollingWatchers = _a.useNonPollingWatchers, tscWatchDirectory = _a.tscWatchDirectory, defaultWatchFileKind = _a.defaultWatchFileKind; var dynamicPollingWatchFile; + var fixedChunkSizePollingWatchFile; var nonPollingWatchFile; var hostRecursiveDirectoryWatcher; return { @@ -7032,6 +7238,8 @@ var ts; return pollingWatchFile(fileName, callback, pollingInterval, /*options*/ undefined); case ts.WatchFileKind.DynamicPriorityPolling: return ensureDynamicPollingWatchFile()(fileName, callback, pollingInterval, /*options*/ undefined); + case ts.WatchFileKind.FixedChunkSizePolling: + return ensureFixedChunkSizePollingWatchFile()(fileName, callback, /* pollingInterval */ undefined, /*options*/ undefined); case ts.WatchFileKind.UseFsEvents: return fsWatch(fileName, 0 /* File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists), /*recursive*/ false, pollingInterval, ts.getFallbackOptions(options)); @@ -7045,8 +7253,10 @@ var ts; } } function ensureDynamicPollingWatchFile() { - return dynamicPollingWatchFile || - (dynamicPollingWatchFile = createDynamicPriorityPollingWatchFile({ getModifiedTime: getModifiedTime, setTimeout: setTimeout })); + return dynamicPollingWatchFile || (dynamicPollingWatchFile = createDynamicPriorityPollingWatchFile({ getModifiedTime: getModifiedTime, setTimeout: setTimeout })); + } + function ensureFixedChunkSizePollingWatchFile() { + return fixedChunkSizePollingWatchFile || (fixedChunkSizePollingWatchFile = createFixedChunkSizePollingWatchFile({ getModifiedTime: getModifiedTime, setTimeout: setTimeout })); } function updateOptionsForWatchFile(options, useNonPollingWatchers) { if (options && options.watchFile !== undefined) @@ -7072,7 +7282,7 @@ var ts; // Use notifications from FS to watch with falling back to fs.watchFile generateWatchFileOptions(ts.WatchFileKind.UseFsEventsOnParentDirectory, ts.PollingWatchKind.PriorityInterval, options) : // Default to do not use fixed polling interval - { watchFile: ts.WatchFileKind.FixedPollingInterval }; + { watchFile: (defaultWatchFileKind === null || defaultWatchFileKind === void 0 ? void 0 : defaultWatchFileKind()) || ts.WatchFileKind.FixedPollingInterval }; } } function generateWatchFileOptions(watchFile, fallbackPolling, options) { @@ -7113,6 +7323,10 @@ var ts; case ts.WatchDirectoryKind.DynamicPriorityPolling: return ensureDynamicPollingWatchFile()(directoryName, function () { return callback(directoryName); }, PollingInterval.Medium, /*options*/ undefined); + case ts.WatchDirectoryKind.FixedChunkSizePolling: + return ensureFixedChunkSizePollingWatchFile()(directoryName, function () { return callback(directoryName); }, + /* 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)); default: @@ -7191,13 +7405,13 @@ var ts; } var activeSession; var profilePath = "./profile.cpuprofile"; - var realpathSync = (_a = _fs.realpathSync.native) !== null && _a !== void 0 ? _a : _fs.realpathSync; var Buffer = require("buffer").Buffer; var nodeVersion = getNodeMajorVersion(); var isNode4OrLater = nodeVersion >= 4; var isLinuxOrMacOs = process.platform === "linux" || process.platform === "darwin"; var platform = _os.platform(); var useCaseSensitiveFileNames = isFileSystemCaseSensitive(); + var realpathSync = useCaseSensitiveFileNames ? ((_a = _fs.realpathSync.native) !== null && _a !== void 0 ? _a : _fs.realpathSync) : _fs.realpathSync; var fsSupportsRecursiveFsWatch = isNode4OrLater && (process.platform === "win32" || process.platform === "darwin"); var getCurrentDirectory = ts.memoize(function () { return process.cwd(); }); var _c = createSystemWatchFunctions({ @@ -7218,6 +7432,7 @@ var ts; tscWatchFile: process.env.TSC_WATCHFILE, useNonPollingWatchers: process.env.TSC_NONPOLLING_WATCHER, tscWatchDirectory: process.env.TSC_WATCHDIRECTORY, + defaultWatchFileKind: function () { var _a, _b; return (_b = (_a = sys).defaultWatchFileKind) === null || _b === void 0 ? void 0 : _b.call(_a); }, }), watchFile = _c.watchFile, watchDirectory = _c.watchDirectory; var nodeSystem = { args: process.argv.slice(2), @@ -7286,6 +7501,7 @@ var ts; }, enableCPUProfiler: enableCPUProfiler, disableCPUProfiler: disableCPUProfiler, + cpuProfilingEnabled: function () { return !!activeSession || ts.contains(process.execArgv, "--cpu-prof") || ts.contains(process.execArgv, "--prof"); }, realpath: realpath, debugMode: !!process.env.NODE_INSPECTOR_IPC || !!process.env.VSCODE_INSPECTOR_OPTIONS || ts.some(process.execArgv, function (arg) { return /^--(inspect|debug)(-brk)?(=\d+)?$/i.test(arg); }), tryEnableSourceMapsForHost: function () { @@ -7535,7 +7751,7 @@ var ts; return event === "rename" && (!relativeName || relativeName === lastDirectoryPart || - relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length) && + (relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) !== -1 && relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length)) && !fileSystemEntryExists(fileOrDirectory, entryKind) ? invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry) : callback(event, relativeName); @@ -7845,9 +8061,10 @@ var ts; Invalid_use_of_0_in_strict_mode: diag(1100, ts.DiagnosticCategory.Error, "Invalid_use_of_0_in_strict_mode_1100", "Invalid use of '{0}' in strict mode."), with_statements_are_not_allowed_in_strict_mode: diag(1101, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_strict_mode_1101", "'with' statements are not allowed in strict mode."), delete_cannot_be_called_on_an_identifier_in_strict_mode: diag(1102, ts.DiagnosticCategory.Error, "delete_cannot_be_called_on_an_identifier_in_strict_mode_1102", "'delete' cannot be called on an identifier in strict mode."), - A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator: diag(1103, ts.DiagnosticCategory.Error, "A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator_1103", "A 'for-await-of' statement is only allowed within an async function or async generator."), + for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1103, ts.DiagnosticCategory.Error, "for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1103", "'for await' loops are only allowed within async functions and at the top levels of modules."), A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: diag(1104, ts.DiagnosticCategory.Error, "A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement_1104", "A 'continue' statement can only be used within an enclosing iteration statement."), A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: diag(1105, ts.DiagnosticCategory.Error, "A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement_1105", "A 'break' statement can only be used within an enclosing iteration or switch statement."), + The_left_hand_side_of_a_for_of_statement_may_not_be_async: diag(1106, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_of_statement_may_not_be_async_1106", "The left-hand side of a 'for...of' statement may not be 'async'."), Jump_target_cannot_cross_function_boundary: diag(1107, ts.DiagnosticCategory.Error, "Jump_target_cannot_cross_function_boundary_1107", "Jump target cannot cross function boundary."), A_return_statement_can_only_be_used_within_a_function_body: diag(1108, ts.DiagnosticCategory.Error, "A_return_statement_can_only_be_used_within_a_function_body_1108", "A 'return' statement can only be used within a function body."), Expression_expected: diag(1109, ts.DiagnosticCategory.Error, "Expression_expected_1109", "Expression expected."), @@ -7894,7 +8111,7 @@ var ts; A_yield_expression_is_only_allowed_in_a_generator_body: diag(1163, ts.DiagnosticCategory.Error, "A_yield_expression_is_only_allowed_in_a_generator_body_1163", "A 'yield' expression is only allowed in a generator body."), Computed_property_names_are_not_allowed_in_enums: diag(1164, ts.DiagnosticCategory.Error, "Computed_property_names_are_not_allowed_in_enums_1164", "Computed property names are not allowed in enums."), A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1165, ts.DiagnosticCategory.Error, "A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_t_1165", "A computed property name in an ambient context must refer to an expression whose type is a literal type or a 'unique symbol' type."), - A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1166, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_1166", "A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type."), + A_computed_property_name_in_a_class_property_declaration_must_have_a_simple_literal_type_or_a_unique_symbol_type: diag(1166, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_class_property_declaration_must_have_a_simple_literal_type_or_a_unique_1166", "A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type."), A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1168, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_ty_1168", "A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type."), A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1169, ts.DiagnosticCategory.Error, "A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_1169", "A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type."), A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1170, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type__1170", "A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type."), @@ -7954,7 +8171,7 @@ var ts; A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: diag(1228, ts.DiagnosticCategory.Error, "A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods_1228", "A type predicate is only allowed in return type position for functions and methods."), A_type_predicate_cannot_reference_a_rest_parameter: diag(1229, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_a_rest_parameter_1229", "A type predicate cannot reference a rest parameter."), A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: diag(1230, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_element_0_in_a_binding_pattern_1230", "A type predicate cannot reference element '{0}' in a binding pattern."), - An_export_assignment_can_only_be_used_in_a_module: diag(1231, ts.DiagnosticCategory.Error, "An_export_assignment_can_only_be_used_in_a_module_1231", "An export assignment can only be used in a module."), + An_export_assignment_must_be_at_the_top_level_of_a_file_or_module_declaration: diag(1231, ts.DiagnosticCategory.Error, "An_export_assignment_must_be_at_the_top_level_of_a_file_or_module_declaration_1231", "An export assignment must be at the top level of a file or module declaration."), An_import_declaration_can_only_be_used_in_a_namespace_or_module: diag(1232, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_in_a_namespace_or_module_1232", "An import declaration can only be used in a namespace or module."), An_export_declaration_can_only_be_used_in_a_module: diag(1233, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_in_a_module_1233", "An export declaration can only be used in a module."), An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: diag(1234, ts.DiagnosticCategory.Error, "An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file_1234", "An ambient module declaration is only allowed at the top level in a file."), @@ -7980,6 +8197,7 @@ var ts; A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_reference: diag(1254, ts.DiagnosticCategory.Error, "A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_refere_1254", "A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference."), A_definite_assignment_assertion_is_not_permitted_in_this_context: diag(1255, ts.DiagnosticCategory.Error, "A_definite_assignment_assertion_is_not_permitted_in_this_context_1255", "A definite assignment assertion '!' is not permitted in this context."), A_required_element_cannot_follow_an_optional_element: diag(1257, ts.DiagnosticCategory.Error, "A_required_element_cannot_follow_an_optional_element_1257", "A required element cannot follow an optional element."), + A_default_export_must_be_at_the_top_level_of_a_file_or_module_declaration: diag(1258, ts.DiagnosticCategory.Error, "A_default_export_must_be_at_the_top_level_of_a_file_or_module_declaration_1258", "A default export must be at the top level of a file or module declaration."), Module_0_can_only_be_default_imported_using_the_1_flag: diag(1259, ts.DiagnosticCategory.Error, "Module_0_can_only_be_default_imported_using_the_1_flag_1259", "Module '{0}' can only be default-imported using the '{1}' flag"), Keywords_cannot_contain_escape_characters: diag(1260, ts.DiagnosticCategory.Error, "Keywords_cannot_contain_escape_characters_1260", "Keywords cannot contain escape characters."), Already_included_file_name_0_differs_from_file_name_1_only_in_casing: diag(1261, ts.DiagnosticCategory.Error, "Already_included_file_name_0_differs_from_file_name_1_only_in_casing_1261", "Already included file name '{0}' differs from file name '{1}' only in casing."), @@ -7988,6 +8206,7 @@ var ts; Declarations_with_definite_assignment_assertions_must_also_have_type_annotations: diag(1264, ts.DiagnosticCategory.Error, "Declarations_with_definite_assignment_assertions_must_also_have_type_annotations_1264", "Declarations with definite assignment assertions must also have type annotations."), A_rest_element_cannot_follow_another_rest_element: diag(1265, ts.DiagnosticCategory.Error, "A_rest_element_cannot_follow_another_rest_element_1265", "A rest element cannot follow another rest element."), An_optional_element_cannot_follow_a_rest_element: diag(1266, ts.DiagnosticCategory.Error, "An_optional_element_cannot_follow_a_rest_element_1266", "An optional element cannot follow a rest element."), + Property_0_cannot_have_an_initializer_because_it_is_marked_abstract: diag(1267, ts.DiagnosticCategory.Error, "Property_0_cannot_have_an_initializer_because_it_is_marked_abstract_1267", "Property '{0}' cannot have an initializer because it is marked abstract."), with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1308, ts.DiagnosticCategory.Error, "await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1308", "'await' expressions are only allowed within async functions and at the top levels of modules."), 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: diag(1312, ts.DiagnosticCategory.Error, "Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_1312", "Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern."), @@ -8066,7 +8285,7 @@ var ts; Constructor_type_notation_must_be_parenthesized_when_used_in_an_intersection_type: diag(1388, ts.DiagnosticCategory.Error, "Constructor_type_notation_must_be_parenthesized_when_used_in_an_intersection_type_1388", "Constructor type notation must be parenthesized when used in an intersection type."), _0_is_not_allowed_as_a_variable_declaration_name: diag(1389, ts.DiagnosticCategory.Error, "_0_is_not_allowed_as_a_variable_declaration_name_1389", "'{0}' is not allowed as a variable declaration name."), Provides_a_root_package_name_when_using_outFile_with_declarations: diag(1390, ts.DiagnosticCategory.Message, "Provides_a_root_package_name_when_using_outFile_with_declarations_1390", "Provides a root package name when using outFile with declarations."), - The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_declaration_emit: diag(1391, ts.DiagnosticCategory.Error, "The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_de_1391", "The `bundledPackageName` option must be provided when using outFile and node module resolution with declaration emit."), + The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_declaration_emit: diag(1391, ts.DiagnosticCategory.Error, "The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_de_1391", "The 'bundledPackageName' option must be provided when using outFile and node module resolution with declaration emit."), An_import_alias_cannot_use_import_type: diag(1392, ts.DiagnosticCategory.Error, "An_import_alias_cannot_use_import_type_1392", "An import alias cannot use 'import type'"), Imported_via_0_from_file_1: diag(1393, ts.DiagnosticCategory.Message, "Imported_via_0_from_file_1_1393", "Imported via {0} from file '{1}'"), Imported_via_0_from_file_1_with_packageId_2: diag(1394, ts.DiagnosticCategory.Message, "Imported_via_0_from_file_1_with_packageId_2_1394", "Imported via {0} from file '{1}' with packageId '{2}'"), @@ -8106,6 +8325,9 @@ var ts; File_is_output_of_project_reference_source_0: diag(1428, ts.DiagnosticCategory.Message, "File_is_output_of_project_reference_source_0_1428", "File is output of project reference source '{0}'"), File_redirects_to_file_0: diag(1429, ts.DiagnosticCategory.Message, "File_redirects_to_file_0_1429", "File redirects to file '{0}'"), The_file_is_in_the_program_because_Colon: diag(1430, ts.DiagnosticCategory.Message, "The_file_is_in_the_program_because_Colon_1430", "The file is in the program because:"), + for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module: diag(1431, ts.DiagnosticCategory.Error, "for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_1431", "'for await' loops are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module."), + Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher: diag(1432, ts.DiagnosticCategory.Error, "Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_1432", "Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher."), + Decorators_may_not_be_applied_to_this_parameters: diag(1433, ts.DiagnosticCategory.Error, "Decorators_may_not_be_applied_to_this_parameters_1433", "Decorators may not be applied to 'this' parameters."), 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), @@ -8173,7 +8395,7 @@ var ts; The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2358, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter."), The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: diag(2359, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type."), The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: diag(2360, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol_2360", "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'."), - The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2361, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter_2361", "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter."), + The_right_hand_side_of_an_in_expression_must_not_be_a_primitive: diag(2361, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_in_expression_must_not_be_a_primitive_2361", "The right-hand side of an 'in' expression must not be a primitive."), The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2362, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2362", "The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."), The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2363, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2363", "The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."), The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: diag(2364, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", "The left-hand side of an assignment expression must be a variable or a property access."), @@ -8191,8 +8413,7 @@ var ts; A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_parameter_properties_or_private_identifiers: diag(2376, ts.DiagnosticCategory.Error, "A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_proper_2376", "A 'super' call must be the first statement in the constructor when a class contains initialized properties, parameter properties, or private identifiers."), Constructors_for_derived_classes_must_contain_a_super_call: diag(2377, ts.DiagnosticCategory.Error, "Constructors_for_derived_classes_must_contain_a_super_call_2377", "Constructors for derived classes must contain a 'super' call."), A_get_accessor_must_return_a_value: diag(2378, ts.DiagnosticCategory.Error, "A_get_accessor_must_return_a_value_2378", "A 'get' accessor must return a value."), - Getter_and_setter_accessors_do_not_agree_in_visibility: diag(2379, ts.DiagnosticCategory.Error, "Getter_and_setter_accessors_do_not_agree_in_visibility_2379", "Getter and setter accessors do not agree in visibility."), - get_and_set_accessor_must_have_the_same_type: diag(2380, ts.DiagnosticCategory.Error, "get_and_set_accessor_must_have_the_same_type_2380", "'get' and 'set' accessor must have the same type."), + The_return_type_of_a_get_accessor_must_be_assignable_to_its_set_accessor_type: diag(2380, ts.DiagnosticCategory.Error, "The_return_type_of_a_get_accessor_must_be_assignable_to_its_set_accessor_type_2380", "The return type of a 'get' accessor must be assignable to its 'set' accessor type"), A_signature_with_an_implementation_cannot_use_a_string_literal_type: diag(2381, ts.DiagnosticCategory.Error, "A_signature_with_an_implementation_cannot_use_a_string_literal_type_2381", "A signature with an implementation cannot use a string literal type."), Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: diag(2382, ts.DiagnosticCategory.Error, "Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature_2382", "Specialized overload signature is not assignable to any non-specialized signature."), Overload_signatures_must_all_be_exported_or_non_exported: diag(2383, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_exported_or_non_exported_2383", "Overload signatures must all be exported or non-exported."), @@ -8255,7 +8476,7 @@ var ts; Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2: diag(2443, ts.DiagnosticCategory.Error, "Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2_2443", "Property '{0}' is protected but type '{1}' is not a class derived from '{2}'."), Property_0_is_protected_in_type_1_but_public_in_type_2: diag(2444, ts.DiagnosticCategory.Error, "Property_0_is_protected_in_type_1_but_public_in_type_2_2444", "Property '{0}' is protected in type '{1}' but public in type '{2}'."), Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses: diag(2445, ts.DiagnosticCategory.Error, "Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses_2445", "Property '{0}' is protected and only accessible within class '{1}' and its subclasses."), - Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: diag(2446, ts.DiagnosticCategory.Error, "Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_2446", "Property '{0}' is protected and only accessible through an instance of class '{1}'."), + Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_This_is_an_instance_of_class_2: diag(2446, ts.DiagnosticCategory.Error, "Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_This_is_an_instance_of_cl_2446", "Property '{0}' is protected and only accessible through an instance of class '{1}'. This is an instance of class '{2}'."), The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: diag(2447, ts.DiagnosticCategory.Error, "The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead_2447", "The '{0}' operator is not allowed for boolean types. Consider using '{1}' instead."), Block_scoped_variable_0_used_before_its_declaration: diag(2448, ts.DiagnosticCategory.Error, "Block_scoped_variable_0_used_before_its_declaration_2448", "Block-scoped variable '{0}' used before its declaration."), Class_0_used_before_its_declaration: diag(2449, ts.DiagnosticCategory.Error, "Class_0_used_before_its_declaration_2449", "Class '{0}' used before its declaration."), @@ -8355,14 +8576,13 @@ var ts; The_type_returned_by_the_0_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_property: diag(2547, ts.DiagnosticCategory.Error, "The_type_returned_by_the_0_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_pro_2547", "The type returned by the '{0}()' method of an async iterator must be a promise for a type with a 'value' property."), Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator: diag(2548, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator_2548", "Type '{0}' is not an array type or does not have a '[Symbol.iterator]()' method that returns an iterator."), Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator: diag(2549, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns__2549", "Type '{0}' is not an array type or a string type or does not have a '[Symbol.iterator]()' method that returns an iterator."), - Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2_or_later: diag(2550, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_c_2550", "Property '{0}' does not exist on type '{1}'. Do you need to change your target library? Try changing the `lib` compiler option to '{2}' or later."), + Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2_or_later: diag(2550, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_c_2550", "Property '{0}' does not exist on type '{1}'. Do you need to change your target library? Try changing the 'lib' compiler option to '{2}' or later."), Property_0_does_not_exist_on_type_1_Did_you_mean_2: diag(2551, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Did_you_mean_2_2551", "Property '{0}' does not exist on type '{1}'. Did you mean '{2}'?"), Cannot_find_name_0_Did_you_mean_1: diag(2552, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Did_you_mean_1_2552", "Cannot find name '{0}'. Did you mean '{1}'?"), Computed_values_are_not_permitted_in_an_enum_with_string_valued_members: diag(2553, ts.DiagnosticCategory.Error, "Computed_values_are_not_permitted_in_an_enum_with_string_valued_members_2553", "Computed values are not permitted in an enum with string valued members."), Expected_0_arguments_but_got_1: diag(2554, ts.DiagnosticCategory.Error, "Expected_0_arguments_but_got_1_2554", "Expected {0} arguments, but got {1}."), Expected_at_least_0_arguments_but_got_1: diag(2555, ts.DiagnosticCategory.Error, "Expected_at_least_0_arguments_but_got_1_2555", "Expected at least {0} arguments, but got {1}."), - Expected_0_arguments_but_got_1_or_more: diag(2556, ts.DiagnosticCategory.Error, "Expected_0_arguments_but_got_1_or_more_2556", "Expected {0} arguments, but got {1} or more."), - Expected_at_least_0_arguments_but_got_1_or_more: diag(2557, ts.DiagnosticCategory.Error, "Expected_at_least_0_arguments_but_got_1_or_more_2557", "Expected at least {0} arguments, but got {1} or more."), + A_spread_argument_must_either_have_a_tuple_type_or_be_passed_to_a_rest_parameter: diag(2556, ts.DiagnosticCategory.Error, "A_spread_argument_must_either_have_a_tuple_type_or_be_passed_to_a_rest_parameter_2556", "A spread argument must either have a tuple type or be passed to a rest parameter."), Expected_0_type_arguments_but_got_1: diag(2558, ts.DiagnosticCategory.Error, "Expected_0_type_arguments_but_got_1_2558", "Expected {0} type arguments, but got {1}."), Type_0_has_no_properties_in_common_with_type_1: diag(2559, ts.DiagnosticCategory.Error, "Type_0_has_no_properties_in_common_with_type_1_2559", "Type '{0}' has no properties in common with type '{1}'."), Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it: diag(2560, ts.DiagnosticCategory.Error, "Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it_2560", "Value of type '{0}' has no properties in common with type '{1}'. Did you mean to call it?"), @@ -8385,17 +8605,17 @@ var ts; Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode: diag(2580, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashno_2580", "Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`."), Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery: diag(2581, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slash_2581", "Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i --save-dev @types/jquery`."), Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_types_Slashjest_or_npm_i_save_dev_types_Slashmocha: diag(2582, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_type_2582", "Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`."), - Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_1_or_later: diag(2583, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2583", "Cannot find name '{0}'. Do you need to change your target library? Try changing the `lib` compiler option to '{1}' or later."), - Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_include_dom: diag(2584, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2584", "Cannot find name '{0}'. Do you need to change your target library? Try changing the `lib` compiler option to include 'dom'."), - _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: diag(2585, ts.DiagnosticCategory.Error, "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_2585", "'{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."), + Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_1_or_later: diag(2583, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2583", "Cannot find name '{0}'. Do you need to change your target library? Try changing the 'lib' compiler option to '{1}' or later."), + Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_include_dom: diag(2584, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2584", "Cannot find name '{0}'. Do you need to change your target library? Try changing the 'lib' compiler option to include 'dom'."), + _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: diag(2585, ts.DiagnosticCategory.Error, "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_2585", "'{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."), Enum_type_0_circularly_references_itself: diag(2586, ts.DiagnosticCategory.Error, "Enum_type_0_circularly_references_itself_2586", "Enum type '{0}' circularly references itself."), JSDoc_type_0_circularly_references_itself: diag(2587, ts.DiagnosticCategory.Error, "JSDoc_type_0_circularly_references_itself_2587", "JSDoc type '{0}' circularly references itself."), Cannot_assign_to_0_because_it_is_a_constant: diag(2588, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_a_constant_2588", "Cannot assign to '{0}' because it is a constant."), Type_instantiation_is_excessively_deep_and_possibly_infinite: diag(2589, ts.DiagnosticCategory.Error, "Type_instantiation_is_excessively_deep_and_possibly_infinite_2589", "Type instantiation is excessively deep and possibly infinite."), Expression_produces_a_union_type_that_is_too_complex_to_represent: diag(2590, ts.DiagnosticCategory.Error, "Expression_produces_a_union_type_that_is_too_complex_to_represent_2590", "Expression produces a union type that is too complex to represent."), - Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode_and_then_add_node_to_the_types_field_in_your_tsconfig: diag(2591, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashno_2591", "Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node` and then add `node` to the types field in your tsconfig."), - Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery_and_then_add_jquery_to_the_types_field_in_your_tsconfig: diag(2592, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slash_2592", "Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i --save-dev @types/jquery` and then add `jquery` to the types field in your tsconfig."), - Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_types_Slashjest_or_npm_i_save_dev_types_Slashmocha_and_then_add_jest_or_mocha_to_the_types_field_in_your_tsconfig: diag(2593, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_type_2593", "Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode_and_then_add_node_to_the_types_field_in_your_tsconfig: diag(2591, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashno_2591", "Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node` and then add 'node' to the types field in your tsconfig."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery_and_then_add_jquery_to_the_types_field_in_your_tsconfig: diag(2592, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slash_2592", "Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i --save-dev @types/jquery` and then add 'jquery' to the types field in your tsconfig."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_types_Slashjest_or_npm_i_save_dev_types_Slashmocha_and_then_add_jest_or_mocha_to_the_types_field_in_your_tsconfig: diag(2593, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_type_2593", "Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig."), This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag: diag(2594, ts.DiagnosticCategory.Error, "This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the__2594", "This module is declared with using 'export =', and can only be used with a default import when using the '{0}' flag."), _0_can_only_be_imported_by_using_a_default_import: diag(2595, ts.DiagnosticCategory.Error, "_0_can_only_be_imported_by_using_a_default_import_2595", "'{0}' can only be imported by using a default import."), _0_can_only_be_imported_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import: diag(2596, ts.DiagnosticCategory.Error, "_0_can_only_be_imported_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import_2596", "'{0}' can only be imported by turning on the 'esModuleInterop' flag and using a default import."), @@ -8428,6 +8648,12 @@ var ts; Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target: diag(2625, ts.DiagnosticCategory.Error, "Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target_2625", "Variadic element at position {0} in source does not match element at position {1} in target."), Type_at_position_0_in_source_is_not_compatible_with_type_at_position_1_in_target: diag(2626, ts.DiagnosticCategory.Error, "Type_at_position_0_in_source_is_not_compatible_with_type_at_position_1_in_target_2626", "Type at position {0} in source is not compatible with type at position {1} in target."), Type_at_positions_0_through_1_in_source_is_not_compatible_with_type_at_position_2_in_target: diag(2627, ts.DiagnosticCategory.Error, "Type_at_positions_0_through_1_in_source_is_not_compatible_with_type_at_position_2_in_target_2627", "Type at positions {0} through {1} in source is not compatible with type at position {2} in target."), + Cannot_assign_to_0_because_it_is_an_enum: diag(2628, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_an_enum_2628", "Cannot assign to '{0}' because it is an enum."), + Cannot_assign_to_0_because_it_is_a_class: diag(2629, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_a_class_2629", "Cannot assign to '{0}' because it is a class."), + Cannot_assign_to_0_because_it_is_a_function: diag(2630, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_a_function_2630", "Cannot assign to '{0}' because it is a function."), + Cannot_assign_to_0_because_it_is_a_namespace: diag(2631, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_a_namespace_2631", "Cannot assign to '{0}' because it is a namespace."), + Cannot_assign_to_0_because_it_is_an_import: diag(2632, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_an_import_2632", "Cannot assign to '{0}' because it is an import."), + JSX_property_access_expressions_cannot_include_JSX_namespace_names: diag(2633, ts.DiagnosticCategory.Error, "JSX_property_access_expressions_cannot_include_JSX_namespace_names_2633", "JSX property access expressions cannot include JSX namespace names"), Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: diag(2649, ts.DiagnosticCategory.Error, "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", "Cannot augment module '{0}' with value exports because it resolves to a non-module entity."), A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: diag(2651, ts.DiagnosticCategory.Error, "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums."), Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: diag(2652, ts.DiagnosticCategory.Error, "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead."), @@ -8474,7 +8700,7 @@ var ts; Namespace_0_has_no_exported_member_1: diag(2694, ts.DiagnosticCategory.Error, "Namespace_0_has_no_exported_member_1_2694", "Namespace '{0}' has no exported member '{1}'."), Left_side_of_comma_operator_is_unused_and_has_no_side_effects: diag(2695, ts.DiagnosticCategory.Error, "Left_side_of_comma_operator_is_unused_and_has_no_side_effects_2695", "Left side of comma operator is unused and has no side effects.", /*reportsUnnecessary*/ true), The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead: diag(2696, ts.DiagnosticCategory.Error, "The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead_2696", "The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?"), - An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: diag(2697, ts.DiagnosticCategory.Error, "An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_in_2697", "An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option."), + An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: diag(2697, ts.DiagnosticCategory.Error, "An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_in_2697", "An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your '--lib' option."), Spread_types_may_only_be_created_from_object_types: diag(2698, ts.DiagnosticCategory.Error, "Spread_types_may_only_be_created_from_object_types_2698", "Spread types may only be created from object types."), Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1: diag(2699, ts.DiagnosticCategory.Error, "Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1_2699", "Static property '{0}' conflicts with built-in property 'Function.{0}' of constructor function '{1}'."), Rest_types_may_only_be_created_from_object_types: diag(2700, ts.DiagnosticCategory.Error, "Rest_types_may_only_be_created_from_object_types_2700", "Rest types may only be created from object types."), @@ -8482,14 +8708,14 @@ var ts; _0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here: diag(2702, ts.DiagnosticCategory.Error, "_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here_2702", "'{0}' only refers to a type, but is being used as a namespace here."), The_operand_of_a_delete_operator_must_be_a_property_reference: diag(2703, ts.DiagnosticCategory.Error, "The_operand_of_a_delete_operator_must_be_a_property_reference_2703", "The operand of a 'delete' operator must be a property reference."), The_operand_of_a_delete_operator_cannot_be_a_read_only_property: diag(2704, ts.DiagnosticCategory.Error, "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704", "The operand of a 'delete' operator cannot be a read-only property."), - 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: diag(2705, ts.DiagnosticCategory.Error, "An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_de_2705", "An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option."), + 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: diag(2705, ts.DiagnosticCategory.Error, "An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_de_2705", "An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option."), Required_type_parameters_may_not_follow_optional_type_parameters: diag(2706, ts.DiagnosticCategory.Error, "Required_type_parameters_may_not_follow_optional_type_parameters_2706", "Required type parameters may not follow optional type parameters."), Generic_type_0_requires_between_1_and_2_type_arguments: diag(2707, ts.DiagnosticCategory.Error, "Generic_type_0_requires_between_1_and_2_type_arguments_2707", "Generic type '{0}' requires between {1} and {2} type arguments."), Cannot_use_namespace_0_as_a_value: diag(2708, ts.DiagnosticCategory.Error, "Cannot_use_namespace_0_as_a_value_2708", "Cannot use namespace '{0}' as a value."), Cannot_use_namespace_0_as_a_type: diag(2709, ts.DiagnosticCategory.Error, "Cannot_use_namespace_0_as_a_type_2709", "Cannot use namespace '{0}' as a type."), _0_are_specified_twice_The_attribute_named_0_will_be_overwritten: diag(2710, ts.DiagnosticCategory.Error, "_0_are_specified_twice_The_attribute_named_0_will_be_overwritten_2710", "'{0}' are specified twice. The attribute named '{0}' will be overwritten."), - A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: diag(2711, ts.DiagnosticCategory.Error, "A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES20_2711", "A dynamic import call returns a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option."), - A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option: diag(2712, ts.DiagnosticCategory.Error, "A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declarat_2712", "A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option."), + A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: diag(2711, ts.DiagnosticCategory.Error, "A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES20_2711", "A dynamic import call returns a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your '--lib' option."), + A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option: diag(2712, ts.DiagnosticCategory.Error, "A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declarat_2712", "A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option."), 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: diag(2713, ts.DiagnosticCategory.Error, "Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_p_2713", "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}\"]'?"), The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context: diag(2714, ts.DiagnosticCategory.Error, "The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context_2714", "The expression of an export assignment must be an identifier or qualified name in an ambient context."), Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor: diag(2715, ts.DiagnosticCategory.Error, "Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor_2715", "Abstract property '{0}' in class '{1}' cannot be accessed in the constructor."), @@ -8551,7 +8777,7 @@ var ts; The_last_overload_is_declared_here: diag(2771, ts.DiagnosticCategory.Error, "The_last_overload_is_declared_here_2771", "The last overload is declared here."), Overload_0_of_1_2_gave_the_following_error: diag(2772, ts.DiagnosticCategory.Error, "Overload_0_of_1_2_gave_the_following_error_2772", "Overload {0} of {1}, '{2}', gave the following error."), Did_you_forget_to_use_await: diag(2773, ts.DiagnosticCategory.Error, "Did_you_forget_to_use_await_2773", "Did you forget to use 'await'?"), - This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead: diag(2774, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it__2774", "This condition will always return true since the function is always defined. Did you mean to call it instead?"), + This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_instead: diag(2774, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_2774", "This condition will always return true since this function is always defined. Did you mean to call it instead?"), Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation: diag(2775, ts.DiagnosticCategory.Error, "Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation_2775", "Assertions require every name in the call target to be declared with an explicit type annotation."), Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name: diag(2776, ts.DiagnosticCategory.Error, "Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name_2776", "Assertions require the call target to be an identifier or qualified name."), The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access: diag(2777, ts.DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access_2777", "The operand of an increment or decrement operator may not be an optional property access."), @@ -8575,6 +8801,23 @@ var ts; The_intrinsic_keyword_can_only_be_used_to_declare_compiler_provided_intrinsic_types: diag(2795, ts.DiagnosticCategory.Error, "The_intrinsic_keyword_can_only_be_used_to_declare_compiler_provided_intrinsic_types_2795", "The 'intrinsic' keyword can only be used to declare compiler provided intrinsic types."), It_is_likely_that_you_are_missing_a_comma_to_separate_these_two_template_expressions_They_form_a_tagged_template_expression_which_cannot_be_invoked: diag(2796, ts.DiagnosticCategory.Error, "It_is_likely_that_you_are_missing_a_comma_to_separate_these_two_template_expressions_They_form_a_tag_2796", "It is likely that you are missing a comma to separate these two template expressions. They form a tagged template expression which cannot be invoked."), A_mixin_class_that_extends_from_a_type_variable_containing_an_abstract_construct_signature_must_also_be_declared_abstract: diag(2797, ts.DiagnosticCategory.Error, "A_mixin_class_that_extends_from_a_type_variable_containing_an_abstract_construct_signature_must_also_2797", "A mixin class that extends from a type variable containing an abstract construct signature must also be declared 'abstract'."), + The_declaration_was_marked_as_deprecated_here: diag(2798, ts.DiagnosticCategory.Error, "The_declaration_was_marked_as_deprecated_here_2798", "The declaration was marked as deprecated here."), + Type_produces_a_tuple_type_that_is_too_large_to_represent: diag(2799, ts.DiagnosticCategory.Error, "Type_produces_a_tuple_type_that_is_too_large_to_represent_2799", "Type produces a tuple type that is too large to represent."), + Expression_produces_a_tuple_type_that_is_too_large_to_represent: diag(2800, ts.DiagnosticCategory.Error, "Expression_produces_a_tuple_type_that_is_too_large_to_represent_2800", "Expression produces a tuple type that is too large to represent."), + This_condition_will_always_return_true_since_this_0_is_always_defined: diag(2801, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_this_0_is_always_defined_2801", "This condition will always return true since this '{0}' is always defined."), + Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher: diag(2802, ts.DiagnosticCategory.Error, "Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es201_2802", "Type '{0}' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher."), + Cannot_assign_to_private_method_0_Private_methods_are_not_writable: diag(2803, ts.DiagnosticCategory.Error, "Cannot_assign_to_private_method_0_Private_methods_are_not_writable_2803", "Cannot assign to private method '{0}'. Private methods are not writable."), + Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name: diag(2804, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name_2804", "Duplicate identifier '{0}'. Static and instance elements cannot share the same private name."), + Static_fields_with_private_names_can_t_have_initializers_when_the_useDefineForClassFields_flag_is_not_specified_with_a_target_of_esnext_Consider_adding_the_useDefineForClassFields_flag: diag(2805, ts.DiagnosticCategory.Error, "Static_fields_with_private_names_can_t_have_initializers_when_the_useDefineForClassFields_flag_is_no_2805", "Static fields with private names can't have initializers when the '--useDefineForClassFields' flag is not specified with a '--target' of 'esnext'. Consider adding the '--useDefineForClassFields' flag."), + Private_accessor_was_defined_without_a_getter: diag(2806, ts.DiagnosticCategory.Error, "Private_accessor_was_defined_without_a_getter_2806", "Private accessor was defined without a getter."), + 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: diag(2807, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807", "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}'."), + A_get_accessor_must_be_at_least_as_accessible_as_the_setter: diag(2808, ts.DiagnosticCategory.Error, "A_get_accessor_must_be_at_least_as_accessible_as_the_setter_2808", "A get accessor must be at least as accessible as the setter"), + 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: diag(2809, ts.DiagnosticCategory.Error, "Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_d_2809", "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."), + Property_0_may_not_be_used_in_a_static_property_s_initializer_in_the_same_class_when_target_is_esnext_and_useDefineForClassFields_is_false: diag(2810, ts.DiagnosticCategory.Error, "Property_0_may_not_be_used_in_a_static_property_s_initializer_in_the_same_class_when_target_is_esnex_2810", "Property '{0}' may not be used in a static property's initializer in the same class when 'target' is 'esnext' and 'useDefineForClassFields' is 'false'."), + Initializer_for_property_0: diag(2811, ts.DiagnosticCategory.Error, "Initializer_for_property_0_2811", "Initializer for property '{0}'"), + Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom: diag(2812, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom_2812", "Property '{0}' does not exist on type '{1}'. Try changing the 'lib' compiler option to include 'dom'."), + Class_declaration_cannot_implement_overload_list_for_0: diag(2813, ts.DiagnosticCategory.Error, "Class_declaration_cannot_implement_overload_list_for_0_2813", "Class declaration cannot implement overload list for '{0}'."), + Function_with_bodies_can_only_merge_with_classes_that_are_ambient: diag(2814, ts.DiagnosticCategory.Error, "Function_with_bodies_can_only_merge_with_classes_that_are_ambient_2814", "Function with bodies can only merge with classes that are ambient."), 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}'."), @@ -8647,6 +8890,7 @@ var ts; Exported_type_alias_0_has_or_is_using_private_name_1: diag(4081, ts.DiagnosticCategory.Error, "Exported_type_alias_0_has_or_is_using_private_name_1_4081", "Exported type alias '{0}' has or is using private name '{1}'."), Default_export_of_the_module_has_or_is_using_private_name_0: diag(4082, ts.DiagnosticCategory.Error, "Default_export_of_the_module_has_or_is_using_private_name_0_4082", "Default export of the module has or is using private name '{0}'."), Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1: diag(4083, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1_4083", "Type parameter '{0}' of exported type alias has or is using private name '{1}'."), + Exported_type_alias_0_has_or_is_using_private_name_1_from_module_2: diag(4084, ts.DiagnosticCategory.Error, "Exported_type_alias_0_has_or_is_using_private_name_1_from_module_2_4084", "Exported type alias '{0}' has or is using private name '{1}' from module {2}."), Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict: diag(4090, ts.DiagnosticCategory.Error, "Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_librar_4090", "Conflicting definitions for '{0}' found at '{1}' and '{2}'. Consider installing a specific version of this library to resolve the conflict."), Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: diag(4091, ts.DiagnosticCategory.Error, "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4091", "Parameter '{0}' of index signature from exported interface has or is using name '{1}' from private module '{2}'."), Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1: diag(4092, ts.DiagnosticCategory.Error, "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1_4092", "Parameter '{0}' of index signature from exported interface has or is using private name '{1}'."), @@ -8668,6 +8912,12 @@ var ts; Type_arguments_for_0_circularly_reference_themselves: diag(4109, ts.DiagnosticCategory.Error, "Type_arguments_for_0_circularly_reference_themselves_4109", "Type arguments for '{0}' circularly reference themselves."), Tuple_type_arguments_circularly_reference_themselves: diag(4110, ts.DiagnosticCategory.Error, "Tuple_type_arguments_circularly_reference_themselves_4110", "Tuple type arguments circularly reference themselves."), Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0: diag(4111, ts.DiagnosticCategory.Error, "Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0_4111", "Property '{0}' comes from an index signature, so it must be accessed with ['{0}']."), + This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class: diag(4112, ts.DiagnosticCategory.Error, "This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another__4112", "This member cannot have an 'override' modifier because its containing class '{0}' does not extend another class."), + This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0: diag(4113, ts.DiagnosticCategory.Error, "This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0_4113", "This member cannot have an 'override' modifier because it is not declared in the base class '{0}'."), + This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0: diag(4114, ts.DiagnosticCategory.Error, "This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0_4114", "This member must have an 'override' modifier because it overrides a member in the base class '{0}'."), + This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0: diag(4115, ts.DiagnosticCategory.Error, "This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0_4115", "This parameter property must have an 'override' modifier because it overrides a member in base class '{0}'."), + This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0: diag(4116, ts.DiagnosticCategory.Error, "This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared__4116", "This member must have an 'override' modifier because it overrides an abstract method that is declared in the base class '{0}'."), + This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1: diag(4117, ts.DiagnosticCategory.Error, "This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0_Did_you__4117", "This member cannot have an 'override' modifier because it is not declared in the base class '{0}'. Did you mean '{1}'?"), The_current_host_does_not_support_the_0_option: diag(5001, ts.DiagnosticCategory.Error, "The_current_host_does_not_support_the_0_option_5001", "The current host does not support the '{0}' option."), Cannot_find_the_common_subdirectory_path_for_the_input_files: diag(5009, ts.DiagnosticCategory.Error, "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", "Cannot find the common subdirectory path for the input files."), File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5010, ts.DiagnosticCategory.Error, "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", "File specification cannot end in a recursive directory wildcard ('**'): '{0}'."), @@ -8702,7 +8952,7 @@ var ts; Option_resolveJsonModule_can_only_be_specified_when_module_code_generation_is_commonjs_amd_es2015_or_esNext: diag(5071, ts.DiagnosticCategory.Error, "Option_resolveJsonModule_can_only_be_specified_when_module_code_generation_is_commonjs_amd_es2015_or_5071", "Option '--resolveJsonModule' can only be specified when module code generation is 'commonjs', 'amd', 'es2015' or 'esNext'."), Unknown_build_option_0: diag(5072, ts.DiagnosticCategory.Error, "Unknown_build_option_0_5072", "Unknown build option '{0}'."), Build_option_0_requires_a_value_of_type_1: diag(5073, ts.DiagnosticCategory.Error, "Build_option_0_requires_a_value_of_type_1_5073", "Build option '{0}' requires a value of type {1}."), - Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified: diag(5074, ts.DiagnosticCategory.Error, "Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBui_5074", "Option '--incremental' can only be specified using tsconfig, emitting to single file or when option `--tsBuildInfoFile` is specified."), + Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified: diag(5074, ts.DiagnosticCategory.Error, "Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBui_5074", "Option '--incremental' can only be specified using tsconfig, emitting to single file or when option '--tsBuildInfoFile' is specified."), _0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2: diag(5075, ts.DiagnosticCategory.Error, "_0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_5075", "'{0}' is assignable to the constraint of type '{1}', but '{1}' could be instantiated with a different subtype of constraint '{2}'."), _0_and_1_operations_cannot_be_mixed_without_parentheses: diag(5076, ts.DiagnosticCategory.Error, "_0_and_1_operations_cannot_be_mixed_without_parentheses_5076", "'{0}' and '{1}' operations cannot be mixed without parentheses."), Unknown_build_option_0_Did_you_mean_1: diag(5077, ts.DiagnosticCategory.Error, "Unknown_build_option_0_Did_you_mean_1_5077", "Unknown build option '{0}'. Did you mean '{1}'?"), @@ -8715,10 +8965,14 @@ var ts; Tuple_members_must_all_have_names_or_all_not_have_names: diag(5084, ts.DiagnosticCategory.Error, "Tuple_members_must_all_have_names_or_all_not_have_names_5084", "Tuple members must all have names or all not have names."), A_tuple_member_cannot_be_both_optional_and_rest: diag(5085, ts.DiagnosticCategory.Error, "A_tuple_member_cannot_be_both_optional_and_rest_5085", "A tuple member cannot be both optional and rest."), A_labeled_tuple_element_is_declared_as_optional_with_a_question_mark_after_the_name_and_before_the_colon_rather_than_after_the_type: diag(5086, ts.DiagnosticCategory.Error, "A_labeled_tuple_element_is_declared_as_optional_with_a_question_mark_after_the_name_and_before_the_c_5086", "A labeled tuple element is declared as optional with a question mark after the name and before the colon, rather than after the type."), - A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type: diag(5087, ts.DiagnosticCategory.Error, "A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type_5087", "A labeled tuple element is declared as rest with a `...` before the name, rather than before the type."), + A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type: diag(5087, ts.DiagnosticCategory.Error, "A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type_5087", "A labeled tuple element is declared as rest with a '...' before the name, rather than before the type."), The_inferred_type_of_0_references_a_type_with_a_cyclic_structure_which_cannot_be_trivially_serialized_A_type_annotation_is_necessary: diag(5088, ts.DiagnosticCategory.Error, "The_inferred_type_of_0_references_a_type_with_a_cyclic_structure_which_cannot_be_trivially_serialize_5088", "The inferred type of '{0}' references a type with a cyclic structure which cannot be trivially serialized. A type annotation is necessary."), Option_0_cannot_be_specified_when_option_jsx_is_1: diag(5089, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_when_option_jsx_is_1_5089", "Option '{0}' cannot be specified when option 'jsx' is '{1}'."), Non_relative_paths_are_not_allowed_when_baseUrl_is_not_set_Did_you_forget_a_leading_Slash: diag(5090, ts.DiagnosticCategory.Error, "Non_relative_paths_are_not_allowed_when_baseUrl_is_not_set_Did_you_forget_a_leading_Slash_5090", "Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?"), + Option_preserveConstEnums_cannot_be_disabled_when_isolatedModules_is_enabled: diag(5091, ts.DiagnosticCategory.Error, "Option_preserveConstEnums_cannot_be_disabled_when_isolatedModules_is_enabled_5091", "Option 'preserveConstEnums' cannot be disabled when 'isolatedModules' is enabled."), + The_root_value_of_a_0_file_must_be_an_object: diag(5092, ts.DiagnosticCategory.Error, "The_root_value_of_a_0_file_must_be_an_object_5092", "The root value of a '{0}' file must be an object."), + Compiler_option_0_may_only_be_used_with_build: diag(5093, ts.DiagnosticCategory.Error, "Compiler_option_0_may_only_be_used_with_build_5093", "Compiler option '--{0}' may only be used with '--build'."), + Compiler_option_0_may_not_be_used_with_build: diag(5094, ts.DiagnosticCategory.Error, "Compiler_option_0_may_not_be_used_with_build_5094", "Compiler option '--{0}' may not be used with '--build'."), Generates_a_sourcemap_for_each_corresponding_d_ts_file: diag(6000, ts.DiagnosticCategory.Message, "Generates_a_sourcemap_for_each_corresponding_d_ts_file_6000", "Generates a sourcemap for each corresponding '.d.ts' file."), Concatenate_and_emit_output_to_single_file: diag(6001, ts.DiagnosticCategory.Message, "Concatenate_and_emit_output_to_single_file_6001", "Concatenate and emit output to single file."), Generates_corresponding_d_ts_file: diag(6002, ts.DiagnosticCategory.Message, "Generates_corresponding_d_ts_file_6002", "Generates corresponding '.d.ts' file."), @@ -8734,7 +8988,7 @@ var ts; Skip_type_checking_of_declaration_files: diag(6012, ts.DiagnosticCategory.Message, "Skip_type_checking_of_declaration_files_6012", "Skip type checking of declaration files."), Do_not_resolve_the_real_path_of_symlinks: diag(6013, ts.DiagnosticCategory.Message, "Do_not_resolve_the_real_path_of_symlinks_6013", "Do not resolve the real path of symlinks."), Only_emit_d_ts_declaration_files: diag(6014, ts.DiagnosticCategory.Message, "Only_emit_d_ts_declaration_files_6014", "Only emit '.d.ts' declaration files."), - Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_or_ESNEXT: diag(6015, ts.DiagnosticCategory.Message, "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_or_6015", "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'."), + Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_ES2021_or_ESNEXT: diag(6015, ts.DiagnosticCategory.Message, "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_ES_6015", "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'."), Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_es2020_or_ESNext: diag(6016, ts.DiagnosticCategory.Message, "Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_es2020_or_ESNext_6016", "Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'."), Print_this_message: diag(6017, ts.DiagnosticCategory.Message, "Print_this_message_6017", "Print this message."), Print_the_compiler_s_version: diag(6019, ts.DiagnosticCategory.Message, "Print_the_compiler_s_version_6019", "Print the compiler's version."), @@ -8877,19 +9131,12 @@ var ts; Show_all_compiler_options: diag(6169, ts.DiagnosticCategory.Message, "Show_all_compiler_options_6169", "Show all compiler options."), Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file: diag(6170, ts.DiagnosticCategory.Message, "Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file_6170", "[Deprecated] Use '--outFile' instead. Concatenate and emit output to single file"), Command_line_Options: diag(6171, ts.DiagnosticCategory.Message, "Command_line_Options_6171", "Command-line Options"), - Basic_Options: diag(6172, ts.DiagnosticCategory.Message, "Basic_Options_6172", "Basic Options"), - Strict_Type_Checking_Options: diag(6173, ts.DiagnosticCategory.Message, "Strict_Type_Checking_Options_6173", "Strict Type-Checking Options"), - Module_Resolution_Options: diag(6174, ts.DiagnosticCategory.Message, "Module_Resolution_Options_6174", "Module Resolution Options"), - Source_Map_Options: diag(6175, ts.DiagnosticCategory.Message, "Source_Map_Options_6175", "Source Map Options"), - Additional_Checks: diag(6176, ts.DiagnosticCategory.Message, "Additional_Checks_6176", "Additional Checks"), - Experimental_Options: diag(6177, ts.DiagnosticCategory.Message, "Experimental_Options_6177", "Experimental Options"), - Advanced_Options: diag(6178, ts.DiagnosticCategory.Message, "Advanced_Options_6178", "Advanced Options"), Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3: diag(6179, ts.DiagnosticCategory.Message, "Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3_6179", "Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'."), Enable_all_strict_type_checking_options: diag(6180, ts.DiagnosticCategory.Message, "Enable_all_strict_type_checking_options_6180", "Enable all strict type-checking options."), List_of_language_service_plugins: diag(6181, ts.DiagnosticCategory.Message, "List_of_language_service_plugins_6181", "List of language service plugins."), Scoped_package_detected_looking_in_0: diag(6182, ts.DiagnosticCategory.Message, "Scoped_package_detected_looking_in_0_6182", "Scoped package detected, looking in '{0}'"), - Reusing_resolution_of_module_0_to_file_1_from_old_program: diag(6183, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_to_file_1_from_old_program_6183", "Reusing resolution of module '{0}' to file '{1}' from old program."), - Reusing_module_resolutions_originating_in_0_since_resolutions_are_unchanged_from_old_program: diag(6184, ts.DiagnosticCategory.Message, "Reusing_module_resolutions_originating_in_0_since_resolutions_are_unchanged_from_old_program_6184", "Reusing module resolutions originating in '{0}' since resolutions are unchanged from old program."), + Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2: diag(6183, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_6183", "Reusing resolution of module '{0}' from '{1}' of old program, it was successfully resolved to '{2}'."), + Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3: diag(6184, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package__6184", "Reusing resolution of module '{0}' from '{1}' of old program, it was successfully resolved to '{2}' with Package ID '{3}'."), Disable_strict_checking_of_generic_signatures_in_function_types: diag(6185, ts.DiagnosticCategory.Message, "Disable_strict_checking_of_generic_signatures_in_function_types_6185", "Disable strict checking of generic signatures in function types."), Enable_strict_checking_of_function_types: diag(6186, ts.DiagnosticCategory.Message, "Enable_strict_checking_of_function_types_6186", "Enable strict checking of function types."), Enable_strict_checking_of_property_initialization_in_classes: diag(6187, ts.DiagnosticCategory.Message, "Enable_strict_checking_of_property_initialization_in_classes_6187", "Enable strict checking of property initialization in classes."), @@ -8929,9 +9176,9 @@ var ts; Emit_class_fields_with_Define_instead_of_Set: diag(6222, ts.DiagnosticCategory.Message, "Emit_class_fields_with_Define_instead_of_Set_6222", "Emit class fields with Define instead of Set."), Generates_a_CPU_profile: diag(6223, ts.DiagnosticCategory.Message, "Generates_a_CPU_profile_6223", "Generates a CPU profile."), Disable_solution_searching_for_this_project: diag(6224, ts.DiagnosticCategory.Message, "Disable_solution_searching_for_this_project_6224", "Disable solution searching for this project."), - Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_DynamicPriorityPolling_UseFsEvents_UseFsEventsOnParentDirectory: diag(6225, ts.DiagnosticCategory.Message, "Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_Dynami_6225", "Specify strategy for watching file: 'FixedPollingInterval' (default), 'PriorityPollingInterval', 'DynamicPriorityPolling', 'UseFsEvents', 'UseFsEventsOnParentDirectory'."), - Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling: diag(6226, ts.DiagnosticCategory.Message, "Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively__6226", "Specify strategy for watching directory on platforms that don't support recursive watching natively: 'UseFsEvents' (default), 'FixedPollingInterval', 'DynamicPriorityPolling'."), - Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority: diag(6227, ts.DiagnosticCategory.Message, "Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_6227", "Specify strategy for creating a polling watch when it fails to create using file system events: 'FixedInterval' (default), 'PriorityInterval', 'DynamicPriority'."), + Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_DynamicPriorityPolling_FixedChunkSizePolling_UseFsEvents_UseFsEventsOnParentDirectory: diag(6225, ts.DiagnosticCategory.Message, "Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_Dynami_6225", "Specify strategy for watching file: 'FixedPollingInterval' (default), 'PriorityPollingInterval', 'DynamicPriorityPolling', 'FixedChunkSizePolling', 'UseFsEvents', 'UseFsEventsOnParentDirectory'."), + Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling_FixedChunkSizePolling: diag(6226, ts.DiagnosticCategory.Message, "Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively__6226", "Specify strategy for watching directory on platforms that don't support recursive watching natively: 'UseFsEvents' (default), 'FixedPollingInterval', 'DynamicPriorityPolling', 'FixedChunkSizePolling'."), + Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority_FixedChunkSize: diag(6227, ts.DiagnosticCategory.Message, "Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_6227", "Specify strategy for creating a polling watch when it fails to create using file system events: 'FixedInterval' (default), 'PriorityInterval', 'DynamicPriority', 'FixedChunkSize'."), Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively: diag(6228, ts.DiagnosticCategory.Message, "Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_supp_6228", "Synchronously call callbacks and update the state of directory watchers on platforms that don't support recursive watching natively."), Tag_0_expects_at_least_1_arguments_but_the_JSX_factory_2_provides_at_most_3: diag(6229, ts.DiagnosticCategory.Error, "Tag_0_expects_at_least_1_arguments_but_the_JSX_factory_2_provides_at_most_3_6229", "Tag '{0}' expects at least '{1}' arguments, but the JSX factory '{2}' provides at most '{3}'."), Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line: diag(6230, ts.DiagnosticCategory.Error, "Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line_6230", "Option '{0}' can only be specified in 'tsconfig.json' file or set to 'false' or 'null' on command line."), @@ -8942,7 +9189,26 @@ var ts; Disable_loading_referenced_projects: diag(6235, ts.DiagnosticCategory.Message, "Disable_loading_referenced_projects_6235", "Disable loading referenced projects."), Arguments_for_the_rest_parameter_0_were_not_provided: diag(6236, ts.DiagnosticCategory.Error, "Arguments_for_the_rest_parameter_0_were_not_provided_6236", "Arguments for the rest parameter '{0}' were not provided."), Generates_an_event_trace_and_a_list_of_types: diag(6237, ts.DiagnosticCategory.Message, "Generates_an_event_trace_and_a_list_of_types_6237", "Generates an event trace and a list of types."), - Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react: diag(6238, ts.DiagnosticCategory.Error, "Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react_6238", "Specify the module specifier to be used to import the `jsx` and `jsxs` factory functions from. eg, react"), + Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react: diag(6238, ts.DiagnosticCategory.Error, "Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react_6238", "Specify the module specifier to be used to import the 'jsx' and 'jsxs' factory functions from. eg, react"), + File_0_exists_according_to_earlier_cached_lookups: diag(6239, ts.DiagnosticCategory.Message, "File_0_exists_according_to_earlier_cached_lookups_6239", "File '{0}' exists according to earlier cached lookups."), + File_0_does_not_exist_according_to_earlier_cached_lookups: diag(6240, ts.DiagnosticCategory.Message, "File_0_does_not_exist_according_to_earlier_cached_lookups_6240", "File '{0}' does not exist according to earlier cached lookups."), + Resolution_for_type_reference_directive_0_was_found_in_cache_from_location_1: diag(6241, ts.DiagnosticCategory.Message, "Resolution_for_type_reference_directive_0_was_found_in_cache_from_location_1_6241", "Resolution for type reference directive '{0}' was found in cache from location '{1}'."), + Resolving_type_reference_directive_0_containing_file_1: diag(6242, ts.DiagnosticCategory.Message, "Resolving_type_reference_directive_0_containing_file_1_6242", "======== Resolving type reference directive '{0}', containing file '{1}'. ========"), + Enable_strict_checking_of_optional_properties: diag(6243, ts.DiagnosticCategory.Message, "Enable_strict_checking_of_optional_properties_6243", "Enable strict checking of optional properties."), + Modules: diag(6244, ts.DiagnosticCategory.Message, "Modules_6244", "Modules"), + File_Management: diag(6245, ts.DiagnosticCategory.Message, "File_Management_6245", "File Management"), + Emit: diag(6246, ts.DiagnosticCategory.Message, "Emit_6246", "Emit"), + JavaScript_Support: diag(6247, ts.DiagnosticCategory.Message, "JavaScript_Support_6247", "JavaScript Support"), + Type_Checking: diag(6248, ts.DiagnosticCategory.Message, "Type_Checking_6248", "Type Checking"), + Editor_Support: diag(6249, ts.DiagnosticCategory.Message, "Editor_Support_6249", "Editor Support"), + Watch_and_Build_Modes: diag(6250, ts.DiagnosticCategory.Message, "Watch_and_Build_Modes_6250", "Watch and Build Modes"), + Compiler_Diagnostics: diag(6251, ts.DiagnosticCategory.Message, "Compiler_Diagnostics_6251", "Compiler Diagnostics"), + Interop_Constraints: diag(6252, ts.DiagnosticCategory.Message, "Interop_Constraints_6252", "Interop Constraints"), + Backwards_Compatibility: diag(6253, ts.DiagnosticCategory.Message, "Backwards_Compatibility_6253", "Backwards Compatibility"), + Language_and_Environment: diag(6254, ts.DiagnosticCategory.Message, "Language_and_Environment_6254", "Language and Environment"), + Projects: diag(6255, ts.DiagnosticCategory.Message, "Projects_6255", "Projects"), + Output_Formatting: diag(6256, ts.DiagnosticCategory.Message, "Output_Formatting_6256", "Output Formatting"), + Completeness: diag(6257, ts.DiagnosticCategory.Message, "Completeness_6257", "Completeness"), Projects_to_reference: diag(6300, ts.DiagnosticCategory.Message, "Projects_to_reference_6300", "Projects to reference"), Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"), Composite_projects_may_not_disable_declaration_emit: diag(6304, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_declaration_emit_6304", "Composite projects may not disable declaration emit."), @@ -8987,16 +9253,31 @@ var ts; Skipping_build_of_project_0_because_its_dependency_1_was_not_built: diag(6382, ts.DiagnosticCategory.Message, "Skipping_build_of_project_0_because_its_dependency_1_was_not_built_6382", "Skipping build of project '{0}' because its dependency '{1}' was not built"), Project_0_can_t_be_built_because_its_dependency_1_was_not_built: diag(6383, ts.DiagnosticCategory.Message, "Project_0_can_t_be_built_because_its_dependency_1_was_not_built_6383", "Project '{0}' can't be built because its dependency '{1}' was not built"), Have_recompiles_in_incremental_and_watch_assume_that_changes_within_a_file_will_only_affect_files_directly_depending_on_it: diag(6384, ts.DiagnosticCategory.Message, "Have_recompiles_in_incremental_and_watch_assume_that_changes_within_a_file_will_only_affect_files_di_6384", "Have recompiles in '--incremental' and '--watch' assume that changes within a file will only affect files directly depending on it."), - _0_is_deprecated: diag(6385, ts.DiagnosticCategory.Suggestion, "_0_is_deprecated_6385", "'{0}' is deprecated", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ undefined, /*reportsDeprecated*/ true), + _0_is_deprecated: diag(6385, ts.DiagnosticCategory.Suggestion, "_0_is_deprecated_6385", "'{0}' is deprecated.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ undefined, /*reportsDeprecated*/ true), Performance_timings_for_diagnostics_or_extendedDiagnostics_are_not_available_in_this_session_A_native_implementation_of_the_Web_Performance_API_could_not_be_found: diag(6386, ts.DiagnosticCategory.Message, "Performance_timings_for_diagnostics_or_extendedDiagnostics_are_not_available_in_this_session_A_nativ_6386", "Performance timings for '--diagnostics' or '--extendedDiagnostics' are not available in this session. A native implementation of the Web Performance API could not be found."), + The_signature_0_of_1_is_deprecated: diag(6387, ts.DiagnosticCategory.Suggestion, "The_signature_0_of_1_is_deprecated_6387", "The signature '{0}' of '{1}' is deprecated.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ undefined, /*reportsDeprecated*/ true), + Project_0_is_being_forcibly_rebuilt: diag(6388, ts.DiagnosticCategory.Message, "Project_0_is_being_forcibly_rebuilt_6388", "Project '{0}' is being forcibly rebuilt"), + Reusing_resolution_of_module_0_from_1_of_old_program_it_was_not_resolved: diag(6389, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_of_old_program_it_was_not_resolved_6389", "Reusing resolution of module '{0}' from '{1}' of old program, it was not resolved."), + Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2: diag(6390, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved__6390", "Reusing resolution of type reference directive '{0}' from '{1}' of old program, it was successfully resolved to '{2}'."), + Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3: diag(6391, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved__6391", "Reusing resolution of type reference directive '{0}' from '{1}' of old program, it was successfully resolved to '{2}' with Package ID '{3}'."), + Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_not_resolved: diag(6392, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_not_resolved_6392", "Reusing resolution of type reference directive '{0}' from '{1}' of old program, it was not resolved."), + Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3: diag(6393, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_6393", "Reusing resolution of module '{0}' from '{1}' found in cache from location '{2}', it was successfully resolved to '{3}'."), + Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4: diag(6394, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_6394", "Reusing resolution of module '{0}' from '{1}' found in cache from location '{2}', it was successfully resolved to '{3}' with Package ID '{4}'."), + Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_not_resolved: diag(6395, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_not_resolved_6395", "Reusing resolution of module '{0}' from '{1}' found in cache from location '{2}', it was not resolved."), + Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3: diag(6396, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_succes_6396", "Reusing resolution of type reference directive '{0}' from '{1}' found in cache from location '{2}', it was successfully resolved to '{3}'."), + Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4: diag(6397, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_succes_6397", "Reusing resolution of type reference directive '{0}' from '{1}' found in cache from location '{2}', it was successfully resolved to '{3}' with Package ID '{4}'."), + Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_not_resolved: diag(6398, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_not_re_6398", "Reusing resolution of type reference directive '{0}' from '{1}' found in cache from location '{2}', it was not resolved."), The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"), The_expected_type_comes_from_this_index_signature: diag(6501, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."), The_expected_type_comes_from_the_return_type_of_this_signature: diag(6502, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_the_return_type_of_this_signature_6502", "The expected type comes from the return type of this signature."), Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing: diag(6503, ts.DiagnosticCategory.Message, "Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing_6503", "Print names of files that are part of the compilation and then stop processing."), File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option: diag(6504, ts.DiagnosticCategory.Error, "File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option_6504", "File '{0}' is a JavaScript file. Did you mean to enable the 'allowJs' option?"), Print_names_of_files_and_the_reason_they_are_part_of_the_compilation: diag(6505, ts.DiagnosticCategory.Message, "Print_names_of_files_and_the_reason_they_are_part_of_the_compilation_6505", "Print names of files and the reason they are part of the compilation."), - Require_undeclared_properties_from_index_signatures_to_use_element_accesses: diag(6803, ts.DiagnosticCategory.Error, "Require_undeclared_properties_from_index_signatures_to_use_element_accesses_6803", "Require undeclared properties from index signatures to use element accesses."), + Consider_adding_a_declare_modifier_to_this_class: diag(6506, ts.DiagnosticCategory.Message, "Consider_adding_a_declare_modifier_to_this_class_6506", "Consider adding a 'declare' modifier to this class."), Include_undefined_in_index_signature_results: diag(6800, ts.DiagnosticCategory.Message, "Include_undefined_in_index_signature_results_6800", "Include 'undefined' in index signature results"), + Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier: diag(6801, ts.DiagnosticCategory.Message, "Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier_6801", "Ensure overriding members in derived classes are marked with an 'override' modifier."), + Require_undeclared_properties_from_index_signatures_to_use_element_accesses: diag(6802, ts.DiagnosticCategory.Message, "Require_undeclared_properties_from_index_signatures_to_use_element_accesses_6802", "Require undeclared properties from index signatures to use element accesses."), + Type_catch_clause_variables_as_unknown_instead_of_any: diag(6803, ts.DiagnosticCategory.Message, "Type_catch_clause_variables_as_unknown_instead_of_any_6803", "Type catch clause variables as 'unknown' instead of 'any'."), Variable_0_implicitly_has_an_1_type: diag(7005, ts.DiagnosticCategory.Error, "Variable_0_implicitly_has_an_1_type_7005", "Variable '{0}' implicitly has an '{1}' type."), Parameter_0_implicitly_has_an_1_type: diag(7006, ts.DiagnosticCategory.Error, "Parameter_0_implicitly_has_an_1_type_7006", "Parameter '{0}' implicitly has an '{1}' type."), Member_0_implicitly_has_an_1_type: diag(7008, ts.DiagnosticCategory.Error, "Member_0_implicitly_has_an_1_type_7008", "Member '{0}' implicitly has an '{1}' type."), @@ -9029,7 +9310,7 @@ var ts; Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for_all_imports_Implies_allowSyntheticDefaultImports: diag(7037, ts.DiagnosticCategory.Message, "Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for__7037", "Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'."), Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead: diag(7038, ts.DiagnosticCategory.Message, "Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cau_7038", "Type originates at this import. A namespace-style import cannot be called or constructed, and will cause a failure at runtime. Consider using a default import or import require here instead."), Mapped_object_type_implicitly_has_an_any_template_type: diag(7039, ts.DiagnosticCategory.Error, "Mapped_object_type_implicitly_has_an_any_template_type_7039", "Mapped object type implicitly has an 'any' template type."), - If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_1: diag(7040, ts.DiagnosticCategory.Error, "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040", "If the '{0}' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}`"), + If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_1: diag(7040, ts.DiagnosticCategory.Error, "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040", "If the '{0}' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}'"), The_containing_arrow_function_captures_the_global_value_of_this: diag(7041, ts.DiagnosticCategory.Error, "The_containing_arrow_function_captures_the_global_value_of_this_7041", "The containing arrow function captures the global value of 'this'."), Module_0_was_resolved_to_1_but_resolveJsonModule_is_not_used: diag(7042, ts.DiagnosticCategory.Error, "Module_0_was_resolved_to_1_but_resolveJsonModule_is_not_used_7042", "Module '{0}' was resolved to '{1}', but '--resolveJsonModule' is not used."), Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage: diag(7043, ts.DiagnosticCategory.Suggestion, "Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7043", "Variable '{0}' implicitly has an '{1}' type, but a better type may be inferred from usage."), @@ -9069,7 +9350,7 @@ var ts; JSDoc_0_is_not_attached_to_a_class: diag(8022, ts.DiagnosticCategory.Error, "JSDoc_0_is_not_attached_to_a_class_8022", "JSDoc '@{0}' is not attached to a class."), JSDoc_0_1_does_not_match_the_extends_2_clause: diag(8023, ts.DiagnosticCategory.Error, "JSDoc_0_1_does_not_match_the_extends_2_clause_8023", "JSDoc '@{0} {1}' does not match the 'extends {2}' clause."), JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name: diag(8024, ts.DiagnosticCategory.Error, "JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_8024", "JSDoc '@param' tag has name '{0}', but there is no parameter with that name."), - Class_declarations_cannot_have_more_than_one_augments_or_extends_tag: diag(8025, ts.DiagnosticCategory.Error, "Class_declarations_cannot_have_more_than_one_augments_or_extends_tag_8025", "Class declarations cannot have more than one `@augments` or `@extends` tag."), + Class_declarations_cannot_have_more_than_one_augments_or_extends_tag: diag(8025, ts.DiagnosticCategory.Error, "Class_declarations_cannot_have_more_than_one_augments_or_extends_tag_8025", "Class declarations cannot have more than one '@augments' or '@extends' tag."), Expected_0_type_arguments_provide_these_with_an_extends_tag: diag(8026, ts.DiagnosticCategory.Error, "Expected_0_type_arguments_provide_these_with_an_extends_tag_8026", "Expected {0} type arguments; provide these with an '@extends' tag."), Expected_0_1_type_arguments_provide_these_with_an_extends_tag: diag(8027, ts.DiagnosticCategory.Error, "Expected_0_1_type_arguments_provide_these_with_an_extends_tag_8027", "Expected {0}-{1} type arguments; provide these with an '@extends' tag."), JSDoc_may_only_appear_in_the_last_parameter_of_a_signature: diag(8028, ts.DiagnosticCategory.Error, "JSDoc_may_only_appear_in_the_last_parameter_of_a_signature_8028", "JSDoc '...' may only appear in the last parameter of a signature."), @@ -9314,6 +9595,11 @@ var ts; Add_all_missing_function_declarations: diag(95157, ts.DiagnosticCategory.Message, "Add_all_missing_function_declarations_95157", "Add all missing function declarations"), Method_not_implemented: diag(95158, ts.DiagnosticCategory.Message, "Method_not_implemented_95158", "Method not implemented."), Function_not_implemented: diag(95159, ts.DiagnosticCategory.Message, "Function_not_implemented_95159", "Function not implemented."), + Add_override_modifier: diag(95160, ts.DiagnosticCategory.Message, "Add_override_modifier_95160", "Add 'override' modifier"), + Remove_override_modifier: diag(95161, ts.DiagnosticCategory.Message, "Remove_override_modifier_95161", "Remove 'override' modifier"), + Add_all_missing_override_modifiers: diag(95162, ts.DiagnosticCategory.Message, "Add_all_missing_override_modifiers_95162", "Add all missing 'override' modifiers"), + Remove_all_unnecessary_override_modifiers: diag(95163, ts.DiagnosticCategory.Message, "Remove_all_unnecessary_override_modifiers_95163", "Remove all unnecessary 'override' modifiers"), + Can_only_convert_named_export: diag(95164, ts.DiagnosticCategory.Message, "Can_only_convert_named_export_95164", "Can only convert named export"), No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, ts.DiagnosticCategory.Error, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."), Classes_may_not_have_a_field_named_constructor: diag(18006, ts.DiagnosticCategory.Error, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."), JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, ts.DiagnosticCategory.Error, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"), @@ -9328,8 +9614,6 @@ var ts; The_shadowing_declaration_of_0_is_defined_here: diag(18017, ts.DiagnosticCategory.Error, "The_shadowing_declaration_of_0_is_defined_here_18017", "The shadowing declaration of '{0}' is defined here"), The_declaration_of_0_that_you_probably_intended_to_use_is_defined_here: diag(18018, ts.DiagnosticCategory.Error, "The_declaration_of_0_that_you_probably_intended_to_use_is_defined_here_18018", "The declaration of '{0}' that you probably intended to use is defined here"), _0_modifier_cannot_be_used_with_a_private_identifier: diag(18019, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_with_a_private_identifier_18019", "'{0}' modifier cannot be used with a private identifier."), - A_method_cannot_be_named_with_a_private_identifier: diag(18022, ts.DiagnosticCategory.Error, "A_method_cannot_be_named_with_a_private_identifier_18022", "A method cannot be named with a private identifier."), - An_accessor_cannot_be_named_with_a_private_identifier: diag(18023, ts.DiagnosticCategory.Error, "An_accessor_cannot_be_named_with_a_private_identifier_18023", "An accessor cannot be named with a private identifier."), An_enum_member_cannot_be_named_with_a_private_identifier: diag(18024, ts.DiagnosticCategory.Error, "An_enum_member_cannot_be_named_with_a_private_identifier_18024", "An enum member cannot be named with a private identifier."), can_only_be_used_at_the_start_of_a_file: diag(18026, ts.DiagnosticCategory.Error, "can_only_be_used_at_the_start_of_a_file_18026", "'#!' can only be used at the start of a file."), Compiler_reserves_name_0_when_emitting_private_identifier_downlevel: diag(18027, ts.DiagnosticCategory.Error, "Compiler_reserves_name_0_when_emitting_private_identifier_downlevel_18027", "Compiler reserves name '{0}' when emitting private identifier downlevel."), @@ -9341,6 +9625,7 @@ var ts; 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: diag(18033, ts.DiagnosticCategory.Error, "Only_numeric_enums_can_have_computed_members_but_this_expression_has_type_0_If_you_do_not_need_exhau_18033", "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."), Specify_the_JSX_fragment_factory_function_to_use_when_targeting_react_JSX_emit_with_jsxFactory_compiler_option_is_specified_e_g_Fragment: diag(18034, ts.DiagnosticCategory.Message, "Specify_the_JSX_fragment_factory_function_to_use_when_targeting_react_JSX_emit_with_jsxFactory_compi_18034", "Specify the JSX fragment factory function to use when targeting 'react' JSX emit with 'jsxFactory' compiler option is specified, e.g. 'Fragment'."), Invalid_value_for_jsxFragmentFactory_0_is_not_a_valid_identifier_or_qualified_name: diag(18035, ts.DiagnosticCategory.Error, "Invalid_value_for_jsxFragmentFactory_0_is_not_a_valid_identifier_or_qualified_name_18035", "Invalid value for 'jsxFragmentFactory'. '{0}' is not a valid identifier or qualified-name."), + Class_decorators_can_t_be_used_with_static_private_identifier_Consider_removing_the_experimental_decorator: diag(18036, ts.DiagnosticCategory.Error, "Class_decorators_can_t_be_used_with_static_private_identifier_Consider_removing_the_experimental_dec_18036", "Class decorators can't be used with static private identifier. Consider removing the experimental decorator."), }; })(ts || (ts = {})); var ts; @@ -9348,7 +9633,7 @@ var ts; var _a; /* @internal */ function tokenIsIdentifierOrKeyword(token) { - return token >= 78 /* Identifier */; + return token >= 79 /* Identifier */; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; /* @internal */ @@ -9357,87 +9642,88 @@ var ts; } ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan; var textToKeywordObj = (_a = { - abstract: 125 /* AbstractKeyword */, - any: 128 /* AnyKeyword */, - as: 126 /* AsKeyword */, - asserts: 127 /* AssertsKeyword */, - bigint: 155 /* BigIntKeyword */, - boolean: 131 /* BooleanKeyword */, - break: 80 /* BreakKeyword */, - case: 81 /* CaseKeyword */, - catch: 82 /* CatchKeyword */, - class: 83 /* ClassKeyword */, - continue: 85 /* ContinueKeyword */, - const: 84 /* ConstKeyword */ + abstract: 126 /* AbstractKeyword */, + any: 129 /* AnyKeyword */, + as: 127 /* AsKeyword */, + asserts: 128 /* AssertsKeyword */, + bigint: 156 /* BigIntKeyword */, + boolean: 132 /* BooleanKeyword */, + break: 81 /* BreakKeyword */, + case: 82 /* CaseKeyword */, + catch: 83 /* CatchKeyword */, + class: 84 /* ClassKeyword */, + continue: 86 /* ContinueKeyword */, + const: 85 /* ConstKeyword */ }, - _a["" + "constructor"] = 132 /* ConstructorKeyword */, - _a.debugger = 86 /* DebuggerKeyword */, - _a.declare = 133 /* DeclareKeyword */, - _a.default = 87 /* DefaultKeyword */, - _a.delete = 88 /* DeleteKeyword */, - _a.do = 89 /* DoKeyword */, - _a.else = 90 /* ElseKeyword */, - _a.enum = 91 /* EnumKeyword */, - _a.export = 92 /* ExportKeyword */, - _a.extends = 93 /* ExtendsKeyword */, - _a.false = 94 /* FalseKeyword */, - _a.finally = 95 /* FinallyKeyword */, - _a.for = 96 /* ForKeyword */, - _a.from = 153 /* FromKeyword */, - _a.function = 97 /* FunctionKeyword */, - _a.get = 134 /* GetKeyword */, - _a.if = 98 /* IfKeyword */, - _a.implements = 116 /* ImplementsKeyword */, - _a.import = 99 /* ImportKeyword */, - _a.in = 100 /* InKeyword */, - _a.infer = 135 /* InferKeyword */, - _a.instanceof = 101 /* InstanceOfKeyword */, - _a.interface = 117 /* InterfaceKeyword */, - _a.intrinsic = 136 /* IntrinsicKeyword */, - _a.is = 137 /* IsKeyword */, - _a.keyof = 138 /* KeyOfKeyword */, - _a.let = 118 /* LetKeyword */, - _a.module = 139 /* ModuleKeyword */, - _a.namespace = 140 /* NamespaceKeyword */, - _a.never = 141 /* NeverKeyword */, - _a.new = 102 /* NewKeyword */, - _a.null = 103 /* NullKeyword */, - _a.number = 144 /* NumberKeyword */, - _a.object = 145 /* ObjectKeyword */, - _a.package = 119 /* PackageKeyword */, - _a.private = 120 /* PrivateKeyword */, - _a.protected = 121 /* ProtectedKeyword */, - _a.public = 122 /* PublicKeyword */, - _a.readonly = 142 /* ReadonlyKeyword */, - _a.require = 143 /* RequireKeyword */, - _a.global = 154 /* GlobalKeyword */, - _a.return = 104 /* ReturnKeyword */, - _a.set = 146 /* SetKeyword */, - _a.static = 123 /* StaticKeyword */, - _a.string = 147 /* StringKeyword */, - _a.super = 105 /* SuperKeyword */, - _a.switch = 106 /* SwitchKeyword */, - _a.symbol = 148 /* SymbolKeyword */, - _a.this = 107 /* ThisKeyword */, - _a.throw = 108 /* ThrowKeyword */, - _a.true = 109 /* TrueKeyword */, - _a.try = 110 /* TryKeyword */, - _a.type = 149 /* TypeKeyword */, - _a.typeof = 111 /* TypeOfKeyword */, - _a.undefined = 150 /* UndefinedKeyword */, - _a.unique = 151 /* UniqueKeyword */, - _a.unknown = 152 /* UnknownKeyword */, - _a.var = 112 /* VarKeyword */, - _a.void = 113 /* VoidKeyword */, - _a.while = 114 /* WhileKeyword */, - _a.with = 115 /* WithKeyword */, - _a.yield = 124 /* YieldKeyword */, - _a.async = 129 /* AsyncKeyword */, - _a.await = 130 /* AwaitKeyword */, - _a.of = 156 /* OfKeyword */, + _a["" + "constructor"] = 133 /* ConstructorKeyword */, + _a.debugger = 87 /* DebuggerKeyword */, + _a.declare = 134 /* 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 = 154 /* FromKeyword */, + _a.function = 98 /* FunctionKeyword */, + _a.get = 135 /* GetKeyword */, + _a.if = 99 /* IfKeyword */, + _a.implements = 117 /* ImplementsKeyword */, + _a.import = 100 /* ImportKeyword */, + _a.in = 101 /* InKeyword */, + _a.infer = 136 /* InferKeyword */, + _a.instanceof = 102 /* InstanceOfKeyword */, + _a.interface = 118 /* InterfaceKeyword */, + _a.intrinsic = 137 /* IntrinsicKeyword */, + _a.is = 138 /* IsKeyword */, + _a.keyof = 139 /* KeyOfKeyword */, + _a.let = 119 /* LetKeyword */, + _a.module = 140 /* ModuleKeyword */, + _a.namespace = 141 /* NamespaceKeyword */, + _a.never = 142 /* NeverKeyword */, + _a.new = 103 /* NewKeyword */, + _a.null = 104 /* NullKeyword */, + _a.number = 145 /* NumberKeyword */, + _a.object = 146 /* ObjectKeyword */, + _a.package = 120 /* PackageKeyword */, + _a.private = 121 /* PrivateKeyword */, + _a.protected = 122 /* ProtectedKeyword */, + _a.public = 123 /* PublicKeyword */, + _a.override = 157 /* OverrideKeyword */, + _a.readonly = 143 /* ReadonlyKeyword */, + _a.require = 144 /* RequireKeyword */, + _a.global = 155 /* GlobalKeyword */, + _a.return = 105 /* ReturnKeyword */, + _a.set = 147 /* SetKeyword */, + _a.static = 124 /* StaticKeyword */, + _a.string = 148 /* StringKeyword */, + _a.super = 106 /* SuperKeyword */, + _a.switch = 107 /* SwitchKeyword */, + _a.symbol = 149 /* SymbolKeyword */, + _a.this = 108 /* ThisKeyword */, + _a.throw = 109 /* ThrowKeyword */, + _a.true = 110 /* TrueKeyword */, + _a.try = 111 /* TryKeyword */, + _a.type = 150 /* TypeKeyword */, + _a.typeof = 112 /* TypeOfKeyword */, + _a.undefined = 151 /* UndefinedKeyword */, + _a.unique = 152 /* UniqueKeyword */, + _a.unknown = 153 /* UnknownKeyword */, + _a.var = 113 /* VarKeyword */, + _a.void = 114 /* VoidKeyword */, + _a.while = 115 /* WhileKeyword */, + _a.with = 116 /* WithKeyword */, + _a.yield = 125 /* YieldKeyword */, + _a.async = 130 /* AsyncKeyword */, + _a.await = 131 /* AwaitKeyword */, + _a.of = 158 /* OfKeyword */, _a); var textToKeyword = new ts.Map(ts.getEntries(textToKeywordObj)); - var textToToken = new ts.Map(ts.getEntries(__assign(__assign({}, 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 */, "=": 62 /* EqualsToken */, "+=": 63 /* PlusEqualsToken */, "-=": 64 /* MinusEqualsToken */, "*=": 65 /* AsteriskEqualsToken */, "**=": 66 /* AsteriskAsteriskEqualsToken */, "/=": 67 /* SlashEqualsToken */, "%=": 68 /* PercentEqualsToken */, "<<=": 69 /* LessThanLessThanEqualsToken */, ">>=": 70 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 72 /* AmpersandEqualsToken */, "|=": 73 /* BarEqualsToken */, "^=": 77 /* CaretEqualsToken */, "||=": 74 /* BarBarEqualsToken */, "&&=": 75 /* AmpersandAmpersandEqualsToken */, "??=": 76 /* QuestionQuestionEqualsToken */, "@": 59 /* AtToken */, "`": 61 /* BacktickToken */ }))); + var textToToken = new ts.Map(ts.getEntries(__assign(__assign({}, 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 */ }))); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers IdentifierStart :: @@ -9493,13 +9779,13 @@ var ts; var unicodeESNextIdentifierStart = [65, 90, 97, 122, 170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 895, 895, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1327, 1329, 1366, 1369, 1369, 1376, 1416, 1488, 1514, 1519, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2144, 2154, 2208, 2228, 2230, 2237, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2432, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2556, 2556, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2809, 2809, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3129, 3133, 3133, 3160, 3162, 3168, 3169, 3200, 3200, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3412, 3414, 3423, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3718, 3722, 3724, 3747, 3749, 3749, 3751, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5109, 5112, 5117, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5880, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6264, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6430, 6480, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7296, 7304, 7312, 7354, 7357, 7359, 7401, 7404, 7406, 7411, 7413, 7414, 7418, 7418, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8472, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12443, 12447, 12449, 12538, 12540, 12543, 12549, 12591, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40943, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42653, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42943, 42946, 42950, 42999, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43261, 43262, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43488, 43492, 43494, 43503, 43514, 43518, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43646, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43824, 43866, 43868, 43879, 43888, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 65536, 65547, 65549, 65574, 65576, 65594, 65596, 65597, 65599, 65613, 65616, 65629, 65664, 65786, 65856, 65908, 66176, 66204, 66208, 66256, 66304, 66335, 66349, 66378, 66384, 66421, 66432, 66461, 66464, 66499, 66504, 66511, 66513, 66517, 66560, 66717, 66736, 66771, 66776, 66811, 66816, 66855, 66864, 66915, 67072, 67382, 67392, 67413, 67424, 67431, 67584, 67589, 67592, 67592, 67594, 67637, 67639, 67640, 67644, 67644, 67647, 67669, 67680, 67702, 67712, 67742, 67808, 67826, 67828, 67829, 67840, 67861, 67872, 67897, 67968, 68023, 68030, 68031, 68096, 68096, 68112, 68115, 68117, 68119, 68121, 68149, 68192, 68220, 68224, 68252, 68288, 68295, 68297, 68324, 68352, 68405, 68416, 68437, 68448, 68466, 68480, 68497, 68608, 68680, 68736, 68786, 68800, 68850, 68864, 68899, 69376, 69404, 69415, 69415, 69424, 69445, 69600, 69622, 69635, 69687, 69763, 69807, 69840, 69864, 69891, 69926, 69956, 69956, 69968, 70002, 70006, 70006, 70019, 70066, 70081, 70084, 70106, 70106, 70108, 70108, 70144, 70161, 70163, 70187, 70272, 70278, 70280, 70280, 70282, 70285, 70287, 70301, 70303, 70312, 70320, 70366, 70405, 70412, 70415, 70416, 70419, 70440, 70442, 70448, 70450, 70451, 70453, 70457, 70461, 70461, 70480, 70480, 70493, 70497, 70656, 70708, 70727, 70730, 70751, 70751, 70784, 70831, 70852, 70853, 70855, 70855, 71040, 71086, 71128, 71131, 71168, 71215, 71236, 71236, 71296, 71338, 71352, 71352, 71424, 71450, 71680, 71723, 71840, 71903, 71935, 71935, 72096, 72103, 72106, 72144, 72161, 72161, 72163, 72163, 72192, 72192, 72203, 72242, 72250, 72250, 72272, 72272, 72284, 72329, 72349, 72349, 72384, 72440, 72704, 72712, 72714, 72750, 72768, 72768, 72818, 72847, 72960, 72966, 72968, 72969, 72971, 73008, 73030, 73030, 73056, 73061, 73063, 73064, 73066, 73097, 73112, 73112, 73440, 73458, 73728, 74649, 74752, 74862, 74880, 75075, 77824, 78894, 82944, 83526, 92160, 92728, 92736, 92766, 92880, 92909, 92928, 92975, 92992, 92995, 93027, 93047, 93053, 93071, 93760, 93823, 93952, 94026, 94032, 94032, 94099, 94111, 94176, 94177, 94179, 94179, 94208, 100343, 100352, 101106, 110592, 110878, 110928, 110930, 110948, 110951, 110960, 111355, 113664, 113770, 113776, 113788, 113792, 113800, 113808, 113817, 119808, 119892, 119894, 119964, 119966, 119967, 119970, 119970, 119973, 119974, 119977, 119980, 119982, 119993, 119995, 119995, 119997, 120003, 120005, 120069, 120071, 120074, 120077, 120084, 120086, 120092, 120094, 120121, 120123, 120126, 120128, 120132, 120134, 120134, 120138, 120144, 120146, 120485, 120488, 120512, 120514, 120538, 120540, 120570, 120572, 120596, 120598, 120628, 120630, 120654, 120656, 120686, 120688, 120712, 120714, 120744, 120746, 120770, 120772, 120779, 123136, 123180, 123191, 123197, 123214, 123214, 123584, 123627, 124928, 125124, 125184, 125251, 125259, 125259, 126464, 126467, 126469, 126495, 126497, 126498, 126500, 126500, 126503, 126503, 126505, 126514, 126516, 126519, 126521, 126521, 126523, 126523, 126530, 126530, 126535, 126535, 126537, 126537, 126539, 126539, 126541, 126543, 126545, 126546, 126548, 126548, 126551, 126551, 126553, 126553, 126555, 126555, 126557, 126557, 126559, 126559, 126561, 126562, 126564, 126564, 126567, 126570, 126572, 126578, 126580, 126583, 126585, 126588, 126590, 126590, 126592, 126601, 126603, 126619, 126625, 126627, 126629, 126633, 126635, 126651, 131072, 173782, 173824, 177972, 177984, 178205, 178208, 183969, 183984, 191456, 194560, 195101]; var unicodeESNextIdentifierPart = [48, 57, 65, 90, 95, 95, 97, 122, 170, 170, 181, 181, 183, 183, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 895, 895, 902, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1327, 1329, 1366, 1369, 1369, 1376, 1416, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1519, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2045, 2045, 2048, 2093, 2112, 2139, 2144, 2154, 2208, 2228, 2230, 2237, 2259, 2273, 2275, 2403, 2406, 2415, 2417, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2556, 2556, 2558, 2558, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2809, 2815, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3072, 3084, 3086, 3088, 3090, 3112, 3114, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3162, 3168, 3171, 3174, 3183, 3200, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3328, 3331, 3333, 3340, 3342, 3344, 3346, 3396, 3398, 3400, 3402, 3406, 3412, 3415, 3423, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3558, 3567, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3718, 3722, 3724, 3747, 3749, 3749, 3751, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4969, 4977, 4992, 5007, 5024, 5109, 5112, 5117, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5880, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6264, 6272, 6314, 6320, 6389, 6400, 6430, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6618, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6832, 6845, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7296, 7304, 7312, 7354, 7357, 7359, 7376, 7378, 7380, 7418, 7424, 7673, 7675, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8472, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12447, 12449, 12538, 12540, 12543, 12549, 12591, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40943, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42737, 42775, 42783, 42786, 42888, 42891, 42943, 42946, 42950, 42999, 43047, 43072, 43123, 43136, 43205, 43216, 43225, 43232, 43255, 43259, 43259, 43261, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43488, 43518, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43824, 43866, 43868, 43879, 43888, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65071, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 65536, 65547, 65549, 65574, 65576, 65594, 65596, 65597, 65599, 65613, 65616, 65629, 65664, 65786, 65856, 65908, 66045, 66045, 66176, 66204, 66208, 66256, 66272, 66272, 66304, 66335, 66349, 66378, 66384, 66426, 66432, 66461, 66464, 66499, 66504, 66511, 66513, 66517, 66560, 66717, 66720, 66729, 66736, 66771, 66776, 66811, 66816, 66855, 66864, 66915, 67072, 67382, 67392, 67413, 67424, 67431, 67584, 67589, 67592, 67592, 67594, 67637, 67639, 67640, 67644, 67644, 67647, 67669, 67680, 67702, 67712, 67742, 67808, 67826, 67828, 67829, 67840, 67861, 67872, 67897, 67968, 68023, 68030, 68031, 68096, 68099, 68101, 68102, 68108, 68115, 68117, 68119, 68121, 68149, 68152, 68154, 68159, 68159, 68192, 68220, 68224, 68252, 68288, 68295, 68297, 68326, 68352, 68405, 68416, 68437, 68448, 68466, 68480, 68497, 68608, 68680, 68736, 68786, 68800, 68850, 68864, 68903, 68912, 68921, 69376, 69404, 69415, 69415, 69424, 69456, 69600, 69622, 69632, 69702, 69734, 69743, 69759, 69818, 69840, 69864, 69872, 69881, 69888, 69940, 69942, 69951, 69956, 69958, 69968, 70003, 70006, 70006, 70016, 70084, 70089, 70092, 70096, 70106, 70108, 70108, 70144, 70161, 70163, 70199, 70206, 70206, 70272, 70278, 70280, 70280, 70282, 70285, 70287, 70301, 70303, 70312, 70320, 70378, 70384, 70393, 70400, 70403, 70405, 70412, 70415, 70416, 70419, 70440, 70442, 70448, 70450, 70451, 70453, 70457, 70459, 70468, 70471, 70472, 70475, 70477, 70480, 70480, 70487, 70487, 70493, 70499, 70502, 70508, 70512, 70516, 70656, 70730, 70736, 70745, 70750, 70751, 70784, 70853, 70855, 70855, 70864, 70873, 71040, 71093, 71096, 71104, 71128, 71133, 71168, 71232, 71236, 71236, 71248, 71257, 71296, 71352, 71360, 71369, 71424, 71450, 71453, 71467, 71472, 71481, 71680, 71738, 71840, 71913, 71935, 71935, 72096, 72103, 72106, 72151, 72154, 72161, 72163, 72164, 72192, 72254, 72263, 72263, 72272, 72345, 72349, 72349, 72384, 72440, 72704, 72712, 72714, 72758, 72760, 72768, 72784, 72793, 72818, 72847, 72850, 72871, 72873, 72886, 72960, 72966, 72968, 72969, 72971, 73014, 73018, 73018, 73020, 73021, 73023, 73031, 73040, 73049, 73056, 73061, 73063, 73064, 73066, 73102, 73104, 73105, 73107, 73112, 73120, 73129, 73440, 73462, 73728, 74649, 74752, 74862, 74880, 75075, 77824, 78894, 82944, 83526, 92160, 92728, 92736, 92766, 92768, 92777, 92880, 92909, 92912, 92916, 92928, 92982, 92992, 92995, 93008, 93017, 93027, 93047, 93053, 93071, 93760, 93823, 93952, 94026, 94031, 94087, 94095, 94111, 94176, 94177, 94179, 94179, 94208, 100343, 100352, 101106, 110592, 110878, 110928, 110930, 110948, 110951, 110960, 111355, 113664, 113770, 113776, 113788, 113792, 113800, 113808, 113817, 113821, 113822, 119141, 119145, 119149, 119154, 119163, 119170, 119173, 119179, 119210, 119213, 119362, 119364, 119808, 119892, 119894, 119964, 119966, 119967, 119970, 119970, 119973, 119974, 119977, 119980, 119982, 119993, 119995, 119995, 119997, 120003, 120005, 120069, 120071, 120074, 120077, 120084, 120086, 120092, 120094, 120121, 120123, 120126, 120128, 120132, 120134, 120134, 120138, 120144, 120146, 120485, 120488, 120512, 120514, 120538, 120540, 120570, 120572, 120596, 120598, 120628, 120630, 120654, 120656, 120686, 120688, 120712, 120714, 120744, 120746, 120770, 120772, 120779, 120782, 120831, 121344, 121398, 121403, 121452, 121461, 121461, 121476, 121476, 121499, 121503, 121505, 121519, 122880, 122886, 122888, 122904, 122907, 122913, 122915, 122916, 122918, 122922, 123136, 123180, 123184, 123197, 123200, 123209, 123214, 123214, 123584, 123641, 124928, 125124, 125136, 125142, 125184, 125259, 125264, 125273, 126464, 126467, 126469, 126495, 126497, 126498, 126500, 126500, 126503, 126503, 126505, 126514, 126516, 126519, 126521, 126521, 126523, 126523, 126530, 126530, 126535, 126535, 126537, 126537, 126539, 126539, 126541, 126543, 126545, 126546, 126548, 126548, 126551, 126551, 126553, 126553, 126555, 126555, 126557, 126557, 126559, 126559, 126561, 126562, 126564, 126564, 126567, 126570, 126572, 126578, 126580, 126583, 126585, 126588, 126590, 126590, 126592, 126601, 126603, 126619, 126625, 126627, 126629, 126633, 126635, 126651, 131072, 173782, 173824, 177972, 177984, 178205, 178208, 183969, 183984, 191456, 194560, 195101, 917760, 917999]; /** - * Test for whether a single line comment's text contains a directive. + * Test for whether a single line comment with leading whitespace trimmed's text contains a directive. */ - var commentDirectiveRegExSingleLine = /^\s*\/\/\/?\s*@(ts-expect-error|ts-ignore)/; + var commentDirectiveRegExSingleLine = /^\/\/\/?\s*@(ts-expect-error|ts-ignore)/; /** - * Test for whether a multi-line comment's last line contains a directive. + * Test for whether a multi-line comment with leading whitespace trimmed's last line contains a directive. */ - var commentDirectiveRegExMultiLine = /^\s*(?:\/|\*)*\s*@(ts-expect-error|ts-ignore)/; + var commentDirectiveRegExMultiLine = /^(?:\/|\*)*\s*@(ts-expect-error|ts-ignore)/; function lookupInUnicodeMap(code, map) { // Bail out quickly if it couldn't possibly be in the map. if (code < map[0]) { @@ -9750,11 +10036,11 @@ var ts; } ts.couldStartTrivia = couldStartTrivia; /* @internal */ - function skipTrivia(text, pos, stopAfterLineBreak, stopAtComments) { - if (stopAtComments === void 0) { stopAtComments = false; } + function skipTrivia(text, pos, stopAfterLineBreak, stopAtComments, inJSDoc) { if (ts.positionIsSynthesized(pos)) { return pos; } + var canConsumeStar = false; // Keep in sync with couldStartTrivia while (true) { var ch = text.charCodeAt(pos); @@ -9769,6 +10055,7 @@ var ts; if (stopAfterLineBreak) { return pos; } + canConsumeStar = !!inJSDoc; continue; case 9 /* tab */: case 11 /* verticalTab */: @@ -9788,6 +10075,7 @@ var ts; } pos++; } + canConsumeStar = false; continue; } if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { @@ -9799,6 +10087,7 @@ var ts; } pos++; } + canConsumeStar = false; continue; } break; @@ -9808,12 +10097,21 @@ var ts; case 62 /* greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos); + canConsumeStar = false; continue; } break; case 35 /* hash */: if (pos === 0 && isShebangTrivia(text, pos)) { pos = scanShebangTrivia(text, pos); + canConsumeStar = false; + continue; + } + break; + case 42 /* asterisk */: + if (canConsumeStar) { + pos++; + canConsumeStar = false; continue; } break; @@ -10101,8 +10399,8 @@ var ts; 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 === 78 /* Identifier */ || token > 115 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 80 /* FirstReservedWord */ && token <= 115 /* LastReservedWord */; }, + 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; }, getCommentDirectives: function () { return commentDirectives; }, getNumericLiteralFlags: function () { return tokenFlags & 1008 /* NumericLiteralFlags */; }, @@ -10117,7 +10415,9 @@ var ts; reScanJsxAttributeValue: reScanJsxAttributeValue, reScanJsxToken: reScanJsxToken, reScanLessThanToken: reScanLessThanToken, + reScanHashToken: reScanHashToken, reScanQuestionToken: reScanQuestionToken, + reScanInvalidIdentifier: reScanInvalidIdentifier, scanJsxToken: scanJsxToken, scanJsDocToken: scanJsDocToken, scan: scan, @@ -10626,7 +10926,7 @@ var ts; } } } - return token = 78 /* Identifier */; + return token = 79 /* Identifier */; } function scanBinaryOrOctalDigits(base) { var value = ""; @@ -10775,19 +11075,19 @@ var ts; return token = scanTemplateAndSetTokenValue(/* isTaggedTemplate */ false); case 37 /* percent */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 68 /* PercentEqualsToken */; + return pos += 2, token = 69 /* 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 = 75 /* AmpersandAmpersandEqualsToken */; + return pos += 3, token = 76 /* AmpersandAmpersandEqualsToken */; } return pos += 2, token = 55 /* AmpersandAmpersandToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 72 /* AmpersandEqualsToken */; + return pos += 2, token = 73 /* AmpersandEqualsToken */; } pos++; return token = 50 /* AmpersandToken */; @@ -10799,11 +11099,11 @@ var ts; return token = 21 /* CloseParenToken */; case 42 /* asterisk */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 65 /* AsteriskEqualsToken */; + return pos += 2, token = 66 /* AsteriskEqualsToken */; } if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 66 /* AsteriskAsteriskEqualsToken */; + return pos += 3, token = 67 /* AsteriskAsteriskEqualsToken */; } return pos += 2, token = 42 /* AsteriskAsteriskToken */; } @@ -10819,7 +11119,7 @@ var ts; return pos += 2, token = 45 /* PlusPlusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 63 /* PlusEqualsToken */; + return pos += 2, token = 64 /* PlusEqualsToken */; } pos++; return token = 39 /* PlusToken */; @@ -10831,7 +11131,7 @@ var ts; return pos += 2, token = 46 /* MinusMinusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 64 /* MinusEqualsToken */; + return pos += 2, token = 65 /* MinusEqualsToken */; } pos++; return token = 40 /* MinusToken */; @@ -10899,7 +11199,7 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 67 /* SlashEqualsToken */; + return pos += 2, token = 68 /* SlashEqualsToken */; } pos++; return token = 43 /* SlashToken */; @@ -10976,7 +11276,7 @@ var ts; } if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 69 /* LessThanLessThanEqualsToken */; + return pos += 3, token = 70 /* LessThanLessThanEqualsToken */; } return pos += 2, token = 47 /* LessThanLessThanToken */; } @@ -11010,7 +11310,7 @@ var ts; return pos += 2, token = 38 /* EqualsGreaterThanToken */; } pos++; - return token = 62 /* EqualsToken */; + return token = 63 /* EqualsToken */; case 62 /* greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -11029,7 +11329,7 @@ var ts; } if (text.charCodeAt(pos + 1) === 63 /* question */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 76 /* QuestionQuestionEqualsToken */; + return pos += 3, token = 77 /* QuestionQuestionEqualsToken */; } return pos += 2, token = 60 /* QuestionQuestionToken */; } @@ -11043,7 +11343,7 @@ var ts; return token = 23 /* CloseBracketToken */; case 94 /* caret */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 77 /* CaretEqualsToken */; + return pos += 2, token = 78 /* CaretEqualsToken */; } pos++; return token = 52 /* CaretToken */; @@ -11062,12 +11362,12 @@ var ts; } if (text.charCodeAt(pos + 1) === 124 /* bar */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 74 /* BarBarEqualsToken */; + return pos += 3, token = 75 /* BarBarEqualsToken */; } return pos += 2, token = 56 /* BarBarToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 73 /* BarEqualsToken */; + return pos += 2, token = 74 /* BarEqualsToken */; } pos++; return token = 51 /* BarToken */; @@ -11105,30 +11405,12 @@ var ts; return token = 0 /* Unknown */; } pos++; - if (isIdentifierStart(ch = text.charCodeAt(pos), languageVersion)) { - pos++; - while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion)) - pos++; - tokenValue = text.substring(tokenPos, pos); - if (ch === 92 /* backslash */) { - tokenValue += scanIdentifierParts(); - } - } - else { - tokenValue = "#"; - error(ts.Diagnostics.Invalid_character); - } - return token = 79 /* PrivateIdentifier */; + scanIdentifier(codePointAt(text, pos), languageVersion); + return token = 80 /* PrivateIdentifier */; default: - if (isIdentifierStart(ch, languageVersion)) { - pos += charSize(ch); - while (pos < end && isIdentifierPart(ch = codePointAt(text, pos), languageVersion)) - pos += charSize(ch); - tokenValue = text.substring(tokenPos, pos); - if (ch === 92 /* backslash */) { - tokenValue += scanIdentifierParts(); - } - return token = getIdentifierToken(); + var identifierKind = scanIdentifier(ch, languageVersion); + if (identifierKind) { + return token = identifierKind; } else if (isWhiteSpaceSingleLine(ch)) { pos += charSize(ch); @@ -11145,17 +11427,42 @@ var ts; } } } + function reScanInvalidIdentifier() { + ts.Debug.assert(token === 0 /* 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 */); + if (identifierKind) { + return token = identifierKind; + } + pos += charSize(ch); + return token; // Still `SyntaKind.Unknown` + } + function scanIdentifier(startCharacter, languageVersion) { + var ch = startCharacter; + if (isIdentifierStart(ch, languageVersion)) { + pos += charSize(ch); + while (pos < end && isIdentifierPart(ch = codePointAt(text, pos), languageVersion)) + pos += charSize(ch); + tokenValue = text.substring(tokenPos, pos); + if (ch === 92 /* 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 = 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + return pos += 3, token = 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */; } return pos += 2, token = 49 /* GreaterThanGreaterThanGreaterThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 70 /* GreaterThanGreaterThanEqualsToken */; + return pos += 2, token = 71 /* GreaterThanGreaterThanEqualsToken */; } pos++; return token = 48 /* GreaterThanGreaterThanToken */; @@ -11168,12 +11475,12 @@ var ts; return token; } function reScanAsteriskEqualsToken() { - ts.Debug.assert(token === 65 /* AsteriskEqualsToken */, "'reScanAsteriskEqualsToken' should only be called on a '*='"); + ts.Debug.assert(token === 66 /* AsteriskEqualsToken */, "'reScanAsteriskEqualsToken' should only be called on a '*='"); pos = tokenPos + 1; - return token = 62 /* EqualsToken */; + return token = 63 /* EqualsToken */; } function reScanSlashToken() { - if (token === 43 /* SlashToken */ || token === 67 /* SlashEqualsToken */) { + if (token === 43 /* SlashToken */ || token === 68 /* SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -11223,7 +11530,7 @@ var ts; return token; } function appendIfCommentDirective(commentDirectives, text, commentDirectiveRegEx, lineStart) { - var type = getDirectiveFromComment(text, commentDirectiveRegEx); + var type = getDirectiveFromComment(ts.trimStringStart(text), commentDirectiveRegEx); if (type === undefined) { return commentDirectives; } @@ -11257,9 +11564,10 @@ var ts; pos = tokenPos; return token = scanTemplateAndSetTokenValue(/* isTaggedTemplate */ true); } - function reScanJsxToken() { + function reScanJsxToken(allowMultilineJsxText) { + if (allowMultilineJsxText === void 0) { allowMultilineJsxText = true; } pos = tokenPos = startPos; - return token = scanJsxToken(); + return token = scanJsxToken(allowMultilineJsxText); } function reScanLessThanToken() { if (token === 47 /* LessThanLessThanToken */) { @@ -11268,12 +11576,20 @@ var ts; } return token; } + function reScanHashToken() { + if (token === 80 /* PrivateIdentifier */) { + pos = tokenPos + 1; + return token = 62 /* HashToken */; + } + return token; + } function reScanQuestionToken() { ts.Debug.assert(token === 60 /* QuestionQuestionToken */, "'reScanQuestionToken' should only be called on a '??'"); pos = tokenPos + 1; return token = 57 /* QuestionToken */; } - function scanJsxToken() { + function scanJsxToken(allowMultilineJsxText) { + if (allowMultilineJsxText === void 0) { allowMultilineJsxText = true; } startPos = tokenPos = pos; if (pos >= end) { return token = 1 /* EndOfFileToken */; @@ -11293,15 +11609,9 @@ var ts; } // First non-whitespace character on this line. var firstNonWhitespace = 0; - var lastNonWhitespace = -1; // These initial values are special because the first line is: // firstNonWhitespace = 0 to indicate that we want leading whitespace, while (pos < end) { - // We want to keep track of the last non-whitespace (but including - // newlines character for hitting the end of the JSX Text region) - if (!isWhiteSpaceSingleLine(char)) { - lastNonWhitespace = pos; - } char = text.charCodeAt(pos); if (char === 123 /* openBrace */) { break; @@ -11319,8 +11629,6 @@ var ts; if (char === 125 /* closeBrace */) { error(ts.Diagnostics.Unexpected_token_Did_you_mean_or_rbrace, pos, 1); } - if (lastNonWhitespace > 0) - lastNonWhitespace++; // FirstNonWhitespace is 0, then we only see whitespaces so far. If we see a linebreak, we want to ignore that whitespaces. // i.e (- : whitespace) //
---- @@ -11330,13 +11638,17 @@ var ts; if (isLineBreak(char) && firstNonWhitespace === 0) { firstNonWhitespace = -1; } + else if (!allowMultilineJsxText && isLineBreak(char) && firstNonWhitespace > 0) { + // Stop JsxText on each line during formatting. This allows the formatter to + // indent each line correctly. + break; + } else if (!isWhiteSpaceLike(char)) { firstNonWhitespace = pos; } pos++; } - var endPosition = lastNonWhitespace === -1 ? pos : lastNonWhitespace; - tokenValue = text.substring(startPos, endPosition); + tokenValue = text.substring(startPos, pos); return firstNonWhitespace === -1 ? 12 /* JsxTextAllWhiteSpaces */ : 11 /* JsxText */; } // Scans a JSX identifier; these differ from normal identifiers in that @@ -11359,6 +11671,7 @@ var ts; tokenValue += ":"; pos++; namespaceSeparator = true; + token = 79 /* Identifier */; // swap from keyword kind to identifier kind continue; } var oldPos = pos; @@ -11433,13 +11746,15 @@ var ts; case 62 /* greaterThan */: return token = 31 /* GreaterThanToken */; case 61 /* equals */: - return token = 62 /* EqualsToken */; + 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 */: pos--; var extendedCookedChar = peekExtendedUnicodeEscape(); @@ -11615,6 +11930,8 @@ var ts; switch (options.target) { case 99 /* ESNext */: return "lib.esnext.full.d.ts"; + case 8 /* ES2021 */: + return "lib.es2021.full.d.ts"; case 7 /* ES2020 */: return "lib.es2020.full.d.ts"; case 6 /* ES2019 */: @@ -11833,9 +12150,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 159 /* TypeParameter */) { + if (d && d.kind === 161 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (isFunctionLike(current) || isClassLike(current) || current.kind === 253 /* InterfaceDeclaration */) { + if (isFunctionLike(current) || isClassLike(current) || current.kind === 255 /* InterfaceDeclaration */) { return current; } } @@ -11843,7 +12160,7 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node, parent) { - return ts.hasSyntacticModifier(node, 92 /* ParameterPropertyModifier */) && parent.kind === 166 /* Constructor */; + return ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */) && parent.kind === 168 /* Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -11873,14 +12190,14 @@ var ts; node = walkUpBindingElementsAndPatterns(node); } var flags = getFlags(node); - if (node.kind === 249 /* VariableDeclaration */) { + if (node.kind === 251 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 250 /* VariableDeclarationList */) { + if (node && node.kind === 252 /* VariableDeclarationList */) { flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 232 /* VariableStatement */) { + if (node && node.kind === 234 /* VariableStatement */) { flags |= getFlags(node); } return flags; @@ -11898,19 +12215,22 @@ var ts; // nodes like variable declarations and binding elements can returned a view of their flags // that includes the modifiers from their container. i.e. flags like export/declare aren't // stored on the variable declaration directly, but on the containing variable statement - // (if it has one). Similarly, flags for let/const are store on the variable declaration + // (if it has one). Similarly, flags for let/const are stored on the variable declaration // list. By calling this function, all those flags are combined so that the client can treat // the node as if it actually had those flags. function getCombinedNodeFlags(node) { return getCombinedFlags(node, function (n) { return n.flags; }); } ts.getCombinedNodeFlags = getCombinedNodeFlags; + /* @internal */ + ts.supportedLocaleDirectories = ["cs", "de", "es", "fr", "it", "ja", "ko", "pl", "pt-br", "ru", "tr", "zh-cn", "zh-tw"]; /** * Checks to see if the locale is in the appropriate format, * and if it is, attempts to set the appropriate language. */ function validateLocaleAndSetLanguage(locale, sys, errors) { - var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase()); + var lowerCaseLocale = locale.toLowerCase(); + var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(lowerCaseLocale); if (!matchResult) { if (errors) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1, "en", "ja-jp")); @@ -11921,7 +12241,7 @@ var ts; var territory = matchResult[3]; // First try the entire locale, then fall back to just language if that's all we have. // Either ways do not fail, and fallback to the English diagnostic strings. - if (!trySetLanguageAndTerritory(language, territory, errors)) { + if (ts.contains(ts.supportedLocaleDirectories, lowerCaseLocale) && !trySetLanguageAndTerritory(language, territory, errors)) { trySetLanguageAndTerritory(language, /*territory*/ undefined, errors); } // Set the UI locale for string collation @@ -12028,7 +12348,7 @@ var ts; } ts.idText = idText; function symbolName(symbol) { - if (symbol.valueDeclaration && isPrivateIdentifierPropertyDeclaration(symbol.valueDeclaration)) { + if (symbol.valueDeclaration && isPrivateIdentifierClassElementDeclaration(symbol.valueDeclaration)) { return idText(symbol.valueDeclaration.name); } return unescapeLeadingUnderscores(symbol.escapedName); @@ -12050,30 +12370,30 @@ var ts; } // Covers remaining cases (returning undefined if none match). switch (hostNode.kind) { - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } break; - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: var expr = hostNode.expression; - if (expr.kind === 216 /* BinaryExpression */ && expr.operatorToken.kind === 62 /* EqualsToken */) { + if (expr.kind === 218 /* BinaryExpression */ && expr.operatorToken.kind === 63 /* EqualsToken */) { expr = expr.left; } switch (expr.kind) { - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return expr.name; - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; } } break; - case 207 /* ParenthesizedExpression */: { + case 209 /* ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 245 /* LabeledStatement */: { + case 247 /* LabeledStatement */: { if (isDeclaration(hostNode.statement) || isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -12108,18 +12428,18 @@ var ts; /** @internal */ function getNonAssignedNameOfDeclaration(declaration) { switch (declaration.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return declaration; - case 333 /* JSDocPropertyTag */: - case 326 /* JSDocParameterTag */: { + case 341 /* JSDocPropertyTag */: + case 334 /* JSDocParameterTag */: { var name = declaration.name; - if (name.kind === 157 /* QualifiedName */) { + if (name.kind === 159 /* QualifiedName */) { return name.right; } break; } - case 203 /* CallExpression */: - case 216 /* BinaryExpression */: { + case 205 /* CallExpression */: + case 218 /* BinaryExpression */: { var expr_1 = declaration; switch (ts.getAssignmentDeclarationKind(expr_1)) { case 1 /* ExportsProperty */: @@ -12135,15 +12455,15 @@ var ts; return undefined; } } - case 331 /* JSDocTypedefTag */: + case 339 /* JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 325 /* JSDocEnumTag */: + case 333 /* JSDocEnumTag */: return nameForNamelessJSDocTypedef(declaration); - case 266 /* ExportAssignment */: { + case 268 /* ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: var expr = declaration; if (ts.isBindableStaticElementAccessExpression(expr)) { return expr.argumentExpression; @@ -12156,7 +12476,7 @@ var ts; if (declaration === undefined) return undefined; return getNonAssignedNameOfDeclaration(declaration) || - (ts.isFunctionExpression(declaration) || ts.isClassExpression(declaration) ? getAssignedName(declaration) : undefined); + (ts.isFunctionExpression(declaration) || ts.isArrowFunction(declaration) || ts.isClassExpression(declaration) ? getAssignedName(declaration) : undefined); } ts.getNameOfDeclaration = getNameOfDeclaration; /*@internal*/ @@ -12309,6 +12629,10 @@ var ts; return getFirstJSDocTag(node, ts.isJSDocReadonlyTag, /*noCache*/ true); } ts.getJSDocReadonlyTagNoCache = getJSDocReadonlyTagNoCache; + function getJSDocOverrideTagNoCache(node) { + return getFirstJSDocTag(node, ts.isJSDocOverrideTag, /*noCache*/ true); + } + ts.getJSDocOverrideTagNoCache = getJSDocOverrideTagNoCache; /** Gets the JSDoc deprecated tag for the node if present */ function getJSDocDeprecatedTag(node) { return getFirstJSDocTag(node, ts.isJSDocDeprecatedTag); @@ -12429,6 +12753,15 @@ var ts; return getJSDocTags(node).filter(function (doc) { return doc.kind === kind; }); } ts.getAllJSDocTagsOfKind = getAllJSDocTagsOfKind; + /** 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) { + // TODO: Other kinds here + return c.kind === 315 /* JSDocText */ ? c.text : "{@link " + (c.name ? ts.entityNameToString(c.name) + " " : "") + c.text + "}"; + }).join(""); + } + ts.getTextOfJSDocComment = getTextOfJSDocComment; /** * Gets the effective type parameters. If the node was parsed in a * JavaScript file, gets the type parameters from the `@template` tag from JSDoc. @@ -12438,7 +12771,7 @@ var ts; return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 311 /* JSDocComment */); + ts.Debug.assert(node.parent.kind === 314 /* JSDocComment */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -12464,13 +12797,13 @@ var ts; } ts.getEffectiveConstraintOfTypeParameter = getEffectiveConstraintOfTypeParameter; // #region - function isIdentifierOrPrivateIdentifier(node) { - return node.kind === 78 /* Identifier */ || node.kind === 79 /* PrivateIdentifier */; + function isMemberName(node) { + return node.kind === 79 /* Identifier */ || node.kind === 80 /* PrivateIdentifier */; } - ts.isIdentifierOrPrivateIdentifier = isIdentifierOrPrivateIdentifier; + ts.isMemberName = isMemberName; /* @internal */ function isGetOrSetAccessorDeclaration(node) { - return node.kind === 168 /* SetAccessor */ || node.kind === 167 /* GetAccessor */; + return node.kind === 170 /* SetAccessor */ || node.kind === 169 /* GetAccessor */; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; function isPropertyAccessChain(node) { @@ -12488,10 +12821,10 @@ var ts; function isOptionalChain(node) { var kind = node.kind; return !!(node.flags & 32 /* OptionalChain */) && - (kind === 201 /* PropertyAccessExpression */ - || kind === 202 /* ElementAccessExpression */ - || kind === 203 /* CallExpression */ - || kind === 225 /* NonNullExpression */); + (kind === 203 /* PropertyAccessExpression */ + || kind === 204 /* ElementAccessExpression */ + || kind === 205 /* CallExpression */ + || kind === 227 /* NonNullExpression */); } ts.isOptionalChain = isOptionalChain; /* @internal */ @@ -12526,7 +12859,7 @@ var ts; } ts.isOutermostOptionalChain = isOutermostOptionalChain; function isNullishCoalesce(node) { - return node.kind === 216 /* BinaryExpression */ && node.operatorToken.kind === 60 /* QuestionQuestionToken */; + return node.kind === 218 /* BinaryExpression */ && node.operatorToken.kind === 60 /* QuestionQuestionToken */; } ts.isNullishCoalesce = isNullishCoalesce; function isConstTypeReference(node) { @@ -12543,17 +12876,17 @@ var ts; } ts.isNonNullChain = isNonNullChain; function isBreakOrContinueStatement(node) { - return node.kind === 241 /* BreakStatement */ || node.kind === 240 /* ContinueStatement */; + return node.kind === 243 /* BreakStatement */ || node.kind === 242 /* ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isNamedExportBindings(node) { - return node.kind === 269 /* NamespaceExport */ || node.kind === 268 /* NamedExports */; + return node.kind === 271 /* NamespaceExport */ || node.kind === 270 /* NamedExports */; } ts.isNamedExportBindings = isNamedExportBindings; function isUnparsedTextLike(node) { switch (node.kind) { - case 294 /* UnparsedText */: - case 295 /* UnparsedInternalText */: + case 296 /* UnparsedText */: + case 297 /* UnparsedInternalText */: return true; default: return false; @@ -12562,12 +12895,12 @@ var ts; ts.isUnparsedTextLike = isUnparsedTextLike; function isUnparsedNode(node) { return isUnparsedTextLike(node) || - node.kind === 292 /* UnparsedPrologue */ || - node.kind === 296 /* UnparsedSyntheticReference */; + node.kind === 294 /* UnparsedPrologue */ || + node.kind === 298 /* UnparsedSyntheticReference */; } ts.isUnparsedNode = isUnparsedNode; function isJSDocPropertyLikeTag(node) { - return node.kind === 333 /* JSDocPropertyTag */ || node.kind === 326 /* JSDocParameterTag */; + return node.kind === 341 /* JSDocPropertyTag */ || node.kind === 334 /* JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; // #endregion @@ -12583,16 +12916,25 @@ var ts; ts.isNode = isNode; /* @internal */ function isNodeKind(kind) { - return kind >= 157 /* FirstNode */; + return kind >= 159 /* FirstNode */; } ts.isNodeKind = isNodeKind; + /** + * True if kind is of some token syntax kind. + * For example, this is true for an IfKeyword but not for an IfStatement. + * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. + */ + function isTokenKind(kind) { + return kind >= 0 /* FirstToken */ && kind <= 158 /* LastToken */; + } + ts.isTokenKind = isTokenKind; /** * True if node is of some token syntax kind. * For example, this is true for an IfKeyword but not for an IfStatement. * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. */ function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 156 /* LastToken */; + return isTokenKind(n.kind); } ts.isToken = isToken; // Node Arrays @@ -12633,13 +12975,13 @@ var ts; ts.isImportOrExportSpecifier = isImportOrExportSpecifier; function isTypeOnlyImportOrExportDeclaration(node) { switch (node.kind) { - case 265 /* ImportSpecifier */: - case 270 /* ExportSpecifier */: + case 267 /* ImportSpecifier */: + case 272 /* ExportSpecifier */: return node.parent.parent.isTypeOnly; - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: return node.parent.isTypeOnly; - case 262 /* ImportClause */: - case 260 /* ImportEqualsDeclaration */: + case 264 /* ImportClause */: + case 262 /* ImportEqualsDeclaration */: return node.isTypeOnly; default: return false; @@ -12658,10 +13000,10 @@ var ts; ts.isGeneratedIdentifier = isGeneratedIdentifier; // Private Identifiers /*@internal*/ - function isPrivateIdentifierPropertyDeclaration(node) { - return ts.isPropertyDeclaration(node) && ts.isPrivateIdentifier(node.name); + function isPrivateIdentifierClassElementDeclaration(node) { + return (ts.isPropertyDeclaration(node) || isMethodOrAccessor(node)) && ts.isPrivateIdentifier(node.name); } - ts.isPrivateIdentifierPropertyDeclaration = isPrivateIdentifierPropertyDeclaration; + ts.isPrivateIdentifierClassElementDeclaration = isPrivateIdentifierClassElementDeclaration; /*@internal*/ function isPrivateIdentifierPropertyAccessExpression(node) { return ts.isPropertyAccessExpression(node) && ts.isPrivateIdentifier(node.name); @@ -12671,17 +13013,18 @@ var ts; /* @internal */ function isModifierKind(token) { switch (token) { - case 125 /* AbstractKeyword */: - case 129 /* AsyncKeyword */: - case 84 /* ConstKeyword */: - case 133 /* DeclareKeyword */: - case 87 /* DefaultKeyword */: - case 92 /* ExportKeyword */: - case 122 /* PublicKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 142 /* ReadonlyKeyword */: - case 123 /* StaticKeyword */: + case 126 /* AbstractKeyword */: + case 130 /* AsyncKeyword */: + case 85 /* ConstKeyword */: + case 134 /* DeclareKeyword */: + case 88 /* DefaultKeyword */: + case 93 /* ExportKeyword */: + case 123 /* PublicKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + case 143 /* ReadonlyKeyword */: + case 124 /* StaticKeyword */: + case 157 /* OverrideKeyword */: return true; } return false; @@ -12689,12 +13032,12 @@ var ts; ts.isModifierKind = isModifierKind; /* @internal */ function isParameterPropertyModifier(kind) { - return !!(ts.modifierToFlag(kind) & 92 /* ParameterPropertyModifier */); + return !!(ts.modifierToFlag(kind) & 16476 /* ParameterPropertyModifier */); } ts.isParameterPropertyModifier = isParameterPropertyModifier; /* @internal */ function isClassMemberModifier(idToken) { - return isParameterPropertyModifier(idToken) || idToken === 123 /* StaticKeyword */; + return isParameterPropertyModifier(idToken) || idToken === 124 /* StaticKeyword */ || idToken === 157 /* OverrideKeyword */; } ts.isClassMemberModifier = isClassMemberModifier; function isModifier(node) { @@ -12703,29 +13046,29 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 157 /* QualifiedName */ - || kind === 78 /* Identifier */; + return kind === 159 /* QualifiedName */ + || kind === 79 /* Identifier */; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 78 /* Identifier */ - || kind === 79 /* PrivateIdentifier */ + return kind === 79 /* Identifier */ + || kind === 80 /* PrivateIdentifier */ || kind === 10 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 158 /* ComputedPropertyName */; + || kind === 160 /* ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; - return kind === 78 /* Identifier */ - || kind === 196 /* ObjectBindingPattern */ - || kind === 197 /* ArrayBindingPattern */; + return kind === 79 /* Identifier */ + || kind === 198 /* ObjectBindingPattern */ + || kind === 199 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions function isFunctionLike(node) { - return node && isFunctionLikeKind(node.kind); + return !!node && isFunctionLikeKind(node.kind); } ts.isFunctionLike = isFunctionLike; /* @internal */ @@ -12735,13 +13078,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 251 /* FunctionDeclaration */: - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 253 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return true; default: return false; @@ -12750,14 +13093,14 @@ var ts; /* @internal */ function isFunctionLikeKind(kind) { switch (kind) { - case 164 /* MethodSignature */: - case 169 /* CallSignature */: - case 313 /* JSDocSignature */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: - case 174 /* FunctionType */: - case 308 /* JSDocFunctionType */: - case 175 /* ConstructorType */: + case 166 /* MethodSignature */: + case 171 /* CallSignature */: + case 317 /* JSDocSignature */: + case 172 /* ConstructSignature */: + case 173 /* IndexSignature */: + case 176 /* FunctionType */: + case 311 /* JSDocFunctionType */: + case 177 /* ConstructorType */: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -12772,29 +13115,29 @@ var ts; // Classes function isClassElement(node) { var kind = node.kind; - return kind === 166 /* Constructor */ - || kind === 163 /* PropertyDeclaration */ - || kind === 165 /* MethodDeclaration */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */ - || kind === 171 /* IndexSignature */ - || kind === 229 /* SemicolonClassElement */; + return kind === 168 /* Constructor */ + || kind === 165 /* PropertyDeclaration */ + || kind === 167 /* MethodDeclaration */ + || kind === 169 /* GetAccessor */ + || kind === 170 /* SetAccessor */ + || kind === 173 /* IndexSignature */ + || kind === 231 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 252 /* ClassDeclaration */ || node.kind === 221 /* ClassExpression */); + return node && (node.kind === 254 /* ClassDeclaration */ || node.kind === 223 /* ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 167 /* GetAccessor */ || node.kind === 168 /* SetAccessor */); + return node && (node.kind === 169 /* GetAccessor */ || node.kind === 170 /* SetAccessor */); } ts.isAccessor = isAccessor; /* @internal */ function isMethodOrAccessor(node) { switch (node.kind) { - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return true; default: return false; @@ -12804,11 +13147,11 @@ var ts; // Type members function isTypeElement(node) { var kind = node.kind; - return kind === 170 /* ConstructSignature */ - || kind === 169 /* CallSignature */ - || kind === 162 /* PropertySignature */ - || kind === 164 /* MethodSignature */ - || kind === 171 /* IndexSignature */; + return kind === 172 /* ConstructSignature */ + || kind === 171 /* CallSignature */ + || kind === 164 /* PropertySignature */ + || kind === 166 /* MethodSignature */ + || kind === 173 /* IndexSignature */; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -12817,12 +13160,12 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 288 /* PropertyAssignment */ - || kind === 289 /* ShorthandPropertyAssignment */ - || kind === 290 /* SpreadAssignment */ - || kind === 165 /* MethodDeclaration */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */; + return kind === 290 /* PropertyAssignment */ + || kind === 291 /* ShorthandPropertyAssignment */ + || kind === 292 /* SpreadAssignment */ + || kind === 167 /* MethodDeclaration */ + || kind === 169 /* GetAccessor */ + || kind === 170 /* SetAccessor */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type @@ -12837,8 +13180,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 174 /* FunctionType */: - case 175 /* ConstructorType */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: return true; } return false; @@ -12849,8 +13192,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 197 /* ArrayBindingPattern */ - || kind === 196 /* ObjectBindingPattern */; + return kind === 199 /* ArrayBindingPattern */ + || kind === 198 /* ObjectBindingPattern */; } return false; } @@ -12858,15 +13201,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 199 /* ArrayLiteralExpression */ - || kind === 200 /* ObjectLiteralExpression */; + return kind === 201 /* ArrayLiteralExpression */ + || kind === 202 /* ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 198 /* BindingElement */ - || kind === 222 /* OmittedExpression */; + return kind === 200 /* BindingElement */ + || kind === 224 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -12875,9 +13218,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 249 /* VariableDeclaration */: - case 160 /* Parameter */: - case 198 /* BindingElement */: + case 251 /* VariableDeclaration */: + case 162 /* Parameter */: + case 200 /* BindingElement */: return true; } return false; @@ -12898,8 +13241,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 196 /* ObjectBindingPattern */: - case 200 /* ObjectLiteralExpression */: + case 198 /* ObjectBindingPattern */: + case 202 /* ObjectLiteralExpression */: return true; } return false; @@ -12911,8 +13254,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 197 /* ArrayBindingPattern */: - case 199 /* ArrayLiteralExpression */: + case 199 /* ArrayBindingPattern */: + case 201 /* ArrayLiteralExpression */: return true; } return false; @@ -12921,26 +13264,26 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 201 /* PropertyAccessExpression */ - || kind === 157 /* QualifiedName */ - || kind === 195 /* ImportType */; + return kind === 203 /* PropertyAccessExpression */ + || kind === 159 /* QualifiedName */ + || kind === 197 /* ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 201 /* PropertyAccessExpression */ - || kind === 157 /* QualifiedName */; + return kind === 203 /* PropertyAccessExpression */ + || kind === 159 /* QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 275 /* JsxOpeningElement */: - case 274 /* JsxSelfClosingElement */: - case 203 /* CallExpression */: - case 204 /* NewExpression */: - case 205 /* TaggedTemplateExpression */: - case 161 /* Decorator */: + case 277 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: + case 207 /* TaggedTemplateExpression */: + case 163 /* Decorator */: return true; default: return false; @@ -12948,12 +13291,12 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 203 /* CallExpression */ || node.kind === 204 /* NewExpression */; + return node.kind === 205 /* CallExpression */ || node.kind === 206 /* NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 218 /* TemplateExpression */ + return kind === 220 /* TemplateExpression */ || kind === 14 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; @@ -12964,34 +13307,34 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: - case 204 /* NewExpression */: - case 203 /* CallExpression */: - case 273 /* JsxElement */: - case 274 /* JsxSelfClosingElement */: - case 277 /* JsxFragment */: - case 205 /* TaggedTemplateExpression */: - case 199 /* ArrayLiteralExpression */: - case 207 /* ParenthesizedExpression */: - case 200 /* ObjectLiteralExpression */: - case 221 /* ClassExpression */: - case 208 /* FunctionExpression */: - case 78 /* Identifier */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: + case 206 /* NewExpression */: + case 205 /* CallExpression */: + case 275 /* JsxElement */: + case 276 /* JsxSelfClosingElement */: + case 279 /* JsxFragment */: + case 207 /* TaggedTemplateExpression */: + case 201 /* ArrayLiteralExpression */: + case 209 /* ParenthesizedExpression */: + case 202 /* ObjectLiteralExpression */: + case 223 /* ClassExpression */: + case 210 /* FunctionExpression */: + case 79 /* Identifier */: case 13 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 218 /* TemplateExpression */: - case 94 /* FalseKeyword */: - case 103 /* NullKeyword */: - case 107 /* ThisKeyword */: - case 109 /* TrueKeyword */: - case 105 /* SuperKeyword */: - case 225 /* NonNullExpression */: - case 226 /* MetaProperty */: - case 99 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression + case 220 /* TemplateExpression */: + case 95 /* FalseKeyword */: + case 104 /* NullKeyword */: + case 108 /* ThisKeyword */: + case 110 /* TrueKeyword */: + case 106 /* SuperKeyword */: + case 227 /* NonNullExpression */: + case 228 /* MetaProperty */: + case 100 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: return false; @@ -13004,13 +13347,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 214 /* PrefixUnaryExpression */: - case 215 /* PostfixUnaryExpression */: - case 210 /* DeleteExpression */: - case 211 /* TypeOfExpression */: - case 212 /* VoidExpression */: - case 213 /* AwaitExpression */: - case 206 /* TypeAssertionExpression */: + case 216 /* PrefixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: + case 212 /* DeleteExpression */: + case 213 /* TypeOfExpression */: + case 214 /* VoidExpression */: + case 215 /* AwaitExpression */: + case 208 /* TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -13019,9 +13362,9 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: return true; - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return expr.operator === 45 /* PlusPlusToken */ || expr.operator === 46 /* MinusMinusToken */; default: @@ -13040,15 +13383,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 217 /* ConditionalExpression */: - case 219 /* YieldExpression */: - case 209 /* ArrowFunction */: - case 216 /* BinaryExpression */: - case 220 /* SpreadElement */: - case 224 /* AsExpression */: - case 222 /* OmittedExpression */: - case 337 /* CommaListExpression */: - case 336 /* PartiallyEmittedExpression */: + case 219 /* ConditionalExpression */: + case 221 /* YieldExpression */: + case 211 /* ArrowFunction */: + case 218 /* BinaryExpression */: + case 222 /* SpreadElement */: + case 226 /* AsExpression */: + case 224 /* OmittedExpression */: + case 345 /* CommaListExpression */: + case 344 /* PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -13056,8 +13399,8 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 206 /* TypeAssertionExpression */ - || kind === 224 /* AsExpression */; + return kind === 208 /* TypeAssertionExpression */ + || kind === 226 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ @@ -13068,13 +13411,13 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: return true; - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -13103,7 +13446,7 @@ var ts; ts.isExternalModuleIndicator = isExternalModuleIndicator; /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 238 /* ForInStatement */ || node.kind === 239 /* ForOfStatement */; + return node.kind === 240 /* ForInStatement */ || node.kind === 241 /* ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -13127,114 +13470,114 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 257 /* ModuleBlock */ - || kind === 256 /* ModuleDeclaration */ - || kind === 78 /* Identifier */; + return kind === 259 /* ModuleBlock */ + || kind === 258 /* ModuleDeclaration */ + || kind === 79 /* Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 257 /* ModuleBlock */ - || kind === 256 /* ModuleDeclaration */; + return kind === 259 /* ModuleBlock */ + || kind === 258 /* ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; - return kind === 78 /* Identifier */ - || kind === 256 /* ModuleDeclaration */; + return kind === 79 /* Identifier */ + || kind === 258 /* ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 264 /* NamedImports */ - || kind === 263 /* NamespaceImport */; + return kind === 266 /* NamedImports */ + || kind === 265 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 256 /* ModuleDeclaration */ || node.kind === 255 /* EnumDeclaration */; + return node.kind === 258 /* ModuleDeclaration */ || node.kind === 257 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 209 /* ArrowFunction */ - || kind === 198 /* BindingElement */ - || kind === 252 /* ClassDeclaration */ - || kind === 221 /* ClassExpression */ - || kind === 166 /* Constructor */ - || kind === 255 /* EnumDeclaration */ - || kind === 291 /* EnumMember */ - || kind === 270 /* ExportSpecifier */ - || kind === 251 /* FunctionDeclaration */ - || kind === 208 /* FunctionExpression */ - || kind === 167 /* GetAccessor */ - || kind === 262 /* ImportClause */ - || kind === 260 /* ImportEqualsDeclaration */ - || kind === 265 /* ImportSpecifier */ - || kind === 253 /* InterfaceDeclaration */ - || kind === 280 /* JsxAttribute */ - || kind === 165 /* MethodDeclaration */ - || kind === 164 /* MethodSignature */ - || kind === 256 /* ModuleDeclaration */ - || kind === 259 /* NamespaceExportDeclaration */ - || kind === 263 /* NamespaceImport */ - || kind === 269 /* NamespaceExport */ - || kind === 160 /* Parameter */ - || kind === 288 /* PropertyAssignment */ - || kind === 163 /* PropertyDeclaration */ - || kind === 162 /* PropertySignature */ - || kind === 168 /* SetAccessor */ - || kind === 289 /* ShorthandPropertyAssignment */ - || kind === 254 /* TypeAliasDeclaration */ - || kind === 159 /* TypeParameter */ - || kind === 249 /* VariableDeclaration */ - || kind === 331 /* JSDocTypedefTag */ - || kind === 324 /* JSDocCallbackTag */ - || kind === 333 /* JSDocPropertyTag */; + return kind === 211 /* ArrowFunction */ + || kind === 200 /* BindingElement */ + || kind === 254 /* ClassDeclaration */ + || kind === 223 /* ClassExpression */ + || kind === 168 /* Constructor */ + || kind === 257 /* EnumDeclaration */ + || kind === 293 /* EnumMember */ + || kind === 272 /* ExportSpecifier */ + || kind === 253 /* FunctionDeclaration */ + || kind === 210 /* FunctionExpression */ + || kind === 169 /* GetAccessor */ + || kind === 264 /* ImportClause */ + || kind === 262 /* ImportEqualsDeclaration */ + || kind === 267 /* ImportSpecifier */ + || kind === 255 /* InterfaceDeclaration */ + || kind === 282 /* JsxAttribute */ + || kind === 167 /* MethodDeclaration */ + || kind === 166 /* MethodSignature */ + || kind === 258 /* ModuleDeclaration */ + || kind === 261 /* NamespaceExportDeclaration */ + || kind === 265 /* NamespaceImport */ + || kind === 271 /* NamespaceExport */ + || kind === 162 /* Parameter */ + || kind === 290 /* PropertyAssignment */ + || kind === 165 /* PropertyDeclaration */ + || kind === 164 /* PropertySignature */ + || kind === 170 /* SetAccessor */ + || kind === 291 /* ShorthandPropertyAssignment */ + || kind === 256 /* TypeAliasDeclaration */ + || kind === 161 /* TypeParameter */ + || kind === 251 /* VariableDeclaration */ + || kind === 339 /* JSDocTypedefTag */ + || kind === 332 /* JSDocCallbackTag */ + || kind === 341 /* JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - return kind === 251 /* FunctionDeclaration */ - || kind === 271 /* MissingDeclaration */ - || kind === 252 /* ClassDeclaration */ - || kind === 253 /* InterfaceDeclaration */ - || kind === 254 /* TypeAliasDeclaration */ - || kind === 255 /* EnumDeclaration */ - || kind === 256 /* ModuleDeclaration */ - || kind === 261 /* ImportDeclaration */ - || kind === 260 /* ImportEqualsDeclaration */ - || kind === 267 /* ExportDeclaration */ - || kind === 266 /* ExportAssignment */ - || kind === 259 /* NamespaceExportDeclaration */; + return kind === 253 /* FunctionDeclaration */ + || kind === 273 /* MissingDeclaration */ + || kind === 254 /* ClassDeclaration */ + || kind === 255 /* InterfaceDeclaration */ + || kind === 256 /* TypeAliasDeclaration */ + || kind === 257 /* EnumDeclaration */ + || kind === 258 /* ModuleDeclaration */ + || kind === 263 /* ImportDeclaration */ + || kind === 262 /* ImportEqualsDeclaration */ + || kind === 269 /* ExportDeclaration */ + || kind === 268 /* ExportAssignment */ + || kind === 261 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 241 /* BreakStatement */ - || kind === 240 /* ContinueStatement */ - || kind === 248 /* DebuggerStatement */ - || kind === 235 /* DoStatement */ - || kind === 233 /* ExpressionStatement */ - || kind === 231 /* EmptyStatement */ - || kind === 238 /* ForInStatement */ - || kind === 239 /* ForOfStatement */ - || kind === 237 /* ForStatement */ - || kind === 234 /* IfStatement */ - || kind === 245 /* LabeledStatement */ - || kind === 242 /* ReturnStatement */ - || kind === 244 /* SwitchStatement */ - || kind === 246 /* ThrowStatement */ - || kind === 247 /* TryStatement */ - || kind === 232 /* VariableStatement */ - || kind === 236 /* WhileStatement */ - || kind === 243 /* WithStatement */ - || kind === 335 /* NotEmittedStatement */ - || kind === 339 /* EndOfDeclarationMarker */ - || kind === 338 /* MergeDeclarationMarker */; + return kind === 243 /* BreakStatement */ + || kind === 242 /* ContinueStatement */ + || kind === 250 /* DebuggerStatement */ + || kind === 237 /* DoStatement */ + || kind === 235 /* ExpressionStatement */ + || kind === 233 /* EmptyStatement */ + || kind === 240 /* ForInStatement */ + || kind === 241 /* ForOfStatement */ + || kind === 239 /* ForStatement */ + || kind === 236 /* IfStatement */ + || kind === 247 /* LabeledStatement */ + || kind === 244 /* ReturnStatement */ + || kind === 246 /* SwitchStatement */ + || kind === 248 /* ThrowStatement */ + || kind === 249 /* TryStatement */ + || kind === 234 /* VariableStatement */ + || kind === 238 /* WhileStatement */ + || kind === 245 /* WithStatement */ + || kind === 343 /* NotEmittedStatement */ + || kind === 347 /* EndOfDeclarationMarker */ + || kind === 346 /* MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { - if (node.kind === 159 /* TypeParameter */) { - return (node.parent && node.parent.kind !== 330 /* JSDocTemplateTag */) || ts.isInJSFile(node); + if (node.kind === 161 /* TypeParameter */) { + return (node.parent && node.parent.kind !== 338 /* JSDocTemplateTag */) || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -13261,10 +13604,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 230 /* Block */) + if (node.kind !== 232 /* Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 247 /* TryStatement */ || node.parent.kind === 287 /* CatchClause */) { + if (node.parent.kind === 249 /* TryStatement */ || node.parent.kind === 289 /* CatchClause */) { return false; } } @@ -13278,88 +13621,94 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 230 /* Block */; + || kind === 232 /* Block */; } ts.isStatementOrBlock = isStatementOrBlock; // Module references /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 272 /* ExternalModuleReference */ - || kind === 157 /* QualifiedName */ - || kind === 78 /* Identifier */; + return kind === 274 /* ExternalModuleReference */ + || kind === 159 /* QualifiedName */ + || kind === 79 /* Identifier */; } ts.isModuleReference = isModuleReference; // JSX /* @internal */ function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 107 /* ThisKeyword */ - || kind === 78 /* Identifier */ - || kind === 201 /* PropertyAccessExpression */; + return kind === 108 /* ThisKeyword */ + || kind === 79 /* Identifier */ + || kind === 203 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 273 /* JsxElement */ - || kind === 283 /* JsxExpression */ - || kind === 274 /* JsxSelfClosingElement */ + return kind === 275 /* JsxElement */ + || kind === 285 /* JsxExpression */ + || kind === 276 /* JsxSelfClosingElement */ || kind === 11 /* JsxText */ - || kind === 277 /* JsxFragment */; + || kind === 279 /* JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 280 /* JsxAttribute */ - || kind === 282 /* JsxSpreadAttribute */; + return kind === 282 /* JsxAttribute */ + || kind === 284 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 10 /* StringLiteral */ - || kind === 283 /* JsxExpression */; + || kind === 285 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 275 /* JsxOpeningElement */ - || kind === 274 /* JsxSelfClosingElement */; + return kind === 277 /* JsxOpeningElement */ + || kind === 276 /* JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 284 /* CaseClause */ - || kind === 285 /* DefaultClause */; + return kind === 286 /* CaseClause */ + || kind === 287 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 301 /* FirstJSDocNode */ && node.kind <= 333 /* LastJSDocNode */; + return node.kind >= 303 /* FirstJSDocNode */ && node.kind <= 341 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 311 /* JSDocComment */ || node.kind === 310 /* JSDocNamepathType */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 314 /* JSDocComment */ + || node.kind === 313 /* JSDocNamepathType */ + || node.kind === 315 /* JSDocText */ + || isJSDocLinkLike(node) + || isJSDocTag(node) + || ts.isJSDocTypeLiteral(node) + || ts.isJSDocSignature(node); } ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode; // TODO: determine what this does before making it public. /* @internal */ function isJSDocTag(node) { - return node.kind >= 314 /* FirstJSDocTagNode */ && node.kind <= 333 /* LastJSDocTagNode */; + return node.kind >= 321 /* FirstJSDocTagNode */ && node.kind <= 341 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 168 /* SetAccessor */; + return node.kind === 170 /* SetAccessor */; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 167 /* GetAccessor */; + return node.kind === 169 /* GetAccessor */; } ts.isGetAccessor = isGetAccessor; /** True if has jsdoc nodes attached to it. */ @@ -13385,13 +13734,13 @@ var ts; /** True if has initializer node attached to it. */ function hasOnlyExpressionInitializer(node) { switch (node.kind) { - case 249 /* VariableDeclaration */: - case 160 /* Parameter */: - case 198 /* BindingElement */: - case 162 /* PropertySignature */: - case 163 /* PropertyDeclaration */: - case 288 /* PropertyAssignment */: - case 291 /* EnumMember */: + case 251 /* VariableDeclaration */: + case 162 /* Parameter */: + case 200 /* BindingElement */: + case 164 /* PropertySignature */: + case 165 /* PropertyDeclaration */: + case 290 /* PropertyAssignment */: + case 293 /* EnumMember */: return true; default: return false; @@ -13399,12 +13748,12 @@ var ts; } ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { - return node.kind === 280 /* JsxAttribute */ || node.kind === 282 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); + return node.kind === 282 /* JsxAttribute */ || node.kind === 284 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); } ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 173 /* TypeReference */ || node.kind === 223 /* ExpressionWithTypeArguments */; + return node.kind === 175 /* TypeReference */ || node.kind === 225 /* ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -13436,6 +13785,10 @@ var ts; return node.kind === 10 /* StringLiteral */ || node.kind === 14 /* NoSubstitutionTemplateLiteral */; } ts.isStringLiteralLike = isStringLiteralLike; + function isJSDocLinkLike(node) { + return node.kind === 318 /* JSDocLink */ || node.kind === 319 /* JSDocLinkCode */ || node.kind === 320 /* JSDocLinkPlain */; + } + ts.isJSDocLinkLike = isJSDocLinkLike; // #endregion })(ts || (ts = {})); /* @internal */ @@ -13520,7 +13873,7 @@ var ts; increaseIndent: ts.noop, decreaseIndent: ts.noop, clear: function () { return str = ""; }, - trackSymbol: ts.noop, + trackSymbol: function () { return false; }, reportInaccessibleThisError: ts.noop, reportInaccessibleUniqueSymbolError: ts.noop, reportPrivateInBaseOfClassExpression: ts.noop, @@ -13532,11 +13885,19 @@ var ts; } ts.changesAffectModuleResolution = changesAffectModuleResolution; function optionsHaveModuleResolutionChanges(oldOptions, newOptions) { - return ts.moduleResolutionOptionDeclarations.some(function (o) { + return optionsHaveChanges(oldOptions, newOptions, ts.moduleResolutionOptionDeclarations); + } + ts.optionsHaveModuleResolutionChanges = optionsHaveModuleResolutionChanges; + function changesAffectingProgramStructure(oldOptions, newOptions) { + return optionsHaveChanges(oldOptions, newOptions, ts.optionsAffectingProgramStructure); + } + ts.changesAffectingProgramStructure = changesAffectingProgramStructure; + function optionsHaveChanges(oldOptions, newOptions, optionDeclarations) { + return oldOptions !== newOptions && optionDeclarations.some(function (o) { return !isJsonEqual(getCompilerOptionValue(oldOptions, o), getCompilerOptionValue(newOptions, o)); }); } - ts.optionsHaveModuleResolutionChanges = optionsHaveModuleResolutionChanges; + ts.optionsHaveChanges = optionsHaveChanges; function forEachAncestor(node, callback) { while (true) { var res = callback(node); @@ -13643,7 +14004,9 @@ var ts; } ts.packageIdToString = packageIdToString; function typeDirectiveIsEqualTo(oldResolution, newResolution) { - return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.primary === newResolution.primary; + return oldResolution.resolvedFileName === newResolution.resolvedFileName + && oldResolution.primary === newResolution.primary + && oldResolution.originalPath === newResolution.originalPath; } ts.typeDirectiveIsEqualTo = typeDirectiveIsEqualTo; function hasChangesInResolutions(names, newResolutions, oldResolutions, comparer) { @@ -13685,7 +14048,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 297 /* SourceFile */) { + while (node && node.kind !== 299 /* SourceFile */) { node = node.parent; } return node; @@ -13693,11 +14056,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 230 /* Block */: - case 258 /* CaseBlock */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: + case 232 /* Block */: + case 260 /* CaseBlock */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: return true; } return false; @@ -13835,10 +14198,10 @@ var ts; commentPos + 2 < commentEnd && text.charCodeAt(commentPos + 2) === 47 /* slash */) { var textSubStr = text.substring(commentPos, commentEnd); - return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) || - textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) || - textSubStr.match(fullTripleSlashReferenceTypeReferenceDirectiveRegEx) || - textSubStr.match(defaultLibReferenceRegEx) ? + return ts.fullTripleSlashReferencePathRegEx.test(textSubStr) || + ts.fullTripleSlashAMDReferencePathRegEx.test(textSubStr) || + fullTripleSlashReferenceTypeReferenceDirectiveRegEx.test(textSubStr) || + defaultLibReferenceRegEx.test(textSubStr) ? true : false; } return false; @@ -13893,10 +14256,12 @@ 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 === 334 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 342 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } - return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); + return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, + /*stopAfterLineBreak*/ false, + /*stopAtComments*/ false, isInJSDoc(node)); } ts.getTokenPosOfNode = getTokenPosOfNode; function getNonDecoratorTokenPosOfNode(node, sourceFile) { @@ -13926,7 +14291,7 @@ var ts; var text = sourceText.substring(includeTrivia ? node.pos : ts.skipTrivia(sourceText, node.pos), node.end); if (isJSDocTypeExpressionOrChild(node)) { // strip space + asterisk at line start - text = text.replace(/(^|\r?\n|\r)\s*\*\s*/g, "$1"); + text = text.split(/\r\n|\n|\r/).map(function (line) { return ts.trimStringStart(line.replace(/^\s*\*/, "")); }).join("\n"); } return text; } @@ -14015,9 +14380,11 @@ var ts; DataView: ["setBigInt64", "setBigUint64", "getBigInt64", "getBigUint64"], RelativeTimeFormat: ["format", "formatToParts", "resolvedOptions"] }, - esnext: { + es2021: { PromiseConstructor: ["any"], - String: ["replaceAll"], + String: ["replaceAll"] + }, + esnext: { NumberFormat: ["formatToParts"] } }; @@ -14110,7 +14477,7 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 249 /* VariableDeclaration */ && node.parent.kind === 287 /* CatchClause */; + return node.kind === 251 /* VariableDeclaration */ && node.parent.kind === 289 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { @@ -14142,11 +14509,11 @@ 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 === 256 /* ModuleDeclaration */ && (!node.body); + return !!node && node.kind === 258 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 297 /* SourceFile */ || - node.kind === 256 /* ModuleDeclaration */ || + return node.kind === 299 /* SourceFile */ || + node.kind === 258 /* ModuleDeclaration */ || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -14163,16 +14530,17 @@ 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 297 /* SourceFile */: + case 299 /* SourceFile */: return ts.isExternalModule(node.parent); - case 257 /* ModuleBlock */: + case 259 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; } ts.isModuleAugmentationExternal = isModuleAugmentationExternal; function getNonAugmentationDeclaration(symbol) { - return ts.find(symbol.declarations, function (d) { return !isExternalModuleAugmentation(d) && !(ts.isModuleDeclaration(d) && isGlobalScopeAugmentation(d)); }); + var _a; + return (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return !isExternalModuleAugmentation(d) && !(ts.isModuleDeclaration(d) && isGlobalScopeAugmentation(d)); }); } ts.getNonAugmentationDeclaration = getNonAugmentationDeclaration; function isEffectiveExternalModule(node, compilerOptions) { @@ -14218,22 +14586,22 @@ var ts; ts.isEffectiveStrictModeSourceFile = isEffectiveStrictModeSourceFile; function isBlockScope(node, parentNode) { switch (node.kind) { - case 297 /* SourceFile */: - case 258 /* CaseBlock */: - case 287 /* CatchClause */: - case 256 /* ModuleDeclaration */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 166 /* Constructor */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 299 /* SourceFile */: + case 260 /* CaseBlock */: + case 289 /* CatchClause */: + case 258 /* ModuleDeclaration */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 168 /* Constructor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return true; - case 230 /* Block */: + case 232 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return !ts.isFunctionLike(parentNode); @@ -14243,9 +14611,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 324 /* JSDocCallbackTag */: - case 331 /* JSDocTypedefTag */: - case 313 /* JSDocSignature */: + case 332 /* JSDocCallbackTag */: + case 339 /* JSDocTypedefTag */: + case 317 /* JSDocSignature */: return true; default: ts.assertType(node); @@ -14255,25 +14623,25 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isDeclarationWithTypeParameterChildren(node) { switch (node.kind) { - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 164 /* MethodSignature */: - case 171 /* IndexSignature */: - case 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 308 /* JSDocFunctionType */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 330 /* JSDocTemplateTag */: - case 251 /* FunctionDeclaration */: - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 166 /* MethodSignature */: + case 173 /* IndexSignature */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: + case 311 /* JSDocFunctionType */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 338 /* JSDocTemplateTag */: + case 253 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return true; default: ts.assertType(node); @@ -14283,8 +14651,8 @@ var ts; ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren; function isAnyImportSyntax(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: - case 260 /* ImportEqualsDeclaration */: + case 263 /* ImportDeclaration */: + case 262 /* ImportEqualsDeclaration */: return true; default: return false; @@ -14293,15 +14661,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: - case 260 /* ImportEqualsDeclaration */: - case 232 /* VariableStatement */: - case 252 /* ClassDeclaration */: - case 251 /* FunctionDeclaration */: - case 256 /* ModuleDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: + case 263 /* ImportDeclaration */: + case 262 /* ImportEqualsDeclaration */: + case 234 /* VariableStatement */: + case 254 /* ClassDeclaration */: + case 253 /* FunctionDeclaration */: + case 258 /* ModuleDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 255 /* InterfaceDeclaration */: + case 257 /* EnumDeclaration */: return true; default: return false; @@ -14334,19 +14702,19 @@ var ts; } ts.getNameFromIndexInfo = getNameFromIndexInfo; function isComputedNonLiteralName(name) { - return name.kind === 158 /* ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression); + return name.kind === 160 /* ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression); } ts.isComputedNonLiteralName = isComputedNonLiteralName; function getTextOfPropertyName(name) { switch (name.kind) { - case 78 /* Identifier */: - case 79 /* PrivateIdentifier */: + case 79 /* Identifier */: + case 80 /* PrivateIdentifier */: return name.escapedText; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: if (isStringOrNumericLiteralLike(name.expression)) return ts.escapeLeadingUnderscores(name.expression.text); return ts.Debug.fail("Text of property name cannot be read from non-literal-valued ComputedPropertyNames"); @@ -14357,20 +14725,22 @@ var ts; ts.getTextOfPropertyName = getTextOfPropertyName; function entityNameToString(name) { switch (name.kind) { - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: return "this"; - case 79 /* PrivateIdentifier */: - case 78 /* Identifier */: + case 80 /* PrivateIdentifier */: + case 79 /* Identifier */: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 157 /* QualifiedName */: + case 159 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 201 /* PropertyAccessExpression */: + case 203 /* 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 305 /* JSDocMemberName */: + return entityNameToString(name.left) + entityNameToString(name.right); default: return ts.Debug.assertNever(name); } @@ -14450,7 +14820,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 230 /* Block */) { + if (node.body && node.body.kind === 232 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -14464,7 +14834,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 297 /* SourceFile */: + case 299 /* 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 @@ -14473,28 +14843,28 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 249 /* VariableDeclaration */: - case 198 /* BindingElement */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 256 /* ModuleDeclaration */: - case 255 /* EnumDeclaration */: - case 291 /* EnumMember */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 254 /* TypeAliasDeclaration */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 251 /* VariableDeclaration */: + case 200 /* BindingElement */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: + case 258 /* ModuleDeclaration */: + case 257 /* EnumDeclaration */: + case 293 /* EnumMember */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 256 /* TypeAliasDeclaration */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: errorNode = node.name; break; - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); - case 284 /* CaseClause */: - case 285 /* DefaultClause */: + case 286 /* CaseClause */: + case 287 /* 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); @@ -14546,16 +14916,16 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 203 /* CallExpression */ && n.expression.kind === 105 /* SuperKeyword */; + return n.kind === 205 /* CallExpression */ && n.expression.kind === 106 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 203 /* CallExpression */ && n.expression.kind === 99 /* ImportKeyword */; + return n.kind === 205 /* CallExpression */ && n.expression.kind === 100 /* ImportKeyword */; } ts.isImportCall = isImportCall; function isImportMeta(n) { return ts.isMetaProperty(n) - && n.keywordToken === 99 /* ImportKeyword */ + && n.keywordToken === 100 /* ImportKeyword */ && n.name.escapedText === "meta"; } ts.isImportMeta = isImportMeta; @@ -14564,7 +14934,7 @@ var ts; } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 233 /* ExpressionStatement */ + return node.kind === 235 /* ExpressionStatement */ && node.expression.kind === 10 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; @@ -14592,11 +14962,12 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 160 /* Parameter */ || - node.kind === 159 /* TypeParameter */ || - node.kind === 208 /* FunctionExpression */ || - node.kind === 209 /* ArrowFunction */ || - node.kind === 207 /* ParenthesizedExpression */) ? + var commentRanges = (node.kind === 162 /* Parameter */ || + node.kind === 161 /* TypeParameter */ || + node.kind === 210 /* FunctionExpression */ || + node.kind === 211 /* ArrowFunction */ || + node.kind === 209 /* ParenthesizedExpression */ || + node.kind === 251 /* VariableDeclaration */) ? 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 '/**/' @@ -14607,53 +14978,53 @@ var ts; }); } ts.getJSDocCommentRanges = getJSDocCommentRanges; - ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; - var fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; - ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; - var defaultLibReferenceRegEx = /^(\/\/\/\s*/; + ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; + var fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; + ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; + var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (172 /* FirstTypeNode */ <= node.kind && node.kind <= 195 /* LastTypeNode */) { + if (174 /* FirstTypeNode */ <= node.kind && node.kind <= 197 /* LastTypeNode */) { return true; } switch (node.kind) { - case 128 /* AnyKeyword */: - case 152 /* UnknownKeyword */: - case 144 /* NumberKeyword */: - case 155 /* BigIntKeyword */: - case 147 /* StringKeyword */: - case 131 /* BooleanKeyword */: - case 148 /* SymbolKeyword */: - case 145 /* ObjectKeyword */: - case 150 /* UndefinedKeyword */: - case 141 /* NeverKeyword */: + case 129 /* AnyKeyword */: + case 153 /* UnknownKeyword */: + case 145 /* NumberKeyword */: + case 156 /* BigIntKeyword */: + case 148 /* StringKeyword */: + case 132 /* BooleanKeyword */: + case 149 /* SymbolKeyword */: + case 146 /* ObjectKeyword */: + case 151 /* UndefinedKeyword */: + case 142 /* NeverKeyword */: return true; - case 113 /* VoidKeyword */: - return node.parent.kind !== 212 /* VoidExpression */; - case 223 /* ExpressionWithTypeArguments */: + case 114 /* VoidKeyword */: + return node.parent.kind !== 214 /* VoidExpression */; + case 225 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 159 /* TypeParameter */: - return node.parent.kind === 190 /* MappedType */ || node.parent.kind === 185 /* InferType */; + case 161 /* TypeParameter */: + return node.parent.kind === 192 /* MappedType */ || node.parent.kind === 187 /* InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container - case 78 /* Identifier */: + case 79 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 157 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 159 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 201 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 203 /* 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 === 78 /* Identifier */ || node.kind === 157 /* QualifiedName */ || node.kind === 201 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 79 /* Identifier */ || node.kind === 159 /* QualifiedName */ || node.kind === 203 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through - case 157 /* QualifiedName */: - case 201 /* PropertyAccessExpression */: - case 107 /* ThisKeyword */: { + case 159 /* QualifiedName */: + case 203 /* PropertyAccessExpression */: + case 108 /* ThisKeyword */: { var parent = node.parent; - if (parent.kind === 176 /* TypeQuery */) { + if (parent.kind === 178 /* TypeQuery */) { return false; } - if (parent.kind === 195 /* ImportType */) { + if (parent.kind === 197 /* ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -14662,40 +15033,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 (172 /* FirstTypeNode */ <= parent.kind && parent.kind <= 195 /* LastTypeNode */) { + if (174 /* FirstTypeNode */ <= parent.kind && parent.kind <= 197 /* LastTypeNode */) { return true; } switch (parent.kind) { - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 159 /* TypeParameter */: + case 161 /* TypeParameter */: return node === parent.constraint; - case 330 /* JSDocTemplateTag */: + case 338 /* JSDocTemplateTag */: return node === parent.constraint; - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 160 /* Parameter */: - case 249 /* VariableDeclaration */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 162 /* Parameter */: + case 251 /* VariableDeclaration */: return node === parent.type; - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 166 /* Constructor */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 168 /* Constructor */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return node === parent.type; - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 173 /* IndexSignature */: return node === parent.type; - case 206 /* TypeAssertionExpression */: + case 208 /* TypeAssertionExpression */: return node === parent.type; - case 203 /* CallExpression */: - case 204 /* NewExpression */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: return ts.contains(parent.typeArguments, node); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -14720,23 +15091,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: return visitor(node); - case 258 /* CaseBlock */: - case 230 /* Block */: - case 234 /* IfStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 243 /* WithStatement */: - case 244 /* SwitchStatement */: - case 284 /* CaseClause */: - case 285 /* DefaultClause */: - case 245 /* LabeledStatement */: - case 247 /* TryStatement */: - case 287 /* CatchClause */: + case 260 /* CaseBlock */: + case 232 /* Block */: + case 236 /* IfStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 245 /* WithStatement */: + case 246 /* SwitchStatement */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: + case 247 /* LabeledStatement */: + case 249 /* TryStatement */: + case 289 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -14746,23 +15117,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 255 /* EnumDeclaration */: - case 253 /* InterfaceDeclaration */: - case 256 /* ModuleDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 257 /* EnumDeclaration */: + case 255 /* InterfaceDeclaration */: + case 258 /* ModuleDeclaration */: + case 256 /* 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 === 158 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 160 /* 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); @@ -14785,10 +15156,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 178 /* ArrayType */) { + if (node && node.kind === 180 /* ArrayType */) { return node.elementType; } - else if (node && node.kind === 173 /* TypeReference */) { + else if (node && node.kind === 175 /* TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -14798,12 +15169,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 253 /* InterfaceDeclaration */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 177 /* TypeLiteral */: + case 255 /* InterfaceDeclaration */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 179 /* TypeLiteral */: return node.members; - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return node.properties; } } @@ -14811,14 +15182,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 198 /* BindingElement */: - case 291 /* EnumMember */: - case 160 /* Parameter */: - case 288 /* PropertyAssignment */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 289 /* ShorthandPropertyAssignment */: - case 249 /* VariableDeclaration */: + case 200 /* BindingElement */: + case 293 /* EnumMember */: + case 162 /* Parameter */: + case 290 /* PropertyAssignment */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 291 /* ShorthandPropertyAssignment */: + case 251 /* VariableDeclaration */: return true; } } @@ -14830,8 +15201,8 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 250 /* VariableDeclarationList */ - && node.parent.parent.kind === 232 /* VariableStatement */; + return node.parent.kind === 252 /* VariableDeclarationList */ + && node.parent.parent.kind === 234 /* VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { @@ -14842,13 +15213,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: return true; } return false; @@ -14859,7 +15230,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 245 /* LabeledStatement */) { + if (node.statement.kind !== 247 /* LabeledStatement */) { return node.statement; } node = node.statement; @@ -14867,17 +15238,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 230 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 232 /* Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 165 /* MethodDeclaration */ && node.parent.kind === 200 /* ObjectLiteralExpression */; + return node && node.kind === 167 /* MethodDeclaration */ && node.parent.kind === 202 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 165 /* MethodDeclaration */ && - (node.parent.kind === 200 /* ObjectLiteralExpression */ || - node.parent.kind === 221 /* ClassExpression */); + return node.kind === 167 /* MethodDeclaration */ && + (node.parent.kind === 202 /* ObjectLiteralExpression */ || + node.parent.kind === 223 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -14890,7 +15261,7 @@ var ts; ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 288 /* PropertyAssignment */) { + if (property.kind === 290 /* PropertyAssignment */) { var propName = getTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -14939,14 +15310,14 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 297 /* SourceFile */); + ts.Debug.assert(node.kind !== 299 /* 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 158 /* ComputedPropertyName */: + case 160 /* 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 @@ -14961,9 +15332,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 161 /* Decorator */: + case 163 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 160 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 162 /* 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; @@ -14974,26 +15345,26 @@ var ts; node = node.parent; } break; - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 256 /* ModuleDeclaration */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: - case 255 /* EnumDeclaration */: - case 297 /* SourceFile */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 258 /* ModuleDeclaration */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 173 /* IndexSignature */: + case 257 /* EnumDeclaration */: + case 299 /* SourceFile */: return node; } } @@ -15012,9 +15383,9 @@ var ts; var container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { switch (container.kind) { - case 166 /* Constructor */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: + case 168 /* Constructor */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: return container; } } @@ -15036,27 +15407,27 @@ var ts; return node; } switch (node.kind) { - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: node = node.parent; break; - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: if (!stopOnFunctions) { continue; } // falls through - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return node; - case 161 /* Decorator */: + case 163 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 160 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 162 /* 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; @@ -15072,21 +15443,21 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 208 /* FunctionExpression */ || func.kind === 209 /* ArrowFunction */) { + if (func.kind === 210 /* FunctionExpression */ || func.kind === 211 /* ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 207 /* ParenthesizedExpression */) { + while (parent.kind === 209 /* ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 203 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 205 /* CallExpression */ && parent.expression === prev) { return parent; } } } ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperOrSuperProperty(node) { - return node.kind === 105 /* SuperKeyword */ + return node.kind === 106 /* SuperKeyword */ || isSuperProperty(node); } ts.isSuperOrSuperProperty = isSuperOrSuperProperty; @@ -15095,8 +15466,8 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 201 /* PropertyAccessExpression */ || kind === 202 /* ElementAccessExpression */) - && node.expression.kind === 105 /* SuperKeyword */; + return (kind === 203 /* PropertyAccessExpression */ || kind === 204 /* ElementAccessExpression */) + && node.expression.kind === 106 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; /** @@ -15104,26 +15475,34 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 201 /* PropertyAccessExpression */ || kind === 202 /* ElementAccessExpression */) - && node.expression.kind === 107 /* ThisKeyword */; + return (kind === 203 /* PropertyAccessExpression */ || kind === 204 /* ElementAccessExpression */) + && node.expression.kind === 108 /* 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) === 107 /* ThisKeyword */; + return !!node && ts.isVariableDeclaration(node) && ((_a = node.initializer) === null || _a === void 0 ? void 0 : _a.kind) === 108 /* 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 */; + } + ts.isThisInitializedObjectBindingExpression = isThisInitializedObjectBindingExpression; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 173 /* TypeReference */: + case 175 /* TypeReference */: return node.typeName; - case 223 /* ExpressionWithTypeArguments */: + case 225 /* 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 78 /* Identifier */: - case 157 /* QualifiedName */: + case 79 /* Identifier */: + case 159 /* QualifiedName */: return node; } return undefined; @@ -15131,10 +15510,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return node.tag; - case 275 /* JsxOpeningElement */: - case 274 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -15147,25 +15526,25 @@ var ts; return false; } switch (node.kind) { - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: // classes are valid targets return true; - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 252 /* ClassDeclaration */; - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 165 /* MethodDeclaration */: + return parent.kind === 254 /* ClassDeclaration */; + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 167 /* 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 === 252 /* ClassDeclaration */; - case 160 /* Parameter */: + && parent.kind === 254 /* ClassDeclaration */; + case 162 /* 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 === 166 /* Constructor */ - || parent.kind === 165 /* MethodDeclaration */ - || parent.kind === 168 /* SetAccessor */) - && grandparent.kind === 252 /* ClassDeclaration */; + && (parent.kind === 168 /* Constructor */ + || parent.kind === 167 /* MethodDeclaration */ + || parent.kind === 170 /* SetAccessor */) + && grandparent.kind === 254 /* ClassDeclaration */; } return false; } @@ -15181,10 +15560,10 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 - case 165 /* MethodDeclaration */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 170 /* SetAccessor */: return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); // TODO: GH#18217 default: return false; @@ -15193,9 +15572,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 275 /* JsxOpeningElement */ || - parent.kind === 274 /* JsxSelfClosingElement */ || - parent.kind === 276 /* JsxClosingElement */) { + if (parent.kind === 277 /* JsxOpeningElement */ || + parent.kind === 276 /* JsxSelfClosingElement */ || + parent.kind === 278 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -15203,49 +15582,54 @@ var ts; ts.isJSXTagName = isJSXTagName; function isExpressionNode(node) { switch (node.kind) { - case 105 /* SuperKeyword */: - case 103 /* NullKeyword */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: + case 106 /* SuperKeyword */: + case 104 /* NullKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: case 13 /* RegularExpressionLiteral */: - case 199 /* ArrayLiteralExpression */: - case 200 /* ObjectLiteralExpression */: - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: - case 203 /* CallExpression */: - case 204 /* NewExpression */: - case 205 /* TaggedTemplateExpression */: - case 224 /* AsExpression */: - case 206 /* TypeAssertionExpression */: - case 225 /* NonNullExpression */: - case 207 /* ParenthesizedExpression */: - case 208 /* FunctionExpression */: - case 221 /* ClassExpression */: - case 209 /* ArrowFunction */: - case 212 /* VoidExpression */: - case 210 /* DeleteExpression */: - case 211 /* TypeOfExpression */: - case 214 /* PrefixUnaryExpression */: - case 215 /* PostfixUnaryExpression */: - case 216 /* BinaryExpression */: - case 217 /* ConditionalExpression */: - case 220 /* SpreadElement */: - case 218 /* TemplateExpression */: - case 222 /* OmittedExpression */: - case 273 /* JsxElement */: - case 274 /* JsxSelfClosingElement */: - case 277 /* JsxFragment */: - case 219 /* YieldExpression */: - case 213 /* AwaitExpression */: - case 226 /* MetaProperty */: + case 201 /* ArrayLiteralExpression */: + case 202 /* ObjectLiteralExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: + case 207 /* TaggedTemplateExpression */: + case 226 /* AsExpression */: + case 208 /* TypeAssertionExpression */: + case 227 /* NonNullExpression */: + case 209 /* ParenthesizedExpression */: + case 210 /* FunctionExpression */: + case 223 /* ClassExpression */: + case 211 /* ArrowFunction */: + case 214 /* VoidExpression */: + case 212 /* DeleteExpression */: + case 213 /* TypeOfExpression */: + case 216 /* PrefixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: + case 218 /* BinaryExpression */: + case 219 /* ConditionalExpression */: + case 222 /* SpreadElement */: + case 220 /* TemplateExpression */: + case 224 /* OmittedExpression */: + case 275 /* JsxElement */: + case 276 /* JsxSelfClosingElement */: + case 279 /* JsxFragment */: + case 221 /* YieldExpression */: + case 215 /* AwaitExpression */: + case 228 /* MetaProperty */: return true; - case 157 /* QualifiedName */: - while (node.parent.kind === 157 /* QualifiedName */) { + case 159 /* QualifiedName */: + while (node.parent.kind === 159 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 176 /* TypeQuery */ || isJSXTagName(node); - case 78 /* Identifier */: - if (node.parent.kind === 176 /* TypeQuery */ || isJSXTagName(node)) { + return node.parent.kind === 178 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); + case 305 /* JSDocMemberName */: + while (ts.isJSDocMemberName(node.parent)) { + node = node.parent; + } + return node.parent.kind === 178 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); + case 79 /* Identifier */: + if (node.parent.kind === 178 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node)) { return true; } // falls through @@ -15253,7 +15637,7 @@ var ts; case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: return isInExpressionContext(node); default: return false; @@ -15263,49 +15647,49 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 249 /* VariableDeclaration */: - case 160 /* Parameter */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 291 /* EnumMember */: - case 288 /* PropertyAssignment */: - case 198 /* BindingElement */: + case 251 /* VariableDeclaration */: + case 162 /* Parameter */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 293 /* EnumMember */: + case 290 /* PropertyAssignment */: + case 200 /* BindingElement */: return parent.initializer === node; - case 233 /* ExpressionStatement */: - case 234 /* IfStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: - case 242 /* ReturnStatement */: - case 243 /* WithStatement */: - case 244 /* SwitchStatement */: - case 284 /* CaseClause */: - case 246 /* ThrowStatement */: + case 235 /* ExpressionStatement */: + case 236 /* IfStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: + case 244 /* ReturnStatement */: + case 245 /* WithStatement */: + case 246 /* SwitchStatement */: + case 286 /* CaseClause */: + case 248 /* ThrowStatement */: return parent.expression === node; - case 237 /* ForStatement */: + case 239 /* ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 250 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 252 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 250 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 252 /* VariableDeclarationList */) || forInStatement.expression === node; - case 206 /* TypeAssertionExpression */: - case 224 /* AsExpression */: + case 208 /* TypeAssertionExpression */: + case 226 /* AsExpression */: return node === parent.expression; - case 228 /* TemplateSpan */: + case 230 /* TemplateSpan */: return node === parent.expression; - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return node === parent.expression; - case 161 /* Decorator */: - case 283 /* JsxExpression */: - case 282 /* JsxSpreadAttribute */: - case 290 /* SpreadAssignment */: + case 163 /* Decorator */: + case 285 /* JsxExpression */: + case 284 /* JsxSpreadAttribute */: + case 292 /* SpreadAssignment */: return true; - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return parent.objectAssignmentInitializer === node; default: return isExpressionNode(parent); @@ -15313,14 +15697,18 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isPartOfTypeQuery(node) { - while (node.kind === 157 /* QualifiedName */ || node.kind === 78 /* Identifier */) { + while (node.kind === 159 /* QualifiedName */ || node.kind === 79 /* Identifier */) { node = node.parent; } - return node.kind === 176 /* TypeQuery */; + return node.kind === 178 /* TypeQuery */; } ts.isPartOfTypeQuery = isPartOfTypeQuery; + function isNamespaceReexportDeclaration(node) { + return ts.isNamespaceExport(node) && !!node.parent.moduleSpecifier; + } + ts.isNamespaceReexportDeclaration = isNamespaceReexportDeclaration; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 260 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 272 /* ExternalModuleReference */; + return node.kind === 262 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 274 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -15329,12 +15717,11 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function getExternalModuleRequireArgument(node) { - return isRequireVariableDeclaration(node, /*requireStringLiteralLikeArgument*/ true) - && getLeftmostAccessExpression(node.initializer).arguments[0]; + return isRequireVariableDeclaration(node) && getLeftmostAccessExpression(node.initializer).arguments[0]; } ts.getExternalModuleRequireArgument = getExternalModuleRequireArgument; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 260 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 272 /* ExternalModuleReference */; + return node.kind === 262 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 274 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJS(file) { @@ -15366,15 +15753,15 @@ var ts; ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && node.typeArguments && node.typeArguments.length === 2 && - (node.typeArguments[0].kind === 147 /* StringKeyword */ || node.typeArguments[0].kind === 144 /* NumberKeyword */); + (node.typeArguments[0].kind === 148 /* StringKeyword */ || node.typeArguments[0].kind === 145 /* NumberKeyword */); } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, requireStringLiteralLikeArgument) { - if (callExpression.kind !== 203 /* CallExpression */) { + if (callExpression.kind !== 205 /* CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; - if (expression.kind !== 78 /* Identifier */ || expression.escapedText !== "require") { + if (expression.kind !== 79 /* Identifier */ || expression.escapedText !== "require") { return false; } if (args.length !== 1) { @@ -15384,18 +15771,21 @@ var ts; return !requireStringLiteralLikeArgument || ts.isStringLiteralLike(arg); } ts.isRequireCall = isRequireCall; - function isRequireVariableDeclaration(node, requireStringLiteralLikeArgument) { - if (node.kind === 198 /* BindingElement */) { + /** + * Returns true if the node is a VariableDeclaration initialized to a require call (see `isRequireCall`). + * This function does not test if the node is in a JavaScript file or not. + */ + function isRequireVariableDeclaration(node) { + if (node.kind === 200 /* BindingElement */) { node = node.parent.parent; } - return ts.isVariableDeclaration(node) && !!node.initializer && isRequireCall(getLeftmostAccessExpression(node.initializer), requireStringLiteralLikeArgument); + return ts.isVariableDeclaration(node) && !!node.initializer && isRequireCall(getLeftmostAccessExpression(node.initializer), /*requireStringLiteralLikeArgument*/ true); } ts.isRequireVariableDeclaration = isRequireVariableDeclaration; - function isRequireVariableStatement(node, requireStringLiteralLikeArgument) { - if (requireStringLiteralLikeArgument === void 0) { requireStringLiteralLikeArgument = true; } + function isRequireVariableStatement(node) { return ts.isVariableStatement(node) && node.declarationList.declarations.length > 0 - && ts.every(node.declarationList.declarations, function (decl) { return isRequireVariableDeclaration(decl, requireStringLiteralLikeArgument); }); + && ts.every(node.declarationList.declarations, function (decl) { return isRequireVariableDeclaration(decl); }); } ts.isRequireVariableStatement = isRequireVariableStatement; function isSingleOrDoubleQuote(charCode) { @@ -15441,7 +15831,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 === 62 /* EqualsToken */) { + if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* EqualsToken */) { var isPrototypeAssignment = isPrototypeAccess(node.parent.left); return getExpandoInitializer(node.parent.right, isPrototypeAssignment) || getDefaultedExpandoInitializer(node.parent.left, node.parent.right, isPrototypeAssignment); @@ -15467,11 +15857,11 @@ var ts; function getExpandoInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 208 /* FunctionExpression */ || e.kind === 209 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 210 /* FunctionExpression */ || e.kind === 211 /* ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 208 /* FunctionExpression */ || - initializer.kind === 221 /* ClassExpression */ || - initializer.kind === 209 /* ArrowFunction */) { + if (initializer.kind === 210 /* FunctionExpression */ || + initializer.kind === 223 /* ClassExpression */ || + initializer.kind === 211 /* ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -15497,7 +15887,7 @@ var ts; } function isDefaultedExpandoInitializer(node) { var name = ts.isVariableDeclaration(node.parent) ? node.parent.name : - ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 /* EqualsToken */ ? node.parent.left : + ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* EqualsToken */ ? node.parent.left : undefined; return name && getExpandoInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left); } @@ -15506,7 +15896,7 @@ var ts; 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 === 62 /* EqualsToken */ && ts.isIdentifier(parent.left)) { + if (parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isIdentifier(parent.left)) { return parent.left; } } @@ -15529,7 +15919,7 @@ var ts; return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(initializer); } if (ts.isIdentifier(name) && isLiteralLikeAccess(initializer) && - (initializer.expression.kind === 107 /* ThisKeyword */ || + (initializer.expression.kind === 108 /* ThisKeyword */ || ts.isIdentifier(initializer.expression) && (initializer.expression.escapedText === "window" || initializer.expression.escapedText === "self" || @@ -15592,20 +15982,19 @@ var ts; ts.isLiteralLikeAccess = isLiteralLikeAccess; /** x[0] OR x['a'] OR x[Symbol.y] */ function isLiteralLikeElementAccess(node) { - return ts.isElementAccessExpression(node) && (isStringOrNumericLiteralLike(node.argumentExpression) || - isWellKnownSymbolSyntactically(node.argumentExpression)); + return ts.isElementAccessExpression(node) && isStringOrNumericLiteralLike(node.argumentExpression); } ts.isLiteralLikeElementAccess = isLiteralLikeElementAccess; /** Any series of property and element accesses. */ function isBindableStaticAccessExpression(node, excludeThisKeyword) { - return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 107 /* ThisKeyword */ || ts.isIdentifier(node.name) && isBindableStaticNameExpression(node.expression, /*excludeThisKeyword*/ true)) + return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 108 /* 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 === 107 /* ThisKeyword */) || + && ((!excludeThisKeyword && node.expression.kind === 108 /* ThisKeyword */) || isEntityNameExpression(node.expression) || isBindableStaticAccessExpression(node.expression, /*excludeThisKeyword*/ true)); } @@ -15635,7 +16024,7 @@ var ts; } return 7 /* ObjectDefinePropertyValue */; } - if (expr.operatorToken.kind !== 62 /* EqualsToken */ || !isAccessExpression(expr.left) || isVoidZero(getRightMostAssignedExpression(expr))) { + if (expr.operatorToken.kind !== 63 /* EqualsToken */ || !isAccessExpression(expr.left) || isVoidZero(getRightMostAssignedExpression(expr))) { return 0 /* None */; } if (isBindableStaticNameExpression(expr.left.expression, /*excludeThisKeyword*/ true) && getElementOrPropertyAccessName(expr.left) === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { @@ -15673,14 +16062,11 @@ var ts; return ts.escapeLeadingUnderscores(name.text); } } - if (ts.isElementAccessExpression(node) && isWellKnownSymbolSyntactically(node.argumentExpression)) { - return getPropertyNameForKnownSymbolName(ts.idText(node.argumentExpression.name)); - } return undefined; } ts.getElementOrPropertyAccessName = getElementOrPropertyAccessName; function getAssignmentDeclarationPropertyAccessKind(lhs) { - if (lhs.expression.kind === 107 /* ThisKeyword */) { + if (lhs.expression.kind === 108 /* ThisKeyword */) { return 4 /* ThisProperty */; } else if (isModuleExportsAccessExpression(lhs)) { @@ -15725,7 +16111,7 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJSFile(expr) && - expr.parent && expr.parent.kind === 233 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 235 /* ExpressionStatement */ && (!ts.isElementAccessExpression(expr) || isLiteralLikeElementAccess(expr)) && !!ts.getJSDocTypeTag(expr.parent); } @@ -15746,23 +16132,37 @@ var ts; return false; } var decl = symbol.valueDeclaration; - return decl.kind === 251 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); + return decl.kind === 253 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); } ts.isFunctionSymbol = isFunctionSymbol; + function tryGetModuleSpecifierFromDeclaration(node) { + var _a, _b, _c; + switch (node.kind) { + case 251 /* VariableDeclaration */: + return node.initializer.arguments[0].text; + case 263 /* ImportDeclaration */: + return (_a = ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike)) === null || _a === void 0 ? void 0 : _a.text; + case 262 /* ImportEqualsDeclaration */: + return (_c = ts.tryCast((_b = ts.tryCast(node.moduleReference, ts.isExternalModuleReference)) === null || _b === void 0 ? void 0 : _b.expression, ts.isStringLiteralLike)) === null || _c === void 0 ? void 0 : _c.text; + default: + ts.Debug.assertNever(node); + } + } + ts.tryGetModuleSpecifierFromDeclaration = tryGetModuleSpecifierFromDeclaration; function importFromModuleSpecifier(node) { return tryGetImportFromModuleSpecifier(node) || ts.Debug.failBadSyntaxKind(node.parent); } ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 261 /* ImportDeclaration */: - case 267 /* ExportDeclaration */: + case 263 /* ImportDeclaration */: + case 269 /* ExportDeclaration */: return node.parent; - case 272 /* ExternalModuleReference */: + case 274 /* ExternalModuleReference */: return node.parent.parent; - case 203 /* CallExpression */: + case 205 /* CallExpression */: return isImportCall(node.parent) || isRequireCall(node.parent, /*checkArg*/ false) ? node.parent : undefined; - case 191 /* LiteralType */: + case 193 /* LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -15772,15 +16172,17 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: - case 267 /* ExportDeclaration */: + case 263 /* ImportDeclaration */: + case 269 /* ExportDeclaration */: return node.moduleSpecifier; - case 260 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 272 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 195 /* ImportType */: + case 262 /* ImportEqualsDeclaration */: + return node.moduleReference.kind === 274 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 197 /* ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; - case 203 /* CallExpression */: + case 205 /* CallExpression */: return node.arguments[0]; + case 258 /* ModuleDeclaration */: + return node.name.kind === 10 /* StringLiteral */ ? node.name : undefined; default: return ts.Debug.assertNever(node); } @@ -15788,11 +16190,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return node; - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: return node.exportClause && ts.tryCast(node.exportClause, ts.isNamespaceExport); default: return ts.Debug.assertNever(node); @@ -15800,7 +16202,7 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 261 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 263 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function forEachImportClauseDeclaration(node, action) { @@ -15821,13 +16223,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 160 /* Parameter */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 289 /* ShorthandPropertyAssignment */: - case 288 /* PropertyAssignment */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 162 /* Parameter */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 291 /* ShorthandPropertyAssignment */: + case 290 /* PropertyAssignment */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -15841,7 +16243,7 @@ var ts; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 331 /* JSDocTypedefTag */ || node.kind === 324 /* JSDocCallbackTag */ || node.kind === 325 /* JSDocEnumTag */; + return node.kind === 339 /* JSDocTypedefTag */ || node.kind === 332 /* JSDocCallbackTag */ || node.kind === 333 /* JSDocEnumTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -15851,7 +16253,7 @@ var ts; function getSourceOfAssignment(node) { return ts.isExpressionStatement(node) && ts.isBinaryExpression(node.expression) && - node.expression.operatorToken.kind === 62 /* EqualsToken */ + node.expression.operatorToken.kind === 63 /* EqualsToken */ ? getRightMostAssignedExpression(node.expression) : undefined; } @@ -15866,12 +16268,12 @@ var ts; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return node.initializer; - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: return node.initializer; } } @@ -15883,7 +16285,7 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 256 /* ModuleDeclaration */ + node.body.kind === 258 /* ModuleDeclaration */ ? node.body : undefined; } @@ -15898,11 +16300,11 @@ var ts; if (ts.hasJSDocNodes(node)) { result = ts.append(result, ts.last(node.jsDoc)); } - if (node.kind === 160 /* Parameter */) { + if (node.kind === 162 /* Parameter */) { result = ts.addRange(result, (noCache ? ts.getJSDocParameterTagsNoCache : ts.getJSDocParameterTags)(node)); break; } - if (node.kind === 159 /* TypeParameter */) { + if (node.kind === 161 /* TypeParameter */) { result = ts.addRange(result, (noCache ? ts.getJSDocTypeParameterTagsNoCache : ts.getJSDocTypeParameterTags)(node)); break; } @@ -15913,12 +16315,13 @@ var ts; ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; function getNextJSDocCommentLocation(node) { var parent = node.parent; - if (parent.kind === 288 /* PropertyAssignment */ || - parent.kind === 266 /* ExportAssignment */ || - parent.kind === 163 /* PropertyDeclaration */ || - parent.kind === 233 /* ExpressionStatement */ && node.kind === 201 /* PropertyAccessExpression */ || + if (parent.kind === 290 /* PropertyAssignment */ || + parent.kind === 268 /* ExportAssignment */ || + parent.kind === 165 /* PropertyDeclaration */ || + parent.kind === 235 /* ExpressionStatement */ && node.kind === 203 /* PropertyAccessExpression */ || + parent.kind === 244 /* ReturnStatement */ || getNestedModuleDeclaration(parent) || - ts.isBinaryExpression(node) && node.operatorToken.kind === 62 /* EqualsToken */) { + ts.isBinaryExpression(node) && node.operatorToken.kind === 63 /* EqualsToken */) { return parent; } // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. @@ -15929,7 +16332,7 @@ var ts; // var x = function(name) { return name.length; } else if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node || - ts.isBinaryExpression(parent) && parent.operatorToken.kind === 62 /* EqualsToken */)) { + ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */)) { return parent.parent; } else if (parent.parent && parent.parent.parent && @@ -15953,7 +16356,7 @@ var ts; if (!decl) { return undefined; } - var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 78 /* Identifier */ && p.name.escapedText === name; }); + var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 79 /* Identifier */ && p.name.escapedText === name; }); return parameter && parameter.symbol; } ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc; @@ -16003,7 +16406,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 === 309 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 312 /* JSDocVariadicType */; } ts.isRestParameter = isRestParameter; function hasTypeArguments(node) { @@ -16020,31 +16423,34 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 62 /* EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* Definite */ : 2 /* Compound */ : + binaryOperator === 63 /* EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; - case 214 /* PrefixUnaryExpression */: - case 215 /* PostfixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; return unaryOperator === 45 /* PlusPlusToken */ || unaryOperator === 46 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 207 /* ParenthesizedExpression */: - case 199 /* ArrayLiteralExpression */: - case 220 /* SpreadElement */: - case 225 /* NonNullExpression */: + case 209 /* ParenthesizedExpression */: + case 201 /* ArrayLiteralExpression */: + case 222 /* SpreadElement */: + case 227 /* NonNullExpression */: node = parent; break; - case 289 /* ShorthandPropertyAssignment */: + case 292 /* SpreadAssignment */: + node = parent.parent; + break; + case 291 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } node = parent.parent; break; - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: if (parent.name === node) { return 0 /* None */; } @@ -16071,22 +16477,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 230 /* Block */: - case 232 /* VariableStatement */: - case 243 /* WithStatement */: - case 234 /* IfStatement */: - case 244 /* SwitchStatement */: - case 258 /* CaseBlock */: - case 284 /* CaseClause */: - case 285 /* DefaultClause */: - case 245 /* LabeledStatement */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: - case 247 /* TryStatement */: - case 287 /* CatchClause */: + case 232 /* Block */: + case 234 /* VariableStatement */: + case 245 /* WithStatement */: + case 236 /* IfStatement */: + case 246 /* SwitchStatement */: + case 260 /* CaseBlock */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: + case 247 /* LabeledStatement */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: + case 249 /* TryStatement */: + case 289 /* CatchClause */: return true; } return false; @@ -16103,11 +16509,11 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 186 /* ParenthesizedType */); + return walkUp(node, 188 /* ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 207 /* ParenthesizedExpression */); + return walkUp(node, 209 /* ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; /** @@ -16117,7 +16523,7 @@ var ts; */ function walkUpParenthesizedTypesAndGetParentAndChild(node) { var child; - while (node && node.kind === 186 /* ParenthesizedType */) { + while (node && node.kind === 188 /* ParenthesizedType */) { child = node; node = node.parent; } @@ -16128,19 +16534,13 @@ var ts; return ts.skipOuterExpressions(node, 1 /* Parentheses */); } ts.skipParentheses = skipParentheses; - function skipParenthesesUp(node) { - while (node.kind === 207 /* ParenthesizedExpression */) { - node = node.parent; - } - return node; - } // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped function isDeleteTarget(node) { - if (node.kind !== 201 /* PropertyAccessExpression */ && node.kind !== 202 /* ElementAccessExpression */) { + if (node.kind !== 203 /* PropertyAccessExpression */ && node.kind !== 204 /* ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 210 /* DeleteExpression */; + return node && node.kind === 212 /* DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -16167,7 +16567,7 @@ var ts; if (ts.isComputedPropertyName(parent)) return parent.parent; // falls through - case 78 /* Identifier */: + case 79 /* Identifier */: if (ts.isDeclaration(parent)) { return parent.name === name ? parent : undefined; } @@ -16184,7 +16584,7 @@ var ts; ? binExp : undefined; } - case 79 /* PrivateIdentifier */: + case 80 /* PrivateIdentifier */: return ts.isDeclaration(parent) && parent.name === name ? parent : undefined; default: return undefined; @@ -16193,7 +16593,7 @@ var ts; ts.getDeclarationFromName = getDeclarationFromName; function isLiteralComputedPropertyDeclarationName(node) { return isStringOrNumericLiteralLike(node) && - node.parent.kind === 158 /* ComputedPropertyName */ && + node.parent.kind === 160 /* ComputedPropertyName */ && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -16201,26 +16601,26 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 291 /* EnumMember */: - case 288 /* PropertyAssignment */: - case 201 /* PropertyAccessExpression */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 293 /* EnumMember */: + case 290 /* PropertyAssignment */: + case 203 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 157 /* QualifiedName */: + case 159 /* QualifiedName */: // Name on right hand side of dot in a type query or type reference return parent.right === node; - case 198 /* BindingElement */: - case 265 /* ImportSpecifier */: + case 200 /* BindingElement */: + case 267 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 270 /* ExportSpecifier */: - case 280 /* JsxAttribute */: + case 272 /* ExportSpecifier */: + case 282 /* JsxAttribute */: // Any name in an export specifier or JSX Attribute return true; } @@ -16240,33 +16640,33 @@ var ts; // {} // {name: } function isAliasSymbolDeclaration(node) { - return node.kind === 260 /* ImportEqualsDeclaration */ || - node.kind === 259 /* NamespaceExportDeclaration */ || - node.kind === 262 /* ImportClause */ && !!node.name || - node.kind === 263 /* NamespaceImport */ || - node.kind === 269 /* NamespaceExport */ || - node.kind === 265 /* ImportSpecifier */ || - node.kind === 270 /* ExportSpecifier */ || - node.kind === 266 /* ExportAssignment */ && exportAssignmentIsAlias(node) || + return node.kind === 262 /* ImportEqualsDeclaration */ || + node.kind === 261 /* NamespaceExportDeclaration */ || + node.kind === 264 /* ImportClause */ && !!node.name || + node.kind === 265 /* NamespaceImport */ || + node.kind === 271 /* NamespaceExport */ || + node.kind === 267 /* ImportSpecifier */ || + node.kind === 272 /* ExportSpecifier */ || + node.kind === 268 /* ExportAssignment */ && exportAssignmentIsAlias(node) || ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) || - ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62 /* EqualsToken */ && isAliasableExpression(node.parent.right) || - node.kind === 289 /* ShorthandPropertyAssignment */ || - node.kind === 288 /* PropertyAssignment */ && isAliasableExpression(node.initializer); + ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* EqualsToken */ && isAliasableExpression(node.parent.right) || + node.kind === 291 /* ShorthandPropertyAssignment */ || + node.kind === 290 /* PropertyAssignment */ && isAliasableExpression(node.initializer); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getAliasDeclarationFromName(node) { switch (node.parent.kind) { - case 262 /* ImportClause */: - case 265 /* ImportSpecifier */: - case 263 /* NamespaceImport */: - case 270 /* ExportSpecifier */: - case 266 /* ExportAssignment */: - case 260 /* ImportEqualsDeclaration */: + case 264 /* ImportClause */: + case 267 /* ImportSpecifier */: + case 265 /* NamespaceImport */: + case 272 /* ExportSpecifier */: + case 268 /* ExportAssignment */: + case 262 /* ImportEqualsDeclaration */: return node.parent; - case 157 /* QualifiedName */: + case 159 /* QualifiedName */: do { node = node.parent; - } while (node.parent.kind === 157 /* QualifiedName */); + } while (node.parent.kind === 159 /* QualifiedName */); return getAliasDeclarationFromName(node); } } @@ -16285,7 +16685,7 @@ var ts; } ts.getExportAssignmentExpression = getExportAssignmentExpression; function getPropertyAssignmentAliasLikeExpression(node) { - return node.kind === 289 /* ShorthandPropertyAssignment */ ? node.name : node.kind === 288 /* PropertyAssignment */ ? node.initializer : + return node.kind === 291 /* ShorthandPropertyAssignment */ ? node.name : node.kind === 290 /* PropertyAssignment */ ? node.initializer : node.parent.right; } ts.getPropertyAssignmentAliasLikeExpression = getPropertyAssignmentAliasLikeExpression; @@ -16302,7 +16702,7 @@ var ts; } ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode; function getClassExtendsHeritageElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 93 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 94 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement; @@ -16311,7 +16711,7 @@ var ts; return ts.getJSDocImplementsTags(node).map(function (n) { return n.class; }); } else { - var heritageClause = getHeritageClause(node.heritageClauses, 116 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 117 /* ImplementsKeyword */); return heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.types; } } @@ -16324,7 +16724,7 @@ var ts; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 93 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 94 /* ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -16351,11 +16751,11 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 80 /* FirstKeyword */ <= token && token <= 156 /* LastKeyword */; + return 81 /* FirstKeyword */ <= token && token <= 158 /* LastKeyword */; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 125 /* FirstContextualKeyword */ <= token && token <= 156 /* LastContextualKeyword */; + return 126 /* FirstContextualKeyword */ <= token && token <= 158 /* LastContextualKeyword */; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { @@ -16363,7 +16763,7 @@ var ts; } ts.isNonContextualKeyword = isNonContextualKeyword; function isFutureReservedKeyword(token) { - return 116 /* FirstFutureReservedWord */ <= token && token <= 124 /* LastFutureReservedWord */; + return 117 /* FirstFutureReservedWord */ <= token && token <= 125 /* LastFutureReservedWord */; } ts.isFutureReservedKeyword = isFutureReservedKeyword; function isStringANonContextualKeyword(name) { @@ -16399,14 +16799,14 @@ var ts; } var flags = 0 /* Normal */; switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 165 /* MethodDeclaration */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 167 /* MethodDeclaration */: if (node.asteriskToken) { flags |= 1 /* Generator */; } // falls through - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: if (hasSyntacticModifier(node, 256 /* Async */)) { flags |= 2 /* Async */; } @@ -16420,10 +16820,10 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 167 /* MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined && hasSyntacticModifier(node, 256 /* Async */); @@ -16446,9 +16846,6 @@ var ts; * 3. The computed name is *not* expressed as a NumericLiteral. * 4. The computed name is *not* expressed as a PlusToken or MinusToken * immediately followed by a NumericLiteral. - * 5. The computed name is *not* expressed as `Symbol.`, where `` - * is a property of the Symbol constructor that denotes a built-in - * Symbol. */ function hasDynamicName(declaration) { var name = ts.getNameOfDeclaration(declaration); @@ -16456,38 +16853,25 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - if (!(name.kind === 158 /* ComputedPropertyName */ || name.kind === 202 /* ElementAccessExpression */)) { + if (!(name.kind === 160 /* ComputedPropertyName */ || name.kind === 204 /* ElementAccessExpression */)) { return false; } var expr = ts.isElementAccessExpression(name) ? skipParentheses(name.argumentExpression) : name.expression; return !isStringOrNumericLiteralLike(expr) && - !isSignedNumericLiteral(expr) && - !isWellKnownSymbolSyntactically(expr); + !isSignedNumericLiteral(expr); } ts.isDynamicName = isDynamicName; - /** - * Checks if the expression is of the form: - * Symbol.name - * where Symbol is literally the word "Symbol", and name is any identifierName - */ - function isWellKnownSymbolSyntactically(node) { - return ts.isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression); - } - ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { switch (name.kind) { - case 78 /* Identifier */: - case 79 /* PrivateIdentifier */: + case 79 /* Identifier */: + case 80 /* PrivateIdentifier */: return name.escapedText; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: var nameExpression = name.expression; - if (isWellKnownSymbolSyntactically(nameExpression)) { - return getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); - } - else if (isStringOrNumericLiteralLike(nameExpression)) { + if (isStringOrNumericLiteralLike(nameExpression)) { return ts.escapeLeadingUnderscores(nameExpression.text); } else if (isSignedNumericLiteral(nameExpression)) { @@ -16504,7 +16888,7 @@ var ts; ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; function isPropertyNameLiteral(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: @@ -16515,21 +16899,17 @@ var ts; } ts.isPropertyNameLiteral = isPropertyNameLiteral; function getTextOfIdentifierOrLiteral(node) { - return ts.isIdentifierOrPrivateIdentifier(node) ? ts.idText(node) : node.text; + return ts.isMemberName(node) ? ts.idText(node) : node.text; } ts.getTextOfIdentifierOrLiteral = getTextOfIdentifierOrLiteral; function getEscapedTextOfIdentifierOrLiteral(node) { - return ts.isIdentifierOrPrivateIdentifier(node) ? node.escapedText : ts.escapeLeadingUnderscores(node.text); + return ts.isMemberName(node) ? node.escapedText : ts.escapeLeadingUnderscores(node.text); } ts.getEscapedTextOfIdentifierOrLiteral = getEscapedTextOfIdentifierOrLiteral; function getPropertyNameForUniqueESSymbol(symbol) { return "__@" + ts.getSymbolId(symbol) + "@" + symbol.escapedName; } ts.getPropertyNameForUniqueESSymbol = getPropertyNameForUniqueESSymbol; - function getPropertyNameForKnownSymbolName(symbolName) { - return "__@" + symbolName; - } - ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; function getSymbolNameForPrivateIdentifier(containingClassSymbol, description) { return "__#" + ts.getSymbolId(containingClassSymbol) + "@" + description; } @@ -16542,7 +16922,7 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 78 /* Identifier */ && node.escapedText === "Symbol"; + return node.kind === 79 /* Identifier */ && node.escapedText === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isPushOrUnshiftIdentifier(node) { @@ -16551,11 +16931,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 160 /* Parameter */; + return root.kind === 162 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 198 /* BindingElement */) { + while (node.kind === 200 /* BindingElement */) { node = node.parent.parent; } return node; @@ -16563,15 +16943,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 166 /* Constructor */ - || kind === 208 /* FunctionExpression */ - || kind === 251 /* FunctionDeclaration */ - || kind === 209 /* ArrowFunction */ - || kind === 165 /* MethodDeclaration */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */ - || kind === 256 /* ModuleDeclaration */ - || kind === 297 /* SourceFile */; + return kind === 168 /* Constructor */ + || kind === 210 /* FunctionExpression */ + || kind === 253 /* FunctionDeclaration */ + || kind === 211 /* ArrowFunction */ + || kind === 167 /* MethodDeclaration */ + || kind === 169 /* GetAccessor */ + || kind === 170 /* SetAccessor */ + || kind === 258 /* ModuleDeclaration */ + || kind === 299 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -16590,41 +16970,41 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 204 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 206 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 204 /* NewExpression */: + case 206 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 214 /* PrefixUnaryExpression */: - case 211 /* TypeOfExpression */: - case 212 /* VoidExpression */: - case 210 /* DeleteExpression */: - case 213 /* AwaitExpression */: - case 217 /* ConditionalExpression */: - case 219 /* YieldExpression */: + case 216 /* PrefixUnaryExpression */: + case 213 /* TypeOfExpression */: + case 214 /* VoidExpression */: + case 212 /* DeleteExpression */: + case 215 /* AwaitExpression */: + case 219 /* ConditionalExpression */: + case 221 /* YieldExpression */: return 1 /* Right */; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: switch (operator) { case 42 /* AsteriskAsteriskToken */: - case 62 /* EqualsToken */: - case 63 /* PlusEqualsToken */: - case 64 /* MinusEqualsToken */: - case 66 /* AsteriskAsteriskEqualsToken */: - case 65 /* AsteriskEqualsToken */: - case 67 /* SlashEqualsToken */: - case 68 /* PercentEqualsToken */: - case 69 /* LessThanLessThanEqualsToken */: - case 70 /* GreaterThanGreaterThanEqualsToken */: - case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 72 /* AmpersandEqualsToken */: - case 77 /* CaretEqualsToken */: - case 73 /* BarEqualsToken */: - case 74 /* BarBarEqualsToken */: - case 75 /* AmpersandAmpersandEqualsToken */: - case 76 /* QuestionQuestionEqualsToken */: + 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 */; } } @@ -16633,15 +17013,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 204 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 206 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 216 /* BinaryExpression */) { + if (expression.kind === 218 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 214 /* PrefixUnaryExpression */ || expression.kind === 215 /* PostfixUnaryExpression */) { + else if (expression.kind === 216 /* PrefixUnaryExpression */ || expression.kind === 217 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -16820,81 +17200,82 @@ var ts; })(OperatorPrecedence = ts.OperatorPrecedence || (ts.OperatorPrecedence = {})); function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 337 /* CommaListExpression */: + case 345 /* CommaListExpression */: return 0 /* Comma */; - case 220 /* SpreadElement */: + case 222 /* SpreadElement */: return 1 /* Spread */; - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: return 2 /* Yield */; - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: return 4 /* Conditional */; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: switch (operatorKind) { case 27 /* CommaToken */: return 0 /* Comma */; - case 62 /* EqualsToken */: - case 63 /* PlusEqualsToken */: - case 64 /* MinusEqualsToken */: - case 66 /* AsteriskAsteriskEqualsToken */: - case 65 /* AsteriskEqualsToken */: - case 67 /* SlashEqualsToken */: - case 68 /* PercentEqualsToken */: - case 69 /* LessThanLessThanEqualsToken */: - case 70 /* GreaterThanGreaterThanEqualsToken */: - case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 72 /* AmpersandEqualsToken */: - case 77 /* CaretEqualsToken */: - case 73 /* BarEqualsToken */: - case 74 /* BarBarEqualsToken */: - case 75 /* AmpersandAmpersandEqualsToken */: - case 76 /* QuestionQuestionEqualsToken */: + 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 */; default: return getBinaryOperatorPrecedence(operatorKind); } // TODO: Should prefix `++` and `--` be moved to the `Update` precedence? - case 206 /* TypeAssertionExpression */: - case 225 /* NonNullExpression */: - case 214 /* PrefixUnaryExpression */: - case 211 /* TypeOfExpression */: - case 212 /* VoidExpression */: - case 210 /* DeleteExpression */: - case 213 /* AwaitExpression */: + case 208 /* TypeAssertionExpression */: + case 227 /* NonNullExpression */: + case 216 /* PrefixUnaryExpression */: + case 213 /* TypeOfExpression */: + case 214 /* VoidExpression */: + case 212 /* DeleteExpression */: + case 215 /* AwaitExpression */: return 16 /* Unary */; - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: return 17 /* Update */; - case 203 /* CallExpression */: + case 205 /* CallExpression */: return 18 /* LeftHandSide */; - case 204 /* NewExpression */: + case 206 /* NewExpression */: return hasArguments ? 19 /* Member */ : 18 /* LeftHandSide */; - case 205 /* TaggedTemplateExpression */: - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 207 /* TaggedTemplateExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: + case 228 /* MetaProperty */: return 19 /* Member */; - case 224 /* AsExpression */: + case 226 /* AsExpression */: return 11 /* Relational */; - case 107 /* ThisKeyword */: - case 105 /* SuperKeyword */: - case 78 /* Identifier */: - case 103 /* NullKeyword */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: + case 108 /* ThisKeyword */: + case 106 /* SuperKeyword */: + case 79 /* Identifier */: + case 104 /* NullKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: - case 199 /* ArrayLiteralExpression */: - case 200 /* ObjectLiteralExpression */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 221 /* ClassExpression */: + case 201 /* ArrayLiteralExpression */: + case 202 /* ObjectLiteralExpression */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 223 /* ClassExpression */: case 13 /* RegularExpressionLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 218 /* TemplateExpression */: - case 207 /* ParenthesizedExpression */: - case 222 /* OmittedExpression */: - case 273 /* JsxElement */: - case 274 /* JsxSelfClosingElement */: - case 277 /* JsxFragment */: + case 220 /* TemplateExpression */: + case 209 /* ParenthesizedExpression */: + case 224 /* OmittedExpression */: + case 275 /* JsxElement */: + case 276 /* JsxSelfClosingElement */: + case 279 /* JsxFragment */: return 20 /* Primary */; default: return -1 /* Invalid */; @@ -16924,9 +17305,9 @@ var ts; case 31 /* GreaterThanToken */: case 32 /* LessThanEqualsToken */: case 33 /* GreaterThanEqualsToken */: - case 101 /* InstanceOfKeyword */: - case 100 /* InKeyword */: - case 126 /* AsKeyword */: + case 102 /* InstanceOfKeyword */: + case 101 /* InKeyword */: + case 127 /* AsKeyword */: return 11 /* Relational */; case 47 /* LessThanLessThanToken */: case 48 /* GreaterThanGreaterThanToken */: @@ -16950,7 +17331,7 @@ var ts; function getSemanticJsxChildren(children) { return ts.filter(children, function (i) { switch (i.kind) { - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: return !!i.expression; case 11 /* JsxText */: return !i.containsOnlyTriviaWhiteSpaces; @@ -17252,7 +17633,7 @@ var ts; reportInaccessibleThisError: ts.noop, reportPrivateInBaseOfClassExpression: ts.noop, reportInaccessibleUniqueSymbolError: ts.noop, - trackSymbol: ts.noop, + trackSymbol: function () { return false; }, writeKeyword: write, writeOperator: write, writeParameter: write, @@ -17344,11 +17725,20 @@ var ts; return file.moduleName || getExternalModuleNameFromPath(host, file.fileName, referenceFile && referenceFile.fileName); } ts.getResolvedExternalModuleName = getResolvedExternalModuleName; + function getCanonicalAbsolutePath(host, path) { + return host.getCanonicalFileName(ts.getNormalizedAbsolutePath(path, host.getCurrentDirectory())); + } function getExternalModuleNameFromDeclaration(host, resolver, declaration) { var file = resolver.getExternalModuleFileFromDeclaration(declaration); if (!file || file.isDeclarationFile) { return undefined; } + // If the declaration already uses a non-relative name, and is outside the common source directory, continue to use it + var specifier = getExternalModuleName(declaration); + if (specifier && ts.isStringLiteralLike(specifier) && !ts.pathIsRelative(specifier.text) && + getCanonicalAbsolutePath(host, file.path).indexOf(getCanonicalAbsolutePath(host, ts.ensureTrailingDirectorySeparator(host.getCommonSourceDirectory()))) === -1) { + return undefined; + } return getResolvedExternalModuleName(host, file); } ts.getExternalModuleNameFromDeclaration = getExternalModuleNameFromDeclaration; @@ -17432,8 +17822,8 @@ var ts; return !(options.noEmitForJsFiles && isSourceFileJS(sourceFile)) && !sourceFile.isDeclarationFile && !host.isSourceFileFromExternalLibrary(sourceFile) && - !(isJsonSourceFile(sourceFile) && host.getResolvedProjectReferenceToRedirect(sourceFile.fileName)) && - (forceDtsEmit || !host.isSourceOfProjectReferenceRedirect(sourceFile.fileName)); + (forceDtsEmit || (!(isJsonSourceFile(sourceFile) && host.getResolvedProjectReferenceToRedirect(sourceFile.fileName)) && + !host.isSourceOfProjectReferenceRedirect(sourceFile.fileName))); } ts.sourceFileMayBeEmitted = sourceFileMayBeEmitted; function getSourceFilePathInNewDir(fileName, host, newDirPath) { @@ -17513,11 +17903,11 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return !!node && node.kind === 78 /* Identifier */ && identifierIsThisKeyword(node); + return !!node && node.kind === 79 /* Identifier */ && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 107 /* ThisKeyword */; + return id.originalKeywordKind === 108 /* ThisKeyword */; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -17528,10 +17918,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 167 /* GetAccessor */) { + if (accessor.kind === 169 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 168 /* SetAccessor */) { + else if (accessor.kind === 170 /* SetAccessor */) { setAccessor = accessor; } else { @@ -17551,10 +17941,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 167 /* GetAccessor */ && !getAccessor) { + if (member.kind === 169 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 168 /* SetAccessor */ && !setAccessor) { + if (member.kind === 170 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -17603,7 +17993,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 === 311 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 314 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -17779,7 +18169,7 @@ var ts; ts.writeCommentRange = writeCommentRange; function writeTrimmedCurrentLine(text, commentEnd, writer, newLine, pos, nextLineStart) { var end = Math.min(commentEnd, nextLineStart - 1); - var currentLineText = text.substring(pos, end).replace(/^\s+|\s+$/g, ""); + var currentLineText = ts.trimString(text.substring(pos, end)); if (currentLineText) { // trimmed forward and ending spaces text writer.writeComment(currentLineText); @@ -17826,6 +18216,18 @@ var ts; return hasSyntacticModifier(node, 32 /* Static */); } ts.hasStaticModifier = hasStaticModifier; + function hasOverrideModifier(node) { + return hasEffectiveModifier(node, 16384 /* Override */); + } + ts.hasOverrideModifier = hasOverrideModifier; + function hasAbstractModifier(node) { + return hasSyntacticModifier(node, 128 /* Abstract */); + } + ts.hasAbstractModifier = hasAbstractModifier; + function hasAmbientModifier(node) { + return hasSyntacticModifier(node, 2 /* Ambient */); + } + ts.hasAmbientModifier = hasAmbientModifier; function hasEffectiveReadonlyModifier(node) { return hasEffectiveModifier(node, 64 /* Readonly */); } @@ -17839,7 +18241,7 @@ var ts; } ts.getSelectedSyntacticModifierFlags = getSelectedSyntacticModifierFlags; function getModifierFlagsWorker(node, includeJSDoc, alwaysIncludeJSDoc) { - if (node.kind >= 0 /* FirstToken */ && node.kind <= 156 /* LastToken */) { + if (node.kind >= 0 /* FirstToken */ && node.kind <= 158 /* LastToken */) { return 0 /* None */; } if (!(node.modifierFlagsCache & 536870912 /* HasComputedFlags */)) { @@ -17884,6 +18286,8 @@ var ts; flags |= 16 /* Protected */; if (ts.getJSDocReadonlyTagNoCache(node)) flags |= 64 /* Readonly */; + if (ts.getJSDocOverrideTagNoCache(node)) + flags |= 16384 /* Override */; } if (ts.getJSDocDeprecatedTagNoCache(node)) flags |= 8192 /* Deprecated */; @@ -17906,7 +18310,7 @@ var ts; */ function getSyntacticModifierFlagsNoCache(node) { var flags = modifiersToFlags(node.modifiers); - if (node.flags & 4 /* NestedNamespace */ || (node.kind === 78 /* Identifier */ && node.isInJSDocNamespace)) { + if (node.flags & 4 /* NestedNamespace */ || (node.kind === 79 /* Identifier */ && node.isInJSDocNamespace)) { flags |= 1 /* Export */; } return flags; @@ -17925,21 +18329,26 @@ var ts; ts.modifiersToFlags = modifiersToFlags; function modifierToFlag(token) { switch (token) { - case 123 /* StaticKeyword */: return 32 /* Static */; - case 122 /* PublicKeyword */: return 4 /* Public */; - case 121 /* ProtectedKeyword */: return 16 /* Protected */; - case 120 /* PrivateKeyword */: return 8 /* Private */; - case 125 /* AbstractKeyword */: return 128 /* Abstract */; - case 92 /* ExportKeyword */: return 1 /* Export */; - case 133 /* DeclareKeyword */: return 2 /* Ambient */; - case 84 /* ConstKeyword */: return 2048 /* Const */; - case 87 /* DefaultKeyword */: return 512 /* Default */; - case 129 /* AsyncKeyword */: return 256 /* Async */; - case 142 /* ReadonlyKeyword */: return 64 /* Readonly */; + 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 134 /* DeclareKeyword */: return 2 /* Ambient */; + case 85 /* ConstKeyword */: return 2048 /* Const */; + case 88 /* DefaultKeyword */: return 512 /* Default */; + case 130 /* AsyncKeyword */: return 256 /* Async */; + case 143 /* ReadonlyKeyword */: return 64 /* Readonly */; + case 157 /* OverrideKeyword */: return 16384 /* Override */; } return 0 /* None */; } ts.modifierToFlag = modifierToFlag; + function createModifiers(modifierFlags) { + return modifierFlags ? ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(modifierFlags)) : undefined; + } + ts.createModifiers = createModifiers; function isLogicalOperator(token) { return token === 56 /* BarBarToken */ || token === 55 /* AmpersandAmpersandToken */ @@ -17947,9 +18356,9 @@ var ts; } ts.isLogicalOperator = isLogicalOperator; function isLogicalOrCoalescingAssignmentOperator(token) { - return token === 74 /* BarBarEqualsToken */ - || token === 75 /* AmpersandAmpersandEqualsToken */ - || token === 76 /* QuestionQuestionEqualsToken */; + return token === 75 /* BarBarEqualsToken */ + || token === 76 /* AmpersandAmpersandEqualsToken */ + || token === 77 /* QuestionQuestionEqualsToken */; } ts.isLogicalOrCoalescingAssignmentOperator = isLogicalOrCoalescingAssignmentOperator; function isLogicalOrCoalescingAssignmentExpression(expr) { @@ -17957,7 +18366,7 @@ var ts; } ts.isLogicalOrCoalescingAssignmentExpression = isLogicalOrCoalescingAssignmentExpression; function isAssignmentOperator(token) { - return token >= 62 /* FirstAssignment */ && token <= 77 /* LastAssignment */; + return token >= 63 /* FirstAssignment */ && token <= 78 /* LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ @@ -17970,23 +18379,27 @@ var ts; return ts.isExpressionWithTypeArguments(node) && ts.isHeritageClause(node.parent) && ts.isClassLike(node.parent.parent) - ? { class: node.parent.parent, isImplements: node.parent.token === 116 /* ImplementsKeyword */ } + ? { class: node.parent.parent, isImplements: node.parent.token === 117 /* ImplementsKeyword */ } : undefined; } ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments = tryGetClassImplementingOrExtendingExpressionWithTypeArguments; function isAssignmentExpression(node, excludeCompoundAssignment) { return ts.isBinaryExpression(node) && (excludeCompoundAssignment - ? node.operatorToken.kind === 62 /* EqualsToken */ + ? node.operatorToken.kind === 63 /* EqualsToken */ : isAssignmentOperator(node.operatorToken.kind)) && ts.isLeftHandSideExpression(node.left); } ts.isAssignmentExpression = isAssignmentExpression; + function isLeftHandSideOfAssignment(node) { + return isAssignmentExpression(node.parent) && node.parent.left === node; + } + ts.isLeftHandSideOfAssignment = isLeftHandSideOfAssignment; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 200 /* ObjectLiteralExpression */ - || kind === 199 /* ArrayLiteralExpression */; + return kind === 202 /* ObjectLiteralExpression */ + || kind === 201 /* ArrayLiteralExpression */; } return false; } @@ -17996,30 +18409,33 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { - return node.kind === 78 /* Identifier */ || isPropertyAccessEntityNameExpression(node); + return node.kind === 79 /* Identifier */ || isPropertyAccessEntityNameExpression(node); } ts.isEntityNameExpression = isEntityNameExpression; function getFirstIdentifier(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return node; - case 157 /* QualifiedName */: + case 159 /* QualifiedName */: do { node = node.left; - } while (node.kind !== 78 /* Identifier */); + } while (node.kind !== 79 /* Identifier */); return node; - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: do { node = node.expression; - } while (node.kind !== 78 /* Identifier */); + } while (node.kind !== 79 /* Identifier */); return node; } } ts.getFirstIdentifier = getFirstIdentifier; function isDottedName(node) { - return node.kind === 78 /* Identifier */ || node.kind === 107 /* ThisKeyword */ || node.kind === 105 /* SuperKeyword */ || - node.kind === 201 /* PropertyAccessExpression */ && isDottedName(node.expression) || - node.kind === 207 /* ParenthesizedExpression */ && isDottedName(node.expression); + return node.kind === 79 /* Identifier */ + || node.kind === 108 /* ThisKeyword */ + || node.kind === 106 /* SuperKeyword */ + || node.kind === 228 /* MetaProperty */ + || node.kind === 203 /* PropertyAccessExpression */ && isDottedName(node.expression) + || node.kind === 209 /* ParenthesizedExpression */ && isDottedName(node.expression); } ts.isDottedName = isDottedName; function isPropertyAccessEntityNameExpression(node) { @@ -18033,6 +18449,12 @@ var ts; return baseStr + "." + entityNameToString(expr.name); } } + else if (ts.isElementAccessExpression(expr)) { + var baseStr = tryGetPropertyAccessOrIdentifierToString(expr.expression); + if (baseStr !== undefined && ts.isPropertyName(expr.argumentExpression)) { + return baseStr + "." + getPropertyNameForPropertyNameNode(expr.argumentExpression); + } + } else if (ts.isIdentifier(expr)) { return ts.unescapeLeadingUnderscores(expr.escapedText); } @@ -18044,22 +18466,28 @@ var ts; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 157 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 201 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 159 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 203 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; + function isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName(node) { + return ts.isQualifiedName(node.parent) && node.parent.right === node + || ts.isPropertyAccessExpression(node.parent) && node.parent.name === node + || ts.isJSDocMemberName(node.parent) && node.parent.right === node; + } + ts.isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName = isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName; function isEmptyObjectLiteral(expression) { - return expression.kind === 200 /* ObjectLiteralExpression */ && + return expression.kind === 202 /* ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 199 /* ArrayLiteralExpression */ && + return expression.kind === 201 /* ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; function getLocalSymbolForExportDefault(symbol) { - if (!isExportDefaultSymbol(symbol)) + if (!isExportDefaultSymbol(symbol) || !symbol.declarations) return undefined; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; @@ -18386,8 +18814,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 255 /* EnumDeclaration */: - case 256 /* ModuleDeclaration */: + case 257 /* EnumDeclaration */: + case 258 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -18414,9 +18842,11 @@ var ts; return symbol.flags & 33554432 /* Transient */ ? symbol.checkFlags : 0; } ts.getCheckFlags = getCheckFlags; - function getDeclarationModifierFlagsFromSymbol(s) { + function getDeclarationModifierFlagsFromSymbol(s, isWrite) { + if (isWrite === void 0) { isWrite = false; } if (s.valueDeclaration) { - var flags = ts.getCombinedModifierFlags(s.valueDeclaration); + var declaration = (isWrite && s.declarations && ts.find(s.declarations, function (d) { return d.kind === 170 /* SetAccessor */; })) || s.valueDeclaration; + var flags = ts.getCombinedModifierFlags(declaration); return s.parent && s.parent.flags & 32 /* Class */ ? flags : flags & ~28 /* AccessibilityModifier */; } if (getCheckFlags(s) & 6 /* Synthetic */) { @@ -18464,35 +18894,35 @@ var ts; if (!parent) return 0 /* Read */; switch (parent.kind) { - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return accessKind(parent); - case 215 /* PostfixUnaryExpression */: - case 214 /* PrefixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: var operator = parent.operator; return operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? - operatorToken.kind === 62 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() + operatorToken.kind === 63 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() : 0 /* Read */; - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return parent.name !== node ? 0 /* Read */ : accessKind(parent); - case 288 /* PropertyAssignment */: { + case 290 /* 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 289 /* ShorthandPropertyAssignment */: + case 291 /* 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 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return accessKind(parent); default: return 0 /* 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 && skipParenthesesUp(parent.parent).kind === 233 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && walkUpParenthesizedExpressions(parent.parent).kind === 235 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; } } function reverseAccessKind(a) { @@ -18580,7 +19010,8 @@ var ts; } ts.isAbstractConstructorSymbol = isAbstractConstructorSymbol; function getClassLikeDeclarationOfSymbol(symbol) { - return ts.find(symbol.declarations, ts.isClassLike); + var _a; + return (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isClassLike); } ts.getClassLikeDeclarationOfSymbol = getClassLikeDeclarationOfSymbol; function getObjectFlags(type) { @@ -18623,7 +19054,6 @@ var ts; ts.getLastChild = getLastChild; function addToSeen(seen, key, value) { if (value === void 0) { value = true; } - key = String(key); if (seen.has(key)) { return false; } @@ -18636,37 +19066,37 @@ var ts; } ts.isObjectTypeDeclaration = isObjectTypeDeclaration; function isTypeNodeKind(kind) { - return (kind >= 172 /* FirstTypeNode */ && kind <= 195 /* LastTypeNode */) - || kind === 128 /* AnyKeyword */ - || kind === 152 /* UnknownKeyword */ - || kind === 144 /* NumberKeyword */ - || kind === 155 /* BigIntKeyword */ - || kind === 145 /* ObjectKeyword */ - || kind === 131 /* BooleanKeyword */ - || kind === 147 /* StringKeyword */ - || kind === 148 /* SymbolKeyword */ - || kind === 113 /* VoidKeyword */ - || kind === 150 /* UndefinedKeyword */ - || kind === 141 /* NeverKeyword */ - || kind === 223 /* ExpressionWithTypeArguments */ - || kind === 303 /* JSDocAllType */ - || kind === 304 /* JSDocUnknownType */ - || kind === 305 /* JSDocNullableType */ - || kind === 306 /* JSDocNonNullableType */ - || kind === 307 /* JSDocOptionalType */ - || kind === 308 /* JSDocFunctionType */ - || kind === 309 /* JSDocVariadicType */; + return (kind >= 174 /* FirstTypeNode */ && kind <= 197 /* LastTypeNode */) + || kind === 129 /* AnyKeyword */ + || kind === 153 /* UnknownKeyword */ + || kind === 145 /* NumberKeyword */ + || kind === 156 /* BigIntKeyword */ + || kind === 146 /* ObjectKeyword */ + || kind === 132 /* BooleanKeyword */ + || kind === 148 /* StringKeyword */ + || kind === 149 /* SymbolKeyword */ + || kind === 114 /* VoidKeyword */ + || kind === 151 /* UndefinedKeyword */ + || kind === 142 /* NeverKeyword */ + || kind === 225 /* ExpressionWithTypeArguments */ + || kind === 306 /* JSDocAllType */ + || kind === 307 /* JSDocUnknownType */ + || kind === 308 /* JSDocNullableType */ + || kind === 309 /* JSDocNonNullableType */ + || kind === 310 /* JSDocOptionalType */ + || kind === 311 /* JSDocFunctionType */ + || kind === 312 /* JSDocVariadicType */; } ts.isTypeNodeKind = isTypeNodeKind; function isAccessExpression(node) { - return node.kind === 201 /* PropertyAccessExpression */ || node.kind === 202 /* ElementAccessExpression */; + return node.kind === 203 /* PropertyAccessExpression */ || node.kind === 204 /* ElementAccessExpression */; } ts.isAccessExpression = isAccessExpression; function getNameOfAccessExpression(node) { - if (node.kind === 201 /* PropertyAccessExpression */) { + if (node.kind === 203 /* PropertyAccessExpression */) { return node.name; } - ts.Debug.assert(node.kind === 202 /* ElementAccessExpression */); + ts.Debug.assert(node.kind === 204 /* ElementAccessExpression */); return node.argumentExpression; } ts.getNameOfAccessExpression = getNameOfAccessExpression; @@ -18681,7 +19111,7 @@ var ts; } ts.isBundleFileTextLike = isBundleFileTextLike; function isNamedImportsOrExports(node) { - return node.kind === 264 /* NamedImports */ || node.kind === 268 /* NamedExports */; + return node.kind === 266 /* NamedImports */ || node.kind === 270 /* NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function getLeftmostAccessExpression(expr) { @@ -18694,28 +19124,28 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: node = node.operand; continue; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: node = node.left; continue; - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: node = node.condition; continue; - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: node = node.tag; continue; - case 203 /* CallExpression */: + case 205 /* CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 224 /* AsExpression */: - case 202 /* ElementAccessExpression */: - case 201 /* PropertyAccessExpression */: - case 225 /* NonNullExpression */: - case 336 /* PartiallyEmittedExpression */: + case 226 /* AsExpression */: + case 204 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 227 /* NonNullExpression */: + case 344 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -18734,7 +19164,7 @@ var ts; } function Type(checker, flags) { this.flags = flags; - if (ts.Debug.isDebugging || ts.tracing.isTracing()) { + if (ts.Debug.isDebugging || ts.tracing) { this.checker = checker; } } @@ -19078,6 +19508,10 @@ var ts; return !!(compilerOptions.declaration || compilerOptions.composite); } ts.getEmitDeclarations = getEmitDeclarations; + function shouldPreserveConstEnums(compilerOptions) { + return !!(compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); + } + ts.shouldPreserveConstEnums = shouldPreserveConstEnums; function isIncrementalCompilation(options) { return !!(options.incremental || options.composite); } @@ -19090,14 +19524,16 @@ var ts; return compilerOptions.allowJs === undefined ? !!compilerOptions.checkJs : compilerOptions.allowJs; } ts.getAllowJSCompilerOption = getAllowJSCompilerOption; + function getUseDefineForClassFields(compilerOptions) { + return compilerOptions.useDefineForClassFields === undefined ? compilerOptions.target === 99 /* ESNext */ : compilerOptions.useDefineForClassFields; + } + ts.getUseDefineForClassFields = getUseDefineForClassFields; function compilerOptionsAffectSemanticDiagnostics(newOptions, oldOptions) { - return oldOptions !== newOptions && - ts.semanticDiagnosticsOptionDeclarations.some(function (option) { return !isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); }); + return optionsHaveChanges(oldOptions, newOptions, ts.semanticDiagnosticsOptionDeclarations); } ts.compilerOptionsAffectSemanticDiagnostics = compilerOptionsAffectSemanticDiagnostics; function compilerOptionsAffectEmit(newOptions, oldOptions) { - return oldOptions !== newOptions && - ts.affectsEmitOptionDeclarations.some(function (option) { return !isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); }); + return optionsHaveChanges(oldOptions, newOptions, ts.affectsEmitOptionDeclarations); } ts.compilerOptionsAffectEmit = compilerOptionsAffectEmit; function getCompilerOptionValue(options, option) { @@ -19111,7 +19547,7 @@ var ts; 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[0] : jsxImportSourcePragmas; + var jsxImportSourcePragma = ts.isArray(jsxImportSourcePragmas) ? jsxImportSourcePragmas[jsxImportSourcePragmas.length - 1] : jsxImportSourcePragmas; return compilerOptions.jsx === 4 /* ReactJSX */ || compilerOptions.jsx === 5 /* ReactJSXDev */ || compilerOptions.jsxImportSource || @@ -19140,37 +19576,65 @@ var ts; return true; } ts.hasZeroOrOneAsteriskCharacter = hasZeroOrOneAsteriskCharacter; - function createSymlinkCache() { + function createSymlinkCache(cwd, getCanonicalFileName) { var symlinkedDirectories; + var symlinkedDirectoriesByRealpath; var symlinkedFiles; return { getSymlinkedFiles: function () { return symlinkedFiles; }, getSymlinkedDirectories: function () { return symlinkedDirectories; }, + getSymlinkedDirectoriesByRealpath: function () { return symlinkedDirectoriesByRealpath; }, setSymlinkedFile: function (path, real) { return (symlinkedFiles || (symlinkedFiles = new ts.Map())).set(path, real); }, - setSymlinkedDirectory: function (path, directory) { return (symlinkedDirectories || (symlinkedDirectories = new ts.Map())).set(path, directory); }, + setSymlinkedDirectory: function (symlink, real) { + // Large, interconnected dependency graphs in pnpm will have a huge number of symlinks + // where both the realpath and the symlink path are inside node_modules/.pnpm. Since + // this path is never a candidate for a module specifier, we can ignore it entirely. + var symlinkPath = ts.toPath(symlink, cwd, getCanonicalFileName); + if (!containsIgnoredPath(symlinkPath)) { + symlinkPath = ts.ensureTrailingDirectorySeparator(symlinkPath); + if (real !== false && !(symlinkedDirectories === null || symlinkedDirectories === void 0 ? void 0 : symlinkedDirectories.has(symlinkPath))) { + (symlinkedDirectoriesByRealpath || (symlinkedDirectoriesByRealpath = ts.createMultiMap())).add(ts.ensureTrailingDirectorySeparator(real.realPath), symlink); + } + (symlinkedDirectories || (symlinkedDirectories = new ts.Map())).set(symlinkPath, real); + } + }, + setSymlinkedDirectoryFromSymlinkedFile: function (symlink, real) { + this.setSymlinkedFile(ts.toPath(symlink, cwd, getCanonicalFileName), real); + var _a = guessDirectorySymlink(real, symlink, cwd, getCanonicalFileName) || ts.emptyArray, commonResolved = _a[0], commonOriginal = _a[1]; + if (commonResolved && commonOriginal) { + this.setSymlinkedDirectory(commonOriginal, { + real: commonResolved, + realPath: ts.toPath(commonResolved, cwd, getCanonicalFileName), + }); + } + }, }; } ts.createSymlinkCache = createSymlinkCache; function discoverProbableSymlinks(files, getCanonicalFileName, cwd) { - var cache = createSymlinkCache(); - var symlinks = ts.flatten(ts.mapDefined(files, function (sf) { - return sf.resolvedModules && ts.compact(ts.arrayFrom(ts.mapIterator(sf.resolvedModules.values(), function (res) { - return res && res.originalPath && res.resolvedFileName !== res.originalPath ? [res.resolvedFileName, res.originalPath] : undefined; + var cache = createSymlinkCache(cwd, getCanonicalFileName); + var symlinks = ts.flatMap(files, function (sf) { + var pairs = sf.resolvedModules && ts.arrayFrom(ts.mapDefinedIterator(sf.resolvedModules.values(), function (res) { + return (res === null || res === void 0 ? void 0 : res.originalPath) ? [res.resolvedFileName, res.originalPath] : undefined; + })); + return ts.concatenate(pairs, sf.resolvedTypeReferenceDirectiveNames && ts.arrayFrom(ts.mapDefinedIterator(sf.resolvedTypeReferenceDirectiveNames.values(), function (res) { + return (res === null || res === void 0 ? void 0 : res.originalPath) && res.resolvedFileName ? [res.resolvedFileName, res.originalPath] : undefined; }))); - })); + }); for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) { var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1]; + cache.setSymlinkedFile(ts.toPath(originalPath, cwd, getCanonicalFileName), resolvedPath); var _b = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName) || ts.emptyArray, commonResolved = _b[0], commonOriginal = _b[1]; if (commonResolved && commonOriginal) { - cache.setSymlinkedDirectory(ts.toPath(commonOriginal, cwd, getCanonicalFileName), { real: commonResolved, realPath: ts.toPath(commonResolved, cwd, getCanonicalFileName) }); + cache.setSymlinkedDirectory(commonOriginal, { real: commonResolved, realPath: ts.toPath(commonResolved, cwd, getCanonicalFileName) }); } } return cache; } ts.discoverProbableSymlinks = discoverProbableSymlinks; function guessDirectorySymlink(a, b, cwd, getCanonicalFileName) { - var aParts = ts.getPathComponents(ts.toPath(a, cwd, getCanonicalFileName)); - var bParts = ts.getPathComponents(ts.toPath(b, cwd, getCanonicalFileName)); + var aParts = ts.getPathComponents(ts.getNormalizedAbsolutePath(a, cwd)); + var bParts = ts.getPathComponents(ts.getNormalizedAbsolutePath(b, cwd)); var isDirectory = false; while (!isNodeModulesOrScopedPackageDirectory(aParts[aParts.length - 2], getCanonicalFileName) && !isNodeModulesOrScopedPackageDirectory(bParts[bParts.length - 2], getCanonicalFileName) && @@ -19554,6 +20018,14 @@ var ts; return false; } ts.isSupportedSourceFileName = isSupportedSourceFileName; + function numberOfDirectorySeparators(str) { + var match = str.match(/\//g); + return match ? match.length : 0; + } + function compareNumberOfDirectorySeparators(path1, path2) { + return ts.compareValues(numberOfDirectorySeparators(path1), numberOfDirectorySeparators(path2)); + } + ts.compareNumberOfDirectorySeparators = compareNumberOfDirectorySeparators; /** * Extension boundaries by priority. Lower numbers indicate higher priorities, and are * aligned to the offset of the highest priority extension in the @@ -19628,16 +20100,27 @@ var ts; return ts.changeAnyExtension(path, newExtension, extensionsToRemove, /*ignoreCase*/ false); } ts.changeExtension = changeExtension; + /** + * Returns the input if there are no stars, a pattern if there is exactly one, + * and undefined if there are more. + */ function tryParsePattern(pattern) { - // This should be verified outside of here and a proper error thrown. - ts.Debug.assert(hasZeroOrOneAsteriskCharacter(pattern)); var indexOfStar = pattern.indexOf("*"); - return indexOfStar === -1 ? undefined : { - prefix: pattern.substr(0, indexOfStar), - suffix: pattern.substr(indexOfStar + 1) - }; + if (indexOfStar === -1) { + return pattern; + } + return pattern.indexOf("*", indexOfStar + 1) !== -1 + ? undefined + : { + prefix: pattern.substr(0, indexOfStar), + suffix: pattern.substr(indexOfStar + 1) + }; } ts.tryParsePattern = tryParsePattern; + function tryParsePatterns(paths) { + return ts.mapDefined(ts.getOwnKeys(paths), function (path) { return tryParsePattern(path); }); + } + ts.tryParsePatterns = tryParsePatterns; function positionIsSynthesized(pos) { // This is a fast way of testing the following conditions: // pos === undefined || pos === null || isNaN(pos) || pos < 0; @@ -19679,23 +20162,19 @@ var ts; directories: ts.emptyArray }; /** - * patternStrings contains both pattern strings (containing "*") and regular strings. + * patternOrStrings contains both patterns (containing "*") and regular strings. * Return an exact match if possible, or a pattern match, or undefined. * (These are verified by verifyCompilerOptions to have 0 or 1 "*" characters.) */ - function matchPatternOrExact(patternStrings, candidate) { + function matchPatternOrExact(patternOrStrings, candidate) { var patterns = []; - for (var _i = 0, patternStrings_1 = patternStrings; _i < patternStrings_1.length; _i++) { - var patternString = patternStrings_1[_i]; - if (!hasZeroOrOneAsteriskCharacter(patternString)) - continue; - var pattern = tryParsePattern(patternString); - if (pattern) { - patterns.push(pattern); + for (var _i = 0, patternOrStrings_1 = patternOrStrings; _i < patternOrStrings_1.length; _i++) { + var patternOrString = patternOrStrings_1[_i]; + if (patternOrString === candidate) { + return candidate; } - else if (patternString === candidate) { - // pattern was matched as is - no need to search further - return patternString; + if (!ts.isString(patternOrString)) { + patterns.push(patternOrString); } } return ts.findBestPatternMatch(patterns, function (_) { return _; }, candidate); @@ -19850,38 +20329,38 @@ var ts; } ts.isValidTypeOnlyAliasUseSite = isValidTypeOnlyAliasUseSite; function typeOnlyDeclarationIsExport(typeOnlyDeclaration) { - return typeOnlyDeclaration.kind === 270 /* ExportSpecifier */; + return typeOnlyDeclaration.kind === 272 /* ExportSpecifier */; } ts.typeOnlyDeclarationIsExport = typeOnlyDeclarationIsExport; function isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(node) { - while (node.kind === 78 /* Identifier */ || node.kind === 201 /* PropertyAccessExpression */) { + while (node.kind === 79 /* Identifier */ || node.kind === 203 /* PropertyAccessExpression */) { node = node.parent; } - if (node.kind !== 158 /* ComputedPropertyName */) { + if (node.kind !== 160 /* ComputedPropertyName */) { return false; } if (hasSyntacticModifier(node.parent, 128 /* Abstract */)) { return true; } var containerKind = node.parent.parent.kind; - return containerKind === 253 /* InterfaceDeclaration */ || containerKind === 177 /* TypeLiteral */; + return containerKind === 255 /* InterfaceDeclaration */ || containerKind === 179 /* 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 !== 78 /* Identifier */) + if (node.kind !== 79 /* Identifier */) return false; var heritageClause = ts.findAncestor(node.parent, function (parent) { switch (parent.kind) { - case 286 /* HeritageClause */: + case 288 /* HeritageClause */: return true; - case 201 /* PropertyAccessExpression */: - case 223 /* ExpressionWithTypeArguments */: + case 203 /* PropertyAccessExpression */: + case 225 /* ExpressionWithTypeArguments */: return false; default: return "quit"; } }); - return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 116 /* ImplementsKeyword */ || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 253 /* InterfaceDeclaration */; + return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 117 /* ImplementsKeyword */ || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 255 /* InterfaceDeclaration */; } function isIdentifierTypeReference(node) { return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName); @@ -20034,6 +20513,76 @@ var ts; } } ts.expressionResultIsUnused = expressionResultIsUnused; + function containsIgnoredPath(path) { + return ts.some(ts.ignoredPaths, function (p) { return ts.stringContains(path, p); }); + } + ts.containsIgnoredPath = containsIgnoredPath; + function getContainingNodeArray(node) { + if (!node.parent) + return undefined; + switch (node.kind) { + case 161 /* TypeParameter */: + var parent_1 = node.parent; + return parent_1.kind === 187 /* InferType */ ? undefined : parent_1.typeParameters; + case 162 /* Parameter */: + return node.parent.parameters; + case 196 /* TemplateLiteralTypeSpan */: + return node.parent.templateSpans; + case 230 /* TemplateSpan */: + return node.parent.templateSpans; + case 163 /* Decorator */: + return node.parent.decorators; + case 288 /* HeritageClause */: + return node.parent.heritageClauses; + } + var parent = node.parent; + if (ts.isJSDocTag(node)) { + return ts.isJSDocTypeLiteral(node.parent) ? undefined : node.parent.tags; + } + switch (parent.kind) { + case 179 /* TypeLiteral */: + case 255 /* InterfaceDeclaration */: + return ts.isTypeElement(node) ? parent.members : undefined; + case 184 /* UnionType */: + case 185 /* IntersectionType */: + return parent.types; + case 181 /* TupleType */: + case 201 /* ArrayLiteralExpression */: + case 345 /* CommaListExpression */: + case 266 /* NamedImports */: + case 270 /* NamedExports */: + return parent.elements; + case 202 /* ObjectLiteralExpression */: + case 283 /* JsxAttributes */: + return parent.properties; + case 205 /* CallExpression */: + case 206 /* NewExpression */: + return ts.isTypeNode(node) ? parent.typeArguments : + parent.expression === node ? undefined : + parent.arguments; + case 275 /* JsxElement */: + case 279 /* JsxFragment */: + return ts.isJsxChild(node) ? parent.children : undefined; + case 277 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: + return ts.isTypeNode(node) ? parent.typeArguments : undefined; + case 232 /* Block */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: + case 259 /* ModuleBlock */: + return parent.statements; + case 260 /* CaseBlock */: + return parent.clauses; + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + return ts.isClassElement(node) ? parent.members : undefined; + case 257 /* EnumDeclaration */: + return ts.isEnumMember(node) ? parent.members : undefined; + case 299 /* SourceFile */: + return parent.statements; + } + } + ts.getContainingNodeArray = getContainingNodeArray; })(ts || (ts = {})); /* @internal */ var ts; @@ -20078,7 +20627,11 @@ var ts; var ts; (function (ts) { function createParenthesizerRules(factory) { + var binaryLeftOperandParenthesizerCache; + var binaryRightOperandParenthesizerCache; return { + getParenthesizeLeftSideOfBinaryForOperator: getParenthesizeLeftSideOfBinaryForOperator, + getParenthesizeRightSideOfBinaryForOperator: getParenthesizeRightSideOfBinaryForOperator, parenthesizeLeftSideOfBinary: parenthesizeLeftSideOfBinary, parenthesizeRightSideOfBinary: parenthesizeRightSideOfBinary, parenthesizeExpressionOfComputedPropertyName: parenthesizeExpressionOfComputedPropertyName, @@ -20099,6 +20652,24 @@ var ts; parenthesizeConstituentTypesOfUnionOrIntersectionType: parenthesizeConstituentTypesOfUnionOrIntersectionType, parenthesizeTypeArguments: parenthesizeTypeArguments, }; + function getParenthesizeLeftSideOfBinaryForOperator(operatorKind) { + binaryLeftOperandParenthesizerCache || (binaryLeftOperandParenthesizerCache = new ts.Map()); + var parenthesizerRule = binaryLeftOperandParenthesizerCache.get(operatorKind); + if (!parenthesizerRule) { + parenthesizerRule = function (node) { return parenthesizeLeftSideOfBinary(operatorKind, node); }; + binaryLeftOperandParenthesizerCache.set(operatorKind, parenthesizerRule); + } + return parenthesizerRule; + } + function getParenthesizeRightSideOfBinaryForOperator(operatorKind) { + binaryRightOperandParenthesizerCache || (binaryRightOperandParenthesizerCache = new ts.Map()); + var parenthesizerRule = binaryRightOperandParenthesizerCache.get(operatorKind); + if (!parenthesizerRule) { + parenthesizerRule = function (node) { return parenthesizeRightSideOfBinary(operatorKind, /*leftSide*/ undefined, node); }; + binaryRightOperandParenthesizerCache.set(operatorKind, parenthesizerRule); + } + return parenthesizerRule; + } /** * Determines whether the operand to a BinaryExpression needs to be parenthesized. * @@ -20125,10 +20696,10 @@ 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(216 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(216 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(218 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(218 /* BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); - if (!isLeftSideOfBinary && operand.kind === 209 /* ArrowFunction */ && binaryOperatorPrecedence > 3 /* Assignment */) { + if (!isLeftSideOfBinary && operand.kind === 211 /* ArrowFunction */ && binaryOperatorPrecedence > 3 /* Assignment */) { // We need to parenthesize arrow functions on the right side to avoid it being // parsed as parenthesized expression: `a && (() => {})` return true; @@ -20140,7 +20711,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 219 /* YieldExpression */) { + && operand.kind === 221 /* YieldExpression */) { return false; } return true; @@ -20228,7 +20799,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 216 /* BinaryExpression */ && node.operatorToken.kind === 39 /* PlusToken */) { + if (node.kind === 218 /* BinaryExpression */ && node.operatorToken.kind === 39 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -20254,7 +20825,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 === 207 /* ParenthesizedExpression */) { + if (skipped.kind === 209 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -20271,7 +20842,7 @@ var ts; return ts.isCommaSequence(expression) ? factory.createParenthesizedExpression(expression) : expression; } function parenthesizeConditionOfConditionalExpression(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(217 /* ConditionalExpression */, 57 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(219 /* ConditionalExpression */, 57 /* QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) !== 1 /* GreaterThan */) { @@ -20304,8 +20875,8 @@ var ts; var needsParens = ts.isCommaSequence(check); if (!needsParens) { switch (ts.getLeftmostExpression(check, /*stopAtCallExpression*/ false).kind) { - case 221 /* ClassExpression */: - case 208 /* FunctionExpression */: + case 223 /* ClassExpression */: + case 210 /* FunctionExpression */: needsParens = true; } } @@ -20318,9 +20889,9 @@ var ts; function parenthesizeExpressionOfNew(expression) { var leftmostExpr = ts.getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 203 /* CallExpression */: + case 205 /* CallExpression */: return factory.createParenthesizedExpression(expression); - case 204 /* NewExpression */: + case 206 /* NewExpression */: return !leftmostExpr.arguments ? factory.createParenthesizedExpression(expression) : expression; // TODO(rbuckton): Verify this assertion holds @@ -20340,7 +20911,7 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 204 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 206 /* NewExpression */ || emittedExpression.arguments)) { // TODO(rbuckton): Verify whether this assertion holds. return expression; } @@ -20362,7 +20933,7 @@ var ts; function parenthesizeExpressionForDisallowedComma(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(216 /* BinaryExpression */, 27 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(218 /* BinaryExpression */, 27 /* CommaToken */); // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(factory.createParenthesizedExpression(expression), expression); } @@ -20371,44 +20942,44 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 208 /* FunctionExpression */ || kind === 209 /* ArrowFunction */) { + if (kind === 210 /* FunctionExpression */ || kind === 211 /* 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 */); } } var leftmostExpressionKind = ts.getLeftmostExpression(emittedExpression, /*stopAtCallExpressions*/ false).kind; - if (leftmostExpressionKind === 200 /* ObjectLiteralExpression */ || leftmostExpressionKind === 208 /* FunctionExpression */) { + if (leftmostExpressionKind === 202 /* ObjectLiteralExpression */ || leftmostExpressionKind === 210 /* 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 === 200 /* ObjectLiteralExpression */)) { + if (!ts.isBlock(body) && (ts.isCommaSequence(body) || ts.getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 202 /* ObjectLiteralExpression */)) { // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return ts.setTextRange(factory.createParenthesizedExpression(body), body); } return body; } function parenthesizeMemberOfConditionalType(member) { - return member.kind === 184 /* ConditionalType */ ? factory.createParenthesizedType(member) : member; + return member.kind === 186 /* ConditionalType */ ? factory.createParenthesizedType(member) : member; } function parenthesizeMemberOfElementType(member) { switch (member.kind) { - case 182 /* UnionType */: - case 183 /* IntersectionType */: - case 174 /* FunctionType */: - case 175 /* ConstructorType */: + case 184 /* UnionType */: + case 185 /* IntersectionType */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: return factory.createParenthesizedType(member); } return parenthesizeMemberOfConditionalType(member); } function parenthesizeElementTypeOfArrayType(member) { switch (member.kind) { - case 176 /* TypeQuery */: - case 188 /* TypeOperator */: - case 185 /* InferType */: + case 178 /* TypeQuery */: + case 190 /* TypeOperator */: + case 187 /* InferType */: return factory.createParenthesizedType(member); } return parenthesizeMemberOfElementType(member); @@ -20427,6 +20998,8 @@ var ts; } ts.createParenthesizerRules = createParenthesizerRules; ts.nullParenthesizerRules = { + getParenthesizeLeftSideOfBinaryForOperator: function (_) { return ts.identity; }, + getParenthesizeRightSideOfBinaryForOperator: function (_) { return ts.identity; }, parenthesizeLeftSideOfBinary: function (_binaryOperator, leftSide) { return leftSide; }, parenthesizeRightSideOfBinary: function (_binaryOperator, _leftSide, rightSide) { return rightSide; }, parenthesizeExpressionOfComputedPropertyName: ts.identity, @@ -20512,11 +21085,11 @@ var ts; } function convertToAssignmentPattern(node) { switch (node.kind) { - case 197 /* ArrayBindingPattern */: - case 199 /* ArrayLiteralExpression */: + case 199 /* ArrayBindingPattern */: + case 201 /* ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 196 /* ObjectBindingPattern */: - case 200 /* ObjectLiteralExpression */: + case 198 /* ObjectBindingPattern */: + case 202 /* ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -20857,18 +21430,18 @@ var ts; createExternalModuleReference: createExternalModuleReference, updateExternalModuleReference: updateExternalModuleReference, // lazily load factory members for JSDoc types with similar structure - get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(303 /* JSDocAllType */); }, - get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(304 /* JSDocUnknownType */); }, - get createJSDocNonNullableType() { return getJSDocUnaryTypeCreateFunction(306 /* JSDocNonNullableType */); }, - get updateJSDocNonNullableType() { return getJSDocUnaryTypeUpdateFunction(306 /* JSDocNonNullableType */); }, - get createJSDocNullableType() { return getJSDocUnaryTypeCreateFunction(305 /* JSDocNullableType */); }, - get updateJSDocNullableType() { return getJSDocUnaryTypeUpdateFunction(305 /* JSDocNullableType */); }, - get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(307 /* JSDocOptionalType */); }, - get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(307 /* JSDocOptionalType */); }, - get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(309 /* JSDocVariadicType */); }, - get updateJSDocVariadicType() { return getJSDocUnaryTypeUpdateFunction(309 /* JSDocVariadicType */); }, - get createJSDocNamepathType() { return getJSDocUnaryTypeCreateFunction(310 /* JSDocNamepathType */); }, - get updateJSDocNamepathType() { return getJSDocUnaryTypeUpdateFunction(310 /* JSDocNamepathType */); }, + get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(306 /* JSDocAllType */); }, + get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(307 /* JSDocUnknownType */); }, + get createJSDocNonNullableType() { return getJSDocUnaryTypeCreateFunction(309 /* JSDocNonNullableType */); }, + get updateJSDocNonNullableType() { return getJSDocUnaryTypeUpdateFunction(309 /* JSDocNonNullableType */); }, + get createJSDocNullableType() { return getJSDocUnaryTypeCreateFunction(308 /* JSDocNullableType */); }, + get updateJSDocNullableType() { return getJSDocUnaryTypeUpdateFunction(308 /* JSDocNullableType */); }, + get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(310 /* JSDocOptionalType */); }, + get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(310 /* JSDocOptionalType */); }, + get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(312 /* JSDocVariadicType */); }, + get updateJSDocVariadicType() { return getJSDocUnaryTypeUpdateFunction(312 /* JSDocVariadicType */); }, + get createJSDocNamepathType() { return getJSDocUnaryTypeCreateFunction(313 /* JSDocNamepathType */); }, + get updateJSDocNamepathType() { return getJSDocUnaryTypeUpdateFunction(313 /* JSDocNamepathType */); }, createJSDocFunctionType: createJSDocFunctionType, updateJSDocFunctionType: updateJSDocFunctionType, createJSDocTypeLiteral: createJSDocTypeLiteral, @@ -20895,31 +21468,43 @@ var ts; updateJSDocSeeTag: updateJSDocSeeTag, createJSDocNameReference: createJSDocNameReference, updateJSDocNameReference: updateJSDocNameReference, + createJSDocMemberName: createJSDocMemberName, + updateJSDocMemberName: updateJSDocMemberName, + createJSDocLink: createJSDocLink, + updateJSDocLink: updateJSDocLink, + createJSDocLinkCode: createJSDocLinkCode, + updateJSDocLinkCode: updateJSDocLinkCode, + createJSDocLinkPlain: createJSDocLinkPlain, + updateJSDocLinkPlain: updateJSDocLinkPlain, // lazily load factory members for JSDoc tags with similar structure - get createJSDocTypeTag() { return getJSDocTypeLikeTagCreateFunction(329 /* JSDocTypeTag */); }, - get updateJSDocTypeTag() { return getJSDocTypeLikeTagUpdateFunction(329 /* JSDocTypeTag */); }, - get createJSDocReturnTag() { return getJSDocTypeLikeTagCreateFunction(327 /* JSDocReturnTag */); }, - get updateJSDocReturnTag() { return getJSDocTypeLikeTagUpdateFunction(327 /* JSDocReturnTag */); }, - get createJSDocThisTag() { return getJSDocTypeLikeTagCreateFunction(328 /* JSDocThisTag */); }, - get updateJSDocThisTag() { return getJSDocTypeLikeTagUpdateFunction(328 /* JSDocThisTag */); }, - get createJSDocEnumTag() { return getJSDocTypeLikeTagCreateFunction(325 /* JSDocEnumTag */); }, - get updateJSDocEnumTag() { return getJSDocTypeLikeTagUpdateFunction(325 /* JSDocEnumTag */); }, - get createJSDocAuthorTag() { return getJSDocSimpleTagCreateFunction(317 /* JSDocAuthorTag */); }, - get updateJSDocAuthorTag() { return getJSDocSimpleTagUpdateFunction(317 /* JSDocAuthorTag */); }, - get createJSDocClassTag() { return getJSDocSimpleTagCreateFunction(319 /* JSDocClassTag */); }, - get updateJSDocClassTag() { return getJSDocSimpleTagUpdateFunction(319 /* JSDocClassTag */); }, - get createJSDocPublicTag() { return getJSDocSimpleTagCreateFunction(320 /* JSDocPublicTag */); }, - get updateJSDocPublicTag() { return getJSDocSimpleTagUpdateFunction(320 /* JSDocPublicTag */); }, - get createJSDocPrivateTag() { return getJSDocSimpleTagCreateFunction(321 /* JSDocPrivateTag */); }, - get updateJSDocPrivateTag() { return getJSDocSimpleTagUpdateFunction(321 /* JSDocPrivateTag */); }, - get createJSDocProtectedTag() { return getJSDocSimpleTagCreateFunction(322 /* JSDocProtectedTag */); }, - get updateJSDocProtectedTag() { return getJSDocSimpleTagUpdateFunction(322 /* JSDocProtectedTag */); }, - get createJSDocReadonlyTag() { return getJSDocSimpleTagCreateFunction(323 /* JSDocReadonlyTag */); }, - get updateJSDocReadonlyTag() { return getJSDocSimpleTagUpdateFunction(323 /* JSDocReadonlyTag */); }, - get createJSDocDeprecatedTag() { return getJSDocSimpleTagCreateFunction(318 /* JSDocDeprecatedTag */); }, - get updateJSDocDeprecatedTag() { return getJSDocSimpleTagUpdateFunction(318 /* JSDocDeprecatedTag */); }, + get createJSDocTypeTag() { return getJSDocTypeLikeTagCreateFunction(337 /* JSDocTypeTag */); }, + get updateJSDocTypeTag() { return getJSDocTypeLikeTagUpdateFunction(337 /* JSDocTypeTag */); }, + get createJSDocReturnTag() { return getJSDocTypeLikeTagCreateFunction(335 /* JSDocReturnTag */); }, + get updateJSDocReturnTag() { return getJSDocTypeLikeTagUpdateFunction(335 /* JSDocReturnTag */); }, + get createJSDocThisTag() { return getJSDocTypeLikeTagCreateFunction(336 /* JSDocThisTag */); }, + get updateJSDocThisTag() { return getJSDocTypeLikeTagUpdateFunction(336 /* JSDocThisTag */); }, + get createJSDocEnumTag() { return getJSDocTypeLikeTagCreateFunction(333 /* JSDocEnumTag */); }, + get updateJSDocEnumTag() { return getJSDocTypeLikeTagUpdateFunction(333 /* JSDocEnumTag */); }, + get createJSDocAuthorTag() { return getJSDocSimpleTagCreateFunction(324 /* JSDocAuthorTag */); }, + get updateJSDocAuthorTag() { return getJSDocSimpleTagUpdateFunction(324 /* JSDocAuthorTag */); }, + get createJSDocClassTag() { return getJSDocSimpleTagCreateFunction(326 /* JSDocClassTag */); }, + get updateJSDocClassTag() { return getJSDocSimpleTagUpdateFunction(326 /* JSDocClassTag */); }, + get createJSDocPublicTag() { return getJSDocSimpleTagCreateFunction(327 /* JSDocPublicTag */); }, + get updateJSDocPublicTag() { return getJSDocSimpleTagUpdateFunction(327 /* JSDocPublicTag */); }, + get createJSDocPrivateTag() { return getJSDocSimpleTagCreateFunction(328 /* JSDocPrivateTag */); }, + get updateJSDocPrivateTag() { return getJSDocSimpleTagUpdateFunction(328 /* JSDocPrivateTag */); }, + get createJSDocProtectedTag() { return getJSDocSimpleTagCreateFunction(329 /* JSDocProtectedTag */); }, + get updateJSDocProtectedTag() { return getJSDocSimpleTagUpdateFunction(329 /* JSDocProtectedTag */); }, + get createJSDocReadonlyTag() { return getJSDocSimpleTagCreateFunction(330 /* JSDocReadonlyTag */); }, + get updateJSDocReadonlyTag() { return getJSDocSimpleTagUpdateFunction(330 /* JSDocReadonlyTag */); }, + get createJSDocOverrideTag() { return getJSDocSimpleTagCreateFunction(331 /* JSDocOverrideTag */); }, + get updateJSDocOverrideTag() { return getJSDocSimpleTagUpdateFunction(331 /* JSDocOverrideTag */); }, + get createJSDocDeprecatedTag() { return getJSDocSimpleTagCreateFunction(325 /* JSDocDeprecatedTag */); }, + get updateJSDocDeprecatedTag() { return getJSDocSimpleTagUpdateFunction(325 /* JSDocDeprecatedTag */); }, createJSDocUnknownTag: createJSDocUnknownTag, updateJSDocUnknownTag: updateJSDocUnknownTag, + createJSDocText: createJSDocText, + updateJSDocText: updateJSDocText, createJSDocComment: createJSDocComment, updateJSDocComment: updateJSDocComment, createJsxElement: createJsxElement, @@ -20984,7 +21569,7 @@ var ts; cloneNode: cloneNode, // Lazily load factory methods for common operator factories and utilities get createComma() { return getBinaryCreateFunction(27 /* CommaToken */); }, - get createAssignment() { return getBinaryCreateFunction(62 /* EqualsToken */); }, + get createAssignment() { return getBinaryCreateFunction(63 /* EqualsToken */); }, get createLogicalOr() { return getBinaryCreateFunction(56 /* BarBarToken */); }, get createLogicalAnd() { return getBinaryCreateFunction(55 /* AmpersandAmpersandToken */); }, get createBitwiseOr() { return getBinaryCreateFunction(51 /* BarToken */); }, @@ -21103,11 +21688,11 @@ var ts; // don't propagate child flags. if (name) { switch (node.kind) { - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 163 /* PropertyDeclaration */: - case 288 /* PropertyAssignment */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 290 /* PropertyAssignment */: if (ts.isIdentifier(name)) { node.transformFlags |= propagateIdentifierNameFlags(name); break; @@ -21148,7 +21733,7 @@ var ts; function createBaseFunctionLikeDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type, body) { var node = createBaseSignatureDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type); node.body = body; - node.transformFlags |= propagateChildFlags(node.body) & ~8388608 /* ContainsPossibleTopLevelAwait */; + node.transformFlags |= propagateChildFlags(node.body) & ~16777216 /* ContainsPossibleTopLevelAwait */; if (!body) node.transformFlags |= 1 /* ContainsTypeScript */; return node; @@ -21201,7 +21786,7 @@ var ts; var node = createBaseLiteral(8 /* NumericLiteral */, typeof value === "number" ? value + "" : value); node.numericLiteralFlags = numericLiteralFlags; if (numericLiteralFlags & 384 /* BinaryOrOctalSpecifier */) - node.transformFlags |= 256 /* ContainsES2015 */; + node.transformFlags |= 512 /* ContainsES2015 */; return node; } // @api @@ -21220,7 +21805,7 @@ var ts; var node = createBaseStringLiteral(text, isSingleQuote); node.hasExtendedUnicodeEscape = hasExtendedUnicodeEscape; if (hasExtendedUnicodeEscape) - node.transformFlags |= 256 /* ContainsES2015 */; + node.transformFlags |= 512 /* ContainsES2015 */; return node; } // @api @@ -21253,10 +21838,10 @@ var ts; if (originalKeywordKind === undefined && text) { originalKeywordKind = ts.stringToToken(text); } - if (originalKeywordKind === 78 /* Identifier */) { + if (originalKeywordKind === 79 /* Identifier */) { originalKeywordKind = undefined; } - var node = baseFactory.createBaseIdentifierNode(78 /* Identifier */); + var node = baseFactory.createBaseIdentifierNode(79 /* Identifier */); node.originalKeywordKind = originalKeywordKind; node.escapedText = ts.escapeLeadingUnderscores(text); return node; @@ -21275,8 +21860,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 === 130 /* AwaitKeyword */) { - node.transformFlags |= 8388608 /* ContainsPossibleTopLevelAwait */; + if (node.originalKeywordKind === 131 /* AwaitKeyword */) { + node.transformFlags |= 16777216 /* ContainsPossibleTopLevelAwait */; } return node; } @@ -21299,8 +21884,11 @@ var ts; } /** Create a unique temporary variable for use in a loop. */ // @api - function createLoopVariable() { - return createBaseGeneratedIdentifier("", 2 /* Loop */); + function createLoopVariable(reservedInNestedScopes) { + var flags = 2 /* Loop */; + if (reservedInNestedScopes) + flags |= 8 /* ReservedInNestedScopes */; + return createBaseGeneratedIdentifier("", flags); } /** Create a unique name based on the supplied text. */ // @api @@ -21323,9 +21911,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(79 /* PrivateIdentifier */); + var node = baseFactory.createBasePrivateIdentifierNode(80 /* PrivateIdentifier */); node.escapedText = ts.escapeLeadingUnderscores(text); - node.transformFlags |= 4194304 /* ContainsClassFields */; + node.transformFlags |= 8388608 /* ContainsClassFields */; return node; } // @@ -21335,46 +21923,47 @@ var ts; return baseFactory.createBaseTokenNode(kind); } function createToken(token) { - ts.Debug.assert(token >= 0 /* FirstToken */ && token <= 156 /* LastToken */, "Invalid token"); + ts.Debug.assert(token >= 0 /* FirstToken */ && token <= 158 /* 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 !== 78 /* Identifier */, "Invalid token. Use 'createIdentifier' to create identifiers"); + ts.Debug.assert(token !== 79 /* Identifier */, "Invalid token. Use 'createIdentifier' to create identifiers"); var node = createBaseToken(token); var transformFlags = 0 /* None */; switch (token) { - case 129 /* AsyncKeyword */: + case 130 /* AsyncKeyword */: // 'async' modifier is ES2017 (async functions) or ES2018 (async generators) transformFlags = - 64 /* ContainsES2017 */ | - 32 /* ContainsES2018 */; + 128 /* ContainsES2017 */ | + 64 /* ContainsES2018 */; break; - case 122 /* PublicKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 142 /* ReadonlyKeyword */: - case 125 /* AbstractKeyword */: - case 133 /* DeclareKeyword */: - case 84 /* ConstKeyword */: - case 128 /* AnyKeyword */: - case 144 /* NumberKeyword */: - case 155 /* BigIntKeyword */: - case 141 /* NeverKeyword */: - case 145 /* ObjectKeyword */: - case 147 /* StringKeyword */: - case 131 /* BooleanKeyword */: - case 148 /* SymbolKeyword */: - case 113 /* VoidKeyword */: - case 152 /* UnknownKeyword */: - case 150 /* UndefinedKeyword */: // `undefined` is an Identifier in the expression case. + case 123 /* PublicKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + case 143 /* ReadonlyKeyword */: + case 126 /* AbstractKeyword */: + case 134 /* DeclareKeyword */: + case 85 /* ConstKeyword */: + case 129 /* AnyKeyword */: + case 145 /* NumberKeyword */: + case 156 /* BigIntKeyword */: + case 142 /* NeverKeyword */: + case 146 /* ObjectKeyword */: + case 157 /* OverrideKeyword */: + case 148 /* StringKeyword */: + case 132 /* BooleanKeyword */: + case 149 /* SymbolKeyword */: + case 114 /* VoidKeyword */: + case 153 /* UnknownKeyword */: + case 151 /* UndefinedKeyword */: // `undefined` is an Identifier in the expression case. transformFlags = 1 /* ContainsTypeScript */; break; - case 123 /* StaticKeyword */: - case 105 /* SuperKeyword */: - transformFlags = 256 /* ContainsES2015 */; + case 124 /* StaticKeyword */: + case 106 /* SuperKeyword */: + transformFlags = 512 /* ContainsES2015 */; break; - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: // 'this' indicates a lexical 'this' - transformFlags = 4096 /* ContainsLexicalThis */; + transformFlags = 8192 /* ContainsLexicalThis */; break; } if (transformFlags) { @@ -21387,23 +21976,23 @@ var ts; // // @api function createSuper() { - return createToken(105 /* SuperKeyword */); + return createToken(106 /* SuperKeyword */); } // @api function createThis() { - return createToken(107 /* ThisKeyword */); + return createToken(108 /* ThisKeyword */); } // @api function createNull() { - return createToken(103 /* NullKeyword */); + return createToken(104 /* NullKeyword */); } // @api function createTrue() { - return createToken(109 /* TrueKeyword */); + return createToken(110 /* TrueKeyword */); } // @api function createFalse() { - return createToken(94 /* FalseKeyword */); + return createToken(95 /* FalseKeyword */); } // // Modifiers @@ -21416,37 +22005,40 @@ var ts; function createModifiersFromModifierFlags(flags) { var result = []; if (flags & 1 /* Export */) { - result.push(createModifier(92 /* ExportKeyword */)); + result.push(createModifier(93 /* ExportKeyword */)); } if (flags & 2 /* Ambient */) { - result.push(createModifier(133 /* DeclareKeyword */)); + result.push(createModifier(134 /* DeclareKeyword */)); } if (flags & 512 /* Default */) { - result.push(createModifier(87 /* DefaultKeyword */)); + result.push(createModifier(88 /* DefaultKeyword */)); } if (flags & 2048 /* Const */) { - result.push(createModifier(84 /* ConstKeyword */)); + result.push(createModifier(85 /* ConstKeyword */)); } if (flags & 4 /* Public */) { - result.push(createModifier(122 /* PublicKeyword */)); + result.push(createModifier(123 /* PublicKeyword */)); } if (flags & 8 /* Private */) { - result.push(createModifier(120 /* PrivateKeyword */)); + result.push(createModifier(121 /* PrivateKeyword */)); } if (flags & 16 /* Protected */) { - result.push(createModifier(121 /* ProtectedKeyword */)); + result.push(createModifier(122 /* ProtectedKeyword */)); } if (flags & 128 /* Abstract */) { - result.push(createModifier(125 /* AbstractKeyword */)); + result.push(createModifier(126 /* AbstractKeyword */)); } if (flags & 32 /* Static */) { - result.push(createModifier(123 /* StaticKeyword */)); + result.push(createModifier(124 /* StaticKeyword */)); + } + if (flags & 16384 /* Override */) { + result.push(createModifier(157 /* OverrideKeyword */)); } if (flags & 64 /* Readonly */) { - result.push(createModifier(142 /* ReadonlyKeyword */)); + result.push(createModifier(143 /* ReadonlyKeyword */)); } if (flags & 256 /* Async */) { - result.push(createModifier(129 /* AsyncKeyword */)); + result.push(createModifier(130 /* AsyncKeyword */)); } return result; } @@ -21455,7 +22047,7 @@ var ts; // // @api function createQualifiedName(left, right) { - var node = createBaseNode(157 /* QualifiedName */); + var node = createBaseNode(159 /* QualifiedName */); node.left = left; node.right = asName(right); node.transformFlags |= @@ -21472,12 +22064,12 @@ var ts; } // @api function createComputedPropertyName(expression) { - var node = createBaseNode(158 /* ComputedPropertyName */); + var node = createBaseNode(160 /* ComputedPropertyName */); node.expression = parenthesizerRules().parenthesizeExpressionOfComputedPropertyName(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 256 /* ContainsES2015 */ | - 32768 /* ContainsComputedPropertyName */; + 512 /* ContainsES2015 */ | + 65536 /* ContainsComputedPropertyName */; return node; } // @api @@ -21491,7 +22083,7 @@ var ts; // // @api function createTypeParameterDeclaration(name, constraint, defaultType) { - var node = createBaseNamedDeclaration(159 /* TypeParameter */, + var node = createBaseNamedDeclaration(161 /* TypeParameter */, /*decorators*/ undefined, /*modifiers*/ undefined, name); node.constraint = constraint; @@ -21509,7 +22101,7 @@ var ts; } // @api function createParameterDeclaration(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(160 /* Parameter */, decorators, modifiers, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); + var node = createBaseVariableLikeDeclaration(162 /* Parameter */, decorators, modifiers, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.dotDotDotToken = dotDotDotToken; node.questionToken = questionToken; if (ts.isThisIdentifier(node.name)) { @@ -21521,10 +22113,10 @@ var ts; propagateChildFlags(node.questionToken); if (questionToken) node.transformFlags |= 1 /* ContainsTypeScript */; - if (ts.modifiersToFlags(node.modifiers) & 92 /* ParameterPropertyModifier */) - node.transformFlags |= 2048 /* ContainsTypeScriptClassSyntax */; + if (ts.modifiersToFlags(node.modifiers) & 16476 /* ParameterPropertyModifier */) + node.transformFlags |= 4096 /* ContainsTypeScriptClassSyntax */; if (initializer || dotDotDotToken) - node.transformFlags |= 256 /* ContainsES2015 */; + node.transformFlags |= 512 /* ContainsES2015 */; } return node; } @@ -21542,12 +22134,12 @@ var ts; } // @api function createDecorator(expression) { - var node = createBaseNode(161 /* Decorator */); + var node = createBaseNode(163 /* Decorator */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= propagateChildFlags(node.expression) | 1 /* ContainsTypeScript */ | - 2048 /* ContainsTypeScriptClassSyntax */; + 4096 /* ContainsTypeScriptClassSyntax */; return node; } // @api @@ -21561,7 +22153,7 @@ var ts; // // @api function createPropertySignature(modifiers, name, questionToken, type) { - var node = createBaseNamedDeclaration(162 /* PropertySignature */, + var node = createBaseNamedDeclaration(164 /* PropertySignature */, /*decorators*/ undefined, modifiers, name); node.type = type; node.questionToken = questionToken; @@ -21579,15 +22171,15 @@ var ts; } // @api function createPropertyDeclaration(decorators, modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(163 /* PropertyDeclaration */, decorators, modifiers, name, type, initializer); + var node = createBaseVariableLikeDeclaration(165 /* PropertyDeclaration */, decorators, 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) | - 4194304 /* ContainsClassFields */; + 8388608 /* ContainsClassFields */; if (ts.isComputedPropertyName(node.name) || (ts.hasStaticModifier(node) && node.initializer)) { - node.transformFlags |= 2048 /* ContainsTypeScriptClassSyntax */; + node.transformFlags |= 4096 /* ContainsTypeScriptClassSyntax */; } if (questionOrExclamationToken || ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { node.transformFlags |= 1 /* ContainsTypeScript */; @@ -21608,7 +22200,7 @@ var ts; } // @api function createMethodSignature(modifiers, name, questionToken, typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(164 /* MethodSignature */, + var node = createBaseSignatureDeclaration(166 /* MethodSignature */, /*decorators*/ undefined, modifiers, name, typeParameters, parameters, type); node.questionToken = questionToken; node.transformFlags = 1 /* ContainsTypeScript */; @@ -21627,26 +22219,26 @@ var ts; } // @api function createMethodDeclaration(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(165 /* MethodDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(167 /* MethodDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; node.questionToken = questionToken; node.transformFlags |= propagateChildFlags(node.asteriskToken) | propagateChildFlags(node.questionToken) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; if (questionToken) { node.transformFlags |= 1 /* ContainsTypeScript */; } if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { if (asteriskToken) { - node.transformFlags |= 32 /* ContainsES2018 */; + node.transformFlags |= 64 /* ContainsES2018 */; } else { - node.transformFlags |= 64 /* ContainsES2017 */; + node.transformFlags |= 128 /* ContainsES2017 */; } } else if (asteriskToken) { - node.transformFlags |= 512 /* ContainsGenerator */; + node.transformFlags |= 1024 /* ContainsGenerator */; } return node; } @@ -21666,11 +22258,11 @@ var ts; } // @api function createConstructorDeclaration(decorators, modifiers, parameters, body) { - var node = createBaseFunctionLikeDeclaration(166 /* Constructor */, decorators, modifiers, + var node = createBaseFunctionLikeDeclaration(168 /* Constructor */, decorators, modifiers, /*name*/ undefined, /*typeParameters*/ undefined, parameters, /*type*/ undefined, body); - node.transformFlags |= 256 /* ContainsES2015 */; + node.transformFlags |= 512 /* ContainsES2015 */; return node; } // @api @@ -21684,7 +22276,7 @@ var ts; } // @api function createGetAccessorDeclaration(decorators, modifiers, name, parameters, type, body) { - return createBaseFunctionLikeDeclaration(167 /* GetAccessor */, decorators, modifiers, name, + return createBaseFunctionLikeDeclaration(169 /* GetAccessor */, decorators, modifiers, name, /*typeParameters*/ undefined, parameters, type, body); } // @api @@ -21700,7 +22292,7 @@ var ts; } // @api function createSetAccessorDeclaration(decorators, modifiers, name, parameters, body) { - return createBaseFunctionLikeDeclaration(168 /* SetAccessor */, decorators, modifiers, name, + return createBaseFunctionLikeDeclaration(170 /* SetAccessor */, decorators, modifiers, name, /*typeParameters*/ undefined, parameters, /*type*/ undefined, body); } @@ -21716,7 +22308,7 @@ var ts; } // @api function createCallSignature(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(169 /* CallSignature */, + var node = createBaseSignatureDeclaration(171 /* CallSignature */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); @@ -21733,7 +22325,7 @@ var ts; } // @api function createConstructSignature(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(170 /* ConstructSignature */, + var node = createBaseSignatureDeclaration(172 /* ConstructSignature */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); @@ -21750,7 +22342,7 @@ var ts; } // @api function createIndexSignature(decorators, modifiers, parameters, type) { - var node = createBaseSignatureDeclaration(171 /* IndexSignature */, decorators, modifiers, + var node = createBaseSignatureDeclaration(173 /* IndexSignature */, decorators, modifiers, /*name*/ undefined, /*typeParameters*/ undefined, parameters, type); node.transformFlags = 1 /* ContainsTypeScript */; @@ -21767,7 +22359,7 @@ var ts; } // @api function createTemplateLiteralTypeSpan(type, literal) { - var node = createBaseNode(194 /* TemplateLiteralTypeSpan */); + var node = createBaseNode(196 /* TemplateLiteralTypeSpan */); node.type = type; node.literal = literal; node.transformFlags = 1 /* ContainsTypeScript */; @@ -21789,7 +22381,7 @@ var ts; } // @api function createTypePredicateNode(assertsModifier, parameterName, type) { - var node = createBaseNode(172 /* TypePredicate */); + var node = createBaseNode(174 /* TypePredicate */); node.assertsModifier = assertsModifier; node.parameterName = asName(parameterName); node.type = type; @@ -21806,7 +22398,7 @@ var ts; } // @api function createTypeReferenceNode(typeName, typeArguments) { - var node = createBaseNode(173 /* TypeReference */); + var node = createBaseNode(175 /* TypeReference */); node.typeName = asName(typeName); node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(createNodeArray(typeArguments)); node.transformFlags = 1 /* ContainsTypeScript */; @@ -21821,7 +22413,7 @@ var ts; } // @api function createFunctionTypeNode(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(174 /* FunctionType */, + var node = createBaseSignatureDeclaration(176 /* FunctionType */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); @@ -21847,7 +22439,7 @@ var ts; ts.Debug.fail("Incorrect number of arguments specified."); } function createConstructorTypeNode1(modifiers, typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(175 /* ConstructorType */, + var node = createBaseSignatureDeclaration(177 /* ConstructorType */, /*decorators*/ undefined, modifiers, /*name*/ undefined, typeParameters, parameters, type); node.transformFlags = 1 /* ContainsTypeScript */; @@ -21881,7 +22473,7 @@ var ts; } // @api function createTypeQueryNode(exprName) { - var node = createBaseNode(176 /* TypeQuery */); + var node = createBaseNode(178 /* TypeQuery */); node.exprName = exprName; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -21894,7 +22486,7 @@ var ts; } // @api function createTypeLiteralNode(members) { - var node = createBaseNode(177 /* TypeLiteral */); + var node = createBaseNode(179 /* TypeLiteral */); node.members = createNodeArray(members); node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -21907,7 +22499,7 @@ var ts; } // @api function createArrayTypeNode(elementType) { - var node = createBaseNode(178 /* ArrayType */); + var node = createBaseNode(180 /* ArrayType */); node.elementType = parenthesizerRules().parenthesizeElementTypeOfArrayType(elementType); node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -21920,7 +22512,7 @@ var ts; } // @api function createTupleTypeNode(elements) { - var node = createBaseNode(179 /* TupleType */); + var node = createBaseNode(181 /* TupleType */); node.elements = createNodeArray(elements); node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -21933,7 +22525,7 @@ var ts; } // @api function createNamedTupleMember(dotDotDotToken, name, questionToken, type) { - var node = createBaseNode(192 /* NamedTupleMember */); + var node = createBaseNode(194 /* NamedTupleMember */); node.dotDotDotToken = dotDotDotToken; node.name = name; node.questionToken = questionToken; @@ -21952,7 +22544,7 @@ var ts; } // @api function createOptionalTypeNode(type) { - var node = createBaseNode(180 /* OptionalType */); + var node = createBaseNode(182 /* OptionalType */); node.type = parenthesizerRules().parenthesizeElementTypeOfArrayType(type); node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -21965,7 +22557,7 @@ var ts; } // @api function createRestTypeNode(type) { - var node = createBaseNode(181 /* RestType */); + var node = createBaseNode(183 /* RestType */); node.type = type; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -21989,7 +22581,7 @@ var ts; } // @api function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(182 /* UnionType */, types); + return createUnionOrIntersectionTypeNode(184 /* UnionType */, types); } // @api function updateUnionTypeNode(node, types) { @@ -21997,7 +22589,7 @@ var ts; } // @api function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(183 /* IntersectionType */, types); + return createUnionOrIntersectionTypeNode(185 /* IntersectionType */, types); } // @api function updateIntersectionTypeNode(node, types) { @@ -22005,7 +22597,7 @@ var ts; } // @api function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createBaseNode(184 /* ConditionalType */); + var node = createBaseNode(186 /* ConditionalType */); node.checkType = parenthesizerRules().parenthesizeMemberOfConditionalType(checkType); node.extendsType = parenthesizerRules().parenthesizeMemberOfConditionalType(extendsType); node.trueType = trueType; @@ -22024,7 +22616,7 @@ var ts; } // @api function createInferTypeNode(typeParameter) { - var node = createBaseNode(185 /* InferType */); + var node = createBaseNode(187 /* InferType */); node.typeParameter = typeParameter; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -22037,7 +22629,7 @@ var ts; } // @api function createTemplateLiteralType(head, templateSpans) { - var node = createBaseNode(193 /* TemplateLiteralType */); + var node = createBaseNode(195 /* TemplateLiteralType */); node.head = head; node.templateSpans = createNodeArray(templateSpans); node.transformFlags = 1 /* ContainsTypeScript */; @@ -22053,7 +22645,7 @@ var ts; // @api function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { if (isTypeOf === void 0) { isTypeOf = false; } - var node = createBaseNode(195 /* ImportType */); + var node = createBaseNode(197 /* ImportType */); node.argument = argument; node.qualifier = qualifier; node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); @@ -22073,7 +22665,7 @@ var ts; } // @api function createParenthesizedType(type) { - var node = createBaseNode(186 /* ParenthesizedType */); + var node = createBaseNode(188 /* ParenthesizedType */); node.type = type; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -22086,13 +22678,13 @@ var ts; } // @api function createThisTypeNode() { - var node = createBaseNode(187 /* ThisType */); + var node = createBaseNode(189 /* ThisType */); node.transformFlags = 1 /* ContainsTypeScript */; return node; } // @api function createTypeOperatorNode(operator, type) { - var node = createBaseNode(188 /* TypeOperator */); + var node = createBaseNode(190 /* TypeOperator */); node.operator = operator; node.type = parenthesizerRules().parenthesizeMemberOfElementType(type); node.transformFlags = 1 /* ContainsTypeScript */; @@ -22106,7 +22698,7 @@ var ts; } // @api function createIndexedAccessTypeNode(objectType, indexType) { - var node = createBaseNode(189 /* IndexedAccessType */); + var node = createBaseNode(191 /* IndexedAccessType */); node.objectType = parenthesizerRules().parenthesizeMemberOfElementType(objectType); node.indexType = indexType; node.transformFlags = 1 /* ContainsTypeScript */; @@ -22121,7 +22713,7 @@ var ts; } // @api function createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type) { - var node = createBaseNode(190 /* MappedType */); + var node = createBaseNode(192 /* MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.nameType = nameType; @@ -22142,7 +22734,7 @@ var ts; } // @api function createLiteralTypeNode(literal) { - var node = createBaseNode(191 /* LiteralType */); + var node = createBaseNode(193 /* LiteralType */); node.literal = literal; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -22158,16 +22750,16 @@ var ts; // // @api function createObjectBindingPattern(elements) { - var node = createBaseNode(196 /* ObjectBindingPattern */); + var node = createBaseNode(198 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements) | - 256 /* ContainsES2015 */ | - 131072 /* ContainsBindingPattern */; - if (node.transformFlags & 8192 /* ContainsRestOrSpread */) { + 512 /* ContainsES2015 */ | + 262144 /* ContainsBindingPattern */; + if (node.transformFlags & 16384 /* ContainsRestOrSpread */) { node.transformFlags |= - 32 /* ContainsES2018 */ | - 16384 /* ContainsObjectRestOrSpread */; + 64 /* ContainsES2018 */ | + 32768 /* ContainsObjectRestOrSpread */; } return node; } @@ -22179,12 +22771,12 @@ var ts; } // @api function createArrayBindingPattern(elements) { - var node = createBaseNode(197 /* ArrayBindingPattern */); + var node = createBaseNode(199 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements) | - 256 /* ContainsES2015 */ | - 131072 /* ContainsBindingPattern */; + 512 /* ContainsES2015 */ | + 262144 /* ContainsBindingPattern */; return node; } // @api @@ -22195,21 +22787,21 @@ var ts; } // @api function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createBaseBindingLikeDeclaration(198 /* BindingElement */, + var node = createBaseBindingLikeDeclaration(200 /* BindingElement */, /*decorators*/ undefined, - /*modifiers*/ undefined, name, initializer); + /*modifiers*/ undefined, name, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.propertyName = asName(propertyName); node.dotDotDotToken = dotDotDotToken; node.transformFlags |= propagateChildFlags(node.dotDotDotToken) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; if (node.propertyName) { node.transformFlags |= ts.isIdentifier(node.propertyName) ? propagateIdentifierNameFlags(node.propertyName) : propagateChildFlags(node.propertyName); } if (dotDotDotToken) - node.transformFlags |= 8192 /* ContainsRestOrSpread */; + node.transformFlags |= 16384 /* ContainsRestOrSpread */; return node; } // @api @@ -22231,7 +22823,7 @@ var ts; } // @api function createArrayLiteralExpression(elements, multiLine) { - var node = createBaseExpression(199 /* ArrayLiteralExpression */); + var node = createBaseExpression(201 /* ArrayLiteralExpression */); node.elements = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(elements)); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.elements); @@ -22245,7 +22837,7 @@ var ts; } // @api function createObjectLiteralExpression(properties, multiLine) { - var node = createBaseExpression(200 /* ObjectLiteralExpression */); + var node = createBaseExpression(202 /* ObjectLiteralExpression */); node.properties = createNodeArray(properties); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.properties); @@ -22259,7 +22851,7 @@ var ts; } // @api function createPropertyAccessExpression(expression, name) { - var node = createBaseExpression(201 /* PropertyAccessExpression */); + var node = createBaseExpression(203 /* PropertyAccessExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.name = asName(name); node.transformFlags = @@ -22271,8 +22863,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 |= - 64 /* ContainsES2017 */ | - 32 /* ContainsES2018 */; + 128 /* ContainsES2017 */ | + 64 /* ContainsES2018 */; } return node; } @@ -22288,13 +22880,13 @@ var ts; } // @api function createPropertyAccessChain(expression, questionDotToken, name) { - var node = createBaseExpression(201 /* PropertyAccessExpression */); + var node = createBaseExpression(203 /* PropertyAccessExpression */); node.flags |= 32 /* OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.questionDotToken = questionDotToken; node.name = asName(name); node.transformFlags |= - 8 /* ContainsES2020 */ | + 16 /* ContainsES2020 */ | propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | (ts.isIdentifier(node.name) ? @@ -22315,7 +22907,7 @@ var ts; } // @api function createElementAccessExpression(expression, index) { - var node = createBaseExpression(202 /* ElementAccessExpression */); + var node = createBaseExpression(204 /* ElementAccessExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.argumentExpression = asExpression(index); node.transformFlags |= @@ -22325,8 +22917,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 |= - 64 /* ContainsES2017 */ | - 32 /* ContainsES2018 */; + 128 /* ContainsES2017 */ | + 64 /* ContainsES2018 */; } return node; } @@ -22342,7 +22934,7 @@ var ts; } // @api function createElementAccessChain(expression, questionDotToken, index) { - var node = createBaseExpression(202 /* ElementAccessExpression */); + var node = createBaseExpression(204 /* ElementAccessExpression */); node.flags |= 32 /* OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.questionDotToken = questionDotToken; @@ -22351,7 +22943,7 @@ var ts; propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | propagateChildFlags(node.argumentExpression) | - 8 /* ContainsES2020 */; + 16 /* ContainsES2020 */; return node; } // @api @@ -22367,7 +22959,7 @@ var ts; } // @api function createCallExpression(expression, typeArguments, argumentsArray) { - var node = createBaseExpression(203 /* CallExpression */); + var node = createBaseExpression(205 /* CallExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray)); @@ -22379,10 +22971,10 @@ var ts; node.transformFlags |= 1 /* ContainsTypeScript */; } if (ts.isImportKeyword(node.expression)) { - node.transformFlags |= 2097152 /* ContainsDynamicImport */; + node.transformFlags |= 4194304 /* ContainsDynamicImport */; } else if (ts.isSuperProperty(node.expression)) { - node.transformFlags |= 4096 /* ContainsLexicalThis */; + node.transformFlags |= 8192 /* ContainsLexicalThis */; } return node; } @@ -22399,7 +22991,7 @@ var ts; } // @api function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) { - var node = createBaseExpression(203 /* CallExpression */); + var node = createBaseExpression(205 /* CallExpression */); node.flags |= 32 /* OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.questionDotToken = questionDotToken; @@ -22410,12 +23002,12 @@ var ts; propagateChildFlags(node.questionDotToken) | propagateChildrenFlags(node.typeArguments) | propagateChildrenFlags(node.arguments) | - 8 /* ContainsES2020 */; + 16 /* ContainsES2020 */; if (node.typeArguments) { node.transformFlags |= 1 /* ContainsTypeScript */; } if (ts.isSuperProperty(node.expression)) { - node.transformFlags |= 4096 /* ContainsLexicalThis */; + node.transformFlags |= 8192 /* ContainsLexicalThis */; } return node; } @@ -22431,7 +23023,7 @@ var ts; } // @api function createNewExpression(expression, typeArguments, argumentsArray) { - var node = createBaseExpression(204 /* NewExpression */); + var node = createBaseExpression(206 /* NewExpression */); node.expression = parenthesizerRules().parenthesizeExpressionOfNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(argumentsArray) : undefined; @@ -22439,7 +23031,7 @@ var ts; propagateChildFlags(node.expression) | propagateChildrenFlags(node.typeArguments) | propagateChildrenFlags(node.arguments) | - 8 /* ContainsES2020 */; + 16 /* ContainsES2020 */; if (node.typeArguments) { node.transformFlags |= 1 /* ContainsTypeScript */; } @@ -22455,7 +23047,7 @@ var ts; } // @api function createTaggedTemplateExpression(tag, typeArguments, template) { - var node = createBaseExpression(205 /* TaggedTemplateExpression */); + var node = createBaseExpression(207 /* TaggedTemplateExpression */); node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag); node.typeArguments = asNodeArray(typeArguments); node.template = template; @@ -22463,12 +23055,12 @@ var ts; propagateChildFlags(node.tag) | propagateChildrenFlags(node.typeArguments) | propagateChildFlags(node.template) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; if (node.typeArguments) { node.transformFlags |= 1 /* ContainsTypeScript */; } if (ts.hasInvalidEscape(node.template)) { - node.transformFlags |= 32 /* ContainsES2018 */; + node.transformFlags |= 64 /* ContainsES2018 */; } return node; } @@ -22482,7 +23074,7 @@ var ts; } // @api function createTypeAssertion(type, expression) { - var node = createBaseExpression(206 /* TypeAssertionExpression */); + var node = createBaseExpression(208 /* TypeAssertionExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.type = type; node.transformFlags |= @@ -22500,7 +23092,7 @@ var ts; } // @api function createParenthesizedExpression(expression) { - var node = createBaseExpression(207 /* ParenthesizedExpression */); + var node = createBaseExpression(209 /* ParenthesizedExpression */); node.expression = expression; node.transformFlags = propagateChildFlags(node.expression); return node; @@ -22513,7 +23105,7 @@ var ts; } // @api function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(208 /* FunctionExpression */, + var node = createBaseFunctionLikeDeclaration(210 /* FunctionExpression */, /*decorators*/ undefined, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; node.transformFlags |= propagateChildFlags(node.asteriskToken); @@ -22522,14 +23114,14 @@ var ts; } if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { if (node.asteriskToken) { - node.transformFlags |= 32 /* ContainsES2018 */; + node.transformFlags |= 64 /* ContainsES2018 */; } else { - node.transformFlags |= 64 /* ContainsES2017 */; + node.transformFlags |= 128 /* ContainsES2017 */; } } else if (node.asteriskToken) { - node.transformFlags |= 512 /* ContainsGenerator */; + node.transformFlags |= 1024 /* ContainsGenerator */; } return node; } @@ -22547,15 +23139,15 @@ var ts; } // @api function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createBaseFunctionLikeDeclaration(209 /* ArrowFunction */, + var node = createBaseFunctionLikeDeclaration(211 /* ArrowFunction */, /*decorators*/ undefined, modifiers, /*name*/ undefined, typeParameters, parameters, type, parenthesizerRules().parenthesizeConciseBodyOfArrowFunction(body)); node.equalsGreaterThanToken = equalsGreaterThanToken !== null && equalsGreaterThanToken !== void 0 ? equalsGreaterThanToken : createToken(38 /* EqualsGreaterThanToken */); node.transformFlags |= propagateChildFlags(node.equalsGreaterThanToken) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { - node.transformFlags |= 64 /* ContainsES2017 */; + node.transformFlags |= 128 /* ContainsES2017 */; } return node; } @@ -22572,7 +23164,7 @@ var ts; } // @api function createDeleteExpression(expression) { - var node = createBaseExpression(210 /* DeleteExpression */); + var node = createBaseExpression(212 /* DeleteExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -22585,7 +23177,7 @@ var ts; } // @api function createTypeOfExpression(expression) { - var node = createBaseExpression(211 /* TypeOfExpression */); + var node = createBaseExpression(213 /* TypeOfExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -22598,7 +23190,7 @@ var ts; } // @api function createVoidExpression(expression) { - var node = createBaseExpression(212 /* VoidExpression */); + var node = createBaseExpression(214 /* VoidExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -22611,13 +23203,13 @@ var ts; } // @api function createAwaitExpression(expression) { - var node = createBaseExpression(213 /* AwaitExpression */); + var node = createBaseExpression(215 /* AwaitExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 64 /* ContainsES2017 */ | - 32 /* ContainsES2018 */ | - 524288 /* ContainsAwait */; + 128 /* ContainsES2017 */ | + 64 /* ContainsES2018 */ | + 1048576 /* ContainsAwait */; return node; } // @api @@ -22628,7 +23220,7 @@ var ts; } // @api function createPrefixUnaryExpression(operator, operand) { - var node = createBaseExpression(214 /* PrefixUnaryExpression */); + var node = createBaseExpression(216 /* PrefixUnaryExpression */); node.operator = operator; node.operand = parenthesizerRules().parenthesizeOperandOfPrefixUnary(operand); node.transformFlags |= propagateChildFlags(node.operand); @@ -22642,7 +23234,7 @@ var ts; } // @api function createPostfixUnaryExpression(operand, operator) { - var node = createBaseExpression(215 /* PostfixUnaryExpression */); + var node = createBaseExpression(217 /* PostfixUnaryExpression */); node.operator = operator; node.operand = parenthesizerRules().parenthesizeOperandOfPostfixUnary(operand); node.transformFlags = propagateChildFlags(node.operand); @@ -22656,7 +23248,7 @@ var ts; } // @api function createBinaryExpression(left, operator, right) { - var node = createBaseExpression(216 /* BinaryExpression */); + var node = createBaseExpression(218 /* BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = parenthesizerRules().parenthesizeLeftSideOfBinary(operatorKind, left); @@ -22667,45 +23259,45 @@ var ts; propagateChildFlags(node.operatorToken) | propagateChildFlags(node.right); if (operatorKind === 60 /* QuestionQuestionToken */) { - node.transformFlags |= 8 /* ContainsES2020 */; + node.transformFlags |= 16 /* ContainsES2020 */; } - else if (operatorKind === 62 /* EqualsToken */) { + else if (operatorKind === 63 /* EqualsToken */) { if (ts.isObjectLiteralExpression(node.left)) { node.transformFlags |= - 256 /* ContainsES2015 */ | - 32 /* ContainsES2018 */ | - 1024 /* ContainsDestructuringAssignment */ | + 512 /* ContainsES2015 */ | + 64 /* ContainsES2018 */ | + 2048 /* ContainsDestructuringAssignment */ | propagateAssignmentPatternFlags(node.left); } else if (ts.isArrayLiteralExpression(node.left)) { node.transformFlags |= - 256 /* ContainsES2015 */ | - 1024 /* ContainsDestructuringAssignment */ | + 512 /* ContainsES2015 */ | + 2048 /* ContainsDestructuringAssignment */ | propagateAssignmentPatternFlags(node.left); } } - else if (operatorKind === 42 /* AsteriskAsteriskToken */ || operatorKind === 66 /* AsteriskAsteriskEqualsToken */) { - node.transformFlags |= 128 /* ContainsES2016 */; + else if (operatorKind === 42 /* AsteriskAsteriskToken */ || operatorKind === 67 /* AsteriskAsteriskEqualsToken */) { + node.transformFlags |= 256 /* ContainsES2016 */; } else if (ts.isLogicalOrCoalescingAssignmentOperator(operatorKind)) { - node.transformFlags |= 4 /* ContainsESNext */; + node.transformFlags |= 8 /* ContainsES2021 */; } return node; } function propagateAssignmentPatternFlags(node) { - if (node.transformFlags & 16384 /* ContainsObjectRestOrSpread */) - return 16384 /* ContainsObjectRestOrSpread */; - if (node.transformFlags & 32 /* ContainsES2018 */) { + if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) + return 32768 /* ContainsObjectRestOrSpread */; + if (node.transformFlags & 64 /* 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 & 16384 /* ContainsObjectRestOrSpread */) { - return 16384 /* ContainsObjectRestOrSpread */; + if (target.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { + return 32768 /* ContainsObjectRestOrSpread */; } - if (target.transformFlags & 32 /* ContainsES2018 */) { + if (target.transformFlags & 64 /* ContainsES2018 */) { var flags_1 = propagateAssignmentPatternFlags(target); if (flags_1) return flags_1; @@ -22725,7 +23317,7 @@ var ts; } // @api function createConditionalExpression(condition, questionToken, whenTrue, colonToken, whenFalse) { - var node = createBaseExpression(217 /* ConditionalExpression */); + var node = createBaseExpression(219 /* ConditionalExpression */); node.condition = parenthesizerRules().parenthesizeConditionOfConditionalExpression(condition); node.questionToken = questionToken !== null && questionToken !== void 0 ? questionToken : createToken(57 /* QuestionToken */); node.whenTrue = parenthesizerRules().parenthesizeBranchOfConditionalExpression(whenTrue); @@ -22751,13 +23343,13 @@ var ts; } // @api function createTemplateExpression(head, templateSpans) { - var node = createBaseExpression(218 /* TemplateExpression */); + var node = createBaseExpression(220 /* TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); node.transformFlags |= propagateChildFlags(node.head) | propagateChildrenFlags(node.templateSpans) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; return node; } // @api @@ -22796,9 +23388,9 @@ var ts; node.text = text; node.rawText = rawText; node.templateFlags = templateFlags & 2048 /* TemplateLiteralLikeFlags */; - node.transformFlags |= 256 /* ContainsES2015 */; + node.transformFlags |= 512 /* ContainsES2015 */; if (node.templateFlags) { - node.transformFlags |= 32 /* ContainsES2018 */; + node.transformFlags |= 64 /* ContainsES2018 */; } return node; } @@ -22821,15 +23413,15 @@ var ts; // @api function createYieldExpression(asteriskToken, expression) { ts.Debug.assert(!asteriskToken || !!expression, "A `YieldExpression` with an asteriskToken must have an expression."); - var node = createBaseExpression(219 /* YieldExpression */); + var node = createBaseExpression(221 /* YieldExpression */); node.expression = expression && parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.asteriskToken = asteriskToken; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.asteriskToken) | - 256 /* ContainsES2015 */ | - 32 /* ContainsES2018 */ | - 262144 /* ContainsYield */; + 512 /* ContainsES2015 */ | + 64 /* ContainsES2018 */ | + 524288 /* ContainsYield */; return node; } // @api @@ -22841,12 +23433,12 @@ var ts; } // @api function createSpreadElement(expression) { - var node = createBaseExpression(220 /* SpreadElement */); + var node = createBaseExpression(222 /* SpreadElement */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 256 /* ContainsES2015 */ | - 8192 /* ContainsRestOrSpread */; + 512 /* ContainsES2015 */ | + 16384 /* ContainsRestOrSpread */; return node; } // @api @@ -22857,8 +23449,8 @@ var ts; } // @api function createClassExpression(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseClassLikeDeclaration(221 /* ClassExpression */, decorators, modifiers, name, typeParameters, heritageClauses, members); - node.transformFlags |= 256 /* ContainsES2015 */; + var node = createBaseClassLikeDeclaration(223 /* ClassExpression */, decorators, modifiers, name, typeParameters, heritageClauses, members); + node.transformFlags |= 512 /* ContainsES2015 */; return node; } // @api @@ -22874,17 +23466,17 @@ var ts; } // @api function createOmittedExpression() { - return createBaseExpression(222 /* OmittedExpression */); + return createBaseExpression(224 /* OmittedExpression */); } // @api function createExpressionWithTypeArguments(expression, typeArguments) { - var node = createBaseNode(223 /* ExpressionWithTypeArguments */); + var node = createBaseNode(225 /* ExpressionWithTypeArguments */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); node.transformFlags |= propagateChildFlags(node.expression) | propagateChildrenFlags(node.typeArguments) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; return node; } // @api @@ -22896,7 +23488,7 @@ var ts; } // @api function createAsExpression(expression, type) { - var node = createBaseExpression(224 /* AsExpression */); + var node = createBaseExpression(226 /* AsExpression */); node.expression = expression; node.type = type; node.transformFlags |= @@ -22914,7 +23506,7 @@ var ts; } // @api function createNonNullExpression(expression) { - var node = createBaseExpression(225 /* NonNullExpression */); + var node = createBaseExpression(227 /* NonNullExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= propagateChildFlags(node.expression) | @@ -22932,7 +23524,7 @@ var ts; } // @api function createNonNullChain(expression) { - var node = createBaseExpression(225 /* NonNullExpression */); + var node = createBaseExpression(227 /* NonNullExpression */); node.flags |= 32 /* OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= @@ -22949,15 +23541,15 @@ var ts; } // @api function createMetaProperty(keywordToken, name) { - var node = createBaseExpression(226 /* MetaProperty */); + var node = createBaseExpression(228 /* MetaProperty */); node.keywordToken = keywordToken; node.name = name; node.transformFlags |= propagateChildFlags(node.name); switch (keywordToken) { - case 102 /* NewKeyword */: - node.transformFlags |= 256 /* ContainsES2015 */; + case 103 /* NewKeyword */: + node.transformFlags |= 512 /* ContainsES2015 */; break; - case 99 /* ImportKeyword */: + case 100 /* ImportKeyword */: node.transformFlags |= 4 /* ContainsESNext */; break; default: @@ -22976,13 +23568,13 @@ var ts; // // @api function createTemplateSpan(expression, literal) { - var node = createBaseNode(228 /* TemplateSpan */); + var node = createBaseNode(230 /* TemplateSpan */); node.expression = expression; node.literal = literal; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.literal) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; return node; } // @api @@ -22994,8 +23586,8 @@ var ts; } // @api function createSemicolonClassElement() { - var node = createBaseNode(229 /* SemicolonClassElement */); - node.transformFlags |= 256 /* ContainsES2015 */; + var node = createBaseNode(231 /* SemicolonClassElement */); + node.transformFlags |= 512 /* ContainsES2015 */; return node; } // @@ -23003,7 +23595,7 @@ var ts; // // @api function createBlock(statements, multiLine) { - var node = createBaseNode(230 /* Block */); + var node = createBaseNode(232 /* Block */); node.statements = createNodeArray(statements); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.statements); @@ -23017,7 +23609,7 @@ var ts; } // @api function createVariableStatement(modifiers, declarationList) { - var node = createBaseDeclaration(232 /* VariableStatement */, /*decorators*/ undefined, modifiers); + var node = createBaseDeclaration(234 /* VariableStatement */, /*decorators*/ undefined, modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; node.transformFlags |= propagateChildFlags(node.declarationList); @@ -23035,11 +23627,11 @@ var ts; } // @api function createEmptyStatement() { - return createBaseNode(231 /* EmptyStatement */); + return createBaseNode(233 /* EmptyStatement */); } // @api function createExpressionStatement(expression) { - var node = createBaseNode(233 /* ExpressionStatement */); + var node = createBaseNode(235 /* ExpressionStatement */); node.expression = parenthesizerRules().parenthesizeExpressionOfExpressionStatement(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -23052,7 +23644,7 @@ var ts; } // @api function createIfStatement(expression, thenStatement, elseStatement) { - var node = createBaseNode(234 /* IfStatement */); + var node = createBaseNode(236 /* IfStatement */); node.expression = expression; node.thenStatement = asEmbeddedStatement(thenStatement); node.elseStatement = asEmbeddedStatement(elseStatement); @@ -23072,7 +23664,7 @@ var ts; } // @api function createDoStatement(statement, expression) { - var node = createBaseNode(235 /* DoStatement */); + var node = createBaseNode(237 /* DoStatement */); node.statement = asEmbeddedStatement(statement); node.expression = expression; node.transformFlags |= @@ -23089,7 +23681,7 @@ var ts; } // @api function createWhileStatement(expression, statement) { - var node = createBaseNode(236 /* WhileStatement */); + var node = createBaseNode(238 /* WhileStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -23106,7 +23698,7 @@ var ts; } // @api function createForStatement(initializer, condition, incrementor, statement) { - var node = createBaseNode(237 /* ForStatement */); + var node = createBaseNode(239 /* ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -23129,7 +23721,7 @@ var ts; } // @api function createForInStatement(initializer, expression, statement) { - var node = createBaseNode(238 /* ForInStatement */); + var node = createBaseNode(240 /* ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = asEmbeddedStatement(statement); @@ -23149,7 +23741,7 @@ var ts; } // @api function createForOfStatement(awaitModifier, initializer, expression, statement) { - var node = createBaseNode(239 /* ForOfStatement */); + var node = createBaseNode(241 /* ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); @@ -23159,9 +23751,9 @@ var ts; propagateChildFlags(node.initializer) | propagateChildFlags(node.expression) | propagateChildFlags(node.statement) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; if (awaitModifier) - node.transformFlags |= 32 /* ContainsES2018 */; + node.transformFlags |= 64 /* ContainsES2018 */; return node; } // @api @@ -23175,11 +23767,11 @@ var ts; } // @api function createContinueStatement(label) { - var node = createBaseNode(240 /* ContinueStatement */); + var node = createBaseNode(242 /* ContinueStatement */); node.label = asName(label); node.transformFlags |= propagateChildFlags(node.label) | - 1048576 /* ContainsHoistedDeclarationOrCompletion */; + 2097152 /* ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -23190,11 +23782,11 @@ var ts; } // @api function createBreakStatement(label) { - var node = createBaseNode(241 /* BreakStatement */); + var node = createBaseNode(243 /* BreakStatement */); node.label = asName(label); node.transformFlags |= propagateChildFlags(node.label) | - 1048576 /* ContainsHoistedDeclarationOrCompletion */; + 2097152 /* ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -23205,13 +23797,13 @@ var ts; } // @api function createReturnStatement(expression) { - var node = createBaseNode(242 /* ReturnStatement */); + var node = createBaseNode(244 /* ReturnStatement */); node.expression = expression; // return in an ES2018 async generator must be awaited node.transformFlags |= propagateChildFlags(node.expression) | - 32 /* ContainsES2018 */ | - 1048576 /* ContainsHoistedDeclarationOrCompletion */; + 64 /* ContainsES2018 */ | + 2097152 /* ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -23222,7 +23814,7 @@ var ts; } // @api function createWithStatement(expression, statement) { - var node = createBaseNode(243 /* WithStatement */); + var node = createBaseNode(245 /* WithStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -23239,7 +23831,7 @@ var ts; } // @api function createSwitchStatement(expression, caseBlock) { - var node = createBaseNode(244 /* SwitchStatement */); + var node = createBaseNode(246 /* SwitchStatement */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.caseBlock = caseBlock; node.transformFlags |= @@ -23256,7 +23848,7 @@ var ts; } // @api function createLabeledStatement(label, statement) { - var node = createBaseNode(245 /* LabeledStatement */); + var node = createBaseNode(247 /* LabeledStatement */); node.label = asName(label); node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -23273,7 +23865,7 @@ var ts; } // @api function createThrowStatement(expression) { - var node = createBaseNode(246 /* ThrowStatement */); + var node = createBaseNode(248 /* ThrowStatement */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -23286,7 +23878,7 @@ var ts; } // @api function createTryStatement(tryBlock, catchClause, finallyBlock) { - var node = createBaseNode(247 /* TryStatement */); + var node = createBaseNode(249 /* TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -23306,11 +23898,11 @@ var ts; } // @api function createDebuggerStatement() { - return createBaseNode(248 /* DebuggerStatement */); + return createBaseNode(250 /* DebuggerStatement */); } // @api function createVariableDeclaration(name, exclamationToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(249 /* VariableDeclaration */, + var node = createBaseVariableLikeDeclaration(251 /* VariableDeclaration */, /*decorators*/ undefined, /*modifiers*/ undefined, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.exclamationToken = exclamationToken; @@ -23332,16 +23924,16 @@ var ts; // @api function createVariableDeclarationList(declarations, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createBaseNode(250 /* VariableDeclarationList */); + var node = createBaseNode(252 /* VariableDeclarationList */); node.flags |= flags & 3 /* BlockScoped */; node.declarations = createNodeArray(declarations); node.transformFlags |= propagateChildrenFlags(node.declarations) | - 1048576 /* ContainsHoistedDeclarationOrCompletion */; + 2097152 /* ContainsHoistedDeclarationOrCompletion */; if (flags & 3 /* BlockScoped */) { node.transformFlags |= - 256 /* ContainsES2015 */ | - 65536 /* ContainsBlockScopedBinding */; + 512 /* ContainsES2015 */ | + 131072 /* ContainsBlockScopedBinding */; } return node; } @@ -23353,7 +23945,7 @@ var ts; } // @api function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(251 /* FunctionDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(253 /* FunctionDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; if (!node.body || ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { node.transformFlags = 1 /* ContainsTypeScript */; @@ -23361,17 +23953,17 @@ var ts; else { node.transformFlags |= propagateChildFlags(node.asteriskToken) | - 1048576 /* ContainsHoistedDeclarationOrCompletion */; + 2097152 /* ContainsHoistedDeclarationOrCompletion */; if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { if (node.asteriskToken) { - node.transformFlags |= 32 /* ContainsES2018 */; + node.transformFlags |= 64 /* ContainsES2018 */; } else { - node.transformFlags |= 64 /* ContainsES2017 */; + node.transformFlags |= 128 /* ContainsES2017 */; } } else if (node.asteriskToken) { - node.transformFlags |= 512 /* ContainsGenerator */; + node.transformFlags |= 1024 /* ContainsGenerator */; } } return node; @@ -23391,13 +23983,13 @@ var ts; } // @api function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseClassLikeDeclaration(252 /* ClassDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses, members); + var node = createBaseClassLikeDeclaration(254 /* ClassDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses, members); if (ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { node.transformFlags = 1 /* ContainsTypeScript */; } else { - node.transformFlags |= 256 /* ContainsES2015 */; - if (node.transformFlags & 2048 /* ContainsTypeScriptClassSyntax */) { + node.transformFlags |= 512 /* ContainsES2015 */; + if (node.transformFlags & 4096 /* ContainsTypeScriptClassSyntax */) { node.transformFlags |= 1 /* ContainsTypeScript */; } } @@ -23416,7 +24008,7 @@ var ts; } // @api function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseInterfaceOrClassLikeDeclaration(253 /* InterfaceDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses); + var node = createBaseInterfaceOrClassLikeDeclaration(255 /* InterfaceDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses); node.members = createNodeArray(members); node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -23434,7 +24026,7 @@ var ts; } // @api function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createBaseGenericNamedDeclaration(254 /* TypeAliasDeclaration */, decorators, modifiers, name, typeParameters); + var node = createBaseGenericNamedDeclaration(256 /* TypeAliasDeclaration */, decorators, modifiers, name, typeParameters); node.type = type; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -23451,12 +24043,12 @@ var ts; } // @api function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createBaseNamedDeclaration(255 /* EnumDeclaration */, decorators, modifiers, name); + var node = createBaseNamedDeclaration(257 /* EnumDeclaration */, decorators, modifiers, name); node.members = createNodeArray(members); node.transformFlags |= propagateChildrenFlags(node.members) | 1 /* ContainsTypeScript */; - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await` + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await` return node; } // @api @@ -23471,7 +24063,7 @@ var ts; // @api function createModuleDeclaration(decorators, modifiers, name, body, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createBaseDeclaration(256 /* ModuleDeclaration */, decorators, modifiers); + var node = createBaseDeclaration(258 /* ModuleDeclaration */, decorators, modifiers); node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 1024 /* GlobalAugmentation */); node.name = name; node.body = body; @@ -23484,7 +24076,7 @@ var ts; propagateChildFlags(node.body) | 1 /* ContainsTypeScript */; } - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`. + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`. return node; } // @api @@ -23498,7 +24090,7 @@ var ts; } // @api function createModuleBlock(statements) { - var node = createBaseNode(257 /* ModuleBlock */); + var node = createBaseNode(259 /* ModuleBlock */); node.statements = createNodeArray(statements); node.transformFlags |= propagateChildrenFlags(node.statements); return node; @@ -23511,7 +24103,7 @@ var ts; } // @api function createCaseBlock(clauses) { - var node = createBaseNode(258 /* CaseBlock */); + var node = createBaseNode(260 /* CaseBlock */); node.clauses = createNodeArray(clauses); node.transformFlags |= propagateChildrenFlags(node.clauses); return node; @@ -23524,7 +24116,7 @@ var ts; } // @api function createNamespaceExportDeclaration(name) { - var node = createBaseNamedDeclaration(259 /* NamespaceExportDeclaration */, + var node = createBaseNamedDeclaration(261 /* NamespaceExportDeclaration */, /*decorators*/ undefined, /*modifiers*/ undefined, name); node.transformFlags = 1 /* ContainsTypeScript */; @@ -23538,13 +24130,13 @@ var ts; } // @api function createImportEqualsDeclaration(decorators, modifiers, isTypeOnly, name, moduleReference) { - var node = createBaseNamedDeclaration(260 /* ImportEqualsDeclaration */, decorators, modifiers, name); + var node = createBaseNamedDeclaration(262 /* ImportEqualsDeclaration */, decorators, modifiers, name); node.isTypeOnly = isTypeOnly; node.moduleReference = moduleReference; node.transformFlags |= propagateChildFlags(node.moduleReference); if (!ts.isExternalModuleReference(node.moduleReference)) node.transformFlags |= 1 /* ContainsTypeScript */; - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // Import= declaration is always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Import= declaration is always parsed in an Await context return node; } // @api @@ -23559,13 +24151,13 @@ var ts; } // @api function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createBaseDeclaration(261 /* ImportDeclaration */, decorators, modifiers); + var node = createBaseDeclaration(263 /* ImportDeclaration */, decorators, modifiers); node.importClause = importClause; node.moduleSpecifier = moduleSpecifier; node.transformFlags |= propagateChildFlags(node.importClause) | propagateChildFlags(node.moduleSpecifier); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23579,7 +24171,7 @@ var ts; } // @api function createImportClause(isTypeOnly, name, namedBindings) { - var node = createBaseNode(262 /* ImportClause */); + var node = createBaseNode(264 /* ImportClause */); node.isTypeOnly = isTypeOnly; node.name = name; node.namedBindings = namedBindings; @@ -23589,7 +24181,7 @@ var ts; if (isTypeOnly) { node.transformFlags |= 1 /* ContainsTypeScript */; } - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23602,10 +24194,10 @@ var ts; } // @api function createNamespaceImport(name) { - var node = createBaseNode(263 /* NamespaceImport */); + var node = createBaseNode(265 /* NamespaceImport */); node.name = name; node.transformFlags |= propagateChildFlags(node.name); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23616,12 +24208,12 @@ var ts; } // @api function createNamespaceExport(name) { - var node = createBaseNode(269 /* NamespaceExport */); + var node = createBaseNode(271 /* NamespaceExport */); node.name = name; node.transformFlags |= propagateChildFlags(node.name) | 4 /* ContainsESNext */; - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23632,10 +24224,10 @@ var ts; } // @api function createNamedImports(elements) { - var node = createBaseNode(264 /* NamedImports */); + var node = createBaseNode(266 /* NamedImports */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23646,13 +24238,13 @@ var ts; } // @api function createImportSpecifier(propertyName, name) { - var node = createBaseNode(265 /* ImportSpecifier */); + var node = createBaseNode(267 /* ImportSpecifier */); node.propertyName = propertyName; node.name = name; node.transformFlags |= propagateChildFlags(node.propertyName) | propagateChildFlags(node.name); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23664,13 +24256,13 @@ var ts; } // @api function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createBaseDeclaration(266 /* ExportAssignment */, decorators, modifiers); + var node = createBaseDeclaration(268 /* ExportAssignment */, decorators, modifiers); node.isExportEquals = isExportEquals; node.expression = isExportEquals - ? parenthesizerRules().parenthesizeRightSideOfBinary(62 /* EqualsToken */, /*leftSide*/ undefined, expression) + ? parenthesizerRules().parenthesizeRightSideOfBinary(63 /* EqualsToken */, /*leftSide*/ undefined, expression) : parenthesizerRules().parenthesizeExpressionOfExportDefault(expression); node.transformFlags |= propagateChildFlags(node.expression); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23683,14 +24275,14 @@ var ts; } // @api function createExportDeclaration(decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier) { - var node = createBaseDeclaration(267 /* ExportDeclaration */, decorators, modifiers); + var node = createBaseDeclaration(269 /* ExportDeclaration */, decorators, modifiers); node.isTypeOnly = isTypeOnly; node.exportClause = exportClause; node.moduleSpecifier = moduleSpecifier; node.transformFlags |= propagateChildFlags(node.exportClause) | propagateChildFlags(node.moduleSpecifier); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23705,10 +24297,10 @@ var ts; } // @api function createNamedExports(elements) { - var node = createBaseNode(268 /* NamedExports */); + var node = createBaseNode(270 /* NamedExports */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23719,13 +24311,13 @@ var ts; } // @api function createExportSpecifier(propertyName, name) { - var node = createBaseNode(270 /* ExportSpecifier */); + var node = createBaseNode(272 /* ExportSpecifier */); node.propertyName = asName(propertyName); node.name = asName(name); node.transformFlags |= propagateChildFlags(node.propertyName) | propagateChildFlags(node.name); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23737,7 +24329,7 @@ var ts; } // @api function createMissingDeclaration() { - var node = createBaseDeclaration(271 /* MissingDeclaration */, + var node = createBaseDeclaration(273 /* MissingDeclaration */, /*decorators*/ undefined, /*modifiers*/ undefined); return node; @@ -23747,10 +24339,10 @@ var ts; // // @api function createExternalModuleReference(expression) { - var node = createBaseNode(272 /* ExternalModuleReference */); + var node = createBaseNode(274 /* ExternalModuleReference */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23792,7 +24384,7 @@ var ts; } // @api function createJSDocFunctionType(parameters, type) { - var node = createBaseSignatureDeclaration(308 /* JSDocFunctionType */, + var node = createBaseSignatureDeclaration(311 /* JSDocFunctionType */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, @@ -23809,7 +24401,7 @@ var ts; // @api function createJSDocTypeLiteral(propertyTags, isArrayType) { if (isArrayType === void 0) { isArrayType = false; } - var node = createBaseNode(312 /* JSDocTypeLiteral */); + var node = createBaseNode(316 /* JSDocTypeLiteral */); node.jsDocPropertyTags = asNodeArray(propertyTags); node.isArrayType = isArrayType; return node; @@ -23823,7 +24415,7 @@ var ts; } // @api function createJSDocTypeExpression(type) { - var node = createBaseNode(301 /* JSDocTypeExpression */); + var node = createBaseNode(303 /* JSDocTypeExpression */); node.type = type; return node; } @@ -23835,7 +24427,7 @@ var ts; } // @api function createJSDocSignature(typeParameters, parameters, type) { - var node = createBaseNode(313 /* JSDocSignature */); + var node = createBaseNode(317 /* JSDocSignature */); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; @@ -23864,7 +24456,7 @@ var ts; } // @api function createJSDocTemplateTag(tagName, constraint, typeParameters, comment) { - var node = createBaseJSDocTag(330 /* JSDocTemplateTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("template"), comment); + var node = createBaseJSDocTag(338 /* JSDocTemplateTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("template"), comment); node.constraint = constraint; node.typeParameters = createNodeArray(typeParameters); return node; @@ -23881,7 +24473,7 @@ var ts; } // @api function createJSDocTypedefTag(tagName, typeExpression, fullName, comment) { - var node = createBaseJSDocTag(331 /* JSDocTypedefTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("typedef"), comment); + var node = createBaseJSDocTag(339 /* JSDocTypedefTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("typedef"), comment); node.typeExpression = typeExpression; node.fullName = fullName; node.name = ts.getJSDocTypeAliasName(fullName); @@ -23899,7 +24491,7 @@ var ts; } // @api function createJSDocParameterTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) { - var node = createBaseJSDocTag(326 /* JSDocParameterTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("param"), comment); + var node = createBaseJSDocTag(334 /* JSDocParameterTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("param"), comment); node.typeExpression = typeExpression; node.name = name; node.isNameFirst = !!isNameFirst; @@ -23920,7 +24512,7 @@ var ts; } // @api function createJSDocPropertyTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) { - var node = createBaseJSDocTag(333 /* JSDocPropertyTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("prop"), comment); + var node = createBaseJSDocTag(341 /* JSDocPropertyTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("prop"), comment); node.typeExpression = typeExpression; node.name = name; node.isNameFirst = !!isNameFirst; @@ -23941,7 +24533,7 @@ var ts; } // @api function createJSDocCallbackTag(tagName, typeExpression, fullName, comment) { - var node = createBaseJSDocTag(324 /* JSDocCallbackTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("callback"), comment); + var node = createBaseJSDocTag(332 /* JSDocCallbackTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("callback"), comment); node.typeExpression = typeExpression; node.fullName = fullName; node.name = ts.getJSDocTypeAliasName(fullName); @@ -23959,7 +24551,7 @@ var ts; } // @api function createJSDocAugmentsTag(tagName, className, comment) { - var node = createBaseJSDocTag(315 /* JSDocAugmentsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("augments"), comment); + var node = createBaseJSDocTag(322 /* JSDocAugmentsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("augments"), comment); node.class = className; return node; } @@ -23974,13 +24566,13 @@ var ts; } // @api function createJSDocImplementsTag(tagName, className, comment) { - var node = createBaseJSDocTag(316 /* JSDocImplementsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("implements"), comment); + var node = createBaseJSDocTag(323 /* JSDocImplementsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("implements"), comment); node.class = className; return node; } // @api function createJSDocSeeTag(tagName, name, comment) { - var node = createBaseJSDocTag(332 /* JSDocSeeTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("see"), comment); + var node = createBaseJSDocTag(340 /* JSDocSeeTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("see"), comment); node.name = name; return node; } @@ -23994,7 +24586,7 @@ var ts; } // @api function createJSDocNameReference(name) { - var node = createBaseNode(302 /* JSDocNameReference */); + var node = createBaseNode(304 /* JSDocNameReference */); node.name = name; return node; } @@ -24005,6 +24597,62 @@ var ts; : node; } // @api + function createJSDocMemberName(left, right) { + var node = createBaseNode(305 /* JSDocMemberName */); + node.left = left; + node.right = right; + node.transformFlags |= + propagateChildFlags(node.left) | + propagateChildFlags(node.right); + return node; + } + // @api + function updateJSDocMemberName(node, left, right) { + return node.left !== left + || node.right !== right + ? update(createJSDocMemberName(left, right), node) + : node; + } + // @api + function createJSDocLink(name, text) { + var node = createBaseNode(318 /* JSDocLink */); + node.name = name; + node.text = text; + return node; + } + // @api + function updateJSDocLink(node, name, text) { + return node.name !== name + ? update(createJSDocLink(name, text), node) + : node; + } + // @api + function createJSDocLinkCode(name, text) { + var node = createBaseNode(319 /* JSDocLinkCode */); + node.name = name; + node.text = text; + return node; + } + // @api + function updateJSDocLinkCode(node, name, text) { + return node.name !== name + ? update(createJSDocLinkCode(name, text), node) + : node; + } + // @api + function createJSDocLinkPlain(name, text) { + var node = createBaseNode(320 /* JSDocLinkPlain */); + node.name = name; + node.text = text; + return node; + } + // @api + function updateJSDocLinkPlain(node, name, text) { + return node.name !== name + ? update(createJSDocLinkPlain(name, text), node) + : node; + } + // @api function updateJSDocImplementsTag(node, tagName, className, comment) { if (tagName === void 0) { tagName = getDefaultTagName(node); } return node.tagName !== tagName @@ -24065,7 +24713,7 @@ var ts; } // @api function createJSDocUnknownTag(tagName, comment) { - var node = createBaseJSDocTag(314 /* JSDocTag */, tagName, comment); + var node = createBaseJSDocTag(321 /* JSDocTag */, tagName, comment); return node; } // @api @@ -24076,8 +24724,20 @@ var ts; : node; } // @api + function createJSDocText(text) { + var node = createBaseNode(315 /* JSDocText */); + node.text = text; + return node; + } + // @api + function updateJSDocText(node, text) { + return node.text !== text + ? update(createJSDocText(text), node) + : node; + } + // @api function createJSDocComment(comment, tags) { - var node = createBaseNode(311 /* JSDocComment */); + var node = createBaseNode(314 /* JSDocComment */); node.comment = comment; node.tags = asNodeArray(tags); return node; @@ -24094,7 +24754,7 @@ var ts; // // @api function createJsxElement(openingElement, children, closingElement) { - var node = createBaseNode(273 /* JsxElement */); + var node = createBaseNode(275 /* JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -24115,7 +24775,7 @@ var ts; } // @api function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createBaseNode(274 /* JsxSelfClosingElement */); + var node = createBaseNode(276 /* JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -24139,7 +24799,7 @@ var ts; } // @api function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createBaseNode(275 /* JsxOpeningElement */); + var node = createBaseNode(277 /* JsxOpeningElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -24163,7 +24823,7 @@ var ts; } // @api function createJsxClosingElement(tagName) { - var node = createBaseNode(276 /* JsxClosingElement */); + var node = createBaseNode(278 /* JsxClosingElement */); node.tagName = tagName; node.transformFlags |= propagateChildFlags(node.tagName) | @@ -24178,7 +24838,7 @@ var ts; } // @api function createJsxFragment(openingFragment, children, closingFragment) { - var node = createBaseNode(277 /* JsxFragment */); + var node = createBaseNode(279 /* JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -24214,19 +24874,19 @@ var ts; } // @api function createJsxOpeningFragment() { - var node = createBaseNode(278 /* JsxOpeningFragment */); + var node = createBaseNode(280 /* JsxOpeningFragment */); node.transformFlags |= 2 /* ContainsJsx */; return node; } // @api function createJsxJsxClosingFragment() { - var node = createBaseNode(279 /* JsxClosingFragment */); + var node = createBaseNode(281 /* JsxClosingFragment */); node.transformFlags |= 2 /* ContainsJsx */; return node; } // @api function createJsxAttribute(name, initializer) { - var node = createBaseNode(280 /* JsxAttribute */); + var node = createBaseNode(282 /* JsxAttribute */); node.name = name; node.initializer = initializer; node.transformFlags |= @@ -24244,7 +24904,7 @@ var ts; } // @api function createJsxAttributes(properties) { - var node = createBaseNode(281 /* JsxAttributes */); + var node = createBaseNode(283 /* JsxAttributes */); node.properties = createNodeArray(properties); node.transformFlags |= propagateChildrenFlags(node.properties) | @@ -24259,7 +24919,7 @@ var ts; } // @api function createJsxSpreadAttribute(expression) { - var node = createBaseNode(282 /* JsxSpreadAttribute */); + var node = createBaseNode(284 /* JsxSpreadAttribute */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression) | @@ -24274,7 +24934,7 @@ var ts; } // @api function createJsxExpression(dotDotDotToken, expression) { - var node = createBaseNode(283 /* JsxExpression */); + var node = createBaseNode(285 /* JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; node.transformFlags |= @@ -24294,7 +24954,7 @@ var ts; // // @api function createCaseClause(expression, statements) { - var node = createBaseNode(284 /* CaseClause */); + var node = createBaseNode(286 /* CaseClause */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.statements = createNodeArray(statements); node.transformFlags |= @@ -24311,7 +24971,7 @@ var ts; } // @api function createDefaultClause(statements) { - var node = createBaseNode(285 /* DefaultClause */); + var node = createBaseNode(287 /* DefaultClause */); node.statements = createNodeArray(statements); node.transformFlags = propagateChildrenFlags(node.statements); return node; @@ -24324,15 +24984,15 @@ var ts; } // @api function createHeritageClause(token, types) { - var node = createBaseNode(286 /* HeritageClause */); + var node = createBaseNode(288 /* HeritageClause */); node.token = token; node.types = createNodeArray(types); node.transformFlags |= propagateChildrenFlags(node.types); switch (token) { - case 93 /* ExtendsKeyword */: - node.transformFlags |= 256 /* ContainsES2015 */; + case 94 /* ExtendsKeyword */: + node.transformFlags |= 512 /* ContainsES2015 */; break; - case 116 /* ImplementsKeyword */: + case 117 /* ImplementsKeyword */: node.transformFlags |= 1 /* ContainsTypeScript */; break; default: @@ -24348,7 +25008,7 @@ var ts; } // @api function createCatchClause(variableDeclaration, block) { - var node = createBaseNode(287 /* CatchClause */); + var node = createBaseNode(289 /* CatchClause */); variableDeclaration = !ts.isString(variableDeclaration) ? variableDeclaration : createVariableDeclaration(variableDeclaration, /*exclamationToken*/ undefined, /*type*/ undefined, @@ -24359,7 +25019,7 @@ var ts; propagateChildFlags(node.variableDeclaration) | propagateChildFlags(node.block); if (!variableDeclaration) - node.transformFlags |= 16 /* ContainsES2019 */; + node.transformFlags |= 32 /* ContainsES2019 */; return node; } // @api @@ -24374,7 +25034,7 @@ var ts; // // @api function createPropertyAssignment(name, initializer) { - var node = createBaseNamedDeclaration(288 /* PropertyAssignment */, + var node = createBaseNamedDeclaration(290 /* PropertyAssignment */, /*decorators*/ undefined, /*modifiers*/ undefined, name); node.initializer = parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); @@ -24404,13 +25064,13 @@ var ts; } // @api function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createBaseNamedDeclaration(289 /* ShorthandPropertyAssignment */, + var node = createBaseNamedDeclaration(291 /* ShorthandPropertyAssignment */, /*decorators*/ undefined, /*modifiers*/ undefined, name); node.objectAssignmentInitializer = objectAssignmentInitializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(objectAssignmentInitializer); node.transformFlags |= propagateChildFlags(node.objectAssignmentInitializer) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; return node; } function finishUpdateShorthandPropertyAssignment(updated, original) { @@ -24436,12 +25096,12 @@ var ts; } // @api function createSpreadAssignment(expression) { - var node = createBaseNode(290 /* SpreadAssignment */); + var node = createBaseNode(292 /* SpreadAssignment */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 32 /* ContainsES2018 */ | - 16384 /* ContainsObjectRestOrSpread */; + 64 /* ContainsES2018 */ | + 32768 /* ContainsObjectRestOrSpread */; return node; } // @api @@ -24455,7 +25115,7 @@ var ts; // // @api function createEnumMember(name, initializer) { - var node = createBaseNode(291 /* EnumMember */); + var node = createBaseNode(293 /* EnumMember */); node.name = asName(name); node.initializer = initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); node.transformFlags |= @@ -24476,7 +25136,7 @@ var ts; // // @api function createSourceFile(statements, endOfFileToken, flags) { - var node = baseFactory.createBaseSourceFileNode(297 /* SourceFile */); + var node = baseFactory.createBaseSourceFileNode(299 /* SourceFile */); node.statements = createNodeArray(statements); node.endOfFileToken = endOfFileToken; node.flags |= flags; @@ -24493,7 +25153,7 @@ var ts; return node; } function cloneSourceFileWithChanges(source, statements, isDeclarationFile, referencedFiles, typeReferences, hasNoDefaultLib, libReferences) { - var node = baseFactory.createBaseSourceFileNode(297 /* SourceFile */); + var node = baseFactory.createBaseSourceFileNode(299 /* SourceFile */); for (var p in source) { if (p === "emitNode" || ts.hasProperty(node, p) || !ts.hasProperty(source, p)) continue; @@ -24531,7 +25191,7 @@ var ts; // @api function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = createBaseNode(298 /* Bundle */); + var node = createBaseNode(300 /* Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; @@ -24546,7 +25206,7 @@ var ts; } // @api function createUnparsedSource(prologues, syntheticReferences, texts) { - var node = createBaseNode(299 /* UnparsedSource */); + var node = createBaseNode(301 /* UnparsedSource */); node.prologues = prologues; node.syntheticReferences = syntheticReferences; node.texts = texts; @@ -24564,28 +25224,28 @@ var ts; } // @api function createUnparsedPrologue(data) { - return createBaseUnparsedNode(292 /* UnparsedPrologue */, data); + return createBaseUnparsedNode(294 /* UnparsedPrologue */, data); } // @api function createUnparsedPrepend(data, texts) { - var node = createBaseUnparsedNode(293 /* UnparsedPrepend */, data); + var node = createBaseUnparsedNode(295 /* UnparsedPrepend */, data); node.texts = texts; return node; } // @api function createUnparsedTextLike(data, internal) { - return createBaseUnparsedNode(internal ? 295 /* UnparsedInternalText */ : 294 /* UnparsedText */, data); + return createBaseUnparsedNode(internal ? 297 /* UnparsedInternalText */ : 296 /* UnparsedText */, data); } // @api function createUnparsedSyntheticReference(section) { - var node = createBaseNode(296 /* UnparsedSyntheticReference */); + var node = createBaseNode(298 /* UnparsedSyntheticReference */); node.data = section.data; node.section = section; return node; } // @api function createInputFiles() { - var node = createBaseNode(300 /* InputFiles */); + var node = createBaseNode(302 /* InputFiles */); node.javascriptText = ""; node.declarationText = ""; return node; @@ -24596,7 +25256,7 @@ var ts; // @api function createSyntheticExpression(type, isSpread, tupleNameSource) { if (isSpread === void 0) { isSpread = false; } - var node = createBaseNode(227 /* SyntheticExpression */); + var node = createBaseNode(229 /* SyntheticExpression */); node.type = type; node.isSpread = isSpread; node.tupleNameSource = tupleNameSource; @@ -24604,7 +25264,7 @@ var ts; } // @api function createSyntaxList(children) { - var node = createBaseNode(334 /* SyntaxList */); + var node = createBaseNode(342 /* SyntaxList */); node._children = children; return node; } @@ -24619,7 +25279,7 @@ var ts; */ // @api function createNotEmittedStatement(original) { - var node = createBaseNode(335 /* NotEmittedStatement */); + var node = createBaseNode(343 /* NotEmittedStatement */); node.original = original; ts.setTextRange(node, original); return node; @@ -24633,7 +25293,7 @@ var ts; */ // @api function createPartiallyEmittedExpression(expression, original) { - var node = createBaseNode(336 /* PartiallyEmittedExpression */); + var node = createBaseNode(344 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; node.transformFlags |= @@ -24661,7 +25321,7 @@ var ts; } // @api function createCommaListExpression(elements) { - var node = createBaseNode(337 /* CommaListExpression */); + var node = createBaseNode(345 /* CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); node.transformFlags |= propagateChildrenFlags(node.elements); return node; @@ -24678,7 +25338,7 @@ var ts; */ // @api function createEndOfDeclarationMarker(original) { - var node = createBaseNode(339 /* EndOfDeclarationMarker */); + var node = createBaseNode(347 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -24689,14 +25349,14 @@ var ts; */ // @api function createMergeDeclarationMarker(original) { - var node = createBaseNode(338 /* MergeDeclarationMarker */); + var node = createBaseNode(346 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; } // @api function createSyntheticReferenceExpression(expression, thisArg) { - var node = createBaseNode(340 /* SyntheticReferenceExpression */); + var node = createBaseNode(348 /* SyntheticReferenceExpression */); node.expression = expression; node.thisArg = thisArg; node.transformFlags |= @@ -24718,9 +25378,9 @@ var ts; if (node === undefined) { return node; } - var clone = ts.isSourceFile(node) ? baseFactory.createBaseSourceFileNode(297 /* SourceFile */) : - ts.isIdentifier(node) ? baseFactory.createBaseIdentifierNode(78 /* Identifier */) : - ts.isPrivateIdentifier(node) ? baseFactory.createBasePrivateIdentifierNode(79 /* PrivateIdentifier */) : + var clone = ts.isSourceFile(node) ? baseFactory.createBaseSourceFileNode(299 /* SourceFile */) : + ts.isIdentifier(node) ? baseFactory.createBaseIdentifierNode(79 /* Identifier */) : + ts.isPrivateIdentifier(node) ? baseFactory.createBasePrivateIdentifierNode(80 /* PrivateIdentifier */) : !ts.isNodeKind(node.kind) ? baseFactory.createBaseTokenNode(node.kind) : baseFactory.createBaseNode(node.kind); clone.flags |= (node.flags & ~8 /* Synthesized */); @@ -24825,11 +25485,11 @@ var ts; } function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 207 /* ParenthesizedExpression */: return updateParenthesizedExpression(outerExpression, expression); - case 206 /* TypeAssertionExpression */: return updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 224 /* AsExpression */: return updateAsExpression(outerExpression, expression, outerExpression.type); - case 225 /* NonNullExpression */: return updateNonNullExpression(outerExpression, expression); - case 336 /* PartiallyEmittedExpression */: return updatePartiallyEmittedExpression(outerExpression, expression); + case 209 /* ParenthesizedExpression */: return updateParenthesizedExpression(outerExpression, expression); + case 208 /* TypeAssertionExpression */: return updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 226 /* AsExpression */: return updateAsExpression(outerExpression, expression, outerExpression.type); + case 227 /* NonNullExpression */: return updateNonNullExpression(outerExpression, expression); + case 344 /* PartiallyEmittedExpression */: return updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -24876,20 +25536,20 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = ts.skipParentheses(node); switch (target.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return cacheIdentifiers; - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: return false; - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -25292,23 +25952,24 @@ var ts; } function getDefaultTagNameForKind(kind) { switch (kind) { - case 329 /* JSDocTypeTag */: return "type"; - case 327 /* JSDocReturnTag */: return "returns"; - case 328 /* JSDocThisTag */: return "this"; - case 325 /* JSDocEnumTag */: return "enum"; - case 317 /* JSDocAuthorTag */: return "author"; - case 319 /* JSDocClassTag */: return "class"; - case 320 /* JSDocPublicTag */: return "public"; - case 321 /* JSDocPrivateTag */: return "private"; - case 322 /* JSDocProtectedTag */: return "protected"; - case 323 /* JSDocReadonlyTag */: return "readonly"; - case 330 /* JSDocTemplateTag */: return "template"; - case 331 /* JSDocTypedefTag */: return "typedef"; - case 326 /* JSDocParameterTag */: return "param"; - case 333 /* JSDocPropertyTag */: return "prop"; - case 324 /* JSDocCallbackTag */: return "callback"; - case 315 /* JSDocAugmentsTag */: return "augments"; - case 316 /* JSDocImplementsTag */: return "implements"; + case 337 /* JSDocTypeTag */: return "type"; + case 335 /* JSDocReturnTag */: return "returns"; + case 336 /* JSDocThisTag */: return "this"; + case 333 /* JSDocEnumTag */: return "enum"; + case 324 /* JSDocAuthorTag */: return "author"; + case 326 /* JSDocClassTag */: return "class"; + case 327 /* JSDocPublicTag */: return "public"; + case 328 /* JSDocPrivateTag */: return "private"; + case 329 /* JSDocProtectedTag */: return "protected"; + case 330 /* JSDocReadonlyTag */: return "readonly"; + case 331 /* JSDocOverrideTag */: return "override"; + case 338 /* JSDocTemplateTag */: return "template"; + case 339 /* JSDocTypedefTag */: return "typedef"; + case 334 /* JSDocParameterTag */: return "param"; + case 341 /* JSDocPropertyTag */: return "prop"; + case 332 /* JSDocCallbackTag */: return "callback"; + case 322 /* JSDocAugmentsTag */: return "augments"; + case 323 /* JSDocImplementsTag */: return "implements"; default: return ts.Debug.fail("Unsupported kind: " + ts.Debug.formatSyntaxKind(kind)); } @@ -25361,10 +26022,10 @@ var ts; } function propagateIdentifierNameFlags(node) { // An IdentifierName is allowed to be `await` - return propagateChildFlags(node) & ~8388608 /* ContainsPossibleTopLevelAwait */; + return propagateChildFlags(node) & ~16777216 /* ContainsPossibleTopLevelAwait */; } function propagatePropertyNameFlagsOfChild(node, transformFlags) { - return transformFlags | (node.transformFlags & 4096 /* PropertyNamePropagatingFlags */); + return transformFlags | (node.transformFlags & 8192 /* PropertyNamePropagatingFlags */); } function propagateChildFlags(child) { if (!child) @@ -25388,69 +26049,69 @@ var ts; */ /* @internal */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 172 /* FirstTypeNode */ && kind <= 195 /* LastTypeNode */) { + if (kind >= 174 /* FirstTypeNode */ && kind <= 197 /* LastTypeNode */) { return -2 /* TypeExcludes */; } switch (kind) { - case 203 /* CallExpression */: - case 204 /* NewExpression */: - case 199 /* ArrayLiteralExpression */: - return 536879104 /* ArrayLiteralOrCallOrNewExcludes */; - case 256 /* ModuleDeclaration */: - return 546379776 /* ModuleExcludes */; - case 160 /* Parameter */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: + case 201 /* ArrayLiteralExpression */: + return 536887296 /* ArrayLiteralOrCallOrNewExcludes */; + case 258 /* ModuleDeclaration */: + return 555888640 /* ModuleExcludes */; + case 162 /* Parameter */: return 536870912 /* ParameterExcludes */; - case 209 /* ArrowFunction */: - return 547309568 /* ArrowFunctionExcludes */; - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: - return 547313664 /* FunctionExcludes */; - case 250 /* VariableDeclarationList */: - return 537018368 /* VariableDeclarationListExcludes */; - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - return 536905728 /* ClassExcludes */; - case 166 /* Constructor */: - return 547311616 /* ConstructorExcludes */; - case 163 /* PropertyDeclaration */: - return 536875008 /* PropertyExcludes */; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - return 538923008 /* MethodOrAccessorExcludes */; - case 128 /* AnyKeyword */: - case 144 /* NumberKeyword */: - case 155 /* BigIntKeyword */: - case 141 /* NeverKeyword */: - case 147 /* StringKeyword */: - case 145 /* ObjectKeyword */: - case 131 /* BooleanKeyword */: - case 148 /* SymbolKeyword */: - case 113 /* VoidKeyword */: - case 159 /* TypeParameter */: - case 162 /* PropertySignature */: - case 164 /* MethodSignature */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 211 /* ArrowFunction */: + return 557748224 /* ArrowFunctionExcludes */; + case 210 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + return 557756416 /* FunctionExcludes */; + case 252 /* VariableDeclarationList */: + return 537165824 /* VariableDeclarationListExcludes */; + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + return 536940544 /* ClassExcludes */; + case 168 /* Constructor */: + return 557752320 /* ConstructorExcludes */; + case 165 /* PropertyDeclaration */: + return 536879104 /* PropertyExcludes */; + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + return 540975104 /* MethodOrAccessorExcludes */; + case 129 /* AnyKeyword */: + case 145 /* NumberKeyword */: + case 156 /* BigIntKeyword */: + case 142 /* NeverKeyword */: + case 148 /* StringKeyword */: + case 146 /* ObjectKeyword */: + case 132 /* BooleanKeyword */: + case 149 /* SymbolKeyword */: + case 114 /* VoidKeyword */: + case 161 /* TypeParameter */: + case 164 /* PropertySignature */: + case 166 /* MethodSignature */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 173 /* IndexSignature */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: return -2 /* TypeExcludes */; - case 200 /* ObjectLiteralExpression */: - return 536922112 /* ObjectLiteralExcludes */; - case 287 /* CatchClause */: - return 536887296 /* CatchClauseExcludes */; - case 196 /* ObjectBindingPattern */: - case 197 /* ArrayBindingPattern */: - return 536879104 /* BindingPatternExcludes */; - case 206 /* TypeAssertionExpression */: - case 224 /* AsExpression */: - case 336 /* PartiallyEmittedExpression */: - case 207 /* ParenthesizedExpression */: - case 105 /* SuperKeyword */: + case 202 /* ObjectLiteralExpression */: + return 536973312 /* ObjectLiteralExcludes */; + case 289 /* CatchClause */: + return 536903680 /* CatchClauseExcludes */; + case 198 /* ObjectBindingPattern */: + case 199 /* ArrayBindingPattern */: + return 536887296 /* BindingPatternExcludes */; + case 208 /* TypeAssertionExpression */: + case 226 /* AsExpression */: + case 344 /* PartiallyEmittedExpression */: + case 209 /* ParenthesizedExpression */: + case 106 /* SuperKeyword */: return 536870912 /* OuterExpressionExcludes */; - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: return 536870912 /* PropertyAccessExcludes */; default: return 536870912 /* NodeExcludes */; @@ -25749,7 +26410,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 === 297 /* SourceFile */) { + if (node.kind === 299 /* 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."); @@ -26236,13 +26897,27 @@ var ts; /*typeArguments*/ undefined, [moduleExpression, exportsExpression]); } // Class Fields Helpers - function createClassPrivateFieldGetHelper(receiver, privateField) { + function createClassPrivateFieldGetHelper(receiver, state, kind, f) { context.requestEmitHelper(ts.classPrivateFieldGetHelper); - return factory.createCallExpression(getUnscopedHelperName("__classPrivateFieldGet"), /*typeArguments*/ undefined, [receiver, privateField]); + var args; + if (!f) { + args = [receiver, state, factory.createStringLiteral(kind)]; + } + else { + args = [receiver, state, factory.createStringLiteral(kind), f]; + } + return factory.createCallExpression(getUnscopedHelperName("__classPrivateFieldGet"), /*typeArguments*/ undefined, args); } - function createClassPrivateFieldSetHelper(receiver, privateField, value) { + function createClassPrivateFieldSetHelper(receiver, state, value, kind, f) { context.requestEmitHelper(ts.classPrivateFieldSetHelper); - return factory.createCallExpression(getUnscopedHelperName("__classPrivateFieldSet"), /*typeArguments*/ undefined, [receiver, privateField, value]); + var args; + if (!f) { + args = [receiver, state, value, factory.createStringLiteral(kind)]; + } + else { + args = [receiver, state, value, factory.createStringLiteral(kind), f]; + } + return factory.createCallExpression(getUnscopedHelperName("__classPrivateFieldSet"), /*typeArguments*/ undefined, args); } } ts.createEmitHelperFactory = createEmitHelperFactory; @@ -26482,7 +27157,6 @@ var ts; scoped: false, text: "\n var __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n };" }; - // emit output for the __export helper function ts.exportStarHelper = { name: "typescript:export-star", importName: "__exportStar", @@ -26491,18 +27165,116 @@ var ts; priority: 2, text: "\n var __exportStar = (this && this.__exportStar) || function(m, exports) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\n };" }; - // Class fields helpers + /** + * Parameters: + * @param receiver — The object from which the private member will be read. + * @param state — One of the following: + * - A WeakMap used to read a private instance field. + * - A WeakSet used as an instance brand for private instance methods and accessors. + * - A function value that should be the undecorated class constructor used to brand check private static fields, methods, and accessors. + * @param kind — (optional pre TS 4.3, required for TS 4.3+) One of the following values: + * - undefined — Indicates a private instance field (pre TS 4.3). + * - "f" — Indicates a private field (instance or static). + * - "m" — Indicates a private method (instance or static). + * - "a" — Indicates a private accessor (instance or static). + * @param f — (optional pre TS 4.3) Depends on the arguments for state and kind: + * - If kind is "m", this should be the function corresponding to the static or instance method. + * - If kind is "a", this should be the function corresponding to the getter method, or undefined if the getter was not defined. + * - If kind is "f" and state is a function, this should be an object holding the value of a static field, or undefined if the static field declaration has not yet been evaluated. + * Usage: + * This helper will only ever be used by the compiler in the following ways: + * + * Reading from a private instance field (pre TS 4.3): + * __classPrivateFieldGet(, ) + * + * Reading from a private instance field (TS 4.3+): + * __classPrivateFieldGet(, , "f") + * + * Reading from a private instance get accessor (when defined, TS 4.3+): + * __classPrivateFieldGet(, , "a", ) + * + * Reading from a private instance get accessor (when not defined, TS 4.3+): + * __classPrivateFieldGet(, , "a", void 0) + * NOTE: This always results in a runtime error. + * + * Reading from a private instance method (TS 4.3+): + * __classPrivateFieldGet(, , "m", ) + * + * Reading from a private static field (TS 4.3+): + * __classPrivateFieldGet(, , "f", <{ value: any }>) + * + * Reading from a private static get accessor (when defined, TS 4.3+): + * __classPrivateFieldGet(, , "a", ) + * + * Reading from a private static get accessor (when not defined, TS 4.3+): + * __classPrivateFieldGet(, , "a", void 0) + * NOTE: This always results in a runtime error. + * + * Reading from a private static method (TS 4.3+): + * __classPrivateFieldGet(, , "m", ) + */ ts.classPrivateFieldGetHelper = { name: "typescript:classPrivateFieldGet", importName: "__classPrivateFieldGet", scoped: false, - text: "\n var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, privateMap) {\n if (!privateMap.has(receiver)) {\n throw new TypeError(\"attempted to get private field on non-instance\");\n }\n return privateMap.get(receiver);\n };" + text: "\n var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n };" }; + /** + * Parameters: + * @param receiver — The object on which the private member will be set. + * @param state — One of the following: + * - A WeakMap used to store a private instance field. + * - A WeakSet used as an instance brand for private instance methods and accessors. + * - A function value that should be the undecorated class constructor used to brand check private static fields, methods, and accessors. + * @param value — The value to set. + * @param kind — (optional pre TS 4.3, required for TS 4.3+) One of the following values: + * - undefined — Indicates a private instance field (pre TS 4.3). + * - "f" — Indicates a private field (instance or static). + * - "m" — Indicates a private method (instance or static). + * - "a" — Indicates a private accessor (instance or static). + * @param f — (optional pre TS 4.3) Depends on the arguments for state and kind: + * - If kind is "m", this should be the function corresponding to the static or instance method. + * - If kind is "a", this should be the function corresponding to the setter method, or undefined if the setter was not defined. + * - If kind is "f" and state is a function, this should be an object holding the value of a static field, or undefined if the static field declaration has not yet been evaluated. + * Usage: + * This helper will only ever be used by the compiler in the following ways: + * + * Writing to a private instance field (pre TS 4.3): + * __classPrivateFieldSet(, , ) + * + * Writing to a private instance field (TS 4.3+): + * __classPrivateFieldSet(, , , "f") + * + * Writing to a private instance set accessor (when defined, TS 4.3+): + * __classPrivateFieldSet(, , , "a", ) + * + * Writing to a private instance set accessor (when not defined, TS 4.3+): + * __classPrivateFieldSet(, , , "a", void 0) + * NOTE: This always results in a runtime error. + * + * Writing to a private instance method (TS 4.3+): + * __classPrivateFieldSet(, , , "m", ) + * NOTE: This always results in a runtime error. + * + * Writing to a private static field (TS 4.3+): + * __classPrivateFieldSet(, , , "f", <{ value: any }>) + * + * Writing to a private static set accessor (when defined, TS 4.3+): + * __classPrivateFieldSet(, , , "a", ) + * + * Writing to a private static set accessor (when not defined, TS 4.3+): + * __classPrivateFieldSet(, , , "a", void 0) + * NOTE: This always results in a runtime error. + * + * Writing to a private static method (TS 4.3+): + * __classPrivateFieldSet(, , , "m", ) + * NOTE: This always results in a runtime error. + */ ts.classPrivateFieldSetHelper = { name: "typescript:classPrivateFieldSet", importName: "__classPrivateFieldSet", scoped: false, - text: "\n var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, privateMap, value) {\n if (!privateMap.has(receiver)) {\n throw new TypeError(\"attempted to set private field on non-instance\");\n }\n privateMap.set(receiver, value);\n return value;\n };" + text: "\n var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\n };" }; var allUnscopedEmitHelpers; function getAllUnscopedEmitHelpers() { @@ -26591,626 +27363,688 @@ var ts; return node.kind === 17 /* TemplateTail */; } ts.isTemplateTail = isTemplateTail; + // Punctuation + function isDotDotDotToken(node) { + return node.kind === 25 /* DotDotDotToken */; + } + ts.isDotDotDotToken = isDotDotDotToken; + /*@internal*/ + function isCommaToken(node) { + return node.kind === 27 /* CommaToken */; + } + ts.isCommaToken = isCommaToken; + function isPlusToken(node) { + return node.kind === 39 /* PlusToken */; + } + ts.isPlusToken = isPlusToken; + function isMinusToken(node) { + return node.kind === 40 /* MinusToken */; + } + ts.isMinusToken = isMinusToken; + function isAsteriskToken(node) { + return node.kind === 41 /* AsteriskToken */; + } + ts.isAsteriskToken = isAsteriskToken; + /*@internal*/ + function isExclamationToken(node) { + return node.kind === 53 /* ExclamationToken */; + } + ts.isExclamationToken = isExclamationToken; + /*@internal*/ + function isQuestionToken(node) { + return node.kind === 57 /* QuestionToken */; + } + ts.isQuestionToken = isQuestionToken; + /*@internal*/ + function isColonToken(node) { + return node.kind === 58 /* ColonToken */; + } + ts.isColonToken = isColonToken; + /*@internal*/ + function isQuestionDotToken(node) { + return node.kind === 28 /* QuestionDotToken */; + } + ts.isQuestionDotToken = isQuestionDotToken; + /*@internal*/ + function isEqualsGreaterThanToken(node) { + return node.kind === 38 /* EqualsGreaterThanToken */; + } + ts.isEqualsGreaterThanToken = isEqualsGreaterThanToken; // Identifiers function isIdentifier(node) { - return node.kind === 78 /* Identifier */; + return node.kind === 79 /* Identifier */; } ts.isIdentifier = isIdentifier; - // Names - function isQualifiedName(node) { - return node.kind === 157 /* QualifiedName */; - } - ts.isQualifiedName = isQualifiedName; - function isComputedPropertyName(node) { - return node.kind === 158 /* ComputedPropertyName */; - } - ts.isComputedPropertyName = isComputedPropertyName; function isPrivateIdentifier(node) { - return node.kind === 79 /* PrivateIdentifier */; + return node.kind === 80 /* PrivateIdentifier */; } ts.isPrivateIdentifier = isPrivateIdentifier; - // Tokens + // Reserved Words + /* @internal */ + function isExportModifier(node) { + return node.kind === 93 /* ExportKeyword */; + } + ts.isExportModifier = isExportModifier; + /* @internal */ + function isAsyncModifier(node) { + return node.kind === 130 /* AsyncKeyword */; + } + ts.isAsyncModifier = isAsyncModifier; + /* @internal */ + function isAssertsKeyword(node) { + return node.kind === 128 /* AssertsKeyword */; + } + ts.isAssertsKeyword = isAssertsKeyword; + /* @internal */ + function isAwaitKeyword(node) { + return node.kind === 131 /* AwaitKeyword */; + } + ts.isAwaitKeyword = isAwaitKeyword; + /* @internal */ + function isReadonlyKeyword(node) { + return node.kind === 143 /* ReadonlyKeyword */; + } + ts.isReadonlyKeyword = isReadonlyKeyword; + /* @internal */ + function isStaticModifier(node) { + return node.kind === 124 /* StaticKeyword */; + } + ts.isStaticModifier = isStaticModifier; /*@internal*/ function isSuperKeyword(node) { - return node.kind === 105 /* SuperKeyword */; + return node.kind === 106 /* SuperKeyword */; } ts.isSuperKeyword = isSuperKeyword; /*@internal*/ function isImportKeyword(node) { - return node.kind === 99 /* ImportKeyword */; + return node.kind === 100 /* ImportKeyword */; } ts.isImportKeyword = isImportKeyword; - /*@internal*/ - function isCommaToken(node) { - return node.kind === 27 /* CommaToken */; - } - ts.isCommaToken = isCommaToken; - /*@internal*/ - function isQuestionToken(node) { - return node.kind === 57 /* QuestionToken */; + // Names + function isQualifiedName(node) { + return node.kind === 159 /* QualifiedName */; } - ts.isQuestionToken = isQuestionToken; - /*@internal*/ - function isExclamationToken(node) { - return node.kind === 53 /* ExclamationToken */; + ts.isQualifiedName = isQualifiedName; + function isComputedPropertyName(node) { + return node.kind === 160 /* ComputedPropertyName */; } - ts.isExclamationToken = isExclamationToken; + ts.isComputedPropertyName = isComputedPropertyName; // Signature elements function isTypeParameterDeclaration(node) { - return node.kind === 159 /* TypeParameter */; + return node.kind === 161 /* TypeParameter */; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; // TODO(rbuckton): Rename to 'isParameterDeclaration' function isParameter(node) { - return node.kind === 160 /* Parameter */; + return node.kind === 162 /* Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 161 /* Decorator */; + return node.kind === 163 /* Decorator */; } ts.isDecorator = isDecorator; // TypeMember function isPropertySignature(node) { - return node.kind === 162 /* PropertySignature */; + return node.kind === 164 /* PropertySignature */; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 163 /* PropertyDeclaration */; + return node.kind === 165 /* PropertyDeclaration */; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 164 /* MethodSignature */; + return node.kind === 166 /* MethodSignature */; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 165 /* MethodDeclaration */; + return node.kind === 167 /* MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isConstructorDeclaration(node) { - return node.kind === 166 /* Constructor */; + return node.kind === 168 /* Constructor */; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 167 /* GetAccessor */; + return node.kind === 169 /* GetAccessor */; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 168 /* SetAccessor */; + return node.kind === 170 /* SetAccessor */; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 169 /* CallSignature */; + return node.kind === 171 /* CallSignature */; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 170 /* ConstructSignature */; + return node.kind === 172 /* ConstructSignature */; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 171 /* IndexSignature */; + return node.kind === 173 /* IndexSignature */; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; // Type function isTypePredicateNode(node) { - return node.kind === 172 /* TypePredicate */; + return node.kind === 174 /* TypePredicate */; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 173 /* TypeReference */; + return node.kind === 175 /* TypeReference */; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 174 /* FunctionType */; + return node.kind === 176 /* FunctionType */; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 175 /* ConstructorType */; + return node.kind === 177 /* ConstructorType */; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 176 /* TypeQuery */; + return node.kind === 178 /* TypeQuery */; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 177 /* TypeLiteral */; + return node.kind === 179 /* TypeLiteral */; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 178 /* ArrayType */; + return node.kind === 180 /* ArrayType */; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 179 /* TupleType */; + return node.kind === 181 /* TupleType */; } ts.isTupleTypeNode = isTupleTypeNode; function isNamedTupleMember(node) { - return node.kind === 192 /* NamedTupleMember */; + return node.kind === 194 /* NamedTupleMember */; } ts.isNamedTupleMember = isNamedTupleMember; function isOptionalTypeNode(node) { - return node.kind === 180 /* OptionalType */; + return node.kind === 182 /* OptionalType */; } ts.isOptionalTypeNode = isOptionalTypeNode; function isRestTypeNode(node) { - return node.kind === 181 /* RestType */; + return node.kind === 183 /* RestType */; } ts.isRestTypeNode = isRestTypeNode; function isUnionTypeNode(node) { - return node.kind === 182 /* UnionType */; + return node.kind === 184 /* UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 183 /* IntersectionType */; + return node.kind === 185 /* IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 184 /* ConditionalType */; + return node.kind === 186 /* ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 185 /* InferType */; + return node.kind === 187 /* InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 186 /* ParenthesizedType */; + return node.kind === 188 /* ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 187 /* ThisType */; + return node.kind === 189 /* ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 188 /* TypeOperator */; + return node.kind === 190 /* TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 189 /* IndexedAccessType */; + return node.kind === 191 /* IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 190 /* MappedType */; + return node.kind === 192 /* MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 191 /* LiteralType */; + return node.kind === 193 /* LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 195 /* ImportType */; + return node.kind === 197 /* ImportType */; } ts.isImportTypeNode = isImportTypeNode; function isTemplateLiteralTypeSpan(node) { - return node.kind === 194 /* TemplateLiteralTypeSpan */; + return node.kind === 196 /* TemplateLiteralTypeSpan */; } ts.isTemplateLiteralTypeSpan = isTemplateLiteralTypeSpan; function isTemplateLiteralTypeNode(node) { - return node.kind === 193 /* TemplateLiteralType */; + return node.kind === 195 /* TemplateLiteralType */; } ts.isTemplateLiteralTypeNode = isTemplateLiteralTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 196 /* ObjectBindingPattern */; + return node.kind === 198 /* ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 197 /* ArrayBindingPattern */; + return node.kind === 199 /* ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 198 /* BindingElement */; + return node.kind === 200 /* BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 199 /* ArrayLiteralExpression */; + return node.kind === 201 /* ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 200 /* ObjectLiteralExpression */; + return node.kind === 202 /* ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 201 /* PropertyAccessExpression */; + return node.kind === 203 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 202 /* ElementAccessExpression */; + return node.kind === 204 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 203 /* CallExpression */; + return node.kind === 205 /* CallExpression */; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 204 /* NewExpression */; + return node.kind === 206 /* NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 205 /* TaggedTemplateExpression */; + return node.kind === 207 /* TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertionExpression(node) { - return node.kind === 206 /* TypeAssertionExpression */; + return node.kind === 208 /* TypeAssertionExpression */; } ts.isTypeAssertionExpression = isTypeAssertionExpression; function isParenthesizedExpression(node) { - return node.kind === 207 /* ParenthesizedExpression */; + return node.kind === 209 /* ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function isFunctionExpression(node) { - return node.kind === 208 /* FunctionExpression */; + return node.kind === 210 /* FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 209 /* ArrowFunction */; + return node.kind === 211 /* ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 210 /* DeleteExpression */; + return node.kind === 212 /* DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 211 /* TypeOfExpression */; + return node.kind === 213 /* TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 212 /* VoidExpression */; + return node.kind === 214 /* VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 213 /* AwaitExpression */; + return node.kind === 215 /* AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 214 /* PrefixUnaryExpression */; + return node.kind === 216 /* PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 215 /* PostfixUnaryExpression */; + return node.kind === 217 /* PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 216 /* BinaryExpression */; + return node.kind === 218 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 217 /* ConditionalExpression */; + return node.kind === 219 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 218 /* TemplateExpression */; + return node.kind === 220 /* TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 219 /* YieldExpression */; + return node.kind === 221 /* YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 220 /* SpreadElement */; + return node.kind === 222 /* SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 221 /* ClassExpression */; + return node.kind === 223 /* ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 222 /* OmittedExpression */; + return node.kind === 224 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 223 /* ExpressionWithTypeArguments */; + return node.kind === 225 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 224 /* AsExpression */; + return node.kind === 226 /* AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 225 /* NonNullExpression */; + return node.kind === 227 /* NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 226 /* MetaProperty */; + return node.kind === 228 /* MetaProperty */; } ts.isMetaProperty = isMetaProperty; function isSyntheticExpression(node) { - return node.kind === 227 /* SyntheticExpression */; + return node.kind === 229 /* SyntheticExpression */; } ts.isSyntheticExpression = isSyntheticExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 336 /* PartiallyEmittedExpression */; + return node.kind === 344 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isCommaListExpression(node) { - return node.kind === 337 /* CommaListExpression */; + return node.kind === 345 /* CommaListExpression */; } ts.isCommaListExpression = isCommaListExpression; // Misc function isTemplateSpan(node) { - return node.kind === 228 /* TemplateSpan */; + return node.kind === 230 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 229 /* SemicolonClassElement */; + return node.kind === 231 /* SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Elements function isBlock(node) { - return node.kind === 230 /* Block */; + return node.kind === 232 /* Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 232 /* VariableStatement */; + return node.kind === 234 /* VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 231 /* EmptyStatement */; + return node.kind === 233 /* EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 233 /* ExpressionStatement */; + return node.kind === 235 /* ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 234 /* IfStatement */; + return node.kind === 236 /* IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 235 /* DoStatement */; + return node.kind === 237 /* DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 236 /* WhileStatement */; + return node.kind === 238 /* WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 237 /* ForStatement */; + return node.kind === 239 /* ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 238 /* ForInStatement */; + return node.kind === 240 /* ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 239 /* ForOfStatement */; + return node.kind === 241 /* ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 240 /* ContinueStatement */; + return node.kind === 242 /* ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 241 /* BreakStatement */; + return node.kind === 243 /* BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isReturnStatement(node) { - return node.kind === 242 /* ReturnStatement */; + return node.kind === 244 /* ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 243 /* WithStatement */; + return node.kind === 245 /* WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 244 /* SwitchStatement */; + return node.kind === 246 /* SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 245 /* LabeledStatement */; + return node.kind === 247 /* LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 246 /* ThrowStatement */; + return node.kind === 248 /* ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 247 /* TryStatement */; + return node.kind === 249 /* TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 248 /* DebuggerStatement */; + return node.kind === 250 /* DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 249 /* VariableDeclaration */; + return node.kind === 251 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 250 /* VariableDeclarationList */; + return node.kind === 252 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 251 /* FunctionDeclaration */; + return node.kind === 253 /* FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 252 /* ClassDeclaration */; + return node.kind === 254 /* ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 253 /* InterfaceDeclaration */; + return node.kind === 255 /* InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 254 /* TypeAliasDeclaration */; + return node.kind === 256 /* TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 255 /* EnumDeclaration */; + return node.kind === 257 /* EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 256 /* ModuleDeclaration */; + return node.kind === 258 /* ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 257 /* ModuleBlock */; + return node.kind === 259 /* ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 258 /* CaseBlock */; + return node.kind === 260 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 259 /* NamespaceExportDeclaration */; + return node.kind === 261 /* NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 260 /* ImportEqualsDeclaration */; + return node.kind === 262 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 261 /* ImportDeclaration */; + return node.kind === 263 /* ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 262 /* ImportClause */; + return node.kind === 264 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 263 /* NamespaceImport */; + return node.kind === 265 /* NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamespaceExport(node) { - return node.kind === 269 /* NamespaceExport */; + return node.kind === 271 /* NamespaceExport */; } ts.isNamespaceExport = isNamespaceExport; function isNamedImports(node) { - return node.kind === 264 /* NamedImports */; + return node.kind === 266 /* NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 265 /* ImportSpecifier */; + return node.kind === 267 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 266 /* ExportAssignment */; + return node.kind === 268 /* ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 267 /* ExportDeclaration */; + return node.kind === 269 /* ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 268 /* NamedExports */; + return node.kind === 270 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 270 /* ExportSpecifier */; + return node.kind === 272 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 271 /* MissingDeclaration */; + return node.kind === 273 /* MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; function isNotEmittedStatement(node) { - return node.kind === 335 /* NotEmittedStatement */; + return node.kind === 343 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ function isSyntheticReference(node) { - return node.kind === 340 /* SyntheticReferenceExpression */; + return node.kind === 348 /* SyntheticReferenceExpression */; } ts.isSyntheticReference = isSyntheticReference; /* @internal */ function isMergeDeclarationMarker(node) { - return node.kind === 338 /* MergeDeclarationMarker */; + return node.kind === 346 /* MergeDeclarationMarker */; } ts.isMergeDeclarationMarker = isMergeDeclarationMarker; /* @internal */ function isEndOfDeclarationMarker(node) { - return node.kind === 339 /* EndOfDeclarationMarker */; + return node.kind === 347 /* EndOfDeclarationMarker */; } ts.isEndOfDeclarationMarker = isEndOfDeclarationMarker; // Module References function isExternalModuleReference(node) { - return node.kind === 272 /* ExternalModuleReference */; + return node.kind === 274 /* ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 273 /* JsxElement */; + return node.kind === 275 /* JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 274 /* JsxSelfClosingElement */; + return node.kind === 276 /* JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 275 /* JsxOpeningElement */; + return node.kind === 277 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 276 /* JsxClosingElement */; + return node.kind === 278 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 277 /* JsxFragment */; + return node.kind === 279 /* JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 278 /* JsxOpeningFragment */; + return node.kind === 280 /* JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 279 /* JsxClosingFragment */; + return node.kind === 281 /* JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 280 /* JsxAttribute */; + return node.kind === 282 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 281 /* JsxAttributes */; + return node.kind === 283 /* JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 282 /* JsxSpreadAttribute */; + return node.kind === 284 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 283 /* JsxExpression */; + return node.kind === 285 /* JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 284 /* CaseClause */; + return node.kind === 286 /* CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 285 /* DefaultClause */; + return node.kind === 287 /* DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 286 /* HeritageClause */; + return node.kind === 288 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 287 /* CatchClause */; + return node.kind === 289 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 288 /* PropertyAssignment */; + return node.kind === 290 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 289 /* ShorthandPropertyAssignment */; + return node.kind === 291 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 290 /* SpreadAssignment */; + return node.kind === 292 /* SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 291 /* EnumMember */; + return node.kind === 293 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Unparsed // TODO(rbuckton): isUnparsedPrologue function isUnparsedPrepend(node) { - return node.kind === 293 /* UnparsedPrepend */; + return node.kind === 295 /* UnparsedPrepend */; } ts.isUnparsedPrepend = isUnparsedPrepend; // TODO(rbuckton): isUnparsedText @@ -27218,156 +28052,176 @@ var ts; // TODO(rbuckton): isUnparsedSyntheticReference // Top-level nodes function isSourceFile(node) { - return node.kind === 297 /* SourceFile */; + return node.kind === 299 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 298 /* Bundle */; + return node.kind === 300 /* Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 299 /* UnparsedSource */; + return node.kind === 301 /* UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; // TODO(rbuckton): isInputFiles // JSDoc Elements function isJSDocTypeExpression(node) { - return node.kind === 301 /* JSDocTypeExpression */; + return node.kind === 303 /* JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocNameReference(node) { - return node.kind === 302 /* JSDocNameReference */; + return node.kind === 304 /* JSDocNameReference */; } ts.isJSDocNameReference = isJSDocNameReference; + function isJSDocMemberName(node) { + return node.kind === 305 /* JSDocMemberName */; + } + ts.isJSDocMemberName = isJSDocMemberName; + function isJSDocLink(node) { + return node.kind === 318 /* JSDocLink */; + } + ts.isJSDocLink = isJSDocLink; + function isJSDocLinkCode(node) { + return node.kind === 319 /* JSDocLinkCode */; + } + ts.isJSDocLinkCode = isJSDocLinkCode; + function isJSDocLinkPlain(node) { + return node.kind === 320 /* JSDocLinkPlain */; + } + ts.isJSDocLinkPlain = isJSDocLinkPlain; function isJSDocAllType(node) { - return node.kind === 303 /* JSDocAllType */; + return node.kind === 306 /* JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 304 /* JSDocUnknownType */; + return node.kind === 307 /* JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 305 /* JSDocNullableType */; + return node.kind === 308 /* JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 306 /* JSDocNonNullableType */; + return node.kind === 309 /* JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 307 /* JSDocOptionalType */; + return node.kind === 310 /* JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 308 /* JSDocFunctionType */; + return node.kind === 311 /* JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 309 /* JSDocVariadicType */; + return node.kind === 312 /* JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDocNamepathType(node) { - return node.kind === 310 /* JSDocNamepathType */; + return node.kind === 313 /* JSDocNamepathType */; } ts.isJSDocNamepathType = isJSDocNamepathType; function isJSDoc(node) { - return node.kind === 311 /* JSDocComment */; + return node.kind === 314 /* JSDocComment */; } ts.isJSDoc = isJSDoc; function isJSDocTypeLiteral(node) { - return node.kind === 312 /* JSDocTypeLiteral */; + return node.kind === 316 /* JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocSignature(node) { - return node.kind === 313 /* JSDocSignature */; + return node.kind === 317 /* JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; // JSDoc Tags function isJSDocAugmentsTag(node) { - return node.kind === 315 /* JSDocAugmentsTag */; + return node.kind === 322 /* JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocAuthorTag(node) { - return node.kind === 317 /* JSDocAuthorTag */; + return node.kind === 324 /* JSDocAuthorTag */; } ts.isJSDocAuthorTag = isJSDocAuthorTag; function isJSDocClassTag(node) { - return node.kind === 319 /* JSDocClassTag */; + return node.kind === 326 /* JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocCallbackTag(node) { - return node.kind === 324 /* JSDocCallbackTag */; + return node.kind === 332 /* JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocPublicTag(node) { - return node.kind === 320 /* JSDocPublicTag */; + return node.kind === 327 /* JSDocPublicTag */; } ts.isJSDocPublicTag = isJSDocPublicTag; function isJSDocPrivateTag(node) { - return node.kind === 321 /* JSDocPrivateTag */; + return node.kind === 328 /* JSDocPrivateTag */; } ts.isJSDocPrivateTag = isJSDocPrivateTag; function isJSDocProtectedTag(node) { - return node.kind === 322 /* JSDocProtectedTag */; + return node.kind === 329 /* JSDocProtectedTag */; } ts.isJSDocProtectedTag = isJSDocProtectedTag; function isJSDocReadonlyTag(node) { - return node.kind === 323 /* JSDocReadonlyTag */; + return node.kind === 330 /* JSDocReadonlyTag */; } ts.isJSDocReadonlyTag = isJSDocReadonlyTag; + function isJSDocOverrideTag(node) { + return node.kind === 331 /* JSDocOverrideTag */; + } + ts.isJSDocOverrideTag = isJSDocOverrideTag; function isJSDocDeprecatedTag(node) { - return node.kind === 318 /* JSDocDeprecatedTag */; + return node.kind === 325 /* JSDocDeprecatedTag */; } ts.isJSDocDeprecatedTag = isJSDocDeprecatedTag; function isJSDocSeeTag(node) { - return node.kind === 332 /* JSDocSeeTag */; + return node.kind === 340 /* JSDocSeeTag */; } ts.isJSDocSeeTag = isJSDocSeeTag; function isJSDocEnumTag(node) { - return node.kind === 325 /* JSDocEnumTag */; + return node.kind === 333 /* JSDocEnumTag */; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocParameterTag(node) { - return node.kind === 326 /* JSDocParameterTag */; + return node.kind === 334 /* JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 327 /* JSDocReturnTag */; + return node.kind === 335 /* JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocThisTag(node) { - return node.kind === 328 /* JSDocThisTag */; + return node.kind === 336 /* JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocTypeTag(node) { - return node.kind === 329 /* JSDocTypeTag */; + return node.kind === 337 /* JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 330 /* JSDocTemplateTag */; + return node.kind === 338 /* JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 331 /* JSDocTypedefTag */; + return node.kind === 339 /* JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocUnknownTag(node) { - return node.kind === 314 /* JSDocTag */; + return node.kind === 321 /* JSDocTag */; } ts.isJSDocUnknownTag = isJSDocUnknownTag; function isJSDocPropertyTag(node) { - return node.kind === 333 /* JSDocPropertyTag */; + return node.kind === 341 /* JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocImplementsTag(node) { - return node.kind === 316 /* JSDocImplementsTag */; + return node.kind === 323 /* JSDocImplementsTag */; } ts.isJSDocImplementsTag = isJSDocImplementsTag; // Synthesized list /* @internal */ function isSyntaxList(n) { - return n.kind === 334 /* SyntaxList */; + return n.kind === 342 /* SyntaxList */; } ts.isSyntaxList = isSyntaxList; })(ts || (ts = {})); @@ -27384,7 +28238,7 @@ var ts; return ts.setTextRange(factory.createElementAccessExpression(target, memberName.expression), location); } else { - var expression = ts.setTextRange(ts.isIdentifierOrPrivateIdentifier(memberName) + var expression = ts.setTextRange(ts.isMemberName(memberName) ? factory.createPropertyAccessExpression(target, memberName) : factory.createElementAccessExpression(target, memberName), memberName); ts.getOrCreateEmitNode(expression).flags |= 64 /* NoNestedSourceMaps */; @@ -27566,14 +28420,14 @@ var ts; ts.Debug.failBadSyntaxKind(property.name, "Private identifiers are not allowed in object literals."); } switch (property.kind) { - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return createExpressionForAccessorDeclaration(factory, node.properties, property, receiver, !!node.multiLine); - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: return createExpressionForPropertyAssignment(factory, property, receiver); - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(factory, property, receiver); - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: return createExpressionForMethodDeclaration(factory, property, receiver); } } @@ -27626,21 +28480,21 @@ var ts; } ts.startsWithUseStrict = startsWithUseStrict; function isCommaSequence(node) { - return node.kind === 216 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || - node.kind === 337 /* CommaListExpression */; + return node.kind === 218 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || + node.kind === 345 /* CommaListExpression */; } ts.isCommaSequence = isCommaSequence; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 15 /* All */; } switch (node.kind) { - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return (kinds & 1 /* Parentheses */) !== 0; - case 206 /* TypeAssertionExpression */: - case 224 /* AsExpression */: + case 208 /* TypeAssertionExpression */: + case 226 /* AsExpression */: return (kinds & 2 /* TypeAssertions */) !== 0; - case 225 /* NonNullExpression */: + case 227 /* NonNullExpression */: return (kinds & 4 /* NonNullAssertions */) !== 0; - case 336 /* PartiallyEmittedExpression */: + case 344 /* PartiallyEmittedExpression */: return (kinds & 8 /* PartiallyEmittedExpressions */) !== 0; } return false; @@ -27761,10 +28615,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : factory.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 261 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 263 /* ImportDeclaration */ && node.importClause) { return factory.getGeneratedNameForNode(node); } - if (node.kind === 267 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 269 /* ExportDeclaration */ && node.moduleSpecifier) { return factory.getGeneratedNameForNode(node); } return undefined; @@ -27883,7 +28737,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -27895,11 +28749,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 290 /* SpreadAssignment */: + case 292 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -27931,12 +28785,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 160 /* Parameter */: - case 198 /* BindingElement */: + case 162 /* Parameter */: + case 200 /* BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 220 /* SpreadElement */: - case 290 /* SpreadAssignment */: + case 222 /* SpreadElement */: + case 292 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -27954,7 +28808,7 @@ var ts; ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement; function tryGetPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 198 /* BindingElement */: + case 200 /* BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -27969,7 +28823,7 @@ var ts; : propertyName; } break; - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -27984,7 +28838,7 @@ var ts; : propertyName; } break; - case 290 /* SpreadAssignment */: + case 292 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` if (bindingElement.name && ts.isPrivateIdentifier(bindingElement.name)) { return ts.Debug.failBadSyntaxKind(bindingElement.name); @@ -28007,13 +28861,13 @@ var ts; */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 196 /* ObjectBindingPattern */: - case 197 /* ArrayBindingPattern */: - case 199 /* ArrayLiteralExpression */: + case 198 /* ObjectBindingPattern */: + case 199 /* ArrayBindingPattern */: + case 201 /* ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -28034,46 +28888,294 @@ var ts; ts.getJSDocTypeAliasName = getJSDocTypeAliasName; function canHaveModifiers(node) { var kind = node.kind; - return kind === 160 /* Parameter */ - || kind === 162 /* PropertySignature */ - || kind === 163 /* PropertyDeclaration */ - || kind === 164 /* MethodSignature */ - || kind === 165 /* MethodDeclaration */ - || kind === 166 /* Constructor */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */ - || kind === 171 /* IndexSignature */ - || kind === 208 /* FunctionExpression */ - || kind === 209 /* ArrowFunction */ - || kind === 221 /* ClassExpression */ - || kind === 232 /* VariableStatement */ - || kind === 251 /* FunctionDeclaration */ - || kind === 252 /* ClassDeclaration */ - || kind === 253 /* InterfaceDeclaration */ - || kind === 254 /* TypeAliasDeclaration */ - || kind === 255 /* EnumDeclaration */ - || kind === 256 /* ModuleDeclaration */ - || kind === 260 /* ImportEqualsDeclaration */ - || kind === 261 /* ImportDeclaration */ - || kind === 266 /* ExportAssignment */ - || kind === 267 /* ExportDeclaration */; + return kind === 162 /* Parameter */ + || kind === 164 /* PropertySignature */ + || kind === 165 /* PropertyDeclaration */ + || kind === 166 /* MethodSignature */ + || kind === 167 /* MethodDeclaration */ + || kind === 168 /* Constructor */ + || kind === 169 /* GetAccessor */ + || kind === 170 /* SetAccessor */ + || kind === 173 /* IndexSignature */ + || kind === 210 /* FunctionExpression */ + || kind === 211 /* ArrowFunction */ + || kind === 223 /* ClassExpression */ + || kind === 234 /* VariableStatement */ + || kind === 253 /* FunctionDeclaration */ + || kind === 254 /* ClassDeclaration */ + || kind === 255 /* InterfaceDeclaration */ + || kind === 256 /* TypeAliasDeclaration */ + || kind === 257 /* EnumDeclaration */ + || kind === 258 /* ModuleDeclaration */ + || kind === 262 /* ImportEqualsDeclaration */ + || kind === 263 /* ImportDeclaration */ + || kind === 268 /* ExportAssignment */ + || kind === 269 /* ExportDeclaration */; } ts.canHaveModifiers = canHaveModifiers; - /* @internal */ - function isExportModifier(node) { - return node.kind === 92 /* ExportKeyword */; - } - ts.isExportModifier = isExportModifier; - /* @internal */ - function isAsyncModifier(node) { - return node.kind === 129 /* AsyncKeyword */; - } - ts.isAsyncModifier = isAsyncModifier; - /* @internal */ - function isStaticModifier(node) { - return node.kind === 123 /* StaticKeyword */; + ts.isTypeNodeOrTypeParameterDeclaration = ts.or(ts.isTypeNode, ts.isTypeParameterDeclaration); + ts.isQuestionOrExclamationToken = ts.or(ts.isQuestionToken, ts.isExclamationToken); + ts.isIdentifierOrThisTypeNode = ts.or(ts.isIdentifier, ts.isThisTypeNode); + ts.isReadonlyKeywordOrPlusOrMinusToken = ts.or(ts.isReadonlyKeyword, ts.isPlusToken, ts.isMinusToken); + ts.isQuestionOrPlusOrMinusToken = ts.or(ts.isQuestionToken, ts.isPlusToken, ts.isMinusToken); + 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 */ + || ts.isLiteralExpression(node) + || ts.isPrefixUnaryExpression(node); + } + ts.isLiteralTypeLikeExpression = isLiteralTypeLikeExpression; + function isExponentiationOperator(kind) { + return kind === 42 /* AsteriskAsteriskToken */; + } + function isMultiplicativeOperator(kind) { + return kind === 41 /* AsteriskToken */ + || kind === 43 /* SlashToken */ + || kind === 44 /* PercentToken */; + } + function isMultiplicativeOperatorOrHigher(kind) { + return isExponentiationOperator(kind) + || isMultiplicativeOperator(kind); + } + function isAdditiveOperator(kind) { + return kind === 39 /* PlusToken */ + || kind === 40 /* MinusToken */; + } + function isAdditiveOperatorOrHigher(kind) { + return isAdditiveOperator(kind) + || isMultiplicativeOperatorOrHigher(kind); + } + function isShiftOperator(kind) { + return kind === 47 /* LessThanLessThanToken */ + || kind === 48 /* GreaterThanGreaterThanToken */ + || kind === 49 /* 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 */; + } + function isRelationalOperatorOrHigher(kind) { + return isRelationalOperator(kind) + || isShiftOperatorOrHigher(kind); + } + function isEqualityOperator(kind) { + return kind === 34 /* EqualsEqualsToken */ + || kind === 36 /* EqualsEqualsEqualsToken */ + || kind === 35 /* ExclamationEqualsToken */ + || kind === 37 /* ExclamationEqualsEqualsToken */; + } + function isEqualityOperatorOrHigher(kind) { + return isEqualityOperator(kind) + || isRelationalOperatorOrHigher(kind); + } + function isBitwiseOperator(kind) { + return kind === 50 /* AmpersandToken */ + || kind === 51 /* BarToken */ + || kind === 52 /* CaretToken */; + } + function isBitwiseOperatorOrHigher(kind) { + return isBitwiseOperator(kind) + || isEqualityOperatorOrHigher(kind); + } + // NOTE: The version in utilities includes ExclamationToken, which is not a binary operator. + function isLogicalOperator(kind) { + return kind === 55 /* AmpersandAmpersandToken */ + || kind === 56 /* BarBarToken */; + } + function isLogicalOperatorOrHigher(kind) { + return isLogicalOperator(kind) + || isBitwiseOperatorOrHigher(kind); + } + function isAssignmentOperatorOrHigher(kind) { + return kind === 60 /* QuestionQuestionToken */ + || isLogicalOperatorOrHigher(kind) + || ts.isAssignmentOperator(kind); + } + function isBinaryOperator(kind) { + return isAssignmentOperatorOrHigher(kind) + || kind === 27 /* CommaToken */; + } + function isBinaryOperatorToken(node) { + return isBinaryOperator(node.kind); + } + ts.isBinaryOperatorToken = isBinaryOperatorToken; + var BinaryExpressionState; + (function (BinaryExpressionState) { + /** + * Handles walking into a `BinaryExpression`. + * @param machine State machine handler functions + * @param frame The current frame + * @returns The new frame + */ + function enter(machine, stackIndex, stateStack, nodeStack, userStateStack, _resultHolder, outerState) { + var prevUserState = stackIndex > 0 ? userStateStack[stackIndex - 1] : undefined; + ts.Debug.assertEqual(stateStack[stackIndex], enter); + userStateStack[stackIndex] = machine.onEnter(nodeStack[stackIndex], prevUserState, outerState); + stateStack[stackIndex] = nextState(machine, enter); + return stackIndex; + } + BinaryExpressionState.enter = enter; + /** + * Handles walking the `left` side of a `BinaryExpression`. + * @param machine State machine handler functions + * @param frame The current frame + * @returns The new frame + */ + function left(machine, stackIndex, stateStack, nodeStack, userStateStack, _resultHolder, _outerState) { + ts.Debug.assertEqual(stateStack[stackIndex], left); + ts.Debug.assertIsDefined(machine.onLeft); + stateStack[stackIndex] = nextState(machine, left); + var nextNode = machine.onLeft(nodeStack[stackIndex].left, userStateStack[stackIndex], nodeStack[stackIndex]); + if (nextNode) { + checkCircularity(stackIndex, nodeStack, nextNode); + return pushStack(stackIndex, stateStack, nodeStack, userStateStack, nextNode); + } + return stackIndex; + } + BinaryExpressionState.left = left; + /** + * Handles walking the `operatorToken` of a `BinaryExpression`. + * @param machine State machine handler functions + * @param frame The current frame + * @returns The new frame + */ + function operator(machine, stackIndex, stateStack, nodeStack, userStateStack, _resultHolder, _outerState) { + ts.Debug.assertEqual(stateStack[stackIndex], operator); + ts.Debug.assertIsDefined(machine.onOperator); + stateStack[stackIndex] = nextState(machine, operator); + machine.onOperator(nodeStack[stackIndex].operatorToken, userStateStack[stackIndex], nodeStack[stackIndex]); + return stackIndex; + } + BinaryExpressionState.operator = operator; + /** + * Handles walking the `right` side of a `BinaryExpression`. + * @param machine State machine handler functions + * @param frame The current frame + * @returns The new frame + */ + function right(machine, stackIndex, stateStack, nodeStack, userStateStack, _resultHolder, _outerState) { + ts.Debug.assertEqual(stateStack[stackIndex], right); + ts.Debug.assertIsDefined(machine.onRight); + stateStack[stackIndex] = nextState(machine, right); + var nextNode = machine.onRight(nodeStack[stackIndex].right, userStateStack[stackIndex], nodeStack[stackIndex]); + if (nextNode) { + checkCircularity(stackIndex, nodeStack, nextNode); + return pushStack(stackIndex, stateStack, nodeStack, userStateStack, nextNode); + } + return stackIndex; + } + BinaryExpressionState.right = right; + /** + * Handles walking out of a `BinaryExpression`. + * @param machine State machine handler functions + * @param frame The current frame + * @returns The new frame + */ + function exit(machine, stackIndex, stateStack, nodeStack, userStateStack, resultHolder, _outerState) { + ts.Debug.assertEqual(stateStack[stackIndex], exit); + stateStack[stackIndex] = nextState(machine, exit); + var result = machine.onExit(nodeStack[stackIndex], userStateStack[stackIndex]); + if (stackIndex > 0) { + stackIndex--; + if (machine.foldState) { + var side = stateStack[stackIndex] === exit ? "right" : "left"; + userStateStack[stackIndex] = machine.foldState(userStateStack[stackIndex], result, side); + } + } + else { + resultHolder.value = result; + } + return stackIndex; + } + BinaryExpressionState.exit = exit; + /** + * Handles a frame that is already done. + * @returns The `done` state. + */ + function done(_machine, stackIndex, stateStack, _nodeStack, _userStateStack, _resultHolder, _outerState) { + ts.Debug.assertEqual(stateStack[stackIndex], done); + return stackIndex; + } + BinaryExpressionState.done = done; + function nextState(machine, currentState) { + switch (currentState) { + case enter: + if (machine.onLeft) + return left; + // falls through + case left: + if (machine.onOperator) + return operator; + // falls through + case operator: + if (machine.onRight) + return right; + // falls through + case right: return exit; + case exit: return done; + case done: return done; + default: ts.Debug.fail("Invalid state"); + } + } + BinaryExpressionState.nextState = nextState; + function pushStack(stackIndex, stateStack, nodeStack, userStateStack, node) { + stackIndex++; + stateStack[stackIndex] = enter; + nodeStack[stackIndex] = node; + userStateStack[stackIndex] = undefined; + return stackIndex; + } + function checkCircularity(stackIndex, nodeStack, node) { + if (ts.Debug.shouldAssert(2 /* Aggressive */)) { + while (stackIndex >= 0) { + ts.Debug.assert(nodeStack[stackIndex] !== node, "Circular traversal detected."); + stackIndex--; + } + } + } + })(BinaryExpressionState || (BinaryExpressionState = {})); + /** + * Holds state machine handler functions + */ + var BinaryExpressionStateMachine = /** @class */ (function () { + function BinaryExpressionStateMachine(onEnter, onLeft, onOperator, onRight, onExit, foldState) { + this.onEnter = onEnter; + this.onLeft = onLeft; + this.onOperator = onOperator; + this.onRight = onRight; + this.onExit = onExit; + this.foldState = foldState; + } + return BinaryExpressionStateMachine; + }()); + function createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, foldState) { + var machine = new BinaryExpressionStateMachine(onEnter, onLeft, onOperator, onRight, onExit, foldState); + return trampoline; + function trampoline(node, outerState) { + var resultHolder = { value: undefined }; + var stateStack = [BinaryExpressionState.enter]; + var nodeStack = [node]; + var userStateStack = [undefined]; + var stackIndex = 0; + while (stateStack[stackIndex] !== BinaryExpressionState.done) { + stackIndex = stateStack[stackIndex](machine, stackIndex, stateStack, nodeStack, userStateStack, resultHolder, outerState); + } + ts.Debug.assertEqual(stackIndex, 0); + return resultHolder.value; + } } - ts.isStaticModifier = isStaticModifier; + ts.createBinaryExpressionTrampoline = createBinaryExpressionTrampoline; })(ts || (ts = {})); var ts; (function (ts) { @@ -28155,19 +29257,19 @@ 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 <= 156 /* LastToken */) { + if (!node || node.kind <= 158 /* LastToken */) { return; } switch (node.kind) { - case 157 /* QualifiedName */: + case 159 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 159 /* TypeParameter */: + case 161 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -28175,9 +29277,9 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 290 /* SpreadAssignment */: + case 292 /* SpreadAssignment */: return visitNode(cbNode, node.expression); - case 160 /* Parameter */: + case 162 /* Parameter */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -28185,7 +29287,7 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -28193,51 +29295,51 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 162 /* PropertySignature */: + case 164 /* PropertySignature */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.initializer); - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 198 /* BindingElement */: + case 200 /* BindingElement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 173 /* 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 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: - case 209 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 210 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 211 /* ArrowFunction */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -28249,374 +29351,395 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 173 /* TypeReference */: + case 175 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 172 /* TypePredicate */: + case 174 /* TypePredicate */: return visitNode(cbNode, node.assertsModifier) || visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 176 /* TypeQuery */: + case 178 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 177 /* TypeLiteral */: + case 179 /* TypeLiteral */: return visitNodes(cbNode, cbNodes, node.members); - case 178 /* ArrayType */: + case 180 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 179 /* TupleType */: + case 181 /* TupleType */: return visitNodes(cbNode, cbNodes, node.elements); - case 182 /* UnionType */: - case 183 /* IntersectionType */: + case 184 /* UnionType */: + case 185 /* IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 184 /* ConditionalType */: + case 186 /* ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 185 /* InferType */: + case 187 /* InferType */: return visitNode(cbNode, node.typeParameter); - case 195 /* ImportType */: + case 197 /* ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 186 /* ParenthesizedType */: - case 188 /* TypeOperator */: + case 188 /* ParenthesizedType */: + case 190 /* TypeOperator */: return visitNode(cbNode, node.type); - case 189 /* IndexedAccessType */: + case 191 /* IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 190 /* MappedType */: + case 192 /* MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.nameType) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 191 /* LiteralType */: + case 193 /* LiteralType */: return visitNode(cbNode, node.literal); - case 192 /* NamedTupleMember */: + case 194 /* NamedTupleMember */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 196 /* ObjectBindingPattern */: - case 197 /* ArrayBindingPattern */: + case 198 /* ObjectBindingPattern */: + case 199 /* ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.name); - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.argumentExpression); - case 203 /* CallExpression */: - case 204 /* NewExpression */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 206 /* TypeAssertionExpression */: + case 208 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 210 /* DeleteExpression */: + case 212 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 211 /* TypeOfExpression */: + case 213 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 212 /* VoidExpression */: + case 214 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 213 /* AwaitExpression */: + case 215 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 224 /* AsExpression */: + case 226 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 225 /* NonNullExpression */: + case 227 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 226 /* MetaProperty */: + case 228 /* MetaProperty */: return visitNode(cbNode, node.name); - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 220 /* SpreadElement */: + case 222 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 230 /* Block */: - case 257 /* ModuleBlock */: + case 232 /* Block */: + case 259 /* ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 297 /* SourceFile */: + case 299 /* SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 250 /* VariableDeclarationList */: + case 252 /* VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 234 /* IfStatement */: + case 236 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 235 /* DoStatement */: + case 237 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 236 /* WhileStatement */: + case 238 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 240 /* ContinueStatement */: - case 241 /* BreakStatement */: + case 242 /* ContinueStatement */: + case 243 /* BreakStatement */: return visitNode(cbNode, node.label); - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 243 /* WithStatement */: + case 245 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 258 /* CaseBlock */: + case 260 /* CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 284 /* CaseClause */: + case 286 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 285 /* DefaultClause */: + case 287 /* DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 246 /* ThrowStatement */: + case 248 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 247 /* TryStatement */: + case 249 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 161 /* Decorator */: + case 163 /* Decorator */: return visitNode(cbNode, node.expression); - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: 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 253 /* InterfaceDeclaration */: + case 255 /* 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 254 /* TypeAliasDeclaration */: + case 256 /* 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 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 291 /* EnumMember */: + case 293 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 262 /* ImportClause */: + case 264 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 259 /* NamespaceExportDeclaration */: + case 261 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 269 /* NamespaceExport */: + case 271 /* NamespaceExport */: return visitNode(cbNode, node.name); - case 264 /* NamedImports */: - case 268 /* NamedExports */: + case 266 /* NamedImports */: + case 270 /* NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 265 /* ImportSpecifier */: - case 270 /* ExportSpecifier */: + case 267 /* ImportSpecifier */: + case 272 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 218 /* TemplateExpression */: + case 220 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 228 /* TemplateSpan */: + case 230 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 193 /* TemplateLiteralType */: + case 195 /* TemplateLiteralType */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 194 /* TemplateLiteralTypeSpan */: + case 196 /* TemplateLiteralTypeSpan */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.literal); - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 286 /* HeritageClause */: + case 288 /* HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 272 /* ExternalModuleReference */: + case 274 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 271 /* MissingDeclaration */: + case 273 /* MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 337 /* CommaListExpression */: + case 345 /* CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 273 /* JsxElement */: + case 275 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 277 /* JsxFragment */: + case 279 /* JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 274 /* JsxSelfClosingElement */: - case 275 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 281 /* JsxAttributes */: + case 283 /* JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 280 /* JsxAttribute */: + case 282 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 282 /* JsxSpreadAttribute */: + case 284 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 276 /* JsxClosingElement */: + case 278 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 180 /* OptionalType */: - case 181 /* RestType */: - case 301 /* JSDocTypeExpression */: - case 306 /* JSDocNonNullableType */: - case 305 /* JSDocNullableType */: - case 307 /* JSDocOptionalType */: - case 309 /* JSDocVariadicType */: + case 182 /* OptionalType */: + case 183 /* RestType */: + case 303 /* JSDocTypeExpression */: + case 309 /* JSDocNonNullableType */: + case 308 /* JSDocNullableType */: + case 310 /* JSDocOptionalType */: + case 312 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 308 /* JSDocFunctionType */: + case 311 /* JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 311 /* JSDocComment */: - return visitNodes(cbNode, cbNodes, node.tags); - case 332 /* JSDocSeeTag */: + case 314 /* JSDocComment */: + return (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) + || visitNodes(cbNode, cbNodes, node.tags); + case 340 /* JSDocSeeTag */: return visitNode(cbNode, node.tagName) || - visitNode(cbNode, node.name); - case 302 /* JSDocNameReference */: + visitNode(cbNode, node.name) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 304 /* JSDocNameReference */: return visitNode(cbNode, node.name); - case 326 /* JSDocParameterTag */: - case 333 /* JSDocPropertyTag */: + case 305 /* JSDocMemberName */: + return visitNode(cbNode, node.left) || + visitNode(cbNode, node.right); + case 334 /* JSDocParameterTag */: + case 341 /* JSDocPropertyTag */: return visitNode(cbNode, node.tagName) || (node.isNameFirst ? visitNode(cbNode, node.name) || - visitNode(cbNode, node.typeExpression) + visitNode(cbNode, node.typeExpression) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) : visitNode(cbNode, node.typeExpression) || - visitNode(cbNode, node.name)); - case 317 /* JSDocAuthorTag */: - return visitNode(cbNode, node.tagName); - case 316 /* JSDocImplementsTag */: + visitNode(cbNode, node.name)) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 324 /* JSDocAuthorTag */: + return visitNode(cbNode, node.tagName) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 323 /* JSDocImplementsTag */: return visitNode(cbNode, node.tagName) || - visitNode(cbNode, node.class); - case 315 /* JSDocAugmentsTag */: + visitNode(cbNode, node.class) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 322 /* JSDocAugmentsTag */: return visitNode(cbNode, node.tagName) || - visitNode(cbNode, node.class); - case 330 /* JSDocTemplateTag */: + visitNode(cbNode, node.class) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 338 /* JSDocTemplateTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.constraint) || - visitNodes(cbNode, cbNodes, node.typeParameters); - case 331 /* JSDocTypedefTag */: + visitNodes(cbNode, cbNodes, node.typeParameters) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 339 /* JSDocTypedefTag */: return visitNode(cbNode, node.tagName) || (node.typeExpression && - node.typeExpression.kind === 301 /* JSDocTypeExpression */ + node.typeExpression.kind === 303 /* JSDocTypeExpression */ ? visitNode(cbNode, node.typeExpression) || - visitNode(cbNode, node.fullName) + visitNode(cbNode, node.fullName) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) : visitNode(cbNode, node.fullName) || - visitNode(cbNode, node.typeExpression)); - case 324 /* JSDocCallbackTag */: + visitNode(cbNode, node.typeExpression)) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 332 /* JSDocCallbackTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.fullName) || - visitNode(cbNode, node.typeExpression); - case 327 /* JSDocReturnTag */: - case 329 /* JSDocTypeTag */: - case 328 /* JSDocThisTag */: - case 325 /* JSDocEnumTag */: + visitNode(cbNode, node.typeExpression) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 335 /* JSDocReturnTag */: + case 337 /* JSDocTypeTag */: + case 336 /* JSDocThisTag */: + case 333 /* JSDocEnumTag */: return visitNode(cbNode, node.tagName) || - visitNode(cbNode, node.typeExpression); - case 313 /* JSDocSignature */: + visitNode(cbNode, node.typeExpression) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 317 /* JSDocSignature */: return ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 312 /* JSDocTypeLiteral */: + case 318 /* JSDocLink */: + case 319 /* JSDocLinkCode */: + case 320 /* JSDocLinkPlain */: + return visitNode(cbNode, node.name); + case 316 /* JSDocTypeLiteral */: return ts.forEach(node.jsDocPropertyTags, cbNode); - case 314 /* JSDocTag */: - case 319 /* JSDocClassTag */: - case 320 /* JSDocPublicTag */: - case 321 /* JSDocPrivateTag */: - case 322 /* JSDocProtectedTag */: - case 323 /* JSDocReadonlyTag */: - return visitNode(cbNode, node.tagName); - case 336 /* PartiallyEmittedExpression */: + case 321 /* JSDocTag */: + case 326 /* JSDocClassTag */: + case 327 /* JSDocPublicTag */: + case 328 /* JSDocPrivateTag */: + case 329 /* JSDocProtectedTag */: + case 330 /* JSDocReadonlyTag */: + case 325 /* JSDocDeprecatedTag */: + return visitNode(cbNode, node.tagName) + || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 344 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -28636,62 +29759,58 @@ var ts; * and while doing so, handles traversing the structure without relying on the callstack to encode the tree structure. */ function forEachChildRecursively(rootNode, cbNode, cbNodes) { - var stack = [rootNode]; - while (stack.length) { - var parent = stack.pop(); - var res = visitAllPossibleChildren(parent, gatherPossibleChildren(parent)); - if (res) { - return res; - } - } - return; - function gatherPossibleChildren(node) { - var children = []; - forEachChild(node, addWorkItem, addWorkItem); // By using a stack above and `unshift` here, we emulate a depth-first preorder traversal - return children; - function addWorkItem(n) { - children.unshift(n); - } - } - function visitAllPossibleChildren(parent, children) { - for (var _i = 0, children_5 = children; _i < children_5.length; _i++) { - var child = children_5[_i]; - if (ts.isArray(child)) { - if (cbNodes) { - var res = cbNodes(child, parent); - if (res) { - if (res === "skip") - continue; - return res; - } - } - for (var i = child.length - 1; i >= 0; i--) { - var realChild = child[i]; - var res = cbNode(realChild, parent); - if (res) { - if (res === "skip") - continue; - return res; - } - stack.push(realChild); - } - } - else { - stack.push(child); - var res = cbNode(child, parent); + var queue = gatherPossibleChildren(rootNode); + var parents = []; // tracks parent references for elements in queue + while (parents.length < queue.length) { + parents.push(rootNode); + } + while (queue.length !== 0) { + var current = queue.pop(); + var parent = parents.pop(); + if (ts.isArray(current)) { + if (cbNodes) { + var res = cbNodes(current, parent); if (res) { if (res === "skip") continue; return res; } } + for (var i = current.length - 1; i >= 0; --i) { + queue.push(current[i]); + parents.push(parent); + } + } + else { + var res = cbNode(current, parent); + if (res) { + if (res === "skip") + continue; + return res; + } + if (current.kind >= 159 /* 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]; + queue.push(child); + parents.push(current); + } + } } } } ts.forEachChildRecursively = forEachChildRecursively; + function gatherPossibleChildren(node) { + var children = []; + forEachChild(node, addWorkItem, addWorkItem); // By using a stack above and `unshift` here, we emulate a depth-first preorder traversal + return children; + function addWorkItem(n) { + children.unshift(n); + } + } function createSourceFile(fileName, sourceText, languageVersion, setParentNodes, scriptKind) { if (setParentNodes === void 0) { setParentNodes = false; } - ts.tracing.push("parse" /* Parse */, "createSourceFile", { path: fileName }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* Parse */, "createSourceFile", { path: fileName }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeParse"); var result; ts.perfLogger.logStartParseSourceFile(fileName); @@ -28704,7 +29823,7 @@ var ts; ts.perfLogger.logStopParseSourceFile(); ts.performance.mark("afterParse"); ts.performance.measure("Parse", "beforeParse", "afterParse"); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; } ts.createSourceFile = createSourceFile; @@ -28886,11 +30005,12 @@ var ts; // attached to the EOF token. var parseErrorBeforeNextFinishedNode = false; function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes, scriptKind) { + var _a; if (setParentNodes === void 0) { setParentNodes = false; } scriptKind = ts.ensureScriptKind(fileName, scriptKind); if (scriptKind === 6 /* JSON */) { var result_3 = parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes); - ts.convertToObjectWorker(result_3, result_3.parseDiagnostics, /*returnValue*/ false, /*knownRootOptions*/ undefined, /*jsonConversionNotifier*/ undefined); + 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; result_3.typeReferenceDirectives = ts.emptyArray; result_3.libReferenceDirectives = ts.emptyArray; @@ -28930,35 +30050,54 @@ var ts; endOfFileToken = parseTokenNode(); } else { - var expression = void 0; - switch (token()) { - case 22 /* OpenBracketToken */: - expression = parseArrayLiteralExpression(); - break; - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: - case 103 /* NullKeyword */: - expression = parseTokenNode(); - break; - case 40 /* MinusToken */: - if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 58 /* ColonToken */; })) { - expression = parsePrefixUnaryExpression(); - } - else { - expression = parseObjectLiteralExpression(); - } - break; - case 8 /* NumericLiteral */: - case 10 /* StringLiteral */: - if (lookAhead(function () { return nextToken() !== 58 /* ColonToken */; })) { - expression = parseLiteralNode(); + // 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 */) { + var expression_1 = void 0; + switch (token()) { + case 22 /* OpenBracketToken */: + expression_1 = parseArrayLiteralExpression(); + break; + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: + case 104 /* NullKeyword */: + expression_1 = parseTokenNode(); break; + case 40 /* MinusToken */: + if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 58 /* ColonToken */; })) { + expression_1 = parsePrefixUnaryExpression(); + } + else { + expression_1 = parseObjectLiteralExpression(); + } + break; + case 8 /* NumericLiteral */: + case 10 /* StringLiteral */: + if (lookAhead(function () { return nextToken() !== 58 /* ColonToken */; })) { + expression_1 = parseLiteralNode(); + break; + } + // falls through + default: + expression_1 = parseObjectLiteralExpression(); + break; + } + // Error recovery: collect multiple top-level expressions + if (expressions && ts.isArray(expressions)) { + expressions.push(expression_1); + } + else if (expressions) { + expressions = [expressions, expression_1]; + } + else { + expressions = expression_1; + if (token() !== 1 /* EndOfFileToken */) { + parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token); } - // falls through - default: - expression = parseObjectLiteralExpression(); - break; + } } + var expression = ts.isArray(expressions) ? finishNode(factory.createArrayLiteralExpression(expressions), pos) : ts.Debug.checkDefined(expressions); var statement = factory.createExpressionStatement(expression); finishNode(statement, pos); statements = createNodeArray([statement], pos); @@ -29153,7 +30292,7 @@ var ts; return factory.updateSourceFile(sourceFile, ts.setTextRange(factory.createNodeArray(statements), sourceFile.statements)); function containsPossibleTopLevelAwait(node) { return !(node.flags & 32768 /* AwaitContext */) - && !!(node.transformFlags & 8388608 /* ContainsPossibleTopLevelAwait */); + && !!(node.transformFlags & 16777216 /* ContainsPossibleTopLevelAwait */); } function findNextStatementWithAwait(statements, start) { for (var i = start; i < statements.length; i++) { @@ -29194,7 +30333,7 @@ var ts; ts.setTextRangePosWidth(sourceFile, 0, sourceText.length); setExternalModuleIndicator(sourceFile); // If we parsed this as an external module, it may contain top-level await - if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 8388608 /* ContainsPossibleTopLevelAwait */) { + if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 16777216 /* ContainsPossibleTopLevelAwait */) { sourceFile = reparseTopLevelAwait(sourceFile); } sourceFile.text = sourceText; @@ -29374,6 +30513,9 @@ var ts; function reScanLessThanToken() { return currentToken = scanner.reScanLessThanToken(); } + function reScanHashToken() { + return currentToken = scanner.reScanHashToken(); + } function scanJsxIdentifier() { return currentToken = scanner.scanJsxIdentifier(); } @@ -29428,27 +30570,27 @@ var ts; return speculationHelper(callback, 0 /* TryParse */); } function isBindingIdentifier() { - if (token() === 78 /* Identifier */) { + if (token() === 79 /* Identifier */) { return true; } - return token() > 115 /* LastReservedWord */; + return token() > 116 /* LastReservedWord */; } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token() === 78 /* Identifier */) { + if (token() === 79 /* 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() === 124 /* YieldKeyword */ && inYieldContext()) { + if (token() === 125 /* 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() === 130 /* AwaitKeyword */ && inAwaitContext()) { + if (token() === 131 /* AwaitKeyword */ && inAwaitContext()) { return false; } - return token() > 115 /* LastReservedWord */; + return token() > 116 /* LastReservedWord */; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -29561,11 +30703,11 @@ var ts; parseErrorAtCurrentToken(diagnosticMessage, arg0); } var pos = getNodePos(); - var result = kind === 78 /* Identifier */ ? factory.createIdentifier("", /*typeArguments*/ undefined, /*originalKeywordKind*/ undefined) : + var result = kind === 79 /* 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 === 271 /* MissingDeclaration */ ? factory.createMissingDeclaration() : + kind === 273 /* MissingDeclaration */ ? factory.createMissingDeclaration() : factory.createToken(kind); return finishNode(result, pos); } @@ -29580,8 +30722,8 @@ var ts; // with magic property names like '__proto__'. The 'identifiers' object is used to share a single string instance for // each identifier in order to reduce memory consumption. function createIdentifier(isIdentifier, diagnosticMessage, privateIdentifierDiagnosticMessage) { - identifierCount++; if (isIdentifier) { + identifierCount++; var pos = getNodePos(); // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker var originalKeywordKind = token(); @@ -29589,10 +30731,15 @@ var ts; nextTokenWithoutCheck(); return finishNode(factory.createIdentifier(text, /*typeArguments*/ undefined, originalKeywordKind), pos); } - if (token() === 79 /* PrivateIdentifier */) { + if (token() === 80 /* 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 */; })) { + // 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 isReservedWord = scanner.isReservedWord(); @@ -29600,7 +30747,7 @@ var ts; var defaultMessage = isReservedWord ? ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here : ts.Diagnostics.Identifier_expected; - return createMissingNode(78 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg); + return createMissingNode(79 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg); } function parseBindingIdentifier(privateIdentifierDiagnosticMessage) { return createIdentifier(isBindingIdentifier(), /*diagnosticMessage*/ undefined, privateIdentifierDiagnosticMessage); @@ -29625,7 +30772,7 @@ var ts; if (allowComputedPropertyNames && token() === 22 /* OpenBracketToken */) { return parseComputedPropertyName(); } - if (token() === 79 /* PrivateIdentifier */) { + if (token() === 80 /* PrivateIdentifier */) { return parsePrivateIdentifier(); } return parseIdentifierName(); @@ -29671,24 +30818,24 @@ var ts; } function nextTokenCanFollowModifier() { switch (token()) { - case 84 /* ConstKeyword */: + case 85 /* ConstKeyword */: // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 91 /* EnumKeyword */; - case 92 /* ExportKeyword */: + return nextToken() === 92 /* EnumKeyword */; + case 93 /* ExportKeyword */: nextToken(); - if (token() === 87 /* DefaultKeyword */) { + if (token() === 88 /* DefaultKeyword */) { return lookAhead(nextTokenCanFollowDefaultKeyword); } - if (token() === 149 /* TypeKeyword */) { + if (token() === 150 /* TypeKeyword */) { return lookAhead(nextTokenCanFollowExportModifier); } return canFollowExportModifier(); - case 87 /* DefaultKeyword */: + case 88 /* DefaultKeyword */: return nextTokenCanFollowDefaultKeyword(); - case 123 /* StaticKeyword */: + case 124 /* StaticKeyword */: return nextTokenIsOnSameLineAndCanFollowModifier(); - case 134 /* GetKeyword */: - case 146 /* SetKeyword */: + case 135 /* GetKeyword */: + case 147 /* SetKeyword */: nextToken(); return canFollowModifier(); default: @@ -29697,7 +30844,7 @@ var ts; } function canFollowExportModifier() { return token() !== 41 /* AsteriskToken */ - && token() !== 126 /* AsKeyword */ + && token() !== 127 /* AsKeyword */ && token() !== 18 /* OpenBraceToken */ && canFollowModifier(); } @@ -29717,10 +30864,10 @@ var ts; } function nextTokenCanFollowDefaultKeyword() { nextToken(); - return token() === 83 /* ClassKeyword */ || token() === 97 /* FunctionKeyword */ || - token() === 117 /* InterfaceKeyword */ || - (token() === 125 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || - (token() === 129 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 84 /* ClassKeyword */ || token() === 98 /* FunctionKeyword */ || + token() === 118 /* InterfaceKeyword */ || + (token() === 126 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || + (token() === 130 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -29740,7 +30887,7 @@ var ts; // outer module. We just want to consume and move on. return !(token() === 26 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); case 2 /* SwitchClauses */: - return token() === 81 /* CaseKeyword */ || token() === 87 /* DefaultKeyword */; + return token() === 82 /* CaseKeyword */ || token() === 88 /* DefaultKeyword */; case 4 /* TypeMembers */: return lookAhead(isTypeMemberStart); case 5 /* ClassMembers */: @@ -29826,7 +30973,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 93 /* ExtendsKeyword */ || next === 116 /* ImplementsKeyword */; + return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 94 /* ExtendsKeyword */ || next === 117 /* ImplementsKeyword */; } return true; } @@ -29843,8 +30990,8 @@ var ts; return ts.tokenIsIdentifierOrKeywordOrGreaterThan(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 116 /* ImplementsKeyword */ || - token() === 93 /* ExtendsKeyword */) { + if (token() === 117 /* ImplementsKeyword */ || + token() === 94 /* ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -29874,14 +31021,14 @@ var ts; case 23 /* ImportOrExportSpecifiers */: return token() === 19 /* CloseBraceToken */; case 3 /* SwitchClauseStatements */: - return token() === 19 /* CloseBraceToken */ || token() === 81 /* CaseKeyword */ || token() === 87 /* DefaultKeyword */; + return token() === 19 /* CloseBraceToken */ || token() === 82 /* CaseKeyword */ || token() === 88 /* DefaultKeyword */; case 7 /* HeritageClauseElement */: - return token() === 18 /* OpenBraceToken */ || token() === 93 /* ExtendsKeyword */ || token() === 116 /* ImplementsKeyword */; + return token() === 18 /* OpenBraceToken */ || token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; case 8 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); case 19 /* TypeParameters */: // Tokens other than '>' are here for better error recovery - return token() === 31 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 93 /* ExtendsKeyword */ || token() === 116 /* ImplementsKeyword */; + return token() === 31 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; case 11 /* ArgumentExpressions */: // Tokens other than ')' are here for better error recovery return token() === 21 /* CloseParenToken */ || token() === 26 /* SemicolonToken */; @@ -29947,8 +31094,7 @@ var ts; var listPos = getNodePos(); while (!isListTerminator(kind)) { if (isListElement(kind, /*inErrorRecovery*/ false)) { - var element = parseListElement(kind, parseElement); - list.push(element); + list.push(parseListElement(kind, parseElement)); continue; } if (abortParsingListOrMoveToNextToken(kind)) { @@ -30098,20 +31244,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 166 /* Constructor */: - case 171 /* IndexSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 163 /* PropertyDeclaration */: - case 229 /* SemicolonClassElement */: + case 168 /* Constructor */: + case 173 /* IndexSignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 231 /* SemicolonClassElement */: return true; - case 165 /* MethodDeclaration */: + case 167 /* 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 === 78 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 132 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 79 /* Identifier */ && + methodDeclaration.name.originalKeywordKind === 133 /* ConstructorKeyword */; return !nameIsConstructor; } } @@ -30120,8 +31266,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 284 /* CaseClause */: - case 285 /* DefaultClause */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: return true; } } @@ -30130,58 +31276,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 232 /* VariableStatement */: - case 230 /* Block */: - case 234 /* IfStatement */: - case 233 /* ExpressionStatement */: - case 246 /* ThrowStatement */: - case 242 /* ReturnStatement */: - case 244 /* SwitchStatement */: - case 241 /* BreakStatement */: - case 240 /* ContinueStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 237 /* ForStatement */: - case 236 /* WhileStatement */: - case 243 /* WithStatement */: - case 231 /* EmptyStatement */: - case 247 /* TryStatement */: - case 245 /* LabeledStatement */: - case 235 /* DoStatement */: - case 248 /* DebuggerStatement */: - case 261 /* ImportDeclaration */: - case 260 /* ImportEqualsDeclaration */: - case 267 /* ExportDeclaration */: - case 266 /* ExportAssignment */: - case 256 /* ModuleDeclaration */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 253 /* FunctionDeclaration */: + case 234 /* VariableStatement */: + case 232 /* Block */: + case 236 /* IfStatement */: + case 235 /* ExpressionStatement */: + case 248 /* ThrowStatement */: + case 244 /* ReturnStatement */: + case 246 /* SwitchStatement */: + case 243 /* BreakStatement */: + case 242 /* ContinueStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 239 /* ForStatement */: + case 238 /* WhileStatement */: + case 245 /* WithStatement */: + case 233 /* EmptyStatement */: + case 249 /* TryStatement */: + case 247 /* LabeledStatement */: + case 237 /* DoStatement */: + case 250 /* DebuggerStatement */: + case 263 /* ImportDeclaration */: + case 262 /* ImportEqualsDeclaration */: + case 269 /* ExportDeclaration */: + case 268 /* ExportAssignment */: + case 258 /* ModuleDeclaration */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 257 /* EnumDeclaration */: + case 256 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 291 /* EnumMember */; + return node.kind === 293 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 170 /* ConstructSignature */: - case 164 /* MethodSignature */: - case 171 /* IndexSignature */: - case 162 /* PropertySignature */: - case 169 /* CallSignature */: + case 172 /* ConstructSignature */: + case 166 /* MethodSignature */: + case 173 /* IndexSignature */: + case 164 /* PropertySignature */: + case 171 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 249 /* VariableDeclaration */) { + if (node.kind !== 251 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -30202,7 +31348,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 160 /* Parameter */) { + if (node.kind !== 162 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -30369,12 +31515,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(78 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } } - if (token() === 79 /* PrivateIdentifier */) { + if (token() === 80 /* PrivateIdentifier */) { var node = parsePrivateIdentifier(); - return allowPrivateIdentifiers ? node : createMissingNode(78 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return allowPrivateIdentifiers ? node : createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } @@ -30483,14 +31629,14 @@ var ts; // If true, we should abort parsing an error function. function typeHasArrowFunctionBlockingParseError(node) { switch (node.kind) { - case 173 /* TypeReference */: + case 175 /* TypeReference */: return ts.nodeIsMissing(node.typeName); - case 174 /* FunctionType */: - case 175 /* ConstructorType */: { + case 176 /* FunctionType */: + case 177 /* ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 186 /* ParenthesizedType */: + case 188 /* ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -30532,7 +31678,7 @@ var ts; token() === 19 /* CloseBraceToken */ || token() === 21 /* CloseParenToken */ || token() === 31 /* GreaterThanToken */ || - token() === 62 /* EqualsToken */ || + token() === 63 /* EqualsToken */ || token() === 51 /* BarToken */) { return finishNode(factory.createJSDocUnknownType(), pos); } @@ -30554,7 +31700,7 @@ var ts; function parseJSDocParameter() { var pos = getNodePos(); var name; - if (token() === 107 /* ThisKeyword */ || token() === 102 /* NewKeyword */) { + if (token() === 108 /* ThisKeyword */ || token() === 103 /* NewKeyword */) { name = parseIdentifierName(); parseExpected(58 /* ColonToken */); } @@ -30570,7 +31716,7 @@ var ts; function parseJSDocType() { scanner.setInJSDocType(true); var pos = getNodePos(); - if (parseOptional(139 /* ModuleKeyword */)) { + if (parseOptional(140 /* 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) { @@ -30593,7 +31739,7 @@ var ts; if (hasDotDotDot) { type = finishNode(factory.createJSDocVariadicType(type), pos); } - if (token() === 62 /* EqualsToken */) { + if (token() === 63 /* EqualsToken */) { nextToken(); return finishNode(factory.createJSDocOptionalType(type), pos); } @@ -30601,7 +31747,7 @@ var ts; } function parseTypeQuery() { var pos = getNodePos(); - parseExpected(111 /* TypeOfKeyword */); + parseExpected(112 /* TypeOfKeyword */); return finishNode(factory.createTypeQueryNode(parseEntityName(/*allowReservedWords*/ true)), pos); } function parseTypeParameter() { @@ -30609,7 +31755,7 @@ var ts; var name = parseIdentifier(); var constraint; var expression; - if (parseOptional(93 /* ExtendsKeyword */)) { + if (parseOptional(94 /* 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 @@ -30628,7 +31774,7 @@ var ts; expression = parseUnaryExpressionOrHigher(); } } - var defaultType = parseOptional(62 /* EqualsToken */) ? parseType() : undefined; + var defaultType = parseOptional(63 /* EqualsToken */) ? parseType() : undefined; var node = factory.createTypeParameterDeclaration(name, constraint, defaultType); node.expression = expression; return finishNode(node, pos); @@ -30671,19 +31817,21 @@ var ts; function parseParameterWorker(inOuterAwaitContext) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - if (token() === 107 /* ThisKeyword */) { - var node_1 = factory.createParameterDeclaration( - /*decorators*/ undefined, + // 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 node_1 = factory.createParameterDeclaration(decorators, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, createIdentifier(/*isIdentifier*/ true), /*questionToken*/ undefined, parseTypeAnnotation(), /*initializer*/ undefined); + if (decorators) { + parseErrorAtRange(decorators[0], ts.Diagnostics.Decorators_may_not_be_applied_to_this_parameters); + } return withJSDoc(finishNode(node_1, pos), hasJSDoc); } - // 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(); var savedTopLevel = topLevel; topLevel = false; var modifiers = parseModifiers(); @@ -30770,14 +31918,14 @@ var ts; function parseSignatureMember(kind) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - if (kind === 170 /* ConstructSignature */) { - parseExpected(102 /* NewKeyword */); + if (kind === 172 /* ConstructSignature */) { + parseExpected(103 /* NewKeyword */); } var typeParameters = parseTypeParameters(); var parameters = parseParameters(4 /* Type */); var type = parseReturnType(58 /* ColonToken */, /*isType*/ true); parseTypeMemberSemicolon(); - var node = kind === 169 /* CallSignature */ + var node = kind === 171 /* CallSignature */ ? factory.createCallSignature(typeParameters, parameters, type) : factory.createConstructSignature(typeParameters, parameters, type); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -30860,7 +32008,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() === 62 /* EqualsToken */) + if (token() === 63 /* EqualsToken */) node.initializer = parseInitializer(); } parseTypeMemberSemicolon(); @@ -30868,7 +32016,10 @@ var ts; } function isTypeMemberStart() { // Return true if we have the start of a signature member - if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + if (token() === 20 /* OpenParenToken */ || + token() === 29 /* LessThanToken */ || + token() === 135 /* GetKeyword */ || + token() === 147 /* SetKeyword */) { return true; } var idToken = false; @@ -30900,14 +32051,20 @@ var ts; } function parseTypeMember() { if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { - return parseSignatureMember(169 /* CallSignature */); + return parseSignatureMember(171 /* CallSignature */); } - if (token() === 102 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(170 /* ConstructSignature */); + if (token() === 103 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { + return parseSignatureMember(172 /* ConstructSignature */); } var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiers(); + if (parseContextualModifier(135 /* GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 169 /* GetAccessor */); + } + if (parseContextualModifier(147 /* SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 170 /* SetAccessor */); + } if (isIndexSignature()) { return parseIndexSignatureDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers); } @@ -30947,17 +32104,17 @@ var ts; function isStartOfMappedType() { nextToken(); if (token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { - return nextToken() === 142 /* ReadonlyKeyword */; + return nextToken() === 143 /* ReadonlyKeyword */; } - if (token() === 142 /* ReadonlyKeyword */) { + if (token() === 143 /* ReadonlyKeyword */) { nextToken(); } - return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 100 /* InKeyword */; + return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 101 /* InKeyword */; } function parseMappedTypeParameter() { var pos = getNodePos(); var name = parseIdentifierName(); - parseExpected(100 /* InKeyword */); + parseExpected(101 /* InKeyword */); var type = parseType(); return finishNode(factory.createTypeParameterDeclaration(name, type, /*defaultType*/ undefined), pos); } @@ -30965,15 +32122,15 @@ var ts; var pos = getNodePos(); parseExpected(18 /* OpenBraceToken */); var readonlyToken; - if (token() === 142 /* ReadonlyKeyword */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { + if (token() === 143 /* ReadonlyKeyword */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { readonlyToken = parseTokenNode(); - if (readonlyToken.kind !== 142 /* ReadonlyKeyword */) { - parseExpected(142 /* ReadonlyKeyword */); + if (readonlyToken.kind !== 143 /* ReadonlyKeyword */) { + parseExpected(143 /* ReadonlyKeyword */); } } parseExpected(22 /* OpenBracketToken */); var typeParameter = parseMappedTypeParameter(); - var nameType = parseOptional(126 /* AsKeyword */) ? parseType() : undefined; + var nameType = parseOptional(127 /* AsKeyword */) ? parseType() : undefined; parseExpected(23 /* CloseBracketToken */); var questionToken; if (token() === 57 /* QuestionToken */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { @@ -31037,10 +32194,10 @@ var ts; } function parseModifiersForConstructorType() { var modifiers; - if (token() === 125 /* AbstractKeyword */) { + if (token() === 126 /* AbstractKeyword */) { var pos = getNodePos(); nextToken(); - var modifier = finishNode(factory.createToken(125 /* AbstractKeyword */), pos); + var modifier = finishNode(factory.createToken(126 /* AbstractKeyword */), pos); modifiers = createNodeArray([modifier], pos); } return modifiers; @@ -31049,7 +32206,7 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiersForConstructorType(); - var isConstructorType = parseOptional(102 /* NewKeyword */); + var isConstructorType = parseOptional(103 /* NewKeyword */); var typeParameters = parseTypeParameters(); var parameters = parseParameters(4 /* Type */); var type = parseReturnType(38 /* EqualsGreaterThanToken */, /*isType*/ false); @@ -31069,7 +32226,7 @@ var ts; if (negative) { nextToken(); } - var expression = token() === 109 /* TrueKeyword */ || token() === 94 /* FalseKeyword */ || token() === 103 /* NullKeyword */ ? + var expression = token() === 110 /* TrueKeyword */ || token() === 95 /* FalseKeyword */ || token() === 104 /* NullKeyword */ ? parseTokenNode() : parseLiteralLikeNode(token()); if (negative) { @@ -31079,13 +32236,13 @@ var ts; } function isStartOfTypeOfImportType() { nextToken(); - return token() === 99 /* ImportKeyword */; + return token() === 100 /* ImportKeyword */; } function parseImportType() { sourceFlags |= 1048576 /* PossiblyContainsDynamicImport */; var pos = getNodePos(); - var isTypeOf = parseOptional(111 /* TypeOfKeyword */); - parseExpected(99 /* ImportKeyword */); + var isTypeOf = parseOptional(112 /* TypeOfKeyword */); + parseExpected(100 /* ImportKeyword */); parseExpected(20 /* OpenParenToken */); var type = parseType(); parseExpected(21 /* CloseParenToken */); @@ -31099,19 +32256,19 @@ var ts; } function parseNonArrayType() { switch (token()) { - case 128 /* AnyKeyword */: - case 152 /* UnknownKeyword */: - case 147 /* StringKeyword */: - case 144 /* NumberKeyword */: - case 155 /* BigIntKeyword */: - case 148 /* SymbolKeyword */: - case 131 /* BooleanKeyword */: - case 150 /* UndefinedKeyword */: - case 141 /* NeverKeyword */: - case 145 /* ObjectKeyword */: + case 129 /* AnyKeyword */: + case 153 /* UnknownKeyword */: + case 148 /* StringKeyword */: + case 145 /* NumberKeyword */: + case 156 /* BigIntKeyword */: + case 149 /* SymbolKeyword */: + case 132 /* BooleanKeyword */: + case 151 /* UndefinedKeyword */: + case 142 /* NeverKeyword */: + case 146 /* ObjectKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. return tryParse(parseKeywordAndNoDot) || parseTypeReference(); - case 65 /* AsteriskEqualsToken */: + case 66 /* AsteriskEqualsToken */: // If there is '*=', treat it as * followed by postfix = scanner.reScanAsteriskEqualsToken(); // falls through @@ -31123,7 +32280,7 @@ var ts; // falls through case 57 /* QuestionToken */: return parseJSDocUnknownOrNullableType(); - case 97 /* FunctionKeyword */: + case 98 /* FunctionKeyword */: return parseJSDocFunctionType(); case 53 /* ExclamationToken */: return parseJSDocNonNullableType(); @@ -31131,24 +32288,24 @@ var ts; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: - case 103 /* NullKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: + case 104 /* NullKeyword */: return parseLiteralTypeNode(); case 40 /* MinusToken */: return lookAhead(nextTokenIsNumericOrBigIntLiteral) ? parseLiteralTypeNode(/*negative*/ true) : parseTypeReference(); - case 113 /* VoidKeyword */: + case 114 /* VoidKeyword */: return parseTokenNode(); - case 107 /* ThisKeyword */: { + case 108 /* ThisKeyword */: { var thisKeyword = parseThisTypeNode(); - if (token() === 137 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 138 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 111 /* TypeOfKeyword */: + case 112 /* TypeOfKeyword */: return lookAhead(isStartOfTypeOfImportType) ? parseImportType() : parseTypeQuery(); case 18 /* OpenBraceToken */: return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral(); @@ -31156,9 +32313,9 @@ var ts; return parseTupleType(); case 20 /* OpenParenToken */: return parseParenthesizedType(); - case 99 /* ImportKeyword */: + case 100 /* ImportKeyword */: return parseImportType(); - case 127 /* AssertsKeyword */: + case 128 /* AssertsKeyword */: return lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? parseAssertsTypePredicate() : parseTypeReference(); case 15 /* TemplateHead */: return parseTemplateType(); @@ -31168,44 +32325,44 @@ var ts; } function isStartOfType(inStartOfParameter) { switch (token()) { - case 128 /* AnyKeyword */: - case 152 /* UnknownKeyword */: - case 147 /* StringKeyword */: - case 144 /* NumberKeyword */: - case 155 /* BigIntKeyword */: - case 131 /* BooleanKeyword */: - case 142 /* ReadonlyKeyword */: - case 148 /* SymbolKeyword */: - case 151 /* UniqueKeyword */: - case 113 /* VoidKeyword */: - case 150 /* UndefinedKeyword */: - case 103 /* NullKeyword */: - case 107 /* ThisKeyword */: - case 111 /* TypeOfKeyword */: - case 141 /* NeverKeyword */: + case 129 /* AnyKeyword */: + case 153 /* UnknownKeyword */: + case 148 /* StringKeyword */: + case 145 /* NumberKeyword */: + case 156 /* BigIntKeyword */: + case 132 /* BooleanKeyword */: + case 143 /* ReadonlyKeyword */: + case 149 /* SymbolKeyword */: + case 152 /* UniqueKeyword */: + case 114 /* VoidKeyword */: + case 151 /* UndefinedKeyword */: + case 104 /* NullKeyword */: + case 108 /* ThisKeyword */: + case 112 /* TypeOfKeyword */: + case 142 /* NeverKeyword */: case 18 /* OpenBraceToken */: case 22 /* OpenBracketToken */: case 29 /* LessThanToken */: case 51 /* BarToken */: case 50 /* AmpersandToken */: - case 102 /* NewKeyword */: + case 103 /* NewKeyword */: case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: - case 145 /* ObjectKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: + case 146 /* ObjectKeyword */: case 41 /* AsteriskToken */: case 57 /* QuestionToken */: case 53 /* ExclamationToken */: case 25 /* DotDotDotToken */: - case 135 /* InferKeyword */: - case 99 /* ImportKeyword */: - case 127 /* AssertsKeyword */: + case 136 /* InferKeyword */: + case 100 /* ImportKeyword */: + case 128 /* AssertsKeyword */: case 14 /* NoSubstitutionTemplateLiteral */: case 15 /* TemplateHead */: return true; - case 97 /* FunctionKeyword */: + case 98 /* FunctionKeyword */: return !inStartOfParameter; case 40 /* MinusToken */: return !inStartOfParameter && lookAhead(nextTokenIsNumericOrBigIntLiteral); @@ -31269,17 +32426,17 @@ var ts; } function parseInferType() { var pos = getNodePos(); - parseExpected(135 /* InferKeyword */); + parseExpected(136 /* InferKeyword */); return finishNode(factory.createInferTypeNode(parseTypeParameterOfInferType()), pos); } function parseTypeOperatorOrHigher() { var operator = token(); switch (operator) { - case 138 /* KeyOfKeyword */: - case 151 /* UniqueKeyword */: - case 142 /* ReadonlyKeyword */: + case 139 /* KeyOfKeyword */: + case 152 /* UniqueKeyword */: + case 143 /* ReadonlyKeyword */: return parseTypeOperator(operator); - case 135 /* InferKeyword */: + case 136 /* InferKeyword */: return parseInferType(); } return parsePostfixTypeOrHigher(); @@ -31329,7 +32486,7 @@ var ts; } function nextTokenIsNewKeyword() { nextToken(); - return token() === 102 /* NewKeyword */; + return token() === 103 /* NewKeyword */; } function isStartOfFunctionTypeOrConstructorType() { if (token() === 29 /* LessThanToken */) { @@ -31338,15 +32495,15 @@ var ts; if (token() === 20 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType)) { return true; } - return token() === 102 /* NewKeyword */ || - token() === 125 /* AbstractKeyword */ && lookAhead(nextTokenIsNewKeyword); + return token() === 103 /* NewKeyword */ || + token() === 126 /* AbstractKeyword */ && lookAhead(nextTokenIsNewKeyword); } function skipParameterStart() { if (ts.isModifierKind(token())) { // Skip modifiers parseModifiers(); } - if (isIdentifier() || token() === 107 /* ThisKeyword */) { + if (isIdentifier() || token() === 108 /* ThisKeyword */) { nextToken(); return true; } @@ -31369,7 +32526,7 @@ var ts; // 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() === 62 /* EqualsToken */) { + token() === 57 /* QuestionToken */ || token() === 63 /* EqualsToken */) { // ( xxx : // ( xxx , // ( xxx ? @@ -31399,16 +32556,16 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 137 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 138 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } } function parseAssertsTypePredicate() { var pos = getNodePos(); - var assertsModifier = parseExpectedToken(127 /* AssertsKeyword */); - var parameterName = token() === 107 /* ThisKeyword */ ? parseThisTypeNode() : parseIdentifier(); - var type = parseOptional(137 /* IsKeyword */) ? parseType() : undefined; + var assertsModifier = parseExpectedToken(128 /* AssertsKeyword */); + var parameterName = token() === 108 /* ThisKeyword */ ? parseThisTypeNode() : parseIdentifier(); + var type = parseOptional(138 /* IsKeyword */) ? parseType() : undefined; return finishNode(factory.createTypePredicateNode(assertsModifier, parameterName, type), pos); } function parseType() { @@ -31422,7 +32579,7 @@ var ts; } var pos = getNodePos(); var type = parseUnionTypeOrHigher(); - if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(93 /* ExtendsKeyword */)) { + if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(94 /* ExtendsKeyword */)) { // The type following 'extends' is not permitted to be another conditional type var extendsType = parseTypeWorker(/*noConditionalTypes*/ true); parseExpected(57 /* QuestionToken */); @@ -31439,11 +32596,11 @@ var ts; // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token()) { - case 107 /* ThisKeyword */: - case 105 /* SuperKeyword */: - case 103 /* NullKeyword */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: + case 108 /* ThisKeyword */: + case 106 /* SuperKeyword */: + case 104 /* NullKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: @@ -31452,14 +32609,14 @@ var ts; case 20 /* OpenParenToken */: case 22 /* OpenBracketToken */: case 18 /* OpenBraceToken */: - case 97 /* FunctionKeyword */: - case 83 /* ClassKeyword */: - case 102 /* NewKeyword */: + case 98 /* FunctionKeyword */: + case 84 /* ClassKeyword */: + case 103 /* NewKeyword */: case 43 /* SlashToken */: - case 67 /* SlashEqualsToken */: - case 78 /* Identifier */: + case 68 /* SlashEqualsToken */: + case 79 /* Identifier */: return true; - case 99 /* ImportKeyword */: + case 100 /* ImportKeyword */: return lookAhead(nextTokenIsOpenParenOrLessThanOrDot); default: return isIdentifier(); @@ -31474,15 +32631,15 @@ var ts; case 40 /* MinusToken */: case 54 /* TildeToken */: case 53 /* ExclamationToken */: - case 88 /* DeleteKeyword */: - case 111 /* TypeOfKeyword */: - case 113 /* VoidKeyword */: + case 89 /* DeleteKeyword */: + case 112 /* TypeOfKeyword */: + case 114 /* VoidKeyword */: case 45 /* PlusPlusToken */: case 46 /* MinusMinusToken */: case 29 /* LessThanToken */: - case 130 /* AwaitKeyword */: - case 124 /* YieldKeyword */: - case 79 /* PrivateIdentifier */: + case 131 /* AwaitKeyword */: + case 125 /* YieldKeyword */: + case 80 /* 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. @@ -31501,8 +32658,8 @@ var ts; function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. return token() !== 18 /* OpenBraceToken */ && - token() !== 97 /* FunctionKeyword */ && - token() !== 83 /* ClassKeyword */ && + token() !== 98 /* FunctionKeyword */ && + token() !== 84 /* ClassKeyword */ && token() !== 59 /* AtToken */ && isStartOfExpression(); } @@ -31527,7 +32684,7 @@ var ts; return expr; } function parseInitializer() { - return parseOptional(62 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; + return parseOptional(63 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; } function parseAssignmentExpressionOrHigher() { // AssignmentExpression[in,yield]: @@ -31573,7 +32730,7 @@ var ts; // 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 === 78 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { + if (expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(pos, expr, /*asyncModifier*/ undefined); } // Now see if we might be in cases '2' or '3'. @@ -31589,7 +32746,7 @@ var ts; return parseConditionalExpressionRest(expr, pos); } function isYieldExpression() { - if (token() === 124 /* YieldKeyword */) { + if (token() === 125 /* 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()) { @@ -31669,7 +32826,7 @@ 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() === 129 /* AsyncKeyword */) { + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */ || token() === 130 /* AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } if (token() === 38 /* EqualsGreaterThanToken */) { @@ -31682,7 +32839,7 @@ var ts; return 0 /* False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 129 /* AsyncKeyword */) { + if (token() === 130 /* AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0 /* False */; @@ -31726,13 +32883,13 @@ var ts; // 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 !== 129 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { + if (ts.isModifierKind(second) && second !== 130 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { return 1 /* 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 !== 107 /* ThisKeyword */) { + if (!isIdentifier() && second !== 108 /* ThisKeyword */) { return 0 /* False */; } switch (nextToken()) { @@ -31743,13 +32900,13 @@ var ts; case 57 /* 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() === 62 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { + if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 63 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { return 1 /* True */; } // Otherwise it is definitely not a lambda. return 0 /* False */; case 27 /* CommaToken */: - case 62 /* EqualsToken */: + case 63 /* EqualsToken */: case 21 /* CloseParenToken */: // If we have "(a," or "(a=" or "(a)" this *could* be an arrow function return 2 /* Unknown */; @@ -31768,10 +32925,10 @@ var ts; if (languageVariant === 1 /* JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 93 /* ExtendsKeyword */) { + if (third === 94 /* ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 62 /* EqualsToken */: + case 63 /* EqualsToken */: case 31 /* GreaterThanToken */: return false; default: @@ -31805,7 +32962,7 @@ var ts; } function tryParseAsyncSimpleArrowFunctionExpression() { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" - if (token() === 129 /* AsyncKeyword */) { + if (token() === 130 /* AsyncKeyword */) { if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) { var pos = getNodePos(); var asyncModifier = parseModifiersForArrowFunction(); @@ -31819,7 +32976,7 @@ 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() === 129 /* AsyncKeyword */) { + if (token() === 130 /* 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" @@ -31828,7 +32985,7 @@ var ts; } // Check for un-parenthesized AsyncArrowFunction var expr = parseBinaryExpressionOrHigher(0 /* Lowest */); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 78 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { + if (!scanner.hasPrecedingLineBreak() && expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { return 1 /* True */; } } @@ -31893,8 +33050,8 @@ var ts; return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */); } if (token() !== 26 /* SemicolonToken */ && - token() !== 97 /* FunctionKeyword */ && - token() !== 83 /* ClassKeyword */ && + token() !== 98 /* FunctionKeyword */ && + token() !== 84 /* ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -31932,7 +33089,7 @@ var ts; var colonToken; return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher), colonToken = parseExpectedToken(58 /* ColonToken */), ts.nodeIsPresent(colonToken) ? parseAssignmentExpressionOrHigher() - : createMissingNode(78 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */))), pos); + : createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */))), pos); } function parseBinaryExpressionOrHigher(precedence) { var pos = getNodePos(); @@ -31940,7 +33097,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand, pos); } function isInOrOfKeyword(t) { - return t === 100 /* InKeyword */ || t === 156 /* OfKeyword */; + return t === 101 /* InKeyword */ || t === 158 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand, pos) { while (true) { @@ -31975,10 +33132,10 @@ var ts; if (!consumeCurrentOperator) { break; } - if (token() === 100 /* InKeyword */ && inDisallowInContext()) { + if (token() === 101 /* InKeyword */ && inDisallowInContext()) { break; } - if (token() === 126 /* AsKeyword */) { + if (token() === 127 /* AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -31999,7 +33156,7 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 100 /* InKeyword */) { + if (inDisallowInContext() && token() === 101 /* InKeyword */) { return false; } return ts.getBinaryOperatorPrecedence(token()) > 0; @@ -32027,7 +33184,7 @@ var ts; return finishNode(factory.createVoidExpression(nextTokenAnd(parseSimpleUnaryExpression)), pos); } function isAwaitExpression() { - if (token() === 130 /* AwaitKeyword */) { + if (token() === 131 /* AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -32080,7 +33237,7 @@ var ts; if (token() === 42 /* AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 206 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 208 /* 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 { @@ -32110,18 +33267,18 @@ var ts; case 54 /* TildeToken */: case 53 /* ExclamationToken */: return parsePrefixUnaryExpression(); - case 88 /* DeleteKeyword */: + case 89 /* DeleteKeyword */: return parseDeleteExpression(); - case 111 /* TypeOfKeyword */: + case 112 /* TypeOfKeyword */: return parseTypeOfExpression(); - case 113 /* VoidKeyword */: + case 114 /* VoidKeyword */: return parseVoidExpression(); case 29 /* LessThanToken */: // This is modified UnaryExpression grammar in TypeScript // UnaryExpression (modified): // < type > UnaryExpression return parseTypeAssertion(); - case 130 /* AwaitKeyword */: + case 131 /* AwaitKeyword */: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -32148,10 +33305,10 @@ var ts; case 40 /* MinusToken */: case 54 /* TildeToken */: case 53 /* ExclamationToken */: - case 88 /* DeleteKeyword */: - case 111 /* TypeOfKeyword */: - case 113 /* VoidKeyword */: - case 130 /* AwaitKeyword */: + case 89 /* DeleteKeyword */: + case 112 /* TypeOfKeyword */: + case 114 /* VoidKeyword */: + case 131 /* AwaitKeyword */: return false; case 29 /* LessThanToken */: // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression @@ -32227,7 +33384,7 @@ var ts; // or starts the beginning of the first four CallExpression productions. var pos = getNodePos(); var expression; - if (token() === 99 /* ImportKeyword */) { + if (token() === 100 /* 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: @@ -32241,7 +33398,7 @@ var ts; // This is an 'import.*' metaproperty (i.e. 'import.meta') nextToken(); // advance past the 'import' nextToken(); // advance past the dot - expression = finishNode(factory.createMetaProperty(99 /* ImportKeyword */, parseIdentifierName()), pos); + expression = finishNode(factory.createMetaProperty(100 /* ImportKeyword */, parseIdentifierName()), pos); sourceFlags |= 2097152 /* PossiblyContainsImportMeta */; } else { @@ -32249,7 +33406,7 @@ var ts; } } else { - expression = token() === 105 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); + expression = token() === 106 /* 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 @@ -32327,23 +33484,45 @@ var ts; // 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); } - function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext, topInvalidNodePosition) { + function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext, topInvalidNodePosition, openingTag) { var pos = getNodePos(); var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 275 /* JsxOpeningElement */) { + if (opening.kind === 277 /* JsxOpeningElement */) { var children = parseJsxChildren(opening); - var closingElement = parseJsxClosingElement(inExpressionContext); - if (!tagNamesAreEquivalent(opening.tagName, closingElement.tagName)) { - parseErrorAtRange(closingElement, ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNodeFromSourceText(sourceText, opening.tagName)); + var closingElement = void 0; + var lastChild = children[children.length - 1]; + if ((lastChild === null || lastChild === void 0 ? void 0 : lastChild.kind) === 275 /* JsxElement */ + && !tagNamesAreEquivalent(lastChild.openingElement.tagName, lastChild.closingElement.tagName) + && tagNamesAreEquivalent(opening.tagName, lastChild.closingElement.tagName)) { + // when an unclosed JsxOpeningElement incorrectly parses its parent's JsxClosingElement, + // restructure (
(...
)) --> (
(...)
) + // (no need to error; the parent will error) + var end = lastChild.openingElement.end; // newly-created children and closing are both zero-width end/end + var newLast = finishNode(factory.createJsxElement(lastChild.openingElement, createNodeArray([], end, end), finishNode(factory.createJsxClosingElement(finishNode(factory.createIdentifier(""), end, end)), end, end)), lastChild.openingElement.pos, end); + children = createNodeArray(__spreadArray(__spreadArray([], children.slice(0, children.length - 1)), [newLast]), children.pos, end); + closingElement = lastChild.closingElement; + } + else { + closingElement = parseJsxClosingElement(opening, inExpressionContext); + if (!tagNamesAreEquivalent(opening.tagName, closingElement.tagName)) { + if (openingTag && ts.isJsxOpeningElement(openingTag) && tagNamesAreEquivalent(closingElement.tagName, openingTag.tagName)) { + // opening incorrectly matched with its parent's closing -- put error on opening + parseErrorAtRange(opening.tagName, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, opening.tagName)); + } + else { + // other opening/closing mismatches -- put error on closing + parseErrorAtRange(closingElement.tagName, ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNodeFromSourceText(sourceText, opening.tagName)); + } + } } result = finishNode(factory.createJsxElement(opening, children, closingElement), pos); } - else if (opening.kind === 278 /* JsxOpeningFragment */) { + else if (opening.kind === 280 /* JsxOpeningFragment */) { result = finishNode(factory.createJsxFragment(opening, parseJsxChildren(opening), parseJsxClosingFragment(inExpressionContext)), pos); } else { - ts.Debug.assert(opening.kind === 274 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 276 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -32397,7 +33576,7 @@ var ts; case 18 /* OpenBraceToken */: return parseJsxExpression(/*inExpressionContext*/ false); case 29 /* LessThanToken */: - return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ false); + return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ false, /*topInvalidNodePosition*/ undefined, openingTag); default: return ts.Debug.assertNever(token); } @@ -32412,6 +33591,13 @@ var ts; if (!child) break; list.push(child); + if (ts.isJsxOpeningElement(openingTag) + && (child === null || child === void 0 ? void 0 : child.kind) === 275 /* 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 + break; + } } parsingContext = saveParsingContext; return createNodeArray(list, listPos); @@ -32441,12 +33627,14 @@ var ts; } else { parseExpected(43 /* SlashToken */); - if (inExpressionContext) { - parseExpected(31 /* GreaterThanToken */); - } - else { - parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); - scanJsxText(); + if (parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { + // manually advance the scanner in order to look for jsx text inside jsx + if (inExpressionContext) { + nextToken(); + } + else { + scanJsxText(); + } } node = factory.createJsxSelfClosingElement(tagName, typeArguments, attributes); } @@ -32460,7 +33648,7 @@ 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() === 107 /* ThisKeyword */ ? + var expression = token() === 108 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); while (parseOptional(24 /* DotToken */)) { expression = finishNode(factory.createPropertyAccessExpression(expression, parseRightSideOfDot(/*allowIdentifierNames*/ true, /*allowPrivateIdentifiers*/ false)), pos); @@ -32497,7 +33685,7 @@ var ts; } scanJsxIdentifier(); var pos = getNodePos(); - return finishNode(factory.createJsxAttribute(parseIdentifierName(), token() !== 62 /* EqualsToken */ ? undefined : + return finishNode(factory.createJsxAttribute(parseIdentifierName(), token() !== 63 /* EqualsToken */ ? undefined : scanJsxAttributeValue() === 10 /* StringLiteral */ ? parseLiteralNode() : parseJsxExpression(/*inExpressionContext*/ true)), pos); } @@ -32509,16 +33697,18 @@ var ts; parseExpected(19 /* CloseBraceToken */); return finishNode(factory.createJsxSpreadAttribute(expression), pos); } - function parseJsxClosingElement(inExpressionContext) { + function parseJsxClosingElement(open, inExpressionContext) { var pos = getNodePos(); parseExpected(30 /* LessThanSlashToken */); var tagName = parseJsxElementName(); - if (inExpressionContext) { - parseExpected(31 /* GreaterThanToken */); - } - else { - parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); - scanJsxText(); + if (parseExpected(31 /* 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(); + } + else { + scanJsxText(); + } } return finishNode(factory.createJsxClosingElement(tagName), pos); } @@ -32528,12 +33718,14 @@ var ts; if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); } - if (inExpressionContext) { - parseExpected(31 /* GreaterThanToken */); - } - else { - parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); - scanJsxText(); + if (parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { + // manually advance the scanner in order to look for jsx text inside jsx + if (inExpressionContext) { + nextToken(); + } + else { + scanJsxText(); + } } return finishNode(factory.createJsxJsxClosingFragment(), pos); } @@ -32590,7 +33782,7 @@ var ts; function parseElementAccessExpressionRest(pos, expression, questionDotToken) { var argumentExpression; if (token() === 23 /* CloseBracketToken */) { - argumentExpression = createMissingNode(78 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); + argumentExpression = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); } else { var argument = allowInAnd(parseExpression); @@ -32685,7 +33877,7 @@ var ts; } if (questionDotToken) { // We failed to parse anything, so report a missing identifier here. - var name = createMissingNode(78 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected); + var name = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected); expression = finishNode(factory.createPropertyAccessChain(expression, questionDotToken, name), pos); } break; @@ -32766,11 +33958,11 @@ var ts; case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 107 /* ThisKeyword */: - case 105 /* SuperKeyword */: - case 103 /* NullKeyword */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: + case 108 /* ThisKeyword */: + case 106 /* SuperKeyword */: + case 104 /* NullKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: return parseTokenNode(); case 20 /* OpenParenToken */: return parseParenthesizedExpression(); @@ -32778,7 +33970,7 @@ var ts; return parseArrayLiteralExpression(); case 18 /* OpenBraceToken */: return parseObjectLiteralExpression(); - case 129 /* AsyncKeyword */: + case 130 /* 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. @@ -32786,14 +33978,14 @@ var ts; break; } return parseFunctionExpression(); - case 83 /* ClassKeyword */: + case 84 /* ClassKeyword */: return parseClassExpression(); - case 97 /* FunctionKeyword */: + case 98 /* FunctionKeyword */: return parseFunctionExpression(); - case 102 /* NewKeyword */: + case 103 /* NewKeyword */: return parseNewExpressionOrNewDotTarget(); case 43 /* SlashToken */: - case 67 /* SlashEqualsToken */: + case 68 /* SlashEqualsToken */: if (reScanSlashToken() === 13 /* RegularExpressionLiteral */) { return parseLiteralNode(); } @@ -32842,11 +34034,11 @@ var ts; } var decorators = parseDecorators(); var modifiers = parseModifiers(); - if (parseContextualModifier(134 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 167 /* GetAccessor */); + if (parseContextualModifier(135 /* GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 169 /* GetAccessor */); } - if (parseContextualModifier(146 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 168 /* SetAccessor */); + if (parseContextualModifier(147 /* SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 170 /* SetAccessor */); } var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); @@ -32865,7 +34057,7 @@ var ts; var node; var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* ColonToken */); if (isShorthandPropertyAssignment) { - var equalsToken = parseOptionalToken(62 /* EqualsToken */); + var equalsToken = parseOptionalToken(63 /* EqualsToken */); var objectAssignmentInitializer = equalsToken ? allowInAnd(parseAssignmentExpressionOrHigher) : undefined; node = factory.createShorthandPropertyAssignment(name, objectAssignmentInitializer); // Save equals token for error reporting. @@ -32911,7 +34103,7 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiers(); - parseExpected(97 /* FunctionKeyword */); + 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 */; @@ -32934,10 +34126,10 @@ var ts; } function parseNewExpressionOrNewDotTarget() { var pos = getNodePos(); - parseExpected(102 /* NewKeyword */); + parseExpected(103 /* NewKeyword */); if (parseOptional(24 /* DotToken */)) { var name = parseIdentifierName(); - return finishNode(factory.createMetaProperty(102 /* NewKeyword */, name), pos); + return finishNode(factory.createMetaProperty(103 /* NewKeyword */, name), pos); } var expressionPos = getNodePos(); var expression = parsePrimaryExpression(); @@ -32964,6 +34156,7 @@ var ts; // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { var pos = getNodePos(); + var hasJSDoc = hasPrecedingJSDocComment(); var openBracePosition = scanner.getTokenPos(); if (parseExpected(18 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { var multiLine = scanner.hasPrecedingLineBreak(); @@ -32974,11 +34167,16 @@ var ts; ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here)); } } - return finishNode(factory.createBlock(statements, multiLine), pos); + var result = withJSDoc(finishNode(factory.createBlock(statements, multiLine), pos), hasJSDoc); + if (token() === 63 /* 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(); + } + return result; } else { var statements = createMissingList(); - return finishNode(factory.createBlock(statements, /*multiLine*/ undefined), pos); + return withJSDoc(finishNode(factory.createBlock(statements, /*multiLine*/ undefined), pos), hasJSDoc); } } function parseFunctionBlock(flags, diagnosticMessage) { @@ -33005,24 +34203,27 @@ var ts; } function parseEmptyStatement() { var pos = getNodePos(); + var hasJSDoc = hasPrecedingJSDocComment(); parseExpected(26 /* SemicolonToken */); - return finishNode(factory.createEmptyStatement(), pos); + return withJSDoc(finishNode(factory.createEmptyStatement(), pos), hasJSDoc); } function parseIfStatement() { var pos = getNodePos(); - parseExpected(98 /* IfKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(99 /* IfKeyword */); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); var thenStatement = parseStatement(); - var elseStatement = parseOptional(90 /* ElseKeyword */) ? parseStatement() : undefined; - return finishNode(factory.createIfStatement(expression, thenStatement, elseStatement), pos); + var elseStatement = parseOptional(91 /* ElseKeyword */) ? parseStatement() : undefined; + return withJSDoc(finishNode(factory.createIfStatement(expression, thenStatement, elseStatement), pos), hasJSDoc); } function parseDoStatement() { var pos = getNodePos(); - parseExpected(89 /* DoKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(90 /* DoKeyword */); var statement = parseStatement(); - parseExpected(114 /* WhileKeyword */); + parseExpected(115 /* WhileKeyword */); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); @@ -33031,25 +34232,27 @@ var ts; // 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 */); - return finishNode(factory.createDoStatement(statement, expression), pos); + return withJSDoc(finishNode(factory.createDoStatement(statement, expression), pos), hasJSDoc); } function parseWhileStatement() { var pos = getNodePos(); - parseExpected(114 /* WhileKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(115 /* WhileKeyword */); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); var statement = parseStatement(); - return finishNode(factory.createWhileStatement(expression, statement), pos); + return withJSDoc(finishNode(factory.createWhileStatement(expression, statement), pos), hasJSDoc); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(96 /* ForKeyword */); - var awaitToken = parseOptionalToken(130 /* AwaitKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(97 /* ForKeyword */); + var awaitToken = parseOptionalToken(131 /* AwaitKeyword */); parseExpected(20 /* OpenParenToken */); var initializer; if (token() !== 26 /* SemicolonToken */) { - if (token() === 112 /* VarKeyword */ || token() === 118 /* LetKeyword */ || token() === 84 /* ConstKeyword */) { + if (token() === 113 /* VarKeyword */ || token() === 119 /* LetKeyword */ || token() === 85 /* ConstKeyword */) { initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { @@ -33057,12 +34260,12 @@ var ts; } } var node; - if (awaitToken ? parseExpected(156 /* OfKeyword */) : parseOptional(156 /* OfKeyword */)) { + if (awaitToken ? parseExpected(158 /* OfKeyword */) : parseOptional(158 /* OfKeyword */)) { var expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(21 /* CloseParenToken */); node = factory.createForOfStatement(awaitToken, initializer, expression, parseStatement()); } - else if (parseOptional(100 /* InKeyword */)) { + else if (parseOptional(101 /* InKeyword */)) { var expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); node = factory.createForInStatement(initializer, expression, parseStatement()); @@ -33079,37 +34282,40 @@ var ts; parseExpected(21 /* CloseParenToken */); node = factory.createForStatement(initializer, condition, incrementor, parseStatement()); } - return finishNode(node, pos); + return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseBreakOrContinueStatement(kind) { var pos = getNodePos(); - parseExpected(kind === 241 /* BreakStatement */ ? 80 /* BreakKeyword */ : 85 /* ContinueKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(kind === 243 /* BreakStatement */ ? 81 /* BreakKeyword */ : 86 /* ContinueKeyword */); var label = canParseSemicolon() ? undefined : parseIdentifier(); parseSemicolon(); - var node = kind === 241 /* BreakStatement */ + var node = kind === 243 /* BreakStatement */ ? factory.createBreakStatement(label) : factory.createContinueStatement(label); - return finishNode(node, pos); + return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseReturnStatement() { var pos = getNodePos(); - parseExpected(104 /* ReturnKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(105 /* ReturnKeyword */); var expression = canParseSemicolon() ? undefined : allowInAnd(parseExpression); parseSemicolon(); - return finishNode(factory.createReturnStatement(expression), pos); + return withJSDoc(finishNode(factory.createReturnStatement(expression), pos), hasJSDoc); } function parseWithStatement() { var pos = getNodePos(); - parseExpected(115 /* WithKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(116 /* WithKeyword */); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); var statement = doInsideOfContext(16777216 /* InWithStatement */, parseStatement); - return finishNode(factory.createWithStatement(expression, statement), pos); + return withJSDoc(finishNode(factory.createWithStatement(expression, statement), pos), hasJSDoc); } function parseCaseClause() { var pos = getNodePos(); - parseExpected(81 /* CaseKeyword */); + parseExpected(82 /* CaseKeyword */); var expression = allowInAnd(parseExpression); parseExpected(58 /* ColonToken */); var statements = parseList(3 /* SwitchClauseStatements */, parseStatement); @@ -33117,13 +34323,13 @@ var ts; } function parseDefaultClause() { var pos = getNodePos(); - parseExpected(87 /* DefaultKeyword */); + parseExpected(88 /* DefaultKeyword */); parseExpected(58 /* ColonToken */); var statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(factory.createDefaultClause(statements), pos); } function parseCaseOrDefaultClause() { - return token() === 81 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token() === 82 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseCaseBlock() { var pos = getNodePos(); @@ -33134,18 +34340,20 @@ var ts; } function parseSwitchStatement() { var pos = getNodePos(); - parseExpected(106 /* SwitchKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(107 /* SwitchKeyword */); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); var caseBlock = parseCaseBlock(); - return finishNode(factory.createSwitchStatement(expression, caseBlock), pos); + return withJSDoc(finishNode(factory.createSwitchStatement(expression, caseBlock), pos), hasJSDoc); } function parseThrowStatement() { // ThrowStatement[Yield] : // throw [no LineTerminator here]Expression[In, ?Yield]; var pos = getNodePos(); - parseExpected(108 /* ThrowKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(109 /* 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. @@ -33157,26 +34365,27 @@ var ts; expression = finishNode(factory.createIdentifier(""), getNodePos()); } parseSemicolon(); - return finishNode(factory.createThrowStatement(expression), pos); + return withJSDoc(finishNode(factory.createThrowStatement(expression), pos), hasJSDoc); } // TODO: Review for error recovery function parseTryStatement() { var pos = getNodePos(); - parseExpected(110 /* TryKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(111 /* TryKeyword */); var tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); - var catchClause = token() === 82 /* CatchKeyword */ ? parseCatchClause() : undefined; + var catchClause = token() === 83 /* 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() === 95 /* FinallyKeyword */) { - parseExpected(95 /* FinallyKeyword */); + if (!catchClause || token() === 96 /* FinallyKeyword */) { + parseExpected(96 /* FinallyKeyword */); finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } - return finishNode(factory.createTryStatement(tryBlock, catchClause, finallyBlock), pos); + return withJSDoc(finishNode(factory.createTryStatement(tryBlock, catchClause, finallyBlock), pos), hasJSDoc); } function parseCatchClause() { var pos = getNodePos(); - parseExpected(82 /* CatchKeyword */); + parseExpected(83 /* CatchKeyword */); var variableDeclaration; if (parseOptional(20 /* OpenParenToken */)) { variableDeclaration = parseVariableDeclaration(); @@ -33191,9 +34400,10 @@ var ts; } function parseDebuggerStatement() { var pos = getNodePos(); - parseExpected(86 /* DebuggerKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(87 /* DebuggerKeyword */); parseSemicolon(); - return finishNode(factory.createDebuggerStatement(), pos); + return withJSDoc(finishNode(factory.createDebuggerStatement(), pos), hasJSDoc); } function parseExpressionOrLabeledStatement() { // Avoiding having to do the lookahead for a labeled statement by just trying to parse @@ -33223,11 +34433,11 @@ var ts; } function nextTokenIsClassKeywordOnSameLine() { nextToken(); - return token() === 83 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 84 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 97 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 98 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine() { nextToken(); @@ -33236,12 +34446,12 @@ var ts; function isDeclaration() { while (true) { switch (token()) { - case 112 /* VarKeyword */: - case 118 /* LetKeyword */: - case 84 /* ConstKeyword */: - case 97 /* FunctionKeyword */: - case 83 /* ClassKeyword */: - case 91 /* EnumKeyword */: + case 113 /* VarKeyword */: + case 119 /* LetKeyword */: + case 85 /* ConstKeyword */: + case 98 /* FunctionKeyword */: + case 84 /* ClassKeyword */: + case 92 /* 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 @@ -33264,44 +34474,44 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 117 /* InterfaceKeyword */: - case 149 /* TypeKeyword */: + case 118 /* InterfaceKeyword */: + case 150 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 139 /* ModuleKeyword */: - case 140 /* NamespaceKeyword */: + case 140 /* ModuleKeyword */: + case 141 /* NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 125 /* AbstractKeyword */: - case 129 /* AsyncKeyword */: - case 133 /* DeclareKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 122 /* PublicKeyword */: - case 142 /* ReadonlyKeyword */: + case 126 /* AbstractKeyword */: + case 130 /* AsyncKeyword */: + case 134 /* DeclareKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + case 123 /* PublicKeyword */: + case 143 /* ReadonlyKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 154 /* GlobalKeyword */: + case 155 /* GlobalKeyword */: nextToken(); - return token() === 18 /* OpenBraceToken */ || token() === 78 /* Identifier */ || token() === 92 /* ExportKeyword */; - case 99 /* ImportKeyword */: + return token() === 18 /* OpenBraceToken */ || token() === 79 /* Identifier */ || token() === 93 /* ExportKeyword */; + case 100 /* ImportKeyword */: nextToken(); return token() === 10 /* StringLiteral */ || token() === 41 /* AsteriskToken */ || token() === 18 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); - case 92 /* ExportKeyword */: + case 93 /* ExportKeyword */: var currentToken_1 = nextToken(); - if (currentToken_1 === 149 /* TypeKeyword */) { + if (currentToken_1 === 150 /* TypeKeyword */) { currentToken_1 = lookAhead(nextToken); } - if (currentToken_1 === 62 /* EqualsToken */ || currentToken_1 === 41 /* AsteriskToken */ || - currentToken_1 === 18 /* OpenBraceToken */ || currentToken_1 === 87 /* DefaultKeyword */ || - currentToken_1 === 126 /* AsKeyword */) { + if (currentToken_1 === 63 /* EqualsToken */ || currentToken_1 === 41 /* AsteriskToken */ || + currentToken_1 === 18 /* OpenBraceToken */ || currentToken_1 === 88 /* DefaultKeyword */ || + currentToken_1 === 127 /* AsKeyword */) { return true; } continue; - case 123 /* StaticKeyword */: + case 124 /* StaticKeyword */: nextToken(); continue; default: @@ -33317,48 +34527,48 @@ var ts; case 59 /* AtToken */: case 26 /* SemicolonToken */: case 18 /* OpenBraceToken */: - case 112 /* VarKeyword */: - case 118 /* LetKeyword */: - case 97 /* FunctionKeyword */: - case 83 /* ClassKeyword */: - case 91 /* EnumKeyword */: - case 98 /* IfKeyword */: - case 89 /* DoKeyword */: - case 114 /* WhileKeyword */: - case 96 /* ForKeyword */: - case 85 /* ContinueKeyword */: - case 80 /* BreakKeyword */: - case 104 /* ReturnKeyword */: - case 115 /* WithKeyword */: - case 106 /* SwitchKeyword */: - case 108 /* ThrowKeyword */: - case 110 /* TryKeyword */: - case 86 /* DebuggerKeyword */: + 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 */: // '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 82 /* CatchKeyword */: - case 95 /* FinallyKeyword */: + case 83 /* CatchKeyword */: + case 96 /* FinallyKeyword */: return true; - case 99 /* ImportKeyword */: + case 100 /* ImportKeyword */: return isStartOfDeclaration() || lookAhead(nextTokenIsOpenParenOrLessThanOrDot); - case 84 /* ConstKeyword */: - case 92 /* ExportKeyword */: + case 85 /* ConstKeyword */: + case 93 /* ExportKeyword */: return isStartOfDeclaration(); - case 129 /* AsyncKeyword */: - case 133 /* DeclareKeyword */: - case 117 /* InterfaceKeyword */: - case 139 /* ModuleKeyword */: - case 140 /* NamespaceKeyword */: - case 149 /* TypeKeyword */: - case 154 /* GlobalKeyword */: + case 130 /* AsyncKeyword */: + case 134 /* DeclareKeyword */: + case 118 /* InterfaceKeyword */: + case 140 /* ModuleKeyword */: + case 141 /* NamespaceKeyword */: + case 150 /* TypeKeyword */: + case 155 /* GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 122 /* PublicKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 123 /* StaticKeyword */: - case 142 /* ReadonlyKeyword */: + case 123 /* PublicKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + case 124 /* StaticKeyword */: + case 143 /* 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); @@ -33381,64 +34591,64 @@ var ts; return parseEmptyStatement(); case 18 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); - case 112 /* VarKeyword */: + case 113 /* VarKeyword */: return parseVariableStatement(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 118 /* LetKeyword */: + case 119 /* LetKeyword */: if (isLetDeclaration()) { return parseVariableStatement(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); } break; - case 97 /* FunctionKeyword */: + case 98 /* FunctionKeyword */: return parseFunctionDeclaration(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 83 /* ClassKeyword */: + case 84 /* ClassKeyword */: return parseClassDeclaration(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 98 /* IfKeyword */: + case 99 /* IfKeyword */: return parseIfStatement(); - case 89 /* DoKeyword */: + case 90 /* DoKeyword */: return parseDoStatement(); - case 114 /* WhileKeyword */: + case 115 /* WhileKeyword */: return parseWhileStatement(); - case 96 /* ForKeyword */: + case 97 /* ForKeyword */: return parseForOrForInOrForOfStatement(); - case 85 /* ContinueKeyword */: - return parseBreakOrContinueStatement(240 /* ContinueStatement */); - case 80 /* BreakKeyword */: - return parseBreakOrContinueStatement(241 /* BreakStatement */); - case 104 /* ReturnKeyword */: + case 86 /* ContinueKeyword */: + return parseBreakOrContinueStatement(242 /* ContinueStatement */); + case 81 /* BreakKeyword */: + return parseBreakOrContinueStatement(243 /* BreakStatement */); + case 105 /* ReturnKeyword */: return parseReturnStatement(); - case 115 /* WithKeyword */: + case 116 /* WithKeyword */: return parseWithStatement(); - case 106 /* SwitchKeyword */: + case 107 /* SwitchKeyword */: return parseSwitchStatement(); - case 108 /* ThrowKeyword */: + case 109 /* ThrowKeyword */: return parseThrowStatement(); - case 110 /* TryKeyword */: + case 111 /* TryKeyword */: // Include 'catch' and 'finally' for error recovery. // falls through - case 82 /* CatchKeyword */: - case 95 /* FinallyKeyword */: + case 83 /* CatchKeyword */: + case 96 /* FinallyKeyword */: return parseTryStatement(); - case 86 /* DebuggerKeyword */: + case 87 /* DebuggerKeyword */: return parseDebuggerStatement(); case 59 /* AtToken */: return parseDeclaration(); - case 129 /* AsyncKeyword */: - case 117 /* InterfaceKeyword */: - case 149 /* TypeKeyword */: - case 139 /* ModuleKeyword */: - case 140 /* NamespaceKeyword */: - case 133 /* DeclareKeyword */: - case 84 /* ConstKeyword */: - case 91 /* EnumKeyword */: - case 92 /* ExportKeyword */: - case 99 /* ImportKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 122 /* PublicKeyword */: - case 125 /* AbstractKeyword */: - case 123 /* StaticKeyword */: - case 142 /* ReadonlyKeyword */: - case 154 /* GlobalKeyword */: + case 130 /* AsyncKeyword */: + case 118 /* InterfaceKeyword */: + case 150 /* TypeKeyword */: + case 140 /* ModuleKeyword */: + case 141 /* NamespaceKeyword */: + case 134 /* 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 143 /* ReadonlyKeyword */: + case 155 /* GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -33447,7 +34657,7 @@ var ts; return parseExpressionOrLabeledStatement(); } function isDeclareModifier(modifier) { - return modifier.kind === 133 /* DeclareKeyword */; + return modifier.kind === 134 /* DeclareKeyword */; } function parseDeclaration() { // TODO: Can we hold onto the parsed decorators/modifiers and advance the scanner @@ -33488,33 +34698,33 @@ var ts; } function parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers) { switch (token()) { - case 112 /* VarKeyword */: - case 118 /* LetKeyword */: - case 84 /* ConstKeyword */: + case 113 /* VarKeyword */: + case 119 /* LetKeyword */: + case 85 /* ConstKeyword */: return parseVariableStatement(pos, hasJSDoc, decorators, modifiers); - case 97 /* FunctionKeyword */: + case 98 /* FunctionKeyword */: return parseFunctionDeclaration(pos, hasJSDoc, decorators, modifiers); - case 83 /* ClassKeyword */: + case 84 /* ClassKeyword */: return parseClassDeclaration(pos, hasJSDoc, decorators, modifiers); - case 117 /* InterfaceKeyword */: + case 118 /* InterfaceKeyword */: return parseInterfaceDeclaration(pos, hasJSDoc, decorators, modifiers); - case 149 /* TypeKeyword */: + case 150 /* TypeKeyword */: return parseTypeAliasDeclaration(pos, hasJSDoc, decorators, modifiers); - case 91 /* EnumKeyword */: + case 92 /* EnumKeyword */: return parseEnumDeclaration(pos, hasJSDoc, decorators, modifiers); - case 154 /* GlobalKeyword */: - case 139 /* ModuleKeyword */: - case 140 /* NamespaceKeyword */: + case 155 /* GlobalKeyword */: + case 140 /* ModuleKeyword */: + case 141 /* NamespaceKeyword */: return parseModuleDeclaration(pos, hasJSDoc, decorators, modifiers); - case 99 /* ImportKeyword */: + case 100 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers); - case 92 /* ExportKeyword */: + case 93 /* ExportKeyword */: nextToken(); switch (token()) { - case 87 /* DefaultKeyword */: - case 62 /* EqualsToken */: + case 88 /* DefaultKeyword */: + case 63 /* EqualsToken */: return parseExportAssignment(pos, hasJSDoc, decorators, modifiers); - case 126 /* AsKeyword */: + case 127 /* AsKeyword */: return parseNamespaceExportDeclaration(pos, hasJSDoc, decorators, modifiers); default: return parseExportDeclaration(pos, hasJSDoc, decorators, modifiers); @@ -33523,7 +34733,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(271 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(273 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); ts.setTextRangePos(missing, pos); missing.decorators = decorators; missing.modifiers = modifiers; @@ -33588,7 +34798,7 @@ var ts; function isBindingIdentifierOrPrivateIdentifierOrPattern() { return token() === 18 /* OpenBraceToken */ || token() === 22 /* OpenBracketToken */ - || token() === 79 /* PrivateIdentifier */ + || token() === 80 /* PrivateIdentifier */ || isBindingIdentifier(); } function parseIdentifierOrPattern(privateIdentifierDiagnosticMessage) { @@ -33605,27 +34815,28 @@ var ts; } function parseVariableDeclaration(allowExclamation) { var pos = getNodePos(); + var hasJSDoc = hasPrecedingJSDocComment(); var name = parseIdentifierOrPattern(ts.Diagnostics.Private_identifiers_are_not_allowed_in_variable_declarations); var exclamationToken; - if (allowExclamation && name.kind === 78 /* Identifier */ && + if (allowExclamation && name.kind === 79 /* Identifier */ && token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { exclamationToken = parseTokenNode(); } var type = parseTypeAnnotation(); var initializer = isInOrOfKeyword(token()) ? undefined : parseInitializer(); var node = factory.createVariableDeclaration(name, exclamationToken, type, initializer); - return finishNode(node, pos); + return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseVariableDeclarationList(inForStatementInitializer) { var pos = getNodePos(); var flags = 0; switch (token()) { - case 112 /* VarKeyword */: + case 113 /* VarKeyword */: break; - case 118 /* LetKeyword */: + case 119 /* LetKeyword */: flags |= 1 /* Let */; break; - case 84 /* ConstKeyword */: + case 85 /* ConstKeyword */: flags |= 2 /* Const */; break; default: @@ -33642,7 +34853,7 @@ var ts; // this context. // The checker will then give an error that there is an empty declaration list. var declarations; - if (token() === 156 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 158 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { declarations = createMissingList(); } else { @@ -33667,7 +34878,7 @@ var ts; function parseFunctionDeclaration(pos, hasJSDoc, decorators, modifiers) { var savedAwaitContext = inAwaitContext(); var modifierFlags = ts.modifiersToFlags(modifiers); - parseExpected(97 /* FunctionKeyword */); + parseExpected(98 /* FunctionKeyword */); var asteriskToken = parseOptionalToken(41 /* 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(); @@ -33684,8 +34895,8 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseConstructorName() { - if (token() === 132 /* ConstructorKeyword */) { - return parseExpected(132 /* ConstructorKeyword */); + if (token() === 133 /* ConstructorKeyword */) { + return parseExpected(133 /* ConstructorKeyword */); } if (token() === 10 /* StringLiteral */ && lookAhead(nextToken) === 20 /* OpenParenToken */) { return tryParse(function () { @@ -33746,12 +34957,12 @@ var ts; var parameters = parseParameters(0 /* None */); var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); var body = parseFunctionBlockOrSemicolon(0 /* None */); - var node = kind === 167 /* GetAccessor */ + var node = kind === 169 /* GetAccessor */ ? factory.createGetAccessorDeclaration(decorators, modifiers, name, parameters, type, body) : factory.createSetAccessorDeclaration(decorators, modifiers, name, parameters, body); // Keep track of `typeParameters` (for both) and `type` (for setters) if they were parsed those indicate grammar errors node.typeParameters = typeParameters; - if (type && node.kind === 168 /* SetAccessor */) + if (type && node.kind === 170 /* SetAccessor */) node.type = type; return withJSDoc(finishNode(node, pos), hasJSDoc); } @@ -33790,7 +35001,7 @@ var ts; // 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 === 146 /* SetKeyword */ || idToken === 134 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 147 /* SetKeyword */ || idToken === 135 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along @@ -33800,7 +35011,7 @@ var ts; case 29 /* LessThanToken */: // Generic Method declaration case 53 /* ExclamationToken */: // Non-null assertion on property name case 58 /* ColonToken */: // Type Annotation for declaration - case 62 /* EqualsToken */: // Initializer for declaration + case 63 /* EqualsToken */: // Initializer for declaration case 57 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. return true; default: @@ -33815,7 +35026,7 @@ var ts; return false; } function parseDecoratorExpression() { - if (inAwaitContext() && token() === 130 /* AwaitKeyword */) { + if (inAwaitContext() && token() === 131 /* 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(); @@ -33845,7 +35056,7 @@ var ts; function tryParseModifier(permitInvalidConstAsModifier) { var pos = getNodePos(); var kind = token(); - if (token() === 84 /* ConstKeyword */ && permitInvalidConstAsModifier) { + if (token() === 85 /* 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)) { @@ -33876,10 +35087,10 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 129 /* AsyncKeyword */) { + if (token() === 130 /* AsyncKeyword */) { var pos = getNodePos(); nextToken(); - var modifier = finishNode(factory.createToken(129 /* AsyncKeyword */), pos); + var modifier = finishNode(factory.createToken(130 /* AsyncKeyword */), pos); modifiers = createNodeArray([modifier], pos); } return modifiers; @@ -33893,13 +35104,13 @@ var ts; var hasJSDoc = hasPrecedingJSDocComment(); var decorators = parseDecorators(); var modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true); - if (parseContextualModifier(134 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 167 /* GetAccessor */); + if (parseContextualModifier(135 /* GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 169 /* GetAccessor */); } - if (parseContextualModifier(146 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 168 /* SetAccessor */); + if (parseContextualModifier(147 /* SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 170 /* SetAccessor */); } - if (token() === 132 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { + if (token() === 133 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { var constructorDeclaration = tryParseConstructorDeclaration(pos, hasJSDoc, decorators, modifiers); if (constructorDeclaration) { return constructorDeclaration; @@ -33929,21 +35140,21 @@ var ts; } if (decorators || modifiers) { // treat this as a property declaration with a missing name. - var name = createMissingNode(78 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var name = createMissingNode(79 /* 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, 221 /* ClassExpression */); + return parseClassDeclarationOrExpression(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined, 223 /* ClassExpression */); } function parseClassDeclaration(pos, hasJSDoc, decorators, modifiers) { - return parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, 252 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, 254 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, kind) { var savedAwaitContext = inAwaitContext(); - parseExpected(83 /* ClassKeyword */); + parseExpected(84 /* 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(); @@ -33961,7 +35172,7 @@ var ts; members = createMissingList(); } setAwaitContext(savedAwaitContext); - var node = kind === 252 /* ClassDeclaration */ + var node = kind === 254 /* ClassDeclaration */ ? factory.createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) : factory.createClassExpression(decorators, modifiers, name, typeParameters, heritageClauses, members); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -33977,7 +35188,7 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 116 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 117 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); } function parseHeritageClauses() { // ClassTail[Yield,Await] : (Modified) See 14.5 @@ -33990,7 +35201,7 @@ var ts; function parseHeritageClause() { var pos = getNodePos(); var tok = token(); - ts.Debug.assert(tok === 93 /* ExtendsKeyword */ || tok === 116 /* ImplementsKeyword */); // isListElement() should ensure this. + ts.Debug.assert(tok === 94 /* ExtendsKeyword */ || tok === 117 /* ImplementsKeyword */); // isListElement() should ensure this. nextToken(); var types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(factory.createHeritageClause(tok, types), pos); @@ -34006,13 +35217,13 @@ var ts; parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */) : undefined; } function isHeritageClause() { - return token() === 93 /* ExtendsKeyword */ || token() === 116 /* ImplementsKeyword */; + return token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; } function parseClassMembers() { return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(117 /* InterfaceKeyword */); + parseExpected(118 /* InterfaceKeyword */); var name = parseIdentifier(); var typeParameters = parseTypeParameters(); var heritageClauses = parseHeritageClauses(); @@ -34021,11 +35232,11 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseTypeAliasDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(149 /* TypeKeyword */); + parseExpected(150 /* TypeKeyword */); var name = parseIdentifier(); var typeParameters = parseTypeParameters(); - parseExpected(62 /* EqualsToken */); - var type = token() === 136 /* IntrinsicKeyword */ && tryParse(parseKeywordAndNoDot) || parseType(); + parseExpected(63 /* EqualsToken */); + var type = token() === 137 /* IntrinsicKeyword */ && tryParse(parseKeywordAndNoDot) || parseType(); parseSemicolon(); var node = factory.createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -34042,7 +35253,7 @@ var ts; return withJSDoc(finishNode(factory.createEnumMember(name, initializer), pos), hasJSDoc); } function parseEnumDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(91 /* EnumKeyword */); + parseExpected(92 /* EnumKeyword */); var name = parseIdentifier(); var members; if (parseExpected(18 /* OpenBraceToken */)) { @@ -34081,7 +35292,7 @@ var ts; function parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers) { var flags = 0; var name; - if (token() === 154 /* GlobalKeyword */) { + if (token() === 155 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation name = parseIdentifier(); flags |= 1024 /* GlobalAugmentation */; @@ -34102,15 +35313,15 @@ var ts; } function parseModuleDeclaration(pos, hasJSDoc, decorators, modifiers) { var flags = 0; - if (token() === 154 /* GlobalKeyword */) { + if (token() === 155 /* GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers); } - else if (parseOptional(140 /* NamespaceKeyword */)) { + else if (parseOptional(141 /* NamespaceKeyword */)) { flags |= 16 /* Namespace */; } else { - parseExpected(139 /* ModuleKeyword */); + parseExpected(140 /* ModuleKeyword */); if (token() === 10 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers); } @@ -34118,7 +35329,7 @@ var ts; return parseModuleOrNamespaceDeclaration(pos, hasJSDoc, decorators, modifiers, flags); } function isExternalModuleReference() { - return token() === 143 /* RequireKeyword */ && + return token() === 144 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { @@ -34128,8 +35339,8 @@ var ts; return nextToken() === 43 /* SlashToken */; } function parseNamespaceExportDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(126 /* AsKeyword */); - parseExpected(140 /* NamespaceKeyword */); + parseExpected(127 /* AsKeyword */); + parseExpected(141 /* NamespaceKeyword */); var name = parseIdentifier(); parseSemicolon(); var node = factory.createNamespaceExportDeclaration(name); @@ -34139,7 +35350,7 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseImportDeclarationOrImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(99 /* ImportKeyword */); + parseExpected(100 /* 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; @@ -34147,7 +35358,7 @@ var ts; identifier = parseIdentifier(); } var isTypeOnly = false; - if (token() !== 153 /* FromKeyword */ && + if (token() !== 154 /* FromKeyword */ && (identifier === null || identifier === void 0 ? void 0 : identifier.escapedText) === "type" && (isIdentifier() || tokenAfterImportDefinitelyProducesImportDeclaration())) { isTypeOnly = true; @@ -34165,7 +35376,7 @@ var ts; token() === 18 /* OpenBraceToken */ // import { ) { importClause = parseImportClause(identifier, afterImportPos, isTypeOnly); - parseExpected(153 /* FromKeyword */); + parseExpected(154 /* FromKeyword */); } var moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -34178,10 +35389,10 @@ var ts; function tokenAfterImportedIdentifierDefinitelyProducesImportDeclaration() { // In `import id ___`, the current token decides whether to produce // an ImportDeclaration or ImportEqualsDeclaration. - return token() === 27 /* CommaToken */ || token() === 153 /* FromKeyword */; + return token() === 27 /* CommaToken */ || token() === 154 /* FromKeyword */; } function parseImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers, identifier, isTypeOnly) { - parseExpected(62 /* EqualsToken */); + parseExpected(63 /* EqualsToken */); var moduleReference = parseModuleReference(); parseSemicolon(); var node = factory.createImportEqualsDeclaration(decorators, modifiers, isTypeOnly, identifier, moduleReference); @@ -34200,7 +35411,7 @@ var ts; var namedBindings; if (!identifier || parseOptional(27 /* CommaToken */)) { - namedBindings = token() === 41 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(264 /* NamedImports */); + namedBindings = token() === 41 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(266 /* NamedImports */); } return finishNode(factory.createImportClause(isTypeOnly, identifier, namedBindings), pos); } @@ -34211,7 +35422,7 @@ var ts; } function parseExternalModuleReference() { var pos = getNodePos(); - parseExpected(143 /* RequireKeyword */); + parseExpected(144 /* RequireKeyword */); parseExpected(20 /* OpenParenToken */); var expression = parseModuleSpecifier(); parseExpected(21 /* CloseParenToken */); @@ -34235,7 +35446,7 @@ var ts; // * as ImportedBinding var pos = getNodePos(); parseExpected(41 /* AsteriskToken */); - parseExpected(126 /* AsKeyword */); + parseExpected(127 /* AsKeyword */); var name = parseIdentifier(); return finishNode(factory.createNamespaceImport(name), pos); } @@ -34248,16 +35459,16 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - var node = kind === 264 /* NamedImports */ + var node = kind === 266 /* NamedImports */ ? factory.createNamedImports(parseBracketedList(23 /* ImportOrExportSpecifiers */, parseImportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */)) : factory.createNamedExports(parseBracketedList(23 /* ImportOrExportSpecifiers */, parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */)); return finishNode(node, pos); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(270 /* ExportSpecifier */); + return parseImportOrExportSpecifier(272 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(265 /* ImportSpecifier */); + return parseImportOrExportSpecifier(267 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var pos = getNodePos(); @@ -34273,9 +35484,9 @@ var ts; var identifierName = parseIdentifierName(); var propertyName; var name; - if (token() === 126 /* AsKeyword */) { + if (token() === 127 /* AsKeyword */) { propertyName = identifierName; - parseExpected(126 /* AsKeyword */); + parseExpected(127 /* AsKeyword */); checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -34284,10 +35495,10 @@ var ts; else { name = identifierName; } - if (kind === 265 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 267 /* ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } - var node = kind === 265 /* ImportSpecifier */ + var node = kind === 267 /* ImportSpecifier */ ? factory.createImportSpecifier(propertyName, name) : factory.createExportSpecifier(propertyName, name); return finishNode(node, pos); @@ -34300,22 +35511,22 @@ var ts; setAwaitContext(/*value*/ true); var exportClause; var moduleSpecifier; - var isTypeOnly = parseOptional(149 /* TypeKeyword */); + var isTypeOnly = parseOptional(150 /* TypeKeyword */); var namespaceExportPos = getNodePos(); if (parseOptional(41 /* AsteriskToken */)) { - if (parseOptional(126 /* AsKeyword */)) { + if (parseOptional(127 /* AsKeyword */)) { exportClause = parseNamespaceExport(namespaceExportPos); } - parseExpected(153 /* FromKeyword */); + parseExpected(154 /* FromKeyword */); moduleSpecifier = parseModuleSpecifier(); } else { - exportClause = parseNamedImportsOrExports(268 /* NamedExports */); + exportClause = parseNamedImportsOrExports(270 /* 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() === 153 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(153 /* FromKeyword */); + if (token() === 154 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(154 /* FromKeyword */); moduleSpecifier = parseModuleSpecifier(); } } @@ -34328,11 +35539,11 @@ var ts; var savedAwaitContext = inAwaitContext(); setAwaitContext(/*value*/ true); var isExportEquals; - if (parseOptional(62 /* EqualsToken */)) { + if (parseOptional(63 /* EqualsToken */)) { isExportEquals = true; } else { - parseExpected(87 /* DefaultKeyword */); + parseExpected(88 /* DefaultKeyword */); } var expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -34348,7 +35559,7 @@ var ts; getImportMetaIfNecessary(sourceFile); } function isAnExternalModuleIndicatorNode(node) { - return hasModifierOfKind(node, 92 /* ExportKeyword */) + return hasModifierOfKind(node, 93 /* ExportKeyword */) || ts.isImportEqualsDeclaration(node) && ts.isExternalModuleReference(node.moduleReference) || ts.isImportDeclaration(node) || ts.isExportAssignment(node) @@ -34367,7 +35578,7 @@ var ts; return ts.some(node.modifiers, function (m) { return m.kind === kind; }); } function isImportMeta(node) { - return ts.isMetaProperty(node) && node.keywordToken === 99 /* ImportKeyword */ && node.name.escapedText === "meta"; + return ts.isMetaProperty(node) && node.keywordToken === 100 /* ImportKeyword */ && node.name.escapedText === "meta"; } var ParsingContext; (function (ParsingContext) { @@ -34435,7 +35646,13 @@ var ts; function parseJSDocNameReference() { var pos = getNodePos(); var hasBrace = parseOptional(18 /* OpenBraceToken */); + var p2 = getNodePos(); var entityName = parseEntityName(/* allowReservedWords*/ false); + while (token() === 80 /* PrivateIdentifier */) { + reScanHashToken(); // rescan #id as # id + nextTokenJSDoc(); // then skip the # + entityName = finishNode(factory.createJSDocMemberName(entityName, parseIdentifier()), p2); + } if (hasBrace) { parseExpectedJSDoc(19 /* CloseBraceToken */); } @@ -34499,7 +35716,10 @@ var ts; var tags; var tagsPos; var tagsEnd; + var linkEnd; + var commentsPos; var comments = []; + var parts = []; // + 3 for leading /**, - 5 in total for /** */ return scanner.scanRange(start + 3, length - 5, function () { // Initially we can parse out a tag. We also have seen a starting asterisk. @@ -34528,6 +35748,8 @@ var ts; case 59 /* AtToken */: if (state === 0 /* BeginningOfLine */ || state === 1 /* SawAsterisk */) { removeTrailingWhitespace(comments); + if (!commentsPos) + commentsPos = getNodePos(); addTag(parseTag(indent)); // 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 @@ -34570,6 +35792,22 @@ var ts; break; case 1 /* EndOfFileToken */: break loop; + case 18 /* OpenBraceToken */: + state = 2 /* SavingComments */; + var commentEnd = scanner.getStartPos(); + var linkStart = scanner.getTextPos() - 1; + var link = parseJSDocLink(linkStart); + if (link) { + if (!linkEnd) { + removeLeadingNewlines(comments); + } + parts.push(finishNode(factory.createJSDocText(comments.join("")), linkEnd !== null && linkEnd !== void 0 ? linkEnd : start, commentEnd)); + parts.push(link); + comments = []; + linkEnd = scanner.getTextPos(); + break; + } + // fallthrough if it's not a {@link sequence default: // 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 @@ -34580,9 +35818,14 @@ var ts; } nextTokenJSDoc(); } - removeLeadingNewlines(comments); removeTrailingWhitespace(comments); - return createJSDocComment(); + if (parts.length && comments.length) { + parts.push(finishNode(factory.createJSDocText(comments.join("")), linkEnd !== null && linkEnd !== void 0 ? linkEnd : start, commentsPos)); + } + if (parts.length && tags) + ts.Debug.assertIsDefined(commentsPos, "having parsed tags implies that the end of the comment span should be set"); + var tagsArray = tags && createNodeArray(tags, tagsPos, tagsEnd); + return finishNode(factory.createJSDocComment(parts.length ? createNodeArray(parts, start, commentsPos) : comments.length ? comments.join("") : undefined, tagsArray), start, end); }); function removeLeadingNewlines(comments) { while (comments.length && (comments[0] === "\n" || comments[0] === "\r")) { @@ -34594,11 +35837,6 @@ var ts; comments.pop(); } } - function createJSDocComment() { - var comment = comments.length ? comments.join("") : undefined; - var tagsArray = tags && createNodeArray(tags, tagsPos, tagsEnd); - return finishNode(factory.createJSDocComment(comment, tagsArray), start, end); - } function isNextNonwhitespaceTokenEndOfFile() { // We must use infinite lookahead, as there could be any number of newlines :( while (true) { @@ -34678,6 +35916,9 @@ var ts; case "readonly": tag = parseSimpleTag(start, factory.createJSDocReadonlyTag, tagName, margin, indentText); break; + case "override": + tag = parseSimpleTag(start, factory.createJSDocOverrideTag, tagName, margin, indentText); + break; case "deprecated": hasDeprecatedTag = true; tag = parseSimpleTag(start, factory.createJSDocDeprecatedTag, tagName, margin, indentText); @@ -34725,8 +35966,12 @@ var ts; return parseTagComments(margin, indentText.slice(margin)); } function parseTagComments(indent, initialMargin) { + var commentsPos = getNodePos(); var comments = []; + var parts = []; + var linkEnd; var state = 0 /* BeginningOfLine */; + var previousWhitespace = true; var margin; function pushComment(text) { if (!margin) { @@ -34752,7 +35997,9 @@ var ts; indent = 0; break; case 59 /* AtToken */: - if (state === 3 /* SavingBackticks */) { + if (state === 3 /* SavingBackticks */ + || state === 2 /* 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; } @@ -34776,13 +36023,18 @@ var ts; break; case 18 /* OpenBraceToken */: state = 2 /* SavingComments */; - if (lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenText() === "link"; })) { - pushComment(scanner.getTokenText()); - nextTokenJSDoc(); + var commentEnd = scanner.getStartPos(); + var linkStart = scanner.getTextPos() - 1; + var link = parseJSDocLink(linkStart); + if (link) { + parts.push(finishNode(factory.createJSDocText(comments.join("")), linkEnd !== null && linkEnd !== void 0 ? linkEnd : commentsPos, commentEnd)); + parts.push(link); + comments = []; + linkEnd = scanner.getTextPos(); + } + else { pushComment(scanner.getTokenText()); - nextTokenJSDoc(); } - pushComment(scanner.getTokenText()); break; case 61 /* BacktickToken */: if (state === 3 /* SavingBackticks */) { @@ -34809,15 +36061,67 @@ var ts; pushComment(scanner.getTokenText()); break; } + previousWhitespace = token() === 5 /* WhitespaceTrivia */; tok = nextTokenJSDoc(); } removeLeadingNewlines(comments); removeTrailingWhitespace(comments); - return comments.length === 0 ? undefined : comments.join(""); + if (parts.length) { + if (comments.length) { + parts.push(finishNode(factory.createJSDocText(comments.join("")), linkEnd !== null && linkEnd !== void 0 ? linkEnd : commentsPos)); + } + return createNodeArray(parts, commentsPos, scanner.getTextPos()); + } + else if (comments.length) { + return comments.join(""); + } + } + function isNextJSDocTokenWhitespace() { + var next = nextTokenJSDoc(); + return next === 5 /* WhitespaceTrivia */ || next === 4 /* NewLineTrivia */; + } + function parseJSDocLink(start) { + var linkType = tryParse(parseJSDocLinkPrefix); + if (!linkType) { + return undefined; + } + nextTokenJSDoc(); // start at token after link, then skip any whitespace + skipWhitespace(); + // parseEntityName logs an error for non-identifier, so create a MissingNode ourselves to avoid the error + var p2 = getNodePos(); + var name = ts.tokenIsIdentifierOrKeyword(token()) + ? parseEntityName(/*allowReservedWords*/ true) + : undefined; + if (name) { + while (token() === 80 /* 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 */) { + text.push(scanner.getTokenText()); + nextTokenJSDoc(); + } + var create = linkType === "link" ? factory.createJSDocLink + : linkType === "linkcode" ? factory.createJSDocLinkCode + : factory.createJSDocLinkPlain; + return finishNode(create(name, text.join("")), start, scanner.getTextPos()); + } + function parseJSDocLinkPrefix() { + skipWhitespaceOrAsterisk(); + if (token() === 18 /* OpenBraceToken */ + && nextTokenJSDoc() === 59 /* AtToken */ + && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc())) { + var kind = scanner.getTokenValue(); + if (kind === "link" || kind === "linkcode" || kind === "linkplain") { + return kind; + } + } } function parseUnknownTag(start, tagName, indent, indentText) { - var end = getNodePos(); - return finishNode(factory.createJSDocUnknownTag(tagName, parseTrailingTagComments(start, end, indent, indentText)), start, end); + return finishNode(factory.createJSDocUnknownTag(tagName, parseTrailingTagComments(start, getNodePos(), indent, indentText)), start); } function addTag(tag) { if (!tag) { @@ -34851,7 +36155,7 @@ var ts; if (isBracketed) { skipWhitespace(); // May have an optional default, e.g. '[foo = 42]' - if (parseOptionalToken(62 /* EqualsToken */)) { + if (parseOptionalToken(63 /* EqualsToken */)) { parseExpression(); } parseExpected(23 /* CloseBracketToken */); @@ -34860,9 +36164,9 @@ var ts; } function isObjectOrObjectArrayTypeReference(node) { switch (node.kind) { - case 145 /* ObjectKeyword */: + case 146 /* ObjectKeyword */: return true; - case 178 /* ArrayType */: + case 180 /* ArrayType */: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && !node.typeArguments; @@ -34873,11 +36177,11 @@ var ts; var isNameFirst = !typeExpression; skipWhitespaceOrAsterisk(); var _a = parseBracketNameInPropertyAndParamTag(), name = _a.name, isBracketed = _a.isBracketed; - skipWhitespace(); - if (isNameFirst) { + var indentText = skipWhitespaceOrAsterisk(); + if (isNameFirst && !lookAhead(parseJSDocLinkPrefix)) { typeExpression = tryParseTypeExpression(); } - var comment = parseTagComments(indent + scanner.getStartPos() - start); + var comment = parseTrailingTagComments(start, getNodePos(), indent, indentText); var nestedTypeLiteral = target !== 4 /* CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { typeExpression = nestedTypeLiteral; @@ -34894,12 +36198,12 @@ var ts; var child = void 0; var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 326 /* JSDocParameterTag */ || child.kind === 333 /* JSDocPropertyTag */) { + if (child.kind === 334 /* JSDocParameterTag */ || child.kind === 341 /* JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - var literal = finishNode(factory.createJSDocTypeLiteral(children, typeExpression.type.kind === 178 /* ArrayType */), pos); + var literal = finishNode(factory.createJSDocTypeLiteral(children, typeExpression.type.kind === 180 /* ArrayType */), pos); return finishNode(factory.createJSDocTypeExpression(literal), pos); } } @@ -34909,27 +36213,34 @@ var ts; parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } var typeExpression = tryParseTypeExpression(); - var end = getNodePos(); - return finishNode(factory.createJSDocReturnTag(tagName, typeExpression, parseTrailingTagComments(start, end, indent, indentText)), start, end); + return finishNode(factory.createJSDocReturnTag(tagName, typeExpression, parseTrailingTagComments(start, getNodePos(), indent, indentText)), start); } function parseTypeTag(start, tagName, indent, indentText) { if (ts.some(tags, ts.isJSDocTypeTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } var typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); - var end = getNodePos(); - var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, end, indent, indentText) : undefined; - return finishNode(factory.createJSDocTypeTag(tagName, typeExpression, comments), start, end); + var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, getNodePos(), indent, indentText) : undefined; + return finishNode(factory.createJSDocTypeTag(tagName, typeExpression, comments), start); } function parseSeeTag(start, tagName, indent, indentText) { - var nameExpression = parseJSDocNameReference(); - var end = getNodePos(); - var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, end, indent, indentText) : undefined; - return finishNode(factory.createJSDocSeeTag(tagName, nameExpression, comments), start, end); + var isLink = lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenValue() === "link"; }); + var nameExpression = isLink ? undefined : parseJSDocNameReference(); + var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, getNodePos(), indent, indentText) : undefined; + return finishNode(factory.createJSDocSeeTag(tagName, nameExpression, comments), start); } function parseAuthorTag(start, tagName, indent, indentText) { - var comments = parseAuthorNameAndEmail() + (parseTrailingTagComments(start, end, indent, indentText) || ""); - return finishNode(factory.createJSDocAuthorTag(tagName, comments || undefined), start); + var commentStart = getNodePos(); + var textOnly = parseAuthorNameAndEmail(); + var commentEnd = scanner.getStartPos(); + var comments = parseTrailingTagComments(start, commentEnd, indent, indentText); + if (!comments) { + commentEnd = scanner.getStartPos(); + } + var allParts = typeof comments !== "string" + ? createNodeArray(ts.concatenate([finishNode(textOnly, commentStart, commentEnd)], comments), commentStart) // cast away readonly + : textOnly.text + comments; + return finishNode(factory.createJSDocAuthorTag(tagName, allParts), start); } function parseAuthorNameAndEmail() { var comments = []; @@ -34950,17 +36261,15 @@ var ts; comments.push(scanner.getTokenText()); token = nextTokenJSDoc(); } - return comments.join(""); + return factory.createJSDocText(comments.join("")); } function parseImplementsTag(start, tagName, margin, indentText) { var className = parseExpressionWithTypeArgumentsForAugments(); - var end = getNodePos(); - return finishNode(factory.createJSDocImplementsTag(tagName, className, parseTrailingTagComments(start, end, margin, indentText)), start, end); + return finishNode(factory.createJSDocImplementsTag(tagName, className, parseTrailingTagComments(start, getNodePos(), margin, indentText)), start); } function parseAugmentsTag(start, tagName, margin, indentText) { var className = parseExpressionWithTypeArgumentsForAugments(); - var end = getNodePos(); - return finishNode(factory.createJSDocAugmentsTag(tagName, className, parseTrailingTagComments(start, end, margin, indentText)), start, end); + return finishNode(factory.createJSDocAugmentsTag(tagName, className, parseTrailingTagComments(start, getNodePos(), margin, indentText)), start); } function parseExpressionWithTypeArgumentsForAugments() { var usedBrace = parseOptional(18 /* OpenBraceToken */); @@ -34984,20 +36293,17 @@ var ts; return node; } function parseSimpleTag(start, createTag, tagName, margin, indentText) { - var end = getNodePos(); - return finishNode(createTag(tagName, parseTrailingTagComments(start, end, margin, indentText)), start, end); + return finishNode(createTag(tagName, parseTrailingTagComments(start, getNodePos(), margin, indentText)), start); } function parseThisTag(start, tagName, margin, indentText) { var typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); - var end = getNodePos(); - return finishNode(factory.createJSDocThisTag(tagName, typeExpression, parseTrailingTagComments(start, end, margin, indentText)), start, end); + return finishNode(factory.createJSDocThisTag(tagName, typeExpression, parseTrailingTagComments(start, getNodePos(), margin, indentText)), start); } function parseEnumTag(start, tagName, margin, indentText) { var typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); - var end = getNodePos(); - return finishNode(factory.createJSDocEnumTag(tagName, typeExpression, parseTrailingTagComments(start, end, margin, indentText)), start, end); + return finishNode(factory.createJSDocEnumTag(tagName, typeExpression, parseTrailingTagComments(start, getNodePos(), margin, indentText)), start); } function parseTypedefTag(start, tagName, indent, indentText) { var _a; @@ -35014,7 +36320,7 @@ var ts; var hasChildren = false; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { hasChildren = true; - if (child.kind === 329 /* JSDocTypeTag */) { + if (child.kind === 337 /* JSDocTypeTag */) { if (childTypeTag) { parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags); var lastError = ts.lastOrUndefined(parseDiagnostics); @@ -35032,7 +36338,7 @@ var ts; } } if (hasChildren) { - var isArrayType = typeExpression && typeExpression.type.kind === 178 /* ArrayType */; + var isArrayType = typeExpression && typeExpression.type.kind === 180 /* ArrayType */; var jsdocTypeLiteral = factory.createJSDocTypeLiteral(jsDocPropertyTags, isArrayType); typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? childTypeTag.typeExpression : @@ -35085,17 +36391,16 @@ var ts; var returnTag = tryParse(function () { if (parseOptionalJsdoc(59 /* AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 327 /* JSDocReturnTag */) { + if (tag && tag.kind === 335 /* JSDocReturnTag */) { return tag; } } }); var typeExpression = finishNode(factory.createJSDocSignature(/*typeParameters*/ undefined, parameters, returnTag), start); - var end = getNodePos(); if (!comment) { - comment = parseTrailingTagComments(start, end, indent, indentText); + comment = parseTrailingTagComments(start, getNodePos(), indent, indentText); } - return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start, end); + return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start); } function escapedTextsEqual(a, b) { while (!ts.isIdentifier(a) || !ts.isIdentifier(b)) { @@ -35120,7 +36425,7 @@ var ts; case 59 /* AtToken */: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 326 /* JSDocParameterTag */ || child.kind === 333 /* JSDocPropertyTag */) && + if (child && (child.kind === 334 /* JSDocParameterTag */ || child.kind === 341 /* JSDocPropertyTag */) && target !== 4 /* CallbackParameter */ && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; @@ -35139,7 +36444,7 @@ var ts; } seenAsterisk = true; break; - case 78 /* Identifier */: + case 79 /* Identifier */: canParseTag = false; break; case 1 /* EndOfFileToken */: @@ -35177,6 +36482,9 @@ var ts; function parseTemplateTagTypeParameter() { var typeParameterPos = getNodePos(); var name = parseJSDocIdentifierName(ts.Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces); + if (ts.nodeIsMissing(name)) { + return undefined; + } return finishNode(factory.createTypeParameterDeclaration(name, /*constraint*/ undefined, /*defaultType*/ undefined), typeParameterPos); } function parseTemplateTagTypeParameters() { @@ -35184,7 +36492,10 @@ var ts; var typeParameters = []; do { skipWhitespace(); - typeParameters.push(parseTemplateTagTypeParameter()); + var node = parseTemplateTagTypeParameter(); + if (node !== undefined) { + typeParameters.push(node); + } skipWhitespaceOrAsterisk(); } while (parseOptionalJsdoc(27 /* CommaToken */)); return createNodeArray(typeParameters, pos); @@ -35203,8 +36514,7 @@ var ts; // TODO: Consider only parsing a single type parameter if there is a constraint. var constraint = token() === 18 /* OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; var typeParameters = parseTemplateTagTypeParameters(); - var end = getNodePos(); - return finishNode(factory.createJSDocTemplateTag(tagName, constraint, typeParameters, parseTrailingTagComments(start, end, indent, indentText)), start, end); + return finishNode(factory.createJSDocTemplateTag(tagName, constraint, typeParameters, parseTrailingTagComments(start, getNodePos(), indent, indentText)), start); } function parseOptionalJsdoc(t) { if (token() === t) { @@ -35232,7 +36542,7 @@ var ts; } function parseJSDocIdentifierName(message) { if (!ts.tokenIsIdentifierOrKeyword(token())) { - return createMissingNode(78 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); + return createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); } identifierCount++; var pos = scanner.getTokenPos(); @@ -35405,7 +36715,7 @@ var ts; switch (node.kind) { case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - case 78 /* Identifier */: + case 79 /* Identifier */: return true; } return false; @@ -35879,7 +37189,7 @@ var ts; if (namedArgRegExCache.has(name)) { return namedArgRegExCache.get(name); } - var result = new RegExp("(\\s" + name + "\\s*=\\s*)('|\")(.+?)\\2", "im"); + var result = new RegExp("(\\s" + name + "\\s*=\\s*)(?:(?:'([^']*)')|(?:\"([^\"]*)\"))", "im"); namedArgRegExCache.set(name, result); return result; } @@ -35903,16 +37213,17 @@ var ts; return; // Missing required argument, don't parse } else if (matchResult) { + var value = matchResult[2] || matchResult[3]; if (arg.captureSpan) { - var startPos = range.pos + matchResult.index + matchResult[1].length + matchResult[2].length; + var startPos = range.pos + matchResult.index + matchResult[1].length + 1; argument[arg.name] = { - value: matchResult[3], + value: value, pos: startPos, - end: startPos + matchResult[3].length + end: startPos + value.length }; } else { - argument[arg.name] = matchResult[3]; + argument[arg.name] = value; } } } @@ -35928,7 +37239,7 @@ var ts; return addPragmaForMatch(pragmas, range, 2 /* SingleLine */, singleLine); } if (range.kind === 3 /* MultiLineCommentTrivia */) { - var multiLinePragmaRegEx = /\s*@(\S+)\s*(.*)\s*$/gim; // Defined inline since it uses the "g" flag, which keeps a persistent index (for iterating) + 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); @@ -35955,7 +37266,7 @@ var ts; return {}; if (!pragma.args) return {}; - var args = text.split(/\s+/); + var args = ts.trimString(text).split(/\s+/); var argMap = {}; for (var i = 0; i < pragma.args.length; i++) { var argument = pragma.args[i]; @@ -35974,10 +37285,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 78 /* Identifier */) { + if (lhs.kind === 79 /* Identifier */) { return lhs.escapedText === rhs.escapedText; } - if (lhs.kind === 107 /* ThisKeyword */) { + if (lhs.kind === 108 /* ThisKeyword */) { return true; } // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only @@ -36019,6 +37330,7 @@ var ts; ["es2018", "lib.es2018.d.ts"], ["es2019", "lib.es2019.d.ts"], ["es2020", "lib.es2020.d.ts"], + ["es2021", "lib.es2021.d.ts"], ["esnext", "lib.esnext.d.ts"], // Host only ["dom", "lib.dom.d.ts"], @@ -36058,14 +37370,17 @@ var ts; ["es2020.string", "lib.es2020.string.d.ts"], ["es2020.symbol.wellknown", "lib.es2020.symbol.wellknown.d.ts"], ["es2020.intl", "lib.es2020.intl.d.ts"], + ["es2021.promise", "lib.es2021.promise.d.ts"], + ["es2021.string", "lib.es2021.string.d.ts"], + ["es2021.weakref", "lib.es2021.weakref.d.ts"], ["esnext.array", "lib.es2019.array.d.ts"], ["esnext.symbol", "lib.es2019.symbol.d.ts"], ["esnext.asynciterable", "lib.es2018.asynciterable.d.ts"], ["esnext.intl", "lib.esnext.intl.d.ts"], ["esnext.bigint", "lib.es2020.bigint.d.ts"], - ["esnext.string", "lib.esnext.string.d.ts"], - ["esnext.promise", "lib.esnext.promise.d.ts"], - ["esnext.weakref", "lib.esnext.weakref.d.ts"] + ["esnext.string", "lib.es2021.string.d.ts"], + ["esnext.promise", "lib.es2021.promise.d.ts"], + ["esnext.weakref", "lib.es2021.weakref.d.ts"] ]; /** * An array of supported "lib" reference file names used to determine the order for inclusion @@ -36089,11 +37404,12 @@ var ts; fixedpollinginterval: ts.WatchFileKind.FixedPollingInterval, prioritypollinginterval: ts.WatchFileKind.PriorityPollingInterval, dynamicprioritypolling: ts.WatchFileKind.DynamicPriorityPolling, + fixedchunksizepolling: ts.WatchFileKind.FixedChunkSizePolling, usefsevents: ts.WatchFileKind.UseFsEvents, usefseventsonparentdirectory: ts.WatchFileKind.UseFsEventsOnParentDirectory, })), - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_DynamicPriorityPolling_UseFsEvents_UseFsEventsOnParentDirectory, + category: ts.Diagnostics.Watch_and_Build_Modes, + description: ts.Diagnostics.Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_DynamicPriorityPolling_FixedChunkSizePolling_UseFsEvents_UseFsEventsOnParentDirectory, }, { name: "watchDirectory", @@ -36101,9 +37417,10 @@ var ts; usefsevents: ts.WatchDirectoryKind.UseFsEvents, fixedpollinginterval: ts.WatchDirectoryKind.FixedPollingInterval, dynamicprioritypolling: ts.WatchDirectoryKind.DynamicPriorityPolling, + fixedchunksizepolling: ts.WatchDirectoryKind.FixedChunkSizePolling, })), - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling, + category: ts.Diagnostics.Watch_and_Build_Modes, + description: ts.Diagnostics.Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling_FixedChunkSizePolling, }, { name: "fallbackPolling", @@ -36111,14 +37428,15 @@ var ts; fixedinterval: ts.PollingWatchKind.FixedInterval, priorityinterval: ts.PollingWatchKind.PriorityInterval, dynamicpriority: ts.PollingWatchKind.DynamicPriority, + fixedchunksize: ts.PollingWatchKind.FixedChunkSize, })), - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority, + category: ts.Diagnostics.Watch_and_Build_Modes, + description: ts.Diagnostics.Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority_FixedChunkSize, }, { name: "synchronousWatchDirectory", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Watch_and_Build_Modes, description: ts.Diagnostics.Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively, }, { @@ -36130,7 +37448,7 @@ var ts; isFilePath: true, extraValidation: specToDiagnostic }, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Watch_and_Build_Modes, description: ts.Diagnostics.Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively, }, { @@ -36142,7 +37460,7 @@ var ts; isFilePath: true, extraValidation: specToDiagnostic }, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Watch_and_Build_Modes, description: ts.Diagnostics.Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively, }, ]; @@ -36166,6 +37484,7 @@ var ts; shortName: "w", type: "boolean", showInSimplifiedHelpView: true, + isCommandLineOnly: true, category: ts.Diagnostics.Command_line_Options, description: ts.Diagnostics.Watch_input_files, }, @@ -36173,49 +37492,50 @@ var ts; name: "preserveWatchOutput", type: "boolean", showInSimplifiedHelpView: false, - category: ts.Diagnostics.Command_line_Options, + category: ts.Diagnostics.Output_Formatting, description: ts.Diagnostics.Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen, }, { name: "listFiles", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Print_names_of_files_part_of_the_compilation }, { name: "explainFiles", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Print_names_of_files_and_the_reason_they_are_part_of_the_compilation - }, { + }, + { name: "listEmittedFiles", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Print_names_of_generated_files_part_of_the_compilation }, { name: "pretty", type: "boolean", showInSimplifiedHelpView: true, - category: ts.Diagnostics.Command_line_Options, + category: ts.Diagnostics.Output_Formatting, description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental }, { name: "traceResolution", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Enable_tracing_of_the_name_resolution_process }, { name: "diagnostics", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Show_diagnostic_information }, { name: "extendedDiagnostics", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Show_verbose_diagnostic_information }, { @@ -36223,7 +37543,7 @@ var ts; type: "string", isFilePath: true, paramType: ts.Diagnostics.FILE_OR_DIRECTORY, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Generates_a_CPU_profile }, { @@ -36232,14 +37552,14 @@ var ts; isFilePath: true, isCommandLineOnly: true, paramType: ts.Diagnostics.DIRECTORY, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Generates_an_event_trace_and_a_list_of_types }, { name: "incremental", shortName: "i", type: "boolean", - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Projects, description: ts.Diagnostics.Enable_incremental_compilation, transpileOptionValue: undefined }, @@ -36248,13 +37568,14 @@ var ts; type: "boolean", affectsSemanticDiagnostics: true, affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Watch_and_Build_Modes, description: ts.Diagnostics.Have_recompiles_in_incremental_and_watch_assume_that_changes_within_a_file_will_only_affect_files_directly_depending_on_it }, { name: "locale", type: "string", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Command_line_Options, + isCommandLineOnly: true, description: ts.Diagnostics.The_locale_used_when_displaying_messages_to_the_user_e_g_en_us }, ]; @@ -36272,6 +37593,7 @@ var ts; es2018: 5 /* ES2018 */, es2019: 6 /* ES2019 */, es2020: 7 /* ES2020 */, + es2021: 8 /* ES2021 */, esnext: 99 /* ESNext */, })), affectsSourceFile: true, @@ -36279,11 +37601,11 @@ var ts; affectsEmit: true, paramType: ts.Diagnostics.VERSION, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_or_ESNEXT, + category: ts.Diagnostics.Language_and_Environment, + description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_ES2021_or_ESNEXT, }; - /* @internal */ - ts.optionDeclarations = __spreadArray(__spreadArray([], ts.commonOptionsWithBuild), [ + var commandOptionsWithoutBuild = [ + // CommandLine only options { name: "all", type: "boolean", @@ -36360,7 +37682,7 @@ var ts; affectsEmit: true, paramType: ts.Diagnostics.KIND, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_es2020_or_ESNext, }, { @@ -36370,9 +37692,9 @@ var ts; name: "lib", type: ts.libMap }, - affectsModuleResolution: true, + affectsProgramStructure: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation, transpileOptionValue: undefined }, @@ -36381,13 +37703,13 @@ var ts; type: "boolean", affectsModuleResolution: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.JavaScript_Support, description: ts.Diagnostics.Allow_javascript_files_to_be_compiled }, { name: "checkJs", type: "boolean", - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.JavaScript_Support, description: ts.Diagnostics.Report_errors_in_js_files }, { @@ -36398,7 +37720,7 @@ var ts; affectsModuleResolution: true, paramType: ts.Diagnostics.KIND, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_react_react_jsx_or_react_jsxdev, }, { @@ -36407,7 +37729,7 @@ var ts; type: "boolean", affectsEmit: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Generates_corresponding_d_ts_file, transpileOptionValue: undefined }, @@ -36416,7 +37738,7 @@ var ts; type: "boolean", affectsEmit: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Generates_a_sourcemap_for_each_corresponding_d_ts_file, transpileOptionValue: undefined }, @@ -36424,7 +37746,7 @@ var ts; name: "emitDeclarationOnly", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Only_emit_d_ts_declaration_files, transpileOptionValue: undefined }, @@ -36433,7 +37755,7 @@ var ts; type: "boolean", affectsEmit: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Generates_corresponding_map_file, }, { @@ -36443,7 +37765,7 @@ var ts; isFilePath: true, paramType: ts.Diagnostics.FILE, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, transpileOptionValue: undefined }, @@ -36454,7 +37776,7 @@ var ts; isFilePath: true, paramType: ts.Diagnostics.DIRECTORY, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Redirect_output_structure_to_the_directory, }, { @@ -36463,7 +37785,7 @@ var ts; affectsEmit: true, isFilePath: true, paramType: ts.Diagnostics.LOCATION, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, }, { @@ -36471,7 +37793,7 @@ var ts; type: "boolean", affectsEmit: true, isTSConfigOnly: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Projects, description: ts.Diagnostics.Enable_project_compilation, transpileOptionValue: undefined }, @@ -36481,7 +37803,7 @@ var ts; affectsEmit: true, isFilePath: true, paramType: ts.Diagnostics.FILE, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Projects, description: ts.Diagnostics.Specify_file_to_store_incremental_compilation_information, transpileOptionValue: undefined }, @@ -36490,14 +37812,14 @@ var ts; type: "boolean", affectsEmit: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Do_not_emit_comments_to_output, }, { name: "noEmit", type: "boolean", showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Do_not_emit_outputs, transpileOptionValue: undefined }, @@ -36505,7 +37827,7 @@ var ts; name: "importHelpers", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Import_emit_helpers_from_tslib }, { @@ -36517,20 +37839,20 @@ var ts; })), affectsEmit: true, affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types }, { name: "downlevelIteration", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3 }, { name: "isolatedModules", type: "boolean", - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Interop_Constraints, description: ts.Diagnostics.Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule, transpileOptionValue: true }, @@ -36539,7 +37861,7 @@ var ts; name: "strict", type: "boolean", showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Enable_all_strict_type_checking_options }, { @@ -36548,7 +37870,7 @@ var ts; affectsSemanticDiagnostics: true, strictFlag: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type }, { @@ -36557,7 +37879,7 @@ var ts; affectsSemanticDiagnostics: true, strictFlag: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Enable_strict_null_checks }, { @@ -36566,7 +37888,7 @@ var ts; affectsSemanticDiagnostics: true, strictFlag: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Enable_strict_checking_of_function_types }, { @@ -36574,7 +37896,7 @@ var ts; type: "boolean", strictFlag: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Enable_strict_bind_call_and_apply_methods_on_functions }, { @@ -36583,25 +37905,43 @@ var ts; affectsSemanticDiagnostics: true, strictFlag: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Enable_strict_checking_of_property_initialization_in_classes }, + { + name: "strictOptionalProperties", + type: "boolean", + affectsSemanticDiagnostics: true, + strictFlag: true, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Type_Checking, + description: ts.Diagnostics.Enable_strict_checking_of_optional_properties + }, { name: "noImplicitThis", type: "boolean", affectsSemanticDiagnostics: true, strictFlag: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, }, + { + name: "useUnknownInCatchVariables", + type: "boolean", + affectsSemanticDiagnostics: true, + strictFlag: true, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Type_Checking, + description: ts.Diagnostics.Type_catch_clause_variables_as_unknown_instead_of_any, + }, { name: "alwaysStrict", type: "boolean", affectsSourceFile: true, strictFlag: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file }, // Additional Checks @@ -36610,7 +37950,7 @@ var ts; type: "boolean", affectsSemanticDiagnostics: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Additional_Checks, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Report_errors_on_unused_locals, }, { @@ -36618,7 +37958,7 @@ var ts; type: "boolean", affectsSemanticDiagnostics: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Additional_Checks, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Report_errors_on_unused_parameters, }, { @@ -36626,7 +37966,7 @@ var ts; type: "boolean", affectsSemanticDiagnostics: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Additional_Checks, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value }, { @@ -36635,7 +37975,7 @@ var ts; affectsBindDiagnostics: true, affectsSemanticDiagnostics: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Additional_Checks, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement }, { @@ -36643,14 +37983,22 @@ var ts; type: "boolean", affectsSemanticDiagnostics: true, showInSimplifiedHelpView: false, - category: ts.Diagnostics.Additional_Checks, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Include_undefined_in_index_signature_results }, + { + name: "noImplicitOverride", + type: "boolean", + affectsSemanticDiagnostics: true, + showInSimplifiedHelpView: false, + category: ts.Diagnostics.Type_Checking, + description: ts.Diagnostics.Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier + }, { name: "noPropertyAccessFromIndexSignature", type: "boolean", showInSimplifiedHelpView: false, - category: ts.Diagnostics.Additional_Checks, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Require_undeclared_properties_from_index_signatures_to_use_element_accesses }, // Module Resolution @@ -36662,7 +38010,7 @@ var ts; })), affectsModuleResolution: true, paramType: ts.Diagnostics.STRATEGY, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, }, { @@ -36670,7 +38018,7 @@ var ts; type: "string", affectsModuleResolution: true, isFilePath: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Base_directory_to_resolve_non_absolute_module_names }, { @@ -36680,7 +38028,7 @@ var ts; type: "object", affectsModuleResolution: true, isTSConfigOnly: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl, transpileOptionValue: undefined }, @@ -36696,7 +38044,7 @@ var ts; isFilePath: true }, affectsModuleResolution: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime, transpileOptionValue: undefined }, @@ -36709,7 +38057,7 @@ var ts; isFilePath: true }, affectsModuleResolution: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.List_of_folders_to_include_type_definitions_from }, { @@ -36719,9 +38067,9 @@ var ts; name: "types", type: "string" }, - affectsModuleResolution: true, + affectsProgramStructure: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation, transpileOptionValue: undefined }, @@ -36729,7 +38077,7 @@ var ts; name: "allowSyntheticDefaultImports", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Interop_Constraints, description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking }, { @@ -36738,20 +38086,20 @@ var ts; affectsSemanticDiagnostics: true, affectsEmit: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Interop_Constraints, description: ts.Diagnostics.Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for_all_imports_Implies_allowSyntheticDefaultImports }, { name: "preserveSymlinks", type: "boolean", - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Interop_Constraints, description: ts.Diagnostics.Do_not_resolve_the_real_path_of_symlinks, }, { name: "allowUmdGlobalAccess", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Allow_accessing_UMD_globals_from_modules, }, // Source Maps @@ -36760,7 +38108,7 @@ var ts; type: "string", affectsEmit: true, paramType: ts.Diagnostics.LOCATION, - category: ts.Diagnostics.Source_Map_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, }, { @@ -36768,21 +38116,21 @@ var ts; type: "string", affectsEmit: true, paramType: ts.Diagnostics.LOCATION, - category: ts.Diagnostics.Source_Map_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, }, { name: "inlineSourceMap", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Source_Map_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file }, { name: "inlineSources", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Source_Map_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap_to_be_set }, // Experimental @@ -36790,7 +38138,7 @@ var ts; name: "experimentalDecorators", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Experimental_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators }, { @@ -36798,20 +38146,20 @@ var ts; type: "boolean", affectsSemanticDiagnostics: true, affectsEmit: true, - category: ts.Diagnostics.Experimental_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators }, // Advanced { name: "jsxFactory", type: "string", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h }, { name: "jsxFragmentFactory", type: "string", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Specify_the_JSX_fragment_factory_function_to_use_when_targeting_react_JSX_emit_with_jsxFactory_compiler_option_is_specified_e_g_Fragment }, { @@ -36820,14 +38168,14 @@ var ts; affectsSemanticDiagnostics: true, affectsEmit: true, affectsModuleResolution: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react }, { name: "resolveJsonModule", type: "boolean", affectsModuleResolution: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Include_modules_imported_with_json_extension }, { @@ -36836,7 +38184,7 @@ var ts; affectsEmit: true, isFilePath: false, // for correct behaviour, please use outFile - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Backwards_Compatibility, paramType: ts.Diagnostics.FILE, description: ts.Diagnostics.Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file, transpileOptionValue: undefined @@ -36845,26 +38193,26 @@ var ts; name: "reactNamespace", type: "string", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react_JSX_emit }, { name: "skipDefaultLibCheck", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Completeness, description: ts.Diagnostics.Deprecated_Use_skipLibCheck_instead_Skip_type_checking_of_default_library_declaration_files }, { name: "charset", type: "string", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Backwards_Compatibility, description: ts.Diagnostics.The_character_set_of_the_input_files }, { name: "emitBOM", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files }, { @@ -36875,21 +38223,21 @@ var ts; })), affectsEmit: true, paramType: ts.Diagnostics.NEWLINE, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, }, { name: "noErrorTruncation", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Output_Formatting, description: ts.Diagnostics.Do_not_truncate_error_messages }, { name: "noLib", type: "boolean", - affectsModuleResolution: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Language_and_Environment, + affectsProgramStructure: true, description: ts.Diagnostics.Do_not_include_the_default_library_file_lib_d_ts, // We are not returning a sourceFile for lib file when asked by the program, // so pass --noLib to avoid reporting a file not found error. @@ -36899,7 +38247,7 @@ var ts; name: "noResolve", type: "boolean", affectsModuleResolution: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files, // We are not doing a full typecheck, we are not resolving the whole context, // so pass --noResolve to avoid reporting missing file errors. @@ -36909,56 +38257,56 @@ var ts; name: "stripInternal", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation, }, { name: "disableSizeLimit", type: "boolean", - affectsSourceFile: true, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Disable_size_limitations_on_JavaScript_projects + affectsProgramStructure: true, + category: ts.Diagnostics.Editor_Support, + description: ts.Diagnostics.JavaScript_Support }, { name: "disableSourceOfProjectReferenceRedirect", type: "boolean", isTSConfigOnly: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Projects, description: ts.Diagnostics.Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects }, { name: "disableSolutionSearching", type: "boolean", isTSConfigOnly: true, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Disable_solution_searching_for_this_project + category: ts.Diagnostics.Projects, + description: ts.Diagnostics.Projects }, { name: "disableReferencedProjectLoad", type: "boolean", isTSConfigOnly: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Projects, description: ts.Diagnostics.Disable_loading_referenced_projects }, { name: "noImplicitUseStrict", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Backwards_Compatibility, description: ts.Diagnostics.Do_not_emit_use_strict_directives_in_module_output }, { name: "noEmitHelpers", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Do_not_generate_custom_helper_functions_like_extends_in_compiled_output }, { name: "noEmitOnError", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, transpileOptionValue: undefined }, @@ -36966,7 +38314,7 @@ var ts; name: "preserveConstEnums", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code }, { @@ -36975,14 +38323,14 @@ var ts; affectsEmit: true, isFilePath: true, paramType: ts.Diagnostics.DIRECTORY, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Output_directory_for_generated_declaration_files, transpileOptionValue: undefined }, { name: "skipLibCheck", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Completeness, description: ts.Diagnostics.Skip_type_checking_of_declaration_files, }, { @@ -36990,7 +38338,7 @@ var ts; type: "boolean", affectsBindDiagnostics: true, affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Do_not_report_errors_on_unused_labels }, { @@ -36998,42 +38346,42 @@ var ts; type: "boolean", affectsBindDiagnostics: true, affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Do_not_report_errors_on_unreachable_code }, { name: "suppressExcessPropertyErrors", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Backwards_Compatibility, description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals, }, { name: "suppressImplicitAnyIndexErrors", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Backwards_Compatibility, description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, }, { name: "forceConsistentCasingInFileNames", type: "boolean", affectsModuleResolution: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Interop_Constraints, description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file }, { name: "maxNodeModuleJsDepth", type: "number", affectsModuleResolution: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.JavaScript_Support, description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files }, { name: "noStrictGenericChecks", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Backwards_Compatibility, description: ts.Diagnostics.Disable_strict_checking_of_generic_signatures_in_function_types, }, { @@ -37041,13 +38389,13 @@ var ts; type: "boolean", affectsSemanticDiagnostics: true, affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Emit_class_fields_with_Define_instead_of_Set, }, { name: "keyofStringsOnly", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Backwards_Compatibility, description: ts.Diagnostics.Resolve_keyof_to_string_valued_property_names_only_no_numbers_or_symbols, }, { @@ -37059,9 +38407,12 @@ var ts; name: "plugin", type: "object" }, - description: ts.Diagnostics.List_of_language_service_plugins + description: ts.Diagnostics.List_of_language_service_plugins, + category: ts.Diagnostics.Editor_Support, }, - ]); + ]; + /* @internal */ + ts.optionDeclarations = __spreadArray(__spreadArray([], ts.commonOptionsWithBuild), commandOptionsWithoutBuild); /* @internal */ ts.semanticDiagnosticsOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsSemanticDiagnostics; }); /* @internal */ @@ -37073,11 +38424,12 @@ var ts; return !!option.affectsSourceFile || !!option.affectsModuleResolution || !!option.affectsBindDiagnostics; }); /* @internal */ + ts.optionsAffectingProgramStructure = ts.optionDeclarations.filter(function (option) { return !!option.affectsProgramStructure; }); + /* @internal */ ts.transpileOptionValueCompilerOptions = ts.optionDeclarations.filter(function (option) { return ts.hasProperty(option, "transpileOptionValue"); }); - /* @internal */ - ts.buildOpts = __spreadArray(__spreadArray([], ts.commonOptionsWithBuild), [ + var commandOptionsOnlyBuild = [ { name: "verbose", shortName: "v", @@ -37105,7 +38457,9 @@ var ts; description: ts.Diagnostics.Delete_the_outputs_of_all_projects, type: "boolean" } - ]); + ]; + /* @internal */ + ts.buildOpts = __spreadArray(__spreadArray([], ts.commonOptionsWithBuild), commandOptionsOnlyBuild); /* @internal */ ts.typeAcquisitionDeclarations = [ { @@ -37159,6 +38513,10 @@ var ts; return optionsNameMapCache || (optionsNameMapCache = createOptionNameMap(ts.optionDeclarations)); } ts.getOptionsNameMap = getOptionsNameMap; + var compilerOptionsAlternateMode = { + diagnostic: ts.Diagnostics.Compiler_option_0_may_only_be_used_with_build, + getOptionsNameMap: getBuildOptionsNameMap + }; /* @internal */ ts.defaultInitCompilerOptions = { module: ts.ModuleKind.CommonJS, @@ -37192,13 +38550,13 @@ var ts; } /* @internal */ function parseCustomTypeOption(opt, value, errors) { - return convertJsonOptionOfCustomType(opt, trimString(value || ""), errors); + return convertJsonOptionOfCustomType(opt, ts.trimString(value || ""), errors); } ts.parseCustomTypeOption = parseCustomTypeOption; /* @internal */ function parseListTypeOption(opt, value, errors) { if (value === void 0) { value = ""; } - value = trimString(value); + value = ts.trimString(value); if (ts.startsWith(value, "-")) { return undefined; } @@ -37220,6 +38578,10 @@ var ts; return option.name; } function createUnknownOptionError(unknownOption, diagnostics, createDiagnostics, unknownOptionErrorText) { + var _a; + if ((_a = diagnostics.alternateMode) === null || _a === void 0 ? void 0 : _a.getOptionsNameMap().optionsNameMap.has(unknownOption.toLowerCase())) { + return createDiagnostics(diagnostics.alternateMode.diagnostic, unknownOption); + } var possibleOption = ts.getSpellingSuggestion(unknownOption, diagnostics.optionDeclarations, getOptionName); return possibleOption ? createDiagnostics(diagnostics.unknownDidYouMeanDiagnostic, unknownOptionErrorText || unknownOption, possibleOption.name) : @@ -37374,6 +38736,7 @@ var ts; } /*@internal*/ ts.compilerOptionsDidYouMeanDiagnostics = { + alternateMode: compilerOptionsAlternateMode, getOptionsNameMap: getOptionsNameMap, optionDeclarations: ts.optionDeclarations, unknownOptionDiagnostic: ts.Diagnostics.Unknown_compiler_option_0, @@ -37406,7 +38769,12 @@ var ts; function getBuildOptionsNameMap() { return buildOptionsNameMapCache || (buildOptionsNameMapCache = createOptionNameMap(ts.buildOpts)); } + var buildOptionsAlternateMode = { + diagnostic: ts.Diagnostics.Compiler_option_0_may_not_be_used_with_build, + getOptionsNameMap: getOptionsNameMap + }; var buildOptionsDidYouMeanDiagnostics = { + alternateMode: buildOptionsAlternateMode, getOptionsNameMap: getBuildOptionsNameMap, optionDeclarations: ts.buildOpts, unknownOptionDiagnostic: ts.Diagnostics.Unknown_build_option_0, @@ -37482,7 +38850,7 @@ var ts; function parseConfigFileTextToJson(fileName, jsonText) { var jsonSourceFile = ts.parseJsonText(fileName, jsonText); return { - config: convertToObject(jsonSourceFile, jsonSourceFile.parseDiagnostics), + config: convertConfigFileToObject(jsonSourceFile, jsonSourceFile.parseDiagnostics, /*reportOptionsErrors*/ false, /*optionsIterator*/ undefined), error: jsonSourceFile.parseDiagnostics.length ? jsonSourceFile.parseDiagnostics[0] : undefined }; } @@ -37572,7 +38940,8 @@ var ts; }, { name: "extends", - type: "string" + type: "string", + category: ts.Diagnostics.File_Management, }, { name: "references", @@ -37580,7 +38949,8 @@ var ts; element: { name: "references", type: "object" - } + }, + category: ts.Diagnostics.Projects, }, { name: "files", @@ -37588,7 +38958,8 @@ var ts; element: { name: "files", type: "string" - } + }, + category: ts.Diagnostics.File_Management, }, { name: "include", @@ -37596,7 +38967,8 @@ var ts; element: { name: "include", type: "string" - } + }, + category: ts.Diagnostics.File_Management, }, { name: "exclude", @@ -37604,7 +38976,8 @@ var ts; element: { name: "exclude", type: "string" - } + }, + category: ts.Diagnostics.File_Management, }, ts.compileOnSaveCommandLineOption ]) @@ -37612,11 +38985,31 @@ var ts; } return _tsconfigRootOptions; } + function convertConfigFileToObject(sourceFile, errors, reportOptionsErrors, optionsIterator) { + 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 !== 202 /* 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 + // array is a well-formed configuration object, made into an array element by stray characters. + if (ts.isArrayLiteralExpression(rootExpression)) { + var firstObject = ts.find(rootExpression.elements, ts.isObjectLiteralExpression); + if (firstObject) { + return convertToObjectWorker(sourceFile, firstObject, errors, /*returnValue*/ true, knownRootOptions, optionsIterator); + } + } + return {}; + } + return convertToObjectWorker(sourceFile, rootExpression, errors, /*returnValue*/ true, knownRootOptions, optionsIterator); + } /** * Convert the json syntax tree into the json value */ function convertToObject(sourceFile, errors) { - return convertToObjectWorker(sourceFile, errors, /*returnValue*/ true, /*knownRootOptions*/ undefined, /*jsonConversionNotifier*/ undefined); + var _a; + return convertToObjectWorker(sourceFile, (_a = sourceFile.statements[0]) === null || _a === void 0 ? void 0 : _a.expression, errors, /*returnValue*/ true, /*knownRootOptions*/ undefined, /*jsonConversionNotifier*/ undefined); } ts.convertToObject = convertToObject; /** @@ -37625,18 +39018,18 @@ var ts; * Otherwise it just checks the errors and returns undefined */ /*@internal*/ - function convertToObjectWorker(sourceFile, errors, returnValue, knownRootOptions, jsonConversionNotifier) { - if (!sourceFile.statements.length) { + function convertToObjectWorker(sourceFile, rootExpression, errors, returnValue, knownRootOptions, jsonConversionNotifier) { + if (!rootExpression) { return returnValue ? {} : undefined; } - return convertPropertyValueToJson(sourceFile.statements[0].expression, knownRootOptions); + return convertPropertyValueToJson(rootExpression, knownRootOptions); function isRootOptionMap(knownOptions) { return knownRootOptions && knownRootOptions.elementOptions === knownOptions; } function convertObjectLiteralExpressionToJson(node, knownOptions, extraKeyDiagnostics, parentOption) { var result = returnValue ? {} : undefined; var _loop_4 = function (element) { - if (element.kind !== 288 /* PropertyAssignment */) { + if (element.kind !== 290 /* PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); return "continue"; } @@ -37703,13 +39096,13 @@ var ts; function convertPropertyValueToJson(valueExpression, option) { var invalidReported; switch (valueExpression.kind) { - case 109 /* TrueKeyword */: + case 110 /* TrueKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return validateValue(/*value*/ true); - case 94 /* FalseKeyword */: + case 95 /* FalseKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return validateValue(/*value*/ false); - case 103 /* NullKeyword */: + case 104 /* 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 */: @@ -37730,13 +39123,13 @@ var ts; case 8 /* NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return validateValue(Number(valueExpression.text)); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: if (valueExpression.operator !== 40 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { break; // not valid JSON syntax } reportInvalidOptionValue(option && option.type !== "number"); return validateValue(-Number(valueExpression.operand.text)); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -37753,7 +39146,7 @@ var ts; return validateValue(convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined)); } - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return validateValue(convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element)); } @@ -37891,7 +39284,7 @@ var ts; if (ts.hasProperty(options, name)) { // tsconfig only options cannot be specified via command line, // so we can assume that only types that can appear here string | number | boolean - if (optionsNameMap.has(name) && optionsNameMap.get(name).category === ts.Diagnostics.Command_line_Options) { + if (optionsNameMap.has(name) && (optionsNameMap.get(name).category === ts.Diagnostics.Command_line_Options || optionsNameMap.get(name).category === ts.Diagnostics.Output_Formatting)) { return "continue"; } var value = options[name]; @@ -37957,13 +39350,11 @@ var ts; function makePadding(paddingLength) { return Array(paddingLength + 1).join(" "); } - function isAllowedOption(_a) { - var category = _a.category, name = _a.name; - // Skip options which do not have a category or have category `Command_line_Options` - // Exclude all possible `Advanced_Options` in tsconfig.json which were NOT defined in command line - return category !== undefined - && category !== ts.Diagnostics.Command_line_Options - && (category !== ts.Diagnostics.Advanced_Options || compilerOptionsMap.has(name)); + function isAllowedOptionForOutput(_a) { + var category = _a.category, name = _a.name, isCommandLineOnly = _a.isCommandLineOnly; + // Skip options which do not have a category or have categories which are more niche + var categoriesToSkip = [ts.Diagnostics.Command_line_Options, ts.Diagnostics.Editor_Support, ts.Diagnostics.Compiler_Diagnostics, ts.Diagnostics.Backwards_Compatibility, ts.Diagnostics.Watch_and_Build_Modes, ts.Diagnostics.Output_Formatting]; + return !isCommandLineOnly && category !== undefined && (!categoriesToSkip.includes(category) || compilerOptionsMap.has(name)); } function writeConfigurations() { // Filter applicable options to place in the file @@ -37971,7 +39362,7 @@ var ts; for (var _i = 0, optionDeclarations_1 = ts.optionDeclarations; _i < optionDeclarations_1.length; _i++) { var option = optionDeclarations_1[_i]; var category = option.category; - if (isAllowedOption(option)) { + if (isAllowedOptionForOutput(option)) { categorizedOptions.add(ts.getLocaleSpecificMessage(category), option); } } @@ -38188,6 +39579,7 @@ var ts; validatedFilesSpec: ts.filter(filesSpecs, ts.isString), validatedIncludeSpecs: validatedIncludeSpecs, validatedExcludeSpecs: validatedExcludeSpecs, + pathPatterns: undefined, // Initialized on first use }; } function getFileNames(basePath) { @@ -38301,14 +39693,14 @@ var ts; if (ownConfig.extendedConfigPath) { // copy the resolution stack so it is never reused between branches in potential diamond-problem scenarios. resolutionStack = resolutionStack.concat([resolvedPath]); - var extendedConfig = getExtendedConfig(sourceFile, ownConfig.extendedConfigPath, host, basePath, resolutionStack, errors, extendedConfigCache); + var extendedConfig = getExtendedConfig(sourceFile, ownConfig.extendedConfigPath, host, resolutionStack, errors, extendedConfigCache); if (extendedConfig && isSuccessfulParsedTsconfig(extendedConfig)) { var baseRaw_1 = extendedConfig.raw; var raw_1 = ownConfig.raw; + var relativeDifference_1; var setPropertyInRawIfNotUndefined = function (propertyName) { - var value = raw_1[propertyName] || baseRaw_1[propertyName]; - if (value) { - raw_1[propertyName] = value; + if (!raw_1[propertyName] && baseRaw_1[propertyName]) { + raw_1[propertyName] = ts.map(baseRaw_1[propertyName], function (path) { return ts.isRootedDiskPath(path) ? path : ts.combinePaths(relativeDifference_1 || (relativeDifference_1 = ts.convertToRelativePath(ts.getDirectoryPath(ownConfig.extendedConfigPath), basePath, ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames))), path); }); } }; setPropertyInRawIfNotUndefined("include"); @@ -38390,7 +39782,7 @@ var ts; } } }; - var json = convertToObjectWorker(sourceFile, errors, /*returnValue*/ true, getTsconfigRootOptionsMap(), optionsIterator); + var json = convertConfigFileToObject(sourceFile, errors, /*reportOptionsErrors*/ true, optionsIterator); if (!typeAcquisition) { if (typingOptionstypeAcquisition) { typeAcquisition = (typingOptionstypeAcquisition.enableAutoDiscovery !== undefined) ? @@ -38428,7 +39820,7 @@ var ts; errors.push(createDiagnostic(ts.Diagnostics.File_0_not_found, extendedConfig)); return undefined; } - function getExtendedConfig(sourceFile, extendedConfigPath, host, basePath, resolutionStack, errors, extendedConfigCache) { + function getExtendedConfig(sourceFile, extendedConfigPath, host, resolutionStack, errors, extendedConfigCache) { var _a; var path = host.useCaseSensitiveFileNames ? extendedConfigPath : ts.toFileNameLowerCase(extendedConfigPath); var value; @@ -38440,22 +39832,7 @@ var ts; else { extendedResult = readJsonConfigFile(extendedConfigPath, function (path) { return host.readFile(path); }); if (!extendedResult.parseDiagnostics.length) { - var extendedDirname = ts.getDirectoryPath(extendedConfigPath); - extendedConfig = parseConfig(/*json*/ undefined, extendedResult, host, extendedDirname, ts.getBaseFileName(extendedConfigPath), resolutionStack, errors, extendedConfigCache); - if (isSuccessfulParsedTsconfig(extendedConfig)) { - // Update the paths to reflect base path - var relativeDifference_1 = ts.convertToRelativePath(extendedDirname, basePath, ts.identity); - var updatePath_1 = function (path) { return ts.isRootedDiskPath(path) ? path : ts.combinePaths(relativeDifference_1, path); }; - var mapPropertiesInRawIfNotUndefined = function (propertyName) { - if (raw_2[propertyName]) { - raw_2[propertyName] = ts.map(raw_2[propertyName], updatePath_1); - } - }; - var raw_2 = extendedConfig.raw; - mapPropertiesInRawIfNotUndefined("include"); - mapPropertiesInRawIfNotUndefined("exclude"); - mapPropertiesInRawIfNotUndefined("files"); - } + extendedConfig = parseConfig(/*json*/ undefined, extendedResult, host, ts.getDirectoryPath(extendedConfigPath), ts.getBaseFileName(extendedConfigPath), resolutionStack, errors, extendedConfigCache); } if (extendedConfigCache) { extendedConfigCache.set(path, { extendedResult: extendedResult, extendedConfig: extendedConfig }); @@ -38600,9 +39977,6 @@ var ts; function convertJsonOptionOfListType(option, values, basePath, errors) { return ts.filter(ts.map(values, function (v) { return convertJsonOption(option.element, v, basePath, errors); }), function (v) { return !!v; }); } - function trimString(s) { - return typeof s.trim === "function" ? s.trim() : s.replace(/^[\s]+|[\s]+$/g, ""); - } /** * Tests for a path that ends in a recursive directory wildcard. * Matches **, \**, **\, and \**\, but not a**b. @@ -38615,34 +39989,6 @@ var ts; * \/?$ # matches an optional trailing directory separator at the end of the string. */ var invalidTrailingRecursionPattern = /(^|\/)\*\*\/?$/; - /** - * Tests for a path where .. appears after a recursive directory wildcard. - * Matches **\..\*, **\a\..\*, and **\.., but not ..\**\* - * - * NOTE: used \ in place of / above to avoid issues with multiline comments. - * - * Breakdown: - * (^|\/) # matches either the beginning of the string or a directory separator. - * \*\*\/ # matches a recursive directory wildcard "**" followed by a directory separator. - * (.*\/)? # optionally matches any number of characters followed by a directory separator. - * \.\. # matches a parent directory path component ".." - * ($|\/) # matches either the end of the string or a directory separator. - */ - var invalidDotDotAfterRecursiveWildcardPattern = /(^|\/)\*\*\/(.*\/)?\.\.($|\/)/; - /** - * Tests for a path containing a wildcard character in a directory component of the path. - * Matches \*\, \?\, and \a*b\, but not \a\ or \a\*. - * - * NOTE: used \ in place of / above to avoid issues with multiline comments. - * - * Breakdown: - * \/ # matches a directory separator. - * [^/]*? # matches any number of characters excluding directory separators (non-greedy). - * [*?] # matches either a wildcard character (* or ?) - * [^/]* # matches any number of characters excluding directory separators (greedy). - * \/ # matches a directory separator. - */ - var watchRecursivePattern = /\/[^/]*?[*?][^/]*\//; /** * Matches the portion of a wildcard path that does not contain wildcards. * Matches \a of \a\*, or \a\b\c of \a\b\c\?\d. @@ -38683,7 +40029,7 @@ var ts; // via wildcard of *.json kind var wildCardJsonFileMap = new ts.Map(); var validatedFilesSpec = configFileSpecs.validatedFilesSpec, validatedIncludeSpecs = configFileSpecs.validatedIncludeSpecs, validatedExcludeSpecs = configFileSpecs.validatedExcludeSpecs; - // Rather than requery this for each file and filespec, we query the supported extensions + // Rather than re-query this for each file and filespec, we query the supported extensions // once and store it on the expansion context. var supportedExtensions = ts.getSupportedExtensions(options, extraFileExtensions); var supportedExtensionsWithJsonIfResolveJsonModule = ts.getSuppoertedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions); @@ -38761,9 +40107,22 @@ var ts; return matchesExcludeWorker(pathToCheck, validatedExcludeSpecs, useCaseSensitiveFileNames, currentDirectory, basePath); } ts.isExcludedFile = isExcludedFile; + function invalidDotDotAfterRecursiveWildcard(s) { + // We used to use the regex /(^|\/)\*\*\/(.*\/)?\.\.($|\/)/ to check for this case, but + // in v8, that has polynomial performance because the recursive wildcard match - **/ - + // can be matched in many arbitrary positions when multiple are present, resulting + // in bad backtracking (and we don't care which is matched - just that some /.. segment + // comes after some **/ segment). + var wildcardIndex = ts.startsWith(s, "**/") ? 0 : s.indexOf("/**/"); + if (wildcardIndex === -1) { + return false; + } + var lastDotIndex = ts.endsWith(s, "/..") ? s.length : s.lastIndexOf("/../"); + return lastDotIndex > wildcardIndex; + } /* @internal */ function matchesExclude(pathToCheck, excludeSpecs, useCaseSensitiveFileNames, currentDirectory) { - return matchesExcludeWorker(pathToCheck, ts.filter(excludeSpecs, function (spec) { return !invalidDotDotAfterRecursiveWildcardPattern.test(spec); }), useCaseSensitiveFileNames, currentDirectory); + return matchesExcludeWorker(pathToCheck, ts.filter(excludeSpecs, function (spec) { return !invalidDotDotAfterRecursiveWildcard(spec); }), useCaseSensitiveFileNames, currentDirectory); } ts.matchesExclude = matchesExclude; function matchesExcludeWorker(pathToCheck, excludeSpecs, useCaseSensitiveFileNames, currentDirectory, basePath) { @@ -38796,7 +40155,7 @@ var ts; if (disallowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) { return [ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec]; } - else if (invalidDotDotAfterRecursiveWildcardPattern.test(spec)) { + else if (invalidDotDotAfterRecursiveWildcard(spec)) { return [ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec]; } } @@ -38857,9 +40216,18 @@ var ts; function getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames) { var match = wildcardDirectoryPattern.exec(spec); if (match) { + // We check this with a few `indexOf` calls because 3 `indexOf`/`lastIndexOf` calls is + // less algorithmically complex (roughly O(3n) worst-case) than the regex we used to use, + // \/[^/]*?[*?][^/]*\/ which was polynominal in v8, since arbitrary sequences of wildcard + // characters could match any of the central patterns, resulting in bad backtracking. + var questionWildcardIndex = spec.indexOf("?"); + var starWildcardIndex = spec.indexOf("*"); + var lastDirectorySeperatorIndex = spec.lastIndexOf(ts.directorySeparator); return { key: useCaseSensitiveFileNames ? match[0] : ts.toFileNameLowerCase(match[0]), - flags: watchRecursivePattern.test(spec) ? 1 /* Recursive */ : 0 /* None */ + flags: (questionWildcardIndex !== -1 && questionWildcardIndex < lastDirectorySeperatorIndex) + || (starWildcardIndex !== -1 && starWildcardIndex < lastDirectorySeperatorIndex) + ? 1 /* Recursive */ : 0 /* None */ }; } if (ts.isImplicitGlob(spec)) { @@ -39152,13 +40520,24 @@ var ts; * This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups * is assumed to be the same as root directory of the project. */ - function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference) { + function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, cache) { var traceEnabled = isTraceEnabled(options, host); if (redirectedReference) { options = redirectedReference.commandLine.options; } - var failedLookupLocations = []; - var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations }; + var containingDirectory = containingFile ? ts.getDirectoryPath(containingFile) : undefined; + var perFolderCache = containingDirectory ? cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference) : undefined; + var result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName); + if (result) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1, typeReferenceDirectiveName, containingFile); + if (redirectedReference) + trace(host, ts.Diagnostics.Using_compiler_options_of_project_reference_redirect_0, redirectedReference.sourceFile.fileName); + trace(host, ts.Diagnostics.Resolution_for_type_reference_directive_0_was_found_in_cache_from_location_1, typeReferenceDirectiveName, containingDirectory); + traceResult(result); + } + return result; + } var typeRoots = getEffectiveTypeRoots(options, host); if (traceEnabled) { if (containingFile === undefined) { @@ -39181,6 +40560,8 @@ var ts; trace(host, ts.Diagnostics.Using_compiler_options_of_project_reference_redirect_0, redirectedReference.sourceFile.fileName); } } + var failedLookupLocations = []; + var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache }; var resolved = primaryLookup(); var primary = true; if (!resolved) { @@ -39191,17 +40572,31 @@ var ts; if (resolved) { var fileName = resolved.fileName, packageId = resolved.packageId; var resolvedFileName = options.preserveSymlinks ? fileName : realPath(fileName, host, traceEnabled); - if (traceEnabled) { - if (packageId) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3, typeReferenceDirectiveName, resolvedFileName, ts.packageIdToString(packageId), primary); - } - else { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFileName, primary); - } + resolvedTypeReferenceDirective = { + primary: primary, + resolvedFileName: resolvedFileName, + originalPath: fileName === resolvedFileName ? undefined : fileName, + packageId: packageId, + isExternalLibraryImport: pathContainsNodeModules(fileName), + }; + } + result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations }; + perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, result); + if (traceEnabled) + traceResult(result); + return result; + function traceResult(result) { + var _a; + if (!((_a = result.resolvedTypeReferenceDirective) === null || _a === void 0 ? void 0 : _a.resolvedFileName)) { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); + } + else if (result.resolvedTypeReferenceDirective.packageId) { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3, typeReferenceDirectiveName, result.resolvedTypeReferenceDirective.resolvedFileName, ts.packageIdToString(result.resolvedTypeReferenceDirective.packageId), result.resolvedTypeReferenceDirective.primary); + } + else { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, result.resolvedTypeReferenceDirective.resolvedFileName, result.resolvedTypeReferenceDirective.primary); } - resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolvedFileName, packageId: packageId, isExternalLibraryImport: pathContainsNodeModules(fileName) }; } - return { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations }; function primaryLookup() { // Check primary library paths if (typeRoots && typeRoots.length) { @@ -39231,20 +40626,16 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); } - var result = void 0; + var result_4; if (!ts.isExternalModuleNameRelative(typeReferenceDirectiveName)) { var searchResult = loadModuleFromNearestNodeModulesDirectory(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, moduleResolutionState, /*cache*/ undefined, /*redirectedReference*/ undefined); - result = searchResult && searchResult.value; + result_4 = searchResult && searchResult.value; } else { var candidate = ts.normalizePathAndParts(ts.combinePaths(initialLocationForSecondaryLookup, typeReferenceDirectiveName)).path; - result = nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, /*onlyRecordFailures*/ false, moduleResolutionState, /*considerPackageJson*/ true); - } - var resolvedFile = resolvedTypeScriptOnly(result); - if (!resolvedFile && traceEnabled) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); + result_4 = nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, /*onlyRecordFailures*/ false, moduleResolutionState, /*considerPackageJson*/ true); } - return resolvedFile; + return resolvedTypeScriptOnly(result_4); } else { if (traceEnabled) { @@ -39299,22 +40690,21 @@ var ts; return result; } ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; - function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options) { - return createModuleResolutionCacheWithMaps(createCacheWithRedirects(options), createCacheWithRedirects(options), currentDirectory, getCanonicalFileName); - } - ts.createModuleResolutionCache = createModuleResolutionCache; /*@internal*/ function createCacheWithRedirects(options) { var ownMap = new ts.Map(); var redirectsMap = new ts.Map(); return { - ownMap: ownMap, + getOwnMap: getOwnMap, redirectsMap: redirectsMap, getOrCreateMapOfCacheRedirects: getOrCreateMapOfCacheRedirects, clear: clear, setOwnOptions: setOwnOptions, setOwnMap: setOwnMap }; + function getOwnMap() { + return ownMap; + } function setOwnOptions(newOptions) { options = newOptions; } @@ -39340,26 +40730,88 @@ var ts; } } ts.createCacheWithRedirects = createCacheWithRedirects; - /*@internal*/ - function createModuleResolutionCacheWithMaps(directoryToModuleNameMap, moduleNameToDirectoryMap, currentDirectory, getCanonicalFileName) { - return { getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, directoryToModuleNameMap: directoryToModuleNameMap, moduleNameToDirectoryMap: moduleNameToDirectoryMap }; + function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName) { + var cache; + return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear }; + function getPackageJsonInfo(packageJsonPath) { + return cache === null || cache === void 0 ? void 0 : cache.get(ts.toPath(packageJsonPath, currentDirectory, getCanonicalFileName)); + } + function setPackageJsonInfo(packageJsonPath, info) { + (cache || (cache = new ts.Map())).set(ts.toPath(packageJsonPath, currentDirectory, getCanonicalFileName), info); + } + function clear() { + cache = undefined; + } + } + function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) { + var cache = cacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference); + var result = cache.get(key); + if (!result) { + result = create(); + cache.set(key, result); + } + return result; + } + function updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap) { + if (!options.configFile) + return; + if (directoryToModuleNameMap.redirectsMap.size === 0) { + // The own map will be for projectCompilerOptions + ts.Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.redirectsMap.size === 0); + ts.Debug.assert(directoryToModuleNameMap.getOwnMap().size === 0); + ts.Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.getOwnMap().size === 0); + directoryToModuleNameMap.redirectsMap.set(options.configFile.path, directoryToModuleNameMap.getOwnMap()); + moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.redirectsMap.set(options.configFile.path, moduleNameToDirectoryMap.getOwnMap()); + } + else { + // Set correct own map + ts.Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.redirectsMap.size > 0); + var ref = { + sourceFile: options.configFile, + commandLine: { options: options } + }; + directoryToModuleNameMap.setOwnMap(directoryToModuleNameMap.getOrCreateMapOfCacheRedirects(ref)); + moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.setOwnMap(moduleNameToDirectoryMap.getOrCreateMapOfCacheRedirects(ref)); + } + directoryToModuleNameMap.setOwnOptions(options); + moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.setOwnOptions(options); + } + function createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap) { + return { + getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, + clear: clear, + update: update, + }; + function clear() { + directoryToModuleNameMap.clear(); + } + function update(options) { + updateRedirectsMap(options, directoryToModuleNameMap); + } function getOrCreateCacheForDirectory(directoryName, redirectedReference) { var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName); return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, function () { return new ts.Map(); }); } + } + function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options, directoryToModuleNameMap, moduleNameToDirectoryMap) { + var preDirectoryResolutionCache = 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; } }); + function clear() { + preDirectoryResolutionCache.clear(); + moduleNameToDirectoryMap.clear(); + packageJsonInfoCache.clear(); + } + function update(options) { + updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap); + } function getOrCreateCacheForModuleName(nonRelativeModuleName, redirectedReference) { ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName)); return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, nonRelativeModuleName, createPerModuleNameCache); } - function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) { - var cache = cacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference); - var result = cache.get(key); - if (!result) { - result = create(); - cache.set(key, result); - } - return result; - } function createPerModuleNameCache() { var directoryPathMap = new ts.Map(); return { get: get, set: set }; @@ -39426,7 +40878,17 @@ var ts; } } } - ts.createModuleResolutionCacheWithMaps = createModuleResolutionCacheWithMaps; + ts.createModuleResolutionCache = createModuleResolutionCache; + function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache, directoryToModuleNameMap) { + var preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options))); + packageJsonInfoCache || (packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName)); + return __assign(__assign(__assign({}, packageJsonInfoCache), preDirectoryResolutionCache), { clear: clear }); + function clear() { + preDirectoryResolutionCache.clear(); + packageJsonInfoCache.clear(); + } + } + ts.createTypeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache; function resolveModuleNameFromCache(moduleName, containingFile, cache) { var containingDirectory = ts.getDirectoryPath(containingFile); var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); @@ -39575,7 +41037,8 @@ var ts; } } function tryLoadModuleUsingPathsIfEligible(extensions, moduleName, loader, state) { - var _a = state.compilerOptions, baseUrl = _a.baseUrl, paths = _a.paths; + var _a; + var _b = state.compilerOptions, baseUrl = _b.baseUrl, paths = _b.paths, configFile = _b.configFile; if (paths && !ts.pathIsRelative(moduleName)) { if (state.traceEnabled) { if (baseUrl) { @@ -39584,7 +41047,8 @@ var ts; trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); } var baseDirectory = ts.getPathsBasePath(state.compilerOptions, state.host); // Always defined when 'paths' is defined - return tryLoadModuleUsingPaths(extensions, moduleName, baseDirectory, paths, loader, /*onlyRecordFailures*/ false, state); + var pathPatterns = (configFile === null || configFile === void 0 ? void 0 : configFile.configFileSpecs) ? (_a = configFile.configFileSpecs).pathPatterns || (_a.pathPatterns = ts.tryParsePatterns(paths)) : undefined; + return tryLoadModuleUsingPaths(extensions, moduleName, baseDirectory, paths, pathPatterns, loader, /*onlyRecordFailures*/ false, state); } } function tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, state) { @@ -39704,7 +41168,7 @@ var ts; var _a, _b; var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations }; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache }; var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); }); return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, state.resultFromCache); function tryResolve(extensions) { @@ -39764,7 +41228,7 @@ var ts; } var resolvedFromFile = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state); if (resolvedFromFile) { - var packageDirectory = considerPackageJson ? parseNodeModuleFromPath(resolvedFromFile) : undefined; + var packageDirectory = considerPackageJson ? parseNodeModuleFromPath(resolvedFromFile.path) : undefined; var packageInfo = packageDirectory ? getPackageJsonInfo(packageDirectory, /*onlyRecordFailures*/ false, state) : undefined; return withPackageId(packageInfo, resolvedFromFile); } @@ -39797,8 +41261,9 @@ var ts; * For `/node_modules/@types/foo/bar/index.d.ts` this is packageDirectory: "@types/foo" * For `/node_modules/foo/bar/index.d.ts` this is packageDirectory: "foo" */ + /* @internal */ function parseNodeModuleFromPath(resolved) { - var path = ts.normalizePath(resolved.path); + var path = ts.normalizePath(resolved); var idx = path.lastIndexOf(ts.nodeModulesPathPart); if (idx === -1) { return undefined; @@ -39810,6 +41275,7 @@ var ts; } return path.slice(0, indexAfterPackageName); } + ts.parseNodeModuleFromPath = parseNodeModuleFromPath; function moveToNextDirectorySeparatorIfAvailable(path, prevSeparatorIndex) { var nextSeparatorIndex = path.indexOf(ts.directorySeparator, prevSeparatorIndex + 1); return nextSeparatorIndex === -1 ? prevSeparatorIndex : nextSeparatorIndex; @@ -39893,21 +41359,43 @@ var ts; return withPackageId(packageInfo, loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJsonContent, versionPaths)); } function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) { + var _a, _b, _c; var host = state.host, traceEnabled = state.traceEnabled; - var directoryExists = !onlyRecordFailures && ts.directoryProbablyExists(packageDirectory, host); var packageJsonPath = ts.combinePaths(packageDirectory, "package.json"); + if (onlyRecordFailures) { + state.failedLookupLocations.push(packageJsonPath); + return undefined; + } + var existing = (_a = state.packageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.getPackageJsonInfo(packageJsonPath); + if (existing !== undefined) { + if (typeof existing !== "boolean") { + if (traceEnabled) + trace(host, ts.Diagnostics.File_0_exists_according_to_earlier_cached_lookups, packageJsonPath); + return existing; + } + else { + if (existing && traceEnabled) + trace(host, ts.Diagnostics.File_0_does_not_exist_according_to_earlier_cached_lookups, packageJsonPath); + state.failedLookupLocations.push(packageJsonPath); + return undefined; + } + } + var directoryExists = ts.directoryProbablyExists(packageDirectory, host); if (directoryExists && host.fileExists(packageJsonPath)) { var packageJsonContent = ts.readJson(packageJsonPath, host); if (traceEnabled) { trace(host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); } var versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state); - return { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths }; + var result = { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths }; + (_b = state.packageJsonInfoCache) === null || _b === void 0 ? void 0 : _b.setPackageJsonInfo(packageJsonPath, result); + return result; } else { if (directoryExists && traceEnabled) { trace(host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); } + (_c = state.packageJsonInfoCache) === null || _c === void 0 ? void 0 : _c.setPackageJsonInfo(packageJsonPath, directoryExists); // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results state.failedLookupLocations.push(packageJsonPath); } @@ -39958,7 +41446,7 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2, versionPaths.version, ts.version, moduleName); } - var result = tryLoadModuleUsingPaths(extensions, moduleName, candidate, versionPaths.paths, loader, onlyRecordFailuresForPackageFile || onlyRecordFailuresForIndex, state); + var result = tryLoadModuleUsingPaths(extensions, moduleName, candidate, versionPaths.paths, /*pathPatterns*/ undefined, loader, onlyRecordFailuresForPackageFile || onlyRecordFailuresForIndex, state); if (result) { return removeIgnoredPackageId(result.value); } @@ -40065,7 +41553,7 @@ var ts; trace(state.host, ts.Diagnostics.package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2, packageInfo.versionPaths.version, ts.version, rest); } var packageDirectoryExists = nodeModulesDirectoryExists && ts.directoryProbablyExists(packageDirectory, state.host); - var fromPaths = tryLoadModuleUsingPaths(extensions, rest, packageDirectory, packageInfo.versionPaths.paths, loader, !packageDirectoryExists, state); + var fromPaths = tryLoadModuleUsingPaths(extensions, rest, packageDirectory, packageInfo.versionPaths.paths, /*pathPatterns*/ undefined, loader, !packageDirectoryExists, state); if (fromPaths) { return fromPaths.value; } @@ -40073,8 +41561,9 @@ var ts; } return loader(extensions, candidate, !nodeModulesDirectoryExists, state); } - function tryLoadModuleUsingPaths(extensions, moduleName, baseDirectory, paths, loader, onlyRecordFailures, state) { - var matchedPattern = ts.matchPatternOrExact(ts.getOwnKeys(paths), moduleName); + function tryLoadModuleUsingPaths(extensions, moduleName, baseDirectory, paths, pathPatterns, loader, onlyRecordFailures, state) { + pathPatterns || (pathPatterns = ts.tryParsePatterns(paths)); + var matchedPattern = ts.matchPatternOrExact(pathPatterns, moduleName); if (matchedPattern) { var matchedStar_1 = ts.isString(matchedPattern) ? undefined : ts.matchedText(matchedPattern, moduleName); var matchedPatternText = ts.isString(matchedPattern) ? matchedPattern : ts.patternText(matchedPattern); @@ -40156,7 +41645,7 @@ var ts; function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) { var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations }; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache }; var containingDirectory = ts.getDirectoryPath(containingFile); var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); // No originalPath because classic resolution doesn't resolve realPath @@ -40197,13 +41686,13 @@ var ts; * This is the minumum code needed to expose that functionality; the rest is in the host. */ /* @internal */ - function loadModuleFromGlobalCache(moduleName, projectName, compilerOptions, host, globalCache) { + function loadModuleFromGlobalCache(moduleName, projectName, compilerOptions, host, globalCache, packageJsonInfoCache) { var traceEnabled = isTraceEnabled(compilerOptions, host); if (traceEnabled) { trace(host, ts.Diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2, projectName, moduleName, globalCache); } var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations }; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: packageJsonInfoCache }; var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, /*typesScopeOnly*/ false); return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, state.resultFromCache); } @@ -40249,26 +41738,26 @@ var ts; // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: return 0 /* NonInstantiated */; // 2. const enum declarations - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: if (ts.isEnumConst(node)) { return 2 /* ConstEnumOnly */; } break; // 3. non-exported import declarations - case 261 /* ImportDeclaration */: - case 260 /* ImportEqualsDeclaration */: + case 263 /* ImportDeclaration */: + case 262 /* ImportEqualsDeclaration */: if (!(ts.hasSyntacticModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } break; // 4. Export alias declarations pointing at only uninstantiated modules or things uninstantiated modules contain - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: var exportDeclaration = node; - if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 268 /* NamedExports */) { + if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 270 /* NamedExports */) { var state = 0 /* NonInstantiated */; for (var _i = 0, _a = exportDeclaration.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; @@ -40284,7 +41773,7 @@ var ts; } break; // 5. other uninstantiated module declarations. - case 257 /* ModuleBlock */: { + case 259 /* ModuleBlock */: { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateCached(n, visited); @@ -40306,9 +41795,9 @@ var ts; }); return state_1; } - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return getModuleInstanceState(node, visited); - case 78 /* Identifier */: + case 79 /* Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should // be considered the same as type alias if (node.isInJSDocNamespace) { @@ -40378,14 +41867,14 @@ var ts; } var binder = createBinder(); function bindSourceFile(file, options) { - ts.tracing.push("bind" /* Bind */, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("bind" /* Bind */, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeBind"); ts.perfLogger.logStartBindFile("" + file.fileName); binder(file, options); ts.perfLogger.logStopBindFile(); ts.performance.mark("afterBind"); ts.performance.measure("Bind", "beforeBind", "afterBind"); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } ts.bindSourceFile = bindSourceFile; function createBinder() { @@ -40424,6 +41913,7 @@ var ts; var classifiableNames; var unreachableFlow = { flags: 1 /* Unreachable */ }; var reportedUnreachableFlow = { flags: 1 /* 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) * If so, the node _must_ be in the current file (as that's the only way anything could have traversed to it to yield it as the error node) @@ -40506,7 +41996,7 @@ var ts; // 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 === 266 /* ExportAssignment */) { + if (node.kind === 268 /* ExportAssignment */) { return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; } var name = ts.getNameOfDeclaration(node); @@ -40515,7 +42005,7 @@ var ts; var moduleName = ts.getTextOfIdentifierOrLiteral(name); return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); } - if (name.kind === 158 /* ComputedPropertyName */) { + if (name.kind === 160 /* ComputedPropertyName */) { var nameExpression = name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteralLike(nameExpression)) { @@ -40524,11 +42014,9 @@ var ts; if (ts.isSignedNumericLiteral(nameExpression)) { return ts.tokenToString(nameExpression.operator) + nameExpression.operand.text; } - ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); - return ts.getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); - } - if (ts.isWellKnownSymbolSyntactically(name)) { - return ts.getPropertyNameForKnownSymbolName(ts.idText(name.name)); + else { + ts.Debug.fail("Only computed properties with literal names have declaration names"); + } } if (ts.isPrivateIdentifier(name)) { // containingClass exists because private names only allowed inside classes @@ -40543,36 +42031,36 @@ var ts; return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 166 /* Constructor */: + case 168 /* Constructor */: return "__constructor" /* Constructor */; - case 174 /* FunctionType */: - case 169 /* CallSignature */: - case 313 /* JSDocSignature */: + case 176 /* FunctionType */: + case 171 /* CallSignature */: + case 317 /* JSDocSignature */: return "__call" /* Call */; - case 175 /* ConstructorType */: - case 170 /* ConstructSignature */: + case 177 /* ConstructorType */: + case 172 /* ConstructSignature */: return "__new" /* New */; - case 171 /* IndexSignature */: + case 173 /* IndexSignature */: return "__index" /* Index */; - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: return "__export" /* ExportStar */; - case 297 /* SourceFile */: + case 299 /* SourceFile */: // json file should behave as // module.exports = ... return "export=" /* ExportEquals */; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */) { // module.exports = ... return "export=" /* ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 308 /* JSDocFunctionType */: + case 311 /* JSDocFunctionType */: return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); - case 160 /* Parameter */: + case 162 /* 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 === 308 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); + ts.Debug.assert(node.parent.kind === 311 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); var functionType = node.parent; var index = functionType.parameters.indexOf(node); return "arg" + index; @@ -40672,7 +42160,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 === 266 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 268 /* ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; messageNeedsName_1 = false; multipleDefaultExports_1 = true; @@ -40711,7 +42199,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = !!(ts.getCombinedModifierFlags(node) & 1 /* Export */) || jsdocTreatAsExported(node); if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 270 /* ExportSpecifier */ || (node.kind === 260 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 272 /* ExportSpecifier */ || (node.kind === 262 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -40800,7 +42288,7 @@ var ts; // 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 !== 209 /* ArrowFunction */) { + if (node.kind !== 211 /* ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -40833,7 +42321,7 @@ var ts; } // We create a return control flow graph for IIFEs and constructors. For constructors // we use the return control flow graph in strict property initialization checks. - currentReturnTarget = isIIFE || node.kind === 166 /* Constructor */ || (ts.isInJSFile(node) && (node.kind === 251 /* FunctionDeclaration */ || node.kind === 208 /* FunctionExpression */)) ? createBranchLabel() : undefined; + currentReturnTarget = isIIFE || node.kind === 168 /* Constructor */ || (ts.isInJSFile(node) && (node.kind === 253 /* FunctionDeclaration */ || node.kind === 210 /* FunctionExpression */)) ? createBranchLabel() : undefined; currentExceptionTarget = undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; @@ -40848,13 +42336,14 @@ var ts; node.flags |= 512 /* HasExplicitReturn */; node.endFlowNode = currentFlow; } - if (node.kind === 297 /* SourceFile */) { + if (node.kind === 299 /* SourceFile */) { node.flags |= emitFlags; + node.endFlowNode = currentFlow; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 166 /* Constructor */ || (ts.isInJSFile(node) && (node.kind === 251 /* FunctionDeclaration */ || node.kind === 208 /* FunctionExpression */))) { + if (node.kind === 168 /* Constructor */ || (ts.isInJSFile(node) && (node.kind === 253 /* FunctionDeclaration */ || node.kind === 210 /* FunctionExpression */))) { node.returnFlowNode = currentFlow; } } @@ -40881,8 +42370,8 @@ var ts; blockScopeContainer = savedBlockScopeContainer; } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 251 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 251 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 253 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 253 /* FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -40905,59 +42394,59 @@ var ts; inAssignmentPattern = saveInAssignmentPattern; return; } - if (node.kind >= 232 /* FirstStatement */ && node.kind <= 248 /* LastStatement */ && !options.allowUnreachableCode) { + if (node.kind >= 234 /* FirstStatement */ && node.kind <= 250 /* LastStatement */ && !options.allowUnreachableCode) { node.flowNode = currentFlow; } switch (node.kind) { - case 236 /* WhileStatement */: + case 238 /* WhileStatement */: bindWhileStatement(node); break; - case 235 /* DoStatement */: + case 237 /* DoStatement */: bindDoStatement(node); break; - case 237 /* ForStatement */: + case 239 /* ForStatement */: bindForStatement(node); break; - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 234 /* IfStatement */: + case 236 /* IfStatement */: bindIfStatement(node); break; - case 242 /* ReturnStatement */: - case 246 /* ThrowStatement */: + case 244 /* ReturnStatement */: + case 248 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 241 /* BreakStatement */: - case 240 /* ContinueStatement */: + case 243 /* BreakStatement */: + case 242 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 247 /* TryStatement */: + case 249 /* TryStatement */: bindTryStatement(node); break; - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: bindSwitchStatement(node); break; - case 258 /* CaseBlock */: + case 260 /* CaseBlock */: bindCaseBlock(node); break; - case 284 /* CaseClause */: + case 286 /* CaseClause */: bindCaseClause(node); break; - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: bindExpressionStatement(node); break; - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: bindLabeledStatement(node); break; - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: if (ts.isDestructuringAssignment(node)) { // Carry over whether we are in an assignment pattern to // binary expressions that could actually be an initializer @@ -40967,47 +42456,47 @@ var ts; } bindBinaryExpressionFlow(node); break; - case 210 /* DeleteExpression */: + case 212 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: bindAccessExpressionFlow(node); break; - case 203 /* CallExpression */: + case 205 /* CallExpression */: bindCallExpressionFlow(node); break; - case 225 /* NonNullExpression */: + case 227 /* NonNullExpression */: bindNonNullExpressionFlow(node); break; - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 325 /* JSDocEnumTag */: + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + case 333 /* JSDocEnumTag */: bindJSDocTypeAlias(node); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 297 /* SourceFile */: { + case 299 /* SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; } - case 230 /* Block */: - case 257 /* ModuleBlock */: + case 232 /* Block */: + case 259 /* ModuleBlock */: bindEachFunctionsFirst(node.statements); break; - case 198 /* BindingElement */: + case 200 /* BindingElement */: bindBindingElementFlow(node); break; - case 200 /* ObjectLiteralExpression */: - case 199 /* ArrayLiteralExpression */: - case 288 /* PropertyAssignment */: - case 220 /* SpreadElement */: + case 202 /* ObjectLiteralExpression */: + case 201 /* ArrayLiteralExpression */: + case 290 /* PropertyAssignment */: + case 222 /* 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; @@ -41021,32 +42510,32 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 78 /* Identifier */: - case 79 /* PrivateIdentifier */: - case 107 /* ThisKeyword */: - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 79 /* Identifier */: + case 80 /* PrivateIdentifier */: + case 108 /* ThisKeyword */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: return containsNarrowableReference(expr); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return hasNarrowableArgument(expr); - case 207 /* ParenthesizedExpression */: - case 225 /* NonNullExpression */: + case 209 /* ParenthesizedExpression */: + case 227 /* NonNullExpression */: return isNarrowingExpression(expr.expression); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return expr.operator === 53 /* ExclamationToken */ && isNarrowingExpression(expr.operand); - case 211 /* TypeOfExpression */: + case 213 /* TypeOfExpression */: return isNarrowingExpression(expr.expression); } return false; } function isNarrowableReference(expr) { - return expr.kind === 78 /* Identifier */ || expr.kind === 79 /* PrivateIdentifier */ || expr.kind === 107 /* ThisKeyword */ || expr.kind === 105 /* SuperKeyword */ || - (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) || - ts.isBinaryExpression(expr) && expr.operatorToken.kind === 27 /* CommaToken */ && isNarrowableReference(expr.right) || - ts.isElementAccessExpression(expr) && ts.isStringOrNumericLiteralLike(expr.argumentExpression) && isNarrowableReference(expr.expression) || - ts.isAssignmentExpression(expr) && isNarrowableReference(expr.left); + 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.isElementAccessExpression(expr) && ts.isStringOrNumericLiteralLike(expr.argumentExpression) && isNarrowableReference(expr.expression) + || ts.isAssignmentExpression(expr) && isNarrowableReference(expr.left); } function containsNarrowableReference(expr) { return isNarrowableReference(expr) || ts.isOptionalChain(expr) && containsNarrowableReference(expr.expression); @@ -41060,7 +42549,7 @@ var ts; } } } - if (expr.expression.kind === 201 /* PropertyAccessExpression */ && + if (expr.expression.kind === 203 /* PropertyAccessExpression */ && containsNarrowableReference(expr.expression.expression)) { return true; } @@ -41074,10 +42563,10 @@ var ts; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 62 /* EqualsToken */: - case 74 /* BarBarEqualsToken */: - case 75 /* AmpersandAmpersandEqualsToken */: - case 76 /* QuestionQuestionEqualsToken */: + case 63 /* EqualsToken */: + case 75 /* BarBarEqualsToken */: + case 76 /* AmpersandAmpersandEqualsToken */: + case 77 /* QuestionQuestionEqualsToken */: return containsNarrowableReference(expr.left); case 34 /* EqualsEqualsToken */: case 35 /* ExclamationEqualsToken */: @@ -41085,9 +42574,9 @@ var ts; case 37 /* ExclamationEqualsEqualsToken */: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 101 /* InstanceOfKeyword */: + case 102 /* InstanceOfKeyword */: return isNarrowableOperand(expr.left); - case 100 /* InKeyword */: + case 101 /* InKeyword */: return isNarrowableInOperands(expr.left, expr.right); case 27 /* CommaToken */: return isNarrowingExpression(expr.right); @@ -41096,11 +42585,11 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: switch (expr.operatorToken.kind) { - case 62 /* EqualsToken */: + case 63 /* EqualsToken */: return isNarrowableOperand(expr.left); case 27 /* CommaToken */: return isNarrowableOperand(expr.right); @@ -41134,8 +42623,8 @@ var ts; if (!expression) { return flags & 32 /* TrueCondition */ ? antecedent : unreachableFlow; } - if ((expression.kind === 109 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || - expression.kind === 94 /* FalseKeyword */ && flags & 32 /* TrueCondition */) && + if ((expression.kind === 110 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || + expression.kind === 95 /* FalseKeyword */ && flags & 32 /* TrueCondition */) && !ts.isExpressionOfOptionalChainRoot(expression) && !ts.isNullishCoalesce(expression.parent)) { return unreachableFlow; } @@ -41174,26 +42663,26 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 234 /* IfStatement */: - case 236 /* WhileStatement */: - case 235 /* DoStatement */: + case 236 /* IfStatement */: + case 238 /* WhileStatement */: + case 237 /* DoStatement */: return parent.expression === node; - case 237 /* ForStatement */: - case 217 /* ConditionalExpression */: + case 239 /* ForStatement */: + case 219 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 207 /* ParenthesizedExpression */) { + if (node.kind === 209 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 214 /* PrefixUnaryExpression */ && node.operator === 53 /* ExclamationToken */) { + else if (node.kind === 216 /* PrefixUnaryExpression */ && node.operator === 53 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 216 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || + return node.kind === 218 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 56 /* BarBarToken */ || node.operatorToken.kind === 60 /* QuestionQuestionToken */); } @@ -41240,7 +42729,7 @@ var ts; } function setContinueTarget(node, target) { var label = activeLabelList; - while (label && node.parent.kind === 245 /* LabeledStatement */) { + while (label && node.parent.kind === 247 /* LabeledStatement */) { label.continueTarget = target; label = label.next; node = node.parent; @@ -41291,12 +42780,12 @@ var ts; bind(node.expression); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 239 /* ForOfStatement */) { + if (node.kind === 241 /* ForOfStatement */) { bind(node.awaitModifier); } addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 250 /* VariableDeclarationList */) { + if (node.initializer.kind !== 252 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -41318,7 +42807,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 242 /* ReturnStatement */) { + if (node.kind === 244 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -41335,7 +42824,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 241 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 243 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -41440,7 +42929,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 285 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 287 /* 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. @@ -41488,9 +42977,9 @@ var ts; function maybeBindExpressionFlowIfCall(node) { // A top level or LHS of 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 === 203 /* CallExpression */) { + if (node.kind === 205 /* CallExpression */) { var call = node; - if (ts.isDottedName(call.expression) && call.expression.kind !== 105 /* SuperKeyword */) { + if (call.expression.kind !== 106 /* SuperKeyword */ && ts.isDottedName(call.expression)) { currentFlow = createFlowCall(currentFlow, call); } } @@ -41514,7 +43003,7 @@ var ts; currentFlow = finishFlowLabel(postStatementLabel); } function bindDestructuringTargetFlow(node) { - if (node.kind === 216 /* BinaryExpression */ && node.operatorToken.kind === 62 /* EqualsToken */) { + if (node.kind === 218 /* BinaryExpression */ && node.operatorToken.kind === 63 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -41525,10 +43014,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowMutation(16 /* Assignment */, currentFlow, node); } - else if (node.kind === 199 /* ArrayLiteralExpression */) { + else if (node.kind === 201 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 220 /* SpreadElement */) { + if (e.kind === 222 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -41536,16 +43025,16 @@ var ts; } } } - else if (node.kind === 200 /* ObjectLiteralExpression */) { + else if (node.kind === 202 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 288 /* PropertyAssignment */) { + if (p.kind === 290 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 289 /* ShorthandPropertyAssignment */) { + else if (p.kind === 291 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 290 /* SpreadAssignment */) { + else if (p.kind === 292 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -41553,7 +43042,7 @@ var ts; } function bindLogicalLikeExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 75 /* AmpersandAmpersandEqualsToken */) { + if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 76 /* AmpersandAmpersandEqualsToken */) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -41610,128 +43099,102 @@ var ts; } bindAssignmentTargetFlow(node.left); } - var BindBinaryExpressionFlowState; - (function (BindBinaryExpressionFlowState) { - BindBinaryExpressionFlowState[BindBinaryExpressionFlowState["BindThenBindChildren"] = 0] = "BindThenBindChildren"; - BindBinaryExpressionFlowState[BindBinaryExpressionFlowState["MaybeBindLeft"] = 1] = "MaybeBindLeft"; - BindBinaryExpressionFlowState[BindBinaryExpressionFlowState["BindToken"] = 2] = "BindToken"; - BindBinaryExpressionFlowState[BindBinaryExpressionFlowState["BindRight"] = 3] = "BindRight"; - BindBinaryExpressionFlowState[BindBinaryExpressionFlowState["FinishBind"] = 4] = "FinishBind"; - })(BindBinaryExpressionFlowState || (BindBinaryExpressionFlowState = {})); - function bindBinaryExpressionFlow(node) { - var workStacks = { - expr: [node], - state: [1 /* MaybeBindLeft */], - inStrictMode: [undefined], - parent: [undefined], - }; - var stackIndex = 0; - while (stackIndex >= 0) { - node = workStacks.expr[stackIndex]; - switch (workStacks.state[stackIndex]) { - case 0 /* BindThenBindChildren */: { - // This state is used only when recuring, to emulate the work that `bind` does before - // reaching `bindChildren`. A normal call to `bindBinaryExpressionFlow` will already have done this work. - ts.setParent(node, parent); - var saveInStrictMode = inStrictMode; - bindWorker(node); - var saveParent = parent; - parent = node; - advanceState(1 /* MaybeBindLeft */, saveInStrictMode, saveParent); - break; - } - case 1 /* MaybeBindLeft */: { - var operator = node.operatorToken.kind; - // TODO: bindLogicalExpression is recursive - if we want to handle deeply nested `&&` expressions - // 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 - if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */ || - ts.isLogicalOrCoalescingAssignmentOperator(operator)) { - if (isTopLevelLogicalExpression(node)) { - var postExpressionLabel = createBranchLabel(); - bindLogicalLikeExpression(node, postExpressionLabel, postExpressionLabel); - currentFlow = finishFlowLabel(postExpressionLabel); - } - else { - bindLogicalLikeExpression(node, currentTrueTarget, currentFalseTarget); - } - completeNode(); - } - else { - advanceState(2 /* BindToken */); - maybeBind(node.left); - } - break; + function createBindBinaryExpressionFlow() { + return ts.createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, /*foldState*/ undefined); + function onEnter(node, state) { + if (state) { + state.stackIndex++; + // Emulate the work that `bind` does before reaching `bindChildren`. A normal call to + // `bindBinaryExpressionFlow` will already have done this work. + ts.setParent(node, parent); + var saveInStrictMode = inStrictMode; + bindWorker(node); + var saveParent = parent; + parent = node; + state.skip = false; + state.inStrictModeStack[state.stackIndex] = saveInStrictMode; + state.parentStack[state.stackIndex] = saveParent; + } + else { + state = { + stackIndex: 0, + skip: false, + inStrictModeStack: [undefined], + parentStack: [undefined] + }; + } + // TODO: bindLogicalExpression is recursive - if we want to handle deeply nested `&&` expressions + // 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 */ || + ts.isLogicalOrCoalescingAssignmentOperator(operator)) { + if (isTopLevelLogicalExpression(node)) { + var postExpressionLabel = createBranchLabel(); + bindLogicalLikeExpression(node, postExpressionLabel, postExpressionLabel); + currentFlow = finishFlowLabel(postExpressionLabel); } - case 2 /* BindToken */: { - if (node.operatorToken.kind === 27 /* CommaToken */) { - maybeBindExpressionFlowIfCall(node.left); - } - advanceState(3 /* BindRight */); - maybeBind(node.operatorToken); - break; + else { + bindLogicalLikeExpression(node, currentTrueTarget, currentFalseTarget); } - case 3 /* BindRight */: { - advanceState(4 /* FinishBind */); - maybeBind(node.right); - break; + state.skip = true; + } + return state; + } + function onLeft(left, state, _node) { + if (!state.skip) { + return maybeBind(left); + } + } + function onOperator(operatorToken, state, node) { + if (!state.skip) { + if (operatorToken.kind === 27 /* CommaToken */) { + maybeBindExpressionFlowIfCall(node.left); } - case 4 /* FinishBind */: { - var operator = node.operatorToken.kind; - if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { - bindAssignmentTargetFlow(node.left); - if (operator === 62 /* EqualsToken */ && node.left.kind === 202 /* ElementAccessExpression */) { - var elementAccess = node.left; - if (isNarrowableOperand(elementAccess.expression)) { - currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node); - } + bind(operatorToken); + } + } + function onRight(right, state, _node) { + if (!state.skip) { + return maybeBind(right); + } + } + function onExit(node, state) { + if (!state.skip) { + var operator = node.operatorToken.kind; + if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { + bindAssignmentTargetFlow(node.left); + if (operator === 63 /* EqualsToken */ && node.left.kind === 204 /* ElementAccessExpression */) { + var elementAccess = node.left; + if (isNarrowableOperand(elementAccess.expression)) { + currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node); } } - completeNode(); - break; } - default: return ts.Debug.fail("Invalid state " + workStacks.state[stackIndex] + " for bindBinaryExpressionFlow"); } - } - /** - * Note that `advanceState` sets the _current_ head state, and that `maybeBind` potentially pushes on a new - * head state; so `advanceState` must be called before any `maybeBind` during a state's execution. - */ - function advanceState(state, isInStrictMode, parent) { - workStacks.state[stackIndex] = state; - if (isInStrictMode !== undefined) { - workStacks.inStrictMode[stackIndex] = isInStrictMode; - } - if (parent !== undefined) { - workStacks.parent[stackIndex] = parent; + var savedInStrictMode = state.inStrictModeStack[state.stackIndex]; + var savedParent = state.parentStack[state.stackIndex]; + if (savedInStrictMode !== undefined) { + inStrictMode = savedInStrictMode; } - } - function completeNode() { - if (workStacks.inStrictMode[stackIndex] !== undefined) { - inStrictMode = workStacks.inStrictMode[stackIndex]; - parent = workStacks.parent[stackIndex]; + if (savedParent !== undefined) { + parent = savedParent; } - stackIndex--; + state.skip = false; + state.stackIndex--; } - /** - * If `node` is a BinaryExpression, adds it to the local work stack, otherwise recursively binds it - */ function maybeBind(node) { if (node && ts.isBinaryExpression(node) && !ts.isDestructuringAssignment(node)) { - stackIndex++; - workStacks.expr[stackIndex] = node; - workStacks.state[stackIndex] = 0 /* BindThenBindChildren */; - workStacks.inStrictMode[stackIndex] = undefined; - workStacks.parent[stackIndex] = undefined; - } - else { - bind(node); + return node; } + bind(node); } } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 201 /* PropertyAccessExpression */) { + if (node.expression.kind === 203 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -41788,7 +43251,7 @@ var ts; } function bindJSDocTypeAlias(node) { ts.setParent(node.tagName, node); - if (node.kind !== 325 /* JSDocEnumTag */ && node.fullName) { + if (node.kind !== 333 /* JSDocEnumTag */ && node.fullName) { ts.setParent(node.fullName, node); ts.setParentRecursive(node.fullName, /*incremental*/ false); } @@ -41796,7 +43259,7 @@ var ts; function bindJSDocClassTag(node) { bindEachChild(node); var host = ts.getHostSignatureFromJSDoc(node); - if (host && host.kind !== 165 /* MethodDeclaration */) { + if (host && host.kind !== 167 /* MethodDeclaration */) { addDeclarationToSymbol(host.symbol, host, 32 /* Class */); } } @@ -41809,15 +43272,15 @@ var ts; } function bindOptionalChainRest(node) { switch (node.kind) { - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: bind(node.questionDotToken); bind(node.name); break; - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: bind(node.questionDotToken); bind(node.argumentExpression); break; - case 203 /* CallExpression */: + case 205 /* CallExpression */: bind(node.questionDotToken); bindEach(node.typeArguments); bindEach(node.arguments); @@ -41882,19 +43345,19 @@ 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 === 208 /* FunctionExpression */ || expr.kind === 209 /* ArrowFunction */) { + if (expr.kind === 210 /* FunctionExpression */ || expr.kind === 211 /* ArrowFunction */) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); } else { bindEachChild(node); - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { currentFlow = createFlowCall(currentFlow, node); } } } - if (node.expression.kind === 201 /* PropertyAccessExpression */) { + if (node.expression.kind === 203 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (ts.isIdentifier(propertyAccess.name) && isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node); @@ -41903,54 +43366,54 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 221 /* ClassExpression */: - case 252 /* ClassDeclaration */: - case 255 /* EnumDeclaration */: - case 200 /* ObjectLiteralExpression */: - case 177 /* TypeLiteral */: - case 312 /* JSDocTypeLiteral */: - case 281 /* JsxAttributes */: + case 223 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 257 /* EnumDeclaration */: + case 202 /* ObjectLiteralExpression */: + case 179 /* TypeLiteral */: + case 316 /* JSDocTypeLiteral */: + case 283 /* JsxAttributes */: return 1 /* IsContainer */; - case 253 /* InterfaceDeclaration */: + case 255 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 256 /* ModuleDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 190 /* MappedType */: + case 258 /* ModuleDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 192 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 297 /* SourceFile */: + case 299 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } // falls through - case 166 /* Constructor */: - case 251 /* FunctionDeclaration */: - case 164 /* MethodSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 169 /* CallSignature */: - case 313 /* JSDocSignature */: - case 308 /* JSDocFunctionType */: - case 174 /* FunctionType */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: - case 175 /* ConstructorType */: + case 168 /* Constructor */: + case 253 /* FunctionDeclaration */: + case 166 /* MethodSignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 171 /* CallSignature */: + case 317 /* JSDocSignature */: + case 311 /* JSDocFunctionType */: + case 176 /* FunctionType */: + case 172 /* ConstructSignature */: + case 173 /* IndexSignature */: + case 177 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 257 /* ModuleBlock */: + case 259 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 287 /* CatchClause */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 258 /* CaseBlock */: + case 289 /* CatchClause */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 260 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 230 /* Block */: + case 232 /* 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 @@ -41983,45 +43446,45 @@ 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 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 297 /* SourceFile */: + case 299 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 221 /* ClassExpression */: - case 252 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 254 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 177 /* TypeLiteral */: - case 312 /* JSDocTypeLiteral */: - case 200 /* ObjectLiteralExpression */: - case 253 /* InterfaceDeclaration */: - case 281 /* JsxAttributes */: + case 179 /* TypeLiteral */: + case 316 /* JSDocTypeLiteral */: + case 202 /* ObjectLiteralExpression */: + case 255 /* InterfaceDeclaration */: + case 283 /* 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 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 313 /* JSDocSignature */: - case 171 /* IndexSignature */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 308 /* JSDocFunctionType */: - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 254 /* TypeAliasDeclaration */: - case 190 /* MappedType */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 317 /* JSDocSignature */: + case 173 /* IndexSignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 311 /* JSDocFunctionType */: + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + case 256 /* TypeAliasDeclaration */: + case 192 /* 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 @@ -42068,15 +43531,13 @@ var ts; var pattern = void 0; if (node.name.kind === 10 /* StringLiteral */) { var text = node.name.text; - if (ts.hasZeroOrOneAsteriskCharacter(text)) { - pattern = ts.tryParsePattern(text); - } - else { + 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 */); - file.patternAmbientModules = ts.append(file.patternAmbientModules, pattern && { pattern: pattern, symbol: symbol }); + file.patternAmbientModules = ts.append(file.patternAmbientModules, pattern && !ts.isString(pattern) ? { pattern: pattern, symbol: symbol } : undefined); } } else { @@ -42122,7 +43583,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 === 290 /* SpreadAssignment */ || prop.name.kind !== 78 /* Identifier */) { + if (prop.kind === 292 /* SpreadAssignment */ || prop.name.kind !== 79 /* Identifier */) { continue; } var identifier = prop.name; @@ -42134,7 +43595,7 @@ var ts; // 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 === 288 /* PropertyAssignment */ || prop.kind === 289 /* ShorthandPropertyAssignment */ || prop.kind === 165 /* MethodDeclaration */ + var currentKind = prop.kind === 290 /* PropertyAssignment */ || prop.kind === 291 /* ShorthandPropertyAssignment */ || prop.kind === 167 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.escapedText); @@ -42166,10 +43627,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 297 /* SourceFile */: + case 299 /* SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -42194,9 +43655,9 @@ var ts; var saveCurrentFlow = currentFlow; for (var _i = 0, delayedTypeAliases_1 = delayedTypeAliases; _i < delayedTypeAliases_1.length; _i++) { var typeAlias = delayedTypeAliases_1[_i]; - var host = ts.getJSDocHost(typeAlias); - container = (host && ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1 /* IsContainer */); })) || file; - blockScopeContainer = (host && ts.getEnclosingBlockScopeContainer(host)) || file; + var host = typeAlias.parent.parent; + container = ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1 /* IsContainer */); }) || file; + blockScopeContainer = ts.getEnclosingBlockScopeContainer(host) || file; currentFlow = initFlowNode({ flags: 2 /* Start */ }); parent = typeAlias; bind(typeAlias.typeExpression); @@ -42237,7 +43698,7 @@ var ts; container = oldContainer; } } - else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 78 /* Identifier */) { + else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 79 /* Identifier */) { parent = typeAlias.parent; bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); } @@ -42262,11 +43723,11 @@ var ts; !ts.isIdentifierName(node)) { // strict mode identifiers if (inStrictMode && - node.originalKeywordKind >= 116 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 124 /* LastFutureReservedWord */) { + node.originalKeywordKind >= 117 /* FirstFutureReservedWord */ && + node.originalKeywordKind <= 125 /* LastFutureReservedWord */) { file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); } - else if (node.originalKeywordKind === 130 /* AwaitKeyword */) { + else if (node.originalKeywordKind === 131 /* 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))); } @@ -42274,7 +43735,7 @@ var ts; 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 === 124 /* YieldKeyword */ && node.flags & 8192 /* YieldContext */) { + else if (node.originalKeywordKind === 125 /* YieldKeyword */ && node.flags & 8192 /* YieldContext */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node))); } } @@ -42316,7 +43777,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 78 /* Identifier */) { + if (inStrictMode && node.expression.kind === 79 /* 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); @@ -42327,7 +43788,7 @@ var ts; return ts.isIdentifier(node) && (node.escapedText === "eval" || node.escapedText === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 78 /* Identifier */) { + if (name && name.kind === 79 /* 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 @@ -42368,8 +43829,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 297 /* SourceFile */ && - blockScopeContainer.kind !== 256 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 299 /* SourceFile */ && + blockScopeContainer.kind !== 258 /* ModuleDeclaration */ && !ts.isFunctionLike(blockScopeContainer)) { // We check first if the name is inside class declaration or class expression; if so give explicit message // otherwise report generic error message. @@ -42464,7 +43925,7 @@ 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 > 156 /* LastToken */) { + if (node.kind > 158 /* LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -42526,7 +43987,7 @@ var ts; function bindWorker(node) { switch (node.kind) { /* Strict mode checks */ - case 78 /* Identifier */: + case 79 /* 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. @@ -42539,18 +44000,24 @@ var ts; break; } // falls through - case 107 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 289 /* ShorthandPropertyAssignment */)) { + case 108 /* ThisKeyword */: + if (currentFlow && (ts.isExpression(node) || parent.kind === 291 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkContextualIdentifier(node); - case 105 /* SuperKeyword */: + case 159 /* QualifiedName */: + if (currentFlow && ts.isPartOfTypeQuery(node)) { + node.flowNode = currentFlow; + } + break; + case 228 /* MetaProperty */: + case 106 /* SuperKeyword */: node.flowNode = currentFlow; break; - case 79 /* PrivateIdentifier */: + case 80 /* PrivateIdentifier */: return checkPrivateIdentifier(node); - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: var expr = node; if (currentFlow && isNarrowableReference(expr)) { expr.flowNode = currentFlow; @@ -42565,7 +44032,7 @@ var ts; declareSymbol(file.locals, /*parent*/ undefined, expr.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 111550 /* FunctionScopedVariableExcludes */); } break; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: var specialKind = ts.getAssignmentDeclarationKind(node); switch (specialKind) { case 1 /* ExportsProperty */: @@ -42601,78 +44068,78 @@ var ts; ts.Debug.fail("Unknown binary expression special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return checkStrictModeCatchClause(node); - case 210 /* DeleteExpression */: + case 212 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 243 /* WithStatement */: + case 245 /* WithStatement */: return checkStrictModeWithStatement(node); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return checkStrictModeLabeledStatement(node); - case 187 /* ThisType */: + case 189 /* ThisType */: seenThisKeyword = true; return; - case 172 /* TypePredicate */: + case 174 /* TypePredicate */: break; // Binding the children will handle everything - case 159 /* TypeParameter */: + case 161 /* TypeParameter */: return bindTypeParameter(node); - case 160 /* Parameter */: + case 162 /* Parameter */: return bindParameter(node); - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 198 /* BindingElement */: + case 200 /* BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: return bindPropertyWorker(node); - case 288 /* PropertyAssignment */: - case 289 /* ShorthandPropertyAssignment */: + case 290 /* PropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 291 /* EnumMember */: + case 293 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 173 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 167 /* MethodDeclaration */: + case 166 /* 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 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return bindFunctionDeclaration(node); - case 166 /* Constructor */: + case 168 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 167 /* GetAccessor */: + case 169 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 46015 /* GetAccessorExcludes */); - case 168 /* SetAccessor */: + case 170 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 78783 /* SetAccessorExcludes */); - case 174 /* FunctionType */: - case 308 /* JSDocFunctionType */: - case 313 /* JSDocSignature */: - case 175 /* ConstructorType */: + case 176 /* FunctionType */: + case 311 /* JSDocFunctionType */: + case 317 /* JSDocSignature */: + case 177 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 177 /* TypeLiteral */: - case 312 /* JSDocTypeLiteral */: - case 190 /* MappedType */: + case 179 /* TypeLiteral */: + case 316 /* JSDocTypeLiteral */: + case 192 /* MappedType */: return bindAnonymousTypeWorker(node); - case 319 /* JSDocClassTag */: + case 326 /* JSDocClassTag */: return bindJSDocClassTag(node); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return bindFunctionExpression(node); - case 203 /* CallExpression */: + case 205 /* CallExpression */: var assignmentKind = ts.getAssignmentDeclarationKind(node); switch (assignmentKind) { case 7 /* ObjectDefinePropertyValue */: @@ -42691,65 +44158,65 @@ var ts; } break; // Members of classes, interfaces, and modules - case 221 /* ClassExpression */: - case 252 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 254 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 253 /* InterfaceDeclaration */: + case 255 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 788872 /* InterfaceExcludes */); - case 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 281 /* JsxAttributes */: + case 283 /* JsxAttributes */: return bindJsxAttributes(node); - case 280 /* JsxAttribute */: + case 282 /* JsxAttribute */: return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); // Imports and exports - case 260 /* ImportEqualsDeclaration */: - case 263 /* NamespaceImport */: - case 265 /* ImportSpecifier */: - case 270 /* ExportSpecifier */: + case 262 /* ImportEqualsDeclaration */: + case 265 /* NamespaceImport */: + case 267 /* ImportSpecifier */: + case 272 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 259 /* NamespaceExportDeclaration */: + case 261 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 262 /* ImportClause */: + case 264 /* ImportClause */: return bindImportClause(node); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: return bindExportDeclaration(node); - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return bindExportAssignment(node); - case 297 /* SourceFile */: + case 299 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 230 /* Block */: + case 232 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // falls through - case 257 /* ModuleBlock */: + case 259 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 326 /* JSDocParameterTag */: - if (node.parent.kind === 313 /* JSDocSignature */) { + case 334 /* JSDocParameterTag */: + if (node.parent.kind === 317 /* JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 312 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 316 /* JSDocTypeLiteral */) { break; } // falls through - case 333 /* JSDocPropertyTag */: + case 341 /* JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 307 /* JSDocOptionalType */ ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 310 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 325 /* JSDocEnumTag */: + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + case 333 /* JSDocEnumTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -42777,8 +44244,8 @@ var ts; } function bindExportAssignment(node) { if (!container.symbol || !container.symbol.exports) { - // Export assignment in some sort of block construct - bindAnonymousDeclaration(node, 2097152 /* Alias */, getDeclarationName(node)); + // Incorrect export assignment in some sort of block construct + bindAnonymousDeclaration(node, 111551 /* Value */, getDeclarationName(node)); } else { var flags = ts.exportAssignmentIsAlias(node) @@ -42912,11 +44379,11 @@ var ts; } var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 210 /* 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 === 62 /* EqualsToken */) { + if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 63 /* EqualsToken */) { var l = thisContainer.parent.left; if (ts.isBindableStaticAccessExpression(l) && ts.isPrototypeAccess(l.expression)) { constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer); @@ -42935,11 +44402,11 @@ var ts; addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* Class */); } break; - case 166 /* Constructor */: - case 163 /* PropertyDeclaration */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 168 /* Constructor */: + case 165 /* PropertyDeclaration */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: // this.foo assignment in a JavaScript class // Bind this property to the containing class var containingClass = thisContainer.parent; @@ -42951,7 +44418,7 @@ var ts; declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* None */, /*isReplaceableByMethod*/ true); } break; - case 297 /* SourceFile */: + case 299 /* 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; @@ -42977,10 +44444,10 @@ var ts; } } function bindSpecialPropertyDeclaration(node) { - if (node.expression.kind === 107 /* ThisKeyword */) { + if (node.expression.kind === 108 /* ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 297 /* SourceFile */) { + else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 299 /* SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -43020,7 +44487,7 @@ var ts; } function bindObjectDefinePropertyAssignment(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); - var isToplevel = node.parent.parent.kind === 297 /* SourceFile */; + var isToplevel = node.parent.parent.kind === 299 /* SourceFile */; namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ false); } @@ -43129,8 +44596,8 @@ var ts; } function isTopLevelNamespaceAssignment(propertyAccess) { return ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 297 /* SourceFile */ - : propertyAccess.parent.parent.kind === 297 /* SourceFile */; + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 299 /* SourceFile */ + : propertyAccess.parent.parent.kind === 299 /* SourceFile */; } function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) { var namespaceSymbol = lookupSymbolForPropertyAccess(name, container) || lookupSymbolForPropertyAccess(name, blockScopeContainer); @@ -43209,7 +44676,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 252 /* ClassDeclaration */) { + if (node.kind === 254 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899503 /* ClassExcludes */); } else { @@ -43251,7 +44718,7 @@ var ts; checkStrictModeEvalOrArguments(node, node.name); } if (!ts.isBindingPattern(node.name)) { - if (ts.isInJSFile(node) && ts.isRequireVariableDeclaration(node, /*requireStringLiteralLikeArgument*/ true) && !ts.getJSDocTypeTag(node)) { + if (ts.isInJSFile(node) && ts.isRequireVariableDeclaration(node) && !ts.getJSDocTypeTag(node)) { declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); } else if (ts.isBlockOrCatchScoped(node)) { @@ -43275,7 +44742,7 @@ var ts; } } function bindParameter(node) { - if (node.kind === 326 /* JSDocParameterTag */ && container.kind !== 313 /* JSDocSignature */) { + if (node.kind === 334 /* JSDocParameterTag */ && container.kind !== 317 /* JSDocSignature */) { return; } if (inStrictMode && !(node.flags & 8388608 /* Ambient */)) { @@ -43352,7 +44819,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } } - else if (node.parent.kind === 185 /* InferType */) { + else if (node.parent.kind === 187 /* InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { @@ -43371,7 +44838,7 @@ var ts; // reachability checks function shouldReportErrorOnModuleDeclaration(node) { var instanceState = getModuleInstanceState(node); - return instanceState === 1 /* Instantiated */ || (instanceState === 2 /* ConstEnumOnly */ && !!options.preserveConstEnums); + return instanceState === 1 /* Instantiated */ || (instanceState === 2 /* ConstEnumOnly */ && ts.shouldPreserveConstEnums(options)); } function checkUnreachable(node) { if (!(currentFlow.flags & 1 /* Unreachable */)) { @@ -43380,11 +44847,11 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 231 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 233 /* EmptyStatement */) || // report error on class declarations - node.kind === 252 /* ClassDeclaration */ || + node.kind === 254 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 256 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); + (node.kind === 258 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -43428,12 +44895,12 @@ var ts; } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: return true; - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return getModuleInstanceState(s) !== 1 /* Instantiated */; - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: return ts.hasSyntacticModifier(s, 2048 /* Const */); default: return false; @@ -43633,7 +45100,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 === 176 /* TypeQuery */) { + if (d.type && d.type.kind === 178 /* TypeQuery */) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); @@ -43803,15 +45270,6 @@ var ts; CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions"; CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp"; })(CheckMode || (CheckMode = {})); - var AccessFlags; - (function (AccessFlags) { - AccessFlags[AccessFlags["None"] = 0] = "None"; - AccessFlags[AccessFlags["NoIndexSignatures"] = 1] = "NoIndexSignatures"; - AccessFlags[AccessFlags["Writing"] = 2] = "Writing"; - AccessFlags[AccessFlags["CacheSymbol"] = 4] = "CacheSymbol"; - AccessFlags[AccessFlags["NoTupleBoundsCheck"] = 8] = "NoTupleBoundsCheck"; - AccessFlags[AccessFlags["ExpressionPosition"] = 16] = "ExpressionPosition"; - })(AccessFlags || (AccessFlags = {})); var SignatureCheckMode; (function (SignatureCheckMode) { SignatureCheckMode[SignatureCheckMode["BivariantCallback"] = 1] = "BivariantCallback"; @@ -43860,6 +45318,7 @@ var ts; DeclarationMeaning[DeclarationMeaning["SetAccessor"] = 2] = "SetAccessor"; DeclarationMeaning[DeclarationMeaning["PropertyAssignment"] = 4] = "PropertyAssignment"; DeclarationMeaning[DeclarationMeaning["Method"] = 8] = "Method"; + DeclarationMeaning[DeclarationMeaning["PrivateStatic"] = 16] = "PrivateStatic"; DeclarationMeaning[DeclarationMeaning["GetOrSetAccessor"] = 3] = "GetOrSetAccessor"; DeclarationMeaning[DeclarationMeaning["PropertyAssignmentOrMethod"] = 12] = "PropertyAssignmentOrMethod"; })(DeclarationMeaning || (DeclarationMeaning = {})); @@ -43951,21 +45410,24 @@ var ts; var instantiationCount = 0; var instantiationDepth = 0; var currentNode; - var typeCatalog = []; // NB: id is index + 1 var emptySymbols = ts.createSymbolTable(); var arrayVariances = [1 /* Covariant */]; var compilerOptions = host.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var moduleKind = ts.getEmitModuleKind(compilerOptions); + var useDefineForClassFields = ts.getUseDefineForClassFields(compilerOptions); var allowSyntheticDefaultImports = ts.getAllowSyntheticDefaultImports(compilerOptions); var strictNullChecks = ts.getStrictOptionValue(compilerOptions, "strictNullChecks"); var strictFunctionTypes = ts.getStrictOptionValue(compilerOptions, "strictFunctionTypes"); var strictBindCallApply = ts.getStrictOptionValue(compilerOptions, "strictBindCallApply"); var strictPropertyInitialization = ts.getStrictOptionValue(compilerOptions, "strictPropertyInitialization"); + var strictOptionalProperties = ts.getStrictOptionValue(compilerOptions, "strictOptionalProperties"); var noImplicitAny = ts.getStrictOptionValue(compilerOptions, "noImplicitAny"); var noImplicitThis = ts.getStrictOptionValue(compilerOptions, "noImplicitThis"); + var useUnknownInCatchVariables = ts.getStrictOptionValue(compilerOptions, "useUnknownInCatchVariables"); var keyofStringsOnly = !!compilerOptions.keyofStringsOnly; - var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 32768 /* FreshLiteral */; + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 16384 /* FreshLiteral */; + var checkBinaryExpression = createCheckBinaryExpression(); var emitResolver = createResolver(); var nodeBuilder = createNodeBuilder(); var globals = ts.createSymbolTable(); @@ -43988,7 +45450,6 @@ var ts; getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); }, getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); }, getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount") + symbolCount; }, - getTypeCatalog: function () { return typeCatalog; }, getTypeCount: function () { return typeCount; }, getInstantiationCount: function () { return totalInstantiationCount; }, getRelationCacheSizes: function () { return ({ @@ -44152,6 +45613,7 @@ var ts; return node && getContextualTypeForJsxAttribute(node); }, isContextSensitive: isContextSensitive, + getTypeOfPropertyOfContextualType: getTypeOfPropertyOfContextualType, getFullyQualifiedName: getFullyQualifiedName, getResolvedSignature: function (node, candidatesOutArray, argumentCount) { return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 0 /* Normal */); @@ -44195,6 +45657,7 @@ var ts; }, tryGetMemberInModuleExports: function (name, symbol) { return tryGetMemberInModuleExports(ts.escapeLeadingUnderscores(name), symbol); }, tryGetMemberInModuleExportsAndProperties: function (name, symbol) { return tryGetMemberInModuleExportsAndProperties(ts.escapeLeadingUnderscores(name), symbol); }, + tryFindAmbientModule: function (moduleName) { return tryFindAmbientModule(moduleName, /*withAugmentations*/ true); }, tryFindAmbientModuleWithoutAugmentations: function (moduleName) { // we deliberately exclude augmentations // since we are only interested in declarations of the module itself @@ -44313,6 +45776,7 @@ var ts; var templateLiteralTypes = new ts.Map(); var stringMappingTypes = new ts.Map(); var substitutionTypes = new ts.Map(); + var subtypeReductionCache = new ts.Map(); var evolvingArrayTypes = []; var undefinedProperties = new ts.Map(); var unknownSymbol = createSymbol(4 /* Property */, "unknown"); @@ -44321,14 +45785,15 @@ var ts; var autoType = createIntrinsicType(1 /* Any */, "any"); var wildcardType = createIntrinsicType(1 /* Any */, "any"); var errorType = createIntrinsicType(1 /* Any */, "error"); - var nonInferrableAnyType = createIntrinsicType(1 /* Any */, "any", 524288 /* ContainsWideningType */); + var nonInferrableAnyType = createIntrinsicType(1 /* Any */, "any", 131072 /* ContainsWideningType */); var intrinsicMarkerType = createIntrinsicType(1 /* Any */, "intrinsic"); var unknownType = createIntrinsicType(2 /* Unknown */, "unknown"); var undefinedType = createIntrinsicType(32768 /* Undefined */, "undefined"); - var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* Undefined */, "undefined", 524288 /* ContainsWideningType */); + var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* Undefined */, "undefined", 131072 /* ContainsWideningType */); var optionalType = createIntrinsicType(32768 /* Undefined */, "undefined"); + var missingType = strictOptionalProperties ? createIntrinsicType(32768 /* Undefined */, "undefined") : undefinedType; var nullType = createIntrinsicType(65536 /* Null */, "null"); - var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* Null */, "null", 524288 /* ContainsWideningType */); + var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* Null */, "null", 131072 /* ContainsWideningType */); var stringType = createIntrinsicType(4 /* String */, "string"); var numberType = createIntrinsicType(8 /* Number */, "number"); var bigintType = createIntrinsicType(64 /* BigInt */, "bigint"); @@ -44354,7 +45819,7 @@ var ts; var voidType = createIntrinsicType(16384 /* Void */, "void"); var neverType = createIntrinsicType(131072 /* Never */, "never"); var silentNeverType = createIntrinsicType(131072 /* Never */, "never"); - var nonInferrableType = createIntrinsicType(131072 /* Never */, "never", 2097152 /* NonInferrableType */); + var nonInferrableType = createIntrinsicType(131072 /* Never */, "never", 524288 /* NonInferrableType */); var implicitNeverType = createIntrinsicType(131072 /* Never */, "never"); var unreachableNeverType = createIntrinsicType(131072 /* Never */, "never"); var nonPrimitiveType = createIntrinsicType(67108864 /* NonPrimitive */, "object"); @@ -44366,7 +45831,7 @@ var ts; var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? wildcardType : t; }); var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var emptyJsxObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); - emptyJsxObjectType.objectFlags |= 4096 /* JsxAttributes */; + emptyJsxObjectType.objectFlags |= 2048 /* JsxAttributes */; var emptyTypeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); emptyTypeLiteralSymbol.members = ts.createSymbolTable(); var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); @@ -44375,7 +45840,7 @@ var ts; var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); // The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated // in getPropagatingFlagsOfTypes, and it is checked in inferFromTypes. - anyFunctionType.objectFlags |= 2097152 /* NonInferrableType */; + anyFunctionType.objectFlags |= 524288 /* NonInferrableType */; var noConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var circularConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var resolvingDefaultType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); @@ -44455,6 +45920,7 @@ var ts; // This allows users to just specify library files they want to used through --lib // and they will not get an error from not having unrelated library files var deferredGlobalESSymbolConstructorSymbol; + var deferredGlobalESSymbolConstructorTypeSymbol; var deferredGlobalESSymbolType; var deferredGlobalTypedPropertyDescriptorType; var deferredGlobalPromiseType; @@ -44506,7 +45972,7 @@ var ts; var flowNodePostSuper = []; var potentialThisCollisions = []; var potentialNewTargetCollisions = []; - var potentialWeakMapCollisions = []; + var potentialWeakMapSetCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); var suggestionDiagnostics = ts.createDiagnosticCollection(); @@ -44653,9 +46119,28 @@ var ts; } return diagnostic; } + function addDeprecatedSuggestionWorker(declarations, diagnostic) { + var deprecatedTag = Array.isArray(declarations) ? ts.forEach(declarations, ts.getJSDocDeprecatedTag) : ts.getJSDocDeprecatedTag(declarations); + if (deprecatedTag) { + ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(deprecatedTag, ts.Diagnostics.The_declaration_was_marked_as_deprecated_here)); + } + // We call `addRelatedInfo()` before adding the diagnostic to prevent duplicates. + suggestionDiagnostics.add(diagnostic); + return diagnostic; + } + function addDeprecatedSuggestion(location, declarations, deprecatedEntity) { + var diagnostic = ts.createDiagnosticForNode(location, ts.Diagnostics._0_is_deprecated, deprecatedEntity); + return addDeprecatedSuggestionWorker(declarations, diagnostic); + } + function addDeprecatedSuggestionWithSignature(location, declaration, deprecatedEntity, signatureString) { + var diagnostic = deprecatedEntity + ? ts.createDiagnosticForNode(location, ts.Diagnostics.The_signature_0_of_1_is_deprecated, signatureString, deprecatedEntity) + : ts.createDiagnosticForNode(location, ts.Diagnostics._0_is_deprecated, signatureString); + return addDeprecatedSuggestionWorker(declaration, diagnostic); + } function createSymbol(flags, name, checkFlags) { symbolCount++; - var symbol = (new Symbol(flags | 33554432 /* Transient */, name)); + var symbol = new Symbol(flags | 33554432 /* Transient */, name); symbol.checkFlags = checkFlags || 0; return symbol; } @@ -44766,7 +46251,7 @@ var ts; // as we will already report a "Declaration name conflicts..." error, and this error // won't make much sense. if (target !== globalThisSymbol) { - error(ts.getNameOfDeclaration(source.declarations[0]), ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); + error(source.declarations && ts.getNameOfDeclaration(source.declarations[0]), ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); } } else { // error @@ -44800,9 +46285,11 @@ var ts; } return target; function addDuplicateLocations(locs, symbol) { - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - ts.pushIfUnique(locs, decl); + if (symbol.declarations) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + ts.pushIfUnique(locs, decl); + } } } } @@ -44848,9 +46335,9 @@ var ts; }); } function mergeModuleAugmentation(moduleName) { - var _a, _b; + var _a, _b, _c; var moduleAugmentation = moduleName.parent; - if (moduleAugmentation.symbol.declarations[0] !== moduleAugmentation) { + if (((_a = moduleAugmentation.symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]) !== moduleAugmentation) { // this is a combined symbol for multiple augmentations within the same file. // its symbol already has accumulated information for all declarations // so we need to add it just once - do the work only for first declaration @@ -44887,11 +46374,11 @@ var ts; patternAmbientModuleAugmentations.set(moduleName.text, merged); } else { - if (((_a = mainModule_1.exports) === null || _a === void 0 ? void 0 : _a.get("__export" /* ExportStar */)) && ((_b = moduleAugmentation.symbol.exports) === null || _b === void 0 ? void 0 : _b.size)) { + 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)) { // 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 */); - for (var _i = 0, _c = ts.arrayFrom(moduleAugmentation.symbol.exports.entries()); _i < _c.length; _i++) { - var _d = _c[_i], key = _d[0], value = _d[1]; + 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)) { mergeSymbol(resolvedExports.get(key), value); } @@ -44932,7 +46419,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = new NodeLinks()); } function isGlobalSourceFile(node) { - return node.kind === 297 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 299 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -44991,17 +46478,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 === 198 /* BindingElement */) { + if (declaration.kind === 200 /* 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, 198 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 200 /* 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, 249 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 251 /* VariableDeclaration */), usage); } - else if (declaration.kind === 249 /* VariableDeclaration */) { + else if (declaration.kind === 251 /* VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -45015,7 +46502,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 !(compilerOptions.target === 99 /* ESNext */ && !!compilerOptions.useDefineForClassFields + return !(compilerOptions.target === 99 /* ESNext */ && useDefineForClassFields && ts.getContainingClass(declaration) === ts.getContainingClass(usage) && isUsedInFunctionOrInstanceProperty(usage, declaration)); } @@ -45031,19 +46518,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 === 270 /* ExportSpecifier */ || (usage.parent.kind === 266 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 272 /* ExportSpecifier */ || (usage.parent.kind === 268 /* 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 === 266 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 268 /* ExportAssignment */ && usage.isExportEquals) { return true; } if (!!(usage.flags & 4194304 /* JSDoc */) || isInTypeQuery(usage) || usageInTypeDeclaration()) { return true; } if (isUsedInFunctionOrInstanceProperty(usage, declaration)) { - if (compilerOptions.target === 99 /* ESNext */ && !!compilerOptions.useDefineForClassFields + if (compilerOptions.target === 99 /* ESNext */ && useDefineForClassFields && ts.getContainingClass(declaration) && (ts.isPropertyDeclaration(declaration) || ts.isParameterPropertyDeclaration(declaration, declaration.parent))) { return !isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, /*stopAtAnyPropertyDeclaration*/ true); @@ -45058,9 +46545,9 @@ var ts; } function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { switch (declaration.parent.parent.kind) { - case 232 /* VariableStatement */: - case 237 /* ForStatement */: - case 239 /* ForOfStatement */: + case 234 /* VariableStatement */: + case 239 /* ForStatement */: + case 241 /* 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)) { @@ -45081,16 +46568,16 @@ var ts; return true; } var initializerOfProperty = current.parent && - current.parent.kind === 163 /* PropertyDeclaration */ && + current.parent.kind === 165 /* PropertyDeclaration */ && current.parent.initializer === current; if (initializerOfProperty) { if (ts.hasSyntacticModifier(current.parent, 32 /* Static */)) { - if (declaration.kind === 165 /* MethodDeclaration */) { + if (declaration.kind === 167 /* MethodDeclaration */) { return true; } } else { - var isDeclarationInstanceProperty = declaration.kind === 163 /* PropertyDeclaration */ && !ts.hasSyntacticModifier(declaration, 32 /* Static */); + var isDeclarationInstanceProperty = declaration.kind === 165 /* PropertyDeclaration */ && !ts.hasSyntacticModifier(declaration, 32 /* Static */); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -45112,19 +46599,19 @@ var ts; return "quit"; } switch (node.kind) { - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return true; - case 163 /* PropertyDeclaration */: + case 165 /* 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 230 /* Block */: + case 232 /* Block */: switch (node.parent.kind) { - case 167 /* GetAccessor */: - case 165 /* MethodDeclaration */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 167 /* MethodDeclaration */: + case 170 /* SetAccessor */: return true; default: return false; @@ -45139,7 +46626,11 @@ var ts; function useOuterVariableScopeInParameter(result, location, lastLocation) { var target = ts.getEmitScriptTarget(compilerOptions); var functionLocation = location; - if (ts.isParameter(lastLocation) && functionLocation.body && result.valueDeclaration.pos >= functionLocation.body.pos && result.valueDeclaration.end <= functionLocation.body.end) { + if (ts.isParameter(lastLocation) + && functionLocation.body + && result.valueDeclaration + && result.valueDeclaration.pos >= functionLocation.body.pos + && result.valueDeclaration.end <= functionLocation.body.end) { // check for several cases where we introduce temporaries that require moving the name/initializer of the parameter to the body // - static field in a class expression // - optional chaining pre-es2020 @@ -45160,21 +46651,21 @@ var ts; } function requiresScopeChangeWorker(node) { switch (node.kind) { - case 209 /* ArrowFunction */: - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: - case 166 /* Constructor */: + case 211 /* ArrowFunction */: + case 210 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 168 /* Constructor */: // do not descend into these return false; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 288 /* PropertyAssignment */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 290 /* PropertyAssignment */: return requiresScopeChangeWorker(node.name); - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: // static properties in classes introduce temporary variables if (ts.hasStaticModifier(node)) { - return target < 99 /* ESNext */ || !compilerOptions.useDefineForClassFields; + return target < 99 /* ESNext */ || !useDefineForClassFields; } return requiresScopeChangeWorker(node.name); default: @@ -45203,6 +46694,7 @@ var ts; return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSymbol, suggestedNameNotFoundMessage); } function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, lookup, suggestedNameNotFoundMessage) { + var _a; var originalLocation = location; // needed for did-you-mean error reporting, which gathers candidates starting from the original location var result; var lastLocation; @@ -45225,12 +46717,12 @@ 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 !== 311 /* JSDocComment */) { + if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 314 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || - lastLocation.kind === 160 /* Parameter */ || - lastLocation.kind === 159 /* TypeParameter */ + lastLocation.kind === 162 /* Parameter */ || + lastLocation.kind === 161 /* TypeParameter */ // local types not visible outside the function body : false; } @@ -45245,13 +46737,13 @@ var ts; // however it is detected separately when checking initializers of parameters // to make sure that they reference no variables declared after them. useResult = - lastLocation.kind === 160 /* Parameter */ || + lastLocation.kind === 162 /* Parameter */ || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } } - else if (location.kind === 184 /* ConditionalType */) { + else if (location.kind === 186 /* 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; @@ -45266,14 +46758,14 @@ var ts; } withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation); switch (location.kind) { - case 297 /* SourceFile */: + case 299 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports || emptySymbols; - if (location.kind === 297 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 8388608 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) { + if (location.kind === 299 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 8388608 /* 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 */)) { @@ -45297,13 +46789,13 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 /* Alias */ && - (ts.getDeclarationOfKind(moduleExport, 270 /* ExportSpecifier */) || ts.getDeclarationOfKind(moduleExport, 269 /* NamespaceExport */))) { + (ts.getDeclarationOfKind(moduleExport, 272 /* ExportSpecifier */) || ts.getDeclarationOfKind(moduleExport, 271 /* 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 (ts.isSourceFile(location) && location.commonJsModuleIndicator && !result.declarations.some(ts.isJSDocTypeAlias)) { + if (ts.isSourceFile(location) && location.commonJsModuleIndicator && !((_a = result.declarations) === null || _a === void 0 ? void 0 : _a.some(ts.isJSDocTypeAlias))) { result = undefined; } else { @@ -45311,12 +46803,12 @@ var ts; } } break; - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 163 /* PropertyDeclaration */: + case 165 /* 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 @@ -45333,9 +46825,9 @@ var ts; } } break; - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* 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! @@ -45354,7 +46846,7 @@ var ts; } break loop; } - if (location.kind === 221 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 223 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -45362,9 +46854,9 @@ var ts; } } break; - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: // The type parameters of a class are not in scope in the base class expression. - if (lastLocation === location.expression && location.parent.token === 93 /* ExtendsKeyword */) { + if (lastLocation === location.expression && location.parent.token === 94 /* ExtendsKeyword */) { var container = location.parent.parent; if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968 /* Type */))) { if (nameNotFoundMessage) { @@ -45382,9 +46874,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 253 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 255 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -45392,24 +46884,24 @@ var ts; } } break; - case 209 /* ArrowFunction */: + case 211 /* 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 (compilerOptions.target >= 2 /* ES2015 */) { break; } // falls through - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 251 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 253 /* FunctionDeclaration */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -45422,7 +46914,7 @@ var ts; } } break; - case 161 /* Decorator */: + case 163 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -45431,7 +46923,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 === 160 /* Parameter */) { + if (location.parent && location.parent.kind === 162 /* Parameter */) { location = location.parent; } // @@ -45446,20 +46938,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 === 252 /* ClassDeclaration */)) { + if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 254 /* ClassDeclaration */)) { location = location.parent; } break; - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 325 /* JSDocEnumTag */: + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + case 333 /* 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 160 /* Parameter */: + case 162 /* Parameter */: if (lastLocation && (lastLocation === location.initializer || lastLocation === location.name && ts.isBindingPattern(lastLocation))) { if (!associatedDeclarationForContainingInitializerOrBindingName) { @@ -45467,7 +46959,7 @@ var ts; } } break; - case 198 /* BindingElement */: + case 200 /* BindingElement */: if (lastLocation && (lastLocation === location.initializer || lastLocation === location.name && ts.isBindingPattern(lastLocation))) { if (ts.isParameterDeclaration(location) && !associatedDeclarationForContainingInitializerOrBindingName) { @@ -45475,7 +46967,7 @@ var ts; } } break; - case 185 /* InferType */: + case 187 /* InferType */: if (meaning & 262144 /* TypeParameter */) { var parameterName = location.typeParameter.name; if (parameterName && name === parameterName.escapedText) { @@ -45499,7 +46991,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 297 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 299 /* SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -45528,6 +47020,10 @@ var ts; var suggestion = void 0; if (suggestedNameNotFoundMessage && suggestionCount < maximumSuggestionCount) { suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning); + var isGlobalScopeAugmentationDeclaration = suggestion && suggestion.valueDeclaration && ts.isAmbientModule(suggestion.valueDeclaration) && ts.isGlobalScopeAugmentation(suggestion.valueDeclaration); + if (isGlobalScopeAugmentationDeclaration) { + suggestion = undefined; + } if (suggestion) { var suggestionName = symbolToString(suggestion); var diagnostic = error(errorLocation, suggestedNameNotFoundMessage, diagnosticName(nameArg), suggestionName); @@ -45554,7 +47050,7 @@ var ts; } // Perform extra checks only if error reporting was requested if (nameNotFoundMessage) { - if (propertyWithInvalidInitializer && !(compilerOptions.target === 99 /* ESNext */ && compilerOptions.useDefineForClassFields)) { + if (propertyWithInvalidInitializer && !(compilerOptions.target === 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. @@ -45624,10 +47120,10 @@ var ts; } } function getIsDeferredContext(location, lastLocation) { - if (location.kind !== 209 /* ArrowFunction */ && location.kind !== 208 /* FunctionExpression */) { + if (location.kind !== 211 /* ArrowFunction */ && location.kind !== 210 /* 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 === 163 /* PropertyDeclaration */ && !ts.hasSyntacticModifier(location, 32 /* Static */))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred + (location.kind === 165 /* PropertyDeclaration */ && !ts.hasSyntacticModifier(location, 32 /* Static */))) && (!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; @@ -45640,12 +47136,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 256 /* ModuleDeclaration */: // For `namespace N { N; }` + case 253 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 257 /* EnumDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 258 /* ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -45655,12 +47151,14 @@ var ts; return ts.isString(nameArg) ? ts.unescapeLeadingUnderscores(nameArg) : ts.declarationNameToString(nameArg); } function isTypeParameterSymbolDeclaredInContainer(symbol, container) { - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - if (decl.kind === 159 /* 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)); // TODO: GH#18217 + if (symbol.declarations) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + if (decl.kind === 161 /* 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)); // TODO: GH#18217 + } } } } @@ -45712,10 +47210,10 @@ var ts; */ function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 78 /* Identifier */: - case 201 /* PropertyAccessExpression */: + case 79 /* Identifier */: + case 203 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -45759,7 +47257,7 @@ 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 === 270 /* ExportSpecifier */) { + if (isPrimitiveTypeName(name) && errorLocation.parent.kind === 272 /* ExportSpecifier */) { error(errorLocation, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, name); return true; } @@ -45828,13 +47326,14 @@ var ts; return false; } 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 */) { // constructor functions aren't block scoped return; } // Block-scoped variables cannot be used before their definition - var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 255 /* 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 === 257 /* EnumDeclaration */); }); if (declaration === undefined) return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration"); if (!(declaration.flags & 8388608 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { @@ -45851,7 +47350,7 @@ var ts; } else { ts.Debug.assert(!!(result.flags & 128 /* ConstEnum */)); - if (compilerOptions.preserveConstEnums) { + if (ts.shouldPreserveConstEnums(compilerOptions)) { diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName); } } @@ -45869,20 +47368,20 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return node; - case 262 /* ImportClause */: + case 264 /* ImportClause */: return node.parent; - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: return node.parent.parent; - case 265 /* ImportSpecifier */: + case 267 /* ImportSpecifier */: return node.parent.parent.parent; default: return undefined; } } function getDeclarationOfAliasSymbol(symbol) { - return ts.find(symbol.declarations, isAliasSymbolDeclaration); + return symbol.declarations && ts.findLast(symbol.declarations, isAliasSymbolDeclaration); } /** * An alias symbol is created by one of the following declarations: @@ -45897,25 +47396,26 @@ var ts; * module.exports = * {} * {name: } + * const { x } = require ... */ function isAliasSymbolDeclaration(node) { - return node.kind === 260 /* ImportEqualsDeclaration */ - || node.kind === 259 /* NamespaceExportDeclaration */ - || node.kind === 262 /* ImportClause */ && !!node.name - || node.kind === 263 /* NamespaceImport */ - || node.kind === 269 /* NamespaceExport */ - || node.kind === 265 /* ImportSpecifier */ - || node.kind === 270 /* ExportSpecifier */ - || node.kind === 266 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) + return node.kind === 262 /* ImportEqualsDeclaration */ + || node.kind === 261 /* NamespaceExportDeclaration */ + || node.kind === 264 /* ImportClause */ && !!node.name + || node.kind === 265 /* NamespaceImport */ + || node.kind === 271 /* NamespaceExport */ + || node.kind === 267 /* ImportSpecifier */ + || node.kind === 272 /* ExportSpecifier */ + || node.kind === 268 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) || ts.isBinaryExpression(node) && ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && ts.exportAssignmentIsAlias(node) || ts.isAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node - && node.parent.operatorToken.kind === 62 /* EqualsToken */ + && node.parent.operatorToken.kind === 63 /* EqualsToken */ && isAliasableOrJsExpression(node.parent.right) - || node.kind === 289 /* ShorthandPropertyAssignment */ - || node.kind === 288 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer) - || ts.isRequireVariableDeclaration(node, /*requireStringLiteralLikeArgument*/ true); + || node.kind === 291 /* ShorthandPropertyAssignment */ + || node.kind === 290 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer) + || ts.isRequireVariableDeclaration(node); } function isAliasableOrJsExpression(e) { return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e); @@ -45928,7 +47428,7 @@ var ts; ? resolveSymbol(getPropertyOfType(resolveExternalModuleTypeByLiteral(name), commonJSPropertyAccess.name.escapedText)) : undefined; } - if (ts.isVariableDeclaration(node) || node.moduleReference.kind === 272 /* ExternalModuleReference */) { + if (ts.isVariableDeclaration(node) || node.moduleReference.kind === 274 /* ExternalModuleReference */) { var immediate = resolveExternalModuleName(node, ts.getExternalModuleRequireArgument(node) || ts.getExternalModuleImportEqualsDeclarationExpression(node)); var resolved_4 = resolveExternalModuleSymbol(immediate); markSymbolOfAliasDeclarationIfTypeOnly(node, immediate, resolved_4, /*overwriteEmpty*/ false); @@ -45995,6 +47495,7 @@ var ts; return !file.externalModuleIndicator && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), /*sourceNode*/ undefined, dontResolveAlias); } function getTargetOfImportClause(node, dontResolveAlias) { + var _a; var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier); if (moduleSymbol) { var exportDefaultSymbol = void 0; @@ -46004,7 +47505,7 @@ var ts; else { exportDefaultSymbol = resolveExportByName(moduleSymbol, "default" /* Default */, node, dontResolveAlias); } - var file = ts.find(moduleSymbol.declarations, ts.isSourceFile); + var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); var hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias); if (!exportDefaultSymbol && !hasSyntheticDefault) { if (hasExportAssignmentSymbol(moduleSymbol)) { @@ -46012,7 +47513,9 @@ var ts; var exportEqualsSymbol = moduleSymbol.exports.get("export=" /* 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); - ts.addRelatedInfo(err, ts.createDiagnosticForNode(exportAssignment, ts.Diagnostics.This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag, compilerOptionName)); + if (exportAssignment) { + ts.addRelatedInfo(err, ts.createDiagnosticForNode(exportAssignment, ts.Diagnostics.This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag, compilerOptionName)); + } } else { reportNonDefaultExport(moduleSymbol, node); @@ -46029,7 +47532,7 @@ var ts; } } function reportNonDefaultExport(moduleSymbol, node) { - var _a, _b; + var _a, _b, _c; if ((_a = moduleSymbol.exports) === null || _a === void 0 ? void 0 : _a.has(node.symbol.escapedName)) { error(node.name, ts.Diagnostics.Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead, symbolToString(moduleSymbol), symbolToString(node.symbol)); } @@ -46037,7 +47540,7 @@ var ts; 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 */); if (exportStar) { - var defaultExport = ts.find(exportStar.declarations, function (decl) { + 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 */))); @@ -46115,7 +47618,7 @@ var ts; } } function getExternalModuleMember(node, specifier, dontResolveAlias) { - var _a; + var _a, _b; if (dontResolveAlias === void 0) { dontResolveAlias = false; } var moduleSpecifier = ts.getExternalModuleRequireArgument(node) || node.moduleSpecifier; var moduleSymbol = resolveExternalModuleName(node, moduleSpecifier); // TODO: GH#18217 @@ -46124,7 +47627,7 @@ var ts; return undefined; } var suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || compilerOptions.esModuleInterop); - var targetSymbol = resolveESModuleSymbol(moduleSymbol, moduleSpecifier, dontResolveAlias, suppressInteropError); + var targetSymbol = resolveESModuleSymbol(moduleSymbol, moduleSpecifier, /*dontResolveAlias*/ false, suppressInteropError); if (targetSymbol) { if (name.escapedText) { if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { @@ -46142,7 +47645,7 @@ var ts; symbolFromVariable = resolveSymbol(symbolFromVariable, dontResolveAlias); var symbolFromModule = getExportOfModule(targetSymbol, name, specifier, dontResolveAlias); if (symbolFromModule === undefined && name.escapedText === "default" /* Default */) { - var file = ts.find(moduleSymbol.declarations, ts.isSourceFile); + var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); if (canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias)) { symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias); } @@ -46162,7 +47665,7 @@ var ts; } } else { - if ((_a = moduleSymbol.exports) === null || _a === void 0 ? void 0 : _a.has("default" /* Default */)) { + if ((_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* 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 { @@ -46175,8 +47678,8 @@ var ts; } } function reportNonExportedMember(node, name, declarationName, moduleSymbol, moduleName) { - var _a; - var localSymbol = (_a = moduleSymbol.valueDeclaration.locals) === null || _a === void 0 ? void 0 : _a.get(name.escapedText); + var _a, _b; + 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 */); @@ -46188,9 +47691,11 @@ var ts; var exportedSymbol = exports ? ts.find(symbolsToArray(exports), function (symbol) { return !!getSymbolIfSameReference(symbol, localSymbol); }) : undefined; var diagnostic = exportedSymbol ? error(name, ts.Diagnostics.Module_0_declares_1_locally_but_it_is_exported_as_2, moduleName, declarationName, symbolToString(exportedSymbol)) : error(name, ts.Diagnostics.Module_0_declares_1_locally_but_it_is_not_exported, moduleName, declarationName); - ts.addRelatedInfo.apply(void 0, __spreadArray([diagnostic], ts.map(localSymbol.declarations, function (decl, index) { - return ts.createDiagnosticForNode(decl, index === 0 ? ts.Diagnostics._0_is_declared_here : ts.Diagnostics.and_here, declarationName); - }))); + if (localSymbol.declarations) { + ts.addRelatedInfo.apply(void 0, __spreadArray([diagnostic], ts.map(localSymbol.declarations, function (decl, index) { + return ts.createDiagnosticForNode(decl, index === 0 ? ts.Diagnostics._0_is_declared_here : ts.Diagnostics.and_here, declarationName); + }))); + } } } else { @@ -46269,7 +47774,7 @@ var ts; return getTargetOfAliasLikeExpression(expression, dontRecursivelyResolve); } function getTargetOfAccessExpression(node, dontRecursivelyResolve) { - if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62 /* EqualsToken */)) { + if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* EqualsToken */)) { return undefined; } return getTargetOfAliasLikeExpression(node.parent.right, dontRecursivelyResolve); @@ -46277,31 +47782,31 @@ var ts; function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 260 /* ImportEqualsDeclaration */: - case 249 /* VariableDeclaration */: + case 262 /* ImportEqualsDeclaration */: + case 251 /* VariableDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 262 /* ImportClause */: + case 264 /* ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 269 /* NamespaceExport */: + case 271 /* NamespaceExport */: return getTargetOfNamespaceExport(node, dontRecursivelyResolve); - case 265 /* ImportSpecifier */: - case 198 /* BindingElement */: + case 267 /* ImportSpecifier */: + case 200 /* BindingElement */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 270 /* ExportSpecifier */: + case 272 /* ExportSpecifier */: return getTargetOfExportSpecifier(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 266 /* ExportAssignment */: - case 216 /* BinaryExpression */: + case 268 /* ExportAssignment */: + case 218 /* BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 259 /* NamespaceExportDeclaration */: + case 261 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return resolveEntityName(node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve); - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: return getTargetOfPropertyAssignment(node, dontRecursivelyResolve); - case 202 /* ElementAccessExpression */: - case 201 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: return getTargetOfAccessExpression(node, dontRecursivelyResolve); default: return ts.Debug.fail(); @@ -46449,17 +47954,17 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 78 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 79 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 78 /* Identifier */ || entityName.parent.kind === 157 /* QualifiedName */) { + if (entityName.kind === 79 /* Identifier */ || entityName.parent.kind === 159 /* QualifiedName */) { return resolveEntityName(entityName, 1920 /* 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 === 260 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 262 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } @@ -46475,7 +47980,7 @@ var ts; } var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 111551 /* Value */ : 0); var symbol; - if (name.kind === 78 /* Identifier */) { + if (name.kind === 79 /* 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)); @@ -46483,9 +47988,9 @@ var ts; return getMergedSymbol(symbolFromJSPrototype); } } - else if (name.kind === 157 /* QualifiedName */ || name.kind === 201 /* PropertyAccessExpression */) { - var left = name.kind === 157 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 157 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 159 /* QualifiedName */ || name.kind === 203 /* PropertyAccessExpression */) { + var left = name.kind === 159 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 159 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -46493,18 +47998,17 @@ var ts; else if (namespace === unknownSymbol) { return namespace; } - if (ts.isInJSFile(name)) { - if (namespace.valueDeclaration && - ts.isVariableDeclaration(namespace.valueDeclaration) && - namespace.valueDeclaration.initializer && - isCommonJsRequire(namespace.valueDeclaration.initializer)) { - var moduleName = namespace.valueDeclaration.initializer.arguments[0]; - var moduleSym = resolveExternalModuleName(moduleName, moduleName); - if (moduleSym) { - var resolvedModuleSymbol = resolveExternalModuleSymbol(moduleSym); - if (resolvedModuleSymbol) { - namespace = resolvedModuleSymbol; - } + if (namespace.valueDeclaration && + ts.isInJSFile(namespace.valueDeclaration) && + ts.isVariableDeclaration(namespace.valueDeclaration) && + namespace.valueDeclaration.initializer && + isCommonJsRequire(namespace.valueDeclaration.initializer)) { + var moduleName = namespace.valueDeclaration.initializer.arguments[0]; + var moduleSym = resolveExternalModuleName(moduleName, moduleName); + if (moduleSym) { + var resolvedModuleSymbol = resolveExternalModuleSymbol(moduleSym); + if (resolvedModuleSymbol) { + namespace = resolvedModuleSymbol; } } } @@ -46525,7 +48029,7 @@ var ts; 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 === 266 /* ExportAssignment */)) { + if (!ts.nodeIsSynthesized(name) && ts.isEntityName(name) && (symbol.flags & 2097152 /* Alias */ || name.parent.kind === 268 /* ExportAssignment */)) { markSymbolOfAliasDeclarationIfTypeOnly(ts.getAliasDeclarationFromName(name), symbol, /*finalTarget*/ undefined, /*overwriteEmpty*/ true); } return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol); @@ -46762,7 +48266,7 @@ var ts; function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias, suppressInteropError) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!suppressInteropError && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 297 /* SourceFile */)) { + if (!suppressInteropError && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 299 /* SourceFile */)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; @@ -46813,7 +48317,10 @@ var ts; var exports = getExportsOfModuleAsArray(moduleSymbol); var exportEquals = resolveExternalModuleSymbol(moduleSymbol); if (exportEquals !== moduleSymbol) { - ts.addRange(exports, getPropertiesOfType(getTypeOfSymbol(exportEquals))); + var type = getTypeOfSymbol(exportEquals); + if (shouldTreatPropertiesOfExternalModuleAsExports(type)) { + ts.addRange(exports, getPropertiesOfType(type)); + } } return exports; } @@ -46833,11 +48340,14 @@ var ts; return undefined; } var type = getTypeOfSymbol(exportEquals); - return type.flags & 131068 /* Primitive */ || - ts.getObjectFlags(type) & 1 /* Class */ || - isArrayOrTupleLikeType(type) - ? undefined - : getPropertyOfType(type, memberName); + return shouldTreatPropertiesOfExternalModuleAsExports(type) ? getPropertyOfType(type, memberName) : undefined; + } + function shouldTreatPropertiesOfExternalModuleAsExports(resolvedExternalModuleType) { + return !(resolvedExternalModuleType.flags & 131068 /* Primitive */ || + ts.getObjectFlags(resolvedExternalModuleType) & 1 /* 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 */) : @@ -46895,11 +48405,13 @@ var ts; if (exportStars) { var nestedSymbols = ts.createSymbolTable(); var lookupTable_1 = new ts.Map(); - for (var _i = 0, _a = exportStars.declarations; _i < _a.length; _i++) { - var node = _a[_i]; - var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); - var exportedSymbols = visit(resolvedModule); - extendExportSymbols(nestedSymbols, exportedSymbols, lookupTable_1, node); + if (exportStars.declarations) { + for (var _i = 0, _a = exportStars.declarations; _i < _a.length; _i++) { + var node = _a[_i]; + var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); + var exportedSymbols = visit(resolvedModule); + extendExportSymbols(nestedSymbols, exportedSymbols, lookupTable_1, node); + } } lookupTable_1.forEach(function (_a, id) { var exportsWithDuplicate = _a.exportsWithDuplicate; @@ -46982,17 +48494,34 @@ var ts; var additionalContainers = ts.mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer); var reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration); var objectLiteralContainer = getVariableDeclarationOfObjectLiteral(container, meaning); - if (enclosingDeclaration && getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* Namespace */, /*externalOnly*/ false)) { + if (enclosingDeclaration && + container.flags & getQualifiedLeftMeaning(meaning) && + getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* 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 } - var res = ts.append(ts.append(additionalContainers, container), objectLiteralContainer); - return ts.concatenate(res, reexportContainers); + // 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 */ + ? forEachSymbolTableInScope(enclosingDeclaration, function (t) { + return ts.forEachEntry(t, function (s) { + if (s.flags & getQualifiedLeftMeaning(meaning) && getTypeOfSymbol(s) === getDeclaredTypeOfSymbol(container)) { + return s; + } + }); + }) : undefined; + var res = firstVariableMatch ? __spreadArray(__spreadArray([firstVariableMatch], additionalContainers), [container]) : __spreadArray(__spreadArray([], additionalContainers), [container]); + res = ts.append(res, objectLiteralContainer); + res = ts.addRange(res, reexportContainers); + return res; } var candidates = ts.mapDefined(symbol.declarations, function (d) { if (!ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent)) { return getSymbolOfNode(d.parent); } - if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 62 /* 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 /* 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)); } @@ -47064,7 +48593,7 @@ var ts; var members = node.members; for (var _i = 0, members_3 = members; _i < members_3.length; _i++) { var member = members_3[_i]; - if (member.kind === 166 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 168 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -47073,7 +48602,9 @@ var ts; var result = new Type(checker, flags); typeCount++; result.id = typeCount; - typeCatalog.push(result); + if (produceDiagnostics) { // Only record types from one checker + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.recordType(result); + } return result; } function createOriginType(flags) { @@ -47133,14 +48664,23 @@ var ts; }); return result || ts.emptyArray; } + function getNamedOrIndexSignatureMembers(members) { + var result = getNamedMembers(members); + var index = getIndexSymbolFromSymbolTable(members); + return index ? ts.concatenate(result, [index]) : result; + } function setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { - type.members = members; - type.properties = members === emptySymbols ? ts.emptyArray : getNamedMembers(members); - type.callSignatures = callSignatures; - type.constructSignatures = constructSignatures; - type.stringIndexInfo = stringIndexInfo; - type.numberIndexInfo = numberIndexInfo; - return type; + var resolved = type; + resolved.members = members; + resolved.properties = ts.emptyArray; + resolved.callSignatures = callSignatures; + resolved.constructSignatures = constructSignatures; + resolved.stringIndexInfo = stringIndexInfo; + resolved.numberIndexInfo = numberIndexInfo; + // This can loop back to getPropertyOfType() which would crash if `callSignatures` & `constructSignatures` are not initialized. + if (members !== emptySymbols) + resolved.properties = getNamedMembers(members); + return resolved; } function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { return setStructuredTypeMembers(createObjectType(16 /* Anonymous */, symbol), members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); @@ -47163,28 +48703,28 @@ var ts; var _loop_8 = function (location) { // Locals of a source file are not in scope (because they get merged into the global symbol table) if (location.locals && !isGlobalSourceFile(location)) { - if (result = callback(location.locals)) { + if (result = callback(location.locals, /*ignoreQualification*/ undefined, /*isLocalNameLookup*/ true, location)) { return { value: result }; } } switch (location.kind) { - case 297 /* SourceFile */: + case 299 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 256 /* ModuleDeclaration */: + case 258 /* 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 // to one another anyway) - if (result = callback((sym === null || sym === void 0 ? void 0 : sym.exports) || emptySymbols)) { + if (result = callback((sym === null || sym === void 0 ? void 0 : sym.exports) || emptySymbols, /*ignoreQualification*/ undefined, /*isLocalNameLookup*/ true, location)) { return { value: result }; } break; - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* 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 @@ -47199,7 +48739,7 @@ var ts; (table_1 || (table_1 = ts.createSymbolTable())).set(key, memberSymbol); } }); - if (table_1 && (result = callback(table_1))) { + if (table_1 && (result = callback(table_1, /*ignoreQualification*/ undefined, /*isLocalNameLookup*/ false, location))) { return { value: result }; } break; @@ -47210,7 +48750,7 @@ var ts; if (typeof state_2 === "object") return state_2.value; } - return callback(globals); + return callback(globals, /*ignoreQualification*/ undefined, /*isLocalNameLookup*/ true); } function getQualifiedLeftMeaning(rightMeaning) { // If we are looking in value space, the parent meaning is value, other wise it is namespace @@ -47221,20 +48761,30 @@ var ts; if (!(symbol && !isPropertyOrMethodDeclarationSymbol(symbol))) { return undefined; } + var links = getSymbolLinks(symbol); + 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; + if (cache.has(key)) { + return cache.get(key); + } var id = getSymbolId(symbol); var visitedSymbolTables = visitedSymbolTablesMap.get(id); if (!visitedSymbolTables) { visitedSymbolTablesMap.set(id, visitedSymbolTables = []); } - return forEachSymbolTableInScope(enclosingDeclaration, getAccessibleSymbolChainFromSymbolTable); + var result = forEachSymbolTableInScope(enclosingDeclaration, getAccessibleSymbolChainFromSymbolTable); + cache.set(key, result); + return result; /** * @param {ignoreQualification} boolean Set when a symbol is being looked for through the exports of another symbol (meaning we have a route to qualify it already) */ - function getAccessibleSymbolChainFromSymbolTable(symbols, ignoreQualification) { + function getAccessibleSymbolChainFromSymbolTable(symbols, ignoreQualification, isLocalNameLookup) { if (!ts.pushIfUnique(visitedSymbolTables, symbols)) { return undefined; } - var result = trySymbolTable(symbols, ignoreQualification); + var result = trySymbolTable(symbols, ignoreQualification, isLocalNameLookup); visitedSymbolTables.pop(); return result; } @@ -47252,7 +48802,7 @@ var ts; !ts.some(symbolFromSymbolTable.declarations, hasNonGlobalAugmentationExternalModuleSymbol) && (ignoreQualification || canQualifySymbol(getMergedSymbol(symbolFromSymbolTable), meaning)); } - function trySymbolTable(symbols, ignoreQualification) { + function trySymbolTable(symbols, ignoreQualification, isLocalNameLookup) { // If symbol is directly available by its name in the symbol table if (isAccessible(symbols.get(symbol.escapedName), /*resolvedAliasSymbol*/ undefined, ignoreQualification)) { return [symbol]; @@ -47265,9 +48815,11 @@ var ts; && !(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)) + // If we're looking up a local name to reference directly, omit namespace reexports, otherwise when we're trawling through an export list to make a dotted name, we can keep it + && (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, 270 /* ExportSpecifier */))) { + && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 272 /* ExportSpecifier */))) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); var candidate = getCandidateListForSymbol(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification); if (candidate) { @@ -47311,7 +48863,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, 270 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 272 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -47326,10 +48878,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 163 /* PropertyDeclaration */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: continue; default: return false; @@ -47367,7 +48919,7 @@ var ts; return hasAccessibleDeclarations; } } - else if (allowModules) { + if (allowModules) { if (ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { if (shouldComputeAliasesToMakeVisible) { earlyModuleBail = true; @@ -47441,7 +48993,8 @@ var ts; return { accessibility: 2 /* CannotBeNamed */, errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning), - errorModuleName: symbolToString(symbolExternalModule) + errorModuleName: symbolToString(symbolExternalModule), + errorNode: ts.isInJSFile(enclosingDeclaration) ? enclosingDeclaration : undefined, }; } } @@ -47458,14 +49011,14 @@ var ts; return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 297 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 299 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 297 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 299 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; - if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 78 /* Identifier */; }), getIsDeclarationVisible)) { + if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 79 /* Identifier */; }), getIsDeclarationVisible)) { return undefined; } return { accessibility: 0 /* Accessible */, aliasesToMakeVisible: aliasesToMakeVisible }; @@ -47517,14 +49070,14 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 176 /* TypeQuery */ || + if (entityName.parent.kind === 178 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) || - entityName.parent.kind === 158 /* ComputedPropertyName */) { + entityName.parent.kind === 160 /* ComputedPropertyName */) { // Typeof value meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 157 /* QualifiedName */ || entityName.kind === 201 /* PropertyAccessExpression */ || - entityName.parent.kind === 260 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 159 /* QualifiedName */ || entityName.kind === 203 /* PropertyAccessExpression */ || + entityName.parent.kind === 262 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -47565,7 +49118,7 @@ var ts; 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) === 297 /* SourceFile */ ? ts.createPrinter({ removeComments: true, neverAsciiEscape: true }) : ts.createPrinter({ removeComments: true }); + var printer = (enclosingDeclaration === null || enclosingDeclaration === void 0 ? void 0 : enclosingDeclaration.kind) === 299 /* 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); return writer; @@ -47577,10 +49130,10 @@ var ts; function signatureToStringWorker(writer) { var sigOutput; if (flags & 262144 /* WriteArrowStyleSignature */) { - sigOutput = kind === 1 /* Construct */ ? 175 /* ConstructorType */ : 174 /* FunctionType */; + sigOutput = kind === 1 /* Construct */ ? 177 /* ConstructorType */ : 176 /* FunctionType */; } else { - sigOutput = kind === 1 /* Construct */ ? 170 /* ConstructSignature */ : 169 /* CallSignature */; + sigOutput = kind === 1 /* Construct */ ? 172 /* ConstructSignature */ : 171 /* CallSignature */; } var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); @@ -47620,14 +49173,14 @@ var ts; return typeToString(type, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */); } function symbolValueDeclarationIsContextSensitive(symbol) { - return symbol && symbol.valueDeclaration && ts.isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration); + 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 */; } function isClassInstanceSide(type) { - return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || !!(ts.getObjectFlags(type) & 1073741824 /* IsClassInstanceClone */)); + return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288 /* Object */) && !!(ts.getObjectFlags(type) & 16777216 /* IsClassInstanceClone */))); } function createNodeBuilder() { return { @@ -47666,7 +49219,7 @@ var ts; enclosingDeclaration: enclosingDeclaration, flags: flags || 0 /* None */, // If no full tracker is provided, fake up a dummy one with a basic limited-functionality moduleResolverHost - tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: ts.noop, moduleResolverHost: flags & 134217728 /* DoNotIncludeSymbolChain */ ? { + tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: function () { return false; }, moduleResolverHost: flags & 134217728 /* DoNotIncludeSymbolChain */ ? { getCommonSourceDirectory: !!host.getCommonSourceDirectory ? function () { return host.getCommonSourceDirectory(); } : function () { return ""; }, getSourceFiles: function () { return host.getSourceFiles(); }, getCurrentDirectory: function () { return host.getCurrentDirectory(); }, @@ -47679,17 +49232,46 @@ var ts; getFileIncludeReasons: function () { return host.getFileIncludeReasons(); }, } : undefined }, encounteredError: false, + reportedDiagnostic: false, visitedTypes: undefined, symbolDepth: undefined, inferTypeParameters: undefined, approximateLength: 0 }; + context.tracker = wrapSymbolTrackerToReportForContext(context, context.tracker); var resultingNode = cb(context); if (context.truncating && context.flags & 1 /* 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; } + function wrapSymbolTrackerToReportForContext(context, tracker) { + var oldTrackSymbol = tracker.trackSymbol; + return __assign(__assign({}, tracker), { reportCyclicStructureError: wrapReportedDiagnostic(tracker.reportCyclicStructureError), reportInaccessibleThisError: wrapReportedDiagnostic(tracker.reportInaccessibleThisError), reportInaccessibleUniqueSymbolError: wrapReportedDiagnostic(tracker.reportInaccessibleUniqueSymbolError), reportLikelyUnsafeImportRequiredError: wrapReportedDiagnostic(tracker.reportLikelyUnsafeImportRequiredError), reportNonlocalAugmentation: wrapReportedDiagnostic(tracker.reportNonlocalAugmentation), reportPrivateInBaseOfClassExpression: wrapReportedDiagnostic(tracker.reportPrivateInBaseOfClassExpression), trackSymbol: oldTrackSymbol && (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var result = oldTrackSymbol.apply(void 0, args); + if (result) { + context.reportedDiagnostic = true; + } + return result; + }) }); + function wrapReportedDiagnostic(method) { + if (!method) { + return method; + } + return (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + context.reportedDiagnostic = true; + return method.apply(void 0, args); + }); + } + } function checkTruncationLength(context) { if (context.truncating) return context.truncating; @@ -47707,33 +49289,33 @@ var ts; return undefined; // TODO: GH#18217 } context.approximateLength += 3; - return ts.factory.createKeywordTypeNode(128 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(129 /* AnyKeyword */); } if (!(context.flags & 536870912 /* NoTypeReduction */)) { type = getReducedType(type); } if (type.flags & 1 /* Any */) { context.approximateLength += 3; - return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 136 /* IntrinsicKeyword */ : 128 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 137 /* IntrinsicKeyword */ : 129 /* AnyKeyword */); } if (type.flags & 2 /* Unknown */) { - return ts.factory.createKeywordTypeNode(152 /* UnknownKeyword */); + return ts.factory.createKeywordTypeNode(153 /* UnknownKeyword */); } if (type.flags & 4 /* String */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(147 /* StringKeyword */); + return ts.factory.createKeywordTypeNode(148 /* StringKeyword */); } if (type.flags & 8 /* Number */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(144 /* NumberKeyword */); + return ts.factory.createKeywordTypeNode(145 /* NumberKeyword */); } if (type.flags & 64 /* BigInt */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(155 /* BigIntKeyword */); + return ts.factory.createKeywordTypeNode(156 /* BigIntKeyword */); } if (type.flags & 16 /* Boolean */) { context.approximateLength += 7; - return ts.factory.createKeywordTypeNode(131 /* BooleanKeyword */); + return ts.factory.createKeywordTypeNode(132 /* BooleanKeyword */); } if (type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */)) { var parentSymbol = getParentOfSymbol(type.symbol); @@ -47787,15 +49369,15 @@ var ts; } } context.approximateLength += 13; - return ts.factory.createTypeOperatorNode(151 /* UniqueKeyword */, ts.factory.createKeywordTypeNode(148 /* SymbolKeyword */)); + return ts.factory.createTypeOperatorNode(152 /* UniqueKeyword */, ts.factory.createKeywordTypeNode(149 /* SymbolKeyword */)); } if (type.flags & 16384 /* Void */) { context.approximateLength += 4; - return ts.factory.createKeywordTypeNode(113 /* VoidKeyword */); + return ts.factory.createKeywordTypeNode(114 /* VoidKeyword */); } if (type.flags & 32768 /* Undefined */) { context.approximateLength += 9; - return ts.factory.createKeywordTypeNode(150 /* UndefinedKeyword */); + return ts.factory.createKeywordTypeNode(151 /* UndefinedKeyword */); } if (type.flags & 65536 /* Null */) { context.approximateLength += 4; @@ -47803,15 +49385,15 @@ var ts; } if (type.flags & 131072 /* Never */) { context.approximateLength += 5; - return ts.factory.createKeywordTypeNode(141 /* NeverKeyword */); + return ts.factory.createKeywordTypeNode(142 /* NeverKeyword */); } if (type.flags & 4096 /* ESSymbol */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(148 /* SymbolKeyword */); + return ts.factory.createKeywordTypeNode(149 /* SymbolKeyword */); } if (type.flags & 67108864 /* NonPrimitive */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(145 /* ObjectKeyword */); + return ts.factory.createKeywordTypeNode(146 /* ObjectKeyword */); } if (isThisTypeParameter(type)) { if (context.flags & 4194304 /* InObjectTypeLiteral */) { @@ -47881,7 +49463,7 @@ var ts; var indexedType = type.type; context.approximateLength += 6; var indexTypeNode = typeToTypeNodeHelper(indexedType, context); - return ts.factory.createTypeOperatorNode(138 /* KeyOfKeyword */, indexTypeNode); + return ts.factory.createTypeOperatorNode(139 /* KeyOfKeyword */, indexTypeNode); } if (type.flags & 134217728 /* TemplateLiteral */) { var texts_1 = type.texts; @@ -47938,14 +49520,14 @@ 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` - appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(138 /* KeyOfKeyword */, typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context)); + appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(139 /* KeyOfKeyword */, 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(getTemplateTypeFromMappedType(type), context); + var templateTypeNode = typeToTypeNodeHelper(removeMissingType(getTemplateTypeFromMappedType(type), !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), context); var mappedTypeNode = ts.factory.createMappedTypeNode(readonlyToken, typeParameterNode, nameTypeNode, questionToken, templateTypeNode); context.approximateLength += 10; return ts.setEmitFlags(mappedTypeNode, 1 /* SingleLine */); @@ -47961,7 +49543,9 @@ var ts; return symbolToTypeNode(symbol, context, isInstanceType); } // Always use 'typeof T' for type of class, enum, and module objects - else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 221 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || + else if (symbol.flags & 32 /* Class */ + && !getBaseTypeVariableOfClass(symbol) + && !(symbol.valueDeclaration && symbol.valueDeclaration.kind === 223 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, isInstanceType); @@ -47992,7 +49576,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 297 /* SourceFile */ || declaration.parent.kind === 257 /* ModuleBlock */; + return declaration.parent.kind === 299 /* SourceFile */ || declaration.parent.kind === 259 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -48002,6 +49586,7 @@ var ts; } } 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) : @@ -48015,6 +49600,19 @@ var ts; if (id && !context.symbolDepth) { context.symbolDepth = new ts.Map(); } + var links = context.enclosingDeclaration && getNodeLinks(context.enclosingDeclaration); + var key = getTypeId(type) + "|" + context.flags; + if (links) { + links.serializedTypes || (links.serializedTypes = new ts.Map()); + } + var cachedResult = (_a = links === null || links === void 0 ? void 0 : links.serializedTypes) === null || _a === void 0 ? void 0 : _a.get(key); + if (cachedResult) { + if (cachedResult.truncating) { + context.truncating = true; + } + context.approximateLength += cachedResult.addedLength; + return deepCloneOrReuseNode(cachedResult); + } var depth; if (id) { depth = context.symbolDepth.get(id) || 0; @@ -48024,12 +49622,27 @@ var ts; context.symbolDepth.set(id, depth + 1); } context.visitedTypes.add(typeId); + var startLength = context.approximateLength; var result = transform(type); + var addedLength = context.approximateLength - startLength; + if (!context.reportedDiagnostic && !context.encounteredError) { + if (context.truncating) { + result.truncating = true; + } + result.addedLength = addedLength; + (_b = links === null || links === void 0 ? void 0 : links.serializedTypes) === null || _b === void 0 ? void 0 : _b.set(key, result); + } context.visitedTypes.delete(typeId); if (id) { context.symbolDepth.set(id, depth); } return result; + function deepCloneOrReuseNode(node) { + if (!ts.nodeIsSynthesized(node) && ts.getParseTreeNode(node) === node) { + return node; + } + return ts.setTextRange(ts.factory.cloneNode(ts.visitEachChild(node, deepCloneOrReuseNode, ts.nullTransformationContext)), node); + } } function createTypeNodeFromObjectType(type) { if (isGenericMappedType(type) || type.containsError) { @@ -48043,12 +49656,12 @@ var ts; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 174 /* FunctionType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 176 /* FunctionType */, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 175 /* ConstructorType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 177 /* ConstructorType */, context); return signatureNode; } } @@ -48092,9 +49705,10 @@ var ts; } var elementType = typeToTypeNodeHelper(typeArguments[0], context); var arrayType = ts.factory.createArrayTypeNode(elementType); - return type.target === globalArrayType ? arrayType : ts.factory.createTypeOperatorNode(142 /* ReadonlyKeyword */, arrayType); + return type.target === globalArrayType ? arrayType : ts.factory.createTypeOperatorNode(143 /* 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 */)); }); if (typeArguments.length > 0) { var arity = getTypeReferenceArity(type); var tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, arity), context); @@ -48116,12 +49730,12 @@ var ts; } } var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode(tupleConstituentNodes), 1 /* SingleLine */); - return type.target.readonly ? ts.factory.createTypeOperatorNode(142 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + return type.target.readonly ? ts.factory.createTypeOperatorNode(143 /* 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(142 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + return type.target.readonly ? ts.factory.createTypeOperatorNode(143 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } context.encounteredError = true; return undefined; // TODO: GH#18217 @@ -48228,17 +49842,17 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 169 /* CallSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 171 /* CallSignature */, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; if (signature.flags & 4 /* Abstract */) continue; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 170 /* ConstructSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 172 /* ConstructSignature */, context)); } if (resolvedType.stringIndexInfo) { var indexSignature = void 0; - if (resolvedType.objectFlags & 2048 /* ReverseMapped */) { + if (resolvedType.objectFlags & 1024 /* ReverseMapped */) { indexSignature = indexInfoToIndexSignatureDeclarationHelper(createIndexInfo(anyType, resolvedType.stringIndexInfo.isReadonly, resolvedType.stringIndexInfo.declaration), 0 /* String */, context, createElidedInformationPlaceholder(context)); } else { @@ -48280,17 +49894,31 @@ var ts; if (!(context.flags & 1 /* NoTruncation */)) { return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier("..."), /*typeArguments*/ undefined); } - return ts.factory.createKeywordTypeNode(128 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(129 /* AnyKeyword */); + } + function shouldUsePlaceholderForProperty(propertySymbol, context) { + var _a; + // Use placeholders for reverse mapped types we've either already descended into, or which + // are nested reverse mappings within a mapping over a non-anonymous type. The later is a restriction mostly just to + // reduce the blowup in printback size from doing, eg, a deep reverse mapping over `Window`. + // 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 */) + && (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 */))); } function addPropertyToElementList(propertySymbol, context, typeElements) { + var _a; var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */); - var propertyType = propertyIsReverseMapped && context.flags & 33554432 /* InReverseMappedType */ ? - anyType : getTypeOfSymbol(propertySymbol); + var propertyType = shouldUsePlaceholderForProperty(propertySymbol, context) ? + anyType : getNonMissingTypeOfSymbol(propertySymbol); var saveEnclosingDeclaration = context.enclosingDeclaration; context.enclosingDeclaration = undefined; if (context.tracker.trackSymbol && ts.getCheckFlags(propertySymbol) & 4096 /* Late */ && isLateBoundName(propertySymbol.escapedName)) { var decl = ts.first(propertySymbol.declarations); - if (hasLateBindableName(decl)) { + if (propertySymbol.declarations && hasLateBindableName(decl)) { if (ts.isBinaryExpression(decl)) { var name = ts.getNameOfDeclaration(decl); if (name && ts.isElementAccessExpression(name) && ts.isPropertyAccessEntityNameExpression(name.argumentExpression)) { @@ -48302,30 +49930,35 @@ var ts; } } } - context.enclosingDeclaration = saveEnclosingDeclaration; + context.enclosingDeclaration = propertySymbol.valueDeclaration || ((_a = propertySymbol.declarations) === null || _a === void 0 ? void 0 : _a[0]) || saveEnclosingDeclaration; 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 */); for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { var signature = signatures_1[_i]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 164 /* MethodSignature */, context, { name: propertyName, questionToken: optionalToken }); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 166 /* MethodSignature */, context, { name: propertyName, questionToken: optionalToken }); typeElements.push(preserveCommentsOn(methodDeclaration)); } } else { - var savedFlags = context.flags; - context.flags |= propertyIsReverseMapped ? 33554432 /* InReverseMappedType */ : 0; var propertyTypeNode = void 0; - if (propertyIsReverseMapped && !!(savedFlags & 33554432 /* InReverseMappedType */)) { + if (shouldUsePlaceholderForProperty(propertySymbol, context)) { propertyTypeNode = createElidedInformationPlaceholder(context); } else { - propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.factory.createKeywordTypeNode(128 /* AnyKeyword */); + if (propertyIsReverseMapped) { + context.reverseMappedStack || (context.reverseMappedStack = []); + context.reverseMappedStack.push(propertySymbol); + } + propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.factory.createKeywordTypeNode(129 /* AnyKeyword */); + if (propertyIsReverseMapped) { + context.reverseMappedStack.pop(); + } } - context.flags = savedFlags; - var modifiers = isReadonlySymbol(propertySymbol) ? [ts.factory.createToken(142 /* ReadonlyKeyword */)] : undefined; + var modifiers = isReadonlySymbol(propertySymbol) ? [ts.factory.createToken(143 /* ReadonlyKeyword */)] : undefined; if (modifiers) { context.approximateLength += 9; } @@ -48333,9 +49966,10 @@ var ts; typeElements.push(preserveCommentsOn(propertySignature)); } function preserveCommentsOn(node) { - if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 333 /* JSDocPropertyTag */; })) { - var d = ts.find(propertySymbol.declarations, function (d) { return d.kind === 333 /* JSDocPropertyTag */; }); - var commentText = d.comment; + var _a; + if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 341 /* JSDocPropertyTag */; })) { + var d = (_a = propertySymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 341 /* 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 }]); } @@ -48364,25 +49998,25 @@ var ts; var mayHaveNameCollisions = !(context.flags & 64 /* 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_4 = []; + var result_5 = []; var i = 0; for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { var type = types_2[_i]; i++; if (checkTruncationLength(context) && (i + 2 < types.length - 1)) { - result_4.push(ts.factory.createTypeReferenceNode("... " + (types.length - i) + " more ...", /*typeArguments*/ undefined)); + result_5.push(ts.factory.createTypeReferenceNode("... " + (types.length - i) + " more ...", /*typeArguments*/ undefined)); var typeNode_1 = typeToTypeNodeHelper(types[types.length - 1], context); if (typeNode_1) { - result_4.push(typeNode_1); + result_5.push(typeNode_1); } break; } context.approximateLength += 2; // Account for whitespace + separator var typeNode = typeToTypeNodeHelper(type, context); if (typeNode) { - result_4.push(typeNode); + result_5.push(typeNode); if (seenNames && ts.isIdentifierTypeReference(typeNode)) { - seenNames.add(typeNode.typeName.escapedText, [type, result_4.length - 1]); + seenNames.add(typeNode.typeName.escapedText, [type, result_5.length - 1]); } } } @@ -48404,13 +50038,13 @@ var ts; })) { for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { var _a = types_3[_i], type = _a[0], resultIndex = _a[1]; - result_4[resultIndex] = typeToTypeNodeHelper(type, context); + result_5[resultIndex] = typeToTypeNodeHelper(type, context); } } }); context.flags = saveContextFlags; } - return result_4; + return result_5; } } function typesAreSameReference(a, b) { @@ -48420,7 +50054,7 @@ var ts; } function indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context, typeNode) { var name = ts.getNameFromIndexInfo(indexInfo) || "x"; - var indexerTypeNode = ts.factory.createKeywordTypeNode(kind === 0 /* String */ ? 147 /* StringKeyword */ : 144 /* NumberKeyword */); + var indexerTypeNode = ts.factory.createKeywordTypeNode(kind === 0 /* String */ ? 148 /* StringKeyword */ : 145 /* NumberKeyword */); var indexingParameter = ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -48435,13 +50069,14 @@ var ts; } context.approximateLength += (name.length + 4); return ts.factory.createIndexSignature( - /*decorators*/ undefined, indexInfo.isReadonly ? [ts.factory.createToken(142 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); + /*decorators*/ undefined, indexInfo.isReadonly ? [ts.factory.createToken(143 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); } function signatureToSignatureDeclarationHelper(signature, kind, context, options) { var _a, _b, _c, _d; var suppressAny = context.flags & 256 /* SuppressAnyReturnType */; if (suppressAny) context.flags &= ~256 /* 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) { @@ -48452,7 +50087,7 @@ 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 === 166 /* Constructor */, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); }); + 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 === 168 /* Constructor */, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -48461,7 +50096,7 @@ var ts; var typePredicate = getTypePredicateOfSignature(signature); if (typePredicate) { var assertsModifier = typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? - ts.factory.createToken(127 /* AssertsKeyword */) : + ts.factory.createToken(128 /* AssertsKeyword */) : undefined; var parameterName = typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.setEmitFlags(ts.factory.createIdentifier(typePredicate.parameterName), 16777216 /* NoAsciiEscaping */) : @@ -48475,29 +50110,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(128 /* AnyKeyword */); + returnTypeNode = ts.factory.createKeywordTypeNode(129 /* AnyKeyword */); } } var modifiers = options === null || options === void 0 ? void 0 : options.modifiers; - if ((kind === 175 /* ConstructorType */) && signature.flags & 4 /* Abstract */) { + if ((kind === 177 /* ConstructorType */) && signature.flags & 4 /* Abstract */) { var flags = ts.modifiersToFlags(modifiers); modifiers = ts.factory.createModifiersFromModifierFlags(flags | 128 /* Abstract */); } - context.approximateLength += 3; // Usually a signature contributes a few more characters than this, but 3 is the minimum - var node = kind === 169 /* CallSignature */ ? ts.factory.createCallSignature(typeParameters, parameters, returnTypeNode) : - kind === 170 /* ConstructSignature */ ? ts.factory.createConstructSignature(typeParameters, parameters, returnTypeNode) : - kind === 164 /* 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 === 165 /* MethodDeclaration */ ? ts.factory.createMethodDeclaration(/*decorators*/ undefined, 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 === 166 /* Constructor */ ? ts.factory.createConstructorDeclaration(/*decorators*/ undefined, modifiers, parameters, /*body*/ undefined) : - kind === 167 /* GetAccessor */ ? ts.factory.createGetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_c = options === null || options === void 0 ? void 0 : options.name) !== null && _c !== void 0 ? _c : ts.factory.createIdentifier(""), parameters, returnTypeNode, /*body*/ undefined) : - kind === 168 /* SetAccessor */ ? ts.factory.createSetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_d = options === null || options === void 0 ? void 0 : options.name) !== null && _d !== void 0 ? _d : ts.factory.createIdentifier(""), parameters, /*body*/ undefined) : - kind === 171 /* IndexSignature */ ? ts.factory.createIndexSignature(/*decorators*/ undefined, modifiers, parameters, returnTypeNode) : - kind === 308 /* JSDocFunctionType */ ? ts.factory.createJSDocFunctionType(parameters, returnTypeNode) : - kind === 174 /* FunctionType */ ? ts.factory.createFunctionTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : - kind === 175 /* ConstructorType */ ? ts.factory.createConstructorTypeNode(modifiers, typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : - kind === 251 /* FunctionDeclaration */ ? ts.factory.createFunctionDeclaration(/*decorators*/ undefined, 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 === 208 /* 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 === 209 /* ArrowFunction */ ? ts.factory.createArrowFunction(modifiers, typeParameters, parameters, returnTypeNode, /*equalsGreaterThanToken*/ undefined, ts.factory.createBlock([])) : + var node = kind === 171 /* CallSignature */ ? ts.factory.createCallSignature(typeParameters, parameters, returnTypeNode) : + kind === 172 /* ConstructSignature */ ? ts.factory.createConstructSignature(typeParameters, parameters, returnTypeNode) : + kind === 166 /* 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 === 167 /* MethodDeclaration */ ? ts.factory.createMethodDeclaration(/*decorators*/ undefined, 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 === 168 /* Constructor */ ? ts.factory.createConstructorDeclaration(/*decorators*/ undefined, modifiers, parameters, /*body*/ undefined) : + kind === 169 /* GetAccessor */ ? ts.factory.createGetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_c = options === null || options === void 0 ? void 0 : options.name) !== null && _c !== void 0 ? _c : ts.factory.createIdentifier(""), parameters, returnTypeNode, /*body*/ undefined) : + kind === 170 /* SetAccessor */ ? ts.factory.createSetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_d = options === null || options === void 0 ? void 0 : options.name) !== null && _d !== void 0 ? _d : ts.factory.createIdentifier(""), parameters, /*body*/ undefined) : + kind === 173 /* IndexSignature */ ? ts.factory.createIndexSignature(/*decorators*/ undefined, modifiers, parameters, returnTypeNode) : + kind === 311 /* JSDocFunctionType */ ? ts.factory.createJSDocFunctionType(parameters, returnTypeNode) : + kind === 176 /* FunctionType */ ? ts.factory.createFunctionTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : + kind === 177 /* ConstructorType */ ? ts.factory.createConstructorTypeNode(modifiers, typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : + kind === 253 /* FunctionDeclaration */ ? ts.factory.createFunctionDeclaration(/*decorators*/ undefined, 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 === 210 /* 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 === 211 /* 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); @@ -48519,9 +50153,9 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags, privateSymbolVisitor, bundledImports) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 160 /* Parameter */); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 162 /* Parameter */); if (!parameterDeclaration && !ts.isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 326 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 334 /* JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -48535,8 +50169,8 @@ var ts; var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* RestParameter */; var dotDotDotToken = isRest ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined; var name = parameterDeclaration ? parameterDeclaration.name ? - parameterDeclaration.name.kind === 78 /* Identifier */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : - parameterDeclaration.name.kind === 157 /* QualifiedName */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 79 /* Identifier */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 159 /* QualifiedName */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : cloneBindingName(parameterDeclaration.name) : ts.symbolName(parameterSymbol) : ts.symbolName(parameterSymbol); @@ -48701,11 +50335,11 @@ var ts; } function getSpecifierForModuleSymbol(symbol, context) { var _a; - var file = ts.getDeclarationOfKind(symbol, 297 /* SourceFile */); + var file = ts.getDeclarationOfKind(symbol, 299 /* SourceFile */); if (!file) { var equivalentFileSymbol = ts.firstDefined(symbol.declarations, function (d) { return getFileSymbolIfFileSymbolExportEqualsContainer(d, symbol); }); if (equivalentFileSymbol) { - file = ts.getDeclarationOfKind(equivalentFileSymbol, 297 /* SourceFile */); + file = ts.getDeclarationOfKind(equivalentFileSymbol, 299 /* SourceFile */); } } if (file && file.moduleName !== undefined) { @@ -48716,8 +50350,8 @@ var ts; if (context.tracker.trackReferencedAmbientModule) { var ambientDecls = ts.filter(symbol.declarations, ts.isAmbientModule); if (ts.length(ambientDecls)) { - for (var _i = 0, ambientDecls_1 = ambientDecls; _i < ambientDecls_1.length; _i++) { - var decl = ambientDecls_1[_i]; + for (var _i = 0, _b = ambientDecls; _i < _b.length; _i++) { + var decl = _b[_i]; context.tracker.trackReferencedAmbientModule(decl, symbol); } } @@ -48744,7 +50378,7 @@ var ts; // specifier preference var moduleResolverHost = context.tracker.moduleResolverHost; var specifierCompilerOptions = isBundle_1 ? __assign(__assign({}, compilerOptions), { baseUrl: moduleResolverHost.getCommonSourceDirectory() }) : compilerOptions; - specifier = ts.first(ts.moduleSpecifiers.getModuleSpecifiers(symbol, checker, specifierCompilerOptions, contextFile, moduleResolverHost, { importModuleSpecifierPreference: isBundle_1 ? "non-relative" : "relative", importModuleSpecifierEnding: isBundle_1 ? "minimal" : undefined })); + specifier = ts.first(ts.moduleSpecifiers.getModuleSpecifiers(symbol, checker, specifierCompilerOptions, contextFile, moduleResolverHost, { importModuleSpecifierPreference: isBundle_1 ? "non-relative" : "project-relative", importModuleSpecifierEnding: isBundle_1 ? "minimal" : undefined })); (_a = links.specifierCache) !== null && _a !== void 0 ? _a : (links.specifierCache = new ts.Map()); links.specifierCache.set(contextFile.path, specifier); } @@ -48857,7 +50491,7 @@ var ts; return false; } function typeParameterToName(type, context) { - var _a; + var _a, _b; if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && context.typeParameterNames) { var cached = context.typeParameterNames.get(getTypeId(type)); if (cached) { @@ -48865,22 +50499,25 @@ var ts; } } var result = symbolToName(type.symbol, context, 788968 /* Type */, /*expectsIdentifier*/ true); - if (!(result.kind & 78 /* Identifier */)) { + if (!(result.kind & 79 /* Identifier */)) { return ts.factory.createIdentifier("(Missing type parameter)"); } if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { var rawtext = result.escapedText; - var i = 0; + var i = ((_a = context.typeParameterNamesByTextNextNameCount) === null || _a === void 0 ? void 0 : _a.get(rawtext)) || 0; var text = rawtext; - while (((_a = context.typeParameterNamesByText) === null || _a === void 0 ? void 0 : _a.has(text)) || typeParameterShadowsNameInScope(text, context, type)) { + while (((_b = context.typeParameterNamesByText) === null || _b === void 0 ? void 0 : _b.has(text)) || typeParameterShadowsNameInScope(text, context, type)) { i++; text = rawtext + "_" + i; } if (text !== rawtext) { result = ts.factory.createIdentifier(text, result.typeArguments); } + // avoiding iterations of the above loop turns out to be worth it when `i` starts to get large, so we cache the max + // `i` we've used thus far, to save work later + (context.typeParameterNamesByTextNextNameCount || (context.typeParameterNamesByTextNextNameCount = new ts.Map())).set(rawtext, i); (context.typeParameterNames || (context.typeParameterNames = new ts.Map())).set(getTypeId(type), result); - (context.typeParameterNamesByText || (context.typeParameterNamesByText = new ts.Set())).add(result.escapedText); + (context.typeParameterNamesByText || (context.typeParameterNamesByText = new ts.Set())).add(rawtext); } return result; } @@ -48888,7 +50525,7 @@ var ts; var chain = lookupSymbolChain(symbol, context, meaning); if (expectsIdentifier && chain.length !== 1 && !context.encounteredError - && !(context.flags & 65536 /* AllowQualifedNameInPlaceOfIdentifier */)) { + && !(context.flags & 65536 /* AllowQualifiedNameInPlaceOfIdentifier */)) { context.encounteredError = true; } return createEntityNameFromSymbolChain(chain, chain.length - 1); @@ -48968,9 +50605,6 @@ var ts; if (fromNameType) { return fromNameType; } - if (ts.isKnownSymbol(symbol)) { - return ts.factory.createComputedPropertyName(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("Symbol"), symbol.escapedName.substr(3))); - } var rawName = ts.unescapeLeadingUnderscores(symbol.escapedName); var stringNamed = !!ts.length(symbol.declarations) && ts.every(symbol.declarations, isStringNamed); return createPropertyNameNodeForIdentifierOrLiteral(rawName, stringNamed, singleQuote); @@ -49022,6 +50656,7 @@ var ts; if (initial.typeParameterSymbolList) { initial.typeParameterSymbolList = new ts.Set(initial.typeParameterSymbolList); } + initial.tracker = wrapSymbolTrackerToReportForContext(initial, initial.tracker); return initial; } function getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration) { @@ -49037,13 +50672,13 @@ var ts; function serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled) { if (type !== errorType && enclosingDeclaration) { var declWithExistingAnnotation = getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration); - if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation)) { + if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation) && !ts.isGetAccessorDeclaration(declWithExistingAnnotation)) { // try to reuse the existing annotation var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation); if (getTypeFromTypeNode(existing) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) { - var result_5 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled); - if (result_5) { - return result_5; + var result_6 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled); + if (result_6) { + return result_6; } } } @@ -49060,10 +50695,14 @@ var ts; function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) { if (type !== errorType && context.enclosingDeclaration) { var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); - if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation && instantiateType(getTypeFromTypeNode(annotation), signature.mapper) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) { - var result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled); - if (result) { - return result; + 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; + if (thisInstantiated === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) { + var result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled); + if (result) { + return result; + } } } } @@ -49107,17 +50746,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 === 310 /* JSDocNamepathType */) { - return ts.factory.createKeywordTypeNode(128 /* AnyKeyword */); + if (ts.isJSDocAllType(node) || node.kind === 313 /* JSDocNamepathType */) { + return ts.factory.createKeywordTypeNode(129 /* AnyKeyword */); } if (ts.isJSDocUnknownType(node)) { - return ts.factory.createKeywordTypeNode(152 /* UnknownKeyword */); + return ts.factory.createKeywordTypeNode(153 /* 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(150 /* UndefinedKeyword */)]); + return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createKeywordTypeNode(151 /* UndefinedKeyword */)]); } if (ts.isJSDocNonNullableType(node)) { return ts.visitNode(node.type, visitExistingNodeTreeSymbols); @@ -49131,11 +50770,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(128 /* AnyKeyword */)); + /*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(129 /* AnyKeyword */)); })); } if (ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "") { - return ts.setOriginalNode(ts.factory.createKeywordTypeNode(128 /* AnyKeyword */), node); + return ts.setOriginalNode(ts.factory.createKeywordTypeNode(129 /* AnyKeyword */), node); } if ((ts.isExpressionWithTypeArguments(node) || ts.isTypeReferenceNode(node)) && ts.isJSDocIndexSignature(node)) { return ts.factory.createTypeLiteralNode([ts.factory.createIndexSignature( @@ -49152,13 +50791,13 @@ var ts; return ts.factory.createConstructorTypeNode(node.modifiers, 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( /*decorators*/ undefined, /*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(128 /* AnyKeyword */)); + /*initializer*/ undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(129 /* AnyKeyword */)); } else { return ts.factory.createFunctionTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.map(node.parameters, function (p, i) { return ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, getEffectiveDotDotDotForParameter(p), getNameForJSDocFunctionParameter(p, i), p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), - /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(128 /* AnyKeyword */)); + /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(129 /* AnyKeyword */)); } } if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(getTypeReferenceName(node), 788968 /* Type */, /*ignoreErrors*/ true))) { @@ -49226,8 +50865,8 @@ var ts; } } function symbolTableToDeclarationStatements(symbolTable, context, bundled) { - var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.factory.createPropertyDeclaration, 165 /* MethodDeclaration */, /*useAcessors*/ true); - var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type) { return ts.factory.createPropertySignature(mods, name, question, type); }, 164 /* MethodSignature */, /*useAcessors*/ false); + var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.factory.createPropertyDeclaration, 167 /* MethodDeclaration */, /*useAcessors*/ true); + var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type) { return ts.factory.createPropertySignature(mods, name, question, type); }, 166 /* 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 @@ -49239,7 +50878,7 @@ var ts; var deferredPrivatesStack = []; 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); + var accessibleResult = isSymbolAccessible(sym, decl, meaning, /*computeAliases*/ false); if (accessibleResult.accessibility === 0 /* 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); @@ -49248,9 +50887,11 @@ var ts; } } else if (oldcontext.tracker && oldcontext.tracker.trackSymbol) { - oldcontext.tracker.trackSymbol(sym, decl, meaning); + return oldcontext.tracker.trackSymbol(sym, decl, meaning); } + return false; } }) }); + context.tracker = wrapSymbolTrackerToReportForContext(context, context.tracker); ts.forEachEntry(symbolTable, function (symbol, name) { var baseName = ts.unescapeLeadingUnderscores(name); void getInternalSymbolName(symbol, baseName); // Called to cache values into `usedSymbolNames` and `remappedSymbolNames` @@ -49265,7 +50906,7 @@ var ts; visitSymbolTable(symbolTable); return mergeRedundantStatements(results); function isIdentifierAndNotUndefined(node) { - return !!node && node.kind === 78 /* Identifier */; + return !!node && node.kind === 79 /* Identifier */; } function getNamesOfDeclaration(statement) { if (ts.isVariableStatement(statement)) { @@ -49434,6 +51075,9 @@ var ts; var oldContext = context; context = cloneNodeBuilderContext(context); var result = serializeSymbolWorker(symbol, isPrivate, propertyAsAlias); + if (context.reportedDiagnostic) { + oldcontext.reportedDiagnostic = context.reportedDiagnostic; // hoist diagnostic result into outer context + } context = oldContext; return result; } @@ -49448,6 +51092,7 @@ var ts; // If it's a class/interface/function: emit a class/interface/function with a `default` modifier // These forms can merge, eg (`export default 12; export default interface A {}`) function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias) { + var _a, _b; var symbolName = ts.unescapeLeadingUnderscores(symbol.escapedName); var isDefault = symbol.escapedName === "default" /* Default */; if (isPrivate && !(context.flags & 131072 /* AllowAnonymousIdentifier */) && ts.isStringANonContextualKeyword(symbolName) && !isDefault) { @@ -49506,9 +51151,9 @@ var ts; if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) { textRange = textRange.parent.parent; } - var propertyAccessRequire = ts.find(symbol.declarations, ts.isPropertyAccessExpression); + var propertyAccessRequire = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isPropertyAccessExpression); if (propertyAccessRequire && ts.isBinaryExpression(propertyAccessRequire.parent) && ts.isIdentifier(propertyAccessRequire.parent.right) - && type.symbol && ts.isSourceFile(type.symbol.valueDeclaration)) { + && ((_b = type.symbol) === null || _b === void 0 ? void 0 : _b.valueDeclaration) && ts.isSourceFile(type.symbol.valueDeclaration)) { var alias = localName === propertyAccessRequire.parent.right.escapedText ? undefined : propertyAccessRequire.parent.right; addResult(ts.factory.createExportDeclaration( /*decorators*/ undefined, @@ -49558,7 +51203,10 @@ var ts; serializeEnum(symbol, symbolName, modifierFlags); } if (symbol.flags & 32 /* Class */) { - if (symbol.flags & 4 /* Property */ && ts.isBinaryExpression(symbol.valueDeclaration.parent) && ts.isClassExpression(symbol.valueDeclaration.parent.right)) { + if (symbol.flags & 4 /* Property */ + && symbol.valueDeclaration + && ts.isBinaryExpression(symbol.valueDeclaration.parent) + && ts.isClassExpression(symbol.valueDeclaration.parent.right)) { // Looks like a `module.exports.Sub = class {}` - if we serialize `symbol` as a class, the result will have no members, // since the classiness is actually from the target of the effective alias the symbol is. yes. A BlockScopedVariable|Class|Property // _really_ acts like an Alias, and none of a BlockScopedVariable, Class, or Property. This is the travesty of JS binding today. @@ -49584,12 +51232,14 @@ var ts; if (symbol.flags & 8388608 /* ExportStar */) { // synthesize export * from "moduleReference" // Straightforward - only one thing to do - make an export declaration - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var node = _a[_i]; - var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); - if (!resolvedModule) - continue; - addResult(ts.factory.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, /*exportClause*/ undefined, ts.factory.createStringLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0 /* None */); + if (symbol.declarations) { + for (var _i = 0, _c = symbol.declarations; _i < _c.length; _i++) { + var node = _c[_i]; + var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); + if (!resolvedModule) + continue; + addResult(ts.factory.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, /*exportClause*/ undefined, ts.factory.createStringLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0 /* None */); + } } } if (needsPostExportDefault) { @@ -49627,15 +51277,16 @@ var ts; function addResult(node, additionalModifierFlags) { if (ts.canHaveModifiers(node)) { var newModifierFlags = 0 /* None */; + var enclosingDeclaration_1 = context.enclosingDeclaration && + (ts.isJSDocTypeAlias(context.enclosingDeclaration) ? ts.getSourceFileOfNode(context.enclosingDeclaration) : context.enclosingDeclaration); if (additionalModifierFlags & 1 /* Export */ && - context.enclosingDeclaration && - (isExportingScope(context.enclosingDeclaration) || ts.isModuleDeclaration(context.enclosingDeclaration)) && + 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 */; } if (addingDeclare && !(newModifierFlags & 1 /* Export */) && - (!context.enclosingDeclaration || !(context.enclosingDeclaration.flags & 8388608 /* Ambient */)) && + (!enclosingDeclaration_1 || !(enclosingDeclaration_1.flags & 8388608 /* 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 */; @@ -49650,19 +51301,23 @@ var ts; results.push(node); } function serializeTypeAlias(symbol, symbolName, modifierFlags) { + var _a; var aliasType = getDeclaredTypeOfTypeAlias(symbol); var typeParams = getSymbolLinks(symbol).typeParameters; var typeParamDecls = ts.map(typeParams, function (p) { return typeParameterToDeclaration(p, context); }); - var jsdocAliasDecl = ts.find(symbol.declarations, ts.isJSDocTypeAlias); - var commentText = jsdocAliasDecl ? jsdocAliasDecl.comment || jsdocAliasDecl.parent.comment : undefined; + 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 */; + 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(/*decorators*/ undefined, /*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); context.flags = oldFlags; + context.enclosingDeclaration = oldEnclosingDecl; } function serializeInterface(symbol, symbolName, modifierFlags) { var interfaceType = getDeclaredTypeOfClassOrInterface(symbol); @@ -49671,10 +51326,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, 169 /* CallSignature */); - var constructSignatures = serializeSignatures(1 /* Construct */, interfaceType, baseType, 170 /* ConstructSignature */); + var callSignatures = serializeSignatures(0 /* Call */, interfaceType, baseType, 171 /* CallSignature */); + var constructSignatures = serializeSignatures(1 /* Construct */, interfaceType, baseType, 172 /* ConstructSignature */); var indexSignatures = serializeIndexSignatures(interfaceType, baseType); - var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.factory.createHeritageClause(93 /* ExtendsKeyword */, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b, 111551 /* Value */); }))]; + var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.factory.createHeritageClause(94 /* ExtendsKeyword */, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b, 111551 /* Value */); }))]; addResult(ts.factory.createInterfaceDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, heritageClauses, __spreadArray(__spreadArray(__spreadArray(__spreadArray([], indexSignatures), constructSignatures), callSignatures), members)), modifierFlags); @@ -49741,9 +51396,8 @@ var ts; 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, 251 /* FunctionDeclaration */, context, { name: ts.factory.createIdentifier(localName), privateSymbolVisitor: includePrivateSymbol, bundledImports: bundled }); - // for expressions assigned to `var`s, use the `var` as the text range - addResult(ts.setTextRange(decl, sig.declaration && ts.isVariableDeclaration(sig.declaration.parent) && sig.declaration.parent.parent || sig.declaration), modifierFlags); + var decl = signatureToSignatureDeclarationHelper(sig, 253 /* 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)) { @@ -49751,6 +51405,18 @@ var ts; 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 */) { + return signature.declaration.parent; + } + // for expressions assigned to `var`s, use the `var` as the text range + if (ts.isVariableDeclaration(signature.declaration.parent) && signature.declaration.parent.parent) { + return signature.declaration.parent.parent; + } + } + return signature.declaration; + } function serializeAsNamespaceDeclaration(props, localName, modifierFlags, suppressNewPrivateContext) { if (ts.length(props)) { var localVsRemoteMap = ts.arrayToMultiMap(props, function (p) { @@ -49837,8 +51503,8 @@ var ts; return undefined; } function serializeAsClass(symbol, localName, modifierFlags) { - var _a; - var originalDecl = ts.find(symbol.declarations, ts.isClassLike); + var _a, _b; + var originalDecl = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isClassLike); var oldEnclosing = context.enclosingDeclaration; context.enclosingDeclaration = originalDecl || oldEnclosing; var localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -49849,25 +51515,25 @@ var ts; var implementsExpressions = originalImplements && sanitizeJSDocImplements(originalImplements) || ts.mapDefined(getImplementsTypes(classType), serializeImplementedType); var staticType = getTypeOfSymbol(symbol); - var isClass = !!((_a = staticType.symbol) === null || _a === void 0 ? void 0 : _a.valueDeclaration) && ts.isClassLike(staticType.symbol.valueDeclaration); + var isClass = !!((_b = staticType.symbol) === null || _b === void 0 ? void 0 : _b.valueDeclaration) && ts.isClassLike(staticType.symbol.valueDeclaration); var staticBaseType = isClass ? getBaseConstructorTypeOfClass(staticType) : anyType; - var heritageClauses = __spreadArray(__spreadArray([], !ts.length(baseTypes) ? [] : [ts.factory.createHeritageClause(93 /* ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))]), !ts.length(implementsExpressions) ? [] : [ts.factory.createHeritageClause(116 /* ImplementsKeyword */, implementsExpressions)]); + var heritageClauses = __spreadArray(__spreadArray([], !ts.length(baseTypes) ? [] : [ts.factory.createHeritageClause(94 /* ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))]), !ts.length(implementsExpressions) ? [] : [ts.factory.createHeritageClause(117 /* ImplementsKeyword */, implementsExpressions)]); var symbolProps = getNonInterhitedProperties(classType, baseTypes, getPropertiesOfType(classType)); var publicSymbolProps = ts.filter(symbolProps, function (s) { // `valueDeclaration` could be undefined if inherited from // a union/intersection base type, but inherited properties // don't matter here. var valueDecl = s.valueDeclaration; - return valueDecl && !(ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name)); + return !!valueDecl && !(ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name)); }); var hasPrivateIdentifier = ts.some(symbolProps, function (s) { // `valueDeclaration` could be undefined if inherited from // a union/intersection base type, but inherited properties // don't matter here. var valueDecl = s.valueDeclaration; - return valueDecl && ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name); + return !!valueDecl && ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name); }); // Boil down all private properties into a single one. var privateProperties = hasPrivateIdentifier ? @@ -49890,7 +51556,7 @@ var ts; !ts.some(getSignaturesOfType(staticType, 1 /* Construct */)); var constructors = isNonConstructableClassLikeInJsFile ? [ts.factory.createConstructorDeclaration(/*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(8 /* Private */), [], /*body*/ undefined)] : - serializeSignatures(1 /* Construct */, staticType, staticBaseType, 166 /* Constructor */); + serializeSignatures(1 /* Construct */, staticType, staticBaseType, 168 /* Constructor */); var indexSignatures = serializeIndexSignatures(classType, baseTypes[0]); context.enclosingDeclaration = oldEnclosing; addResult(ts.setTextRange(ts.factory.createClassDeclaration( @@ -49917,8 +51583,8 @@ var ts; var targetName = getInternalSymbolName(target, verbatimTargetName); includePrivateSymbol(target); // the target may be within the same scope - attempt to serialize it first switch (node.kind) { - case 198 /* BindingElement */: - if (((_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.kind) === 249 /* VariableDeclaration */) { + case 200 /* BindingElement */: + if (((_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.kind) === 251 /* VariableDeclaration */) { // const { SomeClass } = require('./lib'); var specifier_1 = getSpecifierForModuleSymbol(target.parent || target, context); // './lib' var propertyName = node.propertyName; @@ -49930,13 +51596,13 @@ var ts; // 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 289 /* ShorthandPropertyAssignment */: - if (((_e = (_d = node.parent) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.kind) === 216 /* BinaryExpression */) { + case 291 /* ShorthandPropertyAssignment */: + if (((_e = (_d = node.parent) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.kind) === 218 /* BinaryExpression */) { // module.exports = { SomeClass } serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), targetName); } break; - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: // commonjs require: const x = require('y') if (ts.isPropertyAccessExpression(node.initializer)) { // const x = require('y').z @@ -49956,7 +51622,7 @@ var ts; break; } // else fall through and treat commonjs require just like import= - case 260 /* ImportEqualsDeclaration */: + case 262 /* 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)) { @@ -49973,13 +51639,13 @@ var ts; ? symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false) : ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)))), isLocalImport ? modifierFlags : 0 /* None */); break; - case 259 /* NamespaceExportDeclaration */: + case 261 /* 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 */); break; - case 262 /* ImportClause */: + case 264 /* ImportClause */: addResult(ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, ts.factory.createIdentifier(localName), /*namedBindings*/ undefined), @@ -49988,18 +51654,18 @@ var ts; // In such cases, the `target` refers to the module itself already ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context))), 0 /* None */); break; - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: addResult(ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*importClause*/ undefined, ts.factory.createNamespaceImport(ts.factory.createIdentifier(localName))), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* None */); break; - case 269 /* NamespaceExport */: + case 271 /* NamespaceExport */: addResult(ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, ts.factory.createNamespaceExport(ts.factory.createIdentifier(localName)), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* None */); break; - case 265 /* ImportSpecifier */: + case 267 /* ImportSpecifier */: addResult(ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause( @@ -50008,7 +51674,7 @@ var ts; ts.factory.createImportSpecifier(localName !== verbatimTargetName ? ts.factory.createIdentifier(verbatimTargetName) : undefined, ts.factory.createIdentifier(localName)) ])), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context))), 0 /* None */); break; - case 270 /* ExportSpecifier */: + case 272 /* 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; @@ -50016,12 +51682,12 @@ var ts; // another file serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), specifier ? verbatimTargetName : targetName, specifier && ts.isStringLiteralLike(specifier) ? ts.factory.createStringLiteral(specifier.text) : undefined); break; - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: serializeMaybeAliasAssignment(symbol); break; - case 216 /* BinaryExpression */: - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 218 /* BinaryExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* 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 @@ -50076,7 +51742,7 @@ var ts; // a visibility error here (as they're not visible within any scope), but we want to hoist them // into the containing scope anyway, so we want to skip the visibility checks. var oldTrack = context.tracker.trackSymbol; - context.tracker.trackSymbol = ts.noop; + context.tracker.trackSymbol = function () { return false; }; if (isExportAssignmentCompatibleSymbolName) { results.push(ts.factory.createExportAssignment( /*decorators*/ undefined, @@ -50155,6 +51821,7 @@ var ts; } function makeSerializePropertySymbol(createProperty, methodKind, useAccessors) { 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 */))) { @@ -50171,7 +51838,7 @@ var ts; } var flag = (modifierFlags & ~256 /* Async */) | (isStatic ? 32 /* Static */ : 0); var name = getPropertyNameNodeForSymbol(p, context); - var firstPropertyLikeDecl = ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isAccessor, ts.isVariableDeclaration, ts.isPropertySignature, ts.isBinaryExpression, ts.isPropertyAccessExpression)); + 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) { var result = []; if (p.flags & 65536 /* SetAccessor */) { @@ -50181,13 +51848,13 @@ var ts; /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "arg", /*questionToken*/ undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled))], - /*body*/ undefined), ts.find(p.declarations, ts.isSetAccessor) || firstPropertyLikeDecl)); + /*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 */; result.push(ts.setTextRange(ts.factory.createGetAccessorDeclaration( /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(flag), name, [], isPrivate_1 ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), - /*body*/ undefined), ts.find(p.declarations, ts.isGetAccessor) || firstPropertyLikeDecl)); + /*body*/ undefined), ((_c = p.declarations) === null || _c === void 0 ? void 0 : _c.find(ts.isGetAccessor)) || firstPropertyLikeDecl)); } return result; } @@ -50198,7 +51865,7 @@ var ts; /*decorators*/ undefined, 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), // TODO: https://github.com/microsoft/TypeScript/pull/32372#discussion_r328386357 // interface members can't have initializers, however class members _can_ - /*initializer*/ undefined), ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isVariableDeclaration)) || firstPropertyLikeDecl); + /*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 */)) { var type = getTypeOfSymbol(p); @@ -50207,7 +51874,7 @@ var ts; return ts.setTextRange(createProperty( /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | flag), name, p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, /*type*/ undefined, - /*initializer*/ undefined), ts.find(p.declarations, ts.isFunctionLikeDeclaration) || signatures[0] && signatures[0].declaration || p.declarations[0]); + /*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]); } var results_1 = []; for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { @@ -50218,7 +51885,8 @@ var ts; questionToken: p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, modifiers: flag ? ts.factory.createModifiersFromModifierFlags(flag) : undefined }); - results_1.push(ts.setTextRange(decl, sig.declaration)); + var location = sig.declaration && ts.isPrototypePropertyAssignment(sig.declaration.parent) ? sig.declaration.parent : sig.declaration; + results_1.push(ts.setTextRange(decl, location)); } return results_1; } @@ -50389,7 +52057,7 @@ var ts; if (flags === void 0) { flags = 16384 /* 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(127 /* 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 /* 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 printer = ts.createPrinter({ removeComments: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); @@ -50434,9 +52102,9 @@ var ts; return "public"; } function getTypeAliasForTypeLiteral(type) { - if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { + if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */ && type.symbol.declarations) { var node = ts.walkUpParenthesizedTypes(type.symbol.declarations[0].parent); - if (node.kind === 254 /* TypeAliasDeclaration */) { + if (node.kind === 256 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -50444,11 +52112,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 257 /* ModuleBlock */ && + node.parent.kind === 259 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 297 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 299 /* SourceFile */ || ts.isAmbientModule(location); } function getNameOfSymbolFromNameType(symbol, context) { var nameType = getSymbolLinks(symbol).nameType; @@ -50507,17 +52175,17 @@ var ts; if (!declaration) { declaration = symbol.declarations[0]; // Declaration may be nameless, but we'll try anyway } - if (declaration.parent && declaration.parent.kind === 249 /* VariableDeclaration */) { + if (declaration.parent && declaration.parent.kind === 251 /* VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } switch (declaration.kind) { - case 221 /* ClassExpression */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 223 /* ClassExpression */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { context.encounteredError = true; } - return declaration.kind === 221 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; + return declaration.kind === 223 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var name = getNameOfSymbolFromNameType(symbol, context); @@ -50534,28 +52202,28 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 324 /* JSDocCallbackTag */: - case 331 /* JSDocTypedefTag */: - case 325 /* JSDocEnumTag */: + case 332 /* JSDocCallbackTag */: + case 339 /* JSDocTypedefTag */: + case 333 /* 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 198 /* BindingElement */: + case 200 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 249 /* VariableDeclaration */: + case 251 /* 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 256 /* ModuleDeclaration */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 251 /* FunctionDeclaration */: - case 255 /* EnumDeclaration */: - case 260 /* ImportEqualsDeclaration */: + case 258 /* ModuleDeclaration */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 253 /* FunctionDeclaration */: + case 257 /* EnumDeclaration */: + case 262 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; @@ -50563,55 +52231,55 @@ var ts; 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 !== 260 /* ImportEqualsDeclaration */ && parent.kind !== 297 /* SourceFile */ && parent.flags & 8388608 /* Ambient */)) { + !(node.kind !== 262 /* ImportEqualsDeclaration */ && parent.kind !== 299 /* SourceFile */ && parent.flags & 8388608 /* Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent); - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: if (ts.hasEffectiveModifier(node, 8 /* Private */ | 16 /* Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so: // falls through - case 166 /* Constructor */: - case 170 /* ConstructSignature */: - case 169 /* CallSignature */: - case 171 /* IndexSignature */: - case 160 /* Parameter */: - case 257 /* ModuleBlock */: - case 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 177 /* TypeLiteral */: - case 173 /* TypeReference */: - case 178 /* ArrayType */: - case 179 /* TupleType */: - case 182 /* UnionType */: - case 183 /* IntersectionType */: - case 186 /* ParenthesizedType */: - case 192 /* NamedTupleMember */: + case 168 /* Constructor */: + case 172 /* ConstructSignature */: + case 171 /* CallSignature */: + case 173 /* IndexSignature */: + case 162 /* Parameter */: + case 259 /* ModuleBlock */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: + case 179 /* TypeLiteral */: + case 175 /* TypeReference */: + case 180 /* ArrayType */: + case 181 /* TupleType */: + case 184 /* UnionType */: + case 185 /* IntersectionType */: + case 188 /* ParenthesizedType */: + case 194 /* 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 262 /* ImportClause */: - case 263 /* NamespaceImport */: - case 265 /* ImportSpecifier */: + case 264 /* ImportClause */: + case 265 /* NamespaceImport */: + case 267 /* ImportSpecifier */: return false; // Type parameters are always visible - case 159 /* TypeParameter */: + case 161 /* TypeParameter */: // Source file and namespace export are always visible // falls through - case 297 /* SourceFile */: - case 259 /* NamespaceExportDeclaration */: + case 299 /* SourceFile */: + case 261 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return false; default: return false; @@ -50620,10 +52288,10 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 266 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 268 /* ExportAssignment */) { exportSymbol = resolveName(node, node.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 270 /* ExportSpecifier */) { + else if (node.parent.kind === 272 /* ExportSpecifier */) { exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } var result; @@ -50728,12 +52396,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 249 /* VariableDeclaration */: - case 250 /* VariableDeclarationList */: - case 265 /* ImportSpecifier */: - case 264 /* NamedImports */: - case 263 /* NamespaceImport */: - case 262 /* ImportClause */: + case 251 /* VariableDeclaration */: + case 252 /* VariableDeclarationList */: + case 267 /* ImportSpecifier */: + case 266 /* NamedImports */: + case 265 /* NamespaceImport */: + case 264 /* ImportClause */: return false; default: return true; @@ -50796,9 +52464,16 @@ var ts; var stringIndexInfo = getIndexInfoOfType(source, 0 /* String */); var numberIndexInfo = getIndexInfoOfType(source, 1 /* Number */); var result = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); - result.objectFlags |= 131072 /* ObjectRestType */; + result.objectFlags |= 8388608 /* ObjectRestType */; return result; } + function isGenericTypeWithUndefinedConstraint(type) { + return !!(type.flags & 465829888 /* Instantiable */) && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 32768 /* 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 */); + } // Determine the control flow type associated with a destructuring declaration or assignment. The following // forms of destructuring are possible: // let { x } = obj; // BindingElement @@ -50833,23 +52508,23 @@ var ts; function getParentElementAccess(node) { var ancestor = node.parent.parent; switch (ancestor.kind) { - case 198 /* BindingElement */: - case 288 /* PropertyAssignment */: + case 200 /* BindingElement */: + case 290 /* PropertyAssignment */: return getSyntheticElementAccess(ancestor); - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return getSyntheticElementAccess(node.parent); - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return ancestor.initializer; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return ancestor.right; } } function getDestructuringPropertyName(node) { var parent = node.parent; - if (node.kind === 198 /* BindingElement */ && parent.kind === 196 /* ObjectBindingPattern */) { + if (node.kind === 200 /* BindingElement */ && parent.kind === 198 /* ObjectBindingPattern */) { return getLiteralPropertyNameText(node.propertyName || node.name); } - if (node.kind === 288 /* PropertyAssignment */ || node.kind === 289 /* ShorthandPropertyAssignment */) { + if (node.kind === 290 /* PropertyAssignment */ || node.kind === 291 /* ShorthandPropertyAssignment */) { return getLiteralPropertyNameText(node.name); } return "" + parent.elements.indexOf(node); @@ -50875,7 +52550,7 @@ var ts; parentType = getTypeWithFacts(parentType, 524288 /* NEUndefined */); } var type; - if (pattern.kind === 196 /* ObjectBindingPattern */) { + if (pattern.kind === 198 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { parentType = getReducedType(parentType); if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { @@ -50895,7 +52570,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 = getConstraintForLocation(getIndexedAccessType(parentType, indexType, /*noUncheckedIndexedAccessCandidate*/ undefined, name, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, 16 /* ExpressionPosition */), declaration.name); + var declaredType = getIndexedAccessType(parentType, indexType, 32 /* ExpressionPosition */, name); type = getFlowTypeOfDestructuring(declaration, declaredType); } } @@ -50915,8 +52590,8 @@ var ts; } else if (isArrayLikeType(parentType)) { var indexType = getLiteralType(index_2); - var accessFlags = hasDefaultValue(declaration) ? 8 /* NoTupleBoundsCheck */ : 0; - var declaredType = getConstraintForLocation(getIndexedAccessTypeOrUndefined(parentType, indexType, /*noUncheckedIndexedAccessCandidate*/ undefined, declaration.name, accessFlags | 16 /* ExpressionPosition */) || errorType, declaration.name); + var accessFlags = 32 /* ExpressionPosition */ | (hasDefaultValue(declaration) ? 16 /* NoTupleBoundsCheck */ : 0); + var declaredType = getIndexedAccessTypeOrUndefined(parentType, indexType, accessFlags, declaration.name) || errorType; type = getFlowTypeOfDestructuring(declaration, declaredType); } else { @@ -50929,11 +52604,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 && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 32768 /* Undefined */) ? - getTypeWithFacts(type, 524288 /* NEUndefined */) : - type; + return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 32768 /* Undefined */) ? getNonUndefinedType(type) : type; } - return widenTypeInferredFromInitializer(declaration, getUnionType([getTypeWithFacts(type, 524288 /* NEUndefined */), checkDeclarationInitializer(declaration)], 2 /* Subtype */)); + return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration)], 2 /* Subtype */)); } function getTypeForDeclarationFromJSDocComment(declaration) { var jsdocType = ts.getJSDocType(declaration); @@ -50944,25 +52617,26 @@ var ts; } function isNullOrUndefined(node) { var expr = ts.skipParentheses(node); - return expr.kind === 103 /* NullKeyword */ || expr.kind === 78 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; + return expr.kind === 104 /* NullKeyword */ || expr.kind === 79 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 199 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 201 /* ArrayLiteralExpression */ && expr.elements.length === 0; } - function addOptionality(type, optional) { - if (optional === void 0) { optional = true; } - return strictNullChecks && optional ? getOptionalType(type) : type; + function addOptionality(type, isProperty, isOptional) { + if (isProperty === void 0) { isProperty = false; } + if (isOptional === void 0) { isOptional = true; } + return strictNullChecks && isOptional ? getOptionalType(type, isProperty) : type; } // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { // 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 === 238 /* ForInStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 240 /* ForInStatement */) { var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression))); return indexType.flags & (262144 /* TypeParameter */ | 4194304 /* Index */) ? getExtractStringType(indexType) : stringType; } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 239 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 241 /* 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, @@ -50973,13 +52647,14 @@ var ts; if (ts.isBindingPattern(declaration.parent)) { return getTypeForBindingElement(declaration); } - var isOptional = includeOptionality && (ts.isParameter(declaration) && isJSDocOptionalParameter(declaration) - || isOptionalJSDocPropertyLikeTag(declaration) - || !ts.isBindingElement(declaration) && !ts.isVariableDeclaration(declaration) && !!declaration.questionToken); + var isProperty = ts.isPropertyDeclaration(declaration) || ts.isPropertySignature(declaration); + var isOptional = includeOptionality && (isProperty && !!declaration.questionToken || + ts.isParameter(declaration) && (!!declaration.questionToken || isJSDocOptionalParameter(declaration)) || + isOptionalJSDocPropertyLikeTag(declaration)); // Use type from type annotation if one is present var declaredType = tryGetTypeFromEffectiveTypeNode(declaration); if (declaredType) { - return addOptionality(declaredType, isOptional); + return addOptionality(declaredType, isProperty, isOptional); } if ((noImplicitAny || ts.isInJSFile(declaration)) && ts.isVariableDeclaration(declaration) && !ts.isBindingPattern(declaration.name) && @@ -50999,8 +52674,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 === 168 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 167 /* GetAccessor */); + if (func.kind === 170 /* SetAccessor */ && hasBindableName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 169 /* GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -51023,7 +52698,7 @@ var ts; // Use contextual parameter type if one is available var type = declaration.symbol.escapedName === "this" /* This */ ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration); if (type) { - return addOptionality(type, isOptional); + return addOptionality(type, /*isProperty*/ false, isOptional); } } // Use the type of the initializer expression if one is present and the declaration is @@ -51036,7 +52711,7 @@ var ts; } } var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration)); - return addOptionality(type, isOptional); + return addOptionality(type, isProperty, isOptional); } if (ts.isPropertyDeclaration(declaration) && !ts.hasStaticModifier(declaration) && (noImplicitAny || ts.isInJSFile(declaration))) { // We have a property declaration with no type annotation or initializer, in noImplicitAny mode or a .js file. @@ -51045,7 +52720,7 @@ var ts; var type = constructor ? getFlowTypeInConstructor(declaration.symbol, constructor) : ts.getEffectiveModifierFlags(declaration) & 2 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : undefined; - return type && addOptionality(type, isOptional); + return type && addOptionality(type, /*isProperty*/ true, isOptional); } if (ts.isJsxAttribute(declaration)) { // if JSX attribute doesn't have initializer, by default the attribute will have boolean value of true. @@ -51071,7 +52746,7 @@ var ts; links.isConstructorDeclaredProperty = !!getDeclaringConstructor(symbol) && ts.every(symbol.declarations, function (declaration) { return ts.isBinaryExpression(declaration) && isPossiblyAliasedThisProperty(declaration) && - (declaration.left.kind !== 202 /* ElementAccessExpression */ || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) && + (declaration.left.kind !== 204 /* ElementAccessExpression */ || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) && !getAnnotatedTypeForAssignmentDeclaration(/*declaredType*/ undefined, declaration, symbol, declaration); }); } @@ -51087,13 +52762,33 @@ var ts; !declaration.initializer && (noImplicitAny || ts.isInJSFile(declaration)); } function getDeclaringConstructor(symbol) { + if (!symbol.declarations) { + return; + } 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 === 166 /* Constructor */ || isJSConstructor(container))) { + if (container && (container.kind === 168 /* Constructor */ || isJSConstructor(container))) { return container; } } + ; + } + /** Create a synthetic property access flow node after the last statement of the file */ + function getFlowTypeFromCommonJSExport(symbol) { + var file = ts.getSourceFileOfNode(symbol.declarations[0]); + var accessName = ts.unescapeLeadingUnderscores(symbol.escapedName); + var areAllModuleExports = symbol.declarations.every(function (d) { return ts.isInJSFile(d) && ts.isAccessExpression(d) && ts.isModuleExportsAccessExpression(d.expression); }); + var reference = areAllModuleExports + ? ts.factory.createPropertyAccessExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("module"), ts.factory.createIdentifier("exports")), accessName) + : ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("exports"), accessName); + if (areAllModuleExports) { + ts.setParent(reference.expression.expression, reference.expression); + } + ts.setParent(reference.expression, reference); + ts.setParent(reference, file); + reference.flowNode = file.endFlowNode; + return getFlowTypeOfReference(reference, autoType, undefinedType); } function getFlowTypeInConstructor(symbol, constructor) { var accessName = ts.startsWith(symbol.escapedName, "__#") @@ -51111,7 +52806,10 @@ var ts; return everyType(flowType, isNullableType) ? undefined : convertAutoToAny(flowType); } function getFlowTypeOfProperty(reference, prop) { - var initialType = prop && (!isAutoTypedProperty(prop) || ts.getEffectiveModifierFlags(prop.valueDeclaration) & 2 /* Ambient */) && getTypeOfPropertyInBaseClass(prop) || undefinedType; + var initialType = (prop === null || prop === void 0 ? void 0 : prop.valueDeclaration) + && (!isAutoTypedProperty(prop) || ts.getEffectiveModifierFlags(prop.valueDeclaration) & 2 /* Ambient */) + && getTypeOfPropertyInBaseClass(prop) + || undefinedType; return getFlowTypeOfReference(reference, autoType, initialType); } function getWidenedTypeForAssignmentDeclaration(symbol, resolvedSymbol) { @@ -51122,7 +52820,7 @@ var ts; if (tag && tag.typeExpression) { return getTypeFromTypeNode(tag.typeExpression); } - var containerObjectType = getJSContainerObjectType(symbol.valueDeclaration, symbol, container); + var containerObjectType = symbol.valueDeclaration && getJSContainerObjectType(symbol.valueDeclaration, symbol, container); return containerObjectType || getWidenedLiteralType(checkExpressionCached(container)); } var type; @@ -51134,40 +52832,42 @@ var ts; type = getFlowTypeInConstructor(symbol, getDeclaringConstructor(symbol)); } if (!type) { - var jsdocType = void 0; var types = void 0; - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration : - ts.isAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : - undefined; - if (!expression) { - continue; // Non-assignment declaration merged in (eg, an Identifier to mark the thing as a namespace) - skip over it and pull type info from elsewhere - } - var kind = ts.isAccessExpression(expression) - ? ts.getAssignmentDeclarationPropertyAccessKind(expression) - : ts.getAssignmentDeclarationKind(expression); - if (kind === 4 /* ThisProperty */ || ts.isBinaryExpression(expression) && isPossiblyAliasedThisProperty(expression, kind)) { - if (isDeclarationInConstructor(expression)) { - definedInConstructor = true; + if (symbol.declarations) { + var jsdocType = void 0; + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration : + ts.isAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : + undefined; + if (!expression) { + continue; // Non-assignment declaration merged in (eg, an Identifier to mark the thing as a namespace) - skip over it and pull type info from elsewhere } - else { - definedInMethod = true; + var kind = ts.isAccessExpression(expression) + ? ts.getAssignmentDeclarationPropertyAccessKind(expression) + : ts.getAssignmentDeclarationKind(expression); + if (kind === 4 /* ThisProperty */ || ts.isBinaryExpression(expression) && isPossiblyAliasedThisProperty(expression, kind)) { + if (isDeclarationInConstructor(expression)) { + definedInConstructor = true; + } + else { + definedInMethod = true; + } + } + if (!ts.isCallExpression(expression)) { + jsdocType = getAnnotatedTypeForAssignmentDeclaration(jsdocType, expression, symbol, declaration); + } + if (!jsdocType) { + (types || (types = [])).push((ts.isBinaryExpression(expression) || ts.isCallExpression(expression)) ? getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) : neverType); } } - if (!ts.isCallExpression(expression)) { - jsdocType = getAnnotatedTypeForAssignmentDeclaration(jsdocType, expression, symbol, declaration); - } - if (!jsdocType) { - (types || (types = [])).push((ts.isBinaryExpression(expression) || ts.isCallExpression(expression)) ? getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) : neverType); - } + type = jsdocType; } - type = jsdocType; if (!type) { if (!ts.length(types)) { return errorType; // No types from any declarations :( } - var constructorTypes = definedInConstructor ? getConstructorDefinedThisAssignmentTypes(types, symbol.declarations) : undefined; + var constructorTypes = definedInConstructor && symbol.declarations ? getConstructorDefinedThisAssignmentTypes(types, symbol.declarations) : undefined; // use only the constructor types unless they were only assigned null | undefined (including widening variants) if (definedInMethod) { var propType = getTypeOfPropertyInBaseClass(symbol); @@ -51180,8 +52880,8 @@ var ts; type = getUnionType(sourceTypes, 2 /* Subtype */); } } - var widened = getWidenedType(addOptionality(type, definedInMethod && !definedInConstructor)); - if (filterType(widened, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) === neverType) { + var widened = getWidenedType(addOptionality(type, /*isProperty*/ false, definedInMethod && !definedInConstructor)); + if (symbol.valueDeclaration && filterType(widened, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) === neverType) { reportImplicitAny(symbol.valueDeclaration, anyType); return anyType; } @@ -51205,10 +52905,11 @@ var ts; mergeSymbolTable(exports, s.exports); } var type = createAnonymousType(symbol, exports, ts.emptyArray, ts.emptyArray, undefined, undefined); - type.objectFlags |= 16384 /* JSLiteral */; + type.objectFlags |= 8192 /* JSLiteral */; return type; } function getAnnotatedTypeForAssignmentDeclaration(declaredType, expression, symbol, declaration) { + var _a; var typeNode = ts.getEffectiveTypeAnnotationNode(expression.parent); if (typeNode) { var type = getWidenedType(getTypeFromTypeNode(typeNode)); @@ -51219,10 +52920,13 @@ var ts; errorNextVariableOrPropertyDeclarationMustHaveSameType(/*firstDeclaration*/ undefined, declaredType, declaration, type); } } - if (symbol.parent) { + if ((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.valueDeclaration) { var typeNode_2 = ts.getEffectiveTypeAnnotationNode(symbol.parent.valueDeclaration); if (typeNode_2) { - return getTypeOfPropertyOfType(getTypeFromTypeNode(typeNode_2), symbol.escapedName); + var annotationSymbol = getPropertyOfType(getTypeFromTypeNode(typeNode_2), symbol.escapedName); + if (annotationSymbol) { + return getNonMissingTypeOfSymbol(annotationSymbol); + } } } return declaredType; @@ -51283,7 +52987,7 @@ var ts; // but we may have a JS file with `module.exports = { a: true }` along with a TypeScript module augmentation // declaring an `export const a: number`. In that case, we issue a duplicate identifier error, because // it's unclear what that's supposed to mean, so it's probably a mistake. - if (ts.getSourceFileOfNode(s.valueDeclaration) !== ts.getSourceFileOfNode(exportedMember.valueDeclaration)) { + if (s.valueDeclaration && exportedMember.valueDeclaration && ts.getSourceFileOfNode(s.valueDeclaration) !== ts.getSourceFileOfNode(exportedMember.valueDeclaration)) { var unescapedName = ts.unescapeLeadingUnderscores(s.escapedName); var exportedMemberName = ((_a = ts.tryCast(exportedMember.valueDeclaration, ts.isNamedDeclaration)) === null || _a === void 0 ? void 0 : _a.name) || exportedMember.valueDeclaration; ts.addRelatedInfo(error(s.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0, unescapedName), ts.createDiagnosticForNode(exportedMemberName, ts.Diagnostics._0_was_also_declared_here, unescapedName)); @@ -51305,9 +53009,9 @@ var ts; }); var result = createAnonymousType(initialSize !== members_4.size ? undefined : exportedType.symbol, // Only set the type's symbol if it looks to be the same as the original type members_4, exportedType.callSignatures, exportedType.constructSignatures, exportedType.stringIndexInfo, exportedType.numberIndexInfo); - result.objectFlags |= (ts.getObjectFlags(type) & 16384 /* JSLiteral */); // Propagate JSLiteral flag + result.objectFlags |= (ts.getObjectFlags(type) & 8192 /* JSLiteral */); // Propagate JSLiteral flag if (result.symbol && result.symbol.flags & 32 /* Class */ && type === getDeclaredTypeOfClassOrInterface(result.symbol)) { - result.objectFlags |= 1073741824 /* IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type + result.objectFlags |= 16777216 /* IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type } return result; } @@ -51319,16 +53023,16 @@ var ts; } function containsSameNamedThisProperty(thisProperty, expression) { return ts.isPropertyAccessExpression(thisProperty) - && thisProperty.expression.kind === 107 /* ThisKeyword */ + && thisProperty.expression.kind === 108 /* 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 === 166 /* Constructor */ || - thisContainer.kind === 251 /* FunctionDeclaration */ || - (thisContainer.kind === 208 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + return thisContainer.kind === 168 /* Constructor */ || + thisContainer.kind === 253 /* FunctionDeclaration */ || + (thisContainer.kind === 210 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); } function getConstructorDefinedThisAssignmentTypes(types, declarations) { ts.Debug.assert(types.length === declarations.length); @@ -51366,7 +53070,7 @@ var ts; function getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) { var members = ts.createSymbolTable(); var stringIndexInfo; - var objectFlags = 128 /* ObjectLiteral */ | 1048576 /* ContainsObjectOrArrayLiteral */; + var objectFlags = 128 /* ObjectLiteral */ | 262144 /* ContainsObjectOrArrayLiteral */; ts.forEach(pattern.elements, function (e) { var name = e.propertyName || e.name; if (e.dotDotDotToken) { @@ -51390,7 +53094,7 @@ var ts; result.objectFlags |= objectFlags; if (includePatternInType) { result.pattern = pattern; - result.objectFlags |= 1048576 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= 262144 /* ContainsObjectOrArrayLiteral */; } return result; } @@ -51398,7 +53102,7 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - var restElement = lastElement && lastElement.kind === 198 /* BindingElement */ && lastElement.dotDotDotToken ? lastElement : undefined; + var restElement = lastElement && lastElement.kind === 200 /* BindingElement */ && lastElement.dotDotDotToken ? lastElement : undefined; if (elements.length === 0 || elements.length === 1 && restElement) { return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; } @@ -51409,7 +53113,7 @@ var ts; if (includePatternInType) { result = cloneTypeReference(result); result.pattern = pattern; - result.objectFlags |= 1048576 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= 262144 /* ContainsObjectOrArrayLiteral */; } return result; } @@ -51423,7 +53127,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 196 /* ObjectBindingPattern */ + return pattern.kind === 198 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -51439,8 +53143,17 @@ var ts; function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) { return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true), declaration, reportErrors); } + function isGlobalSymbolConstructor(node) { + var symbol = getSymbolOfNode(node); + var globalSymbol = getGlobalESSymbolConstructorTypeSymbol(/*reportErrors*/ false); + return globalSymbol && symbol && symbol === globalSymbol; + } 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)) { + type = getESSymbolLikeTypeForNode(declaration); + } if (reportErrors) { reportErrorsFromWidening(declaration, type); } @@ -51462,7 +53175,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 160 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 162 /* Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(declaration) { @@ -51493,19 +53206,31 @@ var ts; if (symbol === requireSymbol) { return anyType; } - if (symbol.flags & 134217728 /* ModuleExports */) { + if (symbol.flags & 134217728 /* ModuleExports */ && symbol.valueDeclaration) { var fileSymbol = getSymbolOfNode(ts.getSourceFileOfNode(symbol.valueDeclaration)); + var result = createSymbol(fileSymbol.flags, "exports"); + result.declarations = fileSymbol.declarations ? fileSymbol.declarations.slice() : []; + result.parent = symbol; + result.target = fileSymbol; + if (fileSymbol.valueDeclaration) + result.valueDeclaration = fileSymbol.valueDeclaration; + if (fileSymbol.members) + result.members = new ts.Map(fileSymbol.members); + if (fileSymbol.exports) + result.exports = new ts.Map(fileSymbol.exports); var members = ts.createSymbolTable(); - members.set("exports", fileSymbol); + members.set("exports", result); return createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, undefined, undefined); } // Handle catch clause variables + ts.Debug.assertIsDefined(symbol.valueDeclaration); var declaration = symbol.valueDeclaration; if (ts.isCatchClauseVariableDeclarationOrBindingElement(declaration)) { - var decl = declaration; - if (!decl.type) - return anyType; - var type_1 = getTypeOfNode(decl.type); + var typeNode = ts.getEffectiveTypeAnnotationNode(declaration); + if (typeNode === undefined) { + return useUnknownInCatchVariables ? unknownType : anyType; + } + var type_1 = getTypeOfNode(typeNode); // an errorType will make `checkTryStatement` issue an error return isTypeAny(type_1) || type_1 === unknownType ? type_1 : errorType; } @@ -51525,7 +53250,7 @@ var ts; return reportCircularityError(symbol); } var type; - if (declaration.kind === 266 /* ExportAssignment */) { + if (declaration.kind === 268 /* ExportAssignment */) { type = widenTypeForVariableLikeDeclaration(checkExpressionCached(declaration.expression), declaration); } else if (ts.isBinaryExpression(declaration) || @@ -51580,7 +53305,7 @@ var ts; type = getTypeOfEnumMember(symbol); } else if (ts.isAccessor(declaration)) { - type = resolveTypeOfAccessors(symbol); + type = resolveTypeOfAccessors(symbol) || ts.Debug.fail("Non-write accessor resolution must always produce a type"); } else { return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.formatSyntaxKind(declaration.kind) + " for " + ts.Debug.formatSymbol(symbol)); @@ -51596,7 +53321,7 @@ var ts; } function getAnnotatedAccessorTypeNode(accessor) { if (accessor) { - if (accessor.kind === 167 /* GetAccessor */) { + if (accessor.kind === 169 /* GetAccessor */) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation; } @@ -51620,63 +53345,78 @@ var ts; } function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); - return links.type || (links.type = getTypeOfAccessorsWorker(symbol)); + return links.type || (links.type = getTypeOfAccessorsWorker(symbol) || ts.Debug.fail("Read type of accessor must always produce a type")); + } + function getTypeOfSetAccessor(symbol) { + var links = getSymbolLinks(symbol); + return links.writeType || (links.writeType = getTypeOfAccessorsWorker(symbol, /*writing*/ true)); } - function getTypeOfAccessorsWorker(symbol) { + function getTypeOfAccessorsWorker(symbol, writing) { + if (writing === void 0) { writing = false; } if (!pushTypeResolution(symbol, 0 /* Type */)) { return errorType; } - var type = resolveTypeOfAccessors(symbol); + var type = resolveTypeOfAccessors(symbol, writing); if (!popTypeResolution()) { type = anyType; if (noImplicitAny) { - var getter = ts.getDeclarationOfKind(symbol, 167 /* GetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 169 /* GetAccessor */); error(getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } return type; } - function resolveTypeOfAccessors(symbol) { - var getter = ts.getDeclarationOfKind(symbol, 167 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 168 /* SetAccessor */); + function resolveTypeOfAccessors(symbol, writing) { + if (writing === void 0) { writing = false; } + var getter = ts.getDeclarationOfKind(symbol, 169 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 170 /* SetAccessor */); + var setterType = getAnnotatedAccessorType(setter); + // For write operations, prioritize type annotations on the setter + if (writing && setterType) { + return instantiateTypeIfNeeded(setterType, symbol); + } + // Else defer to the getter type if (getter && ts.isInJSFile(getter)) { var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { - return jsDocType; + return instantiateTypeIfNeeded(jsDocType, symbol); } } - // First try to see if the user specified a return type on the get-accessor. - var getterReturnType = getAnnotatedAccessorType(getter); - if (getterReturnType) { - return getterReturnType; + // Try to see if the user specified a return type on the get-accessor. + var getterType = getAnnotatedAccessorType(getter); + if (getterType) { + return instantiateTypeIfNeeded(getterType, symbol); } - else { - // If the user didn't specify a return type, try to use the set-accessor's parameter type. - var setterParameterType = getAnnotatedAccessorType(setter); - if (setterParameterType) { - return setterParameterType; + // If the user didn't specify a return type, try to use the set-accessor's parameter type. + if (setterType) { + return setterType; + } + // If there are no specified types, try to infer it from the body of the get accessor if it exists. + if (getter && getter.body) { + var returnTypeFromBody = getReturnTypeFromBody(getter); + return instantiateTypeIfNeeded(returnTypeFromBody, symbol); + } + // Otherwise, fall back to 'any'. + if (setter) { + if (!isPrivateWithinAmbient(setter)) { + errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol)); } - else { - // If there are no specified types, try to infer it from the body of the get accessor if it exists. - if (getter && getter.body) { - return getReturnTypeFromBody(getter); - } - // Otherwise, fall back to 'any'. - else { - if (setter) { - if (!isPrivateWithinAmbient(setter)) { - errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol)); - } - } - else { - ts.Debug.assert(!!getter, "there must exist a getter as we are current checking either setter or getter in this function"); - if (!isPrivateWithinAmbient(getter)) { - errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol)); - } - } - return anyType; - } + return anyType; + } + else if (getter) { + ts.Debug.assert(!!getter, "there must exist a getter as we are current checking either setter or getter in this function"); + if (!isPrivateWithinAmbient(getter)) { + errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol)); } + return anyType; + } + return undefined; + function instantiateTypeIfNeeded(type, symbol) { + if (ts.getCheckFlags(symbol) & 1 /* Instantiated */) { + var links = getSymbolLinks(symbol); + return instantiateType(type, links.mapper); + } + return type; } } function getBaseTypeVariableOfClass(symbol) { @@ -51706,9 +53446,9 @@ var ts; if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { return anyType; } - else if (declaration && (declaration.kind === 216 /* BinaryExpression */ || + else if (declaration && (declaration.kind === 218 /* BinaryExpression */ || ts.isAccessExpression(declaration) && - declaration.parent.kind === 216 /* BinaryExpression */)) { + declaration.parent.kind === 218 /* BinaryExpression */)) { return getWidenedTypeForAssignmentDeclaration(symbol); } else if (symbol.flags & 512 /* ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { @@ -51742,14 +53482,16 @@ var ts; var links = getSymbolLinks(symbol); if (!links.type) { var targetSymbol = resolveAlias(symbol); + var exportSymbol = symbol.declarations && getTargetOfAliasDeclaration(getDeclarationOfAliasSymbol(symbol), /*dontResolveAlias*/ true); // It only makes sense to get the type of a value symbol. If the result of resolving // the alias is not a value, then it has no type. To get the type associated with a // type symbol, call getDeclaredTypeOfSymbol. // This check is important because without it, a call to getTypeOfSymbol could end // up recursively calling getTypeOfAlias, causing a stack overflow. - links.type = targetSymbol.flags & 111551 /* Value */ - ? getTypeOfSymbol(targetSymbol) - : errorType; + links.type = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.declarations) && isDuplicatedCommonJSExport(exportSymbol.declarations) && symbol.declarations.length ? getFlowTypeFromCommonJSExport(exportSymbol) + : isDuplicatedCommonJSExport(symbol.declarations) ? autoType + : targetSymbol.flags & 111551 /* Value */ ? getTypeOfSymbol(targetSymbol) + : errorType; } return links.type; } @@ -51775,7 +53517,7 @@ var ts; return errorType; } // Check if variable has initializer that circularly references the variable itself - if (noImplicitAny && (declaration.kind !== 160 /* Parameter */ || declaration.initializer)) { + if (noImplicitAny && (declaration.kind !== 162 /* 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 @@ -51792,6 +53534,15 @@ var ts; } return links.type; } + function getSetAccessorTypeOfSymbol(symbol) { + if (symbol.flags & 98304 /* Accessor */) { + var type = getTypeOfSetAccessor(symbol); + if (type) { + return type; + } + } + return getTypeOfSymbol(symbol); + } function getTypeOfSymbol(symbol) { var checkFlags = ts.getCheckFlags(symbol); if (checkFlags & 65536 /* DeferredType */) { @@ -51823,6 +53574,9 @@ var ts; } return errorType; } + function getNonMissingTypeOfSymbol(symbol) { + return removeMissingType(getTypeOfSymbol(symbol), !!(symbol.flags & 16777216 /* Optional */)); + } function isReferenceToType(type, target) { return type !== undefined && target !== undefined @@ -51874,66 +53628,72 @@ var ts; return undefined; } switch (node.kind) { - case 232 /* VariableStatement */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 164 /* MethodSignature */: - case 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 308 /* JSDocFunctionType */: - case 251 /* FunctionDeclaration */: - case 165 /* MethodDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 254 /* TypeAliasDeclaration */: - case 330 /* JSDocTemplateTag */: - case 331 /* JSDocTypedefTag */: - case 325 /* JSDocEnumTag */: - case 324 /* JSDocCallbackTag */: - case 190 /* MappedType */: - case 184 /* ConditionalType */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 166 /* MethodSignature */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: + case 311 /* JSDocFunctionType */: + case 253 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 256 /* TypeAliasDeclaration */: + case 338 /* JSDocTemplateTag */: + case 339 /* JSDocTypedefTag */: + case 333 /* JSDocEnumTag */: + case 332 /* JSDocCallbackTag */: + case 192 /* MappedType */: + case 186 /* ConditionalType */: { var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 190 /* MappedType */) { + if (node.kind === 192 /* MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 184 /* ConditionalType */) { + else if (node.kind === 186 /* ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } - else if (node.kind === 232 /* VariableStatement */ && !ts.isInJSFile(node)) { - break; - } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 252 /* ClassDeclaration */ || node.kind === 221 /* ClassExpression */ || node.kind === 253 /* InterfaceDeclaration */ || isJSConstructor(node)) && + (node.kind === 254 /* ClassDeclaration */ || node.kind === 223 /* ClassExpression */ || node.kind === 255 /* InterfaceDeclaration */ || isJSConstructor(node)) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; - case 326 /* JSDocParameterTag */: + } + case 334 /* JSDocParameterTag */: var paramSymbol = ts.getParameterSymbolFromJSDoc(node); if (paramSymbol) { node = paramSymbol.valueDeclaration; } break; + case 314 /* JSDocComment */: { + var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); + return node.tags + ? appendTypeParameters(outerTypeParameters, ts.flatMap(node.tags, function (t) { return ts.isJSDocTemplateTag(t) ? t.typeParameters : undefined; })) + : outerTypeParameters; + } } } } // 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, 253 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 255 /* InterfaceDeclaration */); ts.Debug.assert(!!declaration, "Class was missing valueDeclaration -OR- non-class had no interface declarations"); return getOuterTypeParameters(declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, // interface, or type alias. function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { + if (!symbol.declarations) { + return; + } var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 253 /* InterfaceDeclaration */ || - node.kind === 252 /* ClassDeclaration */ || - node.kind === 221 /* ClassExpression */ || + if (node.kind === 255 /* InterfaceDeclaration */ || + node.kind === 254 /* ClassDeclaration */ || + node.kind === 223 /* ClassExpression */ || isJSConstructor(node) || ts.isTypeAlias(node)) { var declaration = node; @@ -52027,7 +53787,9 @@ var ts; ctorReturn = getReturnTypeOfSignature(ctorSig[0]); } } - ts.addRelatedInfo(err, ts.createDiagnosticForNode(baseConstructorType.symbol.declarations[0], ts.Diagnostics.Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1, symbolToString(baseConstructorType.symbol), typeToString(ctorReturn))); + if (baseConstructorType.symbol.declarations) { + ts.addRelatedInfo(err, ts.createDiagnosticForNode(baseConstructorType.symbol.declarations[0], ts.Diagnostics.Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1, symbolToString(baseConstructorType.symbol), typeToString(ctorReturn))); + } } return type.resolvedBaseConstructorType = errorType; } @@ -52037,20 +53799,22 @@ var ts; } function getImplementsTypes(type) { var resolvedImplementsTypes = ts.emptyArray; - for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - var implementsTypeNodes = ts.getEffectiveImplementsTypeNodes(declaration); - if (!implementsTypeNodes) - continue; - for (var _b = 0, implementsTypeNodes_1 = implementsTypeNodes; _b < implementsTypeNodes_1.length; _b++) { - var node = implementsTypeNodes_1[_b]; - var implementsType = getTypeFromTypeNode(node); - if (implementsType !== errorType) { - if (resolvedImplementsTypes === ts.emptyArray) { - resolvedImplementsTypes = [implementsType]; - } - else { - resolvedImplementsTypes.push(implementsType); + if (type.symbol.declarations) { + for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + var implementsTypeNodes = ts.getEffectiveImplementsTypeNodes(declaration); + if (!implementsTypeNodes) + continue; + for (var _b = 0, implementsTypeNodes_1 = implementsTypeNodes; _b < implementsTypeNodes_1.length; _b++) { + var node = implementsTypeNodes_1[_b]; + var implementsType = getTypeFromTypeNode(node); + if (implementsType !== errorType) { + if (resolvedImplementsTypes === ts.emptyArray) { + resolvedImplementsTypes = [implementsType]; + } + else { + resolvedImplementsTypes.push(implementsType); + } } } } @@ -52077,10 +53841,10 @@ var ts; else { ts.Debug.fail("type must be class or interface"); } - if (!popTypeResolution()) { + if (!popTypeResolution() && type.symbol.declarations) { for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 252 /* ClassDeclaration */ || declaration.kind === 253 /* InterfaceDeclaration */) { + if (declaration.kind === 254 /* ClassDeclaration */ || declaration.kind === 255 /* InterfaceDeclaration */) { reportCircularBaseType(declaration, type); } } @@ -52173,29 +53937,31 @@ var ts; } function resolveBaseTypesOfInterface(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray; - for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 253 /* 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)); - if (baseType !== errorType) { - if (isValidBaseType(baseType)) { - if (type !== baseType && !hasBaseType(baseType, type)) { - if (type.resolvedBaseTypes === ts.emptyArray) { - type.resolvedBaseTypes = [baseType]; + if (type.symbol.declarations) { + for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 255 /* 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)); + if (baseType !== errorType) { + if (isValidBaseType(baseType)) { + if (type !== baseType && !hasBaseType(baseType, type)) { + if (type.resolvedBaseTypes === ts.emptyArray) { + type.resolvedBaseTypes = [baseType]; + } + else { + type.resolvedBaseTypes.push(baseType); + } } else { - type.resolvedBaseTypes.push(baseType); + reportCircularBaseType(declaration, type); } } else { - reportCircularBaseType(declaration, type); + error(node, ts.Diagnostics.An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_members); } } - else { - error(node, ts.Diagnostics.An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_members); - } } } } @@ -52209,9 +53975,12 @@ var ts; * and if none of the base interfaces have a "this" type. */ function isThislessInterface(symbol) { + if (!symbol.declarations) { + return true; + } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 253 /* InterfaceDeclaration */) { + if (declaration.kind === 255 /* InterfaceDeclaration */) { if (declaration.flags & 128 /* ContainsThis */) { return false; } @@ -52236,7 +54005,7 @@ var ts; var originalLinks = links; if (!links.declaredType) { var kind = symbol.flags & 32 /* Class */ ? 1 /* Class */ : 2 /* Interface */; - var merged = mergeJSSymbols(symbol, getAssignedClassSymbol(symbol.valueDeclaration)); + var merged = mergeJSSymbols(symbol, symbol.valueDeclaration && getAssignedClassSymbol(symbol.valueDeclaration)); if (merged) { // note:we overwrite links because we just cloned the symbol symbol = links = merged; @@ -52266,6 +54035,7 @@ var ts; return links.declaredType; } function getDeclaredTypeOfTypeAlias(symbol) { + var _a; var links = getSymbolLinks(symbol); if (!links.declaredType) { // Note that we use the links object as the target here because the symbol object is used as the unique @@ -52273,7 +54043,7 @@ var ts; if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { return errorType; } - var declaration = ts.Debug.checkDefined(ts.find(symbol.declarations, ts.isTypeAlias), "Type alias symbol with no valid declaration found"); + 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"); var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type; // If typeNode is missing, we will error in checkJSDocTypedefTag. var type = typeNode ? getTypeFromTypeNode(typeNode) : errorType; @@ -52289,7 +54059,12 @@ var ts; } else { type = errorType; - error(ts.isNamedDeclaration(declaration) ? declaration.name : declaration || declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); + if (declaration.kind === 333 /* 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)); + } } links.declaredType = type; } @@ -52299,7 +54074,7 @@ var ts; if (ts.isStringLiteralLike(expr)) { return true; } - else if (expr.kind === 216 /* BinaryExpression */) { + else if (expr.kind === 218 /* BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -52314,12 +54089,12 @@ var ts; case 8 /* NumericLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return true; - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return expr.operator === 40 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; - case 78 /* Identifier */: + case 79 /* Identifier */: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -52331,16 +54106,18 @@ var ts; return links.enumKind; } var hasNonLiteralMember = false; - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 255 /* 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 */; - } - if (!isLiteralEnumMember(member)) { - hasNonLiteralMember = true; + if (symbol.declarations) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 257 /* 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 */; + } + if (!isLiteralEnumMember(member)) { + hasNonLiteralMember = true; + } } } } @@ -52358,15 +54135,17 @@ var ts; if (getEnumKind(symbol) === 1 /* Literal */) { enumCount++; var memberTypeList = []; - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 255 /* EnumDeclaration */) { - for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { - var member = _c[_b]; - var value = getEnumMemberValue(member); - var memberType = getFreshTypeOfLiteralType(getLiteralType(value !== undefined ? value : 0, enumCount, getSymbolOfNode(member))); - getSymbolLinks(getSymbolOfNode(member)).declaredType = memberType; - memberTypeList.push(getRegularTypeOfLiteralType(memberType)); + if (symbol.declarations) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 257 /* EnumDeclaration */) { + for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { + var member = _c[_b]; + var value = getEnumMemberValue(member); + var memberType = getFreshTypeOfLiteralType(getLiteralType(value !== undefined ? value : 0, enumCount, getSymbolOfNode(member))); + getSymbolLinks(getSymbolOfNode(member)).declaredType = memberType; + memberTypeList.push(getRegularTypeOfLiteralType(memberType)); + } } } } @@ -52432,22 +54211,22 @@ var ts; */ function isThislessType(node) { switch (node.kind) { - case 128 /* AnyKeyword */: - case 152 /* UnknownKeyword */: - case 147 /* StringKeyword */: - case 144 /* NumberKeyword */: - case 155 /* BigIntKeyword */: - case 131 /* BooleanKeyword */: - case 148 /* SymbolKeyword */: - case 145 /* ObjectKeyword */: - case 113 /* VoidKeyword */: - case 150 /* UndefinedKeyword */: - case 141 /* NeverKeyword */: - case 191 /* LiteralType */: + case 129 /* AnyKeyword */: + case 153 /* UnknownKeyword */: + case 148 /* StringKeyword */: + case 145 /* NumberKeyword */: + case 156 /* BigIntKeyword */: + case 132 /* BooleanKeyword */: + case 149 /* SymbolKeyword */: + case 146 /* ObjectKeyword */: + case 114 /* VoidKeyword */: + case 151 /* UndefinedKeyword */: + case 142 /* NeverKeyword */: + case 193 /* LiteralType */: return true; - case 178 /* ArrayType */: + case 180 /* ArrayType */: return isThislessType(node.elementType); - case 173 /* TypeReference */: + case 175 /* TypeReference */: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -52473,7 +54252,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 166 /* Constructor */ || (!!returnType && isThislessType(returnType))) && + return (node.kind === 168 /* Constructor */ || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -52489,14 +54268,14 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: return isThislessVariableLikeDeclaration(declaration); - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return isThislessFunctionLikeDeclaration(declaration); } } @@ -52522,7 +54301,7 @@ var ts; } } function isStaticPrivateIdentifierProperty(s) { - return !!s.valueDeclaration && ts.isPrivateIdentifierPropertyDeclaration(s.valueDeclaration) && ts.hasSyntacticModifier(s.valueDeclaration, 32 /* Static */); + return !!s.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(s.valueDeclaration) && ts.hasSyntacticModifier(s.valueDeclaration, 32 /* Static */); } function resolveDeclaredMembers(type) { if (!type.declaredProperties) { @@ -52574,10 +54353,10 @@ var ts; return !!name && isLateBindableName(name); } /** - * Indicates whether a declaration has a dynamic name that cannot be late-bound. + * Indicates whether a declaration has an early-bound name or a dynamic name that can be late-bound. */ - function hasNonBindableDynamicName(node) { - return ts.hasDynamicName(node) && !hasLateBindableName(node); + function hasBindableName(node) { + return !ts.hasDynamicName(node) || hasLateBindableName(node); } /** * Indicates whether a declaration name is a dynamic name that cannot be late-bound. @@ -52847,7 +54626,8 @@ var ts; sig.resolvedMinArgumentCount = undefined; sig.target = undefined; sig.mapper = undefined; - sig.unionSignatures = undefined; + sig.compositeSignatures = undefined; + sig.compositeKind = undefined; return sig; } function cloneSignature(sig) { @@ -52855,12 +54635,14 @@ var ts; /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* PropagatingFlags */); result.target = sig.target; result.mapper = sig.mapper; - result.unionSignatures = sig.unionSignatures; + result.compositeSignatures = sig.compositeSignatures; + result.compositeKind = sig.compositeKind; return result; } function createUnionSignature(signature, unionSignatures) { var result = cloneSignature(signature); - result.unionSignatures = unionSignatures; + result.compositeSignatures = unionSignatures; + result.compositeKind = 1048576 /* Union */; result.target = undefined; result.mapper = undefined; return result; @@ -53019,7 +54801,7 @@ var ts; if (signatures !== masterList) { var signature_1 = signatures[0]; ts.Debug.assert(!!signature_1, "getUnionSignatures bails early on empty signature lists and should not have empty lists on second pass"); - results = signature_1.typeParameters && ts.some(results, function (s) { return !!s.typeParameters && !compareTypeParametersIdentical(signature_1.typeParameters, s.typeParameters); }) ? undefined : ts.map(results, function (sig) { return combineSignaturesOfUnionMembers(sig, signature_1); }); + results = !!signature_1.typeParameters && ts.some(results, function (s) { return !!s.typeParameters && !compareTypeParametersIdentical(signature_1.typeParameters, s.typeParameters); }) ? undefined : ts.map(results, function (sig) { return combineSignaturesOfUnionMembers(sig, signature_1); }); if (!results) { return "break"; } @@ -53036,9 +54818,12 @@ var ts; return result || ts.emptyArray; } function compareTypeParametersIdentical(sourceParams, targetParams) { - if (sourceParams.length !== targetParams.length) { + if (ts.length(sourceParams) !== ts.length(targetParams)) { return false; } + if (!sourceParams || !targetParams) { + return true; + } var mapper = createTypeMapper(targetParams, sourceParams); for (var i = 0; i < sourceParams.length; i++) { var source = sourceParams[i]; @@ -53120,9 +54905,10 @@ var ts; var result = createSignature(declaration, typeParams, thisParam, params, /*resolvedReturnType*/ undefined, /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* PropagatingFlags */); - result.unionSignatures = ts.concatenate(left.unionSignatures || [left], [right]); + result.compositeKind = 1048576 /* Union */; + result.compositeSignatures = ts.concatenate(left.compositeKind !== 2097152 /* Intersection */ && left.compositeSignatures || [left], [right]); if (paramMapper) { - result.mapper = left.mapper && left.unionSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; + result.mapper = left.compositeKind !== 2097152 /* Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; } return result; } @@ -53255,6 +55041,7 @@ var ts; // Combinations of function, class, enum and module var members = emptySymbols; var stringIndexInfo = void 0; + var numberIndexInfo = void 0; if (symbol.exports) { members = getExportsOfSymbol(symbol); if (symbol === globalThisSymbol) { @@ -53267,20 +55054,31 @@ var ts; members = varsOnly_1; } } + var baseConstructorIndexInfo = void 0; setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, undefined, undefined); if (symbol.flags & 32 /* Class */) { var classType = getDeclaredTypeOfClassOrInterface(symbol); var baseConstructorType = getBaseConstructorTypeOfClass(classType); if (baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 8650752 /* TypeVariable */)) { - members = ts.createSymbolTable(getNamedMembers(members)); + members = ts.createSymbolTable(getNamedOrIndexSignatureMembers(members)); addInheritedMembers(members, getPropertiesOfType(baseConstructorType)); } else if (baseConstructorType === anyType) { - stringIndexInfo = createIndexInfo(anyType, /*isReadonly*/ false); + baseConstructorIndexInfo = createIndexInfo(anyType, /*isReadonly*/ false); + } + } + var indexSymbol = getIndexSymbolFromSymbolTable(members); + if (indexSymbol) { + stringIndexInfo = getIndexInfoOfIndexSymbol(indexSymbol, 0 /* String */); + numberIndexInfo = getIndexInfoOfIndexSymbol(indexSymbol, 1 /* Number */); + } + else { + stringIndexInfo = baseConstructorIndexInfo; + if (symbol.flags & 384 /* Enum */ && (getDeclaredTypeOfSymbol(symbol).flags & 32 /* Enum */ || + ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296 /* NumberLike */); }))) { + numberIndexInfo = enumNumberIndexInfo; } } - var numberIndexInfo = symbol.flags & 384 /* Enum */ && (getDeclaredTypeOfSymbol(symbol).flags & 32 /* Enum */ || - ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296 /* NumberLike */); })) ? enumNumberIndexInfo : undefined; setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); // We resolve the members before computing the signatures because a signature may use // typeof with a qualified name expression that circularly references the type we are @@ -53305,6 +55103,18 @@ var ts; } } } + function replaceIndexedAccess(instantiable, type, replacement) { + // map type.indexType to 0 + // map type.objectType to `[TReplacement]` + // thus making the indexed access `[TReplacement][0]` or `TReplacement` + return instantiateType(instantiable, createTypeMapper([type.indexType, type.objectType], [getLiteralType(0), createTupleType([replacement])])); + } + function getIndexInfoOfIndexSymbol(indexSymbol, indexKind) { + var declaration = getIndexDeclarationOfIndexSymbol(indexSymbol, indexKind); + if (!declaration) + return undefined; + return createIndexInfo(declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasEffectiveModifier(declaration, 64 /* Readonly */), declaration); + } function resolveReverseMappedTypeMembers(type) { var indexInfo = getIndexInfoOfType(type.source, 0 /* String */); var modifiers = getMappedTypeModifiers(type.mappedType); @@ -53319,8 +55129,21 @@ var ts; inferredProp.declarations = prop.declarations; inferredProp.nameType = getSymbolLinks(prop).nameType; inferredProp.propertyType = getTypeOfSymbol(prop); - inferredProp.mappedType = type.mappedType; - inferredProp.constraintType = type.constraintType; + if (type.constraintType.type.flags & 8388608 /* IndexedAccess */ + && type.constraintType.type.objectType.flags & 262144 /* TypeParameter */ + && type.constraintType.type.indexType.flags & 262144 /* 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 + var newTypeParam = type.constraintType.type.objectType; + var newMappedType = replaceIndexedAccess(type.mappedType, type.constraintType.type, newTypeParam); + inferredProp.mappedType = newMappedType; + inferredProp.constraintType = getIndexType(newTypeParam); + } + else { + inferredProp.mappedType = type.mappedType; + inferredProp.constraintType = type.constraintType; + } members.set(prop.escapedName, inferredProp); } setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, undefined); @@ -53447,7 +55270,7 @@ 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) : + var type = strictNullChecks && symbol.flags & 16777216 /* Optional */ && !maybeTypeOfKind(propType, 32768 /* Undefined */ | 16384 /* Void */) ? getOptionalType(propType, /*isProperty*/ true) : symbol.checkFlags & 524288 /* StripOptional */ ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : propType; if (!popTypeResolution()) { @@ -53474,7 +55297,7 @@ var ts; function getTemplateTypeFromMappedType(type) { return type.templateType || (type.templateType = type.declaration.type ? - instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), type.mapper) : + instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), /*isProperty*/ true, !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), type.mapper) : errorType); } function getConstraintDeclarationForMappedType(type) { @@ -53482,8 +55305,8 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 188 /* TypeOperator */ && - constraintDeclaration.operator === 138 /* KeyOfKeyword */; + return constraintDeclaration.kind === 190 /* TypeOperator */ && + constraintDeclaration.operator === 139 /* KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { @@ -53534,7 +55357,7 @@ var ts; else if (type.objectFlags & 3 /* ClassOrInterface */) { resolveClassOrInterfaceMembers(type); } - else if (type.objectFlags & 2048 /* ReverseMapped */) { + else if (type.objectFlags & 1024 /* ReverseMapped */) { resolveReverseMappedTypeMembers(type); } else if (type.objectFlags & 16 /* Anonymous */) { @@ -53650,14 +55473,14 @@ var ts; function getConstraintFromIndexedAccess(type) { var indexConstraint = getSimplifiedTypeOrConstraint(type.indexType); if (indexConstraint && indexConstraint !== type.indexType) { - var indexedAccess = getIndexedAccessTypeOrUndefined(type.objectType, indexConstraint, type.noUncheckedIndexedAccessCandidate); + var indexedAccess = getIndexedAccessTypeOrUndefined(type.objectType, indexConstraint, type.accessFlags); if (indexedAccess) { return indexedAccess; } } var objectConstraint = getSimplifiedTypeOrConstraint(type.objectType); if (objectConstraint && objectConstraint !== type.objectType) { - return getIndexedAccessTypeOrUndefined(objectConstraint, type.indexType, type.noUncheckedIndexedAccessCandidate); + return getIndexedAccessTypeOrUndefined(objectConstraint, type.indexType, type.accessFlags); } return undefined; } @@ -53818,12 +55641,22 @@ var ts; if (t.flags & 3145728 /* UnionOrIntersection */) { var types = t.types; var baseTypes = []; + var different = false; for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { var type_3 = types_8[_i]; var baseType = getBaseConstraint(type_3); if (baseType) { + if (baseType !== type_3) { + different = true; + } baseTypes.push(baseType); } + else { + different = true; + } + } + if (!different) { + return t; } return t.flags & 1048576 /* Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) : t.flags & 2097152 /* Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) : @@ -53844,7 +55677,7 @@ var ts; if (t.flags & 8388608 /* IndexedAccess */) { var baseObjectType = getBaseConstraint(t.objectType); var baseIndexType = getBaseConstraint(t.indexType); - var baseIndexedAccess = baseObjectType && baseIndexType && getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, t.noUncheckedIndexedAccessCandidate); + var baseIndexedAccess = baseObjectType && baseIndexType && getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, t.accessFlags); return baseIndexedAccess && getBaseConstraint(baseIndexedAccess); } if (t.flags & 16777216 /* Conditional */) { @@ -53943,6 +55776,7 @@ var ts; return getReducedType(getApparentType(getReducedType(type))); } function createUnionOrIntersectionProperty(containingType, name, skipObjectFunctionPropertyAugment) { + var _a, _b; var singleProp; var propSet; var indexTypes; @@ -53951,8 +55785,9 @@ var ts; var optionalFlag = isUnion ? 0 /* None */ : 16777216 /* Optional */; var syntheticFlag = 4 /* SyntheticMethod */; var checkFlags = 0; - for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { - var current = _a[_i]; + var mergedInstantiations = false; + for (var _i = 0, _c = containingType.types; _i < _c.length; _i++) { + var current = _c[_i]; var type = getApparentType(current); if (!(type === errorType || type.flags & 131072 /* Never */)) { var prop = getPropertyOfType(type, name, skipObjectFunctionPropertyAugment); @@ -53968,13 +55803,25 @@ var ts; singleProp = prop; } else if (prop !== singleProp) { - if (!propSet) { - propSet = new ts.Map(); - propSet.set(getSymbolId(singleProp), singleProp); + var isInstantiation = (getTargetSymbol(prop) || prop) === (getTargetSymbol(singleProp) || singleProp); + // 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 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[]` + mergedInstantiations = !!singleProp.parent && !!ts.length(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(singleProp.parent)); } - var id = getSymbolId(prop); - if (!propSet.has(id)) { - propSet.set(id, prop); + else { + if (!propSet) { + propSet = new ts.Map(); + propSet.set(getSymbolId(singleProp), singleProp); + } + var id = getSymbolId(prop); + if (!propSet.has(id)) { + propSet.set(id, prop); + } } } checkFlags |= (isReadonlySymbol(prop) ? 8 /* Readonly */ : 0) | @@ -53992,7 +55839,7 @@ var ts; checkFlags |= 32 /* WritePartial */ | (indexInfo.isReadonly ? 8 /* Readonly */ : 0); indexTypes = ts.append(indexTypes, isTupleType(type) ? getRestTypeOfTupleType(type) || undefinedType : indexInfo.type); } - else if (isObjectLiteralType(type)) { + else if (isObjectLiteralType(type) && !(ts.getObjectFlags(type) & 4194304 /* ContainsSpread */)) { checkFlags |= 32 /* WritePartial */; indexTypes = ts.append(indexTypes, undefinedType); } @@ -54008,7 +55855,19 @@ var ts; return undefined; } if (!propSet && !(checkFlags & 16 /* ReadPartial */) && !indexTypes) { - return singleProp; + 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!) + // They also have a `.containingType` set, which affects some services endpoints behavior, like `getRootSymbol` + var clone_1 = createSymbolWithType(singleProp, singleProp.type); + clone_1.parent = (_b = (_a = singleProp.valueDeclaration) === null || _a === void 0 ? void 0 : _a.symbol) === null || _b === void 0 ? void 0 : _b.parent; + clone_1.containingType = containingType; + clone_1.mapper = singleProp.mapper; + return clone_1; + } + else { + return singleProp; + } } var props = propSet ? ts.arrayFrom(propSet.values()) : [singleProp]; var declarations; @@ -54017,8 +55876,8 @@ var ts; var propTypes = []; var firstValueDeclaration; var hasNonUniformValueDeclaration = false; - for (var _b = 0, props_1 = props; _b < props_1.length; _b++) { - var prop = props_1[_b]; + for (var _d = 0, props_1 = props; _d < props_1.length; _d++) { + var prop = props_1[_d]; if (!firstValueDeclaration) { firstValueDeclaration = prop.valueDeclaration; } @@ -54095,15 +55954,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 & 268435456 /* ContainsIntersections */) { + if (type.flags & 1048576 /* Union */ && type.objectFlags & 67108864 /* ContainsIntersections */) { return type.resolvedReducedType || (type.resolvedReducedType = getReducedUnionType(type)); } else if (type.flags & 2097152 /* Intersection */) { - if (!(type.objectFlags & 268435456 /* IsNeverIntersectionComputed */)) { - type.objectFlags |= 268435456 /* IsNeverIntersectionComputed */ | - (ts.some(getPropertiesOfUnionOrIntersectionType(type), isNeverReducedProperty) ? 536870912 /* IsNeverIntersection */ : 0); + if (!(type.objectFlags & 67108864 /* IsNeverIntersectionComputed */)) { + type.objectFlags |= 67108864 /* IsNeverIntersectionComputed */ | + (ts.some(getPropertiesOfUnionOrIntersectionType(type), isNeverReducedProperty) ? 134217728 /* IsNeverIntersection */ : 0); } - return type.objectFlags & 536870912 /* IsNeverIntersection */ ? neverType : type; + return type.objectFlags & 134217728 /* IsNeverIntersection */ ? neverType : type; } return type; } @@ -54133,7 +55992,7 @@ var ts; return !prop.valueDeclaration && !!(ts.getCheckFlags(prop) & 1024 /* ContainsPrivate */); } function elaborateNeverIntersection(errorInfo, type) { - if (ts.getObjectFlags(type) & 536870912 /* IsNeverIntersection */) { + if (type.flags & 2097152 /* Intersection */ && ts.getObjectFlags(type) & 134217728 /* 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)); @@ -54220,7 +56079,8 @@ var ts; for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) { var prop = _a[_i]; if (kind === 0 /* String */ || isNumericLiteralName(prop.escapedName)) { - propTypes.push(getTypeOfSymbol(prop)); + var propType = getTypeOfSymbol(prop); + propTypes.push(prop.flags & 16777216 /* Optional */ ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : propType); } } if (kind === 0 /* String */) { @@ -54254,10 +56114,10 @@ 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 === 307 /* JSDocOptionalType */ + node.type && node.type.kind === 310 /* JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 307 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 310 /* JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -54289,12 +56149,15 @@ var ts; } return false; } + function isOptionalPropertyDeclaration(node) { + return ts.isPropertyDeclaration(node) && node.questionToken; + } function isOptionalJSDocPropertyLikeTag(node) { if (!ts.isJSDocPropertyLikeTag(node)) { return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 307 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 310 /* JSDocOptionalType */; } function createTypePredicate(kind, parameterName, parameterIndex, type) { return { kind: kind, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; @@ -54376,7 +56239,7 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 191 /* LiteralType */) { + if (type && type.kind === 193 /* LiteralType */) { flags |= 2 /* HasLiteralTypes */; } // Record a new minimum argument count if this is not an optional parameter @@ -54389,16 +56252,16 @@ 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 === 167 /* GetAccessor */ || declaration.kind === 168 /* SetAccessor */) && - !hasNonBindableDynamicName(declaration) && + if ((declaration.kind === 169 /* GetAccessor */ || declaration.kind === 170 /* SetAccessor */) && + hasBindableName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 167 /* GetAccessor */ ? 168 /* SetAccessor */ : 167 /* GetAccessor */; + var otherKind = declaration.kind === 169 /* GetAccessor */ ? 170 /* SetAccessor */ : 169 /* GetAccessor */; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 166 /* Constructor */ ? + var classType = declaration.kind === 168 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); @@ -54443,8 +56306,7 @@ var ts; if (!(ts.isInJSFile(node) && ts.isFunctionLikeDeclaration(node))) return undefined; var typeTag = ts.getJSDocTypeTag(node); - var signature = typeTag && typeTag.typeExpression && getSingleCallSignature(getTypeFromTypeNode(typeTag.typeExpression)); - return signature && getErasedSignature(signature); + return (typeTag === null || typeTag === void 0 ? void 0 : typeTag.typeExpression) && getSingleCallSignature(getTypeFromTypeNode(typeTag.typeExpression)); } function getReturnTypeOfTypeTag(node) { var signature = getSignatureOfTypeTag(node); @@ -54465,16 +56327,16 @@ var ts; if (!node) return false; switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return node.escapedText === argumentsSymbol.escapedName && getResolvedSymbol(node) === argumentsSymbol; - case 163 /* PropertyDeclaration */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - return node.name.kind === 158 /* ComputedPropertyName */ + case 165 /* PropertyDeclaration */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + return node.name.kind === 160 /* ComputedPropertyName */ && traverse(node.name); - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: return traverse(node.expression); default: return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); @@ -54482,7 +56344,7 @@ var ts; } } function getSignaturesOfSymbol(symbol) { - if (!symbol) + if (!symbol || !symbol.declarations) return ts.emptyArray; var result = []; for (var i = 0; i < symbol.declarations.length; i++) { @@ -54523,8 +56385,8 @@ var ts; var targetTypePredicate = getTypePredicateOfSignature(signature.target); signature.resolvedTypePredicate = targetTypePredicate ? instantiateTypePredicate(targetTypePredicate, signature.mapper) : noTypePredicate; } - else if (signature.unionSignatures) { - signature.resolvedTypePredicate = getUnionTypePredicate(signature.unionSignatures) || noTypePredicate; + else if (signature.compositeSignatures) { + signature.resolvedTypePredicate = getUnionOrIntersectionTypePredicate(signature.compositeSignatures, signature.compositeKind) || noTypePredicate; } else { var type = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); @@ -54546,17 +56408,20 @@ var ts; function createTypePredicateFromTypePredicateNode(node, signature) { var parameterName = node.parameterName; var type = node.type && getTypeFromTypeNode(node.type); - return parameterName.kind === 187 /* ThisType */ ? + return parameterName.kind === 189 /* 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); } + function getUnionOrIntersectionType(types, kind, unionReduction) { + return kind !== 2097152 /* Intersection */ ? getUnionType(types, unionReduction) : getIntersectionType(types); + } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { if (!pushTypeResolution(signature, 3 /* ResolvedReturnType */)) { return errorType; } var type = signature.target ? instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper) : - signature.unionSignatures ? instantiateType(getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature), 2 /* Subtype */), signature.mapper) : + signature.compositeSignatures ? instantiateType(getUnionOrIntersectionType(ts.map(signature.compositeSignatures, getReturnTypeOfSignature), signature.compositeKind, 2 /* Subtype */), signature.mapper) : getReturnTypeFromAnnotation(signature.declaration) || (ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration)); if (signature.flags & 8 /* IsInnerCallChain */) { @@ -54589,7 +56454,7 @@ var ts; return signature.resolvedReturnType; } function getReturnTypeFromAnnotation(declaration) { - if (declaration.kind === 166 /* Constructor */) { + if (declaration.kind === 168 /* Constructor */) { return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)); } if (ts.isJSDocConstructSignature(declaration)) { @@ -54599,12 +56464,12 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 167 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { + if (declaration.kind === 169 /* GetAccessor */ && hasBindableName(declaration)) { var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration); if (jsDocType) { return jsDocType; } - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 168 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 170 /* SetAccessor */); var setterType = getAnnotatedAccessorType(setter); if (setterType) { return setterType; @@ -54681,9 +56546,20 @@ var ts; function getBaseSignature(signature) { var typeParameters = signature.typeParameters; if (typeParameters) { - var typeEraser_1 = createTypeEraser(typeParameters); - var baseConstraints = ts.map(typeParameters, function (tp) { return instantiateType(getBaseConstraintOfType(tp), typeEraser_1) || unknownType; }); - return instantiateSignature(signature, createTypeMapper(typeParameters, baseConstraints), /*eraseTypeParameters*/ true); + if (signature.baseSignatureCache) { + return signature.baseSignatureCache; + } + var typeEraser = createTypeEraser(typeParameters); + var baseConstraintMapper_1 = createTypeMapper(typeParameters, ts.map(typeParameters, function (tp) { return getConstraintOfTypeParameter(tp) || unknownType; })); + var baseConstraints = ts.map(typeParameters, function (tp) { return instantiateType(tp, baseConstraintMapper_1) || unknownType; }); + // Run N type params thru the immediate constraint mapper up to N times + // This way any noncircular interdependent type parameters are definitely resolved to their external dependencies + for (var i = 0; i < typeParameters.length - 1; i++) { + baseConstraints = instantiateTypes(baseConstraints, baseConstraintMapper_1); + } + // and then apply a type eraser to remove any remaining circularly dependent type parameters + baseConstraints = instantiateTypes(baseConstraints, typeEraser); + return signature.baseSignatureCache = instantiateSignature(signature, createTypeMapper(typeParameters, baseConstraints), /*eraseTypeParameters*/ true); } return signature; } @@ -54694,7 +56570,7 @@ var ts; // will result in a different declaration kind. if (!signature.isolatedSignatureType) { var kind = signature.declaration ? signature.declaration.kind : 0 /* Unknown */; - var isConstructor = kind === 166 /* Constructor */ || kind === 170 /* ConstructSignature */ || kind === 175 /* ConstructorType */; + var isConstructor = kind === 168 /* Constructor */ || kind === 172 /* ConstructSignature */ || kind === 177 /* ConstructorType */; var type = createObjectType(16 /* Anonymous */); type.members = emptySymbols; type.properties = ts.emptyArray; @@ -54705,12 +56581,22 @@ var ts; return signature.isolatedSignatureType; } function getIndexSymbol(symbol) { - return symbol.members.get("__index" /* Index */); + return symbol.members ? getIndexSymbolFromSymbolTable(symbol.members) : undefined; + } + function getIndexSymbolFromSymbolTable(symbolTable) { + return symbolTable.get("__index" /* Index */); } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 144 /* NumberKeyword */ : 147 /* StringKeyword */; - var indexSymbol = getIndexSymbol(symbol); - if (indexSymbol) { + var indexSymbol = symbol && getIndexSymbol(symbol); + return indexSymbol && getIndexDeclarationOfIndexSymbol(indexSymbol, kind); + } + function getIndexDeclarationOfSymbolTable(symbolTable, kind) { + var indexSymbol = symbolTable && getIndexSymbolFromSymbolTable(symbolTable); + return indexSymbol && getIndexDeclarationOfIndexSymbol(indexSymbol, kind); + } + function getIndexDeclarationOfIndexSymbol(indexSymbol, kind) { + var syntaxKind = kind === 1 /* Number */ ? 145 /* NumberKeyword */ : 148 /* StringKeyword */; + if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; var node = ts.cast(decl, ts.isIndexSignatureDeclaration); @@ -54738,17 +56624,18 @@ var ts; return ts.mapDefined(ts.filter(type.symbol && type.symbol.declarations, ts.isTypeParameterDeclaration), ts.getEffectiveConstraintOfTypeParameter)[0]; } function getInferredTypeParameterConstraint(typeParameter) { + var _a; var inferences; - if (typeParameter.symbol) { - for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.parent.kind === 185 /* InferType */) { + 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 === 187 /* 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 _b = ts.walkUpParenthesizedTypesAndGetParentAndChild(declaration.parent.parent), _c = _b[0], childTypeParameter = _c === void 0 ? declaration.parent : _c, grandParent = _b[1]; - if (grandParent.kind === 173 /* TypeReference */) { + var _c = ts.walkUpParenthesizedTypesAndGetParentAndChild(declaration.parent.parent), _d = _c[0], childTypeParameter = _d === void 0 ? declaration.parent : _d, grandParent = _c[1]; + if (grandParent.kind === 175 /* TypeReference */) { var typeReference = grandParent; var typeParameters = getTypeParametersForTypeReference(typeReference); if (typeParameters) { @@ -54773,21 +56660,32 @@ 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 === 160 /* Parameter */ && grandParent.dotDotDotToken || - grandParent.kind === 181 /* RestType */ || - grandParent.kind === 192 /* NamedTupleMember */ && grandParent.dotDotDotToken) { + else if (grandParent.kind === 162 /* Parameter */ && grandParent.dotDotDotToken || + grandParent.kind === 183 /* RestType */ || + grandParent.kind === 194 /* 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 === 194 /* TemplateLiteralTypeSpan */) { + else if (grandParent.kind === 196 /* 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 === 159 /* TypeParameter */ && grandParent.parent.kind === 190 /* MappedType */) { + else if (grandParent.kind === 161 /* TypeParameter */ && grandParent.parent.kind === 192 /* 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 === 192 /* MappedType */ && grandParent.type && + ts.skipParentheses(grandParent.type) === declaration.parent && grandParent.parent.kind === 186 /* ConditionalType */ && + grandParent.parent.extendsType === grandParent && grandParent.parent.checkType.kind === 192 /* 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))); + } } } } @@ -54810,7 +56708,7 @@ var ts; if (type.flags & 1 /* Any */ && type !== errorType) { // 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 === 190 /* MappedType */ ? keyofConstraintType : unknownType; + type = constraintDeclaration.parent.parent.kind === 192 /* MappedType */ ? keyofConstraintType : unknownType; } typeParameter.constraint = type; } @@ -54819,7 +56717,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - var tp = ts.getDeclarationOfKind(typeParameter.symbol, 159 /* TypeParameter */); + var tp = ts.getDeclarationOfKind(typeParameter.symbol, 161 /* TypeParameter */); var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getHostSignatureFromJSDoc(tp.parent) : tp.parent; return host && getSymbolOfNode(host); } @@ -54846,6 +56744,9 @@ var ts; } return result; } + function getAliasId(aliasSymbol, aliasTypeArguments) { + return aliasSymbol ? "@" + getSymbolId(aliasSymbol) + (aliasTypeArguments ? ":" + 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 @@ -54858,7 +56759,7 @@ var ts; result |= ts.getObjectFlags(type); } } - return result & 3670016 /* PropagatingFlags */; + return result & 917504 /* PropagatingFlags */; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); @@ -54880,15 +56781,18 @@ var ts; type.resolvedTypeArguments = source.resolvedTypeArguments; return type; } - function createDeferredTypeReference(target, node, mapper) { - var aliasSymbol = getAliasSymbolForTypeNode(node); - var aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); + function createDeferredTypeReference(target, node, mapper, aliasSymbol, aliasTypeArguments) { + if (!aliasSymbol) { + aliasSymbol = getAliasSymbolForTypeNode(node); + var localAliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); + aliasTypeArguments = mapper ? instantiateTypes(localAliasTypeArguments, mapper) : localAliasTypeArguments; + } var type = createObjectType(4 /* Reference */, target.symbol); type.target = target; type.node = node; type.mapper = mapper; type.aliasSymbol = aliasSymbol; - type.aliasTypeArguments = mapper ? instantiateTypes(aliasTypeArguments, mapper) : aliasTypeArguments; + type.aliasTypeArguments = aliasTypeArguments; return type; } function getTypeArguments(type) { @@ -54899,8 +56803,8 @@ var ts; } var node = type.node; var typeArguments = !node ? ts.emptyArray : - node.kind === 173 /* TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : - node.kind === 178 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : + node.kind === 175 /* TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : + node.kind === 180 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); if (popTypeResolution()) { type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments; @@ -54942,7 +56846,7 @@ var ts; return errorType; } } - if (node.kind === 173 /* TypeReference */ && isDeferredTypeReferenceNode(node, ts.length(node.typeArguments) !== typeParameters.length)) { + if (node.kind === 175 /* 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 @@ -54953,17 +56857,17 @@ var ts; } return checkNoTypeArguments(node, symbol) ? type : errorType; } - function getTypeAliasInstantiation(symbol, typeArguments) { + function getTypeAliasInstantiation(symbol, typeArguments, aliasSymbol, aliasTypeArguments) { var type = getDeclaredTypeOfSymbol(symbol); if (type === intrinsicMarkerType && intrinsicTypeKinds.has(symbol.escapedName) && typeArguments && typeArguments.length === 1) { return getStringMappingType(symbol, typeArguments[0]); } var links = getSymbolLinks(symbol); var typeParameters = links.typeParameters; - var id = getTypeListId(typeArguments); + var id = getTypeListId(typeArguments) + getAliasId(aliasSymbol, aliasTypeArguments); var instantiation = links.instantiations.get(id); if (!instantiation) { - links.instantiations.set(id, instantiation = instantiateType(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters), ts.isInJSFile(symbol.valueDeclaration))))); + links.instantiations.set(id, instantiation = instantiateTypeWithAlias(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters), ts.isInJSFile(symbol.valueDeclaration))), aliasSymbol, aliasTypeArguments)); } return instantiation; } @@ -54984,15 +56888,26 @@ var ts; ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); return errorType; } - return getTypeAliasInstantiation(symbol, typeArgumentsFromTypeReferenceNode(node)); + // We refrain from associating a local type alias with an instantiation of a top-level type alias + // because the local alias may end up being referenced in an inferred return type where it is not + // accessible--which in turn may lead to a large structural expansion of the type when generating + // a .d.ts file. See #43622 for an example. + var aliasSymbol = getAliasSymbolForTypeNode(node); + var newAliasSymbol = aliasSymbol && (isLocalTypeAlias(symbol) || !isLocalTypeAlias(aliasSymbol)) ? aliasSymbol : undefined; + return getTypeAliasInstantiation(symbol, typeArgumentsFromTypeReferenceNode(node), newAliasSymbol, getTypeArgumentsForAliasSymbol(newAliasSymbol)); } return checkNoTypeArguments(node, symbol) ? type : errorType; } + function isLocalTypeAlias(symbol) { + var _a; + var declaration = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isTypeAlias); + return !!(declaration && ts.getContainingFunction(declaration)); + } function getTypeReferenceName(node) { switch (node.kind) { - case 173 /* TypeReference */: + case 175 /* TypeReference */: return node.typeName; - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -55048,7 +56963,7 @@ var ts; var valueType = getTypeOfSymbol(symbol); var typeType = valueType; if (symbol.valueDeclaration) { - var isImportTypeWithQualifier = node.kind === 195 /* ImportType */ && node.qualifier; + var isImportTypeWithQualifier = node.kind === 197 /* 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); @@ -55074,7 +56989,7 @@ var ts; return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 179 /* TupleType */ && node.elements.length === 1; + return node.kind === 181 /* TupleType */ && node.elements.length === 1; } function getImpliedConstraint(type, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(type, checkNode.elements[0], extendsNode.elements[0]) : @@ -55083,9 +56998,17 @@ var ts; } function getConditionalFlowTypeOfType(type, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 311 /* JSDocComment */) { + var covariant = true; + while (node && !ts.isStatement(node) && node.kind !== 314 /* JSDocComment */) { var parent = node.parent; - if (parent.kind === 184 /* ConditionalType */ && node === parent.trueType) { + // 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 === 162 /* 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 === 186 /* ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(type, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -55096,7 +57019,7 @@ var ts; return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type; } function isJSDocTypeReference(node) { - return !!(node.flags & 4194304 /* JSDoc */) && (node.kind === 173 /* TypeReference */ || node.kind === 195 /* ImportType */); + return !!(node.flags & 4194304 /* JSDoc */) && (node.kind === 175 /* TypeReference */ || node.kind === 197 /* ImportType */); } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -55206,13 +57129,15 @@ var ts; function getTypeOfGlobalSymbol(symbol, arity) { function getTypeDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { - var declaration = declarations_3[_i]; - switch (declaration.kind) { - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - return declaration; + if (declarations) { + for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { + var declaration = declarations_3[_i]; + switch (declaration.kind) { + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 257 /* EnumDeclaration */: + return declaration; + } } } } @@ -55256,6 +57181,9 @@ var ts; function getGlobalESSymbolConstructorSymbol(reportErrors) { return deferredGlobalESSymbolConstructorSymbol || (deferredGlobalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol", reportErrors)); } + function getGlobalESSymbolConstructorTypeSymbol(reportErrors) { + return deferredGlobalESSymbolConstructorTypeSymbol || (deferredGlobalESSymbolConstructorTypeSymbol = getGlobalTypeSymbol("SymbolConstructor", reportErrors)); + } function getGlobalESSymbolType(reportErrors) { return deferredGlobalESSymbolType || (deferredGlobalESSymbolType = getGlobalType("Symbol", /*arity*/ 0, reportErrors)) || emptyObjectType; } @@ -55332,11 +57260,11 @@ var ts; } function getTupleElementFlags(node) { switch (node.kind) { - case 180 /* OptionalType */: + case 182 /* OptionalType */: return 2 /* Optional */; - case 181 /* RestType */: + case 183 /* RestType */: return getRestTypeElementFlags(node); - case 192 /* NamedTupleMember */: + case 194 /* NamedTupleMember */: return node.questionToken ? 2 /* Optional */ : node.dotDotDotToken ? getRestTypeElementFlags(node) : 1 /* Required */; @@ -55354,14 +57282,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 !== 192 /* NamedTupleMember */; }); + var missingName = ts.some(node.elements, function (e) { return e.kind !== 194 /* 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 === 178 /* ArrayType */ ? mayResolveTypeAlias(node.elementType) : - node.kind === 179 /* TupleType */ ? ts.some(node.elements, mayResolveTypeAlias) : + return !!getAliasSymbolForTypeNode(node) || isResolvedByTypeAlias(node) && (node.kind === 180 /* ArrayType */ ? mayResolveTypeAlias(node.elementType) : + node.kind === 181 /* 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 @@ -55370,18 +57298,18 @@ var ts; function isResolvedByTypeAlias(node) { var parent = node.parent; switch (parent.kind) { - case 186 /* ParenthesizedType */: - case 192 /* NamedTupleMember */: - case 173 /* TypeReference */: - case 182 /* UnionType */: - case 183 /* IntersectionType */: - case 189 /* IndexedAccessType */: - case 184 /* ConditionalType */: - case 188 /* TypeOperator */: - case 178 /* ArrayType */: - case 179 /* TupleType */: + case 188 /* ParenthesizedType */: + case 194 /* NamedTupleMember */: + case 175 /* TypeReference */: + case 184 /* UnionType */: + case 185 /* IntersectionType */: + case 191 /* IndexedAccessType */: + case 186 /* ConditionalType */: + case 190 /* TypeOperator */: + case 180 /* ArrayType */: + case 181 /* TupleType */: return isResolvedByTypeAlias(parent); - case 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: return true; } return false; @@ -55390,28 +57318,28 @@ var ts; // of a type alias. function mayResolveTypeAlias(node) { switch (node.kind) { - case 173 /* TypeReference */: + case 175 /* TypeReference */: return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node.typeName, 788968 /* Type */).flags & 524288 /* TypeAlias */); - case 176 /* TypeQuery */: + case 178 /* TypeQuery */: return true; - case 188 /* TypeOperator */: - return node.operator !== 151 /* UniqueKeyword */ && mayResolveTypeAlias(node.type); - case 186 /* ParenthesizedType */: - case 180 /* OptionalType */: - case 192 /* NamedTupleMember */: - case 307 /* JSDocOptionalType */: - case 305 /* JSDocNullableType */: - case 306 /* JSDocNonNullableType */: - case 301 /* JSDocTypeExpression */: + case 190 /* TypeOperator */: + return node.operator !== 152 /* UniqueKeyword */ && mayResolveTypeAlias(node.type); + case 188 /* ParenthesizedType */: + case 182 /* OptionalType */: + case 194 /* NamedTupleMember */: + case 310 /* JSDocOptionalType */: + case 308 /* JSDocNullableType */: + case 309 /* JSDocNonNullableType */: + case 303 /* JSDocTypeExpression */: return mayResolveTypeAlias(node.type); - case 181 /* RestType */: - return node.type.kind !== 178 /* ArrayType */ || mayResolveTypeAlias(node.type.elementType); - case 182 /* UnionType */: - case 183 /* IntersectionType */: + case 183 /* RestType */: + return node.type.kind !== 180 /* ArrayType */ || mayResolveTypeAlias(node.type.elementType); + case 184 /* UnionType */: + case 185 /* IntersectionType */: return ts.some(node.types, mayResolveTypeAlias); - case 189 /* IndexedAccessType */: + case 191 /* IndexedAccessType */: return mayResolveTypeAlias(node.objectType) || mayResolveTypeAlias(node.indexType); - case 184 /* ConditionalType */: + case 186 /* ConditionalType */: return mayResolveTypeAlias(node.checkType) || mayResolveTypeAlias(node.extendsType) || mayResolveTypeAlias(node.trueType) || mayResolveTypeAlias(node.falseType); } @@ -55424,19 +57352,19 @@ var ts; if (target === emptyGenericType) { links.resolvedType = emptyObjectType; } - else if (!(node.kind === 179 /* TupleType */ && ts.some(node.elements, function (e) { return !!(getTupleElementFlags(e) & 8 /* Variadic */); })) && isDeferredTypeReferenceNode(node)) { - links.resolvedType = node.kind === 179 /* TupleType */ && node.elements.length === 0 ? target : + else if (!(node.kind === 181 /* TupleType */ && ts.some(node.elements, function (e) { return !!(getTupleElementFlags(e) & 8 /* Variadic */); })) && isDeferredTypeReferenceNode(node)) { + links.resolvedType = node.kind === 181 /* TupleType */ && node.elements.length === 0 ? target : createDeferredTypeReference(target, node, /*mapper*/ undefined); } else { - var elementTypes = node.kind === 178 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); + var elementTypes = node.kind === 180 /* 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 === 142 /* ReadonlyKeyword */; + return ts.isTypeOperatorNode(node) && node.operator === 143 /* ReadonlyKeyword */; } function createTupleType(elementTypes, elementFlags, readonly, namedMemberDeclarations) { if (readonly === void 0) { readonly = false; } @@ -55561,8 +57489,15 @@ var ts; addElement(type, 8 /* Variadic */, (_a = target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]); } else if (isTupleType(type)) { + var elements = getTypeArguments(type); + if (elements.length + expandedTypes.length >= 10000) { + error(currentNode, ts.isPartOfTypeNode(currentNode) + ? ts.Diagnostics.Type_produces_a_tuple_type_that_is_too_large_to_represent + : ts.Diagnostics.Expression_produces_a_tuple_type_that_is_too_large_to_represent); + return { value: errorType }; + } // Spread variadic elements with tuple types into the resulting tuple. - ts.forEach(getTypeArguments(type), function (t, n) { var _a; return addElement(t, type.target.elementFlags[n], (_a = type.target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[n]); }); + ts.forEach(elements, function (t, n) { var _a; return addElement(t, type.target.elementFlags[n], (_a = type.target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[n]); }); } else { // Treat everything else as an array type and create a rest element. @@ -55575,7 +57510,9 @@ var ts; } }; for (var i = 0; i < elementTypes.length; i++) { - _loop_13(i); + var state_4 = _loop_13(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++) { @@ -55634,8 +57571,7 @@ var ts; return type.elementFlags.length - ts.findLastIndex(type.elementFlags, function (f) { return !(f & flags); }) - 1; } function getTypeFromOptionalTypeNode(node) { - var type = getTypeFromTypeNode(node.type); - return strictNullChecks ? getOptionalType(type) : type; + return addOptionality(getTypeFromTypeNode(node.type), /*isProperty*/ true); } function getTypeId(type) { return type.id; @@ -55664,7 +57600,7 @@ var ts; if (type === wildcardType) includes |= 8388608 /* IncludesWildcard */; if (!strictNullChecks && flags & 98304 /* Nullable */) { - if (!(ts.getObjectFlags(type) & 524288 /* ContainsWideningType */)) + if (!(ts.getObjectFlags(type) & 131072 /* ContainsWideningType */)) includes |= 4194304 /* IncludesNonWideningType */; } else { @@ -55686,67 +57622,76 @@ var ts; } return includes; } - function isSetOfLiteralsFromSameEnum(types) { - var first = types[0]; - if (first.flags & 1024 /* EnumLiteral */) { - var firstEnum = getParentOfSymbol(first.symbol); - for (var i = 1; i < types.length; i++) { - var other = types[i]; - if (!(other.flags & 1024 /* EnumLiteral */) || (firstEnum !== getParentOfSymbol(other.symbol))) { - return false; - } - } - return true; + function removeSubtypes(types, hasObjectTypes) { + var id = getTypeListId(types); + var match = subtypeReductionCache.get(id); + if (match) { + return match; } - return false; - } - function removeSubtypes(types, primitivesOnly) { + // 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 len = types.length; - if (len === 0 || isSetOfLiteralsFromSameEnum(types)) { - return true; - } var i = len; var count = 0; while (i > 0) { i--; var source = types[i]; - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var target = types_11[_i]; - if (source !== target) { - if (count === 100000) { - // After 100000 subtype checks we estimate the remaining amount of work by assuming the - // same ratio of checks per element. If the estimated number of remaining type checks is - // greater than an upper limit we deem the union type too complex to represent. The - // upper limit is 25M for unions of primitives only, and 1M otherwise. This for example - // caps union types at 5000 unique literal types and 1000 unique object types. - var estimatedCount = (count / (len - i)) * len; - if (estimatedCount > (primitivesOnly ? 25000000 : 1000000)) { - ts.tracing.instant("checkTypes" /* 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 false; + if (hasEmptyObject || source.flags & 469499904 /* 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 */) ? + ts.find(getPropertiesOfType(source), function (p) { return isUnitType(getTypeOfSymbol(p)); }) : + undefined; + var keyPropertyType = keyProperty && getRegularTypeOfLiteralType(getTypeOfSymbol(keyProperty)); + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var target = types_11[_i]; + if (source !== target) { + if (count === 100000) { + // After 100000 subtype checks we estimate the remaining amount of work by assuming the + // same ratio of checks per element. If the estimated number of remaining type checks is + // greater than 1M we deem the union type too complex to represent. This for example + // 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; }) }); + 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 */)) { + 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 */) || + isTypeDerivedFrom(source, target))) { + ts.orderedRemoveItemAt(types, i); + break; } - } - count++; - if (isTypeRelatedTo(source, target, strictSubtypeRelation) && (!(ts.getObjectFlags(getTargetType(source)) & 1 /* Class */) || - !(ts.getObjectFlags(getTargetType(target)) & 1 /* Class */) || - isTypeDerivedFrom(source, target))) { - ts.orderedRemoveItemAt(types, i); - break; } } } } - return true; + subtypeReductionCache.set(id, types); + return types; } - function removeRedundantLiteralTypes(types, includes) { + function removeRedundantLiteralTypes(types, includes, reduceVoidUndefined) { var i = types.length; while (i > 0) { i--; var t = types[i]; - var remove = t.flags & 134217856 /* StringLikeLiteral */ && includes & 4 /* String */ || - t.flags & 256 /* NumberLiteral */ && includes & 8 /* Number */ || - t.flags & 2048 /* BigIntLiteral */ && includes & 64 /* BigInt */ || - t.flags & 8192 /* UniqueESSymbol */ && includes & 4096 /* ESSymbol */ || + var flags = t.flags; + var remove = flags & 128 /* StringLiteral */ && 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 */ || isFreshLiteralType(t) && containsType(types, t.regularType); if (remove) { ts.orderedRemoveItemAt(types, i); @@ -55778,7 +57723,7 @@ var ts; if (t.flags & 1048576 /* Union */) { var origin = t.origin; if (t.aliasSymbol || origin && !(origin.flags & 1048576 /* Union */)) { - namedUnions.push(t); + ts.pushIfUnique(namedUnions, t); } else if (origin && origin.flags & 1048576 /* Union */) { addNamedUnions(namedUnions, origin.types); @@ -55812,20 +57757,23 @@ var ts; if (includes & 3 /* AnyOrUnknown */) { return includes & 1 /* Any */ ? includes & 8388608 /* IncludesWildcard */ ? wildcardType : anyType : unknownType; } - switch (unionReduction) { - case 1 /* Literal */: - if (includes & (134220672 /* FreshableLiteral */ | 8192 /* UniqueESSymbol */)) { - removeRedundantLiteralTypes(typeSet, includes); - } - if (includes & 128 /* StringLiteral */ && includes & 134217728 /* TemplateLiteral */) { - removeStringLiteralsMatchedByTemplateLiterals(typeSet); - } - break; - case 2 /* Subtype */: - if (!removeSubtypes(typeSet, !(includes & 262144 /* IncludesStructuredOrInstantiable */))) { - return errorType; - } - break; + if (strictOptionalProperties && includes & 32768 /* 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 */) || includes & 16384 /* Void */ && includes & 32768 /* Undefined */) { + removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2 /* Subtype */)); + } + if (includes & 128 /* StringLiteral */ && includes & 134217728 /* TemplateLiteral */) { + removeStringLiteralsMatchedByTemplateLiterals(typeSet); + } + if (unionReduction === 2 /* Subtype */) { + typeSet = removeSubtypes(typeSet, !!(includes & 524288 /* Object */)); + if (!typeSet) { + return errorType; + } } if (typeSet.length === 0) { return includes & 65536 /* Null */ ? includes & 4194304 /* IncludesNonWideningType */ ? nullType : nullWideningType : @@ -55860,18 +57808,23 @@ var ts; origin = createOriginUnionOrIntersectionType(1048576 /* Union */, reducedTypes); } } - var objectFlags = (includes & 468598819 /* NotPrimitiveUnion */ ? 0 : 262144 /* PrimitiveUnion */) | - (includes & 2097152 /* Intersection */ ? 268435456 /* ContainsIntersections */ : 0); + var objectFlags = (includes & 468598819 /* NotPrimitiveUnion */ ? 0 : 65536 /* PrimitiveUnion */) | + (includes & 2097152 /* Intersection */ ? 67108864 /* ContainsIntersections */ : 0); return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin); } - function getUnionTypePredicate(signatures) { + function getUnionOrIntersectionTypePredicate(signatures, kind) { var first; var types = []; 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 */) { - continue; + if (kind !== 2097152 /* Intersection */) { + continue; + } + else { + return; // intersections demand all members be type predicates for the result to have a predicate + } } if (first) { if (!typePredicateKindsMatch(first, pred)) { @@ -55885,11 +57838,11 @@ var ts; types.push(pred.type); } if (!first) { - // No union signatures had a type predicate. + // No signatures had a type predicate. return undefined; } - var unionType = getUnionType(types); - return createTypePredicate(first.kind, first.parameterName, first.parameterIndex, unionType); + var compositeType = getUnionOrIntersectionType(types, kind); + return createTypePredicate(first.kind, first.parameterName, first.parameterIndex, compositeType); } function typePredicateKindsMatch(a, b) { return a.kind === b.kind && a.parameterIndex === b.parameterIndex; @@ -55914,8 +57867,8 @@ var ts; var typeKey = !origin ? getTypeListId(types) : origin.flags & 1048576 /* Union */ ? "|" + getTypeListId(origin.types) : origin.flags & 2097152 /* Intersection */ ? "&" + getTypeListId(origin.types) : - "#" + origin.type.id; - var id = typeKey + (aliasSymbol ? "@" + getSymbolId(aliasSymbol) : ""); + "#" + 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 + var id = typeKey + getAliasId(aliasSymbol, aliasTypeArguments); var type = unionTypes.get(id); if (!type) { type = createUnionType(types, aliasSymbol, aliasTypeArguments, origin); @@ -56041,7 +57994,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) & 262144 /* PrimitiveUnion */); }); + var index = ts.findIndex(types, function (t) { return !!(ts.getObjectFlags(t) & 65536 /* PrimitiveUnion */); }); if (index < 0) { return false; } @@ -56050,7 +58003,7 @@ var ts; // the unionTypes array. while (i < types.length) { var t = types[i]; - if (ts.getObjectFlags(t) & 262144 /* PrimitiveUnion */) { + if (ts.getObjectFlags(t) & 65536 /* PrimitiveUnion */) { (unionTypes || (unionTypes = [types[index]])).push(t); ts.orderedRemoveItemAt(types, i); } @@ -56079,14 +58032,14 @@ var ts; } } // Finally replace the first union with the result - types[index] = getUnionTypeFromSortedList(result, 262144 /* PrimitiveUnion */); + types[index] = getUnionTypeFromSortedList(result, 65536 /* PrimitiveUnion */); return true; } function createIntersectionType(types, aliasSymbol, aliasTypeArguments) { var result = createType(2097152 /* Intersection */); result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */); result.types = types; - result.aliasSymbol = aliasSymbol; // See comment in `getUnionTypeFromSortedList`. + result.aliasSymbol = aliasSymbol; result.aliasTypeArguments = aliasTypeArguments; return result; } @@ -56147,7 +58100,7 @@ var ts; if (typeSet.length === 1) { return typeSet[0]; } - var id = getTypeListId(typeSet) + (aliasSymbol ? "@" + getSymbolId(aliasSymbol) : ""); + var id = getTypeListId(typeSet) + getAliasId(aliasSymbol, aliasTypeArguments); var result = intersectionTypes.get(id); if (!result) { if (includes & 1048576 /* Union */) { @@ -56190,7 +58143,7 @@ var ts; function checkCrossProductUnion(types) { var size = getCrossProductUnionSize(types); if (size >= 100000) { - 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" /* 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; } @@ -56240,23 +58193,36 @@ var ts; type.resolvedStringIndexType || (type.resolvedStringIndexType = createIndexType(type, /*stringsOnly*/ true)) : type.resolvedIndexType || (type.resolvedIndexType = createIndexType(type, /*stringsOnly*/ false)); } + function instantiateTypeAsMappedNameType(nameType, type, t) { + return instantiateType(nameType, appendTypeMapping(type.mapper, getTypeParameterFromMappedType(type), t)); + } function getIndexTypeForMappedType(type, noIndexSignatures) { var constraint = filterType(getConstraintTypeFromMappedType(type), function (t) { return !(noIndexSignatures && t.flags & (1 /* Any */ | 4 /* String */)); }); var nameType = type.declaration.nameType && getTypeFromTypeNode(type.declaration.nameType); + // If the constraint is exclusively string/number/never type(s), we need to pull the property names from the modified type and run them through the `nameType` mapper as well + // since they won't appear in the constraint, due to subtype reducing with the string/number index types + var properties = nameType && everyType(constraint, function (t) { return !!(t.flags & (4 /* String */ | 8 /* Number */ | 131072 /* Never */)); }) && getPropertiesOfType(getApparentType(getModifiersTypeFromMappedType(type))); return nameType ? - mapType(constraint, function (t) { return instantiateType(nameType, appendTypeMapping(type.mapper, getTypeParameterFromMappedType(type), t)); }) : + getUnionType([mapType(constraint, function (t) { return instantiateTypeAsMappedNameType(nameType, type, t); }), mapType(getUnionType(ts.map(properties || ts.emptyArray, function (p) { return getLiteralTypeFromProperty(p, 8576 /* StringOrNumberLiteralOrUnique */); })), function (t) { return instantiateTypeAsMappedNameType(nameType, type, t); })]) : constraint; } // Ordinarily we reduce a keyof M, where M is a mapped type { [P in K as N

]: X }, to simply N. This however presumes - // that N distributes over union types, i.e. that N is equivalent to N | N | N. That presumption may not - // be true when N is a non-distributive conditional type or an instantiable type with a non-distributive conditional type as - // a constituent. In those cases, we cannot reduce keyof M and need to preserve it as is. - function maybeNonDistributiveNameType(type) { - return !!(type && (type.flags & 16777216 /* Conditional */ && (!type.root.isDistributive || maybeNonDistributiveNameType(type.checkType)) || - type.flags & (3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */) && ts.some(type.types, maybeNonDistributiveNameType) || - type.flags & (4194304 /* Index */ | 268435456 /* StringMapping */) && maybeNonDistributiveNameType(type.type) || - type.flags & 8388608 /* IndexedAccess */ && maybeNonDistributiveNameType(type.indexType) || - type.flags & 33554432 /* Substitution */ && maybeNonDistributiveNameType(type.substitute))); + // that N distributes over union types, i.e. that N is equivalent to N | N | N. Specifically, we only + // want to perform the reduction when the name type of a mapped type is distributive with respect to the type variable + // introduced by the 'in' clause of the mapped type. Note that non-generic types are considered to be distributive because + // they're the same type regardless of what's being distributed over. + function hasDistributiveNameType(mappedType) { + 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) : + false; + } } function getLiteralTypeFromPropertyName(name) { if (ts.isPrivateIdentifier(name)) { @@ -56274,13 +58240,13 @@ var ts; function getLiteralTypeFromProperty(prop, include) { if (!(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24 /* NonPublicAccessibilityModifier */)) { var type = getSymbolLinks(getLateBoundSymbol(prop)).nameType; - if (!type && !ts.isKnownSymbol(prop)) { + if (!type) { if (prop.escapedName === "default" /* Default */) { type = getLiteralType("default"); } else { var name = prop.valueDeclaration && ts.getNameOfDeclaration(prop.valueDeclaration); - type = name && getLiteralTypeFromPropertyName(name) || getLiteralType(ts.symbolName(prop)); + type = name && getLiteralTypeFromPropertyName(name) || (!ts.isKnownSymbol(prop) ? getLiteralType(ts.symbolName(prop)) : undefined); } } if (type && type.flags & include) { @@ -56304,7 +58270,7 @@ var ts; type = getReducedType(type); return type.flags & 1048576 /* Union */ ? 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) && maybeNonDistributiveNameType(getNameTypeFromMappedType(type)) ? getIndexTypeForGenericType(type, stringsOnly) : + type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) ? getIndexTypeForGenericType(type, stringsOnly) : ts.getObjectFlags(type) & 32 /* Mapped */ ? getIndexTypeForMappedType(type, noIndexSignatures) : type === wildcardType ? wildcardType : type.flags & 2 /* Unknown */ ? neverType : @@ -56329,15 +58295,15 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { switch (node.operator) { - case 138 /* KeyOfKeyword */: + case 139 /* KeyOfKeyword */: links.resolvedType = getIndexType(getTypeFromTypeNode(node.type)); break; - case 151 /* UniqueKeyword */: - links.resolvedType = node.type.kind === 148 /* SymbolKeyword */ + case 152 /* UniqueKeyword */: + links.resolvedType = node.type.kind === 149 /* SymbolKeyword */ ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent)) : errorType; break; - case 142 /* ReadonlyKeyword */: + case 143 /* ReadonlyKeyword */: links.resolvedType = getTypeFromTypeNode(node.type); break; default: @@ -56380,7 +58346,6 @@ var ts; var type = templateLiteralTypes.get(id); if (!type) { templateLiteralTypes.set(id, type = createTemplateLiteralType(newTexts, newTypes)); - type.regularType = type; } return type; function addSpans(texts, types) { @@ -56412,10 +58377,8 @@ var ts; 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 */ ? type.intrinsicName : - type.flags & 65536 /* Null */ ? "null" : - type.flags & 32768 /* Undefined */ ? "undefined" : - undefined; + type.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) ? type.intrinsicName : + undefined; } function createTemplateLiteralType(texts, types) { var type = createType(134217728 /* TemplateLiteral */); @@ -56452,13 +58415,13 @@ var ts; result.type = type; return result; } - function createIndexedAccessType(objectType, indexType, aliasSymbol, aliasTypeArguments, shouldIncludeUndefined) { + function createIndexedAccessType(objectType, indexType, accessFlags, aliasSymbol, aliasTypeArguments) { var type = createType(8388608 /* IndexedAccess */); type.objectType = objectType; type.indexType = indexType; + type.accessFlags = accessFlags; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; - type.noUncheckedIndexedAccessCandidate = shouldIncludeUndefined; return type; } /** @@ -56474,7 +58437,7 @@ var ts; if (noImplicitAny) { return false; // Flag is meaningless under `noImplicitAny` mode } - if (ts.getObjectFlags(type) & 16384 /* JSLiteral */) { + if (ts.getObjectFlags(type) & 8192 /* JSLiteral */) { return true; } if (type.flags & 1048576 /* Union */) { @@ -56484,20 +58447,18 @@ var ts; return ts.some(type.types, isJSLiteralType); } if (type.flags & 465829888 /* Instantiable */) { - return isJSLiteralType(getResolvedBaseConstraint(type)); + var constraint = getResolvedBaseConstraint(type); + return constraint !== type && isJSLiteralType(constraint); } return false; } function getPropertyNameFromIndex(indexType, accessNode) { - var accessExpression = accessNode && accessNode.kind === 202 /* ElementAccessExpression */ ? accessNode : undefined; return isTypeUsableAsPropertyName(indexType) ? getPropertyNameFromType(indexType) : - accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? - ts.getPropertyNameForKnownSymbolName(ts.idText(accessExpression.argumentExpression.name)) : - accessNode && ts.isPropertyName(accessNode) ? - // late bound names are handled in the first branch, so here we only need to handle normal names - ts.getPropertyNameForPropertyNameNode(accessNode) : - undefined; + accessNode && ts.isPropertyName(accessNode) ? + // late bound names are handled in the first branch, so here we only need to handle normal names + ts.getPropertyNameForPropertyNameNode(accessNode) : + undefined; } function isUncalledFunctionReference(node, symbol) { if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { @@ -56509,24 +58470,27 @@ var ts; } return true; } - function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, suppressNoImplicitAnyError, accessNode, accessFlags, noUncheckedIndexedAccessCandidate, reportDeprecated) { + function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, accessNode, accessFlags) { var _a; - var accessExpression = accessNode && accessNode.kind === 202 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 204 /* ElementAccessExpression */ ? accessNode : undefined; var propName = accessNode && ts.isPrivateIdentifier(accessNode) ? undefined : getPropertyNameFromIndex(indexType, accessNode); if (propName !== undefined) { + if (accessFlags & 256 /* Contextual */) { + return getTypeOfPropertyOfContextualType(objectType, propName) || anyType; + } var prop = getPropertyOfType(objectType, propName); if (prop) { - if (reportDeprecated && accessNode && getDeclarationNodeFlagsFromSymbol(prop) & 134217728 /* Deprecated */ && isUncalledFunctionReference(accessNode, prop)) { + if (accessFlags & 64 /* ReportDeprecated */ && accessNode && prop.declarations && getDeclarationNodeFlagsFromSymbol(prop) & 134217728 /* Deprecated */ && 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); - errorOrSuggestion(/* isError */ false, deprecatedNode, ts.Diagnostics._0_is_deprecated, propName); + addDeprecatedSuggestion(deprecatedNode, prop.declarations, propName); } if (accessExpression) { - markPropertyAsReferenced(prop, accessExpression, /*isThisAccess*/ accessExpression.expression.kind === 107 /* ThisKeyword */); + markPropertyAsReferenced(prop, accessExpression, isSelfTypeAccess(accessExpression.expression, objectType.symbol)); if (isAssignmentToReadonlyEntity(accessExpression, prop, ts.getAssignmentTargetKind(accessExpression))) { error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(prop)); return undefined; } - if (accessFlags & 4 /* CacheSymbol */) { + if (accessFlags & 8 /* CacheSymbol */) { getNodeLinks(accessNode).resolvedSymbol = prop; } if (isThisPropertyAccessInConstructor(accessExpression, prop)) { @@ -56539,7 +58503,7 @@ var ts; propType; } if (everyType(objectType, isTupleType) && isNumericLiteralName(propName) && +propName >= 0) { - if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 8 /* NoTupleBoundsCheck */)) { + if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 16 /* NoTupleBoundsCheck */)) { var indexNode = getIndexNodeForAccessExpression(accessNode); if (isTupleType(objectType)) { error(indexNode, ts.Diagnostics.Tuple_type_0_of_length_1_has_no_element_at_index_2, typeToString(objectType), getTypeReferenceArity(objectType), ts.unescapeLeadingUnderscores(propName)); @@ -56551,7 +58515,7 @@ var ts; errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, 1 /* Number */)); return mapType(objectType, function (t) { var restType = getRestTypeOfTupleType(t) || undefinedType; - return noUncheckedIndexedAccessCandidate ? getUnionType([restType, undefinedType]) : restType; + return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([restType, undefinedType]) : restType; }); } } @@ -56562,7 +58526,7 @@ var ts; var stringIndexInfo = getIndexInfoOfType(objectType, 0 /* String */); var indexInfo = isTypeAssignableToKind(indexType, 296 /* NumberLike */) && getIndexInfoOfType(objectType, 1 /* Number */) || stringIndexInfo; if (indexInfo) { - if (accessFlags & 1 /* NoIndexSignatures */ && indexInfo === stringIndexInfo) { + if (accessFlags & 2 /* NoIndexSignatures */ && indexInfo === stringIndexInfo) { if (accessExpression) { error(accessExpression, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(originalObjectType)); } @@ -56571,10 +58535,10 @@ var ts; if (accessNode && !isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) { var indexNode = getIndexNodeForAccessExpression(accessNode); error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); - return noUncheckedIndexedAccessCandidate ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; + return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; } errorIfWritingToReadonlyIndex(indexInfo); - return noUncheckedIndexedAccessCandidate ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; + return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; } if (indexType.flags & 131072 /* Never */) { return neverType; @@ -56598,7 +58562,7 @@ var ts; if (objectType.symbol === globalThisSymbol && propName !== undefined && globalThisSymbol.exports.has(propName) && (globalThisSymbol.exports.get(propName).flags & 418 /* BlockScoped */)) { error(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType)); } - else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !suppressNoImplicitAnyError) { + else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !(accessFlags & 128 /* 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) + "]"); @@ -56671,13 +58635,13 @@ var ts; } } function getIndexNodeForAccessExpression(accessNode) { - return accessNode.kind === 202 /* ElementAccessExpression */ ? accessNode.argumentExpression : - accessNode.kind === 189 /* IndexedAccessType */ ? accessNode.indexType : - accessNode.kind === 158 /* ComputedPropertyName */ ? accessNode.expression : + return accessNode.kind === 204 /* ElementAccessExpression */ ? accessNode.argumentExpression : + accessNode.kind === 191 /* IndexedAccessType */ ? accessNode.indexType : + accessNode.kind === 160 /* ComputedPropertyName */ ? accessNode.expression : accessNode; } function isPatternLiteralPlaceholderType(type) { - return templateConstraintType.types.indexOf(type) !== -1 || !!(type.flags & 1 /* Any */); + return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */)); } function isPatternLiteralType(type) { return !!(type.flags & 134217728 /* TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType); @@ -56690,6 +58654,13 @@ var ts; } return !!(type.objectFlags & 8388608 /* IsGenericObjectType */); } + if (type.flags & 33554432 /* Substitution */) { + if (!(type.objectFlags & 4194304 /* IsGenericObjectTypeComputed */)) { + type.objectFlags |= 4194304 /* IsGenericObjectTypeComputed */ | + (isGenericObjectType(type.substitute) || isGenericObjectType(type.baseType) ? 8388608 /* IsGenericObjectType */ : 0); + } + return !!(type.objectFlags & 8388608 /* IsGenericObjectType */); + } return !!(type.flags & 58982400 /* InstantiableNonPrimitive */) || isGenericMappedType(type) || isGenericTupleType(type); } function isGenericIndexType(type) { @@ -56700,6 +58671,13 @@ var ts; } return !!(type.objectFlags & 33554432 /* IsGenericIndexType */); } + if (type.flags & 33554432 /* Substitution */) { + if (!(type.objectFlags & 16777216 /* IsGenericIndexTypeComputed */)) { + type.objectFlags |= 16777216 /* IsGenericIndexTypeComputed */ | + (isGenericIndexType(type.substitute) || isGenericIndexType(type.baseType) ? 33554432 /* IsGenericIndexType */ : 0); + } + return !!(type.objectFlags & 33554432 /* IsGenericIndexType */); + } return !!(type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */)) && !isPatternLiteralType(type); } function isThisTypeParameter(type) { @@ -56775,6 +58753,12 @@ var ts; } return type[cache] = type; } + function isConditionalTypeAlwaysTrueDisregardingInferTypes(type) { + var extendsInferParamMapper = type.root.inferTypeParameters && createTypeMapper(type.root.inferTypeParameters, ts.map(type.root.inferTypeParameters, function () { return wildcardType; })); + var checkType = type.checkType; + var extendsType = type.extendsType; + return isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(instantiateType(extendsType, extendsInferParamMapper))); + } function getSimplifiedConditionalType(type, writing) { var checkType = type.checkType; var extendsType = type.extendsType; @@ -56810,9 +58794,9 @@ var ts; var templateMapper = combineTypeMappers(objectType.mapper, mapper); return instantiateType(getTemplateTypeFromMappedType(objectType), templateMapper); } - function getIndexedAccessType(objectType, indexType, noUncheckedIndexedAccessCandidate, accessNode, aliasSymbol, aliasTypeArguments, accessFlags) { + function getIndexedAccessType(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) { if (accessFlags === void 0) { accessFlags = 0 /* None */; } - return getIndexedAccessTypeOrUndefined(objectType, indexType, noUncheckedIndexedAccessCandidate, accessNode, accessFlags, aliasSymbol, aliasTypeArguments) || (accessNode ? errorType : unknownType); + return getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) || (accessNode ? errorType : unknownType); } function indexTypeLessThan(indexType, limit) { return everyType(indexType, function (t) { @@ -56826,36 +58810,38 @@ var ts; return false; }); } - function getIndexedAccessTypeOrUndefined(objectType, indexType, noUncheckedIndexedAccessCandidate, accessNode, accessFlags, aliasSymbol, aliasTypeArguments) { + function getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) { if (accessFlags === void 0) { accessFlags = 0 /* None */; } if (objectType === wildcardType || indexType === wildcardType) { return wildcardType; } - var shouldIncludeUndefined = noUncheckedIndexedAccessCandidate || - (!!compilerOptions.noUncheckedIndexedAccess && - (accessFlags & (2 /* Writing */ | 16 /* ExpressionPosition */)) === 16 /* ExpressionPosition */); // 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 */)) { 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 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 !== 189 /* IndexedAccessType */ ? + if (isGenericIndexType(indexType) || (accessNode && accessNode.kind !== 191 /* IndexedAccessType */ ? isGenericTupleType(objectType) && !indexTypeLessThan(indexType, objectType.target.fixedLength) : isGenericObjectType(objectType) && !(isTupleType(objectType) && indexTypeLessThan(indexType, objectType.target.fixedLength)))) { if (objectType.flags & 3 /* AnyOrUnknown */) { return objectType; } // Defer the operation by creating an indexed access type. - var id = objectType.id + "," + indexType.id + (shouldIncludeUndefined ? "?" : "") + (aliasSymbol ? "@" + getSymbolId(aliasSymbol) : ""); + var persistentAccessFlags = accessFlags & 1 /* Persistent */; + var id = objectType.id + "," + indexType.id + "," + persistentAccessFlags + getAliasId(aliasSymbol, aliasTypeArguments); var type = indexedAccessTypes.get(id); if (!type) { - indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType, aliasSymbol, aliasTypeArguments, shouldIncludeUndefined)); + indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType, persistentAccessFlags, aliasSymbol, aliasTypeArguments)); } return type; } @@ -56868,7 +58854,7 @@ var ts; 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, wasMissingProp, accessNode, accessFlags, shouldIncludeUndefined); + var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, indexType, accessNode, accessFlags | (wasMissingProp ? 128 /* SuppressNoImplicitAnyError */ : 0)); if (propType) { propTypes.push(propType); } @@ -56884,11 +58870,11 @@ var ts; if (wasMissingProp) { return undefined; } - return accessFlags & 2 /* Writing */ + return accessFlags & 4 /* Writing */ ? getIntersectionType(propTypes, aliasSymbol, aliasTypeArguments) : getUnionType(propTypes, 1 /* Literal */, aliasSymbol, aliasTypeArguments); } - return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, /* supressNoImplicitAnyError */ false, accessNode, accessFlags | 4 /* CacheSymbol */, shouldIncludeUndefined, /* reportDeprecated */ true); + return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, accessNode, accessFlags | 8 /* CacheSymbol */ | 64 /* ReportDeprecated */); } function getTypeFromIndexedAccessTypeNode(node) { var links = getNodeLinks(node); @@ -56896,7 +58882,7 @@ var ts; var objectType = getTypeFromTypeNode(node.objectType); var indexType = getTypeFromTypeNode(node.indexType); var potentialAlias = getAliasSymbolForTypeNode(node); - var resolved = getIndexedAccessType(objectType, indexType, /*noUncheckedIndexedAccessCandidate*/ undefined, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias)); + var resolved = getIndexedAccessType(objectType, indexType, 0 /* None */, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias)); links.resolvedType = resolved.flags & 8388608 /* IndexedAccess */ && resolved.objectType === objectType && resolved.indexType === indexType ? @@ -56928,16 +58914,32 @@ var ts; } return type; } - function getConditionalType(root, mapper) { + function isTypicalNondistributiveConditional(root) { + return !root.isDistributive + && root.node.checkType.kind === 181 /* TupleType */ + && ts.length(root.node.checkType.elements) === 1 + && root.node.extendsType.kind === 181 /* TupleType */ + && ts.length(root.node.extendsType.elements) === 1; + } + /** + * We syntactually check for common nondistributive conditional shapes and unwrap them into + * the intended comparison - we do this so we can check if the unwrapped types are generic or + * not and appropriately defer condition calculation + */ + function unwrapNondistributiveConditionalTuple(root, type) { + return isTypicalNondistributiveConditional(root) && isTupleType(type) ? getTypeArguments(type)[0] : type; + } + function getConditionalType(root, mapper, aliasSymbol, aliasTypeArguments) { var result; var extraTypes; // We loop here for an immediately nested conditional type in the false position, effectively treating // types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for // purposes of resolution. This means such types aren't subject to the instatiation depth limiter. while (true) { - var checkType = instantiateType(root.checkType, mapper); + var isUnwrapped = isTypicalNondistributiveConditional(root); + var checkType = instantiateType(unwrapNondistributiveConditionalTuple(root, getActualTypeVariable(root.checkType)), mapper); var checkTypeInstantiable = isGenericObjectType(checkType) || isGenericIndexType(checkType); - var extendsType = instantiateType(root.extendsType, mapper); + var extendsType = instantiateType(unwrapNondistributiveConditionalTuple(root, root.extendsType), mapper); if (checkType === wildcardType || extendsType === wildcardType) { return wildcardType; } @@ -56948,21 +58950,24 @@ 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, extendsType, 256 /* NoConstraints */ | 512 /* AlwaysStrict */); + inferTypes(context.inferences, checkType, extendsType, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */); } - combinedMapper = mergeTypeMappers(mapper, context.mapper); + // It's possible for 'infer T' type paramteters to be given uninstantiated constraints when the + // those type parameters are used in type references (see getInferredTypeParameterConstraint). For + // that reason we need context.mapper to be first in the combined mapper. See #42636 for examples. + combinedMapper = mapper ? combineTypeMappers(context.mapper, mapper) : context.mapper; } // Instantiate the extends type including inferences for 'infer T' type parameters - var inferredExtendsType = combinedMapper ? instantiateType(root.extendsType, combinedMapper) : extendsType; + var inferredExtendsType = combinedMapper ? instantiateType(unwrapNondistributiveConditionalTuple(root, root.extendsType), combinedMapper) : extendsType; // We attempt to resolve the conditional type only when the check and extends types are non-generic if (!checkTypeInstantiable && !isGenericObjectType(inferredExtendsType) && !isGenericIndexType(inferredExtendsType)) { // Return falseType for a definitely false extends check. We check an instantiations of the two // 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 */ || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) { + if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && ((checkType.flags & 1 /* Any */ && !isUnwrapped) || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) { // Return union of trueType and falseType for 'any' since it matches anything - if (checkType.flags & 1 /* Any */) { + if (checkType.flags & 1 /* 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 @@ -56991,12 +58996,12 @@ var ts; // Return a deferred type for a check that is neither definitely true nor definitely false result = createType(16777216 /* Conditional */); result.root = root; - result.checkType = checkType; - result.extendsType = extendsType; + result.checkType = instantiateType(root.checkType, mapper); + result.extendsType = instantiateType(root.extendsType, mapper); result.mapper = mapper; result.combinedMapper = combinedMapper; - result.aliasSymbol = root.aliasSymbol; - result.aliasTypeArguments = instantiateTypes(root.aliasTypeArguments, mapper); // TODO: GH#18217 + result.aliasSymbol = aliasSymbol || root.aliasSymbol; + result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(root.aliasTypeArguments, mapper); // TODO: GH#18217 break; } return extraTypes ? getUnionType(ts.append(extraTypes, result)) : result; @@ -57155,7 +59160,7 @@ var ts; } function getAliasSymbolForTypeNode(node) { var host = node.parent; - while (ts.isParenthesizedTypeNode(host) || ts.isJSDocTypeExpression(host) || ts.isTypeOperatorNode(host) && host.operator === 142 /* ReadonlyKeyword */) { + while (ts.isParenthesizedTypeNode(host) || ts.isJSDocTypeExpression(host) || ts.isTypeOperatorNode(host) && host.operator === 143 /* ReadonlyKeyword */) { host = host.parent; } return ts.isTypeAlias(host) ? getSymbolOfNode(host) : undefined; @@ -57194,7 +59199,7 @@ var ts; 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)); - result.type = isSetonlyAccessor ? undefinedType : getUnionType([getTypeOfSymbol(prop), undefinedType]); + result.type = isSetonlyAccessor ? undefinedType : addOptionality(getTypeOfSymbol(prop), /*isProperty*/ true); result.declarations = prop.declarations; result.nameType = getSymbolLinks(prop).nameType; result.syntheticOrigin = prop; @@ -57202,7 +59207,7 @@ var ts; } } var spread = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfoOfType(type, 0 /* String */), getIndexInfoOfType(type, 1 /* Number */)); - spread.objectFlags |= 128 /* ObjectLiteral */ | 1048576 /* ContainsObjectOrArrayLiteral */; + spread.objectFlags |= 128 /* ObjectLiteral */ | 262144 /* ContainsObjectOrArrayLiteral */; return spread; } } @@ -57308,14 +59313,15 @@ var ts; } } var spread = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfoWithReadonly(stringIndexInfo, readonly), getIndexInfoWithReadonly(numberIndexInfo, readonly)); - spread.objectFlags |= 128 /* ObjectLiteral */ | 1048576 /* ContainsObjectOrArrayLiteral */ | 1024 /* ContainsSpread */ | objectFlags; + spread.objectFlags |= 128 /* ObjectLiteral */ | 262144 /* ContainsObjectOrArrayLiteral */ | 4194304 /* ContainsSpread */ | objectFlags; return spread; } /** We approximate own properties as non-methods plus methods that are inside the object literal */ function isSpreadableProperty(prop) { - return !ts.some(prop.declarations, ts.isPrivateIdentifierPropertyDeclaration) && + var _a; + return !ts.some(prop.declarations, ts.isPrivateIdentifierClassElementDeclaration) && (!(prop.flags & (8192 /* Method */ | 32768 /* GetAccessor */ | 65536 /* SetAccessor */)) || - !prop.declarations.some(function (decl) { return ts.isClassLike(decl.parent); })); + !((_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 */); @@ -57340,11 +59346,9 @@ var ts; return type; } function getFreshTypeOfLiteralType(type) { - if (type.flags & 134220672 /* FreshableLiteral */) { + if (type.flags & 2944 /* Literal */) { if (!type.freshType) { - var freshType = type.flags & 134217728 /* TemplateLiteral */ ? - createTemplateLiteralType(type.texts, type.types) : - createLiteralType(type.flags, type.value, type.symbol); + var freshType = createLiteralType(type.flags, type.value, type.symbol); freshType.regularType = type; freshType.freshType = freshType; type.freshType = freshType; @@ -57354,12 +59358,12 @@ var ts; return type; } function getRegularTypeOfLiteralType(type) { - return type.flags & 134220672 /* FreshableLiteral */ ? type.regularType : + return type.flags & 2944 /* Literal */ ? type.regularType : type.flags & 1048576 /* Union */ ? (type.regularType || (type.regularType = mapType(type, getRegularTypeOfLiteralType))) : type; } function isFreshLiteralType(type) { - return !!(type.flags & 134220672 /* FreshableLiteral */) && type.freshType === type; + return !!(type.flags & 2944 /* Literal */) && type.freshType === type; } function getLiteralType(value, enumId, symbol) { // We store all literal types in a single map with keys of the form '#NNN' and '@SSS', @@ -57379,7 +59383,7 @@ var ts; return type; } function getTypeFromLiteralTypeNode(node) { - if (node.literal.kind === 103 /* NullKeyword */) { + if (node.literal.kind === 104 /* NullKeyword */) { return nullType; } var links = getNodeLinks(node); @@ -57405,7 +59409,7 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 253 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 255 /* InterfaceDeclaration */)) { if (!ts.hasSyntacticModifier(container, 32 /* Static */) && (!ts.isConstructorDeclaration(container) || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; @@ -57440,17 +59444,17 @@ var ts; } function getArrayElementTypeNode(node) { switch (node.kind) { - case 186 /* ParenthesizedType */: + case 188 /* ParenthesizedType */: return getArrayElementTypeNode(node.type); - case 179 /* TupleType */: + case 181 /* TupleType */: if (node.elements.length === 1) { node = node.elements[0]; - if (node.kind === 181 /* RestType */ || node.kind === 192 /* NamedTupleMember */ && node.dotDotDotToken) { + if (node.kind === 183 /* RestType */ || node.kind === 194 /* NamedTupleMember */ && node.dotDotDotToken) { return getArrayElementTypeNode(node.type); } } break; - case 178 /* ArrayType */: + case 180 /* ArrayType */: return node.elementType; } return undefined; @@ -57459,107 +59463,106 @@ var ts; var links = getNodeLinks(node); return links.resolvedType || (links.resolvedType = node.dotDotDotToken ? getTypeFromRestTypeNode(node) : - node.questionToken && strictNullChecks ? getOptionalType(getTypeFromTypeNode(node.type)) : - getTypeFromTypeNode(node.type)); + addOptionality(getTypeFromTypeNode(node.type), /*isProperty*/ true, !!node.questionToken)); } function getTypeFromTypeNode(node) { return getConditionalFlowTypeOfType(getTypeFromTypeNodeWorker(node), node); } function getTypeFromTypeNodeWorker(node) { switch (node.kind) { - case 128 /* AnyKeyword */: - case 303 /* JSDocAllType */: - case 304 /* JSDocUnknownType */: + case 129 /* AnyKeyword */: + case 306 /* JSDocAllType */: + case 307 /* JSDocUnknownType */: return anyType; - case 152 /* UnknownKeyword */: + case 153 /* UnknownKeyword */: return unknownType; - case 147 /* StringKeyword */: + case 148 /* StringKeyword */: return stringType; - case 144 /* NumberKeyword */: + case 145 /* NumberKeyword */: return numberType; - case 155 /* BigIntKeyword */: + case 156 /* BigIntKeyword */: return bigintType; - case 131 /* BooleanKeyword */: + case 132 /* BooleanKeyword */: return booleanType; - case 148 /* SymbolKeyword */: + case 149 /* SymbolKeyword */: return esSymbolType; - case 113 /* VoidKeyword */: + case 114 /* VoidKeyword */: return voidType; - case 150 /* UndefinedKeyword */: + case 151 /* UndefinedKeyword */: return undefinedType; - case 103 /* NullKeyword */: + case 104 /* 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 141 /* NeverKeyword */: + case 142 /* NeverKeyword */: return neverType; - case 145 /* ObjectKeyword */: + case 146 /* ObjectKeyword */: return node.flags & 131072 /* JavaScriptFile */ && !noImplicitAny ? anyType : nonPrimitiveType; - case 136 /* IntrinsicKeyword */: + case 137 /* IntrinsicKeyword */: return intrinsicMarkerType; - case 187 /* ThisType */: - case 107 /* ThisKeyword */: + case 189 /* ThisType */: + case 108 /* 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 191 /* LiteralType */: + case 193 /* LiteralType */: return getTypeFromLiteralTypeNode(node); - case 173 /* TypeReference */: + case 175 /* TypeReference */: return getTypeFromTypeReference(node); - case 172 /* TypePredicate */: + case 174 /* TypePredicate */: return node.assertsModifier ? voidType : booleanType; - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 176 /* TypeQuery */: + case 178 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 178 /* ArrayType */: - case 179 /* TupleType */: + case 180 /* ArrayType */: + case 181 /* TupleType */: return getTypeFromArrayOrTupleTypeNode(node); - case 180 /* OptionalType */: + case 182 /* OptionalType */: return getTypeFromOptionalTypeNode(node); - case 182 /* UnionType */: + case 184 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 183 /* IntersectionType */: + case 185 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 305 /* JSDocNullableType */: + case 308 /* JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 307 /* JSDocOptionalType */: + case 310 /* JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 192 /* NamedTupleMember */: + case 194 /* NamedTupleMember */: return getTypeFromNamedTupleTypeNode(node); - case 186 /* ParenthesizedType */: - case 306 /* JSDocNonNullableType */: - case 301 /* JSDocTypeExpression */: + case 188 /* ParenthesizedType */: + case 309 /* JSDocNonNullableType */: + case 303 /* JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 181 /* RestType */: + case 183 /* RestType */: return getTypeFromRestTypeNode(node); - case 309 /* JSDocVariadicType */: + case 312 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); - case 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 177 /* TypeLiteral */: - case 312 /* JSDocTypeLiteral */: - case 308 /* JSDocFunctionType */: - case 313 /* JSDocSignature */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: + case 179 /* TypeLiteral */: + case 316 /* JSDocTypeLiteral */: + case 311 /* JSDocFunctionType */: + case 317 /* JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 188 /* TypeOperator */: + case 190 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 189 /* IndexedAccessType */: + case 191 /* IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 190 /* MappedType */: + case 192 /* MappedType */: return getTypeFromMappedTypeNode(node); - case 184 /* ConditionalType */: + case 186 /* ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 185 /* InferType */: + case 187 /* InferType */: return getTypeFromInferTypeNode(node); - case 193 /* TemplateLiteralType */: + case 195 /* TemplateLiteralType */: return getTypeFromTemplateTypeNode(node); - case 195 /* ImportType */: + case 197 /* 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 78 /* Identifier */: - case 157 /* QualifiedName */: - case 201 /* PropertyAccessExpression */: + case 79 /* Identifier */: + case 159 /* QualifiedName */: + case 203 /* PropertyAccessExpression */: var symbol = getSymbolAtLocation(node); return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType; default: @@ -57712,7 +59715,7 @@ var ts; } return result; } - function getObjectTypeInstantiation(type, mapper) { + function getObjectTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) { var declaration = type.objectFlags & 4 /* Reference */ ? type.node : type.symbol.declarations[0]; var links = getNodeLinks(declaration); var target = type.objectFlags & 4 /* Reference */ ? links.resolvedType : @@ -57729,8 +59732,9 @@ var ts; outerTypeParameters = ts.addRange(outerTypeParameters, templateTagParameters); } typeParameters = outerTypeParameters || ts.emptyArray; - typeParameters = (target.objectFlags & 4 /* Reference */ || target.symbol.flags & 2048 /* TypeLiteral */) && !target.aliasTypeArguments ? - ts.filter(typeParameters, function (tp) { return isTypeParameterPossiblyReferenced(tp, declaration); }) : + var allDeclarations_1 = type.objectFlags & 4 /* Reference */ ? [declaration] : type.symbol.declarations; + typeParameters = (target.objectFlags & 4 /* Reference */ || target.symbol.flags & 8192 /* Method */ || target.symbol.flags & 2048 /* TypeLiteral */) && !target.aliasTypeArguments ? + ts.filter(typeParameters, function (tp) { return ts.some(allDeclarations_1, function (d) { return isTypeParameterPossiblyReferenced(tp, d); }); }) : typeParameters; links.outerTypeParameters = typeParameters; } @@ -57740,17 +59744,19 @@ var ts; // instantiation cache key from the type IDs of the type arguments. var combinedMapper_1 = combineTypeMappers(type.mapper, mapper); var typeArguments = ts.map(typeParameters, function (t) { return getMappedType(t, combinedMapper_1); }); - var id = getTypeListId(typeArguments); + var newAliasSymbol = aliasSymbol || type.aliasSymbol; + var newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper); + var id = getTypeListId(typeArguments) + getAliasId(newAliasSymbol, newAliasTypeArguments); if (!target.instantiations) { target.instantiations = new ts.Map(); - target.instantiations.set(getTypeListId(typeParameters), target); + target.instantiations.set(getTypeListId(typeParameters) + getAliasId(target.aliasSymbol, target.aliasTypeArguments), target); } var result = target.instantiations.get(id); if (!result) { var newMapper = createTypeMapper(typeParameters, typeArguments); - result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper) : - target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper) : - instantiateAnonymousType(target, newMapper); + result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : + target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : + instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments); target.instantiations.set(id, result); } return result; @@ -57758,9 +59764,8 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 157 /* QualifiedName */ || - node.parent.kind === 173 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || - node.parent.kind === 195 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); + return !(node.parent.kind === 175 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || + node.parent.kind === 197 /* 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 @@ -57769,22 +59774,28 @@ 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 === 230 /* Block */ || n.kind === 184 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { + if (!n || n.kind === 232 /* Block */ || n.kind === 186 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { return true; } } - return !!ts.forEachChild(node, containsReference); + return containsReference(node); } return true; function containsReference(node) { switch (node.kind) { - case 187 /* ThisType */: + case 189 /* ThisType */: return !!tp.isThisType; - case 78 /* Identifier */: + case 79 /* Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNodeWorker(node) === tp; // use worker because we're looking for === equality - case 176 /* TypeQuery */: + case 178 /* TypeQuery */: return true; + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + return !node.type && !!node.body || + ts.some(node.typeParameters, containsReference) || + ts.some(node.parameters, containsReference) || + !!node.type && containsReference(node.type); } return !!ts.forEachChild(node, containsReference); } @@ -57799,7 +59810,7 @@ var ts; } return undefined; } - function instantiateMappedType(type, mapper) { + function instantiateMappedType(type, mapper, aliasSymbol, aliasTypeArguments) { // For a homomorphic mapped type { [P in keyof T]: X }, where T is some type variable, the mapping // operation depends on T as follows: // * If T is a primitive type no mapping is performed and the result is simply T. @@ -57814,7 +59825,7 @@ var ts; if (typeVariable) { var mappedTypeVariable = instantiateType(typeVariable, mapper); if (typeVariable !== mappedTypeVariable) { - return mapType(getReducedType(mappedTypeVariable), function (t) { + return mapTypeWithAlias(getReducedType(mappedTypeVariable), function (t) { if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && t !== errorType) { if (!type.declaration.nameType) { if (isArrayType(t)) { @@ -57830,11 +59841,11 @@ var ts; return instantiateAnonymousType(type, prependTypeMapping(typeVariable, t, mapper)); } return t; - }); + }, aliasSymbol, aliasTypeArguments); } } // If the constraint type of the instantiation is the wildcard type, return the wildcard type. - return instantiateType(getConstraintTypeFromMappedType(type), mapper) === wildcardType ? wildcardType : instantiateAnonymousType(type, mapper); + 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; @@ -57877,11 +59888,11 @@ 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) : + return strictNullChecks && modifiers & 4 /* IncludeOptional */ && !maybeTypeOfKind(propType, 32768 /* Undefined */ | 16384 /* Void */) ? getOptionalType(propType, /*isProperty*/ true) : strictNullChecks && modifiers & 8 /* ExcludeOptional */ && isOptional ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : propType; } - function instantiateAnonymousType(type, mapper) { + function instantiateAnonymousType(type, mapper, aliasSymbol, aliasTypeArguments) { var result = createObjectType(type.objectFlags | 64 /* Instantiated */, type.symbol); if (type.objectFlags & 32 /* Mapped */) { result.declaration = type.declaration; @@ -57894,29 +59905,29 @@ var ts; } result.target = type; result.mapper = mapper; - result.aliasSymbol = type.aliasSymbol; - result.aliasTypeArguments = instantiateTypes(type.aliasTypeArguments, mapper); + result.aliasSymbol = aliasSymbol || type.aliasSymbol; + result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper); return result; } - function getConditionalTypeInstantiation(type, mapper) { + function getConditionalTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) { var root = type.root; if (root.outerTypeParameters) { // We are instantiating a conditional type that has one or more type parameters in scope. Apply the // mapper to the type parameters to produce the effective list of type arguments, and compute the // instantiation cache key from the type IDs of the type arguments. var typeArguments = ts.map(root.outerTypeParameters, function (t) { return getMappedType(t, mapper); }); - var id = getTypeListId(typeArguments); + var id = getTypeListId(typeArguments) + getAliasId(aliasSymbol, aliasTypeArguments); var result = root.instantiations.get(id); if (!result) { var newMapper = createTypeMapper(root.outerTypeParameters, typeArguments); - result = instantiateConditionalType(root, newMapper); + result = instantiateConditionalType(root, newMapper, aliasSymbol, aliasTypeArguments); root.instantiations.set(id, result); } return result; } return type; } - function instantiateConditionalType(root, mapper) { + function instantiateConditionalType(root, mapper, aliasSymbol, aliasTypeArguments) { // Check if we have a conditional type where the check type is a naked type parameter. If so, // the conditional type is distributive over union types and when T is instantiated to a union // type A | B, we produce (A extends U ? X : Y) | (B extends U ? X : Y). @@ -57924,31 +59935,34 @@ var ts; var checkType_1 = root.checkType; var instantiatedType = getMappedType(checkType_1, mapper); if (checkType_1 !== instantiatedType && instantiatedType.flags & (1048576 /* Union */ | 131072 /* Never */)) { - return mapType(instantiatedType, function (t) { return getConditionalType(root, prependTypeMapping(checkType_1, t, mapper)); }); + return mapTypeWithAlias(instantiatedType, function (t) { return getConditionalType(root, prependTypeMapping(checkType_1, t, mapper)); }, aliasSymbol, aliasTypeArguments); } } - return getConditionalType(root, mapper); + return getConditionalType(root, mapper, aliasSymbol, aliasTypeArguments); } function instantiateType(type, mapper) { - if (!(type && mapper && couldContainTypeVariables(type))) { + return type && mapper ? instantiateTypeWithAlias(type, mapper, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined) : type; + } + function instantiateTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments) { + if (!couldContainTypeVariables(type)) { return type; } if (instantiationDepth === 50 || instantiationCount >= 5000000) { // We have reached 50 recursive type instantiations and there is a very high likelyhood we're dealing // with a combination of infinite generic types that perpetually generate new type identities. We stop // the recursion here by yielding the error type. - 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" /* CheckTypes */, "instantiateType_DepthLimit", { typeId: type.id, instantiationDepth: instantiationDepth, instantiationCount: instantiationCount }); error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite); return errorType; } totalInstantiationCount++; instantiationCount++; instantiationDepth++; - var result = instantiateTypeWorker(type, mapper); + var result = instantiateTypeWorker(type, mapper, aliasSymbol, aliasTypeArguments); instantiationDepth--; return result; } - function instantiateTypeWorker(type, mapper) { + function instantiateTypeWorker(type, mapper, aliasSymbol, aliasTypeArguments) { var flags = type.flags; if (flags & 262144 /* TypeParameter */) { return getMappedType(type, mapper); @@ -57956,12 +59970,15 @@ var ts; if (flags & 524288 /* Object */) { var objectFlags = type.objectFlags; if (objectFlags & (4 /* Reference */ | 16 /* Anonymous */ | 32 /* Mapped */)) { - if (objectFlags & 4 /* Reference */ && !(type.node)) { + if (objectFlags & 4 /* Reference */ && !type.node) { var resolvedTypeArguments = type.resolvedTypeArguments; var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper); return newTypeArguments !== resolvedTypeArguments ? createNormalizedTypeReference(type.target, newTypeArguments) : type; } - return getObjectTypeInstantiation(type, mapper); + if (objectFlags & 1024 /* ReverseMapped */) { + return instantiateReverseMappedType(type, mapper); + } + return getObjectTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments); } return type; } @@ -57969,10 +59986,14 @@ var ts; var origin = type.flags & 1048576 /* Union */ ? type.origin : undefined; var types = origin && origin.flags & 3145728 /* UnionOrIntersection */ ? origin.types : type.types; var newTypes = instantiateTypes(types, mapper); - return newTypes === types ? type : - flags & 2097152 /* Intersection */ || origin && origin.flags & 2097152 /* Intersection */ ? - getIntersectionType(newTypes, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) : - getUnionType(newTypes, 1 /* Literal */, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, 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 */ ? + getIntersectionType(newTypes, newAliasSymbol, newAliasTypeArguments) : + getUnionType(newTypes, 1 /* Literal */, newAliasSymbol, newAliasTypeArguments); } if (flags & 4194304 /* Index */) { return getIndexType(instantiateType(type.type, mapper)); @@ -57984,10 +60005,12 @@ var ts; return getStringMappingType(type.symbol, instantiateType(type.type, mapper)); } if (flags & 8388608 /* IndexedAccess */) { - return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper), type.noUncheckedIndexedAccessCandidate, /*accessNode*/ undefined, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); + 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 */) { - return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper)); + return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper), aliasSymbol, aliasTypeArguments); } if (flags & 33554432 /* Substitution */) { var maybeVariable = instantiateType(type.baseType, mapper); @@ -58004,6 +60027,21 @@ var ts; } return type; } + function instantiateReverseMappedType(type, mapper) { + var innerMappedType = instantiateType(type.mappedType, mapper); + if (!(ts.getObjectFlags(innerMappedType) & 32 /* Mapped */)) { + return type; + } + var innerIndexType = instantiateType(type.constraintType, mapper); + if (!(innerIndexType.flags & 4194304 /* Index */)) { + return type; + } + var instantiated = inferTypeForHomomorphicMappedType(instantiateType(type.source, mapper), innerMappedType, innerIndexType); + if (instantiated) { + return instantiated; + } + return type; // Nested invocation of `inferTypeForHomomorphicMappedType` or the `source` instantiated into something unmappable + } function getPermissiveInstantiation(type) { return type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */) ? type : type.permissiveInstantiation || (type.permissiveInstantiation = instantiateType(type, permissiveMapper)); @@ -58030,35 +60068,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 !== 165 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 167 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: - case 251 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 253 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type return isContextSensitiveFunctionLikeDeclaration(node); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return (node.operatorToken.kind === 56 /* BarBarToken */ || node.operatorToken.kind === 60 /* QuestionQuestionToken */) && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return isContextSensitive(node.expression); - case 281 /* JsxAttributes */: + case 283 /* JsxAttributes */: return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive); - case 280 /* JsxAttribute */: { + case 282 /* 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 283 /* JsxExpression */: { + case 285 /* JsxExpression */: { // It is possible to that node.expression is undefined (e.g

) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -58077,7 +60115,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 209 /* ArrowFunction */) { + if (node.kind !== 211 /* 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); @@ -58090,7 +60128,7 @@ 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 !== 230 /* Block */ && isContextSensitive(node.body); + return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 232 /* Block */ && isContextSensitive(node.body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && @@ -58193,23 +60231,23 @@ var ts; return true; } switch (node.kind) { - case 283 /* JsxExpression */: - case 207 /* ParenthesizedExpression */: + case 285 /* JsxExpression */: + case 209 /* ParenthesizedExpression */: return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 62 /* EqualsToken */: + case 63 /* EqualsToken */: case 27 /* CommaToken */: return elaborateError(node.right, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); } break; - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 281 /* JsxAttributes */: + case 283 /* JsxAttributes */: return elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer); } return false; @@ -58310,7 +60348,14 @@ var ts; if (!targetPropType || targetPropType.flags & 8388608 /* IndexedAccess */) continue; // Don't elaborate on indexes on generic variables var sourcePropType = getIndexedAccessTypeOrUndefined(source, nameType); - if (sourcePropType && !checkTypeRelatedTo(sourcePropType, targetPropType, relation, /*errorNode*/ undefined)) { + if (!sourcePropType) + continue; + var propName = getPropertyNameFromIndex(nameType, /*accessNode*/ undefined); + var targetIsOptional = !!(propName && (getPropertyOfType(target, propName) || unknownSymbol).flags & 16777216 /* Optional */); + var sourceIsOptional = !!(propName && (getPropertyOfType(source, propName) || unknownSymbol).flags & 16777216 /* Optional */); + targetPropType = removeMissingType(targetPropType, targetIsOptional); + sourcePropType = removeMissingType(sourcePropType, targetIsOptional && sourceIsOptional); + if (!checkTypeRelatedTo(sourcePropType, targetPropType, relation, /*errorNode*/ undefined)) { var elaborated = next && elaborateError(next, sourcePropType, targetPropType, relation, /*headMessage*/ undefined, containingMessageChain, errorOutputContainer); if (elaborated) { reportedError = true; @@ -58409,7 +60454,7 @@ var ts; } function getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic) { switch (child.kind) { - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: // child is of the type of the expression return { errorNode: child, innerExpression: child.expression, nameType: nameType }; case 11 /* JsxText */: @@ -58418,9 +60463,9 @@ var ts; } // child is a string return { errorNode: child, innerExpression: undefined, nameType: nameType, errorMessage: getInvalidTextDiagnostic() }; - case 273 /* JsxElement */: - case 274 /* JsxSelfClosingElement */: - case 277 /* JsxFragment */: + case 275 /* JsxElement */: + case 276 /* JsxSelfClosingElement */: + case 279 /* JsxFragment */: // child is of type JSX.Element return { errorNode: child, innerExpression: child, nameType: nameType }; default: @@ -58568,11 +60613,11 @@ var ts; } _b = prop.kind; switch (_b) { - case 168 /* SetAccessor */: return [3 /*break*/, 2]; - case 167 /* GetAccessor */: return [3 /*break*/, 2]; - case 165 /* MethodDeclaration */: return [3 /*break*/, 2]; - case 289 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; - case 288 /* PropertyAssignment */: return [3 /*break*/, 4]; + case 170 /* SetAccessor */: return [3 /*break*/, 2]; + case 169 /* GetAccessor */: return [3 /*break*/, 2]; + case 167 /* MethodDeclaration */: return [3 /*break*/, 2]; + case 291 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 290 /* PropertyAssignment */: return [3 /*break*/, 4]; } return [3 /*break*/, 6]; case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; @@ -58649,8 +60694,8 @@ var ts; return 0 /* False */; } var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - var strictVariance = !(checkMode & 3 /* Callback */) && strictFunctionTypes && kind !== 165 /* MethodDeclaration */ && - kind !== 164 /* MethodSignature */ && kind !== 166 /* Constructor */; + var strictVariance = !(checkMode & 3 /* Callback */) && strictFunctionTypes && kind !== 167 /* MethodDeclaration */ && + kind !== 166 /* MethodSignature */ && kind !== 168 /* Constructor */; var result = -1 /* True */; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { @@ -58883,7 +60928,7 @@ var ts; // 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 */ || t & 256 /* NumberLiteral */ && t & 1024 /* EnumLiteral */)) + if (s & (8 /* Number */ | 256 /* NumberLiteral */) && !(s & 1024 /* EnumLiteral */) && (t & 32 /* Enum */ || relation === assignableRelation && t & 256 /* NumberLiteral */ && t & 1024 /* EnumLiteral */)) return true; } return false; @@ -58920,7 +60965,7 @@ var ts; return false; } function isIgnoredJsxProperty(source, sourceProp) { - return ts.getObjectFlags(source) & 4096 /* JsxAttributes */ && !isUnhyphenatedJsxName(sourceProp.escapedName); + return ts.getObjectFlags(source) & 2048 /* JsxAttributes */ && !isUnhyphenatedJsxName(sourceProp.escapedName); } function getNormalizedType(type, writing) { while (true) { @@ -58930,6 +60975,7 @@ var ts; type.flags & 33554432 /* Substitution */ ? writing ? type.baseType : type.substitute : type.flags & 25165824 /* Simplifiable */ ? getSimplifiedType(type, writing) : type; + t = getSingleBaseForNonAugmentingSubtype(t) || t; if (t === type) break; type = t; @@ -58967,7 +61013,7 @@ var ts; reportIncompatibleStack(); } if (overflow) { - ts.tracing.instant("checkTypes" /* CheckTypes */, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: depth }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: depth }); 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); @@ -59103,6 +61149,14 @@ var ts; } break; } + case ts.Diagnostics.Type_at_position_0_in_source_is_not_compatible_with_type_at_position_1_in_target.code: { + secondaryRootErrors.unshift([ts.Diagnostics.Type_at_position_0_in_source_is_not_compatible_with_type_at_position_1_in_target, args[0], args[1]]); + break; + } + case ts.Diagnostics.Type_at_positions_0_through_1_in_source_is_not_compatible_with_type_at_position_2_in_target.code: { + secondaryRootErrors.unshift([ts.Diagnostics.Type_at_positions_0_through_1_in_source_is_not_compatible_with_type_at_position_2_in_target, args[0], args[1], args[2]]); + break; + } default: return ts.Debug.fail("Unhandled Diagnostic: " + msg.code); } @@ -59163,6 +61217,7 @@ var ts; reportError(ts.Diagnostics._0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2, needsOriginalSource ? sourceType : generalizedSourceType, targetType, typeToString(constraint)); } else { + errorInfo = undefined; reportError(ts.Diagnostics._0_could_be_instantiated_with_an_arbitrary_type_which_could_be_unrelated_to_1, targetType, generalizedSourceType); } } @@ -59238,7 +61293,7 @@ var ts; if (isSimpleTypeRelatedTo(originalSource, originalTarget, relation, reportErrors ? reportError : undefined)) { return -1 /* True */; } - reportErrorResults(originalSource, originalTarget, 0 /* False */, !!(ts.getObjectFlags(originalSource) & 4096 /* JsxAttributes */)); + reportErrorResults(originalSource, originalTarget, 0 /* False */, !!(ts.getObjectFlags(originalSource) & 2048 /* JsxAttributes */)); return 0 /* False */; } // Normalize the source and target types: Turn fresh literal types into regular literal types, @@ -59273,16 +61328,16 @@ var ts; target.types.length <= 3 && maybeTypeOfKind(target, 98304 /* Nullable */)) { var nullStrippedTarget = extractTypesOfKind(target, ~98304 /* Nullable */); if (!(nullStrippedTarget.flags & (1048576 /* Union */ | 131072 /* Never */))) { - if (source === nullStrippedTarget) - return -1 /* True */; - target = nullStrippedTarget; + target = getNormalizedType(nullStrippedTarget, /*writing*/ true); } + if (source === nullStrippedTarget) + return -1 /* True */; } if (relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return -1 /* True */; - var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096 /* JsxAttributes */); - var isPerformingExcessPropertyChecks = !(intersectionState & 2 /* Target */) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 32768 /* FreshLiteral */); + var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* JsxAttributes */); + var isPerformingExcessPropertyChecks = !(intersectionState & 2 /* Target */) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 16384 /* FreshLiteral */); if (isPerformingExcessPropertyChecks) { if (hasExcessProperties(source, target, reportErrors)) { if (reportErrors) { @@ -59367,7 +61422,7 @@ var ts; // We suppress recursive intersection property checks because they can generate lots of work when relating // recursive intersections that are structurally similar but not exactly identical. See #37854. if (result && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) || - isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 2097152 /* NonInferrableType */); }))) { + isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 524288 /* NonInferrableType */); }))) { inPropertyCheck = true; result &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */); inPropertyCheck = false; @@ -59376,8 +61431,10 @@ var ts; return result; function reportErrorResults(source, target, result, isComparingJsxAttributes) { if (!result && reportErrors) { - source = originalSource.aliasSymbol ? originalSource : source; - target = originalTarget.aliasSymbol ? originalTarget : target; + var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource); + var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget); + source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source; + target = (originalTarget.aliasSymbol || targetHasBase) ? originalTarget : target; var maybeSuppress = overrideNextErrorInfo > 0; if (maybeSuppress) { overrideNextErrorInfo--; @@ -59418,13 +61475,13 @@ var ts; } } function traceUnionsOrIntersectionsTooLarge(source, target) { - if (!ts.tracing.isTracing()) { + if (!ts.tracing) { return; } if ((source.flags & 3145728 /* UnionOrIntersection */) && (target.flags & 3145728 /* UnionOrIntersection */)) { var sourceUnionOrIntersection = source; var targetUnionOrIntersection = target; - if (sourceUnionOrIntersection.objectFlags & targetUnionOrIntersection.objectFlags & 262144 /* PrimitiveUnion */) { + if (sourceUnionOrIntersection.objectFlags & targetUnionOrIntersection.objectFlags & 65536 /* PrimitiveUnion */) { // There's a fast path for comparing primitive unions return; } @@ -59449,11 +61506,11 @@ var ts; } traceUnionsOrIntersectionsTooLarge(source, target); if (flags & 3145728 /* UnionOrIntersection */) { - var result_6 = eachTypeRelatedToSomeType(source, target); - if (result_6) { - result_6 &= eachTypeRelatedToSomeType(target, source); + var result_7 = eachTypeRelatedToSomeType(source, target); + if (result_7) { + result_7 &= eachTypeRelatedToSomeType(target, source); } - return result_6; + return result_7; } return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None */); } @@ -59467,10 +61524,11 @@ var ts; return getUnionType(ts.reduceLeft(types, appendPropType, /*initial*/ undefined) || ts.emptyArray); } function hasExcessProperties(source, target, reportErrors) { - if (!isExcessPropertyCheckTarget(target) || !noImplicitAny && ts.getObjectFlags(target) & 16384 /* JSLiteral */) { + var _a; + if (!isExcessPropertyCheckTarget(target) || !noImplicitAny && ts.getObjectFlags(target) & 8192 /* 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) & 4096 /* JsxAttributes */); + var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* JsxAttributes */); if ((relation === assignableRelation || relation === comparableRelation) && (isTypeSubsetOf(globalObjectType, target) || (!isComparingJsxAttributes && isEmptyObjectType(target)))) { return false; @@ -59513,7 +61571,7 @@ var ts; } else { // use the property's value declaration if the property is assigned inside the literal itself - var objectLiteralDeclaration_1 = source.symbol && ts.firstOrUndefined(source.symbol.declarations); + var objectLiteralDeclaration_1 = ((_a = source.symbol) === null || _a === void 0 ? void 0 : _a.declarations) && ts.firstOrUndefined(source.symbol.declarations); var suggestion = void 0; if (prop.valueDeclaration && ts.findAncestor(prop.valueDeclaration, function (d) { return d === objectLiteralDeclaration_1; }) && ts.getSourceFileOfNode(objectLiteralDeclaration_1) === ts.getSourceFileOfNode(errorNode)) { var propDeclaration = prop.valueDeclaration; @@ -59542,11 +61600,11 @@ var ts; } } }; - for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) { - var prop = _a[_i]; - var state_4 = _loop_16(prop); - if (typeof state_4 === "object") - return state_4.value; + for (var _i = 0, _b = getPropertiesOfType(source); _i < _b.length; _i++) { + var prop = _b[_i]; + var state_5 = _loop_16(prop); + if (typeof state_5 === "object") + return state_5.value; } return false; } @@ -59568,8 +61626,17 @@ var ts; } function typeRelatedToSomeType(source, target, reportErrors) { var targetTypes = target.types; - if (target.flags & 1048576 /* Union */ && containsType(targetTypes, source)) { - return -1 /* True */; + if (target.flags & 1048576 /* Union */) { + if (containsType(targetTypes, source)) { + return -1 /* True */; + } + var match = getMatchingUnionConstituentForType(target, source); + if (match) { + var related = isRelatedTo(source, match, /*reportErrors*/ false); + if (related) { + return related; + } + } } for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { var type = targetTypes_1[_i]; @@ -59743,9 +61810,16 @@ var ts; targetStack = []; } else { + // generate a key where all type parameter id positions are replaced with unconstrained type parameter ids + // this isn't perfect - nested type references passed as type arguments will muck up the indexes and thus + // prevent finding matches- but it should hit up the common cases + var broadestEquivalentId = id.split(",").map(function (i) { return i.replace(/-\d+/g, function (_match, offset) { + var index = ts.length(id.slice(0, offset).match(/[-=]/g) || undefined); + return "=" + index; + }); }).join(","); for (var i = 0; i < maybeCount; i++) { // If source and target are already being compared, consider them related with assumptions - if (id === maybeKeys[i]) { + if (id === maybeKeys[i] || broadestEquivalentId === maybeKeys[i]) { return 3 /* Maybe */; } } @@ -59775,7 +61849,7 @@ var ts; }; } if (expandingFlags === 3 /* Both */) { - ts.tracing.instant("checkTypes" /* CheckTypes */, "recursiveTypeRelatedTo_DepthLimit", { + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "recursiveTypeRelatedTo_DepthLimit", { sourceId: source.id, sourceIdStack: sourceStack.map(function (t) { return t.id; }), targetId: target.id, @@ -59810,9 +61884,9 @@ var ts; return result; } function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) { - 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" /* CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id }); var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; } function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState) { @@ -59834,8 +61908,21 @@ var ts; if (target.flags & 2097152 /* Intersection */) { return typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2 /* Target */); } - // Source is an intersection. Check to see if any constituents of the intersection are immediately related - // to the 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 */) { + var constraints = ts.sameMap(source.types, function (t) { return t.flags & 131068 /* Primitive */ ? t : getBaseConstraintOfType(t) || unknownType; }); + if (constraints !== source.types) { + source = getIntersectionType(constraints); + if (!(source.flags & 2097152 /* Intersection */)) { + return isRelatedTo(source, target, /*reportErrors*/ false); + } + } + } + // Check to see if any constituents of the intersection are immediately related to the target. // // Don't report errors though. Checking whether a constituent is related to the source is not actually // useful and leads to some confusing error messages. Instead it is better to let the below checks @@ -59855,21 +61942,21 @@ var ts; if (flags & 4194304 /* Index */) { return isRelatedTo(source.type, target.type, /*reportErrors*/ false); } - var result_7 = 0 /* False */; + var result_8 = 0 /* False */; if (flags & 8388608 /* IndexedAccess */) { - if (result_7 = isRelatedTo(source.objectType, target.objectType, /*reportErrors*/ false)) { - if (result_7 &= isRelatedTo(source.indexType, target.indexType, /*reportErrors*/ false)) { - return result_7; + if (result_8 = isRelatedTo(source.objectType, target.objectType, /*reportErrors*/ false)) { + if (result_8 &= isRelatedTo(source.indexType, target.indexType, /*reportErrors*/ false)) { + return result_8; } } } if (flags & 16777216 /* Conditional */) { if (source.root.isDistributive === target.root.isDistributive) { - if (result_7 = isRelatedTo(source.checkType, target.checkType, /*reportErrors*/ false)) { - if (result_7 &= isRelatedTo(source.extendsType, target.extendsType, /*reportErrors*/ false)) { - if (result_7 &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), /*reportErrors*/ false)) { - if (result_7 &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), /*reportErrors*/ false)) { - return result_7; + if (result_8 = isRelatedTo(source.checkType, target.checkType, /*reportErrors*/ false)) { + if (result_8 &= isRelatedTo(source.extendsType, target.extendsType, /*reportErrors*/ false)) { + if (result_8 &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), /*reportErrors*/ false)) { + if (result_8 &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), /*reportErrors*/ false)) { + return result_8; } } } @@ -59949,6 +62036,20 @@ var ts; } } else if (target.flags & 8388608 /* IndexedAccess */) { + if (source.flags & 8388608 /* 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, reportErrors)) { + result &= isRelatedTo(source.indexType, target.indexType, reportErrors); + } + if (result) { + resetErrorInfo(saveErrorInfo); + return result; + } + if (reportErrors) { + originalErrorInfo = errorInfo; + } + } // A type S is related to a type T[K] if S is related to C, where C is the base // constraint of T[K] for writing. if (relation === assignableRelation || relation === comparableRelation) { @@ -59957,13 +62058,26 @@ var ts; var baseObjectType = getBaseConstraintOfType(objectType) || objectType; var baseIndexType = getBaseConstraintOfType(indexType) || indexType; if (!isGenericObjectType(baseObjectType) && !isGenericIndexType(baseIndexType)) { - var accessFlags = 2 /* Writing */ | (baseObjectType !== objectType ? 1 /* NoIndexSignatures */ : 0); - var constraint = getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, target.noUncheckedIndexedAccessCandidate, /*accessNode*/ undefined, accessFlags); - if (constraint && (result = isRelatedTo(source, constraint, reportErrors))) { - return result; + var accessFlags = 4 /* Writing */ | (baseObjectType !== objectType ? 2 /* 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, reportErrors)) { + return result; + } + // prefer the shorter chain of the constraint comparison chain, and the direct comparison chain + if (reportErrors && originalErrorInfo && errorInfo) { + errorInfo = countMessageChainBreadth([originalErrorInfo]) <= countMessageChainBreadth([errorInfo]) ? originalErrorInfo : errorInfo; + } } } } + if (reportErrors) { + originalErrorInfo = undefined; + } } else if (isGenericMappedType(target) && !target.declaration.nameType) { // A source type T is related to a target type { [P in X]: T[P] } @@ -60007,27 +62121,48 @@ var ts; } } } - else if (target.flags & 134217728 /* TemplateLiteral */ && source.flags & 128 /* StringLiteral */) { - if (isPatternLiteralType(target)) { - // match all non-`string` segments - var result_8 = inferLiteralsFromTemplateLiteralType(source, target); - if (result_8 && ts.every(result_8, function (r, i) { return isStringLiteralTypeValueParsableAsType(r, target.types[i]); })) { - return -1 /* True */; - } + else if (target.flags & 16777216 /* Conditional */) { + var c = target; + // Check if the conditional is always true or always false but still deferred for distribution purposes + var skipTrue = !isTypeAssignableTo(getPermissiveInstantiation(c.checkType), getPermissiveInstantiation(c.extendsType)); + var skipFalse = !skipTrue && isConditionalTypeAlwaysTrueDisregardingInferTypes(c); + // Instantiate with a replacement mapper if the conditional is distributive, replacing the check type with a clone of itself, + // this way {x: string | number, y: string | number} -> (T extends T ? { x: T, y: T } : never) appropriately _fails_ when + // T = string | number (since that will end up distributing and producing `{x: string, y: string} | {x: number, y: number}`, + // to which `{x: string | number, y: string | number}` isn't assignable) + var distributionMapper = void 0; + var checkVar = getActualTypeVariable(c.root.checkType); + if (c.root.isDistributive && checkVar.flags & 262144 /* TypeParameter */) { + var newParam = cloneTypeParameter(checkVar); + distributionMapper = prependTypeMapping(checkVar, newParam, c.mapper); + newParam.mapper = distributionMapper; + } + // TODO: Find a nice way to include potential conditional type breakdowns in error output, if they seem good (they usually don't) + var localResult = void 0; + if (skipTrue || (localResult = isRelatedTo(source, distributionMapper ? instantiateType(getTypeFromTypeNode(c.root.node.trueType), distributionMapper) : getTrueTypeFromConditionalType(c), /*reportErrors*/ false))) { + if (!skipFalse) { + localResult = (localResult || 3 /* Maybe */) & isRelatedTo(source, distributionMapper ? instantiateType(getTypeFromTypeNode(c.root.node.falseType), distributionMapper) : getFalseTypeFromConditionalType(c), /*reportErrors*/ false); + } + } + if (localResult) { + resetErrorInfo(saveErrorInfo); + return localResult; } } - if (source.flags & 8650752 /* TypeVariable */) { - if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) { - // 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, reportErrors)) { - result &= isRelatedTo(source.indexType, target.indexType, reportErrors); - } - if (result) { - resetErrorInfo(saveErrorInfo); - return result; - } + else if (target.flags & 134217728 /* TemplateLiteral */) { + if (source.flags & 134217728 /* TemplateLiteral */) { + // 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)); } - else { + var result_9 = inferTypesFromTemplateLiteralType(source, target); + if (result_9 && ts.every(result_9, function (r, i) { return isValidTypeForTemplateLiteralPlaceholder(r, target.types[i]); })) { + return -1 /* True */; + } + } + if (source.flags & 8650752 /* TypeVariable */) { + // IndexedAccess comparisons are handled above in the `target.flags & TypeFlage.IndexedAccess` branch + if (!(source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */)) { var constraint = getConstraintOfType(source); if (!constraint || (source.flags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) { // A type variable with no constraint is not related to the non-primitive object type. @@ -60042,7 +62177,7 @@ var ts; 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, reportErrors, /*headMessage*/ undefined, intersectionState)) { + else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, reportErrors && !(target.flags & source.flags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) { resetErrorInfo(saveErrorInfo); return result; } @@ -60055,17 +62190,10 @@ var ts; } } else if (source.flags & 134217728 /* TemplateLiteral */) { - if (target.flags & 134217728 /* TemplateLiteral */) { - if (source.texts.length === target.texts.length && - source.types.length === target.types.length && - ts.every(source.texts, function (t, i) { return t === target.texts[i]; }) && - ts.every(instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)).types, function (t, i) { return !!(target.types[i].flags & (1 /* Any */ | 4 /* String */)) || !!isRelatedTo(t, target.types[i], /*reportErrors*/ false); })) { - return -1 /* True */; - } - } - else { - var constraint = getBaseConstraintOfType(source); - if (result = isRelatedTo(constraint && constraint !== source ? constraint : stringType, target, reportErrors)) { + if (!(target.flags & 134217728 /* TemplateLiteral */)) { + var baseConstraint = getBaseConstraintOfType(source); + var constraint = baseConstraint && baseConstraint !== source ? baseConstraint : stringType; + if (result = isRelatedTo(constraint, target, reportErrors)) { resetErrorInfo(saveErrorInfo); return result; } @@ -60097,7 +62225,7 @@ var ts; 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 */, isRelatedTo); - inferTypes(ctx.inferences, target.extendsType, sourceExtends, 256 /* NoConstraints */ | 512 /* AlwaysStrict */); + inferTypes(ctx.inferences, target.extendsType, sourceExtends, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */); sourceExtends = instantiateType(sourceExtends, ctx.mapper); mapper = ctx.mapper; } @@ -60155,7 +62283,7 @@ var ts; return 0 /* False */; } if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && source.target === target.target && - !(ts.getObjectFlags(source) & 8192 /* MarkerType */ || ts.getObjectFlags(target) & 8192 /* MarkerType */)) { + !(ts.getObjectFlags(source) & 4096 /* MarkerType */ || ts.getObjectFlags(target) & 4096 /* MarkerType */)) { // 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 // information for the type parameters and relate the type arguments accordingly. @@ -60183,7 +62311,7 @@ var ts; } // 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) & 32768 /* FreshLiteral */ && !isEmptyObjectType(source)) { + else if ((relation === subtypeRelation || relation === strictSubtypeRelation) && isEmptyObjectType(target) && ts.getObjectFlags(target) & 16384 /* FreshLiteral */ && !isEmptyObjectType(source)) { return 0 /* False */; } // Even if relationship doesn't hold for unions, intersections, or generic type references, @@ -60221,14 +62349,19 @@ var ts; if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */) && target.flags & 1048576 /* Union */) { var objectOnlyTarget = extractTypesOfKind(target, 524288 /* Object */ | 2097152 /* Intersection */ | 33554432 /* Substitution */); if (objectOnlyTarget.flags & 1048576 /* Union */) { - var result_9 = typeRelatedToDiscriminatedType(source, objectOnlyTarget); - if (result_9) { - return result_9; + var result_10 = typeRelatedToDiscriminatedType(source, objectOnlyTarget); + if (result_10) { + return result_10; } } } } return 0 /* False */; + function countMessageChainBreadth(info) { + if (!info) + return 0; + return ts.reduceLeft(info, function (value, chain) { return value + 1 + countMessageChainBreadth(chain.next); }, 0); + } function relateVariances(sourceTypeArguments, targetTypeArguments, variances, intersectionState) { if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors, intersectionState)) { return result; @@ -60290,13 +62423,13 @@ var ts; var modifiersRelated = relation === comparableRelation || (relation === identityRelation ? getMappedTypeModifiers(source) === getMappedTypeModifiers(target) : getCombinedMappedTypeOptionality(source) <= getCombinedMappedTypeOptionality(target)); if (modifiersRelated) { - var result_10; + var result_11; var targetConstraint = getConstraintTypeFromMappedType(target); var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), makeFunctionTypeMapper(getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMarkers : reportUnreliableMarkers)); - if (result_10 = isRelatedTo(targetConstraint, sourceConstraint, reportErrors)) { + if (result_11 = isRelatedTo(targetConstraint, sourceConstraint, 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), reportErrors); + return result_11 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), reportErrors); } } } @@ -60324,10 +62457,10 @@ var ts; var numCombinations = 1; for (var _i = 0, sourcePropertiesFiltered_1 = sourcePropertiesFiltered; _i < sourcePropertiesFiltered_1.length; _i++) { var sourceProperty = sourcePropertiesFiltered_1[_i]; - numCombinations *= countTypes(getTypeOfSymbol(sourceProperty)); + numCombinations *= countTypes(getNonMissingTypeOfSymbol(sourceProperty)); if (numCombinations > 25) { // We've reached the complexity limit. - ts.tracing.instant("checkTypes" /* CheckTypes */, "typeRelatedToDiscriminatedType_DepthLimit", { sourceId: source.id, targetId: target.id, numCombinations: numCombinations }); + 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 */; } } @@ -60336,7 +62469,7 @@ var ts; var excludedProperties = new ts.Set(); for (var i = 0; i < sourcePropertiesFiltered.length; i++) { var sourceProperty = sourcePropertiesFiltered[i]; - var sourcePropertyType = getTypeOfSymbol(sourceProperty); + var sourcePropertyType = getNonMissingTypeOfSymbol(sourceProperty); sourceDiscriminantTypes[i] = sourcePropertyType.flags & 1048576 /* Union */ ? sourcePropertyType.types : [sourcePropertyType]; @@ -60366,8 +62499,8 @@ var ts; } }; for (var i = 0; i < sourcePropertiesFiltered.length; i++) { - var state_6 = _loop_18(i); - switch (state_6) { + var state_7 = _loop_18(i); + switch (state_7) { case "continue-outer": continue outer; } } @@ -60380,9 +62513,9 @@ var ts; }; for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) { var combination = discriminantCombinations_1[_a]; - var state_5 = _loop_17(combination); - if (typeof state_5 === "object") - return state_5.value; + var state_6 = _loop_17(combination); + if (typeof state_6 === "object") + return state_6.value; } // Compare the remaining non-discriminant properties of each match. var result = -1 /* True */; @@ -60429,46 +62562,9 @@ var ts; } function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState) { var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* Partial */); - var source = getTypeOfSourceProperty(sourceProp); - if (ts.getCheckFlags(targetProp) & 65536 /* DeferredType */ && !getSymbolLinks(targetProp).type) { - // Rather than resolving (and normalizing) the type, relate constituent-by-constituent without performing normalization or seconadary passes - var links = getSymbolLinks(targetProp); - ts.Debug.assertIsDefined(links.deferralParent); - ts.Debug.assertIsDefined(links.deferralConstituents); - var unionParent = !!(links.deferralParent.flags & 1048576 /* Union */); - var result_11 = unionParent ? 0 /* False */ : -1 /* True */; - var targetTypes = links.deferralConstituents; - for (var _i = 0, targetTypes_3 = targetTypes; _i < targetTypes_3.length; _i++) { - var targetType = targetTypes_3[_i]; - var related = isRelatedTo(source, targetType, /*reportErrors*/ false, /*headMessage*/ undefined, unionParent ? 0 : 2 /* Target */); - if (!unionParent) { - if (!related) { - // Can't assign to a target individually - have to fallback to assigning to the _whole_ intersection (which forces normalization) - return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); - } - result_11 &= related; - } - else { - if (related) { - return related; - } - } - } - if (unionParent && !result_11 && targetIsOptional) { - result_11 = isRelatedTo(source, undefinedType); - } - if (unionParent && !result_11 && reportErrors) { - // The easiest way to get the right errors here is to un-defer (which may be costly) - // If it turns out this is too costly too often, we can replicate the error handling logic within - // typeRelatedToSomeType without the discriminatable type branch (as that requires a manifest union - // type on which to hand discriminable properties, which we are expressly trying to avoid here) - return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); - } - return result_11; - } - else { - return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors, /*headMessage*/ undefined, intersectionState); - } + var effectiveTarget = addOptionality(getNonMissingTypeOfSymbol(targetProp), /*isProperty*/ false, targetIsOptional); + var effectiveSource = getTypeOfSourceProperty(sourceProp); + return isRelatedTo(effectiveSource, effectiveTarget, reportErrors, /*headMessage*/ undefined, intersectionState); } function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState, skipOptional) { var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp); @@ -60597,7 +62693,7 @@ var ts; } return 0 /* False */; } - if (!targetRestFlag && sourceRestFlag) { + if (!targetRestFlag && (sourceRestFlag || targetArity < sourceArity)) { if (reportErrors) { if (sourceMinLength < targetMinLength) { reportError(ts.Diagnostics.Target_requires_0_element_s_but_source_may_have_fewer, targetMinLength); @@ -60645,10 +62741,11 @@ var ts; } } var sourceType = !isTupleType(source) ? sourceTypeArguments[0] : - i < startCount || i >= targetArity - endCount ? sourceTypeArguments[sourceIndex] : + i < startCount || i >= targetArity - endCount ? removeMissingType(sourceTypeArguments[sourceIndex], !!(sourceFlags & targetFlags & 2 /* Optional */)) : getElementTypeOfSliceOfTupleType(source, startCount, endCount) || neverType; var targetType = targetTypeArguments[i]; - var targetCheckType = sourceFlags & 8 /* Variadic */ && targetFlags & 4 /* Rest */ ? createArrayType(targetType) : targetType; + var targetCheckType = sourceFlags & 8 /* Variadic */ && targetFlags & 4 /* Rest */ ? createArrayType(targetType) : + removeMissingType(targetType, !!(targetFlags & 2 /* Optional */)); var related = isRelatedTo(sourceType, targetCheckType, reportErrors, /*headMessage*/ undefined, intersectionState); if (!related) { if (reportErrors) { @@ -60682,7 +62779,7 @@ var ts; var sourceProp = _a[_i]; if (!getPropertyOfObjectType(target, sourceProp.escapedName)) { var sourceType = getTypeOfSymbol(sourceProp); - if (!(sourceType === undefinedType || sourceType === undefinedWideningType || sourceType === optionalType)) { + if (!(sourceType.flags & 32768 /* Undefined */)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(sourceProp), typeToString(target)); } @@ -60701,7 +62798,7 @@ var ts; if (!(targetProp.flags & 4194304 /* Prototype */) && (!numericNamesOnly || isNumericLiteralName(name) || name === "length")) { var sourceProp = getPropertyOfType(source, name); if (sourceProp && sourceProp !== targetProp) { - var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, intersectionState, relation === comparableRelation); + var related = propertyRelatedTo(source, target, sourceProp, targetProp, getNonMissingTypeOfSymbol, reportErrors, intersectionState, relation === comparableRelation); if (!related) { return 0 /* False */; } @@ -60795,7 +62892,7 @@ var ts; 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) === 166 /* Constructor */ || ((_b = sourceSignature.declaration) === null || _b === void 0 ? void 0 : _b.kind) === 166 /* Constructor */)) { + (((_a = targetSignature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 168 /* Constructor */ || ((_b = sourceSignature.declaration) === null || _b === void 0 ? void 0 : _b.kind) === 168 /* Constructor */)) { var constructSignatureToString = function (signature) { return signatureToString(signature, /*enclosingDeclaration*/ undefined, 262144 /* WriteArrowStyleSignature */, kind); }; @@ -60903,10 +63000,17 @@ var ts; return indexTypesIdenticalTo(source, target, kind); } var targetType = getIndexTypeOfType(target, kind); - if (!targetType || targetType.flags & 1 /* Any */ && !sourceIsPrimitive) { - // Index signature of type any permits assignment from everything but primitives + if (!targetType) { return -1 /* True */; } + if (targetType.flags & 1 /* Any */ && !sourceIsPrimitive) { + // An index signature of type `any` permits assignment from everything but primitives, + // provided that there is also a `string` index signature of type `any`. + var stringIndexType = kind === 0 /* String */ ? targetType : getIndexTypeOfType(target, 0 /* String */); + if (stringIndexType && stringIndexType.flags & 1 /* Any */) { + return -1 /* True */; + } + } if (isGenericMappedType(source)) { // A generic mapped type { [P in K]: T } is related to a type with an index signature // { [x: string]: U }, and optionally with an index signature { [x: number]: V }, @@ -61061,7 +63165,7 @@ var ts; // type, and flag the result as a marker type reference. function getMarkerTypeReference(type, source, target) { var result = createTypeReference(type, ts.map(type.typeParameters, function (t) { return t === source ? target : t; })); - result.objectFlags |= 8192 /* MarkerType */; + result.objectFlags |= 4096 /* MarkerType */; return result; } function getAliasVariances(symbol) { @@ -61082,7 +63186,7 @@ var ts; if (typeParameters === void 0) { typeParameters = ts.emptyArray; } var variances = cache.variances; if (!variances) { - ts.tracing.push("checkTypes" /* CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: (_c = (_a = cache.id) !== null && _a !== void 0 ? _a : (_b = cache.declaredType) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : -1 }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: (_c = (_a = cache.id) !== null && _a !== void 0 ? _a : (_b = cache.declaredType) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : -1 }); // The emptyArray singleton is used to signal a recursive invocation. cache.variances = ts.emptyArray; variances = []; @@ -61121,7 +63225,7 @@ var ts; _loop_19(tp); } cache.variances = variances; - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } return variances; } @@ -61149,7 +63253,7 @@ var ts; return !!(ts.getObjectFlags(type) & 4 /* Reference */) && !type.node; } function isTypeReferenceWithGenericArguments(type) { - return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); + return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return !!(t.flags & 262144 /* TypeParameter */) || isTypeReferenceWithGenericArguments(t); }); } /** * getTypeReferenceId(A) returns "111=0-12=1" @@ -61235,8 +63339,8 @@ var ts; } // 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) { - return forEachProperty(prop, function (p) { return ts.getDeclarationModifierFlagsFromSymbol(p) & 16 /* Protected */ ? + function isClassDerivedFromDeclaringClasses(checkClass, prop, writing) { + return forEachProperty(prop, function (p) { return ts.getDeclarationModifierFlagsFromSymbol(p, writing) & 16 /* 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 @@ -61254,23 +63358,26 @@ var ts; function isDeeplyNestedType(type, stack, depth) { if (depth >= 5) { var identity_1 = getRecursionIdentity(type); - if (identity_1) { - var count = 0; - for (var i = 0; i < depth; i++) { - if (getRecursionIdentity(stack[i]) === identity_1) { - count++; - if (count >= 5) { - return true; - } + var count = 0; + for (var i = 0; i < depth; i++) { + if (getRecursionIdentity(stack[i]) === identity_1) { + count++; + if (count >= 5) { + return true; } } } } return false; } - // Types with constituents that could circularly reference the type have a recursion identity. The recursion - // identity is some object that is common to instantiations of the type with the same origin. + // The recursion identity of a type is an object identity that is shared among multiple instantiations of the type. + // We track recursion identities in order to identify deeply nested and possibly infinite type instantiations with + // the same origin. For example, when type parameters are in scope in an object type such as { x: T }, all + // instantiations of that type have the same recursion identity. The default recursion identity is the object + // identity of the type, meaning that every type is unique. Generally, types with constituents that could circularly + // 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) { // Deferred type references are tracked through their associated AST node. This gives us finer @@ -61288,6 +63395,9 @@ var ts; return type.target; } } + if (type.flags & 262144 /* TypeParameter */) { + return type.symbol; + } if (type.flags & 8388608 /* IndexedAccess */) { // Identity is the leftmost object type in a chain of indexed accesses, eg, in A[P][Q] it is A do { @@ -61299,7 +63409,7 @@ var ts; // The root object represents the origin of the conditional type return type.root; } - return undefined; + return type; } function isPropertyIdenticalTo(sourceProp, targetProp) { return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0 /* False */; @@ -61438,6 +63548,9 @@ var ts; // 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; }); @@ -61472,9 +63585,35 @@ var ts; // 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); } + function getSingleBaseForNonAugmentingSubtype(type) { + if (!(ts.getObjectFlags(type) & 4 /* Reference */) || !(ts.getObjectFlags(type.target) & 3 /* ClassOrInterface */)) { + return undefined; + } + if (ts.getObjectFlags(type) & 33554432 /* IdenticalBaseTypeCalculated */) { + return ts.getObjectFlags(type) & 67108864 /* IdenticalBaseTypeExists */ ? type.cachedEquivalentBaseType : undefined; + } + type.objectFlags |= 33554432 /* IdenticalBaseTypeCalculated */; + var target = type.target; + var bases = getBaseTypes(target); + if (bases.length !== 1) { + return undefined; + } + if (getMembersOfSymbol(type.symbol).size) { + return undefined; // If the interface has any members, they may subtype members in the base, so we should do a full structural comparison + } + var instantiatedBase = !ts.length(target.typeParameters) ? bases[0] : instantiateType(bases[0], createTypeMapper(target.typeParameters, getTypeArguments(type).slice(0, target.typeParameters.length))); + if (ts.length(getTypeArguments(type)) > ts.length(target.typeParameters)) { + instantiatedBase = getTypeWithThisArgument(instantiatedBase, ts.last(getTypeArguments(type))); + } + type.objectFlags |= 67108864 /* IdenticalBaseTypeExists */; + return type.cachedEquivalentBaseType = instantiatedBase; + } + function isEmptyLiteralType(type) { + return strictNullChecks ? type === implicitNeverType : type === undefinedWideningType; + } function isEmptyArrayLiteralType(type) { - var elementType = isArrayType(type) ? getTypeArguments(type)[0] : undefined; - return elementType === undefinedWideningType || elementType === implicitNeverType; + var elementType = getElementTypeOfArrayType(type); + return !!elementType && isEmptyLiteralType(elementType); } function isTupleLikeType(type) { return isTupleType(type) || !!getPropertyOfType(type, "0"); @@ -61498,6 +63637,13 @@ var ts; function isUnitType(type) { return !!(type.flags & 109440 /* Unit */); } + function isUnitLikeType(type) { + return type.flags & 2097152 /* Intersection */ ? ts.some(type.types, isUnitType) : + !!(type.flags & 109440 /* Unit */); + } + function extractUnitType(type) { + return type.flags & 2097152 /* 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) : @@ -61505,7 +63651,7 @@ var ts; } function getBaseTypeOfLiteralType(type) { return type.flags & 1024 /* EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : - type.flags & 134217856 /* StringLikeLiteral */ ? stringType : + type.flags & 128 /* StringLiteral */ ? stringType : type.flags & 256 /* NumberLiteral */ ? numberType : type.flags & 2048 /* BigIntLiteral */ ? bigintType : type.flags & 512 /* BooleanLiteral */ ? booleanType : @@ -61514,7 +63660,7 @@ var ts; } function getWidenedLiteralType(type) { return type.flags & 1024 /* EnumLiteral */ && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(type) : - type.flags & 134217856 /* StringLikeLiteral */ && isFreshLiteralType(type) ? stringType : + 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 : @@ -61643,19 +63789,23 @@ var ts; missing === 65536 /* Null */ ? getUnionType([type, nullType]) : getUnionType([type, undefinedType, nullType]); } - function getOptionalType(type) { + function getOptionalType(type, isProperty) { + if (isProperty === void 0) { isProperty = false; } ts.Debug.assert(strictNullChecks); - return type.flags & 32768 /* Undefined */ ? type : getUnionType([type, undefinedType]); + return type.flags & 32768 /* Undefined */ ? type : getUnionType([type, isProperty ? missingType : undefinedType]); } function getGlobalNonNullableTypeInstantiation(type) { + // First reduce away any constituents that are assignable to 'undefined' or 'null'. This not only eliminates + // 'undefined' and 'null', but also higher-order types such as a type parameter 'U extends undefined | null' + // that isn't eliminated by a NonNullable instantiation. + var reducedType = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); if (!deferredGlobalNonNullableTypeAlias) { deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288 /* TypeAlias */, /*diagnostic*/ undefined) || unknownSymbol; } - // Use NonNullable global type alias if available to improve quick info/declaration emit - if (deferredGlobalNonNullableTypeAlias !== unknownSymbol) { - return getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]); - } - return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); // Type alias unavailable, fall back to non-higher-order behavior + // If the NonNullable type is available, return an instantiation. Otherwise just return the reduced type. + return deferredGlobalNonNullableTypeAlias !== unknownSymbol ? + getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [reducedType]) : + reducedType; } function getNonNullableType(type) { return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type; @@ -61677,6 +63827,12 @@ var ts; ts.isOptionalChain(expression) ? removeOptionalTypeMarker(exprType) : exprType; } + function removeMissingType(type, isOptional) { + return strictOptionalProperties && isOptional ? filterType(type, function (t) { return t !== missingType; }) : type; + } + function containsMissingType(type) { + return strictOptionalProperties && (type === missingType || type.flags & 1048576 /* Union */ && containsType(type.types, missingType)); + } /** * Is source potentially coercible to target type under `==`. * Assumes that `source` is a constituent of a union, hence @@ -61708,7 +63864,7 @@ var ts; function isObjectTypeWithInferableIndex(type) { return type.flags & 2097152 /* Intersection */ ? ts.every(type.types, isObjectTypeWithInferableIndex) : !!(type.symbol && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 && - !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 2048 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); + !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 1024 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); } function createSymbolWithType(source, type) { var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */); @@ -61741,7 +63897,7 @@ var ts; * Leave signatures alone since they are not subject to the check. */ function getRegularTypeOfObjectLiteral(type) { - if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 32768 /* FreshLiteral */)) { + if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 16384 /* FreshLiteral */)) { return type; } var regularType = type.regularType; @@ -61752,7 +63908,7 @@ var ts; var members = transformTypeOfMembers(type, getRegularTypeOfObjectLiteral); var regularNew = createAnonymousType(resolved.symbol, members, resolved.callSignatures, resolved.constructSignatures, resolved.stringIndexInfo, resolved.numberIndexInfo); regularNew.flags = resolved.flags; - regularNew.objectFlags |= resolved.objectFlags & ~32768 /* FreshLiteral */; + regularNew.objectFlags |= resolved.objectFlags & ~16384 /* FreshLiteral */; type.regularType = regularNew; return regularNew; } @@ -61782,7 +63938,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) & 1024 /* ContainsSpread */)) { + if (isObjectLiteralType(t) && !(ts.getObjectFlags(t) & 4194304 /* ContainsSpread */)) { for (var _b = 0, _c = getPropertiesOfType(t); _b < _c.length; _b++) { var prop = _c[_b]; names.set(prop.escapedName, prop); @@ -61809,7 +63965,7 @@ var ts; if (cached) { return cached; } - var result = createSymbolWithType(prop, undefinedType); + var result = createSymbolWithType(prop, missingType); result.flags |= 16777216 /* Optional */; undefinedProperties.set(prop.escapedName, result); return result; @@ -61831,14 +63987,14 @@ var ts; var stringIndexInfo = getIndexInfoOfType(type, 0 /* String */); var numberIndexInfo = getIndexInfoOfType(type, 1 /* Number */); var result = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, stringIndexInfo && createIndexInfo(getWidenedType(stringIndexInfo.type), stringIndexInfo.isReadonly), numberIndexInfo && createIndexInfo(getWidenedType(numberIndexInfo.type), numberIndexInfo.isReadonly)); - result.objectFlags |= (ts.getObjectFlags(type) & (16384 /* JSLiteral */ | 2097152 /* NonInferrableType */)); // Retain js literal flag through widening + result.objectFlags |= (ts.getObjectFlags(type) & (8192 /* JSLiteral */ | 524288 /* 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) & 1572864 /* RequiresWidening */) { + if (ts.getObjectFlags(type) & 393216 /* RequiresWidening */) { if (context === undefined && type.widened) { return type.widened; } @@ -61883,7 +64039,7 @@ var ts; */ function reportWideningErrorsInType(type) { var errorReported = false; - if (ts.getObjectFlags(type) & 524288 /* ContainsWideningType */) { + if (ts.getObjectFlags(type) & 131072 /* ContainsWideningType */) { if (type.flags & 1048576 /* Union */) { if (ts.some(type.types, isEmptyObjectType)) { errorReported = true; @@ -61909,7 +64065,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) & 524288 /* ContainsWideningType */) { + if (ts.getObjectFlags(t) & 131072 /* ContainsWideningType */) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, symbolToString(p), typeToString(getWidenedType(t))); } @@ -61928,12 +64084,12 @@ var ts; } var diagnostic; switch (declaration.kind) { - case 216 /* BinaryExpression */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 218 /* BinaryExpression */: + case 165 /* PropertyDeclaration */: + case 164 /* 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 160 /* Parameter */: + case 162 /* Parameter */: var param = declaration; if (ts.isIdentifier(param.name) && (ts.isCallSignatureDeclaration(param.parent) || ts.isMethodSignature(param.parent) || ts.isFunctionTypeNode(param.parent)) && @@ -61948,23 +64104,23 @@ 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 198 /* BindingElement */: + case 200 /* 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 308 /* JSDocFunctionType */: + case 311 /* JSDocFunctionType */: error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; - case 251 /* FunctionDeclaration */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 253 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: if (noImplicitAny && !declaration.name) { if (wideningKind === 3 /* 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); @@ -61978,7 +64134,7 @@ var ts; wideningKind === 3 /* 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 190 /* MappedType */: + case 192 /* MappedType */: if (noImplicitAny) { error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); } @@ -61989,7 +64145,7 @@ var ts; errorOrSuggestion(noImplicitAny, declaration, diagnostic, ts.declarationNameToString(ts.getNameOfDeclaration(declaration)), typeAsString); } function reportErrorsFromWidening(declaration, type, wideningKind) { - if (produceDiagnostics && noImplicitAny && ts.getObjectFlags(type) & 524288 /* ContainsWideningType */ && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) { + if (produceDiagnostics && noImplicitAny && ts.getObjectFlags(type) & 131072 /* ContainsWideningType */ && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) { // Report implicit any error within type if possible, otherwise report error on declaration if (!reportWideningErrorsInType(type)) { reportImplicitAny(declaration, type, wideningKind); @@ -62105,23 +64261,23 @@ var ts; // results for union and intersection types for performance reasons. function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); - if (objectFlags & 67108864 /* CouldContainTypeVariablesComputed */) { - return !!(objectFlags & 134217728 /* CouldContainTypeVariables */); + if (objectFlags & 1048576 /* CouldContainTypeVariablesComputed */) { + return !!(objectFlags & 2097152 /* 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 */ | 131072 /* ObjectRestType */)) || + objectFlags & (32 /* Mapped */ | 1024 /* ReverseMapped */ | 8388608 /* ObjectRestType */)) || type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && !isNonGenericTopLevelType(type) && ts.some(type.types, couldContainTypeVariables)); if (type.flags & 3899393 /* ObjectFlagsType */) { - type.objectFlags |= 67108864 /* CouldContainTypeVariablesComputed */ | (result ? 134217728 /* CouldContainTypeVariables */ : 0); + type.objectFlags |= 1048576 /* CouldContainTypeVariablesComputed */ | (result ? 2097152 /* CouldContainTypeVariables */ : 0); } return result; } function isNonGenericTopLevelType(type) { if (type.aliasSymbol && !type.aliasTypeArguments) { - var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 254 /* TypeAliasDeclaration */); - return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 297 /* SourceFile */ ? true : n.kind === 256 /* ModuleDeclaration */ ? false : "quit"; })); + var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 256 /* TypeAliasDeclaration */); + return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 299 /* SourceFile */ ? true : n.kind === 258 /* ModuleDeclaration */ ? false : "quit"; })); } return false; } @@ -62174,7 +64330,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) & 2097152 /* NonInferrableType */) || + return !(ts.getObjectFlags(type) & 524288 /* NonInferrableType */) || isObjectLiteralType(type) && ts.some(getPropertiesOfType(type), function (prop) { return isPartiallyInferableType(getTypeOfSymbol(prop)); }) || isTupleType(type) && ts.some(getTypeArguments(type), isPartiallyInferableType); } @@ -62198,14 +64354,18 @@ var ts; } // 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(2048 /* ReverseMapped */ | 16 /* Anonymous */, /*symbol*/ undefined); + var reversed = createObjectType(1024 /* ReverseMapped */ | 16 /* Anonymous */, /*symbol*/ undefined); reversed.source = source; reversed.mappedType = target; reversed.constraintType = constraint; return reversed; } function getTypeOfReverseMappedSymbol(symbol) { - return inferReverseMappedType(symbol.propertyType, symbol.mappedType, symbol.constraintType); + var links = getSymbolLinks(symbol); + if (!links.type) { + links.type = inferReverseMappedType(symbol.propertyType, symbol.mappedType, symbol.constraintType); + } + return links.type; } function inferReverseMappedType(sourceType, target, constraint) { var typeParameter = getIndexedAccessType(constraint.type, getTypeParameterFromMappedType(target)); @@ -62297,51 +64457,113 @@ var ts; // * 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 */); } - function isStringLiteralTypeValueParsableAsType(s, target) { - if (target.flags & 1048576 /* Union */) { - return !!forEachType(target, function (t) { return isStringLiteralTypeValueParsableAsType(s, t); }); - } - switch (target) { - case stringType: return true; - case numberType: return s.value !== "" && isFinite(+(s.value)); - case bigintType: return s.value !== "" && isValidBigIntString(s.value); - // the next 4 should be handled in `getTemplateLiteralType`, as they are all exactly one value, but are here for completeness, just in case - // this function is ever used on types which don't come from template literal holes - case trueType: return s.value === "true"; - case falseType: return s.value === "false"; - case undefinedType: return s.value === "undefined"; - case nullType: return s.value === "null"; - default: return !!(target.flags & 1 /* Any */); - } - } - function inferLiteralsFromTemplateLiteralType(source, target) { - var value = source.value; - var texts = target.texts; - var lastIndex = texts.length - 1; - var startText = texts[0]; - var endText = texts[lastIndex]; - if (!(value.startsWith(startText) && value.slice(startText.length).endsWith(endText))) + function isValidTypeForTemplateLiteralPlaceholder(source, target) { + if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) { + return true; + } + if (source.flags & 128 /* StringLiteral */) { + var value = source.value; + return !!(target.flags & 8 /* Number */ && value !== "" && isFinite(+value) || + target.flags & 64 /* BigInt */ && value !== "" && isValidBigIntString(value) || + target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName); + } + if (source.flags & 134217728 /* 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 */ ? + ts.arraysEqual(source.texts, target.texts) ? ts.map(source.types, getStringLikeTypeForType) : + inferFromLiteralPartsToTemplateLiteral(source.texts, source.types, target) : + undefined; + } + function getStringLikeTypeForType(type) { + return type.flags & (1 /* Any */ | 402653316 /* 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 + // with one text part and zero type parts. The function returns an array of inferred string or template literal types + // corresponding to the placeholders in the target template literal, or undefined if the source doesn't match the target. + // + // We first check that the starting source text part matches the starting target text part, and that the ending source + // text part ends matches the ending target text part. We then iterate through the remaining target text parts, finding + // a match for each in the source and inferring string or template literal types created from the segments of the source + // that occur between the matches. During this iteration, seg holds the index of the current text part in the sourceTexts + // array and pos holds the current character position in the current text part. + // + // Consider inference from type `<<${string}>.<${number}-${number}>>` to type `<${string}.${string}>`, i.e. + // sourceTexts = ['<<', '>.<', '-', '>>'] + // sourceTypes = [string, number, number] + // target.texts = ['<', '.', '>'] + // We first match '<' in the target to the start of '<<' in the source and '>' in the target to the end of '>>' in + // the source. The first match for the '.' in target occurs at character 1 in the source text part at index 1, and thus + // the first inference is the template literal type `<${string}>`. The remainder of the source makes up the second + // inference, the template literal type `<${number}-${number}>`. + function inferFromLiteralPartsToTemplateLiteral(sourceTexts, sourceTypes, target) { + var lastSourceIndex = sourceTexts.length - 1; + var sourceStartText = sourceTexts[0]; + var sourceEndText = sourceTexts[lastSourceIndex]; + var targetTexts = target.texts; + var lastTargetIndex = targetTexts.length - 1; + var targetStartText = targetTexts[0]; + var targetEndText = targetTexts[lastTargetIndex]; + if (lastSourceIndex === 0 && sourceStartText.length < targetStartText.length + targetEndText.length || + !sourceStartText.startsWith(targetStartText) || !sourceEndText.endsWith(targetEndText)) return undefined; + var remainingEndText = sourceEndText.slice(0, sourceEndText.length - targetEndText.length); var matches = []; - var str = value.slice(startText.length, value.length - endText.length); - var pos = 0; - for (var i = 1; i < lastIndex; i++) { - var delim = texts[i]; - var delimPos = delim.length > 0 ? str.indexOf(delim, pos) : pos < str.length ? pos + 1 : -1; - if (delimPos < 0) + var seg = 0; + var pos = targetStartText.length; + for (var i = 1; i < lastTargetIndex; i++) { + var delim = targetTexts[i]; + if (delim.length > 0) { + var s = seg; + var p = pos; + while (true) { + p = getSourceText(s).indexOf(delim, p); + if (p >= 0) + break; + s++; + if (s === sourceTexts.length) + return undefined; + p = 0; + } + addMatch(s, p); + pos += delim.length; + } + else if (pos < getSourceText(seg).length) { + addMatch(seg, pos + 1); + } + else if (seg < lastSourceIndex) { + addMatch(seg + 1, 0); + } + else { return undefined; - matches.push(getLiteralType(str.slice(pos, delimPos))); - pos = delimPos + delim.length; + } } - matches.push(getLiteralType(str.slice(pos))); + addMatch(lastSourceIndex, getSourceText(lastSourceIndex).length); return matches; + function getSourceText(index) { + return index < lastSourceIndex ? sourceTexts[index] : remainingEndText; + } + function addMatch(s, p) { + var matchType = s === seg ? + getLiteralType(getSourceText(s).slice(pos, p)) : + getTemplateLiteralType(__spreadArray(__spreadArray([sourceTexts[seg].slice(pos)], sourceTexts.slice(seg + 1, s)), [getSourceText(s).slice(0, p)]), sourceTypes.slice(seg, s)); + matches.push(matchType); + seg = s; + pos = p; + } } function inferTypes(inferences, originalSource, originalTarget, priority, contravariant) { if (priority === void 0) { priority = 0; } if (contravariant === void 0) { contravariant = false; } var bivariant = false; var propagationType; - var inferencePriority = 1024 /* MaxValue */; + var inferencePriority = 2048 /* MaxValue */; var allowComplexConstraintInference = true; var visited; var sourceStack; @@ -62428,8 +64650,8 @@ var ts; // 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 (ts.getObjectFlags(source) & 2097152 /* NonInferrableType */ || source === nonInferrableAnyType || source === silentNeverType || - (priority & 64 /* ReturnType */ && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) { + if (ts.getObjectFlags(source) & 524288 /* NonInferrableType */ || source === nonInferrableAnyType || source === silentNeverType || + (priority & 128 /* ReturnType */ && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) { return; } var inference = getInferenceInfoForType(target); @@ -62456,7 +64678,7 @@ var ts; clearCachedInferences(inferences); } } - if (!(priority & 64 /* ReturnType */) && target.flags & 262144 /* TypeParameter */ && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) { + if (!(priority & 128 /* ReturnType */) && target.flags & 262144 /* TypeParameter */ && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) { inference.topLevel = false; clearCachedInferences(inferences); } @@ -62496,7 +64718,7 @@ var ts; else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 4194304 /* Index */) { var empty = createEmptyObjectTypeFromStringLiteral(source); contravariant = !contravariant; - inferWithPriority(empty, target.type, 128 /* LiteralKeyof */); + inferWithPriority(empty, target.type, 256 /* LiteralKeyof */); contravariant = !contravariant; } else if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) { @@ -62508,6 +64730,13 @@ var ts; inferFromTypes(source.type, target.type); } } + else if (source.flags & 33554432 /* Substitution */) { + inferFromTypes(source.baseType, target); + var oldPriority = priority; + priority |= 4 /* SubstituteSource */; + inferFromTypes(source.substitute, target); // Make substitute inference at a lower priority + priority = oldPriority; + } else if (target.flags & 16777216 /* Conditional */) { invokeOnce(source, target, inferToConditionalType); } @@ -62527,7 +64756,7 @@ var ts; } else { source = getReducedType(source); - if (!(priority & 256 /* NoConstraints */ && source.flags & (2097152 /* Intersection */ | 465829888 /* Instantiable */))) { + if (!(priority & 512 /* NoConstraints */ && source.flags & (2097152 /* Intersection */ | 465829888 /* 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` @@ -62565,26 +64794,22 @@ var ts; } (visited || (visited = new ts.Map())).set(key, -1 /* Circularity */); var saveInferencePriority = inferencePriority; - inferencePriority = 1024 /* MaxValue */; + inferencePriority = 2048 /* 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) || source; - var targetIdentity = getRecursionIdentity(target) || target; - if (sourceIdentity && ts.contains(sourceStack, sourceIdentity)) + var sourceIdentity = getRecursionIdentity(source); + var targetIdentity = getRecursionIdentity(target); + if (ts.contains(sourceStack, sourceIdentity)) expandingFlags |= 1 /* Source */; - if (targetIdentity && ts.contains(targetStack, targetIdentity)) + if (ts.contains(targetStack, targetIdentity)) expandingFlags |= 2 /* Target */; if (expandingFlags !== 3 /* Both */) { - if (sourceIdentity) - (sourceStack || (sourceStack = [])).push(sourceIdentity); - if (targetIdentity) - (targetStack || (targetStack = [])).push(targetIdentity); + (sourceStack || (sourceStack = [])).push(sourceIdentity); + (targetStack || (targetStack = [])).push(targetIdentity); action(source, target); - if (targetIdentity) - targetStack.pop(); - if (sourceIdentity) - sourceStack.pop(); + targetStack.pop(); + sourceStack.pop(); } else { inferencePriority = -1 /* Circularity */; @@ -62624,7 +64849,7 @@ var ts; } } function inferFromContravariantTypes(source, target) { - if (strictFunctionTypes || priority & 512 /* AlwaysStrict */) { + if (strictFunctionTypes || priority & 1024 /* AlwaysStrict */) { contravariant = !contravariant; inferFromTypes(source, target); contravariant = !contravariant; @@ -62676,7 +64901,7 @@ var ts; else { for (var i = 0; i < sources.length; i++) { var saveInferencePriority = inferencePriority; - inferencePriority = 1024 /* MaxValue */; + inferencePriority = 2048 /* MaxValue */; inferFromTypes(sources[i], t); if (inferencePriority === priority) matched_1[i] = true; @@ -62755,9 +64980,9 @@ 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) & 2097152 /* NonInferrableType */ ? - 8 /* PartialHomomorphicMappedType */ : - 4 /* HomomorphicMappedType */); + inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 524288 /* NonInferrableType */ ? + 16 /* PartialHomomorphicMappedType */ : + 8 /* HomomorphicMappedType */); } } return true; @@ -62765,7 +64990,7 @@ var ts; if (constraintType.flags & 262144 /* 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, 16 /* MappedTypeConstraint */); + inferWithPriority(getIndexType(source), constraintType, 32 /* 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 @@ -62794,16 +65019,14 @@ var ts; } else { var savePriority = priority; - priority |= contravariant ? 32 /* ContravariantConditional */ : 0; + priority |= contravariant ? 64 /* ContravariantConditional */ : 0; var targetTypes = [getTrueTypeFromConditionalType(target), getFalseTypeFromConditionalType(target)]; inferToMultipleTypes(source, targetTypes, target.flags); priority = savePriority; } } function inferToTemplateLiteralType(source, target) { - var matches = source.flags & 128 /* StringLiteral */ ? inferLiteralsFromTemplateLiteralType(source, target) : - source.flags & 134217728 /* TemplateLiteral */ && ts.arraysEqual(source.texts, target.texts) ? source.types : - undefined; + var matches = inferTypesFromTemplateLiteralType(source, target); var types = target.types; for (var i = 0; i < types.length; i++) { inferFromTypes(matches ? matches[i] : neverType, types[i]); @@ -62919,7 +65142,7 @@ var ts; var sourceLen = sourceSignatures.length; var targetLen = targetSignatures.length; var len = sourceLen < targetLen ? sourceLen : targetLen; - var skipParameters = !!(ts.getObjectFlags(source) & 2097152 /* NonInferrableType */); + var skipParameters = !!(ts.getObjectFlags(source) & 524288 /* NonInferrableType */); for (var i = 0; i < len; i++) { inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i]), skipParameters); } @@ -62929,19 +65152,21 @@ var ts; 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 === 165 /* MethodDeclaration */ || kind === 164 /* MethodSignature */ || kind === 166 /* Constructor */; + bivariant = bivariant || kind === 167 /* MethodDeclaration */ || kind === 166 /* MethodSignature */ || kind === 168 /* Constructor */; applyToParameterTypes(source, target, inferFromContravariantTypes); 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 targetStringIndexType = getIndexTypeOfType(target, 0 /* String */); if (targetStringIndexType) { var sourceIndexType = getIndexTypeOfType(source, 0 /* String */) || getImplicitIndexTypeOfType(source, 0 /* String */); if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetStringIndexType); + inferWithPriority(sourceIndexType, targetStringIndexType, priority); } } var targetNumberIndexType = getIndexTypeOfType(target, 1 /* Number */); @@ -62950,13 +65175,13 @@ var ts; getIndexTypeOfType(source, 0 /* String */) || getImplicitIndexTypeOfType(source, 1 /* Number */); if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetNumberIndexType); + inferWithPriority(sourceIndexType, targetNumberIndexType, priority); } } } } function isTypeOrBaseIdenticalTo(s, t) { - return isTypeIdenticalTo(s, t) || !!(t.flags & 4 /* String */ && s.flags & 134217856 /* StringLikeLiteral */ || t.flags & 8 /* Number */ && s.flags & 256 /* NumberLiteral */); + return isTypeIdenticalTo(s, t) || !!(t.flags & 4 /* String */ && s.flags & 128 /* StringLiteral */ || t.flags & 8 /* Number */ && s.flags & 256 /* NumberLiteral */); } function isTypeCloselyMatchedBy(s, t) { return !!(s.flags & 524288 /* Object */ && t.flags & 524288 /* Object */ && s.symbol && s.symbol === t.symbol || @@ -62970,7 +65195,7 @@ var ts; return !!(ts.getObjectFlags(type) & 128 /* ObjectLiteral */); } function isObjectOrArrayLiteralType(type) { - return !!(ts.getObjectFlags(type) & (128 /* ObjectLiteral */ | 65536 /* ArrayLiteral */)); + return !!(ts.getObjectFlags(type) & (128 /* ObjectLiteral */ | 32768 /* ArrayLiteral */)); } function unionObjectAndArrayLiteralCandidates(candidates) { if (candidates.length > 1) { @@ -62983,7 +65208,7 @@ var ts; return candidates; } function getContravariantInference(inference) { - return inference.priority & 208 /* PriorityImpliesCombination */ ? getIntersectionType(inference.contraCandidates) : getCommonSubtype(inference.contraCandidates); + return inference.priority & 416 /* 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. @@ -63000,7 +65225,7 @@ 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 & 208 /* PriorityImpliesCombination */ ? + var unwidenedType = inference.priority & 416 /* PriorityImpliesCombination */ ? getUnionType(baseCandidates, 2 /* Subtype */) : getCommonSupertype(baseCandidates); return getWidenedType(unwidenedType); @@ -63109,7 +65334,7 @@ var ts; case "BigUint64Array": return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_1_or_later; default: - if (node.parent.kind === 289 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 291 /* ShorthandPropertyAssignment */) { return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer; } else { @@ -63130,26 +65355,27 @@ 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 === 176 /* TypeQuery */ ? true : n.kind === 78 /* Identifier */ || n.kind === 157 /* QualifiedName */ ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 178 /* TypeQuery */ ? true : n.kind === 79 /* Identifier */ || n.kind === 159 /* 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 // leftmost identifier followed by zero or more property names separated by dots. - // The result is undefined if the reference isn't a dotted name. We prefix nodes - // occurring in an apparent type position with '@' because the control flow type - // of such nodes may be based on the apparent type instead of the declared type. + // The result is undefined if the reference isn't a dotted name. function getFlowCacheKey(node, declaredType, initialType, flowContainer) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: var symbol = getResolvedSymbol(node); - return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + (isConstraintPosition(node) ? "@" : "") + getSymbolId(symbol) : undefined; - case 107 /* ThisKeyword */: + return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + getSymbolId(symbol) : undefined; + case 108 /* ThisKeyword */: return "0|" + (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType); - case 225 /* NonNullExpression */: - case 207 /* ParenthesizedExpression */: + case 227 /* NonNullExpression */: + case 209 /* ParenthesizedExpression */: return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 159 /* QualifiedName */: + var left = getFlowCacheKey(node.left, declaredType, initialType, flowContainer); + return left && left + "." + node.right.escapedText; + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: var propName = getAccessedPropertyName(node); if (propName !== undefined) { var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); @@ -63160,32 +65386,40 @@ var ts; } function isMatchingReference(source, target) { switch (target.kind) { - case 207 /* ParenthesizedExpression */: - case 225 /* NonNullExpression */: + case 209 /* ParenthesizedExpression */: + case 227 /* NonNullExpression */: return isMatchingReference(source, target.expression); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return (ts.isAssignmentExpression(target) && isMatchingReference(source, target.left)) || (ts.isBinaryExpression(target) && target.operatorToken.kind === 27 /* CommaToken */ && isMatchingReference(source, target.right)); } switch (source.kind) { - case 78 /* Identifier */: - case 79 /* PrivateIdentifier */: - return target.kind === 78 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 249 /* VariableDeclaration */ || target.kind === 198 /* BindingElement */) && + case 228 /* MetaProperty */: + return target.kind === 228 /* MetaProperty */ + && source.keywordToken === target.keywordToken + && source.name.escapedText === target.name.escapedText; + case 79 /* Identifier */: + case 80 /* PrivateIdentifier */: + return target.kind === 79 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 251 /* VariableDeclaration */ || target.kind === 200 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 107 /* ThisKeyword */: - return target.kind === 107 /* ThisKeyword */; - case 105 /* SuperKeyword */: - return target.kind === 105 /* SuperKeyword */; - case 225 /* NonNullExpression */: - case 207 /* ParenthesizedExpression */: + case 108 /* ThisKeyword */: + return target.kind === 108 /* ThisKeyword */; + case 106 /* SuperKeyword */: + return target.kind === 106 /* SuperKeyword */; + case 227 /* NonNullExpression */: + case 209 /* ParenthesizedExpression */: return isMatchingReference(source.expression, target); - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: return ts.isAccessExpression(target) && getAccessedPropertyName(source) === getAccessedPropertyName(target) && isMatchingReference(source.expression, target.expression); - case 216 /* BinaryExpression */: + case 159 /* QualifiedName */: + return ts.isAccessExpression(target) && + source.right.escapedText === getAccessedPropertyName(target) && + isMatchingReference(source.left, target.expression); + case 218 /* BinaryExpression */: return (ts.isBinaryExpression(source) && source.operatorToken.kind === 27 /* CommaToken */ && isMatchingReference(source.right, target)); } return false; @@ -63193,11 +65427,11 @@ var ts; // Given a source x, check if target matches x or is an && operation with an operand that matches x. function containsTruthyCheck(source, target) { return isMatchingReference(source, target) || - (target.kind === 216 /* BinaryExpression */ && target.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && + (target.kind === 218 /* BinaryExpression */ && target.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && (containsTruthyCheck(source, target.left) || containsTruthyCheck(source, target.right))); } function getAccessedPropertyName(access) { - return access.kind === 201 /* PropertyAccessExpression */ ? access.name.escapedText : + return access.kind === 203 /* PropertyAccessExpression */ ? access.name.escapedText : ts.isStringOrNumericLiteralLike(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) : undefined; } @@ -63247,6 +65481,86 @@ var ts; } return result; } + // Given a set of constituent types and a property name, create and return a map keyed by the literal + // types of the property by that name in each constituent type. No map is returned if some key property + // has a non-literal type or if less than 10 or less than 50% of the constituents have a unique key. + // Entries with duplicate keys have unknownType as the value. + function mapTypesByKeyProperty(types, name) { + var map = new ts.Map(); + var count = 0; + var _loop_20 = function (type) { + if (type.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) { + var discriminant = getTypeOfPropertyOfType(type, name); + if (discriminant) { + if (!isLiteralType(discriminant)) { + return { value: undefined }; + } + var duplicate_1 = false; + forEachType(discriminant, function (t) { + var id = getTypeId(getRegularTypeOfLiteralType(t)); + var existing = map.get(id); + if (!existing) { + map.set(id, type); + } + else if (existing !== unknownType) { + map.set(id, unknownType); + duplicate_1 = true; + } + }); + if (!duplicate_1) + count++; + } + } + }; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var type = types_17[_i]; + var state_8 = _loop_20(type); + if (typeof state_8 === "object") + return state_8.value; + } + return count >= 10 && count * 2 >= types.length ? map : undefined; + } + // Return the name of a discriminant property for which it was possible and feasible to construct a map of + // constituent types keyed by the literal types of the property by that name in each constituent type. + function getKeyPropertyName(unionType) { + var types = unionType.types; + // We only construct maps for large unions with non-primitive constituents. + if (types.length < 10 || ts.getObjectFlags(unionType) & 65536 /* PrimitiveUnion */) { + 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 */) ? + ts.forEach(getPropertiesOfType(t), function (p) { return isUnitType(getTypeOfSymbol(p)) ? p.escapedName : undefined; }) : + undefined; + }); + var mapByKeyProperty = keyPropertyName && mapTypesByKeyProperty(types, keyPropertyName); + unionType.keyPropertyName = mapByKeyProperty ? keyPropertyName : ""; + unionType.constituentMap = mapByKeyProperty; + } + return unionType.keyPropertyName.length ? unionType.keyPropertyName : undefined; + } + // Given a union type for which getKeyPropertyName returned a non-undefined result, return the constituent + // that corresponds to the given key type for that property name. + function getConstituentTypeForKeyType(unionType, keyType) { + var _a; + var result = (_a = unionType.constituentMap) === null || _a === void 0 ? void 0 : _a.get(getTypeId(getRegularTypeOfLiteralType(keyType))); + return result !== unknownType ? result : undefined; + } + function getMatchingUnionConstituentForType(unionType, type) { + var keyPropertyName = getKeyPropertyName(unionType); + var propType = keyPropertyName && getTypeOfPropertyOfType(type, keyPropertyName); + return propType && getConstituentTypeForKeyType(unionType, propType); + } + function getMatchingUnionConstituentForObjectLiteral(unionType, node) { + var keyPropertyName = getKeyPropertyName(unionType); + var propNode = keyPropertyName && ts.find(node.properties, function (p) { return p.symbol && p.kind === 290 /* PropertyAssignment */ && + p.symbol.escapedName === keyPropertyName && isPossiblyDiscriminantValue(p.initializer); }); + var propType = propNode && getTypeOfExpression(propNode.initializer); + return propType && getConstituentTypeForKeyType(unionType, propType); + } function isOrContainsMatchingReference(source, target) { return isMatchingReference(source, target) || containsMatchingReference(source, target); } @@ -63259,7 +65573,7 @@ var ts; } } } - if (expression.expression.kind === 201 /* PropertyAccessExpression */ && + if (expression.expression.kind === 203 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, expression.expression.expression)) { return true; } @@ -63306,14 +65620,6 @@ var ts; } return declaredType; } - function getTypeFactsOfTypes(types) { - var result = 0 /* None */; - for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { - var t = types_17[_i]; - result |= getTypeFacts(t); - } - return result; - } function isFunctionObjectType(type) { // We do a quick check for a "bind" property before performing the more expensive subtype // check. This gives us a quicker out in the common case where an object type is not a function. @@ -63321,7 +65627,8 @@ var ts; return !!(resolved.callSignatures.length || resolved.constructSignatures.length || resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType)); } - function getTypeFacts(type) { + function getTypeFacts(type, ignoreObjects) { + if (ignoreObjects === void 0) { ignoreObjects = false; } var flags = type.flags; if (flags & 4 /* String */) { return strictNullChecks ? 16317953 /* StringStrictFacts */ : 16776705 /* StringFacts */; @@ -63358,7 +65665,7 @@ var ts; (type === falseType || type === regularFalseType) ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ : (type === falseType || type === regularFalseType) ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */; } - if (flags & 524288 /* Object */) { + if (flags & 524288 /* Object */ && !ignoreObjects) { return ts.getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type) ? strictNullChecks ? 16318463 /* EmptyObjectStrictFacts */ : 16777215 /* EmptyObjectFacts */ : isFunctionObjectType(type) ? @@ -63381,11 +65688,17 @@ var ts; return 0 /* None */; } if (flags & 465829888 /* Instantiable */) { - return !isPatternLiteralType(type) ? getTypeFacts(getBaseConstraintOfType(type) || unknownType) : + return !isPatternLiteralType(type) ? getTypeFacts(getBaseConstraintOfType(type) || unknownType, ignoreObjects) : strictNullChecks ? 7929345 /* NonEmptyStringStrictFacts */ : 16776705 /* NonEmptyStringFacts */; } - if (flags & 3145728 /* UnionOrIntersection */) { - return getTypeFactsOfTypes(type.types); + if (flags & 1048576 /* Union */) { + return ts.reduceLeft(type.types, function (facts, t) { return facts | getTypeFacts(t, ignoreObjects); }, 0 /* None */); + } + if (flags & 2097152 /* Intersection */) { + // 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. + ignoreObjects || (ignoreObjects = maybeTypeOfKind(type, 131068 /* Primitive */)); + return ts.reduceLeft(type.types, function (facts, t) { return facts & getTypeFacts(t, ignoreObjects); }, 16777215 /* All */); } return 16777215 /* All */; } @@ -63393,18 +65706,16 @@ var ts; return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; }); } function getTypeWithDefault(type, defaultExpression) { - if (defaultExpression) { - var defaultType = getTypeOfExpression(defaultExpression); - return getUnionType([getTypeWithFacts(type, 524288 /* NEUndefined */), defaultType]); - } - return type; + return defaultExpression ? + getUnionType([getNonUndefinedType(type), getTypeOfExpression(defaultExpression)]) : + type; } function getTypeOfDestructuredProperty(type, name) { var nameType = getLiteralTypeFromPropertyName(name); if (!isTypeUsableAsPropertyName(nameType)) return errorType; var text = getPropertyNameFromType(nameType); - return getConstraintForLocation(getTypeOfPropertyOfType(type, text), name) || + return getTypeOfPropertyOfType(type, text) || isNumericLiteralName(text) && includeUndefinedInIndexSignature(getIndexTypeOfType(type, 1 /* Number */)) || includeUndefinedInIndexSignature(getIndexTypeOfType(type, 0 /* String */)) || errorType; @@ -63425,15 +65736,15 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 199 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 288 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 201 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 290 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 216 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 239 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 218 /* BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 241 /* ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -63450,21 +65761,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return stringType; - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: return checkRightHandSideOfForOf(parent) || errorType; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 210 /* DeleteExpression */: + case 212 /* DeleteExpression */: return undefinedType; - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 220 /* SpreadElement */: + case 222 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -63472,7 +65783,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 196 /* ObjectBindingPattern */ ? + var type = pattern.kind === 198 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -63490,35 +65801,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 238 /* ForInStatement */) { + if (node.parent.parent.kind === 240 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 239 /* ForOfStatement */) { + if (node.parent.parent.kind === 241 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 249 /* VariableDeclaration */ ? + return node.kind === 251 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function isEmptyArrayAssignment(node) { - return node.kind === 249 /* VariableDeclaration */ && node.initializer && + return node.kind === 251 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 198 /* BindingElement */ && node.parent.kind === 216 /* BinaryExpression */ && + node.kind !== 200 /* BindingElement */ && node.parent.kind === 218 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 62 /* EqualsToken */: - case 74 /* BarBarEqualsToken */: - case 75 /* AmpersandAmpersandEqualsToken */: - case 76 /* QuestionQuestionEqualsToken */: + case 63 /* EqualsToken */: + case 75 /* BarBarEqualsToken */: + case 76 /* AmpersandAmpersandEqualsToken */: + case 77 /* QuestionQuestionEqualsToken */: return getReferenceCandidate(node.left); case 27 /* CommaToken */: return getReferenceCandidate(node.right); @@ -63528,13 +65839,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 207 /* ParenthesizedExpression */ || - parent.kind === 216 /* BinaryExpression */ && parent.operatorToken.kind === 62 /* EqualsToken */ && parent.left === node || - parent.kind === 216 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? + return parent.kind === 209 /* ParenthesizedExpression */ || + parent.kind === 218 /* BinaryExpression */ && parent.operatorToken.kind === 63 /* EqualsToken */ && parent.left === node || + parent.kind === 218 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 284 /* CaseClause */) { + if (clause.kind === 286 /* CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -63554,7 +65865,7 @@ var ts; var witnesses = []; for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) { var clause = _a[_i]; - if (clause.kind === 284 /* CaseClause */) { + if (clause.kind === 286 /* CaseClause */) { if (ts.isStringLiteralLike(clause.expression)) { witnesses.push(clause.expression.text); continue; @@ -63590,14 +65901,40 @@ var ts; function forEachType(type, f) { return type.flags & 1048576 /* Union */ ? ts.forEach(type.types, f) : f(type); } + function someType(type, f) { + return type.flags & 1048576 /* Union */ ? ts.some(type.types, f) : f(type); + } function everyType(type, f) { return type.flags & 1048576 /* Union */ ? ts.every(type.types, f) : f(type); } + function everyContainedType(type, f) { + return type.flags & 3145728 /* UnionOrIntersection */ ? ts.every(type.types, f) : f(type); + } function filterType(type, f) { if (type.flags & 1048576 /* Union */) { var types = type.types; var filtered = ts.filter(types, f); - return filtered === types ? type : getUnionTypeFromSortedList(filtered, type.objectFlags); + if (filtered === types) { + return type; + } + var origin = type.origin; + var newOrigin = void 0; + if (origin && origin.flags & 1048576 /* 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); }); + if (originTypes.length - originFiltered.length === types.length - filtered.length) { + if (originFiltered.length === 1) { + return originFiltered[0]; + } + newOrigin = createOriginUnionOrIntersectionType(1048576 /* Union */, originFiltered); + } + } + return getUnionTypeFromSortedList(filtered, type.objectFlags, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, newOrigin); } return type.flags & 131072 /* Never */ || f(type) ? type : neverType; } @@ -63630,6 +65967,11 @@ var ts; } return changed ? mappedTypes && getUnionType(mappedTypes, noReductions ? 0 /* None */ : 1 /* Literal */) : type; } + function mapTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments) { + return type.flags & 1048576 /* Union */ && aliasSymbol ? + getUnionType(ts.map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments) : + mapType(type, mapper); + } function getConstituentCount(type) { return type.flags & 3145728 /* UnionOrIntersection */ ? type.types.length : 1; } @@ -63715,21 +66057,21 @@ var ts; var root = getReferenceRoot(node); var parent = root.parent; var isLengthPushOrUnshift = ts.isPropertyAccessExpression(parent) && (parent.name.escapedText === "length" || - parent.parent.kind === 203 /* CallExpression */ + parent.parent.kind === 205 /* CallExpression */ && ts.isIdentifier(parent.name) && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 202 /* ElementAccessExpression */ && + var isElementAssignment = parent.kind === 204 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 216 /* BinaryExpression */ && - parent.parent.operatorToken.kind === 62 /* EqualsToken */ && + parent.parent.kind === 218 /* BinaryExpression */ && + parent.parent.operatorToken.kind === 63 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* NumberLike */); return isLengthPushOrUnshift || isElementAssignment; } function isDeclarationWithExplicitTypeAnnotation(declaration) { - return (declaration.kind === 249 /* VariableDeclaration */ || declaration.kind === 160 /* Parameter */ || - declaration.kind === 163 /* PropertyDeclaration */ || declaration.kind === 162 /* PropertySignature */) && + return (declaration.kind === 251 /* VariableDeclaration */ || declaration.kind === 162 /* Parameter */ || + declaration.kind === 165 /* PropertyDeclaration */ || declaration.kind === 164 /* PropertySignature */) && !!ts.getEffectiveTypeAnnotationNode(declaration); } function getExplicitTypeOfSymbol(symbol, diagnostic) { @@ -63748,7 +66090,7 @@ var ts; if (isDeclarationWithExplicitTypeAnnotation(declaration)) { return getTypeOfSymbol(symbol); } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 239 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 241 /* ForOfStatement */) { var statement = declaration.parent.parent; var expressionType = getTypeOfDottedName(statement.expression, /*diagnostic*/ undefined); if (expressionType) { @@ -63769,18 +66111,32 @@ var ts; function getTypeOfDottedName(node, diagnostic) { if (!(node.flags & 16777216 /* InWithStatement */)) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node)); return getExplicitTypeOfSymbol(symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol, diagnostic); - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: return getExplicitThisType(node); - case 105 /* SuperKeyword */: + case 106 /* SuperKeyword */: return checkSuperExpression(node); - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: { var type = getTypeOfDottedName(node.expression, diagnostic); - var prop = type && getPropertyOfType(type, node.name.escapedText); - return prop && getExplicitTypeOfSymbol(prop, diagnostic); - case 207 /* ParenthesizedExpression */: + if (type) { + var name = node.name; + var prop = void 0; + if (ts.isPrivateIdentifier(name)) { + if (!type.symbol) { + return undefined; + } + prop = getPropertyOfType(type, ts.getSymbolNameForPrivateIdentifier(type.symbol, name.escapedText)); + } + else { + prop = getPropertyOfType(type, name.escapedText); + } + return prop && getExplicitTypeOfSymbol(prop, diagnostic); + } + return undefined; + } + case 209 /* ParenthesizedExpression */: return getTypeOfDottedName(node.expression, diagnostic); } } @@ -63794,10 +66150,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 === 233 /* ExpressionStatement */) { + if (node.parent.kind === 235 /* ExpressionStatement */) { funcType = getTypeOfDottedName(node.expression, /*diagnostic*/ undefined); } - else if (node.expression.kind !== 105 /* SuperKeyword */) { + else if (node.expression.kind !== 106 /* SuperKeyword */) { if (ts.isOptionalChain(node)) { funcType = checkNonNullType(getOptionalExpressionType(checkExpression(node.expression), node.expression), node.expression); } @@ -63838,7 +66194,7 @@ var ts; } function isFalseExpression(expr) { var node = ts.skipParentheses(expr); - return node.kind === 94 /* FalseKeyword */ || node.kind === 216 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && (isFalseExpression(node.left) || isFalseExpression(node.right)) || + return node.kind === 95 /* FalseKeyword */ || node.kind === 218 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && (isFalseExpression(node.left) || isFalseExpression(node.right)) || node.operatorToken.kind === 56 /* BarBarToken */ && isFalseExpression(node.left) && isFalseExpression(node.right)); } function isReachableFlowNodeWorker(flow, noCacheCheck) { @@ -63926,7 +66282,7 @@ var ts; flow = flow.antecedent; } else if (flags & 512 /* Call */) { - if (flow.node.expression.kind === 105 /* SuperKeyword */) { + if (flow.node.expression.kind === 106 /* SuperKeyword */) { return true; } flow = flow.antecedent; @@ -63973,7 +66329,7 @@ var ts; // 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 === 225 /* NonNullExpression */ && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { + if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 227 /* NonNullExpression */ && !(resultType.flags & 131072 /* Never */) && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { return declaredType; } return resultType; @@ -63988,7 +66344,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.instant("checkTypes" /* CheckTypes */, "getTypeAtFlowNode_DepthLimit", { flowId: flow.id }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "getTypeAtFlowNode_DepthLimit", { flowId: flow.id }); flowAnalysisDisabled = true; reportFlowControlError(reference); return errorType; @@ -64057,9 +66413,9 @@ var ts; // Check if we should continue with the control flow of the containing function. var container = flow.node; if (container && container !== flowContainer && - reference.kind !== 201 /* PropertyAccessExpression */ && - reference.kind !== 202 /* ElementAccessExpression */ && - reference.kind !== 107 /* ThisKeyword */) { + reference.kind !== 203 /* PropertyAccessExpression */ && + reference.kind !== 204 /* ElementAccessExpression */ && + reference.kind !== 108 /* ThisKeyword */) { flow = container.flowNode; continue; } @@ -64083,7 +66439,7 @@ var ts; } function getInitialOrAssignedType(flow) { var node = flow.node; - return getConstraintForLocation(node.kind === 249 /* VariableDeclaration */ || node.kind === 198 /* BindingElement */ ? + return getNarrowableTypeForReference(node.kind === 251 /* VariableDeclaration */ || node.kind === 200 /* BindingElement */ ? getInitialType(node) : getAssignedType(node), reference); } @@ -64123,14 +66479,14 @@ 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 === 208 /* FunctionExpression */ || init.kind === 209 /* ArrowFunction */)) { + if (init && (init.kind === 210 /* FunctionExpression */ || init.kind === 211 /* 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 === 238 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { + if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 240 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); } // Assignment doesn't affect reference @@ -64138,10 +66494,10 @@ var ts; } function narrowTypeByAssertion(type, expr) { var node = ts.skipParentheses(expr); - if (node.kind === 94 /* FalseKeyword */) { + if (node.kind === 95 /* FalseKeyword */) { return unreachableNeverType; } - if (node.kind === 216 /* BinaryExpression */) { + if (node.kind === 218 /* BinaryExpression */) { if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { return narrowTypeByAssertion(narrowTypeByAssertion(type, node.left), node.right); } @@ -64172,7 +66528,7 @@ var ts; function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 203 /* CallExpression */ ? + var expr = node.kind === 205 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -64180,7 +66536,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 203 /* CallExpression */) { + if (node.kind === 205 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -64228,7 +66584,7 @@ var ts; if (isMatchingReference(reference, expr)) { type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } - else if (expr.kind === 211 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { + else if (expr.kind === 213 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } else { @@ -64236,12 +66592,12 @@ var ts; if (optionalChainContainsReference(expr, reference)) { type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & (32768 /* Undefined */ | 131072 /* Never */)); }); } - else if (expr.kind === 211 /* TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) { + else if (expr.kind === 213 /* 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"); }); } } if (isMatchingReferenceDiscriminant(expr, type)) { - type = narrowTypeByDiscriminant(type, expr, function (t) { return narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd); }); + type = narrowTypeBySwitchOnDiscriminantProperty(type, expr, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } } return createFlowType(type, isIncomplete(flowType)); @@ -64412,16 +66768,42 @@ var ts; if (propName === undefined) { return type; } - var propType = getTypeOfPropertyOfType(type, propName); + var removeNullable = strictNullChecks && ts.isOptionalChain(access) && maybeTypeOfKind(type, 98304 /* Nullable */); + var propType = getTypeOfPropertyOfType(removeNullable ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type, propName); if (!propType) { return type; } + propType = removeNullable ? getOptionalType(propType) : propType; var narrowedPropType = narrowType(propType); return filterType(type, function (t) { var discriminantType = getTypeOfPropertyOrIndexSignature(t, propName); return !(discriminantType.flags & 131072 /* Never */) && isTypeComparableTo(discriminantType, narrowedPropType); }); } + function narrowTypeByDiscriminantProperty(type, access, operator, value, assumeTrue) { + if ((operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) && type.flags & 1048576 /* Union */) { + var keyPropertyName = getKeyPropertyName(type); + if (keyPropertyName && keyPropertyName === getAccessedPropertyName(access)) { + var candidate_2 = getConstituentTypeForKeyType(type, getTypeOfExpression(value)); + if (candidate_2) { + return operator === (assumeTrue ? 36 /* EqualsEqualsEqualsToken */ : 37 /* ExclamationEqualsEqualsToken */) ? candidate_2 : + isUnitType(getTypeOfPropertyOfType(candidate_2, keyPropertyName) || unknownType) ? filterType(type, function (t) { return t !== candidate_2; }) : + type; + } + } + } + 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)) { + var clauseTypes = getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd); + var candidate = getUnionType(ts.map(clauseTypes, function (t) { return getConstituentTypeForKeyType(type, t) || unknownType; })); + if (candidate !== unknownType) { + return candidate; + } + } + return narrowTypeByDiscriminant(type, access, function (t) { return narrowTypeBySwitchOnDiscriminant(t, switchStatement, clauseStart, clauseEnd); }); + } function narrowTypeByTruthiness(type, expr, assumeTrue) { if (isMatchingReference(reference, expr)) { return getTypeWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); @@ -64445,7 +66827,8 @@ var ts; return !assumeTrue; } function narrowByInKeyword(type, literal, assumeTrue) { - if (type.flags & (1048576 /* Union */ | 524288 /* Object */) + if (type.flags & 1048576 /* Union */ + || type.flags & 524288 /* Object */ && declaredType !== type || isThisTypeParameter(type) || type.flags & 2097152 /* Intersection */ && ts.every(type.types, function (t) { return t.symbol !== globalThisSymbol; })) { var propName_1 = ts.escapeLeadingUnderscores(literal.text); @@ -64455,57 +66838,63 @@ var ts; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 62 /* EqualsToken */: - case 74 /* BarBarEqualsToken */: - case 75 /* AmpersandAmpersandEqualsToken */: - case 76 /* QuestionQuestionEqualsToken */: + case 63 /* EqualsToken */: + case 75 /* BarBarEqualsToken */: + case 76 /* AmpersandAmpersandEqualsToken */: + case 77 /* QuestionQuestionEqualsToken */: return narrowTypeByTruthiness(narrowType(type, expr.right, assumeTrue), expr.left, assumeTrue); case 34 /* EqualsEqualsToken */: case 35 /* ExclamationEqualsToken */: case 36 /* EqualsEqualsEqualsToken */: case 37 /* ExclamationEqualsEqualsToken */: - var operator_1 = expr.operatorToken.kind; - var left_1 = getReferenceCandidate(expr.left); - var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 211 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { - return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); + var operator = expr.operatorToken.kind; + var left = getReferenceCandidate(expr.left); + var right = getReferenceCandidate(expr.right); + if (left.kind === 213 /* TypeOfExpression */ && ts.isStringLiteralLike(right)) { + return narrowTypeByTypeof(type, left, operator, right, assumeTrue); } - if (right_1.kind === 211 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { - return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); + if (right.kind === 213 /* TypeOfExpression */ && ts.isStringLiteralLike(left)) { + return narrowTypeByTypeof(type, right, operator, left, assumeTrue); } - if (isMatchingReference(reference, left_1)) { - return narrowTypeByEquality(type, operator_1, right_1, assumeTrue); + if (isMatchingReference(reference, left)) { + return narrowTypeByEquality(type, operator, right, assumeTrue); } - if (isMatchingReference(reference, right_1)) { - return narrowTypeByEquality(type, operator_1, left_1, assumeTrue); + if (isMatchingReference(reference, right)) { + return narrowTypeByEquality(type, operator, left, assumeTrue); } if (strictNullChecks) { - if (optionalChainContainsReference(left_1, reference)) { - type = narrowTypeByOptionalChainContainment(type, operator_1, right_1, assumeTrue); + if (optionalChainContainsReference(left, reference)) { + type = narrowTypeByOptionalChainContainment(type, operator, right, assumeTrue); } - else if (optionalChainContainsReference(right_1, reference)) { - type = narrowTypeByOptionalChainContainment(type, operator_1, left_1, assumeTrue); + else if (optionalChainContainsReference(right, reference)) { + type = narrowTypeByOptionalChainContainment(type, operator, left, assumeTrue); } } - if (isMatchingReferenceDiscriminant(left_1, type)) { - return narrowTypeByDiscriminant(type, left_1, function (t) { return narrowTypeByEquality(t, operator_1, right_1, assumeTrue); }); + if (isMatchingReferenceDiscriminant(left, type)) { + return narrowTypeByDiscriminantProperty(type, left, operator, right, assumeTrue); } - if (isMatchingReferenceDiscriminant(right_1, type)) { - return narrowTypeByDiscriminant(type, right_1, function (t) { return narrowTypeByEquality(t, operator_1, left_1, assumeTrue); }); + if (isMatchingReferenceDiscriminant(right, type)) { + return narrowTypeByDiscriminantProperty(type, right, operator, left, assumeTrue); } - if (isMatchingConstructorReference(left_1)) { - return narrowTypeByConstructor(type, operator_1, right_1, assumeTrue); + if (isMatchingConstructorReference(left)) { + return narrowTypeByConstructor(type, operator, right, assumeTrue); } - if (isMatchingConstructorReference(right_1)) { - return narrowTypeByConstructor(type, operator_1, left_1, assumeTrue); + if (isMatchingConstructorReference(right)) { + return narrowTypeByConstructor(type, operator, left, assumeTrue); } break; - case 101 /* InstanceOfKeyword */: + case 102 /* InstanceOfKeyword */: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 100 /* InKeyword */: + case 101 /* InKeyword */: var target = getReferenceCandidate(expr.right); - if (ts.isStringLiteralLike(expr.left) && isMatchingReference(reference, target)) { - return narrowByInKeyword(type, expr.left, assumeTrue); + if (ts.isStringLiteralLike(expr.left)) { + if (containsMissingType(type) && ts.isAccessExpression(reference) && isMatchingReference(reference.expression, target) && + getAccessedPropertyName(reference) === ts.escapeLeadingUnderscores(expr.left.text)) { + return getTypeWithFacts(type, assumeTrue ? 524288 /* NEUndefined */ : 65536 /* EQUndefined */); + } + if (isMatchingReference(reference, target)) { + return narrowByInKeyword(type, expr.left, assumeTrue); + } } break; case 27 /* CommaToken */: @@ -64562,13 +66951,12 @@ var ts; } if (assumeTrue) { var filterFn = operator === 34 /* EqualsEqualsToken */ ? - (function (t) { return areTypesComparable(t, valueType) || isCoercibleUnderDoubleEquals(t, valueType); }) : + function (t) { return areTypesComparable(t, valueType) || isCoercibleUnderDoubleEquals(t, valueType); } : function (t) { return areTypesComparable(t, valueType); }; return replacePrimitivesWithLiterals(filterType(type, filterFn), valueType); } if (isUnitType(valueType)) { - var regularType_1 = getRegularTypeOfLiteralType(valueType); - return filterType(type, function (t) { return isUnitType(t) ? !areTypesComparable(t, valueType) : getRegularTypeOfLiteralType(t) !== regularType_1; }); + return filterType(type, function (t) { return !(isUnitLikeType(t) && areTypesComparable(t, valueType)); }); } return type; } @@ -64590,7 +66978,7 @@ var ts; if (assumeTrue && type.flags & 2 /* Unknown */ && literal.text === "object") { // The pattern x && typeof x === 'object', where x is of type unknown, narrows x to type object. We don't // need to check for the reverse typeof x === 'object' && x since that already narrows correctly. - if (typeOfExpr.parent.parent.kind === 216 /* BinaryExpression */) { + if (typeOfExpr.parent.parent.kind === 218 /* BinaryExpression */) { var expr = typeOfExpr.parent.parent; if (expr.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && expr.right === typeOfExpr.parent && containsTruthyCheck(reference, expr.left)) { return nonPrimitiveType; @@ -64646,7 +67034,7 @@ var ts; if (!hasDefaultClause) { return caseType; } - var defaultType = filterType(type, function (t) { return !(isUnitType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(t))); }); + var defaultType = filterType(type, function (t) { return !(isUnitLikeType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(extractUnitType(t)))); }); return caseType.flags & 131072 /* Never */ ? defaultType : getUnionType([caseType, defaultType]); } function getImpliedTypeFromTypeofGuard(type, text) { @@ -64828,7 +67216,16 @@ var ts; } function getNarrowedType(type, candidate, assumeTrue, isRelated) { if (!assumeTrue) { - return filterType(type, function (t) { return !isRelated(t, candidate); }); + return filterType(type, function (t) { + if (!isRelated(t, candidate)) { + return true; + } + var constraint = getBaseConstraintOfType(t); + if (constraint && constraint !== t) { + return !isRelated(constraint, candidate); + } + return false; + }); } // 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. @@ -64838,10 +67235,15 @@ var ts; return assignableType; } } - // If the candidate type is a subtype of the target type, narrow to the candidate type, - // if the target type is a subtype of the candidate type, narrow to the target type, - // otherwise, narrow to an intersection of the two types. - return isTypeSubtypeOf(candidate, type) ? candidate : isTypeSubtypeOf(type, candidate) ? type : getIntersectionType([type, 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]); } function narrowTypeByCallExpression(type, callExpression, assumeTrue) { if (hasMatchingArgument(callExpression, reference)) { @@ -64851,6 +67253,16 @@ var ts; return narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue); } } + if (containsMissingType(type) && ts.isAccessExpression(reference) && ts.isPropertyAccessExpression(callExpression.expression)) { + var callAccess = callExpression.expression; + if (isMatchingReference(reference.expression, getReferenceCandidate(callAccess.expression)) && + 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 type; } function narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue) { @@ -64881,20 +67293,20 @@ var ts; return narrowTypeByOptionality(type, expr, assumeTrue); } switch (expr.kind) { - case 78 /* Identifier */: - case 107 /* ThisKeyword */: - case 105 /* SuperKeyword */: - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 79 /* Identifier */: + case 108 /* ThisKeyword */: + case 106 /* SuperKeyword */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return narrowTypeByCallExpression(type, expr, assumeTrue); - case 207 /* ParenthesizedExpression */: - case 225 /* NonNullExpression */: + case 209 /* ParenthesizedExpression */: + case 227 /* NonNullExpression */: return narrowType(type, expr.expression, assumeTrue); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: if (expr.operator === 53 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } @@ -64918,34 +67330,40 @@ 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 === 78 /* Identifier */) { + if (location.kind === 79 /* Identifier */ || location.kind === 80 /* PrivateIdentifier */) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } - if (ts.isExpressionNode(location) && !ts.isAssignmentTarget(location)) { + if (ts.isExpressionNode(location) && (!ts.isAssignmentTarget(location) || ts.isWriteAccess(location))) { var type = getTypeOfExpression(location); if (getExportSymbolOfValueSymbolIfExported(getNodeLinks(location).resolvedSymbol) === symbol) { return type; } } } + if (ts.isDeclarationName(location) && ts.isSetAccessor(location.parent) && getAnnotatedAccessorTypeNode(location.parent)) { + return resolveTypeOfAccessors(location.parent.symbol, /*writing*/ true); + } // The location isn't a reference to the given symbol, meaning we're being asked // a hypothetical question of what type the symbol would have if there was a reference // to it at the given location. Since we have no control flow information for the // hypothetical reference (control flow information is created and attached by the // binder), we simply return the declared type of the symbol. - return getTypeOfSymbol(symbol); + return getNonMissingTypeOfSymbol(symbol); } function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 257 /* ModuleBlock */ || - node.kind === 297 /* SourceFile */ || - node.kind === 163 /* PropertyDeclaration */; + node.kind === 259 /* ModuleBlock */ || + node.kind === 299 /* SourceFile */ || + node.kind === 165 /* PropertyDeclaration */; }); } // Check if a parameter is assigned anywhere within its declaring function. function isParameterAssigned(symbol) { + if (!symbol.valueDeclaration) { + return false; + } var func = ts.getRootDeclaration(symbol.valueDeclaration).parent; var links = getNodeLinks(func); if (!(links.flags & 8388608 /* AssignmentsMarked */)) { @@ -64960,10 +67378,10 @@ var ts; return !!ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !!(getNodeLinks(node).flags & 8388608 /* AssignmentsMarked */); }); } function markParameterAssignments(node) { - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 160 /* Parameter */) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 162 /* Parameter */) { symbol.isAssigned = true; } } @@ -64979,7 +67397,7 @@ var ts; function removeOptionalityFromDeclaredType(declaredType, declaration) { if (pushTypeResolution(declaration.symbol, 2 /* DeclaredType */)) { var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 160 /* Parameter */ && + declaration.kind === 162 /* Parameter */ && declaration.initializer && getFalsyFlags(declaredType) & 32768 /* Undefined */ && !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* Undefined */); @@ -64993,23 +67411,40 @@ var ts; } function isConstraintPosition(node) { var parent = node.parent; - return parent.kind === 201 /* PropertyAccessExpression */ || - parent.kind === 203 /* CallExpression */ && parent.expression === node || - parent.kind === 202 /* ElementAccessExpression */ && parent.expression === node || - parent.kind === 198 /* BindingElement */ && parent.name === node && !!parent.initializer; - } - function typeHasNullableConstraint(type) { - return type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 98304 /* Nullable */); - } - function getConstraintForLocation(type, node) { - // When a node is the left hand expression of a property access, element access, or call expression, - // and the type of the node includes type variables with constraints that are nullable, we fetch the - // apparent type of the node *before* performing control flow analysis such that narrowings apply to - // the constraint type. - if (type && isConstraintPosition(node) && forEachType(type, typeHasNullableConstraint)) { - return mapType(getWidenedType(type), getBaseConstraintOrType); - } - return type; + // In an element access obj[x], we consider obj to be in a constraint position only when x is not + // of 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 === 203 /* PropertyAccessExpression */ || + parent.kind === 205 /* CallExpression */ && parent.expression === node || + parent.kind === 204 /* ElementAccessExpression */ && parent.expression === node && + !isGenericIndexType(getTypeOfExpression(parent.argumentExpression)); + } + function isGenericTypeWithUnionConstraint(type) { + return !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */)); + } + function containsGenericType(type) { + return !!(type.flags & 465829888 /* Instantiable */ || type.flags & 3145728 /* UnionOrIntersection */ && ts.some(type.types, containsGenericType)); + } + function hasNonBindingPatternContextualTypeWithNoGenericTypes(node) { + // Computing the contextual type for a child of a JSX element involves resolving the type of the + // element's tag name, so we exclude that here to avoid circularities. + var contextualType = (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) && + !((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && + getContextualType(node, 8 /* SkipBindingPatterns */); + return contextualType && !someType(contextualType, containsGenericType); + } + function getNarrowableTypeForReference(type, reference, checkMode) { + // When the type of a reference is or contains an instantiable type with a union type constraint, and + // when the reference is in a constraint position (where it is known we'll obtain the apparent type) or + // has a contextual type containing no top-level instantiables (meaning constraints will determine + // assignability), we substitute constraints for all instantiables in the type of the reference to give + // 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 */) && + someType(type, isGenericTypeWithUnionConstraint) && + (isConstraintPosition(reference) || hasNonBindingPatternContextualTypeWithNoGenericTypes(reference)); + return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type; } function isExportOrExportExpression(location) { return !!ts.findAncestor(location, function (e) { return e.parent && ts.isExportAssignment(e.parent) && e.parent.expression === e && ts.isEntityNameExpression(e); }); @@ -65018,7 +67453,12 @@ var ts; if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) { var target = resolveAlias(symbol); if (target.flags & 111551 /* Value */) { - if (compilerOptions.preserveConstEnums && isExportOrExportExpression(location) || !isConstEnumOrConstEnumOnlyModule(target)) { + // 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. + if (compilerOptions.isolatedModules || + ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(location) || + !isConstEnumOrConstEnumOnlyModule(target)) { markAliasSymbolAsReferenced(symbol); } else { @@ -65027,7 +67467,7 @@ var ts; } } } - function checkIdentifier(node) { + function checkIdentifier(node, checkMode) { var symbol = getResolvedSymbol(node); if (symbol === unknownSymbol) { return errorType; @@ -65041,7 +67481,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 209 /* ArrowFunction */) { + if (container.kind === 211 /* 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 */)) { @@ -65058,15 +67498,15 @@ var ts; } var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); var sourceSymbol = localOrExportSymbol.flags & 2097152 /* Alias */ ? resolveAlias(localOrExportSymbol) : localOrExportSymbol; - if (getDeclarationNodeFlagsFromSymbol(sourceSymbol) & 134217728 /* Deprecated */ && isUncalledFunctionReference(node, sourceSymbol)) { - errorOrSuggestion(/* isError */ false, node, ts.Diagnostics._0_is_deprecated, node.escapedText); + if (sourceSymbol.declarations && getDeclarationNodeFlagsFromSymbol(sourceSymbol) & 134217728 /* Deprecated */ && isUncalledFunctionReference(node, sourceSymbol)) { + addDeprecatedSuggestion(node, sourceSymbol.declarations, node.escapedText); } var declaration = localOrExportSymbol.valueDeclaration; - if (localOrExportSymbol.flags & 32 /* Class */) { + if (declaration && localOrExportSymbol.flags & 32 /* 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 === 252 /* ClassDeclaration */ + if (declaration.kind === 254 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -65078,14 +67518,14 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 221 /* ClassExpression */) { + else if (declaration.kind === 223 /* 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 !== 297 /* SourceFile */) { + while (container.kind !== 299 /* SourceFile */) { if (container.parent === declaration) { - if (container.kind === 163 /* PropertyDeclaration */ && ts.hasSyntacticModifier(container, 32 /* Static */)) { + if (container.kind === 165 /* PropertyDeclaration */ && ts.hasSyntacticModifier(container, 32 /* Static */)) { getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; } @@ -65096,12 +67536,18 @@ var ts; } } checkNestedBlockScopedBinding(node, symbol); - var type = getConstraintForLocation(getTypeOfSymbol(localOrExportSymbol), node); + var type = getTypeOfSymbol(localOrExportSymbol); var assignmentKind = ts.getAssignmentTargetKind(node); if (assignmentKind) { if (!(localOrExportSymbol.flags & 3 /* Variable */) && !(ts.isInJSFile(node) && localOrExportSymbol.flags & 512 /* ValueModule */)) { - error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_not_a_variable, symbolToString(symbol)); + 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 + : ts.Diagnostics.Cannot_assign_to_0_because_it_is_not_a_variable; + error(node, assignmentError, symbolToString(symbol)); return errorType; } if (isReadonlySymbol(localOrExportSymbol)) { @@ -65123,7 +67569,7 @@ var ts; } } else if (isAlias) { - declaration = ts.find(symbol.declarations, isSomeImportDeclaration); + declaration = getDeclarationOfAliasSymbol(symbol); } else { return type; @@ -65131,10 +67577,11 @@ var ts; if (!declaration) { return type; } + type = getNarrowableTypeForReference(type, node, checkMode); // 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 === 160 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 162 /* Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; @@ -65143,8 +67590,8 @@ var ts; // 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 === 208 /* FunctionExpression */ || - flowContainer.kind === 209 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 210 /* FunctionExpression */ || + flowContainer.kind === 211 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -65153,9 +67600,9 @@ var ts; // 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 === 270 /* ExportSpecifier */) || - node.parent.kind === 225 /* NonNullExpression */ || - declaration.kind === 249 /* VariableDeclaration */ && declaration.exclamationToken || + isInTypeQuery(node) || node.parent.kind === 272 /* ExportSpecifier */) || + node.parent.kind === 227 /* NonNullExpression */ || + declaration.kind === 251 /* VariableDeclaration */ && declaration.exclamationToken || declaration.flags & 8388608 /* Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : @@ -65180,17 +67627,21 @@ var ts; } return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } - function isInsideFunction(node, threshold) { - return !!ts.findAncestor(node, function (n) { return n === threshold ? "quit" : ts.isFunctionLike(n); }); + 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); }); } function getPartOfForStatementContainingNode(node, container) { return ts.findAncestor(node, function (n) { return n === container ? "quit" : n === container.initializer || n === container.condition || n === container.incrementor || n === container.statement; }); } + function getEnclosingIterationStatement(node) { + 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 || + !symbol.valueDeclaration || ts.isSourceFile(symbol.valueDeclaration) || - symbol.valueDeclaration.parent.kind === 287 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 289 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -65198,22 +67649,14 @@ var ts; // 2. walk from the declaration up to the boundary of lexical environment and check // if there is an iteration statement in between declaration and boundary (is binding/class declared inside iteration statement) var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); - var usedInFunction = isInsideFunction(node.parent, container); - var current = container; - var containedInIterationStatement = false; - while (current && !ts.nodeStartsNewLexicalEnvironment(current)) { - if (ts.isIterationStatement(current, /*lookInLabeledStatements*/ false)) { - containedInIterationStatement = true; - break; - } - current = current.parent; - } - if (containedInIterationStatement) { - if (usedInFunction) { + var isCaptured = isInsideFunctionOrInstancePropertyInitializer(node, container); + var enclosingIterationStatement = getEnclosingIterationStatement(container); + if (enclosingIterationStatement) { + if (isCaptured) { // 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, 250 /* VariableDeclarationList */); + var varDeclList = ts.getAncestor(symbol.valueDeclaration, 252 /* VariableDeclarationList */); if (varDeclList && varDeclList.parent === container) { var part = getPartOfForStatementContainingNode(node.parent, container); if (part) { @@ -65228,13 +67671,13 @@ var ts; } } if (capturesBlockScopeBindingInLoopBody) { - getNodeLinks(current).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */; + getNodeLinks(enclosingIterationStatement).flags |= 65536 /* 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, 250 /* VariableDeclarationList */); + var varDeclList = ts.getAncestor(symbol.valueDeclaration, 252 /* VariableDeclarationList */); if (varDeclList && varDeclList.parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NeedsLoopOutParameter */; } @@ -65242,7 +67685,7 @@ var ts; // set 'declared inside loop' bit on the block-scoped binding getNodeLinks(symbol.valueDeclaration).flags |= 524288 /* BlockScopedBindingInLoop */; } - if (usedInFunction) { + if (isCaptured) { getNodeLinks(symbol.valueDeclaration).flags |= 262144 /* CapturedBlockScopedBinding */; } } @@ -65253,7 +67696,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 207 /* ParenthesizedExpression */) { + while (current.parent.kind === 209 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -65261,7 +67704,7 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 214 /* PrefixUnaryExpression */ || current.parent.kind === 215 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 216 /* PrefixUnaryExpression */ || current.parent.kind === 217 /* PostfixUnaryExpression */)) { var expr = current.parent; isAssigned = expr.operator === 45 /* PlusPlusToken */ || expr.operator === 46 /* MinusMinusToken */; } @@ -65274,7 +67717,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 163 /* PropertyDeclaration */ || container.kind === 166 /* Constructor */) { + if (container.kind === 165 /* PropertyDeclaration */ || container.kind === 168 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -65314,37 +67757,37 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var capturedByArrowFunction = false; - if (container.kind === 166 /* Constructor */) { + if (container.kind === 168 /* 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 === 209 /* ArrowFunction */) { + if (container.kind === 211 /* ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); capturedByArrowFunction = true; } switch (container.kind) { - case 256 /* ModuleDeclaration */: + case 258 /* 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 255 /* EnumDeclaration */: + case 257 /* 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 166 /* Constructor */: + case 168 /* 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 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - if (ts.hasSyntacticModifier(container, 32 /* Static */) && !(compilerOptions.target === 99 /* ESNext */ && compilerOptions.useDefineForClassFields)) { + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + if (ts.hasSyntacticModifier(container, 32 /* Static */) && !(compilerOptions.target === 99 /* ESNext */ && useDefineForClassFields)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } break; - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -65432,7 +67875,7 @@ var ts; } function getClassNameFromPrototypeMethod(container) { // Check if it's the RHS of a x.prototype.y = function [name]() { .... } - if (container.kind === 208 /* FunctionExpression */ && + if (container.kind === 210 /* FunctionExpression */ && ts.isBinaryExpression(container.parent) && ts.getAssignmentDeclarationKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = container' @@ -65442,16 +67885,16 @@ var ts; .expression; // x } // x.prototype = { method() { } } - else if (container.kind === 165 /* MethodDeclaration */ && - container.parent.kind === 200 /* ObjectLiteralExpression */ && + else if (container.kind === 167 /* MethodDeclaration */ && + container.parent.kind === 202 /* ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent) === 6 /* Prototype */) { return container.parent.parent.left.expression; } // x.prototype = { method: function() { } } - else if (container.kind === 208 /* FunctionExpression */ && - container.parent.kind === 288 /* PropertyAssignment */ && - container.parent.parent.kind === 200 /* ObjectLiteralExpression */ && + else if (container.kind === 210 /* FunctionExpression */ && + container.parent.kind === 290 /* PropertyAssignment */ && + container.parent.parent.kind === 202 /* ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* Prototype */) { return container.parent.parent.parent.left.expression; @@ -65459,7 +67902,7 @@ var ts; // Object.defineProperty(x, "method", { value: function() { } }); // Object.defineProperty(x, "method", { set: (x: () => void) => void }); // Object.defineProperty(x, "method", { get: () => function() { }) }); - else if (container.kind === 208 /* FunctionExpression */ && + else if (container.kind === 210 /* 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") && @@ -65484,7 +67927,7 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 308 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 311 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -65498,16 +67941,16 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 160 /* Parameter */ && n.parent === constructorDecl; }); + return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 162 /* Parameter */ && n.parent === constructorDecl; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 203 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 205 /* 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 === 209 /* ArrowFunction */) { + while (container && container.kind === 211 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -65520,14 +67963,14 @@ var ts; // class B { // [super.foo()]() {} // } - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 158 /* ComputedPropertyName */; }); - if (current && current.kind === 158 /* ComputedPropertyName */) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 160 /* ComputedPropertyName */; }); + if (current && current.kind === 160 /* 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 === 200 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 202 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -65535,7 +67978,7 @@ var ts; } return errorType; } - if (!isCallExpression && immediateContainer.kind === 166 /* Constructor */) { + if (!isCallExpression && immediateContainer.kind === 168 /* 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.hasSyntacticModifier(container, 32 /* Static */) || isCallExpression) { @@ -65604,7 +68047,7 @@ 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 === 165 /* MethodDeclaration */ && ts.hasSyntacticModifier(container, 256 /* Async */)) { + if (container.kind === 167 /* MethodDeclaration */ && ts.hasSyntacticModifier(container, 256 /* Async */)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; } @@ -65618,7 +68061,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 200 /* ObjectLiteralExpression */) { + if (container.parent.kind === 202 /* ObjectLiteralExpression */) { if (languageVersion < 2 /* ES2015 */) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return errorType; @@ -65639,7 +68082,7 @@ var ts; if (!baseClassType) { return errorType; } - if (container.kind === 166 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 168 /* 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; @@ -65654,7 +68097,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 === 166 /* Constructor */; + return container.kind === 168 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -65662,21 +68105,21 @@ 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 === 200 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 202 /* ObjectLiteralExpression */) { if (ts.hasSyntacticModifier(container, 32 /* Static */)) { - return container.kind === 165 /* MethodDeclaration */ || - container.kind === 164 /* MethodSignature */ || - container.kind === 167 /* GetAccessor */ || - container.kind === 168 /* SetAccessor */; + return container.kind === 167 /* MethodDeclaration */ || + container.kind === 166 /* MethodSignature */ || + container.kind === 169 /* GetAccessor */ || + container.kind === 170 /* SetAccessor */; } else { - return container.kind === 165 /* MethodDeclaration */ || - container.kind === 164 /* MethodSignature */ || - container.kind === 167 /* GetAccessor */ || - container.kind === 168 /* SetAccessor */ || - container.kind === 163 /* PropertyDeclaration */ || - container.kind === 162 /* PropertySignature */ || - container.kind === 166 /* Constructor */; + return container.kind === 167 /* MethodDeclaration */ || + container.kind === 166 /* MethodSignature */ || + container.kind === 169 /* GetAccessor */ || + container.kind === 170 /* SetAccessor */ || + container.kind === 165 /* PropertyDeclaration */ || + container.kind === 164 /* PropertySignature */ || + container.kind === 168 /* Constructor */; } } } @@ -65684,10 +68127,10 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 165 /* MethodDeclaration */ || - func.kind === 167 /* GetAccessor */ || - func.kind === 168 /* SetAccessor */) && func.parent.kind === 200 /* ObjectLiteralExpression */ ? func.parent : - func.kind === 208 /* FunctionExpression */ && func.parent.kind === 288 /* PropertyAssignment */ ? func.parent.parent : + return (func.kind === 167 /* MethodDeclaration */ || + func.kind === 169 /* GetAccessor */ || + func.kind === 170 /* SetAccessor */) && func.parent.kind === 202 /* ObjectLiteralExpression */ ? func.parent : + func.kind === 210 /* FunctionExpression */ && func.parent.kind === 290 /* PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { @@ -65699,7 +68142,7 @@ var ts; }); } function getContextualThisParameterType(func) { - if (func.kind === 209 /* ArrowFunction */) { + if (func.kind === 211 /* ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -65726,7 +68169,7 @@ var ts; if (thisType) { return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral))); } - if (literal.parent.kind !== 288 /* PropertyAssignment */) { + if (literal.parent.kind !== 290 /* PropertyAssignment */) { break; } literal = literal.parent.parent; @@ -65740,7 +68183,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 === 216 /* BinaryExpression */ && parent.operatorToken.kind === 62 /* EqualsToken */) { + if (parent.kind === 218 /* BinaryExpression */ && parent.operatorToken.kind === 63 /* EqualsToken */) { var target = parent.left; if (ts.isAccessExpression(target)) { var expression = target.expression; @@ -65793,11 +68236,11 @@ var ts; return getTypeFromTypeNode(typeNode); } switch (declaration.kind) { - case 160 /* Parameter */: + case 162 /* Parameter */: return getContextuallyTypedParameterType(declaration); - case 198 /* BindingElement */: + case 200 /* BindingElement */: return getContextualTypeForBindingElement(declaration); - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: if (ts.hasSyntacticModifier(declaration, 32 /* Static */)) { return getContextualTypeForStaticPropertyDeclaration(declaration); } @@ -65808,10 +68251,10 @@ var ts; var parent = declaration.parent.parent; var name = declaration.propertyName || declaration.name; var parentType = getContextualTypeForVariableLikeDeclaration(parent) || - parent.kind !== 198 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent); + parent.kind !== 200 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent); if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name)) return undefined; - if (parent.name.kind === 197 /* ArrayBindingPattern */) { + if (parent.name.kind === 199 /* ArrayBindingPattern */) { var index = ts.indexOfNode(declaration.parent.elements, declaration); if (index < 0) return undefined; @@ -65945,10 +68388,13 @@ var ts; if (ts.isJsxOpeningLikeElement(callTarget) && argIndex === 0) { return getEffectiveFirstArgumentForJsxSignature(signature, callTarget); } - return getTypeAtPosition(signature, argIndex); + var restIndex = signature.parameters.length - 1; + return signatureHasRestParameter(signature) && argIndex >= restIndex ? + getIndexedAccessType(getTypeOfSymbol(signature.parameters[restIndex]), getLiteralType(argIndex - restIndex), 256 /* Contextual */) : + getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 205 /* TaggedTemplateExpression */) { + if (template.parent.kind === 207 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -65957,10 +68403,10 @@ var ts; var binaryExpression = node.parent; var left = binaryExpression.left, operatorToken = binaryExpression.operatorToken, right = binaryExpression.right; switch (operatorToken.kind) { - case 62 /* EqualsToken */: - case 75 /* AmpersandAmpersandEqualsToken */: - case 74 /* BarBarEqualsToken */: - case 76 /* QuestionQuestionEqualsToken */: + case 63 /* EqualsToken */: + case 76 /* AmpersandAmpersandEqualsToken */: + case 75 /* BarBarEqualsToken */: + case 77 /* QuestionQuestionEqualsToken */: return node === right ? getContextualTypeForAssignmentDeclaration(binaryExpression) : undefined; case 56 /* BarBarToken */: case 60 /* QuestionQuestionToken */: @@ -65982,16 +68428,16 @@ var ts; // In an assignment expression, the right operand is contextually typed by the type of the left operand. // Don't do this for assignment declarations unless there is a type tag on the assignment, to avoid circularity from checking the right operand. function getContextualTypeForAssignmentDeclaration(binaryExpression) { + var _a, _b; var kind = ts.getAssignmentDeclarationKind(binaryExpression); switch (kind) { case 0 /* None */: return getTypeOfExpression(binaryExpression.left); + case 4 /* ThisProperty */: + return getContextualTypeForThisPropertyAssignment(binaryExpression); case 5 /* Property */: - case 1 /* ExportsProperty */: - case 6 /* Prototype */: - case 3 /* PrototypeProperty */: if (isPossiblyAliasedThisProperty(binaryExpression, kind)) { - return getContextualTypeForThisPropertyAssignment(binaryExpression, kind); + return getContextualTypeForThisPropertyAssignment(binaryExpression); } // If `binaryExpression.left` was assigned a symbol, then this is a new declaration; otherwise it is an assignment to an existing declaration. // See `bindStaticPropertyAssignment` in `binder.ts`. @@ -66012,11 +68458,11 @@ var ts; var id = lhs.expression; var parentSymbol = resolveName(id, id.escapedText, 111551 /* Value */, undefined, id.escapedText, /*isUse*/ true); if (parentSymbol) { - var annotated = parentSymbol.valueDeclaration && ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration); - if (annotated) { + var annotated_1 = parentSymbol.valueDeclaration && ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration); + if (annotated_1) { var nameStr = ts.getElementOrPropertyAccessName(lhs); if (nameStr !== undefined) { - return getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated), nameStr); + return getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated_1), nameStr); } } return undefined; @@ -66024,9 +68470,15 @@ var ts; } return ts.isInJSFile(decl) ? undefined : getTypeOfExpression(binaryExpression.left); } + case 1 /* ExportsProperty */: + case 6 /* Prototype */: + case 3 /* PrototypeProperty */: + var valueDeclaration = (_a = binaryExpression.left.symbol) === null || _a === void 0 ? void 0 : _a.valueDeclaration; + // falls through case 2 /* ModuleExports */: - case 4 /* ThisProperty */: - return getContextualTypeForThisPropertyAssignment(binaryExpression, kind); + 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 */: @@ -66047,7 +68499,7 @@ var ts; var symbol = resolveName(declaration.left, name, 111551 /* Value */, undefined, undefined, /*isUse*/ true, /*excludeGlobals*/ true); return ts.isThisInitializedDeclaration(symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration); } - function getContextualTypeForThisPropertyAssignment(binaryExpression, kind) { + function getContextualTypeForThisPropertyAssignment(binaryExpression) { if (!binaryExpression.symbol) return getTypeOfExpression(binaryExpression.left); if (binaryExpression.symbol.valueDeclaration) { @@ -66059,8 +68511,6 @@ var ts; } } } - if (kind === 2 /* ModuleExports */) - return undefined; var thisAccess = ts.cast(binaryExpression.left, ts.isAccessExpression); if (!ts.isObjectLiteralMethod(ts.getThisContainer(thisAccess.expression, /*includeArrowFunctions*/ false))) { return undefined; @@ -66115,9 +68565,13 @@ var ts; } function getContextualTypeForObjectLiteralElement(element, contextFlags) { var objectLiteral = element.parent; + var propertyAssignmentType = ts.isPropertyAssignment(element) && getContextualTypeForVariableLikeDeclaration(element); + if (propertyAssignmentType) { + return propertyAssignmentType; + } var type = getApparentTypeOfContextualType(objectLiteral, contextFlags); if (type) { - if (!hasNonBindableDynamicName(element)) { + if (hasBindableName(element)) { // For a (non-symbol) computed property, there is no reason to look up the name // in the type. It will just be "__computed", which does not appear in any // SymbolTable. @@ -66197,25 +68651,25 @@ var ts; case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: - case 103 /* NullKeyword */: - case 78 /* Identifier */: - case 150 /* UndefinedKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: + case 104 /* NullKeyword */: + case 79 /* Identifier */: + case 151 /* UndefinedKeyword */: return true; - case 201 /* PropertyAccessExpression */: - case 207 /* ParenthesizedExpression */: + case 203 /* PropertyAccessExpression */: + case 209 /* ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: return !node.expression || isPossiblyDiscriminantValue(node.expression); } return false; } function discriminateContextualTypeByObjectMembers(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 288 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); + return getMatchingUnionConstituentForObjectLiteral(contextualType, node) || discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 290 /* 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); } function discriminateContextualTypeByJSXAttributes(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 280 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return checkExpression(prop.initializer); }), prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 282 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return checkExpression(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 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. @@ -66226,15 +68680,9 @@ var ts; var instantiatedType = instantiateContextualType(contextualType, node, contextFlags); if (instantiatedType && !(contextFlags && contextFlags & 2 /* NoConstraints */ && instantiatedType.flags & 8650752 /* TypeVariable */)) { var apparentType = mapType(instantiatedType, getApparentType, /*noReductions*/ true); - if (apparentType.flags & 1048576 /* Union */) { - if (ts.isObjectLiteralExpression(node)) { - return discriminateContextualTypeByObjectMembers(node, apparentType); - } - else if (ts.isJsxAttributes(node)) { - return discriminateContextualTypeByJSXAttributes(node, apparentType); - } - } - return apparentType; + return apparentType.flags & 1048576 /* Union */ && ts.isObjectLiteralExpression(node) ? discriminateContextualTypeByObjectMembers(node, apparentType) : + apparentType.flags & 1048576 /* Union */ && ts.isJsxAttributes(node) ? discriminateContextualTypeByJSXAttributes(node, apparentType) : + apparentType; } } // If the given contextual type contains instantiable types and if a mapper representing @@ -66301,58 +68749,60 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 249 /* VariableDeclaration */: - case 160 /* Parameter */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 198 /* BindingElement */: + case 251 /* VariableDeclaration */: + case 162 /* Parameter */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 200 /* BindingElement */: return getContextualTypeForInitializerExpression(node, contextFlags); - case 209 /* ArrowFunction */: - case 242 /* ReturnStatement */: + case 211 /* ArrowFunction */: + case 244 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 213 /* AwaitExpression */: + case 215 /* AwaitExpression */: return getContextualTypeForAwaitOperand(parent, contextFlags); - case 203 /* CallExpression */: - if (parent.expression.kind === 99 /* ImportKeyword */) { + case 205 /* CallExpression */: + if (parent.expression.kind === 100 /* ImportKeyword */) { return stringType; } /* falls through */ - case 204 /* NewExpression */: + case 206 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 206 /* TypeAssertionExpression */: - case 224 /* AsExpression */: + case 208 /* TypeAssertionExpression */: + case 226 /* AsExpression */: return ts.isConstTypeReference(parent.type) ? tryFindWhenConstTypeReference(parent) : getTypeFromTypeNode(parent.type); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node, contextFlags); - case 288 /* PropertyAssignment */: - case 289 /* ShorthandPropertyAssignment */: + case 290 /* PropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent, contextFlags); - case 290 /* SpreadAssignment */: - return getApparentTypeOfContextualType(parent.parent, contextFlags); - case 199 /* ArrayLiteralExpression */: { + case 292 /* SpreadAssignment */: + return getContextualType(parent.parent, contextFlags); + case 201 /* ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral, contextFlags); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node, contextFlags); - case 228 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 218 /* TemplateExpression */); + case 230 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 220 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 207 /* ParenthesizedExpression */: { + case 209 /* 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 ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent, contextFlags); } - case 283 /* JsxExpression */: + case 227 /* NonNullExpression */: + return getContextualType(parent, contextFlags); + case 285 /* JsxExpression */: return getContextualTypeForJsxExpression(parent); - case 280 /* JsxAttribute */: - case 282 /* JsxSpreadAttribute */: + case 282 /* JsxAttribute */: + case 284 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 275 /* JsxOpeningElement */: - case 274 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent, contextFlags); } return undefined; @@ -66388,14 +68838,14 @@ var ts; return propsType; } function getJsxPropsTypeForSignatureFromMember(sig, forcedLookupLocation) { - if (sig.unionSignatures) { + if (sig.compositeSignatures) { // JSX Elements using the legacy `props`-field based lookup (eg, react class components) need to treat the `props` member as an input // instead of an output position when resolving the signature. We need to go back to the input signatures of the composite signature, // get the type of `props` on each return type individually, and then _intersect them_, rather than union them (as would normally occur // for a union signature). It's an unfortunate quirk of looking in the output of the signature for the type we want to use for the input. // The default behavior of `getTypeOfFirstParameterOfSignatureWithFallback` when no `props` member name is defined is much more sane. var results = []; - for (var _i = 0, _a = sig.unionSignatures; _i < _a.length; _i++) { + for (var _i = 0, _a = sig.compositeSignatures; _i < _a.length; _i++) { var signature = _a[_i]; var instance = getReturnTypeOfSignature(signature); if (isTypeAny(instance)) { @@ -66407,7 +68857,7 @@ var ts; } results.push(propType); } - return getIntersectionType(results); + return getIntersectionType(results); // Same result for both union and intersection signatures } var instanceType = getReturnTypeOfSignature(sig); return isTypeAny(instanceType) ? instanceType : getTypeOfPropertyOfType(instanceType, forcedLookupLocation); @@ -66432,16 +68882,19 @@ var ts; function getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType) { var managedSym = getJsxLibraryManagedAttributes(ns); if (managedSym) { - var declaredManagedType = getDeclaredTypeOfSymbol(managedSym); + var declaredManagedType = getDeclaredTypeOfSymbol(managedSym); // fetches interface type, or initializes symbol links type parmaeters var ctorType = getStaticTypeOfReferencedJsxConstructor(context); + if (managedSym.flags & 524288 /* TypeAlias */) { + var params = getSymbolLinks(managedSym).typeParameters; + if (ts.length(params) >= 2) { + var args = fillMissingTypeArguments([ctorType, attributesType], params, 2, ts.isInJSFile(context)); + return getTypeAliasInstantiation(managedSym, args); + } + } if (ts.length(declaredManagedType.typeParameters) >= 2) { var args = fillMissingTypeArguments([ctorType, attributesType], declaredManagedType.typeParameters, 2, ts.isInJSFile(context)); return createTypeReference(declaredManagedType, args); } - else if (ts.length(declaredManagedType.aliasTypeArguments) >= 2) { - var args = fillMissingTypeArguments([ctorType, attributesType], declaredManagedType.aliasTypeArguments, 2, ts.isInJSFile(context)); - return getTypeAliasInstantiation(declaredManagedType.aliasSymbol, args); - } } return attributesType; } @@ -66486,16 +68939,93 @@ var ts; return apparentAttributesType; } } + function getIntersectedSignatures(signatures) { + return ts.getStrictOptionValue(compilerOptions, "noImplicitAny") + ? ts.reduceLeft(signatures, function (left, right) { + return left === right || !left ? left + : compareTypeParametersIdentical(left.typeParameters, right.typeParameters) ? combineSignaturesOfIntersectionMembers(left, right) + : undefined; + }) + : undefined; + } + function combineIntersectionThisParam(left, right, mapper) { + if (!left || !right) { + return left || right; + } + // A signature `this` type might be a read or a write position... It's very possible that it should be invariant + // and we should refuse to merge signatures if there are `this` types and they do not match. However, so as to be + // pessimistic when contextual typing, for now, we'll union the `this` types. + var thisType = getUnionType([getTypeOfSymbol(left), instantiateType(getTypeOfSymbol(right), mapper)]); + return createSymbolWithType(left, thisType); + } + function combineIntersectionParameters(left, right, mapper) { + var leftCount = getParameterCount(left); + var rightCount = getParameterCount(right); + var longest = leftCount >= rightCount ? left : right; + var shorter = longest === left ? right : left; + var longestCount = longest === left ? leftCount : rightCount; + var eitherHasEffectiveRest = (hasEffectiveRestParameter(left) || hasEffectiveRestParameter(right)); + var needsExtraRestElement = eitherHasEffectiveRest && !hasEffectiveRestParameter(longest); + var params = new Array(longestCount + (needsExtraRestElement ? 1 : 0)); + for (var i = 0; i < longestCount; i++) { + var longestParamType = tryGetTypeAtPosition(longest, i); + if (longest === right) { + longestParamType = instantiateType(longestParamType, mapper); + } + var shorterParamType = tryGetTypeAtPosition(shorter, i) || unknownType; + if (shorter === right) { + shorterParamType = instantiateType(shorterParamType, mapper); + } + var unionParamType = getUnionType([longestParamType, shorterParamType]); + var isRestParam = eitherHasEffectiveRest && !needsExtraRestElement && i === (longestCount - 1); + var isOptional = i >= getMinArgumentCount(longest) && i >= getMinArgumentCount(shorter); + var leftName = i >= leftCount ? undefined : getParameterNameAtPosition(left, i); + var rightName = i >= rightCount ? undefined : getParameterNameAtPosition(right, i); + var paramName = leftName === rightName ? leftName : + !leftName ? rightName : + !rightName ? leftName : + undefined; + var paramSymbol = createSymbol(1 /* FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* Optional */ : 0), paramName || "arg" + i); + paramSymbol.type = isRestParam ? createArrayType(unionParamType) : unionParamType; + params[i] = paramSymbol; + } + if (needsExtraRestElement) { + var restParamSymbol = createSymbol(1 /* FunctionScopedVariable */, "args"); + restParamSymbol.type = createArrayType(getTypeAtPosition(shorter, longestCount)); + if (shorter === right) { + restParamSymbol.type = instantiateType(restParamSymbol.type, mapper); + } + params[longestCount] = restParamSymbol; + } + return params; + } + function combineSignaturesOfIntersectionMembers(left, right) { + var typeParams = left.typeParameters || right.typeParameters; + var paramMapper; + if (left.typeParameters && right.typeParameters) { + paramMapper = createTypeMapper(right.typeParameters, left.typeParameters); + // We just use the type parameter defaults from the first signature + } + var declaration = left.declaration; + var params = combineIntersectionParameters(left, right, paramMapper); + var thisParam = combineIntersectionThisParam(left.thisParameter, right.thisParameter, paramMapper); + 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]); + if (paramMapper) { + result.mapper = left.compositeKind === 2097152 /* 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 */); - if (signatures.length === 1) { - var signature = signatures[0]; - if (!isAritySmaller(signature, node)) { - return signature; - } - } + var applicableByArity = ts.filter(signatures, function (s) { return !isAritySmaller(s, node); }); + return applicableByArity.length === 1 ? applicableByArity[0] : getIntersectedSignatures(applicableByArity); } /** If the contextual signature has fewer parameters than the function expression, do not use it */ function isAritySmaller(signature, target) { @@ -66512,7 +69042,7 @@ var ts; return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 208 /* FunctionExpression */ || node.kind === 209 /* ArrowFunction */; + return node.kind === 210 /* FunctionExpression */ || node.kind === 211 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -66526,7 +69056,7 @@ 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 !== 165 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 167 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var typeTagSignature = getSignatureOfTypeTag(node); if (typeTagSignature) { return typeTagSignature; @@ -66574,8 +69104,8 @@ var ts; return node.isSpread ? getIndexedAccessType(node.type, numberType) : node.type; } function hasDefaultValue(node) { - return (node.kind === 198 /* BindingElement */ && !!node.initializer) || - (node.kind === 216 /* BinaryExpression */ && node.operatorToken.kind === 62 /* EqualsToken */); + return (node.kind === 200 /* BindingElement */ && !!node.initializer) || + (node.kind === 218 /* BinaryExpression */ && node.operatorToken.kind === 63 /* EqualsToken */); } function checkArrayLiteral(node, checkMode, forceTuple) { var elements = node.elements; @@ -66585,9 +69115,10 @@ var ts; var contextualType = getApparentTypeOfContextualType(node); 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 === 220 /* SpreadElement */) { + if (e.kind === 222 /* SpreadElement */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(e, compilerOptions.downlevelIteration ? 1536 /* SpreadIncludes */ : 1024 /* SpreadArray */); } @@ -66620,17 +69151,22 @@ var ts; elementFlags.push(4 /* Rest */); } } + else if (strictOptionalProperties && e.kind === 224 /* OmittedExpression */) { + hasOmittedExpression = true; + elementTypes.push(missingType); + elementFlags.push(2 /* Optional */); + } else { var elementContextualType = getContextualTypeForElementExpression(contextualType, elementTypes.length); var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple); - elementTypes.push(type); - elementFlags.push(1 /* Required */); + elementTypes.push(addOptionality(type, /*isProperty*/ true, hasOmittedExpression)); + elementFlags.push(hasOmittedExpression ? 2 /* Optional */ : 1 /* Required */); } } if (inDestructuringPattern) { return createTupleType(elementTypes, elementFlags); } - if (forceTuple || inConstContext || contextualType && forEachType(contextualType, isTupleLikeType)) { + if (forceTuple || inConstContext || contextualType && someType(contextualType, isTupleLikeType)) { return createArrayLiteralType(createTupleType(elementTypes, elementFlags, /*readonly*/ inConstContext)); } return createArrayLiteralType(createArrayType(elementTypes.length ? @@ -66644,15 +69180,15 @@ var ts; var literalType = type.literalType; if (!literalType) { literalType = type.literalType = cloneTypeReference(type); - literalType.objectFlags |= 65536 /* ArrayLiteral */ | 1048576 /* ContainsObjectOrArrayLiteral */; + literalType.objectFlags |= 32768 /* ArrayLiteral */ | 262144 /* ContainsObjectOrArrayLiteral */; } return literalType; } function isNumericName(name) { switch (name.kind) { - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return isNumericComputedName(name); - case 78 /* Identifier */: + case 79 /* Identifier */: return isNumericLiteralName(name.escapedText); case 8 /* NumericLiteral */: case 10 /* StringLiteral */: @@ -66697,6 +69233,20 @@ var ts; var links = getNodeLinks(node.expression); if (!links.resolvedType) { links.resolvedType = checkExpression(node.expression); + // The computed property name of a non-static class field within a loop must be stored in a block-scoped binding. + // (It needs to be bound at class evaluation time.) + if (ts.isPropertyDeclaration(node.parent) && !ts.hasStaticModifier(node.parent) && ts.isClassExpression(node.parent.parent)) { + var container = ts.getEnclosingBlockScopeContainer(node.parent.parent); + 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 */; + // The generated variable which stores the computed field name must be block-scoped. + getNodeLinks(node).flags |= 524288 /* BlockScopedBindingInLoop */; + // The generated variable which stores the class must be block-scoped. + getNodeLinks(node.parent.parent).flags |= 524288 /* 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 */ || @@ -66704,9 +69254,6 @@ var ts; !isTypeAssignableTo(links.resolvedType, stringNumberSymbolType)) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } - else { - checkThatExpressionIsProperSymbolReference(node.expression, links.resolvedType, /*reportError*/ true); - } } return links.resolvedType; } @@ -66746,7 +69293,7 @@ var ts; var spread = emptyObjectType; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 196 /* ObjectBindingPattern */ || contextualType.pattern.kind === 200 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 198 /* ObjectBindingPattern */ || contextualType.pattern.kind === 202 /* ObjectLiteralExpression */); var inConstContext = isConstContext(node); var checkFlags = inConstContext ? 8 /* Readonly */ : 0; var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node); @@ -66761,7 +69308,7 @@ var ts; // which may never occur. for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; - if (elem.name && ts.isComputedPropertyName(elem.name) && !ts.isWellKnownSymbolSyntactically(elem.name)) { + if (elem.name && ts.isComputedPropertyName(elem.name)) { checkComputedPropertyName(elem.name); } } @@ -66769,16 +69316,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 === 158 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 160 /* ComputedPropertyName */ ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 288 /* PropertyAssignment */ || - memberDecl.kind === 289 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 290 /* PropertyAssignment */ || + memberDecl.kind === 291 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 288 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + var type = memberDecl.kind === 290 /* 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 === 289 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : + memberDecl.kind === 291 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJavascript) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -66790,7 +69337,7 @@ var ts; checkTypeAssignableTo(type, getTypeFromTypeNode(enumTag.typeExpression), memberDecl); } } - objectFlags |= ts.getObjectFlags(type) & 3670016 /* PropagatingFlags */; + objectFlags |= ts.getObjectFlags(type) & 917504 /* PropagatingFlags */; var nameType = computedNameType && isTypeUsableAsPropertyName(computedNameType) ? computedNameType : undefined; var prop = nameType ? createSymbol(4 /* Property */ | member.flags, getPropertyNameFromType(nameType), checkFlags | 4096 /* Late */) : @@ -66801,8 +69348,8 @@ var ts; 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 === 288 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 289 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 290 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 291 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216 /* Optional */; } @@ -66828,7 +69375,7 @@ var ts; member = prop; allPropertiesTable === null || allPropertiesTable === void 0 ? void 0 : allPropertiesTable.set(prop.escapedName, prop); } - else if (memberDecl.kind === 290 /* SpreadAssignment */) { + else if (memberDecl.kind === 292 /* SpreadAssignment */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } @@ -66840,15 +69387,20 @@ var ts; hasComputedNumberProperty = false; } var type = getReducedType(checkExpression(memberDecl.expression)); - if (!isValidSpreadType(type)) { - error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); - return errorType; + if (isValidSpreadType(type)) { + if (allPropertiesTable) { + checkSpreadPropOverrides(type, allPropertiesTable, memberDecl); + } + offset = propertiesArray.length; + if (spread === errorType) { + continue; + } + spread = getSpreadType(spread, type, node.symbol, objectFlags, inConstContext); } - if (allPropertiesTable) { - checkSpreadPropOverrides(type, allPropertiesTable, memberDecl); + else { + error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); + spread = errorType; } - spread = getSpreadType(spread, type, node.symbol, objectFlags, inConstContext); - offset = propertiesArray.length; continue; } else { @@ -66857,7 +69409,7 @@ 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 === 167 /* GetAccessor */ || memberDecl.kind === 168 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 169 /* GetAccessor */ || memberDecl.kind === 170 /* SetAccessor */); checkNodeDeferred(memberDecl); } if (computedNameType && !(computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */)) { @@ -66882,7 +69434,7 @@ 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 !== 290 /* SpreadAssignment */) { + if (contextualTypeHasPattern && node.parent.kind !== 292 /* 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)) { @@ -66894,6 +69446,9 @@ var ts; } } } + if (spread === errorType) { + return errorType; + } if (spread !== emptyObjectType) { if (propertiesArray.length > 0) { spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, objectFlags, inConstContext); @@ -66910,9 +69465,9 @@ var ts; var stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node, offset, propertiesArray, 0 /* String */) : undefined; var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, offset, propertiesArray, 1 /* Number */) : undefined; var result = createAnonymousType(node.symbol, propertiesTable, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); - result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 1048576 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 262144 /* ContainsObjectOrArrayLiteral */; if (isJSObjectLiteral) { - result.objectFlags |= 16384 /* JSLiteral */; + result.objectFlags |= 8192 /* JSLiteral */; } if (patternWithComputedProperties) { result.objectFlags |= 512 /* ObjectLiteralPatternWithComputedProperties */; @@ -66978,7 +69533,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 === 78 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); + return tagName.kind === 79 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); } function checkJsxAttribute(node, checkMode) { return node.initializer @@ -67002,14 +69557,14 @@ var ts; var hasSpreadAnyType = false; var typeToIntersect; var explicitlySpecifyChildrenAttribute = false; - var objectFlags = 4096 /* JsxAttributes */; + var objectFlags = 2048 /* 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) & 3670016 /* PropagatingFlags */; + objectFlags |= ts.getObjectFlags(exprType) & 917504 /* PropagatingFlags */; var attributeSymbol = createSymbol(4 /* Property */ | member.flags, member.escapedName); attributeSymbol.declarations = member.declarations; attributeSymbol.parent = member.parent; @@ -67025,7 +69580,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 282 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 284 /* JsxSpreadAttribute */); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, /*readonly*/ false); attributesTable = ts.createSymbolTable(); @@ -67051,7 +69606,7 @@ var ts; } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 273 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 275 /* 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); @@ -67067,7 +69622,7 @@ var ts; // 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); childrenPropSymbol.type = childrenTypes.length === 1 ? childrenTypes[0] : - childrenContextualType && forEachType(childrenContextualType, isTupleLikeType) ? createTupleType(childrenTypes) : + childrenContextualType && someType(childrenContextualType, isTupleLikeType) ? createTupleType(childrenTypes) : createArrayType(getUnionType(childrenTypes)); // Fake up a property declaration for the children childrenPropSymbol.valueDeclaration = ts.factory.createPropertySignature(/*modifiers*/ undefined, ts.unescapeLeadingUnderscores(jsxChildrenPropertyName), /*questionToken*/ undefined, /*type*/ undefined); @@ -67093,7 +69648,7 @@ var ts; function createJsxAttributesType() { objectFlags |= freshObjectLiteralFlag; var result = createAnonymousType(attributes.symbol, attributesTable, ts.emptyArray, ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); - result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 1048576 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 262144 /* ContainsObjectOrArrayLiteral */; return result; } } @@ -67108,7 +69663,7 @@ var ts; childrenTypes.push(stringType); } } - else if (child.kind === 283 /* JsxExpression */ && !child.expression) { + else if (child.kind === 285 /* JsxExpression */ && !child.expression) { continue; // empty jsx expressions don't *really* count as present children } else { @@ -67259,7 +69814,7 @@ var ts; else if (propertiesOfJsxElementAttribPropInterface.length === 1) { return propertiesOfJsxElementAttribPropInterface[0].escapedName; } - else if (propertiesOfJsxElementAttribPropInterface.length > 1) { + else if (propertiesOfJsxElementAttribPropInterface.length > 1 && jsxElementAttribPropInterfaceSym.declarations) { // More than one property on ElementAttributesProperty is an error error(jsxElementAttribPropInterfaceSym.declarations[0], ts.Diagnostics.The_global_type_JSX_0_may_not_have_more_than_one_property, ts.unescapeLeadingUnderscores(nameOfAttribPropContainer)); } @@ -67369,11 +69924,11 @@ var ts; if (!links.resolvedJsxElementAttributesType) { var symbol = getIntrinsicTagSymbol(node); if (links.jsxFlags & 1 /* IntrinsicNamedElement */) { - return links.resolvedJsxElementAttributesType = getTypeOfSymbol(symbol); + return links.resolvedJsxElementAttributesType = getTypeOfSymbol(symbol) || errorType; } else if (links.jsxFlags & 2 /* IntrinsicIndexedElement */) { return links.resolvedJsxElementAttributesType = - getIndexTypeOfType(getDeclaredTypeOfSymbol(symbol), 0 /* String */); + getIndexTypeOfType(getJsxType(JsxNames.IntrinsicElements, node), 0 /* String */) || errorType; } else { return links.resolvedJsxElementAttributesType = errorType; @@ -67526,9 +70081,12 @@ var ts; * @param type The type of the object whose property is being accessed. (Not the type of the property.) * @param prop The symbol for the property being accessed. */ - function checkPropertyAccessibility(node, isSuper, type, prop) { - var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 157 /* QualifiedName */ ? node.right : node.kind === 195 /* ImportType */ ? node : node.name; + function checkPropertyAccessibility(node, isSuper, writing, type, prop, reportError) { + if (reportError === void 0) { reportError = true; } + var flags = ts.getDeclarationModifierFlagsFromSymbol(prop, writing); + var errorNode = node.kind === 159 /* QualifiedName */ ? node.right : + node.kind === 197 /* ImportType */ ? node : + node.kind === 200 /* BindingElement */ && node.propertyName ? node.propertyName : node.name; if (isSuper) { // TS 1.0 spec (April 2014): 4.8.2 // - In a constructor, instance member function, instance member accessor, or @@ -67539,7 +70097,9 @@ var ts; // a super property access is permitted and must specify a public static member function of the base class. if (languageVersion < 2 /* ES2015 */) { if (symbolHasNonMethodDeclaration(prop)) { - error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); + if (reportError) { + error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); + } return false; } } @@ -67548,24 +70108,22 @@ var ts; // This error could mask a private property access error. But, a member // cannot simultaneously be private and abstract, so this will trigger an // additional error elsewhere. - error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(getDeclaringClass(prop))); + if (reportError) { + error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(getDeclaringClass(prop))); + } return false; } } // Referencing abstract properties within their own constructors is not allowed - if ((flags & 128 /* Abstract */) && ts.isThisProperty(node) && symbolHasNonMethodDeclaration(prop)) { + if ((flags & 128 /* Abstract */) && symbolHasNonMethodDeclaration(prop) && + (ts.isThisProperty(node) || ts.isThisInitializedObjectBindingExpression(node) || ts.isObjectBindingPattern(node.parent) && ts.isThisInitializedDeclaration(node.parent.parent))) { var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (declaringClassDeclaration && isNodeUsedDuringClassInitialization(node)) { - error(errorNode, ts.Diagnostics.Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor, symbolToString(prop), ts.getTextOfIdentifierOrLiteral(declaringClassDeclaration.name)); // TODO: GH#18217 - return false; - } - } - if (ts.isPropertyAccessExpression(node) && ts.isPrivateIdentifier(node.name)) { - if (!ts.getContainingClass(node)) { - error(errorNode, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); + if (reportError) { + error(errorNode, ts.Diagnostics.Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor, symbolToString(prop), ts.getTextOfIdentifierOrLiteral(declaringClassDeclaration.name)); // TODO: GH#18217 + } return false; } - return true; } // Public properties are otherwise accessible. if (!(flags & 24 /* NonPublicAccessibilityModifier */)) { @@ -67576,7 +70134,9 @@ var ts; if (flags & 8 /* Private */) { var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (!isNodeWithinClass(node, declaringClassDeclaration)) { - error(errorNode, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(getDeclaringClass(prop))); + if (reportError) { + error(errorNode, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(getDeclaringClass(prop))); + } return false; } return true; @@ -67590,7 +70150,7 @@ var ts; // of the property as base classes var enclosingClass = forEachEnclosingClass(node, function (enclosingDeclaration) { var enclosingClass = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingDeclaration)); - return isClassDerivedFromDeclaringClasses(enclosingClass, prop) ? enclosingClass : undefined; + return isClassDerivedFromDeclaringClasses(enclosingClass, prop, writing) ? enclosingClass : undefined; }); // A protected property is accessible if the property is within the declaring class or classes derived from it if (!enclosingClass) { @@ -67598,7 +70158,9 @@ var ts; // static member access is disallow var thisParameter = void 0; if (flags & 32 /* Static */ || !(thisParameter = getThisParameterFromNodeContext(node)) || !thisParameter.type) { - error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || type)); + if (reportError) { + error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || type)); + } return false; } var thisType = getTypeFromTypeNode(thisParameter.type); @@ -67613,7 +70175,9 @@ var ts; type = type.isThisType ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(type); // TODO: GH#18217 Use a different variable that's allowed to be undefined } if (!type || !hasBaseType(type, enclosingClass)) { - error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); + if (reportError) { + error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_This_is_an_instance_of_class_2, symbolToString(prop), typeToString(enclosingClass), typeToString(type)); + } return false; } return true; @@ -67669,20 +70233,20 @@ var ts; } return nonNullType; } - function checkPropertyAccessExpression(node) { - return node.flags & 32 /* OptionalChain */ ? checkPropertyAccessChain(node) : - checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullExpression(node.expression), node.name); + function checkPropertyAccessExpression(node, checkMode) { + return node.flags & 32 /* OptionalChain */ ? checkPropertyAccessChain(node, checkMode) : + checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullExpression(node.expression), node.name, checkMode); } - function checkPropertyAccessChain(node) { + function checkPropertyAccessChain(node, checkMode) { var leftType = checkExpression(node.expression); var nonOptionalType = getOptionalExpressionType(leftType, node.expression); - return propagateOptionalTypeMarker(checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullType(nonOptionalType, node.expression), node.name), node, nonOptionalType !== leftType); + return propagateOptionalTypeMarker(checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullType(nonOptionalType, node.expression), node.name, checkMode), node, nonOptionalType !== leftType); } - function checkQualifiedName(node) { - return checkPropertyAccessExpressionOrQualifiedName(node, node.left, checkNonNullExpression(node.left), node.right); + function checkQualifiedName(node, checkMode) { + return checkPropertyAccessExpressionOrQualifiedName(node, node.left, checkNonNullExpression(node.left), node.right, checkMode); } function isMethodAccessForCall(node) { - while (node.parent.kind === 207 /* ParenthesizedExpression */) { + while (node.parent.kind === 209 /* ParenthesizedExpression */) { node = node.parent; } return ts.isCallOrNewExpression(node.parent) && node.parent.expression === node; @@ -67717,14 +70281,13 @@ var ts; } var diagName = diagnosticName(right); if (propertyOnType) { - var typeValueDecl = propertyOnType.valueDeclaration; - var typeClass_1 = ts.getContainingClass(typeValueDecl); - ts.Debug.assert(!!typeClass_1); + var typeValueDecl = ts.Debug.checkDefined(propertyOnType.valueDeclaration); + var typeClass_1 = ts.Debug.checkDefined(ts.getContainingClass(typeValueDecl)); // We found a private identifier property with the same description. // Either: // - There is a lexically scoped private identifier AND it shadows the one we found on the type. // - It is an attempt to access the private identifier outside of the class. - if (lexicallyScopedIdentifier) { + if (lexicallyScopedIdentifier === null || lexicallyScopedIdentifier === void 0 ? void 0 : lexicallyScopedIdentifier.valueDeclaration) { var lexicalValueDecl = lexicallyScopedIdentifier.valueDeclaration; var lexicalClass = ts.getContainingClass(lexicalValueDecl); ts.Debug.assert(!!lexicalClass); @@ -67743,17 +70306,42 @@ var ts; return (isConstructorDeclaredProperty(prop) || ts.isThisProperty(node) && isAutoTypedProperty(prop)) && ts.getThisContainer(node, /*includeArrowFunctions*/ true) === getDeclaringConstructor(prop); } - function checkPropertyAccessExpressionOrQualifiedName(node, left, leftType, right) { + 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); - if (ts.isPrivateIdentifier(right)) { - checkExternalEmitHelpers(node, 524288 /* ClassPrivateFieldGet */); - } 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 (assignmentKind !== 1 /* Definite */) { + checkExternalEmitHelpers(node, 524288 /* ClassPrivateFieldGet */); + } + } var lexicallyScopedSymbol = lookupSymbolForPrivateIdentifierDeclaration(right.escapedText, right); + if (assignmentKind && lexicallyScopedSymbol && lexicallyScopedSymbol.valueDeclaration && ts.isMethodDeclaration(lexicallyScopedSymbol.valueDeclaration)) { + grammarErrorOnNode(right, ts.Diagnostics.Cannot_assign_to_private_method_0_Private_methods_are_not_writable, ts.idText(right)); + } + if ((lexicallyScopedSymbol === null || lexicallyScopedSymbol === void 0 ? void 0 : lexicallyScopedSymbol.valueDeclaration) && (compilerOptions.target === 99 /* ESNext */ && !useDefineForClassFields)) { + var lexicalClass_1 = ts.getContainingClass(lexicallyScopedSymbol.valueDeclaration); + var parentStaticFieldInitializer = ts.findAncestor(node, function (n) { + if (n === lexicalClass_1) + return "quit"; + if (ts.isPropertyDeclaration(n.parent) && ts.hasStaticModifier(n.parent) && n.parent.initializer === n && n.parent.parent === lexicalClass_1) { + return true; + } + return false; + }); + if (parentStaticFieldInitializer) { + var parentStaticFieldInitializerSymbol = getSymbolOfNode(parentStaticFieldInitializer.parent); + ts.Debug.assert(parentStaticFieldInitializerSymbol, "Initializer without declaration symbol"); + var diagnostic = error(node, ts.Diagnostics.Property_0_may_not_be_used_in_a_static_property_s_initializer_in_the_same_class_when_target_is_esnext_and_useDefineForClassFields_is_false, ts.symbolName(lexicallyScopedSymbol)); + ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(parentStaticFieldInitializer.parent, ts.Diagnostics.Initializer_for_property_0, ts.symbolName(parentStaticFieldInitializerSymbol))); + } + } if (isAnyLike) { if (lexicallyScopedSymbol) { return apparentType; @@ -67768,6 +70356,12 @@ var ts; if (!prop && checkPrivateIdentifierPropertyAccess(leftType, right, lexicallyScopedSymbol)) { return errorType; } + else { + var isSetonlyAccessor = prop && prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); + if (isSetonlyAccessor && assignmentKind !== 1 /* Definite */) { + error(node, ts.Diagnostics.Private_accessor_was_defined_without_a_getter); + } + } } else { if (isAnyLike) { @@ -67778,7 +70372,11 @@ var ts; } prop = getPropertyOfType(apparentType, right.escapedText); } - if (ts.isIdentifier(left) && parentSymbol && !(prop && isConstEnumOrConstEnumOnlyModule(prop))) { + // In `Foo.Bar.Baz`, 'Foo' is not referenced if 'Bar' is a const enum or a module containing only const enums. + // The exceptions are: + // 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)) || ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(node))) { markAliasReferenced(parentSymbol, node); } var propType; @@ -67811,44 +70409,50 @@ var ts; } } else { - if (getDeclarationNodeFlagsFromSymbol(prop) & 134217728 /* Deprecated */ && isUncalledFunctionReference(node, prop)) { - errorOrSuggestion(/* isError */ false, right, ts.Diagnostics._0_is_deprecated, right.escapedText); + if (prop.declarations && getDeclarationNodeFlagsFromSymbol(prop) & 134217728 /* Deprecated */ && isUncalledFunctionReference(node, prop)) { + addDeprecatedSuggestion(right, prop.declarations, right.escapedText); } checkPropertyNotUsedBeforeDeclaration(prop, node, right); - markPropertyAsReferenced(prop, node, left.kind === 107 /* ThisKeyword */); + markPropertyAsReferenced(prop, node, isSelfTypeAccess(left, parentSymbol)); getNodeLinks(node).resolvedSymbol = prop; - checkPropertyAccessibility(node, left.kind === 105 /* SuperKeyword */, apparentType, prop); + var writing = ts.isWriteAccess(node); + checkPropertyAccessibility(node, left.kind === 106 /* 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; } - propType = isThisPropertyAccessInConstructor(node, prop) ? autoType : getConstraintForLocation(getTypeOfSymbol(prop), node); + propType = isThisPropertyAccessInConstructor(node, prop) ? autoType : writing ? getSetAccessorTypeOfSymbol(prop) : getTypeOfSymbol(prop); } - return getFlowTypeOfAccessExpression(node, prop, propType, right); + return getFlowTypeOfAccessExpression(node, prop, propType, right, checkMode); } - function getFlowTypeOfAccessExpression(node, prop, propType, errorNode) { + function getFlowTypeOfAccessExpression(node, prop, propType, errorNode, checkMode) { // Only compute control flow type if this is a property access expression that isn't an // assignment target, and the referenced property was declared as a variable, property, // accessor, or optional method. var assignmentKind = ts.getAssignmentTargetKind(node); - if (!ts.isAccessExpression(node) || - assignmentKind === 1 /* Definite */ || - prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */)) { + if (assignmentKind === 1 /* Definite */) { + return removeMissingType(propType, !!(prop && prop.flags & 16777216 /* Optional */)); + } + if (prop && + !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) + && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */) + && !isDuplicatedCommonJSExport(prop.declarations)) { return propType; } if (propType === autoType) { return getFlowTypeOfProperty(node, prop); } + propType = getNarrowableTypeForReference(propType, node, checkMode); // If strict null checks and strict property initialization checks are enabled, if we have // a this.xxx property access, if the property is an instance property without an initializer, // and if we are in a constructor of the same class as the property declaration, assume that // the property is uninitialized at the top of the control flow. var assumeUninitialized = false; - if (strictNullChecks && strictPropertyInitialization && node.expression.kind === 107 /* ThisKeyword */) { + if (strictNullChecks && strictPropertyInitialization && ts.isAccessExpression(node) && node.expression.kind === 108 /* ThisKeyword */) { var declaration = prop && prop.valueDeclaration; if (declaration && isInstancePropertyWithoutInitializer(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 166 /* Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 8388608 /* Ambient */)) { + if (flowContainer.kind === 168 /* Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 8388608 /* Ambient */)) { assumeUninitialized = true; } } @@ -67875,13 +70479,14 @@ var ts; var diagnosticMessage; var declarationName = ts.idText(right); if (isInPropertyInitializer(node) + && !isOptionalPropertyDeclaration(valueDeclaration) && !(ts.isAccessExpression(node) && ts.isAccessExpression(node.expression)) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) - && !isPropertyDeclaredInAncestorClass(prop)) { + && (compilerOptions.useDefineForClassFields || !isPropertyDeclaredInAncestorClass(prop))) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 252 /* ClassDeclaration */ && - node.parent.kind !== 173 /* TypeReference */ && + else if (valueDeclaration.kind === 254 /* ClassDeclaration */ && + node.parent.kind !== 175 /* TypeReference */ && !(valueDeclaration.flags & 8388608 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); @@ -67893,22 +70498,22 @@ var ts; function isInPropertyInitializer(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return true; - case 288 /* PropertyAssignment */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 290 /* SpreadAssignment */: - case 158 /* ComputedPropertyName */: - case 228 /* TemplateSpan */: - case 283 /* JsxExpression */: - case 280 /* JsxAttribute */: - case 281 /* JsxAttributes */: - case 282 /* JsxSpreadAttribute */: - case 275 /* JsxOpeningElement */: - case 223 /* ExpressionWithTypeArguments */: - case 286 /* HeritageClause */: + case 290 /* PropertyAssignment */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 292 /* SpreadAssignment */: + case 160 /* ComputedPropertyName */: + case 230 /* TemplateSpan */: + case 285 /* JsxExpression */: + case 282 /* JsxAttribute */: + case 283 /* JsxAttributes */: + case 284 /* JsxSpreadAttribute */: + case 277 /* JsxOpeningElement */: + case 225 /* ExpressionWithTypeArguments */: + case 288 /* HeritageClause */: return false; default: return ts.isExpressionNode(node) ? false : "quit"; @@ -67980,7 +70585,10 @@ var ts; relatedInfo = suggestion.valueDeclaration && ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestedName); } else { - errorInfo = ts.chainDiagnosticMessages(elaborateNeverIntersection(errorInfo, containingType), ts.Diagnostics.Property_0_does_not_exist_on_type_1, missingProperty, container); + var diagnostic = containerSeemsToBeEmptyDomElement(containingType) + ? ts.Diagnostics.Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom + : ts.Diagnostics.Property_0_does_not_exist_on_type_1; + errorInfo = ts.chainDiagnosticMessages(elaborateNeverIntersection(errorInfo, containingType), diagnostic, missingProperty, container); } } } @@ -67991,9 +70599,14 @@ var ts; } diagnostics.add(resultDiagnostic); } + function containerSeemsToBeEmptyDomElement(containingType) { + return (compilerOptions.lib && !compilerOptions.lib.includes("dom")) && + everyContainedType(containingType, function (type) { return type.symbol && /^(EventTarget|Node|((HTML[a-zA-Z]*)?Element))$/.test(ts.unescapeLeadingUnderscores(type.symbol.escapedName)); }) && + isEmptyObjectType(containingType); + } function typeHasStaticProperty(propName, containingType) { var prop = containingType.symbol && getPropertyOfType(getTypeOfSymbol(containingType.symbol), propName); - return prop !== undefined && prop.valueDeclaration && ts.hasSyntacticModifier(prop.valueDeclaration, 32 /* Static */); + return prop !== undefined && !!prop.valueDeclaration && ts.hasSyntacticModifier(prop.valueDeclaration, 32 /* Static */); } function getSuggestedLibForNonExistentName(name) { var missingName = diagnosticName(name); @@ -68024,7 +70637,15 @@ var ts; } } function getSuggestedSymbolForNonexistentProperty(name, containingType) { - return getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 111551 /* Value */); + var props = getPropertiesOfType(containingType); + if (typeof name !== "string") { + var parent_2 = name.parent; + if (ts.isPropertyAccessExpression(parent_2)) { + props = ts.filter(props, function (prop) { return isValidPropertyAccessForCompletions(parent_2, containingType, prop); }); + } + name = ts.idText(name); + } + return getSpellingSuggestionForName(name, props, 111551 /* Value */); } function getSuggestedSymbolForNonexistentJSXAttribute(name, containingType) { var strName = ts.isString(name) ? name : ts.idText(name); @@ -68119,20 +70740,20 @@ var ts; return undefined; } } - function markPropertyAsReferenced(prop, nodeForCheckWriteOnly, isThisAccess) { + function markPropertyAsReferenced(prop, nodeForCheckWriteOnly, isSelfTypeAccess) { var valueDeclaration = prop && (prop.flags & 106500 /* ClassMember */) && prop.valueDeclaration; if (!valueDeclaration) { return; } var hasPrivateModifier = ts.hasEffectiveModifier(valueDeclaration, 8 /* Private */); - var hasPrivateIdentifier = ts.isNamedDeclaration(prop.valueDeclaration) && ts.isPrivateIdentifier(prop.valueDeclaration.name); + 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 */)) { return; } - if (isThisAccess) { + if (isSelfTypeAccess) { // Find any FunctionLikeDeclaration because those create a new 'this' binding. But this should only matter for methods (or getters/setters). var containingMethod = ts.findAncestor(nodeForCheckWriteOnly, ts.isFunctionLikeDeclaration); if (containingMethod && containingMethod.symbol === prop) { @@ -68141,18 +70762,22 @@ var ts; } (ts.getCheckFlags(prop) & 1 /* Instantiated */ ? getSymbolLinks(prop).target : prop).isReferenced = 67108863 /* All */; } + function isSelfTypeAccess(name, parent) { + return name.kind === 108 /* ThisKeyword */ + || !!parent && ts.isEntityNameExpression(name) && parent === getResolvedSymbol(ts.getFirstIdentifier(name)); + } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 201 /* PropertyAccessExpression */: - return isValidPropertyAccessWithType(node, node.expression.kind === 105 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); - case 157 /* QualifiedName */: + case 203 /* PropertyAccessExpression */: + return isValidPropertyAccessWithType(node, node.expression.kind === 106 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); + case 159 /* QualifiedName */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getWidenedType(checkExpression(node.left))); - case 195 /* ImportType */: + case 197 /* ImportType */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind === 201 /* PropertyAccessExpression */ && node.expression.kind === 105 /* SuperKeyword */, property.escapedName, type); + return isValidPropertyAccessWithType(node, node.kind === 203 /* PropertyAccessExpression */ && node.expression.kind === 106 /* SuperKeyword */, property.escapedName, type); // Previously we validated the 'this' type of methods but this adversely affected performance. See #31377 for more context. } function isValidPropertyAccessWithType(node, isSuper, propertyName, type) { @@ -68161,11 +70786,11 @@ var ts; } var prop = getPropertyOfType(type, propertyName); if (prop) { - if (ts.isPropertyAccessExpression(node) && prop.valueDeclaration && ts.isPrivateIdentifierPropertyDeclaration(prop.valueDeclaration)) { + if (prop.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(prop.valueDeclaration)) { var declClass_1 = ts.getContainingClass(prop.valueDeclaration); return !ts.isOptionalChain(node) && !!ts.findAncestor(node, function (parent) { return parent === declClass_1; }); } - return checkPropertyAccessibility(node, isSuper, type, prop); + return checkPropertyAccessibility(node, isSuper, /*writing*/ false, type, prop, /* reportError */ false); } // In js files properties of unions are allowed in completion return ts.isInJSFile(node) && (type.flags & 1048576 /* Union */) !== 0 && type.types.some(function (elementType) { return isValidPropertyAccessWithType(node, isSuper, propertyName, elementType); }); @@ -68175,13 +70800,13 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 250 /* VariableDeclarationList */) { + if (initializer.kind === 252 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 78 /* Identifier */) { + else if (initializer.kind === 79 /* Identifier */) { return getResolvedSymbol(initializer); } return undefined; @@ -68198,13 +70823,13 @@ var ts; */ function isForInVariableForNumericPropertyNames(expr) { var e = ts.skipParentheses(expr); - if (e.kind === 78 /* Identifier */) { + if (e.kind === 79 /* Identifier */) { var symbol = getResolvedSymbol(e); if (symbol.flags & 3 /* Variable */) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 238 /* ForInStatement */ && + if (node.kind === 240 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -68217,16 +70842,16 @@ var ts; } return false; } - function checkIndexedAccess(node) { - return node.flags & 32 /* OptionalChain */ ? checkElementAccessChain(node) : - checkElementAccessExpression(node, checkNonNullExpression(node.expression)); + function checkIndexedAccess(node, checkMode) { + return node.flags & 32 /* OptionalChain */ ? checkElementAccessChain(node, checkMode) : + checkElementAccessExpression(node, checkNonNullExpression(node.expression), checkMode); } - function checkElementAccessChain(node) { + function checkElementAccessChain(node, checkMode) { var exprType = checkExpression(node.expression); var nonOptionalType = getOptionalExpressionType(exprType, node.expression); - return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression)), node, nonOptionalType !== exprType); + return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression), checkMode), node, nonOptionalType !== exprType); } - function checkElementAccessExpression(node, exprType) { + function checkElementAccessExpression(node, exprType, checkMode) { var objectType = ts.getAssignmentTargetKind(node) !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; var indexExpression = node.argumentExpression; var indexType = checkExpression(indexExpression); @@ -68239,45 +70864,10 @@ var ts; } var effectiveIndexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType; var accessFlags = ts.isAssignmentTarget(node) ? - 2 /* Writing */ | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 1 /* NoIndexSignatures */ : 0) : - 0 /* None */; - var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, /*noUncheckedIndexedAccessCandidate*/ undefined, node, accessFlags | 16 /* ExpressionPosition */) || errorType; - return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, indexedAccessType.symbol, indexedAccessType, indexExpression), node); - } - function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) { - if (expressionType === errorType) { - // There is already an error, so no need to report one. - return false; - } - if (!ts.isWellKnownSymbolSyntactically(expression)) { - return false; - } - // Make sure the property type is the primitive symbol type - if ((expressionType.flags & 12288 /* ESSymbolLike */) === 0) { - if (reportError) { - error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression)); - } - return false; - } - // The name is Symbol., so make sure Symbol actually resolves to the - // global Symbol object - var leftHandSide = expression.expression; - var leftHandSideSymbol = getResolvedSymbol(leftHandSide); - if (!leftHandSideSymbol) { - return false; - } - var globalESSymbol = getGlobalESSymbolConstructorSymbol(/*reportErrors*/ true); - if (!globalESSymbol) { - // Already errored when we tried to look up the symbol - return false; - } - if (leftHandSideSymbol !== globalESSymbol) { - if (reportError) { - error(leftHandSide, ts.Diagnostics.Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object); - } - return false; - } - return true; + 4 /* Writing */ | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 2 /* NoIndexSignatures */ : 0) : + 32 /* ExpressionPosition */; + var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, accessFlags, node) || errorType; + return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, getNodeLinks(node).resolvedSymbol, indexedAccessType, indexExpression, checkMode), node); } function callLikeExpressionMayHaveTypeArguments(node) { return ts.isCallOrNewExpression(node) || ts.isTaggedTemplateExpression(node) || ts.isJsxOpeningLikeElement(node); @@ -68288,13 +70878,13 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 205 /* TaggedTemplateExpression */) { + if (node.kind === 207 /* TaggedTemplateExpression */) { checkExpression(node.template); } else if (ts.isJsxOpeningLikeElement(node)) { checkExpression(node.attributes); } - else if (node.kind !== 161 /* Decorator */) { + else if (node.kind !== 163 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -68358,7 +70948,7 @@ var ts; } } function isSpreadArgument(arg) { - return !!arg && (arg.kind === 220 /* SpreadElement */ || arg.kind === 227 /* SyntheticExpression */ && arg.isSpread); + return !!arg && (arg.kind === 222 /* SpreadElement */ || arg.kind === 229 /* SyntheticExpression */ && arg.isSpread); } function getSpreadArgumentIndex(args) { return ts.findIndex(args, isSpreadArgument); @@ -68375,9 +70965,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 === 205 /* TaggedTemplateExpression */) { + if (node.kind === 207 /* TaggedTemplateExpression */) { argCount = args.length; - if (node.template.kind === 218 /* TemplateExpression */) { + if (node.template.kind === 220 /* 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. @@ -68392,7 +70982,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 161 /* Decorator */) { + else if (node.kind === 163 /* Decorator */) { argCount = getDecoratorArgumentCount(node, signature); } else if (ts.isJsxOpeningLikeElement(node)) { @@ -68406,7 +70996,7 @@ var ts; } else if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 204 /* NewExpression */); + ts.Debug.assert(node.kind === 206 /* NewExpression */); return getMinArgumentCount(signature) === 0; } else { @@ -68481,7 +71071,7 @@ var ts; }); if (!inferenceContext) { applyToReturnTypes(contextualSignature, signature, function (source, target) { - inferTypes(context.inferences, source, target, 64 /* ReturnType */); + inferTypes(context.inferences, source, target, 128 /* ReturnType */); }); } return getSignatureInstantiation(signature, getInferredTypes(context), ts.isInJSFile(contextualSignature.declaration)); @@ -68492,6 +71082,15 @@ var ts; inferTypes(context.inferences, checkAttrType, paramType); return getInferredTypes(context); } + function getThisArgumentType(thisArgumentNode) { + if (!thisArgumentNode) { + return voidType; + } + var thisArgumentType = checkExpression(thisArgumentNode); + return ts.isOptionalChainRoot(thisArgumentNode.parent) ? getNonNullableType(thisArgumentType) : + ts.isOptionalChain(thisArgumentNode.parent) ? removeOptionalTypeMarker(thisArgumentType) : + thisArgumentType; + } function inferTypeArguments(node, signature, args, checkMode, context) { if (ts.isJsxOpeningLikeElement(node)) { return inferJsxTypeArguments(node, signature, checkMode, context); @@ -68500,7 +71099,7 @@ 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 !== 161 /* Decorator */) { + if (node.kind !== 163 /* Decorator */) { var contextualType = getContextualType(node, ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }) ? 8 /* SkipBindingPatterns */ : 0 /* None */); if (contextualType) { // We clone the inference context to avoid disturbing a resolution in progress for an @@ -68522,7 +71121,7 @@ var ts; instantiatedType; var inferenceTargetType = getReturnTypeOfSignature(signature); // Inferences made from return types have lower priority than all other inferences. - inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 64 /* ReturnType */); + inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* 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 // the source type uses the outer context's return mapper (which excludes inferences made from @@ -68544,12 +71143,11 @@ var ts; var thisType = getThisTypeOfSignature(signature); if (thisType) { var thisArgumentNode = getThisArgumentOfCall(node); - var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; - inferTypes(context.inferences, thisArgumentType, thisType); + inferTypes(context.inferences, getThisArgumentType(thisArgumentNode), thisType); } for (var i = 0; i < argCount; i++) { var arg = args[i]; - if (arg.kind !== 222 /* OmittedExpression */) { + if (arg.kind !== 224 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode); inferTypes(context.inferences, argType, paramType); @@ -68573,7 +71171,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 === 227 /* SyntheticExpression */ ? arg.type : + return getMutableArrayOrTupleType(arg.kind === 229 /* SyntheticExpression */ ? arg.type : checkExpressionWithContextualType(arg.expression, restType, context, checkMode)); } } @@ -68583,24 +71181,24 @@ var ts; for (var i = index; i < argCount; i++) { var arg = args[i]; if (isSpreadArgument(arg)) { - var spreadType = arg.kind === 227 /* SyntheticExpression */ ? arg.type : checkExpression(arg.expression); + var spreadType = arg.kind === 229 /* SyntheticExpression */ ? arg.type : checkExpression(arg.expression); if (isArrayLikeType(spreadType)) { types.push(spreadType); flags.push(8 /* Variadic */); } else { - types.push(checkIteratedTypeOrElementType(33 /* Spread */, spreadType, undefinedType, arg.kind === 220 /* SpreadElement */ ? arg.expression : arg)); + types.push(checkIteratedTypeOrElementType(33 /* Spread */, spreadType, undefinedType, arg.kind === 222 /* SpreadElement */ ? arg.expression : arg)); flags.push(4 /* Rest */); } } else { - var contextualType = getIndexedAccessType(restType, getLiteralType(i - index)); + var contextualType = getIndexedAccessType(restType, getLiteralType(i - index), 256 /* Contextual */); var argType = checkExpressionWithContextualType(arg, contextualType, context, checkMode); var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 131068 /* Primitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */); types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType)); flags.push(1 /* Required */); } - if (arg.kind === 227 /* SyntheticExpression */ && arg.tupleNameSource) { + if (arg.kind === 229 /* SyntheticExpression */ && arg.tupleNameSource) { names.push(arg.tupleNameSource); } } @@ -68744,24 +71342,12 @@ var ts; return undefined; } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 204 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 206 /* 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. var thisArgumentNode = getThisArgumentOfCall(node); - var thisArgumentType = void 0; - if (thisArgumentNode) { - thisArgumentType = checkExpression(thisArgumentNode); - if (ts.isOptionalChainRoot(thisArgumentNode.parent)) { - thisArgumentType = getNonNullableType(thisArgumentType); - } - else if (ts.isOptionalChain(thisArgumentNode.parent)) { - thisArgumentType = removeOptionalTypeMarker(thisArgumentType); - } - } - else { - thisArgumentType = voidType; - } + var thisArgumentType = getThisArgumentType(thisArgumentNode); var errorNode = reportErrors ? (thisArgumentNode || node) : undefined; var headMessage_1 = ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1; if (!checkTypeRelatedTo(thisArgumentType, thisType, relation, errorNode, headMessage_1, containingMessageChain, errorOutputContainer)) { @@ -68774,7 +71360,7 @@ 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 !== 222 /* OmittedExpression */) { + if (arg.kind !== 224 /* 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), @@ -68819,7 +71405,7 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 203 /* CallExpression */) { + if (node.kind === 205 /* CallExpression */) { var callee = ts.skipOuterExpressions(node.expression); if (ts.isAccessExpression(callee)) { return callee.expression; @@ -68836,17 +71422,17 @@ var ts; * Returns the effective arguments for an expression that works like a function invocation. */ function getEffectiveCallArguments(node) { - if (node.kind === 205 /* TaggedTemplateExpression */) { + if (node.kind === 207 /* TaggedTemplateExpression */) { var template = node.template; var args_3 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())]; - if (template.kind === 218 /* TemplateExpression */) { + if (template.kind === 220 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_3.push(span.expression); }); } return args_3; } - if (node.kind === 161 /* Decorator */) { + if (node.kind === 163 /* Decorator */) { return getEffectiveDecoratorArguments(node); } if (ts.isJsxOpeningLikeElement(node)) { @@ -68857,10 +71443,10 @@ var ts; if (spreadIndex >= 0) { // Create synthetic arguments from spreads of tuple types. var effectiveArgs_1 = args.slice(0, spreadIndex); - var _loop_20 = function (i) { + var _loop_21 = function (i) { var arg = args[i]; // We can call checkExpressionCached because spread expressions never have a contextual type. - var spreadType = arg.kind === 220 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression)); + var spreadType = arg.kind === 222 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression)); if (spreadType && isTupleType(spreadType)) { ts.forEach(getTypeArguments(spreadType), function (t, i) { var _a; @@ -68874,7 +71460,7 @@ var ts; } }; for (var i = spreadIndex; i < args.length; i++) { - _loop_20(i); + _loop_21(i); } return effectiveArgs_1; } @@ -68887,30 +71473,30 @@ var ts; var parent = node.parent; var expr = node.expression; switch (parent.kind) { - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* 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 160 /* Parameter */: + case 162 /* 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 === 166 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), + createSyntheticExpression(expr, parent.parent.kind === 168 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), createSyntheticExpression(expr, anyType), createSyntheticExpression(expr, numberType) ]; - case 163 /* PropertyDeclaration */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* 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 !== 163 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; + var hasPropDesc = parent.kind !== 165 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; return [ createSyntheticExpression(expr, getParentTypeOfClassElement(parent)), createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)), @@ -68924,17 +71510,17 @@ var ts; */ function getDecoratorArgumentCount(node, signature) { switch (node.parent.kind) { - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: return 1; - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return 2; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* 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 160 /* Parameter */: + case 162 /* Parameter */: return 3; default: return ts.Debug.fail(); @@ -68980,77 +71566,66 @@ var ts; return constructorSymbol === globalPromiseSymbol; } function getArgumentArityError(node, signatures, args) { - var min = Number.POSITIVE_INFINITY; - var max = Number.NEGATIVE_INFINITY; - var belowArgCount = Number.NEGATIVE_INFINITY; - var aboveArgCount = Number.POSITIVE_INFINITY; - var argCount = args.length; + var _a; + var spreadIndex = getSpreadArgumentIndex(args); + if (spreadIndex > -1) { + return ts.createDiagnosticForNode(args[spreadIndex], ts.Diagnostics.A_spread_argument_must_either_have_a_tuple_type_or_be_passed_to_a_rest_parameter); + } + var min = Number.POSITIVE_INFINITY; // smallest parameter count + var max = Number.NEGATIVE_INFINITY; // largest parameter count + var maxBelow = Number.NEGATIVE_INFINITY; // largest parameter count that is smaller than the number of arguments + var minAbove = Number.POSITIVE_INFINITY; // smallest parameter count that is larger than the number of arguments var closestSignature; for (var _i = 0, signatures_8 = signatures; _i < signatures_8.length; _i++) { var sig = signatures_8[_i]; - var minCount = getMinArgumentCount(sig); - var maxCount = getParameterCount(sig); - if (minCount < argCount && minCount > belowArgCount) - belowArgCount = minCount; - if (argCount < maxCount && maxCount < aboveArgCount) - aboveArgCount = maxCount; - if (minCount < min) { - min = minCount; + var minParameter = getMinArgumentCount(sig); + var maxParameter = getParameterCount(sig); + // smallest/largest parameter counts + if (minParameter < min) { + min = minParameter; closestSignature = sig; } - max = Math.max(max, maxCount); + max = Math.max(max, maxParameter); + // shortest parameter count *longer than the call*/longest parameter count *shorter than the call* + if (minParameter < args.length && minParameter > maxBelow) + maxBelow = minParameter; + if (args.length < maxParameter && maxParameter < minAbove) + minAbove = maxParameter; } var hasRestParameter = ts.some(signatures, hasEffectiveRestParameter); - var paramRange = hasRestParameter ? min : - min < max ? min + "-" + max : - min; - var hasSpreadArgument = getSpreadArgumentIndex(args) > -1; - if (argCount <= max && hasSpreadArgument) { - argCount--; - } - var spanArray; - var related; - var error = hasRestParameter || hasSpreadArgument ? - hasRestParameter && hasSpreadArgument ? - ts.Diagnostics.Expected_at_least_0_arguments_but_got_1_or_more : - hasRestParameter ? - ts.Diagnostics.Expected_at_least_0_arguments_but_got_1 : - ts.Diagnostics.Expected_0_arguments_but_got_1_or_more : - paramRange === 1 && argCount === 0 && isPromiseResolveArityError(node) ? - ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise : - ts.Diagnostics.Expected_0_arguments_but_got_1; - if (closestSignature && getMinArgumentCount(closestSignature) > argCount && closestSignature.declaration) { - var paramDecl = closestSignature.declaration.parameters[closestSignature.thisParameter ? argCount + 1 : argCount]; - if (paramDecl) { - related = ts.createDiagnosticForNode(paramDecl, ts.isBindingPattern(paramDecl.name) ? ts.Diagnostics.An_argument_matching_this_binding_pattern_was_not_provided : - ts.isRestParameter(paramDecl) ? ts.Diagnostics.Arguments_for_the_rest_parameter_0_were_not_provided : ts.Diagnostics.An_argument_for_0_was_not_provided, !paramDecl.name ? argCount : !ts.isBindingPattern(paramDecl.name) ? ts.idText(ts.getFirstIdentifier(paramDecl.name)) : undefined); - } - } - if (min < argCount && argCount < max) { - return getDiagnosticForCallNode(node, ts.Diagnostics.No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments, argCount, belowArgCount, aboveArgCount); - } - if (!hasSpreadArgument && argCount < min) { - var diagnostic_1 = getDiagnosticForCallNode(node, error, paramRange, argCount); - return related ? ts.addRelatedInfo(diagnostic_1, related) : diagnostic_1; - } - if (hasRestParameter || hasSpreadArgument) { - spanArray = ts.factory.createNodeArray(args); - if (hasSpreadArgument && argCount) { - var nextArg = ts.elementAt(args, getSpreadArgumentIndex(args) + 1) || undefined; - spanArray = ts.factory.createNodeArray(args.slice(max > argCount && nextArg ? args.indexOf(nextArg) : Math.min(max, args.length - 1))); + var parameterRange = hasRestParameter ? min + : min < max ? min + "-" + max + : min; + var error = hasRestParameter ? ts.Diagnostics.Expected_at_least_0_arguments_but_got_1 + : parameterRange === 1 && args.length === 0 && isPromiseResolveArityError(node) ? ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise + : ts.Diagnostics.Expected_0_arguments_but_got_1; + if (min < args.length && args.length < max) { + // between min and max, but with no matching overload + return getDiagnosticForCallNode(node, ts.Diagnostics.No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments, args.length, maxBelow, minAbove); + } + else if (args.length < min) { + // too short: put the error span on the call expression, not any of the args + var diagnostic = getDiagnosticForCallNode(node, error, parameterRange, args.length); + var parameter = (_a = closestSignature === null || closestSignature === void 0 ? void 0 : closestSignature.declaration) === null || _a === void 0 ? void 0 : _a.parameters[closestSignature.thisParameter ? args.length + 1 : args.length]; + if (parameter) { + var parameterError = ts.createDiagnosticForNode(parameter, ts.isBindingPattern(parameter.name) ? ts.Diagnostics.An_argument_matching_this_binding_pattern_was_not_provided + : ts.isRestParameter(parameter) ? ts.Diagnostics.Arguments_for_the_rest_parameter_0_were_not_provided + : ts.Diagnostics.An_argument_for_0_was_not_provided, !parameter.name ? args.length : !ts.isBindingPattern(parameter.name) ? ts.idText(ts.getFirstIdentifier(parameter.name)) : undefined); + return ts.addRelatedInfo(diagnostic, parameterError); } + return diagnostic; } else { - spanArray = ts.factory.createNodeArray(args.slice(max)); - } - var pos = ts.first(spanArray).pos; - var end = ts.last(spanArray).end; - if (end === pos) { - end++; + // too long; error goes on the excess parameters + var errorSpan = ts.factory.createNodeArray(args.slice(max)); + var pos = ts.first(errorSpan).pos; + var end = ts.last(errorSpan).end; + if (end === pos) { + end++; + } + ts.setTextRangePosEnd(errorSpan, pos, end); + return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), errorSpan, error, parameterRange, args.length); } - ts.setTextRangePosEnd(spanArray, pos, end); - var diagnostic = ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), spanArray, error, paramRange, argCount); - return related ? ts.addRelatedInfo(diagnostic, related) : diagnostic; } function getTypeArgumentArityError(node, signatures, typeArguments) { var argCount = typeArguments.length; @@ -69081,15 +71656,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 === 205 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 161 /* Decorator */; + var isTaggedTemplate = node.kind === 207 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 163 /* Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var reportErrors = !candidatesOutArray && produceDiagnostics; var typeArguments; if (!isDecorator) { typeArguments = node.typeArguments; // We already perform checking on the type arguments on the class declaration itself. - if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 105 /* SuperKeyword */) { + if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 106 /* SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } @@ -69144,7 +71719,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 === 203 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 205 /* 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 @@ -69198,7 +71773,7 @@ var ts; var min_3 = Number.MAX_VALUE; var minIndex = 0; var i_1 = 0; - var _loop_21 = function (c) { + var _loop_22 = 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); if (diags_2) { @@ -69216,7 +71791,7 @@ var ts; }; for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) { var c = candidatesForArgumentError_1[_a]; - _loop_21(c); + _loop_22(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"); @@ -69374,7 +71949,7 @@ var ts; } var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max; var parameters = []; - var _loop_22 = function (i) { + var _loop_23 = 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; }); @@ -69382,7 +71957,7 @@ var ts; parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); }))); }; for (var i = 0; i < maxNonRestParam; i++) { - _loop_22(i); + _loop_23(i); } var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; }); var flags = 0 /* None */; @@ -69463,7 +72038,7 @@ var ts; return maxParamsIndex; } function resolveCallExpression(node, candidatesOutArray, checkMode) { - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (isTypeAny(superType)) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { @@ -69574,7 +72149,7 @@ 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 */ | 131072 /* Never */)) && isTypeAssignableTo(funcType, globalFunctionType); + !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & 1048576 /* Union */) && !(getReducedType(apparentFuncType).flags & 131072 /* Never */) && isTypeAssignableTo(funcType, globalFunctionType); } function resolveNewExpression(node, candidatesOutArray, checkMode) { if (node.arguments && languageVersion < 1 /* ES5 */) { @@ -69689,7 +72264,7 @@ var ts; var declaration = signature.declaration; var modifiers = ts.getSelectedEffectiveModifierFlags(declaration, 24 /* NonPublicAccessibilityModifier */); // (1) Public constructors and (2) constructor functions are always accessible. - if (!modifiers || declaration.kind !== 166 /* Constructor */) { + if (!modifiers || declaration.kind !== 168 /* Constructor */) { return true; } var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(declaration.parent.symbol); @@ -69833,16 +72408,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 160 /* Parameter */: + case 162 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; default: return ts.Debug.fail(); @@ -69888,7 +72463,7 @@ var ts; // 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(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.factory.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.factory.createKeywordTypeNode(128 /* AnyKeyword */)); + var declaration = ts.factory.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.factory.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.factory.createKeywordTypeNode(129 /* AnyKeyword */)); var parameterSymbol = createSymbol(1 /* FunctionScopedVariable */, "props"); parameterSymbol.type = result; return createSignature(declaration, @@ -69937,16 +72512,16 @@ var ts; } function resolveSignature(node, candidatesOutArray, checkMode) { switch (node.kind) { - case 203 /* CallExpression */: + case 205 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray, checkMode); - case 204 /* NewExpression */: + case 206 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray, checkMode); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode); - case 161 /* Decorator */: + case 163 /* Decorator */: return resolveDecorator(node, candidatesOutArray, checkMode); - case 275 /* JsxOpeningElement */: - case 274 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode); } throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); @@ -70046,7 +72621,7 @@ var ts; else if (ts.isBinaryExpression(node.parent)) { var parentNode = node.parent; var parentNodeOperator = node.parent.operatorToken.kind; - if (parentNodeOperator === 62 /* EqualsToken */ && (allowDeclaration || parentNode.right === node)) { + if (parentNodeOperator === 63 /* EqualsToken */ && (allowDeclaration || parentNode.right === node)) { name = parentNode.left; decl = name; } @@ -70055,7 +72630,7 @@ var ts; name = parentNode.parent.name; decl = parentNode.parent; } - else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 62 /* EqualsToken */ && (allowDeclaration || parentNode.parent.right === parentNode)) { + else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 63 /* EqualsToken */ && (allowDeclaration || parentNode.parent.right === parentNode)) { name = parentNode.parent.left; decl = name; } @@ -70078,10 +72653,10 @@ var ts; return false; } var parent = node.parent; - while (parent && parent.kind === 201 /* PropertyAccessExpression */) { + while (parent && parent.kind === 203 /* PropertyAccessExpression */) { parent = parent.parent; } - if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 62 /* EqualsToken */) { + if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 63 /* EqualsToken */) { var right = ts.getInitializerOfBinaryExpression(parent); return ts.isObjectLiteralExpression(right) && right; } @@ -70102,15 +72677,15 @@ var ts; return nonInferrableType; } checkDeprecatedSignature(signature, node); - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { return voidType; } - if (node.kind === 204 /* NewExpression */) { + if (node.kind === 206 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 166 /* Constructor */ && - declaration.kind !== 170 /* ConstructSignature */ && - declaration.kind !== 175 /* ConstructorType */ && + declaration.kind !== 168 /* Constructor */ && + declaration.kind !== 172 /* ConstructSignature */ && + declaration.kind !== 177 /* ConstructorType */ && !ts.isJSDocConstructSignature(declaration) && !isJSConstructor(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any @@ -70130,7 +72705,7 @@ var ts; if (returnType.flags & 12288 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent)); } - if (node.kind === 203 /* CallExpression */ && node.parent.kind === 233 /* ExpressionStatement */ && + if (node.kind === 205 /* CallExpression */ && !node.questionDotToken && node.parent.kind === 235 /* ExpressionStatement */ && returnType.flags & 16384 /* 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); @@ -70144,7 +72719,7 @@ 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, undefined, undefined); - jsAssignmentType.objectFlags |= 16384 /* JSLiteral */; + jsAssignmentType.objectFlags |= 8192 /* JSLiteral */; return getIntersectionType([returnType, jsAssignmentType]); } } @@ -70153,26 +72728,27 @@ var ts; function checkDeprecatedSignature(signature, node) { if (signature.declaration && signature.declaration.flags & 134217728 /* Deprecated */) { var suggestionNode = getDeprecatedSuggestionNode(node); - errorOrSuggestion(/*isError*/ false, suggestionNode, ts.Diagnostics._0_is_deprecated, signatureToString(signature)); + var name = ts.tryGetPropertyAccessOrIdentifierToString(ts.getInvokedExpression(node)); + addDeprecatedSuggestionWithSignature(suggestionNode, signature.declaration, name, signatureToString(signature)); } } function getDeprecatedSuggestionNode(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 203 /* CallExpression */: - case 161 /* Decorator */: - case 204 /* NewExpression */: + case 205 /* CallExpression */: + case 163 /* Decorator */: + case 206 /* NewExpression */: return getDeprecatedSuggestionNode(node.expression); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return getDeprecatedSuggestionNode(node.tag); - case 275 /* JsxOpeningElement */: - case 274 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: return getDeprecatedSuggestionNode(node.tagName); - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: return node.argumentExpression; - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return node.name; - case 173 /* TypeReference */: + case 175 /* TypeReference */: var typeReference = node; return ts.isQualifiedName(typeReference.typeName) ? typeReference.typeName.right : typeReference; default: @@ -70223,10 +72799,11 @@ var ts; return createPromiseReturnType(node, anyType); } function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol) { + var _a; if (allowSyntheticDefaultImports && type && type !== errorType) { var synthType = type; if (!synthType.syntheticType) { - var file = ts.find(originalSymbol.declarations, ts.isSourceFile); + var file = (_a = originalSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, /*dontResolveAlias*/ false); if (hasSyntheticDefault) { var memberTable = ts.createSymbolTable(); @@ -70264,9 +72841,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 251 /* FunctionDeclaration */ + ? 253 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 249 /* VariableDeclaration */ + ? 251 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -70294,21 +72871,21 @@ var ts; case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: - case 199 /* ArrayLiteralExpression */: - case 200 /* ObjectLiteralExpression */: - case 218 /* TemplateExpression */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: + case 201 /* ArrayLiteralExpression */: + case 202 /* ObjectLiteralExpression */: + case 220 /* TemplateExpression */: return true; - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return isValidConstAssertionArgument(node.expression); - case 214 /* PrefixUnaryExpression */: + case 216 /* 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 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: var expr = node.expression; if (ts.isIdentifier(expr)) { var symbol = getSymbolAtLocation(expr); @@ -70350,10 +72927,10 @@ var ts; } function checkMetaProperty(node) { checkGrammarMetaProperty(node); - if (node.keywordToken === 102 /* NewKeyword */) { + if (node.keywordToken === 103 /* NewKeyword */) { return checkNewTargetMetaProperty(node); } - if (node.keywordToken === 99 /* ImportKeyword */) { + if (node.keywordToken === 100 /* ImportKeyword */) { return checkImportMetaProperty(node); } return ts.Debug.assertNever(node.keywordToken); @@ -70364,7 +72941,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 === 166 /* Constructor */) { + else if (container.kind === 168 /* Constructor */) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -70411,7 +72988,7 @@ var ts; return restParameter.escapedName; } function isValidDeclarationForTupleLabel(d) { - return d.kind === 192 /* NamedTupleMember */ || (ts.isParameter(d) && d.name && ts.isIdentifier(d.name)); + return d.kind === 194 /* NamedTupleMember */ || (ts.isParameter(d) && d.name && ts.isIdentifier(d.name)); } function getNameableDeclarationAtPosition(signature, pos) { var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); @@ -70576,7 +73153,14 @@ var ts; } } function assignContextualParameterTypes(signature, context) { - signature.typeParameters = context.typeParameters; + if (context.typeParameters) { + if (!signature.typeParameters) { + signature.typeParameters = context.typeParameters; + } + else { + return; // This signature has already has a contextual inference performed and cached on it! + } + } if (context.thisParameter) { var parameter = signature.thisParameter; if (!parameter || parameter.valueDeclaration && !parameter.valueDeclaration.type) { @@ -70617,7 +73201,7 @@ var ts; if (!links.type) { var declaration = parameter.valueDeclaration; links.type = type || getWidenedTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true); - if (declaration.name.kind !== 78 /* Identifier */) { + if (declaration.name.kind !== 79 /* 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); @@ -70632,7 +73216,7 @@ var ts; for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { var element = _a[_i]; if (!ts.isOmittedExpression(element)) { - if (element.name.kind === 78 /* Identifier */) { + if (element.name.kind === 79 /* Identifier */) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } else { @@ -70687,7 +73271,7 @@ var ts; var yieldType; var nextType; var fallbackReturnType = voidType; - if (func.body.kind !== 230 /* Block */) { // Async or normal arrow function + if (func.body.kind !== 232 /* Block */) { // Async or normal arrow function returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8 /* SkipGenericFunctions */); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any @@ -70872,7 +73456,7 @@ var ts; return links.isExhaustive !== undefined ? links.isExhaustive : (links.isExhaustive = computeExhaustiveSwitchStatement(node)); } function computeExhaustiveSwitchStatement(node) { - if (node.expression.kind === 211 /* TypeOfExpression */) { + if (node.expression.kind === 213 /* TypeOfExpression */) { var operandType = getTypeOfExpression(node.expression.expression); var witnesses = getSwitchClauseTypeOfWitnesses(node, /*retainDefault*/ false); // notEqualFacts states that the type of the switched value is not equal to every type in the switch. @@ -70935,11 +73519,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return true; - case 165 /* MethodDeclaration */: - return func.parent.kind === 200 /* ObjectLiteralExpression */; + case 167 /* MethodDeclaration */: + return func.parent.kind === 202 /* ObjectLiteralExpression */; default: return false; } @@ -70965,21 +73549,21 @@ var ts; } // 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 === 164 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 230 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 166 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 232 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 512 /* HasExplicitReturn */; + var errorNode = ts.getEffectiveReturnTypeNode(func) || func; if (type && type.flags & 131072 /* Never */) { - error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); + error(errorNode, ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); } else if (type && !hasExplicitReturn) { // minimal check: function has syntactic return type annotation and no explicit return statements in the body // this function does not conform to the specification. - // NOTE: having returnType !== undefined is a precondition for entering this branch so func.type will always be present - error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value); + error(errorNode, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value); } else if (type && strictNullChecks && !isTypeAssignableTo(undefinedType, type)) { - error(ts.getEffectiveReturnTypeNode(func) || func, ts.Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined); + error(errorNode, ts.Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined); } else if (compilerOptions.noImplicitReturns) { if (!type) { @@ -70994,11 +73578,11 @@ var ts; return; } } - error(ts.getEffectiveReturnTypeNode(func) || func, ts.Diagnostics.Not_all_code_paths_return_a_value); + error(errorNode, ts.Diagnostics.Not_all_code_paths_return_a_value); } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 165 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 167 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); checkNodeDeferred(node); // The identityMapper object is used to indicate that function expressions are wildcards if (checkMode && checkMode & 4 /* SkipContextSensitive */ && isContextSensitive(node)) { @@ -71014,7 +73598,7 @@ var ts; var returnType = getReturnTypeFromBody(node, checkMode); var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); var returnOnlyType = createAnonymousType(node.symbol, emptySymbols, [returnOnlySignature], ts.emptyArray, undefined, undefined); - returnOnlyType.objectFlags |= 2097152 /* NonInferrableType */; + returnOnlyType.objectFlags |= 524288 /* NonInferrableType */; return links.contextFreeType = returnOnlyType; } } @@ -71022,7 +73606,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 208 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 210 /* FunctionExpression */) { checkGrammarForGenerator(node); } contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -71068,7 +73652,7 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 165 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 167 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnType = getReturnTypeFromAnnotation(node); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); @@ -71081,7 +73665,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 230 /* Block */) { + if (node.body.kind === 232 /* Block */) { checkSourceElement(node.body); } else { @@ -71168,10 +73752,10 @@ var ts; // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && ts.isAccessExpression(expr) && - expr.expression.kind === 107 /* ThisKeyword */) { + expr.expression.kind === 108 /* 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 === 166 /* Constructor */ || isJSConstructor(ctor)))) { + if (!(ctor && (ctor.kind === 168 /* Constructor */ || isJSConstructor(ctor)))) { return true; } if (symbol.valueDeclaration) { @@ -71192,11 +73776,11 @@ var ts; if (ts.isAccessExpression(expr)) { // references through namespace import should be readonly var node = ts.skipParentheses(expr.expression); - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { var symbol_2 = getNodeLinks(node).resolvedSymbol; if (symbol_2.flags & 2097152 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol_2); - return !!declaration && declaration.kind === 263 /* NamespaceImport */; + return !!declaration && declaration.kind === 265 /* NamespaceImport */; } } } @@ -71205,7 +73789,7 @@ 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 !== 78 /* Identifier */ && !ts.isAccessExpression(node)) { + if (node.kind !== 79 /* Identifier */ && !ts.isAccessExpression(node)) { error(expr, invalidReferenceMessage); return false; } @@ -71277,7 +73861,7 @@ var ts; 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); var func = ts.getContainingFunction(node); - if (func && func.kind !== 166 /* Constructor */ && (ts.getFunctionFlags(func) & 2 /* Async */) === 0) { + if (func && func.kind !== 168 /* Constructor */ && (ts.getFunctionFlags(func) & 2 /* Async */) === 0) { var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); } @@ -71444,14 +74028,33 @@ var ts; rightType = checkNonNullType(rightType, right); // TypeScript 1.0 spec (April 2014): 4.15.5 // The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, - // and the right operand to be of type Any, an object type, or a type parameter type. + // and the right operand to be + // + // 1. assignable to the non-primitive type, + // 2. an unconstrained type parameter, + // 3. a union or intersection including one or more type parameters, whose constituents are all assignable to the + // the non-primitive type, or are unconstrainted type parameters, or have constraints assignable to the + // non-primitive type, or + // 4. a type parameter whose constraint is + // i. an object type, + // ii. the non-primitive type, or + // iii. a union or intersection with at least one constituent assignable to an object or non-primitive type. + // + // The divergent behavior for type parameters and unions containing type parameters is a workaround for type + // parameters not being narrowable. If the right operand is a concrete type, we can error if there is any chance + // it is a primitive. But if the operand is a type parameter, it cannot be narrowed, so we don't issue an error + // unless *all* instantiations would result in an error. + // // The result is always of the Boolean primitive type. if (!(allTypesAssignableToKind(leftType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) || isTypeAssignableToKind(leftType, 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 262144 /* TypeParameter */))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } - if (!allTypesAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */)) { - error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); + 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 */))) { + error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_not_be_a_primitive); } return booleanType; } @@ -71470,7 +74073,7 @@ var ts; if (rightIsThis === void 0) { rightIsThis = false; } var properties = node.properties; var property = properties[propertyIndex]; - if (property.kind === 288 /* PropertyAssignment */ || property.kind === 289 /* ShorthandPropertyAssignment */) { + if (property.kind === 290 /* PropertyAssignment */ || property.kind === 291 /* ShorthandPropertyAssignment */) { var name = property.name; var exprType = getLiteralTypeFromPropertyName(name); if (isTypeUsableAsPropertyName(exprType)) { @@ -71478,14 +74081,14 @@ var ts; var prop = getPropertyOfType(objectLiteralType, text); if (prop) { markPropertyAsReferenced(prop, property, rightIsThis); - checkPropertyAccessibility(property, /*isSuper*/ false, objectLiteralType, prop); + checkPropertyAccessibility(property, /*isSuper*/ false, /*writing*/ true, objectLiteralType, prop); } } - var elementType = getIndexedAccessType(objectLiteralType, exprType, /*noUncheckedIndexedAccessCandidate*/ undefined, name, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, 16 /* ExpressionPosition */); + var elementType = getIndexedAccessType(objectLiteralType, exprType, 32 /* ExpressionPosition */, name); var type = getFlowTypeOfDestructuring(property, elementType); - return checkDestructuringAssignment(property.kind === 289 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); + return checkDestructuringAssignment(property.kind === 291 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); } - else if (property.kind === 290 /* SpreadAssignment */) { + else if (property.kind === 292 /* SpreadAssignment */) { if (propertyIndex < properties.length - 1) { error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } @@ -71523,7 +74126,7 @@ var ts; var inBoundsType = compilerOptions.noUncheckedIndexedAccess ? undefined : possiblyOutOfBoundsType; for (var i = 0; i < elements.length; i++) { var type = possiblyOutOfBoundsType; - if (node.elements[i].kind === 220 /* SpreadElement */) { + if (node.elements[i].kind === 222 /* SpreadElement */) { type = inBoundsType = inBoundsType !== null && inBoundsType !== void 0 ? inBoundsType : (checkIteratedTypeOrElementType(65 /* Destructuring */, sourceType, undefinedType, node) || errorType); } checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, type, checkMode); @@ -71533,14 +74136,14 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 222 /* OmittedExpression */) { - if (element.kind !== 220 /* SpreadElement */) { + if (element.kind !== 224 /* OmittedExpression */) { + if (element.kind !== 222 /* SpreadElement */) { var indexType = getLiteralType(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 = 16 /* ExpressionPosition */ | (hasDefaultValue(element) ? 8 /* NoTupleBoundsCheck */ : 0); - var elementType_2 = getIndexedAccessTypeOrUndefined(sourceType, indexType, /*noUncheckedIndexedAccessCandidate*/ undefined, createSyntheticExpression(element, indexType), accessFlags) || errorType; + var accessFlags = 32 /* ExpressionPosition */ | (hasDefaultValue(element) ? 16 /* 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 type = getFlowTypeOfDestructuring(element, assignedType); return checkDestructuringAssignment(element, type, checkMode); @@ -71552,7 +74155,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 216 /* BinaryExpression */ && restExpression.operatorToken.kind === 62 /* EqualsToken */) { + if (restExpression.kind === 218 /* BinaryExpression */ && restExpression.operatorToken.kind === 63 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -71568,7 +74171,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) { var target; - if (exprOrAssignment.kind === 289 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 291 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove @@ -71584,24 +74187,24 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 216 /* BinaryExpression */ && target.operatorToken.kind === 62 /* EqualsToken */) { + if (target.kind === 218 /* BinaryExpression */ && target.operatorToken.kind === 63 /* EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 200 /* ObjectLiteralExpression */) { + if (target.kind === 202 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, rightIsThis); } - if (target.kind === 199 /* ArrayLiteralExpression */) { + if (target.kind === 201 /* 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 === 290 /* SpreadAssignment */ ? + var error = target.parent.kind === 292 /* 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 === 290 /* SpreadAssignment */ ? + var optionalError = target.parent.kind === 292 /* 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)) { @@ -71623,39 +74226,39 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: case 10 /* StringLiteral */: case 13 /* RegularExpressionLiteral */: - case 205 /* TaggedTemplateExpression */: - case 218 /* TemplateExpression */: + case 207 /* TaggedTemplateExpression */: + case 220 /* TemplateExpression */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: - case 103 /* NullKeyword */: - case 150 /* UndefinedKeyword */: - case 208 /* FunctionExpression */: - case 221 /* ClassExpression */: - case 209 /* ArrowFunction */: - case 199 /* ArrayLiteralExpression */: - case 200 /* ObjectLiteralExpression */: - case 211 /* TypeOfExpression */: - case 225 /* NonNullExpression */: - case 274 /* JsxSelfClosingElement */: - case 273 /* JsxElement */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: + case 104 /* NullKeyword */: + case 151 /* UndefinedKeyword */: + case 210 /* FunctionExpression */: + case 223 /* ClassExpression */: + case 211 /* ArrowFunction */: + case 201 /* ArrayLiteralExpression */: + case 202 /* ObjectLiteralExpression */: + case 213 /* TypeOfExpression */: + case 227 /* NonNullExpression */: + case 276 /* JsxSelfClosingElement */: + case 275 /* JsxElement */: return true; - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 214 /* PrefixUnaryExpression */: - case 215 /* PostfixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { @@ -71667,9 +74270,9 @@ var ts; } return false; // Some forms listed here for clarity - case 212 /* VoidExpression */: // Explicit opt-out - case 206 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 224 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 214 /* VoidExpression */: // Explicit opt-out + case 208 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 226 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } @@ -71677,84 +74280,111 @@ var ts; function isTypeEqualityComparableTo(source, target) { return (target.flags & 98304 /* Nullable */) !== 0 || isTypeComparableTo(source, target); } - var CheckBinaryExpressionState; - (function (CheckBinaryExpressionState) { - CheckBinaryExpressionState[CheckBinaryExpressionState["MaybeCheckLeft"] = 0] = "MaybeCheckLeft"; - CheckBinaryExpressionState[CheckBinaryExpressionState["CheckRight"] = 1] = "CheckRight"; - CheckBinaryExpressionState[CheckBinaryExpressionState["FinishCheck"] = 2] = "FinishCheck"; - })(CheckBinaryExpressionState || (CheckBinaryExpressionState = {})); - function checkBinaryExpression(node, checkMode) { - var workStacks = { - expr: [node], - state: [0 /* MaybeCheckLeft */], - leftType: [undefined] + function createCheckBinaryExpression() { + var trampoline = ts.createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, foldState); + return function (node, checkMode) { + var result = trampoline(node, checkMode); + ts.Debug.assertIsDefined(result); + return result; }; - var stackIndex = 0; - var lastResult; - while (stackIndex >= 0) { - node = workStacks.expr[stackIndex]; - switch (workStacks.state[stackIndex]) { - case 0 /* MaybeCheckLeft */: { - if (ts.isInJSFile(node) && ts.getAssignedExpandoInitializer(node)) { - finishInvocation(checkExpression(node.right, checkMode)); - break; - } - checkGrammarNullishCoalesceWithLogicalExpression(node); - var operator = node.operatorToken.kind; - if (operator === 62 /* EqualsToken */ && (node.left.kind === 200 /* ObjectLiteralExpression */ || node.left.kind === 199 /* ArrayLiteralExpression */)) { - finishInvocation(checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 107 /* ThisKeyword */)); - break; - } - advanceState(1 /* CheckRight */); - maybeCheckExpression(node.left); - break; - } - case 1 /* CheckRight */: { - var leftType = lastResult; - workStacks.leftType[stackIndex] = leftType; - var operator = node.operatorToken.kind; - if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { - if (operator === 55 /* AmpersandAmpersandToken */) { - var parent = ts.walkUpParenthesizedExpressions(node.parent); - checkTestingKnownTruthyCallableType(node.left, leftType, ts.isIfStatement(parent) ? parent.thenStatement : undefined); - } - checkTruthinessOfType(leftType, node.left); + function onEnter(node, state, checkMode) { + if (state) { + state.stackIndex++; + state.skip = false; + setLeftType(state, /*type*/ undefined); + setLastResult(state, /*type*/ undefined); + } + else { + state = { + checkMode: checkMode, + skip: false, + stackIndex: 0, + typeStack: [undefined, undefined], + }; + } + if (ts.isInJSFile(node) && ts.getAssignedExpandoInitializer(node)) { + state.skip = true; + setLastResult(state, checkExpression(node.right, checkMode)); + return state; + } + checkGrammarNullishCoalesceWithLogicalExpression(node); + var operator = node.operatorToken.kind; + if (operator === 63 /* EqualsToken */ && (node.left.kind === 202 /* ObjectLiteralExpression */ || node.left.kind === 201 /* ArrayLiteralExpression */)) { + state.skip = true; + setLastResult(state, checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 108 /* ThisKeyword */)); + return state; + } + return state; + } + function onLeft(left, state, _node) { + if (!state.skip) { + return maybeCheckExpression(state, left); + } + } + function onOperator(operatorToken, state, node) { + if (!state.skip) { + var leftType = getLastResult(state); + ts.Debug.assertIsDefined(leftType); + 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); + checkTestingKnownTruthyCallableOrAwaitableType(node.left, leftType, ts.isIfStatement(parent) ? parent.thenStatement : undefined); } - advanceState(2 /* FinishCheck */); - maybeCheckExpression(node.right); - break; + checkTruthinessOfType(leftType, node.left); } - case 2 /* FinishCheck */: { - var leftType = workStacks.leftType[stackIndex]; - var rightType = lastResult; - finishInvocation(checkBinaryLikeExpressionWorker(node.left, node.operatorToken, node.right, leftType, rightType, node)); - break; - } - default: return ts.Debug.fail("Invalid state " + workStacks.state[stackIndex] + " for checkBinaryExpression"); } } - return lastResult; - function finishInvocation(result) { - lastResult = result; - stackIndex--; - } - /** - * Note that `advanceState` sets the _current_ head state, and that `maybeCheckExpression` potentially pushes on a new - * head state; so `advanceState` must be called before any `maybeCheckExpression` during a state's execution. - */ - function advanceState(nextState) { - workStacks.state[stackIndex] = nextState; + function onRight(right, state, _node) { + if (!state.skip) { + return maybeCheckExpression(state, right); + } } - function maybeCheckExpression(node) { - if (ts.isBinaryExpression(node)) { - stackIndex++; - workStacks.expr[stackIndex] = node; - workStacks.state[stackIndex] = 0 /* MaybeCheckLeft */; - workStacks.leftType[stackIndex] = undefined; + function onExit(node, state) { + var result; + if (state.skip) { + result = getLastResult(state); } else { - lastResult = checkExpression(node, checkMode); + var leftType = getLeftType(state); + ts.Debug.assertIsDefined(leftType); + var rightType = getLastResult(state); + ts.Debug.assertIsDefined(rightType); + result = checkBinaryLikeExpressionWorker(node.left, node.operatorToken, node.right, leftType, rightType, node); + } + state.skip = false; + setLeftType(state, /*type*/ undefined); + setLastResult(state, /*type*/ undefined); + state.stackIndex--; + return result; + } + function foldState(state, result, _side) { + setLastResult(state, result); + return state; + } + function maybeCheckExpression(state, node) { + if (ts.isBinaryExpression(node)) { + return node; } + setLastResult(state, checkExpression(node, state.checkMode)); + } + function getLeftType(state) { + return state.typeStack[state.stackIndex]; + } + function setLeftType(state, type) { + state.typeStack[state.stackIndex] = type; + } + function getLastResult(state) { + return state.typeStack[state.stackIndex + 1]; + } + function setLastResult(state, type) { + // To reduce overhead, reuse the next stack entry to store the + // last result. This avoids the overhead of an additional property + // on `WorkArea` and reuses empty stack entries as we walk back up + // the stack. + state.typeStack[state.stackIndex + 1] = type; } } function checkGrammarNullishCoalesceWithLogicalExpression(node) { @@ -71772,8 +74402,8 @@ 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 === 62 /* EqualsToken */ && (left.kind === 200 /* ObjectLiteralExpression */ || left.kind === 199 /* ArrayLiteralExpression */)) { - return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 107 /* ThisKeyword */); + if (operator === 63 /* EqualsToken */ && (left.kind === 202 /* ObjectLiteralExpression */ || left.kind === 201 /* ArrayLiteralExpression */)) { + return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 108 /* ThisKeyword */); } var leftType; if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { @@ -71790,26 +74420,26 @@ var ts; switch (operator) { case 41 /* AsteriskToken */: case 42 /* AsteriskAsteriskToken */: - case 65 /* AsteriskEqualsToken */: - case 66 /* AsteriskAsteriskEqualsToken */: + case 66 /* AsteriskEqualsToken */: + case 67 /* AsteriskAsteriskEqualsToken */: case 43 /* SlashToken */: - case 67 /* SlashEqualsToken */: + case 68 /* SlashEqualsToken */: case 44 /* PercentToken */: - case 68 /* PercentEqualsToken */: + case 69 /* PercentEqualsToken */: case 40 /* MinusToken */: - case 64 /* MinusEqualsToken */: + case 65 /* MinusEqualsToken */: case 47 /* LessThanLessThanToken */: - case 69 /* LessThanLessThanEqualsToken */: + case 70 /* LessThanLessThanEqualsToken */: case 48 /* GreaterThanGreaterThanToken */: - case 70 /* GreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanEqualsToken */: case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: case 51 /* BarToken */: - case 73 /* BarEqualsToken */: + case 74 /* BarEqualsToken */: case 52 /* CaretToken */: - case 77 /* CaretEqualsToken */: + case 78 /* CaretEqualsToken */: case 50 /* AmpersandToken */: - case 72 /* AmpersandEqualsToken */: + case 73 /* AmpersandEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -71839,11 +74469,11 @@ var ts; else if (bothAreBigIntLike(leftType, rightType)) { switch (operator) { case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: reportOperatorError(); break; case 42 /* AsteriskAsteriskToken */: - case 66 /* AsteriskAsteriskEqualsToken */: + case 67 /* AsteriskAsteriskEqualsToken */: if (languageVersion < 3 /* ES2016 */) { error(errorNode, ts.Diagnostics.Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_later); } @@ -71861,7 +74491,7 @@ var ts; return resultType_1; } case 39 /* PlusToken */: - case 63 /* PlusEqualsToken */: + case 64 /* PlusEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -71904,7 +74534,7 @@ var ts; }); return anyType; } - if (operator === 63 /* PlusEqualsToken */) { + if (operator === 64 /* PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; @@ -71926,41 +74556,41 @@ var ts; case 37 /* ExclamationEqualsEqualsToken */: reportOperatorErrorUnless(function (left, right) { return isTypeEqualityComparableTo(left, right) || isTypeEqualityComparableTo(right, left); }); return booleanType; - case 101 /* InstanceOfKeyword */: + case 102 /* InstanceOfKeyword */: return checkInstanceOfExpression(left, right, leftType, rightType); - case 100 /* InKeyword */: + case 101 /* InKeyword */: return checkInExpression(left, right, leftType, rightType); case 55 /* AmpersandAmpersandToken */: - case 75 /* AmpersandAmpersandEqualsToken */: { + case 76 /* AmpersandAmpersandEqualsToken */: { var resultType_2 = getTypeFacts(leftType) & 4194304 /* Truthy */ ? getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) : leftType; - if (operator === 75 /* AmpersandAmpersandEqualsToken */) { + if (operator === 76 /* AmpersandAmpersandEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_2; } case 56 /* BarBarToken */: - case 74 /* BarBarEqualsToken */: { + case 75 /* BarBarEqualsToken */: { var resultType_3 = getTypeFacts(leftType) & 8388608 /* Falsy */ ? getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2 /* Subtype */) : leftType; - if (operator === 74 /* BarBarEqualsToken */) { + if (operator === 75 /* BarBarEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_3; } case 60 /* QuestionQuestionToken */: - case 76 /* QuestionQuestionEqualsToken */: { + case 77 /* QuestionQuestionEqualsToken */: { var resultType_4 = getTypeFacts(leftType) & 262144 /* EQUndefinedOrNull */ ? getUnionType([getNonNullableType(leftType), rightType], 2 /* Subtype */) : leftType; - if (operator === 76 /* QuestionQuestionEqualsToken */) { + if (operator === 77 /* QuestionQuestionEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_4; } - case 62 /* EqualsToken */: + case 63 /* EqualsToken */: var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0 /* None */; checkAssignmentDeclaration(declKind, rightType); if (isAssignmentDeclaration(declKind)) { @@ -72007,7 +74637,7 @@ var ts; if (propType.symbol && propType.symbol.flags & 32 /* Class */) { var name = prop.escapedName; var symbol = resolveName(prop.valueDeclaration, name, 788968 /* Type */, undefined, name, /*isUse*/ false); - if (symbol && symbol.declarations.some(ts.isJSDocTypedefTag)) { + 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); } @@ -72016,7 +74646,7 @@ var ts; } } function isEvalNode(node) { - return node.kind === 78 /* Identifier */ && node.escapedText === "eval"; + return node.kind === 79 /* Identifier */ && node.escapedText === "eval"; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { @@ -72032,13 +74662,13 @@ var ts; function getSuggestedBooleanOperator(operator) { switch (operator) { case 51 /* BarToken */: - case 73 /* BarEqualsToken */: + case 74 /* BarEqualsToken */: return 56 /* BarBarToken */; case 52 /* CaretToken */: - case 77 /* CaretEqualsToken */: + case 78 /* CaretEqualsToken */: return 37 /* ExclamationEqualsEqualsToken */; case 50 /* AmpersandToken */: - case 72 /* AmpersandEqualsToken */: + case 73 /* AmpersandEqualsToken */: return 55 /* AmpersandAmpersandToken */; default: return undefined; @@ -72202,7 +74832,7 @@ var ts; } function checkConditionalExpression(node, checkMode) { var type = checkTruthinessExpression(node.condition); - checkTestingKnownTruthyCallableType(node.condition, type, node.whenTrue); + checkTestingKnownTruthyCallableOrAwaitableType(node.condition, type, node.whenTrue); var type1 = checkExpression(node.whenTrue, checkMode); var type2 = checkExpression(node.whenFalse, checkMode); return getUnionType([type1, type2], 2 /* Subtype */); @@ -72219,10 +74849,14 @@ var ts; texts.push(span.literal.text); types.push(isTypeAssignableTo(type, templateConstraintType) ? type : stringType); } - return getFreshTypeOfLiteralType(getTemplateLiteralType(texts, types)); + return isConstContext(node) || someType(getContextualType(node) || 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 */)); } function getContextNode(node) { - if (node.kind === 281 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { + if (node.kind === 283 /* 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; @@ -72238,7 +74872,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, 134220672 /* FreshableLiteral */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ? + var result = maybeTypeOfKind(type, 2944 /* Literal */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ? getRegularTypeOfLiteralType(type) : type; return result; } @@ -72271,13 +74905,13 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 206 /* TypeAssertionExpression */ || node.kind === 224 /* AsExpression */; + return node.kind === 208 /* TypeAssertionExpression */ || node.kind === 226 /* AsExpression */; } function checkDeclarationInitializer(declaration, contextualType) { var initializer = ts.getEffectiveInitializer(declaration); var type = getQuickTypeOfExpression(initializer) || (contextualType ? checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, 0 /* Normal */) : checkExpressionCached(initializer)); - return ts.isParameter(declaration) && declaration.name.kind === 197 /* ArrayBindingPattern */ && + return ts.isParameter(declaration) && declaration.name.kind === 199 /* ArrayBindingPattern */ && isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ? padTupleType(type, declaration.name) : type; } @@ -72287,7 +74921,7 @@ 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 === 198 /* BindingElement */ && e.dotDotDotToken)) { + if (i < patternElements.length - 1 || !(e.kind === 200 /* BindingElement */ && e.dotDotDotToken)) { elementTypes.push(!ts.isOmittedExpression(e) && hasDefaultValue(e) ? getTypeFromBindingElement(e, /*includePatternInType*/ false, /*reportErrors*/ false) : anyType); elementFlags.push(2 /* Optional */); if (!ts.isOmittedExpression(e) && !hasDefaultValue(e)) { @@ -72300,7 +74934,7 @@ var ts; function widenTypeInferredFromInitializer(declaration, type) { var widened = ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || ts.isDeclarationReadonly(declaration) ? type : getWidenedLiteralType(type); if (ts.isInJSFile(declaration)) { - if (widened.flags & 98304 /* Nullable */) { + if (isEmptyLiteralType(widened)) { reportImplicitAny(declaration, anyType); return anyType; } @@ -72322,7 +74956,7 @@ var ts; // 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, 134217856 /* StringLikeLiteral */) || + 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 */) || @@ -72330,7 +74964,7 @@ var ts; } // 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 & (134217856 /* StringLikeLiteral */ | 4194304 /* Index */ | 268435456 /* StringMapping */) && maybeTypeOfKind(candidateType, 134217856 /* StringLikeLiteral */) || + 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 */) || @@ -72354,7 +74988,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 === 158 /* ComputedPropertyName */) { + if (node.name.kind === 160 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); @@ -72365,7 +74999,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 === 158 /* ComputedPropertyName */) { + if (node.name.kind === 160 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -72492,7 +75126,7 @@ var ts; len--; var s = baseName.slice(0, len); for (var index = 1; true; index++) { - var augmentedName = (s + index); + var augmentedName = s + index; if (!hasTypeParameterByName(typeParameters, augmentedName)) { return augmentedName; } @@ -72541,7 +75175,7 @@ var ts; var 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 !== 105 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { + if (ts.isCallExpression(expr) && expr.expression.kind !== 106 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { var type = ts.isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) : getReturnTypeOfSingleNonGenericCallSignature(checkNonNullExpression(expr.expression)); if (type) { @@ -72552,7 +75186,7 @@ var ts; return getTypeFromTypeNode(expr.type); } else if (node.kind === 8 /* NumericLiteral */ || node.kind === 10 /* StringLiteral */ || - node.kind === 109 /* TrueKeyword */ || node.kind === 94 /* FalseKeyword */) { + node.kind === 110 /* TrueKeyword */ || node.kind === 95 /* FalseKeyword */) { return checkExpression(node); } return undefined; @@ -72583,7 +75217,7 @@ var ts; } } function checkExpression(node, checkMode, forceTuple) { - ts.tracing.push("check" /* Check */, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end }); var saveCurrentNode = currentNode; currentNode = node; instantiationCount = 0; @@ -72593,7 +75227,7 @@ var ts; checkConstEnumAccess(node, type); } currentNode = saveCurrentNode; - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return type; } function checkConstEnumAccess(node, type) { @@ -72601,11 +75235,11 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 201 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 202 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 78 /* Identifier */ || node.kind === 157 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 176 /* TypeQuery */ && node.parent.exprName === node)) || - (node.parent.kind === 270 /* ExportSpecifier */); // We allow reexporting const enums + var ok = (node.parent.kind === 203 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 204 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 79 /* Identifier */ || node.kind === 159 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 178 /* TypeQuery */ && node.parent.exprName === node)) || + (node.parent.kind === 272 /* 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); } @@ -72620,7 +75254,7 @@ var ts; function checkParenthesizedExpression(node, checkMode) { var tag = ts.isInJSFile(node) ? ts.getJSDocTypeTag(node) : undefined; if (tag) { - return checkAssertionWorker(tag, tag.typeExpression.type, node.expression, checkMode); + return checkAssertionWorker(tag.typeExpression.type, tag.typeExpression.type, node.expression, checkMode); } return checkExpression(node.expression, checkMode); } @@ -72630,20 +75264,20 @@ 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 221 /* ClassExpression */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 223 /* ClassExpression */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 78 /* Identifier */: - return checkIdentifier(node); - case 107 /* ThisKeyword */: + case 79 /* Identifier */: + return checkIdentifier(node, checkMode); + case 108 /* ThisKeyword */: return checkThisExpression(node); - case 105 /* SuperKeyword */: + case 106 /* SuperKeyword */: return checkSuperExpression(node); - case 103 /* NullKeyword */: + case 104 /* NullKeyword */: return nullWideningType; case 14 /* NoSubstitutionTemplateLiteral */: case 10 /* StringLiteral */: @@ -72654,82 +75288,82 @@ var ts; case 9 /* BigIntLiteral */: checkGrammarBigIntLiteral(node); return getFreshTypeOfLiteralType(getBigIntLiteralType(node)); - case 109 /* TrueKeyword */: + case 110 /* TrueKeyword */: return trueType; - case 94 /* FalseKeyword */: + case 95 /* FalseKeyword */: return falseType; - case 218 /* TemplateExpression */: + case 220 /* TemplateExpression */: return checkTemplateExpression(node); case 13 /* RegularExpressionLiteral */: return globalRegExpType; - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode, forceTuple); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 201 /* PropertyAccessExpression */: - return checkPropertyAccessExpression(node); - case 157 /* QualifiedName */: - return checkQualifiedName(node); - case 202 /* ElementAccessExpression */: - return checkIndexedAccess(node); - case 203 /* CallExpression */: - if (node.expression.kind === 99 /* ImportKeyword */) { + case 203 /* PropertyAccessExpression */: + return checkPropertyAccessExpression(node, checkMode); + case 159 /* QualifiedName */: + return checkQualifiedName(node, checkMode); + case 204 /* ElementAccessExpression */: + return checkIndexedAccess(node, checkMode); + case 205 /* CallExpression */: + if (node.expression.kind === 100 /* ImportKeyword */) { return checkImportCallExpression(node); } // falls through - case 204 /* NewExpression */: + case 206 /* NewExpression */: return checkCallExpression(node, checkMode); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: return checkClassExpression(node); - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 211 /* TypeOfExpression */: + case 213 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 206 /* TypeAssertionExpression */: - case 224 /* AsExpression */: + case 208 /* TypeAssertionExpression */: + case 226 /* AsExpression */: return checkAssertion(node); - case 225 /* NonNullExpression */: + case 227 /* NonNullExpression */: return checkNonNullAssertion(node); - case 226 /* MetaProperty */: + case 228 /* MetaProperty */: return checkMetaProperty(node); - case 210 /* DeleteExpression */: + case 212 /* DeleteExpression */: return checkDeleteExpression(node); - case 212 /* VoidExpression */: + case 214 /* VoidExpression */: return checkVoidExpression(node); - case 213 /* AwaitExpression */: + case 215 /* AwaitExpression */: return checkAwaitExpression(node); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 220 /* SpreadElement */: + case 222 /* SpreadElement */: return checkSpreadExpression(node, checkMode); - case 222 /* OmittedExpression */: + case 224 /* OmittedExpression */: return undefinedWideningType; - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: return checkYieldExpression(node); - case 227 /* SyntheticExpression */: + case 229 /* SyntheticExpression */: return checkSyntheticExpression(node); - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: return checkJsxExpression(node, checkMode); - case 273 /* JsxElement */: + case 275 /* JsxElement */: return checkJsxElement(node, checkMode); - case 274 /* JsxSelfClosingElement */: + case 276 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 277 /* JsxFragment */: + case 279 /* JsxFragment */: return checkJsxFragment(node); - case 281 /* JsxAttributes */: + case 283 /* JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 275 /* JsxOpeningElement */: + case 277 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -72765,11 +75399,11 @@ var ts; checkGrammarDecoratorsAndModifiers(node); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); - if (ts.hasSyntacticModifier(node, 92 /* ParameterPropertyModifier */)) { - if (!(func.kind === 166 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */)) { + if (!(func.kind === 168 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } - if (func.kind === 166 /* Constructor */ && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") { + if (func.kind === 168 /* Constructor */ && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") { error(node.name, ts.Diagnostics.constructor_cannot_be_used_as_a_parameter_property_name); } } @@ -72780,13 +75414,13 @@ var ts; if (func.parameters.indexOf(node) !== 0) { error(node, ts.Diagnostics.A_0_parameter_must_be_the_first_parameter, node.name.escapedText); } - if (func.kind === 166 /* Constructor */ || func.kind === 170 /* ConstructSignature */ || func.kind === 175 /* ConstructorType */) { + if (func.kind === 168 /* Constructor */ || func.kind === 172 /* ConstructSignature */ || func.kind === 177 /* ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } - if (func.kind === 209 /* ArrowFunction */) { + if (func.kind === 211 /* ArrowFunction */) { error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter); } - if (func.kind === 167 /* GetAccessor */ || func.kind === 168 /* SetAccessor */) { + if (func.kind === 169 /* GetAccessor */ || func.kind === 170 /* SetAccessor */) { error(node, ts.Diagnostics.get_and_set_accessors_cannot_declare_this_parameters); } } @@ -72844,13 +75478,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 209 /* ArrowFunction */: - case 169 /* CallSignature */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 174 /* FunctionType */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 211 /* ArrowFunction */: + case 171 /* CallSignature */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 176 /* FunctionType */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: var parent = node.parent; if (node === parent.type) { return parent; @@ -72864,11 +75498,11 @@ var ts; continue; } var name = element.name; - if (name.kind === 78 /* Identifier */ && name.escapedText === predicateVariableName) { + if (name.kind === 79 /* 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 === 197 /* ArrayBindingPattern */ || name.kind === 196 /* ObjectBindingPattern */) { + else if (name.kind === 199 /* ArrayBindingPattern */ || name.kind === 198 /* ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -72877,13 +75511,13 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 171 /* IndexSignature */) { + if (node.kind === 173 /* 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 === 174 /* FunctionType */ || node.kind === 251 /* FunctionDeclaration */ || node.kind === 175 /* ConstructorType */ || - node.kind === 169 /* CallSignature */ || node.kind === 166 /* Constructor */ || - node.kind === 170 /* ConstructSignature */) { + else if (node.kind === 176 /* FunctionType */ || node.kind === 253 /* FunctionDeclaration */ || node.kind === 177 /* ConstructorType */ || + node.kind === 171 /* CallSignature */ || node.kind === 168 /* Constructor */ || + node.kind === 172 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); @@ -72913,10 +75547,10 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 170 /* ConstructSignature */: + case 172 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 169 /* CallSignature */: + case 171 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -72946,7 +75580,7 @@ var ts; checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 171 /* IndexSignature */ && node.kind !== 308 /* JSDocFunctionType */) { + if (node.kind !== 173 /* IndexSignature */ && node.kind !== 311 /* JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } @@ -72958,7 +75592,7 @@ 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 === 166 /* Constructor */) { + if (member.kind === 168 /* 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)) { @@ -72970,25 +75604,27 @@ var ts; var isStatic = ts.hasSyntacticModifier(member, 32 /* Static */); var name = member.name; if (!name) { - return; + continue; } - var names = ts.isPrivateIdentifier(name) ? privateIdentifiers : + var isPrivate = ts.isPrivateIdentifier(name); + var privateStaticFlags = isPrivate && isStatic ? 16 /* PrivateStatic */ : 0; + var names = isPrivate ? privateIdentifiers : isStatic ? staticNames : instanceNames; var memberName = name && ts.getPropertyNameForPropertyNameNode(name); if (memberName) { switch (member.kind) { - case 167 /* GetAccessor */: - addName(names, name, memberName, 1 /* GetAccessor */); + case 169 /* GetAccessor */: + addName(names, name, memberName, 1 /* GetAccessor */ | privateStaticFlags); break; - case 168 /* SetAccessor */: - addName(names, name, memberName, 2 /* SetAccessor */); + case 170 /* SetAccessor */: + addName(names, name, memberName, 2 /* SetAccessor */ | privateStaticFlags); break; - case 163 /* PropertyDeclaration */: - addName(names, name, memberName, 3 /* GetOrSetAccessor */); + case 165 /* PropertyDeclaration */: + addName(names, name, memberName, 3 /* GetOrSetAccessor */ | privateStaticFlags); break; - case 165 /* MethodDeclaration */: - addName(names, name, memberName, 8 /* Method */); + case 167 /* MethodDeclaration */: + addName(names, name, memberName, 8 /* Method */ | privateStaticFlags); break; } } @@ -72997,16 +75633,25 @@ var ts; function addName(names, location, name, meaning) { var prev = names.get(name); if (prev) { - if (prev & 8 /* Method */) { - if (meaning !== 8 /* Method */) { - error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); - } - } - else if (prev & meaning) { - error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); + // For private identifiers, do not allow mixing of static and instance members with the same name + if ((prev & 16 /* PrivateStatic */) !== (meaning & 16 /* PrivateStatic */)) { + error(location, ts.Diagnostics.Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name, ts.getTextOfNode(location)); } else { - names.set(name, prev | meaning); + var prevIsMethod = !!(prev & 8 /* Method */); + var isMethod = !!(meaning & 8 /* 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 */) { + error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); + } + else { + names.set(name, prev | meaning); + } } } else { @@ -73050,7 +75695,7 @@ 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 === 162 /* PropertySignature */) { + if (member.kind === 164 /* PropertySignature */) { var memberName = void 0; var name = member.name; switch (name.kind) { @@ -73058,7 +75703,7 @@ var ts; case 8 /* NumericLiteral */: memberName = name.text; break; - case 78 /* Identifier */: + case 79 /* Identifier */: memberName = ts.idText(name); break; default: @@ -73075,11 +75720,11 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 253 /* InterfaceDeclaration */) { + if (node.kind === 255 /* 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 - if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { + if (nodeSymbol.declarations && nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; } } @@ -73087,7 +75732,7 @@ var ts; // 3.7.4: An object type can contain at most one string index signature and one numeric index signature. // 8.5: A class declaration can have at most one string index member declaration and one numeric index member declaration var indexSymbol = getIndexSymbol(getSymbolOfNode(node)); - if (indexSymbol) { + if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) { var seenNumericIndexer = false; var seenStringIndexer = false; for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -73095,7 +75740,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 147 /* StringKeyword */: + case 148 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -73103,7 +75748,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 144 /* NumberKeyword */: + case 145 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -73121,11 +75766,13 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && !checkGrammarProperty(node)) checkGrammarComputedPropertyName(node.name); checkVariableLikeDeclaration(node); - // Private class fields transformation relies on WeakMaps. - if (ts.isPrivateIdentifier(node.name) && languageVersion < 99 /* ESNext */) { - for (var lexicalScope = ts.getEnclosingBlockScopeContainer(node); !!lexicalScope; lexicalScope = ts.getEnclosingBlockScopeContainer(lexicalScope)) { - getNodeLinks(lexicalScope).flags |= 67108864 /* ContainsClassWithPrivateIdentifiers */; - } + setNodeLinksForPrivateIdentifierScope(node); + if (ts.isPrivateIdentifier(node.name) && ts.hasStaticModifier(node) && node.initializer && languageVersion === 99 /* ESNext */ && !compilerOptions.useDefineForClassFields) { + error(node.initializer, ts.Diagnostics.Static_fields_with_private_names_can_t_have_initializers_when_the_useDefineForClassFields_flag_is_not_specified_with_a_target_of_esnext_Consider_adding_the_useDefineForClassFields_flag); + } + // property signatures already report "initializer not allowed in ambient context" elsewhere + if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 165 /* PropertyDeclaration */ && node.initializer) { + error(node, ts.Diagnostics.Property_0_cannot_have_an_initializer_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } function checkPropertySignature(node) { @@ -73138,16 +75785,34 @@ var ts; // Grammar checking if (!checkGrammarMethod(node)) checkGrammarComputedPropertyName(node.name); - if (ts.isPrivateIdentifier(node.name)) { - error(node, ts.Diagnostics.A_method_cannot_be_named_with_a_private_identifier); - } // Grammar checking for modifiers is done inside the function checkGrammarFunctionLikeDeclaration checkFunctionOrMethodDeclaration(node); - // Abstract methods cannot have an implementation. - // Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node. - if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 165 /* MethodDeclaration */ && node.body) { + // method signatures already report "implementation not allowed in ambient context" elsewhere + if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 167 /* 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 + if (ts.isPrivateIdentifier(node.name) && !ts.getContainingClass(node)) { + error(node, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); + } + setNodeLinksForPrivateIdentifierScope(node); + } + function setNodeLinksForPrivateIdentifierScope(node) { + if (ts.isPrivateIdentifier(node.name) && languageVersion < 99 /* ESNext */) { + for (var lexicalScope = ts.getEnclosingBlockScopeContainer(node); !!lexicalScope; lexicalScope = ts.getEnclosingBlockScopeContainer(lexicalScope)) { + getNodeLinks(lexicalScope).flags |= 67108864 /* 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 + // to transform private elements. + if (ts.isClassExpression(node.parent)) { + var enclosingIterationStatement = getEnclosingIterationStatement(node.parent); + if (enclosingIterationStatement) { + getNodeLinks(node.name).flags |= 524288 /* BlockScopedBindingInLoop */; + getNodeLinks(enclosingIterationStatement).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */; + } + } + } } function checkConstructorDeclaration(node) { // Grammar check on signature of constructor and modifier of the constructor is done in checkSignatureDeclaration function. @@ -73170,10 +75835,10 @@ var ts; return; } function isInstancePropertyWithInitializerOrPrivateIdentifierProperty(n) { - if (ts.isPrivateIdentifierPropertyDeclaration(n)) { + if (ts.isPrivateIdentifierClassElementDeclaration(n)) { return true; } - return n.kind === 163 /* PropertyDeclaration */ && + return n.kind === 165 /* PropertyDeclaration */ && !ts.hasSyntacticModifier(n, 32 /* Static */) && !!n.initializer; } @@ -73194,9 +75859,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 superCallShouldBeFirst = (compilerOptions.target !== 99 /* ESNext */ || !compilerOptions.useDefineForClassFields) && + var superCallShouldBeFirst = (compilerOptions.target !== 99 /* ESNext */ || !useDefineForClassFields) && (ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) || - ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 92 /* ParameterPropertyModifier */); })); + ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476 /* ParameterPropertyModifier */); })); // Skip past any prologue directives to find the first statement // to ensure that it was a super call. if (superCallShouldBeFirst) { @@ -73204,7 +75869,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_4 = statements; _i < statements_4.length; _i++) { var statement = statements_4[_i]; - if (statement.kind === 233 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 235 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -73229,7 +75894,7 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 167 /* GetAccessor */) { + if (node.kind === 169 /* GetAccessor */) { if (!(node.flags & 8388608 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* HasImplicitReturn */)) { if (!(node.flags & 512 /* HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); @@ -73239,45 +75904,42 @@ 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 === 158 /* ComputedPropertyName */) { + if (node.name.kind === 160 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } - if (ts.isPrivateIdentifier(node.name)) { - error(node.name, ts.Diagnostics.An_accessor_cannot_be_named_with_a_private_identifier); - } - if (!hasNonBindableDynamicName(node)) { + if (hasBindableName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. - var otherKind = node.kind === 167 /* GetAccessor */ ? 168 /* SetAccessor */ : 167 /* GetAccessor */; - var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); - if (otherAccessor) { - var nodeFlags = ts.getEffectiveModifierFlags(node); - var otherFlags = ts.getEffectiveModifierFlags(otherAccessor); - if ((nodeFlags & 28 /* AccessibilityModifier */) !== (otherFlags & 28 /* AccessibilityModifier */)) { - error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); + var symbol = getSymbolOfNode(node); + var getter = ts.getDeclarationOfKind(symbol, 169 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 170 /* SetAccessor */); + if (getter && setter && !(getNodeCheckFlags(getter) & 1 /* TypeChecked */)) { + getNodeLinks(getter).flags |= 1 /* TypeChecked */; + var getterFlags = ts.getEffectiveModifierFlags(getter); + var setterFlags = ts.getEffectiveModifierFlags(setter); + if ((getterFlags & 128 /* Abstract */) !== (setterFlags & 128 /* 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 */))) { + 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); } - if ((nodeFlags & 128 /* Abstract */) !== (otherFlags & 128 /* Abstract */)) { - error(node.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); + var getterType = getAnnotatedAccessorType(getter); + var setterType = getAnnotatedAccessorType(setter); + if (getterType && setterType) { + checkTypeAssignableTo(getterType, setterType, getter, ts.Diagnostics.The_return_type_of_a_get_accessor_must_be_assignable_to_its_set_accessor_type); } - // TypeScript 1.0 spec (April 2014): 4.5 - // If both accessors include type annotations, the specified types must be identical. - checkAccessorDeclarationTypesIdentical(node, otherAccessor, getAnnotatedAccessorType, ts.Diagnostics.get_and_set_accessor_must_have_the_same_type); - checkAccessorDeclarationTypesIdentical(node, otherAccessor, getThisTypeOfDeclaration, ts.Diagnostics.get_and_set_accessor_must_have_the_same_this_type); } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 167 /* GetAccessor */) { + if (node.kind === 169 /* GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } checkSourceElement(node.body); - } - function checkAccessorDeclarationTypesIdentical(first, second, getAnnotatedType, message) { - var firstType = getAnnotatedType(first); - var secondType = getAnnotatedType(second); - if (firstType && secondType && !isTypeIdenticalTo(firstType, secondType)) { - error(first, message); - } + setNodeLinksForPrivateIdentifierScope(node); } function checkMissingDeclaration(node) { checkDecorators(node); @@ -73314,7 +75976,7 @@ var ts; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 173 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 175 /* 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); @@ -73329,7 +75991,7 @@ var ts; var symbol = getNodeLinks(node).resolvedSymbol; if (symbol) { if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 134217728 /* Deprecated */); })) { - errorOrSuggestion(/* isError */ false, getDeprecatedSuggestionNode(node), ts.Diagnostics._0_is_deprecated, symbol.escapedName); + addDeprecatedSuggestion(getDeprecatedSuggestionNode(node), symbol.declarations, symbol.escapedName); } if (type.flags & 32 /* Enum */ && symbol.flags & 8 /* EnumMember */) { error(node, ts.Diagnostics.Enum_type_0_has_members_with_initializers_that_are_not_literals, typeToString(type)); @@ -73367,7 +76029,7 @@ 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 !== 192 /* NamedTupleMember */ && hasNamedElement) { + if (e.kind !== 194 /* NamedTupleMember */ && hasNamedElement) { grammarErrorOnNode(e, ts.Diagnostics.Tuple_members_must_all_have_names_or_all_not_have_names); break; } @@ -73416,7 +76078,7 @@ var ts; var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, /*stringsOnly*/ false))) { - if (accessNode.kind === 202 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 204 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && ts.getObjectFlags(objectType) & 32 /* Mapped */ && getMappedTypeModifiers(objectType) & 1 /* IncludeReadonly */) { error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); } @@ -73474,7 +76136,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 184 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 186 /* 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); @@ -73497,25 +76159,25 @@ var ts; if (node.dotDotDotToken && node.questionToken) { grammarErrorOnNode(node, ts.Diagnostics.A_tuple_member_cannot_be_both_optional_and_rest); } - if (node.type.kind === 180 /* OptionalType */) { + if (node.type.kind === 182 /* 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 === 181 /* RestType */) { + if (node.type.kind === 183 /* 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.isPrivateIdentifierPropertyDeclaration(node)) && !!(node.flags & 8388608 /* Ambient */); + return (ts.hasEffectiveModifier(node, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 8388608 /* 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 !== 253 /* InterfaceDeclaration */ && - n.parent.kind !== 252 /* ClassDeclaration */ && - n.parent.kind !== 221 /* ClassExpression */ && + if (n.parent.kind !== 255 /* InterfaceDeclaration */ && + n.parent.kind !== 254 /* ClassDeclaration */ && + n.parent.kind !== 223 /* ClassExpression */ && n.flags & 8388608 /* Ambient */) { if (!(flags & 2 /* 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 @@ -73611,7 +76273,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 === 165 /* MethodDeclaration */ || node.kind === 164 /* MethodSignature */) && + var reportError = (node.kind === 167 /* MethodDeclaration */ || node.kind === 166 /* MethodSignature */) && ts.hasSyntacticModifier(node, 32 /* Static */) !== ts.hasSyntacticModifier(subsequentNode, 32 /* Static */); // we can get here in two cases // 1. mixed static and instance class members @@ -73648,55 +76310,57 @@ var ts; var multipleConstructorImplementation = false; var hasNonAmbientClass = false; var functionDeclarations = []; - for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { - var current = declarations_4[_i]; - var node = current; - var inAmbientContext = node.flags & 8388608 /* Ambient */; - var inAmbientContextOrInterface = node.parent && (node.parent.kind === 253 /* InterfaceDeclaration */ || node.parent.kind === 177 /* TypeLiteral */) || inAmbientContext; - if (inAmbientContextOrInterface) { - // check if declarations are consecutive only if they are non-ambient - // 1. ambient declarations can be interleaved - // i.e. this is legal - // declare function foo(); - // declare function bar(); - // declare function foo(); - // 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 === 252 /* ClassDeclaration */ || node.kind === 221 /* ClassExpression */) && !inAmbientContext) { - hasNonAmbientClass = true; - } - if (node.kind === 251 /* FunctionDeclaration */ || node.kind === 165 /* MethodDeclaration */ || node.kind === 164 /* MethodSignature */ || node.kind === 166 /* Constructor */) { - functionDeclarations.push(node); - var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); - someNodeFlags |= currentNodeFlags; - allNodeFlags &= currentNodeFlags; - someHaveQuestionToken = someHaveQuestionToken || ts.hasQuestionToken(node); - allHaveQuestionToken = allHaveQuestionToken && ts.hasQuestionToken(node); - var bodyIsPresent = ts.nodeIsPresent(node.body); - if (bodyIsPresent && bodyDeclaration) { - if (isConstructor) { - multipleConstructorImplementation = true; + if (declarations) { + for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { + var current = declarations_4[_i]; + var node = current; + var inAmbientContext = node.flags & 8388608 /* Ambient */; + var inAmbientContextOrInterface = node.parent && (node.parent.kind === 255 /* InterfaceDeclaration */ || node.parent.kind === 179 /* TypeLiteral */) || inAmbientContext; + if (inAmbientContextOrInterface) { + // check if declarations are consecutive only if they are non-ambient + // 1. ambient declarations can be interleaved + // i.e. this is legal + // declare function foo(); + // declare function bar(); + // declare function foo(); + // 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 === 254 /* ClassDeclaration */ || node.kind === 223 /* ClassExpression */) && !inAmbientContext) { + hasNonAmbientClass = true; + } + if (node.kind === 253 /* FunctionDeclaration */ || node.kind === 167 /* MethodDeclaration */ || node.kind === 166 /* MethodSignature */ || node.kind === 168 /* Constructor */) { + functionDeclarations.push(node); + var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); + someNodeFlags |= currentNodeFlags; + allNodeFlags &= currentNodeFlags; + someHaveQuestionToken = someHaveQuestionToken || ts.hasQuestionToken(node); + allHaveQuestionToken = allHaveQuestionToken && ts.hasQuestionToken(node); + var bodyIsPresent = ts.nodeIsPresent(node.body); + if (bodyIsPresent && bodyDeclaration) { + if (isConstructor) { + multipleConstructorImplementation = true; + } + else { + duplicateFunctionDeclaration = true; + } + } + else if ((previousDeclaration === null || previousDeclaration === void 0 ? void 0 : previousDeclaration.parent) === node.parent && previousDeclaration.end !== node.pos) { + reportImplementationExpectedError(previousDeclaration); + } + if (bodyIsPresent) { + if (!bodyDeclaration) { + bodyDeclaration = node; + } } else { - duplicateFunctionDeclaration = true; + hasOverloads = true; } - } - else if ((previousDeclaration === null || previousDeclaration === void 0 ? void 0 : previousDeclaration.parent) === node.parent && previousDeclaration.end !== node.pos) { - reportImplementationExpectedError(previousDeclaration); - } - if (bodyIsPresent) { - if (!bodyDeclaration) { - bodyDeclaration = node; + previousDeclaration = node; + if (!inAmbientContextOrInterface) { + lastSeenNonAmbientDeclaration = node; } } - else { - hasOverloads = true; - } - previousDeclaration = node; - if (!inAmbientContextOrInterface) { - lastSeenNonAmbientDeclaration = node; - } } } if (multipleConstructorImplementation) { @@ -73709,13 +76373,18 @@ var ts; error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Duplicate_function_implementation); }); } - if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 /* Function */) { - // A non-ambient class cannot be an implementation for a non-constructor function/class merge - // TODO: The below just replicates our older error from when classes and functions were - // entirely unable to merge - a more helpful message like "Class declaration cannot implement overload list" - // might be warranted. :shrug: + if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 /* Function */ && declarations) { + var relatedDiagnostics_1 = ts.filter(declarations, function (d) { return d.kind === 254 /* ClassDeclaration */; }) + .map(function (d) { return ts.createDiagnosticForNode(d, ts.Diagnostics.Consider_adding_a_declare_modifier_to_this_class); }); ts.forEach(declarations, function (declaration) { - addDuplicateDeclarationError(declaration, ts.Diagnostics.Duplicate_identifier_0, ts.symbolName(symbol), declarations); + var diagnostic = declaration.kind === 254 /* ClassDeclaration */ + ? ts.Diagnostics.Class_declaration_cannot_implement_overload_list_for_0 + : declaration.kind === 253 /* FunctionDeclaration */ + ? ts.Diagnostics.Function_with_bodies_can_only_merge_with_classes_that_are_ambient + : undefined; + if (diagnostic) { + ts.addRelatedInfo.apply(void 0, __spreadArray([error(ts.getNameOfDeclaration(declaration) || declaration, diagnostic, ts.symbolName(symbol))], relatedDiagnostics_1)); + } }); } // Abstract methods can't have an implementation -- in particular, they don't need one. @@ -73724,8 +76393,10 @@ var ts; reportImplementationExpectedError(lastSeenNonAmbientDeclaration); } if (hasOverloads) { - checkFlagAgreementBetweenOverloads(declarations, bodyDeclaration, flagsToCheck, someNodeFlags, allNodeFlags); - checkQuestionTokenAgreementBetweenOverloads(declarations, bodyDeclaration, someHaveQuestionToken, allHaveQuestionToken); + if (declarations) { + checkFlagAgreementBetweenOverloads(declarations, bodyDeclaration, flagsToCheck, someNodeFlags, allNodeFlags); + checkQuestionTokenAgreementBetweenOverloads(declarations, bodyDeclaration, someHaveQuestionToken, allHaveQuestionToken); + } if (bodyDeclaration) { var signatures = getSignaturesOfSymbol(symbol); var bodySignature = getSignatureFromDeclaration(bodyDeclaration); @@ -73799,44 +76470,47 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: // A jsdoc typedef and callback are, by definition, type aliases. // falls through - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 325 /* JSDocEnumTag */: + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + case 333 /* JSDocEnumTag */: return 2 /* ExportType */; - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4 /* ExportNamespace */ | 1 /* ExportValue */ : 4 /* ExportNamespace */; - case 252 /* ClassDeclaration */: - case 255 /* EnumDeclaration */: - case 291 /* EnumMember */: + case 254 /* ClassDeclaration */: + case 257 /* EnumDeclaration */: + case 293 /* EnumMember */: return 2 /* ExportType */ | 1 /* ExportValue */; - case 297 /* SourceFile */: + case 299 /* SourceFile */: return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: + case 218 /* 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(d.expression)) { + if (!ts.isEntityNameExpression(expression)) { return 1 /* ExportValue */; } - d = d.expression; + d = expression; // The below options all declare an Alias, which is allowed to merge with other values within the importing module. // falls through - case 260 /* ImportEqualsDeclaration */: - case 263 /* NamespaceImport */: - case 262 /* ImportClause */: + case 262 /* ImportEqualsDeclaration */: + case 265 /* NamespaceImport */: + case 264 /* ImportClause */: var result_12 = 0 /* None */; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_12 |= getDeclarationSpaces(d); }); return result_12; - case 249 /* VariableDeclaration */: - case 198 /* BindingElement */: - case 251 /* FunctionDeclaration */: - case 265 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 - case 78 /* Identifier */: // https://github.com/microsoft/TypeScript/issues/36098 + case 251 /* VariableDeclaration */: + case 200 /* BindingElement */: + case 253 /* FunctionDeclaration */: + case 267 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 79 /* 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) @@ -74088,7 +76762,7 @@ var ts; var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* Value */, /*ignoreErrors*/ true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; if (promiseConstructorType === errorType) { - if (promiseConstructorName.kind === 78 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { + if (promiseConstructorName.kind === 79 /* 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 { @@ -74128,24 +76802,24 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 160 /* Parameter */: + case 162 /* Parameter */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages( /*details*/ undefined, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages( /*details*/ undefined, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -74166,7 +76840,7 @@ var ts; if (!typeName) return; var rootName = ts.getFirstIdentifier(typeName); - var meaning = (typeName.kind === 78 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; + var meaning = (typeName.kind === 79 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isRefernce*/ true); if (rootSymbol && rootSymbol.flags & 2097152 /* Alias */ @@ -74192,15 +76866,15 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 183 /* IntersectionType */: - case 182 /* UnionType */: + case 185 /* IntersectionType */: + case 184 /* UnionType */: return getEntityNameForDecoratorMetadataFromTypeList(node.types); - case 184 /* ConditionalType */: + case 186 /* ConditionalType */: return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]); - case 186 /* ParenthesizedType */: - case 192 /* NamedTupleMember */: + case 188 /* ParenthesizedType */: + case 194 /* NamedTupleMember */: return getEntityNameForDecoratorMetadata(node.type); - case 173 /* TypeReference */: + case 175 /* TypeReference */: return node.typeName; } } @@ -74209,13 +76883,13 @@ var ts; var commonEntityName; for (var _i = 0, types_23 = types; _i < types_23.length; _i++) { var typeNode = types_23[_i]; - while (typeNode.kind === 186 /* ParenthesizedType */ || typeNode.kind === 192 /* NamedTupleMember */) { + while (typeNode.kind === 188 /* ParenthesizedType */ || typeNode.kind === 194 /* NamedTupleMember */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 141 /* NeverKeyword */) { + if (typeNode.kind === 142 /* NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 191 /* LiteralType */ && typeNode.literal.kind === 103 /* NullKeyword */ || typeNode.kind === 150 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 193 /* LiteralType */ && typeNode.literal.kind === 104 /* NullKeyword */ || typeNode.kind === 151 /* 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); @@ -74261,14 +76935,14 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 160 /* Parameter */) { + if (node.kind === 162 /* Parameter */) { checkExternalEmitHelpers(firstDecorator, 32 /* Param */); } if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16 /* 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 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -74277,23 +76951,23 @@ var ts; } } break; - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - var otherKind = node.kind === 167 /* GetAccessor */ ? 168 /* SetAccessor */ : 167 /* GetAccessor */; + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + var otherKind = node.kind === 169 /* GetAccessor */ ? 170 /* SetAccessor */ : 169 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); break; - case 165 /* MethodDeclaration */: + case 167 /* 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 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 160 /* Parameter */: + case 162 /* Parameter */: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -74356,7 +77030,7 @@ var ts; else if (ts.findLast(ts.getJSDocTags(decl), ts.isJSDocParameterTag) === node && node.typeExpression && node.typeExpression.type && !isArrayType(getTypeFromTypeNode(node.typeExpression.type))) { - error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 157 /* QualifiedName */ ? node.name.right : node.name)); + error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 159 /* QualifiedName */ ? node.name.right : node.name)); } } } @@ -74398,27 +77072,28 @@ var ts; } function getIdentifierFromEntityNameExpression(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return node; - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return node.name; default: return undefined; } } function checkFunctionOrMethodDeclaration(node) { + var _a; checkDecorators(node); checkSignatureDeclaration(node); var functionFlags = ts.getFunctionFlags(node); // 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 === 158 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 160 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); } - if (!hasNonBindableDynamicName(node)) { + if (hasBindableName(node)) { // first we want to check the local symbol that contain this declaration // - if node.localSymbol !== undefined - this is current declaration is exported and localSymbol points to the local symbol // - if node.localSymbol === undefined - this node is non-exported so we can just pick the result of getSymbolOfNode @@ -74427,7 +77102,7 @@ var ts; // Since the javascript won't do semantic analysis like typescript, // if the javascript file comes before the typescript file and both contain same name functions, // checkFunctionOrConstructorSymbol wouldn't be called if we didnt ignore javascript function. - var firstDeclaration = ts.find(localSymbol.declarations, + 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 & 131072 /* JavaScriptFile */); }); // Only type check the symbol once @@ -74439,7 +77114,7 @@ var ts; checkFunctionOrConstructorSymbol(symbol); } } - var body = node.kind === 164 /* MethodSignature */ ? undefined : node.body; + var body = node.kind === 166 /* MethodSignature */ ? undefined : node.body; checkSourceElement(body); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node)); if (produceDiagnostics && !ts.getEffectiveReturnTypeNode(node)) { @@ -74481,42 +77156,42 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 297 /* SourceFile */: - case 256 /* ModuleDeclaration */: - case 230 /* Block */: - case 258 /* CaseBlock */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: + case 299 /* SourceFile */: + case 258 /* ModuleDeclaration */: + case 232 /* Block */: + case 260 /* CaseBlock */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 166 /* Constructor */: - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 168 /* Constructor */: + case 210 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 211 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: if (node.body) { // Don't report unused parameters in overloads checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 164 /* MethodSignature */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 254 /* TypeAliasDeclaration */: - case 253 /* InterfaceDeclaration */: + case 166 /* MethodSignature */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: + case 256 /* TypeAliasDeclaration */: + case 255 /* InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 185 /* InferType */: + case 187 /* InferType */: checkUnusedInferTypeParameter(node, addDiagnostic); break; default: @@ -74536,11 +77211,11 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 165 /* MethodDeclaration */: - case 163 /* PropertyDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - if (member.kind === 168 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { + case 167 /* MethodDeclaration */: + case 165 /* PropertyDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + if (member.kind === 170 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { // Already would have reported an error on the getter. break; } @@ -74551,7 +77226,7 @@ var ts; addDiagnostic(member, 0 /* Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); } break; - case 166 /* Constructor */: + case 168 /* 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 */)) { @@ -74559,8 +77234,8 @@ var ts; } } break; - case 171 /* IndexSignature */: - case 229 /* SemicolonClassElement */: + case 173 /* IndexSignature */: + case 231 /* SemicolonClassElement */: // Can't be private break; default: @@ -74577,7 +77252,8 @@ var ts; function checkUnusedTypeParameters(node, addDiagnostic) { // Only report errors on the last declaration for the type parameter container; // this ensures that all uses have been accounted for. - if (ts.last(getSymbolOfNode(node).declarations) !== node) + var declarations = getSymbolOfNode(node).declarations; + if (!declarations || ts.last(declarations) !== node) return; var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); var seenParentsWithEveryUnused = new ts.Set(); @@ -74587,7 +77263,7 @@ var ts; continue; var name = ts.idText(typeParameter.name); var parent = typeParameter.parent; - if (parent.kind !== 185 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { + if (parent.kind !== 187 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { if (ts.tryAddToSet(seenParentsWithEveryUnused, parent)) { var sourceFile = ts.getSourceFileOfNode(parent); var range = ts.isJSDocTemplateTag(parent) @@ -74596,12 +77272,14 @@ var ts; // Include the `<>` in the error message : ts.rangeOfTypeParameters(sourceFile, parent.typeParameters); var only = parent.typeParameters.length === 1; + //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)); } } 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)); } } @@ -74623,11 +77301,15 @@ var ts; return ts.tryCast(ts.getRootDeclaration(node), ts.isParameter); } function isValidUnusedLocalDeclaration(declaration) { - if (ts.isBindingElement(declaration) && isIdentifierThatStartsWithUnderscore(declaration.name)) { - return !!ts.findAncestor(declaration.parent, function (ancestor) { - return ts.isArrayBindingPattern(ancestor) || ts.isVariableDeclaration(ancestor) || ts.isVariableDeclarationList(ancestor) ? false : - ts.isForOfStatement(ancestor) ? true : "quit"; - }); + if (ts.isBindingElement(declaration)) { + if (ts.isObjectBindingPattern(declaration.parent)) { + /** + * ignore starts with underscore names _ + * const { a: _a } = { a: 1 } + */ + return !!(declaration.propertyName && isIdentifierThatStartsWithUnderscore(declaration.name)); + } + return isIdentifierThatStartsWithUnderscore(declaration.name); } return ts.isAmbientModule(declaration) || (ts.isVariableDeclaration(declaration) && ts.isForInOrOfStatement(declaration.parent.parent) || isImportedDeclaration(declaration)) && isIdentifierThatStartsWithUnderscore(declaration.name); @@ -74643,39 +77325,41 @@ var ts; if (local.flags & 262144 /* TypeParameter */ ? !(local.flags & 3 /* Variable */ && !(local.isReferenced & 3 /* Variable */)) : local.isReferenced || local.exportSymbol) { return; } - for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (isValidUnusedLocalDeclaration(declaration)) { - continue; - } - if (isImportedDeclaration(declaration)) { - addToGroup(unusedImports, importClauseFromImported(declaration), declaration, getNodeId); - } - else if (ts.isBindingElement(declaration) && ts.isObjectBindingPattern(declaration.parent)) { - // In `{ a, ...b }, `a` is considered used since it removes a property from `b`. `b` may still be unused though. - var lastElement = ts.last(declaration.parent.elements); - if (declaration === lastElement || !ts.last(declaration.parent.elements).dotDotDotToken) { - addToGroup(unusedDestructures, declaration.parent, declaration, getNodeId); + if (local.declarations) { + for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (isValidUnusedLocalDeclaration(declaration)) { + continue; } - } - else if (ts.isVariableDeclaration(declaration)) { - addToGroup(unusedVariables, declaration.parent, declaration, getNodeId); - } - else { - var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); - var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration); - if (parameter && name) { - if (!ts.isParameterPropertyDeclaration(parameter, parameter.parent) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { - if (ts.isBindingElement(declaration) && ts.isArrayBindingPattern(declaration.parent)) { - 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))); - } + if (isImportedDeclaration(declaration)) { + addToGroup(unusedImports, importClauseFromImported(declaration), declaration, getNodeId); + } + else if (ts.isBindingElement(declaration) && ts.isObjectBindingPattern(declaration.parent)) { + // In `{ a, ...b }, `a` is considered used since it removes a property from `b`. `b` may still be unused though. + var lastElement = ts.last(declaration.parent.elements); + if (declaration === lastElement || !ts.last(declaration.parent.elements).dotDotDotToken) { + addToGroup(unusedDestructures, declaration.parent, declaration, getNodeId); } } + else if (ts.isVariableDeclaration(declaration)) { + addToGroup(unusedVariables, declaration.parent, declaration, getNodeId); + } else { - errorUnusedLocal(declaration, ts.symbolName(local), addDiagnostic); + var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); + var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration); + if (parameter && name) { + if (!ts.isParameterPropertyDeclaration(parameter, parameter.parent) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { + if (ts.isBindingElement(declaration) && ts.isArrayBindingPattern(declaration.parent)) { + 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))); + } + } + } + else { + errorUnusedLocal(declaration, ts.symbolName(local), addDiagnostic); + } } } } @@ -74685,7 +77369,7 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 263 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 265 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { addDiagnostic(importDecl, 0 /* Local */, unuseds.length === 1 @@ -74703,7 +77387,7 @@ var ts; var bindingPattern = _a[0], bindingElements = _a[1]; var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* Parameter */ : 0 /* Local */; if (bindingPattern.elements.length === bindingElements.length) { - if (bindingElements.length === 1 && bindingPattern.parent.kind === 249 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 250 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 251 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 252 /* VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -74724,7 +77408,7 @@ var ts; if (declarationList.declarations.length === declarations.length) { addDiagnostic(declarationList, 0 /* 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 === 232 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 234 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { @@ -74736,24 +77420,24 @@ var ts; } function bindingNameText(name) { switch (name.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return ts.idText(name); - case 197 /* ArrayBindingPattern */: - case 196 /* ObjectBindingPattern */: + case 199 /* ArrayBindingPattern */: + case 198 /* ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 262 /* ImportClause */ || node.kind === 265 /* ImportSpecifier */ || node.kind === 263 /* NamespaceImport */; + return node.kind === 264 /* ImportClause */ || node.kind === 267 /* ImportSpecifier */ || node.kind === 265 /* NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 262 /* ImportClause */ ? decl : decl.kind === 263 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 264 /* ImportClause */ ? decl : decl.kind === 265 /* NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 230 /* Block */) { + if (node.kind === 232 /* Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -74783,12 +77467,12 @@ var ts; if (!(identifier && identifier.escapedText === name)) { return false; } - if (node.kind === 163 /* PropertyDeclaration */ || - node.kind === 162 /* PropertySignature */ || - node.kind === 165 /* MethodDeclaration */ || - node.kind === 164 /* MethodSignature */ || - node.kind === 167 /* GetAccessor */ || - node.kind === 168 /* SetAccessor */) { + if (node.kind === 165 /* PropertyDeclaration */ || + node.kind === 164 /* PropertySignature */ || + node.kind === 167 /* MethodDeclaration */ || + node.kind === 166 /* MethodSignature */ || + node.kind === 169 /* GetAccessor */ || + node.kind === 170 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -74797,7 +77481,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 160 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 162 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -74807,7 +77491,7 @@ var ts; function checkIfThisIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 78 /* Identifier */; + var isDeclaration_1 = node.kind !== 79 /* Identifier */; if (isDeclaration_1) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -74822,7 +77506,7 @@ var ts; function checkIfNewTargetIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 8 /* CaptureNewTarget */) { - var isDeclaration_2 = node.kind !== 78 /* Identifier */; + var isDeclaration_2 = node.kind !== 79 /* 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); } @@ -74834,10 +77518,11 @@ var ts; return false; }); } - function checkWeakMapCollision(node) { + function checkWeakMapSetCollision(node) { var enclosingBlockScope = ts.getEnclosingBlockScopeContainer(node); if (getNodeCheckFlags(enclosingBlockScope) & 67108864 /* ContainsClassWithPrivateIdentifiers */) { - errorSkippedOn("noEmit", node, ts.Diagnostics.Compiler_reserves_name_0_when_emitting_private_identifier_downlevel, "WeakMap"); + 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 checkCollisionWithRequireExportsInGeneratedCode(node, name) { @@ -74854,7 +77539,7 @@ var ts; } // 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 === 297 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 299 /* 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)); } @@ -74869,7 +77554,7 @@ var ts; } // 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 === 297 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* HasAsyncFunctions */) { + if (parent.kind === 299 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* 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)); } @@ -74904,7 +77589,7 @@ var ts; // 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 === 249 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 251 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -74916,17 +77601,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 250 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 232 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 252 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 234 /* 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 === 230 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 257 /* ModuleBlock */ || - container.kind === 256 /* ModuleDeclaration */ || - container.kind === 297 /* SourceFile */); + (container.kind === 232 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 259 /* ModuleBlock */ || + container.kind === 258 /* ModuleDeclaration */ || + container.kind === 299 /* 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 @@ -74957,18 +77642,18 @@ 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 === 158 /* ComputedPropertyName */) { + if (node.name.kind === 160 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 198 /* BindingElement */) { - if (node.parent.kind === 196 /* ObjectBindingPattern */ && languageVersion < 99 /* ESNext */) { + if (ts.isBindingElement(node)) { + if (ts.isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ES2018 */) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 158 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 160 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access @@ -74981,15 +77666,15 @@ var ts; var nameText = getPropertyNameFromType(exprType); var property = getPropertyOfType(parentType, nameText); if (property) { - markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined, /*isThisAccess*/ false); // A destructuring is never a write-only reference. - checkPropertyAccessibility(parent, !!parent.initializer && parent.initializer.kind === 105 /* SuperKeyword */, parentType, 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); } } } } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 197 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + if (node.name.kind === 199 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, 512 /* Read */); } ts.forEach(node.name.elements, checkSourceElement); @@ -75001,7 +77686,7 @@ var ts; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { - var needCheckInitializer = node.initializer && node.parent.parent.kind !== 238 /* ForInStatement */; + var needCheckInitializer = node.initializer && node.parent.parent.kind !== 240 /* ForInStatement */; var needCheckWidenedType = node.name.elements.length === 0; if (needCheckInitializer || needCheckWidenedType) { // Don't validate for-in initializer as it is already an error @@ -75029,7 +77714,7 @@ var ts; } // For a commonjs `const x = require`, validate the alias and exit var symbol = getSymbolOfNode(node); - if (symbol.flags & 2097152 /* Alias */ && ts.isRequireVariableDeclaration(node, /*requireStringLiteralLikeArgument*/ true)) { + if (symbol.flags & 2097152 /* Alias */ && ts.isRequireVariableDeclaration(node)) { checkAliasSymbol(node); return; } @@ -75043,11 +77728,11 @@ 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 !== 238 /* ForInStatement */) { + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 240 /* ForInStatement */) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); } } - if (symbol.declarations.length > 1) { + if (symbol.declarations && symbol.declarations.length > 1) { if (ts.some(symbol.declarations, function (d) { return d !== node && ts.isVariableLike(d) && !areDeclarationFlagsIdentical(d, node); })) { error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } @@ -75065,26 +77750,27 @@ var ts; if (node.initializer) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(node.initializer), declarationType, node, node.initializer, /*headMessage*/ undefined); } - if (!areDeclarationFlagsIdentical(node, symbol.valueDeclaration)) { + if (symbol.valueDeclaration && !areDeclarationFlagsIdentical(node, symbol.valueDeclaration)) { error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 163 /* PropertyDeclaration */ && node.kind !== 162 /* PropertySignature */) { + if (node.kind !== 165 /* PropertyDeclaration */ && node.kind !== 164 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 249 /* VariableDeclaration */ || node.kind === 198 /* BindingElement */) { + if (node.kind === 251 /* VariableDeclaration */ || node.kind === 200 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); - if (languageVersion < 99 /* ESNext */ && needCollisionCheckForIdentifier(node, node.name, "WeakMap")) { - potentialWeakMapCollisions.push(node); + if (languageVersion < 99 /* ESNext */ + && (needCollisionCheckForIdentifier(node, node.name, "WeakMap") || needCollisionCheckForIdentifier(node, node.name, "WeakSet"))) { + potentialWeakMapSetCollisions.push(node); } } } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 163 /* PropertyDeclaration */ || nextDeclaration.kind === 162 /* PropertySignature */ + var message = nextDeclaration.kind === 165 /* PropertyDeclaration */ || nextDeclaration.kind === 164 /* 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); @@ -75094,8 +77780,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 160 /* Parameter */ && right.kind === 249 /* VariableDeclaration */) || - (left.kind === 249 /* VariableDeclaration */ && right.kind === 160 /* Parameter */)) { + if ((left.kind === 162 /* Parameter */ && right.kind === 251 /* VariableDeclaration */) || + (left.kind === 251 /* VariableDeclaration */ && right.kind === 162 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -75111,10 +77797,10 @@ var ts; return ts.getSelectedEffectiveModifierFlags(left, interestingFlags) === ts.getSelectedEffectiveModifierFlags(right, interestingFlags); } function checkVariableDeclaration(node) { - ts.tracing.push("check" /* Check */, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end }); checkGrammarVariableDeclaration(node); checkVariableLikeDeclaration(node); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } function checkBindingElement(node) { checkGrammarBindingElement(node); @@ -75135,49 +77821,55 @@ var ts; // Grammar checking checkGrammarStatementInAmbientContext(node); var type = checkTruthinessExpression(node.expression); - checkTestingKnownTruthyCallableType(node.expression, type, node.thenStatement); + checkTestingKnownTruthyCallableOrAwaitableType(node.expression, type, node.thenStatement); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 231 /* EmptyStatement */) { + if (node.thenStatement.kind === 233 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); } - function checkTestingKnownTruthyCallableType(condExpr, type, body) { - if (!strictNullChecks) { + function checkTestingKnownTruthyCallableOrAwaitableType(condExpr, type, body) { + if (!strictNullChecks) + return; + if (getFalsyFlags(type)) return; - } var location = ts.isBinaryExpression(condExpr) ? condExpr.right : condExpr; var testedNode = ts.isIdentifier(location) ? location : ts.isPropertyAccessExpression(location) ? location.name : ts.isBinaryExpression(location) && ts.isIdentifier(location.right) ? location.right : undefined; - if (!testedNode) { - return; - } - var possiblyFalsy = getFalsyFlags(type); - if (possiblyFalsy) { + var isPropertyExpressionCast = ts.isPropertyAccessExpression(location) + && ts.isAssertionExpression(ts.skipParentheses(location.expression)); + if (!testedNode || isPropertyExpressionCast) { return; } // While it technically should be invalid for any known-truthy value - // to be tested, we de-scope to functions unrefenced 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. + // 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 */); - if (callSignatures.length === 0) { + var isPromise = !!getAwaitedTypeOfPromise(type); + if (callSignatures.length === 0 && !isPromise) { return; } var testedSymbol = getSymbolAtLocation(testedNode); if (!testedSymbol) { return; } - var isUsed = ts.isBinaryExpression(condExpr.parent) && isFunctionUsedInBinaryExpressionChain(condExpr.parent, testedSymbol) - || body && isFunctionUsedInConditionBody(condExpr, body, testedNode, testedSymbol); + var isUsed = ts.isBinaryExpression(condExpr.parent) && isSymbolUsedInBinaryExpressionChain(condExpr.parent, testedSymbol) + || body && isSymbolUsedInConditionBody(condExpr, body, testedNode, testedSymbol); if (!isUsed) { - error(location, ts.Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead); + if (isPromise) { + errorAndMaybeSuggestAwait(location, + /*maybeMissingAwait*/ true, ts.Diagnostics.This_condition_will_always_return_true_since_this_0_is_always_defined, getTypeNameForErrorDisplay(type)); + } + else { + error(location, ts.Diagnostics.This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_instead); + } } } - function isFunctionUsedInConditionBody(expr, body, testedNode, testedSymbol) { + function isSymbolUsedInConditionBody(expr, body, testedNode, testedSymbol) { return !!ts.forEachChild(body, function check(childNode) { if (ts.isIdentifier(childNode)) { var childSymbol = getSymbolAtLocation(childNode); @@ -75191,7 +77883,7 @@ var ts; var childExpression = childNode.parent; while (testedExpression && childExpression) { if (ts.isIdentifier(testedExpression) && ts.isIdentifier(childExpression) || - testedExpression.kind === 107 /* ThisKeyword */ && childExpression.kind === 107 /* ThisKeyword */) { + testedExpression.kind === 108 /* ThisKeyword */ && childExpression.kind === 108 /* ThisKeyword */) { return getSymbolAtLocation(testedExpression) === getSymbolAtLocation(childExpression); } else if (ts.isPropertyAccessExpression(testedExpression) && ts.isPropertyAccessExpression(childExpression)) { @@ -75214,7 +77906,7 @@ var ts; return ts.forEachChild(childNode, check); }); } - function isFunctionUsedInBinaryExpressionChain(node, testedSymbol) { + function isSymbolUsedInBinaryExpressionChain(node, testedSymbol) { while (ts.isBinaryExpression(node) && node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { var isUsed = ts.forEachChild(node.right, function visit(child) { if (ts.isIdentifier(child)) { @@ -75256,12 +77948,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 250 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 252 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 250 /* VariableDeclarationList */) { + if (node.initializer.kind === 252 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -75295,14 +77987,14 @@ var ts; // 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 === 250 /* VariableDeclarationList */) { + if (node.initializer.kind === 252 /* 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 === 199 /* ArrayLiteralExpression */ || varExpr.kind === 200 /* ObjectLiteralExpression */) { + if (varExpr.kind === 201 /* ArrayLiteralExpression */ || varExpr.kind === 202 /* 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. @@ -75334,7 +78026,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 === 250 /* VariableDeclarationList */) { + if (node.initializer.kind === 252 /* 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); @@ -75348,7 +78040,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 === 199 /* ArrayLiteralExpression */ || varExpr.kind === 200 /* ObjectLiteralExpression */) { + if (varExpr.kind === 201 /* ArrayLiteralExpression */ || varExpr.kind === 202 /* 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)) { @@ -75464,18 +78156,8 @@ 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 yieldType = getIterationTypeOfIterable(use, 0 /* Yield */, inputType, /*errorNode*/ undefined); - var _a = !(use & 4 /* AllowsStringInputFlag */) || hasStringConstituent - ? downlevelIteration - ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true] - : yieldType - ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false] - : [ts.Diagnostics.Type_0_is_not_an_array_type, true] - : downlevelIteration - ? [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] - : yieldType - ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false] - : [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type, true], defaultDiagnostic = _a[0], maybeMissingAwait = _a[1]; + var allowsStrings = !!(use & 4 /* AllowsStringInputFlag */) && !hasStringConstituent; + var _a = getIterationDiagnosticDetails(allowsStrings, downlevelIteration), defaultDiagnostic = _a[0], maybeMissingAwait = _a[1]; errorAndMaybeSuggestAwait(errorNode, maybeMissingAwait && !!getAwaitedTypeOfPromise(arrayType), defaultDiagnostic, typeToString(arrayType)); } return hasStringConstituent ? possibleOutOfBounds ? includeUndefinedInIndexSignature(stringType) : stringType : undefined; @@ -75489,6 +78171,40 @@ var ts; return getUnionType(possibleOutOfBounds ? [arrayElementType, stringType, undefinedType] : [arrayElementType, stringType], 2 /* Subtype */); } return (use & 128 /* PossiblyOutOfBounds */) ? includeUndefinedInIndexSignature(arrayElementType) : arrayElementType; + function getIterationDiagnosticDetails(allowsStrings, downlevelIteration) { + var _a; + if (downlevelIteration) { + return allowsStrings + ? [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); + if (yieldType) { + return [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false]; + } + if (isES2015OrLaterIterable((_a = inputType.symbol) === null || _a === void 0 ? void 0 : _a.escapedName)) { + return [ts.Diagnostics.Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher, true]; + } + return allowsStrings + ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type, true] + : [ts.Diagnostics.Type_0_is_not_an_array_type, true]; + } + } + function isES2015OrLaterIterable(n) { + switch (n) { + case "Float32Array": + case "Float64Array": + case "Int16Array": + case "Int32Array": + case "Int8Array": + case "NodeList": + case "Uint16Array": + case "Uint32Array": + case "Uint8Array": + case "Uint8ClampedArray": + return true; + } + return false; } /** * Gets the requested "iteration type" from an `Iterable`-like or `AsyncIterable`-like type. @@ -75732,6 +78448,11 @@ var ts; return setCachedIterationTypes(type, resolver.iterableCacheKey, createIterationTypes(yieldType, returnType, nextType)); } } + function getPropertyNameForKnownSymbolName(symbolName) { + var ctorType = getGlobalESSymbolConstructorSymbol(/*reportErrors*/ false); + var uniqueType = ctorType && getTypeOfPropertyOfType(getTypeOfSymbol(ctorType), ts.escapeLeadingUnderscores(symbolName)); + return uniqueType && isTypeUsableAsPropertyName(uniqueType) ? getPropertyNameFromType(uniqueType) : "__@" + symbolName; + } /** * Gets the *yield*, *return*, and *next* types of an `Iterable`-like or `AsyncIterable`-like * type from its members. @@ -75744,7 +78465,7 @@ var ts; */ function getIterationTypesOfIterableSlow(type, resolver, errorNode) { var _a; - var method = getPropertyOfType(type, ts.getPropertyNameForKnownSymbolName(resolver.iteratorSymbolName)); + var method = getPropertyOfType(type, getPropertyNameForKnownSymbolName(resolver.iteratorSymbolName)); var methodType = method && !(method.flags & 16777216 /* Optional */) ? getTypeOfSymbol(method) : undefined; if (isTypeAny(methodType)) { return setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes); @@ -76043,12 +78764,12 @@ var ts; var functionFlags = ts.getFunctionFlags(func); if (strictNullChecks || node.expression || returnType.flags & 131072 /* Never */) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; - if (func.kind === 168 /* SetAccessor */) { + if (func.kind === 170 /* SetAccessor */) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 166 /* Constructor */) { + else if (func.kind === 168 /* 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); } @@ -76066,7 +78787,7 @@ var ts; } } } - else if (func.kind !== 166 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 168 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, 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); } @@ -76095,7 +78816,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 === 285 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 287 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -76104,7 +78825,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 284 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 286 /* CaseClause */) { // TypeScript 1.0 spec (April 2014): 5.9 // In a 'switch' statement, each 'case' expression must be of a type that is comparable // to or from the type of the 'switch' expression. @@ -76136,7 +78857,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 245 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 247 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -76166,10 +78887,11 @@ var ts; // Grammar checking if (catchClause.variableDeclaration) { var declaration = catchClause.variableDeclaration; - if (declaration.type) { + var typeNode = ts.getEffectiveTypeAnnotationNode(ts.getRootDeclaration(declaration)); + if (typeNode) { var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false); if (type && !(type.flags & 3 /* AnyOrUnknown */)) { - grammarErrorOnFirstToken(declaration.type, ts.Diagnostics.Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified); + grammarErrorOnFirstToken(typeNode, ts.Diagnostics.Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified); } } else if (declaration.initializer) { @@ -76180,7 +78902,7 @@ var ts; if (blockLocals_1) { ts.forEachKey(catchClause.locals, function (caughtName) { var blockLocal = blockLocals_1.get(caughtName); - if (blockLocal && (blockLocal.flags & 2 /* BlockScopedVariable */) !== 0) { + if ((blockLocal === null || blockLocal === void 0 ? void 0 : blockLocal.valueDeclaration) && (blockLocal.flags & 2 /* BlockScopedVariable */) !== 0) { grammarErrorOnNode(blockLocal.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, caughtName); } }); @@ -76193,27 +78915,30 @@ var ts; checkBlock(node.finallyBlock); } } - function checkIndexConstraints(type) { - var declaredNumberIndexer = getIndexDeclarationOfSymbol(type.symbol, 1 /* Number */); - var declaredStringIndexer = getIndexDeclarationOfSymbol(type.symbol, 0 /* String */); + function checkIndexConstraints(type, isStatic) { + var _a, _b, _c, _d; + var declaredNumberIndexer = getIndexDeclarationOfSymbolTable(isStatic ? (_a = type.symbol) === null || _a === void 0 ? void 0 : _a.exports : (_b = type.symbol) === null || _b === void 0 ? void 0 : _b.members, 1 /* Number */); + var declaredStringIndexer = getIndexDeclarationOfSymbolTable(isStatic ? (_c = type.symbol) === null || _c === void 0 ? void 0 : _c.exports : (_d = type.symbol) === null || _d === void 0 ? void 0 : _d.members, 0 /* String */); var stringIndexType = getIndexTypeOfType(type, 0 /* String */); var numberIndexType = getIndexTypeOfType(type, 1 /* Number */); if (stringIndexType || numberIndexType) { ts.forEach(getPropertiesOfObjectType(type), function (prop) { - var propType = getTypeOfSymbol(prop); + if (isStatic && prop.flags & 4194304 /* Prototype */) + return; + var propType = getNonMissingTypeOfSymbol(prop); checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */); checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */); }); var classDeclaration = type.symbol.valueDeclaration; - if (ts.getObjectFlags(type) & 1 /* Class */ && ts.isClassLike(classDeclaration)) { - for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) { - var member = _a[_i]; + if (ts.getObjectFlags(type) & 1 /* Class */ && classDeclaration && ts.isClassLike(classDeclaration)) { + for (var _i = 0, _e = classDeclaration.members; _i < _e.length; _i++) { + var member = _e[_i]; // Only process instance properties with computed names here. // Static properties cannot be in conflict with indexers, // and properties with literal names were already checked. - if (!ts.hasSyntacticModifier(member, 32 /* Static */) && hasNonBindableDynamicName(member)) { + if (!ts.hasSyntacticModifier(member, 32 /* Static */) && !hasBindableName(member)) { var symbol = getSymbolOfNode(member); - var propType = getTypeOfSymbol(symbol); + var propType = getNonMissingTypeOfSymbol(symbol); checkIndexConstraintForProperty(symbol, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */); checkIndexConstraintForProperty(symbol, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */); } @@ -76226,7 +78951,7 @@ var ts; // condition 'errorNode === undefined' may appear if types does not declare nor string neither number indexer if (!errorNode && (ts.getObjectFlags(type) & 2 /* Interface */)) { var someBaseTypeHasBothIndexers = ts.forEach(getBaseTypes(type), function (base) { return getIndexTypeOfType(base, 0 /* String */) && getIndexTypeOfType(base, 1 /* Number */); }); - errorNode = someBaseTypeHasBothIndexers ? undefined : type.symbol.declarations[0]; + errorNode = someBaseTypeHasBothIndexers || !type.symbol.declarations ? undefined : type.symbol.declarations[0]; } } if (errorNode && !isTypeAssignableTo(numberIndexType, stringIndexType)) { // TODO: GH#18217 @@ -76250,8 +78975,8 @@ var ts; // this allows us to rule out cases when both property and indexer are inherited from the base class var errorNode; if (propDeclaration && name && - (propDeclaration.kind === 216 /* BinaryExpression */ || - name.kind === 158 /* ComputedPropertyName */ || + (propDeclaration.kind === 218 /* BinaryExpression */ || + name.kind === 160 /* ComputedPropertyName */ || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -76263,7 +78988,7 @@ var ts; // check if any base class already has both property and indexer. // check should be performed only if 'type' is the first type that brings property\indexer together var someBaseClassHasBothPropertyAndIndexer = ts.forEach(getBaseTypes(containingType), function (base) { return getPropertyOfObjectType(base, prop.escapedName) && getIndexTypeOfType(base, indexKind); }); - errorNode = someBaseClassHasBothPropertyAndIndexer ? undefined : containingType.symbol.declarations[0]; + errorNode = someBaseClassHasBothPropertyAndIndexer || !containingType.symbol.declarations ? undefined : containingType.symbol.declarations[0]; } if (errorNode && !isTypeAssignableTo(propertyType, indexType)) { var errorMessage = indexKind === 0 /* String */ @@ -76279,6 +79004,7 @@ var ts; switch (name.escapedText) { case "any": case "unknown": + case "never": case "number": case "bigint": case "boolean": @@ -76328,7 +79054,7 @@ var ts; function checkTypeParametersNotReferenced(root, typeParameters, index) { visit(root); function visit(node) { - if (node.kind === 173 /* TypeReference */) { + if (node.kind === 175 /* TypeReference */) { var type = getTypeFromTypeReference(node); if (type.flags & 262144 /* TypeParameter */) { for (var i = index; i < typeParameters.length; i++) { @@ -76343,14 +79069,14 @@ var ts; } /** Check that type parameter lists are identical across multiple declarations */ function checkTypeParameterListsIdentical(symbol) { - if (symbol.declarations.length === 1) { + if (symbol.declarations && symbol.declarations.length === 1) { return; } var links = getSymbolLinks(symbol); if (!links.typeParametersChecked) { links.typeParametersChecked = true; var declarations = getClassOrInterfaceDeclarationsOfSymbol(symbol); - if (declarations.length <= 1) { + if (!declarations || declarations.length <= 1) { return; } var type = getDeclaredTypeOfSymbol(symbol); @@ -76414,6 +79140,9 @@ var ts; registerForUnusedIdentifiersCheck(node); } function checkClassDeclaration(node) { + if (ts.some(node.decorators) && ts.some(node.members, function (p) { return ts.hasStaticModifier(p) && ts.isPrivateIdentifierClassElementDeclaration(p); })) { + grammarErrorOnNode(node.decorators[0], 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 */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } @@ -76442,7 +79171,8 @@ var ts; checkFunctionOrConstructorSymbol(symbol); checkClassForDuplicateDeclarations(node); // Only check for reserved static identifiers on non-ambient context. - if (!(node.flags & 8388608 /* Ambient */)) { + var nodeInAmbientContext = !!(node.flags & 8388608 /* Ambient */); + if (!nodeInAmbientContext) { checkClassForStaticPropertyNameConflicts(node); } var baseTypeNode = ts.getEffectiveBaseTypeNode(node); @@ -76502,6 +79232,7 @@ var ts; checkKindsOfPropertyMemberOverrides(type, baseType_1); } } + checkMembersForMissingOverrideModifier(node, type, typeWithThis, staticType); var implementedTypeNodes = ts.getEffectiveImplementsTypeNodes(node); if (implementedTypeNodes) { for (var _b = 0, implementedTypeNodes_1 = implementedTypeNodes; _b < implementedTypeNodes_1.length; _b++) { @@ -76531,14 +79262,79 @@ var ts; } if (produceDiagnostics) { checkIndexConstraints(type); + checkIndexConstraints(staticType, /*isStatic*/ true); checkTypeForDuplicateIndexSignatures(node); checkPropertyInitialization(node); } } + function checkMembersForMissingOverrideModifier(node, type, typeWithThis, staticType) { + var nodeInAmbientContext = !!(node.flags & 8388608 /* Ambient */); + var baseTypeNode = ts.getEffectiveBaseTypeNode(node); + 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_24 = function (member) { + if (ts.hasAmbientModifier(member)) { + return "continue"; + } + if (ts.isConstructorDeclaration(member)) { + ts.forEach(member.parameters, function (param) { + if (ts.isParameterPropertyDeclaration(param, member)) { + checkClassMember(param, /*memberIsParameterProperty*/ true); + } + }); + } + checkClassMember(member); + }; + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + _loop_24(member); + } + function checkClassMember(member, memberIsParameterProperty) { + var hasOverride = ts.hasOverrideModifier(member); + var hasStatic = ts.hasStaticModifier(member); + if (baseWithThis && (hasOverride || compilerOptions.noImplicitOverride)) { + var declaredProp = member.name && getSymbolAtLocation(member.name) || getSymbolAtLocation(member); + if (!declaredProp) { + return; + } + var thisType = hasStatic ? staticType : typeWithThis; + var baseType = hasStatic ? baseStaticType : baseWithThis; + var prop = getPropertyOfType(thisType, declaredProp.escapedName); + var baseProp = getPropertyOfType(baseType, declaredProp.escapedName); + var baseClassName = typeToString(baseWithThis); + if (prop && !baseProp && hasOverride) { + var suggestion = getSpellingSuggestionForName(ts.symbolName(declaredProp), ts.arrayFrom(getMembersOfSymbol(baseType.symbol).values()), 106500 /* ClassMember */); + suggestion ? + error(member, ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1, baseClassName, symbolToString(suggestion)) : + error(member, ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0, baseClassName); + } + else if (prop && (baseProp === null || baseProp === void 0 ? void 0 : baseProp.valueDeclaration) && compilerOptions.noImplicitOverride && !nodeInAmbientContext) { + var baseHasAbstract = ts.hasAbstractModifier(baseProp.valueDeclaration); + if (hasOverride) { + return; + } + if (!baseHasAbstract) { + var diag = memberIsParameterProperty ? + ts.Diagnostics.This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0 : + ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0; + error(member, diag, baseClassName); + } + else if (ts.hasAbstractModifier(member) && baseHasAbstract) { + error(member, ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0, baseClassName); + } + } + } + else if (hasOverride) { + var className = typeToString(type); + error(member, ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class, className); + } + } + } 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_23 = function (member) { + var _loop_25 = function (member) { if (ts.hasStaticModifier(member)) { return "continue"; } @@ -76557,7 +79353,7 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_23(member); + _loop_25(member); } if (!issuedMemberError) { // check again with diagnostics to generate a less-specific error @@ -76583,7 +79379,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 252 /* ClassDeclaration */ || d.kind === 253 /* InterfaceDeclaration */; + return d.kind === 254 /* ClassDeclaration */ || d.kind === 255 /* InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -76600,6 +79396,7 @@ var ts; // but not by other kinds of members. // Base class instance member variables and accessors can be overridden by // derived class instance member variables and accessors, but not by other kinds of members. + var _a, _b; // NOTE: assignability is checked in checkClassDeclaration var baseProperties = getPropertiesOfType(baseType); basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { @@ -76628,8 +79425,8 @@ var ts; // 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.) - for (var _a = 0, _b = getBaseTypes(type); _a < _b.length; _a++) { - var otherBaseType = _b[_a]; + for (var _c = 0, _d = getBaseTypes(type); _c < _d.length; _c++) { + var otherBaseType = _d[_c]; if (otherBaseType === baseType) continue; var baseSymbol_1 = getPropertyOfObjectType(otherBaseType, base.escapedName); @@ -76638,7 +79435,7 @@ var ts; continue basePropertyCheck; } } - if (derivedClassDecl.kind === 221 /* ClassExpression */) { + if (derivedClassDecl.kind === 223 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -76659,7 +79456,7 @@ var ts; if (basePropertyFlags && derivedPropertyFlags) { // property/accessor is overridden with property/accessor if (baseDeclarationFlags & 128 /* Abstract */ && !(base.valueDeclaration && ts.isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer) - || base.valueDeclaration && base.valueDeclaration.parent.kind === 253 /* InterfaceDeclaration */ + || base.valueDeclaration && base.valueDeclaration.parent.kind === 255 /* InterfaceDeclaration */ || derived.valueDeclaration && ts.isBinaryExpression(derived.valueDeclaration)) { // when the base property is abstract or from an interface, base/derived flags don't need to match // same when the derived property is from an assignment @@ -76673,13 +79470,13 @@ var ts; ts.Diagnostics._0_is_defined_as_a_property_in_class_1_but_is_overridden_here_in_2_as_an_accessor; error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_1, symbolToString(base), typeToString(baseType), typeToString(type)); } - else if (compilerOptions.useDefineForClassFields) { - var uninitialized = ts.find(derived.declarations, function (d) { return d.kind === 163 /* PropertyDeclaration */ && !d.initializer; }); + else if (useDefineForClassFields) { + var uninitialized = (_a = derived.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 165 /* PropertyDeclaration */ && !d.initializer; }); if (uninitialized && !(derived.flags & 33554432 /* Transient */) && !(baseDeclarationFlags & 128 /* Abstract */) && !(derivedDeclarationFlags & 128 /* Abstract */) - && !derived.declarations.some(function (d) { return !!(d.flags & 8388608 /* Ambient */); })) { + && !((_b = derived.declarations) === null || _b === void 0 ? void 0 : _b.some(function (d) { return !!(d.flags & 8388608 /* Ambient */); }))) { var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol)); var propName = uninitialized.name; if (uninitialized.exclamationToken @@ -76790,7 +79587,7 @@ var ts; } } function isInstancePropertyWithoutInitializer(node) { - return node.kind === 163 /* PropertyDeclaration */ && + return node.kind === 165 /* PropertyDeclaration */ && !ts.hasSyntacticModifier(node, 32 /* Static */ | 128 /* Abstract */) && !node.exclamationToken && !node.initializer; @@ -76814,7 +79611,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 253 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 255 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -76847,7 +79644,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0); checkExportsOnMergedDeclarations(node); checkTypeParameters(node.typeParameters); - if (node.type.kind === 136 /* IntrinsicKeyword */) { + if (node.type.kind === 137 /* 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); } @@ -76933,7 +79730,7 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { @@ -76943,7 +79740,7 @@ var ts; } } break; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { @@ -76972,22 +79769,22 @@ var ts; case 8 /* NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return evaluate(expr.expression); - case 78 /* Identifier */: + case 79 /* Identifier */: var identifier = expr; if (isInfinityOrNaNString(identifier.escapedText)) { return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 202 /* ElementAccessExpression */: - case 201 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: var ex = expr; if (isConstantMemberAccess(ex)) { var type = getTypeOfExpression(ex.expression); if (type.symbol && type.symbol.flags & 384 /* Enum */) { var name = void 0; - if (ex.kind === 201 /* PropertyAccessExpression */) { + if (ex.kind === 203 /* PropertyAccessExpression */) { name = ex.name.escapedText; } else { @@ -77005,7 +79802,7 @@ var ts; if (memberSymbol) { var declaration = memberSymbol.valueDeclaration; if (declaration !== member) { - if (isBlockScopedNameDeclaredBeforeUse(declaration, member)) { + if (declaration && isBlockScopedNameDeclaredBeforeUse(declaration, member)) { return getEnumMemberValue(declaration); } error(expr, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums); @@ -77019,9 +79816,9 @@ var ts; } } function isConstantMemberAccess(node) { - return node.kind === 78 /* Identifier */ || - node.kind === 201 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 202 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + return node.kind === 79 /* Identifier */ || + node.kind === 203 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 204 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && ts.isStringLiteralLike(node.argumentExpression); } function checkEnumDeclaration(node) { @@ -77045,7 +79842,7 @@ var ts; var enumSymbol = getSymbolOfNode(node); var firstDeclaration = ts.getDeclarationOfKind(enumSymbol, node.kind); if (node === firstDeclaration) { - if (enumSymbol.declarations.length > 1) { + if (enumSymbol.declarations && enumSymbol.declarations.length > 1) { var enumIsConst_1 = ts.isEnumConst(node); // check that const is placed\omitted on all enum declarations ts.forEach(enumSymbol.declarations, function (decl) { @@ -77057,7 +79854,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 !== 255 /* EnumDeclaration */) { + if (declaration.kind !== 257 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -77083,12 +79880,14 @@ var ts; } function getFirstNonAmbientClassOrFunctionDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { - var declaration = declarations_8[_i]; - if ((declaration.kind === 252 /* ClassDeclaration */ || - (declaration.kind === 251 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && - !(declaration.flags & 8388608 /* Ambient */)) { - return declaration; + if (declarations) { + for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { + var declaration = declarations_8[_i]; + if ((declaration.kind === 254 /* ClassDeclaration */ || + (declaration.kind === 253 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + !(declaration.flags & 8388608 /* Ambient */)) { + return declaration; + } } } return undefined; @@ -77136,8 +79935,9 @@ var ts; // The following checks only apply on a non-ambient instantiated module declaration. if (symbol.flags & 512 /* ValueModule */ && !inAmbientContext + && symbol.declarations && symbol.declarations.length > 1 - && isInstantiatedModule(node, !!compilerOptions.preserveConstEnums || !!compilerOptions.isolatedModules)) { + && isInstantiatedModule(node, ts.shouldPreserveConstEnums(compilerOptions))) { var firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol); if (firstNonAmbientClassOrFunc) { if (ts.getSourceFileOfNode(node) !== ts.getSourceFileOfNode(firstNonAmbientClassOrFunc)) { @@ -77149,7 +79949,7 @@ 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, 252 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 254 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -77198,40 +79998,41 @@ var ts; } } function checkModuleAugmentationElement(node, isGlobalAugmentation) { + var _a; switch (node.kind) { - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: // error each individual name in variable statement instead of marking the entire variable statement - for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; + for (var _i = 0, _b = node.declarationList.declarations; _i < _b.length; _i++) { + var decl = _b[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 266 /* ExportAssignment */: - case 267 /* ExportDeclaration */: + case 268 /* ExportAssignment */: + case 269 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 260 /* ImportEqualsDeclaration */: - case 261 /* ImportDeclaration */: + case 262 /* ImportEqualsDeclaration */: + case 263 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 198 /* BindingElement */: - case 249 /* VariableDeclaration */: + case 200 /* BindingElement */: + case 251 /* VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { - for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { - var el = _c[_b]; + for (var _c = 0, _d = name.elements; _c < _d.length; _c++) { + var el = _d[_c]; // mark individual names in binding pattern checkModuleAugmentationElement(el, isGlobalAugmentation); } break; } // falls through - case 252 /* ClassDeclaration */: - case 255 /* EnumDeclaration */: - case 251 /* FunctionDeclaration */: - case 253 /* InterfaceDeclaration */: - case 256 /* ModuleDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 254 /* ClassDeclaration */: + case 257 /* EnumDeclaration */: + case 253 /* FunctionDeclaration */: + case 255 /* InterfaceDeclaration */: + case 258 /* ModuleDeclaration */: + case 256 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -77244,7 +80045,7 @@ var ts; var reportError = !(symbol.flags & 33554432 /* Transient */); if (!reportError) { // symbol should not originate in augmentation - reportError = !!symbol.parent && ts.isExternalModuleAugmentation(symbol.parent.declarations[0]); + reportError = !!((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.declarations) && ts.isExternalModuleAugmentation(symbol.parent.declarations[0]); } } break; @@ -77252,20 +80053,20 @@ var ts; } function getFirstNonModuleExportsIdentifier(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return node; - case 157 /* QualifiedName */: + case 159 /* QualifiedName */: do { node = node.left; - } while (node.kind !== 78 /* Identifier */); + } while (node.kind !== 79 /* Identifier */); return node; - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: do { if (ts.isModuleExportsAccessExpression(node.expression) && !ts.isPrivateIdentifier(node.name)) { return node.name; } node = node.expression; - } while (node.kind !== 78 /* Identifier */); + } while (node.kind !== 79 /* Identifier */); return node; } } @@ -77279,9 +80080,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 257 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 297 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 267 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 259 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 299 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 269 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -77301,6 +80102,7 @@ var ts; return true; } function checkAliasSymbol(node) { + var _a; var symbol = getSymbolOfNode(node); var target = resolveAlias(symbol); if (target !== unknownSymbol) { @@ -77315,21 +80117,21 @@ var ts; (symbol.flags & 788968 /* Type */ ? 788968 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 270 /* ExportSpecifier */ ? + var message = node.kind === 272 /* 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)); } // Don't allow to re-export something with no value side when `--isolatedModules` is set. if (compilerOptions.isolatedModules - && node.kind === 270 /* ExportSpecifier */ + && node.kind === 272 /* ExportSpecifier */ && !node.parent.parent.isTypeOnly && !(target.flags & 111551 /* Value */) && !(node.flags & 8388608 /* Ambient */)) { error(node, ts.Diagnostics.Re_exporting_a_type_when_the_isolatedModules_flag_is_provided_requires_using_export_type); } - if (ts.isImportSpecifier(node) && ts.every(target.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 134217728 /* Deprecated */); })) { - errorOrSuggestion(/* isError */ false, node.name, ts.Diagnostics._0_is_deprecated, symbol.escapedName); + if (ts.isImportSpecifier(node) && ((_a = target.declarations) === null || _a === void 0 ? void 0 : _a.every(function (d) { return !!(ts.getCombinedNodeFlags(d) & 134217728 /* Deprecated */); }))) { + addDeprecatedSuggestion(node.name, target.declarations, symbol.escapedName); } } } @@ -77337,7 +80139,7 @@ var ts; checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); checkAliasSymbol(node); - if (node.kind === 265 /* ImportSpecifier */ && + if (node.kind === 267 /* ImportSpecifier */ && ts.idText(node.propertyName || node.name) === "default" && compilerOptions.esModuleInterop && moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015) { @@ -77359,7 +80161,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 263 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 265 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); if (moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015 && compilerOptions.esModuleInterop) { // import * as ns from "foo"; @@ -77387,7 +80189,7 @@ var ts; if (ts.hasSyntacticModifier(node, 1 /* Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 272 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 274 /* ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { if (target.flags & 111551 /* Value */) { @@ -77430,10 +80232,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 257 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 257 /* ModuleBlock */ && + var inAmbientExternalModule = node.parent.kind === 259 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 259 /* ModuleBlock */ && !node.moduleSpecifier && node.flags & 8388608 /* Ambient */; - if (node.parent.kind !== 297 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 299 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -77466,14 +80268,14 @@ var ts; } function checkGrammarExportDeclaration(node) { var _a; - var isTypeOnlyExportStar = node.isTypeOnly && ((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) !== 268 /* NamedExports */; + var isTypeOnlyExportStar = node.isTypeOnly && ((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) !== 270 /* NamedExports */; if (isTypeOnlyExportStar) { grammarErrorOnNode(node, ts.Diagnostics.Only_named_exports_may_use_export_type); } return !isTypeOnlyExportStar; } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 297 /* SourceFile */ || node.parent.kind === 257 /* ModuleBlock */ || node.parent.kind === 256 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 299 /* SourceFile */ || node.parent.kind === 259 /* ModuleBlock */ || node.parent.kind === 258 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -77523,7 +80325,7 @@ var ts; // 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 */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); - if (symbol && (symbol === undefinedSymbol || symbol === globalThisSymbol || isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { + 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 { @@ -77544,12 +80346,15 @@ var ts; } } function checkExportAssignment(node) { - if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { + var illegalContextMessage = node.isExportEquals + ? ts.Diagnostics.An_export_assignment_must_be_at_the_top_level_of_a_file_or_module_declaration + : ts.Diagnostics.A_default_export_must_be_at_the_top_level_of_a_file_or_module_declaration; + if (checkGrammarModuleElementContext(node, illegalContextMessage)) { // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 297 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 256 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 299 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 258 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -77562,7 +80367,7 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasEffectiveModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 78 /* Identifier */) { + if (node.expression.kind === 79 /* Identifier */) { var id = node.expression; var sym = resolveEntityName(id, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node); if (sym) { @@ -77609,7 +80414,7 @@ var ts; var exportEqualsSymbol = moduleSymbol.exports.get("export="); if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) { var declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration; - if (!isTopLevelInExternalModuleAugmentation(declaration) && !ts.isInJSFile(declaration)) { + if (declaration && !isTopLevelInExternalModuleAugmentation(declaration) && !ts.isInJSFile(declaration)) { error(declaration, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); } } @@ -77633,10 +80438,12 @@ var ts; return; } if (exportedDeclarationsCount > 1) { - for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { - var declaration = declarations_9[_i]; - if (isNotOverload(declaration)) { - diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Cannot_redeclare_exported_variable_0, ts.unescapeLeadingUnderscores(id))); + if (!isDuplicatedCommonJSExport(declarations)) { + for (var _i = 0, _b = declarations; _i < _b.length; _i++) { + var declaration = _b[_i]; + if (isNotOverload(declaration)) { + diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Cannot_redeclare_exported_variable_0, ts.unescapeLeadingUnderscores(id))); + } } } } @@ -77645,6 +80452,11 @@ var ts; links.exportsChecked = true; } } + function isDuplicatedCommonJSExport(declarations) { + return declarations + && declarations.length > 1 + && declarations.every(function (d) { return ts.isInJSFile(d) && ts.isAccessExpression(d) && (ts.isExportsIdentifier(d.expression) || ts.isModuleExportsAccessExpression(d.expression)); }); + } function checkSourceElement(node) { if (node) { var saveCurrentNode = currentNode; @@ -77666,171 +80478,171 @@ 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 256 /* ModuleDeclaration */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 251 /* FunctionDeclaration */: + case 258 /* ModuleDeclaration */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 253 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } - if (kind >= 232 /* FirstStatement */ && kind <= 248 /* LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { + if (kind >= 234 /* FirstStatement */ && kind <= 250 /* LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { errorOrSuggestion(compilerOptions.allowUnreachableCode === false, node, ts.Diagnostics.Unreachable_code_detected); } switch (kind) { - case 159 /* TypeParameter */: + case 161 /* TypeParameter */: return checkTypeParameter(node); - case 160 /* Parameter */: + case 162 /* Parameter */: return checkParameter(node); - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return checkPropertyDeclaration(node); - case 162 /* PropertySignature */: + case 164 /* PropertySignature */: return checkPropertySignature(node); - case 175 /* ConstructorType */: - case 174 /* FunctionType */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: + case 177 /* ConstructorType */: + case 176 /* FunctionType */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 173 /* IndexSignature */: return checkSignatureDeclaration(node); - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: return checkMethodDeclaration(node); - case 166 /* Constructor */: + case 168 /* Constructor */: return checkConstructorDeclaration(node); - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return checkAccessorDeclaration(node); - case 173 /* TypeReference */: + case 175 /* TypeReference */: return checkTypeReferenceNode(node); - case 172 /* TypePredicate */: + case 174 /* TypePredicate */: return checkTypePredicate(node); - case 176 /* TypeQuery */: + case 178 /* TypeQuery */: return checkTypeQuery(node); - case 177 /* TypeLiteral */: + case 179 /* TypeLiteral */: return checkTypeLiteral(node); - case 178 /* ArrayType */: + case 180 /* ArrayType */: return checkArrayType(node); - case 179 /* TupleType */: + case 181 /* TupleType */: return checkTupleType(node); - case 182 /* UnionType */: - case 183 /* IntersectionType */: + case 184 /* UnionType */: + case 185 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 186 /* ParenthesizedType */: - case 180 /* OptionalType */: - case 181 /* RestType */: + case 188 /* ParenthesizedType */: + case 182 /* OptionalType */: + case 183 /* RestType */: return checkSourceElement(node.type); - case 187 /* ThisType */: + case 189 /* ThisType */: return checkThisType(node); - case 188 /* TypeOperator */: + case 190 /* TypeOperator */: return checkTypeOperator(node); - case 184 /* ConditionalType */: + case 186 /* ConditionalType */: return checkConditionalType(node); - case 185 /* InferType */: + case 187 /* InferType */: return checkInferType(node); - case 193 /* TemplateLiteralType */: + case 195 /* TemplateLiteralType */: return checkTemplateLiteralType(node); - case 195 /* ImportType */: + case 197 /* ImportType */: return checkImportType(node); - case 192 /* NamedTupleMember */: + case 194 /* NamedTupleMember */: return checkNamedTupleMember(node); - case 315 /* JSDocAugmentsTag */: + case 322 /* JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 316 /* JSDocImplementsTag */: + case 323 /* JSDocImplementsTag */: return checkJSDocImplementsTag(node); - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 325 /* JSDocEnumTag */: + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + case 333 /* JSDocEnumTag */: return checkJSDocTypeAliasTag(node); - case 330 /* JSDocTemplateTag */: + case 338 /* JSDocTemplateTag */: return checkJSDocTemplateTag(node); - case 329 /* JSDocTypeTag */: + case 337 /* JSDocTypeTag */: return checkJSDocTypeTag(node); - case 326 /* JSDocParameterTag */: + case 334 /* JSDocParameterTag */: return checkJSDocParameterTag(node); - case 333 /* JSDocPropertyTag */: + case 341 /* JSDocPropertyTag */: return checkJSDocPropertyTag(node); - case 308 /* JSDocFunctionType */: + case 311 /* JSDocFunctionType */: checkJSDocFunctionType(node); // falls through - case 306 /* JSDocNonNullableType */: - case 305 /* JSDocNullableType */: - case 303 /* JSDocAllType */: - case 304 /* JSDocUnknownType */: - case 312 /* JSDocTypeLiteral */: + case 309 /* JSDocNonNullableType */: + case 308 /* JSDocNullableType */: + case 306 /* JSDocAllType */: + case 307 /* JSDocUnknownType */: + case 316 /* JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 309 /* JSDocVariadicType */: + case 312 /* JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 301 /* JSDocTypeExpression */: + case 303 /* JSDocTypeExpression */: return checkSourceElement(node.type); - case 189 /* IndexedAccessType */: + case 191 /* IndexedAccessType */: return checkIndexedAccessType(node); - case 190 /* MappedType */: + case 192 /* MappedType */: return checkMappedType(node); - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 230 /* Block */: - case 257 /* ModuleBlock */: + case 232 /* Block */: + case 259 /* ModuleBlock */: return checkBlock(node); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return checkVariableStatement(node); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: return checkExpressionStatement(node); - case 234 /* IfStatement */: + case 236 /* IfStatement */: return checkIfStatement(node); - case 235 /* DoStatement */: + case 237 /* DoStatement */: return checkDoStatement(node); - case 236 /* WhileStatement */: + case 238 /* WhileStatement */: return checkWhileStatement(node); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return checkForStatement(node); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return checkForInStatement(node); - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: return checkForOfStatement(node); - case 240 /* ContinueStatement */: - case 241 /* BreakStatement */: + case 242 /* ContinueStatement */: + case 243 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: return checkReturnStatement(node); - case 243 /* WithStatement */: + case 245 /* WithStatement */: return checkWithStatement(node); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: return checkSwitchStatement(node); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return checkLabeledStatement(node); - case 246 /* ThrowStatement */: + case 248 /* ThrowStatement */: return checkThrowStatement(node); - case 247 /* TryStatement */: + case 249 /* TryStatement */: return checkTryStatement(node); - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 198 /* BindingElement */: + case 200 /* BindingElement */: return checkBindingElement(node); - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: return checkClassDeclaration(node); - case 253 /* InterfaceDeclaration */: + case 255 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return checkImportDeclaration(node); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: return checkExportDeclaration(node); - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return checkExportAssignment(node); - case 231 /* EmptyStatement */: - case 248 /* DebuggerStatement */: + case 233 /* EmptyStatement */: + case 250 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 271 /* MissingDeclaration */: + case 273 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -77875,7 +80687,8 @@ var ts; if (ts.isJSDocTypeExpression(node.parent) && ts.isJSDocParameterTag(paramTag)) { // Else we will add a diagnostic, see `checkJSDocVariadicType`. var host_1 = ts.getHostSignatureFromJSDoc(paramTag); - if (host_1) { + var isCallbackTag = ts.isJSDocCallbackTag(paramTag.parent.parent); + if (host_1 || isCallbackTag) { /* Only return an array type if the corresponding parameter is marked as a rest parameter, or if there are no parameters. So in the following situation we will not create an array type: @@ -77883,7 +80696,9 @@ var ts; function f(a) {} Because `a` will just be of type `number | undefined`. A synthetic `...args` will also be added, which *will* get an array type. */ - var lastParamDeclaration = ts.lastOrUndefined(host_1.parameters); + var lastParamDeclaration = isCallbackTag + ? ts.lastOrUndefined(paramTag.parent.parent.typeExpression.parameters) + : ts.lastOrUndefined(host_1.parameters); var symbol = ts.getParameterSymbolFromJSDoc(paramTag); if (!lastParamDeclaration || symbol && lastParamDeclaration.symbol === symbol && ts.isRestParameter(lastParamDeclaration)) { @@ -77921,51 +80736,51 @@ var ts; } } function checkDeferredNode(node) { - ts.tracing.push("check" /* Check */, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end }); var saveCurrentNode = currentNode; currentNode = node; instantiationCount = 0; switch (node.kind) { - case 203 /* CallExpression */: - case 204 /* NewExpression */: - case 205 /* TaggedTemplateExpression */: - case 161 /* Decorator */: - case 275 /* JsxOpeningElement */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: + case 207 /* TaggedTemplateExpression */: + case 163 /* Decorator */: + case 277 /* 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 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: checkAccessorDeclaration(node); break; - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: checkClassExpressionDeferred(node); break; - case 274 /* JsxSelfClosingElement */: + case 276 /* JsxSelfClosingElement */: checkJsxSelfClosingElementDeferred(node); break; - case 273 /* JsxElement */: + case 275 /* JsxElement */: checkJsxElementDeferred(node); break; } currentNode = saveCurrentNode; - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } function checkSourceFile(node) { - ts.tracing.push("check" /* Check */, "checkSourceFile", { path: node.path }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkSourceFile", { path: node.path }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeCheck"); checkSourceFileWorker(node); ts.performance.mark("afterCheck"); ts.performance.measure("Check", "beforeCheck", "afterCheck"); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } function unusedIsError(kind, isAmbient) { if (isAmbient) { @@ -77994,7 +80809,7 @@ var ts; checkGrammarSourceFile(node); ts.clear(potentialThisCollisions); ts.clear(potentialNewTargetCollisions); - ts.clear(potentialWeakMapCollisions); + ts.clear(potentialWeakMapSetCollisions); ts.forEach(node.statements, checkSourceElement); checkSourceElement(node.endOfFileToken); checkDeferredNodes(node); @@ -78024,9 +80839,9 @@ var ts; ts.forEach(potentialNewTargetCollisions, checkIfNewTargetIsCapturedInEnclosingScope); ts.clear(potentialNewTargetCollisions); } - if (potentialWeakMapCollisions.length) { - ts.forEach(potentialWeakMapCollisions, checkWeakMapCollision); - ts.clear(potentialWeakMapCollisions); + if (potentialWeakMapSetCollisions.length) { + ts.forEach(potentialWeakMapSetCollisions, checkWeakMapSetCollision); + ts.clear(potentialWeakMapSetCollisions); } links.flags |= 1 /* TypeChecked */; } @@ -78098,17 +80913,17 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 297 /* SourceFile */: - if (!ts.isExternalOrCommonJsModule(location)) + case 299 /* SourceFile */: + if (!ts.isExternalModule(location)) break; // falls through - case 256 /* ModuleDeclaration */: - copySymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); + case 258 /* ModuleDeclaration */: + copyLocallyVisibleExportSymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); break; - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); @@ -78116,8 +80931,8 @@ 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 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: + case 254 /* ClassDeclaration */: + case 255 /* 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. @@ -78126,7 +80941,7 @@ var ts; copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* Type */); } break; - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -78166,27 +80981,37 @@ var ts; }); } } + function copyLocallyVisibleExportSymbols(source, meaning) { + if (meaning) { + source.forEach(function (symbol) { + // Similar condition as in `resolveNameHelper` + if (!ts.getDeclarationOfKind(symbol, 272 /* ExportSpecifier */) && !ts.getDeclarationOfKind(symbol, 271 /* NamespaceExport */)) { + copySymbol(symbol, meaning); + } + }); + } + } } function isTypeDeclarationName(name) { - return name.kind === 78 /* Identifier */ && + return name.kind === 79 /* Identifier */ && isTypeDeclaration(name.parent) && ts.getNameOfDeclaration(name.parent) === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 159 /* TypeParameter */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 255 /* EnumDeclaration */: - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 325 /* JSDocEnumTag */: + case 161 /* TypeParameter */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 257 /* EnumDeclaration */: + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + case 333 /* JSDocEnumTag */: return true; - case 262 /* ImportClause */: + case 264 /* ImportClause */: return node.isTypeOnly; - case 265 /* ImportSpecifier */: - case 270 /* ExportSpecifier */: + case 267 /* ImportSpecifier */: + case 272 /* ExportSpecifier */: return node.parent.parent.isTypeOnly; default: return false; @@ -78194,25 +81019,16 @@ var ts; } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(node) { - while (node.parent.kind === 157 /* QualifiedName */) { + while (node.parent.kind === 159 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 173 /* TypeReference */; + return node.parent.kind === 175 /* TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 201 /* PropertyAccessExpression */) { - node = node.parent; - } - return node.parent.kind === 223 /* ExpressionWithTypeArguments */; - } - function isJSDocEntryNameReference(node) { - while (node.parent.kind === 157 /* QualifiedName */) { + while (node.parent.kind === 203 /* PropertyAccessExpression */) { node = node.parent; } - while (node.parent.kind === 201 /* PropertyAccessExpression */) { - node = node.parent; - } - return node.parent.kind === 302 /* JSDocNameReference */; + return node.parent.kind === 225 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -78240,13 +81056,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 157 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 159 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 260 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 262 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 266 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 268 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -78272,7 +81088,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 195 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 197 /* ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -78282,17 +81098,17 @@ var ts; return getSymbolOfNode(name.parent); } if (ts.isInJSFile(name) && - name.parent.kind === 201 /* PropertyAccessExpression */ && + name.parent.kind === 203 /* PropertyAccessExpression */ && name.parent === name.parent.parent.left) { // Check if this is a special property assignment - if (!ts.isPrivateIdentifier(name)) { + if (!ts.isPrivateIdentifier(name) && !ts.isJSDocMemberName(name)) { var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(name); if (specialPropertyAssignmentSymbol) { return specialPropertyAssignmentSymbol; } } } - if (name.parent.kind === 266 /* ExportAssignment */ && ts.isEntityNameExpression(name)) { + if (name.parent.kind === 268 /* 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); @@ -78300,13 +81116,13 @@ var ts; return success; } } - else if (!ts.isPropertyAccessExpression(name) && !ts.isPrivateIdentifier(name) && isInRightSideOfImportOrExportAssignment(name)) { + 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, 260 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(name, 262 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(name, /*dontResolveAlias*/ true); } - if (!ts.isPropertyAccessExpression(name) && !ts.isPrivateIdentifier(name)) { + if (ts.isEntityName(name)) { var possibleImportNode = isImportTypeQualifierPart(name); if (possibleImportNode) { getTypeFromTypeNode(possibleImportNode); @@ -78314,13 +81130,13 @@ var ts; return sym === unknownSymbol ? undefined : sym; } } - while (ts.isRightSideOfQualifiedNameOrPropertyAccess(name)) { + while (ts.isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName(name)) { name = name.parent; } if (isHeritageClauseElementIdentifier(name)) { var meaning = 0 /* None */; // In an interface or class, we're definitely interested in a type. - if (name.parent.kind === 223 /* ExpressionWithTypeArguments */) { + if (name.parent.kind === 225 /* ExpressionWithTypeArguments */) { meaning = 788968 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(name.parent)) { @@ -78336,10 +81152,10 @@ var ts; return entityNameSymbol; } } - if (name.parent.kind === 326 /* JSDocParameterTag */) { + if (name.parent.kind === 334 /* JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(name.parent); } - if (name.parent.kind === 159 /* TypeParameter */ && name.parent.parent.kind === 330 /* JSDocTemplateTag */) { + if (name.parent.kind === 161 /* TypeParameter */ && name.parent.parent.kind === 338 /* JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJSFile(name)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(name.parent); return typeParameter && typeParameter.symbol; @@ -78349,43 +81165,81 @@ var ts; // Missing entity name. return undefined; } - if (name.kind === 78 /* Identifier */) { + 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 */) { if (ts.isJSXTagName(name) && isJsxIntrinsicIdentifier(name)) { var symbol = getIntrinsicTagSymbol(name.parent); return symbol === unknownSymbol ? undefined : symbol; } - return resolveEntityName(name, 111551 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); + var result = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ !isJSDoc_1, ts.getHostSignatureFromJSDoc(name)); + if (!result && isJSDoc_1) { + var container = ts.findAncestor(name, ts.or(ts.isClassLike, ts.isInterfaceDeclaration)); + if (container) { + return resolveJSDocMemberName(name, getSymbolOfNode(container)); + } + } + return result; } - else if (name.kind === 201 /* PropertyAccessExpression */ || name.kind === 157 /* QualifiedName */) { + else if (name.kind === 203 /* PropertyAccessExpression */ || name.kind === 159 /* QualifiedName */) { var links = getNodeLinks(name); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (name.kind === 201 /* PropertyAccessExpression */) { - checkPropertyAccessExpression(name); + if (name.kind === 203 /* PropertyAccessExpression */) { + checkPropertyAccessExpression(name, 0 /* Normal */); } else { - checkQualifiedName(name); + checkQualifiedName(name, 0 /* Normal */); + } + if (!links.resolvedSymbol && isJSDoc_1 && ts.isQualifiedName(name)) { + return resolveJSDocMemberName(name); } return links.resolvedSymbol; } + else if (ts.isJSDocMemberName(name)) { + return resolveJSDocMemberName(name); + } } else if (isTypeReferenceIdentifier(name)) { - var meaning = name.parent.kind === 173 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; + var meaning = name.parent.kind === 175 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; return resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (isJSDocEntryNameReference(name)) { - var meaning = 788968 /* Type */ | 1920 /* Namespace */ | 111551 /* Value */; - return resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true, ts.getHostSignatureFromJSDoc(name)); - } - if (name.parent.kind === 172 /* TypePredicate */) { + if (name.parent.kind === 174 /* TypePredicate */) { return resolveEntityName(name, /*meaning*/ 1 /* FunctionScopedVariable */); } - // Do we want to return undefined here? return undefined; } + /** + * Recursively resolve entity names and jsdoc instance references: + * 1. K#m as K.prototype.m for a class (or other value) K + * 2. K.m as K.prototype.m + * 3. I.m as I.m for a type I, or any other I.m that fails to resolve in (1) or (2) + * + * For unqualified names, a container K may be provided as a second argument. + */ + function resolveJSDocMemberName(name, container) { + if (ts.isEntityName(name)) { + // resolve static values first + var meaning = 788968 /* Type */ | 1920 /* Namespace */ | 111551 /* Value */; + var symbol = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true, ts.getHostSignatureFromJSDoc(name)); + if (!symbol && ts.isIdentifier(name) && container) { + symbol = getMergedSymbol(getSymbol(getExportsOfSymbol(container), name.escapedText, meaning)); + } + if (symbol) { + return symbol; + } + } + var left = ts.isIdentifier(name) ? container : resolveJSDocMemberName(name.left); + var right = ts.isIdentifier(name) ? name.escapedText : name.right.escapedText; + if (left) { + var proto = left.flags & 111551 /* Value */ && getPropertyOfType(getTypeOfSymbol(left), "prototype"); + var t = proto ? getTypeOfSymbol(proto) : getDeclaredTypeOfSymbol(left); + return getPropertyOfType(t, right); + } + } function getSymbolAtLocation(node, ignoreErrors) { - if (node.kind === 297 /* SourceFile */) { + if (node.kind === 299 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; @@ -78404,12 +81258,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(parent.parent); } - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfNameOrPropertyAccessExpression(node); } - else if (parent.kind === 198 /* BindingElement */ && - grandParent.kind === 196 /* ObjectBindingPattern */ && + else if (parent.kind === 200 /* BindingElement */ && + grandParent.kind === 198 /* ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText); @@ -78419,12 +81273,12 @@ var ts; } } switch (node.kind) { - case 78 /* Identifier */: - case 79 /* PrivateIdentifier */: - case 201 /* PropertyAccessExpression */: - case 157 /* QualifiedName */: + case 79 /* Identifier */: + case 80 /* PrivateIdentifier */: + case 203 /* PropertyAccessExpression */: + case 159 /* QualifiedName */: return getSymbolOfNameOrPropertyAccessExpression(node); - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -78436,14 +81290,14 @@ var ts; return checkExpression(node).symbol; } // falls through - case 187 /* ThisType */: + case 189 /* ThisType */: return getTypeFromThisTypeNode(node).symbol; - case 105 /* SuperKeyword */: + case 106 /* SuperKeyword */: return checkExpression(node).symbol; - case 132 /* ConstructorKeyword */: + case 133 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 166 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 168 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -78454,7 +81308,7 @@ var ts; // 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 === 261 /* ImportDeclaration */ || node.parent.kind === 267 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 263 /* ImportDeclaration */ || node.parent.kind === 269 /* 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); @@ -78471,21 +81325,21 @@ var ts; ? getTypeFromTypeNode(grandParent.objectType) : undefined; return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text)); - case 87 /* DefaultKeyword */: - case 97 /* FunctionKeyword */: + case 88 /* DefaultKeyword */: + case 98 /* FunctionKeyword */: case 38 /* EqualsGreaterThanToken */: - case 83 /* ClassKeyword */: + case 84 /* ClassKeyword */: return getSymbolOfNode(node.parent); - case 195 /* ImportType */: + case 197 /* ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal, ignoreErrors) : undefined; - case 92 /* ExportKeyword */: + case 93 /* ExportKeyword */: return ts.isExportAssignment(node.parent) ? ts.Debug.checkDefined(node.parent.symbol) : undefined; default: return undefined; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 289 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 291 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 111551 /* Value */ | 2097152 /* Alias */); } return undefined; @@ -78564,27 +81418,27 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfAssignmentPattern(expr) { - ts.Debug.assert(expr.kind === 200 /* ObjectLiteralExpression */ || expr.kind === 199 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 202 /* ObjectLiteralExpression */ || expr.kind === 201 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 239 /* ForOfStatement */) { + if (expr.parent.kind === 241 /* 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 === 216 /* BinaryExpression */) { + if (expr.parent.kind === 218 /* 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 === 288 /* PropertyAssignment */) { - var node_2 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); - var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_2) || errorType; - var propertyIndex = ts.indexOfNode(node_2.properties, expr.parent); - return checkObjectLiteralDestructuringPropertyAssignment(node_2, typeOfParentObjectLiteral, propertyIndex); + if (expr.parent.kind === 290 /* 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); + return checkObjectLiteralDestructuringPropertyAssignment(node_3, typeOfParentObjectLiteral, propertyIndex); } // Array literal assignment - array destructuring pattern var node = ts.cast(expr.parent, ts.isArrayLiteralExpression); @@ -78623,12 +81477,12 @@ var ts; function getClassElementPropertyKeyType(element) { var name = element.name; switch (name.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return getLiteralType(ts.idText(name)); case 8 /* NumericLiteral */: case 10 /* StringLiteral */: return getLiteralType(name.text); - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(name); return isTypeAssignableToKind(nameType, 12288 /* ESSymbolLike */) ? nameType : stringType; default: @@ -78725,6 +81579,7 @@ var ts; // When resolved as an expression identifier, if the given node references an exported entity, return the declaration // node of the exported entity's container. Otherwise, return undefined. function getReferencedExportContainer(nodeIn, prefixLocals) { + var _a; var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { // When resolving the export container for the name of a module or enum @@ -78745,7 +81600,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 297 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && ((_a = parentSymbol_1.valueDeclaration) === null || _a === void 0 ? void 0 : _a.kind) === 299 /* 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. @@ -78775,11 +81630,12 @@ var ts; return undefined; } function isSymbolOfDestructuredElementOfCatchBinding(symbol) { - return ts.isBindingElement(symbol.valueDeclaration) - && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 287 /* CatchClause */; + return symbol.valueDeclaration + && ts.isBindingElement(symbol.valueDeclaration) + && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 289 /* CatchClause */; } function isSymbolOfDeclarationWithCollidingName(symbol) { - if (symbol.flags & 418 /* BlockScoped */ && !ts.isSourceFile(symbol.valueDeclaration)) { + if (symbol.flags & 418 /* BlockScoped */ && symbol.valueDeclaration && !ts.isSourceFile(symbol.valueDeclaration)) { var links = getSymbolLinks(symbol); if (links.isDeclarationWithCollidingName === undefined) { var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); @@ -78807,7 +81663,7 @@ var ts; // they will not collide with anything var isDeclaredInLoop = nodeLinks_1.flags & 524288 /* BlockScopedBindingInLoop */; var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false); - var inLoopBodyBlock = container.kind === 230 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 232 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -78848,20 +81704,20 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 262 /* ImportClause */: - case 263 /* NamespaceImport */: - case 265 /* ImportSpecifier */: - case 270 /* ExportSpecifier */: + case 264 /* ImportClause */: + case 265 /* NamespaceImport */: + case 267 /* ImportSpecifier */: + case 272 /* ExportSpecifier */: var symbol = getSymbolOfNode(node) || unknownSymbol; return isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && (ts.isNamespaceExport(exportClause) || ts.some(exportClause.elements, isValueAliasDeclaration)); - case 266 /* ExportAssignment */: - return node.expression && node.expression.kind === 78 /* Identifier */ ? + case 268 /* ExportAssignment */: + return node.expression && node.expression.kind === 79 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : true; } @@ -78869,7 +81725,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 297 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 299 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -78884,7 +81740,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 */) && - (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target)); + (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target)); } function isConstEnumOrConstEnumOnlyModule(s) { return isConstEnumSymbol(s) || !!s.constEnumOnlyModule; @@ -78892,13 +81748,14 @@ var ts; function isReferencedAliasDeclaration(node, checkChildren) { if (isAliasSymbolDeclaration(node)) { var symbol = getSymbolOfNode(node); - if (symbol && getSymbolLinks(symbol).referenced) { + var links = symbol && getSymbolLinks(symbol); + if (links === null || links === void 0 ? void 0 : links.referenced) { return true; } var target = getSymbolLinks(symbol).target; // TODO: GH#18217 if (target && ts.getEffectiveModifierFlags(node) & 1 /* Export */ && target.flags & 111551 /* Value */ && - (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) { + (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) { // An `export import ... =` of a value symbol is always considered referenced return true; } @@ -78935,13 +81792,13 @@ var ts; !isOptionalParameter(parameter) && !ts.isJSDocParameterTag(parameter) && !!parameter.initializer && - !ts.hasSyntacticModifier(parameter, 92 /* ParameterPropertyModifier */); + !ts.hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */); } function isOptionalUninitializedParameterProperty(parameter) { return strictNullChecks && isOptionalParameter(parameter) && !parameter.initializer && - ts.hasSyntacticModifier(parameter, 92 /* ParameterPropertyModifier */); + ts.hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */); } function isOptionalUninitializedParameter(parameter) { return !!strictNullChecks && @@ -78976,15 +81833,15 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 291 /* EnumMember */: - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 293 /* EnumMember */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 291 /* EnumMember */) { + if (node.kind === 293 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -79072,7 +81929,7 @@ var ts; function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) { var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor); if (!declaration) { - return ts.factory.createToken(128 /* AnyKeyword */); + return ts.factory.createToken(129 /* AnyKeyword */); } // Get type of the symbol if this is the valid symbol otherwise get type at location var symbol = getSymbolOfNode(declaration); @@ -79091,7 +81948,7 @@ var ts; function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) { var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike); if (!signatureDeclaration) { - return ts.factory.createToken(128 /* AnyKeyword */); + return ts.factory.createToken(129 /* AnyKeyword */); } var signature = getSignatureFromDeclaration(signatureDeclaration); return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); @@ -79099,7 +81956,7 @@ var ts; function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) { var expr = ts.getParseTreeNode(exprIn, ts.isExpression); if (!expr) { - return ts.factory.createToken(128 /* AnyKeyword */); + return ts.factory.createToken(129 /* AnyKeyword */); } var type = getWidenedType(getRegularTypeOfExpression(expr)); return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); @@ -79137,8 +81994,7 @@ var ts; } function isLiteralConstDeclaration(node) { if (ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node)) { - var type = getTypeOfSymbol(getSymbolOfNode(node)); - return !!(type.flags & 2944 /* Literal */) && isFreshLiteralType(type); + return isFreshLiteralType(getTypeOfSymbol(getSymbolOfNode(node))); } return false; } @@ -79257,12 +82113,12 @@ var ts; getJsxFragmentFactoryEntity: getJsxFragmentFactoryEntity, getAllAccessorDeclarations: function (accessor) { accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); // TODO: GH#18217 - var otherKind = accessor.kind === 168 /* SetAccessor */ ? 167 /* GetAccessor */ : 168 /* SetAccessor */; + var otherKind = accessor.kind === 170 /* SetAccessor */ ? 169 /* GetAccessor */ : 170 /* 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 === 168 /* SetAccessor */ ? accessor : otherAccessor; - var getAccessor = accessor.kind === 167 /* GetAccessor */ ? accessor : otherAccessor; + var setAccessor = accessor.kind === 170 /* SetAccessor */ ? accessor : otherAccessor; + var getAccessor = accessor.kind === 169 /* GetAccessor */ ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -79278,7 +82134,7 @@ var ts; }, getDeclarationStatementsForSourceFile: function (node, flags, tracker, bundled) { var n = ts.getParseTreeNode(node); - ts.Debug.assert(n && n.kind === 297 /* SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); + ts.Debug.assert(n && n.kind === 299 /* SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); var sym = getSymbolOfNode(node); if (!sym) { return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker, bundled); @@ -79301,11 +82157,13 @@ var ts; var s = _a[_i]; if (s.mergeId) { var merged = getMergedSymbol(s); - for (var _b = 0, _c = merged.declarations; _b < _c.length; _b++) { - var d = _c[_b]; - var declFile = ts.getSourceFileOfNode(d); - if (declFile === importTarget) { - return true; + if (merged.declarations) { + for (var _b = 0, _c = merged.declarations; _b < _c.length; _b++) { + var d = _c[_b]; + var declFile = ts.getSourceFileOfNode(d); + if (declFile === importTarget) { + return true; + } } } } @@ -79313,7 +82171,7 @@ var ts; return false; } function isInHeritageClause(node) { - return node.parent && node.parent.kind === 223 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 286 /* HeritageClause */; + return node.parent && node.parent.kind === 225 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 288 /* HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -79325,7 +82183,7 @@ var ts; // 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 === 78 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 201 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { + if ((node.kind === 79 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 203 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); @@ -79334,10 +82192,7 @@ var ts; // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForSymbol(symbol, meaning) { // program does not have any files with type reference directives - bail out - if (!fileToDirective) { - return undefined; - } - if (!isSymbolFromTypeDeclarationFile(symbol)) { + if (!fileToDirective || !isSymbolFromTypeDeclarationFile(symbol)) { return undefined; } // check what declarations in the symbol can contribute to the target meaning @@ -79376,7 +82231,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 297 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 299 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -79404,12 +82259,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 256 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 258 /* 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, 297 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 299 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -79429,7 +82284,7 @@ var ts; // It is an error for a non-external-module (i.e. script) to declare its own `globalThis`. // We can't use `builtinGlobals` for this due to synthetic expando-namespace generation in JS files. var fileGlobalThisSymbol = file.locals.get("globalThis"); - if (fileGlobalThisSymbol) { + if (fileGlobalThisSymbol === null || fileGlobalThisSymbol === void 0 ? void 0 : fileGlobalThisSymbol.declarations) { for (var _d = 0, _e = fileGlobalThisSymbol.declarations; _d < _e.length; _d++) { var declaration = _e[_d]; diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0, "globalThis")); @@ -79553,6 +82408,16 @@ var ts; 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 */) { + 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 */) { + 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); + } + } } } } @@ -79602,14 +82467,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 165 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 167 /* 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 === 167 /* GetAccessor */ || node.kind === 168 /* SetAccessor */) { + else if (node.kind === 169 /* GetAccessor */ || node.kind === 170 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -79622,31 +82487,51 @@ var ts; if (quickResult !== undefined) { return quickResult; } - var lastStatic, lastDeclare, lastAsync, lastReadonly; + var lastStatic, lastDeclare, lastAsync, lastReadonly, lastOverride; var flags = 0 /* None */; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 142 /* ReadonlyKeyword */) { - if (node.kind === 162 /* PropertySignature */ || node.kind === 164 /* MethodSignature */) { + if (modifier.kind !== 143 /* ReadonlyKeyword */) { + if (node.kind === 164 /* PropertySignature */ || node.kind === 166 /* MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 171 /* IndexSignature */) { + if (node.kind === 173 /* IndexSignature */ && (modifier.kind !== 124 /* StaticKeyword */ || !ts.isClassLike(node.parent))) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 84 /* ConstKeyword */: - if (node.kind !== 255 /* EnumDeclaration */) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(84 /* ConstKeyword */)); + case 85 /* ConstKeyword */: + if (node.kind !== 257 /* EnumDeclaration */) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(85 /* ConstKeyword */)); } break; - case 122 /* PublicKeyword */: - case 121 /* ProtectedKeyword */: - case 120 /* PrivateKeyword */: + case 157 /* OverrideKeyword */: + // If node.kind === SyntaxKind.Parameter, checkParameter reports an error if it's not a parameter property. + if (flags & 16384 /* Override */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "override"); + } + else if (flags & 2 /* Ambient */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "override", "declare"); + } + else if (flags & 64 /* Readonly */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "override", "readonly"); + } + else if (flags & 256 /* Async */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "override", "async"); + } + flags |= 16384 /* Override */; + lastOverride = modifier; + break; + case 123 /* PublicKeyword */: + case 122 /* ProtectedKeyword */: + case 121 /* PrivateKeyword */: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); if (flags & 28 /* AccessibilityModifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); } + else if (flags & 16384 /* Override */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "override"); + } else if (flags & 32 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } @@ -79656,23 +82541,23 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 257 /* ModuleBlock */ || node.parent.kind === 297 /* SourceFile */) { + else if (node.parent.kind === 259 /* ModuleBlock */ || node.parent.kind === 299 /* 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 === 120 /* PrivateKeyword */) { + if (modifier.kind === 121 /* PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "abstract"); } } - else if (ts.isPrivateIdentifierPropertyDeclaration(node)) { + else if (ts.isPrivateIdentifierClassElementDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics.An_accessibility_modifier_cannot_be_used_with_a_private_identifier); } flags |= ts.modifierToFlag(modifier.kind); break; - case 123 /* StaticKeyword */: + case 124 /* StaticKeyword */: if (flags & 32 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } @@ -79682,33 +82567,33 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 257 /* ModuleBlock */ || node.parent.kind === 297 /* SourceFile */) { + else if (node.parent.kind === 259 /* ModuleBlock */ || node.parent.kind === 299 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 160 /* Parameter */) { + else if (node.kind === 162 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - else if (ts.isPrivateIdentifierPropertyDeclaration(node)) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "static"); + else if (flags & 16384 /* Override */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "override"); } flags |= 32 /* Static */; lastStatic = modifier; break; - case 142 /* ReadonlyKeyword */: + case 143 /* ReadonlyKeyword */: if (flags & 64 /* Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 163 /* PropertyDeclaration */ && node.kind !== 162 /* PropertySignature */ && node.kind !== 171 /* IndexSignature */ && node.kind !== 160 /* Parameter */) { - // If node.kind === SyntaxKind.Parameter, checkParameter report an error if it's not a parameter property. + else if (node.kind !== 165 /* PropertyDeclaration */ && node.kind !== 164 /* PropertySignature */ && node.kind !== 173 /* IndexSignature */ && node.kind !== 162 /* 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 */; lastReadonly = modifier; break; - case 92 /* ExportKeyword */: + case 93 /* ExportKeyword */: if (flags & 1 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -79724,53 +82609,56 @@ var ts; 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 === 160 /* Parameter */) { + else if (node.kind === 162 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; - case 87 /* DefaultKeyword */: - var container = node.parent.kind === 297 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 256 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + case 88 /* DefaultKeyword */: + var container = node.parent.kind === 299 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 258 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } flags |= 512 /* Default */; break; - case 133 /* DeclareKeyword */: + case 134 /* DeclareKeyword */: if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } + else if (flags & 16384 /* 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 === 160 /* Parameter */) { + else if (node.kind === 162 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 8388608 /* Ambient */) && node.parent.kind === 257 /* ModuleBlock */) { + else if ((node.parent.flags & 8388608 /* Ambient */) && node.parent.kind === 259 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } - else if (ts.isPrivateIdentifierPropertyDeclaration(node)) { + else if (ts.isPrivateIdentifierClassElementDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "declare"); } flags |= 2 /* Ambient */; lastDeclare = modifier; break; - case 125 /* AbstractKeyword */: + case 126 /* AbstractKeyword */: if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 252 /* ClassDeclaration */ && - node.kind !== 175 /* ConstructorType */) { - if (node.kind !== 165 /* MethodDeclaration */ && - node.kind !== 163 /* PropertyDeclaration */ && - node.kind !== 167 /* GetAccessor */ && - node.kind !== 168 /* SetAccessor */) { + if (node.kind !== 254 /* ClassDeclaration */ && + node.kind !== 177 /* ConstructorType */) { + if (node.kind !== 167 /* MethodDeclaration */ && + node.kind !== 165 /* PropertyDeclaration */ && + node.kind !== 169 /* GetAccessor */ && + node.kind !== 170 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 252 /* ClassDeclaration */ && ts.hasSyntacticModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 254 /* ClassDeclaration */ && ts.hasSyntacticModifier(node.parent, 128 /* Abstract */))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32 /* Static */) { @@ -79782,20 +82670,23 @@ var ts; if (flags & 256 /* Async */ && lastAsync) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "async", "abstract"); } + if (flags & 16384 /* Override */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "abstract", "override"); + } } - if (ts.isNamedDeclaration(node) && node.name.kind === 79 /* PrivateIdentifier */) { + if (ts.isNamedDeclaration(node) && node.name.kind === 80 /* PrivateIdentifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "abstract"); } flags |= 128 /* Abstract */; break; - case 129 /* AsyncKeyword */: + case 130 /* AsyncKeyword */: if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } else if (flags & 2 /* Ambient */ || node.parent.flags & 8388608 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 160 /* Parameter */) { + else if (node.kind === 162 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } if (flags & 128 /* Abstract */) { @@ -79806,13 +82697,16 @@ var ts; break; } } - if (node.kind === 166 /* Constructor */) { + if (node.kind === 168 /* Constructor */) { if (flags & 32 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } if (flags & 128 /* Abstract */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract"); // TODO: GH#18217 } + if (flags & 16384 /* Override */) { + return grammarErrorOnNode(lastOverride, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "override"); // TODO: GH#18217 + } else if (flags & 256 /* Async */) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); } @@ -79821,13 +82715,13 @@ var ts; } return false; } - else if ((node.kind === 261 /* ImportDeclaration */ || node.kind === 260 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 263 /* ImportDeclaration */ || node.kind === 262 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 160 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 162 /* Parameter */ && (flags & 16476 /* 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 === 160 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 162 /* Parameter */ && (flags & 16476 /* ParameterPropertyModifier */) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256 /* Async */) { @@ -79848,39 +82742,39 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 166 /* Constructor */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 171 /* IndexSignature */: - case 256 /* ModuleDeclaration */: - case 261 /* ImportDeclaration */: - case 260 /* ImportEqualsDeclaration */: - case 267 /* ExportDeclaration */: - case 266 /* ExportAssignment */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 160 /* Parameter */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 168 /* Constructor */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 173 /* IndexSignature */: + case 258 /* ModuleDeclaration */: + case 263 /* ImportDeclaration */: + case 262 /* ImportEqualsDeclaration */: + case 269 /* ExportDeclaration */: + case 268 /* ExportAssignment */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 162 /* Parameter */: return false; default: - if (node.parent.kind === 257 /* ModuleBlock */ || node.parent.kind === 297 /* SourceFile */) { + if (node.parent.kind === 259 /* ModuleBlock */ || node.parent.kind === 299 /* SourceFile */) { return false; } switch (node.kind) { - case 251 /* FunctionDeclaration */: - return nodeHasAnyModifiersExcept(node, 129 /* AsyncKeyword */); - case 252 /* ClassDeclaration */: - case 175 /* ConstructorType */: - return nodeHasAnyModifiersExcept(node, 125 /* AbstractKeyword */); - case 253 /* InterfaceDeclaration */: - case 232 /* VariableStatement */: - case 254 /* TypeAliasDeclaration */: + case 253 /* FunctionDeclaration */: + return nodeHasAnyModifiersExcept(node, 130 /* AsyncKeyword */); + case 254 /* ClassDeclaration */: + case 177 /* ConstructorType */: + return nodeHasAnyModifiersExcept(node, 126 /* AbstractKeyword */); + case 255 /* InterfaceDeclaration */: + case 234 /* VariableStatement */: + case 256 /* TypeAliasDeclaration */: return true; - case 255 /* EnumDeclaration */: - return nodeHasAnyModifiersExcept(node, 84 /* ConstKeyword */); + case 257 /* EnumDeclaration */: + return nodeHasAnyModifiersExcept(node, 85 /* ConstKeyword */); default: ts.Debug.fail(); } @@ -79891,10 +82785,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 165 /* MethodDeclaration */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -80013,7 +82907,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 147 /* StringKeyword */ && parameter.type.kind !== 144 /* NumberKeyword */) { + if (parameter.type.kind !== 148 /* StringKeyword */ && parameter.type.kind !== 145 /* NumberKeyword */) { var type = getTypeFromTypeNode(parameter.type); if (type.flags & 4 /* String */ || type.flags & 8 /* Number */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead, ts.getTextOfNode(parameter.name), typeToString(type), typeToString(node.type ? getTypeFromTypeNode(node.type) : anyType)); @@ -80055,7 +82949,7 @@ var ts; if (args) { for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 222 /* OmittedExpression */) { + if (arg.kind === 224 /* OmittedExpression */) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -80085,7 +82979,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 === 93 /* ExtendsKeyword */) { + if (heritageClause.token === 94 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -80098,7 +82992,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 116 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 117 /* ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -80114,14 +83008,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 93 /* ExtendsKeyword */) { + if (heritageClause.token === 94 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 116 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 117 /* ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -80132,20 +83026,20 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 158 /* ComputedPropertyName */) { + if (node.kind !== 160 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 216 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* CommaToken */) { + if (computedPropertyName.expression.kind === 218 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* 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 === 251 /* FunctionDeclaration */ || - node.kind === 208 /* FunctionExpression */ || - node.kind === 165 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 253 /* FunctionDeclaration */ || + node.kind === 210 /* FunctionExpression */ || + node.kind === 167 /* MethodDeclaration */); if (node.flags & 8388608 /* Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -80164,7 +83058,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 === 290 /* SpreadAssignment */) { + if (prop.kind === 292 /* SpreadAssignment */) { if (inDestructuring) { // a rest property cannot be destructured any further var expression = ts.skipParentheses(prop.expression); @@ -80175,24 +83069,24 @@ var ts; continue; } var name = prop.name; - if (name.kind === 158 /* ComputedPropertyName */) { + if (name.kind === 160 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 289 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 291 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern // outside of destructuring it is a syntax error return 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 === 79 /* PrivateIdentifier */) { - return grammarErrorOnNode(name, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); + if (name.kind === 80 /* 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 (prop.modifiers) { // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { // TODO: GH#19955 var mod = _c[_b]; - if (mod.kind !== 129 /* AsyncKeyword */ || prop.kind !== 165 /* MethodDeclaration */) { + if (mod.kind !== 130 /* AsyncKeyword */ || prop.kind !== 167 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -80207,10 +83101,10 @@ 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 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); // falls through - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8 /* NumericLiteral */) { @@ -80218,13 +83112,13 @@ var ts; } currentKind = 4 /* PropertyAssignment */; break; - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: currentKind = 8 /* Method */; break; - case 167 /* GetAccessor */: + case 169 /* GetAccessor */: currentKind = 1 /* GetAccessor */; break; - case 168 /* SetAccessor */: + case 170 /* SetAccessor */: currentKind = 2 /* SetAccessor */; break; default: @@ -80259,11 +83153,12 @@ var ts; } } function checkGrammarJsxElement(node) { + checkGrammarJsxName(node.tagName); checkGrammarTypeArguments(node, node.typeArguments); var seen = new ts.Map(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 282 /* JsxSpreadAttribute */) { + if (attr.kind === 284 /* JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -80273,11 +83168,32 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 283 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 285 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } } + function checkGrammarJsxName(node) { + if (ts.isPropertyAccessExpression(node)) { + var propName = node; + do { + var check_1 = checkGrammarJsxNestedIdentifier(propName.name); + if (check_1) { + return check_1; + } + propName = propName.expression; + } while (ts.isPropertyAccessExpression(propName)); + var check = checkGrammarJsxNestedIdentifier(propName); + if (check) { + return check; + } + } + function checkGrammarJsxNestedIdentifier(name) { + if (ts.isIdentifier(name) && ts.idText(name).indexOf(":") !== -1) { + return grammarErrorOnNode(name, ts.Diagnostics.JSX_property_access_expressions_cannot_include_JSX_namespace_names); + } + } + } function checkGrammarJsxExpression(node) { if (node.expression && ts.isCommaSequence(node.expression)) { return grammarErrorOnNode(node.expression, ts.Diagnostics.JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array); @@ -80287,25 +83203,42 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 239 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { - if ((forInOrOfStatement.flags & 32768 /* AwaitContext */) === 0 /* None */) { - // use of 'for-await-of' in non-async function + if (forInOrOfStatement.kind === 241 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if (!(forInOrOfStatement.flags & 32768 /* AwaitContext */)) { var sourceFile = ts.getSourceFileOfNode(forInOrOfStatement); - if (!hasParseDiagnostics(sourceFile)) { - var diagnostic = ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); - var func = ts.getContainingFunction(forInOrOfStatement); - if (func && func.kind !== 166 /* Constructor */) { - ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* 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); - } - diagnostics.add(diagnostic); - return true; + if (ts.isInTopLevelContext(forInOrOfStatement)) { + if (!hasParseDiagnostics(sourceFile)) { + if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) { + diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module)); + } + if ((moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) || languageVersion < 4 /* ES2017 */) { + diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher)); + } + } + } + else { + // use of 'for-await-of' in non-async function + 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 !== 168 /* Constructor */) { + ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* 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); + } + diagnostics.add(diagnostic); + return true; + } } return false; } } - if (forInOrOfStatement.initializer.kind === 250 /* VariableDeclarationList */) { + if (ts.isForOfStatement(forInOrOfStatement) && !(forInOrOfStatement.flags & 32768 /* 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 === 252 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -80320,20 +83253,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 238 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 240 /* 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 === 238 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 240 /* 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 === 238 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 240 /* 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); @@ -80343,26 +83276,34 @@ var ts; return false; } function checkGrammarAccessor(accessor) { - if (!(accessor.flags & 8388608 /* Ambient */)) { + if (!(accessor.flags & 8388608 /* Ambient */) && (accessor.parent.kind !== 179 /* TypeLiteral */) && (accessor.parent.kind !== 255 /* InterfaceDeclaration */)) { if (languageVersion < 1 /* 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)) { + 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 */)) { return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } } - if (accessor.body && ts.hasSyntacticModifier(accessor, 128 /* Abstract */)) { - return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation); + if (accessor.body) { + if (ts.hasSyntacticModifier(accessor, 128 /* Abstract */)) { + return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation); + } + if (accessor.parent.kind === 179 /* TypeLiteral */ || accessor.parent.kind === 255 /* InterfaceDeclaration */) { + return grammarErrorOnNode(accessor.body, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); + } } if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, accessor.kind === 167 /* GetAccessor */ ? + return grammarErrorOnNode(accessor.name, accessor.kind === 169 /* GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - if (accessor.kind === 168 /* SetAccessor */) { + if (accessor.kind === 170 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -80384,17 +83325,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 === 167 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 169 /* GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 167 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 169 /* GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } function checkGrammarTypeOperatorNode(node) { - if (node.operator === 151 /* UniqueKeyword */) { - if (node.type.kind !== 148 /* SymbolKeyword */) { - return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(148 /* SymbolKeyword */)); + if (node.operator === 152 /* UniqueKeyword */) { + if (node.type.kind !== 149 /* SymbolKeyword */) { + return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(149 /* SymbolKeyword */)); } var parent = ts.walkUpParenthesizedTypes(node.parent); if (ts.isInJSFile(parent) && ts.isJSDocTypeExpression(parent)) { @@ -80405,9 +83346,9 @@ var ts; } } switch (parent.kind) { - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: var decl = parent; - if (decl.name.kind !== 78 /* Identifier */) { + if (decl.name.kind !== 79 /* 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)) { @@ -80417,13 +83358,13 @@ var ts; return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: if (!ts.hasSyntacticModifier(parent, 32 /* Static */) || !ts.hasEffectiveModifier(parent, 64 /* Readonly */)) { 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 162 /* PropertySignature */: + case 164 /* PropertySignature */: if (!ts.hasSyntacticModifier(parent, 64 /* 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); } @@ -80432,9 +83373,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_not_allowed_here); } } - else if (node.operator === 142 /* ReadonlyKeyword */) { - if (node.type.kind !== 178 /* ArrayType */ && node.type.kind !== 179 /* TupleType */) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(148 /* SymbolKeyword */)); + else if (node.operator === 143 /* ReadonlyKeyword */) { + if (node.type.kind !== 180 /* ArrayType */ && node.type.kind !== 181 /* TupleType */) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(149 /* SymbolKeyword */)); } } } @@ -80447,10 +83388,10 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 165 /* MethodDeclaration */) { - if (node.parent.kind === 200 /* ObjectLiteralExpression */) { + if (node.kind === 167 /* MethodDeclaration */) { + if (node.parent.kind === 202 /* 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 === 129 /* AsyncKeyword */)) { + if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 130 /* AsyncKeyword */)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } else if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { @@ -80468,6 +83409,9 @@ var ts; } } if (ts.isClassLike(node.parent)) { + if (languageVersion < 2 /* 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 // for property declarations and accessors too, not just methods. // However, property declarations disallow computed names in general, @@ -80476,14 +83420,14 @@ var ts; if (node.flags & 8388608 /* 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 === 165 /* MethodDeclaration */ && !node.body) { + else if (node.kind === 167 /* 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 === 253 /* InterfaceDeclaration */) { + else if (node.parent.kind === 255 /* 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 === 177 /* TypeLiteral */) { + else if (node.parent.kind === 179 /* 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); } } @@ -80494,11 +83438,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 245 /* LabeledStatement */: + case 247 /* 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 === 240 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 242 /* 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); @@ -80506,8 +83450,8 @@ var ts; return false; } break; - case 244 /* SwitchStatement */: - if (node.kind === 241 /* BreakStatement */ && !node.label) { + case 246 /* SwitchStatement */: + if (node.kind === 243 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -80522,13 +83466,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 241 /* BreakStatement */ + var message = node.kind === 243 /* 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 === 241 /* BreakStatement */ + var message = node.kind === 243 /* 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); @@ -80552,12 +83496,12 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return ts.isStringOrNumericLiteralLike(expr) || - expr.kind === 214 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && + expr.kind === 216 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function isBigIntLiteralExpression(expr) { return expr.kind === 9 /* BigIntLiteral */ || - expr.kind === 214 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && + expr.kind === 216 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && expr.operand.kind === 9 /* BigIntLiteral */; } function isSimpleLiteralEnumReference(expr) { @@ -80571,7 +83515,7 @@ var ts; if (initializer) { var isInvalidInitializer = !(isStringOrNumberLiteralExpression(initializer) || isSimpleLiteralEnumReference(initializer) || - initializer.kind === 109 /* TrueKeyword */ || initializer.kind === 94 /* FalseKeyword */ || + initializer.kind === 110 /* TrueKeyword */ || initializer.kind === 95 /* FalseKeyword */ || isBigIntLiteralExpression(initializer)); var isConstOrReadonly = ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node); if (isConstOrReadonly && !node.type) { @@ -80588,7 +83532,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 238 /* ForInStatement */ && node.parent.parent.kind !== 239 /* ForOfStatement */) { + if (node.parent.parent.kind !== 240 /* ForInStatement */ && node.parent.parent.kind !== 241 /* ForOfStatement */) { if (node.flags & 8388608 /* Ambient */) { checkAmbientInitializer(node); } @@ -80601,7 +83545,7 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 232 /* VariableStatement */ || !node.type || node.initializer || node.flags & 8388608 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 234 /* VariableStatement */ || !node.type || node.initializer || node.flags & 8388608 /* Ambient */)) { var message = node.initializer ? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions : !node.type @@ -80624,7 +83568,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkESModuleMarker(name) { - if (name.kind === 78 /* Identifier */) { + if (name.kind === 79 /* 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); } @@ -80641,8 +83585,8 @@ var ts; return false; } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 78 /* Identifier */) { - if (name.originalKeywordKind === 118 /* LetKeyword */) { + if (name.kind === 79 /* Identifier */) { + if (name.originalKeywordKind === 119 /* LetKeyword */) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -80669,15 +83613,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 234 /* IfStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: - case 243 /* WithStatement */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: + case 236 /* IfStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: + case 245 /* WithStatement */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: return false; - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -80695,12 +83639,12 @@ var ts; function checkGrammarMetaProperty(node) { var escapedText = node.name.escapedText; switch (node.keywordToken) { - case 102 /* NewKeyword */: + case 103 /* 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 99 /* ImportKeyword */: + case 100 /* 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"); } @@ -80762,14 +83706,14 @@ var ts; if (ts.isStringLiteral(node.name) && node.name.text === "constructor") { return grammarErrorOnNode(node.name, ts.Diagnostics.Classes_may_not_have_a_field_named_constructor); } - if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { + 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)) { return grammarErrorOnNode(node.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher); } } - else if (node.parent.kind === 253 /* InterfaceDeclaration */) { + else if (node.parent.kind === 255 /* 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; } @@ -80777,7 +83721,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 177 /* TypeLiteral */) { + else if (node.parent.kind === 179 /* TypeLiteral */) { if (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)) { return true; } @@ -80811,13 +83755,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 253 /* InterfaceDeclaration */ || - node.kind === 254 /* TypeAliasDeclaration */ || - node.kind === 261 /* ImportDeclaration */ || - node.kind === 260 /* ImportEqualsDeclaration */ || - node.kind === 267 /* ExportDeclaration */ || - node.kind === 266 /* ExportAssignment */ || - node.kind === 259 /* NamespaceExportDeclaration */ || + if (node.kind === 255 /* InterfaceDeclaration */ || + node.kind === 256 /* TypeAliasDeclaration */ || + node.kind === 263 /* ImportDeclaration */ || + node.kind === 262 /* ImportEqualsDeclaration */ || + node.kind === 269 /* ExportDeclaration */ || + node.kind === 268 /* ExportAssignment */ || + node.kind === 261 /* NamespaceExportDeclaration */ || ts.hasSyntacticModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -80826,7 +83770,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 === 232 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 234 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -80849,7 +83793,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 === 230 /* Block */ || node.parent.kind === 257 /* ModuleBlock */ || node.parent.kind === 297 /* SourceFile */) { + if (node.parent.kind === 232 /* Block */ || node.parent.kind === 259 /* ModuleBlock */ || node.parent.kind === 299 /* SourceFile */) { var links_2 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_2.hasReportedStatementInAmbientContext) { @@ -80871,10 +83815,10 @@ var ts; if (languageVersion >= 1 /* ES5 */) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 191 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 193 /* LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 291 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 293 /* EnumMember */)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { @@ -80980,7 +83924,7 @@ var ts; } } function findBestTypeForObjectLiteral(source, unionTarget) { - if (ts.getObjectFlags(source) & 128 /* ObjectLiteral */ && forEachType(unionTarget, isArrayLikeType)) { + if (ts.getObjectFlags(source) & 128 /* ObjectLiteral */ && someType(unionTarget, isArrayLikeType)) { return ts.find(unionTarget.types, function (t) { return !isArrayLikeType(t); }); } } @@ -81032,6 +83976,10 @@ 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 */)) { + var match = getMatchingUnionConstituentForType(target, source); + if (match) { + return match; + } var sourceProperties = getPropertiesOfType(source); if (sourceProperties) { var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target); @@ -81049,33 +83997,19 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 251 /* FunctionDeclaration */ && declaration.kind !== 165 /* MethodDeclaration */) || + return (declaration.kind !== 253 /* FunctionDeclaration */ && declaration.kind !== 167 /* 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 265 /* ImportSpecifier */: - case 270 /* ExportSpecifier */: + case 267 /* ImportSpecifier */: + case 272 /* ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); } } - function isSomeImportDeclaration(decl) { - switch (decl.kind) { - case 262 /* ImportClause */: // For default import - case 260 /* ImportEqualsDeclaration */: - case 263 /* NamespaceImport */: - case 265 /* ImportSpecifier */: // For rename import `x as y` - return true; - case 78 /* Identifier */: - // For regular import, `decl` is an Identifier under the ImportSpecifier. - return decl.parent.kind === 265 /* ImportSpecifier */; - default: - return false; - } - } var JsxNames; (function (JsxNames) { JsxNames.JSX = "JSX"; @@ -81106,7 +84040,6 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var isTypeNodeOrTypeParameterDeclaration = ts.or(ts.isTypeNode, ts.isTypeParameterDeclaration); function visitNode(node, visitor, test, lift) { if (node === undefined || visitor === undefined) { return node; @@ -81295,6 +84228,24 @@ var ts; return updated; } ts.visitFunctionBody = visitFunctionBody; + /** + * Visits an iteration body, adding any block-scoped variables required by the transformation. + */ + function visitIterationBody(body, visitor, context) { + context.startBlockScope(); + var updated = visitNode(body, visitor, ts.isStatement, context.factory.liftToBlock); + var declarations = context.endBlockScope(); + if (ts.some(declarations)) { + if (ts.isBlock(updated)) { + declarations.push.apply(declarations, updated.statements); + return context.factory.updateBlock(updated, declarations); + } + declarations.push(updated); + return context.factory.createBlock(declarations); + } + return updated; + } + ts.visitIterationBody = visitIterationBody; function visitEachChild(node, visitor, context, nodesVisitor, tokenVisitor, nodeVisitor) { if (nodesVisitor === void 0) { nodesVisitor = visitNodes; } if (nodeVisitor === void 0) { nodeVisitor = visitNode; } @@ -81303,299 +84254,433 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 156 /* LastToken */) || kind === 187 /* ThisType */) { + if ((kind > 0 /* FirstToken */ && kind <= 158 /* LastToken */) || kind === 189 /* ThisType */) { return node; } var factory = context.factory; switch (kind) { // Names - case 78 /* Identifier */: - return factory.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration)); - case 157 /* QualifiedName */: + case 79 /* Identifier */: + ts.Debug.type(node); + return factory.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNodeOrTypeParameterDeclaration)); + case 159 /* QualifiedName */: + ts.Debug.type(node); return factory.updateQualifiedName(node, nodeVisitor(node.left, visitor, ts.isEntityName), nodeVisitor(node.right, visitor, ts.isIdentifier)); - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: + ts.Debug.type(node); return factory.updateComputedPropertyName(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Signature elements - case 159 /* TypeParameter */: + case 161 /* TypeParameter */: + ts.Debug.type(node); return factory.updateTypeParameterDeclaration(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.constraint, visitor, ts.isTypeNode), nodeVisitor(node.default, visitor, ts.isTypeNode)); - case 160 /* Parameter */: - return factory.updateParameterDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isToken), nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 161 /* Decorator */: + case 162 /* Parameter */: + ts.Debug.type(node); + return factory.updateParameterDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), 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 163 /* Decorator */: + ts.Debug.type(node); return factory.updateDecorator(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Type elements - case 162 /* PropertySignature */: - return factory.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isToken), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 163 /* PropertyDeclaration */: + case 164 /* 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 165 /* PropertyDeclaration */: + ts.Debug.type(node); return factory.updatePropertyDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), 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.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 164 /* MethodSignature */: - return factory.updateMethodSignature(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 165 /* MethodDeclaration */: - return factory.updateMethodDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isToken), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), 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 166 /* Constructor */: + nodeVisitor(node.questionToken || node.exclamationToken, tokenVisitor, ts.isQuestionOrExclamationToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); + case 166 /* 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 167 /* MethodDeclaration */: + ts.Debug.type(node); + return factory.updateMethodDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), 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 168 /* Constructor */: + ts.Debug.type(node); return factory.updateConstructorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 167 /* GetAccessor */: + case 169 /* GetAccessor */: + ts.Debug.type(node); return factory.updateGetAccessorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), 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 168 /* SetAccessor */: + case 170 /* SetAccessor */: + ts.Debug.type(node); return factory.updateSetAccessorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 169 /* CallSignature */: + case 171 /* 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 170 /* ConstructSignature */: + case 172 /* 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 171 /* IndexSignature */: + case 173 /* IndexSignature */: + ts.Debug.type(node); return factory.updateIndexSignature(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); // Types - case 172 /* TypePredicate */: - return factory.updateTypePredicateNode(node, nodeVisitor(node.assertsModifier, visitor), nodeVisitor(node.parameterName, visitor), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 173 /* TypeReference */: + case 174 /* 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 175 /* TypeReference */: + ts.Debug.type(node); return factory.updateTypeReferenceNode(node, nodeVisitor(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 174 /* FunctionType */: + case 176 /* 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 175 /* ConstructorType */: + case 177 /* 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 176 /* TypeQuery */: + case 178 /* TypeQuery */: + ts.Debug.type(node); return factory.updateTypeQueryNode(node, nodeVisitor(node.exprName, visitor, ts.isEntityName)); - case 177 /* TypeLiteral */: + case 179 /* TypeLiteral */: + ts.Debug.type(node); return factory.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 178 /* ArrayType */: + case 180 /* ArrayType */: + ts.Debug.type(node); return factory.updateArrayTypeNode(node, nodeVisitor(node.elementType, visitor, ts.isTypeNode)); - case 179 /* TupleType */: + case 181 /* TupleType */: + ts.Debug.type(node); return factory.updateTupleTypeNode(node, nodesVisitor(node.elements, visitor, ts.isTypeNode)); - case 180 /* OptionalType */: + case 182 /* OptionalType */: + ts.Debug.type(node); return factory.updateOptionalTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 181 /* RestType */: + case 183 /* RestType */: + ts.Debug.type(node); return factory.updateRestTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 182 /* UnionType */: + case 184 /* UnionType */: + ts.Debug.type(node); return factory.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 183 /* IntersectionType */: + case 185 /* IntersectionType */: + ts.Debug.type(node); return factory.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 184 /* ConditionalType */: + case 186 /* 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 185 /* InferType */: + case 187 /* InferType */: + ts.Debug.type(node); return factory.updateInferTypeNode(node, nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 195 /* ImportType */: + case 197 /* ImportType */: + ts.Debug.type(node); return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); - case 192 /* NamedTupleMember */: - return factory.updateNamedTupleMember(node, visitNode(node.dotDotDotToken, visitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode)); - case 186 /* ParenthesizedType */: + case 194 /* 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 188 /* ParenthesizedType */: + ts.Debug.type(node); return factory.updateParenthesizedType(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 188 /* TypeOperator */: + case 190 /* TypeOperator */: + ts.Debug.type(node); return factory.updateTypeOperatorNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 189 /* IndexedAccessType */: + case 191 /* IndexedAccessType */: + ts.Debug.type(node); return factory.updateIndexedAccessTypeNode(node, nodeVisitor(node.objectType, visitor, ts.isTypeNode), nodeVisitor(node.indexType, visitor, ts.isTypeNode)); - case 190 /* MappedType */: - return factory.updateMappedTypeNode(node, nodeVisitor(node.readonlyToken, tokenVisitor, ts.isToken), nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration), nodeVisitor(node.nameType, visitor, ts.isTypeNode), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 191 /* LiteralType */: + case 192 /* 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)); + case 193 /* LiteralType */: + ts.Debug.type(node); return factory.updateLiteralTypeNode(node, nodeVisitor(node.literal, visitor, ts.isExpression)); - case 193 /* TemplateLiteralType */: + case 195 /* TemplateLiteralType */: + ts.Debug.type(node); return factory.updateTemplateLiteralType(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateLiteralTypeSpan)); - case 194 /* TemplateLiteralTypeSpan */: + case 196 /* TemplateLiteralTypeSpan */: + ts.Debug.type(node); return factory.updateTemplateLiteralTypeSpan(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Binding patterns - case 196 /* ObjectBindingPattern */: + case 198 /* ObjectBindingPattern */: + ts.Debug.type(node); return factory.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 197 /* ArrayBindingPattern */: + case 199 /* ArrayBindingPattern */: + ts.Debug.type(node); return factory.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 198 /* BindingElement */: - return factory.updateBindingElement(node, nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isToken), nodeVisitor(node.propertyName, visitor, ts.isPropertyName), nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.initializer, visitor, ts.isExpression)); + case 200 /* 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 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: + ts.Debug.type(node); return factory.updateArrayLiteralExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: + ts.Debug.type(node); return factory.updateObjectLiteralExpression(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: if (node.flags & 32 /* OptionalChain */) { - return factory.updatePropertyAccessChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isToken), nodeVisitor(node.name, visitor, ts.isIdentifier)); + 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)); } - return factory.updatePropertyAccessExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.name, visitor, ts.isIdentifierOrPrivateIdentifier)); - case 202 /* ElementAccessExpression */: + ts.Debug.type(node); + return factory.updatePropertyAccessExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.name, visitor, ts.isMemberName)); + case 204 /* ElementAccessExpression */: if (node.flags & 32 /* OptionalChain */) { - return factory.updateElementAccessChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isToken), nodeVisitor(node.argumentExpression, visitor, ts.isExpression)); + 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 203 /* CallExpression */: + case 205 /* CallExpression */: if (node.flags & 32 /* OptionalChain */) { - return factory.updateCallChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); + 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 204 /* NewExpression */: + case 206 /* 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 205 /* TaggedTemplateExpression */: - return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), nodeVisitor(node.template, visitor, ts.isTemplateLiteral)); - case 206 /* TypeAssertionExpression */: + case 207 /* 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 208 /* TypeAssertionExpression */: + ts.Debug.type(node); return factory.updateTypeAssertion(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: + ts.Debug.type(node); return factory.updateParenthesizedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 208 /* FunctionExpression */: - return factory.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isToken), 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 209 /* ArrowFunction */: - 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.isToken), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 210 /* DeleteExpression */: + case 210 /* 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 211 /* 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 212 /* DeleteExpression */: + ts.Debug.type(node); return factory.updateDeleteExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 211 /* TypeOfExpression */: + case 213 /* TypeOfExpression */: + ts.Debug.type(node); return factory.updateTypeOfExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 212 /* VoidExpression */: + case 214 /* VoidExpression */: + ts.Debug.type(node); return factory.updateVoidExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 213 /* AwaitExpression */: + case 215 /* AwaitExpression */: + ts.Debug.type(node); return factory.updateAwaitExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: + ts.Debug.type(node); return factory.updatePrefixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression)); - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: + ts.Debug.type(node); return factory.updatePostfixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression)); - case 216 /* BinaryExpression */: - return factory.updateBinaryExpression(node, nodeVisitor(node.left, visitor, ts.isExpression), nodeVisitor(node.operatorToken, tokenVisitor, ts.isToken), nodeVisitor(node.right, visitor, ts.isExpression)); - case 217 /* ConditionalExpression */: - return factory.updateConditionalExpression(node, nodeVisitor(node.condition, visitor, ts.isExpression), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.whenTrue, visitor, ts.isExpression), nodeVisitor(node.colonToken, tokenVisitor, ts.isToken), nodeVisitor(node.whenFalse, visitor, ts.isExpression)); - case 218 /* TemplateExpression */: + case 218 /* 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 219 /* 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 220 /* TemplateExpression */: + ts.Debug.type(node); return factory.updateTemplateExpression(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 219 /* YieldExpression */: - return factory.updateYieldExpression(node, nodeVisitor(node.asteriskToken, tokenVisitor, ts.isToken), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 220 /* SpreadElement */: + case 221 /* YieldExpression */: + ts.Debug.type(node); + return factory.updateYieldExpression(node, nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.expression, visitor, ts.isExpression)); + case 222 /* SpreadElement */: + ts.Debug.type(node); return factory.updateSpreadElement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: + ts.Debug.type(node); return factory.updateClassExpression(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), 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.isClassElement)); - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: + ts.Debug.type(node); return factory.updateExpressionWithTypeArguments(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 224 /* AsExpression */: + case 226 /* AsExpression */: + ts.Debug.type(node); return factory.updateAsExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 225 /* NonNullExpression */: + case 227 /* NonNullExpression */: if (node.flags & 32 /* 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 226 /* MetaProperty */: + case 228 /* MetaProperty */: + ts.Debug.type(node); return factory.updateMetaProperty(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); // Misc - case 228 /* TemplateSpan */: + case 230 /* TemplateSpan */: + ts.Debug.type(node); return factory.updateTemplateSpan(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 230 /* Block */: + case 232 /* Block */: + ts.Debug.type(node); return factory.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: + ts.Debug.type(node); return factory.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: + ts.Debug.type(node); return factory.updateExpressionStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 234 /* IfStatement */: + case 236 /* 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 235 /* DoStatement */: - return factory.updateDoStatement(node, nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 236 /* WhileStatement */: - return factory.updateWhileStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 237 /* ForStatement */: - return factory.updateForStatement(node, nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.condition, visitor, ts.isExpression), nodeVisitor(node.incrementor, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 238 /* ForInStatement */: - return factory.updateForInStatement(node, nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 239 /* ForOfStatement */: - return factory.updateForOfStatement(node, nodeVisitor(node.awaitModifier, tokenVisitor, ts.isToken), nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 240 /* ContinueStatement */: + case 237 /* DoStatement */: + ts.Debug.type(node); + return factory.updateDoStatement(node, visitIterationBody(node.statement, visitor, context), nodeVisitor(node.expression, visitor, ts.isExpression)); + case 238 /* WhileStatement */: + ts.Debug.type(node); + return factory.updateWhileStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); + case 239 /* 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 240 /* 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 241 /* 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 242 /* ContinueStatement */: + ts.Debug.type(node); return factory.updateContinueStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier)); - case 241 /* BreakStatement */: + case 243 /* BreakStatement */: + ts.Debug.type(node); return factory.updateBreakStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier)); - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: + ts.Debug.type(node); return factory.updateReturnStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 243 /* WithStatement */: + case 245 /* WithStatement */: + ts.Debug.type(node); return factory.updateWithStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: + ts.Debug.type(node); return factory.updateSwitchStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.caseBlock, visitor, ts.isCaseBlock)); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: + ts.Debug.type(node); return factory.updateLabeledStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 246 /* ThrowStatement */: + case 248 /* ThrowStatement */: + ts.Debug.type(node); return factory.updateThrowStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 247 /* TryStatement */: + case 249 /* 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 249 /* VariableDeclaration */: - return factory.updateVariableDeclaration(node, nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.exclamationToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 250 /* VariableDeclarationList */: + case 251 /* 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 252 /* VariableDeclarationList */: + ts.Debug.type(node); return factory.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 251 /* FunctionDeclaration */: - return factory.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isToken), 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 252 /* ClassDeclaration */: + case 253 /* FunctionDeclaration */: + ts.Debug.type(node); + return factory.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), 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 254 /* ClassDeclaration */: + ts.Debug.type(node); return factory.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), 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.isClassElement)); - case 253 /* InterfaceDeclaration */: + case 255 /* InterfaceDeclaration */: + ts.Debug.type(node); return factory.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), 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 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: + ts.Debug.type(node); return factory.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), 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 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: + ts.Debug.type(node); return factory.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); - case 256 /* ModuleDeclaration */: - return factory.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.body, visitor, ts.isModuleBody)); - case 257 /* ModuleBlock */: + case 258 /* ModuleDeclaration */: + ts.Debug.type(node); + return factory.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isModuleName), nodeVisitor(node.body, visitor, ts.isModuleBody)); + case 259 /* ModuleBlock */: + ts.Debug.type(node); return factory.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 258 /* CaseBlock */: + case 260 /* CaseBlock */: + ts.Debug.type(node); return factory.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 259 /* NamespaceExportDeclaration */: + case 261 /* NamespaceExportDeclaration */: + ts.Debug.type(node); return factory.updateNamespaceExportDeclaration(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: + ts.Debug.type(node); return factory.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.moduleReference, visitor, ts.isModuleReference)); - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: + ts.Debug.type(node); return factory.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.importClause, visitor, ts.isImportClause), nodeVisitor(node.moduleSpecifier, visitor, ts.isExpression)); - case 262 /* ImportClause */: + case 264 /* ImportClause */: + ts.Debug.type(node); return factory.updateImportClause(node, node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: + ts.Debug.type(node); return factory.updateNamespaceImport(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 269 /* NamespaceExport */: + case 271 /* NamespaceExport */: + ts.Debug.type(node); return factory.updateNamespaceExport(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 264 /* NamedImports */: + case 266 /* NamedImports */: + ts.Debug.type(node); return factory.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 265 /* ImportSpecifier */: + case 267 /* ImportSpecifier */: + ts.Debug.type(node); return factory.updateImportSpecifier(node, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: + ts.Debug.type(node); return factory.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: + ts.Debug.type(node); return factory.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), node.isTypeOnly, nodeVisitor(node.exportClause, visitor, ts.isNamedExportBindings), nodeVisitor(node.moduleSpecifier, visitor, ts.isExpression)); - case 268 /* NamedExports */: + case 270 /* NamedExports */: + ts.Debug.type(node); return factory.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 270 /* ExportSpecifier */: + case 272 /* ExportSpecifier */: + ts.Debug.type(node); return factory.updateExportSpecifier(node, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier)); // Module references - case 272 /* ExternalModuleReference */: + case 274 /* ExternalModuleReference */: + ts.Debug.type(node); return factory.updateExternalModuleReference(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // JSX - case 273 /* JsxElement */: + case 275 /* 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 274 /* JsxSelfClosingElement */: + case 276 /* 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 275 /* JsxOpeningElement */: + case 277 /* 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 276 /* JsxClosingElement */: + case 278 /* JsxClosingElement */: + ts.Debug.type(node); return factory.updateJsxClosingElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 277 /* JsxFragment */: + case 279 /* 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 280 /* JsxAttribute */: + case 282 /* JsxAttribute */: + ts.Debug.type(node); return factory.updateJsxAttribute(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 281 /* JsxAttributes */: + case 283 /* JsxAttributes */: + ts.Debug.type(node); return factory.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 282 /* JsxSpreadAttribute */: + case 284 /* JsxSpreadAttribute */: + ts.Debug.type(node); return factory.updateJsxSpreadAttribute(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: + ts.Debug.type(node); return factory.updateJsxExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Clauses - case 284 /* CaseClause */: + case 286 /* CaseClause */: + ts.Debug.type(node); return factory.updateCaseClause(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 285 /* DefaultClause */: + case 287 /* DefaultClause */: + ts.Debug.type(node); return factory.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 286 /* HeritageClause */: + case 288 /* HeritageClause */: + ts.Debug.type(node); return factory.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 287 /* CatchClause */: + case 289 /* CatchClause */: + ts.Debug.type(node); return factory.updateCatchClause(node, nodeVisitor(node.variableDeclaration, visitor, ts.isVariableDeclaration), nodeVisitor(node.block, visitor, ts.isBlock)); // Property assignments - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: + ts.Debug.type(node); return factory.updatePropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: + ts.Debug.type(node); return factory.updateShorthandPropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 290 /* SpreadAssignment */: + case 292 /* SpreadAssignment */: + ts.Debug.type(node); return factory.updateSpreadAssignment(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Enum - case 291 /* EnumMember */: + case 293 /* 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 297 /* SourceFile */: + case 299 /* SourceFile */: + ts.Debug.type(node); return factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 336 /* PartiallyEmittedExpression */: + case 344 /* PartiallyEmittedExpression */: + ts.Debug.type(node); return factory.updatePartiallyEmittedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 337 /* CommaListExpression */: + case 345 /* CommaListExpression */: + ts.Debug.type(node); return factory.updateCommaListExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: // No need to visit nodes with no children. @@ -81627,6 +84712,7 @@ var ts; var sourcesContent; var names = []; var nameToNameIndexMap; + var mappingCharCodes = []; var mappings = ""; // Last recorded and encoded mappings var lastGeneratedLine = 0; @@ -81801,6 +84887,14 @@ var ts; || lastSourceCharacter !== pendingSourceCharacter || lastNameIndex !== pendingNameIndex; } + function appendMappingCharCode(charCode) { + mappingCharCodes.push(charCode); + // String.fromCharCode accepts its arguments on the stack, so we have to chunk the input, + // otherwise we can get stack overflows for large source maps + if (mappingCharCodes.length >= 1024) { + flushMappingBuffer(); + } + } function commitPendingMapping() { if (!hasPending || !shouldCommitMapping()) { return; @@ -81810,42 +84904,50 @@ var ts; if (lastGeneratedLine < pendingGeneratedLine) { // Emit line delimiters do { - mappings += ";"; + appendMappingCharCode(59 /* semicolon */); lastGeneratedLine++; - lastGeneratedCharacter = 0; } while (lastGeneratedLine < pendingGeneratedLine); + // Only need to set this once + lastGeneratedCharacter = 0; } else { ts.Debug.assertEqual(lastGeneratedLine, pendingGeneratedLine, "generatedLine cannot backtrack"); // Emit comma to separate the entry if (hasLast) { - mappings += ","; + appendMappingCharCode(44 /* comma */); } } // 1. Relative generated character - mappings += base64VLQFormatEncode(pendingGeneratedCharacter - lastGeneratedCharacter); + appendBase64VLQ(pendingGeneratedCharacter - lastGeneratedCharacter); lastGeneratedCharacter = pendingGeneratedCharacter; if (hasPendingSource) { // 2. Relative sourceIndex - mappings += base64VLQFormatEncode(pendingSourceIndex - lastSourceIndex); + appendBase64VLQ(pendingSourceIndex - lastSourceIndex); lastSourceIndex = pendingSourceIndex; // 3. Relative source line - mappings += base64VLQFormatEncode(pendingSourceLine - lastSourceLine); + appendBase64VLQ(pendingSourceLine - lastSourceLine); lastSourceLine = pendingSourceLine; // 4. Relative source character - mappings += base64VLQFormatEncode(pendingSourceCharacter - lastSourceCharacter); + appendBase64VLQ(pendingSourceCharacter - lastSourceCharacter); lastSourceCharacter = pendingSourceCharacter; if (hasPendingName) { // 5. Relative nameIndex - mappings += base64VLQFormatEncode(pendingNameIndex - lastNameIndex); + appendBase64VLQ(pendingNameIndex - lastNameIndex); lastNameIndex = pendingNameIndex; } } hasLast = true; exit(); } + function flushMappingBuffer() { + if (mappingCharCodes.length > 0) { + mappings += String.fromCharCode.apply(undefined, mappingCharCodes); + mappingCharCodes.length = 0; + } + } function toJSON() { commitPendingMapping(); + flushMappingBuffer(); return { version: 3, file: file, @@ -81856,10 +84958,33 @@ var ts; sourcesContent: sourcesContent, }; } + function appendBase64VLQ(inValue) { + // Add a new least significant bit that has the sign of the value. + // if negative number the least significant bit that gets added to the number has value 1 + // else least significant bit value that gets added is 0 + // eg. -1 changes to binary : 01 [1] => 3 + // +1 changes to binary : 01 [0] => 2 + if (inValue < 0) { + inValue = ((-inValue) << 1) + 1; + } + else { + inValue = inValue << 1; + } + // Encode 5 bits at a time starting from least significant bits + do { + var currentDigit = inValue & 31; // 11111 + inValue = inValue >> 5; + if (inValue > 0) { + // There are still more digits to decode, set the msb (6th bit) + currentDigit = currentDigit | 32; + } + appendMappingCharCode(base64FormatEncode(currentDigit)); + } while (inValue > 0); + } } ts.createSourceMapGenerator = createSourceMapGenerator; // Sometimes tools can see the following line as a source mapping url comment, so we mangle it a bit (the [M]) - var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)\s*$/; + var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)$/; var whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/; function getLineInfo(text, lineStarts) { return { @@ -81876,7 +85001,7 @@ var ts; var line = lineInfo.getLineText(index); var comment = sourceMapCommentRegExp.exec(line); if (comment) { - return comment[1]; + return ts.trimStringEnd(comment[1]); } // If we see a non-whitespace/map comment-like line, break, to avoid scanning up the entire file else if (!line.match(whitespaceOrMapCommentRegExp)) { @@ -82082,31 +85207,6 @@ var ts; ch === 47 /* slash */ ? 63 : -1; } - function base64VLQFormatEncode(inValue) { - // Add a new least significant bit that has the sign of the value. - // if negative number the least significant bit that gets added to the number has value 1 - // else least significant bit value that gets added is 0 - // eg. -1 changes to binary : 01 [1] => 3 - // +1 changes to binary : 01 [0] => 2 - if (inValue < 0) { - inValue = ((-inValue) << 1) + 1; - } - else { - inValue = inValue << 1; - } - // Encode 5 bits at a time starting from least significant bits - var encodedStr = ""; - do { - var currentDigit = inValue & 31; // 11111 - inValue = inValue >> 5; - if (inValue > 0) { - // There are still more digits to decode, set the msb (6th bit) - currentDigit = currentDigit | 32; - } - encodedStr = encodedStr + String.fromCharCode(base64FormatEncode(currentDigit)); - } while (inValue > 0); - return encodedStr; - } function isSourceMappedPosition(value) { return value.sourceIndex !== undefined && value.sourcePosition !== undefined; @@ -82270,7 +85370,7 @@ var ts; function chainBundle(context, transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 297 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 299 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return context.factory.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -82321,7 +85421,7 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" @@ -82334,13 +85434,13 @@ var ts; hasImportDefault = true; } break; - case 260 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 272 /* ExternalModuleReference */) { + case 262 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 274 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -82371,13 +85471,13 @@ var ts; addExportedNamesForExportDeclaration(node); } break; - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: if (ts.hasSyntacticModifier(node, 1 /* Export */)) { for (var _b = 0, _c = node.declarationList.declarations; _b < _c.length; _b++) { var decl = _c[_b]; @@ -82385,7 +85485,7 @@ var ts; } } break; - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: if (ts.hasSyntacticModifier(node, 1 /* Export */)) { if (ts.hasSyntacticModifier(node, 512 /* Default */)) { // export default function() { } @@ -82405,7 +85505,7 @@ var ts; } } break; - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: if (ts.hasSyntacticModifier(node, 1 /* Export */)) { if (ts.hasSyntacticModifier(node, 512 /* Default */)) { // export default class { } @@ -82499,32 +85599,31 @@ var ts; * any such locations */ function isSimpleInlineableExpression(expression) { - return !ts.isIdentifier(expression) && isSimpleCopiableExpression(expression) || - ts.isWellKnownSymbolSyntactically(expression); + return !ts.isIdentifier(expression) && isSimpleCopiableExpression(expression); } ts.isSimpleInlineableExpression = isSimpleInlineableExpression; function isCompoundAssignment(kind) { - return kind >= 63 /* FirstCompoundAssignment */ - && kind <= 77 /* LastCompoundAssignment */; + return kind >= 64 /* FirstCompoundAssignment */ + && kind <= 78 /* LastCompoundAssignment */; } ts.isCompoundAssignment = isCompoundAssignment; function getNonAssignmentOperatorForCompoundAssignment(kind) { switch (kind) { - case 63 /* PlusEqualsToken */: return 39 /* PlusToken */; - case 64 /* MinusEqualsToken */: return 40 /* MinusToken */; - case 65 /* AsteriskEqualsToken */: return 41 /* AsteriskToken */; - case 66 /* AsteriskAsteriskEqualsToken */: return 42 /* AsteriskAsteriskToken */; - case 67 /* SlashEqualsToken */: return 43 /* SlashToken */; - case 68 /* PercentEqualsToken */: return 44 /* PercentToken */; - case 69 /* LessThanLessThanEqualsToken */: return 47 /* LessThanLessThanToken */; - case 70 /* GreaterThanGreaterThanEqualsToken */: return 48 /* GreaterThanGreaterThanToken */; - case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 49 /* GreaterThanGreaterThanGreaterThanToken */; - case 72 /* AmpersandEqualsToken */: return 50 /* AmpersandToken */; - case 73 /* BarEqualsToken */: return 51 /* BarToken */; - case 77 /* CaretEqualsToken */: return 52 /* CaretToken */; - case 74 /* BarBarEqualsToken */: return 56 /* BarBarToken */; - case 75 /* AmpersandAmpersandEqualsToken */: return 55 /* AmpersandAmpersandToken */; - case 76 /* QuestionQuestionEqualsToken */: return 60 /* QuestionQuestionToken */; + 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 */; } } ts.getNonAssignmentOperatorForCompoundAssignment = getNonAssignmentOperatorForCompoundAssignment; @@ -82579,10 +85678,19 @@ var ts; * @param isStatic A value indicating whether the member should be a static or instance member. */ function isInitializedProperty(member) { - return member.kind === 163 /* PropertyDeclaration */ + return member.kind === 165 /* PropertyDeclaration */ && member.initializer !== undefined; } ts.isInitializedProperty = isInitializedProperty; + /** + * Gets a value indicating whether a class element is a private instance method or accessor. + * + * @param member The class element node. + */ + function isNonStaticMethodOrAccessorWithPrivateName(member) { + return !ts.hasStaticModifier(member) && ts.isMethodOrAccessor(member) && ts.isPrivateIdentifier(member.name); + } + ts.isNonStaticMethodOrAccessorWithPrivateName = isNonStaticMethodOrAccessorWithPrivateName; })(ts || (ts = {})); /*@internal*/ var ts; @@ -82856,8 +85964,8 @@ var ts; if (!ts.getRestIndicatorOfBindingOrAssignmentElement(element)) { var propertyName = ts.getPropertyNameOfBindingOrAssignmentElement(element); if (flattenContext.level >= 1 /* ObjectRest */ - && !(element.transformFlags & (8192 /* ContainsRestOrSpread */ | 16384 /* ContainsObjectRestOrSpread */)) - && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (8192 /* ContainsRestOrSpread */ | 16384 /* ContainsObjectRestOrSpread */)) + && !(element.transformFlags & (16384 /* ContainsRestOrSpread */ | 32768 /* ContainsObjectRestOrSpread */)) + && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (16384 /* ContainsRestOrSpread */ | 32768 /* ContainsObjectRestOrSpread */)) && !ts.isComputedPropertyName(propertyName)) { bindingElements = ts.append(bindingElements, ts.visitNode(element, flattenContext.visitor)); } @@ -82923,7 +86031,7 @@ var ts; if (flattenContext.level >= 1 /* 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 & 16384 /* ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) { + if (element.transformFlags & 32768 /* ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) { flattenContext.hasTransformedPriorElement = true; var temp = flattenContext.context.factory.createTempVariable(/*recordTempVariable*/ undefined); if (flattenContext.hoistTempVariables) { @@ -83181,8 +86289,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(201 /* PropertyAccessExpression */); - context.enableSubstitution(202 /* ElementAccessExpression */); + context.enableSubstitution(203 /* PropertyAccessExpression */); + context.enableSubstitution(204 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -83208,14 +86316,14 @@ var ts; var applicableSubstitutions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 298 /* Bundle */) { + if (node.kind === 300 /* 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 === 300 /* InputFiles */) { + if (prepend.kind === 302 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend, "js"); } return prepend; @@ -83266,16 +86374,16 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 297 /* SourceFile */: - case 258 /* CaseBlock */: - case 257 /* ModuleBlock */: - case 230 /* Block */: + case 299 /* SourceFile */: + case 260 /* CaseBlock */: + case 259 /* ModuleBlock */: + case 232 /* Block */: currentLexicalScope = node; currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 252 /* ClassDeclaration */: - case 251 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: + case 253 /* FunctionDeclaration */: if (ts.hasSyntacticModifier(node, 2 /* Ambient */)) { break; } @@ -83287,7 +86395,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 === 252 /* ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 254 /* ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* Default */)); } if (ts.isClassDeclaration(node)) { // XXX: should probably also cover interfaces and type aliases that can have type variables? @@ -83330,10 +86438,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: - case 260 /* ImportEqualsDeclaration */: - case 266 /* ExportAssignment */: - case 267 /* ExportDeclaration */: + case 263 /* ImportDeclaration */: + case 262 /* ImportEqualsDeclaration */: + case 268 /* ExportAssignment */: + case 269 /* ExportDeclaration */: return visitElidableStatement(node); default: return visitorWorker(node); @@ -83354,13 +86462,13 @@ var ts; return node; } switch (node.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return visitImportDeclaration(node); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return visitExportAssignment(node); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -83380,11 +86488,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 267 /* ExportDeclaration */ || - node.kind === 261 /* ImportDeclaration */ || - node.kind === 262 /* ImportClause */ || - (node.kind === 260 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 272 /* ExternalModuleReference */)) { + if (node.kind === 269 /* ExportDeclaration */ || + node.kind === 263 /* ImportDeclaration */ || + node.kind === 264 /* ImportClause */ || + (node.kind === 262 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 274 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -83408,29 +86516,29 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 166 /* Constructor */: + case 168 /* Constructor */: return visitConstructor(node); - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: // Property declarations are not TypeScript syntax, but they must be visited // for the decorator transformation. return visitPropertyDeclaration(node); - case 171 /* IndexSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 165 /* MethodDeclaration */: + case 173 /* IndexSignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 167 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 229 /* SemicolonClassElement */: + case 231 /* SemicolonClassElement */: return node; default: return ts.Debug.failBadSyntaxKind(node); } } function modifierVisitor(node) { - if (ts.modifierToFlag(node.kind) & 2270 /* TypeScriptModifier */) { + if (ts.modifierToFlag(node.kind) & 18654 /* TypeScriptModifier */) { return undefined; } - else if (currentNamespace && node.kind === 92 /* ExportKeyword */) { + else if (currentNamespace && node.kind === 93 /* ExportKeyword */) { return undefined; } return node; @@ -83447,71 +86555,71 @@ var ts; return factory.createNotEmittedStatement(node); } switch (node.kind) { - case 92 /* ExportKeyword */: - case 87 /* DefaultKeyword */: + case 93 /* ExportKeyword */: + case 88 /* DefaultKeyword */: // ES6 export and default modifiers are elided when inside a namespace. return currentNamespace ? undefined : node; - case 122 /* PublicKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 125 /* AbstractKeyword */: - case 84 /* ConstKeyword */: - case 133 /* DeclareKeyword */: - case 142 /* ReadonlyKeyword */: + case 123 /* PublicKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + case 126 /* AbstractKeyword */: + case 85 /* ConstKeyword */: + case 134 /* DeclareKeyword */: + case 143 /* ReadonlyKeyword */: // TypeScript accessibility and readonly modifiers are elided // falls through - case 178 /* ArrayType */: - case 179 /* TupleType */: - case 180 /* OptionalType */: - case 181 /* RestType */: - case 177 /* TypeLiteral */: - case 172 /* TypePredicate */: - case 159 /* TypeParameter */: - case 128 /* AnyKeyword */: - case 152 /* UnknownKeyword */: - case 131 /* BooleanKeyword */: - case 147 /* StringKeyword */: - case 144 /* NumberKeyword */: - case 141 /* NeverKeyword */: - case 113 /* VoidKeyword */: - case 148 /* SymbolKeyword */: - case 175 /* ConstructorType */: - case 174 /* FunctionType */: - case 176 /* TypeQuery */: - case 173 /* TypeReference */: - case 182 /* UnionType */: - case 183 /* IntersectionType */: - case 184 /* ConditionalType */: - case 186 /* ParenthesizedType */: - case 187 /* ThisType */: - case 188 /* TypeOperator */: - case 189 /* IndexedAccessType */: - case 190 /* MappedType */: - case 191 /* LiteralType */: + case 180 /* ArrayType */: + case 181 /* TupleType */: + case 182 /* OptionalType */: + case 183 /* RestType */: + case 179 /* TypeLiteral */: + case 174 /* TypePredicate */: + case 161 /* TypeParameter */: + case 129 /* AnyKeyword */: + case 153 /* UnknownKeyword */: + case 132 /* BooleanKeyword */: + case 148 /* StringKeyword */: + case 145 /* NumberKeyword */: + case 142 /* NeverKeyword */: + case 114 /* VoidKeyword */: + case 149 /* SymbolKeyword */: + case 177 /* ConstructorType */: + case 176 /* FunctionType */: + case 178 /* TypeQuery */: + case 175 /* TypeReference */: + case 184 /* UnionType */: + case 185 /* IntersectionType */: + case 186 /* ConditionalType */: + case 188 /* ParenthesizedType */: + case 189 /* ThisType */: + case 190 /* TypeOperator */: + case 191 /* IndexedAccessType */: + case 192 /* MappedType */: + case 193 /* LiteralType */: // TypeScript type nodes are elided. // falls through - case 171 /* IndexSignature */: + case 173 /* IndexSignature */: // TypeScript index signatures are elided. // falls through - case 161 /* Decorator */: + case 163 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. // falls through - case 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return undefined; - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: // TypeScript property declarations are elided. However their names are still visited, and can potentially be retained if they could have sideeffects return visitPropertyDeclaration(node); - case 259 /* NamespaceExportDeclaration */: + case 261 /* NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; - case 166 /* Constructor */: + case 168 /* Constructor */: return visitConstructor(node); - case 253 /* InterfaceDeclaration */: + case 255 /* 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 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: // This may be a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -83521,7 +86629,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: // This may be a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -83531,35 +86639,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 286 /* HeritageClause */: + case 288 /* HeritageClause */: // This may be a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 167 /* GetAccessor */: + case 169 /* GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 168 /* SetAccessor */: + case 170 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 160 /* Parameter */: + case 162 /* Parameter */: // This may be a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -83569,40 +86677,40 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 206 /* TypeAssertionExpression */: - case 224 /* AsExpression */: + case 208 /* TypeAssertionExpression */: + case 226 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return visitCallExpression(node); - case 204 /* NewExpression */: + case 206 /* NewExpression */: return visitNewExpression(node); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 225 /* NonNullExpression */: + case 227 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); - case 274 /* JsxSelfClosingElement */: + case 276 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node); - case 275 /* JsxOpeningElement */: + case 277 /* JsxOpeningElement */: return visitJsxJsxOpeningElement(node); default: // node contains some other TypeScript syntax @@ -83639,7 +86747,7 @@ var ts; if (ts.some(staticProperties)) facts |= 1 /* HasStaticInitializedProperties */; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 103 /* NullKeyword */) + if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */) facts |= 64 /* IsDerivedClass */; if (shouldEmitDecorateCallForClass(node)) facts |= 2 /* HasConstructorDecorators */; @@ -83656,7 +86764,7 @@ var ts; return facts; } function hasTypeScriptClassSyntax(node) { - return !!(node.transformFlags & 2048 /* ContainsTypeScriptClassSyntax */); + return !!(node.transformFlags & 4096 /* ContainsTypeScriptClassSyntax */); } function isClassLikeDeclarationWithTypeScriptSyntax(node) { return ts.some(node.decorators) @@ -84011,12 +87119,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -84169,7 +87277,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ true); var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 163 /* PropertyDeclaration */ + ? member.kind === 165 /* 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() @@ -84293,10 +87401,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 165 /* MethodDeclaration */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */ - || kind === 163 /* PropertyDeclaration */; + return kind === 167 /* MethodDeclaration */ + || kind === 169 /* GetAccessor */ + || kind === 170 /* SetAccessor */ + || kind === 165 /* PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -84306,7 +87414,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 165 /* MethodDeclaration */; + return node.kind === 167 /* MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -84317,12 +87425,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return true; } return false; @@ -84339,15 +87447,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 163 /* PropertyDeclaration */: - case 160 /* Parameter */: + case 165 /* PropertyDeclaration */: + case 162 /* Parameter */: return serializeTypeNode(node.type); - case 168 /* SetAccessor */: - case 167 /* GetAccessor */: + case 170 /* SetAccessor */: + case 169 /* GetAccessor */: return serializeTypeNode(getAccessorTypeNode(node)); - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 165 /* MethodDeclaration */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 167 /* MethodDeclaration */: return factory.createIdentifier("Function"); default: return factory.createVoidZero(); @@ -84384,7 +87492,7 @@ var ts; return factory.createArrayLiteralExpression(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 167 /* GetAccessor */) { + if (container && node.kind === 169 /* GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -84429,82 +87537,82 @@ var ts; return factory.createIdentifier("Object"); } switch (node.kind) { - case 113 /* VoidKeyword */: - case 150 /* UndefinedKeyword */: - case 141 /* NeverKeyword */: + case 114 /* VoidKeyword */: + case 151 /* UndefinedKeyword */: + case 142 /* NeverKeyword */: return factory.createVoidZero(); - case 186 /* ParenthesizedType */: + case 188 /* ParenthesizedType */: return serializeTypeNode(node.type); - case 174 /* FunctionType */: - case 175 /* ConstructorType */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: return factory.createIdentifier("Function"); - case 178 /* ArrayType */: - case 179 /* TupleType */: + case 180 /* ArrayType */: + case 181 /* TupleType */: return factory.createIdentifier("Array"); - case 172 /* TypePredicate */: - case 131 /* BooleanKeyword */: + case 174 /* TypePredicate */: + case 132 /* BooleanKeyword */: return factory.createIdentifier("Boolean"); - case 147 /* StringKeyword */: + case 148 /* StringKeyword */: return factory.createIdentifier("String"); - case 145 /* ObjectKeyword */: + case 146 /* ObjectKeyword */: return factory.createIdentifier("Object"); - case 191 /* LiteralType */: + case 193 /* LiteralType */: switch (node.literal.kind) { case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return factory.createIdentifier("String"); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: case 8 /* NumericLiteral */: return factory.createIdentifier("Number"); case 9 /* BigIntLiteral */: return getGlobalBigIntNameWithFallback(); - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: return factory.createIdentifier("Boolean"); - case 103 /* NullKeyword */: + case 104 /* NullKeyword */: return factory.createVoidZero(); default: return ts.Debug.failBadSyntaxKind(node.literal); } - case 144 /* NumberKeyword */: + case 145 /* NumberKeyword */: return factory.createIdentifier("Number"); - case 155 /* BigIntKeyword */: + case 156 /* BigIntKeyword */: return getGlobalBigIntNameWithFallback(); - case 148 /* SymbolKeyword */: + case 149 /* SymbolKeyword */: return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : factory.createIdentifier("Symbol"); - case 173 /* TypeReference */: + case 175 /* TypeReference */: return serializeTypeReferenceNode(node); - case 183 /* IntersectionType */: - case 182 /* UnionType */: + case 185 /* IntersectionType */: + case 184 /* UnionType */: return serializeTypeList(node.types); - case 184 /* ConditionalType */: + case 186 /* ConditionalType */: return serializeTypeList([node.trueType, node.falseType]); - case 188 /* TypeOperator */: - if (node.operator === 142 /* ReadonlyKeyword */) { + case 190 /* TypeOperator */: + if (node.operator === 143 /* ReadonlyKeyword */) { return serializeTypeNode(node.type); } break; - case 176 /* TypeQuery */: - case 189 /* IndexedAccessType */: - case 190 /* MappedType */: - case 177 /* TypeLiteral */: - case 128 /* AnyKeyword */: - case 152 /* UnknownKeyword */: - case 187 /* ThisType */: - case 195 /* ImportType */: + case 178 /* TypeQuery */: + case 191 /* IndexedAccessType */: + case 192 /* MappedType */: + case 179 /* TypeLiteral */: + case 129 /* AnyKeyword */: + case 153 /* UnknownKeyword */: + case 189 /* ThisType */: + case 197 /* ImportType */: break; // handle JSDoc types from an invalid parse - case 303 /* JSDocAllType */: - case 304 /* JSDocUnknownType */: - case 308 /* JSDocFunctionType */: - case 309 /* JSDocVariadicType */: - case 310 /* JSDocNamepathType */: + case 306 /* JSDocAllType */: + case 307 /* JSDocUnknownType */: + case 311 /* JSDocFunctionType */: + case 312 /* JSDocVariadicType */: + case 313 /* JSDocNamepathType */: break; - case 305 /* JSDocNullableType */: - case 306 /* JSDocNonNullableType */: - case 307 /* JSDocOptionalType */: + case 308 /* JSDocNullableType */: + case 309 /* JSDocNonNullableType */: + case 310 /* JSDocOptionalType */: return serializeTypeNode(node.type); default: return ts.Debug.failBadSyntaxKind(node); @@ -84517,13 +87625,13 @@ var ts; var serializedUnion; for (var _i = 0, types_24 = types; _i < types_24.length; _i++) { var typeNode = types_24[_i]; - while (typeNode.kind === 186 /* ParenthesizedType */) { + while (typeNode.kind === 188 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 141 /* NeverKeyword */) { + if (typeNode.kind === 142 /* NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 191 /* LiteralType */ && typeNode.literal.kind === 103 /* NullKeyword */ || typeNode.kind === 150 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 193 /* LiteralType */ && typeNode.literal.kind === 104 /* NullKeyword */ || typeNode.kind === 151 /* UndefinedKeyword */)) { continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks } var serializedIndividual = serializeTypeNode(typeNode); @@ -84605,12 +87713,12 @@ var ts; * @param node The entity name to serialize. */ function serializeEntityNameAsExpressionFallback(node) { - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { // A -> typeof A !== undefined && A var copied = serializeEntityNameAsExpression(node); return createCheckedValue(copied, copied); } - if (node.left.kind === 78 /* Identifier */) { + if (node.left.kind === 79 /* Identifier */) { // A.B -> typeof A !== undefined && A.B return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node)); } @@ -84626,14 +87734,14 @@ var ts; */ function serializeEntityNameAsExpression(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* 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 157 /* QualifiedName */: + case 159 /* QualifiedName */: return serializeQualifiedNameAsExpression(node); } } @@ -84724,7 +87832,7 @@ var ts; * @param node The HeritageClause to transform. */ function visitHeritageClause(node) { - if (node.token === 116 /* ImplementsKeyword */) { + if (node.token === 117 /* ImplementsKeyword */) { // implements clauses are elided return undefined; } @@ -85021,8 +88129,7 @@ var ts; */ function shouldEmitEnumDeclaration(node) { return !ts.isEnumConst(node) - || compilerOptions.preserveConstEnums - || compilerOptions.isolatedModules; + || ts.shouldPreserveConstEnums(compilerOptions); } /** * Visits an enum declaration. @@ -85156,7 +88263,7 @@ var ts; // If we can't find a parse tree node, assume the node is instantiated. return true; } - return ts.isInstantiatedModule(node, !!compilerOptions.preserveConstEnums || !!compilerOptions.isolatedModules); + return ts.isInstantiatedModule(node, ts.shouldPreserveConstEnums(compilerOptions)); } /** * Determines whether an exported declaration will have a qualified export name (e.g. `f.x` @@ -85207,12 +88314,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 === 297 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 299 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { // Adjust the source map emit to match the old emitter. - if (node.kind === 255 /* EnumDeclaration */) { + if (node.kind === 257 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -85337,7 +88444,7 @@ var ts; var statementsLocation; var blockLocation; if (node.body) { - if (node.body.kind === 257 /* ModuleBlock */) { + if (node.body.kind === 259 /* ModuleBlock */) { saveStateAndInvoke(node.body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = node.body.statements; blockLocation = node.body; @@ -85384,13 +88491,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 !== 257 /* ModuleBlock */) { + if (!node.body || node.body.kind !== 259 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 256 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 258 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -85440,7 +88547,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 263 /* NamespaceImport */) { + if (node.kind === 265 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -85674,7 +88781,7 @@ var ts; function enableSubstitutionForNonQualifiedEnumMembers() { if ((enabledSubstitutions & 8 /* NonQualifiedEnumMembers */) === 0) { enabledSubstitutions |= 8 /* NonQualifiedEnumMembers */; - context.enableSubstitution(78 /* Identifier */); + context.enableSubstitution(79 /* Identifier */); } } function enableSubstitutionForClassAliases() { @@ -85682,7 +88789,7 @@ var ts; enabledSubstitutions |= 1 /* ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(78 /* Identifier */); + context.enableSubstitution(79 /* Identifier */); // Keep track of class aliases. classAliases = []; } @@ -85692,17 +88799,17 @@ var ts; enabledSubstitutions |= 2 /* 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(78 /* Identifier */); - context.enableSubstitution(289 /* ShorthandPropertyAssignment */); + context.enableSubstitution(79 /* Identifier */); + context.enableSubstitution(291 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(256 /* ModuleDeclaration */); + context.enableEmitNotification(258 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 256 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 258 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 255 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 257 /* EnumDeclaration */; } /** * Hook for node emit. @@ -85761,11 +88868,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return substituteExpressionIdentifier(node); - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -85787,10 +88894,10 @@ var ts; if (declaration) { var classAlias = classAliases[declaration.id]; // TODO: GH#18217 if (classAlias) { - var clone_1 = factory.cloneNode(classAlias); - ts.setSourceMapRange(clone_1, node); - ts.setCommentRange(clone_1, node); - return clone_1; + var clone_2 = factory.cloneNode(classAlias); + ts.setSourceMapRange(clone_2, node); + ts.setCommentRange(clone_2, node); + return clone_2; } } } @@ -85803,9 +88910,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 !== 297 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 256 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 255 /* EnumDeclaration */); + if (container && container.kind !== 299 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 258 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 257 /* EnumDeclaration */); if (substitute) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(container), node), /*location*/ node); @@ -85857,10 +88964,12 @@ var ts; */ ClassPropertySubstitutionFlags[ClassPropertySubstitutionFlags["ClassAliases"] = 1] = "ClassAliases"; })(ClassPropertySubstitutionFlags || (ClassPropertySubstitutionFlags = {})); - var PrivateIdentifierPlacement; - (function (PrivateIdentifierPlacement) { - PrivateIdentifierPlacement[PrivateIdentifierPlacement["InstanceField"] = 0] = "InstanceField"; - })(PrivateIdentifierPlacement || (PrivateIdentifierPlacement = {})); + var PrivateIdentifierKind; + (function (PrivateIdentifierKind) { + PrivateIdentifierKind["Field"] = "f"; + PrivateIdentifierKind["Method"] = "m"; + PrivateIdentifierKind["Accessor"] = "a"; + })(PrivateIdentifierKind = ts.PrivateIdentifierKind || (ts.PrivateIdentifierKind = {})); /** * Transforms ECMAScript Class Syntax. * TypeScript parameter property syntax is transformed in the TypeScript transformer. @@ -85869,11 +88978,12 @@ var ts; * When --useDefineForClassFields is on, this transforms to ECMAScript semantics, with Object.defineProperty. */ function transformClassFields(context) { - var factory = context.factory, hoistVariableDeclaration = context.hoistVariableDeclaration, endLexicalEnvironment = context.endLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment; + var factory = context.factory, hoistVariableDeclaration = context.hoistVariableDeclaration, endLexicalEnvironment = context.endLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, addBlockScopedVariable = context.addBlockScopedVariable; var resolver = context.getEmitResolver(); var compilerOptions = context.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); - var shouldTransformPrivateFields = languageVersion < 99 /* ESNext */; + var useDefineForClassFields = ts.getUseDefineForClassFields(compilerOptions); + var shouldTransformPrivateElements = languageVersion < 99 /* ESNext */; var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; var enabledSubstitutions; @@ -85894,7 +89004,7 @@ var ts; function transformSourceFile(node) { var options = context.getCompilerOptions(); if (node.isDeclarationFile - || options.useDefineForClassFields && options.target === 99 /* ESNext */) { + || useDefineForClassFields && options.target === 99 /* ESNext */) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -85902,41 +89012,41 @@ var ts; return visited; } function visitor(node) { - if (!(node.transformFlags & 4194304 /* ContainsClassFields */)) + if (!(node.transformFlags & 8388608 /* ContainsClassFields */)) return node; switch (node.kind) { - case 221 /* ClassExpression */: - case 252 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 254 /* ClassDeclaration */: return visitClassLike(node); - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return visitPropertyDeclaration(node); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return visitVariableStatement(node); - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return visitPropertyAccessExpression(node); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return visitPrefixUnaryExpression(node); - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: return visitPostfixUnaryExpression(node, /*valueIsDiscarded*/ false); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return visitCallExpression(node); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return visitBinaryExpression(node); - case 79 /* PrivateIdentifier */: + case 80 /* PrivateIdentifier */: return visitPrivateIdentifier(node); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: return visitExpressionStatement(node); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return visitForStatement(node); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); } return ts.visitEachChild(node, visitor, context); } function visitorDestructuringTarget(node) { switch (node.kind) { - case 200 /* ObjectLiteralExpression */: - case 199 /* ArrayLiteralExpression */: + case 202 /* ObjectLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return visitAssignmentPattern(node); default: return visitor(node); @@ -85947,7 +89057,7 @@ var ts; * Replace it with an empty identifier to indicate a problem with the code. */ function visitPrivateIdentifier(node) { - if (!shouldTransformPrivateFields) { + if (!shouldTransformPrivateElements) { return node; } return ts.setOriginalNode(factory.createIdentifier(""), node); @@ -85959,20 +89069,19 @@ var ts; */ function classElementVisitor(node) { switch (node.kind) { - case 166 /* Constructor */: + case 168 /* Constructor */: // Constructors for classes using class fields are transformed in // `visitClassDeclaration` or `visitClassExpression`. return undefined; - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 165 /* MethodDeclaration */: - // Visit the name of the member (if it's a computed property name). - return ts.visitEachChild(node, classElementVisitor, context); - case 163 /* PropertyDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 167 /* MethodDeclaration */: + return visitMethodOrAccessorDeclaration(node); + case 165 /* PropertyDeclaration */: return visitPropertyDeclaration(node); - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 229 /* SemicolonClassElement */: + case 231 /* SemicolonClassElement */: return node; default: return visitor(node); @@ -85997,44 +89106,96 @@ var ts; } return node; } + function visitMethodOrAccessorDeclaration(node) { + ts.Debug.assert(!ts.some(node.decorators)); + if (!shouldTransformPrivateElements || !ts.isPrivateIdentifier(node.name)) { + return ts.visitEachChild(node, classElementVisitor, context); + } + // leave invalid code untransformed + var info = accessPrivateIdentifier(node.name); + ts.Debug.assert(info, "Undeclared private name for property declaration."); + if (!info.isValid) { + return node; + } + var functionName = getHoistedFunctionName(node); + if (functionName) { + getPendingExpressions().push(factory.createAssignment(functionName, factory.createFunctionExpression(ts.filter(node.modifiers, function (m) { return !ts.isStaticModifier(m); }), node.asteriskToken, functionName, + /* typeParameters */ undefined, ts.visitParameterList(node.parameters, classElementVisitor, context), + /* type */ undefined, ts.visitFunctionBody(node.body, classElementVisitor, context)))); + } + // remove method declaration from class + return undefined; + } + function getHoistedFunctionName(node) { + 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 */) { + return info.methodName; + } + if (info.kind === "a" /* Accessor */) { + if (ts.isGetAccessor(node)) { + return info.getterName; + } + if (ts.isSetAccessor(node)) { + return info.setterName; + } + } + } function visitPropertyDeclaration(node) { ts.Debug.assert(!ts.some(node.decorators)); - if (!shouldTransformPrivateFields && ts.isPrivateIdentifier(node.name)) { - // Initializer is elided as the field is initialized in transformConstructor. - return factory.updatePropertyDeclaration(node, - /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name, - /*questionOrExclamationToken*/ undefined, - /*type*/ undefined, - /*initializer*/ undefined); + if (ts.isPrivateIdentifier(node.name)) { + if (!shouldTransformPrivateElements) { + // Initializer is elided as the field is initialized in transformConstructor. + return factory.updatePropertyDeclaration(node, + /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name, + /*questionOrExclamationToken*/ undefined, + /*type*/ undefined, + /*initializer*/ undefined); + } + // leave invalid code untransformed + var info = accessPrivateIdentifier(node.name); + ts.Debug.assert(info, "Undeclared private name for property declaration."); + if (!info.isValid) { + return node; + } } // Create a temporary variable to store a computed property name (if necessary). // If it's not inlineable, then we emit an expression after the class which assigns // the property name to the temporary variable. - var expr = getPropertyNameExpressionIfNeeded(node.name, !!node.initializer || !!context.getCompilerOptions().useDefineForClassFields); + var expr = getPropertyNameExpressionIfNeeded(node.name, !!node.initializer || useDefineForClassFields); if (expr && !ts.isSimpleInlineableExpression(expr)) { getPendingExpressions().push(expr); } return undefined; } function createPrivateIdentifierAccess(info, receiver) { - receiver = ts.visitNode(receiver, visitor, ts.isExpression); - switch (info.placement) { - case 0 /* InstanceField */: - return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(ts.nodeIsSynthesized(receiver) ? receiver : factory.cloneNode(receiver), info.weakMapName); - default: return ts.Debug.fail("Unexpected private identifier placement"); + return createPrivateIdentifierAccessHelper(info, ts.visitNode(receiver, visitor, ts.isExpression)); + } + function createPrivateIdentifierAccessHelper(info, receiver) { + ts.setCommentRange(receiver, ts.moveRangePos(receiver, -1)); + switch (info.kind) { + case "a" /* Accessor */: + return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.getterName); + case "m" /* Method */: + return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.methodName); + case "f" /* Field */: + return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.variableName); + default: + ts.Debug.assertNever(info, "Unknown private element type"); } } function visitPropertyAccessExpression(node) { - if (shouldTransformPrivateFields && ts.isPrivateIdentifier(node.name)) { + if (shouldTransformPrivateElements && ts.isPrivateIdentifier(node.name)) { var privateIdentifierInfo = accessPrivateIdentifier(node.name); if (privateIdentifierInfo) { - return ts.setOriginalNode(createPrivateIdentifierAccess(privateIdentifierInfo, node.expression), node); + return ts.setTextRange(ts.setOriginalNode(createPrivateIdentifierAccess(privateIdentifierInfo, node.expression), node), node); } } return ts.visitEachChild(node, visitor, context); } function visitPrefixUnaryExpression(node) { - if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { + if (shouldTransformPrivateElements && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { var operator = node.operator === 45 /* PlusPlusToken */ ? 39 /* PlusToken */ : node.operator === 46 /* MinusMinusToken */ ? 40 /* MinusToken */ : undefined; @@ -86043,13 +89204,13 @@ var ts; var receiver = ts.visitNode(node.operand.expression, visitor, ts.isExpression); var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression; var existingValue = factory.createPrefixUnaryExpression(39 /* PlusToken */, createPrivateIdentifierAccess(info, readExpression)); - return ts.setOriginalNode(createPrivateIdentifierAssignment(info, initializeExpression || readExpression, factory.createBinaryExpression(existingValue, operator, factory.createNumericLiteral(1)), 62 /* EqualsToken */), node); + return ts.setOriginalNode(createPrivateIdentifierAssignment(info, initializeExpression || readExpression, factory.createBinaryExpression(existingValue, operator, factory.createNumericLiteral(1)), 63 /* EqualsToken */), node); } } return ts.visitEachChild(node, visitor, context); } function visitPostfixUnaryExpression(node, valueIsDiscarded) { - if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { + if (shouldTransformPrivateElements && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { var operator = node.operator === 45 /* PlusPlusToken */ ? 39 /* PlusToken */ : node.operator === 46 /* MinusMinusToken */ ? 40 /* MinusToken */ : undefined; @@ -86061,7 +89222,7 @@ var ts; // Create a temporary variable to store the value returned by the expression. var returnValue = valueIsDiscarded ? undefined : factory.createTempVariable(hoistVariableDeclaration); return ts.setOriginalNode(factory.inlineExpressions(ts.compact([ - createPrivateIdentifierAssignment(info, initializeExpression || readExpression, factory.createBinaryExpression(returnValue ? factory.createAssignment(returnValue, existingValue) : existingValue, operator, factory.createNumericLiteral(1)), 62 /* EqualsToken */), + createPrivateIdentifierAssignment(info, initializeExpression || readExpression, factory.createBinaryExpression(returnValue ? factory.createAssignment(returnValue, existingValue) : existingValue, operator, factory.createNumericLiteral(1)), 63 /* EqualsToken */), returnValue ])), node); } @@ -86070,7 +89231,7 @@ var ts; } function visitForStatement(node) { if (node.incrementor && ts.isPostfixUnaryExpression(node.incrementor)) { - return factory.updateForStatement(node, ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), visitPostfixUnaryExpression(node.incrementor, /*valueIsDiscarded*/ true), ts.visitNode(node.statement, visitor, ts.isStatement)); + return factory.updateForStatement(node, ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), visitPostfixUnaryExpression(node.incrementor, /*valueIsDiscarded*/ true), ts.visitIterationBody(node.statement, visitor, context)); } return ts.visitEachChild(node, visitor, context); } @@ -86090,16 +89251,21 @@ var ts; return { readExpression: readExpression, initializeExpression: initializeExpression }; } function visitCallExpression(node) { - if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.expression)) { + if (shouldTransformPrivateElements && ts.isPrivateIdentifierPropertyAccessExpression(node.expression)) { // Transform call expressions of private names to properly bind the `this` parameter. var _a = factory.createCallBinding(node.expression, hoistVariableDeclaration, languageVersion), thisArg = _a.thisArg, target = _a.target; + if (ts.isCallChain(node)) { + return factory.updateCallChain(node, factory.createPropertyAccessChain(ts.visitNode(target, visitor), node.questionDotToken, "call"), + /*questionDotToken*/ undefined, + /*typeArguments*/ undefined, __spreadArray([ts.visitNode(thisArg, visitor, ts.isExpression)], ts.visitNodes(node.arguments, visitor, ts.isExpression))); + } return factory.updateCallExpression(node, factory.createPropertyAccessExpression(ts.visitNode(target, visitor), "call"), /*typeArguments*/ undefined, __spreadArray([ts.visitNode(thisArg, visitor, ts.isExpression)], ts.visitNodes(node.arguments, visitor, ts.isExpression))); } return ts.visitEachChild(node, visitor, context); } function visitTaggedTemplateExpression(node) { - if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.tag)) { + if (shouldTransformPrivateElements && ts.isPrivateIdentifierPropertyAccessExpression(node.tag)) { // Bind the `this` correctly for tagged template literals when the tag is a private identifier property access. var _a = factory.createCallBinding(node.tag, hoistVariableDeclaration, languageVersion), thisArg = _a.thisArg, target = _a.target; return factory.updateTaggedTemplateExpression(node, factory.createCallExpression(factory.createPropertyAccessExpression(ts.visitNode(target, visitor), "bind"), @@ -86109,7 +89275,7 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitBinaryExpression(node) { - if (shouldTransformPrivateFields) { + if (shouldTransformPrivateElements) { if (ts.isDestructuringAssignment(node)) { var savedPendingExpressions = pendingExpressions; pendingExpressions = undefined; @@ -86123,29 +89289,31 @@ var ts; if (ts.isAssignmentExpression(node) && ts.isPrivateIdentifierPropertyAccessExpression(node.left)) { var info = accessPrivateIdentifier(node.left.name); if (info) { - return ts.setOriginalNode(createPrivateIdentifierAssignment(info, node.left.expression, node.right, node.operatorToken.kind), node); + return ts.setTextRange(ts.setOriginalNode(createPrivateIdentifierAssignment(info, node.left.expression, node.right, node.operatorToken.kind), node), node); } } } return ts.visitEachChild(node, visitor, context); } function createPrivateIdentifierAssignment(info, receiver, right, operator) { - switch (info.placement) { - case 0 /* InstanceField */: { - return createPrivateIdentifierInstanceFieldAssignment(info, receiver, right, operator); - } - default: return ts.Debug.fail("Unexpected private identifier placement"); - } - } - function createPrivateIdentifierInstanceFieldAssignment(info, receiver, right, operator) { receiver = ts.visitNode(receiver, visitor, ts.isExpression); right = ts.visitNode(right, visitor, ts.isExpression); if (ts.isCompoundAssignment(operator)) { var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression; - return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(initializeExpression || readExpression, info.weakMapName, factory.createBinaryExpression(context.getEmitHelperFactory().createClassPrivateFieldGetHelper(readExpression, info.weakMapName), ts.getNonAssignmentOperatorForCompoundAssignment(operator), right)); - } - else { - return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.weakMapName, right); + receiver = initializeExpression || readExpression; + right = factory.createBinaryExpression(createPrivateIdentifierAccessHelper(info, readExpression), ts.getNonAssignmentOperatorForCompoundAssignment(operator), right); + } + ts.setCommentRange(receiver, ts.moveRangePos(receiver, -1)); + switch (info.kind) { + case "a" /* Accessor */: + return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, info.setterName); + case "m" /* Method */: + return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, + /* f */ undefined); + case "f" /* Field */: + return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, info.variableName); + default: + ts.Debug.assertNever(info, "Unknown private element type"); } } /** @@ -86154,32 +89322,53 @@ var ts; function visitClassLike(node) { var savedPendingExpressions = pendingExpressions; pendingExpressions = undefined; - if (shouldTransformPrivateFields) { + if (shouldTransformPrivateElements) { startPrivateIdentifierEnvironment(); + var name = ts.getNameOfDeclaration(node); + if (name && ts.isIdentifier(name)) { + getPrivateIdentifierEnvironment().className = ts.idText(name); + } + var privateInstanceMethodsAndAccessors = getPrivateInstanceMethodsAndAccessors(node); + if (ts.some(privateInstanceMethodsAndAccessors)) { + getPrivateIdentifierEnvironment().weakSetName = createHoistedVariableForClass("instances", privateInstanceMethodsAndAccessors[0].name); + } } var result = ts.isClassDeclaration(node) ? visitClassDeclaration(node) : visitClassExpression(node); - if (shouldTransformPrivateFields) { + if (shouldTransformPrivateElements) { endPrivateIdentifierEnvironment(); } pendingExpressions = savedPendingExpressions; return result; } function doesClassElementNeedTransform(node) { - return ts.isPropertyDeclaration(node) || (shouldTransformPrivateFields && node.name && ts.isPrivateIdentifier(node.name)); + return ts.isPropertyDeclaration(node) || (shouldTransformPrivateElements && node.name && ts.isPrivateIdentifier(node.name)); + } + function getPrivateInstanceMethodsAndAccessors(node) { + return ts.filter(node.members, ts.isNonStaticMethodOrAccessorWithPrivateName); } function visitClassDeclaration(node) { if (!ts.forEach(node.members, doesClassElementNeedTransform)) { return ts.visitEachChild(node, visitor, context); } + var staticProperties = ts.getProperties(node, /*requireInitializer*/ false, /*isStatic*/ true); + var pendingPrivateStateAssignment; + if (shouldTransformPrivateElements && ts.some(node.members, function (m) { return ts.hasStaticModifier(m) && !!m.name && ts.isPrivateIdentifier(m.name); })) { + var temp = factory.createTempVariable(hoistVariableDeclaration, /* reservedInNestedScopes */ true); + getPrivateIdentifierEnvironment().classConstructor = factory.cloneNode(temp); + pendingPrivateStateAssignment = factory.createAssignment(temp, factory.getInternalName(node)); + } var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 103 /* NullKeyword */); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */); var statements = [ factory.updateClassDeclaration(node, /*decorators*/ undefined, node.modifiers, node.name, /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass)) ]; + if (pendingPrivateStateAssignment) { + getPendingExpressions().unshift(pendingPrivateStateAssignment); + } // Write any pending expressions from elided or moved computed property names if (ts.some(pendingExpressions)) { statements.push(factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))); @@ -86189,7 +89378,6 @@ var ts; // From ES6 specification: // HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using // a lexical declaration such as a LexicalDeclaration or a ClassDeclaration. - var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); if (ts.some(staticProperties)) { addPropertyStatements(statements, staticProperties, factory.getInternalName(node)); } @@ -86207,12 +89395,25 @@ var ts; // class declaration transformation. The VariableStatement visitor will insert // these statements after the class expression variable statement. var isDecoratedClassDeclaration = ts.isClassDeclaration(ts.getOriginalNode(node)); - var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); + var staticProperties = ts.getProperties(node, /*requireInitializer*/ false, /*isStatic*/ true); var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 103 /* NullKeyword */); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */); + var isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */; + var temp; + function createClassTempVar() { + var classCheckFlags = resolver.getNodeCheckFlags(node); + var isClassWithConstructorReference = classCheckFlags & 16777216 /* ClassWithConstructorReference */; + var requiresBlockScopedVar = classCheckFlags & 524288 /* BlockScopedBindingInLoop */; + return factory.createTempVariable(requiresBlockScopedVar ? addBlockScopedVariable : hoistVariableDeclaration, !!isClassWithConstructorReference); + } + if (shouldTransformPrivateElements && ts.some(node.members, function (m) { return ts.hasStaticModifier(m) && !!m.name && ts.isPrivateIdentifier(m.name); })) { + temp = createClassTempVar(); + getPrivateIdentifierEnvironment().classConstructor = factory.cloneNode(temp); + } var classExpression = factory.updateClassExpression(node, ts.visitNodes(node.decorators, visitor, ts.isDecorator), node.modifiers, node.name, /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass)); - if (ts.some(staticProperties) || ts.some(pendingExpressions)) { + var hasTransformableStatics = ts.some(staticProperties, function (p) { return !!p.initializer || (shouldTransformPrivateElements && ts.isPrivateIdentifier(p.name)); }); + if (hasTransformableStatics || ts.some(pendingExpressions)) { if (isDecoratedClassDeclaration) { ts.Debug.assertIsDefined(pendingStatements, "Decorated classes transformed by TypeScript are expected to be within a variable declaration."); // Write any pending expressions from elided or moved computed property names @@ -86222,12 +89423,14 @@ var ts; if (pendingStatements && ts.some(staticProperties)) { addPropertyStatements(pendingStatements, staticProperties, factory.getInternalName(node)); } + if (temp) { + return factory.inlineExpressions([factory.createAssignment(temp, classExpression), temp]); + } return classExpression; } else { var expressions = []; - var isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */; - var temp = factory.createTempVariable(hoistVariableDeclaration, !!isClassWithConstructorReference); + temp || (temp = createClassTempVar()); if (isClassWithConstructorReference) { // record an alias as the class name is not in scope for statics. enableSubstitutionForClassAliases(); @@ -86249,14 +89452,17 @@ var ts; return classExpression; } function transformClassMembers(node, isDerivedClass) { - if (shouldTransformPrivateFields) { + if (shouldTransformPrivateElements) { // Declare private names. for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (ts.isPrivateIdentifierPropertyDeclaration(member)) { - addPrivateIdentifierToEnvironment(member.name); + if (ts.isPrivateIdentifierClassElementDeclaration(member)) { + addPrivateIdentifierToEnvironment(member); } } + if (ts.some(getPrivateInstanceMethodsAndAccessors(node))) { + createBrandCheckWeakSetForPrivateMethods(); + } } var members = []; var constructor = transformConstructor(node, isDerivedClass); @@ -86266,21 +89472,27 @@ var ts; ts.addRange(members, ts.visitNodes(node.members, classElementVisitor, ts.isClassElement)); return ts.setTextRange(factory.createNodeArray(members), /*location*/ node.members); } - function isPropertyDeclarationThatRequiresConstructorStatement(member) { - if (!ts.isPropertyDeclaration(member) || ts.hasStaticModifier(member) || ts.hasSyntacticModifier(ts.getOriginalNode(member), 128 /* Abstract */)) { + function createBrandCheckWeakSetForPrivateMethods() { + var weakSetName = getPrivateIdentifierEnvironment().weakSetName; + ts.Debug.assert(weakSetName, "weakSetName should be set in private identifier environment"); + getPendingExpressions().push(factory.createAssignment(weakSetName, factory.createNewExpression(factory.createIdentifier("WeakSet"), + /*typeArguments*/ undefined, []))); + } + function isClassElementThatRequiresConstructorStatement(member) { + if (ts.hasStaticModifier(member) || ts.hasSyntacticModifier(ts.getOriginalNode(member), 128 /* Abstract */)) { return false; } - if (context.getCompilerOptions().useDefineForClassFields) { + 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 < 99 /* ESNext */; } - return ts.isInitializedProperty(member) || shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyDeclaration(member); + return ts.isInitializedProperty(member) || shouldTransformPrivateElements && ts.isPrivateIdentifierClassElementDeclaration(member); } function transformConstructor(node, isDerivedClass) { var constructor = ts.visitNode(ts.getFirstConstructorWithBody(node), visitor, ts.isConstructorDeclaration); - var properties = node.members.filter(isPropertyDeclarationThatRequiresConstructorStatement); - if (!ts.some(properties)) { + var elements = node.members.filter(isClassElementThatRequiresConstructorStatement); + if (!ts.some(elements)) { return constructor; } var parameters = ts.visitParameterList(constructor ? constructor.parameters : undefined, visitor, context); @@ -86293,13 +89505,14 @@ var ts; /*modifiers*/ undefined, parameters !== null && parameters !== void 0 ? parameters : [], body), constructor || node), constructor)); } function transformConstructorBody(node, constructor, isDerivedClass) { - var useDefineForClassFields = context.getCompilerOptions().useDefineForClassFields; var properties = ts.getProperties(node, /*requireInitializer*/ false, /*isStatic*/ false); if (!useDefineForClassFields) { properties = ts.filter(properties, function (property) { return !!property.initializer || ts.isPrivateIdentifier(property.name); }); } + var privateMethodsAndAccessors = getPrivateInstanceMethodsAndAccessors(node); + var needsConstructorBody = ts.some(properties) || ts.some(privateMethodsAndAccessors); // Only generate synthetic constructor when there are property initializers to move. - if (!constructor && !ts.some(properties)) { + if (!constructor && !needsConstructorBody) { return ts.visitFunctionBody(/*node*/ undefined, visitor, context); } resumeLexicalEnvironment(); @@ -86338,7 +89551,10 @@ var ts; indexOfFirstStatement = afterParameterProperties; } } - addPropertyStatements(statements, properties, factory.createThis()); + var receiver = factory.createThis(); + // private methods can be called in property initializers, they should execute first. + addMethodStatements(statements, privateMethodsAndAccessors, receiver); + addPropertyStatements(statements, properties, receiver); // Add existing statements, skipping the initial super call. if (constructor) { ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement)); @@ -86400,27 +89616,30 @@ var ts; function transformProperty(property, receiver) { var _a; // We generate a name here in order to reuse the value cached by the relocated computed name expression (which uses the same generated name) - var emitAssignment = !context.getCompilerOptions().useDefineForClassFields; + var emitAssignment = !useDefineForClassFields; var propertyName = ts.isComputedPropertyName(property.name) && !ts.isSimpleInlineableExpression(property.name.expression) ? factory.updateComputedPropertyName(property.name, factory.getGeneratedNameForNode(property.name)) : property.name; - if (shouldTransformPrivateFields && ts.isPrivateIdentifier(propertyName)) { + if (shouldTransformPrivateElements && ts.isPrivateIdentifier(propertyName)) { var privateIdentifierInfo = accessPrivateIdentifier(propertyName); if (privateIdentifierInfo) { - switch (privateIdentifierInfo.placement) { - case 0 /* InstanceField */: { - return createPrivateInstanceFieldInitializer(receiver, ts.visitNode(property.initializer, visitor, ts.isExpression), privateIdentifierInfo.weakMapName); + if (privateIdentifierInfo.kind === "f" /* Field */) { + if (!privateIdentifierInfo.isStatic) { + return createPrivateInstanceFieldInitializer(receiver, ts.visitNode(property.initializer, visitor, ts.isExpression), privateIdentifierInfo.brandCheckIdentifier); + } + else { + return createPrivateStaticFieldInitializer(privateIdentifierInfo.variableName, ts.visitNode(property.initializer, visitor, ts.isExpression)); } } + else { + return undefined; + } } else { ts.Debug.fail("Undeclared private name for property declaration."); } } - if (ts.isPrivateIdentifier(propertyName) && !property.initializer) { - return undefined; - } - if (ts.isPrivateIdentifier(propertyName) && !property.initializer) { + if ((ts.isPrivateIdentifier(propertyName) || ts.hasStaticModifier(property)) && !property.initializer) { return undefined; } var propertyOriginalNode = ts.getOriginalNode(property); @@ -86447,11 +89666,26 @@ var ts; enabledSubstitutions |= 1 /* ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(78 /* Identifier */); + context.enableSubstitution(79 /* Identifier */); // Keep track of class aliases. classAliases = []; } } + /** + * Generates brand-check initializer for private methods. + * + * @param statements Statement list that should be used to append new statements. + * @param methods An array of method declarations. + * @param receiver The receiver on which each method should be assigned. + */ + function addMethodStatements(statements, methods, receiver) { + if (!shouldTransformPrivateElements || !ts.some(methods)) { + return; + } + var weakSetName = getPrivateIdentifierEnvironment().weakSetName; + ts.Debug.assert(weakSetName, "weakSetName should be set in private identifier environment"); + statements.push(factory.createExpressionStatement(createPrivateInstanceMethodInitializer(receiver, weakSetName))); + } /** * Hooks node substitutions. * @@ -86467,7 +89701,7 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return substituteExpressionIdentifier(node); } return node; @@ -86487,10 +89721,10 @@ var ts; if (declaration) { var classAlias = classAliases[declaration.id]; // TODO: GH#18217 if (classAlias) { - var clone_2 = factory.cloneNode(classAlias); - ts.setSourceMapRange(clone_2, node); - ts.setCommentRange(clone_2, node); - return clone_2; + var clone_3 = factory.cloneNode(classAlias); + ts.setSourceMapRange(clone_3, node); + ts.setCommentRange(clone_3, node); + return clone_3; } } } @@ -86510,7 +89744,12 @@ var ts; var alreadyTransformed = ts.isAssignmentExpression(innerExpression) && ts.isGeneratedIdentifier(innerExpression.left); if (!alreadyTransformed && !inlinable && shouldHoist) { var generatedName = factory.getGeneratedNameForNode(name); - hoistVariableDeclaration(generatedName); + if (resolver.getNodeCheckFlags(name) & 524288 /* BlockScopedBindingInLoop */) { + addBlockScopedVariable(generatedName); + } + else { + hoistVariableDeclaration(generatedName); + } return factory.createAssignment(generatedName, expression); } return (inlinable || ts.isIdentifier(innerExpression)) ? undefined : expression; @@ -86524,22 +89763,164 @@ var ts; currentPrivateIdentifierEnvironment = privateIdentifierEnvironmentStack.pop(); } function getPrivateIdentifierEnvironment() { - return currentPrivateIdentifierEnvironment || (currentPrivateIdentifierEnvironment = new ts.Map()); + if (!currentPrivateIdentifierEnvironment) { + currentPrivateIdentifierEnvironment = { + className: "", + identifiers: new ts.Map() + }; + } + return currentPrivateIdentifierEnvironment; } function getPendingExpressions() { return pendingExpressions || (pendingExpressions = []); } - function addPrivateIdentifierToEnvironment(name) { - var text = ts.getTextOfPropertyName(name); - var weakMapName = factory.createUniqueName("_" + text.substring(1), 16 /* Optimistic */ | 8 /* ReservedInNestedScopes */); - hoistVariableDeclaration(weakMapName); - getPrivateIdentifierEnvironment().set(name.escapedText, { placement: 0 /* InstanceField */, weakMapName: weakMapName }); - getPendingExpressions().push(factory.createAssignment(weakMapName, factory.createNewExpression(factory.createIdentifier("WeakMap"), - /*typeArguments*/ undefined, []))); + function addPrivateIdentifierToEnvironment(node) { + var _a; + var text = ts.getTextOfPropertyName(node.name); + var env = getPrivateIdentifierEnvironment(); + var weakSetName = env.weakSetName, classConstructor = env.classConstructor; + var assignmentExpressions = []; + var privateName = node.name.escapedText; + var previousInfo = env.identifiers.get(privateName); + var isValid = !isReservedPrivateName(node.name) && previousInfo === undefined; + if (ts.hasStaticModifier(node)) { + ts.Debug.assert(classConstructor, "weakSetName should be set in private identifier environment"); + if (ts.isPropertyDeclaration(node)) { + var variableName = createHoistedVariableForPrivateName(text, node); + env.identifiers.set(privateName, { + kind: "f" /* Field */, + variableName: variableName, + brandCheckIdentifier: classConstructor, + isStatic: true, + isValid: isValid, + }); + } + else if (ts.isMethodDeclaration(node)) { + var functionName = createHoistedVariableForPrivateName(text, node); + env.identifiers.set(privateName, { + kind: "m" /* Method */, + methodName: functionName, + brandCheckIdentifier: classConstructor, + isStatic: true, + isValid: isValid, + }); + } + 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) { + previousInfo.getterName = getterName; + } + else { + env.identifiers.set(privateName, { + kind: "a" /* Accessor */, + getterName: getterName, + setterName: undefined, + brandCheckIdentifier: classConstructor, + isStatic: true, + isValid: isValid, + }); + } + } + 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) { + previousInfo.setterName = setterName; + } + else { + env.identifiers.set(privateName, { + kind: "a" /* Accessor */, + getterName: undefined, + setterName: setterName, + brandCheckIdentifier: classConstructor, + isStatic: true, + isValid: isValid, + }); + } + } + else { + ts.Debug.assertNever(node, "Unknown class element type."); + } + } + else if (ts.isPropertyDeclaration(node)) { + var weakMapName = createHoistedVariableForPrivateName(text, node); + env.identifiers.set(privateName, { + kind: "f" /* Field */, + brandCheckIdentifier: weakMapName, + isStatic: false, + variableName: undefined, + isValid: isValid, + }); + assignmentExpressions.push(factory.createAssignment(weakMapName, factory.createNewExpression(factory.createIdentifier("WeakMap"), + /*typeArguments*/ undefined, []))); + } + else if (ts.isMethodDeclaration(node)) { + ts.Debug.assert(weakSetName, "weakSetName should be set in private identifier environment"); + env.identifiers.set(privateName, { + kind: "m" /* Method */, + methodName: createHoistedVariableForPrivateName(text, node), + brandCheckIdentifier: weakSetName, + isStatic: false, + isValid: isValid, + }); + } + else if (ts.isAccessor(node)) { + 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) { + previousInfo.getterName = getterName; + } + else { + env.identifiers.set(privateName, { + kind: "a" /* Accessor */, + getterName: getterName, + setterName: undefined, + brandCheckIdentifier: weakSetName, + isStatic: false, + isValid: isValid, + }); + } + } + else { + var setterName = createHoistedVariableForPrivateName(text + "_set", node); + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && !previousInfo.isStatic && !previousInfo.setterName) { + previousInfo.setterName = setterName; + } + else { + env.identifiers.set(privateName, { + kind: "a" /* Accessor */, + getterName: undefined, + setterName: setterName, + brandCheckIdentifier: weakSetName, + isStatic: false, + isValid: isValid, + }); + } + } + } + else { + ts.Debug.assertNever(node, "Unknown class element type."); + } + (_a = getPendingExpressions()).push.apply(_a, assignmentExpressions); + } + 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 */) { + addBlockScopedVariable(identifier); + } + else { + hoistVariableDeclaration(identifier); + } + return identifier; + } + function createHoistedVariableForPrivateName(privateName, node) { + return createHoistedVariableForClass(privateName.substring(1), node.name); } function accessPrivateIdentifier(name) { if (currentPrivateIdentifierEnvironment) { - var info = currentPrivateIdentifierEnvironment.get(name.escapedText); + var info = currentPrivateIdentifierEnvironment.identifiers.get(name.escapedText); if (info) { return info; } @@ -86549,7 +89930,7 @@ var ts; if (!env) { continue; } - var info = env.get(name.escapedText); + var info = env.identifiers.get(name.escapedText); if (info) { return info; } @@ -86567,7 +89948,7 @@ 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, 62 /* EqualsToken */, node.expression)); + getPendingExpressions().push(factory.createBinaryExpression(receiver, 63 /* EqualsToken */, node.expression)); } return factory.createPropertyAccessExpression( // Explicit parens required because of v8 regression (https://bugs.chromium.org/p/v8/issues/detail?id=9560) @@ -86580,7 +89961,7 @@ var ts; /*dotDotDotToken*/ undefined, parameter, /*questionToken*/ undefined, /*type*/ undefined, - /*initializer*/ undefined)], factory.createBlock([factory.createExpressionStatement(createPrivateIdentifierAssignment(info, receiver, parameter, 62 /* EqualsToken */))])) + /*initializer*/ undefined)], factory.createBlock([factory.createExpressionStatement(createPrivateIdentifierAssignment(info, receiver, parameter, 63 /* EqualsToken */))])) ])), "value"); } function visitArrayAssignmentTarget(node) { @@ -86635,10 +90016,22 @@ var ts; } } ts.transformClassFields = transformClassFields; + function createPrivateStaticFieldInitializer(variableName, initializer) { + return ts.factory.createAssignment(variableName, ts.factory.createObjectLiteralExpression([ + ts.factory.createPropertyAssignment("value", initializer || ts.factory.createVoidZero()) + ])); + } function createPrivateInstanceFieldInitializer(receiver, initializer, weakMapName) { return ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(weakMapName, "set"), /*typeArguments*/ undefined, [receiver, initializer || ts.factory.createVoidZero()]); } + function createPrivateInstanceMethodInitializer(receiver, weakSetName) { + return ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(weakSetName, "add"), + /*typeArguments*/ undefined, [receiver]); + } + function isReservedPrivateName(node) { + return node.escapedText === "#constructor"; + } })(ts || (ts = {})); /*@internal*/ var ts; @@ -86721,38 +90114,38 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 64 /* ContainsES2017 */) === 0) { + if ((node.transformFlags & 128 /* ContainsES2017 */) === 0) { return node; } switch (node.kind) { - case 129 /* AsyncKeyword */: + case 130 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 213 /* AwaitExpression */: + case 215 /* AwaitExpression */: return visitAwaitExpression(node); - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitMethodDeclaration, node); - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitFunctionDeclaration, node); - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitFunctionExpression, node); - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return doWithContext(1 /* NonTopLevel */, visitArrowFunction, node); - case 201 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 105 /* SuperKeyword */) { + case 203 /* PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SuperKeyword */) { capturedSuperProperties.add(node.name.escapedText); } return ts.visitEachChild(node, visitor, context); - case 202 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 105 /* SuperKeyword */) { + case 204 /* ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 106 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 166 /* Constructor */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 168 /* Constructor */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitDefault, node); default: return ts.visitEachChild(node, visitor, context); @@ -86761,27 +90154,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return visitForStatementInAsyncBody(node); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return visitForInStatementInAsyncBody(node); - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return visitCatchClauseInAsyncBody(node); - case 230 /* Block */: - case 244 /* SwitchStatement */: - case 258 /* CaseBlock */: - case 284 /* CaseClause */: - case 285 /* DefaultClause */: - case 247 /* TryStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: - case 234 /* IfStatement */: - case 243 /* WithStatement */: - case 245 /* LabeledStatement */: + case 232 /* Block */: + case 246 /* SwitchStatement */: + case 260 /* CaseBlock */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: + case 249 /* TryStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: + case 236 /* IfStatement */: + case 245 /* WithStatement */: + case 247 /* LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -86823,18 +90216,18 @@ var ts; function visitForInStatementInAsyncBody(node) { return factory.updateForInStatement(node, isVariableDeclarationListWithCollidingName(node.initializer) ? visitVariableDeclarationListWithCollidingNames(node.initializer, /*hasReceiver*/ true) - : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, asyncBodyVisitor, ts.isStatement, factory.liftToBlock)); + : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitIterationBody(node.statement, asyncBodyVisitor, context)); } function visitForOfStatementInAsyncBody(node) { return factory.updateForOfStatement(node, ts.visitNode(node.awaitModifier, visitor, ts.isToken), isVariableDeclarationListWithCollidingName(node.initializer) ? visitVariableDeclarationListWithCollidingNames(node.initializer, /*hasReceiver*/ true) - : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, asyncBodyVisitor, ts.isStatement, factory.liftToBlock)); + : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitIterationBody(node.statement, asyncBodyVisitor, context)); } function visitForStatementInAsyncBody(node) { var initializer = node.initializer; // TODO: GH#18217 return factory.updateForStatement(node, isVariableDeclarationListWithCollidingName(initializer) ? visitVariableDeclarationListWithCollidingNames(initializer, /*hasReceiver*/ false) - : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitor, ts.isExpression), ts.visitNode(node.statement, asyncBodyVisitor, ts.isStatement, factory.liftToBlock)); + : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitor, ts.isExpression), ts.visitIterationBody(node.statement, asyncBodyVisitor, context)); } /** * Visits an AwaitExpression node. @@ -86986,7 +90379,7 @@ var ts; var original = ts.getOriginalNode(node, ts.isFunctionLike); var nodeType = original.type; var promiseConstructor = languageVersion < 2 /* ES2015 */ ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 209 /* ArrowFunction */; + var isArrowFunction = node.kind === 211 /* ArrowFunction */; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* 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 @@ -87077,17 +90470,17 @@ var ts; enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(203 /* CallExpression */); - context.enableSubstitution(201 /* PropertyAccessExpression */); - context.enableSubstitution(202 /* ElementAccessExpression */); + context.enableSubstitution(205 /* CallExpression */); + context.enableSubstitution(203 /* PropertyAccessExpression */); + context.enableSubstitution(204 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(252 /* ClassDeclaration */); - context.enableEmitNotification(165 /* MethodDeclaration */); - context.enableEmitNotification(167 /* GetAccessor */); - context.enableEmitNotification(168 /* SetAccessor */); - context.enableEmitNotification(166 /* Constructor */); + context.enableEmitNotification(254 /* ClassDeclaration */); + context.enableEmitNotification(167 /* MethodDeclaration */); + context.enableEmitNotification(169 /* GetAccessor */); + context.enableEmitNotification(170 /* SetAccessor */); + context.enableEmitNotification(168 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(232 /* VariableStatement */); + context.enableEmitNotification(234 /* VariableStatement */); } } /** @@ -87135,23 +90528,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -87171,11 +90564,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 252 /* ClassDeclaration */ - || kind === 166 /* Constructor */ - || kind === 165 /* MethodDeclaration */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */; + return kind === 254 /* ClassDeclaration */ + || kind === 168 /* Constructor */ + || kind === 167 /* MethodDeclaration */ + || kind === 169 /* GetAccessor */ + || kind === 170 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -87332,7 +90725,7 @@ var ts; return visitorWorker(node, /*expressionResultIsUnused*/ true); } function visitorNoAsyncModifier(node) { - if (node.kind === 129 /* AsyncKeyword */) { + if (node.kind === 130 /* AsyncKeyword */) { return undefined; } return node; @@ -87354,74 +90747,74 @@ var ts; * expression of an `ExpressionStatement`). */ function visitorWorker(node, expressionResultIsUnused) { - if ((node.transformFlags & 32 /* ContainsES2018 */) === 0) { + if ((node.transformFlags & 64 /* ContainsES2018 */) === 0) { return node; } switch (node.kind) { - case 213 /* AwaitExpression */: + case 215 /* AwaitExpression */: return visitAwaitExpression(node); - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: return visitYieldExpression(node); - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: return visitReturnStatement(node); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return visitLabeledStatement(node); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return visitBinaryExpression(node, expressionResultIsUnused); - case 337 /* CommaListExpression */: + case 345 /* CommaListExpression */: return visitCommaListExpression(node, expressionResultIsUnused); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return visitCatchClause(node); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return visitVariableStatement(node); - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 235 /* DoStatement */: - case 236 /* WhileStatement */: - case 238 /* ForInStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: + case 240 /* ForInStatement */: return doWithHierarchyFacts(visitDefault, node, 0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return doWithHierarchyFacts(visitForStatement, node, 0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - case 212 /* VoidExpression */: + case 214 /* VoidExpression */: return visitVoidExpression(node); - case 166 /* Constructor */: + case 168 /* Constructor */: return doWithHierarchyFacts(visitConstructorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: return doWithHierarchyFacts(visitMethodDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 167 /* GetAccessor */: + case 169 /* GetAccessor */: return doWithHierarchyFacts(visitGetAccessorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 168 /* SetAccessor */: + case 170 /* SetAccessor */: return doWithHierarchyFacts(visitSetAccessorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return doWithHierarchyFacts(visitFunctionDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: return doWithHierarchyFacts(visitFunctionExpression, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return doWithHierarchyFacts(visitArrowFunction, node, 2 /* ArrowFunctionExcludes */, 0 /* ArrowFunctionIncludes */); - case 160 /* Parameter */: + case 162 /* Parameter */: return visitParameter(node); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: return visitExpressionStatement(node); - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, expressionResultIsUnused); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 201 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 105 /* SuperKeyword */) { + case 203 /* PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SuperKeyword */) { capturedSuperProperties.add(node.name.escapedText); } return ts.visitEachChild(node, visitor, context); - case 202 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 105 /* SuperKeyword */) { + case 204 /* ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 106 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: return doWithHierarchyFacts(visitDefault, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); default: return ts.visitEachChild(node, visitor, context); @@ -87457,7 +90850,7 @@ var ts; function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2 /* Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 239 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 241 /* ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return factory.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement, factory.liftToBlock), node); @@ -87469,7 +90862,7 @@ var ts; var objects = []; for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) { var e = elements_4[_i]; - if (e.kind === 290 /* SpreadAssignment */) { + if (e.kind === 292 /* SpreadAssignment */) { if (chunkObject) { objects.push(factory.createObjectLiteralExpression(chunkObject)); chunkObject = undefined; @@ -87478,7 +90871,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 288 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 290 /* PropertyAssignment */ ? factory.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -87489,7 +90882,7 @@ var ts; return objects; } function visitObjectLiteralExpression(node) { - if (node.transformFlags & 16384 /* ContainsObjectRestOrSpread */) { + if (node.transformFlags & 32768 /* 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}); @@ -87512,7 +90905,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 !== 200 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 202 /* ObjectLiteralExpression */) { objects.unshift(factory.createObjectLiteralExpression()); } var expression = objects[0]; @@ -87562,7 +90955,7 @@ var ts; * expression of an `ExpressionStatement`). */ function visitBinaryExpression(node, expressionResultIsUnused) { - if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 16384 /* ContainsObjectRestOrSpread */) { + if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { return ts.flattenDestructuringAssignment(node, visitor, context, 1 /* ObjectRest */, !expressionResultIsUnused); } if (node.operatorToken.kind === 27 /* CommaToken */) { @@ -87593,7 +90986,7 @@ var ts; function visitCatchClause(node) { if (node.variableDeclaration && ts.isBindingPattern(node.variableDeclaration.name) && - node.variableDeclaration.name.transformFlags & 16384 /* ContainsObjectRestOrSpread */) { + node.variableDeclaration.name.transformFlags & 32768 /* 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 */); @@ -87634,14 +91027,14 @@ 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 & 16384 /* ContainsObjectRestOrSpread */) { + if (ts.isBindingPattern(node.name) && node.name.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { return ts.flattenDestructuringBinding(node, visitor, context, 1 /* ObjectRest */, /*rval*/ undefined, exportedVariableStatement); } return ts.visitEachChild(node, visitor, context); } function visitForStatement(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)); + 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.visitIterationBody(node.statement, visitor, context)); } function visitVoidExpression(node) { return ts.visitEachChild(node, visitorWithUnusedExpressionResult, context); @@ -87653,7 +91046,7 @@ var ts; */ function visitForOfStatement(node, outermostLabeledStatement) { var ancestorFacts = enterSubtree(0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - if (node.initializer.transformFlags & 16384 /* ContainsObjectRestOrSpread */) { + if (node.initializer.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { node = transformForOfStatementWithObjectRest(node); } var result = node.awaitModifier ? @@ -87691,7 +91084,7 @@ var ts; var bodyLocation; var statementsLocation; var statements = [ts.visitNode(binding, visitor, ts.isStatement)]; - var statement = ts.visitNode(node.statement, visitor, ts.isStatement); + var statement = ts.visitIterationBody(node.statement, visitor, context); if (ts.isBlock(statement)) { ts.addRange(statements, statement.statements); bodyLocation = statement; @@ -87753,7 +91146,7 @@ var ts; ])); } function visitParameter(node) { - if (node.transformFlags & 16384 /* ContainsObjectRestOrSpread */) { + if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { // Binding patterns are converted into a generated name and are // evaluated inside the function body. return factory.updateParameterDeclaration(node, @@ -87905,7 +91298,7 @@ var ts; function appendObjectRestAssignmentsIfNeeded(statements, node) { for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { var parameter = _a[_i]; - if (parameter.transformFlags & 16384 /* ContainsObjectRestOrSpread */) { + if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { var temp = factory.getGeneratedNameForNode(parameter); var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* ObjectRest */, temp, /*doNotRecordTempVariablesInLine*/ false, @@ -87925,17 +91318,17 @@ var ts; enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(203 /* CallExpression */); - context.enableSubstitution(201 /* PropertyAccessExpression */); - context.enableSubstitution(202 /* ElementAccessExpression */); + context.enableSubstitution(205 /* CallExpression */); + context.enableSubstitution(203 /* PropertyAccessExpression */); + context.enableSubstitution(204 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(252 /* ClassDeclaration */); - context.enableEmitNotification(165 /* MethodDeclaration */); - context.enableEmitNotification(167 /* GetAccessor */); - context.enableEmitNotification(168 /* SetAccessor */); - context.enableEmitNotification(166 /* Constructor */); + context.enableEmitNotification(254 /* ClassDeclaration */); + context.enableEmitNotification(167 /* MethodDeclaration */); + context.enableEmitNotification(169 /* GetAccessor */); + context.enableEmitNotification(170 /* SetAccessor */); + context.enableEmitNotification(168 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(232 /* VariableStatement */); + context.enableEmitNotification(234 /* VariableStatement */); } } /** @@ -87983,23 +91376,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -88019,11 +91412,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 252 /* ClassDeclaration */ - || kind === 166 /* Constructor */ - || kind === 165 /* MethodDeclaration */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */; + return kind === 254 /* ClassDeclaration */ + || kind === 168 /* Constructor */ + || kind === 167 /* MethodDeclaration */ + || kind === 169 /* GetAccessor */ + || kind === 170 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -88051,11 +91444,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 16 /* ContainsES2019 */) === 0) { + if ((node.transformFlags & 32 /* ContainsES2019 */) === 0) { return node; } switch (node.kind) { - case 287 /* CatchClause */: + case 289 /* CatchClause */: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -88083,25 +91476,29 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 8 /* ContainsES2020 */) === 0) { + if ((node.transformFlags & 16 /* ContainsES2020 */) === 0) { return node; } switch (node.kind) { - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: - case 203 /* CallExpression */: - if (node.flags & 32 /* OptionalChain */) { + case 205 /* CallExpression */: { + var updated = visitNonOptionalCallExpression(node, /*captureThisArg*/ false); + ts.Debug.assertNotNode(updated, ts.isSyntheticReference); + return updated; + } + case 203 /* PropertyAccessExpression */: + case 204 /* 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 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: if (node.operatorToken.kind === 60 /* QuestionQuestionToken */) { return transformNullishCoalescingExpression(node); } return ts.visitEachChild(node, visitor, context); - case 210 /* DeleteExpression */: + case 212 /* DeleteExpression */: return visitDeleteExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -88143,7 +91540,7 @@ var ts; thisArg = expression; } } - expression = node.kind === 201 /* PropertyAccessExpression */ + expression = node.kind === 203 /* 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; @@ -88153,14 +91550,23 @@ var ts; // If `node` is an optional chain, then it is the outermost chain of an optional expression. return visitOptionalExpression(node, captureThisArg, /*isDelete*/ false); } + if (ts.isParenthesizedExpression(node.expression) && ts.isOptionalChain(ts.skipParentheses(node.expression))) { + // capture thisArg for calls of parenthesized optional chains like `(foo?.bar)()` + var expression = visitNonOptionalParenthesizedExpression(node.expression, /*captureThisArg*/ true, /*isDelete*/ false); + var args = ts.visitNodes(node.arguments, visitor, ts.isExpression); + if (ts.isSyntheticReference(expression)) { + return ts.setTextRange(factory.createFunctionCallCall(expression.expression, expression.thisArg, args), node); + } + return factory.updateCallExpression(node, expression, /*typeArguments*/ undefined, args); + } return ts.visitEachChild(node, visitor, context); } function visitNonOptionalExpression(node, captureThisArg, isDelete) { switch (node.kind) { - case 207 /* ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete); - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete); - case 203 /* CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); + case 209 /* ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete); + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete); + case 205 /* CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); default: return ts.visitNode(node, visitor, ts.isExpression); } } @@ -88179,8 +91585,8 @@ var ts; for (var i = 0; i < chain.length; i++) { var segment = chain[i]; switch (segment.kind) { - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: if (i === chain.length - 1 && captureThisArg) { if (!ts.isSimpleCopiableExpression(rightExpression)) { thisArg = factory.createTempVariable(hoistVariableDeclaration); @@ -88190,13 +91596,13 @@ var ts; thisArg = rightExpression; } } - rightExpression = segment.kind === 201 /* PropertyAccessExpression */ + rightExpression = segment.kind === 203 /* PropertyAccessExpression */ ? factory.createPropertyAccessExpression(rightExpression, ts.visitNode(segment.name, visitor, ts.isIdentifier)) : factory.createElementAccessExpression(rightExpression, ts.visitNode(segment.argumentExpression, visitor, ts.isExpression)); break; - case 203 /* CallExpression */: + case 205 /* CallExpression */: if (i === 0 && leftThisArg) { - rightExpression = factory.createFunctionCallCall(rightExpression, leftThisArg.kind === 105 /* SuperKeyword */ ? factory.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); + rightExpression = factory.createFunctionCallCall(rightExpression, leftThisArg.kind === 106 /* SuperKeyword */ ? factory.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); } else { rightExpression = factory.createCallExpression(rightExpression, @@ -88237,7 +91643,7 @@ var ts; /*@internal*/ var ts; (function (ts) { - function transformESNext(context) { + function transformES2021(context) { var hoistVariableDeclaration = context.hoistVariableDeclaration, factory = context.factory; return ts.chainBundle(context, transformSourceFile); function transformSourceFile(node) { @@ -88247,11 +91653,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 4 /* ContainsESNext */) === 0) { + if ((node.transformFlags & 8 /* ContainsES2021 */) === 0) { return node; } switch (node.kind) { - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: var binaryExpression = node; if (ts.isLogicalOrCoalescingAssignmentExpression(binaryExpression)) { return transformLogicalAssignment(binaryExpression); @@ -88287,6 +91693,29 @@ var ts; return factory.createBinaryExpression(left, nonAssignmentOperator, factory.createParenthesizedExpression(factory.createAssignment(assignmentTarget, right))); } } + ts.transformES2021 = transformES2021; +})(ts || (ts = {})); +/*@internal*/ +var ts; +(function (ts) { + function transformESNext(context) { + return ts.chainBundle(context, transformSourceFile); + function transformSourceFile(node) { + if (node.isDeclarationFile) { + return node; + } + return ts.visitEachChild(node, visitor, context); + } + function visitor(node) { + if ((node.transformFlags & 4 /* ContainsESNext */) === 0) { + return node; + } + switch (node.kind) { + default: + return ts.visitEachChild(node, visitor, context); + } + } + } ts.transformESNext = transformESNext; })(ts || (ts = {})); /*@internal*/ @@ -88397,13 +91826,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 273 /* JsxElement */: + case 275 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 274 /* JsxSelfClosingElement */: + case 276 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 277 /* JsxFragment */: + case 279 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -88413,13 +91842,13 @@ var ts; switch (node.kind) { case 11 /* JsxText */: return visitJsxText(node); - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: return visitJsxExpression(node); - case 273 /* JsxElement */: + case 275 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 274 /* JsxSelfClosingElement */: + case 276 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 277 /* JsxFragment */: + case 279 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -88537,21 +91966,29 @@ var ts; // When there are no attributes, React wants "null" } else { - // Map spans of JsxAttribute nodes into object literals and spans - // of JsxSpreadAttribute nodes into expressions. - var segments = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread - ? ts.map(attrs, transformJsxSpreadAttributeToExpression) - : factory.createObjectLiteralExpression(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); })); - if (ts.isJsxSpreadAttribute(attrs[0])) { - // We must always emit at least one object literal before a spread - // argument.factory.createObjectLiteral - segments.unshift(factory.createObjectLiteralExpression()); + var target = compilerOptions.target; + if (target && target >= 5 /* ES2018 */) { + objectProperties = factory.createObjectLiteralExpression(ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { + return isSpread ? ts.map(attrs, transformJsxSpreadAttributeToSpreadAssignment) : ts.map(attrs, transformJsxAttributeToObjectLiteralElement); + }))); } - // Either emit one big object literal (no spread attribs), or - // a call to the __assign helper. - objectProperties = ts.singleOrUndefined(segments); - if (!objectProperties) { - objectProperties = emitHelpers().createAssignHelper(segments); + else { + // Map spans of JsxAttribute nodes into object literals and spans + // of JsxSpreadAttribute nodes into expressions. + var segments = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread + ? ts.map(attrs, transformJsxSpreadAttributeToExpression) + : factory.createObjectLiteralExpression(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); })); + if (ts.isJsxSpreadAttribute(attrs[0])) { + // We must always emit at least one object literal before a spread + // argument.factory.createObjectLiteral + segments.unshift(factory.createObjectLiteralExpression()); + } + // Either emit one big object literal (no spread attribs), or + // a call to the __assign helper. + objectProperties = ts.singleOrUndefined(segments); + if (!objectProperties) { + objectProperties = emitHelpers().createAssignHelper(segments); + } } } var callee = currentFileState.importSpecifier === undefined @@ -88583,6 +92020,9 @@ var ts; } return element; } + function transformJsxSpreadAttributeToSpreadAssignment(node) { + return factory.createSpreadAssignment(ts.visitNode(node.expression, visitor, ts.isExpression)); + } function transformJsxSpreadAttributeToExpression(node) { return ts.visitNode(node.expression, visitor, ts.isExpression); } @@ -88602,7 +92042,7 @@ var ts; var literal = factory.createStringLiteral(tryDecodeEntities(node.text) || node.text, singleQuote); return ts.setTextRange(literal, node); } - else if (node.kind === 283 /* JsxExpression */) { + else if (node.kind === 285 /* JsxExpression */) { if (node.expression === undefined) { return factory.createTrue(); } @@ -88696,7 +92136,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 273 /* JsxElement */) { + if (node.kind === 275 /* JsxElement */) { return getTagName(node.openingElement); } else { @@ -88998,11 +92438,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 128 /* ContainsES2016 */) === 0) { + if ((node.transformFlags & 256 /* ContainsES2016 */) === 0) { return node; } switch (node.kind) { - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -89010,7 +92450,7 @@ var ts; } function visitBinaryExpression(node) { switch (node.operatorToken.kind) { - case 66 /* AsteriskAsteriskEqualsToken */: + case 67 /* AsteriskAsteriskEqualsToken */: return visitExponentiationAssignmentExpression(node); case 42 /* AsteriskAsteriskToken */: return visitExponentiationExpression(node); @@ -89215,11 +92655,11 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 242 /* ReturnStatement */ + && node.kind === 244 /* ReturnStatement */ && !node.expression; } function isOrMayContainReturnCompletion(node) { - return node.transformFlags & 1048576 /* ContainsHoistedDeclarationOrCompletion */ + return node.transformFlags & 2097152 /* ContainsHoistedDeclarationOrCompletion */ && (ts.isReturnStatement(node) || ts.isIfStatement(node) || ts.isWithStatement(node) @@ -89234,7 +92674,7 @@ var ts; || ts.isBlock(node)); } function shouldVisitNode(node) { - return (node.transformFlags & 256 /* ContainsES2015 */) !== 0 + return (node.transformFlags & 512 /* ContainsES2015 */) !== 0 || convertedLoopState !== undefined || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && isOrMayContainReturnCompletion(node)) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatement(node)) @@ -89247,74 +92687,74 @@ var ts; return shouldVisitNode(node) ? visitorWorker(node, /*expressionResultIsUnused*/ true) : node; } function callExpressionVisitor(node) { - if (node.kind === 105 /* SuperKeyword */) { + if (node.kind === 106 /* SuperKeyword */) { return visitSuperKeyword(/*isExpressionOfCall*/ true); } return visitor(node); } function visitorWorker(node, expressionResultIsUnused) { switch (node.kind) { - case 123 /* StaticKeyword */: + case 124 /* StaticKeyword */: return undefined; // elide static keyword - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: return visitClassDeclaration(node); - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: return visitClassExpression(node); - case 160 /* Parameter */: + case 162 /* Parameter */: return visitParameter(node); - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return visitArrowFunction(node); - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: return visitFunctionExpression(node); - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 78 /* Identifier */: + case 79 /* Identifier */: return visitIdentifier(node); - case 250 /* VariableDeclarationList */: + case 252 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: return visitSwitchStatement(node); - case 258 /* CaseBlock */: + case 260 /* CaseBlock */: return visitCaseBlock(node); - case 230 /* Block */: + case 232 /* Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 241 /* BreakStatement */: - case 240 /* ContinueStatement */: + case 243 /* BreakStatement */: + case 242 /* ContinueStatement */: return visitBreakOrContinueStatement(node); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return visitLabeledStatement(node); - case 235 /* DoStatement */: - case 236 /* WhileStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: return visitExpressionStatement(node); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return visitCatchClause(node); - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return visitCallExpression(node); - case 204 /* NewExpression */: + case 206 /* NewExpression */: return visitNewExpression(node); - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, expressionResultIsUnused); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return visitBinaryExpression(node, expressionResultIsUnused); - case 337 /* CommaListExpression */: + case 345 /* CommaListExpression */: return visitCommaListExpression(node, expressionResultIsUnused); case 14 /* NoSubstitutionTemplateLiteral */: case 15 /* TemplateHead */: @@ -89325,30 +92765,30 @@ var ts; return visitStringLiteral(node); case 8 /* NumericLiteral */: return visitNumericLiteral(node); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 218 /* TemplateExpression */: + case 220 /* TemplateExpression */: return visitTemplateExpression(node); - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: return visitYieldExpression(node); - case 220 /* SpreadElement */: + case 222 /* SpreadElement */: return visitSpreadElement(node); - case 105 /* SuperKeyword */: + case 106 /* SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: return visitThisKeyword(node); - case 226 /* MetaProperty */: + case 228 /* MetaProperty */: return visitMetaProperty(node); - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return visitAccessorDeclaration(node); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return visitVariableStatement(node); - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: return visitReturnStatement(node); - case 212 /* VoidExpression */: + case 214 /* VoidExpression */: return visitVoidExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -89438,14 +92878,14 @@ 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 === 241 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 243 /* BreakStatement */ ? 2 /* Break */ : 4 /* 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 === 241 /* BreakStatement */) { + if (node.kind === 243 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -89456,7 +92896,7 @@ var ts; } } else { - if (node.kind === 241 /* BreakStatement */) { + if (node.kind === 243 /* BreakStatement */) { labelMarker = "break-" + label.escapedText; setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } @@ -89716,7 +93156,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 !== 103 /* NullKeyword */; + var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */; // When the subclass does not have a constructor, we synthesize a *default* constructor using the following // representation: // @@ -89768,7 +93208,7 @@ var ts; factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment()); insertCaptureNewTargetIfNeeded(prologue, constructor, /*copyOnWrite*/ false); if (isDerivedClass) { - if (superCallExpression && statementOffset === constructor.body.statements.length && !(constructor.body.transformFlags & 4096 /* ContainsLexicalThis */)) { + if (superCallExpression && statementOffset === constructor.body.statements.length && !(constructor.body.transformFlags & 8192 /* ContainsLexicalThis */)) { // If the subclass constructor does *not* contain `this` and *ends* with a `super()` call, we will use the // following representation: // @@ -89854,11 +93294,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 242 /* ReturnStatement */) { + if (statement.kind === 244 /* ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 234 /* IfStatement */) { + else if (statement.kind === 236 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -89866,7 +93306,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 230 /* Block */) { + else if (statement.kind === 232 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -90024,10 +93464,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 === 78 /* Identifier */ ? ts.setParent(ts.setTextRange(factory.cloneNode(parameter.name), parameter.name), parameter.name.parent) : factory.createTempVariable(/*recordTempVariable*/ undefined); + 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 */); // `expressionName` is the name of the parameter used in expressions. - var expressionName = parameter.name.kind === 78 /* Identifier */ ? factory.cloneNode(parameter.name) : declarationName; + var expressionName = parameter.name.kind === 79 /* Identifier */ ? factory.cloneNode(parameter.name) : declarationName; var restIndex = node.parameters.length - 1; var temp = factory.createLoopVariable(); // var param = []; @@ -90052,7 +93492,7 @@ var ts; ts.setEmitFlags(forStatement, 1048576 /* CustomPrologue */); ts.startOnNewLine(forStatement); prologueStatements.push(forStatement); - if (parameter.name.kind !== 78 /* Identifier */) { + if (parameter.name.kind !== 79 /* 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 */)); @@ -90068,7 +93508,7 @@ var ts; * @param node A node. */ function insertCaptureThisForNodeIfNeeded(statements, node) { - if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 209 /* ArrowFunction */) { + if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 211 /* ArrowFunction */) { insertCaptureThisForNode(statements, node, factory.createThis()); return true; } @@ -90090,25 +93530,25 @@ var ts; if (hierarchyFacts & 16384 /* NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return statements; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: // Methods and accessors cannot be constructors, so 'new.target' will // always return 'undefined'. newTarget = factory.createVoidZero(); break; - case 166 /* Constructor */: + case 168 /* 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"); break; - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 210 /* 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 */), 101 /* InstanceOfKeyword */, factory.getLocalName(node))), + 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"), /*colonToken*/ undefined, factory.createVoidZero()); break; @@ -90140,20 +93580,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 229 /* SemicolonClassElement */: + case 231 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 166 /* Constructor */: + case 168 /* Constructor */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -90182,7 +93622,7 @@ var ts; var memberFunction = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined, container); var propertyName = ts.visitNode(member.name, visitor, ts.isPropertyName); var e; - if (!ts.isPrivateIdentifier(propertyName) && context.getCompilerOptions().useDefineForClassFields) { + if (!ts.isPrivateIdentifier(propertyName) && ts.getUseDefineForClassFields(context.getCompilerOptions())) { var name = ts.isComputedPropertyName(propertyName) ? propertyName.expression : ts.isIdentifier(propertyName) ? factory.createStringLiteral(ts.unescapeLeadingUnderscores(propertyName.escapedText)) : propertyName; @@ -90274,7 +93714,7 @@ var ts; * @param node An ArrowFunction node. */ function visitArrowFunction(node) { - if (node.transformFlags & 4096 /* ContainsLexicalThis */) { + if (node.transformFlags & 8192 /* ContainsLexicalThis */) { hierarchyFacts |= 32768 /* CapturedLexicalThis */; } var savedConvertedLoopState = convertedLoopState; @@ -90356,7 +93796,7 @@ var ts; : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 251 /* FunctionDeclaration */ || node.kind === 208 /* FunctionExpression */)) { + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 253 /* FunctionDeclaration */ || node.kind === 210 /* FunctionExpression */)) { name = factory.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */); @@ -90402,7 +93842,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 209 /* ArrowFunction */); + ts.Debug.assert(node.kind === 211 /* 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 @@ -90537,7 +93977,7 @@ var ts; assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0 /* All */); } else { - assignment = factory.createBinaryExpression(decl.name, 62 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + assignment = factory.createBinaryExpression(decl.name, 63 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); ts.setTextRange(assignment, decl); } assignments = ts.append(assignments, assignment); @@ -90563,7 +94003,7 @@ var ts; * @param node A VariableDeclarationList node. */ function visitVariableDeclarationList(node) { - if (node.flags & 3 /* BlockScoped */ || node.transformFlags & 131072 /* ContainsBindingPattern */) { + if (node.flags & 3 /* BlockScoped */ || node.transformFlags & 262144 /* ContainsBindingPattern */) { if (node.flags & 3 /* BlockScoped */) { enableSubstitutionsForBlockScopedBindings(); } @@ -90576,7 +94016,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 & 131072 /* ContainsBindingPattern */ + if (node.transformFlags & 262144 /* ContainsBindingPattern */ && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.last(node.declarations).name))) { ts.setSourceMapRange(declarationList, getRangeUnion(declarations)); } @@ -90588,8 +94028,8 @@ var ts; // declarations may not be sorted by position. // pos should be the minimum* position over all nodes (that's not -1), end should be the maximum end over all nodes. var pos = -1, end = -1; - for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) { - var node = declarations_10[_i]; + for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { + var node = declarations_9[_i]; pos = pos === -1 ? node.pos : node.pos === -1 ? pos : Math.min(pos, node.pos); end = Math.max(end, node.end); } @@ -90709,14 +94149,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 235 /* DoStatement */: - case 236 /* WhileStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -90900,9 +94340,9 @@ var ts; var numInitialProperties = -1, hasComputed = false; for (var i = 0; i < properties.length; i++) { var property = properties[i]; - if ((property.transformFlags & 262144 /* ContainsYield */ && + if ((property.transformFlags & 524288 /* ContainsYield */ && hierarchyFacts & 4 /* AsyncFunctionBody */) - || (hasComputed = ts.Debug.checkDefined(property.name).kind === 158 /* ComputedPropertyName */)) { + || (hasComputed = ts.Debug.checkDefined(property.name).kind === 160 /* ComputedPropertyName */)) { numInitialProperties = i; break; } @@ -90954,7 +94394,7 @@ var ts; } visit(node.name); function visit(node) { - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { state.hoistedLocalVariables.push(node); } else { @@ -91005,24 +94445,24 @@ var ts; loop = convert(node, outermostLabeledStatement, bodyFunction.part, ancestorFacts); } else { - var clone_3 = convertIterationStatementCore(node, initializerFunction, factory.createBlock(bodyFunction.part, /*multiLine*/ true)); - loop = factory.restoreEnclosingLabel(clone_3, outermostLabeledStatement, convertedLoopState && resetLabel); + var clone_4 = convertIterationStatementCore(node, initializerFunction, factory.createBlock(bodyFunction.part, /*multiLine*/ true)); + loop = factory.restoreEnclosingLabel(clone_4, outermostLabeledStatement, convertedLoopState && resetLabel); } } else { - var clone_4 = convertIterationStatementCore(node, initializerFunction, ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - loop = factory.restoreEnclosingLabel(clone_4, outermostLabeledStatement, convertedLoopState && resetLabel); + var clone_5 = convertIterationStatementCore(node, initializerFunction, ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock)); + loop = factory.restoreEnclosingLabel(clone_5, outermostLabeledStatement, convertedLoopState && resetLabel); } statements.push(loop); return statements; } function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) { switch (node.kind) { - case 237 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); - case 238 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); - case 239 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); - case 235 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); - case 236 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); + case 239 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); + case 240 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); + case 241 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); + case 237 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); + case 238 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected"); } } @@ -91047,11 +94487,11 @@ var ts; function createConvertedLoopState(node) { var loopInitializer; switch (node.kind) { - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 250 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 252 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -91171,7 +94611,7 @@ var ts; */ function createFunctionForInitializerOfForStatement(node, currentState) { var functionName = factory.createUniqueName("_loop_init"); - var containsYield = (node.initializer.transformFlags & 262144 /* ContainsYield */) !== 0; + var containsYield = (node.initializer.transformFlags & 524288 /* ContainsYield */) !== 0; var emitFlags = 0 /* None */; if (currentState.containsLexicalThis) emitFlags |= 8 /* CapturesThis */; @@ -91286,7 +94726,7 @@ var ts; var loopBody = factory.createBlock(statements, /*multiLine*/ true); if (ts.isBlock(statement)) ts.setOriginalNode(loopBody, statement); - var containsYield = (node.statement.transformFlags & 262144 /* ContainsYield */) !== 0; + var containsYield = (node.statement.transformFlags & 524288 /* ContainsYield */) !== 0; var emitFlags = 524288 /* ReuseTempVariableScope */; if (currentState.containsLexicalThis) emitFlags |= 8 /* CapturesThis */; @@ -91322,7 +94762,7 @@ var ts; 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, 62 /* EqualsToken */, source); + return factory.createBinaryExpression(target, 63 /* EqualsToken */, source); } function copyOutParameters(outParams, partFlags, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { @@ -91459,20 +94899,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -91579,7 +95019,7 @@ var ts; var updated; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (node.kind === 167 /* GetAccessor */) { + if (node.kind === 169 /* GetAccessor */) { updated = factory.updateGetAccessorDeclaration(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); } else { @@ -91632,7 +95072,7 @@ var ts; return visitTypeScriptClassWrapper(node); } var expression = ts.skipOuterExpressions(node.expression); - if (expression.kind === 105 /* SuperKeyword */ || + if (expression.kind === 106 /* SuperKeyword */ || ts.isSuperProperty(expression) || ts.some(node.arguments, ts.isSpreadElement)) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); @@ -91759,15 +95199,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 & 8192 /* ContainsRestOrSpread */ || - node.expression.kind === 105 /* SuperKeyword */ || + if (node.transformFlags & 16384 /* ContainsRestOrSpread */ || + node.expression.kind === 106 /* SuperKeyword */ || ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) { var _a = factory.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { ts.setEmitFlags(thisArg, 4 /* NoSubstitution */); } var resultingCall = void 0; - if (node.transformFlags & 8192 /* ContainsRestOrSpread */) { + if (node.transformFlags & 16384 /* ContainsRestOrSpread */) { // [source] // f(...a, b) // x.m(...a, b) @@ -91781,7 +95221,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 === 105 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); + resultingCall = factory.createFunctionApplyCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); } else { // [source] @@ -91793,9 +95233,9 @@ 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 === 105 /* 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 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression)), node); } - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { var initializer = factory.createLogicalOr(resultingCall, createActualThis()); resultingCall = assignToCapturedThis ? factory.createAssignment(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), initializer) @@ -92042,7 +95482,7 @@ var ts; : factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */); } function visitMetaProperty(node) { - if (node.keywordToken === 102 /* NewKeyword */ && node.name.escapedText === "target") { + if (node.keywordToken === 103 /* NewKeyword */ && node.name.escapedText === "target") { hierarchyFacts |= 16384 /* NewTarget */; return factory.createUniqueName("_newTarget", 16 /* Optimistic */ | 32 /* FileLevel */); } @@ -92074,7 +95514,7 @@ var ts; function enableSubstitutionsForBlockScopedBindings() { if ((enabledSubstitutions & 2 /* BlockScopedBindings */) === 0) { enabledSubstitutions |= 2 /* BlockScopedBindings */; - context.enableSubstitution(78 /* Identifier */); + context.enableSubstitution(79 /* Identifier */); } } /** @@ -92084,14 +95524,14 @@ var ts; function enableSubstitutionsForCapturedThis() { if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { enabledSubstitutions |= 1 /* CapturedThis */; - context.enableSubstitution(107 /* ThisKeyword */); - context.enableEmitNotification(166 /* Constructor */); - context.enableEmitNotification(165 /* MethodDeclaration */); - context.enableEmitNotification(167 /* GetAccessor */); - context.enableEmitNotification(168 /* SetAccessor */); - context.enableEmitNotification(209 /* ArrowFunction */); - context.enableEmitNotification(208 /* FunctionExpression */); - context.enableEmitNotification(251 /* FunctionDeclaration */); + context.enableSubstitution(108 /* ThisKeyword */); + context.enableEmitNotification(168 /* Constructor */); + context.enableEmitNotification(167 /* MethodDeclaration */); + context.enableEmitNotification(169 /* GetAccessor */); + context.enableEmitNotification(170 /* SetAccessor */); + context.enableEmitNotification(211 /* ArrowFunction */); + context.enableEmitNotification(210 /* FunctionExpression */); + context.enableEmitNotification(253 /* FunctionDeclaration */); } } /** @@ -92132,10 +95572,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 198 /* BindingElement */: - case 252 /* ClassDeclaration */: - case 255 /* EnumDeclaration */: - case 249 /* VariableDeclaration */: + case 200 /* BindingElement */: + case 254 /* ClassDeclaration */: + case 257 /* EnumDeclaration */: + case 251 /* VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -92148,9 +95588,9 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return substituteExpressionIdentifier(node); - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: return substituteThisKeyword(node); } return node; @@ -92217,19 +95657,19 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 233 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 235 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 203 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 205 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 105 /* SuperKeyword */) { + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 106 /* SuperKeyword */) { return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 220 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 222 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -92255,15 +95695,15 @@ var ts; if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(275 /* JsxOpeningElement */); - context.enableEmitNotification(276 /* JsxClosingElement */); - context.enableEmitNotification(274 /* JsxSelfClosingElement */); + context.enableEmitNotification(277 /* JsxOpeningElement */); + context.enableEmitNotification(278 /* JsxClosingElement */); + context.enableEmitNotification(276 /* JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(201 /* PropertyAccessExpression */); - context.enableSubstitution(288 /* PropertyAssignment */); + context.enableSubstitution(203 /* PropertyAccessExpression */); + context.enableSubstitution(290 /* PropertyAssignment */); return ts.chainBundle(context, transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -92282,9 +95722,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 275 /* JsxOpeningElement */: - case 276 /* JsxClosingElement */: - case 274 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: + case 278 /* JsxClosingElement */: + case 276 /* JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -92344,7 +95784,7 @@ var ts; */ function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined); - if (token !== undefined && token >= 80 /* FirstReservedWord */ && token <= 115 /* LastReservedWord */) { + if (token !== undefined && token >= 81 /* FirstReservedWord */ && token <= 116 /* LastReservedWord */) { return ts.setTextRange(factory.createStringLiteralFromNode(name), name); } return undefined; @@ -92582,7 +96022,7 @@ var ts; var withBlockStack; // A stack containing `with` blocks. return ts.chainBundle(context, transformSourceFile); function transformSourceFile(node) { - if (node.isDeclarationFile || (node.transformFlags & 512 /* ContainsGenerator */) === 0) { + if (node.isDeclarationFile || (node.transformFlags & 1024 /* ContainsGenerator */) === 0) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -92605,7 +96045,7 @@ var ts; else if (ts.isFunctionLikeDeclaration(node) && node.asteriskToken) { return visitGenerator(node); } - else if (transformFlags & 512 /* ContainsGenerator */) { + else if (transformFlags & 1024 /* ContainsGenerator */) { return ts.visitEachChild(node, visitor, context); } else { @@ -92619,13 +96059,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 235 /* DoStatement */: + case 237 /* DoStatement */: return visitDoStatement(node); - case 236 /* WhileStatement */: + case 238 /* WhileStatement */: return visitWhileStatement(node); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: return visitSwitchStatement(node); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -92638,30 +96078,30 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: return visitFunctionExpression(node); - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return visitAccessorDeclaration(node); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return visitVariableStatement(node); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return visitForStatement(node); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return visitForInStatement(node); - case 241 /* BreakStatement */: + case 243 /* BreakStatement */: return visitBreakStatement(node); - case 240 /* ContinueStatement */: + case 242 /* ContinueStatement */: return visitContinueStatement(node); - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: return visitReturnStatement(node); default: - if (node.transformFlags & 262144 /* ContainsYield */) { + if (node.transformFlags & 524288 /* ContainsYield */) { return visitJavaScriptContainingYield(node); } - else if (node.transformFlags & (512 /* ContainsGenerator */ | 1048576 /* ContainsHoistedDeclarationOrCompletion */)) { + else if (node.transformFlags & (1024 /* ContainsGenerator */ | 2097152 /* ContainsHoistedDeclarationOrCompletion */)) { return ts.visitEachChild(node, visitor, context); } else { @@ -92676,23 +96116,23 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return visitBinaryExpression(node); - case 337 /* CommaListExpression */: + case 345 /* CommaListExpression */: return visitCommaListExpression(node); - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: return visitConditionalExpression(node); - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: return visitYieldExpression(node); - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return visitCallExpression(node); - case 204 /* NewExpression */: + case 206 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -92705,9 +96145,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -92866,7 +96306,7 @@ var ts; * @param node The node to visit. */ function visitVariableStatement(node) { - if (node.transformFlags & 262144 /* ContainsYield */) { + if (node.transformFlags & 524288 /* ContainsYield */) { transformAndEmitVariableDeclarationList(node.declarationList); return undefined; } @@ -92915,7 +96355,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -92927,7 +96367,7 @@ var ts; // _a.b = %sent%; target = factory.updatePropertyAccessExpression(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -93321,35 +96761,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 230 /* Block */: + case 232 /* Block */: return transformAndEmitBlock(node); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 234 /* IfStatement */: + case 236 /* IfStatement */: return transformAndEmitIfStatement(node); - case 235 /* DoStatement */: + case 237 /* DoStatement */: return transformAndEmitDoStatement(node); - case 236 /* WhileStatement */: + case 238 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return transformAndEmitForStatement(node); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 240 /* ContinueStatement */: + case 242 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 241 /* BreakStatement */: + case 243 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 243 /* WithStatement */: + case 245 /* WithStatement */: return transformAndEmitWithStatement(node); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 246 /* ThrowStatement */: + case 248 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 247 /* TryStatement */: + case 249 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -93569,7 +97009,7 @@ var ts; var variables = ts.getInitializedVariables(initializer); node = factory.updateForStatement(node, variables.length > 0 ? factory.inlineExpressions(ts.map(variables, transformInitializedVariable)) - : undefined, ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitor, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock)); + : undefined, ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitor, ts.isExpression), ts.visitIterationBody(node.statement, visitor, context)); } else { node = ts.visitEachChild(node, visitor, context); @@ -93779,7 +97219,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 285 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 287 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -93792,7 +97232,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 284 /* CaseClause */) { + if (clause.kind === 286 /* CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -93924,7 +97364,7 @@ var ts; } } function containsYield(node) { - return !!node && (node.transformFlags & 262144 /* ContainsYield */) !== 0; + return !!node && (node.transformFlags & 524288 /* ContainsYield */) !== 0; } function countInitialNodesWithoutYield(nodes) { var numNodes = nodes.length; @@ -93957,10 +97397,10 @@ var ts; var name = renamedCatchVariableDeclarations[ts.getOriginalNodeId(declaration)]; if (name) { // TODO(rbuckton): Does this need to be parented? - var clone_5 = ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent); - ts.setSourceMapRange(clone_5, node); - ts.setCommentRange(clone_5, node); - return clone_5; + var clone_6 = ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent); + ts.setSourceMapRange(clone_6, node); + ts.setCommentRange(clone_6, node); + return clone_6; } } } @@ -94106,7 +97546,7 @@ var ts; if (!renamedCatchVariables) { renamedCatchVariables = new ts.Map(); renamedCatchVariableDeclarations = []; - context.enableSubstitution(78 /* Identifier */); + context.enableSubstitution(79 /* Identifier */); } renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; @@ -94952,12 +98392,12 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(78 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(216 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(214 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(215 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(289 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(297 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(79 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. + context.enableSubstitution(218 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(216 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(217 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(291 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(299 /* 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. @@ -94973,7 +98413,7 @@ var ts; function transformSourceFile(node) { if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || - node.transformFlags & 2097152 /* ContainsDynamicImport */ || + node.transformFlags & 4194304 /* ContainsDynamicImport */ || (ts.isJsonSourceFile(node) && ts.hasJsonModuleEmitEnabled(compilerOptions) && ts.outFile(compilerOptions)))) { return node; } @@ -95285,23 +98725,23 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return visitImportDeclaration(node); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: return visitExportDeclaration(node); - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return visitExportAssignment(node); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return visitVariableStatement(node); - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: return visitClassDeclaration(node); - case 338 /* MergeDeclarationMarker */: + case 346 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 339 /* EndOfDeclarationMarker */: + case 347 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -95310,7 +98750,7 @@ var ts; function moduleExpressionElementVisitor(node) { // This visitor does not need to descend into the tree if there is no dynamic import or destructuring assignment, // as export/import statements are only transformed at the top level of a file. - if (!(node.transformFlags & 2097152 /* ContainsDynamicImport */) && !(node.transformFlags & 1024 /* ContainsDestructuringAssignment */)) { + if (!(node.transformFlags & 4194304 /* ContainsDynamicImport */) && !(node.transformFlags & 2048 /* ContainsDestructuringAssignment */)) { return node; } if (ts.isImportCall(node)) { @@ -95328,24 +98768,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 290 /* SpreadAssignment */: + case 292 /* SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -95380,7 +98820,7 @@ var ts; var firstArgument = ts.visitNode(ts.firstOrUndefined(node.arguments), moduleExpressionElementVisitor); // 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 & 4096 /* ContainsLexicalThis */); + var containsLexicalThis = !!(node.transformFlags & 8192 /* ContainsLexicalThis */); switch (compilerOptions.module) { case ts.ModuleKind.AMD: return createImportCallExpressionAMD(argument, containsLexicalThis); @@ -95873,7 +99313,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 232 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 234 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -95928,10 +99368,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 264 /* NamedImports */: + case 266 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding, /* liveBinding */ true); @@ -96127,8 +99567,8 @@ var ts; function modifierVisitor(node) { // Elide module-specific modifiers. switch (node.kind) { - case 92 /* ExportKeyword */: - case 87 /* DefaultKeyword */: + case 93 /* ExportKeyword */: + case 88 /* DefaultKeyword */: return undefined; } return node; @@ -96144,7 +99584,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 297 /* SourceFile */) { + if (node.kind === 299 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -96206,12 +99646,12 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return substituteExpressionIdentifier(node); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return substituteBinaryExpression(node); - case 215 /* PostfixUnaryExpression */: - case 214 /* PrefixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -96231,9 +99671,9 @@ var ts; } return node; } - if (!(ts.isGeneratedIdentifier(node) && !(node.autoGenerateFlags & 64 /* AllowNameSubstitution */)) && !ts.isLocalName(node)) { + else if (!(ts.isGeneratedIdentifier(node) && !(node.autoGenerateFlags & 64 /* AllowNameSubstitution */)) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 297 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 299 /* SourceFile */) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.cloneNode(node)), /*location*/ node); } @@ -96308,8 +99748,8 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 215 /* PostfixUnaryExpression */ - ? ts.setTextRange(factory.createBinaryExpression(node.operand, factory.createToken(node.operator === 45 /* PlusPlusToken */ ? 63 /* PlusEqualsToken */ : 64 /* MinusEqualsToken */), factory.createNumericLiteral(1)), + var expression = node.kind === 217 /* PostfixUnaryExpression */ + ? ts.setTextRange(factory.createPrefixUnaryExpression(node.operator, node.operand), /*location*/ node) : node; for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) { @@ -96318,6 +99758,12 @@ var ts; noSubstitution[ts.getNodeId(expression)] = true; expression = createExportExpression(exportName, expression); } + if (node.kind === 217 /* PostfixUnaryExpression */) { + noSubstitution[ts.getNodeId(expression)] = true; + expression = node.operator === 45 /* PlusPlusToken */ + ? factory.createSubtract(expression, factory.createNumericLiteral(1)) + : factory.createAdd(expression, factory.createNumericLiteral(1)); + } return expression; } } @@ -96359,13 +99805,13 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(78 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(289 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols - context.enableSubstitution(216 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(214 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(215 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(226 /* MetaProperty */); // Substitutes 'import.meta' - context.enableEmitNotification(297 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(79 /* Identifier */); // Substitutes expression identifiers for imported symbols. + context.enableSubstitution(291 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(218 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(216 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(217 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(228 /* MetaProperty */); // Substitutes 'import.meta' + context.enableEmitNotification(299 /* 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. @@ -96385,7 +99831,7 @@ var ts; * @param node The SourceFile node. */ function transformSourceFile(node) { - if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 2097152 /* ContainsDynamicImport */)) { + if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 4194304 /* ContainsDynamicImport */)) { return node; } var id = ts.getOriginalNodeId(node); @@ -96554,7 +100000,7 @@ 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 & 524288 /* ContainsAwait */ ? + var modifiers = node.transformFlags & 1048576 /* ContainsAwait */ ? factory.createModifiersFromModifierFlags(256 /* Async */) : undefined; var moduleObject = factory.createObjectLiteralExpression([ @@ -96589,7 +100035,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 267 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 269 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -96679,19 +100125,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(factory, entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(factory.createExpressionStatement(factory.createAssignment(importVariableName, parameterName))); break; - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { if (ts.isNamedExports(entry.exportClause)) { @@ -96750,13 +100196,13 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return visitImportDeclaration(node); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: return visitExportDeclaration(node); - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -96936,7 +100382,7 @@ 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 === 297 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 299 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -97000,7 +100446,7 @@ 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 === 232 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 234 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasSyntacticModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -97062,10 +100508,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 264 /* NamedImports */: + case 266 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -97245,43 +100691,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return visitVariableStatement(node); - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: return visitClassDeclaration(node); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return visitForStatement(node); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return visitForInStatement(node); - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: return visitForOfStatement(node); - case 235 /* DoStatement */: + case 237 /* DoStatement */: return visitDoStatement(node); - case 236 /* WhileStatement */: + case 238 /* WhileStatement */: return visitWhileStatement(node); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return visitLabeledStatement(node); - case 243 /* WithStatement */: + case 245 /* WithStatement */: return visitWithStatement(node); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: return visitSwitchStatement(node); - case 258 /* CaseBlock */: + case 260 /* CaseBlock */: return visitCaseBlock(node); - case 284 /* CaseClause */: + case 286 /* CaseClause */: return visitCaseClause(node); - case 285 /* DefaultClause */: + case 287 /* DefaultClause */: return visitDefaultClause(node); - case 247 /* TryStatement */: + case 249 /* TryStatement */: return visitTryStatement(node); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return visitCatchClause(node); - case 230 /* Block */: + case 232 /* Block */: return visitBlock(node); - case 338 /* MergeDeclarationMarker */: + case 346 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 339 /* EndOfDeclarationMarker */: + case 347 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -97295,7 +100741,7 @@ var ts; function visitForStatement(node) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = factory.updateForStatement(node, node.initializer && visitForInitializer(node.initializer), ts.visitNode(node.condition, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.incrementor, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement)); + node = factory.updateForStatement(node, node.initializer && visitForInitializer(node.initializer), ts.visitNode(node.condition, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.incrementor, destructuringAndImportCallVisitor, ts.isExpression), ts.visitIterationBody(node.statement, nestedElementVisitor, context)); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } @@ -97307,7 +100753,7 @@ var ts; function visitForInStatement(node) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = factory.updateForInStatement(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock)); + node = factory.updateForInStatement(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitIterationBody(node.statement, nestedElementVisitor, context)); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } @@ -97319,7 +100765,7 @@ var ts; function visitForOfStatement(node) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = factory.updateForOfStatement(node, node.awaitModifier, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock)); + node = factory.updateForOfStatement(node, node.awaitModifier, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitIterationBody(node.statement, nestedElementVisitor, context)); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } @@ -97360,7 +100806,7 @@ var ts; * @param node The node to visit. */ function visitDoStatement(node) { - return factory.updateDoStatement(node, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression)); + return factory.updateDoStatement(node, ts.visitIterationBody(node.statement, nestedElementVisitor, context), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression)); } /** * Visits the body of a WhileStatement to hoist declarations. @@ -97368,7 +100814,7 @@ var ts; * @param node The node to visit. */ function visitWhileStatement(node) { - return factory.updateWhileStatement(node, ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock)); + return factory.updateWhileStatement(node, ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitIterationBody(node.statement, nestedElementVisitor, context)); } /** * Visits the body of a LabeledStatement to hoist declarations. @@ -97469,7 +100915,7 @@ var ts; else if (ts.isImportCall(node)) { return visitImportCallExpression(node); } - else if ((node.transformFlags & 1024 /* ContainsDestructuringAssignment */) || (node.transformFlags & 2097152 /* ContainsDynamicImport */)) { + else if ((node.transformFlags & 2048 /* ContainsDestructuringAssignment */) || (node.transformFlags & 4194304 /* ContainsDynamicImport */)) { return ts.visitEachChild(node, destructuringAndImportCallVisitor, context); } else { @@ -97507,7 +100953,7 @@ var ts; return ts.visitEachChild(node, destructuringAndImportCallVisitor, context); } /** - * Determines whether the target of a destructuring assigment refers to an exported symbol. + * Determines whether the target of a destructuring assignment refers to an exported symbol. * * @param node The destructuring target. */ @@ -97532,7 +100978,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 297 /* SourceFile */; + return container !== undefined && container.kind === 299 /* SourceFile */; } else { return false; @@ -97548,8 +100994,8 @@ var ts; */ function modifierVisitor(node) { switch (node.kind) { - case 92 /* ExportKeyword */: - case 87 /* DefaultKeyword */: + case 93 /* ExportKeyword */: + case 88 /* DefaultKeyword */: return undefined; } return node; @@ -97565,7 +101011,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 297 /* SourceFile */) { + if (node.kind === 299 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -97615,7 +101061,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -97650,14 +101096,14 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return substituteExpressionIdentifier(node); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return substituteBinaryExpression(node); - case 214 /* PrefixUnaryExpression */: - case 215 /* PostfixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: return substituteUnaryExpression(node); - case 226 /* MetaProperty */: + case 228 /* MetaProperty */: return substituteMetaProperty(node); } return node; @@ -97751,14 +101197,14 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 215 /* PostfixUnaryExpression */ + var expression = node.kind === 217 /* PostfixUnaryExpression */ ? ts.setTextRange(factory.createPrefixUnaryExpression(node.operator, node.operand), node) : node; for (var _i = 0, exportedNames_5 = exportedNames; _i < exportedNames_5.length; _i++) { var exportName = exportedNames_5[_i]; expression = createExportExpression(exportName, preventSubstitution(expression)); } - if (node.kind === 215 /* PostfixUnaryExpression */) { + if (node.kind === 217 /* PostfixUnaryExpression */) { expression = node.operator === 45 /* PlusPlusToken */ ? factory.createSubtract(preventSubstitution(expression), factory.createNumericLiteral(1)) : factory.createAdd(preventSubstitution(expression), factory.createNumericLiteral(1)); @@ -97786,7 +101232,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 297 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 299 /* SourceFile */) { exportedNames = ts.append(exportedNames, factory.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -97826,8 +101272,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(297 /* SourceFile */); - context.enableSubstitution(78 /* Identifier */); + context.enableEmitNotification(299 /* SourceFile */); + context.enableSubstitution(79 /* Identifier */); var helperNameSubstitutions; return ts.chainBundle(context, transformSourceFile); function transformSourceFile(node) { @@ -97858,12 +101304,12 @@ var ts; } function visitor(node) { switch (node.kind) { - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: // Elide `import=` as it is not legal with --module ES6 return undefined; - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return visitExportAssignment(node); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: var exportDecl = node; return visitExportDeclaration(exportDecl); } @@ -97968,7 +101414,8 @@ var ts; ts.isTypeAliasDeclaration(node) || ts.isConstructorDeclaration(node) || ts.isIndexSignatureDeclaration(node) || - ts.isPropertyAccessExpression(node); + ts.isPropertyAccessExpression(node) || + ts.isJSDocTypeAlias(node); } ts.canProduceDiagnostics = canProduceDiagnostics; function createGetSymbolAccessibilityDiagnosticForNodeName(node) { @@ -97997,7 +101444,7 @@ var ts; 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 === 252 /* ClassDeclaration */) { + else if (node.parent.kind === 254 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -98026,7 +101473,7 @@ var ts; 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 === 252 /* ClassDeclaration */) { + else if (node.parent.kind === 254 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -98066,14 +101513,14 @@ var ts; else if (ts.isImportEqualsDeclaration(node)) { return getImportEntityNameVisibilityError; } - else if (ts.isTypeAliasDeclaration(node)) { + else if (ts.isTypeAliasDeclaration(node) || ts.isJSDocTypeAlias(node)) { return getTypeAliasDeclarationVisibilityError; } else { return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]); } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 249 /* VariableDeclaration */ || node.kind === 198 /* BindingElement */) { + if (node.kind === 251 /* VariableDeclaration */ || node.kind === 200 /* BindingElement */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -98082,8 +101529,8 @@ var ts; } // 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 === 163 /* PropertyDeclaration */ || node.kind === 201 /* PropertyAccessExpression */ || node.kind === 162 /* PropertySignature */ || - (node.kind === 160 /* Parameter */ && ts.hasSyntacticModifier(node.parent, 8 /* Private */))) { + else if (node.kind === 165 /* PropertyDeclaration */ || node.kind === 203 /* PropertyAccessExpression */ || node.kind === 164 /* PropertySignature */ || + (node.kind === 162 /* Parameter */ && ts.hasSyntacticModifier(node.parent, 8 /* Private */))) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.hasSyntacticModifier(node, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? @@ -98092,7 +101539,7 @@ var ts; 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 === 252 /* ClassDeclaration */ || node.kind === 160 /* Parameter */) { + else if (node.parent.kind === 254 /* ClassDeclaration */ || node.kind === 162 /* Parameter */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -98117,7 +101564,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 168 /* SetAccessor */) { + if (node.kind === 170 /* 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.hasSyntacticModifier(node, 32 /* Static */)) { @@ -98156,26 +101603,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 170 /* ConstructSignature */: + case 172 /* 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 169 /* CallSignature */: + case 171 /* 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 171 /* IndexSignature */: + case 173 /* 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 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: if (ts.hasSyntacticModifier(node, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -98183,7 +101630,7 @@ var ts; 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 === 252 /* ClassDeclaration */) { + else if (node.parent.kind === 254 /* ClassDeclaration */) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* 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 : @@ -98197,7 +101644,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -98222,30 +101669,30 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 166 /* Constructor */: + case 168 /* Constructor */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* 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 170 /* ConstructSignature */: - case 175 /* ConstructorType */: + case 172 /* ConstructSignature */: + case 177 /* 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 169 /* CallSignature */: + case 171 /* 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 171 /* IndexSignature */: + case 173 /* 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 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: if (ts.hasSyntacticModifier(node.parent, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -98253,7 +101700,7 @@ var ts; 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 === 252 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 254 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* 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 : @@ -98266,15 +101713,15 @@ 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 251 /* FunctionDeclaration */: - case 174 /* FunctionType */: + case 253 /* FunctionDeclaration */: + case 176 /* FunctionType */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* 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 168 /* SetAccessor */: - case 167 /* GetAccessor */: + case 170 /* SetAccessor */: + case 169 /* GetAccessor */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -98288,39 +101735,39 @@ var ts; // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 253 /* InterfaceDeclaration */: + case 255 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 190 /* MappedType */: + case 192 /* MappedType */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1; break; - case 175 /* ConstructorType */: - case 170 /* ConstructSignature */: + case 177 /* ConstructorType */: + case 172 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 169 /* CallSignature */: + case 171 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: if (ts.hasSyntacticModifier(node.parent, 32 /* Static */)) { 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 === 252 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 254 /* 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 174 /* FunctionType */: - case 251 /* FunctionDeclaration */: + case 176 /* FunctionType */: + case 253 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -98337,7 +101784,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 === 116 /* ImplementsKeyword */ ? + diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 117 /* 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; @@ -98359,11 +101806,13 @@ var ts; typeName: node.name }; } - function getTypeAliasDeclarationVisibilityError() { + function getTypeAliasDeclarationVisibilityError(symbolAccessibilityResult) { return { - diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, - errorNode: node.type, - typeName: node.name + diagnosticMessage: symbolAccessibilityResult.errorModuleName + ? ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1_from_module_2 + : ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, + errorNode: ts.isJSDocTypeAlias(node) ? ts.Debug.checkDefined(node.typeExpression) : node.type, + typeName: ts.isJSDocTypeAlias(node) ? ts.getNameOfDeclaration(node) : node.name, }; } } @@ -98384,7 +101833,7 @@ var ts; } function isInternalDeclaration(node, currentSourceFile) { var parseTreeNode = ts.getParseTreeNode(node); - if (parseTreeNode && parseTreeNode.kind === 160 /* Parameter */) { + if (parseTreeNode && parseTreeNode.kind === 162 /* Parameter */) { var paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode); var previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : undefined; var text = currentSourceFile.text; @@ -98446,6 +101895,7 @@ var ts; reportNonlocalAugmentation: reportNonlocalAugmentation }; var errorNameNode; + var errorFallbackNode; var currentSourceFile; var refs; var libs; @@ -98500,8 +101950,10 @@ var ts; else { context.addDiagnostic(ts.createDiagnosticForNode(symbolAccessibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, symbolAccessibilityResult.errorSymbolName, symbolAccessibilityResult.errorModuleName)); } + return true; } } + return false; } function trackExternalModuleSymbolOfImportTypeNode(symbol) { if (!isBundledEmit) { @@ -98510,13 +101962,14 @@ var ts; } function trackSymbol(symbol, enclosingDeclaration, meaning) { if (symbol.flags & 262144 /* TypeParameter */) - return; - handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, /*shouldComputeAliasesToMakeVisible*/ true)); + return false; + var issuedDiagnostic = handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, /*shouldComputeAliasesToMakeVisible*/ true)); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForSymbol(symbol, meaning)); + return issuedDiagnostic; } function reportPrivateInBaseOfClassExpression(propertyName) { - if (errorNameNode) { - context.addDiagnostic(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.Property_0_of_exported_class_expression_may_not_be_private_or_protected, propertyName)); + if (errorNameNode || errorFallbackNode) { + context.addDiagnostic(ts.createDiagnosticForNode((errorNameNode || errorFallbackNode), ts.Diagnostics.Property_0_of_exported_class_expression_may_not_be_private_or_protected, propertyName)); } } function reportInaccessibleUniqueSymbolError() { @@ -98540,35 +101993,38 @@ var ts; } } function reportTruncationError() { - if (errorNameNode) { - context.addDiagnostic(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_this_node_exceeds_the_maximum_length_the_compiler_will_serialize_An_explicit_type_annotation_is_needed)); + if (errorNameNode || errorFallbackNode) { + context.addDiagnostic(ts.createDiagnosticForNode((errorNameNode || errorFallbackNode), ts.Diagnostics.The_inferred_type_of_this_node_exceeds_the_maximum_length_the_compiler_will_serialize_An_explicit_type_annotation_is_needed)); } } function reportNonlocalAugmentation(containingFile, parentSymbol, symbol) { - var primaryDeclaration = ts.find(parentSymbol.declarations, function (d) { return ts.getSourceFileOfNode(d) === containingFile; }); + var _a; + var primaryDeclaration = (_a = parentSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.getSourceFileOfNode(d) === containingFile; }); var augmentingDeclarations = ts.filter(symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== containingFile; }); - for (var _i = 0, augmentingDeclarations_1 = augmentingDeclarations; _i < augmentingDeclarations_1.length; _i++) { - var augmentations = augmentingDeclarations_1[_i]; - context.addDiagnostic(ts.addRelatedInfo(ts.createDiagnosticForNode(augmentations, ts.Diagnostics.Declaration_augments_declaration_in_another_file_This_cannot_be_serialized), ts.createDiagnosticForNode(primaryDeclaration, ts.Diagnostics.This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_file))); + if (augmentingDeclarations) { + for (var _i = 0, augmentingDeclarations_1 = augmentingDeclarations; _i < augmentingDeclarations_1.length; _i++) { + var augmentations = augmentingDeclarations_1[_i]; + context.addDiagnostic(ts.addRelatedInfo(ts.createDiagnosticForNode(augmentations, ts.Diagnostics.Declaration_augments_declaration_in_another_file_This_cannot_be_serialized), ts.createDiagnosticForNode(primaryDeclaration, ts.Diagnostics.This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_file))); + } } } function transformDeclarationsForJS(sourceFile, bundled) { var oldDiag = getSymbolAccessibilityDiagnostic; - getSymbolAccessibilityDiagnostic = function (s) { return ({ + getSymbolAccessibilityDiagnostic = function (s) { return (s.errorNode && ts.canProduceDiagnostics(s.errorNode) ? ts.createGetSymbolAccessibilityDiagnosticForNode(s.errorNode)(s) : ({ diagnosticMessage: s.errorModuleName ? ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit : ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit, errorNode: s.errorNode || sourceFile - }); }; + })); }; var result = resolver.getDeclarationStatementsForSourceFile(sourceFile, declarationEmitNodeBuilderFlags, symbolTracker, bundled); getSymbolAccessibilityDiagnostic = oldDiag; return result; } function transformRoot(node) { - if (node.kind === 297 /* SourceFile */ && node.isDeclarationFile) { + if (node.kind === 299 /* SourceFile */ && node.isDeclarationFile) { return node; } - if (node.kind === 298 /* Bundle */) { + if (node.kind === 300 /* Bundle */) { isBundledEmit = true; refs = new ts.Map(); libs = new ts.Map(); @@ -98591,14 +102047,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(133 /* 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(134 /* 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 === 300 /* InputFiles */) { + if (prepend.kind === 302 /* InputFiles */) { var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal); hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib; collectReferences(sourceFile, refs); @@ -98690,7 +102146,7 @@ var ts; declFileName = paths.declarationFilePath || paths.jsFilePath || file.fileName; } if (declFileName) { - var specifier = ts.moduleSpecifiers.getModuleSpecifier(__assign(__assign({}, options), { baseUrl: options.baseUrl && ts.toPath(options.baseUrl, host.getCurrentDirectory(), host.getCanonicalFileName) }), currentSourceFile, ts.toPath(outputFilePath, host.getCurrentDirectory(), host.getCanonicalFileName), ts.toPath(declFileName, host.getCurrentDirectory(), host.getCanonicalFileName), host, + var specifier = ts.moduleSpecifiers.getModuleSpecifier(options, currentSourceFile, ts.toPath(outputFilePath, host.getCurrentDirectory(), host.getCanonicalFileName), ts.toPath(declFileName, host.getCurrentDirectory(), host.getCanonicalFileName), host, /*preferences*/ undefined); if (!ts.pathIsRelative(specifier)) { // If some compiler option/symlink/whatever allows access to the file containing the ambient module declaration @@ -98735,11 +102191,11 @@ var ts; return ret; } function filterBindingPatternInitializers(name) { - if (name.kind === 78 /* Identifier */) { + if (name.kind === 79 /* Identifier */) { return name; } else { - if (name.kind === 197 /* ArrayBindingPattern */) { + if (name.kind === 199 /* ArrayBindingPattern */) { return factory.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -98747,7 +102203,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 222 /* OmittedExpression */) { + if (elem.kind === 224 /* OmittedExpression */) { return elem; } return factory.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); @@ -98785,19 +102241,19 @@ var ts; // Literal const declarations will have an initializer ensured rather than a type return; } - var shouldUseResolverType = node.kind === 160 /* Parameter */ && + var shouldUseResolverType = node.kind === 162 /* 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(128 /* AnyKeyword */); + return type ? ts.visitNode(type, visitDeclarationSubtree) : factory.createKeywordTypeNode(129 /* AnyKeyword */); } - if (node.kind === 168 /* SetAccessor */) { + if (node.kind === 170 /* 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(128 /* AnyKeyword */); + return factory.createKeywordTypeNode(129 /* AnyKeyword */); } errorNameNode = node.name; var oldDiag; @@ -98805,12 +102261,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 249 /* VariableDeclaration */ || node.kind === 198 /* BindingElement */) { + if (node.kind === 251 /* VariableDeclaration */ || node.kind === 200 /* BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 160 /* Parameter */ - || node.kind === 163 /* PropertyDeclaration */ - || node.kind === 162 /* PropertySignature */) { + if (node.kind === 162 /* Parameter */ + || node.kind === 165 /* PropertyDeclaration */ + || node.kind === 164 /* PropertySignature */) { if (!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)); @@ -98821,30 +102277,39 @@ var ts; if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } - return returnValue || factory.createKeywordTypeNode(128 /* AnyKeyword */); + return returnValue || factory.createKeywordTypeNode(129 /* AnyKeyword */); } } function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 256 /* ModuleDeclaration */: - case 253 /* InterfaceDeclaration */: - case 252 /* ClassDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 255 /* EnumDeclaration */: + case 253 /* FunctionDeclaration */: + case 258 /* ModuleDeclaration */: + case 255 /* InterfaceDeclaration */: + case 254 /* ClassDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 257 /* EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return !getBindingNameVisible(node); - case 260 /* ImportEqualsDeclaration */: - case 261 /* ImportDeclaration */: - case 267 /* ExportDeclaration */: - case 266 /* ExportAssignment */: + case 262 /* ImportEqualsDeclaration */: + case 263 /* ImportDeclaration */: + case 269 /* ExportDeclaration */: + case 268 /* ExportAssignment */: return false; } return false; } + // If the ExpandoFunctionDeclaration have multiple overloads, then we only need to emit properties for the last one. + function shouldEmitFunctionProperties(input) { + var _a; + if (input.body) { + return true; + } + var overloadSignatures = (_a = input.symbol.declarations) === null || _a === void 0 ? void 0 : _a.filter(function (decl) { return ts.isFunctionDeclaration(decl) && !decl.body; }); + return !overloadSignatures || overloadSignatures.indexOf(input) === overloadSignatures.length - 1; + } function getBindingNameVisible(elem) { if (ts.isOmittedExpression(elem)) { return false; @@ -98921,7 +102386,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 256 /* ModuleDeclaration */ && parent.kind !== 195 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 258 /* ModuleDeclaration */ && parent.kind !== 197 /* ImportType */); if (ts.isStringLiteralLike(input)) { if (isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); @@ -98941,7 +102406,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 272 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 274 /* ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return factory.updateImportEqualsDeclaration(decl, @@ -98968,7 +102433,7 @@ var ts; return visibleDefaultBinding && factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier)); } - if (decl.importClause.namedBindings.kind === 263 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 265 /* 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, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier)) : undefined; @@ -99063,7 +102528,7 @@ var ts; // We'd see a TDZ violation at runtime var canProduceDiagnostic = ts.canProduceDiagnostics(input); var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 177 /* TypeLiteral */ || input.kind === 190 /* MappedType */) && input.parent.kind !== 254 /* TypeAliasDeclaration */); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 179 /* TypeLiteral */ || input.kind === 192 /* MappedType */) && input.parent.kind !== 256 /* 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 */)) { @@ -99084,21 +102549,21 @@ var ts; } if (isProcessedComponent(input)) { switch (input.kind) { - case 223 /* ExpressionWithTypeArguments */: { + case 225 /* 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 173 /* TypeReference */: { + case 175 /* TypeReference */: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(factory.updateTypeReferenceNode(node, node.typeName, node.typeArguments)); } - case 170 /* ConstructSignature */: + case 172 /* ConstructSignature */: return cleanup(factory.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 166 /* Constructor */: { + case 168 /* Constructor */: { // A constructor declaration may not have a type annotation var ctor = factory.createConstructorDeclaration( /*decorators*/ undefined, @@ -99106,7 +102571,7 @@ var ts; /*body*/ undefined); return cleanup(ctor); } - case 165 /* MethodDeclaration */: { + case 167 /* MethodDeclaration */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } @@ -99116,7 +102581,7 @@ var ts; /*body*/ undefined); return cleanup(sig); } - case 167 /* GetAccessor */: { + case 169 /* GetAccessor */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } @@ -99125,7 +102590,7 @@ var ts; /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* Private */)), ensureType(input, accessorType), /*body*/ undefined)); } - case 168 /* SetAccessor */: { + case 170 /* SetAccessor */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } @@ -99133,31 +102598,31 @@ var ts; /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* Private */)), /*body*/ undefined)); } - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } return cleanup(factory.updatePropertyDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type), ensureNoInitializer(input))); - case 162 /* PropertySignature */: + case 164 /* 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 164 /* MethodSignature */: { + case 166 /* 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 169 /* CallSignature */: { + case 171 /* CallSignature */: { return cleanup(factory.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 171 /* IndexSignature */: { + case 173 /* IndexSignature */: { return cleanup(factory.updateIndexSignature(input, - /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || factory.createKeywordTypeNode(128 /* AnyKeyword */))); + /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || factory.createKeywordTypeNode(129 /* AnyKeyword */))); } - case 249 /* VariableDeclaration */: { + case 251 /* VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -99165,13 +102630,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 159 /* TypeParameter */: { + case 161 /* TypeParameter */: { if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) { return cleanup(factory.updateTypeParameterDeclaration(input, input.name, /*constraint*/ undefined, /*defaultType*/ undefined)); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 184 /* ConditionalType */: { + case 186 /* 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); @@ -99183,13 +102648,13 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(factory.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 174 /* FunctionType */: { + case 176 /* FunctionType */: { return cleanup(factory.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 175 /* ConstructorType */: { + case 177 /* ConstructorType */: { return cleanup(factory.updateConstructorTypeNode(input, ensureModifiers(input), ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 195 /* ImportType */: { + case 197 /* ImportType */: { if (!ts.isLiteralImportTypeNode(input)) return cleanup(input); return cleanup(factory.updateImportTypeNode(input, factory.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); @@ -99221,7 +102686,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 165 /* MethodDeclaration */ && ts.hasEffectiveModifier(node.parent, 8 /* Private */); + return node.parent.kind === 167 /* MethodDeclaration */ && ts.hasEffectiveModifier(node.parent, 8 /* Private */); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -99231,7 +102696,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 267 /* ExportDeclaration */: { + case 269 /* ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } @@ -99241,13 +102706,13 @@ var ts; return factory.updateExportDeclaration(input, /*decorators*/ undefined, input.modifiers, input.isTypeOnly, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 266 /* ExportAssignment */: { + case 268 /* 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 === 78 /* Identifier */) { + if (input.expression.kind === 79 /* Identifier */) { return input; } else { @@ -99256,8 +102721,10 @@ var ts; diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0, errorNode: input }); }; + errorFallbackNode = input; var varDecl = factory.createVariableDeclaration(newId, /*exclamationToken*/ undefined, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); - var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(133 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); + errorFallbackNode = undefined; + var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(134 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); return [statement, factory.updateExportAssignment(input, input.decorators, input.modifiers, newId)]; } } @@ -99273,17 +102740,17 @@ var ts; // 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) & (11263 /* All */ ^ 1 /* Export */)); + var modifiers = factory.createModifiersFromModifierFlags(ts.getEffectiveModifierFlags(statement) & (27647 /* All */ ^ 1 /* Export */)); return factory.updateModifiers(statement, modifiers); } function transformTopLevelDeclaration(input) { if (shouldStripInternal(input)) return; switch (input.kind) { - case 260 /* ImportEqualsDeclaration */: { + case 262 /* ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 261 /* ImportDeclaration */: { + case 263 /* ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -99304,20 +102771,20 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 254 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 256 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all return cleanup(factory.updateTypeAliasDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 253 /* InterfaceDeclaration */: { + case 255 /* InterfaceDeclaration */: { return cleanup(factory.updateInterfaceDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 251 /* FunctionDeclaration */: { + case 253 /* FunctionDeclaration */: { // Generators lose their generator-ness, excepting their return type var clean = cleanup(factory.updateFunctionDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), /*asteriskToken*/ undefined, input.name, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), /*body*/ undefined)); - if (clean && resolver.isExpandoFunctionDeclaration(input)) { + 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(/*decorators*/ undefined, /*modifiers*/ undefined, clean.name || factory.createIdentifier("_default"), factory.createModuleBlock([]), 16 /* Namespace */); @@ -99326,7 +102793,7 @@ var ts; fakespace_1.symbol = props[0].parent; var exportMappings_1 = []; var declarations = ts.mapDefined(props, function (p) { - if (!ts.isPropertyAccessExpression(p.valueDeclaration)) { + if (!p.valueDeclaration || !ts.isPropertyAccessExpression(p.valueDeclaration)) { return undefined; // TODO GH#33569: Handle element access expressions that created late bound names (rather than silently omitting them) } getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p.valueDeclaration); @@ -99339,7 +102806,7 @@ var ts; exportMappings_1.push([name, nameStr]); } var varDecl = factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, type, /*initializer*/ undefined); - return factory.createVariableStatement(isNonContextualKeywordName ? undefined : [factory.createToken(92 /* ExportKeyword */)], factory.createVariableDeclarationList([varDecl])); + return factory.createVariableStatement(isNonContextualKeywordName ? undefined : [factory.createToken(93 /* ExportKeyword */)], factory.createVariableDeclarationList([varDecl])); }); if (!exportMappings_1.length) { declarations = ts.mapDefined(declarations, function (declaration) { return factory.updateModifiers(declaration, 0 /* None */); }); @@ -99378,10 +102845,10 @@ var ts; return clean; } } - case 256 /* ModuleDeclaration */: { + case 258 /* ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 257 /* ModuleBlock */) { + if (inner && inner.kind === 259 /* ModuleBlock */) { var oldNeedsScopeFix = needsScopeFixMarker; var oldHasScopeFix = resultHasScopeMarker; resultHasScopeMarker = false; @@ -99424,7 +102891,9 @@ var ts; /*decorators*/ undefined, mods, input.name, body)); } } - case 252 /* ClassDeclaration */: { + case 254 /* ClassDeclaration */: { + errorNameNode = input.name; + errorFallbackNode = input; var modifiers = factory.createNodeArray(ensureModifiers(input)); var typeParameters = ensureTypeParams(input, input.typeParameters); var ctor = ts.getFirstConstructorWithBody(input); @@ -99432,10 +102901,10 @@ var ts; if (ctor) { var oldDiag_1 = getSymbolAccessibilityDiagnostic; parameterProperties = ts.compact(ts.flatMap(ctor.parameters, function (param) { - if (!ts.hasSyntacticModifier(param, 92 /* ParameterPropertyModifier */) || shouldStripInternal(param)) + if (!ts.hasSyntacticModifier(param, 16476 /* ParameterPropertyModifier */) || shouldStripInternal(param)) return; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(param); - if (param.name.kind === 78 /* Identifier */) { + if (param.name.kind === 79 /* Identifier */) { return preserveJsDoc(factory.createPropertyDeclaration( /*decorators*/ undefined, ensureModifiers(param), param.name, param.questionToken, ensureType(param, param.type), ensureNoInitializer(param)), param); } @@ -99477,7 +102946,7 @@ 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 !== 103 /* NullKeyword */) { + if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 104 /* 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 */); @@ -99487,16 +102956,16 @@ var ts; 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(133 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(134 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); var heritageClauses = factory.createNodeArray(ts.map(input.heritageClauses, function (clause) { - if (clause.token === 93 /* ExtendsKeyword */) { + if (clause.token === 94 /* 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 === 103 /* 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 /* NullKeyword */; })), visitDeclarationSubtree)); })); return [statement, cleanup(factory.updateClassDeclaration(input, /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members))]; // TODO: GH#18217 @@ -99507,10 +102976,10 @@ var ts; /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 232 /* VariableStatement */: { + case 234 /* VariableStatement */: { return cleanup(transformVariableStatement(input)); } - case 255 /* EnumDeclaration */: { + case 257 /* EnumDeclaration */: { return cleanup(factory.updateEnumDeclaration(input, /*decorators*/ undefined, factory.createNodeArray(ensureModifiers(input)), input.name, factory.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -99529,12 +102998,14 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 256 /* ModuleDeclaration */) { + if (input.kind === 258 /* ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { return node; } + errorFallbackNode = undefined; + errorNameNode = undefined; return node && ts.setOriginalNode(preserveJsDoc(node, input), input); } } @@ -99550,7 +103021,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 222 /* OmittedExpression */) { + if (e.kind === 224 /* OmittedExpression */) { return; } if (e.name) { @@ -99598,9 +103069,9 @@ var ts; return factory.createModifiersFromModifierFlags(newFlags); } function ensureModifierFlags(node) { - var mask = 11263 /* All */ ^ (4 /* Public */ | 256 /* Async */); // No async modifiers in declaration files + var mask = 27647 /* 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 === 297 /* SourceFile */; + var parentIsFile = node.parent.kind === 299 /* SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= 2 /* Ambient */; additions = 0 /* None */; @@ -99623,13 +103094,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 === 93 /* ExtendsKeyword */ && t.expression.kind === 103 /* NullKeyword */); + return ts.isEntityNameExpression(t.expression) || (clause.token === 94 /* ExtendsKeyword */ && t.expression.kind === 104 /* NullKeyword */); })), visitDeclarationSubtree)); }), function (clause) { return clause.types && !!clause.types.length; })); } } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 253 /* InterfaceDeclaration */) { + if (node.kind === 255 /* InterfaceDeclaration */) { return true; } return false; @@ -99639,7 +103110,7 @@ var ts; return ts.factory.createModifiersFromModifierFlags(maskModifierFlags(node, modifierMask, modifierAdditions)); } function maskModifierFlags(node, modifierMask, modifierAdditions) { - if (modifierMask === void 0) { modifierMask = 11263 /* All */ ^ 4 /* Public */; } + if (modifierMask === void 0) { modifierMask = 27647 /* All */ ^ 4 /* Public */; } if (modifierAdditions === void 0) { modifierAdditions = 0 /* None */; } var flags = (ts.getEffectiveModifierFlags(node) & modifierMask) | modifierAdditions; if (flags & 512 /* Default */ && !(flags & 1 /* Export */)) { @@ -99654,7 +103125,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 167 /* GetAccessor */ + return accessor.kind === 169 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -99663,52 +103134,52 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: return !ts.hasEffectiveModifier(node, 8 /* Private */); - case 160 /* Parameter */: - case 249 /* VariableDeclaration */: + case 162 /* Parameter */: + case 251 /* VariableDeclaration */: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 256 /* ModuleDeclaration */: - case 260 /* ImportEqualsDeclaration */: - case 253 /* InterfaceDeclaration */: - case 252 /* ClassDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 255 /* EnumDeclaration */: - case 232 /* VariableStatement */: - case 261 /* ImportDeclaration */: - case 267 /* ExportDeclaration */: - case 266 /* ExportAssignment */: + case 253 /* FunctionDeclaration */: + case 258 /* ModuleDeclaration */: + case 262 /* ImportEqualsDeclaration */: + case 255 /* InterfaceDeclaration */: + case 254 /* ClassDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 257 /* EnumDeclaration */: + case 234 /* VariableStatement */: + case 263 /* ImportDeclaration */: + case 269 /* ExportDeclaration */: + case 268 /* ExportAssignment */: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { - case 170 /* ConstructSignature */: - case 166 /* Constructor */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 164 /* MethodSignature */: - case 169 /* CallSignature */: - case 171 /* IndexSignature */: - case 249 /* VariableDeclaration */: - case 159 /* TypeParameter */: - case 223 /* ExpressionWithTypeArguments */: - case 173 /* TypeReference */: - case 184 /* ConditionalType */: - case 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 195 /* ImportType */: + case 172 /* ConstructSignature */: + case 168 /* Constructor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 166 /* MethodSignature */: + case 171 /* CallSignature */: + case 173 /* IndexSignature */: + case 251 /* VariableDeclaration */: + case 161 /* TypeParameter */: + case 225 /* ExpressionWithTypeArguments */: + case 175 /* TypeReference */: + case 186 /* ConditionalType */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: + case 197 /* ImportType */: return true; } return false; @@ -99764,6 +103235,9 @@ var ts; if (languageVersion < 99 /* ESNext */) { transformers.push(ts.transformESNext); } + if (languageVersion < 8 /* ES2021 */) { + transformers.push(ts.transformES2021); + } if (languageVersion < 7 /* ES2020 */) { transformers.push(ts.transformES2020); } @@ -99840,7 +103314,7 @@ 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(341 /* Count */); + var enabledSyntaxKindFeatures = new Array(349 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentStatements; @@ -99851,6 +103325,9 @@ var ts; var lexicalEnvironmentFlagsStack = []; var lexicalEnvironmentStackOffset = 0; var lexicalEnvironmentSuspended = false; + var blockScopedVariableDeclarationsStack = []; + var blockScopeStackOffset = 0; + var blockScopedVariableDeclarations; var emitHelpers; var onSubstituteNode = noEmitSubstitution; var onEmitNode = noEmitNotification; @@ -99873,6 +103350,9 @@ var ts; hoistVariableDeclaration: hoistVariableDeclaration, hoistFunctionDeclaration: hoistFunctionDeclaration, addInitializationStatement: addInitializationStatement, + startBlockScope: startBlockScope, + endBlockScope: endBlockScope, + addBlockScopedVariable: addBlockScopedVariable, requestEmitHelper: requestEmitHelper, readEmitHelpers: readEmitHelpers, enableSubstitution: enableSubstitution, @@ -99916,9 +103396,9 @@ var ts; var transformed = []; for (var _a = 0, nodes_3 = nodes; _a < nodes_3.length; _a++) { var node = nodes_3[_a]; - ts.tracing.push("emit" /* Emit */, "transformNodes", node.kind === 297 /* 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" /* Emit */, "transformNodes", node.kind === 299 /* SourceFile */ ? { path: node.path } : { kind: node.kind, pos: node.pos, end: node.end }); transformed.push((allowDtsFiles ? transformation : transformRoot)(node)); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } // prevent modification of the lexical environment. state = 2 /* Completed */; @@ -100133,6 +103613,38 @@ var ts; function getLexicalEnvironmentFlags() { return lexicalEnvironmentFlags; } + /** + * 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."); + blockScopedVariableDeclarationsStack[blockScopeStackOffset] = blockScopedVariableDeclarations; + blockScopeStackOffset++; + blockScopedVariableDeclarations = undefined; + } + /** + * 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."); + var statements = ts.some(blockScopedVariableDeclarations) ? + [ + factory.createVariableStatement( + /*modifiers*/ undefined, factory.createVariableDeclarationList(blockScopedVariableDeclarations.map(function (identifier) { return factory.createVariableDeclaration(identifier); }), 1 /* Let */)) + ] : undefined; + blockScopeStackOffset--; + blockScopedVariableDeclarations = blockScopedVariableDeclarationsStack[blockScopeStackOffset]; + if (blockScopeStackOffset === 0) { + blockScopedVariableDeclarationsStack = []; + } + return statements; + } + function addBlockScopedVariable(name) { + ts.Debug.assert(blockScopeStackOffset > 0, "Cannot add a block scoped variable outside of an iteration body."); + (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."); @@ -100174,35 +103686,37 @@ var ts; } ts.transformNodes = transformNodes; ts.nullTransformationContext = { - get factory() { return ts.factory; }, - enableEmitNotification: ts.noop, - enableSubstitution: ts.noop, - endLexicalEnvironment: ts.returnUndefined, + factory: ts.factory, getCompilerOptions: function () { return ({}); }, - getEmitHost: ts.notImplemented, getEmitResolver: ts.notImplemented, + getEmitHost: ts.notImplemented, getEmitHelperFactory: ts.notImplemented, + startLexicalEnvironment: ts.noop, + resumeLexicalEnvironment: ts.noop, + suspendLexicalEnvironment: ts.noop, + endLexicalEnvironment: ts.returnUndefined, setLexicalEnvironmentFlags: ts.noop, getLexicalEnvironmentFlags: function () { return 0; }, - hoistFunctionDeclaration: ts.noop, hoistVariableDeclaration: ts.noop, + hoistFunctionDeclaration: ts.noop, addInitializationStatement: ts.noop, - isEmitNotificationEnabled: ts.notImplemented, - isSubstitutionEnabled: ts.notImplemented, - onEmitNode: ts.noop, - onSubstituteNode: ts.notImplemented, - readEmitHelpers: ts.notImplemented, + startBlockScope: ts.noop, + endBlockScope: ts.returnUndefined, + addBlockScopedVariable: ts.noop, requestEmitHelper: ts.noop, - resumeLexicalEnvironment: ts.noop, - startLexicalEnvironment: ts.noop, - suspendLexicalEnvironment: ts.noop, + readEmitHelpers: ts.notImplemented, + enableSubstitution: ts.noop, + enableEmitNotification: ts.noop, + isSubstitutionEnabled: ts.notImplemented, + isEmitNotificationEnabled: ts.notImplemented, + onSubstituteNode: noEmitSubstitution, + onEmitNode: noEmitNotification, addDiagnostic: ts.noop, }; })(ts || (ts = {})); var ts; (function (ts) { var brackets = createBracketsMap(); - var syntheticParent = { pos: -1, end: -1 }; /*@internal*/ function isBuildInfoFile(file) { return ts.fileExtensionIs(file, ".tsbuildinfo" /* TsBuildInfo */); @@ -100288,7 +103802,7 @@ var ts; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 298 /* Bundle */) { + if (sourceFile.kind === 300 /* Bundle */) { return getOutputPathsForBundle(options, forceDtsPaths); } else { @@ -100514,15 +104028,15 @@ var ts; sourceFiles: sourceFileOrBundle.sourceFiles.map(function (file) { return relativeToBuildInfo(ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory())); }) }; } - ts.tracing.push("emit" /* Emit */, "emitJsFileOrBundle", { jsFilePath: jsFilePath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitJsFileOrBundle", { jsFilePath: jsFilePath }); emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo); - ts.tracing.pop(); - ts.tracing.push("emit" /* Emit */, "emitDeclarationFileOrBundle", { declarationFilePath: declarationFilePath }); + 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 }); emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo); - ts.tracing.pop(); - ts.tracing.push("emit" /* Emit */, "emitBuildInfo", { buildInfoPath: buildInfoPath }); + 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 }); emitBuildInfo(bundleBuildInfo, buildInfoPath); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); if (!emitSkipped && emittedFilesList) { if (!emitOnlyDtsFiles) { if (jsFilePath) { @@ -100649,13 +104163,13 @@ var ts; 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: compilerOptions.declarationMap, + sourceMap: !forceDtsEmit && compilerOptions.declarationMap, sourceRoot: compilerOptions.sourceRoot, mapRoot: compilerOptions.mapRoot, extendedDiagnostics: compilerOptions.extendedDiagnostics, // Explicitly do not passthru either `inline` option }); - if (forceDtsEmit && declarationTransform.transformed[0].kind === 297 /* SourceFile */) { + if (forceDtsEmit && declarationTransform.transformed[0].kind === 299 /* SourceFile */) { var sourceFile = declarationTransform.transformed[0]; exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; } @@ -100666,7 +104180,7 @@ var ts; } function collectLinkedAliases(node) { if (ts.isExportAssignment(node)) { - if (node.expression.kind === 78 /* Identifier */) { + if (node.expression.kind === 79 /* Identifier */) { resolver.collectLinkedAliases(node.expression, /*setVisibility*/ true); } return; @@ -100678,8 +104192,8 @@ var ts; ts.forEachChild(node, collectLinkedAliases); } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) { - var bundle = sourceFileOrBundle.kind === 298 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 297 /* SourceFile */ ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 300 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 299 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; var sourceMapGenerator; if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { @@ -100720,7 +104234,7 @@ var ts; } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { return (mapOptions.sourceMap || mapOptions.inlineSourceMap) - && (sourceFileOrBundle.kind !== 297 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); + && (sourceFileOrBundle.kind !== 299 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); } function getSourceRoot(mapOptions) { // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the @@ -100779,7 +104293,7 @@ var ts; ts.emitFiles = emitFiles; /*@internal*/ function getBuildInfoText(buildInfo) { - return JSON.stringify(buildInfo, undefined, 2); + return JSON.stringify(buildInfo); } ts.getBuildInfoText = getBuildInfoText; /*@internal*/ @@ -100960,7 +104474,7 @@ var ts; function createPrinter(printerOptions, handlers) { if (printerOptions === void 0) { printerOptions = {}; } if (handlers === void 0) { handlers = {}; } - var hasGlobalName = handlers.hasGlobalName, _a = handlers.onEmitNode, onEmitNode = _a === void 0 ? ts.noEmitNotification : _a, isEmitNotificationEnabled = handlers.isEmitNotificationEnabled, _b = handlers.substituteNode, substituteNode = _b === void 0 ? ts.noEmitSubstitution : _b, onBeforeEmitNodeArray = handlers.onBeforeEmitNodeArray, onAfterEmitNodeArray = handlers.onAfterEmitNodeArray, onBeforeEmitToken = handlers.onBeforeEmitToken, onAfterEmitToken = handlers.onAfterEmitToken; + var hasGlobalName = handlers.hasGlobalName, _a = handlers.onEmitNode, onEmitNode = _a === void 0 ? ts.noEmitNotification : _a, isEmitNotificationEnabled = handlers.isEmitNotificationEnabled, _b = handlers.substituteNode, substituteNode = _b === void 0 ? ts.noEmitSubstitution : _b, onBeforeEmitNode = handlers.onBeforeEmitNode, onAfterEmitNode = handlers.onAfterEmitNode, onBeforeEmitNodeArray = handlers.onBeforeEmitNodeArray, onAfterEmitNodeArray = handlers.onAfterEmitNodeArray, onBeforeEmitToken = handlers.onBeforeEmitToken, onAfterEmitToken = handlers.onAfterEmitToken; var extendedDiagnostics = !!printerOptions.extendedDiagnostics; var newLine = ts.getNewLineCharacter(printerOptions); var moduleKind = ts.getEmitModuleKind(printerOptions); @@ -100999,9 +104513,11 @@ var ts; var detachedCommentsInfo; var hasWrittenComment = false; var commentsDisabled = !!printerOptions.removeComments; - var lastNode; var lastSubstitution; + var currentParenthesizerRule; var _c = ts.performance.createTimerIf(extendedDiagnostics, "commentTime", "beforeComment", "afterComment"), enterComment = _c.enter, exitComment = _c.exit; + var parenthesizer = ts.factory.parenthesizer; + var emitBinaryExpression = createEmitBinaryExpression(); reset(); return { // public API @@ -101029,9 +104545,9 @@ var ts; break; } switch (node.kind) { - case 297 /* SourceFile */: return printFile(node); - case 298 /* Bundle */: return printBundle(node); - case 299 /* UnparsedSource */: return printUnparsedSource(node); + case 299 /* SourceFile */: return printFile(node); + case 300 /* Bundle */: return printBundle(node); + case 301 /* UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -101065,7 +104581,7 @@ var ts; if (sourceFile) { setSourceFile(sourceFile); } - emitList(syntheticParent, nodes, format); + emitList(/*parentNode*/ undefined, nodes, format); reset(); writer = previousWriter; } @@ -101200,7 +104716,7 @@ var ts; if (sourceFile) { setSourceFile(sourceFile); } - pipelineEmit(hint, node); + pipelineEmit(hint, node, /*parenthesizerRule*/ undefined); } function setSourceFile(sourceFile) { currentSourceFile = sourceFile; @@ -101228,51 +104744,54 @@ var ts; currentSourceFile = undefined; currentLineMap = undefined; detachedCommentsInfo = undefined; - lastNode = undefined; - lastSubstitution = undefined; setWriter(/*output*/ undefined, /*_sourceMapGenerator*/ undefined); } function getCurrentLineMap() { return currentLineMap || (currentLineMap = ts.getLineStarts(currentSourceFile)); } - function emit(node) { + function emit(node, parenthesizerRule) { if (node === undefined) return; var prevSourceFileTextKind = recordBundleFileInternalSectionStart(node); - var substitute = pipelineEmit(4 /* Unspecified */, node); + pipelineEmit(4 /* Unspecified */, node, parenthesizerRule); recordBundleFileInternalSectionEnd(prevSourceFileTextKind); - return substitute; } function emitIdentifierName(node) { if (node === undefined) return; - return pipelineEmit(2 /* IdentifierName */, node); + pipelineEmit(2 /* IdentifierName */, node, /*parenthesizerRule*/ undefined); } - function emitExpression(node) { + function emitExpression(node, parenthesizerRule) { if (node === undefined) return; - return pipelineEmit(1 /* Expression */, node); + pipelineEmit(1 /* Expression */, node, parenthesizerRule); } function emitJsxAttributeValue(node) { - return pipelineEmit(ts.isStringLiteral(node) ? 6 /* JsxAttributeValue */ : 4 /* Unspecified */, node); + pipelineEmit(ts.isStringLiteral(node) ? 6 /* JsxAttributeValue */ : 4 /* Unspecified */, node); } - function pipelineEmit(emitHint, node) { - var savedLastNode = lastNode; - var savedLastSubstitution = lastSubstitution; - var savedPreserveSourceNewlines = preserveSourceNewlines; - lastNode = node; - lastSubstitution = undefined; - if (preserveSourceNewlines && !!(ts.getEmitFlags(node) & 134217728 /* IgnoreSourceNewlines */)) { + function beforeEmitNode(node) { + if (preserveSourceNewlines && (ts.getEmitFlags(node) & 134217728 /* IgnoreSourceNewlines */)) { preserveSourceNewlines = false; } + } + function afterEmitNode(savedPreserveSourceNewlines) { + preserveSourceNewlines = savedPreserveSourceNewlines; + } + function pipelineEmit(emitHint, node, parenthesizerRule) { + currentParenthesizerRule = parenthesizerRule; var pipelinePhase = getPipelinePhase(0 /* Notification */, emitHint, node); pipelinePhase(emitHint, node); - ts.Debug.assert(lastNode === node); - var substitute = lastSubstitution; - lastNode = savedLastNode; - lastSubstitution = savedLastSubstitution; - preserveSourceNewlines = savedPreserveSourceNewlines; - return substitute || node; + currentParenthesizerRule = undefined; + } + function shouldEmitComments(node) { + return !commentsDisabled && !ts.isSourceFile(node); + } + function shouldEmitSourceMaps(node) { + return !sourceMapsDisabled && + !ts.isSourceFile(node) && + !ts.isInJsonFile(node) && + !ts.isUnparsedSource(node) && + !ts.isUnparsedPrepend(node); } function getPipelinePhase(phase, emitHint, node) { switch (phase) { @@ -101282,18 +104801,21 @@ var ts; } // falls through case 1 /* Substitution */: - if (substituteNode !== ts.noEmitSubstitution && (lastSubstitution = substituteNode(emitHint, node)) !== node) { + if (substituteNode !== ts.noEmitSubstitution && (lastSubstitution = substituteNode(emitHint, node) || node) !== node) { + if (currentParenthesizerRule) { + lastSubstitution = currentParenthesizerRule(lastSubstitution); + } return pipelineEmitWithSubstitution; } // falls through case 2 /* Comments */: - if (!commentsDisabled && node.kind !== 297 /* SourceFile */) { + if (shouldEmitComments(node)) { return pipelineEmitWithComments; } // falls through case 3 /* SourceMaps */: - if (!sourceMapsDisabled && node.kind !== 297 /* SourceFile */ && !ts.isInJsonFile(node)) { - return pipelineEmitWithSourceMap; + if (shouldEmitSourceMaps(node)) { + return pipelineEmitWithSourceMaps; } // falls through case 4 /* Emit */: @@ -101306,13 +104828,25 @@ var ts; return getPipelinePhase(currentPhase + 1, emitHint, node); } function pipelineEmitWithNotification(hint, node) { - ts.Debug.assert(lastNode === node); var pipelinePhase = getNextPipelinePhase(0 /* Notification */, hint, node); onEmitNode(hint, node, pipelinePhase); - ts.Debug.assert(lastNode === node); } function pipelineEmitWithHint(hint, node) { - ts.Debug.assert(lastNode === node || lastSubstitution === node); + onBeforeEmitNode === null || onBeforeEmitNode === void 0 ? void 0 : onBeforeEmitNode(node); + if (preserveSourceNewlines) { + var savedPreserveSourceNewlines = preserveSourceNewlines; + beforeEmitNode(node); + pipelineEmitWithHintWorker(hint, node); + afterEmitNode(savedPreserveSourceNewlines); + } + else { + pipelineEmitWithHintWorker(hint, node); + } + onAfterEmitNode === null || onAfterEmitNode === void 0 ? void 0 : onAfterEmitNode(node); + // clear the parenthesizer rule as we ascend + currentParenthesizerRule = undefined; + } + function pipelineEmitWithHintWorker(hint, node) { if (hint === 0 /* SourceFile */) return emitSourceFile(ts.cast(node, ts.isSourceFile)); if (hint === 2 /* IdentifierName */) @@ -101326,308 +104860,337 @@ var ts; return emitEmptyStatement(/*isEmbeddedStatement*/ true); } if (hint === 4 /* Unspecified */) { - if (ts.isKeyword(node.kind)) - return writeTokenNode(node, writeKeyword); switch (node.kind) { // Pseudo-literals case 15 /* TemplateHead */: case 16 /* TemplateMiddle */: case 17 /* TemplateTail */: return emitLiteral(node, /*jsxAttributeEscape*/ false); - case 299 /* UnparsedSource */: - case 293 /* UnparsedPrepend */: - return emitUnparsedSourceOrPrepend(node); - case 292 /* UnparsedPrologue */: - return writeUnparsedNode(node); - case 294 /* UnparsedText */: - case 295 /* UnparsedInternalText */: - return emitUnparsedTextLike(node); - case 296 /* UnparsedSyntheticReference */: - return emitUnparsedSyntheticReference(node); // Identifiers - case 78 /* Identifier */: + case 79 /* Identifier */: return emitIdentifier(node); // PrivateIdentifiers - case 79 /* PrivateIdentifier */: + case 80 /* PrivateIdentifier */: return emitPrivateIdentifier(node); // Parse tree nodes // Names - case 157 /* QualifiedName */: + case 159 /* QualifiedName */: return emitQualifiedName(node); - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 159 /* TypeParameter */: + case 161 /* TypeParameter */: return emitTypeParameter(node); - case 160 /* Parameter */: + case 162 /* Parameter */: return emitParameter(node); - case 161 /* Decorator */: + case 163 /* Decorator */: return emitDecorator(node); // Type members - case 162 /* PropertySignature */: + case 164 /* PropertySignature */: return emitPropertySignature(node); - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return emitPropertyDeclaration(node); - case 164 /* MethodSignature */: + case 166 /* MethodSignature */: return emitMethodSignature(node); - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: return emitMethodDeclaration(node); - case 166 /* Constructor */: + case 168 /* Constructor */: return emitConstructor(node); - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return emitAccessorDeclaration(node); - case 169 /* CallSignature */: + case 171 /* CallSignature */: return emitCallSignature(node); - case 170 /* ConstructSignature */: + case 172 /* ConstructSignature */: return emitConstructSignature(node); - case 171 /* IndexSignature */: + case 173 /* IndexSignature */: return emitIndexSignature(node); - case 194 /* TemplateLiteralTypeSpan */: - return emitTemplateTypeSpan(node); // Types - case 172 /* TypePredicate */: + case 174 /* TypePredicate */: return emitTypePredicate(node); - case 173 /* TypeReference */: + case 175 /* TypeReference */: return emitTypeReference(node); - case 174 /* FunctionType */: + case 176 /* FunctionType */: return emitFunctionType(node); - case 308 /* JSDocFunctionType */: - return emitJSDocFunctionType(node); - case 175 /* ConstructorType */: + case 177 /* ConstructorType */: return emitConstructorType(node); - case 176 /* TypeQuery */: + case 178 /* TypeQuery */: return emitTypeQuery(node); - case 177 /* TypeLiteral */: + case 179 /* TypeLiteral */: return emitTypeLiteral(node); - case 178 /* ArrayType */: + case 180 /* ArrayType */: return emitArrayType(node); - case 179 /* TupleType */: + case 181 /* TupleType */: return emitTupleType(node); - case 180 /* OptionalType */: + case 182 /* OptionalType */: return emitOptionalType(node); - case 182 /* UnionType */: + // SyntaxKind.RestType is handled below + case 184 /* UnionType */: return emitUnionType(node); - case 183 /* IntersectionType */: + case 185 /* IntersectionType */: return emitIntersectionType(node); - case 184 /* ConditionalType */: + case 186 /* ConditionalType */: return emitConditionalType(node); - case 185 /* InferType */: + case 187 /* InferType */: return emitInferType(node); - case 186 /* ParenthesizedType */: + case 188 /* ParenthesizedType */: return emitParenthesizedType(node); - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 187 /* ThisType */: + case 189 /* ThisType */: return emitThisType(); - case 188 /* TypeOperator */: + case 190 /* TypeOperator */: return emitTypeOperator(node); - case 189 /* IndexedAccessType */: + case 191 /* IndexedAccessType */: return emitIndexedAccessType(node); - case 190 /* MappedType */: + case 192 /* MappedType */: return emitMappedType(node); - case 191 /* LiteralType */: + case 193 /* LiteralType */: return emitLiteralType(node); - case 193 /* TemplateLiteralType */: + case 194 /* NamedTupleMember */: + return emitNamedTupleMember(node); + case 195 /* TemplateLiteralType */: return emitTemplateType(node); - case 195 /* ImportType */: + case 196 /* TemplateLiteralTypeSpan */: + return emitTemplateTypeSpan(node); + case 197 /* ImportType */: return emitImportTypeNode(node); - case 303 /* JSDocAllType */: - writePunctuation("*"); - return; - case 304 /* JSDocUnknownType */: - writePunctuation("?"); - return; - case 305 /* JSDocNullableType */: - return emitJSDocNullableType(node); - case 306 /* JSDocNonNullableType */: - return emitJSDocNonNullableType(node); - case 307 /* JSDocOptionalType */: - return emitJSDocOptionalType(node); - case 181 /* RestType */: - case 309 /* JSDocVariadicType */: - return emitRestOrJSDocVariadicType(node); - case 192 /* NamedTupleMember */: - return emitNamedTupleMember(node); // Binding patterns - case 196 /* ObjectBindingPattern */: + case 198 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 197 /* ArrayBindingPattern */: + case 199 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 198 /* BindingElement */: + case 200 /* BindingElement */: return emitBindingElement(node); // Misc - case 228 /* TemplateSpan */: + case 230 /* TemplateSpan */: return emitTemplateSpan(node); - case 229 /* SemicolonClassElement */: + case 231 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 230 /* Block */: + case 232 /* Block */: return emitBlock(node); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return emitVariableStatement(node); - case 231 /* EmptyStatement */: + case 233 /* EmptyStatement */: return emitEmptyStatement(/*isEmbeddedStatement*/ false); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: return emitExpressionStatement(node); - case 234 /* IfStatement */: + case 236 /* IfStatement */: return emitIfStatement(node); - case 235 /* DoStatement */: + case 237 /* DoStatement */: return emitDoStatement(node); - case 236 /* WhileStatement */: + case 238 /* WhileStatement */: return emitWhileStatement(node); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return emitForStatement(node); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return emitForInStatement(node); - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: return emitForOfStatement(node); - case 240 /* ContinueStatement */: + case 242 /* ContinueStatement */: return emitContinueStatement(node); - case 241 /* BreakStatement */: + case 243 /* BreakStatement */: return emitBreakStatement(node); - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: return emitReturnStatement(node); - case 243 /* WithStatement */: + case 245 /* WithStatement */: return emitWithStatement(node); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: return emitSwitchStatement(node); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return emitLabeledStatement(node); - case 246 /* ThrowStatement */: + case 248 /* ThrowStatement */: return emitThrowStatement(node); - case 247 /* TryStatement */: + case 249 /* TryStatement */: return emitTryStatement(node); - case 248 /* DebuggerStatement */: + case 250 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 250 /* VariableDeclarationList */: + case 252 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: return emitClassDeclaration(node); - case 253 /* InterfaceDeclaration */: + case 255 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 257 /* ModuleBlock */: + case 259 /* ModuleBlock */: return emitModuleBlock(node); - case 258 /* CaseBlock */: + case 260 /* CaseBlock */: return emitCaseBlock(node); - case 259 /* NamespaceExportDeclaration */: + case 261 /* NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return emitImportDeclaration(node); - case 262 /* ImportClause */: + case 264 /* ImportClause */: return emitImportClause(node); - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: return emitNamespaceImport(node); - case 269 /* NamespaceExport */: + case 271 /* NamespaceExport */: return emitNamespaceExport(node); - case 264 /* NamedImports */: + case 266 /* NamedImports */: return emitNamedImports(node); - case 265 /* ImportSpecifier */: + case 267 /* ImportSpecifier */: return emitImportSpecifier(node); - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return emitExportAssignment(node); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: return emitExportDeclaration(node); - case 268 /* NamedExports */: + case 270 /* NamedExports */: return emitNamedExports(node); - case 270 /* ExportSpecifier */: + case 272 /* ExportSpecifier */: return emitExportSpecifier(node); - case 271 /* MissingDeclaration */: + case 273 /* MissingDeclaration */: return; // Module references - case 272 /* ExternalModuleReference */: + case 274 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 11 /* JsxText */: return emitJsxText(node); - case 275 /* JsxOpeningElement */: - case 278 /* JsxOpeningFragment */: + case 277 /* JsxOpeningElement */: + case 280 /* JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 276 /* JsxClosingElement */: - case 279 /* JsxClosingFragment */: + case 278 /* JsxClosingElement */: + case 281 /* JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 280 /* JsxAttribute */: + case 282 /* JsxAttribute */: return emitJsxAttribute(node); - case 281 /* JsxAttributes */: + case 283 /* JsxAttributes */: return emitJsxAttributes(node); - case 282 /* JsxSpreadAttribute */: + case 284 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 284 /* CaseClause */: + case 286 /* CaseClause */: return emitCaseClause(node); - case 285 /* DefaultClause */: + case 287 /* DefaultClause */: return emitDefaultClause(node); - case 286 /* HeritageClause */: + case 288 /* HeritageClause */: return emitHeritageClause(node); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 290 /* SpreadAssignment */: + case 292 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 291 /* EnumMember */: + case 293 /* EnumMember */: return emitEnumMember(node); + // Unparsed + case 294 /* UnparsedPrologue */: + return writeUnparsedNode(node); + case 301 /* UnparsedSource */: + case 295 /* UnparsedPrepend */: + return emitUnparsedSourceOrPrepend(node); + case 296 /* UnparsedText */: + case 297 /* UnparsedInternalText */: + return emitUnparsedTextLike(node); + case 298 /* UnparsedSyntheticReference */: + return emitUnparsedSyntheticReference(node); + // Top-level nodes + case 299 /* SourceFile */: + return emitSourceFile(node); + case 300 /* Bundle */: + return ts.Debug.fail("Bundles should be printed using printBundle"); + // SyntaxKind.UnparsedSource (handled above) + case 302 /* InputFiles */: + return ts.Debug.fail("InputFiles should not be printed"); // JSDoc nodes (only used in codefixes currently) - case 326 /* JSDocParameterTag */: - case 333 /* JSDocPropertyTag */: + case 303 /* JSDocTypeExpression */: + return emitJSDocTypeExpression(node); + case 304 /* JSDocNameReference */: + return emitJSDocNameReference(node); + case 306 /* JSDocAllType */: + return writePunctuation("*"); + case 307 /* JSDocUnknownType */: + return writePunctuation("?"); + case 308 /* JSDocNullableType */: + return emitJSDocNullableType(node); + case 309 /* JSDocNonNullableType */: + return emitJSDocNonNullableType(node); + case 310 /* JSDocOptionalType */: + return emitJSDocOptionalType(node); + case 311 /* JSDocFunctionType */: + return emitJSDocFunctionType(node); + case 183 /* RestType */: + case 312 /* JSDocVariadicType */: + return emitRestOrJSDocVariadicType(node); + case 313 /* JSDocNamepathType */: + return; + case 314 /* JSDocComment */: + return emitJSDoc(node); + case 316 /* JSDocTypeLiteral */: + return emitJSDocTypeLiteral(node); + case 317 /* JSDocSignature */: + return emitJSDocSignature(node); + case 321 /* JSDocTag */: + case 326 /* JSDocClassTag */: + return emitJSDocSimpleTag(node); + case 322 /* JSDocAugmentsTag */: + case 323 /* JSDocImplementsTag */: + return emitJSDocHeritageTag(node); + case 324 /* JSDocAuthorTag */: + case 325 /* JSDocDeprecatedTag */: + return; + // SyntaxKind.JSDocClassTag (see JSDocTag, above) + case 327 /* JSDocPublicTag */: + case 328 /* JSDocPrivateTag */: + case 329 /* JSDocProtectedTag */: + case 330 /* JSDocReadonlyTag */: + case 331 /* JSDocOverrideTag */: + return; + case 332 /* JSDocCallbackTag */: + return emitJSDocCallbackTag(node); + // SyntaxKind.JSDocEnumTag (see below) + case 334 /* JSDocParameterTag */: + case 341 /* JSDocPropertyTag */: return emitJSDocPropertyLikeTag(node); - case 327 /* JSDocReturnTag */: - case 329 /* JSDocTypeTag */: - case 328 /* JSDocThisTag */: - case 325 /* JSDocEnumTag */: + case 333 /* JSDocEnumTag */: + case 335 /* JSDocReturnTag */: + case 336 /* JSDocThisTag */: + case 337 /* JSDocTypeTag */: return emitJSDocSimpleTypedTag(node); - case 316 /* JSDocImplementsTag */: - case 315 /* JSDocAugmentsTag */: - return emitJSDocHeritageTag(node); - case 330 /* JSDocTemplateTag */: + case 338 /* JSDocTemplateTag */: return emitJSDocTemplateTag(node); - case 331 /* JSDocTypedefTag */: + case 339 /* JSDocTypedefTag */: return emitJSDocTypedefTag(node); - case 324 /* JSDocCallbackTag */: - return emitJSDocCallbackTag(node); - case 313 /* JSDocSignature */: - return emitJSDocSignature(node); - case 312 /* JSDocTypeLiteral */: - return emitJSDocTypeLiteral(node); - case 319 /* JSDocClassTag */: - case 314 /* JSDocTag */: - return emitJSDocSimpleTag(node); - case 332 /* JSDocSeeTag */: + case 340 /* JSDocSeeTag */: return emitJSDocSeeTag(node); - case 302 /* JSDocNameReference */: - return emitJSDocNameReference(node); - case 311 /* JSDocComment */: - return emitJSDoc(node); - // Transformation nodes (ignored) + // SyntaxKind.JSDocPropertyTag (see JSDocParameterTag, above) + // Transformation nodes + case 343 /* NotEmittedStatement */: + case 347 /* EndOfDeclarationMarker */: + case 346 /* MergeDeclarationMarker */: + return; } if (ts.isExpression(node)) { hint = 1 /* Expression */; if (substituteNode !== ts.noEmitSubstitution) { - lastSubstitution = node = substituteNode(hint, node); + var substitute = substituteNode(hint, node) || node; + if (substitute !== node) { + node = substitute; + if (currentParenthesizerRule) { + node = currentParenthesizerRule(node); + } + } } } - else if (ts.isToken(node)) { - return writeTokenNode(node, writePunctuation); - } } if (hint === 1 /* Expression */) { switch (node.kind) { @@ -101640,86 +105203,94 @@ var ts; case 14 /* NoSubstitutionTemplateLiteral */: return emitLiteral(node, /*jsxAttributeEscape*/ false); // Identifiers - case 78 /* Identifier */: + case 79 /* Identifier */: return emitIdentifier(node); - // Reserved words - case 94 /* FalseKeyword */: - case 103 /* NullKeyword */: - case 105 /* SuperKeyword */: - case 109 /* TrueKeyword */: - case 107 /* ThisKeyword */: - case 99 /* ImportKeyword */: - writeTokenNode(node, writeKeyword); - return; // Expressions - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return emitCallExpression(node); - case 204 /* NewExpression */: + case 206 /* NewExpression */: return emitNewExpression(node); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 206 /* TypeAssertionExpression */: + case 208 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: return emitFunctionExpression(node); - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return emitArrowFunction(node); - case 210 /* DeleteExpression */: + case 212 /* DeleteExpression */: return emitDeleteExpression(node); - case 211 /* TypeOfExpression */: + case 213 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 212 /* VoidExpression */: + case 214 /* VoidExpression */: return emitVoidExpression(node); - case 213 /* AwaitExpression */: + case 215 /* AwaitExpression */: return emitAwaitExpression(node); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return emitBinaryExpression(node); - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: return emitConditionalExpression(node); - case 218 /* TemplateExpression */: + case 220 /* TemplateExpression */: return emitTemplateExpression(node); - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: return emitYieldExpression(node); - case 220 /* SpreadElement */: - return emitSpreadExpression(node); - case 221 /* ClassExpression */: + case 222 /* SpreadElement */: + return emitSpreadElement(node); + case 223 /* ClassExpression */: return emitClassExpression(node); - case 222 /* OmittedExpression */: + case 224 /* OmittedExpression */: return; - case 224 /* AsExpression */: + case 226 /* AsExpression */: return emitAsExpression(node); - case 225 /* NonNullExpression */: + case 227 /* NonNullExpression */: return emitNonNullExpression(node); - case 226 /* MetaProperty */: + case 228 /* MetaProperty */: return emitMetaProperty(node); + case 229 /* SyntheticExpression */: + return ts.Debug.fail("SyntheticExpression should never be printed."); // JSX - case 273 /* JsxElement */: + case 275 /* JsxElement */: return emitJsxElement(node); - case 274 /* JsxSelfClosingElement */: + case 276 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 277 /* JsxFragment */: + case 279 /* JsxFragment */: return emitJsxFragment(node); + // Synthesized list + case 342 /* SyntaxList */: + return ts.Debug.fail("SyntaxList should not be printed"); // Transformation nodes - case 336 /* PartiallyEmittedExpression */: + case 343 /* NotEmittedStatement */: + return; + case 344 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 337 /* CommaListExpression */: + case 345 /* CommaListExpression */: return emitCommaList(node); + case 346 /* MergeDeclarationMarker */: + case 347 /* EndOfDeclarationMarker */: + return; + case 348 /* SyntheticReferenceExpression */: + return ts.Debug.fail("SyntheticReferenceExpression should not be printed"); } } + if (ts.isKeyword(node.kind)) + return writeTokenNode(node, writeKeyword); + if (ts.isTokenKind(node.kind)) + return writeTokenNode(node, writePunctuation); + ts.Debug.fail("Unhandled SyntaxKind: " + ts.Debug.formatSyntaxKind(node.kind) + "."); } function emitMappedTypeParameter(node) { emit(node.name); @@ -101729,10 +105300,11 @@ var ts; emit(node.constraint); } function pipelineEmitWithSubstitution(hint, node) { - ts.Debug.assert(lastNode === node || lastSubstitution === node); var pipelinePhase = getNextPipelinePhase(1 /* Substitution */, hint, node); - pipelinePhase(hint, lastSubstitution); - ts.Debug.assert(lastNode === node || lastSubstitution === node); + ts.Debug.assertIsDefined(lastSubstitution); + node = lastSubstitution; + lastSubstitution = undefined; + pipelinePhase(hint, node); } function getHelpersFromBundledSourceFiles(bundle) { var result; @@ -101758,7 +105330,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 298 /* Bundle */ ? node : undefined; + var bundle = node.kind === 300 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -101858,7 +105430,7 @@ var ts; var pos = getTextPosWithWriteLine(); writeUnparsedNode(unparsed); if (bundleFileInfo) { - updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 294 /* UnparsedText */ ? + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 296 /* UnparsedText */ ? "text" /* Text */ : "internal" /* Internal */); } @@ -101895,7 +105467,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { emitExpression(node); } else { @@ -101904,7 +105476,7 @@ var ts; } function emitComputedPropertyName(node) { writePunctuation("["); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfComputedPropertyName); writePunctuation("]"); } // @@ -101931,18 +105503,18 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 308 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 311 /* JSDocFunctionType */ && !node.name) { emit(node.type); } else { emitTypeAnnotation(node.type); } // The comment position has to fallback to any present node within the parameterdeclaration because as it turns out, the parser can make parameter declarations with _just_ an initializer. - emitInitializer(node.initializer, node.type ? node.type.end : node.questionToken ? node.questionToken.end : node.name ? node.name.end : node.modifiers ? node.modifiers.end : node.decorators ? node.decorators.end : node.pos, node); + emitInitializer(node.initializer, node.type ? node.type.end : node.questionToken ? node.questionToken.end : node.name ? node.name.end : node.modifiers ? node.modifiers.end : node.decorators ? node.decorators.end : node.pos, node, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitDecorator(decorator) { writePunctuation("@"); - emitExpression(decorator.expression); + emitExpression(decorator.expression, parenthesizer.parenthesizeLeftSideOfAccess); } // // Type members @@ -101993,7 +105565,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeKeyword(node.kind === 167 /* GetAccessor */ ? "get" : "set"); + writeKeyword(node.kind === 169 /* GetAccessor */ ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -102107,7 +105679,7 @@ var ts; writePunctuation("}"); } function emitArrayType(node) { - emit(node.elementType); + emit(node.elementType, parenthesizer.parenthesizeElementTypeOfArrayType); writePunctuation("["); writePunctuation("]"); } @@ -102130,21 +105702,21 @@ var ts; emit(node.type); } function emitOptionalType(node) { - emit(node.type); + emit(node.type, parenthesizer.parenthesizeElementTypeOfArrayType); writePunctuation("?"); } function emitUnionType(node) { - emitList(node, node.types, 516 /* UnionTypeConstituents */); + emitList(node, node.types, 516 /* UnionTypeConstituents */, parenthesizer.parenthesizeMemberOfElementType); } function emitIntersectionType(node) { - emitList(node, node.types, 520 /* IntersectionTypeConstituents */); + emitList(node, node.types, 520 /* IntersectionTypeConstituents */, parenthesizer.parenthesizeMemberOfElementType); } function emitConditionalType(node) { - emit(node.checkType); + emit(node.checkType, parenthesizer.parenthesizeMemberOfConditionalType); writeSpace(); writeKeyword("extends"); writeSpace(); - emit(node.extendsType); + emit(node.extendsType, parenthesizer.parenthesizeMemberOfConditionalType); writeSpace(); writePunctuation("?"); writeSpace(); @@ -102170,10 +105742,10 @@ var ts; function emitTypeOperator(node) { writeTokenText(node.operator, writeKeyword); writeSpace(); - emit(node.type); + emit(node.type, parenthesizer.parenthesizeMemberOfElementType); } function emitIndexedAccessType(node) { - emit(node.objectType); + emit(node.objectType, parenthesizer.parenthesizeMemberOfElementType); writePunctuation("["); emit(node.indexType); writePunctuation("]"); @@ -102190,7 +105762,7 @@ var ts; } if (node.readonlyToken) { emit(node.readonlyToken); - if (node.readonlyToken.kind !== 142 /* ReadonlyKeyword */) { + if (node.readonlyToken.kind !== 143 /* ReadonlyKeyword */) { writeKeyword("readonly"); } writeSpace(); @@ -102266,7 +105838,7 @@ var ts; writeSpace(); } emit(node.name); - emitInitializer(node.initializer, node.name.end, node); + emitInitializer(node.initializer, node.name.end, node, parenthesizer.parenthesizeExpressionForDisallowedComma); } // // Expressions @@ -102274,7 +105846,7 @@ var ts; function emitArrayLiteralExpression(node) { var elements = node.elements; var preferNewLine = node.multiLine ? 65536 /* PreferNewLine */ : 0 /* None */; - emitExpressionList(node, elements, 8914 /* ArrayLiteralExpressionElements */ | preferNewLine); + emitExpressionList(node, elements, 8914 /* ArrayLiteralExpressionElements */ | preferNewLine, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitObjectLiteralExpression(node) { ts.forEach(node.properties, generateMemberNames); @@ -102290,13 +105862,13 @@ var ts; } } function emitPropertyAccessExpression(node) { - var expression = ts.cast(emitExpression(node.expression), ts.isExpression); + emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); var token = node.questionDotToken || ts.setTextRangePosEnd(ts.factory.createToken(24 /* 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 */ && - mayNeedDotDotForPropertyAccess(expression) && + mayNeedDotDotForPropertyAccess(node.expression) && !writer.hasTrailingComment() && !writer.hasTrailingWhitespace(); if (shouldEmitDotDot) { @@ -102332,27 +105904,27 @@ var ts; } } function emitElementAccessExpression(node) { - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); emit(node.questionDotToken); emitTokenWithComment(22 /* OpenBracketToken */, node.expression.end, writePunctuation, node); emitExpression(node.argumentExpression); emitTokenWithComment(23 /* CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); } function emitCallExpression(node) { - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); emit(node.questionDotToken); emitTypeArguments(node, node.typeArguments); - emitExpressionList(node, node.arguments, 2576 /* CallExpressionArguments */); + emitExpressionList(node, node.arguments, 2576 /* CallExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitNewExpression(node) { - emitTokenWithComment(102 /* NewKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(103 /* NewKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfNew); emitTypeArguments(node, node.typeArguments); - emitExpressionList(node, node.arguments, 18960 /* NewExpressionArguments */); + emitExpressionList(node, node.arguments, 18960 /* NewExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitTaggedTemplateExpression(node) { - emitExpression(node.tag); + emitExpression(node.tag, parenthesizer.parenthesizeLeftSideOfAccess); emitTypeArguments(node, node.typeArguments); writeSpace(); emitExpression(node.template); @@ -102361,12 +105933,12 @@ var ts; writePunctuation("<"); emit(node.type); writePunctuation(">"); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitParenthesizedExpression(node) { var openParenPos = emitTokenWithComment(20 /* OpenParenToken */, node.pos, writePunctuation, node); var indented = writeLineSeparatorsAndIndentBefore(node.expression, node); - emitExpression(node.expression); + emitExpression(node.expression, /*parenthesizerRules*/ undefined); writeLineSeparatorsAfter(node.expression, node); decreaseIndentIf(indented); emitTokenWithComment(21 /* CloseParenToken */, node.expression ? node.expression.end : openParenPos, writePunctuation, node); @@ -102388,31 +105960,31 @@ var ts; emit(node.equalsGreaterThanToken); } function emitDeleteExpression(node) { - emitTokenWithComment(88 /* DeleteKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(89 /* DeleteKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitTypeOfExpression(node) { - emitTokenWithComment(111 /* TypeOfKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(112 /* TypeOfKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitVoidExpression(node) { - emitTokenWithComment(113 /* VoidKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(114 /* VoidKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitAwaitExpression(node) { - emitTokenWithComment(130 /* AwaitKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(131 /* AwaitKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitPrefixUnaryExpression(node) { writeTokenText(node.operator, writeOperator); if (shouldEmitWhitespaceBeforeOperand(node)) { writeSpace(); } - emitExpression(node.operand); + emitExpression(node.operand, parenthesizer.parenthesizeOperandOfPrefixUnary); } function shouldEmitWhitespaceBeforeOperand(node) { // In some cases, we need to emit a space between the operator and the operand. One obvious case @@ -102428,84 +106000,101 @@ 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 === 214 /* PrefixUnaryExpression */ + return operand.kind === 216 /* 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 */))); } function emitPostfixUnaryExpression(node) { - emitExpression(node.operand); + emitExpression(node.operand, parenthesizer.parenthesizeOperandOfPostfixUnary); writeTokenText(node.operator, writeOperator); } - var EmitBinaryExpressionState; - (function (EmitBinaryExpressionState) { - EmitBinaryExpressionState[EmitBinaryExpressionState["EmitLeft"] = 0] = "EmitLeft"; - EmitBinaryExpressionState[EmitBinaryExpressionState["EmitRight"] = 1] = "EmitRight"; - EmitBinaryExpressionState[EmitBinaryExpressionState["FinishEmit"] = 2] = "FinishEmit"; - })(EmitBinaryExpressionState || (EmitBinaryExpressionState = {})); - /** - * emitBinaryExpression includes an embedded work stack to attempt to handle as many nested binary expressions - * as possible without creating any additional stack frames. This can only be done when the emit pipeline does - * not require notification/substitution/comment/sourcemap decorations. - */ - function emitBinaryExpression(node) { - var nodeStack = [node]; - var stateStack = [0 /* EmitLeft */]; - var stackIndex = 0; - while (stackIndex >= 0) { - node = nodeStack[stackIndex]; - switch (stateStack[stackIndex]) { - case 0 /* EmitLeft */: { - maybePipelineEmitExpression(node.left); - break; - } - case 1 /* EmitRight */: { - var isCommaOperator = node.operatorToken.kind !== 27 /* CommaToken */; - var linesBeforeOperator = getLinesBetweenNodes(node, node.left, node.operatorToken); - var linesAfterOperator = getLinesBetweenNodes(node, node.operatorToken, node.right); - writeLinesAndIndent(linesBeforeOperator, isCommaOperator); - emitLeadingCommentsOfPosition(node.operatorToken.pos); - writeTokenNode(node.operatorToken, node.operatorToken.kind === 100 /* InKeyword */ ? writeKeyword : writeOperator); - emitTrailingCommentsOfPosition(node.operatorToken.end, /*prefixSpace*/ true); // Binary operators should have a space before the comment starts - writeLinesAndIndent(linesAfterOperator, /*writeSpaceIfNotIndenting*/ true); - maybePipelineEmitExpression(node.right); - break; - } - case 2 /* FinishEmit */: { - var linesBeforeOperator = getLinesBetweenNodes(node, node.left, node.operatorToken); - var linesAfterOperator = getLinesBetweenNodes(node, node.operatorToken, node.right); - decreaseIndentIf(linesBeforeOperator, linesAfterOperator); - stackIndex--; - break; - } - default: return ts.Debug.fail("Invalid state " + stateStack[stackIndex] + " for emitBinaryExpressionWorker"); + function createEmitBinaryExpression() { + return ts.createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, /*foldState*/ undefined); + function onEnter(node, state) { + if (state) { + state.stackIndex++; + state.preserveSourceNewlinesStack[state.stackIndex] = preserveSourceNewlines; + state.containerPosStack[state.stackIndex] = containerPos; + state.containerEndStack[state.stackIndex] = containerEnd; + state.declarationListContainerEndStack[state.stackIndex] = declarationListContainerEnd; + var emitComments_1 = state.shouldEmitCommentsStack[state.stackIndex] = shouldEmitComments(node); + var emitSourceMaps = state.shouldEmitSourceMapsStack[state.stackIndex] = shouldEmitSourceMaps(node); + onBeforeEmitNode === null || onBeforeEmitNode === void 0 ? void 0 : onBeforeEmitNode(node); + if (emitComments_1) + emitCommentsBeforeNode(node); + if (emitSourceMaps) + emitSourceMapsBeforeNode(node); + beforeEmitNode(node); } - } - function maybePipelineEmitExpression(next) { - // Advance the state of this unit of work, - stateStack[stackIndex]++; - // Then actually do the work of emitting the node `next` returned by the prior state - // The following section should be identical to `pipelineEmit` save it assumes EmitHint.Expression and offloads - // binary expression handling, where possible, to the contained work queue - // #region trampolinePipelineEmit - var savedLastNode = lastNode; - var savedLastSubstitution = lastSubstitution; - lastNode = next; - lastSubstitution = undefined; + else { + state = { + stackIndex: 0, + preserveSourceNewlinesStack: [undefined], + containerPosStack: [-1], + containerEndStack: [-1], + declarationListContainerEndStack: [-1], + shouldEmitCommentsStack: [false], + shouldEmitSourceMapsStack: [false], + }; + } + return state; + } + function onLeft(next, _workArea, parent) { + return maybeEmitExpression(next, parent, "left"); + } + function onOperator(operatorToken, _state, node) { + var isCommaOperator = operatorToken.kind !== 27 /* 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); + emitTrailingCommentsOfPosition(operatorToken.end, /*prefixSpace*/ true); // Binary operators should have a space before the comment starts + writeLinesAndIndent(linesAfterOperator, /*writeSpaceIfNotIndenting*/ true); + } + function onRight(next, _workArea, parent) { + return maybeEmitExpression(next, parent, "right"); + } + function onExit(node, state) { + var linesBeforeOperator = getLinesBetweenNodes(node, node.left, node.operatorToken); + var linesAfterOperator = getLinesBetweenNodes(node, node.operatorToken, node.right); + decreaseIndentIf(linesBeforeOperator, linesAfterOperator); + if (state.stackIndex > 0) { + var savedPreserveSourceNewlines = state.preserveSourceNewlinesStack[state.stackIndex]; + var savedContainerPos = state.containerPosStack[state.stackIndex]; + var savedContainerEnd = state.containerEndStack[state.stackIndex]; + var savedDeclarationListContainerEnd = state.declarationListContainerEndStack[state.stackIndex]; + var shouldEmitComments_1 = state.shouldEmitCommentsStack[state.stackIndex]; + var shouldEmitSourceMaps_1 = state.shouldEmitSourceMapsStack[state.stackIndex]; + afterEmitNode(savedPreserveSourceNewlines); + if (shouldEmitSourceMaps_1) + emitSourceMapsAfterNode(node); + if (shouldEmitComments_1) + emitCommentsAfterNode(node, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd); + onAfterEmitNode === null || onAfterEmitNode === void 0 ? void 0 : onAfterEmitNode(node); + state.stackIndex--; + } + } + function maybeEmitExpression(next, parent, side) { + var parenthesizerRule = side === "left" ? + parenthesizer.getParenthesizeLeftSideOfBinaryForOperator(parent.operatorToken.kind) : + parenthesizer.getParenthesizeRightSideOfBinaryForOperator(parent.operatorToken.kind); var pipelinePhase = getPipelinePhase(0 /* Notification */, 1 /* Expression */, next); - if (pipelinePhase === pipelineEmitWithHint && ts.isBinaryExpression(next)) { - // If the target pipeline phase is emit directly, and the next node's also a binary expression, - // skip all the intermediate indirection and push the expression directly onto the work stack - stackIndex++; - stateStack[stackIndex] = 0 /* EmitLeft */; - nodeStack[stackIndex] = next; + if (pipelinePhase === pipelineEmitWithSubstitution) { + ts.Debug.assertIsDefined(lastSubstitution); + next = parenthesizerRule(ts.cast(lastSubstitution, ts.isExpression)); + pipelinePhase = getNextPipelinePhase(1 /* Substitution */, 1 /* Expression */, next); + lastSubstitution = undefined; } - else { - pipelinePhase(1 /* Expression */, next); + if (pipelinePhase === pipelineEmitWithComments || + pipelinePhase === pipelineEmitWithSourceMaps || + pipelinePhase === pipelineEmitWithHint) { + if (ts.isBinaryExpression(next)) { + return next; + } } - ts.Debug.assert(lastNode === next); - lastNode = savedLastNode; - lastSubstitution = savedLastSubstitution; - // #endregion trampolinePipelineEmit + currentParenthesizerRule = parenthesizerRule; + pipelinePhase(1 /* Expression */, next); } } function emitConditionalExpression(node) { @@ -102513,16 +106102,16 @@ var ts; var linesAfterQuestion = getLinesBetweenNodes(node, node.questionToken, node.whenTrue); var linesBeforeColon = getLinesBetweenNodes(node, node.whenTrue, node.colonToken); var linesAfterColon = getLinesBetweenNodes(node, node.colonToken, node.whenFalse); - emitExpression(node.condition); + emitExpression(node.condition, parenthesizer.parenthesizeConditionOfConditionalExpression); writeLinesAndIndent(linesBeforeQuestion, /*writeSpaceIfNotIndenting*/ true); emit(node.questionToken); writeLinesAndIndent(linesAfterQuestion, /*writeSpaceIfNotIndenting*/ true); - emitExpression(node.whenTrue); + emitExpression(node.whenTrue, parenthesizer.parenthesizeBranchOfConditionalExpression); decreaseIndentIf(linesBeforeQuestion, linesAfterQuestion); writeLinesAndIndent(linesBeforeColon, /*writeSpaceIfNotIndenting*/ true); emit(node.colonToken); writeLinesAndIndent(linesAfterColon, /*writeSpaceIfNotIndenting*/ true); - emitExpression(node.whenFalse); + emitExpression(node.whenFalse, parenthesizer.parenthesizeBranchOfConditionalExpression); decreaseIndentIf(linesBeforeColon, linesAfterColon); } function emitTemplateExpression(node) { @@ -102530,24 +106119,24 @@ var ts; emitList(node, node.templateSpans, 262144 /* TemplateExpressionSpans */); } function emitYieldExpression(node) { - emitTokenWithComment(124 /* YieldKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(125 /* YieldKeyword */, node.pos, writeKeyword, node); emit(node.asteriskToken); - emitExpressionWithLeadingSpace(node.expression); + emitExpressionWithLeadingSpace(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); } - function emitSpreadExpression(node) { + function emitSpreadElement(node) { emitTokenWithComment(25 /* DotDotDotToken */, node.pos, writePunctuation, node); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitClassExpression(node) { generateNameIfNeeded(node.name); emitClassDeclarationOrExpression(node); } function emitExpressionWithTypeArguments(node) { - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); emitTypeArguments(node, node.typeArguments); } function emitAsExpression(node) { - emitExpression(node.expression); + emitExpression(node.expression, /*parenthesizerRules*/ undefined); if (node.type) { writeSpace(); writeKeyword("as"); @@ -102556,7 +106145,7 @@ var ts; } } function emitNonNullExpression(node) { - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); writeOperator("!"); } function emitMetaProperty(node) { @@ -102599,7 +106188,7 @@ var ts; } } function emitExpressionStatement(node) { - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfExpressionStatement); // Emit semicolon in non json files // or if json file that created synthesized expression(eg.define expression statement when --out and amd code generation) if (!ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) { @@ -102607,7 +106196,7 @@ var ts; } } function emitIfStatement(node) { - var openParenPos = emitTokenWithComment(98 /* IfKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(99 /* IfKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -102615,8 +106204,8 @@ var ts; emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { writeLineOrSpace(node, node.thenStatement, node.elseStatement); - emitTokenWithComment(90 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 234 /* IfStatement */) { + emitTokenWithComment(91 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); + if (node.elseStatement.kind === 236 /* IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -102626,14 +106215,14 @@ var ts; } } function emitWhileClause(node, startPos) { - var openParenPos = emitTokenWithComment(114 /* WhileKeyword */, startPos, writeKeyword, node); + var openParenPos = emitTokenWithComment(115 /* WhileKeyword */, startPos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); } function emitDoStatement(node) { - emitTokenWithComment(89 /* DoKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(90 /* DoKeyword */, node.pos, writeKeyword, node); emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement) && !preserveSourceNewlines) { writeSpace(); @@ -102649,7 +106238,7 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { - var openParenPos = emitTokenWithComment(96 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); var pos = emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node); emitForBinding(node.initializer); @@ -102661,25 +106250,25 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { - var openParenPos = emitTokenWithComment(96 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(100 /* InKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(101 /* InKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { - var openParenPos = emitTokenWithComment(96 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitWithTrailingSpace(node.awaitModifier); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(156 /* OfKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(158 /* OfKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); @@ -102687,7 +106276,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 250 /* VariableDeclarationList */) { + if (node.kind === 252 /* VariableDeclarationList */) { emit(node); } else { @@ -102696,12 +106285,12 @@ var ts; } } function emitContinueStatement(node) { - emitTokenWithComment(85 /* ContinueKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(86 /* ContinueKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } function emitBreakStatement(node) { - emitTokenWithComment(80 /* BreakKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(81 /* BreakKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } @@ -102724,18 +106313,18 @@ var ts; } pos = writeTokenText(token, writer, pos); if (isSimilarNode && contextNode.end !== pos) { - var isJsxExprContext = contextNode.kind === 283 /* JsxExpression */; + var isJsxExprContext = contextNode.kind === 285 /* JsxExpression */; emitTrailingCommentsOfPosition(pos, /*prefixSpace*/ !isJsxExprContext, /*forceNoNewline*/ isJsxExprContext); } return pos; } function emitReturnStatement(node) { - emitTokenWithComment(104 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); + emitTokenWithComment(105 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); emitExpressionWithLeadingSpace(node.expression); writeTrailingSemicolon(); } function emitWithStatement(node) { - var openParenPos = emitTokenWithComment(115 /* WithKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(116 /* WithKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -102743,7 +106332,7 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { - var openParenPos = emitTokenWithComment(106 /* SwitchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(107 /* SwitchKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -102758,12 +106347,12 @@ var ts; emit(node.statement); } function emitThrowStatement(node) { - emitTokenWithComment(108 /* ThrowKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(109 /* ThrowKeyword */, node.pos, writeKeyword, node); emitExpressionWithLeadingSpace(node.expression); writeTrailingSemicolon(); } function emitTryStatement(node) { - emitTokenWithComment(110 /* TryKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(111 /* TryKeyword */, node.pos, writeKeyword, node); writeSpace(); emit(node.tryBlock); if (node.catchClause) { @@ -102772,13 +106361,13 @@ var ts; } if (node.finallyBlock) { writeLineOrSpace(node, node.catchClause || node.tryBlock, node.finallyBlock); - emitTokenWithComment(95 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); + emitTokenWithComment(96 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); writeSpace(); emit(node.finallyBlock); } } function emitDebuggerStatement(node) { - writeToken(86 /* DebuggerKeyword */, node.pos, writeKeyword); + writeToken(87 /* DebuggerKeyword */, node.pos, writeKeyword); writeTrailingSemicolon(); } // @@ -102788,7 +106377,7 @@ var ts; emit(node.name); emit(node.exclamationToken); emitTypeAnnotation(node.type); - emitInitializer(node.initializer, node.type ? node.type.end : node.name.end, node); + emitInitializer(node.initializer, node.type ? node.type.end : node.name.end, node, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitVariableDeclarationList(node) { writeKeyword(ts.isLet(node) ? "let" : ts.isVarConst(node) ? "const" : "var"); @@ -102807,9 +106396,6 @@ var ts; emitIdentifierName(node.name); emitSignatureAndBody(node, emitSignatureHead); } - function emitBlockCallback(_hint, body) { - emitBlockFunctionBody(body); - } function emitSignatureAndBody(node, emitSignatureHead) { var body = node.body; if (body) { @@ -102822,12 +106408,7 @@ var ts; ts.forEach(node.parameters, generateNames); generateNames(node.body); emitSignatureHead(node); - if (onEmitNode) { - onEmitNode(4 /* Unspecified */, body, emitBlockCallback); - } - else { - emitBlockFunctionBody(body); - } + emitBlockFunctionBody(body); popNameGenerationScope(node); if (indentedFlag) { decreaseIndent(); @@ -102836,7 +106417,7 @@ var ts; else { emitSignatureHead(node); writeSpace(); - emitExpression(body); + emitExpression(body, parenthesizer.parenthesizeConciseBodyOfArrowFunction); } } else { @@ -102880,6 +106461,7 @@ var ts; return true; } function emitBlockFunctionBody(body) { + onBeforeEmitNode === null || onBeforeEmitNode === void 0 ? void 0 : onBeforeEmitNode(body); writeSpace(); writePunctuation("{"); increaseIndent(); @@ -102894,6 +106476,7 @@ var ts; } decreaseIndent(); writeToken(19 /* CloseBraceToken */, body.statements.end, writePunctuation, body); + onAfterEmitNode === null || onAfterEmitNode === void 0 ? void 0 : onAfterEmitNode(body); } function emitBlockFunctionBodyOnSingleLine(body) { emitBlockFunctionBodyWorker(body, /*emitBlockFunctionBodyOnSingleLine*/ true); @@ -102909,7 +106492,7 @@ var ts; increaseIndent(); } else { - emitList(body, body.statements, 1 /* MultiLineFunctionBodyStatements */, statementOffset); + emitList(body, body.statements, 1 /* MultiLineFunctionBodyStatements */, /*parenthesizerRule*/ undefined, statementOffset); } } function emitClassDeclaration(node) { @@ -102984,7 +106567,7 @@ var ts; var body = node.body; if (!body) return writeTrailingSemicolon(); - while (body.kind === 256 /* ModuleDeclaration */) { + while (body && ts.isModuleDeclaration(body)) { writePunctuation("."); emit(body.name); body = body.body; @@ -103005,21 +106588,21 @@ var ts; } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(99 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(100 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.isTypeOnly) { - emitTokenWithComment(149 /* TypeKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(150 /* TypeKeyword */, node.pos, writeKeyword, node); writeSpace(); } emit(node.name); writeSpace(); - emitTokenWithComment(62 /* EqualsToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(63 /* EqualsToken */, node.name.end, writePunctuation, node); writeSpace(); emitModuleReference(node.moduleReference); writeTrailingSemicolon(); } function emitModuleReference(node) { - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { emitExpression(node); } else { @@ -103028,12 +106611,12 @@ var ts; } function emitImportDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(99 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(100 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.importClause) { emit(node.importClause); writeSpace(); - emitTokenWithComment(153 /* FromKeyword */, node.importClause.end, writeKeyword, node); + emitTokenWithComment(154 /* FromKeyword */, node.importClause.end, writeKeyword, node); writeSpace(); } emitExpression(node.moduleSpecifier); @@ -103041,7 +106624,7 @@ var ts; } function emitImportClause(node) { if (node.isTypeOnly) { - emitTokenWithComment(149 /* TypeKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(150 /* TypeKeyword */, node.pos, writeKeyword, node); writeSpace(); } emit(node.name); @@ -103054,7 +106637,7 @@ var ts; function emitNamespaceImport(node) { var asPos = emitTokenWithComment(41 /* AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(126 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(127 /* AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -103065,23 +106648,25 @@ var ts; emitImportOrExportSpecifier(node); } function emitExportAssignment(node) { - var nextPos = emitTokenWithComment(92 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isExportEquals) { - emitTokenWithComment(62 /* EqualsToken */, nextPos, writeOperator, node); + emitTokenWithComment(63 /* EqualsToken */, nextPos, writeOperator, node); } else { - emitTokenWithComment(87 /* DefaultKeyword */, nextPos, writeKeyword, node); + emitTokenWithComment(88 /* DefaultKeyword */, nextPos, writeKeyword, node); } writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, node.isExportEquals ? + parenthesizer.getParenthesizeRightSideOfBinaryForOperator(63 /* EqualsToken */) : + parenthesizer.parenthesizeExpressionOfExportDefault); writeTrailingSemicolon(); } function emitExportDeclaration(node) { - var nextPos = emitTokenWithComment(92 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isTypeOnly) { - nextPos = emitTokenWithComment(149 /* TypeKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(150 /* TypeKeyword */, nextPos, writeKeyword, node); writeSpace(); } if (node.exportClause) { @@ -103093,18 +106678,18 @@ var ts; if (node.moduleSpecifier) { writeSpace(); var fromPos = node.exportClause ? node.exportClause.end : nextPos; - emitTokenWithComment(153 /* FromKeyword */, fromPos, writeKeyword, node); + emitTokenWithComment(154 /* FromKeyword */, fromPos, writeKeyword, node); writeSpace(); emitExpression(node.moduleSpecifier); } writeTrailingSemicolon(); } function emitNamespaceExportDeclaration(node) { - var nextPos = emitTokenWithComment(92 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(126 /* AsKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(127 /* AsKeyword */, nextPos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(140 /* NamespaceKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(141 /* NamespaceKeyword */, nextPos, writeKeyword, node); writeSpace(); emit(node.name); writeTrailingSemicolon(); @@ -103112,7 +106697,7 @@ var ts; function emitNamespaceExport(node) { var asPos = emitTokenWithComment(41 /* AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(126 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(127 /* AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -103131,7 +106716,7 @@ var ts; if (node.propertyName) { emit(node.propertyName); writeSpace(); - emitTokenWithComment(126 /* AsKeyword */, node.propertyName.end, writeKeyword, node); + emitTokenWithComment(127 /* AsKeyword */, node.propertyName.end, writeKeyword, node); writeSpace(); } emit(node.name); @@ -103233,7 +106818,7 @@ var ts; } } function emitJsxTagName(node) { - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { emitExpression(node); } else { @@ -103244,13 +106829,13 @@ var ts; // Clauses // function emitCaseClause(node) { - emitTokenWithComment(81 /* CaseKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(82 /* CaseKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); emitCaseOrDefaultClauseRest(node, node.statements, node.expression.end); } function emitDefaultClause(node) { - var pos = emitTokenWithComment(87 /* DefaultKeyword */, node.pos, writeKeyword, node); + var pos = emitTokenWithComment(88 /* DefaultKeyword */, node.pos, writeKeyword, node); emitCaseOrDefaultClauseRest(node, node.statements, pos); } function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) { @@ -103278,7 +106863,7 @@ var ts; emitList(node, node.types, 528 /* HeritageClauseTypes */); } function emitCatchClause(node) { - var openParenPos = emitTokenWithComment(82 /* CatchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(83 /* CatchKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.variableDeclaration) { emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); @@ -103307,7 +106892,7 @@ var ts; var commentRange = ts.getCommentRange(initializer); emitTrailingCommentsOfPosition(commentRange.pos); } - emitExpression(initializer); + emitExpression(initializer, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitShorthandPropertyAssignment(node) { emit(node.name); @@ -103315,13 +106900,13 @@ var ts; writeSpace(); writePunctuation("="); writeSpace(); - emitExpression(node.objectAssignmentInitializer); + emitExpression(node.objectAssignmentInitializer, parenthesizer.parenthesizeExpressionForDisallowedComma); } } function emitSpreadAssignment(node) { if (node.expression) { emitTokenWithComment(25 /* DotDotDotToken */, node.pos, writePunctuation, node); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); } } // @@ -103329,7 +106914,7 @@ var ts; // function emitEnumMember(node) { emit(node.name); - emitInitializer(node.initializer, node.name.end, node); + emitInitializer(node.initializer, node.name.end, node, parenthesizer.parenthesizeExpressionForDisallowedComma); } // // JSDoc @@ -103337,18 +106922,21 @@ var ts; function emitJSDoc(node) { write("/**"); if (node.comment) { - var lines = node.comment.split(/\r\n?|\n/g); - for (var _a = 0, lines_2 = lines; _a < lines_2.length; _a++) { - var line = lines_2[_a]; - writeLine(); - writeSpace(); - writePunctuation("*"); - writeSpace(); - write(line); + var text = ts.getTextOfJSDocComment(node.comment); + if (text) { + var lines = text.split(/\r\n?|\n/g); + for (var _a = 0, lines_2 = lines; _a < lines_2.length; _a++) { + var line = lines_2[_a]; + writeLine(); + writeSpace(); + writePunctuation("*"); + writeSpace(); + write(line); + } } } if (node.tags) { - if (node.tags.length === 1 && node.tags[0].kind === 329 /* JSDocTypeTag */ && !node.comment) { + if (node.tags.length === 1 && node.tags[0].kind === 337 /* JSDocTypeTag */ && !node.comment) { writeSpace(); emit(node.tags[0]); } @@ -103393,7 +106981,7 @@ var ts; function emitJSDocTypedefTag(tag) { emitJSDocTagName(tag.tagName); if (tag.typeExpression) { - if (tag.typeExpression.kind === 301 /* JSDocTypeExpression */) { + if (tag.typeExpression.kind === 303 /* JSDocTypeExpression */) { emitJSDocTypeExpression(tag.typeExpression); } else { @@ -103412,7 +107000,7 @@ var ts; emit(tag.fullName); } emitJSDocComment(tag.comment); - if (tag.typeExpression && tag.typeExpression.kind === 312 /* JSDocTypeLiteral */) { + if (tag.typeExpression && tag.typeExpression.kind === 316 /* JSDocTypeLiteral */) { emitJSDocTypeLiteral(tag.typeExpression); } } @@ -103465,9 +107053,10 @@ var ts; emit(tagName); } function emitJSDocComment(comment) { - if (comment) { + var text = ts.getTextOfJSDocComment(comment); + if (text) { writeSpace(); - write(comment); + write(text); } } function emitJSDocTypeExpression(typeExpression) { @@ -103570,7 +107159,7 @@ var ts; emitHelpers(node); var index = ts.findIndex(statements, function (statement) { return !ts.isPrologueDirective(statement); }); emitTripleSlashDirectivesIfNeeded(node); - emitList(node, statements, 1 /* MultiLine */, index === -1 ? statements.length : index); + emitList(node, statements, 1 /* MultiLine */, /*parenthesizerRule*/ undefined, index === -1 ? statements.length : index); popNameGenerationScope(node); } // Transformation nodes @@ -103578,7 +107167,7 @@ var ts; emitExpression(node.expression); } function emitCommaList(node) { - emitExpressionList(node, node.elements, 528 /* CommaListElements */); + emitExpressionList(node, node.elements, 528 /* CommaListElements */, /*parenthesizerRule*/ undefined); } /** * Emits any prologue directives at the start of a Statement list, returning the @@ -103724,12 +107313,12 @@ var ts; emit(node); } } - function emitInitializer(node, equalCommentStartPos, container) { + function emitInitializer(node, equalCommentStartPos, container, parenthesizerRule) { if (node) { writeSpace(); - emitTokenWithComment(62 /* EqualsToken */, equalCommentStartPos, writeOperator, container); + emitTokenWithComment(63 /* EqualsToken */, equalCommentStartPos, writeOperator, container); writeSpace(); - emitExpression(node); + emitExpression(node, parenthesizerRule); } } function emitNodeWithPrefix(prefix, prefixWriter, node, emit) { @@ -103744,10 +107333,10 @@ var ts; emit(node); } } - function emitExpressionWithLeadingSpace(node) { + function emitExpressionWithLeadingSpace(node, parenthesizerRule) { if (node) { writeSpace(); - emitExpression(node); + emitExpression(node, parenthesizerRule); } } function emitWithTrailingSpace(node) { @@ -103777,7 +107366,7 @@ var ts; emitList(parentNode, decorators, 2146305 /* Decorators */); } function emitTypeArguments(parentNode, typeArguments) { - emitList(parentNode, typeArguments, 53776 /* TypeArguments */); + emitList(parentNode, typeArguments, 53776 /* TypeArguments */, parenthesizer.parenthesizeMemberOfElementType); } function emitTypeParameters(parentNode, typeParameters) { if (ts.isFunctionLike(parentNode) && parentNode.typeArguments) { // Quick info uses type arguments in place of type parameters on instantiated signatures @@ -103816,12 +107405,6 @@ var ts; function emitParametersForIndexSignature(parentNode, parameters) { emitList(parentNode, parameters, 8848 /* IndexSignatureParameters */); } - function emitList(parentNode, children, format, start, count) { - emitNodeList(emit, parentNode, children, format, start, count); - } - function emitExpressionList(parentNode, children, format, start, count) { - emitNodeList(emitExpression, parentNode, children, format, start, count); // TODO: GH#18217 - } function writeDelimiter(format) { switch (format & 60 /* DelimitersMask */) { case 0 /* None */: @@ -103844,7 +107427,13 @@ var ts; break; } } - function emitNodeList(emit, parentNode, children, format, start, count) { + function emitList(parentNode, children, format, parenthesizerRule, start, count) { + emitNodeList(emit, parentNode, children, format, parenthesizerRule, start, count); + } + function emitExpressionList(parentNode, children, format, parenthesizerRule, start, count) { + emitNodeList(emitExpression, parentNode, children, format, parenthesizerRule, start, count); + } + function emitNodeList(emit, parentNode, children, format, parenthesizerRule, start, count) { if (start === void 0) { start = 0; } if (count === void 0) { count = children ? children.length - start : 0; } var isUndefined = children === undefined; @@ -103863,8 +107452,7 @@ var ts; } if (format & 15360 /* BracketsMask */) { writePunctuation(getOpeningBracket(format)); - if (isEmpty && !isUndefined) { - // TODO: GH#18217 + if (isEmpty && children) { emitTrailingCommentsOfPosition(children.pos, /*prefixSpace*/ true); // Emit comments within empty bracketed lists } } @@ -103873,7 +107461,7 @@ var ts; } if (isEmpty) { // Write a line terminator if the parent node was multi-line - if (format & 1 /* MultiLine */ && !(preserveSourceNewlines && ts.rangeIsOnSingleLine(parentNode, currentSourceFile))) { + if (format & 1 /* MultiLine */ && !(preserveSourceNewlines && (!parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) { writeLine(); } else if (format & 256 /* SpaceBetweenBraces */ && !(format & 524288 /* NoSpaceIfEmpty */)) { @@ -103881,6 +107469,7 @@ var ts; } } else { + ts.Debug.type(children); // Write the opening line terminator or leading whitespace. var mayEmitInterveningComments = (format & 262144 /* NoInterveningComments */) === 0; var shouldEmitInterveningComments = mayEmitInterveningComments; @@ -103915,7 +107504,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.end) { + if (format & 60 /* DelimitersMask */ && previousSibling.end !== (parentNode ? parentNode.end : -1)) { emitLeadingCommentsOfPosition(previousSibling.end); } writeDelimiter(format); @@ -103948,7 +107537,12 @@ var ts; shouldEmitInterveningComments = mayEmitInterveningComments; } nextListElementPos = child.pos; - emit(child); + if (emit.length === 1) { + emit(child); + } + else { + emit(child, parenthesizerRule); + } if (shouldDecreaseIndentAfterEmit) { decreaseIndent(); shouldDecreaseIndentAfterEmit = false; @@ -103973,7 +107567,7 @@ var ts; // 2 // /* end of element 2 */ // ]; - if (previousSibling && parentNode.end !== previousSibling.end && (format & 60 /* DelimitersMask */) && !skipTrailingComments) { + if (previousSibling && (parentNode ? parentNode.end : -1) !== previousSibling.end && (format & 60 /* DelimitersMask */) && !skipTrailingComments) { emitLeadingCommentsOfPosition(hasTrailingComma && (children === null || children === void 0 ? void 0 : children.end) ? children.end : previousSibling.end); } // Decrease the indent, if requested. @@ -103994,8 +107588,7 @@ var ts; onAfterEmitNodeArray(children); } if (format & 15360 /* BracketsMask */) { - if (isEmpty && !isUndefined) { - // TODO: GH#18217 + if (isEmpty && children) { emitLeadingCommentsOfPosition(children.end); // Emit leading comments within empty lists } writePunctuation(getClosingBracket(format)); @@ -104126,7 +107719,7 @@ var ts; } var firstChild_1 = children[0]; if (firstChild_1 === undefined) { - return ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; + return !parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; } if (firstChild_1.pos === nextListElementPos) { // If this child starts at the beginning of a list item in a parent list, its leading @@ -104150,7 +107743,8 @@ var ts; // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } - if (!ts.positionIsSynthesized(parentNode.pos) && + if (parentNode && + !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(firstChild_1) && (!firstChild_1.parent || ts.getOriginalNode(firstChild_1.parent) === ts.getOriginalNode(parentNode))) { if (preserveSourceNewlines) { @@ -104173,10 +107767,10 @@ var ts; // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } - else if (!ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode) && previousNode.parent === nextNode.parent) { - if (preserveSourceNewlines) { - return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); - } + else if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) { + return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); + } + else if (!preserveSourceNewlines && !ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) { return ts.rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile) ? 0 : 1; } else if (synthesizedNodeStartsOnNewLine(previousNode, format) || synthesizedNodeStartsOnNewLine(nextNode, format)) { @@ -104195,9 +107789,9 @@ var ts; } var lastChild = ts.lastOrUndefined(children); if (lastChild === undefined) { - return ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; + return !parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; } - if (!ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) { + if (parentNode && !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) { if (preserveSourceNewlines) { var end_1 = ts.isNodeArray(children) && !ts.positionIsSynthesized(children.end) ? children.end : lastChild.end; return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenPositionAndNextNonWhitespaceCharacter(end_1, parentNode.end, currentSourceFile, includeComments); }); @@ -104283,7 +107877,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 207 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 209 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -104353,84 +107947,84 @@ var ts; if (!node) return; switch (node.kind) { - case 230 /* Block */: + case 232 /* Block */: ts.forEach(node.statements, generateNames); break; - case 245 /* LabeledStatement */: - case 243 /* WithStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: + case 247 /* LabeledStatement */: + case 245 /* WithStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: generateNames(node.statement); break; - case 234 /* IfStatement */: + case 236 /* IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 237 /* ForStatement */: - case 239 /* ForOfStatement */: - case 238 /* ForInStatement */: + case 239 /* ForStatement */: + case 241 /* ForOfStatement */: + case 240 /* ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: generateNames(node.caseBlock); break; - case 258 /* CaseBlock */: + case 260 /* CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 284 /* CaseClause */: - case 285 /* DefaultClause */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 247 /* TryStatement */: + case 249 /* TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 287 /* CatchClause */: + case 289 /* CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: generateNames(node.declarationList); break; - case 250 /* VariableDeclarationList */: + case 252 /* VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 249 /* VariableDeclaration */: - case 160 /* Parameter */: - case 198 /* BindingElement */: - case 252 /* ClassDeclaration */: + case 251 /* VariableDeclaration */: + case 162 /* Parameter */: + case 200 /* BindingElement */: + case 254 /* ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 196 /* ObjectBindingPattern */: - case 197 /* ArrayBindingPattern */: + case 198 /* ObjectBindingPattern */: + case 199 /* ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: generateNames(node.importClause); break; - case 262 /* ImportClause */: + case 264 /* ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: generateNameIfNeeded(node.name); break; - case 269 /* NamespaceExport */: + case 271 /* NamespaceExport */: generateNameIfNeeded(node.name); break; - case 264 /* NamedImports */: + case 266 /* NamedImports */: ts.forEach(node.elements, generateNames); break; - case 265 /* ImportSpecifier */: + case 267 /* ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -104439,12 +108033,12 @@ var ts; if (!node) return; switch (node.kind) { - case 288 /* PropertyAssignment */: - case 289 /* ShorthandPropertyAssignment */: - case 163 /* PropertyDeclaration */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 290 /* PropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: + case 165 /* PropertyDeclaration */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: generateNameIfNeeded(node.name); break; } @@ -104624,25 +108218,25 @@ var ts; */ function generateNameForNode(node, flags) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 256 /* ModuleDeclaration */: - case 255 /* EnumDeclaration */: + case 258 /* ModuleDeclaration */: + case 257 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 261 /* ImportDeclaration */: - case 267 /* ExportDeclaration */: + case 263 /* ImportDeclaration */: + case 269 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 251 /* FunctionDeclaration */: - case 252 /* ClassDeclaration */: - case 266 /* ExportAssignment */: + case 253 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: + case 268 /* ExportAssignment */: return generateNameForExportDefault(); - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: return generateNameForClassExpression(); - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return generateNameForMethodOrAccessor(node); - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return makeTempVariableName(0 /* Auto */, /*reserveInNestedScopes*/ true); default: return makeTempVariableName(0 /* Auto */); @@ -104685,25 +108279,45 @@ var ts; } // Comments function pipelineEmitWithComments(hint, node) { - ts.Debug.assert(lastNode === node || lastSubstitution === node); + var pipelinePhase = getNextPipelinePhase(2 /* Comments */, hint, node); + var savedContainerPos = containerPos; + var savedContainerEnd = containerEnd; + var savedDeclarationListContainerEnd = declarationListContainerEnd; + emitCommentsBeforeNode(node); + pipelinePhase(hint, node); + emitCommentsAfterNode(node, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd); + } + function emitCommentsBeforeNode(node) { + var emitFlags = ts.getEmitFlags(node); + var commentRange = ts.getCommentRange(node); + // Emit leading comments + emitLeadingCommentsOfNode(node, emitFlags, commentRange.pos, commentRange.end); + if (emitFlags & 2048 /* NoNestedComments */) { + commentsDisabled = true; + } + } + function emitCommentsAfterNode(node, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd) { + var emitFlags = ts.getEmitFlags(node); + var commentRange = ts.getCommentRange(node); + // Emit trailing comments + if (emitFlags & 2048 /* NoNestedComments */) { + commentsDisabled = false; + } + emitTrailingCommentsOfNode(node, emitFlags, commentRange.pos, commentRange.end, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd); + } + function emitLeadingCommentsOfNode(node, emitFlags, pos, end) { enterComment(); hasWrittenComment = false; - var emitFlags = ts.getEmitFlags(node); - var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; - var isEmittedNode = node.kind !== 335 /* NotEmittedStatement */; // 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 */; // Save current container state on the stack. - var savedContainerPos = containerPos; - var savedContainerEnd = containerEnd; - var savedDeclarationListContainerEnd = declarationListContainerEnd; 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); + emitLeadingComments(pos, /*isEmittedNode*/ node.kind !== 343 /* NotEmittedStatement */); } if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512 /* NoLeadingComments */) !== 0)) { // Advance the container position if comments get emitted or if they've been disabled explicitly using NoLeadingComments. @@ -104714,23 +108328,17 @@ var ts; 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 === 250 /* VariableDeclarationList */) { + if (node.kind === 252 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } } ts.forEach(ts.getSyntheticLeadingComments(node), emitLeadingSynthesizedComment); exitComment(); - var pipelinePhase = getNextPipelinePhase(2 /* Comments */, hint, node); - if (emitFlags & 2048 /* NoNestedComments */) { - commentsDisabled = true; - pipelinePhase(hint, node); - commentsDisabled = false; - } - else { - pipelinePhase(hint, node); - } + } + function emitTrailingCommentsOfNode(node, emitFlags, pos, end, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd) { enterComment(); + var skipTrailingComments = end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0 || node.kind === 11 /* JsxText */; ts.forEach(ts.getSyntheticTrailingComments(node), emitTrailingSynthesizedComment); if ((pos > 0 || end > 0) && pos !== end) { // Restore previous container state. @@ -104739,12 +108347,11 @@ 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 && isEmittedNode) { + if (!skipTrailingComments && node.kind !== 343 /* NotEmittedStatement */) { emitTrailingComments(end); } } exitComment(); - ts.Debug.assert(lastNode === node || lastSubstitution === node); } function emitLeadingSynthesizedComment(comment) { if (comment.hasLeadingNewline || comment.kind === 2 /* SingleLineCommentTrivia */) { @@ -104804,6 +108411,23 @@ var ts; } exitComment(); } + function siblingNodePositionsAreComparable(previousNode, nextNode) { + if (ts.nodeIsSynthesized(previousNode) || ts.nodeIsSynthesized(nextNode)) { + return false; + } + if (nextNode.pos < previousNode.end) { + return false; + } + previousNode = ts.getOriginalNode(previousNode); + nextNode = ts.getOriginalNode(nextNode); + var parent = previousNode.parent; + if (!parent || parent !== nextNode.parent) { + return false; + } + var parentNodeArray = ts.getContainingNodeArray(previousNode); + var prevNodeIndex = parentNodeArray === null || parentNodeArray === void 0 ? void 0 : parentNodeArray.indexOf(previousNode); + return prevNodeIndex !== undefined && prevNodeIndex > -1 && parentNodeArray.indexOf(nextNode) === prevNodeIndex + 1; + } function emitLeadingComments(pos, isEmittedNode) { hasWrittenComment = false; if (isEmittedNode) { @@ -104976,42 +108600,49 @@ var ts; } return node.parsedSourceMap || undefined; } - function pipelineEmitWithSourceMap(hint, node) { - ts.Debug.assert(lastNode === node || lastSubstitution === node); + function pipelineEmitWithSourceMaps(hint, node) { var pipelinePhase = getNextPipelinePhase(3 /* SourceMaps */, hint, node); - if (ts.isUnparsedSource(node) || ts.isUnparsedPrepend(node)) { - pipelinePhase(hint, node); - } - else if (ts.isUnparsedNode(node)) { + emitSourceMapsBeforeNode(node); + pipelinePhase(hint, node); + emitSourceMapsAfterNode(node); + } + function emitSourceMapsBeforeNode(node) { + var emitFlags = ts.getEmitFlags(node); + var sourceMapRange = ts.getSourceMapRange(node); + // Emit leading sourcemap + if (ts.isUnparsedNode(node)) { + ts.Debug.assertIsDefined(node.parent, "UnparsedNodes must have parent pointers"); var parsed = getParsedSourceMap(node.parent); if (parsed && sourceMapGenerator) { sourceMapGenerator.appendSourceMap(writer.getLine(), writer.getColumn(), parsed, node.parent.sourceMapPath, node.parent.getLineAndCharacterOfPosition(node.pos), node.parent.getLineAndCharacterOfPosition(node.end)); } - pipelinePhase(hint, node); } else { - var _a = ts.getSourceMapRange(node), pos = _a.pos, end = _a.end, _b = _a.source, source = _b === void 0 ? sourceMapSource : _b; - var emitFlags = ts.getEmitFlags(node); - if (node.kind !== 335 /* NotEmittedStatement */ + var source = sourceMapRange.source || sourceMapSource; + if (node.kind !== 343 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 - && pos >= 0) { - emitSourcePos(source, skipSourceTrivia(source, pos)); + && sourceMapRange.pos >= 0) { + emitSourcePos(sourceMapRange.source || sourceMapSource, skipSourceTrivia(source, sourceMapRange.pos)); } if (emitFlags & 64 /* NoNestedSourceMaps */) { sourceMapsDisabled = true; - pipelinePhase(hint, node); - sourceMapsDisabled = false; } - else { - pipelinePhase(hint, node); + } + } + function emitSourceMapsAfterNode(node) { + var emitFlags = ts.getEmitFlags(node); + var sourceMapRange = ts.getSourceMapRange(node); + // Emit trailing sourcemap + if (!ts.isUnparsedNode(node)) { + if (emitFlags & 64 /* NoNestedSourceMaps */) { + sourceMapsDisabled = false; } - if (node.kind !== 335 /* NotEmittedStatement */ + if (node.kind !== 343 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 - && end >= 0) { - emitSourcePos(source, end); + && sourceMapRange.end >= 0) { + emitSourcePos(sourceMapRange.source || sourceMapSource, sourceMapRange.end); } } - ts.Debug.assert(lastNode === node || lastSubstitution === node); } /** * Skips trivia such as comments and white-space that can be optionally overridden by the source-map source @@ -105163,12 +108794,22 @@ var ts; return ts.getBaseFileName(ts.normalizePath(fileName)); } function createCachedFileSystemEntries(rootDir, rootDirPath) { - var resultFromHost = { - files: ts.map(host.readDirectory(rootDir, /*extensions*/ undefined, /*exclude*/ undefined, /*include*/ ["*.*"]), getBaseNameOfFileName) || [], - directories: host.getDirectories(rootDir) || [] - }; - cachedReadDirectoryResult.set(ts.ensureTrailingDirectorySeparator(rootDirPath), resultFromHost); - return resultFromHost; + var _a; + if (!host.realpath || ts.ensureTrailingDirectorySeparator(toPath(host.realpath(rootDir))) === rootDirPath) { + var resultFromHost = { + files: ts.map(host.readDirectory(rootDir, /*extensions*/ undefined, /*exclude*/ undefined, /*include*/ ["*.*"]), getBaseNameOfFileName) || [], + directories: host.getDirectories(rootDir) || [] + }; + cachedReadDirectoryResult.set(ts.ensureTrailingDirectorySeparator(rootDirPath), resultFromHost); + return resultFromHost; + } + // If the directory is symlink do not cache the result + if ((_a = host.directoryExists) === null || _a === void 0 ? void 0 : _a.call(host, rootDir)) { + cachedReadDirectoryResult.set(rootDirPath, false); + return false; + } + // Non existing directory + return undefined; } /** * If the readDirectory result was already cached, it returns that @@ -105243,17 +108884,32 @@ var ts; } function readDirectory(rootDir, extensions, excludes, includes, depth) { var rootDirPath = toPath(rootDir); - var result = tryReadDirectory(rootDir, rootDirPath); - if (result) { + var rootResult = tryReadDirectory(rootDir, rootDirPath); + var rootSymLinkResult; + if (rootResult !== undefined) { return ts.matchFiles(rootDir, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, depth, getFileSystemEntries, realpath); } return host.readDirectory(rootDir, extensions, excludes, includes, depth); function getFileSystemEntries(dir) { var path = toPath(dir); if (path === rootDirPath) { - return result; - } - return tryReadDirectory(dir, path) || ts.emptyFileSystemEntries; + return rootResult || getFileSystemEntriesFromHost(dir, path); + } + var result = tryReadDirectory(dir, path); + return result !== undefined ? + result || getFileSystemEntriesFromHost(dir, path) : + ts.emptyFileSystemEntries; + } + function getFileSystemEntriesFromHost(dir, path) { + if (rootSymLinkResult && path === rootDirPath) + return rootSymLinkResult; + var result = { + files: ts.map(host.readDirectory(dir, /*extensions*/ undefined, /*exclude*/ undefined, /*include*/ ["*.*"]), getBaseNameOfFileName) || ts.emptyArray, + directories: host.getDirectories(dir) || ts.emptyArray + }; + if (path === rootDirPath) + rootSymLinkResult = result; + return result; } } function realpath(s) { @@ -105261,7 +108917,7 @@ var ts; } function addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath) { var existingResult = getCachedFileSystemEntries(fileOrDirectoryPath); - if (existingResult) { + if (existingResult !== undefined) { // Just clear the cache for now // For now just clear the cache, since this could mean that multiple level entries might need to be re-evaluated clearCache(); @@ -105321,9 +108977,9 @@ var ts; /** * Updates the map of shared extended config file watches with a new set of extended config files from a base config file of the project */ - function updateSharedExtendedConfigFileWatcher(projectPath, parsed, extendedConfigFilesMap, createExtendedConfigFileWatch, toPath) { + function updateSharedExtendedConfigFileWatcher(projectPath, options, extendedConfigFilesMap, createExtendedConfigFileWatch, toPath) { var _a; - var extendedConfigs = ts.arrayToMap(((_a = parsed === null || parsed === void 0 ? void 0 : parsed.options.configFile) === null || _a === void 0 ? void 0 : _a.extendedSourceFiles) || ts.emptyArray, toPath); + var extendedConfigs = ts.arrayToMap(((_a = options === null || options === void 0 ? void 0 : options.configFile) === null || _a === void 0 ? void 0 : _a.extendedSourceFiles) || ts.emptyArray, toPath); // remove project from all unrelated watchers extendedConfigFilesMap.forEach(function (watcher, extendedConfigFilePath) { if (!extendedConfigs.has(extendedConfigFilePath)) { @@ -105341,12 +108997,12 @@ var ts; // start watching previously unseen extended config extendedConfigFilesMap.set(extendedConfigFilePath, { projects: new ts.Set([projectPath]), - fileWatcher: createExtendedConfigFileWatch(extendedConfigFileName, extendedConfigFilePath), + watcher: createExtendedConfigFileWatch(extendedConfigFileName, extendedConfigFilePath), close: function () { var existing = extendedConfigFilesMap.get(extendedConfigFilePath); if (!existing || existing.projects.size !== 0) return; - existing.fileWatcher.close(); + existing.watcher.close(); extendedConfigFilesMap.delete(extendedConfigFilePath); }, }); @@ -105354,6 +109010,31 @@ var ts; }); } ts.updateSharedExtendedConfigFileWatcher = updateSharedExtendedConfigFileWatcher; + /** + * Remove the project from the extended config file watchers and close not needed watches + */ + function clearSharedExtendedConfigFileWatcher(projectPath, extendedConfigFilesMap) { + extendedConfigFilesMap.forEach(function (watcher) { + if (watcher.projects.delete(projectPath)) + watcher.close(); + }); + } + ts.clearSharedExtendedConfigFileWatcher = clearSharedExtendedConfigFileWatcher; + /** + * Clean the extendsConfigCache when extended config file has changed + */ + function cleanExtendedConfigCache(extendedConfigCache, extendedConfigFilePath, toPath) { + if (!extendedConfigCache.delete(extendedConfigFilePath)) + return; + extendedConfigCache.forEach(function (_a, key) { + var _b; + var extendedResult = _a.extendedResult; + if ((_b = extendedResult.extendedSourceFiles) === null || _b === void 0 ? void 0 : _b.some(function (extendedFile) { return toPath(extendedFile) === extendedConfigFilePath; })) { + cleanExtendedConfigCache(extendedConfigCache, key, toPath); + } + }); + } + ts.cleanExtendedConfigCache = cleanExtendedConfigCache; /** * Updates the existing missing file watches with the new set of missing files after new program is created */ @@ -105405,7 +109086,7 @@ var ts; ts.updateWatchingWildcardDirectories = updateWatchingWildcardDirectories; /* @internal */ function isIgnoredFileFromWildCardWatching(_a) { - 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; + 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); @@ -105428,7 +109109,7 @@ var ts; return false; // We want to ignore emit file check if file is not going to be emitted next to source file // In that case we follow config file inclusion rules - if (options.outFile || options.outDir) + if (ts.outFile(options) || options.outDir) return false; // File if emitted next to input needs to be ignored if (ts.fileExtensionIs(fileOrDirectoryPath, ".d.ts" /* Dts */)) { @@ -105441,7 +109122,8 @@ var ts; } // just check if sourceFile with the name exists var filePathWithoutExtension = ts.removeFileExtension(fileOrDirectoryPath); - var realProgram = isBuilderProgram(program) ? program.getProgramOrUndefined() : program; + 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); @@ -105451,7 +109133,9 @@ var ts; function hasSourceFile(file) { return realProgram ? !!realProgram.getSourceFileByPath(file) : - program.getState().fileInfos.has(file); + builderProgram ? + builderProgram.getState().fileInfos.has(file) : + !!ts.find(program, function (rootFile) { return toPath(rootFile) === file; }); } } ts.isIgnoredFileFromWildCardWatching = isIgnoredFileFromWildCardWatching; @@ -105924,8 +109608,8 @@ var ts; var lineStart = ts.getPositionOfLineAndCharacter(file, i, 0); var lineEnd = i < lastLineInFile ? ts.getPositionOfLineAndCharacter(file, i + 1, 0) : file.text.length; var lineContent = file.text.slice(lineStart, lineEnd); - lineContent = lineContent.replace(/\s+$/g, ""); // trim from end - lineContent = lineContent.replace("\t", " "); // convert tabs to single spaces + lineContent = ts.trimStringEnd(lineContent); // trim from end + lineContent = lineContent.replace(/\t/g, " "); // convert tabs to single spaces // Output the gutter and the actual contents of the line. context += indent + formatColorAndReset(ts.padLeft(i + 1 + "", gutterWidth), gutterStyleSequence) + gutterSeparator; context += lineContent + host.getNewLine(); @@ -106130,38 +109814,31 @@ var ts; * Determines if program structure is upto date or needs to be recreated */ /* @internal */ - function isProgramUptoDate(program, rootFileNames, newOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, projectReferences) { + function isProgramUptoDate(program, rootFileNames, newOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences) { // If we haven't created a program yet or have changed automatic type directives, then it is not up-to-date - if (!program || (hasChangedAutomaticTypeDirectiveNames === null || hasChangedAutomaticTypeDirectiveNames === void 0 ? void 0 : hasChangedAutomaticTypeDirectiveNames())) { + if (!program || (hasChangedAutomaticTypeDirectiveNames === null || hasChangedAutomaticTypeDirectiveNames === void 0 ? void 0 : hasChangedAutomaticTypeDirectiveNames())) return false; - } // If root file names don't match - if (!ts.arrayIsEqualTo(program.getRootFileNames(), rootFileNames)) { + if (!ts.arrayIsEqualTo(program.getRootFileNames(), rootFileNames)) return false; - } var seenResolvedRefs; // If project references don't match - if (!ts.arrayIsEqualTo(program.getProjectReferences(), projectReferences, projectReferenceUptoDate)) { + if (!ts.arrayIsEqualTo(program.getProjectReferences(), projectReferences, projectReferenceUptoDate)) return false; - } // If any file is not up-to-date, then the whole program is not up-to-date - if (program.getSourceFiles().some(sourceFileNotUptoDate)) { + if (program.getSourceFiles().some(sourceFileNotUptoDate)) return false; - } // If any of the missing file paths are now created - if (program.getMissingFilePaths().some(fileExists)) { + if (program.getMissingFilePaths().some(fileExists)) return false; - } var currentOptions = program.getCompilerOptions(); // If the compilation settings do no match, then the program is not up-to-date - if (!ts.compareDataObjects(currentOptions, newOptions)) { + if (!ts.compareDataObjects(currentOptions, newOptions)) return false; - } // If everything matches but the text of config file is changed, // error locations can change for program options, so update the program - if (currentOptions.configFile && newOptions.configFile) { + if (currentOptions.configFile && newOptions.configFile) return currentOptions.configFile.text === newOptions.configFile.text; - } return true; function sourceFileNotUptoDate(sourceFile) { return !sourceFileVersionUptoDate(sourceFile) || @@ -106171,21 +109848,25 @@ var ts; return sourceFile.version === getSourceVersion(sourceFile.resolvedPath, sourceFile.fileName); } function projectReferenceUptoDate(oldRef, newRef, index) { - if (!ts.projectReferenceIsEqualTo(oldRef, newRef)) { - return false; - } - return resolvedProjectReferenceUptoDate(program.getResolvedProjectReferences()[index], oldRef); + return ts.projectReferenceIsEqualTo(oldRef, newRef) && + resolvedProjectReferenceUptoDate(program.getResolvedProjectReferences()[index], oldRef); } function resolvedProjectReferenceUptoDate(oldResolvedRef, oldRef) { if (oldResolvedRef) { - if (ts.contains(seenResolvedRefs, oldResolvedRef)) { - // Assume true + // Assume true + if (ts.contains(seenResolvedRefs, oldResolvedRef)) return true; - } - // If sourceFile for the oldResolvedRef existed, check the version for uptodate - if (!sourceFileVersionUptoDate(oldResolvedRef.sourceFile)) { + var refPath_1 = resolveProjectReferencePath(oldRef); + var newParsedCommandLine = getParsedCommandLine(refPath_1); + // Check if config file exists + if (!newParsedCommandLine) + return false; + // If change in source file + if (oldResolvedRef.commandLine.options.configFile !== newParsedCommandLine.options.configFile) + return false; + // check file names + if (!ts.arrayIsEqualTo(oldResolvedRef.commandLine.fileNames, newParsedCommandLine.fileNames)) return false; - } // Add to seen before checking the referenced paths of this config file (seenResolvedRefs || (seenResolvedRefs = [])).push(oldResolvedRef); // If child project references are upto date, this project reference is uptodate @@ -106195,7 +109876,8 @@ var ts; } // In old program, not able to resolve project reference path, // so if config file doesnt exist, it is uptodate. - return !fileExists(resolveProjectReferencePath(oldRef)); + var refPath = resolveProjectReferencePath(oldRef); + return !getParsedCommandLine(refPath); } } ts.isProgramUptoDate = isProgramUptoDate; @@ -106212,10 +109894,7 @@ var ts; return false; // If any compiler options change, we can't reuse old source file even if version match // The change in options like these could result in change in syntax tree or `sourceFile.bindDiagnostics`. - var oldOptions = program.getCompilerOptions(); - return !!ts.sourceFileAffectingCompilerOptions.some(function (option) { - return !ts.isJsonEqual(ts.getCompilerOptionValue(oldOptions, option), ts.getCompilerOptionValue(newOptions, option)); - }); + return ts.optionsHaveChanges(program.getCompilerOptions(), newOptions, ts.sourceFileAffectingCompilerOptions); } function createCreateProgramOptions(rootNames, options, host, oldProgram, configFileParsingDiagnostics) { return { @@ -106259,7 +109938,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.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" /* Program */, "createProgram", { configFilePath: options.configFilePath, rootDir: options.rootDir }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeProgram"); var host = createProgramOptions.host || createCompilerHost(options); var configParsingHost = parseConfigHostFromCompilerHostLike(host); @@ -106274,6 +109953,7 @@ var ts; var hasEmitBlockingDiagnostics = new ts.Map(); var _compilerOptionsObjectLiteralSyntax; var moduleResolutionCache; + var typeReferenceDirectiveResolutionCache; var actualResolveModuleNamesWorker; var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse; if (host.resolveModuleNames) { @@ -106288,7 +109968,7 @@ var ts; }); }; } else { - moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, function (x) { return host.getCanonicalFileName(x); }, options); + moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName, options); var loader_1 = function (moduleName, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache, redirectedReference).resolvedModule; }; // TODO: GH#18217 actualResolveModuleNamesWorker = function (moduleNames, containingFile, _reusedNames, redirectedReference) { return loadWithLocalCache(ts.Debug.checkEachDefined(moduleNames), containingFile, redirectedReference, loader_1); }; } @@ -106297,7 +109977,8 @@ var ts; actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options); }; } else { - var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference).resolvedTypeReferenceDirective; }; // TODO: GH#18217 + typeReferenceDirectiveResolutionCache = ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, /*options*/ undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache()); + var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache).resolvedTypeReferenceDirective; }; // TODO: GH#18217 actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { return loadWithLocalCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, loader_2); }; } // Map from a stringified PackageId to the source file with that id. @@ -106335,15 +110016,15 @@ var ts; getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect, forEachResolvedProjectReference: forEachResolvedProjectReference }), onProgramCreateComplete = _d.onProgramCreateComplete, fileExists = _d.fileExists, directoryExists = _d.directoryExists; - ts.tracing.push("program" /* Program */, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram }); var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options); - ts.tracing.pop(); + 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.push("program" /* Program */, "tryReuseStructureFromOldProgram", {}); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "tryReuseStructureFromOldProgram", {}); structureIsReused = tryReuseStructureFromOldProgram(); // eslint-disable-line prefer-const - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); if (structureIsReused !== 2 /* Completely */) { processingDefaultLibFiles = []; processingOtherFiles = []; @@ -106381,13 +110062,13 @@ var ts; }); } } - ts.tracing.push("program" /* Program */, "processRootFiles", { count: rootNames.length }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* 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.pop(); + 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.push("program" /* Program */, "processTypeReferences", { count: typeReferences.length }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* 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); @@ -106395,7 +110076,7 @@ var ts; for (var i = 0; i < typeReferences.length; i++) { processTypeReferenceDirective(typeReferences[i], resolutions[i], { kind: ts.FileIncludeKind.AutomaticTypeDirectiveFile, typeReference: typeReferences[i], packageId: (_b = resolutions[i]) === null || _b === void 0 ? void 0 : _b.packageId }); } - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } // Do not process the default library if: // - The '--noLib' flag is used. @@ -106436,12 +110117,25 @@ var ts; host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path)); } } - oldProgram.forEachResolvedProjectReference(function (resolvedProjectReference) { - if (!getResolvedProjectReferenceByPath(resolvedProjectReference.sourceFile.path)) { - host.onReleaseOldSourceFile(resolvedProjectReference.sourceFile, oldProgram.getCompilerOptions(), /*hasSourceFileByPath*/ false); + if (!host.getParsedCommandLine) { + oldProgram.forEachResolvedProjectReference(function (resolvedProjectReference) { + if (!getResolvedProjectReferenceByPath(resolvedProjectReference.sourceFile.path)) { + host.onReleaseOldSourceFile(resolvedProjectReference.sourceFile, oldProgram.getCompilerOptions(), /*hasSourceFileByPath*/ false); + } + }); + } + } + // Release commandlines that new program does not use + if (oldProgram && host.onReleaseParsedCommandLine) { + forEachProjectReference(oldProgram.getProjectReferences(), oldProgram.getResolvedProjectReferences(), function (oldResolvedRef, parent, index) { + var oldReference = (parent === null || parent === void 0 ? void 0 : parent.commandLine.projectReferences[index]) || oldProgram.getProjectReferences()[index]; + var oldRefPath = resolveProjectReferencePath(oldReference); + if (!(projectReferenceRedirects === null || projectReferenceRedirects === void 0 ? void 0 : projectReferenceRedirects.has(toPath(oldRefPath)))) { + host.onReleaseParsedCommandLine(oldRefPath, oldResolvedRef, oldProgram.getCompilerOptions()); } }); } + typeReferenceDirectiveResolutionCache = undefined; // unconditionally set oldProgram to undefined to prevent it from being captured in closure oldProgram = undefined; var program = { @@ -106470,7 +110164,6 @@ var ts; getNodeCount: function () { return getDiagnosticsProducingTypeChecker().getNodeCount(); }, getIdentifierCount: function () { return getDiagnosticsProducingTypeChecker().getIdentifierCount(); }, getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); }, - getTypeCatalog: function () { return getDiagnosticsProducingTypeChecker().getTypeCatalog(); }, getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); }, getInstantiationCount: function () { return getDiagnosticsProducingTypeChecker().getInstantiationCount(); }, getRelationCacheSizes: function () { return getDiagnosticsProducingTypeChecker().getRelationCacheSizes(); }, @@ -106518,19 +110211,19 @@ var ts; verifyCompilerOptions(); ts.performance.mark("afterProgram"); ts.performance.measure("Program", "beforeProgram", "afterProgram"); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return program; function resolveModuleNamesWorker(moduleNames, containingFile, reusedNames) { if (!moduleNames.length) return ts.emptyArray; var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory); var redirectedReference = getRedirectReferenceForResolution(containingFile); - ts.tracing.push("program" /* Program */, "resolveModuleNamesWorker", { containingFileName: containingFileName }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveModuleNamesWorker", { containingFileName: containingFileName }); ts.performance.mark("beforeResolveModule"); var result = actualResolveModuleNamesWorker(moduleNames, containingFileName, reusedNames, redirectedReference); ts.performance.mark("afterResolveModule"); ts.performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule"); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; } function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile) { @@ -106538,12 +110231,12 @@ var ts; return []; var containingFileName = !ts.isString(containingFile) ? ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile; var redirectedReference = !ts.isString(containingFile) ? getRedirectReferenceForResolution(containingFile) : undefined; - ts.tracing.push("program" /* Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName }); ts.performance.mark("beforeResolveTypeReference"); var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference); ts.performance.mark("afterResolveTypeReference"); ts.performance.measure("ResolveTypeReference", "beforeResolveTypeReference", "afterResolveTypeReference"); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; } function getRedirectReferenceForResolution(file) { @@ -106670,7 +110363,9 @@ var ts; var oldResolvedModule = ts.getResolvedModule(oldSourceFile, moduleName); if (oldResolvedModule) { if (ts.isTraceEnabled(options, host)) { - ts.trace(host, ts.Diagnostics.Reusing_resolution_of_module_0_to_file_1_from_old_program, moduleName, ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory)); + ts.trace(host, oldResolvedModule.packageId ? + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 : + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2, moduleName, ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory), oldResolvedModule.resolvedFileName, oldResolvedModule.packageId && ts.packageIdToString(oldResolvedModule.packageId)); } (result || (result = new Array(moduleNames.length)))[i] = oldResolvedModule; (reusedNames || (reusedNames = [])).push(moduleName); @@ -106753,7 +110448,9 @@ var ts; var newResolvedRef = parseProjectReferenceConfigFile(newRef); if (oldResolvedRef) { // Resolved project reference has gone missing or changed - return !newResolvedRef || newResolvedRef.sourceFile !== oldResolvedRef.sourceFile; + return !newResolvedRef || + newResolvedRef.sourceFile !== oldResolvedRef.sourceFile || + !ts.arrayIsEqualTo(oldResolvedRef.commandLine.fileNames, newResolvedRef.commandLine.fileNames); } else { // A previously-unresolved reference may be resolved now @@ -106781,9 +110478,6 @@ var ts; if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) { return 0 /* Not */; } - if (!ts.arrayIsEqualTo(options.types, oldOptions.types)) { - return 0 /* Not */; - } // Check if any referenced project tsconfig files are different if (!canReuseProjectReferences()) { return 0 /* Not */; @@ -106858,7 +110552,7 @@ var ts; // The `newSourceFile` object was created for the new program. if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) { // 'lib' references has changed. Matches behavior in changesAffectModuleResolution - return 0 /* Not */; + structureIsReused = 1 /* SafeModules */; } if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { // value of no-default-lib has changed @@ -106943,7 +110637,7 @@ var ts; if (structureIsReused !== 2 /* Completely */) { return structureIsReused; } - if ((_a = host.hasChangedAutomaticTypeDirectiveNames) === null || _a === void 0 ? void 0 : _a.call(host)) { + if (ts.changesAffectingProgramStructure(oldOptions, options) || ((_a = host.hasChangedAutomaticTypeDirectiveNames) === null || _a === void 0 ? void 0 : _a.call(host))) { return 1 /* SafeModules */; } missingFilePaths = oldProgram.getMissingFilePaths(); @@ -107015,7 +110709,7 @@ var ts; } function emitBuildInfo(writeFileCallback) { ts.Debug.assert(!ts.outFile(options)); - ts.tracing.push("emit" /* Emit */, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeEmit"); var emitResult = ts.emitFiles(ts.notImplementedResolver, getEmitHost(writeFileCallback), /*targetSourceFile*/ undefined, @@ -107024,7 +110718,7 @@ var ts; /*onlyBuildInfo*/ true); ts.performance.mark("afterEmit"); ts.performance.measure("Emit", "beforeEmit", "afterEmit"); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return emitResult; } function getResolvedProjectReferences() { @@ -107070,9 +110764,9 @@ var ts; return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ false)); } function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) { - 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" /* 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.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; } function isEmitBlocked(emitFileName) { @@ -107276,22 +110970,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 160 /* Parameter */: - case 163 /* PropertyDeclaration */: - case 165 /* MethodDeclaration */: + case 162 /* Parameter */: + case 165 /* PropertyDeclaration */: + case 167 /* 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 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: - case 209 /* ArrowFunction */: - case 249 /* VariableDeclaration */: + case 166 /* MethodSignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 210 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 211 /* ArrowFunction */: + case 251 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files)); @@ -107299,58 +110993,58 @@ var ts; } } switch (node.kind) { - case 262 /* ImportClause */: + case 264 /* 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 267 /* ExportDeclaration */: + case 269 /* 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 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_TypeScript_files)); return "skip"; - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 286 /* HeritageClause */: + case 288 /* HeritageClause */: var heritageClause = node; - if (heritageClause.token === 116 /* ImplementsKeyword */) { + if (heritageClause.token === 117 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 253 /* InterfaceDeclaration */: - var interfaceKeyword = ts.tokenToString(117 /* InterfaceKeyword */); + case 255 /* InterfaceDeclaration */: + var interfaceKeyword = ts.tokenToString(118 /* InterfaceKeyword */); ts.Debug.assertIsDefined(interfaceKeyword); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, interfaceKeyword)); return "skip"; - case 256 /* ModuleDeclaration */: - var moduleKeyword = node.flags & 16 /* Namespace */ ? ts.tokenToString(140 /* NamespaceKeyword */) : ts.tokenToString(139 /* ModuleKeyword */); + case 258 /* ModuleDeclaration */: + var moduleKeyword = node.flags & 16 /* Namespace */ ? ts.tokenToString(141 /* NamespaceKeyword */) : ts.tokenToString(140 /* ModuleKeyword */); ts.Debug.assertIsDefined(moduleKeyword); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, moduleKeyword)); return "skip"; - case 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_aliases_can_only_be_used_in_TypeScript_files)); return "skip"; - case 255 /* EnumDeclaration */: - var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(91 /* EnumKeyword */)); + case 257 /* EnumDeclaration */: + var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(92 /* EnumKeyword */)); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, enumKeyword)); return "skip"; - case 225 /* NonNullExpression */: + case 227 /* NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Non_null_assertions_can_only_be_used_in_TypeScript_files)); return "skip"; - case 224 /* AsExpression */: + case 226 /* AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.Type_assertion_expressions_can_only_be_used_in_TypeScript_files)); return "skip"; - case 206 /* TypeAssertionExpression */: + case 208 /* TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } } @@ -107359,53 +111053,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 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: - case 209 /* ArrowFunction */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 167 /* MethodDeclaration */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 210 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 211 /* 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 232 /* VariableStatement */: + case 234 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - checkModifiers(parent.modifiers, parent.kind === 232 /* VariableStatement */); + checkModifiers(parent.modifiers, parent.kind === 234 /* VariableStatement */); return "skip"; } break; - case 163 /* PropertyDeclaration */: + case 165 /* 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 (modifier.kind !== 123 /* StaticKeyword */) { + if (modifier.kind !== 124 /* 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 160 /* Parameter */: + case 162 /* Parameter */: // Check modifiers of parameter declaration if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Parameter_modifiers_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 203 /* CallExpression */: - case 204 /* NewExpression */: - case 223 /* ExpressionWithTypeArguments */: - case 274 /* JsxSelfClosingElement */: - case 275 /* JsxOpeningElement */: - case 205 /* TaggedTemplateExpression */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: + case 225 /* ExpressionWithTypeArguments */: + case 276 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: + case 207 /* TaggedTemplateExpression */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_arguments_can_only_be_used_in_TypeScript_files)); @@ -107418,24 +111112,25 @@ var ts; for (var _i = 0, modifiers_2 = modifiers; _i < modifiers_2.length; _i++) { var modifier = modifiers_2[_i]; switch (modifier.kind) { - case 84 /* ConstKeyword */: + case 85 /* ConstKeyword */: if (isConstValid) { continue; } // to report error, // falls through - case 122 /* PublicKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 142 /* ReadonlyKeyword */: - case 133 /* DeclareKeyword */: - case 125 /* AbstractKeyword */: + case 123 /* PublicKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + case 143 /* ReadonlyKeyword */: + case 134 /* DeclareKeyword */: + case 126 /* AbstractKeyword */: + case 157 /* OverrideKeyword */: 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 123 /* StaticKeyword */: - case 92 /* ExportKeyword */: - case 87 /* DefaultKeyword */: + case 124 /* StaticKeyword */: + case 93 /* ExportKeyword */: + case 88 /* DefaultKeyword */: } } } @@ -107506,8 +111201,8 @@ var ts; return a.fileName === b.fileName; } function moduleNameIsEqualTo(a, b) { - return a.kind === 78 /* Identifier */ - ? b.kind === 78 /* Identifier */ && a.escapedText === b.escapedText + return a.kind === 79 /* Identifier */ + ? b.kind === 79 /* Identifier */ && a.escapedText === b.escapedText : b.kind === 10 /* StringLiteral */ && a.text === b.text; } function createSyntheticImport(text, file) { @@ -107733,13 +111428,13 @@ var ts; } // Get source file from normalized fileName function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, reason, packageId) { - ts.tracing.push("program" /* Program */, "findSourceFile", { + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "findSourceFile", { fileName: fileName, isDefaultLib: isDefaultLib || undefined, fileIncludeKind: ts.FileIncludeKind[reason.kind], }); var result = findSourceFileWorker(fileName, path, isDefaultLib, ignoreNoDefaultLib, reason, packageId); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; } function findSourceFileWorker(fileName, path, isDefaultLib, ignoreNoDefaultLib, reason, packageId) { @@ -107998,9 +111693,9 @@ var ts; } } function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, reason) { - 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" /* Program */, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolveModuleNamesReusingOldState, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined }); processTypeReferenceDirectiveWorker(typeReferenceDirective, resolvedTypeReferenceDirective, reason); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } function processTypeReferenceDirectiveWorker(typeReferenceDirective, resolvedTypeReferenceDirective, reason) { // If we already found this library as a primary reference - nothing to do @@ -108071,12 +111766,14 @@ var ts; return host.getCanonicalFileName(fileName); } function processImportedModules(file) { + var _a; collectExternalModuleReferences(file); if (file.imports.length || file.moduleAugmentations.length) { // Because global augmentation doesn't have string literal name, we can check for global augmentation as such. var moduleNames = getModuleNames(file); var resolutions = resolveModuleNamesReusingOldState(moduleNames, file); ts.Debug.assert(resolutions.length === moduleNames.length); + var optionsForFile = (useSourceOfProjectReferenceRedirect ? (_a = getRedirectReferenceForResolution(file)) === null || _a === void 0 ? void 0 : _a.commandLine.options : undefined) || options; for (var index = 0; index < moduleNames.length; index++) { var resolution = resolutions[index]; ts.setResolvedModule(file, moduleNames[index], resolution); @@ -108099,11 +111796,11 @@ var ts; // Don't add the file if it has a bad extension (e.g. 'tsx' if we don't have '--allowJs') // This may still end up being an untyped module -- the file won't be included but imports will be allowed. var shouldAddFile = resolvedFileName - && !getResolutionDiagnostic(options, resolution) - && !options.noResolve + && !getResolutionDiagnostic(optionsForFile, resolution) + && !optionsForFile.noResolve && index < file.imports.length && !elideImport - && !(isJsFile && !ts.getAllowJSCompilerOption(options)) + && !(isJsFile && !ts.getAllowJSCompilerOption(optionsForFile)) && (ts.isInJSFile(file.imports[index]) || !(file.imports[index].flags & 4194304 /* JSDoc */)); if (elideImport) { modulesWithElidedImports.set(file.path, true); @@ -108189,6 +111886,9 @@ var ts; if (options.strictPropertyInitialization && !ts.getStrictOptionValue(options, "strictNullChecks")) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictPropertyInitialization", "strictNullChecks"); } + if (options.strictOptionalProperties && !ts.getStrictOptionValue(options, "strictNullChecks")) { + createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictOptionalProperties", "strictNullChecks"); + } if (options.isolatedModules) { if (options.out) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules"); @@ -108306,6 +112006,9 @@ var ts; if (options.module === ts.ModuleKind.None && languageVersion < 2 /* 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 */; }); if (firstNonExternalModuleSourceFile) { var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); @@ -108336,9 +112039,10 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Option_resolveJsonModule_can_only_be_specified_when_module_code_generation_is_commonjs_amd_es2015_or_esNext, "resolveJsonModule", "module"); } } - // there has to be common source directory if user specified --outdir || --sourceRoot + // there has to be common source directory if user specified --outdir || --rootDir || --sourceRoot // if user specified --mapRoot, there needs to be common source directory if there would be multiple files being emitted if (options.outDir || // there is --outDir specified + options.rootDir || // there is --rootDir specified options.sourceRoot || // there is --sourceRoot specified options.mapRoot) { // there is --mapRoot specified // Precalculate and cache the common source directory @@ -108835,7 +112539,7 @@ var ts; } function handleDirectoryCouldBeSymlink(directory) { var _a; - if (!host.getResolvedProjectReferences()) + if (!host.getResolvedProjectReferences() || ts.containsIgnoredPath(directory)) return; // Because we already watch node_modules, handle symlinks in there if (!originalRealpath || !ts.stringContains(directory, ts.nodeModulesPathPart)) @@ -108852,7 +112556,7 @@ var ts; symlinkCache.setSymlinkedDirectory(directoryPath, false); return; } - symlinkCache.setSymlinkedDirectory(directoryPath, { + symlinkCache.setSymlinkedDirectory(directory, { real: ts.ensureTrailingDirectorySeparator(real), realPath: realPath }); @@ -109128,12 +112832,15 @@ var ts; // From ambient modules for (var _f = 0, _g = program.getTypeChecker().getAmbientModules(); _f < _g.length; _f++) { var ambientModule = _g[_f]; - if (ambientModule.declarations.length > 1) { + if (ambientModule.declarations && ambientModule.declarations.length > 1) { addReferenceFromAmbientModule(ambientModule); } } return referencedFiles; function addReferenceFromAmbientModule(symbol) { + if (!symbol.declarations) { + return; + } // Add any file other than our own as reference for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; @@ -109158,7 +112865,7 @@ var ts; /** * Creates the state of file references and signature for the new program from oldState if it is safe */ - function create(newProgram, getCanonicalFileName, oldState) { + function create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) { var fileInfos = new ts.Map(); var referencedMap = newProgram.getCompilerOptions().module !== ts.ModuleKind.None ? new ts.Map() : undefined; var exportedModulesMap = referencedMap ? new ts.Map() : undefined; @@ -109184,13 +112891,14 @@ var ts; } } } - fileInfos.set(sourceFile.resolvedPath, { version: version_2, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) }); + fileInfos.set(sourceFile.resolvedPath, { version: version_2, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) || undefined }); } return { fileInfos: fileInfos, referencedMap: referencedMap, exportedModulesMap: exportedModulesMap, - hasCalledUpdateShapeSignature: hasCalledUpdateShapeSignature + hasCalledUpdateShapeSignature: hasCalledUpdateShapeSignature, + useFileVersionAsSignature: !disableUseFileVersionAsSignature && !useOldState }; } BuilderState.create = create; @@ -109212,6 +112920,7 @@ var ts; referencedMap: state.referencedMap && new ts.Map(state.referencedMap), exportedModulesMap: state.exportedModulesMap && new ts.Map(state.exportedModulesMap), hasCalledUpdateShapeSignature: new ts.Set(state.hasCalledUpdateShapeSignature), + useFileVersionAsSignature: state.useFileVersionAsSignature, }; } BuilderState.clone = clone; @@ -109267,23 +112976,12 @@ var ts; return ts.Debug.fail(); var prevSignature = info.signature; var latestSignature; - if (sourceFile.isDeclarationFile) { - latestSignature = sourceFile.version; - if (exportedModulesMapCache && latestSignature !== prevSignature) { - // All the references in this file are exported - var references = state.referencedMap ? state.referencedMap.get(sourceFile.resolvedPath) : undefined; - exportedModulesMapCache.set(sourceFile.resolvedPath, references || false); - } - } - else { + if (!sourceFile.isDeclarationFile && !state.useFileVersionAsSignature) { var emitOutput_1 = getFileEmitOutput(programOfThisState, sourceFile, /*emitOnlyDtsFiles*/ true, cancellationToken, /*customTransformers*/ undefined, /*forceDtsEmit*/ true); - var firstDts_1 = emitOutput_1.outputFiles && - programOfThisState.getCompilerOptions().declarationMap ? - emitOutput_1.outputFiles.length > 1 ? emitOutput_1.outputFiles[1] : undefined : - emitOutput_1.outputFiles.length > 0 ? emitOutput_1.outputFiles[0] : undefined; + var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles); if (firstDts_1) { ts.Debug.assert(ts.fileExtensionIs(firstDts_1.name, ".d.ts" /* Dts */), "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 = (computeHash || ts.generateDjb2Hash)(firstDts_1.text); @@ -109291,12 +112989,18 @@ var ts; updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache); } } - else { - latestSignature = prevSignature; // TODO: GH#18217 + } + // Default is to use file version as signature + if (latestSignature === undefined) { + latestSignature = sourceFile.version; + if (exportedModulesMapCache && latestSignature !== prevSignature) { + // All the references in this file are exported + var references = state.referencedMap ? state.referencedMap.get(sourceFile.resolvedPath) : undefined; + exportedModulesMapCache.set(sourceFile.resolvedPath, references || false); } } cacheToUpdateSignature.set(sourceFile.resolvedPath, latestSignature); - return !prevSignature || latestSignature !== prevSignature; + return latestSignature !== prevSignature; } BuilderState.updateShapeSignature = updateShapeSignature; /** @@ -109416,7 +113120,7 @@ var ts; */ function isFileAffectingGlobalScope(sourceFile) { return containsGlobalScopeAugmentation(sourceFile) || - !ts.isExternalModule(sourceFile) && !containsOnlyAmbientModules(sourceFile); + !ts.isExternalOrCommonJsModule(sourceFile) && !containsOnlyAmbientModules(sourceFile); } /** * Gets all files of the program excluding the default library file @@ -109504,8 +113208,8 @@ var ts; /** * Create the state so that we can iterate on changedFiles/affected files */ - function createBuilderProgramState(newProgram, getCanonicalFileName, oldState) { - var state = ts.BuilderState.create(newProgram, getCanonicalFileName, oldState); + function createBuilderProgramState(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) { + var state = ts.BuilderState.create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature); state.program = newProgram; var compilerOptions = newProgram.getCompilerOptions(); state.compilerOptions = compilerOptions; @@ -109743,6 +113447,7 @@ var ts; * 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) { + var _a; removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath); // If affected files is everything except default library, then nothing more to do if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) { @@ -109756,8 +113461,15 @@ var ts; removeSemanticDiagnosticsOf(state, f.resolvedPath); }); } + // 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, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap); return; } + else { + ts.Debug.assert(state.hasCalledUpdateShapeSignature.has(affectedFile.resolvedPath) || ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.has(affectedFile.resolvedPath)), "Signature not updated for affected file: " + affectedFile.fileName); + } if (!state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) { forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash); }); } @@ -109969,83 +113681,116 @@ var ts; return undefined; var currentDirectory = ts.Debug.checkDefined(state.program).getCurrentDirectory(); var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory)); - var fileInfos = {}; - state.fileInfos.forEach(function (value, key) { + var fileNames = []; + var fileNameToFileId = new ts.Map(); + var fileIdsList; + var fileNamesToFileIdListId; + var fileInfos = ts.arrayFrom(state.fileInfos.entries(), function (_a) { + var key = _a[0], value = _a[1]; + // Ensure fileId + var fileId = toFileId(key); + ts.Debug.assert(fileNames[fileId - 1] === relativeToBuildInfo(key)); var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key); - fileInfos[relativeToBuildInfo(key)] = signature === undefined ? value : { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope }; + var actualSignature = signature !== null && signature !== void 0 ? signature : value.signature; + return value.version === actualSignature ? + value.affectsGlobalScope ? + { version: value.version, signature: undefined, affectsGlobalScope: true } : + value.version : + actualSignature !== undefined ? + signature === undefined ? + value : + { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope } : + { version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope }; }); - var result = { - fileInfos: fileInfos, - options: convertToReusableCompilerOptions(state.compilerOptions, relativeToBuildInfoEnsuringAbsolutePath) - }; + var referencedMap; if (state.referencedMap) { - var referencedMap = {}; - for (var _i = 0, _a = ts.arrayFrom(state.referencedMap.keys()).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) { - var key = _a[_i]; - referencedMap[relativeToBuildInfo(key)] = ts.arrayFrom(state.referencedMap.get(key).keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive); - } - result.referencedMap = referencedMap; + referencedMap = ts.arrayFrom(state.referencedMap.keys()).sort(ts.compareStringsCaseSensitive).map(function (key) { return [ + toFileId(key), + toFileIdListId(state.referencedMap.get(key)) + ]; }); } + var exportedModulesMap; if (state.exportedModulesMap) { - var exportedModulesMap = {}; - for (var _b = 0, _c = ts.arrayFrom(state.exportedModulesMap.keys()).sort(ts.compareStringsCaseSensitive); _b < _c.length; _b++) { - var key = _c[_b]; + exportedModulesMap = ts.mapDefined(ts.arrayFrom(state.exportedModulesMap.keys()).sort(ts.compareStringsCaseSensitive), function (key) { var newValue = state.currentAffectedFilesExportedModulesMap && state.currentAffectedFilesExportedModulesMap.get(key); // Not in temporary cache, use existing value if (newValue === undefined) - exportedModulesMap[relativeToBuildInfo(key)] = ts.arrayFrom(state.exportedModulesMap.get(key).keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive); + return [toFileId(key), toFileIdListId(state.exportedModulesMap.get(key))]; // Value in cache and has updated value map, use that else if (newValue) - exportedModulesMap[relativeToBuildInfo(key)] = ts.arrayFrom(newValue.keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive); - } - result.exportedModulesMap = exportedModulesMap; + return [toFileId(key), toFileIdListId(newValue)]; + }); } + var semanticDiagnosticsPerFile; if (state.semanticDiagnosticsPerFile) { - var semanticDiagnosticsPerFile = []; - for (var _d = 0, _e = ts.arrayFrom(state.semanticDiagnosticsPerFile.keys()).sort(ts.compareStringsCaseSensitive); _d < _e.length; _d++) { - var key = _e[_d]; + for (var _i = 0, _a = ts.arrayFrom(state.semanticDiagnosticsPerFile.keys()).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) { + var key = _a[_i]; var value = state.semanticDiagnosticsPerFile.get(key); - semanticDiagnosticsPerFile.push(value.length ? + (semanticDiagnosticsPerFile || (semanticDiagnosticsPerFile = [])).push(value.length ? [ - relativeToBuildInfo(key), + toFileId(key), state.hasReusableDiagnostic ? value : convertToReusableDiagnostics(value, relativeToBuildInfo) ] : - relativeToBuildInfo(key)); + toFileId(key)); } - result.semanticDiagnosticsPerFile = semanticDiagnosticsPerFile; } + var affectedFilesPendingEmit; if (state.affectedFilesPendingEmit) { - var affectedFilesPendingEmit = []; var seenFiles = new ts.Set(); - for (var _f = 0, _g = state.affectedFilesPendingEmit.slice(state.affectedFilesPendingEmitIndex).sort(ts.compareStringsCaseSensitive); _f < _g.length; _f++) { - var path = _g[_f]; + for (var _b = 0, _c = state.affectedFilesPendingEmit.slice(state.affectedFilesPendingEmitIndex).sort(ts.compareStringsCaseSensitive); _b < _c.length; _b++) { + var path = _c[_b]; if (ts.tryAddToSet(seenFiles, path)) { - affectedFilesPendingEmit.push([relativeToBuildInfo(path), state.affectedFilesPendingEmitKind.get(path)]); + (affectedFilesPendingEmit || (affectedFilesPendingEmit = [])).push([toFileId(path), state.affectedFilesPendingEmitKind.get(path)]); } } - result.affectedFilesPendingEmit = affectedFilesPendingEmit; } - return result; + return { + fileNames: fileNames, + fileInfos: fileInfos, + options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, relativeToBuildInfoEnsuringAbsolutePath), + fileIdsList: fileIdsList, + referencedMap: referencedMap, + exportedModulesMap: exportedModulesMap, + semanticDiagnosticsPerFile: semanticDiagnosticsPerFile, + affectedFilesPendingEmit: affectedFilesPendingEmit, + }; function relativeToBuildInfoEnsuringAbsolutePath(path) { return relativeToBuildInfo(ts.getNormalizedAbsolutePath(path, currentDirectory)); } function relativeToBuildInfo(path) { return ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(buildInfoDirectory, path, getCanonicalFileName)); } + function toFileId(path) { + var fileId = fileNameToFileId.get(path); + if (fileId === undefined) { + fileNames.push(relativeToBuildInfo(path)); + fileNameToFileId.set(path, fileId = fileNames.length); + } + return fileId; + } + function toFileIdListId(set) { + var fileIds = ts.arrayFrom(set.keys(), toFileId).sort(ts.compareValues); + var key = fileIds.join(); + var fileIdListId = fileNamesToFileIdListId === null || fileNamesToFileIdListId === void 0 ? void 0 : fileNamesToFileIdListId.get(key); + if (fileIdListId === undefined) { + (fileIdsList || (fileIdsList = [])).push(fileIds); + (fileNamesToFileIdListId || (fileNamesToFileIdListId = new ts.Map())).set(key, fileIdListId = fileIdsList.length); + } + return fileIdListId; + } } - function convertToReusableCompilerOptions(options, relativeToBuildInfo) { - var result = {}; + function convertToProgramBuildInfoCompilerOptions(options, relativeToBuildInfo) { + var result; var optionsNameMap = ts.getOptionsNameMap().optionsNameMap; - for (var name in options) { - if (ts.hasProperty(options, name)) { - result[name] = convertToReusableCompilerOptionValue(optionsNameMap.get(name.toLowerCase()), options[name], relativeToBuildInfo); + for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) { + var name = _a[_i]; + var optionInfo = optionsNameMap.get(name.toLowerCase()); + if ((optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsEmit) || (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsSemanticDiagnostics) || name === "skipLibCheck" || name === "skipDefaultLibCheck") { + (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfo); } } - if (result.configFilePath) { - result.configFilePath = relativeToBuildInfo(result.configFilePath); - } return result; } function convertToReusableCompilerOptionValue(option, value, relativeToBuildInfo) { @@ -110137,15 +113882,16 @@ var ts; * Computing hash to for signature verification */ var computeHash = ts.maybeBind(host, host.createHash); - var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState); + var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState, host.disableUseFileVersionAsSignature); var backupState; 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; oldState = undefined; - var builderProgram = createRedirectedBuilderProgram(state, configFileParsingDiagnostics); - builderProgram.getState = function () { return state; }; + var getState = function () { return state; }; + var builderProgram = createRedirectedBuilderProgram(getState, configFileParsingDiagnostics); + builderProgram.getState = getState; builderProgram.backupState = function () { ts.Debug.assert(backupState === undefined); backupState = cloneBuilderProgramState(state); @@ -110361,37 +114107,31 @@ var ts; state.affectedFilesPendingEmitIndex = 0; } } - function getMapOfReferencedSet(mapLike, toPath) { - if (!mapLike) - return undefined; - var map = new ts.Map(); - // Copies keys/values from template. Note that for..in will not throw if - // template is undefined, and instead will just exit the loop. - for (var key in mapLike) { - if (ts.hasProperty(mapLike, key)) { - map.set(toPath(key), new ts.Set(mapLike[key].map(toPath))); - } - } - return map; + function toBuilderStateFileInfo(fileInfo) { + return ts.isString(fileInfo) ? + { version: fileInfo, signature: fileInfo, affectsGlobalScope: undefined } : + ts.isString(fileInfo.signature) ? + fileInfo : + { version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope }; } + ts.toBuilderStateFileInfo = toBuilderStateFileInfo; function createBuildProgramUsingProgramBuildInfo(program, buildInfoPath, host) { + var _a; var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory())); var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames()); + var filePaths = program.fileNames.map(toPath); + var filePathsSetList = (_a = program.fileIdsList) === null || _a === void 0 ? void 0 : _a.map(function (fileIds) { return new ts.Set(fileIds.map(toFilePath)); }); var fileInfos = new ts.Map(); - for (var key in program.fileInfos) { - if (ts.hasProperty(program.fileInfos, key)) { - fileInfos.set(toPath(key), program.fileInfos[key]); - } - } + program.fileInfos.forEach(function (fileInfo, index) { return fileInfos.set(toFilePath(index + 1), toBuilderStateFileInfo(fileInfo)); }); var state = { fileInfos: fileInfos, - compilerOptions: ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath), - referencedMap: getMapOfReferencedSet(program.referencedMap, toPath), - exportedModulesMap: getMapOfReferencedSet(program.exportedModulesMap, toPath), - semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, function (value) { return toPath(ts.isString(value) ? value : value[0]); }, function (value) { return ts.isString(value) ? ts.emptyArray : value[1]; }), + compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {}, + referencedMap: toMapOfReferencedSet(program.referencedMap), + exportedModulesMap: toMapOfReferencedSet(program.exportedModulesMap), + semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, function (value) { return toFilePath(ts.isNumber(value) ? value : value[0]); }, function (value) { return ts.isNumber(value) ? ts.emptyArray : value[1]; }), hasReusableDiagnostic: true, - affectedFilesPendingEmit: ts.map(program.affectedFilesPendingEmit, function (value) { return toPath(value[0]); }), - affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toPath(value[0]); }, function (value) { return value[1]; }), + affectedFilesPendingEmit: ts.map(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }), + affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }, function (value) { return value[1]; }), affectedFilesPendingEmitIndex: program.affectedFilesPendingEmit && 0, }; return { @@ -110424,17 +114164,26 @@ var ts; function toAbsolutePath(path) { return ts.getNormalizedAbsolutePath(path, buildInfoDirectory); } + function toFilePath(fileId) { + return filePaths[fileId - 1]; + } + function toFilePathsSet(fileIdsListId) { + return filePathsSetList[fileIdsListId - 1]; + } + function toMapOfReferencedSet(referenceMap) { + return referenceMap && ts.arrayToMap(referenceMap, function (value) { return toFilePath(value[0]); }, function (value) { return toFilePathsSet(value[1]); }); + } } ts.createBuildProgramUsingProgramBuildInfo = createBuildProgramUsingProgramBuildInfo; - function createRedirectedBuilderProgram(state, configFileParsingDiagnostics) { + function createRedirectedBuilderProgram(getState, configFileParsingDiagnostics) { return { getState: ts.notImplemented, backupState: ts.noop, restoreState: ts.noop, getProgram: getProgram, - getProgramOrUndefined: function () { return state.program; }, - releaseProgram: function () { return state.program = undefined; }, - getCompilerOptions: function () { return state.compilerOptions; }, + getProgramOrUndefined: function () { return getState().program; }, + releaseProgram: function () { return getState().program = undefined; }, + getCompilerOptions: function () { return getState().compilerOptions; }, getSourceFile: function (fileName) { return getProgram().getSourceFile(fileName); }, getSourceFiles: function () { return getProgram().getSourceFiles(); }, getOptionsDiagnostics: function (cancellationToken) { return getProgram().getOptionsDiagnostics(cancellationToken); }, @@ -110450,7 +114199,7 @@ var ts; close: ts.noop, }; function getProgram() { - return ts.Debug.checkDefined(state.program); + return ts.Debug.checkDefined(getState().program); } } ts.createRedirectedBuilderProgram = createRedirectedBuilderProgram; @@ -110467,7 +114216,7 @@ var ts; ts.createEmitAndSemanticDiagnosticsBuilderProgram = createEmitAndSemanticDiagnosticsBuilderProgram; function createAbstractBuilder(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences) { var _a = ts.getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences), newProgram = _a.newProgram, newConfigFileParsingDiagnostics = _a.configFileParsingDiagnostics; - return ts.createRedirectedBuilderProgram({ program: newProgram, compilerOptions: newProgram.getCompilerOptions() }, newConfigFileParsingDiagnostics); + return ts.createRedirectedBuilderProgram(function () { return ({ program: newProgram, compilerOptions: newProgram.getCompilerOptions() }); }, newConfigFileParsingDiagnostics); } ts.createAbstractBuilder = createAbstractBuilder; })(ts || (ts = {})); @@ -110536,9 +114285,9 @@ var ts; var resolutionsWithFailedLookups = []; var resolvedFileToResolution = ts.createMultiMap(); var hasChangedAutomaticTypeDirectiveNames = false; - var failedLookupChecks = []; - var startsWithPathChecks = []; - var isInDirectoryChecks = []; + var failedLookupChecks; + var startsWithPathChecks; + var isInDirectoryChecks; var getCurrentDirectory = ts.memoize(function () { return resolutionHost.getCurrentDirectory(); }); // TODO: GH#18217 var cachedDirectoryStructureHost = resolutionHost.getCachedDirectoryStructureHost(); // The resolvedModuleNames and resolvedTypeReferenceDirectives are the cache of resolutions per file. @@ -110547,9 +114296,12 @@ var ts; var resolvedModuleNames = new ts.Map(); var perDirectoryResolvedModuleNames = ts.createCacheWithRedirects(); var nonRelativeModuleNameCache = ts.createCacheWithRedirects(); - var moduleResolutionCache = ts.createModuleResolutionCacheWithMaps(perDirectoryResolvedModuleNames, nonRelativeModuleNameCache, getCurrentDirectory(), resolutionHost.getCanonicalFileName); + var moduleResolutionCache = ts.createModuleResolutionCache(getCurrentDirectory(), resolutionHost.getCanonicalFileName, + /*options*/ undefined, perDirectoryResolvedModuleNames, nonRelativeModuleNameCache); var resolvedTypeReferenceDirectives = new ts.Map(); var perDirectoryResolvedTypeReferenceDirectives = ts.createCacheWithRedirects(); + var typeReferenceDirectiveResolutionCache = ts.createTypeReferenceDirectiveResolutionCache(getCurrentDirectory(), resolutionHost.getCanonicalFileName, + /*options*/ undefined, moduleResolutionCache.getPackageJsonInfoCache(), perDirectoryResolvedTypeReferenceDirectives); /** * These are the extensions that failed lookup files will have by default, * any other extension of failed lookup will be store that path in custom failed lookup path @@ -110581,6 +114333,7 @@ var ts; invalidateResolutionsOfFailedLookupLocations: invalidateResolutionsOfFailedLookupLocations, setFilesWithInvalidatedNonRelativeUnresolvedImports: setFilesWithInvalidatedNonRelativeUnresolvedImports, createHasInvalidatedResolution: createHasInvalidatedResolution, + isFileWithInvalidatedNonRelativeUnresolvedImports: isFileWithInvalidatedNonRelativeUnresolvedImports, updateTypeRootsWatch: updateTypeRootsWatch, closeTypeRootsWatch: closeTypeRootsWatch, clear: clear @@ -110606,9 +114359,9 @@ var ts; resolvedTypeReferenceDirectives.clear(); resolvedFileToResolution.clear(); resolutionsWithFailedLookups.length = 0; - failedLookupChecks.length = 0; - startsWithPathChecks.length = 0; - isInDirectoryChecks.length = 0; + failedLookupChecks = undefined; + startsWithPathChecks = undefined; + isInDirectoryChecks = undefined; // perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update // (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution) clearPerDirectoryResolutions(); @@ -110644,9 +114397,8 @@ var ts; isFileWithInvalidatedNonRelativeUnresolvedImports(path); }; } function clearPerDirectoryResolutions() { - perDirectoryResolvedModuleNames.clear(); - nonRelativeModuleNameCache.clear(); - perDirectoryResolvedTypeReferenceDirectives.clear(); + moduleResolutionCache.clear(); + typeReferenceDirectiveResolutionCache.clear(); nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions); nonRelativeExternalModuleResolutions.clear(); } @@ -110673,7 +114425,7 @@ var ts; if (globalCache !== undefined && !ts.isExternalModuleNameRelative(moduleName) && !(primaryResult.resolvedModule && ts.extensionIsTS(primaryResult.resolvedModule.extension))) { // create different collection of failed lookup locations for second pass // if it will fail and we've already found something during the first pass - we don't want to pollute its results - var _b = ts.loadModuleFromGlobalCache(ts.Debug.checkDefined(resolutionHost.globalCacheResolutionModuleName)(moduleName), resolutionHost.projectName, compilerOptions, host, globalCache), resolvedModule = _b.resolvedModule, failedLookupLocations = _b.failedLookupLocations; + var _b = ts.loadModuleFromGlobalCache(ts.Debug.checkDefined(resolutionHost.globalCacheResolutionModuleName)(moduleName), resolutionHost.projectName, compilerOptions, host, globalCache, moduleResolutionCache), resolvedModule = _b.resolvedModule, failedLookupLocations = _b.failedLookupLocations; if (resolvedModule) { // Modify existing resolution so its saved in the directory cache as well primaryResult.resolvedModule = resolvedModule; @@ -110684,8 +114436,11 @@ var ts; // Default return the result from the first pass return primaryResult; } + function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference) { + return ts.resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache); + } function resolveNamesWithLocalCache(_a) { - var _b; + var _b, _c, _d; var names = _a.names, containingFile = _a.containingFile, redirectedReference = _a.redirectedReference, cache = _a.cache, perDirectoryCacheWithRedirects = _a.perDirectoryCacheWithRedirects, loader = _a.loader, getResolutionWithResolvedFileName = _a.getResolutionWithResolvedFileName, shouldRetryResolution = _a.shouldRetryResolution, reusedNames = _a.reusedNames, logChanges = _a.logChanges; var path = resolutionHost.toPath(containingFile); var resolutionsInFile = cache.get(path) || cache.set(path, new ts.Map()).get(path); @@ -110718,9 +114473,24 @@ var ts; var resolutionInDirectory = perDirectoryResolution.get(name); if (resolutionInDirectory) { resolution = resolutionInDirectory; + var host = ((_b = resolutionHost.getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(resolutionHost)) || resolutionHost; + if (ts.isTraceEnabled(compilerOptions, host)) { + var resolved = getResolutionWithResolvedFileName(resolution); + ts.trace(host, loader === resolveModuleName ? + (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ? + resolved.packagetId ? + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4 : + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3 : + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_not_resolved : + (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ? + resolved.packagetId ? + ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4 : + ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3 : + ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_not_resolved, name, containingFile, ts.getDirectoryPath(containingFile), resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName, (resolved === null || resolved === void 0 ? void 0 : resolved.packagetId) && ts.packageIdToString(resolved.packagetId)); + } } else { - resolution = loader(name, containingFile, compilerOptions, ((_b = resolutionHost.getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(resolutionHost)) || resolutionHost, redirectedReference); + resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference); perDirectoryResolution.set(name, resolution); } resolutionsInFile.set(name, resolution); @@ -110734,6 +114504,23 @@ var ts; logChanges = false; } } + else { + var host = ((_d = resolutionHost.getCompilerHost) === null || _d === void 0 ? void 0 : _d.call(resolutionHost)) || resolutionHost; + if (ts.isTraceEnabled(compilerOptions, host) && !seenNamesInFile.has(name)) { + var resolved = getResolutionWithResolvedFileName(resolution); + ts.trace(host, loader === resolveModuleName ? + (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ? + resolved.packagetId ? + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 : + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2 : + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_not_resolved : + (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ? + resolved.packagetId ? + ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 : + ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2 : + ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_not_resolved, name, containingFile, resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName, (resolved === null || resolved === void 0 ? void 0 : resolved.packagetId) && ts.packageIdToString(resolved.packagetId)); + } + } ts.Debug.assert(resolution !== undefined && !resolution.isInvalidated); seenNamesInFile.set(name, true); resolvedModules.push(getResolutionWithResolvedFileName(resolution)); @@ -110771,7 +114558,7 @@ var ts; redirectedReference: redirectedReference, cache: resolvedTypeReferenceDirectives, perDirectoryCacheWithRedirects: perDirectoryResolvedTypeReferenceDirectives, - loader: ts.resolveTypeReferenceDirective, + loader: resolveTypeReferenceDirective, getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective, shouldRetryResolution: function (resolution) { return resolution.resolvedTypeReferenceDirective === undefined; }, }); @@ -111046,7 +114833,7 @@ var ts; if (isCreatingWatchedDirectory) { // Watching directory is created // Invalidate any resolution has failed lookup in this directory - isInDirectoryChecks.push(fileOrDirectoryPath); + (isInDirectoryChecks || (isInDirectoryChecks = [])).push(fileOrDirectoryPath); } else { // If something to do with folder/file starting with "." in node_modules folder, skip it @@ -111064,8 +114851,8 @@ var ts; if (isNodeModulesAtTypesDirectory(fileOrDirectoryPath) || ts.isNodeModulesDirectory(fileOrDirectoryPath) || isNodeModulesAtTypesDirectory(dirOfFileOrDirectory) || ts.isNodeModulesDirectory(dirOfFileOrDirectory)) { // Invalidate any resolution from this directory - failedLookupChecks.push(fileOrDirectoryPath); - startsWithPathChecks.push(fileOrDirectoryPath); + (failedLookupChecks || (failedLookupChecks = [])).push(fileOrDirectoryPath); + (startsWithPathChecks || (startsWithPathChecks = new ts.Set())).add(fileOrDirectoryPath); } else { if (!isPathWithDefaultFailedLookupExtension(fileOrDirectoryPath) && !customFailedLookupPaths.has(fileOrDirectoryPath)) { @@ -111076,27 +114863,33 @@ var ts; return false; } // Resolution need to be invalidated if failed lookup location is same as the file or directory getting created - failedLookupChecks.push(fileOrDirectoryPath); + (failedLookupChecks || (failedLookupChecks = [])).push(fileOrDirectoryPath); + // If the invalidated file is from a node_modules package, invalidate everything else + // in the package since we might not get notifications for other files in the package. + // This hardens our logic against unreliable file watchers. + var packagePath = ts.parseNodeModuleFromPath(fileOrDirectoryPath); + if (packagePath) + (startsWithPathChecks || (startsWithPathChecks = new ts.Set())).add(packagePath); } } resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations(); } function invalidateResolutionsOfFailedLookupLocations() { - if (!failedLookupChecks.length && !startsWithPathChecks.length && !isInDirectoryChecks.length) { + if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks) { return false; } var invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution); - failedLookupChecks.length = 0; - startsWithPathChecks.length = 0; - isInDirectoryChecks.length = 0; + failedLookupChecks = undefined; + startsWithPathChecks = undefined; + isInDirectoryChecks = undefined; return invalidated; } function canInvalidateFailedLookupResolution(resolution) { return resolution.failedLookupLocations.some(function (location) { var locationPath = resolutionHost.toPath(location); return ts.contains(failedLookupChecks, locationPath) || - startsWithPathChecks.some(function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath); }) || - isInDirectoryChecks.some(function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath); }); + ts.firstDefinedIterator((startsWithPathChecks === null || startsWithPathChecks === void 0 ? void 0 : startsWithPathChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath) ? true : undefined; }) || + (isInDirectoryChecks === null || isInDirectoryChecks === void 0 ? void 0 : isInDirectoryChecks.some(function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath); })); }); } function closeTypeRootsWatch() { @@ -111247,6 +115040,9 @@ var ts; return [ambient]; var info = getInfo(importingSourceFile.path, host); var moduleSourceFile = ts.getSourceFileOfNode(moduleSymbol.valueDeclaration || ts.getNonAugmentationDeclaration(moduleSymbol)); + if (!moduleSourceFile) { + return []; + } var modulePaths = getAllModulePaths(importingSourceFile.path, moduleSourceFile.originalFileName, host); var preferences = getPreferences(userPreferences, compilerOptions, importingSourceFile); var existingSpecifier = ts.forEach(modulePaths, function (modulePath) { return ts.forEach(host.getFileIncludeReasons().get(ts.toPath(modulePath.path, host.getCurrentDirectory(), info.getCanonicalFileName)), function (reason) { @@ -111317,7 +115113,7 @@ var ts; if (!baseUrl && !paths || relativePreference === 0 /* Relative */) { return relativePath; } - var baseDirectory = ts.getPathsBasePath(compilerOptions, host) || baseUrl; + var baseDirectory = ts.getNormalizedAbsolutePath(ts.getPathsBasePath(compilerOptions, host) || baseUrl, host.getCurrentDirectory()); var relativeToBaseUrl = getRelativePathIfInDirectory(moduleFileName, baseDirectory, getCanonicalFileName); if (!relativeToBaseUrl) { return relativePath; @@ -111332,7 +115128,9 @@ var ts; return nonRelative; } if (relativePreference === 3 /* ExternalNonRelative */) { - var projectDirectory = host.getCurrentDirectory(); + var projectDirectory = compilerOptions.configFilePath ? + ts.toPath(ts.getDirectoryPath(compilerOptions.configFilePath), host.getCurrentDirectory(), info.getCanonicalFileName) : + info.getCanonicalFileName(host.getCurrentDirectory()); var modulePath = ts.toPath(moduleFileName, projectDirectory, getCanonicalFileName); var sourceIsInternal = ts.startsWith(sourceDirectory, projectDirectory); var targetIsInternal = ts.startsWith(modulePath, projectDirectory); @@ -111384,12 +115182,8 @@ var ts; return ts.pathIsRelative(text) ? ts.hasJSFileExtension(text) : undefined; }) || false; } - function numberOfDirectorySeparators(str) { - var match = str.match(/\//g); - return match ? match.length : 0; - } function comparePathsByRedirectAndNumberOfDirectorySeparators(a, b) { - return ts.compareBooleans(b.isRedirect, a.isRedirect) || ts.compareValues(numberOfDirectorySeparators(a.path), numberOfDirectorySeparators(b.path)); + return ts.compareBooleans(b.isRedirect, a.isRedirect) || ts.compareNumberOfDirectorySeparators(a.path, b.path); } function getNearestAncestorDirectoryWithPackageJson(host, fileName) { if (host.getNearestAncestorDirectoryWithPackageJson) { @@ -111403,40 +115197,49 @@ var ts; var getCanonicalFileName = ts.hostGetCanonicalFileName(host); var cwd = host.getCurrentDirectory(); var referenceRedirect = host.isSourceOfProjectReferenceRedirect(importedFileName) ? host.getProjectReferenceRedirect(importedFileName) : undefined; - var redirects = host.redirectTargetsMap.get(ts.toPath(importedFileName, cwd, getCanonicalFileName)) || ts.emptyArray; + var importedPath = ts.toPath(importedFileName, cwd, getCanonicalFileName); + var redirects = host.redirectTargetsMap.get(importedPath) || ts.emptyArray; var importedFileNames = __spreadArray(__spreadArray(__spreadArray([], (referenceRedirect ? [referenceRedirect] : ts.emptyArray)), [importedFileName]), redirects); var targets = importedFileNames.map(function (f) { return ts.getNormalizedAbsolutePath(f, cwd); }); + var shouldFilterIgnoredPaths = !ts.every(targets, ts.containsIgnoredPath); if (!preferSymlinks) { - var result_15 = ts.forEach(targets, function (p) { return cb(p, referenceRedirect === p); }); + // Symlinks inside ignored paths are already filtered out of the symlink cache, + // so we only need to remove them from the realpath filenames. + var result_15 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); }); if (result_15) return result_15; } var links = host.getSymlinkCache ? host.getSymlinkCache() : ts.discoverProbableSymlinks(host.getSourceFiles(), getCanonicalFileName, cwd); - var symlinkedDirectories = links.getSymlinkedDirectories(); - var useCaseSensitiveFileNames = !host.useCaseSensitiveFileNames || host.useCaseSensitiveFileNames(); - var result = symlinkedDirectories && ts.forEachEntry(symlinkedDirectories, function (resolved, path) { - if (resolved === false) - return undefined; - if (ts.startsWithDirectory(importingFileName, resolved.realPath, getCanonicalFileName)) { - return undefined; // Don't want to a package to globally import from itself + var symlinkedDirectories = links.getSymlinkedDirectoriesByRealpath(); + var fullImportedFileName = ts.getNormalizedAbsolutePath(importedFileName, cwd); + var result = symlinkedDirectories && ts.forEachAncestorDirectory(ts.getDirectoryPath(fullImportedFileName), function (realPathDirectory) { + var symlinkDirectories = symlinkedDirectories.get(ts.ensureTrailingDirectorySeparator(ts.toPath(realPathDirectory, cwd, getCanonicalFileName))); + if (!symlinkDirectories) + return undefined; // Continue to ancestor directory + // Don't want to a package to globally import from itself (importNameCodeFix_symlink_own_package.ts) + if (ts.startsWithDirectory(importingFileName, realPathDirectory, getCanonicalFileName)) { + return false; // Stop search, each ancestor directory will also hit this condition } return ts.forEach(targets, function (target) { - if (!ts.containsPath(resolved.real, target, !useCaseSensitiveFileNames)) { + if (!ts.startsWithDirectory(target, realPathDirectory, getCanonicalFileName)) { return; } - var relative = ts.getRelativePathFromDirectory(resolved.real, target, getCanonicalFileName); - var option = ts.resolvePath(path, relative); - if (!host.fileExists || host.fileExists(option)) { + var relative = ts.getRelativePathFromDirectory(realPathDirectory, target, getCanonicalFileName); + for (var _i = 0, symlinkDirectories_1 = symlinkDirectories; _i < symlinkDirectories_1.length; _i++) { + var symlinkDirectory = symlinkDirectories_1[_i]; + var option = ts.resolvePath(symlinkDirectory, relative); var result_16 = cb(option, target === referenceRedirect); + shouldFilterIgnoredPaths = true; // We found a non-ignored path in symlinks, so we can reject ignored-path realpaths if (result_16) return result_16; } }); }); - return result || - (preferSymlinks ? ts.forEach(targets, function (p) { return cb(p, p === referenceRedirect); }) : undefined); + return result || (preferSymlinks + ? ts.forEach(targets, function (p) { return shouldFilterIgnoredPaths && ts.containsIgnoredPath(p) ? undefined : cb(p, p === referenceRedirect); }) + : undefined); } moduleSpecifiers.forEachFileNameOfModule = forEachFileNameOfModule; /** @@ -111444,8 +115247,14 @@ var ts; * Symlinks will be returned first so they are preferred over the real path. */ function getAllModulePaths(importingFileName, importedFileName, host) { - var cwd = host.getCurrentDirectory(); + var _a; + var cache = (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host); var getCanonicalFileName = ts.hostGetCanonicalFileName(host); + if (cache) { + var cached = cache.get(importingFileName, ts.toPath(importedFileName, host.getCurrentDirectory(), getCanonicalFileName)); + if (typeof cached === "object") + return cached; + } var allFileNames = new ts.Map(); var importedFileFromNodeModules = false; forEachFileNameOfModule(importingFileName, importedFileName, host, @@ -111457,7 +115266,7 @@ var ts; }); // Sort by paths closest to importing file Name directory var sortedPaths = []; - var _loop_24 = function (directory) { + var _loop_26 = function (directory) { var directoryStart = ts.ensureTrailingDirectorySeparator(directory); var pathsInDirectory; allFileNames.forEach(function (_a, fileName) { @@ -111480,10 +115289,10 @@ var ts; out_directory_1 = directory; }; var out_directory_1; - for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0;) { - var state_7 = _loop_24(directory); + for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) { + var state_9 = _loop_26(directory); directory = out_directory_1; - if (state_7 === "break") + if (state_9 === "break") break; } if (allFileNames.size) { @@ -111492,10 +115301,14 @@ var ts; remainingPaths.sort(comparePathsByRedirectAndNumberOfDirectorySeparators); sortedPaths.push.apply(sortedPaths, remainingPaths); } + if (cache) { + cache.set(importingFileName, ts.toPath(importedFileName, host.getCurrentDirectory(), getCanonicalFileName), sortedPaths); + } return sortedPaths; } function tryGetModuleNameFromAmbientModule(moduleSymbol, checker) { - var decl = ts.find(moduleSymbol.declarations, function (d) { return ts.isNonGlobalAmbientModule(d) && (!ts.isExternalModuleAugmentation(d) || !ts.isExternalModuleNameRelative(ts.getTextOfIdentifierOrLiteral(d.name))); }); + var _a; + var decl = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.isNonGlobalAmbientModule(d) && (!ts.isExternalModuleAugmentation(d) || !ts.isExternalModuleNameRelative(ts.getTextOfIdentifierOrLiteral(d.name))); }); if (decl) { return decl.name.text; } @@ -111551,7 +115364,7 @@ var ts; ts.startsWith(relativeToBaseUrl, prefix) && ts.endsWith(relativeToBaseUrl, suffix) || !suffix && relativeToBaseUrl === ts.removeTrailingDirectorySeparator(prefix)) { - var matchedStar = relativeToBaseUrl.substr(prefix.length, relativeToBaseUrl.length - suffix.length); + var matchedStar = relativeToBaseUrl.substr(prefix.length, relativeToBaseUrl.length - suffix.length - prefix.length); return key.replace("*", matchedStar); } } @@ -111855,10 +115668,10 @@ var ts; } ts.createWatchStatusReporter = createWatchStatusReporter; /** Parses config file using System interface */ - function parseConfigFileWithSystem(configFileName, optionsToExtend, watchOptionsToExtend, system, reportDiagnostic) { + function parseConfigFileWithSystem(configFileName, optionsToExtend, extendedConfigCache, watchOptionsToExtend, system, reportDiagnostic) { var host = system; host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(system, reportDiagnostic, diagnostic); }; - var result = ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtend, host, /*extendedConfigCache*/ undefined, watchOptionsToExtend); + var result = ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtend, host, extendedConfigCache, watchOptionsToExtend); host.onUnRecoverableConfigFileDiagnostic = undefined; // TODO: GH#18217 return result; } @@ -112126,7 +115939,10 @@ var ts; MissingFile: "Missing file", WildcardDirectory: "Wild card directory", FailedLookupLocations: "Failed Lookup Locations", - TypeRoots: "Type roots" + TypeRoots: "Type roots", + ConfigFileOfReferencedProject: "Config file of referened project", + ExtendedConfigOfReferencedProject: "Extended config file of referenced project", + WildcardDirectoryOfReferencedProject: "Wild card directory of referenced project", }; function createWatchFactory(host, options) { var watchLogLevel = host.trace ? options.extendedDiagnostics ? ts.WatchLogLevel.Verbose : options.diagnostics ? ts.WatchLogLevel.TriggerOnly : ts.WatchLogLevel.None : ts.WatchLogLevel.None; @@ -112173,6 +115989,7 @@ var ts; getEnvironmentVariable: ts.maybeBind(host, host.getEnvironmentVariable) || (function () { return ""; }), createHash: ts.maybeBind(host, host.createHash), readDirectory: ts.maybeBind(host, host.readDirectory), + disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature, }; function writeFile(fileName, text, writeByteOrderMark, onError) { try { @@ -112230,7 +116047,8 @@ var ts; createDirectory: function (path) { return system.createDirectory(path); }, writeFile: function (path, data, writeByteOrderMark) { return system.writeFile(path, data, writeByteOrderMark); }, createHash: ts.maybeBind(system, system.createHash), - createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram + createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram, + disableUseFileVersionAsSignature: system.disableUseFileVersionAsSignature, }; } ts.createProgramHost = createProgramHost; @@ -112318,6 +116136,7 @@ var ts; if (system === void 0) { system = ts.sys; } var host = ts.createCompilerHostWorker(options, /*setParentNodes*/ undefined, system); host.createHash = ts.maybeBind(system, system.createHash); + host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature; ts.setGetSourceFileAsHashVersioned(host, system); ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); }); return host; @@ -112361,11 +116180,13 @@ var ts; function createWatchProgram(host) { var builderProgram; var reloadLevel; // level to indicate if the program needs to be reloaded from config file/just filenames etc - var extendedConfigFilesMap; // Map of file watchers for the extended config files var missingFilesMap; // Map of file watchers for the missing files var watchedWildcardDirectories; // map of watchers for the wild card directories in the config file var timerToUpdateProgram; // timer callback to recompile the program var timerToInvalidateFailedLookupResolutions; // timer callback to invalidate resolutions for changes in failed lookup locations + 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 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 var hasChangedCompilerOptions = false; // True if the compiler options have changed between compilations @@ -112415,6 +116236,7 @@ var ts; compilerHost.getNewLine = function () { return newLine; }; compilerHost.fileExists = fileExists; compilerHost.onReleaseOldSourceFile = onReleaseOldSourceFile; + compilerHost.onReleaseParsedCommandLine = onReleaseParsedCommandLine; // Members for ResolutionCacheHost compilerHost.toPath = toPath; compilerHost.getCompilationSettings = function () { return compilerOptions; }; @@ -112428,6 +116250,7 @@ var ts; compilerHost.fileIsOpen = ts.returnFalse; compilerHost.getCurrentProgram = getCurrentProgram; compilerHost.writeLog = writeLog; + compilerHost.getParsedCommandLine = getParsedCommandLine; // Cache for the module resolution var resolutionCache = ts.createResolutionCache(compilerHost, configFileName ? ts.getDirectoryPath(ts.getNormalizedAbsolutePath(configFileName, currentDirectory)) : @@ -112458,7 +116281,8 @@ var ts; // Update the wild card directory watch watchConfigFileWildCardDirectories(); // Update extended config file watch - watchExtendedConfigFiles(); + if (configFileName) + updateExtendedConfigFilesWatches(toPath(configFileName), compilerOptions, watchOptions, ts.WatchType.ExtendedConfigFile); return configFileName ? { getCurrentProgram: getCurrentBuilderProgram, getProgram: updateProgram, close: close } : { getCurrentProgram: getCurrentBuilderProgram, getProgram: updateProgram, updateRootFileNames: updateRootFileNames, close: close }; @@ -112475,9 +116299,11 @@ var ts; configFileWatcher.close(); configFileWatcher = undefined; } - if (extendedConfigFilesMap) { - ts.clearMap(extendedConfigFilesMap, ts.closeFileWatcher); - extendedConfigFilesMap = undefined; + extendedConfigCache === null || extendedConfigCache === void 0 ? void 0 : extendedConfigCache.clear(); + extendedConfigCache = undefined; + if (sharedExtendedConfigFileWatchers) { + ts.clearMap(sharedExtendedConfigFileWatchers, ts.closeFileWatcherOf); + sharedExtendedConfigFileWatchers = undefined; } if (watchedWildcardDirectories) { ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcherOf); @@ -112487,6 +116313,17 @@ var ts; ts.clearMap(missingFilesMap, ts.closeFileWatcher); missingFilesMap = undefined; } + if (parsedConfigs) { + ts.clearMap(parsedConfigs, function (config) { + var _a; + (_a = config.watcher) === null || _a === void 0 ? void 0 : _a.close(); + config.watcher = undefined; + if (config.watchedDirectories) + ts.clearMap(config.watchedDirectories, ts.closeFileWatcherOf); + config.watchedDirectories = undefined; + }); + parsedConfigs = undefined; + } } function getCurrentBuilderProgram() { return builderProgram; @@ -112506,7 +116343,7 @@ var ts; } // All resolutions are invalid if user provided resolutions var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution); - if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, projectReferences)) { + if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) { if (hasChangedConfigFileParsingErrors) { builderProgram = createProgram(/*rootNames*/ undefined, /*options*/ undefined, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences); hasChangedConfigFileParsingErrors = false; @@ -112525,6 +116362,8 @@ var ts; writeLog("CreatingProgramWith::"); writeLog(" roots: " + JSON.stringify(rootFileNames)); writeLog(" options: " + JSON.stringify(compilerOptions)); + if (projectReferences) + writeLog(" projectReferences: " + JSON.stringify(projectReferences)); var needsUpdateInTypeRootWatch = hasChangedCompilerOptions || !getCurrentProgram(); hasChangedCompilerOptions = false; hasChangedConfigFileParsingErrors = false; @@ -112747,10 +116586,10 @@ var ts; // Update the wild card directory watch watchConfigFileWildCardDirectories(); // Update extended config file watch - watchExtendedConfigFiles(); + updateExtendedConfigFilesWatches(toPath(configFileName), compilerOptions, watchOptions, ts.WatchType.ExtendedConfigFile); } function parseConfigFile() { - setConfigFileParsingResult(ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtendForConfigFile, parseConfigFileHost, /*extendedConfigCache*/ undefined, watchOptionsToExtend, extraFileExtensions)); // TODO: GH#18217 + setConfigFileParsingResult(ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtendForConfigFile, parseConfigFileHost, extendedConfigCache || (extendedConfigCache = new ts.Map()), watchOptionsToExtend, extraFileExtensions)); // TODO: GH#18217 } function setConfigFileParsingResult(configFileParseResult) { rootFileNames = configFileParseResult.fileNames; @@ -112762,6 +116601,56 @@ var ts; canConfigFileJsonReportNoInputFiles = ts.canJsonReportNoInputFiles(configFileParseResult.raw); hasChangedConfigFileParsingErrors = true; } + function getParsedCommandLine(configFileName) { + var configPath = toPath(configFileName); + var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(configPath); + if (config) { + if (!config.reloadLevel) + return config.parsedCommandLine; + // With host implementing getParsedCommandLine we cant just update file names + if (config.parsedCommandLine && config.reloadLevel === ts.ConfigFileProgramReloadLevel.Partial && !host.getParsedCommandLine) { + writeLog("Reloading new file names and options"); + var fileNames = ts.getFileNamesFromConfigSpecs(config.parsedCommandLine.options.configFile.configFileSpecs, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), compilerOptions, parseConfigFileHost); + config.parsedCommandLine = __assign(__assign({}, config.parsedCommandLine), { fileNames: fileNames }); + config.reloadLevel = undefined; + return config.parsedCommandLine; + } + } + writeLog("Loading config file: " + configFileName); + var parsedCommandLine = host.getParsedCommandLine ? + host.getParsedCommandLine(configFileName) : + getParsedCommandLineFromConfigFileHost(configFileName); + if (config) { + config.parsedCommandLine = parsedCommandLine; + config.reloadLevel = undefined; + } + else { + (parsedConfigs || (parsedConfigs = new ts.Map())).set(configPath, config = { parsedCommandLine: parsedCommandLine }); + } + watchReferencedProject(configFileName, configPath, config); + return parsedCommandLine; + } + function getParsedCommandLineFromConfigFileHost(configFileName) { + // Ignore the file absent errors + var onUnRecoverableConfigFileDiagnostic = parseConfigFileHost.onUnRecoverableConfigFileDiagnostic; + parseConfigFileHost.onUnRecoverableConfigFileDiagnostic = ts.noop; + var parsedCommandLine = ts.getParsedCommandLineOfConfigFile(configFileName, + /*optionsToExtend*/ undefined, parseConfigFileHost, extendedConfigCache || (extendedConfigCache = new ts.Map()), watchOptionsToExtend); + parseConfigFileHost.onUnRecoverableConfigFileDiagnostic = onUnRecoverableConfigFileDiagnostic; + return parsedCommandLine; + } + function onReleaseParsedCommandLine(fileName) { + var _a; + var path = toPath(fileName); + var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(path); + if (!config) + return; + parsedConfigs.delete(path); + if (config.watchedDirectories) + ts.clearMap(config.watchedDirectories, ts.closeFileWatcherOf); + (_a = config.watcher) === null || _a === void 0 ? void 0 : _a.close(); + ts.clearSharedExtendedConfigFileWatcher(path, sharedExtendedConfigFileWatchers); + } function watchFilePath(path, file, callback, pollingInterval, options, watchType) { return watchFile(file, function (fileName, eventKind) { return callback(fileName, eventKind, path); }, pollingInterval, options, watchType); } @@ -112771,7 +116660,6 @@ var ts; if (eventKind === ts.FileWatcherEventKind.Deleted && sourceFilesCache.has(path)) { resolutionCache.invalidateResolutionOfFile(path); } - resolutionCache.removeResolutionsFromProjectReferenceRedirects(path); nextSourceFileVersion(path); // Update the program scheduleProgramUpdate(); @@ -112782,7 +116670,10 @@ var ts; } } function watchMissingFilePath(missingFilePath) { - return watchFilePath(missingFilePath, missingFilePath, onMissingFileChange, ts.PollingInterval.Medium, watchOptions, ts.WatchType.MissingFile); + // If watching missing referenced config file, we are already watching it so no need for separate watcher + return (parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.has(missingFilePath)) ? + ts.noopFileWatcher : + watchFilePath(missingFilePath, missingFilePath, onMissingFileChange, ts.PollingInterval.Medium, watchOptions, ts.WatchType.MissingFile); } function onMissingFileChange(fileName, eventKind, missingFilePath) { updateCachedSystemWithFile(fileName, missingFilePath, eventKind); @@ -112819,10 +116710,11 @@ var ts; configFileName: configFileName, extraFileExtensions: extraFileExtensions, options: compilerOptions, - program: getCurrentBuilderProgram(), + program: getCurrentBuilderProgram() || rootFileNames, currentDirectory: currentDirectory, useCaseSensitiveFileNames: useCaseSensitiveFileNames, - writeLog: writeLog + writeLog: writeLog, + toPath: toPath, })) return; // Reload is pending, do the reload @@ -112833,18 +116725,87 @@ var ts; } }, flags, watchOptions, ts.WatchType.WildcardDirectory); } - function watchExtendedConfigFiles() { - var _a; - // Update the extended config files watcher - ts.mutateMap(extendedConfigFilesMap || (extendedConfigFilesMap = new ts.Map()), ts.arrayToMap(((_a = compilerOptions.configFile) === null || _a === void 0 ? void 0 : _a.extendedSourceFiles) || ts.emptyArray, toPath), { - // Watch the extended config files - createNewValue: watchExtendedConfigFile, - // Config files that are no longer extended should no longer be watched. - onDeleteValue: ts.closeFileWatcher - }); + function updateExtendedConfigFilesWatches(forProjectPath, options, watchOptions, watchType) { + ts.updateSharedExtendedConfigFileWatcher(forProjectPath, options, sharedExtendedConfigFileWatchers || (sharedExtendedConfigFileWatchers = new ts.Map()), function (extendedConfigFileName, extendedConfigFilePath) { return watchFile(extendedConfigFileName, function (_fileName, eventKind) { + var _a; + updateCachedSystemWithFile(extendedConfigFileName, extendedConfigFilePath, eventKind); + // Update extended config cache + if (extendedConfigCache) + ts.cleanExtendedConfigCache(extendedConfigCache, extendedConfigFilePath, toPath); + // Update projects + var projects = (_a = sharedExtendedConfigFileWatchers.get(extendedConfigFilePath)) === null || _a === void 0 ? void 0 : _a.projects; + // If there are no referenced projects this extended config file watcher depend on ignore + if (!(projects === null || projects === void 0 ? void 0 : projects.size)) + return; + projects.forEach(function (projectPath) { + if (toPath(configFileName) === projectPath) { + // If this is the config file of the project, reload completely + reloadLevel = ts.ConfigFileProgramReloadLevel.Full; + } + else { + // Reload config for the referenced projects and remove the resolutions from referenced projects since the config file changed + var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(projectPath); + if (config) + config.reloadLevel = ts.ConfigFileProgramReloadLevel.Full; + resolutionCache.removeResolutionsFromProjectReferenceRedirects(projectPath); + } + scheduleProgramUpdate(); + }); + }, ts.PollingInterval.High, watchOptions, watchType); }, toPath); } - function watchExtendedConfigFile(extendedConfigFile) { - return watchFile(extendedConfigFile, scheduleProgramReload, ts.PollingInterval.High, watchOptions, ts.WatchType.ExtendedConfigFile); + function watchReferencedProject(configFileName, configPath, commandLine) { + var _a, _b, _c, _d, _e; + // Watch file + commandLine.watcher || (commandLine.watcher = watchFile(configFileName, function (_fileName, eventKind) { + updateCachedSystemWithFile(configFileName, configPath, eventKind); + var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(configPath); + if (config) + config.reloadLevel = ts.ConfigFileProgramReloadLevel.Full; + resolutionCache.removeResolutionsFromProjectReferenceRedirects(configPath); + scheduleProgramUpdate(); + }, ts.PollingInterval.High, ((_a = commandLine.parsedCommandLine) === null || _a === void 0 ? void 0 : _a.watchOptions) || watchOptions, ts.WatchType.ConfigFileOfReferencedProject)); + // Watch Wild card + if ((_b = commandLine.parsedCommandLine) === null || _b === void 0 ? void 0 : _b.wildcardDirectories) { + ts.updateWatchingWildcardDirectories(commandLine.watchedDirectories || (commandLine.watchedDirectories = new ts.Map()), new ts.Map(ts.getEntries((_c = commandLine.parsedCommandLine) === null || _c === void 0 ? void 0 : _c.wildcardDirectories)), function (directory, flags) { + var _a; + return watchDirectory(directory, function (fileOrDirectory) { + var fileOrDirectoryPath = toPath(fileOrDirectory); + // Since the file existence changed, update the sourceFiles cache + if (cachedDirectoryStructureHost) { + cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); + } + nextSourceFileVersion(fileOrDirectoryPath); + var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(configPath); + if (!(config === null || config === void 0 ? void 0 : config.parsedCommandLine)) + return; + if (ts.isIgnoredFileFromWildCardWatching({ + watchedDirPath: toPath(directory), + fileOrDirectory: fileOrDirectory, + fileOrDirectoryPath: fileOrDirectoryPath, + configFileName: configFileName, + options: config.parsedCommandLine.options, + program: config.parsedCommandLine.fileNames, + currentDirectory: currentDirectory, + useCaseSensitiveFileNames: useCaseSensitiveFileNames, + writeLog: writeLog, + toPath: toPath, + })) + return; + // Reload is pending, do the reload + if (config.reloadLevel !== ts.ConfigFileProgramReloadLevel.Full) { + config.reloadLevel = ts.ConfigFileProgramReloadLevel.Partial; + // Schedule Update the program + scheduleProgramUpdate(); + } + }, flags, ((_a = commandLine.parsedCommandLine) === null || _a === void 0 ? void 0 : _a.watchOptions) || watchOptions, ts.WatchType.WildcardDirectoryOfReferencedProject); + }); + } + else if (commandLine.watchedDirectories) { + ts.clearMap(commandLine.watchedDirectories, ts.closeFileWatcherOf); + commandLine.watchedDirectories = undefined; + } + // Watch extended config files + updateExtendedConfigFilesWatches(configPath, (_d = commandLine.parsedCommandLine) === null || _d === void 0 ? void 0 : _d.options, ((_e = commandLine.parsedCommandLine) === null || _e === void 0 ? void 0 : _e.watchOptions) || watchOptions, ts.WatchType.ExtendedConfigOfReferencedProject); } } ts.createWatchProgram = createWatchProgram; @@ -113004,12 +116965,19 @@ var ts; compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames); compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives); 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) { var loader_3 = function (moduleName, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference).resolvedModule; }; compilerHost.resolveModuleNames = function (moduleNames, containingFile, _reusedNames, redirectedReference) { return ts.loadWithLocalCache(ts.Debug.checkEachDefined(moduleNames), containingFile, redirectedReference, loader_3); }; } + if (!compilerHost.resolveTypeReferenceDirectives) { + var loader_4 = function (moduleName, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache).resolvedTypeReferenceDirective; }; + compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { + return ts.loadWithLocalCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, loader_4); + }; + } var _a = ts.createWatchFactory(hostWithWatch, options), watchFile = _a.watchFile, watchDirectory = _a.watchDirectory, writeLog = _a.writeLog; var state = { host: host, @@ -113034,6 +117002,7 @@ var ts; projectErrorsReported: new ts.Map(), compilerHost: compilerHost, moduleResolutionCache: moduleResolutionCache, + typeReferenceDirectiveResolutionCache: typeReferenceDirectiveResolutionCache, // Mutable state buildOrder: undefined, readFileWithCache: function (f) { return host.readFile(f); }, @@ -113072,6 +117041,10 @@ var ts; function isParsedCommandLine(entry) { return !!entry.options; } + function getCachedParsedConfigFile(state, configFilePath) { + var value = state.configFileCache.get(configFilePath); + return value && isParsedCommandLine(value) ? value : undefined; + } function parseConfigFile(state, configFileName, configFilePath) { var configFileCache = state.configFileCache; var value = configFileCache.get(configFilePath); @@ -113217,7 +117190,7 @@ var ts; function disableCache(state) { if (!state.cache) return; - var cache = state.cache, host = state.host, compilerHost = state.compilerHost, extendedConfigCache = state.extendedConfigCache, moduleResolutionCache = state.moduleResolutionCache; + var cache = state.cache, host = state.host, compilerHost = state.compilerHost, extendedConfigCache = state.extendedConfigCache, moduleResolutionCache = state.moduleResolutionCache, typeReferenceDirectiveResolutionCache = state.typeReferenceDirectiveResolutionCache; host.readFile = cache.originalReadFile; host.fileExists = cache.originalFileExists; host.directoryExists = cache.originalDirectoryExists; @@ -113226,10 +117199,8 @@ var ts; compilerHost.getSourceFile = cache.originalGetSourceFile; state.readFileWithCache = cache.originalReadFileWithCache; extendedConfigCache.clear(); - if (moduleResolutionCache) { - moduleResolutionCache.directoryToModuleNameMap.clear(); - moduleResolutionCache.moduleNameToDirectoryMap.clear(); - } + moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.clear(); + typeReferenceDirectiveResolutionCache === null || typeReferenceDirectiveResolutionCache === void 0 ? void 0 : typeReferenceDirectiveResolutionCache.clear(); state.cache = undefined; } function clearProjectStatus(state, resolved) { @@ -113396,6 +117367,7 @@ var ts; return withProgramOrUndefined(action) || ts.emptyArray; } function createProgram() { + var _a, _b; ts.Debug.assert(program === undefined); if (state.options.dry) { reportStatus(state, ts.Diagnostics.A_non_dry_build_would_build_project_0, project); @@ -113415,7 +117387,8 @@ var ts; var host = state.host, compilerHost = state.compilerHost; state.projectCompilerOptions = config.options; // Update module resolution cache if needed - updateModuleResolutionCache(state, project, config); + (_a = state.moduleResolutionCache) === null || _a === void 0 ? void 0 : _a.update(config.options); + (_b = state.typeReferenceDirectiveResolutionCache) === null || _b === void 0 ? void 0 : _b.update(config.options); // Create program program = host.createProgram(config.fileNames, config.options, compilerHost, getOldProgram(state, projectPath, config), ts.getConfigFileParsingDiagnostics(config), config.projectReferences); if (state.watch) { @@ -113590,7 +117563,7 @@ var ts; emitBundle(writeFile, customTransformers); break; case BuildStep.BuildInvalidatedProjectOfBundle: - ts.Debug.checkDefined(invalidatedProjectOfBundle).done(cancellationToken); + ts.Debug.checkDefined(invalidatedProjectOfBundle).done(cancellationToken, writeFile, customTransformers); step = BuildStep.Done; break; case BuildStep.QueueReferencingProjects: @@ -113732,34 +117705,9 @@ var ts; afterProgramDone(state, program, config); return { buildResult: buildResult, step: BuildStep.QueueReferencingProjects }; } - function updateModuleResolutionCache(state, proj, config) { - if (!state.moduleResolutionCache) - return; - // Update module resolution cache if needed - var moduleResolutionCache = state.moduleResolutionCache; - var projPath = toPath(state, proj); - if (moduleResolutionCache.directoryToModuleNameMap.redirectsMap.size === 0) { - // The own map will be for projectCompilerOptions - ts.Debug.assert(moduleResolutionCache.moduleNameToDirectoryMap.redirectsMap.size === 0); - moduleResolutionCache.directoryToModuleNameMap.redirectsMap.set(projPath, moduleResolutionCache.directoryToModuleNameMap.ownMap); - moduleResolutionCache.moduleNameToDirectoryMap.redirectsMap.set(projPath, moduleResolutionCache.moduleNameToDirectoryMap.ownMap); - } - else { - // Set correct own map - ts.Debug.assert(moduleResolutionCache.moduleNameToDirectoryMap.redirectsMap.size > 0); - var ref = { - sourceFile: config.options.configFile, - commandLine: config - }; - moduleResolutionCache.directoryToModuleNameMap.setOwnMap(moduleResolutionCache.directoryToModuleNameMap.getOrCreateMapOfCacheRedirects(ref)); - moduleResolutionCache.moduleNameToDirectoryMap.setOwnMap(moduleResolutionCache.moduleNameToDirectoryMap.getOrCreateMapOfCacheRedirects(ref)); - } - moduleResolutionCache.directoryToModuleNameMap.setOwnOptions(config.options); - moduleResolutionCache.moduleNameToDirectoryMap.setOwnOptions(config.options); - } function checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName) { // Check tsconfig time - var tsconfigTime = state.host.getModifiedTime(configFile) || ts.missingFileModifiedTime; + var tsconfigTime = ts.getModifiedTime(state.host, configFile); if (oldestOutputFileTime < tsconfigTime) { return { type: ts.UpToDateStatusType.OutOfDateWithSelf, @@ -113769,6 +117717,7 @@ var ts; } } function getUpToDateStatusWorker(state, project, resolvedPath) { + var force = !!state.options.force; var newestInputFileName = undefined; var newestInputFileTime = minimumDate; var host = state.host; @@ -113781,10 +117730,13 @@ var ts; reason: inputFile + " does not exist" }; } - var inputTime = host.getModifiedTime(inputFile) || ts.missingFileModifiedTime; - if (inputTime > newestInputFileTime) { - newestInputFileName = inputFile; - newestInputFileTime = inputTime; + if (!force) { + var inputTime = ts.getModifiedTime(host, inputFile); + host.getModifiedTime(inputFile); + if (inputTime > newestInputFileTime) { + newestInputFileName = inputFile; + newestInputFileTime = inputTime; + } } } // Container if no files are specified in the project @@ -113803,36 +117755,38 @@ var ts; var missingOutputFileName; var newestDeclarationFileContentChangedTime = minimumDate; var isOutOfDateWithInputs = false; - for (var _b = 0, outputs_1 = outputs; _b < outputs_1.length; _b++) { - var output = outputs_1[_b]; - // Output is missing; can stop checking - // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status - if (!host.fileExists(output)) { - missingOutputFileName = output; - break; - } - var outputTime = host.getModifiedTime(output) || ts.missingFileModifiedTime; - if (outputTime < oldestOutputFileTime) { - oldestOutputFileTime = outputTime; - oldestOutputFileName = output; - } - // If an output is older than the newest input, we can stop checking - // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status - if (outputTime < newestInputFileTime) { - isOutOfDateWithInputs = true; - break; - } - if (outputTime > newestOutputFileTime) { - newestOutputFileTime = outputTime; - newestOutputFileName = output; - } - // Keep track of when the most recent time a .d.ts file was changed. - // In addition to file timestamps, we also keep track of when a .d.ts file - // had its file touched but not had its contents changed - this allows us - // to skip a downstream typecheck - if (isDeclarationFile(output)) { - var outputModifiedTime = host.getModifiedTime(output) || ts.missingFileModifiedTime; - newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime); + if (!force) { + for (var _b = 0, outputs_1 = outputs; _b < outputs_1.length; _b++) { + var output = outputs_1[_b]; + // Output is missing; can stop checking + // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status + if (!host.fileExists(output)) { + missingOutputFileName = output; + break; + } + var outputTime = ts.getModifiedTime(host, output); + if (outputTime < oldestOutputFileTime) { + oldestOutputFileTime = outputTime; + oldestOutputFileName = output; + } + // If an output is older than the newest input, we can stop checking + // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status + if (outputTime < newestInputFileTime) { + isOutOfDateWithInputs = true; + break; + } + if (outputTime > newestOutputFileTime) { + newestOutputFileTime = outputTime; + newestOutputFileName = output; + } + // Keep track of when the most recent time a .d.ts file was changed. + // In addition to file timestamps, we also keep track of when a .d.ts file + // had its file touched but not had its contents changed - this allows us + // to skip a downstream typecheck + if (isDeclarationFile(output)) { + var outputModifiedTime = ts.getModifiedTime(host, output); + newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime); + } } } var pseudoUpToDate = false; @@ -113868,7 +117822,8 @@ var ts; }; } // Check oldest output file name only if there is no missing output file name - if (!missingOutputFileName) { + // (a check we will have skipped if this is a forced build) + if (!force && !missingOutputFileName) { // If the upstream project's newest file is older than our oldest output, we // can't be out of date because of it if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) { @@ -113914,7 +117869,7 @@ var ts; if (extendedConfigStatus) return extendedConfigStatus; } - if (!state.buildInfoChecked.has(resolvedPath)) { + if (!force && !state.buildInfoChecked.has(resolvedPath)) { state.buildInfoChecked.set(resolvedPath, true); var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options); if (buildInfoPath) { @@ -113959,6 +117914,8 @@ var ts; return actual; } function updateOutputTimestampsWorker(state, proj, priorNewestUpdateTime, verboseMessage, skipOutputs) { + if (proj.options.noEmit) + return priorNewestUpdateTime; var host = state.host; var outputs = ts.getAllProjectOutputs(proj, !host.useCaseSensitiveFileNames()); if (!skipOutputs || outputs.length !== skipOutputs.size) { @@ -113974,7 +117931,7 @@ var ts; reportStatus(state, verboseMessage, proj.options.configFilePath); } if (isDeclarationFile(file)) { - priorNewestUpdateTime = newer(priorNewestUpdateTime, host.getModifiedTime(file) || ts.missingFileModifiedTime); + priorNewestUpdateTime = newer(priorNewestUpdateTime, ts.getModifiedTime(host, file)); } host.setModifiedTime(file, now); } @@ -114056,7 +118013,7 @@ var ts; } } } - function build(state, project, cancellationToken, onlyReferences) { + function build(state, project, cancellationToken, writeFile, getCustomTransformers, onlyReferences) { var buildOrder = getBuildOrderFor(state, project, onlyReferences); if (!buildOrder) return ts.ExitStatus.InvalidProject_OutputsSkipped; @@ -114068,7 +118025,7 @@ var ts; if (!invalidatedProject) break; reportQueue = false; - invalidatedProject.done(cancellationToken); + invalidatedProject.done(cancellationToken, writeFile, getCustomTransformers === null || getCustomTransformers === void 0 ? void 0 : getCustomTransformers(invalidatedProject.project)); if (!state.diagnostics.has(invalidatedProject.projectPath)) successfulProjects++; } @@ -114103,8 +118060,14 @@ var ts; continue; } var outputs = ts.getAllProjectOutputs(parsed, !host.useCaseSensitiveFileNames()); + if (!outputs.length) + continue; + var inputFileNames = new ts.Set(parsed.fileNames.map(function (f) { return toPath(state, f); })); for (var _a = 0, outputs_3 = outputs; _a < outputs_3.length; _a++) { var output = outputs_3[_a]; + // If output name is same as input file name, do not delete and ignore the error + if (inputFileNames.has(toPath(state, output))) + continue; if (host.fileExists(output)) { if (filesToDelete) { filesToDelete.push(output); @@ -114180,7 +118143,7 @@ var ts; }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.ConfigFile, resolved)); } function watchExtendedConfigFiles(state, resolvedPath, parsed) { - ts.updateSharedExtendedConfigFileWatcher(resolvedPath, parsed, state.allWatchedExtendedConfigFiles, function (extendedConfigFileName, extendedConfigFilePath) { return state.watchFile(extendedConfigFileName, function () { + ts.updateSharedExtendedConfigFileWatcher(resolvedPath, parsed === null || parsed === void 0 ? void 0 : parsed.options, state.allWatchedExtendedConfigFiles, function (extendedConfigFileName, extendedConfigFilePath) { return state.watchFile(extendedConfigFileName, function () { var _a; return (_a = state.allWatchedExtendedConfigFiles.get(extendedConfigFilePath)) === null || _a === void 0 ? void 0 : _a.projects.forEach(function (projectConfigFilePath) { return invalidateProjectAndScheduleBuilds(state, projectConfigFilePath, ts.ConfigFileProgramReloadLevel.Full); @@ -114191,6 +118154,7 @@ var ts; if (!state.watch) return; ts.updateWatchingWildcardDirectories(getOrCreateValueMapFromConfigFileMap(state.allWatchedWildcardDirectories, resolvedPath), new ts.Map(ts.getEntries(parsed.wildcardDirectories)), function (dir, flags) { return state.watchDirectory(dir, function (fileOrDirectory) { + var _a; if (ts.isIgnoredFileFromWildCardWatching({ watchedDirPath: toPath(state, dir), fileOrDirectory: fileOrDirectory, @@ -114198,9 +118162,10 @@ var ts; configFileName: resolved, currentDirectory: state.currentDirectory, options: parsed.options, - program: state.builderPrograms.get(resolvedPath), + program: state.builderPrograms.get(resolvedPath) || ((_a = getCachedParsedConfigFile(state, resolvedPath)) === null || _a === void 0 ? void 0 : _a.fileNames), useCaseSensitiveFileNames: state.parseConfigFileHost.useCaseSensitiveFileNames, - writeLog: function (s) { return state.writeLog(s); } + writeLog: function (s) { return state.writeLog(s); }, + toPath: function (fileName) { return toPath(state, fileName); } })) return; invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.Partial); @@ -114235,19 +118200,16 @@ var ts; } function stopWatching(state) { ts.clearMap(state.allWatchedConfigFiles, ts.closeFileWatcher); - ts.clearMap(state.allWatchedExtendedConfigFiles, function (watcher) { - watcher.projects.clear(); - watcher.close(); - }); + ts.clearMap(state.allWatchedExtendedConfigFiles, ts.closeFileWatcherOf); ts.clearMap(state.allWatchedWildcardDirectories, function (watchedWildcardDirectories) { return ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcherOf); }); ts.clearMap(state.allWatchedInputFiles, function (watchedWildcardDirectories) { return ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcher); }); } function createSolutionBuilderWorker(watch, hostOrHostWithWatch, rootNames, options, baseWatchOptions) { var state = createSolutionBuilderState(watch, hostOrHostWithWatch, rootNames, options, baseWatchOptions); return { - build: function (project, cancellationToken) { return build(state, project, cancellationToken); }, + build: function (project, cancellationToken, writeFile, getCustomTransformers) { return build(state, project, cancellationToken, writeFile, getCustomTransformers); }, clean: function (project) { return clean(state, project); }, - buildReferences: function (project, cancellationToken) { return build(state, project, cancellationToken, /*onlyReferences*/ true); }, + buildReferences: function (project, cancellationToken, writeFile, getCustomTransformers) { return build(state, project, cancellationToken, writeFile, getCustomTransformers, /*onlyReferences*/ true); }, cleanReferences: function (project) { return clean(state, project, /*onlyReferences*/ true); }, getNextInvalidatedProject: function (cancellationToken) { setupInitialBuild(state, cancellationToken); @@ -114337,6 +118299,9 @@ var ts; } } function reportUpToDateStatus(state, configFileName, status) { + if (state.options.force && (status.type === ts.UpToDateStatusType.UpToDate || status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes)) { + return reportStatus(state, ts.Diagnostics.Project_0_is_being_forcibly_rebuilt, relName(state, configFileName)); + } switch (status.type) { case ts.UpToDateStatusType.OutOfDateWithSelf: return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, relName(state, configFileName), relName(state, status.outOfDateOutputFileName), relName(state, status.newerInputFileName)); @@ -114886,6 +118851,9 @@ var ts; SymbolDisplayPartKind[SymbolDisplayPartKind["enumMemberName"] = 19] = "enumMemberName"; SymbolDisplayPartKind[SymbolDisplayPartKind["functionName"] = 20] = "functionName"; SymbolDisplayPartKind[SymbolDisplayPartKind["regularExpressionLiteral"] = 21] = "regularExpressionLiteral"; + SymbolDisplayPartKind[SymbolDisplayPartKind["link"] = 22] = "link"; + SymbolDisplayPartKind[SymbolDisplayPartKind["linkName"] = 23] = "linkName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["linkText"] = 24] = "linkText"; })(SymbolDisplayPartKind = ts.SymbolDisplayPartKind || (ts.SymbolDisplayPartKind = {})); var OutliningSpanKind; (function (OutliningSpanKind) { @@ -114996,6 +118964,12 @@ var ts; ScriptElementKind["jsxAttribute"] = "JSX attribute"; /** String literal */ ScriptElementKind["string"] = "string"; + /** Jsdoc @link: in `{@link C link text}`, the before and after text "{@link " and "}" */ + ScriptElementKind["link"] = "link"; + /** Jsdoc @link: in `{@link C link text}`, the entity name "C" */ + ScriptElementKind["linkName"] = "link name"; + /** Jsdoc @link: in `{@link C link text}`, the link text "link text" */ + ScriptElementKind["linkText"] = "link text"; })(ScriptElementKind = ts.ScriptElementKind || (ts.ScriptElementKind = {})); var ScriptElementKindModifier; (function (ScriptElementKindModifier) { @@ -115088,37 +119062,37 @@ var ts; })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return ts.isInJSFile(node) && ts.getJSDocEnumTag(node) ? 7 /* All */ : 1 /* Value */; - case 160 /* Parameter */: - case 198 /* BindingElement */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 288 /* PropertyAssignment */: - case 289 /* ShorthandPropertyAssignment */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 287 /* CatchClause */: - case 280 /* JsxAttribute */: + case 162 /* Parameter */: + case 200 /* BindingElement */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 290 /* PropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 289 /* CatchClause */: + case 282 /* JsxAttribute */: return 1 /* Value */; - case 159 /* TypeParameter */: - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 177 /* TypeLiteral */: + case 161 /* TypeParameter */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 179 /* TypeLiteral */: return 2 /* Type */; - case 331 /* JSDocTypedefTag */: + case 339 /* 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 291 /* EnumMember */: - case 252 /* ClassDeclaration */: + case 293 /* EnumMember */: + case 254 /* ClassDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -115128,16 +119102,16 @@ var ts; else { return 4 /* Namespace */; } - case 255 /* EnumDeclaration */: - case 264 /* NamedImports */: - case 265 /* ImportSpecifier */: - case 260 /* ImportEqualsDeclaration */: - case 261 /* ImportDeclaration */: - case 266 /* ExportAssignment */: - case 267 /* ExportDeclaration */: + case 257 /* EnumDeclaration */: + case 266 /* NamedImports */: + case 267 /* ImportSpecifier */: + case 262 /* ImportEqualsDeclaration */: + case 263 /* ImportDeclaration */: + case 268 /* ExportAssignment */: + case 269 /* ExportDeclaration */: return 7 /* All */; // An external module can be a Value - case 297 /* SourceFile */: + case 299 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 7 /* All */; @@ -115145,13 +119119,13 @@ var ts; ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { node = getAdjustedReferenceLocation(node); - if (node.kind === 297 /* SourceFile */) { + if (node.kind === 299 /* SourceFile */) { return 1 /* Value */; } - else if (node.parent.kind === 266 /* ExportAssignment */ - || node.parent.kind === 272 /* ExternalModuleReference */ - || node.parent.kind === 265 /* ImportSpecifier */ - || node.parent.kind === 262 /* ImportClause */ + else if (node.parent.kind === 268 /* ExportAssignment */ + || node.parent.kind === 274 /* ExternalModuleReference */ + || node.parent.kind === 267 /* ImportSpecifier */ + || node.parent.kind === 264 /* ImportClause */ || ts.isImportEqualsDeclaration(node.parent) && node === node.parent.name) { return 7 /* All */; } @@ -115161,7 +119135,7 @@ var ts; else if (ts.isDeclarationName(node)) { return getMeaningFromDeclaration(node.parent); } - else if (ts.isEntityName(node) && ts.isJSDocNameReference(node.parent)) { + else if (ts.isEntityName(node) && ts.findAncestor(node, ts.or(ts.isJSDocNameReference, ts.isJSDocLinkLike, ts.isJSDocMemberName))) { return 7 /* All */; } else if (isTypeReference(node)) { @@ -115187,11 +119161,11 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - var name = node.kind === 157 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; - return name && name.parent.kind === 260 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; + var name = node.kind === 159 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; + return name && name.parent.kind === 262 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; } function isInRightSideOfInternalImportEqualsDeclaration(node) { - while (node.parent.kind === 157 /* QualifiedName */) { + while (node.parent.kind === 159 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -115203,27 +119177,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 157 /* QualifiedName */) { - while (root.parent && root.parent.kind === 157 /* QualifiedName */) { + if (root.parent.kind === 159 /* QualifiedName */) { + while (root.parent && root.parent.kind === 159 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 173 /* TypeReference */ && !isLastClause; + return root.parent.kind === 175 /* TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 201 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 201 /* PropertyAccessExpression */) { + if (root.parent.kind === 203 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 203 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 223 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 286 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 225 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 288 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 252 /* ClassDeclaration */ && root.parent.parent.token === 116 /* ImplementsKeyword */) || - (decl.kind === 253 /* InterfaceDeclaration */ && root.parent.parent.token === 93 /* ExtendsKeyword */); + return (decl.kind === 254 /* ClassDeclaration */ && root.parent.parent.token === 117 /* ImplementsKeyword */) || + (decl.kind === 255 /* InterfaceDeclaration */ && root.parent.parent.token === 94 /* ExtendsKeyword */); } return false; } @@ -115232,17 +119206,17 @@ var ts; node = node.parent; } switch (node.kind) { - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: return !ts.isExpressionNode(node); - case 187 /* ThisType */: + case 189 /* ThisType */: return true; } switch (node.parent.kind) { - case 173 /* TypeReference */: + case 175 /* TypeReference */: return true; - case 195 /* ImportType */: + case 197 /* ImportType */: return !node.parent.isTypeOf; - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: return !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent); } return false; @@ -115309,7 +119283,7 @@ var ts; ts.climbPastPropertyOrElementAccess = climbPastPropertyOrElementAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 245 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { + if (referenceNode.kind === 247 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -115370,22 +119344,22 @@ var ts; ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { switch (node.parent.kind) { - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 288 /* PropertyAssignment */: - case 291 /* EnumMember */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 256 /* ModuleDeclaration */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 290 /* PropertyAssignment */: + case 293 /* EnumMember */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 258 /* ModuleDeclaration */: return ts.getNameOfDeclaration(node.parent) === node; - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: return node.parent.argumentExpression === node; - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return true; - case 191 /* LiteralType */: - return node.parent.parent.kind === 189 /* IndexedAccessType */; + case 193 /* LiteralType */: + return node.parent.parent.kind === 191 /* IndexedAccessType */; default: return false; } @@ -115409,17 +119383,17 @@ var ts; return undefined; } switch (node.kind) { - case 297 /* SourceFile */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - case 256 /* ModuleDeclaration */: + case 299 /* SourceFile */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 257 /* EnumDeclaration */: + case 258 /* ModuleDeclaration */: return node; } } @@ -115427,54 +119401,54 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 297 /* SourceFile */: + case 299 /* SourceFile */: return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return "module" /* moduleElement */; - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: return "class" /* classElement */; - case 253 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; - case 254 /* TypeAliasDeclaration */: - case 324 /* JSDocCallbackTag */: - case 331 /* JSDocTypedefTag */: + case 255 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; + case 256 /* TypeAliasDeclaration */: + case 332 /* JSDocCallbackTag */: + case 339 /* JSDocTypedefTag */: return "type" /* typeElement */; - case 255 /* EnumDeclaration */: return "enum" /* enumElement */; - case 249 /* VariableDeclaration */: + case 257 /* EnumDeclaration */: return "enum" /* enumElement */; + case 251 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 198 /* BindingElement */: + case 200 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 209 /* ArrowFunction */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: return "function" /* functionElement */; - case 167 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; - case 168 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 169 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; + case 170 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: return "method" /* memberFunctionElement */; - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: var initializer = node.initializer; return ts.isFunctionLike(initializer) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */; - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 289 /* ShorthandPropertyAssignment */: - case 290 /* SpreadAssignment */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 291 /* ShorthandPropertyAssignment */: + case 292 /* SpreadAssignment */: return "property" /* memberVariableElement */; - case 171 /* IndexSignature */: return "index" /* indexSignatureElement */; - case 170 /* ConstructSignature */: return "construct" /* constructSignatureElement */; - case 169 /* CallSignature */: return "call" /* callSignatureElement */; - case 166 /* Constructor */: return "constructor" /* constructorImplementationElement */; - case 159 /* TypeParameter */: return "type parameter" /* typeParameterElement */; - case 291 /* EnumMember */: return "enum member" /* enumMemberElement */; - case 160 /* Parameter */: return ts.hasSyntacticModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; - case 260 /* ImportEqualsDeclaration */: - case 265 /* ImportSpecifier */: - case 270 /* ExportSpecifier */: - case 263 /* NamespaceImport */: - case 269 /* NamespaceExport */: + case 173 /* IndexSignature */: return "index" /* indexSignatureElement */; + case 172 /* ConstructSignature */: return "construct" /* constructSignatureElement */; + case 171 /* CallSignature */: return "call" /* callSignatureElement */; + case 168 /* Constructor */: return "constructor" /* constructorImplementationElement */; + case 161 /* TypeParameter */: return "type parameter" /* typeParameterElement */; + case 293 /* EnumMember */: return "enum member" /* enumMemberElement */; + case 162 /* Parameter */: return ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; + case 262 /* ImportEqualsDeclaration */: + case 267 /* ImportSpecifier */: + case 272 /* ExportSpecifier */: + case 265 /* NamespaceImport */: + case 271 /* NamespaceExport */: return "alias" /* alias */; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: var kind = ts.getAssignmentDeclarationKind(node); var right = node.right; switch (kind) { @@ -115501,9 +119475,9 @@ var ts; return "" /* unknown */; } } - case 78 /* Identifier */: + case 79 /* Identifier */: return ts.isImportClause(node.parent) ? "alias" /* alias */ : "" /* unknown */; - case 266 /* ExportAssignment */: + case 268 /* 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; @@ -115521,12 +119495,12 @@ var ts; ts.getNodeKind = getNodeKind; function isThis(node) { switch (node.kind) { - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: // case SyntaxKind.ThisType: TODO: GH#9267 return true; - case 78 /* Identifier */: + case 79 /* Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 160 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 162 /* Parameter */; default: return false; } @@ -115591,42 +119565,42 @@ var ts; return false; } switch (n.kind) { - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - case 200 /* ObjectLiteralExpression */: - case 196 /* ObjectBindingPattern */: - case 177 /* TypeLiteral */: - case 230 /* Block */: - case 257 /* ModuleBlock */: - case 258 /* CaseBlock */: - case 264 /* NamedImports */: - case 268 /* NamedExports */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 257 /* EnumDeclaration */: + case 202 /* ObjectLiteralExpression */: + case 198 /* ObjectBindingPattern */: + case 179 /* TypeLiteral */: + case 232 /* Block */: + case 259 /* ModuleBlock */: + case 260 /* CaseBlock */: + case 266 /* NamedImports */: + case 270 /* NamedExports */: return nodeEndsWith(n, 19 /* CloseBraceToken */, sourceFile); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 204 /* NewExpression */: + case 206 /* NewExpression */: if (!n.arguments) { return true; } // falls through - case 203 /* CallExpression */: - case 207 /* ParenthesizedExpression */: - case 186 /* ParenthesizedType */: + case 205 /* CallExpression */: + case 209 /* ParenthesizedExpression */: + case 188 /* ParenthesizedType */: return nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile); - case 174 /* FunctionType */: - case 175 /* ConstructorType */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 170 /* ConstructSignature */: - case 169 /* CallSignature */: - case 209 /* ArrowFunction */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 172 /* ConstructSignature */: + case 171 /* CallSignature */: + case 211 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -115636,65 +119610,65 @@ 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 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return !!n.body && isCompletedNode(n.body, sourceFile); - case 234 /* IfStatement */: + case 236 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 26 /* SemicolonToken */, sourceFile); - case 199 /* ArrayLiteralExpression */: - case 197 /* ArrayBindingPattern */: - case 202 /* ElementAccessExpression */: - case 158 /* ComputedPropertyName */: - case 179 /* TupleType */: + case 201 /* ArrayLiteralExpression */: + case 199 /* ArrayBindingPattern */: + case 204 /* ElementAccessExpression */: + case 160 /* ComputedPropertyName */: + case 181 /* TupleType */: return nodeEndsWith(n, 23 /* CloseBracketToken */, sourceFile); - case 171 /* IndexSignature */: + case 173 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 23 /* CloseBracketToken */, sourceFile); - case 284 /* CaseClause */: - case 285 /* DefaultClause */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 236 /* WhileStatement */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 238 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 235 /* DoStatement */: + case 237 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; - return hasChildOfKind(n, 114 /* WhileKeyword */, sourceFile) + return hasChildOfKind(n, 115 /* WhileKeyword */, sourceFile) ? nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile) : isCompletedNode(n.statement, sourceFile); - case 176 /* TypeQuery */: + case 178 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 211 /* TypeOfExpression */: - case 210 /* DeleteExpression */: - case 212 /* VoidExpression */: - case 219 /* YieldExpression */: - case 220 /* SpreadElement */: + case 213 /* TypeOfExpression */: + case 212 /* DeleteExpression */: + case 214 /* VoidExpression */: + case 221 /* YieldExpression */: + case 222 /* SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 218 /* TemplateExpression */: + case 220 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 228 /* TemplateSpan */: + case 230 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 267 /* ExportDeclaration */: - case 261 /* ImportDeclaration */: + case 269 /* ExportDeclaration */: + case 263 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -115754,13 +119728,13 @@ var ts; } ts.findContainingList = findContainingList; function isDefaultModifier(node) { - return node.kind === 87 /* DefaultKeyword */; + return node.kind === 88 /* DefaultKeyword */; } function isClassKeyword(node) { - return node.kind === 83 /* ClassKeyword */; + return node.kind === 84 /* ClassKeyword */; } function isFunctionKeyword(node) { - return node.kind === 97 /* FunctionKeyword */; + return node.kind === 98 /* FunctionKeyword */; } function getAdjustedLocationForClass(node) { if (ts.isNamedDeclaration(node)) { @@ -115820,11 +119794,11 @@ var ts; function getAdjustedLocationForDeclaration(node, forRename) { if (!forRename) { switch (node.kind) { - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: return getAdjustedLocationForClass(node); - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: return getAdjustedLocationForFunction(node); } } @@ -115914,30 +119888,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 !== 87 /* DefaultKeyword */) ? ts.contains(parent.modifiers, node) : - node.kind === 83 /* ClassKeyword */ ? ts.isClassDeclaration(parent) || ts.isClassExpression(node) : - node.kind === 97 /* FunctionKeyword */ ? ts.isFunctionDeclaration(parent) || ts.isFunctionExpression(node) : - node.kind === 117 /* InterfaceKeyword */ ? ts.isInterfaceDeclaration(parent) : - node.kind === 91 /* EnumKeyword */ ? ts.isEnumDeclaration(parent) : - node.kind === 149 /* TypeKeyword */ ? ts.isTypeAliasDeclaration(parent) : - node.kind === 140 /* NamespaceKeyword */ || node.kind === 139 /* ModuleKeyword */ ? ts.isModuleDeclaration(parent) : - node.kind === 99 /* ImportKeyword */ ? ts.isImportEqualsDeclaration(parent) : - node.kind === 134 /* GetKeyword */ ? ts.isGetAccessorDeclaration(parent) : - node.kind === 146 /* SetKeyword */ && ts.isSetAccessorDeclaration(parent)) { + if (ts.isModifier(node) && (forRename || node.kind !== 88 /* DefaultKeyword */) ? 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 === 150 /* TypeKeyword */ ? ts.isTypeAliasDeclaration(parent) : + node.kind === 141 /* NamespaceKeyword */ || node.kind === 140 /* ModuleKeyword */ ? ts.isModuleDeclaration(parent) : + node.kind === 100 /* ImportKeyword */ ? ts.isImportEqualsDeclaration(parent) : + node.kind === 135 /* GetKeyword */ ? ts.isGetAccessorDeclaration(parent) : + node.kind === 147 /* SetKeyword */ && ts.isSetAccessorDeclaration(parent)) { var location = getAdjustedLocationForDeclaration(parent, forRename); if (location) { return location; } } // /**/ [|name|] ... - if ((node.kind === 112 /* VarKeyword */ || node.kind === 84 /* ConstKeyword */ || node.kind === 118 /* LetKeyword */) && + if ((node.kind === 113 /* VarKeyword */ || node.kind === 85 /* ConstKeyword */ || node.kind === 119 /* LetKeyword */) && ts.isVariableDeclarationList(parent) && parent.declarations.length === 1) { var decl = parent.declarations[0]; if (ts.isIdentifier(decl.name)) { return decl.name; } } - if (node.kind === 149 /* TypeKeyword */) { + if (node.kind === 150 /* TypeKeyword */) { // import /**/type [|name|] from ...; // import /**/type { [|name|] } from ...; // import /**/type { propertyName as [|name|] } from ...; @@ -115963,7 +119937,7 @@ var ts; // import * /**/as [|name|] ... // export { propertyName /**/as [|name|] } ... // export * /**/as [|name|] ... - if (node.kind === 126 /* AsKeyword */) { + if (node.kind === 127 /* AsKeyword */) { if (ts.isImportSpecifier(parent) && parent.propertyName || ts.isExportSpecifier(parent) && parent.propertyName || ts.isNamespaceImport(parent) || @@ -115979,13 +119953,13 @@ var ts; // /**/import { propertyName as [|name|] } from ...; // /**/import ... from "[|module|]"; // /**/import "[|module|]"; - if (node.kind === 99 /* ImportKeyword */ && ts.isImportDeclaration(parent)) { + if (node.kind === 100 /* ImportKeyword */ && ts.isImportDeclaration(parent)) { var location = getAdjustedLocationForImportDeclaration(parent, forRename); if (location) { return location; } } - if (node.kind === 92 /* ExportKeyword */) { + if (node.kind === 93 /* ExportKeyword */) { // /**/export { [|name|] } ...; // /**/export { propertyName as [|name|] } ...; // /**/export * from "[|module|]"; @@ -116004,12 +119978,12 @@ var ts; } } // import name = /**/require("[|module|]"); - if (node.kind === 143 /* RequireKeyword */ && ts.isExternalModuleReference(parent)) { + if (node.kind === 144 /* RequireKeyword */ && ts.isExternalModuleReference(parent)) { return parent.expression; } // import ... /**/from "[|module|]"; // export ... /**/from "[|module|]"; - if (node.kind === 153 /* FromKeyword */ && (ts.isImportDeclaration(parent) || ts.isExportDeclaration(parent)) && parent.moduleSpecifier) { + if (node.kind === 154 /* FromKeyword */ && (ts.isImportDeclaration(parent) || ts.isExportDeclaration(parent)) && parent.moduleSpecifier) { return parent.moduleSpecifier; } // class ... /**/extends [|name|] ... @@ -116017,13 +119991,13 @@ var ts; // class ... /**/implements name1, name2 ... // interface ... /**/extends [|name|] ... // interface ... /**/extends name1, name2 ... - if ((node.kind === 93 /* ExtendsKeyword */ || node.kind === 116 /* ImplementsKeyword */) && ts.isHeritageClause(parent) && parent.token === node.kind) { + if ((node.kind === 94 /* ExtendsKeyword */ || node.kind === 117 /* ImplementsKeyword */) && ts.isHeritageClause(parent) && parent.token === node.kind) { var location = getAdjustedLocationForHeritageClause(parent); if (location) { return location; } } - if (node.kind === 93 /* ExtendsKeyword */) { + if (node.kind === 94 /* ExtendsKeyword */) { // ... ... if (ts.isTypeParameterDeclaration(parent) && parent.constraint && ts.isTypeReferenceNode(parent.constraint)) { return parent.constraint.typeName; @@ -116034,20 +120008,20 @@ var ts; } } // ... T extends /**/infer [|U|] ? ... - if (node.kind === 135 /* InferKeyword */ && ts.isInferTypeNode(parent)) { + if (node.kind === 136 /* InferKeyword */ && ts.isInferTypeNode(parent)) { return parent.typeParameter.name; } // { [ [|K|] /**/in keyof T]: ... } - if (node.kind === 100 /* InKeyword */ && ts.isTypeParameterDeclaration(parent) && ts.isMappedTypeNode(parent.parent)) { + if (node.kind === 101 /* InKeyword */ && ts.isTypeParameterDeclaration(parent) && ts.isMappedTypeNode(parent.parent)) { return parent.name; } // /**/keyof [|T|] - if (node.kind === 138 /* KeyOfKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 138 /* KeyOfKeyword */ && + if (node.kind === 139 /* KeyOfKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 139 /* KeyOfKeyword */ && ts.isTypeReferenceNode(parent.type)) { return parent.type.typeName; } // /**/readonly [|name|][] - if (node.kind === 142 /* ReadonlyKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 142 /* ReadonlyKeyword */ && + if (node.kind === 143 /* ReadonlyKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 143 /* ReadonlyKeyword */ && ts.isArrayTypeNode(parent.type) && ts.isTypeReferenceNode(parent.type.elementType)) { return parent.type.elementType.typeName; } @@ -116062,29 +120036,29 @@ var ts; // /**/yield [|name|] // /**/yield obj.[|name|] // /**/delete obj.[|name|] - if (node.kind === 102 /* NewKeyword */ && ts.isNewExpression(parent) || - node.kind === 113 /* VoidKeyword */ && ts.isVoidExpression(parent) || - node.kind === 111 /* TypeOfKeyword */ && ts.isTypeOfExpression(parent) || - node.kind === 130 /* AwaitKeyword */ && ts.isAwaitExpression(parent) || - node.kind === 124 /* YieldKeyword */ && ts.isYieldExpression(parent) || - node.kind === 88 /* DeleteKeyword */ && ts.isDeleteExpression(parent)) { + if (node.kind === 103 /* NewKeyword */ && ts.isNewExpression(parent) || + node.kind === 114 /* VoidKeyword */ && ts.isVoidExpression(parent) || + node.kind === 112 /* TypeOfKeyword */ && ts.isTypeOfExpression(parent) || + node.kind === 131 /* AwaitKeyword */ && ts.isAwaitExpression(parent) || + node.kind === 125 /* YieldKeyword */ && ts.isYieldExpression(parent) || + node.kind === 89 /* DeleteKeyword */ && ts.isDeleteExpression(parent)) { if (parent.expression) { return ts.skipOuterExpressions(parent.expression); } } // left /**/in [|name|] // left /**/instanceof [|name|] - if ((node.kind === 100 /* InKeyword */ || node.kind === 101 /* InstanceOfKeyword */) && ts.isBinaryExpression(parent) && parent.operatorToken === node) { + if ((node.kind === 101 /* InKeyword */ || node.kind === 102 /* InstanceOfKeyword */) && ts.isBinaryExpression(parent) && parent.operatorToken === node) { return ts.skipOuterExpressions(parent.right); } // left /**/as [|name|] - if (node.kind === 126 /* AsKeyword */ && ts.isAsExpression(parent) && ts.isTypeReferenceNode(parent.type)) { + if (node.kind === 127 /* AsKeyword */ && ts.isAsExpression(parent) && ts.isTypeReferenceNode(parent.type)) { return parent.type.typeName; } // for (... /**/in [|name|]) // for (... /**/of [|name|]) - if (node.kind === 100 /* InKeyword */ && ts.isForInStatement(parent) || - node.kind === 156 /* OfKeyword */ && ts.isForOfStatement(parent)) { + if (node.kind === 101 /* InKeyword */ && ts.isForInStatement(parent) || + node.kind === 158 /* OfKeyword */ && ts.isForOfStatement(parent)) { return ts.skipOuterExpressions(parent.expression); } } @@ -116153,6 +120127,21 @@ var ts; return current; } } + /** + * Returns the first token where position is in [start, end), + * excluding `JsxText` tokens containing only whitespace. + */ + function findFirstNonJsxWhitespaceToken(sourceFile, position) { + var tokenAtPosition = getTokenAtPosition(sourceFile, position); + while (isWhiteSpaceOnlyJsxText(tokenAtPosition)) { + var nextToken = findNextToken(tokenAtPosition, tokenAtPosition.parent, sourceFile); + if (!nextToken) + return; + tokenAtPosition = nextToken; + } + return tokenAtPosition; + } + ts.findFirstNonJsxWhitespaceToken = findFirstNonJsxWhitespaceToken; /** * The token on the left of the position is the token that strictly includes the position * or sits to the left of the cursor if it is on a boundary. For example @@ -116239,7 +120228,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 297 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); + ts.Debug.assert(startNode !== undefined || n.kind === 299 /* SourceFile */ || n.kind === 1 /* 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. @@ -116312,17 +120301,17 @@ var ts; return true; } //
{ |
or
- if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 283 /* JsxExpression */) { + if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 285 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 283 /* JsxExpression */) { + if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 285 /* JsxExpression */) { return true; } //
|
- if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 276 /* JsxClosingElement */) { + if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 278 /* JsxClosingElement */) { return true; } return false; @@ -116353,17 +120342,17 @@ var ts; function isInsideJsxElement(sourceFile, position) { function isInsideJsxElementTraversal(node) { while (node) { - if (node.kind >= 274 /* JsxSelfClosingElement */ && node.kind <= 283 /* JsxExpression */ + if (node.kind >= 276 /* JsxSelfClosingElement */ && node.kind <= 285 /* JsxExpression */ || node.kind === 11 /* JsxText */ || node.kind === 29 /* LessThanToken */ || node.kind === 31 /* GreaterThanToken */ - || node.kind === 78 /* Identifier */ + || node.kind === 79 /* Identifier */ || node.kind === 19 /* CloseBraceToken */ || node.kind === 18 /* OpenBraceToken */ || node.kind === 43 /* SlashToken */) { node = node.parent; } - else if (node.kind === 273 /* JsxElement */) { + else if (node.kind === 275 /* JsxElement */) { if (position > node.getStart(sourceFile)) return true; node = node.parent; @@ -116502,16 +120491,16 @@ var ts; break; case 38 /* EqualsGreaterThanToken */: // falls through - case 78 /* Identifier */: + case 79 /* Identifier */: case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: // falls through - case 111 /* TypeOfKeyword */: - case 93 /* ExtendsKeyword */: - case 138 /* KeyOfKeyword */: + case 112 /* TypeOfKeyword */: + case 94 /* ExtendsKeyword */: + case 139 /* KeyOfKeyword */: case 24 /* DotToken */: case 51 /* BarToken */: case 57 /* QuestionToken */: @@ -116571,16 +120560,16 @@ var ts; result.push("deprecated" /* deprecatedModifier */); if (node.flags & 8388608 /* Ambient */) result.push("declare" /* ambientModifier */); - if (node.kind === 266 /* ExportAssignment */) + if (node.kind === 268 /* ExportAssignment */) result.push("export" /* exportedModifier */); return result.length > 0 ? result.join(",") : "" /* none */; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 173 /* TypeReference */ || node.kind === 203 /* CallExpression */) { + if (node.kind === 175 /* TypeReference */ || node.kind === 205 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 252 /* ClassDeclaration */ || node.kind === 253 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 254 /* ClassDeclaration */ || node.kind === 255 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; @@ -116600,7 +120589,7 @@ var ts; } ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; function isPunctuation(kind) { - return 18 /* FirstPunctuation */ <= kind && kind <= 77 /* LastPunctuation */; + return 18 /* FirstPunctuation */ <= kind && kind <= 78 /* LastPunctuation */; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position, sourceFile) { @@ -116610,9 +120599,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 122 /* PublicKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: + case 123 /* PublicKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: return true; } return false; @@ -116625,18 +120614,18 @@ var ts; } ts.cloneCompilerOptions = cloneCompilerOptions; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 199 /* ArrayLiteralExpression */ || - node.kind === 200 /* ObjectLiteralExpression */) { + if (node.kind === 201 /* ArrayLiteralExpression */ || + node.kind === 202 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 216 /* BinaryExpression */ && + if (node.parent.kind === 218 /* BinaryExpression */ && node.parent.left === node && - node.parent.operatorToken.kind === 62 /* EqualsToken */) { + node.parent.operatorToken.kind === 63 /* EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 239 /* ForOfStatement */ && + if (node.parent.kind === 241 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -116644,7 +120633,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 288 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 290 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -116706,32 +120695,32 @@ var ts; } ts.createTextChange = createTextChange; ts.typeKeywords = [ - 128 /* AnyKeyword */, - 127 /* AssertsKeyword */, - 155 /* BigIntKeyword */, - 131 /* BooleanKeyword */, - 94 /* FalseKeyword */, - 135 /* InferKeyword */, - 138 /* KeyOfKeyword */, - 141 /* NeverKeyword */, - 103 /* NullKeyword */, - 144 /* NumberKeyword */, - 145 /* ObjectKeyword */, - 142 /* ReadonlyKeyword */, - 147 /* StringKeyword */, - 148 /* SymbolKeyword */, - 109 /* TrueKeyword */, - 113 /* VoidKeyword */, - 150 /* UndefinedKeyword */, - 151 /* UniqueKeyword */, - 152 /* UnknownKeyword */, + 129 /* AnyKeyword */, + 128 /* AssertsKeyword */, + 156 /* BigIntKeyword */, + 132 /* BooleanKeyword */, + 95 /* FalseKeyword */, + 136 /* InferKeyword */, + 139 /* KeyOfKeyword */, + 142 /* NeverKeyword */, + 104 /* NullKeyword */, + 145 /* NumberKeyword */, + 146 /* ObjectKeyword */, + 143 /* ReadonlyKeyword */, + 148 /* StringKeyword */, + 149 /* SymbolKeyword */, + 110 /* TrueKeyword */, + 114 /* VoidKeyword */, + 151 /* UndefinedKeyword */, + 152 /* UniqueKeyword */, + 153 /* UnknownKeyword */, ]; function isTypeKeyword(kind) { return ts.contains(ts.typeKeywords, kind); } ts.isTypeKeyword = isTypeKeyword; function isTypeKeywordToken(node) { - return node.kind === 149 /* TypeKeyword */; + return node.kind === 150 /* TypeKeyword */; } ts.isTypeKeywordToken = isTypeKeywordToken; /** True if the symbol is for an external module, as opposed to a namespace. */ @@ -116764,7 +120753,7 @@ var ts; } ts.skipConstraint = skipConstraint; function getNameFromPropertyName(name) { - return name.kind === 158 /* ComputedPropertyName */ + return name.kind === 160 /* 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); @@ -116783,7 +120772,7 @@ var ts; } ts.compilerOptionsIndicateEs6Modules = compilerOptionsIndicateEs6Modules; function createModuleSpecifierResolutionHost(program, host) { - // Mix in `getProbableSymlinks` from Program when host doesn't have it + // Mix in `getSymlinkCache` from Program when host doesn't have it // in order for non-Project hosts to have a symlinks cache. return { fileExists: function (fileName) { return program.fileExists(fileName); }, @@ -116791,6 +120780,7 @@ var ts; readFile: ts.maybeBind(host, host.readFile), useCaseSensitiveFileNames: ts.maybeBind(host, host.useCaseSensitiveFileNames), getSymlinkCache: ts.maybeBind(host, host.getSymlinkCache) || program.getSymlinkCache, + getModuleSpecifierCache: ts.maybeBind(host, host.getModuleSpecifierCache), getGlobalTypingsCacheLocation: ts.maybeBind(host, host.getGlobalTypingsCacheLocation), getSourceFiles: function () { return program.getSourceFiles(); }, redirectTargetsMap: program.redirectTargetsMap, @@ -116861,10 +120851,17 @@ var ts; } return ts.firstDefined(symbol.declarations, function (decl) { var name = ts.getNameOfDeclaration(decl); - return name && name.kind === 78 /* Identifier */ ? name.escapedText : undefined; + return name && name.kind === 79 /* Identifier */ ? name.escapedText : undefined; }); } ts.symbolEscapedNameNoDefault = symbolEscapedNameNoDefault; + function isModuleSpecifierLike(node) { + return ts.isStringLiteralLike(node) && (ts.isExternalModuleReference(node.parent) || + ts.isImportDeclaration(node.parent) || + ts.isRequireCall(node.parent, /*requireStringLiteralLikeArgument*/ false) && node.parent.arguments[0] === node || + ts.isImportCall(node.parent) && node.parent.arguments[0] === node); + } + ts.isModuleSpecifierLike = isModuleSpecifierLike; function isObjectBindingElementWithoutPropertyName(bindingElement) { return ts.isBindingElement(bindingElement) && ts.isObjectBindingPattern(bindingElement.parent) && @@ -116898,7 +120895,7 @@ var ts; ts.findModifier = findModifier; function insertImports(changes, sourceFile, imports, blankLineBetween) { var decl = ts.isArray(imports) ? imports[0] : imports; - var importKindPredicate = decl.kind === 232 /* VariableStatement */ ? ts.isRequireVariableStatement : ts.isAnyImportSyntax; + var importKindPredicate = decl.kind === 234 /* 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) { @@ -116976,7 +120973,7 @@ var ts; // Display-part writer helpers // #region function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 160 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 162 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -117024,7 +121021,7 @@ var ts; increaseIndent: function () { indent++; }, decreaseIndent: function () { indent--; }, clear: resetWriter, - trackSymbol: ts.noop, + trackSymbol: function () { return false; }, reportInaccessibleThisError: ts.noop, reportInaccessibleUniqueSymbolError: ts.noop, reportPrivateInBaseOfClassExpression: ts.noop, @@ -117139,6 +121136,14 @@ var ts; return displayPart(ts.tokenToString(kind), ts.SymbolDisplayPartKind.operator); } ts.operatorPart = operatorPart; + function parameterNamePart(text) { + return displayPart(text, ts.SymbolDisplayPartKind.parameterName); + } + ts.parameterNamePart = parameterNamePart; + function propertyNamePart(text) { + return displayPart(text, ts.SymbolDisplayPartKind.propertyName); + } + ts.propertyNamePart = propertyNamePart; function textOrKeywordPart(text) { var kind = ts.stringToToken(text); return kind === undefined @@ -117150,6 +121155,61 @@ var ts; return displayPart(text, ts.SymbolDisplayPartKind.text); } ts.textPart = textPart; + function typeAliasNamePart(text) { + return displayPart(text, ts.SymbolDisplayPartKind.aliasName); + } + ts.typeAliasNamePart = typeAliasNamePart; + function typeParameterNamePart(text) { + return displayPart(text, ts.SymbolDisplayPartKind.typeParameterName); + } + ts.typeParameterNamePart = typeParameterNamePart; + function linkTextPart(text) { + return displayPart(text, ts.SymbolDisplayPartKind.linkText); + } + ts.linkTextPart = linkTextPart; + function linkNamePart(name, target) { + return { + text: ts.getTextOfNode(name), + kind: ts.SymbolDisplayPartKind[ts.SymbolDisplayPartKind.linkName], + target: { + fileName: ts.getSourceFileOfNode(target).fileName, + textSpan: createTextSpanFromNode(target), + }, + }; + } + ts.linkNamePart = linkNamePart; + function linkPart(text) { + return displayPart(text, ts.SymbolDisplayPartKind.link); + } + ts.linkPart = linkPart; + function buildLinkParts(link, checker) { + var _a; + var prefix = ts.isJSDocLink(link) ? "link" + : ts.isJSDocLinkCode(link) ? "linkcode" + : "linkplain"; + var parts = [linkPart("{@" + prefix + " ")]; + if (!link.name) { + if (link.text) { + parts.push(linkTextPart(link.text)); + } + } + else { + var symbol = checker === null || checker === void 0 ? void 0 : checker.getSymbolAtLocation(link.name); + var decl = (symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration) || ((_a = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]); + if (decl) { + parts.push(linkNamePart(link.name, decl)); + if (link.text) { + parts.push(linkTextPart(link.text)); + } + } + else { + parts.push(linkTextPart(ts.getTextOfNode(link.name) + " " + link.text)); + } + } + parts.push(linkPart("}")); + return parts; + } + ts.buildLinkParts = buildLinkParts; var carriageReturnLineFeed = "\r\n"; /** * The default is CRLF. @@ -117435,21 +121495,23 @@ var ts; } /* @internal */ function needsParentheses(expression) { - return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 27 /* CommaToken */ || ts.isObjectLiteralExpression(expression); + return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 27 /* CommaToken */ + || ts.isObjectLiteralExpression(expression) + || ts.isAsExpression(expression) && ts.isObjectLiteralExpression(expression.expression); } ts.needsParentheses = needsParentheses; function getContextualTypeFromParent(node, checker) { var parent = node.parent; switch (parent.kind) { - case 204 /* NewExpression */: + case 206 /* NewExpression */: return checker.getContextualType(parent); - case 216 /* BinaryExpression */: { + case 218 /* 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 284 /* CaseClause */: + case 286 /* CaseClause */: return parent.expression === node ? getSwitchedType(parent, checker) : undefined; default: return checker.getContextualType(node); @@ -117460,7 +121522,7 @@ 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("'", "\\'").replace('\\"', '"') + "'" : quoted; + return quotePreference === 0 /* Single */ ? "'" + ts.stripQuotes(quoted).replace(/'/g, "\\'").replace(/\\"/g, '"') + "'" : quoted; } ts.quote = quote; function isEqualityOperatorKind(kind) { @@ -117479,8 +121541,8 @@ var ts; switch (node.kind) { case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 218 /* TemplateExpression */: - case 205 /* TaggedTemplateExpression */: + case 220 /* TemplateExpression */: + case 207 /* TaggedTemplateExpression */: return true; default: return false; @@ -117503,6 +121565,7 @@ var ts; var res = checker.typeToTypeNode(type, enclosingScope, 1 /* NoTruncation */, { trackSymbol: function (symbol, declaration, meaning) { typeIsAccessible = typeIsAccessible && checker.isSymbolAccessible(symbol, declaration, meaning, /*shouldComputeAliasToMarkVisible*/ false).accessibility === 0 /* Accessible */; + return !typeIsAccessible; }, reportInaccessibleThisError: notAccessible, reportPrivateInBaseOfClassExpression: notAccessible, @@ -117513,41 +121576,41 @@ var ts; } ts.getTypeNodeIfAccessible = getTypeNodeIfAccessible; function syntaxRequiresTrailingCommaOrSemicolonOrASI(kind) { - return kind === 169 /* CallSignature */ - || kind === 170 /* ConstructSignature */ - || kind === 171 /* IndexSignature */ - || kind === 162 /* PropertySignature */ - || kind === 164 /* MethodSignature */; + return kind === 171 /* CallSignature */ + || kind === 172 /* ConstructSignature */ + || kind === 173 /* IndexSignature */ + || kind === 164 /* PropertySignature */ + || kind === 166 /* MethodSignature */; } ts.syntaxRequiresTrailingCommaOrSemicolonOrASI = syntaxRequiresTrailingCommaOrSemicolonOrASI; function syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI(kind) { - return kind === 251 /* FunctionDeclaration */ - || kind === 166 /* Constructor */ - || kind === 165 /* MethodDeclaration */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */; + return kind === 253 /* FunctionDeclaration */ + || kind === 168 /* Constructor */ + || kind === 167 /* MethodDeclaration */ + || kind === 169 /* GetAccessor */ + || kind === 170 /* SetAccessor */; } ts.syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI = syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI; function syntaxRequiresTrailingModuleBlockOrSemicolonOrASI(kind) { - return kind === 256 /* ModuleDeclaration */; + return kind === 258 /* ModuleDeclaration */; } ts.syntaxRequiresTrailingModuleBlockOrSemicolonOrASI = syntaxRequiresTrailingModuleBlockOrSemicolonOrASI; function syntaxRequiresTrailingSemicolonOrASI(kind) { - return kind === 232 /* VariableStatement */ - || kind === 233 /* ExpressionStatement */ - || kind === 235 /* DoStatement */ - || kind === 240 /* ContinueStatement */ - || kind === 241 /* BreakStatement */ - || kind === 242 /* ReturnStatement */ - || kind === 246 /* ThrowStatement */ - || kind === 248 /* DebuggerStatement */ - || kind === 163 /* PropertyDeclaration */ - || kind === 254 /* TypeAliasDeclaration */ - || kind === 261 /* ImportDeclaration */ - || kind === 260 /* ImportEqualsDeclaration */ - || kind === 267 /* ExportDeclaration */ - || kind === 259 /* NamespaceExportDeclaration */ - || kind === 266 /* ExportAssignment */; + return kind === 234 /* VariableStatement */ + || kind === 235 /* ExpressionStatement */ + || kind === 237 /* DoStatement */ + || kind === 242 /* ContinueStatement */ + || kind === 243 /* BreakStatement */ + || kind === 244 /* ReturnStatement */ + || kind === 248 /* ThrowStatement */ + || kind === 250 /* DebuggerStatement */ + || kind === 165 /* PropertyDeclaration */ + || kind === 256 /* TypeAliasDeclaration */ + || kind === 263 /* ImportDeclaration */ + || kind === 262 /* ImportEqualsDeclaration */ + || kind === 269 /* ExportDeclaration */ + || kind === 261 /* NamespaceExportDeclaration */ + || kind === 268 /* ExportAssignment */; } ts.syntaxRequiresTrailingSemicolonOrASI = syntaxRequiresTrailingSemicolonOrASI; ts.syntaxMayBeASICandidate = ts.or(syntaxRequiresTrailingCommaOrSemicolonOrASI, syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI, syntaxRequiresTrailingModuleBlockOrSemicolonOrASI, syntaxRequiresTrailingSemicolonOrASI); @@ -117577,7 +121640,7 @@ var ts; return false; } // See comment in parser’s `parseDoStatement` - if (node.kind === 235 /* DoStatement */) { + if (node.kind === 237 /* DoStatement */) { return true; } var topNode = ts.findAncestor(node, function (ancestor) { return !ancestor.parent; }); @@ -117751,6 +121814,94 @@ var ts; } } ts.createPackageJsonInfo = createPackageJsonInfo; + function createPackageJsonImportFilter(fromFile, host) { + var packageJsons = ((host.getPackageJsonsVisibleToFile && host.getPackageJsonsVisibleToFile(fromFile.fileName)) || getPackageJsonsVisibleToFile(fromFile.fileName, host)).filter(function (p) { return p.parseable; }); + var usesNodeCoreModules; + return { allowsImportingAmbientModule: allowsImportingAmbientModule, allowsImportingSourceFile: allowsImportingSourceFile, allowsImportingSpecifier: allowsImportingSpecifier }; + function moduleSpecifierIsCoveredByPackageJson(specifier) { + var packageName = getNodeModuleRootSpecifier(specifier); + for (var _i = 0, packageJsons_1 = packageJsons; _i < packageJsons_1.length; _i++) { + var packageJson = packageJsons_1[_i]; + if (packageJson.has(packageName) || packageJson.has(ts.getTypesPackageName(packageName))) { + return true; + } + } + return false; + } + function allowsImportingAmbientModule(moduleSymbol, moduleSpecifierResolutionHost) { + if (!packageJsons.length || !moduleSymbol.valueDeclaration) { + return true; + } + var declaringSourceFile = moduleSymbol.valueDeclaration.getSourceFile(); + var declaringNodeModuleName = getNodeModulesPackageNameFromFileName(declaringSourceFile.fileName, moduleSpecifierResolutionHost); + if (typeof declaringNodeModuleName === "undefined") { + return true; + } + var declaredModuleSpecifier = ts.stripQuotes(moduleSymbol.getName()); + if (isAllowedCoreNodeModulesImport(declaredModuleSpecifier)) { + return true; + } + return moduleSpecifierIsCoveredByPackageJson(declaringNodeModuleName) + || moduleSpecifierIsCoveredByPackageJson(declaredModuleSpecifier); + } + function allowsImportingSourceFile(sourceFile, moduleSpecifierResolutionHost) { + if (!packageJsons.length) { + return true; + } + var moduleSpecifier = getNodeModulesPackageNameFromFileName(sourceFile.fileName, moduleSpecifierResolutionHost); + if (!moduleSpecifier) { + return true; + } + return moduleSpecifierIsCoveredByPackageJson(moduleSpecifier); + } + function allowsImportingSpecifier(moduleSpecifier) { + if (!packageJsons.length || isAllowedCoreNodeModulesImport(moduleSpecifier)) { + return true; + } + if (ts.pathIsRelative(moduleSpecifier) || ts.isRootedDiskPath(moduleSpecifier)) { + return true; + } + return moduleSpecifierIsCoveredByPackageJson(moduleSpecifier); + } + function isAllowedCoreNodeModulesImport(moduleSpecifier) { + // If we’re in JavaScript, it can be difficult to tell whether the user wants to import + // from Node core modules or not. We can start by seeing if the user is actually using + // any node core modules, as opposed to simply having @types/node accidentally as a + // dependency of a dependency. + if (ts.isSourceFileJS(fromFile) && ts.JsTyping.nodeCoreModules.has(moduleSpecifier)) { + if (usesNodeCoreModules === undefined) { + usesNodeCoreModules = consumesNodeCoreModules(fromFile); + } + if (usesNodeCoreModules) { + return true; + } + } + return false; + } + function getNodeModulesPackageNameFromFileName(importedFileName, moduleSpecifierResolutionHost) { + if (!ts.stringContains(importedFileName, "node_modules")) { + return undefined; + } + var specifier = ts.moduleSpecifiers.getNodeModulesPackageName(host.getCompilationSettings(), fromFile.path, importedFileName, moduleSpecifierResolutionHost); + if (!specifier) { + return undefined; + } + // Paths here are not node_modules, so we don’t care about them; + // returning anything will trigger a lookup in package.json. + if (!ts.pathIsRelative(specifier) && !ts.isRootedDiskPath(specifier)) { + return getNodeModuleRootSpecifier(specifier); + } + } + function getNodeModuleRootSpecifier(fullSpecifier) { + var components = ts.getPathComponents(ts.getPackageNameFromTypesPackageName(fullSpecifier)).slice(1); + // Scoped packages + if (ts.startsWith(components[0], "@")) { + return components[0] + "/" + components[1]; + } + return components[0]; + } + } + ts.createPackageJsonImportFilter = createPackageJsonImportFilter; function tryParseJson(text) { try { return JSON.parse(text); @@ -117827,9 +121978,9 @@ var ts; } ts.firstOrOnly = firstOrOnly; function getNameForExportedSymbol(symbol, scriptTarget) { - if (symbol.escapedName === "export=" /* ExportEquals */ || symbol.escapedName === "default" /* Default */) { + if (!(symbol.flags & 33554432 /* Transient */) && (symbol.escapedName === "export=" /* ExportEquals */ || symbol.escapedName === "default" /* Default */)) { // Name of "export default foo;" is "foo". Name of "export default 0" is the filename converted to camelCase. - return ts.firstDefined(symbol.declarations, function (d) { return ts.isExportAssignment(d) && ts.isIdentifier(d.expression) ? d.expression.text : undefined; }) + 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; }) || ts.codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget); } return symbol.name; @@ -117893,6 +122044,188 @@ var ts; return ts.isInJSFile(declaration) || !ts.findAncestor(declaration, ts.isGlobalScopeAugmentation); } ts.isNonGlobalDeclaration = isNonGlobalDeclaration; + var ImportKind; + (function (ImportKind) { + ImportKind[ImportKind["Named"] = 0] = "Named"; + ImportKind[ImportKind["Default"] = 1] = "Default"; + ImportKind[ImportKind["Namespace"] = 2] = "Namespace"; + ImportKind[ImportKind["CommonJS"] = 3] = "CommonJS"; + })(ImportKind = ts.ImportKind || (ts.ImportKind = {})); + var ExportKind; + (function (ExportKind) { + ExportKind[ExportKind["Named"] = 0] = "Named"; + ExportKind[ExportKind["Default"] = 1] = "Default"; + ExportKind[ExportKind["ExportEquals"] = 2] = "ExportEquals"; + ExportKind[ExportKind["UMD"] = 3] = "UMD"; + })(ExportKind = ts.ExportKind || (ts.ExportKind = {})); + function createExportMapCache() { + var cache; + var projectVersion; + var usableByFileName; + var wrapped = { + isEmpty: function () { + return !cache; + }, + clear: function () { + cache = undefined; + projectVersion = undefined; + }, + set: function (suggestions, version) { + cache = suggestions; + if (version) { + projectVersion = version; + } + }, + get: function (file, checker, version) { + if (usableByFileName && file !== usableByFileName) { + return undefined; + } + if (version && projectVersion === version) { + return cache; + } + cache === null || cache === void 0 ? void 0 : cache.forEach(function (infos) { + var _a, _b, _c; + for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) { + var info = infos_1[_i]; + // If the symbol/moduleSymbol was a merged symbol, it will have a new identity + // in the checker, even though the symbols to merge are the same (guaranteed by + // cache invalidation in synchronizeHostData). + if ((_a = info.symbol.declarations) === null || _a === void 0 ? void 0 : _a.length) { + info.symbol = checker.getMergedSymbol(info.exportKind === 1 /* Default */ + ? (_b = info.symbol.declarations[0].localSymbol) !== null && _b !== void 0 ? _b : info.symbol.declarations[0].symbol + : info.symbol.declarations[0].symbol); + } + if ((_c = info.moduleSymbol.declarations) === null || _c === void 0 ? void 0 : _c.length) { + info.moduleSymbol = checker.getMergedSymbol(info.moduleSymbol.declarations[0].symbol); + } + } + }); + return cache; + }, + onFileChanged: function (oldSourceFile, newSourceFile, typeAcquisitionEnabled) { + if (fileIsGlobalOnly(oldSourceFile) && fileIsGlobalOnly(newSourceFile)) { + // File is purely global; doesn't affect export map + return false; + } + if (usableByFileName && usableByFileName !== newSourceFile.path || + // If ATA is enabled, auto-imports uses existing imports to guess whether you want auto-imports from node. + // Adding or removing imports from node could change the outcome of that guess, so could change the suggestions list. + typeAcquisitionEnabled && consumesNodeCoreModules(oldSourceFile) !== consumesNodeCoreModules(newSourceFile) || + // Module agumentation and ambient module changes can add or remove exports available to be auto-imported. + // Changes elsewhere in the file can change the *type* of an export in a module augmentation, + // but type info is gathered in getCompletionEntryDetails, which doesn’t use the cache. + !ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations) || + !ambientModuleDeclarationsAreEqual(oldSourceFile, newSourceFile)) { + this.clear(); + return true; + } + usableByFileName = newSourceFile.path; + return false; + }, + }; + if (ts.Debug.isDebugging) { + Object.defineProperty(wrapped, "__cache", { get: function () { return cache; } }); + } + return wrapped; + function fileIsGlobalOnly(file) { + return !file.commonJsModuleIndicator && !file.externalModuleIndicator && !file.moduleAugmentations && !file.ambientModuleNames; + } + function ambientModuleDeclarationsAreEqual(oldSourceFile, newSourceFile) { + if (!ts.arrayIsEqualTo(oldSourceFile.ambientModuleNames, newSourceFile.ambientModuleNames)) { + return false; + } + var oldFileStatementIndex = -1; + var newFileStatementIndex = -1; + var _loop_1 = function (ambientModuleName) { + var isMatchingModuleDeclaration = function (node) { return ts.isNonGlobalAmbientModule(node) && node.name.text === ambientModuleName; }; + oldFileStatementIndex = ts.findIndex(oldSourceFile.statements, isMatchingModuleDeclaration, oldFileStatementIndex + 1); + newFileStatementIndex = ts.findIndex(newSourceFile.statements, isMatchingModuleDeclaration, newFileStatementIndex + 1); + if (oldSourceFile.statements[oldFileStatementIndex] !== newSourceFile.statements[newFileStatementIndex]) { + return { value: false }; + } + }; + for (var _i = 0, _a = newSourceFile.ambientModuleNames; _i < _a.length; _i++) { + var ambientModuleName = _a[_i]; + var state_1 = _loop_1(ambientModuleName); + if (typeof state_1 === "object") + return state_1.value; + } + return true; + } + } + ts.createExportMapCache = createExportMapCache; + function createModuleSpecifierCache() { + var cache; + var importingFileName; + var wrapped = { + get: function (fromFileName, toFileName) { + if (!cache || fromFileName !== importingFileName) + return undefined; + return cache.get(toFileName); + }, + set: function (fromFileName, toFileName, moduleSpecifiers) { + if (cache && fromFileName !== importingFileName) { + cache.clear(); + } + importingFileName = fromFileName; + (cache || (cache = new ts.Map())).set(toFileName, moduleSpecifiers); + }, + clear: function () { + cache = undefined; + importingFileName = undefined; + }, + count: function () { + return cache ? cache.size : 0; + } + }; + if (ts.Debug.isDebugging) { + Object.defineProperty(wrapped, "__cache", { get: function () { return cache; } }); + } + return wrapped; + } + ts.createModuleSpecifierCache = createModuleSpecifierCache; + function isImportableFile(program, from, to, packageJsonFilter, moduleSpecifierResolutionHost, moduleSpecifierCache) { + var _a; + if (from === to) + return false; + var cachedResult = moduleSpecifierCache === null || moduleSpecifierCache === void 0 ? void 0 : moduleSpecifierCache.get(from.path, to.path); + if (cachedResult !== undefined) { + return !!cachedResult; + } + var getCanonicalFileName = ts.hostGetCanonicalFileName(moduleSpecifierResolutionHost); + var globalTypingsCache = (_a = moduleSpecifierResolutionHost.getGlobalTypingsCacheLocation) === null || _a === void 0 ? void 0 : _a.call(moduleSpecifierResolutionHost); + var hasImportablePath = !!ts.moduleSpecifiers.forEachFileNameOfModule(from.fileName, to.fileName, moduleSpecifierResolutionHost, + /*preferSymlinks*/ false, function (toPath) { + var toFile = program.getSourceFile(toPath); + // Determine to import using toPath only if toPath is what we were looking at + // or there doesnt exist the file in the program by the symlink + return (toFile === to || !toFile) && + isImportablePath(from.fileName, toPath, getCanonicalFileName, globalTypingsCache); + }); + if (packageJsonFilter) { + var isImportable = hasImportablePath && packageJsonFilter.allowsImportingSourceFile(to, moduleSpecifierResolutionHost); + moduleSpecifierCache === null || moduleSpecifierCache === void 0 ? void 0 : moduleSpecifierCache.set(from.path, to.path, isImportable); + return isImportable; + } + return hasImportablePath; + } + ts.isImportableFile = isImportableFile; + /** + * Don't include something from a `node_modules` that isn't actually reachable by a global import. + * A relative import to node_modules is usually a bad idea. + */ + function isImportablePath(fromPath, toPath, getCanonicalFileName, globalCachePath) { + // If it's in a `node_modules` but is not reachable from here via a global import, don't bother. + var toNodeModules = ts.forEachAncestorDirectory(toPath, function (ancestor) { return ts.getBaseFileName(ancestor) === "node_modules" ? ancestor : undefined; }); + var toNodeModulesParent = toNodeModules && ts.getDirectoryPath(getCanonicalFileName(toNodeModules)); + return toNodeModulesParent === undefined + || ts.startsWith(getCanonicalFileName(fromPath), toNodeModulesParent) + || (!!globalCachePath && ts.startsWith(getCanonicalFileName(globalCachePath), toNodeModulesParent)); + } + function isDeprecatedDeclaration(decl) { + return !!(ts.getCombinedNodeFlagsAlwaysIncludeJSDoc(decl) & 8192 /* Deprecated */); + } + ts.isDeprecatedDeclaration = isDeprecatedDeclaration; // #endregion })(ts || (ts = {})); var ts; @@ -117976,13 +122309,13 @@ var ts; function handleToken() { switch (token) { case 43 /* SlashToken */: - case 67 /* SlashEqualsToken */: + case 68 /* SlashEqualsToken */: if (!noRegexTable[lastNonTriviaToken] && scanner.reScanSlashToken() === 13 /* RegularExpressionLiteral */) { token = 13 /* RegularExpressionLiteral */; } break; case 29 /* LessThanToken */: - if (lastNonTriviaToken === 78 /* Identifier */) { + if (lastNonTriviaToken === 79 /* 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++; @@ -117995,16 +122328,16 @@ var ts; angleBracketStack--; } break; - case 128 /* AnyKeyword */: - case 147 /* StringKeyword */: - case 144 /* NumberKeyword */: - case 131 /* BooleanKeyword */: - case 148 /* SymbolKeyword */: + case 129 /* AnyKeyword */: + case 148 /* StringKeyword */: + case 145 /* NumberKeyword */: + case 132 /* BooleanKeyword */: + case 149 /* 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 = 78 /* Identifier */; + token = 79 /* Identifier */; } break; case 15 /* TemplateHead */: @@ -118043,14 +122376,14 @@ var ts; break; } if (lastNonTriviaToken === 24 /* DotToken */) { - token = 78 /* Identifier */; + token = 79 /* 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 = 78 /* Identifier */; + token = 79 /* Identifier */; } } } @@ -118064,19 +122397,19 @@ 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([ - 78 /* Identifier */, + 79 /* Identifier */, 10 /* StringLiteral */, 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 13 /* RegularExpressionLiteral */, - 107 /* ThisKeyword */, + 108 /* ThisKeyword */, 45 /* PlusPlusToken */, 46 /* MinusMinusToken */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 19 /* CloseBraceToken */, - 109 /* TrueKeyword */, - 94 /* FalseKeyword */, + 110 /* TrueKeyword */, + 95 /* FalseKeyword */, ], function (token) { return token; }, function () { return true; }); function getNewEndOfLineState(scanner, token, lastOnTemplateStack) { switch (token) { @@ -118188,10 +122521,10 @@ var ts; return true; } switch (keyword2) { - case 134 /* GetKeyword */: - case 146 /* SetKeyword */: - case 132 /* ConstructorKeyword */: - case 123 /* StaticKeyword */: + case 135 /* GetKeyword */: + case 147 /* SetKeyword */: + case 133 /* ConstructorKeyword */: + case 124 /* 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. @@ -118236,9 +122569,9 @@ var ts; case 31 /* GreaterThanToken */: case 32 /* LessThanEqualsToken */: case 33 /* GreaterThanEqualsToken */: - case 101 /* InstanceOfKeyword */: - case 100 /* InKeyword */: - case 126 /* AsKeyword */: + case 102 /* InstanceOfKeyword */: + case 101 /* InKeyword */: + case 127 /* AsKeyword */: case 34 /* EqualsEqualsToken */: case 35 /* ExclamationEqualsToken */: case 36 /* EqualsEqualsEqualsToken */: @@ -118248,23 +122581,23 @@ var ts; case 51 /* BarToken */: case 55 /* AmpersandAmpersandToken */: case 56 /* BarBarToken */: - case 73 /* BarEqualsToken */: - case 72 /* AmpersandEqualsToken */: - case 77 /* CaretEqualsToken */: - case 69 /* LessThanLessThanEqualsToken */: - case 70 /* GreaterThanGreaterThanEqualsToken */: - case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 63 /* PlusEqualsToken */: - case 64 /* MinusEqualsToken */: - case 65 /* AsteriskEqualsToken */: - case 67 /* SlashEqualsToken */: - case 68 /* PercentEqualsToken */: - case 62 /* EqualsToken */: + 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 74 /* BarBarEqualsToken */: - case 75 /* AmpersandAmpersandEqualsToken */: - case 76 /* QuestionQuestionEqualsToken */: + case 75 /* BarBarEqualsToken */: + case 76 /* AmpersandAmpersandEqualsToken */: + case 77 /* QuestionQuestionEqualsToken */: return true; default: return false; @@ -118290,7 +122623,7 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5 /* operator */; } - else if (token >= 18 /* FirstPunctuation */ && token <= 77 /* LastPunctuation */) { + else if (token >= 18 /* FirstPunctuation */ && token <= 78 /* LastPunctuation */) { return 10 /* punctuation */; } switch (token) { @@ -118309,7 +122642,7 @@ var ts; case 5 /* WhitespaceTrivia */: case 4 /* NewLineTrivia */: return 8 /* whiteSpace */; - case 78 /* Identifier */: + case 79 /* Identifier */: default: if (ts.isTemplateLiteralKind(token)) { return 6 /* stringLiteral */; @@ -118334,13 +122667,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 256 /* ModuleDeclaration */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 251 /* FunctionDeclaration */: - case 221 /* ClassExpression */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 258 /* ModuleDeclaration */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 253 /* FunctionDeclaration */: + case 223 /* ClassExpression */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } } @@ -118547,10 +122880,11 @@ var ts; pushClassification(start, width, 1 /* comment */); } function classifyJSDocComment(docComment) { + var _a, _b, _c, _d, _e, _f, _g; var pos = docComment.pos; if (docComment.tags) { - for (var _i = 0, _a = docComment.tags; _i < _a.length; _i++) { - var tag = _a[_i]; + for (var _i = 0, _h = docComment.tags; _i < _h.length; _i++) { + var tag = _h[_i]; // As we walk through each tag, classify the portion of text from the end of // the last tag (or the start of the entire doc comment) as 'comment'. if (tag.pos !== pos) { @@ -118559,22 +122893,56 @@ var ts; pushClassification(tag.pos, 1, 10 /* punctuation */); // "@" pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); // e.g. "param" pos = tag.tagName.end; + var commentStart = tag.tagName.end; switch (tag.kind) { - case 326 /* JSDocParameterTag */: - processJSDocParameterTag(tag); + case 334 /* 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 330 /* JSDocTemplateTag */: + case 341 /* JSDocPropertyTag */: + var prop = tag; + commentStart = prop.isNameFirst && ((_b = prop.typeExpression) === null || _b === void 0 ? void 0 : _b.end) || prop.name.end; + break; + case 338 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); pos = tag.end; + commentStart = tag.typeParameters.end; + break; + case 339 /* JSDocTypedefTag */: + var type = tag; + commentStart = ((_c = type.typeExpression) === null || _c === void 0 ? void 0 : _c.kind) === 303 /* 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 329 /* JSDocTypeTag */: + case 332 /* JSDocCallbackTag */: + commentStart = tag.typeExpression.end; + break; + case 337 /* JSDocTypeTag */: processElement(tag.typeExpression); pos = tag.end; + commentStart = tag.typeExpression.end; + break; + case 336 /* JSDocThisTag */: + case 333 /* JSDocEnumTag */: + commentStart = tag.typeExpression.end; break; - case 327 /* JSDocReturnTag */: + case 335 /* JSDocReturnTag */: processElement(tag.typeExpression); pos = tag.end; + commentStart = ((_f = tag.typeExpression) === null || _f === void 0 ? void 0 : _f.end) || commentStart; break; + case 340 /* JSDocSeeTag */: + commentStart = ((_g = tag.name) === null || _g === void 0 ? void 0 : _g.end) || commentStart; + break; + case 322 /* JSDocAugmentsTag */: + case 323 /* JSDocImplementsTag */: + commentStart = tag.class.end; + break; + } + if (typeof tag.comment === "object") { + pushCommentRange(tag.comment.pos, tag.comment.end - tag.comment.pos); + } + else if (typeof tag.comment === "string") { + pushCommentRange(commentStart, tag.end - commentStart); } } } @@ -118602,7 +122970,8 @@ var ts; } function tryClassifyTripleSlashComment(start, width) { var tripleSlashXMLCommentRegEx = /^(\/\/\/\s*)(<)(?:(\S+)((?:[^/]|\/[^>])*)(\/>)?)?/im; - var attributeRegex = /(\S+)(\s*)(=)(\s*)('[^']+'|"[^"]+")/img; + // Require a leading whitespace character (the parser already does) to prevent terrible backtracking performance + var attributeRegex = /(\s)(\S+)(\s*)(=)(\s*)('[^']+'|"[^"]+")/img; var text = sourceFile.text.substr(start, width); var match = tripleSlashXMLCommentRegEx.exec(text); if (!match) { @@ -118630,25 +122999,25 @@ var ts; if (!attrMatch) { break; } - var newAttrPos = pos + attrMatch.index; + var newAttrPos = pos + attrMatch.index + attrMatch[1].length; // whitespace if (newAttrPos > attrPos) { pushCommentRange(attrPos, newAttrPos - attrPos); attrPos = newAttrPos; } - pushClassification(attrPos, attrMatch[1].length, 22 /* jsxAttribute */); // attribute name - attrPos += attrMatch[1].length; - if (attrMatch[2].length) { - pushCommentRange(attrPos, attrMatch[2].length); // whitespace - attrPos += attrMatch[2].length; + pushClassification(attrPos, attrMatch[2].length, 22 /* jsxAttribute */); // attribute name + attrPos += attrMatch[2].length; + if (attrMatch[3].length) { + pushCommentRange(attrPos, attrMatch[3].length); // whitespace + attrPos += attrMatch[3].length; } - pushClassification(attrPos, attrMatch[3].length, 5 /* operator */); // = - attrPos += attrMatch[3].length; - if (attrMatch[4].length) { - pushCommentRange(attrPos, attrMatch[4].length); // whitespace - attrPos += attrMatch[4].length; + pushClassification(attrPos, attrMatch[4].length, 5 /* operator */); // = + attrPos += attrMatch[4].length; + if (attrMatch[5].length) { + pushCommentRange(attrPos, attrMatch[5].length); // whitespace + attrPos += attrMatch[5].length; } - pushClassification(attrPos, attrMatch[5].length, 24 /* jsxAttributeStringLiteralValue */); // attribute value - attrPos += attrMatch[5].length; + pushClassification(attrPos, attrMatch[6].length, 24 /* jsxAttributeStringLiteralValue */); // attribute value + attrPos += attrMatch[6].length; } pos += match[4].length; if (pos > attrPos) { @@ -118722,22 +123091,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 275 /* JsxOpeningElement */: + case 277 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 276 /* JsxClosingElement */: + case 278 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 274 /* JsxSelfClosingElement */: + case 276 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 280 /* JsxAttribute */: + case 282 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -118764,19 +123133,19 @@ var ts; if (ts.isPunctuation(tokenKind)) { if (token) { var parent = token.parent; - if (tokenKind === 62 /* EqualsToken */) { + if (tokenKind === 63 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (parent.kind === 249 /* VariableDeclaration */ || - parent.kind === 163 /* PropertyDeclaration */ || - parent.kind === 160 /* Parameter */ || - parent.kind === 280 /* JsxAttribute */) { + if (parent.kind === 251 /* VariableDeclaration */ || + parent.kind === 165 /* PropertyDeclaration */ || + parent.kind === 162 /* Parameter */ || + parent.kind === 282 /* JsxAttribute */) { return 5 /* operator */; } } - if (parent.kind === 216 /* BinaryExpression */ || - parent.kind === 214 /* PrefixUnaryExpression */ || - parent.kind === 215 /* PostfixUnaryExpression */ || - parent.kind === 217 /* ConditionalExpression */) { + if (parent.kind === 218 /* BinaryExpression */ || + parent.kind === 216 /* PrefixUnaryExpression */ || + parent.kind === 217 /* PostfixUnaryExpression */ || + parent.kind === 219 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -118789,7 +123158,7 @@ var ts; return 25 /* bigintLiteral */; } else if (tokenKind === 10 /* StringLiteral */) { - return token && token.parent.kind === 280 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + return token && token.parent.kind === 282 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } else if (tokenKind === 13 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. @@ -118802,35 +123171,35 @@ var ts; else if (tokenKind === 11 /* JsxText */) { return 23 /* jsxText */; } - else if (tokenKind === 78 /* Identifier */) { + else if (tokenKind === 79 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 159 /* TypeParameter */: + case 161 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 253 /* InterfaceDeclaration */: + case 255 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 160 /* Parameter */: + case 162 /* Parameter */: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; } @@ -118932,13 +123301,13 @@ var ts; var inJSXElement = false; function visit(node) { switch (node.kind) { - case 256 /* ModuleDeclaration */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 251 /* FunctionDeclaration */: - case 221 /* ClassExpression */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 258 /* ModuleDeclaration */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 253 /* FunctionDeclaration */: + case 223 /* ClassExpression */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } if (!node || !ts.textSpanIntersectsWith(span, node.pos, node.getFullWidth()) || node.getFullWidth() === 0) { @@ -119084,25 +123453,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([ - [249 /* VariableDeclaration */, 7 /* variable */], - [160 /* Parameter */, 6 /* parameter */], - [163 /* PropertyDeclaration */, 9 /* property */], - [256 /* ModuleDeclaration */, 3 /* namespace */], - [255 /* EnumDeclaration */, 1 /* enum */], - [291 /* EnumMember */, 8 /* enumMember */], - [252 /* ClassDeclaration */, 0 /* class */], - [165 /* MethodDeclaration */, 11 /* member */], - [251 /* FunctionDeclaration */, 10 /* function */], - [208 /* FunctionExpression */, 10 /* function */], - [164 /* MethodSignature */, 11 /* member */], - [167 /* GetAccessor */, 9 /* property */], - [168 /* SetAccessor */, 9 /* property */], - [162 /* PropertySignature */, 9 /* property */], - [253 /* InterfaceDeclaration */, 2 /* interface */], - [254 /* TypeAliasDeclaration */, 5 /* type */], - [159 /* TypeParameter */, 4 /* typeParameter */], - [288 /* PropertyAssignment */, 9 /* property */], - [289 /* ShorthandPropertyAssignment */, 9 /* property */] + [251 /* VariableDeclaration */, 7 /* variable */], + [162 /* Parameter */, 6 /* parameter */], + [165 /* PropertyDeclaration */, 9 /* property */], + [258 /* ModuleDeclaration */, 3 /* namespace */], + [257 /* EnumDeclaration */, 1 /* enum */], + [293 /* EnumMember */, 8 /* enumMember */], + [254 /* ClassDeclaration */, 0 /* class */], + [167 /* MethodDeclaration */, 11 /* member */], + [253 /* FunctionDeclaration */, 10 /* function */], + [210 /* FunctionExpression */, 10 /* function */], + [166 /* MethodSignature */, 11 /* member */], + [169 /* GetAccessor */, 9 /* property */], + [170 /* SetAccessor */, 9 /* property */], + [164 /* PropertySignature */, 9 /* property */], + [255 /* InterfaceDeclaration */, 2 /* interface */], + [256 /* TypeAliasDeclaration */, 5 /* type */], + [161 /* TypeParameter */, 4 /* typeParameter */], + [290 /* PropertyAssignment */, 9 /* property */], + [291 /* ShorthandPropertyAssignment */, 9 /* property */] ]); })(v2020 = classifier.v2020 || (classifier.v2020 = {})); })(classifier = ts.classifier || (ts.classifier = {})); @@ -119122,12 +123491,12 @@ var ts; if (ts.isInString(sourceFile, position, contextToken)) { if (!contextToken || !ts.isStringLiteralLike(contextToken)) return undefined; - var entries = getStringLiteralCompletionEntries(sourceFile, contextToken, position, checker, options, host); - return convertStringLiteralCompletions(entries, contextToken, sourceFile, checker, log, preferences); + var entries = getStringLiteralCompletionEntries(sourceFile, contextToken, position, checker, options, host, preferences); + return convertStringLiteralCompletions(entries, contextToken, sourceFile, checker, log, options, preferences); } } StringCompletions.getStringLiteralCompletions = getStringLiteralCompletions; - function convertStringLiteralCompletions(completion, contextToken, sourceFile, checker, log, preferences) { + function convertStringLiteralCompletions(completion, contextToken, sourceFile, checker, log, options, preferences) { if (completion === undefined) { return undefined; } @@ -119137,7 +123506,7 @@ var ts; return convertPathCompletions(completion.paths); case 1 /* Properties */: { var entries = []; - Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, sourceFile, sourceFile, checker, 99 /* ESNext */, log, 4 /* String */, preferences); // Target will not be used, so arbitrary + Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, sourceFile, sourceFile, checker, 99 /* ESNext */, log, 4 /* String */, preferences, options); // Target will not be used, so arbitrary return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: completion.hasIndexSignature, optionalReplacementSpan: optionalReplacementSpan, entries: entries }; } case 2 /* Types */: { @@ -119154,10 +123523,10 @@ var ts; return ts.Debug.assertNever(completion); } } - function getStringLiteralCompletionDetails(name, sourceFile, position, contextToken, checker, options, host, cancellationToken) { + function getStringLiteralCompletionDetails(name, sourceFile, position, contextToken, checker, options, host, cancellationToken, preferences) { if (!contextToken || !ts.isStringLiteralLike(contextToken)) return undefined; - var completions = getStringLiteralCompletionEntries(sourceFile, contextToken, position, checker, options, host); + var completions = getStringLiteralCompletionEntries(sourceFile, contextToken, position, checker, options, host, preferences); return completions && stringLiteralCompletionDetails(name, contextToken, completions, sourceFile, checker, cancellationToken); } StringCompletions.getStringLiteralCompletionDetails = getStringLiteralCompletionDetails; @@ -119206,13 +123575,13 @@ var ts; StringLiteralCompletionKind[StringLiteralCompletionKind["Properties"] = 1] = "Properties"; StringLiteralCompletionKind[StringLiteralCompletionKind["Types"] = 2] = "Types"; })(StringLiteralCompletionKind || (StringLiteralCompletionKind = {})); - function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host) { + function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host, preferences) { var parent = walkUpParentheses(node.parent); switch (parent.kind) { - case 191 /* LiteralType */: { + case 193 /* LiteralType */: { var grandParent = walkUpParentheses(parent.parent); switch (grandParent.kind) { - case 173 /* TypeReference */: { + case 175 /* TypeReference */: { var typeReference_1 = grandParent; var typeArgument = ts.findAncestor(parent, function (n) { return n.parent === typeReference_1; }); if (typeArgument) { @@ -119220,7 +123589,7 @@ var ts; } return undefined; } - case 189 /* IndexedAccessType */: + case 191 /* IndexedAccessType */: // Get all apparent property names // i.e. interface Foo { // foo: string; @@ -119232,9 +123601,9 @@ var ts; return undefined; } return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(objectType)); - case 195 /* ImportType */: - return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) }; - case 182 /* UnionType */: { + case 197 /* ImportType */: + return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) }; + case 184 /* UnionType */: { if (!ts.isTypeReferenceNode(grandParent.parent)) { return undefined; } @@ -119246,7 +123615,7 @@ var ts; return undefined; } } - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: if (ts.isObjectLiteralExpression(parent.parent) && parent.name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { @@ -119263,7 +123632,7 @@ var ts; return stringLiteralCompletionsForObjectLiteral(typeChecker, parent.parent); } return fromContextualType(); - case 202 /* ElementAccessExpression */: { + case 204 /* ElementAccessExpression */: { var _b = parent, expression = _b.expression, argumentExpression = _b.argumentExpression; if (node === ts.skipParentheses(argumentExpression)) { // Get all names of properties on the expression @@ -119276,8 +123645,8 @@ var ts; } return undefined; } - case 203 /* CallExpression */: - case 204 /* NewExpression */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: if (!ts.isRequireCall(parent, /*checkArgumentIsStringLiteralLike*/ false) && !ts.isImportCall(parent)) { var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(node, position, sourceFile); // Get string literal completions from specialized signatures of the target @@ -119286,16 +123655,16 @@ var ts; return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo, typeChecker) : fromContextualType(); } // falls through (is `require("")` or `import("")`) - case 261 /* ImportDeclaration */: - case 267 /* ExportDeclaration */: - case 272 /* ExternalModuleReference */: + case 263 /* ImportDeclaration */: + case 269 /* ExportDeclaration */: + case 274 /* 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) }; + return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) }; default: return fromContextualType(); } @@ -119307,9 +123676,9 @@ var ts; } function walkUpParentheses(node) { switch (node.kind) { - case 186 /* ParenthesizedType */: + case 188 /* ParenthesizedType */: return ts.walkUpParenthesizedTypes(node); - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return ts.walkUpParenthesizedExpressions(node); default: return node; @@ -119337,7 +123706,7 @@ var ts; function stringLiteralCompletionsFromProperties(type) { return type && { kind: 1 /* Properties */, - symbols: ts.filter(type.getApparentProperties(), function (prop) { return !(prop.valueDeclaration && ts.isPrivateIdentifierPropertyDeclaration(prop.valueDeclaration)); }), + symbols: ts.filter(type.getApparentProperties(), function (prop) { return !(prop.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(prop.valueDeclaration)); }), hasIndexSignature: ts.hasIndexSignature(type) }; } @@ -119375,23 +123744,23 @@ var ts; return Math.max(name.indexOf(ts.directorySeparator), name.indexOf(ts.altDirectorySeparator)) !== -1 ? { name: name, kind: kind, extension: extension, span: wholeSpan } : { name: name, kind: kind, extension: extension, span: span }; }); } - function getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) { - return addReplacementSpans(node.text, node.getStart(sourceFile) + 1, getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker)); + function getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) { + return addReplacementSpans(node.text, node.getStart(sourceFile) + 1, getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker, preferences)); } - function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker) { + function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker, preferences) { var literalValue = ts.normalizeSlashes(node.text); 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) + ? getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, preferences) : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, compilerOptions, host, typeChecker); } function getExtensionOptions(compilerOptions, includeExtensions) { if (includeExtensions === void 0) { includeExtensions = false; } return { extensions: getSupportedExtensionsForModuleResolution(compilerOptions), includeExtensions: includeExtensions }; } - function getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath) { - var extensionOptions = getExtensionOptions(compilerOptions); + function getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, preferences) { + var extensionOptions = getExtensionOptions(compilerOptions, preferences.importModuleSpecifierEnding === "js"); if (compilerOptions.rootDirs) { return getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, extensionOptions, compilerOptions, host, scriptPath); } @@ -119508,7 +123877,7 @@ var ts; continue; var patterns = paths[path]; if (patterns) { - var _loop_1 = function (name, kind, extension) { + var _loop_2 = function (name, kind, extension) { // Path mappings may provide a duplicate way to get to something we've already added, so don't add again. if (!result.some(function (entry) { return entry.name === name; })) { result.push(nameAndKind(name, kind, extension)); @@ -119516,7 +123885,7 @@ var ts; }; for (var _i = 0, _a = getCompletionsForPathMapping(path, patterns, fragment, baseDirectory, fileExtensions, host); _i < _a.length; _i++) { var _b = _a[_i], name = _b.name, kind = _b.kind, extension = _b.extension; - _loop_1(name, kind, extension); + _loop_2(name, kind, extension); } } } @@ -119551,7 +123920,7 @@ var ts; // (But do if we didn't find anything, e.g. 'package.json' missing.) var foundGlobal = false; if (fragmentDirectory === undefined) { - var _loop_2 = function (moduleName) { + 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)); @@ -119559,7 +123928,7 @@ var ts; }; for (var _b = 0, _c = enumerateNodeModulesVisibleToScript(host, scriptPath); _b < _c.length; _b++) { var moduleName = _c[_b]; - _loop_2(moduleName); + _loop_3(moduleName); } } if (!foundGlobal) { @@ -119594,8 +123963,8 @@ var ts; if (!host.readDirectory) { return undefined; } - var parsed = ts.hasZeroOrOneAsteriskCharacter(pattern) ? ts.tryParsePattern(pattern) : undefined; - if (!parsed) { + var parsed = ts.tryParsePattern(pattern); + if (parsed === undefined || ts.isString(parsed)) { return undefined; } // The prefix has two effective parts: the directory path and the base component after the filepath that is not a @@ -119782,7 +124151,26 @@ var ts; SortText["GlobalsOrKeywords"] = "5"; SortText["AutoImportSuggestions"] = "6"; SortText["JavascriptIdentifiers"] = "7"; + SortText["DeprecatedLocalDeclarationPriority"] = "8"; + SortText["DeprecatedLocationPriority"] = "9"; + SortText["DeprecatedOptionalMember"] = "10"; + SortText["DeprecatedMemberDeclaredBySpreadAssignment"] = "11"; + SortText["DeprecatedSuggestedClassMembers"] = "12"; + SortText["DeprecatedGlobalsOrKeywords"] = "13"; + SortText["DeprecatedAutoImportSuggestions"] = "14"; })(SortText = Completions.SortText || (Completions.SortText = {})); + var SortTextId; + (function (SortTextId) { + SortTextId[SortTextId["LocalDeclarationPriority"] = 0] = "LocalDeclarationPriority"; + SortTextId[SortTextId["LocationPriority"] = 1] = "LocationPriority"; + SortTextId[SortTextId["OptionalMember"] = 2] = "OptionalMember"; + SortTextId[SortTextId["MemberDeclaredBySpreadAssignment"] = 3] = "MemberDeclaredBySpreadAssignment"; + SortTextId[SortTextId["SuggestedClassMembers"] = 4] = "SuggestedClassMembers"; + SortTextId[SortTextId["GlobalsOrKeywords"] = 5] = "GlobalsOrKeywords"; + SortTextId[SortTextId["AutoImportSuggestions"] = 6] = "AutoImportSuggestions"; + })(SortTextId || (SortTextId = {})); + // for JavaScript identifiers since they are preferred over deprecated symbols + var DeprecatedSortTextStart = SortTextId.AutoImportSuggestions + 2; /** * Special values for `CompletionInfo['source']` used to disambiguate * completion items with the same `name`. (Each completion item must @@ -119806,6 +124194,7 @@ var ts; SymbolOriginInfoKind[SymbolOriginInfoKind["Export"] = 4] = "Export"; SymbolOriginInfoKind[SymbolOriginInfoKind["Promise"] = 8] = "Promise"; SymbolOriginInfoKind[SymbolOriginInfoKind["Nullable"] = 16] = "Nullable"; + SymbolOriginInfoKind[SymbolOriginInfoKind["ResolvedExport"] = 32] = "ResolvedExport"; SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberNoExport"] = 2] = "SymbolMemberNoExport"; SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberExport"] = 6] = "SymbolMemberExport"; })(SymbolOriginInfoKind || (SymbolOriginInfoKind = {})); @@ -119818,8 +124207,14 @@ var ts; function originIsExport(origin) { return !!(origin && origin.kind & 4 /* Export */); } + function originIsResolvedExport(origin) { + return !!(origin && origin.kind === 32 /* ResolvedExport */); + } + function originIncludesSymbolName(origin) { + return originIsExport(origin) || originIsResolvedExport(origin); + } function originIsPackageJsonImport(origin) { - return originIsExport(origin) && !!origin.isFromPackageJson; + return (originIsExport(origin) || originIsResolvedExport(origin)) && !!origin.isFromPackageJson; } function originIsPromise(origin) { return !!(origin.kind & 8 /* Promise */); @@ -119845,52 +124240,6 @@ var ts; GlobalsSearch[GlobalsSearch["Success"] = 1] = "Success"; GlobalsSearch[GlobalsSearch["Fail"] = 2] = "Fail"; })(GlobalsSearch || (GlobalsSearch = {})); - function createImportSuggestionsForFileCache() { - var cache; - var projectVersion; - var fileName; - return { - isEmpty: function () { - return !cache; - }, - clear: function () { - cache = undefined; - fileName = undefined; - projectVersion = undefined; - }, - set: function (file, suggestions, version) { - cache = suggestions; - fileName = file; - if (version) { - projectVersion = version; - } - }, - get: function (file, checker, version) { - if (file !== fileName) { - return undefined; - } - if (version) { - return projectVersion === version ? cache : undefined; - } - ts.forEach(cache, function (suggestion) { - var _a, _b, _c; - // If the symbol/moduleSymbol was a merged symbol, it will have a new identity - // in the checker, even though the symbols to merge are the same (guaranteed by - // cache invalidation in synchronizeHostData). - if ((_a = suggestion.symbol.declarations) === null || _a === void 0 ? void 0 : _a.length) { - suggestion.symbol = checker.getMergedSymbol(suggestion.origin.isDefaultExport - ? (_b = suggestion.symbol.declarations[0].localSymbol) !== null && _b !== void 0 ? _b : suggestion.symbol.declarations[0].symbol - : suggestion.symbol.declarations[0].symbol); - } - if ((_c = suggestion.origin.moduleSymbol.declarations) === null || _c === void 0 ? void 0 : _c.length) { - suggestion.origin.moduleSymbol = checker.getMergedSymbol(suggestion.origin.moduleSymbol.declarations[0].symbol); - } - }); - return cache; - }, - }; - } - Completions.createImportSuggestionsForFileCache = createImportSuggestionsForFileCache; function getCompletionsAtPosition(host, program, log, sourceFile, position, preferences, triggerCharacter) { var typeChecker = program.getTypeChecker(); var compilerOptions = program.getCompilerOptions(); @@ -119898,12 +124247,19 @@ var ts; if (triggerCharacter && !ts.isInString(sourceFile, position, contextToken) && !isValidTrigger(sourceFile, triggerCharacter, contextToken, position)) { return undefined; } + if (triggerCharacter === " ") { + // `isValidTrigger` ensures we are at `import |` + if (preferences.includeCompletionsForImportStatements && preferences.includeCompletionsWithInsertText) { + return { isGlobalCompletion: true, isMemberCompletion: false, isNewIdentifierLocation: true, isIncomplete: true, entries: [] }; + } + return undefined; + } var stringCompletions = Completions.StringCompletions.getStringLiteralCompletions(sourceFile, position, contextToken, typeChecker, compilerOptions, host, log, preferences); if (stringCompletions) { return stringCompletions; } if (contextToken && ts.isBreakOrContinueStatement(contextToken.parent) - && (contextToken.kind === 80 /* BreakKeyword */ || contextToken.kind === 85 /* ContinueKeyword */ || contextToken.kind === 78 /* Identifier */)) { + && (contextToken.kind === 81 /* BreakKeyword */ || contextToken.kind === 86 /* ContinueKeyword */ || contextToken.kind === 79 /* Identifier */)) { return getLabelCompletionAtPosition(contextToken.parent); } var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, preferences, /*detailsEntryId*/ undefined, host); @@ -119921,6 +124277,8 @@ var ts; return jsdocCompletionInfo(ts.JsDoc.getJSDocTagCompletions()); case 3 /* JsDocParameterName */: return jsdocCompletionInfo(ts.JsDoc.getJSDocParameterNameCompletions(completionData.tag)); + case 4 /* Keywords */: + return specificKeywordCompletionInfo(completionData.keywords); default: return ts.Debug.assertNever(completionData); } @@ -119929,33 +124287,36 @@ var ts; function jsdocCompletionInfo(entries) { return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: entries }; } + function specificKeywordCompletionInfo(keywords) { + return { + isGlobalCompletion: false, + isMemberCompletion: false, + isNewIdentifierLocation: false, + entries: keywords.map(function (k) { return ({ + name: ts.tokenToString(k), + kind: "keyword" /* keyword */, + kindModifiers: "" /* none */, + sortText: SortText.GlobalsOrKeywords, + }); }), + }; + } function getOptionalReplacementSpan(location) { // StringLiteralLike locations are handled separately in stringCompletions.ts - return (location === null || location === void 0 ? void 0 : location.kind) === 78 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined; + return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined; } function completionInfoFromData(sourceFile, typeChecker, compilerOptions, log, completionData, preferences) { - var symbols = completionData.symbols, 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, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextMap = completionData.symbolToSortTextMap; - if (location && location.parent && ts.isJsxClosingElement(location.parent)) { - // In the TypeScript JSX element, if such element is not defined. When users query for completion at closing tag, - // instead of simply giving unknown value, the completion will return the tag-name of an associated opening-element. - // For example: - // var x =
" with type any - // And at `
` (with a closing `>`), the completion list will contain "div". - var tagName = location.parent.parent.openingElement.tagName; - var hasClosingAngleBracket = !!ts.findChildOfKind(location.parent, 31 /* GreaterThanToken */, sourceFile); - var entry = { - name: tagName.getFullText(sourceFile) + (hasClosingAngleBracket ? "" : ">"), - kind: "class" /* classElement */, - kindModifiers: undefined, - sortText: SortText.LocationPriority, - }; - return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: false, optionalReplacementSpan: getOptionalReplacementSpan(location), entries: [entry] }; + var symbols = completionData.symbols, 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, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextIdMap = completionData.symbolToSortTextIdMap; + // Verify if the file is JSX language variant + if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) { + var completionInfo = getJsxClosingTagCompletion(location, sourceFile); + if (completionInfo) { + return completionInfo; + } } var entries = []; if (isUncheckedFile(sourceFile, compilerOptions)) { var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, - /* contextToken */ undefined, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, propertyAccessToConvert, completionData.isJsxIdentifierExpected, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap); + /* contextToken */ undefined, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap); getJSCompletionEntries(sourceFile, location.pos, uniqueNames, compilerOptions.target, entries); // TODO: GH#18217 } else { @@ -119963,7 +124324,7 @@ var ts; return undefined; } getCompletionEntriesFromSymbols(symbols, entries, - /* contextToken */ undefined, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, propertyAccessToConvert, completionData.isJsxIdentifierExpected, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap); + /* contextToken */ undefined, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap); } if (keywordFilters !== 0 /* None */) { var entryNames = new ts.Set(entries.map(function (e) { return e.name; })); @@ -119999,6 +124360,49 @@ var ts; return false; } } + function getJsxClosingTagCompletion(location, sourceFile) { + // We wanna walk up the tree till we find a JSX closing element + var jsxClosingElement = ts.findAncestor(location, function (node) { + switch (node.kind) { + case 278 /* JsxClosingElement */: + return true; + case 43 /* SlashToken */: + case 31 /* GreaterThanToken */: + case 79 /* Identifier */: + case 203 /* PropertyAccessExpression */: + return false; + default: + return "quit"; + } + }); + if (jsxClosingElement) { + // In the TypeScript JSX element, if such element is not defined. When users query for completion at closing tag, + // instead of simply giving unknown value, the completion will return the tag-name of an associated opening-element. + // For example: + // var x =
" with type any + // And at `
` (with a closing `>`), the completion list will contain "div". + // And at property access expressions ` ` the completion will + // return full closing tag with an optional replacement span + // For example: + // 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 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 */, + kindModifiers: undefined, + sortText: SortText.LocationPriority, + }; + return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: false, optionalReplacementSpan: replacementSpan, entries: [entry] }; + } + return; + } function getJSCompletionEntries(sourceFile, position, uniqueNames, target, entries) { ts.getNameTable(sourceFile).forEach(function (pos, name) { // Skip identifiers produced only from the current location @@ -120025,9 +124429,13 @@ var ts; function createCompletionEntryForLiteral(sourceFile, preferences, literal) { return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority }; } - function createCompletionEntry(symbol, sortText, contextToken, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, preferences) { + function createCompletionEntry(symbol, sortText, contextToken, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences) { + var _a; var insertText; var replacementSpan = ts.getReplacementSpanForContextToken(contextToken); + var data; + var isSnippet; + var sourceDisplay; var insertQuestionDot = origin && originIsNullableMember(origin); var useBraces = origin && originIsSymbolMember(origin) || needsConvertPropertyAccess; if (origin && originIsThisType(origin)) { @@ -120071,9 +124479,24 @@ var ts; insertText = needsConvertPropertyAccess ? "" + awaitText + insertText : "" + awaitText + (insertQuestionDot ? "?." : ".") + insertText; replacementSpan = ts.createTextSpanFromBounds(propertyAccessToConvert.getStart(sourceFile), propertyAccessToConvert.end); } + if (originIsResolvedExport(origin)) { + ts.Debug.assertIsDefined(importCompletionNode); + (_a = getInsertTextAndReplacementSpanForImportCompletion(name, importCompletionNode, origin, useSemicolons, options, preferences), insertText = _a.insertText, replacementSpan = _a.replacementSpan); + sourceDisplay = [ts.textPart(origin.moduleSpecifier)]; + isSnippet = preferences.includeCompletionsWithSnippetText ? true : undefined; + } if (insertText !== undefined && !preferences.includeCompletionsWithInsertText) { return undefined; } + if (originIsExport(origin) || originIsResolvedExport(origin)) { + data = { + exportName: origin.exportName, + fileName: origin.fileName, + ambientModuleName: origin.fileName ? undefined : ts.stripQuotes(origin.moduleSymbol.name), + isPackageJsonImport: origin.isFromPackageJson ? true : undefined, + moduleSpecifier: originIsResolvedExport(origin) ? origin.moduleSpecifier : undefined, + }; + } // TODO(drosen): Right now we just permit *all* semantic meanings when calling // 'getSymbolKind' which is permissible given that it is backwards compatible; but // really we should consider passing the meaning for the node so that we don't report @@ -120091,9 +124514,30 @@ var ts; isRecommended: isRecommendedCompletionMatch(symbol, recommendedCompletion, typeChecker) || undefined, insertText: insertText, replacementSpan: replacementSpan, + sourceDisplay: sourceDisplay, + isSnippet: isSnippet, isPackageJsonImport: originIsPackageJsonImport(origin) || undefined, + isImportStatementCompletion: originIsResolvedExport(origin) || undefined, + data: data, }; } + function getInsertTextAndReplacementSpanForImportCompletion(name, importCompletionNode, origin, useSemicolons, options, preferences) { + var sourceFile = importCompletionNode.getSourceFile(); + var replacementSpan = ts.createTextSpanFromNode(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 tabStop = preferences.includeCompletionsWithSnippetText ? "$1" : ""; + var importKind = ts.codefix.getImportKind(sourceFile, exportKind, options); + var suffix = useSemicolons ? ";" : ""; + switch (importKind) { + case 3 /* CommonJS */: return { replacementSpan: replacementSpan, insertText: "import " + name + tabStop + " = require(" + quotedModuleSpecifier + ")" + suffix }; + case 1 /* Default */: return { replacementSpan: replacementSpan, insertText: "import " + name + tabStop + " from " + quotedModuleSpecifier + suffix }; + case 2 /* Namespace */: return { replacementSpan: replacementSpan, insertText: "import * as " + name + tabStop + " from " + quotedModuleSpecifier + suffix }; + case 0 /* Named */: return { replacementSpan: replacementSpan, insertText: "import { " + name + tabStop + " } from " + quotedModuleSpecifier + suffix }; + } + } function quotePropertyName(sourceFile, preferences, name) { if (/^\d+$/.test(name)) { return name; @@ -120108,29 +124552,34 @@ var ts; if (originIsExport(origin)) { return ts.stripQuotes(origin.moduleSymbol.name); } + if (originIsResolvedExport(origin)) { + return origin.moduleSpecifier; + } if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 1 /* ThisType */) { return CompletionSource.ThisProperty; } } - function getCompletionEntriesFromSymbols(symbols, entries, contextToken, location, sourceFile, typeChecker, target, log, kind, preferences, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap) { + function getCompletionEntriesFromSymbols(symbols, entries, contextToken, location, sourceFile, typeChecker, target, log, kind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap) { + var _a; var start = ts.timestamp(); + var variableDeclaration = getVariableDeclaration(location); + var useSemicolons = ts.probablyUsesSemicolons(sourceFile); // Tracks unique names. // Value is set to false for global variables or completions from external module exports, because we can have multiple of those; // true otherwise. Based on the order we add things we will always see locals first, then globals, then module exports. // So adding a completion for a local will prevent us from adding completions for external module exports sharing the same name. var uniques = new ts.Map(); - for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) { - var symbol = symbols_1[_i]; - var origin = symbolToOriginInfoMap ? symbolToOriginInfoMap[ts.getSymbolId(symbol)] : undefined; + for (var i = 0; i < symbols.length; i++) { + 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) { + if (!info || uniques.get(info.name) || kind === 1 /* Global */ && symbolToSortTextIdMap && !shouldIncludeSymbol(symbol, symbolToSortTextIdMap)) { continue; } var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess; - if (uniques.get(name)) { - continue; - } - var entry = createCompletionEntry(symbol, symbolToSortTextMap && symbolToSortTextMap[ts.getSymbolId(symbol)] || SortText.LocationPriority, contextToken, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, preferences); + var sortTextId = (_a = symbolToSortTextIdMap === null || symbolToSortTextIdMap === void 0 ? void 0 : symbolToSortTextIdMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : SortTextId.LocationPriority; + var sortText = (isDeprecated(symbol, typeChecker) ? DeprecatedSortTextStart + sortTextId : sortTextId).toString(); + var entry = createCompletionEntry(symbol, sortText, contextToken, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences); if (!entry) { continue; } @@ -120147,6 +124596,46 @@ var ts; has: function (name) { return uniques.has(name); }, add: function (name) { return uniques.set(name, true); }, }; + function shouldIncludeSymbol(symbol, symbolToSortTextIdMap) { + if (!ts.isSourceFile(location)) { + // export = /**/ here we want to get all meanings, so any symbol is ok + if (ts.isExportAssignment(location.parent)) { + return true; + } + // Filter out variables from their own initializers + // `const a = /* no 'a' here */` + if (variableDeclaration && symbol.valueDeclaration === variableDeclaration) { + return false; + } + // External modules can have global export declarations that will be + // available as global keywords in all scopes. But if the external module + // already has an explicit export and user only wants to user explicit + // module imports then the global keywords will be filtered out so auto + // import suggestions will win in the completion + var symbolOrigin = ts.skipAlias(symbol, typeChecker); + // We only want to filter out the global keywords + // Auto Imports are not available for scripts so this conditional is always false + if (!!sourceFile.externalModuleIndicator + && !compilerOptions.allowUmdGlobalAccess + && symbolToSortTextIdMap[ts.getSymbolId(symbol)] === SortTextId.GlobalsOrKeywords + && (symbolToSortTextIdMap[ts.getSymbolId(symbolOrigin)] === SortTextId.AutoImportSuggestions + || symbolToSortTextIdMap[ts.getSymbolId(symbolOrigin)] === SortTextId.LocationPriority)) { + return false; + } + // Continue with origin symbol + symbol = 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 !!(symbol.flags & 1920 /* Namespace */); + } + if (isTypeOnlyLocation) { + // It's a type, but you can reach it by namespace.type as well + return symbolCanBeReferencedAtTypeLocation(symbol, typeChecker); + } + } + // expressions are value space (which includes the value namespaces) + return !!(ts.getCombinedLocalAndExportSymbolFlags(symbol) & 111551 /* Value */); + } } Completions.getCompletionEntriesFromSymbols = getCompletionEntriesFromSymbols; function getLabelCompletionAtPosition(node) { @@ -120180,6 +124669,20 @@ var ts; return entries; } function getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host, preferences) { + if (entryId.data) { + var autoImport = getAutoImportSymbolFromCompletionEntryData(entryId.name, entryId.data, program, host); + if (autoImport) { + return { + type: "symbol", + symbol: autoImport.symbol, + location: ts.getTouchingPropertyName(sourceFile, position), + previousToken: ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined), + isJsxInitializer: false, + isTypeOnlyLocation: false, + origin: autoImport.origin, + }; + } + } var compilerOptions = program.getCompilerOptions(); var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId, host); if (!completionData) { @@ -120196,11 +124699,11 @@ var ts; // We don't need to perform character checks here because we're only comparing the // name against 'entryName' (which is known to be good), not building a new // completion entry. - return ts.firstDefined(symbols, function (symbol) { - var origin = symbolToOriginInfoMap[ts.getSymbolId(symbol)]; + return ts.firstDefined(symbols, function (symbol, index) { + var origin = symbolToOriginInfoMap[index]; var info = getCompletionEntryDisplayNameForSymbol(symbol, compilerOptions.target, origin, completionKind, completionData.isJsxIdentifierExpected); return info && info.name === entryId.name && getSourceFromOrigin(origin) === entryId.source - ? { type: "symbol", symbol: symbol, location: location, symbolToOriginInfoMap: symbolToOriginInfoMap, previousToken: previousToken, isJsxInitializer: isJsxInitializer, isTypeOnlyLocation: isTypeOnlyLocation } + ? { type: "symbol", symbol: symbol, location: location, origin: origin, previousToken: previousToken, isJsxInitializer: isJsxInitializer, isTypeOnlyLocation: isTypeOnlyLocation } : undefined; }) || { type: "none" }; } @@ -120210,7 +124713,7 @@ var ts; var name = entryId.name; var contextToken = ts.findPrecedingToken(position, sourceFile); if (ts.isInString(sourceFile, position, contextToken)) { - return Completions.StringCompletions.getStringLiteralCompletionDetails(name, sourceFile, position, contextToken, typeChecker, compilerOptions, host, cancellationToken); + return Completions.StringCompletions.getStringLiteralCompletionDetails(name, sourceFile, position, contextToken, typeChecker, compilerOptions, host, cancellationToken, preferences); } // Compute all the completion symbols again. var symbolCompletion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host, preferences); @@ -120224,13 +124727,15 @@ var ts; return ts.JsDoc.getJSDocTagCompletionDetails(name); case 3 /* JsDocParameterName */: return ts.JsDoc.getJSDocParameterNameCompletionDetails(name); + case 4 /* Keywords */: + return request.keywords.indexOf(ts.stringToToken(name)) > -1 ? createSimpleDetails(name, "keyword" /* keyword */, ts.SymbolDisplayPartKind.keyword) : undefined; default: return ts.Debug.assertNever(request); } } case "symbol": { - var symbol = symbolCompletion.symbol, location = symbolCompletion.location, symbolToOriginInfoMap = symbolCompletion.symbolToOriginInfoMap, previousToken = symbolCompletion.previousToken; - var _a = getCompletionEntryCodeActionsAndSourceDisplay(symbolToOriginInfoMap, symbol, program, typeChecker, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences), codeActions = _a.codeActions, sourceDisplay = _a.sourceDisplay; + var symbol = symbolCompletion.symbol, location = symbolCompletion.location, origin = symbolCompletion.origin, previousToken = symbolCompletion.previousToken; + var _a = getCompletionEntryCodeActionsAndSourceDisplay(origin, symbol, program, typeChecker, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, entryId.data), codeActions = _a.codeActions, sourceDisplay = _a.sourceDisplay; return createCompletionDetailsForSymbol(symbol, typeChecker, sourceFile, location, cancellationToken, codeActions, sourceDisplay); // TODO: GH#18217 } case "literal": { @@ -120256,15 +124761,17 @@ var ts; } Completions.createCompletionDetailsForSymbol = createCompletionDetailsForSymbol; function createCompletionDetails(name, kindModifiers, kind, displayParts, documentation, tags, codeActions, source) { - return { name: name, kindModifiers: kindModifiers, kind: kind, displayParts: displayParts, documentation: documentation, tags: tags, codeActions: codeActions, source: source }; + return { name: name, kindModifiers: kindModifiers, kind: kind, displayParts: displayParts, documentation: documentation, tags: tags, codeActions: codeActions, source: source, sourceDisplay: source }; } Completions.createCompletionDetails = createCompletionDetails; - function getCompletionEntryCodeActionsAndSourceDisplay(symbolToOriginInfoMap, symbol, program, checker, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences) { - var symbolOriginInfo = symbolToOriginInfoMap[ts.getSymbolId(symbol)]; - if (!symbolOriginInfo || !originIsExport(symbolOriginInfo)) { + function getCompletionEntryCodeActionsAndSourceDisplay(origin, symbol, program, checker, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, data) { + if (data === null || data === void 0 ? void 0 : data.moduleSpecifier) { + return { codeActions: undefined, sourceDisplay: [ts.textPart(data.moduleSpecifier)] }; + } + if (!origin || !originIsExport(origin)) { return { codeActions: undefined, sourceDisplay: undefined }; } - var moduleSymbol = symbolOriginInfo.moduleSymbol; + var moduleSymbol = origin.moduleSymbol; var exportedSymbol = checker.getMergedSymbol(ts.skipAlias(symbol.exportSymbol || symbol, checker)); var _a = ts.codefix.getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, ts.getNameForExportedSymbol(symbol, compilerOptions.target), host, program, formatContext, previousToken && ts.isIdentifier(previousToken) ? previousToken.getStart(sourceFile) : position, preferences), moduleSpecifier = _a.moduleSpecifier, codeAction = _a.codeAction; return { sourceDisplay: [ts.textPart(moduleSpecifier)], codeActions: [codeAction] }; @@ -120280,6 +124787,7 @@ var ts; CompletionDataKind[CompletionDataKind["JsDocTagName"] = 1] = "JsDocTagName"; CompletionDataKind[CompletionDataKind["JsDocTag"] = 2] = "JsDocTag"; CompletionDataKind[CompletionDataKind["JsDocParameterName"] = 3] = "JsDocParameterName"; + CompletionDataKind[CompletionDataKind["Keywords"] = 4] = "Keywords"; })(CompletionDataKind || (CompletionDataKind = {})); var CompletionKind; (function (CompletionKind) { @@ -120303,25 +124811,25 @@ var ts; function getContextualType(previousToken, position, sourceFile, checker) { var parent = previousToken.parent; switch (previousToken.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return ts.getContextualTypeFromParent(previousToken, checker); - case 62 /* EqualsToken */: + case 63 /* EqualsToken */: switch (parent.kind) { - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return checker.getContextualType(parent.initializer); // TODO: GH#18217 - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return checker.getTypeAtLocation(parent.left); - case 280 /* JsxAttribute */: + case 282 /* JsxAttribute */: return checker.getContextualTypeForJsxAttribute(parent); default: return undefined; } - case 102 /* NewKeyword */: + case 103 /* NewKeyword */: return checker.getContextualType(parent); - case 81 /* CaseKeyword */: + case 82 /* CaseKeyword */: return ts.getSwitchedType(ts.cast(parent, ts.isCaseClause), checker); case 18 /* OpenBraceToken */: - return ts.isJsxExpression(parent) && parent.parent.kind !== 273 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; + return ts.isJsxExpression(parent) && parent.parent.kind !== 275 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; default: var argInfo = ts.SignatureHelp.getArgumentInfoForCompletions(previousToken, position, sourceFile); return argInfo ? @@ -120340,7 +124848,8 @@ var ts; return symbol.parent && (isModuleSymbol(symbol.parent) ? symbol : getFirstSymbolInChain(symbol.parent, enclosingDeclaration, checker)); } function isModuleSymbol(symbol) { - return symbol.declarations.some(function (d) { return d.kind === 297 /* SourceFile */; }); + var _a; + return !!((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d.kind === 299 /* SourceFile */; })); } function getCompletionData(program, log, sourceFile, isUncheckedFile, position, preferences, detailsEntryId, host) { var typeChecker = program.getTypeChecker(); @@ -120391,11 +124900,11 @@ var ts; if (tag.tagName.pos <= position && position <= tag.tagName.end) { return { kind: 1 /* JsDocTagName */ }; } - if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 301 /* JSDocTypeExpression */) { + if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 303 /* JSDocTypeExpression */) { currentToken = ts.getTokenAtPosition(sourceFile, position); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 333 /* JSDocPropertyTag */ || + (currentToken.parent.kind !== 341 /* JSDocPropertyTag */ || currentToken.parent.name !== currentToken))) { // Use as type location if inside tag's type expression insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression); @@ -120420,7 +124929,7 @@ var ts; var contextToken = previousToken; // Check if the caret is at the end of an identifier; this is a partial identifier that we want to complete: e.g. a.toS| // Skip this partial identifier and adjust the contextToken to the token that precedes it. - if (contextToken && position <= contextToken.end && (ts.isIdentifierOrPrivateIdentifier(contextToken) || ts.isKeyword(contextToken.kind))) { + if (contextToken && position <= contextToken.end && (ts.isMemberName(contextToken) || ts.isKeyword(contextToken.kind))) { var start_1 = ts.timestamp(); contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile, /*startNode*/ undefined); // TODO: GH#18217 log("getCompletionData: Get previous token 2: " + (ts.timestamp() - start_1)); @@ -120436,10 +124945,22 @@ var ts; var isStartingCloseTag = false; var isJsxInitializer = false; var isJsxIdentifierExpected = false; + var importCompletionNode; var location = ts.getTouchingPropertyName(sourceFile, position); if (contextToken) { + var importCompletionCandidate = getImportCompletionNode(contextToken); + if (importCompletionCandidate === 154 /* FromKeyword */) { + return { kind: 4 /* Keywords */, keywords: [154 /* FromKeyword */] }; + } + // Import statement completions use `insertText`, and also require the `data` property of `CompletionEntryIdentifier` + // added in TypeScript 4.3 to be sent back from the client during `getCompletionEntryDetails`. Since this feature + // 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. + if (importCompletionCandidate && preferences.includeCompletionsForImportStatements && preferences.includeCompletionsWithInsertText) { + importCompletionNode = importCompletionCandidate; + } // Bail out if this is a known invalid completion location - if (isCompletionListBlocker(contextToken)) { + if (!importCompletionNode && isCompletionListBlocker(contextToken)) { log("Returning an empty list because completion was requested in an invalid position."); return undefined; } @@ -120448,7 +124969,7 @@ var ts; isRightOfDot = contextToken.kind === 24 /* DotToken */; isRightOfQuestionDot = contextToken.kind === 28 /* QuestionDotToken */; switch (parent.kind) { - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: propertyAccessToConvert = parent; node = propertyAccessToConvert.expression; if ((ts.isCallExpression(node) || ts.isFunctionLike(node)) && @@ -120461,14 +124982,14 @@ var ts; return undefined; } break; - case 157 /* QualifiedName */: + case 159 /* QualifiedName */: node = parent.left; break; - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: node = parent.name; break; - case 195 /* ImportType */: - case 226 /* MetaProperty */: + case 197 /* ImportType */: + case 228 /* MetaProperty */: node = parent; break; default: @@ -120477,11 +124998,11 @@ var ts; return undefined; } } - else if (sourceFile.languageVariant === 1 /* JSX */) { + else if (!importCompletionNode && sourceFile.languageVariant === 1 /* 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 === 201 /* PropertyAccessExpression */) { + if (parent && parent.kind === 203 /* PropertyAccessExpression */) { contextToken = parent; parent = parent.parent; } @@ -120489,45 +125010,45 @@ var ts; if (currentToken.parent === location) { switch (currentToken.kind) { case 31 /* GreaterThanToken */: - if (currentToken.parent.kind === 273 /* JsxElement */ || currentToken.parent.kind === 275 /* JsxOpeningElement */) { + if (currentToken.parent.kind === 275 /* JsxElement */ || currentToken.parent.kind === 277 /* JsxOpeningElement */) { location = currentToken; } break; case 43 /* SlashToken */: - if (currentToken.parent.kind === 274 /* JsxSelfClosingElement */) { + if (currentToken.parent.kind === 276 /* JsxSelfClosingElement */) { location = currentToken; } break; } } switch (parent.kind) { - case 276 /* JsxClosingElement */: + case 278 /* JsxClosingElement */: if (contextToken.kind === 43 /* SlashToken */) { isStartingCloseTag = true; location = contextToken; } break; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: if (!binaryExpressionMayBeOpenTag(parent)) { break; } // falls through - case 274 /* JsxSelfClosingElement */: - case 273 /* JsxElement */: - case 275 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: + case 275 /* JsxElement */: + case 277 /* JsxOpeningElement */: isJsxIdentifierExpected = true; if (contextToken.kind === 29 /* LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } break; - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: // For `
`, `parent` will be `{true}` and `previousToken` will be `}` if (previousToken.kind === 19 /* CloseBraceToken */ && currentToken.kind === 31 /* GreaterThanToken */) { isJsxIdentifierExpected = true; } break; - case 280 /* JsxAttribute */: + case 282 /* JsxAttribute */: // For `
`, `parent` will be JsxAttribute and `previousToken` will be its initializer if (parent.initializer === previousToken && previousToken.end < position) { @@ -120535,16 +125056,16 @@ var ts; break; } switch (previousToken.kind) { - case 62 /* EqualsToken */: + case 63 /* EqualsToken */: isJsxInitializer = true; break; - case 78 /* Identifier */: + case 79 /* 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, 62 /* EqualsToken */, sourceFile)) { + ts.findChildOfKind(parent, 63 /* EqualsToken */, sourceFile)) { isJsxInitializer = previousToken; } } @@ -120560,9 +125081,12 @@ var ts; // This also gets mutated in nested-functions after the return var symbols = []; var symbolToOriginInfoMap = []; - var symbolToSortTextMap = []; - var importSuggestionsCache = host.getImportSuggestionsCache && host.getImportSuggestionsCache(); + var symbolToSortTextIdMap = []; + var seenPropertySymbols = new ts.Map(); var isTypeOnly = isTypeOnlyCompletion(); + var getModuleSpecifierResolutionHost = ts.memoizeOne(function (isFromPackageJson) { + return ts.createModuleSpecifierResolutionHost(isFromPackageJson ? host.getPackageJsonAutoImportProvider() : program, host); + }); if (isRightOfDot || isRightOfQuestionDot) { getTypeScriptMemberSymbols(); } @@ -120571,7 +125095,7 @@ var ts; ts.Debug.assertEachIsDefined(tagSymbols, "getJsxIntrinsicTagNames() should all be defined"); tryGetGlobalSymbols(); symbols = tagSymbols.concat(symbols); - completionKind = 3 /* MemberLike */; + completionKind = 1 /* Global */; keywordFilters = 0 /* None */; } else if (isStartingCloseTag) { @@ -120580,7 +125104,7 @@ var ts; if (tagSymbol) { symbols = [tagSymbol]; } - completionKind = 3 /* MemberLike */; + completionKind = 1 /* Global */; keywordFilters = 0 /* None */; } else { @@ -120610,17 +125134,18 @@ var ts; previousToken: previousToken, isJsxInitializer: isJsxInitializer, insideJsDocTagTypeExpression: insideJsDocTagTypeExpression, - symbolToSortTextMap: symbolToSortTextMap, + symbolToSortTextIdMap: symbolToSortTextIdMap, isTypeOnlyLocation: isTypeOnly, isJsxIdentifierExpected: isJsxIdentifierExpected, + importCompletionNode: importCompletionNode, }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 326 /* JSDocParameterTag */: - case 333 /* JSDocPropertyTag */: - case 327 /* JSDocReturnTag */: - case 329 /* JSDocTypeTag */: - case 331 /* JSDocTypedefTag */: + case 334 /* JSDocParameterTag */: + case 341 /* JSDocPropertyTag */: + case 335 /* JSDocReturnTag */: + case 337 /* JSDocTypeTag */: + case 339 /* JSDocTypedefTag */: return true; default: return false; @@ -120647,11 +125172,11 @@ var ts; // Extract module or enum members var exportedSymbols = typeChecker.getExportsOfModule(symbol); ts.Debug.assertEachIsDefined(exportedSymbols, "getExportsOfModule() should all be defined"); - var isValidValueAccess_1 = function (symbol) { return typeChecker.isValidPropertyAccess(isImportType ? node : (node.parent), symbol.name); }; - var isValidTypeAccess_1 = function (symbol) { return symbolCanBeReferencedAtTypeLocation(symbol); }; + var isValidValueAccess_1 = function (symbol) { return typeChecker.isValidPropertyAccess(isImportType ? node : node.parent, symbol.name); }; + 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) { return !!(symbol.flags & 1920 /* Namespace */) && !symbol.declarations.every(function (d) { return d.parent === node.parent; }); } + ? 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; })); } : isRhsOfImportDeclaration ? // Any kind is allowed when dotting off namespace in internal import equals declaration function (symbol) { return isValidTypeAccess_1(symbol) || isValidValueAccess_1(symbol); } : @@ -120665,7 +125190,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 !== 297 /* SourceFile */ && d.kind !== 256 /* ModuleDeclaration */ && d.kind !== 255 /* EnumDeclaration */; })) { + symbol.declarations.some(function (d) { return d.kind !== 299 /* SourceFile */ && d.kind !== 258 /* ModuleDeclaration */ && d.kind !== 257 /* EnumDeclaration */; })) { var type = typeChecker.getTypeOfSymbolAtLocation(symbol, node).getNonOptionalType(); var insertQuestionDot = false; if (type.isNullableType()) { @@ -120685,8 +125210,8 @@ var ts; } } } - if (ts.isMetaProperty(node) && (node.keywordToken === 102 /* NewKeyword */ || node.keywordToken === 99 /* ImportKeyword */) && contextToken === node.getChildAt(1)) { - var completion = (node.keywordToken === 102 /* NewKeyword */) ? "target" : "meta"; + if (ts.isMetaProperty(node) && (node.keywordToken === 103 /* NewKeyword */ || node.keywordToken === 100 /* ImportKeyword */) && contextToken === node.getChildAt(1)) { + var completion = (node.keywordToken === 103 /* NewKeyword */) ? "target" : "meta"; symbols.push(typeChecker.createSymbol(4 /* Property */, ts.escapeLeadingUnderscores(completion))); return; } @@ -120712,7 +125237,7 @@ var ts; if (isRightOfQuestionDot && ts.some(type.getCallSignatures())) { isNewIdentifierLocation = true; } - var propertyAccess = node.kind === 195 /* ImportType */ ? node : node.parent; + var propertyAccess = node.kind === 197 /* ImportType */ ? node : node.parent; if (isUncheckedFile) { // 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 @@ -120751,13 +125276,24 @@ var ts; var nameSymbol = leftMostName && typeChecker.getSymbolAtLocation(leftMostName); // If this is nested like for `namespace N { export const sym = Symbol(); }`, we'll add the completion for `N`. var firstAccessibleSymbol = nameSymbol && getFirstSymbolInChain(nameSymbol, contextToken, typeChecker); - if (firstAccessibleSymbol && !symbolToOriginInfoMap[ts.getSymbolId(firstAccessibleSymbol)]) { + if (firstAccessibleSymbol && ts.addToSeen(seenPropertySymbols, ts.getSymbolId(firstAccessibleSymbol))) { + var index = symbols.length; symbols.push(firstAccessibleSymbol); var moduleSymbol = firstAccessibleSymbol.parent; - symbolToOriginInfoMap[ts.getSymbolId(firstAccessibleSymbol)] = - !moduleSymbol || !ts.isExternalModuleSymbol(moduleSymbol) - ? { kind: getNullableSymbolOriginInfoKind(2 /* SymbolMemberNoExport */) } - : { kind: getNullableSymbolOriginInfoKind(6 /* SymbolMemberExport */), moduleSymbol: moduleSymbol, isDefaultExport: false }; + if (!moduleSymbol || !ts.isExternalModuleSymbol(moduleSymbol)) { + symbolToOriginInfoMap[index] = { kind: getNullableSymbolOriginInfoKind(2 /* SymbolMemberNoExport */) }; + } + else { + var origin = { + kind: getNullableSymbolOriginInfoKind(6 /* SymbolMemberExport */), + moduleSymbol: moduleSymbol, + isDefaultExport: false, + symbolName: firstAccessibleSymbol.name, + exportName: firstAccessibleSymbol.name, + fileName: ts.isExternalModuleNameRelative(ts.stripQuotes(moduleSymbol.name)) ? ts.cast(moduleSymbol.valueDeclaration, ts.isSourceFile).fileName : undefined, + }; + symbolToOriginInfoMap[index] = origin; + } } else if (preferences.includeCompletionsWithInsertText) { addSymbolOriginInfo(symbol); @@ -120772,16 +125308,16 @@ var ts; } function addSymbolSortInfo(symbol) { if (isStaticProperty(symbol)) { - symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.LocalDeclarationPriority; + symbolToSortTextIdMap[ts.getSymbolId(symbol)] = SortTextId.LocalDeclarationPriority; } } function addSymbolOriginInfo(symbol) { if (preferences.includeCompletionsWithInsertText) { - if (insertAwait && !symbolToOriginInfoMap[ts.getSymbolId(symbol)]) { - symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: getNullableSymbolOriginInfoKind(8 /* Promise */) }; + if (insertAwait && ts.addToSeen(seenPropertySymbols, ts.getSymbolId(symbol))) { + symbolToOriginInfoMap[symbols.length] = { kind: getNullableSymbolOriginInfoKind(8 /* Promise */) }; } else if (insertQuestionDot) { - symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: 16 /* Nullable */ }; + symbolToOriginInfoMap[symbols.length] = { kind: 16 /* Nullable */ }; } } } @@ -120794,7 +125330,9 @@ var ts; return ts.isIdentifier(e) ? e : ts.isPropertyAccessExpression(e) ? getLeftMostName(e.expression) : undefined; } function tryGetGlobalSymbols() { - var result = tryGetObjectLikeCompletionSymbols() + var result = tryGetObjectTypeLiteralInTypeArgumentCompletionSymbols() + || tryGetObjectLikeCompletionSymbols() + || tryGetImportCompletionSymbols() || tryGetImportOrExportClauseCompletionSymbols() || tryGetLocalNamedExportCompletionSymbols() || tryGetConstructorCompletion() @@ -120827,11 +125365,17 @@ var ts; isNewIdentifierLocation = false; return 1 /* Success */; } + function tryGetImportCompletionSymbols() { + if (!importCompletionNode) + return 0 /* Continue */; + collectAutoImports(/*resolveModuleSpecifiers*/ true); + return 1 /* Success */; + } function getGlobalCompletions() { keywordFilters = tryGetFunctionLikeBodyCompletionContainer(contextToken) ? 5 /* FunctionLikeBodyKeywords */ : 1 /* All */; // Get all entities in the current scope. completionKind = 1 /* Global */; - isNewIdentifierLocation = isNewIdentifierDefinitionLocation(contextToken); + isNewIdentifierLocation = isNewIdentifierDefinitionLocation(); if (previousToken !== contextToken) { ts.Debug.assert(!!previousToken, "Expected 'contextToken' to be defined when different from 'previousToken'."); } @@ -120868,50 +125412,36 @@ var ts; var symbolMeanings = (isTypeOnly ? 0 /* None */ : 111551 /* Value */) | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */; symbols = typeChecker.getSymbolsInScope(scopeNode, symbolMeanings); ts.Debug.assertEachIsDefined(symbols, "getSymbolsInScope() should all be defined"); - for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) { - var symbol = symbols_2[_i]; + for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) { + var symbol = symbols_1[_i]; if (!typeChecker.isArgumentsSymbol(symbol) && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === sourceFile; })) { - symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.GlobalsOrKeywords; + symbolToSortTextIdMap[ts.getSymbolId(symbol)] = SortTextId.GlobalsOrKeywords; } } // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions` - if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 297 /* SourceFile */) { + if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 299 /* SourceFile */) { var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false); if (thisType && !isProbablyGlobalType(thisType, sourceFile, typeChecker)) { for (var _a = 0, _b = getPropertiesForCompletion(thisType, typeChecker); _a < _b.length; _a++) { var symbol = _b[_a]; - symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: 1 /* ThisType */ }; + symbolToOriginInfoMap[symbols.length] = { kind: 1 /* ThisType */ }; symbols.push(symbol); - symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.SuggestedClassMembers; + symbolToSortTextIdMap[ts.getSymbolId(symbol)] = SortTextId.SuggestedClassMembers; } } } - if (shouldOfferImportCompletions()) { - var lowerCaseTokenText_1 = previousToken && ts.isIdentifier(previousToken) ? previousToken.text.toLowerCase() : ""; - var autoImportSuggestions = getSymbolsFromOtherSourceFileExports(program.getCompilerOptions().target, host); - if (!detailsEntryId && importSuggestionsCache) { - importSuggestionsCache.set(sourceFile.fileName, autoImportSuggestions, host.getProjectVersion && host.getProjectVersion()); - } - autoImportSuggestions.forEach(function (_a) { - var symbol = _a.symbol, symbolName = _a.symbolName, skipFilter = _a.skipFilter, origin = _a.origin; - if (detailsEntryId) { - if (detailsEntryId.source && ts.stripQuotes(origin.moduleSymbol.name) !== detailsEntryId.source) { - return; - } - } - else if (!skipFilter && !stringContainsCharactersInOrder(symbolName.toLowerCase(), lowerCaseTokenText_1)) { - return; - } - var symbolId = ts.getSymbolId(symbol); - symbols.push(symbol); - symbolToOriginInfoMap[symbolId] = origin; - symbolToSortTextMap[symbolId] = SortText.AutoImportSuggestions; - }); + collectAutoImports(/*resolveModuleSpecifier*/ false); + if (isTypeOnly) { + keywordFilters = contextToken && ts.isAssertionExpression(contextToken.parent) + ? 6 /* TypeAssertionKeywords */ + : 7 /* TypeKeywords */; } - filterGlobalCompletion(symbols); } function shouldOfferImportCompletions() { + // If already typing an import statement, provide completions for it. + if (importCompletionNode) + return true; // If current completion is for non-contextual Object literal shortahands, ignore auto-import symbols if (isNonContextualObjectLiteral) return false; @@ -120929,42 +125459,15 @@ var ts; } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { - case 297 /* SourceFile */: - case 218 /* TemplateExpression */: - case 283 /* JsxExpression */: - case 230 /* Block */: + case 299 /* SourceFile */: + case 220 /* TemplateExpression */: + case 285 /* JsxExpression */: + case 232 /* Block */: return true; default: return ts.isStatement(scopeNode); } } - function filterGlobalCompletion(symbols) { - var isTypeOnly = isTypeOnlyCompletion(); - if (isTypeOnly) { - keywordFilters = contextToken && ts.isAssertionExpression(contextToken.parent) - ? 6 /* TypeAssertionKeywords */ - : 7 /* TypeKeywords */; - } - ts.filterMutate(symbols, function (symbol) { - if (!ts.isSourceFile(location)) { - // export = /**/ here we want to get all meanings, so any symbol is ok - if (ts.isExportAssignment(location.parent)) { - return true; - } - symbol = ts.skipAlias(symbol, typeChecker); - // import m = /**/ <-- It can only access namespace (if typing import = x. this would get member symbols and not namespace) - if (ts.isInRightSideOfInternalImportEqualsDeclaration(location)) { - return !!(symbol.flags & 1920 /* Namespace */); - } - if (isTypeOnly) { - // It's a type, but you can reach it by namespace.type as well - return symbolCanBeReferencedAtTypeLocation(symbol); - } - } - // expressions are value space (which includes the value namespaces) - return !!(ts.getCombinedLocalAndExportSymbolFlags(symbol) & 111551 /* Value */); - }); - } function isTypeOnlyCompletion() { return insideJsDocTagTypeExpression || !isContextTokenValueLocation(contextToken) && @@ -120974,191 +125477,105 @@ var ts; } function isContextTokenValueLocation(contextToken) { return contextToken && - contextToken.kind === 111 /* TypeOfKeyword */ && - (contextToken.parent.kind === 176 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent)); + ((contextToken.kind === 112 /* TypeOfKeyword */ && + (contextToken.parent.kind === 178 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent))) || + (contextToken.kind === 128 /* AssertsKeyword */ && contextToken.parent.kind === 174 /* TypePredicate */)); } function isContextTokenTypeLocation(contextToken) { if (contextToken) { var parentKind = contextToken.parent.kind; switch (contextToken.kind) { case 58 /* ColonToken */: - return parentKind === 163 /* PropertyDeclaration */ || - parentKind === 162 /* PropertySignature */ || - parentKind === 160 /* Parameter */ || - parentKind === 249 /* VariableDeclaration */ || + return parentKind === 165 /* PropertyDeclaration */ || + parentKind === 164 /* PropertySignature */ || + parentKind === 162 /* Parameter */ || + parentKind === 251 /* VariableDeclaration */ || ts.isFunctionLikeKind(parentKind); - case 62 /* EqualsToken */: - return parentKind === 254 /* TypeAliasDeclaration */; - case 126 /* AsKeyword */: - return parentKind === 224 /* AsExpression */; + case 63 /* EqualsToken */: + return parentKind === 256 /* TypeAliasDeclaration */; + case 127 /* AsKeyword */: + return parentKind === 226 /* AsExpression */; case 29 /* LessThanToken */: - return parentKind === 173 /* TypeReference */ || - parentKind === 206 /* TypeAssertionExpression */; - case 93 /* ExtendsKeyword */: - return parentKind === 159 /* TypeParameter */; + return parentKind === 175 /* TypeReference */ || + parentKind === 208 /* TypeAssertionExpression */; + case 94 /* ExtendsKeyword */: + return parentKind === 161 /* TypeParameter */; } } return false; } - /** True if symbol is a type or a module containing at least one type. */ - function symbolCanBeReferencedAtTypeLocation(symbol, seenModules) { - if (seenModules === void 0) { seenModules = new ts.Map(); } - var sym = ts.skipAlias(symbol.exportSymbol || symbol, typeChecker); - return !!(sym.flags & 788968 /* Type */) || - !!(sym.flags & 1536 /* Module */) && - ts.addToSeen(seenModules, ts.getSymbolId(sym)) && - typeChecker.getExportsOfModule(sym).some(function (e) { return symbolCanBeReferencedAtTypeLocation(e, seenModules); }); - } - /** - * Gathers symbols that can be imported from other files, de-duplicating along the way. Symbols can be "duplicates" - * if re-exported from another module, e.g. `export { foo } from "./a"`. That syntax creates a fresh symbol, but - * it’s just an alias to the first, and both have the same name, so we generally want to filter those aliases out, - * if and only if the the first can be imported (it may be excluded due to package.json filtering in - * `codefix.forEachExternalModuleToImportFrom`). - * - * Example. Imagine a chain of node_modules re-exporting one original symbol: - * - * ```js - * node_modules/x/index.js node_modules/y/index.js node_modules/z/index.js - * +-----------------------+ +--------------------------+ +--------------------------+ - * | | | | | | - * | export const foo = 0; | <--- | export { foo } from 'x'; | <--- | export { foo } from 'y'; | - * | | | | | | - * +-----------------------+ +--------------------------+ +--------------------------+ - * ``` - * - * Also imagine three buckets, which we’ll reference soon: - * - * ```md - * | | | | | | - * | **Bucket A** | | **Bucket B** | | **Bucket C** | - * | Symbols to | | Aliases to symbols | | Symbols to return | - * | definitely | | in Buckets A or C | | if nothing better | - * | return | | (don’t return these) | | comes along | - * |__________________| |______________________| |___________________| - * ``` - * - * We _probably_ want to show `foo` from 'x', but not from 'y' or 'z'. However, if 'x' is not in a package.json, it - * will not appear in a `forEachExternalModuleToImportFrom` iteration. Furthermore, the order of iterations is not - * guaranteed, as it is host-dependent. Therefore, when presented with the symbol `foo` from module 'y' alone, we - * may not be sure whether or not it should go in the list. So, we’ll take the following steps: - * - * 1. Resolve alias `foo` from 'y' to the export declaration in 'x', get the symbol there, and see if that symbol is - * already in Bucket A (symbols we already know will be returned). If it is, put `foo` from 'y' in Bucket B - * (symbols that are aliases to symbols in Bucket A). If it’s not, put it in Bucket C. - * 2. Next, imagine we see `foo` from module 'z'. Again, we resolve the alias to the nearest export, which is in 'y'. - * At this point, if that nearest export from 'y' is in _any_ of the three buckets, we know the symbol in 'z' - * should never be returned in the final list, so put it in Bucket B. - * 3. Next, imagine we see `foo` from module 'x', the original. Syntactically, it doesn’t look like a re-export, so - * we can just check Bucket C to see if we put any aliases to the original in there. If they exist, throw them out. - * Put this symbol in Bucket A. - * 4. After we’ve iterated through every symbol of every module, any symbol left in Bucket C means that step 3 didn’t - * occur for that symbol---that is, the original symbol is not in Bucket A, so we should include the alias. Move - * everything from Bucket C to Bucket A. - */ - function getSymbolsFromOtherSourceFileExports(target, host) { - var cached = importSuggestionsCache && importSuggestionsCache.get(sourceFile.fileName, typeChecker, detailsEntryId && host.getProjectVersion ? host.getProjectVersion() : undefined); - if (cached) { - log("getSymbolsFromOtherSourceFileExports: Using cached list"); - return cached; - } - var startTime = ts.timestamp(); - log("getSymbolsFromOtherSourceFileExports: Recomputing list" + (detailsEntryId ? " for details entry" : "")); - var seenResolvedModules = new ts.Map(); - var seenExports = new ts.Map(); - /** Bucket B */ - var aliasesToAlreadyIncludedSymbols = new ts.Map(); - /** Bucket C */ - var aliasesToReturnIfOriginalsAreMissing = new ts.Map(); - /** Bucket A */ - var results = []; - /** Ids present in `results` for faster lookup */ - var resultSymbolIds = new ts.Map(); - ts.codefix.forEachExternalModuleToImportFrom(program, host, sourceFile, !detailsEntryId, /*useAutoImportProvider*/ true, function (moduleSymbol, _, program, isFromPackageJson) { - // Perf -- ignore other modules if this is a request for details - if (detailsEntryId && detailsEntryId.source && ts.stripQuotes(moduleSymbol.name) !== detailsEntryId.source) { - return; - } - var typeChecker = program.getTypeChecker(); - var resolvedModuleSymbol = typeChecker.resolveExternalModuleSymbol(moduleSymbol); - // resolvedModuleSymbol may be a namespace. A namespace may be `export =` by multiple module declarations, but only keep the first one. - if (!ts.addToSeen(seenResolvedModules, ts.getSymbolId(resolvedModuleSymbol))) { + /** Mutates `symbols`, `symbolToOriginInfoMap`, and `symbolToSortTextIdMap` */ + function collectAutoImports(resolveModuleSpecifiers) { + var _a, _b, _c, _d, _e; + if (!shouldOfferImportCompletions()) + return; + ts.Debug.assert(!(detailsEntryId === null || detailsEntryId === void 0 ? void 0 : detailsEntryId.data)); + var start = ts.timestamp(); + var moduleSpecifierCache = (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host); + (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, "collectAutoImports: starting, " + (resolveModuleSpecifiers ? "" : "not ") + "resolving module specifiers"); + if (moduleSpecifierCache) { + (_c = host.log) === null || _c === void 0 ? void 0 : _c.call(host, "collectAutoImports: module specifier cache size: " + moduleSpecifierCache.count()); + } + var lowerCaseTokenText = previousToken && ts.isIdentifier(previousToken) ? previousToken.text.toLowerCase() : ""; + var exportInfo = ts.codefix.getSymbolToExportInfoMap(sourceFile, host, program); + var packageJsonAutoImportProvider = (_d = host.getPackageJsonAutoImportProvider) === null || _d === void 0 ? void 0 : _d.call(host); + var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, host); + exportInfo.forEach(function (info, key) { + var symbolName = key.substring(0, key.indexOf("|")); + if (!detailsEntryId && ts.isStringANonContextualKeyword(symbolName)) return; - } - // Don't add another completion for `export =` of a symbol that's already global. - // So in `declare namespace foo {} declare module "foo" { export = foo; }`, there will just be the global completion for `foo`. - if (resolvedModuleSymbol !== moduleSymbol && ts.every(resolvedModuleSymbol.declarations, ts.isNonGlobalDeclaration)) { - pushSymbol(resolvedModuleSymbol, moduleSymbol, isFromPackageJson, /*skipFilter*/ true); - } - for (var _i = 0, _a = typeChecker.getExportsAndPropertiesOfModule(moduleSymbol); _i < _a.length; _i++) { - var symbol = _a[_i]; - var symbolId = ts.getSymbolId(symbol).toString(); - // `getExportsAndPropertiesOfModule` can include duplicates - if (!ts.addToSeen(seenExports, symbolId)) { - continue; - } - // If this is `export { _break as break };` (a keyword) -- skip this and prefer the keyword completion. - if (ts.some(symbol.declarations, function (d) { return ts.isExportSpecifier(d) && !!d.propertyName && ts.isIdentifierANonContextualKeyword(d.name); })) { - continue; - } - // If `symbol.parent !== moduleSymbol`, this is an `export * from "foo"` re-export. Those don't create new symbols. - var isExportStarFromReExport = typeChecker.getMergedSymbol(symbol.parent) !== resolvedModuleSymbol; - // If `!!d.parent.parent.moduleSpecifier`, this is `export { foo } from "foo"` re-export, which creates a new symbol (thus isn't caught by the first check). - if (isExportStarFromReExport || ts.some(symbol.declarations, function (d) { return ts.isExportSpecifier(d) && !d.propertyName && !!d.parent.parent.moduleSpecifier; })) { - // Walk the export chain back one module (step 1 or 2 in diagrammed example). - // Or, in the case of `export * from "foo"`, `symbol` already points to the original export, so just use that. - var nearestExportSymbol = isExportStarFromReExport ? symbol : getNearestExportSymbol(symbol); - if (!nearestExportSymbol) - continue; - var nearestExportSymbolId = ts.getSymbolId(nearestExportSymbol).toString(); - var symbolHasBeenSeen = resultSymbolIds.has(nearestExportSymbolId) || aliasesToAlreadyIncludedSymbols.has(nearestExportSymbolId); - if (!symbolHasBeenSeen) { - aliasesToReturnIfOriginalsAreMissing.set(nearestExportSymbolId, { alias: symbol, moduleSymbol: moduleSymbol, isFromPackageJson: isFromPackageJson }); - aliasesToAlreadyIncludedSymbols.set(symbolId, true); - } - else { - // Perf - we know this symbol is an alias to one that’s already covered in `symbols`, so store it here - // in case another symbol re-exports this one; that way we can short-circuit as soon as we see this symbol id. - ts.addToSeen(aliasesToAlreadyIncludedSymbols, symbolId); - } - } - else { - // This is not a re-export, so see if we have any aliases pending and remove them (step 3 in diagrammed example) - aliasesToReturnIfOriginalsAreMissing.delete(symbolId); - pushSymbol(symbol, moduleSymbol, isFromPackageJson, /*skipFilter*/ false); - } + var isCompletionDetailsMatch = detailsEntryId && ts.some(info, function (i) { return detailsEntryId.source === ts.stripQuotes(i.moduleSymbol.name); }); + if (isCompletionDetailsMatch || isNameMatch(symbolName)) { + // If we don't need to resolve module specifiers, we can use any re-export that is importable at all + // (We need to ensure that at least one is importable to show a completion.) + var _a = resolveModuleSpecifiers + ? ts.codefix.getModuleSpecifierForBestExportInfo(info, sourceFile, program, host, preferences) + : { moduleSpecifier: undefined, exportInfo: ts.find(info, isImportableExportInfo) }, moduleSpecifier = _a.moduleSpecifier, exportInfo_1 = _a.exportInfo; + if (!exportInfo_1) + return; + var moduleFile = ts.tryCast(exportInfo_1.moduleSymbol.valueDeclaration, ts.isSourceFile); + var isDefaultExport = exportInfo_1.exportKind === 1 /* Default */; + var symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(exportInfo_1.symbol) || exportInfo_1.symbol; + pushAutoImportSymbol(symbol, { + kind: resolveModuleSpecifiers ? 32 /* ResolvedExport */ : 4 /* Export */, + moduleSpecifier: moduleSpecifier, + symbolName: symbolName, + exportName: exportInfo_1.exportKind === 2 /* ExportEquals */ ? "export=" /* ExportEquals */ : exportInfo_1.symbol.name, + fileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName, + isDefaultExport: isDefaultExport, + moduleSymbol: exportInfo_1.moduleSymbol, + isFromPackageJson: exportInfo_1.isFromPackageJson, + }); } }); - // By this point, any potential duplicates that were actually duplicates have been - // removed, so the rest need to be added. (Step 4 in diagrammed example) - aliasesToReturnIfOriginalsAreMissing.forEach(function (_a) { - var alias = _a.alias, moduleSymbol = _a.moduleSymbol, isFromPackageJson = _a.isFromPackageJson; - return pushSymbol(alias, moduleSymbol, isFromPackageJson, /*skipFilter*/ false); - }); - log("getSymbolsFromOtherSourceFileExports: " + (ts.timestamp() - startTime)); - return results; - function pushSymbol(symbol, moduleSymbol, isFromPackageJson, skipFilter) { - var isDefaultExport = symbol.escapedName === "default" /* Default */; - if (isDefaultExport) { - symbol = ts.getLocalSymbolForExportDefault(symbol) || symbol; + (_e = host.log) === null || _e === void 0 ? void 0 : _e.call(host, "collectAutoImports: done in " + (ts.timestamp() - start) + " ms"); + function isNameMatch(symbolName) { + var lowerCaseSymbolName = symbolName.toLowerCase(); + if (resolveModuleSpecifiers && lowerCaseTokenText) { + // Use a more restrictive filter if resolving module specifiers since resolving module specifiers is expensive. + return lowerCaseTokenText[0] === lowerCaseSymbolName[0] && stringContainsCharactersInOrder(lowerCaseSymbolName, lowerCaseTokenText); } - if (typeChecker.isUndefinedSymbol(symbol)) { - return; + return stringContainsCharactersInOrder(lowerCaseSymbolName, lowerCaseTokenText); + } + function isImportableExportInfo(info) { + var moduleFile = ts.tryCast(info.moduleSymbol.valueDeclaration, ts.isSourceFile); + if (!moduleFile) { + return packageJsonFilter + ? packageJsonFilter.allowsImportingAmbientModule(info.moduleSymbol, getModuleSpecifierResolutionHost(info.isFromPackageJson)) + : true; } - ts.addToSeen(resultSymbolIds, ts.getSymbolId(symbol)); - var origin = { kind: 4 /* Export */, moduleSymbol: moduleSymbol, isDefaultExport: isDefaultExport, isFromPackageJson: isFromPackageJson }; - results.push({ - symbol: symbol, - symbolName: ts.getNameForExportedSymbol(symbol, target), - origin: origin, - skipFilter: skipFilter, - }); + return ts.isImportableFile(info.isFromPackageJson ? packageJsonAutoImportProvider : program, sourceFile, moduleFile, packageJsonFilter, getModuleSpecifierResolutionHost(info.isFromPackageJson), moduleSpecifierCache); } } - function getNearestExportSymbol(fromSymbol) { - return findAlias(typeChecker, fromSymbol, function (alias) { - return ts.some(alias.declarations, function (d) { return ts.isExportSpecifier(d) || !!d.localSymbol; }); - }); + function pushAutoImportSymbol(symbol, origin) { + var symbolId = ts.getSymbolId(symbol); + if (symbolToSortTextIdMap[symbolId] === SortTextId.GlobalsOrKeywords) { + // If an auto-importable symbol is available as a global, don't add the auto import + return; + } + symbolToOriginInfoMap[symbols.length] = origin; + symbolToSortTextIdMap[symbolId] = importCompletionNode ? SortTextId.LocationPriority : SortTextId.AutoImportSuggestions; + symbols.push(symbol); } /** * True if you could remove some characters in `a` to get `b`. @@ -121170,7 +125587,8 @@ var ts; return true; } var characterIndex = 0; - for (var strIndex = 0; strIndex < str.length; strIndex++) { + var len = str.length; + for (var strIndex = 0; strIndex < len; strIndex++) { if (str.charCodeAt(strIndex) === characters.charCodeAt(characterIndex)) { characterIndex++; if (characterIndex === characters.length) { @@ -121206,7 +125624,7 @@ var ts; return true; } if (contextToken.kind === 31 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 275 /* JsxOpeningElement */) { + if (contextToken.parent.kind === 277 /* JsxOpeningElement */) { // Two possibilities: // 1.
/**/ // - contextToken: GreaterThanToken (before cursor) @@ -121216,54 +125634,56 @@ var ts; // - contextToken: GreaterThanToken (before cursor) // - location: GreaterThanToken (after cursor) // - same parent (JSXOpeningElement) - return location.parent.kind !== 275 /* JsxOpeningElement */; + return location.parent.kind !== 277 /* JsxOpeningElement */; } - if (contextToken.parent.kind === 276 /* JsxClosingElement */ || contextToken.parent.kind === 274 /* JsxSelfClosingElement */) { - return !!contextToken.parent.parent && contextToken.parent.parent.kind === 273 /* JsxElement */; + if (contextToken.parent.kind === 278 /* JsxClosingElement */ || contextToken.parent.kind === 276 /* JsxSelfClosingElement */) { + return !!contextToken.parent.parent && contextToken.parent.parent.kind === 275 /* JsxElement */; } } return false; } - function isNewIdentifierDefinitionLocation(previousToken) { - if (previousToken) { - var containingNodeKind = previousToken.parent.kind; + function isNewIdentifierDefinitionLocation() { + if (contextToken) { + var containingNodeKind = contextToken.parent.kind; // Previous token may have been a keyword that was converted to an identifier. - switch (keywordForNode(previousToken)) { + switch (keywordForNode(contextToken)) { case 27 /* CommaToken */: - return containingNodeKind === 203 /* CallExpression */ // func( a, | - || containingNodeKind === 166 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 204 /* NewExpression */ // new C(a, | - || containingNodeKind === 199 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 216 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 174 /* FunctionType */; // var x: (s: string, list| + return containingNodeKind === 205 /* CallExpression */ // func( a, | + || containingNodeKind === 168 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 206 /* NewExpression */ // new C(a, | + || containingNodeKind === 201 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 218 /* BinaryExpression */ // const x = (a, | + || containingNodeKind === 176 /* FunctionType */ // var x: (s: string, list| + || containingNodeKind === 202 /* ObjectLiteralExpression */; // const obj = { x, | case 20 /* OpenParenToken */: - return containingNodeKind === 203 /* CallExpression */ // func( | - || containingNodeKind === 166 /* Constructor */ // constructor( | - || containingNodeKind === 204 /* NewExpression */ // new C(a| - || containingNodeKind === 207 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 186 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + return containingNodeKind === 205 /* CallExpression */ // func( | + || containingNodeKind === 168 /* Constructor */ // constructor( | + || containingNodeKind === 206 /* NewExpression */ // new C(a| + || containingNodeKind === 209 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 188 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case 22 /* OpenBracketToken */: - return containingNodeKind === 199 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 171 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 158 /* ComputedPropertyName */; // [ | /* this can become an index signature */ - case 139 /* ModuleKeyword */: // module | - case 140 /* NamespaceKeyword */: // namespace | + return containingNodeKind === 201 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 173 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 160 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + case 140 /* ModuleKeyword */: // module | + case 141 /* NamespaceKeyword */: // namespace | return true; case 24 /* DotToken */: - return containingNodeKind === 256 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 258 /* ModuleDeclaration */; // module A.| case 18 /* OpenBraceToken */: - return containingNodeKind === 252 /* ClassDeclaration */; // class A{ | - case 62 /* EqualsToken */: - return containingNodeKind === 249 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 216 /* BinaryExpression */; // x = a| + return containingNodeKind === 254 /* ClassDeclaration */ // class A { | + || containingNodeKind === 202 /* ObjectLiteralExpression */; // const obj = { | + case 63 /* EqualsToken */: + return containingNodeKind === 251 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 218 /* BinaryExpression */; // x = a| case 15 /* TemplateHead */: - return containingNodeKind === 218 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 220 /* TemplateExpression */; // `aa ${| case 16 /* TemplateMiddle */: - return containingNodeKind === 228 /* TemplateSpan */; // `aa ${10} dd ${| - case 122 /* PublicKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - return containingNodeKind === 163 /* PropertyDeclaration */; // class A{ public | + return containingNodeKind === 230 /* TemplateSpan */; // `aa ${10} dd ${| + case 123 /* PublicKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + return containingNodeKind === 165 /* PropertyDeclaration */; // class A{ public | } } return false; @@ -121276,6 +125696,25 @@ var ts; return (ts.isRegularExpressionLiteral(contextToken) || ts.isStringTextContainingNode(contextToken)) && (ts.rangeContainsPositionExclusive(ts.createTextRangeFromSpan(ts.createTextSpanFromNode(contextToken)), position) || position === contextToken.end && (!!contextToken.isUnterminated || ts.isRegularExpressionLiteral(contextToken))); } + function tryGetObjectTypeLiteralInTypeArgumentCompletionSymbols() { + var typeLiteralNode = tryGetTypeLiteralNode(contextToken); + if (!typeLiteralNode) + return 0 /* Continue */; + var intersectionTypeNode = ts.isIntersectionTypeNode(typeLiteralNode.parent) ? typeLiteralNode.parent : undefined; + var containerTypeNode = intersectionTypeNode || typeLiteralNode; + var containerExpectedType = getConstraintOfTypeArgumentProperty(containerTypeNode, typeChecker); + if (!containerExpectedType) + return 0 /* 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.filter(members, function (s) { return !existingMemberEscapedNames.has(s.escapedName); }); + completionKind = 0 /* ObjectPropertyDeclaration */; + isNewIdentifierLocation = true; + return 1 /* Success */; + } /** * Aggregates relevant symbols for completion in object literals and object binding patterns. * Relevant symbols are stored in the captured 'symbols' variable. @@ -121290,7 +125729,7 @@ var ts; completionKind = 0 /* ObjectPropertyDeclaration */; var typeMembers; var existingMembers; - if (objectLikeContainer.kind === 200 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 202 /* ObjectLiteralExpression */) { var instantiatedType = tryGetObjectLiteralContextualType(objectLikeContainer, typeChecker); // Check completions for Object property value shorthand if (instantiatedType === undefined) { @@ -121315,7 +125754,7 @@ var ts; } } else { - ts.Debug.assert(objectLikeContainer.kind === 196 /* ObjectBindingPattern */); + ts.Debug.assert(objectLikeContainer.kind === 198 /* ObjectBindingPattern */); // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -121326,12 +125765,12 @@ 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.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 239 /* ForOfStatement */; - if (!canGetType && rootDeclaration.kind === 160 /* Parameter */) { + var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 241 /* ForOfStatement */; + if (!canGetType && rootDeclaration.kind === 162 /* Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 165 /* MethodDeclaration */ || rootDeclaration.parent.kind === 168 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 167 /* MethodDeclaration */ || rootDeclaration.parent.kind === 170 /* SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -121378,9 +125817,9 @@ var ts; if (!namedImportsOrExports) return 0 /* Continue */; // try to show exported member for imported/re-exported module - var moduleSpecifier = (namedImportsOrExports.kind === 264 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; + var moduleSpecifier = (namedImportsOrExports.kind === 266 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; if (!moduleSpecifier) - return namedImportsOrExports.kind === 264 /* NamedImports */ ? 2 /* Fail */ : 0 /* Continue */; + return namedImportsOrExports.kind === 266 /* NamedImports */ ? 2 /* Fail */ : 0 /* Continue */; var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); // TODO: GH#18217 if (!moduleSpecifierSymbol) return 2 /* Fail */; @@ -121415,7 +125854,7 @@ var ts; var _a, _b; symbols.push(symbol); if ((_b = (_a = localsContainer.symbol) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.has(name)) { - symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.OptionalMember; + symbolToSortTextIdMap[ts.getSymbolId(symbol)] = SortTextId.OptionalMember; } }); return 1 /* Success */; @@ -121440,7 +125879,7 @@ var ts; var classElement = contextToken.kind === 26 /* SemicolonToken */ ? contextToken.parent.parent : contextToken.parent; var classElementModifierFlags = ts.isClassElement(classElement) ? ts.getEffectiveModifierFlags(classElement) : 0 /* None */; // If this is context token is not something we are editing now, consider if this would lead to be modifier - if (contextToken.kind === 78 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { + if (contextToken.kind === 79 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { switch (contextToken.getText()) { case "private": classElementModifierFlags = classElementModifierFlags | 8 /* Private */; @@ -121448,12 +125887,16 @@ var ts; case "static": classElementModifierFlags = classElementModifierFlags | 32 /* Static */; break; + case "override": + classElementModifierFlags = classElementModifierFlags | 16384 /* Override */; + break; } } // No member list for private methods if (!(classElementModifierFlags & 8 /* Private */)) { // List of property symbols of base type that are not private and already implemented - var baseSymbols = ts.flatMap(ts.getAllSuperTypeNodes(decl), function (baseTypeNode) { + var baseTypeNodes = ts.isClassLike(decl) && classElementModifierFlags & 16384 /* 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 */ ? (type === null || type === void 0 ? void 0 : type.symbol) && typeChecker.getPropertiesOfType(typeChecker.getTypeOfSymbolAtLocation(type.symbol, decl)) : @@ -121479,7 +125922,7 @@ var ts; break; case 41 /* AsteriskToken */: return ts.isMethodDeclaration(parent) ? ts.tryCast(parent.parent, ts.isObjectLiteralExpression) : undefined; - case 78 /* Identifier */: + case 79 /* Identifier */: return contextToken.text === "async" && ts.isShorthandPropertyAssignment(contextToken.parent) ? contextToken.parent.parent : undefined; } @@ -121532,12 +125975,12 @@ var ts; case 31 /* GreaterThanToken */: // End of a type argument list case 30 /* LessThanSlashToken */: case 43 /* SlashToken */: - case 78 /* Identifier */: - case 201 /* PropertyAccessExpression */: - case 281 /* JsxAttributes */: - case 280 /* JsxAttribute */: - case 282 /* JsxSpreadAttribute */: - if (parent && (parent.kind === 274 /* JsxSelfClosingElement */ || parent.kind === 275 /* JsxOpeningElement */)) { + case 79 /* Identifier */: + case 203 /* PropertyAccessExpression */: + case 283 /* JsxAttributes */: + case 282 /* JsxAttribute */: + case 284 /* JsxSpreadAttribute */: + if (parent && (parent.kind === 276 /* JsxSelfClosingElement */ || parent.kind === 277 /* JsxOpeningElement */)) { if (contextToken.kind === 31 /* GreaterThanToken */) { var precedingToken = ts.findPrecedingToken(contextToken.pos, sourceFile, /*startNode*/ undefined); if (!parent.typeArguments || (precedingToken && precedingToken.kind === 43 /* SlashToken */)) @@ -121545,7 +125988,7 @@ var ts; } return parent; } - else if (parent.kind === 280 /* JsxAttribute */) { + else if (parent.kind === 282 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -121557,7 +126000,7 @@ var ts; // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement case 10 /* StringLiteral */: - if (parent && ((parent.kind === 280 /* JsxAttribute */) || (parent.kind === 282 /* JsxSpreadAttribute */))) { + if (parent && ((parent.kind === 282 /* JsxAttribute */) || (parent.kind === 284 /* JsxSpreadAttribute */))) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -121567,8 +126010,8 @@ var ts; break; case 19 /* CloseBraceToken */: if (parent && - parent.kind === 283 /* JsxExpression */ && - parent.parent && parent.parent.kind === 280 /* JsxAttribute */) { + parent.kind === 285 /* JsxExpression */ && + parent.parent && parent.parent.kind === 282 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -121576,7 +126019,7 @@ var ts; // each JsxAttribute can have initializer as JsxExpression return parent.parent.parent.parent; } - if (parent && parent.kind === 282 /* JsxSpreadAttribute */) { + if (parent && parent.kind === 284 /* JsxSpreadAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -121596,67 +126039,67 @@ var ts; var containingNodeKind = parent.kind; switch (contextToken.kind) { case 27 /* CommaToken */: - return containingNodeKind === 249 /* VariableDeclaration */ || + return containingNodeKind === 251 /* VariableDeclaration */ || isVariableDeclarationListButNotTypeArgument(contextToken) || - containingNodeKind === 232 /* VariableStatement */ || - containingNodeKind === 255 /* EnumDeclaration */ || // enum a { foo, | + containingNodeKind === 234 /* VariableStatement */ || + containingNodeKind === 257 /* EnumDeclaration */ || // enum a { foo, | isFunctionLikeButNotConstructor(containingNodeKind) || - containingNodeKind === 253 /* InterfaceDeclaration */ || // interface A= contextToken.pos); case 24 /* DotToken */: - return containingNodeKind === 197 /* ArrayBindingPattern */; // var [.| + return containingNodeKind === 199 /* ArrayBindingPattern */; // var [.| case 58 /* ColonToken */: - return containingNodeKind === 198 /* BindingElement */; // var {x :html| + return containingNodeKind === 200 /* BindingElement */; // var {x :html| case 22 /* OpenBracketToken */: - return containingNodeKind === 197 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 199 /* ArrayBindingPattern */; // var [x| case 20 /* OpenParenToken */: - return containingNodeKind === 287 /* CatchClause */ || + return containingNodeKind === 289 /* CatchClause */ || isFunctionLikeButNotConstructor(containingNodeKind); case 18 /* OpenBraceToken */: - return containingNodeKind === 255 /* EnumDeclaration */; // enum a { | + return containingNodeKind === 257 /* EnumDeclaration */; // enum a { | case 29 /* LessThanToken */: - return containingNodeKind === 252 /* ClassDeclaration */ || // class A< | - containingNodeKind === 221 /* ClassExpression */ || // var C = class D< | - containingNodeKind === 253 /* InterfaceDeclaration */ || // interface A< | - containingNodeKind === 254 /* TypeAliasDeclaration */ || // type List< | + return containingNodeKind === 254 /* ClassDeclaration */ || // class A< | + containingNodeKind === 223 /* ClassExpression */ || // var C = class D< | + containingNodeKind === 255 /* InterfaceDeclaration */ || // interface A< | + containingNodeKind === 256 /* TypeAliasDeclaration */ || // type List< | ts.isFunctionLikeKind(containingNodeKind); - case 123 /* StaticKeyword */: - return containingNodeKind === 163 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); + case 124 /* StaticKeyword */: + return containingNodeKind === 165 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); case 25 /* DotDotDotToken */: - return containingNodeKind === 160 /* Parameter */ || - (!!parent.parent && parent.parent.kind === 197 /* ArrayBindingPattern */); // var [...z| - case 122 /* PublicKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - return containingNodeKind === 160 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); - case 126 /* AsKeyword */: - return containingNodeKind === 265 /* ImportSpecifier */ || - containingNodeKind === 270 /* ExportSpecifier */ || - containingNodeKind === 263 /* NamespaceImport */; - case 134 /* GetKeyword */: - case 146 /* SetKeyword */: + return containingNodeKind === 162 /* Parameter */ || + (!!parent.parent && parent.parent.kind === 199 /* ArrayBindingPattern */); // var [...z| + case 123 /* PublicKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + return containingNodeKind === 162 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); + case 127 /* AsKeyword */: + return containingNodeKind === 267 /* ImportSpecifier */ || + containingNodeKind === 272 /* ExportSpecifier */ || + containingNodeKind === 265 /* NamespaceImport */; + case 135 /* GetKeyword */: + case 147 /* SetKeyword */: return !isFromObjectTypeDeclaration(contextToken); - case 83 /* ClassKeyword */: - case 91 /* EnumKeyword */: - case 117 /* InterfaceKeyword */: - case 97 /* FunctionKeyword */: - case 112 /* VarKeyword */: - case 99 /* ImportKeyword */: - case 118 /* LetKeyword */: - case 84 /* ConstKeyword */: - case 135 /* InferKeyword */: - case 149 /* TypeKeyword */: // type htm| + 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 136 /* InferKeyword */: + case 150 /* TypeKeyword */: // type htm| return true; case 41 /* AsteriskToken */: return ts.isFunctionLike(contextToken.parent) && !ts.isMethodDeclaration(contextToken.parent); } - // If the previous token is keyword correspoding to class member completion keyword + // If the previous token is keyword corresponding to class member completion keyword // there will be completion available here if (isClassMemberCompletionKeyword(keywordForNode(contextToken)) && isFromObjectTypeDeclaration(contextToken)) { return false; @@ -121674,23 +126117,48 @@ var ts; } // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(contextToken)) { - case 125 /* AbstractKeyword */: - case 83 /* ClassKeyword */: - case 84 /* ConstKeyword */: - case 133 /* DeclareKeyword */: - case 91 /* EnumKeyword */: - case 97 /* FunctionKeyword */: - case 117 /* InterfaceKeyword */: - case 118 /* LetKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 122 /* PublicKeyword */: - case 123 /* StaticKeyword */: - case 112 /* VarKeyword */: + case 126 /* AbstractKeyword */: + case 84 /* ClassKeyword */: + case 85 /* ConstKeyword */: + case 134 /* 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 */: return true; - case 129 /* AsyncKeyword */: + case 130 /* AsyncKeyword */: return ts.isPropertyDeclaration(contextToken.parent); } + // If we are inside a class declaration, and `constructor` is totally not present, + // but we request a completion manually at a whitespace... + var ancestorClassLike = ts.findAncestor(contextToken.parent, ts.isClassLike); + if (ancestorClassLike && contextToken === previousToken && isPreviousPropertyDeclarationTerminated(contextToken, position)) { + return false; // Don't block completions. + } + var ancestorPropertyDeclaraion = ts.getAncestor(contextToken.parent, 165 /* PropertyDeclaration */); + // If we are inside a class declaration and typing `constructor` after property declaration... + if (ancestorPropertyDeclaraion + && contextToken !== previousToken + && ts.isClassLike(previousToken.parent.parent) + // And the cursor is at the token... + && position <= previousToken.end) { + // If we are sure that the previous property declaration is terminated according to newline or semicolon... + if (isPreviousPropertyDeclarationTerminated(contextToken, previousToken.end)) { + return false; // Don't block completions. + } + else if (contextToken.kind !== 63 /* 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) + || ts.hasType(ancestorPropertyDeclaraion))) { + return true; + } + } return ts.isDeclarationName(contextToken) && !ts.isShorthandPropertyAssignment(contextToken.parent) && !ts.isJsxAttribute(contextToken.parent) @@ -121698,8 +126166,13 @@ var ts; // If `contextToken !== previousToken`, this is `class C ex/**/`. && !(ts.isClassLike(contextToken.parent) && (contextToken !== previousToken || position > previousToken.end)); } + function isPreviousPropertyDeclarationTerminated(contextToken, position) { + return contextToken.kind !== 63 /* EqualsToken */ && + (contextToken.kind === 26 /* SemicolonToken */ + || !ts.positionsAreOnSameLine(contextToken.end, position, sourceFile)); + } function isFunctionLikeButNotConstructor(kind) { - return ts.isFunctionLikeKind(kind) && kind !== 166 /* Constructor */; + return ts.isFunctionLikeKind(kind) && kind !== 168 /* Constructor */; } function isDotOfNumericLiteral(contextToken) { if (contextToken.kind === 8 /* NumericLiteral */) { @@ -121709,7 +126182,7 @@ var ts; return false; } function isVariableDeclarationListButNotTypeArgument(node) { - return node.parent.kind === 250 /* VariableDeclarationList */ + return node.parent.kind === 252 /* VariableDeclarationList */ && !ts.isPossiblyTypeArgumentPosition(node, sourceFile, typeChecker); } /** @@ -121727,13 +126200,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 !== 288 /* PropertyAssignment */ && - m.kind !== 289 /* ShorthandPropertyAssignment */ && - m.kind !== 198 /* BindingElement */ && - m.kind !== 165 /* MethodDeclaration */ && - m.kind !== 167 /* GetAccessor */ && - m.kind !== 168 /* SetAccessor */ && - m.kind !== 290 /* SpreadAssignment */) { + if (m.kind !== 290 /* PropertyAssignment */ && + m.kind !== 291 /* ShorthandPropertyAssignment */ && + m.kind !== 200 /* BindingElement */ && + m.kind !== 167 /* MethodDeclaration */ && + m.kind !== 169 /* GetAccessor */ && + m.kind !== 170 /* SetAccessor */ && + m.kind !== 292 /* SpreadAssignment */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -121746,7 +126219,7 @@ var ts; } else if (ts.isBindingElement(m) && m.propertyName) { // include only identifiers in completion list - if (m.propertyName.kind === 78 /* Identifier */) { + if (m.propertyName.kind === 79 /* Identifier */) { existingName = m.propertyName.escapedText; } } @@ -121779,8 +126252,10 @@ var ts; // Set SortText to OptionalMember if it is an optional member function setSortTextToOptionalMember() { symbols.forEach(function (m) { + var _a; if (m.flags & 16777216 /* Optional */) { - symbolToSortTextMap[ts.getSymbolId(m)] = symbolToSortTextMap[ts.getSymbolId(m)] || SortText.OptionalMember; + var symbolId = ts.getSymbolId(m); + symbolToSortTextIdMap[symbolId] = (_a = symbolToSortTextIdMap[symbolId]) !== null && _a !== void 0 ? _a : SortTextId.OptionalMember; } }); } @@ -121792,7 +126267,7 @@ var ts; for (var _i = 0, contextualMemberSymbols_1 = contextualMemberSymbols; _i < contextualMemberSymbols_1.length; _i++) { var contextualMemberSymbol = contextualMemberSymbols_1[_i]; if (membersDeclaredBySpreadAssignment.has(contextualMemberSymbol.name)) { - symbolToSortTextMap[ts.getSymbolId(contextualMemberSymbol)] = SortText.MemberDeclaredBySpreadAssignment; + symbolToSortTextIdMap[ts.getSymbolId(contextualMemberSymbol)] = SortTextId.MemberDeclaredBySpreadAssignment; } } } @@ -121806,10 +126281,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 !== 163 /* PropertyDeclaration */ && - m.kind !== 165 /* MethodDeclaration */ && - m.kind !== 167 /* GetAccessor */ && - m.kind !== 168 /* SetAccessor */) { + if (m.kind !== 165 /* PropertyDeclaration */ && + m.kind !== 167 /* MethodDeclaration */ && + m.kind !== 169 /* GetAccessor */ && + m.kind !== 170 /* SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -121833,7 +126308,7 @@ var ts; return !existingMemberNames.has(propertySymbol.escapedName) && !!propertySymbol.declarations && !(ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 8 /* Private */) && - !(propertySymbol.valueDeclaration && ts.isPrivateIdentifierPropertyDeclaration(propertySymbol.valueDeclaration)); + !(propertySymbol.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(propertySymbol.valueDeclaration)); }); } /** @@ -121851,7 +126326,7 @@ var ts; if (isCurrentlyEditingNode(attr)) { continue; } - if (attr.kind === 280 /* JsxAttribute */) { + if (attr.kind === 282 /* JsxAttribute */) { seenNames.add(attr.name.escapedText); } else if (ts.isJsxSpreadAttribute(attr)) { @@ -121866,8 +126341,35 @@ var ts; return node.getStart(sourceFile) <= position && position <= node.getEnd(); } } + function getAutoImportSymbolFromCompletionEntryData(name, data, program, host) { + var containingProgram = data.isPackageJsonImport ? host.getPackageJsonAutoImportProvider() : program; + var checker = containingProgram.getTypeChecker(); + var moduleSymbol = data.ambientModuleName ? checker.tryFindAmbientModule(data.ambientModuleName) : + data.fileName ? checker.getMergedSymbol(ts.Debug.checkDefined(containingProgram.getSourceFile(data.fileName)).symbol) : + undefined; + if (!moduleSymbol) + return undefined; + var symbol = data.exportName === "export=" /* ExportEquals */ + ? checker.resolveExternalModuleSymbol(moduleSymbol) + : checker.tryGetMemberInModuleExportsAndProperties(data.exportName, moduleSymbol); + if (!symbol) + return undefined; + var isDefaultExport = data.exportName === "default" /* Default */; + symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(symbol) || symbol; + return { + symbol: symbol, + origin: { + kind: data.moduleSpecifier ? 32 /* ResolvedExport */ : 4 /* Export */, + moduleSymbol: moduleSymbol, + symbolName: name, + isDefaultExport: isDefaultExport, + exportName: data.exportName, + fileName: data.fileName, + } + }; + } function getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind, jsxIdentifierExpected) { - var name = originIsExport(origin) ? ts.getNameForExportedSymbol(symbol, target) : symbol.name; + var name = originIncludesSymbolName(origin) ? origin.symbolName : symbol.name; 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) @@ -121877,7 +126379,7 @@ var ts; return undefined; } var validNameResult = { name: name, needsConvertPropertyAccess: false }; - if (ts.isIdentifierText(name, target, jsxIdentifierExpected ? 1 /* JSX */ : 0 /* Standard */) || symbol.valueDeclaration && ts.isPrivateIdentifierPropertyDeclaration(symbol.valueDeclaration)) { + if (ts.isIdentifierText(name, target, jsxIdentifierExpected ? 1 /* JSX */ : 0 /* Standard */) || symbol.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(symbol.valueDeclaration)) { return validNameResult; } switch (kind) { @@ -121901,7 +126403,7 @@ var ts; var _keywordCompletions = []; var allKeywordsCompletions = ts.memoize(function () { var res = []; - for (var i = 80 /* FirstKeyword */; i <= 156 /* LastKeyword */; i++) { + for (var i = 81 /* FirstKeyword */; i <= 158 /* LastKeyword */; i++) { res.push({ name: ts.tokenToString(i), kind: "keyword" /* keyword */, @@ -121927,11 +126429,11 @@ var ts; return false; case 1 /* All */: return isFunctionLikeBodyKeyword(kind) - || kind === 133 /* DeclareKeyword */ - || kind === 139 /* ModuleKeyword */ - || kind === 149 /* TypeKeyword */ - || kind === 140 /* NamespaceKeyword */ - || ts.isTypeKeyword(kind) && kind !== 150 /* UndefinedKeyword */; + || kind === 134 /* DeclareKeyword */ + || kind === 140 /* ModuleKeyword */ + || kind === 150 /* TypeKeyword */ + || kind === 141 /* NamespaceKeyword */ + || ts.isTypeKeyword(kind) && kind !== 151 /* UndefinedKeyword */; case 5 /* FunctionLikeBodyKeywords */: return isFunctionLikeBodyKeyword(kind); case 2 /* ClassElementKeywords */: @@ -121941,7 +126443,7 @@ var ts; case 4 /* ConstructorParameterKeywords */: return ts.isParameterPropertyModifier(kind); case 6 /* TypeAssertionKeywords */: - return ts.isTypeKeyword(kind) || kind === 84 /* ConstKeyword */; + return ts.isTypeKeyword(kind) || kind === 85 /* ConstKeyword */; case 7 /* TypeKeywords */: return ts.isTypeKeyword(kind); default: @@ -121951,57 +126453,59 @@ var ts; } function isTypeScriptOnlyKeyword(kind) { switch (kind) { - case 125 /* AbstractKeyword */: - case 128 /* AnyKeyword */: - case 155 /* BigIntKeyword */: - case 131 /* BooleanKeyword */: - case 133 /* DeclareKeyword */: - case 91 /* EnumKeyword */: - case 154 /* GlobalKeyword */: - case 116 /* ImplementsKeyword */: - case 135 /* InferKeyword */: - case 117 /* InterfaceKeyword */: - case 137 /* IsKeyword */: - case 138 /* KeyOfKeyword */: - case 139 /* ModuleKeyword */: - case 140 /* NamespaceKeyword */: - case 141 /* NeverKeyword */: - case 144 /* NumberKeyword */: - case 145 /* ObjectKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 122 /* PublicKeyword */: - case 142 /* ReadonlyKeyword */: - case 147 /* StringKeyword */: - case 148 /* SymbolKeyword */: - case 149 /* TypeKeyword */: - case 151 /* UniqueKeyword */: - case 152 /* UnknownKeyword */: + case 126 /* AbstractKeyword */: + case 129 /* AnyKeyword */: + case 156 /* BigIntKeyword */: + case 132 /* BooleanKeyword */: + case 134 /* DeclareKeyword */: + case 92 /* EnumKeyword */: + case 155 /* GlobalKeyword */: + case 117 /* ImplementsKeyword */: + case 136 /* InferKeyword */: + case 118 /* InterfaceKeyword */: + case 138 /* IsKeyword */: + case 139 /* KeyOfKeyword */: + case 140 /* ModuleKeyword */: + case 141 /* NamespaceKeyword */: + case 142 /* NeverKeyword */: + case 145 /* NumberKeyword */: + case 146 /* ObjectKeyword */: + case 157 /* OverrideKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + case 123 /* PublicKeyword */: + case 143 /* ReadonlyKeyword */: + case 148 /* StringKeyword */: + case 149 /* SymbolKeyword */: + case 150 /* TypeKeyword */: + case 152 /* UniqueKeyword */: + case 153 /* UnknownKeyword */: return true; default: return false; } } function isInterfaceOrTypeLiteralCompletionKeyword(kind) { - return kind === 142 /* ReadonlyKeyword */; + return kind === 143 /* ReadonlyKeyword */; } function isClassMemberCompletionKeyword(kind) { switch (kind) { - case 125 /* AbstractKeyword */: - case 132 /* ConstructorKeyword */: - case 134 /* GetKeyword */: - case 146 /* SetKeyword */: - case 129 /* AsyncKeyword */: - case 133 /* DeclareKeyword */: + case 126 /* AbstractKeyword */: + case 133 /* ConstructorKeyword */: + case 135 /* GetKeyword */: + case 147 /* SetKeyword */: + case 130 /* AsyncKeyword */: + case 134 /* DeclareKeyword */: + case 157 /* OverrideKeyword */: return true; default: return ts.isClassMemberModifier(kind); } } function isFunctionLikeBodyKeyword(kind) { - return kind === 129 /* AsyncKeyword */ - || kind === 130 /* AwaitKeyword */ - || kind === 126 /* AsKeyword */ + return kind === 130 /* AsyncKeyword */ + || kind === 131 /* AwaitKeyword */ + || kind === 127 /* AsKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind); } function keywordForNode(node) { @@ -122053,7 +126557,7 @@ var ts; function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location, position) { // class c { method() { } | method2() { } } switch (location.kind) { - case 334 /* SyntaxList */: + case 342 /* SyntaxList */: return ts.tryCast(location.parent, ts.isObjectTypeDeclaration); case 1 /* EndOfFileToken */: var cls = ts.tryCast(ts.lastOrUndefined(ts.cast(location.parent, ts.isSourceFile).statements), ts.isObjectTypeDeclaration); @@ -122061,7 +126565,7 @@ var ts; return cls; } break; - case 78 /* Identifier */: { + case 79 /* Identifier */: { // class c { public prop = c| } if (ts.isPropertyDeclaration(location.parent) && location.parent.initializer === location) { return undefined; @@ -122074,8 +126578,14 @@ var ts; } if (!contextToken) return undefined; + // class C { blah; constructor/**/ } and so on + if (location.kind === 133 /* 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 62 /* EqualsToken */: // class c { public prop = | /* global completions */ } + case 63 /* EqualsToken */: // class c { public prop = | /* global completions */ } return undefined; case 26 /* SemicolonToken */: // class c {getValue(): number; | } case 19 /* CloseBraceToken */: // class c { method() { } | } @@ -122099,6 +126609,44 @@ var ts; ? contextToken.parent.parent : undefined; } } + function tryGetTypeLiteralNode(node) { + if (!node) + return undefined; + var parent = node.parent; + switch (node.kind) { + case 18 /* OpenBraceToken */: + if (ts.isTypeLiteralNode(parent)) { + return parent; + } + break; + case 26 /* SemicolonToken */: + case 27 /* CommaToken */: + case 79 /* Identifier */: + if (parent.kind === 164 /* PropertySignature */ && ts.isTypeLiteralNode(parent.parent)) { + return parent.parent; + } + break; + } + return undefined; + } + function getConstraintOfTypeArgumentProperty(node, checker) { + if (!node) + return undefined; + if (ts.isTypeNode(node) && ts.isTypeReferenceType(node.parent)) { + return checker.getTypeArgumentConstraint(node); + } + var t = getConstraintOfTypeArgumentProperty(node.parent, checker); + if (!t) + return undefined; + switch (node.kind) { + case 164 /* PropertySignature */: + return checker.getTypeOfPropertyOfContextualType(t, node.symbol.escapedName); + case 185 /* IntersectionType */: + case 179 /* TypeLiteral */: + case 184 /* UnionType */: + return t; + } + } // TODO: GH#19856 Would like to return `node is Node & { parent: (ClassElement | TypeElement) & { parent: ObjectTypeDeclaration } }` but then compilation takes > 10 minutes function isFromObjectTypeDeclaration(node) { return node.parent && ts.isClassOrTypeElement(node.parent) && ts.isObjectTypeDeclaration(node.parent.parent); @@ -122122,6 +126670,8 @@ var ts; return !!contextToken && (ts.isStringLiteralLike(contextToken) ? !!ts.tryGetImportFromModuleSpecifier(contextToken) : contextToken.kind === 43 /* SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); + case " ": + return !!contextToken && ts.isImportKeyword(contextToken) && contextToken.parent.kind === 299 /* SourceFile */; default: return ts.Debug.assertNever(triggerCharacter); } @@ -122130,14 +126680,6 @@ var ts; var left = _a.left; return ts.nodeIsMissing(left); } - function findAlias(typeChecker, symbol, predicate) { - var currentAlias = symbol; - while (currentAlias.flags & 2097152 /* Alias */ && (currentAlias = typeChecker.getImmediateAliasedSymbol(currentAlias))) { - if (predicate(currentAlias)) { - return currentAlias; - } - } - } /** Determines if a type is exactly the same type resolved by the global 'self', 'global', or 'globalThis'. */ 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 @@ -122164,11 +126706,71 @@ var ts; if (type) { return type; } - if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 /* EqualsToken */) { + if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* EqualsToken */ && node === node.parent.left) { + // Object literal is assignment pattern: ({ | } = x) return typeChecker.getTypeAtLocation(node.parent); } return undefined; } + function getImportCompletionNode(contextToken) { + var candidate = getCandidate(); + return candidate === 154 /* FromKeyword */ || candidate && ts.rangeIsOnSingleLine(candidate, candidate.getSourceFile()) ? candidate : undefined; + function getCandidate() { + var parent = contextToken.parent; + if (ts.isImportEqualsDeclaration(parent)) { + return isModuleSpecifierMissingOrEmpty(parent.moduleReference) ? parent : undefined; + } + if (ts.isNamedImports(parent) || ts.isNamespaceImport(parent)) { + if (isModuleSpecifierMissingOrEmpty(parent.parent.parent.moduleSpecifier) && (ts.isNamespaceImport(parent) || parent.elements.length < 2) && !parent.parent.name) { + // At `import { ... } |` or `import * as Foo |`, the only possible completion is `from` + return contextToken.kind === 19 /* CloseBraceToken */ || contextToken.kind === 79 /* Identifier */ + ? 154 /* FromKeyword */ + : parent.parent.parent; + } + return undefined; + } + if (ts.isImportKeyword(contextToken) && ts.isSourceFile(parent)) { + // A lone import keyword with nothing following it does not parse as a statement at all + return contextToken; + } + if (ts.isImportKeyword(contextToken) && ts.isImportDeclaration(parent)) { + // `import s| from` + return isModuleSpecifierMissingOrEmpty(parent.moduleSpecifier) ? parent : undefined; + } + return undefined; + } + } + function isModuleSpecifierMissingOrEmpty(specifier) { + var _a; + if (ts.nodeIsMissing(specifier)) + return true; + return !((_a = ts.tryCast(ts.isExternalModuleReference(specifier) ? specifier.expression : specifier, ts.isStringLiteralLike)) === null || _a === void 0 ? void 0 : _a.text); + } + function getVariableDeclaration(property) { + var variableDeclaration = ts.findAncestor(property, function (node) { + return ts.isFunctionBlock(node) || isArrowFunctionBody(node) || ts.isBindingPattern(node) + ? "quit" + : ts.isVariableDeclaration(node); + }); + return variableDeclaration; + } + function isArrowFunctionBody(node) { + return node.parent && ts.isArrowFunction(node.parent) && node.parent.body === node; + } + ; + /** True if symbol is a type or a module containing at least one type. */ + function symbolCanBeReferencedAtTypeLocation(symbol, checker, seenModules) { + if (seenModules === void 0) { seenModules = new ts.Map(); } + var sym = ts.skipAlias(symbol.exportSymbol || symbol, checker); + return !!(sym.flags & 788968 /* Type */) || + !!(sym.flags & 1536 /* Module */) && + ts.addToSeen(seenModules, ts.getSymbolId(sym)) && + checker.getExportsOfModule(sym).some(function (e) { return symbolCanBeReferencedAtTypeLocation(e, checker, seenModules); }); + } + function isDeprecated(symbol, checker) { + var declarations = ts.skipAlias(symbol, checker).declarations; + return !!ts.length(declarations) && ts.every(declarations, ts.isDeprecatedDeclaration); + } })(Completions = ts.Completions || (ts.Completions = {})); })(ts || (ts = {})); var ts; @@ -122203,10 +126805,13 @@ var ts; if (!referenceEntries) return undefined; var map = ts.arrayToMultiMap(referenceEntries.map(ts.FindAllReferences.toHighlightSpan), function (e) { return e.fileName; }, function (e) { return e.span; }); - return ts.arrayFrom(map.entries(), function (_a) { + var getCanonicalFileName = ts.createGetCanonicalFileName(program.useCaseSensitiveFileNames()); + return ts.mapDefined(ts.arrayFrom(map.entries()), function (_a) { var fileName = _a[0], highlightSpans = _a[1]; if (!sourceFilesSet.has(fileName)) { - ts.Debug.assert(program.redirectTargetsMap.has(fileName)); + if (!program.redirectTargetsMap.has(ts.toPath(fileName, program.getCurrentDirectory(), getCanonicalFileName))) { + return undefined; + } var redirectTarget_1 = program.getSourceFile(fileName); var redirect = ts.find(sourceFilesToSearch, function (f) { return !!f.redirectInfo && f.redirectInfo.redirectTarget === redirectTarget_1; }); fileName = redirect.fileName; @@ -122221,44 +126826,44 @@ var ts; } function getHighlightSpans(node, sourceFile) { switch (node.kind) { - case 98 /* IfKeyword */: - case 90 /* ElseKeyword */: + case 99 /* IfKeyword */: + case 91 /* ElseKeyword */: return ts.isIfStatement(node.parent) ? getIfElseOccurrences(node.parent, sourceFile) : undefined; - case 104 /* ReturnKeyword */: + case 105 /* ReturnKeyword */: return useParent(node.parent, ts.isReturnStatement, getReturnOccurrences); - case 108 /* ThrowKeyword */: + case 109 /* ThrowKeyword */: return useParent(node.parent, ts.isThrowStatement, getThrowOccurrences); - case 110 /* TryKeyword */: - case 82 /* CatchKeyword */: - case 95 /* FinallyKeyword */: - var tryStatement = node.kind === 82 /* CatchKeyword */ ? node.parent.parent : node.parent; + case 111 /* TryKeyword */: + case 83 /* CatchKeyword */: + case 96 /* FinallyKeyword */: + var tryStatement = node.kind === 83 /* CatchKeyword */ ? node.parent.parent : node.parent; return useParent(tryStatement, ts.isTryStatement, getTryCatchFinallyOccurrences); - case 106 /* SwitchKeyword */: + case 107 /* SwitchKeyword */: return useParent(node.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); - case 81 /* CaseKeyword */: - case 87 /* DefaultKeyword */: { + case 82 /* CaseKeyword */: + case 88 /* DefaultKeyword */: { if (ts.isDefaultClause(node.parent) || ts.isCaseClause(node.parent)) { return useParent(node.parent.parent.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); } return undefined; } - case 80 /* BreakKeyword */: - case 85 /* ContinueKeyword */: + case 81 /* BreakKeyword */: + case 86 /* ContinueKeyword */: return useParent(node.parent, ts.isBreakOrContinueStatement, getBreakOrContinueStatementOccurrences); - case 96 /* ForKeyword */: - case 114 /* WhileKeyword */: - case 89 /* DoKeyword */: + case 97 /* ForKeyword */: + case 115 /* WhileKeyword */: + case 90 /* DoKeyword */: return useParent(node.parent, function (n) { return ts.isIterationStatement(n, /*lookInLabeledStatements*/ true); }, getLoopBreakContinueOccurrences); - case 132 /* ConstructorKeyword */: - return getFromAllDeclarations(ts.isConstructorDeclaration, [132 /* ConstructorKeyword */]); - case 134 /* GetKeyword */: - case 146 /* SetKeyword */: - return getFromAllDeclarations(ts.isAccessor, [134 /* GetKeyword */, 146 /* SetKeyword */]); - case 130 /* AwaitKeyword */: + case 133 /* ConstructorKeyword */: + return getFromAllDeclarations(ts.isConstructorDeclaration, [133 /* ConstructorKeyword */]); + case 135 /* GetKeyword */: + case 147 /* SetKeyword */: + return getFromAllDeclarations(ts.isAccessor, [135 /* GetKeyword */, 147 /* SetKeyword */]); + case 131 /* AwaitKeyword */: return useParent(node.parent, ts.isAwaitExpression, getAsyncAndAwaitOccurrences); - case 129 /* AsyncKeyword */: + case 130 /* AsyncKeyword */: return highlightSpans(getAsyncAndAwaitOccurrences(node)); - case 124 /* YieldKeyword */: + case 125 /* YieldKeyword */: return highlightSpans(getYieldOccurrences(node)); default: return ts.isModifierKind(node.kind) && (ts.isDeclaration(node.parent) || ts.isVariableStatement(node.parent)) @@ -122301,7 +126906,7 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (ts.isFunctionBlock(parent) || parent.kind === 297 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 299 /* SourceFile */) { return parent; } // A throw-statement is only owned by a try-statement if the try-statement has @@ -122333,16 +126938,16 @@ var ts; function getBreakOrContinueOwner(statement) { return ts.findAncestor(statement, function (node) { switch (node.kind) { - case 244 /* SwitchStatement */: - if (statement.kind === 240 /* ContinueStatement */) { + case 246 /* SwitchStatement */: + if (statement.kind === 242 /* ContinueStatement */) { return false; } // falls through - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 236 /* WhileStatement */: - case 235 /* DoStatement */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 238 /* WhileStatement */: + case 237 /* DoStatement */: return !statement.label || isLabeledBy(node, statement.label.escapedText); default: // Don't cross function boundaries. @@ -122358,11 +126963,11 @@ var ts; // Types of node whose children might have modifiers. var container = declaration.parent; switch (container.kind) { - case 257 /* ModuleBlock */: - case 297 /* SourceFile */: - case 230 /* Block */: - case 284 /* CaseClause */: - case 285 /* DefaultClause */: + case 259 /* ModuleBlock */: + case 299 /* SourceFile */: + case 232 /* Block */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 128 /* Abstract */ && ts.isClassDeclaration(declaration)) { return __spreadArray(__spreadArray([], declaration.members), [declaration]); @@ -122370,14 +126975,14 @@ var ts; else { return container.statements; } - case 166 /* Constructor */: - case 165 /* MethodDeclaration */: - case 251 /* FunctionDeclaration */: + case 168 /* Constructor */: + case 167 /* MethodDeclaration */: + case 253 /* FunctionDeclaration */: return __spreadArray(__spreadArray([], container.parameters), (ts.isClassLike(container.parent) ? container.parent.members : [])); - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 177 /* TypeLiteral */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: + case 179 /* 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. @@ -122392,7 +126997,7 @@ var ts; } return nodes; // Syntactically invalid positions that the parser might produce anyway - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return undefined; default: ts.Debug.assertNever(container, "Invalid container kind."); @@ -122411,12 +127016,12 @@ var ts; } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 96 /* ForKeyword */, 114 /* WhileKeyword */, 89 /* DoKeyword */)) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 97 /* ForKeyword */, 115 /* WhileKeyword */, 90 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 235 /* DoStatement */) { + if (loopNode.kind === 237 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 114 /* WhileKeyword */)) { + if (pushKeywordIf(keywords, loopTokens[i], 115 /* WhileKeyword */)) { break; } } @@ -122424,7 +127029,7 @@ var ts; } ts.forEach(aggregateAllBreakAndContinueStatements(loopNode.statement), function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 80 /* BreakKeyword */, 85 /* ContinueKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 81 /* BreakKeyword */, 86 /* ContinueKeyword */); } }); return keywords; @@ -122433,13 +127038,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -122447,13 +127052,13 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 106 /* SwitchKeyword */); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 107 /* 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(), 81 /* CaseKeyword */, 87 /* DefaultKeyword */); + pushKeywordIf(keywords, clause.getFirstToken(), 82 /* CaseKeyword */, 88 /* DefaultKeyword */); ts.forEach(aggregateAllBreakAndContinueStatements(clause), function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 80 /* BreakKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 81 /* BreakKeyword */); } }); }); @@ -122461,13 +127066,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement, sourceFile) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 110 /* TryKeyword */); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 111 /* TryKeyword */); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 82 /* CatchKeyword */); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 83 /* CatchKeyword */); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 95 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 95 /* FinallyKeyword */); + var finallyKeyword = ts.findChildOfKind(tryStatement, 96 /* FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 96 /* FinallyKeyword */); } return keywords; } @@ -122478,13 +127083,13 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - keywords.push(ts.findChildOfKind(throwStatement, 108 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 109 /* 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, 104 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 105 /* ReturnKeyword */, sourceFile)); }); } return keywords; @@ -122496,11 +127101,11 @@ var ts; } var keywords = []; ts.forEachReturnStatement(ts.cast(func.body, ts.isBlock), function (returnStatement) { - keywords.push(ts.findChildOfKind(returnStatement, 104 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 105 /* 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, 108 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 109 /* ThrowKeyword */, sourceFile)); }); return keywords; } @@ -122512,13 +127117,13 @@ var ts; var keywords = []; if (func.modifiers) { func.modifiers.forEach(function (modifier) { - pushKeywordIf(keywords, modifier, 129 /* AsyncKeyword */); + pushKeywordIf(keywords, modifier, 130 /* AsyncKeyword */); }); } ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isAwaitExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 130 /* AwaitKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 131 /* AwaitKeyword */); } }); }); @@ -122533,7 +127138,7 @@ var ts; ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isYieldExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 124 /* YieldKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 125 /* YieldKeyword */); } }); }); @@ -122552,7 +127157,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 === 90 /* ElseKeyword */ && i < keywords.length - 1) { + if (keywords[i].kind === 91 /* ElseKeyword */ && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. var shouldCombineElseAndIf = true; @@ -122587,10 +127192,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], 98 /* IfKeyword */); + pushKeywordIf(keywords, children[0], 99 /* 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], 90 /* ElseKeyword */)) { + if (pushKeywordIf(keywords, children[i], 91 /* ElseKeyword */)) { break; } } @@ -122612,6 +127217,9 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + function isDocumentRegistryEntry(entry) { + return !!entry.sourceFile; + } function createDocumentRegistry(useCaseSensitiveFileNames, currentDirectory) { return createDocumentRegistryInternal(useCaseSensitiveFileNames, currentDirectory); } @@ -122628,10 +127236,16 @@ var ts; var entries = buckets.get(name); var sourceFiles = []; entries.forEach(function (entry, name) { - sourceFiles.push({ - name: name, - refCount: entry.languageServiceRefCount - }); + if (isDocumentRegistryEntry(entry)) { + sourceFiles.push({ + name: name, + scriptKind: entry.sourceFile.scriptKind, + refCount: entry.languageServiceRefCount + }); + } + else { + entry.forEach(function (value, scriptKind) { return sourceFiles.push({ name: name, scriptKind: scriptKind, refCount: value.languageServiceRefCount }); }); + } }); sourceFiles.sort(function (x, y) { return y.refCount - x.refCount; }); return { @@ -122657,10 +127271,17 @@ var ts; function updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind) { return acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, /*acquiring*/ false, scriptKind); } + 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); + return entry; + } function acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, acquiring, scriptKind) { - var bucket = ts.getOrUpdate(buckets, key, function () { return new ts.Map(); }); - var entry = bucket.get(path); + scriptKind = ts.ensureScriptKind(fileName, scriptKind); var scriptTarget = scriptKind === 6 /* JSON */ ? 100 /* JSON */ : compilationSettings.target || 1 /* ES5 */; + var bucket = ts.getOrUpdate(buckets, key, function () { return new ts.Map(); }); + var bucketEntry = bucket.get(path); + var entry = bucketEntry && getDocumentRegistryEntry(bucketEntry, scriptKind); if (!entry && externalCache) { var sourceFile = externalCache.getDocument(key, path); if (sourceFile) { @@ -122669,7 +127290,7 @@ var ts; sourceFile: sourceFile, languageServiceRefCount: 0 }; - bucket.set(path, entry); + setBucketEntry(); } } if (!entry) { @@ -122682,7 +127303,7 @@ var ts; sourceFile: sourceFile, languageServiceRefCount: 1, }; - bucket.set(path, entry); + setBucketEntry(); } else { // We have an entry for this file. However, it may be for a different version of @@ -122705,25 +127326,49 @@ var ts; } ts.Debug.assert(entry.languageServiceRefCount !== 0); return entry.sourceFile; + function setBucketEntry() { + if (!bucketEntry) { + bucket.set(path, entry); + } + else if (isDocumentRegistryEntry(bucketEntry)) { + var scriptKindMap = new ts.Map(); + scriptKindMap.set(bucketEntry.sourceFile.scriptKind, bucketEntry); + scriptKindMap.set(scriptKind, entry); + bucket.set(path, scriptKindMap); + } + else { + bucketEntry.set(scriptKind, entry); + } + } } - function releaseDocument(fileName, compilationSettings) { + function releaseDocument(fileName, compilationSettings, scriptKind) { var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); var key = getKeyForCompilationSettings(compilationSettings); - return releaseDocumentWithKey(path, key); + return releaseDocumentWithKey(path, key, scriptKind); } - function releaseDocumentWithKey(path, key) { + function releaseDocumentWithKey(path, key, scriptKind) { var bucket = ts.Debug.checkDefined(buckets.get(key)); - var entry = bucket.get(path); + var bucketEntry = bucket.get(path); + var entry = getDocumentRegistryEntry(bucketEntry, scriptKind); entry.languageServiceRefCount--; ts.Debug.assert(entry.languageServiceRefCount >= 0); if (entry.languageServiceRefCount === 0) { - bucket.delete(path); + if (isDocumentRegistryEntry(bucketEntry)) { + bucket.delete(path); + } + else { + bucketEntry.delete(scriptKind); + if (bucketEntry.size === 1) { + bucket.set(path, ts.firstDefinedIterator(bucketEntry.values(), ts.identity)); + } + } } } - function getLanguageServiceRefCounts(path) { + function getLanguageServiceRefCounts(path, scriptKind) { return ts.arrayFrom(buckets.entries(), function (_a) { var key = _a[0], bucket = _a[1]; - var entry = bucket.get(path); + var bucketEntry = bucket.get(path); + var entry = bucketEntry && getDocumentRegistryEntry(bucketEntry, scriptKind); return [key, entry && entry.languageServiceRefCount]; }); } @@ -122786,10 +127431,12 @@ var ts; return sourceFiles; } // Module augmentations may use this module's exports without importing it. - for (var _i = 0, _a = exportingModuleSymbol.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - if (ts.isExternalModuleAugmentation(decl) && sourceFilesSet.has(decl.getSourceFile().fileName)) { - addIndirectUser(decl); + if (exportingModuleSymbol.declarations) { + for (var _i = 0, _a = exportingModuleSymbol.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + if (ts.isExternalModuleAugmentation(decl) && sourceFilesSet.has(decl.getSourceFile().fileName)) { + addIndirectUser(decl); + } } } // This may return duplicates (if there are multiple module declarations in a single source file, all importing the same thing as a namespace), but `State.markSearchedSymbol` will handle that. @@ -122806,43 +127453,43 @@ var ts; if (cancellationToken) cancellationToken.throwIfCancellationRequested(); switch (direct.kind) { - case 203 /* CallExpression */: + case 205 /* CallExpression */: if (ts.isImportCall(direct)) { handleImportCall(direct); break; } if (!isAvailableThroughGlobal) { var parent = direct.parent; - if (exportKind === 2 /* ExportEquals */ && parent.kind === 249 /* VariableDeclaration */) { + if (exportKind === 2 /* ExportEquals */ && parent.kind === 251 /* VariableDeclaration */) { var name = parent.name; - if (name.kind === 78 /* Identifier */) { + if (name.kind === 79 /* Identifier */) { directImports.push(name); break; } } } break; - case 78 /* Identifier */: // for 'const x = require("y"); + case 79 /* Identifier */: // for 'const x = require("y"); break; // TODO: GH#23879 - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: handleNamespaceImport(direct, direct.name, ts.hasSyntacticModifier(direct, 1 /* Export */), /*alreadyAddedDirect*/ false); break; - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: directImports.push(direct); var namedBindings = direct.importClause && direct.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 263 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 265 /* 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 267 /* ExportDeclaration */: + case 269 /* 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 === 269 /* NamespaceExport */) { + else if (direct.exportClause.kind === 271 /* NamespaceExport */) { // `export * as foo from "foo"` add to indirect uses addIndirectUser(getSourceFileLikeForImportDeclaration(direct), /** addTransitiveDependencies */ true); } @@ -122851,7 +127498,7 @@ var ts; directImports.push(direct); } break; - case 195 /* ImportType */: + case 197 /* ImportType */: // Only check for typeof import('xyz') if (direct.isTypeOf && !direct.qualifier && isExported(direct)) { addIndirectUser(direct.getSourceFile(), /** addTransitiveDependencies */ true); @@ -122873,7 +127520,7 @@ var ts; return ts.findAncestor(node, function (node) { if (stopAtAmbientModule && isAmbientModuleDeclaration(node)) return "quit"; - return ts.some(node.modifiers, function (mod) { return mod.kind === 92 /* ExportKeyword */; }); + return ts.some(node.modifiers, function (mod) { return mod.kind === 93 /* ExportKeyword */; }); }); } function handleNamespaceImport(importDeclaration, name, isReExport, alreadyAddedDirect) { @@ -122884,7 +127531,7 @@ var ts; } else if (!isAvailableThroughGlobal) { var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); - ts.Debug.assert(sourceFileLike.kind === 297 /* SourceFile */ || sourceFileLike.kind === 256 /* ModuleDeclaration */); + ts.Debug.assert(sourceFileLike.kind === 299 /* SourceFile */ || sourceFileLike.kind === 258 /* ModuleDeclaration */); if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { addIndirectUser(sourceFileLike, /** addTransitiveDependencies */ true); } @@ -122940,17 +127587,17 @@ var ts; } return { importSearches: importSearches, singleReferences: singleReferences }; function handleImport(decl) { - if (decl.kind === 260 /* ImportEqualsDeclaration */) { + if (decl.kind === 262 /* ImportEqualsDeclaration */) { if (isExternalModuleImportEquals(decl)) { handleNamespaceImportLike(decl.name); } return; } - if (decl.kind === 78 /* Identifier */) { + if (decl.kind === 79 /* Identifier */) { handleNamespaceImportLike(decl); return; } - if (decl.kind === 195 /* ImportType */) { + if (decl.kind === 197 /* ImportType */) { if (decl.qualifier) { var firstIdentifier = ts.getFirstIdentifier(decl.qualifier); if (firstIdentifier.escapedText === ts.symbolName(exportSymbol)) { @@ -122966,7 +127613,7 @@ var ts; if (decl.moduleSpecifier.kind !== 10 /* StringLiteral */) { return; } - if (decl.kind === 267 /* ExportDeclaration */) { + if (decl.kind === 269 /* ExportDeclaration */) { if (decl.exportClause && ts.isNamedExports(decl.exportClause)) { searchForNamedImport(decl.exportClause); } @@ -122975,10 +127622,10 @@ var ts; var _a = decl.importClause || { name: undefined, namedBindings: undefined }, name = _a.name, namedBindings = _a.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: handleNamespaceImportLike(namedBindings.name); break; - case 264 /* NamedImports */: + case 266 /* NamedImports */: // 'default' might be accessed as a named import `{ default as foo }`. if (exportKind === 0 /* Named */ || exportKind === 1 /* Default */) { searchForNamedImport(namedBindings); @@ -123028,7 +127675,7 @@ var ts; } } else { - var localSymbol = element.kind === 270 /* ExportSpecifier */ && element.propertyName + var localSymbol = element.kind === 272 /* 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); @@ -123057,7 +127704,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.kind === 297 /* SourceFile */) { + if ((searchSourceFile === null || searchSourceFile === void 0 ? void 0 : searchSourceFile.kind) === 299 /* SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { var ref = _b[_a]; if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) { @@ -123105,7 +127752,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 === 297 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return ts.forEach(sourceFileLike.kind === 299 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); }); } @@ -123120,15 +127767,15 @@ var ts; else { forEachPossibleImportOrExportStatement(sourceFile, function (statement) { switch (statement.kind) { - case 267 /* ExportDeclaration */: - case 261 /* ImportDeclaration */: { + case 269 /* ExportDeclaration */: + case 263 /* ImportDeclaration */: { var decl = statement; if (decl.moduleSpecifier && ts.isStringLiteral(decl.moduleSpecifier)) { action(decl, decl.moduleSpecifier); } break; } - case 260 /* ImportEqualsDeclaration */: { + case 262 /* ImportEqualsDeclaration */: { var decl = statement; if (isExternalModuleImportEquals(decl)) { action(decl, decl.moduleReference.expression); @@ -123149,14 +127796,15 @@ var ts; function getImportOrExportSymbol(node, symbol, checker, comingFromExport) { return comingFromExport ? getExport() : getExport() || getImport(); function getExport() { + var _a; var parent = node.parent; - var grandParent = parent.parent; + var grandparent = parent.parent; if (symbol.exportSymbol) { - if (parent.kind === 201 /* PropertyAccessExpression */) { + if (parent.kind === 203 /* 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 symbol.declarations.some(function (d) { return d === parent; }) && ts.isBinaryExpression(grandParent) - ? getSpecialPropertyExport(grandParent, /*useLhsSymbol*/ false) + return ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d === parent; })) && ts.isBinaryExpression(grandparent) + ? getSpecialPropertyExport(grandparent, /*useLhsSymbol*/ false) : undefined; } else { @@ -123186,15 +127834,15 @@ var ts; return getExportAssignmentExport(parent); } // If we are in `export = class A {};` (or `export = class A {};`) at `A`, `parent.parent` is the export assignment. - else if (ts.isExportAssignment(grandParent)) { - return getExportAssignmentExport(grandParent); + else if (ts.isExportAssignment(grandparent)) { + return getExportAssignmentExport(grandparent); } // Similar for `module.exports =` and `exports.A =`. else if (ts.isBinaryExpression(parent)) { return getSpecialPropertyExport(parent, /*useLhsSymbol*/ true); } - else if (ts.isBinaryExpression(grandParent)) { - return getSpecialPropertyExport(grandParent, /*useLhsSymbol*/ true); + else if (ts.isBinaryExpression(grandparent)) { + return getSpecialPropertyExport(grandparent, /*useLhsSymbol*/ true); } else if (ts.isJSDocTypedefTag(parent)) { return exportInfo(symbol, 0 /* Named */); @@ -123202,9 +127850,10 @@ var ts; } function getExportAssignmentExport(ex) { // Get the symbol for the `export =` node; its parent is the module it's the export of. - var exportingModuleSymbol = ts.Debug.checkDefined(ex.symbol.parent, "Expected export symbol to have a parent"); + if (!ex.symbol.parent) + return undefined; var exportKind = ex.isExportEquals ? 2 /* ExportEquals */ : 1 /* Default */; - return { kind: 1 /* Export */, symbol: symbol, exportInfo: { exportingModuleSymbol: exportingModuleSymbol, exportKind: exportKind } }; + return { kind: 1 /* Export */, symbol: symbol, exportInfo: { exportingModuleSymbol: ex.symbol.parent, exportKind: exportKind } }; } function getSpecialPropertyExport(node, useLhsSymbol) { var kind; @@ -123258,7 +127907,7 @@ var ts; if (importedSymbol.flags & 2097152 /* Alias */) { return ts.Debug.checkDefined(checker.getImmediateAliasedSymbol(importedSymbol)); } - var decl = importedSymbol.valueDeclaration; + var decl = ts.Debug.checkDefined(importedSymbol.valueDeclaration); if (ts.isExportAssignment(decl)) { // `export = class {}` return ts.Debug.checkDefined(decl.expression.symbol); } @@ -123285,17 +127934,17 @@ var ts; function isNodeImport(node) { var parent = node.parent; switch (parent.kind) { - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return parent.name === node && isExternalModuleImportEquals(parent); - case 265 /* ImportSpecifier */: + case 267 /* 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 262 /* ImportClause */: - case 263 /* NamespaceImport */: + case 264 /* ImportClause */: + case 265 /* NamespaceImport */: ts.Debug.assert(parent.name === node); return true; - case 198 /* BindingElement */: - return ts.isInJSFile(node) && ts.isRequireVariableDeclaration(parent, /*requireStringLiteralLikeArgument*/ true); + case 200 /* BindingElement */: + return ts.isInJSFile(node) && ts.isRequireVariableDeclaration(parent); default: return false; } @@ -123319,7 +127968,8 @@ var ts; return checker.getExportSpecifierLocalTargetSymbol(declaration); } else if (ts.isPropertyAccessExpression(declaration) && ts.isModuleExportsAccessExpression(declaration.expression) && !ts.isPrivateIdentifier(declaration.name)) { - return checker.getExportSpecifierLocalTargetSymbol(declaration.name); + // Export of form 'module.exports.propName = expr'; + return checker.getSymbolAtLocation(declaration); } else if (ts.isShorthandPropertyAssignment(declaration) && ts.isBinaryExpression(declaration.parent.parent) @@ -123334,21 +127984,21 @@ var ts; return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol); } function getSourceFileLikeForImportDeclaration(node) { - if (node.kind === 203 /* CallExpression */) { + if (node.kind === 205 /* CallExpression */) { return node.getSourceFile(); } var parent = node.parent; - if (parent.kind === 297 /* SourceFile */) { + if (parent.kind === 299 /* SourceFile */) { return parent; } - ts.Debug.assert(parent.kind === 257 /* ModuleBlock */); + ts.Debug.assert(parent.kind === 259 /* ModuleBlock */); return ts.cast(parent.parent, isAmbientModuleDeclaration); } function isAmbientModuleDeclaration(node) { - return node.kind === 256 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; + return node.kind === 258 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; } function isExternalModuleImportEquals(eq) { - return eq.moduleReference.kind === 272 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; + return eq.moduleReference.kind === 274 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); @@ -123442,7 +128092,7 @@ var ts; ((ts.isImportOrExportSpecifier(node.parent) || ts.isBindingElement(node.parent)) && node.parent.propertyName === node) || // Is default export - (node.kind === 87 /* DefaultKeyword */ && ts.hasSyntacticModifier(node.parent, 513 /* ExportDefault */))) { + (node.kind === 88 /* DefaultKeyword */ && ts.hasSyntacticModifier(node.parent, 513 /* ExportDefault */))) { return getContextNode(node.parent); } return undefined; @@ -123451,7 +128101,7 @@ var ts; if (!node) return undefined; switch (node.kind) { - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return !ts.isVariableDeclarationList(node.parent) || node.parent.declarations.length !== 1 ? node : ts.isVariableStatement(node.parent.parent) ? @@ -123459,28 +128109,28 @@ var ts; ts.isForInOrOfStatement(node.parent.parent) ? getContextNode(node.parent.parent) : node.parent; - case 198 /* BindingElement */: + case 200 /* BindingElement */: return getContextNode(node.parent.parent); - case 265 /* ImportSpecifier */: + case 267 /* ImportSpecifier */: return node.parent.parent.parent; - case 270 /* ExportSpecifier */: - case 263 /* NamespaceImport */: + case 272 /* ExportSpecifier */: + case 265 /* NamespaceImport */: return node.parent.parent; - case 262 /* ImportClause */: - case 269 /* NamespaceExport */: + case 264 /* ImportClause */: + case 271 /* NamespaceExport */: return node.parent; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return ts.isExpressionStatement(node.parent) ? node.parent : node; - case 239 /* ForOfStatement */: - case 238 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 240 /* ForInStatement */: return { start: node.initializer, end: node.expression }; - case 288 /* PropertyAssignment */: - case 289 /* ShorthandPropertyAssignment */: + case 290 /* PropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent) ? getContextNode(ts.findAncestor(node.parent, function (node) { return ts.isBinaryExpression(node) || ts.isForInOrOfStatement(node); @@ -123537,10 +128187,10 @@ var ts; var node = ts.getTouchingPropertyName(sourceFile, position); var referenceEntries; var entries = getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position); - if (node.parent.kind === 201 /* PropertyAccessExpression */ - || node.parent.kind === 198 /* BindingElement */ - || node.parent.kind === 202 /* ElementAccessExpression */ - || node.kind === 105 /* SuperKeyword */) { + if (node.parent.kind === 203 /* PropertyAccessExpression */ + || node.parent.kind === 200 /* BindingElement */ + || node.parent.kind === 204 /* ElementAccessExpression */ + || node.kind === 106 /* SuperKeyword */) { referenceEntries = entries && __spreadArray([], entries); } else { @@ -123563,18 +128213,18 @@ var ts; } FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) { - if (node.kind === 297 /* SourceFile */) { + if (node.kind === 299 /* 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 === 289 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 291 /* ShorthandPropertyAssignment */) { var result_1 = []; Core.getReferenceEntriesForShorthandPropertyAssignment(node, checker, function (node) { return result_1.push(nodeEntry(node)); }); return result_1; } - else if (node.kind === 105 /* SuperKeyword */ || ts.isSuperProperty(node.parent)) { + else if (node.kind === 106 /* 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); @@ -123744,13 +128394,13 @@ var ts; if (symbol) { return getDefinitionKindAndDisplayParts(symbol, checker, node); } - else if (node.kind === 200 /* ObjectLiteralExpression */) { + else if (node.kind === 202 /* ObjectLiteralExpression */) { return { kind: "interface" /* interfaceElement */, displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(21 /* CloseParenToken */)] }; } - else if (node.kind === 221 /* ClassExpression */) { + else if (node.kind === 223 /* ClassExpression */) { return { kind: "local class" /* localClassElement */, displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(21 /* CloseParenToken */)] @@ -123794,13 +128444,13 @@ var ts; /** 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 === 87 /* DefaultKeyword */ || ts.isWriteAccess(node); + return !!decl && declarationIsWriteAccess(decl) || node.kind === 88 /* DefaultKeyword */ || ts.isWriteAccess(node); } function isDefinitionForReference(node) { - return node.kind === 87 /* DefaultKeyword */ + return node.kind === 88 /* DefaultKeyword */ || !!ts.getDeclarationFromName(node) || ts.isLiteralComputedPropertyDeclarationName(node) - || (node.kind === 132 /* ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent)); + || (node.kind === 133 /* ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent)); } /** * True if 'decl' provides a value, as in `function f() {}`; @@ -123811,47 +128461,47 @@ var ts; if (!!(decl.flags & 8388608 /* Ambient */)) return true; switch (decl.kind) { - case 216 /* BinaryExpression */: - case 198 /* BindingElement */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 87 /* DefaultKeyword */: - case 255 /* EnumDeclaration */: - case 291 /* EnumMember */: - case 270 /* ExportSpecifier */: - case 262 /* ImportClause */: // default import - case 260 /* ImportEqualsDeclaration */: - case 265 /* ImportSpecifier */: - case 253 /* InterfaceDeclaration */: - case 324 /* JSDocCallbackTag */: - case 331 /* JSDocTypedefTag */: - case 280 /* JsxAttribute */: - case 256 /* ModuleDeclaration */: - case 259 /* NamespaceExportDeclaration */: - case 263 /* NamespaceImport */: - case 269 /* NamespaceExport */: - case 160 /* Parameter */: - case 289 /* ShorthandPropertyAssignment */: - case 254 /* TypeAliasDeclaration */: - case 159 /* TypeParameter */: + case 218 /* BinaryExpression */: + case 200 /* BindingElement */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 88 /* DefaultKeyword */: + case 257 /* EnumDeclaration */: + case 293 /* EnumMember */: + case 272 /* ExportSpecifier */: + case 264 /* ImportClause */: // default import + case 262 /* ImportEqualsDeclaration */: + case 267 /* ImportSpecifier */: + case 255 /* InterfaceDeclaration */: + case 332 /* JSDocCallbackTag */: + case 339 /* JSDocTypedefTag */: + case 282 /* JsxAttribute */: + case 258 /* ModuleDeclaration */: + case 261 /* NamespaceExportDeclaration */: + case 265 /* NamespaceImport */: + case 271 /* NamespaceExport */: + case 162 /* Parameter */: + case 291 /* ShorthandPropertyAssignment */: + case 256 /* TypeAliasDeclaration */: + case 161 /* TypeParameter */: return true; - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: // In `({ x: y } = 0);`, `x` is not a write access. (Won't call this function for `y`.) return !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(decl.parent); - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 166 /* Constructor */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 168 /* Constructor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return !!decl.body; - case 249 /* VariableDeclaration */: - case 163 /* PropertyDeclaration */: + case 251 /* VariableDeclaration */: + case 165 /* PropertyDeclaration */: return !!decl.initializer || ts.isCatchClause(decl.parent); - case 164 /* MethodSignature */: - case 162 /* PropertySignature */: - case 333 /* JSDocPropertyTag */: - case 326 /* JSDocParameterTag */: + case 166 /* MethodSignature */: + case 164 /* PropertySignature */: + case 341 /* JSDocPropertyTag */: + case 334 /* JSDocParameterTag */: return false; default: return ts.Debug.failBadSyntaxKind(decl); @@ -123873,7 +128523,7 @@ var ts; } if (ts.isSourceFile(node)) { var resolvedRef = ts.GoToDefinition.getReferenceAtPosition(node, position, program); - if (!resolvedRef) { + if (!(resolvedRef === null || resolvedRef === void 0 ? void 0 : resolvedRef.file)) { return undefined; } var moduleSymbol = program.getTypeChecker().getMergedSymbol(resolvedRef.file.symbol); @@ -123902,7 +128552,7 @@ var ts; if (!symbol) { // String literal might be a property (and thus have a symbol), so do this here rather than in getReferencedSymbolsSpecial. if (!options.implementations && ts.isStringLiteralLike(node)) { - if (ts.isRequireCall(node.parent, /*requireStringLiteralLikeArgument*/ true) || ts.isExternalModuleReference(node.parent) || ts.isImportDeclaration(node.parent) || ts.isImportCall(node.parent)) { + if (ts.isModuleSpecifierLike(node)) { var fileIncludeReasons = program.getFileIncludeReasons(); var referencedFileName = (_b = (_a = node.getSourceFile().resolvedModules) === null || _a === void 0 ? void 0 : _a.get(node.text)) === null || _b === void 0 ? void 0 : _b.resolvedFileName; var referencedFile = referencedFileName ? program.getSourceFile(referencedFileName) : undefined; @@ -124003,7 +128653,7 @@ var ts; result = references; continue; } - var _loop_3 = function (entry) { + var _loop_4 = function (entry) { if (!entry.definition || entry.definition.type !== 0 /* Symbol */) { result.push(entry); return "continue"; @@ -124035,7 +128685,7 @@ var ts; }; for (var _b = 0, references_2 = references; _b < references_2.length; _b++) { var entry = references_2[_b]; - _loop_3(entry); + _loop_4(entry); } } return result; @@ -124072,10 +128722,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; switch (decl.kind) { - case 297 /* SourceFile */: + case 299 /* 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 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: if (sourceFilesSet.has(decl.getSourceFile().fileName)) { references.push(nodeEntry(decl.name)); } @@ -124087,14 +128737,14 @@ var ts; } } var exported = symbol.exports.get("export=" /* ExportEquals */); - if (exported) { + 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]; var sourceFile = decl.getSourceFile(); 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, 92 /* ExportKeyword */, sourceFile)) : + ts.isExportAssignment(decl) ? ts.Debug.checkDefined(ts.findChildOfKind(decl, 93 /* ExportKeyword */, sourceFile)) : ts.getNameOfDeclaration(decl) || decl; references.push(nodeEntry(node)); } @@ -124104,25 +128754,25 @@ var ts; } /** As in a `readonly prop: any` or `constructor(readonly prop: any)`, not a `readonly any[]`. */ function isReadonlyTypeOperator(node) { - return node.kind === 142 /* ReadonlyKeyword */ + return node.kind === 143 /* ReadonlyKeyword */ && ts.isTypeOperatorNode(node.parent) - && node.parent.operator === 142 /* ReadonlyKeyword */; + && node.parent.operator === 143 /* 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 === 113 /* VoidKeyword */ && ts.isVoidExpression(node.parent)) { + if (node.kind === 114 /* 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 === 142 /* ReadonlyKeyword */ && !isReadonlyTypeOperator(node)) { + if (node.kind === 143 /* 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 === 142 /* ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined); + return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken, node.kind === 143 /* ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined); } // Labels if (ts.isJumpStatementTarget(node)) { @@ -124138,7 +128788,7 @@ var ts; if (ts.isThis(node)) { return getReferencesForThisKeyword(node, sourceFiles, cancellationToken); } - if (node.kind === 105 /* SuperKeyword */) { + if (node.kind === 106 /* SuperKeyword */) { return getReferencesForSuperKeyword(node); } return undefined; @@ -124150,14 +128800,14 @@ var ts; var searchMeaning = node ? getIntersectingMeaningFromDeclarations(node, symbol) : 7 /* All */; var result = []; var state = new State(sourceFiles, sourceFilesSet, node ? getSpecialSearchKind(node) : 0 /* None */, checker, cancellationToken, searchMeaning, options, result); - var exportSpecifier = !isForRenameWithPrefixAndSuffixText(options) ? undefined : ts.find(symbol.declarations, ts.isExportSpecifier); + 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 === 87 /* DefaultKeyword */) { + else if (node && node.kind === 88 /* DefaultKeyword */ && symbol.escapedName === "default" /* Default */ && symbol.parent) { addReference(node, symbol, state); - searchForImportsOfExport(node, symbol, { exportingModuleSymbol: ts.Debug.checkDefined(symbol.parent, "Expected export symbol to have a parent"), exportKind: 1 /* Default */ }, state); + searchForImportsOfExport(node, symbol, { exportingModuleSymbol: symbol.parent, exportKind: 1 /* 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] }); @@ -124183,10 +128833,10 @@ var ts; } function getSpecialSearchKind(node) { switch (node.kind) { - case 166 /* Constructor */: - case 132 /* ConstructorKeyword */: + case 168 /* Constructor */: + case 133 /* ConstructorKeyword */: return 1 /* Constructor */; - case 78 /* Identifier */: + case 79 /* Identifier */: if (ts.isClassLike(node.parent)) { ts.Debug.assert(node.parent.name === node); return 2 /* Class */; @@ -124314,8 +128964,8 @@ var ts; var sourceId = ts.getNodeId(sourceFile); var seenSymbols = this.sourceFileToSeenSymbols[sourceId] || (this.sourceFileToSeenSymbols[sourceId] = new ts.Set()); var anyNewSymbols = false; - for (var _i = 0, symbols_3 = symbols; _i < symbols_3.length; _i++) { - var sym = symbols_3[_i]; + for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) { + var sym = symbols_2[_i]; anyNewSymbols = ts.tryAddToSet(seenSymbols, ts.getSymbolId(sym)) || anyNewSymbols; } return anyNewSymbols; @@ -124372,7 +129022,9 @@ var ts; for (var _c = 0, _d = getPossibleSymbolReferenceNodes(indirectUser, isDefaultExport ? "default" : exportName); _c < _d.length; _c++) { var node = _d[_c]; // Import specifiers should be handled by importSearches - if (ts.isIdentifier(node) && !ts.isImportOrExportSpecifier(node.parent) && checker.getSymbolAtLocation(node) === exportSymbol) { + var symbol = checker.getSymbolAtLocation(node); + var hasExportAssignmentDeclaration = ts.some(symbol === null || symbol === void 0 ? void 0 : symbol.declarations, function (d) { return ts.tryCast(d, ts.isExportAssignment) ? true : false; }); + if (ts.isIdentifier(node) && !ts.isImportOrExportSpecifier(node.parent) && (symbol === exportSymbol || hasExportAssignmentDeclaration)) { cb(node); } } @@ -124424,7 +129076,7 @@ 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 === 208 /* FunctionExpression */ || valueDeclaration.kind === 221 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 210 /* FunctionExpression */ || valueDeclaration.kind === 223 /* ClassExpression */)) { return valueDeclaration; } if (!declarations) { @@ -124432,9 +129084,9 @@ var ts; } // 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.isPrivateIdentifierPropertyDeclaration(d); }); + var privateDeclaration = ts.find(declarations, function (d) { return ts.hasEffectiveModifier(d, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(d); }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 252 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 254 /* ClassDeclaration */); } // Else this is a public property and could be accessed from anywhere. return undefined; @@ -124463,7 +129115,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (!container || container.kind === 297 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { + if (!container || container.kind === 299 /* 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; @@ -124579,8 +129231,12 @@ var ts; function isValidReferencePosition(node, searchSymbolName) { // Compare the length so we filter out strict superstrings of the symbol we are looking for switch (node.kind) { - case 79 /* PrivateIdentifier */: - case 78 /* Identifier */: + case 80 /* PrivateIdentifier */: + if (ts.isJSDocMemberName(node.parent)) { + return true; + } + // falls through I guess + case 79 /* Identifier */: return node.text.length === searchSymbolName.length; case 14 /* NoSubstitutionTemplateLiteral */: case 10 /* StringLiteral */: { @@ -124590,7 +129246,7 @@ var ts; } case 8 /* NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.text.length === searchSymbolName.length; - case 87 /* DefaultKeyword */: + case 88 /* DefaultKeyword */: return "default".length === searchSymbolName.length; default: return false; @@ -124656,7 +129312,7 @@ var ts; return; } if (ts.isExportSpecifier(parent)) { - ts.Debug.assert(referenceLocation.kind === 78 /* Identifier */); + ts.Debug.assert(referenceLocation.kind === 79 /* Identifier */); getReferencesAtExportSpecifier(referenceLocation, referenceSymbol, parent, search, state, addReferencesHere); return; } @@ -124679,6 +129335,10 @@ var ts; default: ts.Debug.assertNever(state.specialSearchKind); } + // Use the parent symbol if the location is commonjs require syntax on javascript files only. + referenceSymbol = ts.isInJSFile(referenceLocation) && referenceLocation.parent.kind === 200 /* BindingElement */ && ts.isRequireVariableDeclaration(referenceLocation.parent) + ? referenceLocation.parent.symbol + : referenceSymbol; getImportOrExportReferences(referenceLocation, referenceSymbol, search, state); } function getReferencesAtExportSpecifier(referenceLocation, referenceSymbol, exportSpecifier, search, state, addReferencesHere, alwaysGetReferences) { @@ -124712,8 +129372,8 @@ var ts; } // For `export { foo as bar }`, rename `foo`, but not `bar`. if (!isForRenameWithPrefixAndSuffixText(state.options) || alwaysGetReferences) { - var isDefaultExport = referenceLocation.originalKeywordKind === 87 /* DefaultKeyword */ - || exportSpecifier.name.originalKeywordKind === 87 /* DefaultKeyword */; + var isDefaultExport = referenceLocation.originalKeywordKind === 88 /* DefaultKeyword */ + || exportSpecifier.name.originalKeywordKind === 88 /* DefaultKeyword */; var exportKind = isDefaultExport ? 1 /* Default */ : 0 /* Named */; var exportSymbol = ts.Debug.checkDefined(exportSpecifier.symbol); var exportInfo = FindAllReferences.getExportInfo(exportSymbol, exportKind, state.checker); @@ -124794,7 +129454,7 @@ var ts; } var pusher = function () { return state.referenceAdder(search.symbol); }; if (ts.isClassLike(referenceLocation.parent)) { - ts.Debug.assert(referenceLocation.kind === 87 /* DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); + ts.Debug.assert(referenceLocation.kind === 88 /* DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); // This is the class declaration containing the constructor. findOwnConstructorReferences(search.symbol, sourceFile, pusher()); } @@ -124821,7 +129481,7 @@ var ts; } if (member.body) { member.body.forEachChild(function cb(node) { - if (node.kind === 107 /* ThisKeyword */) { + if (node.kind === 108 /* ThisKeyword */) { addRef(node); } else if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) { @@ -124840,18 +129500,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, 132 /* ConstructorKeyword */, sourceFile); - ts.Debug.assert(decl.kind === 166 /* Constructor */ && !!ctrKeyword); + var ctrKeyword = ts.findChildOfKind(decl, 133 /* ConstructorKeyword */, sourceFile); + ts.Debug.assert(decl.kind === 168 /* Constructor */ && !!ctrKeyword); addNode(ctrKeyword); } } if (classSymbol.exports) { classSymbol.exports.forEach(function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 165 /* MethodDeclaration */) { + if (decl && decl.kind === 167 /* MethodDeclaration */) { var body = decl.body; if (body) { - forEachDescendantOfKind(body, 107 /* ThisKeyword */, function (thisKeyword) { + forEachDescendantOfKind(body, 108 /* ThisKeyword */, function (thisKeyword) { if (ts.isNewExpressionTarget(thisKeyword)) { addNode(thisKeyword); } @@ -124872,10 +129532,10 @@ var ts; } for (var _i = 0, _a = constructor.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 166 /* Constructor */); + ts.Debug.assert(decl.kind === 168 /* Constructor */); var body = decl.body; if (body) { - forEachDescendantOfKind(body, 105 /* SuperKeyword */, function (node) { + forEachDescendantOfKind(body, 106 /* SuperKeyword */, function (node) { if (ts.isCallExpressionTarget(node)) { addNode(node); } @@ -124899,10 +129559,10 @@ var ts; addReference(refNode); return; } - if (refNode.kind !== 78 /* Identifier */) { + if (refNode.kind !== 79 /* Identifier */) { return; } - if (refNode.parent.kind === 289 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 291 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference); } @@ -124922,7 +129582,7 @@ var ts; } else if (ts.isFunctionLike(typeHavingNode) && typeHavingNode.body) { var body = typeHavingNode.body; - if (body.kind === 230 /* Block */) { + if (body.kind === 232 /* Block */) { ts.forEachReturnStatement(body, function (returnStatement) { if (returnStatement.expression) addIfImplementation(returnStatement.expression); @@ -124950,13 +129610,13 @@ var ts; */ function isImplementationExpression(node) { switch (node.kind) { - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return isImplementationExpression(node.expression); - case 209 /* ArrowFunction */: - case 208 /* FunctionExpression */: - case 200 /* ObjectLiteralExpression */: - case 221 /* ClassExpression */: - case 199 /* ArrayLiteralExpression */: + case 211 /* ArrowFunction */: + case 210 /* FunctionExpression */: + case 202 /* ObjectLiteralExpression */: + case 223 /* ClassExpression */: + case 201 /* ArrayLiteralExpression */: return true; default: return false; @@ -125009,13 +129669,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -125024,7 +129684,7 @@ var ts; } var sourceFile = searchSpaceNode.getSourceFile(); var references = ts.mapDefined(getPossibleSymbolReferenceNodes(sourceFile, "super", searchSpaceNode), function (node) { - if (node.kind !== 105 /* SuperKeyword */) { + if (node.kind !== 106 /* SuperKeyword */) { return; } var container = ts.getSuperContainer(node, /*stopOnFunctions*/ false); @@ -125036,41 +129696,43 @@ var ts; return [{ definition: { type: 0 /* Symbol */, symbol: searchSpaceNode.symbol }, references: references }]; } function isParameterName(node) { - return node.kind === 78 /* Identifier */ && node.parent.kind === 160 /* Parameter */ && node.parent.name === node; + return node.kind === 79 /* Identifier */ && node.parent.kind === 162 /* 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 */; switch (searchSpaceNode.kind) { - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { + staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); + searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning object literals break; } // falls through - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 297 /* SourceFile */: + case 299 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode) || isParameterName(thisOrSuperKeyword)) { return undefined; } // falls through - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 210 /* 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 === 297 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { + var references = ts.flatMap(searchSpaceNode.kind === 299 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { if (!ts.isThis(node)) { @@ -125078,19 +129740,20 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: return searchSpaceNode.symbol === container.symbol; - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: return ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol; - case 221 /* ClassExpression */: - case 252 /* ClassDeclaration */: - // Make sure the container belongs to the same class + case 223 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 202 /* 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.getSyntacticModifierFlags(container) & 32 /* Static */) === staticFlag; - case 297 /* SourceFile */: - return container.kind === 297 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); + case 299 /* SourceFile */: + return container.kind === 299 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); } }); }).map(function (n) { return nodeEntry(n); }); @@ -125200,7 +129863,7 @@ var ts; 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]); } - var exportSpecifier = ts.getDeclarationOfKind(symbol, 270 /* ExportSpecifier */); + var exportSpecifier = ts.getDeclarationOfKind(symbol, 272 /* ExportSpecifier */); if (!isForRenamePopulateSearchSymbolSet || exportSpecifier && !exportSpecifier.propertyName) { var localSymbol = exportSpecifier && checker.getExportSpecifierLocalTargetSymbol(exportSpecifier); if (localSymbol) { @@ -125245,7 +129908,7 @@ var ts; }); } function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker) { - var bindingElement = ts.getDeclarationOfKind(symbol, 198 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 200 /* BindingElement */); if (bindingElement && ts.isObjectBindingElementWithoutPropertyName(bindingElement)) { return ts.getPropertySymbolFromBindingElement(checker, bindingElement); } @@ -125449,7 +130112,7 @@ var ts; return ts.Debug.checkDefined(node.modifiers && ts.find(node.modifiers, isDefaultModifier)); } function isDefaultModifier(node) { - return node.kind === 87 /* DefaultKeyword */; + return node.kind === 88 /* DefaultKeyword */; } /** Gets the symbol for a call hierarchy declaration. */ function getSymbolOfCallHierarchyDeclaration(typeChecker, node) { @@ -125498,16 +130161,16 @@ var ts; return; } switch (node.kind) { - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 165 /* MethodDeclaration */: - if (node.parent.kind === 200 /* ObjectLiteralExpression */) { + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 167 /* MethodDeclaration */: + if (node.parent.kind === 202 /* 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 251 /* FunctionDeclaration */: - case 252 /* ClassDeclaration */: - case 256 /* ModuleDeclaration */: + case 253 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: + case 258 /* ModuleDeclaration */: if (ts.isModuleBlock(node.parent) && ts.isIdentifier(node.parent.parent.name)) { return node.parent.parent.name.getText(); } @@ -125712,56 +130375,56 @@ var ts; return; } switch (node.kind) { - case 78 /* Identifier */: - case 260 /* ImportEqualsDeclaration */: - case 261 /* ImportDeclaration */: - case 267 /* ExportDeclaration */: - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 79 /* Identifier */: + case 262 /* ImportEqualsDeclaration */: + case 263 /* ImportDeclaration */: + case 269 /* ExportDeclaration */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: // do not descend into nodes that cannot contain callable nodes return; - case 206 /* TypeAssertionExpression */: - case 224 /* AsExpression */: + case 208 /* TypeAssertionExpression */: + case 226 /* AsExpression */: // do not descend into the type side of an assertion collect(node.expression); return; - case 249 /* VariableDeclaration */: - case 160 /* Parameter */: + case 251 /* VariableDeclaration */: + case 162 /* Parameter */: // do not descend into the type of a variable or parameter declaration collect(node.name); collect(node.initializer); return; - case 203 /* CallExpression */: + case 205 /* CallExpression */: // do not descend into the type arguments of a call expression recordCallSite(node); collect(node.expression); ts.forEach(node.arguments, collect); return; - case 204 /* NewExpression */: + case 206 /* NewExpression */: // do not descend into the type arguments of a new expression recordCallSite(node); collect(node.expression); ts.forEach(node.arguments, collect); return; - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: // do not descend into the type arguments of a tagged template expression recordCallSite(node); collect(node.tag); collect(node.template); return; - case 275 /* JsxOpeningElement */: - case 274 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: // do not descend into the type arguments of a JsxOpeningLikeElement recordCallSite(node); collect(node.tagName); collect(node.attributes); return; - case 161 /* Decorator */: + case 163 /* Decorator */: recordCallSite(node); collect(node.expression); return; - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: recordCallSite(node); ts.forEachChild(node, collect); break; @@ -125811,22 +130474,22 @@ var ts; var callSites = []; var collect = createCallSiteCollector(program, callSites); switch (node.kind) { - case 297 /* SourceFile */: + case 299 /* SourceFile */: collectCallSitesOfSourceFile(node, collect); break; - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: collectCallSitesOfModuleDeclaration(node, collect); break; - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: collectCallSitesOfFunctionLikeDeclaration(program.getTypeChecker(), node, collect); break; - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: collectCallSitesOfClassLikeDeclaration(node, collect); break; default: @@ -125959,7 +130622,7 @@ var ts; } function updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName) { var allFiles = program.getSourceFiles(); - var _loop_4 = function (sourceFile) { + var _loop_5 = function (sourceFile) { var newFromOld = oldToNew(sourceFile.fileName); var newImportFromPath = newFromOld !== null && newFromOld !== void 0 ? newFromOld : sourceFile.fileName; var newImportFromDirectory = ts.getDirectoryPath(newImportFromPath); @@ -125976,7 +130639,7 @@ var ts; }, function (importLiteral) { var importedModuleSymbol = program.getTypeChecker().getSymbolAtLocation(importLiteral); // No need to update if it's an ambient module^M - if (importedModuleSymbol && importedModuleSymbol.declarations.some(function (d) { return ts.isAmbientModule(d); })) + if ((importedModuleSymbol === null || importedModuleSymbol === void 0 ? void 0 : importedModuleSymbol.declarations) && importedModuleSymbol.declarations.some(function (d) { return ts.isAmbientModule(d); })) return undefined; var toImport = oldFromNew !== undefined // If we're at the new location (file was already renamed), need to redo module resolution starting from the old location. @@ -125991,7 +130654,7 @@ var ts; }; for (var _i = 0, allFiles_1 = allFiles; _i < allFiles_1.length; _i++) { var sourceFile = allFiles_1[_i]; - _loop_4(sourceFile); + _loop_5(sourceFile); } } function combineNormal(pathA, pathB) { @@ -126082,8 +130745,10 @@ var ts; (function (GoToDefinition) { function getDefinitionAtPosition(program, sourceFile, position) { var resolvedRef = getReferenceAtPosition(sourceFile, position, program); - if (resolvedRef) { - return [getDefinitionInfoForFileReference(resolvedRef.reference.fileName, resolvedRef.file.fileName)]; + var fileReferenceDefinition = resolvedRef && [getDefinitionInfoForFileReference(resolvedRef.reference.fileName, resolvedRef.fileName, resolvedRef.unverified)] || ts.emptyArray; + if (resolvedRef === null || resolvedRef === void 0 ? void 0 : resolvedRef.file) { + // If `file` is missing, do a symbol-based lookup as well + return fileReferenceDefinition; } var node = ts.getTouchingPropertyName(sourceFile, position); if (node === sourceFile) { @@ -126100,7 +130765,7 @@ var ts; // Could not find a symbol e.g. node is string or number keyword, // or the symbol was an internal symbol and does not have a declaration e.g. undefined symbol if (!symbol) { - return getDefinitionInfoForIndexSignatures(node, typeChecker); + return ts.concatenate(fileReferenceDefinition, getDefinitionInfoForIndexSignatures(node, typeChecker)); } var calledDeclaration = tryGetSignatureDeclaration(typeChecker, node); // Don't go to the component constructor definition for a JSX element, just go to the component definition. @@ -126114,7 +130779,7 @@ var ts; else { var defs = getDefinitionFromSymbol(typeChecker, symbol, node, calledDeclaration) || ts.emptyArray; // For a 'super()' call, put the signature first, else put the variable first. - return node.kind === 105 /* SuperKeyword */ ? __spreadArray([sigInfo], defs) : __spreadArray(__spreadArray([], defs), [sigInfo]); + return node.kind === 106 /* SuperKeyword */ ? __spreadArray([sigInfo], defs) : __spreadArray(__spreadArray([], defs), [sigInfo]); } } // Because name in short-hand property assignment has two different meanings: property name and property value, @@ -126122,9 +130787,10 @@ 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 === 289 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 291 /* ShorthandPropertyAssignment */) { var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); - return shorthandSymbol_1 ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node); }) : []; + 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); }) : ts.emptyArray; + return ts.concatenate(definitions, getDefinitionFromObjectLiteralElement(typeChecker, node) || ts.emptyArray); } // If the node is the name of a BindingElement within an ObjectBindingPattern instead of just returning the // declaration the symbol (which is itself), we should try to get to the original type of the ObjectBindingPattern @@ -126146,25 +130812,7 @@ var ts; return prop && getDefinitionFromSymbol(typeChecker, prop, node); }); } - // If the current location we want to find its definition is in an object literal, try to get the contextual type for the - // object literal, lookup the property symbol in the contextual type, and use this for goto-definition. - // For example - // interface Props{ - // /*first*/prop1: number - // prop2: boolean - // } - // function Foo(arg: Props) {} - // Foo( { pr/*1*/op1: 10, prop2: true }) - var element = ts.getContainingObjectLiteralElement(node); - if (element) { - var contextualType = element && typeChecker.getContextualType(element.parent); - if (contextualType) { - return ts.flatMap(ts.getPropertySymbolsFromContextualType(element, typeChecker, contextualType, /*unionSymbolOk*/ false), function (propertySymbol) { - return getDefinitionFromSymbol(typeChecker, propertySymbol, node); - }); - } - } - return getDefinitionFromSymbol(typeChecker, symbol, node); + return ts.concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node)); } GoToDefinition.getDefinitionAtPosition = getDefinitionAtPosition; /** @@ -126178,22 +130826,60 @@ var ts; || ts.isAssignmentExpression(calledDeclaration.parent) || (!ts.isCallLikeExpression(calledDeclaration.parent) && s === calledDeclaration.parent.symbol); } + // If the current location we want to find its definition is in an object literal, try to get the contextual type for the + // object literal, lookup the property symbol in the contextual type, and use this for goto-definition. + // For example + // interface Props{ + // /*first*/prop1: number + // prop2: boolean + // } + // function Foo(arg: Props) {} + // Foo( { pr/*1*/op1: 10, prop2: true }) + function getDefinitionFromObjectLiteralElement(typeChecker, node) { + var element = ts.getContainingObjectLiteralElement(node); + if (element) { + var contextualType = element && typeChecker.getContextualType(element.parent); + if (contextualType) { + return ts.flatMap(ts.getPropertySymbolsFromContextualType(element, typeChecker, contextualType, /*unionSymbolOk*/ false), function (propertySymbol) { + return getDefinitionFromSymbol(typeChecker, propertySymbol, node); + }); + } + } + } function getReferenceAtPosition(sourceFile, position, program) { + var _a, _b; var referencePath = findReferenceInPosition(sourceFile.referencedFiles, position); if (referencePath) { var file = program.getSourceFileFromReference(sourceFile, referencePath); - return file && { reference: referencePath, file: file }; + return file && { reference: referencePath, fileName: file.fileName, file: file, unverified: false }; } var typeReferenceDirective = findReferenceInPosition(sourceFile.typeReferenceDirectives, position); if (typeReferenceDirective) { var reference = program.getResolvedTypeReferenceDirectives().get(typeReferenceDirective.fileName); var file = reference && program.getSourceFile(reference.resolvedFileName); // TODO:GH#18217 - return file && { reference: typeReferenceDirective, file: file }; + return file && { reference: typeReferenceDirective, fileName: file.fileName, file: file, unverified: false }; } var libReferenceDirective = findReferenceInPosition(sourceFile.libReferenceDirectives, position); if (libReferenceDirective) { var file = program.getLibFileFromReference(libReferenceDirective); - return file && { reference: libReferenceDirective, file: file }; + return file && { reference: libReferenceDirective, fileName: file.fileName, file: file, unverified: false }; + } + if ((_a = sourceFile.resolvedModules) === null || _a === void 0 ? void 0 : _a.size) { + var node = ts.getTokenAtPosition(sourceFile, position); + if (ts.isModuleSpecifierLike(node) && ts.isExternalModuleNameRelative(node.text) && sourceFile.resolvedModules.has(node.text)) { + var verifiedFileName = (_b = sourceFile.resolvedModules.get(node.text)) === null || _b === void 0 ? void 0 : _b.resolvedFileName; + var fileName = verifiedFileName || ts.resolvePath(ts.getDirectoryPath(sourceFile.fileName), node.text); + return { + file: program.getSourceFile(fileName), + fileName: fileName, + reference: { + pos: node.getStart(), + end: node.getEnd(), + fileName: node.text + }, + unverified: !verifiedFileName, + }; + } } return undefined; } @@ -126264,7 +130950,7 @@ var ts; // get the aliased symbol instead. This allows for goto def on an import e.g. // import {A, B} from "mod"; // to jump to the implementation directly. - if (symbol && symbol.flags & 2097152 /* Alias */ && shouldSkipAlias(node, symbol.declarations[0])) { + if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.flags & 2097152 /* Alias */ && shouldSkipAlias(node, symbol.declarations[0])) { var aliased = checker.getAliasedSymbol(symbol); if (aliased.declarations) { return aliased; @@ -126278,21 +130964,21 @@ var ts; // (2) when the aliased symbol is originating from an import. // function shouldSkipAlias(node, declaration) { - if (node.kind !== 78 /* Identifier */) { + if (node.kind !== 79 /* Identifier */) { return false; } if (node.parent === declaration) { return true; } switch (declaration.kind) { - case 262 /* ImportClause */: - case 260 /* ImportEqualsDeclaration */: + case 264 /* ImportClause */: + case 262 /* ImportEqualsDeclaration */: return true; - case 265 /* ImportSpecifier */: - return declaration.parent.kind === 264 /* NamedImports */; - case 198 /* BindingElement */: - case 249 /* VariableDeclaration */: - return ts.isInJSFile(declaration) && ts.isRequireVariableDeclaration(declaration, /*requireStringLiteralLikeArgument*/ true); + case 267 /* ImportSpecifier */: + return declaration.parent.kind === 266 /* NamedImports */; + case 200 /* BindingElement */: + case 251 /* VariableDeclaration */: + return ts.isInJSFile(declaration) && ts.isRequireVariableDeclaration(declaration); default: return false; } @@ -126307,7 +130993,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 === 132 /* ConstructorKeyword */)) { + if (symbol.flags & 32 /* Class */ && !(symbol.flags & (16 /* Function */ | 3 /* Variable */)) && (ts.isNewExpressionTarget(node) || node.kind === 133 /* 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); } @@ -126344,7 +131030,38 @@ var ts; var sourceFile = name.getSourceFile(); var 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: !checker.isDeclarationVisible(declaration) }); + containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration) }); + } + function isDefinitionVisible(checker, declaration) { + if (checker.isDeclarationVisible(declaration)) + return true; + if (!declaration.parent) + return false; + // Variable initializers are visible if variable is visible + if (ts.hasInitializer(declaration.parent) && declaration.parent.initializer === declaration) + 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 165 /* PropertyDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 167 /* MethodDeclaration */: + // Private/protected properties/methods are not visible + if (ts.hasEffectiveModifier(declaration, 8 /* Private */)) + return false; + // Public properties/methods are visible if its parents are visible, so: + // falls through + case 168 /* Constructor */: + case 290 /* PropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: + case 202 /* ObjectLiteralExpression */: + case 223 /* ClassExpression */: + case 211 /* ArrowFunction */: + case 210 /* FunctionExpression */: + return isDefinitionVisible(checker, declaration.parent); + default: + return false; + } } function createDefinitionFromSignatureDeclaration(typeChecker, decl) { return createDefinitionInfo(decl, typeChecker, decl.symbol, decl); @@ -126353,14 +131070,15 @@ var ts; return ts.find(refs, function (ref) { return ts.textRangeContainsPositionInclusive(ref, pos); }); } GoToDefinition.findReferenceInPosition = findReferenceInPosition; - function getDefinitionInfoForFileReference(name, targetFileName) { + function getDefinitionInfoForFileReference(name, targetFileName, unverified) { return { fileName: targetFileName, textSpan: ts.createTextSpanFromBounds(0, 0), kind: "script" /* scriptElement */, name: name, containerName: undefined, - containerKind: undefined, // TODO: GH#18217 + containerKind: undefined, + unverified: unverified, }; } /** Returns a CallLikeExpression where `node` is the target being invoked. */ @@ -126377,9 +131095,9 @@ var ts; } function isConstructorLike(node) { switch (node.kind) { - case 166 /* Constructor */: - case 175 /* ConstructorType */: - case 170 /* ConstructSignature */: + case 168 /* Constructor */: + case 177 /* ConstructorType */: + case 172 /* ConstructSignature */: return true; default: return false; @@ -126436,6 +131154,7 @@ var ts; "kind", "lends", "license", + "link", "listens", "member", "memberof", @@ -126473,78 +131192,115 @@ var ts; ]; var jsDocTagNameCompletionEntries; var jsDocTagCompletionEntries; - function getJsDocCommentsFromDeclarations(declarations) { + function getJsDocCommentsFromDeclarations(declarations, checker) { // Only collect doc comments from duplicate declarations once: // In case of a union property there might be same declaration multiple times // which only varies in type parameter // Eg. const a: Array | Array; a.length // The property length will have two declarations of property length coming // from Array - Array and Array - var documentationComment = []; + var parts = []; ts.forEachUnique(declarations, function (declaration) { for (var _i = 0, _a = getCommentHavingNodes(declaration); _i < _a.length; _i++) { var comment = _a[_i].comment; if (comment === undefined) continue; - ts.pushIfUnique(documentationComment, comment); + var newparts = getDisplayPartsFromComment(comment, checker); + if (!ts.contains(parts, newparts, isIdenticalListOfDisplayParts)) { + parts.push(newparts); + } } }); - return ts.intersperse(ts.map(documentationComment, ts.textPart), ts.lineBreakPart()); + return ts.flatten(ts.intersperse(parts, [ts.lineBreakPart()])); } JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; + function isIdenticalListOfDisplayParts(parts1, parts2) { + return ts.arraysEqual(parts1, parts2, function (p1, p2) { return p1.kind === p2.kind && p1.text === p2.text; }); + } function getCommentHavingNodes(declaration) { switch (declaration.kind) { - case 326 /* JSDocParameterTag */: - case 333 /* JSDocPropertyTag */: + case 334 /* JSDocParameterTag */: + case 341 /* JSDocPropertyTag */: return [declaration]; - case 324 /* JSDocCallbackTag */: - case 331 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + case 339 /* JSDocTypedefTag */: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); } } - function getJsDocTagsFromDeclarations(declarations) { + function getJsDocTagsFromDeclarations(declarations, checker) { // Only collect doc comments from duplicate declarations once. var tags = []; ts.forEachUnique(declarations, function (declaration) { for (var _i = 0, _a = ts.getJSDocTags(declaration); _i < _a.length; _i++) { var tag = _a[_i]; - tags.push({ name: tag.tagName.text, text: getCommentText(tag) }); + tags.push({ name: tag.tagName.text, text: getCommentDisplayParts(tag, checker) }); } }); return tags; } JsDoc.getJsDocTagsFromDeclarations = getJsDocTagsFromDeclarations; - function getCommentText(tag) { - var comment = tag.comment; - switch (tag.kind) { - case 316 /* JSDocImplementsTag */: + function getDisplayPartsFromComment(comment, checker) { + if (typeof comment === "string") { + return [ts.textPart(comment)]; + } + return ts.flatMap(comment, function (node) { return node.kind === 315 /* 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 323 /* JSDocImplementsTag */: return withNode(tag.class); - case 315 /* JSDocAugmentsTag */: + case 322 /* JSDocAugmentsTag */: return withNode(tag.class); - case 330 /* JSDocTemplateTag */: - return withList(tag.typeParameters); - case 329 /* JSDocTypeTag */: + case 338 /* JSDocTemplateTag */: + return addComment(tag.typeParameters.map(function (tp) { return tp.getText(); }).join(", ")); + case 337 /* JSDocTypeTag */: return withNode(tag.typeExpression); - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 333 /* JSDocPropertyTag */: - case 326 /* JSDocParameterTag */: - case 332 /* JSDocSeeTag */: + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + case 341 /* JSDocPropertyTag */: + case 334 /* JSDocParameterTag */: + case 340 /* JSDocSeeTag */: var name = tag.name; - return name ? withNode(name) : comment; + return name ? withNode(name) + : comment === undefined ? undefined + : getDisplayPartsFromComment(comment, checker); default: - return comment; + return comment === undefined ? undefined : getDisplayPartsFromComment(comment, checker); } function withNode(node) { return addComment(node.getText()); } - function withList(list) { - return addComment(list.map(function (x) { return x.getText(); }).join(", ")); - } function addComment(s) { - return comment === undefined ? s : s + " " + comment; + if (comment) { + if (s.match(/^https?$/)) { + return __spreadArray([ts.textPart(s)], getDisplayPartsFromComment(comment, checker)); + } + else { + return __spreadArray([namePart(s), ts.spacePart()], getDisplayPartsFromComment(comment, checker)); + } + } + else { + return [ts.textPart(s)]; + } + } + } + function getTagNameDisplayPart(kind) { + switch (kind) { + case 334 /* JSDocParameterTag */: + return ts.parameterNamePart; + case 341 /* JSDocPropertyTag */: + return ts.propertyNamePart; + case 338 /* JSDocTemplateTag */: + return ts.typeParameterNamePart; + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + return ts.typeAliasNamePart; + default: + return ts.textPart; } } function getJSDocTagNameCompletions() { @@ -126638,7 +131394,7 @@ var ts; * @param position The (character-indexed) position in the file where the check should * be performed. */ - function getDocCommentTemplateAtPosition(newLine, sourceFile, position) { + function getDocCommentTemplateAtPosition(newLine, sourceFile, position, options) { var tokenAtPos = ts.getTokenAtPosition(sourceFile, position); var existingDocComment = ts.findAncestor(tokenAtPos, ts.isJSDoc); if (existingDocComment && (existingDocComment.comment !== undefined || ts.length(existingDocComment.tags))) { @@ -126650,7 +131406,7 @@ var ts; if (!existingDocComment && tokenStart < position) { return undefined; } - var commentOwnerInfo = getCommentOwnerInfo(tokenAtPos); + var commentOwnerInfo = getCommentOwnerInfo(tokenAtPos, options); if (!commentOwnerInfo) { return undefined; } @@ -126692,7 +131448,7 @@ 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 === 78 /* Identifier */ ? name.text : "param" + i; + var paramName = name.kind === 79 /* Identifier */ ? name.text : "param" + i; var type = isJavaScriptFile ? (dotDotDotToken ? "{...any} " : "{any} ") : ""; return indentationStr + " * @param " + type + paramName + newLine; }).join(""); @@ -126700,76 +131456,77 @@ var ts; function returnsDocComment(indentationStr, newLine) { return indentationStr + " * @returns" + newLine; } - function getCommentOwnerInfo(tokenAtPos) { - return ts.forEachAncestor(tokenAtPos, getCommentOwnerInfoWorker); + function getCommentOwnerInfo(tokenAtPos, options) { + return ts.forEachAncestor(tokenAtPos, function (n) { return getCommentOwnerInfoWorker(n, options); }); } - function getCommentOwnerInfoWorker(commentOwner) { + function getCommentOwnerInfoWorker(commentOwner, options) { switch (commentOwner.kind) { - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: - case 164 /* MethodSignature */: - case 209 /* ArrowFunction */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 167 /* MethodDeclaration */: + case 168 /* Constructor */: + case 166 /* MethodSignature */: + case 211 /* ArrowFunction */: var host = commentOwner; - return { commentOwner: commentOwner, parameters: host.parameters, hasReturn: hasReturn(host) }; - case 288 /* PropertyAssignment */: - return getCommentOwnerInfoWorker(commentOwner.initializer); - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 162 /* PropertySignature */: - case 255 /* EnumDeclaration */: - case 291 /* EnumMember */: - case 254 /* TypeAliasDeclaration */: + return { commentOwner: commentOwner, parameters: host.parameters, hasReturn: hasReturn(host, options) }; + case 290 /* PropertyAssignment */: + return getCommentOwnerInfoWorker(commentOwner.initializer, options); + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 164 /* PropertySignature */: + case 257 /* EnumDeclaration */: + case 293 /* EnumMember */: + case 256 /* TypeAliasDeclaration */: return { commentOwner: commentOwner }; - case 232 /* VariableStatement */: { + case 234 /* VariableStatement */: { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; var host_1 = varDeclarations.length === 1 && varDeclarations[0].initializer ? getRightHandSideOfAssignment(varDeclarations[0].initializer) : undefined; return host_1 - ? { commentOwner: commentOwner, parameters: host_1.parameters, hasReturn: hasReturn(host_1) } + ? { commentOwner: commentOwner, parameters: host_1.parameters, hasReturn: hasReturn(host_1, options) } : { commentOwner: commentOwner }; } - case 297 /* SourceFile */: + case 299 /* SourceFile */: return "quit"; - case 256 /* ModuleDeclaration */: + case 258 /* 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 === 256 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; - case 233 /* ExpressionStatement */: - return getCommentOwnerInfoWorker(commentOwner.expression); - case 216 /* BinaryExpression */: { + return commentOwner.parent.kind === 258 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; + case 235 /* ExpressionStatement */: + return getCommentOwnerInfoWorker(commentOwner.expression, options); + case 218 /* BinaryExpression */: { var be = commentOwner; if (ts.getAssignmentDeclarationKind(be) === 0 /* None */) { return "quit"; } return ts.isFunctionLike(be.right) - ? { commentOwner: commentOwner, parameters: be.right.parameters, hasReturn: hasReturn(be.right) } + ? { commentOwner: commentOwner, parameters: be.right.parameters, hasReturn: hasReturn(be.right, options) } : { commentOwner: commentOwner }; } - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: var init = commentOwner.initializer; if (init && (ts.isFunctionExpression(init) || ts.isArrowFunction(init))) { - return { commentOwner: commentOwner, parameters: init.parameters, hasReturn: hasReturn(init) }; + return { commentOwner: commentOwner, parameters: init.parameters, hasReturn: hasReturn(init, options) }; } } } - function hasReturn(node) { - return ts.isArrowFunction(node) && ts.isExpression(node.body) - || ts.isFunctionLikeDeclaration(node) && node.body && ts.isBlock(node.body) && !!ts.forEachReturnStatement(node.body, function (n) { return n; }); + function hasReturn(node, options) { + return !!(options === null || options === void 0 ? void 0 : options.generateReturnInDocTemplate) && + (ts.isArrowFunction(node) && ts.isExpression(node.body) + || ts.isFunctionLikeDeclaration(node) && node.body && ts.isBlock(node.body) && !!ts.forEachReturnStatement(node.body, function (n) { return n; })); } function getRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 207 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 209 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return rightHandSide; - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: return ts.find(rightHandSide.members, ts.isConstructorDeclaration); } } @@ -126785,7 +131542,7 @@ var ts; if (!patternMatcher) return ts.emptyArray; var rawItems = []; - var _loop_5 = function (sourceFile) { + var _loop_6 = function (sourceFile) { cancellationToken.throwIfCancellationRequested(); if (excludeDtsFiles && sourceFile.isDeclarationFile) { return "continue"; @@ -126797,7 +131554,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_5(sourceFile); + _loop_6(sourceFile); } rawItems.sort(compareNavigateToItems); return (maxResultCount === undefined ? rawItems : rawItems.slice(0, maxResultCount)).map(createNavigateToItem); @@ -126828,9 +131585,9 @@ var ts; } function shouldKeepItem(declaration, checker) { switch (declaration.kind) { - case 262 /* ImportClause */: - case 265 /* ImportSpecifier */: - case 260 /* ImportEqualsDeclaration */: + case 264 /* ImportClause */: + case 267 /* ImportSpecifier */: + case 262 /* ImportEqualsDeclaration */: var importer = checker.getSymbolAtLocation(declaration.name); // TODO: GH#18217 var imported = checker.getAliasedSymbol(importer); return importer.escapedName !== imported.escapedName; @@ -126840,7 +131597,7 @@ var ts; } function tryAddSingleDeclarationName(declaration, containers) { var name = ts.getNameOfDeclaration(declaration); - return !!name && (pushLiteral(name, containers) || name.kind === 158 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); + return !!name && (pushLiteral(name, containers) || name.kind === 160 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); } // Only added the names of computed properties if they're simple dotted expressions, like: // @@ -126857,7 +131614,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 === 158 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { + if (name && name.kind === 160 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { return ts.emptyArray; } // Don't include the last portion. @@ -127057,6 +131814,28 @@ var ts; addChildrenRecursively(child); endNode(); } + function addNodeWithRecursiveInitializer(node) { + if (node.initializer && isFunctionOrClassExpression(node.initializer)) { + startNode(node); + ts.forEachChild(node.initializer, addChildrenRecursively); + endNode(); + } + else { + addNodeWithRecursiveChild(node, node.initializer); + } + } + /** + * Historically, we've elided dynamic names from the nav tree (including late bound names), + * but included certain "well known" symbol names. While we no longer distinguish those well-known + * symbols from other unique symbols, we do the below to retain those members in the nav tree. + */ + function hasNavigationBarName(node) { + return !ts.hasDynamicName(node) || + (node.kind !== 218 /* BinaryExpression */ && + ts.isPropertyAccessExpression(node.name.expression) && + ts.isIdentifier(node.name.expression.expression) && + ts.idText(node.name.expression.expression) === "Symbol"); + } /** Look for navigation bar items in node's subtree, adding them to the current `parent`. */ function addChildrenRecursively(node) { var _a; @@ -127065,7 +131844,7 @@ var ts; return; } switch (node.kind) { - case 166 /* Constructor */: + case 168 /* 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); @@ -127077,21 +131856,25 @@ var ts; } } break; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 164 /* MethodSignature */: - if (!ts.hasDynamicName(node)) { + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 166 /* MethodSignature */: + if (hasNavigationBarName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - if (!ts.hasDynamicName(node)) { + case 165 /* PropertyDeclaration */: + if (hasNavigationBarName(node)) { + addNodeWithRecursiveInitializer(node); + } + break; + case 164 /* PropertySignature */: + if (hasNavigationBarName(node)) { addLeafNode(node); } break; - case 262 /* ImportClause */: + case 264 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -127103,7 +131886,7 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 263 /* NamespaceImport */) { + if (namedBindings.kind === 265 /* NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -127114,32 +131897,27 @@ var ts; } } break; - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: addNodeWithRecursiveChild(node, node.name); break; - case 290 /* SpreadAssignment */: + case 292 /* 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 198 /* BindingElement */: - case 288 /* PropertyAssignment */: - case 249 /* VariableDeclaration */: - var _e = node, name = _e.name, initializer = _e.initializer; - if (ts.isBindingPattern(name)) { - addChildrenRecursively(name); - } - else if (initializer && isFunctionOrClassExpression(initializer)) { - // Add a node for the VariableDeclaration, but not for the initializer. - startNode(node); - ts.forEachChild(initializer, addChildrenRecursively); - endNode(); + case 200 /* BindingElement */: + case 290 /* PropertyAssignment */: + case 251 /* VariableDeclaration */: { + var child = node; + if (ts.isBindingPattern(child.name)) { + addChildrenRecursively(child.name); } else { - addNodeWithRecursiveChild(node, initializer); + addNodeWithRecursiveInitializer(child); } break; - case 251 /* FunctionDeclaration */: + } + case 253 /* FunctionDeclaration */: var nameNode = node.name; // If we see a function declaration track as a possible ES5 class if (nameNode && ts.isIdentifier(nameNode)) { @@ -127147,34 +131925,34 @@ var ts; } addNodeWithRecursiveChild(node, node.body); break; - case 209 /* ArrowFunction */: - case 208 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 210 /* FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: startNode(node); - for (var _f = 0, _g = node.members; _f < _g.length; _f++) { - var member = _g[_f]; + for (var _e = 0, _f = node.members; _e < _f.length; _e++) { + var member = _f[_e]; if (!isComputedProperty(member)) { addLeafNode(member); } } endNode(); break; - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: startNode(node); - for (var _h = 0, _j = node.members; _h < _j.length; _h++) { - var member = _j[_h]; + for (var _g = 0, _h = node.members; _g < _h.length; _g++) { + var member = _h[_g]; addChildrenRecursively(member); } endNode(); break; - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 266 /* ExportAssignment */: { + case 268 /* 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; @@ -127188,16 +131966,16 @@ var ts; } break; } - case 270 /* ExportSpecifier */: - case 260 /* ImportEqualsDeclaration */: - case 171 /* IndexSignature */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 254 /* TypeAliasDeclaration */: + case 272 /* ExportSpecifier */: + case 262 /* ImportEqualsDeclaration */: + case 173 /* IndexSignature */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 256 /* TypeAliasDeclaration */: addLeafNode(node); break; - case 203 /* CallExpression */: - case 216 /* BinaryExpression */: { + case 205 /* CallExpression */: + case 218 /* BinaryExpression */: { var special = ts.getAssignmentDeclarationKind(node); switch (special) { case 1 /* ExportsProperty */: @@ -127249,7 +132027,7 @@ var ts; defineCall.arguments[0] : defineCall.arguments[0].expression; var memberName = defineCall.arguments[1]; - var _k = startNestedNodes(node, className), depth = _k[0], classNameIdentifier = _k[1]; + var _j = startNestedNodes(node, className), depth = _j[0], classNameIdentifier = _j[1]; startNode(node, classNameIdentifier); startNode(node, ts.setTextRange(ts.factory.createIdentifier(memberName.text), memberName)); addChildrenRecursively(node.arguments[2]); @@ -127439,13 +132217,14 @@ var ts; return false; } switch (a.kind) { - case 163 /* PropertyDeclaration */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return ts.hasSyntacticModifier(a, 32 /* Static */) === ts.hasSyntacticModifier(b, 32 /* Static */); - case 256 /* ModuleDeclaration */: - return areSameModule(a, b); + case 258 /* ModuleDeclaration */: + return areSameModule(a, b) + && getFullyQualifiedModuleName(a) === getFullyQualifiedModuleName(b); default: return true; } @@ -127462,8 +132241,7 @@ var ts; // We use 1 NavNode to represent 'A.B.C', but there are multiple source nodes. // Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'! function areSameModule(a, b) { - // TODO: GH#18217 - return a.body.kind === b.body.kind && (a.body.kind !== 256 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); + return a.body.kind === b.body.kind && (a.body.kind !== 258 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); } /** Merge source into target. Source should be thrown away after this is called. */ function merge(target, source) { @@ -127493,7 +132271,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 256 /* ModuleDeclaration */) { + if (node.kind === 258 /* ModuleDeclaration */) { return getModuleName(node); } var declName = ts.getNameOfDeclaration(node); @@ -127502,16 +132280,16 @@ var ts; return propertyName && ts.unescapeLeadingUnderscores(propertyName); } switch (node.kind) { - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 221 /* ClassExpression */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 223 /* ClassExpression */: return getFunctionOrClassName(node); default: return undefined; } } function getItemName(node, name) { - if (node.kind === 256 /* ModuleDeclaration */) { + if (node.kind === 258 /* ModuleDeclaration */) { return cleanText(getModuleName(node)); } if (name) { @@ -127523,18 +132301,18 @@ var ts; } } switch (node.kind) { - case 297 /* SourceFile */: + case 299 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return ts.isExportAssignment(node) && node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; - case 209 /* ArrowFunction */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 211 /* ArrowFunction */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: if (ts.getSyntacticModifierFlags(node) & 512 /* Default */) { return "default"; } @@ -127542,13 +132320,13 @@ var ts; // (eg: "app\n.onactivated"), so we should remove the whitespace for readability in the // navigation bar. return getFunctionOrClassName(node); - case 166 /* Constructor */: + case 168 /* Constructor */: return "constructor"; - case 170 /* ConstructSignature */: + case 172 /* ConstructSignature */: return "new()"; - case 169 /* CallSignature */: + case 171 /* CallSignature */: return "()"; - case 171 /* IndexSignature */: + case 173 /* IndexSignature */: return "[]"; default: return ""; @@ -127581,19 +132359,19 @@ var ts; } // Some nodes are otherwise important enough to always include in the primary navigation menu. switch (navigationBarNodeKind(item)) { - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 255 /* EnumDeclaration */: - case 253 /* InterfaceDeclaration */: - case 256 /* ModuleDeclaration */: - case 297 /* SourceFile */: - case 254 /* TypeAliasDeclaration */: - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 257 /* EnumDeclaration */: + case 255 /* InterfaceDeclaration */: + case 258 /* ModuleDeclaration */: + case 299 /* SourceFile */: + case 256 /* TypeAliasDeclaration */: + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: return true; - case 209 /* ArrowFunction */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -127603,10 +132381,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 257 /* ModuleBlock */: - case 297 /* SourceFile */: - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: + case 259 /* ModuleBlock */: + case 299 /* SourceFile */: + case 167 /* MethodDeclaration */: + case 168 /* Constructor */: return true; default: return false; @@ -127663,9 +132441,12 @@ var ts; if (ts.isAmbientModule(moduleDeclaration)) { return ts.getTextOfNode(moduleDeclaration.name); } + return getFullyQualifiedModuleName(moduleDeclaration); + } + 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 === 256 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 258 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); } @@ -127679,13 +132460,13 @@ var ts; return decl.body && ts.isModuleDeclaration(decl.body) ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 158 /* ComputedPropertyName */; + return !member.name || member.name.kind === 160 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 297 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); + return node.kind === 299 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { - if (node.parent && node.parent.kind === 249 /* VariableDeclaration */) { + if (node.parent && node.parent.kind === 251 /* VariableDeclaration */) { node = node.parent; } return ts.getNodeModifiers(node); @@ -127700,7 +132481,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 === 62 /* EqualsToken */) { + else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */) { return nodeText(parent.left).replace(whiteSpaceRegex, ""); } // See if it is a property assignment, and if so use the property name @@ -127743,9 +132524,9 @@ var ts; } function isFunctionOrClassExpression(node) { switch (node.kind) { - case 209 /* ArrowFunction */: - case 208 /* FunctionExpression */: - case 221 /* ClassExpression */: + case 211 /* ArrowFunction */: + case 210 /* FunctionExpression */: + case 223 /* ClassExpression */: return true; default: return false; @@ -127774,9 +132555,9 @@ var ts; * 2) Coalescing imports from the same module * 3) Sorting imports */ - function organizeImports(sourceFile, formatContext, host, program, preferences) { + function organizeImports(sourceFile, formatContext, host, program, preferences, skipDestructiveCodeActions) { var changeTracker = ts.textChanges.ChangeTracker.fromContext({ host: host, formatContext: formatContext, preferences: preferences }); - var coalesceAndOrganizeImports = function (importGroup) { return ts.stableSort(coalesceImports(removeUnusedImports(importGroup, sourceFile, program)), function (s1, s2) { return compareImportsOrRequireStatements(s1, s2); }); }; + var coalesceAndOrganizeImports = function (importGroup) { return ts.stableSort(coalesceImports(removeUnusedImports(importGroup, sourceFile, program, skipDestructiveCodeActions)), function (s1, s2) { return compareImportsOrRequireStatements(s1, s2); }); }; // All of the old ImportDeclarations in the file, in syntactic order. var topLevelImportDecls = sourceFile.statements.filter(ts.isImportDeclaration); organizeImportsWorker(topLevelImportDecls, coalesceAndOrganizeImports); @@ -127811,26 +132592,35 @@ var ts; ? coalesce(importGroup) : importGroup; }); - // Delete or replace the first import. + // Delete all nodes if there are no imports. if (newImportDecls.length === 0) { - changeTracker.delete(sourceFile, oldImportDecls[0]); + // Consider the first node to have trailingTrivia as we want to exclude the + // "header" comment. + changeTracker.deleteNodes(sourceFile, oldImportDecls, { + trailingTriviaOption: ts.textChanges.TrailingTriviaOption.Include, + }, /*hasTrailingComment*/ true); } else { // Note: Delete the surrounding trivia because it will have been retained in newImportDecls. - changeTracker.replaceNodeWithNodes(sourceFile, oldImportDecls[0], newImportDecls, { + var replaceOptions = { leadingTriviaOption: ts.textChanges.LeadingTriviaOption.Exclude, trailingTriviaOption: ts.textChanges.TrailingTriviaOption.Include, suffix: ts.getNewLineOrDefaultFromHost(host, formatContext.options), - }); - } - // Delete any subsequent imports. - for (var i = 1; i < oldImportDecls.length; i++) { - changeTracker.deleteNode(sourceFile, oldImportDecls[i]); + }; + changeTracker.replaceNodeWithNodes(sourceFile, oldImportDecls[0], newImportDecls, replaceOptions); + var hasTrailingComment = changeTracker.nodeHasTrailingComment(sourceFile, oldImportDecls[0], replaceOptions); + changeTracker.deleteNodes(sourceFile, oldImportDecls.slice(1), { + trailingTriviaOption: ts.textChanges.TrailingTriviaOption.Include, + }, hasTrailingComment); } } } OrganizeImports.organizeImports = organizeImports; - function removeUnusedImports(oldImports, sourceFile, program) { + function removeUnusedImports(oldImports, sourceFile, program, skipDestructiveCodeActions) { + // As a precaution, consider unused import detection to be destructive (GH #43051) + if (skipDestructiveCodeActions) { + return oldImports; + } var typeChecker = program.getTypeChecker(); var jsxNamespace = typeChecker.getJsxNamespace(sourceFile); var jsxFragmentFactory = typeChecker.getJsxFragmentFactory(sourceFile); @@ -128101,11 +132891,11 @@ var ts; function getModuleSpecifierExpression(declaration) { var _a; switch (declaration.kind) { - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return (_a = ts.tryCast(declaration.moduleReference, ts.isExternalModuleReference)) === null || _a === void 0 ? void 0 : _a.expression; - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return declaration.moduleSpecifier; - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return declaration.declarationList.declarations[0].initializer.arguments[0]; } } @@ -128144,19 +132934,19 @@ var ts; function getImportKindOrder(s1) { var _a; switch (s1.kind) { - case 261 /* ImportDeclaration */: + case 263 /* 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) === 263 /* NamespaceImport */) + if (((_a = s1.importClause.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 265 /* NamespaceImport */) return 2; if (s1.importClause.name) return 3; return 4; - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return 5; - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return 6; } } @@ -128194,7 +132984,7 @@ var ts; } var lastImport = current - 1; if (lastImport !== firstImport) { - out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 99 /* ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* Imports */)); + out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 100 /* ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* Imports */)); } } function visitNonImportNode(n) { @@ -128258,8 +133048,15 @@ var ts; } } } - var regionDelimiterRegExp = /^\s*\/\/\s*#(end)?region(?:\s+(.*))?(?:\r)?$/; + var regionDelimiterRegExp = /^#(end)?region(?:\s+(.*))?(?:\r)?$/; function isRegionDelimiter(lineText) { + // We trim the leading whitespace and // without the regex since the + // multiple potential whitespace matches can make for some gnarly backtracking behavior + lineText = ts.trimStringStart(lineText); + if (!ts.startsWith(lineText, "\/\/")) { + return null; // eslint-disable-line no-null/no-null + } + lineText = ts.trimString(lineText.slice(2)); return regionDelimiterRegExp.exec(lineText); } function addOutliningForLeadingCommentsForNode(n, sourceFile, cancellationToken, out) { @@ -128312,7 +133109,7 @@ var ts; } function getOutliningSpanForNode(n, sourceFile) { switch (n.kind) { - case 230 /* Block */: + case 232 /* Block */: if (ts.isFunctionLike(n.parent)) { return functionSpan(n.parent, n, sourceFile); } @@ -128320,23 +133117,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 235 /* DoStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 237 /* ForStatement */: - case 234 /* IfStatement */: - case 236 /* WhileStatement */: - case 243 /* WithStatement */: - case 287 /* CatchClause */: + case 237 /* DoStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 239 /* ForStatement */: + case 236 /* IfStatement */: + case 238 /* WhileStatement */: + case 245 /* WithStatement */: + case 289 /* CatchClause */: return spanForNode(n.parent); - case 247 /* TryStatement */: + case 249 /* 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, 95 /* FinallyKeyword */, sourceFile); + var node = ts.findChildOfKind(tryStatement, 96 /* FinallyKeyword */, sourceFile); if (node) return spanForNode(node); } @@ -128346,40 +133143,40 @@ var ts; // the span of the block, independent of any parent span. return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* Code */); } - case 257 /* ModuleBlock */: + case 259 /* ModuleBlock */: return spanForNode(n.parent); - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - case 258 /* CaseBlock */: - case 177 /* TypeLiteral */: - case 196 /* ObjectBindingPattern */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: + case 257 /* EnumDeclaration */: + case 260 /* CaseBlock */: + case 179 /* TypeLiteral */: + case 198 /* ObjectBindingPattern */: return spanForNode(n); - case 179 /* TupleType */: + case 181 /* TupleType */: return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isTupleTypeNode(n.parent), 22 /* OpenBracketToken */); - case 284 /* CaseClause */: - case 285 /* DefaultClause */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: return spanForNodeArray(n.statements); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return spanForObjectOrArrayLiteral(n); - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return spanForObjectOrArrayLiteral(n, 22 /* OpenBracketToken */); - case 273 /* JsxElement */: + case 275 /* JsxElement */: return spanForJSXElement(n); - case 277 /* JsxFragment */: + case 279 /* JsxFragment */: return spanForJSXFragment(n); - case 274 /* JsxSelfClosingElement */: - case 275 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: return spanForJSXAttributes(n.attributes); - case 218 /* TemplateExpression */: + case 220 /* TemplateExpression */: case 14 /* NoSubstitutionTemplateLiteral */: return spanForTemplateLiteral(n); - case 197 /* ArrayBindingPattern */: + case 199 /* ArrayBindingPattern */: return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isBindingElement(n.parent), 22 /* OpenBracketToken */); - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return spanForArrowFunction(n); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return spanForCallExpression(n); } function spanForCallExpression(node) { @@ -128446,7 +133243,7 @@ var ts; 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 !== 209 /* ArrowFunction */); + return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 211 /* ArrowFunction */); } function spanBetweenTokens(openToken, closeToken, hintSpanNode, sourceFile, autoCollapse, useFullStart) { if (autoCollapse === void 0) { autoCollapse = false; } @@ -128749,15 +133546,15 @@ var ts; // Assumes 'value' is already lowercase. function indexOfIgnoringCase(str, value) { var n = str.length - value.length; - var _loop_6 = function (start) { + var _loop_7 = 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_1 = _loop_6(start); - if (typeof state_1 === "object") - return state_1.value; + var state_2 = _loop_7(start); + if (typeof state_2 === "object") + return state_2.value; } return -1; } @@ -128990,10 +133787,10 @@ var ts; */ function tryConsumeDeclare() { var token = ts.scanner.getToken(); - if (token === 133 /* DeclareKeyword */) { + if (token === 134 /* DeclareKeyword */) { // declare module "mod" token = nextToken(); - if (token === 139 /* ModuleKeyword */) { + if (token === 140 /* ModuleKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { recordAmbientExternalModule(); @@ -129011,7 +133808,7 @@ var ts; return false; } var token = ts.scanner.getToken(); - if (token === 99 /* ImportKeyword */) { + if (token === 100 /* ImportKeyword */) { token = nextToken(); if (token === 20 /* OpenParenToken */) { token = nextToken(); @@ -129027,21 +133824,21 @@ var ts; return true; } else { - if (token === 149 /* TypeKeyword */) { + if (token === 150 /* TypeKeyword */) { var skipTypeKeyword = ts.scanner.lookAhead(function () { var token = ts.scanner.scan(); - return token !== 153 /* FromKeyword */ && (token === 41 /* AsteriskToken */ || + return token !== 154 /* FromKeyword */ && (token === 41 /* AsteriskToken */ || token === 18 /* OpenBraceToken */ || - token === 78 /* Identifier */ || + token === 79 /* Identifier */ || ts.isKeyword(token)); }); if (skipTypeKeyword) { token = nextToken(); } } - if (token === 78 /* Identifier */ || ts.isKeyword(token)) { + if (token === 79 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 153 /* FromKeyword */) { + if (token === 154 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // import d from "mod"; @@ -129049,7 +133846,7 @@ var ts; return true; } } - else if (token === 62 /* EqualsToken */) { + else if (token === 63 /* EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } @@ -129072,7 +133869,7 @@ var ts; } if (token === 19 /* CloseBraceToken */) { token = nextToken(); - if (token === 153 /* FromKeyword */) { + if (token === 154 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // import {a as A} from "mod"; @@ -129084,11 +133881,11 @@ var ts; } else if (token === 41 /* AsteriskToken */) { token = nextToken(); - if (token === 126 /* AsKeyword */) { + if (token === 127 /* AsKeyword */) { token = nextToken(); - if (token === 78 /* Identifier */ || ts.isKeyword(token)) { + if (token === 79 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 153 /* FromKeyword */) { + if (token === 154 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // import * as NS from "mod" @@ -129106,10 +133903,10 @@ var ts; } function tryConsumeExport() { var token = ts.scanner.getToken(); - if (token === 92 /* ExportKeyword */) { + if (token === 93 /* ExportKeyword */) { markAsExternalModuleIfTopLevel(); token = nextToken(); - if (token === 149 /* TypeKeyword */) { + if (token === 150 /* TypeKeyword */) { var skipTypeKeyword = ts.scanner.lookAhead(function () { var token = ts.scanner.scan(); return token === 41 /* AsteriskToken */ || @@ -129128,7 +133925,7 @@ var ts; } if (token === 19 /* CloseBraceToken */) { token = nextToken(); - if (token === 153 /* FromKeyword */) { + if (token === 154 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // export {a as A} from "mod"; @@ -129140,7 +133937,7 @@ var ts; } else if (token === 41 /* AsteriskToken */) { token = nextToken(); - if (token === 153 /* FromKeyword */) { + if (token === 154 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // export * from "mod" @@ -129148,21 +133945,21 @@ var ts; } } } - else if (token === 99 /* ImportKeyword */) { + else if (token === 100 /* ImportKeyword */) { token = nextToken(); - if (token === 149 /* TypeKeyword */) { + if (token === 150 /* TypeKeyword */) { var skipTypeKeyword = ts.scanner.lookAhead(function () { var token = ts.scanner.scan(); - return token === 78 /* Identifier */ || + return token === 79 /* Identifier */ || ts.isKeyword(token); }); if (skipTypeKeyword) { token = nextToken(); } } - if (token === 78 /* Identifier */ || ts.isKeyword(token)) { + if (token === 79 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 62 /* EqualsToken */) { + if (token === 63 /* EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } @@ -129176,7 +133973,7 @@ var ts; function tryConsumeRequireCall(skipCurrentToken, allowTemplateLiterals) { if (allowTemplateLiterals === void 0) { allowTemplateLiterals = false; } var token = skipCurrentToken ? nextToken() : ts.scanner.getToken(); - if (token === 143 /* RequireKeyword */) { + if (token === 144 /* RequireKeyword */) { token = nextToken(); if (token === 20 /* OpenParenToken */) { token = nextToken(); @@ -129192,7 +133989,7 @@ var ts; } function tryConsumeDefine() { var token = ts.scanner.getToken(); - if (token === 78 /* Identifier */ && ts.scanner.getTokenValue() === "define") { + if (token === 79 /* Identifier */ && ts.scanner.getTokenValue() === "define") { token = nextToken(); if (token !== 20 /* OpenParenToken */) { return true; @@ -129309,7 +134106,7 @@ var ts; function getRenameInfo(program, sourceFile, position, options) { var node = ts.getAdjustedRenameLocation(ts.getTouchingPropertyName(sourceFile, position)); if (nodeIsEligibleForRename(node)) { - var renameInfo = getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, function (declaration) { return program.isSourceFileDefaultLibrary(declaration.getSourceFile()); }, options); + var renameInfo = getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, program, options); if (renameInfo) { return renameInfo; } @@ -129317,7 +134114,7 @@ var ts; return getRenameInfoError(ts.Diagnostics.You_cannot_rename_this_element); } Rename.getRenameInfo = getRenameInfo; - function getRenameInfoForNode(node, typeChecker, sourceFile, isDefinedInLibraryFile, options) { + function getRenameInfoForNode(node, typeChecker, sourceFile, program, options) { var symbol = typeChecker.getSymbolAtLocation(node); if (!symbol) { if (ts.isStringLiteralLike(node)) { @@ -129337,29 +134134,33 @@ var ts; if (!declarations || declarations.length === 0) return; // Disallow rename for elements that are defined in the standard TypeScript library. - if (declarations.some(isDefinedInLibraryFile)) { + if (declarations.some(function (declaration) { return isDefinedInLibraryFile(program, declaration); })) { 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 === 87 /* DefaultKeyword */ && symbol.parent && symbol.parent.flags & 1536 /* Module */) { + if (ts.isIdentifier(node) && node.originalKeywordKind === 88 /* DefaultKeyword */ && symbol.parent && symbol.parent.flags & 1536 /* Module */) { return undefined; } if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) { return options && options.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined; } var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); - var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 158 /* ComputedPropertyName */) + var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 160 /* ComputedPropertyName */) ? ts.stripQuotes(ts.getTextOfIdentifierOrLiteral(node)) : undefined; var displayName = specifierName || typeChecker.symbolToString(symbol); var fullDisplayName = specifierName || typeChecker.getFullyQualifiedName(symbol); return getRenameInfoSuccess(displayName, fullDisplayName, kind, ts.SymbolDisplay.getSymbolModifiers(typeChecker, symbol), node, sourceFile); } + function isDefinedInLibraryFile(program, declaration) { + var sourceFile = declaration.getSourceFile(); + return program.isSourceFileDefaultLibrary(sourceFile) && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Dts */); + } function getRenameInfoForModule(node, sourceFile, moduleSymbol) { if (!ts.isExternalModuleNameRelative(node.text)) { return getRenameInfoError(ts.Diagnostics.You_cannot_rename_a_module_via_a_global_import); } - var moduleSourceFile = ts.find(moduleSymbol.declarations, ts.isSourceFile); + var moduleSourceFile = moduleSymbol.declarations && ts.find(moduleSymbol.declarations, ts.isSourceFile); if (!moduleSourceFile) return undefined; var withoutIndex = ts.endsWith(node.text, "/index") || ts.endsWith(node.text, "/index.js") ? undefined : ts.tryRemoveSuffix(ts.removeFileExtension(moduleSourceFile.fileName), "/index"); @@ -129404,11 +134205,11 @@ var ts; } function nodeIsEligibleForRename(node) { switch (node.kind) { - case 78 /* Identifier */: - case 79 /* PrivateIdentifier */: + case 79 /* Identifier */: + case 80 /* PrivateIdentifier */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: return true; case 8 /* NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node); @@ -129440,6 +134241,10 @@ var ts; if (ts.getTokenPosOfNode(node, sourceFile, /*includeJsDoc*/ true) > pos) { break outer; } + var comment = ts.singleOrUndefined(ts.getTrailingCommentRanges(sourceFile.text, node.end)); + if (comment && comment.kind === 2 /* SingleLineCommentTrivia */) { + pushSelectionCommentRange(comment.pos, comment.end); + } if (positionShouldSnapToNode(sourceFile, pos, node)) { // 1. Blocks are effectively redundant with SyntaxLists. // 2. TemplateSpans, along with the SyntaxLists containing them, are a somewhat unintuitive grouping @@ -129502,6 +134307,14 @@ var ts; } } } + function pushSelectionCommentRange(start, end) { + pushSelectionRange(start, end); + var pos = start; + while (sourceFile.text.charCodeAt(pos) === 47 /* slash */) { + pos++; + } + pushSelectionRange(pos, end); + } } SmartSelectionRange.getSmartSelectionRange = getSmartSelectionRange; /** @@ -129558,14 +134371,14 @@ var ts; ts.Debug.assertEqual(closeBraceToken.kind, 19 /* CloseBraceToken */); // Group `-/+readonly` and `-/+?` var groupedWithPlusMinusTokens = groupChildren(children, function (child) { - return child === node.readonlyToken || child.kind === 142 /* ReadonlyKeyword */ || + return child === node.readonlyToken || child.kind === 143 /* ReadonlyKeyword */ || child === node.questionToken || child.kind === 57 /* QuestionToken */; }); // Group type parameter with surrounding brackets var groupedWithBrackets = groupChildren(groupedWithPlusMinusTokens, function (_a) { var kind = _a.kind; return kind === 22 /* OpenBracketToken */ || - kind === 159 /* TypeParameter */ || + kind === 161 /* TypeParameter */ || kind === 23 /* CloseBracketToken */; }); return [ @@ -129598,14 +134411,14 @@ var ts; }); return splitChildren(groupedWithQuestionToken, function (_a) { var kind = _a.kind; - return kind === 62 /* EqualsToken */; + return kind === 63 /* EqualsToken */; }); } // Pivot on '=' if (ts.isBindingElement(node)) { return splitChildren(node.getChildren(), function (_a) { var kind = _a.kind; - return kind === 62 /* EqualsToken */; + return kind === 63 /* EqualsToken */; }); } return node.getChildren(); @@ -129679,22 +134492,22 @@ var ts; return kind === 18 /* OpenBraceToken */ || kind === 22 /* OpenBracketToken */ || kind === 20 /* OpenParenToken */ - || kind === 275 /* JsxOpeningElement */; + || kind === 277 /* JsxOpeningElement */; } function isListCloser(token) { var kind = token && token.kind; return kind === 19 /* CloseBraceToken */ || kind === 23 /* CloseBracketToken */ || kind === 21 /* CloseParenToken */ - || kind === 276 /* JsxClosingElement */; + || kind === 278 /* JsxClosingElement */; } function getEndPos(sourceFile, node) { switch (node.kind) { - case 326 /* JSDocParameterTag */: - case 324 /* JSDocCallbackTag */: - case 333 /* JSDocPropertyTag */: - case 331 /* JSDocTypedefTag */: - case 328 /* JSDocThisTag */: + case 334 /* JSDocParameterTag */: + case 332 /* JSDocCallbackTag */: + case 341 /* JSDocPropertyTag */: + case 339 /* JSDocTypedefTag */: + case 336 /* JSDocThisTag */: return sourceFile.getLineEndOfPosition(node.getStart()); default: return node.getEnd(); @@ -129904,10 +134717,10 @@ var ts; } return undefined; } - else if (ts.isTemplateHead(node) && parent.parent.kind === 205 /* TaggedTemplateExpression */) { + else if (ts.isTemplateHead(node) && parent.parent.kind === 207 /* TaggedTemplateExpression */) { var templateExpression = parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 218 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 220 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position, sourceFile) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } @@ -129976,17 +134789,17 @@ var ts; return undefined; var parent = startingToken.parent; switch (parent.kind) { - case 207 /* ParenthesizedExpression */: - case 165 /* MethodDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 209 /* ParenthesizedExpression */: + case 167 /* MethodDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: var info = getArgumentOrParameterListInfo(startingToken, 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 216 /* BinaryExpression */: { + case 218 /* BinaryExpression */: { var highestBinary = getHighestBinary(parent); var contextualType_1 = checker.getContextualType(highestBinary); var argumentIndex_1 = startingToken.kind === 20 /* OpenParenToken */ ? 0 : countBinaryExpressionParameters(parent) - 1; @@ -130110,7 +134923,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 === 218 /* TemplateExpression */) { + if (template.kind === 220 /* TemplateExpression */) { var lastSpan = ts.last(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -130119,7 +134932,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node, position, sourceFile, checker, isManuallyInvoked) { - var _loop_7 = function (n) { + var _loop_8 = 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); }); @@ -130129,9 +134942,9 @@ var ts; } }; for (var n = node; !ts.isSourceFile(n) && (isManuallyInvoked || !ts.isBlock(n)); n = n.parent) { - var state_2 = _loop_7(n); - if (typeof state_2 === "object") - return state_2.value; + var state_3 = _loop_8(n); + if (typeof state_3 === "object") + return state_3.value; } return undefined; } @@ -130181,7 +134994,19 @@ var ts; itemsSeen += item.length; } ts.Debug.assert(selectedItemIndex !== -1); // If candidates is non-empty it should always include bestSignature. We check for an empty candidates before calling this function. - return { items: ts.flatMapToMutable(items, ts.identity), applicableSpan: applicableSpan, selectedItemIndex: selectedItemIndex, argumentIndex: argumentIndex, argumentCount: argumentCount }; + var help = { items: ts.flatMapToMutable(items, ts.identity), applicableSpan: applicableSpan, selectedItemIndex: selectedItemIndex, argumentIndex: argumentIndex, argumentCount: argumentCount }; + var selected = help.items[selectedItemIndex]; + if (selected.isVariadic) { + var firstRest = ts.findIndex(selected.parameters, function (p) { return !!p.isRest; }); + if (-1 < firstRest && firstRest < selected.parameters.length - 1) { + // We don't have any code to get this correct; instead, don't highlight a current parameter AT ALL + help.argumentIndex = selected.parameters.length; + } + else { + help.argumentIndex = Math.min(help.argumentIndex, selected.parameters.length - 1); + } + } + return help; } function createTypeHelpItems(symbol, _a, sourceFile, checker) { var argumentCount = _a.argumentCount, applicableSpan = _a.argumentsSpan, invocation = _a.invocation, argumentIndex = _a.argumentIndex; @@ -130196,7 +135021,7 @@ var ts; var printer = ts.createPrinter({ removeComments: true }); var parameters = typeParameters.map(function (t) { return createSignatureHelpParameterForTypeParameter(t, checker, enclosingDeclaration, sourceFile, printer); }); var documentation = symbol.getDocumentationComment(checker); - var tags = symbol.getJsDocTags(); + var tags = symbol.getJsDocTags(checker); var prefixDisplayParts = __spreadArray(__spreadArray([], typeSymbolDisplay), [ts.punctuationPart(29 /* LessThanToken */)]); return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(31 /* GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; } @@ -130239,7 +135064,6 @@ var ts; }); } function itemInfoForParameters(candidateSignature, checker, enclosingDeclaration, sourceFile) { - var isVariadic = checker.hasEffectiveRestParameter(candidateSignature); var printer = ts.createPrinter({ removeComments: true }); var typeParameterParts = ts.mapToDisplayParts(function (writer) { if (candidateSignature.typeParameters && candidateSignature.typeParameters.length) { @@ -130248,14 +135072,15 @@ var ts; } }); var lists = checker.getExpandedParameters(candidateSignature); - return lists.map(function (parameterList) { - return { - isVariadic: isVariadic && (lists.length === 1 || !!(parameterList[parameterList.length - 1].checkFlags & 32768 /* RestParameter */)), - parameters: parameterList.map(function (p) { return createSignatureHelpParameterForParameter(p, checker, enclosingDeclaration, sourceFile, printer); }), - prefix: __spreadArray(__spreadArray([], typeParameterParts), [ts.punctuationPart(20 /* OpenParenToken */)]), - suffix: [ts.punctuationPart(21 /* CloseParenToken */)] - }; - }); + 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 */); }; + 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), [ts.punctuationPart(20 /* OpenParenToken */)]), + suffix: [ts.punctuationPart(21 /* CloseParenToken */)] + }); }); } function createSignatureHelpParameterForParameter(parameter, checker, enclosingDeclaration, sourceFile, printer) { var displayParts = ts.mapToDisplayParts(function (writer) { @@ -130263,14 +135088,15 @@ var ts; printer.writeNode(4 /* Unspecified */, param, sourceFile, writer); }); var isOptional = checker.isOptionalParameter(parameter.valueDeclaration); - return { name: parameter.name, documentation: parameter.getDocumentationComment(checker), displayParts: displayParts, isOptional: isOptional }; + var isRest = !!(parameter.checkFlags & 32768 /* 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); }); - return { name: typeParameter.symbol.name, documentation: typeParameter.symbol.getDocumentationComment(checker), displayParts: displayParts, isOptional: false }; + return { name: typeParameter.symbol.name, documentation: typeParameter.symbol.getDocumentationComment(checker), displayParts: displayParts, isOptional: false, isRest: false }; } })(SignatureHelp = ts.SignatureHelp || (ts.SignatureHelp = {})); })(ts || (ts = {})); @@ -130480,7 +135306,7 @@ var ts; diags.push(ts.createDiagnosticForNode(node.name || node, ts.Diagnostics.JSDoc_types_may_be_moved_to_TypeScript_types)); } } - if (ts.isFunctionLikeDeclaration(node)) { + if (canBeConvertedToAsync(node)) { addConvertToAsyncFunctionDiagnostics(node, checker, diags); } node.forEachChild(check); @@ -130491,11 +135317,11 @@ var ts; function containsTopLevelCommonjs(sourceFile) { return sourceFile.statements.some(function (statement) { switch (statement.kind) { - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return statement.declarationList.declarations.some(function (decl) { return !!decl.initializer && ts.isRequireCall(propertyAccessLeftHandSide(decl.initializer), /*checkArgumentIsStringLiteralLike*/ true); }); - case 233 /* ExpressionStatement */: { + case 235 /* ExpressionStatement */: { var expression = statement.expression; if (!ts.isBinaryExpression(expression)) return ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true); @@ -130512,12 +135338,12 @@ var ts; } function importNameForConvertToDefaultImport(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: var importClause = node.importClause, moduleSpecifier = node.moduleSpecifier; - return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 263 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) + return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 265 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) ? importClause.namedBindings.name : undefined; - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return node.name; default: return undefined; @@ -130533,35 +135359,35 @@ var ts; return !ts.isAsyncFunction(node) && node.body && ts.isBlock(node.body) && - hasReturnStatementWithPromiseHandler(node.body) && + hasReturnStatementWithPromiseHandler(node.body, checker) && returnsPromise(node, checker); } function returnsPromise(node, checker) { - var functionType = checker.getTypeAtLocation(node); - var callSignatures = checker.getSignaturesOfType(functionType, 0 /* Call */); - var returnType = callSignatures.length ? checker.getReturnTypeOfSignature(callSignatures[0]) : undefined; + var signature = checker.getSignatureFromDeclaration(node); + var returnType = signature ? checker.getReturnTypeOfSignature(signature) : undefined; return !!returnType && !!checker.getPromisedTypeOfPromise(returnType); } + ts.returnsPromise = returnsPromise; function getErrorNodeFromCommonJsIndicator(commonJsModuleIndicator) { return ts.isBinaryExpression(commonJsModuleIndicator) ? commonJsModuleIndicator.left : commonJsModuleIndicator; } - function hasReturnStatementWithPromiseHandler(body) { - return !!ts.forEachReturnStatement(body, isReturnStatementWithFixablePromiseHandler); + function hasReturnStatementWithPromiseHandler(body, checker) { + return !!ts.forEachReturnStatement(body, function (statement) { return isReturnStatementWithFixablePromiseHandler(statement, checker); }); } - function isReturnStatementWithFixablePromiseHandler(node) { - return ts.isReturnStatement(node) && !!node.expression && isFixablePromiseHandler(node.expression); + function isReturnStatementWithFixablePromiseHandler(node, checker) { + return ts.isReturnStatement(node) && !!node.expression && isFixablePromiseHandler(node.expression, checker); } ts.isReturnStatementWithFixablePromiseHandler = isReturnStatementWithFixablePromiseHandler; // Should be kept up to date with transformExpression in convertToAsyncFunction.ts - function isFixablePromiseHandler(node) { + function isFixablePromiseHandler(node, checker) { // ensure outermost call exists and is a promise handler - if (!isPromiseHandler(node) || !node.arguments.every(isFixablePromiseArgument)) { + if (!isPromiseHandler(node) || !node.arguments.every(function (arg) { return isFixablePromiseArgument(arg, checker); })) { return false; } // ensure all chained calls are valid var currentNode = node.expression; while (isPromiseHandler(currentNode) || ts.isPropertyAccessExpression(currentNode)) { - if (ts.isCallExpression(currentNode) && !currentNode.arguments.every(isFixablePromiseArgument)) { + if (ts.isCallExpression(currentNode) && !currentNode.arguments.every(function (arg) { return isFixablePromiseArgument(arg, checker); })) { return false; } currentNode = currentNode.expression; @@ -130579,21 +135405,34 @@ var ts; if (node.arguments.length < 2) return true; return ts.some(node.arguments, function (arg) { - return arg.kind === 103 /* NullKeyword */ || + return arg.kind === 104 /* NullKeyword */ || ts.isIdentifier(arg) && arg.text === "undefined"; }); } // should be kept up to date with getTransformationBody in convertToAsyncFunction.ts - function isFixablePromiseArgument(arg) { + function isFixablePromiseArgument(arg, checker) { switch (arg.kind) { - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + var functionFlags = ts.getFunctionFlags(arg); + if (functionFlags & 1 /* Generator */) { + return false; + } + // falls through + case 211 /* ArrowFunction */: visitedNestedConvertibleFunctions.set(getKeyFromNode(arg), true); // falls through - case 103 /* NullKeyword */: - case 78 /* Identifier */: // identifier includes undefined + case 104 /* NullKeyword */: return true; + case 79 /* Identifier */: + case 203 /* PropertyAccessExpression */: { + var symbol = checker.getSymbolAtLocation(arg); + if (!symbol) { + return false; + } + return checker.isUndefinedSymbol(symbol) || + ts.some(ts.skipAlias(symbol, checker).declarations, function (d) { return ts.isFunctionLike(d) || ts.hasInitializer(d) && !!d.initializer && ts.isFunctionLike(d.initializer); }); + } default: return false; } @@ -130603,18 +135442,30 @@ var ts; } function canBeConvertedToClass(node, checker) { var _a, _b, _c, _d; - if (node.kind === 208 /* FunctionExpression */) { + if (node.kind === 210 /* 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 === 251 /* FunctionDeclaration */) { + if (node.kind === 253 /* FunctionDeclaration */) { return !!((_d = node.symbol.members) === null || _d === void 0 ? void 0 : _d.size); } return false; } + function canBeConvertedToAsync(node) { + switch (node.kind) { + case 253 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + return true; + default: + return false; + } + } + ts.canBeConvertedToAsync = canBeConvertedToAsync; })(ts || (ts = {})); /* @internal */ var ts; @@ -130630,7 +135481,7 @@ var ts; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); if (flags & 32 /* Class */) { - return ts.getDeclarationOfKind(symbol, 221 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 223 /* ClassExpression */) ? "local class" /* localClassElement */ : "class" /* classElement */; } if (flags & 384 /* Enum */) @@ -130665,7 +135516,7 @@ var ts; if (typeChecker.isArgumentsSymbol(symbol)) { return "local var" /* localVariableElement */; } - if (location.kind === 107 /* ThisKeyword */ && ts.isExpression(location)) { + if (location.kind === 108 /* ThisKeyword */ && ts.isExpression(location)) { return "parameter" /* parameterElement */; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); @@ -130714,11 +135565,11 @@ var ts; // If we requested completions after `x.` at the top-level, we may be at a source file location. switch (location.parent && location.parent.kind) { // If we've typed a character of the attribute name, will be 'JsxAttribute', else will be 'JsxOpeningElement'. - case 275 /* JsxOpeningElement */: - case 273 /* JsxElement */: - case 274 /* JsxSelfClosingElement */: - return location.kind === 78 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; - case 280 /* JsxAttribute */: + case 277 /* JsxOpeningElement */: + case 275 /* JsxElement */: + case 276 /* JsxSelfClosingElement */: + return location.kind === 79 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; + case 282 /* JsxAttribute */: return "JSX attribute" /* jsxAttribute */; default: return "property" /* memberVariableElement */; @@ -130726,14 +135577,11 @@ var ts; } return "" /* unknown */; } - function isDeprecatedDeclaration(decl) { - return !!(ts.getCombinedNodeFlagsAlwaysIncludeJSDoc(decl) & 8192 /* Deprecated */); - } 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) && isDeprecatedDeclaration(declaration) && ts.some(declarations, function (d) { return !isDeprecatedDeclaration(d); }) + var excludeFlags = ts.length(declarations) && ts.isDeprecatedDeclaration(declaration) && ts.some(declarations, function (d) { return !ts.isDeprecatedDeclaration(d); }) ? 8192 /* Deprecated */ : 0 /* None */; var modifiers = ts.getNodeModifiers(declaration, excludeFlags); @@ -130764,6 +135612,7 @@ var ts; SymbolDisplay.getSymbolModifiers = getSymbolModifiers; // TODO(drosen): Currently completion entry details passes the SemanticMeaning.All instead of using semanticMeaning of location function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, enclosingDeclaration, location, semanticMeaning, alias) { + var _a; if (semanticMeaning === void 0) { semanticMeaning = ts.getMeaningFromLocation(location); } var displayParts = []; var documentation = []; @@ -130771,14 +135620,14 @@ var ts; var symbolFlags = ts.getCombinedLocalAndExportSymbolFlags(symbol); var symbolKind = semanticMeaning & 1 /* Value */ ? getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) : "" /* unknown */; var hasAddedSymbolInfo = false; - var isThisExpression = location.kind === 107 /* ThisKeyword */ && ts.isInExpressionContext(location); + var isThisExpression = location.kind === 108 /* ThisKeyword */ && ts.isInExpressionContext(location); var type; var printer; var documentationFromAlias; var tagsFromAlias; var hasMultipleSignatures = false; - if (location.kind === 107 /* ThisKeyword */ && !isThisExpression) { - return { displayParts: [ts.keywordPart(107 /* ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* primitiveType */, tags: undefined }; + if (location.kind === 108 /* ThisKeyword */ && !isThisExpression) { + return { displayParts: [ts.keywordPart(108 /* ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* 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 */) { @@ -130787,8 +135636,8 @@ var ts; symbolKind = "property" /* memberVariableElement */; } var signature = void 0; - type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol.exportSymbol || symbol, location); - if (location.parent && location.parent.kind === 201 /* PropertyAccessExpression */) { + type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); + if (location.parent && location.parent.kind === 203 /* 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)) { @@ -130808,9 +135657,9 @@ var ts; } if (callExpressionLike) { signature = typeChecker.getResolvedSignature(callExpressionLike); // TODO: GH#18217 - var useConstructSignatures = callExpressionLike.kind === 204 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 105 /* SuperKeyword */); + var useConstructSignatures = callExpressionLike.kind === 206 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 106 /* SuperKeyword */); var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); - if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { + if (signature && !ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { // Get the first signature if there is one -- allSignatures may contain // either the original signature or its target, so check for either signature = allSignatures.length ? allSignatures[0] : undefined; @@ -130827,10 +135676,10 @@ var ts; displayParts.push(ts.spacePart()); if (useConstructSignatures) { if (signature.flags & 4 /* Abstract */) { - displayParts.push(ts.keywordPart(125 /* AbstractKeyword */)); + displayParts.push(ts.keywordPart(126 /* AbstractKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(102 /* NewKeyword */)); + displayParts.push(ts.keywordPart(103 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -130855,10 +135704,10 @@ var ts; } if (useConstructSignatures) { if (signature.flags & 4 /* Abstract */) { - displayParts.push(ts.keywordPart(125 /* AbstractKeyword */)); + displayParts.push(ts.keywordPart(126 /* AbstractKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(102 /* NewKeyword */)); + displayParts.push(ts.keywordPart(103 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addSignatureDisplayParts(signature, allSignatures, 262144 /* WriteArrowStyleSignature */); @@ -130872,32 +135721,34 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* Accessor */)) || // name of function declaration - (location.kind === 132 /* ConstructorKeyword */ && location.parent.kind === 166 /* Constructor */)) { // At constructor keyword of constructor declaration + (location.kind === 133 /* ConstructorKeyword */ && location.parent.kind === 168 /* 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 === 132 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); + return declaration === (location.kind === 133 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); }); if (locationIsSymbolDeclaration) { - var allSignatures = functionDeclaration_1.kind === 166 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration_1.kind === 168 /* 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 === 166 /* Constructor */) { + if (functionDeclaration_1.kind === 168 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = "constructor" /* constructorImplementationElement */; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 169 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 171 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } - addSignatureDisplayParts(signature, allSignatures); + if (signature) { + addSignatureDisplayParts(signature, allSignatures); + } hasAddedSymbolInfo = true; hasMultipleSignatures = allSignatures.length > 1; } @@ -130905,7 +135756,7 @@ var ts; } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { addAliasPrefixIfNecessary(); - if (ts.getDeclarationOfKind(symbol, 221 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 223 /* 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 @@ -130913,7 +135764,7 @@ var ts; } else { // Class declaration has name which is not local. - displayParts.push(ts.keywordPart(83 /* ClassKeyword */)); + displayParts.push(ts.keywordPart(84 /* ClassKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); @@ -130921,37 +135772,37 @@ var ts; } if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(117 /* InterfaceKeyword */)); + displayParts.push(ts.keywordPart(118 /* InterfaceKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if ((symbolFlags & 524288 /* TypeAlias */) && (semanticMeaning & 2 /* Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(149 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(150 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(62 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* EqualsToken */)); displayParts.push(ts.spacePart()); ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 8388608 /* InTypeAlias */)); } if (symbolFlags & 384 /* Enum */) { prefixNextMeaning(); if (ts.some(symbol.declarations, function (d) { return ts.isEnumDeclaration(d) && ts.isEnumConst(d); })) { - displayParts.push(ts.keywordPart(84 /* ConstKeyword */)); + displayParts.push(ts.keywordPart(85 /* ConstKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(91 /* EnumKeyword */)); + displayParts.push(ts.keywordPart(92 /* EnumKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536 /* Module */ && !isThisExpression) { prefixNextMeaning(); - var declaration = ts.getDeclarationOfKind(symbol, 256 /* ModuleDeclaration */); - var isNamespace = declaration && declaration.name && declaration.name.kind === 78 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 140 /* NamespaceKeyword */ : 139 /* ModuleKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 258 /* ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 79 /* Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 141 /* NamespaceKeyword */ : 140 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } @@ -130970,7 +135821,7 @@ var ts; } else { // Method/function type parameter - var decl = ts.getDeclarationOfKind(symbol, 159 /* TypeParameter */); + var decl = ts.getDeclarationOfKind(symbol, 161 /* TypeParameter */); if (decl === undefined) return ts.Debug.fail(); var declaration = decl.parent; @@ -130978,21 +135829,21 @@ var ts; if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); var signature = typeChecker.getSignatureFromDeclaration(declaration); // TODO: GH#18217 - if (declaration.kind === 170 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(102 /* NewKeyword */)); + if (declaration.kind === 172 /* ConstructSignature */) { + displayParts.push(ts.keywordPart(103 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 169 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 171 /* CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 254 /* TypeAliasDeclaration */) { + else if (declaration.kind === 256 /* TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path addInPrefix(); - displayParts.push(ts.keywordPart(149 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(150 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -131003,12 +135854,12 @@ var ts; if (symbolFlags & 8 /* EnumMember */) { symbolKind = "enum member" /* enumMemberElement */; addPrefixForAnyFunctionOrVar(symbol, "enum member"); - var declaration = symbol.declarations[0]; - if (declaration.kind === 291 /* EnumMember */) { + var declaration = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]; + if ((declaration === null || declaration === void 0 ? void 0 : declaration.kind) === 293 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(62 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* EqualsToken */)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(ts.getTextOfConstantValue(constantValue), typeof constantValue === "number" ? ts.SymbolDisplayPartKind.numericLiteral : ts.SymbolDisplayPartKind.stringLiteral)); } @@ -131034,37 +135885,39 @@ var ts; } else { documentationFromAlias = resolvedSymbol.getContextualDocumentationComment(resolvedNode, typeChecker); - tagsFromAlias = resolvedSymbol.getJsDocTags(); + tagsFromAlias = resolvedSymbol.getJsDocTags(typeChecker); } } } - switch (symbol.declarations[0].kind) { - case 259 /* NamespaceExportDeclaration */: - displayParts.push(ts.keywordPart(92 /* ExportKeyword */)); - displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(140 /* NamespaceKeyword */)); - break; - case 266 /* ExportAssignment */: - displayParts.push(ts.keywordPart(92 /* ExportKeyword */)); - displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 62 /* EqualsToken */ : 87 /* DefaultKeyword */)); - break; - case 270 /* ExportSpecifier */: - displayParts.push(ts.keywordPart(92 /* ExportKeyword */)); - break; - default: - displayParts.push(ts.keywordPart(99 /* ImportKeyword */)); + if (symbol.declarations) { + switch (symbol.declarations[0].kind) { + case 261 /* NamespaceExportDeclaration */: + displayParts.push(ts.keywordPart(93 /* ExportKeyword */)); + displayParts.push(ts.spacePart()); + displayParts.push(ts.keywordPart(141 /* NamespaceKeyword */)); + break; + case 268 /* ExportAssignment */: + displayParts.push(ts.keywordPart(93 /* ExportKeyword */)); + displayParts.push(ts.spacePart()); + displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 63 /* EqualsToken */ : 88 /* DefaultKeyword */)); + break; + case 272 /* ExportSpecifier */: + displayParts.push(ts.keywordPart(93 /* ExportKeyword */)); + break; + default: + displayParts.push(ts.keywordPart(100 /* ImportKeyword */)); + } } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 260 /* ImportEqualsDeclaration */) { + if (declaration.kind === 262 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(62 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(143 /* RequireKeyword */)); + displayParts.push(ts.keywordPart(144 /* RequireKeyword */)); displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); @@ -131073,7 +135926,7 @@ var ts; var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(62 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* EqualsToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -131087,7 +135940,7 @@ var ts; if (type) { if (isThisExpression) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(107 /* ThisKeyword */)); + displayParts.push(ts.keywordPart(108 /* ThisKeyword */)); } else { addPrefixForAnyFunctionOrVar(symbol, symbolKind); @@ -131145,10 +135998,10 @@ var ts; // 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 && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 297 /* SourceFile */; })) { - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 216 /* BinaryExpression */) { + if (symbol.parent && symbol.declarations && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 299 /* SourceFile */; })) { + for (var _i = 0, _b = symbol.declarations; _i < _b.length; _i++) { + var declaration = _b[_i]; + if (!declaration.parent || declaration.parent.kind !== 218 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -131156,7 +136009,7 @@ var ts; continue; } documentation = rhsSymbol.getDocumentationComment(typeChecker); - tags = rhsSymbol.getJsDocTags(); + tags = rhsSymbol.getJsDocTags(typeChecker); if (documentation.length > 0) { break; } @@ -131164,7 +136017,7 @@ var ts; } } if (tags.length === 0 && !hasMultipleSignatures) { - tags = symbol.getJsDocTags(); + tags = symbol.getJsDocTags(typeChecker); } if (documentation.length === 0 && documentationFromAlias) { documentation = documentationFromAlias; @@ -131193,7 +136046,7 @@ var ts; } function addInPrefix() { displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(100 /* InKeyword */)); + displayParts.push(ts.keywordPart(101 /* InKeyword */)); displayParts.push(ts.spacePart()); } function addFullSymbolName(symbolToDisplay, enclosingDeclaration) { @@ -131266,16 +136119,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 208 /* FunctionExpression */) { + if (declaration.kind === 210 /* FunctionExpression */) { return true; } - if (declaration.kind !== 249 /* VariableDeclaration */ && declaration.kind !== 251 /* FunctionDeclaration */) { + if (declaration.kind !== 251 /* VariableDeclaration */ && declaration.kind !== 253 /* 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 === 297 /* SourceFile */ || parent.kind === 257 /* ModuleBlock */) { + if (parent.kind === 299 /* SourceFile */ || parent.kind === 259 /* ModuleBlock */) { return false; } } @@ -131377,11 +136230,10 @@ var ts; /*@internal*/ function fixupCompilerOptions(options, diagnostics) { // Lazily create this value to fix module loading errors. - commandLineOptionsStringToEnum = commandLineOptionsStringToEnum || ts.filter(ts.optionDeclarations, function (o) { - return typeof o.type === "object" && !ts.forEachEntry(o.type, function (v) { return typeof v !== "number"; }); - }); + 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_8 = function (opt) { + var _loop_9 = function (opt) { if (!ts.hasProperty(options, opt.name)) { return "continue"; } @@ -131400,7 +136252,7 @@ var ts; }; for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) { var opt = commandLineOptionsStringToEnum_1[_i]; - _loop_8(opt); + _loop_9(opt); } return options; } @@ -131565,8 +136417,8 @@ var ts; function shouldRescanGreaterThanToken(node) { switch (node.kind) { case 33 /* GreaterThanEqualsToken */: - case 70 /* GreaterThanGreaterThanEqualsToken */: - case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanEqualsToken */: + case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: case 49 /* GreaterThanGreaterThanGreaterThanToken */: case 48 /* GreaterThanGreaterThanToken */: return true; @@ -131576,25 +136428,18 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 280 /* JsxAttribute */: - case 275 /* JsxOpeningElement */: - case 276 /* JsxClosingElement */: - case 274 /* JsxSelfClosingElement */: + case 282 /* JsxAttribute */: + case 277 /* JsxOpeningElement */: + case 278 /* JsxClosingElement */: + case 276 /* 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 === 78 /* Identifier */; + return ts.isKeyword(node.kind) || node.kind === 79 /* Identifier */; } } return false; } function shouldRescanJsxText(node) { - var isJSXText = ts.isJsxText(node); - if (isJSXText) { - var containingElement = ts.findAncestor(node.parent, function (p) { return ts.isJsxElement(p); }); - if (!containingElement) - return false; // should never happen - return !ts.isParenthesizedExpression(containingElement.parent); - } - return false; + return ts.isJsxText(node); } function shouldRescanSlashToken(container) { return container.kind === 13 /* RegularExpressionLiteral */; @@ -131607,7 +136452,7 @@ var ts; return node.parent && ts.isJsxAttribute(node.parent) && node.parent.initializer === node; } function startsWithSlashToken(t) { - return t === 43 /* SlashToken */ || t === 67 /* SlashEqualsToken */; + return t === 43 /* SlashToken */ || t === 68 /* SlashEqualsToken */; } function readTokenInfo(n) { ts.Debug.assert(isOnToken()); @@ -131691,7 +136536,7 @@ var ts; return scanner.scanJsxIdentifier(); case 5 /* RescanJsxText */: lastScanAction = 5 /* RescanJsxText */; - return scanner.reScanJsxToken(); + return scanner.reScanJsxToken(/* allowMultilineJsxText */ false); case 6 /* RescanJsxAttributeValue */: lastScanAction = 6 /* RescanJsxAttributeValue */; return scanner.reScanJsxAttributeValue(); @@ -131780,7 +136625,7 @@ var ts; (function (formatting) { function getAllRules() { var allTokens = []; - for (var token = 0 /* FirstToken */; token <= 156 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 158 /* LastToken */; token++) { if (token !== 1 /* EndOfFileToken */) { allTokens.push(token); } @@ -131795,27 +136640,27 @@ var ts; var anyToken = { tokens: allTokens, isSpecific: false }; var anyTokenIncludingMultilineComments = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens), [3 /* MultiLineCommentTrivia */])); var anyTokenIncludingEOF = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens), [1 /* EndOfFileToken */])); - var keywords = tokenRangeFromRange(80 /* FirstKeyword */, 156 /* LastKeyword */); - var binaryOperators = tokenRangeFromRange(29 /* FirstBinaryOperator */, 77 /* LastBinaryOperator */); - var binaryKeywordOperators = [100 /* InKeyword */, 101 /* InstanceOfKeyword */, 156 /* OfKeyword */, 126 /* AsKeyword */, 137 /* IsKeyword */]; + var keywords = tokenRangeFromRange(81 /* FirstKeyword */, 158 /* LastKeyword */); + var binaryOperators = tokenRangeFromRange(29 /* FirstBinaryOperator */, 78 /* LastBinaryOperator */); + var binaryKeywordOperators = [101 /* InKeyword */, 102 /* InstanceOfKeyword */, 158 /* OfKeyword */, 127 /* AsKeyword */, 138 /* IsKeyword */]; var unaryPrefixOperators = [45 /* PlusPlusToken */, 46 /* MinusMinusToken */, 54 /* TildeToken */, 53 /* ExclamationToken */]; var unaryPrefixExpressions = [ - 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 78 /* Identifier */, 20 /* OpenParenToken */, - 22 /* OpenBracketToken */, 18 /* OpenBraceToken */, 107 /* ThisKeyword */, 102 /* NewKeyword */ + 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 79 /* Identifier */, 20 /* OpenParenToken */, + 22 /* OpenBracketToken */, 18 /* OpenBraceToken */, 108 /* ThisKeyword */, 103 /* NewKeyword */ ]; - var unaryPreincrementExpressions = [78 /* Identifier */, 20 /* OpenParenToken */, 107 /* ThisKeyword */, 102 /* NewKeyword */]; - var unaryPostincrementExpressions = [78 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 102 /* NewKeyword */]; - var unaryPredecrementExpressions = [78 /* Identifier */, 20 /* OpenParenToken */, 107 /* ThisKeyword */, 102 /* NewKeyword */]; - var unaryPostdecrementExpressions = [78 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 102 /* 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([78 /* Identifier */], ts.typeKeywords); + var typeNames = __spreadArray([79 /* Identifier */], ts.typeKeywords); // 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([78 /* Identifier */, 3 /* MultiLineCommentTrivia */, 83 /* ClassKeyword */, 92 /* ExportKeyword */, 99 /* ImportKeyword */]); + var typeScriptOpenBraceLeftTokenRange = tokenRangeFrom([79 /* Identifier */, 3 /* MultiLineCommentTrivia */, 84 /* ClassKeyword */, 93 /* ExportKeyword */, 100 /* ImportKeyword */]); // Place a space before open brace in a control flow construct - var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 89 /* DoKeyword */, 110 /* TryKeyword */, 95 /* FinallyKeyword */, 90 /* ElseKeyword */]); + var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 90 /* DoKeyword */, 111 /* TryKeyword */, 96 /* FinallyKeyword */, 91 /* ElseKeyword */]); // These rules are higher in priority than user-configurable var highPriorityCommonRules = [ // Leave comments alone @@ -131830,7 +136675,7 @@ var ts; 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", 99 /* ImportKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 16 /* DeleteSpace */), + rule("NoSpaceBetweenImportParenInImportType", 100 /* ImportKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 16 /* DeleteSpace */), // Special handling of unary operators. // Prefix operators generally shouldn't have a space between // them and their target unary expression. @@ -131857,79 +136702,79 @@ var ts; rule("SpaceAfterCloseBrace", 19 /* CloseBraceToken */, anyTokenExcept(21 /* CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 4 /* 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 */, 90 /* ElseKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBetweenCloseBraceAndWhile", 19 /* CloseBraceToken */, 114 /* WhileKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + 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 */), // 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", 97 /* FunctionKeyword */, 41 /* AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 16 /* DeleteSpace */), - rule("SpaceAfterStarInGeneratorDeclaration", 41 /* AsteriskToken */, 78 /* Identifier */, [isFunctionDeclarationOrFunctionExpressionContext], 4 /* InsertSpace */), - rule("SpaceAfterFunctionInFuncDecl", 97 /* FunctionKeyword */, anyToken, [isFunctionDeclContext], 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 */), // Insert new line after { and before } in multi-line contexts. rule("NewLineAfterOpenBraceInBlockContext", 18 /* OpenBraceToken */, anyToken, [isMultilineBlockContext], 8 /* 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", [134 /* GetKeyword */, 146 /* SetKeyword */], 78 /* Identifier */, [isFunctionDeclContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenYieldKeywordAndStar", 124 /* YieldKeyword */, 41 /* AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 16 /* DeleteSpace */), - rule("SpaceBetweenYieldOrYieldStarAndOperand", [124 /* YieldKeyword */, 41 /* AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 4 /* InsertSpace */), - rule("NoSpaceBetweenReturnAndSemicolon", 104 /* ReturnKeyword */, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("SpaceAfterCertainKeywords", [112 /* VarKeyword */, 108 /* ThrowKeyword */, 102 /* NewKeyword */, 88 /* DeleteKeyword */, 104 /* ReturnKeyword */, 111 /* TypeOfKeyword */, 130 /* AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceAfterLetConstInVariableDeclaration", [118 /* LetKeyword */, 84 /* ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 4 /* InsertSpace */), + rule("SpaceAfterGetSetInMember", [135 /* GetKeyword */, 147 /* 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 */, 131 /* 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 */), // 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", 113 /* VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 4 /* InsertSpace */), + rule("SpaceAfterVoidOperator", 114 /* VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 4 /* InsertSpace */), // Async-await - rule("SpaceBetweenAsyncAndOpenParen", 129 /* AsyncKeyword */, 20 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBetweenAsyncAndFunctionKeyword", 129 /* AsyncKeyword */, [97 /* FunctionKeyword */, 78 /* Identifier */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenAsyncAndOpenParen", 130 /* AsyncKeyword */, 20 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenAsyncAndFunctionKeyword", 130 /* AsyncKeyword */, [98 /* FunctionKeyword */, 79 /* Identifier */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Template string - rule("NoSpaceBetweenTagAndTemplateString", [78 /* Identifier */, 21 /* CloseParenToken */], [14 /* NoSubstitutionTemplateLiteral */, 15 /* TemplateHead */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBetweenTagAndTemplateString", [79 /* Identifier */, 21 /* CloseParenToken */], [14 /* NoSubstitutionTemplateLiteral */, 15 /* TemplateHead */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // JSX opening elements - rule("SpaceBeforeJsxAttribute", anyToken, 78 /* Identifier */, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + 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, 62 /* EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterEqualInJsxAttribute", 62 /* EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeEqualInJsxAttribute", anyToken, 63 /* EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterEqualInJsxAttribute", 63 /* EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // TypeScript-specific rules // Use of module as a function call. e.g.: import m2 = module("m2"); - rule("NoSpaceAfterModuleImport", [139 /* ModuleKeyword */, 143 /* RequireKeyword */], 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterModuleImport", [140 /* ModuleKeyword */, 144 /* RequireKeyword */], 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Add a space around certain TypeScript keywords rule("SpaceAfterCertainTypeScriptKeywords", [ - 125 /* AbstractKeyword */, - 83 /* ClassKeyword */, - 133 /* DeclareKeyword */, - 87 /* DefaultKeyword */, - 91 /* EnumKeyword */, - 92 /* ExportKeyword */, - 93 /* ExtendsKeyword */, - 134 /* GetKeyword */, - 116 /* ImplementsKeyword */, - 99 /* ImportKeyword */, - 117 /* InterfaceKeyword */, - 139 /* ModuleKeyword */, - 140 /* NamespaceKeyword */, - 120 /* PrivateKeyword */, - 122 /* PublicKeyword */, - 121 /* ProtectedKeyword */, - 142 /* ReadonlyKeyword */, - 146 /* SetKeyword */, - 123 /* StaticKeyword */, - 149 /* TypeKeyword */, - 153 /* FromKeyword */, - 138 /* KeyOfKeyword */, - 135 /* InferKeyword */, + 126 /* AbstractKeyword */, + 84 /* ClassKeyword */, + 134 /* DeclareKeyword */, + 88 /* DefaultKeyword */, + 92 /* EnumKeyword */, + 93 /* ExportKeyword */, + 94 /* ExtendsKeyword */, + 135 /* GetKeyword */, + 117 /* ImplementsKeyword */, + 100 /* ImportKeyword */, + 118 /* InterfaceKeyword */, + 140 /* ModuleKeyword */, + 141 /* NamespaceKeyword */, + 121 /* PrivateKeyword */, + 123 /* PublicKeyword */, + 122 /* ProtectedKeyword */, + 143 /* ReadonlyKeyword */, + 147 /* SetKeyword */, + 124 /* StaticKeyword */, + 150 /* TypeKeyword */, + 154 /* FromKeyword */, + 139 /* KeyOfKeyword */, + 136 /* InferKeyword */, ], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [93 /* ExtendsKeyword */, 116 /* ImplementsKeyword */, 153 /* FromKeyword */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [94 /* ExtendsKeyword */, 117 /* ImplementsKeyword */, 154 /* FromKeyword */], [isNonJsxSameLineTokenContext], 4 /* 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 */), // Lambda expressions rule("SpaceBeforeArrow", anyToken, 38 /* EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), rule("SpaceAfterArrow", 38 /* EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Optional parameters and let args - rule("NoSpaceAfterEllipsis", 25 /* DotDotDotToken */, 78 /* Identifier */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterEllipsis", 25 /* DotDotDotToken */, 79 /* Identifier */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), rule("NoSpaceAfterOptionalParameters", 57 /* QuestionToken */, [21 /* CloseParenToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */), // Remove spaces in empty interface literals. e.g.: x: {} rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 16 /* DeleteSpace */), @@ -131940,38 +136785,38 @@ var ts; 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 */), // decorators - rule("SpaceBeforeAt", [21 /* CloseParenToken */, 78 /* Identifier */], 59 /* AtToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeAt", [21 /* CloseParenToken */, 79 /* Identifier */], 59 /* AtToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), rule("NoSpaceAfterAt", 59 /* AtToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Insert space after @ in decorator rule("SpaceAfterDecorator", anyToken, [ - 125 /* AbstractKeyword */, - 78 /* Identifier */, - 92 /* ExportKeyword */, - 87 /* DefaultKeyword */, - 83 /* ClassKeyword */, - 123 /* StaticKeyword */, - 122 /* PublicKeyword */, - 120 /* PrivateKeyword */, - 121 /* ProtectedKeyword */, - 134 /* GetKeyword */, - 146 /* SetKeyword */, + 126 /* AbstractKeyword */, + 79 /* Identifier */, + 93 /* ExportKeyword */, + 88 /* DefaultKeyword */, + 84 /* ClassKeyword */, + 124 /* StaticKeyword */, + 123 /* PublicKeyword */, + 121 /* PrivateKeyword */, + 122 /* ProtectedKeyword */, + 135 /* GetKeyword */, + 147 /* SetKeyword */, 22 /* OpenBracketToken */, 41 /* AsteriskToken */, ], [isEndOfDecoratorContextOnSameLine], 4 /* InsertSpace */), rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 53 /* ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterNewKeywordOnConstructorSignature", 102 /* NewKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterNewKeywordOnConstructorSignature", 103 /* NewKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 16 /* DeleteSpace */), rule("SpaceLessThanAndNonJSXTypeAnnotation", 29 /* LessThanToken */, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext], 4 /* 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", 132 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceAfterConstructor", 132 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterConstructor", 133 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceAfterConstructor", 133 /* 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 */), // Insert space after function keyword for anonymous functions - rule("SpaceAfterAnonymousFunctionKeyword", [97 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 4 /* InsertSpace */), - rule("NoSpaceAfterAnonymousFunctionKeyword", [97 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 16 /* DeleteSpace */), + 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 */), // 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 */), @@ -132040,16 +136885,16 @@ var ts; rule("SpaceBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), rule("NoSpaceBeforeComma", anyToken, 27 /* CommaToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // No space before and after indexer `x[]` - rule("NoSpaceBeforeOpenBracket", anyTokenExcept(129 /* AsyncKeyword */, 81 /* CaseKeyword */), 22 /* OpenBracketToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeOpenBracket", anyTokenExcept(130 /* 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 */), // Remove extra space between for and await - rule("SpaceBetweenForAndAwaitKeyword", 96 /* ForKeyword */, 130 /* AwaitKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenForAndAwaitKeyword", 97 /* ForKeyword */, 131 /* AwaitKeyword */, [isNonJsxSameLineTokenContext], 4 /* 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 */, 89 /* DoKeyword */, 90 /* ElseKeyword */, 81 /* CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 4 /* InsertSpace */), + rule("SpaceBetweenStatements", [21 /* CloseParenToken */, 90 /* DoKeyword */, 91 /* ElseKeyword */, 82 /* CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 4 /* InsertSpace */), // This low-pri rule takes care of "try {", "catch {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. - rule("SpaceAfterTryCatchFinally", [110 /* TryKeyword */, 82 /* CatchKeyword */, 95 /* FinallyKeyword */], 18 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceAfterTryCatchFinally", [111 /* TryKeyword */, 83 /* CatchKeyword */, 96 /* FinallyKeyword */], 18 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), ]; return __spreadArray(__spreadArray(__spreadArray([], highPriorityCommonRules), userConfigurableRules), lowPriorityCommonRules); } @@ -132108,51 +136953,51 @@ var ts; return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; }; } function isForContext(context) { - return context.contextNode.kind === 237 /* ForStatement */; + return context.contextNode.kind === 239 /* ForStatement */; } function isNotForContext(context) { return !isForContext(context); } function isBinaryOpContext(context) { switch (context.contextNode.kind) { - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return context.contextNode.operatorToken.kind !== 27 /* CommaToken */; - case 217 /* ConditionalExpression */: - case 184 /* ConditionalType */: - case 224 /* AsExpression */: - case 270 /* ExportSpecifier */: - case 265 /* ImportSpecifier */: - case 172 /* TypePredicate */: - case 182 /* UnionType */: - case 183 /* IntersectionType */: + case 219 /* ConditionalExpression */: + case 186 /* ConditionalType */: + case 226 /* AsExpression */: + case 272 /* ExportSpecifier */: + case 267 /* ImportSpecifier */: + case 174 /* TypePredicate */: + case 184 /* UnionType */: + case 185 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 198 /* BindingElement */: + case 200 /* BindingElement */: // equals in type X = ... // falls through - case 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: // equal in import a = module('a'); // falls through - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: // equal in let a = 0 // falls through - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: // equal in p = 0 // falls through - case 160 /* Parameter */: - case 291 /* EnumMember */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - return context.currentTokenSpan.kind === 62 /* EqualsToken */ || context.nextTokenSpan.kind === 62 /* EqualsToken */; + case 162 /* Parameter */: + case 293 /* EnumMember */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + return context.currentTokenSpan.kind === 63 /* EqualsToken */ || context.nextTokenSpan.kind === 63 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: // "in" keyword in [P in keyof T]: T[P] // falls through - case 159 /* TypeParameter */: - return context.currentTokenSpan.kind === 100 /* InKeyword */ || context.nextTokenSpan.kind === 100 /* InKeyword */ || context.currentTokenSpan.kind === 62 /* EqualsToken */ || context.nextTokenSpan.kind === 62 /* EqualsToken */; + case 161 /* TypeParameter */: + return context.currentTokenSpan.kind === 101 /* InKeyword */ || context.nextTokenSpan.kind === 101 /* InKeyword */ || context.currentTokenSpan.kind === 63 /* EqualsToken */ || context.nextTokenSpan.kind === 63 /* EqualsToken */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 239 /* ForOfStatement */: - return context.currentTokenSpan.kind === 156 /* OfKeyword */ || context.nextTokenSpan.kind === 156 /* OfKeyword */; + case 241 /* ForOfStatement */: + return context.currentTokenSpan.kind === 158 /* OfKeyword */ || context.nextTokenSpan.kind === 158 /* OfKeyword */; } return false; } @@ -132164,22 +137009,22 @@ var ts; } function isTypeAnnotationContext(context) { var contextKind = context.contextNode.kind; - return contextKind === 163 /* PropertyDeclaration */ || - contextKind === 162 /* PropertySignature */ || - contextKind === 160 /* Parameter */ || - contextKind === 249 /* VariableDeclaration */ || + return contextKind === 165 /* PropertyDeclaration */ || + contextKind === 164 /* PropertySignature */ || + contextKind === 162 /* Parameter */ || + contextKind === 251 /* VariableDeclaration */ || ts.isFunctionLikeKind(contextKind); } function isConditionalOperatorContext(context) { - return context.contextNode.kind === 217 /* ConditionalExpression */ || - context.contextNode.kind === 184 /* ConditionalType */; + return context.contextNode.kind === 219 /* ConditionalExpression */ || + context.contextNode.kind === 186 /* ConditionalType */; } function isSameLineTokenOrBeforeBlockContext(context) { return context.TokensAreOnSameLine() || isBeforeBlockContext(context); } function isBraceWrappedContext(context) { - return context.contextNode.kind === 196 /* ObjectBindingPattern */ || - context.contextNode.kind === 190 /* MappedType */ || + return context.contextNode.kind === 198 /* ObjectBindingPattern */ || + context.contextNode.kind === 192 /* MappedType */ || isSingleLineBlockContext(context); } // This check is done before an open brace in a control construct, a function, or a typescript block declaration @@ -132205,34 +137050,34 @@ var ts; return true; } switch (node.kind) { - case 230 /* Block */: - case 258 /* CaseBlock */: - case 200 /* ObjectLiteralExpression */: - case 257 /* ModuleBlock */: + case 232 /* Block */: + case 260 /* CaseBlock */: + case 202 /* ObjectLiteralExpression */: + case 259 /* ModuleBlock */: return true; } return false; } function isFunctionDeclContext(context) { switch (context.contextNode.kind) { - case 251 /* FunctionDeclaration */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 253 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: // falls through - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: // case SyntaxKind.MethodSignature: // falls through - case 169 /* CallSignature */: - case 208 /* FunctionExpression */: - case 166 /* Constructor */: - case 209 /* ArrowFunction */: + case 171 /* CallSignature */: + case 210 /* FunctionExpression */: + case 168 /* Constructor */: + case 211 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: // falls through - case 253 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one + case 255 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one return true; } return false; @@ -132241,40 +137086,40 @@ var ts; return !isFunctionDeclContext(context); } function isFunctionDeclarationOrFunctionExpressionContext(context) { - return context.contextNode.kind === 251 /* FunctionDeclaration */ || context.contextNode.kind === 208 /* FunctionExpression */; + return context.contextNode.kind === 253 /* FunctionDeclaration */ || context.contextNode.kind === 210 /* FunctionExpression */; } function isTypeScriptDeclWithBlockContext(context) { return nodeIsTypeScriptDeclWithBlockContext(context.contextNode); } function nodeIsTypeScriptDeclWithBlockContext(node) { switch (node.kind) { - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - case 177 /* TypeLiteral */: - case 256 /* ModuleDeclaration */: - case 267 /* ExportDeclaration */: - case 268 /* NamedExports */: - case 261 /* ImportDeclaration */: - case 264 /* NamedImports */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: + case 257 /* EnumDeclaration */: + case 179 /* TypeLiteral */: + case 258 /* ModuleDeclaration */: + case 269 /* ExportDeclaration */: + case 270 /* NamedExports */: + case 263 /* ImportDeclaration */: + case 266 /* NamedImports */: return true; } return false; } function isAfterCodeBlockContext(context) { switch (context.currentTokenParent.kind) { - case 252 /* ClassDeclaration */: - case 256 /* ModuleDeclaration */: - case 255 /* EnumDeclaration */: - case 287 /* CatchClause */: - case 257 /* ModuleBlock */: - case 244 /* SwitchStatement */: + case 254 /* ClassDeclaration */: + case 258 /* ModuleDeclaration */: + case 257 /* EnumDeclaration */: + case 289 /* CatchClause */: + case 259 /* ModuleBlock */: + case 246 /* SwitchStatement */: return true; - case 230 /* Block */: { + case 232 /* 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 !== 209 /* ArrowFunction */ && blockParent.kind !== 208 /* FunctionExpression */) { + if (!blockParent || blockParent.kind !== 211 /* ArrowFunction */ && blockParent.kind !== 210 /* FunctionExpression */) { return true; } } @@ -132283,32 +137128,32 @@ var ts; } function isControlDeclContext(context) { switch (context.contextNode.kind) { - case 234 /* IfStatement */: - case 244 /* SwitchStatement */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 236 /* WhileStatement */: - case 247 /* TryStatement */: - case 235 /* DoStatement */: - case 243 /* WithStatement */: + case 236 /* IfStatement */: + case 246 /* SwitchStatement */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 238 /* WhileStatement */: + case 249 /* TryStatement */: + case 237 /* DoStatement */: + case 245 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: // falls through - case 287 /* CatchClause */: + case 289 /* CatchClause */: return true; default: return false; } } function isObjectContext(context) { - return context.contextNode.kind === 200 /* ObjectLiteralExpression */; + return context.contextNode.kind === 202 /* ObjectLiteralExpression */; } function isFunctionCallContext(context) { - return context.contextNode.kind === 203 /* CallExpression */; + return context.contextNode.kind === 205 /* CallExpression */; } function isNewContext(context) { - return context.contextNode.kind === 204 /* NewExpression */; + return context.contextNode.kind === 206 /* NewExpression */; } function isFunctionCallOrNewContext(context) { return isFunctionCallContext(context) || isNewContext(context); @@ -132323,10 +137168,10 @@ var ts; return context.nextTokenSpan.kind !== 21 /* CloseParenToken */; } function isArrowFunctionContext(context) { - return context.contextNode.kind === 209 /* ArrowFunction */; + return context.contextNode.kind === 211 /* ArrowFunction */; } function isImportTypeContext(context) { - return context.contextNode.kind === 195 /* ImportType */; + return context.contextNode.kind === 197 /* ImportType */; } function isNonJsxSameLineTokenContext(context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 11 /* JsxText */; @@ -132335,19 +137180,19 @@ var ts; return context.contextNode.kind !== 11 /* JsxText */; } function isNonJsxElementOrFragmentContext(context) { - return context.contextNode.kind !== 273 /* JsxElement */ && context.contextNode.kind !== 277 /* JsxFragment */; + return context.contextNode.kind !== 275 /* JsxElement */ && context.contextNode.kind !== 279 /* JsxFragment */; } function isJsxExpressionContext(context) { - return context.contextNode.kind === 283 /* JsxExpression */ || context.contextNode.kind === 282 /* JsxSpreadAttribute */; + return context.contextNode.kind === 285 /* JsxExpression */ || context.contextNode.kind === 284 /* JsxSpreadAttribute */; } function isNextTokenParentJsxAttribute(context) { - return context.nextTokenParent.kind === 280 /* JsxAttribute */; + return context.nextTokenParent.kind === 282 /* JsxAttribute */; } function isJsxAttributeContext(context) { - return context.contextNode.kind === 280 /* JsxAttribute */; + return context.contextNode.kind === 282 /* JsxAttribute */; } function isJsxSelfClosingElementContext(context) { - return context.contextNode.kind === 274 /* JsxSelfClosingElement */; + return context.contextNode.kind === 276 /* JsxSelfClosingElement */; } function isNotBeforeBlockInFunctionDeclarationContext(context) { return !isFunctionDeclContext(context) && !isBeforeBlockContext(context); @@ -132362,45 +137207,45 @@ var ts; while (ts.isExpressionNode(node)) { node = node.parent; } - return node.kind === 161 /* Decorator */; + return node.kind === 163 /* Decorator */; } function isStartOfVariableDeclarationList(context) { - return context.currentTokenParent.kind === 250 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 252 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; } function isNotFormatOnEnter(context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; } function isModuleDeclContext(context) { - return context.contextNode.kind === 256 /* ModuleDeclaration */; + return context.contextNode.kind === 258 /* ModuleDeclaration */; } function isObjectTypeContext(context) { - return context.contextNode.kind === 177 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 179 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; } function isConstructorSignatureContext(context) { - return context.contextNode.kind === 170 /* ConstructSignature */; + return context.contextNode.kind === 172 /* ConstructSignature */; } function isTypeArgumentOrParameterOrAssertion(token, parent) { if (token.kind !== 29 /* LessThanToken */ && token.kind !== 31 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 173 /* TypeReference */: - case 206 /* TypeAssertionExpression */: - case 254 /* TypeAliasDeclaration */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 203 /* CallExpression */: - case 204 /* NewExpression */: - case 223 /* ExpressionWithTypeArguments */: + case 175 /* TypeReference */: + case 208 /* TypeAssertionExpression */: + case 256 /* TypeAliasDeclaration */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: + case 225 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -132411,28 +137256,28 @@ var ts; isTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); } function isTypeAssertionContext(context) { - return context.contextNode.kind === 206 /* TypeAssertionExpression */; + return context.contextNode.kind === 208 /* TypeAssertionExpression */; } function isVoidOpContext(context) { - return context.currentTokenSpan.kind === 113 /* VoidKeyword */ && context.currentTokenParent.kind === 212 /* VoidExpression */; + return context.currentTokenSpan.kind === 114 /* VoidKeyword */ && context.currentTokenParent.kind === 214 /* VoidExpression */; } function isYieldOrYieldStarWithOperand(context) { - return context.contextNode.kind === 219 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 221 /* YieldExpression */ && context.contextNode.expression !== undefined; } function isNonNullAssertionContext(context) { - return context.contextNode.kind === 225 /* NonNullExpression */; + return context.contextNode.kind === 227 /* NonNullExpression */; } function isNotStatementConditionContext(context) { return !isStatementConditionContext(context); } function isStatementConditionContext(context) { switch (context.contextNode.kind) { - case 234 /* IfStatement */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: + case 236 /* IfStatement */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: return true; default: return false; @@ -132457,12 +137302,12 @@ var ts; return nextTokenKind === 19 /* CloseBraceToken */ || nextTokenKind === 1 /* EndOfFileToken */; } - if (nextTokenKind === 229 /* SemicolonClassElement */ || + if (nextTokenKind === 231 /* SemicolonClassElement */ || nextTokenKind === 26 /* SemicolonToken */) { return false; } - if (context.contextNode.kind === 253 /* InterfaceDeclaration */ || - context.contextNode.kind === 254 /* TypeAliasDeclaration */) { + if (context.contextNode.kind === 255 /* InterfaceDeclaration */ || + context.contextNode.kind === 256 /* TypeAliasDeclaration */) { // Can’t remove semicolon after `foo`; it would parse as a method declaration: // // interface I { @@ -132476,9 +137321,9 @@ var ts; if (ts.isPropertyDeclaration(context.currentTokenParent)) { return !context.currentTokenParent.initializer; } - return context.currentTokenParent.kind !== 237 /* ForStatement */ - && context.currentTokenParent.kind !== 231 /* EmptyStatement */ - && context.currentTokenParent.kind !== 229 /* SemicolonClassElement */ + return context.currentTokenParent.kind !== 239 /* ForStatement */ + && context.currentTokenParent.kind !== 233 /* EmptyStatement */ + && context.currentTokenParent.kind !== 231 /* SemicolonClassElement */ && nextTokenKind !== 22 /* OpenBracketToken */ && nextTokenKind !== 20 /* OpenParenToken */ && nextTokenKind !== 39 /* PlusToken */ @@ -132486,7 +137331,7 @@ var ts; && nextTokenKind !== 43 /* SlashToken */ && nextTokenKind !== 13 /* RegularExpressionLiteral */ && nextTokenKind !== 27 /* CommaToken */ - && nextTokenKind !== 218 /* TemplateExpression */ + && nextTokenKind !== 220 /* TemplateExpression */ && nextTokenKind !== 15 /* TemplateHead */ && nextTokenKind !== 14 /* NoSubstitutionTemplateLiteral */ && nextTokenKind !== 24 /* DotToken */; @@ -132577,12 +137422,12 @@ var ts; return map; } function getRuleBucketIndex(row, column) { - ts.Debug.assert(row <= 156 /* LastKeyword */ && column <= 156 /* LastKeyword */, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 158 /* LastKeyword */ && column <= 158 /* LastKeyword */, "Must compute formatting context from tokens"); return (row * mapRowLength) + column; } var maskBitSize = 5; var mask = 31; // MaskBitSize bits - var mapRowLength = 156 /* LastToken */ + 1; + var mapRowLength = 158 /* LastToken */ + 1; var RulesPosition; (function (RulesPosition) { RulesPosition[RulesPosition["StopRulesSpecific"] = 0] = "StopRulesSpecific"; @@ -132770,17 +137615,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 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: var body = parent.body; - return !!body && body.kind === 257 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 297 /* SourceFile */: - case 230 /* Block */: - case 257 /* ModuleBlock */: + return !!body && body.kind === 259 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 299 /* SourceFile */: + case 232 /* Block */: + case 259 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -132934,14 +137779,17 @@ var ts; processNode(enclosingNode, enclosingNode, startLine, undecoratedStartLine, initialIndentation, delta); } if (!formattingScanner.isOnToken()) { + var indentation = formatting.SmartIndenter.nodeWillIndentChild(options, enclosingNode, /*child*/ undefined, sourceFile, /*indentByDefault*/ false) + ? initialIndentation + options.indentSize + : initialIndentation; var leadingTrivia = formattingScanner.getCurrentLeadingTrivia(); if (leadingTrivia) { - indentTriviaItems(leadingTrivia, initialIndentation, /*indentNextTokenOrTrivia*/ false, function (item) { return processRange(item, sourceFile.getLineAndCharacterOfPosition(item.pos), enclosingNode, enclosingNode, /*dynamicIndentation*/ undefined); }); - if (options.trimTrailingWhitespace !== false) { - trimTrailingWhitespacesForRemainingRange(); - } + indentTriviaItems(leadingTrivia, indentation, /*indentNextTokenOrTrivia*/ false, function (item) { return processRange(item, sourceFile.getLineAndCharacterOfPosition(item.pos), enclosingNode, enclosingNode, /*dynamicIndentation*/ undefined); }); } } + if (options.trimTrailingWhitespace !== false) { + trimTrailingWhitespacesForRemainingRange(); + } return edits; // local functions /** Tries to compute the indentation for a list element. @@ -132988,10 +137836,9 @@ var ts; // - we need to get the indentation on last line and the delta of parent return { indentation: indentationOnLastIndentedLine, delta: parentDynamicIndentation.getDelta(node) }; } - else if (formatting.SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement(parent, node, startLine, sourceFile)) { - return { indentation: parentDynamicIndentation.getIndentation(), delta: delta }; - } - else if (formatting.SmartIndenter.argumentStartsOnSameLineAsPreviousArgument(parent, node, startLine, sourceFile)) { + else if (formatting.SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement(parent, node, startLine, sourceFile) || + formatting.SmartIndenter.childIsUnindentedBranchOfConditionalExpression(parent, node, startLine, sourceFile) || + formatting.SmartIndenter.argumentStartsOnSameLineAsPreviousArgument(parent, node, startLine, sourceFile)) { return { indentation: parentDynamicIndentation.getIndentation(), delta: delta }; } else { @@ -133007,19 +137854,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 252 /* ClassDeclaration */: return 83 /* ClassKeyword */; - case 253 /* InterfaceDeclaration */: return 117 /* InterfaceKeyword */; - case 251 /* FunctionDeclaration */: return 97 /* FunctionKeyword */; - case 255 /* EnumDeclaration */: return 255 /* EnumDeclaration */; - case 167 /* GetAccessor */: return 134 /* GetKeyword */; - case 168 /* SetAccessor */: return 146 /* SetKeyword */; - case 165 /* MethodDeclaration */: + case 254 /* ClassDeclaration */: return 84 /* ClassKeyword */; + case 255 /* InterfaceDeclaration */: return 118 /* InterfaceKeyword */; + case 253 /* FunctionDeclaration */: return 98 /* FunctionKeyword */; + case 257 /* EnumDeclaration */: return 257 /* EnumDeclaration */; + case 169 /* GetAccessor */: return 135 /* GetKeyword */; + case 170 /* SetAccessor */: return 147 /* SetKeyword */; + case 167 /* MethodDeclaration */: if (node.asteriskToken) { return 41 /* AsteriskToken */; } // falls through - case 163 /* PropertyDeclaration */: - case 160 /* Parameter */: + case 165 /* PropertyDeclaration */: + case 162 /* Parameter */: var name = ts.getNameOfDeclaration(node); if (name) { return name.kind; @@ -133069,22 +137916,23 @@ var ts; case 18 /* OpenBraceToken */: case 19 /* CloseBraceToken */: case 21 /* CloseParenToken */: - case 90 /* ElseKeyword */: - case 114 /* WhileKeyword */: + case 91 /* ElseKeyword */: + case 115 /* WhileKeyword */: case 59 /* AtToken */: return false; case 43 /* SlashToken */: case 31 /* GreaterThanToken */: switch (container.kind) { - case 275 /* JsxOpeningElement */: - case 276 /* JsxClosingElement */: - case 274 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: + case 278 /* JsxClosingElement */: + case 276 /* JsxSelfClosingElement */: + case 225 /* ExpressionWithTypeArguments */: return false; } break; case 22 /* OpenBracketToken */: case 23 /* CloseBracketToken */: - if (container.kind !== 190 /* MappedType */) { + if (container.kind !== 192 /* MappedType */) { return false; } break; @@ -133129,11 +137977,6 @@ var ts; if (tokenInfo.token.end > node.end) { break; } - if (node.kind === 11 /* JsxText */) { - // Intentation rules for jsx text are handled by `indentMultilineCommentOrJsxText` inside `processChildNode`; just fastforward past it here - formattingScanner.advance(); - continue; - } consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation, node); } if (!node.parent && formattingScanner.isOnEOF()) { @@ -133192,27 +138035,11 @@ var ts; return inheritedIndentation; } } - var effectiveParentStartLine = child.kind === 161 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 163 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); - if (child.kind === 11 /* JsxText */) { - var range = { pos: child.getStart(), end: child.getEnd() }; - if (range.pos !== range.end) { // don't indent zero-width jsx text - var siblings = parent.getChildren(sourceFile); - var currentIndex = ts.findIndex(siblings, function (arg) { return arg.pos === child.pos; }); - var previousNode = siblings[currentIndex - 1]; - if (previousNode) { - // The jsx text needs no indentation whatsoever if it ends on the same line the previous sibling ends on - if (sourceFile.getLineAndCharacterOfPosition(range.end).line !== sourceFile.getLineAndCharacterOfPosition(previousNode.end).line) { - // The first line is (already) "indented" if the text starts on the same line as the previous sibling element ends on - var firstLineIsIndented = sourceFile.getLineAndCharacterOfPosition(range.pos).line === sourceFile.getLineAndCharacterOfPosition(previousNode.end).line; - indentMultilineCommentOrJsxText(range, childIndentation.indentation, firstLineIsIndented, /*indentFinalLine*/ false, /*jsxStyle*/ true); - } - } - } - } childContextNode = node; - if (isFirstListItem && parent.kind === 199 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 201 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -133336,7 +138163,7 @@ var ts; switch (triviaItem.kind) { case 3 /* MultiLineCommentTrivia */: if (triviaInRange) { - indentMultilineCommentOrJsxText(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia); + indentMultilineComment(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia); } indentNextTokenOrTrivia = false; break; @@ -133453,7 +138280,7 @@ var ts; function indentationIsDifferent(indentationString, startLinePosition) { return indentationString !== sourceFile.text.substr(startLinePosition, indentationString.length); } - function indentMultilineCommentOrJsxText(commentRange, indentation, firstLineIsIndented, indentFinalLine, jsxTextStyleIndent) { + function indentMultilineComment(commentRange, indentation, firstLineIsIndented, indentFinalLine) { if (indentFinalLine === void 0) { indentFinalLine = true; } // split comment in lines var startLine = sourceFile.getLineAndCharacterOfPosition(commentRange.pos).line; @@ -133491,13 +138318,6 @@ var ts; var nonWhitespaceCharacterAndColumn = i === 0 ? nonWhitespaceColumnInFirstPart : formatting.SmartIndenter.findFirstNonWhitespaceCharacterAndColumn(parts[i].pos, parts[i].end, sourceFile, options); - if (jsxTextStyleIndent) { - // skip adding indentation to blank lines - if (ts.isLineBreak(sourceFile.text.charCodeAt(ts.getStartPositionOfLine(startLine, sourceFile)))) - continue; - // reset delta on every line - delta = indentation - nonWhitespaceCharacterAndColumn.column; - } var newIndentation = nonWhitespaceCharacterAndColumn.column + delta; if (newIndentation > 0) { var indentationString = getIndentationString(newIndentation, options); @@ -133652,12 +138472,12 @@ var ts; formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment; function getOpenTokenForList(node, list) { switch (node.kind) { - case 166 /* Constructor */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 209 /* ArrowFunction */: + case 168 /* Constructor */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 211 /* ArrowFunction */: if (node.typeParameters === list) { return 29 /* LessThanToken */; } @@ -133665,8 +138485,8 @@ var ts; return 20 /* OpenParenToken */; } break; - case 203 /* CallExpression */: - case 204 /* NewExpression */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: if (node.typeArguments === list) { return 29 /* LessThanToken */; } @@ -133674,12 +138494,12 @@ var ts; return 20 /* OpenParenToken */; } break; - case 173 /* TypeReference */: + case 175 /* TypeReference */: if (node.typeArguments === list) { return 29 /* LessThanToken */; } break; - case 177 /* TypeLiteral */: + case 179 /* TypeLiteral */: return 18 /* OpenBraceToken */; } return 0 /* Unknown */; @@ -133797,7 +138617,7 @@ var ts; if (options.indentStyle === ts.IndentStyle.Block) { return getBlockIndent(sourceFile, position, options); } - if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 216 /* BinaryExpression */) { + if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 218 /* 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 */) { @@ -133880,6 +138700,7 @@ var ts; } SmartIndenter.getBaseIndentation = getBaseIndentation; function getIndentationForNodeWorker(current, currentStart, ignoreActualIndentationRange, indentationDelta, sourceFile, isNextChild, options) { + var _a; var parent = current.parent; // Walk up the tree and collect indentation for parent-child node pairs. Indentation is not added if // * parent and child nodes start on the same line, or @@ -133895,7 +138716,25 @@ var ts; childStartsOnTheSameLineWithElseInIfStatement(parent, current, currentStart.line, sourceFile); if (useActualIndentation) { // check if current node is a list item - if yes, take indentation from it - var actualIndentation = getActualIndentationForListItem(current, sourceFile, options, !parentAndChildShareLine); + var firstListChild = (_a = getContainingList(current, sourceFile)) === null || _a === void 0 ? void 0 : _a[0]; + // A list indents its children if the children begin on a later line than the list itself: + // + // f1( L0 - List start + // { L1 - First child start: indented, along with all other children + // prop: 0 + // }, + // { + // prop: 1 + // } + // ) + // + // f2({ L0 - List start and first child start: children are not indented. + // prop: 0 Object properties are indented only one level, because the list + // }, { itself contributes nothing. + // prop: 1 L3 - The indentation of the second object literal is best understood by + // }) 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 */) { return actualIndentation + indentationDelta; } @@ -133951,7 +138790,7 @@ 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 === 297 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 299 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -133999,8 +138838,8 @@ var ts; } SmartIndenter.isArgumentAndStartLineOverlapsExpressionBeingCalled = isArgumentAndStartLineOverlapsExpressionBeingCalled; function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 234 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 90 /* ElseKeyword */, sourceFile); + if (parent.kind === 236 /* IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 91 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -134008,6 +138847,49 @@ var ts; return false; } SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement = childStartsOnTheSameLineWithElseInIfStatement; + // A multiline conditional typically increases the indentation of its whenTrue and whenFalse children: + // + // condition + // ? whenTrue + // : whenFalse; + // + // However, that indentation does not apply if the subexpressions themselves span multiple lines, + // applying their own indentation: + // + // (() => { + // return complexCalculationForCondition(); + // })() ? { + // whenTrue: 'multiline object literal' + // } : ( + // whenFalse('multiline parenthesized expression') + // ); + // + // In these cases, we must discard the indentation increase that would otherwise be applied to the + // whenTrue and whenFalse children to avoid double-indenting their contents. To identify this scenario, + // we check for the whenTrue branch beginning on the line that the condition ends, and the whenFalse + // branch beginning on the line that the whenTrue branch ends. + function childIsUnindentedBranchOfConditionalExpression(parent, child, childStartLine, sourceFile) { + if (ts.isConditionalExpression(parent) && (child === parent.whenTrue || child === parent.whenFalse)) { + var conditionEndLine = ts.getLineAndCharacterOfPosition(sourceFile, parent.condition.end).line; + if (child === parent.whenTrue) { + return childStartLine === conditionEndLine; + } + else { + // On the whenFalse side, we have to look at the whenTrue side, because if that one was + // indented, whenFalse must also be indented: + // + // const y = true + // ? 1 : ( L1: whenTrue indented because it's on a new line + // 0 L2: indented two stops, one because whenTrue was indented + // ); and one because of the parentheses spanning multiple lines + var trueStartLine = getStartLineAndCharacterForNode(parent.whenTrue, sourceFile).line; + var trueEndLine = ts.getLineAndCharacterOfPosition(sourceFile, parent.whenTrue.end).line; + return conditionEndLine === trueStartLine && trueEndLine === childStartLine; + } + } + return false; + } + SmartIndenter.childIsUnindentedBranchOfConditionalExpression = childIsUnindentedBranchOfConditionalExpression; function argumentStartsOnSameLineAsPreviousArgument(parent, child, childStartLine, sourceFile) { if (ts.isCallOrNewExpression(parent)) { if (!parent.arguments) @@ -134037,40 +138919,40 @@ var ts; } function getListByRange(start, end, node, sourceFile) { switch (node.kind) { - case 173 /* TypeReference */: + case 175 /* TypeReference */: return getList(node.typeArguments); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return getList(node.properties); - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return getList(node.elements); - case 177 /* TypeLiteral */: + case 179 /* TypeLiteral */: return getList(node.members); - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 169 /* CallSignature */: - case 166 /* Constructor */: - case 175 /* ConstructorType */: - case 170 /* ConstructSignature */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 171 /* CallSignature */: + case 168 /* Constructor */: + case 177 /* ConstructorType */: + case 172 /* ConstructSignature */: return getList(node.typeParameters) || getList(node.parameters); - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 330 /* JSDocTemplateTag */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 338 /* JSDocTemplateTag */: return getList(node.typeParameters); - case 204 /* NewExpression */: - case 203 /* CallExpression */: + case 206 /* NewExpression */: + case 205 /* CallExpression */: return getList(node.typeArguments) || getList(node.arguments); - case 250 /* VariableDeclarationList */: + case 252 /* VariableDeclarationList */: return getList(node.declarations); - case 264 /* NamedImports */: - case 268 /* NamedExports */: + case 266 /* NamedImports */: + case 270 /* NamedExports */: return getList(node.elements); - case 196 /* ObjectBindingPattern */: - case 197 /* ArrayBindingPattern */: + case 198 /* ObjectBindingPattern */: + case 199 /* ArrayBindingPattern */: return getList(node.elements); } function getList(list) { @@ -134093,7 +138975,7 @@ var ts; return findColumnForFirstNonWhitespaceCharacterInLine(sourceFile.getLineAndCharacterOfPosition(list.pos), sourceFile, options); } function getActualIndentationForListItem(node, sourceFile, options, listIndentsChild) { - if (node.parent && node.parent.kind === 250 /* VariableDeclarationList */) { + if (node.parent && node.parent.kind === 252 /* VariableDeclarationList */) { // VariableDeclarationList has no wrapping tokens return -1 /* Unknown */; } @@ -134166,94 +139048,94 @@ var ts; function nodeWillIndentChild(settings, parent, child, sourceFile, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 233 /* ExpressionStatement */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 199 /* ArrayLiteralExpression */: - case 230 /* Block */: - case 257 /* ModuleBlock */: - case 200 /* ObjectLiteralExpression */: - case 177 /* TypeLiteral */: - case 190 /* MappedType */: - case 179 /* TupleType */: - case 258 /* CaseBlock */: - case 285 /* DefaultClause */: - case 284 /* CaseClause */: - case 207 /* ParenthesizedExpression */: - case 201 /* PropertyAccessExpression */: - case 203 /* CallExpression */: - case 204 /* NewExpression */: - case 232 /* VariableStatement */: - case 266 /* ExportAssignment */: - case 242 /* ReturnStatement */: - case 217 /* ConditionalExpression */: - case 197 /* ArrayBindingPattern */: - case 196 /* ObjectBindingPattern */: - case 275 /* JsxOpeningElement */: - case 278 /* JsxOpeningFragment */: - case 274 /* JsxSelfClosingElement */: - case 283 /* JsxExpression */: - case 164 /* MethodSignature */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 160 /* Parameter */: - case 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 186 /* ParenthesizedType */: - case 205 /* TaggedTemplateExpression */: - case 213 /* AwaitExpression */: - case 268 /* NamedExports */: - case 264 /* NamedImports */: - case 270 /* ExportSpecifier */: - case 265 /* ImportSpecifier */: - case 163 /* PropertyDeclaration */: + case 235 /* ExpressionStatement */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: + case 257 /* EnumDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 201 /* ArrayLiteralExpression */: + case 232 /* Block */: + case 259 /* ModuleBlock */: + case 202 /* ObjectLiteralExpression */: + case 179 /* TypeLiteral */: + case 192 /* MappedType */: + case 181 /* TupleType */: + case 260 /* CaseBlock */: + case 287 /* DefaultClause */: + case 286 /* CaseClause */: + case 209 /* ParenthesizedExpression */: + case 203 /* PropertyAccessExpression */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: + case 234 /* VariableStatement */: + case 268 /* ExportAssignment */: + case 244 /* ReturnStatement */: + case 219 /* ConditionalExpression */: + case 199 /* ArrayBindingPattern */: + case 198 /* ObjectBindingPattern */: + case 277 /* JsxOpeningElement */: + case 280 /* JsxOpeningFragment */: + case 276 /* JsxSelfClosingElement */: + case 285 /* JsxExpression */: + case 166 /* MethodSignature */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 162 /* Parameter */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: + case 188 /* ParenthesizedType */: + case 207 /* TaggedTemplateExpression */: + case 215 /* AwaitExpression */: + case 270 /* NamedExports */: + case 266 /* NamedImports */: + case 272 /* ExportSpecifier */: + case 267 /* ImportSpecifier */: + case 165 /* PropertyDeclaration */: return true; - case 249 /* VariableDeclaration */: - case 288 /* PropertyAssignment */: - case 216 /* BinaryExpression */: - if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 200 /* ObjectLiteralExpression */) { // TODO: GH#18217 + case 251 /* VariableDeclaration */: + case 290 /* PropertyAssignment */: + case 218 /* BinaryExpression */: + if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 202 /* ObjectLiteralExpression */) { // TODO: GH#18217 return rangeIsOnOneLine(sourceFile, child); } - if (parent.kind !== 216 /* BinaryExpression */) { + if (parent.kind !== 218 /* BinaryExpression */) { return true; } break; - case 235 /* DoStatement */: - case 236 /* WhileStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 237 /* ForStatement */: - case 234 /* IfStatement */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - return childKind !== 230 /* Block */; - case 209 /* ArrowFunction */: - if (sourceFile && childKind === 207 /* ParenthesizedExpression */) { + case 237 /* DoStatement */: + case 238 /* WhileStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 239 /* ForStatement */: + case 236 /* IfStatement */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 167 /* MethodDeclaration */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + return childKind !== 232 /* Block */; + case 211 /* ArrowFunction */: + if (sourceFile && childKind === 209 /* ParenthesizedExpression */) { return rangeIsOnOneLine(sourceFile, child); } - return childKind !== 230 /* Block */; - case 267 /* ExportDeclaration */: - return childKind !== 268 /* NamedExports */; - case 261 /* ImportDeclaration */: - return childKind !== 262 /* ImportClause */ || - (!!child.namedBindings && child.namedBindings.kind !== 264 /* NamedImports */); - case 273 /* JsxElement */: - return childKind !== 276 /* JsxClosingElement */; - case 277 /* JsxFragment */: - return childKind !== 279 /* JsxClosingFragment */; - case 183 /* IntersectionType */: - case 182 /* UnionType */: - if (childKind === 177 /* TypeLiteral */ || childKind === 179 /* TupleType */) { + return childKind !== 232 /* Block */; + case 269 /* ExportDeclaration */: + return childKind !== 270 /* NamedExports */; + case 263 /* ImportDeclaration */: + return childKind !== 264 /* ImportClause */ || + (!!child.namedBindings && child.namedBindings.kind !== 266 /* NamedImports */); + case 275 /* JsxElement */: + return childKind !== 278 /* JsxClosingElement */; + case 279 /* JsxFragment */: + return childKind !== 281 /* JsxClosingFragment */; + case 185 /* IntersectionType */: + case 184 /* UnionType */: + if (childKind === 179 /* TypeLiteral */ || childKind === 181 /* TupleType */) { return false; } - // falls through + break; } // No explicit rule for given nodes so the result will follow the default value argument return indentByDefault; @@ -134261,11 +139143,11 @@ var ts; SmartIndenter.nodeWillIndentChild = nodeWillIndentChild; function isControlFlowEndingStatement(kind, parent) { switch (kind) { - case 242 /* ReturnStatement */: - case 246 /* ThrowStatement */: - case 240 /* ContinueStatement */: - case 241 /* BreakStatement */: - return parent.kind !== 230 /* Block */; + case 244 /* ReturnStatement */: + case 248 /* ThrowStatement */: + case 242 /* ContinueStatement */: + case 243 /* BreakStatement */: + return parent.kind !== 232 /* Block */; default: return false; } @@ -134373,7 +139255,9 @@ var ts; function getAdjustedRange(sourceFile, startNode, endNode, options) { return { pos: getAdjustedStartPosition(sourceFile, startNode, options), end: getAdjustedEndPosition(sourceFile, endNode, options) }; } - function getAdjustedStartPosition(sourceFile, node, options) { + function getAdjustedStartPosition(sourceFile, node, options, hasTrailingComment) { + var _a, _b; + if (hasTrailingComment === void 0) { hasTrailingComment = false; } var leadingTriviaOption = options.leadingTriviaOption; if (leadingTriviaOption === LeadingTriviaOption.Exclude) { return node.getStart(sourceFile); @@ -134404,6 +139288,15 @@ var ts; // when b is deleted - we delete it return leadingTriviaOption === LeadingTriviaOption.IncludeAll ? fullStart : start; } + // if node has a trailing comments, use comment end position as the text has already been included. + if (hasTrailingComment) { + // Check first for leading comments as if the node is the first import, we want to exclude the trivia; + // otherwise we get the trailing comments. + var comment = ((_a = ts.getLeadingCommentRanges(sourceFile.text, fullStart)) === null || _a === void 0 ? void 0 : _a[0]) || ((_b = ts.getTrailingCommentRanges(sourceFile.text, fullStart)) === null || _b === void 0 ? void 0 : _b[0]); + if (comment) { + return ts.skipTrivia(sourceFile.text, comment.end, /*stopAfterLineBreak*/ true, /*stopAtComments*/ true); + } + } // get start position of the line following the line that contains fullstart position // (but only if the fullstart isn't the very beginning of the file) var nextLineStart = fullStart > 0 ? 1 : 0; @@ -134412,6 +139305,35 @@ var ts; adjustedStartPosition = skipWhitespacesAndLineBreaks(sourceFile.text, adjustedStartPosition); return ts.getStartPositionOfLine(ts.getLineOfLocalPosition(sourceFile, adjustedStartPosition), sourceFile); } + /** Return the end position of a multiline comment of it is on another line; otherwise returns `undefined`; */ + function getEndPositionOfMultilineTrailingComment(sourceFile, node, options) { + var end = node.end; + var trailingTriviaOption = options.trailingTriviaOption; + if (trailingTriviaOption === TrailingTriviaOption.Include) { + // If the trailing comment is a multiline comment that extends to the next lines, + // return the end of the comment and track it for the next nodes to adjust. + var comments = ts.getTrailingCommentRanges(sourceFile.text, end); + if (comments) { + var nodeEndLine = ts.getLineOfLocalPosition(sourceFile, node.end); + for (var _i = 0, comments_2 = comments; _i < comments_2.length; _i++) { + 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) { + break; + } + // Get the end line of the comment and compare against the end line of the node. + // If the comment end line position and the multiline comment extends to multiple lines, + // then is safe to return the end position. + var commentEndLine = ts.getLineOfLocalPosition(sourceFile, comment.end); + if (commentEndLine > nodeEndLine) { + return ts.skipTrivia(sourceFile.text, comment.end, /*stopAfterLineBreak*/ true, /*stopAtComments*/ true); + } + } + } + } + return undefined; + } function getAdjustedEndPosition(sourceFile, node, options) { var _a; var end = node.end; @@ -134427,6 +139349,10 @@ var ts; } return end; } + var multilineEndPosition = getEndPositionOfMultilineTrailingComment(sourceFile, node, options); + if (multilineEndPosition) { + return multilineEndPosition; + } var newEnd = ts.skipTrivia(sourceFile.text, end, /*stopAfterLineBreak*/ true); return newEnd !== end && (trailingTriviaOption === TrailingTriviaOption.Include || ts.isLineBreak(sourceFile.text.charCodeAt(newEnd - 1))) ? newEnd @@ -134436,14 +139362,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 === 200 /* ObjectLiteralExpression */)); - } - function spaces(count) { - var s = ""; - for (var i = 0; i < count; i++) { - s += " "; - } - return s; + return !!candidate && !!node.parent && (candidate.kind === 27 /* CommaToken */ || (candidate.kind === 26 /* SemicolonToken */ && node.parent.kind === 202 /* ObjectLiteralExpression */)); } function isThisTypeAnnotatable(containingFunction) { return ts.isFunctionExpression(containingFunction) || ts.isFunctionDeclaration(containingFunction); @@ -134489,6 +139408,17 @@ var ts; if (options === void 0) { options = { leadingTriviaOption: LeadingTriviaOption.IncludeAll }; } this.deleteRange(sourceFile, getAdjustedRange(sourceFile, node, node, options)); }; + ChangeTracker.prototype.deleteNodes = function (sourceFile, nodes, options, hasTrailingComment) { + if (options === void 0) { options = { leadingTriviaOption: LeadingTriviaOption.IncludeAll }; } + // When deleting multiple nodes we need to track if the end position is including multiline trailing comments. + for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { + var node = nodes_1[_i]; + var pos = getAdjustedStartPosition(sourceFile, node, options, hasTrailingComment); + var end = getAdjustedEndPosition(sourceFile, node, options); + this.deleteRange(sourceFile, { pos: pos, end: end }); + hasTrailingComment = !!getEndPositionOfMultilineTrailingComment(sourceFile, node, options); + } + }; ChangeTracker.prototype.deleteModifier = function (sourceFile, modifier) { this.deleteRange(sourceFile, { pos: modifier.getStart(sourceFile), end: ts.skipTrivia(sourceFile.text, modifier.end, /*stopAfterLineBreak*/ true) }); }; @@ -134531,6 +139461,10 @@ var ts; if (options === void 0) { options = useNonAdjustedPositions; } this.replaceRangeWithNodes(sourceFile, getAdjustedRange(sourceFile, startNode, endNode, options), newNodes, options); }; + ChangeTracker.prototype.nodeHasTrailingComment = function (sourceFile, oldNode, configurableEnd) { + if (configurableEnd === void 0) { configurableEnd = useNonAdjustedPositions; } + return !!getEndPositionOfMultilineTrailingComment(sourceFile, oldNode, configurableEnd); + }; ChangeTracker.prototype.nextCommaToken = function (sourceFile, node) { var next = ts.findNextToken(node, node.parent, sourceFile); return next && next.kind === 27 /* CommaToken */ ? next : undefined; @@ -134635,7 +139569,7 @@ var ts; } } else { - endNode = (_a = (node.kind === 249 /* VariableDeclaration */ ? node.exclamationToken : node.questionToken)) !== null && _a !== void 0 ? _a : node.name; + endNode = (_a = (node.kind === 251 /* VariableDeclaration */ ? node.exclamationToken : node.questionToken)) !== null && _a !== void 0 ? _a : node.name; } this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " }); return true; @@ -134677,6 +139611,15 @@ var ts; this.insertNodeBefore(sourceFile, firstStatement, newStatement); } }; + ChangeTracker.prototype.insertNodeAtConstructorStartAfterSuperCall = function (sourceFile, ctr, newStatement) { + var superCallStatement = ts.find(ctr.body.statements, function (stmt) { return ts.isExpressionStatement(stmt) && ts.isSuperCall(stmt.expression); }); + if (!superCallStatement || !ctr.body.multiLine) { + this.replaceConstructorBody(sourceFile, ctr, __spreadArray(__spreadArray([], ctr.body.statements), [newStatement])); + } + else { + this.insertNodeAfter(sourceFile, superCallStatement, newStatement); + } + }; ChangeTracker.prototype.insertNodeAtConstructorEnd = function (sourceFile, ctr, newStatement) { var lastStatement = ts.lastOrUndefined(ctr.body.statements); if (!lastStatement || !ctr.body.multiLine) { @@ -134792,18 +139735,18 @@ var ts; }; ChangeTracker.prototype.getInsertNodeAfterOptionsWorker = function (node) { switch (node.kind) { - case 252 /* ClassDeclaration */: - case 256 /* ModuleDeclaration */: + case 254 /* ClassDeclaration */: + case 258 /* ModuleDeclaration */: return { prefix: this.newLineCharacter, suffix: this.newLineCharacter }; - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: case 10 /* StringLiteral */: - case 78 /* Identifier */: + case 79 /* Identifier */: return { prefix: ", " }; - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: return { suffix: "," + this.newLineCharacter }; - case 92 /* ExportKeyword */: + case 93 /* ExportKeyword */: return { prefix: " " }; - case 160 /* Parameter */: + case 162 /* Parameter */: return {}; default: ts.Debug.assert(ts.isStatement(node) || ts.isClassOrTypeElement(node)); // Else we haven't handled this kind of node yet -- add it @@ -134812,12 +139755,12 @@ var ts; }; ChangeTracker.prototype.insertName = function (sourceFile, node, name) { ts.Debug.assert(!node.name); - if (node.kind === 209 /* ArrowFunction */) { + if (node.kind === 211 /* ArrowFunction */) { var arrow = ts.findChildOfKind(node, 38 /* EqualsGreaterThanToken */, sourceFile); var lparen = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); if (lparen) { // `() => {}` --> `function f() {}` - this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.factory.createToken(97 /* FunctionKeyword */), ts.factory.createIdentifier(name)], { joiner: " " }); + this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.factory.createToken(98 /* FunctionKeyword */), ts.factory.createIdentifier(name)], { joiner: " " }); deleteNode(this, sourceFile, arrow); } else { @@ -134826,14 +139769,14 @@ var ts; // Replacing full range of arrow to get rid of the leading space -- replace ` =>` with `)` this.replaceRange(sourceFile, arrow, ts.factory.createToken(21 /* CloseParenToken */)); } - if (node.body.kind !== 230 /* Block */) { + if (node.body.kind !== 232 /* Block */) { // `() => 0` => `function f() { return 0; }` - this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.factory.createToken(18 /* OpenBraceToken */), ts.factory.createToken(104 /* ReturnKeyword */)], { joiner: " ", suffix: " " }); + 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: " " }); } } else { - var pos = ts.findChildOfKind(node, node.kind === 208 /* FunctionExpression */ ? 97 /* FunctionKeyword */ : 83 /* ClassKeyword */, sourceFile).end; + var pos = ts.findChildOfKind(node, node.kind === 210 /* FunctionExpression */ ? 98 /* FunctionKeyword */ : 84 /* ClassKeyword */, sourceFile).end; this.insertNodeAt(sourceFile, pos, ts.factory.createIdentifier(name), { prefix: " " }); } }; @@ -134865,47 +139808,22 @@ var ts; // a, b, c // create change for adding 'e' after 'a' as // - find start of next element after a (it is b) - // - use this start as start and end position in final change - // - build text of change by formatting the text of node + separator + whitespace trivia of b + // - use next element start as start and end position in final change + // - build text of change by formatting the text of node + whitespace trivia of b // in multiline case it will work as // a, // b, // c, // result - '*' denotes leading trivia that will be inserted after new text (displayed as '#') - // a,* - // ***insertedtext# + // a, + // insertedtext# // ###b, // c, - // find line and character of the next element - var lineAndCharOfNextElement = ts.getLineAndCharacterOfPosition(sourceFile, skipWhitespacesAndLineBreaks(sourceFile.text, containingList[index + 1].getFullStart())); - // find line and character of the token that precedes next element (usually it is separator) - var lineAndCharOfNextToken = ts.getLineAndCharacterOfPosition(sourceFile, nextToken.end); - var prefix = void 0; - var startPos = void 0; - if (lineAndCharOfNextToken.line === lineAndCharOfNextElement.line) { - // next element is located on the same line with separator: - // a,$$$$b - // ^ ^ - // | |-next element - // |-separator - // where $$$ is some leading trivia - // for a newly inserted node we'll maintain the same relative position comparing to separator and replace leading trivia with spaces - // a, x,$$$$b - // ^ ^ ^ - // | | |-next element - // | |-new inserted node padded with spaces - // |-separator - startPos = nextToken.end; - prefix = spaces(lineAndCharOfNextElement.character - lineAndCharOfNextToken.character); - } - else { - // next element is located on different line that separator - // let insert position be the beginning of the line that contains next element - startPos = ts.getStartPositionOfLine(lineAndCharOfNextElement.line, sourceFile); - } + 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, containingList[index + 1].getStart(sourceFile)); - this.replaceRange(sourceFile, ts.createRange(startPos, containingList[index + 1].getStart(sourceFile)), newNode, { prefix: prefix, suffix: suffix }); + var suffix = "" + ts.tokenToString(nextToken.kind) + sourceFile.text.substring(nextToken.end, startPos); + this.insertNodesAt(sourceFile, startPos, [newNode], { suffix: suffix }); } } else { @@ -134977,7 +139895,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_9 = function (sourceFile, node) { + var _loop_10 = 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)); @@ -134990,7 +139908,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_9(sourceFile, node); + _loop_10(sourceFile, node); } deletedNodesInLists.forEach(function (node) { var sourceFile = node.getSourceFile(); @@ -135049,14 +139967,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_10 = function (i) { + var _loop_11 = 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); }); }; // verify that change intervals do not overlap, except possibly at end points. for (var i = 0; i < normalized.length - 1; i++) { - _loop_10(i); + _loop_11(i); } var textChanges = ts.mapDefined(normalized, function (c) { var span = ts.createTextSpanFromRange(c.range); @@ -135170,11 +140088,12 @@ var ts; function createWriter(newLine) { var lastNonTriviaPosition = 0; var writer = ts.createTextWriter(newLine); - var onEmitNode = function (hint, node, printCallback) { + var onBeforeEmitNode = function (node) { if (node) { setPos(node, lastNonTriviaPosition); } - printCallback(hint, node); + }; + var onAfterEmitNode = function (node) { if (node) { setEnd(node, lastNonTriviaPosition); } @@ -135293,7 +140212,8 @@ var ts; lastNonTriviaPosition = 0; } return { - onEmitNode: onEmitNode, + onBeforeEmitNode: onBeforeEmitNode, + onAfterEmitNode: onAfterEmitNode, onBeforeEmitNodeArray: onBeforeEmitNodeArray, onAfterEmitNodeArray: onAfterEmitNodeArray, onBeforeEmitToken: onBeforeEmitToken, @@ -135408,14 +140328,14 @@ var ts; } textChanges_3.isValidLocationToAddComment = isValidLocationToAddComment; function needSemicolonBetween(a, b) { - return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 158 /* ComputedPropertyName */ + return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 160 /* 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 160 /* Parameter */: { + case 162 /* Parameter */: { var oldFunction = node.parent; if (ts.isArrowFunction(oldFunction) && oldFunction.parameters.length === 1 && @@ -135430,15 +140350,17 @@ var ts; } break; } - case 261 /* ImportDeclaration */: - case 260 /* ImportEqualsDeclaration */: + case 263 /* ImportDeclaration */: + case 262 /* 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 }); + deleteNode(changes, sourceFile, node, { + leadingTriviaOption: isFirstImport ? LeadingTriviaOption.Exclude : ts.hasJSDocNodes(node) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine, + }); break; - case 198 /* BindingElement */: + case 200 /* BindingElement */: var pattern = node.parent; - var preserveComma = pattern.kind === 197 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); + var preserveComma = pattern.kind === 199 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); if (preserveComma) { deleteNode(changes, sourceFile, node); } @@ -135446,13 +140368,13 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node); break; - case 159 /* TypeParameter */: + case 161 /* TypeParameter */: deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); break; - case 265 /* ImportSpecifier */: + case 267 /* ImportSpecifier */: var namedImports = node.parent; if (namedImports.elements.length === 1) { deleteImportBinding(changes, sourceFile, namedImports); @@ -135461,21 +140383,25 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: deleteImportBinding(changes, sourceFile, node); break; case 26 /* SemicolonToken */: deleteNode(changes, sourceFile, node, { trailingTriviaOption: TrailingTriviaOption.Exclude }); break; - case 97 /* FunctionKeyword */: + case 98 /* FunctionKeyword */: deleteNode(changes, sourceFile, node, { leadingTriviaOption: LeadingTriviaOption.Exclude }); break; - case 252 /* ClassDeclaration */: - case 251 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: + case 253 /* FunctionDeclaration */: deleteNode(changes, sourceFile, node, { leadingTriviaOption: ts.hasJSDocNodes(node) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine }); break; default: - if (ts.isImportClause(node.parent) && node.parent.name === node) { + if (!node.parent) { + // a misbehaving client can reach here with the SourceFile node + deleteNode(changes, sourceFile, node); + } + else if (ts.isImportClause(node.parent) && node.parent.name === node) { deleteDefaultImport(changes, sourceFile, node.parent); } else if (ts.isCallExpression(node.parent) && ts.contains(node.parent.arguments, node)) { @@ -135518,13 +140444,13 @@ var ts; // Delete the entire import declaration // |import * as ns from './file'| // |import { a } from './file'| - var importDecl = ts.getAncestor(node, 261 /* ImportDeclaration */); + var importDecl = ts.getAncestor(node, 263 /* ImportDeclaration */); deleteNode(changes, sourceFile, importDecl); } } function deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node) { var parent = node.parent; - if (parent.kind === 287 /* CatchClause */) { + if (parent.kind === 289 /* 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)); return; @@ -135535,14 +140461,14 @@ var ts; } var gp = parent.parent; switch (gp.kind) { - case 239 /* ForOfStatement */: - case 238 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 240 /* ForInStatement */: changes.replaceNode(sourceFile, node, ts.factory.createObjectLiteralExpression()); break; - case 237 /* ForStatement */: + case 239 /* ForStatement */: deleteNode(changes, sourceFile, parent); break; - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: deleteNode(changes, sourceFile, gp, { leadingTriviaOption: ts.hasJSDocNodes(gp) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine }); break; default: @@ -135598,6 +140524,10 @@ var ts; return createCodeFixActionWorker(fixName, diagnosticToString(description), changes, fixId, diagnosticToString(fixAllDescription), command); } codefix.createCodeFixAction = createCodeFixAction; + function createCodeFixActionMaybeFixAll(fixName, changes, description, fixId, fixAllDescription, command) { + return createCodeFixActionWorker(fixName, diagnosticToString(description), changes, fixId, fixAllDescription && diagnosticToString(fixAllDescription), command); + } + codefix.createCodeFixActionMaybeFixAll = createCodeFixActionMaybeFixAll; function createCodeFixActionWorker(fixName, description, changes, fixId, fixAllDescription, command) { return { fixName: fixName, description: description, changes: changes, fixId: fixId, fixAllDescription: fixAllDescription, commands: command ? [command] : undefined }; } @@ -135724,8 +140654,8 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, pos); var assertion = ts.Debug.checkDefined(ts.findAncestor(token, function (n) { return ts.isAsExpression(n) || ts.isTypeAssertionExpression(n); }), "Expected to find an assertion expression"); var replacement = ts.isAsExpression(assertion) - ? ts.factory.createAsExpression(assertion.expression, ts.factory.createKeywordTypeNode(152 /* UnknownKeyword */)) - : ts.factory.createTypeAssertion(ts.factory.createKeywordTypeNode(152 /* UnknownKeyword */), assertion.expression); + ? ts.factory.createAsExpression(assertion.expression, ts.factory.createKeywordTypeNode(153 /* UnknownKeyword */)) + : ts.factory.createTypeAssertion(ts.factory.createKeywordTypeNode(153 /* UnknownKeyword */), assertion.expression); changeTracker.replaceNode(sourceFile, assertion.expression, replacement); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -135736,7 +140666,10 @@ var ts; var codefix; (function (codefix) { codefix.registerCodeFix({ - errorCodes: [ts.Diagnostics.await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module.code], + errorCodes: [ + ts.Diagnostics.await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module.code, + ts.Diagnostics.for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module.code, + ], getCodeActions: function (context) { var sourceFile = context.sourceFile; var changes = ts.textChanges.ChangeTracker.with(context, function (changes) { @@ -135849,6 +140782,7 @@ var ts; ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1.code, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2.code, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap.code, + ts.Diagnostics.This_condition_will_always_return_true_since_this_0_is_always_defined.code, ts.Diagnostics.Type_0_is_not_an_array_type.code, ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type.code, ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators.code, @@ -135947,14 +140881,14 @@ var ts; } var isCompleteFix = identifiers.isCompleteFix; var initializers; - var _loop_11 = function (identifier) { + var _loop_12 = 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, 232 /* VariableStatement */); + var variableStatement = ts.getAncestor(declaration, 234 /* VariableStatement */); if (!declaration || !variableStatement || declaration.type || !declaration.initializer || @@ -135980,7 +140914,7 @@ var ts; }; for (var _i = 0, _a = identifiers.identifiers; _i < _a.length; _i++) { var identifier = _a[_i]; - _loop_11(identifier); + _loop_12(identifier); } return initializers && { initializers: initializers, @@ -136032,10 +140966,10 @@ var ts; function isInsideAwaitableBody(node) { return node.kind & 32768 /* AwaitContext */ || !!ts.findAncestor(node, function (ancestor) { return ancestor.parent && ts.isArrowFunction(ancestor.parent) && ancestor.parent.body === ancestor || - ts.isBlock(ancestor) && (ancestor.parent.kind === 251 /* FunctionDeclaration */ || - ancestor.parent.kind === 208 /* FunctionExpression */ || - ancestor.parent.kind === 209 /* ArrowFunction */ || - ancestor.parent.kind === 165 /* MethodDeclaration */); + ts.isBlock(ancestor) && (ancestor.parent.kind === 253 /* FunctionDeclaration */ || + ancestor.parent.kind === 210 /* FunctionExpression */ || + ancestor.parent.kind === 211 /* ArrowFunction */ || + ancestor.parent.kind === 167 /* MethodDeclaration */); }); } function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite, fixedDeclarations) { @@ -136124,7 +141058,7 @@ var ts; if (forInitializer) return applyChange(changeTracker, forInitializer, sourceFile, fixedNodes); var parent = token.parent; - if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 62 /* EqualsToken */ && ts.isExpressionStatement(parent.parent)) { + if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isExpressionStatement(parent.parent)) { return applyChange(changeTracker, token, sourceFile, fixedNodes); } if (ts.isArrayLiteralExpression(parent)) { @@ -136148,16 +141082,16 @@ var ts; } function applyChange(changeTracker, initializer, sourceFile, fixedNodes) { if (!fixedNodes || ts.tryAddToSet(fixedNodes, initializer)) { - changeTracker.insertModifierBefore(sourceFile, 84 /* ConstKeyword */, initializer); + changeTracker.insertModifierBefore(sourceFile, 85 /* ConstKeyword */, initializer); } } function isPossiblyPartOfDestructuring(node) { switch (node.kind) { - case 78 /* Identifier */: - case 199 /* ArrayLiteralExpression */: - case 200 /* ObjectLiteralExpression */: - case 288 /* PropertyAssignment */: - case 289 /* ShorthandPropertyAssignment */: + case 79 /* Identifier */: + case 201 /* ArrayLiteralExpression */: + case 202 /* ObjectLiteralExpression */: + case 290 /* PropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return true; default: return false; @@ -136171,8 +141105,8 @@ var ts; } function isPossiblyPartOfCommaSeperatedInitializer(node) { switch (node.kind) { - case 78 /* Identifier */: - case 216 /* BinaryExpression */: + case 79 /* Identifier */: + case 218 /* BinaryExpression */: case 27 /* CommaToken */: return true; default: @@ -136186,7 +141120,7 @@ var ts; if (expression.operatorToken.kind === 27 /* CommaToken */) { return ts.every([expression.left, expression.right], function (expression) { return expressionCouldBeVariableDeclaration(expression, checker); }); } - return expression.operatorToken.kind === 62 /* EqualsToken */ + return expression.operatorToken.kind === 63 /* EqualsToken */ && ts.isIdentifier(expression.left) && !checker.getSymbolAtLocation(expression.left); } @@ -136221,9 +141155,9 @@ var ts; return; } var declaration = token.parent; - if (declaration.kind === 163 /* PropertyDeclaration */ && + if (declaration.kind === 165 /* PropertyDeclaration */ && (!fixedNodes || ts.tryAddToSet(fixedNodes, declaration))) { - changeTracker.insertModifierBefore(sourceFile, 133 /* DeclareKeyword */, declaration); + changeTracker.insertModifierBefore(sourceFile, 134 /* DeclareKeyword */, declaration); } } })(codefix = ts.codefix || (ts.codefix = {})); @@ -136358,26 +141292,26 @@ var ts; } function isDeclarationWithType(node) { return ts.isFunctionLikeDeclaration(node) || - node.kind === 249 /* VariableDeclaration */ || - node.kind === 162 /* PropertySignature */ || - node.kind === 163 /* PropertyDeclaration */; + node.kind === 251 /* VariableDeclaration */ || + node.kind === 164 /* PropertySignature */ || + node.kind === 165 /* PropertyDeclaration */; } function transformJSDocType(node) { switch (node.kind) { - case 303 /* JSDocAllType */: - case 304 /* JSDocUnknownType */: + case 306 /* JSDocAllType */: + case 307 /* JSDocUnknownType */: return ts.factory.createTypeReferenceNode("any", ts.emptyArray); - case 307 /* JSDocOptionalType */: + case 310 /* JSDocOptionalType */: return transformJSDocOptionalType(node); - case 306 /* JSDocNonNullableType */: + case 309 /* JSDocNonNullableType */: return transformJSDocType(node.type); - case 305 /* JSDocNullableType */: + case 308 /* JSDocNullableType */: return transformJSDocNullableType(node); - case 309 /* JSDocVariadicType */: + case 312 /* JSDocVariadicType */: return transformJSDocVariadicType(node); - case 308 /* JSDocFunctionType */: + case 311 /* JSDocFunctionType */: return transformJSDocFunctionType(node); - case 173 /* TypeReference */: + case 175 /* TypeReference */: return transformJSDocTypeReference(node); default: var visited = ts.visitEachChild(node, transformJSDocType, ts.nullTransformationContext); @@ -136398,11 +141332,11 @@ 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(128 /* AnyKeyword */)); + return ts.factory.createFunctionTypeNode(ts.emptyArray, node.parameters.map(transformJSDocParameter), (_a = node.type) !== null && _a !== void 0 ? _a : ts.factory.createKeywordTypeNode(129 /* AnyKeyword */)); } function transformJSDocParameter(node) { var index = node.parent.parameters.indexOf(node); - var isRest = node.type.kind === 309 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 + var isRest = node.type.kind === 312 /* 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; return ts.factory.createParameterDeclaration(node.decorators, node.modifiers, dotdotdot, name, node.questionToken, ts.visitNode(node.type, transformJSDocType), node.initializer); @@ -136442,8 +141376,8 @@ var ts; var index = ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 144 /* NumberKeyword */ ? "n" : "s", - /*questionToken*/ undefined, ts.factory.createTypeReferenceNode(node.typeArguments[0].kind === 144 /* NumberKeyword */ ? "number" : "string", []), + /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 145 /* NumberKeyword */ ? "n" : "s", + /*questionToken*/ undefined, ts.factory.createTypeReferenceNode(node.typeArguments[0].kind === 145 /* NumberKeyword */ ? "number" : "string", []), /*initializer*/ undefined); var indexSignature = ts.factory.createTypeLiteralNode([ts.factory.createIndexSignature(/*decorators*/ undefined, /*modifiers*/ undefined, [index], node.typeArguments[1])]); ts.setEmitFlags(indexSignature, 1 /* SingleLine */); @@ -136473,7 +141407,7 @@ var ts; }); function doChange(changes, sourceFile, position, checker, preferences, compilerOptions) { var ctorSymbol = checker.getSymbolAtLocation(ts.getTokenAtPosition(sourceFile, position)); - if (!ctorSymbol || !(ctorSymbol.flags & (16 /* Function */ | 3 /* Variable */))) { + if (!ctorSymbol || !ctorSymbol.valueDeclaration || !(ctorSymbol.flags & (16 /* Function */ | 3 /* Variable */))) { // Bad input return undefined; } @@ -136500,7 +141434,7 @@ var ts; // all instance members are stored in the "member" array of symbol if (symbol.members) { symbol.members.forEach(function (member, key) { - if (key === "constructor") { + if (key === "constructor" && member.valueDeclaration) { // fn.prototype.constructor = fn changes.delete(sourceFile, member.valueDeclaration.parent); return; @@ -136514,13 +141448,13 @@ var ts; // all static members are stored in the "exports" array of symbol if (symbol.exports) { symbol.exports.forEach(function (member) { - if (member.name === "prototype") { + if (member.name === "prototype" && member.declarations) { var firstDeclaration = member.declarations[0]; // only one "x.prototype = { ... }" will pass if (member.declarations.length === 1 && ts.isPropertyAccessExpression(firstDeclaration) && ts.isBinaryExpression(firstDeclaration.parent) && - firstDeclaration.parent.operatorToken.kind === 62 /* EqualsToken */ && + firstDeclaration.parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isObjectLiteralExpression(firstDeclaration.parent.right)) { var prototypes = firstDeclaration.parent.right; var memberElement = createClassElement(prototypes.symbol, /** modifiers */ undefined); @@ -136530,7 +141464,7 @@ var ts; } } else { - var memberElement = createClassElement(member, [ts.factory.createToken(123 /* StaticKeyword */)]); + var memberElement = createClassElement(member, [ts.factory.createToken(124 /* StaticKeyword */)]); if (memberElement) { memberElements.push.apply(memberElements, memberElement); } @@ -136576,7 +141510,7 @@ var ts; return members; } // delete the entire statement if this expression is the sole expression to take care of the semicolon at the end - var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 233 /* ExpressionStatement */ + var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 235 /* ExpressionStatement */ ? assignmentBinaryExpression.parent : assignmentBinaryExpression; changes.delete(sourceFile, nodeToDelete); if (!assignmentExpr) { @@ -136627,7 +141561,7 @@ var ts; return createArrowFunctionExpressionMember(members, expression, name); } function createFunctionExpressionMember(members, functionExpression, name) { - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 129 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 130 /* AsyncKeyword */)); var method = ts.factory.createMethodDeclaration(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined, /*typeParameters*/ undefined, functionExpression.parameters, /*type*/ undefined, functionExpression.body); ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); @@ -136637,14 +141571,14 @@ var ts; var arrowFunctionBody = arrowFunction.body; var bodyBlock; // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 230 /* Block */) { + if (arrowFunctionBody.kind === 232 /* Block */) { bodyBlock = arrowFunctionBody; } // case 2: () => [1,2,3] else { bodyBlock = ts.factory.createBlock([ts.factory.createReturnStatement(arrowFunctionBody)]); } - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 129 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 130 /* AsyncKeyword */)); var method = ts.factory.createMethodDeclaration(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined, /*typeParameters*/ undefined, arrowFunction.parameters, /*type*/ undefined, bodyBlock); ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); @@ -136661,7 +141595,7 @@ var ts; if (initializer.body) { memberElements.unshift(ts.factory.createConstructorDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, initializer.parameters, initializer.body)); } - var modifiers = getModifierKindFromSource(node.parent.parent, 92 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(node.parent.parent, 93 /* ExportKeyword */); var cls = ts.factory.createClassDeclaration(/*decorators*/ undefined, modifiers, node.name, /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); // Don't call copyComments here because we'll already leave them in place @@ -136672,7 +141606,7 @@ var ts; if (node.body) { memberElements.unshift(ts.factory.createConstructorDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, node.parameters, node.body)); } - var modifiers = getModifierKindFromSource(node, 92 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(node, 93 /* ExportKeyword */); var cls = ts.factory.createClassDeclaration(/*decorators*/ undefined, modifiers, node.name, /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); // Don't call copyComments here because we'll already leave them in place @@ -136739,7 +141673,7 @@ var ts; functionToConvert = tokenAtPosition.parent.initializer; } else { - functionToConvert = ts.tryCast(ts.getContainingFunction(ts.getTokenAtPosition(sourceFile, position)), ts.isFunctionLikeDeclaration); + functionToConvert = ts.tryCast(ts.getContainingFunction(ts.getTokenAtPosition(sourceFile, position)), ts.canBeConvertedToAsync); } if (!functionToConvert) { return; @@ -136748,7 +141682,10 @@ var ts; var isInJavascript = ts.isInJSFile(functionToConvert); var setOfExpressionsToReturn = getAllPromiseExpressionsToReturn(functionToConvert, checker); var functionToConvertRenamed = renameCollidingVarNames(functionToConvert, checker, synthNamesMap); - var returnStatements = functionToConvertRenamed.body && ts.isBlock(functionToConvertRenamed.body) ? getReturnStatementsWithPromiseHandlers(functionToConvertRenamed.body) : ts.emptyArray; + if (!ts.returnsPromise(functionToConvertRenamed, checker)) { + return; + } + var returnStatements = functionToConvertRenamed.body && ts.isBlock(functionToConvertRenamed.body) ? getReturnStatementsWithPromiseHandlers(functionToConvertRenamed.body, checker) : ts.emptyArray; var transformer = { checker: checker, synthNamesMap: synthNamesMap, setOfExpressionsToReturn: setOfExpressionsToReturn, isInJSFile: isInJavascript }; if (!returnStatements.length) { return; @@ -136757,8 +141694,8 @@ var ts; functionToConvert.decorators ? ts.skipTrivia(sourceFile.text, functionToConvert.decorators.end) : functionToConvert.getStart(sourceFile); var options = functionToConvert.modifiers ? { prefix: " " } : { suffix: " " }; - changes.insertModifierAt(sourceFile, pos, 129 /* AsyncKeyword */, options); - var _loop_12 = function (returnStatement) { + changes.insertModifierAt(sourceFile, pos, 130 /* AsyncKeyword */, options); + var _loop_13 = function (returnStatement) { ts.forEachChild(returnStatement, function visit(node) { if (ts.isCallExpression(node)) { var newNodes = transformExpression(node, transformer); @@ -136771,13 +141708,13 @@ var ts; }; for (var _i = 0, returnStatements_1 = returnStatements; _i < returnStatements_1.length; _i++) { var returnStatement = returnStatements_1[_i]; - _loop_12(returnStatement); + _loop_13(returnStatement); } } - function getReturnStatementsWithPromiseHandlers(body) { + function getReturnStatementsWithPromiseHandlers(body, checker) { var res = []; ts.forEachReturnStatement(body, function (ret) { - if (ts.isReturnStatementWithFixablePromiseHandler(ret)) + if (ts.isReturnStatementWithFixablePromiseHandler(ret, checker)) res.push(ret); }); return res; @@ -136848,7 +141785,10 @@ var ts; // so we push an entry for 'response'. if (lastCallSignature && !ts.isParameter(node.parent) && !ts.isFunctionLikeDeclaration(node.parent) && !synthNamesMap.has(symbolIdString)) { var firstParameter = ts.firstOrUndefined(lastCallSignature.parameters); - var ident = firstParameter && ts.isParameter(firstParameter.valueDeclaration) && ts.tryCast(firstParameter.valueDeclaration.name, ts.isIdentifier) || ts.factory.createUniqueName("result", 16 /* Optimistic */); + 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 */); var synthName = getNewNameIfConflict(ident, collidingSymbolMap); synthNamesMap.set(symbolIdString, synthName); collidingSymbolMap.add(ident.text, symbol); @@ -137023,10 +141963,11 @@ var ts; function getTransformationBody(func, prevArgName, argName, parent, transformer) { var _a, _b, _c, _d, _e; switch (func.kind) { - case 103 /* NullKeyword */: + case 104 /* NullKeyword */: // do not produce a transformed statement for a null argument break; - case 78 /* Identifier */: // identifier includes undefined + case 203 /* PropertyAccessExpression */: + case 79 /* Identifier */: // identifier includes undefined if (!argName) { // undefined was argument passed to promise handler break; @@ -137047,8 +141988,8 @@ var ts; prevArgName.types.push(returnType); } return varDeclOrAssignment; - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: { + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: { var funcBody = func.body; var returnType_1 = (_c = getLastCallSignature(transformer.checker.getTypeAtLocation(func), transformer.checker)) === null || _c === void 0 ? void 0 : _c.getReturnType(); // Arrow functions with block bodies { } will enter this control flow @@ -137059,7 +142000,7 @@ var ts; var statement = _f[_i]; if (ts.isReturnStatement(statement)) { seenReturnStatement = true; - if (ts.isReturnStatementWithFixablePromiseHandler(statement)) { + if (ts.isReturnStatementWithFixablePromiseHandler(statement, transformer.checker)) { refactoredStmts = refactoredStmts.concat(getInnerTransformationBody(transformer, [statement], prevArgName)); } else { @@ -137076,7 +142017,7 @@ var ts; : removeReturns(refactoredStmts, prevArgName, transformer, seenReturnStatement); } else { - var innerRetStmts = ts.isFixablePromiseHandler(funcBody) ? [ts.factory.createReturnStatement(funcBody)] : ts.emptyArray; + var innerRetStmts = ts.isFixablePromiseHandler(funcBody, transformer.checker) ? [ts.factory.createReturnStatement(funcBody)] : ts.emptyArray; var innerCbBody = getInnerTransformationBody(transformer, innerRetStmts, prevArgName); if (innerCbBody.length > 0) { return innerCbBody; @@ -137169,6 +142110,9 @@ var ts; else if (ts.isIdentifier(funcNode)) { name = getMapEntryOrDefault(funcNode); } + else if (ts.isPropertyAccessExpression(funcNode) && ts.isIdentifier(funcNode.name)) { + name = getMapEntryOrDefault(funcNode.name); + } // return undefined argName when arg is null or undefined // eslint-disable-next-line no-in-operator if (!name || "identifier" in name && name.identifier.text === "undefined") { @@ -137264,10 +142208,10 @@ var ts; } var importNode = ts.importFromModuleSpecifier(moduleSpecifier); switch (importNode.kind) { - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier, quotePreference)); break; - case 203 /* CallExpression */: + case 205 /* CallExpression */: if (ts.isRequireCall(importNode, /*checkArgumentIsStringLiteralLike*/ false)) { changes.replaceNode(importingFile, importNode, ts.factory.createPropertyAccessExpression(ts.getSynthesizedDeepClone(importNode), "default")); } @@ -137327,29 +142271,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 === 62 /* EqualsToken */); + cb(node, ts.isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === 63 /* EqualsToken */); } node.forEachChild(recur); }); } function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, useSitesToUnqualify, quotePreference) { switch (statement.kind) { - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, quotePreference); return false; - case 233 /* ExpressionStatement */: { + case 235 /* ExpressionStatement */: { var expression = statement.expression; switch (expression.kind) { - case 203 /* CallExpression */: { + case 205 /* 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 216 /* BinaryExpression */: { + case 218 /* BinaryExpression */: { var operatorToken = expression.operatorToken; - return operatorToken.kind === 62 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports, useSitesToUnqualify); + return operatorToken.kind === 63 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports, useSitesToUnqualify); } } } @@ -137396,8 +142340,8 @@ var ts; /** Converts `const name = require("moduleSpecifier").propertyName` */ function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers, quotePreference) { switch (name.kind) { - case 196 /* ObjectBindingPattern */: - case 197 /* ArrayBindingPattern */: { + case 198 /* ObjectBindingPattern */: + case 199 /* ArrayBindingPattern */: { // `const [a, b] = require("c").d` --> `import { d } from "c"; const [a, b] = d;` var tmp = makeUniqueName(propertyName, identifiers); return convertedImports([ @@ -137405,7 +142349,7 @@ var ts; makeConst(/*modifiers*/ undefined, name, ts.factory.createIdentifier(tmp)), ]); } - case 78 /* Identifier */: + case 79 /* Identifier */: // `const a = require("b").c` --> `import { c as a } from "./b"; return convertedImports([makeSingleImport(name.text, propertyName, moduleSpecifier, quotePreference)]); default: @@ -137448,17 +142392,17 @@ var ts; function tryChangeModuleExportsObject(object, useSitesToUnqualify) { var statements = ts.mapAllOrFail(object.properties, function (prop) { switch (prop.kind) { - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: // TODO: Maybe we should handle this? See fourslash test `refactorConvertToEs6Module_export_object_shorthand.ts`. // falls through - case 289 /* ShorthandPropertyAssignment */: - case 290 /* SpreadAssignment */: + case 291 /* ShorthandPropertyAssignment */: + case 292 /* SpreadAssignment */: return undefined; - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: return !ts.isIdentifier(prop.name) ? undefined : convertExportsDotXEquals_replaceNode(prop.name.text, prop.initializer, useSitesToUnqualify); - case 165 /* MethodDeclaration */: - return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.factory.createToken(92 /* ExportKeyword */)], prop, useSitesToUnqualify); + case 167 /* MethodDeclaration */: + return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.factory.createToken(93 /* ExportKeyword */)], prop, useSitesToUnqualify); default: ts.Debug.assertNever(prop, "Convert to ES6 got invalid prop kind " + prop.kind); } @@ -137505,7 +142449,7 @@ 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(92 /* ExportKeyword */), { suffix: " " }); + changes.replaceRange(sourceFile, { pos: left.getStart(sourceFile), end: right.getStart(sourceFile) }, ts.factory.createToken(93 /* ExportKeyword */), { suffix: " " }); if (!right.name) changes.insertName(sourceFile, right, name); var semi = ts.findChildOfKind(parent, 26 /* SemicolonToken */, sourceFile); @@ -137514,14 +142458,14 @@ var ts; } 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(92 /* ExportKeyword */), ts.factory.createToken(84 /* ConstKeyword */)], { joiner: " ", suffix: " " }); + changes.replaceNodeRangeWithNodes(sourceFile, left.expression, ts.findChildOfKind(left, 24 /* DotToken */, sourceFile), [ts.factory.createToken(93 /* ExportKeyword */), ts.factory.createToken(85 /* 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(92 /* ExportKeyword */)]; + var modifiers = [ts.factory.createToken(93 /* ExportKeyword */)]; switch (exported.kind) { - case 208 /* FunctionExpression */: { + case 210 /* FunctionExpression */: { var expressionName = exported.name; if (expressionName && expressionName.text !== name) { // `exports.f = function g() {}` -> `export const f = function g() {}` @@ -137529,10 +142473,10 @@ var ts; } } // falls through - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: // `exports.f = function() {}` --> `export function f() {}` return functionExpressionToDeclaration(name, modifiers, exported, useSitesToUnqualify); - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: // `exports.C = class {}` --> `export class C {}` return classExpressionToDeclaration(name, modifiers, exported, useSitesToUnqualify); default: @@ -137552,7 +142496,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 === 201 /* PropertyAccessExpression */) { + if (original.kind === 203 /* 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); @@ -137567,7 +142511,7 @@ var ts; */ function convertSingleImport(name, moduleSpecifier, checker, identifiers, target, quotePreference) { switch (name.kind) { - case 196 /* ObjectBindingPattern */: { + case 198 /* 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 @@ -137580,7 +142524,7 @@ var ts; } } // falls through -- object destructuring has an interesting pattern and must be a variable declaration - case 197 /* ArrayBindingPattern */: { + case 199 /* ArrayBindingPattern */: { /* import x from "x"; const [a, b, c] = x; @@ -137591,7 +142535,7 @@ var ts; makeConst(/*modifiers*/ undefined, ts.getSynthesizedDeepClone(name), ts.factory.createIdentifier(tmp)), ]); } - case 78 /* Identifier */: + case 79 /* Identifier */: return convertSingleIdentifierImport(name, moduleSpecifier, checker, identifiers, quotePreference); default: return ts.Debug.assertNever(name, "Convert to ES6 module got invalid name kind " + name.kind); @@ -137599,7 +142543,9 @@ var ts; } /** * Convert `import x = require("x").` - * Also converts uses like `x.y()` to `y()` and uses a named import. + * Also: + * - Convert `x.default()` to `x()` to handle ES6 default export + * - Converts uses like `x.y()` to `y()` and uses a named import. */ function convertSingleIdentifierImport(name, moduleSpecifier, checker, identifiers, quotePreference) { var nameSymbol = checker.getSymbolAtLocation(name); @@ -137616,14 +142562,21 @@ var ts; } var parent = use.parent; if (ts.isPropertyAccessExpression(parent)) { - var expression = parent.expression, propertyName = parent.name.text; - ts.Debug.assert(expression === use, "Didn't expect expression === use"); // Else shouldn't have been in `collectIdentifiers` - var idName = namedBindingsNames.get(propertyName); - if (idName === undefined) { - idName = makeUniqueName(propertyName, identifiers); - namedBindingsNames.set(propertyName, idName); + var propertyName = parent.name.text; + if (propertyName === "default") { + needDefaultImport = true; + var importDefaultName = use.getText(); + (useSitesToUnqualify !== null && useSitesToUnqualify !== void 0 ? useSitesToUnqualify : (useSitesToUnqualify = new ts.Map())).set(parent, ts.factory.createIdentifier(importDefaultName)); + } + else { + ts.Debug.assert(parent.expression === use, "Didn't expect expression === use"); // Else shouldn't have been in `collectIdentifiers` + var idName = namedBindingsNames.get(propertyName); + if (idName === undefined) { + idName = makeUniqueName(propertyName, identifiers); + namedBindingsNames.set(propertyName, idName); + } + (useSitesToUnqualify !== null && useSitesToUnqualify !== void 0 ? useSitesToUnqualify : (useSitesToUnqualify = new ts.Map())).set(parent, ts.factory.createIdentifier(idName)); } - (useSitesToUnqualify !== null && useSitesToUnqualify !== void 0 ? useSitesToUnqualify : (useSitesToUnqualify = new ts.Map())).set(parent, ts.factory.createIdentifier(idName)); } else { needDefaultImport = true; @@ -137664,11 +142617,11 @@ var ts; function isFreeIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return parent.name !== node; - case 198 /* BindingElement */: + case 200 /* BindingElement */: return parent.propertyName !== node; - case 265 /* ImportSpecifier */: + case 267 /* ImportSpecifier */: return parent.propertyName !== node; default: return true; @@ -137782,7 +142735,7 @@ var ts; var exportDeclaration = exportClause.parent; var typeExportSpecifiers = getTypeExportSpecifiers(exportSpecifier, context); if (typeExportSpecifiers.length === exportClause.elements.length) { - changes.insertModifierBefore(context.sourceFile, 149 /* TypeKeyword */, exportClause); + changes.insertModifierBefore(context.sourceFile, 150 /* TypeKeyword */, exportClause); } else { var valueExportDeclaration = ts.factory.updateExportDeclaration(exportDeclaration, exportDeclaration.decorators, exportDeclaration.modifiers, @@ -138145,87 +143098,138 @@ var ts; ImportFixKind[ImportFixKind["AddToExisting"] = 2] = "AddToExisting"; ImportFixKind[ImportFixKind["AddNew"] = 3] = "AddNew"; })(ImportFixKind || (ImportFixKind = {})); - var ImportKind; - (function (ImportKind) { - ImportKind[ImportKind["Named"] = 0] = "Named"; - ImportKind[ImportKind["Default"] = 1] = "Default"; - ImportKind[ImportKind["Namespace"] = 2] = "Namespace"; - ImportKind[ImportKind["CommonJS"] = 3] = "CommonJS"; - })(ImportKind || (ImportKind = {})); function getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, symbolName, host, program, formatContext, position, preferences) { var compilerOptions = program.getCompilerOptions(); var exportInfos = ts.pathIsBareSpecifier(ts.stripQuotes(moduleSymbol.name)) - ? [getSymbolExportInfoForSymbol(exportedSymbol, moduleSymbol, sourceFile, program, host)] + ? [getSymbolExportInfoForSymbol(exportedSymbol, moduleSymbol, program, host)] : getAllReExportingModules(sourceFile, exportedSymbol, moduleSymbol, symbolName, host, program, /*useAutoImportProvider*/ true); var useRequire = shouldUseRequire(sourceFile, program); var preferTypeOnlyImport = compilerOptions.importsNotUsedAsValues === 2 /* Error */ && !ts.isSourceFileJS(sourceFile) && ts.isValidTypeOnlyAliasUseSite(ts.getTokenAtPosition(sourceFile, position)); - var moduleSpecifier = ts.first(getNewImportInfos(program, sourceFile, position, preferTypeOnlyImport, useRequire, exportInfos, host, preferences)).moduleSpecifier; var fix = getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, preferTypeOnlyImport, useRequire, host, preferences); - return { moduleSpecifier: moduleSpecifier, codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, ts.getQuotePreference(sourceFile, preferences))) }; + return { moduleSpecifier: fix.moduleSpecifier, codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, ts.getQuotePreference(sourceFile, preferences))) }; } codefix.getImportCompletionAction = getImportCompletionAction; function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, preferTypeOnlyImport, useRequire, host, preferences) { ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol"); - // We sort the best codefixes first, so taking `first` is best. - return ts.first(getFixForImport(exportInfos, symbolName, position, preferTypeOnlyImport, useRequire, program, sourceFile, host, preferences)); + return getBestFix(getImportFixes(exportInfos, symbolName, position, preferTypeOnlyImport, useRequire, program, sourceFile, host, preferences), sourceFile, host); } function codeFixActionToCodeAction(_a) { var description = _a.description, changes = _a.changes, commands = _a.commands; return { description: description, changes: changes, commands: commands }; } - function getSymbolExportInfoForSymbol(symbol, moduleSymbol, importingFile, program, host) { + function getSymbolExportInfoForSymbol(symbol, moduleSymbol, program, host) { var _a, _b; var compilerOptions = program.getCompilerOptions(); - var mainProgramInfo = getInfoWithChecker(program.getTypeChecker()); + var mainProgramInfo = getInfoWithChecker(program.getTypeChecker(), /*isFromPackageJson*/ false); if (mainProgramInfo) { return mainProgramInfo; } var autoImportProvider = (_b = (_a = host.getPackageJsonAutoImportProvider) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getTypeChecker(); - return ts.Debug.checkDefined(autoImportProvider && getInfoWithChecker(autoImportProvider), "Could not find symbol in specified module for code actions"); - function getInfoWithChecker(checker) { - var defaultInfo = getDefaultLikeExportInfo(importingFile, moduleSymbol, checker, compilerOptions); + return ts.Debug.checkDefined(autoImportProvider && getInfoWithChecker(autoImportProvider, /*isFromPackageJson*/ true), "Could not find symbol in specified module for code actions"); + function getInfoWithChecker(checker, isFromPackageJson) { + var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); if (defaultInfo && ts.skipAlias(defaultInfo.symbol, checker) === symbol) { - return { moduleSymbol: moduleSymbol, importKind: defaultInfo.kind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(symbol, checker) }; + return { symbol: defaultInfo.symbol, moduleSymbol: moduleSymbol, exportKind: defaultInfo.exportKind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(symbol, checker), isFromPackageJson: isFromPackageJson }; } var named = checker.tryGetMemberInModuleExportsAndProperties(symbol.name, moduleSymbol); if (named && ts.skipAlias(named, checker) === symbol) { - return { moduleSymbol: moduleSymbol, importKind: 0 /* Named */, exportedSymbolIsTypeOnly: isTypeOnlySymbol(symbol, checker) }; + return { symbol: named, moduleSymbol: moduleSymbol, exportKind: 0 /* Named */, exportedSymbolIsTypeOnly: isTypeOnlySymbol(symbol, checker), isFromPackageJson: isFromPackageJson }; } } } function getAllReExportingModules(importingFile, exportedSymbol, exportingModuleSymbol, symbolName, host, program, useAutoImportProvider) { var result = []; var compilerOptions = program.getCompilerOptions(); - forEachExternalModuleToImportFrom(program, host, importingFile, /*filterByPackageJson*/ false, useAutoImportProvider, function (moduleSymbol, moduleFile, program) { + var getModuleSpecifierResolutionHost = ts.memoizeOne(function (isFromPackageJson) { + return ts.createModuleSpecifierResolutionHost(isFromPackageJson ? host.getPackageJsonAutoImportProvider() : program, host); + }); + forEachExternalModuleToImportFrom(program, host, useAutoImportProvider, function (moduleSymbol, moduleFile, program, isFromPackageJson) { var checker = program.getTypeChecker(); // Don't import from a re-export when looking "up" like to `./index` or `../index`. if (moduleFile && moduleSymbol !== exportingModuleSymbol && ts.startsWith(importingFile.fileName, ts.getDirectoryPath(moduleFile.fileName))) { return; } - var defaultInfo = getDefaultLikeExportInfo(importingFile, moduleSymbol, checker, compilerOptions); - if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, compilerOptions.target) === symbolName) && ts.skipAlias(defaultInfo.symbol, checker) === exportedSymbol) { - result.push({ moduleSymbol: moduleSymbol, importKind: defaultInfo.kind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(defaultInfo.symbol, checker) }); + var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); + if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, compilerOptions.target) === symbolName) && ts.skipAlias(defaultInfo.symbol, checker) === exportedSymbol && isImportable(program, moduleFile, isFromPackageJson)) { + result.push({ symbol: defaultInfo.symbol, moduleSymbol: moduleSymbol, exportKind: defaultInfo.exportKind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(defaultInfo.symbol, checker), isFromPackageJson: isFromPackageJson }); } for (var _i = 0, _a = checker.getExportsAndPropertiesOfModule(moduleSymbol); _i < _a.length; _i++) { var exported = _a[_i]; - if (exported.name === symbolName && ts.skipAlias(exported, checker) === exportedSymbol) { - result.push({ moduleSymbol: moduleSymbol, importKind: 0 /* Named */, exportedSymbolIsTypeOnly: isTypeOnlySymbol(exported, checker) }); + if (exported.name === symbolName && ts.skipAlias(exported, checker) === exportedSymbol && isImportable(program, moduleFile, isFromPackageJson)) { + result.push({ symbol: exported, moduleSymbol: moduleSymbol, exportKind: 0 /* Named */, exportedSymbolIsTypeOnly: isTypeOnlySymbol(exported, checker), isFromPackageJson: isFromPackageJson }); } } }); return result; + function isImportable(program, moduleFile, isFromPackageJson) { + var _a; + return !moduleFile || ts.isImportableFile(program, importingFile, moduleFile, /*packageJsonFilter*/ undefined, getModuleSpecifierResolutionHost(isFromPackageJson), (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host)); + } + } + function getModuleSpecifierForBestExportInfo(exportInfo, importingFile, program, host, preferences) { + return getBestFix(getNewImportFixes(program, importingFile, /*position*/ undefined, /*preferTypeOnlyImport*/ false, /*useRequire*/ false, exportInfo, host, preferences), importingFile, host); } + codefix.getModuleSpecifierForBestExportInfo = getModuleSpecifierForBestExportInfo; + function getSymbolToExportInfoMap(importingFile, host, program) { + var _a, _b, _c, _d, _e, _f, _g, _h; + var start = ts.timestamp(); + // Pulling the AutoImportProvider project will trigger its updateGraph if pending, + // which will invalidate the export map cache if things change, so pull it before + // checking the cache. + (_a = host.getPackageJsonAutoImportProvider) === null || _a === void 0 ? void 0 : _a.call(host); + var cache = (_b = host.getExportMapCache) === null || _b === void 0 ? void 0 : _b.call(host); + if (cache) { + var cached = cache.get(importingFile.path, program.getTypeChecker(), (_c = host.getProjectVersion) === null || _c === void 0 ? void 0 : _c.call(host)); + if (cached) { + (_d = host.log) === null || _d === void 0 ? void 0 : _d.call(host, "getSymbolToExportInfoMap: cache hit"); + return cached; + } + else { + (_e = host.log) === null || _e === void 0 ? void 0 : _e.call(host, "getSymbolToExportInfoMap: cache miss or empty; calculating new results"); + } + } + var result = ts.createMultiMap(); + var compilerOptions = program.getCompilerOptions(); + var target = ts.getEmitScriptTarget(compilerOptions); + forEachExternalModuleToImportFrom(program, host, /*useAutoImportProvider*/ true, function (moduleSymbol, _moduleFile, program, isFromPackageJson) { + var checker = program.getTypeChecker(); + var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); + if (defaultInfo) { + var name = ts.getNameForExportedSymbol(ts.getLocalSymbolForExportDefault(defaultInfo.symbol) || defaultInfo.symbol, target); + result.add(key(name, defaultInfo.symbol, moduleSymbol, checker), { symbol: defaultInfo.symbol, moduleSymbol: moduleSymbol, exportKind: defaultInfo.exportKind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(defaultInfo.symbol, checker), isFromPackageJson: isFromPackageJson }); + } + var seenExports = new ts.Map(); + for (var _i = 0, _a = checker.getExportsAndPropertiesOfModule(moduleSymbol); _i < _a.length; _i++) { + var exported = _a[_i]; + if (exported !== (defaultInfo === null || defaultInfo === void 0 ? void 0 : defaultInfo.symbol) && ts.addToSeen(seenExports, exported)) { + result.add(key(ts.getNameForExportedSymbol(exported, target), exported, moduleSymbol, checker), { symbol: exported, moduleSymbol: moduleSymbol, exportKind: 0 /* Named */, exportedSymbolIsTypeOnly: isTypeOnlySymbol(exported, checker), isFromPackageJson: isFromPackageJson }); + } + } + }); + if (cache) { + (_f = host.log) === null || _f === void 0 ? void 0 : _f.call(host, "getSymbolToExportInfoMap: caching results"); + cache.set(result, (_g = host.getProjectVersion) === null || _g === void 0 ? void 0 : _g.call(host)); + } + (_h = host.log) === null || _h === void 0 ? void 0 : _h.call(host, "getSymbolToExportInfoMap: done in " + (ts.timestamp() - start) + " ms"); + return result; + function key(name, alias, moduleSymbol, checker) { + var moduleName = ts.stripQuotes(moduleSymbol.name); + var moduleKey = ts.isExternalModuleNameRelative(moduleName) ? "/" : moduleName; + return name + "|" + ts.getSymbolId(ts.skipAlias(alias, checker)) + "|" + moduleKey; + } + } + codefix.getSymbolToExportInfoMap = getSymbolToExportInfoMap; function isTypeOnlySymbol(s, checker) { return !(ts.skipAlias(s, checker).flags & 111551 /* Value */); } function isTypeOnlyPosition(sourceFile, position) { return ts.isValidTypeOnlyAliasUseSite(ts.getTokenAtPosition(sourceFile, position)); } - function getFixForImport(exportInfos, symbolName, + function getImportFixes(exportInfos, symbolName, /** undefined only for missing JSX namespace */ position, preferTypeOnlyImport, useRequire, program, sourceFile, host, preferences) { var checker = program.getTypeChecker(); - var existingImports = ts.flatMap(exportInfos, function (info) { return getExistingImportDeclarations(info, checker, sourceFile); }); + var existingImports = ts.flatMap(exportInfos, function (info) { return getExistingImportDeclarations(info, checker, sourceFile, program.getCompilerOptions()); }); var useNamespace = position === undefined ? undefined : tryUseExistingNamespaceImport(existingImports, symbolName, position, checker); var addToExisting = tryAddToExistingImport(existingImports, position !== undefined && isTypeOnlyPosition(sourceFile, position)); // Don't bother providing an action to add a new import if we can add to an existing one. @@ -138248,10 +143252,11 @@ var ts; return ts.firstDefined(existingImports, function (_a) { var declaration = _a.declaration; var namespacePrefix = getNamespaceLikeImportText(declaration); - if (namespacePrefix) { + var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration); + if (namespacePrefix && moduleSpecifier) { var moduleSymbol = getTargetModuleFromNamespaceLikeImport(declaration, checker); if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(symbolName))) { - return { kind: 0 /* UseNamespace */, namespacePrefix: namespacePrefix, position: position }; + return { kind: 0 /* UseNamespace */, namespacePrefix: namespacePrefix, position: position, moduleSpecifier: moduleSpecifier }; } } }); @@ -138259,11 +143264,11 @@ var ts; function getTargetModuleFromNamespaceLikeImport(declaration, checker) { var _a; switch (declaration.kind) { - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return checker.resolveExternalModuleName(declaration.initializer.arguments[0]); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return checker.getAliasedSymbol(declaration.symbol); - case 261 /* ImportDeclaration */: + case 263 /* 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: @@ -138273,11 +143278,11 @@ var ts; function getNamespaceLikeImportText(declaration) { var _a, _b, _c; switch (declaration.kind) { - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return (_a = ts.tryCast(declaration.name, ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text; - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return declaration.name.text; - case 261 /* ImportDeclaration */: + case 263 /* 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); @@ -138286,31 +143291,38 @@ var ts; function tryAddToExistingImport(existingImports, canUseTypeOnlyImport) { return ts.firstDefined(existingImports, function (_a) { var declaration = _a.declaration, importKind = _a.importKind; - if (declaration.kind === 260 /* ImportEqualsDeclaration */) + if (declaration.kind === 262 /* ImportEqualsDeclaration */) return undefined; - if (declaration.kind === 249 /* VariableDeclaration */) { - return (importKind === 0 /* Named */ || importKind === 1 /* Default */) && declaration.name.kind === 196 /* ObjectBindingPattern */ + if (declaration.kind === 251 /* VariableDeclaration */) { + return (importKind === 0 /* Named */ || importKind === 1 /* Default */) && declaration.name.kind === 198 /* ObjectBindingPattern */ ? { kind: 2 /* AddToExisting */, importClauseOrBindingPattern: declaration.name, importKind: importKind, moduleSpecifier: declaration.initializer.arguments[0].text, canUseTypeOnlyImport: false } : undefined; } var importClause = declaration.importClause; - if (!importClause) + if (!importClause || !ts.isStringLiteralLike(declaration.moduleSpecifier)) return undefined; var name = importClause.name, namedBindings = importClause.namedBindings; - return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 264 /* NamedImports */) - ? { kind: 2 /* AddToExisting */, importClauseOrBindingPattern: importClause, importKind: importKind, moduleSpecifier: declaration.moduleSpecifier.getText(), canUseTypeOnlyImport: canUseTypeOnlyImport } + // 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)) + return undefined; + return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 266 /* NamedImports */) + ? { kind: 2 /* AddToExisting */, importClauseOrBindingPattern: importClause, importKind: importKind, moduleSpecifier: declaration.moduleSpecifier.text, canUseTypeOnlyImport: canUseTypeOnlyImport } : undefined; }); } - function getExistingImportDeclarations(_a, checker, sourceFile) { - var moduleSymbol = _a.moduleSymbol, importKind = _a.importKind, exportedSymbolIsTypeOnly = _a.exportedSymbolIsTypeOnly; + function getExistingImportDeclarations(_a, checker, importingFile, compilerOptions) { + var moduleSymbol = _a.moduleSymbol, exportKind = _a.exportKind, exportedSymbolIsTypeOnly = _a.exportedSymbolIsTypeOnly; // Can't use an es6 import for a type in JS. - return exportedSymbolIsTypeOnly && ts.isSourceFileJS(sourceFile) ? ts.emptyArray : ts.mapDefined(sourceFile.imports, function (moduleSpecifier) { + if (exportedSymbolIsTypeOnly && ts.isSourceFileJS(importingFile)) + return ts.emptyArray; + var importKind = getImportKind(importingFile, exportKind, compilerOptions); + return ts.mapDefined(importingFile.imports, function (moduleSpecifier) { var i = ts.importFromModuleSpecifier(moduleSpecifier); - if (ts.isRequireVariableDeclaration(i.parent, /*requireStringLiteralLikeArgument*/ true)) { + if (ts.isRequireVariableDeclaration(i.parent)) { return checker.resolveExternalModuleName(moduleSpecifier) === moduleSymbol ? { declaration: i.parent, importKind: importKind } : undefined; } - if (i.kind === 261 /* ImportDeclaration */ || i.kind === 260 /* ImportEqualsDeclaration */) { + if (i.kind === 263 /* ImportDeclaration */ || i.kind === 262 /* ImportEqualsDeclaration */) { return checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind } : undefined; } }); @@ -138343,45 +143355,29 @@ var ts; // 5. Literally nothing to go on return true; } - function getNewImportInfos(program, sourceFile, position, preferTypeOnlyImport, useRequire, moduleSymbols, host, preferences) { + function getNewImportFixes(program, sourceFile, position, preferTypeOnlyImport, useRequire, moduleSymbols, host, preferences) { var isJs = ts.isSourceFileJS(sourceFile); var compilerOptions = program.getCompilerOptions(); - var allowsImportingSpecifier = createAutoImportFilter(sourceFile, program, host).allowsImportingSpecifier; - var choicesForEachExportingModule = ts.flatMap(moduleSymbols, function (_a) { - var moduleSymbol = _a.moduleSymbol, importKind = _a.importKind, exportedSymbolIsTypeOnly = _a.exportedSymbolIsTypeOnly; - return ts.moduleSpecifiers.getModuleSpecifiers(moduleSymbol, program.getTypeChecker(), compilerOptions, sourceFile, ts.createModuleSpecifierResolutionHost(program, host), preferences) + var moduleSpecifierResolutionHost = ts.createModuleSpecifierResolutionHost(program, host); + return ts.flatMap(moduleSymbols, function (exportInfo) { + return ts.moduleSpecifiers.getModuleSpecifiers(exportInfo.moduleSymbol, program.getTypeChecker(), compilerOptions, sourceFile, moduleSpecifierResolutionHost, preferences) .map(function (moduleSpecifier) { // `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types. - return exportedSymbolIsTypeOnly && isJs - ? { kind: 1 /* ImportType */, moduleSpecifier: moduleSpecifier, position: ts.Debug.checkDefined(position, "position should be defined") } - : { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind, useRequire: useRequire, typeOnly: preferTypeOnlyImport }; + return exportInfo.exportedSymbolIsTypeOnly && isJs && position !== undefined + ? { kind: 1 /* ImportType */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo } + : { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: getImportKind(sourceFile, exportInfo.exportKind, compilerOptions), useRequire: useRequire, typeOnly: preferTypeOnlyImport, exportInfo: exportInfo }; }); }); - // Sort by presence in package.json, then shortest paths first - return ts.sort(choicesForEachExportingModule, function (a, b) { - var allowsImportingA = allowsImportingSpecifier(a.moduleSpecifier); - var allowsImportingB = allowsImportingSpecifier(b.moduleSpecifier); - if (allowsImportingA && !allowsImportingB) { - return -1; - } - if (allowsImportingB && !allowsImportingA) { - return 1; - } - return a.moduleSpecifier.length - b.moduleSpecifier.length; - }); } function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, preferTypeOnlyImport, useRequire, host, preferences) { var existingDeclaration = ts.firstDefined(existingImports, function (info) { return newImportInfoFromExistingSpecifier(info, preferTypeOnlyImport, useRequire); }); - return existingDeclaration ? [existingDeclaration] : getNewImportInfos(program, sourceFile, position, preferTypeOnlyImport, useRequire, exportInfos, host, preferences); + return existingDeclaration ? [existingDeclaration] : getNewImportFixes(program, sourceFile, position, preferTypeOnlyImport, useRequire, exportInfos, host, preferences); } function newImportInfoFromExistingSpecifier(_a, preferTypeOnlyImport, useRequire) { var declaration = _a.declaration, importKind = _a.importKind; - var moduleSpecifier = declaration.kind === 261 /* ImportDeclaration */ ? declaration.moduleSpecifier : - declaration.kind === 249 /* VariableDeclaration */ ? declaration.initializer.arguments[0] : - declaration.moduleReference.kind === 272 /* ExternalModuleReference */ ? declaration.moduleReference.expression : - undefined; - return moduleSpecifier && ts.isStringLiteral(moduleSpecifier) - ? { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier.text, importKind: importKind, typeOnly: preferTypeOnlyImport, useRequire: useRequire } + var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration); + return moduleSpecifier + ? { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind, typeOnly: preferTypeOnlyImport, useRequire: useRequire } : undefined; } function getFixesInfo(context, errorCode, pos, useAutoImportProvider) { @@ -138389,7 +143385,28 @@ var ts; var info = errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code ? getFixesInfoForUMDImport(context, symbolToken) : ts.isIdentifier(symbolToken) ? getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider) : undefined; - return info && __assign(__assign({}, info), { fixes: ts.sort(info.fixes, function (a, b) { return a.kind - b.kind; }) }); + return info && __assign(__assign({}, info), { fixes: sortFixes(info.fixes, context.sourceFile, context.host) }); + } + function sortFixes(fixes, sourceFile, host) { + var allowsImportingSpecifier = ts.createPackageJsonImportFilter(sourceFile, host).allowsImportingSpecifier; + return ts.sort(fixes, function (a, b) { return ts.compareValues(a.kind, b.kind) || compareModuleSpecifiers(a, b, allowsImportingSpecifier); }); + } + function getBestFix(fixes, sourceFile, host) { + // 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 */) { + return fixes[0]; + } + var allowsImportingSpecifier = ts.createPackageJsonImportFilter(sourceFile, host).allowsImportingSpecifier; + return fixes.reduce(function (best, fix) { + return compareModuleSpecifiers(fix, best, allowsImportingSpecifier) === -1 /* LessThan */ ? fix : best; + }); + } + function compareModuleSpecifiers(a, b, allowsImportingSpecifier) { + if (a.kind !== 0 /* UseNamespace */ && b.kind !== 0 /* UseNamespace */) { + return ts.compareBooleans(allowsImportingSpecifier(a.moduleSpecifier), allowsImportingSpecifier(b.moduleSpecifier)) + || ts.compareNumberOfDirectorySeparators(a.moduleSpecifier, b.moduleSpecifier); + } + return 0 /* EqualTo */; } function getFixesInfoForUMDImport(_a, token) { var sourceFile = _a.sourceFile, program = _a.program, host = _a.host, preferences = _a.preferences; @@ -138399,9 +143416,9 @@ var ts; return undefined; var symbol = checker.getAliasedSymbol(umdSymbol); var symbolName = umdSymbol.name; - var exportInfos = [{ moduleSymbol: symbol, importKind: getUmdImportKind(sourceFile, program.getCompilerOptions()), exportedSymbolIsTypeOnly: false }]; + var exportInfos = [{ symbol: umdSymbol, moduleSymbol: symbol, exportKind: 3 /* UMD */, exportedSymbolIsTypeOnly: false, isFromPackageJson: false }]; var useRequire = shouldUseRequire(sourceFile, program); - var fixes = getFixForImport(exportInfos, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, /*preferTypeOnlyImport*/ false, useRequire, program, sourceFile, host, preferences); + var fixes = getImportFixes(exportInfos, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, /*preferTypeOnlyImport*/ false, useRequire, program, sourceFile, host, preferences); return { fixes: fixes, symbolName: symbolName }; } function getUmdSymbol(token, checker) { @@ -138415,6 +143432,16 @@ var ts; ? ts.tryCast(checker.resolveName(checker.getJsxNamespace(parent), ts.isJsxOpeningLikeElement(parent) ? token : parent, 111551 /* Value */, /*excludeGlobals*/ false), ts.isUMDExportSymbol) : undefined; } + function getImportKind(importingFile, exportKind, compilerOptions) { + switch (exportKind) { + case 0 /* Named */: return 0 /* Named */; + case 1 /* Default */: return 1 /* Default */; + case 2 /* ExportEquals */: return getExportEqualsImportKind(importingFile, compilerOptions); + case 3 /* UMD */: return getUmdImportKind(importingFile, compilerOptions); + default: return ts.Debug.assertNever(exportKind); + } + } + codefix.getImportKind = getImportKind; function getUmdImportKind(importingFile, compilerOptions) { // Import a synthetic `default` if enabled. if (ts.getAllowSyntheticDefaultImports(compilerOptions)) { @@ -138444,22 +143471,22 @@ var ts; function getFixesInfoForNonUMDImport(_a, symbolToken, useAutoImportProvider) { var sourceFile = _a.sourceFile, program = _a.program, cancellationToken = _a.cancellationToken, host = _a.host, preferences = _a.preferences; var checker = program.getTypeChecker(); - var symbolName = getSymbolName(sourceFile, checker, symbolToken); + var compilerOptions = program.getCompilerOptions(); + var symbolName = getSymbolName(sourceFile, checker, symbolToken, compilerOptions); // "default" is a keyword and not a legal identifier for the import, so we don't expect it here ts.Debug.assert(symbolName !== "default" /* Default */, "'default' isn't a legal identifier and couldn't occur here"); - var compilerOptions = program.getCompilerOptions(); var preferTypeOnlyImport = compilerOptions.importsNotUsedAsValues === 2 /* Error */ && ts.isValidTypeOnlyAliasUseSite(symbolToken); var useRequire = shouldUseRequire(sourceFile, program); var exportInfos = getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host); var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfos.entries(), function (_a) { var _ = _a[0], exportInfos = _a[1]; - return getFixForImport(exportInfos, symbolName, symbolToken.getStart(sourceFile), preferTypeOnlyImport, useRequire, program, sourceFile, host, preferences); + return getImportFixes(exportInfos, symbolName, symbolToken.getStart(sourceFile), preferTypeOnlyImport, useRequire, program, sourceFile, host, preferences); })); return { fixes: fixes, symbolName: symbolName }; } - function getSymbolName(sourceFile, checker, symbolToken) { + function getSymbolName(sourceFile, checker, symbolToken, compilerOptions) { var parent = symbolToken.parent; - if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken) { + if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken && compilerOptions.jsx !== 4 /* ReactJSX */ && compilerOptions.jsx !== 5 /* ReactJSXDev */) { var jsxNamespace = checker.getJsxNamespace(sourceFile); if (ts.isIntrinsicJsxName(symbolToken.text) || !checker.resolveName(jsxNamespace, parent, 111551 /* Value */, /*excludeGlobals*/ true)) { return jsxNamespace; @@ -138468,43 +143495,55 @@ var ts; return symbolToken.text; } // Returns a map from an exported symbol's ID to a list of every way it's (re-)exported. - function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, sourceFile, program, useAutoImportProvider, host) { + function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, fromFile, program, useAutoImportProvider, host) { + var _a; // For each original symbol, keep all re-exports of that symbol together so we can call `getCodeActionsForImport` on the whole group at once. // Maps symbol id to info for modules providing that symbol (original export + re-exports). var originalSymbolToExportInfos = ts.createMultiMap(); - function addSymbol(moduleSymbol, exportedSymbol, importKind, checker) { - originalSymbolToExportInfos.add(ts.getUniqueSymbolId(exportedSymbol, checker).toString(), { moduleSymbol: moduleSymbol, importKind: importKind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(exportedSymbol, checker) }); + var packageJsonFilter = ts.createPackageJsonImportFilter(fromFile, host); + var moduleSpecifierCache = (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host); + var getModuleSpecifierResolutionHost = ts.memoizeOne(function (isFromPackageJson) { + return ts.createModuleSpecifierResolutionHost(isFromPackageJson ? host.getPackageJsonAutoImportProvider() : program, host); + }); + function addSymbol(moduleSymbol, toFile, exportedSymbol, exportKind, program, isFromPackageJson) { + var moduleSpecifierResolutionHost = getModuleSpecifierResolutionHost(isFromPackageJson); + if (toFile && ts.isImportableFile(program, fromFile, toFile, packageJsonFilter, moduleSpecifierResolutionHost, moduleSpecifierCache) || + !toFile && packageJsonFilter.allowsImportingAmbientModule(moduleSymbol, moduleSpecifierResolutionHost)) { + var checker = program.getTypeChecker(); + originalSymbolToExportInfos.add(ts.getUniqueSymbolId(exportedSymbol, checker).toString(), { symbol: exportedSymbol, moduleSymbol: moduleSymbol, exportKind: exportKind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(exportedSymbol, checker), isFromPackageJson: isFromPackageJson }); + } } - forEachExternalModuleToImportFrom(program, host, sourceFile, /*filterByPackageJson*/ true, useAutoImportProvider, function (moduleSymbol, _, program) { + forEachExternalModuleToImportFrom(program, host, useAutoImportProvider, function (moduleSymbol, sourceFile, program, isFromPackageJson) { var checker = program.getTypeChecker(); cancellationToken.throwIfCancellationRequested(); var compilerOptions = program.getCompilerOptions(); - var defaultInfo = getDefaultLikeExportInfo(sourceFile, moduleSymbol, checker, compilerOptions); + var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, compilerOptions.target) === symbolName) && symbolHasMeaning(defaultInfo.symbolForMeaning, currentTokenMeaning)) { - addSymbol(moduleSymbol, defaultInfo.symbol, defaultInfo.kind, checker); + addSymbol(moduleSymbol, sourceFile, defaultInfo.symbol, defaultInfo.exportKind, program, isFromPackageJson); } // check exports with the same name var exportSymbolWithIdenticalName = checker.tryGetMemberInModuleExportsAndProperties(symbolName, moduleSymbol); if (exportSymbolWithIdenticalName && symbolHasMeaning(exportSymbolWithIdenticalName, currentTokenMeaning)) { - addSymbol(moduleSymbol, exportSymbolWithIdenticalName, 0 /* Named */, checker); + addSymbol(moduleSymbol, sourceFile, exportSymbolWithIdenticalName, 0 /* Named */, program, isFromPackageJson); } }); return originalSymbolToExportInfos; } - function getDefaultLikeExportInfo(importingFile, moduleSymbol, checker, compilerOptions) { - var exported = getDefaultLikeExportWorker(importingFile, moduleSymbol, checker, compilerOptions); + function getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions) { + var exported = getDefaultLikeExportWorker(moduleSymbol, checker); if (!exported) return undefined; - var symbol = exported.symbol, kind = exported.kind; - var info = getDefaultExportInfoWorker(symbol, moduleSymbol, checker, compilerOptions); - return info && __assign({ symbol: symbol, kind: kind }, info); + var symbol = exported.symbol, exportKind = exported.exportKind; + var info = getDefaultExportInfoWorker(symbol, checker, compilerOptions); + return info && __assign({ symbol: symbol, exportKind: exportKind }, info); } - function getDefaultLikeExportWorker(importingFile, moduleSymbol, checker, compilerOptions) { + 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); if (defaultExport) - return { symbol: defaultExport, kind: 1 /* Default */ }; - var exportEquals = checker.resolveExternalModuleSymbol(moduleSymbol); - return exportEquals === moduleSymbol ? undefined : { symbol: exportEquals, kind: getExportEqualsImportKind(importingFile, compilerOptions) }; + return { symbol: defaultExport, exportKind: 1 /* Default */ }; } function getExportEqualsImportKind(importingFile, compilerOptions) { var allowSyntheticDefaults = ts.getAllowSyntheticDefaultImports(compilerOptions); @@ -138523,7 +143562,8 @@ var ts; // on how to handle it. for (var _i = 0, _a = importingFile.statements; _i < _a.length; _i++) { var statement = _a[_i]; - if (ts.isImportEqualsDeclaration(statement)) { + // `import foo` parses as an ImportEqualsDeclaration even though it could be an ImportDeclaration + if (ts.isImportEqualsDeclaration(statement) && !ts.nodeIsMissing(statement.moduleReference)) { return 3 /* CommonJS */; } } @@ -138531,7 +143571,7 @@ var ts; // allowSyntheticDefaultImports/esModuleInterop is enabled. return allowSyntheticDefaults ? 1 /* Default */ : 3 /* CommonJS */; } - function getDefaultExportInfoWorker(defaultExport, moduleSymbol, checker, compilerOptions) { + function getDefaultExportInfoWorker(defaultExport, checker, compilerOptions) { var localSymbol = ts.getLocalSymbolForExportDefault(defaultExport); if (localSymbol) return { symbolForMeaning: localSymbol, name: localSymbol.name }; @@ -138545,21 +143585,20 @@ var ts; // but we can still offer completions for it. // - `aliased.parent` will be undefined if the module is exporting `globalThis.something`, // or another expression that resolves to a global. - return getDefaultExportInfoWorker(aliased, aliased.parent, checker, compilerOptions); + return getDefaultExportInfoWorker(aliased, checker, compilerOptions); } } if (defaultExport.escapedName !== "default" /* Default */ && defaultExport.escapedName !== "export=" /* ExportEquals */) { return { symbolForMeaning: defaultExport, name: defaultExport.getName() }; } - return { symbolForMeaning: defaultExport, name: moduleSymbolToValidIdentifier(moduleSymbol, compilerOptions.target) }; + return { symbolForMeaning: defaultExport, name: ts.getNameForExportedSymbol(defaultExport, compilerOptions.target) }; } function getNameForExportDefault(symbol) { return symbol.declarations && ts.firstDefined(symbol.declarations, function (declaration) { + var _a; if (ts.isExportAssignment(declaration)) { - if (ts.isIdentifier(declaration.expression)) { - return declaration.expression.text; - } + 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"); @@ -138602,7 +143641,7 @@ var ts; } } function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports, canUseTypeOnlyImport) { - if (clause.kind === 196 /* ObjectBindingPattern */) { + if (clause.kind === 198 /* ObjectBindingPattern */) { if (defaultImport) { addElementToBindingPattern(clause, defaultImport, "default"); } @@ -138729,48 +143768,23 @@ var ts; var declarations = _a.declarations; return ts.some(declarations, function (decl) { return !!(ts.getMeaningFromDeclaration(decl) & meaning); }); } - function forEachExternalModuleToImportFrom(program, host, from, filterByPackageJson, useAutoImportProvider, cb) { + function forEachExternalModuleToImportFrom(program, host, useAutoImportProvider, cb) { var _a, _b; - forEachExternalModuleToImportFromInProgram(program, host, from, filterByPackageJson, function (module, file) { return cb(module, file, program, /*isFromPackageJson*/ false); }); + forEachExternalModule(program.getTypeChecker(), program.getSourceFiles(), function (module, file) { return cb(module, file, program, /*isFromPackageJson*/ false); }); var autoImportProvider = useAutoImportProvider && ((_a = host.getPackageJsonAutoImportProvider) === null || _a === void 0 ? void 0 : _a.call(host)); if (autoImportProvider) { var start = ts.timestamp(); - forEachExternalModuleToImportFromInProgram(autoImportProvider, host, from, filterByPackageJson, function (module, file) { return cb(module, file, autoImportProvider, /*isFromPackageJson*/ true); }); + forEachExternalModule(autoImportProvider.getTypeChecker(), autoImportProvider.getSourceFiles(), 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)); } } codefix.forEachExternalModuleToImportFrom = forEachExternalModuleToImportFrom; - function forEachExternalModuleToImportFromInProgram(program, host, from, filterByPackageJson, cb) { - var _a; - var filteredCount = 0; - var moduleSpecifierResolutionHost = ts.createModuleSpecifierResolutionHost(program, host); - var packageJson = filterByPackageJson && createAutoImportFilter(from, program, host, moduleSpecifierResolutionHost); - forEachExternalModule(program.getTypeChecker(), program.getSourceFiles(), function (module, sourceFile) { - if (sourceFile === undefined) { - if (!packageJson || packageJson.allowsImportingAmbientModule(module)) { - cb(module, sourceFile); - } - else if (packageJson) { - filteredCount++; - } - } - else if (sourceFile && - sourceFile !== from && - isImportableFile(program, from, sourceFile, moduleSpecifierResolutionHost)) { - if (!packageJson || packageJson.allowsImportingSourceFile(sourceFile)) { - cb(module, sourceFile); - } - else if (packageJson) { - filteredCount++; - } - } - }); - (_a = host.log) === null || _a === void 0 ? void 0 : _a.call(host, "forEachExternalModuleToImportFrom: filtered out " + filteredCount + " modules by package.json contents"); - } function forEachExternalModule(checker, allSourceFiles, cb) { for (var _i = 0, _a = checker.getAmbientModules(); _i < _a.length; _i++) { var ambient = _a[_i]; - cb(ambient, /*sourceFile*/ undefined); + if (!ts.stringContains(ambient.name, "*")) { + cb(ambient, /*sourceFile*/ undefined); + } } for (var _b = 0, allSourceFiles_1 = allSourceFiles; _b < allSourceFiles_1.length; _b++) { var sourceFile = allSourceFiles_1[_b]; @@ -138779,31 +143793,6 @@ var ts; } } } - function isImportableFile(program, from, to, moduleSpecifierResolutionHost) { - var _a; - var getCanonicalFileName = ts.hostGetCanonicalFileName(moduleSpecifierResolutionHost); - var globalTypingsCache = (_a = moduleSpecifierResolutionHost.getGlobalTypingsCacheLocation) === null || _a === void 0 ? void 0 : _a.call(moduleSpecifierResolutionHost); - return !!ts.moduleSpecifiers.forEachFileNameOfModule(from.fileName, to.fileName, moduleSpecifierResolutionHost, - /*preferSymlinks*/ false, function (toPath) { - var toFile = program.getSourceFile(toPath); - // Determine to import using toPath only if toPath is what we were looking at - // or there doesnt exist the file in the program by the symlink - return (toFile === to || !toFile) && - isImportablePath(from.fileName, toPath, getCanonicalFileName, globalTypingsCache); - }); - } - /** - * Don't include something from a `node_modules` that isn't actually reachable by a global import. - * A relative import to node_modules is usually a bad idea. - */ - function isImportablePath(fromPath, toPath, getCanonicalFileName, globalCachePath) { - // If it's in a `node_modules` but is not reachable from here via a global import, don't bother. - var toNodeModules = ts.forEachAncestorDirectory(toPath, function (ancestor) { return ts.getBaseFileName(ancestor) === "node_modules" ? ancestor : undefined; }); - var toNodeModulesParent = toNodeModules && ts.getDirectoryPath(getCanonicalFileName(toNodeModules)); - return toNodeModulesParent === undefined - || ts.startsWith(getCanonicalFileName(fromPath), toNodeModulesParent) - || (!!globalCachePath && ts.startsWith(getCanonicalFileName(globalCachePath), toNodeModulesParent)); - } function moduleSymbolToValidIdentifier(moduleSymbol, target) { return moduleSpecifierToValidIdentifier(ts.removeFileExtension(ts.stripQuotes(moduleSymbol.name)), target); } @@ -138835,99 +143824,122 @@ var ts; return !ts.isStringANonContextualKeyword(res) ? res || "_" : "_" + res; } codefix.moduleSpecifierToValidIdentifier = moduleSpecifierToValidIdentifier; - function createAutoImportFilter(fromFile, program, host, moduleSpecifierResolutionHost) { - if (moduleSpecifierResolutionHost === void 0) { moduleSpecifierResolutionHost = ts.createModuleSpecifierResolutionHost(program, host); } - var packageJsons = ((host.getPackageJsonsVisibleToFile && host.getPackageJsonsVisibleToFile(fromFile.fileName)) || ts.getPackageJsonsVisibleToFile(fromFile.fileName, host)).filter(function (p) { return p.parseable; }); - var usesNodeCoreModules; - return { allowsImportingAmbientModule: allowsImportingAmbientModule, allowsImportingSourceFile: allowsImportingSourceFile, allowsImportingSpecifier: allowsImportingSpecifier, moduleSpecifierResolutionHost: moduleSpecifierResolutionHost }; - function moduleSpecifierIsCoveredByPackageJson(specifier) { - var packageName = getNodeModuleRootSpecifier(specifier); - for (var _i = 0, packageJsons_1 = packageJsons; _i < packageJsons_1.length; _i++) { - var packageJson = packageJsons_1[_i]; - if (packageJson.has(packageName) || packageJson.has(ts.getTypesPackageName(packageName))) { - return true; + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var codefix; + (function (codefix) { + var _a; + var fixName = "fixOverrideModifier"; + var fixAddOverrideId = "fixAddOverrideModifier"; + var fixRemoveOverrideId = "fixRemoveOverrideModifier"; + var errorCodes = [ + ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0.code, + ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class.code, + ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0.code, + ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0.code, + ts.Diagnostics.This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0.code + ]; + var errorCodeFixIdMap = (_a = {}, + _a[ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0.code] = [ + ts.Diagnostics.Add_override_modifier, fixAddOverrideId, ts.Diagnostics.Add_all_missing_override_modifiers, + ], + _a[ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class.code] = [ + ts.Diagnostics.Remove_override_modifier, fixRemoveOverrideId, ts.Diagnostics.Remove_all_unnecessary_override_modifiers + ], + _a[ts.Diagnostics.This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0.code] = [ + ts.Diagnostics.Add_override_modifier, fixAddOverrideId, ts.Diagnostics.Add_all_missing_override_modifiers, + ], + _a[ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0.code] = [ + ts.Diagnostics.Add_override_modifier, fixAddOverrideId, ts.Diagnostics.Remove_all_unnecessary_override_modifiers + ], + _a[ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0.code] = [ + ts.Diagnostics.Remove_override_modifier, fixRemoveOverrideId, ts.Diagnostics.Remove_all_unnecessary_override_modifiers + ], + _a); + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var errorCode = context.errorCode, span = context.span, sourceFile = context.sourceFile; + var info = errorCodeFixIdMap[errorCode]; + if (!info) + return ts.emptyArray; + var descriptions = info[0], fixId = info[1], fixAllDescriptions = info[2]; + if (ts.isSourceFileJS(sourceFile)) + return ts.emptyArray; + var changes = ts.textChanges.ChangeTracker.with(context, function (changes) { return dispatchChanges(changes, context, errorCode, span.start); }); + return [ + codefix.createCodeFixActionMaybeFixAll(fixName, changes, descriptions, fixId, fixAllDescriptions) + ]; + }, + fixIds: [fixName, fixAddOverrideId, fixRemoveOverrideId], + getAllCodeActions: function (context) { + return codefix.codeFixAll(context, errorCodes, function (changes, diag) { + var code = diag.code, start = diag.start, file = diag.file; + var info = errorCodeFixIdMap[code]; + if (!info || info[1] !== context.fixId || ts.isSourceFileJS(file)) { + return; } - } - return false; - } - function allowsImportingAmbientModule(moduleSymbol) { - if (!packageJsons.length) { - return true; - } - var declaringSourceFile = moduleSymbol.valueDeclaration.getSourceFile(); - var declaringNodeModuleName = getNodeModulesPackageNameFromFileName(declaringSourceFile.fileName); - if (typeof declaringNodeModuleName === "undefined") { - return true; - } - var declaredModuleSpecifier = ts.stripQuotes(moduleSymbol.getName()); - if (isAllowedCoreNodeModulesImport(declaredModuleSpecifier)) { - return true; - } - return moduleSpecifierIsCoveredByPackageJson(declaringNodeModuleName) - || moduleSpecifierIsCoveredByPackageJson(declaredModuleSpecifier); - } - function allowsImportingSourceFile(sourceFile) { - if (!packageJsons.length) { - return true; - } - var moduleSpecifier = getNodeModulesPackageNameFromFileName(sourceFile.fileName); - if (!moduleSpecifier) { - return true; - } - return moduleSpecifierIsCoveredByPackageJson(moduleSpecifier); + dispatchChanges(changes, context, code, start); + }); } - /** - * Use for a specific module specifier that has already been resolved. - * Use `allowsImportingAmbientModule` or `allowsImportingSourceFile` to resolve - * the best module specifier for a given module _and_ determine if it’s importable. - */ - function allowsImportingSpecifier(moduleSpecifier) { - if (!packageJsons.length || isAllowedCoreNodeModulesImport(moduleSpecifier)) { - return true; - } - if (ts.pathIsRelative(moduleSpecifier) || ts.isRootedDiskPath(moduleSpecifier)) { + }); + function dispatchChanges(changeTracker, context, errorCode, pos) { + switch (errorCode) { + case ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0.code: + case ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0.code: + case ts.Diagnostics.This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0.code: + return doAddOverrideModifierChange(changeTracker, context.sourceFile, pos); + case ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0.code: + case ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class.code: + return doRemoveOverrideModifierChange(changeTracker, context.sourceFile, pos); + default: + ts.Debug.fail("Unexpected error code: " + errorCode); + } + } + function doAddOverrideModifierChange(changeTracker, sourceFile, pos) { + var classElement = findContainerClassElementLike(sourceFile, pos); + var modifiers = classElement.modifiers || ts.emptyArray; + var staticModifier = ts.find(modifiers, ts.isStaticModifier); + var accessibilityModifier = ts.find(modifiers, function (m) { return ts.isAccessibilityModifier(m.kind); }); + var modifierPos = staticModifier ? staticModifier.end : + accessibilityModifier ? accessibilityModifier.end : + classElement.decorators ? ts.skipTrivia(sourceFile.text, classElement.decorators.end) : classElement.getStart(sourceFile); + var options = accessibilityModifier || staticModifier ? { prefix: " " } : { suffix: " " }; + changeTracker.insertModifierAt(sourceFile, modifierPos, 157 /* OverrideKeyword */, options); + } + function doRemoveOverrideModifierChange(changeTracker, sourceFile, pos) { + var classElement = findContainerClassElementLike(sourceFile, pos); + var overrideModifier = classElement.modifiers && ts.find(classElement.modifiers, function (modifier) { return modifier.kind === 157 /* OverrideKeyword */; }); + ts.Debug.assertIsDefined(overrideModifier); + changeTracker.deleteModifier(sourceFile, overrideModifier); + } + function isClassElementLikeHasJSDoc(node) { + switch (node.kind) { + case 168 /* Constructor */: + case 165 /* PropertyDeclaration */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return true; - } - return moduleSpecifierIsCoveredByPackageJson(moduleSpecifier); - } - function isAllowedCoreNodeModulesImport(moduleSpecifier) { - // If we’re in JavaScript, it can be difficult to tell whether the user wants to import - // from Node core modules or not. We can start by seeing if the user is actually using - // any node core modules, as opposed to simply having @types/node accidentally as a - // dependency of a dependency. - if (ts.isSourceFileJS(fromFile) && ts.JsTyping.nodeCoreModules.has(moduleSpecifier)) { - if (usesNodeCoreModules === undefined) { - usesNodeCoreModules = ts.consumesNodeCoreModules(fromFile); - } - if (usesNodeCoreModules) { - return true; - } - } - return false; - } - function getNodeModulesPackageNameFromFileName(importedFileName) { - if (!ts.stringContains(importedFileName, "node_modules")) { - return undefined; - } - var specifier = ts.moduleSpecifiers.getNodeModulesPackageName(host.getCompilationSettings(), fromFile.path, importedFileName, moduleSpecifierResolutionHost); - if (!specifier) { - return undefined; - } - // Paths here are not node_modules, so we don’t care about them; - // returning anything will trigger a lookup in package.json. - if (!ts.pathIsRelative(specifier) && !ts.isRootedDiskPath(specifier)) { - return getNodeModuleRootSpecifier(specifier); - } - } - function getNodeModuleRootSpecifier(fullSpecifier) { - var components = ts.getPathComponents(ts.getPackageNameFromTypesPackageName(fullSpecifier)).slice(1); - // Scoped packages - if (ts.startsWith(components[0], "@")) { - return components[0] + "/" + components[1]; - } - return components[0]; + case 162 /* Parameter */: + return ts.isParameterPropertyDeclaration(node, node.parent); + default: + return false; } } + function findContainerClassElementLike(sourceFile, pos) { + var token = ts.getTokenAtPosition(sourceFile, pos); + var classElement = ts.findAncestor(token, function (node) { + if (ts.isClassLike(node)) + return "quit"; + return isClassElementLikeHasJSDoc(node); + }); + ts.Debug.assert(classElement && isClassElementLikeHasJSDoc(classElement)); + return classElement; + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -138988,12 +144000,12 @@ var ts; }); function doChange(changes, sourceFile, pos, checker) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 107 /* ThisKeyword */); + ts.Debug.assert(token.kind === 108 /* ThisKeyword */); var fn = ts.getThisContainer(token, /*includeArrowFunctions*/ false); 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.assertDefined(ts.findChildOfKind(fn, 97 /* FunctionKeyword */, sourceFile)); + var fnKeyword = ts.Debug.assertDefined(ts.findChildOfKind(fn, 98 /* FunctionKeyword */, sourceFile)); var name = fn.name; var body = ts.Debug.assertDefined(fn.body); // Should be defined because the function contained a 'this' expression if (ts.isFunctionExpression(fn)) { @@ -139012,7 +144024,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(84 /* ConstKeyword */)); + changes.replaceNode(sourceFile, fnKeyword, ts.factory.createToken(85 /* ConstKeyword */)); changes.insertText(sourceFile, name.end, " = "); changes.insertText(sourceFile, body.pos, " =>"); return [ts.Diagnostics.Convert_function_declaration_0_to_arrow_function, name.text]; @@ -139043,7 +144055,7 @@ var ts; }); function getNamedTupleMember(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - return ts.findAncestor(token, function (t) { return t.kind === 192 /* NamedTupleMember */; }); + return ts.findAncestor(token, function (t) { return t.kind === 194 /* NamedTupleMember */; }); } function doChange(changes, sourceFile, namedTupleMember) { if (!namedTupleMember) { @@ -139052,11 +144064,11 @@ var ts; var unwrappedType = namedTupleMember.type; var sawOptional = false; var sawRest = false; - while (unwrappedType.kind === 180 /* OptionalType */ || unwrappedType.kind === 181 /* RestType */ || unwrappedType.kind === 186 /* ParenthesizedType */) { - if (unwrappedType.kind === 180 /* OptionalType */) { + while (unwrappedType.kind === 182 /* OptionalType */ || unwrappedType.kind === 183 /* RestType */ || unwrappedType.kind === 188 /* ParenthesizedType */) { + if (unwrappedType.kind === 182 /* OptionalType */) { sawOptional = true; } - else if (unwrappedType.kind === 181 /* RestType */) { + else if (unwrappedType.kind === 183 /* RestType */) { sawRest = true; } unwrappedType = unwrappedType.type; @@ -139120,7 +144132,7 @@ var ts; var checker = context.program.getTypeChecker(); var suggestedSymbol; if (ts.isPropertyAccessExpression(parent) && parent.name === node) { - ts.Debug.assert(ts.isIdentifierOrPrivateIdentifier(node), "Expected an identifier for spelling (property access)"); + ts.Debug.assert(ts.isMemberName(node), "Expected an identifier for spelling (property access)"); var containingType = checker.getTypeAtLocation(parent.expression); if (parent.flags & 32 /* OptionalChain */) { containingType = checker.getNonNullableType(containingType); @@ -139159,7 +144171,7 @@ var ts; var suggestion = ts.symbolName(suggestedSymbol); if (!ts.isIdentifierText(suggestion, target) && ts.isPropertyAccessExpression(node.parent)) { var valDecl = suggestedSymbol.valueDeclaration; - if (ts.isNamedDeclaration(valDecl) && ts.isPrivateIdentifier(valDecl.name)) { + if (valDecl && ts.isNamedDeclaration(valDecl) && ts.isPrivateIdentifier(valDecl.name)) { changes.replaceNode(sourceFile, node, ts.factory.createIdentifier(suggestion)); } else { @@ -139356,19 +144368,19 @@ var ts; } function getVariableLikeInitializer(declaration) { switch (declaration.kind) { - case 249 /* VariableDeclaration */: - case 160 /* Parameter */: - case 198 /* BindingElement */: - case 163 /* PropertyDeclaration */: - case 288 /* PropertyAssignment */: + case 251 /* VariableDeclaration */: + case 162 /* Parameter */: + case 200 /* BindingElement */: + case 165 /* PropertyDeclaration */: + case 290 /* PropertyAssignment */: return declaration.initializer; - case 280 /* JsxAttribute */: + case 282 /* JsxAttribute */: return declaration.initializer && (ts.isJsxExpression(declaration.initializer) ? declaration.initializer.expression : undefined); - case 289 /* ShorthandPropertyAssignment */: - case 162 /* PropertySignature */: - case 291 /* EnumMember */: - case 333 /* JSDocPropertyTag */: - case 326 /* JSDocParameterTag */: + case 291 /* ShorthandPropertyAssignment */: + case 164 /* PropertySignature */: + case 293 /* EnumMember */: + case 341 /* JSDocPropertyTag */: + case 334 /* JSDocParameterTag */: return undefined; } } @@ -139469,7 +144481,7 @@ var ts; }); typeDeclToMembers.forEach(function (infos, classDeclaration) { var supers = codefix.getAllSupers(classDeclaration, checker); - var _loop_13 = function (info) { + var _loop_14 = function (info) { // If some superclass added this property, don't add it again. if (supers.some(function (superClassOrInterface) { var superInfos = typeDeclToMembers.get(superClassOrInterface); @@ -139494,9 +144506,9 @@ var ts; } } }; - for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) { - var info = infos_1[_i]; - _loop_13(info); + for (var _i = 0, infos_2 = infos; _i < infos_2.length; _i++) { + var info = infos_2[_i]; + _loop_14(info); } }); })); @@ -139586,7 +144598,7 @@ var ts; function addMissingMemberInJs(changeTracker, declSourceFile, classDeclaration, token, makeStatic) { var tokenName = token.text; if (makeStatic) { - if (classDeclaration.kind === 221 /* ClassExpression */) { + if (classDeclaration.kind === 223 /* ClassExpression */) { return; } var className = classDeclaration.name.getText(); @@ -139638,17 +144650,17 @@ var ts; } function getTypeNode(checker, classDeclaration, token) { var typeNode; - if (token.parent.parent.kind === 216 /* BinaryExpression */) { + if (token.parent.parent.kind === 218 /* 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, classDeclaration, /*flags*/ undefined); + typeNode = checker.typeToTypeNode(widenedType, classDeclaration, 1 /* NoTruncation */); } else { var contextualType = checker.getContextualType(token.parent); - typeNode = contextualType ? checker.typeToTypeNode(contextualType, /*enclosingDeclaration*/ undefined, /*flags*/ undefined) : undefined; + typeNode = contextualType ? checker.typeToTypeNode(contextualType, /*enclosingDeclaration*/ undefined, 1 /* NoTruncation */) : undefined; } - return typeNode || ts.factory.createKeywordTypeNode(128 /* AnyKeyword */); + return typeNode || ts.factory.createKeywordTypeNode(129 /* AnyKeyword */); } function addPropertyDeclaration(changeTracker, declSourceFile, classDeclaration, tokenName, typeNode, modifierFlags) { var property = ts.factory.createPropertyDeclaration( @@ -139677,7 +144689,7 @@ var ts; } function createAddIndexSignatureAction(context, declSourceFile, classDeclaration, tokenName, typeNode) { // Index signatures cannot have the static modifier. - var stringTypeNode = ts.factory.createKeywordTypeNode(147 /* StringKeyword */); + var stringTypeNode = ts.factory.createKeywordTypeNode(148 /* StringKeyword */); var indexingParameter = ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -139710,7 +144722,7 @@ var ts; } function addMethodDeclaration(context, changes, callExpression, name, modifierFlags, parentDeclaration, sourceFile) { var importAdder = codefix.createImportAdder(sourceFile, context.program, context.preferences, context.host); - var methodDeclaration = codefix.createSignatureDeclarationFromCallExpression(165 /* MethodDeclaration */, context, importAdder, callExpression, name, modifierFlags, parentDeclaration); + var methodDeclaration = codefix.createSignatureDeclarationFromCallExpression(167 /* MethodDeclaration */, context, importAdder, callExpression, name, modifierFlags, parentDeclaration); var containingMethodDeclaration = ts.findAncestor(callExpression, function (n) { return ts.isMethodDeclaration(n) || ts.isConstructorDeclaration(n); }); if (containingMethodDeclaration && containingMethodDeclaration.parent === parentDeclaration) { changes.insertNodeAfter(sourceFile, containingMethodDeclaration, methodDeclaration); @@ -139739,7 +144751,7 @@ var ts; } function addFunctionDeclaration(changes, context, info) { var importAdder = codefix.createImportAdder(context.sourceFile, context.program, context.preferences, context.host); - var functionDeclaration = codefix.createSignatureDeclarationFromCallExpression(251 /* FunctionDeclaration */, context, importAdder, info.call, info.token, info.modifierFlags, info.parentDeclaration); + var functionDeclaration = codefix.createSignatureDeclarationFromCallExpression(253 /* FunctionDeclaration */, context, importAdder, info.call, ts.idText(info.token), info.modifierFlags, info.parentDeclaration); changes.insertNodeAtEndOfScope(info.sourceFile, info.parentDeclaration, functionDeclaration); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -139826,7 +144838,10 @@ var ts; return { type: "install package", file: fileName, packageName: packageName }; } function tryGetImportedPackageName(sourceFile, pos) { - var moduleName = ts.cast(ts.getTokenAtPosition(sourceFile, pos), ts.isStringLiteral).text; + var moduleSpecifierText = ts.tryCast(ts.getTokenAtPosition(sourceFile, pos), ts.isStringLiteral); + if (!moduleSpecifierText) + return undefined; + var moduleName = moduleSpecifierText.text; var packageName = ts.parsePackageName(moduleName).packageName; return ts.isExternalModuleNameRelative(packageName) ? undefined : packageName; } @@ -139932,7 +144947,7 @@ var ts; } function getNodes(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - if (token.kind !== 107 /* ThisKeyword */) + if (token.kind !== 108 /* ThisKeyword */) return undefined; var constructor = ts.getContainingFunction(token); var superCall = findSuperCall(constructor.body); @@ -140056,7 +145071,10 @@ var ts; var codefix; (function (codefix) { codefix.registerCodeFix({ - errorCodes: [ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher.code], + errorCodes: [ + ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher.code, + ts.Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher.code, + ], getCodeActions: function (context) { var compilerOptions = context.program.getCompilerOptions(); var configFile = compilerOptions.configFile; @@ -140152,14 +145170,14 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, pos); var heritageClauses = ts.getContainingClass(token).heritageClauses; var extendsToken = heritageClauses[0].getFirstToken(); - return extendsToken.kind === 93 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; + return extendsToken.kind === 94 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; } function doChanges(changes, sourceFile, extendsToken, heritageClauses) { - changes.replaceNode(sourceFile, extendsToken, ts.factory.createToken(116 /* ImplementsKeyword */)); + changes.replaceNode(sourceFile, extendsToken, ts.factory.createToken(117 /* ImplementsKeyword */)); // If there is already an implements clause, replace the implements keyword with a comma. if (heritageClauses.length === 2 && - heritageClauses[0].token === 93 /* ExtendsKeyword */ && - heritageClauses[1].token === 116 /* ImplementsKeyword */) { + heritageClauses[0].token === 94 /* ExtendsKeyword */ && + heritageClauses[1].token === 117 /* ImplementsKeyword */) { var implementsToken = heritageClauses[1].getFirstToken(); var implementsFullStart = implementsToken.getFullStart(); changes.replaceRange(sourceFile, { pos: implementsFullStart, end: implementsFullStart }, ts.factory.createToken(27 /* CommaToken */)); @@ -140335,7 +145353,7 @@ var ts; ]; } var result = []; - if (token.kind === 135 /* InferKeyword */) { + if (token.kind === 136 /* 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)); @@ -140377,7 +145395,7 @@ var ts; break; } case fixIdDelete: { - if (token.kind === 135 /* InferKeyword */ || isImport(token)) { + if (token.kind === 136 /* InferKeyword */ || isImport(token)) { break; // Can't delete } else if (ts.isJSDocTemplateTag(token)) { @@ -140406,7 +145424,7 @@ var ts; break; } case fixIdInfer: - if (token.kind === 135 /* InferKeyword */) { + if (token.kind === 136 /* InferKeyword */) { changeInferToUnknown(changes, sourceFile, token); } break; @@ -140417,7 +145435,7 @@ var ts; }, }); function changeInferToUnknown(changes, sourceFile, token) { - changes.replaceNode(sourceFile, token.parent, ts.factory.createKeywordTypeNode(152 /* UnknownKeyword */)); + changes.replaceNode(sourceFile, token.parent, ts.factory.createKeywordTypeNode(153 /* UnknownKeyword */)); } function createDeleteFix(changes, diag) { return codefix.createCodeFixAction(fixName, changes, diag, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations); @@ -140426,18 +145444,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 === 99 /* ImportKeyword */ - || token.kind === 78 /* Identifier */ && (token.parent.kind === 265 /* ImportSpecifier */ || token.parent.kind === 262 /* ImportClause */); + return token.kind === 100 /* ImportKeyword */ + || token.kind === 79 /* Identifier */ && (token.parent.kind === 267 /* ImportSpecifier */ || token.parent.kind === 264 /* ImportClause */); } /** Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing. */ function tryGetFullImport(token) { - return token.kind === 99 /* ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; + return token.kind === 100 /* 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 === 232 /* VariableStatement */ ? node.parent : node); + changes.delete(sourceFile, node.parent.kind === 234 /* VariableStatement */ ? node.parent : node); } function deleteDestructuringElements(changes, sourceFile, node) { ts.forEach(node.elements, function (n) { return changes.delete(sourceFile, n); }); @@ -140446,7 +145464,7 @@ 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 === 135 /* InferKeyword */) { + if (token.kind === 136 /* InferKeyword */) { token = ts.cast(token.parent, ts.isInferTypeNode).typeParameter.name; } if (ts.isIdentifier(token) && canPrefix(token)) { @@ -140462,14 +145480,14 @@ var ts; } function canPrefix(token) { switch (token.parent.kind) { - case 160 /* Parameter */: - case 159 /* TypeParameter */: + case 162 /* Parameter */: + case 161 /* TypeParameter */: return true; - case 249 /* VariableDeclaration */: { + case 251 /* VariableDeclaration */: { var varDecl = token.parent; switch (varDecl.parent.parent.kind) { - case 239 /* ForOfStatement */: - case 238 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 240 /* ForInStatement */: return true; } } @@ -140493,8 +145511,10 @@ var ts; if (ts.isParameter(parent)) { tryDeleteParameter(changes, sourceFile, parent, checker, sourceFiles, program, cancellationToken, isFixAll); } - else if (!isFixAll || !(ts.isIdentifier(token) && ts.FindAllReferences.Core.isSymbolReferencedInFile(token, checker, sourceFile))) { - changes.delete(sourceFile, ts.isImportClause(parent) ? token : ts.isComputedPropertyName(parent) ? parent.parent : parent); + else if (!(isFixAll && ts.isIdentifier(token) && ts.FindAllReferences.Core.isSymbolReferencedInFile(token, checker, sourceFile))) { + var node = ts.isImportClause(parent) ? token : ts.isComputedPropertyName(parent) ? parent.parent : parent; + ts.Debug.assert(node !== sourceFile, "should not delete whole source file"); + changes.delete(sourceFile, node); } } function tryDeleteParameter(changes, sourceFile, parameter, checker, sourceFiles, program, cancellationToken, isFixAll) { @@ -140517,8 +145537,8 @@ var ts; function mayDeleteParameter(checker, sourceFile, parameter, sourceFiles, program, cancellationToken, isFixAll) { var parent = parameter.parent; switch (parent.kind) { - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: + case 167 /* MethodDeclaration */: + case 168 /* 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); @@ -140548,17 +145568,17 @@ var ts; } } return true; - case 251 /* FunctionDeclaration */: { + case 253 /* FunctionDeclaration */: { if (parent.name && isCallbackLike(checker, sourceFile, parent.name)) { return isLastParameter(parent, parameter, isFixAll); } return true; } - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 210 /* FunctionExpression */: + case 211 /* 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 168 /* SetAccessor */: + case 170 /* SetAccessor */: // Setter must have a parameter return false; default: @@ -140616,7 +145636,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 234 /* IfStatement */: + case 236 /* IfStatement */: if (container.elseStatement) { if (ts.isBlock(statement.parent)) { break; @@ -140627,8 +145647,8 @@ var ts; return; } // falls through - case 236 /* WhileStatement */: - case 237 /* ForStatement */: + case 238 /* WhileStatement */: + case 239 /* ForStatement */: changes.delete(sourceFile, container); return; } @@ -140701,7 +145721,7 @@ 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 === 305 /* JSDocNullableType */) { + if (typeNode.kind === 308 /* 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)); @@ -140721,7 +145741,7 @@ var ts; if (!info) return; var typeNode = info.typeNode, type = info.type; - var fixedType = typeNode.kind === 305 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; + var fixedType = typeNode.kind === 308 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; doChange(changes, sourceFile, typeNode, fixedType, checker); }); } @@ -140738,22 +145758,22 @@ var ts; // NOTE: Some locations are not handled yet: // MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments switch (node.kind) { - case 224 /* AsExpression */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 251 /* FunctionDeclaration */: - case 167 /* GetAccessor */: - case 171 /* IndexSignature */: - case 190 /* MappedType */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 160 /* Parameter */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 168 /* SetAccessor */: - case 254 /* TypeAliasDeclaration */: - case 206 /* TypeAssertionExpression */: - case 249 /* VariableDeclaration */: + case 226 /* AsExpression */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 253 /* FunctionDeclaration */: + case 169 /* GetAccessor */: + case 173 /* IndexSignature */: + case 192 /* MappedType */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 162 /* Parameter */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 170 /* SetAccessor */: + case 256 /* TypeAliasDeclaration */: + case 208 /* TypeAssertionExpression */: + case 251 /* VariableDeclaration */: return true; default: return false; @@ -140768,7 +145788,7 @@ var ts; (function (codefix) { var fixId = "fixMissingCallParentheses"; var errorCodes = [ - ts.Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead.code, + ts.Diagnostics.This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_instead.code, ]; codefix.registerCodeFix({ errorCodes: errorCodes, @@ -140814,7 +145834,7 @@ var ts; var fixId = "fixAwaitInSyncFunction"; var errorCodes = [ ts.Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code, - ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator.code, + ts.Diagnostics.for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code, ]; codefix.registerCodeFix({ errorCodes: errorCodes, @@ -140855,14 +145875,14 @@ var ts; } var insertBefore; switch (containingFunction.kind) { - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: insertBefore = containingFunction.name; break; - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - insertBefore = ts.findChildOfKind(containingFunction, 97 /* FunctionKeyword */, sourceFile); + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + insertBefore = ts.findChildOfKind(containingFunction, 98 /* FunctionKeyword */, sourceFile); break; - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: insertBefore = ts.findChildOfKind(containingFunction, 20 /* OpenParenToken */, sourceFile) || ts.first(containingFunction.parameters); break; default: @@ -140877,11 +145897,11 @@ var ts; var insertBefore = _a.insertBefore, returnType = _a.returnType; if (returnType) { var entityName = ts.getEntityNameFromTypeNode(returnType); - if (!entityName || entityName.kind !== 78 /* Identifier */ || entityName.text !== "Promise") { + if (!entityName || entityName.kind !== 79 /* Identifier */ || entityName.text !== "Promise") { changes.replaceNode(sourceFile, returnType, ts.factory.createTypeReferenceNode("Promise", ts.factory.createNodeArray([returnType]))); } } - changes.insertModifierBefore(sourceFile, 129 /* AsyncKeyword */, insertBefore); + changes.insertModifierBefore(sourceFile, 130 /* AsyncKeyword */, insertBefore); } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -141041,7 +146061,7 @@ var ts; return errorCode; } function doChange(changes, sourceFile, token, errorCode, program, cancellationToken, markSeen, host, preferences) { - if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 78 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 107 /* ThisKeyword */) { + if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 79 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 108 /* ThisKeyword */) { return undefined; } var parent = token.parent; @@ -141061,7 +146081,7 @@ var ts; var typeNode = ts.getTypeNodeIfAccessible(type, parent, program, host); if (typeNode) { // Note that the codefix will never fire with an existing `@type` tag, so there is no need to merge tags - var typeTag = ts.factory.createJSDocTypeTag(/*tagName*/ undefined, ts.factory.createJSDocTypeExpression(typeNode), /*comment*/ ""); + var typeTag = ts.factory.createJSDocTypeTag(/*tagName*/ undefined, ts.factory.createJSDocTypeExpression(typeNode), /*comment*/ undefined); addJSDocTags(changes, sourceFile, ts.cast(parent.parent.parent, ts.isExpressionStatement), [typeTag]); } importAdder.writeFixes(changes); @@ -141195,13 +146215,13 @@ 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 !== 162 /* PropertySignature */) { + if (ts.isInJSFile(sourceFile) && declaration.kind !== 164 /* PropertySignature */) { var parent = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : declaration; if (!parent) { return; } var typeExpression = ts.factory.createJSDocTypeExpression(typeNode); - var typeTag = ts.isGetAccessorDeclaration(declaration) ? ts.factory.createJSDocReturnTag(/*tagName*/ undefined, typeExpression, "") : ts.factory.createJSDocTypeTag(/*tagName*/ undefined, typeExpression, ""); + var typeTag = ts.isGetAccessorDeclaration(declaration) ? ts.factory.createJSDocReturnTag(/*tagName*/ undefined, typeExpression, /*comment*/ undefined) : ts.factory.createJSDocTypeTag(/*tagName*/ undefined, typeExpression, /*comment*/ undefined); addJSDocTags(changes, sourceFile, parent, [typeTag]); } else if (!tryReplaceImportTypeNodeWithAutoImport(typeNode, declaration, sourceFile, changes, importAdder, ts.getEmitScriptTarget(program.getCompilerOptions()))) { @@ -141256,13 +146276,13 @@ var ts; else { var paramTags = ts.map(inferences, function (_a) { var name = _a.name, typeNode = _a.typeNode, isOptional = _a.isOptional; - return ts.factory.createJSDocParameterTag(/*tagName*/ undefined, name, /*isBracketed*/ !!isOptional, ts.factory.createJSDocTypeExpression(typeNode), /* isNameFirst */ false, ""); + return ts.factory.createJSDocParameterTag(/*tagName*/ undefined, name, /*isBracketed*/ !!isOptional, ts.factory.createJSDocTypeExpression(typeNode), /* isNameFirst */ false, /*comment*/ undefined); }); addJSDocTags(changes, sourceFile, signature, paramTags); } } function addJSDocTags(changes, sourceFile, parent, newTags) { - var comments = ts.mapDefined(parent.jsDoc, function (j) { return j.comment; }); + var comments = ts.flatMap(parent.jsDoc, function (j) { return typeof j.comment === "string" ? ts.factory.createJSDocText(j.comment) : j.comment; }); var oldTags = ts.flatMapToMutable(parent.jsDoc, function (j) { return j.tags; }); var unmergedNewTags = newTags.filter(function (newTag) { return !oldTags || !oldTags.some(function (tag, i) { var merged = tryMergeJsdocTags(tag, newTag); @@ -141270,15 +146290,15 @@ var ts; oldTags[i] = merged; return !!merged; }); }); - var tag = ts.factory.createJSDocComment(comments.join("\n"), ts.factory.createNodeArray(__spreadArray(__spreadArray([], (oldTags || ts.emptyArray)), unmergedNewTags))); - var jsDocNode = parent.kind === 209 /* ArrowFunction */ ? getJsDocNodeForArrowFunction(parent) : parent; + var tag = ts.factory.createJSDocComment(ts.factory.createNodeArray(ts.intersperse(comments, ts.factory.createJSDocText("\n"))), ts.factory.createNodeArray(__spreadArray(__spreadArray([], (oldTags || ts.emptyArray)), unmergedNewTags))); + var jsDocNode = parent.kind === 211 /* ArrowFunction */ ? getJsDocNodeForArrowFunction(parent) : parent; jsDocNode.jsDoc = parent.jsDoc; jsDocNode.jsDocCache = parent.jsDocCache; changes.insertJsdocCommentBefore(sourceFile, jsDocNode, tag); } codefix.addJSDocTags = addJSDocTags; function getJsDocNodeForArrowFunction(signature) { - if (signature.parent.kind === 163 /* PropertyDeclaration */) { + if (signature.parent.kind === 165 /* PropertyDeclaration */) { return signature.parent; } return signature.parent.parent; @@ -141288,14 +146308,14 @@ var ts; return undefined; } switch (oldTag.kind) { - case 326 /* JSDocParameterTag */: { + case 334 /* 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 327 /* JSDocReturnTag */: + case 335 /* JSDocReturnTag */: return ts.factory.createJSDocReturnTag(/*tagName*/ undefined, newTag.typeExpression, oldTag.comment); } } @@ -141320,19 +146340,19 @@ var ts; function getFunctionReferences(containingFunction, sourceFile, program, cancellationToken) { var searchToken; switch (containingFunction.kind) { - case 166 /* Constructor */: - searchToken = ts.findChildOfKind(containingFunction, 132 /* ConstructorKeyword */, sourceFile); + case 168 /* Constructor */: + searchToken = ts.findChildOfKind(containingFunction, 133 /* ConstructorKeyword */, sourceFile); break; - case 209 /* ArrowFunction */: - case 208 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 210 /* FunctionExpression */: var parent = containingFunction.parent; searchToken = (ts.isVariableDeclaration(parent) || ts.isPropertyDeclaration(parent)) && ts.isIdentifier(parent.name) ? parent.name : containingFunction.name; break; - case 251 /* FunctionDeclaration */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 253 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: searchToken = containingFunction.name; break; } @@ -141474,24 +146494,24 @@ var ts; node = node.parent; } switch (node.parent.kind) { - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: inferTypeFromExpressionStatement(node, usage); break; - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: usage.isNumber = true; break; - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: inferTypeFromPrefixUnaryExpression(node.parent, usage); break; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: inferTypeFromBinaryExpression(node, node.parent, usage); break; - case 284 /* CaseClause */: - case 285 /* DefaultClause */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: inferTypeFromSwitchStatementLabel(node.parent, usage); break; - case 203 /* CallExpression */: - case 204 /* NewExpression */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: if (node.parent.expression === node) { inferTypeFromCallExpression(node.parent, usage); } @@ -141499,20 +146519,20 @@ var ts; inferTypeFromContextualType(node, usage); } break; - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: inferTypeFromPropertyAccessExpression(node.parent, usage); break; - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: inferTypeFromPropertyElementExpression(node.parent, node, usage); break; - case 288 /* PropertyAssignment */: - case 289 /* ShorthandPropertyAssignment */: + case 290 /* PropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: inferTypeFromPropertyAssignment(node.parent, usage); break; - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: inferTypeFromPropertyDeclaration(node.parent, usage); break; - case 249 /* VariableDeclaration */: { + case 251 /* 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. @@ -141570,17 +146590,17 @@ var ts; case 52 /* CaretToken */: // CompoundAssignmentOperator // falls through - case 64 /* MinusEqualsToken */: - case 66 /* AsteriskAsteriskEqualsToken */: - case 65 /* AsteriskEqualsToken */: - case 67 /* SlashEqualsToken */: - case 68 /* PercentEqualsToken */: - case 72 /* AmpersandEqualsToken */: - case 73 /* BarEqualsToken */: - case 77 /* CaretEqualsToken */: - case 69 /* LessThanLessThanEqualsToken */: - case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 70 /* GreaterThanGreaterThanEqualsToken */: + 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 */: // AdditiveOperator // falls through case 40 /* MinusToken */: @@ -141598,7 +146618,7 @@ var ts; usage.isNumber = true; } break; - case 63 /* PlusEqualsToken */: + case 64 /* PlusEqualsToken */: case 39 /* PlusToken */: var otherOperandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); if (otherOperandType.flags & 1056 /* EnumLike */) { @@ -141618,14 +146638,14 @@ var ts; } break; // AssignmentOperators - case 62 /* EqualsToken */: + case 63 /* EqualsToken */: case 34 /* EqualsEqualsToken */: case 36 /* EqualsEqualsEqualsToken */: case 37 /* ExclamationEqualsEqualsToken */: case 35 /* ExclamationEqualsToken */: addCandidateType(usage, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); break; - case 100 /* InKeyword */: + case 101 /* InKeyword */: if (node === parent.left) { usage.isString = true; } @@ -141634,7 +146654,7 @@ var ts; case 56 /* BarBarToken */: case 60 /* QuestionQuestionToken */: if (node === parent.left && - (node.parent.parent.kind === 249 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { + (node.parent.parent.kind === 251 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { // var x = x || {}; // TODO: use getFalsyflagsOfType addCandidateType(usage, checker.getTypeAtLocation(parent.right)); @@ -141642,7 +146662,7 @@ var ts; break; case 55 /* AmpersandAmpersandToken */: case 27 /* CommaToken */: - case 101 /* InstanceOfKeyword */: + case 102 /* InstanceOfKeyword */: // nothing to infer here break; } @@ -141662,7 +146682,7 @@ var ts; } } calculateUsageOfNode(parent, call.return_); - if (parent.kind === 203 /* CallExpression */) { + if (parent.kind === 205 /* CallExpression */) { (usage.calls || (usage.calls = [])).push(call); } else { @@ -141765,7 +146785,7 @@ var ts; var anon = anons_1[_i]; for (var _a = 0, _b = checker.getPropertiesOfType(anon); _a < _b.length; _a++) { var p = _b[_a]; - props.add(p.name, checker.getTypeOfSymbolAtLocation(p, p.valueDeclaration)); + 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 */)); @@ -141906,12 +146926,13 @@ var ts; if (!usageParam) { break; } - var genericParamType = checker.getTypeOfSymbolAtLocation(genericParam, genericParam.valueDeclaration); + var genericParamType = genericParam.valueDeclaration ? checker.getTypeOfSymbolAtLocation(genericParam, genericParam.valueDeclaration) : checker.getAnyType(); var elementType = isRest && checker.getElementTypeOfArrayType(genericParamType); if (elementType) { genericParamType = elementType; } - var targetType = usageParam.type || checker.getTypeOfSymbolAtLocation(usageParam, usageParam.valueDeclaration); + var targetType = usageParam.type + || (usageParam.valueDeclaration ? checker.getTypeOfSymbolAtLocation(usageParam, usageParam.valueDeclaration) : checker.getAnyType()); types.push.apply(types, inferTypeParameters(genericParamType, targetType, typeParameter)); } var genericReturn = checker.getReturnTypeOfSignature(genericSig); @@ -141925,7 +146946,7 @@ var ts; function getSignatureFromCalls(calls) { var parameters = []; var length = Math.max.apply(Math, calls.map(function (c) { return c.argumentTypes.length; })); - var _loop_14 = function (i) { + var _loop_15 = function (i) { var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i)); symbol.type = combineTypes(calls.map(function (call) { return call.argumentTypes[i] || checker.getUndefinedType(); })); if (calls.some(function (call) { return call.argumentTypes[i] === undefined; })) { @@ -141934,10 +146955,9 @@ var ts; parameters.push(symbol); }; for (var i = 0; i < length; i++) { - _loop_14(i); + _loop_15(i); } var returnType = combineFromUsage(combineUsages(calls.map(function (call) { return call.return_; }))); - // TODO: GH#18217 return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, 0 /* None */); } function addCandidateType(usage, type) { @@ -142081,7 +147101,7 @@ var ts; codefix.createMissingMemberNodes = createMissingMemberNodes; function getNoopSymbolTrackerWithResolver(context) { return { - trackSymbol: ts.noop, + trackSymbol: function () { return false; }, moduleResolverHost: ts.getModuleSpecifierResolverHost(context.program, context.host), }; } @@ -142105,8 +147125,8 @@ var ts; var ambient = !!(enclosingDeclaration.flags & 8388608 /* Ambient */); var quotePreference = ts.getQuotePreference(sourceFile, preferences); switch (declaration.kind) { - case 162 /* PropertySignature */: - case 163 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 165 /* PropertyDeclaration */: var flags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : undefined; var typeNode = checker.typeToTypeNode(type, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context)); if (importAdder) { @@ -142120,8 +147140,8 @@ var ts; /*decorators*/ undefined, modifiers, name, optional ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeNode, /*initializer*/ undefined)); break; - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: { + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: { var typeNode_1 = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); var allAccessors = ts.getAllAccessorDeclarations(declarations, declaration); var orderedAccessors = allAccessors.secondAccessor @@ -142150,8 +147170,8 @@ var ts; } break; } - case 164 /* MethodSignature */: - case 165 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 167 /* 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 @@ -142181,7 +147201,7 @@ var ts; } else { ts.Debug.assert(declarations.length === signatures.length, "Declarations and signatures should match count"); - addClassElement(createMethodImplementingSignatures(signatures, name, optional, modifiers, quotePreference)); + addClassElement(createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional, modifiers, quotePreference)); } } break; @@ -142197,7 +147217,7 @@ var ts; var checker = program.getTypeChecker(); var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions()); var flags = 1 /* NoTruncation */ | 1073741824 /* NoUndefinedOptionalParameterType */ | 256 /* SuppressAnyReturnType */ | (quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : 0); - var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, 165 /* MethodDeclaration */, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context)); + var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, 167 /* MethodDeclaration */, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context)); if (!signatureDeclaration) { return undefined; } @@ -142281,7 +147301,7 @@ var ts; var type = isJs || contextualType === undefined ? undefined : checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker); - if (kind === 165 /* MethodDeclaration */) { + if (kind === 167 /* MethodDeclaration */) { return ts.factory.createMethodDeclaration( /*decorators*/ undefined, modifiers, asteriskToken, name, /*questionToken*/ undefined, typeParameters, parameters, type, ts.isInterfaceDeclaration(contextNode) ? undefined : createStubbedMethodBody(quotePreference)); @@ -142311,13 +147331,13 @@ var ts; /*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(128 /* AnyKeyword */), + /*type*/ inJs ? undefined : types && types[i] || ts.factory.createKeywordTypeNode(129 /* AnyKeyword */), /*initializer*/ undefined); parameters.push(newParameter); } return parameters; } - function createMethodImplementingSignatures(signatures, name, optional, modifiers, quotePreference) { + function createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional, modifiers, quotePreference) { /** This is *a* signature with the maximal number of arguments, * such that if there is a "maximal" signature without rest arguments, * this is one of them. @@ -142339,7 +147359,7 @@ var ts; var maxArgsParameterSymbolNames = maxArgsSignature.parameters.map(function (symbol) { return symbol.name; }); var parameters = createDummyParameters(maxNonRestArgs, maxArgsParameterSymbolNames, /* types */ undefined, minArgumentCount, /*inJs*/ false); if (someSigHasRestParameter) { - var anyArrayType = ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(128 /* AnyKeyword */)); + var anyArrayType = ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(129 /* AnyKeyword */)); var restParameter = ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createToken(25 /* DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest", @@ -142348,8 +147368,13 @@ var ts; parameters.push(restParameter); } return createStubbedMethod(modifiers, name, optional, - /*typeParameters*/ undefined, parameters, - /*returnType*/ undefined, quotePreference); + /*typeParameters*/ undefined, parameters, getReturnTypeFromSignatures(signatures, checker, context, enclosingDeclaration), quotePreference); + } + function getReturnTypeFromSignatures(signatures, checker, context, enclosingDeclaration) { + if (ts.length(signatures)) { + var type = checker.getUnionType(ts.map(signatures, checker.getReturnTypeOfSignature)); + return checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); + } } function createStubbedMethod(modifiers, name, optional, typeParameters, parameters, returnType, quotePreference) { return ts.factory.createMethodDeclaration( @@ -142369,10 +147394,10 @@ var ts; codefix.createStubbedBody = createStubbedBody; function createVisibilityModifier(flags) { if (flags & 4 /* Public */) { - return ts.factory.createToken(122 /* PublicKeyword */); + return ts.factory.createToken(123 /* PublicKeyword */); } else if (flags & 16 /* Protected */) { - return ts.factory.createToken(121 /* ProtectedKeyword */); + return ts.factory.createToken(122 /* ProtectedKeyword */); } return undefined; } @@ -142445,7 +147470,7 @@ var ts; } codefix.tryGetAutoImportableReferenceFromTypeNode = tryGetAutoImportableReferenceFromTypeNode; function replaceFirstIdentifierOfEntityName(name, newIdentifier) { - if (name.kind === 78 /* Identifier */) { + if (name.kind === 79 /* Identifier */) { return newIdentifier; } return ts.factory.createQualifiedName(replaceFirstIdentifierOfEntityName(name.left, newIdentifier), name.right); @@ -142476,13 +147501,13 @@ var ts; if (ts.isClassLike(container)) { var modifierFlags = ts.getEffectiveModifierFlags(declaration); if (ts.isSourceFileJS(file)) { - var modifiers = createModifiers(modifierFlags); + var modifiers = ts.createModifiers(modifierFlags); accessorModifiers = modifiers; fieldModifiers = modifiers; } else { - accessorModifiers = createModifiers(prepareModifierFlagsForAccessor(modifierFlags)); - fieldModifiers = createModifiers(prepareModifierFlagsForField(modifierFlags)); + accessorModifiers = ts.createModifiers(prepareModifierFlagsForAccessor(modifierFlags)); + fieldModifiers = ts.createModifiers(prepareModifierFlagsForField(modifierFlags)); } } updateFieldDeclaration(changeTracker, file, declaration, type, fieldName, fieldModifiers); @@ -142517,9 +147542,6 @@ var ts; var leftHead = isStatic ? container.name : ts.factory.createThis(); // TODO: GH#18217 return ts.isIdentifier(fieldName) ? ts.factory.createPropertyAccessExpression(leftHead, fieldName) : ts.factory.createElementAccessExpression(leftHead, ts.factory.createStringLiteralFromNode(fieldName)); } - function createModifiers(modifierFlags) { - return modifierFlags ? ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(modifierFlags)) : undefined; - } function prepareModifierFlagsForAccessor(modifierFlags) { modifierFlags &= ~64 /* Readonly */; // avoid Readonly modifier because it will convert to get accessor modifierFlags &= ~8 /* Private */; @@ -142564,7 +147586,7 @@ var ts; isStatic: ts.hasStaticModifier(declaration), isReadonly: ts.hasEffectiveReadonlyModifier(declaration), type: getDeclarationType(declaration, program), - container: declaration.kind === 160 /* Parameter */ ? declaration.parent.parent : declaration.parent, + container: declaration.kind === 162 /* Parameter */ ? declaration.parent.parent : declaration.parent, originalName: declaration.name.text, declaration: declaration, fieldName: fieldName, @@ -142620,13 +147642,13 @@ var ts; return; constructor.body.forEachChild(function recur(node) { if (ts.isElementAccessExpression(node) && - node.expression.kind === 107 /* ThisKeyword */ && + node.expression.kind === 108 /* 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 === 107 /* ThisKeyword */ && node.name.text === originalName && ts.isWriteAccess(node)) { + if (ts.isPropertyAccessExpression(node) && node.expression.kind === 108 /* ThisKeyword */ && node.name.text === originalName && ts.isWriteAccess(node)) { changeTracker.replaceNode(file, node.name, ts.factory.createIdentifier(fieldName)); } if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) { @@ -142641,7 +147663,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), [ts.factory.createKeywordTypeNode(150 /* UndefinedKeyword */)])); + return ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], types), [ts.factory.createKeywordTypeNode(151 /* UndefinedKeyword */)])); } } return typeNode; @@ -142654,7 +147676,7 @@ var ts; if (!superSymbol) break; var symbol = superSymbol.flags & 2097152 /* Alias */ ? checker.getAliasedSymbol(superSymbol) : superSymbol; - var superDecl = ts.find(symbol.declarations, ts.isClassLike); + var superDecl = symbol.declarations && ts.find(symbol.declarations, ts.isClassLike); if (!superDecl) break; res.push(superDecl); @@ -142700,7 +147722,7 @@ var ts; }); function getActionsForUsageOfInvalidImport(context) { var sourceFile = context.sourceFile; - var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 203 /* CallExpression */ : 204 /* NewExpression */; + var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 205 /* CallExpression */ : 206 /* NewExpression */; var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start), function (a) { return a.kind === targetKind; }); if (!node) { return []; @@ -142819,7 +147841,7 @@ var ts; return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_undefined_type_to_property_0, propertyDeclaration.name.getText()], fixIdAddUndefinedType, ts.Diagnostics.Add_undefined_type_to_all_uninitialized_properties); } function addUndefinedType(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) { - var undefinedTypeNode = ts.factory.createKeywordTypeNode(150 /* UndefinedKeyword */); + var undefinedTypeNode = ts.factory.createKeywordTypeNode(151 /* UndefinedKeyword */); var type = propertyDeclaration.type; // TODO: GH#18217 var types = ts.isUnionTypeNode(type) ? type.types.concat(undefinedTypeNode) : [type, undefinedTypeNode]; changeTracker.replaceNode(propertyDeclarationSourceFile, type, ts.factory.createUnionTypeNode(types)); @@ -143033,8 +148055,8 @@ var ts; }); function getImportTypeNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 99 /* ImportKeyword */, "This token should be an ImportKeyword"); - ts.Debug.assert(token.parent.kind === 195 /* ImportType */, "Token parent should be an ImportType"); + ts.Debug.assert(token.kind === 100 /* ImportKeyword */, "This token should be an ImportKeyword"); + ts.Debug.assert(token.parent.kind === 197 /* ImportType */, "Token parent should be an ImportType"); return token.parent; } function doChange(changes, sourceFile, importType) { @@ -143053,10 +148075,6 @@ var ts; codefix.registerCodeFix({ errorCodes: errorCodes, getCodeActions: function (context) { - var jsx = context.program.getCompilerOptions().jsx; - if (jsx !== 2 /* React */ && jsx !== 3 /* ReactNative */) { - return undefined; - } var sourceFile = context.sourceFile, span = context.span; var node = findNodeToFix(sourceFile, span.start); if (!node) @@ -143166,7 +148184,7 @@ var ts; var otherMembers = members.filter(function (member) { return !ts.isIndexSignatureDeclaration(member); }); var parameter = ts.first(indexSignature.parameters); var mappedTypeParameter = ts.factory.createTypeParameterDeclaration(ts.cast(parameter.name, ts.isIdentifier), parameter.type); - var mappedIntersectionType = ts.factory.createMappedTypeNode(ts.hasEffectiveReadonlyModifier(indexSignature) ? ts.factory.createModifier(142 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, + var mappedIntersectionType = ts.factory.createMappedTypeNode(ts.hasEffectiveReadonlyModifier(indexSignature) ? ts.factory.createModifier(143 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, /*nameType*/ undefined, indexSignature.questionToken, indexSignature.type); var intersectionType = ts.factory.createIntersectionTypeNode(__spreadArray(__spreadArray(__spreadArray([], ts.getAllSuperTypeNodes(container)), [ mappedIntersectionType @@ -143223,7 +148241,7 @@ var ts; }, }); function makeChange(changeTracker, sourceFile, span) { - var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 130 /* AwaitKeyword */; }); + var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 131 /* AwaitKeyword */; }); var awaitExpression = awaitKeyword && ts.tryCast(awaitKeyword.parent, ts.isAwaitExpression); if (!awaitExpression) { return; @@ -143234,7 +148252,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 !== 102 /* NewKeyword */) { + if (precedingToken && precedingToken.kind !== 103 /* NewKeyword */) { expressionToReplace = awaitExpression.parent; } } @@ -143301,7 +148319,7 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, pos); var checker = program.getTypeChecker(); var symbol = checker.getSymbolAtLocation(token); - if (symbol) { + if (symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration) { return symbol.valueDeclaration.parent.parent; } } @@ -143396,7 +148414,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(113 /* VoidKeyword */)]).types[0]); + ts.isParenthesizedTypeNode(ts.factory.createUnionTypeNode([typeArgument, ts.factory.createKeywordTypeNode(114 /* VoidKeyword */)]).types[0]); if (needsParens) { changes.insertText(sourceFile, typeArgument.pos, "("); } @@ -143488,7 +148506,7 @@ var ts; ; function getInfo(context, considerPartialSpans) { if (considerPartialSpans === void 0) { considerPartialSpans = true; } - var file = context.file; + 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); @@ -143496,23 +148514,31 @@ var ts; return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_export_statement) }; } var exportingModuleSymbol = ts.isSourceFile(exportNode.parent) ? exportNode.parent.symbol : exportNode.parent.parent.symbol; - var flags = ts.getSyntacticModifierFlags(exportNode); + var flags = ts.getSyntacticModifierFlags(exportNode) || ((ts.isExportAssignment(exportNode) && !exportNode.isExportEquals) ? 513 /* ExportDefault */ : 0 /* None */); var wasDefault = !!(flags & 512 /* Default */); // If source file already has a default export, don't offer refactor. if (!(flags & 1 /* Export */) || !wasDefault && exportingModuleSymbol.exports.has("default" /* Default */)) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.This_file_already_has_a_default_export) }; } + var checker = program.getTypeChecker(); + var noSymbolError = function (id) { + return (ts.isIdentifier(id) && checker.getSymbolAtLocation(id)) ? undefined + : { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Can_only_convert_named_export) }; + }; switch (exportNode.kind) { - case 251 /* FunctionDeclaration */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 256 /* ModuleDeclaration */: { + case 253 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 257 /* EnumDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 258 /* ModuleDeclaration */: { var node = exportNode; - return node.name && ts.isIdentifier(node.name) ? { exportNode: node, exportName: node.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; + if (!node.name) + return undefined; + return noSymbolError(node.name) + || { exportNode: node, exportName: node.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol }; } - case 232 /* VariableStatement */: { + case 234 /* VariableStatement */: { var vs = exportNode; // Must be `export const x = something;`. if (!(vs.declarationList.flags & 2 /* Const */) || vs.declarationList.declarations.length !== 1) { @@ -143522,7 +148548,15 @@ var ts; if (!decl.initializer) return undefined; ts.Debug.assert(!wasDefault, "Can't have a default flag here"); - return ts.isIdentifier(decl.name) ? { exportNode: vs, exportName: decl.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; + return noSymbolError(decl.name) + || { exportNode: vs, exportName: decl.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol }; + } + case 268 /* ExportAssignment */: { + var node = exportNode; + if (node.isExportEquals) + return undefined; + return noSymbolError(node.expression) + || { exportNode: node, exportName: node.expression, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol }; } default: return undefined; @@ -143535,17 +148569,24 @@ var ts; function changeExport(exportingSourceFile, _a, changes, checker) { var wasDefault = _a.wasDefault, exportNode = _a.exportNode, exportName = _a.exportName; if (wasDefault) { - changes.delete(exportingSourceFile, ts.Debug.checkDefined(ts.findModifier(exportNode, 87 /* DefaultKeyword */), "Should find a default keyword in modifier list")); + if (ts.isExportAssignment(exportNode) && !exportNode.isExportEquals) { + var exp = exportNode.expression; + var spec = makeExportSpecifier(exp.text, exp.text); + changes.replaceNode(exportingSourceFile, exportNode, ts.factory.createExportDeclaration(/*decorators*/ undefined, /*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")); + } } else { - var exportKeyword = ts.Debug.checkDefined(ts.findModifier(exportNode, 92 /* ExportKeyword */), "Should find an export keyword in modifier list"); + var exportKeyword = ts.Debug.checkDefined(ts.findModifier(exportNode, 93 /* ExportKeyword */), "Should find an export keyword in modifier list"); switch (exportNode.kind) { - case 251 /* FunctionDeclaration */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.factory.createToken(87 /* DefaultKeyword */)); + case 253 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.factory.createToken(88 /* DefaultKeyword */)); break; - case 232 /* VariableStatement */: + case 234 /* 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) { @@ -143554,15 +148595,15 @@ var ts; break; } // falls through - case 255 /* EnumDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 256 /* ModuleDeclaration */: + case 257 /* EnumDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 258 /* 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.assertNever(exportNode, "Unexpected exportNode kind " + exportNode.kind); + ts.Debug.fail("Unexpected exportNode kind " + exportNode.kind); } } } @@ -143583,18 +148624,18 @@ var ts; function changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName) { var parent = ref.parent; switch (parent.kind) { - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: // `a.default` --> `a.foo` changes.replaceNode(importingSourceFile, ref, ts.factory.createIdentifier(exportName)); break; - case 265 /* ImportSpecifier */: - case 270 /* ExportSpecifier */: { + case 267 /* ImportSpecifier */: + case 272 /* 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 262 /* ImportClause */: { + case 264 /* ImportClause */: { var clause = parent; ts.Debug.assert(clause.name === ref, "Import clause name should match provided ref"); var spec = makeImportSpecifier(exportName, ref.text); @@ -143603,7 +148644,7 @@ var ts; // `import foo from "./a";` --> `import { foo } from "./a";` changes.replaceNode(importingSourceFile, ref, ts.factory.createNamedImports([spec])); } - else if (namedBindings.kind === 263 /* NamespaceImport */) { + else if (namedBindings.kind === 265 /* 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 */; @@ -143624,11 +148665,11 @@ var ts; function changeNamedToDefaultImport(importingSourceFile, ref, changes) { var parent = ref.parent; switch (parent.kind) { - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: // `a.foo` --> `a.default` changes.replaceNode(importingSourceFile, ref, ts.factory.createIdentifier("default")); break; - case 265 /* ImportSpecifier */: { + case 267 /* 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); @@ -143641,7 +148682,7 @@ var ts; } break; } - case 270 /* ExportSpecifier */: { + case 272 /* 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";` @@ -143687,7 +148728,7 @@ var ts; if (!info) return ts.emptyArray; if (!refactor.isRefactorErrorInfo(info)) { - var namespaceImport = info.kind === 263 /* NamespaceImport */; + var namespaceImport = info.kind === 265 /* NamespaceImport */; var action = namespaceImport ? namespaceToNamedAction : namedToNamespaceAction; return [{ name: refactorName, description: action.description, actions: [action] }]; } @@ -143729,7 +148770,7 @@ var ts; } function doChange(sourceFile, program, changes, toConvert) { var checker = program.getTypeChecker(); - if (toConvert.kind === 263 /* NamespaceImport */) { + if (toConvert.kind === 265 /* NamespaceImport */) { doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())); } else { @@ -143794,7 +148835,7 @@ var ts; }); var namespaceImportName = namespaceNameConflicts ? ts.getUniqueName(preferredName, sourceFile) : preferredName; var neededNamedImports = []; - var _loop_15 = function (element) { + var _loop_16 = 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); @@ -143813,7 +148854,7 @@ var ts; }; for (var _i = 0, _a = toConvert.elements; _i < _a.length; _i++) { var element = _a[_i]; - _loop_15(element); + _loop_16(element); } changes.replaceNode(sourceFile, toConvert, ts.factory.createNamespaceImport(ts.factory.createIdentifier(namespaceImportName))); if (neededNamedImports.length) { @@ -144130,27 +149171,27 @@ var ts; var lastDeclaration = signatureDecls[signatureDecls.length - 1]; var updated = lastDeclaration; switch (lastDeclaration.kind) { - case 164 /* MethodSignature */: { + case 166 /* MethodSignature */: { updated = ts.factory.updateMethodSignature(lastDeclaration, lastDeclaration.modifiers, lastDeclaration.name, lastDeclaration.questionToken, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 165 /* MethodDeclaration */: { + case 167 /* MethodDeclaration */: { updated = ts.factory.updateMethodDeclaration(lastDeclaration, lastDeclaration.decorators, lastDeclaration.modifiers, lastDeclaration.asteriskToken, lastDeclaration.name, lastDeclaration.questionToken, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type, lastDeclaration.body); break; } - case 169 /* CallSignature */: { + case 171 /* CallSignature */: { updated = ts.factory.updateCallSignature(lastDeclaration, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 166 /* Constructor */: { + case 168 /* Constructor */: { updated = ts.factory.updateConstructorDeclaration(lastDeclaration, lastDeclaration.decorators, lastDeclaration.modifiers, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.body); break; } - case 170 /* ConstructSignature */: { + case 172 /* ConstructSignature */: { updated = ts.factory.updateConstructSignature(lastDeclaration, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 251 /* FunctionDeclaration */: { + case 253 /* FunctionDeclaration */: { updated = ts.factory.updateFunctionDeclaration(lastDeclaration, lastDeclaration.decorators, lastDeclaration.modifiers, lastDeclaration.asteriskToken, lastDeclaration.name, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type, lastDeclaration.body); break; } @@ -144182,7 +149223,7 @@ var ts; } 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(128 /* AnyKeyword */)), p); + var result = ts.setTextRange(ts.factory.createNamedTupleMember(p.dotDotDotToken, p.name, p.questionToken, p.type || ts.factory.createKeywordTypeNode(129 /* AnyKeyword */)), p); var parameterDocComment = p.symbol && p.symbol.getDocumentationComment(checker); if (parameterDocComment) { var newComment = ts.displayPartsToString(parameterDocComment); @@ -144202,12 +149243,12 @@ var ts; } function isConvertableSignatureDeclaration(d) { switch (d.kind) { - case 164 /* MethodSignature */: - case 165 /* MethodDeclaration */: - case 169 /* CallSignature */: - case 166 /* Constructor */: - case 170 /* ConstructSignature */: - case 251 /* FunctionDeclaration */: + case 166 /* MethodSignature */: + case 167 /* MethodDeclaration */: + case 171 /* CallSignature */: + case 168 /* Constructor */: + case 172 /* ConstructSignature */: + case 253 /* FunctionDeclaration */: return true; } return false; @@ -144347,7 +149388,6 @@ var ts; }; } } - // Skip these since we don't have a way to report errors yet if (refactor.refactorKindBeginsWith(extractConstantAction.kind, requestedRefactor)) { if (constantExtraction.errors.length === 0) { // Don't issue refactorings with duplicated names. @@ -144479,24 +149519,28 @@ var ts; /** * getRangeToExtract takes a span inside a text file and returns either an expression or an array * of statements representing the minimum set of nodes needed to extract the entire span. This - * process may fail, in which case a set of errors is returned instead (these are currently - * not shown to the user, but can be used by us diagnostically) + * process may fail, in which case a set of errors is returned instead. These errors are shown to + * users if they have the provideRefactorNotApplicableReason option set. */ // exported only for tests - function getRangeToExtract(sourceFile, span, considerEmptySpans) { - if (considerEmptySpans === void 0) { considerEmptySpans = true; } + function getRangeToExtract(sourceFile, span, invoked) { + if (invoked === void 0) { invoked = true; } var length = span.length; - if (length === 0 && !considerEmptySpans) { + if (length === 0 && !invoked) { return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractEmpty)] }; } - var cursorRequest = length === 0 && considerEmptySpans; + var cursorRequest = length === 0 && invoked; + var startToken = ts.findFirstNonJsxWhitespaceToken(sourceFile, span.start); + var endToken = ts.findTokenOnLeftOfPosition(sourceFile, ts.textSpanEnd(span)); + /* If the refactoring command is invoked through a keyboard action it's safe to assume that the user is actively looking for + refactoring actions at the span location. As they may not know the exact range that will trigger a refactoring, we expand the + searched span to cover a real node range making it more likely that something useful will show up. */ + var adjustedSpan = startToken && endToken && invoked ? getAdjustedSpanFromNodes(startToken, endToken, sourceFile) : span; // Walk up starting from the the start position until we find a non-SourceFile node that subsumes the selected span. // This may fail (e.g. you select two statements in the root of a source file) - var startToken = ts.getTokenAtPosition(sourceFile, span.start); - var start = cursorRequest ? getExtractableParent(startToken) : ts.getParentNodeInSpan(startToken, sourceFile, span); + var start = cursorRequest ? getExtractableParent(startToken) : ts.getParentNodeInSpan(startToken, sourceFile, adjustedSpan); // Do the same for the ending position - var endToken = ts.findTokenOnLeftOfPosition(sourceFile, ts.textSpanEnd(span)); - var end = cursorRequest ? start : ts.getParentNodeInSpan(endToken, sourceFile, span); + var end = cursorRequest ? start : ts.getParentNodeInSpan(endToken, sourceFile, adjustedSpan); var declarations = []; // We'll modify these flags as we walk the tree to collect data // about what things need to be done as part of the extraction. @@ -144505,6 +149549,9 @@ var ts; // cannot find either start or end node return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] }; } + if (ts.isJSDoc(start)) { + return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractJSDoc)] }; + } if (start.parent !== end.parent) { // start and end nodes belong to different subtrees return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] }; @@ -144539,9 +149586,6 @@ var ts; } return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations } }; } - if (ts.isJSDoc(start)) { - return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractJSDoc)] }; - } if (ts.isReturnStatement(start) && !start.expression) { // Makes no sense to extract an expression-less return statement. return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] }; @@ -144594,20 +149638,20 @@ var ts; function checkForStaticContext(nodeToCheck, containingClass) { var current = nodeToCheck; while (current !== containingClass) { - if (current.kind === 163 /* PropertyDeclaration */) { + if (current.kind === 165 /* PropertyDeclaration */) { if (ts.hasSyntacticModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 160 /* Parameter */) { + else if (current.kind === 162 /* Parameter */) { var ctorOrMethod = ts.getContainingFunction(current); - if (ctorOrMethod.kind === 166 /* Constructor */) { + if (ctorOrMethod.kind === 168 /* Constructor */) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 165 /* MethodDeclaration */) { + else if (current.kind === 167 /* MethodDeclaration */) { if (ts.hasSyntacticModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } @@ -144650,7 +149694,7 @@ var ts; return true; } if (ts.isDeclaration(node)) { - var declaringNode = (node.kind === 249 /* VariableDeclaration */) ? node.parent.parent : node; + var declaringNode = (node.kind === 251 /* VariableDeclaration */) ? node.parent.parent : node; if (ts.hasSyntacticModifier(declaringNode, 1 /* 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`! @@ -144662,16 +149706,16 @@ var ts; } // Some things can't be extracted in certain situations switch (node.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractImport)); return true; - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractExportedEntity)); return true; - case 105 /* SuperKeyword */: + case 106 /* 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 === 203 /* CallExpression */) { + if (node.parent.kind === 205 /* CallExpression */) { // Super constructor call var containingClass_1 = ts.getContainingClass(node); // TODO:GH#18217 if (containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) { @@ -144683,7 +149727,7 @@ var ts; rangeFacts |= RangeFacts.UsesThis; } break; - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: // check if arrow function uses this ts.forEachChild(node, function check(n) { if (ts.isThis(n)) { @@ -144697,39 +149741,39 @@ var ts; } }); // falls through - case 252 /* ClassDeclaration */: - case 251 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: + case 253 /* 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 221 /* ClassExpression */: - case 208 /* FunctionExpression */: - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 223 /* ClassExpression */: + case 210 /* FunctionExpression */: + case 167 /* MethodDeclaration */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: // do not dive into functions or classes return false; } var savedPermittedJumps = permittedJumps; switch (node.kind) { - case 234 /* IfStatement */: + case 236 /* IfStatement */: permittedJumps = 0 /* None */; break; - case 247 /* TryStatement */: + case 249 /* TryStatement */: // forbid all jumps inside try blocks permittedJumps = 0 /* None */; break; - case 230 /* Block */: - if (node.parent && node.parent.kind === 247 /* TryStatement */ && node.parent.finallyBlock === node) { + case 232 /* Block */: + if (node.parent && node.parent.kind === 249 /* TryStatement */ && node.parent.finallyBlock === node) { // allow unconditional returns from finally blocks permittedJumps = 4 /* Return */; } break; - case 285 /* DefaultClause */: - case 284 /* CaseClause */: + case 287 /* DefaultClause */: + case 286 /* CaseClause */: // allow unlabeled break inside case clauses permittedJumps |= 1 /* Break */; break; @@ -144741,19 +149785,19 @@ var ts; break; } switch (node.kind) { - case 187 /* ThisType */: - case 107 /* ThisKeyword */: + case 189 /* ThisType */: + case 108 /* ThisKeyword */: rangeFacts |= RangeFacts.UsesThis; break; - case 245 /* LabeledStatement */: { + case 247 /* LabeledStatement */: { var label = node.label; (seenLabels || (seenLabels = [])).push(label.escapedText); ts.forEachChild(node, visit); seenLabels.pop(); break; } - case 241 /* BreakStatement */: - case 240 /* ContinueStatement */: { + case 243 /* BreakStatement */: + case 242 /* ContinueStatement */: { var label = node.label; if (label) { if (!ts.contains(seenLabels, label.escapedText)) { @@ -144762,20 +149806,20 @@ var ts; } } else { - if (!(permittedJumps & (node.kind === 241 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { + if (!(permittedJumps & (node.kind === 243 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { // attempt to break or continue in a forbidden context (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractRangeContainingConditionalBreakOrContinueStatements)); } } break; } - case 213 /* AwaitExpression */: + case 215 /* AwaitExpression */: rangeFacts |= RangeFacts.IsAsyncFunction; break; - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: rangeFacts |= RangeFacts.IsGenerator; break; - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: if (permittedJumps & 4 /* Return */) { rangeFacts |= RangeFacts.HasReturn; } @@ -144792,6 +149836,18 @@ var ts; } } extractSymbol.getRangeToExtract = getRangeToExtract; + /** + * Includes the final semicolon so that the span covers statements in cases where it would otherwise + * only cover the declaration list. + */ + function getAdjustedSpanFromNodes(startNode, endNode, sourceFile) { + var start = startNode.getStart(sourceFile); + var end = endNode.getEnd(); + if (sourceFile.text.charCodeAt(end) === 59 /* semicolon */) { + end++; + } + return { start: start, length: end - start }; + } function getStatementOrExpressionRange(node) { if (ts.isStatement(node)) { return [node]; @@ -144829,7 +149885,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 === 160 /* Parameter */) { + if (current.kind === 162 /* 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; } @@ -144840,7 +149896,7 @@ var ts; // * Module/namespace or source file if (isScope(current)) { scopes.push(current); - if (current.kind === 297 /* SourceFile */) { + if (current.kind === 299 /* SourceFile */) { return scopes; } } @@ -144930,32 +149986,32 @@ var ts; } function getDescriptionForFunctionLikeDeclaration(scope) { switch (scope.kind) { - case 166 /* Constructor */: + case 168 /* Constructor */: return "constructor"; - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: return scope.name ? "function '" + scope.name.text + "'" : ts.ANONYMOUS; - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return "arrow function"; - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: return "method '" + scope.name.getText() + "'"; - case 167 /* GetAccessor */: + case 169 /* GetAccessor */: return "'get " + scope.name.getText() + "'"; - case 168 /* SetAccessor */: + case 170 /* SetAccessor */: return "'set " + scope.name.getText() + "'"; default: throw ts.Debug.assertNever(scope, "Unexpected scope kind " + scope.kind); } } function getDescriptionForClassLikeDeclaration(scope) { - return scope.kind === 252 /* ClassDeclaration */ + return scope.kind === 254 /* ClassDeclaration */ ? scope.name ? "class '" + scope.name.text + "'" : "anonymous class declaration" : scope.name ? "class expression '" + scope.name.text + "'" : "anonymous class expression"; } function getDescriptionForModuleLikeDeclaration(scope) { - return scope.kind === 257 /* ModuleBlock */ + return scope.kind === 259 /* ModuleBlock */ ? "namespace '" + scope.parent.name.getText() + "'" : scope.externalModuleIndicator ? 0 /* Module */ : 1 /* Global */; } @@ -145023,12 +150079,12 @@ var ts; var newFunction; if (ts.isClassLike(scope)) { // always create private method in TypeScript files - var modifiers = isJS ? [] : [ts.factory.createModifier(120 /* PrivateKeyword */)]; + var modifiers = isJS ? [] : [ts.factory.createModifier(121 /* PrivateKeyword */)]; if (range.facts & RangeFacts.InStaticRegion) { - modifiers.push(ts.factory.createModifier(123 /* StaticKeyword */)); + modifiers.push(ts.factory.createModifier(124 /* StaticKeyword */)); } if (range.facts & RangeFacts.IsAsyncFunction) { - modifiers.push(ts.factory.createModifier(129 /* AsyncKeyword */)); + modifiers.push(ts.factory.createModifier(130 /* AsyncKeyword */)); } newFunction = ts.factory.createMethodDeclaration( /*decorators*/ undefined, modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* AsteriskToken */) : undefined, functionName, @@ -145036,7 +150092,7 @@ var ts; } else { newFunction = ts.factory.createFunctionDeclaration( - /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.factory.createToken(129 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body); + /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.factory.createToken(130 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* 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; @@ -145181,9 +150237,9 @@ var ts; while (ts.isParenthesizedTypeNode(withoutParens)) { withoutParens = withoutParens.type; } - return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 150 /* UndefinedKeyword */; }) + return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 151 /* UndefinedKeyword */; }) ? clone - : ts.factory.createUnionTypeNode([clone, ts.factory.createKeywordTypeNode(150 /* UndefinedKeyword */)]); + : ts.factory.createUnionTypeNode([clone, ts.factory.createKeywordTypeNode(151 /* UndefinedKeyword */)]); } } /** @@ -145208,11 +150264,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(120 /* PrivateKeyword */)); + modifiers.push(ts.factory.createModifier(121 /* PrivateKeyword */)); if (rangeFacts & RangeFacts.InStaticRegion) { - modifiers.push(ts.factory.createModifier(123 /* StaticKeyword */)); + modifiers.push(ts.factory.createModifier(124 /* StaticKeyword */)); } - modifiers.push(ts.factory.createModifier(142 /* ReadonlyKeyword */)); + modifiers.push(ts.factory.createModifier(143 /* ReadonlyKeyword */)); var newVariable = ts.factory.createPropertyDeclaration( /*decorators*/ undefined, modifiers, localNameText, /*questionToken*/ undefined, variableType, initializer); @@ -145244,7 +150300,7 @@ var ts; var localReference = ts.factory.createIdentifier(localNameText); changeTracker.replaceNode(context.file, node, localReference); } - else if (node.parent.kind === 233 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { + else if (node.parent.kind === 235 /* 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( @@ -145263,7 +150319,7 @@ var ts; changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariableStatement, /*blankLineBetween*/ false); } // Consume - if (node.parent.kind === 233 /* ExpressionStatement */) { + if (node.parent.kind === 235 /* ExpressionStatement */) { // If the parent is an expression statement, delete it. changeTracker.delete(context.file, node.parent); } @@ -145590,7 +150646,7 @@ var ts; var scope = scopes_1[_i]; usagesPerScope.push({ usages: new ts.Map(), typeParameterUsages: new ts.Map(), substitutions: new ts.Map() }); substitutionsPerScope.push(new ts.Map()); - functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 251 /* FunctionDeclaration */ + functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 253 /* FunctionDeclaration */ ? [ts.createDiagnosticForNode(scope, Messages.cannotExtractToOtherFunctionLike)] : []); var constantErrors = []; @@ -145653,7 +150709,7 @@ var ts; : ts.getEnclosingBlockScopeContainer(scopes[0]); ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations); } - var _loop_16 = function (i) { + var _loop_17 = 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 @@ -145693,7 +150749,7 @@ var ts; } }; for (var i = 0; i < scopes.length; i++) { - _loop_16(i); + _loop_17(i); } return { target: target, usagesPerScope: usagesPerScope, functionErrorsPerScope: functionErrorsPerScope, constantErrorsPerScope: constantErrorsPerScope, exposedVariableDeclarations: exposedVariableDeclarations }; function isInGenericContext(node) { @@ -145909,37 +150965,37 @@ var ts; function isExtractableExpression(node) { var parent = node.parent; switch (parent.kind) { - case 291 /* EnumMember */: + case 293 /* EnumMember */: return false; } switch (node.kind) { case 10 /* StringLiteral */: - return parent.kind !== 261 /* ImportDeclaration */ && - parent.kind !== 265 /* ImportSpecifier */; - case 220 /* SpreadElement */: - case 196 /* ObjectBindingPattern */: - case 198 /* BindingElement */: + return parent.kind !== 263 /* ImportDeclaration */ && + parent.kind !== 267 /* ImportSpecifier */; + case 222 /* SpreadElement */: + case 198 /* ObjectBindingPattern */: + case 200 /* BindingElement */: return false; - case 78 /* Identifier */: - return parent.kind !== 198 /* BindingElement */ && - parent.kind !== 265 /* ImportSpecifier */ && - parent.kind !== 270 /* ExportSpecifier */; + case 79 /* Identifier */: + return parent.kind !== 200 /* BindingElement */ && + parent.kind !== 267 /* ImportSpecifier */ && + parent.kind !== 272 /* ExportSpecifier */; } return true; } function isBlockLike(node) { switch (node.kind) { - case 230 /* Block */: - case 297 /* SourceFile */: - case 257 /* ModuleBlock */: - case 284 /* CaseClause */: + case 232 /* Block */: + case 299 /* SourceFile */: + case 259 /* ModuleBlock */: + case 286 /* CaseClause */: return true; default: return false; } } function isInJSXContent(node) { - return (ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node) || ts.isJsxFragment(node)) && ts.isJsxElement(node.parent); + return (ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node) || ts.isJsxFragment(node)) && (ts.isJsxElement(node.parent) || ts.isJsxFragment(node.parent)); } })(extractSymbol = refactor.extractSymbol || (refactor.extractSymbol = {})); })(refactor = ts.refactor || (ts.refactor = {})); @@ -146074,7 +151130,7 @@ var ts; if (ts.isTypeReferenceNode(node)) { if (ts.isIdentifier(node.typeName)) { var symbol = checker.resolveName(node.typeName.text, node.typeName, 262144 /* TypeParameter */, /* excludeGlobals */ true); - if (symbol) { + if (symbol === null || symbol === void 0 ? void 0 : symbol.declarations) { var declaration = ts.cast(ts.first(symbol.declarations), ts.isTypeParameterDeclaration); if (rangeContainsSkipTrivia(statement, declaration, file) && !rangeContainsSkipTrivia(selection, declaration, file)) { ts.pushIfUnique(result, declaration); @@ -146097,7 +151153,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); - if (symbol && rangeContainsSkipTrivia(statement, symbol.valueDeclaration, file) && !rangeContainsSkipTrivia(selection, symbol.valueDeclaration, file)) { + if ((symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration) && rangeContainsSkipTrivia(statement, symbol.valueDeclaration, file) && !rangeContainsSkipTrivia(selection, symbol.valueDeclaration, file)) { return true; } } @@ -146317,11 +151373,11 @@ var ts; } function isPureImport(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return true; - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return !ts.hasSyntacticModifier(node, 1 /* Export */); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return node.declarationList.declarations.every(function (d) { return !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); }); default: return false; @@ -146382,10 +151438,10 @@ var ts; } function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) { var checker = program.getTypeChecker(); - var _loop_17 = function (sourceFile) { + var _loop_18 = function (sourceFile) { if (sourceFile === oldFile) return "continue"; - var _loop_18 = function (statement) { + var _loop_19 = function (statement) { forEachImportInStatement(statement, function (importNode) { if (checker.getSymbolAtLocation(moduleSpecifierFromImport(importNode)) !== oldFile.symbol) return; @@ -146407,22 +151463,22 @@ var ts; }; for (var _b = 0, _c = sourceFile.statements; _b < _c.length; _b++) { var statement = _c[_b]; - _loop_18(statement); + _loop_19(statement); } }; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; - _loop_17(sourceFile); + _loop_18(sourceFile); } } function getNamespaceLikeImport(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: - return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 263 /* NamespaceImport */ ? + case 263 /* ImportDeclaration */: + return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 265 /* NamespaceImport */ ? node.importClause.namedBindings.name : undefined; - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return node.name; - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return ts.tryCast(node.name, ts.isIdentifier); default: return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); @@ -146453,20 +151509,20 @@ var ts; var newNamespaceId = ts.factory.createIdentifier(newNamespaceName); var newModuleString = ts.factory.createStringLiteral(newModuleSpecifier); switch (node.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, ts.factory.createNamespaceImport(newNamespaceId)), newModuleString); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return ts.factory.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, newNamespaceId, ts.factory.createExternalModuleReference(newModuleString)); - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return ts.factory.createVariableDeclaration(newNamespaceId, /*exclamationToken*/ undefined, /*type*/ undefined, createRequireCall(newModuleString)); default: return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); } } function moduleSpecifierFromImport(i) { - return (i.kind === 261 /* ImportDeclaration */ ? i.moduleSpecifier - : i.kind === 260 /* ImportEqualsDeclaration */ ? i.moduleReference.expression + return (i.kind === 263 /* ImportDeclaration */ ? i.moduleSpecifier + : i.kind === 262 /* ImportEqualsDeclaration */ ? i.moduleReference.expression : i.initializer.arguments[0]); } function forEachImportInStatement(statement, cb) { @@ -146536,15 +151592,15 @@ var ts; } function deleteUnusedImports(sourceFile, importDecl, changes, isUnused) { switch (importDecl.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused); break; - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: if (isUnused(importDecl.name)) { changes.delete(sourceFile, importDecl); } break; - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: deleteUnusedImportsInVariableDeclaration(sourceFile, importDecl, changes, isUnused); break; default: @@ -146557,7 +151613,7 @@ var ts; var _a = importDecl.importClause, name = _a.name, namedBindings = _a.namedBindings; var defaultUnused = !name || isUnused(name); var namedBindingsUnused = !namedBindings || - (namedBindings.kind === 263 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); + (namedBindings.kind === 265 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); if (defaultUnused && namedBindingsUnused) { changes.delete(sourceFile, importDecl); } @@ -146569,7 +151625,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 === 264 /* NamedImports */) { + else if (namedBindings.kind === 266 /* NamedImports */) { for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) { var element = _b[_i]; if (isUnused(element.name)) @@ -146582,14 +151638,14 @@ var ts; function deleteUnusedImportsInVariableDeclaration(sourceFile, varDecl, changes, isUnused) { var name = varDecl.name; switch (name.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: if (isUnused(name)) { changes.delete(sourceFile, name); } break; - case 197 /* ArrayBindingPattern */: + case 199 /* ArrayBindingPattern */: break; - case 196 /* ObjectBindingPattern */: + case 198 /* 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); } @@ -146617,6 +151673,9 @@ var ts; var oldFileNamedImports = []; var markSeenTop = ts.nodeSeenTracker(); // Needed because multiple declarations may appear in `const x = 0, y = 1;`. newFileImportsFromOldFile.forEach(function (symbol) { + if (!symbol.declarations) { + return; + } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; if (!isTopLevelDeclaration(decl)) @@ -146716,14 +151775,14 @@ var ts; // Below should all be utilities function isInImport(decl) { switch (decl.kind) { - case 260 /* ImportEqualsDeclaration */: - case 265 /* ImportSpecifier */: - case 262 /* ImportClause */: - case 263 /* NamespaceImport */: + case 262 /* ImportEqualsDeclaration */: + case 267 /* ImportSpecifier */: + case 264 /* ImportClause */: + case 265 /* NamespaceImport */: return true; - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return isVariableDeclarationInImport(decl); - case 198 /* BindingElement */: + case 200 /* BindingElement */: return ts.isVariableDeclaration(decl.parent.parent) && isVariableDeclarationInImport(decl.parent.parent); default: return false; @@ -146735,7 +151794,7 @@ var ts; } function filterImport(i, moduleSpecifier, keep) { switch (i.kind) { - case 261 /* ImportDeclaration */: { + case 263 /* ImportDeclaration */: { var clause = i.importClause; if (!clause) return undefined; @@ -146745,9 +151804,9 @@ var ts; ? ts.factory.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, defaultImport, namedBindings), moduleSpecifier) : undefined; } - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return keep(i.name) ? i : undefined; - case 249 /* VariableDeclaration */: { + case 251 /* VariableDeclaration */: { var name = filterBindingName(i.name, keep); return name ? makeVariableStatement(name, i.type, createRequireCall(moduleSpecifier), i.parent.flags) : undefined; } @@ -146756,7 +151815,7 @@ var ts; } } function filterNamedBindings(namedBindings, keep) { - if (namedBindings.kind === 263 /* NamespaceImport */) { + if (namedBindings.kind === 265 /* NamespaceImport */) { return keep(namedBindings.name) ? namedBindings : undefined; } else { @@ -146766,11 +151825,11 @@ var ts; } function filterBindingName(name, keep) { switch (name.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return keep(name) ? name : undefined; - case 197 /* ArrayBindingPattern */: + case 199 /* ArrayBindingPattern */: return name; - case 196 /* ObjectBindingPattern */: { + case 198 /* 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; @@ -146827,13 +151886,13 @@ var ts; } function isNonVariableTopLevelDeclaration(node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 252 /* ClassDeclaration */: - case 256 /* ModuleDeclaration */: - case 255 /* EnumDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 253 /* InterfaceDeclaration */: - case 260 /* ImportEqualsDeclaration */: + case 253 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: + case 258 /* ModuleDeclaration */: + case 257 /* EnumDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 255 /* InterfaceDeclaration */: + case 262 /* ImportEqualsDeclaration */: return true; default: return false; @@ -146841,17 +151900,17 @@ var ts; } function forEachTopLevelDeclaration(statement, cb) { switch (statement.kind) { - case 251 /* FunctionDeclaration */: - case 252 /* ClassDeclaration */: - case 256 /* ModuleDeclaration */: - case 255 /* EnumDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 253 /* InterfaceDeclaration */: - case 260 /* ImportEqualsDeclaration */: + case 253 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: + case 258 /* ModuleDeclaration */: + case 257 /* EnumDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 255 /* InterfaceDeclaration */: + case 262 /* ImportEqualsDeclaration */: return cb(statement); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return ts.firstDefined(statement.declarationList.declarations, function (decl) { return forEachTopLevelDeclarationInBindingName(decl.name, cb); }); - case 233 /* ExpressionStatement */: { + case 235 /* ExpressionStatement */: { var expression = statement.expression; return ts.isBinaryExpression(expression) && ts.getAssignmentDeclarationKind(expression) === 1 /* ExportsProperty */ ? cb(statement) @@ -146861,10 +151920,10 @@ var ts; } function forEachTopLevelDeclarationInBindingName(name, cb) { switch (name.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return cb(ts.cast(name.parent, function (x) { return ts.isVariableDeclaration(x) || ts.isBindingElement(x); })); - case 197 /* ArrayBindingPattern */: - case 196 /* ObjectBindingPattern */: + case 199 /* ArrayBindingPattern */: + case 198 /* 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); @@ -146875,9 +151934,9 @@ var ts; } function getTopLevelDeclarationStatement(d) { switch (d.kind) { - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return d.parent.parent; - case 198 /* BindingElement */: + case 200 /* BindingElement */: return getTopLevelDeclarationStatement(ts.cast(d.parent.parent, function (p) { return ts.isVariableDeclaration(p) || ts.isBindingElement(p); })); default: return d; @@ -146908,25 +151967,25 @@ var ts; return useEs6Exports ? [addEs6Export(decl)] : addCommonjsExport(decl); } function addEs6Export(d) { - var modifiers = ts.concatenate([ts.factory.createModifier(92 /* ExportKeyword */)], d.modifiers); + var modifiers = ts.concatenate([ts.factory.createModifier(93 /* ExportKeyword */)], d.modifiers); switch (d.kind) { - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return ts.factory.updateFunctionDeclaration(d, d.decorators, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body); - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: return ts.factory.updateClassDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return ts.factory.updateVariableStatement(d, modifiers, d.declarationList); - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return ts.factory.updateModuleDeclaration(d, d.decorators, modifiers, d.name, d.body); - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: return ts.factory.updateEnumDeclaration(d, d.decorators, modifiers, d.name, d.members); - case 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: return ts.factory.updateTypeAliasDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.type); - case 253 /* InterfaceDeclaration */: + case 255 /* InterfaceDeclaration */: return ts.factory.updateInterfaceDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return ts.factory.updateImportEqualsDeclaration(d, d.decorators, modifiers, d.isTypeOnly, d.name, d.moduleReference); - case 233 /* ExpressionStatement */: + case 235 /* 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); @@ -146937,18 +151996,18 @@ var ts; } function getNamesToExportInCommonJS(decl) { switch (decl.kind) { - case 251 /* FunctionDeclaration */: - case 252 /* ClassDeclaration */: + case 253 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: return [decl.name.text]; // TODO: GH#18217 - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return ts.mapDefined(decl.declarationList.declarations, function (d) { return ts.isIdentifier(d.name) ? d.name.text : undefined; }); - case 256 /* ModuleDeclaration */: - case 255 /* EnumDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 253 /* InterfaceDeclaration */: - case 260 /* ImportEqualsDeclaration */: + case 258 /* ModuleDeclaration */: + case 257 /* EnumDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 255 /* InterfaceDeclaration */: + case 262 /* ImportEqualsDeclaration */: return ts.emptyArray; - case 233 /* ExpressionStatement */: + case 235 /* 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); @@ -146956,7 +152015,7 @@ var ts; } /** 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)), 62 /* EqualsToken */, ts.factory.createIdentifier(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))); } })(refactor = ts.refactor || (ts.refactor = {})); })(ts || (ts = {})); @@ -147117,13 +152176,13 @@ var ts; return { edits: [] }; // TODO: GH#30113 } function doChange(sourceFile, program, host, changes, functionDeclaration, groupedReferences) { - var newParamDeclaration = ts.map(createNewParameters(functionDeclaration, program, host), function (param) { return ts.getSynthesizedDeepClone(param); }); - changes.replaceNodeRangeWithNodes(sourceFile, ts.first(functionDeclaration.parameters), ts.last(functionDeclaration.parameters), newParamDeclaration, { joiner: ", ", - // indentation is set to 0 because otherwise the object parameter will be indented if there is a `this` parameter - indentation: 0, - leadingTriviaOption: ts.textChanges.LeadingTriviaOption.IncludeAll, - trailingTriviaOption: ts.textChanges.TrailingTriviaOption.Include - }); + var signature = groupedReferences.signature; + var newFunctionDeclarationParams = ts.map(createNewParameters(functionDeclaration, program, host), function (param) { return ts.getSynthesizedDeepClone(param); }); + if (signature) { + var newSignatureParams = ts.map(createNewParameters(signature, program, host), function (param) { return ts.getSynthesizedDeepClone(param); }); + replaceParameters(signature, newSignatureParams); + } + replaceParameters(functionDeclaration, newFunctionDeclarationParams); var functionCalls = ts.sortAndDeduplicate(groupedReferences.functionCalls, /*comparer*/ function (a, b) { return ts.compareValues(a.pos, b.pos); }); for (var _i = 0, functionCalls_1 = functionCalls; _i < functionCalls_1.length; _i++) { var call = functionCalls_1[_i]; @@ -147132,6 +152191,15 @@ var ts; changes.replaceNodeRange(ts.getSourceFileOfNode(call), ts.first(call.arguments), ts.last(call.arguments), newArgument, { leadingTriviaOption: ts.textChanges.LeadingTriviaOption.IncludeAll, trailingTriviaOption: ts.textChanges.TrailingTriviaOption.Include }); } } + function replaceParameters(declarationOrSignature, parameterDeclarations) { + changes.replaceNodeRangeWithNodes(sourceFile, ts.first(declarationOrSignature.parameters), ts.last(declarationOrSignature.parameters), parameterDeclarations, { + joiner: ", ", + // indentation is set to 0 because otherwise the object parameter will be indented if there is a `this` parameter + indentation: 0, + leadingTriviaOption: ts.textChanges.LeadingTriviaOption.IncludeAll, + trailingTriviaOption: ts.textChanges.TrailingTriviaOption.Include + }); + } } function getGroupedReferences(functionDeclaration, program, cancellationToken) { var functionNames = getFunctionNames(functionDeclaration); @@ -147150,12 +152218,38 @@ var ts; var functionSymbols = ts.map(functionNames, getSymbolTargetAtLocation); var classSymbols = ts.map(classNames, getSymbolTargetAtLocation); var isConstructor = ts.isConstructorDeclaration(functionDeclaration); + 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 !== 1 /* Node */) { + if (entry.kind === 0 /* Span */) { groupedReferences.valid = false; continue; } + /* Declarations in object literals may be implementations of method signatures which have a different symbol from the declaration + For example: + interface IFoo { m(a: number): void } + const foo: IFoo = { m(a: number): void {} } + In these cases we get the symbol for the signature from the contextual type. + */ + if (ts.contains(contextualSymbols, getSymbolTargetAtLocation(entry.node))) { + if (isValidMethodSignature(entry.node.parent)) { + groupedReferences.signature = entry.node.parent; + continue; + } + var call = entryToFunctionCall(entry); + if (call) { + groupedReferences.functionCalls.push(call); + continue; + } + } + var contextualSymbol = getSymbolForContextualType(entry.node, checker); + if (contextualSymbol && ts.contains(contextualSymbols, contextualSymbol)) { + var decl = entryToDeclaration(entry); + if (decl) { + groupedReferences.declarations.push(decl); + continue; + } + } /* We compare symbols because in some cases find all references wil return a reference that may or may not be to the refactored function. Example from the refactorConvertParamsToDestructuredObject_methodCallUnion.ts test: class A { foo(a: number, b: number) { return a + b; } } @@ -147218,6 +152312,19 @@ var ts; return symbol && ts.getSymbolTarget(symbol, checker); } } + /** + * Gets the symbol for the contextual type of the node if it is not a union or intersection. + */ + function getSymbolForContextualType(node, checker) { + var element = ts.getContainingObjectLiteralElement(node); + 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 */)) { + return symbol; + } + } + } function entryToImportOrExport(entry) { var node = entry.node; if (ts.isImportSpecifier(node.parent) @@ -147243,15 +152350,15 @@ var ts; var parent = functionReference.parent; switch (parent.kind) { // foo(...) or super(...) or new Foo(...) - case 203 /* CallExpression */: - case 204 /* NewExpression */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: var callOrNewExpression = ts.tryCast(parent, ts.isCallOrNewExpression); if (callOrNewExpression && callOrNewExpression.expression === functionReference) { return callOrNewExpression; } break; // x.foo(...) - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.parent && propertyAccessExpression.name === functionReference) { var callOrNewExpression_1 = ts.tryCast(propertyAccessExpression.parent, ts.isCallOrNewExpression); @@ -147261,7 +152368,7 @@ var ts; } break; // x["foo"](...) - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.parent && elementAccessExpression.argumentExpression === functionReference) { var callOrNewExpression_2 = ts.tryCast(elementAccessExpression.parent, ts.isCallOrNewExpression); @@ -147280,14 +152387,14 @@ var ts; var parent = reference.parent; switch (parent.kind) { // `C.foo` - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.expression === reference) { return propertyAccessExpression; } break; // `C["foo"]` - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.expression === reference) { return elementAccessExpression; @@ -147325,15 +152432,24 @@ var ts; } return false; } + function isValidMethodSignature(node) { + return ts.isMethodSignature(node) && (ts.isInterfaceDeclaration(node.parent) || ts.isTypeLiteralNode(node.parent)); + } function isValidFunctionDeclaration(functionDeclaration, checker) { + var _a; if (!isValidParameterNodeArray(functionDeclaration.parameters, checker)) return false; switch (functionDeclaration.kind) { - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return hasNameOrDefault(functionDeclaration) && isSingleImplementation(functionDeclaration, checker); - case 165 /* MethodDeclaration */: + case 167 /* 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 166 /* Constructor */: + case 168 /* Constructor */: if (ts.isClassDeclaration(functionDeclaration.parent)) { return hasNameOrDefault(functionDeclaration.parent) && isSingleImplementation(functionDeclaration, checker); } @@ -147341,8 +152457,8 @@ var ts; return isValidVariableDeclaration(functionDeclaration.parent.parent) && isSingleImplementation(functionDeclaration, checker); } - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return isValidVariableDeclaration(functionDeclaration.parent); } return false; @@ -147352,7 +152468,7 @@ var ts; } function hasNameOrDefault(functionOrClassDeclaration) { if (!functionOrClassDeclaration.name) { - var defaultKeyword = ts.findModifier(functionOrClassDeclaration, 87 /* DefaultKeyword */); + var defaultKeyword = ts.findModifier(functionOrClassDeclaration, 88 /* DefaultKeyword */); return !!defaultKeyword; } return true; @@ -147492,15 +152608,15 @@ var ts; } function getClassNames(constructorDeclaration) { switch (constructorDeclaration.parent.kind) { - case 252 /* ClassDeclaration */: + case 254 /* 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, 87 /* DefaultKeyword */), "Nameless class declaration should be a default export"); + var defaultModifier = ts.Debug.checkDefined(ts.findModifier(classDeclaration, 88 /* DefaultKeyword */), "Nameless class declaration should be a default export"); return [defaultModifier]; - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: var classExpression = constructorDeclaration.parent; var variableDeclaration = constructorDeclaration.parent.parent; var className = classExpression.name; @@ -147511,25 +152627,25 @@ var ts; } function getFunctionNames(functionDeclaration) { switch (functionDeclaration.kind) { - case 251 /* FunctionDeclaration */: + case 253 /* 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, 87 /* DefaultKeyword */), "Nameless function declaration should be a default export"); + var defaultModifier = ts.Debug.checkDefined(ts.findModifier(functionDeclaration, 88 /* DefaultKeyword */), "Nameless function declaration should be a default export"); return [defaultModifier]; - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: return [functionDeclaration.name]; - case 166 /* Constructor */: - var ctrKeyword = ts.Debug.checkDefined(ts.findChildOfKind(functionDeclaration, 132 /* ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); - if (functionDeclaration.parent.kind === 221 /* ClassExpression */) { + case 168 /* Constructor */: + var ctrKeyword = ts.Debug.checkDefined(ts.findChildOfKind(functionDeclaration, 133 /* ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); + if (functionDeclaration.parent.kind === 223 /* ClassExpression */) { var variableDeclaration = functionDeclaration.parent.parent; return [variableDeclaration.name, ctrKeyword]; } return [ctrKeyword]; - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return [functionDeclaration.parent.name]; - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: if (functionDeclaration.name) return [functionDeclaration.name, functionDeclaration.parent.name]; return [functionDeclaration.parent.name]; @@ -147615,16 +152731,16 @@ var ts; } } function isNotEqualsOperator(node) { - return node.operatorToken.kind !== 62 /* EqualsToken */; + return node.operatorToken.kind !== 63 /* EqualsToken */; } function getParentBinaryExpression(expr) { var container = ts.findAncestor(expr.parent, function (n) { switch (n.kind) { - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: return false; - case 218 /* TemplateExpression */: - case 216 /* BinaryExpression */: + case 220 /* TemplateExpression */: + case 218 /* BinaryExpression */: return !(ts.isBinaryExpression(n.parent) && isNotEqualsOperator(n.parent)); default: return "quit"; @@ -147701,7 +152817,7 @@ var ts; var templateSpans = []; var templateHead = ts.factory.createTemplateHead(headText); copyCommentFromStringLiterals(headIndexes, templateHead); - var _loop_19 = function (i) { + var _loop_20 = function (i) { var currentNode = getExpressionFromParenthesesOrExpression(nodes[i]); copyOperatorComments(i, currentNode); var _c = concatConsecutiveString(i + 1, nodes), newIndex = _c[0], subsequentText = _c[1], stringIndexes = _c[2]; @@ -147725,7 +152841,7 @@ var ts; }; var out_i_1; for (var i = begin; i < nodes.length; i++) { - _loop_19(i); + _loop_20(i); i = out_i_1; } return ts.factory.createTemplateExpression(templateHead, templateSpans); @@ -147925,7 +153041,9 @@ var ts; var body = convertToBlock(func.body); var variableDeclaration = variableInfo.variableDeclaration, variableDeclarationList = variableInfo.variableDeclarationList, statement = variableInfo.statement, name = variableInfo.name; ts.suppressLeadingTrivia(statement); - var newNode = ts.factory.createFunctionDeclaration(func.decorators, statement.modifiers, func.asteriskToken, name, func.typeParameters, func.parameters, func.type, body); + var modifiersFlags = (ts.getCombinedModifierFlags(variableDeclaration) & 1 /* Export */) | ts.getEffectiveModifierFlags(func); + var modifiers = ts.factory.createModifiersFromModifierFlags(modifiersFlags); + var newNode = ts.factory.createFunctionDeclaration(func.decorators, ts.length(modifiers) ? modifiers : undefined, func.asteriskToken, name, func.typeParameters, func.parameters, func.type, body); if (variableDeclarationList.declarations.length === 1) { return ts.textChanges.ChangeTracker.with(context, function (t) { return t.replaceNode(file, statement, newNode); }); } @@ -147983,9 +153101,7 @@ var ts; function getEditsForAction(context) { var info = getInfo(context); if (info && !refactor.isRefactorErrorInfo(info)) { - var edits = ts.textChanges.ChangeTracker.with(context, function (t) { - return t.tryInsertTypeAnnotation(context.file, info.declaration, info.returnTypeNode); - }); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, t, info.declaration, info.returnTypeNode); }); return { renameFilename: undefined, renameLocation: undefined, edits: edits }; } return undefined; @@ -148010,11 +153126,26 @@ var ts; } return ts.emptyArray; } + function doChange(sourceFile, changes, declaration, typeNode) { + var closeParen = ts.findChildOfKind(declaration, 21 /* 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.insertNodeAt(sourceFile, endNode.end, typeNode, { prefix: ": " }); + } + } function getInfo(context) { if (ts.isInJSFile(context.file) || !refactor.refactorKindBeginsWith(inferReturnTypeAction.kind, context.kind)) return; var token = ts.getTokenAtPosition(context.file, context.startPosition); - var declaration = ts.findAncestor(token, isConvertibleDeclaration); + 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" : + isConvertibleDeclaration(n); + }); if (!declaration || !declaration.body || declaration.type) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Return_type_must_be_inferred_from_a_function) }; } @@ -148023,7 +153154,6 @@ var ts; if (!returnType) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_determine_function_return_type) }; } - ; var returnTypeNode = typeChecker.typeToTypeNode(returnType, declaration, 1 /* NoTruncation */); if (returnTypeNode) { return { declaration: declaration, returnTypeNode: returnTypeNode }; @@ -148031,10 +153161,10 @@ var ts; } function isConvertibleDeclaration(node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 167 /* MethodDeclaration */: return true; default: return false; @@ -148061,8 +153191,8 @@ var ts; ts.servicesVersion = "0.8"; function createNode(kind, pos, end, parent) { var node = ts.isNodeKind(kind) ? new NodeObject(kind, pos, end) : - kind === 78 /* Identifier */ ? new IdentifierObject(78 /* Identifier */, pos, end) : - kind === 79 /* PrivateIdentifier */ ? new PrivateIdentifierObject(79 /* PrivateIdentifier */, pos, end) : + kind === 79 /* Identifier */ ? new IdentifierObject(79 /* Identifier */, pos, end) : + kind === 80 /* PrivateIdentifier */ ? new PrivateIdentifierObject(80 /* PrivateIdentifier */, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; node.flags = parent.flags & 25358336 /* ContextFlags */; @@ -148136,8 +153266,8 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 301 /* FirstJSDocNode */ || kid.kind > 333 /* LastJSDocNode */; }); - return child.kind < 157 /* FirstNode */ ? + var child = ts.find(children, function (kid) { return kid.kind < 303 /* FirstJSDocNode */ || kid.kind > 341 /* LastJSDocNode */; }); + return child.kind < 159 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; @@ -148148,7 +153278,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 157 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 159 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; NodeObject.prototype.forEachChild = function (cbNode, cbNodeArray) { return ts.forEachChild(this, cbNode, cbNodeArray); @@ -148194,7 +153324,7 @@ var ts; var token = ts.scanner.scan(); var textPos = ts.scanner.getTextPos(); if (textPos <= end) { - if (token === 78 /* Identifier */) { + if (token === 79 /* Identifier */) { ts.Debug.fail("Did not expect " + ts.Debug.formatSyntaxKind(parent.kind) + " to have an Identifier in its trivia"); } nodes.push(createNode(token, pos, textPos, parent)); @@ -148206,11 +153336,11 @@ var ts; } } function createSyntaxList(nodes, parent) { - var list = createNode(334 /* SyntaxList */, nodes.pos, nodes.end, parent); + var list = createNode(342 /* SyntaxList */, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; - for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { - var node = nodes_1[_i]; + for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) { + var node = nodes_2[_i]; addSyntheticNodes(list._children, pos, node.pos, parent); list._children.push(node); pos = node.end; @@ -148317,13 +153447,13 @@ var ts; }; SymbolObject.prototype.getContextualDocumentationComment = function (context, checker) { switch (context === null || context === void 0 ? void 0 : context.kind) { - case 167 /* GetAccessor */: + case 169 /* GetAccessor */: if (!this.contextualGetAccessorDocumentationComment) { this.contextualGetAccessorDocumentationComment = ts.emptyArray; this.contextualGetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isGetAccessor), checker); } return this.contextualGetAccessorDocumentationComment; - case 168 /* SetAccessor */: + case 170 /* SetAccessor */: if (!this.contextualSetAccessorDocumentationComment) { this.contextualSetAccessorDocumentationComment = ts.emptyArray; this.contextualSetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isSetAccessor), checker); @@ -148333,9 +153463,9 @@ var ts; return this.getDocumentationComment(checker); } }; - SymbolObject.prototype.getJsDocTags = function () { + SymbolObject.prototype.getJsDocTags = function (checker) { if (this.tags === undefined) { - this.tags = ts.JsDoc.getJsDocTagsFromDeclarations(this.declarations); + this.tags = ts.JsDoc.getJsDocTagsFromDeclarations(this.declarations, checker); } return this.tags; }; @@ -148354,7 +153484,7 @@ var ts; __extends(IdentifierObject, _super); function IdentifierObject(_kind, pos, end) { var _this = _super.call(this, pos, end) || this; - _this.kind = 78 /* Identifier */; + _this.kind = 79 /* Identifier */; return _this; } Object.defineProperty(IdentifierObject.prototype, "text", { @@ -148366,7 +153496,7 @@ var ts; }); return IdentifierObject; }(TokenOrIdentifierObject)); - IdentifierObject.prototype.kind = 78 /* Identifier */; + IdentifierObject.prototype.kind = 79 /* Identifier */; var PrivateIdentifierObject = /** @class */ (function (_super) { __extends(PrivateIdentifierObject, _super); function PrivateIdentifierObject(_kind, pos, end) { @@ -148381,7 +153511,7 @@ var ts; }); return PrivateIdentifierObject; }(TokenOrIdentifierObject)); - PrivateIdentifierObject.prototype.kind = 79 /* PrivateIdentifier */; + PrivateIdentifierObject.prototype.kind = 80 /* PrivateIdentifier */; var TypeObject = /** @class */ (function () { function TypeObject(checker, flags) { this.checker = checker; @@ -148496,7 +153626,7 @@ var ts; }; SignatureObject.prototype.getJsDocTags = function () { if (this.jsDocTags === undefined) { - this.jsDocTags = this.declaration ? getJsDocTags([this.declaration], this.checker) : []; + this.jsDocTags = this.declaration ? getJsDocTagsOfSignature(this.declaration, this.checker) : []; } return this.jsDocTags; }; @@ -148510,29 +153640,34 @@ var ts; function hasJSDocInheritDocTag(node) { return ts.getJSDocTags(node).some(function (tag) { return tag.tagName.text === "inheritDoc"; }); } - function getJsDocTags(declarations, checker) { - var tags = ts.JsDoc.getJsDocTagsFromDeclarations(declarations); - if (tags.length === 0 || declarations.some(hasJSDocInheritDocTag)) { - ts.forEachUnique(declarations, function (declaration) { - var inheritedTags = findBaseOfDeclaration(checker, declaration, function (symbol) { return symbol.getJsDocTags(); }); - if (inheritedTags) { - tags = __spreadArray(__spreadArray([], inheritedTags), tags); - } - }); + function getJsDocTagsOfSignature(declaration, checker) { + var tags = ts.JsDoc.getJsDocTagsFromDeclarations([declaration], checker); + if (tags.length === 0 || hasJSDocInheritDocTag(declaration)) { + var inheritedTags = findBaseOfDeclaration(checker, declaration, function (symbol) { var _a; return ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.length) === 1 ? symbol.getJsDocTags() : undefined; }); + if (inheritedTags) { + tags = __spreadArray(__spreadArray([], inheritedTags), tags); + } } return tags; } function getDocumentationComment(declarations, checker) { if (!declarations) return ts.emptyArray; - var doc = ts.JsDoc.getJsDocCommentsFromDeclarations(declarations); + var doc = ts.JsDoc.getJsDocCommentsFromDeclarations(declarations, checker); if (checker && (doc.length === 0 || declarations.some(hasJSDocInheritDocTag))) { - ts.forEachUnique(declarations, function (declaration) { - var inheritedDocs = findBaseOfDeclaration(checker, declaration, function (symbol) { return symbol.getDocumentationComment(checker); }); + var seenSymbols_1 = new ts.Set(); + for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { + var declaration = declarations_4[_i]; + var inheritedDocs = findBaseOfDeclaration(checker, declaration, function (symbol) { + if (!seenSymbols_1.has(symbol)) { + seenSymbols_1.add(symbol); + return symbol.getDocumentationComment(checker); + } + }); // TODO: GH#16312 Return a ReadonlyArray, avoid copying inheritedDocs if (inheritedDocs) doc = doc.length === 0 ? inheritedDocs.slice() : inheritedDocs.concat(ts.lineBreakPart(), doc); - }); + } } return doc; } @@ -148546,7 +153681,7 @@ var ts; __extends(SourceFileObject, _super); function SourceFileObject(kind, pos, end) { var _this = _super.call(this, kind, pos, end) || this; - _this.kind = 297 /* SourceFile */; + _this.kind = 299 /* SourceFile */; return _this; } SourceFileObject.prototype.update = function (newText, textChangeRange) { @@ -148605,10 +153740,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -148628,31 +153763,31 @@ var ts; } ts.forEachChild(node, visit); break; - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 255 /* EnumDeclaration */: - case 256 /* ModuleDeclaration */: - case 260 /* ImportEqualsDeclaration */: - case 270 /* ExportSpecifier */: - case 265 /* ImportSpecifier */: - case 262 /* ImportClause */: - case 263 /* NamespaceImport */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 177 /* TypeLiteral */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 257 /* EnumDeclaration */: + case 258 /* ModuleDeclaration */: + case 262 /* ImportEqualsDeclaration */: + case 272 /* ExportSpecifier */: + case 267 /* ImportSpecifier */: + case 264 /* ImportClause */: + case 265 /* NamespaceImport */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 179 /* TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 160 /* Parameter */: + case 162 /* Parameter */: // Only consider parameter properties - if (!ts.hasSyntacticModifier(node, 92 /* ParameterPropertyModifier */)) { + if (!ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */)) { break; } // falls through - case 249 /* VariableDeclaration */: - case 198 /* BindingElement */: { + case 251 /* VariableDeclaration */: + case 200 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -148663,12 +153798,12 @@ var ts; } } // falls through - case 291 /* EnumMember */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 293 /* EnumMember */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: addDeclaration(node); break; - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; var exportDeclaration = node; @@ -148681,7 +153816,7 @@ var ts; } } break; - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -148693,7 +153828,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 263 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 265 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -148702,7 +153837,7 @@ var ts; } } break; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) !== 0 /* None */) { addDeclaration(node); } @@ -148796,15 +153931,7 @@ var ts; var fileName = rootFileNames_1[_i]; this.createEntry(fileName, ts.toPath(fileName, this.currentDirectory, getCanonicalFileName)); } - // store the compilation settings - this._compilationSettings = host.getCompilationSettings() || getDefaultCompilerOptions(); } - HostCache.prototype.compilationSettings = function () { - return this._compilationSettings; - }; - HostCache.prototype.getProjectReferences = function () { - return this.host.getProjectReferences && this.host.getProjectReferences(); - }; HostCache.prototype.createEntry = function (fileName, path) { var entry; var scriptSnapshot = this.host.getScriptSnapshot(fileName); @@ -148954,7 +154081,7 @@ var ts; }; CancellationTokenObject.prototype.throwIfCancellationRequested = function () { if (this.isCancellationRequested()) { - ts.tracing.instant("session" /* Session */, "cancellationThrown", { kind: "CancellationTokenObject" }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "cancellationThrown", { kind: "CancellationTokenObject" }); throw new ts.OperationCanceledException(); } }; @@ -148984,7 +154111,7 @@ var ts; }; ThrottledCancellationToken.prototype.throwIfCancellationRequested = function () { if (this.isCancellationRequested()) { - ts.tracing.instant("session" /* Session */, "cancellationThrown", { kind: "ThrottledCancellationToken" }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "cancellationThrown", { kind: "ThrottledCancellationToken" }); throw new ts.OperationCanceledException(); } }; @@ -149084,7 +154211,7 @@ var ts; return sourceFile; } function synchronizeHostData() { - var _a, _b; + var _a, _b, _c; ts.Debug.assert(languageServiceMode !== ts.LanguageServiceMode.Syntactic); // perform fast check if host supports it if (host.getProjectVersion) { @@ -149105,11 +154232,22 @@ var ts; // Get a fresh cache of the host information var hostCache = new HostCache(host, getCanonicalFileName); var rootFileNames = hostCache.getRootFileNames(); + var newSettings = host.getCompilationSettings() || getDefaultCompilerOptions(); var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse; var hasChangedAutomaticTypeDirectiveNames = ts.maybeBind(host, host.hasChangedAutomaticTypeDirectiveNames); - var projectReferences = hostCache.getProjectReferences(); + var projectReferences = (_b = host.getProjectReferences) === null || _b === void 0 ? void 0 : _b.call(host); + var parsedCommandLines; + var parseConfigHost = { + useCaseSensitiveFileNames: useCaseSensitiveFileNames, + fileExists: fileExists, + readFile: readFile, + readDirectory: readDirectory, + trace: ts.maybeBind(host, host.trace), + getCurrentDirectory: function () { return currentDirectory; }, + onUnRecoverableConfigFileDiagnostic: ts.noop, + }; // If the program is already up-to-date, we can reuse it - if (ts.isProgramUptoDate(program, rootFileNames, hostCache.compilationSettings(), function (_path, fileName) { return host.getScriptVersion(fileName); }, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, projectReferences)) { + if (ts.isProgramUptoDate(program, rootFileNames, newSettings, function (_path, fileName) { return host.getScriptVersion(fileName); }, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) { return; } // IMPORTANT - It is critical from this moment onward that we do not check @@ -149117,7 +154255,6 @@ var ts; // instance. If we cancel midway through, we may end up in an inconsistent state where // the program points to old source files that have been invalidated because of // incremental parsing. - var newSettings = hostCache.compilationSettings(); // Now create a new compiler var compilerHost = { getSourceFile: getOrCreateSourceFile, @@ -149139,19 +154276,18 @@ var ts; getDirectories: function (path) { return host.getDirectories ? host.getDirectories(path) : []; }, - readDirectory: function (path, extensions, exclude, include, depth) { - ts.Debug.checkDefined(host.readDirectory, "'LanguageServiceHost.readDirectory' must be implemented to correctly process 'projectReferences'"); - return host.readDirectory(path, extensions, exclude, include, depth); - }, + readDirectory: readDirectory, onReleaseOldSourceFile: onReleaseOldSourceFile, + onReleaseParsedCommandLine: onReleaseParsedCommandLine, hasInvalidatedResolution: hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames: hasChangedAutomaticTypeDirectiveNames, - trace: ts.maybeBind(host, host.trace), + trace: parseConfigHost.trace, resolveModuleNames: ts.maybeBind(host, host.resolveModuleNames), resolveTypeReferenceDirectives: ts.maybeBind(host, host.resolveTypeReferenceDirectives), useSourceOfProjectReferenceRedirect: ts.maybeBind(host, host.useSourceOfProjectReferenceRedirect), + getParsedCommandLine: getParsedCommandLine, }; - (_b = host.setCompilerHost) === null || _b === void 0 ? void 0 : _b.call(host, compilerHost); + (_c = host.setCompilerHost) === null || _c === void 0 ? void 0 : _c.call(host, compilerHost); var documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings); var options = { rootNames: rootFileNames, @@ -149164,6 +154300,7 @@ var ts; // hostCache is captured in the closure for 'getOrCreateSourceFile' but it should not be used past this point. // It needs to be cleared to allow all collected snapshots to be released hostCache = undefined; + parsedCommandLines = undefined; // We reset this cache on structure invalidation so we don't hold on to outdated files for long; however we can't use the `compilerHost` above, // Because it only functions until `hostCache` is cleared, while we'll potentially need the functionality to lazily read sourcemap files during // the course of whatever called `synchronizeHostData` @@ -149172,6 +154309,36 @@ var ts; // pointers set property. program.getTypeChecker(); return; + function getParsedCommandLine(fileName) { + var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); + var existing = parsedCommandLines === null || parsedCommandLines === void 0 ? void 0 : parsedCommandLines.get(path); + if (existing !== undefined) + return existing || undefined; + var result = host.getParsedCommandLine ? + host.getParsedCommandLine(fileName) : + getParsedCommandLineOfConfigFileUsingSourceFile(fileName); + (parsedCommandLines || (parsedCommandLines = new ts.Map())).set(path, result || false); + return result; + } + function getParsedCommandLineOfConfigFileUsingSourceFile(configFileName) { + var result = getOrCreateSourceFile(configFileName, 100 /* JSON */); + if (!result) + return undefined; + result.path = ts.toPath(configFileName, currentDirectory, getCanonicalFileName); + result.resolvedPath = result.path; + result.originalFileName = result.fileName; + return ts.parseJsonSourceFileConfigFileContent(result, parseConfigHost, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), + /*optionsToExtend*/ undefined, ts.getNormalizedAbsolutePath(configFileName, currentDirectory)); + } + function onReleaseParsedCommandLine(configFileName, oldResolvedRef, oldOptions) { + var _a; + if (host.getParsedCommandLine) { + (_a = host.onReleaseParsedCommandLine) === null || _a === void 0 ? void 0 : _a.call(host, configFileName, oldResolvedRef, oldOptions); + } + else if (oldResolvedRef) { + onReleaseOldSourceFile(oldResolvedRef.sourceFile, oldOptions); + } + } function fileExists(fileName) { var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); var entry = hostCache && hostCache.getEntryByPath(path); @@ -149188,11 +154355,15 @@ var ts; } return host.readFile && host.readFile(fileName); } + function readDirectory(path, extensions, exclude, include, depth) { + ts.Debug.checkDefined(host.readDirectory, "'LanguageServiceHost.readDirectory' must be implemented to correctly process 'projectReferences'"); + return host.readDirectory(path, extensions, exclude, include, depth); + } // Release any files we have acquired in the old program but are // not part of the new program. function onReleaseOldSourceFile(oldSourceFile, oldOptions) { var oldSettingsKey = documentRegistry.getKeyForCompilationSettings(oldOptions); - documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, oldSettingsKey); + documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, oldSettingsKey, oldSourceFile.scriptKind); } function getOrCreateSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile) { return getOrCreateSourceFileByPath(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), languageVersion, onError, shouldCreateNewSourceFile); @@ -149237,8 +154408,13 @@ var ts; // We do not support the scenario where a host can modify a registered // file's script kind, i.e. in one project some file is treated as ".ts" // and in another as ".js" - ts.Debug.assertEqual(hostFileInformation.scriptKind, oldSourceFile.scriptKind, "Registered script kind should match new script kind."); - return documentRegistry.updateDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind); + if (hostFileInformation.scriptKind === oldSourceFile.scriptKind) { + return documentRegistry.updateDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind); + } + 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); + } } // We didn't already have the file. Fall through and acquire it from the registry. } @@ -149267,7 +154443,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); + return documentRegistry.releaseDocumentWithKey(f.resolvedPath, key_1, f.scriptKind); }); program = undefined; // TODO: GH#18217 } @@ -149310,10 +154486,10 @@ var ts; synchronizeHostData(); return ts.Completions.getCompletionsAtPosition(host, program, log, getValidSourceFile(fileName), position, fullPreferences, options.triggerCharacter); } - function getCompletionEntryDetails(fileName, position, name, formattingOptions, source, preferences) { + function getCompletionEntryDetails(fileName, position, name, formattingOptions, source, preferences, data) { if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); - return ts.Completions.getCompletionEntryDetails(program, log, getValidSourceFile(fileName), position, { name: name, source: source }, host, (formattingOptions && ts.formatting.getFormatContext(formattingOptions, host)), // TODO: GH#18217 + return ts.Completions.getCompletionEntryDetails(program, log, getValidSourceFile(fileName), position, { name: name, source: source, data: data }, host, (formattingOptions && ts.formatting.getFormatContext(formattingOptions, host)), // TODO: GH#18217 preferences, cancellationToken); } function getCompletionEntrySymbol(fileName, position, name, source, preferences) { @@ -149340,7 +154516,7 @@ var ts; 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, - tags: type_2.symbol ? type_2.symbol.getJsDocTags() : undefined + tags: type_2.symbol ? type_2.symbol.getJsDocTags(typeChecker) : undefined }; } var _a = typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { @@ -149359,19 +154535,23 @@ var ts; if (ts.isNewExpression(node.parent) && node.pos === node.parent.pos) { return node.parent.expression; } + if (ts.isNamedTupleMember(node.parent) && node.pos === node.parent.pos) { + return node.parent; + } return node; } function shouldGetType(sourceFile, node, position) { switch (node.kind) { - case 78 /* Identifier */: - return !ts.isLabelName(node) && !ts.isTagName(node); - case 201 /* PropertyAccessExpression */: - case 157 /* QualifiedName */: + case 79 /* Identifier */: + return !ts.isLabelName(node) && !ts.isTagName(node) && !ts.isConstTypeReference(node.parent); + case 203 /* PropertyAccessExpression */: + case 159 /* QualifiedName */: // Don't return quickInfo if inside the comment in `a/**/.b` return !ts.isInComment(sourceFile, position); - case 107 /* ThisKeyword */: - case 187 /* ThisType */: - case 105 /* SuperKeyword */: + case 108 /* ThisKeyword */: + case 189 /* ThisType */: + case 106 /* SuperKeyword */: + case 194 /* NamedTupleMember */: return true; default: return false; @@ -149476,16 +154656,16 @@ var ts; return undefined; } switch (node.kind) { - case 201 /* PropertyAccessExpression */: - case 157 /* QualifiedName */: + case 203 /* PropertyAccessExpression */: + case 159 /* QualifiedName */: case 10 /* StringLiteral */: - case 94 /* FalseKeyword */: - case 109 /* TrueKeyword */: - case 103 /* NullKeyword */: - case 105 /* SuperKeyword */: - case 107 /* ThisKeyword */: - case 187 /* ThisType */: - case 78 /* Identifier */: + case 95 /* FalseKeyword */: + case 110 /* TrueKeyword */: + case 104 /* NullKeyword */: + case 106 /* SuperKeyword */: + case 108 /* ThisKeyword */: + case 189 /* ThisType */: + case 79 /* Identifier */: break; // Cant create the text span default: @@ -149501,7 +154681,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 === 256 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 258 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -149529,15 +154709,7 @@ var ts; function getNavigationTree(fileName) { return ts.NavigationBar.getNavigationTree(syntaxTreeCache.getCurrentSourceFile(fileName), cancellationToken); } - function isTsOrTsxFile(fileName) { - var kind = ts.getScriptKind(fileName, host); - return kind === 3 /* TS */ || kind === 4 /* TSX */; - } function getSemanticClassifications(fileName, span, format) { - if (!isTsOrTsxFile(fileName)) { - // do not run semantic classification on non-ts-or-tsx files - return []; - } synchronizeHostData(); var responseFormat = format || "original" /* Original */; if (responseFormat === "2020" /* TwentyTwenty */) { @@ -149548,10 +154720,6 @@ var ts; } } function getEncodedSemanticClassifications(fileName, span, format) { - if (!isTsOrTsxFile(fileName)) { - // do not run semantic classification on non-ts-or-tsx files - return { spans: [], endOfLineState: 0 /* None */ }; - } synchronizeHostData(); var responseFormat = format || "original" /* Original */; if (responseFormat === "original" /* Original */) { @@ -149642,13 +154810,13 @@ var ts; var formatContext = ts.formatting.getFormatContext(formatOptions, host); return ts.codefix.getAllFixes({ fixId: fixId, sourceFile: sourceFile, program: program, host: host, cancellationToken: cancellationToken, formatContext: formatContext, preferences: preferences }); } - function organizeImports(scope, formatOptions, preferences) { + function organizeImports(args, formatOptions, preferences) { if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); - ts.Debug.assert(scope.type === "file"); - var sourceFile = getValidSourceFile(scope.fileName); + ts.Debug.assert(args.type === "file"); + var sourceFile = getValidSourceFile(args.fileName); var formatContext = ts.formatting.getFormatContext(formatOptions, host); - return ts.OrganizeImports.organizeImports(sourceFile, formatContext, host, program, preferences); + return ts.OrganizeImports.organizeImports(sourceFile, formatContext, host, program, preferences, args.skipDestructiveCodeActions); } function getEditsForFileRename(oldFilePath, newFilePath, formatOptions, preferences) { if (preferences === void 0) { preferences = ts.emptyOptions; } @@ -149665,8 +154833,8 @@ var ts; ? host.installPackage({ fileName: getPath(action.file), packageName: action.packageName }) : Promise.reject("Host does not implement `installPackage`"); } - function getDocCommentTemplateAtPosition(fileName, position) { - return ts.JsDoc.getDocCommentTemplateAtPosition(ts.getNewLineOrDefaultFromHost(host), syntaxTreeCache.getCurrentSourceFile(fileName), position); + function getDocCommentTemplateAtPosition(fileName, position, options) { + return ts.JsDoc.getDocCommentTemplateAtPosition(ts.getNewLineOrDefaultFromHost(host), syntaxTreeCache.getCurrentSourceFile(fileName), position, options); } function isValidBraceCompletionAtPosition(fileName, position, openingBrace) { // '<' is currently not supported, figuring out if we're in a Generic Type vs. a comparison is too @@ -150081,6 +155249,16 @@ var ts; var file = getValidSourceFile(fileName); return ts.refactor.getEditsForRefactor(getRefactorContext(file, positionOrRange, preferences, formatOptions), refactorName, actionName); } + function toLineColumnOffset(fileName, position) { + // Go to Definition supports returning a zero-length span at position 0 for + // non-existent files. We need to special-case the conversion of position 0 + // to avoid a crash trying to get the text for that file, since this function + // otherwise assumes that 'fileName' is the name of a file that exists. + if (position === 0) { + return { line: 0, character: 0 }; + } + return sourceMapper.toLineColumnOffset(fileName, position); + } function prepareCallHierarchy(fileName, position) { synchronizeHostData(); var declarations = ts.CallHierarchy.resolveCallHierarchyDeclaration(program, ts.getTouchingPropertyName(getValidSourceFile(fileName), position)); @@ -150153,7 +155331,7 @@ var ts; getAutoImportProvider: getAutoImportProvider, getApplicableRefactors: getApplicableRefactors, getEditsForRefactor: getEditsForRefactor, - toLineColumnOffset: sourceMapper.toLineColumnOffset, + toLineColumnOffset: toLineColumnOffset, getSourceMapper: function () { return sourceMapper; }, clearSourceMapperCache: function () { return sourceMapper.clearCache(); }, prepareCallHierarchy: prepareCallHierarchy, @@ -150224,7 +155402,7 @@ var ts; */ function literalIsName(node) { return ts.isDeclarationName(node) || - node.parent.kind === 272 /* ExternalModuleReference */ || + node.parent.kind === 274 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node); } @@ -150242,13 +155420,13 @@ var ts; case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: - if (node.parent.kind === 158 /* ComputedPropertyName */) { + if (node.parent.kind === 160 /* ComputedPropertyName */) { return ts.isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; } // falls through - case 78 /* Identifier */: + case 79 /* Identifier */: return ts.isObjectLiteralElement(node.parent) && - (node.parent.parent.kind === 200 /* ObjectLiteralExpression */ || node.parent.parent.kind === 281 /* JsxAttributes */) && + (node.parent.parent.kind === 202 /* ObjectLiteralExpression */ || node.parent.parent.kind === 283 /* JsxAttributes */) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -150290,7 +155468,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 202 /* ElementAccessExpression */ && + node.parent.kind === 204 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -150370,114 +155548,114 @@ var ts; if (node) { var parent = node.parent; switch (node.kind) { - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 249 /* VariableDeclaration */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 251 /* VariableDeclaration */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: return spanInVariableDeclaration(node); - case 160 /* Parameter */: + case 162 /* Parameter */: return spanInParameterDeclaration(node); - case 251 /* FunctionDeclaration */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 166 /* Constructor */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 253 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 168 /* Constructor */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 230 /* Block */: + case 232 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // falls through - case 257 /* ModuleBlock */: + case 259 /* ModuleBlock */: return spanInBlock(node); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return spanInBlock(node.block); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 236 /* WhileStatement */: + case 238 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 235 /* DoStatement */: + case 237 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 248 /* DebuggerStatement */: + case 250 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 234 /* IfStatement */: + case 236 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 241 /* BreakStatement */: - case 240 /* ContinueStatement */: + case 243 /* BreakStatement */: + case 242 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return spanInForStatement(node); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 284 /* CaseClause */: - case 285 /* DefaultClause */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 247 /* TryStatement */: + case 249 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 246 /* ThrowStatement */: + case 248 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } // falls through - case 252 /* ClassDeclaration */: - case 255 /* EnumDeclaration */: - case 291 /* EnumMember */: - case 198 /* BindingElement */: + case 254 /* ClassDeclaration */: + case 257 /* EnumDeclaration */: + case 293 /* EnumMember */: + case 200 /* BindingElement */: // span on complete node return textSpan(node); - case 243 /* WithStatement */: + case 245 /* WithStatement */: // span in statement return spanInNode(node.statement); - case 161 /* Decorator */: + case 163 /* Decorator */: return spanInNodeArray(parent.decorators); - case 196 /* ObjectBindingPattern */: - case 197 /* ArrayBindingPattern */: + case 198 /* ObjectBindingPattern */: + case 199 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: return undefined; // Tokens: case 26 /* SemicolonToken */: @@ -150501,13 +155679,13 @@ var ts; case 29 /* LessThanToken */: return spanInGreaterThanOrLessThanToken(node); // Keywords: - case 114 /* WhileKeyword */: + case 115 /* WhileKeyword */: return spanInWhileKeyword(node); - case 90 /* ElseKeyword */: - case 82 /* CatchKeyword */: - case 95 /* FinallyKeyword */: + case 91 /* ElseKeyword */: + case 83 /* CatchKeyword */: + case 96 /* FinallyKeyword */: return spanInNextNode(node); - case 156 /* OfKeyword */: + case 158 /* OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -150519,14 +155697,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 === 78 /* Identifier */ || - node.kind === 220 /* SpreadElement */ || - node.kind === 288 /* PropertyAssignment */ || - node.kind === 289 /* ShorthandPropertyAssignment */) && + if ((node.kind === 79 /* Identifier */ || + node.kind === 222 /* SpreadElement */ || + node.kind === 290 /* PropertyAssignment */ || + node.kind === 291 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(parent)) { return textSpan(node); } - if (node.kind === 216 /* BinaryExpression */) { + if (node.kind === 218 /* 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 @@ -150535,7 +155713,7 @@ var ts; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(left); } - if (operatorToken.kind === 62 /* EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { + if (operatorToken.kind === 63 /* EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { // Set breakpoint on assignment expression element of destructuring pattern // a = expression of // [a = expression, b, c] = someExpression or @@ -150548,22 +155726,22 @@ var ts; } if (ts.isExpressionNode(node)) { switch (parent.kind) { - case 235 /* DoStatement */: + case 237 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 161 /* Decorator */: + case 163 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 237 /* ForStatement */: - case 239 /* ForOfStatement */: + case 239 /* ForStatement */: + case 241 /* ForOfStatement */: return textSpan(node); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: if (node.parent.operatorToken.kind === 27 /* CommaToken */) { // If this is a comma expression, the breakpoint is possible in this expression return textSpan(node); } break; - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -150572,21 +155750,21 @@ var ts; } } switch (node.parent.kind) { - case 288 /* PropertyAssignment */: + case 290 /* 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 206 /* TypeAssertionExpression */: + case 208 /* TypeAssertionExpression */: // Breakpoint in type assertion goes to its operand if (node.parent.type === node) { return spanInNextNode(node.parent.type); } break; - case 249 /* VariableDeclaration */: - case 160 /* Parameter */: { + case 251 /* VariableDeclaration */: + case 162 /* 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)) { @@ -150594,7 +155772,7 @@ var ts; } break; } - case 216 /* BinaryExpression */: { + case 218 /* BinaryExpression */: { var left = node.parent.left; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left) && node !== left) { // If initializer of destructuring assignment move to previous token @@ -150624,7 +155802,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 238 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 240 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } var parent = variableDeclaration.parent; @@ -150636,7 +155814,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasSyntacticModifier(variableDeclaration, 1 /* Export */) || - parent.parent.kind === 239 /* ForOfStatement */) { + parent.parent.kind === 241 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } if (ts.isVariableDeclarationList(variableDeclaration.parent) && @@ -150677,7 +155855,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasSyntacticModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 252 /* ClassDeclaration */ && functionDeclaration.kind !== 166 /* Constructor */); + (functionDeclaration.parent.kind === 254 /* ClassDeclaration */ && functionDeclaration.kind !== 168 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -150700,26 +155878,26 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement // falls through - case 236 /* WhileStatement */: - case 234 /* IfStatement */: - case 238 /* ForInStatement */: + case 238 /* WhileStatement */: + case 236 /* IfStatement */: + case 240 /* 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 237 /* ForStatement */: - case 239 /* ForOfStatement */: + case 239 /* ForStatement */: + case 241 /* 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 === 250 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 252 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -150744,21 +155922,21 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 222 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 224 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 198 /* BindingElement */) { + if (bindingPattern.parent.kind === 200 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 197 /* ArrayBindingPattern */ && node.kind !== 196 /* ObjectBindingPattern */); - var elements = node.kind === 199 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 222 /* OmittedExpression */ ? element : undefined; }); + ts.Debug.assert(node.kind !== 199 /* ArrayBindingPattern */ && node.kind !== 198 /* ObjectBindingPattern */); + var elements = node.kind === 201 /* ArrayLiteralExpression */ ? node.elements : node.properties; + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 224 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -150766,18 +155944,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 === 216 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 218 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 258 /* CaseBlock */: + case 260 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -150785,25 +155963,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 257 /* ModuleBlock */: + case 259 /* ModuleBlock */: // If this is not an instantiated module block, no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } // falls through - case 255 /* EnumDeclaration */: - case 252 /* ClassDeclaration */: + case 257 /* EnumDeclaration */: + case 254 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 230 /* Block */: + case 232 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // falls through - case 287 /* CatchClause */: + case 289 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 258 /* CaseBlock */: + case 260 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -150811,7 +155989,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 196 /* ObjectBindingPattern */: + case 198 /* 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); @@ -150827,7 +156005,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 197 /* ArrayBindingPattern */: + case 199 /* 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); @@ -150842,12 +156020,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 235 /* DoStatement */ || // Go to while keyword and do action instead - node.parent.kind === 203 /* CallExpression */ || - node.parent.kind === 204 /* NewExpression */) { + if (node.parent.kind === 237 /* DoStatement */ || // Go to while keyword and do action instead + node.parent.kind === 205 /* CallExpression */ || + node.parent.kind === 206 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 207 /* ParenthesizedExpression */) { + if (node.parent.kind === 209 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -150856,21 +156034,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 166 /* Constructor */: - case 236 /* WhileStatement */: - case 235 /* DoStatement */: - case 237 /* ForStatement */: - case 239 /* ForOfStatement */: - case 203 /* CallExpression */: - case 204 /* NewExpression */: - case 207 /* ParenthesizedExpression */: + case 210 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 211 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 168 /* Constructor */: + case 238 /* WhileStatement */: + case 237 /* DoStatement */: + case 239 /* ForStatement */: + case 241 /* ForOfStatement */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: + case 209 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -150880,20 +156058,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 288 /* PropertyAssignment */ || - node.parent.kind === 160 /* Parameter */) { + node.parent.kind === 290 /* PropertyAssignment */ || + node.parent.kind === 162 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 206 /* TypeAssertionExpression */) { + if (node.parent.kind === 208 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 235 /* DoStatement */) { + if (node.parent.kind === 237 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -150901,7 +156079,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 239 /* ForOfStatement */) { + if (node.parent.kind === 241 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -151442,11 +156620,11 @@ var ts; return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ", " + preferences + ")", function () { return _this.languageService.getCompletionsAtPosition(fileName, position, preferences); }); }; /** Get a string based representation of a completion list entry details */ - LanguageServiceShimObject.prototype.getCompletionEntryDetails = function (fileName, position, entryName, formatOptions, source, preferences) { + LanguageServiceShimObject.prototype.getCompletionEntryDetails = function (fileName, position, entryName, formatOptions, source, preferences, data) { var _this = this; return this.forwardJSONCall("getCompletionEntryDetails('" + fileName + "', " + position + ", '" + entryName + "')", function () { var localOptions = formatOptions === undefined ? undefined : JSON.parse(formatOptions); - return _this.languageService.getCompletionEntryDetails(fileName, position, entryName, localOptions, source, preferences); + return _this.languageService.getCompletionEntryDetails(fileName, position, entryName, localOptions, source, preferences, data); }); }; LanguageServiceShimObject.prototype.getFormattingEditsForRange = function (fileName, start, end, options /*Services.FormatCodeOptions*/) { @@ -151470,9 +156648,9 @@ var ts; return _this.languageService.getFormattingEditsAfterKeystroke(fileName, position, key, localOptions); }); }; - LanguageServiceShimObject.prototype.getDocCommentTemplateAtPosition = function (fileName, position) { + LanguageServiceShimObject.prototype.getDocCommentTemplateAtPosition = function (fileName, position, options) { var _this = this; - return this.forwardJSONCall("getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position); }); + return this.forwardJSONCall("getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position, options); }); }; /// NAVIGATE TO /** Return a list of symbols that are interesting to navigate to */ @@ -152484,7 +157662,7 @@ var ts; } else { type = operatorOrType; - operator = 138 /* KeyOfKeyword */; + operator = 139 /* KeyOfKeyword */; } return ts.factory.createTypeOperatorNode(operator, type); }, factoryDeprecation); @@ -152612,7 +157790,7 @@ var ts; }, factoryDeprecation); /** @deprecated Use `factory.createJSDocParameterTag` or the factory supplied by your transformation context instead. */ ts.createJSDocParamTag = ts.Debug.deprecate(function createJSDocParamTag(name, isBracketed, typeExpression, comment) { - return ts.factory.createJSDocParameterTag(/*tagName*/ undefined, name, isBracketed, typeExpression, /*isNameFirst*/ false, comment); + return ts.factory.createJSDocParameterTag(/*tagName*/ undefined, name, isBracketed, typeExpression, /*isNameFirst*/ false, comment ? ts.factory.createNodeArray([ts.factory.createJSDocText(comment)]) : undefined); }, factoryDeprecation); /** @deprecated Use `factory.createComma` or the factory supplied by your transformation context instead. */ ts.createComma = ts.Debug.deprecate(function createComma(left, right) { @@ -152662,9 +157840,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 === 297 /* SourceFile */ ? ts.parseBaseNodeFactory.createBaseSourceFileNode(kind) : - kind === 78 /* Identifier */ ? ts.parseBaseNodeFactory.createBaseIdentifierNode(kind) : - kind === 79 /* PrivateIdentifier */ ? ts.parseBaseNodeFactory.createBasePrivateIdentifierNode(kind) : + return ts.setTextRangePosEnd(kind === 299 /* SourceFile */ ? ts.parseBaseNodeFactory.createBaseSourceFileNode(kind) : + kind === 79 /* Identifier */ ? ts.parseBaseNodeFactory.createBaseIdentifierNode(kind) : + kind === 80 /* 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." }); @@ -152691,13 +157869,30 @@ var ts; // #region Renamed node Tests /** @deprecated Use `isTypeAssertionExpression` instead. */ ts.isTypeAssertion = ts.Debug.deprecate(function isTypeAssertion(node) { - return node.kind === 206 /* TypeAssertionExpression */; + return node.kind === 208 /* TypeAssertionExpression */; }, { since: "4.0", warnAfter: "4.1", message: "Use `isTypeAssertionExpression` instead." }); // #endregion + // DEPRECATION: Renamed node tests + // DEPRECATION PLAN: + // - soft: 4.2 + // - warn: 4.3 + // - error: TBD + // #region Renamed node Tests + /** + * @deprecated Use `isMemberName` instead. + */ + ts.isIdentifierOrPrivateIdentifier = ts.Debug.deprecate(function isIdentifierOrPrivateIdentifier(node) { + return ts.isMemberName(node); + }, { + since: "4.2", + warnAfter: "4.3", + message: "Use `isMemberName` instead." + }); + // #endregion Renamed node Tests })(ts || (ts = {})); diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts index 1050818279ea0..df25d19bd0c84 100644 --- a/lib/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -14,7 +14,7 @@ and limitations under the License. ***************************************************************************** */ declare namespace ts { - const versionMajorMinor = "4.2"; + const versionMajorMinor = "4.4"; /** The version of the TypeScript compiler release */ const version: string; /** @@ -166,302 +166,311 @@ declare namespace ts { QuestionQuestionToken = 60, /** Only the JSDoc scanner produces BacktickToken. The normal scanner produces NoSubstitutionTemplateLiteral and related kinds. */ BacktickToken = 61, - EqualsToken = 62, - PlusEqualsToken = 63, - MinusEqualsToken = 64, - AsteriskEqualsToken = 65, - AsteriskAsteriskEqualsToken = 66, - SlashEqualsToken = 67, - PercentEqualsToken = 68, - LessThanLessThanEqualsToken = 69, - GreaterThanGreaterThanEqualsToken = 70, - GreaterThanGreaterThanGreaterThanEqualsToken = 71, - AmpersandEqualsToken = 72, - BarEqualsToken = 73, - BarBarEqualsToken = 74, - AmpersandAmpersandEqualsToken = 75, - QuestionQuestionEqualsToken = 76, - CaretEqualsToken = 77, - Identifier = 78, - PrivateIdentifier = 79, - BreakKeyword = 80, - CaseKeyword = 81, - CatchKeyword = 82, - ClassKeyword = 83, - ConstKeyword = 84, - ContinueKeyword = 85, - DebuggerKeyword = 86, - DefaultKeyword = 87, - DeleteKeyword = 88, - DoKeyword = 89, - ElseKeyword = 90, - EnumKeyword = 91, - ExportKeyword = 92, - ExtendsKeyword = 93, - FalseKeyword = 94, - FinallyKeyword = 95, - ForKeyword = 96, - FunctionKeyword = 97, - IfKeyword = 98, - ImportKeyword = 99, - InKeyword = 100, - InstanceOfKeyword = 101, - NewKeyword = 102, - NullKeyword = 103, - ReturnKeyword = 104, - SuperKeyword = 105, - SwitchKeyword = 106, - ThisKeyword = 107, - ThrowKeyword = 108, - TrueKeyword = 109, - TryKeyword = 110, - TypeOfKeyword = 111, - VarKeyword = 112, - VoidKeyword = 113, - WhileKeyword = 114, - WithKeyword = 115, - ImplementsKeyword = 116, - InterfaceKeyword = 117, - LetKeyword = 118, - PackageKeyword = 119, - PrivateKeyword = 120, - ProtectedKeyword = 121, - PublicKeyword = 122, - StaticKeyword = 123, - YieldKeyword = 124, - AbstractKeyword = 125, - AsKeyword = 126, - AssertsKeyword = 127, - AnyKeyword = 128, - AsyncKeyword = 129, - AwaitKeyword = 130, - BooleanKeyword = 131, - ConstructorKeyword = 132, - DeclareKeyword = 133, - GetKeyword = 134, - InferKeyword = 135, - IntrinsicKeyword = 136, - IsKeyword = 137, - KeyOfKeyword = 138, - ModuleKeyword = 139, - NamespaceKeyword = 140, - NeverKeyword = 141, - ReadonlyKeyword = 142, - RequireKeyword = 143, - NumberKeyword = 144, - ObjectKeyword = 145, - SetKeyword = 146, - StringKeyword = 147, - SymbolKeyword = 148, - TypeKeyword = 149, - UndefinedKeyword = 150, - UniqueKeyword = 151, - UnknownKeyword = 152, - FromKeyword = 153, - GlobalKeyword = 154, - BigIntKeyword = 155, - OfKeyword = 156, - QualifiedName = 157, - ComputedPropertyName = 158, - TypeParameter = 159, - Parameter = 160, - Decorator = 161, - PropertySignature = 162, - PropertyDeclaration = 163, - MethodSignature = 164, - MethodDeclaration = 165, - Constructor = 166, - GetAccessor = 167, - SetAccessor = 168, - CallSignature = 169, - ConstructSignature = 170, - IndexSignature = 171, - TypePredicate = 172, - TypeReference = 173, - FunctionType = 174, - ConstructorType = 175, - TypeQuery = 176, - TypeLiteral = 177, - ArrayType = 178, - TupleType = 179, - OptionalType = 180, - RestType = 181, - UnionType = 182, - IntersectionType = 183, - ConditionalType = 184, - InferType = 185, - ParenthesizedType = 186, - ThisType = 187, - TypeOperator = 188, - IndexedAccessType = 189, - MappedType = 190, - LiteralType = 191, - NamedTupleMember = 192, - TemplateLiteralType = 193, - TemplateLiteralTypeSpan = 194, - ImportType = 195, - ObjectBindingPattern = 196, - ArrayBindingPattern = 197, - BindingElement = 198, - ArrayLiteralExpression = 199, - ObjectLiteralExpression = 200, - PropertyAccessExpression = 201, - ElementAccessExpression = 202, - CallExpression = 203, - NewExpression = 204, - TaggedTemplateExpression = 205, - TypeAssertionExpression = 206, - ParenthesizedExpression = 207, - FunctionExpression = 208, - ArrowFunction = 209, - DeleteExpression = 210, - TypeOfExpression = 211, - VoidExpression = 212, - AwaitExpression = 213, - PrefixUnaryExpression = 214, - PostfixUnaryExpression = 215, - BinaryExpression = 216, - ConditionalExpression = 217, - TemplateExpression = 218, - YieldExpression = 219, - SpreadElement = 220, - ClassExpression = 221, - OmittedExpression = 222, - ExpressionWithTypeArguments = 223, - AsExpression = 224, - NonNullExpression = 225, - MetaProperty = 226, - SyntheticExpression = 227, - TemplateSpan = 228, - SemicolonClassElement = 229, - Block = 230, - EmptyStatement = 231, - VariableStatement = 232, - ExpressionStatement = 233, - IfStatement = 234, - DoStatement = 235, - WhileStatement = 236, - ForStatement = 237, - ForInStatement = 238, - ForOfStatement = 239, - ContinueStatement = 240, - BreakStatement = 241, - ReturnStatement = 242, - WithStatement = 243, - SwitchStatement = 244, - LabeledStatement = 245, - ThrowStatement = 246, - TryStatement = 247, - DebuggerStatement = 248, - VariableDeclaration = 249, - VariableDeclarationList = 250, - FunctionDeclaration = 251, - ClassDeclaration = 252, - InterfaceDeclaration = 253, - TypeAliasDeclaration = 254, - EnumDeclaration = 255, - ModuleDeclaration = 256, - ModuleBlock = 257, - CaseBlock = 258, - NamespaceExportDeclaration = 259, - ImportEqualsDeclaration = 260, - ImportDeclaration = 261, - ImportClause = 262, - NamespaceImport = 263, - NamedImports = 264, - ImportSpecifier = 265, - ExportAssignment = 266, - ExportDeclaration = 267, - NamedExports = 268, - NamespaceExport = 269, - ExportSpecifier = 270, - MissingDeclaration = 271, - ExternalModuleReference = 272, - JsxElement = 273, - JsxSelfClosingElement = 274, - JsxOpeningElement = 275, - JsxClosingElement = 276, - JsxFragment = 277, - JsxOpeningFragment = 278, - JsxClosingFragment = 279, - JsxAttribute = 280, - JsxAttributes = 281, - JsxSpreadAttribute = 282, - JsxExpression = 283, - CaseClause = 284, - DefaultClause = 285, - HeritageClause = 286, - CatchClause = 287, - PropertyAssignment = 288, - ShorthandPropertyAssignment = 289, - SpreadAssignment = 290, - EnumMember = 291, - UnparsedPrologue = 292, - UnparsedPrepend = 293, - UnparsedText = 294, - UnparsedInternalText = 295, - UnparsedSyntheticReference = 296, - SourceFile = 297, - Bundle = 298, - UnparsedSource = 299, - InputFiles = 300, - JSDocTypeExpression = 301, - JSDocNameReference = 302, - JSDocAllType = 303, - JSDocUnknownType = 304, - JSDocNullableType = 305, - JSDocNonNullableType = 306, - JSDocOptionalType = 307, - JSDocFunctionType = 308, - JSDocVariadicType = 309, - JSDocNamepathType = 310, - JSDocComment = 311, - JSDocTypeLiteral = 312, - JSDocSignature = 313, - JSDocTag = 314, - JSDocAugmentsTag = 315, - JSDocImplementsTag = 316, - JSDocAuthorTag = 317, - JSDocDeprecatedTag = 318, - JSDocClassTag = 319, - JSDocPublicTag = 320, - JSDocPrivateTag = 321, - JSDocProtectedTag = 322, - JSDocReadonlyTag = 323, - JSDocCallbackTag = 324, - JSDocEnumTag = 325, - JSDocParameterTag = 326, - JSDocReturnTag = 327, - JSDocThisTag = 328, - JSDocTypeTag = 329, - JSDocTemplateTag = 330, - JSDocTypedefTag = 331, - JSDocSeeTag = 332, - JSDocPropertyTag = 333, - SyntaxList = 334, - NotEmittedStatement = 335, - PartiallyEmittedExpression = 336, - CommaListExpression = 337, - MergeDeclarationMarker = 338, - EndOfDeclarationMarker = 339, - SyntheticReferenceExpression = 340, - Count = 341, - FirstAssignment = 62, - LastAssignment = 77, - FirstCompoundAssignment = 63, - LastCompoundAssignment = 77, - FirstReservedWord = 80, - LastReservedWord = 115, - FirstKeyword = 80, - LastKeyword = 156, - FirstFutureReservedWord = 116, - LastFutureReservedWord = 124, - FirstTypeNode = 172, - LastTypeNode = 195, + /** Only the JSDoc scanner produces HashToken. The normal scanner produces PrivateIdentifier. */ + HashToken = 62, + EqualsToken = 63, + PlusEqualsToken = 64, + MinusEqualsToken = 65, + AsteriskEqualsToken = 66, + AsteriskAsteriskEqualsToken = 67, + SlashEqualsToken = 68, + PercentEqualsToken = 69, + LessThanLessThanEqualsToken = 70, + GreaterThanGreaterThanEqualsToken = 71, + GreaterThanGreaterThanGreaterThanEqualsToken = 72, + AmpersandEqualsToken = 73, + BarEqualsToken = 74, + BarBarEqualsToken = 75, + AmpersandAmpersandEqualsToken = 76, + QuestionQuestionEqualsToken = 77, + CaretEqualsToken = 78, + Identifier = 79, + PrivateIdentifier = 80, + BreakKeyword = 81, + CaseKeyword = 82, + CatchKeyword = 83, + ClassKeyword = 84, + ConstKeyword = 85, + ContinueKeyword = 86, + DebuggerKeyword = 87, + DefaultKeyword = 88, + DeleteKeyword = 89, + DoKeyword = 90, + ElseKeyword = 91, + EnumKeyword = 92, + ExportKeyword = 93, + ExtendsKeyword = 94, + FalseKeyword = 95, + FinallyKeyword = 96, + ForKeyword = 97, + FunctionKeyword = 98, + IfKeyword = 99, + ImportKeyword = 100, + InKeyword = 101, + InstanceOfKeyword = 102, + NewKeyword = 103, + NullKeyword = 104, + ReturnKeyword = 105, + SuperKeyword = 106, + SwitchKeyword = 107, + ThisKeyword = 108, + ThrowKeyword = 109, + TrueKeyword = 110, + TryKeyword = 111, + TypeOfKeyword = 112, + VarKeyword = 113, + VoidKeyword = 114, + WhileKeyword = 115, + WithKeyword = 116, + ImplementsKeyword = 117, + InterfaceKeyword = 118, + LetKeyword = 119, + PackageKeyword = 120, + PrivateKeyword = 121, + ProtectedKeyword = 122, + PublicKeyword = 123, + StaticKeyword = 124, + YieldKeyword = 125, + AbstractKeyword = 126, + AsKeyword = 127, + AssertsKeyword = 128, + AnyKeyword = 129, + AsyncKeyword = 130, + AwaitKeyword = 131, + BooleanKeyword = 132, + ConstructorKeyword = 133, + DeclareKeyword = 134, + GetKeyword = 135, + InferKeyword = 136, + IntrinsicKeyword = 137, + IsKeyword = 138, + KeyOfKeyword = 139, + ModuleKeyword = 140, + NamespaceKeyword = 141, + NeverKeyword = 142, + ReadonlyKeyword = 143, + RequireKeyword = 144, + NumberKeyword = 145, + ObjectKeyword = 146, + SetKeyword = 147, + StringKeyword = 148, + SymbolKeyword = 149, + TypeKeyword = 150, + UndefinedKeyword = 151, + UniqueKeyword = 152, + UnknownKeyword = 153, + FromKeyword = 154, + GlobalKeyword = 155, + BigIntKeyword = 156, + OverrideKeyword = 157, + OfKeyword = 158, + QualifiedName = 159, + ComputedPropertyName = 160, + TypeParameter = 161, + Parameter = 162, + Decorator = 163, + PropertySignature = 164, + PropertyDeclaration = 165, + MethodSignature = 166, + MethodDeclaration = 167, + Constructor = 168, + GetAccessor = 169, + SetAccessor = 170, + CallSignature = 171, + ConstructSignature = 172, + IndexSignature = 173, + TypePredicate = 174, + TypeReference = 175, + FunctionType = 176, + ConstructorType = 177, + TypeQuery = 178, + TypeLiteral = 179, + ArrayType = 180, + TupleType = 181, + OptionalType = 182, + RestType = 183, + UnionType = 184, + IntersectionType = 185, + ConditionalType = 186, + InferType = 187, + ParenthesizedType = 188, + ThisType = 189, + TypeOperator = 190, + IndexedAccessType = 191, + MappedType = 192, + LiteralType = 193, + NamedTupleMember = 194, + TemplateLiteralType = 195, + TemplateLiteralTypeSpan = 196, + ImportType = 197, + ObjectBindingPattern = 198, + ArrayBindingPattern = 199, + BindingElement = 200, + ArrayLiteralExpression = 201, + ObjectLiteralExpression = 202, + PropertyAccessExpression = 203, + ElementAccessExpression = 204, + CallExpression = 205, + NewExpression = 206, + TaggedTemplateExpression = 207, + TypeAssertionExpression = 208, + ParenthesizedExpression = 209, + FunctionExpression = 210, + ArrowFunction = 211, + DeleteExpression = 212, + TypeOfExpression = 213, + VoidExpression = 214, + AwaitExpression = 215, + PrefixUnaryExpression = 216, + PostfixUnaryExpression = 217, + BinaryExpression = 218, + ConditionalExpression = 219, + TemplateExpression = 220, + YieldExpression = 221, + SpreadElement = 222, + ClassExpression = 223, + OmittedExpression = 224, + ExpressionWithTypeArguments = 225, + AsExpression = 226, + NonNullExpression = 227, + MetaProperty = 228, + SyntheticExpression = 229, + TemplateSpan = 230, + SemicolonClassElement = 231, + Block = 232, + EmptyStatement = 233, + VariableStatement = 234, + ExpressionStatement = 235, + IfStatement = 236, + DoStatement = 237, + WhileStatement = 238, + ForStatement = 239, + ForInStatement = 240, + ForOfStatement = 241, + ContinueStatement = 242, + BreakStatement = 243, + ReturnStatement = 244, + WithStatement = 245, + SwitchStatement = 246, + LabeledStatement = 247, + ThrowStatement = 248, + TryStatement = 249, + DebuggerStatement = 250, + VariableDeclaration = 251, + VariableDeclarationList = 252, + FunctionDeclaration = 253, + ClassDeclaration = 254, + InterfaceDeclaration = 255, + TypeAliasDeclaration = 256, + EnumDeclaration = 257, + ModuleDeclaration = 258, + ModuleBlock = 259, + CaseBlock = 260, + NamespaceExportDeclaration = 261, + ImportEqualsDeclaration = 262, + ImportDeclaration = 263, + ImportClause = 264, + NamespaceImport = 265, + NamedImports = 266, + ImportSpecifier = 267, + ExportAssignment = 268, + ExportDeclaration = 269, + NamedExports = 270, + NamespaceExport = 271, + ExportSpecifier = 272, + MissingDeclaration = 273, + ExternalModuleReference = 274, + JsxElement = 275, + JsxSelfClosingElement = 276, + JsxOpeningElement = 277, + JsxClosingElement = 278, + JsxFragment = 279, + JsxOpeningFragment = 280, + JsxClosingFragment = 281, + JsxAttribute = 282, + JsxAttributes = 283, + JsxSpreadAttribute = 284, + JsxExpression = 285, + CaseClause = 286, + DefaultClause = 287, + HeritageClause = 288, + CatchClause = 289, + PropertyAssignment = 290, + ShorthandPropertyAssignment = 291, + SpreadAssignment = 292, + EnumMember = 293, + UnparsedPrologue = 294, + UnparsedPrepend = 295, + UnparsedText = 296, + UnparsedInternalText = 297, + UnparsedSyntheticReference = 298, + SourceFile = 299, + Bundle = 300, + UnparsedSource = 301, + InputFiles = 302, + JSDocTypeExpression = 303, + JSDocNameReference = 304, + JSDocMemberName = 305, + JSDocAllType = 306, + JSDocUnknownType = 307, + JSDocNullableType = 308, + JSDocNonNullableType = 309, + JSDocOptionalType = 310, + JSDocFunctionType = 311, + JSDocVariadicType = 312, + JSDocNamepathType = 313, + JSDocComment = 314, + JSDocText = 315, + JSDocTypeLiteral = 316, + JSDocSignature = 317, + JSDocLink = 318, + JSDocLinkCode = 319, + JSDocLinkPlain = 320, + JSDocTag = 321, + JSDocAugmentsTag = 322, + JSDocImplementsTag = 323, + JSDocAuthorTag = 324, + JSDocDeprecatedTag = 325, + JSDocClassTag = 326, + JSDocPublicTag = 327, + JSDocPrivateTag = 328, + JSDocProtectedTag = 329, + JSDocReadonlyTag = 330, + JSDocOverrideTag = 331, + JSDocCallbackTag = 332, + JSDocEnumTag = 333, + JSDocParameterTag = 334, + JSDocReturnTag = 335, + JSDocThisTag = 336, + JSDocTypeTag = 337, + JSDocTemplateTag = 338, + JSDocTypedefTag = 339, + JSDocSeeTag = 340, + JSDocPropertyTag = 341, + SyntaxList = 342, + NotEmittedStatement = 343, + PartiallyEmittedExpression = 344, + CommaListExpression = 345, + MergeDeclarationMarker = 346, + EndOfDeclarationMarker = 347, + SyntheticReferenceExpression = 348, + Count = 349, + FirstAssignment = 63, + LastAssignment = 78, + FirstCompoundAssignment = 64, + LastCompoundAssignment = 78, + FirstReservedWord = 81, + LastReservedWord = 116, + FirstKeyword = 81, + LastKeyword = 158, + FirstFutureReservedWord = 117, + LastFutureReservedWord = 125, + FirstTypeNode = 174, + LastTypeNode = 197, FirstPunctuation = 18, - LastPunctuation = 77, + LastPunctuation = 78, FirstToken = 0, - LastToken = 156, + LastToken = 158, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -469,25 +478,25 @@ declare namespace ts { FirstTemplateToken = 14, LastTemplateToken = 17, FirstBinaryOperator = 29, - LastBinaryOperator = 77, - FirstStatement = 232, - LastStatement = 248, - FirstNode = 157, - FirstJSDocNode = 301, - LastJSDocNode = 333, - FirstJSDocTagNode = 314, - LastJSDocTagNode = 333, + LastBinaryOperator = 78, + FirstStatement = 234, + LastStatement = 250, + FirstNode = 159, + FirstJSDocNode = 303, + LastJSDocNode = 341, + FirstJSDocTagNode = 321, + LastJSDocTagNode = 341, } export type TriviaSyntaxKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia; export type LiteralSyntaxKind = SyntaxKind.NumericLiteral | SyntaxKind.BigIntLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral; export type PseudoLiteralSyntaxKind = SyntaxKind.TemplateHead | SyntaxKind.TemplateMiddle | SyntaxKind.TemplateTail; - export type PunctuationSyntaxKind = SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.OpenParenToken | SyntaxKind.CloseParenToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.DotToken | SyntaxKind.DotDotDotToken | SyntaxKind.SemicolonToken | SyntaxKind.CommaToken | SyntaxKind.QuestionDotToken | SyntaxKind.LessThanToken | SyntaxKind.LessThanSlashToken | SyntaxKind.GreaterThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.EqualsEqualsToken | SyntaxKind.ExclamationEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.EqualsGreaterThanToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.AsteriskToken | SyntaxKind.AsteriskAsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken | SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken | SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken | SyntaxKind.ExclamationToken | SyntaxKind.TildeToken | SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken | SyntaxKind.QuestionQuestionToken | SyntaxKind.QuestionToken | SyntaxKind.ColonToken | SyntaxKind.AtToken | SyntaxKind.BacktickToken | SyntaxKind.EqualsToken | SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken; - export type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.AssertsKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InferKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.OfKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword; - export type ModifierSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.ConstKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.ExportKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.StaticKeyword; + export type PunctuationSyntaxKind = SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.OpenParenToken | SyntaxKind.CloseParenToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.DotToken | SyntaxKind.DotDotDotToken | SyntaxKind.SemicolonToken | SyntaxKind.CommaToken | SyntaxKind.QuestionDotToken | SyntaxKind.LessThanToken | SyntaxKind.LessThanSlashToken | SyntaxKind.GreaterThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.EqualsEqualsToken | SyntaxKind.ExclamationEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.EqualsGreaterThanToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.AsteriskToken | SyntaxKind.AsteriskAsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken | SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken | SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken | SyntaxKind.ExclamationToken | SyntaxKind.TildeToken | SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken | SyntaxKind.QuestionQuestionToken | SyntaxKind.QuestionToken | SyntaxKind.ColonToken | SyntaxKind.AtToken | SyntaxKind.BacktickToken | SyntaxKind.HashToken | SyntaxKind.EqualsToken | SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken; + export type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.AssertsKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InferKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.OfKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.RequireKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword; + export type ModifierSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.ConstKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.ExportKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.StaticKeyword; export type KeywordTypeSyntaxKind = SyntaxKind.AnyKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VoidKeyword; export type TokenSyntaxKind = SyntaxKind.Unknown | SyntaxKind.EndOfFileToken | TriviaSyntaxKind | LiteralSyntaxKind | PseudoLiteralSyntaxKind | PunctuationSyntaxKind | SyntaxKind.Identifier | KeywordSyntaxKind; export type JsxTokenSyntaxKind = SyntaxKind.LessThanSlashToken | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken; - export type JSDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.GreaterThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.BacktickToken | SyntaxKind.Unknown | KeywordSyntaxKind; + export type JSDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.GreaterThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.BacktickToken | SyntaxKind.HashToken | SyntaxKind.Unknown | KeywordSyntaxKind; export enum NodeFlags { None = 0, Let = 1, @@ -533,13 +542,14 @@ declare namespace ts { Const = 2048, HasComputedJSDocModifiers = 4096, Deprecated = 8192, + Override = 16384, HasComputedFlags = 536870912, AccessibilityModifier = 28, - ParameterPropertyModifier = 92, + ParameterPropertyModifier = 16476, NonPublicAccessibilityModifier = 24, - TypeScriptModifier = 2270, + TypeScriptModifier = 18654, ExportDefault = 513, - All = 11263 + All = 27647 } export enum JsxFlags { None = 0, @@ -558,7 +568,7 @@ declare namespace ts { } export interface JSDocContainer { } - export type HasJSDoc = ParameterDeclaration | CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | PropertySignature | ArrowFunction | ParenthesizedExpression | SpreadAssignment | ShorthandPropertyAssignment | PropertyAssignment | FunctionExpression | LabeledStatement | ExpressionStatement | VariableStatement | FunctionDeclaration | ConstructorDeclaration | MethodDeclaration | PropertyDeclaration | AccessorDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | EnumMember | EnumDeclaration | ModuleDeclaration | ImportEqualsDeclaration | ImportDeclaration | NamespaceExportDeclaration | ExportAssignment | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | ExportDeclaration | NamedTupleMember | EndOfFileToken; + export type HasJSDoc = ParameterDeclaration | CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | PropertySignature | ArrowFunction | ParenthesizedExpression | SpreadAssignment | ShorthandPropertyAssignment | PropertyAssignment | FunctionExpression | EmptyStatement | DebuggerStatement | Block | VariableStatement | ExpressionStatement | IfStatement | DoStatement | WhileStatement | ForStatement | ForInStatement | ForOfStatement | BreakStatement | ContinueStatement | ReturnStatement | WithStatement | SwitchStatement | LabeledStatement | ThrowStatement | TryStatement | FunctionDeclaration | ConstructorDeclaration | MethodDeclaration | VariableDeclaration | PropertyDeclaration | AccessorDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | EnumMember | EnumDeclaration | ModuleDeclaration | ImportEqualsDeclaration | ImportDeclaration | NamespaceExportDeclaration | ExportAssignment | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | ExportDeclaration | NamedTupleMember | EndOfFileToken; export type HasType = SignatureDeclaration | VariableDeclaration | ParameterDeclaration | PropertySignature | PropertyDeclaration | TypePredicateNode | ParenthesizedTypeNode | TypeOperatorNode | MappedTypeNode | AssertionExpression | TypeAliasDeclaration | JSDocTypeExpression | JSDocNonNullableType | JSDocNullableType | JSDocOptionalType | JSDocVariadicType; export type HasTypeArguments = CallExpression | NewExpression | TaggedTemplateExpression | JsxOpeningElement | JsxSelfClosingElement; export type HasInitializer = HasExpressionInitializer | ForStatement | ForInStatement | ForOfStatement | JsxAttribute; @@ -603,10 +613,11 @@ declare namespace ts { export type ProtectedKeyword = ModifierToken; export type PublicKeyword = ModifierToken; export type ReadonlyKeyword = ModifierToken; + export type OverrideKeyword = ModifierToken; export type StaticKeyword = ModifierToken; /** @deprecated Use `ReadonlyKeyword` instead. */ export type ReadonlyToken = ReadonlyKeyword; - export type Modifier = AbstractKeyword | AsyncKeyword | ConstKeyword | DeclareKeyword | DefaultKeyword | ExportKeyword | PrivateKeyword | ProtectedKeyword | PublicKeyword | ReadonlyKeyword | StaticKeyword; + export type Modifier = AbstractKeyword | AsyncKeyword | ConstKeyword | DeclareKeyword | DefaultKeyword | ExportKeyword | PrivateKeyword | ProtectedKeyword | PublicKeyword | OverrideKeyword | ReadonlyKeyword | StaticKeyword; export type AccessibilityModifier = PublicKeyword | PrivateKeyword | ProtectedKeyword; export type ParameterPropertyModifier = AccessibilityModifier | ReadonlyKeyword; export type ClassMemberModifier = AccessibilityModifier | ReadonlyKeyword | StaticKeyword; @@ -638,6 +649,7 @@ declare namespace ts { } export type EntityName = Identifier | QualifiedName; export type PropertyName = Identifier | StringLiteral | NumericLiteral | ComputedPropertyName | PrivateIdentifier; + export type MemberName = Identifier | PrivateIdentifier; export type DeclarationName = Identifier | PrivateIdentifier | StringLiteralLike | NumericLiteral | ComputedPropertyName | ElementAccessExpression | BindingPattern | EntityNameExpression; export interface Declaration extends Node { _declarationBrand: any; @@ -686,7 +698,7 @@ declare namespace ts { readonly kind: SyntaxKind.ConstructSignature; } export type BindingName = Identifier | BindingPattern; - export interface VariableDeclaration extends NamedDeclaration { + export interface VariableDeclaration extends NamedDeclaration, JSDocContainer { readonly kind: SyntaxKind.VariableDeclaration; readonly parent: VariableDeclarationList | CatchClause; readonly name: BindingName; @@ -820,15 +832,15 @@ declare namespace ts { readonly kind: SyntaxKind.SemicolonClassElement; readonly parent: ClassLikeDeclaration; } - export interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { + export interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, TypeElement, ObjectLiteralElement, JSDocContainer { readonly kind: SyntaxKind.GetAccessor; - readonly parent: ClassLikeDeclaration | ObjectLiteralExpression; + readonly parent: ClassLikeDeclaration | ObjectLiteralExpression | TypeLiteralNode | InterfaceDeclaration; readonly name: PropertyName; readonly body?: FunctionBody; } - export interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { + export interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, TypeElement, ObjectLiteralElement, JSDocContainer { readonly kind: SyntaxKind.SetAccessor; - readonly parent: ClassLikeDeclaration | ObjectLiteralExpression; + readonly parent: ClassLikeDeclaration | ObjectLiteralExpression | TypeLiteralNode | InterfaceDeclaration; readonly name: PropertyName; readonly body?: FunctionBody; } @@ -1216,11 +1228,11 @@ declare namespace ts { readonly kind: SyntaxKind.PropertyAccessExpression; readonly expression: LeftHandSideExpression; readonly questionDotToken?: QuestionDotToken; - readonly name: Identifier | PrivateIdentifier; + readonly name: MemberName; } export interface PropertyAccessChain extends PropertyAccessExpression { _optionalChainBrand: any; - readonly name: Identifier | PrivateIdentifier; + readonly name: MemberName; } export interface SuperPropertyAccessExpression extends PropertyAccessExpression { readonly expression: SuperExpression; @@ -1373,7 +1385,7 @@ declare namespace ts { readonly containsOnlyTriviaWhiteSpaces: boolean; } export type JsxChild = JsxText | JsxExpression | JsxElement | JsxSelfClosingElement | JsxFragment; - export interface Statement extends Node { + export interface Statement extends Node, JSDocContainer { _statementBrand: any; } export interface NotEmittedStatement extends Statement { @@ -1401,11 +1413,11 @@ declare namespace ts { readonly kind: SyntaxKind.Block; readonly statements: NodeArray; } - export interface VariableStatement extends Statement, JSDocContainer { + export interface VariableStatement extends Statement { readonly kind: SyntaxKind.VariableStatement; readonly declarationList: VariableDeclarationList; } - export interface ExpressionStatement extends Statement, JSDocContainer { + export interface ExpressionStatement extends Statement { readonly kind: SyntaxKind.ExpressionStatement; readonly expression: Expression; } @@ -1486,7 +1498,7 @@ declare namespace ts { readonly statements: NodeArray; } export type CaseOrDefaultClause = CaseClause | DefaultClause; - export interface LabeledStatement extends Statement, JSDocContainer { + export interface LabeledStatement extends Statement { readonly kind: SyntaxKind.LabeledStatement; readonly label: Identifier; readonly statement: Statement; @@ -1606,7 +1618,7 @@ declare namespace ts { readonly parent: ImportEqualsDeclaration; readonly expression: Expression; } - export interface ImportDeclaration extends Statement, JSDocContainer { + export interface ImportDeclaration extends Statement { readonly kind: SyntaxKind.ImportDeclaration; readonly parent: SourceFile | ModuleBlock; readonly importClause?: ImportClause; @@ -1703,7 +1715,13 @@ declare namespace ts { } export interface JSDocNameReference extends Node { readonly kind: SyntaxKind.JSDocNameReference; - readonly name: EntityName; + readonly name: EntityName | JSDocMemberName; + } + /** Class#method reference in JSDoc */ + export interface JSDocMemberName extends Node { + readonly kind: SyntaxKind.JSDocMemberName; + readonly left: EntityName | JSDocMemberName; + readonly right: Identifier; } export interface JSDocType extends TypeNode { _jsDocTypeBrand: any; @@ -1742,12 +1760,32 @@ declare namespace ts { readonly kind: SyntaxKind.JSDocComment; readonly parent: HasJSDoc; readonly tags?: NodeArray; - readonly comment?: string; + readonly comment?: string | NodeArray; } export interface JSDocTag extends Node { readonly parent: JSDoc | JSDocTypeLiteral; readonly tagName: Identifier; - readonly comment?: string; + readonly comment?: string | NodeArray; + } + export interface JSDocLink extends Node { + readonly kind: SyntaxKind.JSDocLink; + readonly name?: EntityName | JSDocMemberName; + text: string; + } + export interface JSDocLinkCode extends Node { + readonly kind: SyntaxKind.JSDocLinkCode; + readonly name?: EntityName | JSDocMemberName; + text: string; + } + export interface JSDocLinkPlain extends Node { + readonly kind: SyntaxKind.JSDocLinkPlain; + readonly name?: EntityName | JSDocMemberName; + text: string; + } + export type JSDocComment = JSDocText | JSDocLink | JSDocLinkCode | JSDocLinkPlain; + export interface JSDocText extends Node { + readonly kind: SyntaxKind.JSDocText; + text: string; } export interface JSDocUnknownTag extends JSDocTag { readonly kind: SyntaxKind.JSDocTag; @@ -1789,6 +1827,9 @@ declare namespace ts { export interface JSDocReadonlyTag extends JSDocTag { readonly kind: SyntaxKind.JSDocReadonlyTag; } + export interface JSDocOverrideTag extends JSDocTag { + readonly kind: SyntaxKind.JSDocOverrideTag; + } export interface JSDocEnumTag extends JSDocTag, Declaration { readonly kind: SyntaxKind.JSDocEnumTag; readonly parent: JSDoc; @@ -2080,7 +2121,6 @@ declare namespace ts { * Gets a type checker that can be used to semantically analyze source files in the program. */ getTypeChecker(): TypeChecker; - getTypeCatalog(): readonly Type[]; getNodeCount(): number; getIdentifierCount(): number; getSymbolCount(): number; @@ -2186,7 +2226,7 @@ declare namespace ts { * The function returns the value (local variable) symbol of an identifier in the short-hand property assignment. * This is necessary as an identifier in short-hand property assignment can contains two meaning: property name and property value. */ - getShorthandAssignmentValueSymbol(location: Node): Symbol | undefined; + getShorthandAssignmentValueSymbol(location: Node | undefined): Symbol | undefined; getExportSpecifierLocalTargetSymbol(location: ExportSpecifier | Identifier): Symbol | undefined; /** * If a symbol is a local symbol with an associated exported symbol, returns the exported symbol. @@ -2261,6 +2301,8 @@ declare namespace ts { NoTypeReduction = 536870912, NoUndefinedOptionalParameterType = 1073741824, AllowThisInObjectLiteral = 32768, + AllowQualifiedNameInPlaceOfIdentifier = 65536, + /** @deprecated AllowQualifedNameInPlaceOfIdentifier. Use AllowQualifiedNameInPlaceOfIdentifier instead. */ AllowQualifedNameInPlaceOfIdentifier = 65536, AllowAnonymousIdentifier = 131072, AllowEmptyUnionOrIntersection = 262144, @@ -2271,8 +2313,7 @@ declare namespace ts { IgnoreErrors = 70221824, InObjectTypeLiteral = 4194304, InTypeAlias = 8388608, - InInitialEntityName = 16777216, - InReverseMappedType = 33554432 + InInitialEntityName = 16777216 } export enum TypeFormatFlags { None = 0, @@ -2405,8 +2446,8 @@ declare namespace ts { export interface Symbol { flags: SymbolFlags; escapedName: __String; - declarations: Declaration[]; - valueDeclaration: Declaration; + declarations?: Declaration[]; + valueDeclaration?: Declaration; members?: SymbolTable; exports?: SymbolTable; globalExports?: SymbolTable; @@ -2540,15 +2581,15 @@ declare namespace ts { ObjectLiteral = 128, EvolvingArray = 256, ObjectLiteralPatternWithComputedProperties = 512, - ContainsSpread = 1024, - ReverseMapped = 2048, - JsxAttributes = 4096, - MarkerType = 8192, - JSLiteral = 16384, - FreshLiteral = 32768, - ArrayLiteral = 65536, - ObjectRestType = 131072, + ReverseMapped = 1024, + JsxAttributes = 2048, + MarkerType = 4096, + JSLiteral = 8192, + FreshLiteral = 16384, + ArrayLiteral = 32768, ClassOrInterface = 3, + ContainsSpread = 4194304, + ObjectRestType = 8388608, } export interface ObjectType extends Type { objectFlags: ObjectFlags; @@ -2656,14 +2697,13 @@ declare namespace ts { export interface TemplateLiteralType extends InstantiableType { texts: readonly string[]; types: readonly Type[]; - freshType: TemplateLiteralType; - regularType: TemplateLiteralType; } export interface StringMappingType extends InstantiableType { symbol: Symbol; type: Type; } export interface SubstitutionType extends InstantiableType { + objectFlags: ObjectFlags; baseType: Type; substitute: Type; } @@ -2688,16 +2728,17 @@ declare namespace ts { export enum InferencePriority { NakedTypeVariable = 1, SpeculativeTuple = 2, - HomomorphicMappedType = 4, - PartialHomomorphicMappedType = 8, - MappedTypeConstraint = 16, - ContravariantConditional = 32, - ReturnType = 64, - LiteralKeyof = 128, - NoConstraints = 256, - AlwaysStrict = 512, - MaxValue = 1024, - PriorityImpliesCombination = 208, + SubstituteSource = 4, + HomomorphicMappedType = 8, + PartialHomomorphicMappedType = 16, + MappedTypeConstraint = 32, + ContravariantConditional = 64, + ReturnType = 128, + LiteralKeyof = 256, + NoConstraints = 512, + AlwaysStrict = 1024, + MaxValue = 2048, + PriorityImpliesCombination = 416, Circularity = -1 } /** @deprecated Use FileExtensionInfo instead. */ @@ -2774,18 +2815,21 @@ declare namespace ts { FixedPollingInterval = 0, PriorityPollingInterval = 1, DynamicPriorityPolling = 2, - UseFsEvents = 3, - UseFsEventsOnParentDirectory = 4 + FixedChunkSizePolling = 3, + UseFsEvents = 4, + UseFsEventsOnParentDirectory = 5 } export enum WatchDirectoryKind { UseFsEvents = 0, FixedPollingInterval = 1, - DynamicPriorityPolling = 2 + DynamicPriorityPolling = 2, + FixedChunkSizePolling = 3 } export enum PollingWatchKind { FixedInterval = 0, PriorityInterval = 1, - DynamicPriority = 2 + DynamicPriority = 2, + FixedChunkSize = 3 } export type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[] | ProjectReference[] | null | undefined; export interface CompilerOptions { @@ -2847,6 +2891,7 @@ declare namespace ts { outFile?: string; paths?: MapLike; preserveConstEnums?: boolean; + noImplicitOverride?: boolean; preserveSymlinks?: boolean; project?: string; reactNamespace?: string; @@ -2868,11 +2913,13 @@ declare namespace ts { strictBindCallApply?: boolean; strictNullChecks?: boolean; strictPropertyInitialization?: boolean; + strictOptionalProperties?: boolean; stripInternal?: boolean; suppressExcessPropertyErrors?: boolean; suppressImplicitAnyIndexErrors?: boolean; target?: ScriptTarget; traceResolution?: boolean; + useUnknownInCatchVariables?: boolean; resolveJsonModule?: boolean; types?: string[]; /** Paths used to compute primary types search locations */ @@ -2957,6 +3004,7 @@ declare namespace ts { ES2018 = 5, ES2019 = 6, ES2020 = 7, + ES2021 = 8, ESNext = 99, JSON = 100, Latest = 99 @@ -3130,17 +3178,21 @@ declare namespace ts { Iterator = 8388608, NoAsciiEscaping = 16777216, } - export interface EmitHelper { + export interface EmitHelperBase { readonly name: string; readonly scoped: boolean; readonly text: string | ((node: EmitHelperUniqueNameCallback) => string); readonly priority?: number; readonly dependencies?: EmitHelper[]; } - export interface UnscopedEmitHelper extends EmitHelper { + export interface ScopedEmitHelper extends EmitHelperBase { + readonly scoped: true; + } + export interface UnscopedEmitHelper extends EmitHelperBase { readonly scoped: false; readonly text: string; } + export type EmitHelper = ScopedEmitHelper | UnscopedEmitHelper; export type EmitHelperUniqueNameCallback = (name: string) => string; export enum EmitHint { SourceFile = 0, @@ -3168,14 +3220,27 @@ declare namespace ts { createStringLiteralFromNode(sourceNode: PropertyNameLiteral, isSingleQuote?: boolean): StringLiteral; createRegularExpressionLiteral(text: string): RegularExpressionLiteral; createIdentifier(text: string): Identifier; - /** Create a unique temporary variable. */ - createTempVariable(recordTempVariable: ((node: Identifier) => void) | undefined): Identifier; - /** Create a unique temporary variable for use in a loop. */ - createLoopVariable(): Identifier; + /** + * Create a unique temporary variable. + * @param recordTempVariable An optional callback used to record the temporary variable name. This + * should usually be a reference to `hoistVariableDeclaration` from a `TransformationContext`, but + * can be `undefined` if you plan to record the temporary variable manually. + * @param reservedInNestedScopes When `true`, reserves the temporary variable name in all nested scopes + * during emit so that the variable can be referenced in a nested function body. This is an alternative to + * setting `EmitFlags.ReuseTempVariableScope` on the nested function itself. + */ + createTempVariable(recordTempVariable: ((node: Identifier) => void) | undefined, reservedInNestedScopes?: boolean): Identifier; + /** + * Create a unique temporary variable for use in a loop. + * @param reservedInNestedScopes When `true`, reserves the temporary variable name in all nested scopes + * during emit so that the variable can be referenced in a nested function body. This is an alternative to + * setting `EmitFlags.ReuseTempVariableScope` on the nested function itself. + */ + createLoopVariable(reservedInNestedScopes?: boolean): Identifier; /** Create a unique name based on the supplied text. */ createUniqueName(text: string, flags?: GeneratedIdentifierFlags): Identifier; /** Create a unique name generated for a node. */ - getGeneratedNameForNode(node: Node | undefined): Identifier; + getGeneratedNameForNode(node: Node | undefined, flags?: GeneratedIdentifierFlags): Identifier; createPrivateIdentifier(text: string): PrivateIdentifier; createToken(token: SyntaxKind.SuperKeyword): SuperExpression; createToken(token: SyntaxKind.ThisKeyword): ThisExpression; @@ -3286,10 +3351,10 @@ declare namespace ts { updateArrayLiteralExpression(node: ArrayLiteralExpression, elements: readonly Expression[]): ArrayLiteralExpression; createObjectLiteralExpression(properties?: readonly ObjectLiteralElementLike[], multiLine?: boolean): ObjectLiteralExpression; updateObjectLiteralExpression(node: ObjectLiteralExpression, properties: readonly ObjectLiteralElementLike[]): ObjectLiteralExpression; - createPropertyAccessExpression(expression: Expression, name: string | Identifier | PrivateIdentifier): PropertyAccessExpression; - updatePropertyAccessExpression(node: PropertyAccessExpression, expression: Expression, name: Identifier | PrivateIdentifier): PropertyAccessExpression; - createPropertyAccessChain(expression: Expression, questionDotToken: QuestionDotToken | undefined, name: string | Identifier | PrivateIdentifier): PropertyAccessChain; - updatePropertyAccessChain(node: PropertyAccessChain, expression: Expression, questionDotToken: QuestionDotToken | undefined, name: Identifier | PrivateIdentifier): PropertyAccessChain; + createPropertyAccessExpression(expression: Expression, name: string | MemberName): PropertyAccessExpression; + updatePropertyAccessExpression(node: PropertyAccessExpression, expression: Expression, name: MemberName): PropertyAccessExpression; + createPropertyAccessChain(expression: Expression, questionDotToken: QuestionDotToken | undefined, name: string | MemberName): PropertyAccessChain; + updatePropertyAccessChain(node: PropertyAccessChain, expression: Expression, questionDotToken: QuestionDotToken | undefined, name: MemberName): PropertyAccessChain; createElementAccessExpression(expression: Expression, index: number | Expression): ElementAccessExpression; updateElementAccessExpression(node: ElementAccessExpression, expression: Expression, argumentExpression: Expression): ElementAccessExpression; createElementAccessChain(expression: Expression, questionDotToken: QuestionDotToken | undefined, index: number | Expression): ElementAccessChain; @@ -3455,54 +3520,66 @@ declare namespace ts { updateJSDocNamepathType(node: JSDocNamepathType, type: TypeNode): JSDocNamepathType; createJSDocTypeExpression(type: TypeNode): JSDocTypeExpression; updateJSDocTypeExpression(node: JSDocTypeExpression, type: TypeNode): JSDocTypeExpression; - createJSDocNameReference(name: EntityName): JSDocNameReference; - updateJSDocNameReference(node: JSDocNameReference, name: EntityName): JSDocNameReference; + createJSDocNameReference(name: EntityName | JSDocMemberName): JSDocNameReference; + updateJSDocNameReference(node: JSDocNameReference, name: EntityName | JSDocMemberName): JSDocNameReference; + createJSDocMemberName(left: EntityName | JSDocMemberName, right: Identifier): JSDocMemberName; + updateJSDocMemberName(node: JSDocMemberName, left: EntityName | JSDocMemberName, right: Identifier): JSDocMemberName; + createJSDocLink(name: EntityName | JSDocMemberName | undefined, text: string): JSDocLink; + updateJSDocLink(node: JSDocLink, name: EntityName | JSDocMemberName | undefined, text: string): JSDocLink; + createJSDocLinkCode(name: EntityName | JSDocMemberName | undefined, text: string): JSDocLinkCode; + updateJSDocLinkCode(node: JSDocLinkCode, name: EntityName | JSDocMemberName | undefined, text: string): JSDocLinkCode; + createJSDocLinkPlain(name: EntityName | JSDocMemberName | undefined, text: string): JSDocLinkPlain; + updateJSDocLinkPlain(node: JSDocLinkPlain, name: EntityName | JSDocMemberName | undefined, text: string): JSDocLinkPlain; createJSDocTypeLiteral(jsDocPropertyTags?: readonly JSDocPropertyLikeTag[], isArrayType?: boolean): JSDocTypeLiteral; updateJSDocTypeLiteral(node: JSDocTypeLiteral, jsDocPropertyTags: readonly JSDocPropertyLikeTag[] | undefined, isArrayType: boolean | undefined): JSDocTypeLiteral; createJSDocSignature(typeParameters: readonly JSDocTemplateTag[] | undefined, parameters: readonly JSDocParameterTag[], type?: JSDocReturnTag): JSDocSignature; updateJSDocSignature(node: JSDocSignature, typeParameters: readonly JSDocTemplateTag[] | undefined, parameters: readonly JSDocParameterTag[], type: JSDocReturnTag | undefined): JSDocSignature; - createJSDocTemplateTag(tagName: Identifier | undefined, constraint: JSDocTypeExpression | undefined, typeParameters: readonly TypeParameterDeclaration[], comment?: string): JSDocTemplateTag; - updateJSDocTemplateTag(node: JSDocTemplateTag, tagName: Identifier | undefined, constraint: JSDocTypeExpression | undefined, typeParameters: readonly TypeParameterDeclaration[], comment: string | undefined): JSDocTemplateTag; - createJSDocTypedefTag(tagName: Identifier | undefined, typeExpression?: JSDocTypeExpression | JSDocTypeLiteral, fullName?: Identifier | JSDocNamespaceDeclaration, comment?: string): JSDocTypedefTag; - updateJSDocTypedefTag(node: JSDocTypedefTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression | JSDocTypeLiteral | undefined, fullName: Identifier | JSDocNamespaceDeclaration | undefined, comment: string | undefined): JSDocTypedefTag; - createJSDocParameterTag(tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression, isNameFirst?: boolean, comment?: string): JSDocParameterTag; - updateJSDocParameterTag(node: JSDocParameterTag, tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression: JSDocTypeExpression | undefined, isNameFirst: boolean, comment: string | undefined): JSDocParameterTag; - createJSDocPropertyTag(tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression, isNameFirst?: boolean, comment?: string): JSDocPropertyTag; - updateJSDocPropertyTag(node: JSDocPropertyTag, tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression: JSDocTypeExpression | undefined, isNameFirst: boolean, comment: string | undefined): JSDocPropertyTag; - createJSDocTypeTag(tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string): JSDocTypeTag; - updateJSDocTypeTag(node: JSDocTypeTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment: string | undefined): JSDocTypeTag; - createJSDocSeeTag(tagName: Identifier | undefined, nameExpression: JSDocNameReference | undefined, comment?: string): JSDocSeeTag; - updateJSDocSeeTag(node: JSDocSeeTag, tagName: Identifier | undefined, nameExpression: JSDocNameReference | undefined, comment?: string): JSDocSeeTag; - createJSDocReturnTag(tagName: Identifier | undefined, typeExpression?: JSDocTypeExpression, comment?: string): JSDocReturnTag; - updateJSDocReturnTag(node: JSDocReturnTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression | undefined, comment: string | undefined): JSDocReturnTag; - createJSDocThisTag(tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string): JSDocThisTag; - updateJSDocThisTag(node: JSDocThisTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression | undefined, comment: string | undefined): JSDocThisTag; - createJSDocEnumTag(tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string): JSDocEnumTag; - updateJSDocEnumTag(node: JSDocEnumTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment: string | undefined): JSDocEnumTag; - createJSDocCallbackTag(tagName: Identifier | undefined, typeExpression: JSDocSignature, fullName?: Identifier | JSDocNamespaceDeclaration, comment?: string): JSDocCallbackTag; - updateJSDocCallbackTag(node: JSDocCallbackTag, tagName: Identifier | undefined, typeExpression: JSDocSignature, fullName: Identifier | JSDocNamespaceDeclaration | undefined, comment: string | undefined): JSDocCallbackTag; - createJSDocAugmentsTag(tagName: Identifier | undefined, className: JSDocAugmentsTag["class"], comment?: string): JSDocAugmentsTag; - updateJSDocAugmentsTag(node: JSDocAugmentsTag, tagName: Identifier | undefined, className: JSDocAugmentsTag["class"], comment: string | undefined): JSDocAugmentsTag; - createJSDocImplementsTag(tagName: Identifier | undefined, className: JSDocImplementsTag["class"], comment?: string): JSDocImplementsTag; - updateJSDocImplementsTag(node: JSDocImplementsTag, tagName: Identifier | undefined, className: JSDocImplementsTag["class"], comment: string | undefined): JSDocImplementsTag; - createJSDocAuthorTag(tagName: Identifier | undefined, comment?: string): JSDocAuthorTag; - updateJSDocAuthorTag(node: JSDocAuthorTag, tagName: Identifier | undefined, comment: string | undefined): JSDocAuthorTag; - createJSDocClassTag(tagName: Identifier | undefined, comment?: string): JSDocClassTag; - updateJSDocClassTag(node: JSDocClassTag, tagName: Identifier | undefined, comment: string | undefined): JSDocClassTag; - createJSDocPublicTag(tagName: Identifier | undefined, comment?: string): JSDocPublicTag; - updateJSDocPublicTag(node: JSDocPublicTag, tagName: Identifier | undefined, comment: string | undefined): JSDocPublicTag; - createJSDocPrivateTag(tagName: Identifier | undefined, comment?: string): JSDocPrivateTag; - updateJSDocPrivateTag(node: JSDocPrivateTag, tagName: Identifier | undefined, comment: string | undefined): JSDocPrivateTag; - createJSDocProtectedTag(tagName: Identifier | undefined, comment?: string): JSDocProtectedTag; - updateJSDocProtectedTag(node: JSDocProtectedTag, tagName: Identifier | undefined, comment: string | undefined): JSDocProtectedTag; - createJSDocReadonlyTag(tagName: Identifier | undefined, comment?: string): JSDocReadonlyTag; - updateJSDocReadonlyTag(node: JSDocReadonlyTag, tagName: Identifier | undefined, comment: string | undefined): JSDocReadonlyTag; - createJSDocUnknownTag(tagName: Identifier, comment?: string): JSDocUnknownTag; - updateJSDocUnknownTag(node: JSDocUnknownTag, tagName: Identifier, comment: string | undefined): JSDocUnknownTag; - createJSDocDeprecatedTag(tagName: Identifier, comment?: string): JSDocDeprecatedTag; - updateJSDocDeprecatedTag(node: JSDocDeprecatedTag, tagName: Identifier, comment?: string): JSDocDeprecatedTag; - createJSDocComment(comment?: string | undefined, tags?: readonly JSDocTag[] | undefined): JSDoc; - updateJSDocComment(node: JSDoc, comment: string | undefined, tags: readonly JSDocTag[] | undefined): JSDoc; + createJSDocTemplateTag(tagName: Identifier | undefined, constraint: JSDocTypeExpression | undefined, typeParameters: readonly TypeParameterDeclaration[], comment?: string | NodeArray): JSDocTemplateTag; + updateJSDocTemplateTag(node: JSDocTemplateTag, tagName: Identifier | undefined, constraint: JSDocTypeExpression | undefined, typeParameters: readonly TypeParameterDeclaration[], comment: string | NodeArray | undefined): JSDocTemplateTag; + createJSDocTypedefTag(tagName: Identifier | undefined, typeExpression?: JSDocTypeExpression | JSDocTypeLiteral, fullName?: Identifier | JSDocNamespaceDeclaration, comment?: string | NodeArray): JSDocTypedefTag; + updateJSDocTypedefTag(node: JSDocTypedefTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression | JSDocTypeLiteral | undefined, fullName: Identifier | JSDocNamespaceDeclaration | undefined, comment: string | NodeArray | undefined): JSDocTypedefTag; + createJSDocParameterTag(tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression, isNameFirst?: boolean, comment?: string | NodeArray): JSDocParameterTag; + updateJSDocParameterTag(node: JSDocParameterTag, tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression: JSDocTypeExpression | undefined, isNameFirst: boolean, comment: string | NodeArray | undefined): JSDocParameterTag; + createJSDocPropertyTag(tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression, isNameFirst?: boolean, comment?: string | NodeArray): JSDocPropertyTag; + updateJSDocPropertyTag(node: JSDocPropertyTag, tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression: JSDocTypeExpression | undefined, isNameFirst: boolean, comment: string | NodeArray | undefined): JSDocPropertyTag; + createJSDocTypeTag(tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | NodeArray): JSDocTypeTag; + updateJSDocTypeTag(node: JSDocTypeTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment: string | NodeArray | undefined): JSDocTypeTag; + createJSDocSeeTag(tagName: Identifier | undefined, nameExpression: JSDocNameReference | undefined, comment?: string | NodeArray): JSDocSeeTag; + updateJSDocSeeTag(node: JSDocSeeTag, tagName: Identifier | undefined, nameExpression: JSDocNameReference | undefined, comment?: string | NodeArray): JSDocSeeTag; + createJSDocReturnTag(tagName: Identifier | undefined, typeExpression?: JSDocTypeExpression, comment?: string | NodeArray): JSDocReturnTag; + updateJSDocReturnTag(node: JSDocReturnTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression | undefined, comment: string | NodeArray | undefined): JSDocReturnTag; + createJSDocThisTag(tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | NodeArray): JSDocThisTag; + updateJSDocThisTag(node: JSDocThisTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression | undefined, comment: string | NodeArray | undefined): JSDocThisTag; + createJSDocEnumTag(tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | NodeArray): JSDocEnumTag; + updateJSDocEnumTag(node: JSDocEnumTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment: string | NodeArray | undefined): JSDocEnumTag; + createJSDocCallbackTag(tagName: Identifier | undefined, typeExpression: JSDocSignature, fullName?: Identifier | JSDocNamespaceDeclaration, comment?: string | NodeArray): JSDocCallbackTag; + updateJSDocCallbackTag(node: JSDocCallbackTag, tagName: Identifier | undefined, typeExpression: JSDocSignature, fullName: Identifier | JSDocNamespaceDeclaration | undefined, comment: string | NodeArray | undefined): JSDocCallbackTag; + createJSDocAugmentsTag(tagName: Identifier | undefined, className: JSDocAugmentsTag["class"], comment?: string | NodeArray): JSDocAugmentsTag; + updateJSDocAugmentsTag(node: JSDocAugmentsTag, tagName: Identifier | undefined, className: JSDocAugmentsTag["class"], comment: string | NodeArray | undefined): JSDocAugmentsTag; + createJSDocImplementsTag(tagName: Identifier | undefined, className: JSDocImplementsTag["class"], comment?: string | NodeArray): JSDocImplementsTag; + updateJSDocImplementsTag(node: JSDocImplementsTag, tagName: Identifier | undefined, className: JSDocImplementsTag["class"], comment: string | NodeArray | undefined): JSDocImplementsTag; + createJSDocAuthorTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocAuthorTag; + updateJSDocAuthorTag(node: JSDocAuthorTag, tagName: Identifier | undefined, comment: string | NodeArray | undefined): JSDocAuthorTag; + createJSDocClassTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocClassTag; + updateJSDocClassTag(node: JSDocClassTag, tagName: Identifier | undefined, comment: string | NodeArray | undefined): JSDocClassTag; + createJSDocPublicTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocPublicTag; + updateJSDocPublicTag(node: JSDocPublicTag, tagName: Identifier | undefined, comment: string | NodeArray | undefined): JSDocPublicTag; + createJSDocPrivateTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocPrivateTag; + updateJSDocPrivateTag(node: JSDocPrivateTag, tagName: Identifier | undefined, comment: string | NodeArray | undefined): JSDocPrivateTag; + createJSDocProtectedTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocProtectedTag; + updateJSDocProtectedTag(node: JSDocProtectedTag, tagName: Identifier | undefined, comment: string | NodeArray | undefined): JSDocProtectedTag; + createJSDocReadonlyTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocReadonlyTag; + updateJSDocReadonlyTag(node: JSDocReadonlyTag, tagName: Identifier | undefined, comment: string | NodeArray | undefined): JSDocReadonlyTag; + createJSDocUnknownTag(tagName: Identifier, comment?: string | NodeArray): JSDocUnknownTag; + updateJSDocUnknownTag(node: JSDocUnknownTag, tagName: Identifier, comment: string | NodeArray | undefined): JSDocUnknownTag; + createJSDocDeprecatedTag(tagName: Identifier, comment?: string | NodeArray): JSDocDeprecatedTag; + updateJSDocDeprecatedTag(node: JSDocDeprecatedTag, tagName: Identifier, comment?: string | NodeArray): JSDocDeprecatedTag; + createJSDocOverrideTag(tagName: Identifier, comment?: string | NodeArray): JSDocOverrideTag; + updateJSDocOverrideTag(node: JSDocOverrideTag, tagName: Identifier, comment?: string | NodeArray): JSDocOverrideTag; + createJSDocText(text: string): JSDocText; + updateJSDocText(node: JSDocText, text: string): JSDocText; + createJSDocComment(comment?: string | NodeArray | undefined, tags?: readonly JSDocTag[] | undefined): JSDoc; + updateJSDocComment(node: JSDoc, comment: string | NodeArray | undefined, tags: readonly JSDocTag[] | undefined): JSDoc; createJsxElement(openingElement: JsxOpeningElement, children: readonly JsxChild[], closingElement: JsxClosingElement): JsxElement; updateJsxElement(node: JsxElement, openingElement: JsxOpeningElement, children: readonly JsxChild[], closingElement: JsxClosingElement): JsxElement; createJsxSelfClosingElement(tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxSelfClosingElement; @@ -3750,12 +3827,12 @@ declare namespace ts { * }); * ``` */ - onEmitNode?(hint: EmitHint, node: Node | undefined, emitCallback: (hint: EmitHint, node: Node | undefined) => void): void; + onEmitNode?(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void): void; /** * A hook used to check if an emit notification is required for a node. * @param node The node to emit. */ - isEmitNotificationEnabled?(node: Node | undefined): boolean; + isEmitNotificationEnabled?(node: Node): boolean; /** * A hook used by the Printer to perform just-in-time substitution of a node. This is * primarily used by node transformations that need to substitute one node for another, @@ -3869,6 +3946,8 @@ declare namespace ts { readonly disableSuggestions?: boolean; readonly quotePreference?: "auto" | "double" | "single"; readonly includeCompletionsForModuleExports?: boolean; + readonly includeCompletionsForImportStatements?: boolean; + readonly includeCompletionsWithSnippetText?: boolean; readonly includeAutomaticOptionalChainCompletions?: boolean; readonly includeCompletionsWithInsertText?: boolean; readonly importModuleSpecifierPreference?: "shortest" | "project-relative" | "relative" | "non-relative"; @@ -3967,9 +4046,11 @@ declare namespace ts { scanJsxIdentifier(): SyntaxKind; scanJsxAttributeValue(): SyntaxKind; reScanJsxAttributeValue(): SyntaxKind; - reScanJsxToken(): JsxTokenSyntaxKind; + reScanJsxToken(allowMultilineJsxText?: boolean): JsxTokenSyntaxKind; reScanLessThanToken(): SyntaxKind; + reScanHashToken(): SyntaxKind; reScanQuestionToken(): SyntaxKind; + reScanInvalidIdentifier(): SyntaxKind; scanJsxToken(): JsxTokenSyntaxKind; scanJsDocToken(): JSDocSyntaxKind; scan(): SyntaxKind; @@ -4101,7 +4182,7 @@ declare namespace ts { function idText(identifierOrPrivateName: Identifier | PrivateIdentifier): string; function symbolName(symbol: Symbol): string; function getNameOfJSDocTypedef(declaration: JSDocTypedefTag): Identifier | PrivateIdentifier | undefined; - function getNameOfDeclaration(declaration: Declaration | Expression): DeclarationName | undefined; + function getNameOfDeclaration(declaration: Declaration | Expression | undefined): DeclarationName | undefined; /** * Gets the JSDoc parameter tags for the node if present. * @@ -4147,6 +4228,7 @@ declare namespace ts { function getJSDocProtectedTag(node: Node): JSDocProtectedTag | undefined; /** Gets the JSDoc protected tag for the node if present */ function getJSDocReadonlyTag(node: Node): JSDocReadonlyTag | undefined; + function getJSDocOverrideTagNoCache(node: Node): JSDocOverrideTag | undefined; /** Gets the JSDoc deprecated tag for the node if present */ function getJSDocDeprecatedTag(node: Node): JSDocDeprecatedTag | undefined; /** Gets the JSDoc enum tag for the node if present */ @@ -4184,13 +4266,15 @@ declare namespace ts { function getAllJSDocTags(node: Node, predicate: (tag: JSDocTag) => tag is T): readonly T[]; /** Gets all JSDoc tags of a specified kind */ function getAllJSDocTagsOfKind(node: Node, kind: SyntaxKind): readonly JSDocTag[]; + /** Gets the text of a jsdoc comment, flattening links to their text. */ + function getTextOfJSDocComment(comment?: string | NodeArray): string | undefined; /** * Gets the effective type parameters. If the node was parsed in a * JavaScript file, gets the type parameters from the `@template` tag from JSDoc. */ function getEffectiveTypeParameterDeclarations(node: DeclarationWithTypeParameters): readonly TypeParameterDeclaration[]; function getEffectiveConstraintOfTypeParameter(node: TypeParameterDeclaration): TypeNode | undefined; - function isIdentifierOrPrivateIdentifier(node: Node): node is Identifier | PrivateIdentifier; + function isMemberName(node: Node): node is MemberName; function isPropertyAccessChain(node: Node): node is PropertyAccessChain; function isElementAccessChain(node: Node): node is ElementAccessChain; function isCallChain(node: Node): node is CallChain; @@ -4205,6 +4289,12 @@ declare namespace ts { function isUnparsedTextLike(node: Node): node is UnparsedTextLike; function isUnparsedNode(node: Node): node is UnparsedNode; function isJSDocPropertyLikeTag(node: Node): node is JSDocPropertyLikeTag; + /** + * True if kind is of some token syntax kind. + * For example, this is true for an IfKeyword but not for an IfStatement. + * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. + */ + function isTokenKind(kind: SyntaxKind): boolean; /** * True if node is of some token syntax kind. * For example, this is true for an IfKeyword but not for an IfStatement. @@ -4221,7 +4311,7 @@ declare namespace ts { function isEntityName(node: Node): node is EntityName; function isPropertyName(node: Node): node is PropertyName; function isBindingName(node: Node): node is BindingName; - function isFunctionLike(node: Node): node is SignatureDeclaration; + function isFunctionLike(node: Node | undefined): node is SignatureDeclaration; function isClassElement(node: Node): node is ClassElement; function isClassLike(node: Node): node is ClassLikeDeclaration; function isAccessor(node: Node): node is AccessorDeclaration; @@ -4252,6 +4342,7 @@ declare namespace ts { function hasOnlyExpressionInitializer(node: Node): node is HasExpressionInitializer; function isObjectLiteralElement(node: Node): node is ObjectLiteralElement; function isStringLiteralLike(node: Node): node is StringLiteralLike; + function isJSDocLinkLike(node: Node): node is JSDocLink | JSDocLinkCode | JSDocLinkPlain; } declare namespace ts { const factory: NodeFactory; @@ -4347,10 +4438,14 @@ declare namespace ts { function isTemplateHead(node: Node): node is TemplateHead; function isTemplateMiddle(node: Node): node is TemplateMiddle; function isTemplateTail(node: Node): node is TemplateTail; + function isDotDotDotToken(node: Node): node is DotDotDotToken; + function isPlusToken(node: Node): node is PlusToken; + function isMinusToken(node: Node): node is MinusToken; + function isAsteriskToken(node: Node): node is AsteriskToken; function isIdentifier(node: Node): node is Identifier; + function isPrivateIdentifier(node: Node): node is PrivateIdentifier; function isQualifiedName(node: Node): node is QualifiedName; function isComputedPropertyName(node: Node): node is ComputedPropertyName; - function isPrivateIdentifier(node: Node): node is PrivateIdentifier; function isTypeParameterDeclaration(node: Node): node is TypeParameterDeclaration; function isParameter(node: Node): node is ParameterDeclaration; function isDecorator(node: Node): node is Decorator; @@ -4493,6 +4588,10 @@ declare namespace ts { function isUnparsedSource(node: Node): node is UnparsedSource; function isJSDocTypeExpression(node: Node): node is JSDocTypeExpression; function isJSDocNameReference(node: Node): node is JSDocNameReference; + function isJSDocMemberName(node: Node): node is JSDocMemberName; + function isJSDocLink(node: Node): node is JSDocLink; + function isJSDocLinkCode(node: Node): node is JSDocLinkCode; + function isJSDocLinkPlain(node: Node): node is JSDocLinkPlain; function isJSDocAllType(node: Node): node is JSDocAllType; function isJSDocUnknownType(node: Node): node is JSDocUnknownType; function isJSDocNullableType(node: Node): node is JSDocNullableType; @@ -4512,6 +4611,7 @@ declare namespace ts { function isJSDocPrivateTag(node: Node): node is JSDocPrivateTag; function isJSDocProtectedTag(node: Node): node is JSDocProtectedTag; function isJSDocReadonlyTag(node: Node): node is JSDocReadonlyTag; + function isJSDocOverrideTag(node: Node): node is JSDocOverrideTag; function isJSDocDeprecatedTag(node: Node): node is JSDocDeprecatedTag; function isJSDocSeeTag(node: Node): node is JSDocSeeTag; function isJSDocEnumTag(node: Node): node is JSDocEnumTag; @@ -4576,7 +4676,7 @@ declare namespace ts { /** * Reads the config file, reports errors if any and exits if the config file cannot be found */ - export function getParsedCommandLineOfConfigFile(configFileName: string, optionsToExtend: CompilerOptions, host: ParseConfigFileHost, extendedConfigCache?: Map, watchOptionsToExtend?: WatchOptions, extraFileExtensions?: readonly FileExtensionInfo[]): ParsedCommandLine | undefined; + export function getParsedCommandLineOfConfigFile(configFileName: string, optionsToExtend: CompilerOptions | undefined, host: ParseConfigFileHost, extendedConfigCache?: Map, watchOptionsToExtend?: WatchOptions, extraFileExtensions?: readonly FileExtensionInfo[]): ParsedCommandLine | undefined; /** * Read tsconfig.json file * @param fileName The path to the config file @@ -4644,13 +4744,13 @@ declare namespace ts { export {}; } declare namespace ts { - function getEffectiveTypeRoots(options: CompilerOptions, host: GetEffectiveTypeRootsHost): string[] | undefined; + export function getEffectiveTypeRoots(options: CompilerOptions, host: GetEffectiveTypeRootsHost): string[] | undefined; /** * @param {string | undefined} containingFile - file that contains type reference directive, can be undefined if containing file is unknown. * This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups * is assumed to be the same as root directory of the project. */ - function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string | undefined, options: CompilerOptions, host: ModuleResolutionHost, redirectedReference?: ResolvedProjectReference): ResolvedTypeReferenceDirectiveWithFailedLookupLocations; + export function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string | undefined, options: CompilerOptions, host: ModuleResolutionHost, redirectedReference?: ResolvedProjectReference, cache?: TypeReferenceDirectiveResolutionCache): ResolvedTypeReferenceDirectiveWithFailedLookupLocations; /** * Given a set of options, returns the set of type directive names * that should be included for this program automatically. @@ -4659,30 +4759,46 @@ declare namespace ts { * More type directives might appear in the program later as a result of loading actual source files; * this list is only the set of defaults that are implicitly included. */ - function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[]; + export function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[]; + export interface TypeReferenceDirectiveResolutionCache extends PerDirectoryResolutionCache, PackageJsonInfoCache { + } /** - * Cached module resolutions per containing directory. + * Cached resolutions per containing directory. * This assumes that any module id will have the same resolution for sibling files located in the same folder. */ - interface ModuleResolutionCache extends NonRelativeModuleNameResolutionCache { - getOrCreateCacheForDirectory(directoryName: string, redirectedReference?: ResolvedProjectReference): Map; + export interface PerDirectoryResolutionCache { + getOrCreateCacheForDirectory(directoryName: string, redirectedReference?: ResolvedProjectReference): Map; + clear(): void; + /** + * Updates with the current compilerOptions the cache will operate with. + * This updates the redirects map as well if needed so module resolutions are cached if they can across the projects + */ + update(options: CompilerOptions): void; + } + export interface ModuleResolutionCache extends PerDirectoryResolutionCache, NonRelativeModuleNameResolutionCache, PackageJsonInfoCache { + getPackageJsonInfoCache(): PackageJsonInfoCache; } /** * Stored map from non-relative module name to a table: directory -> result of module lookup in this directory * We support only non-relative module names because resolution of relative module names is usually more deterministic and thus less expensive. */ - interface NonRelativeModuleNameResolutionCache { + export interface NonRelativeModuleNameResolutionCache extends PackageJsonInfoCache { getOrCreateCacheForModuleName(nonRelativeModuleName: string, redirectedReference?: ResolvedProjectReference): PerModuleNameCache; } - interface PerModuleNameCache { + export interface PackageJsonInfoCache { + clear(): void; + } + export interface PerModuleNameCache { get(directory: string): ResolvedModuleWithFailedLookupLocations | undefined; set(directory: string, result: ResolvedModuleWithFailedLookupLocations): void; } - function createModuleResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string, options?: CompilerOptions): ModuleResolutionCache; - function resolveModuleNameFromCache(moduleName: string, containingFile: string, cache: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations | undefined; - function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; - function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; - function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; + export function createModuleResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string, options?: CompilerOptions): ModuleResolutionCache; + export function createTypeReferenceDirectiveResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string, options?: CompilerOptions, packageJsonInfoCache?: PackageJsonInfoCache): TypeReferenceDirectiveResolutionCache; + export function resolveModuleNameFromCache(moduleName: string, containingFile: string, cache: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations | undefined; + export function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; + export function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; + export function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; + export {}; } declare namespace ts { /** @@ -4749,6 +4865,10 @@ declare namespace ts { * environment and merging hoisted declarations upon completion. */ function visitFunctionBody(node: ConciseBody, visitor: Visitor, context: TransformationContext): ConciseBody; + /** + * Visits an iteration body, adding any block-scoped variables required by the transformation. + */ + function visitIterationBody(body: Statement, visitor: Visitor, context: TransformationContext): Statement; /** * Visits each child of a Node using the supplied visitor, possibly returning a new Node of the same kind in its place. * @@ -5037,6 +5157,8 @@ declare namespace ts { interface WatchCompilerHost extends ProgramHost, WatchHost { /** Instead of using output d.ts file from project reference, use its source file */ useSourceOfProjectReferenceRedirect?(): boolean; + /** If provided, use this method to get parsed command lines for referenced projects */ + getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined; /** If provided, callback to invoke after every new program creation */ afterProgramCreate?(program: T): void; } @@ -5132,9 +5254,9 @@ declare namespace ts { interface SolutionBuilderWithWatchHost extends SolutionBuilderHostBase, WatchHost { } interface SolutionBuilder { - build(project?: string, cancellationToken?: CancellationToken): ExitStatus; + build(project?: string, cancellationToken?: CancellationToken, writeFile?: WriteFileCallback, getCustomTransformers?: (project: string) => CustomTransformers): ExitStatus; clean(project?: string): ExitStatus; - buildReferences(project: string, cancellationToken?: CancellationToken): ExitStatus; + buildReferences(project: string, cancellationToken?: CancellationToken, writeFile?: WriteFileCallback, getCustomTransformers?: (project: string) => CustomTransformers): ExitStatus; cleanReferences(project?: string): ExitStatus; getNextInvalidatedProject(cancellationToken?: CancellationToken): InvalidatedProject | undefined; } @@ -5292,7 +5414,7 @@ declare namespace ts { getName(): string; getDeclarations(): Declaration[] | undefined; getDocumentationComment(typeChecker: TypeChecker | undefined): SymbolDisplayPart[]; - getJsDocTags(): JSDocTagInfo[]; + getJsDocTags(checker?: TypeChecker): JSDocTagInfo[]; } interface Type { getFlags(): TypeFlags; @@ -5423,6 +5545,7 @@ declare namespace ts { isKnownTypesPackageName?(name: string): boolean; installPackage?(options: InstallPackageOptions): Promise; writeFile?(fileName: string, content: string): void; + getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined; } type WithMetadata = T & { metadata?: unknown; @@ -5512,12 +5635,13 @@ declare namespace ts { * * @param fileName The path to the file * @param position A zero based index of the character where you want the entries - * @param entryName The name from an existing completion which came from `getCompletionsAtPosition` + * @param entryName The `name` from an existing completion which came from `getCompletionsAtPosition` * @param formatOptions How should code samples in the completions be formatted, can be undefined for backwards compatibility - * @param source Source code for the current file, can be undefined for backwards compatibility + * @param source `source` property from the completion entry * @param preferences User settings, can be undefined for backwards compatibility + * @param data `data` property from the completion entry */ - getCompletionEntryDetails(fileName: string, position: number, entryName: string, formatOptions: FormatCodeOptions | FormatCodeSettings | undefined, source: string | undefined, preferences: UserPreferences | undefined): CompletionEntryDetails | undefined; + getCompletionEntryDetails(fileName: string, position: number, entryName: string, formatOptions: FormatCodeOptions | FormatCodeSettings | undefined, source: string | undefined, preferences: UserPreferences | undefined, data: CompletionEntryData | undefined): CompletionEntryDetails | undefined; getCompletionEntrySymbol(fileName: string, position: number, name: string, source: string | undefined): Symbol | undefined; /** * Gets semantic information about the identifier at a particular position in a @@ -5556,7 +5680,7 @@ declare namespace ts { getFormattingEditsForRange(fileName: string, start: number, end: number, options: FormatCodeOptions | FormatCodeSettings): TextChange[]; getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions | FormatCodeSettings): TextChange[]; getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions | FormatCodeSettings): TextChange[]; - getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion | undefined; + getDocCommentTemplateAtPosition(fileName: string, position: number, options?: DocCommentTemplateOptions): TextInsertion | undefined; isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean; /** * This will return a defined result if the position is after the `>` of the opening tag, or somewhere in the text, of a JSXElement with no closing tag. @@ -5578,7 +5702,7 @@ declare namespace ts { applyCodeActionCommand(fileName: string, action: CodeActionCommand | CodeActionCommand[]): Promise; getApplicableRefactors(fileName: string, positionOrRange: number | TextRange, preferences: UserPreferences | undefined, triggerReason?: RefactorTriggerReason, kind?: string): ApplicableRefactorInfo[]; getEditsForRefactor(fileName: string, formatOptions: FormatCodeSettings, positionOrRange: number | TextRange, refactorName: string, actionName: string, preferences: UserPreferences | undefined): RefactorEditInfo | undefined; - organizeImports(scope: OrganizeImportsScope, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): readonly FileTextChanges[]; + organizeImports(args: OrganizeImportsArgs, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): readonly FileTextChanges[]; getEditsForFileRename(oldFilePath: string, newFilePath: string, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): readonly FileTextChanges[]; getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean, forceDtsEmit?: boolean): EmitOutput; getProgram(): Program | undefined; @@ -5595,8 +5719,10 @@ declare namespace ts { type: "file"; fileName: string; } - type OrganizeImportsScope = CombinedCodeFixScope; - type CompletionsTriggerCharacter = "." | '"' | "'" | "`" | "/" | "@" | "<" | "#"; + interface OrganizeImportsArgs extends CombinedCodeFixScope { + skipDestructiveCodeActions?: boolean; + } + type CompletionsTriggerCharacter = "." | '"' | "'" | "`" | "/" | "@" | "<" | "#" | " "; interface GetCompletionsAtPositionOptions extends UserPreferences { /** * If the editor is asking for completions because a certain character was typed @@ -5948,6 +6074,7 @@ declare namespace ts { name: string; containerKind: ScriptElementKind; containerName: string; + unverified?: boolean; } interface DefinitionInfoAndBoundSpan { definitions?: readonly DefinitionInfo[]; @@ -5982,15 +6109,21 @@ declare namespace ts { typeParameterName = 18, enumMemberName = 19, functionName = 20, - regularExpressionLiteral = 21 + regularExpressionLiteral = 21, + link = 22, + linkName = 23, + linkText = 24 } interface SymbolDisplayPart { text: string; kind: string; } + interface JSDocLinkDisplayPart extends SymbolDisplayPart { + target: DocumentSpan; + } interface JSDocTagInfo { name: string; - text?: string; + text?: SymbolDisplayPart[]; } interface QuickInfo { kind: ScriptElementKind; @@ -6021,11 +6154,15 @@ declare namespace ts { interface RenameInfoOptions { readonly allowRenameOfImportPath?: boolean; } + interface DocCommentTemplateOptions { + readonly generateReturnInDocTemplate?: boolean; + } interface SignatureHelpParameter { name: string; documentation: SymbolDisplayPart[]; displayParts: SymbolDisplayPart[]; isOptional: boolean; + isRest?: boolean; } interface SelectionRange { textSpan: TextSpan; @@ -6071,14 +6208,36 @@ declare namespace ts { * true when the current location also allows for a new identifier */ isNewIdentifierLocation: boolean; + /** + * Indicates to client to continue requesting completions on subsequent keystrokes. + */ + isIncomplete?: true; entries: CompletionEntry[]; } + interface CompletionEntryData { + /** The file name declaring the export's module symbol, if it was an external module */ + fileName?: string; + /** The module name (with quotes stripped) of the export's module symbol, if it was an ambient module */ + ambientModuleName?: string; + /** True if the export was found in the package.json AutoImportProvider */ + isPackageJsonImport?: true; + /** + * The name of the property or export in the module's symbol table. Differs from the completion name + * in the case of InternalSymbolName.ExportEquals and InternalSymbolName.Default. + */ + exportName: string; + /** + * Set for auto imports with eagerly resolved module specifiers. + */ + moduleSpecifier?: string; + } interface CompletionEntry { name: string; kind: ScriptElementKind; kindModifiers?: string; sortText: string; insertText?: string; + isSnippet?: true; /** * An optional span that indicates the text to be replaced by this completion item. * If present, this span should be used instead of the default one. @@ -6087,9 +6246,20 @@ declare namespace ts { replacementSpan?: TextSpan; hasAction?: true; source?: string; + sourceDisplay?: SymbolDisplayPart[]; isRecommended?: true; isFromUncheckedFile?: true; isPackageJsonImport?: true; + isImportStatementCompletion?: true; + /** + * A property to be sent back to TS Server in the CompletionDetailsRequest, along with `name`, + * that allows TS Server to look up the symbol represented by the completion item, disambiguating + * items with the same name. Currently only defined for auto-import completions, but the type is + * `unknown` in the protocol, so it can be changed as needed to support other kinds of completions. + * The presence of this property should generally not be used to assume that this completion entry + * is an auto-import. + */ + data?: CompletionEntryData; } interface CompletionEntryDetails { name: string; @@ -6099,7 +6269,9 @@ declare namespace ts { documentation?: SymbolDisplayPart[]; tags?: JSDocTagInfo[]; codeActions?: CodeAction[]; + /** @deprecated Use `sourceDisplay` instead. */ source?: SymbolDisplayPart[]; + sourceDisplay?: SymbolDisplayPart[]; } interface OutliningSpan { /** The span of the document to actually collapse. */ @@ -6253,7 +6425,13 @@ declare namespace ts { */ jsxAttribute = "JSX attribute", /** String literal */ - string = "string" + string = "string", + /** Jsdoc @link: in `{@link C link text}`, the before and after text "{@link " and "}" */ + link = "link", + /** Jsdoc @link: in `{@link C link text}`, the entity name "C" */ + linkName = "link name", + /** Jsdoc @link: in `{@link C link text}`, the link text "link text" */ + linkText = "link text" } enum ScriptElementKindModifier { none = "", @@ -6394,8 +6572,23 @@ declare namespace ts { * @param fileName The name of the file to be released * @param compilationSettings The compilation settings used to acquire the file */ + /**@deprecated pass scriptKind for correctness */ releaseDocument(fileName: string, compilationSettings: CompilerOptions): void; + /** + * Informs the DocumentRegistry that a file is not needed any longer. + * + * Note: It is not allowed to call release on a SourceFile that was not acquired from + * this registry originally. + * + * @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 + */ + releaseDocument(fileName: string, compilationSettings: CompilerOptions, scriptKind: ScriptKind): void; + /** + * @deprecated pass scriptKind for correctness */ releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey): void; + releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey, scriptKind: ScriptKind): void; reportStats(): string; } type DocumentRegistryBucketKey = string & { @@ -6466,7 +6659,7 @@ declare namespace ts { /** @deprecated Use `factory.createRegularExpressionLiteral` or the factory supplied by your transformation context instead. */ const createRegularExpressionLiteral: (text: string) => RegularExpressionLiteral; /** @deprecated Use `factory.createLoopVariable` or the factory supplied by your transformation context instead. */ - const createLoopVariable: () => Identifier; + const createLoopVariable: (reservedInNestedScopes?: boolean | undefined) => Identifier; /** @deprecated Use `factory.createUniqueName` or the factory supplied by your transformation context instead. */ const createUniqueName: (text: string, flags?: GeneratedIdentifierFlags | undefined) => Identifier; /** @deprecated Use `factory.createPrivateIdentifier` or the factory supplied by your transformation context instead. */ @@ -6638,13 +6831,13 @@ declare namespace ts { /** @deprecated Use `factory.updateObjectLiteralExpression` or the factory supplied by your transformation context instead. */ const updateObjectLiteral: (node: ObjectLiteralExpression, properties: readonly ObjectLiteralElementLike[]) => ObjectLiteralExpression; /** @deprecated Use `factory.createPropertyAccessExpression` or the factory supplied by your transformation context instead. */ - const createPropertyAccess: (expression: Expression, name: string | Identifier | PrivateIdentifier) => PropertyAccessExpression; + const createPropertyAccess: (expression: Expression, name: string | MemberName) => PropertyAccessExpression; /** @deprecated Use `factory.updatePropertyAccessExpression` or the factory supplied by your transformation context instead. */ - const updatePropertyAccess: (node: PropertyAccessExpression, expression: Expression, name: Identifier | PrivateIdentifier) => PropertyAccessExpression; + const updatePropertyAccess: (node: PropertyAccessExpression, expression: Expression, name: MemberName) => PropertyAccessExpression; /** @deprecated Use `factory.createPropertyAccessChain` or the factory supplied by your transformation context instead. */ - const createPropertyAccessChain: (expression: Expression, questionDotToken: QuestionDotToken | undefined, name: string | Identifier | PrivateIdentifier) => PropertyAccessChain; + const createPropertyAccessChain: (expression: Expression, questionDotToken: QuestionDotToken | undefined, name: string | MemberName) => PropertyAccessChain; /** @deprecated Use `factory.updatePropertyAccessChain` or the factory supplied by your transformation context instead. */ - const updatePropertyAccessChain: (node: PropertyAccessChain, expression: Expression, questionDotToken: QuestionDotToken | undefined, name: Identifier | PrivateIdentifier) => PropertyAccessChain; + const updatePropertyAccessChain: (node: PropertyAccessChain, expression: Expression, questionDotToken: QuestionDotToken | undefined, name: MemberName) => PropertyAccessChain; /** @deprecated Use `factory.createElementAccessExpression` or the factory supplied by your transformation context instead. */ const createElementAccess: (expression: Expression, index: number | Expression) => ElementAccessExpression; /** @deprecated Use `factory.updateElementAccessExpression` or the factory supplied by your transformation context instead. */ @@ -6914,51 +7107,51 @@ declare namespace ts { /** @deprecated Use `factory.createJSDocTypeExpression` or the factory supplied by your transformation context instead. */ const createJSDocTypeExpression: (type: TypeNode) => JSDocTypeExpression; /** @deprecated Use `factory.createJSDocTypeTag` or the factory supplied by your transformation context instead. */ - const createJSDocTypeTag: (tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | undefined) => JSDocTypeTag; + const createJSDocTypeTag: (tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | NodeArray | undefined) => JSDocTypeTag; /** @deprecated Use `factory.createJSDocReturnTag` or the factory supplied by your transformation context instead. */ - const createJSDocReturnTag: (tagName: Identifier | undefined, typeExpression?: JSDocTypeExpression | undefined, comment?: string | undefined) => JSDocReturnTag; + const createJSDocReturnTag: (tagName: Identifier | undefined, typeExpression?: JSDocTypeExpression | undefined, comment?: string | NodeArray | undefined) => JSDocReturnTag; /** @deprecated Use `factory.createJSDocThisTag` or the factory supplied by your transformation context instead. */ - const createJSDocThisTag: (tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | undefined) => JSDocThisTag; + const createJSDocThisTag: (tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | NodeArray | undefined) => JSDocThisTag; /** @deprecated Use `factory.createJSDocComment` or the factory supplied by your transformation context instead. */ - const createJSDocComment: (comment?: string | undefined, tags?: readonly JSDocTag[] | undefined) => JSDoc; + const createJSDocComment: (comment?: string | NodeArray | undefined, tags?: readonly JSDocTag[] | undefined) => JSDoc; /** @deprecated Use `factory.createJSDocParameterTag` or the factory supplied by your transformation context instead. */ - const createJSDocParameterTag: (tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression | undefined, isNameFirst?: boolean | undefined, comment?: string | undefined) => JSDocParameterTag; + const createJSDocParameterTag: (tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression | undefined, isNameFirst?: boolean | undefined, comment?: string | NodeArray | undefined) => JSDocParameterTag; /** @deprecated Use `factory.createJSDocClassTag` or the factory supplied by your transformation context instead. */ - const createJSDocClassTag: (tagName: Identifier | undefined, comment?: string | undefined) => JSDocClassTag; + const createJSDocClassTag: (tagName: Identifier | undefined, comment?: string | NodeArray | undefined) => JSDocClassTag; /** @deprecated Use `factory.createJSDocAugmentsTag` or the factory supplied by your transformation context instead. */ const createJSDocAugmentsTag: (tagName: Identifier | undefined, className: ExpressionWithTypeArguments & { readonly expression: Identifier | PropertyAccessEntityNameExpression; - }, comment?: string | undefined) => JSDocAugmentsTag; + }, comment?: string | NodeArray | undefined) => JSDocAugmentsTag; /** @deprecated Use `factory.createJSDocEnumTag` or the factory supplied by your transformation context instead. */ - const createJSDocEnumTag: (tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | undefined) => JSDocEnumTag; + const createJSDocEnumTag: (tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | NodeArray | undefined) => JSDocEnumTag; /** @deprecated Use `factory.createJSDocTemplateTag` or the factory supplied by your transformation context instead. */ - const createJSDocTemplateTag: (tagName: Identifier | undefined, constraint: JSDocTypeExpression | undefined, typeParameters: readonly TypeParameterDeclaration[], comment?: string | undefined) => JSDocTemplateTag; + const createJSDocTemplateTag: (tagName: Identifier | undefined, constraint: JSDocTypeExpression | undefined, typeParameters: readonly TypeParameterDeclaration[], comment?: string | NodeArray | undefined) => JSDocTemplateTag; /** @deprecated Use `factory.createJSDocTypedefTag` or the factory supplied by your transformation context instead. */ - const createJSDocTypedefTag: (tagName: Identifier | undefined, typeExpression?: JSDocTypeLiteral | JSDocTypeExpression | undefined, fullName?: Identifier | JSDocNamespaceDeclaration | undefined, comment?: string | undefined) => JSDocTypedefTag; + const createJSDocTypedefTag: (tagName: Identifier | undefined, typeExpression?: JSDocTypeLiteral | JSDocTypeExpression | undefined, fullName?: Identifier | JSDocNamespaceDeclaration | undefined, comment?: string | NodeArray | undefined) => JSDocTypedefTag; /** @deprecated Use `factory.createJSDocCallbackTag` or the factory supplied by your transformation context instead. */ - const createJSDocCallbackTag: (tagName: Identifier | undefined, typeExpression: JSDocSignature, fullName?: Identifier | JSDocNamespaceDeclaration | undefined, comment?: string | undefined) => JSDocCallbackTag; + const createJSDocCallbackTag: (tagName: Identifier | undefined, typeExpression: JSDocSignature, fullName?: Identifier | JSDocNamespaceDeclaration | undefined, comment?: string | NodeArray | undefined) => JSDocCallbackTag; /** @deprecated Use `factory.createJSDocSignature` or the factory supplied by your transformation context instead. */ const createJSDocSignature: (typeParameters: readonly JSDocTemplateTag[] | undefined, parameters: readonly JSDocParameterTag[], type?: JSDocReturnTag | undefined) => JSDocSignature; /** @deprecated Use `factory.createJSDocPropertyTag` or the factory supplied by your transformation context instead. */ - const createJSDocPropertyTag: (tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression | undefined, isNameFirst?: boolean | undefined, comment?: string | undefined) => JSDocPropertyTag; + const createJSDocPropertyTag: (tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression | undefined, isNameFirst?: boolean | undefined, comment?: string | NodeArray | undefined) => JSDocPropertyTag; /** @deprecated Use `factory.createJSDocTypeLiteral` or the factory supplied by your transformation context instead. */ const createJSDocTypeLiteral: (jsDocPropertyTags?: readonly JSDocPropertyLikeTag[] | undefined, isArrayType?: boolean | undefined) => JSDocTypeLiteral; /** @deprecated Use `factory.createJSDocImplementsTag` or the factory supplied by your transformation context instead. */ const createJSDocImplementsTag: (tagName: Identifier | undefined, className: ExpressionWithTypeArguments & { readonly expression: Identifier | PropertyAccessEntityNameExpression; - }, comment?: string | undefined) => JSDocImplementsTag; + }, comment?: string | NodeArray | undefined) => JSDocImplementsTag; /** @deprecated Use `factory.createJSDocAuthorTag` or the factory supplied by your transformation context instead. */ - const createJSDocAuthorTag: (tagName: Identifier | undefined, comment?: string | undefined) => JSDocAuthorTag; + const createJSDocAuthorTag: (tagName: Identifier | undefined, comment?: string | NodeArray | undefined) => JSDocAuthorTag; /** @deprecated Use `factory.createJSDocPublicTag` or the factory supplied by your transformation context instead. */ - const createJSDocPublicTag: (tagName: Identifier | undefined, comment?: string | undefined) => JSDocPublicTag; + const createJSDocPublicTag: (tagName: Identifier | undefined, comment?: string | NodeArray | undefined) => JSDocPublicTag; /** @deprecated Use `factory.createJSDocPrivateTag` or the factory supplied by your transformation context instead. */ - const createJSDocPrivateTag: (tagName: Identifier | undefined, comment?: string | undefined) => JSDocPrivateTag; + const createJSDocPrivateTag: (tagName: Identifier | undefined, comment?: string | NodeArray | undefined) => JSDocPrivateTag; /** @deprecated Use `factory.createJSDocProtectedTag` or the factory supplied by your transformation context instead. */ - const createJSDocProtectedTag: (tagName: Identifier | undefined, comment?: string | undefined) => JSDocProtectedTag; + const createJSDocProtectedTag: (tagName: Identifier | undefined, comment?: string | NodeArray | undefined) => JSDocProtectedTag; /** @deprecated Use `factory.createJSDocReadonlyTag` or the factory supplied by your transformation context instead. */ - const createJSDocReadonlyTag: (tagName: Identifier | undefined, comment?: string | undefined) => JSDocReadonlyTag; + const createJSDocReadonlyTag: (tagName: Identifier | undefined, comment?: string | NodeArray | undefined) => JSDocReadonlyTag; /** @deprecated Use `factory.createJSDocUnknownTag` or the factory supplied by your transformation context instead. */ - const createJSDocTag: (tagName: Identifier, comment?: string | undefined) => JSDocUnknownTag; + const createJSDocTag: (tagName: Identifier, comment?: string | NodeArray | undefined) => JSDocUnknownTag; /** @deprecated Use `factory.createJsxElement` or the factory supplied by your transformation context instead. */ const createJsxElement: (openingElement: JsxOpeningElement, children: readonly JsxChild[], closingElement: JsxClosingElement) => JsxElement; /** @deprecated Use `factory.updateJsxElement` or the factory supplied by your transformation context instead. */ @@ -7214,4 +7407,8 @@ declare namespace ts { */ interface Map extends ESMap { } + /** + * @deprecated Use `isMemberName` instead. + */ + const isIdentifierOrPrivateIdentifier: (node: Node) => node is MemberName; } diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index bf9fd8adc3ce6..f1e6718847b7f 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -286,7 +286,7 @@ var ts; (function (ts) { // WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values. // If changing the text in this section, be sure to test `configurePrerelease` too. - ts.versionMajorMinor = "4.2"; + ts.versionMajorMinor = "4.4"; // 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 @@ -2133,10 +2133,46 @@ var ts; * Takes a string like "jquery-min.4.2.3" and returns "jquery" */ function removeMinAndVersionNumbers(fileName) { - // Match a "." or "-" followed by a version number or 'min' at the end of the name - var trailingMinOrVersion = /[.-]((min)|(\d+(\.\d+)*))$/; - // The "min" or version may both be present, in either order, so try applying the above twice. - return fileName.replace(trailingMinOrVersion, "").replace(trailingMinOrVersion, ""); + // We used to use the regex /[.-]((min)|(\d+(\.\d+)*))$/ and would just .replace it twice. + // Unfortunately, that regex has O(n^2) performance because v8 doesn't match from the end of the string. + // Instead, we now essentially scan the filename (backwards) ourselves. + var end = fileName.length; + for (var pos = end - 1; pos > 0; pos--) { + var ch = fileName.charCodeAt(pos); + if (ch >= 48 /* _0 */ && ch <= 57 /* _9 */) { + // Match a \d+ segment + do { + --pos; + ch = fileName.charCodeAt(pos); + } while (pos > 0 && ch >= 48 /* _0 */ && ch <= 57 /* _9 */); + } + else if (pos > 4 && (ch === 110 /* n */ || ch === 78 /* N */)) { + // Looking for "min" or "min" + // Already matched the 'n' + --pos; + ch = fileName.charCodeAt(pos); + if (ch !== 105 /* i */ && ch !== 73 /* I */) { + break; + } + --pos; + ch = fileName.charCodeAt(pos); + if (ch !== 109 /* m */ && ch !== 77 /* M */) { + break; + } + --pos; + ch = fileName.charCodeAt(pos); + } + else { + // This character is not part of either suffix pattern + break; + } + if (ch !== 45 /* minus */ && ch !== 46 /* dot */) { + break; + } + end = pos; + } + // end might be fileName.length, in which case this should internally no-op + return end === fileName.length ? fileName : fileName.slice(0, end); } ts.removeMinAndVersionNumbers = removeMinAndVersionNumbers; /** Remove an item from an array, moving everything to its right one space left. */ @@ -2377,6 +2413,33 @@ var ts; return array.slice(0, index); } ts.takeWhile = takeWhile; + /** + * Removes the leading and trailing white space and line terminator characters from a string. + */ + ts.trimString = !!String.prototype.trim ? (function (s) { return s.trim(); }) : function (s) { return ts.trimStringEnd(ts.trimStringStart(s)); }; + /** + * Returns a copy with trailing whitespace removed. + */ + ts.trimStringEnd = !!String.prototype.trimEnd ? (function (s) { return s.trimEnd(); }) : trimEndImpl; + /** + * Returns a copy with leading whitespace removed. + */ + ts.trimStringStart = !!String.prototype.trimStart ? (function (s) { return s.trimStart(); }) : function (s) { return s.replace(/^\s+/g, ""); }; + /** + * https://jsbench.me/gjkoxld4au/1 + * The simple regex for this, /\s+$/g is O(n^2) in v8. + * The native .trimEnd method is by far best, but since that's technically ES2019, + * we provide a (still much faster than the simple regex) fallback. + */ + function trimEndImpl(s) { + var end = s.length - 1; + while (end >= 0) { + if (!ts.isWhiteSpaceLike(s.charCodeAt(end))) + break; + end--; + } + return s.slice(0, end + 1); + } })(ts || (ts = {})); /* @internal */ var ts; @@ -2594,6 +2657,8 @@ var ts; } } Debug.assertMissingNode = assertMissingNode; + function type(_value) { } + Debug.type = type; function getFunctionName(func) { if (typeof func !== "function") { return ""; @@ -2771,6 +2836,9 @@ var ts; // An `Array` with extra properties is rendered as `[A, B, prop1: 1, prop2: 2]`. Most of // these aren't immediately useful so we trim off the `prop1: ..., prop2: ...` part from the // formatted string. + // This regex can trigger slow backtracking because of overlapping potential captures. + // 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; } @@ -2855,11 +2923,11 @@ var ts; this.objectFlags & 8 /* Tuple */ ? "TupleType" : this.objectFlags & 16 /* Anonymous */ ? "AnonymousType" : this.objectFlags & 32 /* Mapped */ ? "MappedType" : - this.objectFlags & 2048 /* ReverseMapped */ ? "ReverseMappedType" : + this.objectFlags & 1024 /* ReverseMapped */ ? "ReverseMappedType" : this.objectFlags & 256 /* EvolvingArray */ ? "EvolvingArrayType" : "ObjectType" : "Type"; - var remainingObjectFlags = this.flags & 524288 /* Object */ ? this.objectFlags & ~2367 /* ObjectTypeKindMask */ : 0; + var remainingObjectFlags = this.flags & 524288 /* Object */ ? this.objectFlags & ~1343 /* ObjectTypeKindMask */ : 0; return "" + typeHeader + (this.symbol ? " '" + ts.symbolName(this.symbol) + "'" : "") + (remainingObjectFlags ? " (" + formatObjectFlags(remainingObjectFlags) + ")" : ""); } }, @@ -3219,7 +3287,7 @@ var ts; // range-set ::= range ( logical-or range ) * // range ::= hyphen | simple ( ' ' simple ) * | '' // logical-or ::= ( ' ' ) * '||' ( ' ' ) * - var logicalOrRegExp = /\s*\|\|\s*/g; + var logicalOrRegExp = /\|\|/g; var whitespaceRegExp = /\s+/g; // https://github.com/npm/node-semver#range-grammar // @@ -3242,14 +3310,15 @@ var ts; // primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial // tilde ::= '~' partial // caret ::= '^' partial - var rangeRegExp = /^\s*(~|\^|<|<=|>|>=|=)?\s*([a-z0-9-+.*]+)$/i; + var rangeRegExp = /^(~|\^|<|<=|>|>=|=)?\s*([a-z0-9-+.*]+)$/i; function parseRange(text) { var alternatives = []; - for (var _i = 0, _a = text.trim().split(logicalOrRegExp); _i < _a.length; _i++) { + for (var _i = 0, _a = ts.trimString(text).split(logicalOrRegExp); _i < _a.length; _i++) { var range = _a[_i]; if (!range) continue; var comparators = []; + range = ts.trimString(range); var match = hyphenRegExp.exec(range); if (match) { if (!parseHyphen(match[1], match[2], comparators)) @@ -3258,7 +3327,7 @@ var ts; else { for (var _b = 0, _c = range.split(whitespaceRegExp); _b < _c.length; _b++) { var simple = _c[_b]; - var match_1 = rangeRegExp.exec(simple); + var match_1 = rangeRegExp.exec(ts.trimString(simple)); if (!match_1 || !parseComparator(match_1[1], match_1[2], comparators)) return undefined; } @@ -3405,16 +3474,22 @@ var ts; typeof PerformanceObserver === "function" && hasRequiredAPI(performance, PerformanceObserver)) { return { + // For now we always write native performance events when running in the browser. We may + // make this conditional in the future if we find that native web performance hooks + // in the browser also slow down compilation. + shouldWriteNativeEvents: true, performance: performance, PerformanceObserver: PerformanceObserver }; } } function tryGetNodePerformanceHooks() { - if (typeof module === "object" && typeof require === "function") { + if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof module === "object" && typeof require === "function") { try { - var _a = require("perf_hooks"), performance_1 = _a.performance, PerformanceObserver_1 = _a.PerformanceObserver; - if (hasRequiredAPI(performance_1, PerformanceObserver_1)) { + var performance_1; + var _a = require("perf_hooks"), nodePerformance_1 = _a.performance, PerformanceObserver_1 = _a.PerformanceObserver; + if (hasRequiredAPI(nodePerformance_1, PerformanceObserver_1)) { + performance_1 = nodePerformance_1; // There is a bug in Node's performance.measure prior to 12.16.3/13.13.0 that does not // match the Web Performance API specification. Node's implementation did not allow // optional `start` and `end` arguments for `performance.measure`. @@ -3422,27 +3497,26 @@ var ts; var version_1 = new ts.Version(process.versions.node); var range = new ts.VersionRange("<12.16.3 || 13 <13.13"); if (range.test(version_1)) { - return { - performance: { - get timeOrigin() { return performance_1.timeOrigin; }, - now: function () { return performance_1.now(); }, - mark: function (name) { return performance_1.mark(name); }, - measure: function (name, start, end) { - if (start === void 0) { start = "nodeStart"; } - if (end === undefined) { - end = "__performance.measure-fix__"; - performance_1.mark(end); - } - performance_1.measure(name, start, end); - if (end === "__performance.measure-fix__") { - performance_1.clearMarks("__performance.measure-fix__"); - } + performance_1 = { + get timeOrigin() { return nodePerformance_1.timeOrigin; }, + now: function () { return nodePerformance_1.now(); }, + mark: function (name) { return nodePerformance_1.mark(name); }, + measure: function (name, start, end) { + if (start === void 0) { start = "nodeStart"; } + if (end === undefined) { + end = "__performance.measure-fix__"; + nodePerformance_1.mark(end); + } + nodePerformance_1.measure(name, start, end); + if (end === "__performance.measure-fix__") { + nodePerformance_1.clearMarks("__performance.measure-fix__"); } - }, - PerformanceObserver: PerformanceObserver_1 + } }; } return { + // By default, only write native events when generating a cpu profile or using the v8 profiler. + shouldWriteNativeEvents: false, performance: performance_1, PerformanceObserver: PerformanceObserver_1 }; @@ -3473,7 +3547,6 @@ var ts; var performance; (function (performance) { var perfHooks; - var perfObserver; // when set, indicates the implementation of `Performance` to use for user timing. // when unset, indicates user timing is unavailable or disabled. var performanceImpl; @@ -3504,6 +3577,9 @@ var ts; } performance.createTimer = createTimer; performance.nullTimer = { enter: ts.noop, exit: ts.noop }; + var enabled = false; + var timeorigin = ts.timestamp(); + var marks = new ts.Map(); var counts = new ts.Map(); var durations = new ts.Map(); /** @@ -3512,7 +3588,13 @@ var ts; * @param markName The name of the mark. */ function mark(markName) { - performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.mark(markName); + var _a; + if (enabled) { + var count = (_a = counts.get(markName)) !== null && _a !== void 0 ? _a : 0; + counts.set(markName, count + 1); + marks.set(markName, ts.timestamp()); + performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.mark(markName); + } } performance.mark = mark; /** @@ -3525,7 +3607,14 @@ var ts; * used. */ function measure(measureName, startMarkName, endMarkName) { - performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.measure(measureName, startMarkName, endMarkName); + var _a, _b; + if (enabled) { + var end = (_a = (endMarkName !== undefined ? marks.get(endMarkName) : undefined)) !== null && _a !== void 0 ? _a : ts.timestamp(); + var start = (_b = (startMarkName !== undefined ? marks.get(startMarkName) : undefined)) !== null && _b !== void 0 ? _b : timeorigin; + var previousDuration = durations.get(measureName) || 0; + durations.set(measureName, previousDuration + (end - start)); + performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.measure(measureName, startMarkName, endMarkName); + } } performance.measure = measure; /** @@ -3559,40 +3648,41 @@ var ts; * Indicates whether the performance API is enabled. */ function isEnabled() { - return !!performanceImpl; + return enabled; } performance.isEnabled = isEnabled; /** Enables (and resets) performance measurements for the compiler. */ - function enable() { - if (!performanceImpl) { + function enable(system) { + var _a; + if (system === void 0) { system = ts.sys; } + if (!enabled) { + enabled = true; perfHooks || (perfHooks = ts.tryGetNativePerformanceHooks()); - if (!perfHooks) - return false; - perfObserver || (perfObserver = new perfHooks.PerformanceObserver(updateStatisticsFromList)); - perfObserver.observe({ entryTypes: ["mark", "measure"] }); - performanceImpl = perfHooks.performance; + if (perfHooks) { + timeorigin = perfHooks.performance.timeOrigin; + // NodeJS's Web Performance API is currently slower than expected, but we'd still like + // to be able to leverage native trace events when node is run with either `--cpu-prof` + // or `--prof`, if we're running with our own `--generateCpuProfile` flag, or when + // running in debug mode (since its possible to generate a cpu profile while debugging). + if (perfHooks.shouldWriteNativeEvents || ((_a = system === null || system === void 0 ? void 0 : system.cpuProfilingEnabled) === null || _a === void 0 ? void 0 : _a.call(system)) || (system === null || system === void 0 ? void 0 : system.debugMode)) { + performanceImpl = perfHooks.performance; + } + } } return true; } performance.enable = enable; /** Disables performance measurements for the compiler. */ function disable() { - perfObserver === null || perfObserver === void 0 ? void 0 : perfObserver.disconnect(); - performanceImpl = undefined; - counts.clear(); - durations.clear(); - } - performance.disable = disable; - function updateStatisticsFromList(list) { - for (var _i = 0, _a = list.getEntriesByType("mark"); _i < _a.length; _i++) { - var mark_1 = _a[_i]; - counts.set(mark_1.name, (counts.get(mark_1.name) || 0) + 1); - } - for (var _b = 0, _c = list.getEntriesByType("measure"); _b < _c.length; _b++) { - var measure_1 = _c[_b]; - durations.set(measure_1.name, (durations.get(measure_1.name) || 0) + measure_1.duration); + if (enabled) { + marks.clear(); + counts.clear(); + durations.clear(); + performanceImpl = undefined; + enabled = false; } } + performance.disable = disable; })(performance = ts.performance || (ts.performance = {})); })(ts || (ts = {})); /* @internal */ @@ -3636,40 +3726,35 @@ var ts; /** Performance logger that will generate ETW events if possible - check for `logEvent` member, as `etwModule` will be `{}` when browserified */ ts.perfLogger = etwModule && etwModule.logEvent ? etwModule : nullLogger; })(ts || (ts = {})); +/* Tracing events for the compiler. */ /*@internal*/ -/** Tracing events for the compiler. */ var ts; (function (ts) { - var tracing; - (function (tracing) { - var Mode; - (function (Mode) { - Mode[Mode["Project"] = 0] = "Project"; - Mode[Mode["Build"] = 1] = "Build"; - Mode[Mode["Server"] = 2] = "Server"; - })(Mode = tracing.Mode || (tracing.Mode = {})); + // enable the above using startTracing() + // `tracingEnabled` should never be used directly, only through the above + var tracingEnabled; + (function (tracingEnabled) { var fs; var traceCount = 0; - var traceFd; + var traceFd = 0; var mode; + var typeCatalog = []; // NB: id is index + 1 var legendPath; var legend = []; ; - /** Starts tracing for the given project (unless the `fs` module is unavailable). */ + /** Starts tracing for the given project. */ function startTracing(tracingMode, traceDir, configFilePath) { - ts.Debug.assert(!traceFd, "Tracing already started"); + ts.Debug.assert(!ts.tracing, "Tracing already started"); if (fs === undefined) { try { fs = require("fs"); } - catch (_a) { - fs = false; + catch (e) { + throw new Error("tracing requires having fs\n(original error: " + (e.message || e) + ")"); } } - if (!fs) { - return; - } mode = tracingMode; + typeCatalog.length = 0; if (legendPath === undefined) { legendPath = ts.combinePaths(traceDir, "legend.json"); } @@ -3677,9 +3762,9 @@ var ts; if (!fs.existsSync(traceDir)) { fs.mkdirSync(traceDir, { recursive: true }); } - var countPart = mode === 1 /* Build */ ? "." + process.pid + "-" + ++traceCount : - mode === 2 /* Server */ ? "." + process.pid : - ""; + var countPart = mode === "build" ? "." + process.pid + "-" + ++traceCount + : mode === "server" ? "." + process.pid + : ""; var tracePath = ts.combinePaths(traceDir, "trace" + countPart + ".json"); var typesPath = ts.combinePaths(traceDir, "types" + countPart + ".json"); legend.push({ @@ -3688,25 +3773,22 @@ var ts; typesPath: typesPath, }); traceFd = fs.openSync(tracePath, "w"); + ts.tracing = tracingEnabled; // only when traceFd is properly set // Start with a prefix that contains some metadata that the devtools profiler expects (also avoids a warning on import) var meta = { cat: "__metadata", ph: "M", ts: 1000 * ts.timestamp(), pid: 1, tid: 1 }; fs.writeSync(traceFd, "[\n" + [__assign({ name: "process_name", args: { name: "tsc" } }, meta), __assign({ name: "thread_name", args: { name: "Main" } }, meta), __assign(__assign({ name: "TracingStartedInBrowser" }, meta), { cat: "disabled-by-default-devtools.timeline" })] .map(function (v) { return JSON.stringify(v); }).join(",\n")); } - tracing.startTracing = startTracing; - /** Stops tracing for the in-progress project and dumps the type catalog (unless the `fs` module is unavailable). */ - function stopTracing(typeCatalog) { - if (!traceFd) { - ts.Debug.assert(!fs, "Tracing is not in progress"); - return; - } - ts.Debug.assert(fs); - ts.Debug.assert(!!typeCatalog === (mode !== 2 /* Server */)); // Have a type catalog iff not in server mode + tracingEnabled.startTracing = startTracing; + /** Stops tracing for the in-progress project and dumps the type catalog. */ + function stopTracing() { + ts.Debug.assert(ts.tracing, "Tracing is not in progress"); + ts.Debug.assert(!!typeCatalog.length === (mode !== "server")); // Have a type catalog iff not in server mode fs.writeSync(traceFd, "\n]\n"); fs.closeSync(traceFd); - traceFd = undefined; - if (typeCatalog) { + ts.tracing = undefined; + if (typeCatalog.length) { dumpTypes(typeCatalog); } else { @@ -3715,11 +3797,13 @@ var ts; legend[legend.length - 1].typesPath = undefined; } } - tracing.stopTracing = stopTracing; - function isTracing() { - return !!traceFd; + tracingEnabled.stopTracing = stopTracing; + function recordType(type) { + if (mode !== "server") { + typeCatalog.push(type); + } } - tracing.isTracing = isTracing; + tracingEnabled.recordType = recordType; var Phase; (function (Phase) { Phase["Parse"] = "parse"; @@ -3729,13 +3813,11 @@ var ts; Phase["CheckTypes"] = "checkTypes"; Phase["Emit"] = "emit"; Phase["Session"] = "session"; - })(Phase = tracing.Phase || (tracing.Phase = {})); + })(Phase = tracingEnabled.Phase || (tracingEnabled.Phase = {})); function instant(phase, name, args) { - if (!traceFd) - return; writeEvent("I", phase, name, args, "\"s\":\"g\""); } - tracing.instant = instant; + tracingEnabled.instant = instant; var eventStack = []; /** * @param separateBeginAndEnd - used for special cases where we need the trace point even if the event @@ -3745,47 +3827,42 @@ var ts; */ function push(phase, name, args, separateBeginAndEnd) { if (separateBeginAndEnd === void 0) { separateBeginAndEnd = false; } - if (!traceFd) - return; if (separateBeginAndEnd) { writeEvent("B", phase, name, args); } eventStack.push({ phase: phase, name: name, args: args, time: 1000 * ts.timestamp(), separateBeginAndEnd: separateBeginAndEnd }); } - tracing.push = push; + tracingEnabled.push = push; function pop() { - if (!traceFd) - return; ts.Debug.assert(eventStack.length > 0); writeStackEvent(eventStack.length - 1, 1000 * ts.timestamp()); eventStack.length--; } - tracing.pop = pop; + tracingEnabled.pop = pop; function popAll() { - if (!traceFd) - return; var endTime = 1000 * ts.timestamp(); for (var i = eventStack.length - 1; i >= 0; i--) { writeStackEvent(i, endTime); } eventStack.length = 0; } - tracing.popAll = popAll; + tracingEnabled.popAll = popAll; + // sample every 10ms + var sampleInterval = 1000 * 10; function writeStackEvent(index, endTime) { var _a = eventStack[index], phase = _a.phase, name = _a.name, args = _a.args, time = _a.time, separateBeginAndEnd = _a.separateBeginAndEnd; if (separateBeginAndEnd) { writeEvent("E", phase, name, args, /*extras*/ undefined, endTime); } - else { + // test if [time,endTime) straddles a sampling point + else if (sampleInterval - (time % sampleInterval) <= endTime - time) { writeEvent("X", phase, name, args, "\"dur\":" + (endTime - time), time); } } function writeEvent(eventType, phase, name, args, extras, time) { if (time === void 0) { time = 1000 * ts.timestamp(); } - ts.Debug.assert(traceFd); - ts.Debug.assert(fs); // In server mode, there's no easy way to dump type information, so we drop events that would require it. - if (mode === 2 /* Server */ && phase === "checkTypes" /* CheckTypes */) + if (mode === "server" && phase === "checkTypes" /* CheckTypes */) return; ts.performance.mark("beginTracing"); fs.writeSync(traceFd, ",\n{\"pid\":1,\"tid\":1,\"ph\":\"" + eventType + "\",\"cat\":\"" + phase + "\",\"ts\":" + time + ",\"name\":\"" + name + "\""); @@ -3797,15 +3874,24 @@ var ts; ts.performance.mark("endTracing"); ts.performance.measure("Tracing", "beginTracing", "endTracing"); } - function indexFromOne(lc) { - return { - line: lc.line + 1, - character: lc.character + 1, - }; + function getLocation(node) { + var file = ts.getSourceFileOfNode(node); + return !file + ? undefined + : { + path: file.path, + start: indexFromOne(ts.getLineAndCharacterOfPosition(file, node.pos)), + end: indexFromOne(ts.getLineAndCharacterOfPosition(file, node.end)), + }; + function indexFromOne(lc) { + return { + line: lc.line + 1, + character: lc.character + 1, + }; + } } function dumpTypes(types) { - var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r; - ts.Debug.assert(fs); + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x; ts.performance.mark("beginDumpTypes"); var typesPath = legend[legend.length - 1].typesPath; var typesFd = fs.openSync(typesPath, "w"); @@ -3817,15 +3903,13 @@ var ts; var type = types[i]; var objectFlags = type.objectFlags; var symbol = (_a = type.aliasSymbol) !== null && _a !== void 0 ? _a : type.symbol; - var firstDeclaration = (_b = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _b === void 0 ? void 0 : _b[0]; - var firstFile = firstDeclaration && ts.getSourceFileOfNode(firstDeclaration); // 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 */)) { try { - display = (_c = type.checker) === null || _c === void 0 ? void 0 : _c.typeToString(type); + display = (_b = type.checker) === null || _b === void 0 ? void 0 : _b.typeToString(type); } - catch (_s) { + catch (_y) { display = undefined; } } @@ -3833,26 +3917,52 @@ var ts; if (type.flags & 8388608 /* IndexedAccess */) { var indexedAccessType = type; indexedAccessProperties = { - indexedAccessObjectType: (_d = indexedAccessType.objectType) === null || _d === void 0 ? void 0 : _d.id, - indexedAccessIndexType: (_e = indexedAccessType.indexType) === null || _e === void 0 ? void 0 : _e.id, + indexedAccessObjectType: (_c = indexedAccessType.objectType) === null || _c === void 0 ? void 0 : _c.id, + indexedAccessIndexType: (_d = indexedAccessType.indexType) === null || _d === void 0 ? void 0 : _d.id, }; } var referenceProperties = {}; if (objectFlags & 4 /* Reference */) { var referenceType = type; referenceProperties = { - instantiatedType: (_f = referenceType.target) === null || _f === void 0 ? void 0 : _f.id, - typeArguments: (_g = referenceType.resolvedTypeArguments) === null || _g === void 0 ? void 0 : _g.map(function (t) { return t.id; }), + instantiatedType: (_e = referenceType.target) === null || _e === void 0 ? void 0 : _e.id, + typeArguments: (_f = referenceType.resolvedTypeArguments) === null || _f === void 0 ? void 0 : _f.map(function (t) { return t.id; }), + referenceLocation: getLocation(referenceType.node), }; } var conditionalProperties = {}; if (type.flags & 16777216 /* Conditional */) { var conditionalType = type; conditionalProperties = { - conditionalCheckType: (_h = conditionalType.checkType) === null || _h === void 0 ? void 0 : _h.id, - conditionalExtendsType: (_j = conditionalType.extendsType) === null || _j === void 0 ? void 0 : _j.id, - conditionalTrueType: (_l = (_k = conditionalType.resolvedTrueType) === null || _k === void 0 ? void 0 : _k.id) !== null && _l !== void 0 ? _l : -1, - conditionalFalseType: (_o = (_m = conditionalType.resolvedFalseType) === null || _m === void 0 ? void 0 : _m.id) !== null && _o !== void 0 ? _o : -1, + conditionalCheckType: (_g = conditionalType.checkType) === null || _g === void 0 ? void 0 : _g.id, + conditionalExtendsType: (_h = conditionalType.extendsType) === null || _h === void 0 ? void 0 : _h.id, + conditionalTrueType: (_k = (_j = conditionalType.resolvedTrueType) === null || _j === void 0 ? void 0 : _j.id) !== null && _k !== void 0 ? _k : -1, + conditionalFalseType: (_m = (_l = conditionalType.resolvedFalseType) === null || _l === void 0 ? void 0 : _l.id) !== null && _m !== void 0 ? _m : -1, + }; + } + var substitutionProperties = {}; + if (type.flags & 33554432 /* Substitution */) { + var substitutionType = type; + substitutionProperties = { + substitutionBaseType: (_o = substitutionType.baseType) === null || _o === void 0 ? void 0 : _o.id, + substituteType: (_p = substitutionType.substitute) === null || _p === void 0 ? void 0 : _p.id, + }; + } + var reverseMappedProperties = {}; + if (objectFlags & 1024 /* ReverseMapped */) { + var reverseMappedType = type; + reverseMappedProperties = { + reverseMappedSourceType: (_q = reverseMappedType.source) === null || _q === void 0 ? void 0 : _q.id, + reverseMappedMappedType: (_r = reverseMappedType.mappedType) === null || _r === void 0 ? void 0 : _r.id, + reverseMappedConstraintType: (_s = reverseMappedType.constraintType) === null || _s === void 0 ? void 0 : _s.id, + }; + } + var evolvingArrayProperties = {}; + if (objectFlags & 256 /* EvolvingArray */) { + var evolvingArrayType = type; + evolvingArrayProperties = { + evolvingArrayElementType: evolvingArrayType.elementType.id, + evolvingArrayFinalType: (_t = evolvingArrayType.finalArrayType) === null || _t === void 0 ? void 0 : _t.id, }; } // We can't print out an arbitrary object, so just assign each one a unique number. @@ -3866,11 +3976,7 @@ var ts; recursionIdentityMap.set(recursionIdentity, recursionToken); } } - var descriptor = __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, unionTypes: (type.flags & 1048576 /* Union */) ? (_p = type.types) === null || _p === void 0 ? void 0 : _p.map(function (t) { return t.id; }) : undefined, intersectionTypes: (type.flags & 2097152 /* Intersection */) ? type.types.map(function (t) { return t.id; }) : undefined, aliasTypeArguments: (_q = type.aliasTypeArguments) === null || _q === void 0 ? void 0 : _q.map(function (t) { return t.id; }), keyofType: (type.flags & 4194304 /* Index */) ? (_r = type.type) === null || _r === void 0 ? void 0 : _r.id : undefined }, indexedAccessProperties), referenceProperties), conditionalProperties), { firstDeclaration: firstDeclaration && { - path: firstFile.path, - start: indexFromOne(ts.getLineAndCharacterOfPosition(firstFile, firstDeclaration.pos)), - end: indexFromOne(ts.getLineAndCharacterOfPosition(ts.getSourceFileOfNode(firstDeclaration), firstDeclaration.end)), - }, 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 /* 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 }); fs.writeSync(typesFd, JSON.stringify(descriptor)); if (i < numTypes - 1) { fs.writeSync(typesFd, ",\n"); @@ -3885,11 +3991,13 @@ var ts; if (!legendPath) { return; } - ts.Debug.assert(fs); fs.writeFileSync(legendPath, JSON.stringify(legend)); } - tracing.dumpLegend = dumpLegend; - })(tracing = ts.tracing || (ts.tracing = {})); + tracingEnabled.dumpLegend = dumpLegend; + })(tracingEnabled || (tracingEnabled = {})); + // define after tracingEnabled is initialized + ts.startTracing = tracingEnabled.startTracing; + ts.dumpTracingLegend = tracingEnabled.dumpLegend; })(ts || (ts = {})); var ts; (function (ts) { @@ -3966,331 +4074,337 @@ var ts; SyntaxKind[SyntaxKind["QuestionQuestionToken"] = 60] = "QuestionQuestionToken"; /** Only the JSDoc scanner produces BacktickToken. The normal scanner produces NoSubstitutionTemplateLiteral and related kinds. */ SyntaxKind[SyntaxKind["BacktickToken"] = 61] = "BacktickToken"; + /** Only the JSDoc scanner produces HashToken. The normal scanner produces PrivateIdentifier. */ + SyntaxKind[SyntaxKind["HashToken"] = 62] = "HashToken"; // Assignments - SyntaxKind[SyntaxKind["EqualsToken"] = 62] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 63] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 64] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 65] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 66] = "AsteriskAsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 67] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 68] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 69] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 70] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 71] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 72] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 73] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["BarBarEqualsToken"] = 74] = "BarBarEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandEqualsToken"] = 75] = "AmpersandAmpersandEqualsToken"; - SyntaxKind[SyntaxKind["QuestionQuestionEqualsToken"] = 76] = "QuestionQuestionEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 77] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 63] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 64] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 65] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 66] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 67] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 68] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 69] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 70] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 71] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 72] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 73] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 74] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["BarBarEqualsToken"] = 75] = "BarBarEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandEqualsToken"] = 76] = "AmpersandAmpersandEqualsToken"; + SyntaxKind[SyntaxKind["QuestionQuestionEqualsToken"] = 77] = "QuestionQuestionEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 78] = "CaretEqualsToken"; // Identifiers and PrivateIdentifiers - SyntaxKind[SyntaxKind["Identifier"] = 78] = "Identifier"; - SyntaxKind[SyntaxKind["PrivateIdentifier"] = 79] = "PrivateIdentifier"; + SyntaxKind[SyntaxKind["Identifier"] = 79] = "Identifier"; + SyntaxKind[SyntaxKind["PrivateIdentifier"] = 80] = "PrivateIdentifier"; // Reserved words - SyntaxKind[SyntaxKind["BreakKeyword"] = 80] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 81] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 82] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 83] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 84] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 85] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 86] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 87] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 88] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 89] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 90] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 91] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 92] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 93] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 94] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 95] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 96] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 97] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 98] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 99] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 100] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 101] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 102] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 103] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 104] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 105] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 106] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 107] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 108] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 109] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 110] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 111] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 112] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 113] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 114] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 115] = "WithKeyword"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 81] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 82] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 83] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 84] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 85] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 86] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 87] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 88] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 89] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 90] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 91] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 92] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 93] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 94] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 95] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 96] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 97] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 98] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 99] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 100] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 101] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 102] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 103] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 104] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 105] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 106] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 107] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 108] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 109] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 110] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 111] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 112] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 113] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 114] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 115] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 116] = "WithKeyword"; // Strict mode reserved words - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 116] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 117] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 118] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 119] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 120] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 121] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 122] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 123] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 124] = "YieldKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 117] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 118] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 119] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 120] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 121] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 122] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 123] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 124] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 125] = "YieldKeyword"; // Contextual keywords - SyntaxKind[SyntaxKind["AbstractKeyword"] = 125] = "AbstractKeyword"; - SyntaxKind[SyntaxKind["AsKeyword"] = 126] = "AsKeyword"; - SyntaxKind[SyntaxKind["AssertsKeyword"] = 127] = "AssertsKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 128] = "AnyKeyword"; - SyntaxKind[SyntaxKind["AsyncKeyword"] = 129] = "AsyncKeyword"; - SyntaxKind[SyntaxKind["AwaitKeyword"] = 130] = "AwaitKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 131] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 132] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 133] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 134] = "GetKeyword"; - SyntaxKind[SyntaxKind["InferKeyword"] = 135] = "InferKeyword"; - SyntaxKind[SyntaxKind["IntrinsicKeyword"] = 136] = "IntrinsicKeyword"; - SyntaxKind[SyntaxKind["IsKeyword"] = 137] = "IsKeyword"; - SyntaxKind[SyntaxKind["KeyOfKeyword"] = 138] = "KeyOfKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 139] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["NamespaceKeyword"] = 140] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["NeverKeyword"] = 141] = "NeverKeyword"; - SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 142] = "ReadonlyKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 143] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 144] = "NumberKeyword"; - SyntaxKind[SyntaxKind["ObjectKeyword"] = 145] = "ObjectKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 146] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 147] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 148] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 149] = "TypeKeyword"; - SyntaxKind[SyntaxKind["UndefinedKeyword"] = 150] = "UndefinedKeyword"; - SyntaxKind[SyntaxKind["UniqueKeyword"] = 151] = "UniqueKeyword"; - SyntaxKind[SyntaxKind["UnknownKeyword"] = 152] = "UnknownKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 153] = "FromKeyword"; - SyntaxKind[SyntaxKind["GlobalKeyword"] = 154] = "GlobalKeyword"; - SyntaxKind[SyntaxKind["BigIntKeyword"] = 155] = "BigIntKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 156] = "OfKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 126] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 127] = "AsKeyword"; + SyntaxKind[SyntaxKind["AssertsKeyword"] = 128] = "AssertsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 129] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 130] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 131] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 132] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 133] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 134] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 135] = "GetKeyword"; + SyntaxKind[SyntaxKind["InferKeyword"] = 136] = "InferKeyword"; + SyntaxKind[SyntaxKind["IntrinsicKeyword"] = 137] = "IntrinsicKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 138] = "IsKeyword"; + SyntaxKind[SyntaxKind["KeyOfKeyword"] = 139] = "KeyOfKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 140] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 141] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 142] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 143] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 144] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 145] = "NumberKeyword"; + SyntaxKind[SyntaxKind["ObjectKeyword"] = 146] = "ObjectKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 147] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 148] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 149] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 150] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 151] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["UniqueKeyword"] = 152] = "UniqueKeyword"; + SyntaxKind[SyntaxKind["UnknownKeyword"] = 153] = "UnknownKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 154] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 155] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["BigIntKeyword"] = 156] = "BigIntKeyword"; + SyntaxKind[SyntaxKind["OverrideKeyword"] = 157] = "OverrideKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 158] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 157] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 158] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 159] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 160] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 159] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 160] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 161] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 161] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 162] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 163] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 162] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 163] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 164] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 165] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 166] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 167] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 168] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 169] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 170] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 171] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 164] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 165] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 166] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 167] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 168] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 169] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 170] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 171] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 172] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 173] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 172] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 173] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 174] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 175] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 176] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 177] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 178] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 179] = "TupleType"; - SyntaxKind[SyntaxKind["OptionalType"] = 180] = "OptionalType"; - SyntaxKind[SyntaxKind["RestType"] = 181] = "RestType"; - SyntaxKind[SyntaxKind["UnionType"] = 182] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 183] = "IntersectionType"; - SyntaxKind[SyntaxKind["ConditionalType"] = 184] = "ConditionalType"; - SyntaxKind[SyntaxKind["InferType"] = 185] = "InferType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 186] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 187] = "ThisType"; - SyntaxKind[SyntaxKind["TypeOperator"] = 188] = "TypeOperator"; - SyntaxKind[SyntaxKind["IndexedAccessType"] = 189] = "IndexedAccessType"; - SyntaxKind[SyntaxKind["MappedType"] = 190] = "MappedType"; - SyntaxKind[SyntaxKind["LiteralType"] = 191] = "LiteralType"; - SyntaxKind[SyntaxKind["NamedTupleMember"] = 192] = "NamedTupleMember"; - SyntaxKind[SyntaxKind["TemplateLiteralType"] = 193] = "TemplateLiteralType"; - SyntaxKind[SyntaxKind["TemplateLiteralTypeSpan"] = 194] = "TemplateLiteralTypeSpan"; - SyntaxKind[SyntaxKind["ImportType"] = 195] = "ImportType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 174] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 175] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 176] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 177] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 178] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 179] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 180] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 181] = "TupleType"; + SyntaxKind[SyntaxKind["OptionalType"] = 182] = "OptionalType"; + SyntaxKind[SyntaxKind["RestType"] = 183] = "RestType"; + SyntaxKind[SyntaxKind["UnionType"] = 184] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 185] = "IntersectionType"; + SyntaxKind[SyntaxKind["ConditionalType"] = 186] = "ConditionalType"; + SyntaxKind[SyntaxKind["InferType"] = 187] = "InferType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 188] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 189] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 190] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 191] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 192] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 193] = "LiteralType"; + SyntaxKind[SyntaxKind["NamedTupleMember"] = 194] = "NamedTupleMember"; + SyntaxKind[SyntaxKind["TemplateLiteralType"] = 195] = "TemplateLiteralType"; + SyntaxKind[SyntaxKind["TemplateLiteralTypeSpan"] = 196] = "TemplateLiteralTypeSpan"; + SyntaxKind[SyntaxKind["ImportType"] = 197] = "ImportType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 196] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 197] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 198] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 198] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 199] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 200] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 199] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 200] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 201] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 202] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 203] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 204] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 205] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 206] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 207] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 208] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 209] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 210] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 211] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 212] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 213] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 214] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 215] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 216] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 217] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 218] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 219] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElement"] = 220] = "SpreadElement"; - SyntaxKind[SyntaxKind["ClassExpression"] = 221] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 222] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 223] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 224] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 225] = "NonNullExpression"; - SyntaxKind[SyntaxKind["MetaProperty"] = 226] = "MetaProperty"; - SyntaxKind[SyntaxKind["SyntheticExpression"] = 227] = "SyntheticExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 201] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 202] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 203] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 204] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 205] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 206] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 207] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 208] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 209] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 210] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 211] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 212] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 213] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 214] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 215] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 216] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 217] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 218] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 219] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 220] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 221] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 222] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 223] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 224] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 225] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 226] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 227] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 228] = "MetaProperty"; + SyntaxKind[SyntaxKind["SyntheticExpression"] = 229] = "SyntheticExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 228] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 229] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 230] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 231] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 230] = "Block"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 231] = "EmptyStatement"; - SyntaxKind[SyntaxKind["VariableStatement"] = 232] = "VariableStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 233] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 234] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 235] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 236] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 237] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 238] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 239] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 240] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 241] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 242] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 243] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 244] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 245] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 246] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 247] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 248] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 249] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 250] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 251] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 252] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 253] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 254] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 255] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 256] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 257] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 258] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 259] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 260] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 261] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 262] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 263] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 264] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 265] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 266] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 267] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 268] = "NamedExports"; - SyntaxKind[SyntaxKind["NamespaceExport"] = 269] = "NamespaceExport"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 270] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 271] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 232] = "Block"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 233] = "EmptyStatement"; + SyntaxKind[SyntaxKind["VariableStatement"] = 234] = "VariableStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 235] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 236] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 237] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 238] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 239] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 240] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 241] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 242] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 243] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 244] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 245] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 246] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 247] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 248] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 249] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 250] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 251] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 252] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 253] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 254] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 255] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 256] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 257] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 258] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 259] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 260] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 261] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 262] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 263] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 264] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 265] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 266] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 267] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 268] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 269] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 270] = "NamedExports"; + SyntaxKind[SyntaxKind["NamespaceExport"] = 271] = "NamespaceExport"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 272] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 273] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 272] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 274] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 273] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 274] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 275] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 276] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxFragment"] = 277] = "JsxFragment"; - SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 278] = "JsxOpeningFragment"; - SyntaxKind[SyntaxKind["JsxClosingFragment"] = 279] = "JsxClosingFragment"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 280] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxAttributes"] = 281] = "JsxAttributes"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 282] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 283] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 275] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 276] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 277] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 278] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxFragment"] = 279] = "JsxFragment"; + SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 280] = "JsxOpeningFragment"; + SyntaxKind[SyntaxKind["JsxClosingFragment"] = 281] = "JsxClosingFragment"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 282] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 283] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 284] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 285] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 284] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 285] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 286] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 287] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 286] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 287] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 288] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 289] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 288] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 289] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 290] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 290] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 291] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 292] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 291] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 293] = "EnumMember"; // Unparsed - SyntaxKind[SyntaxKind["UnparsedPrologue"] = 292] = "UnparsedPrologue"; - SyntaxKind[SyntaxKind["UnparsedPrepend"] = 293] = "UnparsedPrepend"; - SyntaxKind[SyntaxKind["UnparsedText"] = 294] = "UnparsedText"; - SyntaxKind[SyntaxKind["UnparsedInternalText"] = 295] = "UnparsedInternalText"; - SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 296] = "UnparsedSyntheticReference"; + SyntaxKind[SyntaxKind["UnparsedPrologue"] = 294] = "UnparsedPrologue"; + SyntaxKind[SyntaxKind["UnparsedPrepend"] = 295] = "UnparsedPrepend"; + SyntaxKind[SyntaxKind["UnparsedText"] = 296] = "UnparsedText"; + SyntaxKind[SyntaxKind["UnparsedInternalText"] = 297] = "UnparsedInternalText"; + SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 298] = "UnparsedSyntheticReference"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 297] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 298] = "Bundle"; - SyntaxKind[SyntaxKind["UnparsedSource"] = 299] = "UnparsedSource"; - SyntaxKind[SyntaxKind["InputFiles"] = 300] = "InputFiles"; + SyntaxKind[SyntaxKind["SourceFile"] = 299] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 300] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 301] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 302] = "InputFiles"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 301] = "JSDocTypeExpression"; - SyntaxKind[SyntaxKind["JSDocNameReference"] = 302] = "JSDocNameReference"; - // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 303] = "JSDocAllType"; - // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 304] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 305] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 306] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 307] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 308] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 309] = "JSDocVariadicType"; - // https://jsdoc.app/about-namepaths.html - SyntaxKind[SyntaxKind["JSDocNamepathType"] = 310] = "JSDocNamepathType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 311] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 312] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocSignature"] = 313] = "JSDocSignature"; - SyntaxKind[SyntaxKind["JSDocTag"] = 314] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 315] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocImplementsTag"] = 316] = "JSDocImplementsTag"; - SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 317] = "JSDocAuthorTag"; - SyntaxKind[SyntaxKind["JSDocDeprecatedTag"] = 318] = "JSDocDeprecatedTag"; - SyntaxKind[SyntaxKind["JSDocClassTag"] = 319] = "JSDocClassTag"; - SyntaxKind[SyntaxKind["JSDocPublicTag"] = 320] = "JSDocPublicTag"; - SyntaxKind[SyntaxKind["JSDocPrivateTag"] = 321] = "JSDocPrivateTag"; - SyntaxKind[SyntaxKind["JSDocProtectedTag"] = 322] = "JSDocProtectedTag"; - SyntaxKind[SyntaxKind["JSDocReadonlyTag"] = 323] = "JSDocReadonlyTag"; - SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 324] = "JSDocCallbackTag"; - SyntaxKind[SyntaxKind["JSDocEnumTag"] = 325] = "JSDocEnumTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 326] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 327] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocThisTag"] = 328] = "JSDocThisTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 329] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 330] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 331] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocSeeTag"] = 332] = "JSDocSeeTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 333] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 303] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocNameReference"] = 304] = "JSDocNameReference"; + SyntaxKind[SyntaxKind["JSDocMemberName"] = 305] = "JSDocMemberName"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 306] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 307] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 308] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 309] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 310] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 311] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 312] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocNamepathType"] = 313] = "JSDocNamepathType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 314] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocText"] = 315] = "JSDocText"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 316] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 317] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocLink"] = 318] = "JSDocLink"; + SyntaxKind[SyntaxKind["JSDocLinkCode"] = 319] = "JSDocLinkCode"; + SyntaxKind[SyntaxKind["JSDocLinkPlain"] = 320] = "JSDocLinkPlain"; + SyntaxKind[SyntaxKind["JSDocTag"] = 321] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 322] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocImplementsTag"] = 323] = "JSDocImplementsTag"; + SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 324] = "JSDocAuthorTag"; + SyntaxKind[SyntaxKind["JSDocDeprecatedTag"] = 325] = "JSDocDeprecatedTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 326] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocPublicTag"] = 327] = "JSDocPublicTag"; + SyntaxKind[SyntaxKind["JSDocPrivateTag"] = 328] = "JSDocPrivateTag"; + SyntaxKind[SyntaxKind["JSDocProtectedTag"] = 329] = "JSDocProtectedTag"; + SyntaxKind[SyntaxKind["JSDocReadonlyTag"] = 330] = "JSDocReadonlyTag"; + SyntaxKind[SyntaxKind["JSDocOverrideTag"] = 331] = "JSDocOverrideTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 332] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocEnumTag"] = 333] = "JSDocEnumTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 334] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 335] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocThisTag"] = 336] = "JSDocThisTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 337] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 338] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 339] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocSeeTag"] = 340] = "JSDocSeeTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 341] = "JSDocPropertyTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 334] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 342] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 335] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 336] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["CommaListExpression"] = 337] = "CommaListExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 338] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 339] = "EndOfDeclarationMarker"; - SyntaxKind[SyntaxKind["SyntheticReferenceExpression"] = 340] = "SyntheticReferenceExpression"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 343] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 344] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 345] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 346] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 347] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["SyntheticReferenceExpression"] = 348] = "SyntheticReferenceExpression"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 341] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 349] = "Count"; // Markers - SyntaxKind[SyntaxKind["FirstAssignment"] = 62] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 77] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 63] = "FirstCompoundAssignment"; - SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 77] = "LastCompoundAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 80] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 115] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 80] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 156] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 116] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 124] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 172] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 195] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 63] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 78] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 64] = "FirstCompoundAssignment"; + SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 78] = "LastCompoundAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 81] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 116] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 81] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 158] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 117] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 125] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 174] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 197] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 18] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 77] = "LastPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 78] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 156] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 158] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; @@ -4298,16 +4412,16 @@ var ts; SyntaxKind[SyntaxKind["FirstTemplateToken"] = 14] = "FirstTemplateToken"; SyntaxKind[SyntaxKind["LastTemplateToken"] = 17] = "LastTemplateToken"; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 29] = "FirstBinaryOperator"; - SyntaxKind[SyntaxKind["LastBinaryOperator"] = 77] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstStatement"] = 232] = "FirstStatement"; - SyntaxKind[SyntaxKind["LastStatement"] = 248] = "LastStatement"; - SyntaxKind[SyntaxKind["FirstNode"] = 157] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 301] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 333] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 314] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 333] = "LastJSDocTagNode"; - /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 125] = "FirstContextualKeyword"; - /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 156] = "LastContextualKeyword"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 78] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstStatement"] = 234] = "FirstStatement"; + SyntaxKind[SyntaxKind["LastStatement"] = 250] = "LastStatement"; + SyntaxKind[SyntaxKind["FirstNode"] = 159] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 303] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 341] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 321] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 341] = "LastJSDocTagNode"; + /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 126] = "FirstContextualKeyword"; + /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 158] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); var NodeFlags; (function (NodeFlags) { @@ -4377,14 +4491,15 @@ var ts; ModifierFlags[ModifierFlags["Const"] = 2048] = "Const"; ModifierFlags[ModifierFlags["HasComputedJSDocModifiers"] = 4096] = "HasComputedJSDocModifiers"; ModifierFlags[ModifierFlags["Deprecated"] = 8192] = "Deprecated"; + ModifierFlags[ModifierFlags["Override"] = 16384] = "Override"; ModifierFlags[ModifierFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; ModifierFlags[ModifierFlags["AccessibilityModifier"] = 28] = "AccessibilityModifier"; // Accessibility modifiers and 'readonly' can be attached to a parameter in a constructor to make it a property. - ModifierFlags[ModifierFlags["ParameterPropertyModifier"] = 92] = "ParameterPropertyModifier"; + ModifierFlags[ModifierFlags["ParameterPropertyModifier"] = 16476] = "ParameterPropertyModifier"; ModifierFlags[ModifierFlags["NonPublicAccessibilityModifier"] = 24] = "NonPublicAccessibilityModifier"; - ModifierFlags[ModifierFlags["TypeScriptModifier"] = 2270] = "TypeScriptModifier"; + ModifierFlags[ModifierFlags["TypeScriptModifier"] = 18654] = "TypeScriptModifier"; ModifierFlags[ModifierFlags["ExportDefault"] = 513] = "ExportDefault"; - ModifierFlags[ModifierFlags["All"] = 11263] = "All"; + ModifierFlags[ModifierFlags["All"] = 27647] = "All"; })(ModifierFlags = ts.ModifierFlags || (ts.ModifierFlags = {})); var JsxFlags; (function (JsxFlags) { @@ -4565,6 +4680,8 @@ var ts; NodeBuilderFlags[NodeBuilderFlags["NoUndefinedOptionalParameterType"] = 1073741824] = "NoUndefinedOptionalParameterType"; // Error handling NodeBuilderFlags[NodeBuilderFlags["AllowThisInObjectLiteral"] = 32768] = "AllowThisInObjectLiteral"; + NodeBuilderFlags[NodeBuilderFlags["AllowQualifiedNameInPlaceOfIdentifier"] = 65536] = "AllowQualifiedNameInPlaceOfIdentifier"; + /** @deprecated AllowQualifedNameInPlaceOfIdentifier. Use AllowQualifiedNameInPlaceOfIdentifier instead. */ NodeBuilderFlags[NodeBuilderFlags["AllowQualifedNameInPlaceOfIdentifier"] = 65536] = "AllowQualifedNameInPlaceOfIdentifier"; NodeBuilderFlags[NodeBuilderFlags["AllowAnonymousIdentifier"] = 131072] = "AllowAnonymousIdentifier"; NodeBuilderFlags[NodeBuilderFlags["AllowEmptyUnionOrIntersection"] = 262144] = "AllowEmptyUnionOrIntersection"; @@ -4579,7 +4696,6 @@ var ts; NodeBuilderFlags[NodeBuilderFlags["InObjectTypeLiteral"] = 4194304] = "InObjectTypeLiteral"; NodeBuilderFlags[NodeBuilderFlags["InTypeAlias"] = 8388608] = "InTypeAlias"; NodeBuilderFlags[NodeBuilderFlags["InInitialEntityName"] = 16777216] = "InInitialEntityName"; - NodeBuilderFlags[NodeBuilderFlags["InReverseMappedType"] = 33554432] = "InReverseMappedType"; })(NodeBuilderFlags = ts.NodeBuilderFlags || (ts.NodeBuilderFlags = {})); // Ensure the shared flags between this and `NodeBuilderFlags` stay in alignment var TypeFormatFlags; @@ -4884,10 +5000,6 @@ var ts; TypeFlags[TypeFlags["Unit"] = 109440] = "Unit"; TypeFlags[TypeFlags["StringOrNumberLiteral"] = 384] = "StringOrNumberLiteral"; /* @internal */ - TypeFlags[TypeFlags["StringLikeLiteral"] = 134217856] = "StringLikeLiteral"; - /* @internal */ - TypeFlags[TypeFlags["FreshableLiteral"] = 134220672] = "FreshableLiteral"; - /* @internal */ TypeFlags[TypeFlags["StringOrNumberLiteralOrUnique"] = 8576] = "StringOrNumberLiteralOrUnique"; /* @internal */ TypeFlags[TypeFlags["DefinitelyFalsy"] = 117632] = "DefinitelyFalsy"; @@ -4936,6 +5048,9 @@ var ts; /* @internal */ TypeFlags[TypeFlags["IncludesEmptyObject"] = 16777216] = "IncludesEmptyObject"; })(TypeFlags = ts.TypeFlags || (ts.TypeFlags = {})); + // Types included in TypeFlags.ObjectFlagsType have an objectFlags property. Some ObjectFlags + // are specific to certain types and reuse the same bit position. Those ObjectFlags require a check + // for a certain TypeFlags value to determine their meaning. var ObjectFlags; (function (ObjectFlags) { ObjectFlags[ObjectFlags["Class"] = 1] = "Class"; @@ -4948,50 +5063,59 @@ var ts; ObjectFlags[ObjectFlags["ObjectLiteral"] = 128] = "ObjectLiteral"; ObjectFlags[ObjectFlags["EvolvingArray"] = 256] = "EvolvingArray"; ObjectFlags[ObjectFlags["ObjectLiteralPatternWithComputedProperties"] = 512] = "ObjectLiteralPatternWithComputedProperties"; - ObjectFlags[ObjectFlags["ContainsSpread"] = 1024] = "ContainsSpread"; - ObjectFlags[ObjectFlags["ReverseMapped"] = 2048] = "ReverseMapped"; - ObjectFlags[ObjectFlags["JsxAttributes"] = 4096] = "JsxAttributes"; - ObjectFlags[ObjectFlags["MarkerType"] = 8192] = "MarkerType"; - ObjectFlags[ObjectFlags["JSLiteral"] = 16384] = "JSLiteral"; - ObjectFlags[ObjectFlags["FreshLiteral"] = 32768] = "FreshLiteral"; - ObjectFlags[ObjectFlags["ArrayLiteral"] = 65536] = "ArrayLiteral"; - ObjectFlags[ObjectFlags["ObjectRestType"] = 131072] = "ObjectRestType"; + ObjectFlags[ObjectFlags["ReverseMapped"] = 1024] = "ReverseMapped"; + ObjectFlags[ObjectFlags["JsxAttributes"] = 2048] = "JsxAttributes"; + ObjectFlags[ObjectFlags["MarkerType"] = 4096] = "MarkerType"; + ObjectFlags[ObjectFlags["JSLiteral"] = 8192] = "JSLiteral"; + ObjectFlags[ObjectFlags["FreshLiteral"] = 16384] = "FreshLiteral"; + ObjectFlags[ObjectFlags["ArrayLiteral"] = 32768] = "ArrayLiteral"; /* @internal */ - ObjectFlags[ObjectFlags["PrimitiveUnion"] = 262144] = "PrimitiveUnion"; + ObjectFlags[ObjectFlags["PrimitiveUnion"] = 65536] = "PrimitiveUnion"; /* @internal */ - ObjectFlags[ObjectFlags["ContainsWideningType"] = 524288] = "ContainsWideningType"; + ObjectFlags[ObjectFlags["ContainsWideningType"] = 131072] = "ContainsWideningType"; /* @internal */ - ObjectFlags[ObjectFlags["ContainsObjectOrArrayLiteral"] = 1048576] = "ContainsObjectOrArrayLiteral"; + ObjectFlags[ObjectFlags["ContainsObjectOrArrayLiteral"] = 262144] = "ContainsObjectOrArrayLiteral"; /* @internal */ - ObjectFlags[ObjectFlags["NonInferrableType"] = 2097152] = "NonInferrableType"; + ObjectFlags[ObjectFlags["NonInferrableType"] = 524288] = "NonInferrableType"; /* @internal */ - ObjectFlags[ObjectFlags["IsGenericObjectTypeComputed"] = 4194304] = "IsGenericObjectTypeComputed"; + ObjectFlags[ObjectFlags["CouldContainTypeVariablesComputed"] = 1048576] = "CouldContainTypeVariablesComputed"; /* @internal */ - ObjectFlags[ObjectFlags["IsGenericObjectType"] = 8388608] = "IsGenericObjectType"; + ObjectFlags[ObjectFlags["CouldContainTypeVariables"] = 2097152] = "CouldContainTypeVariables"; + ObjectFlags[ObjectFlags["ClassOrInterface"] = 3] = "ClassOrInterface"; /* @internal */ - ObjectFlags[ObjectFlags["IsGenericIndexTypeComputed"] = 16777216] = "IsGenericIndexTypeComputed"; + ObjectFlags[ObjectFlags["RequiresWidening"] = 393216] = "RequiresWidening"; /* @internal */ - ObjectFlags[ObjectFlags["IsGenericIndexType"] = 33554432] = "IsGenericIndexType"; + ObjectFlags[ObjectFlags["PropagatingFlags"] = 917504] = "PropagatingFlags"; + // Object flags that uniquely identify the kind of ObjectType /* @internal */ - ObjectFlags[ObjectFlags["CouldContainTypeVariablesComputed"] = 67108864] = "CouldContainTypeVariablesComputed"; + ObjectFlags[ObjectFlags["ObjectTypeKindMask"] = 1343] = "ObjectTypeKindMask"; + // Flags that require TypeFlags.Object + ObjectFlags[ObjectFlags["ContainsSpread"] = 4194304] = "ContainsSpread"; + ObjectFlags[ObjectFlags["ObjectRestType"] = 8388608] = "ObjectRestType"; /* @internal */ - ObjectFlags[ObjectFlags["CouldContainTypeVariables"] = 134217728] = "CouldContainTypeVariables"; + ObjectFlags[ObjectFlags["IsClassInstanceClone"] = 16777216] = "IsClassInstanceClone"; + // Flags that require TypeFlags.Object and ObjectFlags.Reference /* @internal */ - ObjectFlags[ObjectFlags["ContainsIntersections"] = 268435456] = "ContainsIntersections"; + ObjectFlags[ObjectFlags["IdenticalBaseTypeCalculated"] = 33554432] = "IdenticalBaseTypeCalculated"; /* @internal */ - ObjectFlags[ObjectFlags["IsNeverIntersectionComputed"] = 268435456] = "IsNeverIntersectionComputed"; + ObjectFlags[ObjectFlags["IdenticalBaseTypeExists"] = 67108864] = "IdenticalBaseTypeExists"; + // Flags that require TypeFlags.UnionOrIntersection or TypeFlags.Substitution /* @internal */ - ObjectFlags[ObjectFlags["IsNeverIntersection"] = 536870912] = "IsNeverIntersection"; + ObjectFlags[ObjectFlags["IsGenericObjectTypeComputed"] = 4194304] = "IsGenericObjectTypeComputed"; /* @internal */ - ObjectFlags[ObjectFlags["IsClassInstanceClone"] = 1073741824] = "IsClassInstanceClone"; - ObjectFlags[ObjectFlags["ClassOrInterface"] = 3] = "ClassOrInterface"; + ObjectFlags[ObjectFlags["IsGenericObjectType"] = 8388608] = "IsGenericObjectType"; /* @internal */ - ObjectFlags[ObjectFlags["RequiresWidening"] = 1572864] = "RequiresWidening"; + ObjectFlags[ObjectFlags["IsGenericIndexTypeComputed"] = 16777216] = "IsGenericIndexTypeComputed"; /* @internal */ - ObjectFlags[ObjectFlags["PropagatingFlags"] = 3670016] = "PropagatingFlags"; - // Object flags that uniquely identify the kind of ObjectType + ObjectFlags[ObjectFlags["IsGenericIndexType"] = 33554432] = "IsGenericIndexType"; + // Flags that require TypeFlags.Union + /* @internal */ + ObjectFlags[ObjectFlags["ContainsIntersections"] = 67108864] = "ContainsIntersections"; + // Flags that require TypeFlags.Intersection /* @internal */ - ObjectFlags[ObjectFlags["ObjectTypeKindMask"] = 2367] = "ObjectTypeKindMask"; + ObjectFlags[ObjectFlags["IsNeverIntersectionComputed"] = 67108864] = "IsNeverIntersectionComputed"; + /* @internal */ + ObjectFlags[ObjectFlags["IsNeverIntersection"] = 134217728] = "IsNeverIntersection"; })(ObjectFlags = ts.ObjectFlags || (ts.ObjectFlags = {})); /* @internal */ var VarianceFlags; @@ -5018,6 +5142,21 @@ var ts; ElementFlags[ElementFlags["NonRest"] = 11] = "NonRest"; })(ElementFlags = ts.ElementFlags || (ts.ElementFlags = {})); /* @internal */ + var AccessFlags; + (function (AccessFlags) { + AccessFlags[AccessFlags["None"] = 0] = "None"; + AccessFlags[AccessFlags["IncludeUndefined"] = 1] = "IncludeUndefined"; + AccessFlags[AccessFlags["NoIndexSignatures"] = 2] = "NoIndexSignatures"; + AccessFlags[AccessFlags["Writing"] = 4] = "Writing"; + AccessFlags[AccessFlags["CacheSymbol"] = 8] = "CacheSymbol"; + AccessFlags[AccessFlags["NoTupleBoundsCheck"] = 16] = "NoTupleBoundsCheck"; + AccessFlags[AccessFlags["ExpressionPosition"] = 32] = "ExpressionPosition"; + AccessFlags[AccessFlags["ReportDeprecated"] = 64] = "ReportDeprecated"; + AccessFlags[AccessFlags["SuppressNoImplicitAnyError"] = 128] = "SuppressNoImplicitAnyError"; + AccessFlags[AccessFlags["Contextual"] = 256] = "Contextual"; + AccessFlags[AccessFlags["Persistent"] = 1] = "Persistent"; + })(AccessFlags = ts.AccessFlags || (ts.AccessFlags = {})); + /* @internal */ var JsxReferenceKind; (function (JsxReferenceKind) { JsxReferenceKind[JsxReferenceKind["Component"] = 0] = "Component"; @@ -5065,16 +5204,17 @@ var ts; (function (InferencePriority) { InferencePriority[InferencePriority["NakedTypeVariable"] = 1] = "NakedTypeVariable"; InferencePriority[InferencePriority["SpeculativeTuple"] = 2] = "SpeculativeTuple"; - InferencePriority[InferencePriority["HomomorphicMappedType"] = 4] = "HomomorphicMappedType"; - InferencePriority[InferencePriority["PartialHomomorphicMappedType"] = 8] = "PartialHomomorphicMappedType"; - InferencePriority[InferencePriority["MappedTypeConstraint"] = 16] = "MappedTypeConstraint"; - InferencePriority[InferencePriority["ContravariantConditional"] = 32] = "ContravariantConditional"; - InferencePriority[InferencePriority["ReturnType"] = 64] = "ReturnType"; - InferencePriority[InferencePriority["LiteralKeyof"] = 128] = "LiteralKeyof"; - InferencePriority[InferencePriority["NoConstraints"] = 256] = "NoConstraints"; - InferencePriority[InferencePriority["AlwaysStrict"] = 512] = "AlwaysStrict"; - InferencePriority[InferencePriority["MaxValue"] = 1024] = "MaxValue"; - InferencePriority[InferencePriority["PriorityImpliesCombination"] = 208] = "PriorityImpliesCombination"; + InferencePriority[InferencePriority["SubstituteSource"] = 4] = "SubstituteSource"; + InferencePriority[InferencePriority["HomomorphicMappedType"] = 8] = "HomomorphicMappedType"; + InferencePriority[InferencePriority["PartialHomomorphicMappedType"] = 16] = "PartialHomomorphicMappedType"; + InferencePriority[InferencePriority["MappedTypeConstraint"] = 32] = "MappedTypeConstraint"; + InferencePriority[InferencePriority["ContravariantConditional"] = 64] = "ContravariantConditional"; + InferencePriority[InferencePriority["ReturnType"] = 128] = "ReturnType"; + InferencePriority[InferencePriority["LiteralKeyof"] = 256] = "LiteralKeyof"; + InferencePriority[InferencePriority["NoConstraints"] = 512] = "NoConstraints"; + InferencePriority[InferencePriority["AlwaysStrict"] = 1024] = "AlwaysStrict"; + InferencePriority[InferencePriority["MaxValue"] = 2048] = "MaxValue"; + InferencePriority[InferencePriority["PriorityImpliesCombination"] = 416] = "PriorityImpliesCombination"; InferencePriority[InferencePriority["Circularity"] = -1] = "Circularity"; })(InferencePriority = ts.InferencePriority || (ts.InferencePriority = {})); /* @internal */ @@ -5152,20 +5292,23 @@ var ts; WatchFileKind[WatchFileKind["FixedPollingInterval"] = 0] = "FixedPollingInterval"; WatchFileKind[WatchFileKind["PriorityPollingInterval"] = 1] = "PriorityPollingInterval"; WatchFileKind[WatchFileKind["DynamicPriorityPolling"] = 2] = "DynamicPriorityPolling"; - WatchFileKind[WatchFileKind["UseFsEvents"] = 3] = "UseFsEvents"; - WatchFileKind[WatchFileKind["UseFsEventsOnParentDirectory"] = 4] = "UseFsEventsOnParentDirectory"; + WatchFileKind[WatchFileKind["FixedChunkSizePolling"] = 3] = "FixedChunkSizePolling"; + WatchFileKind[WatchFileKind["UseFsEvents"] = 4] = "UseFsEvents"; + WatchFileKind[WatchFileKind["UseFsEventsOnParentDirectory"] = 5] = "UseFsEventsOnParentDirectory"; })(WatchFileKind = ts.WatchFileKind || (ts.WatchFileKind = {})); var WatchDirectoryKind; (function (WatchDirectoryKind) { WatchDirectoryKind[WatchDirectoryKind["UseFsEvents"] = 0] = "UseFsEvents"; WatchDirectoryKind[WatchDirectoryKind["FixedPollingInterval"] = 1] = "FixedPollingInterval"; WatchDirectoryKind[WatchDirectoryKind["DynamicPriorityPolling"] = 2] = "DynamicPriorityPolling"; + WatchDirectoryKind[WatchDirectoryKind["FixedChunkSizePolling"] = 3] = "FixedChunkSizePolling"; })(WatchDirectoryKind = ts.WatchDirectoryKind || (ts.WatchDirectoryKind = {})); var PollingWatchKind; (function (PollingWatchKind) { PollingWatchKind[PollingWatchKind["FixedInterval"] = 0] = "FixedInterval"; PollingWatchKind[PollingWatchKind["PriorityInterval"] = 1] = "PriorityInterval"; PollingWatchKind[PollingWatchKind["DynamicPriority"] = 2] = "DynamicPriority"; + PollingWatchKind[PollingWatchKind["FixedChunkSize"] = 3] = "FixedChunkSize"; })(PollingWatchKind = ts.PollingWatchKind || (ts.PollingWatchKind = {})); var ModuleKind; (function (ModuleKind) { @@ -5226,6 +5369,7 @@ var ts; ScriptTarget[ScriptTarget["ES2018"] = 5] = "ES2018"; ScriptTarget[ScriptTarget["ES2019"] = 6] = "ES2019"; ScriptTarget[ScriptTarget["ES2020"] = 7] = "ES2020"; + ScriptTarget[ScriptTarget["ES2021"] = 8] = "ES2021"; ScriptTarget[ScriptTarget["ESNext"] = 99] = "ESNext"; ScriptTarget[ScriptTarget["JSON"] = 100] = "JSON"; ScriptTarget[ScriptTarget["Latest"] = 99] = "Latest"; @@ -5388,29 +5532,30 @@ var ts; TransformFlags[TransformFlags["ContainsTypeScript"] = 1] = "ContainsTypeScript"; TransformFlags[TransformFlags["ContainsJsx"] = 2] = "ContainsJsx"; TransformFlags[TransformFlags["ContainsESNext"] = 4] = "ContainsESNext"; - TransformFlags[TransformFlags["ContainsES2020"] = 8] = "ContainsES2020"; - TransformFlags[TransformFlags["ContainsES2019"] = 16] = "ContainsES2019"; - TransformFlags[TransformFlags["ContainsES2018"] = 32] = "ContainsES2018"; - TransformFlags[TransformFlags["ContainsES2017"] = 64] = "ContainsES2017"; - TransformFlags[TransformFlags["ContainsES2016"] = 128] = "ContainsES2016"; - TransformFlags[TransformFlags["ContainsES2015"] = 256] = "ContainsES2015"; - TransformFlags[TransformFlags["ContainsGenerator"] = 512] = "ContainsGenerator"; - TransformFlags[TransformFlags["ContainsDestructuringAssignment"] = 1024] = "ContainsDestructuringAssignment"; + TransformFlags[TransformFlags["ContainsES2021"] = 8] = "ContainsES2021"; + TransformFlags[TransformFlags["ContainsES2020"] = 16] = "ContainsES2020"; + TransformFlags[TransformFlags["ContainsES2019"] = 32] = "ContainsES2019"; + TransformFlags[TransformFlags["ContainsES2018"] = 64] = "ContainsES2018"; + TransformFlags[TransformFlags["ContainsES2017"] = 128] = "ContainsES2017"; + TransformFlags[TransformFlags["ContainsES2016"] = 256] = "ContainsES2016"; + TransformFlags[TransformFlags["ContainsES2015"] = 512] = "ContainsES2015"; + TransformFlags[TransformFlags["ContainsGenerator"] = 1024] = "ContainsGenerator"; + TransformFlags[TransformFlags["ContainsDestructuringAssignment"] = 2048] = "ContainsDestructuringAssignment"; // Markers // - Flags used to indicate that a subtree contains a specific transformation. - TransformFlags[TransformFlags["ContainsTypeScriptClassSyntax"] = 2048] = "ContainsTypeScriptClassSyntax"; - TransformFlags[TransformFlags["ContainsLexicalThis"] = 4096] = "ContainsLexicalThis"; - TransformFlags[TransformFlags["ContainsRestOrSpread"] = 8192] = "ContainsRestOrSpread"; - TransformFlags[TransformFlags["ContainsObjectRestOrSpread"] = 16384] = "ContainsObjectRestOrSpread"; - TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 32768] = "ContainsComputedPropertyName"; - TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 65536] = "ContainsBlockScopedBinding"; - TransformFlags[TransformFlags["ContainsBindingPattern"] = 131072] = "ContainsBindingPattern"; - TransformFlags[TransformFlags["ContainsYield"] = 262144] = "ContainsYield"; - TransformFlags[TransformFlags["ContainsAwait"] = 524288] = "ContainsAwait"; - TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 1048576] = "ContainsHoistedDeclarationOrCompletion"; - TransformFlags[TransformFlags["ContainsDynamicImport"] = 2097152] = "ContainsDynamicImport"; - TransformFlags[TransformFlags["ContainsClassFields"] = 4194304] = "ContainsClassFields"; - TransformFlags[TransformFlags["ContainsPossibleTopLevelAwait"] = 8388608] = "ContainsPossibleTopLevelAwait"; + TransformFlags[TransformFlags["ContainsTypeScriptClassSyntax"] = 4096] = "ContainsTypeScriptClassSyntax"; + TransformFlags[TransformFlags["ContainsLexicalThis"] = 8192] = "ContainsLexicalThis"; + TransformFlags[TransformFlags["ContainsRestOrSpread"] = 16384] = "ContainsRestOrSpread"; + TransformFlags[TransformFlags["ContainsObjectRestOrSpread"] = 32768] = "ContainsObjectRestOrSpread"; + TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 65536] = "ContainsComputedPropertyName"; + TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 131072] = "ContainsBlockScopedBinding"; + TransformFlags[TransformFlags["ContainsBindingPattern"] = 262144] = "ContainsBindingPattern"; + TransformFlags[TransformFlags["ContainsYield"] = 524288] = "ContainsYield"; + TransformFlags[TransformFlags["ContainsAwait"] = 1048576] = "ContainsAwait"; + TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 2097152] = "ContainsHoistedDeclarationOrCompletion"; + TransformFlags[TransformFlags["ContainsDynamicImport"] = 4194304] = "ContainsDynamicImport"; + TransformFlags[TransformFlags["ContainsClassFields"] = 8388608] = "ContainsClassFields"; + TransformFlags[TransformFlags["ContainsPossibleTopLevelAwait"] = 16777216] = "ContainsPossibleTopLevelAwait"; // 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 @@ -5420,37 +5565,38 @@ var ts; TransformFlags[TransformFlags["AssertTypeScript"] = 1] = "AssertTypeScript"; TransformFlags[TransformFlags["AssertJsx"] = 2] = "AssertJsx"; TransformFlags[TransformFlags["AssertESNext"] = 4] = "AssertESNext"; - TransformFlags[TransformFlags["AssertES2020"] = 8] = "AssertES2020"; - TransformFlags[TransformFlags["AssertES2019"] = 16] = "AssertES2019"; - TransformFlags[TransformFlags["AssertES2018"] = 32] = "AssertES2018"; - TransformFlags[TransformFlags["AssertES2017"] = 64] = "AssertES2017"; - TransformFlags[TransformFlags["AssertES2016"] = 128] = "AssertES2016"; - TransformFlags[TransformFlags["AssertES2015"] = 256] = "AssertES2015"; - TransformFlags[TransformFlags["AssertGenerator"] = 512] = "AssertGenerator"; - TransformFlags[TransformFlags["AssertDestructuringAssignment"] = 1024] = "AssertDestructuringAssignment"; + TransformFlags[TransformFlags["AssertES2021"] = 8] = "AssertES2021"; + TransformFlags[TransformFlags["AssertES2020"] = 16] = "AssertES2020"; + TransformFlags[TransformFlags["AssertES2019"] = 32] = "AssertES2019"; + TransformFlags[TransformFlags["AssertES2018"] = 64] = "AssertES2018"; + TransformFlags[TransformFlags["AssertES2017"] = 128] = "AssertES2017"; + TransformFlags[TransformFlags["AssertES2016"] = 256] = "AssertES2016"; + TransformFlags[TransformFlags["AssertES2015"] = 512] = "AssertES2015"; + TransformFlags[TransformFlags["AssertGenerator"] = 1024] = "AssertGenerator"; + TransformFlags[TransformFlags["AssertDestructuringAssignment"] = 2048] = "AssertDestructuringAssignment"; // 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"] = 547309568] = "ArrowFunctionExcludes"; - TransformFlags[TransformFlags["FunctionExcludes"] = 547313664] = "FunctionExcludes"; - TransformFlags[TransformFlags["ConstructorExcludes"] = 547311616] = "ConstructorExcludes"; - TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 538923008] = "MethodOrAccessorExcludes"; - TransformFlags[TransformFlags["PropertyExcludes"] = 536875008] = "PropertyExcludes"; - TransformFlags[TransformFlags["ClassExcludes"] = 536905728] = "ClassExcludes"; - TransformFlags[TransformFlags["ModuleExcludes"] = 546379776] = "ModuleExcludes"; + TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 557748224] = "ArrowFunctionExcludes"; + TransformFlags[TransformFlags["FunctionExcludes"] = 557756416] = "FunctionExcludes"; + TransformFlags[TransformFlags["ConstructorExcludes"] = 557752320] = "ConstructorExcludes"; + TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 540975104] = "MethodOrAccessorExcludes"; + TransformFlags[TransformFlags["PropertyExcludes"] = 536879104] = "PropertyExcludes"; + TransformFlags[TransformFlags["ClassExcludes"] = 536940544] = "ClassExcludes"; + TransformFlags[TransformFlags["ModuleExcludes"] = 555888640] = "ModuleExcludes"; TransformFlags[TransformFlags["TypeExcludes"] = -2] = "TypeExcludes"; - TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 536922112] = "ObjectLiteralExcludes"; - TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 536879104] = "ArrayLiteralOrCallOrNewExcludes"; - TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 537018368] = "VariableDeclarationListExcludes"; + TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 536973312] = "ObjectLiteralExcludes"; + TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 536887296] = "ArrayLiteralOrCallOrNewExcludes"; + TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 537165824] = "VariableDeclarationListExcludes"; TransformFlags[TransformFlags["ParameterExcludes"] = 536870912] = "ParameterExcludes"; - TransformFlags[TransformFlags["CatchClauseExcludes"] = 536887296] = "CatchClauseExcludes"; - TransformFlags[TransformFlags["BindingPatternExcludes"] = 536879104] = "BindingPatternExcludes"; + TransformFlags[TransformFlags["CatchClauseExcludes"] = 536903680] = "CatchClauseExcludes"; + TransformFlags[TransformFlags["BindingPatternExcludes"] = 536887296] = "BindingPatternExcludes"; // Propagating flags // - Bitmasks for flags that should propagate from a child - TransformFlags[TransformFlags["PropertyNamePropagatingFlags"] = 4096] = "PropertyNamePropagatingFlags"; + TransformFlags[TransformFlags["PropertyNamePropagatingFlags"] = 8192] = "PropertyNamePropagatingFlags"; // Masks // - Additional bitmasks })(TransformFlags = ts.TransformFlags || (ts.TransformFlags = {})); @@ -6048,6 +6194,11 @@ var ts; * Normalize path separators, converting `\` into `/`. */ function normalizeSlashes(path) { + var index = path.indexOf("\\"); + if (index === -1) { + return path; + } + backslashRegExp.lastIndex = index; // prime regex with known position return path.replace(backslashRegExp, ts.directorySeparator); } ts.normalizeSlashes = normalizeSlashes; @@ -6158,6 +6309,19 @@ var ts; ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath; function normalizePath(path) { path = normalizeSlashes(path); + // Most paths don't require normalization + if (!relativePathSegmentRegExp.test(path)) { + return path; + } + // Some paths only require cleanup of `/./` or leading `./` + var simplified = path.replace(/\/\.\//g, "/").replace(/^\.\//, ""); + if (simplified !== path) { + path = simplified; + if (!relativePathSegmentRegExp.test(path)) { + return path; + } + } + // Other paths require full normalization var normalized = getPathFromPathComponents(reducePathComponents(getPathComponents(path))); return normalized && hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalized) : normalized; } @@ -6226,7 +6390,7 @@ var ts; ts.changeAnyExtension = changeAnyExtension; //// Path Comparisons // check path for these segments: '', '.'. '..' - var relativePathSegmentRegExp = /(^|\/)\.{0,2}($|\/)/; + var relativePathSegmentRegExp = /(?:\/\/)|(?:^|\/)\.\.?(?:$|\/)/; function comparePathsWorker(a, b, componentComparer) { if (a === b) return 0 /* EqualTo */; @@ -6318,7 +6482,7 @@ var ts; * Determines whether `fileName` starts with the specified `directoryName` using the provided path canonicalization callback. * Comparison is case-sensitive between the canonical paths. * - * @deprecated Use `containsPath` if possible. + * Use `containsPath` if file names are not already reduced and absolute. */ function startsWithDirectory(fileName, directoryName, getCanonicalFileName) { var canonicalFileName = getCanonicalFileName(fileName); @@ -6438,6 +6602,11 @@ var ts; })(PollingInterval = ts.PollingInterval || (ts.PollingInterval = {})); /* @internal */ ts.missingFileModifiedTime = new Date(0); // Any subsequent modification will occur after this time + /* @internal */ + function getModifiedTime(host, fileName) { + return host.getModifiedTime(fileName) || ts.missingFileModifiedTime; + } + ts.getModifiedTime = getModifiedTime; function createPollingIntervalBasedLevels(levels) { var _a; return _a = {}, @@ -6494,6 +6663,51 @@ var ts; } } ts.setCustomPollingValues = setCustomPollingValues; + function pollWatchedFileQueue(host, queue, pollIndex, chunkSize, callbackOnWatchFileStat) { + var definedValueCopyToIndex = pollIndex; + // Max visit would be all elements of the queue + for (var canVisit = queue.length; chunkSize && canVisit; nextPollIndex(), canVisit--) { + var watchedFile = queue[pollIndex]; + if (!watchedFile) { + continue; + } + else if (watchedFile.isClosed) { + queue[pollIndex] = undefined; + continue; + } + // Only files polled count towards chunkSize + chunkSize--; + var fileChanged = onWatchedFileStat(watchedFile, getModifiedTime(host, watchedFile.fileName)); + if (watchedFile.isClosed) { + // Closed watcher as part of callback + queue[pollIndex] = undefined; + continue; + } + callbackOnWatchFileStat === null || callbackOnWatchFileStat === void 0 ? void 0 : callbackOnWatchFileStat(watchedFile, pollIndex, fileChanged); + // Defragment the queue while we are at it + if (queue[pollIndex]) { + // Copy this file to the non hole location + if (definedValueCopyToIndex < pollIndex) { + queue[definedValueCopyToIndex] = watchedFile; + queue[pollIndex] = undefined; + } + definedValueCopyToIndex++; + } + } + // Return next poll index + return pollIndex; + function nextPollIndex() { + pollIndex++; + if (pollIndex === queue.length) { + if (definedValueCopyToIndex < pollIndex) { + // There are holes from definedValueCopyToIndex to end of queue, change queue size + queue.length = definedValueCopyToIndex; + } + pollIndex = 0; + definedValueCopyToIndex = 0; + } + } + } /* @internal */ function createDynamicPriorityPollingWatchFile(host) { var watchedFiles = []; @@ -6507,7 +6721,7 @@ var ts; fileName: fileName, callback: callback, unchangedPolls: 0, - mtime: getModifiedTime(fileName) + mtime: getModifiedTime(host, fileName) }; watchedFiles.push(file); addToPollingIntervalQueue(file, defaultPollingInterval); @@ -6550,25 +6764,9 @@ var ts; } } function pollQueue(queue, pollingInterval, pollIndex, chunkSize) { - // Max visit would be all elements of the queue - var needsVisit = queue.length; - var definedValueCopyToIndex = pollIndex; - for (var polled = 0; polled < chunkSize && needsVisit > 0; nextPollIndex(), needsVisit--) { - var watchedFile = queue[pollIndex]; - if (!watchedFile) { - continue; - } - else if (watchedFile.isClosed) { - queue[pollIndex] = undefined; - continue; - } - polled++; - var fileChanged = onWatchedFileStat(watchedFile, getModifiedTime(watchedFile.fileName)); - if (watchedFile.isClosed) { - // Closed watcher as part of callback - queue[pollIndex] = undefined; - } - else if (fileChanged) { + return pollWatchedFileQueue(host, queue, pollIndex, chunkSize, onWatchFileStat); + function onWatchFileStat(watchedFile, pollIndex, fileChanged) { + if (fileChanged) { watchedFile.unchangedPolls = 0; // Changed files go to changedFilesInLastPoll queue if (queue !== changedFilesInLastPoll) { @@ -6590,27 +6788,6 @@ var ts; queue[pollIndex] = undefined; addToPollingIntervalQueue(watchedFile, pollingInterval === PollingInterval.Low ? PollingInterval.Medium : PollingInterval.High); } - if (queue[pollIndex]) { - // Copy this file to the non hole location - if (definedValueCopyToIndex < pollIndex) { - queue[definedValueCopyToIndex] = watchedFile; - queue[pollIndex] = undefined; - } - definedValueCopyToIndex++; - } - } - // Return next poll index - return pollIndex; - function nextPollIndex() { - pollIndex++; - if (pollIndex === queue.length) { - if (definedValueCopyToIndex < pollIndex) { - // There are holes from nextDefinedValueIndex to end of queue, change queue size - queue.length = definedValueCopyToIndex; - } - pollIndex = 0; - definedValueCopyToIndex = 0; - } } } function pollingIntervalQueue(pollingInterval) { @@ -6639,9 +6816,6 @@ var ts; function scheduleNextPoll(pollingInterval) { pollingIntervalQueue(pollingInterval).pollScheduled = host.setTimeout(pollingInterval === PollingInterval.Low ? pollLowPollingIntervalQueue : pollPollingIntervalQueue, pollingInterval, pollingIntervalQueue(pollingInterval)); } - function getModifiedTime(fileName) { - return host.getModifiedTime(fileName) || ts.missingFileModifiedTime; - } } ts.createDynamicPriorityPollingWatchFile = createDynamicPriorityPollingWatchFile; function createUseFsEventsOnParentDirectoryWatchFile(fsWatch, useCaseSensitiveFileNames) { @@ -6692,6 +6866,37 @@ var ts; return watcher; } } + function createFixedChunkSizePollingWatchFile(host) { + var watchedFiles = []; + var pollIndex = 0; + var pollScheduled; + return watchFile; + function watchFile(fileName, callback) { + var file = { + fileName: fileName, + callback: callback, + mtime: getModifiedTime(host, fileName) + }; + watchedFiles.push(file); + scheduleNextPoll(); + return { + close: function () { + file.isClosed = true; + ts.unorderedRemoveItem(watchedFiles, file); + } + }; + } + function pollQueue() { + pollScheduled = undefined; + pollIndex = pollWatchedFileQueue(host, watchedFiles, pollIndex, pollingChunkSize[PollingInterval.Low]); + scheduleNextPoll(); + } + function scheduleNextPoll() { + if (!watchedFiles.length || pollScheduled) + return; + pollScheduled = host.setTimeout(pollQueue, PollingInterval.High); + } + } /* @internal */ function createSingleFileWatcherPerName(watchFile, useCaseSensitiveFileNames) { var cache = new ts.Map(); @@ -7014,8 +7219,9 @@ var ts; } /*@internal*/ function createSystemWatchFunctions(_a) { - var pollingWatchFile = _a.pollingWatchFile, getModifiedTime = _a.getModifiedTime, setTimeout = _a.setTimeout, clearTimeout = _a.clearTimeout, fsWatch = _a.fsWatch, fileExists = _a.fileExists, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, getCurrentDirectory = _a.getCurrentDirectory, fsSupportsRecursiveFsWatch = _a.fsSupportsRecursiveFsWatch, directoryExists = _a.directoryExists, getAccessibleSortedChildDirectories = _a.getAccessibleSortedChildDirectories, realpath = _a.realpath, tscWatchFile = _a.tscWatchFile, useNonPollingWatchers = _a.useNonPollingWatchers, tscWatchDirectory = _a.tscWatchDirectory; + var pollingWatchFile = _a.pollingWatchFile, getModifiedTime = _a.getModifiedTime, setTimeout = _a.setTimeout, clearTimeout = _a.clearTimeout, fsWatch = _a.fsWatch, fileExists = _a.fileExists, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, getCurrentDirectory = _a.getCurrentDirectory, fsSupportsRecursiveFsWatch = _a.fsSupportsRecursiveFsWatch, directoryExists = _a.directoryExists, getAccessibleSortedChildDirectories = _a.getAccessibleSortedChildDirectories, realpath = _a.realpath, tscWatchFile = _a.tscWatchFile, useNonPollingWatchers = _a.useNonPollingWatchers, tscWatchDirectory = _a.tscWatchDirectory, defaultWatchFileKind = _a.defaultWatchFileKind; var dynamicPollingWatchFile; + var fixedChunkSizePollingWatchFile; var nonPollingWatchFile; var hostRecursiveDirectoryWatcher; return { @@ -7032,6 +7238,8 @@ var ts; return pollingWatchFile(fileName, callback, pollingInterval, /*options*/ undefined); case ts.WatchFileKind.DynamicPriorityPolling: return ensureDynamicPollingWatchFile()(fileName, callback, pollingInterval, /*options*/ undefined); + case ts.WatchFileKind.FixedChunkSizePolling: + return ensureFixedChunkSizePollingWatchFile()(fileName, callback, /* pollingInterval */ undefined, /*options*/ undefined); case ts.WatchFileKind.UseFsEvents: return fsWatch(fileName, 0 /* File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists), /*recursive*/ false, pollingInterval, ts.getFallbackOptions(options)); @@ -7045,8 +7253,10 @@ var ts; } } function ensureDynamicPollingWatchFile() { - return dynamicPollingWatchFile || - (dynamicPollingWatchFile = createDynamicPriorityPollingWatchFile({ getModifiedTime: getModifiedTime, setTimeout: setTimeout })); + return dynamicPollingWatchFile || (dynamicPollingWatchFile = createDynamicPriorityPollingWatchFile({ getModifiedTime: getModifiedTime, setTimeout: setTimeout })); + } + function ensureFixedChunkSizePollingWatchFile() { + return fixedChunkSizePollingWatchFile || (fixedChunkSizePollingWatchFile = createFixedChunkSizePollingWatchFile({ getModifiedTime: getModifiedTime, setTimeout: setTimeout })); } function updateOptionsForWatchFile(options, useNonPollingWatchers) { if (options && options.watchFile !== undefined) @@ -7072,7 +7282,7 @@ var ts; // Use notifications from FS to watch with falling back to fs.watchFile generateWatchFileOptions(ts.WatchFileKind.UseFsEventsOnParentDirectory, ts.PollingWatchKind.PriorityInterval, options) : // Default to do not use fixed polling interval - { watchFile: ts.WatchFileKind.FixedPollingInterval }; + { watchFile: (defaultWatchFileKind === null || defaultWatchFileKind === void 0 ? void 0 : defaultWatchFileKind()) || ts.WatchFileKind.FixedPollingInterval }; } } function generateWatchFileOptions(watchFile, fallbackPolling, options) { @@ -7113,6 +7323,10 @@ var ts; case ts.WatchDirectoryKind.DynamicPriorityPolling: return ensureDynamicPollingWatchFile()(directoryName, function () { return callback(directoryName); }, PollingInterval.Medium, /*options*/ undefined); + case ts.WatchDirectoryKind.FixedChunkSizePolling: + return ensureFixedChunkSizePollingWatchFile()(directoryName, function () { return callback(directoryName); }, + /* 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)); default: @@ -7191,13 +7405,13 @@ var ts; } var activeSession; var profilePath = "./profile.cpuprofile"; - var realpathSync = (_a = _fs.realpathSync.native) !== null && _a !== void 0 ? _a : _fs.realpathSync; var Buffer = require("buffer").Buffer; var nodeVersion = getNodeMajorVersion(); var isNode4OrLater = nodeVersion >= 4; var isLinuxOrMacOs = process.platform === "linux" || process.platform === "darwin"; var platform = _os.platform(); var useCaseSensitiveFileNames = isFileSystemCaseSensitive(); + var realpathSync = useCaseSensitiveFileNames ? ((_a = _fs.realpathSync.native) !== null && _a !== void 0 ? _a : _fs.realpathSync) : _fs.realpathSync; var fsSupportsRecursiveFsWatch = isNode4OrLater && (process.platform === "win32" || process.platform === "darwin"); var getCurrentDirectory = ts.memoize(function () { return process.cwd(); }); var _c = createSystemWatchFunctions({ @@ -7218,6 +7432,7 @@ var ts; tscWatchFile: process.env.TSC_WATCHFILE, useNonPollingWatchers: process.env.TSC_NONPOLLING_WATCHER, tscWatchDirectory: process.env.TSC_WATCHDIRECTORY, + defaultWatchFileKind: function () { var _a, _b; return (_b = (_a = sys).defaultWatchFileKind) === null || _b === void 0 ? void 0 : _b.call(_a); }, }), watchFile = _c.watchFile, watchDirectory = _c.watchDirectory; var nodeSystem = { args: process.argv.slice(2), @@ -7286,6 +7501,7 @@ var ts; }, enableCPUProfiler: enableCPUProfiler, disableCPUProfiler: disableCPUProfiler, + cpuProfilingEnabled: function () { return !!activeSession || ts.contains(process.execArgv, "--cpu-prof") || ts.contains(process.execArgv, "--prof"); }, realpath: realpath, debugMode: !!process.env.NODE_INSPECTOR_IPC || !!process.env.VSCODE_INSPECTOR_OPTIONS || ts.some(process.execArgv, function (arg) { return /^--(inspect|debug)(-brk)?(=\d+)?$/i.test(arg); }), tryEnableSourceMapsForHost: function () { @@ -7535,7 +7751,7 @@ var ts; return event === "rename" && (!relativeName || relativeName === lastDirectoryPart || - relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length) && + (relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) !== -1 && relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length)) && !fileSystemEntryExists(fileOrDirectory, entryKind) ? invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry) : callback(event, relativeName); @@ -7845,9 +8061,10 @@ var ts; Invalid_use_of_0_in_strict_mode: diag(1100, ts.DiagnosticCategory.Error, "Invalid_use_of_0_in_strict_mode_1100", "Invalid use of '{0}' in strict mode."), with_statements_are_not_allowed_in_strict_mode: diag(1101, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_strict_mode_1101", "'with' statements are not allowed in strict mode."), delete_cannot_be_called_on_an_identifier_in_strict_mode: diag(1102, ts.DiagnosticCategory.Error, "delete_cannot_be_called_on_an_identifier_in_strict_mode_1102", "'delete' cannot be called on an identifier in strict mode."), - A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator: diag(1103, ts.DiagnosticCategory.Error, "A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator_1103", "A 'for-await-of' statement is only allowed within an async function or async generator."), + for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1103, ts.DiagnosticCategory.Error, "for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1103", "'for await' loops are only allowed within async functions and at the top levels of modules."), A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: diag(1104, ts.DiagnosticCategory.Error, "A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement_1104", "A 'continue' statement can only be used within an enclosing iteration statement."), A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: diag(1105, ts.DiagnosticCategory.Error, "A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement_1105", "A 'break' statement can only be used within an enclosing iteration or switch statement."), + The_left_hand_side_of_a_for_of_statement_may_not_be_async: diag(1106, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_of_statement_may_not_be_async_1106", "The left-hand side of a 'for...of' statement may not be 'async'."), Jump_target_cannot_cross_function_boundary: diag(1107, ts.DiagnosticCategory.Error, "Jump_target_cannot_cross_function_boundary_1107", "Jump target cannot cross function boundary."), A_return_statement_can_only_be_used_within_a_function_body: diag(1108, ts.DiagnosticCategory.Error, "A_return_statement_can_only_be_used_within_a_function_body_1108", "A 'return' statement can only be used within a function body."), Expression_expected: diag(1109, ts.DiagnosticCategory.Error, "Expression_expected_1109", "Expression expected."), @@ -7894,7 +8111,7 @@ var ts; A_yield_expression_is_only_allowed_in_a_generator_body: diag(1163, ts.DiagnosticCategory.Error, "A_yield_expression_is_only_allowed_in_a_generator_body_1163", "A 'yield' expression is only allowed in a generator body."), Computed_property_names_are_not_allowed_in_enums: diag(1164, ts.DiagnosticCategory.Error, "Computed_property_names_are_not_allowed_in_enums_1164", "Computed property names are not allowed in enums."), A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1165, ts.DiagnosticCategory.Error, "A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_t_1165", "A computed property name in an ambient context must refer to an expression whose type is a literal type or a 'unique symbol' type."), - A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1166, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_1166", "A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type."), + A_computed_property_name_in_a_class_property_declaration_must_have_a_simple_literal_type_or_a_unique_symbol_type: diag(1166, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_class_property_declaration_must_have_a_simple_literal_type_or_a_unique_1166", "A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type."), A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1168, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_ty_1168", "A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type."), A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1169, ts.DiagnosticCategory.Error, "A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_1169", "A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type."), A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1170, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type__1170", "A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type."), @@ -7954,7 +8171,7 @@ var ts; A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: diag(1228, ts.DiagnosticCategory.Error, "A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods_1228", "A type predicate is only allowed in return type position for functions and methods."), A_type_predicate_cannot_reference_a_rest_parameter: diag(1229, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_a_rest_parameter_1229", "A type predicate cannot reference a rest parameter."), A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: diag(1230, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_element_0_in_a_binding_pattern_1230", "A type predicate cannot reference element '{0}' in a binding pattern."), - An_export_assignment_can_only_be_used_in_a_module: diag(1231, ts.DiagnosticCategory.Error, "An_export_assignment_can_only_be_used_in_a_module_1231", "An export assignment can only be used in a module."), + An_export_assignment_must_be_at_the_top_level_of_a_file_or_module_declaration: diag(1231, ts.DiagnosticCategory.Error, "An_export_assignment_must_be_at_the_top_level_of_a_file_or_module_declaration_1231", "An export assignment must be at the top level of a file or module declaration."), An_import_declaration_can_only_be_used_in_a_namespace_or_module: diag(1232, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_in_a_namespace_or_module_1232", "An import declaration can only be used in a namespace or module."), An_export_declaration_can_only_be_used_in_a_module: diag(1233, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_in_a_module_1233", "An export declaration can only be used in a module."), An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: diag(1234, ts.DiagnosticCategory.Error, "An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file_1234", "An ambient module declaration is only allowed at the top level in a file."), @@ -7980,6 +8197,7 @@ var ts; A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_reference: diag(1254, ts.DiagnosticCategory.Error, "A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_refere_1254", "A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference."), A_definite_assignment_assertion_is_not_permitted_in_this_context: diag(1255, ts.DiagnosticCategory.Error, "A_definite_assignment_assertion_is_not_permitted_in_this_context_1255", "A definite assignment assertion '!' is not permitted in this context."), A_required_element_cannot_follow_an_optional_element: diag(1257, ts.DiagnosticCategory.Error, "A_required_element_cannot_follow_an_optional_element_1257", "A required element cannot follow an optional element."), + A_default_export_must_be_at_the_top_level_of_a_file_or_module_declaration: diag(1258, ts.DiagnosticCategory.Error, "A_default_export_must_be_at_the_top_level_of_a_file_or_module_declaration_1258", "A default export must be at the top level of a file or module declaration."), Module_0_can_only_be_default_imported_using_the_1_flag: diag(1259, ts.DiagnosticCategory.Error, "Module_0_can_only_be_default_imported_using_the_1_flag_1259", "Module '{0}' can only be default-imported using the '{1}' flag"), Keywords_cannot_contain_escape_characters: diag(1260, ts.DiagnosticCategory.Error, "Keywords_cannot_contain_escape_characters_1260", "Keywords cannot contain escape characters."), Already_included_file_name_0_differs_from_file_name_1_only_in_casing: diag(1261, ts.DiagnosticCategory.Error, "Already_included_file_name_0_differs_from_file_name_1_only_in_casing_1261", "Already included file name '{0}' differs from file name '{1}' only in casing."), @@ -7988,6 +8206,7 @@ var ts; Declarations_with_definite_assignment_assertions_must_also_have_type_annotations: diag(1264, ts.DiagnosticCategory.Error, "Declarations_with_definite_assignment_assertions_must_also_have_type_annotations_1264", "Declarations with definite assignment assertions must also have type annotations."), A_rest_element_cannot_follow_another_rest_element: diag(1265, ts.DiagnosticCategory.Error, "A_rest_element_cannot_follow_another_rest_element_1265", "A rest element cannot follow another rest element."), An_optional_element_cannot_follow_a_rest_element: diag(1266, ts.DiagnosticCategory.Error, "An_optional_element_cannot_follow_a_rest_element_1266", "An optional element cannot follow a rest element."), + Property_0_cannot_have_an_initializer_because_it_is_marked_abstract: diag(1267, ts.DiagnosticCategory.Error, "Property_0_cannot_have_an_initializer_because_it_is_marked_abstract_1267", "Property '{0}' cannot have an initializer because it is marked abstract."), with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1308, ts.DiagnosticCategory.Error, "await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1308", "'await' expressions are only allowed within async functions and at the top levels of modules."), 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: diag(1312, ts.DiagnosticCategory.Error, "Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_1312", "Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern."), @@ -8066,7 +8285,7 @@ var ts; Constructor_type_notation_must_be_parenthesized_when_used_in_an_intersection_type: diag(1388, ts.DiagnosticCategory.Error, "Constructor_type_notation_must_be_parenthesized_when_used_in_an_intersection_type_1388", "Constructor type notation must be parenthesized when used in an intersection type."), _0_is_not_allowed_as_a_variable_declaration_name: diag(1389, ts.DiagnosticCategory.Error, "_0_is_not_allowed_as_a_variable_declaration_name_1389", "'{0}' is not allowed as a variable declaration name."), Provides_a_root_package_name_when_using_outFile_with_declarations: diag(1390, ts.DiagnosticCategory.Message, "Provides_a_root_package_name_when_using_outFile_with_declarations_1390", "Provides a root package name when using outFile with declarations."), - The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_declaration_emit: diag(1391, ts.DiagnosticCategory.Error, "The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_de_1391", "The `bundledPackageName` option must be provided when using outFile and node module resolution with declaration emit."), + The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_declaration_emit: diag(1391, ts.DiagnosticCategory.Error, "The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_de_1391", "The 'bundledPackageName' option must be provided when using outFile and node module resolution with declaration emit."), An_import_alias_cannot_use_import_type: diag(1392, ts.DiagnosticCategory.Error, "An_import_alias_cannot_use_import_type_1392", "An import alias cannot use 'import type'"), Imported_via_0_from_file_1: diag(1393, ts.DiagnosticCategory.Message, "Imported_via_0_from_file_1_1393", "Imported via {0} from file '{1}'"), Imported_via_0_from_file_1_with_packageId_2: diag(1394, ts.DiagnosticCategory.Message, "Imported_via_0_from_file_1_with_packageId_2_1394", "Imported via {0} from file '{1}' with packageId '{2}'"), @@ -8106,6 +8325,9 @@ var ts; File_is_output_of_project_reference_source_0: diag(1428, ts.DiagnosticCategory.Message, "File_is_output_of_project_reference_source_0_1428", "File is output of project reference source '{0}'"), File_redirects_to_file_0: diag(1429, ts.DiagnosticCategory.Message, "File_redirects_to_file_0_1429", "File redirects to file '{0}'"), The_file_is_in_the_program_because_Colon: diag(1430, ts.DiagnosticCategory.Message, "The_file_is_in_the_program_because_Colon_1430", "The file is in the program because:"), + for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module: diag(1431, ts.DiagnosticCategory.Error, "for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_1431", "'for await' loops are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module."), + Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher: diag(1432, ts.DiagnosticCategory.Error, "Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_1432", "Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher."), + Decorators_may_not_be_applied_to_this_parameters: diag(1433, ts.DiagnosticCategory.Error, "Decorators_may_not_be_applied_to_this_parameters_1433", "Decorators may not be applied to 'this' parameters."), 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), @@ -8173,7 +8395,7 @@ var ts; The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2358, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter."), The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: diag(2359, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type."), The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: diag(2360, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol_2360", "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'."), - The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2361, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter_2361", "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter."), + The_right_hand_side_of_an_in_expression_must_not_be_a_primitive: diag(2361, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_in_expression_must_not_be_a_primitive_2361", "The right-hand side of an 'in' expression must not be a primitive."), The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2362, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2362", "The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."), The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2363, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2363", "The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."), The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: diag(2364, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", "The left-hand side of an assignment expression must be a variable or a property access."), @@ -8191,8 +8413,7 @@ var ts; A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_parameter_properties_or_private_identifiers: diag(2376, ts.DiagnosticCategory.Error, "A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_proper_2376", "A 'super' call must be the first statement in the constructor when a class contains initialized properties, parameter properties, or private identifiers."), Constructors_for_derived_classes_must_contain_a_super_call: diag(2377, ts.DiagnosticCategory.Error, "Constructors_for_derived_classes_must_contain_a_super_call_2377", "Constructors for derived classes must contain a 'super' call."), A_get_accessor_must_return_a_value: diag(2378, ts.DiagnosticCategory.Error, "A_get_accessor_must_return_a_value_2378", "A 'get' accessor must return a value."), - Getter_and_setter_accessors_do_not_agree_in_visibility: diag(2379, ts.DiagnosticCategory.Error, "Getter_and_setter_accessors_do_not_agree_in_visibility_2379", "Getter and setter accessors do not agree in visibility."), - get_and_set_accessor_must_have_the_same_type: diag(2380, ts.DiagnosticCategory.Error, "get_and_set_accessor_must_have_the_same_type_2380", "'get' and 'set' accessor must have the same type."), + The_return_type_of_a_get_accessor_must_be_assignable_to_its_set_accessor_type: diag(2380, ts.DiagnosticCategory.Error, "The_return_type_of_a_get_accessor_must_be_assignable_to_its_set_accessor_type_2380", "The return type of a 'get' accessor must be assignable to its 'set' accessor type"), A_signature_with_an_implementation_cannot_use_a_string_literal_type: diag(2381, ts.DiagnosticCategory.Error, "A_signature_with_an_implementation_cannot_use_a_string_literal_type_2381", "A signature with an implementation cannot use a string literal type."), Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: diag(2382, ts.DiagnosticCategory.Error, "Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature_2382", "Specialized overload signature is not assignable to any non-specialized signature."), Overload_signatures_must_all_be_exported_or_non_exported: diag(2383, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_exported_or_non_exported_2383", "Overload signatures must all be exported or non-exported."), @@ -8255,7 +8476,7 @@ var ts; Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2: diag(2443, ts.DiagnosticCategory.Error, "Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2_2443", "Property '{0}' is protected but type '{1}' is not a class derived from '{2}'."), Property_0_is_protected_in_type_1_but_public_in_type_2: diag(2444, ts.DiagnosticCategory.Error, "Property_0_is_protected_in_type_1_but_public_in_type_2_2444", "Property '{0}' is protected in type '{1}' but public in type '{2}'."), Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses: diag(2445, ts.DiagnosticCategory.Error, "Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses_2445", "Property '{0}' is protected and only accessible within class '{1}' and its subclasses."), - Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: diag(2446, ts.DiagnosticCategory.Error, "Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_2446", "Property '{0}' is protected and only accessible through an instance of class '{1}'."), + Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_This_is_an_instance_of_class_2: diag(2446, ts.DiagnosticCategory.Error, "Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_This_is_an_instance_of_cl_2446", "Property '{0}' is protected and only accessible through an instance of class '{1}'. This is an instance of class '{2}'."), The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: diag(2447, ts.DiagnosticCategory.Error, "The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead_2447", "The '{0}' operator is not allowed for boolean types. Consider using '{1}' instead."), Block_scoped_variable_0_used_before_its_declaration: diag(2448, ts.DiagnosticCategory.Error, "Block_scoped_variable_0_used_before_its_declaration_2448", "Block-scoped variable '{0}' used before its declaration."), Class_0_used_before_its_declaration: diag(2449, ts.DiagnosticCategory.Error, "Class_0_used_before_its_declaration_2449", "Class '{0}' used before its declaration."), @@ -8355,14 +8576,13 @@ var ts; The_type_returned_by_the_0_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_property: diag(2547, ts.DiagnosticCategory.Error, "The_type_returned_by_the_0_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_pro_2547", "The type returned by the '{0}()' method of an async iterator must be a promise for a type with a 'value' property."), Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator: diag(2548, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator_2548", "Type '{0}' is not an array type or does not have a '[Symbol.iterator]()' method that returns an iterator."), Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator: diag(2549, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns__2549", "Type '{0}' is not an array type or a string type or does not have a '[Symbol.iterator]()' method that returns an iterator."), - Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2_or_later: diag(2550, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_c_2550", "Property '{0}' does not exist on type '{1}'. Do you need to change your target library? Try changing the `lib` compiler option to '{2}' or later."), + Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2_or_later: diag(2550, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_c_2550", "Property '{0}' does not exist on type '{1}'. Do you need to change your target library? Try changing the 'lib' compiler option to '{2}' or later."), Property_0_does_not_exist_on_type_1_Did_you_mean_2: diag(2551, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Did_you_mean_2_2551", "Property '{0}' does not exist on type '{1}'. Did you mean '{2}'?"), Cannot_find_name_0_Did_you_mean_1: diag(2552, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Did_you_mean_1_2552", "Cannot find name '{0}'. Did you mean '{1}'?"), Computed_values_are_not_permitted_in_an_enum_with_string_valued_members: diag(2553, ts.DiagnosticCategory.Error, "Computed_values_are_not_permitted_in_an_enum_with_string_valued_members_2553", "Computed values are not permitted in an enum with string valued members."), Expected_0_arguments_but_got_1: diag(2554, ts.DiagnosticCategory.Error, "Expected_0_arguments_but_got_1_2554", "Expected {0} arguments, but got {1}."), Expected_at_least_0_arguments_but_got_1: diag(2555, ts.DiagnosticCategory.Error, "Expected_at_least_0_arguments_but_got_1_2555", "Expected at least {0} arguments, but got {1}."), - Expected_0_arguments_but_got_1_or_more: diag(2556, ts.DiagnosticCategory.Error, "Expected_0_arguments_but_got_1_or_more_2556", "Expected {0} arguments, but got {1} or more."), - Expected_at_least_0_arguments_but_got_1_or_more: diag(2557, ts.DiagnosticCategory.Error, "Expected_at_least_0_arguments_but_got_1_or_more_2557", "Expected at least {0} arguments, but got {1} or more."), + A_spread_argument_must_either_have_a_tuple_type_or_be_passed_to_a_rest_parameter: diag(2556, ts.DiagnosticCategory.Error, "A_spread_argument_must_either_have_a_tuple_type_or_be_passed_to_a_rest_parameter_2556", "A spread argument must either have a tuple type or be passed to a rest parameter."), Expected_0_type_arguments_but_got_1: diag(2558, ts.DiagnosticCategory.Error, "Expected_0_type_arguments_but_got_1_2558", "Expected {0} type arguments, but got {1}."), Type_0_has_no_properties_in_common_with_type_1: diag(2559, ts.DiagnosticCategory.Error, "Type_0_has_no_properties_in_common_with_type_1_2559", "Type '{0}' has no properties in common with type '{1}'."), Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it: diag(2560, ts.DiagnosticCategory.Error, "Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it_2560", "Value of type '{0}' has no properties in common with type '{1}'. Did you mean to call it?"), @@ -8385,17 +8605,17 @@ var ts; Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode: diag(2580, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashno_2580", "Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`."), Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery: diag(2581, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slash_2581", "Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i --save-dev @types/jquery`."), Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_types_Slashjest_or_npm_i_save_dev_types_Slashmocha: diag(2582, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_type_2582", "Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`."), - Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_1_or_later: diag(2583, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2583", "Cannot find name '{0}'. Do you need to change your target library? Try changing the `lib` compiler option to '{1}' or later."), - Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_include_dom: diag(2584, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2584", "Cannot find name '{0}'. Do you need to change your target library? Try changing the `lib` compiler option to include 'dom'."), - _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: diag(2585, ts.DiagnosticCategory.Error, "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_2585", "'{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."), + Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_1_or_later: diag(2583, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2583", "Cannot find name '{0}'. Do you need to change your target library? Try changing the 'lib' compiler option to '{1}' or later."), + Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_include_dom: diag(2584, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2584", "Cannot find name '{0}'. Do you need to change your target library? Try changing the 'lib' compiler option to include 'dom'."), + _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: diag(2585, ts.DiagnosticCategory.Error, "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_2585", "'{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."), Enum_type_0_circularly_references_itself: diag(2586, ts.DiagnosticCategory.Error, "Enum_type_0_circularly_references_itself_2586", "Enum type '{0}' circularly references itself."), JSDoc_type_0_circularly_references_itself: diag(2587, ts.DiagnosticCategory.Error, "JSDoc_type_0_circularly_references_itself_2587", "JSDoc type '{0}' circularly references itself."), Cannot_assign_to_0_because_it_is_a_constant: diag(2588, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_a_constant_2588", "Cannot assign to '{0}' because it is a constant."), Type_instantiation_is_excessively_deep_and_possibly_infinite: diag(2589, ts.DiagnosticCategory.Error, "Type_instantiation_is_excessively_deep_and_possibly_infinite_2589", "Type instantiation is excessively deep and possibly infinite."), Expression_produces_a_union_type_that_is_too_complex_to_represent: diag(2590, ts.DiagnosticCategory.Error, "Expression_produces_a_union_type_that_is_too_complex_to_represent_2590", "Expression produces a union type that is too complex to represent."), - Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode_and_then_add_node_to_the_types_field_in_your_tsconfig: diag(2591, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashno_2591", "Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node` and then add `node` to the types field in your tsconfig."), - Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery_and_then_add_jquery_to_the_types_field_in_your_tsconfig: diag(2592, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slash_2592", "Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i --save-dev @types/jquery` and then add `jquery` to the types field in your tsconfig."), - Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_types_Slashjest_or_npm_i_save_dev_types_Slashmocha_and_then_add_jest_or_mocha_to_the_types_field_in_your_tsconfig: diag(2593, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_type_2593", "Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode_and_then_add_node_to_the_types_field_in_your_tsconfig: diag(2591, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashno_2591", "Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node` and then add 'node' to the types field in your tsconfig."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery_and_then_add_jquery_to_the_types_field_in_your_tsconfig: diag(2592, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slash_2592", "Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i --save-dev @types/jquery` and then add 'jquery' to the types field in your tsconfig."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_types_Slashjest_or_npm_i_save_dev_types_Slashmocha_and_then_add_jest_or_mocha_to_the_types_field_in_your_tsconfig: diag(2593, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_type_2593", "Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig."), This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag: diag(2594, ts.DiagnosticCategory.Error, "This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the__2594", "This module is declared with using 'export =', and can only be used with a default import when using the '{0}' flag."), _0_can_only_be_imported_by_using_a_default_import: diag(2595, ts.DiagnosticCategory.Error, "_0_can_only_be_imported_by_using_a_default_import_2595", "'{0}' can only be imported by using a default import."), _0_can_only_be_imported_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import: diag(2596, ts.DiagnosticCategory.Error, "_0_can_only_be_imported_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import_2596", "'{0}' can only be imported by turning on the 'esModuleInterop' flag and using a default import."), @@ -8428,6 +8648,12 @@ var ts; Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target: diag(2625, ts.DiagnosticCategory.Error, "Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target_2625", "Variadic element at position {0} in source does not match element at position {1} in target."), Type_at_position_0_in_source_is_not_compatible_with_type_at_position_1_in_target: diag(2626, ts.DiagnosticCategory.Error, "Type_at_position_0_in_source_is_not_compatible_with_type_at_position_1_in_target_2626", "Type at position {0} in source is not compatible with type at position {1} in target."), Type_at_positions_0_through_1_in_source_is_not_compatible_with_type_at_position_2_in_target: diag(2627, ts.DiagnosticCategory.Error, "Type_at_positions_0_through_1_in_source_is_not_compatible_with_type_at_position_2_in_target_2627", "Type at positions {0} through {1} in source is not compatible with type at position {2} in target."), + Cannot_assign_to_0_because_it_is_an_enum: diag(2628, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_an_enum_2628", "Cannot assign to '{0}' because it is an enum."), + Cannot_assign_to_0_because_it_is_a_class: diag(2629, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_a_class_2629", "Cannot assign to '{0}' because it is a class."), + Cannot_assign_to_0_because_it_is_a_function: diag(2630, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_a_function_2630", "Cannot assign to '{0}' because it is a function."), + Cannot_assign_to_0_because_it_is_a_namespace: diag(2631, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_a_namespace_2631", "Cannot assign to '{0}' because it is a namespace."), + Cannot_assign_to_0_because_it_is_an_import: diag(2632, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_an_import_2632", "Cannot assign to '{0}' because it is an import."), + JSX_property_access_expressions_cannot_include_JSX_namespace_names: diag(2633, ts.DiagnosticCategory.Error, "JSX_property_access_expressions_cannot_include_JSX_namespace_names_2633", "JSX property access expressions cannot include JSX namespace names"), Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: diag(2649, ts.DiagnosticCategory.Error, "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", "Cannot augment module '{0}' with value exports because it resolves to a non-module entity."), A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: diag(2651, ts.DiagnosticCategory.Error, "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums."), Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: diag(2652, ts.DiagnosticCategory.Error, "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead."), @@ -8474,7 +8700,7 @@ var ts; Namespace_0_has_no_exported_member_1: diag(2694, ts.DiagnosticCategory.Error, "Namespace_0_has_no_exported_member_1_2694", "Namespace '{0}' has no exported member '{1}'."), Left_side_of_comma_operator_is_unused_and_has_no_side_effects: diag(2695, ts.DiagnosticCategory.Error, "Left_side_of_comma_operator_is_unused_and_has_no_side_effects_2695", "Left side of comma operator is unused and has no side effects.", /*reportsUnnecessary*/ true), The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead: diag(2696, ts.DiagnosticCategory.Error, "The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead_2696", "The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?"), - An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: diag(2697, ts.DiagnosticCategory.Error, "An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_in_2697", "An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option."), + An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: diag(2697, ts.DiagnosticCategory.Error, "An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_in_2697", "An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your '--lib' option."), Spread_types_may_only_be_created_from_object_types: diag(2698, ts.DiagnosticCategory.Error, "Spread_types_may_only_be_created_from_object_types_2698", "Spread types may only be created from object types."), Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1: diag(2699, ts.DiagnosticCategory.Error, "Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1_2699", "Static property '{0}' conflicts with built-in property 'Function.{0}' of constructor function '{1}'."), Rest_types_may_only_be_created_from_object_types: diag(2700, ts.DiagnosticCategory.Error, "Rest_types_may_only_be_created_from_object_types_2700", "Rest types may only be created from object types."), @@ -8482,14 +8708,14 @@ var ts; _0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here: diag(2702, ts.DiagnosticCategory.Error, "_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here_2702", "'{0}' only refers to a type, but is being used as a namespace here."), The_operand_of_a_delete_operator_must_be_a_property_reference: diag(2703, ts.DiagnosticCategory.Error, "The_operand_of_a_delete_operator_must_be_a_property_reference_2703", "The operand of a 'delete' operator must be a property reference."), The_operand_of_a_delete_operator_cannot_be_a_read_only_property: diag(2704, ts.DiagnosticCategory.Error, "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704", "The operand of a 'delete' operator cannot be a read-only property."), - 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: diag(2705, ts.DiagnosticCategory.Error, "An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_de_2705", "An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option."), + 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: diag(2705, ts.DiagnosticCategory.Error, "An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_de_2705", "An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option."), Required_type_parameters_may_not_follow_optional_type_parameters: diag(2706, ts.DiagnosticCategory.Error, "Required_type_parameters_may_not_follow_optional_type_parameters_2706", "Required type parameters may not follow optional type parameters."), Generic_type_0_requires_between_1_and_2_type_arguments: diag(2707, ts.DiagnosticCategory.Error, "Generic_type_0_requires_between_1_and_2_type_arguments_2707", "Generic type '{0}' requires between {1} and {2} type arguments."), Cannot_use_namespace_0_as_a_value: diag(2708, ts.DiagnosticCategory.Error, "Cannot_use_namespace_0_as_a_value_2708", "Cannot use namespace '{0}' as a value."), Cannot_use_namespace_0_as_a_type: diag(2709, ts.DiagnosticCategory.Error, "Cannot_use_namespace_0_as_a_type_2709", "Cannot use namespace '{0}' as a type."), _0_are_specified_twice_The_attribute_named_0_will_be_overwritten: diag(2710, ts.DiagnosticCategory.Error, "_0_are_specified_twice_The_attribute_named_0_will_be_overwritten_2710", "'{0}' are specified twice. The attribute named '{0}' will be overwritten."), - A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: diag(2711, ts.DiagnosticCategory.Error, "A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES20_2711", "A dynamic import call returns a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option."), - A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option: diag(2712, ts.DiagnosticCategory.Error, "A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declarat_2712", "A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option."), + A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: diag(2711, ts.DiagnosticCategory.Error, "A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES20_2711", "A dynamic import call returns a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your '--lib' option."), + A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option: diag(2712, ts.DiagnosticCategory.Error, "A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declarat_2712", "A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option."), 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: diag(2713, ts.DiagnosticCategory.Error, "Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_p_2713", "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}\"]'?"), The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context: diag(2714, ts.DiagnosticCategory.Error, "The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context_2714", "The expression of an export assignment must be an identifier or qualified name in an ambient context."), Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor: diag(2715, ts.DiagnosticCategory.Error, "Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor_2715", "Abstract property '{0}' in class '{1}' cannot be accessed in the constructor."), @@ -8551,7 +8777,7 @@ var ts; The_last_overload_is_declared_here: diag(2771, ts.DiagnosticCategory.Error, "The_last_overload_is_declared_here_2771", "The last overload is declared here."), Overload_0_of_1_2_gave_the_following_error: diag(2772, ts.DiagnosticCategory.Error, "Overload_0_of_1_2_gave_the_following_error_2772", "Overload {0} of {1}, '{2}', gave the following error."), Did_you_forget_to_use_await: diag(2773, ts.DiagnosticCategory.Error, "Did_you_forget_to_use_await_2773", "Did you forget to use 'await'?"), - This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead: diag(2774, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it__2774", "This condition will always return true since the function is always defined. Did you mean to call it instead?"), + This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_instead: diag(2774, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_2774", "This condition will always return true since this function is always defined. Did you mean to call it instead?"), Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation: diag(2775, ts.DiagnosticCategory.Error, "Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation_2775", "Assertions require every name in the call target to be declared with an explicit type annotation."), Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name: diag(2776, ts.DiagnosticCategory.Error, "Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name_2776", "Assertions require the call target to be an identifier or qualified name."), The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access: diag(2777, ts.DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access_2777", "The operand of an increment or decrement operator may not be an optional property access."), @@ -8575,6 +8801,23 @@ var ts; The_intrinsic_keyword_can_only_be_used_to_declare_compiler_provided_intrinsic_types: diag(2795, ts.DiagnosticCategory.Error, "The_intrinsic_keyword_can_only_be_used_to_declare_compiler_provided_intrinsic_types_2795", "The 'intrinsic' keyword can only be used to declare compiler provided intrinsic types."), It_is_likely_that_you_are_missing_a_comma_to_separate_these_two_template_expressions_They_form_a_tagged_template_expression_which_cannot_be_invoked: diag(2796, ts.DiagnosticCategory.Error, "It_is_likely_that_you_are_missing_a_comma_to_separate_these_two_template_expressions_They_form_a_tag_2796", "It is likely that you are missing a comma to separate these two template expressions. They form a tagged template expression which cannot be invoked."), A_mixin_class_that_extends_from_a_type_variable_containing_an_abstract_construct_signature_must_also_be_declared_abstract: diag(2797, ts.DiagnosticCategory.Error, "A_mixin_class_that_extends_from_a_type_variable_containing_an_abstract_construct_signature_must_also_2797", "A mixin class that extends from a type variable containing an abstract construct signature must also be declared 'abstract'."), + The_declaration_was_marked_as_deprecated_here: diag(2798, ts.DiagnosticCategory.Error, "The_declaration_was_marked_as_deprecated_here_2798", "The declaration was marked as deprecated here."), + Type_produces_a_tuple_type_that_is_too_large_to_represent: diag(2799, ts.DiagnosticCategory.Error, "Type_produces_a_tuple_type_that_is_too_large_to_represent_2799", "Type produces a tuple type that is too large to represent."), + Expression_produces_a_tuple_type_that_is_too_large_to_represent: diag(2800, ts.DiagnosticCategory.Error, "Expression_produces_a_tuple_type_that_is_too_large_to_represent_2800", "Expression produces a tuple type that is too large to represent."), + This_condition_will_always_return_true_since_this_0_is_always_defined: diag(2801, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_this_0_is_always_defined_2801", "This condition will always return true since this '{0}' is always defined."), + Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher: diag(2802, ts.DiagnosticCategory.Error, "Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es201_2802", "Type '{0}' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher."), + Cannot_assign_to_private_method_0_Private_methods_are_not_writable: diag(2803, ts.DiagnosticCategory.Error, "Cannot_assign_to_private_method_0_Private_methods_are_not_writable_2803", "Cannot assign to private method '{0}'. Private methods are not writable."), + Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name: diag(2804, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name_2804", "Duplicate identifier '{0}'. Static and instance elements cannot share the same private name."), + Static_fields_with_private_names_can_t_have_initializers_when_the_useDefineForClassFields_flag_is_not_specified_with_a_target_of_esnext_Consider_adding_the_useDefineForClassFields_flag: diag(2805, ts.DiagnosticCategory.Error, "Static_fields_with_private_names_can_t_have_initializers_when_the_useDefineForClassFields_flag_is_no_2805", "Static fields with private names can't have initializers when the '--useDefineForClassFields' flag is not specified with a '--target' of 'esnext'. Consider adding the '--useDefineForClassFields' flag."), + Private_accessor_was_defined_without_a_getter: diag(2806, ts.DiagnosticCategory.Error, "Private_accessor_was_defined_without_a_getter_2806", "Private accessor was defined without a getter."), + 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: diag(2807, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807", "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}'."), + A_get_accessor_must_be_at_least_as_accessible_as_the_setter: diag(2808, ts.DiagnosticCategory.Error, "A_get_accessor_must_be_at_least_as_accessible_as_the_setter_2808", "A get accessor must be at least as accessible as the setter"), + 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: diag(2809, ts.DiagnosticCategory.Error, "Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_d_2809", "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."), + Property_0_may_not_be_used_in_a_static_property_s_initializer_in_the_same_class_when_target_is_esnext_and_useDefineForClassFields_is_false: diag(2810, ts.DiagnosticCategory.Error, "Property_0_may_not_be_used_in_a_static_property_s_initializer_in_the_same_class_when_target_is_esnex_2810", "Property '{0}' may not be used in a static property's initializer in the same class when 'target' is 'esnext' and 'useDefineForClassFields' is 'false'."), + Initializer_for_property_0: diag(2811, ts.DiagnosticCategory.Error, "Initializer_for_property_0_2811", "Initializer for property '{0}'"), + Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom: diag(2812, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom_2812", "Property '{0}' does not exist on type '{1}'. Try changing the 'lib' compiler option to include 'dom'."), + Class_declaration_cannot_implement_overload_list_for_0: diag(2813, ts.DiagnosticCategory.Error, "Class_declaration_cannot_implement_overload_list_for_0_2813", "Class declaration cannot implement overload list for '{0}'."), + Function_with_bodies_can_only_merge_with_classes_that_are_ambient: diag(2814, ts.DiagnosticCategory.Error, "Function_with_bodies_can_only_merge_with_classes_that_are_ambient_2814", "Function with bodies can only merge with classes that are ambient."), 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}'."), @@ -8647,6 +8890,7 @@ var ts; Exported_type_alias_0_has_or_is_using_private_name_1: diag(4081, ts.DiagnosticCategory.Error, "Exported_type_alias_0_has_or_is_using_private_name_1_4081", "Exported type alias '{0}' has or is using private name '{1}'."), Default_export_of_the_module_has_or_is_using_private_name_0: diag(4082, ts.DiagnosticCategory.Error, "Default_export_of_the_module_has_or_is_using_private_name_0_4082", "Default export of the module has or is using private name '{0}'."), Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1: diag(4083, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1_4083", "Type parameter '{0}' of exported type alias has or is using private name '{1}'."), + Exported_type_alias_0_has_or_is_using_private_name_1_from_module_2: diag(4084, ts.DiagnosticCategory.Error, "Exported_type_alias_0_has_or_is_using_private_name_1_from_module_2_4084", "Exported type alias '{0}' has or is using private name '{1}' from module {2}."), Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict: diag(4090, ts.DiagnosticCategory.Error, "Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_librar_4090", "Conflicting definitions for '{0}' found at '{1}' and '{2}'. Consider installing a specific version of this library to resolve the conflict."), Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: diag(4091, ts.DiagnosticCategory.Error, "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4091", "Parameter '{0}' of index signature from exported interface has or is using name '{1}' from private module '{2}'."), Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1: diag(4092, ts.DiagnosticCategory.Error, "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1_4092", "Parameter '{0}' of index signature from exported interface has or is using private name '{1}'."), @@ -8668,6 +8912,12 @@ var ts; Type_arguments_for_0_circularly_reference_themselves: diag(4109, ts.DiagnosticCategory.Error, "Type_arguments_for_0_circularly_reference_themselves_4109", "Type arguments for '{0}' circularly reference themselves."), Tuple_type_arguments_circularly_reference_themselves: diag(4110, ts.DiagnosticCategory.Error, "Tuple_type_arguments_circularly_reference_themselves_4110", "Tuple type arguments circularly reference themselves."), Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0: diag(4111, ts.DiagnosticCategory.Error, "Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0_4111", "Property '{0}' comes from an index signature, so it must be accessed with ['{0}']."), + This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class: diag(4112, ts.DiagnosticCategory.Error, "This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another__4112", "This member cannot have an 'override' modifier because its containing class '{0}' does not extend another class."), + This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0: diag(4113, ts.DiagnosticCategory.Error, "This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0_4113", "This member cannot have an 'override' modifier because it is not declared in the base class '{0}'."), + This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0: diag(4114, ts.DiagnosticCategory.Error, "This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0_4114", "This member must have an 'override' modifier because it overrides a member in the base class '{0}'."), + This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0: diag(4115, ts.DiagnosticCategory.Error, "This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0_4115", "This parameter property must have an 'override' modifier because it overrides a member in base class '{0}'."), + This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0: diag(4116, ts.DiagnosticCategory.Error, "This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared__4116", "This member must have an 'override' modifier because it overrides an abstract method that is declared in the base class '{0}'."), + This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1: diag(4117, ts.DiagnosticCategory.Error, "This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0_Did_you__4117", "This member cannot have an 'override' modifier because it is not declared in the base class '{0}'. Did you mean '{1}'?"), The_current_host_does_not_support_the_0_option: diag(5001, ts.DiagnosticCategory.Error, "The_current_host_does_not_support_the_0_option_5001", "The current host does not support the '{0}' option."), Cannot_find_the_common_subdirectory_path_for_the_input_files: diag(5009, ts.DiagnosticCategory.Error, "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", "Cannot find the common subdirectory path for the input files."), File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5010, ts.DiagnosticCategory.Error, "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", "File specification cannot end in a recursive directory wildcard ('**'): '{0}'."), @@ -8702,7 +8952,7 @@ var ts; Option_resolveJsonModule_can_only_be_specified_when_module_code_generation_is_commonjs_amd_es2015_or_esNext: diag(5071, ts.DiagnosticCategory.Error, "Option_resolveJsonModule_can_only_be_specified_when_module_code_generation_is_commonjs_amd_es2015_or_5071", "Option '--resolveJsonModule' can only be specified when module code generation is 'commonjs', 'amd', 'es2015' or 'esNext'."), Unknown_build_option_0: diag(5072, ts.DiagnosticCategory.Error, "Unknown_build_option_0_5072", "Unknown build option '{0}'."), Build_option_0_requires_a_value_of_type_1: diag(5073, ts.DiagnosticCategory.Error, "Build_option_0_requires_a_value_of_type_1_5073", "Build option '{0}' requires a value of type {1}."), - Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified: diag(5074, ts.DiagnosticCategory.Error, "Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBui_5074", "Option '--incremental' can only be specified using tsconfig, emitting to single file or when option `--tsBuildInfoFile` is specified."), + Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified: diag(5074, ts.DiagnosticCategory.Error, "Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBui_5074", "Option '--incremental' can only be specified using tsconfig, emitting to single file or when option '--tsBuildInfoFile' is specified."), _0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2: diag(5075, ts.DiagnosticCategory.Error, "_0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_5075", "'{0}' is assignable to the constraint of type '{1}', but '{1}' could be instantiated with a different subtype of constraint '{2}'."), _0_and_1_operations_cannot_be_mixed_without_parentheses: diag(5076, ts.DiagnosticCategory.Error, "_0_and_1_operations_cannot_be_mixed_without_parentheses_5076", "'{0}' and '{1}' operations cannot be mixed without parentheses."), Unknown_build_option_0_Did_you_mean_1: diag(5077, ts.DiagnosticCategory.Error, "Unknown_build_option_0_Did_you_mean_1_5077", "Unknown build option '{0}'. Did you mean '{1}'?"), @@ -8715,10 +8965,14 @@ var ts; Tuple_members_must_all_have_names_or_all_not_have_names: diag(5084, ts.DiagnosticCategory.Error, "Tuple_members_must_all_have_names_or_all_not_have_names_5084", "Tuple members must all have names or all not have names."), A_tuple_member_cannot_be_both_optional_and_rest: diag(5085, ts.DiagnosticCategory.Error, "A_tuple_member_cannot_be_both_optional_and_rest_5085", "A tuple member cannot be both optional and rest."), A_labeled_tuple_element_is_declared_as_optional_with_a_question_mark_after_the_name_and_before_the_colon_rather_than_after_the_type: diag(5086, ts.DiagnosticCategory.Error, "A_labeled_tuple_element_is_declared_as_optional_with_a_question_mark_after_the_name_and_before_the_c_5086", "A labeled tuple element is declared as optional with a question mark after the name and before the colon, rather than after the type."), - A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type: diag(5087, ts.DiagnosticCategory.Error, "A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type_5087", "A labeled tuple element is declared as rest with a `...` before the name, rather than before the type."), + A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type: diag(5087, ts.DiagnosticCategory.Error, "A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type_5087", "A labeled tuple element is declared as rest with a '...' before the name, rather than before the type."), The_inferred_type_of_0_references_a_type_with_a_cyclic_structure_which_cannot_be_trivially_serialized_A_type_annotation_is_necessary: diag(5088, ts.DiagnosticCategory.Error, "The_inferred_type_of_0_references_a_type_with_a_cyclic_structure_which_cannot_be_trivially_serialize_5088", "The inferred type of '{0}' references a type with a cyclic structure which cannot be trivially serialized. A type annotation is necessary."), Option_0_cannot_be_specified_when_option_jsx_is_1: diag(5089, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_when_option_jsx_is_1_5089", "Option '{0}' cannot be specified when option 'jsx' is '{1}'."), Non_relative_paths_are_not_allowed_when_baseUrl_is_not_set_Did_you_forget_a_leading_Slash: diag(5090, ts.DiagnosticCategory.Error, "Non_relative_paths_are_not_allowed_when_baseUrl_is_not_set_Did_you_forget_a_leading_Slash_5090", "Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?"), + Option_preserveConstEnums_cannot_be_disabled_when_isolatedModules_is_enabled: diag(5091, ts.DiagnosticCategory.Error, "Option_preserveConstEnums_cannot_be_disabled_when_isolatedModules_is_enabled_5091", "Option 'preserveConstEnums' cannot be disabled when 'isolatedModules' is enabled."), + The_root_value_of_a_0_file_must_be_an_object: diag(5092, ts.DiagnosticCategory.Error, "The_root_value_of_a_0_file_must_be_an_object_5092", "The root value of a '{0}' file must be an object."), + Compiler_option_0_may_only_be_used_with_build: diag(5093, ts.DiagnosticCategory.Error, "Compiler_option_0_may_only_be_used_with_build_5093", "Compiler option '--{0}' may only be used with '--build'."), + Compiler_option_0_may_not_be_used_with_build: diag(5094, ts.DiagnosticCategory.Error, "Compiler_option_0_may_not_be_used_with_build_5094", "Compiler option '--{0}' may not be used with '--build'."), Generates_a_sourcemap_for_each_corresponding_d_ts_file: diag(6000, ts.DiagnosticCategory.Message, "Generates_a_sourcemap_for_each_corresponding_d_ts_file_6000", "Generates a sourcemap for each corresponding '.d.ts' file."), Concatenate_and_emit_output_to_single_file: diag(6001, ts.DiagnosticCategory.Message, "Concatenate_and_emit_output_to_single_file_6001", "Concatenate and emit output to single file."), Generates_corresponding_d_ts_file: diag(6002, ts.DiagnosticCategory.Message, "Generates_corresponding_d_ts_file_6002", "Generates corresponding '.d.ts' file."), @@ -8734,7 +8988,7 @@ var ts; Skip_type_checking_of_declaration_files: diag(6012, ts.DiagnosticCategory.Message, "Skip_type_checking_of_declaration_files_6012", "Skip type checking of declaration files."), Do_not_resolve_the_real_path_of_symlinks: diag(6013, ts.DiagnosticCategory.Message, "Do_not_resolve_the_real_path_of_symlinks_6013", "Do not resolve the real path of symlinks."), Only_emit_d_ts_declaration_files: diag(6014, ts.DiagnosticCategory.Message, "Only_emit_d_ts_declaration_files_6014", "Only emit '.d.ts' declaration files."), - Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_or_ESNEXT: diag(6015, ts.DiagnosticCategory.Message, "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_or_6015", "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'."), + Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_ES2021_or_ESNEXT: diag(6015, ts.DiagnosticCategory.Message, "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_ES_6015", "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'."), Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_es2020_or_ESNext: diag(6016, ts.DiagnosticCategory.Message, "Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_es2020_or_ESNext_6016", "Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'."), Print_this_message: diag(6017, ts.DiagnosticCategory.Message, "Print_this_message_6017", "Print this message."), Print_the_compiler_s_version: diag(6019, ts.DiagnosticCategory.Message, "Print_the_compiler_s_version_6019", "Print the compiler's version."), @@ -8877,19 +9131,12 @@ var ts; Show_all_compiler_options: diag(6169, ts.DiagnosticCategory.Message, "Show_all_compiler_options_6169", "Show all compiler options."), Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file: diag(6170, ts.DiagnosticCategory.Message, "Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file_6170", "[Deprecated] Use '--outFile' instead. Concatenate and emit output to single file"), Command_line_Options: diag(6171, ts.DiagnosticCategory.Message, "Command_line_Options_6171", "Command-line Options"), - Basic_Options: diag(6172, ts.DiagnosticCategory.Message, "Basic_Options_6172", "Basic Options"), - Strict_Type_Checking_Options: diag(6173, ts.DiagnosticCategory.Message, "Strict_Type_Checking_Options_6173", "Strict Type-Checking Options"), - Module_Resolution_Options: diag(6174, ts.DiagnosticCategory.Message, "Module_Resolution_Options_6174", "Module Resolution Options"), - Source_Map_Options: diag(6175, ts.DiagnosticCategory.Message, "Source_Map_Options_6175", "Source Map Options"), - Additional_Checks: diag(6176, ts.DiagnosticCategory.Message, "Additional_Checks_6176", "Additional Checks"), - Experimental_Options: diag(6177, ts.DiagnosticCategory.Message, "Experimental_Options_6177", "Experimental Options"), - Advanced_Options: diag(6178, ts.DiagnosticCategory.Message, "Advanced_Options_6178", "Advanced Options"), Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3: diag(6179, ts.DiagnosticCategory.Message, "Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3_6179", "Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'."), Enable_all_strict_type_checking_options: diag(6180, ts.DiagnosticCategory.Message, "Enable_all_strict_type_checking_options_6180", "Enable all strict type-checking options."), List_of_language_service_plugins: diag(6181, ts.DiagnosticCategory.Message, "List_of_language_service_plugins_6181", "List of language service plugins."), Scoped_package_detected_looking_in_0: diag(6182, ts.DiagnosticCategory.Message, "Scoped_package_detected_looking_in_0_6182", "Scoped package detected, looking in '{0}'"), - Reusing_resolution_of_module_0_to_file_1_from_old_program: diag(6183, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_to_file_1_from_old_program_6183", "Reusing resolution of module '{0}' to file '{1}' from old program."), - Reusing_module_resolutions_originating_in_0_since_resolutions_are_unchanged_from_old_program: diag(6184, ts.DiagnosticCategory.Message, "Reusing_module_resolutions_originating_in_0_since_resolutions_are_unchanged_from_old_program_6184", "Reusing module resolutions originating in '{0}' since resolutions are unchanged from old program."), + Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2: diag(6183, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_6183", "Reusing resolution of module '{0}' from '{1}' of old program, it was successfully resolved to '{2}'."), + Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3: diag(6184, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package__6184", "Reusing resolution of module '{0}' from '{1}' of old program, it was successfully resolved to '{2}' with Package ID '{3}'."), Disable_strict_checking_of_generic_signatures_in_function_types: diag(6185, ts.DiagnosticCategory.Message, "Disable_strict_checking_of_generic_signatures_in_function_types_6185", "Disable strict checking of generic signatures in function types."), Enable_strict_checking_of_function_types: diag(6186, ts.DiagnosticCategory.Message, "Enable_strict_checking_of_function_types_6186", "Enable strict checking of function types."), Enable_strict_checking_of_property_initialization_in_classes: diag(6187, ts.DiagnosticCategory.Message, "Enable_strict_checking_of_property_initialization_in_classes_6187", "Enable strict checking of property initialization in classes."), @@ -8929,9 +9176,9 @@ var ts; Emit_class_fields_with_Define_instead_of_Set: diag(6222, ts.DiagnosticCategory.Message, "Emit_class_fields_with_Define_instead_of_Set_6222", "Emit class fields with Define instead of Set."), Generates_a_CPU_profile: diag(6223, ts.DiagnosticCategory.Message, "Generates_a_CPU_profile_6223", "Generates a CPU profile."), Disable_solution_searching_for_this_project: diag(6224, ts.DiagnosticCategory.Message, "Disable_solution_searching_for_this_project_6224", "Disable solution searching for this project."), - Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_DynamicPriorityPolling_UseFsEvents_UseFsEventsOnParentDirectory: diag(6225, ts.DiagnosticCategory.Message, "Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_Dynami_6225", "Specify strategy for watching file: 'FixedPollingInterval' (default), 'PriorityPollingInterval', 'DynamicPriorityPolling', 'UseFsEvents', 'UseFsEventsOnParentDirectory'."), - Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling: diag(6226, ts.DiagnosticCategory.Message, "Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively__6226", "Specify strategy for watching directory on platforms that don't support recursive watching natively: 'UseFsEvents' (default), 'FixedPollingInterval', 'DynamicPriorityPolling'."), - Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority: diag(6227, ts.DiagnosticCategory.Message, "Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_6227", "Specify strategy for creating a polling watch when it fails to create using file system events: 'FixedInterval' (default), 'PriorityInterval', 'DynamicPriority'."), + Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_DynamicPriorityPolling_FixedChunkSizePolling_UseFsEvents_UseFsEventsOnParentDirectory: diag(6225, ts.DiagnosticCategory.Message, "Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_Dynami_6225", "Specify strategy for watching file: 'FixedPollingInterval' (default), 'PriorityPollingInterval', 'DynamicPriorityPolling', 'FixedChunkSizePolling', 'UseFsEvents', 'UseFsEventsOnParentDirectory'."), + Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling_FixedChunkSizePolling: diag(6226, ts.DiagnosticCategory.Message, "Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively__6226", "Specify strategy for watching directory on platforms that don't support recursive watching natively: 'UseFsEvents' (default), 'FixedPollingInterval', 'DynamicPriorityPolling', 'FixedChunkSizePolling'."), + Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority_FixedChunkSize: diag(6227, ts.DiagnosticCategory.Message, "Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_6227", "Specify strategy for creating a polling watch when it fails to create using file system events: 'FixedInterval' (default), 'PriorityInterval', 'DynamicPriority', 'FixedChunkSize'."), Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively: diag(6228, ts.DiagnosticCategory.Message, "Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_supp_6228", "Synchronously call callbacks and update the state of directory watchers on platforms that don't support recursive watching natively."), Tag_0_expects_at_least_1_arguments_but_the_JSX_factory_2_provides_at_most_3: diag(6229, ts.DiagnosticCategory.Error, "Tag_0_expects_at_least_1_arguments_but_the_JSX_factory_2_provides_at_most_3_6229", "Tag '{0}' expects at least '{1}' arguments, but the JSX factory '{2}' provides at most '{3}'."), Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line: diag(6230, ts.DiagnosticCategory.Error, "Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line_6230", "Option '{0}' can only be specified in 'tsconfig.json' file or set to 'false' or 'null' on command line."), @@ -8942,7 +9189,26 @@ var ts; Disable_loading_referenced_projects: diag(6235, ts.DiagnosticCategory.Message, "Disable_loading_referenced_projects_6235", "Disable loading referenced projects."), Arguments_for_the_rest_parameter_0_were_not_provided: diag(6236, ts.DiagnosticCategory.Error, "Arguments_for_the_rest_parameter_0_were_not_provided_6236", "Arguments for the rest parameter '{0}' were not provided."), Generates_an_event_trace_and_a_list_of_types: diag(6237, ts.DiagnosticCategory.Message, "Generates_an_event_trace_and_a_list_of_types_6237", "Generates an event trace and a list of types."), - Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react: diag(6238, ts.DiagnosticCategory.Error, "Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react_6238", "Specify the module specifier to be used to import the `jsx` and `jsxs` factory functions from. eg, react"), + Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react: diag(6238, ts.DiagnosticCategory.Error, "Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react_6238", "Specify the module specifier to be used to import the 'jsx' and 'jsxs' factory functions from. eg, react"), + File_0_exists_according_to_earlier_cached_lookups: diag(6239, ts.DiagnosticCategory.Message, "File_0_exists_according_to_earlier_cached_lookups_6239", "File '{0}' exists according to earlier cached lookups."), + File_0_does_not_exist_according_to_earlier_cached_lookups: diag(6240, ts.DiagnosticCategory.Message, "File_0_does_not_exist_according_to_earlier_cached_lookups_6240", "File '{0}' does not exist according to earlier cached lookups."), + Resolution_for_type_reference_directive_0_was_found_in_cache_from_location_1: diag(6241, ts.DiagnosticCategory.Message, "Resolution_for_type_reference_directive_0_was_found_in_cache_from_location_1_6241", "Resolution for type reference directive '{0}' was found in cache from location '{1}'."), + Resolving_type_reference_directive_0_containing_file_1: diag(6242, ts.DiagnosticCategory.Message, "Resolving_type_reference_directive_0_containing_file_1_6242", "======== Resolving type reference directive '{0}', containing file '{1}'. ========"), + Enable_strict_checking_of_optional_properties: diag(6243, ts.DiagnosticCategory.Message, "Enable_strict_checking_of_optional_properties_6243", "Enable strict checking of optional properties."), + Modules: diag(6244, ts.DiagnosticCategory.Message, "Modules_6244", "Modules"), + File_Management: diag(6245, ts.DiagnosticCategory.Message, "File_Management_6245", "File Management"), + Emit: diag(6246, ts.DiagnosticCategory.Message, "Emit_6246", "Emit"), + JavaScript_Support: diag(6247, ts.DiagnosticCategory.Message, "JavaScript_Support_6247", "JavaScript Support"), + Type_Checking: diag(6248, ts.DiagnosticCategory.Message, "Type_Checking_6248", "Type Checking"), + Editor_Support: diag(6249, ts.DiagnosticCategory.Message, "Editor_Support_6249", "Editor Support"), + Watch_and_Build_Modes: diag(6250, ts.DiagnosticCategory.Message, "Watch_and_Build_Modes_6250", "Watch and Build Modes"), + Compiler_Diagnostics: diag(6251, ts.DiagnosticCategory.Message, "Compiler_Diagnostics_6251", "Compiler Diagnostics"), + Interop_Constraints: diag(6252, ts.DiagnosticCategory.Message, "Interop_Constraints_6252", "Interop Constraints"), + Backwards_Compatibility: diag(6253, ts.DiagnosticCategory.Message, "Backwards_Compatibility_6253", "Backwards Compatibility"), + Language_and_Environment: diag(6254, ts.DiagnosticCategory.Message, "Language_and_Environment_6254", "Language and Environment"), + Projects: diag(6255, ts.DiagnosticCategory.Message, "Projects_6255", "Projects"), + Output_Formatting: diag(6256, ts.DiagnosticCategory.Message, "Output_Formatting_6256", "Output Formatting"), + Completeness: diag(6257, ts.DiagnosticCategory.Message, "Completeness_6257", "Completeness"), Projects_to_reference: diag(6300, ts.DiagnosticCategory.Message, "Projects_to_reference_6300", "Projects to reference"), Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"), Composite_projects_may_not_disable_declaration_emit: diag(6304, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_declaration_emit_6304", "Composite projects may not disable declaration emit."), @@ -8987,16 +9253,31 @@ var ts; Skipping_build_of_project_0_because_its_dependency_1_was_not_built: diag(6382, ts.DiagnosticCategory.Message, "Skipping_build_of_project_0_because_its_dependency_1_was_not_built_6382", "Skipping build of project '{0}' because its dependency '{1}' was not built"), Project_0_can_t_be_built_because_its_dependency_1_was_not_built: diag(6383, ts.DiagnosticCategory.Message, "Project_0_can_t_be_built_because_its_dependency_1_was_not_built_6383", "Project '{0}' can't be built because its dependency '{1}' was not built"), Have_recompiles_in_incremental_and_watch_assume_that_changes_within_a_file_will_only_affect_files_directly_depending_on_it: diag(6384, ts.DiagnosticCategory.Message, "Have_recompiles_in_incremental_and_watch_assume_that_changes_within_a_file_will_only_affect_files_di_6384", "Have recompiles in '--incremental' and '--watch' assume that changes within a file will only affect files directly depending on it."), - _0_is_deprecated: diag(6385, ts.DiagnosticCategory.Suggestion, "_0_is_deprecated_6385", "'{0}' is deprecated", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ undefined, /*reportsDeprecated*/ true), + _0_is_deprecated: diag(6385, ts.DiagnosticCategory.Suggestion, "_0_is_deprecated_6385", "'{0}' is deprecated.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ undefined, /*reportsDeprecated*/ true), Performance_timings_for_diagnostics_or_extendedDiagnostics_are_not_available_in_this_session_A_native_implementation_of_the_Web_Performance_API_could_not_be_found: diag(6386, ts.DiagnosticCategory.Message, "Performance_timings_for_diagnostics_or_extendedDiagnostics_are_not_available_in_this_session_A_nativ_6386", "Performance timings for '--diagnostics' or '--extendedDiagnostics' are not available in this session. A native implementation of the Web Performance API could not be found."), + The_signature_0_of_1_is_deprecated: diag(6387, ts.DiagnosticCategory.Suggestion, "The_signature_0_of_1_is_deprecated_6387", "The signature '{0}' of '{1}' is deprecated.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ undefined, /*reportsDeprecated*/ true), + Project_0_is_being_forcibly_rebuilt: diag(6388, ts.DiagnosticCategory.Message, "Project_0_is_being_forcibly_rebuilt_6388", "Project '{0}' is being forcibly rebuilt"), + Reusing_resolution_of_module_0_from_1_of_old_program_it_was_not_resolved: diag(6389, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_of_old_program_it_was_not_resolved_6389", "Reusing resolution of module '{0}' from '{1}' of old program, it was not resolved."), + Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2: diag(6390, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved__6390", "Reusing resolution of type reference directive '{0}' from '{1}' of old program, it was successfully resolved to '{2}'."), + Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3: diag(6391, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved__6391", "Reusing resolution of type reference directive '{0}' from '{1}' of old program, it was successfully resolved to '{2}' with Package ID '{3}'."), + Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_not_resolved: diag(6392, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_not_resolved_6392", "Reusing resolution of type reference directive '{0}' from '{1}' of old program, it was not resolved."), + Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3: diag(6393, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_6393", "Reusing resolution of module '{0}' from '{1}' found in cache from location '{2}', it was successfully resolved to '{3}'."), + Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4: diag(6394, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_6394", "Reusing resolution of module '{0}' from '{1}' found in cache from location '{2}', it was successfully resolved to '{3}' with Package ID '{4}'."), + Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_not_resolved: diag(6395, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_not_resolved_6395", "Reusing resolution of module '{0}' from '{1}' found in cache from location '{2}', it was not resolved."), + Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3: diag(6396, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_succes_6396", "Reusing resolution of type reference directive '{0}' from '{1}' found in cache from location '{2}', it was successfully resolved to '{3}'."), + Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4: diag(6397, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_succes_6397", "Reusing resolution of type reference directive '{0}' from '{1}' found in cache from location '{2}', it was successfully resolved to '{3}' with Package ID '{4}'."), + Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_not_resolved: diag(6398, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_not_re_6398", "Reusing resolution of type reference directive '{0}' from '{1}' found in cache from location '{2}', it was not resolved."), The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"), The_expected_type_comes_from_this_index_signature: diag(6501, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."), The_expected_type_comes_from_the_return_type_of_this_signature: diag(6502, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_the_return_type_of_this_signature_6502", "The expected type comes from the return type of this signature."), Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing: diag(6503, ts.DiagnosticCategory.Message, "Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing_6503", "Print names of files that are part of the compilation and then stop processing."), File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option: diag(6504, ts.DiagnosticCategory.Error, "File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option_6504", "File '{0}' is a JavaScript file. Did you mean to enable the 'allowJs' option?"), Print_names_of_files_and_the_reason_they_are_part_of_the_compilation: diag(6505, ts.DiagnosticCategory.Message, "Print_names_of_files_and_the_reason_they_are_part_of_the_compilation_6505", "Print names of files and the reason they are part of the compilation."), - Require_undeclared_properties_from_index_signatures_to_use_element_accesses: diag(6803, ts.DiagnosticCategory.Error, "Require_undeclared_properties_from_index_signatures_to_use_element_accesses_6803", "Require undeclared properties from index signatures to use element accesses."), + Consider_adding_a_declare_modifier_to_this_class: diag(6506, ts.DiagnosticCategory.Message, "Consider_adding_a_declare_modifier_to_this_class_6506", "Consider adding a 'declare' modifier to this class."), Include_undefined_in_index_signature_results: diag(6800, ts.DiagnosticCategory.Message, "Include_undefined_in_index_signature_results_6800", "Include 'undefined' in index signature results"), + Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier: diag(6801, ts.DiagnosticCategory.Message, "Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier_6801", "Ensure overriding members in derived classes are marked with an 'override' modifier."), + Require_undeclared_properties_from_index_signatures_to_use_element_accesses: diag(6802, ts.DiagnosticCategory.Message, "Require_undeclared_properties_from_index_signatures_to_use_element_accesses_6802", "Require undeclared properties from index signatures to use element accesses."), + Type_catch_clause_variables_as_unknown_instead_of_any: diag(6803, ts.DiagnosticCategory.Message, "Type_catch_clause_variables_as_unknown_instead_of_any_6803", "Type catch clause variables as 'unknown' instead of 'any'."), Variable_0_implicitly_has_an_1_type: diag(7005, ts.DiagnosticCategory.Error, "Variable_0_implicitly_has_an_1_type_7005", "Variable '{0}' implicitly has an '{1}' type."), Parameter_0_implicitly_has_an_1_type: diag(7006, ts.DiagnosticCategory.Error, "Parameter_0_implicitly_has_an_1_type_7006", "Parameter '{0}' implicitly has an '{1}' type."), Member_0_implicitly_has_an_1_type: diag(7008, ts.DiagnosticCategory.Error, "Member_0_implicitly_has_an_1_type_7008", "Member '{0}' implicitly has an '{1}' type."), @@ -9029,7 +9310,7 @@ var ts; Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for_all_imports_Implies_allowSyntheticDefaultImports: diag(7037, ts.DiagnosticCategory.Message, "Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for__7037", "Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'."), Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead: diag(7038, ts.DiagnosticCategory.Message, "Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cau_7038", "Type originates at this import. A namespace-style import cannot be called or constructed, and will cause a failure at runtime. Consider using a default import or import require here instead."), Mapped_object_type_implicitly_has_an_any_template_type: diag(7039, ts.DiagnosticCategory.Error, "Mapped_object_type_implicitly_has_an_any_template_type_7039", "Mapped object type implicitly has an 'any' template type."), - If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_1: diag(7040, ts.DiagnosticCategory.Error, "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040", "If the '{0}' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}`"), + If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_1: diag(7040, ts.DiagnosticCategory.Error, "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040", "If the '{0}' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}'"), The_containing_arrow_function_captures_the_global_value_of_this: diag(7041, ts.DiagnosticCategory.Error, "The_containing_arrow_function_captures_the_global_value_of_this_7041", "The containing arrow function captures the global value of 'this'."), Module_0_was_resolved_to_1_but_resolveJsonModule_is_not_used: diag(7042, ts.DiagnosticCategory.Error, "Module_0_was_resolved_to_1_but_resolveJsonModule_is_not_used_7042", "Module '{0}' was resolved to '{1}', but '--resolveJsonModule' is not used."), Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage: diag(7043, ts.DiagnosticCategory.Suggestion, "Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7043", "Variable '{0}' implicitly has an '{1}' type, but a better type may be inferred from usage."), @@ -9069,7 +9350,7 @@ var ts; JSDoc_0_is_not_attached_to_a_class: diag(8022, ts.DiagnosticCategory.Error, "JSDoc_0_is_not_attached_to_a_class_8022", "JSDoc '@{0}' is not attached to a class."), JSDoc_0_1_does_not_match_the_extends_2_clause: diag(8023, ts.DiagnosticCategory.Error, "JSDoc_0_1_does_not_match_the_extends_2_clause_8023", "JSDoc '@{0} {1}' does not match the 'extends {2}' clause."), JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name: diag(8024, ts.DiagnosticCategory.Error, "JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_8024", "JSDoc '@param' tag has name '{0}', but there is no parameter with that name."), - Class_declarations_cannot_have_more_than_one_augments_or_extends_tag: diag(8025, ts.DiagnosticCategory.Error, "Class_declarations_cannot_have_more_than_one_augments_or_extends_tag_8025", "Class declarations cannot have more than one `@augments` or `@extends` tag."), + Class_declarations_cannot_have_more_than_one_augments_or_extends_tag: diag(8025, ts.DiagnosticCategory.Error, "Class_declarations_cannot_have_more_than_one_augments_or_extends_tag_8025", "Class declarations cannot have more than one '@augments' or '@extends' tag."), Expected_0_type_arguments_provide_these_with_an_extends_tag: diag(8026, ts.DiagnosticCategory.Error, "Expected_0_type_arguments_provide_these_with_an_extends_tag_8026", "Expected {0} type arguments; provide these with an '@extends' tag."), Expected_0_1_type_arguments_provide_these_with_an_extends_tag: diag(8027, ts.DiagnosticCategory.Error, "Expected_0_1_type_arguments_provide_these_with_an_extends_tag_8027", "Expected {0}-{1} type arguments; provide these with an '@extends' tag."), JSDoc_may_only_appear_in_the_last_parameter_of_a_signature: diag(8028, ts.DiagnosticCategory.Error, "JSDoc_may_only_appear_in_the_last_parameter_of_a_signature_8028", "JSDoc '...' may only appear in the last parameter of a signature."), @@ -9314,6 +9595,11 @@ var ts; Add_all_missing_function_declarations: diag(95157, ts.DiagnosticCategory.Message, "Add_all_missing_function_declarations_95157", "Add all missing function declarations"), Method_not_implemented: diag(95158, ts.DiagnosticCategory.Message, "Method_not_implemented_95158", "Method not implemented."), Function_not_implemented: diag(95159, ts.DiagnosticCategory.Message, "Function_not_implemented_95159", "Function not implemented."), + Add_override_modifier: diag(95160, ts.DiagnosticCategory.Message, "Add_override_modifier_95160", "Add 'override' modifier"), + Remove_override_modifier: diag(95161, ts.DiagnosticCategory.Message, "Remove_override_modifier_95161", "Remove 'override' modifier"), + Add_all_missing_override_modifiers: diag(95162, ts.DiagnosticCategory.Message, "Add_all_missing_override_modifiers_95162", "Add all missing 'override' modifiers"), + Remove_all_unnecessary_override_modifiers: diag(95163, ts.DiagnosticCategory.Message, "Remove_all_unnecessary_override_modifiers_95163", "Remove all unnecessary 'override' modifiers"), + Can_only_convert_named_export: diag(95164, ts.DiagnosticCategory.Message, "Can_only_convert_named_export_95164", "Can only convert named export"), No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, ts.DiagnosticCategory.Error, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."), Classes_may_not_have_a_field_named_constructor: diag(18006, ts.DiagnosticCategory.Error, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."), JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, ts.DiagnosticCategory.Error, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"), @@ -9328,8 +9614,6 @@ var ts; The_shadowing_declaration_of_0_is_defined_here: diag(18017, ts.DiagnosticCategory.Error, "The_shadowing_declaration_of_0_is_defined_here_18017", "The shadowing declaration of '{0}' is defined here"), The_declaration_of_0_that_you_probably_intended_to_use_is_defined_here: diag(18018, ts.DiagnosticCategory.Error, "The_declaration_of_0_that_you_probably_intended_to_use_is_defined_here_18018", "The declaration of '{0}' that you probably intended to use is defined here"), _0_modifier_cannot_be_used_with_a_private_identifier: diag(18019, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_with_a_private_identifier_18019", "'{0}' modifier cannot be used with a private identifier."), - A_method_cannot_be_named_with_a_private_identifier: diag(18022, ts.DiagnosticCategory.Error, "A_method_cannot_be_named_with_a_private_identifier_18022", "A method cannot be named with a private identifier."), - An_accessor_cannot_be_named_with_a_private_identifier: diag(18023, ts.DiagnosticCategory.Error, "An_accessor_cannot_be_named_with_a_private_identifier_18023", "An accessor cannot be named with a private identifier."), An_enum_member_cannot_be_named_with_a_private_identifier: diag(18024, ts.DiagnosticCategory.Error, "An_enum_member_cannot_be_named_with_a_private_identifier_18024", "An enum member cannot be named with a private identifier."), can_only_be_used_at_the_start_of_a_file: diag(18026, ts.DiagnosticCategory.Error, "can_only_be_used_at_the_start_of_a_file_18026", "'#!' can only be used at the start of a file."), Compiler_reserves_name_0_when_emitting_private_identifier_downlevel: diag(18027, ts.DiagnosticCategory.Error, "Compiler_reserves_name_0_when_emitting_private_identifier_downlevel_18027", "Compiler reserves name '{0}' when emitting private identifier downlevel."), @@ -9341,6 +9625,7 @@ var ts; 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: diag(18033, ts.DiagnosticCategory.Error, "Only_numeric_enums_can_have_computed_members_but_this_expression_has_type_0_If_you_do_not_need_exhau_18033", "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."), Specify_the_JSX_fragment_factory_function_to_use_when_targeting_react_JSX_emit_with_jsxFactory_compiler_option_is_specified_e_g_Fragment: diag(18034, ts.DiagnosticCategory.Message, "Specify_the_JSX_fragment_factory_function_to_use_when_targeting_react_JSX_emit_with_jsxFactory_compi_18034", "Specify the JSX fragment factory function to use when targeting 'react' JSX emit with 'jsxFactory' compiler option is specified, e.g. 'Fragment'."), Invalid_value_for_jsxFragmentFactory_0_is_not_a_valid_identifier_or_qualified_name: diag(18035, ts.DiagnosticCategory.Error, "Invalid_value_for_jsxFragmentFactory_0_is_not_a_valid_identifier_or_qualified_name_18035", "Invalid value for 'jsxFragmentFactory'. '{0}' is not a valid identifier or qualified-name."), + Class_decorators_can_t_be_used_with_static_private_identifier_Consider_removing_the_experimental_decorator: diag(18036, ts.DiagnosticCategory.Error, "Class_decorators_can_t_be_used_with_static_private_identifier_Consider_removing_the_experimental_dec_18036", "Class decorators can't be used with static private identifier. Consider removing the experimental decorator."), }; })(ts || (ts = {})); var ts; @@ -9348,7 +9633,7 @@ var ts; var _a; /* @internal */ function tokenIsIdentifierOrKeyword(token) { - return token >= 78 /* Identifier */; + return token >= 79 /* Identifier */; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; /* @internal */ @@ -9357,87 +9642,88 @@ var ts; } ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan; var textToKeywordObj = (_a = { - abstract: 125 /* AbstractKeyword */, - any: 128 /* AnyKeyword */, - as: 126 /* AsKeyword */, - asserts: 127 /* AssertsKeyword */, - bigint: 155 /* BigIntKeyword */, - boolean: 131 /* BooleanKeyword */, - break: 80 /* BreakKeyword */, - case: 81 /* CaseKeyword */, - catch: 82 /* CatchKeyword */, - class: 83 /* ClassKeyword */, - continue: 85 /* ContinueKeyword */, - const: 84 /* ConstKeyword */ + abstract: 126 /* AbstractKeyword */, + any: 129 /* AnyKeyword */, + as: 127 /* AsKeyword */, + asserts: 128 /* AssertsKeyword */, + bigint: 156 /* BigIntKeyword */, + boolean: 132 /* BooleanKeyword */, + break: 81 /* BreakKeyword */, + case: 82 /* CaseKeyword */, + catch: 83 /* CatchKeyword */, + class: 84 /* ClassKeyword */, + continue: 86 /* ContinueKeyword */, + const: 85 /* ConstKeyword */ }, - _a["" + "constructor"] = 132 /* ConstructorKeyword */, - _a.debugger = 86 /* DebuggerKeyword */, - _a.declare = 133 /* DeclareKeyword */, - _a.default = 87 /* DefaultKeyword */, - _a.delete = 88 /* DeleteKeyword */, - _a.do = 89 /* DoKeyword */, - _a.else = 90 /* ElseKeyword */, - _a.enum = 91 /* EnumKeyword */, - _a.export = 92 /* ExportKeyword */, - _a.extends = 93 /* ExtendsKeyword */, - _a.false = 94 /* FalseKeyword */, - _a.finally = 95 /* FinallyKeyword */, - _a.for = 96 /* ForKeyword */, - _a.from = 153 /* FromKeyword */, - _a.function = 97 /* FunctionKeyword */, - _a.get = 134 /* GetKeyword */, - _a.if = 98 /* IfKeyword */, - _a.implements = 116 /* ImplementsKeyword */, - _a.import = 99 /* ImportKeyword */, - _a.in = 100 /* InKeyword */, - _a.infer = 135 /* InferKeyword */, - _a.instanceof = 101 /* InstanceOfKeyword */, - _a.interface = 117 /* InterfaceKeyword */, - _a.intrinsic = 136 /* IntrinsicKeyword */, - _a.is = 137 /* IsKeyword */, - _a.keyof = 138 /* KeyOfKeyword */, - _a.let = 118 /* LetKeyword */, - _a.module = 139 /* ModuleKeyword */, - _a.namespace = 140 /* NamespaceKeyword */, - _a.never = 141 /* NeverKeyword */, - _a.new = 102 /* NewKeyword */, - _a.null = 103 /* NullKeyword */, - _a.number = 144 /* NumberKeyword */, - _a.object = 145 /* ObjectKeyword */, - _a.package = 119 /* PackageKeyword */, - _a.private = 120 /* PrivateKeyword */, - _a.protected = 121 /* ProtectedKeyword */, - _a.public = 122 /* PublicKeyword */, - _a.readonly = 142 /* ReadonlyKeyword */, - _a.require = 143 /* RequireKeyword */, - _a.global = 154 /* GlobalKeyword */, - _a.return = 104 /* ReturnKeyword */, - _a.set = 146 /* SetKeyword */, - _a.static = 123 /* StaticKeyword */, - _a.string = 147 /* StringKeyword */, - _a.super = 105 /* SuperKeyword */, - _a.switch = 106 /* SwitchKeyword */, - _a.symbol = 148 /* SymbolKeyword */, - _a.this = 107 /* ThisKeyword */, - _a.throw = 108 /* ThrowKeyword */, - _a.true = 109 /* TrueKeyword */, - _a.try = 110 /* TryKeyword */, - _a.type = 149 /* TypeKeyword */, - _a.typeof = 111 /* TypeOfKeyword */, - _a.undefined = 150 /* UndefinedKeyword */, - _a.unique = 151 /* UniqueKeyword */, - _a.unknown = 152 /* UnknownKeyword */, - _a.var = 112 /* VarKeyword */, - _a.void = 113 /* VoidKeyword */, - _a.while = 114 /* WhileKeyword */, - _a.with = 115 /* WithKeyword */, - _a.yield = 124 /* YieldKeyword */, - _a.async = 129 /* AsyncKeyword */, - _a.await = 130 /* AwaitKeyword */, - _a.of = 156 /* OfKeyword */, + _a["" + "constructor"] = 133 /* ConstructorKeyword */, + _a.debugger = 87 /* DebuggerKeyword */, + _a.declare = 134 /* 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 = 154 /* FromKeyword */, + _a.function = 98 /* FunctionKeyword */, + _a.get = 135 /* GetKeyword */, + _a.if = 99 /* IfKeyword */, + _a.implements = 117 /* ImplementsKeyword */, + _a.import = 100 /* ImportKeyword */, + _a.in = 101 /* InKeyword */, + _a.infer = 136 /* InferKeyword */, + _a.instanceof = 102 /* InstanceOfKeyword */, + _a.interface = 118 /* InterfaceKeyword */, + _a.intrinsic = 137 /* IntrinsicKeyword */, + _a.is = 138 /* IsKeyword */, + _a.keyof = 139 /* KeyOfKeyword */, + _a.let = 119 /* LetKeyword */, + _a.module = 140 /* ModuleKeyword */, + _a.namespace = 141 /* NamespaceKeyword */, + _a.never = 142 /* NeverKeyword */, + _a.new = 103 /* NewKeyword */, + _a.null = 104 /* NullKeyword */, + _a.number = 145 /* NumberKeyword */, + _a.object = 146 /* ObjectKeyword */, + _a.package = 120 /* PackageKeyword */, + _a.private = 121 /* PrivateKeyword */, + _a.protected = 122 /* ProtectedKeyword */, + _a.public = 123 /* PublicKeyword */, + _a.override = 157 /* OverrideKeyword */, + _a.readonly = 143 /* ReadonlyKeyword */, + _a.require = 144 /* RequireKeyword */, + _a.global = 155 /* GlobalKeyword */, + _a.return = 105 /* ReturnKeyword */, + _a.set = 147 /* SetKeyword */, + _a.static = 124 /* StaticKeyword */, + _a.string = 148 /* StringKeyword */, + _a.super = 106 /* SuperKeyword */, + _a.switch = 107 /* SwitchKeyword */, + _a.symbol = 149 /* SymbolKeyword */, + _a.this = 108 /* ThisKeyword */, + _a.throw = 109 /* ThrowKeyword */, + _a.true = 110 /* TrueKeyword */, + _a.try = 111 /* TryKeyword */, + _a.type = 150 /* TypeKeyword */, + _a.typeof = 112 /* TypeOfKeyword */, + _a.undefined = 151 /* UndefinedKeyword */, + _a.unique = 152 /* UniqueKeyword */, + _a.unknown = 153 /* UnknownKeyword */, + _a.var = 113 /* VarKeyword */, + _a.void = 114 /* VoidKeyword */, + _a.while = 115 /* WhileKeyword */, + _a.with = 116 /* WithKeyword */, + _a.yield = 125 /* YieldKeyword */, + _a.async = 130 /* AsyncKeyword */, + _a.await = 131 /* AwaitKeyword */, + _a.of = 158 /* OfKeyword */, _a); var textToKeyword = new ts.Map(ts.getEntries(textToKeywordObj)); - var textToToken = new ts.Map(ts.getEntries(__assign(__assign({}, 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 */, "=": 62 /* EqualsToken */, "+=": 63 /* PlusEqualsToken */, "-=": 64 /* MinusEqualsToken */, "*=": 65 /* AsteriskEqualsToken */, "**=": 66 /* AsteriskAsteriskEqualsToken */, "/=": 67 /* SlashEqualsToken */, "%=": 68 /* PercentEqualsToken */, "<<=": 69 /* LessThanLessThanEqualsToken */, ">>=": 70 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 72 /* AmpersandEqualsToken */, "|=": 73 /* BarEqualsToken */, "^=": 77 /* CaretEqualsToken */, "||=": 74 /* BarBarEqualsToken */, "&&=": 75 /* AmpersandAmpersandEqualsToken */, "??=": 76 /* QuestionQuestionEqualsToken */, "@": 59 /* AtToken */, "`": 61 /* BacktickToken */ }))); + var textToToken = new ts.Map(ts.getEntries(__assign(__assign({}, 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 */ }))); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers IdentifierStart :: @@ -9493,13 +9779,13 @@ var ts; var unicodeESNextIdentifierStart = [65, 90, 97, 122, 170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 895, 895, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1327, 1329, 1366, 1369, 1369, 1376, 1416, 1488, 1514, 1519, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2144, 2154, 2208, 2228, 2230, 2237, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2432, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2556, 2556, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2809, 2809, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3129, 3133, 3133, 3160, 3162, 3168, 3169, 3200, 3200, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3412, 3414, 3423, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3718, 3722, 3724, 3747, 3749, 3749, 3751, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5109, 5112, 5117, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5880, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6264, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6430, 6480, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7296, 7304, 7312, 7354, 7357, 7359, 7401, 7404, 7406, 7411, 7413, 7414, 7418, 7418, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8472, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12443, 12447, 12449, 12538, 12540, 12543, 12549, 12591, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40943, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42653, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42943, 42946, 42950, 42999, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43261, 43262, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43488, 43492, 43494, 43503, 43514, 43518, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43646, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43824, 43866, 43868, 43879, 43888, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 65536, 65547, 65549, 65574, 65576, 65594, 65596, 65597, 65599, 65613, 65616, 65629, 65664, 65786, 65856, 65908, 66176, 66204, 66208, 66256, 66304, 66335, 66349, 66378, 66384, 66421, 66432, 66461, 66464, 66499, 66504, 66511, 66513, 66517, 66560, 66717, 66736, 66771, 66776, 66811, 66816, 66855, 66864, 66915, 67072, 67382, 67392, 67413, 67424, 67431, 67584, 67589, 67592, 67592, 67594, 67637, 67639, 67640, 67644, 67644, 67647, 67669, 67680, 67702, 67712, 67742, 67808, 67826, 67828, 67829, 67840, 67861, 67872, 67897, 67968, 68023, 68030, 68031, 68096, 68096, 68112, 68115, 68117, 68119, 68121, 68149, 68192, 68220, 68224, 68252, 68288, 68295, 68297, 68324, 68352, 68405, 68416, 68437, 68448, 68466, 68480, 68497, 68608, 68680, 68736, 68786, 68800, 68850, 68864, 68899, 69376, 69404, 69415, 69415, 69424, 69445, 69600, 69622, 69635, 69687, 69763, 69807, 69840, 69864, 69891, 69926, 69956, 69956, 69968, 70002, 70006, 70006, 70019, 70066, 70081, 70084, 70106, 70106, 70108, 70108, 70144, 70161, 70163, 70187, 70272, 70278, 70280, 70280, 70282, 70285, 70287, 70301, 70303, 70312, 70320, 70366, 70405, 70412, 70415, 70416, 70419, 70440, 70442, 70448, 70450, 70451, 70453, 70457, 70461, 70461, 70480, 70480, 70493, 70497, 70656, 70708, 70727, 70730, 70751, 70751, 70784, 70831, 70852, 70853, 70855, 70855, 71040, 71086, 71128, 71131, 71168, 71215, 71236, 71236, 71296, 71338, 71352, 71352, 71424, 71450, 71680, 71723, 71840, 71903, 71935, 71935, 72096, 72103, 72106, 72144, 72161, 72161, 72163, 72163, 72192, 72192, 72203, 72242, 72250, 72250, 72272, 72272, 72284, 72329, 72349, 72349, 72384, 72440, 72704, 72712, 72714, 72750, 72768, 72768, 72818, 72847, 72960, 72966, 72968, 72969, 72971, 73008, 73030, 73030, 73056, 73061, 73063, 73064, 73066, 73097, 73112, 73112, 73440, 73458, 73728, 74649, 74752, 74862, 74880, 75075, 77824, 78894, 82944, 83526, 92160, 92728, 92736, 92766, 92880, 92909, 92928, 92975, 92992, 92995, 93027, 93047, 93053, 93071, 93760, 93823, 93952, 94026, 94032, 94032, 94099, 94111, 94176, 94177, 94179, 94179, 94208, 100343, 100352, 101106, 110592, 110878, 110928, 110930, 110948, 110951, 110960, 111355, 113664, 113770, 113776, 113788, 113792, 113800, 113808, 113817, 119808, 119892, 119894, 119964, 119966, 119967, 119970, 119970, 119973, 119974, 119977, 119980, 119982, 119993, 119995, 119995, 119997, 120003, 120005, 120069, 120071, 120074, 120077, 120084, 120086, 120092, 120094, 120121, 120123, 120126, 120128, 120132, 120134, 120134, 120138, 120144, 120146, 120485, 120488, 120512, 120514, 120538, 120540, 120570, 120572, 120596, 120598, 120628, 120630, 120654, 120656, 120686, 120688, 120712, 120714, 120744, 120746, 120770, 120772, 120779, 123136, 123180, 123191, 123197, 123214, 123214, 123584, 123627, 124928, 125124, 125184, 125251, 125259, 125259, 126464, 126467, 126469, 126495, 126497, 126498, 126500, 126500, 126503, 126503, 126505, 126514, 126516, 126519, 126521, 126521, 126523, 126523, 126530, 126530, 126535, 126535, 126537, 126537, 126539, 126539, 126541, 126543, 126545, 126546, 126548, 126548, 126551, 126551, 126553, 126553, 126555, 126555, 126557, 126557, 126559, 126559, 126561, 126562, 126564, 126564, 126567, 126570, 126572, 126578, 126580, 126583, 126585, 126588, 126590, 126590, 126592, 126601, 126603, 126619, 126625, 126627, 126629, 126633, 126635, 126651, 131072, 173782, 173824, 177972, 177984, 178205, 178208, 183969, 183984, 191456, 194560, 195101]; var unicodeESNextIdentifierPart = [48, 57, 65, 90, 95, 95, 97, 122, 170, 170, 181, 181, 183, 183, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 895, 895, 902, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1327, 1329, 1366, 1369, 1369, 1376, 1416, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1519, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2045, 2045, 2048, 2093, 2112, 2139, 2144, 2154, 2208, 2228, 2230, 2237, 2259, 2273, 2275, 2403, 2406, 2415, 2417, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2556, 2556, 2558, 2558, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2809, 2815, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3072, 3084, 3086, 3088, 3090, 3112, 3114, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3162, 3168, 3171, 3174, 3183, 3200, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3328, 3331, 3333, 3340, 3342, 3344, 3346, 3396, 3398, 3400, 3402, 3406, 3412, 3415, 3423, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3558, 3567, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3718, 3722, 3724, 3747, 3749, 3749, 3751, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4969, 4977, 4992, 5007, 5024, 5109, 5112, 5117, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5880, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6264, 6272, 6314, 6320, 6389, 6400, 6430, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6618, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6832, 6845, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7296, 7304, 7312, 7354, 7357, 7359, 7376, 7378, 7380, 7418, 7424, 7673, 7675, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8472, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12447, 12449, 12538, 12540, 12543, 12549, 12591, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40943, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42737, 42775, 42783, 42786, 42888, 42891, 42943, 42946, 42950, 42999, 43047, 43072, 43123, 43136, 43205, 43216, 43225, 43232, 43255, 43259, 43259, 43261, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43488, 43518, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43824, 43866, 43868, 43879, 43888, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65071, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 65536, 65547, 65549, 65574, 65576, 65594, 65596, 65597, 65599, 65613, 65616, 65629, 65664, 65786, 65856, 65908, 66045, 66045, 66176, 66204, 66208, 66256, 66272, 66272, 66304, 66335, 66349, 66378, 66384, 66426, 66432, 66461, 66464, 66499, 66504, 66511, 66513, 66517, 66560, 66717, 66720, 66729, 66736, 66771, 66776, 66811, 66816, 66855, 66864, 66915, 67072, 67382, 67392, 67413, 67424, 67431, 67584, 67589, 67592, 67592, 67594, 67637, 67639, 67640, 67644, 67644, 67647, 67669, 67680, 67702, 67712, 67742, 67808, 67826, 67828, 67829, 67840, 67861, 67872, 67897, 67968, 68023, 68030, 68031, 68096, 68099, 68101, 68102, 68108, 68115, 68117, 68119, 68121, 68149, 68152, 68154, 68159, 68159, 68192, 68220, 68224, 68252, 68288, 68295, 68297, 68326, 68352, 68405, 68416, 68437, 68448, 68466, 68480, 68497, 68608, 68680, 68736, 68786, 68800, 68850, 68864, 68903, 68912, 68921, 69376, 69404, 69415, 69415, 69424, 69456, 69600, 69622, 69632, 69702, 69734, 69743, 69759, 69818, 69840, 69864, 69872, 69881, 69888, 69940, 69942, 69951, 69956, 69958, 69968, 70003, 70006, 70006, 70016, 70084, 70089, 70092, 70096, 70106, 70108, 70108, 70144, 70161, 70163, 70199, 70206, 70206, 70272, 70278, 70280, 70280, 70282, 70285, 70287, 70301, 70303, 70312, 70320, 70378, 70384, 70393, 70400, 70403, 70405, 70412, 70415, 70416, 70419, 70440, 70442, 70448, 70450, 70451, 70453, 70457, 70459, 70468, 70471, 70472, 70475, 70477, 70480, 70480, 70487, 70487, 70493, 70499, 70502, 70508, 70512, 70516, 70656, 70730, 70736, 70745, 70750, 70751, 70784, 70853, 70855, 70855, 70864, 70873, 71040, 71093, 71096, 71104, 71128, 71133, 71168, 71232, 71236, 71236, 71248, 71257, 71296, 71352, 71360, 71369, 71424, 71450, 71453, 71467, 71472, 71481, 71680, 71738, 71840, 71913, 71935, 71935, 72096, 72103, 72106, 72151, 72154, 72161, 72163, 72164, 72192, 72254, 72263, 72263, 72272, 72345, 72349, 72349, 72384, 72440, 72704, 72712, 72714, 72758, 72760, 72768, 72784, 72793, 72818, 72847, 72850, 72871, 72873, 72886, 72960, 72966, 72968, 72969, 72971, 73014, 73018, 73018, 73020, 73021, 73023, 73031, 73040, 73049, 73056, 73061, 73063, 73064, 73066, 73102, 73104, 73105, 73107, 73112, 73120, 73129, 73440, 73462, 73728, 74649, 74752, 74862, 74880, 75075, 77824, 78894, 82944, 83526, 92160, 92728, 92736, 92766, 92768, 92777, 92880, 92909, 92912, 92916, 92928, 92982, 92992, 92995, 93008, 93017, 93027, 93047, 93053, 93071, 93760, 93823, 93952, 94026, 94031, 94087, 94095, 94111, 94176, 94177, 94179, 94179, 94208, 100343, 100352, 101106, 110592, 110878, 110928, 110930, 110948, 110951, 110960, 111355, 113664, 113770, 113776, 113788, 113792, 113800, 113808, 113817, 113821, 113822, 119141, 119145, 119149, 119154, 119163, 119170, 119173, 119179, 119210, 119213, 119362, 119364, 119808, 119892, 119894, 119964, 119966, 119967, 119970, 119970, 119973, 119974, 119977, 119980, 119982, 119993, 119995, 119995, 119997, 120003, 120005, 120069, 120071, 120074, 120077, 120084, 120086, 120092, 120094, 120121, 120123, 120126, 120128, 120132, 120134, 120134, 120138, 120144, 120146, 120485, 120488, 120512, 120514, 120538, 120540, 120570, 120572, 120596, 120598, 120628, 120630, 120654, 120656, 120686, 120688, 120712, 120714, 120744, 120746, 120770, 120772, 120779, 120782, 120831, 121344, 121398, 121403, 121452, 121461, 121461, 121476, 121476, 121499, 121503, 121505, 121519, 122880, 122886, 122888, 122904, 122907, 122913, 122915, 122916, 122918, 122922, 123136, 123180, 123184, 123197, 123200, 123209, 123214, 123214, 123584, 123641, 124928, 125124, 125136, 125142, 125184, 125259, 125264, 125273, 126464, 126467, 126469, 126495, 126497, 126498, 126500, 126500, 126503, 126503, 126505, 126514, 126516, 126519, 126521, 126521, 126523, 126523, 126530, 126530, 126535, 126535, 126537, 126537, 126539, 126539, 126541, 126543, 126545, 126546, 126548, 126548, 126551, 126551, 126553, 126553, 126555, 126555, 126557, 126557, 126559, 126559, 126561, 126562, 126564, 126564, 126567, 126570, 126572, 126578, 126580, 126583, 126585, 126588, 126590, 126590, 126592, 126601, 126603, 126619, 126625, 126627, 126629, 126633, 126635, 126651, 131072, 173782, 173824, 177972, 177984, 178205, 178208, 183969, 183984, 191456, 194560, 195101, 917760, 917999]; /** - * Test for whether a single line comment's text contains a directive. + * Test for whether a single line comment with leading whitespace trimmed's text contains a directive. */ - var commentDirectiveRegExSingleLine = /^\s*\/\/\/?\s*@(ts-expect-error|ts-ignore)/; + var commentDirectiveRegExSingleLine = /^\/\/\/?\s*@(ts-expect-error|ts-ignore)/; /** - * Test for whether a multi-line comment's last line contains a directive. + * Test for whether a multi-line comment with leading whitespace trimmed's last line contains a directive. */ - var commentDirectiveRegExMultiLine = /^\s*(?:\/|\*)*\s*@(ts-expect-error|ts-ignore)/; + var commentDirectiveRegExMultiLine = /^(?:\/|\*)*\s*@(ts-expect-error|ts-ignore)/; function lookupInUnicodeMap(code, map) { // Bail out quickly if it couldn't possibly be in the map. if (code < map[0]) { @@ -9750,11 +10036,11 @@ var ts; } ts.couldStartTrivia = couldStartTrivia; /* @internal */ - function skipTrivia(text, pos, stopAfterLineBreak, stopAtComments) { - if (stopAtComments === void 0) { stopAtComments = false; } + function skipTrivia(text, pos, stopAfterLineBreak, stopAtComments, inJSDoc) { if (ts.positionIsSynthesized(pos)) { return pos; } + var canConsumeStar = false; // Keep in sync with couldStartTrivia while (true) { var ch = text.charCodeAt(pos); @@ -9769,6 +10055,7 @@ var ts; if (stopAfterLineBreak) { return pos; } + canConsumeStar = !!inJSDoc; continue; case 9 /* tab */: case 11 /* verticalTab */: @@ -9788,6 +10075,7 @@ var ts; } pos++; } + canConsumeStar = false; continue; } if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { @@ -9799,6 +10087,7 @@ var ts; } pos++; } + canConsumeStar = false; continue; } break; @@ -9808,12 +10097,21 @@ var ts; case 62 /* greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos); + canConsumeStar = false; continue; } break; case 35 /* hash */: if (pos === 0 && isShebangTrivia(text, pos)) { pos = scanShebangTrivia(text, pos); + canConsumeStar = false; + continue; + } + break; + case 42 /* asterisk */: + if (canConsumeStar) { + pos++; + canConsumeStar = false; continue; } break; @@ -10101,8 +10399,8 @@ var ts; 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 === 78 /* Identifier */ || token > 115 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 80 /* FirstReservedWord */ && token <= 115 /* LastReservedWord */; }, + 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; }, getCommentDirectives: function () { return commentDirectives; }, getNumericLiteralFlags: function () { return tokenFlags & 1008 /* NumericLiteralFlags */; }, @@ -10117,7 +10415,9 @@ var ts; reScanJsxAttributeValue: reScanJsxAttributeValue, reScanJsxToken: reScanJsxToken, reScanLessThanToken: reScanLessThanToken, + reScanHashToken: reScanHashToken, reScanQuestionToken: reScanQuestionToken, + reScanInvalidIdentifier: reScanInvalidIdentifier, scanJsxToken: scanJsxToken, scanJsDocToken: scanJsDocToken, scan: scan, @@ -10626,7 +10926,7 @@ var ts; } } } - return token = 78 /* Identifier */; + return token = 79 /* Identifier */; } function scanBinaryOrOctalDigits(base) { var value = ""; @@ -10775,19 +11075,19 @@ var ts; return token = scanTemplateAndSetTokenValue(/* isTaggedTemplate */ false); case 37 /* percent */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 68 /* PercentEqualsToken */; + return pos += 2, token = 69 /* 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 = 75 /* AmpersandAmpersandEqualsToken */; + return pos += 3, token = 76 /* AmpersandAmpersandEqualsToken */; } return pos += 2, token = 55 /* AmpersandAmpersandToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 72 /* AmpersandEqualsToken */; + return pos += 2, token = 73 /* AmpersandEqualsToken */; } pos++; return token = 50 /* AmpersandToken */; @@ -10799,11 +11099,11 @@ var ts; return token = 21 /* CloseParenToken */; case 42 /* asterisk */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 65 /* AsteriskEqualsToken */; + return pos += 2, token = 66 /* AsteriskEqualsToken */; } if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 66 /* AsteriskAsteriskEqualsToken */; + return pos += 3, token = 67 /* AsteriskAsteriskEqualsToken */; } return pos += 2, token = 42 /* AsteriskAsteriskToken */; } @@ -10819,7 +11119,7 @@ var ts; return pos += 2, token = 45 /* PlusPlusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 63 /* PlusEqualsToken */; + return pos += 2, token = 64 /* PlusEqualsToken */; } pos++; return token = 39 /* PlusToken */; @@ -10831,7 +11131,7 @@ var ts; return pos += 2, token = 46 /* MinusMinusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 64 /* MinusEqualsToken */; + return pos += 2, token = 65 /* MinusEqualsToken */; } pos++; return token = 40 /* MinusToken */; @@ -10899,7 +11199,7 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 67 /* SlashEqualsToken */; + return pos += 2, token = 68 /* SlashEqualsToken */; } pos++; return token = 43 /* SlashToken */; @@ -10976,7 +11276,7 @@ var ts; } if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 69 /* LessThanLessThanEqualsToken */; + return pos += 3, token = 70 /* LessThanLessThanEqualsToken */; } return pos += 2, token = 47 /* LessThanLessThanToken */; } @@ -11010,7 +11310,7 @@ var ts; return pos += 2, token = 38 /* EqualsGreaterThanToken */; } pos++; - return token = 62 /* EqualsToken */; + return token = 63 /* EqualsToken */; case 62 /* greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -11029,7 +11329,7 @@ var ts; } if (text.charCodeAt(pos + 1) === 63 /* question */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 76 /* QuestionQuestionEqualsToken */; + return pos += 3, token = 77 /* QuestionQuestionEqualsToken */; } return pos += 2, token = 60 /* QuestionQuestionToken */; } @@ -11043,7 +11343,7 @@ var ts; return token = 23 /* CloseBracketToken */; case 94 /* caret */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 77 /* CaretEqualsToken */; + return pos += 2, token = 78 /* CaretEqualsToken */; } pos++; return token = 52 /* CaretToken */; @@ -11062,12 +11362,12 @@ var ts; } if (text.charCodeAt(pos + 1) === 124 /* bar */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 74 /* BarBarEqualsToken */; + return pos += 3, token = 75 /* BarBarEqualsToken */; } return pos += 2, token = 56 /* BarBarToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 73 /* BarEqualsToken */; + return pos += 2, token = 74 /* BarEqualsToken */; } pos++; return token = 51 /* BarToken */; @@ -11105,30 +11405,12 @@ var ts; return token = 0 /* Unknown */; } pos++; - if (isIdentifierStart(ch = text.charCodeAt(pos), languageVersion)) { - pos++; - while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion)) - pos++; - tokenValue = text.substring(tokenPos, pos); - if (ch === 92 /* backslash */) { - tokenValue += scanIdentifierParts(); - } - } - else { - tokenValue = "#"; - error(ts.Diagnostics.Invalid_character); - } - return token = 79 /* PrivateIdentifier */; + scanIdentifier(codePointAt(text, pos), languageVersion); + return token = 80 /* PrivateIdentifier */; default: - if (isIdentifierStart(ch, languageVersion)) { - pos += charSize(ch); - while (pos < end && isIdentifierPart(ch = codePointAt(text, pos), languageVersion)) - pos += charSize(ch); - tokenValue = text.substring(tokenPos, pos); - if (ch === 92 /* backslash */) { - tokenValue += scanIdentifierParts(); - } - return token = getIdentifierToken(); + var identifierKind = scanIdentifier(ch, languageVersion); + if (identifierKind) { + return token = identifierKind; } else if (isWhiteSpaceSingleLine(ch)) { pos += charSize(ch); @@ -11145,17 +11427,42 @@ var ts; } } } + function reScanInvalidIdentifier() { + ts.Debug.assert(token === 0 /* 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 */); + if (identifierKind) { + return token = identifierKind; + } + pos += charSize(ch); + return token; // Still `SyntaKind.Unknown` + } + function scanIdentifier(startCharacter, languageVersion) { + var ch = startCharacter; + if (isIdentifierStart(ch, languageVersion)) { + pos += charSize(ch); + while (pos < end && isIdentifierPart(ch = codePointAt(text, pos), languageVersion)) + pos += charSize(ch); + tokenValue = text.substring(tokenPos, pos); + if (ch === 92 /* 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 = 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + return pos += 3, token = 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */; } return pos += 2, token = 49 /* GreaterThanGreaterThanGreaterThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 70 /* GreaterThanGreaterThanEqualsToken */; + return pos += 2, token = 71 /* GreaterThanGreaterThanEqualsToken */; } pos++; return token = 48 /* GreaterThanGreaterThanToken */; @@ -11168,12 +11475,12 @@ var ts; return token; } function reScanAsteriskEqualsToken() { - ts.Debug.assert(token === 65 /* AsteriskEqualsToken */, "'reScanAsteriskEqualsToken' should only be called on a '*='"); + ts.Debug.assert(token === 66 /* AsteriskEqualsToken */, "'reScanAsteriskEqualsToken' should only be called on a '*='"); pos = tokenPos + 1; - return token = 62 /* EqualsToken */; + return token = 63 /* EqualsToken */; } function reScanSlashToken() { - if (token === 43 /* SlashToken */ || token === 67 /* SlashEqualsToken */) { + if (token === 43 /* SlashToken */ || token === 68 /* SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -11223,7 +11530,7 @@ var ts; return token; } function appendIfCommentDirective(commentDirectives, text, commentDirectiveRegEx, lineStart) { - var type = getDirectiveFromComment(text, commentDirectiveRegEx); + var type = getDirectiveFromComment(ts.trimStringStart(text), commentDirectiveRegEx); if (type === undefined) { return commentDirectives; } @@ -11257,9 +11564,10 @@ var ts; pos = tokenPos; return token = scanTemplateAndSetTokenValue(/* isTaggedTemplate */ true); } - function reScanJsxToken() { + function reScanJsxToken(allowMultilineJsxText) { + if (allowMultilineJsxText === void 0) { allowMultilineJsxText = true; } pos = tokenPos = startPos; - return token = scanJsxToken(); + return token = scanJsxToken(allowMultilineJsxText); } function reScanLessThanToken() { if (token === 47 /* LessThanLessThanToken */) { @@ -11268,12 +11576,20 @@ var ts; } return token; } + function reScanHashToken() { + if (token === 80 /* PrivateIdentifier */) { + pos = tokenPos + 1; + return token = 62 /* HashToken */; + } + return token; + } function reScanQuestionToken() { ts.Debug.assert(token === 60 /* QuestionQuestionToken */, "'reScanQuestionToken' should only be called on a '??'"); pos = tokenPos + 1; return token = 57 /* QuestionToken */; } - function scanJsxToken() { + function scanJsxToken(allowMultilineJsxText) { + if (allowMultilineJsxText === void 0) { allowMultilineJsxText = true; } startPos = tokenPos = pos; if (pos >= end) { return token = 1 /* EndOfFileToken */; @@ -11293,15 +11609,9 @@ var ts; } // First non-whitespace character on this line. var firstNonWhitespace = 0; - var lastNonWhitespace = -1; // These initial values are special because the first line is: // firstNonWhitespace = 0 to indicate that we want leading whitespace, while (pos < end) { - // We want to keep track of the last non-whitespace (but including - // newlines character for hitting the end of the JSX Text region) - if (!isWhiteSpaceSingleLine(char)) { - lastNonWhitespace = pos; - } char = text.charCodeAt(pos); if (char === 123 /* openBrace */) { break; @@ -11319,8 +11629,6 @@ var ts; if (char === 125 /* closeBrace */) { error(ts.Diagnostics.Unexpected_token_Did_you_mean_or_rbrace, pos, 1); } - if (lastNonWhitespace > 0) - lastNonWhitespace++; // FirstNonWhitespace is 0, then we only see whitespaces so far. If we see a linebreak, we want to ignore that whitespaces. // i.e (- : whitespace) //
---- @@ -11330,13 +11638,17 @@ var ts; if (isLineBreak(char) && firstNonWhitespace === 0) { firstNonWhitespace = -1; } + else if (!allowMultilineJsxText && isLineBreak(char) && firstNonWhitespace > 0) { + // Stop JsxText on each line during formatting. This allows the formatter to + // indent each line correctly. + break; + } else if (!isWhiteSpaceLike(char)) { firstNonWhitespace = pos; } pos++; } - var endPosition = lastNonWhitespace === -1 ? pos : lastNonWhitespace; - tokenValue = text.substring(startPos, endPosition); + tokenValue = text.substring(startPos, pos); return firstNonWhitespace === -1 ? 12 /* JsxTextAllWhiteSpaces */ : 11 /* JsxText */; } // Scans a JSX identifier; these differ from normal identifiers in that @@ -11359,6 +11671,7 @@ var ts; tokenValue += ":"; pos++; namespaceSeparator = true; + token = 79 /* Identifier */; // swap from keyword kind to identifier kind continue; } var oldPos = pos; @@ -11433,13 +11746,15 @@ var ts; case 62 /* greaterThan */: return token = 31 /* GreaterThanToken */; case 61 /* equals */: - return token = 62 /* EqualsToken */; + 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 */: pos--; var extendedCookedChar = peekExtendedUnicodeEscape(); @@ -11615,6 +11930,8 @@ var ts; switch (options.target) { case 99 /* ESNext */: return "lib.esnext.full.d.ts"; + case 8 /* ES2021 */: + return "lib.es2021.full.d.ts"; case 7 /* ES2020 */: return "lib.es2020.full.d.ts"; case 6 /* ES2019 */: @@ -11833,9 +12150,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 159 /* TypeParameter */) { + if (d && d.kind === 161 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (isFunctionLike(current) || isClassLike(current) || current.kind === 253 /* InterfaceDeclaration */) { + if (isFunctionLike(current) || isClassLike(current) || current.kind === 255 /* InterfaceDeclaration */) { return current; } } @@ -11843,7 +12160,7 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node, parent) { - return ts.hasSyntacticModifier(node, 92 /* ParameterPropertyModifier */) && parent.kind === 166 /* Constructor */; + return ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */) && parent.kind === 168 /* Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -11873,14 +12190,14 @@ var ts; node = walkUpBindingElementsAndPatterns(node); } var flags = getFlags(node); - if (node.kind === 249 /* VariableDeclaration */) { + if (node.kind === 251 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 250 /* VariableDeclarationList */) { + if (node && node.kind === 252 /* VariableDeclarationList */) { flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 232 /* VariableStatement */) { + if (node && node.kind === 234 /* VariableStatement */) { flags |= getFlags(node); } return flags; @@ -11898,19 +12215,22 @@ var ts; // nodes like variable declarations and binding elements can returned a view of their flags // that includes the modifiers from their container. i.e. flags like export/declare aren't // stored on the variable declaration directly, but on the containing variable statement - // (if it has one). Similarly, flags for let/const are store on the variable declaration + // (if it has one). Similarly, flags for let/const are stored on the variable declaration // list. By calling this function, all those flags are combined so that the client can treat // the node as if it actually had those flags. function getCombinedNodeFlags(node) { return getCombinedFlags(node, function (n) { return n.flags; }); } ts.getCombinedNodeFlags = getCombinedNodeFlags; + /* @internal */ + ts.supportedLocaleDirectories = ["cs", "de", "es", "fr", "it", "ja", "ko", "pl", "pt-br", "ru", "tr", "zh-cn", "zh-tw"]; /** * Checks to see if the locale is in the appropriate format, * and if it is, attempts to set the appropriate language. */ function validateLocaleAndSetLanguage(locale, sys, errors) { - var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase()); + var lowerCaseLocale = locale.toLowerCase(); + var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(lowerCaseLocale); if (!matchResult) { if (errors) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1, "en", "ja-jp")); @@ -11921,7 +12241,7 @@ var ts; var territory = matchResult[3]; // First try the entire locale, then fall back to just language if that's all we have. // Either ways do not fail, and fallback to the English diagnostic strings. - if (!trySetLanguageAndTerritory(language, territory, errors)) { + if (ts.contains(ts.supportedLocaleDirectories, lowerCaseLocale) && !trySetLanguageAndTerritory(language, territory, errors)) { trySetLanguageAndTerritory(language, /*territory*/ undefined, errors); } // Set the UI locale for string collation @@ -12028,7 +12348,7 @@ var ts; } ts.idText = idText; function symbolName(symbol) { - if (symbol.valueDeclaration && isPrivateIdentifierPropertyDeclaration(symbol.valueDeclaration)) { + if (symbol.valueDeclaration && isPrivateIdentifierClassElementDeclaration(symbol.valueDeclaration)) { return idText(symbol.valueDeclaration.name); } return unescapeLeadingUnderscores(symbol.escapedName); @@ -12050,30 +12370,30 @@ var ts; } // Covers remaining cases (returning undefined if none match). switch (hostNode.kind) { - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } break; - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: var expr = hostNode.expression; - if (expr.kind === 216 /* BinaryExpression */ && expr.operatorToken.kind === 62 /* EqualsToken */) { + if (expr.kind === 218 /* BinaryExpression */ && expr.operatorToken.kind === 63 /* EqualsToken */) { expr = expr.left; } switch (expr.kind) { - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return expr.name; - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; } } break; - case 207 /* ParenthesizedExpression */: { + case 209 /* ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 245 /* LabeledStatement */: { + case 247 /* LabeledStatement */: { if (isDeclaration(hostNode.statement) || isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -12108,18 +12428,18 @@ var ts; /** @internal */ function getNonAssignedNameOfDeclaration(declaration) { switch (declaration.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return declaration; - case 333 /* JSDocPropertyTag */: - case 326 /* JSDocParameterTag */: { + case 341 /* JSDocPropertyTag */: + case 334 /* JSDocParameterTag */: { var name = declaration.name; - if (name.kind === 157 /* QualifiedName */) { + if (name.kind === 159 /* QualifiedName */) { return name.right; } break; } - case 203 /* CallExpression */: - case 216 /* BinaryExpression */: { + case 205 /* CallExpression */: + case 218 /* BinaryExpression */: { var expr_1 = declaration; switch (ts.getAssignmentDeclarationKind(expr_1)) { case 1 /* ExportsProperty */: @@ -12135,15 +12455,15 @@ var ts; return undefined; } } - case 331 /* JSDocTypedefTag */: + case 339 /* JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 325 /* JSDocEnumTag */: + case 333 /* JSDocEnumTag */: return nameForNamelessJSDocTypedef(declaration); - case 266 /* ExportAssignment */: { + case 268 /* ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: var expr = declaration; if (ts.isBindableStaticElementAccessExpression(expr)) { return expr.argumentExpression; @@ -12156,7 +12476,7 @@ var ts; if (declaration === undefined) return undefined; return getNonAssignedNameOfDeclaration(declaration) || - (ts.isFunctionExpression(declaration) || ts.isClassExpression(declaration) ? getAssignedName(declaration) : undefined); + (ts.isFunctionExpression(declaration) || ts.isArrowFunction(declaration) || ts.isClassExpression(declaration) ? getAssignedName(declaration) : undefined); } ts.getNameOfDeclaration = getNameOfDeclaration; /*@internal*/ @@ -12309,6 +12629,10 @@ var ts; return getFirstJSDocTag(node, ts.isJSDocReadonlyTag, /*noCache*/ true); } ts.getJSDocReadonlyTagNoCache = getJSDocReadonlyTagNoCache; + function getJSDocOverrideTagNoCache(node) { + return getFirstJSDocTag(node, ts.isJSDocOverrideTag, /*noCache*/ true); + } + ts.getJSDocOverrideTagNoCache = getJSDocOverrideTagNoCache; /** Gets the JSDoc deprecated tag for the node if present */ function getJSDocDeprecatedTag(node) { return getFirstJSDocTag(node, ts.isJSDocDeprecatedTag); @@ -12429,6 +12753,15 @@ var ts; return getJSDocTags(node).filter(function (doc) { return doc.kind === kind; }); } ts.getAllJSDocTagsOfKind = getAllJSDocTagsOfKind; + /** 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) { + // TODO: Other kinds here + return c.kind === 315 /* JSDocText */ ? c.text : "{@link " + (c.name ? ts.entityNameToString(c.name) + " " : "") + c.text + "}"; + }).join(""); + } + ts.getTextOfJSDocComment = getTextOfJSDocComment; /** * Gets the effective type parameters. If the node was parsed in a * JavaScript file, gets the type parameters from the `@template` tag from JSDoc. @@ -12438,7 +12771,7 @@ var ts; return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 311 /* JSDocComment */); + ts.Debug.assert(node.parent.kind === 314 /* JSDocComment */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -12464,13 +12797,13 @@ var ts; } ts.getEffectiveConstraintOfTypeParameter = getEffectiveConstraintOfTypeParameter; // #region - function isIdentifierOrPrivateIdentifier(node) { - return node.kind === 78 /* Identifier */ || node.kind === 79 /* PrivateIdentifier */; + function isMemberName(node) { + return node.kind === 79 /* Identifier */ || node.kind === 80 /* PrivateIdentifier */; } - ts.isIdentifierOrPrivateIdentifier = isIdentifierOrPrivateIdentifier; + ts.isMemberName = isMemberName; /* @internal */ function isGetOrSetAccessorDeclaration(node) { - return node.kind === 168 /* SetAccessor */ || node.kind === 167 /* GetAccessor */; + return node.kind === 170 /* SetAccessor */ || node.kind === 169 /* GetAccessor */; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; function isPropertyAccessChain(node) { @@ -12488,10 +12821,10 @@ var ts; function isOptionalChain(node) { var kind = node.kind; return !!(node.flags & 32 /* OptionalChain */) && - (kind === 201 /* PropertyAccessExpression */ - || kind === 202 /* ElementAccessExpression */ - || kind === 203 /* CallExpression */ - || kind === 225 /* NonNullExpression */); + (kind === 203 /* PropertyAccessExpression */ + || kind === 204 /* ElementAccessExpression */ + || kind === 205 /* CallExpression */ + || kind === 227 /* NonNullExpression */); } ts.isOptionalChain = isOptionalChain; /* @internal */ @@ -12526,7 +12859,7 @@ var ts; } ts.isOutermostOptionalChain = isOutermostOptionalChain; function isNullishCoalesce(node) { - return node.kind === 216 /* BinaryExpression */ && node.operatorToken.kind === 60 /* QuestionQuestionToken */; + return node.kind === 218 /* BinaryExpression */ && node.operatorToken.kind === 60 /* QuestionQuestionToken */; } ts.isNullishCoalesce = isNullishCoalesce; function isConstTypeReference(node) { @@ -12543,17 +12876,17 @@ var ts; } ts.isNonNullChain = isNonNullChain; function isBreakOrContinueStatement(node) { - return node.kind === 241 /* BreakStatement */ || node.kind === 240 /* ContinueStatement */; + return node.kind === 243 /* BreakStatement */ || node.kind === 242 /* ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isNamedExportBindings(node) { - return node.kind === 269 /* NamespaceExport */ || node.kind === 268 /* NamedExports */; + return node.kind === 271 /* NamespaceExport */ || node.kind === 270 /* NamedExports */; } ts.isNamedExportBindings = isNamedExportBindings; function isUnparsedTextLike(node) { switch (node.kind) { - case 294 /* UnparsedText */: - case 295 /* UnparsedInternalText */: + case 296 /* UnparsedText */: + case 297 /* UnparsedInternalText */: return true; default: return false; @@ -12562,12 +12895,12 @@ var ts; ts.isUnparsedTextLike = isUnparsedTextLike; function isUnparsedNode(node) { return isUnparsedTextLike(node) || - node.kind === 292 /* UnparsedPrologue */ || - node.kind === 296 /* UnparsedSyntheticReference */; + node.kind === 294 /* UnparsedPrologue */ || + node.kind === 298 /* UnparsedSyntheticReference */; } ts.isUnparsedNode = isUnparsedNode; function isJSDocPropertyLikeTag(node) { - return node.kind === 333 /* JSDocPropertyTag */ || node.kind === 326 /* JSDocParameterTag */; + return node.kind === 341 /* JSDocPropertyTag */ || node.kind === 334 /* JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; // #endregion @@ -12583,16 +12916,25 @@ var ts; ts.isNode = isNode; /* @internal */ function isNodeKind(kind) { - return kind >= 157 /* FirstNode */; + return kind >= 159 /* FirstNode */; } ts.isNodeKind = isNodeKind; + /** + * True if kind is of some token syntax kind. + * For example, this is true for an IfKeyword but not for an IfStatement. + * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. + */ + function isTokenKind(kind) { + return kind >= 0 /* FirstToken */ && kind <= 158 /* LastToken */; + } + ts.isTokenKind = isTokenKind; /** * True if node is of some token syntax kind. * For example, this is true for an IfKeyword but not for an IfStatement. * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. */ function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 156 /* LastToken */; + return isTokenKind(n.kind); } ts.isToken = isToken; // Node Arrays @@ -12633,13 +12975,13 @@ var ts; ts.isImportOrExportSpecifier = isImportOrExportSpecifier; function isTypeOnlyImportOrExportDeclaration(node) { switch (node.kind) { - case 265 /* ImportSpecifier */: - case 270 /* ExportSpecifier */: + case 267 /* ImportSpecifier */: + case 272 /* ExportSpecifier */: return node.parent.parent.isTypeOnly; - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: return node.parent.isTypeOnly; - case 262 /* ImportClause */: - case 260 /* ImportEqualsDeclaration */: + case 264 /* ImportClause */: + case 262 /* ImportEqualsDeclaration */: return node.isTypeOnly; default: return false; @@ -12658,10 +13000,10 @@ var ts; ts.isGeneratedIdentifier = isGeneratedIdentifier; // Private Identifiers /*@internal*/ - function isPrivateIdentifierPropertyDeclaration(node) { - return ts.isPropertyDeclaration(node) && ts.isPrivateIdentifier(node.name); + function isPrivateIdentifierClassElementDeclaration(node) { + return (ts.isPropertyDeclaration(node) || isMethodOrAccessor(node)) && ts.isPrivateIdentifier(node.name); } - ts.isPrivateIdentifierPropertyDeclaration = isPrivateIdentifierPropertyDeclaration; + ts.isPrivateIdentifierClassElementDeclaration = isPrivateIdentifierClassElementDeclaration; /*@internal*/ function isPrivateIdentifierPropertyAccessExpression(node) { return ts.isPropertyAccessExpression(node) && ts.isPrivateIdentifier(node.name); @@ -12671,17 +13013,18 @@ var ts; /* @internal */ function isModifierKind(token) { switch (token) { - case 125 /* AbstractKeyword */: - case 129 /* AsyncKeyword */: - case 84 /* ConstKeyword */: - case 133 /* DeclareKeyword */: - case 87 /* DefaultKeyword */: - case 92 /* ExportKeyword */: - case 122 /* PublicKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 142 /* ReadonlyKeyword */: - case 123 /* StaticKeyword */: + case 126 /* AbstractKeyword */: + case 130 /* AsyncKeyword */: + case 85 /* ConstKeyword */: + case 134 /* DeclareKeyword */: + case 88 /* DefaultKeyword */: + case 93 /* ExportKeyword */: + case 123 /* PublicKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + case 143 /* ReadonlyKeyword */: + case 124 /* StaticKeyword */: + case 157 /* OverrideKeyword */: return true; } return false; @@ -12689,12 +13032,12 @@ var ts; ts.isModifierKind = isModifierKind; /* @internal */ function isParameterPropertyModifier(kind) { - return !!(ts.modifierToFlag(kind) & 92 /* ParameterPropertyModifier */); + return !!(ts.modifierToFlag(kind) & 16476 /* ParameterPropertyModifier */); } ts.isParameterPropertyModifier = isParameterPropertyModifier; /* @internal */ function isClassMemberModifier(idToken) { - return isParameterPropertyModifier(idToken) || idToken === 123 /* StaticKeyword */; + return isParameterPropertyModifier(idToken) || idToken === 124 /* StaticKeyword */ || idToken === 157 /* OverrideKeyword */; } ts.isClassMemberModifier = isClassMemberModifier; function isModifier(node) { @@ -12703,29 +13046,29 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 157 /* QualifiedName */ - || kind === 78 /* Identifier */; + return kind === 159 /* QualifiedName */ + || kind === 79 /* Identifier */; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 78 /* Identifier */ - || kind === 79 /* PrivateIdentifier */ + return kind === 79 /* Identifier */ + || kind === 80 /* PrivateIdentifier */ || kind === 10 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 158 /* ComputedPropertyName */; + || kind === 160 /* ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; - return kind === 78 /* Identifier */ - || kind === 196 /* ObjectBindingPattern */ - || kind === 197 /* ArrayBindingPattern */; + return kind === 79 /* Identifier */ + || kind === 198 /* ObjectBindingPattern */ + || kind === 199 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions function isFunctionLike(node) { - return node && isFunctionLikeKind(node.kind); + return !!node && isFunctionLikeKind(node.kind); } ts.isFunctionLike = isFunctionLike; /* @internal */ @@ -12735,13 +13078,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 251 /* FunctionDeclaration */: - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 253 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return true; default: return false; @@ -12750,14 +13093,14 @@ var ts; /* @internal */ function isFunctionLikeKind(kind) { switch (kind) { - case 164 /* MethodSignature */: - case 169 /* CallSignature */: - case 313 /* JSDocSignature */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: - case 174 /* FunctionType */: - case 308 /* JSDocFunctionType */: - case 175 /* ConstructorType */: + case 166 /* MethodSignature */: + case 171 /* CallSignature */: + case 317 /* JSDocSignature */: + case 172 /* ConstructSignature */: + case 173 /* IndexSignature */: + case 176 /* FunctionType */: + case 311 /* JSDocFunctionType */: + case 177 /* ConstructorType */: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -12772,29 +13115,29 @@ var ts; // Classes function isClassElement(node) { var kind = node.kind; - return kind === 166 /* Constructor */ - || kind === 163 /* PropertyDeclaration */ - || kind === 165 /* MethodDeclaration */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */ - || kind === 171 /* IndexSignature */ - || kind === 229 /* SemicolonClassElement */; + return kind === 168 /* Constructor */ + || kind === 165 /* PropertyDeclaration */ + || kind === 167 /* MethodDeclaration */ + || kind === 169 /* GetAccessor */ + || kind === 170 /* SetAccessor */ + || kind === 173 /* IndexSignature */ + || kind === 231 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 252 /* ClassDeclaration */ || node.kind === 221 /* ClassExpression */); + return node && (node.kind === 254 /* ClassDeclaration */ || node.kind === 223 /* ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 167 /* GetAccessor */ || node.kind === 168 /* SetAccessor */); + return node && (node.kind === 169 /* GetAccessor */ || node.kind === 170 /* SetAccessor */); } ts.isAccessor = isAccessor; /* @internal */ function isMethodOrAccessor(node) { switch (node.kind) { - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return true; default: return false; @@ -12804,11 +13147,11 @@ var ts; // Type members function isTypeElement(node) { var kind = node.kind; - return kind === 170 /* ConstructSignature */ - || kind === 169 /* CallSignature */ - || kind === 162 /* PropertySignature */ - || kind === 164 /* MethodSignature */ - || kind === 171 /* IndexSignature */; + return kind === 172 /* ConstructSignature */ + || kind === 171 /* CallSignature */ + || kind === 164 /* PropertySignature */ + || kind === 166 /* MethodSignature */ + || kind === 173 /* IndexSignature */; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -12817,12 +13160,12 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 288 /* PropertyAssignment */ - || kind === 289 /* ShorthandPropertyAssignment */ - || kind === 290 /* SpreadAssignment */ - || kind === 165 /* MethodDeclaration */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */; + return kind === 290 /* PropertyAssignment */ + || kind === 291 /* ShorthandPropertyAssignment */ + || kind === 292 /* SpreadAssignment */ + || kind === 167 /* MethodDeclaration */ + || kind === 169 /* GetAccessor */ + || kind === 170 /* SetAccessor */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type @@ -12837,8 +13180,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 174 /* FunctionType */: - case 175 /* ConstructorType */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: return true; } return false; @@ -12849,8 +13192,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 197 /* ArrayBindingPattern */ - || kind === 196 /* ObjectBindingPattern */; + return kind === 199 /* ArrayBindingPattern */ + || kind === 198 /* ObjectBindingPattern */; } return false; } @@ -12858,15 +13201,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 199 /* ArrayLiteralExpression */ - || kind === 200 /* ObjectLiteralExpression */; + return kind === 201 /* ArrayLiteralExpression */ + || kind === 202 /* ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 198 /* BindingElement */ - || kind === 222 /* OmittedExpression */; + return kind === 200 /* BindingElement */ + || kind === 224 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -12875,9 +13218,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 249 /* VariableDeclaration */: - case 160 /* Parameter */: - case 198 /* BindingElement */: + case 251 /* VariableDeclaration */: + case 162 /* Parameter */: + case 200 /* BindingElement */: return true; } return false; @@ -12898,8 +13241,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 196 /* ObjectBindingPattern */: - case 200 /* ObjectLiteralExpression */: + case 198 /* ObjectBindingPattern */: + case 202 /* ObjectLiteralExpression */: return true; } return false; @@ -12911,8 +13254,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 197 /* ArrayBindingPattern */: - case 199 /* ArrayLiteralExpression */: + case 199 /* ArrayBindingPattern */: + case 201 /* ArrayLiteralExpression */: return true; } return false; @@ -12921,26 +13264,26 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 201 /* PropertyAccessExpression */ - || kind === 157 /* QualifiedName */ - || kind === 195 /* ImportType */; + return kind === 203 /* PropertyAccessExpression */ + || kind === 159 /* QualifiedName */ + || kind === 197 /* ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 201 /* PropertyAccessExpression */ - || kind === 157 /* QualifiedName */; + return kind === 203 /* PropertyAccessExpression */ + || kind === 159 /* QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 275 /* JsxOpeningElement */: - case 274 /* JsxSelfClosingElement */: - case 203 /* CallExpression */: - case 204 /* NewExpression */: - case 205 /* TaggedTemplateExpression */: - case 161 /* Decorator */: + case 277 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: + case 207 /* TaggedTemplateExpression */: + case 163 /* Decorator */: return true; default: return false; @@ -12948,12 +13291,12 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 203 /* CallExpression */ || node.kind === 204 /* NewExpression */; + return node.kind === 205 /* CallExpression */ || node.kind === 206 /* NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 218 /* TemplateExpression */ + return kind === 220 /* TemplateExpression */ || kind === 14 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; @@ -12964,34 +13307,34 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: - case 204 /* NewExpression */: - case 203 /* CallExpression */: - case 273 /* JsxElement */: - case 274 /* JsxSelfClosingElement */: - case 277 /* JsxFragment */: - case 205 /* TaggedTemplateExpression */: - case 199 /* ArrayLiteralExpression */: - case 207 /* ParenthesizedExpression */: - case 200 /* ObjectLiteralExpression */: - case 221 /* ClassExpression */: - case 208 /* FunctionExpression */: - case 78 /* Identifier */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: + case 206 /* NewExpression */: + case 205 /* CallExpression */: + case 275 /* JsxElement */: + case 276 /* JsxSelfClosingElement */: + case 279 /* JsxFragment */: + case 207 /* TaggedTemplateExpression */: + case 201 /* ArrayLiteralExpression */: + case 209 /* ParenthesizedExpression */: + case 202 /* ObjectLiteralExpression */: + case 223 /* ClassExpression */: + case 210 /* FunctionExpression */: + case 79 /* Identifier */: case 13 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 218 /* TemplateExpression */: - case 94 /* FalseKeyword */: - case 103 /* NullKeyword */: - case 107 /* ThisKeyword */: - case 109 /* TrueKeyword */: - case 105 /* SuperKeyword */: - case 225 /* NonNullExpression */: - case 226 /* MetaProperty */: - case 99 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression + case 220 /* TemplateExpression */: + case 95 /* FalseKeyword */: + case 104 /* NullKeyword */: + case 108 /* ThisKeyword */: + case 110 /* TrueKeyword */: + case 106 /* SuperKeyword */: + case 227 /* NonNullExpression */: + case 228 /* MetaProperty */: + case 100 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: return false; @@ -13004,13 +13347,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 214 /* PrefixUnaryExpression */: - case 215 /* PostfixUnaryExpression */: - case 210 /* DeleteExpression */: - case 211 /* TypeOfExpression */: - case 212 /* VoidExpression */: - case 213 /* AwaitExpression */: - case 206 /* TypeAssertionExpression */: + case 216 /* PrefixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: + case 212 /* DeleteExpression */: + case 213 /* TypeOfExpression */: + case 214 /* VoidExpression */: + case 215 /* AwaitExpression */: + case 208 /* TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -13019,9 +13362,9 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: return true; - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return expr.operator === 45 /* PlusPlusToken */ || expr.operator === 46 /* MinusMinusToken */; default: @@ -13040,15 +13383,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 217 /* ConditionalExpression */: - case 219 /* YieldExpression */: - case 209 /* ArrowFunction */: - case 216 /* BinaryExpression */: - case 220 /* SpreadElement */: - case 224 /* AsExpression */: - case 222 /* OmittedExpression */: - case 337 /* CommaListExpression */: - case 336 /* PartiallyEmittedExpression */: + case 219 /* ConditionalExpression */: + case 221 /* YieldExpression */: + case 211 /* ArrowFunction */: + case 218 /* BinaryExpression */: + case 222 /* SpreadElement */: + case 226 /* AsExpression */: + case 224 /* OmittedExpression */: + case 345 /* CommaListExpression */: + case 344 /* PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -13056,8 +13399,8 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 206 /* TypeAssertionExpression */ - || kind === 224 /* AsExpression */; + return kind === 208 /* TypeAssertionExpression */ + || kind === 226 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ @@ -13068,13 +13411,13 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: return true; - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -13103,7 +13446,7 @@ var ts; ts.isExternalModuleIndicator = isExternalModuleIndicator; /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 238 /* ForInStatement */ || node.kind === 239 /* ForOfStatement */; + return node.kind === 240 /* ForInStatement */ || node.kind === 241 /* ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -13127,114 +13470,114 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 257 /* ModuleBlock */ - || kind === 256 /* ModuleDeclaration */ - || kind === 78 /* Identifier */; + return kind === 259 /* ModuleBlock */ + || kind === 258 /* ModuleDeclaration */ + || kind === 79 /* Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 257 /* ModuleBlock */ - || kind === 256 /* ModuleDeclaration */; + return kind === 259 /* ModuleBlock */ + || kind === 258 /* ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; - return kind === 78 /* Identifier */ - || kind === 256 /* ModuleDeclaration */; + return kind === 79 /* Identifier */ + || kind === 258 /* ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 264 /* NamedImports */ - || kind === 263 /* NamespaceImport */; + return kind === 266 /* NamedImports */ + || kind === 265 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 256 /* ModuleDeclaration */ || node.kind === 255 /* EnumDeclaration */; + return node.kind === 258 /* ModuleDeclaration */ || node.kind === 257 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 209 /* ArrowFunction */ - || kind === 198 /* BindingElement */ - || kind === 252 /* ClassDeclaration */ - || kind === 221 /* ClassExpression */ - || kind === 166 /* Constructor */ - || kind === 255 /* EnumDeclaration */ - || kind === 291 /* EnumMember */ - || kind === 270 /* ExportSpecifier */ - || kind === 251 /* FunctionDeclaration */ - || kind === 208 /* FunctionExpression */ - || kind === 167 /* GetAccessor */ - || kind === 262 /* ImportClause */ - || kind === 260 /* ImportEqualsDeclaration */ - || kind === 265 /* ImportSpecifier */ - || kind === 253 /* InterfaceDeclaration */ - || kind === 280 /* JsxAttribute */ - || kind === 165 /* MethodDeclaration */ - || kind === 164 /* MethodSignature */ - || kind === 256 /* ModuleDeclaration */ - || kind === 259 /* NamespaceExportDeclaration */ - || kind === 263 /* NamespaceImport */ - || kind === 269 /* NamespaceExport */ - || kind === 160 /* Parameter */ - || kind === 288 /* PropertyAssignment */ - || kind === 163 /* PropertyDeclaration */ - || kind === 162 /* PropertySignature */ - || kind === 168 /* SetAccessor */ - || kind === 289 /* ShorthandPropertyAssignment */ - || kind === 254 /* TypeAliasDeclaration */ - || kind === 159 /* TypeParameter */ - || kind === 249 /* VariableDeclaration */ - || kind === 331 /* JSDocTypedefTag */ - || kind === 324 /* JSDocCallbackTag */ - || kind === 333 /* JSDocPropertyTag */; + return kind === 211 /* ArrowFunction */ + || kind === 200 /* BindingElement */ + || kind === 254 /* ClassDeclaration */ + || kind === 223 /* ClassExpression */ + || kind === 168 /* Constructor */ + || kind === 257 /* EnumDeclaration */ + || kind === 293 /* EnumMember */ + || kind === 272 /* ExportSpecifier */ + || kind === 253 /* FunctionDeclaration */ + || kind === 210 /* FunctionExpression */ + || kind === 169 /* GetAccessor */ + || kind === 264 /* ImportClause */ + || kind === 262 /* ImportEqualsDeclaration */ + || kind === 267 /* ImportSpecifier */ + || kind === 255 /* InterfaceDeclaration */ + || kind === 282 /* JsxAttribute */ + || kind === 167 /* MethodDeclaration */ + || kind === 166 /* MethodSignature */ + || kind === 258 /* ModuleDeclaration */ + || kind === 261 /* NamespaceExportDeclaration */ + || kind === 265 /* NamespaceImport */ + || kind === 271 /* NamespaceExport */ + || kind === 162 /* Parameter */ + || kind === 290 /* PropertyAssignment */ + || kind === 165 /* PropertyDeclaration */ + || kind === 164 /* PropertySignature */ + || kind === 170 /* SetAccessor */ + || kind === 291 /* ShorthandPropertyAssignment */ + || kind === 256 /* TypeAliasDeclaration */ + || kind === 161 /* TypeParameter */ + || kind === 251 /* VariableDeclaration */ + || kind === 339 /* JSDocTypedefTag */ + || kind === 332 /* JSDocCallbackTag */ + || kind === 341 /* JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - return kind === 251 /* FunctionDeclaration */ - || kind === 271 /* MissingDeclaration */ - || kind === 252 /* ClassDeclaration */ - || kind === 253 /* InterfaceDeclaration */ - || kind === 254 /* TypeAliasDeclaration */ - || kind === 255 /* EnumDeclaration */ - || kind === 256 /* ModuleDeclaration */ - || kind === 261 /* ImportDeclaration */ - || kind === 260 /* ImportEqualsDeclaration */ - || kind === 267 /* ExportDeclaration */ - || kind === 266 /* ExportAssignment */ - || kind === 259 /* NamespaceExportDeclaration */; + return kind === 253 /* FunctionDeclaration */ + || kind === 273 /* MissingDeclaration */ + || kind === 254 /* ClassDeclaration */ + || kind === 255 /* InterfaceDeclaration */ + || kind === 256 /* TypeAliasDeclaration */ + || kind === 257 /* EnumDeclaration */ + || kind === 258 /* ModuleDeclaration */ + || kind === 263 /* ImportDeclaration */ + || kind === 262 /* ImportEqualsDeclaration */ + || kind === 269 /* ExportDeclaration */ + || kind === 268 /* ExportAssignment */ + || kind === 261 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 241 /* BreakStatement */ - || kind === 240 /* ContinueStatement */ - || kind === 248 /* DebuggerStatement */ - || kind === 235 /* DoStatement */ - || kind === 233 /* ExpressionStatement */ - || kind === 231 /* EmptyStatement */ - || kind === 238 /* ForInStatement */ - || kind === 239 /* ForOfStatement */ - || kind === 237 /* ForStatement */ - || kind === 234 /* IfStatement */ - || kind === 245 /* LabeledStatement */ - || kind === 242 /* ReturnStatement */ - || kind === 244 /* SwitchStatement */ - || kind === 246 /* ThrowStatement */ - || kind === 247 /* TryStatement */ - || kind === 232 /* VariableStatement */ - || kind === 236 /* WhileStatement */ - || kind === 243 /* WithStatement */ - || kind === 335 /* NotEmittedStatement */ - || kind === 339 /* EndOfDeclarationMarker */ - || kind === 338 /* MergeDeclarationMarker */; + return kind === 243 /* BreakStatement */ + || kind === 242 /* ContinueStatement */ + || kind === 250 /* DebuggerStatement */ + || kind === 237 /* DoStatement */ + || kind === 235 /* ExpressionStatement */ + || kind === 233 /* EmptyStatement */ + || kind === 240 /* ForInStatement */ + || kind === 241 /* ForOfStatement */ + || kind === 239 /* ForStatement */ + || kind === 236 /* IfStatement */ + || kind === 247 /* LabeledStatement */ + || kind === 244 /* ReturnStatement */ + || kind === 246 /* SwitchStatement */ + || kind === 248 /* ThrowStatement */ + || kind === 249 /* TryStatement */ + || kind === 234 /* VariableStatement */ + || kind === 238 /* WhileStatement */ + || kind === 245 /* WithStatement */ + || kind === 343 /* NotEmittedStatement */ + || kind === 347 /* EndOfDeclarationMarker */ + || kind === 346 /* MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { - if (node.kind === 159 /* TypeParameter */) { - return (node.parent && node.parent.kind !== 330 /* JSDocTemplateTag */) || ts.isInJSFile(node); + if (node.kind === 161 /* TypeParameter */) { + return (node.parent && node.parent.kind !== 338 /* JSDocTemplateTag */) || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -13261,10 +13604,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 230 /* Block */) + if (node.kind !== 232 /* Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 247 /* TryStatement */ || node.parent.kind === 287 /* CatchClause */) { + if (node.parent.kind === 249 /* TryStatement */ || node.parent.kind === 289 /* CatchClause */) { return false; } } @@ -13278,88 +13621,94 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 230 /* Block */; + || kind === 232 /* Block */; } ts.isStatementOrBlock = isStatementOrBlock; // Module references /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 272 /* ExternalModuleReference */ - || kind === 157 /* QualifiedName */ - || kind === 78 /* Identifier */; + return kind === 274 /* ExternalModuleReference */ + || kind === 159 /* QualifiedName */ + || kind === 79 /* Identifier */; } ts.isModuleReference = isModuleReference; // JSX /* @internal */ function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 107 /* ThisKeyword */ - || kind === 78 /* Identifier */ - || kind === 201 /* PropertyAccessExpression */; + return kind === 108 /* ThisKeyword */ + || kind === 79 /* Identifier */ + || kind === 203 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 273 /* JsxElement */ - || kind === 283 /* JsxExpression */ - || kind === 274 /* JsxSelfClosingElement */ + return kind === 275 /* JsxElement */ + || kind === 285 /* JsxExpression */ + || kind === 276 /* JsxSelfClosingElement */ || kind === 11 /* JsxText */ - || kind === 277 /* JsxFragment */; + || kind === 279 /* JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 280 /* JsxAttribute */ - || kind === 282 /* JsxSpreadAttribute */; + return kind === 282 /* JsxAttribute */ + || kind === 284 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 10 /* StringLiteral */ - || kind === 283 /* JsxExpression */; + || kind === 285 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 275 /* JsxOpeningElement */ - || kind === 274 /* JsxSelfClosingElement */; + return kind === 277 /* JsxOpeningElement */ + || kind === 276 /* JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 284 /* CaseClause */ - || kind === 285 /* DefaultClause */; + return kind === 286 /* CaseClause */ + || kind === 287 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 301 /* FirstJSDocNode */ && node.kind <= 333 /* LastJSDocNode */; + return node.kind >= 303 /* FirstJSDocNode */ && node.kind <= 341 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 311 /* JSDocComment */ || node.kind === 310 /* JSDocNamepathType */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 314 /* JSDocComment */ + || node.kind === 313 /* JSDocNamepathType */ + || node.kind === 315 /* JSDocText */ + || isJSDocLinkLike(node) + || isJSDocTag(node) + || ts.isJSDocTypeLiteral(node) + || ts.isJSDocSignature(node); } ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode; // TODO: determine what this does before making it public. /* @internal */ function isJSDocTag(node) { - return node.kind >= 314 /* FirstJSDocTagNode */ && node.kind <= 333 /* LastJSDocTagNode */; + return node.kind >= 321 /* FirstJSDocTagNode */ && node.kind <= 341 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 168 /* SetAccessor */; + return node.kind === 170 /* SetAccessor */; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 167 /* GetAccessor */; + return node.kind === 169 /* GetAccessor */; } ts.isGetAccessor = isGetAccessor; /** True if has jsdoc nodes attached to it. */ @@ -13385,13 +13734,13 @@ var ts; /** True if has initializer node attached to it. */ function hasOnlyExpressionInitializer(node) { switch (node.kind) { - case 249 /* VariableDeclaration */: - case 160 /* Parameter */: - case 198 /* BindingElement */: - case 162 /* PropertySignature */: - case 163 /* PropertyDeclaration */: - case 288 /* PropertyAssignment */: - case 291 /* EnumMember */: + case 251 /* VariableDeclaration */: + case 162 /* Parameter */: + case 200 /* BindingElement */: + case 164 /* PropertySignature */: + case 165 /* PropertyDeclaration */: + case 290 /* PropertyAssignment */: + case 293 /* EnumMember */: return true; default: return false; @@ -13399,12 +13748,12 @@ var ts; } ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { - return node.kind === 280 /* JsxAttribute */ || node.kind === 282 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); + return node.kind === 282 /* JsxAttribute */ || node.kind === 284 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); } ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 173 /* TypeReference */ || node.kind === 223 /* ExpressionWithTypeArguments */; + return node.kind === 175 /* TypeReference */ || node.kind === 225 /* ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -13436,6 +13785,10 @@ var ts; return node.kind === 10 /* StringLiteral */ || node.kind === 14 /* NoSubstitutionTemplateLiteral */; } ts.isStringLiteralLike = isStringLiteralLike; + function isJSDocLinkLike(node) { + return node.kind === 318 /* JSDocLink */ || node.kind === 319 /* JSDocLinkCode */ || node.kind === 320 /* JSDocLinkPlain */; + } + ts.isJSDocLinkLike = isJSDocLinkLike; // #endregion })(ts || (ts = {})); /* @internal */ @@ -13520,7 +13873,7 @@ var ts; increaseIndent: ts.noop, decreaseIndent: ts.noop, clear: function () { return str = ""; }, - trackSymbol: ts.noop, + trackSymbol: function () { return false; }, reportInaccessibleThisError: ts.noop, reportInaccessibleUniqueSymbolError: ts.noop, reportPrivateInBaseOfClassExpression: ts.noop, @@ -13532,11 +13885,19 @@ var ts; } ts.changesAffectModuleResolution = changesAffectModuleResolution; function optionsHaveModuleResolutionChanges(oldOptions, newOptions) { - return ts.moduleResolutionOptionDeclarations.some(function (o) { + return optionsHaveChanges(oldOptions, newOptions, ts.moduleResolutionOptionDeclarations); + } + ts.optionsHaveModuleResolutionChanges = optionsHaveModuleResolutionChanges; + function changesAffectingProgramStructure(oldOptions, newOptions) { + return optionsHaveChanges(oldOptions, newOptions, ts.optionsAffectingProgramStructure); + } + ts.changesAffectingProgramStructure = changesAffectingProgramStructure; + function optionsHaveChanges(oldOptions, newOptions, optionDeclarations) { + return oldOptions !== newOptions && optionDeclarations.some(function (o) { return !isJsonEqual(getCompilerOptionValue(oldOptions, o), getCompilerOptionValue(newOptions, o)); }); } - ts.optionsHaveModuleResolutionChanges = optionsHaveModuleResolutionChanges; + ts.optionsHaveChanges = optionsHaveChanges; function forEachAncestor(node, callback) { while (true) { var res = callback(node); @@ -13643,7 +14004,9 @@ var ts; } ts.packageIdToString = packageIdToString; function typeDirectiveIsEqualTo(oldResolution, newResolution) { - return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.primary === newResolution.primary; + return oldResolution.resolvedFileName === newResolution.resolvedFileName + && oldResolution.primary === newResolution.primary + && oldResolution.originalPath === newResolution.originalPath; } ts.typeDirectiveIsEqualTo = typeDirectiveIsEqualTo; function hasChangesInResolutions(names, newResolutions, oldResolutions, comparer) { @@ -13685,7 +14048,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 297 /* SourceFile */) { + while (node && node.kind !== 299 /* SourceFile */) { node = node.parent; } return node; @@ -13693,11 +14056,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 230 /* Block */: - case 258 /* CaseBlock */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: + case 232 /* Block */: + case 260 /* CaseBlock */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: return true; } return false; @@ -13835,10 +14198,10 @@ var ts; commentPos + 2 < commentEnd && text.charCodeAt(commentPos + 2) === 47 /* slash */) { var textSubStr = text.substring(commentPos, commentEnd); - return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) || - textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) || - textSubStr.match(fullTripleSlashReferenceTypeReferenceDirectiveRegEx) || - textSubStr.match(defaultLibReferenceRegEx) ? + return ts.fullTripleSlashReferencePathRegEx.test(textSubStr) || + ts.fullTripleSlashAMDReferencePathRegEx.test(textSubStr) || + fullTripleSlashReferenceTypeReferenceDirectiveRegEx.test(textSubStr) || + defaultLibReferenceRegEx.test(textSubStr) ? true : false; } return false; @@ -13893,10 +14256,12 @@ 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 === 334 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 342 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } - return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); + return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, + /*stopAfterLineBreak*/ false, + /*stopAtComments*/ false, isInJSDoc(node)); } ts.getTokenPosOfNode = getTokenPosOfNode; function getNonDecoratorTokenPosOfNode(node, sourceFile) { @@ -13926,7 +14291,7 @@ var ts; var text = sourceText.substring(includeTrivia ? node.pos : ts.skipTrivia(sourceText, node.pos), node.end); if (isJSDocTypeExpressionOrChild(node)) { // strip space + asterisk at line start - text = text.replace(/(^|\r?\n|\r)\s*\*\s*/g, "$1"); + text = text.split(/\r\n|\n|\r/).map(function (line) { return ts.trimStringStart(line.replace(/^\s*\*/, "")); }).join("\n"); } return text; } @@ -14015,9 +14380,11 @@ var ts; DataView: ["setBigInt64", "setBigUint64", "getBigInt64", "getBigUint64"], RelativeTimeFormat: ["format", "formatToParts", "resolvedOptions"] }, - esnext: { + es2021: { PromiseConstructor: ["any"], - String: ["replaceAll"], + String: ["replaceAll"] + }, + esnext: { NumberFormat: ["formatToParts"] } }; @@ -14110,7 +14477,7 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 249 /* VariableDeclaration */ && node.parent.kind === 287 /* CatchClause */; + return node.kind === 251 /* VariableDeclaration */ && node.parent.kind === 289 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { @@ -14142,11 +14509,11 @@ 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 === 256 /* ModuleDeclaration */ && (!node.body); + return !!node && node.kind === 258 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 297 /* SourceFile */ || - node.kind === 256 /* ModuleDeclaration */ || + return node.kind === 299 /* SourceFile */ || + node.kind === 258 /* ModuleDeclaration */ || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -14163,16 +14530,17 @@ 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 297 /* SourceFile */: + case 299 /* SourceFile */: return ts.isExternalModule(node.parent); - case 257 /* ModuleBlock */: + case 259 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; } ts.isModuleAugmentationExternal = isModuleAugmentationExternal; function getNonAugmentationDeclaration(symbol) { - return ts.find(symbol.declarations, function (d) { return !isExternalModuleAugmentation(d) && !(ts.isModuleDeclaration(d) && isGlobalScopeAugmentation(d)); }); + var _a; + return (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return !isExternalModuleAugmentation(d) && !(ts.isModuleDeclaration(d) && isGlobalScopeAugmentation(d)); }); } ts.getNonAugmentationDeclaration = getNonAugmentationDeclaration; function isEffectiveExternalModule(node, compilerOptions) { @@ -14218,22 +14586,22 @@ var ts; ts.isEffectiveStrictModeSourceFile = isEffectiveStrictModeSourceFile; function isBlockScope(node, parentNode) { switch (node.kind) { - case 297 /* SourceFile */: - case 258 /* CaseBlock */: - case 287 /* CatchClause */: - case 256 /* ModuleDeclaration */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 166 /* Constructor */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 299 /* SourceFile */: + case 260 /* CaseBlock */: + case 289 /* CatchClause */: + case 258 /* ModuleDeclaration */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 168 /* Constructor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return true; - case 230 /* Block */: + case 232 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return !ts.isFunctionLike(parentNode); @@ -14243,9 +14611,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 324 /* JSDocCallbackTag */: - case 331 /* JSDocTypedefTag */: - case 313 /* JSDocSignature */: + case 332 /* JSDocCallbackTag */: + case 339 /* JSDocTypedefTag */: + case 317 /* JSDocSignature */: return true; default: ts.assertType(node); @@ -14255,25 +14623,25 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isDeclarationWithTypeParameterChildren(node) { switch (node.kind) { - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 164 /* MethodSignature */: - case 171 /* IndexSignature */: - case 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 308 /* JSDocFunctionType */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 330 /* JSDocTemplateTag */: - case 251 /* FunctionDeclaration */: - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 166 /* MethodSignature */: + case 173 /* IndexSignature */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: + case 311 /* JSDocFunctionType */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 338 /* JSDocTemplateTag */: + case 253 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return true; default: ts.assertType(node); @@ -14283,8 +14651,8 @@ var ts; ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren; function isAnyImportSyntax(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: - case 260 /* ImportEqualsDeclaration */: + case 263 /* ImportDeclaration */: + case 262 /* ImportEqualsDeclaration */: return true; default: return false; @@ -14293,15 +14661,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: - case 260 /* ImportEqualsDeclaration */: - case 232 /* VariableStatement */: - case 252 /* ClassDeclaration */: - case 251 /* FunctionDeclaration */: - case 256 /* ModuleDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: + case 263 /* ImportDeclaration */: + case 262 /* ImportEqualsDeclaration */: + case 234 /* VariableStatement */: + case 254 /* ClassDeclaration */: + case 253 /* FunctionDeclaration */: + case 258 /* ModuleDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 255 /* InterfaceDeclaration */: + case 257 /* EnumDeclaration */: return true; default: return false; @@ -14334,19 +14702,19 @@ var ts; } ts.getNameFromIndexInfo = getNameFromIndexInfo; function isComputedNonLiteralName(name) { - return name.kind === 158 /* ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression); + return name.kind === 160 /* ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression); } ts.isComputedNonLiteralName = isComputedNonLiteralName; function getTextOfPropertyName(name) { switch (name.kind) { - case 78 /* Identifier */: - case 79 /* PrivateIdentifier */: + case 79 /* Identifier */: + case 80 /* PrivateIdentifier */: return name.escapedText; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: if (isStringOrNumericLiteralLike(name.expression)) return ts.escapeLeadingUnderscores(name.expression.text); return ts.Debug.fail("Text of property name cannot be read from non-literal-valued ComputedPropertyNames"); @@ -14357,20 +14725,22 @@ var ts; ts.getTextOfPropertyName = getTextOfPropertyName; function entityNameToString(name) { switch (name.kind) { - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: return "this"; - case 79 /* PrivateIdentifier */: - case 78 /* Identifier */: + case 80 /* PrivateIdentifier */: + case 79 /* Identifier */: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 157 /* QualifiedName */: + case 159 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 201 /* PropertyAccessExpression */: + case 203 /* 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 305 /* JSDocMemberName */: + return entityNameToString(name.left) + entityNameToString(name.right); default: return ts.Debug.assertNever(name); } @@ -14450,7 +14820,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 230 /* Block */) { + if (node.body && node.body.kind === 232 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -14464,7 +14834,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 297 /* SourceFile */: + case 299 /* 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 @@ -14473,28 +14843,28 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 249 /* VariableDeclaration */: - case 198 /* BindingElement */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 256 /* ModuleDeclaration */: - case 255 /* EnumDeclaration */: - case 291 /* EnumMember */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 254 /* TypeAliasDeclaration */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 251 /* VariableDeclaration */: + case 200 /* BindingElement */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: + case 258 /* ModuleDeclaration */: + case 257 /* EnumDeclaration */: + case 293 /* EnumMember */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 256 /* TypeAliasDeclaration */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: errorNode = node.name; break; - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); - case 284 /* CaseClause */: - case 285 /* DefaultClause */: + case 286 /* CaseClause */: + case 287 /* 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); @@ -14546,16 +14916,16 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 203 /* CallExpression */ && n.expression.kind === 105 /* SuperKeyword */; + return n.kind === 205 /* CallExpression */ && n.expression.kind === 106 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 203 /* CallExpression */ && n.expression.kind === 99 /* ImportKeyword */; + return n.kind === 205 /* CallExpression */ && n.expression.kind === 100 /* ImportKeyword */; } ts.isImportCall = isImportCall; function isImportMeta(n) { return ts.isMetaProperty(n) - && n.keywordToken === 99 /* ImportKeyword */ + && n.keywordToken === 100 /* ImportKeyword */ && n.name.escapedText === "meta"; } ts.isImportMeta = isImportMeta; @@ -14564,7 +14934,7 @@ var ts; } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 233 /* ExpressionStatement */ + return node.kind === 235 /* ExpressionStatement */ && node.expression.kind === 10 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; @@ -14592,11 +14962,12 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 160 /* Parameter */ || - node.kind === 159 /* TypeParameter */ || - node.kind === 208 /* FunctionExpression */ || - node.kind === 209 /* ArrowFunction */ || - node.kind === 207 /* ParenthesizedExpression */) ? + var commentRanges = (node.kind === 162 /* Parameter */ || + node.kind === 161 /* TypeParameter */ || + node.kind === 210 /* FunctionExpression */ || + node.kind === 211 /* ArrowFunction */ || + node.kind === 209 /* ParenthesizedExpression */ || + node.kind === 251 /* VariableDeclaration */) ? 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 '/**/' @@ -14607,53 +14978,53 @@ var ts; }); } ts.getJSDocCommentRanges = getJSDocCommentRanges; - ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; - var fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; - ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; - var defaultLibReferenceRegEx = /^(\/\/\/\s*/; + ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; + var fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; + ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; + var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (172 /* FirstTypeNode */ <= node.kind && node.kind <= 195 /* LastTypeNode */) { + if (174 /* FirstTypeNode */ <= node.kind && node.kind <= 197 /* LastTypeNode */) { return true; } switch (node.kind) { - case 128 /* AnyKeyword */: - case 152 /* UnknownKeyword */: - case 144 /* NumberKeyword */: - case 155 /* BigIntKeyword */: - case 147 /* StringKeyword */: - case 131 /* BooleanKeyword */: - case 148 /* SymbolKeyword */: - case 145 /* ObjectKeyword */: - case 150 /* UndefinedKeyword */: - case 141 /* NeverKeyword */: + case 129 /* AnyKeyword */: + case 153 /* UnknownKeyword */: + case 145 /* NumberKeyword */: + case 156 /* BigIntKeyword */: + case 148 /* StringKeyword */: + case 132 /* BooleanKeyword */: + case 149 /* SymbolKeyword */: + case 146 /* ObjectKeyword */: + case 151 /* UndefinedKeyword */: + case 142 /* NeverKeyword */: return true; - case 113 /* VoidKeyword */: - return node.parent.kind !== 212 /* VoidExpression */; - case 223 /* ExpressionWithTypeArguments */: + case 114 /* VoidKeyword */: + return node.parent.kind !== 214 /* VoidExpression */; + case 225 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 159 /* TypeParameter */: - return node.parent.kind === 190 /* MappedType */ || node.parent.kind === 185 /* InferType */; + case 161 /* TypeParameter */: + return node.parent.kind === 192 /* MappedType */ || node.parent.kind === 187 /* InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container - case 78 /* Identifier */: + case 79 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 157 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 159 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 201 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 203 /* 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 === 78 /* Identifier */ || node.kind === 157 /* QualifiedName */ || node.kind === 201 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 79 /* Identifier */ || node.kind === 159 /* QualifiedName */ || node.kind === 203 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through - case 157 /* QualifiedName */: - case 201 /* PropertyAccessExpression */: - case 107 /* ThisKeyword */: { + case 159 /* QualifiedName */: + case 203 /* PropertyAccessExpression */: + case 108 /* ThisKeyword */: { var parent = node.parent; - if (parent.kind === 176 /* TypeQuery */) { + if (parent.kind === 178 /* TypeQuery */) { return false; } - if (parent.kind === 195 /* ImportType */) { + if (parent.kind === 197 /* ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -14662,40 +15033,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 (172 /* FirstTypeNode */ <= parent.kind && parent.kind <= 195 /* LastTypeNode */) { + if (174 /* FirstTypeNode */ <= parent.kind && parent.kind <= 197 /* LastTypeNode */) { return true; } switch (parent.kind) { - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 159 /* TypeParameter */: + case 161 /* TypeParameter */: return node === parent.constraint; - case 330 /* JSDocTemplateTag */: + case 338 /* JSDocTemplateTag */: return node === parent.constraint; - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 160 /* Parameter */: - case 249 /* VariableDeclaration */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 162 /* Parameter */: + case 251 /* VariableDeclaration */: return node === parent.type; - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 166 /* Constructor */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 168 /* Constructor */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return node === parent.type; - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 173 /* IndexSignature */: return node === parent.type; - case 206 /* TypeAssertionExpression */: + case 208 /* TypeAssertionExpression */: return node === parent.type; - case 203 /* CallExpression */: - case 204 /* NewExpression */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: return ts.contains(parent.typeArguments, node); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -14720,23 +15091,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: return visitor(node); - case 258 /* CaseBlock */: - case 230 /* Block */: - case 234 /* IfStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 243 /* WithStatement */: - case 244 /* SwitchStatement */: - case 284 /* CaseClause */: - case 285 /* DefaultClause */: - case 245 /* LabeledStatement */: - case 247 /* TryStatement */: - case 287 /* CatchClause */: + case 260 /* CaseBlock */: + case 232 /* Block */: + case 236 /* IfStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 245 /* WithStatement */: + case 246 /* SwitchStatement */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: + case 247 /* LabeledStatement */: + case 249 /* TryStatement */: + case 289 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -14746,23 +15117,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 255 /* EnumDeclaration */: - case 253 /* InterfaceDeclaration */: - case 256 /* ModuleDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 257 /* EnumDeclaration */: + case 255 /* InterfaceDeclaration */: + case 258 /* ModuleDeclaration */: + case 256 /* 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 === 158 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 160 /* 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); @@ -14785,10 +15156,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 178 /* ArrayType */) { + if (node && node.kind === 180 /* ArrayType */) { return node.elementType; } - else if (node && node.kind === 173 /* TypeReference */) { + else if (node && node.kind === 175 /* TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -14798,12 +15169,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 253 /* InterfaceDeclaration */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 177 /* TypeLiteral */: + case 255 /* InterfaceDeclaration */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 179 /* TypeLiteral */: return node.members; - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return node.properties; } } @@ -14811,14 +15182,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 198 /* BindingElement */: - case 291 /* EnumMember */: - case 160 /* Parameter */: - case 288 /* PropertyAssignment */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 289 /* ShorthandPropertyAssignment */: - case 249 /* VariableDeclaration */: + case 200 /* BindingElement */: + case 293 /* EnumMember */: + case 162 /* Parameter */: + case 290 /* PropertyAssignment */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 291 /* ShorthandPropertyAssignment */: + case 251 /* VariableDeclaration */: return true; } } @@ -14830,8 +15201,8 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 250 /* VariableDeclarationList */ - && node.parent.parent.kind === 232 /* VariableStatement */; + return node.parent.kind === 252 /* VariableDeclarationList */ + && node.parent.parent.kind === 234 /* VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { @@ -14842,13 +15213,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: return true; } return false; @@ -14859,7 +15230,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 245 /* LabeledStatement */) { + if (node.statement.kind !== 247 /* LabeledStatement */) { return node.statement; } node = node.statement; @@ -14867,17 +15238,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 230 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 232 /* Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 165 /* MethodDeclaration */ && node.parent.kind === 200 /* ObjectLiteralExpression */; + return node && node.kind === 167 /* MethodDeclaration */ && node.parent.kind === 202 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 165 /* MethodDeclaration */ && - (node.parent.kind === 200 /* ObjectLiteralExpression */ || - node.parent.kind === 221 /* ClassExpression */); + return node.kind === 167 /* MethodDeclaration */ && + (node.parent.kind === 202 /* ObjectLiteralExpression */ || + node.parent.kind === 223 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -14890,7 +15261,7 @@ var ts; ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 288 /* PropertyAssignment */) { + if (property.kind === 290 /* PropertyAssignment */) { var propName = getTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -14939,14 +15310,14 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 297 /* SourceFile */); + ts.Debug.assert(node.kind !== 299 /* 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 158 /* ComputedPropertyName */: + case 160 /* 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 @@ -14961,9 +15332,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 161 /* Decorator */: + case 163 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 160 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 162 /* 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; @@ -14974,26 +15345,26 @@ var ts; node = node.parent; } break; - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 256 /* ModuleDeclaration */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: - case 255 /* EnumDeclaration */: - case 297 /* SourceFile */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 258 /* ModuleDeclaration */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 173 /* IndexSignature */: + case 257 /* EnumDeclaration */: + case 299 /* SourceFile */: return node; } } @@ -15012,9 +15383,9 @@ var ts; var container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { switch (container.kind) { - case 166 /* Constructor */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: + case 168 /* Constructor */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: return container; } } @@ -15036,27 +15407,27 @@ var ts; return node; } switch (node.kind) { - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: node = node.parent; break; - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: if (!stopOnFunctions) { continue; } // falls through - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return node; - case 161 /* Decorator */: + case 163 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 160 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 162 /* 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; @@ -15072,21 +15443,21 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 208 /* FunctionExpression */ || func.kind === 209 /* ArrowFunction */) { + if (func.kind === 210 /* FunctionExpression */ || func.kind === 211 /* ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 207 /* ParenthesizedExpression */) { + while (parent.kind === 209 /* ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 203 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 205 /* CallExpression */ && parent.expression === prev) { return parent; } } } ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperOrSuperProperty(node) { - return node.kind === 105 /* SuperKeyword */ + return node.kind === 106 /* SuperKeyword */ || isSuperProperty(node); } ts.isSuperOrSuperProperty = isSuperOrSuperProperty; @@ -15095,8 +15466,8 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 201 /* PropertyAccessExpression */ || kind === 202 /* ElementAccessExpression */) - && node.expression.kind === 105 /* SuperKeyword */; + return (kind === 203 /* PropertyAccessExpression */ || kind === 204 /* ElementAccessExpression */) + && node.expression.kind === 106 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; /** @@ -15104,26 +15475,34 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 201 /* PropertyAccessExpression */ || kind === 202 /* ElementAccessExpression */) - && node.expression.kind === 107 /* ThisKeyword */; + return (kind === 203 /* PropertyAccessExpression */ || kind === 204 /* ElementAccessExpression */) + && node.expression.kind === 108 /* 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) === 107 /* ThisKeyword */; + return !!node && ts.isVariableDeclaration(node) && ((_a = node.initializer) === null || _a === void 0 ? void 0 : _a.kind) === 108 /* 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 */; + } + ts.isThisInitializedObjectBindingExpression = isThisInitializedObjectBindingExpression; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 173 /* TypeReference */: + case 175 /* TypeReference */: return node.typeName; - case 223 /* ExpressionWithTypeArguments */: + case 225 /* 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 78 /* Identifier */: - case 157 /* QualifiedName */: + case 79 /* Identifier */: + case 159 /* QualifiedName */: return node; } return undefined; @@ -15131,10 +15510,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return node.tag; - case 275 /* JsxOpeningElement */: - case 274 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -15147,25 +15526,25 @@ var ts; return false; } switch (node.kind) { - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: // classes are valid targets return true; - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 252 /* ClassDeclaration */; - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 165 /* MethodDeclaration */: + return parent.kind === 254 /* ClassDeclaration */; + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 167 /* 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 === 252 /* ClassDeclaration */; - case 160 /* Parameter */: + && parent.kind === 254 /* ClassDeclaration */; + case 162 /* 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 === 166 /* Constructor */ - || parent.kind === 165 /* MethodDeclaration */ - || parent.kind === 168 /* SetAccessor */) - && grandparent.kind === 252 /* ClassDeclaration */; + && (parent.kind === 168 /* Constructor */ + || parent.kind === 167 /* MethodDeclaration */ + || parent.kind === 170 /* SetAccessor */) + && grandparent.kind === 254 /* ClassDeclaration */; } return false; } @@ -15181,10 +15560,10 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 - case 165 /* MethodDeclaration */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 170 /* SetAccessor */: return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); // TODO: GH#18217 default: return false; @@ -15193,9 +15572,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 275 /* JsxOpeningElement */ || - parent.kind === 274 /* JsxSelfClosingElement */ || - parent.kind === 276 /* JsxClosingElement */) { + if (parent.kind === 277 /* JsxOpeningElement */ || + parent.kind === 276 /* JsxSelfClosingElement */ || + parent.kind === 278 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -15203,49 +15582,54 @@ var ts; ts.isJSXTagName = isJSXTagName; function isExpressionNode(node) { switch (node.kind) { - case 105 /* SuperKeyword */: - case 103 /* NullKeyword */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: + case 106 /* SuperKeyword */: + case 104 /* NullKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: case 13 /* RegularExpressionLiteral */: - case 199 /* ArrayLiteralExpression */: - case 200 /* ObjectLiteralExpression */: - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: - case 203 /* CallExpression */: - case 204 /* NewExpression */: - case 205 /* TaggedTemplateExpression */: - case 224 /* AsExpression */: - case 206 /* TypeAssertionExpression */: - case 225 /* NonNullExpression */: - case 207 /* ParenthesizedExpression */: - case 208 /* FunctionExpression */: - case 221 /* ClassExpression */: - case 209 /* ArrowFunction */: - case 212 /* VoidExpression */: - case 210 /* DeleteExpression */: - case 211 /* TypeOfExpression */: - case 214 /* PrefixUnaryExpression */: - case 215 /* PostfixUnaryExpression */: - case 216 /* BinaryExpression */: - case 217 /* ConditionalExpression */: - case 220 /* SpreadElement */: - case 218 /* TemplateExpression */: - case 222 /* OmittedExpression */: - case 273 /* JsxElement */: - case 274 /* JsxSelfClosingElement */: - case 277 /* JsxFragment */: - case 219 /* YieldExpression */: - case 213 /* AwaitExpression */: - case 226 /* MetaProperty */: + case 201 /* ArrayLiteralExpression */: + case 202 /* ObjectLiteralExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: + case 207 /* TaggedTemplateExpression */: + case 226 /* AsExpression */: + case 208 /* TypeAssertionExpression */: + case 227 /* NonNullExpression */: + case 209 /* ParenthesizedExpression */: + case 210 /* FunctionExpression */: + case 223 /* ClassExpression */: + case 211 /* ArrowFunction */: + case 214 /* VoidExpression */: + case 212 /* DeleteExpression */: + case 213 /* TypeOfExpression */: + case 216 /* PrefixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: + case 218 /* BinaryExpression */: + case 219 /* ConditionalExpression */: + case 222 /* SpreadElement */: + case 220 /* TemplateExpression */: + case 224 /* OmittedExpression */: + case 275 /* JsxElement */: + case 276 /* JsxSelfClosingElement */: + case 279 /* JsxFragment */: + case 221 /* YieldExpression */: + case 215 /* AwaitExpression */: + case 228 /* MetaProperty */: return true; - case 157 /* QualifiedName */: - while (node.parent.kind === 157 /* QualifiedName */) { + case 159 /* QualifiedName */: + while (node.parent.kind === 159 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 176 /* TypeQuery */ || isJSXTagName(node); - case 78 /* Identifier */: - if (node.parent.kind === 176 /* TypeQuery */ || isJSXTagName(node)) { + return node.parent.kind === 178 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); + case 305 /* JSDocMemberName */: + while (ts.isJSDocMemberName(node.parent)) { + node = node.parent; + } + return node.parent.kind === 178 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); + case 79 /* Identifier */: + if (node.parent.kind === 178 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node)) { return true; } // falls through @@ -15253,7 +15637,7 @@ var ts; case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: return isInExpressionContext(node); default: return false; @@ -15263,49 +15647,49 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 249 /* VariableDeclaration */: - case 160 /* Parameter */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 291 /* EnumMember */: - case 288 /* PropertyAssignment */: - case 198 /* BindingElement */: + case 251 /* VariableDeclaration */: + case 162 /* Parameter */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 293 /* EnumMember */: + case 290 /* PropertyAssignment */: + case 200 /* BindingElement */: return parent.initializer === node; - case 233 /* ExpressionStatement */: - case 234 /* IfStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: - case 242 /* ReturnStatement */: - case 243 /* WithStatement */: - case 244 /* SwitchStatement */: - case 284 /* CaseClause */: - case 246 /* ThrowStatement */: + case 235 /* ExpressionStatement */: + case 236 /* IfStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: + case 244 /* ReturnStatement */: + case 245 /* WithStatement */: + case 246 /* SwitchStatement */: + case 286 /* CaseClause */: + case 248 /* ThrowStatement */: return parent.expression === node; - case 237 /* ForStatement */: + case 239 /* ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 250 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 252 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 250 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 252 /* VariableDeclarationList */) || forInStatement.expression === node; - case 206 /* TypeAssertionExpression */: - case 224 /* AsExpression */: + case 208 /* TypeAssertionExpression */: + case 226 /* AsExpression */: return node === parent.expression; - case 228 /* TemplateSpan */: + case 230 /* TemplateSpan */: return node === parent.expression; - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return node === parent.expression; - case 161 /* Decorator */: - case 283 /* JsxExpression */: - case 282 /* JsxSpreadAttribute */: - case 290 /* SpreadAssignment */: + case 163 /* Decorator */: + case 285 /* JsxExpression */: + case 284 /* JsxSpreadAttribute */: + case 292 /* SpreadAssignment */: return true; - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return parent.objectAssignmentInitializer === node; default: return isExpressionNode(parent); @@ -15313,14 +15697,18 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isPartOfTypeQuery(node) { - while (node.kind === 157 /* QualifiedName */ || node.kind === 78 /* Identifier */) { + while (node.kind === 159 /* QualifiedName */ || node.kind === 79 /* Identifier */) { node = node.parent; } - return node.kind === 176 /* TypeQuery */; + return node.kind === 178 /* TypeQuery */; } ts.isPartOfTypeQuery = isPartOfTypeQuery; + function isNamespaceReexportDeclaration(node) { + return ts.isNamespaceExport(node) && !!node.parent.moduleSpecifier; + } + ts.isNamespaceReexportDeclaration = isNamespaceReexportDeclaration; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 260 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 272 /* ExternalModuleReference */; + return node.kind === 262 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 274 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -15329,12 +15717,11 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function getExternalModuleRequireArgument(node) { - return isRequireVariableDeclaration(node, /*requireStringLiteralLikeArgument*/ true) - && getLeftmostAccessExpression(node.initializer).arguments[0]; + return isRequireVariableDeclaration(node) && getLeftmostAccessExpression(node.initializer).arguments[0]; } ts.getExternalModuleRequireArgument = getExternalModuleRequireArgument; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 260 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 272 /* ExternalModuleReference */; + return node.kind === 262 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 274 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJS(file) { @@ -15366,15 +15753,15 @@ var ts; ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && node.typeArguments && node.typeArguments.length === 2 && - (node.typeArguments[0].kind === 147 /* StringKeyword */ || node.typeArguments[0].kind === 144 /* NumberKeyword */); + (node.typeArguments[0].kind === 148 /* StringKeyword */ || node.typeArguments[0].kind === 145 /* NumberKeyword */); } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, requireStringLiteralLikeArgument) { - if (callExpression.kind !== 203 /* CallExpression */) { + if (callExpression.kind !== 205 /* CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; - if (expression.kind !== 78 /* Identifier */ || expression.escapedText !== "require") { + if (expression.kind !== 79 /* Identifier */ || expression.escapedText !== "require") { return false; } if (args.length !== 1) { @@ -15384,18 +15771,21 @@ var ts; return !requireStringLiteralLikeArgument || ts.isStringLiteralLike(arg); } ts.isRequireCall = isRequireCall; - function isRequireVariableDeclaration(node, requireStringLiteralLikeArgument) { - if (node.kind === 198 /* BindingElement */) { + /** + * Returns true if the node is a VariableDeclaration initialized to a require call (see `isRequireCall`). + * This function does not test if the node is in a JavaScript file or not. + */ + function isRequireVariableDeclaration(node) { + if (node.kind === 200 /* BindingElement */) { node = node.parent.parent; } - return ts.isVariableDeclaration(node) && !!node.initializer && isRequireCall(getLeftmostAccessExpression(node.initializer), requireStringLiteralLikeArgument); + return ts.isVariableDeclaration(node) && !!node.initializer && isRequireCall(getLeftmostAccessExpression(node.initializer), /*requireStringLiteralLikeArgument*/ true); } ts.isRequireVariableDeclaration = isRequireVariableDeclaration; - function isRequireVariableStatement(node, requireStringLiteralLikeArgument) { - if (requireStringLiteralLikeArgument === void 0) { requireStringLiteralLikeArgument = true; } + function isRequireVariableStatement(node) { return ts.isVariableStatement(node) && node.declarationList.declarations.length > 0 - && ts.every(node.declarationList.declarations, function (decl) { return isRequireVariableDeclaration(decl, requireStringLiteralLikeArgument); }); + && ts.every(node.declarationList.declarations, function (decl) { return isRequireVariableDeclaration(decl); }); } ts.isRequireVariableStatement = isRequireVariableStatement; function isSingleOrDoubleQuote(charCode) { @@ -15441,7 +15831,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 === 62 /* EqualsToken */) { + if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* EqualsToken */) { var isPrototypeAssignment = isPrototypeAccess(node.parent.left); return getExpandoInitializer(node.parent.right, isPrototypeAssignment) || getDefaultedExpandoInitializer(node.parent.left, node.parent.right, isPrototypeAssignment); @@ -15467,11 +15857,11 @@ var ts; function getExpandoInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 208 /* FunctionExpression */ || e.kind === 209 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 210 /* FunctionExpression */ || e.kind === 211 /* ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 208 /* FunctionExpression */ || - initializer.kind === 221 /* ClassExpression */ || - initializer.kind === 209 /* ArrowFunction */) { + if (initializer.kind === 210 /* FunctionExpression */ || + initializer.kind === 223 /* ClassExpression */ || + initializer.kind === 211 /* ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -15497,7 +15887,7 @@ var ts; } function isDefaultedExpandoInitializer(node) { var name = ts.isVariableDeclaration(node.parent) ? node.parent.name : - ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 /* EqualsToken */ ? node.parent.left : + ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* EqualsToken */ ? node.parent.left : undefined; return name && getExpandoInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left); } @@ -15506,7 +15896,7 @@ var ts; 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 === 62 /* EqualsToken */ && ts.isIdentifier(parent.left)) { + if (parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isIdentifier(parent.left)) { return parent.left; } } @@ -15529,7 +15919,7 @@ var ts; return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(initializer); } if (ts.isIdentifier(name) && isLiteralLikeAccess(initializer) && - (initializer.expression.kind === 107 /* ThisKeyword */ || + (initializer.expression.kind === 108 /* ThisKeyword */ || ts.isIdentifier(initializer.expression) && (initializer.expression.escapedText === "window" || initializer.expression.escapedText === "self" || @@ -15592,20 +15982,19 @@ var ts; ts.isLiteralLikeAccess = isLiteralLikeAccess; /** x[0] OR x['a'] OR x[Symbol.y] */ function isLiteralLikeElementAccess(node) { - return ts.isElementAccessExpression(node) && (isStringOrNumericLiteralLike(node.argumentExpression) || - isWellKnownSymbolSyntactically(node.argumentExpression)); + return ts.isElementAccessExpression(node) && isStringOrNumericLiteralLike(node.argumentExpression); } ts.isLiteralLikeElementAccess = isLiteralLikeElementAccess; /** Any series of property and element accesses. */ function isBindableStaticAccessExpression(node, excludeThisKeyword) { - return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 107 /* ThisKeyword */ || ts.isIdentifier(node.name) && isBindableStaticNameExpression(node.expression, /*excludeThisKeyword*/ true)) + return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 108 /* 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 === 107 /* ThisKeyword */) || + && ((!excludeThisKeyword && node.expression.kind === 108 /* ThisKeyword */) || isEntityNameExpression(node.expression) || isBindableStaticAccessExpression(node.expression, /*excludeThisKeyword*/ true)); } @@ -15635,7 +16024,7 @@ var ts; } return 7 /* ObjectDefinePropertyValue */; } - if (expr.operatorToken.kind !== 62 /* EqualsToken */ || !isAccessExpression(expr.left) || isVoidZero(getRightMostAssignedExpression(expr))) { + if (expr.operatorToken.kind !== 63 /* EqualsToken */ || !isAccessExpression(expr.left) || isVoidZero(getRightMostAssignedExpression(expr))) { return 0 /* None */; } if (isBindableStaticNameExpression(expr.left.expression, /*excludeThisKeyword*/ true) && getElementOrPropertyAccessName(expr.left) === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { @@ -15673,14 +16062,11 @@ var ts; return ts.escapeLeadingUnderscores(name.text); } } - if (ts.isElementAccessExpression(node) && isWellKnownSymbolSyntactically(node.argumentExpression)) { - return getPropertyNameForKnownSymbolName(ts.idText(node.argumentExpression.name)); - } return undefined; } ts.getElementOrPropertyAccessName = getElementOrPropertyAccessName; function getAssignmentDeclarationPropertyAccessKind(lhs) { - if (lhs.expression.kind === 107 /* ThisKeyword */) { + if (lhs.expression.kind === 108 /* ThisKeyword */) { return 4 /* ThisProperty */; } else if (isModuleExportsAccessExpression(lhs)) { @@ -15725,7 +16111,7 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJSFile(expr) && - expr.parent && expr.parent.kind === 233 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 235 /* ExpressionStatement */ && (!ts.isElementAccessExpression(expr) || isLiteralLikeElementAccess(expr)) && !!ts.getJSDocTypeTag(expr.parent); } @@ -15746,23 +16132,37 @@ var ts; return false; } var decl = symbol.valueDeclaration; - return decl.kind === 251 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); + return decl.kind === 253 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); } ts.isFunctionSymbol = isFunctionSymbol; + function tryGetModuleSpecifierFromDeclaration(node) { + var _a, _b, _c; + switch (node.kind) { + case 251 /* VariableDeclaration */: + return node.initializer.arguments[0].text; + case 263 /* ImportDeclaration */: + return (_a = ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike)) === null || _a === void 0 ? void 0 : _a.text; + case 262 /* ImportEqualsDeclaration */: + return (_c = ts.tryCast((_b = ts.tryCast(node.moduleReference, ts.isExternalModuleReference)) === null || _b === void 0 ? void 0 : _b.expression, ts.isStringLiteralLike)) === null || _c === void 0 ? void 0 : _c.text; + default: + ts.Debug.assertNever(node); + } + } + ts.tryGetModuleSpecifierFromDeclaration = tryGetModuleSpecifierFromDeclaration; function importFromModuleSpecifier(node) { return tryGetImportFromModuleSpecifier(node) || ts.Debug.failBadSyntaxKind(node.parent); } ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 261 /* ImportDeclaration */: - case 267 /* ExportDeclaration */: + case 263 /* ImportDeclaration */: + case 269 /* ExportDeclaration */: return node.parent; - case 272 /* ExternalModuleReference */: + case 274 /* ExternalModuleReference */: return node.parent.parent; - case 203 /* CallExpression */: + case 205 /* CallExpression */: return isImportCall(node.parent) || isRequireCall(node.parent, /*checkArg*/ false) ? node.parent : undefined; - case 191 /* LiteralType */: + case 193 /* LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -15772,15 +16172,17 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: - case 267 /* ExportDeclaration */: + case 263 /* ImportDeclaration */: + case 269 /* ExportDeclaration */: return node.moduleSpecifier; - case 260 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 272 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 195 /* ImportType */: + case 262 /* ImportEqualsDeclaration */: + return node.moduleReference.kind === 274 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 197 /* ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; - case 203 /* CallExpression */: + case 205 /* CallExpression */: return node.arguments[0]; + case 258 /* ModuleDeclaration */: + return node.name.kind === 10 /* StringLiteral */ ? node.name : undefined; default: return ts.Debug.assertNever(node); } @@ -15788,11 +16190,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return node; - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: return node.exportClause && ts.tryCast(node.exportClause, ts.isNamespaceExport); default: return ts.Debug.assertNever(node); @@ -15800,7 +16202,7 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 261 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 263 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function forEachImportClauseDeclaration(node, action) { @@ -15821,13 +16223,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 160 /* Parameter */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 289 /* ShorthandPropertyAssignment */: - case 288 /* PropertyAssignment */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 162 /* Parameter */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 291 /* ShorthandPropertyAssignment */: + case 290 /* PropertyAssignment */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -15841,7 +16243,7 @@ var ts; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 331 /* JSDocTypedefTag */ || node.kind === 324 /* JSDocCallbackTag */ || node.kind === 325 /* JSDocEnumTag */; + return node.kind === 339 /* JSDocTypedefTag */ || node.kind === 332 /* JSDocCallbackTag */ || node.kind === 333 /* JSDocEnumTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -15851,7 +16253,7 @@ var ts; function getSourceOfAssignment(node) { return ts.isExpressionStatement(node) && ts.isBinaryExpression(node.expression) && - node.expression.operatorToken.kind === 62 /* EqualsToken */ + node.expression.operatorToken.kind === 63 /* EqualsToken */ ? getRightMostAssignedExpression(node.expression) : undefined; } @@ -15866,12 +16268,12 @@ var ts; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return node.initializer; - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: return node.initializer; } } @@ -15883,7 +16285,7 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 256 /* ModuleDeclaration */ + node.body.kind === 258 /* ModuleDeclaration */ ? node.body : undefined; } @@ -15898,11 +16300,11 @@ var ts; if (ts.hasJSDocNodes(node)) { result = ts.append(result, ts.last(node.jsDoc)); } - if (node.kind === 160 /* Parameter */) { + if (node.kind === 162 /* Parameter */) { result = ts.addRange(result, (noCache ? ts.getJSDocParameterTagsNoCache : ts.getJSDocParameterTags)(node)); break; } - if (node.kind === 159 /* TypeParameter */) { + if (node.kind === 161 /* TypeParameter */) { result = ts.addRange(result, (noCache ? ts.getJSDocTypeParameterTagsNoCache : ts.getJSDocTypeParameterTags)(node)); break; } @@ -15913,12 +16315,13 @@ var ts; ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; function getNextJSDocCommentLocation(node) { var parent = node.parent; - if (parent.kind === 288 /* PropertyAssignment */ || - parent.kind === 266 /* ExportAssignment */ || - parent.kind === 163 /* PropertyDeclaration */ || - parent.kind === 233 /* ExpressionStatement */ && node.kind === 201 /* PropertyAccessExpression */ || + if (parent.kind === 290 /* PropertyAssignment */ || + parent.kind === 268 /* ExportAssignment */ || + parent.kind === 165 /* PropertyDeclaration */ || + parent.kind === 235 /* ExpressionStatement */ && node.kind === 203 /* PropertyAccessExpression */ || + parent.kind === 244 /* ReturnStatement */ || getNestedModuleDeclaration(parent) || - ts.isBinaryExpression(node) && node.operatorToken.kind === 62 /* EqualsToken */) { + ts.isBinaryExpression(node) && node.operatorToken.kind === 63 /* EqualsToken */) { return parent; } // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. @@ -15929,7 +16332,7 @@ var ts; // var x = function(name) { return name.length; } else if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node || - ts.isBinaryExpression(parent) && parent.operatorToken.kind === 62 /* EqualsToken */)) { + ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */)) { return parent.parent; } else if (parent.parent && parent.parent.parent && @@ -15953,7 +16356,7 @@ var ts; if (!decl) { return undefined; } - var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 78 /* Identifier */ && p.name.escapedText === name; }); + var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 79 /* Identifier */ && p.name.escapedText === name; }); return parameter && parameter.symbol; } ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc; @@ -16003,7 +16406,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 === 309 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 312 /* JSDocVariadicType */; } ts.isRestParameter = isRestParameter; function hasTypeArguments(node) { @@ -16020,31 +16423,34 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 62 /* EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* Definite */ : 2 /* Compound */ : + binaryOperator === 63 /* EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; - case 214 /* PrefixUnaryExpression */: - case 215 /* PostfixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; return unaryOperator === 45 /* PlusPlusToken */ || unaryOperator === 46 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 207 /* ParenthesizedExpression */: - case 199 /* ArrayLiteralExpression */: - case 220 /* SpreadElement */: - case 225 /* NonNullExpression */: + case 209 /* ParenthesizedExpression */: + case 201 /* ArrayLiteralExpression */: + case 222 /* SpreadElement */: + case 227 /* NonNullExpression */: node = parent; break; - case 289 /* ShorthandPropertyAssignment */: + case 292 /* SpreadAssignment */: + node = parent.parent; + break; + case 291 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } node = parent.parent; break; - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: if (parent.name === node) { return 0 /* None */; } @@ -16071,22 +16477,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 230 /* Block */: - case 232 /* VariableStatement */: - case 243 /* WithStatement */: - case 234 /* IfStatement */: - case 244 /* SwitchStatement */: - case 258 /* CaseBlock */: - case 284 /* CaseClause */: - case 285 /* DefaultClause */: - case 245 /* LabeledStatement */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: - case 247 /* TryStatement */: - case 287 /* CatchClause */: + case 232 /* Block */: + case 234 /* VariableStatement */: + case 245 /* WithStatement */: + case 236 /* IfStatement */: + case 246 /* SwitchStatement */: + case 260 /* CaseBlock */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: + case 247 /* LabeledStatement */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: + case 249 /* TryStatement */: + case 289 /* CatchClause */: return true; } return false; @@ -16103,11 +16509,11 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 186 /* ParenthesizedType */); + return walkUp(node, 188 /* ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 207 /* ParenthesizedExpression */); + return walkUp(node, 209 /* ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; /** @@ -16117,7 +16523,7 @@ var ts; */ function walkUpParenthesizedTypesAndGetParentAndChild(node) { var child; - while (node && node.kind === 186 /* ParenthesizedType */) { + while (node && node.kind === 188 /* ParenthesizedType */) { child = node; node = node.parent; } @@ -16128,19 +16534,13 @@ var ts; return ts.skipOuterExpressions(node, 1 /* Parentheses */); } ts.skipParentheses = skipParentheses; - function skipParenthesesUp(node) { - while (node.kind === 207 /* ParenthesizedExpression */) { - node = node.parent; - } - return node; - } // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped function isDeleteTarget(node) { - if (node.kind !== 201 /* PropertyAccessExpression */ && node.kind !== 202 /* ElementAccessExpression */) { + if (node.kind !== 203 /* PropertyAccessExpression */ && node.kind !== 204 /* ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 210 /* DeleteExpression */; + return node && node.kind === 212 /* DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -16167,7 +16567,7 @@ var ts; if (ts.isComputedPropertyName(parent)) return parent.parent; // falls through - case 78 /* Identifier */: + case 79 /* Identifier */: if (ts.isDeclaration(parent)) { return parent.name === name ? parent : undefined; } @@ -16184,7 +16584,7 @@ var ts; ? binExp : undefined; } - case 79 /* PrivateIdentifier */: + case 80 /* PrivateIdentifier */: return ts.isDeclaration(parent) && parent.name === name ? parent : undefined; default: return undefined; @@ -16193,7 +16593,7 @@ var ts; ts.getDeclarationFromName = getDeclarationFromName; function isLiteralComputedPropertyDeclarationName(node) { return isStringOrNumericLiteralLike(node) && - node.parent.kind === 158 /* ComputedPropertyName */ && + node.parent.kind === 160 /* ComputedPropertyName */ && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -16201,26 +16601,26 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 291 /* EnumMember */: - case 288 /* PropertyAssignment */: - case 201 /* PropertyAccessExpression */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 293 /* EnumMember */: + case 290 /* PropertyAssignment */: + case 203 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 157 /* QualifiedName */: + case 159 /* QualifiedName */: // Name on right hand side of dot in a type query or type reference return parent.right === node; - case 198 /* BindingElement */: - case 265 /* ImportSpecifier */: + case 200 /* BindingElement */: + case 267 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 270 /* ExportSpecifier */: - case 280 /* JsxAttribute */: + case 272 /* ExportSpecifier */: + case 282 /* JsxAttribute */: // Any name in an export specifier or JSX Attribute return true; } @@ -16240,33 +16640,33 @@ var ts; // {} // {name: } function isAliasSymbolDeclaration(node) { - return node.kind === 260 /* ImportEqualsDeclaration */ || - node.kind === 259 /* NamespaceExportDeclaration */ || - node.kind === 262 /* ImportClause */ && !!node.name || - node.kind === 263 /* NamespaceImport */ || - node.kind === 269 /* NamespaceExport */ || - node.kind === 265 /* ImportSpecifier */ || - node.kind === 270 /* ExportSpecifier */ || - node.kind === 266 /* ExportAssignment */ && exportAssignmentIsAlias(node) || + return node.kind === 262 /* ImportEqualsDeclaration */ || + node.kind === 261 /* NamespaceExportDeclaration */ || + node.kind === 264 /* ImportClause */ && !!node.name || + node.kind === 265 /* NamespaceImport */ || + node.kind === 271 /* NamespaceExport */ || + node.kind === 267 /* ImportSpecifier */ || + node.kind === 272 /* ExportSpecifier */ || + node.kind === 268 /* ExportAssignment */ && exportAssignmentIsAlias(node) || ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) || - ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62 /* EqualsToken */ && isAliasableExpression(node.parent.right) || - node.kind === 289 /* ShorthandPropertyAssignment */ || - node.kind === 288 /* PropertyAssignment */ && isAliasableExpression(node.initializer); + ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* EqualsToken */ && isAliasableExpression(node.parent.right) || + node.kind === 291 /* ShorthandPropertyAssignment */ || + node.kind === 290 /* PropertyAssignment */ && isAliasableExpression(node.initializer); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getAliasDeclarationFromName(node) { switch (node.parent.kind) { - case 262 /* ImportClause */: - case 265 /* ImportSpecifier */: - case 263 /* NamespaceImport */: - case 270 /* ExportSpecifier */: - case 266 /* ExportAssignment */: - case 260 /* ImportEqualsDeclaration */: + case 264 /* ImportClause */: + case 267 /* ImportSpecifier */: + case 265 /* NamespaceImport */: + case 272 /* ExportSpecifier */: + case 268 /* ExportAssignment */: + case 262 /* ImportEqualsDeclaration */: return node.parent; - case 157 /* QualifiedName */: + case 159 /* QualifiedName */: do { node = node.parent; - } while (node.parent.kind === 157 /* QualifiedName */); + } while (node.parent.kind === 159 /* QualifiedName */); return getAliasDeclarationFromName(node); } } @@ -16285,7 +16685,7 @@ var ts; } ts.getExportAssignmentExpression = getExportAssignmentExpression; function getPropertyAssignmentAliasLikeExpression(node) { - return node.kind === 289 /* ShorthandPropertyAssignment */ ? node.name : node.kind === 288 /* PropertyAssignment */ ? node.initializer : + return node.kind === 291 /* ShorthandPropertyAssignment */ ? node.name : node.kind === 290 /* PropertyAssignment */ ? node.initializer : node.parent.right; } ts.getPropertyAssignmentAliasLikeExpression = getPropertyAssignmentAliasLikeExpression; @@ -16302,7 +16702,7 @@ var ts; } ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode; function getClassExtendsHeritageElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 93 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 94 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement; @@ -16311,7 +16711,7 @@ var ts; return ts.getJSDocImplementsTags(node).map(function (n) { return n.class; }); } else { - var heritageClause = getHeritageClause(node.heritageClauses, 116 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 117 /* ImplementsKeyword */); return heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.types; } } @@ -16324,7 +16724,7 @@ var ts; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 93 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 94 /* ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -16351,11 +16751,11 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 80 /* FirstKeyword */ <= token && token <= 156 /* LastKeyword */; + return 81 /* FirstKeyword */ <= token && token <= 158 /* LastKeyword */; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 125 /* FirstContextualKeyword */ <= token && token <= 156 /* LastContextualKeyword */; + return 126 /* FirstContextualKeyword */ <= token && token <= 158 /* LastContextualKeyword */; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { @@ -16363,7 +16763,7 @@ var ts; } ts.isNonContextualKeyword = isNonContextualKeyword; function isFutureReservedKeyword(token) { - return 116 /* FirstFutureReservedWord */ <= token && token <= 124 /* LastFutureReservedWord */; + return 117 /* FirstFutureReservedWord */ <= token && token <= 125 /* LastFutureReservedWord */; } ts.isFutureReservedKeyword = isFutureReservedKeyword; function isStringANonContextualKeyword(name) { @@ -16399,14 +16799,14 @@ var ts; } var flags = 0 /* Normal */; switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 165 /* MethodDeclaration */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 167 /* MethodDeclaration */: if (node.asteriskToken) { flags |= 1 /* Generator */; } // falls through - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: if (hasSyntacticModifier(node, 256 /* Async */)) { flags |= 2 /* Async */; } @@ -16420,10 +16820,10 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 167 /* MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined && hasSyntacticModifier(node, 256 /* Async */); @@ -16446,9 +16846,6 @@ var ts; * 3. The computed name is *not* expressed as a NumericLiteral. * 4. The computed name is *not* expressed as a PlusToken or MinusToken * immediately followed by a NumericLiteral. - * 5. The computed name is *not* expressed as `Symbol.`, where `` - * is a property of the Symbol constructor that denotes a built-in - * Symbol. */ function hasDynamicName(declaration) { var name = ts.getNameOfDeclaration(declaration); @@ -16456,38 +16853,25 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - if (!(name.kind === 158 /* ComputedPropertyName */ || name.kind === 202 /* ElementAccessExpression */)) { + if (!(name.kind === 160 /* ComputedPropertyName */ || name.kind === 204 /* ElementAccessExpression */)) { return false; } var expr = ts.isElementAccessExpression(name) ? skipParentheses(name.argumentExpression) : name.expression; return !isStringOrNumericLiteralLike(expr) && - !isSignedNumericLiteral(expr) && - !isWellKnownSymbolSyntactically(expr); + !isSignedNumericLiteral(expr); } ts.isDynamicName = isDynamicName; - /** - * Checks if the expression is of the form: - * Symbol.name - * where Symbol is literally the word "Symbol", and name is any identifierName - */ - function isWellKnownSymbolSyntactically(node) { - return ts.isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression); - } - ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { switch (name.kind) { - case 78 /* Identifier */: - case 79 /* PrivateIdentifier */: + case 79 /* Identifier */: + case 80 /* PrivateIdentifier */: return name.escapedText; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: var nameExpression = name.expression; - if (isWellKnownSymbolSyntactically(nameExpression)) { - return getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); - } - else if (isStringOrNumericLiteralLike(nameExpression)) { + if (isStringOrNumericLiteralLike(nameExpression)) { return ts.escapeLeadingUnderscores(nameExpression.text); } else if (isSignedNumericLiteral(nameExpression)) { @@ -16504,7 +16888,7 @@ var ts; ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; function isPropertyNameLiteral(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: @@ -16515,21 +16899,17 @@ var ts; } ts.isPropertyNameLiteral = isPropertyNameLiteral; function getTextOfIdentifierOrLiteral(node) { - return ts.isIdentifierOrPrivateIdentifier(node) ? ts.idText(node) : node.text; + return ts.isMemberName(node) ? ts.idText(node) : node.text; } ts.getTextOfIdentifierOrLiteral = getTextOfIdentifierOrLiteral; function getEscapedTextOfIdentifierOrLiteral(node) { - return ts.isIdentifierOrPrivateIdentifier(node) ? node.escapedText : ts.escapeLeadingUnderscores(node.text); + return ts.isMemberName(node) ? node.escapedText : ts.escapeLeadingUnderscores(node.text); } ts.getEscapedTextOfIdentifierOrLiteral = getEscapedTextOfIdentifierOrLiteral; function getPropertyNameForUniqueESSymbol(symbol) { return "__@" + ts.getSymbolId(symbol) + "@" + symbol.escapedName; } ts.getPropertyNameForUniqueESSymbol = getPropertyNameForUniqueESSymbol; - function getPropertyNameForKnownSymbolName(symbolName) { - return "__@" + symbolName; - } - ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; function getSymbolNameForPrivateIdentifier(containingClassSymbol, description) { return "__#" + ts.getSymbolId(containingClassSymbol) + "@" + description; } @@ -16542,7 +16922,7 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 78 /* Identifier */ && node.escapedText === "Symbol"; + return node.kind === 79 /* Identifier */ && node.escapedText === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isPushOrUnshiftIdentifier(node) { @@ -16551,11 +16931,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 160 /* Parameter */; + return root.kind === 162 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 198 /* BindingElement */) { + while (node.kind === 200 /* BindingElement */) { node = node.parent.parent; } return node; @@ -16563,15 +16943,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 166 /* Constructor */ - || kind === 208 /* FunctionExpression */ - || kind === 251 /* FunctionDeclaration */ - || kind === 209 /* ArrowFunction */ - || kind === 165 /* MethodDeclaration */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */ - || kind === 256 /* ModuleDeclaration */ - || kind === 297 /* SourceFile */; + return kind === 168 /* Constructor */ + || kind === 210 /* FunctionExpression */ + || kind === 253 /* FunctionDeclaration */ + || kind === 211 /* ArrowFunction */ + || kind === 167 /* MethodDeclaration */ + || kind === 169 /* GetAccessor */ + || kind === 170 /* SetAccessor */ + || kind === 258 /* ModuleDeclaration */ + || kind === 299 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -16590,41 +16970,41 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 204 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 206 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 204 /* NewExpression */: + case 206 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 214 /* PrefixUnaryExpression */: - case 211 /* TypeOfExpression */: - case 212 /* VoidExpression */: - case 210 /* DeleteExpression */: - case 213 /* AwaitExpression */: - case 217 /* ConditionalExpression */: - case 219 /* YieldExpression */: + case 216 /* PrefixUnaryExpression */: + case 213 /* TypeOfExpression */: + case 214 /* VoidExpression */: + case 212 /* DeleteExpression */: + case 215 /* AwaitExpression */: + case 219 /* ConditionalExpression */: + case 221 /* YieldExpression */: return 1 /* Right */; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: switch (operator) { case 42 /* AsteriskAsteriskToken */: - case 62 /* EqualsToken */: - case 63 /* PlusEqualsToken */: - case 64 /* MinusEqualsToken */: - case 66 /* AsteriskAsteriskEqualsToken */: - case 65 /* AsteriskEqualsToken */: - case 67 /* SlashEqualsToken */: - case 68 /* PercentEqualsToken */: - case 69 /* LessThanLessThanEqualsToken */: - case 70 /* GreaterThanGreaterThanEqualsToken */: - case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 72 /* AmpersandEqualsToken */: - case 77 /* CaretEqualsToken */: - case 73 /* BarEqualsToken */: - case 74 /* BarBarEqualsToken */: - case 75 /* AmpersandAmpersandEqualsToken */: - case 76 /* QuestionQuestionEqualsToken */: + 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 */; } } @@ -16633,15 +17013,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 204 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 206 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 216 /* BinaryExpression */) { + if (expression.kind === 218 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 214 /* PrefixUnaryExpression */ || expression.kind === 215 /* PostfixUnaryExpression */) { + else if (expression.kind === 216 /* PrefixUnaryExpression */ || expression.kind === 217 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -16820,81 +17200,82 @@ var ts; })(OperatorPrecedence = ts.OperatorPrecedence || (ts.OperatorPrecedence = {})); function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 337 /* CommaListExpression */: + case 345 /* CommaListExpression */: return 0 /* Comma */; - case 220 /* SpreadElement */: + case 222 /* SpreadElement */: return 1 /* Spread */; - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: return 2 /* Yield */; - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: return 4 /* Conditional */; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: switch (operatorKind) { case 27 /* CommaToken */: return 0 /* Comma */; - case 62 /* EqualsToken */: - case 63 /* PlusEqualsToken */: - case 64 /* MinusEqualsToken */: - case 66 /* AsteriskAsteriskEqualsToken */: - case 65 /* AsteriskEqualsToken */: - case 67 /* SlashEqualsToken */: - case 68 /* PercentEqualsToken */: - case 69 /* LessThanLessThanEqualsToken */: - case 70 /* GreaterThanGreaterThanEqualsToken */: - case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 72 /* AmpersandEqualsToken */: - case 77 /* CaretEqualsToken */: - case 73 /* BarEqualsToken */: - case 74 /* BarBarEqualsToken */: - case 75 /* AmpersandAmpersandEqualsToken */: - case 76 /* QuestionQuestionEqualsToken */: + 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 */; default: return getBinaryOperatorPrecedence(operatorKind); } // TODO: Should prefix `++` and `--` be moved to the `Update` precedence? - case 206 /* TypeAssertionExpression */: - case 225 /* NonNullExpression */: - case 214 /* PrefixUnaryExpression */: - case 211 /* TypeOfExpression */: - case 212 /* VoidExpression */: - case 210 /* DeleteExpression */: - case 213 /* AwaitExpression */: + case 208 /* TypeAssertionExpression */: + case 227 /* NonNullExpression */: + case 216 /* PrefixUnaryExpression */: + case 213 /* TypeOfExpression */: + case 214 /* VoidExpression */: + case 212 /* DeleteExpression */: + case 215 /* AwaitExpression */: return 16 /* Unary */; - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: return 17 /* Update */; - case 203 /* CallExpression */: + case 205 /* CallExpression */: return 18 /* LeftHandSide */; - case 204 /* NewExpression */: + case 206 /* NewExpression */: return hasArguments ? 19 /* Member */ : 18 /* LeftHandSide */; - case 205 /* TaggedTemplateExpression */: - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 207 /* TaggedTemplateExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: + case 228 /* MetaProperty */: return 19 /* Member */; - case 224 /* AsExpression */: + case 226 /* AsExpression */: return 11 /* Relational */; - case 107 /* ThisKeyword */: - case 105 /* SuperKeyword */: - case 78 /* Identifier */: - case 103 /* NullKeyword */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: + case 108 /* ThisKeyword */: + case 106 /* SuperKeyword */: + case 79 /* Identifier */: + case 104 /* NullKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: - case 199 /* ArrayLiteralExpression */: - case 200 /* ObjectLiteralExpression */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 221 /* ClassExpression */: + case 201 /* ArrayLiteralExpression */: + case 202 /* ObjectLiteralExpression */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 223 /* ClassExpression */: case 13 /* RegularExpressionLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 218 /* TemplateExpression */: - case 207 /* ParenthesizedExpression */: - case 222 /* OmittedExpression */: - case 273 /* JsxElement */: - case 274 /* JsxSelfClosingElement */: - case 277 /* JsxFragment */: + case 220 /* TemplateExpression */: + case 209 /* ParenthesizedExpression */: + case 224 /* OmittedExpression */: + case 275 /* JsxElement */: + case 276 /* JsxSelfClosingElement */: + case 279 /* JsxFragment */: return 20 /* Primary */; default: return -1 /* Invalid */; @@ -16924,9 +17305,9 @@ var ts; case 31 /* GreaterThanToken */: case 32 /* LessThanEqualsToken */: case 33 /* GreaterThanEqualsToken */: - case 101 /* InstanceOfKeyword */: - case 100 /* InKeyword */: - case 126 /* AsKeyword */: + case 102 /* InstanceOfKeyword */: + case 101 /* InKeyword */: + case 127 /* AsKeyword */: return 11 /* Relational */; case 47 /* LessThanLessThanToken */: case 48 /* GreaterThanGreaterThanToken */: @@ -16950,7 +17331,7 @@ var ts; function getSemanticJsxChildren(children) { return ts.filter(children, function (i) { switch (i.kind) { - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: return !!i.expression; case 11 /* JsxText */: return !i.containsOnlyTriviaWhiteSpaces; @@ -17252,7 +17633,7 @@ var ts; reportInaccessibleThisError: ts.noop, reportPrivateInBaseOfClassExpression: ts.noop, reportInaccessibleUniqueSymbolError: ts.noop, - trackSymbol: ts.noop, + trackSymbol: function () { return false; }, writeKeyword: write, writeOperator: write, writeParameter: write, @@ -17344,11 +17725,20 @@ var ts; return file.moduleName || getExternalModuleNameFromPath(host, file.fileName, referenceFile && referenceFile.fileName); } ts.getResolvedExternalModuleName = getResolvedExternalModuleName; + function getCanonicalAbsolutePath(host, path) { + return host.getCanonicalFileName(ts.getNormalizedAbsolutePath(path, host.getCurrentDirectory())); + } function getExternalModuleNameFromDeclaration(host, resolver, declaration) { var file = resolver.getExternalModuleFileFromDeclaration(declaration); if (!file || file.isDeclarationFile) { return undefined; } + // If the declaration already uses a non-relative name, and is outside the common source directory, continue to use it + var specifier = getExternalModuleName(declaration); + if (specifier && ts.isStringLiteralLike(specifier) && !ts.pathIsRelative(specifier.text) && + getCanonicalAbsolutePath(host, file.path).indexOf(getCanonicalAbsolutePath(host, ts.ensureTrailingDirectorySeparator(host.getCommonSourceDirectory()))) === -1) { + return undefined; + } return getResolvedExternalModuleName(host, file); } ts.getExternalModuleNameFromDeclaration = getExternalModuleNameFromDeclaration; @@ -17432,8 +17822,8 @@ var ts; return !(options.noEmitForJsFiles && isSourceFileJS(sourceFile)) && !sourceFile.isDeclarationFile && !host.isSourceFileFromExternalLibrary(sourceFile) && - !(isJsonSourceFile(sourceFile) && host.getResolvedProjectReferenceToRedirect(sourceFile.fileName)) && - (forceDtsEmit || !host.isSourceOfProjectReferenceRedirect(sourceFile.fileName)); + (forceDtsEmit || (!(isJsonSourceFile(sourceFile) && host.getResolvedProjectReferenceToRedirect(sourceFile.fileName)) && + !host.isSourceOfProjectReferenceRedirect(sourceFile.fileName))); } ts.sourceFileMayBeEmitted = sourceFileMayBeEmitted; function getSourceFilePathInNewDir(fileName, host, newDirPath) { @@ -17513,11 +17903,11 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return !!node && node.kind === 78 /* Identifier */ && identifierIsThisKeyword(node); + return !!node && node.kind === 79 /* Identifier */ && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 107 /* ThisKeyword */; + return id.originalKeywordKind === 108 /* ThisKeyword */; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -17528,10 +17918,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 167 /* GetAccessor */) { + if (accessor.kind === 169 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 168 /* SetAccessor */) { + else if (accessor.kind === 170 /* SetAccessor */) { setAccessor = accessor; } else { @@ -17551,10 +17941,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 167 /* GetAccessor */ && !getAccessor) { + if (member.kind === 169 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 168 /* SetAccessor */ && !setAccessor) { + if (member.kind === 170 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -17603,7 +17993,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 === 311 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 314 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -17779,7 +18169,7 @@ var ts; ts.writeCommentRange = writeCommentRange; function writeTrimmedCurrentLine(text, commentEnd, writer, newLine, pos, nextLineStart) { var end = Math.min(commentEnd, nextLineStart - 1); - var currentLineText = text.substring(pos, end).replace(/^\s+|\s+$/g, ""); + var currentLineText = ts.trimString(text.substring(pos, end)); if (currentLineText) { // trimmed forward and ending spaces text writer.writeComment(currentLineText); @@ -17826,6 +18216,18 @@ var ts; return hasSyntacticModifier(node, 32 /* Static */); } ts.hasStaticModifier = hasStaticModifier; + function hasOverrideModifier(node) { + return hasEffectiveModifier(node, 16384 /* Override */); + } + ts.hasOverrideModifier = hasOverrideModifier; + function hasAbstractModifier(node) { + return hasSyntacticModifier(node, 128 /* Abstract */); + } + ts.hasAbstractModifier = hasAbstractModifier; + function hasAmbientModifier(node) { + return hasSyntacticModifier(node, 2 /* Ambient */); + } + ts.hasAmbientModifier = hasAmbientModifier; function hasEffectiveReadonlyModifier(node) { return hasEffectiveModifier(node, 64 /* Readonly */); } @@ -17839,7 +18241,7 @@ var ts; } ts.getSelectedSyntacticModifierFlags = getSelectedSyntacticModifierFlags; function getModifierFlagsWorker(node, includeJSDoc, alwaysIncludeJSDoc) { - if (node.kind >= 0 /* FirstToken */ && node.kind <= 156 /* LastToken */) { + if (node.kind >= 0 /* FirstToken */ && node.kind <= 158 /* LastToken */) { return 0 /* None */; } if (!(node.modifierFlagsCache & 536870912 /* HasComputedFlags */)) { @@ -17884,6 +18286,8 @@ var ts; flags |= 16 /* Protected */; if (ts.getJSDocReadonlyTagNoCache(node)) flags |= 64 /* Readonly */; + if (ts.getJSDocOverrideTagNoCache(node)) + flags |= 16384 /* Override */; } if (ts.getJSDocDeprecatedTagNoCache(node)) flags |= 8192 /* Deprecated */; @@ -17906,7 +18310,7 @@ var ts; */ function getSyntacticModifierFlagsNoCache(node) { var flags = modifiersToFlags(node.modifiers); - if (node.flags & 4 /* NestedNamespace */ || (node.kind === 78 /* Identifier */ && node.isInJSDocNamespace)) { + if (node.flags & 4 /* NestedNamespace */ || (node.kind === 79 /* Identifier */ && node.isInJSDocNamespace)) { flags |= 1 /* Export */; } return flags; @@ -17925,21 +18329,26 @@ var ts; ts.modifiersToFlags = modifiersToFlags; function modifierToFlag(token) { switch (token) { - case 123 /* StaticKeyword */: return 32 /* Static */; - case 122 /* PublicKeyword */: return 4 /* Public */; - case 121 /* ProtectedKeyword */: return 16 /* Protected */; - case 120 /* PrivateKeyword */: return 8 /* Private */; - case 125 /* AbstractKeyword */: return 128 /* Abstract */; - case 92 /* ExportKeyword */: return 1 /* Export */; - case 133 /* DeclareKeyword */: return 2 /* Ambient */; - case 84 /* ConstKeyword */: return 2048 /* Const */; - case 87 /* DefaultKeyword */: return 512 /* Default */; - case 129 /* AsyncKeyword */: return 256 /* Async */; - case 142 /* ReadonlyKeyword */: return 64 /* Readonly */; + 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 134 /* DeclareKeyword */: return 2 /* Ambient */; + case 85 /* ConstKeyword */: return 2048 /* Const */; + case 88 /* DefaultKeyword */: return 512 /* Default */; + case 130 /* AsyncKeyword */: return 256 /* Async */; + case 143 /* ReadonlyKeyword */: return 64 /* Readonly */; + case 157 /* OverrideKeyword */: return 16384 /* Override */; } return 0 /* None */; } ts.modifierToFlag = modifierToFlag; + function createModifiers(modifierFlags) { + return modifierFlags ? ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(modifierFlags)) : undefined; + } + ts.createModifiers = createModifiers; function isLogicalOperator(token) { return token === 56 /* BarBarToken */ || token === 55 /* AmpersandAmpersandToken */ @@ -17947,9 +18356,9 @@ var ts; } ts.isLogicalOperator = isLogicalOperator; function isLogicalOrCoalescingAssignmentOperator(token) { - return token === 74 /* BarBarEqualsToken */ - || token === 75 /* AmpersandAmpersandEqualsToken */ - || token === 76 /* QuestionQuestionEqualsToken */; + return token === 75 /* BarBarEqualsToken */ + || token === 76 /* AmpersandAmpersandEqualsToken */ + || token === 77 /* QuestionQuestionEqualsToken */; } ts.isLogicalOrCoalescingAssignmentOperator = isLogicalOrCoalescingAssignmentOperator; function isLogicalOrCoalescingAssignmentExpression(expr) { @@ -17957,7 +18366,7 @@ var ts; } ts.isLogicalOrCoalescingAssignmentExpression = isLogicalOrCoalescingAssignmentExpression; function isAssignmentOperator(token) { - return token >= 62 /* FirstAssignment */ && token <= 77 /* LastAssignment */; + return token >= 63 /* FirstAssignment */ && token <= 78 /* LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ @@ -17970,23 +18379,27 @@ var ts; return ts.isExpressionWithTypeArguments(node) && ts.isHeritageClause(node.parent) && ts.isClassLike(node.parent.parent) - ? { class: node.parent.parent, isImplements: node.parent.token === 116 /* ImplementsKeyword */ } + ? { class: node.parent.parent, isImplements: node.parent.token === 117 /* ImplementsKeyword */ } : undefined; } ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments = tryGetClassImplementingOrExtendingExpressionWithTypeArguments; function isAssignmentExpression(node, excludeCompoundAssignment) { return ts.isBinaryExpression(node) && (excludeCompoundAssignment - ? node.operatorToken.kind === 62 /* EqualsToken */ + ? node.operatorToken.kind === 63 /* EqualsToken */ : isAssignmentOperator(node.operatorToken.kind)) && ts.isLeftHandSideExpression(node.left); } ts.isAssignmentExpression = isAssignmentExpression; + function isLeftHandSideOfAssignment(node) { + return isAssignmentExpression(node.parent) && node.parent.left === node; + } + ts.isLeftHandSideOfAssignment = isLeftHandSideOfAssignment; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 200 /* ObjectLiteralExpression */ - || kind === 199 /* ArrayLiteralExpression */; + return kind === 202 /* ObjectLiteralExpression */ + || kind === 201 /* ArrayLiteralExpression */; } return false; } @@ -17996,30 +18409,33 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { - return node.kind === 78 /* Identifier */ || isPropertyAccessEntityNameExpression(node); + return node.kind === 79 /* Identifier */ || isPropertyAccessEntityNameExpression(node); } ts.isEntityNameExpression = isEntityNameExpression; function getFirstIdentifier(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return node; - case 157 /* QualifiedName */: + case 159 /* QualifiedName */: do { node = node.left; - } while (node.kind !== 78 /* Identifier */); + } while (node.kind !== 79 /* Identifier */); return node; - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: do { node = node.expression; - } while (node.kind !== 78 /* Identifier */); + } while (node.kind !== 79 /* Identifier */); return node; } } ts.getFirstIdentifier = getFirstIdentifier; function isDottedName(node) { - return node.kind === 78 /* Identifier */ || node.kind === 107 /* ThisKeyword */ || node.kind === 105 /* SuperKeyword */ || - node.kind === 201 /* PropertyAccessExpression */ && isDottedName(node.expression) || - node.kind === 207 /* ParenthesizedExpression */ && isDottedName(node.expression); + return node.kind === 79 /* Identifier */ + || node.kind === 108 /* ThisKeyword */ + || node.kind === 106 /* SuperKeyword */ + || node.kind === 228 /* MetaProperty */ + || node.kind === 203 /* PropertyAccessExpression */ && isDottedName(node.expression) + || node.kind === 209 /* ParenthesizedExpression */ && isDottedName(node.expression); } ts.isDottedName = isDottedName; function isPropertyAccessEntityNameExpression(node) { @@ -18033,6 +18449,12 @@ var ts; return baseStr + "." + entityNameToString(expr.name); } } + else if (ts.isElementAccessExpression(expr)) { + var baseStr = tryGetPropertyAccessOrIdentifierToString(expr.expression); + if (baseStr !== undefined && ts.isPropertyName(expr.argumentExpression)) { + return baseStr + "." + getPropertyNameForPropertyNameNode(expr.argumentExpression); + } + } else if (ts.isIdentifier(expr)) { return ts.unescapeLeadingUnderscores(expr.escapedText); } @@ -18044,22 +18466,28 @@ var ts; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 157 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 201 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 159 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 203 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; + function isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName(node) { + return ts.isQualifiedName(node.parent) && node.parent.right === node + || ts.isPropertyAccessExpression(node.parent) && node.parent.name === node + || ts.isJSDocMemberName(node.parent) && node.parent.right === node; + } + ts.isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName = isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName; function isEmptyObjectLiteral(expression) { - return expression.kind === 200 /* ObjectLiteralExpression */ && + return expression.kind === 202 /* ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 199 /* ArrayLiteralExpression */ && + return expression.kind === 201 /* ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; function getLocalSymbolForExportDefault(symbol) { - if (!isExportDefaultSymbol(symbol)) + if (!isExportDefaultSymbol(symbol) || !symbol.declarations) return undefined; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; @@ -18386,8 +18814,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 255 /* EnumDeclaration */: - case 256 /* ModuleDeclaration */: + case 257 /* EnumDeclaration */: + case 258 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -18414,9 +18842,11 @@ var ts; return symbol.flags & 33554432 /* Transient */ ? symbol.checkFlags : 0; } ts.getCheckFlags = getCheckFlags; - function getDeclarationModifierFlagsFromSymbol(s) { + function getDeclarationModifierFlagsFromSymbol(s, isWrite) { + if (isWrite === void 0) { isWrite = false; } if (s.valueDeclaration) { - var flags = ts.getCombinedModifierFlags(s.valueDeclaration); + var declaration = (isWrite && s.declarations && ts.find(s.declarations, function (d) { return d.kind === 170 /* SetAccessor */; })) || s.valueDeclaration; + var flags = ts.getCombinedModifierFlags(declaration); return s.parent && s.parent.flags & 32 /* Class */ ? flags : flags & ~28 /* AccessibilityModifier */; } if (getCheckFlags(s) & 6 /* Synthetic */) { @@ -18464,35 +18894,35 @@ var ts; if (!parent) return 0 /* Read */; switch (parent.kind) { - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return accessKind(parent); - case 215 /* PostfixUnaryExpression */: - case 214 /* PrefixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: var operator = parent.operator; return operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? - operatorToken.kind === 62 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() + operatorToken.kind === 63 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() : 0 /* Read */; - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return parent.name !== node ? 0 /* Read */ : accessKind(parent); - case 288 /* PropertyAssignment */: { + case 290 /* 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 289 /* ShorthandPropertyAssignment */: + case 291 /* 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 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return accessKind(parent); default: return 0 /* 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 && skipParenthesesUp(parent.parent).kind === 233 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && walkUpParenthesizedExpressions(parent.parent).kind === 235 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; } } function reverseAccessKind(a) { @@ -18580,7 +19010,8 @@ var ts; } ts.isAbstractConstructorSymbol = isAbstractConstructorSymbol; function getClassLikeDeclarationOfSymbol(symbol) { - return ts.find(symbol.declarations, ts.isClassLike); + var _a; + return (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isClassLike); } ts.getClassLikeDeclarationOfSymbol = getClassLikeDeclarationOfSymbol; function getObjectFlags(type) { @@ -18623,7 +19054,6 @@ var ts; ts.getLastChild = getLastChild; function addToSeen(seen, key, value) { if (value === void 0) { value = true; } - key = String(key); if (seen.has(key)) { return false; } @@ -18636,37 +19066,37 @@ var ts; } ts.isObjectTypeDeclaration = isObjectTypeDeclaration; function isTypeNodeKind(kind) { - return (kind >= 172 /* FirstTypeNode */ && kind <= 195 /* LastTypeNode */) - || kind === 128 /* AnyKeyword */ - || kind === 152 /* UnknownKeyword */ - || kind === 144 /* NumberKeyword */ - || kind === 155 /* BigIntKeyword */ - || kind === 145 /* ObjectKeyword */ - || kind === 131 /* BooleanKeyword */ - || kind === 147 /* StringKeyword */ - || kind === 148 /* SymbolKeyword */ - || kind === 113 /* VoidKeyword */ - || kind === 150 /* UndefinedKeyword */ - || kind === 141 /* NeverKeyword */ - || kind === 223 /* ExpressionWithTypeArguments */ - || kind === 303 /* JSDocAllType */ - || kind === 304 /* JSDocUnknownType */ - || kind === 305 /* JSDocNullableType */ - || kind === 306 /* JSDocNonNullableType */ - || kind === 307 /* JSDocOptionalType */ - || kind === 308 /* JSDocFunctionType */ - || kind === 309 /* JSDocVariadicType */; + return (kind >= 174 /* FirstTypeNode */ && kind <= 197 /* LastTypeNode */) + || kind === 129 /* AnyKeyword */ + || kind === 153 /* UnknownKeyword */ + || kind === 145 /* NumberKeyword */ + || kind === 156 /* BigIntKeyword */ + || kind === 146 /* ObjectKeyword */ + || kind === 132 /* BooleanKeyword */ + || kind === 148 /* StringKeyword */ + || kind === 149 /* SymbolKeyword */ + || kind === 114 /* VoidKeyword */ + || kind === 151 /* UndefinedKeyword */ + || kind === 142 /* NeverKeyword */ + || kind === 225 /* ExpressionWithTypeArguments */ + || kind === 306 /* JSDocAllType */ + || kind === 307 /* JSDocUnknownType */ + || kind === 308 /* JSDocNullableType */ + || kind === 309 /* JSDocNonNullableType */ + || kind === 310 /* JSDocOptionalType */ + || kind === 311 /* JSDocFunctionType */ + || kind === 312 /* JSDocVariadicType */; } ts.isTypeNodeKind = isTypeNodeKind; function isAccessExpression(node) { - return node.kind === 201 /* PropertyAccessExpression */ || node.kind === 202 /* ElementAccessExpression */; + return node.kind === 203 /* PropertyAccessExpression */ || node.kind === 204 /* ElementAccessExpression */; } ts.isAccessExpression = isAccessExpression; function getNameOfAccessExpression(node) { - if (node.kind === 201 /* PropertyAccessExpression */) { + if (node.kind === 203 /* PropertyAccessExpression */) { return node.name; } - ts.Debug.assert(node.kind === 202 /* ElementAccessExpression */); + ts.Debug.assert(node.kind === 204 /* ElementAccessExpression */); return node.argumentExpression; } ts.getNameOfAccessExpression = getNameOfAccessExpression; @@ -18681,7 +19111,7 @@ var ts; } ts.isBundleFileTextLike = isBundleFileTextLike; function isNamedImportsOrExports(node) { - return node.kind === 264 /* NamedImports */ || node.kind === 268 /* NamedExports */; + return node.kind === 266 /* NamedImports */ || node.kind === 270 /* NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function getLeftmostAccessExpression(expr) { @@ -18694,28 +19124,28 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: node = node.operand; continue; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: node = node.left; continue; - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: node = node.condition; continue; - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: node = node.tag; continue; - case 203 /* CallExpression */: + case 205 /* CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 224 /* AsExpression */: - case 202 /* ElementAccessExpression */: - case 201 /* PropertyAccessExpression */: - case 225 /* NonNullExpression */: - case 336 /* PartiallyEmittedExpression */: + case 226 /* AsExpression */: + case 204 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 227 /* NonNullExpression */: + case 344 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -18734,7 +19164,7 @@ var ts; } function Type(checker, flags) { this.flags = flags; - if (ts.Debug.isDebugging || ts.tracing.isTracing()) { + if (ts.Debug.isDebugging || ts.tracing) { this.checker = checker; } } @@ -19078,6 +19508,10 @@ var ts; return !!(compilerOptions.declaration || compilerOptions.composite); } ts.getEmitDeclarations = getEmitDeclarations; + function shouldPreserveConstEnums(compilerOptions) { + return !!(compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); + } + ts.shouldPreserveConstEnums = shouldPreserveConstEnums; function isIncrementalCompilation(options) { return !!(options.incremental || options.composite); } @@ -19090,14 +19524,16 @@ var ts; return compilerOptions.allowJs === undefined ? !!compilerOptions.checkJs : compilerOptions.allowJs; } ts.getAllowJSCompilerOption = getAllowJSCompilerOption; + function getUseDefineForClassFields(compilerOptions) { + return compilerOptions.useDefineForClassFields === undefined ? compilerOptions.target === 99 /* ESNext */ : compilerOptions.useDefineForClassFields; + } + ts.getUseDefineForClassFields = getUseDefineForClassFields; function compilerOptionsAffectSemanticDiagnostics(newOptions, oldOptions) { - return oldOptions !== newOptions && - ts.semanticDiagnosticsOptionDeclarations.some(function (option) { return !isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); }); + return optionsHaveChanges(oldOptions, newOptions, ts.semanticDiagnosticsOptionDeclarations); } ts.compilerOptionsAffectSemanticDiagnostics = compilerOptionsAffectSemanticDiagnostics; function compilerOptionsAffectEmit(newOptions, oldOptions) { - return oldOptions !== newOptions && - ts.affectsEmitOptionDeclarations.some(function (option) { return !isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); }); + return optionsHaveChanges(oldOptions, newOptions, ts.affectsEmitOptionDeclarations); } ts.compilerOptionsAffectEmit = compilerOptionsAffectEmit; function getCompilerOptionValue(options, option) { @@ -19111,7 +19547,7 @@ var ts; 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[0] : jsxImportSourcePragmas; + var jsxImportSourcePragma = ts.isArray(jsxImportSourcePragmas) ? jsxImportSourcePragmas[jsxImportSourcePragmas.length - 1] : jsxImportSourcePragmas; return compilerOptions.jsx === 4 /* ReactJSX */ || compilerOptions.jsx === 5 /* ReactJSXDev */ || compilerOptions.jsxImportSource || @@ -19140,37 +19576,65 @@ var ts; return true; } ts.hasZeroOrOneAsteriskCharacter = hasZeroOrOneAsteriskCharacter; - function createSymlinkCache() { + function createSymlinkCache(cwd, getCanonicalFileName) { var symlinkedDirectories; + var symlinkedDirectoriesByRealpath; var symlinkedFiles; return { getSymlinkedFiles: function () { return symlinkedFiles; }, getSymlinkedDirectories: function () { return symlinkedDirectories; }, + getSymlinkedDirectoriesByRealpath: function () { return symlinkedDirectoriesByRealpath; }, setSymlinkedFile: function (path, real) { return (symlinkedFiles || (symlinkedFiles = new ts.Map())).set(path, real); }, - setSymlinkedDirectory: function (path, directory) { return (symlinkedDirectories || (symlinkedDirectories = new ts.Map())).set(path, directory); }, + setSymlinkedDirectory: function (symlink, real) { + // Large, interconnected dependency graphs in pnpm will have a huge number of symlinks + // where both the realpath and the symlink path are inside node_modules/.pnpm. Since + // this path is never a candidate for a module specifier, we can ignore it entirely. + var symlinkPath = ts.toPath(symlink, cwd, getCanonicalFileName); + if (!containsIgnoredPath(symlinkPath)) { + symlinkPath = ts.ensureTrailingDirectorySeparator(symlinkPath); + if (real !== false && !(symlinkedDirectories === null || symlinkedDirectories === void 0 ? void 0 : symlinkedDirectories.has(symlinkPath))) { + (symlinkedDirectoriesByRealpath || (symlinkedDirectoriesByRealpath = ts.createMultiMap())).add(ts.ensureTrailingDirectorySeparator(real.realPath), symlink); + } + (symlinkedDirectories || (symlinkedDirectories = new ts.Map())).set(symlinkPath, real); + } + }, + setSymlinkedDirectoryFromSymlinkedFile: function (symlink, real) { + this.setSymlinkedFile(ts.toPath(symlink, cwd, getCanonicalFileName), real); + var _a = guessDirectorySymlink(real, symlink, cwd, getCanonicalFileName) || ts.emptyArray, commonResolved = _a[0], commonOriginal = _a[1]; + if (commonResolved && commonOriginal) { + this.setSymlinkedDirectory(commonOriginal, { + real: commonResolved, + realPath: ts.toPath(commonResolved, cwd, getCanonicalFileName), + }); + } + }, }; } ts.createSymlinkCache = createSymlinkCache; function discoverProbableSymlinks(files, getCanonicalFileName, cwd) { - var cache = createSymlinkCache(); - var symlinks = ts.flatten(ts.mapDefined(files, function (sf) { - return sf.resolvedModules && ts.compact(ts.arrayFrom(ts.mapIterator(sf.resolvedModules.values(), function (res) { - return res && res.originalPath && res.resolvedFileName !== res.originalPath ? [res.resolvedFileName, res.originalPath] : undefined; + var cache = createSymlinkCache(cwd, getCanonicalFileName); + var symlinks = ts.flatMap(files, function (sf) { + var pairs = sf.resolvedModules && ts.arrayFrom(ts.mapDefinedIterator(sf.resolvedModules.values(), function (res) { + return (res === null || res === void 0 ? void 0 : res.originalPath) ? [res.resolvedFileName, res.originalPath] : undefined; + })); + return ts.concatenate(pairs, sf.resolvedTypeReferenceDirectiveNames && ts.arrayFrom(ts.mapDefinedIterator(sf.resolvedTypeReferenceDirectiveNames.values(), function (res) { + return (res === null || res === void 0 ? void 0 : res.originalPath) && res.resolvedFileName ? [res.resolvedFileName, res.originalPath] : undefined; }))); - })); + }); for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) { var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1]; + cache.setSymlinkedFile(ts.toPath(originalPath, cwd, getCanonicalFileName), resolvedPath); var _b = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName) || ts.emptyArray, commonResolved = _b[0], commonOriginal = _b[1]; if (commonResolved && commonOriginal) { - cache.setSymlinkedDirectory(ts.toPath(commonOriginal, cwd, getCanonicalFileName), { real: commonResolved, realPath: ts.toPath(commonResolved, cwd, getCanonicalFileName) }); + cache.setSymlinkedDirectory(commonOriginal, { real: commonResolved, realPath: ts.toPath(commonResolved, cwd, getCanonicalFileName) }); } } return cache; } ts.discoverProbableSymlinks = discoverProbableSymlinks; function guessDirectorySymlink(a, b, cwd, getCanonicalFileName) { - var aParts = ts.getPathComponents(ts.toPath(a, cwd, getCanonicalFileName)); - var bParts = ts.getPathComponents(ts.toPath(b, cwd, getCanonicalFileName)); + var aParts = ts.getPathComponents(ts.getNormalizedAbsolutePath(a, cwd)); + var bParts = ts.getPathComponents(ts.getNormalizedAbsolutePath(b, cwd)); var isDirectory = false; while (!isNodeModulesOrScopedPackageDirectory(aParts[aParts.length - 2], getCanonicalFileName) && !isNodeModulesOrScopedPackageDirectory(bParts[bParts.length - 2], getCanonicalFileName) && @@ -19554,6 +20018,14 @@ var ts; return false; } ts.isSupportedSourceFileName = isSupportedSourceFileName; + function numberOfDirectorySeparators(str) { + var match = str.match(/\//g); + return match ? match.length : 0; + } + function compareNumberOfDirectorySeparators(path1, path2) { + return ts.compareValues(numberOfDirectorySeparators(path1), numberOfDirectorySeparators(path2)); + } + ts.compareNumberOfDirectorySeparators = compareNumberOfDirectorySeparators; /** * Extension boundaries by priority. Lower numbers indicate higher priorities, and are * aligned to the offset of the highest priority extension in the @@ -19628,16 +20100,27 @@ var ts; return ts.changeAnyExtension(path, newExtension, extensionsToRemove, /*ignoreCase*/ false); } ts.changeExtension = changeExtension; + /** + * Returns the input if there are no stars, a pattern if there is exactly one, + * and undefined if there are more. + */ function tryParsePattern(pattern) { - // This should be verified outside of here and a proper error thrown. - ts.Debug.assert(hasZeroOrOneAsteriskCharacter(pattern)); var indexOfStar = pattern.indexOf("*"); - return indexOfStar === -1 ? undefined : { - prefix: pattern.substr(0, indexOfStar), - suffix: pattern.substr(indexOfStar + 1) - }; + if (indexOfStar === -1) { + return pattern; + } + return pattern.indexOf("*", indexOfStar + 1) !== -1 + ? undefined + : { + prefix: pattern.substr(0, indexOfStar), + suffix: pattern.substr(indexOfStar + 1) + }; } ts.tryParsePattern = tryParsePattern; + function tryParsePatterns(paths) { + return ts.mapDefined(ts.getOwnKeys(paths), function (path) { return tryParsePattern(path); }); + } + ts.tryParsePatterns = tryParsePatterns; function positionIsSynthesized(pos) { // This is a fast way of testing the following conditions: // pos === undefined || pos === null || isNaN(pos) || pos < 0; @@ -19679,23 +20162,19 @@ var ts; directories: ts.emptyArray }; /** - * patternStrings contains both pattern strings (containing "*") and regular strings. + * patternOrStrings contains both patterns (containing "*") and regular strings. * Return an exact match if possible, or a pattern match, or undefined. * (These are verified by verifyCompilerOptions to have 0 or 1 "*" characters.) */ - function matchPatternOrExact(patternStrings, candidate) { + function matchPatternOrExact(patternOrStrings, candidate) { var patterns = []; - for (var _i = 0, patternStrings_1 = patternStrings; _i < patternStrings_1.length; _i++) { - var patternString = patternStrings_1[_i]; - if (!hasZeroOrOneAsteriskCharacter(patternString)) - continue; - var pattern = tryParsePattern(patternString); - if (pattern) { - patterns.push(pattern); + for (var _i = 0, patternOrStrings_1 = patternOrStrings; _i < patternOrStrings_1.length; _i++) { + var patternOrString = patternOrStrings_1[_i]; + if (patternOrString === candidate) { + return candidate; } - else if (patternString === candidate) { - // pattern was matched as is - no need to search further - return patternString; + if (!ts.isString(patternOrString)) { + patterns.push(patternOrString); } } return ts.findBestPatternMatch(patterns, function (_) { return _; }, candidate); @@ -19850,38 +20329,38 @@ var ts; } ts.isValidTypeOnlyAliasUseSite = isValidTypeOnlyAliasUseSite; function typeOnlyDeclarationIsExport(typeOnlyDeclaration) { - return typeOnlyDeclaration.kind === 270 /* ExportSpecifier */; + return typeOnlyDeclaration.kind === 272 /* ExportSpecifier */; } ts.typeOnlyDeclarationIsExport = typeOnlyDeclarationIsExport; function isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(node) { - while (node.kind === 78 /* Identifier */ || node.kind === 201 /* PropertyAccessExpression */) { + while (node.kind === 79 /* Identifier */ || node.kind === 203 /* PropertyAccessExpression */) { node = node.parent; } - if (node.kind !== 158 /* ComputedPropertyName */) { + if (node.kind !== 160 /* ComputedPropertyName */) { return false; } if (hasSyntacticModifier(node.parent, 128 /* Abstract */)) { return true; } var containerKind = node.parent.parent.kind; - return containerKind === 253 /* InterfaceDeclaration */ || containerKind === 177 /* TypeLiteral */; + return containerKind === 255 /* InterfaceDeclaration */ || containerKind === 179 /* 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 !== 78 /* Identifier */) + if (node.kind !== 79 /* Identifier */) return false; var heritageClause = ts.findAncestor(node.parent, function (parent) { switch (parent.kind) { - case 286 /* HeritageClause */: + case 288 /* HeritageClause */: return true; - case 201 /* PropertyAccessExpression */: - case 223 /* ExpressionWithTypeArguments */: + case 203 /* PropertyAccessExpression */: + case 225 /* ExpressionWithTypeArguments */: return false; default: return "quit"; } }); - return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 116 /* ImplementsKeyword */ || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 253 /* InterfaceDeclaration */; + return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 117 /* ImplementsKeyword */ || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 255 /* InterfaceDeclaration */; } function isIdentifierTypeReference(node) { return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName); @@ -20034,6 +20513,76 @@ var ts; } } ts.expressionResultIsUnused = expressionResultIsUnused; + function containsIgnoredPath(path) { + return ts.some(ts.ignoredPaths, function (p) { return ts.stringContains(path, p); }); + } + ts.containsIgnoredPath = containsIgnoredPath; + function getContainingNodeArray(node) { + if (!node.parent) + return undefined; + switch (node.kind) { + case 161 /* TypeParameter */: + var parent_1 = node.parent; + return parent_1.kind === 187 /* InferType */ ? undefined : parent_1.typeParameters; + case 162 /* Parameter */: + return node.parent.parameters; + case 196 /* TemplateLiteralTypeSpan */: + return node.parent.templateSpans; + case 230 /* TemplateSpan */: + return node.parent.templateSpans; + case 163 /* Decorator */: + return node.parent.decorators; + case 288 /* HeritageClause */: + return node.parent.heritageClauses; + } + var parent = node.parent; + if (ts.isJSDocTag(node)) { + return ts.isJSDocTypeLiteral(node.parent) ? undefined : node.parent.tags; + } + switch (parent.kind) { + case 179 /* TypeLiteral */: + case 255 /* InterfaceDeclaration */: + return ts.isTypeElement(node) ? parent.members : undefined; + case 184 /* UnionType */: + case 185 /* IntersectionType */: + return parent.types; + case 181 /* TupleType */: + case 201 /* ArrayLiteralExpression */: + case 345 /* CommaListExpression */: + case 266 /* NamedImports */: + case 270 /* NamedExports */: + return parent.elements; + case 202 /* ObjectLiteralExpression */: + case 283 /* JsxAttributes */: + return parent.properties; + case 205 /* CallExpression */: + case 206 /* NewExpression */: + return ts.isTypeNode(node) ? parent.typeArguments : + parent.expression === node ? undefined : + parent.arguments; + case 275 /* JsxElement */: + case 279 /* JsxFragment */: + return ts.isJsxChild(node) ? parent.children : undefined; + case 277 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: + return ts.isTypeNode(node) ? parent.typeArguments : undefined; + case 232 /* Block */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: + case 259 /* ModuleBlock */: + return parent.statements; + case 260 /* CaseBlock */: + return parent.clauses; + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + return ts.isClassElement(node) ? parent.members : undefined; + case 257 /* EnumDeclaration */: + return ts.isEnumMember(node) ? parent.members : undefined; + case 299 /* SourceFile */: + return parent.statements; + } + } + ts.getContainingNodeArray = getContainingNodeArray; })(ts || (ts = {})); /* @internal */ var ts; @@ -20078,7 +20627,11 @@ var ts; var ts; (function (ts) { function createParenthesizerRules(factory) { + var binaryLeftOperandParenthesizerCache; + var binaryRightOperandParenthesizerCache; return { + getParenthesizeLeftSideOfBinaryForOperator: getParenthesizeLeftSideOfBinaryForOperator, + getParenthesizeRightSideOfBinaryForOperator: getParenthesizeRightSideOfBinaryForOperator, parenthesizeLeftSideOfBinary: parenthesizeLeftSideOfBinary, parenthesizeRightSideOfBinary: parenthesizeRightSideOfBinary, parenthesizeExpressionOfComputedPropertyName: parenthesizeExpressionOfComputedPropertyName, @@ -20099,6 +20652,24 @@ var ts; parenthesizeConstituentTypesOfUnionOrIntersectionType: parenthesizeConstituentTypesOfUnionOrIntersectionType, parenthesizeTypeArguments: parenthesizeTypeArguments, }; + function getParenthesizeLeftSideOfBinaryForOperator(operatorKind) { + binaryLeftOperandParenthesizerCache || (binaryLeftOperandParenthesizerCache = new ts.Map()); + var parenthesizerRule = binaryLeftOperandParenthesizerCache.get(operatorKind); + if (!parenthesizerRule) { + parenthesizerRule = function (node) { return parenthesizeLeftSideOfBinary(operatorKind, node); }; + binaryLeftOperandParenthesizerCache.set(operatorKind, parenthesizerRule); + } + return parenthesizerRule; + } + function getParenthesizeRightSideOfBinaryForOperator(operatorKind) { + binaryRightOperandParenthesizerCache || (binaryRightOperandParenthesizerCache = new ts.Map()); + var parenthesizerRule = binaryRightOperandParenthesizerCache.get(operatorKind); + if (!parenthesizerRule) { + parenthesizerRule = function (node) { return parenthesizeRightSideOfBinary(operatorKind, /*leftSide*/ undefined, node); }; + binaryRightOperandParenthesizerCache.set(operatorKind, parenthesizerRule); + } + return parenthesizerRule; + } /** * Determines whether the operand to a BinaryExpression needs to be parenthesized. * @@ -20125,10 +20696,10 @@ 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(216 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(216 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(218 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(218 /* BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); - if (!isLeftSideOfBinary && operand.kind === 209 /* ArrowFunction */ && binaryOperatorPrecedence > 3 /* Assignment */) { + if (!isLeftSideOfBinary && operand.kind === 211 /* ArrowFunction */ && binaryOperatorPrecedence > 3 /* Assignment */) { // We need to parenthesize arrow functions on the right side to avoid it being // parsed as parenthesized expression: `a && (() => {})` return true; @@ -20140,7 +20711,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 219 /* YieldExpression */) { + && operand.kind === 221 /* YieldExpression */) { return false; } return true; @@ -20228,7 +20799,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 216 /* BinaryExpression */ && node.operatorToken.kind === 39 /* PlusToken */) { + if (node.kind === 218 /* BinaryExpression */ && node.operatorToken.kind === 39 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -20254,7 +20825,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 === 207 /* ParenthesizedExpression */) { + if (skipped.kind === 209 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -20271,7 +20842,7 @@ var ts; return ts.isCommaSequence(expression) ? factory.createParenthesizedExpression(expression) : expression; } function parenthesizeConditionOfConditionalExpression(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(217 /* ConditionalExpression */, 57 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(219 /* ConditionalExpression */, 57 /* QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) !== 1 /* GreaterThan */) { @@ -20304,8 +20875,8 @@ var ts; var needsParens = ts.isCommaSequence(check); if (!needsParens) { switch (ts.getLeftmostExpression(check, /*stopAtCallExpression*/ false).kind) { - case 221 /* ClassExpression */: - case 208 /* FunctionExpression */: + case 223 /* ClassExpression */: + case 210 /* FunctionExpression */: needsParens = true; } } @@ -20318,9 +20889,9 @@ var ts; function parenthesizeExpressionOfNew(expression) { var leftmostExpr = ts.getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 203 /* CallExpression */: + case 205 /* CallExpression */: return factory.createParenthesizedExpression(expression); - case 204 /* NewExpression */: + case 206 /* NewExpression */: return !leftmostExpr.arguments ? factory.createParenthesizedExpression(expression) : expression; // TODO(rbuckton): Verify this assertion holds @@ -20340,7 +20911,7 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 204 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 206 /* NewExpression */ || emittedExpression.arguments)) { // TODO(rbuckton): Verify whether this assertion holds. return expression; } @@ -20362,7 +20933,7 @@ var ts; function parenthesizeExpressionForDisallowedComma(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(216 /* BinaryExpression */, 27 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(218 /* BinaryExpression */, 27 /* CommaToken */); // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(factory.createParenthesizedExpression(expression), expression); } @@ -20371,44 +20942,44 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 208 /* FunctionExpression */ || kind === 209 /* ArrowFunction */) { + if (kind === 210 /* FunctionExpression */ || kind === 211 /* 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 */); } } var leftmostExpressionKind = ts.getLeftmostExpression(emittedExpression, /*stopAtCallExpressions*/ false).kind; - if (leftmostExpressionKind === 200 /* ObjectLiteralExpression */ || leftmostExpressionKind === 208 /* FunctionExpression */) { + if (leftmostExpressionKind === 202 /* ObjectLiteralExpression */ || leftmostExpressionKind === 210 /* 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 === 200 /* ObjectLiteralExpression */)) { + if (!ts.isBlock(body) && (ts.isCommaSequence(body) || ts.getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 202 /* ObjectLiteralExpression */)) { // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return ts.setTextRange(factory.createParenthesizedExpression(body), body); } return body; } function parenthesizeMemberOfConditionalType(member) { - return member.kind === 184 /* ConditionalType */ ? factory.createParenthesizedType(member) : member; + return member.kind === 186 /* ConditionalType */ ? factory.createParenthesizedType(member) : member; } function parenthesizeMemberOfElementType(member) { switch (member.kind) { - case 182 /* UnionType */: - case 183 /* IntersectionType */: - case 174 /* FunctionType */: - case 175 /* ConstructorType */: + case 184 /* UnionType */: + case 185 /* IntersectionType */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: return factory.createParenthesizedType(member); } return parenthesizeMemberOfConditionalType(member); } function parenthesizeElementTypeOfArrayType(member) { switch (member.kind) { - case 176 /* TypeQuery */: - case 188 /* TypeOperator */: - case 185 /* InferType */: + case 178 /* TypeQuery */: + case 190 /* TypeOperator */: + case 187 /* InferType */: return factory.createParenthesizedType(member); } return parenthesizeMemberOfElementType(member); @@ -20427,6 +20998,8 @@ var ts; } ts.createParenthesizerRules = createParenthesizerRules; ts.nullParenthesizerRules = { + getParenthesizeLeftSideOfBinaryForOperator: function (_) { return ts.identity; }, + getParenthesizeRightSideOfBinaryForOperator: function (_) { return ts.identity; }, parenthesizeLeftSideOfBinary: function (_binaryOperator, leftSide) { return leftSide; }, parenthesizeRightSideOfBinary: function (_binaryOperator, _leftSide, rightSide) { return rightSide; }, parenthesizeExpressionOfComputedPropertyName: ts.identity, @@ -20512,11 +21085,11 @@ var ts; } function convertToAssignmentPattern(node) { switch (node.kind) { - case 197 /* ArrayBindingPattern */: - case 199 /* ArrayLiteralExpression */: + case 199 /* ArrayBindingPattern */: + case 201 /* ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 196 /* ObjectBindingPattern */: - case 200 /* ObjectLiteralExpression */: + case 198 /* ObjectBindingPattern */: + case 202 /* ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -20857,18 +21430,18 @@ var ts; createExternalModuleReference: createExternalModuleReference, updateExternalModuleReference: updateExternalModuleReference, // lazily load factory members for JSDoc types with similar structure - get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(303 /* JSDocAllType */); }, - get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(304 /* JSDocUnknownType */); }, - get createJSDocNonNullableType() { return getJSDocUnaryTypeCreateFunction(306 /* JSDocNonNullableType */); }, - get updateJSDocNonNullableType() { return getJSDocUnaryTypeUpdateFunction(306 /* JSDocNonNullableType */); }, - get createJSDocNullableType() { return getJSDocUnaryTypeCreateFunction(305 /* JSDocNullableType */); }, - get updateJSDocNullableType() { return getJSDocUnaryTypeUpdateFunction(305 /* JSDocNullableType */); }, - get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(307 /* JSDocOptionalType */); }, - get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(307 /* JSDocOptionalType */); }, - get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(309 /* JSDocVariadicType */); }, - get updateJSDocVariadicType() { return getJSDocUnaryTypeUpdateFunction(309 /* JSDocVariadicType */); }, - get createJSDocNamepathType() { return getJSDocUnaryTypeCreateFunction(310 /* JSDocNamepathType */); }, - get updateJSDocNamepathType() { return getJSDocUnaryTypeUpdateFunction(310 /* JSDocNamepathType */); }, + get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(306 /* JSDocAllType */); }, + get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(307 /* JSDocUnknownType */); }, + get createJSDocNonNullableType() { return getJSDocUnaryTypeCreateFunction(309 /* JSDocNonNullableType */); }, + get updateJSDocNonNullableType() { return getJSDocUnaryTypeUpdateFunction(309 /* JSDocNonNullableType */); }, + get createJSDocNullableType() { return getJSDocUnaryTypeCreateFunction(308 /* JSDocNullableType */); }, + get updateJSDocNullableType() { return getJSDocUnaryTypeUpdateFunction(308 /* JSDocNullableType */); }, + get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(310 /* JSDocOptionalType */); }, + get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(310 /* JSDocOptionalType */); }, + get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(312 /* JSDocVariadicType */); }, + get updateJSDocVariadicType() { return getJSDocUnaryTypeUpdateFunction(312 /* JSDocVariadicType */); }, + get createJSDocNamepathType() { return getJSDocUnaryTypeCreateFunction(313 /* JSDocNamepathType */); }, + get updateJSDocNamepathType() { return getJSDocUnaryTypeUpdateFunction(313 /* JSDocNamepathType */); }, createJSDocFunctionType: createJSDocFunctionType, updateJSDocFunctionType: updateJSDocFunctionType, createJSDocTypeLiteral: createJSDocTypeLiteral, @@ -20895,31 +21468,43 @@ var ts; updateJSDocSeeTag: updateJSDocSeeTag, createJSDocNameReference: createJSDocNameReference, updateJSDocNameReference: updateJSDocNameReference, + createJSDocMemberName: createJSDocMemberName, + updateJSDocMemberName: updateJSDocMemberName, + createJSDocLink: createJSDocLink, + updateJSDocLink: updateJSDocLink, + createJSDocLinkCode: createJSDocLinkCode, + updateJSDocLinkCode: updateJSDocLinkCode, + createJSDocLinkPlain: createJSDocLinkPlain, + updateJSDocLinkPlain: updateJSDocLinkPlain, // lazily load factory members for JSDoc tags with similar structure - get createJSDocTypeTag() { return getJSDocTypeLikeTagCreateFunction(329 /* JSDocTypeTag */); }, - get updateJSDocTypeTag() { return getJSDocTypeLikeTagUpdateFunction(329 /* JSDocTypeTag */); }, - get createJSDocReturnTag() { return getJSDocTypeLikeTagCreateFunction(327 /* JSDocReturnTag */); }, - get updateJSDocReturnTag() { return getJSDocTypeLikeTagUpdateFunction(327 /* JSDocReturnTag */); }, - get createJSDocThisTag() { return getJSDocTypeLikeTagCreateFunction(328 /* JSDocThisTag */); }, - get updateJSDocThisTag() { return getJSDocTypeLikeTagUpdateFunction(328 /* JSDocThisTag */); }, - get createJSDocEnumTag() { return getJSDocTypeLikeTagCreateFunction(325 /* JSDocEnumTag */); }, - get updateJSDocEnumTag() { return getJSDocTypeLikeTagUpdateFunction(325 /* JSDocEnumTag */); }, - get createJSDocAuthorTag() { return getJSDocSimpleTagCreateFunction(317 /* JSDocAuthorTag */); }, - get updateJSDocAuthorTag() { return getJSDocSimpleTagUpdateFunction(317 /* JSDocAuthorTag */); }, - get createJSDocClassTag() { return getJSDocSimpleTagCreateFunction(319 /* JSDocClassTag */); }, - get updateJSDocClassTag() { return getJSDocSimpleTagUpdateFunction(319 /* JSDocClassTag */); }, - get createJSDocPublicTag() { return getJSDocSimpleTagCreateFunction(320 /* JSDocPublicTag */); }, - get updateJSDocPublicTag() { return getJSDocSimpleTagUpdateFunction(320 /* JSDocPublicTag */); }, - get createJSDocPrivateTag() { return getJSDocSimpleTagCreateFunction(321 /* JSDocPrivateTag */); }, - get updateJSDocPrivateTag() { return getJSDocSimpleTagUpdateFunction(321 /* JSDocPrivateTag */); }, - get createJSDocProtectedTag() { return getJSDocSimpleTagCreateFunction(322 /* JSDocProtectedTag */); }, - get updateJSDocProtectedTag() { return getJSDocSimpleTagUpdateFunction(322 /* JSDocProtectedTag */); }, - get createJSDocReadonlyTag() { return getJSDocSimpleTagCreateFunction(323 /* JSDocReadonlyTag */); }, - get updateJSDocReadonlyTag() { return getJSDocSimpleTagUpdateFunction(323 /* JSDocReadonlyTag */); }, - get createJSDocDeprecatedTag() { return getJSDocSimpleTagCreateFunction(318 /* JSDocDeprecatedTag */); }, - get updateJSDocDeprecatedTag() { return getJSDocSimpleTagUpdateFunction(318 /* JSDocDeprecatedTag */); }, + get createJSDocTypeTag() { return getJSDocTypeLikeTagCreateFunction(337 /* JSDocTypeTag */); }, + get updateJSDocTypeTag() { return getJSDocTypeLikeTagUpdateFunction(337 /* JSDocTypeTag */); }, + get createJSDocReturnTag() { return getJSDocTypeLikeTagCreateFunction(335 /* JSDocReturnTag */); }, + get updateJSDocReturnTag() { return getJSDocTypeLikeTagUpdateFunction(335 /* JSDocReturnTag */); }, + get createJSDocThisTag() { return getJSDocTypeLikeTagCreateFunction(336 /* JSDocThisTag */); }, + get updateJSDocThisTag() { return getJSDocTypeLikeTagUpdateFunction(336 /* JSDocThisTag */); }, + get createJSDocEnumTag() { return getJSDocTypeLikeTagCreateFunction(333 /* JSDocEnumTag */); }, + get updateJSDocEnumTag() { return getJSDocTypeLikeTagUpdateFunction(333 /* JSDocEnumTag */); }, + get createJSDocAuthorTag() { return getJSDocSimpleTagCreateFunction(324 /* JSDocAuthorTag */); }, + get updateJSDocAuthorTag() { return getJSDocSimpleTagUpdateFunction(324 /* JSDocAuthorTag */); }, + get createJSDocClassTag() { return getJSDocSimpleTagCreateFunction(326 /* JSDocClassTag */); }, + get updateJSDocClassTag() { return getJSDocSimpleTagUpdateFunction(326 /* JSDocClassTag */); }, + get createJSDocPublicTag() { return getJSDocSimpleTagCreateFunction(327 /* JSDocPublicTag */); }, + get updateJSDocPublicTag() { return getJSDocSimpleTagUpdateFunction(327 /* JSDocPublicTag */); }, + get createJSDocPrivateTag() { return getJSDocSimpleTagCreateFunction(328 /* JSDocPrivateTag */); }, + get updateJSDocPrivateTag() { return getJSDocSimpleTagUpdateFunction(328 /* JSDocPrivateTag */); }, + get createJSDocProtectedTag() { return getJSDocSimpleTagCreateFunction(329 /* JSDocProtectedTag */); }, + get updateJSDocProtectedTag() { return getJSDocSimpleTagUpdateFunction(329 /* JSDocProtectedTag */); }, + get createJSDocReadonlyTag() { return getJSDocSimpleTagCreateFunction(330 /* JSDocReadonlyTag */); }, + get updateJSDocReadonlyTag() { return getJSDocSimpleTagUpdateFunction(330 /* JSDocReadonlyTag */); }, + get createJSDocOverrideTag() { return getJSDocSimpleTagCreateFunction(331 /* JSDocOverrideTag */); }, + get updateJSDocOverrideTag() { return getJSDocSimpleTagUpdateFunction(331 /* JSDocOverrideTag */); }, + get createJSDocDeprecatedTag() { return getJSDocSimpleTagCreateFunction(325 /* JSDocDeprecatedTag */); }, + get updateJSDocDeprecatedTag() { return getJSDocSimpleTagUpdateFunction(325 /* JSDocDeprecatedTag */); }, createJSDocUnknownTag: createJSDocUnknownTag, updateJSDocUnknownTag: updateJSDocUnknownTag, + createJSDocText: createJSDocText, + updateJSDocText: updateJSDocText, createJSDocComment: createJSDocComment, updateJSDocComment: updateJSDocComment, createJsxElement: createJsxElement, @@ -20984,7 +21569,7 @@ var ts; cloneNode: cloneNode, // Lazily load factory methods for common operator factories and utilities get createComma() { return getBinaryCreateFunction(27 /* CommaToken */); }, - get createAssignment() { return getBinaryCreateFunction(62 /* EqualsToken */); }, + get createAssignment() { return getBinaryCreateFunction(63 /* EqualsToken */); }, get createLogicalOr() { return getBinaryCreateFunction(56 /* BarBarToken */); }, get createLogicalAnd() { return getBinaryCreateFunction(55 /* AmpersandAmpersandToken */); }, get createBitwiseOr() { return getBinaryCreateFunction(51 /* BarToken */); }, @@ -21103,11 +21688,11 @@ var ts; // don't propagate child flags. if (name) { switch (node.kind) { - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 163 /* PropertyDeclaration */: - case 288 /* PropertyAssignment */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 290 /* PropertyAssignment */: if (ts.isIdentifier(name)) { node.transformFlags |= propagateIdentifierNameFlags(name); break; @@ -21148,7 +21733,7 @@ var ts; function createBaseFunctionLikeDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type, body) { var node = createBaseSignatureDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type); node.body = body; - node.transformFlags |= propagateChildFlags(node.body) & ~8388608 /* ContainsPossibleTopLevelAwait */; + node.transformFlags |= propagateChildFlags(node.body) & ~16777216 /* ContainsPossibleTopLevelAwait */; if (!body) node.transformFlags |= 1 /* ContainsTypeScript */; return node; @@ -21201,7 +21786,7 @@ var ts; var node = createBaseLiteral(8 /* NumericLiteral */, typeof value === "number" ? value + "" : value); node.numericLiteralFlags = numericLiteralFlags; if (numericLiteralFlags & 384 /* BinaryOrOctalSpecifier */) - node.transformFlags |= 256 /* ContainsES2015 */; + node.transformFlags |= 512 /* ContainsES2015 */; return node; } // @api @@ -21220,7 +21805,7 @@ var ts; var node = createBaseStringLiteral(text, isSingleQuote); node.hasExtendedUnicodeEscape = hasExtendedUnicodeEscape; if (hasExtendedUnicodeEscape) - node.transformFlags |= 256 /* ContainsES2015 */; + node.transformFlags |= 512 /* ContainsES2015 */; return node; } // @api @@ -21253,10 +21838,10 @@ var ts; if (originalKeywordKind === undefined && text) { originalKeywordKind = ts.stringToToken(text); } - if (originalKeywordKind === 78 /* Identifier */) { + if (originalKeywordKind === 79 /* Identifier */) { originalKeywordKind = undefined; } - var node = baseFactory.createBaseIdentifierNode(78 /* Identifier */); + var node = baseFactory.createBaseIdentifierNode(79 /* Identifier */); node.originalKeywordKind = originalKeywordKind; node.escapedText = ts.escapeLeadingUnderscores(text); return node; @@ -21275,8 +21860,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 === 130 /* AwaitKeyword */) { - node.transformFlags |= 8388608 /* ContainsPossibleTopLevelAwait */; + if (node.originalKeywordKind === 131 /* AwaitKeyword */) { + node.transformFlags |= 16777216 /* ContainsPossibleTopLevelAwait */; } return node; } @@ -21299,8 +21884,11 @@ var ts; } /** Create a unique temporary variable for use in a loop. */ // @api - function createLoopVariable() { - return createBaseGeneratedIdentifier("", 2 /* Loop */); + function createLoopVariable(reservedInNestedScopes) { + var flags = 2 /* Loop */; + if (reservedInNestedScopes) + flags |= 8 /* ReservedInNestedScopes */; + return createBaseGeneratedIdentifier("", flags); } /** Create a unique name based on the supplied text. */ // @api @@ -21323,9 +21911,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(79 /* PrivateIdentifier */); + var node = baseFactory.createBasePrivateIdentifierNode(80 /* PrivateIdentifier */); node.escapedText = ts.escapeLeadingUnderscores(text); - node.transformFlags |= 4194304 /* ContainsClassFields */; + node.transformFlags |= 8388608 /* ContainsClassFields */; return node; } // @@ -21335,46 +21923,47 @@ var ts; return baseFactory.createBaseTokenNode(kind); } function createToken(token) { - ts.Debug.assert(token >= 0 /* FirstToken */ && token <= 156 /* LastToken */, "Invalid token"); + ts.Debug.assert(token >= 0 /* FirstToken */ && token <= 158 /* 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 !== 78 /* Identifier */, "Invalid token. Use 'createIdentifier' to create identifiers"); + ts.Debug.assert(token !== 79 /* Identifier */, "Invalid token. Use 'createIdentifier' to create identifiers"); var node = createBaseToken(token); var transformFlags = 0 /* None */; switch (token) { - case 129 /* AsyncKeyword */: + case 130 /* AsyncKeyword */: // 'async' modifier is ES2017 (async functions) or ES2018 (async generators) transformFlags = - 64 /* ContainsES2017 */ | - 32 /* ContainsES2018 */; + 128 /* ContainsES2017 */ | + 64 /* ContainsES2018 */; break; - case 122 /* PublicKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 142 /* ReadonlyKeyword */: - case 125 /* AbstractKeyword */: - case 133 /* DeclareKeyword */: - case 84 /* ConstKeyword */: - case 128 /* AnyKeyword */: - case 144 /* NumberKeyword */: - case 155 /* BigIntKeyword */: - case 141 /* NeverKeyword */: - case 145 /* ObjectKeyword */: - case 147 /* StringKeyword */: - case 131 /* BooleanKeyword */: - case 148 /* SymbolKeyword */: - case 113 /* VoidKeyword */: - case 152 /* UnknownKeyword */: - case 150 /* UndefinedKeyword */: // `undefined` is an Identifier in the expression case. + case 123 /* PublicKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + case 143 /* ReadonlyKeyword */: + case 126 /* AbstractKeyword */: + case 134 /* DeclareKeyword */: + case 85 /* ConstKeyword */: + case 129 /* AnyKeyword */: + case 145 /* NumberKeyword */: + case 156 /* BigIntKeyword */: + case 142 /* NeverKeyword */: + case 146 /* ObjectKeyword */: + case 157 /* OverrideKeyword */: + case 148 /* StringKeyword */: + case 132 /* BooleanKeyword */: + case 149 /* SymbolKeyword */: + case 114 /* VoidKeyword */: + case 153 /* UnknownKeyword */: + case 151 /* UndefinedKeyword */: // `undefined` is an Identifier in the expression case. transformFlags = 1 /* ContainsTypeScript */; break; - case 123 /* StaticKeyword */: - case 105 /* SuperKeyword */: - transformFlags = 256 /* ContainsES2015 */; + case 124 /* StaticKeyword */: + case 106 /* SuperKeyword */: + transformFlags = 512 /* ContainsES2015 */; break; - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: // 'this' indicates a lexical 'this' - transformFlags = 4096 /* ContainsLexicalThis */; + transformFlags = 8192 /* ContainsLexicalThis */; break; } if (transformFlags) { @@ -21387,23 +21976,23 @@ var ts; // // @api function createSuper() { - return createToken(105 /* SuperKeyword */); + return createToken(106 /* SuperKeyword */); } // @api function createThis() { - return createToken(107 /* ThisKeyword */); + return createToken(108 /* ThisKeyword */); } // @api function createNull() { - return createToken(103 /* NullKeyword */); + return createToken(104 /* NullKeyword */); } // @api function createTrue() { - return createToken(109 /* TrueKeyword */); + return createToken(110 /* TrueKeyword */); } // @api function createFalse() { - return createToken(94 /* FalseKeyword */); + return createToken(95 /* FalseKeyword */); } // // Modifiers @@ -21416,37 +22005,40 @@ var ts; function createModifiersFromModifierFlags(flags) { var result = []; if (flags & 1 /* Export */) { - result.push(createModifier(92 /* ExportKeyword */)); + result.push(createModifier(93 /* ExportKeyword */)); } if (flags & 2 /* Ambient */) { - result.push(createModifier(133 /* DeclareKeyword */)); + result.push(createModifier(134 /* DeclareKeyword */)); } if (flags & 512 /* Default */) { - result.push(createModifier(87 /* DefaultKeyword */)); + result.push(createModifier(88 /* DefaultKeyword */)); } if (flags & 2048 /* Const */) { - result.push(createModifier(84 /* ConstKeyword */)); + result.push(createModifier(85 /* ConstKeyword */)); } if (flags & 4 /* Public */) { - result.push(createModifier(122 /* PublicKeyword */)); + result.push(createModifier(123 /* PublicKeyword */)); } if (flags & 8 /* Private */) { - result.push(createModifier(120 /* PrivateKeyword */)); + result.push(createModifier(121 /* PrivateKeyword */)); } if (flags & 16 /* Protected */) { - result.push(createModifier(121 /* ProtectedKeyword */)); + result.push(createModifier(122 /* ProtectedKeyword */)); } if (flags & 128 /* Abstract */) { - result.push(createModifier(125 /* AbstractKeyword */)); + result.push(createModifier(126 /* AbstractKeyword */)); } if (flags & 32 /* Static */) { - result.push(createModifier(123 /* StaticKeyword */)); + result.push(createModifier(124 /* StaticKeyword */)); + } + if (flags & 16384 /* Override */) { + result.push(createModifier(157 /* OverrideKeyword */)); } if (flags & 64 /* Readonly */) { - result.push(createModifier(142 /* ReadonlyKeyword */)); + result.push(createModifier(143 /* ReadonlyKeyword */)); } if (flags & 256 /* Async */) { - result.push(createModifier(129 /* AsyncKeyword */)); + result.push(createModifier(130 /* AsyncKeyword */)); } return result; } @@ -21455,7 +22047,7 @@ var ts; // // @api function createQualifiedName(left, right) { - var node = createBaseNode(157 /* QualifiedName */); + var node = createBaseNode(159 /* QualifiedName */); node.left = left; node.right = asName(right); node.transformFlags |= @@ -21472,12 +22064,12 @@ var ts; } // @api function createComputedPropertyName(expression) { - var node = createBaseNode(158 /* ComputedPropertyName */); + var node = createBaseNode(160 /* ComputedPropertyName */); node.expression = parenthesizerRules().parenthesizeExpressionOfComputedPropertyName(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 256 /* ContainsES2015 */ | - 32768 /* ContainsComputedPropertyName */; + 512 /* ContainsES2015 */ | + 65536 /* ContainsComputedPropertyName */; return node; } // @api @@ -21491,7 +22083,7 @@ var ts; // // @api function createTypeParameterDeclaration(name, constraint, defaultType) { - var node = createBaseNamedDeclaration(159 /* TypeParameter */, + var node = createBaseNamedDeclaration(161 /* TypeParameter */, /*decorators*/ undefined, /*modifiers*/ undefined, name); node.constraint = constraint; @@ -21509,7 +22101,7 @@ var ts; } // @api function createParameterDeclaration(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(160 /* Parameter */, decorators, modifiers, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); + var node = createBaseVariableLikeDeclaration(162 /* Parameter */, decorators, modifiers, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.dotDotDotToken = dotDotDotToken; node.questionToken = questionToken; if (ts.isThisIdentifier(node.name)) { @@ -21521,10 +22113,10 @@ var ts; propagateChildFlags(node.questionToken); if (questionToken) node.transformFlags |= 1 /* ContainsTypeScript */; - if (ts.modifiersToFlags(node.modifiers) & 92 /* ParameterPropertyModifier */) - node.transformFlags |= 2048 /* ContainsTypeScriptClassSyntax */; + if (ts.modifiersToFlags(node.modifiers) & 16476 /* ParameterPropertyModifier */) + node.transformFlags |= 4096 /* ContainsTypeScriptClassSyntax */; if (initializer || dotDotDotToken) - node.transformFlags |= 256 /* ContainsES2015 */; + node.transformFlags |= 512 /* ContainsES2015 */; } return node; } @@ -21542,12 +22134,12 @@ var ts; } // @api function createDecorator(expression) { - var node = createBaseNode(161 /* Decorator */); + var node = createBaseNode(163 /* Decorator */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= propagateChildFlags(node.expression) | 1 /* ContainsTypeScript */ | - 2048 /* ContainsTypeScriptClassSyntax */; + 4096 /* ContainsTypeScriptClassSyntax */; return node; } // @api @@ -21561,7 +22153,7 @@ var ts; // // @api function createPropertySignature(modifiers, name, questionToken, type) { - var node = createBaseNamedDeclaration(162 /* PropertySignature */, + var node = createBaseNamedDeclaration(164 /* PropertySignature */, /*decorators*/ undefined, modifiers, name); node.type = type; node.questionToken = questionToken; @@ -21579,15 +22171,15 @@ var ts; } // @api function createPropertyDeclaration(decorators, modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(163 /* PropertyDeclaration */, decorators, modifiers, name, type, initializer); + var node = createBaseVariableLikeDeclaration(165 /* PropertyDeclaration */, decorators, 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) | - 4194304 /* ContainsClassFields */; + 8388608 /* ContainsClassFields */; if (ts.isComputedPropertyName(node.name) || (ts.hasStaticModifier(node) && node.initializer)) { - node.transformFlags |= 2048 /* ContainsTypeScriptClassSyntax */; + node.transformFlags |= 4096 /* ContainsTypeScriptClassSyntax */; } if (questionOrExclamationToken || ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { node.transformFlags |= 1 /* ContainsTypeScript */; @@ -21608,7 +22200,7 @@ var ts; } // @api function createMethodSignature(modifiers, name, questionToken, typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(164 /* MethodSignature */, + var node = createBaseSignatureDeclaration(166 /* MethodSignature */, /*decorators*/ undefined, modifiers, name, typeParameters, parameters, type); node.questionToken = questionToken; node.transformFlags = 1 /* ContainsTypeScript */; @@ -21627,26 +22219,26 @@ var ts; } // @api function createMethodDeclaration(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(165 /* MethodDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(167 /* MethodDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; node.questionToken = questionToken; node.transformFlags |= propagateChildFlags(node.asteriskToken) | propagateChildFlags(node.questionToken) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; if (questionToken) { node.transformFlags |= 1 /* ContainsTypeScript */; } if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { if (asteriskToken) { - node.transformFlags |= 32 /* ContainsES2018 */; + node.transformFlags |= 64 /* ContainsES2018 */; } else { - node.transformFlags |= 64 /* ContainsES2017 */; + node.transformFlags |= 128 /* ContainsES2017 */; } } else if (asteriskToken) { - node.transformFlags |= 512 /* ContainsGenerator */; + node.transformFlags |= 1024 /* ContainsGenerator */; } return node; } @@ -21666,11 +22258,11 @@ var ts; } // @api function createConstructorDeclaration(decorators, modifiers, parameters, body) { - var node = createBaseFunctionLikeDeclaration(166 /* Constructor */, decorators, modifiers, + var node = createBaseFunctionLikeDeclaration(168 /* Constructor */, decorators, modifiers, /*name*/ undefined, /*typeParameters*/ undefined, parameters, /*type*/ undefined, body); - node.transformFlags |= 256 /* ContainsES2015 */; + node.transformFlags |= 512 /* ContainsES2015 */; return node; } // @api @@ -21684,7 +22276,7 @@ var ts; } // @api function createGetAccessorDeclaration(decorators, modifiers, name, parameters, type, body) { - return createBaseFunctionLikeDeclaration(167 /* GetAccessor */, decorators, modifiers, name, + return createBaseFunctionLikeDeclaration(169 /* GetAccessor */, decorators, modifiers, name, /*typeParameters*/ undefined, parameters, type, body); } // @api @@ -21700,7 +22292,7 @@ var ts; } // @api function createSetAccessorDeclaration(decorators, modifiers, name, parameters, body) { - return createBaseFunctionLikeDeclaration(168 /* SetAccessor */, decorators, modifiers, name, + return createBaseFunctionLikeDeclaration(170 /* SetAccessor */, decorators, modifiers, name, /*typeParameters*/ undefined, parameters, /*type*/ undefined, body); } @@ -21716,7 +22308,7 @@ var ts; } // @api function createCallSignature(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(169 /* CallSignature */, + var node = createBaseSignatureDeclaration(171 /* CallSignature */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); @@ -21733,7 +22325,7 @@ var ts; } // @api function createConstructSignature(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(170 /* ConstructSignature */, + var node = createBaseSignatureDeclaration(172 /* ConstructSignature */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); @@ -21750,7 +22342,7 @@ var ts; } // @api function createIndexSignature(decorators, modifiers, parameters, type) { - var node = createBaseSignatureDeclaration(171 /* IndexSignature */, decorators, modifiers, + var node = createBaseSignatureDeclaration(173 /* IndexSignature */, decorators, modifiers, /*name*/ undefined, /*typeParameters*/ undefined, parameters, type); node.transformFlags = 1 /* ContainsTypeScript */; @@ -21767,7 +22359,7 @@ var ts; } // @api function createTemplateLiteralTypeSpan(type, literal) { - var node = createBaseNode(194 /* TemplateLiteralTypeSpan */); + var node = createBaseNode(196 /* TemplateLiteralTypeSpan */); node.type = type; node.literal = literal; node.transformFlags = 1 /* ContainsTypeScript */; @@ -21789,7 +22381,7 @@ var ts; } // @api function createTypePredicateNode(assertsModifier, parameterName, type) { - var node = createBaseNode(172 /* TypePredicate */); + var node = createBaseNode(174 /* TypePredicate */); node.assertsModifier = assertsModifier; node.parameterName = asName(parameterName); node.type = type; @@ -21806,7 +22398,7 @@ var ts; } // @api function createTypeReferenceNode(typeName, typeArguments) { - var node = createBaseNode(173 /* TypeReference */); + var node = createBaseNode(175 /* TypeReference */); node.typeName = asName(typeName); node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(createNodeArray(typeArguments)); node.transformFlags = 1 /* ContainsTypeScript */; @@ -21821,7 +22413,7 @@ var ts; } // @api function createFunctionTypeNode(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(174 /* FunctionType */, + var node = createBaseSignatureDeclaration(176 /* FunctionType */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); @@ -21847,7 +22439,7 @@ var ts; ts.Debug.fail("Incorrect number of arguments specified."); } function createConstructorTypeNode1(modifiers, typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(175 /* ConstructorType */, + var node = createBaseSignatureDeclaration(177 /* ConstructorType */, /*decorators*/ undefined, modifiers, /*name*/ undefined, typeParameters, parameters, type); node.transformFlags = 1 /* ContainsTypeScript */; @@ -21881,7 +22473,7 @@ var ts; } // @api function createTypeQueryNode(exprName) { - var node = createBaseNode(176 /* TypeQuery */); + var node = createBaseNode(178 /* TypeQuery */); node.exprName = exprName; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -21894,7 +22486,7 @@ var ts; } // @api function createTypeLiteralNode(members) { - var node = createBaseNode(177 /* TypeLiteral */); + var node = createBaseNode(179 /* TypeLiteral */); node.members = createNodeArray(members); node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -21907,7 +22499,7 @@ var ts; } // @api function createArrayTypeNode(elementType) { - var node = createBaseNode(178 /* ArrayType */); + var node = createBaseNode(180 /* ArrayType */); node.elementType = parenthesizerRules().parenthesizeElementTypeOfArrayType(elementType); node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -21920,7 +22512,7 @@ var ts; } // @api function createTupleTypeNode(elements) { - var node = createBaseNode(179 /* TupleType */); + var node = createBaseNode(181 /* TupleType */); node.elements = createNodeArray(elements); node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -21933,7 +22525,7 @@ var ts; } // @api function createNamedTupleMember(dotDotDotToken, name, questionToken, type) { - var node = createBaseNode(192 /* NamedTupleMember */); + var node = createBaseNode(194 /* NamedTupleMember */); node.dotDotDotToken = dotDotDotToken; node.name = name; node.questionToken = questionToken; @@ -21952,7 +22544,7 @@ var ts; } // @api function createOptionalTypeNode(type) { - var node = createBaseNode(180 /* OptionalType */); + var node = createBaseNode(182 /* OptionalType */); node.type = parenthesizerRules().parenthesizeElementTypeOfArrayType(type); node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -21965,7 +22557,7 @@ var ts; } // @api function createRestTypeNode(type) { - var node = createBaseNode(181 /* RestType */); + var node = createBaseNode(183 /* RestType */); node.type = type; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -21989,7 +22581,7 @@ var ts; } // @api function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(182 /* UnionType */, types); + return createUnionOrIntersectionTypeNode(184 /* UnionType */, types); } // @api function updateUnionTypeNode(node, types) { @@ -21997,7 +22589,7 @@ var ts; } // @api function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(183 /* IntersectionType */, types); + return createUnionOrIntersectionTypeNode(185 /* IntersectionType */, types); } // @api function updateIntersectionTypeNode(node, types) { @@ -22005,7 +22597,7 @@ var ts; } // @api function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createBaseNode(184 /* ConditionalType */); + var node = createBaseNode(186 /* ConditionalType */); node.checkType = parenthesizerRules().parenthesizeMemberOfConditionalType(checkType); node.extendsType = parenthesizerRules().parenthesizeMemberOfConditionalType(extendsType); node.trueType = trueType; @@ -22024,7 +22616,7 @@ var ts; } // @api function createInferTypeNode(typeParameter) { - var node = createBaseNode(185 /* InferType */); + var node = createBaseNode(187 /* InferType */); node.typeParameter = typeParameter; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -22037,7 +22629,7 @@ var ts; } // @api function createTemplateLiteralType(head, templateSpans) { - var node = createBaseNode(193 /* TemplateLiteralType */); + var node = createBaseNode(195 /* TemplateLiteralType */); node.head = head; node.templateSpans = createNodeArray(templateSpans); node.transformFlags = 1 /* ContainsTypeScript */; @@ -22053,7 +22645,7 @@ var ts; // @api function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { if (isTypeOf === void 0) { isTypeOf = false; } - var node = createBaseNode(195 /* ImportType */); + var node = createBaseNode(197 /* ImportType */); node.argument = argument; node.qualifier = qualifier; node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); @@ -22073,7 +22665,7 @@ var ts; } // @api function createParenthesizedType(type) { - var node = createBaseNode(186 /* ParenthesizedType */); + var node = createBaseNode(188 /* ParenthesizedType */); node.type = type; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -22086,13 +22678,13 @@ var ts; } // @api function createThisTypeNode() { - var node = createBaseNode(187 /* ThisType */); + var node = createBaseNode(189 /* ThisType */); node.transformFlags = 1 /* ContainsTypeScript */; return node; } // @api function createTypeOperatorNode(operator, type) { - var node = createBaseNode(188 /* TypeOperator */); + var node = createBaseNode(190 /* TypeOperator */); node.operator = operator; node.type = parenthesizerRules().parenthesizeMemberOfElementType(type); node.transformFlags = 1 /* ContainsTypeScript */; @@ -22106,7 +22698,7 @@ var ts; } // @api function createIndexedAccessTypeNode(objectType, indexType) { - var node = createBaseNode(189 /* IndexedAccessType */); + var node = createBaseNode(191 /* IndexedAccessType */); node.objectType = parenthesizerRules().parenthesizeMemberOfElementType(objectType); node.indexType = indexType; node.transformFlags = 1 /* ContainsTypeScript */; @@ -22121,7 +22713,7 @@ var ts; } // @api function createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type) { - var node = createBaseNode(190 /* MappedType */); + var node = createBaseNode(192 /* MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.nameType = nameType; @@ -22142,7 +22734,7 @@ var ts; } // @api function createLiteralTypeNode(literal) { - var node = createBaseNode(191 /* LiteralType */); + var node = createBaseNode(193 /* LiteralType */); node.literal = literal; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -22158,16 +22750,16 @@ var ts; // // @api function createObjectBindingPattern(elements) { - var node = createBaseNode(196 /* ObjectBindingPattern */); + var node = createBaseNode(198 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements) | - 256 /* ContainsES2015 */ | - 131072 /* ContainsBindingPattern */; - if (node.transformFlags & 8192 /* ContainsRestOrSpread */) { + 512 /* ContainsES2015 */ | + 262144 /* ContainsBindingPattern */; + if (node.transformFlags & 16384 /* ContainsRestOrSpread */) { node.transformFlags |= - 32 /* ContainsES2018 */ | - 16384 /* ContainsObjectRestOrSpread */; + 64 /* ContainsES2018 */ | + 32768 /* ContainsObjectRestOrSpread */; } return node; } @@ -22179,12 +22771,12 @@ var ts; } // @api function createArrayBindingPattern(elements) { - var node = createBaseNode(197 /* ArrayBindingPattern */); + var node = createBaseNode(199 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements) | - 256 /* ContainsES2015 */ | - 131072 /* ContainsBindingPattern */; + 512 /* ContainsES2015 */ | + 262144 /* ContainsBindingPattern */; return node; } // @api @@ -22195,21 +22787,21 @@ var ts; } // @api function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createBaseBindingLikeDeclaration(198 /* BindingElement */, + var node = createBaseBindingLikeDeclaration(200 /* BindingElement */, /*decorators*/ undefined, - /*modifiers*/ undefined, name, initializer); + /*modifiers*/ undefined, name, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.propertyName = asName(propertyName); node.dotDotDotToken = dotDotDotToken; node.transformFlags |= propagateChildFlags(node.dotDotDotToken) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; if (node.propertyName) { node.transformFlags |= ts.isIdentifier(node.propertyName) ? propagateIdentifierNameFlags(node.propertyName) : propagateChildFlags(node.propertyName); } if (dotDotDotToken) - node.transformFlags |= 8192 /* ContainsRestOrSpread */; + node.transformFlags |= 16384 /* ContainsRestOrSpread */; return node; } // @api @@ -22231,7 +22823,7 @@ var ts; } // @api function createArrayLiteralExpression(elements, multiLine) { - var node = createBaseExpression(199 /* ArrayLiteralExpression */); + var node = createBaseExpression(201 /* ArrayLiteralExpression */); node.elements = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(elements)); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.elements); @@ -22245,7 +22837,7 @@ var ts; } // @api function createObjectLiteralExpression(properties, multiLine) { - var node = createBaseExpression(200 /* ObjectLiteralExpression */); + var node = createBaseExpression(202 /* ObjectLiteralExpression */); node.properties = createNodeArray(properties); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.properties); @@ -22259,7 +22851,7 @@ var ts; } // @api function createPropertyAccessExpression(expression, name) { - var node = createBaseExpression(201 /* PropertyAccessExpression */); + var node = createBaseExpression(203 /* PropertyAccessExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.name = asName(name); node.transformFlags = @@ -22271,8 +22863,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 |= - 64 /* ContainsES2017 */ | - 32 /* ContainsES2018 */; + 128 /* ContainsES2017 */ | + 64 /* ContainsES2018 */; } return node; } @@ -22288,13 +22880,13 @@ var ts; } // @api function createPropertyAccessChain(expression, questionDotToken, name) { - var node = createBaseExpression(201 /* PropertyAccessExpression */); + var node = createBaseExpression(203 /* PropertyAccessExpression */); node.flags |= 32 /* OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.questionDotToken = questionDotToken; node.name = asName(name); node.transformFlags |= - 8 /* ContainsES2020 */ | + 16 /* ContainsES2020 */ | propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | (ts.isIdentifier(node.name) ? @@ -22315,7 +22907,7 @@ var ts; } // @api function createElementAccessExpression(expression, index) { - var node = createBaseExpression(202 /* ElementAccessExpression */); + var node = createBaseExpression(204 /* ElementAccessExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.argumentExpression = asExpression(index); node.transformFlags |= @@ -22325,8 +22917,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 |= - 64 /* ContainsES2017 */ | - 32 /* ContainsES2018 */; + 128 /* ContainsES2017 */ | + 64 /* ContainsES2018 */; } return node; } @@ -22342,7 +22934,7 @@ var ts; } // @api function createElementAccessChain(expression, questionDotToken, index) { - var node = createBaseExpression(202 /* ElementAccessExpression */); + var node = createBaseExpression(204 /* ElementAccessExpression */); node.flags |= 32 /* OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.questionDotToken = questionDotToken; @@ -22351,7 +22943,7 @@ var ts; propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | propagateChildFlags(node.argumentExpression) | - 8 /* ContainsES2020 */; + 16 /* ContainsES2020 */; return node; } // @api @@ -22367,7 +22959,7 @@ var ts; } // @api function createCallExpression(expression, typeArguments, argumentsArray) { - var node = createBaseExpression(203 /* CallExpression */); + var node = createBaseExpression(205 /* CallExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray)); @@ -22379,10 +22971,10 @@ var ts; node.transformFlags |= 1 /* ContainsTypeScript */; } if (ts.isImportKeyword(node.expression)) { - node.transformFlags |= 2097152 /* ContainsDynamicImport */; + node.transformFlags |= 4194304 /* ContainsDynamicImport */; } else if (ts.isSuperProperty(node.expression)) { - node.transformFlags |= 4096 /* ContainsLexicalThis */; + node.transformFlags |= 8192 /* ContainsLexicalThis */; } return node; } @@ -22399,7 +22991,7 @@ var ts; } // @api function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) { - var node = createBaseExpression(203 /* CallExpression */); + var node = createBaseExpression(205 /* CallExpression */); node.flags |= 32 /* OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.questionDotToken = questionDotToken; @@ -22410,12 +23002,12 @@ var ts; propagateChildFlags(node.questionDotToken) | propagateChildrenFlags(node.typeArguments) | propagateChildrenFlags(node.arguments) | - 8 /* ContainsES2020 */; + 16 /* ContainsES2020 */; if (node.typeArguments) { node.transformFlags |= 1 /* ContainsTypeScript */; } if (ts.isSuperProperty(node.expression)) { - node.transformFlags |= 4096 /* ContainsLexicalThis */; + node.transformFlags |= 8192 /* ContainsLexicalThis */; } return node; } @@ -22431,7 +23023,7 @@ var ts; } // @api function createNewExpression(expression, typeArguments, argumentsArray) { - var node = createBaseExpression(204 /* NewExpression */); + var node = createBaseExpression(206 /* NewExpression */); node.expression = parenthesizerRules().parenthesizeExpressionOfNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(argumentsArray) : undefined; @@ -22439,7 +23031,7 @@ var ts; propagateChildFlags(node.expression) | propagateChildrenFlags(node.typeArguments) | propagateChildrenFlags(node.arguments) | - 8 /* ContainsES2020 */; + 16 /* ContainsES2020 */; if (node.typeArguments) { node.transformFlags |= 1 /* ContainsTypeScript */; } @@ -22455,7 +23047,7 @@ var ts; } // @api function createTaggedTemplateExpression(tag, typeArguments, template) { - var node = createBaseExpression(205 /* TaggedTemplateExpression */); + var node = createBaseExpression(207 /* TaggedTemplateExpression */); node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag); node.typeArguments = asNodeArray(typeArguments); node.template = template; @@ -22463,12 +23055,12 @@ var ts; propagateChildFlags(node.tag) | propagateChildrenFlags(node.typeArguments) | propagateChildFlags(node.template) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; if (node.typeArguments) { node.transformFlags |= 1 /* ContainsTypeScript */; } if (ts.hasInvalidEscape(node.template)) { - node.transformFlags |= 32 /* ContainsES2018 */; + node.transformFlags |= 64 /* ContainsES2018 */; } return node; } @@ -22482,7 +23074,7 @@ var ts; } // @api function createTypeAssertion(type, expression) { - var node = createBaseExpression(206 /* TypeAssertionExpression */); + var node = createBaseExpression(208 /* TypeAssertionExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.type = type; node.transformFlags |= @@ -22500,7 +23092,7 @@ var ts; } // @api function createParenthesizedExpression(expression) { - var node = createBaseExpression(207 /* ParenthesizedExpression */); + var node = createBaseExpression(209 /* ParenthesizedExpression */); node.expression = expression; node.transformFlags = propagateChildFlags(node.expression); return node; @@ -22513,7 +23105,7 @@ var ts; } // @api function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(208 /* FunctionExpression */, + var node = createBaseFunctionLikeDeclaration(210 /* FunctionExpression */, /*decorators*/ undefined, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; node.transformFlags |= propagateChildFlags(node.asteriskToken); @@ -22522,14 +23114,14 @@ var ts; } if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { if (node.asteriskToken) { - node.transformFlags |= 32 /* ContainsES2018 */; + node.transformFlags |= 64 /* ContainsES2018 */; } else { - node.transformFlags |= 64 /* ContainsES2017 */; + node.transformFlags |= 128 /* ContainsES2017 */; } } else if (node.asteriskToken) { - node.transformFlags |= 512 /* ContainsGenerator */; + node.transformFlags |= 1024 /* ContainsGenerator */; } return node; } @@ -22547,15 +23139,15 @@ var ts; } // @api function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createBaseFunctionLikeDeclaration(209 /* ArrowFunction */, + var node = createBaseFunctionLikeDeclaration(211 /* ArrowFunction */, /*decorators*/ undefined, modifiers, /*name*/ undefined, typeParameters, parameters, type, parenthesizerRules().parenthesizeConciseBodyOfArrowFunction(body)); node.equalsGreaterThanToken = equalsGreaterThanToken !== null && equalsGreaterThanToken !== void 0 ? equalsGreaterThanToken : createToken(38 /* EqualsGreaterThanToken */); node.transformFlags |= propagateChildFlags(node.equalsGreaterThanToken) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { - node.transformFlags |= 64 /* ContainsES2017 */; + node.transformFlags |= 128 /* ContainsES2017 */; } return node; } @@ -22572,7 +23164,7 @@ var ts; } // @api function createDeleteExpression(expression) { - var node = createBaseExpression(210 /* DeleteExpression */); + var node = createBaseExpression(212 /* DeleteExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -22585,7 +23177,7 @@ var ts; } // @api function createTypeOfExpression(expression) { - var node = createBaseExpression(211 /* TypeOfExpression */); + var node = createBaseExpression(213 /* TypeOfExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -22598,7 +23190,7 @@ var ts; } // @api function createVoidExpression(expression) { - var node = createBaseExpression(212 /* VoidExpression */); + var node = createBaseExpression(214 /* VoidExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -22611,13 +23203,13 @@ var ts; } // @api function createAwaitExpression(expression) { - var node = createBaseExpression(213 /* AwaitExpression */); + var node = createBaseExpression(215 /* AwaitExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 64 /* ContainsES2017 */ | - 32 /* ContainsES2018 */ | - 524288 /* ContainsAwait */; + 128 /* ContainsES2017 */ | + 64 /* ContainsES2018 */ | + 1048576 /* ContainsAwait */; return node; } // @api @@ -22628,7 +23220,7 @@ var ts; } // @api function createPrefixUnaryExpression(operator, operand) { - var node = createBaseExpression(214 /* PrefixUnaryExpression */); + var node = createBaseExpression(216 /* PrefixUnaryExpression */); node.operator = operator; node.operand = parenthesizerRules().parenthesizeOperandOfPrefixUnary(operand); node.transformFlags |= propagateChildFlags(node.operand); @@ -22642,7 +23234,7 @@ var ts; } // @api function createPostfixUnaryExpression(operand, operator) { - var node = createBaseExpression(215 /* PostfixUnaryExpression */); + var node = createBaseExpression(217 /* PostfixUnaryExpression */); node.operator = operator; node.operand = parenthesizerRules().parenthesizeOperandOfPostfixUnary(operand); node.transformFlags = propagateChildFlags(node.operand); @@ -22656,7 +23248,7 @@ var ts; } // @api function createBinaryExpression(left, operator, right) { - var node = createBaseExpression(216 /* BinaryExpression */); + var node = createBaseExpression(218 /* BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = parenthesizerRules().parenthesizeLeftSideOfBinary(operatorKind, left); @@ -22667,45 +23259,45 @@ var ts; propagateChildFlags(node.operatorToken) | propagateChildFlags(node.right); if (operatorKind === 60 /* QuestionQuestionToken */) { - node.transformFlags |= 8 /* ContainsES2020 */; + node.transformFlags |= 16 /* ContainsES2020 */; } - else if (operatorKind === 62 /* EqualsToken */) { + else if (operatorKind === 63 /* EqualsToken */) { if (ts.isObjectLiteralExpression(node.left)) { node.transformFlags |= - 256 /* ContainsES2015 */ | - 32 /* ContainsES2018 */ | - 1024 /* ContainsDestructuringAssignment */ | + 512 /* ContainsES2015 */ | + 64 /* ContainsES2018 */ | + 2048 /* ContainsDestructuringAssignment */ | propagateAssignmentPatternFlags(node.left); } else if (ts.isArrayLiteralExpression(node.left)) { node.transformFlags |= - 256 /* ContainsES2015 */ | - 1024 /* ContainsDestructuringAssignment */ | + 512 /* ContainsES2015 */ | + 2048 /* ContainsDestructuringAssignment */ | propagateAssignmentPatternFlags(node.left); } } - else if (operatorKind === 42 /* AsteriskAsteriskToken */ || operatorKind === 66 /* AsteriskAsteriskEqualsToken */) { - node.transformFlags |= 128 /* ContainsES2016 */; + else if (operatorKind === 42 /* AsteriskAsteriskToken */ || operatorKind === 67 /* AsteriskAsteriskEqualsToken */) { + node.transformFlags |= 256 /* ContainsES2016 */; } else if (ts.isLogicalOrCoalescingAssignmentOperator(operatorKind)) { - node.transformFlags |= 4 /* ContainsESNext */; + node.transformFlags |= 8 /* ContainsES2021 */; } return node; } function propagateAssignmentPatternFlags(node) { - if (node.transformFlags & 16384 /* ContainsObjectRestOrSpread */) - return 16384 /* ContainsObjectRestOrSpread */; - if (node.transformFlags & 32 /* ContainsES2018 */) { + if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) + return 32768 /* ContainsObjectRestOrSpread */; + if (node.transformFlags & 64 /* 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 & 16384 /* ContainsObjectRestOrSpread */) { - return 16384 /* ContainsObjectRestOrSpread */; + if (target.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { + return 32768 /* ContainsObjectRestOrSpread */; } - if (target.transformFlags & 32 /* ContainsES2018 */) { + if (target.transformFlags & 64 /* ContainsES2018 */) { var flags_1 = propagateAssignmentPatternFlags(target); if (flags_1) return flags_1; @@ -22725,7 +23317,7 @@ var ts; } // @api function createConditionalExpression(condition, questionToken, whenTrue, colonToken, whenFalse) { - var node = createBaseExpression(217 /* ConditionalExpression */); + var node = createBaseExpression(219 /* ConditionalExpression */); node.condition = parenthesizerRules().parenthesizeConditionOfConditionalExpression(condition); node.questionToken = questionToken !== null && questionToken !== void 0 ? questionToken : createToken(57 /* QuestionToken */); node.whenTrue = parenthesizerRules().parenthesizeBranchOfConditionalExpression(whenTrue); @@ -22751,13 +23343,13 @@ var ts; } // @api function createTemplateExpression(head, templateSpans) { - var node = createBaseExpression(218 /* TemplateExpression */); + var node = createBaseExpression(220 /* TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); node.transformFlags |= propagateChildFlags(node.head) | propagateChildrenFlags(node.templateSpans) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; return node; } // @api @@ -22796,9 +23388,9 @@ var ts; node.text = text; node.rawText = rawText; node.templateFlags = templateFlags & 2048 /* TemplateLiteralLikeFlags */; - node.transformFlags |= 256 /* ContainsES2015 */; + node.transformFlags |= 512 /* ContainsES2015 */; if (node.templateFlags) { - node.transformFlags |= 32 /* ContainsES2018 */; + node.transformFlags |= 64 /* ContainsES2018 */; } return node; } @@ -22821,15 +23413,15 @@ var ts; // @api function createYieldExpression(asteriskToken, expression) { ts.Debug.assert(!asteriskToken || !!expression, "A `YieldExpression` with an asteriskToken must have an expression."); - var node = createBaseExpression(219 /* YieldExpression */); + var node = createBaseExpression(221 /* YieldExpression */); node.expression = expression && parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.asteriskToken = asteriskToken; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.asteriskToken) | - 256 /* ContainsES2015 */ | - 32 /* ContainsES2018 */ | - 262144 /* ContainsYield */; + 512 /* ContainsES2015 */ | + 64 /* ContainsES2018 */ | + 524288 /* ContainsYield */; return node; } // @api @@ -22841,12 +23433,12 @@ var ts; } // @api function createSpreadElement(expression) { - var node = createBaseExpression(220 /* SpreadElement */); + var node = createBaseExpression(222 /* SpreadElement */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 256 /* ContainsES2015 */ | - 8192 /* ContainsRestOrSpread */; + 512 /* ContainsES2015 */ | + 16384 /* ContainsRestOrSpread */; return node; } // @api @@ -22857,8 +23449,8 @@ var ts; } // @api function createClassExpression(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseClassLikeDeclaration(221 /* ClassExpression */, decorators, modifiers, name, typeParameters, heritageClauses, members); - node.transformFlags |= 256 /* ContainsES2015 */; + var node = createBaseClassLikeDeclaration(223 /* ClassExpression */, decorators, modifiers, name, typeParameters, heritageClauses, members); + node.transformFlags |= 512 /* ContainsES2015 */; return node; } // @api @@ -22874,17 +23466,17 @@ var ts; } // @api function createOmittedExpression() { - return createBaseExpression(222 /* OmittedExpression */); + return createBaseExpression(224 /* OmittedExpression */); } // @api function createExpressionWithTypeArguments(expression, typeArguments) { - var node = createBaseNode(223 /* ExpressionWithTypeArguments */); + var node = createBaseNode(225 /* ExpressionWithTypeArguments */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); node.transformFlags |= propagateChildFlags(node.expression) | propagateChildrenFlags(node.typeArguments) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; return node; } // @api @@ -22896,7 +23488,7 @@ var ts; } // @api function createAsExpression(expression, type) { - var node = createBaseExpression(224 /* AsExpression */); + var node = createBaseExpression(226 /* AsExpression */); node.expression = expression; node.type = type; node.transformFlags |= @@ -22914,7 +23506,7 @@ var ts; } // @api function createNonNullExpression(expression) { - var node = createBaseExpression(225 /* NonNullExpression */); + var node = createBaseExpression(227 /* NonNullExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= propagateChildFlags(node.expression) | @@ -22932,7 +23524,7 @@ var ts; } // @api function createNonNullChain(expression) { - var node = createBaseExpression(225 /* NonNullExpression */); + var node = createBaseExpression(227 /* NonNullExpression */); node.flags |= 32 /* OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= @@ -22949,15 +23541,15 @@ var ts; } // @api function createMetaProperty(keywordToken, name) { - var node = createBaseExpression(226 /* MetaProperty */); + var node = createBaseExpression(228 /* MetaProperty */); node.keywordToken = keywordToken; node.name = name; node.transformFlags |= propagateChildFlags(node.name); switch (keywordToken) { - case 102 /* NewKeyword */: - node.transformFlags |= 256 /* ContainsES2015 */; + case 103 /* NewKeyword */: + node.transformFlags |= 512 /* ContainsES2015 */; break; - case 99 /* ImportKeyword */: + case 100 /* ImportKeyword */: node.transformFlags |= 4 /* ContainsESNext */; break; default: @@ -22976,13 +23568,13 @@ var ts; // // @api function createTemplateSpan(expression, literal) { - var node = createBaseNode(228 /* TemplateSpan */); + var node = createBaseNode(230 /* TemplateSpan */); node.expression = expression; node.literal = literal; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.literal) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; return node; } // @api @@ -22994,8 +23586,8 @@ var ts; } // @api function createSemicolonClassElement() { - var node = createBaseNode(229 /* SemicolonClassElement */); - node.transformFlags |= 256 /* ContainsES2015 */; + var node = createBaseNode(231 /* SemicolonClassElement */); + node.transformFlags |= 512 /* ContainsES2015 */; return node; } // @@ -23003,7 +23595,7 @@ var ts; // // @api function createBlock(statements, multiLine) { - var node = createBaseNode(230 /* Block */); + var node = createBaseNode(232 /* Block */); node.statements = createNodeArray(statements); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.statements); @@ -23017,7 +23609,7 @@ var ts; } // @api function createVariableStatement(modifiers, declarationList) { - var node = createBaseDeclaration(232 /* VariableStatement */, /*decorators*/ undefined, modifiers); + var node = createBaseDeclaration(234 /* VariableStatement */, /*decorators*/ undefined, modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; node.transformFlags |= propagateChildFlags(node.declarationList); @@ -23035,11 +23627,11 @@ var ts; } // @api function createEmptyStatement() { - return createBaseNode(231 /* EmptyStatement */); + return createBaseNode(233 /* EmptyStatement */); } // @api function createExpressionStatement(expression) { - var node = createBaseNode(233 /* ExpressionStatement */); + var node = createBaseNode(235 /* ExpressionStatement */); node.expression = parenthesizerRules().parenthesizeExpressionOfExpressionStatement(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -23052,7 +23644,7 @@ var ts; } // @api function createIfStatement(expression, thenStatement, elseStatement) { - var node = createBaseNode(234 /* IfStatement */); + var node = createBaseNode(236 /* IfStatement */); node.expression = expression; node.thenStatement = asEmbeddedStatement(thenStatement); node.elseStatement = asEmbeddedStatement(elseStatement); @@ -23072,7 +23664,7 @@ var ts; } // @api function createDoStatement(statement, expression) { - var node = createBaseNode(235 /* DoStatement */); + var node = createBaseNode(237 /* DoStatement */); node.statement = asEmbeddedStatement(statement); node.expression = expression; node.transformFlags |= @@ -23089,7 +23681,7 @@ var ts; } // @api function createWhileStatement(expression, statement) { - var node = createBaseNode(236 /* WhileStatement */); + var node = createBaseNode(238 /* WhileStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -23106,7 +23698,7 @@ var ts; } // @api function createForStatement(initializer, condition, incrementor, statement) { - var node = createBaseNode(237 /* ForStatement */); + var node = createBaseNode(239 /* ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -23129,7 +23721,7 @@ var ts; } // @api function createForInStatement(initializer, expression, statement) { - var node = createBaseNode(238 /* ForInStatement */); + var node = createBaseNode(240 /* ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = asEmbeddedStatement(statement); @@ -23149,7 +23741,7 @@ var ts; } // @api function createForOfStatement(awaitModifier, initializer, expression, statement) { - var node = createBaseNode(239 /* ForOfStatement */); + var node = createBaseNode(241 /* ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); @@ -23159,9 +23751,9 @@ var ts; propagateChildFlags(node.initializer) | propagateChildFlags(node.expression) | propagateChildFlags(node.statement) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; if (awaitModifier) - node.transformFlags |= 32 /* ContainsES2018 */; + node.transformFlags |= 64 /* ContainsES2018 */; return node; } // @api @@ -23175,11 +23767,11 @@ var ts; } // @api function createContinueStatement(label) { - var node = createBaseNode(240 /* ContinueStatement */); + var node = createBaseNode(242 /* ContinueStatement */); node.label = asName(label); node.transformFlags |= propagateChildFlags(node.label) | - 1048576 /* ContainsHoistedDeclarationOrCompletion */; + 2097152 /* ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -23190,11 +23782,11 @@ var ts; } // @api function createBreakStatement(label) { - var node = createBaseNode(241 /* BreakStatement */); + var node = createBaseNode(243 /* BreakStatement */); node.label = asName(label); node.transformFlags |= propagateChildFlags(node.label) | - 1048576 /* ContainsHoistedDeclarationOrCompletion */; + 2097152 /* ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -23205,13 +23797,13 @@ var ts; } // @api function createReturnStatement(expression) { - var node = createBaseNode(242 /* ReturnStatement */); + var node = createBaseNode(244 /* ReturnStatement */); node.expression = expression; // return in an ES2018 async generator must be awaited node.transformFlags |= propagateChildFlags(node.expression) | - 32 /* ContainsES2018 */ | - 1048576 /* ContainsHoistedDeclarationOrCompletion */; + 64 /* ContainsES2018 */ | + 2097152 /* ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -23222,7 +23814,7 @@ var ts; } // @api function createWithStatement(expression, statement) { - var node = createBaseNode(243 /* WithStatement */); + var node = createBaseNode(245 /* WithStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -23239,7 +23831,7 @@ var ts; } // @api function createSwitchStatement(expression, caseBlock) { - var node = createBaseNode(244 /* SwitchStatement */); + var node = createBaseNode(246 /* SwitchStatement */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.caseBlock = caseBlock; node.transformFlags |= @@ -23256,7 +23848,7 @@ var ts; } // @api function createLabeledStatement(label, statement) { - var node = createBaseNode(245 /* LabeledStatement */); + var node = createBaseNode(247 /* LabeledStatement */); node.label = asName(label); node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -23273,7 +23865,7 @@ var ts; } // @api function createThrowStatement(expression) { - var node = createBaseNode(246 /* ThrowStatement */); + var node = createBaseNode(248 /* ThrowStatement */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -23286,7 +23878,7 @@ var ts; } // @api function createTryStatement(tryBlock, catchClause, finallyBlock) { - var node = createBaseNode(247 /* TryStatement */); + var node = createBaseNode(249 /* TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -23306,11 +23898,11 @@ var ts; } // @api function createDebuggerStatement() { - return createBaseNode(248 /* DebuggerStatement */); + return createBaseNode(250 /* DebuggerStatement */); } // @api function createVariableDeclaration(name, exclamationToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(249 /* VariableDeclaration */, + var node = createBaseVariableLikeDeclaration(251 /* VariableDeclaration */, /*decorators*/ undefined, /*modifiers*/ undefined, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.exclamationToken = exclamationToken; @@ -23332,16 +23924,16 @@ var ts; // @api function createVariableDeclarationList(declarations, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createBaseNode(250 /* VariableDeclarationList */); + var node = createBaseNode(252 /* VariableDeclarationList */); node.flags |= flags & 3 /* BlockScoped */; node.declarations = createNodeArray(declarations); node.transformFlags |= propagateChildrenFlags(node.declarations) | - 1048576 /* ContainsHoistedDeclarationOrCompletion */; + 2097152 /* ContainsHoistedDeclarationOrCompletion */; if (flags & 3 /* BlockScoped */) { node.transformFlags |= - 256 /* ContainsES2015 */ | - 65536 /* ContainsBlockScopedBinding */; + 512 /* ContainsES2015 */ | + 131072 /* ContainsBlockScopedBinding */; } return node; } @@ -23353,7 +23945,7 @@ var ts; } // @api function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(251 /* FunctionDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(253 /* FunctionDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; if (!node.body || ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { node.transformFlags = 1 /* ContainsTypeScript */; @@ -23361,17 +23953,17 @@ var ts; else { node.transformFlags |= propagateChildFlags(node.asteriskToken) | - 1048576 /* ContainsHoistedDeclarationOrCompletion */; + 2097152 /* ContainsHoistedDeclarationOrCompletion */; if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { if (node.asteriskToken) { - node.transformFlags |= 32 /* ContainsES2018 */; + node.transformFlags |= 64 /* ContainsES2018 */; } else { - node.transformFlags |= 64 /* ContainsES2017 */; + node.transformFlags |= 128 /* ContainsES2017 */; } } else if (node.asteriskToken) { - node.transformFlags |= 512 /* ContainsGenerator */; + node.transformFlags |= 1024 /* ContainsGenerator */; } } return node; @@ -23391,13 +23983,13 @@ var ts; } // @api function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseClassLikeDeclaration(252 /* ClassDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses, members); + var node = createBaseClassLikeDeclaration(254 /* ClassDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses, members); if (ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { node.transformFlags = 1 /* ContainsTypeScript */; } else { - node.transformFlags |= 256 /* ContainsES2015 */; - if (node.transformFlags & 2048 /* ContainsTypeScriptClassSyntax */) { + node.transformFlags |= 512 /* ContainsES2015 */; + if (node.transformFlags & 4096 /* ContainsTypeScriptClassSyntax */) { node.transformFlags |= 1 /* ContainsTypeScript */; } } @@ -23416,7 +24008,7 @@ var ts; } // @api function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseInterfaceOrClassLikeDeclaration(253 /* InterfaceDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses); + var node = createBaseInterfaceOrClassLikeDeclaration(255 /* InterfaceDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses); node.members = createNodeArray(members); node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -23434,7 +24026,7 @@ var ts; } // @api function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createBaseGenericNamedDeclaration(254 /* TypeAliasDeclaration */, decorators, modifiers, name, typeParameters); + var node = createBaseGenericNamedDeclaration(256 /* TypeAliasDeclaration */, decorators, modifiers, name, typeParameters); node.type = type; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -23451,12 +24043,12 @@ var ts; } // @api function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createBaseNamedDeclaration(255 /* EnumDeclaration */, decorators, modifiers, name); + var node = createBaseNamedDeclaration(257 /* EnumDeclaration */, decorators, modifiers, name); node.members = createNodeArray(members); node.transformFlags |= propagateChildrenFlags(node.members) | 1 /* ContainsTypeScript */; - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await` + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await` return node; } // @api @@ -23471,7 +24063,7 @@ var ts; // @api function createModuleDeclaration(decorators, modifiers, name, body, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createBaseDeclaration(256 /* ModuleDeclaration */, decorators, modifiers); + var node = createBaseDeclaration(258 /* ModuleDeclaration */, decorators, modifiers); node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 1024 /* GlobalAugmentation */); node.name = name; node.body = body; @@ -23484,7 +24076,7 @@ var ts; propagateChildFlags(node.body) | 1 /* ContainsTypeScript */; } - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`. + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`. return node; } // @api @@ -23498,7 +24090,7 @@ var ts; } // @api function createModuleBlock(statements) { - var node = createBaseNode(257 /* ModuleBlock */); + var node = createBaseNode(259 /* ModuleBlock */); node.statements = createNodeArray(statements); node.transformFlags |= propagateChildrenFlags(node.statements); return node; @@ -23511,7 +24103,7 @@ var ts; } // @api function createCaseBlock(clauses) { - var node = createBaseNode(258 /* CaseBlock */); + var node = createBaseNode(260 /* CaseBlock */); node.clauses = createNodeArray(clauses); node.transformFlags |= propagateChildrenFlags(node.clauses); return node; @@ -23524,7 +24116,7 @@ var ts; } // @api function createNamespaceExportDeclaration(name) { - var node = createBaseNamedDeclaration(259 /* NamespaceExportDeclaration */, + var node = createBaseNamedDeclaration(261 /* NamespaceExportDeclaration */, /*decorators*/ undefined, /*modifiers*/ undefined, name); node.transformFlags = 1 /* ContainsTypeScript */; @@ -23538,13 +24130,13 @@ var ts; } // @api function createImportEqualsDeclaration(decorators, modifiers, isTypeOnly, name, moduleReference) { - var node = createBaseNamedDeclaration(260 /* ImportEqualsDeclaration */, decorators, modifiers, name); + var node = createBaseNamedDeclaration(262 /* ImportEqualsDeclaration */, decorators, modifiers, name); node.isTypeOnly = isTypeOnly; node.moduleReference = moduleReference; node.transformFlags |= propagateChildFlags(node.moduleReference); if (!ts.isExternalModuleReference(node.moduleReference)) node.transformFlags |= 1 /* ContainsTypeScript */; - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // Import= declaration is always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Import= declaration is always parsed in an Await context return node; } // @api @@ -23559,13 +24151,13 @@ var ts; } // @api function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createBaseDeclaration(261 /* ImportDeclaration */, decorators, modifiers); + var node = createBaseDeclaration(263 /* ImportDeclaration */, decorators, modifiers); node.importClause = importClause; node.moduleSpecifier = moduleSpecifier; node.transformFlags |= propagateChildFlags(node.importClause) | propagateChildFlags(node.moduleSpecifier); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23579,7 +24171,7 @@ var ts; } // @api function createImportClause(isTypeOnly, name, namedBindings) { - var node = createBaseNode(262 /* ImportClause */); + var node = createBaseNode(264 /* ImportClause */); node.isTypeOnly = isTypeOnly; node.name = name; node.namedBindings = namedBindings; @@ -23589,7 +24181,7 @@ var ts; if (isTypeOnly) { node.transformFlags |= 1 /* ContainsTypeScript */; } - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23602,10 +24194,10 @@ var ts; } // @api function createNamespaceImport(name) { - var node = createBaseNode(263 /* NamespaceImport */); + var node = createBaseNode(265 /* NamespaceImport */); node.name = name; node.transformFlags |= propagateChildFlags(node.name); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23616,12 +24208,12 @@ var ts; } // @api function createNamespaceExport(name) { - var node = createBaseNode(269 /* NamespaceExport */); + var node = createBaseNode(271 /* NamespaceExport */); node.name = name; node.transformFlags |= propagateChildFlags(node.name) | 4 /* ContainsESNext */; - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23632,10 +24224,10 @@ var ts; } // @api function createNamedImports(elements) { - var node = createBaseNode(264 /* NamedImports */); + var node = createBaseNode(266 /* NamedImports */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23646,13 +24238,13 @@ var ts; } // @api function createImportSpecifier(propertyName, name) { - var node = createBaseNode(265 /* ImportSpecifier */); + var node = createBaseNode(267 /* ImportSpecifier */); node.propertyName = propertyName; node.name = name; node.transformFlags |= propagateChildFlags(node.propertyName) | propagateChildFlags(node.name); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23664,13 +24256,13 @@ var ts; } // @api function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createBaseDeclaration(266 /* ExportAssignment */, decorators, modifiers); + var node = createBaseDeclaration(268 /* ExportAssignment */, decorators, modifiers); node.isExportEquals = isExportEquals; node.expression = isExportEquals - ? parenthesizerRules().parenthesizeRightSideOfBinary(62 /* EqualsToken */, /*leftSide*/ undefined, expression) + ? parenthesizerRules().parenthesizeRightSideOfBinary(63 /* EqualsToken */, /*leftSide*/ undefined, expression) : parenthesizerRules().parenthesizeExpressionOfExportDefault(expression); node.transformFlags |= propagateChildFlags(node.expression); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23683,14 +24275,14 @@ var ts; } // @api function createExportDeclaration(decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier) { - var node = createBaseDeclaration(267 /* ExportDeclaration */, decorators, modifiers); + var node = createBaseDeclaration(269 /* ExportDeclaration */, decorators, modifiers); node.isTypeOnly = isTypeOnly; node.exportClause = exportClause; node.moduleSpecifier = moduleSpecifier; node.transformFlags |= propagateChildFlags(node.exportClause) | propagateChildFlags(node.moduleSpecifier); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23705,10 +24297,10 @@ var ts; } // @api function createNamedExports(elements) { - var node = createBaseNode(268 /* NamedExports */); + var node = createBaseNode(270 /* NamedExports */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23719,13 +24311,13 @@ var ts; } // @api function createExportSpecifier(propertyName, name) { - var node = createBaseNode(270 /* ExportSpecifier */); + var node = createBaseNode(272 /* ExportSpecifier */); node.propertyName = asName(propertyName); node.name = asName(name); node.transformFlags |= propagateChildFlags(node.propertyName) | propagateChildFlags(node.name); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23737,7 +24329,7 @@ var ts; } // @api function createMissingDeclaration() { - var node = createBaseDeclaration(271 /* MissingDeclaration */, + var node = createBaseDeclaration(273 /* MissingDeclaration */, /*decorators*/ undefined, /*modifiers*/ undefined); return node; @@ -23747,10 +24339,10 @@ var ts; // // @api function createExternalModuleReference(expression) { - var node = createBaseNode(272 /* ExternalModuleReference */); + var node = createBaseNode(274 /* ExternalModuleReference */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23792,7 +24384,7 @@ var ts; } // @api function createJSDocFunctionType(parameters, type) { - var node = createBaseSignatureDeclaration(308 /* JSDocFunctionType */, + var node = createBaseSignatureDeclaration(311 /* JSDocFunctionType */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, @@ -23809,7 +24401,7 @@ var ts; // @api function createJSDocTypeLiteral(propertyTags, isArrayType) { if (isArrayType === void 0) { isArrayType = false; } - var node = createBaseNode(312 /* JSDocTypeLiteral */); + var node = createBaseNode(316 /* JSDocTypeLiteral */); node.jsDocPropertyTags = asNodeArray(propertyTags); node.isArrayType = isArrayType; return node; @@ -23823,7 +24415,7 @@ var ts; } // @api function createJSDocTypeExpression(type) { - var node = createBaseNode(301 /* JSDocTypeExpression */); + var node = createBaseNode(303 /* JSDocTypeExpression */); node.type = type; return node; } @@ -23835,7 +24427,7 @@ var ts; } // @api function createJSDocSignature(typeParameters, parameters, type) { - var node = createBaseNode(313 /* JSDocSignature */); + var node = createBaseNode(317 /* JSDocSignature */); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; @@ -23864,7 +24456,7 @@ var ts; } // @api function createJSDocTemplateTag(tagName, constraint, typeParameters, comment) { - var node = createBaseJSDocTag(330 /* JSDocTemplateTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("template"), comment); + var node = createBaseJSDocTag(338 /* JSDocTemplateTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("template"), comment); node.constraint = constraint; node.typeParameters = createNodeArray(typeParameters); return node; @@ -23881,7 +24473,7 @@ var ts; } // @api function createJSDocTypedefTag(tagName, typeExpression, fullName, comment) { - var node = createBaseJSDocTag(331 /* JSDocTypedefTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("typedef"), comment); + var node = createBaseJSDocTag(339 /* JSDocTypedefTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("typedef"), comment); node.typeExpression = typeExpression; node.fullName = fullName; node.name = ts.getJSDocTypeAliasName(fullName); @@ -23899,7 +24491,7 @@ var ts; } // @api function createJSDocParameterTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) { - var node = createBaseJSDocTag(326 /* JSDocParameterTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("param"), comment); + var node = createBaseJSDocTag(334 /* JSDocParameterTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("param"), comment); node.typeExpression = typeExpression; node.name = name; node.isNameFirst = !!isNameFirst; @@ -23920,7 +24512,7 @@ var ts; } // @api function createJSDocPropertyTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) { - var node = createBaseJSDocTag(333 /* JSDocPropertyTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("prop"), comment); + var node = createBaseJSDocTag(341 /* JSDocPropertyTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("prop"), comment); node.typeExpression = typeExpression; node.name = name; node.isNameFirst = !!isNameFirst; @@ -23941,7 +24533,7 @@ var ts; } // @api function createJSDocCallbackTag(tagName, typeExpression, fullName, comment) { - var node = createBaseJSDocTag(324 /* JSDocCallbackTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("callback"), comment); + var node = createBaseJSDocTag(332 /* JSDocCallbackTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("callback"), comment); node.typeExpression = typeExpression; node.fullName = fullName; node.name = ts.getJSDocTypeAliasName(fullName); @@ -23959,7 +24551,7 @@ var ts; } // @api function createJSDocAugmentsTag(tagName, className, comment) { - var node = createBaseJSDocTag(315 /* JSDocAugmentsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("augments"), comment); + var node = createBaseJSDocTag(322 /* JSDocAugmentsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("augments"), comment); node.class = className; return node; } @@ -23974,13 +24566,13 @@ var ts; } // @api function createJSDocImplementsTag(tagName, className, comment) { - var node = createBaseJSDocTag(316 /* JSDocImplementsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("implements"), comment); + var node = createBaseJSDocTag(323 /* JSDocImplementsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("implements"), comment); node.class = className; return node; } // @api function createJSDocSeeTag(tagName, name, comment) { - var node = createBaseJSDocTag(332 /* JSDocSeeTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("see"), comment); + var node = createBaseJSDocTag(340 /* JSDocSeeTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("see"), comment); node.name = name; return node; } @@ -23994,7 +24586,7 @@ var ts; } // @api function createJSDocNameReference(name) { - var node = createBaseNode(302 /* JSDocNameReference */); + var node = createBaseNode(304 /* JSDocNameReference */); node.name = name; return node; } @@ -24005,6 +24597,62 @@ var ts; : node; } // @api + function createJSDocMemberName(left, right) { + var node = createBaseNode(305 /* JSDocMemberName */); + node.left = left; + node.right = right; + node.transformFlags |= + propagateChildFlags(node.left) | + propagateChildFlags(node.right); + return node; + } + // @api + function updateJSDocMemberName(node, left, right) { + return node.left !== left + || node.right !== right + ? update(createJSDocMemberName(left, right), node) + : node; + } + // @api + function createJSDocLink(name, text) { + var node = createBaseNode(318 /* JSDocLink */); + node.name = name; + node.text = text; + return node; + } + // @api + function updateJSDocLink(node, name, text) { + return node.name !== name + ? update(createJSDocLink(name, text), node) + : node; + } + // @api + function createJSDocLinkCode(name, text) { + var node = createBaseNode(319 /* JSDocLinkCode */); + node.name = name; + node.text = text; + return node; + } + // @api + function updateJSDocLinkCode(node, name, text) { + return node.name !== name + ? update(createJSDocLinkCode(name, text), node) + : node; + } + // @api + function createJSDocLinkPlain(name, text) { + var node = createBaseNode(320 /* JSDocLinkPlain */); + node.name = name; + node.text = text; + return node; + } + // @api + function updateJSDocLinkPlain(node, name, text) { + return node.name !== name + ? update(createJSDocLinkPlain(name, text), node) + : node; + } + // @api function updateJSDocImplementsTag(node, tagName, className, comment) { if (tagName === void 0) { tagName = getDefaultTagName(node); } return node.tagName !== tagName @@ -24065,7 +24713,7 @@ var ts; } // @api function createJSDocUnknownTag(tagName, comment) { - var node = createBaseJSDocTag(314 /* JSDocTag */, tagName, comment); + var node = createBaseJSDocTag(321 /* JSDocTag */, tagName, comment); return node; } // @api @@ -24076,8 +24724,20 @@ var ts; : node; } // @api + function createJSDocText(text) { + var node = createBaseNode(315 /* JSDocText */); + node.text = text; + return node; + } + // @api + function updateJSDocText(node, text) { + return node.text !== text + ? update(createJSDocText(text), node) + : node; + } + // @api function createJSDocComment(comment, tags) { - var node = createBaseNode(311 /* JSDocComment */); + var node = createBaseNode(314 /* JSDocComment */); node.comment = comment; node.tags = asNodeArray(tags); return node; @@ -24094,7 +24754,7 @@ var ts; // // @api function createJsxElement(openingElement, children, closingElement) { - var node = createBaseNode(273 /* JsxElement */); + var node = createBaseNode(275 /* JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -24115,7 +24775,7 @@ var ts; } // @api function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createBaseNode(274 /* JsxSelfClosingElement */); + var node = createBaseNode(276 /* JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -24139,7 +24799,7 @@ var ts; } // @api function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createBaseNode(275 /* JsxOpeningElement */); + var node = createBaseNode(277 /* JsxOpeningElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -24163,7 +24823,7 @@ var ts; } // @api function createJsxClosingElement(tagName) { - var node = createBaseNode(276 /* JsxClosingElement */); + var node = createBaseNode(278 /* JsxClosingElement */); node.tagName = tagName; node.transformFlags |= propagateChildFlags(node.tagName) | @@ -24178,7 +24838,7 @@ var ts; } // @api function createJsxFragment(openingFragment, children, closingFragment) { - var node = createBaseNode(277 /* JsxFragment */); + var node = createBaseNode(279 /* JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -24214,19 +24874,19 @@ var ts; } // @api function createJsxOpeningFragment() { - var node = createBaseNode(278 /* JsxOpeningFragment */); + var node = createBaseNode(280 /* JsxOpeningFragment */); node.transformFlags |= 2 /* ContainsJsx */; return node; } // @api function createJsxJsxClosingFragment() { - var node = createBaseNode(279 /* JsxClosingFragment */); + var node = createBaseNode(281 /* JsxClosingFragment */); node.transformFlags |= 2 /* ContainsJsx */; return node; } // @api function createJsxAttribute(name, initializer) { - var node = createBaseNode(280 /* JsxAttribute */); + var node = createBaseNode(282 /* JsxAttribute */); node.name = name; node.initializer = initializer; node.transformFlags |= @@ -24244,7 +24904,7 @@ var ts; } // @api function createJsxAttributes(properties) { - var node = createBaseNode(281 /* JsxAttributes */); + var node = createBaseNode(283 /* JsxAttributes */); node.properties = createNodeArray(properties); node.transformFlags |= propagateChildrenFlags(node.properties) | @@ -24259,7 +24919,7 @@ var ts; } // @api function createJsxSpreadAttribute(expression) { - var node = createBaseNode(282 /* JsxSpreadAttribute */); + var node = createBaseNode(284 /* JsxSpreadAttribute */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression) | @@ -24274,7 +24934,7 @@ var ts; } // @api function createJsxExpression(dotDotDotToken, expression) { - var node = createBaseNode(283 /* JsxExpression */); + var node = createBaseNode(285 /* JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; node.transformFlags |= @@ -24294,7 +24954,7 @@ var ts; // // @api function createCaseClause(expression, statements) { - var node = createBaseNode(284 /* CaseClause */); + var node = createBaseNode(286 /* CaseClause */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.statements = createNodeArray(statements); node.transformFlags |= @@ -24311,7 +24971,7 @@ var ts; } // @api function createDefaultClause(statements) { - var node = createBaseNode(285 /* DefaultClause */); + var node = createBaseNode(287 /* DefaultClause */); node.statements = createNodeArray(statements); node.transformFlags = propagateChildrenFlags(node.statements); return node; @@ -24324,15 +24984,15 @@ var ts; } // @api function createHeritageClause(token, types) { - var node = createBaseNode(286 /* HeritageClause */); + var node = createBaseNode(288 /* HeritageClause */); node.token = token; node.types = createNodeArray(types); node.transformFlags |= propagateChildrenFlags(node.types); switch (token) { - case 93 /* ExtendsKeyword */: - node.transformFlags |= 256 /* ContainsES2015 */; + case 94 /* ExtendsKeyword */: + node.transformFlags |= 512 /* ContainsES2015 */; break; - case 116 /* ImplementsKeyword */: + case 117 /* ImplementsKeyword */: node.transformFlags |= 1 /* ContainsTypeScript */; break; default: @@ -24348,7 +25008,7 @@ var ts; } // @api function createCatchClause(variableDeclaration, block) { - var node = createBaseNode(287 /* CatchClause */); + var node = createBaseNode(289 /* CatchClause */); variableDeclaration = !ts.isString(variableDeclaration) ? variableDeclaration : createVariableDeclaration(variableDeclaration, /*exclamationToken*/ undefined, /*type*/ undefined, @@ -24359,7 +25019,7 @@ var ts; propagateChildFlags(node.variableDeclaration) | propagateChildFlags(node.block); if (!variableDeclaration) - node.transformFlags |= 16 /* ContainsES2019 */; + node.transformFlags |= 32 /* ContainsES2019 */; return node; } // @api @@ -24374,7 +25034,7 @@ var ts; // // @api function createPropertyAssignment(name, initializer) { - var node = createBaseNamedDeclaration(288 /* PropertyAssignment */, + var node = createBaseNamedDeclaration(290 /* PropertyAssignment */, /*decorators*/ undefined, /*modifiers*/ undefined, name); node.initializer = parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); @@ -24404,13 +25064,13 @@ var ts; } // @api function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createBaseNamedDeclaration(289 /* ShorthandPropertyAssignment */, + var node = createBaseNamedDeclaration(291 /* ShorthandPropertyAssignment */, /*decorators*/ undefined, /*modifiers*/ undefined, name); node.objectAssignmentInitializer = objectAssignmentInitializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(objectAssignmentInitializer); node.transformFlags |= propagateChildFlags(node.objectAssignmentInitializer) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; return node; } function finishUpdateShorthandPropertyAssignment(updated, original) { @@ -24436,12 +25096,12 @@ var ts; } // @api function createSpreadAssignment(expression) { - var node = createBaseNode(290 /* SpreadAssignment */); + var node = createBaseNode(292 /* SpreadAssignment */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 32 /* ContainsES2018 */ | - 16384 /* ContainsObjectRestOrSpread */; + 64 /* ContainsES2018 */ | + 32768 /* ContainsObjectRestOrSpread */; return node; } // @api @@ -24455,7 +25115,7 @@ var ts; // // @api function createEnumMember(name, initializer) { - var node = createBaseNode(291 /* EnumMember */); + var node = createBaseNode(293 /* EnumMember */); node.name = asName(name); node.initializer = initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); node.transformFlags |= @@ -24476,7 +25136,7 @@ var ts; // // @api function createSourceFile(statements, endOfFileToken, flags) { - var node = baseFactory.createBaseSourceFileNode(297 /* SourceFile */); + var node = baseFactory.createBaseSourceFileNode(299 /* SourceFile */); node.statements = createNodeArray(statements); node.endOfFileToken = endOfFileToken; node.flags |= flags; @@ -24493,7 +25153,7 @@ var ts; return node; } function cloneSourceFileWithChanges(source, statements, isDeclarationFile, referencedFiles, typeReferences, hasNoDefaultLib, libReferences) { - var node = baseFactory.createBaseSourceFileNode(297 /* SourceFile */); + var node = baseFactory.createBaseSourceFileNode(299 /* SourceFile */); for (var p in source) { if (p === "emitNode" || ts.hasProperty(node, p) || !ts.hasProperty(source, p)) continue; @@ -24531,7 +25191,7 @@ var ts; // @api function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = createBaseNode(298 /* Bundle */); + var node = createBaseNode(300 /* Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; @@ -24546,7 +25206,7 @@ var ts; } // @api function createUnparsedSource(prologues, syntheticReferences, texts) { - var node = createBaseNode(299 /* UnparsedSource */); + var node = createBaseNode(301 /* UnparsedSource */); node.prologues = prologues; node.syntheticReferences = syntheticReferences; node.texts = texts; @@ -24564,28 +25224,28 @@ var ts; } // @api function createUnparsedPrologue(data) { - return createBaseUnparsedNode(292 /* UnparsedPrologue */, data); + return createBaseUnparsedNode(294 /* UnparsedPrologue */, data); } // @api function createUnparsedPrepend(data, texts) { - var node = createBaseUnparsedNode(293 /* UnparsedPrepend */, data); + var node = createBaseUnparsedNode(295 /* UnparsedPrepend */, data); node.texts = texts; return node; } // @api function createUnparsedTextLike(data, internal) { - return createBaseUnparsedNode(internal ? 295 /* UnparsedInternalText */ : 294 /* UnparsedText */, data); + return createBaseUnparsedNode(internal ? 297 /* UnparsedInternalText */ : 296 /* UnparsedText */, data); } // @api function createUnparsedSyntheticReference(section) { - var node = createBaseNode(296 /* UnparsedSyntheticReference */); + var node = createBaseNode(298 /* UnparsedSyntheticReference */); node.data = section.data; node.section = section; return node; } // @api function createInputFiles() { - var node = createBaseNode(300 /* InputFiles */); + var node = createBaseNode(302 /* InputFiles */); node.javascriptText = ""; node.declarationText = ""; return node; @@ -24596,7 +25256,7 @@ var ts; // @api function createSyntheticExpression(type, isSpread, tupleNameSource) { if (isSpread === void 0) { isSpread = false; } - var node = createBaseNode(227 /* SyntheticExpression */); + var node = createBaseNode(229 /* SyntheticExpression */); node.type = type; node.isSpread = isSpread; node.tupleNameSource = tupleNameSource; @@ -24604,7 +25264,7 @@ var ts; } // @api function createSyntaxList(children) { - var node = createBaseNode(334 /* SyntaxList */); + var node = createBaseNode(342 /* SyntaxList */); node._children = children; return node; } @@ -24619,7 +25279,7 @@ var ts; */ // @api function createNotEmittedStatement(original) { - var node = createBaseNode(335 /* NotEmittedStatement */); + var node = createBaseNode(343 /* NotEmittedStatement */); node.original = original; ts.setTextRange(node, original); return node; @@ -24633,7 +25293,7 @@ var ts; */ // @api function createPartiallyEmittedExpression(expression, original) { - var node = createBaseNode(336 /* PartiallyEmittedExpression */); + var node = createBaseNode(344 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; node.transformFlags |= @@ -24661,7 +25321,7 @@ var ts; } // @api function createCommaListExpression(elements) { - var node = createBaseNode(337 /* CommaListExpression */); + var node = createBaseNode(345 /* CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); node.transformFlags |= propagateChildrenFlags(node.elements); return node; @@ -24678,7 +25338,7 @@ var ts; */ // @api function createEndOfDeclarationMarker(original) { - var node = createBaseNode(339 /* EndOfDeclarationMarker */); + var node = createBaseNode(347 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -24689,14 +25349,14 @@ var ts; */ // @api function createMergeDeclarationMarker(original) { - var node = createBaseNode(338 /* MergeDeclarationMarker */); + var node = createBaseNode(346 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; } // @api function createSyntheticReferenceExpression(expression, thisArg) { - var node = createBaseNode(340 /* SyntheticReferenceExpression */); + var node = createBaseNode(348 /* SyntheticReferenceExpression */); node.expression = expression; node.thisArg = thisArg; node.transformFlags |= @@ -24718,9 +25378,9 @@ var ts; if (node === undefined) { return node; } - var clone = ts.isSourceFile(node) ? baseFactory.createBaseSourceFileNode(297 /* SourceFile */) : - ts.isIdentifier(node) ? baseFactory.createBaseIdentifierNode(78 /* Identifier */) : - ts.isPrivateIdentifier(node) ? baseFactory.createBasePrivateIdentifierNode(79 /* PrivateIdentifier */) : + var clone = ts.isSourceFile(node) ? baseFactory.createBaseSourceFileNode(299 /* SourceFile */) : + ts.isIdentifier(node) ? baseFactory.createBaseIdentifierNode(79 /* Identifier */) : + ts.isPrivateIdentifier(node) ? baseFactory.createBasePrivateIdentifierNode(80 /* PrivateIdentifier */) : !ts.isNodeKind(node.kind) ? baseFactory.createBaseTokenNode(node.kind) : baseFactory.createBaseNode(node.kind); clone.flags |= (node.flags & ~8 /* Synthesized */); @@ -24825,11 +25485,11 @@ var ts; } function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 207 /* ParenthesizedExpression */: return updateParenthesizedExpression(outerExpression, expression); - case 206 /* TypeAssertionExpression */: return updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 224 /* AsExpression */: return updateAsExpression(outerExpression, expression, outerExpression.type); - case 225 /* NonNullExpression */: return updateNonNullExpression(outerExpression, expression); - case 336 /* PartiallyEmittedExpression */: return updatePartiallyEmittedExpression(outerExpression, expression); + case 209 /* ParenthesizedExpression */: return updateParenthesizedExpression(outerExpression, expression); + case 208 /* TypeAssertionExpression */: return updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 226 /* AsExpression */: return updateAsExpression(outerExpression, expression, outerExpression.type); + case 227 /* NonNullExpression */: return updateNonNullExpression(outerExpression, expression); + case 344 /* PartiallyEmittedExpression */: return updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -24876,20 +25536,20 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = ts.skipParentheses(node); switch (target.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return cacheIdentifiers; - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: return false; - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -25292,23 +25952,24 @@ var ts; } function getDefaultTagNameForKind(kind) { switch (kind) { - case 329 /* JSDocTypeTag */: return "type"; - case 327 /* JSDocReturnTag */: return "returns"; - case 328 /* JSDocThisTag */: return "this"; - case 325 /* JSDocEnumTag */: return "enum"; - case 317 /* JSDocAuthorTag */: return "author"; - case 319 /* JSDocClassTag */: return "class"; - case 320 /* JSDocPublicTag */: return "public"; - case 321 /* JSDocPrivateTag */: return "private"; - case 322 /* JSDocProtectedTag */: return "protected"; - case 323 /* JSDocReadonlyTag */: return "readonly"; - case 330 /* JSDocTemplateTag */: return "template"; - case 331 /* JSDocTypedefTag */: return "typedef"; - case 326 /* JSDocParameterTag */: return "param"; - case 333 /* JSDocPropertyTag */: return "prop"; - case 324 /* JSDocCallbackTag */: return "callback"; - case 315 /* JSDocAugmentsTag */: return "augments"; - case 316 /* JSDocImplementsTag */: return "implements"; + case 337 /* JSDocTypeTag */: return "type"; + case 335 /* JSDocReturnTag */: return "returns"; + case 336 /* JSDocThisTag */: return "this"; + case 333 /* JSDocEnumTag */: return "enum"; + case 324 /* JSDocAuthorTag */: return "author"; + case 326 /* JSDocClassTag */: return "class"; + case 327 /* JSDocPublicTag */: return "public"; + case 328 /* JSDocPrivateTag */: return "private"; + case 329 /* JSDocProtectedTag */: return "protected"; + case 330 /* JSDocReadonlyTag */: return "readonly"; + case 331 /* JSDocOverrideTag */: return "override"; + case 338 /* JSDocTemplateTag */: return "template"; + case 339 /* JSDocTypedefTag */: return "typedef"; + case 334 /* JSDocParameterTag */: return "param"; + case 341 /* JSDocPropertyTag */: return "prop"; + case 332 /* JSDocCallbackTag */: return "callback"; + case 322 /* JSDocAugmentsTag */: return "augments"; + case 323 /* JSDocImplementsTag */: return "implements"; default: return ts.Debug.fail("Unsupported kind: " + ts.Debug.formatSyntaxKind(kind)); } @@ -25361,10 +26022,10 @@ var ts; } function propagateIdentifierNameFlags(node) { // An IdentifierName is allowed to be `await` - return propagateChildFlags(node) & ~8388608 /* ContainsPossibleTopLevelAwait */; + return propagateChildFlags(node) & ~16777216 /* ContainsPossibleTopLevelAwait */; } function propagatePropertyNameFlagsOfChild(node, transformFlags) { - return transformFlags | (node.transformFlags & 4096 /* PropertyNamePropagatingFlags */); + return transformFlags | (node.transformFlags & 8192 /* PropertyNamePropagatingFlags */); } function propagateChildFlags(child) { if (!child) @@ -25388,69 +26049,69 @@ var ts; */ /* @internal */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 172 /* FirstTypeNode */ && kind <= 195 /* LastTypeNode */) { + if (kind >= 174 /* FirstTypeNode */ && kind <= 197 /* LastTypeNode */) { return -2 /* TypeExcludes */; } switch (kind) { - case 203 /* CallExpression */: - case 204 /* NewExpression */: - case 199 /* ArrayLiteralExpression */: - return 536879104 /* ArrayLiteralOrCallOrNewExcludes */; - case 256 /* ModuleDeclaration */: - return 546379776 /* ModuleExcludes */; - case 160 /* Parameter */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: + case 201 /* ArrayLiteralExpression */: + return 536887296 /* ArrayLiteralOrCallOrNewExcludes */; + case 258 /* ModuleDeclaration */: + return 555888640 /* ModuleExcludes */; + case 162 /* Parameter */: return 536870912 /* ParameterExcludes */; - case 209 /* ArrowFunction */: - return 547309568 /* ArrowFunctionExcludes */; - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: - return 547313664 /* FunctionExcludes */; - case 250 /* VariableDeclarationList */: - return 537018368 /* VariableDeclarationListExcludes */; - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - return 536905728 /* ClassExcludes */; - case 166 /* Constructor */: - return 547311616 /* ConstructorExcludes */; - case 163 /* PropertyDeclaration */: - return 536875008 /* PropertyExcludes */; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - return 538923008 /* MethodOrAccessorExcludes */; - case 128 /* AnyKeyword */: - case 144 /* NumberKeyword */: - case 155 /* BigIntKeyword */: - case 141 /* NeverKeyword */: - case 147 /* StringKeyword */: - case 145 /* ObjectKeyword */: - case 131 /* BooleanKeyword */: - case 148 /* SymbolKeyword */: - case 113 /* VoidKeyword */: - case 159 /* TypeParameter */: - case 162 /* PropertySignature */: - case 164 /* MethodSignature */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 211 /* ArrowFunction */: + return 557748224 /* ArrowFunctionExcludes */; + case 210 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + return 557756416 /* FunctionExcludes */; + case 252 /* VariableDeclarationList */: + return 537165824 /* VariableDeclarationListExcludes */; + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + return 536940544 /* ClassExcludes */; + case 168 /* Constructor */: + return 557752320 /* ConstructorExcludes */; + case 165 /* PropertyDeclaration */: + return 536879104 /* PropertyExcludes */; + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + return 540975104 /* MethodOrAccessorExcludes */; + case 129 /* AnyKeyword */: + case 145 /* NumberKeyword */: + case 156 /* BigIntKeyword */: + case 142 /* NeverKeyword */: + case 148 /* StringKeyword */: + case 146 /* ObjectKeyword */: + case 132 /* BooleanKeyword */: + case 149 /* SymbolKeyword */: + case 114 /* VoidKeyword */: + case 161 /* TypeParameter */: + case 164 /* PropertySignature */: + case 166 /* MethodSignature */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 173 /* IndexSignature */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: return -2 /* TypeExcludes */; - case 200 /* ObjectLiteralExpression */: - return 536922112 /* ObjectLiteralExcludes */; - case 287 /* CatchClause */: - return 536887296 /* CatchClauseExcludes */; - case 196 /* ObjectBindingPattern */: - case 197 /* ArrayBindingPattern */: - return 536879104 /* BindingPatternExcludes */; - case 206 /* TypeAssertionExpression */: - case 224 /* AsExpression */: - case 336 /* PartiallyEmittedExpression */: - case 207 /* ParenthesizedExpression */: - case 105 /* SuperKeyword */: + case 202 /* ObjectLiteralExpression */: + return 536973312 /* ObjectLiteralExcludes */; + case 289 /* CatchClause */: + return 536903680 /* CatchClauseExcludes */; + case 198 /* ObjectBindingPattern */: + case 199 /* ArrayBindingPattern */: + return 536887296 /* BindingPatternExcludes */; + case 208 /* TypeAssertionExpression */: + case 226 /* AsExpression */: + case 344 /* PartiallyEmittedExpression */: + case 209 /* ParenthesizedExpression */: + case 106 /* SuperKeyword */: return 536870912 /* OuterExpressionExcludes */; - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: return 536870912 /* PropertyAccessExcludes */; default: return 536870912 /* NodeExcludes */; @@ -25749,7 +26410,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 === 297 /* SourceFile */) { + if (node.kind === 299 /* 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."); @@ -26236,13 +26897,27 @@ var ts; /*typeArguments*/ undefined, [moduleExpression, exportsExpression]); } // Class Fields Helpers - function createClassPrivateFieldGetHelper(receiver, privateField) { + function createClassPrivateFieldGetHelper(receiver, state, kind, f) { context.requestEmitHelper(ts.classPrivateFieldGetHelper); - return factory.createCallExpression(getUnscopedHelperName("__classPrivateFieldGet"), /*typeArguments*/ undefined, [receiver, privateField]); + var args; + if (!f) { + args = [receiver, state, factory.createStringLiteral(kind)]; + } + else { + args = [receiver, state, factory.createStringLiteral(kind), f]; + } + return factory.createCallExpression(getUnscopedHelperName("__classPrivateFieldGet"), /*typeArguments*/ undefined, args); } - function createClassPrivateFieldSetHelper(receiver, privateField, value) { + function createClassPrivateFieldSetHelper(receiver, state, value, kind, f) { context.requestEmitHelper(ts.classPrivateFieldSetHelper); - return factory.createCallExpression(getUnscopedHelperName("__classPrivateFieldSet"), /*typeArguments*/ undefined, [receiver, privateField, value]); + var args; + if (!f) { + args = [receiver, state, value, factory.createStringLiteral(kind)]; + } + else { + args = [receiver, state, value, factory.createStringLiteral(kind), f]; + } + return factory.createCallExpression(getUnscopedHelperName("__classPrivateFieldSet"), /*typeArguments*/ undefined, args); } } ts.createEmitHelperFactory = createEmitHelperFactory; @@ -26482,7 +27157,6 @@ var ts; scoped: false, text: "\n var __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n };" }; - // emit output for the __export helper function ts.exportStarHelper = { name: "typescript:export-star", importName: "__exportStar", @@ -26491,18 +27165,116 @@ var ts; priority: 2, text: "\n var __exportStar = (this && this.__exportStar) || function(m, exports) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\n };" }; - // Class fields helpers + /** + * Parameters: + * @param receiver — The object from which the private member will be read. + * @param state — One of the following: + * - A WeakMap used to read a private instance field. + * - A WeakSet used as an instance brand for private instance methods and accessors. + * - A function value that should be the undecorated class constructor used to brand check private static fields, methods, and accessors. + * @param kind — (optional pre TS 4.3, required for TS 4.3+) One of the following values: + * - undefined — Indicates a private instance field (pre TS 4.3). + * - "f" — Indicates a private field (instance or static). + * - "m" — Indicates a private method (instance or static). + * - "a" — Indicates a private accessor (instance or static). + * @param f — (optional pre TS 4.3) Depends on the arguments for state and kind: + * - If kind is "m", this should be the function corresponding to the static or instance method. + * - If kind is "a", this should be the function corresponding to the getter method, or undefined if the getter was not defined. + * - If kind is "f" and state is a function, this should be an object holding the value of a static field, or undefined if the static field declaration has not yet been evaluated. + * Usage: + * This helper will only ever be used by the compiler in the following ways: + * + * Reading from a private instance field (pre TS 4.3): + * __classPrivateFieldGet(, ) + * + * Reading from a private instance field (TS 4.3+): + * __classPrivateFieldGet(, , "f") + * + * Reading from a private instance get accessor (when defined, TS 4.3+): + * __classPrivateFieldGet(, , "a", ) + * + * Reading from a private instance get accessor (when not defined, TS 4.3+): + * __classPrivateFieldGet(, , "a", void 0) + * NOTE: This always results in a runtime error. + * + * Reading from a private instance method (TS 4.3+): + * __classPrivateFieldGet(, , "m", ) + * + * Reading from a private static field (TS 4.3+): + * __classPrivateFieldGet(, , "f", <{ value: any }>) + * + * Reading from a private static get accessor (when defined, TS 4.3+): + * __classPrivateFieldGet(, , "a", ) + * + * Reading from a private static get accessor (when not defined, TS 4.3+): + * __classPrivateFieldGet(, , "a", void 0) + * NOTE: This always results in a runtime error. + * + * Reading from a private static method (TS 4.3+): + * __classPrivateFieldGet(, , "m", ) + */ ts.classPrivateFieldGetHelper = { name: "typescript:classPrivateFieldGet", importName: "__classPrivateFieldGet", scoped: false, - text: "\n var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, privateMap) {\n if (!privateMap.has(receiver)) {\n throw new TypeError(\"attempted to get private field on non-instance\");\n }\n return privateMap.get(receiver);\n };" + text: "\n var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n };" }; + /** + * Parameters: + * @param receiver — The object on which the private member will be set. + * @param state — One of the following: + * - A WeakMap used to store a private instance field. + * - A WeakSet used as an instance brand for private instance methods and accessors. + * - A function value that should be the undecorated class constructor used to brand check private static fields, methods, and accessors. + * @param value — The value to set. + * @param kind — (optional pre TS 4.3, required for TS 4.3+) One of the following values: + * - undefined — Indicates a private instance field (pre TS 4.3). + * - "f" — Indicates a private field (instance or static). + * - "m" — Indicates a private method (instance or static). + * - "a" — Indicates a private accessor (instance or static). + * @param f — (optional pre TS 4.3) Depends on the arguments for state and kind: + * - If kind is "m", this should be the function corresponding to the static or instance method. + * - If kind is "a", this should be the function corresponding to the setter method, or undefined if the setter was not defined. + * - If kind is "f" and state is a function, this should be an object holding the value of a static field, or undefined if the static field declaration has not yet been evaluated. + * Usage: + * This helper will only ever be used by the compiler in the following ways: + * + * Writing to a private instance field (pre TS 4.3): + * __classPrivateFieldSet(, , ) + * + * Writing to a private instance field (TS 4.3+): + * __classPrivateFieldSet(, , , "f") + * + * Writing to a private instance set accessor (when defined, TS 4.3+): + * __classPrivateFieldSet(, , , "a", ) + * + * Writing to a private instance set accessor (when not defined, TS 4.3+): + * __classPrivateFieldSet(, , , "a", void 0) + * NOTE: This always results in a runtime error. + * + * Writing to a private instance method (TS 4.3+): + * __classPrivateFieldSet(, , , "m", ) + * NOTE: This always results in a runtime error. + * + * Writing to a private static field (TS 4.3+): + * __classPrivateFieldSet(, , , "f", <{ value: any }>) + * + * Writing to a private static set accessor (when defined, TS 4.3+): + * __classPrivateFieldSet(, , , "a", ) + * + * Writing to a private static set accessor (when not defined, TS 4.3+): + * __classPrivateFieldSet(, , , "a", void 0) + * NOTE: This always results in a runtime error. + * + * Writing to a private static method (TS 4.3+): + * __classPrivateFieldSet(, , , "m", ) + * NOTE: This always results in a runtime error. + */ ts.classPrivateFieldSetHelper = { name: "typescript:classPrivateFieldSet", importName: "__classPrivateFieldSet", scoped: false, - text: "\n var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, privateMap, value) {\n if (!privateMap.has(receiver)) {\n throw new TypeError(\"attempted to set private field on non-instance\");\n }\n privateMap.set(receiver, value);\n return value;\n };" + text: "\n var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\n };" }; var allUnscopedEmitHelpers; function getAllUnscopedEmitHelpers() { @@ -26591,626 +27363,688 @@ var ts; return node.kind === 17 /* TemplateTail */; } ts.isTemplateTail = isTemplateTail; + // Punctuation + function isDotDotDotToken(node) { + return node.kind === 25 /* DotDotDotToken */; + } + ts.isDotDotDotToken = isDotDotDotToken; + /*@internal*/ + function isCommaToken(node) { + return node.kind === 27 /* CommaToken */; + } + ts.isCommaToken = isCommaToken; + function isPlusToken(node) { + return node.kind === 39 /* PlusToken */; + } + ts.isPlusToken = isPlusToken; + function isMinusToken(node) { + return node.kind === 40 /* MinusToken */; + } + ts.isMinusToken = isMinusToken; + function isAsteriskToken(node) { + return node.kind === 41 /* AsteriskToken */; + } + ts.isAsteriskToken = isAsteriskToken; + /*@internal*/ + function isExclamationToken(node) { + return node.kind === 53 /* ExclamationToken */; + } + ts.isExclamationToken = isExclamationToken; + /*@internal*/ + function isQuestionToken(node) { + return node.kind === 57 /* QuestionToken */; + } + ts.isQuestionToken = isQuestionToken; + /*@internal*/ + function isColonToken(node) { + return node.kind === 58 /* ColonToken */; + } + ts.isColonToken = isColonToken; + /*@internal*/ + function isQuestionDotToken(node) { + return node.kind === 28 /* QuestionDotToken */; + } + ts.isQuestionDotToken = isQuestionDotToken; + /*@internal*/ + function isEqualsGreaterThanToken(node) { + return node.kind === 38 /* EqualsGreaterThanToken */; + } + ts.isEqualsGreaterThanToken = isEqualsGreaterThanToken; // Identifiers function isIdentifier(node) { - return node.kind === 78 /* Identifier */; + return node.kind === 79 /* Identifier */; } ts.isIdentifier = isIdentifier; - // Names - function isQualifiedName(node) { - return node.kind === 157 /* QualifiedName */; - } - ts.isQualifiedName = isQualifiedName; - function isComputedPropertyName(node) { - return node.kind === 158 /* ComputedPropertyName */; - } - ts.isComputedPropertyName = isComputedPropertyName; function isPrivateIdentifier(node) { - return node.kind === 79 /* PrivateIdentifier */; + return node.kind === 80 /* PrivateIdentifier */; } ts.isPrivateIdentifier = isPrivateIdentifier; - // Tokens + // Reserved Words + /* @internal */ + function isExportModifier(node) { + return node.kind === 93 /* ExportKeyword */; + } + ts.isExportModifier = isExportModifier; + /* @internal */ + function isAsyncModifier(node) { + return node.kind === 130 /* AsyncKeyword */; + } + ts.isAsyncModifier = isAsyncModifier; + /* @internal */ + function isAssertsKeyword(node) { + return node.kind === 128 /* AssertsKeyword */; + } + ts.isAssertsKeyword = isAssertsKeyword; + /* @internal */ + function isAwaitKeyword(node) { + return node.kind === 131 /* AwaitKeyword */; + } + ts.isAwaitKeyword = isAwaitKeyword; + /* @internal */ + function isReadonlyKeyword(node) { + return node.kind === 143 /* ReadonlyKeyword */; + } + ts.isReadonlyKeyword = isReadonlyKeyword; + /* @internal */ + function isStaticModifier(node) { + return node.kind === 124 /* StaticKeyword */; + } + ts.isStaticModifier = isStaticModifier; /*@internal*/ function isSuperKeyword(node) { - return node.kind === 105 /* SuperKeyword */; + return node.kind === 106 /* SuperKeyword */; } ts.isSuperKeyword = isSuperKeyword; /*@internal*/ function isImportKeyword(node) { - return node.kind === 99 /* ImportKeyword */; + return node.kind === 100 /* ImportKeyword */; } ts.isImportKeyword = isImportKeyword; - /*@internal*/ - function isCommaToken(node) { - return node.kind === 27 /* CommaToken */; - } - ts.isCommaToken = isCommaToken; - /*@internal*/ - function isQuestionToken(node) { - return node.kind === 57 /* QuestionToken */; + // Names + function isQualifiedName(node) { + return node.kind === 159 /* QualifiedName */; } - ts.isQuestionToken = isQuestionToken; - /*@internal*/ - function isExclamationToken(node) { - return node.kind === 53 /* ExclamationToken */; + ts.isQualifiedName = isQualifiedName; + function isComputedPropertyName(node) { + return node.kind === 160 /* ComputedPropertyName */; } - ts.isExclamationToken = isExclamationToken; + ts.isComputedPropertyName = isComputedPropertyName; // Signature elements function isTypeParameterDeclaration(node) { - return node.kind === 159 /* TypeParameter */; + return node.kind === 161 /* TypeParameter */; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; // TODO(rbuckton): Rename to 'isParameterDeclaration' function isParameter(node) { - return node.kind === 160 /* Parameter */; + return node.kind === 162 /* Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 161 /* Decorator */; + return node.kind === 163 /* Decorator */; } ts.isDecorator = isDecorator; // TypeMember function isPropertySignature(node) { - return node.kind === 162 /* PropertySignature */; + return node.kind === 164 /* PropertySignature */; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 163 /* PropertyDeclaration */; + return node.kind === 165 /* PropertyDeclaration */; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 164 /* MethodSignature */; + return node.kind === 166 /* MethodSignature */; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 165 /* MethodDeclaration */; + return node.kind === 167 /* MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isConstructorDeclaration(node) { - return node.kind === 166 /* Constructor */; + return node.kind === 168 /* Constructor */; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 167 /* GetAccessor */; + return node.kind === 169 /* GetAccessor */; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 168 /* SetAccessor */; + return node.kind === 170 /* SetAccessor */; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 169 /* CallSignature */; + return node.kind === 171 /* CallSignature */; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 170 /* ConstructSignature */; + return node.kind === 172 /* ConstructSignature */; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 171 /* IndexSignature */; + return node.kind === 173 /* IndexSignature */; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; // Type function isTypePredicateNode(node) { - return node.kind === 172 /* TypePredicate */; + return node.kind === 174 /* TypePredicate */; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 173 /* TypeReference */; + return node.kind === 175 /* TypeReference */; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 174 /* FunctionType */; + return node.kind === 176 /* FunctionType */; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 175 /* ConstructorType */; + return node.kind === 177 /* ConstructorType */; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 176 /* TypeQuery */; + return node.kind === 178 /* TypeQuery */; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 177 /* TypeLiteral */; + return node.kind === 179 /* TypeLiteral */; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 178 /* ArrayType */; + return node.kind === 180 /* ArrayType */; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 179 /* TupleType */; + return node.kind === 181 /* TupleType */; } ts.isTupleTypeNode = isTupleTypeNode; function isNamedTupleMember(node) { - return node.kind === 192 /* NamedTupleMember */; + return node.kind === 194 /* NamedTupleMember */; } ts.isNamedTupleMember = isNamedTupleMember; function isOptionalTypeNode(node) { - return node.kind === 180 /* OptionalType */; + return node.kind === 182 /* OptionalType */; } ts.isOptionalTypeNode = isOptionalTypeNode; function isRestTypeNode(node) { - return node.kind === 181 /* RestType */; + return node.kind === 183 /* RestType */; } ts.isRestTypeNode = isRestTypeNode; function isUnionTypeNode(node) { - return node.kind === 182 /* UnionType */; + return node.kind === 184 /* UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 183 /* IntersectionType */; + return node.kind === 185 /* IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 184 /* ConditionalType */; + return node.kind === 186 /* ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 185 /* InferType */; + return node.kind === 187 /* InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 186 /* ParenthesizedType */; + return node.kind === 188 /* ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 187 /* ThisType */; + return node.kind === 189 /* ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 188 /* TypeOperator */; + return node.kind === 190 /* TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 189 /* IndexedAccessType */; + return node.kind === 191 /* IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 190 /* MappedType */; + return node.kind === 192 /* MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 191 /* LiteralType */; + return node.kind === 193 /* LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 195 /* ImportType */; + return node.kind === 197 /* ImportType */; } ts.isImportTypeNode = isImportTypeNode; function isTemplateLiteralTypeSpan(node) { - return node.kind === 194 /* TemplateLiteralTypeSpan */; + return node.kind === 196 /* TemplateLiteralTypeSpan */; } ts.isTemplateLiteralTypeSpan = isTemplateLiteralTypeSpan; function isTemplateLiteralTypeNode(node) { - return node.kind === 193 /* TemplateLiteralType */; + return node.kind === 195 /* TemplateLiteralType */; } ts.isTemplateLiteralTypeNode = isTemplateLiteralTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 196 /* ObjectBindingPattern */; + return node.kind === 198 /* ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 197 /* ArrayBindingPattern */; + return node.kind === 199 /* ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 198 /* BindingElement */; + return node.kind === 200 /* BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 199 /* ArrayLiteralExpression */; + return node.kind === 201 /* ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 200 /* ObjectLiteralExpression */; + return node.kind === 202 /* ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 201 /* PropertyAccessExpression */; + return node.kind === 203 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 202 /* ElementAccessExpression */; + return node.kind === 204 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 203 /* CallExpression */; + return node.kind === 205 /* CallExpression */; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 204 /* NewExpression */; + return node.kind === 206 /* NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 205 /* TaggedTemplateExpression */; + return node.kind === 207 /* TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertionExpression(node) { - return node.kind === 206 /* TypeAssertionExpression */; + return node.kind === 208 /* TypeAssertionExpression */; } ts.isTypeAssertionExpression = isTypeAssertionExpression; function isParenthesizedExpression(node) { - return node.kind === 207 /* ParenthesizedExpression */; + return node.kind === 209 /* ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function isFunctionExpression(node) { - return node.kind === 208 /* FunctionExpression */; + return node.kind === 210 /* FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 209 /* ArrowFunction */; + return node.kind === 211 /* ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 210 /* DeleteExpression */; + return node.kind === 212 /* DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 211 /* TypeOfExpression */; + return node.kind === 213 /* TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 212 /* VoidExpression */; + return node.kind === 214 /* VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 213 /* AwaitExpression */; + return node.kind === 215 /* AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 214 /* PrefixUnaryExpression */; + return node.kind === 216 /* PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 215 /* PostfixUnaryExpression */; + return node.kind === 217 /* PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 216 /* BinaryExpression */; + return node.kind === 218 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 217 /* ConditionalExpression */; + return node.kind === 219 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 218 /* TemplateExpression */; + return node.kind === 220 /* TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 219 /* YieldExpression */; + return node.kind === 221 /* YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 220 /* SpreadElement */; + return node.kind === 222 /* SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 221 /* ClassExpression */; + return node.kind === 223 /* ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 222 /* OmittedExpression */; + return node.kind === 224 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 223 /* ExpressionWithTypeArguments */; + return node.kind === 225 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 224 /* AsExpression */; + return node.kind === 226 /* AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 225 /* NonNullExpression */; + return node.kind === 227 /* NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 226 /* MetaProperty */; + return node.kind === 228 /* MetaProperty */; } ts.isMetaProperty = isMetaProperty; function isSyntheticExpression(node) { - return node.kind === 227 /* SyntheticExpression */; + return node.kind === 229 /* SyntheticExpression */; } ts.isSyntheticExpression = isSyntheticExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 336 /* PartiallyEmittedExpression */; + return node.kind === 344 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isCommaListExpression(node) { - return node.kind === 337 /* CommaListExpression */; + return node.kind === 345 /* CommaListExpression */; } ts.isCommaListExpression = isCommaListExpression; // Misc function isTemplateSpan(node) { - return node.kind === 228 /* TemplateSpan */; + return node.kind === 230 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 229 /* SemicolonClassElement */; + return node.kind === 231 /* SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Elements function isBlock(node) { - return node.kind === 230 /* Block */; + return node.kind === 232 /* Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 232 /* VariableStatement */; + return node.kind === 234 /* VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 231 /* EmptyStatement */; + return node.kind === 233 /* EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 233 /* ExpressionStatement */; + return node.kind === 235 /* ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 234 /* IfStatement */; + return node.kind === 236 /* IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 235 /* DoStatement */; + return node.kind === 237 /* DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 236 /* WhileStatement */; + return node.kind === 238 /* WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 237 /* ForStatement */; + return node.kind === 239 /* ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 238 /* ForInStatement */; + return node.kind === 240 /* ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 239 /* ForOfStatement */; + return node.kind === 241 /* ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 240 /* ContinueStatement */; + return node.kind === 242 /* ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 241 /* BreakStatement */; + return node.kind === 243 /* BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isReturnStatement(node) { - return node.kind === 242 /* ReturnStatement */; + return node.kind === 244 /* ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 243 /* WithStatement */; + return node.kind === 245 /* WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 244 /* SwitchStatement */; + return node.kind === 246 /* SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 245 /* LabeledStatement */; + return node.kind === 247 /* LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 246 /* ThrowStatement */; + return node.kind === 248 /* ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 247 /* TryStatement */; + return node.kind === 249 /* TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 248 /* DebuggerStatement */; + return node.kind === 250 /* DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 249 /* VariableDeclaration */; + return node.kind === 251 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 250 /* VariableDeclarationList */; + return node.kind === 252 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 251 /* FunctionDeclaration */; + return node.kind === 253 /* FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 252 /* ClassDeclaration */; + return node.kind === 254 /* ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 253 /* InterfaceDeclaration */; + return node.kind === 255 /* InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 254 /* TypeAliasDeclaration */; + return node.kind === 256 /* TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 255 /* EnumDeclaration */; + return node.kind === 257 /* EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 256 /* ModuleDeclaration */; + return node.kind === 258 /* ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 257 /* ModuleBlock */; + return node.kind === 259 /* ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 258 /* CaseBlock */; + return node.kind === 260 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 259 /* NamespaceExportDeclaration */; + return node.kind === 261 /* NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 260 /* ImportEqualsDeclaration */; + return node.kind === 262 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 261 /* ImportDeclaration */; + return node.kind === 263 /* ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 262 /* ImportClause */; + return node.kind === 264 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 263 /* NamespaceImport */; + return node.kind === 265 /* NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamespaceExport(node) { - return node.kind === 269 /* NamespaceExport */; + return node.kind === 271 /* NamespaceExport */; } ts.isNamespaceExport = isNamespaceExport; function isNamedImports(node) { - return node.kind === 264 /* NamedImports */; + return node.kind === 266 /* NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 265 /* ImportSpecifier */; + return node.kind === 267 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 266 /* ExportAssignment */; + return node.kind === 268 /* ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 267 /* ExportDeclaration */; + return node.kind === 269 /* ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 268 /* NamedExports */; + return node.kind === 270 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 270 /* ExportSpecifier */; + return node.kind === 272 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 271 /* MissingDeclaration */; + return node.kind === 273 /* MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; function isNotEmittedStatement(node) { - return node.kind === 335 /* NotEmittedStatement */; + return node.kind === 343 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ function isSyntheticReference(node) { - return node.kind === 340 /* SyntheticReferenceExpression */; + return node.kind === 348 /* SyntheticReferenceExpression */; } ts.isSyntheticReference = isSyntheticReference; /* @internal */ function isMergeDeclarationMarker(node) { - return node.kind === 338 /* MergeDeclarationMarker */; + return node.kind === 346 /* MergeDeclarationMarker */; } ts.isMergeDeclarationMarker = isMergeDeclarationMarker; /* @internal */ function isEndOfDeclarationMarker(node) { - return node.kind === 339 /* EndOfDeclarationMarker */; + return node.kind === 347 /* EndOfDeclarationMarker */; } ts.isEndOfDeclarationMarker = isEndOfDeclarationMarker; // Module References function isExternalModuleReference(node) { - return node.kind === 272 /* ExternalModuleReference */; + return node.kind === 274 /* ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 273 /* JsxElement */; + return node.kind === 275 /* JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 274 /* JsxSelfClosingElement */; + return node.kind === 276 /* JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 275 /* JsxOpeningElement */; + return node.kind === 277 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 276 /* JsxClosingElement */; + return node.kind === 278 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 277 /* JsxFragment */; + return node.kind === 279 /* JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 278 /* JsxOpeningFragment */; + return node.kind === 280 /* JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 279 /* JsxClosingFragment */; + return node.kind === 281 /* JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 280 /* JsxAttribute */; + return node.kind === 282 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 281 /* JsxAttributes */; + return node.kind === 283 /* JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 282 /* JsxSpreadAttribute */; + return node.kind === 284 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 283 /* JsxExpression */; + return node.kind === 285 /* JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 284 /* CaseClause */; + return node.kind === 286 /* CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 285 /* DefaultClause */; + return node.kind === 287 /* DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 286 /* HeritageClause */; + return node.kind === 288 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 287 /* CatchClause */; + return node.kind === 289 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 288 /* PropertyAssignment */; + return node.kind === 290 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 289 /* ShorthandPropertyAssignment */; + return node.kind === 291 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 290 /* SpreadAssignment */; + return node.kind === 292 /* SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 291 /* EnumMember */; + return node.kind === 293 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Unparsed // TODO(rbuckton): isUnparsedPrologue function isUnparsedPrepend(node) { - return node.kind === 293 /* UnparsedPrepend */; + return node.kind === 295 /* UnparsedPrepend */; } ts.isUnparsedPrepend = isUnparsedPrepend; // TODO(rbuckton): isUnparsedText @@ -27218,156 +28052,176 @@ var ts; // TODO(rbuckton): isUnparsedSyntheticReference // Top-level nodes function isSourceFile(node) { - return node.kind === 297 /* SourceFile */; + return node.kind === 299 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 298 /* Bundle */; + return node.kind === 300 /* Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 299 /* UnparsedSource */; + return node.kind === 301 /* UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; // TODO(rbuckton): isInputFiles // JSDoc Elements function isJSDocTypeExpression(node) { - return node.kind === 301 /* JSDocTypeExpression */; + return node.kind === 303 /* JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocNameReference(node) { - return node.kind === 302 /* JSDocNameReference */; + return node.kind === 304 /* JSDocNameReference */; } ts.isJSDocNameReference = isJSDocNameReference; + function isJSDocMemberName(node) { + return node.kind === 305 /* JSDocMemberName */; + } + ts.isJSDocMemberName = isJSDocMemberName; + function isJSDocLink(node) { + return node.kind === 318 /* JSDocLink */; + } + ts.isJSDocLink = isJSDocLink; + function isJSDocLinkCode(node) { + return node.kind === 319 /* JSDocLinkCode */; + } + ts.isJSDocLinkCode = isJSDocLinkCode; + function isJSDocLinkPlain(node) { + return node.kind === 320 /* JSDocLinkPlain */; + } + ts.isJSDocLinkPlain = isJSDocLinkPlain; function isJSDocAllType(node) { - return node.kind === 303 /* JSDocAllType */; + return node.kind === 306 /* JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 304 /* JSDocUnknownType */; + return node.kind === 307 /* JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 305 /* JSDocNullableType */; + return node.kind === 308 /* JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 306 /* JSDocNonNullableType */; + return node.kind === 309 /* JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 307 /* JSDocOptionalType */; + return node.kind === 310 /* JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 308 /* JSDocFunctionType */; + return node.kind === 311 /* JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 309 /* JSDocVariadicType */; + return node.kind === 312 /* JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDocNamepathType(node) { - return node.kind === 310 /* JSDocNamepathType */; + return node.kind === 313 /* JSDocNamepathType */; } ts.isJSDocNamepathType = isJSDocNamepathType; function isJSDoc(node) { - return node.kind === 311 /* JSDocComment */; + return node.kind === 314 /* JSDocComment */; } ts.isJSDoc = isJSDoc; function isJSDocTypeLiteral(node) { - return node.kind === 312 /* JSDocTypeLiteral */; + return node.kind === 316 /* JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocSignature(node) { - return node.kind === 313 /* JSDocSignature */; + return node.kind === 317 /* JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; // JSDoc Tags function isJSDocAugmentsTag(node) { - return node.kind === 315 /* JSDocAugmentsTag */; + return node.kind === 322 /* JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocAuthorTag(node) { - return node.kind === 317 /* JSDocAuthorTag */; + return node.kind === 324 /* JSDocAuthorTag */; } ts.isJSDocAuthorTag = isJSDocAuthorTag; function isJSDocClassTag(node) { - return node.kind === 319 /* JSDocClassTag */; + return node.kind === 326 /* JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocCallbackTag(node) { - return node.kind === 324 /* JSDocCallbackTag */; + return node.kind === 332 /* JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocPublicTag(node) { - return node.kind === 320 /* JSDocPublicTag */; + return node.kind === 327 /* JSDocPublicTag */; } ts.isJSDocPublicTag = isJSDocPublicTag; function isJSDocPrivateTag(node) { - return node.kind === 321 /* JSDocPrivateTag */; + return node.kind === 328 /* JSDocPrivateTag */; } ts.isJSDocPrivateTag = isJSDocPrivateTag; function isJSDocProtectedTag(node) { - return node.kind === 322 /* JSDocProtectedTag */; + return node.kind === 329 /* JSDocProtectedTag */; } ts.isJSDocProtectedTag = isJSDocProtectedTag; function isJSDocReadonlyTag(node) { - return node.kind === 323 /* JSDocReadonlyTag */; + return node.kind === 330 /* JSDocReadonlyTag */; } ts.isJSDocReadonlyTag = isJSDocReadonlyTag; + function isJSDocOverrideTag(node) { + return node.kind === 331 /* JSDocOverrideTag */; + } + ts.isJSDocOverrideTag = isJSDocOverrideTag; function isJSDocDeprecatedTag(node) { - return node.kind === 318 /* JSDocDeprecatedTag */; + return node.kind === 325 /* JSDocDeprecatedTag */; } ts.isJSDocDeprecatedTag = isJSDocDeprecatedTag; function isJSDocSeeTag(node) { - return node.kind === 332 /* JSDocSeeTag */; + return node.kind === 340 /* JSDocSeeTag */; } ts.isJSDocSeeTag = isJSDocSeeTag; function isJSDocEnumTag(node) { - return node.kind === 325 /* JSDocEnumTag */; + return node.kind === 333 /* JSDocEnumTag */; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocParameterTag(node) { - return node.kind === 326 /* JSDocParameterTag */; + return node.kind === 334 /* JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 327 /* JSDocReturnTag */; + return node.kind === 335 /* JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocThisTag(node) { - return node.kind === 328 /* JSDocThisTag */; + return node.kind === 336 /* JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocTypeTag(node) { - return node.kind === 329 /* JSDocTypeTag */; + return node.kind === 337 /* JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 330 /* JSDocTemplateTag */; + return node.kind === 338 /* JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 331 /* JSDocTypedefTag */; + return node.kind === 339 /* JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocUnknownTag(node) { - return node.kind === 314 /* JSDocTag */; + return node.kind === 321 /* JSDocTag */; } ts.isJSDocUnknownTag = isJSDocUnknownTag; function isJSDocPropertyTag(node) { - return node.kind === 333 /* JSDocPropertyTag */; + return node.kind === 341 /* JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocImplementsTag(node) { - return node.kind === 316 /* JSDocImplementsTag */; + return node.kind === 323 /* JSDocImplementsTag */; } ts.isJSDocImplementsTag = isJSDocImplementsTag; // Synthesized list /* @internal */ function isSyntaxList(n) { - return n.kind === 334 /* SyntaxList */; + return n.kind === 342 /* SyntaxList */; } ts.isSyntaxList = isSyntaxList; })(ts || (ts = {})); @@ -27384,7 +28238,7 @@ var ts; return ts.setTextRange(factory.createElementAccessExpression(target, memberName.expression), location); } else { - var expression = ts.setTextRange(ts.isIdentifierOrPrivateIdentifier(memberName) + var expression = ts.setTextRange(ts.isMemberName(memberName) ? factory.createPropertyAccessExpression(target, memberName) : factory.createElementAccessExpression(target, memberName), memberName); ts.getOrCreateEmitNode(expression).flags |= 64 /* NoNestedSourceMaps */; @@ -27566,14 +28420,14 @@ var ts; ts.Debug.failBadSyntaxKind(property.name, "Private identifiers are not allowed in object literals."); } switch (property.kind) { - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return createExpressionForAccessorDeclaration(factory, node.properties, property, receiver, !!node.multiLine); - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: return createExpressionForPropertyAssignment(factory, property, receiver); - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(factory, property, receiver); - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: return createExpressionForMethodDeclaration(factory, property, receiver); } } @@ -27626,21 +28480,21 @@ var ts; } ts.startsWithUseStrict = startsWithUseStrict; function isCommaSequence(node) { - return node.kind === 216 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || - node.kind === 337 /* CommaListExpression */; + return node.kind === 218 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || + node.kind === 345 /* CommaListExpression */; } ts.isCommaSequence = isCommaSequence; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 15 /* All */; } switch (node.kind) { - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return (kinds & 1 /* Parentheses */) !== 0; - case 206 /* TypeAssertionExpression */: - case 224 /* AsExpression */: + case 208 /* TypeAssertionExpression */: + case 226 /* AsExpression */: return (kinds & 2 /* TypeAssertions */) !== 0; - case 225 /* NonNullExpression */: + case 227 /* NonNullExpression */: return (kinds & 4 /* NonNullAssertions */) !== 0; - case 336 /* PartiallyEmittedExpression */: + case 344 /* PartiallyEmittedExpression */: return (kinds & 8 /* PartiallyEmittedExpressions */) !== 0; } return false; @@ -27761,10 +28615,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : factory.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 261 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 263 /* ImportDeclaration */ && node.importClause) { return factory.getGeneratedNameForNode(node); } - if (node.kind === 267 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 269 /* ExportDeclaration */ && node.moduleSpecifier) { return factory.getGeneratedNameForNode(node); } return undefined; @@ -27883,7 +28737,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -27895,11 +28749,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 290 /* SpreadAssignment */: + case 292 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -27931,12 +28785,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 160 /* Parameter */: - case 198 /* BindingElement */: + case 162 /* Parameter */: + case 200 /* BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 220 /* SpreadElement */: - case 290 /* SpreadAssignment */: + case 222 /* SpreadElement */: + case 292 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -27954,7 +28808,7 @@ var ts; ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement; function tryGetPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 198 /* BindingElement */: + case 200 /* BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -27969,7 +28823,7 @@ var ts; : propertyName; } break; - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -27984,7 +28838,7 @@ var ts; : propertyName; } break; - case 290 /* SpreadAssignment */: + case 292 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` if (bindingElement.name && ts.isPrivateIdentifier(bindingElement.name)) { return ts.Debug.failBadSyntaxKind(bindingElement.name); @@ -28007,13 +28861,13 @@ var ts; */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 196 /* ObjectBindingPattern */: - case 197 /* ArrayBindingPattern */: - case 199 /* ArrayLiteralExpression */: + case 198 /* ObjectBindingPattern */: + case 199 /* ArrayBindingPattern */: + case 201 /* ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -28034,46 +28888,294 @@ var ts; ts.getJSDocTypeAliasName = getJSDocTypeAliasName; function canHaveModifiers(node) { var kind = node.kind; - return kind === 160 /* Parameter */ - || kind === 162 /* PropertySignature */ - || kind === 163 /* PropertyDeclaration */ - || kind === 164 /* MethodSignature */ - || kind === 165 /* MethodDeclaration */ - || kind === 166 /* Constructor */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */ - || kind === 171 /* IndexSignature */ - || kind === 208 /* FunctionExpression */ - || kind === 209 /* ArrowFunction */ - || kind === 221 /* ClassExpression */ - || kind === 232 /* VariableStatement */ - || kind === 251 /* FunctionDeclaration */ - || kind === 252 /* ClassDeclaration */ - || kind === 253 /* InterfaceDeclaration */ - || kind === 254 /* TypeAliasDeclaration */ - || kind === 255 /* EnumDeclaration */ - || kind === 256 /* ModuleDeclaration */ - || kind === 260 /* ImportEqualsDeclaration */ - || kind === 261 /* ImportDeclaration */ - || kind === 266 /* ExportAssignment */ - || kind === 267 /* ExportDeclaration */; + return kind === 162 /* Parameter */ + || kind === 164 /* PropertySignature */ + || kind === 165 /* PropertyDeclaration */ + || kind === 166 /* MethodSignature */ + || kind === 167 /* MethodDeclaration */ + || kind === 168 /* Constructor */ + || kind === 169 /* GetAccessor */ + || kind === 170 /* SetAccessor */ + || kind === 173 /* IndexSignature */ + || kind === 210 /* FunctionExpression */ + || kind === 211 /* ArrowFunction */ + || kind === 223 /* ClassExpression */ + || kind === 234 /* VariableStatement */ + || kind === 253 /* FunctionDeclaration */ + || kind === 254 /* ClassDeclaration */ + || kind === 255 /* InterfaceDeclaration */ + || kind === 256 /* TypeAliasDeclaration */ + || kind === 257 /* EnumDeclaration */ + || kind === 258 /* ModuleDeclaration */ + || kind === 262 /* ImportEqualsDeclaration */ + || kind === 263 /* ImportDeclaration */ + || kind === 268 /* ExportAssignment */ + || kind === 269 /* ExportDeclaration */; } ts.canHaveModifiers = canHaveModifiers; - /* @internal */ - function isExportModifier(node) { - return node.kind === 92 /* ExportKeyword */; - } - ts.isExportModifier = isExportModifier; - /* @internal */ - function isAsyncModifier(node) { - return node.kind === 129 /* AsyncKeyword */; - } - ts.isAsyncModifier = isAsyncModifier; - /* @internal */ - function isStaticModifier(node) { - return node.kind === 123 /* StaticKeyword */; + ts.isTypeNodeOrTypeParameterDeclaration = ts.or(ts.isTypeNode, ts.isTypeParameterDeclaration); + ts.isQuestionOrExclamationToken = ts.or(ts.isQuestionToken, ts.isExclamationToken); + ts.isIdentifierOrThisTypeNode = ts.or(ts.isIdentifier, ts.isThisTypeNode); + ts.isReadonlyKeywordOrPlusOrMinusToken = ts.or(ts.isReadonlyKeyword, ts.isPlusToken, ts.isMinusToken); + ts.isQuestionOrPlusOrMinusToken = ts.or(ts.isQuestionToken, ts.isPlusToken, ts.isMinusToken); + 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 */ + || ts.isLiteralExpression(node) + || ts.isPrefixUnaryExpression(node); + } + ts.isLiteralTypeLikeExpression = isLiteralTypeLikeExpression; + function isExponentiationOperator(kind) { + return kind === 42 /* AsteriskAsteriskToken */; + } + function isMultiplicativeOperator(kind) { + return kind === 41 /* AsteriskToken */ + || kind === 43 /* SlashToken */ + || kind === 44 /* PercentToken */; + } + function isMultiplicativeOperatorOrHigher(kind) { + return isExponentiationOperator(kind) + || isMultiplicativeOperator(kind); + } + function isAdditiveOperator(kind) { + return kind === 39 /* PlusToken */ + || kind === 40 /* MinusToken */; + } + function isAdditiveOperatorOrHigher(kind) { + return isAdditiveOperator(kind) + || isMultiplicativeOperatorOrHigher(kind); + } + function isShiftOperator(kind) { + return kind === 47 /* LessThanLessThanToken */ + || kind === 48 /* GreaterThanGreaterThanToken */ + || kind === 49 /* 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 */; + } + function isRelationalOperatorOrHigher(kind) { + return isRelationalOperator(kind) + || isShiftOperatorOrHigher(kind); + } + function isEqualityOperator(kind) { + return kind === 34 /* EqualsEqualsToken */ + || kind === 36 /* EqualsEqualsEqualsToken */ + || kind === 35 /* ExclamationEqualsToken */ + || kind === 37 /* ExclamationEqualsEqualsToken */; + } + function isEqualityOperatorOrHigher(kind) { + return isEqualityOperator(kind) + || isRelationalOperatorOrHigher(kind); + } + function isBitwiseOperator(kind) { + return kind === 50 /* AmpersandToken */ + || kind === 51 /* BarToken */ + || kind === 52 /* CaretToken */; + } + function isBitwiseOperatorOrHigher(kind) { + return isBitwiseOperator(kind) + || isEqualityOperatorOrHigher(kind); + } + // NOTE: The version in utilities includes ExclamationToken, which is not a binary operator. + function isLogicalOperator(kind) { + return kind === 55 /* AmpersandAmpersandToken */ + || kind === 56 /* BarBarToken */; + } + function isLogicalOperatorOrHigher(kind) { + return isLogicalOperator(kind) + || isBitwiseOperatorOrHigher(kind); + } + function isAssignmentOperatorOrHigher(kind) { + return kind === 60 /* QuestionQuestionToken */ + || isLogicalOperatorOrHigher(kind) + || ts.isAssignmentOperator(kind); + } + function isBinaryOperator(kind) { + return isAssignmentOperatorOrHigher(kind) + || kind === 27 /* CommaToken */; + } + function isBinaryOperatorToken(node) { + return isBinaryOperator(node.kind); + } + ts.isBinaryOperatorToken = isBinaryOperatorToken; + var BinaryExpressionState; + (function (BinaryExpressionState) { + /** + * Handles walking into a `BinaryExpression`. + * @param machine State machine handler functions + * @param frame The current frame + * @returns The new frame + */ + function enter(machine, stackIndex, stateStack, nodeStack, userStateStack, _resultHolder, outerState) { + var prevUserState = stackIndex > 0 ? userStateStack[stackIndex - 1] : undefined; + ts.Debug.assertEqual(stateStack[stackIndex], enter); + userStateStack[stackIndex] = machine.onEnter(nodeStack[stackIndex], prevUserState, outerState); + stateStack[stackIndex] = nextState(machine, enter); + return stackIndex; + } + BinaryExpressionState.enter = enter; + /** + * Handles walking the `left` side of a `BinaryExpression`. + * @param machine State machine handler functions + * @param frame The current frame + * @returns The new frame + */ + function left(machine, stackIndex, stateStack, nodeStack, userStateStack, _resultHolder, _outerState) { + ts.Debug.assertEqual(stateStack[stackIndex], left); + ts.Debug.assertIsDefined(machine.onLeft); + stateStack[stackIndex] = nextState(machine, left); + var nextNode = machine.onLeft(nodeStack[stackIndex].left, userStateStack[stackIndex], nodeStack[stackIndex]); + if (nextNode) { + checkCircularity(stackIndex, nodeStack, nextNode); + return pushStack(stackIndex, stateStack, nodeStack, userStateStack, nextNode); + } + return stackIndex; + } + BinaryExpressionState.left = left; + /** + * Handles walking the `operatorToken` of a `BinaryExpression`. + * @param machine State machine handler functions + * @param frame The current frame + * @returns The new frame + */ + function operator(machine, stackIndex, stateStack, nodeStack, userStateStack, _resultHolder, _outerState) { + ts.Debug.assertEqual(stateStack[stackIndex], operator); + ts.Debug.assertIsDefined(machine.onOperator); + stateStack[stackIndex] = nextState(machine, operator); + machine.onOperator(nodeStack[stackIndex].operatorToken, userStateStack[stackIndex], nodeStack[stackIndex]); + return stackIndex; + } + BinaryExpressionState.operator = operator; + /** + * Handles walking the `right` side of a `BinaryExpression`. + * @param machine State machine handler functions + * @param frame The current frame + * @returns The new frame + */ + function right(machine, stackIndex, stateStack, nodeStack, userStateStack, _resultHolder, _outerState) { + ts.Debug.assertEqual(stateStack[stackIndex], right); + ts.Debug.assertIsDefined(machine.onRight); + stateStack[stackIndex] = nextState(machine, right); + var nextNode = machine.onRight(nodeStack[stackIndex].right, userStateStack[stackIndex], nodeStack[stackIndex]); + if (nextNode) { + checkCircularity(stackIndex, nodeStack, nextNode); + return pushStack(stackIndex, stateStack, nodeStack, userStateStack, nextNode); + } + return stackIndex; + } + BinaryExpressionState.right = right; + /** + * Handles walking out of a `BinaryExpression`. + * @param machine State machine handler functions + * @param frame The current frame + * @returns The new frame + */ + function exit(machine, stackIndex, stateStack, nodeStack, userStateStack, resultHolder, _outerState) { + ts.Debug.assertEqual(stateStack[stackIndex], exit); + stateStack[stackIndex] = nextState(machine, exit); + var result = machine.onExit(nodeStack[stackIndex], userStateStack[stackIndex]); + if (stackIndex > 0) { + stackIndex--; + if (machine.foldState) { + var side = stateStack[stackIndex] === exit ? "right" : "left"; + userStateStack[stackIndex] = machine.foldState(userStateStack[stackIndex], result, side); + } + } + else { + resultHolder.value = result; + } + return stackIndex; + } + BinaryExpressionState.exit = exit; + /** + * Handles a frame that is already done. + * @returns The `done` state. + */ + function done(_machine, stackIndex, stateStack, _nodeStack, _userStateStack, _resultHolder, _outerState) { + ts.Debug.assertEqual(stateStack[stackIndex], done); + return stackIndex; + } + BinaryExpressionState.done = done; + function nextState(machine, currentState) { + switch (currentState) { + case enter: + if (machine.onLeft) + return left; + // falls through + case left: + if (machine.onOperator) + return operator; + // falls through + case operator: + if (machine.onRight) + return right; + // falls through + case right: return exit; + case exit: return done; + case done: return done; + default: ts.Debug.fail("Invalid state"); + } + } + BinaryExpressionState.nextState = nextState; + function pushStack(stackIndex, stateStack, nodeStack, userStateStack, node) { + stackIndex++; + stateStack[stackIndex] = enter; + nodeStack[stackIndex] = node; + userStateStack[stackIndex] = undefined; + return stackIndex; + } + function checkCircularity(stackIndex, nodeStack, node) { + if (ts.Debug.shouldAssert(2 /* Aggressive */)) { + while (stackIndex >= 0) { + ts.Debug.assert(nodeStack[stackIndex] !== node, "Circular traversal detected."); + stackIndex--; + } + } + } + })(BinaryExpressionState || (BinaryExpressionState = {})); + /** + * Holds state machine handler functions + */ + var BinaryExpressionStateMachine = /** @class */ (function () { + function BinaryExpressionStateMachine(onEnter, onLeft, onOperator, onRight, onExit, foldState) { + this.onEnter = onEnter; + this.onLeft = onLeft; + this.onOperator = onOperator; + this.onRight = onRight; + this.onExit = onExit; + this.foldState = foldState; + } + return BinaryExpressionStateMachine; + }()); + function createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, foldState) { + var machine = new BinaryExpressionStateMachine(onEnter, onLeft, onOperator, onRight, onExit, foldState); + return trampoline; + function trampoline(node, outerState) { + var resultHolder = { value: undefined }; + var stateStack = [BinaryExpressionState.enter]; + var nodeStack = [node]; + var userStateStack = [undefined]; + var stackIndex = 0; + while (stateStack[stackIndex] !== BinaryExpressionState.done) { + stackIndex = stateStack[stackIndex](machine, stackIndex, stateStack, nodeStack, userStateStack, resultHolder, outerState); + } + ts.Debug.assertEqual(stackIndex, 0); + return resultHolder.value; + } } - ts.isStaticModifier = isStaticModifier; + ts.createBinaryExpressionTrampoline = createBinaryExpressionTrampoline; })(ts || (ts = {})); var ts; (function (ts) { @@ -28155,19 +29257,19 @@ 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 <= 156 /* LastToken */) { + if (!node || node.kind <= 158 /* LastToken */) { return; } switch (node.kind) { - case 157 /* QualifiedName */: + case 159 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 159 /* TypeParameter */: + case 161 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -28175,9 +29277,9 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 290 /* SpreadAssignment */: + case 292 /* SpreadAssignment */: return visitNode(cbNode, node.expression); - case 160 /* Parameter */: + case 162 /* Parameter */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -28185,7 +29287,7 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -28193,51 +29295,51 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 162 /* PropertySignature */: + case 164 /* PropertySignature */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.initializer); - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 198 /* BindingElement */: + case 200 /* BindingElement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 173 /* 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 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: - case 209 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 210 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 211 /* ArrowFunction */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -28249,374 +29351,395 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 173 /* TypeReference */: + case 175 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 172 /* TypePredicate */: + case 174 /* TypePredicate */: return visitNode(cbNode, node.assertsModifier) || visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 176 /* TypeQuery */: + case 178 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 177 /* TypeLiteral */: + case 179 /* TypeLiteral */: return visitNodes(cbNode, cbNodes, node.members); - case 178 /* ArrayType */: + case 180 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 179 /* TupleType */: + case 181 /* TupleType */: return visitNodes(cbNode, cbNodes, node.elements); - case 182 /* UnionType */: - case 183 /* IntersectionType */: + case 184 /* UnionType */: + case 185 /* IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 184 /* ConditionalType */: + case 186 /* ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 185 /* InferType */: + case 187 /* InferType */: return visitNode(cbNode, node.typeParameter); - case 195 /* ImportType */: + case 197 /* ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 186 /* ParenthesizedType */: - case 188 /* TypeOperator */: + case 188 /* ParenthesizedType */: + case 190 /* TypeOperator */: return visitNode(cbNode, node.type); - case 189 /* IndexedAccessType */: + case 191 /* IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 190 /* MappedType */: + case 192 /* MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.nameType) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 191 /* LiteralType */: + case 193 /* LiteralType */: return visitNode(cbNode, node.literal); - case 192 /* NamedTupleMember */: + case 194 /* NamedTupleMember */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 196 /* ObjectBindingPattern */: - case 197 /* ArrayBindingPattern */: + case 198 /* ObjectBindingPattern */: + case 199 /* ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.name); - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.argumentExpression); - case 203 /* CallExpression */: - case 204 /* NewExpression */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 206 /* TypeAssertionExpression */: + case 208 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 210 /* DeleteExpression */: + case 212 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 211 /* TypeOfExpression */: + case 213 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 212 /* VoidExpression */: + case 214 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 213 /* AwaitExpression */: + case 215 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 224 /* AsExpression */: + case 226 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 225 /* NonNullExpression */: + case 227 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 226 /* MetaProperty */: + case 228 /* MetaProperty */: return visitNode(cbNode, node.name); - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 220 /* SpreadElement */: + case 222 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 230 /* Block */: - case 257 /* ModuleBlock */: + case 232 /* Block */: + case 259 /* ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 297 /* SourceFile */: + case 299 /* SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 250 /* VariableDeclarationList */: + case 252 /* VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 234 /* IfStatement */: + case 236 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 235 /* DoStatement */: + case 237 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 236 /* WhileStatement */: + case 238 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 240 /* ContinueStatement */: - case 241 /* BreakStatement */: + case 242 /* ContinueStatement */: + case 243 /* BreakStatement */: return visitNode(cbNode, node.label); - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 243 /* WithStatement */: + case 245 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 258 /* CaseBlock */: + case 260 /* CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 284 /* CaseClause */: + case 286 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 285 /* DefaultClause */: + case 287 /* DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 246 /* ThrowStatement */: + case 248 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 247 /* TryStatement */: + case 249 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 161 /* Decorator */: + case 163 /* Decorator */: return visitNode(cbNode, node.expression); - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: 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 253 /* InterfaceDeclaration */: + case 255 /* 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 254 /* TypeAliasDeclaration */: + case 256 /* 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 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 291 /* EnumMember */: + case 293 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 262 /* ImportClause */: + case 264 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 259 /* NamespaceExportDeclaration */: + case 261 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 269 /* NamespaceExport */: + case 271 /* NamespaceExport */: return visitNode(cbNode, node.name); - case 264 /* NamedImports */: - case 268 /* NamedExports */: + case 266 /* NamedImports */: + case 270 /* NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 265 /* ImportSpecifier */: - case 270 /* ExportSpecifier */: + case 267 /* ImportSpecifier */: + case 272 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 218 /* TemplateExpression */: + case 220 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 228 /* TemplateSpan */: + case 230 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 193 /* TemplateLiteralType */: + case 195 /* TemplateLiteralType */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 194 /* TemplateLiteralTypeSpan */: + case 196 /* TemplateLiteralTypeSpan */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.literal); - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 286 /* HeritageClause */: + case 288 /* HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 272 /* ExternalModuleReference */: + case 274 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 271 /* MissingDeclaration */: + case 273 /* MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 337 /* CommaListExpression */: + case 345 /* CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 273 /* JsxElement */: + case 275 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 277 /* JsxFragment */: + case 279 /* JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 274 /* JsxSelfClosingElement */: - case 275 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 281 /* JsxAttributes */: + case 283 /* JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 280 /* JsxAttribute */: + case 282 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 282 /* JsxSpreadAttribute */: + case 284 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 276 /* JsxClosingElement */: + case 278 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 180 /* OptionalType */: - case 181 /* RestType */: - case 301 /* JSDocTypeExpression */: - case 306 /* JSDocNonNullableType */: - case 305 /* JSDocNullableType */: - case 307 /* JSDocOptionalType */: - case 309 /* JSDocVariadicType */: + case 182 /* OptionalType */: + case 183 /* RestType */: + case 303 /* JSDocTypeExpression */: + case 309 /* JSDocNonNullableType */: + case 308 /* JSDocNullableType */: + case 310 /* JSDocOptionalType */: + case 312 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 308 /* JSDocFunctionType */: + case 311 /* JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 311 /* JSDocComment */: - return visitNodes(cbNode, cbNodes, node.tags); - case 332 /* JSDocSeeTag */: + case 314 /* JSDocComment */: + return (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) + || visitNodes(cbNode, cbNodes, node.tags); + case 340 /* JSDocSeeTag */: return visitNode(cbNode, node.tagName) || - visitNode(cbNode, node.name); - case 302 /* JSDocNameReference */: + visitNode(cbNode, node.name) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 304 /* JSDocNameReference */: return visitNode(cbNode, node.name); - case 326 /* JSDocParameterTag */: - case 333 /* JSDocPropertyTag */: + case 305 /* JSDocMemberName */: + return visitNode(cbNode, node.left) || + visitNode(cbNode, node.right); + case 334 /* JSDocParameterTag */: + case 341 /* JSDocPropertyTag */: return visitNode(cbNode, node.tagName) || (node.isNameFirst ? visitNode(cbNode, node.name) || - visitNode(cbNode, node.typeExpression) + visitNode(cbNode, node.typeExpression) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) : visitNode(cbNode, node.typeExpression) || - visitNode(cbNode, node.name)); - case 317 /* JSDocAuthorTag */: - return visitNode(cbNode, node.tagName); - case 316 /* JSDocImplementsTag */: + visitNode(cbNode, node.name)) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 324 /* JSDocAuthorTag */: + return visitNode(cbNode, node.tagName) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 323 /* JSDocImplementsTag */: return visitNode(cbNode, node.tagName) || - visitNode(cbNode, node.class); - case 315 /* JSDocAugmentsTag */: + visitNode(cbNode, node.class) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 322 /* JSDocAugmentsTag */: return visitNode(cbNode, node.tagName) || - visitNode(cbNode, node.class); - case 330 /* JSDocTemplateTag */: + visitNode(cbNode, node.class) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 338 /* JSDocTemplateTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.constraint) || - visitNodes(cbNode, cbNodes, node.typeParameters); - case 331 /* JSDocTypedefTag */: + visitNodes(cbNode, cbNodes, node.typeParameters) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 339 /* JSDocTypedefTag */: return visitNode(cbNode, node.tagName) || (node.typeExpression && - node.typeExpression.kind === 301 /* JSDocTypeExpression */ + node.typeExpression.kind === 303 /* JSDocTypeExpression */ ? visitNode(cbNode, node.typeExpression) || - visitNode(cbNode, node.fullName) + visitNode(cbNode, node.fullName) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) : visitNode(cbNode, node.fullName) || - visitNode(cbNode, node.typeExpression)); - case 324 /* JSDocCallbackTag */: + visitNode(cbNode, node.typeExpression)) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 332 /* JSDocCallbackTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.fullName) || - visitNode(cbNode, node.typeExpression); - case 327 /* JSDocReturnTag */: - case 329 /* JSDocTypeTag */: - case 328 /* JSDocThisTag */: - case 325 /* JSDocEnumTag */: + visitNode(cbNode, node.typeExpression) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 335 /* JSDocReturnTag */: + case 337 /* JSDocTypeTag */: + case 336 /* JSDocThisTag */: + case 333 /* JSDocEnumTag */: return visitNode(cbNode, node.tagName) || - visitNode(cbNode, node.typeExpression); - case 313 /* JSDocSignature */: + visitNode(cbNode, node.typeExpression) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 317 /* JSDocSignature */: return ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 312 /* JSDocTypeLiteral */: + case 318 /* JSDocLink */: + case 319 /* JSDocLinkCode */: + case 320 /* JSDocLinkPlain */: + return visitNode(cbNode, node.name); + case 316 /* JSDocTypeLiteral */: return ts.forEach(node.jsDocPropertyTags, cbNode); - case 314 /* JSDocTag */: - case 319 /* JSDocClassTag */: - case 320 /* JSDocPublicTag */: - case 321 /* JSDocPrivateTag */: - case 322 /* JSDocProtectedTag */: - case 323 /* JSDocReadonlyTag */: - return visitNode(cbNode, node.tagName); - case 336 /* PartiallyEmittedExpression */: + case 321 /* JSDocTag */: + case 326 /* JSDocClassTag */: + case 327 /* JSDocPublicTag */: + case 328 /* JSDocPrivateTag */: + case 329 /* JSDocProtectedTag */: + case 330 /* JSDocReadonlyTag */: + case 325 /* JSDocDeprecatedTag */: + return visitNode(cbNode, node.tagName) + || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 344 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -28636,62 +29759,58 @@ var ts; * and while doing so, handles traversing the structure without relying on the callstack to encode the tree structure. */ function forEachChildRecursively(rootNode, cbNode, cbNodes) { - var stack = [rootNode]; - while (stack.length) { - var parent = stack.pop(); - var res = visitAllPossibleChildren(parent, gatherPossibleChildren(parent)); - if (res) { - return res; - } - } - return; - function gatherPossibleChildren(node) { - var children = []; - forEachChild(node, addWorkItem, addWorkItem); // By using a stack above and `unshift` here, we emulate a depth-first preorder traversal - return children; - function addWorkItem(n) { - children.unshift(n); - } - } - function visitAllPossibleChildren(parent, children) { - for (var _i = 0, children_5 = children; _i < children_5.length; _i++) { - var child = children_5[_i]; - if (ts.isArray(child)) { - if (cbNodes) { - var res = cbNodes(child, parent); - if (res) { - if (res === "skip") - continue; - return res; - } - } - for (var i = child.length - 1; i >= 0; i--) { - var realChild = child[i]; - var res = cbNode(realChild, parent); - if (res) { - if (res === "skip") - continue; - return res; - } - stack.push(realChild); - } - } - else { - stack.push(child); - var res = cbNode(child, parent); + var queue = gatherPossibleChildren(rootNode); + var parents = []; // tracks parent references for elements in queue + while (parents.length < queue.length) { + parents.push(rootNode); + } + while (queue.length !== 0) { + var current = queue.pop(); + var parent = parents.pop(); + if (ts.isArray(current)) { + if (cbNodes) { + var res = cbNodes(current, parent); if (res) { if (res === "skip") continue; return res; } } + for (var i = current.length - 1; i >= 0; --i) { + queue.push(current[i]); + parents.push(parent); + } + } + else { + var res = cbNode(current, parent); + if (res) { + if (res === "skip") + continue; + return res; + } + if (current.kind >= 159 /* 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]; + queue.push(child); + parents.push(current); + } + } } } } ts.forEachChildRecursively = forEachChildRecursively; + function gatherPossibleChildren(node) { + var children = []; + forEachChild(node, addWorkItem, addWorkItem); // By using a stack above and `unshift` here, we emulate a depth-first preorder traversal + return children; + function addWorkItem(n) { + children.unshift(n); + } + } function createSourceFile(fileName, sourceText, languageVersion, setParentNodes, scriptKind) { if (setParentNodes === void 0) { setParentNodes = false; } - ts.tracing.push("parse" /* Parse */, "createSourceFile", { path: fileName }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* Parse */, "createSourceFile", { path: fileName }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeParse"); var result; ts.perfLogger.logStartParseSourceFile(fileName); @@ -28704,7 +29823,7 @@ var ts; ts.perfLogger.logStopParseSourceFile(); ts.performance.mark("afterParse"); ts.performance.measure("Parse", "beforeParse", "afterParse"); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; } ts.createSourceFile = createSourceFile; @@ -28886,11 +30005,12 @@ var ts; // attached to the EOF token. var parseErrorBeforeNextFinishedNode = false; function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes, scriptKind) { + var _a; if (setParentNodes === void 0) { setParentNodes = false; } scriptKind = ts.ensureScriptKind(fileName, scriptKind); if (scriptKind === 6 /* JSON */) { var result_3 = parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes); - ts.convertToObjectWorker(result_3, result_3.parseDiagnostics, /*returnValue*/ false, /*knownRootOptions*/ undefined, /*jsonConversionNotifier*/ undefined); + 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; result_3.typeReferenceDirectives = ts.emptyArray; result_3.libReferenceDirectives = ts.emptyArray; @@ -28930,35 +30050,54 @@ var ts; endOfFileToken = parseTokenNode(); } else { - var expression = void 0; - switch (token()) { - case 22 /* OpenBracketToken */: - expression = parseArrayLiteralExpression(); - break; - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: - case 103 /* NullKeyword */: - expression = parseTokenNode(); - break; - case 40 /* MinusToken */: - if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 58 /* ColonToken */; })) { - expression = parsePrefixUnaryExpression(); - } - else { - expression = parseObjectLiteralExpression(); - } - break; - case 8 /* NumericLiteral */: - case 10 /* StringLiteral */: - if (lookAhead(function () { return nextToken() !== 58 /* ColonToken */; })) { - expression = parseLiteralNode(); + // 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 */) { + var expression_1 = void 0; + switch (token()) { + case 22 /* OpenBracketToken */: + expression_1 = parseArrayLiteralExpression(); + break; + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: + case 104 /* NullKeyword */: + expression_1 = parseTokenNode(); break; + case 40 /* MinusToken */: + if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 58 /* ColonToken */; })) { + expression_1 = parsePrefixUnaryExpression(); + } + else { + expression_1 = parseObjectLiteralExpression(); + } + break; + case 8 /* NumericLiteral */: + case 10 /* StringLiteral */: + if (lookAhead(function () { return nextToken() !== 58 /* ColonToken */; })) { + expression_1 = parseLiteralNode(); + break; + } + // falls through + default: + expression_1 = parseObjectLiteralExpression(); + break; + } + // Error recovery: collect multiple top-level expressions + if (expressions && ts.isArray(expressions)) { + expressions.push(expression_1); + } + else if (expressions) { + expressions = [expressions, expression_1]; + } + else { + expressions = expression_1; + if (token() !== 1 /* EndOfFileToken */) { + parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token); } - // falls through - default: - expression = parseObjectLiteralExpression(); - break; + } } + var expression = ts.isArray(expressions) ? finishNode(factory.createArrayLiteralExpression(expressions), pos) : ts.Debug.checkDefined(expressions); var statement = factory.createExpressionStatement(expression); finishNode(statement, pos); statements = createNodeArray([statement], pos); @@ -29153,7 +30292,7 @@ var ts; return factory.updateSourceFile(sourceFile, ts.setTextRange(factory.createNodeArray(statements), sourceFile.statements)); function containsPossibleTopLevelAwait(node) { return !(node.flags & 32768 /* AwaitContext */) - && !!(node.transformFlags & 8388608 /* ContainsPossibleTopLevelAwait */); + && !!(node.transformFlags & 16777216 /* ContainsPossibleTopLevelAwait */); } function findNextStatementWithAwait(statements, start) { for (var i = start; i < statements.length; i++) { @@ -29194,7 +30333,7 @@ var ts; ts.setTextRangePosWidth(sourceFile, 0, sourceText.length); setExternalModuleIndicator(sourceFile); // If we parsed this as an external module, it may contain top-level await - if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 8388608 /* ContainsPossibleTopLevelAwait */) { + if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 16777216 /* ContainsPossibleTopLevelAwait */) { sourceFile = reparseTopLevelAwait(sourceFile); } sourceFile.text = sourceText; @@ -29374,6 +30513,9 @@ var ts; function reScanLessThanToken() { return currentToken = scanner.reScanLessThanToken(); } + function reScanHashToken() { + return currentToken = scanner.reScanHashToken(); + } function scanJsxIdentifier() { return currentToken = scanner.scanJsxIdentifier(); } @@ -29428,27 +30570,27 @@ var ts; return speculationHelper(callback, 0 /* TryParse */); } function isBindingIdentifier() { - if (token() === 78 /* Identifier */) { + if (token() === 79 /* Identifier */) { return true; } - return token() > 115 /* LastReservedWord */; + return token() > 116 /* LastReservedWord */; } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token() === 78 /* Identifier */) { + if (token() === 79 /* 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() === 124 /* YieldKeyword */ && inYieldContext()) { + if (token() === 125 /* 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() === 130 /* AwaitKeyword */ && inAwaitContext()) { + if (token() === 131 /* AwaitKeyword */ && inAwaitContext()) { return false; } - return token() > 115 /* LastReservedWord */; + return token() > 116 /* LastReservedWord */; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -29561,11 +30703,11 @@ var ts; parseErrorAtCurrentToken(diagnosticMessage, arg0); } var pos = getNodePos(); - var result = kind === 78 /* Identifier */ ? factory.createIdentifier("", /*typeArguments*/ undefined, /*originalKeywordKind*/ undefined) : + var result = kind === 79 /* 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 === 271 /* MissingDeclaration */ ? factory.createMissingDeclaration() : + kind === 273 /* MissingDeclaration */ ? factory.createMissingDeclaration() : factory.createToken(kind); return finishNode(result, pos); } @@ -29580,8 +30722,8 @@ var ts; // with magic property names like '__proto__'. The 'identifiers' object is used to share a single string instance for // each identifier in order to reduce memory consumption. function createIdentifier(isIdentifier, diagnosticMessage, privateIdentifierDiagnosticMessage) { - identifierCount++; if (isIdentifier) { + identifierCount++; var pos = getNodePos(); // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker var originalKeywordKind = token(); @@ -29589,10 +30731,15 @@ var ts; nextTokenWithoutCheck(); return finishNode(factory.createIdentifier(text, /*typeArguments*/ undefined, originalKeywordKind), pos); } - if (token() === 79 /* PrivateIdentifier */) { + if (token() === 80 /* 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 */; })) { + // 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 isReservedWord = scanner.isReservedWord(); @@ -29600,7 +30747,7 @@ var ts; var defaultMessage = isReservedWord ? ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here : ts.Diagnostics.Identifier_expected; - return createMissingNode(78 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg); + return createMissingNode(79 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg); } function parseBindingIdentifier(privateIdentifierDiagnosticMessage) { return createIdentifier(isBindingIdentifier(), /*diagnosticMessage*/ undefined, privateIdentifierDiagnosticMessage); @@ -29625,7 +30772,7 @@ var ts; if (allowComputedPropertyNames && token() === 22 /* OpenBracketToken */) { return parseComputedPropertyName(); } - if (token() === 79 /* PrivateIdentifier */) { + if (token() === 80 /* PrivateIdentifier */) { return parsePrivateIdentifier(); } return parseIdentifierName(); @@ -29671,24 +30818,24 @@ var ts; } function nextTokenCanFollowModifier() { switch (token()) { - case 84 /* ConstKeyword */: + case 85 /* ConstKeyword */: // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 91 /* EnumKeyword */; - case 92 /* ExportKeyword */: + return nextToken() === 92 /* EnumKeyword */; + case 93 /* ExportKeyword */: nextToken(); - if (token() === 87 /* DefaultKeyword */) { + if (token() === 88 /* DefaultKeyword */) { return lookAhead(nextTokenCanFollowDefaultKeyword); } - if (token() === 149 /* TypeKeyword */) { + if (token() === 150 /* TypeKeyword */) { return lookAhead(nextTokenCanFollowExportModifier); } return canFollowExportModifier(); - case 87 /* DefaultKeyword */: + case 88 /* DefaultKeyword */: return nextTokenCanFollowDefaultKeyword(); - case 123 /* StaticKeyword */: + case 124 /* StaticKeyword */: return nextTokenIsOnSameLineAndCanFollowModifier(); - case 134 /* GetKeyword */: - case 146 /* SetKeyword */: + case 135 /* GetKeyword */: + case 147 /* SetKeyword */: nextToken(); return canFollowModifier(); default: @@ -29697,7 +30844,7 @@ var ts; } function canFollowExportModifier() { return token() !== 41 /* AsteriskToken */ - && token() !== 126 /* AsKeyword */ + && token() !== 127 /* AsKeyword */ && token() !== 18 /* OpenBraceToken */ && canFollowModifier(); } @@ -29717,10 +30864,10 @@ var ts; } function nextTokenCanFollowDefaultKeyword() { nextToken(); - return token() === 83 /* ClassKeyword */ || token() === 97 /* FunctionKeyword */ || - token() === 117 /* InterfaceKeyword */ || - (token() === 125 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || - (token() === 129 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 84 /* ClassKeyword */ || token() === 98 /* FunctionKeyword */ || + token() === 118 /* InterfaceKeyword */ || + (token() === 126 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || + (token() === 130 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -29740,7 +30887,7 @@ var ts; // outer module. We just want to consume and move on. return !(token() === 26 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); case 2 /* SwitchClauses */: - return token() === 81 /* CaseKeyword */ || token() === 87 /* DefaultKeyword */; + return token() === 82 /* CaseKeyword */ || token() === 88 /* DefaultKeyword */; case 4 /* TypeMembers */: return lookAhead(isTypeMemberStart); case 5 /* ClassMembers */: @@ -29826,7 +30973,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 93 /* ExtendsKeyword */ || next === 116 /* ImplementsKeyword */; + return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 94 /* ExtendsKeyword */ || next === 117 /* ImplementsKeyword */; } return true; } @@ -29843,8 +30990,8 @@ var ts; return ts.tokenIsIdentifierOrKeywordOrGreaterThan(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 116 /* ImplementsKeyword */ || - token() === 93 /* ExtendsKeyword */) { + if (token() === 117 /* ImplementsKeyword */ || + token() === 94 /* ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -29874,14 +31021,14 @@ var ts; case 23 /* ImportOrExportSpecifiers */: return token() === 19 /* CloseBraceToken */; case 3 /* SwitchClauseStatements */: - return token() === 19 /* CloseBraceToken */ || token() === 81 /* CaseKeyword */ || token() === 87 /* DefaultKeyword */; + return token() === 19 /* CloseBraceToken */ || token() === 82 /* CaseKeyword */ || token() === 88 /* DefaultKeyword */; case 7 /* HeritageClauseElement */: - return token() === 18 /* OpenBraceToken */ || token() === 93 /* ExtendsKeyword */ || token() === 116 /* ImplementsKeyword */; + return token() === 18 /* OpenBraceToken */ || token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; case 8 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); case 19 /* TypeParameters */: // Tokens other than '>' are here for better error recovery - return token() === 31 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 93 /* ExtendsKeyword */ || token() === 116 /* ImplementsKeyword */; + return token() === 31 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; case 11 /* ArgumentExpressions */: // Tokens other than ')' are here for better error recovery return token() === 21 /* CloseParenToken */ || token() === 26 /* SemicolonToken */; @@ -29947,8 +31094,7 @@ var ts; var listPos = getNodePos(); while (!isListTerminator(kind)) { if (isListElement(kind, /*inErrorRecovery*/ false)) { - var element = parseListElement(kind, parseElement); - list.push(element); + list.push(parseListElement(kind, parseElement)); continue; } if (abortParsingListOrMoveToNextToken(kind)) { @@ -30098,20 +31244,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 166 /* Constructor */: - case 171 /* IndexSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 163 /* PropertyDeclaration */: - case 229 /* SemicolonClassElement */: + case 168 /* Constructor */: + case 173 /* IndexSignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 231 /* SemicolonClassElement */: return true; - case 165 /* MethodDeclaration */: + case 167 /* 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 === 78 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 132 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 79 /* Identifier */ && + methodDeclaration.name.originalKeywordKind === 133 /* ConstructorKeyword */; return !nameIsConstructor; } } @@ -30120,8 +31266,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 284 /* CaseClause */: - case 285 /* DefaultClause */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: return true; } } @@ -30130,58 +31276,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 232 /* VariableStatement */: - case 230 /* Block */: - case 234 /* IfStatement */: - case 233 /* ExpressionStatement */: - case 246 /* ThrowStatement */: - case 242 /* ReturnStatement */: - case 244 /* SwitchStatement */: - case 241 /* BreakStatement */: - case 240 /* ContinueStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 237 /* ForStatement */: - case 236 /* WhileStatement */: - case 243 /* WithStatement */: - case 231 /* EmptyStatement */: - case 247 /* TryStatement */: - case 245 /* LabeledStatement */: - case 235 /* DoStatement */: - case 248 /* DebuggerStatement */: - case 261 /* ImportDeclaration */: - case 260 /* ImportEqualsDeclaration */: - case 267 /* ExportDeclaration */: - case 266 /* ExportAssignment */: - case 256 /* ModuleDeclaration */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 253 /* FunctionDeclaration */: + case 234 /* VariableStatement */: + case 232 /* Block */: + case 236 /* IfStatement */: + case 235 /* ExpressionStatement */: + case 248 /* ThrowStatement */: + case 244 /* ReturnStatement */: + case 246 /* SwitchStatement */: + case 243 /* BreakStatement */: + case 242 /* ContinueStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 239 /* ForStatement */: + case 238 /* WhileStatement */: + case 245 /* WithStatement */: + case 233 /* EmptyStatement */: + case 249 /* TryStatement */: + case 247 /* LabeledStatement */: + case 237 /* DoStatement */: + case 250 /* DebuggerStatement */: + case 263 /* ImportDeclaration */: + case 262 /* ImportEqualsDeclaration */: + case 269 /* ExportDeclaration */: + case 268 /* ExportAssignment */: + case 258 /* ModuleDeclaration */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 257 /* EnumDeclaration */: + case 256 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 291 /* EnumMember */; + return node.kind === 293 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 170 /* ConstructSignature */: - case 164 /* MethodSignature */: - case 171 /* IndexSignature */: - case 162 /* PropertySignature */: - case 169 /* CallSignature */: + case 172 /* ConstructSignature */: + case 166 /* MethodSignature */: + case 173 /* IndexSignature */: + case 164 /* PropertySignature */: + case 171 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 249 /* VariableDeclaration */) { + if (node.kind !== 251 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -30202,7 +31348,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 160 /* Parameter */) { + if (node.kind !== 162 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -30369,12 +31515,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(78 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } } - if (token() === 79 /* PrivateIdentifier */) { + if (token() === 80 /* PrivateIdentifier */) { var node = parsePrivateIdentifier(); - return allowPrivateIdentifiers ? node : createMissingNode(78 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return allowPrivateIdentifiers ? node : createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } @@ -30483,14 +31629,14 @@ var ts; // If true, we should abort parsing an error function. function typeHasArrowFunctionBlockingParseError(node) { switch (node.kind) { - case 173 /* TypeReference */: + case 175 /* TypeReference */: return ts.nodeIsMissing(node.typeName); - case 174 /* FunctionType */: - case 175 /* ConstructorType */: { + case 176 /* FunctionType */: + case 177 /* ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 186 /* ParenthesizedType */: + case 188 /* ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -30532,7 +31678,7 @@ var ts; token() === 19 /* CloseBraceToken */ || token() === 21 /* CloseParenToken */ || token() === 31 /* GreaterThanToken */ || - token() === 62 /* EqualsToken */ || + token() === 63 /* EqualsToken */ || token() === 51 /* BarToken */) { return finishNode(factory.createJSDocUnknownType(), pos); } @@ -30554,7 +31700,7 @@ var ts; function parseJSDocParameter() { var pos = getNodePos(); var name; - if (token() === 107 /* ThisKeyword */ || token() === 102 /* NewKeyword */) { + if (token() === 108 /* ThisKeyword */ || token() === 103 /* NewKeyword */) { name = parseIdentifierName(); parseExpected(58 /* ColonToken */); } @@ -30570,7 +31716,7 @@ var ts; function parseJSDocType() { scanner.setInJSDocType(true); var pos = getNodePos(); - if (parseOptional(139 /* ModuleKeyword */)) { + if (parseOptional(140 /* 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) { @@ -30593,7 +31739,7 @@ var ts; if (hasDotDotDot) { type = finishNode(factory.createJSDocVariadicType(type), pos); } - if (token() === 62 /* EqualsToken */) { + if (token() === 63 /* EqualsToken */) { nextToken(); return finishNode(factory.createJSDocOptionalType(type), pos); } @@ -30601,7 +31747,7 @@ var ts; } function parseTypeQuery() { var pos = getNodePos(); - parseExpected(111 /* TypeOfKeyword */); + parseExpected(112 /* TypeOfKeyword */); return finishNode(factory.createTypeQueryNode(parseEntityName(/*allowReservedWords*/ true)), pos); } function parseTypeParameter() { @@ -30609,7 +31755,7 @@ var ts; var name = parseIdentifier(); var constraint; var expression; - if (parseOptional(93 /* ExtendsKeyword */)) { + if (parseOptional(94 /* 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 @@ -30628,7 +31774,7 @@ var ts; expression = parseUnaryExpressionOrHigher(); } } - var defaultType = parseOptional(62 /* EqualsToken */) ? parseType() : undefined; + var defaultType = parseOptional(63 /* EqualsToken */) ? parseType() : undefined; var node = factory.createTypeParameterDeclaration(name, constraint, defaultType); node.expression = expression; return finishNode(node, pos); @@ -30671,19 +31817,21 @@ var ts; function parseParameterWorker(inOuterAwaitContext) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - if (token() === 107 /* ThisKeyword */) { - var node_1 = factory.createParameterDeclaration( - /*decorators*/ undefined, + // 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 node_1 = factory.createParameterDeclaration(decorators, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, createIdentifier(/*isIdentifier*/ true), /*questionToken*/ undefined, parseTypeAnnotation(), /*initializer*/ undefined); + if (decorators) { + parseErrorAtRange(decorators[0], ts.Diagnostics.Decorators_may_not_be_applied_to_this_parameters); + } return withJSDoc(finishNode(node_1, pos), hasJSDoc); } - // 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(); var savedTopLevel = topLevel; topLevel = false; var modifiers = parseModifiers(); @@ -30770,14 +31918,14 @@ var ts; function parseSignatureMember(kind) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - if (kind === 170 /* ConstructSignature */) { - parseExpected(102 /* NewKeyword */); + if (kind === 172 /* ConstructSignature */) { + parseExpected(103 /* NewKeyword */); } var typeParameters = parseTypeParameters(); var parameters = parseParameters(4 /* Type */); var type = parseReturnType(58 /* ColonToken */, /*isType*/ true); parseTypeMemberSemicolon(); - var node = kind === 169 /* CallSignature */ + var node = kind === 171 /* CallSignature */ ? factory.createCallSignature(typeParameters, parameters, type) : factory.createConstructSignature(typeParameters, parameters, type); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -30860,7 +32008,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() === 62 /* EqualsToken */) + if (token() === 63 /* EqualsToken */) node.initializer = parseInitializer(); } parseTypeMemberSemicolon(); @@ -30868,7 +32016,10 @@ var ts; } function isTypeMemberStart() { // Return true if we have the start of a signature member - if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + if (token() === 20 /* OpenParenToken */ || + token() === 29 /* LessThanToken */ || + token() === 135 /* GetKeyword */ || + token() === 147 /* SetKeyword */) { return true; } var idToken = false; @@ -30900,14 +32051,20 @@ var ts; } function parseTypeMember() { if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { - return parseSignatureMember(169 /* CallSignature */); + return parseSignatureMember(171 /* CallSignature */); } - if (token() === 102 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(170 /* ConstructSignature */); + if (token() === 103 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { + return parseSignatureMember(172 /* ConstructSignature */); } var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiers(); + if (parseContextualModifier(135 /* GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 169 /* GetAccessor */); + } + if (parseContextualModifier(147 /* SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 170 /* SetAccessor */); + } if (isIndexSignature()) { return parseIndexSignatureDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers); } @@ -30947,17 +32104,17 @@ var ts; function isStartOfMappedType() { nextToken(); if (token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { - return nextToken() === 142 /* ReadonlyKeyword */; + return nextToken() === 143 /* ReadonlyKeyword */; } - if (token() === 142 /* ReadonlyKeyword */) { + if (token() === 143 /* ReadonlyKeyword */) { nextToken(); } - return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 100 /* InKeyword */; + return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 101 /* InKeyword */; } function parseMappedTypeParameter() { var pos = getNodePos(); var name = parseIdentifierName(); - parseExpected(100 /* InKeyword */); + parseExpected(101 /* InKeyword */); var type = parseType(); return finishNode(factory.createTypeParameterDeclaration(name, type, /*defaultType*/ undefined), pos); } @@ -30965,15 +32122,15 @@ var ts; var pos = getNodePos(); parseExpected(18 /* OpenBraceToken */); var readonlyToken; - if (token() === 142 /* ReadonlyKeyword */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { + if (token() === 143 /* ReadonlyKeyword */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { readonlyToken = parseTokenNode(); - if (readonlyToken.kind !== 142 /* ReadonlyKeyword */) { - parseExpected(142 /* ReadonlyKeyword */); + if (readonlyToken.kind !== 143 /* ReadonlyKeyword */) { + parseExpected(143 /* ReadonlyKeyword */); } } parseExpected(22 /* OpenBracketToken */); var typeParameter = parseMappedTypeParameter(); - var nameType = parseOptional(126 /* AsKeyword */) ? parseType() : undefined; + var nameType = parseOptional(127 /* AsKeyword */) ? parseType() : undefined; parseExpected(23 /* CloseBracketToken */); var questionToken; if (token() === 57 /* QuestionToken */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { @@ -31037,10 +32194,10 @@ var ts; } function parseModifiersForConstructorType() { var modifiers; - if (token() === 125 /* AbstractKeyword */) { + if (token() === 126 /* AbstractKeyword */) { var pos = getNodePos(); nextToken(); - var modifier = finishNode(factory.createToken(125 /* AbstractKeyword */), pos); + var modifier = finishNode(factory.createToken(126 /* AbstractKeyword */), pos); modifiers = createNodeArray([modifier], pos); } return modifiers; @@ -31049,7 +32206,7 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiersForConstructorType(); - var isConstructorType = parseOptional(102 /* NewKeyword */); + var isConstructorType = parseOptional(103 /* NewKeyword */); var typeParameters = parseTypeParameters(); var parameters = parseParameters(4 /* Type */); var type = parseReturnType(38 /* EqualsGreaterThanToken */, /*isType*/ false); @@ -31069,7 +32226,7 @@ var ts; if (negative) { nextToken(); } - var expression = token() === 109 /* TrueKeyword */ || token() === 94 /* FalseKeyword */ || token() === 103 /* NullKeyword */ ? + var expression = token() === 110 /* TrueKeyword */ || token() === 95 /* FalseKeyword */ || token() === 104 /* NullKeyword */ ? parseTokenNode() : parseLiteralLikeNode(token()); if (negative) { @@ -31079,13 +32236,13 @@ var ts; } function isStartOfTypeOfImportType() { nextToken(); - return token() === 99 /* ImportKeyword */; + return token() === 100 /* ImportKeyword */; } function parseImportType() { sourceFlags |= 1048576 /* PossiblyContainsDynamicImport */; var pos = getNodePos(); - var isTypeOf = parseOptional(111 /* TypeOfKeyword */); - parseExpected(99 /* ImportKeyword */); + var isTypeOf = parseOptional(112 /* TypeOfKeyword */); + parseExpected(100 /* ImportKeyword */); parseExpected(20 /* OpenParenToken */); var type = parseType(); parseExpected(21 /* CloseParenToken */); @@ -31099,19 +32256,19 @@ var ts; } function parseNonArrayType() { switch (token()) { - case 128 /* AnyKeyword */: - case 152 /* UnknownKeyword */: - case 147 /* StringKeyword */: - case 144 /* NumberKeyword */: - case 155 /* BigIntKeyword */: - case 148 /* SymbolKeyword */: - case 131 /* BooleanKeyword */: - case 150 /* UndefinedKeyword */: - case 141 /* NeverKeyword */: - case 145 /* ObjectKeyword */: + case 129 /* AnyKeyword */: + case 153 /* UnknownKeyword */: + case 148 /* StringKeyword */: + case 145 /* NumberKeyword */: + case 156 /* BigIntKeyword */: + case 149 /* SymbolKeyword */: + case 132 /* BooleanKeyword */: + case 151 /* UndefinedKeyword */: + case 142 /* NeverKeyword */: + case 146 /* ObjectKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. return tryParse(parseKeywordAndNoDot) || parseTypeReference(); - case 65 /* AsteriskEqualsToken */: + case 66 /* AsteriskEqualsToken */: // If there is '*=', treat it as * followed by postfix = scanner.reScanAsteriskEqualsToken(); // falls through @@ -31123,7 +32280,7 @@ var ts; // falls through case 57 /* QuestionToken */: return parseJSDocUnknownOrNullableType(); - case 97 /* FunctionKeyword */: + case 98 /* FunctionKeyword */: return parseJSDocFunctionType(); case 53 /* ExclamationToken */: return parseJSDocNonNullableType(); @@ -31131,24 +32288,24 @@ var ts; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: - case 103 /* NullKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: + case 104 /* NullKeyword */: return parseLiteralTypeNode(); case 40 /* MinusToken */: return lookAhead(nextTokenIsNumericOrBigIntLiteral) ? parseLiteralTypeNode(/*negative*/ true) : parseTypeReference(); - case 113 /* VoidKeyword */: + case 114 /* VoidKeyword */: return parseTokenNode(); - case 107 /* ThisKeyword */: { + case 108 /* ThisKeyword */: { var thisKeyword = parseThisTypeNode(); - if (token() === 137 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 138 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 111 /* TypeOfKeyword */: + case 112 /* TypeOfKeyword */: return lookAhead(isStartOfTypeOfImportType) ? parseImportType() : parseTypeQuery(); case 18 /* OpenBraceToken */: return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral(); @@ -31156,9 +32313,9 @@ var ts; return parseTupleType(); case 20 /* OpenParenToken */: return parseParenthesizedType(); - case 99 /* ImportKeyword */: + case 100 /* ImportKeyword */: return parseImportType(); - case 127 /* AssertsKeyword */: + case 128 /* AssertsKeyword */: return lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? parseAssertsTypePredicate() : parseTypeReference(); case 15 /* TemplateHead */: return parseTemplateType(); @@ -31168,44 +32325,44 @@ var ts; } function isStartOfType(inStartOfParameter) { switch (token()) { - case 128 /* AnyKeyword */: - case 152 /* UnknownKeyword */: - case 147 /* StringKeyword */: - case 144 /* NumberKeyword */: - case 155 /* BigIntKeyword */: - case 131 /* BooleanKeyword */: - case 142 /* ReadonlyKeyword */: - case 148 /* SymbolKeyword */: - case 151 /* UniqueKeyword */: - case 113 /* VoidKeyword */: - case 150 /* UndefinedKeyword */: - case 103 /* NullKeyword */: - case 107 /* ThisKeyword */: - case 111 /* TypeOfKeyword */: - case 141 /* NeverKeyword */: + case 129 /* AnyKeyword */: + case 153 /* UnknownKeyword */: + case 148 /* StringKeyword */: + case 145 /* NumberKeyword */: + case 156 /* BigIntKeyword */: + case 132 /* BooleanKeyword */: + case 143 /* ReadonlyKeyword */: + case 149 /* SymbolKeyword */: + case 152 /* UniqueKeyword */: + case 114 /* VoidKeyword */: + case 151 /* UndefinedKeyword */: + case 104 /* NullKeyword */: + case 108 /* ThisKeyword */: + case 112 /* TypeOfKeyword */: + case 142 /* NeverKeyword */: case 18 /* OpenBraceToken */: case 22 /* OpenBracketToken */: case 29 /* LessThanToken */: case 51 /* BarToken */: case 50 /* AmpersandToken */: - case 102 /* NewKeyword */: + case 103 /* NewKeyword */: case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: - case 145 /* ObjectKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: + case 146 /* ObjectKeyword */: case 41 /* AsteriskToken */: case 57 /* QuestionToken */: case 53 /* ExclamationToken */: case 25 /* DotDotDotToken */: - case 135 /* InferKeyword */: - case 99 /* ImportKeyword */: - case 127 /* AssertsKeyword */: + case 136 /* InferKeyword */: + case 100 /* ImportKeyword */: + case 128 /* AssertsKeyword */: case 14 /* NoSubstitutionTemplateLiteral */: case 15 /* TemplateHead */: return true; - case 97 /* FunctionKeyword */: + case 98 /* FunctionKeyword */: return !inStartOfParameter; case 40 /* MinusToken */: return !inStartOfParameter && lookAhead(nextTokenIsNumericOrBigIntLiteral); @@ -31269,17 +32426,17 @@ var ts; } function parseInferType() { var pos = getNodePos(); - parseExpected(135 /* InferKeyword */); + parseExpected(136 /* InferKeyword */); return finishNode(factory.createInferTypeNode(parseTypeParameterOfInferType()), pos); } function parseTypeOperatorOrHigher() { var operator = token(); switch (operator) { - case 138 /* KeyOfKeyword */: - case 151 /* UniqueKeyword */: - case 142 /* ReadonlyKeyword */: + case 139 /* KeyOfKeyword */: + case 152 /* UniqueKeyword */: + case 143 /* ReadonlyKeyword */: return parseTypeOperator(operator); - case 135 /* InferKeyword */: + case 136 /* InferKeyword */: return parseInferType(); } return parsePostfixTypeOrHigher(); @@ -31329,7 +32486,7 @@ var ts; } function nextTokenIsNewKeyword() { nextToken(); - return token() === 102 /* NewKeyword */; + return token() === 103 /* NewKeyword */; } function isStartOfFunctionTypeOrConstructorType() { if (token() === 29 /* LessThanToken */) { @@ -31338,15 +32495,15 @@ var ts; if (token() === 20 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType)) { return true; } - return token() === 102 /* NewKeyword */ || - token() === 125 /* AbstractKeyword */ && lookAhead(nextTokenIsNewKeyword); + return token() === 103 /* NewKeyword */ || + token() === 126 /* AbstractKeyword */ && lookAhead(nextTokenIsNewKeyword); } function skipParameterStart() { if (ts.isModifierKind(token())) { // Skip modifiers parseModifiers(); } - if (isIdentifier() || token() === 107 /* ThisKeyword */) { + if (isIdentifier() || token() === 108 /* ThisKeyword */) { nextToken(); return true; } @@ -31369,7 +32526,7 @@ var ts; // 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() === 62 /* EqualsToken */) { + token() === 57 /* QuestionToken */ || token() === 63 /* EqualsToken */) { // ( xxx : // ( xxx , // ( xxx ? @@ -31399,16 +32556,16 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 137 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 138 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } } function parseAssertsTypePredicate() { var pos = getNodePos(); - var assertsModifier = parseExpectedToken(127 /* AssertsKeyword */); - var parameterName = token() === 107 /* ThisKeyword */ ? parseThisTypeNode() : parseIdentifier(); - var type = parseOptional(137 /* IsKeyword */) ? parseType() : undefined; + var assertsModifier = parseExpectedToken(128 /* AssertsKeyword */); + var parameterName = token() === 108 /* ThisKeyword */ ? parseThisTypeNode() : parseIdentifier(); + var type = parseOptional(138 /* IsKeyword */) ? parseType() : undefined; return finishNode(factory.createTypePredicateNode(assertsModifier, parameterName, type), pos); } function parseType() { @@ -31422,7 +32579,7 @@ var ts; } var pos = getNodePos(); var type = parseUnionTypeOrHigher(); - if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(93 /* ExtendsKeyword */)) { + if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(94 /* ExtendsKeyword */)) { // The type following 'extends' is not permitted to be another conditional type var extendsType = parseTypeWorker(/*noConditionalTypes*/ true); parseExpected(57 /* QuestionToken */); @@ -31439,11 +32596,11 @@ var ts; // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token()) { - case 107 /* ThisKeyword */: - case 105 /* SuperKeyword */: - case 103 /* NullKeyword */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: + case 108 /* ThisKeyword */: + case 106 /* SuperKeyword */: + case 104 /* NullKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: @@ -31452,14 +32609,14 @@ var ts; case 20 /* OpenParenToken */: case 22 /* OpenBracketToken */: case 18 /* OpenBraceToken */: - case 97 /* FunctionKeyword */: - case 83 /* ClassKeyword */: - case 102 /* NewKeyword */: + case 98 /* FunctionKeyword */: + case 84 /* ClassKeyword */: + case 103 /* NewKeyword */: case 43 /* SlashToken */: - case 67 /* SlashEqualsToken */: - case 78 /* Identifier */: + case 68 /* SlashEqualsToken */: + case 79 /* Identifier */: return true; - case 99 /* ImportKeyword */: + case 100 /* ImportKeyword */: return lookAhead(nextTokenIsOpenParenOrLessThanOrDot); default: return isIdentifier(); @@ -31474,15 +32631,15 @@ var ts; case 40 /* MinusToken */: case 54 /* TildeToken */: case 53 /* ExclamationToken */: - case 88 /* DeleteKeyword */: - case 111 /* TypeOfKeyword */: - case 113 /* VoidKeyword */: + case 89 /* DeleteKeyword */: + case 112 /* TypeOfKeyword */: + case 114 /* VoidKeyword */: case 45 /* PlusPlusToken */: case 46 /* MinusMinusToken */: case 29 /* LessThanToken */: - case 130 /* AwaitKeyword */: - case 124 /* YieldKeyword */: - case 79 /* PrivateIdentifier */: + case 131 /* AwaitKeyword */: + case 125 /* YieldKeyword */: + case 80 /* 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. @@ -31501,8 +32658,8 @@ var ts; function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. return token() !== 18 /* OpenBraceToken */ && - token() !== 97 /* FunctionKeyword */ && - token() !== 83 /* ClassKeyword */ && + token() !== 98 /* FunctionKeyword */ && + token() !== 84 /* ClassKeyword */ && token() !== 59 /* AtToken */ && isStartOfExpression(); } @@ -31527,7 +32684,7 @@ var ts; return expr; } function parseInitializer() { - return parseOptional(62 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; + return parseOptional(63 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; } function parseAssignmentExpressionOrHigher() { // AssignmentExpression[in,yield]: @@ -31573,7 +32730,7 @@ var ts; // 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 === 78 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { + if (expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(pos, expr, /*asyncModifier*/ undefined); } // Now see if we might be in cases '2' or '3'. @@ -31589,7 +32746,7 @@ var ts; return parseConditionalExpressionRest(expr, pos); } function isYieldExpression() { - if (token() === 124 /* YieldKeyword */) { + if (token() === 125 /* 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()) { @@ -31669,7 +32826,7 @@ 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() === 129 /* AsyncKeyword */) { + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */ || token() === 130 /* AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } if (token() === 38 /* EqualsGreaterThanToken */) { @@ -31682,7 +32839,7 @@ var ts; return 0 /* False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 129 /* AsyncKeyword */) { + if (token() === 130 /* AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0 /* False */; @@ -31726,13 +32883,13 @@ var ts; // 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 !== 129 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { + if (ts.isModifierKind(second) && second !== 130 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { return 1 /* 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 !== 107 /* ThisKeyword */) { + if (!isIdentifier() && second !== 108 /* ThisKeyword */) { return 0 /* False */; } switch (nextToken()) { @@ -31743,13 +32900,13 @@ var ts; case 57 /* 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() === 62 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { + if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 63 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { return 1 /* True */; } // Otherwise it is definitely not a lambda. return 0 /* False */; case 27 /* CommaToken */: - case 62 /* EqualsToken */: + case 63 /* EqualsToken */: case 21 /* CloseParenToken */: // If we have "(a," or "(a=" or "(a)" this *could* be an arrow function return 2 /* Unknown */; @@ -31768,10 +32925,10 @@ var ts; if (languageVariant === 1 /* JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 93 /* ExtendsKeyword */) { + if (third === 94 /* ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 62 /* EqualsToken */: + case 63 /* EqualsToken */: case 31 /* GreaterThanToken */: return false; default: @@ -31805,7 +32962,7 @@ var ts; } function tryParseAsyncSimpleArrowFunctionExpression() { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" - if (token() === 129 /* AsyncKeyword */) { + if (token() === 130 /* AsyncKeyword */) { if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) { var pos = getNodePos(); var asyncModifier = parseModifiersForArrowFunction(); @@ -31819,7 +32976,7 @@ 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() === 129 /* AsyncKeyword */) { + if (token() === 130 /* 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" @@ -31828,7 +32985,7 @@ var ts; } // Check for un-parenthesized AsyncArrowFunction var expr = parseBinaryExpressionOrHigher(0 /* Lowest */); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 78 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { + if (!scanner.hasPrecedingLineBreak() && expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { return 1 /* True */; } } @@ -31893,8 +33050,8 @@ var ts; return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */); } if (token() !== 26 /* SemicolonToken */ && - token() !== 97 /* FunctionKeyword */ && - token() !== 83 /* ClassKeyword */ && + token() !== 98 /* FunctionKeyword */ && + token() !== 84 /* ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -31932,7 +33089,7 @@ var ts; var colonToken; return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher), colonToken = parseExpectedToken(58 /* ColonToken */), ts.nodeIsPresent(colonToken) ? parseAssignmentExpressionOrHigher() - : createMissingNode(78 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */))), pos); + : createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */))), pos); } function parseBinaryExpressionOrHigher(precedence) { var pos = getNodePos(); @@ -31940,7 +33097,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand, pos); } function isInOrOfKeyword(t) { - return t === 100 /* InKeyword */ || t === 156 /* OfKeyword */; + return t === 101 /* InKeyword */ || t === 158 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand, pos) { while (true) { @@ -31975,10 +33132,10 @@ var ts; if (!consumeCurrentOperator) { break; } - if (token() === 100 /* InKeyword */ && inDisallowInContext()) { + if (token() === 101 /* InKeyword */ && inDisallowInContext()) { break; } - if (token() === 126 /* AsKeyword */) { + if (token() === 127 /* AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -31999,7 +33156,7 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 100 /* InKeyword */) { + if (inDisallowInContext() && token() === 101 /* InKeyword */) { return false; } return ts.getBinaryOperatorPrecedence(token()) > 0; @@ -32027,7 +33184,7 @@ var ts; return finishNode(factory.createVoidExpression(nextTokenAnd(parseSimpleUnaryExpression)), pos); } function isAwaitExpression() { - if (token() === 130 /* AwaitKeyword */) { + if (token() === 131 /* AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -32080,7 +33237,7 @@ var ts; if (token() === 42 /* AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 206 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 208 /* 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 { @@ -32110,18 +33267,18 @@ var ts; case 54 /* TildeToken */: case 53 /* ExclamationToken */: return parsePrefixUnaryExpression(); - case 88 /* DeleteKeyword */: + case 89 /* DeleteKeyword */: return parseDeleteExpression(); - case 111 /* TypeOfKeyword */: + case 112 /* TypeOfKeyword */: return parseTypeOfExpression(); - case 113 /* VoidKeyword */: + case 114 /* VoidKeyword */: return parseVoidExpression(); case 29 /* LessThanToken */: // This is modified UnaryExpression grammar in TypeScript // UnaryExpression (modified): // < type > UnaryExpression return parseTypeAssertion(); - case 130 /* AwaitKeyword */: + case 131 /* AwaitKeyword */: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -32148,10 +33305,10 @@ var ts; case 40 /* MinusToken */: case 54 /* TildeToken */: case 53 /* ExclamationToken */: - case 88 /* DeleteKeyword */: - case 111 /* TypeOfKeyword */: - case 113 /* VoidKeyword */: - case 130 /* AwaitKeyword */: + case 89 /* DeleteKeyword */: + case 112 /* TypeOfKeyword */: + case 114 /* VoidKeyword */: + case 131 /* AwaitKeyword */: return false; case 29 /* LessThanToken */: // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression @@ -32227,7 +33384,7 @@ var ts; // or starts the beginning of the first four CallExpression productions. var pos = getNodePos(); var expression; - if (token() === 99 /* ImportKeyword */) { + if (token() === 100 /* 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: @@ -32241,7 +33398,7 @@ var ts; // This is an 'import.*' metaproperty (i.e. 'import.meta') nextToken(); // advance past the 'import' nextToken(); // advance past the dot - expression = finishNode(factory.createMetaProperty(99 /* ImportKeyword */, parseIdentifierName()), pos); + expression = finishNode(factory.createMetaProperty(100 /* ImportKeyword */, parseIdentifierName()), pos); sourceFlags |= 2097152 /* PossiblyContainsImportMeta */; } else { @@ -32249,7 +33406,7 @@ var ts; } } else { - expression = token() === 105 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); + expression = token() === 106 /* 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 @@ -32327,23 +33484,45 @@ var ts; // 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); } - function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext, topInvalidNodePosition) { + function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext, topInvalidNodePosition, openingTag) { var pos = getNodePos(); var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 275 /* JsxOpeningElement */) { + if (opening.kind === 277 /* JsxOpeningElement */) { var children = parseJsxChildren(opening); - var closingElement = parseJsxClosingElement(inExpressionContext); - if (!tagNamesAreEquivalent(opening.tagName, closingElement.tagName)) { - parseErrorAtRange(closingElement, ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNodeFromSourceText(sourceText, opening.tagName)); + var closingElement = void 0; + var lastChild = children[children.length - 1]; + if ((lastChild === null || lastChild === void 0 ? void 0 : lastChild.kind) === 275 /* JsxElement */ + && !tagNamesAreEquivalent(lastChild.openingElement.tagName, lastChild.closingElement.tagName) + && tagNamesAreEquivalent(opening.tagName, lastChild.closingElement.tagName)) { + // when an unclosed JsxOpeningElement incorrectly parses its parent's JsxClosingElement, + // restructure (
(...
)) --> (
(...)
) + // (no need to error; the parent will error) + var end = lastChild.openingElement.end; // newly-created children and closing are both zero-width end/end + var newLast = finishNode(factory.createJsxElement(lastChild.openingElement, createNodeArray([], end, end), finishNode(factory.createJsxClosingElement(finishNode(factory.createIdentifier(""), end, end)), end, end)), lastChild.openingElement.pos, end); + children = createNodeArray(__spreadArray(__spreadArray([], children.slice(0, children.length - 1)), [newLast]), children.pos, end); + closingElement = lastChild.closingElement; + } + else { + closingElement = parseJsxClosingElement(opening, inExpressionContext); + if (!tagNamesAreEquivalent(opening.tagName, closingElement.tagName)) { + if (openingTag && ts.isJsxOpeningElement(openingTag) && tagNamesAreEquivalent(closingElement.tagName, openingTag.tagName)) { + // opening incorrectly matched with its parent's closing -- put error on opening + parseErrorAtRange(opening.tagName, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, opening.tagName)); + } + else { + // other opening/closing mismatches -- put error on closing + parseErrorAtRange(closingElement.tagName, ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNodeFromSourceText(sourceText, opening.tagName)); + } + } } result = finishNode(factory.createJsxElement(opening, children, closingElement), pos); } - else if (opening.kind === 278 /* JsxOpeningFragment */) { + else if (opening.kind === 280 /* JsxOpeningFragment */) { result = finishNode(factory.createJsxFragment(opening, parseJsxChildren(opening), parseJsxClosingFragment(inExpressionContext)), pos); } else { - ts.Debug.assert(opening.kind === 274 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 276 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -32397,7 +33576,7 @@ var ts; case 18 /* OpenBraceToken */: return parseJsxExpression(/*inExpressionContext*/ false); case 29 /* LessThanToken */: - return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ false); + return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ false, /*topInvalidNodePosition*/ undefined, openingTag); default: return ts.Debug.assertNever(token); } @@ -32412,6 +33591,13 @@ var ts; if (!child) break; list.push(child); + if (ts.isJsxOpeningElement(openingTag) + && (child === null || child === void 0 ? void 0 : child.kind) === 275 /* 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 + break; + } } parsingContext = saveParsingContext; return createNodeArray(list, listPos); @@ -32441,12 +33627,14 @@ var ts; } else { parseExpected(43 /* SlashToken */); - if (inExpressionContext) { - parseExpected(31 /* GreaterThanToken */); - } - else { - parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); - scanJsxText(); + if (parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { + // manually advance the scanner in order to look for jsx text inside jsx + if (inExpressionContext) { + nextToken(); + } + else { + scanJsxText(); + } } node = factory.createJsxSelfClosingElement(tagName, typeArguments, attributes); } @@ -32460,7 +33648,7 @@ 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() === 107 /* ThisKeyword */ ? + var expression = token() === 108 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); while (parseOptional(24 /* DotToken */)) { expression = finishNode(factory.createPropertyAccessExpression(expression, parseRightSideOfDot(/*allowIdentifierNames*/ true, /*allowPrivateIdentifiers*/ false)), pos); @@ -32497,7 +33685,7 @@ var ts; } scanJsxIdentifier(); var pos = getNodePos(); - return finishNode(factory.createJsxAttribute(parseIdentifierName(), token() !== 62 /* EqualsToken */ ? undefined : + return finishNode(factory.createJsxAttribute(parseIdentifierName(), token() !== 63 /* EqualsToken */ ? undefined : scanJsxAttributeValue() === 10 /* StringLiteral */ ? parseLiteralNode() : parseJsxExpression(/*inExpressionContext*/ true)), pos); } @@ -32509,16 +33697,18 @@ var ts; parseExpected(19 /* CloseBraceToken */); return finishNode(factory.createJsxSpreadAttribute(expression), pos); } - function parseJsxClosingElement(inExpressionContext) { + function parseJsxClosingElement(open, inExpressionContext) { var pos = getNodePos(); parseExpected(30 /* LessThanSlashToken */); var tagName = parseJsxElementName(); - if (inExpressionContext) { - parseExpected(31 /* GreaterThanToken */); - } - else { - parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); - scanJsxText(); + if (parseExpected(31 /* 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(); + } + else { + scanJsxText(); + } } return finishNode(factory.createJsxClosingElement(tagName), pos); } @@ -32528,12 +33718,14 @@ var ts; if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); } - if (inExpressionContext) { - parseExpected(31 /* GreaterThanToken */); - } - else { - parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); - scanJsxText(); + if (parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { + // manually advance the scanner in order to look for jsx text inside jsx + if (inExpressionContext) { + nextToken(); + } + else { + scanJsxText(); + } } return finishNode(factory.createJsxJsxClosingFragment(), pos); } @@ -32590,7 +33782,7 @@ var ts; function parseElementAccessExpressionRest(pos, expression, questionDotToken) { var argumentExpression; if (token() === 23 /* CloseBracketToken */) { - argumentExpression = createMissingNode(78 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); + argumentExpression = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); } else { var argument = allowInAnd(parseExpression); @@ -32685,7 +33877,7 @@ var ts; } if (questionDotToken) { // We failed to parse anything, so report a missing identifier here. - var name = createMissingNode(78 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected); + var name = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected); expression = finishNode(factory.createPropertyAccessChain(expression, questionDotToken, name), pos); } break; @@ -32766,11 +33958,11 @@ var ts; case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 107 /* ThisKeyword */: - case 105 /* SuperKeyword */: - case 103 /* NullKeyword */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: + case 108 /* ThisKeyword */: + case 106 /* SuperKeyword */: + case 104 /* NullKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: return parseTokenNode(); case 20 /* OpenParenToken */: return parseParenthesizedExpression(); @@ -32778,7 +33970,7 @@ var ts; return parseArrayLiteralExpression(); case 18 /* OpenBraceToken */: return parseObjectLiteralExpression(); - case 129 /* AsyncKeyword */: + case 130 /* 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. @@ -32786,14 +33978,14 @@ var ts; break; } return parseFunctionExpression(); - case 83 /* ClassKeyword */: + case 84 /* ClassKeyword */: return parseClassExpression(); - case 97 /* FunctionKeyword */: + case 98 /* FunctionKeyword */: return parseFunctionExpression(); - case 102 /* NewKeyword */: + case 103 /* NewKeyword */: return parseNewExpressionOrNewDotTarget(); case 43 /* SlashToken */: - case 67 /* SlashEqualsToken */: + case 68 /* SlashEqualsToken */: if (reScanSlashToken() === 13 /* RegularExpressionLiteral */) { return parseLiteralNode(); } @@ -32842,11 +34034,11 @@ var ts; } var decorators = parseDecorators(); var modifiers = parseModifiers(); - if (parseContextualModifier(134 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 167 /* GetAccessor */); + if (parseContextualModifier(135 /* GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 169 /* GetAccessor */); } - if (parseContextualModifier(146 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 168 /* SetAccessor */); + if (parseContextualModifier(147 /* SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 170 /* SetAccessor */); } var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); @@ -32865,7 +34057,7 @@ var ts; var node; var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* ColonToken */); if (isShorthandPropertyAssignment) { - var equalsToken = parseOptionalToken(62 /* EqualsToken */); + var equalsToken = parseOptionalToken(63 /* EqualsToken */); var objectAssignmentInitializer = equalsToken ? allowInAnd(parseAssignmentExpressionOrHigher) : undefined; node = factory.createShorthandPropertyAssignment(name, objectAssignmentInitializer); // Save equals token for error reporting. @@ -32911,7 +34103,7 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiers(); - parseExpected(97 /* FunctionKeyword */); + 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 */; @@ -32934,10 +34126,10 @@ var ts; } function parseNewExpressionOrNewDotTarget() { var pos = getNodePos(); - parseExpected(102 /* NewKeyword */); + parseExpected(103 /* NewKeyword */); if (parseOptional(24 /* DotToken */)) { var name = parseIdentifierName(); - return finishNode(factory.createMetaProperty(102 /* NewKeyword */, name), pos); + return finishNode(factory.createMetaProperty(103 /* NewKeyword */, name), pos); } var expressionPos = getNodePos(); var expression = parsePrimaryExpression(); @@ -32964,6 +34156,7 @@ var ts; // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { var pos = getNodePos(); + var hasJSDoc = hasPrecedingJSDocComment(); var openBracePosition = scanner.getTokenPos(); if (parseExpected(18 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { var multiLine = scanner.hasPrecedingLineBreak(); @@ -32974,11 +34167,16 @@ var ts; ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here)); } } - return finishNode(factory.createBlock(statements, multiLine), pos); + var result = withJSDoc(finishNode(factory.createBlock(statements, multiLine), pos), hasJSDoc); + if (token() === 63 /* 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(); + } + return result; } else { var statements = createMissingList(); - return finishNode(factory.createBlock(statements, /*multiLine*/ undefined), pos); + return withJSDoc(finishNode(factory.createBlock(statements, /*multiLine*/ undefined), pos), hasJSDoc); } } function parseFunctionBlock(flags, diagnosticMessage) { @@ -33005,24 +34203,27 @@ var ts; } function parseEmptyStatement() { var pos = getNodePos(); + var hasJSDoc = hasPrecedingJSDocComment(); parseExpected(26 /* SemicolonToken */); - return finishNode(factory.createEmptyStatement(), pos); + return withJSDoc(finishNode(factory.createEmptyStatement(), pos), hasJSDoc); } function parseIfStatement() { var pos = getNodePos(); - parseExpected(98 /* IfKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(99 /* IfKeyword */); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); var thenStatement = parseStatement(); - var elseStatement = parseOptional(90 /* ElseKeyword */) ? parseStatement() : undefined; - return finishNode(factory.createIfStatement(expression, thenStatement, elseStatement), pos); + var elseStatement = parseOptional(91 /* ElseKeyword */) ? parseStatement() : undefined; + return withJSDoc(finishNode(factory.createIfStatement(expression, thenStatement, elseStatement), pos), hasJSDoc); } function parseDoStatement() { var pos = getNodePos(); - parseExpected(89 /* DoKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(90 /* DoKeyword */); var statement = parseStatement(); - parseExpected(114 /* WhileKeyword */); + parseExpected(115 /* WhileKeyword */); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); @@ -33031,25 +34232,27 @@ var ts; // 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 */); - return finishNode(factory.createDoStatement(statement, expression), pos); + return withJSDoc(finishNode(factory.createDoStatement(statement, expression), pos), hasJSDoc); } function parseWhileStatement() { var pos = getNodePos(); - parseExpected(114 /* WhileKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(115 /* WhileKeyword */); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); var statement = parseStatement(); - return finishNode(factory.createWhileStatement(expression, statement), pos); + return withJSDoc(finishNode(factory.createWhileStatement(expression, statement), pos), hasJSDoc); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(96 /* ForKeyword */); - var awaitToken = parseOptionalToken(130 /* AwaitKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(97 /* ForKeyword */); + var awaitToken = parseOptionalToken(131 /* AwaitKeyword */); parseExpected(20 /* OpenParenToken */); var initializer; if (token() !== 26 /* SemicolonToken */) { - if (token() === 112 /* VarKeyword */ || token() === 118 /* LetKeyword */ || token() === 84 /* ConstKeyword */) { + if (token() === 113 /* VarKeyword */ || token() === 119 /* LetKeyword */ || token() === 85 /* ConstKeyword */) { initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { @@ -33057,12 +34260,12 @@ var ts; } } var node; - if (awaitToken ? parseExpected(156 /* OfKeyword */) : parseOptional(156 /* OfKeyword */)) { + if (awaitToken ? parseExpected(158 /* OfKeyword */) : parseOptional(158 /* OfKeyword */)) { var expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(21 /* CloseParenToken */); node = factory.createForOfStatement(awaitToken, initializer, expression, parseStatement()); } - else if (parseOptional(100 /* InKeyword */)) { + else if (parseOptional(101 /* InKeyword */)) { var expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); node = factory.createForInStatement(initializer, expression, parseStatement()); @@ -33079,37 +34282,40 @@ var ts; parseExpected(21 /* CloseParenToken */); node = factory.createForStatement(initializer, condition, incrementor, parseStatement()); } - return finishNode(node, pos); + return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseBreakOrContinueStatement(kind) { var pos = getNodePos(); - parseExpected(kind === 241 /* BreakStatement */ ? 80 /* BreakKeyword */ : 85 /* ContinueKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(kind === 243 /* BreakStatement */ ? 81 /* BreakKeyword */ : 86 /* ContinueKeyword */); var label = canParseSemicolon() ? undefined : parseIdentifier(); parseSemicolon(); - var node = kind === 241 /* BreakStatement */ + var node = kind === 243 /* BreakStatement */ ? factory.createBreakStatement(label) : factory.createContinueStatement(label); - return finishNode(node, pos); + return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseReturnStatement() { var pos = getNodePos(); - parseExpected(104 /* ReturnKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(105 /* ReturnKeyword */); var expression = canParseSemicolon() ? undefined : allowInAnd(parseExpression); parseSemicolon(); - return finishNode(factory.createReturnStatement(expression), pos); + return withJSDoc(finishNode(factory.createReturnStatement(expression), pos), hasJSDoc); } function parseWithStatement() { var pos = getNodePos(); - parseExpected(115 /* WithKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(116 /* WithKeyword */); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); var statement = doInsideOfContext(16777216 /* InWithStatement */, parseStatement); - return finishNode(factory.createWithStatement(expression, statement), pos); + return withJSDoc(finishNode(factory.createWithStatement(expression, statement), pos), hasJSDoc); } function parseCaseClause() { var pos = getNodePos(); - parseExpected(81 /* CaseKeyword */); + parseExpected(82 /* CaseKeyword */); var expression = allowInAnd(parseExpression); parseExpected(58 /* ColonToken */); var statements = parseList(3 /* SwitchClauseStatements */, parseStatement); @@ -33117,13 +34323,13 @@ var ts; } function parseDefaultClause() { var pos = getNodePos(); - parseExpected(87 /* DefaultKeyword */); + parseExpected(88 /* DefaultKeyword */); parseExpected(58 /* ColonToken */); var statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(factory.createDefaultClause(statements), pos); } function parseCaseOrDefaultClause() { - return token() === 81 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token() === 82 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseCaseBlock() { var pos = getNodePos(); @@ -33134,18 +34340,20 @@ var ts; } function parseSwitchStatement() { var pos = getNodePos(); - parseExpected(106 /* SwitchKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(107 /* SwitchKeyword */); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); var caseBlock = parseCaseBlock(); - return finishNode(factory.createSwitchStatement(expression, caseBlock), pos); + return withJSDoc(finishNode(factory.createSwitchStatement(expression, caseBlock), pos), hasJSDoc); } function parseThrowStatement() { // ThrowStatement[Yield] : // throw [no LineTerminator here]Expression[In, ?Yield]; var pos = getNodePos(); - parseExpected(108 /* ThrowKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(109 /* 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. @@ -33157,26 +34365,27 @@ var ts; expression = finishNode(factory.createIdentifier(""), getNodePos()); } parseSemicolon(); - return finishNode(factory.createThrowStatement(expression), pos); + return withJSDoc(finishNode(factory.createThrowStatement(expression), pos), hasJSDoc); } // TODO: Review for error recovery function parseTryStatement() { var pos = getNodePos(); - parseExpected(110 /* TryKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(111 /* TryKeyword */); var tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); - var catchClause = token() === 82 /* CatchKeyword */ ? parseCatchClause() : undefined; + var catchClause = token() === 83 /* 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() === 95 /* FinallyKeyword */) { - parseExpected(95 /* FinallyKeyword */); + if (!catchClause || token() === 96 /* FinallyKeyword */) { + parseExpected(96 /* FinallyKeyword */); finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } - return finishNode(factory.createTryStatement(tryBlock, catchClause, finallyBlock), pos); + return withJSDoc(finishNode(factory.createTryStatement(tryBlock, catchClause, finallyBlock), pos), hasJSDoc); } function parseCatchClause() { var pos = getNodePos(); - parseExpected(82 /* CatchKeyword */); + parseExpected(83 /* CatchKeyword */); var variableDeclaration; if (parseOptional(20 /* OpenParenToken */)) { variableDeclaration = parseVariableDeclaration(); @@ -33191,9 +34400,10 @@ var ts; } function parseDebuggerStatement() { var pos = getNodePos(); - parseExpected(86 /* DebuggerKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(87 /* DebuggerKeyword */); parseSemicolon(); - return finishNode(factory.createDebuggerStatement(), pos); + return withJSDoc(finishNode(factory.createDebuggerStatement(), pos), hasJSDoc); } function parseExpressionOrLabeledStatement() { // Avoiding having to do the lookahead for a labeled statement by just trying to parse @@ -33223,11 +34433,11 @@ var ts; } function nextTokenIsClassKeywordOnSameLine() { nextToken(); - return token() === 83 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 84 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 97 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 98 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine() { nextToken(); @@ -33236,12 +34446,12 @@ var ts; function isDeclaration() { while (true) { switch (token()) { - case 112 /* VarKeyword */: - case 118 /* LetKeyword */: - case 84 /* ConstKeyword */: - case 97 /* FunctionKeyword */: - case 83 /* ClassKeyword */: - case 91 /* EnumKeyword */: + case 113 /* VarKeyword */: + case 119 /* LetKeyword */: + case 85 /* ConstKeyword */: + case 98 /* FunctionKeyword */: + case 84 /* ClassKeyword */: + case 92 /* 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 @@ -33264,44 +34474,44 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 117 /* InterfaceKeyword */: - case 149 /* TypeKeyword */: + case 118 /* InterfaceKeyword */: + case 150 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 139 /* ModuleKeyword */: - case 140 /* NamespaceKeyword */: + case 140 /* ModuleKeyword */: + case 141 /* NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 125 /* AbstractKeyword */: - case 129 /* AsyncKeyword */: - case 133 /* DeclareKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 122 /* PublicKeyword */: - case 142 /* ReadonlyKeyword */: + case 126 /* AbstractKeyword */: + case 130 /* AsyncKeyword */: + case 134 /* DeclareKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + case 123 /* PublicKeyword */: + case 143 /* ReadonlyKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 154 /* GlobalKeyword */: + case 155 /* GlobalKeyword */: nextToken(); - return token() === 18 /* OpenBraceToken */ || token() === 78 /* Identifier */ || token() === 92 /* ExportKeyword */; - case 99 /* ImportKeyword */: + return token() === 18 /* OpenBraceToken */ || token() === 79 /* Identifier */ || token() === 93 /* ExportKeyword */; + case 100 /* ImportKeyword */: nextToken(); return token() === 10 /* StringLiteral */ || token() === 41 /* AsteriskToken */ || token() === 18 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); - case 92 /* ExportKeyword */: + case 93 /* ExportKeyword */: var currentToken_1 = nextToken(); - if (currentToken_1 === 149 /* TypeKeyword */) { + if (currentToken_1 === 150 /* TypeKeyword */) { currentToken_1 = lookAhead(nextToken); } - if (currentToken_1 === 62 /* EqualsToken */ || currentToken_1 === 41 /* AsteriskToken */ || - currentToken_1 === 18 /* OpenBraceToken */ || currentToken_1 === 87 /* DefaultKeyword */ || - currentToken_1 === 126 /* AsKeyword */) { + if (currentToken_1 === 63 /* EqualsToken */ || currentToken_1 === 41 /* AsteriskToken */ || + currentToken_1 === 18 /* OpenBraceToken */ || currentToken_1 === 88 /* DefaultKeyword */ || + currentToken_1 === 127 /* AsKeyword */) { return true; } continue; - case 123 /* StaticKeyword */: + case 124 /* StaticKeyword */: nextToken(); continue; default: @@ -33317,48 +34527,48 @@ var ts; case 59 /* AtToken */: case 26 /* SemicolonToken */: case 18 /* OpenBraceToken */: - case 112 /* VarKeyword */: - case 118 /* LetKeyword */: - case 97 /* FunctionKeyword */: - case 83 /* ClassKeyword */: - case 91 /* EnumKeyword */: - case 98 /* IfKeyword */: - case 89 /* DoKeyword */: - case 114 /* WhileKeyword */: - case 96 /* ForKeyword */: - case 85 /* ContinueKeyword */: - case 80 /* BreakKeyword */: - case 104 /* ReturnKeyword */: - case 115 /* WithKeyword */: - case 106 /* SwitchKeyword */: - case 108 /* ThrowKeyword */: - case 110 /* TryKeyword */: - case 86 /* DebuggerKeyword */: + 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 */: // '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 82 /* CatchKeyword */: - case 95 /* FinallyKeyword */: + case 83 /* CatchKeyword */: + case 96 /* FinallyKeyword */: return true; - case 99 /* ImportKeyword */: + case 100 /* ImportKeyword */: return isStartOfDeclaration() || lookAhead(nextTokenIsOpenParenOrLessThanOrDot); - case 84 /* ConstKeyword */: - case 92 /* ExportKeyword */: + case 85 /* ConstKeyword */: + case 93 /* ExportKeyword */: return isStartOfDeclaration(); - case 129 /* AsyncKeyword */: - case 133 /* DeclareKeyword */: - case 117 /* InterfaceKeyword */: - case 139 /* ModuleKeyword */: - case 140 /* NamespaceKeyword */: - case 149 /* TypeKeyword */: - case 154 /* GlobalKeyword */: + case 130 /* AsyncKeyword */: + case 134 /* DeclareKeyword */: + case 118 /* InterfaceKeyword */: + case 140 /* ModuleKeyword */: + case 141 /* NamespaceKeyword */: + case 150 /* TypeKeyword */: + case 155 /* GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 122 /* PublicKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 123 /* StaticKeyword */: - case 142 /* ReadonlyKeyword */: + case 123 /* PublicKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + case 124 /* StaticKeyword */: + case 143 /* 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); @@ -33381,64 +34591,64 @@ var ts; return parseEmptyStatement(); case 18 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); - case 112 /* VarKeyword */: + case 113 /* VarKeyword */: return parseVariableStatement(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 118 /* LetKeyword */: + case 119 /* LetKeyword */: if (isLetDeclaration()) { return parseVariableStatement(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); } break; - case 97 /* FunctionKeyword */: + case 98 /* FunctionKeyword */: return parseFunctionDeclaration(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 83 /* ClassKeyword */: + case 84 /* ClassKeyword */: return parseClassDeclaration(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 98 /* IfKeyword */: + case 99 /* IfKeyword */: return parseIfStatement(); - case 89 /* DoKeyword */: + case 90 /* DoKeyword */: return parseDoStatement(); - case 114 /* WhileKeyword */: + case 115 /* WhileKeyword */: return parseWhileStatement(); - case 96 /* ForKeyword */: + case 97 /* ForKeyword */: return parseForOrForInOrForOfStatement(); - case 85 /* ContinueKeyword */: - return parseBreakOrContinueStatement(240 /* ContinueStatement */); - case 80 /* BreakKeyword */: - return parseBreakOrContinueStatement(241 /* BreakStatement */); - case 104 /* ReturnKeyword */: + case 86 /* ContinueKeyword */: + return parseBreakOrContinueStatement(242 /* ContinueStatement */); + case 81 /* BreakKeyword */: + return parseBreakOrContinueStatement(243 /* BreakStatement */); + case 105 /* ReturnKeyword */: return parseReturnStatement(); - case 115 /* WithKeyword */: + case 116 /* WithKeyword */: return parseWithStatement(); - case 106 /* SwitchKeyword */: + case 107 /* SwitchKeyword */: return parseSwitchStatement(); - case 108 /* ThrowKeyword */: + case 109 /* ThrowKeyword */: return parseThrowStatement(); - case 110 /* TryKeyword */: + case 111 /* TryKeyword */: // Include 'catch' and 'finally' for error recovery. // falls through - case 82 /* CatchKeyword */: - case 95 /* FinallyKeyword */: + case 83 /* CatchKeyword */: + case 96 /* FinallyKeyword */: return parseTryStatement(); - case 86 /* DebuggerKeyword */: + case 87 /* DebuggerKeyword */: return parseDebuggerStatement(); case 59 /* AtToken */: return parseDeclaration(); - case 129 /* AsyncKeyword */: - case 117 /* InterfaceKeyword */: - case 149 /* TypeKeyword */: - case 139 /* ModuleKeyword */: - case 140 /* NamespaceKeyword */: - case 133 /* DeclareKeyword */: - case 84 /* ConstKeyword */: - case 91 /* EnumKeyword */: - case 92 /* ExportKeyword */: - case 99 /* ImportKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 122 /* PublicKeyword */: - case 125 /* AbstractKeyword */: - case 123 /* StaticKeyword */: - case 142 /* ReadonlyKeyword */: - case 154 /* GlobalKeyword */: + case 130 /* AsyncKeyword */: + case 118 /* InterfaceKeyword */: + case 150 /* TypeKeyword */: + case 140 /* ModuleKeyword */: + case 141 /* NamespaceKeyword */: + case 134 /* 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 143 /* ReadonlyKeyword */: + case 155 /* GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -33447,7 +34657,7 @@ var ts; return parseExpressionOrLabeledStatement(); } function isDeclareModifier(modifier) { - return modifier.kind === 133 /* DeclareKeyword */; + return modifier.kind === 134 /* DeclareKeyword */; } function parseDeclaration() { // TODO: Can we hold onto the parsed decorators/modifiers and advance the scanner @@ -33488,33 +34698,33 @@ var ts; } function parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers) { switch (token()) { - case 112 /* VarKeyword */: - case 118 /* LetKeyword */: - case 84 /* ConstKeyword */: + case 113 /* VarKeyword */: + case 119 /* LetKeyword */: + case 85 /* ConstKeyword */: return parseVariableStatement(pos, hasJSDoc, decorators, modifiers); - case 97 /* FunctionKeyword */: + case 98 /* FunctionKeyword */: return parseFunctionDeclaration(pos, hasJSDoc, decorators, modifiers); - case 83 /* ClassKeyword */: + case 84 /* ClassKeyword */: return parseClassDeclaration(pos, hasJSDoc, decorators, modifiers); - case 117 /* InterfaceKeyword */: + case 118 /* InterfaceKeyword */: return parseInterfaceDeclaration(pos, hasJSDoc, decorators, modifiers); - case 149 /* TypeKeyword */: + case 150 /* TypeKeyword */: return parseTypeAliasDeclaration(pos, hasJSDoc, decorators, modifiers); - case 91 /* EnumKeyword */: + case 92 /* EnumKeyword */: return parseEnumDeclaration(pos, hasJSDoc, decorators, modifiers); - case 154 /* GlobalKeyword */: - case 139 /* ModuleKeyword */: - case 140 /* NamespaceKeyword */: + case 155 /* GlobalKeyword */: + case 140 /* ModuleKeyword */: + case 141 /* NamespaceKeyword */: return parseModuleDeclaration(pos, hasJSDoc, decorators, modifiers); - case 99 /* ImportKeyword */: + case 100 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers); - case 92 /* ExportKeyword */: + case 93 /* ExportKeyword */: nextToken(); switch (token()) { - case 87 /* DefaultKeyword */: - case 62 /* EqualsToken */: + case 88 /* DefaultKeyword */: + case 63 /* EqualsToken */: return parseExportAssignment(pos, hasJSDoc, decorators, modifiers); - case 126 /* AsKeyword */: + case 127 /* AsKeyword */: return parseNamespaceExportDeclaration(pos, hasJSDoc, decorators, modifiers); default: return parseExportDeclaration(pos, hasJSDoc, decorators, modifiers); @@ -33523,7 +34733,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(271 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(273 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); ts.setTextRangePos(missing, pos); missing.decorators = decorators; missing.modifiers = modifiers; @@ -33588,7 +34798,7 @@ var ts; function isBindingIdentifierOrPrivateIdentifierOrPattern() { return token() === 18 /* OpenBraceToken */ || token() === 22 /* OpenBracketToken */ - || token() === 79 /* PrivateIdentifier */ + || token() === 80 /* PrivateIdentifier */ || isBindingIdentifier(); } function parseIdentifierOrPattern(privateIdentifierDiagnosticMessage) { @@ -33605,27 +34815,28 @@ var ts; } function parseVariableDeclaration(allowExclamation) { var pos = getNodePos(); + var hasJSDoc = hasPrecedingJSDocComment(); var name = parseIdentifierOrPattern(ts.Diagnostics.Private_identifiers_are_not_allowed_in_variable_declarations); var exclamationToken; - if (allowExclamation && name.kind === 78 /* Identifier */ && + if (allowExclamation && name.kind === 79 /* Identifier */ && token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { exclamationToken = parseTokenNode(); } var type = parseTypeAnnotation(); var initializer = isInOrOfKeyword(token()) ? undefined : parseInitializer(); var node = factory.createVariableDeclaration(name, exclamationToken, type, initializer); - return finishNode(node, pos); + return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseVariableDeclarationList(inForStatementInitializer) { var pos = getNodePos(); var flags = 0; switch (token()) { - case 112 /* VarKeyword */: + case 113 /* VarKeyword */: break; - case 118 /* LetKeyword */: + case 119 /* LetKeyword */: flags |= 1 /* Let */; break; - case 84 /* ConstKeyword */: + case 85 /* ConstKeyword */: flags |= 2 /* Const */; break; default: @@ -33642,7 +34853,7 @@ var ts; // this context. // The checker will then give an error that there is an empty declaration list. var declarations; - if (token() === 156 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 158 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { declarations = createMissingList(); } else { @@ -33667,7 +34878,7 @@ var ts; function parseFunctionDeclaration(pos, hasJSDoc, decorators, modifiers) { var savedAwaitContext = inAwaitContext(); var modifierFlags = ts.modifiersToFlags(modifiers); - parseExpected(97 /* FunctionKeyword */); + parseExpected(98 /* FunctionKeyword */); var asteriskToken = parseOptionalToken(41 /* 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(); @@ -33684,8 +34895,8 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseConstructorName() { - if (token() === 132 /* ConstructorKeyword */) { - return parseExpected(132 /* ConstructorKeyword */); + if (token() === 133 /* ConstructorKeyword */) { + return parseExpected(133 /* ConstructorKeyword */); } if (token() === 10 /* StringLiteral */ && lookAhead(nextToken) === 20 /* OpenParenToken */) { return tryParse(function () { @@ -33746,12 +34957,12 @@ var ts; var parameters = parseParameters(0 /* None */); var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); var body = parseFunctionBlockOrSemicolon(0 /* None */); - var node = kind === 167 /* GetAccessor */ + var node = kind === 169 /* GetAccessor */ ? factory.createGetAccessorDeclaration(decorators, modifiers, name, parameters, type, body) : factory.createSetAccessorDeclaration(decorators, modifiers, name, parameters, body); // Keep track of `typeParameters` (for both) and `type` (for setters) if they were parsed those indicate grammar errors node.typeParameters = typeParameters; - if (type && node.kind === 168 /* SetAccessor */) + if (type && node.kind === 170 /* SetAccessor */) node.type = type; return withJSDoc(finishNode(node, pos), hasJSDoc); } @@ -33790,7 +35001,7 @@ var ts; // 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 === 146 /* SetKeyword */ || idToken === 134 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 147 /* SetKeyword */ || idToken === 135 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along @@ -33800,7 +35011,7 @@ var ts; case 29 /* LessThanToken */: // Generic Method declaration case 53 /* ExclamationToken */: // Non-null assertion on property name case 58 /* ColonToken */: // Type Annotation for declaration - case 62 /* EqualsToken */: // Initializer for declaration + case 63 /* EqualsToken */: // Initializer for declaration case 57 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. return true; default: @@ -33815,7 +35026,7 @@ var ts; return false; } function parseDecoratorExpression() { - if (inAwaitContext() && token() === 130 /* AwaitKeyword */) { + if (inAwaitContext() && token() === 131 /* 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(); @@ -33845,7 +35056,7 @@ var ts; function tryParseModifier(permitInvalidConstAsModifier) { var pos = getNodePos(); var kind = token(); - if (token() === 84 /* ConstKeyword */ && permitInvalidConstAsModifier) { + if (token() === 85 /* 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)) { @@ -33876,10 +35087,10 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 129 /* AsyncKeyword */) { + if (token() === 130 /* AsyncKeyword */) { var pos = getNodePos(); nextToken(); - var modifier = finishNode(factory.createToken(129 /* AsyncKeyword */), pos); + var modifier = finishNode(factory.createToken(130 /* AsyncKeyword */), pos); modifiers = createNodeArray([modifier], pos); } return modifiers; @@ -33893,13 +35104,13 @@ var ts; var hasJSDoc = hasPrecedingJSDocComment(); var decorators = parseDecorators(); var modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true); - if (parseContextualModifier(134 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 167 /* GetAccessor */); + if (parseContextualModifier(135 /* GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 169 /* GetAccessor */); } - if (parseContextualModifier(146 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 168 /* SetAccessor */); + if (parseContextualModifier(147 /* SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 170 /* SetAccessor */); } - if (token() === 132 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { + if (token() === 133 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { var constructorDeclaration = tryParseConstructorDeclaration(pos, hasJSDoc, decorators, modifiers); if (constructorDeclaration) { return constructorDeclaration; @@ -33929,21 +35140,21 @@ var ts; } if (decorators || modifiers) { // treat this as a property declaration with a missing name. - var name = createMissingNode(78 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var name = createMissingNode(79 /* 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, 221 /* ClassExpression */); + return parseClassDeclarationOrExpression(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined, 223 /* ClassExpression */); } function parseClassDeclaration(pos, hasJSDoc, decorators, modifiers) { - return parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, 252 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, 254 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, kind) { var savedAwaitContext = inAwaitContext(); - parseExpected(83 /* ClassKeyword */); + parseExpected(84 /* 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(); @@ -33961,7 +35172,7 @@ var ts; members = createMissingList(); } setAwaitContext(savedAwaitContext); - var node = kind === 252 /* ClassDeclaration */ + var node = kind === 254 /* ClassDeclaration */ ? factory.createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) : factory.createClassExpression(decorators, modifiers, name, typeParameters, heritageClauses, members); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -33977,7 +35188,7 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 116 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 117 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); } function parseHeritageClauses() { // ClassTail[Yield,Await] : (Modified) See 14.5 @@ -33990,7 +35201,7 @@ var ts; function parseHeritageClause() { var pos = getNodePos(); var tok = token(); - ts.Debug.assert(tok === 93 /* ExtendsKeyword */ || tok === 116 /* ImplementsKeyword */); // isListElement() should ensure this. + ts.Debug.assert(tok === 94 /* ExtendsKeyword */ || tok === 117 /* ImplementsKeyword */); // isListElement() should ensure this. nextToken(); var types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(factory.createHeritageClause(tok, types), pos); @@ -34006,13 +35217,13 @@ var ts; parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */) : undefined; } function isHeritageClause() { - return token() === 93 /* ExtendsKeyword */ || token() === 116 /* ImplementsKeyword */; + return token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; } function parseClassMembers() { return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(117 /* InterfaceKeyword */); + parseExpected(118 /* InterfaceKeyword */); var name = parseIdentifier(); var typeParameters = parseTypeParameters(); var heritageClauses = parseHeritageClauses(); @@ -34021,11 +35232,11 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseTypeAliasDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(149 /* TypeKeyword */); + parseExpected(150 /* TypeKeyword */); var name = parseIdentifier(); var typeParameters = parseTypeParameters(); - parseExpected(62 /* EqualsToken */); - var type = token() === 136 /* IntrinsicKeyword */ && tryParse(parseKeywordAndNoDot) || parseType(); + parseExpected(63 /* EqualsToken */); + var type = token() === 137 /* IntrinsicKeyword */ && tryParse(parseKeywordAndNoDot) || parseType(); parseSemicolon(); var node = factory.createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -34042,7 +35253,7 @@ var ts; return withJSDoc(finishNode(factory.createEnumMember(name, initializer), pos), hasJSDoc); } function parseEnumDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(91 /* EnumKeyword */); + parseExpected(92 /* EnumKeyword */); var name = parseIdentifier(); var members; if (parseExpected(18 /* OpenBraceToken */)) { @@ -34081,7 +35292,7 @@ var ts; function parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers) { var flags = 0; var name; - if (token() === 154 /* GlobalKeyword */) { + if (token() === 155 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation name = parseIdentifier(); flags |= 1024 /* GlobalAugmentation */; @@ -34102,15 +35313,15 @@ var ts; } function parseModuleDeclaration(pos, hasJSDoc, decorators, modifiers) { var flags = 0; - if (token() === 154 /* GlobalKeyword */) { + if (token() === 155 /* GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers); } - else if (parseOptional(140 /* NamespaceKeyword */)) { + else if (parseOptional(141 /* NamespaceKeyword */)) { flags |= 16 /* Namespace */; } else { - parseExpected(139 /* ModuleKeyword */); + parseExpected(140 /* ModuleKeyword */); if (token() === 10 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers); } @@ -34118,7 +35329,7 @@ var ts; return parseModuleOrNamespaceDeclaration(pos, hasJSDoc, decorators, modifiers, flags); } function isExternalModuleReference() { - return token() === 143 /* RequireKeyword */ && + return token() === 144 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { @@ -34128,8 +35339,8 @@ var ts; return nextToken() === 43 /* SlashToken */; } function parseNamespaceExportDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(126 /* AsKeyword */); - parseExpected(140 /* NamespaceKeyword */); + parseExpected(127 /* AsKeyword */); + parseExpected(141 /* NamespaceKeyword */); var name = parseIdentifier(); parseSemicolon(); var node = factory.createNamespaceExportDeclaration(name); @@ -34139,7 +35350,7 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseImportDeclarationOrImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(99 /* ImportKeyword */); + parseExpected(100 /* 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; @@ -34147,7 +35358,7 @@ var ts; identifier = parseIdentifier(); } var isTypeOnly = false; - if (token() !== 153 /* FromKeyword */ && + if (token() !== 154 /* FromKeyword */ && (identifier === null || identifier === void 0 ? void 0 : identifier.escapedText) === "type" && (isIdentifier() || tokenAfterImportDefinitelyProducesImportDeclaration())) { isTypeOnly = true; @@ -34165,7 +35376,7 @@ var ts; token() === 18 /* OpenBraceToken */ // import { ) { importClause = parseImportClause(identifier, afterImportPos, isTypeOnly); - parseExpected(153 /* FromKeyword */); + parseExpected(154 /* FromKeyword */); } var moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -34178,10 +35389,10 @@ var ts; function tokenAfterImportedIdentifierDefinitelyProducesImportDeclaration() { // In `import id ___`, the current token decides whether to produce // an ImportDeclaration or ImportEqualsDeclaration. - return token() === 27 /* CommaToken */ || token() === 153 /* FromKeyword */; + return token() === 27 /* CommaToken */ || token() === 154 /* FromKeyword */; } function parseImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers, identifier, isTypeOnly) { - parseExpected(62 /* EqualsToken */); + parseExpected(63 /* EqualsToken */); var moduleReference = parseModuleReference(); parseSemicolon(); var node = factory.createImportEqualsDeclaration(decorators, modifiers, isTypeOnly, identifier, moduleReference); @@ -34200,7 +35411,7 @@ var ts; var namedBindings; if (!identifier || parseOptional(27 /* CommaToken */)) { - namedBindings = token() === 41 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(264 /* NamedImports */); + namedBindings = token() === 41 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(266 /* NamedImports */); } return finishNode(factory.createImportClause(isTypeOnly, identifier, namedBindings), pos); } @@ -34211,7 +35422,7 @@ var ts; } function parseExternalModuleReference() { var pos = getNodePos(); - parseExpected(143 /* RequireKeyword */); + parseExpected(144 /* RequireKeyword */); parseExpected(20 /* OpenParenToken */); var expression = parseModuleSpecifier(); parseExpected(21 /* CloseParenToken */); @@ -34235,7 +35446,7 @@ var ts; // * as ImportedBinding var pos = getNodePos(); parseExpected(41 /* AsteriskToken */); - parseExpected(126 /* AsKeyword */); + parseExpected(127 /* AsKeyword */); var name = parseIdentifier(); return finishNode(factory.createNamespaceImport(name), pos); } @@ -34248,16 +35459,16 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - var node = kind === 264 /* NamedImports */ + var node = kind === 266 /* NamedImports */ ? factory.createNamedImports(parseBracketedList(23 /* ImportOrExportSpecifiers */, parseImportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */)) : factory.createNamedExports(parseBracketedList(23 /* ImportOrExportSpecifiers */, parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */)); return finishNode(node, pos); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(270 /* ExportSpecifier */); + return parseImportOrExportSpecifier(272 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(265 /* ImportSpecifier */); + return parseImportOrExportSpecifier(267 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var pos = getNodePos(); @@ -34273,9 +35484,9 @@ var ts; var identifierName = parseIdentifierName(); var propertyName; var name; - if (token() === 126 /* AsKeyword */) { + if (token() === 127 /* AsKeyword */) { propertyName = identifierName; - parseExpected(126 /* AsKeyword */); + parseExpected(127 /* AsKeyword */); checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -34284,10 +35495,10 @@ var ts; else { name = identifierName; } - if (kind === 265 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 267 /* ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } - var node = kind === 265 /* ImportSpecifier */ + var node = kind === 267 /* ImportSpecifier */ ? factory.createImportSpecifier(propertyName, name) : factory.createExportSpecifier(propertyName, name); return finishNode(node, pos); @@ -34300,22 +35511,22 @@ var ts; setAwaitContext(/*value*/ true); var exportClause; var moduleSpecifier; - var isTypeOnly = parseOptional(149 /* TypeKeyword */); + var isTypeOnly = parseOptional(150 /* TypeKeyword */); var namespaceExportPos = getNodePos(); if (parseOptional(41 /* AsteriskToken */)) { - if (parseOptional(126 /* AsKeyword */)) { + if (parseOptional(127 /* AsKeyword */)) { exportClause = parseNamespaceExport(namespaceExportPos); } - parseExpected(153 /* FromKeyword */); + parseExpected(154 /* FromKeyword */); moduleSpecifier = parseModuleSpecifier(); } else { - exportClause = parseNamedImportsOrExports(268 /* NamedExports */); + exportClause = parseNamedImportsOrExports(270 /* 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() === 153 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(153 /* FromKeyword */); + if (token() === 154 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(154 /* FromKeyword */); moduleSpecifier = parseModuleSpecifier(); } } @@ -34328,11 +35539,11 @@ var ts; var savedAwaitContext = inAwaitContext(); setAwaitContext(/*value*/ true); var isExportEquals; - if (parseOptional(62 /* EqualsToken */)) { + if (parseOptional(63 /* EqualsToken */)) { isExportEquals = true; } else { - parseExpected(87 /* DefaultKeyword */); + parseExpected(88 /* DefaultKeyword */); } var expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -34348,7 +35559,7 @@ var ts; getImportMetaIfNecessary(sourceFile); } function isAnExternalModuleIndicatorNode(node) { - return hasModifierOfKind(node, 92 /* ExportKeyword */) + return hasModifierOfKind(node, 93 /* ExportKeyword */) || ts.isImportEqualsDeclaration(node) && ts.isExternalModuleReference(node.moduleReference) || ts.isImportDeclaration(node) || ts.isExportAssignment(node) @@ -34367,7 +35578,7 @@ var ts; return ts.some(node.modifiers, function (m) { return m.kind === kind; }); } function isImportMeta(node) { - return ts.isMetaProperty(node) && node.keywordToken === 99 /* ImportKeyword */ && node.name.escapedText === "meta"; + return ts.isMetaProperty(node) && node.keywordToken === 100 /* ImportKeyword */ && node.name.escapedText === "meta"; } var ParsingContext; (function (ParsingContext) { @@ -34435,7 +35646,13 @@ var ts; function parseJSDocNameReference() { var pos = getNodePos(); var hasBrace = parseOptional(18 /* OpenBraceToken */); + var p2 = getNodePos(); var entityName = parseEntityName(/* allowReservedWords*/ false); + while (token() === 80 /* PrivateIdentifier */) { + reScanHashToken(); // rescan #id as # id + nextTokenJSDoc(); // then skip the # + entityName = finishNode(factory.createJSDocMemberName(entityName, parseIdentifier()), p2); + } if (hasBrace) { parseExpectedJSDoc(19 /* CloseBraceToken */); } @@ -34499,7 +35716,10 @@ var ts; var tags; var tagsPos; var tagsEnd; + var linkEnd; + var commentsPos; var comments = []; + var parts = []; // + 3 for leading /**, - 5 in total for /** */ return scanner.scanRange(start + 3, length - 5, function () { // Initially we can parse out a tag. We also have seen a starting asterisk. @@ -34528,6 +35748,8 @@ var ts; case 59 /* AtToken */: if (state === 0 /* BeginningOfLine */ || state === 1 /* SawAsterisk */) { removeTrailingWhitespace(comments); + if (!commentsPos) + commentsPos = getNodePos(); addTag(parseTag(indent)); // 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 @@ -34570,6 +35792,22 @@ var ts; break; case 1 /* EndOfFileToken */: break loop; + case 18 /* OpenBraceToken */: + state = 2 /* SavingComments */; + var commentEnd = scanner.getStartPos(); + var linkStart = scanner.getTextPos() - 1; + var link = parseJSDocLink(linkStart); + if (link) { + if (!linkEnd) { + removeLeadingNewlines(comments); + } + parts.push(finishNode(factory.createJSDocText(comments.join("")), linkEnd !== null && linkEnd !== void 0 ? linkEnd : start, commentEnd)); + parts.push(link); + comments = []; + linkEnd = scanner.getTextPos(); + break; + } + // fallthrough if it's not a {@link sequence default: // 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 @@ -34580,9 +35818,14 @@ var ts; } nextTokenJSDoc(); } - removeLeadingNewlines(comments); removeTrailingWhitespace(comments); - return createJSDocComment(); + if (parts.length && comments.length) { + parts.push(finishNode(factory.createJSDocText(comments.join("")), linkEnd !== null && linkEnd !== void 0 ? linkEnd : start, commentsPos)); + } + if (parts.length && tags) + ts.Debug.assertIsDefined(commentsPos, "having parsed tags implies that the end of the comment span should be set"); + var tagsArray = tags && createNodeArray(tags, tagsPos, tagsEnd); + return finishNode(factory.createJSDocComment(parts.length ? createNodeArray(parts, start, commentsPos) : comments.length ? comments.join("") : undefined, tagsArray), start, end); }); function removeLeadingNewlines(comments) { while (comments.length && (comments[0] === "\n" || comments[0] === "\r")) { @@ -34594,11 +35837,6 @@ var ts; comments.pop(); } } - function createJSDocComment() { - var comment = comments.length ? comments.join("") : undefined; - var tagsArray = tags && createNodeArray(tags, tagsPos, tagsEnd); - return finishNode(factory.createJSDocComment(comment, tagsArray), start, end); - } function isNextNonwhitespaceTokenEndOfFile() { // We must use infinite lookahead, as there could be any number of newlines :( while (true) { @@ -34678,6 +35916,9 @@ var ts; case "readonly": tag = parseSimpleTag(start, factory.createJSDocReadonlyTag, tagName, margin, indentText); break; + case "override": + tag = parseSimpleTag(start, factory.createJSDocOverrideTag, tagName, margin, indentText); + break; case "deprecated": hasDeprecatedTag = true; tag = parseSimpleTag(start, factory.createJSDocDeprecatedTag, tagName, margin, indentText); @@ -34725,8 +35966,12 @@ var ts; return parseTagComments(margin, indentText.slice(margin)); } function parseTagComments(indent, initialMargin) { + var commentsPos = getNodePos(); var comments = []; + var parts = []; + var linkEnd; var state = 0 /* BeginningOfLine */; + var previousWhitespace = true; var margin; function pushComment(text) { if (!margin) { @@ -34752,7 +35997,9 @@ var ts; indent = 0; break; case 59 /* AtToken */: - if (state === 3 /* SavingBackticks */) { + if (state === 3 /* SavingBackticks */ + || state === 2 /* 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; } @@ -34776,13 +36023,18 @@ var ts; break; case 18 /* OpenBraceToken */: state = 2 /* SavingComments */; - if (lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenText() === "link"; })) { - pushComment(scanner.getTokenText()); - nextTokenJSDoc(); + var commentEnd = scanner.getStartPos(); + var linkStart = scanner.getTextPos() - 1; + var link = parseJSDocLink(linkStart); + if (link) { + parts.push(finishNode(factory.createJSDocText(comments.join("")), linkEnd !== null && linkEnd !== void 0 ? linkEnd : commentsPos, commentEnd)); + parts.push(link); + comments = []; + linkEnd = scanner.getTextPos(); + } + else { pushComment(scanner.getTokenText()); - nextTokenJSDoc(); } - pushComment(scanner.getTokenText()); break; case 61 /* BacktickToken */: if (state === 3 /* SavingBackticks */) { @@ -34809,15 +36061,67 @@ var ts; pushComment(scanner.getTokenText()); break; } + previousWhitespace = token() === 5 /* WhitespaceTrivia */; tok = nextTokenJSDoc(); } removeLeadingNewlines(comments); removeTrailingWhitespace(comments); - return comments.length === 0 ? undefined : comments.join(""); + if (parts.length) { + if (comments.length) { + parts.push(finishNode(factory.createJSDocText(comments.join("")), linkEnd !== null && linkEnd !== void 0 ? linkEnd : commentsPos)); + } + return createNodeArray(parts, commentsPos, scanner.getTextPos()); + } + else if (comments.length) { + return comments.join(""); + } + } + function isNextJSDocTokenWhitespace() { + var next = nextTokenJSDoc(); + return next === 5 /* WhitespaceTrivia */ || next === 4 /* NewLineTrivia */; + } + function parseJSDocLink(start) { + var linkType = tryParse(parseJSDocLinkPrefix); + if (!linkType) { + return undefined; + } + nextTokenJSDoc(); // start at token after link, then skip any whitespace + skipWhitespace(); + // parseEntityName logs an error for non-identifier, so create a MissingNode ourselves to avoid the error + var p2 = getNodePos(); + var name = ts.tokenIsIdentifierOrKeyword(token()) + ? parseEntityName(/*allowReservedWords*/ true) + : undefined; + if (name) { + while (token() === 80 /* 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 */) { + text.push(scanner.getTokenText()); + nextTokenJSDoc(); + } + var create = linkType === "link" ? factory.createJSDocLink + : linkType === "linkcode" ? factory.createJSDocLinkCode + : factory.createJSDocLinkPlain; + return finishNode(create(name, text.join("")), start, scanner.getTextPos()); + } + function parseJSDocLinkPrefix() { + skipWhitespaceOrAsterisk(); + if (token() === 18 /* OpenBraceToken */ + && nextTokenJSDoc() === 59 /* AtToken */ + && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc())) { + var kind = scanner.getTokenValue(); + if (kind === "link" || kind === "linkcode" || kind === "linkplain") { + return kind; + } + } } function parseUnknownTag(start, tagName, indent, indentText) { - var end = getNodePos(); - return finishNode(factory.createJSDocUnknownTag(tagName, parseTrailingTagComments(start, end, indent, indentText)), start, end); + return finishNode(factory.createJSDocUnknownTag(tagName, parseTrailingTagComments(start, getNodePos(), indent, indentText)), start); } function addTag(tag) { if (!tag) { @@ -34851,7 +36155,7 @@ var ts; if (isBracketed) { skipWhitespace(); // May have an optional default, e.g. '[foo = 42]' - if (parseOptionalToken(62 /* EqualsToken */)) { + if (parseOptionalToken(63 /* EqualsToken */)) { parseExpression(); } parseExpected(23 /* CloseBracketToken */); @@ -34860,9 +36164,9 @@ var ts; } function isObjectOrObjectArrayTypeReference(node) { switch (node.kind) { - case 145 /* ObjectKeyword */: + case 146 /* ObjectKeyword */: return true; - case 178 /* ArrayType */: + case 180 /* ArrayType */: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && !node.typeArguments; @@ -34873,11 +36177,11 @@ var ts; var isNameFirst = !typeExpression; skipWhitespaceOrAsterisk(); var _a = parseBracketNameInPropertyAndParamTag(), name = _a.name, isBracketed = _a.isBracketed; - skipWhitespace(); - if (isNameFirst) { + var indentText = skipWhitespaceOrAsterisk(); + if (isNameFirst && !lookAhead(parseJSDocLinkPrefix)) { typeExpression = tryParseTypeExpression(); } - var comment = parseTagComments(indent + scanner.getStartPos() - start); + var comment = parseTrailingTagComments(start, getNodePos(), indent, indentText); var nestedTypeLiteral = target !== 4 /* CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { typeExpression = nestedTypeLiteral; @@ -34894,12 +36198,12 @@ var ts; var child = void 0; var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 326 /* JSDocParameterTag */ || child.kind === 333 /* JSDocPropertyTag */) { + if (child.kind === 334 /* JSDocParameterTag */ || child.kind === 341 /* JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - var literal = finishNode(factory.createJSDocTypeLiteral(children, typeExpression.type.kind === 178 /* ArrayType */), pos); + var literal = finishNode(factory.createJSDocTypeLiteral(children, typeExpression.type.kind === 180 /* ArrayType */), pos); return finishNode(factory.createJSDocTypeExpression(literal), pos); } } @@ -34909,27 +36213,34 @@ var ts; parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } var typeExpression = tryParseTypeExpression(); - var end = getNodePos(); - return finishNode(factory.createJSDocReturnTag(tagName, typeExpression, parseTrailingTagComments(start, end, indent, indentText)), start, end); + return finishNode(factory.createJSDocReturnTag(tagName, typeExpression, parseTrailingTagComments(start, getNodePos(), indent, indentText)), start); } function parseTypeTag(start, tagName, indent, indentText) { if (ts.some(tags, ts.isJSDocTypeTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } var typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); - var end = getNodePos(); - var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, end, indent, indentText) : undefined; - return finishNode(factory.createJSDocTypeTag(tagName, typeExpression, comments), start, end); + var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, getNodePos(), indent, indentText) : undefined; + return finishNode(factory.createJSDocTypeTag(tagName, typeExpression, comments), start); } function parseSeeTag(start, tagName, indent, indentText) { - var nameExpression = parseJSDocNameReference(); - var end = getNodePos(); - var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, end, indent, indentText) : undefined; - return finishNode(factory.createJSDocSeeTag(tagName, nameExpression, comments), start, end); + var isLink = lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenValue() === "link"; }); + var nameExpression = isLink ? undefined : parseJSDocNameReference(); + var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, getNodePos(), indent, indentText) : undefined; + return finishNode(factory.createJSDocSeeTag(tagName, nameExpression, comments), start); } function parseAuthorTag(start, tagName, indent, indentText) { - var comments = parseAuthorNameAndEmail() + (parseTrailingTagComments(start, end, indent, indentText) || ""); - return finishNode(factory.createJSDocAuthorTag(tagName, comments || undefined), start); + var commentStart = getNodePos(); + var textOnly = parseAuthorNameAndEmail(); + var commentEnd = scanner.getStartPos(); + var comments = parseTrailingTagComments(start, commentEnd, indent, indentText); + if (!comments) { + commentEnd = scanner.getStartPos(); + } + var allParts = typeof comments !== "string" + ? createNodeArray(ts.concatenate([finishNode(textOnly, commentStart, commentEnd)], comments), commentStart) // cast away readonly + : textOnly.text + comments; + return finishNode(factory.createJSDocAuthorTag(tagName, allParts), start); } function parseAuthorNameAndEmail() { var comments = []; @@ -34950,17 +36261,15 @@ var ts; comments.push(scanner.getTokenText()); token = nextTokenJSDoc(); } - return comments.join(""); + return factory.createJSDocText(comments.join("")); } function parseImplementsTag(start, tagName, margin, indentText) { var className = parseExpressionWithTypeArgumentsForAugments(); - var end = getNodePos(); - return finishNode(factory.createJSDocImplementsTag(tagName, className, parseTrailingTagComments(start, end, margin, indentText)), start, end); + return finishNode(factory.createJSDocImplementsTag(tagName, className, parseTrailingTagComments(start, getNodePos(), margin, indentText)), start); } function parseAugmentsTag(start, tagName, margin, indentText) { var className = parseExpressionWithTypeArgumentsForAugments(); - var end = getNodePos(); - return finishNode(factory.createJSDocAugmentsTag(tagName, className, parseTrailingTagComments(start, end, margin, indentText)), start, end); + return finishNode(factory.createJSDocAugmentsTag(tagName, className, parseTrailingTagComments(start, getNodePos(), margin, indentText)), start); } function parseExpressionWithTypeArgumentsForAugments() { var usedBrace = parseOptional(18 /* OpenBraceToken */); @@ -34984,20 +36293,17 @@ var ts; return node; } function parseSimpleTag(start, createTag, tagName, margin, indentText) { - var end = getNodePos(); - return finishNode(createTag(tagName, parseTrailingTagComments(start, end, margin, indentText)), start, end); + return finishNode(createTag(tagName, parseTrailingTagComments(start, getNodePos(), margin, indentText)), start); } function parseThisTag(start, tagName, margin, indentText) { var typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); - var end = getNodePos(); - return finishNode(factory.createJSDocThisTag(tagName, typeExpression, parseTrailingTagComments(start, end, margin, indentText)), start, end); + return finishNode(factory.createJSDocThisTag(tagName, typeExpression, parseTrailingTagComments(start, getNodePos(), margin, indentText)), start); } function parseEnumTag(start, tagName, margin, indentText) { var typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); - var end = getNodePos(); - return finishNode(factory.createJSDocEnumTag(tagName, typeExpression, parseTrailingTagComments(start, end, margin, indentText)), start, end); + return finishNode(factory.createJSDocEnumTag(tagName, typeExpression, parseTrailingTagComments(start, getNodePos(), margin, indentText)), start); } function parseTypedefTag(start, tagName, indent, indentText) { var _a; @@ -35014,7 +36320,7 @@ var ts; var hasChildren = false; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { hasChildren = true; - if (child.kind === 329 /* JSDocTypeTag */) { + if (child.kind === 337 /* JSDocTypeTag */) { if (childTypeTag) { parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags); var lastError = ts.lastOrUndefined(parseDiagnostics); @@ -35032,7 +36338,7 @@ var ts; } } if (hasChildren) { - var isArrayType = typeExpression && typeExpression.type.kind === 178 /* ArrayType */; + var isArrayType = typeExpression && typeExpression.type.kind === 180 /* ArrayType */; var jsdocTypeLiteral = factory.createJSDocTypeLiteral(jsDocPropertyTags, isArrayType); typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? childTypeTag.typeExpression : @@ -35085,17 +36391,16 @@ var ts; var returnTag = tryParse(function () { if (parseOptionalJsdoc(59 /* AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 327 /* JSDocReturnTag */) { + if (tag && tag.kind === 335 /* JSDocReturnTag */) { return tag; } } }); var typeExpression = finishNode(factory.createJSDocSignature(/*typeParameters*/ undefined, parameters, returnTag), start); - var end = getNodePos(); if (!comment) { - comment = parseTrailingTagComments(start, end, indent, indentText); + comment = parseTrailingTagComments(start, getNodePos(), indent, indentText); } - return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start, end); + return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start); } function escapedTextsEqual(a, b) { while (!ts.isIdentifier(a) || !ts.isIdentifier(b)) { @@ -35120,7 +36425,7 @@ var ts; case 59 /* AtToken */: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 326 /* JSDocParameterTag */ || child.kind === 333 /* JSDocPropertyTag */) && + if (child && (child.kind === 334 /* JSDocParameterTag */ || child.kind === 341 /* JSDocPropertyTag */) && target !== 4 /* CallbackParameter */ && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; @@ -35139,7 +36444,7 @@ var ts; } seenAsterisk = true; break; - case 78 /* Identifier */: + case 79 /* Identifier */: canParseTag = false; break; case 1 /* EndOfFileToken */: @@ -35177,6 +36482,9 @@ var ts; function parseTemplateTagTypeParameter() { var typeParameterPos = getNodePos(); var name = parseJSDocIdentifierName(ts.Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces); + if (ts.nodeIsMissing(name)) { + return undefined; + } return finishNode(factory.createTypeParameterDeclaration(name, /*constraint*/ undefined, /*defaultType*/ undefined), typeParameterPos); } function parseTemplateTagTypeParameters() { @@ -35184,7 +36492,10 @@ var ts; var typeParameters = []; do { skipWhitespace(); - typeParameters.push(parseTemplateTagTypeParameter()); + var node = parseTemplateTagTypeParameter(); + if (node !== undefined) { + typeParameters.push(node); + } skipWhitespaceOrAsterisk(); } while (parseOptionalJsdoc(27 /* CommaToken */)); return createNodeArray(typeParameters, pos); @@ -35203,8 +36514,7 @@ var ts; // TODO: Consider only parsing a single type parameter if there is a constraint. var constraint = token() === 18 /* OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; var typeParameters = parseTemplateTagTypeParameters(); - var end = getNodePos(); - return finishNode(factory.createJSDocTemplateTag(tagName, constraint, typeParameters, parseTrailingTagComments(start, end, indent, indentText)), start, end); + return finishNode(factory.createJSDocTemplateTag(tagName, constraint, typeParameters, parseTrailingTagComments(start, getNodePos(), indent, indentText)), start); } function parseOptionalJsdoc(t) { if (token() === t) { @@ -35232,7 +36542,7 @@ var ts; } function parseJSDocIdentifierName(message) { if (!ts.tokenIsIdentifierOrKeyword(token())) { - return createMissingNode(78 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); + return createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); } identifierCount++; var pos = scanner.getTokenPos(); @@ -35405,7 +36715,7 @@ var ts; switch (node.kind) { case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - case 78 /* Identifier */: + case 79 /* Identifier */: return true; } return false; @@ -35879,7 +37189,7 @@ var ts; if (namedArgRegExCache.has(name)) { return namedArgRegExCache.get(name); } - var result = new RegExp("(\\s" + name + "\\s*=\\s*)('|\")(.+?)\\2", "im"); + var result = new RegExp("(\\s" + name + "\\s*=\\s*)(?:(?:'([^']*)')|(?:\"([^\"]*)\"))", "im"); namedArgRegExCache.set(name, result); return result; } @@ -35903,16 +37213,17 @@ var ts; return; // Missing required argument, don't parse } else if (matchResult) { + var value = matchResult[2] || matchResult[3]; if (arg.captureSpan) { - var startPos = range.pos + matchResult.index + matchResult[1].length + matchResult[2].length; + var startPos = range.pos + matchResult.index + matchResult[1].length + 1; argument[arg.name] = { - value: matchResult[3], + value: value, pos: startPos, - end: startPos + matchResult[3].length + end: startPos + value.length }; } else { - argument[arg.name] = matchResult[3]; + argument[arg.name] = value; } } } @@ -35928,7 +37239,7 @@ var ts; return addPragmaForMatch(pragmas, range, 2 /* SingleLine */, singleLine); } if (range.kind === 3 /* MultiLineCommentTrivia */) { - var multiLinePragmaRegEx = /\s*@(\S+)\s*(.*)\s*$/gim; // Defined inline since it uses the "g" flag, which keeps a persistent index (for iterating) + 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); @@ -35955,7 +37266,7 @@ var ts; return {}; if (!pragma.args) return {}; - var args = text.split(/\s+/); + var args = ts.trimString(text).split(/\s+/); var argMap = {}; for (var i = 0; i < pragma.args.length; i++) { var argument = pragma.args[i]; @@ -35974,10 +37285,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 78 /* Identifier */) { + if (lhs.kind === 79 /* Identifier */) { return lhs.escapedText === rhs.escapedText; } - if (lhs.kind === 107 /* ThisKeyword */) { + if (lhs.kind === 108 /* ThisKeyword */) { return true; } // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only @@ -36019,6 +37330,7 @@ var ts; ["es2018", "lib.es2018.d.ts"], ["es2019", "lib.es2019.d.ts"], ["es2020", "lib.es2020.d.ts"], + ["es2021", "lib.es2021.d.ts"], ["esnext", "lib.esnext.d.ts"], // Host only ["dom", "lib.dom.d.ts"], @@ -36058,14 +37370,17 @@ var ts; ["es2020.string", "lib.es2020.string.d.ts"], ["es2020.symbol.wellknown", "lib.es2020.symbol.wellknown.d.ts"], ["es2020.intl", "lib.es2020.intl.d.ts"], + ["es2021.promise", "lib.es2021.promise.d.ts"], + ["es2021.string", "lib.es2021.string.d.ts"], + ["es2021.weakref", "lib.es2021.weakref.d.ts"], ["esnext.array", "lib.es2019.array.d.ts"], ["esnext.symbol", "lib.es2019.symbol.d.ts"], ["esnext.asynciterable", "lib.es2018.asynciterable.d.ts"], ["esnext.intl", "lib.esnext.intl.d.ts"], ["esnext.bigint", "lib.es2020.bigint.d.ts"], - ["esnext.string", "lib.esnext.string.d.ts"], - ["esnext.promise", "lib.esnext.promise.d.ts"], - ["esnext.weakref", "lib.esnext.weakref.d.ts"] + ["esnext.string", "lib.es2021.string.d.ts"], + ["esnext.promise", "lib.es2021.promise.d.ts"], + ["esnext.weakref", "lib.es2021.weakref.d.ts"] ]; /** * An array of supported "lib" reference file names used to determine the order for inclusion @@ -36089,11 +37404,12 @@ var ts; fixedpollinginterval: ts.WatchFileKind.FixedPollingInterval, prioritypollinginterval: ts.WatchFileKind.PriorityPollingInterval, dynamicprioritypolling: ts.WatchFileKind.DynamicPriorityPolling, + fixedchunksizepolling: ts.WatchFileKind.FixedChunkSizePolling, usefsevents: ts.WatchFileKind.UseFsEvents, usefseventsonparentdirectory: ts.WatchFileKind.UseFsEventsOnParentDirectory, })), - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_DynamicPriorityPolling_UseFsEvents_UseFsEventsOnParentDirectory, + category: ts.Diagnostics.Watch_and_Build_Modes, + description: ts.Diagnostics.Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_DynamicPriorityPolling_FixedChunkSizePolling_UseFsEvents_UseFsEventsOnParentDirectory, }, { name: "watchDirectory", @@ -36101,9 +37417,10 @@ var ts; usefsevents: ts.WatchDirectoryKind.UseFsEvents, fixedpollinginterval: ts.WatchDirectoryKind.FixedPollingInterval, dynamicprioritypolling: ts.WatchDirectoryKind.DynamicPriorityPolling, + fixedchunksizepolling: ts.WatchDirectoryKind.FixedChunkSizePolling, })), - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling, + category: ts.Diagnostics.Watch_and_Build_Modes, + description: ts.Diagnostics.Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling_FixedChunkSizePolling, }, { name: "fallbackPolling", @@ -36111,14 +37428,15 @@ var ts; fixedinterval: ts.PollingWatchKind.FixedInterval, priorityinterval: ts.PollingWatchKind.PriorityInterval, dynamicpriority: ts.PollingWatchKind.DynamicPriority, + fixedchunksize: ts.PollingWatchKind.FixedChunkSize, })), - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority, + category: ts.Diagnostics.Watch_and_Build_Modes, + description: ts.Diagnostics.Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority_FixedChunkSize, }, { name: "synchronousWatchDirectory", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Watch_and_Build_Modes, description: ts.Diagnostics.Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively, }, { @@ -36130,7 +37448,7 @@ var ts; isFilePath: true, extraValidation: specToDiagnostic }, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Watch_and_Build_Modes, description: ts.Diagnostics.Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively, }, { @@ -36142,7 +37460,7 @@ var ts; isFilePath: true, extraValidation: specToDiagnostic }, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Watch_and_Build_Modes, description: ts.Diagnostics.Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively, }, ]; @@ -36166,6 +37484,7 @@ var ts; shortName: "w", type: "boolean", showInSimplifiedHelpView: true, + isCommandLineOnly: true, category: ts.Diagnostics.Command_line_Options, description: ts.Diagnostics.Watch_input_files, }, @@ -36173,49 +37492,50 @@ var ts; name: "preserveWatchOutput", type: "boolean", showInSimplifiedHelpView: false, - category: ts.Diagnostics.Command_line_Options, + category: ts.Diagnostics.Output_Formatting, description: ts.Diagnostics.Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen, }, { name: "listFiles", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Print_names_of_files_part_of_the_compilation }, { name: "explainFiles", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Print_names_of_files_and_the_reason_they_are_part_of_the_compilation - }, { + }, + { name: "listEmittedFiles", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Print_names_of_generated_files_part_of_the_compilation }, { name: "pretty", type: "boolean", showInSimplifiedHelpView: true, - category: ts.Diagnostics.Command_line_Options, + category: ts.Diagnostics.Output_Formatting, description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental }, { name: "traceResolution", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Enable_tracing_of_the_name_resolution_process }, { name: "diagnostics", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Show_diagnostic_information }, { name: "extendedDiagnostics", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Show_verbose_diagnostic_information }, { @@ -36223,7 +37543,7 @@ var ts; type: "string", isFilePath: true, paramType: ts.Diagnostics.FILE_OR_DIRECTORY, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Generates_a_CPU_profile }, { @@ -36232,14 +37552,14 @@ var ts; isFilePath: true, isCommandLineOnly: true, paramType: ts.Diagnostics.DIRECTORY, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Generates_an_event_trace_and_a_list_of_types }, { name: "incremental", shortName: "i", type: "boolean", - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Projects, description: ts.Diagnostics.Enable_incremental_compilation, transpileOptionValue: undefined }, @@ -36248,13 +37568,14 @@ var ts; type: "boolean", affectsSemanticDiagnostics: true, affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Watch_and_Build_Modes, description: ts.Diagnostics.Have_recompiles_in_incremental_and_watch_assume_that_changes_within_a_file_will_only_affect_files_directly_depending_on_it }, { name: "locale", type: "string", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Command_line_Options, + isCommandLineOnly: true, description: ts.Diagnostics.The_locale_used_when_displaying_messages_to_the_user_e_g_en_us }, ]; @@ -36272,6 +37593,7 @@ var ts; es2018: 5 /* ES2018 */, es2019: 6 /* ES2019 */, es2020: 7 /* ES2020 */, + es2021: 8 /* ES2021 */, esnext: 99 /* ESNext */, })), affectsSourceFile: true, @@ -36279,11 +37601,11 @@ var ts; affectsEmit: true, paramType: ts.Diagnostics.VERSION, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_or_ESNEXT, + category: ts.Diagnostics.Language_and_Environment, + description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_ES2021_or_ESNEXT, }; - /* @internal */ - ts.optionDeclarations = __spreadArray(__spreadArray([], ts.commonOptionsWithBuild), [ + var commandOptionsWithoutBuild = [ + // CommandLine only options { name: "all", type: "boolean", @@ -36360,7 +37682,7 @@ var ts; affectsEmit: true, paramType: ts.Diagnostics.KIND, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_es2020_or_ESNext, }, { @@ -36370,9 +37692,9 @@ var ts; name: "lib", type: ts.libMap }, - affectsModuleResolution: true, + affectsProgramStructure: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation, transpileOptionValue: undefined }, @@ -36381,13 +37703,13 @@ var ts; type: "boolean", affectsModuleResolution: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.JavaScript_Support, description: ts.Diagnostics.Allow_javascript_files_to_be_compiled }, { name: "checkJs", type: "boolean", - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.JavaScript_Support, description: ts.Diagnostics.Report_errors_in_js_files }, { @@ -36398,7 +37720,7 @@ var ts; affectsModuleResolution: true, paramType: ts.Diagnostics.KIND, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_react_react_jsx_or_react_jsxdev, }, { @@ -36407,7 +37729,7 @@ var ts; type: "boolean", affectsEmit: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Generates_corresponding_d_ts_file, transpileOptionValue: undefined }, @@ -36416,7 +37738,7 @@ var ts; type: "boolean", affectsEmit: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Generates_a_sourcemap_for_each_corresponding_d_ts_file, transpileOptionValue: undefined }, @@ -36424,7 +37746,7 @@ var ts; name: "emitDeclarationOnly", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Only_emit_d_ts_declaration_files, transpileOptionValue: undefined }, @@ -36433,7 +37755,7 @@ var ts; type: "boolean", affectsEmit: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Generates_corresponding_map_file, }, { @@ -36443,7 +37765,7 @@ var ts; isFilePath: true, paramType: ts.Diagnostics.FILE, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, transpileOptionValue: undefined }, @@ -36454,7 +37776,7 @@ var ts; isFilePath: true, paramType: ts.Diagnostics.DIRECTORY, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Redirect_output_structure_to_the_directory, }, { @@ -36463,7 +37785,7 @@ var ts; affectsEmit: true, isFilePath: true, paramType: ts.Diagnostics.LOCATION, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, }, { @@ -36471,7 +37793,7 @@ var ts; type: "boolean", affectsEmit: true, isTSConfigOnly: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Projects, description: ts.Diagnostics.Enable_project_compilation, transpileOptionValue: undefined }, @@ -36481,7 +37803,7 @@ var ts; affectsEmit: true, isFilePath: true, paramType: ts.Diagnostics.FILE, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Projects, description: ts.Diagnostics.Specify_file_to_store_incremental_compilation_information, transpileOptionValue: undefined }, @@ -36490,14 +37812,14 @@ var ts; type: "boolean", affectsEmit: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Do_not_emit_comments_to_output, }, { name: "noEmit", type: "boolean", showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Do_not_emit_outputs, transpileOptionValue: undefined }, @@ -36505,7 +37827,7 @@ var ts; name: "importHelpers", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Import_emit_helpers_from_tslib }, { @@ -36517,20 +37839,20 @@ var ts; })), affectsEmit: true, affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types }, { name: "downlevelIteration", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3 }, { name: "isolatedModules", type: "boolean", - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Interop_Constraints, description: ts.Diagnostics.Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule, transpileOptionValue: true }, @@ -36539,7 +37861,7 @@ var ts; name: "strict", type: "boolean", showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Enable_all_strict_type_checking_options }, { @@ -36548,7 +37870,7 @@ var ts; affectsSemanticDiagnostics: true, strictFlag: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type }, { @@ -36557,7 +37879,7 @@ var ts; affectsSemanticDiagnostics: true, strictFlag: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Enable_strict_null_checks }, { @@ -36566,7 +37888,7 @@ var ts; affectsSemanticDiagnostics: true, strictFlag: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Enable_strict_checking_of_function_types }, { @@ -36574,7 +37896,7 @@ var ts; type: "boolean", strictFlag: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Enable_strict_bind_call_and_apply_methods_on_functions }, { @@ -36583,25 +37905,43 @@ var ts; affectsSemanticDiagnostics: true, strictFlag: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Enable_strict_checking_of_property_initialization_in_classes }, + { + name: "strictOptionalProperties", + type: "boolean", + affectsSemanticDiagnostics: true, + strictFlag: true, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Type_Checking, + description: ts.Diagnostics.Enable_strict_checking_of_optional_properties + }, { name: "noImplicitThis", type: "boolean", affectsSemanticDiagnostics: true, strictFlag: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, }, + { + name: "useUnknownInCatchVariables", + type: "boolean", + affectsSemanticDiagnostics: true, + strictFlag: true, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Type_Checking, + description: ts.Diagnostics.Type_catch_clause_variables_as_unknown_instead_of_any, + }, { name: "alwaysStrict", type: "boolean", affectsSourceFile: true, strictFlag: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file }, // Additional Checks @@ -36610,7 +37950,7 @@ var ts; type: "boolean", affectsSemanticDiagnostics: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Additional_Checks, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Report_errors_on_unused_locals, }, { @@ -36618,7 +37958,7 @@ var ts; type: "boolean", affectsSemanticDiagnostics: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Additional_Checks, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Report_errors_on_unused_parameters, }, { @@ -36626,7 +37966,7 @@ var ts; type: "boolean", affectsSemanticDiagnostics: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Additional_Checks, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value }, { @@ -36635,7 +37975,7 @@ var ts; affectsBindDiagnostics: true, affectsSemanticDiagnostics: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Additional_Checks, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement }, { @@ -36643,14 +37983,22 @@ var ts; type: "boolean", affectsSemanticDiagnostics: true, showInSimplifiedHelpView: false, - category: ts.Diagnostics.Additional_Checks, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Include_undefined_in_index_signature_results }, + { + name: "noImplicitOverride", + type: "boolean", + affectsSemanticDiagnostics: true, + showInSimplifiedHelpView: false, + category: ts.Diagnostics.Type_Checking, + description: ts.Diagnostics.Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier + }, { name: "noPropertyAccessFromIndexSignature", type: "boolean", showInSimplifiedHelpView: false, - category: ts.Diagnostics.Additional_Checks, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Require_undeclared_properties_from_index_signatures_to_use_element_accesses }, // Module Resolution @@ -36662,7 +38010,7 @@ var ts; })), affectsModuleResolution: true, paramType: ts.Diagnostics.STRATEGY, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, }, { @@ -36670,7 +38018,7 @@ var ts; type: "string", affectsModuleResolution: true, isFilePath: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Base_directory_to_resolve_non_absolute_module_names }, { @@ -36680,7 +38028,7 @@ var ts; type: "object", affectsModuleResolution: true, isTSConfigOnly: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl, transpileOptionValue: undefined }, @@ -36696,7 +38044,7 @@ var ts; isFilePath: true }, affectsModuleResolution: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime, transpileOptionValue: undefined }, @@ -36709,7 +38057,7 @@ var ts; isFilePath: true }, affectsModuleResolution: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.List_of_folders_to_include_type_definitions_from }, { @@ -36719,9 +38067,9 @@ var ts; name: "types", type: "string" }, - affectsModuleResolution: true, + affectsProgramStructure: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation, transpileOptionValue: undefined }, @@ -36729,7 +38077,7 @@ var ts; name: "allowSyntheticDefaultImports", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Interop_Constraints, description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking }, { @@ -36738,20 +38086,20 @@ var ts; affectsSemanticDiagnostics: true, affectsEmit: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Interop_Constraints, description: ts.Diagnostics.Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for_all_imports_Implies_allowSyntheticDefaultImports }, { name: "preserveSymlinks", type: "boolean", - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Interop_Constraints, description: ts.Diagnostics.Do_not_resolve_the_real_path_of_symlinks, }, { name: "allowUmdGlobalAccess", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Allow_accessing_UMD_globals_from_modules, }, // Source Maps @@ -36760,7 +38108,7 @@ var ts; type: "string", affectsEmit: true, paramType: ts.Diagnostics.LOCATION, - category: ts.Diagnostics.Source_Map_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, }, { @@ -36768,21 +38116,21 @@ var ts; type: "string", affectsEmit: true, paramType: ts.Diagnostics.LOCATION, - category: ts.Diagnostics.Source_Map_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, }, { name: "inlineSourceMap", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Source_Map_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file }, { name: "inlineSources", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Source_Map_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap_to_be_set }, // Experimental @@ -36790,7 +38138,7 @@ var ts; name: "experimentalDecorators", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Experimental_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators }, { @@ -36798,20 +38146,20 @@ var ts; type: "boolean", affectsSemanticDiagnostics: true, affectsEmit: true, - category: ts.Diagnostics.Experimental_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators }, // Advanced { name: "jsxFactory", type: "string", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h }, { name: "jsxFragmentFactory", type: "string", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Specify_the_JSX_fragment_factory_function_to_use_when_targeting_react_JSX_emit_with_jsxFactory_compiler_option_is_specified_e_g_Fragment }, { @@ -36820,14 +38168,14 @@ var ts; affectsSemanticDiagnostics: true, affectsEmit: true, affectsModuleResolution: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react }, { name: "resolveJsonModule", type: "boolean", affectsModuleResolution: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Include_modules_imported_with_json_extension }, { @@ -36836,7 +38184,7 @@ var ts; affectsEmit: true, isFilePath: false, // for correct behaviour, please use outFile - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Backwards_Compatibility, paramType: ts.Diagnostics.FILE, description: ts.Diagnostics.Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file, transpileOptionValue: undefined @@ -36845,26 +38193,26 @@ var ts; name: "reactNamespace", type: "string", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react_JSX_emit }, { name: "skipDefaultLibCheck", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Completeness, description: ts.Diagnostics.Deprecated_Use_skipLibCheck_instead_Skip_type_checking_of_default_library_declaration_files }, { name: "charset", type: "string", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Backwards_Compatibility, description: ts.Diagnostics.The_character_set_of_the_input_files }, { name: "emitBOM", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files }, { @@ -36875,21 +38223,21 @@ var ts; })), affectsEmit: true, paramType: ts.Diagnostics.NEWLINE, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, }, { name: "noErrorTruncation", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Output_Formatting, description: ts.Diagnostics.Do_not_truncate_error_messages }, { name: "noLib", type: "boolean", - affectsModuleResolution: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Language_and_Environment, + affectsProgramStructure: true, description: ts.Diagnostics.Do_not_include_the_default_library_file_lib_d_ts, // We are not returning a sourceFile for lib file when asked by the program, // so pass --noLib to avoid reporting a file not found error. @@ -36899,7 +38247,7 @@ var ts; name: "noResolve", type: "boolean", affectsModuleResolution: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files, // We are not doing a full typecheck, we are not resolving the whole context, // so pass --noResolve to avoid reporting missing file errors. @@ -36909,56 +38257,56 @@ var ts; name: "stripInternal", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation, }, { name: "disableSizeLimit", type: "boolean", - affectsSourceFile: true, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Disable_size_limitations_on_JavaScript_projects + affectsProgramStructure: true, + category: ts.Diagnostics.Editor_Support, + description: ts.Diagnostics.JavaScript_Support }, { name: "disableSourceOfProjectReferenceRedirect", type: "boolean", isTSConfigOnly: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Projects, description: ts.Diagnostics.Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects }, { name: "disableSolutionSearching", type: "boolean", isTSConfigOnly: true, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Disable_solution_searching_for_this_project + category: ts.Diagnostics.Projects, + description: ts.Diagnostics.Projects }, { name: "disableReferencedProjectLoad", type: "boolean", isTSConfigOnly: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Projects, description: ts.Diagnostics.Disable_loading_referenced_projects }, { name: "noImplicitUseStrict", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Backwards_Compatibility, description: ts.Diagnostics.Do_not_emit_use_strict_directives_in_module_output }, { name: "noEmitHelpers", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Do_not_generate_custom_helper_functions_like_extends_in_compiled_output }, { name: "noEmitOnError", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, transpileOptionValue: undefined }, @@ -36966,7 +38314,7 @@ var ts; name: "preserveConstEnums", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code }, { @@ -36975,14 +38323,14 @@ var ts; affectsEmit: true, isFilePath: true, paramType: ts.Diagnostics.DIRECTORY, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Output_directory_for_generated_declaration_files, transpileOptionValue: undefined }, { name: "skipLibCheck", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Completeness, description: ts.Diagnostics.Skip_type_checking_of_declaration_files, }, { @@ -36990,7 +38338,7 @@ var ts; type: "boolean", affectsBindDiagnostics: true, affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Do_not_report_errors_on_unused_labels }, { @@ -36998,42 +38346,42 @@ var ts; type: "boolean", affectsBindDiagnostics: true, affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Do_not_report_errors_on_unreachable_code }, { name: "suppressExcessPropertyErrors", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Backwards_Compatibility, description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals, }, { name: "suppressImplicitAnyIndexErrors", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Backwards_Compatibility, description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, }, { name: "forceConsistentCasingInFileNames", type: "boolean", affectsModuleResolution: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Interop_Constraints, description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file }, { name: "maxNodeModuleJsDepth", type: "number", affectsModuleResolution: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.JavaScript_Support, description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files }, { name: "noStrictGenericChecks", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Backwards_Compatibility, description: ts.Diagnostics.Disable_strict_checking_of_generic_signatures_in_function_types, }, { @@ -37041,13 +38389,13 @@ var ts; type: "boolean", affectsSemanticDiagnostics: true, affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Emit_class_fields_with_Define_instead_of_Set, }, { name: "keyofStringsOnly", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Backwards_Compatibility, description: ts.Diagnostics.Resolve_keyof_to_string_valued_property_names_only_no_numbers_or_symbols, }, { @@ -37059,9 +38407,12 @@ var ts; name: "plugin", type: "object" }, - description: ts.Diagnostics.List_of_language_service_plugins + description: ts.Diagnostics.List_of_language_service_plugins, + category: ts.Diagnostics.Editor_Support, }, - ]); + ]; + /* @internal */ + ts.optionDeclarations = __spreadArray(__spreadArray([], ts.commonOptionsWithBuild), commandOptionsWithoutBuild); /* @internal */ ts.semanticDiagnosticsOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsSemanticDiagnostics; }); /* @internal */ @@ -37073,11 +38424,12 @@ var ts; return !!option.affectsSourceFile || !!option.affectsModuleResolution || !!option.affectsBindDiagnostics; }); /* @internal */ + ts.optionsAffectingProgramStructure = ts.optionDeclarations.filter(function (option) { return !!option.affectsProgramStructure; }); + /* @internal */ ts.transpileOptionValueCompilerOptions = ts.optionDeclarations.filter(function (option) { return ts.hasProperty(option, "transpileOptionValue"); }); - /* @internal */ - ts.buildOpts = __spreadArray(__spreadArray([], ts.commonOptionsWithBuild), [ + var commandOptionsOnlyBuild = [ { name: "verbose", shortName: "v", @@ -37105,7 +38457,9 @@ var ts; description: ts.Diagnostics.Delete_the_outputs_of_all_projects, type: "boolean" } - ]); + ]; + /* @internal */ + ts.buildOpts = __spreadArray(__spreadArray([], ts.commonOptionsWithBuild), commandOptionsOnlyBuild); /* @internal */ ts.typeAcquisitionDeclarations = [ { @@ -37159,6 +38513,10 @@ var ts; return optionsNameMapCache || (optionsNameMapCache = createOptionNameMap(ts.optionDeclarations)); } ts.getOptionsNameMap = getOptionsNameMap; + var compilerOptionsAlternateMode = { + diagnostic: ts.Diagnostics.Compiler_option_0_may_only_be_used_with_build, + getOptionsNameMap: getBuildOptionsNameMap + }; /* @internal */ ts.defaultInitCompilerOptions = { module: ts.ModuleKind.CommonJS, @@ -37192,13 +38550,13 @@ var ts; } /* @internal */ function parseCustomTypeOption(opt, value, errors) { - return convertJsonOptionOfCustomType(opt, trimString(value || ""), errors); + return convertJsonOptionOfCustomType(opt, ts.trimString(value || ""), errors); } ts.parseCustomTypeOption = parseCustomTypeOption; /* @internal */ function parseListTypeOption(opt, value, errors) { if (value === void 0) { value = ""; } - value = trimString(value); + value = ts.trimString(value); if (ts.startsWith(value, "-")) { return undefined; } @@ -37220,6 +38578,10 @@ var ts; return option.name; } function createUnknownOptionError(unknownOption, diagnostics, createDiagnostics, unknownOptionErrorText) { + var _a; + if ((_a = diagnostics.alternateMode) === null || _a === void 0 ? void 0 : _a.getOptionsNameMap().optionsNameMap.has(unknownOption.toLowerCase())) { + return createDiagnostics(diagnostics.alternateMode.diagnostic, unknownOption); + } var possibleOption = ts.getSpellingSuggestion(unknownOption, diagnostics.optionDeclarations, getOptionName); return possibleOption ? createDiagnostics(diagnostics.unknownDidYouMeanDiagnostic, unknownOptionErrorText || unknownOption, possibleOption.name) : @@ -37374,6 +38736,7 @@ var ts; } /*@internal*/ ts.compilerOptionsDidYouMeanDiagnostics = { + alternateMode: compilerOptionsAlternateMode, getOptionsNameMap: getOptionsNameMap, optionDeclarations: ts.optionDeclarations, unknownOptionDiagnostic: ts.Diagnostics.Unknown_compiler_option_0, @@ -37406,7 +38769,12 @@ var ts; function getBuildOptionsNameMap() { return buildOptionsNameMapCache || (buildOptionsNameMapCache = createOptionNameMap(ts.buildOpts)); } + var buildOptionsAlternateMode = { + diagnostic: ts.Diagnostics.Compiler_option_0_may_not_be_used_with_build, + getOptionsNameMap: getOptionsNameMap + }; var buildOptionsDidYouMeanDiagnostics = { + alternateMode: buildOptionsAlternateMode, getOptionsNameMap: getBuildOptionsNameMap, optionDeclarations: ts.buildOpts, unknownOptionDiagnostic: ts.Diagnostics.Unknown_build_option_0, @@ -37482,7 +38850,7 @@ var ts; function parseConfigFileTextToJson(fileName, jsonText) { var jsonSourceFile = ts.parseJsonText(fileName, jsonText); return { - config: convertToObject(jsonSourceFile, jsonSourceFile.parseDiagnostics), + config: convertConfigFileToObject(jsonSourceFile, jsonSourceFile.parseDiagnostics, /*reportOptionsErrors*/ false, /*optionsIterator*/ undefined), error: jsonSourceFile.parseDiagnostics.length ? jsonSourceFile.parseDiagnostics[0] : undefined }; } @@ -37572,7 +38940,8 @@ var ts; }, { name: "extends", - type: "string" + type: "string", + category: ts.Diagnostics.File_Management, }, { name: "references", @@ -37580,7 +38949,8 @@ var ts; element: { name: "references", type: "object" - } + }, + category: ts.Diagnostics.Projects, }, { name: "files", @@ -37588,7 +38958,8 @@ var ts; element: { name: "files", type: "string" - } + }, + category: ts.Diagnostics.File_Management, }, { name: "include", @@ -37596,7 +38967,8 @@ var ts; element: { name: "include", type: "string" - } + }, + category: ts.Diagnostics.File_Management, }, { name: "exclude", @@ -37604,7 +38976,8 @@ var ts; element: { name: "exclude", type: "string" - } + }, + category: ts.Diagnostics.File_Management, }, ts.compileOnSaveCommandLineOption ]) @@ -37612,11 +38985,31 @@ var ts; } return _tsconfigRootOptions; } + function convertConfigFileToObject(sourceFile, errors, reportOptionsErrors, optionsIterator) { + 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 !== 202 /* 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 + // array is a well-formed configuration object, made into an array element by stray characters. + if (ts.isArrayLiteralExpression(rootExpression)) { + var firstObject = ts.find(rootExpression.elements, ts.isObjectLiteralExpression); + if (firstObject) { + return convertToObjectWorker(sourceFile, firstObject, errors, /*returnValue*/ true, knownRootOptions, optionsIterator); + } + } + return {}; + } + return convertToObjectWorker(sourceFile, rootExpression, errors, /*returnValue*/ true, knownRootOptions, optionsIterator); + } /** * Convert the json syntax tree into the json value */ function convertToObject(sourceFile, errors) { - return convertToObjectWorker(sourceFile, errors, /*returnValue*/ true, /*knownRootOptions*/ undefined, /*jsonConversionNotifier*/ undefined); + var _a; + return convertToObjectWorker(sourceFile, (_a = sourceFile.statements[0]) === null || _a === void 0 ? void 0 : _a.expression, errors, /*returnValue*/ true, /*knownRootOptions*/ undefined, /*jsonConversionNotifier*/ undefined); } ts.convertToObject = convertToObject; /** @@ -37625,18 +39018,18 @@ var ts; * Otherwise it just checks the errors and returns undefined */ /*@internal*/ - function convertToObjectWorker(sourceFile, errors, returnValue, knownRootOptions, jsonConversionNotifier) { - if (!sourceFile.statements.length) { + function convertToObjectWorker(sourceFile, rootExpression, errors, returnValue, knownRootOptions, jsonConversionNotifier) { + if (!rootExpression) { return returnValue ? {} : undefined; } - return convertPropertyValueToJson(sourceFile.statements[0].expression, knownRootOptions); + return convertPropertyValueToJson(rootExpression, knownRootOptions); function isRootOptionMap(knownOptions) { return knownRootOptions && knownRootOptions.elementOptions === knownOptions; } function convertObjectLiteralExpressionToJson(node, knownOptions, extraKeyDiagnostics, parentOption) { var result = returnValue ? {} : undefined; var _loop_4 = function (element) { - if (element.kind !== 288 /* PropertyAssignment */) { + if (element.kind !== 290 /* PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); return "continue"; } @@ -37703,13 +39096,13 @@ var ts; function convertPropertyValueToJson(valueExpression, option) { var invalidReported; switch (valueExpression.kind) { - case 109 /* TrueKeyword */: + case 110 /* TrueKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return validateValue(/*value*/ true); - case 94 /* FalseKeyword */: + case 95 /* FalseKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return validateValue(/*value*/ false); - case 103 /* NullKeyword */: + case 104 /* 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 */: @@ -37730,13 +39123,13 @@ var ts; case 8 /* NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return validateValue(Number(valueExpression.text)); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: if (valueExpression.operator !== 40 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { break; // not valid JSON syntax } reportInvalidOptionValue(option && option.type !== "number"); return validateValue(-Number(valueExpression.operand.text)); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -37753,7 +39146,7 @@ var ts; return validateValue(convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined)); } - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return validateValue(convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element)); } @@ -37891,7 +39284,7 @@ var ts; if (ts.hasProperty(options, name)) { // tsconfig only options cannot be specified via command line, // so we can assume that only types that can appear here string | number | boolean - if (optionsNameMap.has(name) && optionsNameMap.get(name).category === ts.Diagnostics.Command_line_Options) { + if (optionsNameMap.has(name) && (optionsNameMap.get(name).category === ts.Diagnostics.Command_line_Options || optionsNameMap.get(name).category === ts.Diagnostics.Output_Formatting)) { return "continue"; } var value = options[name]; @@ -37957,13 +39350,11 @@ var ts; function makePadding(paddingLength) { return Array(paddingLength + 1).join(" "); } - function isAllowedOption(_a) { - var category = _a.category, name = _a.name; - // Skip options which do not have a category or have category `Command_line_Options` - // Exclude all possible `Advanced_Options` in tsconfig.json which were NOT defined in command line - return category !== undefined - && category !== ts.Diagnostics.Command_line_Options - && (category !== ts.Diagnostics.Advanced_Options || compilerOptionsMap.has(name)); + function isAllowedOptionForOutput(_a) { + var category = _a.category, name = _a.name, isCommandLineOnly = _a.isCommandLineOnly; + // Skip options which do not have a category or have categories which are more niche + var categoriesToSkip = [ts.Diagnostics.Command_line_Options, ts.Diagnostics.Editor_Support, ts.Diagnostics.Compiler_Diagnostics, ts.Diagnostics.Backwards_Compatibility, ts.Diagnostics.Watch_and_Build_Modes, ts.Diagnostics.Output_Formatting]; + return !isCommandLineOnly && category !== undefined && (!categoriesToSkip.includes(category) || compilerOptionsMap.has(name)); } function writeConfigurations() { // Filter applicable options to place in the file @@ -37971,7 +39362,7 @@ var ts; for (var _i = 0, optionDeclarations_1 = ts.optionDeclarations; _i < optionDeclarations_1.length; _i++) { var option = optionDeclarations_1[_i]; var category = option.category; - if (isAllowedOption(option)) { + if (isAllowedOptionForOutput(option)) { categorizedOptions.add(ts.getLocaleSpecificMessage(category), option); } } @@ -38188,6 +39579,7 @@ var ts; validatedFilesSpec: ts.filter(filesSpecs, ts.isString), validatedIncludeSpecs: validatedIncludeSpecs, validatedExcludeSpecs: validatedExcludeSpecs, + pathPatterns: undefined, // Initialized on first use }; } function getFileNames(basePath) { @@ -38301,14 +39693,14 @@ var ts; if (ownConfig.extendedConfigPath) { // copy the resolution stack so it is never reused between branches in potential diamond-problem scenarios. resolutionStack = resolutionStack.concat([resolvedPath]); - var extendedConfig = getExtendedConfig(sourceFile, ownConfig.extendedConfigPath, host, basePath, resolutionStack, errors, extendedConfigCache); + var extendedConfig = getExtendedConfig(sourceFile, ownConfig.extendedConfigPath, host, resolutionStack, errors, extendedConfigCache); if (extendedConfig && isSuccessfulParsedTsconfig(extendedConfig)) { var baseRaw_1 = extendedConfig.raw; var raw_1 = ownConfig.raw; + var relativeDifference_1; var setPropertyInRawIfNotUndefined = function (propertyName) { - var value = raw_1[propertyName] || baseRaw_1[propertyName]; - if (value) { - raw_1[propertyName] = value; + if (!raw_1[propertyName] && baseRaw_1[propertyName]) { + raw_1[propertyName] = ts.map(baseRaw_1[propertyName], function (path) { return ts.isRootedDiskPath(path) ? path : ts.combinePaths(relativeDifference_1 || (relativeDifference_1 = ts.convertToRelativePath(ts.getDirectoryPath(ownConfig.extendedConfigPath), basePath, ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames))), path); }); } }; setPropertyInRawIfNotUndefined("include"); @@ -38390,7 +39782,7 @@ var ts; } } }; - var json = convertToObjectWorker(sourceFile, errors, /*returnValue*/ true, getTsconfigRootOptionsMap(), optionsIterator); + var json = convertConfigFileToObject(sourceFile, errors, /*reportOptionsErrors*/ true, optionsIterator); if (!typeAcquisition) { if (typingOptionstypeAcquisition) { typeAcquisition = (typingOptionstypeAcquisition.enableAutoDiscovery !== undefined) ? @@ -38428,7 +39820,7 @@ var ts; errors.push(createDiagnostic(ts.Diagnostics.File_0_not_found, extendedConfig)); return undefined; } - function getExtendedConfig(sourceFile, extendedConfigPath, host, basePath, resolutionStack, errors, extendedConfigCache) { + function getExtendedConfig(sourceFile, extendedConfigPath, host, resolutionStack, errors, extendedConfigCache) { var _a; var path = host.useCaseSensitiveFileNames ? extendedConfigPath : ts.toFileNameLowerCase(extendedConfigPath); var value; @@ -38440,22 +39832,7 @@ var ts; else { extendedResult = readJsonConfigFile(extendedConfigPath, function (path) { return host.readFile(path); }); if (!extendedResult.parseDiagnostics.length) { - var extendedDirname = ts.getDirectoryPath(extendedConfigPath); - extendedConfig = parseConfig(/*json*/ undefined, extendedResult, host, extendedDirname, ts.getBaseFileName(extendedConfigPath), resolutionStack, errors, extendedConfigCache); - if (isSuccessfulParsedTsconfig(extendedConfig)) { - // Update the paths to reflect base path - var relativeDifference_1 = ts.convertToRelativePath(extendedDirname, basePath, ts.identity); - var updatePath_1 = function (path) { return ts.isRootedDiskPath(path) ? path : ts.combinePaths(relativeDifference_1, path); }; - var mapPropertiesInRawIfNotUndefined = function (propertyName) { - if (raw_2[propertyName]) { - raw_2[propertyName] = ts.map(raw_2[propertyName], updatePath_1); - } - }; - var raw_2 = extendedConfig.raw; - mapPropertiesInRawIfNotUndefined("include"); - mapPropertiesInRawIfNotUndefined("exclude"); - mapPropertiesInRawIfNotUndefined("files"); - } + extendedConfig = parseConfig(/*json*/ undefined, extendedResult, host, ts.getDirectoryPath(extendedConfigPath), ts.getBaseFileName(extendedConfigPath), resolutionStack, errors, extendedConfigCache); } if (extendedConfigCache) { extendedConfigCache.set(path, { extendedResult: extendedResult, extendedConfig: extendedConfig }); @@ -38600,9 +39977,6 @@ var ts; function convertJsonOptionOfListType(option, values, basePath, errors) { return ts.filter(ts.map(values, function (v) { return convertJsonOption(option.element, v, basePath, errors); }), function (v) { return !!v; }); } - function trimString(s) { - return typeof s.trim === "function" ? s.trim() : s.replace(/^[\s]+|[\s]+$/g, ""); - } /** * Tests for a path that ends in a recursive directory wildcard. * Matches **, \**, **\, and \**\, but not a**b. @@ -38615,34 +39989,6 @@ var ts; * \/?$ # matches an optional trailing directory separator at the end of the string. */ var invalidTrailingRecursionPattern = /(^|\/)\*\*\/?$/; - /** - * Tests for a path where .. appears after a recursive directory wildcard. - * Matches **\..\*, **\a\..\*, and **\.., but not ..\**\* - * - * NOTE: used \ in place of / above to avoid issues with multiline comments. - * - * Breakdown: - * (^|\/) # matches either the beginning of the string or a directory separator. - * \*\*\/ # matches a recursive directory wildcard "**" followed by a directory separator. - * (.*\/)? # optionally matches any number of characters followed by a directory separator. - * \.\. # matches a parent directory path component ".." - * ($|\/) # matches either the end of the string or a directory separator. - */ - var invalidDotDotAfterRecursiveWildcardPattern = /(^|\/)\*\*\/(.*\/)?\.\.($|\/)/; - /** - * Tests for a path containing a wildcard character in a directory component of the path. - * Matches \*\, \?\, and \a*b\, but not \a\ or \a\*. - * - * NOTE: used \ in place of / above to avoid issues with multiline comments. - * - * Breakdown: - * \/ # matches a directory separator. - * [^/]*? # matches any number of characters excluding directory separators (non-greedy). - * [*?] # matches either a wildcard character (* or ?) - * [^/]* # matches any number of characters excluding directory separators (greedy). - * \/ # matches a directory separator. - */ - var watchRecursivePattern = /\/[^/]*?[*?][^/]*\//; /** * Matches the portion of a wildcard path that does not contain wildcards. * Matches \a of \a\*, or \a\b\c of \a\b\c\?\d. @@ -38683,7 +40029,7 @@ var ts; // via wildcard of *.json kind var wildCardJsonFileMap = new ts.Map(); var validatedFilesSpec = configFileSpecs.validatedFilesSpec, validatedIncludeSpecs = configFileSpecs.validatedIncludeSpecs, validatedExcludeSpecs = configFileSpecs.validatedExcludeSpecs; - // Rather than requery this for each file and filespec, we query the supported extensions + // Rather than re-query this for each file and filespec, we query the supported extensions // once and store it on the expansion context. var supportedExtensions = ts.getSupportedExtensions(options, extraFileExtensions); var supportedExtensionsWithJsonIfResolveJsonModule = ts.getSuppoertedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions); @@ -38761,9 +40107,22 @@ var ts; return matchesExcludeWorker(pathToCheck, validatedExcludeSpecs, useCaseSensitiveFileNames, currentDirectory, basePath); } ts.isExcludedFile = isExcludedFile; + function invalidDotDotAfterRecursiveWildcard(s) { + // We used to use the regex /(^|\/)\*\*\/(.*\/)?\.\.($|\/)/ to check for this case, but + // in v8, that has polynomial performance because the recursive wildcard match - **/ - + // can be matched in many arbitrary positions when multiple are present, resulting + // in bad backtracking (and we don't care which is matched - just that some /.. segment + // comes after some **/ segment). + var wildcardIndex = ts.startsWith(s, "**/") ? 0 : s.indexOf("/**/"); + if (wildcardIndex === -1) { + return false; + } + var lastDotIndex = ts.endsWith(s, "/..") ? s.length : s.lastIndexOf("/../"); + return lastDotIndex > wildcardIndex; + } /* @internal */ function matchesExclude(pathToCheck, excludeSpecs, useCaseSensitiveFileNames, currentDirectory) { - return matchesExcludeWorker(pathToCheck, ts.filter(excludeSpecs, function (spec) { return !invalidDotDotAfterRecursiveWildcardPattern.test(spec); }), useCaseSensitiveFileNames, currentDirectory); + return matchesExcludeWorker(pathToCheck, ts.filter(excludeSpecs, function (spec) { return !invalidDotDotAfterRecursiveWildcard(spec); }), useCaseSensitiveFileNames, currentDirectory); } ts.matchesExclude = matchesExclude; function matchesExcludeWorker(pathToCheck, excludeSpecs, useCaseSensitiveFileNames, currentDirectory, basePath) { @@ -38796,7 +40155,7 @@ var ts; if (disallowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) { return [ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec]; } - else if (invalidDotDotAfterRecursiveWildcardPattern.test(spec)) { + else if (invalidDotDotAfterRecursiveWildcard(spec)) { return [ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec]; } } @@ -38857,9 +40216,18 @@ var ts; function getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames) { var match = wildcardDirectoryPattern.exec(spec); if (match) { + // We check this with a few `indexOf` calls because 3 `indexOf`/`lastIndexOf` calls is + // less algorithmically complex (roughly O(3n) worst-case) than the regex we used to use, + // \/[^/]*?[*?][^/]*\/ which was polynominal in v8, since arbitrary sequences of wildcard + // characters could match any of the central patterns, resulting in bad backtracking. + var questionWildcardIndex = spec.indexOf("?"); + var starWildcardIndex = spec.indexOf("*"); + var lastDirectorySeperatorIndex = spec.lastIndexOf(ts.directorySeparator); return { key: useCaseSensitiveFileNames ? match[0] : ts.toFileNameLowerCase(match[0]), - flags: watchRecursivePattern.test(spec) ? 1 /* Recursive */ : 0 /* None */ + flags: (questionWildcardIndex !== -1 && questionWildcardIndex < lastDirectorySeperatorIndex) + || (starWildcardIndex !== -1 && starWildcardIndex < lastDirectorySeperatorIndex) + ? 1 /* Recursive */ : 0 /* None */ }; } if (ts.isImplicitGlob(spec)) { @@ -39152,13 +40520,24 @@ var ts; * This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups * is assumed to be the same as root directory of the project. */ - function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference) { + function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, cache) { var traceEnabled = isTraceEnabled(options, host); if (redirectedReference) { options = redirectedReference.commandLine.options; } - var failedLookupLocations = []; - var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations }; + var containingDirectory = containingFile ? ts.getDirectoryPath(containingFile) : undefined; + var perFolderCache = containingDirectory ? cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference) : undefined; + var result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName); + if (result) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1, typeReferenceDirectiveName, containingFile); + if (redirectedReference) + trace(host, ts.Diagnostics.Using_compiler_options_of_project_reference_redirect_0, redirectedReference.sourceFile.fileName); + trace(host, ts.Diagnostics.Resolution_for_type_reference_directive_0_was_found_in_cache_from_location_1, typeReferenceDirectiveName, containingDirectory); + traceResult(result); + } + return result; + } var typeRoots = getEffectiveTypeRoots(options, host); if (traceEnabled) { if (containingFile === undefined) { @@ -39181,6 +40560,8 @@ var ts; trace(host, ts.Diagnostics.Using_compiler_options_of_project_reference_redirect_0, redirectedReference.sourceFile.fileName); } } + var failedLookupLocations = []; + var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache }; var resolved = primaryLookup(); var primary = true; if (!resolved) { @@ -39191,17 +40572,31 @@ var ts; if (resolved) { var fileName = resolved.fileName, packageId = resolved.packageId; var resolvedFileName = options.preserveSymlinks ? fileName : realPath(fileName, host, traceEnabled); - if (traceEnabled) { - if (packageId) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3, typeReferenceDirectiveName, resolvedFileName, ts.packageIdToString(packageId), primary); - } - else { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFileName, primary); - } + resolvedTypeReferenceDirective = { + primary: primary, + resolvedFileName: resolvedFileName, + originalPath: fileName === resolvedFileName ? undefined : fileName, + packageId: packageId, + isExternalLibraryImport: pathContainsNodeModules(fileName), + }; + } + result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations }; + perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, result); + if (traceEnabled) + traceResult(result); + return result; + function traceResult(result) { + var _a; + if (!((_a = result.resolvedTypeReferenceDirective) === null || _a === void 0 ? void 0 : _a.resolvedFileName)) { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); + } + else if (result.resolvedTypeReferenceDirective.packageId) { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3, typeReferenceDirectiveName, result.resolvedTypeReferenceDirective.resolvedFileName, ts.packageIdToString(result.resolvedTypeReferenceDirective.packageId), result.resolvedTypeReferenceDirective.primary); + } + else { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, result.resolvedTypeReferenceDirective.resolvedFileName, result.resolvedTypeReferenceDirective.primary); } - resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolvedFileName, packageId: packageId, isExternalLibraryImport: pathContainsNodeModules(fileName) }; } - return { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations }; function primaryLookup() { // Check primary library paths if (typeRoots && typeRoots.length) { @@ -39231,20 +40626,16 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); } - var result = void 0; + var result_4; if (!ts.isExternalModuleNameRelative(typeReferenceDirectiveName)) { var searchResult = loadModuleFromNearestNodeModulesDirectory(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, moduleResolutionState, /*cache*/ undefined, /*redirectedReference*/ undefined); - result = searchResult && searchResult.value; + result_4 = searchResult && searchResult.value; } else { var candidate = ts.normalizePathAndParts(ts.combinePaths(initialLocationForSecondaryLookup, typeReferenceDirectiveName)).path; - result = nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, /*onlyRecordFailures*/ false, moduleResolutionState, /*considerPackageJson*/ true); - } - var resolvedFile = resolvedTypeScriptOnly(result); - if (!resolvedFile && traceEnabled) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); + result_4 = nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, /*onlyRecordFailures*/ false, moduleResolutionState, /*considerPackageJson*/ true); } - return resolvedFile; + return resolvedTypeScriptOnly(result_4); } else { if (traceEnabled) { @@ -39299,22 +40690,21 @@ var ts; return result; } ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; - function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options) { - return createModuleResolutionCacheWithMaps(createCacheWithRedirects(options), createCacheWithRedirects(options), currentDirectory, getCanonicalFileName); - } - ts.createModuleResolutionCache = createModuleResolutionCache; /*@internal*/ function createCacheWithRedirects(options) { var ownMap = new ts.Map(); var redirectsMap = new ts.Map(); return { - ownMap: ownMap, + getOwnMap: getOwnMap, redirectsMap: redirectsMap, getOrCreateMapOfCacheRedirects: getOrCreateMapOfCacheRedirects, clear: clear, setOwnOptions: setOwnOptions, setOwnMap: setOwnMap }; + function getOwnMap() { + return ownMap; + } function setOwnOptions(newOptions) { options = newOptions; } @@ -39340,26 +40730,88 @@ var ts; } } ts.createCacheWithRedirects = createCacheWithRedirects; - /*@internal*/ - function createModuleResolutionCacheWithMaps(directoryToModuleNameMap, moduleNameToDirectoryMap, currentDirectory, getCanonicalFileName) { - return { getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, directoryToModuleNameMap: directoryToModuleNameMap, moduleNameToDirectoryMap: moduleNameToDirectoryMap }; + function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName) { + var cache; + return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear }; + function getPackageJsonInfo(packageJsonPath) { + return cache === null || cache === void 0 ? void 0 : cache.get(ts.toPath(packageJsonPath, currentDirectory, getCanonicalFileName)); + } + function setPackageJsonInfo(packageJsonPath, info) { + (cache || (cache = new ts.Map())).set(ts.toPath(packageJsonPath, currentDirectory, getCanonicalFileName), info); + } + function clear() { + cache = undefined; + } + } + function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) { + var cache = cacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference); + var result = cache.get(key); + if (!result) { + result = create(); + cache.set(key, result); + } + return result; + } + function updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap) { + if (!options.configFile) + return; + if (directoryToModuleNameMap.redirectsMap.size === 0) { + // The own map will be for projectCompilerOptions + ts.Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.redirectsMap.size === 0); + ts.Debug.assert(directoryToModuleNameMap.getOwnMap().size === 0); + ts.Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.getOwnMap().size === 0); + directoryToModuleNameMap.redirectsMap.set(options.configFile.path, directoryToModuleNameMap.getOwnMap()); + moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.redirectsMap.set(options.configFile.path, moduleNameToDirectoryMap.getOwnMap()); + } + else { + // Set correct own map + ts.Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.redirectsMap.size > 0); + var ref = { + sourceFile: options.configFile, + commandLine: { options: options } + }; + directoryToModuleNameMap.setOwnMap(directoryToModuleNameMap.getOrCreateMapOfCacheRedirects(ref)); + moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.setOwnMap(moduleNameToDirectoryMap.getOrCreateMapOfCacheRedirects(ref)); + } + directoryToModuleNameMap.setOwnOptions(options); + moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.setOwnOptions(options); + } + function createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap) { + return { + getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, + clear: clear, + update: update, + }; + function clear() { + directoryToModuleNameMap.clear(); + } + function update(options) { + updateRedirectsMap(options, directoryToModuleNameMap); + } function getOrCreateCacheForDirectory(directoryName, redirectedReference) { var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName); return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, function () { return new ts.Map(); }); } + } + function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options, directoryToModuleNameMap, moduleNameToDirectoryMap) { + var preDirectoryResolutionCache = 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; } }); + function clear() { + preDirectoryResolutionCache.clear(); + moduleNameToDirectoryMap.clear(); + packageJsonInfoCache.clear(); + } + function update(options) { + updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap); + } function getOrCreateCacheForModuleName(nonRelativeModuleName, redirectedReference) { ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName)); return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, nonRelativeModuleName, createPerModuleNameCache); } - function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) { - var cache = cacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference); - var result = cache.get(key); - if (!result) { - result = create(); - cache.set(key, result); - } - return result; - } function createPerModuleNameCache() { var directoryPathMap = new ts.Map(); return { get: get, set: set }; @@ -39426,7 +40878,17 @@ var ts; } } } - ts.createModuleResolutionCacheWithMaps = createModuleResolutionCacheWithMaps; + ts.createModuleResolutionCache = createModuleResolutionCache; + function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache, directoryToModuleNameMap) { + var preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options))); + packageJsonInfoCache || (packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName)); + return __assign(__assign(__assign({}, packageJsonInfoCache), preDirectoryResolutionCache), { clear: clear }); + function clear() { + preDirectoryResolutionCache.clear(); + packageJsonInfoCache.clear(); + } + } + ts.createTypeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache; function resolveModuleNameFromCache(moduleName, containingFile, cache) { var containingDirectory = ts.getDirectoryPath(containingFile); var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); @@ -39575,7 +41037,8 @@ var ts; } } function tryLoadModuleUsingPathsIfEligible(extensions, moduleName, loader, state) { - var _a = state.compilerOptions, baseUrl = _a.baseUrl, paths = _a.paths; + var _a; + var _b = state.compilerOptions, baseUrl = _b.baseUrl, paths = _b.paths, configFile = _b.configFile; if (paths && !ts.pathIsRelative(moduleName)) { if (state.traceEnabled) { if (baseUrl) { @@ -39584,7 +41047,8 @@ var ts; trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); } var baseDirectory = ts.getPathsBasePath(state.compilerOptions, state.host); // Always defined when 'paths' is defined - return tryLoadModuleUsingPaths(extensions, moduleName, baseDirectory, paths, loader, /*onlyRecordFailures*/ false, state); + var pathPatterns = (configFile === null || configFile === void 0 ? void 0 : configFile.configFileSpecs) ? (_a = configFile.configFileSpecs).pathPatterns || (_a.pathPatterns = ts.tryParsePatterns(paths)) : undefined; + return tryLoadModuleUsingPaths(extensions, moduleName, baseDirectory, paths, pathPatterns, loader, /*onlyRecordFailures*/ false, state); } } function tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, state) { @@ -39704,7 +41168,7 @@ var ts; var _a, _b; var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations }; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache }; var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); }); return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, state.resultFromCache); function tryResolve(extensions) { @@ -39764,7 +41228,7 @@ var ts; } var resolvedFromFile = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state); if (resolvedFromFile) { - var packageDirectory = considerPackageJson ? parseNodeModuleFromPath(resolvedFromFile) : undefined; + var packageDirectory = considerPackageJson ? parseNodeModuleFromPath(resolvedFromFile.path) : undefined; var packageInfo = packageDirectory ? getPackageJsonInfo(packageDirectory, /*onlyRecordFailures*/ false, state) : undefined; return withPackageId(packageInfo, resolvedFromFile); } @@ -39797,8 +41261,9 @@ var ts; * For `/node_modules/@types/foo/bar/index.d.ts` this is packageDirectory: "@types/foo" * For `/node_modules/foo/bar/index.d.ts` this is packageDirectory: "foo" */ + /* @internal */ function parseNodeModuleFromPath(resolved) { - var path = ts.normalizePath(resolved.path); + var path = ts.normalizePath(resolved); var idx = path.lastIndexOf(ts.nodeModulesPathPart); if (idx === -1) { return undefined; @@ -39810,6 +41275,7 @@ var ts; } return path.slice(0, indexAfterPackageName); } + ts.parseNodeModuleFromPath = parseNodeModuleFromPath; function moveToNextDirectorySeparatorIfAvailable(path, prevSeparatorIndex) { var nextSeparatorIndex = path.indexOf(ts.directorySeparator, prevSeparatorIndex + 1); return nextSeparatorIndex === -1 ? prevSeparatorIndex : nextSeparatorIndex; @@ -39893,21 +41359,43 @@ var ts; return withPackageId(packageInfo, loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJsonContent, versionPaths)); } function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) { + var _a, _b, _c; var host = state.host, traceEnabled = state.traceEnabled; - var directoryExists = !onlyRecordFailures && ts.directoryProbablyExists(packageDirectory, host); var packageJsonPath = ts.combinePaths(packageDirectory, "package.json"); + if (onlyRecordFailures) { + state.failedLookupLocations.push(packageJsonPath); + return undefined; + } + var existing = (_a = state.packageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.getPackageJsonInfo(packageJsonPath); + if (existing !== undefined) { + if (typeof existing !== "boolean") { + if (traceEnabled) + trace(host, ts.Diagnostics.File_0_exists_according_to_earlier_cached_lookups, packageJsonPath); + return existing; + } + else { + if (existing && traceEnabled) + trace(host, ts.Diagnostics.File_0_does_not_exist_according_to_earlier_cached_lookups, packageJsonPath); + state.failedLookupLocations.push(packageJsonPath); + return undefined; + } + } + var directoryExists = ts.directoryProbablyExists(packageDirectory, host); if (directoryExists && host.fileExists(packageJsonPath)) { var packageJsonContent = ts.readJson(packageJsonPath, host); if (traceEnabled) { trace(host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); } var versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state); - return { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths }; + var result = { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths }; + (_b = state.packageJsonInfoCache) === null || _b === void 0 ? void 0 : _b.setPackageJsonInfo(packageJsonPath, result); + return result; } else { if (directoryExists && traceEnabled) { trace(host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); } + (_c = state.packageJsonInfoCache) === null || _c === void 0 ? void 0 : _c.setPackageJsonInfo(packageJsonPath, directoryExists); // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results state.failedLookupLocations.push(packageJsonPath); } @@ -39958,7 +41446,7 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2, versionPaths.version, ts.version, moduleName); } - var result = tryLoadModuleUsingPaths(extensions, moduleName, candidate, versionPaths.paths, loader, onlyRecordFailuresForPackageFile || onlyRecordFailuresForIndex, state); + var result = tryLoadModuleUsingPaths(extensions, moduleName, candidate, versionPaths.paths, /*pathPatterns*/ undefined, loader, onlyRecordFailuresForPackageFile || onlyRecordFailuresForIndex, state); if (result) { return removeIgnoredPackageId(result.value); } @@ -40065,7 +41553,7 @@ var ts; trace(state.host, ts.Diagnostics.package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2, packageInfo.versionPaths.version, ts.version, rest); } var packageDirectoryExists = nodeModulesDirectoryExists && ts.directoryProbablyExists(packageDirectory, state.host); - var fromPaths = tryLoadModuleUsingPaths(extensions, rest, packageDirectory, packageInfo.versionPaths.paths, loader, !packageDirectoryExists, state); + var fromPaths = tryLoadModuleUsingPaths(extensions, rest, packageDirectory, packageInfo.versionPaths.paths, /*pathPatterns*/ undefined, loader, !packageDirectoryExists, state); if (fromPaths) { return fromPaths.value; } @@ -40073,8 +41561,9 @@ var ts; } return loader(extensions, candidate, !nodeModulesDirectoryExists, state); } - function tryLoadModuleUsingPaths(extensions, moduleName, baseDirectory, paths, loader, onlyRecordFailures, state) { - var matchedPattern = ts.matchPatternOrExact(ts.getOwnKeys(paths), moduleName); + function tryLoadModuleUsingPaths(extensions, moduleName, baseDirectory, paths, pathPatterns, loader, onlyRecordFailures, state) { + pathPatterns || (pathPatterns = ts.tryParsePatterns(paths)); + var matchedPattern = ts.matchPatternOrExact(pathPatterns, moduleName); if (matchedPattern) { var matchedStar_1 = ts.isString(matchedPattern) ? undefined : ts.matchedText(matchedPattern, moduleName); var matchedPatternText = ts.isString(matchedPattern) ? matchedPattern : ts.patternText(matchedPattern); @@ -40156,7 +41645,7 @@ var ts; function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) { var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations }; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache }; var containingDirectory = ts.getDirectoryPath(containingFile); var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); // No originalPath because classic resolution doesn't resolve realPath @@ -40197,13 +41686,13 @@ var ts; * This is the minumum code needed to expose that functionality; the rest is in the host. */ /* @internal */ - function loadModuleFromGlobalCache(moduleName, projectName, compilerOptions, host, globalCache) { + function loadModuleFromGlobalCache(moduleName, projectName, compilerOptions, host, globalCache, packageJsonInfoCache) { var traceEnabled = isTraceEnabled(compilerOptions, host); if (traceEnabled) { trace(host, ts.Diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2, projectName, moduleName, globalCache); } var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations }; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: packageJsonInfoCache }; var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, /*typesScopeOnly*/ false); return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, state.resultFromCache); } @@ -40249,26 +41738,26 @@ var ts; // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: return 0 /* NonInstantiated */; // 2. const enum declarations - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: if (ts.isEnumConst(node)) { return 2 /* ConstEnumOnly */; } break; // 3. non-exported import declarations - case 261 /* ImportDeclaration */: - case 260 /* ImportEqualsDeclaration */: + case 263 /* ImportDeclaration */: + case 262 /* ImportEqualsDeclaration */: if (!(ts.hasSyntacticModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } break; // 4. Export alias declarations pointing at only uninstantiated modules or things uninstantiated modules contain - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: var exportDeclaration = node; - if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 268 /* NamedExports */) { + if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 270 /* NamedExports */) { var state = 0 /* NonInstantiated */; for (var _i = 0, _a = exportDeclaration.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; @@ -40284,7 +41773,7 @@ var ts; } break; // 5. other uninstantiated module declarations. - case 257 /* ModuleBlock */: { + case 259 /* ModuleBlock */: { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateCached(n, visited); @@ -40306,9 +41795,9 @@ var ts; }); return state_1; } - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return getModuleInstanceState(node, visited); - case 78 /* Identifier */: + case 79 /* Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should // be considered the same as type alias if (node.isInJSDocNamespace) { @@ -40378,14 +41867,14 @@ var ts; } var binder = createBinder(); function bindSourceFile(file, options) { - ts.tracing.push("bind" /* Bind */, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("bind" /* Bind */, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeBind"); ts.perfLogger.logStartBindFile("" + file.fileName); binder(file, options); ts.perfLogger.logStopBindFile(); ts.performance.mark("afterBind"); ts.performance.measure("Bind", "beforeBind", "afterBind"); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } ts.bindSourceFile = bindSourceFile; function createBinder() { @@ -40424,6 +41913,7 @@ var ts; var classifiableNames; var unreachableFlow = { flags: 1 /* Unreachable */ }; var reportedUnreachableFlow = { flags: 1 /* 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) * If so, the node _must_ be in the current file (as that's the only way anything could have traversed to it to yield it as the error node) @@ -40506,7 +41996,7 @@ var ts; // 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 === 266 /* ExportAssignment */) { + if (node.kind === 268 /* ExportAssignment */) { return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; } var name = ts.getNameOfDeclaration(node); @@ -40515,7 +42005,7 @@ var ts; var moduleName = ts.getTextOfIdentifierOrLiteral(name); return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); } - if (name.kind === 158 /* ComputedPropertyName */) { + if (name.kind === 160 /* ComputedPropertyName */) { var nameExpression = name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteralLike(nameExpression)) { @@ -40524,11 +42014,9 @@ var ts; if (ts.isSignedNumericLiteral(nameExpression)) { return ts.tokenToString(nameExpression.operator) + nameExpression.operand.text; } - ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); - return ts.getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); - } - if (ts.isWellKnownSymbolSyntactically(name)) { - return ts.getPropertyNameForKnownSymbolName(ts.idText(name.name)); + else { + ts.Debug.fail("Only computed properties with literal names have declaration names"); + } } if (ts.isPrivateIdentifier(name)) { // containingClass exists because private names only allowed inside classes @@ -40543,36 +42031,36 @@ var ts; return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 166 /* Constructor */: + case 168 /* Constructor */: return "__constructor" /* Constructor */; - case 174 /* FunctionType */: - case 169 /* CallSignature */: - case 313 /* JSDocSignature */: + case 176 /* FunctionType */: + case 171 /* CallSignature */: + case 317 /* JSDocSignature */: return "__call" /* Call */; - case 175 /* ConstructorType */: - case 170 /* ConstructSignature */: + case 177 /* ConstructorType */: + case 172 /* ConstructSignature */: return "__new" /* New */; - case 171 /* IndexSignature */: + case 173 /* IndexSignature */: return "__index" /* Index */; - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: return "__export" /* ExportStar */; - case 297 /* SourceFile */: + case 299 /* SourceFile */: // json file should behave as // module.exports = ... return "export=" /* ExportEquals */; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */) { // module.exports = ... return "export=" /* ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 308 /* JSDocFunctionType */: + case 311 /* JSDocFunctionType */: return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); - case 160 /* Parameter */: + case 162 /* 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 === 308 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); + ts.Debug.assert(node.parent.kind === 311 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); var functionType = node.parent; var index = functionType.parameters.indexOf(node); return "arg" + index; @@ -40672,7 +42160,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 === 266 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 268 /* ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; messageNeedsName_1 = false; multipleDefaultExports_1 = true; @@ -40711,7 +42199,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = !!(ts.getCombinedModifierFlags(node) & 1 /* Export */) || jsdocTreatAsExported(node); if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 270 /* ExportSpecifier */ || (node.kind === 260 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 272 /* ExportSpecifier */ || (node.kind === 262 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -40800,7 +42288,7 @@ var ts; // 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 !== 209 /* ArrowFunction */) { + if (node.kind !== 211 /* ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -40833,7 +42321,7 @@ var ts; } // We create a return control flow graph for IIFEs and constructors. For constructors // we use the return control flow graph in strict property initialization checks. - currentReturnTarget = isIIFE || node.kind === 166 /* Constructor */ || (ts.isInJSFile(node) && (node.kind === 251 /* FunctionDeclaration */ || node.kind === 208 /* FunctionExpression */)) ? createBranchLabel() : undefined; + currentReturnTarget = isIIFE || node.kind === 168 /* Constructor */ || (ts.isInJSFile(node) && (node.kind === 253 /* FunctionDeclaration */ || node.kind === 210 /* FunctionExpression */)) ? createBranchLabel() : undefined; currentExceptionTarget = undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; @@ -40848,13 +42336,14 @@ var ts; node.flags |= 512 /* HasExplicitReturn */; node.endFlowNode = currentFlow; } - if (node.kind === 297 /* SourceFile */) { + if (node.kind === 299 /* SourceFile */) { node.flags |= emitFlags; + node.endFlowNode = currentFlow; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 166 /* Constructor */ || (ts.isInJSFile(node) && (node.kind === 251 /* FunctionDeclaration */ || node.kind === 208 /* FunctionExpression */))) { + if (node.kind === 168 /* Constructor */ || (ts.isInJSFile(node) && (node.kind === 253 /* FunctionDeclaration */ || node.kind === 210 /* FunctionExpression */))) { node.returnFlowNode = currentFlow; } } @@ -40881,8 +42370,8 @@ var ts; blockScopeContainer = savedBlockScopeContainer; } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 251 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 251 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 253 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 253 /* FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -40905,59 +42394,59 @@ var ts; inAssignmentPattern = saveInAssignmentPattern; return; } - if (node.kind >= 232 /* FirstStatement */ && node.kind <= 248 /* LastStatement */ && !options.allowUnreachableCode) { + if (node.kind >= 234 /* FirstStatement */ && node.kind <= 250 /* LastStatement */ && !options.allowUnreachableCode) { node.flowNode = currentFlow; } switch (node.kind) { - case 236 /* WhileStatement */: + case 238 /* WhileStatement */: bindWhileStatement(node); break; - case 235 /* DoStatement */: + case 237 /* DoStatement */: bindDoStatement(node); break; - case 237 /* ForStatement */: + case 239 /* ForStatement */: bindForStatement(node); break; - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 234 /* IfStatement */: + case 236 /* IfStatement */: bindIfStatement(node); break; - case 242 /* ReturnStatement */: - case 246 /* ThrowStatement */: + case 244 /* ReturnStatement */: + case 248 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 241 /* BreakStatement */: - case 240 /* ContinueStatement */: + case 243 /* BreakStatement */: + case 242 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 247 /* TryStatement */: + case 249 /* TryStatement */: bindTryStatement(node); break; - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: bindSwitchStatement(node); break; - case 258 /* CaseBlock */: + case 260 /* CaseBlock */: bindCaseBlock(node); break; - case 284 /* CaseClause */: + case 286 /* CaseClause */: bindCaseClause(node); break; - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: bindExpressionStatement(node); break; - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: bindLabeledStatement(node); break; - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: if (ts.isDestructuringAssignment(node)) { // Carry over whether we are in an assignment pattern to // binary expressions that could actually be an initializer @@ -40967,47 +42456,47 @@ var ts; } bindBinaryExpressionFlow(node); break; - case 210 /* DeleteExpression */: + case 212 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: bindAccessExpressionFlow(node); break; - case 203 /* CallExpression */: + case 205 /* CallExpression */: bindCallExpressionFlow(node); break; - case 225 /* NonNullExpression */: + case 227 /* NonNullExpression */: bindNonNullExpressionFlow(node); break; - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 325 /* JSDocEnumTag */: + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + case 333 /* JSDocEnumTag */: bindJSDocTypeAlias(node); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 297 /* SourceFile */: { + case 299 /* SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; } - case 230 /* Block */: - case 257 /* ModuleBlock */: + case 232 /* Block */: + case 259 /* ModuleBlock */: bindEachFunctionsFirst(node.statements); break; - case 198 /* BindingElement */: + case 200 /* BindingElement */: bindBindingElementFlow(node); break; - case 200 /* ObjectLiteralExpression */: - case 199 /* ArrayLiteralExpression */: - case 288 /* PropertyAssignment */: - case 220 /* SpreadElement */: + case 202 /* ObjectLiteralExpression */: + case 201 /* ArrayLiteralExpression */: + case 290 /* PropertyAssignment */: + case 222 /* 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; @@ -41021,32 +42510,32 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 78 /* Identifier */: - case 79 /* PrivateIdentifier */: - case 107 /* ThisKeyword */: - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 79 /* Identifier */: + case 80 /* PrivateIdentifier */: + case 108 /* ThisKeyword */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: return containsNarrowableReference(expr); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return hasNarrowableArgument(expr); - case 207 /* ParenthesizedExpression */: - case 225 /* NonNullExpression */: + case 209 /* ParenthesizedExpression */: + case 227 /* NonNullExpression */: return isNarrowingExpression(expr.expression); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return expr.operator === 53 /* ExclamationToken */ && isNarrowingExpression(expr.operand); - case 211 /* TypeOfExpression */: + case 213 /* TypeOfExpression */: return isNarrowingExpression(expr.expression); } return false; } function isNarrowableReference(expr) { - return expr.kind === 78 /* Identifier */ || expr.kind === 79 /* PrivateIdentifier */ || expr.kind === 107 /* ThisKeyword */ || expr.kind === 105 /* SuperKeyword */ || - (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) || - ts.isBinaryExpression(expr) && expr.operatorToken.kind === 27 /* CommaToken */ && isNarrowableReference(expr.right) || - ts.isElementAccessExpression(expr) && ts.isStringOrNumericLiteralLike(expr.argumentExpression) && isNarrowableReference(expr.expression) || - ts.isAssignmentExpression(expr) && isNarrowableReference(expr.left); + 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.isElementAccessExpression(expr) && ts.isStringOrNumericLiteralLike(expr.argumentExpression) && isNarrowableReference(expr.expression) + || ts.isAssignmentExpression(expr) && isNarrowableReference(expr.left); } function containsNarrowableReference(expr) { return isNarrowableReference(expr) || ts.isOptionalChain(expr) && containsNarrowableReference(expr.expression); @@ -41060,7 +42549,7 @@ var ts; } } } - if (expr.expression.kind === 201 /* PropertyAccessExpression */ && + if (expr.expression.kind === 203 /* PropertyAccessExpression */ && containsNarrowableReference(expr.expression.expression)) { return true; } @@ -41074,10 +42563,10 @@ var ts; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 62 /* EqualsToken */: - case 74 /* BarBarEqualsToken */: - case 75 /* AmpersandAmpersandEqualsToken */: - case 76 /* QuestionQuestionEqualsToken */: + case 63 /* EqualsToken */: + case 75 /* BarBarEqualsToken */: + case 76 /* AmpersandAmpersandEqualsToken */: + case 77 /* QuestionQuestionEqualsToken */: return containsNarrowableReference(expr.left); case 34 /* EqualsEqualsToken */: case 35 /* ExclamationEqualsToken */: @@ -41085,9 +42574,9 @@ var ts; case 37 /* ExclamationEqualsEqualsToken */: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 101 /* InstanceOfKeyword */: + case 102 /* InstanceOfKeyword */: return isNarrowableOperand(expr.left); - case 100 /* InKeyword */: + case 101 /* InKeyword */: return isNarrowableInOperands(expr.left, expr.right); case 27 /* CommaToken */: return isNarrowingExpression(expr.right); @@ -41096,11 +42585,11 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: switch (expr.operatorToken.kind) { - case 62 /* EqualsToken */: + case 63 /* EqualsToken */: return isNarrowableOperand(expr.left); case 27 /* CommaToken */: return isNarrowableOperand(expr.right); @@ -41134,8 +42623,8 @@ var ts; if (!expression) { return flags & 32 /* TrueCondition */ ? antecedent : unreachableFlow; } - if ((expression.kind === 109 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || - expression.kind === 94 /* FalseKeyword */ && flags & 32 /* TrueCondition */) && + if ((expression.kind === 110 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || + expression.kind === 95 /* FalseKeyword */ && flags & 32 /* TrueCondition */) && !ts.isExpressionOfOptionalChainRoot(expression) && !ts.isNullishCoalesce(expression.parent)) { return unreachableFlow; } @@ -41174,26 +42663,26 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 234 /* IfStatement */: - case 236 /* WhileStatement */: - case 235 /* DoStatement */: + case 236 /* IfStatement */: + case 238 /* WhileStatement */: + case 237 /* DoStatement */: return parent.expression === node; - case 237 /* ForStatement */: - case 217 /* ConditionalExpression */: + case 239 /* ForStatement */: + case 219 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 207 /* ParenthesizedExpression */) { + if (node.kind === 209 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 214 /* PrefixUnaryExpression */ && node.operator === 53 /* ExclamationToken */) { + else if (node.kind === 216 /* PrefixUnaryExpression */ && node.operator === 53 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 216 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || + return node.kind === 218 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 56 /* BarBarToken */ || node.operatorToken.kind === 60 /* QuestionQuestionToken */); } @@ -41240,7 +42729,7 @@ var ts; } function setContinueTarget(node, target) { var label = activeLabelList; - while (label && node.parent.kind === 245 /* LabeledStatement */) { + while (label && node.parent.kind === 247 /* LabeledStatement */) { label.continueTarget = target; label = label.next; node = node.parent; @@ -41291,12 +42780,12 @@ var ts; bind(node.expression); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 239 /* ForOfStatement */) { + if (node.kind === 241 /* ForOfStatement */) { bind(node.awaitModifier); } addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 250 /* VariableDeclarationList */) { + if (node.initializer.kind !== 252 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -41318,7 +42807,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 242 /* ReturnStatement */) { + if (node.kind === 244 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -41335,7 +42824,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 241 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 243 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -41440,7 +42929,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 285 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 287 /* 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. @@ -41488,9 +42977,9 @@ var ts; function maybeBindExpressionFlowIfCall(node) { // A top level or LHS of 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 === 203 /* CallExpression */) { + if (node.kind === 205 /* CallExpression */) { var call = node; - if (ts.isDottedName(call.expression) && call.expression.kind !== 105 /* SuperKeyword */) { + if (call.expression.kind !== 106 /* SuperKeyword */ && ts.isDottedName(call.expression)) { currentFlow = createFlowCall(currentFlow, call); } } @@ -41514,7 +43003,7 @@ var ts; currentFlow = finishFlowLabel(postStatementLabel); } function bindDestructuringTargetFlow(node) { - if (node.kind === 216 /* BinaryExpression */ && node.operatorToken.kind === 62 /* EqualsToken */) { + if (node.kind === 218 /* BinaryExpression */ && node.operatorToken.kind === 63 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -41525,10 +43014,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowMutation(16 /* Assignment */, currentFlow, node); } - else if (node.kind === 199 /* ArrayLiteralExpression */) { + else if (node.kind === 201 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 220 /* SpreadElement */) { + if (e.kind === 222 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -41536,16 +43025,16 @@ var ts; } } } - else if (node.kind === 200 /* ObjectLiteralExpression */) { + else if (node.kind === 202 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 288 /* PropertyAssignment */) { + if (p.kind === 290 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 289 /* ShorthandPropertyAssignment */) { + else if (p.kind === 291 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 290 /* SpreadAssignment */) { + else if (p.kind === 292 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -41553,7 +43042,7 @@ var ts; } function bindLogicalLikeExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 75 /* AmpersandAmpersandEqualsToken */) { + if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 76 /* AmpersandAmpersandEqualsToken */) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -41610,128 +43099,102 @@ var ts; } bindAssignmentTargetFlow(node.left); } - var BindBinaryExpressionFlowState; - (function (BindBinaryExpressionFlowState) { - BindBinaryExpressionFlowState[BindBinaryExpressionFlowState["BindThenBindChildren"] = 0] = "BindThenBindChildren"; - BindBinaryExpressionFlowState[BindBinaryExpressionFlowState["MaybeBindLeft"] = 1] = "MaybeBindLeft"; - BindBinaryExpressionFlowState[BindBinaryExpressionFlowState["BindToken"] = 2] = "BindToken"; - BindBinaryExpressionFlowState[BindBinaryExpressionFlowState["BindRight"] = 3] = "BindRight"; - BindBinaryExpressionFlowState[BindBinaryExpressionFlowState["FinishBind"] = 4] = "FinishBind"; - })(BindBinaryExpressionFlowState || (BindBinaryExpressionFlowState = {})); - function bindBinaryExpressionFlow(node) { - var workStacks = { - expr: [node], - state: [1 /* MaybeBindLeft */], - inStrictMode: [undefined], - parent: [undefined], - }; - var stackIndex = 0; - while (stackIndex >= 0) { - node = workStacks.expr[stackIndex]; - switch (workStacks.state[stackIndex]) { - case 0 /* BindThenBindChildren */: { - // This state is used only when recuring, to emulate the work that `bind` does before - // reaching `bindChildren`. A normal call to `bindBinaryExpressionFlow` will already have done this work. - ts.setParent(node, parent); - var saveInStrictMode = inStrictMode; - bindWorker(node); - var saveParent = parent; - parent = node; - advanceState(1 /* MaybeBindLeft */, saveInStrictMode, saveParent); - break; - } - case 1 /* MaybeBindLeft */: { - var operator = node.operatorToken.kind; - // TODO: bindLogicalExpression is recursive - if we want to handle deeply nested `&&` expressions - // 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 - if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */ || - ts.isLogicalOrCoalescingAssignmentOperator(operator)) { - if (isTopLevelLogicalExpression(node)) { - var postExpressionLabel = createBranchLabel(); - bindLogicalLikeExpression(node, postExpressionLabel, postExpressionLabel); - currentFlow = finishFlowLabel(postExpressionLabel); - } - else { - bindLogicalLikeExpression(node, currentTrueTarget, currentFalseTarget); - } - completeNode(); - } - else { - advanceState(2 /* BindToken */); - maybeBind(node.left); - } - break; + function createBindBinaryExpressionFlow() { + return ts.createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, /*foldState*/ undefined); + function onEnter(node, state) { + if (state) { + state.stackIndex++; + // Emulate the work that `bind` does before reaching `bindChildren`. A normal call to + // `bindBinaryExpressionFlow` will already have done this work. + ts.setParent(node, parent); + var saveInStrictMode = inStrictMode; + bindWorker(node); + var saveParent = parent; + parent = node; + state.skip = false; + state.inStrictModeStack[state.stackIndex] = saveInStrictMode; + state.parentStack[state.stackIndex] = saveParent; + } + else { + state = { + stackIndex: 0, + skip: false, + inStrictModeStack: [undefined], + parentStack: [undefined] + }; + } + // TODO: bindLogicalExpression is recursive - if we want to handle deeply nested `&&` expressions + // 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 */ || + ts.isLogicalOrCoalescingAssignmentOperator(operator)) { + if (isTopLevelLogicalExpression(node)) { + var postExpressionLabel = createBranchLabel(); + bindLogicalLikeExpression(node, postExpressionLabel, postExpressionLabel); + currentFlow = finishFlowLabel(postExpressionLabel); } - case 2 /* BindToken */: { - if (node.operatorToken.kind === 27 /* CommaToken */) { - maybeBindExpressionFlowIfCall(node.left); - } - advanceState(3 /* BindRight */); - maybeBind(node.operatorToken); - break; + else { + bindLogicalLikeExpression(node, currentTrueTarget, currentFalseTarget); } - case 3 /* BindRight */: { - advanceState(4 /* FinishBind */); - maybeBind(node.right); - break; + state.skip = true; + } + return state; + } + function onLeft(left, state, _node) { + if (!state.skip) { + return maybeBind(left); + } + } + function onOperator(operatorToken, state, node) { + if (!state.skip) { + if (operatorToken.kind === 27 /* CommaToken */) { + maybeBindExpressionFlowIfCall(node.left); } - case 4 /* FinishBind */: { - var operator = node.operatorToken.kind; - if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { - bindAssignmentTargetFlow(node.left); - if (operator === 62 /* EqualsToken */ && node.left.kind === 202 /* ElementAccessExpression */) { - var elementAccess = node.left; - if (isNarrowableOperand(elementAccess.expression)) { - currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node); - } + bind(operatorToken); + } + } + function onRight(right, state, _node) { + if (!state.skip) { + return maybeBind(right); + } + } + function onExit(node, state) { + if (!state.skip) { + var operator = node.operatorToken.kind; + if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { + bindAssignmentTargetFlow(node.left); + if (operator === 63 /* EqualsToken */ && node.left.kind === 204 /* ElementAccessExpression */) { + var elementAccess = node.left; + if (isNarrowableOperand(elementAccess.expression)) { + currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node); } } - completeNode(); - break; } - default: return ts.Debug.fail("Invalid state " + workStacks.state[stackIndex] + " for bindBinaryExpressionFlow"); } - } - /** - * Note that `advanceState` sets the _current_ head state, and that `maybeBind` potentially pushes on a new - * head state; so `advanceState` must be called before any `maybeBind` during a state's execution. - */ - function advanceState(state, isInStrictMode, parent) { - workStacks.state[stackIndex] = state; - if (isInStrictMode !== undefined) { - workStacks.inStrictMode[stackIndex] = isInStrictMode; - } - if (parent !== undefined) { - workStacks.parent[stackIndex] = parent; + var savedInStrictMode = state.inStrictModeStack[state.stackIndex]; + var savedParent = state.parentStack[state.stackIndex]; + if (savedInStrictMode !== undefined) { + inStrictMode = savedInStrictMode; } - } - function completeNode() { - if (workStacks.inStrictMode[stackIndex] !== undefined) { - inStrictMode = workStacks.inStrictMode[stackIndex]; - parent = workStacks.parent[stackIndex]; + if (savedParent !== undefined) { + parent = savedParent; } - stackIndex--; + state.skip = false; + state.stackIndex--; } - /** - * If `node` is a BinaryExpression, adds it to the local work stack, otherwise recursively binds it - */ function maybeBind(node) { if (node && ts.isBinaryExpression(node) && !ts.isDestructuringAssignment(node)) { - stackIndex++; - workStacks.expr[stackIndex] = node; - workStacks.state[stackIndex] = 0 /* BindThenBindChildren */; - workStacks.inStrictMode[stackIndex] = undefined; - workStacks.parent[stackIndex] = undefined; - } - else { - bind(node); + return node; } + bind(node); } } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 201 /* PropertyAccessExpression */) { + if (node.expression.kind === 203 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -41788,7 +43251,7 @@ var ts; } function bindJSDocTypeAlias(node) { ts.setParent(node.tagName, node); - if (node.kind !== 325 /* JSDocEnumTag */ && node.fullName) { + if (node.kind !== 333 /* JSDocEnumTag */ && node.fullName) { ts.setParent(node.fullName, node); ts.setParentRecursive(node.fullName, /*incremental*/ false); } @@ -41796,7 +43259,7 @@ var ts; function bindJSDocClassTag(node) { bindEachChild(node); var host = ts.getHostSignatureFromJSDoc(node); - if (host && host.kind !== 165 /* MethodDeclaration */) { + if (host && host.kind !== 167 /* MethodDeclaration */) { addDeclarationToSymbol(host.symbol, host, 32 /* Class */); } } @@ -41809,15 +43272,15 @@ var ts; } function bindOptionalChainRest(node) { switch (node.kind) { - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: bind(node.questionDotToken); bind(node.name); break; - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: bind(node.questionDotToken); bind(node.argumentExpression); break; - case 203 /* CallExpression */: + case 205 /* CallExpression */: bind(node.questionDotToken); bindEach(node.typeArguments); bindEach(node.arguments); @@ -41882,19 +43345,19 @@ 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 === 208 /* FunctionExpression */ || expr.kind === 209 /* ArrowFunction */) { + if (expr.kind === 210 /* FunctionExpression */ || expr.kind === 211 /* ArrowFunction */) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); } else { bindEachChild(node); - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { currentFlow = createFlowCall(currentFlow, node); } } } - if (node.expression.kind === 201 /* PropertyAccessExpression */) { + if (node.expression.kind === 203 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (ts.isIdentifier(propertyAccess.name) && isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node); @@ -41903,54 +43366,54 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 221 /* ClassExpression */: - case 252 /* ClassDeclaration */: - case 255 /* EnumDeclaration */: - case 200 /* ObjectLiteralExpression */: - case 177 /* TypeLiteral */: - case 312 /* JSDocTypeLiteral */: - case 281 /* JsxAttributes */: + case 223 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 257 /* EnumDeclaration */: + case 202 /* ObjectLiteralExpression */: + case 179 /* TypeLiteral */: + case 316 /* JSDocTypeLiteral */: + case 283 /* JsxAttributes */: return 1 /* IsContainer */; - case 253 /* InterfaceDeclaration */: + case 255 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 256 /* ModuleDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 190 /* MappedType */: + case 258 /* ModuleDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 192 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 297 /* SourceFile */: + case 299 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } // falls through - case 166 /* Constructor */: - case 251 /* FunctionDeclaration */: - case 164 /* MethodSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 169 /* CallSignature */: - case 313 /* JSDocSignature */: - case 308 /* JSDocFunctionType */: - case 174 /* FunctionType */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: - case 175 /* ConstructorType */: + case 168 /* Constructor */: + case 253 /* FunctionDeclaration */: + case 166 /* MethodSignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 171 /* CallSignature */: + case 317 /* JSDocSignature */: + case 311 /* JSDocFunctionType */: + case 176 /* FunctionType */: + case 172 /* ConstructSignature */: + case 173 /* IndexSignature */: + case 177 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 257 /* ModuleBlock */: + case 259 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 287 /* CatchClause */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 258 /* CaseBlock */: + case 289 /* CatchClause */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 260 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 230 /* Block */: + case 232 /* 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 @@ -41983,45 +43446,45 @@ 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 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 297 /* SourceFile */: + case 299 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 221 /* ClassExpression */: - case 252 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 254 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 177 /* TypeLiteral */: - case 312 /* JSDocTypeLiteral */: - case 200 /* ObjectLiteralExpression */: - case 253 /* InterfaceDeclaration */: - case 281 /* JsxAttributes */: + case 179 /* TypeLiteral */: + case 316 /* JSDocTypeLiteral */: + case 202 /* ObjectLiteralExpression */: + case 255 /* InterfaceDeclaration */: + case 283 /* 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 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 313 /* JSDocSignature */: - case 171 /* IndexSignature */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 308 /* JSDocFunctionType */: - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 254 /* TypeAliasDeclaration */: - case 190 /* MappedType */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 317 /* JSDocSignature */: + case 173 /* IndexSignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 311 /* JSDocFunctionType */: + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + case 256 /* TypeAliasDeclaration */: + case 192 /* 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 @@ -42068,15 +43531,13 @@ var ts; var pattern = void 0; if (node.name.kind === 10 /* StringLiteral */) { var text = node.name.text; - if (ts.hasZeroOrOneAsteriskCharacter(text)) { - pattern = ts.tryParsePattern(text); - } - else { + 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 */); - file.patternAmbientModules = ts.append(file.patternAmbientModules, pattern && { pattern: pattern, symbol: symbol }); + file.patternAmbientModules = ts.append(file.patternAmbientModules, pattern && !ts.isString(pattern) ? { pattern: pattern, symbol: symbol } : undefined); } } else { @@ -42122,7 +43583,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 === 290 /* SpreadAssignment */ || prop.name.kind !== 78 /* Identifier */) { + if (prop.kind === 292 /* SpreadAssignment */ || prop.name.kind !== 79 /* Identifier */) { continue; } var identifier = prop.name; @@ -42134,7 +43595,7 @@ var ts; // 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 === 288 /* PropertyAssignment */ || prop.kind === 289 /* ShorthandPropertyAssignment */ || prop.kind === 165 /* MethodDeclaration */ + var currentKind = prop.kind === 290 /* PropertyAssignment */ || prop.kind === 291 /* ShorthandPropertyAssignment */ || prop.kind === 167 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.escapedText); @@ -42166,10 +43627,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 297 /* SourceFile */: + case 299 /* SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -42194,9 +43655,9 @@ var ts; var saveCurrentFlow = currentFlow; for (var _i = 0, delayedTypeAliases_1 = delayedTypeAliases; _i < delayedTypeAliases_1.length; _i++) { var typeAlias = delayedTypeAliases_1[_i]; - var host = ts.getJSDocHost(typeAlias); - container = (host && ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1 /* IsContainer */); })) || file; - blockScopeContainer = (host && ts.getEnclosingBlockScopeContainer(host)) || file; + var host = typeAlias.parent.parent; + container = ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1 /* IsContainer */); }) || file; + blockScopeContainer = ts.getEnclosingBlockScopeContainer(host) || file; currentFlow = initFlowNode({ flags: 2 /* Start */ }); parent = typeAlias; bind(typeAlias.typeExpression); @@ -42237,7 +43698,7 @@ var ts; container = oldContainer; } } - else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 78 /* Identifier */) { + else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 79 /* Identifier */) { parent = typeAlias.parent; bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); } @@ -42262,11 +43723,11 @@ var ts; !ts.isIdentifierName(node)) { // strict mode identifiers if (inStrictMode && - node.originalKeywordKind >= 116 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 124 /* LastFutureReservedWord */) { + node.originalKeywordKind >= 117 /* FirstFutureReservedWord */ && + node.originalKeywordKind <= 125 /* LastFutureReservedWord */) { file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); } - else if (node.originalKeywordKind === 130 /* AwaitKeyword */) { + else if (node.originalKeywordKind === 131 /* 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))); } @@ -42274,7 +43735,7 @@ var ts; 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 === 124 /* YieldKeyword */ && node.flags & 8192 /* YieldContext */) { + else if (node.originalKeywordKind === 125 /* YieldKeyword */ && node.flags & 8192 /* YieldContext */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node))); } } @@ -42316,7 +43777,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 78 /* Identifier */) { + if (inStrictMode && node.expression.kind === 79 /* 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); @@ -42327,7 +43788,7 @@ var ts; return ts.isIdentifier(node) && (node.escapedText === "eval" || node.escapedText === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 78 /* Identifier */) { + if (name && name.kind === 79 /* 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 @@ -42368,8 +43829,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 297 /* SourceFile */ && - blockScopeContainer.kind !== 256 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 299 /* SourceFile */ && + blockScopeContainer.kind !== 258 /* ModuleDeclaration */ && !ts.isFunctionLike(blockScopeContainer)) { // We check first if the name is inside class declaration or class expression; if so give explicit message // otherwise report generic error message. @@ -42464,7 +43925,7 @@ 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 > 156 /* LastToken */) { + if (node.kind > 158 /* LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -42526,7 +43987,7 @@ var ts; function bindWorker(node) { switch (node.kind) { /* Strict mode checks */ - case 78 /* Identifier */: + case 79 /* 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. @@ -42539,18 +44000,24 @@ var ts; break; } // falls through - case 107 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 289 /* ShorthandPropertyAssignment */)) { + case 108 /* ThisKeyword */: + if (currentFlow && (ts.isExpression(node) || parent.kind === 291 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkContextualIdentifier(node); - case 105 /* SuperKeyword */: + case 159 /* QualifiedName */: + if (currentFlow && ts.isPartOfTypeQuery(node)) { + node.flowNode = currentFlow; + } + break; + case 228 /* MetaProperty */: + case 106 /* SuperKeyword */: node.flowNode = currentFlow; break; - case 79 /* PrivateIdentifier */: + case 80 /* PrivateIdentifier */: return checkPrivateIdentifier(node); - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: var expr = node; if (currentFlow && isNarrowableReference(expr)) { expr.flowNode = currentFlow; @@ -42565,7 +44032,7 @@ var ts; declareSymbol(file.locals, /*parent*/ undefined, expr.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 111550 /* FunctionScopedVariableExcludes */); } break; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: var specialKind = ts.getAssignmentDeclarationKind(node); switch (specialKind) { case 1 /* ExportsProperty */: @@ -42601,78 +44068,78 @@ var ts; ts.Debug.fail("Unknown binary expression special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return checkStrictModeCatchClause(node); - case 210 /* DeleteExpression */: + case 212 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 243 /* WithStatement */: + case 245 /* WithStatement */: return checkStrictModeWithStatement(node); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return checkStrictModeLabeledStatement(node); - case 187 /* ThisType */: + case 189 /* ThisType */: seenThisKeyword = true; return; - case 172 /* TypePredicate */: + case 174 /* TypePredicate */: break; // Binding the children will handle everything - case 159 /* TypeParameter */: + case 161 /* TypeParameter */: return bindTypeParameter(node); - case 160 /* Parameter */: + case 162 /* Parameter */: return bindParameter(node); - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 198 /* BindingElement */: + case 200 /* BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: return bindPropertyWorker(node); - case 288 /* PropertyAssignment */: - case 289 /* ShorthandPropertyAssignment */: + case 290 /* PropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 291 /* EnumMember */: + case 293 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 173 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 167 /* MethodDeclaration */: + case 166 /* 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 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return bindFunctionDeclaration(node); - case 166 /* Constructor */: + case 168 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 167 /* GetAccessor */: + case 169 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 46015 /* GetAccessorExcludes */); - case 168 /* SetAccessor */: + case 170 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 78783 /* SetAccessorExcludes */); - case 174 /* FunctionType */: - case 308 /* JSDocFunctionType */: - case 313 /* JSDocSignature */: - case 175 /* ConstructorType */: + case 176 /* FunctionType */: + case 311 /* JSDocFunctionType */: + case 317 /* JSDocSignature */: + case 177 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 177 /* TypeLiteral */: - case 312 /* JSDocTypeLiteral */: - case 190 /* MappedType */: + case 179 /* TypeLiteral */: + case 316 /* JSDocTypeLiteral */: + case 192 /* MappedType */: return bindAnonymousTypeWorker(node); - case 319 /* JSDocClassTag */: + case 326 /* JSDocClassTag */: return bindJSDocClassTag(node); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return bindFunctionExpression(node); - case 203 /* CallExpression */: + case 205 /* CallExpression */: var assignmentKind = ts.getAssignmentDeclarationKind(node); switch (assignmentKind) { case 7 /* ObjectDefinePropertyValue */: @@ -42691,65 +44158,65 @@ var ts; } break; // Members of classes, interfaces, and modules - case 221 /* ClassExpression */: - case 252 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 254 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 253 /* InterfaceDeclaration */: + case 255 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 788872 /* InterfaceExcludes */); - case 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 281 /* JsxAttributes */: + case 283 /* JsxAttributes */: return bindJsxAttributes(node); - case 280 /* JsxAttribute */: + case 282 /* JsxAttribute */: return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); // Imports and exports - case 260 /* ImportEqualsDeclaration */: - case 263 /* NamespaceImport */: - case 265 /* ImportSpecifier */: - case 270 /* ExportSpecifier */: + case 262 /* ImportEqualsDeclaration */: + case 265 /* NamespaceImport */: + case 267 /* ImportSpecifier */: + case 272 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 259 /* NamespaceExportDeclaration */: + case 261 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 262 /* ImportClause */: + case 264 /* ImportClause */: return bindImportClause(node); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: return bindExportDeclaration(node); - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return bindExportAssignment(node); - case 297 /* SourceFile */: + case 299 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 230 /* Block */: + case 232 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // falls through - case 257 /* ModuleBlock */: + case 259 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 326 /* JSDocParameterTag */: - if (node.parent.kind === 313 /* JSDocSignature */) { + case 334 /* JSDocParameterTag */: + if (node.parent.kind === 317 /* JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 312 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 316 /* JSDocTypeLiteral */) { break; } // falls through - case 333 /* JSDocPropertyTag */: + case 341 /* JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 307 /* JSDocOptionalType */ ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 310 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 325 /* JSDocEnumTag */: + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + case 333 /* JSDocEnumTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -42777,8 +44244,8 @@ var ts; } function bindExportAssignment(node) { if (!container.symbol || !container.symbol.exports) { - // Export assignment in some sort of block construct - bindAnonymousDeclaration(node, 2097152 /* Alias */, getDeclarationName(node)); + // Incorrect export assignment in some sort of block construct + bindAnonymousDeclaration(node, 111551 /* Value */, getDeclarationName(node)); } else { var flags = ts.exportAssignmentIsAlias(node) @@ -42912,11 +44379,11 @@ var ts; } var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 210 /* 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 === 62 /* EqualsToken */) { + if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 63 /* EqualsToken */) { var l = thisContainer.parent.left; if (ts.isBindableStaticAccessExpression(l) && ts.isPrototypeAccess(l.expression)) { constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer); @@ -42935,11 +44402,11 @@ var ts; addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* Class */); } break; - case 166 /* Constructor */: - case 163 /* PropertyDeclaration */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 168 /* Constructor */: + case 165 /* PropertyDeclaration */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: // this.foo assignment in a JavaScript class // Bind this property to the containing class var containingClass = thisContainer.parent; @@ -42951,7 +44418,7 @@ var ts; declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* None */, /*isReplaceableByMethod*/ true); } break; - case 297 /* SourceFile */: + case 299 /* 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; @@ -42977,10 +44444,10 @@ var ts; } } function bindSpecialPropertyDeclaration(node) { - if (node.expression.kind === 107 /* ThisKeyword */) { + if (node.expression.kind === 108 /* ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 297 /* SourceFile */) { + else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 299 /* SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -43020,7 +44487,7 @@ var ts; } function bindObjectDefinePropertyAssignment(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); - var isToplevel = node.parent.parent.kind === 297 /* SourceFile */; + var isToplevel = node.parent.parent.kind === 299 /* SourceFile */; namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ false); } @@ -43129,8 +44596,8 @@ var ts; } function isTopLevelNamespaceAssignment(propertyAccess) { return ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 297 /* SourceFile */ - : propertyAccess.parent.parent.kind === 297 /* SourceFile */; + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 299 /* SourceFile */ + : propertyAccess.parent.parent.kind === 299 /* SourceFile */; } function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) { var namespaceSymbol = lookupSymbolForPropertyAccess(name, container) || lookupSymbolForPropertyAccess(name, blockScopeContainer); @@ -43209,7 +44676,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 252 /* ClassDeclaration */) { + if (node.kind === 254 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899503 /* ClassExcludes */); } else { @@ -43251,7 +44718,7 @@ var ts; checkStrictModeEvalOrArguments(node, node.name); } if (!ts.isBindingPattern(node.name)) { - if (ts.isInJSFile(node) && ts.isRequireVariableDeclaration(node, /*requireStringLiteralLikeArgument*/ true) && !ts.getJSDocTypeTag(node)) { + if (ts.isInJSFile(node) && ts.isRequireVariableDeclaration(node) && !ts.getJSDocTypeTag(node)) { declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); } else if (ts.isBlockOrCatchScoped(node)) { @@ -43275,7 +44742,7 @@ var ts; } } function bindParameter(node) { - if (node.kind === 326 /* JSDocParameterTag */ && container.kind !== 313 /* JSDocSignature */) { + if (node.kind === 334 /* JSDocParameterTag */ && container.kind !== 317 /* JSDocSignature */) { return; } if (inStrictMode && !(node.flags & 8388608 /* Ambient */)) { @@ -43352,7 +44819,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } } - else if (node.parent.kind === 185 /* InferType */) { + else if (node.parent.kind === 187 /* InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { @@ -43371,7 +44838,7 @@ var ts; // reachability checks function shouldReportErrorOnModuleDeclaration(node) { var instanceState = getModuleInstanceState(node); - return instanceState === 1 /* Instantiated */ || (instanceState === 2 /* ConstEnumOnly */ && !!options.preserveConstEnums); + return instanceState === 1 /* Instantiated */ || (instanceState === 2 /* ConstEnumOnly */ && ts.shouldPreserveConstEnums(options)); } function checkUnreachable(node) { if (!(currentFlow.flags & 1 /* Unreachable */)) { @@ -43380,11 +44847,11 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 231 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 233 /* EmptyStatement */) || // report error on class declarations - node.kind === 252 /* ClassDeclaration */ || + node.kind === 254 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 256 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); + (node.kind === 258 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -43428,12 +44895,12 @@ var ts; } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: return true; - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return getModuleInstanceState(s) !== 1 /* Instantiated */; - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: return ts.hasSyntacticModifier(s, 2048 /* Const */); default: return false; @@ -43633,7 +45100,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 === 176 /* TypeQuery */) { + if (d.type && d.type.kind === 178 /* TypeQuery */) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); @@ -43803,15 +45270,6 @@ var ts; CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions"; CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp"; })(CheckMode || (CheckMode = {})); - var AccessFlags; - (function (AccessFlags) { - AccessFlags[AccessFlags["None"] = 0] = "None"; - AccessFlags[AccessFlags["NoIndexSignatures"] = 1] = "NoIndexSignatures"; - AccessFlags[AccessFlags["Writing"] = 2] = "Writing"; - AccessFlags[AccessFlags["CacheSymbol"] = 4] = "CacheSymbol"; - AccessFlags[AccessFlags["NoTupleBoundsCheck"] = 8] = "NoTupleBoundsCheck"; - AccessFlags[AccessFlags["ExpressionPosition"] = 16] = "ExpressionPosition"; - })(AccessFlags || (AccessFlags = {})); var SignatureCheckMode; (function (SignatureCheckMode) { SignatureCheckMode[SignatureCheckMode["BivariantCallback"] = 1] = "BivariantCallback"; @@ -43860,6 +45318,7 @@ var ts; DeclarationMeaning[DeclarationMeaning["SetAccessor"] = 2] = "SetAccessor"; DeclarationMeaning[DeclarationMeaning["PropertyAssignment"] = 4] = "PropertyAssignment"; DeclarationMeaning[DeclarationMeaning["Method"] = 8] = "Method"; + DeclarationMeaning[DeclarationMeaning["PrivateStatic"] = 16] = "PrivateStatic"; DeclarationMeaning[DeclarationMeaning["GetOrSetAccessor"] = 3] = "GetOrSetAccessor"; DeclarationMeaning[DeclarationMeaning["PropertyAssignmentOrMethod"] = 12] = "PropertyAssignmentOrMethod"; })(DeclarationMeaning || (DeclarationMeaning = {})); @@ -43951,21 +45410,24 @@ var ts; var instantiationCount = 0; var instantiationDepth = 0; var currentNode; - var typeCatalog = []; // NB: id is index + 1 var emptySymbols = ts.createSymbolTable(); var arrayVariances = [1 /* Covariant */]; var compilerOptions = host.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var moduleKind = ts.getEmitModuleKind(compilerOptions); + var useDefineForClassFields = ts.getUseDefineForClassFields(compilerOptions); var allowSyntheticDefaultImports = ts.getAllowSyntheticDefaultImports(compilerOptions); var strictNullChecks = ts.getStrictOptionValue(compilerOptions, "strictNullChecks"); var strictFunctionTypes = ts.getStrictOptionValue(compilerOptions, "strictFunctionTypes"); var strictBindCallApply = ts.getStrictOptionValue(compilerOptions, "strictBindCallApply"); var strictPropertyInitialization = ts.getStrictOptionValue(compilerOptions, "strictPropertyInitialization"); + var strictOptionalProperties = ts.getStrictOptionValue(compilerOptions, "strictOptionalProperties"); var noImplicitAny = ts.getStrictOptionValue(compilerOptions, "noImplicitAny"); var noImplicitThis = ts.getStrictOptionValue(compilerOptions, "noImplicitThis"); + var useUnknownInCatchVariables = ts.getStrictOptionValue(compilerOptions, "useUnknownInCatchVariables"); var keyofStringsOnly = !!compilerOptions.keyofStringsOnly; - var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 32768 /* FreshLiteral */; + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 16384 /* FreshLiteral */; + var checkBinaryExpression = createCheckBinaryExpression(); var emitResolver = createResolver(); var nodeBuilder = createNodeBuilder(); var globals = ts.createSymbolTable(); @@ -43988,7 +45450,6 @@ var ts; getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); }, getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); }, getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount") + symbolCount; }, - getTypeCatalog: function () { return typeCatalog; }, getTypeCount: function () { return typeCount; }, getInstantiationCount: function () { return totalInstantiationCount; }, getRelationCacheSizes: function () { return ({ @@ -44152,6 +45613,7 @@ var ts; return node && getContextualTypeForJsxAttribute(node); }, isContextSensitive: isContextSensitive, + getTypeOfPropertyOfContextualType: getTypeOfPropertyOfContextualType, getFullyQualifiedName: getFullyQualifiedName, getResolvedSignature: function (node, candidatesOutArray, argumentCount) { return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 0 /* Normal */); @@ -44195,6 +45657,7 @@ var ts; }, tryGetMemberInModuleExports: function (name, symbol) { return tryGetMemberInModuleExports(ts.escapeLeadingUnderscores(name), symbol); }, tryGetMemberInModuleExportsAndProperties: function (name, symbol) { return tryGetMemberInModuleExportsAndProperties(ts.escapeLeadingUnderscores(name), symbol); }, + tryFindAmbientModule: function (moduleName) { return tryFindAmbientModule(moduleName, /*withAugmentations*/ true); }, tryFindAmbientModuleWithoutAugmentations: function (moduleName) { // we deliberately exclude augmentations // since we are only interested in declarations of the module itself @@ -44313,6 +45776,7 @@ var ts; var templateLiteralTypes = new ts.Map(); var stringMappingTypes = new ts.Map(); var substitutionTypes = new ts.Map(); + var subtypeReductionCache = new ts.Map(); var evolvingArrayTypes = []; var undefinedProperties = new ts.Map(); var unknownSymbol = createSymbol(4 /* Property */, "unknown"); @@ -44321,14 +45785,15 @@ var ts; var autoType = createIntrinsicType(1 /* Any */, "any"); var wildcardType = createIntrinsicType(1 /* Any */, "any"); var errorType = createIntrinsicType(1 /* Any */, "error"); - var nonInferrableAnyType = createIntrinsicType(1 /* Any */, "any", 524288 /* ContainsWideningType */); + var nonInferrableAnyType = createIntrinsicType(1 /* Any */, "any", 131072 /* ContainsWideningType */); var intrinsicMarkerType = createIntrinsicType(1 /* Any */, "intrinsic"); var unknownType = createIntrinsicType(2 /* Unknown */, "unknown"); var undefinedType = createIntrinsicType(32768 /* Undefined */, "undefined"); - var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* Undefined */, "undefined", 524288 /* ContainsWideningType */); + var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* Undefined */, "undefined", 131072 /* ContainsWideningType */); var optionalType = createIntrinsicType(32768 /* Undefined */, "undefined"); + var missingType = strictOptionalProperties ? createIntrinsicType(32768 /* Undefined */, "undefined") : undefinedType; var nullType = createIntrinsicType(65536 /* Null */, "null"); - var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* Null */, "null", 524288 /* ContainsWideningType */); + var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* Null */, "null", 131072 /* ContainsWideningType */); var stringType = createIntrinsicType(4 /* String */, "string"); var numberType = createIntrinsicType(8 /* Number */, "number"); var bigintType = createIntrinsicType(64 /* BigInt */, "bigint"); @@ -44354,7 +45819,7 @@ var ts; var voidType = createIntrinsicType(16384 /* Void */, "void"); var neverType = createIntrinsicType(131072 /* Never */, "never"); var silentNeverType = createIntrinsicType(131072 /* Never */, "never"); - var nonInferrableType = createIntrinsicType(131072 /* Never */, "never", 2097152 /* NonInferrableType */); + var nonInferrableType = createIntrinsicType(131072 /* Never */, "never", 524288 /* NonInferrableType */); var implicitNeverType = createIntrinsicType(131072 /* Never */, "never"); var unreachableNeverType = createIntrinsicType(131072 /* Never */, "never"); var nonPrimitiveType = createIntrinsicType(67108864 /* NonPrimitive */, "object"); @@ -44366,7 +45831,7 @@ var ts; var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? wildcardType : t; }); var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var emptyJsxObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); - emptyJsxObjectType.objectFlags |= 4096 /* JsxAttributes */; + emptyJsxObjectType.objectFlags |= 2048 /* JsxAttributes */; var emptyTypeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); emptyTypeLiteralSymbol.members = ts.createSymbolTable(); var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); @@ -44375,7 +45840,7 @@ var ts; var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); // The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated // in getPropagatingFlagsOfTypes, and it is checked in inferFromTypes. - anyFunctionType.objectFlags |= 2097152 /* NonInferrableType */; + anyFunctionType.objectFlags |= 524288 /* NonInferrableType */; var noConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var circularConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var resolvingDefaultType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); @@ -44455,6 +45920,7 @@ var ts; // This allows users to just specify library files they want to used through --lib // and they will not get an error from not having unrelated library files var deferredGlobalESSymbolConstructorSymbol; + var deferredGlobalESSymbolConstructorTypeSymbol; var deferredGlobalESSymbolType; var deferredGlobalTypedPropertyDescriptorType; var deferredGlobalPromiseType; @@ -44506,7 +45972,7 @@ var ts; var flowNodePostSuper = []; var potentialThisCollisions = []; var potentialNewTargetCollisions = []; - var potentialWeakMapCollisions = []; + var potentialWeakMapSetCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); var suggestionDiagnostics = ts.createDiagnosticCollection(); @@ -44653,9 +46119,28 @@ var ts; } return diagnostic; } + function addDeprecatedSuggestionWorker(declarations, diagnostic) { + var deprecatedTag = Array.isArray(declarations) ? ts.forEach(declarations, ts.getJSDocDeprecatedTag) : ts.getJSDocDeprecatedTag(declarations); + if (deprecatedTag) { + ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(deprecatedTag, ts.Diagnostics.The_declaration_was_marked_as_deprecated_here)); + } + // We call `addRelatedInfo()` before adding the diagnostic to prevent duplicates. + suggestionDiagnostics.add(diagnostic); + return diagnostic; + } + function addDeprecatedSuggestion(location, declarations, deprecatedEntity) { + var diagnostic = ts.createDiagnosticForNode(location, ts.Diagnostics._0_is_deprecated, deprecatedEntity); + return addDeprecatedSuggestionWorker(declarations, diagnostic); + } + function addDeprecatedSuggestionWithSignature(location, declaration, deprecatedEntity, signatureString) { + var diagnostic = deprecatedEntity + ? ts.createDiagnosticForNode(location, ts.Diagnostics.The_signature_0_of_1_is_deprecated, signatureString, deprecatedEntity) + : ts.createDiagnosticForNode(location, ts.Diagnostics._0_is_deprecated, signatureString); + return addDeprecatedSuggestionWorker(declaration, diagnostic); + } function createSymbol(flags, name, checkFlags) { symbolCount++; - var symbol = (new Symbol(flags | 33554432 /* Transient */, name)); + var symbol = new Symbol(flags | 33554432 /* Transient */, name); symbol.checkFlags = checkFlags || 0; return symbol; } @@ -44766,7 +46251,7 @@ var ts; // as we will already report a "Declaration name conflicts..." error, and this error // won't make much sense. if (target !== globalThisSymbol) { - error(ts.getNameOfDeclaration(source.declarations[0]), ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); + error(source.declarations && ts.getNameOfDeclaration(source.declarations[0]), ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); } } else { // error @@ -44800,9 +46285,11 @@ var ts; } return target; function addDuplicateLocations(locs, symbol) { - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - ts.pushIfUnique(locs, decl); + if (symbol.declarations) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + ts.pushIfUnique(locs, decl); + } } } } @@ -44848,9 +46335,9 @@ var ts; }); } function mergeModuleAugmentation(moduleName) { - var _a, _b; + var _a, _b, _c; var moduleAugmentation = moduleName.parent; - if (moduleAugmentation.symbol.declarations[0] !== moduleAugmentation) { + if (((_a = moduleAugmentation.symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]) !== moduleAugmentation) { // this is a combined symbol for multiple augmentations within the same file. // its symbol already has accumulated information for all declarations // so we need to add it just once - do the work only for first declaration @@ -44887,11 +46374,11 @@ var ts; patternAmbientModuleAugmentations.set(moduleName.text, merged); } else { - if (((_a = mainModule_1.exports) === null || _a === void 0 ? void 0 : _a.get("__export" /* ExportStar */)) && ((_b = moduleAugmentation.symbol.exports) === null || _b === void 0 ? void 0 : _b.size)) { + 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)) { // 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 */); - for (var _i = 0, _c = ts.arrayFrom(moduleAugmentation.symbol.exports.entries()); _i < _c.length; _i++) { - var _d = _c[_i], key = _d[0], value = _d[1]; + 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)) { mergeSymbol(resolvedExports.get(key), value); } @@ -44932,7 +46419,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = new NodeLinks()); } function isGlobalSourceFile(node) { - return node.kind === 297 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 299 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -44991,17 +46478,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 === 198 /* BindingElement */) { + if (declaration.kind === 200 /* 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, 198 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 200 /* 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, 249 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 251 /* VariableDeclaration */), usage); } - else if (declaration.kind === 249 /* VariableDeclaration */) { + else if (declaration.kind === 251 /* VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -45015,7 +46502,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 !(compilerOptions.target === 99 /* ESNext */ && !!compilerOptions.useDefineForClassFields + return !(compilerOptions.target === 99 /* ESNext */ && useDefineForClassFields && ts.getContainingClass(declaration) === ts.getContainingClass(usage) && isUsedInFunctionOrInstanceProperty(usage, declaration)); } @@ -45031,19 +46518,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 === 270 /* ExportSpecifier */ || (usage.parent.kind === 266 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 272 /* ExportSpecifier */ || (usage.parent.kind === 268 /* 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 === 266 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 268 /* ExportAssignment */ && usage.isExportEquals) { return true; } if (!!(usage.flags & 4194304 /* JSDoc */) || isInTypeQuery(usage) || usageInTypeDeclaration()) { return true; } if (isUsedInFunctionOrInstanceProperty(usage, declaration)) { - if (compilerOptions.target === 99 /* ESNext */ && !!compilerOptions.useDefineForClassFields + if (compilerOptions.target === 99 /* ESNext */ && useDefineForClassFields && ts.getContainingClass(declaration) && (ts.isPropertyDeclaration(declaration) || ts.isParameterPropertyDeclaration(declaration, declaration.parent))) { return !isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, /*stopAtAnyPropertyDeclaration*/ true); @@ -45058,9 +46545,9 @@ var ts; } function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { switch (declaration.parent.parent.kind) { - case 232 /* VariableStatement */: - case 237 /* ForStatement */: - case 239 /* ForOfStatement */: + case 234 /* VariableStatement */: + case 239 /* ForStatement */: + case 241 /* 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)) { @@ -45081,16 +46568,16 @@ var ts; return true; } var initializerOfProperty = current.parent && - current.parent.kind === 163 /* PropertyDeclaration */ && + current.parent.kind === 165 /* PropertyDeclaration */ && current.parent.initializer === current; if (initializerOfProperty) { if (ts.hasSyntacticModifier(current.parent, 32 /* Static */)) { - if (declaration.kind === 165 /* MethodDeclaration */) { + if (declaration.kind === 167 /* MethodDeclaration */) { return true; } } else { - var isDeclarationInstanceProperty = declaration.kind === 163 /* PropertyDeclaration */ && !ts.hasSyntacticModifier(declaration, 32 /* Static */); + var isDeclarationInstanceProperty = declaration.kind === 165 /* PropertyDeclaration */ && !ts.hasSyntacticModifier(declaration, 32 /* Static */); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -45112,19 +46599,19 @@ var ts; return "quit"; } switch (node.kind) { - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return true; - case 163 /* PropertyDeclaration */: + case 165 /* 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 230 /* Block */: + case 232 /* Block */: switch (node.parent.kind) { - case 167 /* GetAccessor */: - case 165 /* MethodDeclaration */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 167 /* MethodDeclaration */: + case 170 /* SetAccessor */: return true; default: return false; @@ -45139,7 +46626,11 @@ var ts; function useOuterVariableScopeInParameter(result, location, lastLocation) { var target = ts.getEmitScriptTarget(compilerOptions); var functionLocation = location; - if (ts.isParameter(lastLocation) && functionLocation.body && result.valueDeclaration.pos >= functionLocation.body.pos && result.valueDeclaration.end <= functionLocation.body.end) { + if (ts.isParameter(lastLocation) + && functionLocation.body + && result.valueDeclaration + && result.valueDeclaration.pos >= functionLocation.body.pos + && result.valueDeclaration.end <= functionLocation.body.end) { // check for several cases where we introduce temporaries that require moving the name/initializer of the parameter to the body // - static field in a class expression // - optional chaining pre-es2020 @@ -45160,21 +46651,21 @@ var ts; } function requiresScopeChangeWorker(node) { switch (node.kind) { - case 209 /* ArrowFunction */: - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: - case 166 /* Constructor */: + case 211 /* ArrowFunction */: + case 210 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 168 /* Constructor */: // do not descend into these return false; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 288 /* PropertyAssignment */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 290 /* PropertyAssignment */: return requiresScopeChangeWorker(node.name); - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: // static properties in classes introduce temporary variables if (ts.hasStaticModifier(node)) { - return target < 99 /* ESNext */ || !compilerOptions.useDefineForClassFields; + return target < 99 /* ESNext */ || !useDefineForClassFields; } return requiresScopeChangeWorker(node.name); default: @@ -45203,6 +46694,7 @@ var ts; return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSymbol, suggestedNameNotFoundMessage); } function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, lookup, suggestedNameNotFoundMessage) { + var _a; var originalLocation = location; // needed for did-you-mean error reporting, which gathers candidates starting from the original location var result; var lastLocation; @@ -45225,12 +46717,12 @@ 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 !== 311 /* JSDocComment */) { + if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 314 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || - lastLocation.kind === 160 /* Parameter */ || - lastLocation.kind === 159 /* TypeParameter */ + lastLocation.kind === 162 /* Parameter */ || + lastLocation.kind === 161 /* TypeParameter */ // local types not visible outside the function body : false; } @@ -45245,13 +46737,13 @@ var ts; // however it is detected separately when checking initializers of parameters // to make sure that they reference no variables declared after them. useResult = - lastLocation.kind === 160 /* Parameter */ || + lastLocation.kind === 162 /* Parameter */ || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } } - else if (location.kind === 184 /* ConditionalType */) { + else if (location.kind === 186 /* 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; @@ -45266,14 +46758,14 @@ var ts; } withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation); switch (location.kind) { - case 297 /* SourceFile */: + case 299 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports || emptySymbols; - if (location.kind === 297 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 8388608 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) { + if (location.kind === 299 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 8388608 /* 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 */)) { @@ -45297,13 +46789,13 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 /* Alias */ && - (ts.getDeclarationOfKind(moduleExport, 270 /* ExportSpecifier */) || ts.getDeclarationOfKind(moduleExport, 269 /* NamespaceExport */))) { + (ts.getDeclarationOfKind(moduleExport, 272 /* ExportSpecifier */) || ts.getDeclarationOfKind(moduleExport, 271 /* 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 (ts.isSourceFile(location) && location.commonJsModuleIndicator && !result.declarations.some(ts.isJSDocTypeAlias)) { + if (ts.isSourceFile(location) && location.commonJsModuleIndicator && !((_a = result.declarations) === null || _a === void 0 ? void 0 : _a.some(ts.isJSDocTypeAlias))) { result = undefined; } else { @@ -45311,12 +46803,12 @@ var ts; } } break; - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 163 /* PropertyDeclaration */: + case 165 /* 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 @@ -45333,9 +46825,9 @@ var ts; } } break; - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* 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! @@ -45354,7 +46846,7 @@ var ts; } break loop; } - if (location.kind === 221 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 223 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -45362,9 +46854,9 @@ var ts; } } break; - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: // The type parameters of a class are not in scope in the base class expression. - if (lastLocation === location.expression && location.parent.token === 93 /* ExtendsKeyword */) { + if (lastLocation === location.expression && location.parent.token === 94 /* ExtendsKeyword */) { var container = location.parent.parent; if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968 /* Type */))) { if (nameNotFoundMessage) { @@ -45382,9 +46874,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 253 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 255 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -45392,24 +46884,24 @@ var ts; } } break; - case 209 /* ArrowFunction */: + case 211 /* 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 (compilerOptions.target >= 2 /* ES2015 */) { break; } // falls through - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 251 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 253 /* FunctionDeclaration */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -45422,7 +46914,7 @@ var ts; } } break; - case 161 /* Decorator */: + case 163 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -45431,7 +46923,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 === 160 /* Parameter */) { + if (location.parent && location.parent.kind === 162 /* Parameter */) { location = location.parent; } // @@ -45446,20 +46938,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 === 252 /* ClassDeclaration */)) { + if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 254 /* ClassDeclaration */)) { location = location.parent; } break; - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 325 /* JSDocEnumTag */: + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + case 333 /* 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 160 /* Parameter */: + case 162 /* Parameter */: if (lastLocation && (lastLocation === location.initializer || lastLocation === location.name && ts.isBindingPattern(lastLocation))) { if (!associatedDeclarationForContainingInitializerOrBindingName) { @@ -45467,7 +46959,7 @@ var ts; } } break; - case 198 /* BindingElement */: + case 200 /* BindingElement */: if (lastLocation && (lastLocation === location.initializer || lastLocation === location.name && ts.isBindingPattern(lastLocation))) { if (ts.isParameterDeclaration(location) && !associatedDeclarationForContainingInitializerOrBindingName) { @@ -45475,7 +46967,7 @@ var ts; } } break; - case 185 /* InferType */: + case 187 /* InferType */: if (meaning & 262144 /* TypeParameter */) { var parameterName = location.typeParameter.name; if (parameterName && name === parameterName.escapedText) { @@ -45499,7 +46991,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 297 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 299 /* SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -45528,6 +47020,10 @@ var ts; var suggestion = void 0; if (suggestedNameNotFoundMessage && suggestionCount < maximumSuggestionCount) { suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning); + var isGlobalScopeAugmentationDeclaration = suggestion && suggestion.valueDeclaration && ts.isAmbientModule(suggestion.valueDeclaration) && ts.isGlobalScopeAugmentation(suggestion.valueDeclaration); + if (isGlobalScopeAugmentationDeclaration) { + suggestion = undefined; + } if (suggestion) { var suggestionName = symbolToString(suggestion); var diagnostic = error(errorLocation, suggestedNameNotFoundMessage, diagnosticName(nameArg), suggestionName); @@ -45554,7 +47050,7 @@ var ts; } // Perform extra checks only if error reporting was requested if (nameNotFoundMessage) { - if (propertyWithInvalidInitializer && !(compilerOptions.target === 99 /* ESNext */ && compilerOptions.useDefineForClassFields)) { + if (propertyWithInvalidInitializer && !(compilerOptions.target === 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. @@ -45624,10 +47120,10 @@ var ts; } } function getIsDeferredContext(location, lastLocation) { - if (location.kind !== 209 /* ArrowFunction */ && location.kind !== 208 /* FunctionExpression */) { + if (location.kind !== 211 /* ArrowFunction */ && location.kind !== 210 /* 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 === 163 /* PropertyDeclaration */ && !ts.hasSyntacticModifier(location, 32 /* Static */))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred + (location.kind === 165 /* PropertyDeclaration */ && !ts.hasSyntacticModifier(location, 32 /* Static */))) && (!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; @@ -45640,12 +47136,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 256 /* ModuleDeclaration */: // For `namespace N { N; }` + case 253 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 257 /* EnumDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 258 /* ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -45655,12 +47151,14 @@ var ts; return ts.isString(nameArg) ? ts.unescapeLeadingUnderscores(nameArg) : ts.declarationNameToString(nameArg); } function isTypeParameterSymbolDeclaredInContainer(symbol, container) { - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - if (decl.kind === 159 /* 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)); // TODO: GH#18217 + if (symbol.declarations) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + if (decl.kind === 161 /* 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)); // TODO: GH#18217 + } } } } @@ -45712,10 +47210,10 @@ var ts; */ function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 78 /* Identifier */: - case 201 /* PropertyAccessExpression */: + case 79 /* Identifier */: + case 203 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -45759,7 +47257,7 @@ 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 === 270 /* ExportSpecifier */) { + if (isPrimitiveTypeName(name) && errorLocation.parent.kind === 272 /* ExportSpecifier */) { error(errorLocation, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, name); return true; } @@ -45828,13 +47326,14 @@ var ts; return false; } 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 */) { // constructor functions aren't block scoped return; } // Block-scoped variables cannot be used before their definition - var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 255 /* 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 === 257 /* EnumDeclaration */); }); if (declaration === undefined) return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration"); if (!(declaration.flags & 8388608 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { @@ -45851,7 +47350,7 @@ var ts; } else { ts.Debug.assert(!!(result.flags & 128 /* ConstEnum */)); - if (compilerOptions.preserveConstEnums) { + if (ts.shouldPreserveConstEnums(compilerOptions)) { diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName); } } @@ -45869,20 +47368,20 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return node; - case 262 /* ImportClause */: + case 264 /* ImportClause */: return node.parent; - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: return node.parent.parent; - case 265 /* ImportSpecifier */: + case 267 /* ImportSpecifier */: return node.parent.parent.parent; default: return undefined; } } function getDeclarationOfAliasSymbol(symbol) { - return ts.find(symbol.declarations, isAliasSymbolDeclaration); + return symbol.declarations && ts.findLast(symbol.declarations, isAliasSymbolDeclaration); } /** * An alias symbol is created by one of the following declarations: @@ -45897,25 +47396,26 @@ var ts; * module.exports = * {} * {name: } + * const { x } = require ... */ function isAliasSymbolDeclaration(node) { - return node.kind === 260 /* ImportEqualsDeclaration */ - || node.kind === 259 /* NamespaceExportDeclaration */ - || node.kind === 262 /* ImportClause */ && !!node.name - || node.kind === 263 /* NamespaceImport */ - || node.kind === 269 /* NamespaceExport */ - || node.kind === 265 /* ImportSpecifier */ - || node.kind === 270 /* ExportSpecifier */ - || node.kind === 266 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) + return node.kind === 262 /* ImportEqualsDeclaration */ + || node.kind === 261 /* NamespaceExportDeclaration */ + || node.kind === 264 /* ImportClause */ && !!node.name + || node.kind === 265 /* NamespaceImport */ + || node.kind === 271 /* NamespaceExport */ + || node.kind === 267 /* ImportSpecifier */ + || node.kind === 272 /* ExportSpecifier */ + || node.kind === 268 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) || ts.isBinaryExpression(node) && ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && ts.exportAssignmentIsAlias(node) || ts.isAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node - && node.parent.operatorToken.kind === 62 /* EqualsToken */ + && node.parent.operatorToken.kind === 63 /* EqualsToken */ && isAliasableOrJsExpression(node.parent.right) - || node.kind === 289 /* ShorthandPropertyAssignment */ - || node.kind === 288 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer) - || ts.isRequireVariableDeclaration(node, /*requireStringLiteralLikeArgument*/ true); + || node.kind === 291 /* ShorthandPropertyAssignment */ + || node.kind === 290 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer) + || ts.isRequireVariableDeclaration(node); } function isAliasableOrJsExpression(e) { return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e); @@ -45928,7 +47428,7 @@ var ts; ? resolveSymbol(getPropertyOfType(resolveExternalModuleTypeByLiteral(name), commonJSPropertyAccess.name.escapedText)) : undefined; } - if (ts.isVariableDeclaration(node) || node.moduleReference.kind === 272 /* ExternalModuleReference */) { + if (ts.isVariableDeclaration(node) || node.moduleReference.kind === 274 /* ExternalModuleReference */) { var immediate = resolveExternalModuleName(node, ts.getExternalModuleRequireArgument(node) || ts.getExternalModuleImportEqualsDeclarationExpression(node)); var resolved_4 = resolveExternalModuleSymbol(immediate); markSymbolOfAliasDeclarationIfTypeOnly(node, immediate, resolved_4, /*overwriteEmpty*/ false); @@ -45995,6 +47495,7 @@ var ts; return !file.externalModuleIndicator && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), /*sourceNode*/ undefined, dontResolveAlias); } function getTargetOfImportClause(node, dontResolveAlias) { + var _a; var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier); if (moduleSymbol) { var exportDefaultSymbol = void 0; @@ -46004,7 +47505,7 @@ var ts; else { exportDefaultSymbol = resolveExportByName(moduleSymbol, "default" /* Default */, node, dontResolveAlias); } - var file = ts.find(moduleSymbol.declarations, ts.isSourceFile); + var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); var hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias); if (!exportDefaultSymbol && !hasSyntheticDefault) { if (hasExportAssignmentSymbol(moduleSymbol)) { @@ -46012,7 +47513,9 @@ var ts; var exportEqualsSymbol = moduleSymbol.exports.get("export=" /* 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); - ts.addRelatedInfo(err, ts.createDiagnosticForNode(exportAssignment, ts.Diagnostics.This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag, compilerOptionName)); + if (exportAssignment) { + ts.addRelatedInfo(err, ts.createDiagnosticForNode(exportAssignment, ts.Diagnostics.This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag, compilerOptionName)); + } } else { reportNonDefaultExport(moduleSymbol, node); @@ -46029,7 +47532,7 @@ var ts; } } function reportNonDefaultExport(moduleSymbol, node) { - var _a, _b; + var _a, _b, _c; if ((_a = moduleSymbol.exports) === null || _a === void 0 ? void 0 : _a.has(node.symbol.escapedName)) { error(node.name, ts.Diagnostics.Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead, symbolToString(moduleSymbol), symbolToString(node.symbol)); } @@ -46037,7 +47540,7 @@ var ts; 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 */); if (exportStar) { - var defaultExport = ts.find(exportStar.declarations, function (decl) { + 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 */))); @@ -46115,7 +47618,7 @@ var ts; } } function getExternalModuleMember(node, specifier, dontResolveAlias) { - var _a; + var _a, _b; if (dontResolveAlias === void 0) { dontResolveAlias = false; } var moduleSpecifier = ts.getExternalModuleRequireArgument(node) || node.moduleSpecifier; var moduleSymbol = resolveExternalModuleName(node, moduleSpecifier); // TODO: GH#18217 @@ -46124,7 +47627,7 @@ var ts; return undefined; } var suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || compilerOptions.esModuleInterop); - var targetSymbol = resolveESModuleSymbol(moduleSymbol, moduleSpecifier, dontResolveAlias, suppressInteropError); + var targetSymbol = resolveESModuleSymbol(moduleSymbol, moduleSpecifier, /*dontResolveAlias*/ false, suppressInteropError); if (targetSymbol) { if (name.escapedText) { if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { @@ -46142,7 +47645,7 @@ var ts; symbolFromVariable = resolveSymbol(symbolFromVariable, dontResolveAlias); var symbolFromModule = getExportOfModule(targetSymbol, name, specifier, dontResolveAlias); if (symbolFromModule === undefined && name.escapedText === "default" /* Default */) { - var file = ts.find(moduleSymbol.declarations, ts.isSourceFile); + var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); if (canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias)) { symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias); } @@ -46162,7 +47665,7 @@ var ts; } } else { - if ((_a = moduleSymbol.exports) === null || _a === void 0 ? void 0 : _a.has("default" /* Default */)) { + if ((_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* 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 { @@ -46175,8 +47678,8 @@ var ts; } } function reportNonExportedMember(node, name, declarationName, moduleSymbol, moduleName) { - var _a; - var localSymbol = (_a = moduleSymbol.valueDeclaration.locals) === null || _a === void 0 ? void 0 : _a.get(name.escapedText); + var _a, _b; + 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 */); @@ -46188,9 +47691,11 @@ var ts; var exportedSymbol = exports ? ts.find(symbolsToArray(exports), function (symbol) { return !!getSymbolIfSameReference(symbol, localSymbol); }) : undefined; var diagnostic = exportedSymbol ? error(name, ts.Diagnostics.Module_0_declares_1_locally_but_it_is_exported_as_2, moduleName, declarationName, symbolToString(exportedSymbol)) : error(name, ts.Diagnostics.Module_0_declares_1_locally_but_it_is_not_exported, moduleName, declarationName); - ts.addRelatedInfo.apply(void 0, __spreadArray([diagnostic], ts.map(localSymbol.declarations, function (decl, index) { - return ts.createDiagnosticForNode(decl, index === 0 ? ts.Diagnostics._0_is_declared_here : ts.Diagnostics.and_here, declarationName); - }))); + if (localSymbol.declarations) { + ts.addRelatedInfo.apply(void 0, __spreadArray([diagnostic], ts.map(localSymbol.declarations, function (decl, index) { + return ts.createDiagnosticForNode(decl, index === 0 ? ts.Diagnostics._0_is_declared_here : ts.Diagnostics.and_here, declarationName); + }))); + } } } else { @@ -46269,7 +47774,7 @@ var ts; return getTargetOfAliasLikeExpression(expression, dontRecursivelyResolve); } function getTargetOfAccessExpression(node, dontRecursivelyResolve) { - if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62 /* EqualsToken */)) { + if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* EqualsToken */)) { return undefined; } return getTargetOfAliasLikeExpression(node.parent.right, dontRecursivelyResolve); @@ -46277,31 +47782,31 @@ var ts; function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 260 /* ImportEqualsDeclaration */: - case 249 /* VariableDeclaration */: + case 262 /* ImportEqualsDeclaration */: + case 251 /* VariableDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 262 /* ImportClause */: + case 264 /* ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 269 /* NamespaceExport */: + case 271 /* NamespaceExport */: return getTargetOfNamespaceExport(node, dontRecursivelyResolve); - case 265 /* ImportSpecifier */: - case 198 /* BindingElement */: + case 267 /* ImportSpecifier */: + case 200 /* BindingElement */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 270 /* ExportSpecifier */: + case 272 /* ExportSpecifier */: return getTargetOfExportSpecifier(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 266 /* ExportAssignment */: - case 216 /* BinaryExpression */: + case 268 /* ExportAssignment */: + case 218 /* BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 259 /* NamespaceExportDeclaration */: + case 261 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return resolveEntityName(node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve); - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: return getTargetOfPropertyAssignment(node, dontRecursivelyResolve); - case 202 /* ElementAccessExpression */: - case 201 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: return getTargetOfAccessExpression(node, dontRecursivelyResolve); default: return ts.Debug.fail(); @@ -46449,17 +47954,17 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 78 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 79 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 78 /* Identifier */ || entityName.parent.kind === 157 /* QualifiedName */) { + if (entityName.kind === 79 /* Identifier */ || entityName.parent.kind === 159 /* QualifiedName */) { return resolveEntityName(entityName, 1920 /* 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 === 260 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 262 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } @@ -46475,7 +47980,7 @@ var ts; } var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 111551 /* Value */ : 0); var symbol; - if (name.kind === 78 /* Identifier */) { + if (name.kind === 79 /* 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)); @@ -46483,9 +47988,9 @@ var ts; return getMergedSymbol(symbolFromJSPrototype); } } - else if (name.kind === 157 /* QualifiedName */ || name.kind === 201 /* PropertyAccessExpression */) { - var left = name.kind === 157 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 157 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 159 /* QualifiedName */ || name.kind === 203 /* PropertyAccessExpression */) { + var left = name.kind === 159 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 159 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -46493,18 +47998,17 @@ var ts; else if (namespace === unknownSymbol) { return namespace; } - if (ts.isInJSFile(name)) { - if (namespace.valueDeclaration && - ts.isVariableDeclaration(namespace.valueDeclaration) && - namespace.valueDeclaration.initializer && - isCommonJsRequire(namespace.valueDeclaration.initializer)) { - var moduleName = namespace.valueDeclaration.initializer.arguments[0]; - var moduleSym = resolveExternalModuleName(moduleName, moduleName); - if (moduleSym) { - var resolvedModuleSymbol = resolveExternalModuleSymbol(moduleSym); - if (resolvedModuleSymbol) { - namespace = resolvedModuleSymbol; - } + if (namespace.valueDeclaration && + ts.isInJSFile(namespace.valueDeclaration) && + ts.isVariableDeclaration(namespace.valueDeclaration) && + namespace.valueDeclaration.initializer && + isCommonJsRequire(namespace.valueDeclaration.initializer)) { + var moduleName = namespace.valueDeclaration.initializer.arguments[0]; + var moduleSym = resolveExternalModuleName(moduleName, moduleName); + if (moduleSym) { + var resolvedModuleSymbol = resolveExternalModuleSymbol(moduleSym); + if (resolvedModuleSymbol) { + namespace = resolvedModuleSymbol; } } } @@ -46525,7 +48029,7 @@ var ts; 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 === 266 /* ExportAssignment */)) { + if (!ts.nodeIsSynthesized(name) && ts.isEntityName(name) && (symbol.flags & 2097152 /* Alias */ || name.parent.kind === 268 /* ExportAssignment */)) { markSymbolOfAliasDeclarationIfTypeOnly(ts.getAliasDeclarationFromName(name), symbol, /*finalTarget*/ undefined, /*overwriteEmpty*/ true); } return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol); @@ -46762,7 +48266,7 @@ var ts; function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias, suppressInteropError) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!suppressInteropError && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 297 /* SourceFile */)) { + if (!suppressInteropError && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 299 /* SourceFile */)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; @@ -46813,7 +48317,10 @@ var ts; var exports = getExportsOfModuleAsArray(moduleSymbol); var exportEquals = resolveExternalModuleSymbol(moduleSymbol); if (exportEquals !== moduleSymbol) { - ts.addRange(exports, getPropertiesOfType(getTypeOfSymbol(exportEquals))); + var type = getTypeOfSymbol(exportEquals); + if (shouldTreatPropertiesOfExternalModuleAsExports(type)) { + ts.addRange(exports, getPropertiesOfType(type)); + } } return exports; } @@ -46833,11 +48340,14 @@ var ts; return undefined; } var type = getTypeOfSymbol(exportEquals); - return type.flags & 131068 /* Primitive */ || - ts.getObjectFlags(type) & 1 /* Class */ || - isArrayOrTupleLikeType(type) - ? undefined - : getPropertyOfType(type, memberName); + return shouldTreatPropertiesOfExternalModuleAsExports(type) ? getPropertyOfType(type, memberName) : undefined; + } + function shouldTreatPropertiesOfExternalModuleAsExports(resolvedExternalModuleType) { + return !(resolvedExternalModuleType.flags & 131068 /* Primitive */ || + ts.getObjectFlags(resolvedExternalModuleType) & 1 /* 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 */) : @@ -46895,11 +48405,13 @@ var ts; if (exportStars) { var nestedSymbols = ts.createSymbolTable(); var lookupTable_1 = new ts.Map(); - for (var _i = 0, _a = exportStars.declarations; _i < _a.length; _i++) { - var node = _a[_i]; - var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); - var exportedSymbols = visit(resolvedModule); - extendExportSymbols(nestedSymbols, exportedSymbols, lookupTable_1, node); + if (exportStars.declarations) { + for (var _i = 0, _a = exportStars.declarations; _i < _a.length; _i++) { + var node = _a[_i]; + var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); + var exportedSymbols = visit(resolvedModule); + extendExportSymbols(nestedSymbols, exportedSymbols, lookupTable_1, node); + } } lookupTable_1.forEach(function (_a, id) { var exportsWithDuplicate = _a.exportsWithDuplicate; @@ -46982,17 +48494,34 @@ var ts; var additionalContainers = ts.mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer); var reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration); var objectLiteralContainer = getVariableDeclarationOfObjectLiteral(container, meaning); - if (enclosingDeclaration && getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* Namespace */, /*externalOnly*/ false)) { + if (enclosingDeclaration && + container.flags & getQualifiedLeftMeaning(meaning) && + getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* 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 } - var res = ts.append(ts.append(additionalContainers, container), objectLiteralContainer); - return ts.concatenate(res, reexportContainers); + // 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 */ + ? forEachSymbolTableInScope(enclosingDeclaration, function (t) { + return ts.forEachEntry(t, function (s) { + if (s.flags & getQualifiedLeftMeaning(meaning) && getTypeOfSymbol(s) === getDeclaredTypeOfSymbol(container)) { + return s; + } + }); + }) : undefined; + var res = firstVariableMatch ? __spreadArray(__spreadArray([firstVariableMatch], additionalContainers), [container]) : __spreadArray(__spreadArray([], additionalContainers), [container]); + res = ts.append(res, objectLiteralContainer); + res = ts.addRange(res, reexportContainers); + return res; } var candidates = ts.mapDefined(symbol.declarations, function (d) { if (!ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent)) { return getSymbolOfNode(d.parent); } - if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 62 /* 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 /* 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)); } @@ -47064,7 +48593,7 @@ var ts; var members = node.members; for (var _i = 0, members_3 = members; _i < members_3.length; _i++) { var member = members_3[_i]; - if (member.kind === 166 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 168 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -47073,7 +48602,9 @@ var ts; var result = new Type(checker, flags); typeCount++; result.id = typeCount; - typeCatalog.push(result); + if (produceDiagnostics) { // Only record types from one checker + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.recordType(result); + } return result; } function createOriginType(flags) { @@ -47133,14 +48664,23 @@ var ts; }); return result || ts.emptyArray; } + function getNamedOrIndexSignatureMembers(members) { + var result = getNamedMembers(members); + var index = getIndexSymbolFromSymbolTable(members); + return index ? ts.concatenate(result, [index]) : result; + } function setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { - type.members = members; - type.properties = members === emptySymbols ? ts.emptyArray : getNamedMembers(members); - type.callSignatures = callSignatures; - type.constructSignatures = constructSignatures; - type.stringIndexInfo = stringIndexInfo; - type.numberIndexInfo = numberIndexInfo; - return type; + var resolved = type; + resolved.members = members; + resolved.properties = ts.emptyArray; + resolved.callSignatures = callSignatures; + resolved.constructSignatures = constructSignatures; + resolved.stringIndexInfo = stringIndexInfo; + resolved.numberIndexInfo = numberIndexInfo; + // This can loop back to getPropertyOfType() which would crash if `callSignatures` & `constructSignatures` are not initialized. + if (members !== emptySymbols) + resolved.properties = getNamedMembers(members); + return resolved; } function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { return setStructuredTypeMembers(createObjectType(16 /* Anonymous */, symbol), members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); @@ -47163,28 +48703,28 @@ var ts; var _loop_8 = function (location) { // Locals of a source file are not in scope (because they get merged into the global symbol table) if (location.locals && !isGlobalSourceFile(location)) { - if (result = callback(location.locals)) { + if (result = callback(location.locals, /*ignoreQualification*/ undefined, /*isLocalNameLookup*/ true, location)) { return { value: result }; } } switch (location.kind) { - case 297 /* SourceFile */: + case 299 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 256 /* ModuleDeclaration */: + case 258 /* 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 // to one another anyway) - if (result = callback((sym === null || sym === void 0 ? void 0 : sym.exports) || emptySymbols)) { + if (result = callback((sym === null || sym === void 0 ? void 0 : sym.exports) || emptySymbols, /*ignoreQualification*/ undefined, /*isLocalNameLookup*/ true, location)) { return { value: result }; } break; - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* 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 @@ -47199,7 +48739,7 @@ var ts; (table_1 || (table_1 = ts.createSymbolTable())).set(key, memberSymbol); } }); - if (table_1 && (result = callback(table_1))) { + if (table_1 && (result = callback(table_1, /*ignoreQualification*/ undefined, /*isLocalNameLookup*/ false, location))) { return { value: result }; } break; @@ -47210,7 +48750,7 @@ var ts; if (typeof state_2 === "object") return state_2.value; } - return callback(globals); + return callback(globals, /*ignoreQualification*/ undefined, /*isLocalNameLookup*/ true); } function getQualifiedLeftMeaning(rightMeaning) { // If we are looking in value space, the parent meaning is value, other wise it is namespace @@ -47221,20 +48761,30 @@ var ts; if (!(symbol && !isPropertyOrMethodDeclarationSymbol(symbol))) { return undefined; } + var links = getSymbolLinks(symbol); + 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; + if (cache.has(key)) { + return cache.get(key); + } var id = getSymbolId(symbol); var visitedSymbolTables = visitedSymbolTablesMap.get(id); if (!visitedSymbolTables) { visitedSymbolTablesMap.set(id, visitedSymbolTables = []); } - return forEachSymbolTableInScope(enclosingDeclaration, getAccessibleSymbolChainFromSymbolTable); + var result = forEachSymbolTableInScope(enclosingDeclaration, getAccessibleSymbolChainFromSymbolTable); + cache.set(key, result); + return result; /** * @param {ignoreQualification} boolean Set when a symbol is being looked for through the exports of another symbol (meaning we have a route to qualify it already) */ - function getAccessibleSymbolChainFromSymbolTable(symbols, ignoreQualification) { + function getAccessibleSymbolChainFromSymbolTable(symbols, ignoreQualification, isLocalNameLookup) { if (!ts.pushIfUnique(visitedSymbolTables, symbols)) { return undefined; } - var result = trySymbolTable(symbols, ignoreQualification); + var result = trySymbolTable(symbols, ignoreQualification, isLocalNameLookup); visitedSymbolTables.pop(); return result; } @@ -47252,7 +48802,7 @@ var ts; !ts.some(symbolFromSymbolTable.declarations, hasNonGlobalAugmentationExternalModuleSymbol) && (ignoreQualification || canQualifySymbol(getMergedSymbol(symbolFromSymbolTable), meaning)); } - function trySymbolTable(symbols, ignoreQualification) { + function trySymbolTable(symbols, ignoreQualification, isLocalNameLookup) { // If symbol is directly available by its name in the symbol table if (isAccessible(symbols.get(symbol.escapedName), /*resolvedAliasSymbol*/ undefined, ignoreQualification)) { return [symbol]; @@ -47265,9 +48815,11 @@ var ts; && !(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)) + // If we're looking up a local name to reference directly, omit namespace reexports, otherwise when we're trawling through an export list to make a dotted name, we can keep it + && (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, 270 /* ExportSpecifier */))) { + && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 272 /* ExportSpecifier */))) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); var candidate = getCandidateListForSymbol(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification); if (candidate) { @@ -47311,7 +48863,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, 270 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 272 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -47326,10 +48878,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 163 /* PropertyDeclaration */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: continue; default: return false; @@ -47367,7 +48919,7 @@ var ts; return hasAccessibleDeclarations; } } - else if (allowModules) { + if (allowModules) { if (ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { if (shouldComputeAliasesToMakeVisible) { earlyModuleBail = true; @@ -47441,7 +48993,8 @@ var ts; return { accessibility: 2 /* CannotBeNamed */, errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning), - errorModuleName: symbolToString(symbolExternalModule) + errorModuleName: symbolToString(symbolExternalModule), + errorNode: ts.isInJSFile(enclosingDeclaration) ? enclosingDeclaration : undefined, }; } } @@ -47458,14 +49011,14 @@ var ts; return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 297 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 299 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 297 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 299 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; - if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 78 /* Identifier */; }), getIsDeclarationVisible)) { + if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 79 /* Identifier */; }), getIsDeclarationVisible)) { return undefined; } return { accessibility: 0 /* Accessible */, aliasesToMakeVisible: aliasesToMakeVisible }; @@ -47517,14 +49070,14 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 176 /* TypeQuery */ || + if (entityName.parent.kind === 178 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) || - entityName.parent.kind === 158 /* ComputedPropertyName */) { + entityName.parent.kind === 160 /* ComputedPropertyName */) { // Typeof value meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 157 /* QualifiedName */ || entityName.kind === 201 /* PropertyAccessExpression */ || - entityName.parent.kind === 260 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 159 /* QualifiedName */ || entityName.kind === 203 /* PropertyAccessExpression */ || + entityName.parent.kind === 262 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -47565,7 +49118,7 @@ var ts; 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) === 297 /* SourceFile */ ? ts.createPrinter({ removeComments: true, neverAsciiEscape: true }) : ts.createPrinter({ removeComments: true }); + var printer = (enclosingDeclaration === null || enclosingDeclaration === void 0 ? void 0 : enclosingDeclaration.kind) === 299 /* 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); return writer; @@ -47577,10 +49130,10 @@ var ts; function signatureToStringWorker(writer) { var sigOutput; if (flags & 262144 /* WriteArrowStyleSignature */) { - sigOutput = kind === 1 /* Construct */ ? 175 /* ConstructorType */ : 174 /* FunctionType */; + sigOutput = kind === 1 /* Construct */ ? 177 /* ConstructorType */ : 176 /* FunctionType */; } else { - sigOutput = kind === 1 /* Construct */ ? 170 /* ConstructSignature */ : 169 /* CallSignature */; + sigOutput = kind === 1 /* Construct */ ? 172 /* ConstructSignature */ : 171 /* CallSignature */; } var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); @@ -47620,14 +49173,14 @@ var ts; return typeToString(type, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */); } function symbolValueDeclarationIsContextSensitive(symbol) { - return symbol && symbol.valueDeclaration && ts.isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration); + 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 */; } function isClassInstanceSide(type) { - return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || !!(ts.getObjectFlags(type) & 1073741824 /* IsClassInstanceClone */)); + return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288 /* Object */) && !!(ts.getObjectFlags(type) & 16777216 /* IsClassInstanceClone */))); } function createNodeBuilder() { return { @@ -47666,7 +49219,7 @@ var ts; enclosingDeclaration: enclosingDeclaration, flags: flags || 0 /* None */, // If no full tracker is provided, fake up a dummy one with a basic limited-functionality moduleResolverHost - tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: ts.noop, moduleResolverHost: flags & 134217728 /* DoNotIncludeSymbolChain */ ? { + tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: function () { return false; }, moduleResolverHost: flags & 134217728 /* DoNotIncludeSymbolChain */ ? { getCommonSourceDirectory: !!host.getCommonSourceDirectory ? function () { return host.getCommonSourceDirectory(); } : function () { return ""; }, getSourceFiles: function () { return host.getSourceFiles(); }, getCurrentDirectory: function () { return host.getCurrentDirectory(); }, @@ -47679,17 +49232,46 @@ var ts; getFileIncludeReasons: function () { return host.getFileIncludeReasons(); }, } : undefined }, encounteredError: false, + reportedDiagnostic: false, visitedTypes: undefined, symbolDepth: undefined, inferTypeParameters: undefined, approximateLength: 0 }; + context.tracker = wrapSymbolTrackerToReportForContext(context, context.tracker); var resultingNode = cb(context); if (context.truncating && context.flags & 1 /* 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; } + function wrapSymbolTrackerToReportForContext(context, tracker) { + var oldTrackSymbol = tracker.trackSymbol; + return __assign(__assign({}, tracker), { reportCyclicStructureError: wrapReportedDiagnostic(tracker.reportCyclicStructureError), reportInaccessibleThisError: wrapReportedDiagnostic(tracker.reportInaccessibleThisError), reportInaccessibleUniqueSymbolError: wrapReportedDiagnostic(tracker.reportInaccessibleUniqueSymbolError), reportLikelyUnsafeImportRequiredError: wrapReportedDiagnostic(tracker.reportLikelyUnsafeImportRequiredError), reportNonlocalAugmentation: wrapReportedDiagnostic(tracker.reportNonlocalAugmentation), reportPrivateInBaseOfClassExpression: wrapReportedDiagnostic(tracker.reportPrivateInBaseOfClassExpression), trackSymbol: oldTrackSymbol && (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var result = oldTrackSymbol.apply(void 0, args); + if (result) { + context.reportedDiagnostic = true; + } + return result; + }) }); + function wrapReportedDiagnostic(method) { + if (!method) { + return method; + } + return (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + context.reportedDiagnostic = true; + return method.apply(void 0, args); + }); + } + } function checkTruncationLength(context) { if (context.truncating) return context.truncating; @@ -47707,33 +49289,33 @@ var ts; return undefined; // TODO: GH#18217 } context.approximateLength += 3; - return ts.factory.createKeywordTypeNode(128 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(129 /* AnyKeyword */); } if (!(context.flags & 536870912 /* NoTypeReduction */)) { type = getReducedType(type); } if (type.flags & 1 /* Any */) { context.approximateLength += 3; - return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 136 /* IntrinsicKeyword */ : 128 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 137 /* IntrinsicKeyword */ : 129 /* AnyKeyword */); } if (type.flags & 2 /* Unknown */) { - return ts.factory.createKeywordTypeNode(152 /* UnknownKeyword */); + return ts.factory.createKeywordTypeNode(153 /* UnknownKeyword */); } if (type.flags & 4 /* String */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(147 /* StringKeyword */); + return ts.factory.createKeywordTypeNode(148 /* StringKeyword */); } if (type.flags & 8 /* Number */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(144 /* NumberKeyword */); + return ts.factory.createKeywordTypeNode(145 /* NumberKeyword */); } if (type.flags & 64 /* BigInt */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(155 /* BigIntKeyword */); + return ts.factory.createKeywordTypeNode(156 /* BigIntKeyword */); } if (type.flags & 16 /* Boolean */) { context.approximateLength += 7; - return ts.factory.createKeywordTypeNode(131 /* BooleanKeyword */); + return ts.factory.createKeywordTypeNode(132 /* BooleanKeyword */); } if (type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */)) { var parentSymbol = getParentOfSymbol(type.symbol); @@ -47787,15 +49369,15 @@ var ts; } } context.approximateLength += 13; - return ts.factory.createTypeOperatorNode(151 /* UniqueKeyword */, ts.factory.createKeywordTypeNode(148 /* SymbolKeyword */)); + return ts.factory.createTypeOperatorNode(152 /* UniqueKeyword */, ts.factory.createKeywordTypeNode(149 /* SymbolKeyword */)); } if (type.flags & 16384 /* Void */) { context.approximateLength += 4; - return ts.factory.createKeywordTypeNode(113 /* VoidKeyword */); + return ts.factory.createKeywordTypeNode(114 /* VoidKeyword */); } if (type.flags & 32768 /* Undefined */) { context.approximateLength += 9; - return ts.factory.createKeywordTypeNode(150 /* UndefinedKeyword */); + return ts.factory.createKeywordTypeNode(151 /* UndefinedKeyword */); } if (type.flags & 65536 /* Null */) { context.approximateLength += 4; @@ -47803,15 +49385,15 @@ var ts; } if (type.flags & 131072 /* Never */) { context.approximateLength += 5; - return ts.factory.createKeywordTypeNode(141 /* NeverKeyword */); + return ts.factory.createKeywordTypeNode(142 /* NeverKeyword */); } if (type.flags & 4096 /* ESSymbol */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(148 /* SymbolKeyword */); + return ts.factory.createKeywordTypeNode(149 /* SymbolKeyword */); } if (type.flags & 67108864 /* NonPrimitive */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(145 /* ObjectKeyword */); + return ts.factory.createKeywordTypeNode(146 /* ObjectKeyword */); } if (isThisTypeParameter(type)) { if (context.flags & 4194304 /* InObjectTypeLiteral */) { @@ -47881,7 +49463,7 @@ var ts; var indexedType = type.type; context.approximateLength += 6; var indexTypeNode = typeToTypeNodeHelper(indexedType, context); - return ts.factory.createTypeOperatorNode(138 /* KeyOfKeyword */, indexTypeNode); + return ts.factory.createTypeOperatorNode(139 /* KeyOfKeyword */, indexTypeNode); } if (type.flags & 134217728 /* TemplateLiteral */) { var texts_1 = type.texts; @@ -47938,14 +49520,14 @@ 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` - appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(138 /* KeyOfKeyword */, typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context)); + appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(139 /* KeyOfKeyword */, 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(getTemplateTypeFromMappedType(type), context); + var templateTypeNode = typeToTypeNodeHelper(removeMissingType(getTemplateTypeFromMappedType(type), !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), context); var mappedTypeNode = ts.factory.createMappedTypeNode(readonlyToken, typeParameterNode, nameTypeNode, questionToken, templateTypeNode); context.approximateLength += 10; return ts.setEmitFlags(mappedTypeNode, 1 /* SingleLine */); @@ -47961,7 +49543,9 @@ var ts; return symbolToTypeNode(symbol, context, isInstanceType); } // Always use 'typeof T' for type of class, enum, and module objects - else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 221 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || + else if (symbol.flags & 32 /* Class */ + && !getBaseTypeVariableOfClass(symbol) + && !(symbol.valueDeclaration && symbol.valueDeclaration.kind === 223 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, isInstanceType); @@ -47992,7 +49576,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 297 /* SourceFile */ || declaration.parent.kind === 257 /* ModuleBlock */; + return declaration.parent.kind === 299 /* SourceFile */ || declaration.parent.kind === 259 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -48002,6 +49586,7 @@ var ts; } } 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) : @@ -48015,6 +49600,19 @@ var ts; if (id && !context.symbolDepth) { context.symbolDepth = new ts.Map(); } + var links = context.enclosingDeclaration && getNodeLinks(context.enclosingDeclaration); + var key = getTypeId(type) + "|" + context.flags; + if (links) { + links.serializedTypes || (links.serializedTypes = new ts.Map()); + } + var cachedResult = (_a = links === null || links === void 0 ? void 0 : links.serializedTypes) === null || _a === void 0 ? void 0 : _a.get(key); + if (cachedResult) { + if (cachedResult.truncating) { + context.truncating = true; + } + context.approximateLength += cachedResult.addedLength; + return deepCloneOrReuseNode(cachedResult); + } var depth; if (id) { depth = context.symbolDepth.get(id) || 0; @@ -48024,12 +49622,27 @@ var ts; context.symbolDepth.set(id, depth + 1); } context.visitedTypes.add(typeId); + var startLength = context.approximateLength; var result = transform(type); + var addedLength = context.approximateLength - startLength; + if (!context.reportedDiagnostic && !context.encounteredError) { + if (context.truncating) { + result.truncating = true; + } + result.addedLength = addedLength; + (_b = links === null || links === void 0 ? void 0 : links.serializedTypes) === null || _b === void 0 ? void 0 : _b.set(key, result); + } context.visitedTypes.delete(typeId); if (id) { context.symbolDepth.set(id, depth); } return result; + function deepCloneOrReuseNode(node) { + if (!ts.nodeIsSynthesized(node) && ts.getParseTreeNode(node) === node) { + return node; + } + return ts.setTextRange(ts.factory.cloneNode(ts.visitEachChild(node, deepCloneOrReuseNode, ts.nullTransformationContext)), node); + } } function createTypeNodeFromObjectType(type) { if (isGenericMappedType(type) || type.containsError) { @@ -48043,12 +49656,12 @@ var ts; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 174 /* FunctionType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 176 /* FunctionType */, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 175 /* ConstructorType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 177 /* ConstructorType */, context); return signatureNode; } } @@ -48092,9 +49705,10 @@ var ts; } var elementType = typeToTypeNodeHelper(typeArguments[0], context); var arrayType = ts.factory.createArrayTypeNode(elementType); - return type.target === globalArrayType ? arrayType : ts.factory.createTypeOperatorNode(142 /* ReadonlyKeyword */, arrayType); + return type.target === globalArrayType ? arrayType : ts.factory.createTypeOperatorNode(143 /* 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 */)); }); if (typeArguments.length > 0) { var arity = getTypeReferenceArity(type); var tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, arity), context); @@ -48116,12 +49730,12 @@ var ts; } } var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode(tupleConstituentNodes), 1 /* SingleLine */); - return type.target.readonly ? ts.factory.createTypeOperatorNode(142 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + return type.target.readonly ? ts.factory.createTypeOperatorNode(143 /* 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(142 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + return type.target.readonly ? ts.factory.createTypeOperatorNode(143 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } context.encounteredError = true; return undefined; // TODO: GH#18217 @@ -48228,17 +49842,17 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 169 /* CallSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 171 /* CallSignature */, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; if (signature.flags & 4 /* Abstract */) continue; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 170 /* ConstructSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 172 /* ConstructSignature */, context)); } if (resolvedType.stringIndexInfo) { var indexSignature = void 0; - if (resolvedType.objectFlags & 2048 /* ReverseMapped */) { + if (resolvedType.objectFlags & 1024 /* ReverseMapped */) { indexSignature = indexInfoToIndexSignatureDeclarationHelper(createIndexInfo(anyType, resolvedType.stringIndexInfo.isReadonly, resolvedType.stringIndexInfo.declaration), 0 /* String */, context, createElidedInformationPlaceholder(context)); } else { @@ -48280,17 +49894,31 @@ var ts; if (!(context.flags & 1 /* NoTruncation */)) { return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier("..."), /*typeArguments*/ undefined); } - return ts.factory.createKeywordTypeNode(128 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(129 /* AnyKeyword */); + } + function shouldUsePlaceholderForProperty(propertySymbol, context) { + var _a; + // Use placeholders for reverse mapped types we've either already descended into, or which + // are nested reverse mappings within a mapping over a non-anonymous type. The later is a restriction mostly just to + // reduce the blowup in printback size from doing, eg, a deep reverse mapping over `Window`. + // 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 */) + && (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 */))); } function addPropertyToElementList(propertySymbol, context, typeElements) { + var _a; var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */); - var propertyType = propertyIsReverseMapped && context.flags & 33554432 /* InReverseMappedType */ ? - anyType : getTypeOfSymbol(propertySymbol); + var propertyType = shouldUsePlaceholderForProperty(propertySymbol, context) ? + anyType : getNonMissingTypeOfSymbol(propertySymbol); var saveEnclosingDeclaration = context.enclosingDeclaration; context.enclosingDeclaration = undefined; if (context.tracker.trackSymbol && ts.getCheckFlags(propertySymbol) & 4096 /* Late */ && isLateBoundName(propertySymbol.escapedName)) { var decl = ts.first(propertySymbol.declarations); - if (hasLateBindableName(decl)) { + if (propertySymbol.declarations && hasLateBindableName(decl)) { if (ts.isBinaryExpression(decl)) { var name = ts.getNameOfDeclaration(decl); if (name && ts.isElementAccessExpression(name) && ts.isPropertyAccessEntityNameExpression(name.argumentExpression)) { @@ -48302,30 +49930,35 @@ var ts; } } } - context.enclosingDeclaration = saveEnclosingDeclaration; + context.enclosingDeclaration = propertySymbol.valueDeclaration || ((_a = propertySymbol.declarations) === null || _a === void 0 ? void 0 : _a[0]) || saveEnclosingDeclaration; 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 */); for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { var signature = signatures_1[_i]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 164 /* MethodSignature */, context, { name: propertyName, questionToken: optionalToken }); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 166 /* MethodSignature */, context, { name: propertyName, questionToken: optionalToken }); typeElements.push(preserveCommentsOn(methodDeclaration)); } } else { - var savedFlags = context.flags; - context.flags |= propertyIsReverseMapped ? 33554432 /* InReverseMappedType */ : 0; var propertyTypeNode = void 0; - if (propertyIsReverseMapped && !!(savedFlags & 33554432 /* InReverseMappedType */)) { + if (shouldUsePlaceholderForProperty(propertySymbol, context)) { propertyTypeNode = createElidedInformationPlaceholder(context); } else { - propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.factory.createKeywordTypeNode(128 /* AnyKeyword */); + if (propertyIsReverseMapped) { + context.reverseMappedStack || (context.reverseMappedStack = []); + context.reverseMappedStack.push(propertySymbol); + } + propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.factory.createKeywordTypeNode(129 /* AnyKeyword */); + if (propertyIsReverseMapped) { + context.reverseMappedStack.pop(); + } } - context.flags = savedFlags; - var modifiers = isReadonlySymbol(propertySymbol) ? [ts.factory.createToken(142 /* ReadonlyKeyword */)] : undefined; + var modifiers = isReadonlySymbol(propertySymbol) ? [ts.factory.createToken(143 /* ReadonlyKeyword */)] : undefined; if (modifiers) { context.approximateLength += 9; } @@ -48333,9 +49966,10 @@ var ts; typeElements.push(preserveCommentsOn(propertySignature)); } function preserveCommentsOn(node) { - if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 333 /* JSDocPropertyTag */; })) { - var d = ts.find(propertySymbol.declarations, function (d) { return d.kind === 333 /* JSDocPropertyTag */; }); - var commentText = d.comment; + var _a; + if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 341 /* JSDocPropertyTag */; })) { + var d = (_a = propertySymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 341 /* 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 }]); } @@ -48364,25 +49998,25 @@ var ts; var mayHaveNameCollisions = !(context.flags & 64 /* 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_4 = []; + var result_5 = []; var i = 0; for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { var type = types_2[_i]; i++; if (checkTruncationLength(context) && (i + 2 < types.length - 1)) { - result_4.push(ts.factory.createTypeReferenceNode("... " + (types.length - i) + " more ...", /*typeArguments*/ undefined)); + result_5.push(ts.factory.createTypeReferenceNode("... " + (types.length - i) + " more ...", /*typeArguments*/ undefined)); var typeNode_1 = typeToTypeNodeHelper(types[types.length - 1], context); if (typeNode_1) { - result_4.push(typeNode_1); + result_5.push(typeNode_1); } break; } context.approximateLength += 2; // Account for whitespace + separator var typeNode = typeToTypeNodeHelper(type, context); if (typeNode) { - result_4.push(typeNode); + result_5.push(typeNode); if (seenNames && ts.isIdentifierTypeReference(typeNode)) { - seenNames.add(typeNode.typeName.escapedText, [type, result_4.length - 1]); + seenNames.add(typeNode.typeName.escapedText, [type, result_5.length - 1]); } } } @@ -48404,13 +50038,13 @@ var ts; })) { for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { var _a = types_3[_i], type = _a[0], resultIndex = _a[1]; - result_4[resultIndex] = typeToTypeNodeHelper(type, context); + result_5[resultIndex] = typeToTypeNodeHelper(type, context); } } }); context.flags = saveContextFlags; } - return result_4; + return result_5; } } function typesAreSameReference(a, b) { @@ -48420,7 +50054,7 @@ var ts; } function indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context, typeNode) { var name = ts.getNameFromIndexInfo(indexInfo) || "x"; - var indexerTypeNode = ts.factory.createKeywordTypeNode(kind === 0 /* String */ ? 147 /* StringKeyword */ : 144 /* NumberKeyword */); + var indexerTypeNode = ts.factory.createKeywordTypeNode(kind === 0 /* String */ ? 148 /* StringKeyword */ : 145 /* NumberKeyword */); var indexingParameter = ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -48435,13 +50069,14 @@ var ts; } context.approximateLength += (name.length + 4); return ts.factory.createIndexSignature( - /*decorators*/ undefined, indexInfo.isReadonly ? [ts.factory.createToken(142 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); + /*decorators*/ undefined, indexInfo.isReadonly ? [ts.factory.createToken(143 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); } function signatureToSignatureDeclarationHelper(signature, kind, context, options) { var _a, _b, _c, _d; var suppressAny = context.flags & 256 /* SuppressAnyReturnType */; if (suppressAny) context.flags &= ~256 /* 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) { @@ -48452,7 +50087,7 @@ 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 === 166 /* Constructor */, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); }); + 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 === 168 /* Constructor */, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -48461,7 +50096,7 @@ var ts; var typePredicate = getTypePredicateOfSignature(signature); if (typePredicate) { var assertsModifier = typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? - ts.factory.createToken(127 /* AssertsKeyword */) : + ts.factory.createToken(128 /* AssertsKeyword */) : undefined; var parameterName = typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.setEmitFlags(ts.factory.createIdentifier(typePredicate.parameterName), 16777216 /* NoAsciiEscaping */) : @@ -48475,29 +50110,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(128 /* AnyKeyword */); + returnTypeNode = ts.factory.createKeywordTypeNode(129 /* AnyKeyword */); } } var modifiers = options === null || options === void 0 ? void 0 : options.modifiers; - if ((kind === 175 /* ConstructorType */) && signature.flags & 4 /* Abstract */) { + if ((kind === 177 /* ConstructorType */) && signature.flags & 4 /* Abstract */) { var flags = ts.modifiersToFlags(modifiers); modifiers = ts.factory.createModifiersFromModifierFlags(flags | 128 /* Abstract */); } - context.approximateLength += 3; // Usually a signature contributes a few more characters than this, but 3 is the minimum - var node = kind === 169 /* CallSignature */ ? ts.factory.createCallSignature(typeParameters, parameters, returnTypeNode) : - kind === 170 /* ConstructSignature */ ? ts.factory.createConstructSignature(typeParameters, parameters, returnTypeNode) : - kind === 164 /* 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 === 165 /* MethodDeclaration */ ? ts.factory.createMethodDeclaration(/*decorators*/ undefined, 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 === 166 /* Constructor */ ? ts.factory.createConstructorDeclaration(/*decorators*/ undefined, modifiers, parameters, /*body*/ undefined) : - kind === 167 /* GetAccessor */ ? ts.factory.createGetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_c = options === null || options === void 0 ? void 0 : options.name) !== null && _c !== void 0 ? _c : ts.factory.createIdentifier(""), parameters, returnTypeNode, /*body*/ undefined) : - kind === 168 /* SetAccessor */ ? ts.factory.createSetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_d = options === null || options === void 0 ? void 0 : options.name) !== null && _d !== void 0 ? _d : ts.factory.createIdentifier(""), parameters, /*body*/ undefined) : - kind === 171 /* IndexSignature */ ? ts.factory.createIndexSignature(/*decorators*/ undefined, modifiers, parameters, returnTypeNode) : - kind === 308 /* JSDocFunctionType */ ? ts.factory.createJSDocFunctionType(parameters, returnTypeNode) : - kind === 174 /* FunctionType */ ? ts.factory.createFunctionTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : - kind === 175 /* ConstructorType */ ? ts.factory.createConstructorTypeNode(modifiers, typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : - kind === 251 /* FunctionDeclaration */ ? ts.factory.createFunctionDeclaration(/*decorators*/ undefined, 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 === 208 /* 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 === 209 /* ArrowFunction */ ? ts.factory.createArrowFunction(modifiers, typeParameters, parameters, returnTypeNode, /*equalsGreaterThanToken*/ undefined, ts.factory.createBlock([])) : + var node = kind === 171 /* CallSignature */ ? ts.factory.createCallSignature(typeParameters, parameters, returnTypeNode) : + kind === 172 /* ConstructSignature */ ? ts.factory.createConstructSignature(typeParameters, parameters, returnTypeNode) : + kind === 166 /* 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 === 167 /* MethodDeclaration */ ? ts.factory.createMethodDeclaration(/*decorators*/ undefined, 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 === 168 /* Constructor */ ? ts.factory.createConstructorDeclaration(/*decorators*/ undefined, modifiers, parameters, /*body*/ undefined) : + kind === 169 /* GetAccessor */ ? ts.factory.createGetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_c = options === null || options === void 0 ? void 0 : options.name) !== null && _c !== void 0 ? _c : ts.factory.createIdentifier(""), parameters, returnTypeNode, /*body*/ undefined) : + kind === 170 /* SetAccessor */ ? ts.factory.createSetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_d = options === null || options === void 0 ? void 0 : options.name) !== null && _d !== void 0 ? _d : ts.factory.createIdentifier(""), parameters, /*body*/ undefined) : + kind === 173 /* IndexSignature */ ? ts.factory.createIndexSignature(/*decorators*/ undefined, modifiers, parameters, returnTypeNode) : + kind === 311 /* JSDocFunctionType */ ? ts.factory.createJSDocFunctionType(parameters, returnTypeNode) : + kind === 176 /* FunctionType */ ? ts.factory.createFunctionTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : + kind === 177 /* ConstructorType */ ? ts.factory.createConstructorTypeNode(modifiers, typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : + kind === 253 /* FunctionDeclaration */ ? ts.factory.createFunctionDeclaration(/*decorators*/ undefined, 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 === 210 /* 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 === 211 /* 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); @@ -48519,9 +50153,9 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags, privateSymbolVisitor, bundledImports) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 160 /* Parameter */); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 162 /* Parameter */); if (!parameterDeclaration && !ts.isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 326 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 334 /* JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -48535,8 +50169,8 @@ var ts; var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* RestParameter */; var dotDotDotToken = isRest ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined; var name = parameterDeclaration ? parameterDeclaration.name ? - parameterDeclaration.name.kind === 78 /* Identifier */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : - parameterDeclaration.name.kind === 157 /* QualifiedName */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 79 /* Identifier */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 159 /* QualifiedName */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : cloneBindingName(parameterDeclaration.name) : ts.symbolName(parameterSymbol) : ts.symbolName(parameterSymbol); @@ -48701,11 +50335,11 @@ var ts; } function getSpecifierForModuleSymbol(symbol, context) { var _a; - var file = ts.getDeclarationOfKind(symbol, 297 /* SourceFile */); + var file = ts.getDeclarationOfKind(symbol, 299 /* SourceFile */); if (!file) { var equivalentFileSymbol = ts.firstDefined(symbol.declarations, function (d) { return getFileSymbolIfFileSymbolExportEqualsContainer(d, symbol); }); if (equivalentFileSymbol) { - file = ts.getDeclarationOfKind(equivalentFileSymbol, 297 /* SourceFile */); + file = ts.getDeclarationOfKind(equivalentFileSymbol, 299 /* SourceFile */); } } if (file && file.moduleName !== undefined) { @@ -48716,8 +50350,8 @@ var ts; if (context.tracker.trackReferencedAmbientModule) { var ambientDecls = ts.filter(symbol.declarations, ts.isAmbientModule); if (ts.length(ambientDecls)) { - for (var _i = 0, ambientDecls_1 = ambientDecls; _i < ambientDecls_1.length; _i++) { - var decl = ambientDecls_1[_i]; + for (var _i = 0, _b = ambientDecls; _i < _b.length; _i++) { + var decl = _b[_i]; context.tracker.trackReferencedAmbientModule(decl, symbol); } } @@ -48744,7 +50378,7 @@ var ts; // specifier preference var moduleResolverHost = context.tracker.moduleResolverHost; var specifierCompilerOptions = isBundle_1 ? __assign(__assign({}, compilerOptions), { baseUrl: moduleResolverHost.getCommonSourceDirectory() }) : compilerOptions; - specifier = ts.first(ts.moduleSpecifiers.getModuleSpecifiers(symbol, checker, specifierCompilerOptions, contextFile, moduleResolverHost, { importModuleSpecifierPreference: isBundle_1 ? "non-relative" : "relative", importModuleSpecifierEnding: isBundle_1 ? "minimal" : undefined })); + specifier = ts.first(ts.moduleSpecifiers.getModuleSpecifiers(symbol, checker, specifierCompilerOptions, contextFile, moduleResolverHost, { importModuleSpecifierPreference: isBundle_1 ? "non-relative" : "project-relative", importModuleSpecifierEnding: isBundle_1 ? "minimal" : undefined })); (_a = links.specifierCache) !== null && _a !== void 0 ? _a : (links.specifierCache = new ts.Map()); links.specifierCache.set(contextFile.path, specifier); } @@ -48857,7 +50491,7 @@ var ts; return false; } function typeParameterToName(type, context) { - var _a; + var _a, _b; if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && context.typeParameterNames) { var cached = context.typeParameterNames.get(getTypeId(type)); if (cached) { @@ -48865,22 +50499,25 @@ var ts; } } var result = symbolToName(type.symbol, context, 788968 /* Type */, /*expectsIdentifier*/ true); - if (!(result.kind & 78 /* Identifier */)) { + if (!(result.kind & 79 /* Identifier */)) { return ts.factory.createIdentifier("(Missing type parameter)"); } if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { var rawtext = result.escapedText; - var i = 0; + var i = ((_a = context.typeParameterNamesByTextNextNameCount) === null || _a === void 0 ? void 0 : _a.get(rawtext)) || 0; var text = rawtext; - while (((_a = context.typeParameterNamesByText) === null || _a === void 0 ? void 0 : _a.has(text)) || typeParameterShadowsNameInScope(text, context, type)) { + while (((_b = context.typeParameterNamesByText) === null || _b === void 0 ? void 0 : _b.has(text)) || typeParameterShadowsNameInScope(text, context, type)) { i++; text = rawtext + "_" + i; } if (text !== rawtext) { result = ts.factory.createIdentifier(text, result.typeArguments); } + // avoiding iterations of the above loop turns out to be worth it when `i` starts to get large, so we cache the max + // `i` we've used thus far, to save work later + (context.typeParameterNamesByTextNextNameCount || (context.typeParameterNamesByTextNextNameCount = new ts.Map())).set(rawtext, i); (context.typeParameterNames || (context.typeParameterNames = new ts.Map())).set(getTypeId(type), result); - (context.typeParameterNamesByText || (context.typeParameterNamesByText = new ts.Set())).add(result.escapedText); + (context.typeParameterNamesByText || (context.typeParameterNamesByText = new ts.Set())).add(rawtext); } return result; } @@ -48888,7 +50525,7 @@ var ts; var chain = lookupSymbolChain(symbol, context, meaning); if (expectsIdentifier && chain.length !== 1 && !context.encounteredError - && !(context.flags & 65536 /* AllowQualifedNameInPlaceOfIdentifier */)) { + && !(context.flags & 65536 /* AllowQualifiedNameInPlaceOfIdentifier */)) { context.encounteredError = true; } return createEntityNameFromSymbolChain(chain, chain.length - 1); @@ -48968,9 +50605,6 @@ var ts; if (fromNameType) { return fromNameType; } - if (ts.isKnownSymbol(symbol)) { - return ts.factory.createComputedPropertyName(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("Symbol"), symbol.escapedName.substr(3))); - } var rawName = ts.unescapeLeadingUnderscores(symbol.escapedName); var stringNamed = !!ts.length(symbol.declarations) && ts.every(symbol.declarations, isStringNamed); return createPropertyNameNodeForIdentifierOrLiteral(rawName, stringNamed, singleQuote); @@ -49022,6 +50656,7 @@ var ts; if (initial.typeParameterSymbolList) { initial.typeParameterSymbolList = new ts.Set(initial.typeParameterSymbolList); } + initial.tracker = wrapSymbolTrackerToReportForContext(initial, initial.tracker); return initial; } function getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration) { @@ -49037,13 +50672,13 @@ var ts; function serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled) { if (type !== errorType && enclosingDeclaration) { var declWithExistingAnnotation = getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration); - if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation)) { + if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation) && !ts.isGetAccessorDeclaration(declWithExistingAnnotation)) { // try to reuse the existing annotation var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation); if (getTypeFromTypeNode(existing) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) { - var result_5 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled); - if (result_5) { - return result_5; + var result_6 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled); + if (result_6) { + return result_6; } } } @@ -49060,10 +50695,14 @@ var ts; function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) { if (type !== errorType && context.enclosingDeclaration) { var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); - if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation && instantiateType(getTypeFromTypeNode(annotation), signature.mapper) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) { - var result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled); - if (result) { - return result; + 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; + if (thisInstantiated === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) { + var result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled); + if (result) { + return result; + } } } } @@ -49107,17 +50746,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 === 310 /* JSDocNamepathType */) { - return ts.factory.createKeywordTypeNode(128 /* AnyKeyword */); + if (ts.isJSDocAllType(node) || node.kind === 313 /* JSDocNamepathType */) { + return ts.factory.createKeywordTypeNode(129 /* AnyKeyword */); } if (ts.isJSDocUnknownType(node)) { - return ts.factory.createKeywordTypeNode(152 /* UnknownKeyword */); + return ts.factory.createKeywordTypeNode(153 /* 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(150 /* UndefinedKeyword */)]); + return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createKeywordTypeNode(151 /* UndefinedKeyword */)]); } if (ts.isJSDocNonNullableType(node)) { return ts.visitNode(node.type, visitExistingNodeTreeSymbols); @@ -49131,11 +50770,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(128 /* AnyKeyword */)); + /*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(129 /* AnyKeyword */)); })); } if (ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "") { - return ts.setOriginalNode(ts.factory.createKeywordTypeNode(128 /* AnyKeyword */), node); + return ts.setOriginalNode(ts.factory.createKeywordTypeNode(129 /* AnyKeyword */), node); } if ((ts.isExpressionWithTypeArguments(node) || ts.isTypeReferenceNode(node)) && ts.isJSDocIndexSignature(node)) { return ts.factory.createTypeLiteralNode([ts.factory.createIndexSignature( @@ -49152,13 +50791,13 @@ var ts; return ts.factory.createConstructorTypeNode(node.modifiers, 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( /*decorators*/ undefined, /*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(128 /* AnyKeyword */)); + /*initializer*/ undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(129 /* AnyKeyword */)); } else { return ts.factory.createFunctionTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.map(node.parameters, function (p, i) { return ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, getEffectiveDotDotDotForParameter(p), getNameForJSDocFunctionParameter(p, i), p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), - /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(128 /* AnyKeyword */)); + /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(129 /* AnyKeyword */)); } } if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(getTypeReferenceName(node), 788968 /* Type */, /*ignoreErrors*/ true))) { @@ -49226,8 +50865,8 @@ var ts; } } function symbolTableToDeclarationStatements(symbolTable, context, bundled) { - var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.factory.createPropertyDeclaration, 165 /* MethodDeclaration */, /*useAcessors*/ true); - var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type) { return ts.factory.createPropertySignature(mods, name, question, type); }, 164 /* MethodSignature */, /*useAcessors*/ false); + var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.factory.createPropertyDeclaration, 167 /* MethodDeclaration */, /*useAcessors*/ true); + var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type) { return ts.factory.createPropertySignature(mods, name, question, type); }, 166 /* 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 @@ -49239,7 +50878,7 @@ var ts; var deferredPrivatesStack = []; 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); + var accessibleResult = isSymbolAccessible(sym, decl, meaning, /*computeAliases*/ false); if (accessibleResult.accessibility === 0 /* 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); @@ -49248,9 +50887,11 @@ var ts; } } else if (oldcontext.tracker && oldcontext.tracker.trackSymbol) { - oldcontext.tracker.trackSymbol(sym, decl, meaning); + return oldcontext.tracker.trackSymbol(sym, decl, meaning); } + return false; } }) }); + context.tracker = wrapSymbolTrackerToReportForContext(context, context.tracker); ts.forEachEntry(symbolTable, function (symbol, name) { var baseName = ts.unescapeLeadingUnderscores(name); void getInternalSymbolName(symbol, baseName); // Called to cache values into `usedSymbolNames` and `remappedSymbolNames` @@ -49265,7 +50906,7 @@ var ts; visitSymbolTable(symbolTable); return mergeRedundantStatements(results); function isIdentifierAndNotUndefined(node) { - return !!node && node.kind === 78 /* Identifier */; + return !!node && node.kind === 79 /* Identifier */; } function getNamesOfDeclaration(statement) { if (ts.isVariableStatement(statement)) { @@ -49434,6 +51075,9 @@ var ts; var oldContext = context; context = cloneNodeBuilderContext(context); var result = serializeSymbolWorker(symbol, isPrivate, propertyAsAlias); + if (context.reportedDiagnostic) { + oldcontext.reportedDiagnostic = context.reportedDiagnostic; // hoist diagnostic result into outer context + } context = oldContext; return result; } @@ -49448,6 +51092,7 @@ var ts; // If it's a class/interface/function: emit a class/interface/function with a `default` modifier // These forms can merge, eg (`export default 12; export default interface A {}`) function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias) { + var _a, _b; var symbolName = ts.unescapeLeadingUnderscores(symbol.escapedName); var isDefault = symbol.escapedName === "default" /* Default */; if (isPrivate && !(context.flags & 131072 /* AllowAnonymousIdentifier */) && ts.isStringANonContextualKeyword(symbolName) && !isDefault) { @@ -49506,9 +51151,9 @@ var ts; if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) { textRange = textRange.parent.parent; } - var propertyAccessRequire = ts.find(symbol.declarations, ts.isPropertyAccessExpression); + var propertyAccessRequire = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isPropertyAccessExpression); if (propertyAccessRequire && ts.isBinaryExpression(propertyAccessRequire.parent) && ts.isIdentifier(propertyAccessRequire.parent.right) - && type.symbol && ts.isSourceFile(type.symbol.valueDeclaration)) { + && ((_b = type.symbol) === null || _b === void 0 ? void 0 : _b.valueDeclaration) && ts.isSourceFile(type.symbol.valueDeclaration)) { var alias = localName === propertyAccessRequire.parent.right.escapedText ? undefined : propertyAccessRequire.parent.right; addResult(ts.factory.createExportDeclaration( /*decorators*/ undefined, @@ -49558,7 +51203,10 @@ var ts; serializeEnum(symbol, symbolName, modifierFlags); } if (symbol.flags & 32 /* Class */) { - if (symbol.flags & 4 /* Property */ && ts.isBinaryExpression(symbol.valueDeclaration.parent) && ts.isClassExpression(symbol.valueDeclaration.parent.right)) { + if (symbol.flags & 4 /* Property */ + && symbol.valueDeclaration + && ts.isBinaryExpression(symbol.valueDeclaration.parent) + && ts.isClassExpression(symbol.valueDeclaration.parent.right)) { // Looks like a `module.exports.Sub = class {}` - if we serialize `symbol` as a class, the result will have no members, // since the classiness is actually from the target of the effective alias the symbol is. yes. A BlockScopedVariable|Class|Property // _really_ acts like an Alias, and none of a BlockScopedVariable, Class, or Property. This is the travesty of JS binding today. @@ -49584,12 +51232,14 @@ var ts; if (symbol.flags & 8388608 /* ExportStar */) { // synthesize export * from "moduleReference" // Straightforward - only one thing to do - make an export declaration - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var node = _a[_i]; - var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); - if (!resolvedModule) - continue; - addResult(ts.factory.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, /*exportClause*/ undefined, ts.factory.createStringLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0 /* None */); + if (symbol.declarations) { + for (var _i = 0, _c = symbol.declarations; _i < _c.length; _i++) { + var node = _c[_i]; + var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); + if (!resolvedModule) + continue; + addResult(ts.factory.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, /*exportClause*/ undefined, ts.factory.createStringLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0 /* None */); + } } } if (needsPostExportDefault) { @@ -49627,15 +51277,16 @@ var ts; function addResult(node, additionalModifierFlags) { if (ts.canHaveModifiers(node)) { var newModifierFlags = 0 /* None */; + var enclosingDeclaration_1 = context.enclosingDeclaration && + (ts.isJSDocTypeAlias(context.enclosingDeclaration) ? ts.getSourceFileOfNode(context.enclosingDeclaration) : context.enclosingDeclaration); if (additionalModifierFlags & 1 /* Export */ && - context.enclosingDeclaration && - (isExportingScope(context.enclosingDeclaration) || ts.isModuleDeclaration(context.enclosingDeclaration)) && + 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 */; } if (addingDeclare && !(newModifierFlags & 1 /* Export */) && - (!context.enclosingDeclaration || !(context.enclosingDeclaration.flags & 8388608 /* Ambient */)) && + (!enclosingDeclaration_1 || !(enclosingDeclaration_1.flags & 8388608 /* 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 */; @@ -49650,19 +51301,23 @@ var ts; results.push(node); } function serializeTypeAlias(symbol, symbolName, modifierFlags) { + var _a; var aliasType = getDeclaredTypeOfTypeAlias(symbol); var typeParams = getSymbolLinks(symbol).typeParameters; var typeParamDecls = ts.map(typeParams, function (p) { return typeParameterToDeclaration(p, context); }); - var jsdocAliasDecl = ts.find(symbol.declarations, ts.isJSDocTypeAlias); - var commentText = jsdocAliasDecl ? jsdocAliasDecl.comment || jsdocAliasDecl.parent.comment : undefined; + 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 */; + 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(/*decorators*/ undefined, /*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); context.flags = oldFlags; + context.enclosingDeclaration = oldEnclosingDecl; } function serializeInterface(symbol, symbolName, modifierFlags) { var interfaceType = getDeclaredTypeOfClassOrInterface(symbol); @@ -49671,10 +51326,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, 169 /* CallSignature */); - var constructSignatures = serializeSignatures(1 /* Construct */, interfaceType, baseType, 170 /* ConstructSignature */); + var callSignatures = serializeSignatures(0 /* Call */, interfaceType, baseType, 171 /* CallSignature */); + var constructSignatures = serializeSignatures(1 /* Construct */, interfaceType, baseType, 172 /* ConstructSignature */); var indexSignatures = serializeIndexSignatures(interfaceType, baseType); - var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.factory.createHeritageClause(93 /* ExtendsKeyword */, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b, 111551 /* Value */); }))]; + var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.factory.createHeritageClause(94 /* ExtendsKeyword */, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b, 111551 /* Value */); }))]; addResult(ts.factory.createInterfaceDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, heritageClauses, __spreadArray(__spreadArray(__spreadArray(__spreadArray([], indexSignatures), constructSignatures), callSignatures), members)), modifierFlags); @@ -49741,9 +51396,8 @@ var ts; 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, 251 /* FunctionDeclaration */, context, { name: ts.factory.createIdentifier(localName), privateSymbolVisitor: includePrivateSymbol, bundledImports: bundled }); - // for expressions assigned to `var`s, use the `var` as the text range - addResult(ts.setTextRange(decl, sig.declaration && ts.isVariableDeclaration(sig.declaration.parent) && sig.declaration.parent.parent || sig.declaration), modifierFlags); + var decl = signatureToSignatureDeclarationHelper(sig, 253 /* 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)) { @@ -49751,6 +51405,18 @@ var ts; 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 */) { + return signature.declaration.parent; + } + // for expressions assigned to `var`s, use the `var` as the text range + if (ts.isVariableDeclaration(signature.declaration.parent) && signature.declaration.parent.parent) { + return signature.declaration.parent.parent; + } + } + return signature.declaration; + } function serializeAsNamespaceDeclaration(props, localName, modifierFlags, suppressNewPrivateContext) { if (ts.length(props)) { var localVsRemoteMap = ts.arrayToMultiMap(props, function (p) { @@ -49837,8 +51503,8 @@ var ts; return undefined; } function serializeAsClass(symbol, localName, modifierFlags) { - var _a; - var originalDecl = ts.find(symbol.declarations, ts.isClassLike); + var _a, _b; + var originalDecl = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isClassLike); var oldEnclosing = context.enclosingDeclaration; context.enclosingDeclaration = originalDecl || oldEnclosing; var localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -49849,25 +51515,25 @@ var ts; var implementsExpressions = originalImplements && sanitizeJSDocImplements(originalImplements) || ts.mapDefined(getImplementsTypes(classType), serializeImplementedType); var staticType = getTypeOfSymbol(symbol); - var isClass = !!((_a = staticType.symbol) === null || _a === void 0 ? void 0 : _a.valueDeclaration) && ts.isClassLike(staticType.symbol.valueDeclaration); + var isClass = !!((_b = staticType.symbol) === null || _b === void 0 ? void 0 : _b.valueDeclaration) && ts.isClassLike(staticType.symbol.valueDeclaration); var staticBaseType = isClass ? getBaseConstructorTypeOfClass(staticType) : anyType; - var heritageClauses = __spreadArray(__spreadArray([], !ts.length(baseTypes) ? [] : [ts.factory.createHeritageClause(93 /* ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))]), !ts.length(implementsExpressions) ? [] : [ts.factory.createHeritageClause(116 /* ImplementsKeyword */, implementsExpressions)]); + var heritageClauses = __spreadArray(__spreadArray([], !ts.length(baseTypes) ? [] : [ts.factory.createHeritageClause(94 /* ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))]), !ts.length(implementsExpressions) ? [] : [ts.factory.createHeritageClause(117 /* ImplementsKeyword */, implementsExpressions)]); var symbolProps = getNonInterhitedProperties(classType, baseTypes, getPropertiesOfType(classType)); var publicSymbolProps = ts.filter(symbolProps, function (s) { // `valueDeclaration` could be undefined if inherited from // a union/intersection base type, but inherited properties // don't matter here. var valueDecl = s.valueDeclaration; - return valueDecl && !(ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name)); + return !!valueDecl && !(ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name)); }); var hasPrivateIdentifier = ts.some(symbolProps, function (s) { // `valueDeclaration` could be undefined if inherited from // a union/intersection base type, but inherited properties // don't matter here. var valueDecl = s.valueDeclaration; - return valueDecl && ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name); + return !!valueDecl && ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name); }); // Boil down all private properties into a single one. var privateProperties = hasPrivateIdentifier ? @@ -49890,7 +51556,7 @@ var ts; !ts.some(getSignaturesOfType(staticType, 1 /* Construct */)); var constructors = isNonConstructableClassLikeInJsFile ? [ts.factory.createConstructorDeclaration(/*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(8 /* Private */), [], /*body*/ undefined)] : - serializeSignatures(1 /* Construct */, staticType, staticBaseType, 166 /* Constructor */); + serializeSignatures(1 /* Construct */, staticType, staticBaseType, 168 /* Constructor */); var indexSignatures = serializeIndexSignatures(classType, baseTypes[0]); context.enclosingDeclaration = oldEnclosing; addResult(ts.setTextRange(ts.factory.createClassDeclaration( @@ -49917,8 +51583,8 @@ var ts; var targetName = getInternalSymbolName(target, verbatimTargetName); includePrivateSymbol(target); // the target may be within the same scope - attempt to serialize it first switch (node.kind) { - case 198 /* BindingElement */: - if (((_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.kind) === 249 /* VariableDeclaration */) { + case 200 /* BindingElement */: + if (((_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.kind) === 251 /* VariableDeclaration */) { // const { SomeClass } = require('./lib'); var specifier_1 = getSpecifierForModuleSymbol(target.parent || target, context); // './lib' var propertyName = node.propertyName; @@ -49930,13 +51596,13 @@ var ts; // 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 289 /* ShorthandPropertyAssignment */: - if (((_e = (_d = node.parent) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.kind) === 216 /* BinaryExpression */) { + case 291 /* ShorthandPropertyAssignment */: + if (((_e = (_d = node.parent) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.kind) === 218 /* BinaryExpression */) { // module.exports = { SomeClass } serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), targetName); } break; - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: // commonjs require: const x = require('y') if (ts.isPropertyAccessExpression(node.initializer)) { // const x = require('y').z @@ -49956,7 +51622,7 @@ var ts; break; } // else fall through and treat commonjs require just like import= - case 260 /* ImportEqualsDeclaration */: + case 262 /* 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)) { @@ -49973,13 +51639,13 @@ var ts; ? symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false) : ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)))), isLocalImport ? modifierFlags : 0 /* None */); break; - case 259 /* NamespaceExportDeclaration */: + case 261 /* 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 */); break; - case 262 /* ImportClause */: + case 264 /* ImportClause */: addResult(ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, ts.factory.createIdentifier(localName), /*namedBindings*/ undefined), @@ -49988,18 +51654,18 @@ var ts; // In such cases, the `target` refers to the module itself already ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context))), 0 /* None */); break; - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: addResult(ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*importClause*/ undefined, ts.factory.createNamespaceImport(ts.factory.createIdentifier(localName))), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* None */); break; - case 269 /* NamespaceExport */: + case 271 /* NamespaceExport */: addResult(ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, ts.factory.createNamespaceExport(ts.factory.createIdentifier(localName)), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* None */); break; - case 265 /* ImportSpecifier */: + case 267 /* ImportSpecifier */: addResult(ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause( @@ -50008,7 +51674,7 @@ var ts; ts.factory.createImportSpecifier(localName !== verbatimTargetName ? ts.factory.createIdentifier(verbatimTargetName) : undefined, ts.factory.createIdentifier(localName)) ])), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context))), 0 /* None */); break; - case 270 /* ExportSpecifier */: + case 272 /* 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; @@ -50016,12 +51682,12 @@ var ts; // another file serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), specifier ? verbatimTargetName : targetName, specifier && ts.isStringLiteralLike(specifier) ? ts.factory.createStringLiteral(specifier.text) : undefined); break; - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: serializeMaybeAliasAssignment(symbol); break; - case 216 /* BinaryExpression */: - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 218 /* BinaryExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* 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 @@ -50076,7 +51742,7 @@ var ts; // a visibility error here (as they're not visible within any scope), but we want to hoist them // into the containing scope anyway, so we want to skip the visibility checks. var oldTrack = context.tracker.trackSymbol; - context.tracker.trackSymbol = ts.noop; + context.tracker.trackSymbol = function () { return false; }; if (isExportAssignmentCompatibleSymbolName) { results.push(ts.factory.createExportAssignment( /*decorators*/ undefined, @@ -50155,6 +51821,7 @@ var ts; } function makeSerializePropertySymbol(createProperty, methodKind, useAccessors) { 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 */))) { @@ -50171,7 +51838,7 @@ var ts; } var flag = (modifierFlags & ~256 /* Async */) | (isStatic ? 32 /* Static */ : 0); var name = getPropertyNameNodeForSymbol(p, context); - var firstPropertyLikeDecl = ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isAccessor, ts.isVariableDeclaration, ts.isPropertySignature, ts.isBinaryExpression, ts.isPropertyAccessExpression)); + 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) { var result = []; if (p.flags & 65536 /* SetAccessor */) { @@ -50181,13 +51848,13 @@ var ts; /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "arg", /*questionToken*/ undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled))], - /*body*/ undefined), ts.find(p.declarations, ts.isSetAccessor) || firstPropertyLikeDecl)); + /*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 */; result.push(ts.setTextRange(ts.factory.createGetAccessorDeclaration( /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(flag), name, [], isPrivate_1 ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), - /*body*/ undefined), ts.find(p.declarations, ts.isGetAccessor) || firstPropertyLikeDecl)); + /*body*/ undefined), ((_c = p.declarations) === null || _c === void 0 ? void 0 : _c.find(ts.isGetAccessor)) || firstPropertyLikeDecl)); } return result; } @@ -50198,7 +51865,7 @@ var ts; /*decorators*/ undefined, 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), // TODO: https://github.com/microsoft/TypeScript/pull/32372#discussion_r328386357 // interface members can't have initializers, however class members _can_ - /*initializer*/ undefined), ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isVariableDeclaration)) || firstPropertyLikeDecl); + /*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 */)) { var type = getTypeOfSymbol(p); @@ -50207,7 +51874,7 @@ var ts; return ts.setTextRange(createProperty( /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | flag), name, p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, /*type*/ undefined, - /*initializer*/ undefined), ts.find(p.declarations, ts.isFunctionLikeDeclaration) || signatures[0] && signatures[0].declaration || p.declarations[0]); + /*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]); } var results_1 = []; for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { @@ -50218,7 +51885,8 @@ var ts; questionToken: p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, modifiers: flag ? ts.factory.createModifiersFromModifierFlags(flag) : undefined }); - results_1.push(ts.setTextRange(decl, sig.declaration)); + var location = sig.declaration && ts.isPrototypePropertyAssignment(sig.declaration.parent) ? sig.declaration.parent : sig.declaration; + results_1.push(ts.setTextRange(decl, location)); } return results_1; } @@ -50389,7 +52057,7 @@ var ts; if (flags === void 0) { flags = 16384 /* 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(127 /* 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 /* 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 printer = ts.createPrinter({ removeComments: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); @@ -50434,9 +52102,9 @@ var ts; return "public"; } function getTypeAliasForTypeLiteral(type) { - if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { + if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */ && type.symbol.declarations) { var node = ts.walkUpParenthesizedTypes(type.symbol.declarations[0].parent); - if (node.kind === 254 /* TypeAliasDeclaration */) { + if (node.kind === 256 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -50444,11 +52112,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 257 /* ModuleBlock */ && + node.parent.kind === 259 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 297 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 299 /* SourceFile */ || ts.isAmbientModule(location); } function getNameOfSymbolFromNameType(symbol, context) { var nameType = getSymbolLinks(symbol).nameType; @@ -50507,17 +52175,17 @@ var ts; if (!declaration) { declaration = symbol.declarations[0]; // Declaration may be nameless, but we'll try anyway } - if (declaration.parent && declaration.parent.kind === 249 /* VariableDeclaration */) { + if (declaration.parent && declaration.parent.kind === 251 /* VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } switch (declaration.kind) { - case 221 /* ClassExpression */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 223 /* ClassExpression */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { context.encounteredError = true; } - return declaration.kind === 221 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; + return declaration.kind === 223 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var name = getNameOfSymbolFromNameType(symbol, context); @@ -50534,28 +52202,28 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 324 /* JSDocCallbackTag */: - case 331 /* JSDocTypedefTag */: - case 325 /* JSDocEnumTag */: + case 332 /* JSDocCallbackTag */: + case 339 /* JSDocTypedefTag */: + case 333 /* 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 198 /* BindingElement */: + case 200 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 249 /* VariableDeclaration */: + case 251 /* 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 256 /* ModuleDeclaration */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 251 /* FunctionDeclaration */: - case 255 /* EnumDeclaration */: - case 260 /* ImportEqualsDeclaration */: + case 258 /* ModuleDeclaration */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 253 /* FunctionDeclaration */: + case 257 /* EnumDeclaration */: + case 262 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; @@ -50563,55 +52231,55 @@ var ts; 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 !== 260 /* ImportEqualsDeclaration */ && parent.kind !== 297 /* SourceFile */ && parent.flags & 8388608 /* Ambient */)) { + !(node.kind !== 262 /* ImportEqualsDeclaration */ && parent.kind !== 299 /* SourceFile */ && parent.flags & 8388608 /* Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent); - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: if (ts.hasEffectiveModifier(node, 8 /* Private */ | 16 /* Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so: // falls through - case 166 /* Constructor */: - case 170 /* ConstructSignature */: - case 169 /* CallSignature */: - case 171 /* IndexSignature */: - case 160 /* Parameter */: - case 257 /* ModuleBlock */: - case 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 177 /* TypeLiteral */: - case 173 /* TypeReference */: - case 178 /* ArrayType */: - case 179 /* TupleType */: - case 182 /* UnionType */: - case 183 /* IntersectionType */: - case 186 /* ParenthesizedType */: - case 192 /* NamedTupleMember */: + case 168 /* Constructor */: + case 172 /* ConstructSignature */: + case 171 /* CallSignature */: + case 173 /* IndexSignature */: + case 162 /* Parameter */: + case 259 /* ModuleBlock */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: + case 179 /* TypeLiteral */: + case 175 /* TypeReference */: + case 180 /* ArrayType */: + case 181 /* TupleType */: + case 184 /* UnionType */: + case 185 /* IntersectionType */: + case 188 /* ParenthesizedType */: + case 194 /* 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 262 /* ImportClause */: - case 263 /* NamespaceImport */: - case 265 /* ImportSpecifier */: + case 264 /* ImportClause */: + case 265 /* NamespaceImport */: + case 267 /* ImportSpecifier */: return false; // Type parameters are always visible - case 159 /* TypeParameter */: + case 161 /* TypeParameter */: // Source file and namespace export are always visible // falls through - case 297 /* SourceFile */: - case 259 /* NamespaceExportDeclaration */: + case 299 /* SourceFile */: + case 261 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return false; default: return false; @@ -50620,10 +52288,10 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 266 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 268 /* ExportAssignment */) { exportSymbol = resolveName(node, node.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 270 /* ExportSpecifier */) { + else if (node.parent.kind === 272 /* ExportSpecifier */) { exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } var result; @@ -50728,12 +52396,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 249 /* VariableDeclaration */: - case 250 /* VariableDeclarationList */: - case 265 /* ImportSpecifier */: - case 264 /* NamedImports */: - case 263 /* NamespaceImport */: - case 262 /* ImportClause */: + case 251 /* VariableDeclaration */: + case 252 /* VariableDeclarationList */: + case 267 /* ImportSpecifier */: + case 266 /* NamedImports */: + case 265 /* NamespaceImport */: + case 264 /* ImportClause */: return false; default: return true; @@ -50796,9 +52464,16 @@ var ts; var stringIndexInfo = getIndexInfoOfType(source, 0 /* String */); var numberIndexInfo = getIndexInfoOfType(source, 1 /* Number */); var result = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); - result.objectFlags |= 131072 /* ObjectRestType */; + result.objectFlags |= 8388608 /* ObjectRestType */; return result; } + function isGenericTypeWithUndefinedConstraint(type) { + return !!(type.flags & 465829888 /* Instantiable */) && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 32768 /* 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 */); + } // Determine the control flow type associated with a destructuring declaration or assignment. The following // forms of destructuring are possible: // let { x } = obj; // BindingElement @@ -50833,23 +52508,23 @@ var ts; function getParentElementAccess(node) { var ancestor = node.parent.parent; switch (ancestor.kind) { - case 198 /* BindingElement */: - case 288 /* PropertyAssignment */: + case 200 /* BindingElement */: + case 290 /* PropertyAssignment */: return getSyntheticElementAccess(ancestor); - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return getSyntheticElementAccess(node.parent); - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return ancestor.initializer; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return ancestor.right; } } function getDestructuringPropertyName(node) { var parent = node.parent; - if (node.kind === 198 /* BindingElement */ && parent.kind === 196 /* ObjectBindingPattern */) { + if (node.kind === 200 /* BindingElement */ && parent.kind === 198 /* ObjectBindingPattern */) { return getLiteralPropertyNameText(node.propertyName || node.name); } - if (node.kind === 288 /* PropertyAssignment */ || node.kind === 289 /* ShorthandPropertyAssignment */) { + if (node.kind === 290 /* PropertyAssignment */ || node.kind === 291 /* ShorthandPropertyAssignment */) { return getLiteralPropertyNameText(node.name); } return "" + parent.elements.indexOf(node); @@ -50875,7 +52550,7 @@ var ts; parentType = getTypeWithFacts(parentType, 524288 /* NEUndefined */); } var type; - if (pattern.kind === 196 /* ObjectBindingPattern */) { + if (pattern.kind === 198 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { parentType = getReducedType(parentType); if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { @@ -50895,7 +52570,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 = getConstraintForLocation(getIndexedAccessType(parentType, indexType, /*noUncheckedIndexedAccessCandidate*/ undefined, name, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, 16 /* ExpressionPosition */), declaration.name); + var declaredType = getIndexedAccessType(parentType, indexType, 32 /* ExpressionPosition */, name); type = getFlowTypeOfDestructuring(declaration, declaredType); } } @@ -50915,8 +52590,8 @@ var ts; } else if (isArrayLikeType(parentType)) { var indexType = getLiteralType(index_2); - var accessFlags = hasDefaultValue(declaration) ? 8 /* NoTupleBoundsCheck */ : 0; - var declaredType = getConstraintForLocation(getIndexedAccessTypeOrUndefined(parentType, indexType, /*noUncheckedIndexedAccessCandidate*/ undefined, declaration.name, accessFlags | 16 /* ExpressionPosition */) || errorType, declaration.name); + var accessFlags = 32 /* ExpressionPosition */ | (hasDefaultValue(declaration) ? 16 /* NoTupleBoundsCheck */ : 0); + var declaredType = getIndexedAccessTypeOrUndefined(parentType, indexType, accessFlags, declaration.name) || errorType; type = getFlowTypeOfDestructuring(declaration, declaredType); } else { @@ -50929,11 +52604,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 && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 32768 /* Undefined */) ? - getTypeWithFacts(type, 524288 /* NEUndefined */) : - type; + return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 32768 /* Undefined */) ? getNonUndefinedType(type) : type; } - return widenTypeInferredFromInitializer(declaration, getUnionType([getTypeWithFacts(type, 524288 /* NEUndefined */), checkDeclarationInitializer(declaration)], 2 /* Subtype */)); + return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration)], 2 /* Subtype */)); } function getTypeForDeclarationFromJSDocComment(declaration) { var jsdocType = ts.getJSDocType(declaration); @@ -50944,25 +52617,26 @@ var ts; } function isNullOrUndefined(node) { var expr = ts.skipParentheses(node); - return expr.kind === 103 /* NullKeyword */ || expr.kind === 78 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; + return expr.kind === 104 /* NullKeyword */ || expr.kind === 79 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 199 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 201 /* ArrayLiteralExpression */ && expr.elements.length === 0; } - function addOptionality(type, optional) { - if (optional === void 0) { optional = true; } - return strictNullChecks && optional ? getOptionalType(type) : type; + function addOptionality(type, isProperty, isOptional) { + if (isProperty === void 0) { isProperty = false; } + if (isOptional === void 0) { isOptional = true; } + return strictNullChecks && isOptional ? getOptionalType(type, isProperty) : type; } // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { // 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 === 238 /* ForInStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 240 /* ForInStatement */) { var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression))); return indexType.flags & (262144 /* TypeParameter */ | 4194304 /* Index */) ? getExtractStringType(indexType) : stringType; } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 239 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 241 /* 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, @@ -50973,13 +52647,14 @@ var ts; if (ts.isBindingPattern(declaration.parent)) { return getTypeForBindingElement(declaration); } - var isOptional = includeOptionality && (ts.isParameter(declaration) && isJSDocOptionalParameter(declaration) - || isOptionalJSDocPropertyLikeTag(declaration) - || !ts.isBindingElement(declaration) && !ts.isVariableDeclaration(declaration) && !!declaration.questionToken); + var isProperty = ts.isPropertyDeclaration(declaration) || ts.isPropertySignature(declaration); + var isOptional = includeOptionality && (isProperty && !!declaration.questionToken || + ts.isParameter(declaration) && (!!declaration.questionToken || isJSDocOptionalParameter(declaration)) || + isOptionalJSDocPropertyLikeTag(declaration)); // Use type from type annotation if one is present var declaredType = tryGetTypeFromEffectiveTypeNode(declaration); if (declaredType) { - return addOptionality(declaredType, isOptional); + return addOptionality(declaredType, isProperty, isOptional); } if ((noImplicitAny || ts.isInJSFile(declaration)) && ts.isVariableDeclaration(declaration) && !ts.isBindingPattern(declaration.name) && @@ -50999,8 +52674,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 === 168 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 167 /* GetAccessor */); + if (func.kind === 170 /* SetAccessor */ && hasBindableName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 169 /* GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -51023,7 +52698,7 @@ var ts; // Use contextual parameter type if one is available var type = declaration.symbol.escapedName === "this" /* This */ ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration); if (type) { - return addOptionality(type, isOptional); + return addOptionality(type, /*isProperty*/ false, isOptional); } } // Use the type of the initializer expression if one is present and the declaration is @@ -51036,7 +52711,7 @@ var ts; } } var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration)); - return addOptionality(type, isOptional); + return addOptionality(type, isProperty, isOptional); } if (ts.isPropertyDeclaration(declaration) && !ts.hasStaticModifier(declaration) && (noImplicitAny || ts.isInJSFile(declaration))) { // We have a property declaration with no type annotation or initializer, in noImplicitAny mode or a .js file. @@ -51045,7 +52720,7 @@ var ts; var type = constructor ? getFlowTypeInConstructor(declaration.symbol, constructor) : ts.getEffectiveModifierFlags(declaration) & 2 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : undefined; - return type && addOptionality(type, isOptional); + return type && addOptionality(type, /*isProperty*/ true, isOptional); } if (ts.isJsxAttribute(declaration)) { // if JSX attribute doesn't have initializer, by default the attribute will have boolean value of true. @@ -51071,7 +52746,7 @@ var ts; links.isConstructorDeclaredProperty = !!getDeclaringConstructor(symbol) && ts.every(symbol.declarations, function (declaration) { return ts.isBinaryExpression(declaration) && isPossiblyAliasedThisProperty(declaration) && - (declaration.left.kind !== 202 /* ElementAccessExpression */ || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) && + (declaration.left.kind !== 204 /* ElementAccessExpression */ || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) && !getAnnotatedTypeForAssignmentDeclaration(/*declaredType*/ undefined, declaration, symbol, declaration); }); } @@ -51087,13 +52762,33 @@ var ts; !declaration.initializer && (noImplicitAny || ts.isInJSFile(declaration)); } function getDeclaringConstructor(symbol) { + if (!symbol.declarations) { + return; + } 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 === 166 /* Constructor */ || isJSConstructor(container))) { + if (container && (container.kind === 168 /* Constructor */ || isJSConstructor(container))) { return container; } } + ; + } + /** Create a synthetic property access flow node after the last statement of the file */ + function getFlowTypeFromCommonJSExport(symbol) { + var file = ts.getSourceFileOfNode(symbol.declarations[0]); + var accessName = ts.unescapeLeadingUnderscores(symbol.escapedName); + var areAllModuleExports = symbol.declarations.every(function (d) { return ts.isInJSFile(d) && ts.isAccessExpression(d) && ts.isModuleExportsAccessExpression(d.expression); }); + var reference = areAllModuleExports + ? ts.factory.createPropertyAccessExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("module"), ts.factory.createIdentifier("exports")), accessName) + : ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("exports"), accessName); + if (areAllModuleExports) { + ts.setParent(reference.expression.expression, reference.expression); + } + ts.setParent(reference.expression, reference); + ts.setParent(reference, file); + reference.flowNode = file.endFlowNode; + return getFlowTypeOfReference(reference, autoType, undefinedType); } function getFlowTypeInConstructor(symbol, constructor) { var accessName = ts.startsWith(symbol.escapedName, "__#") @@ -51111,7 +52806,10 @@ var ts; return everyType(flowType, isNullableType) ? undefined : convertAutoToAny(flowType); } function getFlowTypeOfProperty(reference, prop) { - var initialType = prop && (!isAutoTypedProperty(prop) || ts.getEffectiveModifierFlags(prop.valueDeclaration) & 2 /* Ambient */) && getTypeOfPropertyInBaseClass(prop) || undefinedType; + var initialType = (prop === null || prop === void 0 ? void 0 : prop.valueDeclaration) + && (!isAutoTypedProperty(prop) || ts.getEffectiveModifierFlags(prop.valueDeclaration) & 2 /* Ambient */) + && getTypeOfPropertyInBaseClass(prop) + || undefinedType; return getFlowTypeOfReference(reference, autoType, initialType); } function getWidenedTypeForAssignmentDeclaration(symbol, resolvedSymbol) { @@ -51122,7 +52820,7 @@ var ts; if (tag && tag.typeExpression) { return getTypeFromTypeNode(tag.typeExpression); } - var containerObjectType = getJSContainerObjectType(symbol.valueDeclaration, symbol, container); + var containerObjectType = symbol.valueDeclaration && getJSContainerObjectType(symbol.valueDeclaration, symbol, container); return containerObjectType || getWidenedLiteralType(checkExpressionCached(container)); } var type; @@ -51134,40 +52832,42 @@ var ts; type = getFlowTypeInConstructor(symbol, getDeclaringConstructor(symbol)); } if (!type) { - var jsdocType = void 0; var types = void 0; - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration : - ts.isAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : - undefined; - if (!expression) { - continue; // Non-assignment declaration merged in (eg, an Identifier to mark the thing as a namespace) - skip over it and pull type info from elsewhere - } - var kind = ts.isAccessExpression(expression) - ? ts.getAssignmentDeclarationPropertyAccessKind(expression) - : ts.getAssignmentDeclarationKind(expression); - if (kind === 4 /* ThisProperty */ || ts.isBinaryExpression(expression) && isPossiblyAliasedThisProperty(expression, kind)) { - if (isDeclarationInConstructor(expression)) { - definedInConstructor = true; + if (symbol.declarations) { + var jsdocType = void 0; + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration : + ts.isAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : + undefined; + if (!expression) { + continue; // Non-assignment declaration merged in (eg, an Identifier to mark the thing as a namespace) - skip over it and pull type info from elsewhere } - else { - definedInMethod = true; + var kind = ts.isAccessExpression(expression) + ? ts.getAssignmentDeclarationPropertyAccessKind(expression) + : ts.getAssignmentDeclarationKind(expression); + if (kind === 4 /* ThisProperty */ || ts.isBinaryExpression(expression) && isPossiblyAliasedThisProperty(expression, kind)) { + if (isDeclarationInConstructor(expression)) { + definedInConstructor = true; + } + else { + definedInMethod = true; + } + } + if (!ts.isCallExpression(expression)) { + jsdocType = getAnnotatedTypeForAssignmentDeclaration(jsdocType, expression, symbol, declaration); + } + if (!jsdocType) { + (types || (types = [])).push((ts.isBinaryExpression(expression) || ts.isCallExpression(expression)) ? getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) : neverType); } } - if (!ts.isCallExpression(expression)) { - jsdocType = getAnnotatedTypeForAssignmentDeclaration(jsdocType, expression, symbol, declaration); - } - if (!jsdocType) { - (types || (types = [])).push((ts.isBinaryExpression(expression) || ts.isCallExpression(expression)) ? getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) : neverType); - } + type = jsdocType; } - type = jsdocType; if (!type) { if (!ts.length(types)) { return errorType; // No types from any declarations :( } - var constructorTypes = definedInConstructor ? getConstructorDefinedThisAssignmentTypes(types, symbol.declarations) : undefined; + var constructorTypes = definedInConstructor && symbol.declarations ? getConstructorDefinedThisAssignmentTypes(types, symbol.declarations) : undefined; // use only the constructor types unless they were only assigned null | undefined (including widening variants) if (definedInMethod) { var propType = getTypeOfPropertyInBaseClass(symbol); @@ -51180,8 +52880,8 @@ var ts; type = getUnionType(sourceTypes, 2 /* Subtype */); } } - var widened = getWidenedType(addOptionality(type, definedInMethod && !definedInConstructor)); - if (filterType(widened, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) === neverType) { + var widened = getWidenedType(addOptionality(type, /*isProperty*/ false, definedInMethod && !definedInConstructor)); + if (symbol.valueDeclaration && filterType(widened, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) === neverType) { reportImplicitAny(symbol.valueDeclaration, anyType); return anyType; } @@ -51205,10 +52905,11 @@ var ts; mergeSymbolTable(exports, s.exports); } var type = createAnonymousType(symbol, exports, ts.emptyArray, ts.emptyArray, undefined, undefined); - type.objectFlags |= 16384 /* JSLiteral */; + type.objectFlags |= 8192 /* JSLiteral */; return type; } function getAnnotatedTypeForAssignmentDeclaration(declaredType, expression, symbol, declaration) { + var _a; var typeNode = ts.getEffectiveTypeAnnotationNode(expression.parent); if (typeNode) { var type = getWidenedType(getTypeFromTypeNode(typeNode)); @@ -51219,10 +52920,13 @@ var ts; errorNextVariableOrPropertyDeclarationMustHaveSameType(/*firstDeclaration*/ undefined, declaredType, declaration, type); } } - if (symbol.parent) { + if ((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.valueDeclaration) { var typeNode_2 = ts.getEffectiveTypeAnnotationNode(symbol.parent.valueDeclaration); if (typeNode_2) { - return getTypeOfPropertyOfType(getTypeFromTypeNode(typeNode_2), symbol.escapedName); + var annotationSymbol = getPropertyOfType(getTypeFromTypeNode(typeNode_2), symbol.escapedName); + if (annotationSymbol) { + return getNonMissingTypeOfSymbol(annotationSymbol); + } } } return declaredType; @@ -51283,7 +52987,7 @@ var ts; // but we may have a JS file with `module.exports = { a: true }` along with a TypeScript module augmentation // declaring an `export const a: number`. In that case, we issue a duplicate identifier error, because // it's unclear what that's supposed to mean, so it's probably a mistake. - if (ts.getSourceFileOfNode(s.valueDeclaration) !== ts.getSourceFileOfNode(exportedMember.valueDeclaration)) { + if (s.valueDeclaration && exportedMember.valueDeclaration && ts.getSourceFileOfNode(s.valueDeclaration) !== ts.getSourceFileOfNode(exportedMember.valueDeclaration)) { var unescapedName = ts.unescapeLeadingUnderscores(s.escapedName); var exportedMemberName = ((_a = ts.tryCast(exportedMember.valueDeclaration, ts.isNamedDeclaration)) === null || _a === void 0 ? void 0 : _a.name) || exportedMember.valueDeclaration; ts.addRelatedInfo(error(s.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0, unescapedName), ts.createDiagnosticForNode(exportedMemberName, ts.Diagnostics._0_was_also_declared_here, unescapedName)); @@ -51305,9 +53009,9 @@ var ts; }); var result = createAnonymousType(initialSize !== members_4.size ? undefined : exportedType.symbol, // Only set the type's symbol if it looks to be the same as the original type members_4, exportedType.callSignatures, exportedType.constructSignatures, exportedType.stringIndexInfo, exportedType.numberIndexInfo); - result.objectFlags |= (ts.getObjectFlags(type) & 16384 /* JSLiteral */); // Propagate JSLiteral flag + result.objectFlags |= (ts.getObjectFlags(type) & 8192 /* JSLiteral */); // Propagate JSLiteral flag if (result.symbol && result.symbol.flags & 32 /* Class */ && type === getDeclaredTypeOfClassOrInterface(result.symbol)) { - result.objectFlags |= 1073741824 /* IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type + result.objectFlags |= 16777216 /* IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type } return result; } @@ -51319,16 +53023,16 @@ var ts; } function containsSameNamedThisProperty(thisProperty, expression) { return ts.isPropertyAccessExpression(thisProperty) - && thisProperty.expression.kind === 107 /* ThisKeyword */ + && thisProperty.expression.kind === 108 /* 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 === 166 /* Constructor */ || - thisContainer.kind === 251 /* FunctionDeclaration */ || - (thisContainer.kind === 208 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + return thisContainer.kind === 168 /* Constructor */ || + thisContainer.kind === 253 /* FunctionDeclaration */ || + (thisContainer.kind === 210 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); } function getConstructorDefinedThisAssignmentTypes(types, declarations) { ts.Debug.assert(types.length === declarations.length); @@ -51366,7 +53070,7 @@ var ts; function getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) { var members = ts.createSymbolTable(); var stringIndexInfo; - var objectFlags = 128 /* ObjectLiteral */ | 1048576 /* ContainsObjectOrArrayLiteral */; + var objectFlags = 128 /* ObjectLiteral */ | 262144 /* ContainsObjectOrArrayLiteral */; ts.forEach(pattern.elements, function (e) { var name = e.propertyName || e.name; if (e.dotDotDotToken) { @@ -51390,7 +53094,7 @@ var ts; result.objectFlags |= objectFlags; if (includePatternInType) { result.pattern = pattern; - result.objectFlags |= 1048576 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= 262144 /* ContainsObjectOrArrayLiteral */; } return result; } @@ -51398,7 +53102,7 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - var restElement = lastElement && lastElement.kind === 198 /* BindingElement */ && lastElement.dotDotDotToken ? lastElement : undefined; + var restElement = lastElement && lastElement.kind === 200 /* BindingElement */ && lastElement.dotDotDotToken ? lastElement : undefined; if (elements.length === 0 || elements.length === 1 && restElement) { return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; } @@ -51409,7 +53113,7 @@ var ts; if (includePatternInType) { result = cloneTypeReference(result); result.pattern = pattern; - result.objectFlags |= 1048576 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= 262144 /* ContainsObjectOrArrayLiteral */; } return result; } @@ -51423,7 +53127,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 196 /* ObjectBindingPattern */ + return pattern.kind === 198 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -51439,8 +53143,17 @@ var ts; function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) { return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true), declaration, reportErrors); } + function isGlobalSymbolConstructor(node) { + var symbol = getSymbolOfNode(node); + var globalSymbol = getGlobalESSymbolConstructorTypeSymbol(/*reportErrors*/ false); + return globalSymbol && symbol && symbol === globalSymbol; + } 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)) { + type = getESSymbolLikeTypeForNode(declaration); + } if (reportErrors) { reportErrorsFromWidening(declaration, type); } @@ -51462,7 +53175,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 160 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 162 /* Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(declaration) { @@ -51493,19 +53206,31 @@ var ts; if (symbol === requireSymbol) { return anyType; } - if (symbol.flags & 134217728 /* ModuleExports */) { + if (symbol.flags & 134217728 /* ModuleExports */ && symbol.valueDeclaration) { var fileSymbol = getSymbolOfNode(ts.getSourceFileOfNode(symbol.valueDeclaration)); + var result = createSymbol(fileSymbol.flags, "exports"); + result.declarations = fileSymbol.declarations ? fileSymbol.declarations.slice() : []; + result.parent = symbol; + result.target = fileSymbol; + if (fileSymbol.valueDeclaration) + result.valueDeclaration = fileSymbol.valueDeclaration; + if (fileSymbol.members) + result.members = new ts.Map(fileSymbol.members); + if (fileSymbol.exports) + result.exports = new ts.Map(fileSymbol.exports); var members = ts.createSymbolTable(); - members.set("exports", fileSymbol); + members.set("exports", result); return createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, undefined, undefined); } // Handle catch clause variables + ts.Debug.assertIsDefined(symbol.valueDeclaration); var declaration = symbol.valueDeclaration; if (ts.isCatchClauseVariableDeclarationOrBindingElement(declaration)) { - var decl = declaration; - if (!decl.type) - return anyType; - var type_1 = getTypeOfNode(decl.type); + var typeNode = ts.getEffectiveTypeAnnotationNode(declaration); + if (typeNode === undefined) { + return useUnknownInCatchVariables ? unknownType : anyType; + } + var type_1 = getTypeOfNode(typeNode); // an errorType will make `checkTryStatement` issue an error return isTypeAny(type_1) || type_1 === unknownType ? type_1 : errorType; } @@ -51525,7 +53250,7 @@ var ts; return reportCircularityError(symbol); } var type; - if (declaration.kind === 266 /* ExportAssignment */) { + if (declaration.kind === 268 /* ExportAssignment */) { type = widenTypeForVariableLikeDeclaration(checkExpressionCached(declaration.expression), declaration); } else if (ts.isBinaryExpression(declaration) || @@ -51580,7 +53305,7 @@ var ts; type = getTypeOfEnumMember(symbol); } else if (ts.isAccessor(declaration)) { - type = resolveTypeOfAccessors(symbol); + type = resolveTypeOfAccessors(symbol) || ts.Debug.fail("Non-write accessor resolution must always produce a type"); } else { return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.formatSyntaxKind(declaration.kind) + " for " + ts.Debug.formatSymbol(symbol)); @@ -51596,7 +53321,7 @@ var ts; } function getAnnotatedAccessorTypeNode(accessor) { if (accessor) { - if (accessor.kind === 167 /* GetAccessor */) { + if (accessor.kind === 169 /* GetAccessor */) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation; } @@ -51620,63 +53345,78 @@ var ts; } function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); - return links.type || (links.type = getTypeOfAccessorsWorker(symbol)); + return links.type || (links.type = getTypeOfAccessorsWorker(symbol) || ts.Debug.fail("Read type of accessor must always produce a type")); + } + function getTypeOfSetAccessor(symbol) { + var links = getSymbolLinks(symbol); + return links.writeType || (links.writeType = getTypeOfAccessorsWorker(symbol, /*writing*/ true)); } - function getTypeOfAccessorsWorker(symbol) { + function getTypeOfAccessorsWorker(symbol, writing) { + if (writing === void 0) { writing = false; } if (!pushTypeResolution(symbol, 0 /* Type */)) { return errorType; } - var type = resolveTypeOfAccessors(symbol); + var type = resolveTypeOfAccessors(symbol, writing); if (!popTypeResolution()) { type = anyType; if (noImplicitAny) { - var getter = ts.getDeclarationOfKind(symbol, 167 /* GetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 169 /* GetAccessor */); error(getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } return type; } - function resolveTypeOfAccessors(symbol) { - var getter = ts.getDeclarationOfKind(symbol, 167 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 168 /* SetAccessor */); + function resolveTypeOfAccessors(symbol, writing) { + if (writing === void 0) { writing = false; } + var getter = ts.getDeclarationOfKind(symbol, 169 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 170 /* SetAccessor */); + var setterType = getAnnotatedAccessorType(setter); + // For write operations, prioritize type annotations on the setter + if (writing && setterType) { + return instantiateTypeIfNeeded(setterType, symbol); + } + // Else defer to the getter type if (getter && ts.isInJSFile(getter)) { var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { - return jsDocType; + return instantiateTypeIfNeeded(jsDocType, symbol); } } - // First try to see if the user specified a return type on the get-accessor. - var getterReturnType = getAnnotatedAccessorType(getter); - if (getterReturnType) { - return getterReturnType; + // Try to see if the user specified a return type on the get-accessor. + var getterType = getAnnotatedAccessorType(getter); + if (getterType) { + return instantiateTypeIfNeeded(getterType, symbol); } - else { - // If the user didn't specify a return type, try to use the set-accessor's parameter type. - var setterParameterType = getAnnotatedAccessorType(setter); - if (setterParameterType) { - return setterParameterType; + // If the user didn't specify a return type, try to use the set-accessor's parameter type. + if (setterType) { + return setterType; + } + // If there are no specified types, try to infer it from the body of the get accessor if it exists. + if (getter && getter.body) { + var returnTypeFromBody = getReturnTypeFromBody(getter); + return instantiateTypeIfNeeded(returnTypeFromBody, symbol); + } + // Otherwise, fall back to 'any'. + if (setter) { + if (!isPrivateWithinAmbient(setter)) { + errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol)); } - else { - // If there are no specified types, try to infer it from the body of the get accessor if it exists. - if (getter && getter.body) { - return getReturnTypeFromBody(getter); - } - // Otherwise, fall back to 'any'. - else { - if (setter) { - if (!isPrivateWithinAmbient(setter)) { - errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol)); - } - } - else { - ts.Debug.assert(!!getter, "there must exist a getter as we are current checking either setter or getter in this function"); - if (!isPrivateWithinAmbient(getter)) { - errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol)); - } - } - return anyType; - } + return anyType; + } + else if (getter) { + ts.Debug.assert(!!getter, "there must exist a getter as we are current checking either setter or getter in this function"); + if (!isPrivateWithinAmbient(getter)) { + errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol)); } + return anyType; + } + return undefined; + function instantiateTypeIfNeeded(type, symbol) { + if (ts.getCheckFlags(symbol) & 1 /* Instantiated */) { + var links = getSymbolLinks(symbol); + return instantiateType(type, links.mapper); + } + return type; } } function getBaseTypeVariableOfClass(symbol) { @@ -51706,9 +53446,9 @@ var ts; if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { return anyType; } - else if (declaration && (declaration.kind === 216 /* BinaryExpression */ || + else if (declaration && (declaration.kind === 218 /* BinaryExpression */ || ts.isAccessExpression(declaration) && - declaration.parent.kind === 216 /* BinaryExpression */)) { + declaration.parent.kind === 218 /* BinaryExpression */)) { return getWidenedTypeForAssignmentDeclaration(symbol); } else if (symbol.flags & 512 /* ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { @@ -51742,14 +53482,16 @@ var ts; var links = getSymbolLinks(symbol); if (!links.type) { var targetSymbol = resolveAlias(symbol); + var exportSymbol = symbol.declarations && getTargetOfAliasDeclaration(getDeclarationOfAliasSymbol(symbol), /*dontResolveAlias*/ true); // It only makes sense to get the type of a value symbol. If the result of resolving // the alias is not a value, then it has no type. To get the type associated with a // type symbol, call getDeclaredTypeOfSymbol. // This check is important because without it, a call to getTypeOfSymbol could end // up recursively calling getTypeOfAlias, causing a stack overflow. - links.type = targetSymbol.flags & 111551 /* Value */ - ? getTypeOfSymbol(targetSymbol) - : errorType; + links.type = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.declarations) && isDuplicatedCommonJSExport(exportSymbol.declarations) && symbol.declarations.length ? getFlowTypeFromCommonJSExport(exportSymbol) + : isDuplicatedCommonJSExport(symbol.declarations) ? autoType + : targetSymbol.flags & 111551 /* Value */ ? getTypeOfSymbol(targetSymbol) + : errorType; } return links.type; } @@ -51775,7 +53517,7 @@ var ts; return errorType; } // Check if variable has initializer that circularly references the variable itself - if (noImplicitAny && (declaration.kind !== 160 /* Parameter */ || declaration.initializer)) { + if (noImplicitAny && (declaration.kind !== 162 /* 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 @@ -51792,6 +53534,15 @@ var ts; } return links.type; } + function getSetAccessorTypeOfSymbol(symbol) { + if (symbol.flags & 98304 /* Accessor */) { + var type = getTypeOfSetAccessor(symbol); + if (type) { + return type; + } + } + return getTypeOfSymbol(symbol); + } function getTypeOfSymbol(symbol) { var checkFlags = ts.getCheckFlags(symbol); if (checkFlags & 65536 /* DeferredType */) { @@ -51823,6 +53574,9 @@ var ts; } return errorType; } + function getNonMissingTypeOfSymbol(symbol) { + return removeMissingType(getTypeOfSymbol(symbol), !!(symbol.flags & 16777216 /* Optional */)); + } function isReferenceToType(type, target) { return type !== undefined && target !== undefined @@ -51874,66 +53628,72 @@ var ts; return undefined; } switch (node.kind) { - case 232 /* VariableStatement */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 164 /* MethodSignature */: - case 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 308 /* JSDocFunctionType */: - case 251 /* FunctionDeclaration */: - case 165 /* MethodDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 254 /* TypeAliasDeclaration */: - case 330 /* JSDocTemplateTag */: - case 331 /* JSDocTypedefTag */: - case 325 /* JSDocEnumTag */: - case 324 /* JSDocCallbackTag */: - case 190 /* MappedType */: - case 184 /* ConditionalType */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 166 /* MethodSignature */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: + case 311 /* JSDocFunctionType */: + case 253 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 256 /* TypeAliasDeclaration */: + case 338 /* JSDocTemplateTag */: + case 339 /* JSDocTypedefTag */: + case 333 /* JSDocEnumTag */: + case 332 /* JSDocCallbackTag */: + case 192 /* MappedType */: + case 186 /* ConditionalType */: { var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 190 /* MappedType */) { + if (node.kind === 192 /* MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 184 /* ConditionalType */) { + else if (node.kind === 186 /* ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } - else if (node.kind === 232 /* VariableStatement */ && !ts.isInJSFile(node)) { - break; - } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 252 /* ClassDeclaration */ || node.kind === 221 /* ClassExpression */ || node.kind === 253 /* InterfaceDeclaration */ || isJSConstructor(node)) && + (node.kind === 254 /* ClassDeclaration */ || node.kind === 223 /* ClassExpression */ || node.kind === 255 /* InterfaceDeclaration */ || isJSConstructor(node)) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; - case 326 /* JSDocParameterTag */: + } + case 334 /* JSDocParameterTag */: var paramSymbol = ts.getParameterSymbolFromJSDoc(node); if (paramSymbol) { node = paramSymbol.valueDeclaration; } break; + case 314 /* JSDocComment */: { + var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); + return node.tags + ? appendTypeParameters(outerTypeParameters, ts.flatMap(node.tags, function (t) { return ts.isJSDocTemplateTag(t) ? t.typeParameters : undefined; })) + : outerTypeParameters; + } } } } // 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, 253 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 255 /* InterfaceDeclaration */); ts.Debug.assert(!!declaration, "Class was missing valueDeclaration -OR- non-class had no interface declarations"); return getOuterTypeParameters(declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, // interface, or type alias. function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { + if (!symbol.declarations) { + return; + } var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 253 /* InterfaceDeclaration */ || - node.kind === 252 /* ClassDeclaration */ || - node.kind === 221 /* ClassExpression */ || + if (node.kind === 255 /* InterfaceDeclaration */ || + node.kind === 254 /* ClassDeclaration */ || + node.kind === 223 /* ClassExpression */ || isJSConstructor(node) || ts.isTypeAlias(node)) { var declaration = node; @@ -52027,7 +53787,9 @@ var ts; ctorReturn = getReturnTypeOfSignature(ctorSig[0]); } } - ts.addRelatedInfo(err, ts.createDiagnosticForNode(baseConstructorType.symbol.declarations[0], ts.Diagnostics.Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1, symbolToString(baseConstructorType.symbol), typeToString(ctorReturn))); + if (baseConstructorType.symbol.declarations) { + ts.addRelatedInfo(err, ts.createDiagnosticForNode(baseConstructorType.symbol.declarations[0], ts.Diagnostics.Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1, symbolToString(baseConstructorType.symbol), typeToString(ctorReturn))); + } } return type.resolvedBaseConstructorType = errorType; } @@ -52037,20 +53799,22 @@ var ts; } function getImplementsTypes(type) { var resolvedImplementsTypes = ts.emptyArray; - for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - var implementsTypeNodes = ts.getEffectiveImplementsTypeNodes(declaration); - if (!implementsTypeNodes) - continue; - for (var _b = 0, implementsTypeNodes_1 = implementsTypeNodes; _b < implementsTypeNodes_1.length; _b++) { - var node = implementsTypeNodes_1[_b]; - var implementsType = getTypeFromTypeNode(node); - if (implementsType !== errorType) { - if (resolvedImplementsTypes === ts.emptyArray) { - resolvedImplementsTypes = [implementsType]; - } - else { - resolvedImplementsTypes.push(implementsType); + if (type.symbol.declarations) { + for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + var implementsTypeNodes = ts.getEffectiveImplementsTypeNodes(declaration); + if (!implementsTypeNodes) + continue; + for (var _b = 0, implementsTypeNodes_1 = implementsTypeNodes; _b < implementsTypeNodes_1.length; _b++) { + var node = implementsTypeNodes_1[_b]; + var implementsType = getTypeFromTypeNode(node); + if (implementsType !== errorType) { + if (resolvedImplementsTypes === ts.emptyArray) { + resolvedImplementsTypes = [implementsType]; + } + else { + resolvedImplementsTypes.push(implementsType); + } } } } @@ -52077,10 +53841,10 @@ var ts; else { ts.Debug.fail("type must be class or interface"); } - if (!popTypeResolution()) { + if (!popTypeResolution() && type.symbol.declarations) { for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 252 /* ClassDeclaration */ || declaration.kind === 253 /* InterfaceDeclaration */) { + if (declaration.kind === 254 /* ClassDeclaration */ || declaration.kind === 255 /* InterfaceDeclaration */) { reportCircularBaseType(declaration, type); } } @@ -52173,29 +53937,31 @@ var ts; } function resolveBaseTypesOfInterface(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray; - for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 253 /* 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)); - if (baseType !== errorType) { - if (isValidBaseType(baseType)) { - if (type !== baseType && !hasBaseType(baseType, type)) { - if (type.resolvedBaseTypes === ts.emptyArray) { - type.resolvedBaseTypes = [baseType]; + if (type.symbol.declarations) { + for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 255 /* 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)); + if (baseType !== errorType) { + if (isValidBaseType(baseType)) { + if (type !== baseType && !hasBaseType(baseType, type)) { + if (type.resolvedBaseTypes === ts.emptyArray) { + type.resolvedBaseTypes = [baseType]; + } + else { + type.resolvedBaseTypes.push(baseType); + } } else { - type.resolvedBaseTypes.push(baseType); + reportCircularBaseType(declaration, type); } } else { - reportCircularBaseType(declaration, type); + error(node, ts.Diagnostics.An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_members); } } - else { - error(node, ts.Diagnostics.An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_members); - } } } } @@ -52209,9 +53975,12 @@ var ts; * and if none of the base interfaces have a "this" type. */ function isThislessInterface(symbol) { + if (!symbol.declarations) { + return true; + } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 253 /* InterfaceDeclaration */) { + if (declaration.kind === 255 /* InterfaceDeclaration */) { if (declaration.flags & 128 /* ContainsThis */) { return false; } @@ -52236,7 +54005,7 @@ var ts; var originalLinks = links; if (!links.declaredType) { var kind = symbol.flags & 32 /* Class */ ? 1 /* Class */ : 2 /* Interface */; - var merged = mergeJSSymbols(symbol, getAssignedClassSymbol(symbol.valueDeclaration)); + var merged = mergeJSSymbols(symbol, symbol.valueDeclaration && getAssignedClassSymbol(symbol.valueDeclaration)); if (merged) { // note:we overwrite links because we just cloned the symbol symbol = links = merged; @@ -52266,6 +54035,7 @@ var ts; return links.declaredType; } function getDeclaredTypeOfTypeAlias(symbol) { + var _a; var links = getSymbolLinks(symbol); if (!links.declaredType) { // Note that we use the links object as the target here because the symbol object is used as the unique @@ -52273,7 +54043,7 @@ var ts; if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { return errorType; } - var declaration = ts.Debug.checkDefined(ts.find(symbol.declarations, ts.isTypeAlias), "Type alias symbol with no valid declaration found"); + 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"); var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type; // If typeNode is missing, we will error in checkJSDocTypedefTag. var type = typeNode ? getTypeFromTypeNode(typeNode) : errorType; @@ -52289,7 +54059,12 @@ var ts; } else { type = errorType; - error(ts.isNamedDeclaration(declaration) ? declaration.name : declaration || declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); + if (declaration.kind === 333 /* 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)); + } } links.declaredType = type; } @@ -52299,7 +54074,7 @@ var ts; if (ts.isStringLiteralLike(expr)) { return true; } - else if (expr.kind === 216 /* BinaryExpression */) { + else if (expr.kind === 218 /* BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -52314,12 +54089,12 @@ var ts; case 8 /* NumericLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return true; - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return expr.operator === 40 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; - case 78 /* Identifier */: + case 79 /* Identifier */: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -52331,16 +54106,18 @@ var ts; return links.enumKind; } var hasNonLiteralMember = false; - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 255 /* 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 */; - } - if (!isLiteralEnumMember(member)) { - hasNonLiteralMember = true; + if (symbol.declarations) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 257 /* 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 */; + } + if (!isLiteralEnumMember(member)) { + hasNonLiteralMember = true; + } } } } @@ -52358,15 +54135,17 @@ var ts; if (getEnumKind(symbol) === 1 /* Literal */) { enumCount++; var memberTypeList = []; - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 255 /* EnumDeclaration */) { - for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { - var member = _c[_b]; - var value = getEnumMemberValue(member); - var memberType = getFreshTypeOfLiteralType(getLiteralType(value !== undefined ? value : 0, enumCount, getSymbolOfNode(member))); - getSymbolLinks(getSymbolOfNode(member)).declaredType = memberType; - memberTypeList.push(getRegularTypeOfLiteralType(memberType)); + if (symbol.declarations) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 257 /* EnumDeclaration */) { + for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { + var member = _c[_b]; + var value = getEnumMemberValue(member); + var memberType = getFreshTypeOfLiteralType(getLiteralType(value !== undefined ? value : 0, enumCount, getSymbolOfNode(member))); + getSymbolLinks(getSymbolOfNode(member)).declaredType = memberType; + memberTypeList.push(getRegularTypeOfLiteralType(memberType)); + } } } } @@ -52432,22 +54211,22 @@ var ts; */ function isThislessType(node) { switch (node.kind) { - case 128 /* AnyKeyword */: - case 152 /* UnknownKeyword */: - case 147 /* StringKeyword */: - case 144 /* NumberKeyword */: - case 155 /* BigIntKeyword */: - case 131 /* BooleanKeyword */: - case 148 /* SymbolKeyword */: - case 145 /* ObjectKeyword */: - case 113 /* VoidKeyword */: - case 150 /* UndefinedKeyword */: - case 141 /* NeverKeyword */: - case 191 /* LiteralType */: + case 129 /* AnyKeyword */: + case 153 /* UnknownKeyword */: + case 148 /* StringKeyword */: + case 145 /* NumberKeyword */: + case 156 /* BigIntKeyword */: + case 132 /* BooleanKeyword */: + case 149 /* SymbolKeyword */: + case 146 /* ObjectKeyword */: + case 114 /* VoidKeyword */: + case 151 /* UndefinedKeyword */: + case 142 /* NeverKeyword */: + case 193 /* LiteralType */: return true; - case 178 /* ArrayType */: + case 180 /* ArrayType */: return isThislessType(node.elementType); - case 173 /* TypeReference */: + case 175 /* TypeReference */: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -52473,7 +54252,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 166 /* Constructor */ || (!!returnType && isThislessType(returnType))) && + return (node.kind === 168 /* Constructor */ || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -52489,14 +54268,14 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: return isThislessVariableLikeDeclaration(declaration); - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return isThislessFunctionLikeDeclaration(declaration); } } @@ -52522,7 +54301,7 @@ var ts; } } function isStaticPrivateIdentifierProperty(s) { - return !!s.valueDeclaration && ts.isPrivateIdentifierPropertyDeclaration(s.valueDeclaration) && ts.hasSyntacticModifier(s.valueDeclaration, 32 /* Static */); + return !!s.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(s.valueDeclaration) && ts.hasSyntacticModifier(s.valueDeclaration, 32 /* Static */); } function resolveDeclaredMembers(type) { if (!type.declaredProperties) { @@ -52574,10 +54353,10 @@ var ts; return !!name && isLateBindableName(name); } /** - * Indicates whether a declaration has a dynamic name that cannot be late-bound. + * Indicates whether a declaration has an early-bound name or a dynamic name that can be late-bound. */ - function hasNonBindableDynamicName(node) { - return ts.hasDynamicName(node) && !hasLateBindableName(node); + function hasBindableName(node) { + return !ts.hasDynamicName(node) || hasLateBindableName(node); } /** * Indicates whether a declaration name is a dynamic name that cannot be late-bound. @@ -52847,7 +54626,8 @@ var ts; sig.resolvedMinArgumentCount = undefined; sig.target = undefined; sig.mapper = undefined; - sig.unionSignatures = undefined; + sig.compositeSignatures = undefined; + sig.compositeKind = undefined; return sig; } function cloneSignature(sig) { @@ -52855,12 +54635,14 @@ var ts; /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* PropagatingFlags */); result.target = sig.target; result.mapper = sig.mapper; - result.unionSignatures = sig.unionSignatures; + result.compositeSignatures = sig.compositeSignatures; + result.compositeKind = sig.compositeKind; return result; } function createUnionSignature(signature, unionSignatures) { var result = cloneSignature(signature); - result.unionSignatures = unionSignatures; + result.compositeSignatures = unionSignatures; + result.compositeKind = 1048576 /* Union */; result.target = undefined; result.mapper = undefined; return result; @@ -53019,7 +54801,7 @@ var ts; if (signatures !== masterList) { var signature_1 = signatures[0]; ts.Debug.assert(!!signature_1, "getUnionSignatures bails early on empty signature lists and should not have empty lists on second pass"); - results = signature_1.typeParameters && ts.some(results, function (s) { return !!s.typeParameters && !compareTypeParametersIdentical(signature_1.typeParameters, s.typeParameters); }) ? undefined : ts.map(results, function (sig) { return combineSignaturesOfUnionMembers(sig, signature_1); }); + results = !!signature_1.typeParameters && ts.some(results, function (s) { return !!s.typeParameters && !compareTypeParametersIdentical(signature_1.typeParameters, s.typeParameters); }) ? undefined : ts.map(results, function (sig) { return combineSignaturesOfUnionMembers(sig, signature_1); }); if (!results) { return "break"; } @@ -53036,9 +54818,12 @@ var ts; return result || ts.emptyArray; } function compareTypeParametersIdentical(sourceParams, targetParams) { - if (sourceParams.length !== targetParams.length) { + if (ts.length(sourceParams) !== ts.length(targetParams)) { return false; } + if (!sourceParams || !targetParams) { + return true; + } var mapper = createTypeMapper(targetParams, sourceParams); for (var i = 0; i < sourceParams.length; i++) { var source = sourceParams[i]; @@ -53120,9 +54905,10 @@ var ts; var result = createSignature(declaration, typeParams, thisParam, params, /*resolvedReturnType*/ undefined, /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* PropagatingFlags */); - result.unionSignatures = ts.concatenate(left.unionSignatures || [left], [right]); + result.compositeKind = 1048576 /* Union */; + result.compositeSignatures = ts.concatenate(left.compositeKind !== 2097152 /* Intersection */ && left.compositeSignatures || [left], [right]); if (paramMapper) { - result.mapper = left.mapper && left.unionSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; + result.mapper = left.compositeKind !== 2097152 /* Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; } return result; } @@ -53255,6 +55041,7 @@ var ts; // Combinations of function, class, enum and module var members = emptySymbols; var stringIndexInfo = void 0; + var numberIndexInfo = void 0; if (symbol.exports) { members = getExportsOfSymbol(symbol); if (symbol === globalThisSymbol) { @@ -53267,20 +55054,31 @@ var ts; members = varsOnly_1; } } + var baseConstructorIndexInfo = void 0; setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, undefined, undefined); if (symbol.flags & 32 /* Class */) { var classType = getDeclaredTypeOfClassOrInterface(symbol); var baseConstructorType = getBaseConstructorTypeOfClass(classType); if (baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 8650752 /* TypeVariable */)) { - members = ts.createSymbolTable(getNamedMembers(members)); + members = ts.createSymbolTable(getNamedOrIndexSignatureMembers(members)); addInheritedMembers(members, getPropertiesOfType(baseConstructorType)); } else if (baseConstructorType === anyType) { - stringIndexInfo = createIndexInfo(anyType, /*isReadonly*/ false); + baseConstructorIndexInfo = createIndexInfo(anyType, /*isReadonly*/ false); + } + } + var indexSymbol = getIndexSymbolFromSymbolTable(members); + if (indexSymbol) { + stringIndexInfo = getIndexInfoOfIndexSymbol(indexSymbol, 0 /* String */); + numberIndexInfo = getIndexInfoOfIndexSymbol(indexSymbol, 1 /* Number */); + } + else { + stringIndexInfo = baseConstructorIndexInfo; + if (symbol.flags & 384 /* Enum */ && (getDeclaredTypeOfSymbol(symbol).flags & 32 /* Enum */ || + ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296 /* NumberLike */); }))) { + numberIndexInfo = enumNumberIndexInfo; } } - var numberIndexInfo = symbol.flags & 384 /* Enum */ && (getDeclaredTypeOfSymbol(symbol).flags & 32 /* Enum */ || - ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296 /* NumberLike */); })) ? enumNumberIndexInfo : undefined; setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); // We resolve the members before computing the signatures because a signature may use // typeof with a qualified name expression that circularly references the type we are @@ -53305,6 +55103,18 @@ var ts; } } } + function replaceIndexedAccess(instantiable, type, replacement) { + // map type.indexType to 0 + // map type.objectType to `[TReplacement]` + // thus making the indexed access `[TReplacement][0]` or `TReplacement` + return instantiateType(instantiable, createTypeMapper([type.indexType, type.objectType], [getLiteralType(0), createTupleType([replacement])])); + } + function getIndexInfoOfIndexSymbol(indexSymbol, indexKind) { + var declaration = getIndexDeclarationOfIndexSymbol(indexSymbol, indexKind); + if (!declaration) + return undefined; + return createIndexInfo(declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasEffectiveModifier(declaration, 64 /* Readonly */), declaration); + } function resolveReverseMappedTypeMembers(type) { var indexInfo = getIndexInfoOfType(type.source, 0 /* String */); var modifiers = getMappedTypeModifiers(type.mappedType); @@ -53319,8 +55129,21 @@ var ts; inferredProp.declarations = prop.declarations; inferredProp.nameType = getSymbolLinks(prop).nameType; inferredProp.propertyType = getTypeOfSymbol(prop); - inferredProp.mappedType = type.mappedType; - inferredProp.constraintType = type.constraintType; + if (type.constraintType.type.flags & 8388608 /* IndexedAccess */ + && type.constraintType.type.objectType.flags & 262144 /* TypeParameter */ + && type.constraintType.type.indexType.flags & 262144 /* 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 + var newTypeParam = type.constraintType.type.objectType; + var newMappedType = replaceIndexedAccess(type.mappedType, type.constraintType.type, newTypeParam); + inferredProp.mappedType = newMappedType; + inferredProp.constraintType = getIndexType(newTypeParam); + } + else { + inferredProp.mappedType = type.mappedType; + inferredProp.constraintType = type.constraintType; + } members.set(prop.escapedName, inferredProp); } setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, undefined); @@ -53447,7 +55270,7 @@ 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) : + var type = strictNullChecks && symbol.flags & 16777216 /* Optional */ && !maybeTypeOfKind(propType, 32768 /* Undefined */ | 16384 /* Void */) ? getOptionalType(propType, /*isProperty*/ true) : symbol.checkFlags & 524288 /* StripOptional */ ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : propType; if (!popTypeResolution()) { @@ -53474,7 +55297,7 @@ var ts; function getTemplateTypeFromMappedType(type) { return type.templateType || (type.templateType = type.declaration.type ? - instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), type.mapper) : + instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), /*isProperty*/ true, !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), type.mapper) : errorType); } function getConstraintDeclarationForMappedType(type) { @@ -53482,8 +55305,8 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 188 /* TypeOperator */ && - constraintDeclaration.operator === 138 /* KeyOfKeyword */; + return constraintDeclaration.kind === 190 /* TypeOperator */ && + constraintDeclaration.operator === 139 /* KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { @@ -53534,7 +55357,7 @@ var ts; else if (type.objectFlags & 3 /* ClassOrInterface */) { resolveClassOrInterfaceMembers(type); } - else if (type.objectFlags & 2048 /* ReverseMapped */) { + else if (type.objectFlags & 1024 /* ReverseMapped */) { resolveReverseMappedTypeMembers(type); } else if (type.objectFlags & 16 /* Anonymous */) { @@ -53650,14 +55473,14 @@ var ts; function getConstraintFromIndexedAccess(type) { var indexConstraint = getSimplifiedTypeOrConstraint(type.indexType); if (indexConstraint && indexConstraint !== type.indexType) { - var indexedAccess = getIndexedAccessTypeOrUndefined(type.objectType, indexConstraint, type.noUncheckedIndexedAccessCandidate); + var indexedAccess = getIndexedAccessTypeOrUndefined(type.objectType, indexConstraint, type.accessFlags); if (indexedAccess) { return indexedAccess; } } var objectConstraint = getSimplifiedTypeOrConstraint(type.objectType); if (objectConstraint && objectConstraint !== type.objectType) { - return getIndexedAccessTypeOrUndefined(objectConstraint, type.indexType, type.noUncheckedIndexedAccessCandidate); + return getIndexedAccessTypeOrUndefined(objectConstraint, type.indexType, type.accessFlags); } return undefined; } @@ -53818,12 +55641,22 @@ var ts; if (t.flags & 3145728 /* UnionOrIntersection */) { var types = t.types; var baseTypes = []; + var different = false; for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { var type_3 = types_8[_i]; var baseType = getBaseConstraint(type_3); if (baseType) { + if (baseType !== type_3) { + different = true; + } baseTypes.push(baseType); } + else { + different = true; + } + } + if (!different) { + return t; } return t.flags & 1048576 /* Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) : t.flags & 2097152 /* Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) : @@ -53844,7 +55677,7 @@ var ts; if (t.flags & 8388608 /* IndexedAccess */) { var baseObjectType = getBaseConstraint(t.objectType); var baseIndexType = getBaseConstraint(t.indexType); - var baseIndexedAccess = baseObjectType && baseIndexType && getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, t.noUncheckedIndexedAccessCandidate); + var baseIndexedAccess = baseObjectType && baseIndexType && getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, t.accessFlags); return baseIndexedAccess && getBaseConstraint(baseIndexedAccess); } if (t.flags & 16777216 /* Conditional */) { @@ -53943,6 +55776,7 @@ var ts; return getReducedType(getApparentType(getReducedType(type))); } function createUnionOrIntersectionProperty(containingType, name, skipObjectFunctionPropertyAugment) { + var _a, _b; var singleProp; var propSet; var indexTypes; @@ -53951,8 +55785,9 @@ var ts; var optionalFlag = isUnion ? 0 /* None */ : 16777216 /* Optional */; var syntheticFlag = 4 /* SyntheticMethod */; var checkFlags = 0; - for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { - var current = _a[_i]; + var mergedInstantiations = false; + for (var _i = 0, _c = containingType.types; _i < _c.length; _i++) { + var current = _c[_i]; var type = getApparentType(current); if (!(type === errorType || type.flags & 131072 /* Never */)) { var prop = getPropertyOfType(type, name, skipObjectFunctionPropertyAugment); @@ -53968,13 +55803,25 @@ var ts; singleProp = prop; } else if (prop !== singleProp) { - if (!propSet) { - propSet = new ts.Map(); - propSet.set(getSymbolId(singleProp), singleProp); + var isInstantiation = (getTargetSymbol(prop) || prop) === (getTargetSymbol(singleProp) || singleProp); + // 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 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[]` + mergedInstantiations = !!singleProp.parent && !!ts.length(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(singleProp.parent)); } - var id = getSymbolId(prop); - if (!propSet.has(id)) { - propSet.set(id, prop); + else { + if (!propSet) { + propSet = new ts.Map(); + propSet.set(getSymbolId(singleProp), singleProp); + } + var id = getSymbolId(prop); + if (!propSet.has(id)) { + propSet.set(id, prop); + } } } checkFlags |= (isReadonlySymbol(prop) ? 8 /* Readonly */ : 0) | @@ -53992,7 +55839,7 @@ var ts; checkFlags |= 32 /* WritePartial */ | (indexInfo.isReadonly ? 8 /* Readonly */ : 0); indexTypes = ts.append(indexTypes, isTupleType(type) ? getRestTypeOfTupleType(type) || undefinedType : indexInfo.type); } - else if (isObjectLiteralType(type)) { + else if (isObjectLiteralType(type) && !(ts.getObjectFlags(type) & 4194304 /* ContainsSpread */)) { checkFlags |= 32 /* WritePartial */; indexTypes = ts.append(indexTypes, undefinedType); } @@ -54008,7 +55855,19 @@ var ts; return undefined; } if (!propSet && !(checkFlags & 16 /* ReadPartial */) && !indexTypes) { - return singleProp; + 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!) + // They also have a `.containingType` set, which affects some services endpoints behavior, like `getRootSymbol` + var clone_1 = createSymbolWithType(singleProp, singleProp.type); + clone_1.parent = (_b = (_a = singleProp.valueDeclaration) === null || _a === void 0 ? void 0 : _a.symbol) === null || _b === void 0 ? void 0 : _b.parent; + clone_1.containingType = containingType; + clone_1.mapper = singleProp.mapper; + return clone_1; + } + else { + return singleProp; + } } var props = propSet ? ts.arrayFrom(propSet.values()) : [singleProp]; var declarations; @@ -54017,8 +55876,8 @@ var ts; var propTypes = []; var firstValueDeclaration; var hasNonUniformValueDeclaration = false; - for (var _b = 0, props_1 = props; _b < props_1.length; _b++) { - var prop = props_1[_b]; + for (var _d = 0, props_1 = props; _d < props_1.length; _d++) { + var prop = props_1[_d]; if (!firstValueDeclaration) { firstValueDeclaration = prop.valueDeclaration; } @@ -54095,15 +55954,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 & 268435456 /* ContainsIntersections */) { + if (type.flags & 1048576 /* Union */ && type.objectFlags & 67108864 /* ContainsIntersections */) { return type.resolvedReducedType || (type.resolvedReducedType = getReducedUnionType(type)); } else if (type.flags & 2097152 /* Intersection */) { - if (!(type.objectFlags & 268435456 /* IsNeverIntersectionComputed */)) { - type.objectFlags |= 268435456 /* IsNeverIntersectionComputed */ | - (ts.some(getPropertiesOfUnionOrIntersectionType(type), isNeverReducedProperty) ? 536870912 /* IsNeverIntersection */ : 0); + if (!(type.objectFlags & 67108864 /* IsNeverIntersectionComputed */)) { + type.objectFlags |= 67108864 /* IsNeverIntersectionComputed */ | + (ts.some(getPropertiesOfUnionOrIntersectionType(type), isNeverReducedProperty) ? 134217728 /* IsNeverIntersection */ : 0); } - return type.objectFlags & 536870912 /* IsNeverIntersection */ ? neverType : type; + return type.objectFlags & 134217728 /* IsNeverIntersection */ ? neverType : type; } return type; } @@ -54133,7 +55992,7 @@ var ts; return !prop.valueDeclaration && !!(ts.getCheckFlags(prop) & 1024 /* ContainsPrivate */); } function elaborateNeverIntersection(errorInfo, type) { - if (ts.getObjectFlags(type) & 536870912 /* IsNeverIntersection */) { + if (type.flags & 2097152 /* Intersection */ && ts.getObjectFlags(type) & 134217728 /* 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)); @@ -54220,7 +56079,8 @@ var ts; for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) { var prop = _a[_i]; if (kind === 0 /* String */ || isNumericLiteralName(prop.escapedName)) { - propTypes.push(getTypeOfSymbol(prop)); + var propType = getTypeOfSymbol(prop); + propTypes.push(prop.flags & 16777216 /* Optional */ ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : propType); } } if (kind === 0 /* String */) { @@ -54254,10 +56114,10 @@ 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 === 307 /* JSDocOptionalType */ + node.type && node.type.kind === 310 /* JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 307 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 310 /* JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -54289,12 +56149,15 @@ var ts; } return false; } + function isOptionalPropertyDeclaration(node) { + return ts.isPropertyDeclaration(node) && node.questionToken; + } function isOptionalJSDocPropertyLikeTag(node) { if (!ts.isJSDocPropertyLikeTag(node)) { return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 307 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 310 /* JSDocOptionalType */; } function createTypePredicate(kind, parameterName, parameterIndex, type) { return { kind: kind, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; @@ -54376,7 +56239,7 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 191 /* LiteralType */) { + if (type && type.kind === 193 /* LiteralType */) { flags |= 2 /* HasLiteralTypes */; } // Record a new minimum argument count if this is not an optional parameter @@ -54389,16 +56252,16 @@ 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 === 167 /* GetAccessor */ || declaration.kind === 168 /* SetAccessor */) && - !hasNonBindableDynamicName(declaration) && + if ((declaration.kind === 169 /* GetAccessor */ || declaration.kind === 170 /* SetAccessor */) && + hasBindableName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 167 /* GetAccessor */ ? 168 /* SetAccessor */ : 167 /* GetAccessor */; + var otherKind = declaration.kind === 169 /* GetAccessor */ ? 170 /* SetAccessor */ : 169 /* GetAccessor */; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 166 /* Constructor */ ? + var classType = declaration.kind === 168 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); @@ -54443,8 +56306,7 @@ var ts; if (!(ts.isInJSFile(node) && ts.isFunctionLikeDeclaration(node))) return undefined; var typeTag = ts.getJSDocTypeTag(node); - var signature = typeTag && typeTag.typeExpression && getSingleCallSignature(getTypeFromTypeNode(typeTag.typeExpression)); - return signature && getErasedSignature(signature); + return (typeTag === null || typeTag === void 0 ? void 0 : typeTag.typeExpression) && getSingleCallSignature(getTypeFromTypeNode(typeTag.typeExpression)); } function getReturnTypeOfTypeTag(node) { var signature = getSignatureOfTypeTag(node); @@ -54465,16 +56327,16 @@ var ts; if (!node) return false; switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return node.escapedText === argumentsSymbol.escapedName && getResolvedSymbol(node) === argumentsSymbol; - case 163 /* PropertyDeclaration */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - return node.name.kind === 158 /* ComputedPropertyName */ + case 165 /* PropertyDeclaration */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + return node.name.kind === 160 /* ComputedPropertyName */ && traverse(node.name); - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: return traverse(node.expression); default: return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); @@ -54482,7 +56344,7 @@ var ts; } } function getSignaturesOfSymbol(symbol) { - if (!symbol) + if (!symbol || !symbol.declarations) return ts.emptyArray; var result = []; for (var i = 0; i < symbol.declarations.length; i++) { @@ -54523,8 +56385,8 @@ var ts; var targetTypePredicate = getTypePredicateOfSignature(signature.target); signature.resolvedTypePredicate = targetTypePredicate ? instantiateTypePredicate(targetTypePredicate, signature.mapper) : noTypePredicate; } - else if (signature.unionSignatures) { - signature.resolvedTypePredicate = getUnionTypePredicate(signature.unionSignatures) || noTypePredicate; + else if (signature.compositeSignatures) { + signature.resolvedTypePredicate = getUnionOrIntersectionTypePredicate(signature.compositeSignatures, signature.compositeKind) || noTypePredicate; } else { var type = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); @@ -54546,17 +56408,20 @@ var ts; function createTypePredicateFromTypePredicateNode(node, signature) { var parameterName = node.parameterName; var type = node.type && getTypeFromTypeNode(node.type); - return parameterName.kind === 187 /* ThisType */ ? + return parameterName.kind === 189 /* 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); } + function getUnionOrIntersectionType(types, kind, unionReduction) { + return kind !== 2097152 /* Intersection */ ? getUnionType(types, unionReduction) : getIntersectionType(types); + } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { if (!pushTypeResolution(signature, 3 /* ResolvedReturnType */)) { return errorType; } var type = signature.target ? instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper) : - signature.unionSignatures ? instantiateType(getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature), 2 /* Subtype */), signature.mapper) : + signature.compositeSignatures ? instantiateType(getUnionOrIntersectionType(ts.map(signature.compositeSignatures, getReturnTypeOfSignature), signature.compositeKind, 2 /* Subtype */), signature.mapper) : getReturnTypeFromAnnotation(signature.declaration) || (ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration)); if (signature.flags & 8 /* IsInnerCallChain */) { @@ -54589,7 +56454,7 @@ var ts; return signature.resolvedReturnType; } function getReturnTypeFromAnnotation(declaration) { - if (declaration.kind === 166 /* Constructor */) { + if (declaration.kind === 168 /* Constructor */) { return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)); } if (ts.isJSDocConstructSignature(declaration)) { @@ -54599,12 +56464,12 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 167 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { + if (declaration.kind === 169 /* GetAccessor */ && hasBindableName(declaration)) { var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration); if (jsDocType) { return jsDocType; } - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 168 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 170 /* SetAccessor */); var setterType = getAnnotatedAccessorType(setter); if (setterType) { return setterType; @@ -54681,9 +56546,20 @@ var ts; function getBaseSignature(signature) { var typeParameters = signature.typeParameters; if (typeParameters) { - var typeEraser_1 = createTypeEraser(typeParameters); - var baseConstraints = ts.map(typeParameters, function (tp) { return instantiateType(getBaseConstraintOfType(tp), typeEraser_1) || unknownType; }); - return instantiateSignature(signature, createTypeMapper(typeParameters, baseConstraints), /*eraseTypeParameters*/ true); + if (signature.baseSignatureCache) { + return signature.baseSignatureCache; + } + var typeEraser = createTypeEraser(typeParameters); + var baseConstraintMapper_1 = createTypeMapper(typeParameters, ts.map(typeParameters, function (tp) { return getConstraintOfTypeParameter(tp) || unknownType; })); + var baseConstraints = ts.map(typeParameters, function (tp) { return instantiateType(tp, baseConstraintMapper_1) || unknownType; }); + // Run N type params thru the immediate constraint mapper up to N times + // This way any noncircular interdependent type parameters are definitely resolved to their external dependencies + for (var i = 0; i < typeParameters.length - 1; i++) { + baseConstraints = instantiateTypes(baseConstraints, baseConstraintMapper_1); + } + // and then apply a type eraser to remove any remaining circularly dependent type parameters + baseConstraints = instantiateTypes(baseConstraints, typeEraser); + return signature.baseSignatureCache = instantiateSignature(signature, createTypeMapper(typeParameters, baseConstraints), /*eraseTypeParameters*/ true); } return signature; } @@ -54694,7 +56570,7 @@ var ts; // will result in a different declaration kind. if (!signature.isolatedSignatureType) { var kind = signature.declaration ? signature.declaration.kind : 0 /* Unknown */; - var isConstructor = kind === 166 /* Constructor */ || kind === 170 /* ConstructSignature */ || kind === 175 /* ConstructorType */; + var isConstructor = kind === 168 /* Constructor */ || kind === 172 /* ConstructSignature */ || kind === 177 /* ConstructorType */; var type = createObjectType(16 /* Anonymous */); type.members = emptySymbols; type.properties = ts.emptyArray; @@ -54705,12 +56581,22 @@ var ts; return signature.isolatedSignatureType; } function getIndexSymbol(symbol) { - return symbol.members.get("__index" /* Index */); + return symbol.members ? getIndexSymbolFromSymbolTable(symbol.members) : undefined; + } + function getIndexSymbolFromSymbolTable(symbolTable) { + return symbolTable.get("__index" /* Index */); } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 144 /* NumberKeyword */ : 147 /* StringKeyword */; - var indexSymbol = getIndexSymbol(symbol); - if (indexSymbol) { + var indexSymbol = symbol && getIndexSymbol(symbol); + return indexSymbol && getIndexDeclarationOfIndexSymbol(indexSymbol, kind); + } + function getIndexDeclarationOfSymbolTable(symbolTable, kind) { + var indexSymbol = symbolTable && getIndexSymbolFromSymbolTable(symbolTable); + return indexSymbol && getIndexDeclarationOfIndexSymbol(indexSymbol, kind); + } + function getIndexDeclarationOfIndexSymbol(indexSymbol, kind) { + var syntaxKind = kind === 1 /* Number */ ? 145 /* NumberKeyword */ : 148 /* StringKeyword */; + if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; var node = ts.cast(decl, ts.isIndexSignatureDeclaration); @@ -54738,17 +56624,18 @@ var ts; return ts.mapDefined(ts.filter(type.symbol && type.symbol.declarations, ts.isTypeParameterDeclaration), ts.getEffectiveConstraintOfTypeParameter)[0]; } function getInferredTypeParameterConstraint(typeParameter) { + var _a; var inferences; - if (typeParameter.symbol) { - for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.parent.kind === 185 /* InferType */) { + 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 === 187 /* 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 _b = ts.walkUpParenthesizedTypesAndGetParentAndChild(declaration.parent.parent), _c = _b[0], childTypeParameter = _c === void 0 ? declaration.parent : _c, grandParent = _b[1]; - if (grandParent.kind === 173 /* TypeReference */) { + var _c = ts.walkUpParenthesizedTypesAndGetParentAndChild(declaration.parent.parent), _d = _c[0], childTypeParameter = _d === void 0 ? declaration.parent : _d, grandParent = _c[1]; + if (grandParent.kind === 175 /* TypeReference */) { var typeReference = grandParent; var typeParameters = getTypeParametersForTypeReference(typeReference); if (typeParameters) { @@ -54773,21 +56660,32 @@ 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 === 160 /* Parameter */ && grandParent.dotDotDotToken || - grandParent.kind === 181 /* RestType */ || - grandParent.kind === 192 /* NamedTupleMember */ && grandParent.dotDotDotToken) { + else if (grandParent.kind === 162 /* Parameter */ && grandParent.dotDotDotToken || + grandParent.kind === 183 /* RestType */ || + grandParent.kind === 194 /* 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 === 194 /* TemplateLiteralTypeSpan */) { + else if (grandParent.kind === 196 /* 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 === 159 /* TypeParameter */ && grandParent.parent.kind === 190 /* MappedType */) { + else if (grandParent.kind === 161 /* TypeParameter */ && grandParent.parent.kind === 192 /* 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 === 192 /* MappedType */ && grandParent.type && + ts.skipParentheses(grandParent.type) === declaration.parent && grandParent.parent.kind === 186 /* ConditionalType */ && + grandParent.parent.extendsType === grandParent && grandParent.parent.checkType.kind === 192 /* 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))); + } } } } @@ -54810,7 +56708,7 @@ var ts; if (type.flags & 1 /* Any */ && type !== errorType) { // 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 === 190 /* MappedType */ ? keyofConstraintType : unknownType; + type = constraintDeclaration.parent.parent.kind === 192 /* MappedType */ ? keyofConstraintType : unknownType; } typeParameter.constraint = type; } @@ -54819,7 +56717,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - var tp = ts.getDeclarationOfKind(typeParameter.symbol, 159 /* TypeParameter */); + var tp = ts.getDeclarationOfKind(typeParameter.symbol, 161 /* TypeParameter */); var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getHostSignatureFromJSDoc(tp.parent) : tp.parent; return host && getSymbolOfNode(host); } @@ -54846,6 +56744,9 @@ var ts; } return result; } + function getAliasId(aliasSymbol, aliasTypeArguments) { + return aliasSymbol ? "@" + getSymbolId(aliasSymbol) + (aliasTypeArguments ? ":" + 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 @@ -54858,7 +56759,7 @@ var ts; result |= ts.getObjectFlags(type); } } - return result & 3670016 /* PropagatingFlags */; + return result & 917504 /* PropagatingFlags */; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); @@ -54880,15 +56781,18 @@ var ts; type.resolvedTypeArguments = source.resolvedTypeArguments; return type; } - function createDeferredTypeReference(target, node, mapper) { - var aliasSymbol = getAliasSymbolForTypeNode(node); - var aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); + function createDeferredTypeReference(target, node, mapper, aliasSymbol, aliasTypeArguments) { + if (!aliasSymbol) { + aliasSymbol = getAliasSymbolForTypeNode(node); + var localAliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); + aliasTypeArguments = mapper ? instantiateTypes(localAliasTypeArguments, mapper) : localAliasTypeArguments; + } var type = createObjectType(4 /* Reference */, target.symbol); type.target = target; type.node = node; type.mapper = mapper; type.aliasSymbol = aliasSymbol; - type.aliasTypeArguments = mapper ? instantiateTypes(aliasTypeArguments, mapper) : aliasTypeArguments; + type.aliasTypeArguments = aliasTypeArguments; return type; } function getTypeArguments(type) { @@ -54899,8 +56803,8 @@ var ts; } var node = type.node; var typeArguments = !node ? ts.emptyArray : - node.kind === 173 /* TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : - node.kind === 178 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : + node.kind === 175 /* TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : + node.kind === 180 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); if (popTypeResolution()) { type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments; @@ -54942,7 +56846,7 @@ var ts; return errorType; } } - if (node.kind === 173 /* TypeReference */ && isDeferredTypeReferenceNode(node, ts.length(node.typeArguments) !== typeParameters.length)) { + if (node.kind === 175 /* 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 @@ -54953,17 +56857,17 @@ var ts; } return checkNoTypeArguments(node, symbol) ? type : errorType; } - function getTypeAliasInstantiation(symbol, typeArguments) { + function getTypeAliasInstantiation(symbol, typeArguments, aliasSymbol, aliasTypeArguments) { var type = getDeclaredTypeOfSymbol(symbol); if (type === intrinsicMarkerType && intrinsicTypeKinds.has(symbol.escapedName) && typeArguments && typeArguments.length === 1) { return getStringMappingType(symbol, typeArguments[0]); } var links = getSymbolLinks(symbol); var typeParameters = links.typeParameters; - var id = getTypeListId(typeArguments); + var id = getTypeListId(typeArguments) + getAliasId(aliasSymbol, aliasTypeArguments); var instantiation = links.instantiations.get(id); if (!instantiation) { - links.instantiations.set(id, instantiation = instantiateType(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters), ts.isInJSFile(symbol.valueDeclaration))))); + links.instantiations.set(id, instantiation = instantiateTypeWithAlias(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters), ts.isInJSFile(symbol.valueDeclaration))), aliasSymbol, aliasTypeArguments)); } return instantiation; } @@ -54984,15 +56888,26 @@ var ts; ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); return errorType; } - return getTypeAliasInstantiation(symbol, typeArgumentsFromTypeReferenceNode(node)); + // We refrain from associating a local type alias with an instantiation of a top-level type alias + // because the local alias may end up being referenced in an inferred return type where it is not + // accessible--which in turn may lead to a large structural expansion of the type when generating + // a .d.ts file. See #43622 for an example. + var aliasSymbol = getAliasSymbolForTypeNode(node); + var newAliasSymbol = aliasSymbol && (isLocalTypeAlias(symbol) || !isLocalTypeAlias(aliasSymbol)) ? aliasSymbol : undefined; + return getTypeAliasInstantiation(symbol, typeArgumentsFromTypeReferenceNode(node), newAliasSymbol, getTypeArgumentsForAliasSymbol(newAliasSymbol)); } return checkNoTypeArguments(node, symbol) ? type : errorType; } + function isLocalTypeAlias(symbol) { + var _a; + var declaration = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isTypeAlias); + return !!(declaration && ts.getContainingFunction(declaration)); + } function getTypeReferenceName(node) { switch (node.kind) { - case 173 /* TypeReference */: + case 175 /* TypeReference */: return node.typeName; - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -55048,7 +56963,7 @@ var ts; var valueType = getTypeOfSymbol(symbol); var typeType = valueType; if (symbol.valueDeclaration) { - var isImportTypeWithQualifier = node.kind === 195 /* ImportType */ && node.qualifier; + var isImportTypeWithQualifier = node.kind === 197 /* 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); @@ -55074,7 +56989,7 @@ var ts; return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 179 /* TupleType */ && node.elements.length === 1; + return node.kind === 181 /* TupleType */ && node.elements.length === 1; } function getImpliedConstraint(type, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(type, checkNode.elements[0], extendsNode.elements[0]) : @@ -55083,9 +56998,17 @@ var ts; } function getConditionalFlowTypeOfType(type, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 311 /* JSDocComment */) { + var covariant = true; + while (node && !ts.isStatement(node) && node.kind !== 314 /* JSDocComment */) { var parent = node.parent; - if (parent.kind === 184 /* ConditionalType */ && node === parent.trueType) { + // 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 === 162 /* 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 === 186 /* ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(type, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -55096,7 +57019,7 @@ var ts; return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type; } function isJSDocTypeReference(node) { - return !!(node.flags & 4194304 /* JSDoc */) && (node.kind === 173 /* TypeReference */ || node.kind === 195 /* ImportType */); + return !!(node.flags & 4194304 /* JSDoc */) && (node.kind === 175 /* TypeReference */ || node.kind === 197 /* ImportType */); } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -55206,13 +57129,15 @@ var ts; function getTypeOfGlobalSymbol(symbol, arity) { function getTypeDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { - var declaration = declarations_3[_i]; - switch (declaration.kind) { - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - return declaration; + if (declarations) { + for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { + var declaration = declarations_3[_i]; + switch (declaration.kind) { + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 257 /* EnumDeclaration */: + return declaration; + } } } } @@ -55256,6 +57181,9 @@ var ts; function getGlobalESSymbolConstructorSymbol(reportErrors) { return deferredGlobalESSymbolConstructorSymbol || (deferredGlobalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol", reportErrors)); } + function getGlobalESSymbolConstructorTypeSymbol(reportErrors) { + return deferredGlobalESSymbolConstructorTypeSymbol || (deferredGlobalESSymbolConstructorTypeSymbol = getGlobalTypeSymbol("SymbolConstructor", reportErrors)); + } function getGlobalESSymbolType(reportErrors) { return deferredGlobalESSymbolType || (deferredGlobalESSymbolType = getGlobalType("Symbol", /*arity*/ 0, reportErrors)) || emptyObjectType; } @@ -55332,11 +57260,11 @@ var ts; } function getTupleElementFlags(node) { switch (node.kind) { - case 180 /* OptionalType */: + case 182 /* OptionalType */: return 2 /* Optional */; - case 181 /* RestType */: + case 183 /* RestType */: return getRestTypeElementFlags(node); - case 192 /* NamedTupleMember */: + case 194 /* NamedTupleMember */: return node.questionToken ? 2 /* Optional */ : node.dotDotDotToken ? getRestTypeElementFlags(node) : 1 /* Required */; @@ -55354,14 +57282,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 !== 192 /* NamedTupleMember */; }); + var missingName = ts.some(node.elements, function (e) { return e.kind !== 194 /* 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 === 178 /* ArrayType */ ? mayResolveTypeAlias(node.elementType) : - node.kind === 179 /* TupleType */ ? ts.some(node.elements, mayResolveTypeAlias) : + return !!getAliasSymbolForTypeNode(node) || isResolvedByTypeAlias(node) && (node.kind === 180 /* ArrayType */ ? mayResolveTypeAlias(node.elementType) : + node.kind === 181 /* 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 @@ -55370,18 +57298,18 @@ var ts; function isResolvedByTypeAlias(node) { var parent = node.parent; switch (parent.kind) { - case 186 /* ParenthesizedType */: - case 192 /* NamedTupleMember */: - case 173 /* TypeReference */: - case 182 /* UnionType */: - case 183 /* IntersectionType */: - case 189 /* IndexedAccessType */: - case 184 /* ConditionalType */: - case 188 /* TypeOperator */: - case 178 /* ArrayType */: - case 179 /* TupleType */: + case 188 /* ParenthesizedType */: + case 194 /* NamedTupleMember */: + case 175 /* TypeReference */: + case 184 /* UnionType */: + case 185 /* IntersectionType */: + case 191 /* IndexedAccessType */: + case 186 /* ConditionalType */: + case 190 /* TypeOperator */: + case 180 /* ArrayType */: + case 181 /* TupleType */: return isResolvedByTypeAlias(parent); - case 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: return true; } return false; @@ -55390,28 +57318,28 @@ var ts; // of a type alias. function mayResolveTypeAlias(node) { switch (node.kind) { - case 173 /* TypeReference */: + case 175 /* TypeReference */: return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node.typeName, 788968 /* Type */).flags & 524288 /* TypeAlias */); - case 176 /* TypeQuery */: + case 178 /* TypeQuery */: return true; - case 188 /* TypeOperator */: - return node.operator !== 151 /* UniqueKeyword */ && mayResolveTypeAlias(node.type); - case 186 /* ParenthesizedType */: - case 180 /* OptionalType */: - case 192 /* NamedTupleMember */: - case 307 /* JSDocOptionalType */: - case 305 /* JSDocNullableType */: - case 306 /* JSDocNonNullableType */: - case 301 /* JSDocTypeExpression */: + case 190 /* TypeOperator */: + return node.operator !== 152 /* UniqueKeyword */ && mayResolveTypeAlias(node.type); + case 188 /* ParenthesizedType */: + case 182 /* OptionalType */: + case 194 /* NamedTupleMember */: + case 310 /* JSDocOptionalType */: + case 308 /* JSDocNullableType */: + case 309 /* JSDocNonNullableType */: + case 303 /* JSDocTypeExpression */: return mayResolveTypeAlias(node.type); - case 181 /* RestType */: - return node.type.kind !== 178 /* ArrayType */ || mayResolveTypeAlias(node.type.elementType); - case 182 /* UnionType */: - case 183 /* IntersectionType */: + case 183 /* RestType */: + return node.type.kind !== 180 /* ArrayType */ || mayResolveTypeAlias(node.type.elementType); + case 184 /* UnionType */: + case 185 /* IntersectionType */: return ts.some(node.types, mayResolveTypeAlias); - case 189 /* IndexedAccessType */: + case 191 /* IndexedAccessType */: return mayResolveTypeAlias(node.objectType) || mayResolveTypeAlias(node.indexType); - case 184 /* ConditionalType */: + case 186 /* ConditionalType */: return mayResolveTypeAlias(node.checkType) || mayResolveTypeAlias(node.extendsType) || mayResolveTypeAlias(node.trueType) || mayResolveTypeAlias(node.falseType); } @@ -55424,19 +57352,19 @@ var ts; if (target === emptyGenericType) { links.resolvedType = emptyObjectType; } - else if (!(node.kind === 179 /* TupleType */ && ts.some(node.elements, function (e) { return !!(getTupleElementFlags(e) & 8 /* Variadic */); })) && isDeferredTypeReferenceNode(node)) { - links.resolvedType = node.kind === 179 /* TupleType */ && node.elements.length === 0 ? target : + else if (!(node.kind === 181 /* TupleType */ && ts.some(node.elements, function (e) { return !!(getTupleElementFlags(e) & 8 /* Variadic */); })) && isDeferredTypeReferenceNode(node)) { + links.resolvedType = node.kind === 181 /* TupleType */ && node.elements.length === 0 ? target : createDeferredTypeReference(target, node, /*mapper*/ undefined); } else { - var elementTypes = node.kind === 178 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); + var elementTypes = node.kind === 180 /* 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 === 142 /* ReadonlyKeyword */; + return ts.isTypeOperatorNode(node) && node.operator === 143 /* ReadonlyKeyword */; } function createTupleType(elementTypes, elementFlags, readonly, namedMemberDeclarations) { if (readonly === void 0) { readonly = false; } @@ -55561,8 +57489,15 @@ var ts; addElement(type, 8 /* Variadic */, (_a = target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]); } else if (isTupleType(type)) { + var elements = getTypeArguments(type); + if (elements.length + expandedTypes.length >= 10000) { + error(currentNode, ts.isPartOfTypeNode(currentNode) + ? ts.Diagnostics.Type_produces_a_tuple_type_that_is_too_large_to_represent + : ts.Diagnostics.Expression_produces_a_tuple_type_that_is_too_large_to_represent); + return { value: errorType }; + } // Spread variadic elements with tuple types into the resulting tuple. - ts.forEach(getTypeArguments(type), function (t, n) { var _a; return addElement(t, type.target.elementFlags[n], (_a = type.target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[n]); }); + ts.forEach(elements, function (t, n) { var _a; return addElement(t, type.target.elementFlags[n], (_a = type.target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[n]); }); } else { // Treat everything else as an array type and create a rest element. @@ -55575,7 +57510,9 @@ var ts; } }; for (var i = 0; i < elementTypes.length; i++) { - _loop_13(i); + var state_4 = _loop_13(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++) { @@ -55634,8 +57571,7 @@ var ts; return type.elementFlags.length - ts.findLastIndex(type.elementFlags, function (f) { return !(f & flags); }) - 1; } function getTypeFromOptionalTypeNode(node) { - var type = getTypeFromTypeNode(node.type); - return strictNullChecks ? getOptionalType(type) : type; + return addOptionality(getTypeFromTypeNode(node.type), /*isProperty*/ true); } function getTypeId(type) { return type.id; @@ -55664,7 +57600,7 @@ var ts; if (type === wildcardType) includes |= 8388608 /* IncludesWildcard */; if (!strictNullChecks && flags & 98304 /* Nullable */) { - if (!(ts.getObjectFlags(type) & 524288 /* ContainsWideningType */)) + if (!(ts.getObjectFlags(type) & 131072 /* ContainsWideningType */)) includes |= 4194304 /* IncludesNonWideningType */; } else { @@ -55686,67 +57622,76 @@ var ts; } return includes; } - function isSetOfLiteralsFromSameEnum(types) { - var first = types[0]; - if (first.flags & 1024 /* EnumLiteral */) { - var firstEnum = getParentOfSymbol(first.symbol); - for (var i = 1; i < types.length; i++) { - var other = types[i]; - if (!(other.flags & 1024 /* EnumLiteral */) || (firstEnum !== getParentOfSymbol(other.symbol))) { - return false; - } - } - return true; + function removeSubtypes(types, hasObjectTypes) { + var id = getTypeListId(types); + var match = subtypeReductionCache.get(id); + if (match) { + return match; } - return false; - } - function removeSubtypes(types, primitivesOnly) { + // 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 len = types.length; - if (len === 0 || isSetOfLiteralsFromSameEnum(types)) { - return true; - } var i = len; var count = 0; while (i > 0) { i--; var source = types[i]; - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var target = types_11[_i]; - if (source !== target) { - if (count === 100000) { - // After 100000 subtype checks we estimate the remaining amount of work by assuming the - // same ratio of checks per element. If the estimated number of remaining type checks is - // greater than an upper limit we deem the union type too complex to represent. The - // upper limit is 25M for unions of primitives only, and 1M otherwise. This for example - // caps union types at 5000 unique literal types and 1000 unique object types. - var estimatedCount = (count / (len - i)) * len; - if (estimatedCount > (primitivesOnly ? 25000000 : 1000000)) { - ts.tracing.instant("checkTypes" /* 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 false; + if (hasEmptyObject || source.flags & 469499904 /* 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 */) ? + ts.find(getPropertiesOfType(source), function (p) { return isUnitType(getTypeOfSymbol(p)); }) : + undefined; + var keyPropertyType = keyProperty && getRegularTypeOfLiteralType(getTypeOfSymbol(keyProperty)); + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var target = types_11[_i]; + if (source !== target) { + if (count === 100000) { + // After 100000 subtype checks we estimate the remaining amount of work by assuming the + // same ratio of checks per element. If the estimated number of remaining type checks is + // greater than 1M we deem the union type too complex to represent. This for example + // 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; }) }); + 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 */)) { + 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 */) || + isTypeDerivedFrom(source, target))) { + ts.orderedRemoveItemAt(types, i); + break; } - } - count++; - if (isTypeRelatedTo(source, target, strictSubtypeRelation) && (!(ts.getObjectFlags(getTargetType(source)) & 1 /* Class */) || - !(ts.getObjectFlags(getTargetType(target)) & 1 /* Class */) || - isTypeDerivedFrom(source, target))) { - ts.orderedRemoveItemAt(types, i); - break; } } } } - return true; + subtypeReductionCache.set(id, types); + return types; } - function removeRedundantLiteralTypes(types, includes) { + function removeRedundantLiteralTypes(types, includes, reduceVoidUndefined) { var i = types.length; while (i > 0) { i--; var t = types[i]; - var remove = t.flags & 134217856 /* StringLikeLiteral */ && includes & 4 /* String */ || - t.flags & 256 /* NumberLiteral */ && includes & 8 /* Number */ || - t.flags & 2048 /* BigIntLiteral */ && includes & 64 /* BigInt */ || - t.flags & 8192 /* UniqueESSymbol */ && includes & 4096 /* ESSymbol */ || + var flags = t.flags; + var remove = flags & 128 /* StringLiteral */ && 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 */ || isFreshLiteralType(t) && containsType(types, t.regularType); if (remove) { ts.orderedRemoveItemAt(types, i); @@ -55778,7 +57723,7 @@ var ts; if (t.flags & 1048576 /* Union */) { var origin = t.origin; if (t.aliasSymbol || origin && !(origin.flags & 1048576 /* Union */)) { - namedUnions.push(t); + ts.pushIfUnique(namedUnions, t); } else if (origin && origin.flags & 1048576 /* Union */) { addNamedUnions(namedUnions, origin.types); @@ -55812,20 +57757,23 @@ var ts; if (includes & 3 /* AnyOrUnknown */) { return includes & 1 /* Any */ ? includes & 8388608 /* IncludesWildcard */ ? wildcardType : anyType : unknownType; } - switch (unionReduction) { - case 1 /* Literal */: - if (includes & (134220672 /* FreshableLiteral */ | 8192 /* UniqueESSymbol */)) { - removeRedundantLiteralTypes(typeSet, includes); - } - if (includes & 128 /* StringLiteral */ && includes & 134217728 /* TemplateLiteral */) { - removeStringLiteralsMatchedByTemplateLiterals(typeSet); - } - break; - case 2 /* Subtype */: - if (!removeSubtypes(typeSet, !(includes & 262144 /* IncludesStructuredOrInstantiable */))) { - return errorType; - } - break; + if (strictOptionalProperties && includes & 32768 /* 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 */) || includes & 16384 /* Void */ && includes & 32768 /* Undefined */) { + removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2 /* Subtype */)); + } + if (includes & 128 /* StringLiteral */ && includes & 134217728 /* TemplateLiteral */) { + removeStringLiteralsMatchedByTemplateLiterals(typeSet); + } + if (unionReduction === 2 /* Subtype */) { + typeSet = removeSubtypes(typeSet, !!(includes & 524288 /* Object */)); + if (!typeSet) { + return errorType; + } } if (typeSet.length === 0) { return includes & 65536 /* Null */ ? includes & 4194304 /* IncludesNonWideningType */ ? nullType : nullWideningType : @@ -55860,18 +57808,23 @@ var ts; origin = createOriginUnionOrIntersectionType(1048576 /* Union */, reducedTypes); } } - var objectFlags = (includes & 468598819 /* NotPrimitiveUnion */ ? 0 : 262144 /* PrimitiveUnion */) | - (includes & 2097152 /* Intersection */ ? 268435456 /* ContainsIntersections */ : 0); + var objectFlags = (includes & 468598819 /* NotPrimitiveUnion */ ? 0 : 65536 /* PrimitiveUnion */) | + (includes & 2097152 /* Intersection */ ? 67108864 /* ContainsIntersections */ : 0); return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin); } - function getUnionTypePredicate(signatures) { + function getUnionOrIntersectionTypePredicate(signatures, kind) { var first; var types = []; 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 */) { - continue; + if (kind !== 2097152 /* Intersection */) { + continue; + } + else { + return; // intersections demand all members be type predicates for the result to have a predicate + } } if (first) { if (!typePredicateKindsMatch(first, pred)) { @@ -55885,11 +57838,11 @@ var ts; types.push(pred.type); } if (!first) { - // No union signatures had a type predicate. + // No signatures had a type predicate. return undefined; } - var unionType = getUnionType(types); - return createTypePredicate(first.kind, first.parameterName, first.parameterIndex, unionType); + var compositeType = getUnionOrIntersectionType(types, kind); + return createTypePredicate(first.kind, first.parameterName, first.parameterIndex, compositeType); } function typePredicateKindsMatch(a, b) { return a.kind === b.kind && a.parameterIndex === b.parameterIndex; @@ -55914,8 +57867,8 @@ var ts; var typeKey = !origin ? getTypeListId(types) : origin.flags & 1048576 /* Union */ ? "|" + getTypeListId(origin.types) : origin.flags & 2097152 /* Intersection */ ? "&" + getTypeListId(origin.types) : - "#" + origin.type.id; - var id = typeKey + (aliasSymbol ? "@" + getSymbolId(aliasSymbol) : ""); + "#" + 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 + var id = typeKey + getAliasId(aliasSymbol, aliasTypeArguments); var type = unionTypes.get(id); if (!type) { type = createUnionType(types, aliasSymbol, aliasTypeArguments, origin); @@ -56041,7 +57994,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) & 262144 /* PrimitiveUnion */); }); + var index = ts.findIndex(types, function (t) { return !!(ts.getObjectFlags(t) & 65536 /* PrimitiveUnion */); }); if (index < 0) { return false; } @@ -56050,7 +58003,7 @@ var ts; // the unionTypes array. while (i < types.length) { var t = types[i]; - if (ts.getObjectFlags(t) & 262144 /* PrimitiveUnion */) { + if (ts.getObjectFlags(t) & 65536 /* PrimitiveUnion */) { (unionTypes || (unionTypes = [types[index]])).push(t); ts.orderedRemoveItemAt(types, i); } @@ -56079,14 +58032,14 @@ var ts; } } // Finally replace the first union with the result - types[index] = getUnionTypeFromSortedList(result, 262144 /* PrimitiveUnion */); + types[index] = getUnionTypeFromSortedList(result, 65536 /* PrimitiveUnion */); return true; } function createIntersectionType(types, aliasSymbol, aliasTypeArguments) { var result = createType(2097152 /* Intersection */); result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */); result.types = types; - result.aliasSymbol = aliasSymbol; // See comment in `getUnionTypeFromSortedList`. + result.aliasSymbol = aliasSymbol; result.aliasTypeArguments = aliasTypeArguments; return result; } @@ -56147,7 +58100,7 @@ var ts; if (typeSet.length === 1) { return typeSet[0]; } - var id = getTypeListId(typeSet) + (aliasSymbol ? "@" + getSymbolId(aliasSymbol) : ""); + var id = getTypeListId(typeSet) + getAliasId(aliasSymbol, aliasTypeArguments); var result = intersectionTypes.get(id); if (!result) { if (includes & 1048576 /* Union */) { @@ -56190,7 +58143,7 @@ var ts; function checkCrossProductUnion(types) { var size = getCrossProductUnionSize(types); if (size >= 100000) { - 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" /* 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; } @@ -56240,23 +58193,36 @@ var ts; type.resolvedStringIndexType || (type.resolvedStringIndexType = createIndexType(type, /*stringsOnly*/ true)) : type.resolvedIndexType || (type.resolvedIndexType = createIndexType(type, /*stringsOnly*/ false)); } + function instantiateTypeAsMappedNameType(nameType, type, t) { + return instantiateType(nameType, appendTypeMapping(type.mapper, getTypeParameterFromMappedType(type), t)); + } function getIndexTypeForMappedType(type, noIndexSignatures) { var constraint = filterType(getConstraintTypeFromMappedType(type), function (t) { return !(noIndexSignatures && t.flags & (1 /* Any */ | 4 /* String */)); }); var nameType = type.declaration.nameType && getTypeFromTypeNode(type.declaration.nameType); + // If the constraint is exclusively string/number/never type(s), we need to pull the property names from the modified type and run them through the `nameType` mapper as well + // since they won't appear in the constraint, due to subtype reducing with the string/number index types + var properties = nameType && everyType(constraint, function (t) { return !!(t.flags & (4 /* String */ | 8 /* Number */ | 131072 /* Never */)); }) && getPropertiesOfType(getApparentType(getModifiersTypeFromMappedType(type))); return nameType ? - mapType(constraint, function (t) { return instantiateType(nameType, appendTypeMapping(type.mapper, getTypeParameterFromMappedType(type), t)); }) : + getUnionType([mapType(constraint, function (t) { return instantiateTypeAsMappedNameType(nameType, type, t); }), mapType(getUnionType(ts.map(properties || ts.emptyArray, function (p) { return getLiteralTypeFromProperty(p, 8576 /* StringOrNumberLiteralOrUnique */); })), function (t) { return instantiateTypeAsMappedNameType(nameType, type, t); })]) : constraint; } // Ordinarily we reduce a keyof M, where M is a mapped type { [P in K as N

]: X }, to simply N. This however presumes - // that N distributes over union types, i.e. that N is equivalent to N | N | N. That presumption may not - // be true when N is a non-distributive conditional type or an instantiable type with a non-distributive conditional type as - // a constituent. In those cases, we cannot reduce keyof M and need to preserve it as is. - function maybeNonDistributiveNameType(type) { - return !!(type && (type.flags & 16777216 /* Conditional */ && (!type.root.isDistributive || maybeNonDistributiveNameType(type.checkType)) || - type.flags & (3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */) && ts.some(type.types, maybeNonDistributiveNameType) || - type.flags & (4194304 /* Index */ | 268435456 /* StringMapping */) && maybeNonDistributiveNameType(type.type) || - type.flags & 8388608 /* IndexedAccess */ && maybeNonDistributiveNameType(type.indexType) || - type.flags & 33554432 /* Substitution */ && maybeNonDistributiveNameType(type.substitute))); + // that N distributes over union types, i.e. that N is equivalent to N | N | N. Specifically, we only + // want to perform the reduction when the name type of a mapped type is distributive with respect to the type variable + // introduced by the 'in' clause of the mapped type. Note that non-generic types are considered to be distributive because + // they're the same type regardless of what's being distributed over. + function hasDistributiveNameType(mappedType) { + 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) : + false; + } } function getLiteralTypeFromPropertyName(name) { if (ts.isPrivateIdentifier(name)) { @@ -56274,13 +58240,13 @@ var ts; function getLiteralTypeFromProperty(prop, include) { if (!(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24 /* NonPublicAccessibilityModifier */)) { var type = getSymbolLinks(getLateBoundSymbol(prop)).nameType; - if (!type && !ts.isKnownSymbol(prop)) { + if (!type) { if (prop.escapedName === "default" /* Default */) { type = getLiteralType("default"); } else { var name = prop.valueDeclaration && ts.getNameOfDeclaration(prop.valueDeclaration); - type = name && getLiteralTypeFromPropertyName(name) || getLiteralType(ts.symbolName(prop)); + type = name && getLiteralTypeFromPropertyName(name) || (!ts.isKnownSymbol(prop) ? getLiteralType(ts.symbolName(prop)) : undefined); } } if (type && type.flags & include) { @@ -56304,7 +58270,7 @@ var ts; type = getReducedType(type); return type.flags & 1048576 /* Union */ ? 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) && maybeNonDistributiveNameType(getNameTypeFromMappedType(type)) ? getIndexTypeForGenericType(type, stringsOnly) : + type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) ? getIndexTypeForGenericType(type, stringsOnly) : ts.getObjectFlags(type) & 32 /* Mapped */ ? getIndexTypeForMappedType(type, noIndexSignatures) : type === wildcardType ? wildcardType : type.flags & 2 /* Unknown */ ? neverType : @@ -56329,15 +58295,15 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { switch (node.operator) { - case 138 /* KeyOfKeyword */: + case 139 /* KeyOfKeyword */: links.resolvedType = getIndexType(getTypeFromTypeNode(node.type)); break; - case 151 /* UniqueKeyword */: - links.resolvedType = node.type.kind === 148 /* SymbolKeyword */ + case 152 /* UniqueKeyword */: + links.resolvedType = node.type.kind === 149 /* SymbolKeyword */ ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent)) : errorType; break; - case 142 /* ReadonlyKeyword */: + case 143 /* ReadonlyKeyword */: links.resolvedType = getTypeFromTypeNode(node.type); break; default: @@ -56380,7 +58346,6 @@ var ts; var type = templateLiteralTypes.get(id); if (!type) { templateLiteralTypes.set(id, type = createTemplateLiteralType(newTexts, newTypes)); - type.regularType = type; } return type; function addSpans(texts, types) { @@ -56412,10 +58377,8 @@ var ts; 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 */ ? type.intrinsicName : - type.flags & 65536 /* Null */ ? "null" : - type.flags & 32768 /* Undefined */ ? "undefined" : - undefined; + type.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) ? type.intrinsicName : + undefined; } function createTemplateLiteralType(texts, types) { var type = createType(134217728 /* TemplateLiteral */); @@ -56452,13 +58415,13 @@ var ts; result.type = type; return result; } - function createIndexedAccessType(objectType, indexType, aliasSymbol, aliasTypeArguments, shouldIncludeUndefined) { + function createIndexedAccessType(objectType, indexType, accessFlags, aliasSymbol, aliasTypeArguments) { var type = createType(8388608 /* IndexedAccess */); type.objectType = objectType; type.indexType = indexType; + type.accessFlags = accessFlags; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; - type.noUncheckedIndexedAccessCandidate = shouldIncludeUndefined; return type; } /** @@ -56474,7 +58437,7 @@ var ts; if (noImplicitAny) { return false; // Flag is meaningless under `noImplicitAny` mode } - if (ts.getObjectFlags(type) & 16384 /* JSLiteral */) { + if (ts.getObjectFlags(type) & 8192 /* JSLiteral */) { return true; } if (type.flags & 1048576 /* Union */) { @@ -56484,20 +58447,18 @@ var ts; return ts.some(type.types, isJSLiteralType); } if (type.flags & 465829888 /* Instantiable */) { - return isJSLiteralType(getResolvedBaseConstraint(type)); + var constraint = getResolvedBaseConstraint(type); + return constraint !== type && isJSLiteralType(constraint); } return false; } function getPropertyNameFromIndex(indexType, accessNode) { - var accessExpression = accessNode && accessNode.kind === 202 /* ElementAccessExpression */ ? accessNode : undefined; return isTypeUsableAsPropertyName(indexType) ? getPropertyNameFromType(indexType) : - accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? - ts.getPropertyNameForKnownSymbolName(ts.idText(accessExpression.argumentExpression.name)) : - accessNode && ts.isPropertyName(accessNode) ? - // late bound names are handled in the first branch, so here we only need to handle normal names - ts.getPropertyNameForPropertyNameNode(accessNode) : - undefined; + accessNode && ts.isPropertyName(accessNode) ? + // late bound names are handled in the first branch, so here we only need to handle normal names + ts.getPropertyNameForPropertyNameNode(accessNode) : + undefined; } function isUncalledFunctionReference(node, symbol) { if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { @@ -56509,24 +58470,27 @@ var ts; } return true; } - function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, suppressNoImplicitAnyError, accessNode, accessFlags, noUncheckedIndexedAccessCandidate, reportDeprecated) { + function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, accessNode, accessFlags) { var _a; - var accessExpression = accessNode && accessNode.kind === 202 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 204 /* ElementAccessExpression */ ? accessNode : undefined; var propName = accessNode && ts.isPrivateIdentifier(accessNode) ? undefined : getPropertyNameFromIndex(indexType, accessNode); if (propName !== undefined) { + if (accessFlags & 256 /* Contextual */) { + return getTypeOfPropertyOfContextualType(objectType, propName) || anyType; + } var prop = getPropertyOfType(objectType, propName); if (prop) { - if (reportDeprecated && accessNode && getDeclarationNodeFlagsFromSymbol(prop) & 134217728 /* Deprecated */ && isUncalledFunctionReference(accessNode, prop)) { + if (accessFlags & 64 /* ReportDeprecated */ && accessNode && prop.declarations && getDeclarationNodeFlagsFromSymbol(prop) & 134217728 /* Deprecated */ && 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); - errorOrSuggestion(/* isError */ false, deprecatedNode, ts.Diagnostics._0_is_deprecated, propName); + addDeprecatedSuggestion(deprecatedNode, prop.declarations, propName); } if (accessExpression) { - markPropertyAsReferenced(prop, accessExpression, /*isThisAccess*/ accessExpression.expression.kind === 107 /* ThisKeyword */); + markPropertyAsReferenced(prop, accessExpression, isSelfTypeAccess(accessExpression.expression, objectType.symbol)); if (isAssignmentToReadonlyEntity(accessExpression, prop, ts.getAssignmentTargetKind(accessExpression))) { error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(prop)); return undefined; } - if (accessFlags & 4 /* CacheSymbol */) { + if (accessFlags & 8 /* CacheSymbol */) { getNodeLinks(accessNode).resolvedSymbol = prop; } if (isThisPropertyAccessInConstructor(accessExpression, prop)) { @@ -56539,7 +58503,7 @@ var ts; propType; } if (everyType(objectType, isTupleType) && isNumericLiteralName(propName) && +propName >= 0) { - if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 8 /* NoTupleBoundsCheck */)) { + if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 16 /* NoTupleBoundsCheck */)) { var indexNode = getIndexNodeForAccessExpression(accessNode); if (isTupleType(objectType)) { error(indexNode, ts.Diagnostics.Tuple_type_0_of_length_1_has_no_element_at_index_2, typeToString(objectType), getTypeReferenceArity(objectType), ts.unescapeLeadingUnderscores(propName)); @@ -56551,7 +58515,7 @@ var ts; errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, 1 /* Number */)); return mapType(objectType, function (t) { var restType = getRestTypeOfTupleType(t) || undefinedType; - return noUncheckedIndexedAccessCandidate ? getUnionType([restType, undefinedType]) : restType; + return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([restType, undefinedType]) : restType; }); } } @@ -56562,7 +58526,7 @@ var ts; var stringIndexInfo = getIndexInfoOfType(objectType, 0 /* String */); var indexInfo = isTypeAssignableToKind(indexType, 296 /* NumberLike */) && getIndexInfoOfType(objectType, 1 /* Number */) || stringIndexInfo; if (indexInfo) { - if (accessFlags & 1 /* NoIndexSignatures */ && indexInfo === stringIndexInfo) { + if (accessFlags & 2 /* NoIndexSignatures */ && indexInfo === stringIndexInfo) { if (accessExpression) { error(accessExpression, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(originalObjectType)); } @@ -56571,10 +58535,10 @@ var ts; if (accessNode && !isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) { var indexNode = getIndexNodeForAccessExpression(accessNode); error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); - return noUncheckedIndexedAccessCandidate ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; + return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; } errorIfWritingToReadonlyIndex(indexInfo); - return noUncheckedIndexedAccessCandidate ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; + return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; } if (indexType.flags & 131072 /* Never */) { return neverType; @@ -56598,7 +58562,7 @@ var ts; if (objectType.symbol === globalThisSymbol && propName !== undefined && globalThisSymbol.exports.has(propName) && (globalThisSymbol.exports.get(propName).flags & 418 /* BlockScoped */)) { error(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType)); } - else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !suppressNoImplicitAnyError) { + else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !(accessFlags & 128 /* 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) + "]"); @@ -56671,13 +58635,13 @@ var ts; } } function getIndexNodeForAccessExpression(accessNode) { - return accessNode.kind === 202 /* ElementAccessExpression */ ? accessNode.argumentExpression : - accessNode.kind === 189 /* IndexedAccessType */ ? accessNode.indexType : - accessNode.kind === 158 /* ComputedPropertyName */ ? accessNode.expression : + return accessNode.kind === 204 /* ElementAccessExpression */ ? accessNode.argumentExpression : + accessNode.kind === 191 /* IndexedAccessType */ ? accessNode.indexType : + accessNode.kind === 160 /* ComputedPropertyName */ ? accessNode.expression : accessNode; } function isPatternLiteralPlaceholderType(type) { - return templateConstraintType.types.indexOf(type) !== -1 || !!(type.flags & 1 /* Any */); + return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */)); } function isPatternLiteralType(type) { return !!(type.flags & 134217728 /* TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType); @@ -56690,6 +58654,13 @@ var ts; } return !!(type.objectFlags & 8388608 /* IsGenericObjectType */); } + if (type.flags & 33554432 /* Substitution */) { + if (!(type.objectFlags & 4194304 /* IsGenericObjectTypeComputed */)) { + type.objectFlags |= 4194304 /* IsGenericObjectTypeComputed */ | + (isGenericObjectType(type.substitute) || isGenericObjectType(type.baseType) ? 8388608 /* IsGenericObjectType */ : 0); + } + return !!(type.objectFlags & 8388608 /* IsGenericObjectType */); + } return !!(type.flags & 58982400 /* InstantiableNonPrimitive */) || isGenericMappedType(type) || isGenericTupleType(type); } function isGenericIndexType(type) { @@ -56700,6 +58671,13 @@ var ts; } return !!(type.objectFlags & 33554432 /* IsGenericIndexType */); } + if (type.flags & 33554432 /* Substitution */) { + if (!(type.objectFlags & 16777216 /* IsGenericIndexTypeComputed */)) { + type.objectFlags |= 16777216 /* IsGenericIndexTypeComputed */ | + (isGenericIndexType(type.substitute) || isGenericIndexType(type.baseType) ? 33554432 /* IsGenericIndexType */ : 0); + } + return !!(type.objectFlags & 33554432 /* IsGenericIndexType */); + } return !!(type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */)) && !isPatternLiteralType(type); } function isThisTypeParameter(type) { @@ -56775,6 +58753,12 @@ var ts; } return type[cache] = type; } + function isConditionalTypeAlwaysTrueDisregardingInferTypes(type) { + var extendsInferParamMapper = type.root.inferTypeParameters && createTypeMapper(type.root.inferTypeParameters, ts.map(type.root.inferTypeParameters, function () { return wildcardType; })); + var checkType = type.checkType; + var extendsType = type.extendsType; + return isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(instantiateType(extendsType, extendsInferParamMapper))); + } function getSimplifiedConditionalType(type, writing) { var checkType = type.checkType; var extendsType = type.extendsType; @@ -56810,9 +58794,9 @@ var ts; var templateMapper = combineTypeMappers(objectType.mapper, mapper); return instantiateType(getTemplateTypeFromMappedType(objectType), templateMapper); } - function getIndexedAccessType(objectType, indexType, noUncheckedIndexedAccessCandidate, accessNode, aliasSymbol, aliasTypeArguments, accessFlags) { + function getIndexedAccessType(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) { if (accessFlags === void 0) { accessFlags = 0 /* None */; } - return getIndexedAccessTypeOrUndefined(objectType, indexType, noUncheckedIndexedAccessCandidate, accessNode, accessFlags, aliasSymbol, aliasTypeArguments) || (accessNode ? errorType : unknownType); + return getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) || (accessNode ? errorType : unknownType); } function indexTypeLessThan(indexType, limit) { return everyType(indexType, function (t) { @@ -56826,36 +58810,38 @@ var ts; return false; }); } - function getIndexedAccessTypeOrUndefined(objectType, indexType, noUncheckedIndexedAccessCandidate, accessNode, accessFlags, aliasSymbol, aliasTypeArguments) { + function getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) { if (accessFlags === void 0) { accessFlags = 0 /* None */; } if (objectType === wildcardType || indexType === wildcardType) { return wildcardType; } - var shouldIncludeUndefined = noUncheckedIndexedAccessCandidate || - (!!compilerOptions.noUncheckedIndexedAccess && - (accessFlags & (2 /* Writing */ | 16 /* ExpressionPosition */)) === 16 /* ExpressionPosition */); // 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 */)) { 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 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 !== 189 /* IndexedAccessType */ ? + if (isGenericIndexType(indexType) || (accessNode && accessNode.kind !== 191 /* IndexedAccessType */ ? isGenericTupleType(objectType) && !indexTypeLessThan(indexType, objectType.target.fixedLength) : isGenericObjectType(objectType) && !(isTupleType(objectType) && indexTypeLessThan(indexType, objectType.target.fixedLength)))) { if (objectType.flags & 3 /* AnyOrUnknown */) { return objectType; } // Defer the operation by creating an indexed access type. - var id = objectType.id + "," + indexType.id + (shouldIncludeUndefined ? "?" : "") + (aliasSymbol ? "@" + getSymbolId(aliasSymbol) : ""); + var persistentAccessFlags = accessFlags & 1 /* Persistent */; + var id = objectType.id + "," + indexType.id + "," + persistentAccessFlags + getAliasId(aliasSymbol, aliasTypeArguments); var type = indexedAccessTypes.get(id); if (!type) { - indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType, aliasSymbol, aliasTypeArguments, shouldIncludeUndefined)); + indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType, persistentAccessFlags, aliasSymbol, aliasTypeArguments)); } return type; } @@ -56868,7 +58854,7 @@ var ts; 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, wasMissingProp, accessNode, accessFlags, shouldIncludeUndefined); + var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, indexType, accessNode, accessFlags | (wasMissingProp ? 128 /* SuppressNoImplicitAnyError */ : 0)); if (propType) { propTypes.push(propType); } @@ -56884,11 +58870,11 @@ var ts; if (wasMissingProp) { return undefined; } - return accessFlags & 2 /* Writing */ + return accessFlags & 4 /* Writing */ ? getIntersectionType(propTypes, aliasSymbol, aliasTypeArguments) : getUnionType(propTypes, 1 /* Literal */, aliasSymbol, aliasTypeArguments); } - return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, /* supressNoImplicitAnyError */ false, accessNode, accessFlags | 4 /* CacheSymbol */, shouldIncludeUndefined, /* reportDeprecated */ true); + return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, accessNode, accessFlags | 8 /* CacheSymbol */ | 64 /* ReportDeprecated */); } function getTypeFromIndexedAccessTypeNode(node) { var links = getNodeLinks(node); @@ -56896,7 +58882,7 @@ var ts; var objectType = getTypeFromTypeNode(node.objectType); var indexType = getTypeFromTypeNode(node.indexType); var potentialAlias = getAliasSymbolForTypeNode(node); - var resolved = getIndexedAccessType(objectType, indexType, /*noUncheckedIndexedAccessCandidate*/ undefined, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias)); + var resolved = getIndexedAccessType(objectType, indexType, 0 /* None */, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias)); links.resolvedType = resolved.flags & 8388608 /* IndexedAccess */ && resolved.objectType === objectType && resolved.indexType === indexType ? @@ -56928,16 +58914,32 @@ var ts; } return type; } - function getConditionalType(root, mapper) { + function isTypicalNondistributiveConditional(root) { + return !root.isDistributive + && root.node.checkType.kind === 181 /* TupleType */ + && ts.length(root.node.checkType.elements) === 1 + && root.node.extendsType.kind === 181 /* TupleType */ + && ts.length(root.node.extendsType.elements) === 1; + } + /** + * We syntactually check for common nondistributive conditional shapes and unwrap them into + * the intended comparison - we do this so we can check if the unwrapped types are generic or + * not and appropriately defer condition calculation + */ + function unwrapNondistributiveConditionalTuple(root, type) { + return isTypicalNondistributiveConditional(root) && isTupleType(type) ? getTypeArguments(type)[0] : type; + } + function getConditionalType(root, mapper, aliasSymbol, aliasTypeArguments) { var result; var extraTypes; // We loop here for an immediately nested conditional type in the false position, effectively treating // types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for // purposes of resolution. This means such types aren't subject to the instatiation depth limiter. while (true) { - var checkType = instantiateType(root.checkType, mapper); + var isUnwrapped = isTypicalNondistributiveConditional(root); + var checkType = instantiateType(unwrapNondistributiveConditionalTuple(root, getActualTypeVariable(root.checkType)), mapper); var checkTypeInstantiable = isGenericObjectType(checkType) || isGenericIndexType(checkType); - var extendsType = instantiateType(root.extendsType, mapper); + var extendsType = instantiateType(unwrapNondistributiveConditionalTuple(root, root.extendsType), mapper); if (checkType === wildcardType || extendsType === wildcardType) { return wildcardType; } @@ -56948,21 +58950,24 @@ 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, extendsType, 256 /* NoConstraints */ | 512 /* AlwaysStrict */); + inferTypes(context.inferences, checkType, extendsType, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */); } - combinedMapper = mergeTypeMappers(mapper, context.mapper); + // It's possible for 'infer T' type paramteters to be given uninstantiated constraints when the + // those type parameters are used in type references (see getInferredTypeParameterConstraint). For + // that reason we need context.mapper to be first in the combined mapper. See #42636 for examples. + combinedMapper = mapper ? combineTypeMappers(context.mapper, mapper) : context.mapper; } // Instantiate the extends type including inferences for 'infer T' type parameters - var inferredExtendsType = combinedMapper ? instantiateType(root.extendsType, combinedMapper) : extendsType; + var inferredExtendsType = combinedMapper ? instantiateType(unwrapNondistributiveConditionalTuple(root, root.extendsType), combinedMapper) : extendsType; // We attempt to resolve the conditional type only when the check and extends types are non-generic if (!checkTypeInstantiable && !isGenericObjectType(inferredExtendsType) && !isGenericIndexType(inferredExtendsType)) { // Return falseType for a definitely false extends check. We check an instantiations of the two // 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 */ || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) { + if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && ((checkType.flags & 1 /* Any */ && !isUnwrapped) || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) { // Return union of trueType and falseType for 'any' since it matches anything - if (checkType.flags & 1 /* Any */) { + if (checkType.flags & 1 /* 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 @@ -56991,12 +58996,12 @@ var ts; // Return a deferred type for a check that is neither definitely true nor definitely false result = createType(16777216 /* Conditional */); result.root = root; - result.checkType = checkType; - result.extendsType = extendsType; + result.checkType = instantiateType(root.checkType, mapper); + result.extendsType = instantiateType(root.extendsType, mapper); result.mapper = mapper; result.combinedMapper = combinedMapper; - result.aliasSymbol = root.aliasSymbol; - result.aliasTypeArguments = instantiateTypes(root.aliasTypeArguments, mapper); // TODO: GH#18217 + result.aliasSymbol = aliasSymbol || root.aliasSymbol; + result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(root.aliasTypeArguments, mapper); // TODO: GH#18217 break; } return extraTypes ? getUnionType(ts.append(extraTypes, result)) : result; @@ -57155,7 +59160,7 @@ var ts; } function getAliasSymbolForTypeNode(node) { var host = node.parent; - while (ts.isParenthesizedTypeNode(host) || ts.isJSDocTypeExpression(host) || ts.isTypeOperatorNode(host) && host.operator === 142 /* ReadonlyKeyword */) { + while (ts.isParenthesizedTypeNode(host) || ts.isJSDocTypeExpression(host) || ts.isTypeOperatorNode(host) && host.operator === 143 /* ReadonlyKeyword */) { host = host.parent; } return ts.isTypeAlias(host) ? getSymbolOfNode(host) : undefined; @@ -57194,7 +59199,7 @@ var ts; 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)); - result.type = isSetonlyAccessor ? undefinedType : getUnionType([getTypeOfSymbol(prop), undefinedType]); + result.type = isSetonlyAccessor ? undefinedType : addOptionality(getTypeOfSymbol(prop), /*isProperty*/ true); result.declarations = prop.declarations; result.nameType = getSymbolLinks(prop).nameType; result.syntheticOrigin = prop; @@ -57202,7 +59207,7 @@ var ts; } } var spread = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfoOfType(type, 0 /* String */), getIndexInfoOfType(type, 1 /* Number */)); - spread.objectFlags |= 128 /* ObjectLiteral */ | 1048576 /* ContainsObjectOrArrayLiteral */; + spread.objectFlags |= 128 /* ObjectLiteral */ | 262144 /* ContainsObjectOrArrayLiteral */; return spread; } } @@ -57308,14 +59313,15 @@ var ts; } } var spread = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfoWithReadonly(stringIndexInfo, readonly), getIndexInfoWithReadonly(numberIndexInfo, readonly)); - spread.objectFlags |= 128 /* ObjectLiteral */ | 1048576 /* ContainsObjectOrArrayLiteral */ | 1024 /* ContainsSpread */ | objectFlags; + spread.objectFlags |= 128 /* ObjectLiteral */ | 262144 /* ContainsObjectOrArrayLiteral */ | 4194304 /* ContainsSpread */ | objectFlags; return spread; } /** We approximate own properties as non-methods plus methods that are inside the object literal */ function isSpreadableProperty(prop) { - return !ts.some(prop.declarations, ts.isPrivateIdentifierPropertyDeclaration) && + var _a; + return !ts.some(prop.declarations, ts.isPrivateIdentifierClassElementDeclaration) && (!(prop.flags & (8192 /* Method */ | 32768 /* GetAccessor */ | 65536 /* SetAccessor */)) || - !prop.declarations.some(function (decl) { return ts.isClassLike(decl.parent); })); + !((_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 */); @@ -57340,11 +59346,9 @@ var ts; return type; } function getFreshTypeOfLiteralType(type) { - if (type.flags & 134220672 /* FreshableLiteral */) { + if (type.flags & 2944 /* Literal */) { if (!type.freshType) { - var freshType = type.flags & 134217728 /* TemplateLiteral */ ? - createTemplateLiteralType(type.texts, type.types) : - createLiteralType(type.flags, type.value, type.symbol); + var freshType = createLiteralType(type.flags, type.value, type.symbol); freshType.regularType = type; freshType.freshType = freshType; type.freshType = freshType; @@ -57354,12 +59358,12 @@ var ts; return type; } function getRegularTypeOfLiteralType(type) { - return type.flags & 134220672 /* FreshableLiteral */ ? type.regularType : + return type.flags & 2944 /* Literal */ ? type.regularType : type.flags & 1048576 /* Union */ ? (type.regularType || (type.regularType = mapType(type, getRegularTypeOfLiteralType))) : type; } function isFreshLiteralType(type) { - return !!(type.flags & 134220672 /* FreshableLiteral */) && type.freshType === type; + return !!(type.flags & 2944 /* Literal */) && type.freshType === type; } function getLiteralType(value, enumId, symbol) { // We store all literal types in a single map with keys of the form '#NNN' and '@SSS', @@ -57379,7 +59383,7 @@ var ts; return type; } function getTypeFromLiteralTypeNode(node) { - if (node.literal.kind === 103 /* NullKeyword */) { + if (node.literal.kind === 104 /* NullKeyword */) { return nullType; } var links = getNodeLinks(node); @@ -57405,7 +59409,7 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 253 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 255 /* InterfaceDeclaration */)) { if (!ts.hasSyntacticModifier(container, 32 /* Static */) && (!ts.isConstructorDeclaration(container) || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; @@ -57440,17 +59444,17 @@ var ts; } function getArrayElementTypeNode(node) { switch (node.kind) { - case 186 /* ParenthesizedType */: + case 188 /* ParenthesizedType */: return getArrayElementTypeNode(node.type); - case 179 /* TupleType */: + case 181 /* TupleType */: if (node.elements.length === 1) { node = node.elements[0]; - if (node.kind === 181 /* RestType */ || node.kind === 192 /* NamedTupleMember */ && node.dotDotDotToken) { + if (node.kind === 183 /* RestType */ || node.kind === 194 /* NamedTupleMember */ && node.dotDotDotToken) { return getArrayElementTypeNode(node.type); } } break; - case 178 /* ArrayType */: + case 180 /* ArrayType */: return node.elementType; } return undefined; @@ -57459,107 +59463,106 @@ var ts; var links = getNodeLinks(node); return links.resolvedType || (links.resolvedType = node.dotDotDotToken ? getTypeFromRestTypeNode(node) : - node.questionToken && strictNullChecks ? getOptionalType(getTypeFromTypeNode(node.type)) : - getTypeFromTypeNode(node.type)); + addOptionality(getTypeFromTypeNode(node.type), /*isProperty*/ true, !!node.questionToken)); } function getTypeFromTypeNode(node) { return getConditionalFlowTypeOfType(getTypeFromTypeNodeWorker(node), node); } function getTypeFromTypeNodeWorker(node) { switch (node.kind) { - case 128 /* AnyKeyword */: - case 303 /* JSDocAllType */: - case 304 /* JSDocUnknownType */: + case 129 /* AnyKeyword */: + case 306 /* JSDocAllType */: + case 307 /* JSDocUnknownType */: return anyType; - case 152 /* UnknownKeyword */: + case 153 /* UnknownKeyword */: return unknownType; - case 147 /* StringKeyword */: + case 148 /* StringKeyword */: return stringType; - case 144 /* NumberKeyword */: + case 145 /* NumberKeyword */: return numberType; - case 155 /* BigIntKeyword */: + case 156 /* BigIntKeyword */: return bigintType; - case 131 /* BooleanKeyword */: + case 132 /* BooleanKeyword */: return booleanType; - case 148 /* SymbolKeyword */: + case 149 /* SymbolKeyword */: return esSymbolType; - case 113 /* VoidKeyword */: + case 114 /* VoidKeyword */: return voidType; - case 150 /* UndefinedKeyword */: + case 151 /* UndefinedKeyword */: return undefinedType; - case 103 /* NullKeyword */: + case 104 /* 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 141 /* NeverKeyword */: + case 142 /* NeverKeyword */: return neverType; - case 145 /* ObjectKeyword */: + case 146 /* ObjectKeyword */: return node.flags & 131072 /* JavaScriptFile */ && !noImplicitAny ? anyType : nonPrimitiveType; - case 136 /* IntrinsicKeyword */: + case 137 /* IntrinsicKeyword */: return intrinsicMarkerType; - case 187 /* ThisType */: - case 107 /* ThisKeyword */: + case 189 /* ThisType */: + case 108 /* 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 191 /* LiteralType */: + case 193 /* LiteralType */: return getTypeFromLiteralTypeNode(node); - case 173 /* TypeReference */: + case 175 /* TypeReference */: return getTypeFromTypeReference(node); - case 172 /* TypePredicate */: + case 174 /* TypePredicate */: return node.assertsModifier ? voidType : booleanType; - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 176 /* TypeQuery */: + case 178 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 178 /* ArrayType */: - case 179 /* TupleType */: + case 180 /* ArrayType */: + case 181 /* TupleType */: return getTypeFromArrayOrTupleTypeNode(node); - case 180 /* OptionalType */: + case 182 /* OptionalType */: return getTypeFromOptionalTypeNode(node); - case 182 /* UnionType */: + case 184 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 183 /* IntersectionType */: + case 185 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 305 /* JSDocNullableType */: + case 308 /* JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 307 /* JSDocOptionalType */: + case 310 /* JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 192 /* NamedTupleMember */: + case 194 /* NamedTupleMember */: return getTypeFromNamedTupleTypeNode(node); - case 186 /* ParenthesizedType */: - case 306 /* JSDocNonNullableType */: - case 301 /* JSDocTypeExpression */: + case 188 /* ParenthesizedType */: + case 309 /* JSDocNonNullableType */: + case 303 /* JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 181 /* RestType */: + case 183 /* RestType */: return getTypeFromRestTypeNode(node); - case 309 /* JSDocVariadicType */: + case 312 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); - case 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 177 /* TypeLiteral */: - case 312 /* JSDocTypeLiteral */: - case 308 /* JSDocFunctionType */: - case 313 /* JSDocSignature */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: + case 179 /* TypeLiteral */: + case 316 /* JSDocTypeLiteral */: + case 311 /* JSDocFunctionType */: + case 317 /* JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 188 /* TypeOperator */: + case 190 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 189 /* IndexedAccessType */: + case 191 /* IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 190 /* MappedType */: + case 192 /* MappedType */: return getTypeFromMappedTypeNode(node); - case 184 /* ConditionalType */: + case 186 /* ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 185 /* InferType */: + case 187 /* InferType */: return getTypeFromInferTypeNode(node); - case 193 /* TemplateLiteralType */: + case 195 /* TemplateLiteralType */: return getTypeFromTemplateTypeNode(node); - case 195 /* ImportType */: + case 197 /* 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 78 /* Identifier */: - case 157 /* QualifiedName */: - case 201 /* PropertyAccessExpression */: + case 79 /* Identifier */: + case 159 /* QualifiedName */: + case 203 /* PropertyAccessExpression */: var symbol = getSymbolAtLocation(node); return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType; default: @@ -57712,7 +59715,7 @@ var ts; } return result; } - function getObjectTypeInstantiation(type, mapper) { + function getObjectTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) { var declaration = type.objectFlags & 4 /* Reference */ ? type.node : type.symbol.declarations[0]; var links = getNodeLinks(declaration); var target = type.objectFlags & 4 /* Reference */ ? links.resolvedType : @@ -57729,8 +59732,9 @@ var ts; outerTypeParameters = ts.addRange(outerTypeParameters, templateTagParameters); } typeParameters = outerTypeParameters || ts.emptyArray; - typeParameters = (target.objectFlags & 4 /* Reference */ || target.symbol.flags & 2048 /* TypeLiteral */) && !target.aliasTypeArguments ? - ts.filter(typeParameters, function (tp) { return isTypeParameterPossiblyReferenced(tp, declaration); }) : + var allDeclarations_1 = type.objectFlags & 4 /* Reference */ ? [declaration] : type.symbol.declarations; + typeParameters = (target.objectFlags & 4 /* Reference */ || target.symbol.flags & 8192 /* Method */ || target.symbol.flags & 2048 /* TypeLiteral */) && !target.aliasTypeArguments ? + ts.filter(typeParameters, function (tp) { return ts.some(allDeclarations_1, function (d) { return isTypeParameterPossiblyReferenced(tp, d); }); }) : typeParameters; links.outerTypeParameters = typeParameters; } @@ -57740,17 +59744,19 @@ var ts; // instantiation cache key from the type IDs of the type arguments. var combinedMapper_1 = combineTypeMappers(type.mapper, mapper); var typeArguments = ts.map(typeParameters, function (t) { return getMappedType(t, combinedMapper_1); }); - var id = getTypeListId(typeArguments); + var newAliasSymbol = aliasSymbol || type.aliasSymbol; + var newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper); + var id = getTypeListId(typeArguments) + getAliasId(newAliasSymbol, newAliasTypeArguments); if (!target.instantiations) { target.instantiations = new ts.Map(); - target.instantiations.set(getTypeListId(typeParameters), target); + target.instantiations.set(getTypeListId(typeParameters) + getAliasId(target.aliasSymbol, target.aliasTypeArguments), target); } var result = target.instantiations.get(id); if (!result) { var newMapper = createTypeMapper(typeParameters, typeArguments); - result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper) : - target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper) : - instantiateAnonymousType(target, newMapper); + result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : + target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : + instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments); target.instantiations.set(id, result); } return result; @@ -57758,9 +59764,8 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 157 /* QualifiedName */ || - node.parent.kind === 173 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || - node.parent.kind === 195 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); + return !(node.parent.kind === 175 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || + node.parent.kind === 197 /* 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 @@ -57769,22 +59774,28 @@ 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 === 230 /* Block */ || n.kind === 184 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { + if (!n || n.kind === 232 /* Block */ || n.kind === 186 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { return true; } } - return !!ts.forEachChild(node, containsReference); + return containsReference(node); } return true; function containsReference(node) { switch (node.kind) { - case 187 /* ThisType */: + case 189 /* ThisType */: return !!tp.isThisType; - case 78 /* Identifier */: + case 79 /* Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNodeWorker(node) === tp; // use worker because we're looking for === equality - case 176 /* TypeQuery */: + case 178 /* TypeQuery */: return true; + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + return !node.type && !!node.body || + ts.some(node.typeParameters, containsReference) || + ts.some(node.parameters, containsReference) || + !!node.type && containsReference(node.type); } return !!ts.forEachChild(node, containsReference); } @@ -57799,7 +59810,7 @@ var ts; } return undefined; } - function instantiateMappedType(type, mapper) { + function instantiateMappedType(type, mapper, aliasSymbol, aliasTypeArguments) { // For a homomorphic mapped type { [P in keyof T]: X }, where T is some type variable, the mapping // operation depends on T as follows: // * If T is a primitive type no mapping is performed and the result is simply T. @@ -57814,7 +59825,7 @@ var ts; if (typeVariable) { var mappedTypeVariable = instantiateType(typeVariable, mapper); if (typeVariable !== mappedTypeVariable) { - return mapType(getReducedType(mappedTypeVariable), function (t) { + return mapTypeWithAlias(getReducedType(mappedTypeVariable), function (t) { if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && t !== errorType) { if (!type.declaration.nameType) { if (isArrayType(t)) { @@ -57830,11 +59841,11 @@ var ts; return instantiateAnonymousType(type, prependTypeMapping(typeVariable, t, mapper)); } return t; - }); + }, aliasSymbol, aliasTypeArguments); } } // If the constraint type of the instantiation is the wildcard type, return the wildcard type. - return instantiateType(getConstraintTypeFromMappedType(type), mapper) === wildcardType ? wildcardType : instantiateAnonymousType(type, mapper); + 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; @@ -57877,11 +59888,11 @@ 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) : + return strictNullChecks && modifiers & 4 /* IncludeOptional */ && !maybeTypeOfKind(propType, 32768 /* Undefined */ | 16384 /* Void */) ? getOptionalType(propType, /*isProperty*/ true) : strictNullChecks && modifiers & 8 /* ExcludeOptional */ && isOptional ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : propType; } - function instantiateAnonymousType(type, mapper) { + function instantiateAnonymousType(type, mapper, aliasSymbol, aliasTypeArguments) { var result = createObjectType(type.objectFlags | 64 /* Instantiated */, type.symbol); if (type.objectFlags & 32 /* Mapped */) { result.declaration = type.declaration; @@ -57894,29 +59905,29 @@ var ts; } result.target = type; result.mapper = mapper; - result.aliasSymbol = type.aliasSymbol; - result.aliasTypeArguments = instantiateTypes(type.aliasTypeArguments, mapper); + result.aliasSymbol = aliasSymbol || type.aliasSymbol; + result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper); return result; } - function getConditionalTypeInstantiation(type, mapper) { + function getConditionalTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) { var root = type.root; if (root.outerTypeParameters) { // We are instantiating a conditional type that has one or more type parameters in scope. Apply the // mapper to the type parameters to produce the effective list of type arguments, and compute the // instantiation cache key from the type IDs of the type arguments. var typeArguments = ts.map(root.outerTypeParameters, function (t) { return getMappedType(t, mapper); }); - var id = getTypeListId(typeArguments); + var id = getTypeListId(typeArguments) + getAliasId(aliasSymbol, aliasTypeArguments); var result = root.instantiations.get(id); if (!result) { var newMapper = createTypeMapper(root.outerTypeParameters, typeArguments); - result = instantiateConditionalType(root, newMapper); + result = instantiateConditionalType(root, newMapper, aliasSymbol, aliasTypeArguments); root.instantiations.set(id, result); } return result; } return type; } - function instantiateConditionalType(root, mapper) { + function instantiateConditionalType(root, mapper, aliasSymbol, aliasTypeArguments) { // Check if we have a conditional type where the check type is a naked type parameter. If so, // the conditional type is distributive over union types and when T is instantiated to a union // type A | B, we produce (A extends U ? X : Y) | (B extends U ? X : Y). @@ -57924,31 +59935,34 @@ var ts; var checkType_1 = root.checkType; var instantiatedType = getMappedType(checkType_1, mapper); if (checkType_1 !== instantiatedType && instantiatedType.flags & (1048576 /* Union */ | 131072 /* Never */)) { - return mapType(instantiatedType, function (t) { return getConditionalType(root, prependTypeMapping(checkType_1, t, mapper)); }); + return mapTypeWithAlias(instantiatedType, function (t) { return getConditionalType(root, prependTypeMapping(checkType_1, t, mapper)); }, aliasSymbol, aliasTypeArguments); } } - return getConditionalType(root, mapper); + return getConditionalType(root, mapper, aliasSymbol, aliasTypeArguments); } function instantiateType(type, mapper) { - if (!(type && mapper && couldContainTypeVariables(type))) { + return type && mapper ? instantiateTypeWithAlias(type, mapper, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined) : type; + } + function instantiateTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments) { + if (!couldContainTypeVariables(type)) { return type; } if (instantiationDepth === 50 || instantiationCount >= 5000000) { // We have reached 50 recursive type instantiations and there is a very high likelyhood we're dealing // with a combination of infinite generic types that perpetually generate new type identities. We stop // the recursion here by yielding the error type. - 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" /* CheckTypes */, "instantiateType_DepthLimit", { typeId: type.id, instantiationDepth: instantiationDepth, instantiationCount: instantiationCount }); error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite); return errorType; } totalInstantiationCount++; instantiationCount++; instantiationDepth++; - var result = instantiateTypeWorker(type, mapper); + var result = instantiateTypeWorker(type, mapper, aliasSymbol, aliasTypeArguments); instantiationDepth--; return result; } - function instantiateTypeWorker(type, mapper) { + function instantiateTypeWorker(type, mapper, aliasSymbol, aliasTypeArguments) { var flags = type.flags; if (flags & 262144 /* TypeParameter */) { return getMappedType(type, mapper); @@ -57956,12 +59970,15 @@ var ts; if (flags & 524288 /* Object */) { var objectFlags = type.objectFlags; if (objectFlags & (4 /* Reference */ | 16 /* Anonymous */ | 32 /* Mapped */)) { - if (objectFlags & 4 /* Reference */ && !(type.node)) { + if (objectFlags & 4 /* Reference */ && !type.node) { var resolvedTypeArguments = type.resolvedTypeArguments; var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper); return newTypeArguments !== resolvedTypeArguments ? createNormalizedTypeReference(type.target, newTypeArguments) : type; } - return getObjectTypeInstantiation(type, mapper); + if (objectFlags & 1024 /* ReverseMapped */) { + return instantiateReverseMappedType(type, mapper); + } + return getObjectTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments); } return type; } @@ -57969,10 +59986,14 @@ var ts; var origin = type.flags & 1048576 /* Union */ ? type.origin : undefined; var types = origin && origin.flags & 3145728 /* UnionOrIntersection */ ? origin.types : type.types; var newTypes = instantiateTypes(types, mapper); - return newTypes === types ? type : - flags & 2097152 /* Intersection */ || origin && origin.flags & 2097152 /* Intersection */ ? - getIntersectionType(newTypes, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) : - getUnionType(newTypes, 1 /* Literal */, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, 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 */ ? + getIntersectionType(newTypes, newAliasSymbol, newAliasTypeArguments) : + getUnionType(newTypes, 1 /* Literal */, newAliasSymbol, newAliasTypeArguments); } if (flags & 4194304 /* Index */) { return getIndexType(instantiateType(type.type, mapper)); @@ -57984,10 +60005,12 @@ var ts; return getStringMappingType(type.symbol, instantiateType(type.type, mapper)); } if (flags & 8388608 /* IndexedAccess */) { - return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper), type.noUncheckedIndexedAccessCandidate, /*accessNode*/ undefined, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); + 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 */) { - return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper)); + return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper), aliasSymbol, aliasTypeArguments); } if (flags & 33554432 /* Substitution */) { var maybeVariable = instantiateType(type.baseType, mapper); @@ -58004,6 +60027,21 @@ var ts; } return type; } + function instantiateReverseMappedType(type, mapper) { + var innerMappedType = instantiateType(type.mappedType, mapper); + if (!(ts.getObjectFlags(innerMappedType) & 32 /* Mapped */)) { + return type; + } + var innerIndexType = instantiateType(type.constraintType, mapper); + if (!(innerIndexType.flags & 4194304 /* Index */)) { + return type; + } + var instantiated = inferTypeForHomomorphicMappedType(instantiateType(type.source, mapper), innerMappedType, innerIndexType); + if (instantiated) { + return instantiated; + } + return type; // Nested invocation of `inferTypeForHomomorphicMappedType` or the `source` instantiated into something unmappable + } function getPermissiveInstantiation(type) { return type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */) ? type : type.permissiveInstantiation || (type.permissiveInstantiation = instantiateType(type, permissiveMapper)); @@ -58030,35 +60068,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 !== 165 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 167 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: - case 251 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 253 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type return isContextSensitiveFunctionLikeDeclaration(node); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return (node.operatorToken.kind === 56 /* BarBarToken */ || node.operatorToken.kind === 60 /* QuestionQuestionToken */) && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return isContextSensitive(node.expression); - case 281 /* JsxAttributes */: + case 283 /* JsxAttributes */: return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive); - case 280 /* JsxAttribute */: { + case 282 /* 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 283 /* JsxExpression */: { + case 285 /* JsxExpression */: { // It is possible to that node.expression is undefined (e.g

) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -58077,7 +60115,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 209 /* ArrowFunction */) { + if (node.kind !== 211 /* 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); @@ -58090,7 +60128,7 @@ 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 !== 230 /* Block */ && isContextSensitive(node.body); + return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 232 /* Block */ && isContextSensitive(node.body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && @@ -58193,23 +60231,23 @@ var ts; return true; } switch (node.kind) { - case 283 /* JsxExpression */: - case 207 /* ParenthesizedExpression */: + case 285 /* JsxExpression */: + case 209 /* ParenthesizedExpression */: return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 62 /* EqualsToken */: + case 63 /* EqualsToken */: case 27 /* CommaToken */: return elaborateError(node.right, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); } break; - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 281 /* JsxAttributes */: + case 283 /* JsxAttributes */: return elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer); } return false; @@ -58310,7 +60348,14 @@ var ts; if (!targetPropType || targetPropType.flags & 8388608 /* IndexedAccess */) continue; // Don't elaborate on indexes on generic variables var sourcePropType = getIndexedAccessTypeOrUndefined(source, nameType); - if (sourcePropType && !checkTypeRelatedTo(sourcePropType, targetPropType, relation, /*errorNode*/ undefined)) { + if (!sourcePropType) + continue; + var propName = getPropertyNameFromIndex(nameType, /*accessNode*/ undefined); + var targetIsOptional = !!(propName && (getPropertyOfType(target, propName) || unknownSymbol).flags & 16777216 /* Optional */); + var sourceIsOptional = !!(propName && (getPropertyOfType(source, propName) || unknownSymbol).flags & 16777216 /* Optional */); + targetPropType = removeMissingType(targetPropType, targetIsOptional); + sourcePropType = removeMissingType(sourcePropType, targetIsOptional && sourceIsOptional); + if (!checkTypeRelatedTo(sourcePropType, targetPropType, relation, /*errorNode*/ undefined)) { var elaborated = next && elaborateError(next, sourcePropType, targetPropType, relation, /*headMessage*/ undefined, containingMessageChain, errorOutputContainer); if (elaborated) { reportedError = true; @@ -58409,7 +60454,7 @@ var ts; } function getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic) { switch (child.kind) { - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: // child is of the type of the expression return { errorNode: child, innerExpression: child.expression, nameType: nameType }; case 11 /* JsxText */: @@ -58418,9 +60463,9 @@ var ts; } // child is a string return { errorNode: child, innerExpression: undefined, nameType: nameType, errorMessage: getInvalidTextDiagnostic() }; - case 273 /* JsxElement */: - case 274 /* JsxSelfClosingElement */: - case 277 /* JsxFragment */: + case 275 /* JsxElement */: + case 276 /* JsxSelfClosingElement */: + case 279 /* JsxFragment */: // child is of type JSX.Element return { errorNode: child, innerExpression: child, nameType: nameType }; default: @@ -58568,11 +60613,11 @@ var ts; } _b = prop.kind; switch (_b) { - case 168 /* SetAccessor */: return [3 /*break*/, 2]; - case 167 /* GetAccessor */: return [3 /*break*/, 2]; - case 165 /* MethodDeclaration */: return [3 /*break*/, 2]; - case 289 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; - case 288 /* PropertyAssignment */: return [3 /*break*/, 4]; + case 170 /* SetAccessor */: return [3 /*break*/, 2]; + case 169 /* GetAccessor */: return [3 /*break*/, 2]; + case 167 /* MethodDeclaration */: return [3 /*break*/, 2]; + case 291 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 290 /* PropertyAssignment */: return [3 /*break*/, 4]; } return [3 /*break*/, 6]; case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; @@ -58649,8 +60694,8 @@ var ts; return 0 /* False */; } var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - var strictVariance = !(checkMode & 3 /* Callback */) && strictFunctionTypes && kind !== 165 /* MethodDeclaration */ && - kind !== 164 /* MethodSignature */ && kind !== 166 /* Constructor */; + var strictVariance = !(checkMode & 3 /* Callback */) && strictFunctionTypes && kind !== 167 /* MethodDeclaration */ && + kind !== 166 /* MethodSignature */ && kind !== 168 /* Constructor */; var result = -1 /* True */; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { @@ -58883,7 +60928,7 @@ var ts; // 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 */ || t & 256 /* NumberLiteral */ && t & 1024 /* EnumLiteral */)) + if (s & (8 /* Number */ | 256 /* NumberLiteral */) && !(s & 1024 /* EnumLiteral */) && (t & 32 /* Enum */ || relation === assignableRelation && t & 256 /* NumberLiteral */ && t & 1024 /* EnumLiteral */)) return true; } return false; @@ -58920,7 +60965,7 @@ var ts; return false; } function isIgnoredJsxProperty(source, sourceProp) { - return ts.getObjectFlags(source) & 4096 /* JsxAttributes */ && !isUnhyphenatedJsxName(sourceProp.escapedName); + return ts.getObjectFlags(source) & 2048 /* JsxAttributes */ && !isUnhyphenatedJsxName(sourceProp.escapedName); } function getNormalizedType(type, writing) { while (true) { @@ -58930,6 +60975,7 @@ var ts; type.flags & 33554432 /* Substitution */ ? writing ? type.baseType : type.substitute : type.flags & 25165824 /* Simplifiable */ ? getSimplifiedType(type, writing) : type; + t = getSingleBaseForNonAugmentingSubtype(t) || t; if (t === type) break; type = t; @@ -58967,7 +61013,7 @@ var ts; reportIncompatibleStack(); } if (overflow) { - ts.tracing.instant("checkTypes" /* CheckTypes */, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: depth }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: depth }); 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); @@ -59103,6 +61149,14 @@ var ts; } break; } + case ts.Diagnostics.Type_at_position_0_in_source_is_not_compatible_with_type_at_position_1_in_target.code: { + secondaryRootErrors.unshift([ts.Diagnostics.Type_at_position_0_in_source_is_not_compatible_with_type_at_position_1_in_target, args[0], args[1]]); + break; + } + case ts.Diagnostics.Type_at_positions_0_through_1_in_source_is_not_compatible_with_type_at_position_2_in_target.code: { + secondaryRootErrors.unshift([ts.Diagnostics.Type_at_positions_0_through_1_in_source_is_not_compatible_with_type_at_position_2_in_target, args[0], args[1], args[2]]); + break; + } default: return ts.Debug.fail("Unhandled Diagnostic: " + msg.code); } @@ -59163,6 +61217,7 @@ var ts; reportError(ts.Diagnostics._0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2, needsOriginalSource ? sourceType : generalizedSourceType, targetType, typeToString(constraint)); } else { + errorInfo = undefined; reportError(ts.Diagnostics._0_could_be_instantiated_with_an_arbitrary_type_which_could_be_unrelated_to_1, targetType, generalizedSourceType); } } @@ -59238,7 +61293,7 @@ var ts; if (isSimpleTypeRelatedTo(originalSource, originalTarget, relation, reportErrors ? reportError : undefined)) { return -1 /* True */; } - reportErrorResults(originalSource, originalTarget, 0 /* False */, !!(ts.getObjectFlags(originalSource) & 4096 /* JsxAttributes */)); + reportErrorResults(originalSource, originalTarget, 0 /* False */, !!(ts.getObjectFlags(originalSource) & 2048 /* JsxAttributes */)); return 0 /* False */; } // Normalize the source and target types: Turn fresh literal types into regular literal types, @@ -59273,16 +61328,16 @@ var ts; target.types.length <= 3 && maybeTypeOfKind(target, 98304 /* Nullable */)) { var nullStrippedTarget = extractTypesOfKind(target, ~98304 /* Nullable */); if (!(nullStrippedTarget.flags & (1048576 /* Union */ | 131072 /* Never */))) { - if (source === nullStrippedTarget) - return -1 /* True */; - target = nullStrippedTarget; + target = getNormalizedType(nullStrippedTarget, /*writing*/ true); } + if (source === nullStrippedTarget) + return -1 /* True */; } if (relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return -1 /* True */; - var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096 /* JsxAttributes */); - var isPerformingExcessPropertyChecks = !(intersectionState & 2 /* Target */) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 32768 /* FreshLiteral */); + var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* JsxAttributes */); + var isPerformingExcessPropertyChecks = !(intersectionState & 2 /* Target */) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 16384 /* FreshLiteral */); if (isPerformingExcessPropertyChecks) { if (hasExcessProperties(source, target, reportErrors)) { if (reportErrors) { @@ -59367,7 +61422,7 @@ var ts; // We suppress recursive intersection property checks because they can generate lots of work when relating // recursive intersections that are structurally similar but not exactly identical. See #37854. if (result && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) || - isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 2097152 /* NonInferrableType */); }))) { + isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 524288 /* NonInferrableType */); }))) { inPropertyCheck = true; result &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */); inPropertyCheck = false; @@ -59376,8 +61431,10 @@ var ts; return result; function reportErrorResults(source, target, result, isComparingJsxAttributes) { if (!result && reportErrors) { - source = originalSource.aliasSymbol ? originalSource : source; - target = originalTarget.aliasSymbol ? originalTarget : target; + var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource); + var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget); + source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source; + target = (originalTarget.aliasSymbol || targetHasBase) ? originalTarget : target; var maybeSuppress = overrideNextErrorInfo > 0; if (maybeSuppress) { overrideNextErrorInfo--; @@ -59418,13 +61475,13 @@ var ts; } } function traceUnionsOrIntersectionsTooLarge(source, target) { - if (!ts.tracing.isTracing()) { + if (!ts.tracing) { return; } if ((source.flags & 3145728 /* UnionOrIntersection */) && (target.flags & 3145728 /* UnionOrIntersection */)) { var sourceUnionOrIntersection = source; var targetUnionOrIntersection = target; - if (sourceUnionOrIntersection.objectFlags & targetUnionOrIntersection.objectFlags & 262144 /* PrimitiveUnion */) { + if (sourceUnionOrIntersection.objectFlags & targetUnionOrIntersection.objectFlags & 65536 /* PrimitiveUnion */) { // There's a fast path for comparing primitive unions return; } @@ -59449,11 +61506,11 @@ var ts; } traceUnionsOrIntersectionsTooLarge(source, target); if (flags & 3145728 /* UnionOrIntersection */) { - var result_6 = eachTypeRelatedToSomeType(source, target); - if (result_6) { - result_6 &= eachTypeRelatedToSomeType(target, source); + var result_7 = eachTypeRelatedToSomeType(source, target); + if (result_7) { + result_7 &= eachTypeRelatedToSomeType(target, source); } - return result_6; + return result_7; } return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None */); } @@ -59467,10 +61524,11 @@ var ts; return getUnionType(ts.reduceLeft(types, appendPropType, /*initial*/ undefined) || ts.emptyArray); } function hasExcessProperties(source, target, reportErrors) { - if (!isExcessPropertyCheckTarget(target) || !noImplicitAny && ts.getObjectFlags(target) & 16384 /* JSLiteral */) { + var _a; + if (!isExcessPropertyCheckTarget(target) || !noImplicitAny && ts.getObjectFlags(target) & 8192 /* 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) & 4096 /* JsxAttributes */); + var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* JsxAttributes */); if ((relation === assignableRelation || relation === comparableRelation) && (isTypeSubsetOf(globalObjectType, target) || (!isComparingJsxAttributes && isEmptyObjectType(target)))) { return false; @@ -59513,7 +61571,7 @@ var ts; } else { // use the property's value declaration if the property is assigned inside the literal itself - var objectLiteralDeclaration_1 = source.symbol && ts.firstOrUndefined(source.symbol.declarations); + var objectLiteralDeclaration_1 = ((_a = source.symbol) === null || _a === void 0 ? void 0 : _a.declarations) && ts.firstOrUndefined(source.symbol.declarations); var suggestion = void 0; if (prop.valueDeclaration && ts.findAncestor(prop.valueDeclaration, function (d) { return d === objectLiteralDeclaration_1; }) && ts.getSourceFileOfNode(objectLiteralDeclaration_1) === ts.getSourceFileOfNode(errorNode)) { var propDeclaration = prop.valueDeclaration; @@ -59542,11 +61600,11 @@ var ts; } } }; - for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) { - var prop = _a[_i]; - var state_4 = _loop_16(prop); - if (typeof state_4 === "object") - return state_4.value; + for (var _i = 0, _b = getPropertiesOfType(source); _i < _b.length; _i++) { + var prop = _b[_i]; + var state_5 = _loop_16(prop); + if (typeof state_5 === "object") + return state_5.value; } return false; } @@ -59568,8 +61626,17 @@ var ts; } function typeRelatedToSomeType(source, target, reportErrors) { var targetTypes = target.types; - if (target.flags & 1048576 /* Union */ && containsType(targetTypes, source)) { - return -1 /* True */; + if (target.flags & 1048576 /* Union */) { + if (containsType(targetTypes, source)) { + return -1 /* True */; + } + var match = getMatchingUnionConstituentForType(target, source); + if (match) { + var related = isRelatedTo(source, match, /*reportErrors*/ false); + if (related) { + return related; + } + } } for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { var type = targetTypes_1[_i]; @@ -59743,9 +61810,16 @@ var ts; targetStack = []; } else { + // generate a key where all type parameter id positions are replaced with unconstrained type parameter ids + // this isn't perfect - nested type references passed as type arguments will muck up the indexes and thus + // prevent finding matches- but it should hit up the common cases + var broadestEquivalentId = id.split(",").map(function (i) { return i.replace(/-\d+/g, function (_match, offset) { + var index = ts.length(id.slice(0, offset).match(/[-=]/g) || undefined); + return "=" + index; + }); }).join(","); for (var i = 0; i < maybeCount; i++) { // If source and target are already being compared, consider them related with assumptions - if (id === maybeKeys[i]) { + if (id === maybeKeys[i] || broadestEquivalentId === maybeKeys[i]) { return 3 /* Maybe */; } } @@ -59775,7 +61849,7 @@ var ts; }; } if (expandingFlags === 3 /* Both */) { - ts.tracing.instant("checkTypes" /* CheckTypes */, "recursiveTypeRelatedTo_DepthLimit", { + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "recursiveTypeRelatedTo_DepthLimit", { sourceId: source.id, sourceIdStack: sourceStack.map(function (t) { return t.id; }), targetId: target.id, @@ -59810,9 +61884,9 @@ var ts; return result; } function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) { - 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" /* CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id }); var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; } function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState) { @@ -59834,8 +61908,21 @@ var ts; if (target.flags & 2097152 /* Intersection */) { return typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2 /* Target */); } - // Source is an intersection. Check to see if any constituents of the intersection are immediately related - // to the 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 */) { + var constraints = ts.sameMap(source.types, function (t) { return t.flags & 131068 /* Primitive */ ? t : getBaseConstraintOfType(t) || unknownType; }); + if (constraints !== source.types) { + source = getIntersectionType(constraints); + if (!(source.flags & 2097152 /* Intersection */)) { + return isRelatedTo(source, target, /*reportErrors*/ false); + } + } + } + // Check to see if any constituents of the intersection are immediately related to the target. // // Don't report errors though. Checking whether a constituent is related to the source is not actually // useful and leads to some confusing error messages. Instead it is better to let the below checks @@ -59855,21 +61942,21 @@ var ts; if (flags & 4194304 /* Index */) { return isRelatedTo(source.type, target.type, /*reportErrors*/ false); } - var result_7 = 0 /* False */; + var result_8 = 0 /* False */; if (flags & 8388608 /* IndexedAccess */) { - if (result_7 = isRelatedTo(source.objectType, target.objectType, /*reportErrors*/ false)) { - if (result_7 &= isRelatedTo(source.indexType, target.indexType, /*reportErrors*/ false)) { - return result_7; + if (result_8 = isRelatedTo(source.objectType, target.objectType, /*reportErrors*/ false)) { + if (result_8 &= isRelatedTo(source.indexType, target.indexType, /*reportErrors*/ false)) { + return result_8; } } } if (flags & 16777216 /* Conditional */) { if (source.root.isDistributive === target.root.isDistributive) { - if (result_7 = isRelatedTo(source.checkType, target.checkType, /*reportErrors*/ false)) { - if (result_7 &= isRelatedTo(source.extendsType, target.extendsType, /*reportErrors*/ false)) { - if (result_7 &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), /*reportErrors*/ false)) { - if (result_7 &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), /*reportErrors*/ false)) { - return result_7; + if (result_8 = isRelatedTo(source.checkType, target.checkType, /*reportErrors*/ false)) { + if (result_8 &= isRelatedTo(source.extendsType, target.extendsType, /*reportErrors*/ false)) { + if (result_8 &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), /*reportErrors*/ false)) { + if (result_8 &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), /*reportErrors*/ false)) { + return result_8; } } } @@ -59949,6 +62036,20 @@ var ts; } } else if (target.flags & 8388608 /* IndexedAccess */) { + if (source.flags & 8388608 /* 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, reportErrors)) { + result &= isRelatedTo(source.indexType, target.indexType, reportErrors); + } + if (result) { + resetErrorInfo(saveErrorInfo); + return result; + } + if (reportErrors) { + originalErrorInfo = errorInfo; + } + } // A type S is related to a type T[K] if S is related to C, where C is the base // constraint of T[K] for writing. if (relation === assignableRelation || relation === comparableRelation) { @@ -59957,13 +62058,26 @@ var ts; var baseObjectType = getBaseConstraintOfType(objectType) || objectType; var baseIndexType = getBaseConstraintOfType(indexType) || indexType; if (!isGenericObjectType(baseObjectType) && !isGenericIndexType(baseIndexType)) { - var accessFlags = 2 /* Writing */ | (baseObjectType !== objectType ? 1 /* NoIndexSignatures */ : 0); - var constraint = getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, target.noUncheckedIndexedAccessCandidate, /*accessNode*/ undefined, accessFlags); - if (constraint && (result = isRelatedTo(source, constraint, reportErrors))) { - return result; + var accessFlags = 4 /* Writing */ | (baseObjectType !== objectType ? 2 /* 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, reportErrors)) { + return result; + } + // prefer the shorter chain of the constraint comparison chain, and the direct comparison chain + if (reportErrors && originalErrorInfo && errorInfo) { + errorInfo = countMessageChainBreadth([originalErrorInfo]) <= countMessageChainBreadth([errorInfo]) ? originalErrorInfo : errorInfo; + } } } } + if (reportErrors) { + originalErrorInfo = undefined; + } } else if (isGenericMappedType(target) && !target.declaration.nameType) { // A source type T is related to a target type { [P in X]: T[P] } @@ -60007,27 +62121,48 @@ var ts; } } } - else if (target.flags & 134217728 /* TemplateLiteral */ && source.flags & 128 /* StringLiteral */) { - if (isPatternLiteralType(target)) { - // match all non-`string` segments - var result_8 = inferLiteralsFromTemplateLiteralType(source, target); - if (result_8 && ts.every(result_8, function (r, i) { return isStringLiteralTypeValueParsableAsType(r, target.types[i]); })) { - return -1 /* True */; - } + else if (target.flags & 16777216 /* Conditional */) { + var c = target; + // Check if the conditional is always true or always false but still deferred for distribution purposes + var skipTrue = !isTypeAssignableTo(getPermissiveInstantiation(c.checkType), getPermissiveInstantiation(c.extendsType)); + var skipFalse = !skipTrue && isConditionalTypeAlwaysTrueDisregardingInferTypes(c); + // Instantiate with a replacement mapper if the conditional is distributive, replacing the check type with a clone of itself, + // this way {x: string | number, y: string | number} -> (T extends T ? { x: T, y: T } : never) appropriately _fails_ when + // T = string | number (since that will end up distributing and producing `{x: string, y: string} | {x: number, y: number}`, + // to which `{x: string | number, y: string | number}` isn't assignable) + var distributionMapper = void 0; + var checkVar = getActualTypeVariable(c.root.checkType); + if (c.root.isDistributive && checkVar.flags & 262144 /* TypeParameter */) { + var newParam = cloneTypeParameter(checkVar); + distributionMapper = prependTypeMapping(checkVar, newParam, c.mapper); + newParam.mapper = distributionMapper; + } + // TODO: Find a nice way to include potential conditional type breakdowns in error output, if they seem good (they usually don't) + var localResult = void 0; + if (skipTrue || (localResult = isRelatedTo(source, distributionMapper ? instantiateType(getTypeFromTypeNode(c.root.node.trueType), distributionMapper) : getTrueTypeFromConditionalType(c), /*reportErrors*/ false))) { + if (!skipFalse) { + localResult = (localResult || 3 /* Maybe */) & isRelatedTo(source, distributionMapper ? instantiateType(getTypeFromTypeNode(c.root.node.falseType), distributionMapper) : getFalseTypeFromConditionalType(c), /*reportErrors*/ false); + } + } + if (localResult) { + resetErrorInfo(saveErrorInfo); + return localResult; } } - if (source.flags & 8650752 /* TypeVariable */) { - if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) { - // 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, reportErrors)) { - result &= isRelatedTo(source.indexType, target.indexType, reportErrors); - } - if (result) { - resetErrorInfo(saveErrorInfo); - return result; - } + else if (target.flags & 134217728 /* TemplateLiteral */) { + if (source.flags & 134217728 /* TemplateLiteral */) { + // 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)); } - else { + var result_9 = inferTypesFromTemplateLiteralType(source, target); + if (result_9 && ts.every(result_9, function (r, i) { return isValidTypeForTemplateLiteralPlaceholder(r, target.types[i]); })) { + return -1 /* True */; + } + } + if (source.flags & 8650752 /* TypeVariable */) { + // IndexedAccess comparisons are handled above in the `target.flags & TypeFlage.IndexedAccess` branch + if (!(source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */)) { var constraint = getConstraintOfType(source); if (!constraint || (source.flags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) { // A type variable with no constraint is not related to the non-primitive object type. @@ -60042,7 +62177,7 @@ var ts; 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, reportErrors, /*headMessage*/ undefined, intersectionState)) { + else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, reportErrors && !(target.flags & source.flags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) { resetErrorInfo(saveErrorInfo); return result; } @@ -60055,17 +62190,10 @@ var ts; } } else if (source.flags & 134217728 /* TemplateLiteral */) { - if (target.flags & 134217728 /* TemplateLiteral */) { - if (source.texts.length === target.texts.length && - source.types.length === target.types.length && - ts.every(source.texts, function (t, i) { return t === target.texts[i]; }) && - ts.every(instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)).types, function (t, i) { return !!(target.types[i].flags & (1 /* Any */ | 4 /* String */)) || !!isRelatedTo(t, target.types[i], /*reportErrors*/ false); })) { - return -1 /* True */; - } - } - else { - var constraint = getBaseConstraintOfType(source); - if (result = isRelatedTo(constraint && constraint !== source ? constraint : stringType, target, reportErrors)) { + if (!(target.flags & 134217728 /* TemplateLiteral */)) { + var baseConstraint = getBaseConstraintOfType(source); + var constraint = baseConstraint && baseConstraint !== source ? baseConstraint : stringType; + if (result = isRelatedTo(constraint, target, reportErrors)) { resetErrorInfo(saveErrorInfo); return result; } @@ -60097,7 +62225,7 @@ var ts; 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 */, isRelatedTo); - inferTypes(ctx.inferences, target.extendsType, sourceExtends, 256 /* NoConstraints */ | 512 /* AlwaysStrict */); + inferTypes(ctx.inferences, target.extendsType, sourceExtends, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */); sourceExtends = instantiateType(sourceExtends, ctx.mapper); mapper = ctx.mapper; } @@ -60155,7 +62283,7 @@ var ts; return 0 /* False */; } if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && source.target === target.target && - !(ts.getObjectFlags(source) & 8192 /* MarkerType */ || ts.getObjectFlags(target) & 8192 /* MarkerType */)) { + !(ts.getObjectFlags(source) & 4096 /* MarkerType */ || ts.getObjectFlags(target) & 4096 /* MarkerType */)) { // 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 // information for the type parameters and relate the type arguments accordingly. @@ -60183,7 +62311,7 @@ var ts; } // 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) & 32768 /* FreshLiteral */ && !isEmptyObjectType(source)) { + else if ((relation === subtypeRelation || relation === strictSubtypeRelation) && isEmptyObjectType(target) && ts.getObjectFlags(target) & 16384 /* FreshLiteral */ && !isEmptyObjectType(source)) { return 0 /* False */; } // Even if relationship doesn't hold for unions, intersections, or generic type references, @@ -60221,14 +62349,19 @@ var ts; if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */) && target.flags & 1048576 /* Union */) { var objectOnlyTarget = extractTypesOfKind(target, 524288 /* Object */ | 2097152 /* Intersection */ | 33554432 /* Substitution */); if (objectOnlyTarget.flags & 1048576 /* Union */) { - var result_9 = typeRelatedToDiscriminatedType(source, objectOnlyTarget); - if (result_9) { - return result_9; + var result_10 = typeRelatedToDiscriminatedType(source, objectOnlyTarget); + if (result_10) { + return result_10; } } } } return 0 /* False */; + function countMessageChainBreadth(info) { + if (!info) + return 0; + return ts.reduceLeft(info, function (value, chain) { return value + 1 + countMessageChainBreadth(chain.next); }, 0); + } function relateVariances(sourceTypeArguments, targetTypeArguments, variances, intersectionState) { if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors, intersectionState)) { return result; @@ -60290,13 +62423,13 @@ var ts; var modifiersRelated = relation === comparableRelation || (relation === identityRelation ? getMappedTypeModifiers(source) === getMappedTypeModifiers(target) : getCombinedMappedTypeOptionality(source) <= getCombinedMappedTypeOptionality(target)); if (modifiersRelated) { - var result_10; + var result_11; var targetConstraint = getConstraintTypeFromMappedType(target); var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), makeFunctionTypeMapper(getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMarkers : reportUnreliableMarkers)); - if (result_10 = isRelatedTo(targetConstraint, sourceConstraint, reportErrors)) { + if (result_11 = isRelatedTo(targetConstraint, sourceConstraint, 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), reportErrors); + return result_11 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), reportErrors); } } } @@ -60324,10 +62457,10 @@ var ts; var numCombinations = 1; for (var _i = 0, sourcePropertiesFiltered_1 = sourcePropertiesFiltered; _i < sourcePropertiesFiltered_1.length; _i++) { var sourceProperty = sourcePropertiesFiltered_1[_i]; - numCombinations *= countTypes(getTypeOfSymbol(sourceProperty)); + numCombinations *= countTypes(getNonMissingTypeOfSymbol(sourceProperty)); if (numCombinations > 25) { // We've reached the complexity limit. - ts.tracing.instant("checkTypes" /* CheckTypes */, "typeRelatedToDiscriminatedType_DepthLimit", { sourceId: source.id, targetId: target.id, numCombinations: numCombinations }); + 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 */; } } @@ -60336,7 +62469,7 @@ var ts; var excludedProperties = new ts.Set(); for (var i = 0; i < sourcePropertiesFiltered.length; i++) { var sourceProperty = sourcePropertiesFiltered[i]; - var sourcePropertyType = getTypeOfSymbol(sourceProperty); + var sourcePropertyType = getNonMissingTypeOfSymbol(sourceProperty); sourceDiscriminantTypes[i] = sourcePropertyType.flags & 1048576 /* Union */ ? sourcePropertyType.types : [sourcePropertyType]; @@ -60366,8 +62499,8 @@ var ts; } }; for (var i = 0; i < sourcePropertiesFiltered.length; i++) { - var state_6 = _loop_18(i); - switch (state_6) { + var state_7 = _loop_18(i); + switch (state_7) { case "continue-outer": continue outer; } } @@ -60380,9 +62513,9 @@ var ts; }; for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) { var combination = discriminantCombinations_1[_a]; - var state_5 = _loop_17(combination); - if (typeof state_5 === "object") - return state_5.value; + var state_6 = _loop_17(combination); + if (typeof state_6 === "object") + return state_6.value; } // Compare the remaining non-discriminant properties of each match. var result = -1 /* True */; @@ -60429,46 +62562,9 @@ var ts; } function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState) { var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* Partial */); - var source = getTypeOfSourceProperty(sourceProp); - if (ts.getCheckFlags(targetProp) & 65536 /* DeferredType */ && !getSymbolLinks(targetProp).type) { - // Rather than resolving (and normalizing) the type, relate constituent-by-constituent without performing normalization or seconadary passes - var links = getSymbolLinks(targetProp); - ts.Debug.assertIsDefined(links.deferralParent); - ts.Debug.assertIsDefined(links.deferralConstituents); - var unionParent = !!(links.deferralParent.flags & 1048576 /* Union */); - var result_11 = unionParent ? 0 /* False */ : -1 /* True */; - var targetTypes = links.deferralConstituents; - for (var _i = 0, targetTypes_3 = targetTypes; _i < targetTypes_3.length; _i++) { - var targetType = targetTypes_3[_i]; - var related = isRelatedTo(source, targetType, /*reportErrors*/ false, /*headMessage*/ undefined, unionParent ? 0 : 2 /* Target */); - if (!unionParent) { - if (!related) { - // Can't assign to a target individually - have to fallback to assigning to the _whole_ intersection (which forces normalization) - return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); - } - result_11 &= related; - } - else { - if (related) { - return related; - } - } - } - if (unionParent && !result_11 && targetIsOptional) { - result_11 = isRelatedTo(source, undefinedType); - } - if (unionParent && !result_11 && reportErrors) { - // The easiest way to get the right errors here is to un-defer (which may be costly) - // If it turns out this is too costly too often, we can replicate the error handling logic within - // typeRelatedToSomeType without the discriminatable type branch (as that requires a manifest union - // type on which to hand discriminable properties, which we are expressly trying to avoid here) - return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); - } - return result_11; - } - else { - return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors, /*headMessage*/ undefined, intersectionState); - } + var effectiveTarget = addOptionality(getNonMissingTypeOfSymbol(targetProp), /*isProperty*/ false, targetIsOptional); + var effectiveSource = getTypeOfSourceProperty(sourceProp); + return isRelatedTo(effectiveSource, effectiveTarget, reportErrors, /*headMessage*/ undefined, intersectionState); } function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState, skipOptional) { var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp); @@ -60597,7 +62693,7 @@ var ts; } return 0 /* False */; } - if (!targetRestFlag && sourceRestFlag) { + if (!targetRestFlag && (sourceRestFlag || targetArity < sourceArity)) { if (reportErrors) { if (sourceMinLength < targetMinLength) { reportError(ts.Diagnostics.Target_requires_0_element_s_but_source_may_have_fewer, targetMinLength); @@ -60645,10 +62741,11 @@ var ts; } } var sourceType = !isTupleType(source) ? sourceTypeArguments[0] : - i < startCount || i >= targetArity - endCount ? sourceTypeArguments[sourceIndex] : + i < startCount || i >= targetArity - endCount ? removeMissingType(sourceTypeArguments[sourceIndex], !!(sourceFlags & targetFlags & 2 /* Optional */)) : getElementTypeOfSliceOfTupleType(source, startCount, endCount) || neverType; var targetType = targetTypeArguments[i]; - var targetCheckType = sourceFlags & 8 /* Variadic */ && targetFlags & 4 /* Rest */ ? createArrayType(targetType) : targetType; + var targetCheckType = sourceFlags & 8 /* Variadic */ && targetFlags & 4 /* Rest */ ? createArrayType(targetType) : + removeMissingType(targetType, !!(targetFlags & 2 /* Optional */)); var related = isRelatedTo(sourceType, targetCheckType, reportErrors, /*headMessage*/ undefined, intersectionState); if (!related) { if (reportErrors) { @@ -60682,7 +62779,7 @@ var ts; var sourceProp = _a[_i]; if (!getPropertyOfObjectType(target, sourceProp.escapedName)) { var sourceType = getTypeOfSymbol(sourceProp); - if (!(sourceType === undefinedType || sourceType === undefinedWideningType || sourceType === optionalType)) { + if (!(sourceType.flags & 32768 /* Undefined */)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(sourceProp), typeToString(target)); } @@ -60701,7 +62798,7 @@ var ts; if (!(targetProp.flags & 4194304 /* Prototype */) && (!numericNamesOnly || isNumericLiteralName(name) || name === "length")) { var sourceProp = getPropertyOfType(source, name); if (sourceProp && sourceProp !== targetProp) { - var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, intersectionState, relation === comparableRelation); + var related = propertyRelatedTo(source, target, sourceProp, targetProp, getNonMissingTypeOfSymbol, reportErrors, intersectionState, relation === comparableRelation); if (!related) { return 0 /* False */; } @@ -60795,7 +62892,7 @@ var ts; 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) === 166 /* Constructor */ || ((_b = sourceSignature.declaration) === null || _b === void 0 ? void 0 : _b.kind) === 166 /* Constructor */)) { + (((_a = targetSignature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 168 /* Constructor */ || ((_b = sourceSignature.declaration) === null || _b === void 0 ? void 0 : _b.kind) === 168 /* Constructor */)) { var constructSignatureToString = function (signature) { return signatureToString(signature, /*enclosingDeclaration*/ undefined, 262144 /* WriteArrowStyleSignature */, kind); }; @@ -60903,10 +63000,17 @@ var ts; return indexTypesIdenticalTo(source, target, kind); } var targetType = getIndexTypeOfType(target, kind); - if (!targetType || targetType.flags & 1 /* Any */ && !sourceIsPrimitive) { - // Index signature of type any permits assignment from everything but primitives + if (!targetType) { return -1 /* True */; } + if (targetType.flags & 1 /* Any */ && !sourceIsPrimitive) { + // An index signature of type `any` permits assignment from everything but primitives, + // provided that there is also a `string` index signature of type `any`. + var stringIndexType = kind === 0 /* String */ ? targetType : getIndexTypeOfType(target, 0 /* String */); + if (stringIndexType && stringIndexType.flags & 1 /* Any */) { + return -1 /* True */; + } + } if (isGenericMappedType(source)) { // A generic mapped type { [P in K]: T } is related to a type with an index signature // { [x: string]: U }, and optionally with an index signature { [x: number]: V }, @@ -61061,7 +63165,7 @@ var ts; // type, and flag the result as a marker type reference. function getMarkerTypeReference(type, source, target) { var result = createTypeReference(type, ts.map(type.typeParameters, function (t) { return t === source ? target : t; })); - result.objectFlags |= 8192 /* MarkerType */; + result.objectFlags |= 4096 /* MarkerType */; return result; } function getAliasVariances(symbol) { @@ -61082,7 +63186,7 @@ var ts; if (typeParameters === void 0) { typeParameters = ts.emptyArray; } var variances = cache.variances; if (!variances) { - ts.tracing.push("checkTypes" /* CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: (_c = (_a = cache.id) !== null && _a !== void 0 ? _a : (_b = cache.declaredType) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : -1 }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: (_c = (_a = cache.id) !== null && _a !== void 0 ? _a : (_b = cache.declaredType) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : -1 }); // The emptyArray singleton is used to signal a recursive invocation. cache.variances = ts.emptyArray; variances = []; @@ -61121,7 +63225,7 @@ var ts; _loop_19(tp); } cache.variances = variances; - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } return variances; } @@ -61149,7 +63253,7 @@ var ts; return !!(ts.getObjectFlags(type) & 4 /* Reference */) && !type.node; } function isTypeReferenceWithGenericArguments(type) { - return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); + return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return !!(t.flags & 262144 /* TypeParameter */) || isTypeReferenceWithGenericArguments(t); }); } /** * getTypeReferenceId(A) returns "111=0-12=1" @@ -61235,8 +63339,8 @@ var ts; } // 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) { - return forEachProperty(prop, function (p) { return ts.getDeclarationModifierFlagsFromSymbol(p) & 16 /* Protected */ ? + function isClassDerivedFromDeclaringClasses(checkClass, prop, writing) { + return forEachProperty(prop, function (p) { return ts.getDeclarationModifierFlagsFromSymbol(p, writing) & 16 /* 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 @@ -61254,23 +63358,26 @@ var ts; function isDeeplyNestedType(type, stack, depth) { if (depth >= 5) { var identity_1 = getRecursionIdentity(type); - if (identity_1) { - var count = 0; - for (var i = 0; i < depth; i++) { - if (getRecursionIdentity(stack[i]) === identity_1) { - count++; - if (count >= 5) { - return true; - } + var count = 0; + for (var i = 0; i < depth; i++) { + if (getRecursionIdentity(stack[i]) === identity_1) { + count++; + if (count >= 5) { + return true; } } } } return false; } - // Types with constituents that could circularly reference the type have a recursion identity. The recursion - // identity is some object that is common to instantiations of the type with the same origin. + // The recursion identity of a type is an object identity that is shared among multiple instantiations of the type. + // We track recursion identities in order to identify deeply nested and possibly infinite type instantiations with + // the same origin. For example, when type parameters are in scope in an object type such as { x: T }, all + // instantiations of that type have the same recursion identity. The default recursion identity is the object + // identity of the type, meaning that every type is unique. Generally, types with constituents that could circularly + // 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) { // Deferred type references are tracked through their associated AST node. This gives us finer @@ -61288,6 +63395,9 @@ var ts; return type.target; } } + if (type.flags & 262144 /* TypeParameter */) { + return type.symbol; + } if (type.flags & 8388608 /* IndexedAccess */) { // Identity is the leftmost object type in a chain of indexed accesses, eg, in A[P][Q] it is A do { @@ -61299,7 +63409,7 @@ var ts; // The root object represents the origin of the conditional type return type.root; } - return undefined; + return type; } function isPropertyIdenticalTo(sourceProp, targetProp) { return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0 /* False */; @@ -61438,6 +63548,9 @@ var ts; // 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; }); @@ -61472,9 +63585,35 @@ var ts; // 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); } + function getSingleBaseForNonAugmentingSubtype(type) { + if (!(ts.getObjectFlags(type) & 4 /* Reference */) || !(ts.getObjectFlags(type.target) & 3 /* ClassOrInterface */)) { + return undefined; + } + if (ts.getObjectFlags(type) & 33554432 /* IdenticalBaseTypeCalculated */) { + return ts.getObjectFlags(type) & 67108864 /* IdenticalBaseTypeExists */ ? type.cachedEquivalentBaseType : undefined; + } + type.objectFlags |= 33554432 /* IdenticalBaseTypeCalculated */; + var target = type.target; + var bases = getBaseTypes(target); + if (bases.length !== 1) { + return undefined; + } + if (getMembersOfSymbol(type.symbol).size) { + return undefined; // If the interface has any members, they may subtype members in the base, so we should do a full structural comparison + } + var instantiatedBase = !ts.length(target.typeParameters) ? bases[0] : instantiateType(bases[0], createTypeMapper(target.typeParameters, getTypeArguments(type).slice(0, target.typeParameters.length))); + if (ts.length(getTypeArguments(type)) > ts.length(target.typeParameters)) { + instantiatedBase = getTypeWithThisArgument(instantiatedBase, ts.last(getTypeArguments(type))); + } + type.objectFlags |= 67108864 /* IdenticalBaseTypeExists */; + return type.cachedEquivalentBaseType = instantiatedBase; + } + function isEmptyLiteralType(type) { + return strictNullChecks ? type === implicitNeverType : type === undefinedWideningType; + } function isEmptyArrayLiteralType(type) { - var elementType = isArrayType(type) ? getTypeArguments(type)[0] : undefined; - return elementType === undefinedWideningType || elementType === implicitNeverType; + var elementType = getElementTypeOfArrayType(type); + return !!elementType && isEmptyLiteralType(elementType); } function isTupleLikeType(type) { return isTupleType(type) || !!getPropertyOfType(type, "0"); @@ -61498,6 +63637,13 @@ var ts; function isUnitType(type) { return !!(type.flags & 109440 /* Unit */); } + function isUnitLikeType(type) { + return type.flags & 2097152 /* Intersection */ ? ts.some(type.types, isUnitType) : + !!(type.flags & 109440 /* Unit */); + } + function extractUnitType(type) { + return type.flags & 2097152 /* 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) : @@ -61505,7 +63651,7 @@ var ts; } function getBaseTypeOfLiteralType(type) { return type.flags & 1024 /* EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : - type.flags & 134217856 /* StringLikeLiteral */ ? stringType : + type.flags & 128 /* StringLiteral */ ? stringType : type.flags & 256 /* NumberLiteral */ ? numberType : type.flags & 2048 /* BigIntLiteral */ ? bigintType : type.flags & 512 /* BooleanLiteral */ ? booleanType : @@ -61514,7 +63660,7 @@ var ts; } function getWidenedLiteralType(type) { return type.flags & 1024 /* EnumLiteral */ && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(type) : - type.flags & 134217856 /* StringLikeLiteral */ && isFreshLiteralType(type) ? stringType : + 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 : @@ -61643,19 +63789,23 @@ var ts; missing === 65536 /* Null */ ? getUnionType([type, nullType]) : getUnionType([type, undefinedType, nullType]); } - function getOptionalType(type) { + function getOptionalType(type, isProperty) { + if (isProperty === void 0) { isProperty = false; } ts.Debug.assert(strictNullChecks); - return type.flags & 32768 /* Undefined */ ? type : getUnionType([type, undefinedType]); + return type.flags & 32768 /* Undefined */ ? type : getUnionType([type, isProperty ? missingType : undefinedType]); } function getGlobalNonNullableTypeInstantiation(type) { + // First reduce away any constituents that are assignable to 'undefined' or 'null'. This not only eliminates + // 'undefined' and 'null', but also higher-order types such as a type parameter 'U extends undefined | null' + // that isn't eliminated by a NonNullable instantiation. + var reducedType = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); if (!deferredGlobalNonNullableTypeAlias) { deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288 /* TypeAlias */, /*diagnostic*/ undefined) || unknownSymbol; } - // Use NonNullable global type alias if available to improve quick info/declaration emit - if (deferredGlobalNonNullableTypeAlias !== unknownSymbol) { - return getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]); - } - return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); // Type alias unavailable, fall back to non-higher-order behavior + // If the NonNullable type is available, return an instantiation. Otherwise just return the reduced type. + return deferredGlobalNonNullableTypeAlias !== unknownSymbol ? + getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [reducedType]) : + reducedType; } function getNonNullableType(type) { return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type; @@ -61677,6 +63827,12 @@ var ts; ts.isOptionalChain(expression) ? removeOptionalTypeMarker(exprType) : exprType; } + function removeMissingType(type, isOptional) { + return strictOptionalProperties && isOptional ? filterType(type, function (t) { return t !== missingType; }) : type; + } + function containsMissingType(type) { + return strictOptionalProperties && (type === missingType || type.flags & 1048576 /* Union */ && containsType(type.types, missingType)); + } /** * Is source potentially coercible to target type under `==`. * Assumes that `source` is a constituent of a union, hence @@ -61708,7 +63864,7 @@ var ts; function isObjectTypeWithInferableIndex(type) { return type.flags & 2097152 /* Intersection */ ? ts.every(type.types, isObjectTypeWithInferableIndex) : !!(type.symbol && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 && - !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 2048 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); + !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 1024 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); } function createSymbolWithType(source, type) { var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */); @@ -61741,7 +63897,7 @@ var ts; * Leave signatures alone since they are not subject to the check. */ function getRegularTypeOfObjectLiteral(type) { - if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 32768 /* FreshLiteral */)) { + if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 16384 /* FreshLiteral */)) { return type; } var regularType = type.regularType; @@ -61752,7 +63908,7 @@ var ts; var members = transformTypeOfMembers(type, getRegularTypeOfObjectLiteral); var regularNew = createAnonymousType(resolved.symbol, members, resolved.callSignatures, resolved.constructSignatures, resolved.stringIndexInfo, resolved.numberIndexInfo); regularNew.flags = resolved.flags; - regularNew.objectFlags |= resolved.objectFlags & ~32768 /* FreshLiteral */; + regularNew.objectFlags |= resolved.objectFlags & ~16384 /* FreshLiteral */; type.regularType = regularNew; return regularNew; } @@ -61782,7 +63938,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) & 1024 /* ContainsSpread */)) { + if (isObjectLiteralType(t) && !(ts.getObjectFlags(t) & 4194304 /* ContainsSpread */)) { for (var _b = 0, _c = getPropertiesOfType(t); _b < _c.length; _b++) { var prop = _c[_b]; names.set(prop.escapedName, prop); @@ -61809,7 +63965,7 @@ var ts; if (cached) { return cached; } - var result = createSymbolWithType(prop, undefinedType); + var result = createSymbolWithType(prop, missingType); result.flags |= 16777216 /* Optional */; undefinedProperties.set(prop.escapedName, result); return result; @@ -61831,14 +63987,14 @@ var ts; var stringIndexInfo = getIndexInfoOfType(type, 0 /* String */); var numberIndexInfo = getIndexInfoOfType(type, 1 /* Number */); var result = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, stringIndexInfo && createIndexInfo(getWidenedType(stringIndexInfo.type), stringIndexInfo.isReadonly), numberIndexInfo && createIndexInfo(getWidenedType(numberIndexInfo.type), numberIndexInfo.isReadonly)); - result.objectFlags |= (ts.getObjectFlags(type) & (16384 /* JSLiteral */ | 2097152 /* NonInferrableType */)); // Retain js literal flag through widening + result.objectFlags |= (ts.getObjectFlags(type) & (8192 /* JSLiteral */ | 524288 /* 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) & 1572864 /* RequiresWidening */) { + if (ts.getObjectFlags(type) & 393216 /* RequiresWidening */) { if (context === undefined && type.widened) { return type.widened; } @@ -61883,7 +64039,7 @@ var ts; */ function reportWideningErrorsInType(type) { var errorReported = false; - if (ts.getObjectFlags(type) & 524288 /* ContainsWideningType */) { + if (ts.getObjectFlags(type) & 131072 /* ContainsWideningType */) { if (type.flags & 1048576 /* Union */) { if (ts.some(type.types, isEmptyObjectType)) { errorReported = true; @@ -61909,7 +64065,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) & 524288 /* ContainsWideningType */) { + if (ts.getObjectFlags(t) & 131072 /* ContainsWideningType */) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, symbolToString(p), typeToString(getWidenedType(t))); } @@ -61928,12 +64084,12 @@ var ts; } var diagnostic; switch (declaration.kind) { - case 216 /* BinaryExpression */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 218 /* BinaryExpression */: + case 165 /* PropertyDeclaration */: + case 164 /* 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 160 /* Parameter */: + case 162 /* Parameter */: var param = declaration; if (ts.isIdentifier(param.name) && (ts.isCallSignatureDeclaration(param.parent) || ts.isMethodSignature(param.parent) || ts.isFunctionTypeNode(param.parent)) && @@ -61948,23 +64104,23 @@ 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 198 /* BindingElement */: + case 200 /* 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 308 /* JSDocFunctionType */: + case 311 /* JSDocFunctionType */: error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; - case 251 /* FunctionDeclaration */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 253 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: if (noImplicitAny && !declaration.name) { if (wideningKind === 3 /* 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); @@ -61978,7 +64134,7 @@ var ts; wideningKind === 3 /* 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 190 /* MappedType */: + case 192 /* MappedType */: if (noImplicitAny) { error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); } @@ -61989,7 +64145,7 @@ var ts; errorOrSuggestion(noImplicitAny, declaration, diagnostic, ts.declarationNameToString(ts.getNameOfDeclaration(declaration)), typeAsString); } function reportErrorsFromWidening(declaration, type, wideningKind) { - if (produceDiagnostics && noImplicitAny && ts.getObjectFlags(type) & 524288 /* ContainsWideningType */ && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) { + if (produceDiagnostics && noImplicitAny && ts.getObjectFlags(type) & 131072 /* ContainsWideningType */ && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) { // Report implicit any error within type if possible, otherwise report error on declaration if (!reportWideningErrorsInType(type)) { reportImplicitAny(declaration, type, wideningKind); @@ -62105,23 +64261,23 @@ var ts; // results for union and intersection types for performance reasons. function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); - if (objectFlags & 67108864 /* CouldContainTypeVariablesComputed */) { - return !!(objectFlags & 134217728 /* CouldContainTypeVariables */); + if (objectFlags & 1048576 /* CouldContainTypeVariablesComputed */) { + return !!(objectFlags & 2097152 /* 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 */ | 131072 /* ObjectRestType */)) || + objectFlags & (32 /* Mapped */ | 1024 /* ReverseMapped */ | 8388608 /* ObjectRestType */)) || type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && !isNonGenericTopLevelType(type) && ts.some(type.types, couldContainTypeVariables)); if (type.flags & 3899393 /* ObjectFlagsType */) { - type.objectFlags |= 67108864 /* CouldContainTypeVariablesComputed */ | (result ? 134217728 /* CouldContainTypeVariables */ : 0); + type.objectFlags |= 1048576 /* CouldContainTypeVariablesComputed */ | (result ? 2097152 /* CouldContainTypeVariables */ : 0); } return result; } function isNonGenericTopLevelType(type) { if (type.aliasSymbol && !type.aliasTypeArguments) { - var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 254 /* TypeAliasDeclaration */); - return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 297 /* SourceFile */ ? true : n.kind === 256 /* ModuleDeclaration */ ? false : "quit"; })); + var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 256 /* TypeAliasDeclaration */); + return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 299 /* SourceFile */ ? true : n.kind === 258 /* ModuleDeclaration */ ? false : "quit"; })); } return false; } @@ -62174,7 +64330,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) & 2097152 /* NonInferrableType */) || + return !(ts.getObjectFlags(type) & 524288 /* NonInferrableType */) || isObjectLiteralType(type) && ts.some(getPropertiesOfType(type), function (prop) { return isPartiallyInferableType(getTypeOfSymbol(prop)); }) || isTupleType(type) && ts.some(getTypeArguments(type), isPartiallyInferableType); } @@ -62198,14 +64354,18 @@ var ts; } // 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(2048 /* ReverseMapped */ | 16 /* Anonymous */, /*symbol*/ undefined); + var reversed = createObjectType(1024 /* ReverseMapped */ | 16 /* Anonymous */, /*symbol*/ undefined); reversed.source = source; reversed.mappedType = target; reversed.constraintType = constraint; return reversed; } function getTypeOfReverseMappedSymbol(symbol) { - return inferReverseMappedType(symbol.propertyType, symbol.mappedType, symbol.constraintType); + var links = getSymbolLinks(symbol); + if (!links.type) { + links.type = inferReverseMappedType(symbol.propertyType, symbol.mappedType, symbol.constraintType); + } + return links.type; } function inferReverseMappedType(sourceType, target, constraint) { var typeParameter = getIndexedAccessType(constraint.type, getTypeParameterFromMappedType(target)); @@ -62297,51 +64457,113 @@ var ts; // * 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 */); } - function isStringLiteralTypeValueParsableAsType(s, target) { - if (target.flags & 1048576 /* Union */) { - return !!forEachType(target, function (t) { return isStringLiteralTypeValueParsableAsType(s, t); }); - } - switch (target) { - case stringType: return true; - case numberType: return s.value !== "" && isFinite(+(s.value)); - case bigintType: return s.value !== "" && isValidBigIntString(s.value); - // the next 4 should be handled in `getTemplateLiteralType`, as they are all exactly one value, but are here for completeness, just in case - // this function is ever used on types which don't come from template literal holes - case trueType: return s.value === "true"; - case falseType: return s.value === "false"; - case undefinedType: return s.value === "undefined"; - case nullType: return s.value === "null"; - default: return !!(target.flags & 1 /* Any */); - } - } - function inferLiteralsFromTemplateLiteralType(source, target) { - var value = source.value; - var texts = target.texts; - var lastIndex = texts.length - 1; - var startText = texts[0]; - var endText = texts[lastIndex]; - if (!(value.startsWith(startText) && value.slice(startText.length).endsWith(endText))) + function isValidTypeForTemplateLiteralPlaceholder(source, target) { + if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) { + return true; + } + if (source.flags & 128 /* StringLiteral */) { + var value = source.value; + return !!(target.flags & 8 /* Number */ && value !== "" && isFinite(+value) || + target.flags & 64 /* BigInt */ && value !== "" && isValidBigIntString(value) || + target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName); + } + if (source.flags & 134217728 /* 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 */ ? + ts.arraysEqual(source.texts, target.texts) ? ts.map(source.types, getStringLikeTypeForType) : + inferFromLiteralPartsToTemplateLiteral(source.texts, source.types, target) : + undefined; + } + function getStringLikeTypeForType(type) { + return type.flags & (1 /* Any */ | 402653316 /* 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 + // with one text part and zero type parts. The function returns an array of inferred string or template literal types + // corresponding to the placeholders in the target template literal, or undefined if the source doesn't match the target. + // + // We first check that the starting source text part matches the starting target text part, and that the ending source + // text part ends matches the ending target text part. We then iterate through the remaining target text parts, finding + // a match for each in the source and inferring string or template literal types created from the segments of the source + // that occur between the matches. During this iteration, seg holds the index of the current text part in the sourceTexts + // array and pos holds the current character position in the current text part. + // + // Consider inference from type `<<${string}>.<${number}-${number}>>` to type `<${string}.${string}>`, i.e. + // sourceTexts = ['<<', '>.<', '-', '>>'] + // sourceTypes = [string, number, number] + // target.texts = ['<', '.', '>'] + // We first match '<' in the target to the start of '<<' in the source and '>' in the target to the end of '>>' in + // the source. The first match for the '.' in target occurs at character 1 in the source text part at index 1, and thus + // the first inference is the template literal type `<${string}>`. The remainder of the source makes up the second + // inference, the template literal type `<${number}-${number}>`. + function inferFromLiteralPartsToTemplateLiteral(sourceTexts, sourceTypes, target) { + var lastSourceIndex = sourceTexts.length - 1; + var sourceStartText = sourceTexts[0]; + var sourceEndText = sourceTexts[lastSourceIndex]; + var targetTexts = target.texts; + var lastTargetIndex = targetTexts.length - 1; + var targetStartText = targetTexts[0]; + var targetEndText = targetTexts[lastTargetIndex]; + if (lastSourceIndex === 0 && sourceStartText.length < targetStartText.length + targetEndText.length || + !sourceStartText.startsWith(targetStartText) || !sourceEndText.endsWith(targetEndText)) return undefined; + var remainingEndText = sourceEndText.slice(0, sourceEndText.length - targetEndText.length); var matches = []; - var str = value.slice(startText.length, value.length - endText.length); - var pos = 0; - for (var i = 1; i < lastIndex; i++) { - var delim = texts[i]; - var delimPos = delim.length > 0 ? str.indexOf(delim, pos) : pos < str.length ? pos + 1 : -1; - if (delimPos < 0) + var seg = 0; + var pos = targetStartText.length; + for (var i = 1; i < lastTargetIndex; i++) { + var delim = targetTexts[i]; + if (delim.length > 0) { + var s = seg; + var p = pos; + while (true) { + p = getSourceText(s).indexOf(delim, p); + if (p >= 0) + break; + s++; + if (s === sourceTexts.length) + return undefined; + p = 0; + } + addMatch(s, p); + pos += delim.length; + } + else if (pos < getSourceText(seg).length) { + addMatch(seg, pos + 1); + } + else if (seg < lastSourceIndex) { + addMatch(seg + 1, 0); + } + else { return undefined; - matches.push(getLiteralType(str.slice(pos, delimPos))); - pos = delimPos + delim.length; + } } - matches.push(getLiteralType(str.slice(pos))); + addMatch(lastSourceIndex, getSourceText(lastSourceIndex).length); return matches; + function getSourceText(index) { + return index < lastSourceIndex ? sourceTexts[index] : remainingEndText; + } + function addMatch(s, p) { + var matchType = s === seg ? + getLiteralType(getSourceText(s).slice(pos, p)) : + getTemplateLiteralType(__spreadArray(__spreadArray([sourceTexts[seg].slice(pos)], sourceTexts.slice(seg + 1, s)), [getSourceText(s).slice(0, p)]), sourceTypes.slice(seg, s)); + matches.push(matchType); + seg = s; + pos = p; + } } function inferTypes(inferences, originalSource, originalTarget, priority, contravariant) { if (priority === void 0) { priority = 0; } if (contravariant === void 0) { contravariant = false; } var bivariant = false; var propagationType; - var inferencePriority = 1024 /* MaxValue */; + var inferencePriority = 2048 /* MaxValue */; var allowComplexConstraintInference = true; var visited; var sourceStack; @@ -62428,8 +64650,8 @@ var ts; // 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 (ts.getObjectFlags(source) & 2097152 /* NonInferrableType */ || source === nonInferrableAnyType || source === silentNeverType || - (priority & 64 /* ReturnType */ && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) { + if (ts.getObjectFlags(source) & 524288 /* NonInferrableType */ || source === nonInferrableAnyType || source === silentNeverType || + (priority & 128 /* ReturnType */ && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) { return; } var inference = getInferenceInfoForType(target); @@ -62456,7 +64678,7 @@ var ts; clearCachedInferences(inferences); } } - if (!(priority & 64 /* ReturnType */) && target.flags & 262144 /* TypeParameter */ && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) { + if (!(priority & 128 /* ReturnType */) && target.flags & 262144 /* TypeParameter */ && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) { inference.topLevel = false; clearCachedInferences(inferences); } @@ -62496,7 +64718,7 @@ var ts; else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 4194304 /* Index */) { var empty = createEmptyObjectTypeFromStringLiteral(source); contravariant = !contravariant; - inferWithPriority(empty, target.type, 128 /* LiteralKeyof */); + inferWithPriority(empty, target.type, 256 /* LiteralKeyof */); contravariant = !contravariant; } else if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) { @@ -62508,6 +64730,13 @@ var ts; inferFromTypes(source.type, target.type); } } + else if (source.flags & 33554432 /* Substitution */) { + inferFromTypes(source.baseType, target); + var oldPriority = priority; + priority |= 4 /* SubstituteSource */; + inferFromTypes(source.substitute, target); // Make substitute inference at a lower priority + priority = oldPriority; + } else if (target.flags & 16777216 /* Conditional */) { invokeOnce(source, target, inferToConditionalType); } @@ -62527,7 +64756,7 @@ var ts; } else { source = getReducedType(source); - if (!(priority & 256 /* NoConstraints */ && source.flags & (2097152 /* Intersection */ | 465829888 /* Instantiable */))) { + if (!(priority & 512 /* NoConstraints */ && source.flags & (2097152 /* Intersection */ | 465829888 /* 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` @@ -62565,26 +64794,22 @@ var ts; } (visited || (visited = new ts.Map())).set(key, -1 /* Circularity */); var saveInferencePriority = inferencePriority; - inferencePriority = 1024 /* MaxValue */; + inferencePriority = 2048 /* 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) || source; - var targetIdentity = getRecursionIdentity(target) || target; - if (sourceIdentity && ts.contains(sourceStack, sourceIdentity)) + var sourceIdentity = getRecursionIdentity(source); + var targetIdentity = getRecursionIdentity(target); + if (ts.contains(sourceStack, sourceIdentity)) expandingFlags |= 1 /* Source */; - if (targetIdentity && ts.contains(targetStack, targetIdentity)) + if (ts.contains(targetStack, targetIdentity)) expandingFlags |= 2 /* Target */; if (expandingFlags !== 3 /* Both */) { - if (sourceIdentity) - (sourceStack || (sourceStack = [])).push(sourceIdentity); - if (targetIdentity) - (targetStack || (targetStack = [])).push(targetIdentity); + (sourceStack || (sourceStack = [])).push(sourceIdentity); + (targetStack || (targetStack = [])).push(targetIdentity); action(source, target); - if (targetIdentity) - targetStack.pop(); - if (sourceIdentity) - sourceStack.pop(); + targetStack.pop(); + sourceStack.pop(); } else { inferencePriority = -1 /* Circularity */; @@ -62624,7 +64849,7 @@ var ts; } } function inferFromContravariantTypes(source, target) { - if (strictFunctionTypes || priority & 512 /* AlwaysStrict */) { + if (strictFunctionTypes || priority & 1024 /* AlwaysStrict */) { contravariant = !contravariant; inferFromTypes(source, target); contravariant = !contravariant; @@ -62676,7 +64901,7 @@ var ts; else { for (var i = 0; i < sources.length; i++) { var saveInferencePriority = inferencePriority; - inferencePriority = 1024 /* MaxValue */; + inferencePriority = 2048 /* MaxValue */; inferFromTypes(sources[i], t); if (inferencePriority === priority) matched_1[i] = true; @@ -62755,9 +64980,9 @@ 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) & 2097152 /* NonInferrableType */ ? - 8 /* PartialHomomorphicMappedType */ : - 4 /* HomomorphicMappedType */); + inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 524288 /* NonInferrableType */ ? + 16 /* PartialHomomorphicMappedType */ : + 8 /* HomomorphicMappedType */); } } return true; @@ -62765,7 +64990,7 @@ var ts; if (constraintType.flags & 262144 /* 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, 16 /* MappedTypeConstraint */); + inferWithPriority(getIndexType(source), constraintType, 32 /* 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 @@ -62794,16 +65019,14 @@ var ts; } else { var savePriority = priority; - priority |= contravariant ? 32 /* ContravariantConditional */ : 0; + priority |= contravariant ? 64 /* ContravariantConditional */ : 0; var targetTypes = [getTrueTypeFromConditionalType(target), getFalseTypeFromConditionalType(target)]; inferToMultipleTypes(source, targetTypes, target.flags); priority = savePriority; } } function inferToTemplateLiteralType(source, target) { - var matches = source.flags & 128 /* StringLiteral */ ? inferLiteralsFromTemplateLiteralType(source, target) : - source.flags & 134217728 /* TemplateLiteral */ && ts.arraysEqual(source.texts, target.texts) ? source.types : - undefined; + var matches = inferTypesFromTemplateLiteralType(source, target); var types = target.types; for (var i = 0; i < types.length; i++) { inferFromTypes(matches ? matches[i] : neverType, types[i]); @@ -62919,7 +65142,7 @@ var ts; var sourceLen = sourceSignatures.length; var targetLen = targetSignatures.length; var len = sourceLen < targetLen ? sourceLen : targetLen; - var skipParameters = !!(ts.getObjectFlags(source) & 2097152 /* NonInferrableType */); + var skipParameters = !!(ts.getObjectFlags(source) & 524288 /* NonInferrableType */); for (var i = 0; i < len; i++) { inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i]), skipParameters); } @@ -62929,19 +65152,21 @@ var ts; 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 === 165 /* MethodDeclaration */ || kind === 164 /* MethodSignature */ || kind === 166 /* Constructor */; + bivariant = bivariant || kind === 167 /* MethodDeclaration */ || kind === 166 /* MethodSignature */ || kind === 168 /* Constructor */; applyToParameterTypes(source, target, inferFromContravariantTypes); 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 targetStringIndexType = getIndexTypeOfType(target, 0 /* String */); if (targetStringIndexType) { var sourceIndexType = getIndexTypeOfType(source, 0 /* String */) || getImplicitIndexTypeOfType(source, 0 /* String */); if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetStringIndexType); + inferWithPriority(sourceIndexType, targetStringIndexType, priority); } } var targetNumberIndexType = getIndexTypeOfType(target, 1 /* Number */); @@ -62950,13 +65175,13 @@ var ts; getIndexTypeOfType(source, 0 /* String */) || getImplicitIndexTypeOfType(source, 1 /* Number */); if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetNumberIndexType); + inferWithPriority(sourceIndexType, targetNumberIndexType, priority); } } } } function isTypeOrBaseIdenticalTo(s, t) { - return isTypeIdenticalTo(s, t) || !!(t.flags & 4 /* String */ && s.flags & 134217856 /* StringLikeLiteral */ || t.flags & 8 /* Number */ && s.flags & 256 /* NumberLiteral */); + return isTypeIdenticalTo(s, t) || !!(t.flags & 4 /* String */ && s.flags & 128 /* StringLiteral */ || t.flags & 8 /* Number */ && s.flags & 256 /* NumberLiteral */); } function isTypeCloselyMatchedBy(s, t) { return !!(s.flags & 524288 /* Object */ && t.flags & 524288 /* Object */ && s.symbol && s.symbol === t.symbol || @@ -62970,7 +65195,7 @@ var ts; return !!(ts.getObjectFlags(type) & 128 /* ObjectLiteral */); } function isObjectOrArrayLiteralType(type) { - return !!(ts.getObjectFlags(type) & (128 /* ObjectLiteral */ | 65536 /* ArrayLiteral */)); + return !!(ts.getObjectFlags(type) & (128 /* ObjectLiteral */ | 32768 /* ArrayLiteral */)); } function unionObjectAndArrayLiteralCandidates(candidates) { if (candidates.length > 1) { @@ -62983,7 +65208,7 @@ var ts; return candidates; } function getContravariantInference(inference) { - return inference.priority & 208 /* PriorityImpliesCombination */ ? getIntersectionType(inference.contraCandidates) : getCommonSubtype(inference.contraCandidates); + return inference.priority & 416 /* 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. @@ -63000,7 +65225,7 @@ 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 & 208 /* PriorityImpliesCombination */ ? + var unwidenedType = inference.priority & 416 /* PriorityImpliesCombination */ ? getUnionType(baseCandidates, 2 /* Subtype */) : getCommonSupertype(baseCandidates); return getWidenedType(unwidenedType); @@ -63109,7 +65334,7 @@ var ts; case "BigUint64Array": return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_1_or_later; default: - if (node.parent.kind === 289 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 291 /* ShorthandPropertyAssignment */) { return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer; } else { @@ -63130,26 +65355,27 @@ 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 === 176 /* TypeQuery */ ? true : n.kind === 78 /* Identifier */ || n.kind === 157 /* QualifiedName */ ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 178 /* TypeQuery */ ? true : n.kind === 79 /* Identifier */ || n.kind === 159 /* 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 // leftmost identifier followed by zero or more property names separated by dots. - // The result is undefined if the reference isn't a dotted name. We prefix nodes - // occurring in an apparent type position with '@' because the control flow type - // of such nodes may be based on the apparent type instead of the declared type. + // The result is undefined if the reference isn't a dotted name. function getFlowCacheKey(node, declaredType, initialType, flowContainer) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: var symbol = getResolvedSymbol(node); - return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + (isConstraintPosition(node) ? "@" : "") + getSymbolId(symbol) : undefined; - case 107 /* ThisKeyword */: + return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + getSymbolId(symbol) : undefined; + case 108 /* ThisKeyword */: return "0|" + (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType); - case 225 /* NonNullExpression */: - case 207 /* ParenthesizedExpression */: + case 227 /* NonNullExpression */: + case 209 /* ParenthesizedExpression */: return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 159 /* QualifiedName */: + var left = getFlowCacheKey(node.left, declaredType, initialType, flowContainer); + return left && left + "." + node.right.escapedText; + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: var propName = getAccessedPropertyName(node); if (propName !== undefined) { var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); @@ -63160,32 +65386,40 @@ var ts; } function isMatchingReference(source, target) { switch (target.kind) { - case 207 /* ParenthesizedExpression */: - case 225 /* NonNullExpression */: + case 209 /* ParenthesizedExpression */: + case 227 /* NonNullExpression */: return isMatchingReference(source, target.expression); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return (ts.isAssignmentExpression(target) && isMatchingReference(source, target.left)) || (ts.isBinaryExpression(target) && target.operatorToken.kind === 27 /* CommaToken */ && isMatchingReference(source, target.right)); } switch (source.kind) { - case 78 /* Identifier */: - case 79 /* PrivateIdentifier */: - return target.kind === 78 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 249 /* VariableDeclaration */ || target.kind === 198 /* BindingElement */) && + case 228 /* MetaProperty */: + return target.kind === 228 /* MetaProperty */ + && source.keywordToken === target.keywordToken + && source.name.escapedText === target.name.escapedText; + case 79 /* Identifier */: + case 80 /* PrivateIdentifier */: + return target.kind === 79 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 251 /* VariableDeclaration */ || target.kind === 200 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 107 /* ThisKeyword */: - return target.kind === 107 /* ThisKeyword */; - case 105 /* SuperKeyword */: - return target.kind === 105 /* SuperKeyword */; - case 225 /* NonNullExpression */: - case 207 /* ParenthesizedExpression */: + case 108 /* ThisKeyword */: + return target.kind === 108 /* ThisKeyword */; + case 106 /* SuperKeyword */: + return target.kind === 106 /* SuperKeyword */; + case 227 /* NonNullExpression */: + case 209 /* ParenthesizedExpression */: return isMatchingReference(source.expression, target); - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: return ts.isAccessExpression(target) && getAccessedPropertyName(source) === getAccessedPropertyName(target) && isMatchingReference(source.expression, target.expression); - case 216 /* BinaryExpression */: + case 159 /* QualifiedName */: + return ts.isAccessExpression(target) && + source.right.escapedText === getAccessedPropertyName(target) && + isMatchingReference(source.left, target.expression); + case 218 /* BinaryExpression */: return (ts.isBinaryExpression(source) && source.operatorToken.kind === 27 /* CommaToken */ && isMatchingReference(source.right, target)); } return false; @@ -63193,11 +65427,11 @@ var ts; // Given a source x, check if target matches x or is an && operation with an operand that matches x. function containsTruthyCheck(source, target) { return isMatchingReference(source, target) || - (target.kind === 216 /* BinaryExpression */ && target.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && + (target.kind === 218 /* BinaryExpression */ && target.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && (containsTruthyCheck(source, target.left) || containsTruthyCheck(source, target.right))); } function getAccessedPropertyName(access) { - return access.kind === 201 /* PropertyAccessExpression */ ? access.name.escapedText : + return access.kind === 203 /* PropertyAccessExpression */ ? access.name.escapedText : ts.isStringOrNumericLiteralLike(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) : undefined; } @@ -63247,6 +65481,86 @@ var ts; } return result; } + // Given a set of constituent types and a property name, create and return a map keyed by the literal + // types of the property by that name in each constituent type. No map is returned if some key property + // has a non-literal type or if less than 10 or less than 50% of the constituents have a unique key. + // Entries with duplicate keys have unknownType as the value. + function mapTypesByKeyProperty(types, name) { + var map = new ts.Map(); + var count = 0; + var _loop_20 = function (type) { + if (type.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) { + var discriminant = getTypeOfPropertyOfType(type, name); + if (discriminant) { + if (!isLiteralType(discriminant)) { + return { value: undefined }; + } + var duplicate_1 = false; + forEachType(discriminant, function (t) { + var id = getTypeId(getRegularTypeOfLiteralType(t)); + var existing = map.get(id); + if (!existing) { + map.set(id, type); + } + else if (existing !== unknownType) { + map.set(id, unknownType); + duplicate_1 = true; + } + }); + if (!duplicate_1) + count++; + } + } + }; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var type = types_17[_i]; + var state_8 = _loop_20(type); + if (typeof state_8 === "object") + return state_8.value; + } + return count >= 10 && count * 2 >= types.length ? map : undefined; + } + // Return the name of a discriminant property for which it was possible and feasible to construct a map of + // constituent types keyed by the literal types of the property by that name in each constituent type. + function getKeyPropertyName(unionType) { + var types = unionType.types; + // We only construct maps for large unions with non-primitive constituents. + if (types.length < 10 || ts.getObjectFlags(unionType) & 65536 /* PrimitiveUnion */) { + 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 */) ? + ts.forEach(getPropertiesOfType(t), function (p) { return isUnitType(getTypeOfSymbol(p)) ? p.escapedName : undefined; }) : + undefined; + }); + var mapByKeyProperty = keyPropertyName && mapTypesByKeyProperty(types, keyPropertyName); + unionType.keyPropertyName = mapByKeyProperty ? keyPropertyName : ""; + unionType.constituentMap = mapByKeyProperty; + } + return unionType.keyPropertyName.length ? unionType.keyPropertyName : undefined; + } + // Given a union type for which getKeyPropertyName returned a non-undefined result, return the constituent + // that corresponds to the given key type for that property name. + function getConstituentTypeForKeyType(unionType, keyType) { + var _a; + var result = (_a = unionType.constituentMap) === null || _a === void 0 ? void 0 : _a.get(getTypeId(getRegularTypeOfLiteralType(keyType))); + return result !== unknownType ? result : undefined; + } + function getMatchingUnionConstituentForType(unionType, type) { + var keyPropertyName = getKeyPropertyName(unionType); + var propType = keyPropertyName && getTypeOfPropertyOfType(type, keyPropertyName); + return propType && getConstituentTypeForKeyType(unionType, propType); + } + function getMatchingUnionConstituentForObjectLiteral(unionType, node) { + var keyPropertyName = getKeyPropertyName(unionType); + var propNode = keyPropertyName && ts.find(node.properties, function (p) { return p.symbol && p.kind === 290 /* PropertyAssignment */ && + p.symbol.escapedName === keyPropertyName && isPossiblyDiscriminantValue(p.initializer); }); + var propType = propNode && getTypeOfExpression(propNode.initializer); + return propType && getConstituentTypeForKeyType(unionType, propType); + } function isOrContainsMatchingReference(source, target) { return isMatchingReference(source, target) || containsMatchingReference(source, target); } @@ -63259,7 +65573,7 @@ var ts; } } } - if (expression.expression.kind === 201 /* PropertyAccessExpression */ && + if (expression.expression.kind === 203 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, expression.expression.expression)) { return true; } @@ -63306,14 +65620,6 @@ var ts; } return declaredType; } - function getTypeFactsOfTypes(types) { - var result = 0 /* None */; - for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { - var t = types_17[_i]; - result |= getTypeFacts(t); - } - return result; - } function isFunctionObjectType(type) { // We do a quick check for a "bind" property before performing the more expensive subtype // check. This gives us a quicker out in the common case where an object type is not a function. @@ -63321,7 +65627,8 @@ var ts; return !!(resolved.callSignatures.length || resolved.constructSignatures.length || resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType)); } - function getTypeFacts(type) { + function getTypeFacts(type, ignoreObjects) { + if (ignoreObjects === void 0) { ignoreObjects = false; } var flags = type.flags; if (flags & 4 /* String */) { return strictNullChecks ? 16317953 /* StringStrictFacts */ : 16776705 /* StringFacts */; @@ -63358,7 +65665,7 @@ var ts; (type === falseType || type === regularFalseType) ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ : (type === falseType || type === regularFalseType) ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */; } - if (flags & 524288 /* Object */) { + if (flags & 524288 /* Object */ && !ignoreObjects) { return ts.getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type) ? strictNullChecks ? 16318463 /* EmptyObjectStrictFacts */ : 16777215 /* EmptyObjectFacts */ : isFunctionObjectType(type) ? @@ -63381,11 +65688,17 @@ var ts; return 0 /* None */; } if (flags & 465829888 /* Instantiable */) { - return !isPatternLiteralType(type) ? getTypeFacts(getBaseConstraintOfType(type) || unknownType) : + return !isPatternLiteralType(type) ? getTypeFacts(getBaseConstraintOfType(type) || unknownType, ignoreObjects) : strictNullChecks ? 7929345 /* NonEmptyStringStrictFacts */ : 16776705 /* NonEmptyStringFacts */; } - if (flags & 3145728 /* UnionOrIntersection */) { - return getTypeFactsOfTypes(type.types); + if (flags & 1048576 /* Union */) { + return ts.reduceLeft(type.types, function (facts, t) { return facts | getTypeFacts(t, ignoreObjects); }, 0 /* None */); + } + if (flags & 2097152 /* Intersection */) { + // 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. + ignoreObjects || (ignoreObjects = maybeTypeOfKind(type, 131068 /* Primitive */)); + return ts.reduceLeft(type.types, function (facts, t) { return facts & getTypeFacts(t, ignoreObjects); }, 16777215 /* All */); } return 16777215 /* All */; } @@ -63393,18 +65706,16 @@ var ts; return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; }); } function getTypeWithDefault(type, defaultExpression) { - if (defaultExpression) { - var defaultType = getTypeOfExpression(defaultExpression); - return getUnionType([getTypeWithFacts(type, 524288 /* NEUndefined */), defaultType]); - } - return type; + return defaultExpression ? + getUnionType([getNonUndefinedType(type), getTypeOfExpression(defaultExpression)]) : + type; } function getTypeOfDestructuredProperty(type, name) { var nameType = getLiteralTypeFromPropertyName(name); if (!isTypeUsableAsPropertyName(nameType)) return errorType; var text = getPropertyNameFromType(nameType); - return getConstraintForLocation(getTypeOfPropertyOfType(type, text), name) || + return getTypeOfPropertyOfType(type, text) || isNumericLiteralName(text) && includeUndefinedInIndexSignature(getIndexTypeOfType(type, 1 /* Number */)) || includeUndefinedInIndexSignature(getIndexTypeOfType(type, 0 /* String */)) || errorType; @@ -63425,15 +65736,15 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 199 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 288 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 201 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 290 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 216 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 239 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 218 /* BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 241 /* ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -63450,21 +65761,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return stringType; - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: return checkRightHandSideOfForOf(parent) || errorType; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 210 /* DeleteExpression */: + case 212 /* DeleteExpression */: return undefinedType; - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 220 /* SpreadElement */: + case 222 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -63472,7 +65783,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 196 /* ObjectBindingPattern */ ? + var type = pattern.kind === 198 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -63490,35 +65801,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 238 /* ForInStatement */) { + if (node.parent.parent.kind === 240 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 239 /* ForOfStatement */) { + if (node.parent.parent.kind === 241 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 249 /* VariableDeclaration */ ? + return node.kind === 251 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function isEmptyArrayAssignment(node) { - return node.kind === 249 /* VariableDeclaration */ && node.initializer && + return node.kind === 251 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 198 /* BindingElement */ && node.parent.kind === 216 /* BinaryExpression */ && + node.kind !== 200 /* BindingElement */ && node.parent.kind === 218 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 62 /* EqualsToken */: - case 74 /* BarBarEqualsToken */: - case 75 /* AmpersandAmpersandEqualsToken */: - case 76 /* QuestionQuestionEqualsToken */: + case 63 /* EqualsToken */: + case 75 /* BarBarEqualsToken */: + case 76 /* AmpersandAmpersandEqualsToken */: + case 77 /* QuestionQuestionEqualsToken */: return getReferenceCandidate(node.left); case 27 /* CommaToken */: return getReferenceCandidate(node.right); @@ -63528,13 +65839,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 207 /* ParenthesizedExpression */ || - parent.kind === 216 /* BinaryExpression */ && parent.operatorToken.kind === 62 /* EqualsToken */ && parent.left === node || - parent.kind === 216 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? + return parent.kind === 209 /* ParenthesizedExpression */ || + parent.kind === 218 /* BinaryExpression */ && parent.operatorToken.kind === 63 /* EqualsToken */ && parent.left === node || + parent.kind === 218 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 284 /* CaseClause */) { + if (clause.kind === 286 /* CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -63554,7 +65865,7 @@ var ts; var witnesses = []; for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) { var clause = _a[_i]; - if (clause.kind === 284 /* CaseClause */) { + if (clause.kind === 286 /* CaseClause */) { if (ts.isStringLiteralLike(clause.expression)) { witnesses.push(clause.expression.text); continue; @@ -63590,14 +65901,40 @@ var ts; function forEachType(type, f) { return type.flags & 1048576 /* Union */ ? ts.forEach(type.types, f) : f(type); } + function someType(type, f) { + return type.flags & 1048576 /* Union */ ? ts.some(type.types, f) : f(type); + } function everyType(type, f) { return type.flags & 1048576 /* Union */ ? ts.every(type.types, f) : f(type); } + function everyContainedType(type, f) { + return type.flags & 3145728 /* UnionOrIntersection */ ? ts.every(type.types, f) : f(type); + } function filterType(type, f) { if (type.flags & 1048576 /* Union */) { var types = type.types; var filtered = ts.filter(types, f); - return filtered === types ? type : getUnionTypeFromSortedList(filtered, type.objectFlags); + if (filtered === types) { + return type; + } + var origin = type.origin; + var newOrigin = void 0; + if (origin && origin.flags & 1048576 /* 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); }); + if (originTypes.length - originFiltered.length === types.length - filtered.length) { + if (originFiltered.length === 1) { + return originFiltered[0]; + } + newOrigin = createOriginUnionOrIntersectionType(1048576 /* Union */, originFiltered); + } + } + return getUnionTypeFromSortedList(filtered, type.objectFlags, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, newOrigin); } return type.flags & 131072 /* Never */ || f(type) ? type : neverType; } @@ -63630,6 +65967,11 @@ var ts; } return changed ? mappedTypes && getUnionType(mappedTypes, noReductions ? 0 /* None */ : 1 /* Literal */) : type; } + function mapTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments) { + return type.flags & 1048576 /* Union */ && aliasSymbol ? + getUnionType(ts.map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments) : + mapType(type, mapper); + } function getConstituentCount(type) { return type.flags & 3145728 /* UnionOrIntersection */ ? type.types.length : 1; } @@ -63715,21 +66057,21 @@ var ts; var root = getReferenceRoot(node); var parent = root.parent; var isLengthPushOrUnshift = ts.isPropertyAccessExpression(parent) && (parent.name.escapedText === "length" || - parent.parent.kind === 203 /* CallExpression */ + parent.parent.kind === 205 /* CallExpression */ && ts.isIdentifier(parent.name) && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 202 /* ElementAccessExpression */ && + var isElementAssignment = parent.kind === 204 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 216 /* BinaryExpression */ && - parent.parent.operatorToken.kind === 62 /* EqualsToken */ && + parent.parent.kind === 218 /* BinaryExpression */ && + parent.parent.operatorToken.kind === 63 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* NumberLike */); return isLengthPushOrUnshift || isElementAssignment; } function isDeclarationWithExplicitTypeAnnotation(declaration) { - return (declaration.kind === 249 /* VariableDeclaration */ || declaration.kind === 160 /* Parameter */ || - declaration.kind === 163 /* PropertyDeclaration */ || declaration.kind === 162 /* PropertySignature */) && + return (declaration.kind === 251 /* VariableDeclaration */ || declaration.kind === 162 /* Parameter */ || + declaration.kind === 165 /* PropertyDeclaration */ || declaration.kind === 164 /* PropertySignature */) && !!ts.getEffectiveTypeAnnotationNode(declaration); } function getExplicitTypeOfSymbol(symbol, diagnostic) { @@ -63748,7 +66090,7 @@ var ts; if (isDeclarationWithExplicitTypeAnnotation(declaration)) { return getTypeOfSymbol(symbol); } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 239 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 241 /* ForOfStatement */) { var statement = declaration.parent.parent; var expressionType = getTypeOfDottedName(statement.expression, /*diagnostic*/ undefined); if (expressionType) { @@ -63769,18 +66111,32 @@ var ts; function getTypeOfDottedName(node, diagnostic) { if (!(node.flags & 16777216 /* InWithStatement */)) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node)); return getExplicitTypeOfSymbol(symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol, diagnostic); - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: return getExplicitThisType(node); - case 105 /* SuperKeyword */: + case 106 /* SuperKeyword */: return checkSuperExpression(node); - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: { var type = getTypeOfDottedName(node.expression, diagnostic); - var prop = type && getPropertyOfType(type, node.name.escapedText); - return prop && getExplicitTypeOfSymbol(prop, diagnostic); - case 207 /* ParenthesizedExpression */: + if (type) { + var name = node.name; + var prop = void 0; + if (ts.isPrivateIdentifier(name)) { + if (!type.symbol) { + return undefined; + } + prop = getPropertyOfType(type, ts.getSymbolNameForPrivateIdentifier(type.symbol, name.escapedText)); + } + else { + prop = getPropertyOfType(type, name.escapedText); + } + return prop && getExplicitTypeOfSymbol(prop, diagnostic); + } + return undefined; + } + case 209 /* ParenthesizedExpression */: return getTypeOfDottedName(node.expression, diagnostic); } } @@ -63794,10 +66150,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 === 233 /* ExpressionStatement */) { + if (node.parent.kind === 235 /* ExpressionStatement */) { funcType = getTypeOfDottedName(node.expression, /*diagnostic*/ undefined); } - else if (node.expression.kind !== 105 /* SuperKeyword */) { + else if (node.expression.kind !== 106 /* SuperKeyword */) { if (ts.isOptionalChain(node)) { funcType = checkNonNullType(getOptionalExpressionType(checkExpression(node.expression), node.expression), node.expression); } @@ -63838,7 +66194,7 @@ var ts; } function isFalseExpression(expr) { var node = ts.skipParentheses(expr); - return node.kind === 94 /* FalseKeyword */ || node.kind === 216 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && (isFalseExpression(node.left) || isFalseExpression(node.right)) || + return node.kind === 95 /* FalseKeyword */ || node.kind === 218 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && (isFalseExpression(node.left) || isFalseExpression(node.right)) || node.operatorToken.kind === 56 /* BarBarToken */ && isFalseExpression(node.left) && isFalseExpression(node.right)); } function isReachableFlowNodeWorker(flow, noCacheCheck) { @@ -63926,7 +66282,7 @@ var ts; flow = flow.antecedent; } else if (flags & 512 /* Call */) { - if (flow.node.expression.kind === 105 /* SuperKeyword */) { + if (flow.node.expression.kind === 106 /* SuperKeyword */) { return true; } flow = flow.antecedent; @@ -63973,7 +66329,7 @@ var ts; // 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 === 225 /* NonNullExpression */ && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { + if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 227 /* NonNullExpression */ && !(resultType.flags & 131072 /* Never */) && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { return declaredType; } return resultType; @@ -63988,7 +66344,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.instant("checkTypes" /* CheckTypes */, "getTypeAtFlowNode_DepthLimit", { flowId: flow.id }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "getTypeAtFlowNode_DepthLimit", { flowId: flow.id }); flowAnalysisDisabled = true; reportFlowControlError(reference); return errorType; @@ -64057,9 +66413,9 @@ var ts; // Check if we should continue with the control flow of the containing function. var container = flow.node; if (container && container !== flowContainer && - reference.kind !== 201 /* PropertyAccessExpression */ && - reference.kind !== 202 /* ElementAccessExpression */ && - reference.kind !== 107 /* ThisKeyword */) { + reference.kind !== 203 /* PropertyAccessExpression */ && + reference.kind !== 204 /* ElementAccessExpression */ && + reference.kind !== 108 /* ThisKeyword */) { flow = container.flowNode; continue; } @@ -64083,7 +66439,7 @@ var ts; } function getInitialOrAssignedType(flow) { var node = flow.node; - return getConstraintForLocation(node.kind === 249 /* VariableDeclaration */ || node.kind === 198 /* BindingElement */ ? + return getNarrowableTypeForReference(node.kind === 251 /* VariableDeclaration */ || node.kind === 200 /* BindingElement */ ? getInitialType(node) : getAssignedType(node), reference); } @@ -64123,14 +66479,14 @@ 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 === 208 /* FunctionExpression */ || init.kind === 209 /* ArrowFunction */)) { + if (init && (init.kind === 210 /* FunctionExpression */ || init.kind === 211 /* 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 === 238 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { + if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 240 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); } // Assignment doesn't affect reference @@ -64138,10 +66494,10 @@ var ts; } function narrowTypeByAssertion(type, expr) { var node = ts.skipParentheses(expr); - if (node.kind === 94 /* FalseKeyword */) { + if (node.kind === 95 /* FalseKeyword */) { return unreachableNeverType; } - if (node.kind === 216 /* BinaryExpression */) { + if (node.kind === 218 /* BinaryExpression */) { if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { return narrowTypeByAssertion(narrowTypeByAssertion(type, node.left), node.right); } @@ -64172,7 +66528,7 @@ var ts; function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 203 /* CallExpression */ ? + var expr = node.kind === 205 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -64180,7 +66536,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 203 /* CallExpression */) { + if (node.kind === 205 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -64228,7 +66584,7 @@ var ts; if (isMatchingReference(reference, expr)) { type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } - else if (expr.kind === 211 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { + else if (expr.kind === 213 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } else { @@ -64236,12 +66592,12 @@ var ts; if (optionalChainContainsReference(expr, reference)) { type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & (32768 /* Undefined */ | 131072 /* Never */)); }); } - else if (expr.kind === 211 /* TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) { + else if (expr.kind === 213 /* 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"); }); } } if (isMatchingReferenceDiscriminant(expr, type)) { - type = narrowTypeByDiscriminant(type, expr, function (t) { return narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd); }); + type = narrowTypeBySwitchOnDiscriminantProperty(type, expr, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } } return createFlowType(type, isIncomplete(flowType)); @@ -64412,16 +66768,42 @@ var ts; if (propName === undefined) { return type; } - var propType = getTypeOfPropertyOfType(type, propName); + var removeNullable = strictNullChecks && ts.isOptionalChain(access) && maybeTypeOfKind(type, 98304 /* Nullable */); + var propType = getTypeOfPropertyOfType(removeNullable ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type, propName); if (!propType) { return type; } + propType = removeNullable ? getOptionalType(propType) : propType; var narrowedPropType = narrowType(propType); return filterType(type, function (t) { var discriminantType = getTypeOfPropertyOrIndexSignature(t, propName); return !(discriminantType.flags & 131072 /* Never */) && isTypeComparableTo(discriminantType, narrowedPropType); }); } + function narrowTypeByDiscriminantProperty(type, access, operator, value, assumeTrue) { + if ((operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) && type.flags & 1048576 /* Union */) { + var keyPropertyName = getKeyPropertyName(type); + if (keyPropertyName && keyPropertyName === getAccessedPropertyName(access)) { + var candidate_2 = getConstituentTypeForKeyType(type, getTypeOfExpression(value)); + if (candidate_2) { + return operator === (assumeTrue ? 36 /* EqualsEqualsEqualsToken */ : 37 /* ExclamationEqualsEqualsToken */) ? candidate_2 : + isUnitType(getTypeOfPropertyOfType(candidate_2, keyPropertyName) || unknownType) ? filterType(type, function (t) { return t !== candidate_2; }) : + type; + } + } + } + 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)) { + var clauseTypes = getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd); + var candidate = getUnionType(ts.map(clauseTypes, function (t) { return getConstituentTypeForKeyType(type, t) || unknownType; })); + if (candidate !== unknownType) { + return candidate; + } + } + return narrowTypeByDiscriminant(type, access, function (t) { return narrowTypeBySwitchOnDiscriminant(t, switchStatement, clauseStart, clauseEnd); }); + } function narrowTypeByTruthiness(type, expr, assumeTrue) { if (isMatchingReference(reference, expr)) { return getTypeWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); @@ -64445,7 +66827,8 @@ var ts; return !assumeTrue; } function narrowByInKeyword(type, literal, assumeTrue) { - if (type.flags & (1048576 /* Union */ | 524288 /* Object */) + if (type.flags & 1048576 /* Union */ + || type.flags & 524288 /* Object */ && declaredType !== type || isThisTypeParameter(type) || type.flags & 2097152 /* Intersection */ && ts.every(type.types, function (t) { return t.symbol !== globalThisSymbol; })) { var propName_1 = ts.escapeLeadingUnderscores(literal.text); @@ -64455,57 +66838,63 @@ var ts; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 62 /* EqualsToken */: - case 74 /* BarBarEqualsToken */: - case 75 /* AmpersandAmpersandEqualsToken */: - case 76 /* QuestionQuestionEqualsToken */: + case 63 /* EqualsToken */: + case 75 /* BarBarEqualsToken */: + case 76 /* AmpersandAmpersandEqualsToken */: + case 77 /* QuestionQuestionEqualsToken */: return narrowTypeByTruthiness(narrowType(type, expr.right, assumeTrue), expr.left, assumeTrue); case 34 /* EqualsEqualsToken */: case 35 /* ExclamationEqualsToken */: case 36 /* EqualsEqualsEqualsToken */: case 37 /* ExclamationEqualsEqualsToken */: - var operator_1 = expr.operatorToken.kind; - var left_1 = getReferenceCandidate(expr.left); - var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 211 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { - return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); + var operator = expr.operatorToken.kind; + var left = getReferenceCandidate(expr.left); + var right = getReferenceCandidate(expr.right); + if (left.kind === 213 /* TypeOfExpression */ && ts.isStringLiteralLike(right)) { + return narrowTypeByTypeof(type, left, operator, right, assumeTrue); } - if (right_1.kind === 211 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { - return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); + if (right.kind === 213 /* TypeOfExpression */ && ts.isStringLiteralLike(left)) { + return narrowTypeByTypeof(type, right, operator, left, assumeTrue); } - if (isMatchingReference(reference, left_1)) { - return narrowTypeByEquality(type, operator_1, right_1, assumeTrue); + if (isMatchingReference(reference, left)) { + return narrowTypeByEquality(type, operator, right, assumeTrue); } - if (isMatchingReference(reference, right_1)) { - return narrowTypeByEquality(type, operator_1, left_1, assumeTrue); + if (isMatchingReference(reference, right)) { + return narrowTypeByEquality(type, operator, left, assumeTrue); } if (strictNullChecks) { - if (optionalChainContainsReference(left_1, reference)) { - type = narrowTypeByOptionalChainContainment(type, operator_1, right_1, assumeTrue); + if (optionalChainContainsReference(left, reference)) { + type = narrowTypeByOptionalChainContainment(type, operator, right, assumeTrue); } - else if (optionalChainContainsReference(right_1, reference)) { - type = narrowTypeByOptionalChainContainment(type, operator_1, left_1, assumeTrue); + else if (optionalChainContainsReference(right, reference)) { + type = narrowTypeByOptionalChainContainment(type, operator, left, assumeTrue); } } - if (isMatchingReferenceDiscriminant(left_1, type)) { - return narrowTypeByDiscriminant(type, left_1, function (t) { return narrowTypeByEquality(t, operator_1, right_1, assumeTrue); }); + if (isMatchingReferenceDiscriminant(left, type)) { + return narrowTypeByDiscriminantProperty(type, left, operator, right, assumeTrue); } - if (isMatchingReferenceDiscriminant(right_1, type)) { - return narrowTypeByDiscriminant(type, right_1, function (t) { return narrowTypeByEquality(t, operator_1, left_1, assumeTrue); }); + if (isMatchingReferenceDiscriminant(right, type)) { + return narrowTypeByDiscriminantProperty(type, right, operator, left, assumeTrue); } - if (isMatchingConstructorReference(left_1)) { - return narrowTypeByConstructor(type, operator_1, right_1, assumeTrue); + if (isMatchingConstructorReference(left)) { + return narrowTypeByConstructor(type, operator, right, assumeTrue); } - if (isMatchingConstructorReference(right_1)) { - return narrowTypeByConstructor(type, operator_1, left_1, assumeTrue); + if (isMatchingConstructorReference(right)) { + return narrowTypeByConstructor(type, operator, left, assumeTrue); } break; - case 101 /* InstanceOfKeyword */: + case 102 /* InstanceOfKeyword */: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 100 /* InKeyword */: + case 101 /* InKeyword */: var target = getReferenceCandidate(expr.right); - if (ts.isStringLiteralLike(expr.left) && isMatchingReference(reference, target)) { - return narrowByInKeyword(type, expr.left, assumeTrue); + if (ts.isStringLiteralLike(expr.left)) { + if (containsMissingType(type) && ts.isAccessExpression(reference) && isMatchingReference(reference.expression, target) && + getAccessedPropertyName(reference) === ts.escapeLeadingUnderscores(expr.left.text)) { + return getTypeWithFacts(type, assumeTrue ? 524288 /* NEUndefined */ : 65536 /* EQUndefined */); + } + if (isMatchingReference(reference, target)) { + return narrowByInKeyword(type, expr.left, assumeTrue); + } } break; case 27 /* CommaToken */: @@ -64562,13 +66951,12 @@ var ts; } if (assumeTrue) { var filterFn = operator === 34 /* EqualsEqualsToken */ ? - (function (t) { return areTypesComparable(t, valueType) || isCoercibleUnderDoubleEquals(t, valueType); }) : + function (t) { return areTypesComparable(t, valueType) || isCoercibleUnderDoubleEquals(t, valueType); } : function (t) { return areTypesComparable(t, valueType); }; return replacePrimitivesWithLiterals(filterType(type, filterFn), valueType); } if (isUnitType(valueType)) { - var regularType_1 = getRegularTypeOfLiteralType(valueType); - return filterType(type, function (t) { return isUnitType(t) ? !areTypesComparable(t, valueType) : getRegularTypeOfLiteralType(t) !== regularType_1; }); + return filterType(type, function (t) { return !(isUnitLikeType(t) && areTypesComparable(t, valueType)); }); } return type; } @@ -64590,7 +66978,7 @@ var ts; if (assumeTrue && type.flags & 2 /* Unknown */ && literal.text === "object") { // The pattern x && typeof x === 'object', where x is of type unknown, narrows x to type object. We don't // need to check for the reverse typeof x === 'object' && x since that already narrows correctly. - if (typeOfExpr.parent.parent.kind === 216 /* BinaryExpression */) { + if (typeOfExpr.parent.parent.kind === 218 /* BinaryExpression */) { var expr = typeOfExpr.parent.parent; if (expr.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && expr.right === typeOfExpr.parent && containsTruthyCheck(reference, expr.left)) { return nonPrimitiveType; @@ -64646,7 +67034,7 @@ var ts; if (!hasDefaultClause) { return caseType; } - var defaultType = filterType(type, function (t) { return !(isUnitType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(t))); }); + var defaultType = filterType(type, function (t) { return !(isUnitLikeType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(extractUnitType(t)))); }); return caseType.flags & 131072 /* Never */ ? defaultType : getUnionType([caseType, defaultType]); } function getImpliedTypeFromTypeofGuard(type, text) { @@ -64828,7 +67216,16 @@ var ts; } function getNarrowedType(type, candidate, assumeTrue, isRelated) { if (!assumeTrue) { - return filterType(type, function (t) { return !isRelated(t, candidate); }); + return filterType(type, function (t) { + if (!isRelated(t, candidate)) { + return true; + } + var constraint = getBaseConstraintOfType(t); + if (constraint && constraint !== t) { + return !isRelated(constraint, candidate); + } + return false; + }); } // 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. @@ -64838,10 +67235,15 @@ var ts; return assignableType; } } - // If the candidate type is a subtype of the target type, narrow to the candidate type, - // if the target type is a subtype of the candidate type, narrow to the target type, - // otherwise, narrow to an intersection of the two types. - return isTypeSubtypeOf(candidate, type) ? candidate : isTypeSubtypeOf(type, candidate) ? type : getIntersectionType([type, 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]); } function narrowTypeByCallExpression(type, callExpression, assumeTrue) { if (hasMatchingArgument(callExpression, reference)) { @@ -64851,6 +67253,16 @@ var ts; return narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue); } } + if (containsMissingType(type) && ts.isAccessExpression(reference) && ts.isPropertyAccessExpression(callExpression.expression)) { + var callAccess = callExpression.expression; + if (isMatchingReference(reference.expression, getReferenceCandidate(callAccess.expression)) && + 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 type; } function narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue) { @@ -64881,20 +67293,20 @@ var ts; return narrowTypeByOptionality(type, expr, assumeTrue); } switch (expr.kind) { - case 78 /* Identifier */: - case 107 /* ThisKeyword */: - case 105 /* SuperKeyword */: - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 79 /* Identifier */: + case 108 /* ThisKeyword */: + case 106 /* SuperKeyword */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return narrowTypeByCallExpression(type, expr, assumeTrue); - case 207 /* ParenthesizedExpression */: - case 225 /* NonNullExpression */: + case 209 /* ParenthesizedExpression */: + case 227 /* NonNullExpression */: return narrowType(type, expr.expression, assumeTrue); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: if (expr.operator === 53 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } @@ -64918,34 +67330,40 @@ 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 === 78 /* Identifier */) { + if (location.kind === 79 /* Identifier */ || location.kind === 80 /* PrivateIdentifier */) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } - if (ts.isExpressionNode(location) && !ts.isAssignmentTarget(location)) { + if (ts.isExpressionNode(location) && (!ts.isAssignmentTarget(location) || ts.isWriteAccess(location))) { var type = getTypeOfExpression(location); if (getExportSymbolOfValueSymbolIfExported(getNodeLinks(location).resolvedSymbol) === symbol) { return type; } } } + if (ts.isDeclarationName(location) && ts.isSetAccessor(location.parent) && getAnnotatedAccessorTypeNode(location.parent)) { + return resolveTypeOfAccessors(location.parent.symbol, /*writing*/ true); + } // The location isn't a reference to the given symbol, meaning we're being asked // a hypothetical question of what type the symbol would have if there was a reference // to it at the given location. Since we have no control flow information for the // hypothetical reference (control flow information is created and attached by the // binder), we simply return the declared type of the symbol. - return getTypeOfSymbol(symbol); + return getNonMissingTypeOfSymbol(symbol); } function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 257 /* ModuleBlock */ || - node.kind === 297 /* SourceFile */ || - node.kind === 163 /* PropertyDeclaration */; + node.kind === 259 /* ModuleBlock */ || + node.kind === 299 /* SourceFile */ || + node.kind === 165 /* PropertyDeclaration */; }); } // Check if a parameter is assigned anywhere within its declaring function. function isParameterAssigned(symbol) { + if (!symbol.valueDeclaration) { + return false; + } var func = ts.getRootDeclaration(symbol.valueDeclaration).parent; var links = getNodeLinks(func); if (!(links.flags & 8388608 /* AssignmentsMarked */)) { @@ -64960,10 +67378,10 @@ var ts; return !!ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !!(getNodeLinks(node).flags & 8388608 /* AssignmentsMarked */); }); } function markParameterAssignments(node) { - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 160 /* Parameter */) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 162 /* Parameter */) { symbol.isAssigned = true; } } @@ -64979,7 +67397,7 @@ var ts; function removeOptionalityFromDeclaredType(declaredType, declaration) { if (pushTypeResolution(declaration.symbol, 2 /* DeclaredType */)) { var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 160 /* Parameter */ && + declaration.kind === 162 /* Parameter */ && declaration.initializer && getFalsyFlags(declaredType) & 32768 /* Undefined */ && !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* Undefined */); @@ -64993,23 +67411,40 @@ var ts; } function isConstraintPosition(node) { var parent = node.parent; - return parent.kind === 201 /* PropertyAccessExpression */ || - parent.kind === 203 /* CallExpression */ && parent.expression === node || - parent.kind === 202 /* ElementAccessExpression */ && parent.expression === node || - parent.kind === 198 /* BindingElement */ && parent.name === node && !!parent.initializer; - } - function typeHasNullableConstraint(type) { - return type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 98304 /* Nullable */); - } - function getConstraintForLocation(type, node) { - // When a node is the left hand expression of a property access, element access, or call expression, - // and the type of the node includes type variables with constraints that are nullable, we fetch the - // apparent type of the node *before* performing control flow analysis such that narrowings apply to - // the constraint type. - if (type && isConstraintPosition(node) && forEachType(type, typeHasNullableConstraint)) { - return mapType(getWidenedType(type), getBaseConstraintOrType); - } - return type; + // In an element access obj[x], we consider obj to be in a constraint position only when x is not + // of 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 === 203 /* PropertyAccessExpression */ || + parent.kind === 205 /* CallExpression */ && parent.expression === node || + parent.kind === 204 /* ElementAccessExpression */ && parent.expression === node && + !isGenericIndexType(getTypeOfExpression(parent.argumentExpression)); + } + function isGenericTypeWithUnionConstraint(type) { + return !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */)); + } + function containsGenericType(type) { + return !!(type.flags & 465829888 /* Instantiable */ || type.flags & 3145728 /* UnionOrIntersection */ && ts.some(type.types, containsGenericType)); + } + function hasNonBindingPatternContextualTypeWithNoGenericTypes(node) { + // Computing the contextual type for a child of a JSX element involves resolving the type of the + // element's tag name, so we exclude that here to avoid circularities. + var contextualType = (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) && + !((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && + getContextualType(node, 8 /* SkipBindingPatterns */); + return contextualType && !someType(contextualType, containsGenericType); + } + function getNarrowableTypeForReference(type, reference, checkMode) { + // When the type of a reference is or contains an instantiable type with a union type constraint, and + // when the reference is in a constraint position (where it is known we'll obtain the apparent type) or + // has a contextual type containing no top-level instantiables (meaning constraints will determine + // assignability), we substitute constraints for all instantiables in the type of the reference to give + // 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 */) && + someType(type, isGenericTypeWithUnionConstraint) && + (isConstraintPosition(reference) || hasNonBindingPatternContextualTypeWithNoGenericTypes(reference)); + return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type; } function isExportOrExportExpression(location) { return !!ts.findAncestor(location, function (e) { return e.parent && ts.isExportAssignment(e.parent) && e.parent.expression === e && ts.isEntityNameExpression(e); }); @@ -65018,7 +67453,12 @@ var ts; if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) { var target = resolveAlias(symbol); if (target.flags & 111551 /* Value */) { - if (compilerOptions.preserveConstEnums && isExportOrExportExpression(location) || !isConstEnumOrConstEnumOnlyModule(target)) { + // 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. + if (compilerOptions.isolatedModules || + ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(location) || + !isConstEnumOrConstEnumOnlyModule(target)) { markAliasSymbolAsReferenced(symbol); } else { @@ -65027,7 +67467,7 @@ var ts; } } } - function checkIdentifier(node) { + function checkIdentifier(node, checkMode) { var symbol = getResolvedSymbol(node); if (symbol === unknownSymbol) { return errorType; @@ -65041,7 +67481,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 209 /* ArrowFunction */) { + if (container.kind === 211 /* 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 */)) { @@ -65058,15 +67498,15 @@ var ts; } var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); var sourceSymbol = localOrExportSymbol.flags & 2097152 /* Alias */ ? resolveAlias(localOrExportSymbol) : localOrExportSymbol; - if (getDeclarationNodeFlagsFromSymbol(sourceSymbol) & 134217728 /* Deprecated */ && isUncalledFunctionReference(node, sourceSymbol)) { - errorOrSuggestion(/* isError */ false, node, ts.Diagnostics._0_is_deprecated, node.escapedText); + if (sourceSymbol.declarations && getDeclarationNodeFlagsFromSymbol(sourceSymbol) & 134217728 /* Deprecated */ && isUncalledFunctionReference(node, sourceSymbol)) { + addDeprecatedSuggestion(node, sourceSymbol.declarations, node.escapedText); } var declaration = localOrExportSymbol.valueDeclaration; - if (localOrExportSymbol.flags & 32 /* Class */) { + if (declaration && localOrExportSymbol.flags & 32 /* 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 === 252 /* ClassDeclaration */ + if (declaration.kind === 254 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -65078,14 +67518,14 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 221 /* ClassExpression */) { + else if (declaration.kind === 223 /* 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 !== 297 /* SourceFile */) { + while (container.kind !== 299 /* SourceFile */) { if (container.parent === declaration) { - if (container.kind === 163 /* PropertyDeclaration */ && ts.hasSyntacticModifier(container, 32 /* Static */)) { + if (container.kind === 165 /* PropertyDeclaration */ && ts.hasSyntacticModifier(container, 32 /* Static */)) { getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; } @@ -65096,12 +67536,18 @@ var ts; } } checkNestedBlockScopedBinding(node, symbol); - var type = getConstraintForLocation(getTypeOfSymbol(localOrExportSymbol), node); + var type = getTypeOfSymbol(localOrExportSymbol); var assignmentKind = ts.getAssignmentTargetKind(node); if (assignmentKind) { if (!(localOrExportSymbol.flags & 3 /* Variable */) && !(ts.isInJSFile(node) && localOrExportSymbol.flags & 512 /* ValueModule */)) { - error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_not_a_variable, symbolToString(symbol)); + 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 + : ts.Diagnostics.Cannot_assign_to_0_because_it_is_not_a_variable; + error(node, assignmentError, symbolToString(symbol)); return errorType; } if (isReadonlySymbol(localOrExportSymbol)) { @@ -65123,7 +67569,7 @@ var ts; } } else if (isAlias) { - declaration = ts.find(symbol.declarations, isSomeImportDeclaration); + declaration = getDeclarationOfAliasSymbol(symbol); } else { return type; @@ -65131,10 +67577,11 @@ var ts; if (!declaration) { return type; } + type = getNarrowableTypeForReference(type, node, checkMode); // 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 === 160 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 162 /* Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; @@ -65143,8 +67590,8 @@ var ts; // 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 === 208 /* FunctionExpression */ || - flowContainer.kind === 209 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 210 /* FunctionExpression */ || + flowContainer.kind === 211 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -65153,9 +67600,9 @@ var ts; // 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 === 270 /* ExportSpecifier */) || - node.parent.kind === 225 /* NonNullExpression */ || - declaration.kind === 249 /* VariableDeclaration */ && declaration.exclamationToken || + isInTypeQuery(node) || node.parent.kind === 272 /* ExportSpecifier */) || + node.parent.kind === 227 /* NonNullExpression */ || + declaration.kind === 251 /* VariableDeclaration */ && declaration.exclamationToken || declaration.flags & 8388608 /* Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : @@ -65180,17 +67627,21 @@ var ts; } return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } - function isInsideFunction(node, threshold) { - return !!ts.findAncestor(node, function (n) { return n === threshold ? "quit" : ts.isFunctionLike(n); }); + 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); }); } function getPartOfForStatementContainingNode(node, container) { return ts.findAncestor(node, function (n) { return n === container ? "quit" : n === container.initializer || n === container.condition || n === container.incrementor || n === container.statement; }); } + function getEnclosingIterationStatement(node) { + 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 || + !symbol.valueDeclaration || ts.isSourceFile(symbol.valueDeclaration) || - symbol.valueDeclaration.parent.kind === 287 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 289 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -65198,22 +67649,14 @@ var ts; // 2. walk from the declaration up to the boundary of lexical environment and check // if there is an iteration statement in between declaration and boundary (is binding/class declared inside iteration statement) var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); - var usedInFunction = isInsideFunction(node.parent, container); - var current = container; - var containedInIterationStatement = false; - while (current && !ts.nodeStartsNewLexicalEnvironment(current)) { - if (ts.isIterationStatement(current, /*lookInLabeledStatements*/ false)) { - containedInIterationStatement = true; - break; - } - current = current.parent; - } - if (containedInIterationStatement) { - if (usedInFunction) { + var isCaptured = isInsideFunctionOrInstancePropertyInitializer(node, container); + var enclosingIterationStatement = getEnclosingIterationStatement(container); + if (enclosingIterationStatement) { + if (isCaptured) { // 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, 250 /* VariableDeclarationList */); + var varDeclList = ts.getAncestor(symbol.valueDeclaration, 252 /* VariableDeclarationList */); if (varDeclList && varDeclList.parent === container) { var part = getPartOfForStatementContainingNode(node.parent, container); if (part) { @@ -65228,13 +67671,13 @@ var ts; } } if (capturesBlockScopeBindingInLoopBody) { - getNodeLinks(current).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */; + getNodeLinks(enclosingIterationStatement).flags |= 65536 /* 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, 250 /* VariableDeclarationList */); + var varDeclList = ts.getAncestor(symbol.valueDeclaration, 252 /* VariableDeclarationList */); if (varDeclList && varDeclList.parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NeedsLoopOutParameter */; } @@ -65242,7 +67685,7 @@ var ts; // set 'declared inside loop' bit on the block-scoped binding getNodeLinks(symbol.valueDeclaration).flags |= 524288 /* BlockScopedBindingInLoop */; } - if (usedInFunction) { + if (isCaptured) { getNodeLinks(symbol.valueDeclaration).flags |= 262144 /* CapturedBlockScopedBinding */; } } @@ -65253,7 +67696,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 207 /* ParenthesizedExpression */) { + while (current.parent.kind === 209 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -65261,7 +67704,7 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 214 /* PrefixUnaryExpression */ || current.parent.kind === 215 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 216 /* PrefixUnaryExpression */ || current.parent.kind === 217 /* PostfixUnaryExpression */)) { var expr = current.parent; isAssigned = expr.operator === 45 /* PlusPlusToken */ || expr.operator === 46 /* MinusMinusToken */; } @@ -65274,7 +67717,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 163 /* PropertyDeclaration */ || container.kind === 166 /* Constructor */) { + if (container.kind === 165 /* PropertyDeclaration */ || container.kind === 168 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -65314,37 +67757,37 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var capturedByArrowFunction = false; - if (container.kind === 166 /* Constructor */) { + if (container.kind === 168 /* 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 === 209 /* ArrowFunction */) { + if (container.kind === 211 /* ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); capturedByArrowFunction = true; } switch (container.kind) { - case 256 /* ModuleDeclaration */: + case 258 /* 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 255 /* EnumDeclaration */: + case 257 /* 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 166 /* Constructor */: + case 168 /* 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 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - if (ts.hasSyntacticModifier(container, 32 /* Static */) && !(compilerOptions.target === 99 /* ESNext */ && compilerOptions.useDefineForClassFields)) { + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + if (ts.hasSyntacticModifier(container, 32 /* Static */) && !(compilerOptions.target === 99 /* ESNext */ && useDefineForClassFields)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } break; - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -65432,7 +67875,7 @@ var ts; } function getClassNameFromPrototypeMethod(container) { // Check if it's the RHS of a x.prototype.y = function [name]() { .... } - if (container.kind === 208 /* FunctionExpression */ && + if (container.kind === 210 /* FunctionExpression */ && ts.isBinaryExpression(container.parent) && ts.getAssignmentDeclarationKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = container' @@ -65442,16 +67885,16 @@ var ts; .expression; // x } // x.prototype = { method() { } } - else if (container.kind === 165 /* MethodDeclaration */ && - container.parent.kind === 200 /* ObjectLiteralExpression */ && + else if (container.kind === 167 /* MethodDeclaration */ && + container.parent.kind === 202 /* ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent) === 6 /* Prototype */) { return container.parent.parent.left.expression; } // x.prototype = { method: function() { } } - else if (container.kind === 208 /* FunctionExpression */ && - container.parent.kind === 288 /* PropertyAssignment */ && - container.parent.parent.kind === 200 /* ObjectLiteralExpression */ && + else if (container.kind === 210 /* FunctionExpression */ && + container.parent.kind === 290 /* PropertyAssignment */ && + container.parent.parent.kind === 202 /* ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* Prototype */) { return container.parent.parent.parent.left.expression; @@ -65459,7 +67902,7 @@ var ts; // Object.defineProperty(x, "method", { value: function() { } }); // Object.defineProperty(x, "method", { set: (x: () => void) => void }); // Object.defineProperty(x, "method", { get: () => function() { }) }); - else if (container.kind === 208 /* FunctionExpression */ && + else if (container.kind === 210 /* 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") && @@ -65484,7 +67927,7 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 308 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 311 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -65498,16 +67941,16 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 160 /* Parameter */ && n.parent === constructorDecl; }); + return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 162 /* Parameter */ && n.parent === constructorDecl; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 203 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 205 /* 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 === 209 /* ArrowFunction */) { + while (container && container.kind === 211 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -65520,14 +67963,14 @@ var ts; // class B { // [super.foo()]() {} // } - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 158 /* ComputedPropertyName */; }); - if (current && current.kind === 158 /* ComputedPropertyName */) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 160 /* ComputedPropertyName */; }); + if (current && current.kind === 160 /* 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 === 200 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 202 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -65535,7 +67978,7 @@ var ts; } return errorType; } - if (!isCallExpression && immediateContainer.kind === 166 /* Constructor */) { + if (!isCallExpression && immediateContainer.kind === 168 /* 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.hasSyntacticModifier(container, 32 /* Static */) || isCallExpression) { @@ -65604,7 +68047,7 @@ 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 === 165 /* MethodDeclaration */ && ts.hasSyntacticModifier(container, 256 /* Async */)) { + if (container.kind === 167 /* MethodDeclaration */ && ts.hasSyntacticModifier(container, 256 /* Async */)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; } @@ -65618,7 +68061,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 200 /* ObjectLiteralExpression */) { + if (container.parent.kind === 202 /* ObjectLiteralExpression */) { if (languageVersion < 2 /* ES2015 */) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return errorType; @@ -65639,7 +68082,7 @@ var ts; if (!baseClassType) { return errorType; } - if (container.kind === 166 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 168 /* 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; @@ -65654,7 +68097,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 === 166 /* Constructor */; + return container.kind === 168 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -65662,21 +68105,21 @@ 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 === 200 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 202 /* ObjectLiteralExpression */) { if (ts.hasSyntacticModifier(container, 32 /* Static */)) { - return container.kind === 165 /* MethodDeclaration */ || - container.kind === 164 /* MethodSignature */ || - container.kind === 167 /* GetAccessor */ || - container.kind === 168 /* SetAccessor */; + return container.kind === 167 /* MethodDeclaration */ || + container.kind === 166 /* MethodSignature */ || + container.kind === 169 /* GetAccessor */ || + container.kind === 170 /* SetAccessor */; } else { - return container.kind === 165 /* MethodDeclaration */ || - container.kind === 164 /* MethodSignature */ || - container.kind === 167 /* GetAccessor */ || - container.kind === 168 /* SetAccessor */ || - container.kind === 163 /* PropertyDeclaration */ || - container.kind === 162 /* PropertySignature */ || - container.kind === 166 /* Constructor */; + return container.kind === 167 /* MethodDeclaration */ || + container.kind === 166 /* MethodSignature */ || + container.kind === 169 /* GetAccessor */ || + container.kind === 170 /* SetAccessor */ || + container.kind === 165 /* PropertyDeclaration */ || + container.kind === 164 /* PropertySignature */ || + container.kind === 168 /* Constructor */; } } } @@ -65684,10 +68127,10 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 165 /* MethodDeclaration */ || - func.kind === 167 /* GetAccessor */ || - func.kind === 168 /* SetAccessor */) && func.parent.kind === 200 /* ObjectLiteralExpression */ ? func.parent : - func.kind === 208 /* FunctionExpression */ && func.parent.kind === 288 /* PropertyAssignment */ ? func.parent.parent : + return (func.kind === 167 /* MethodDeclaration */ || + func.kind === 169 /* GetAccessor */ || + func.kind === 170 /* SetAccessor */) && func.parent.kind === 202 /* ObjectLiteralExpression */ ? func.parent : + func.kind === 210 /* FunctionExpression */ && func.parent.kind === 290 /* PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { @@ -65699,7 +68142,7 @@ var ts; }); } function getContextualThisParameterType(func) { - if (func.kind === 209 /* ArrowFunction */) { + if (func.kind === 211 /* ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -65726,7 +68169,7 @@ var ts; if (thisType) { return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral))); } - if (literal.parent.kind !== 288 /* PropertyAssignment */) { + if (literal.parent.kind !== 290 /* PropertyAssignment */) { break; } literal = literal.parent.parent; @@ -65740,7 +68183,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 === 216 /* BinaryExpression */ && parent.operatorToken.kind === 62 /* EqualsToken */) { + if (parent.kind === 218 /* BinaryExpression */ && parent.operatorToken.kind === 63 /* EqualsToken */) { var target = parent.left; if (ts.isAccessExpression(target)) { var expression = target.expression; @@ -65793,11 +68236,11 @@ var ts; return getTypeFromTypeNode(typeNode); } switch (declaration.kind) { - case 160 /* Parameter */: + case 162 /* Parameter */: return getContextuallyTypedParameterType(declaration); - case 198 /* BindingElement */: + case 200 /* BindingElement */: return getContextualTypeForBindingElement(declaration); - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: if (ts.hasSyntacticModifier(declaration, 32 /* Static */)) { return getContextualTypeForStaticPropertyDeclaration(declaration); } @@ -65808,10 +68251,10 @@ var ts; var parent = declaration.parent.parent; var name = declaration.propertyName || declaration.name; var parentType = getContextualTypeForVariableLikeDeclaration(parent) || - parent.kind !== 198 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent); + parent.kind !== 200 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent); if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name)) return undefined; - if (parent.name.kind === 197 /* ArrayBindingPattern */) { + if (parent.name.kind === 199 /* ArrayBindingPattern */) { var index = ts.indexOfNode(declaration.parent.elements, declaration); if (index < 0) return undefined; @@ -65945,10 +68388,13 @@ var ts; if (ts.isJsxOpeningLikeElement(callTarget) && argIndex === 0) { return getEffectiveFirstArgumentForJsxSignature(signature, callTarget); } - return getTypeAtPosition(signature, argIndex); + var restIndex = signature.parameters.length - 1; + return signatureHasRestParameter(signature) && argIndex >= restIndex ? + getIndexedAccessType(getTypeOfSymbol(signature.parameters[restIndex]), getLiteralType(argIndex - restIndex), 256 /* Contextual */) : + getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 205 /* TaggedTemplateExpression */) { + if (template.parent.kind === 207 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -65957,10 +68403,10 @@ var ts; var binaryExpression = node.parent; var left = binaryExpression.left, operatorToken = binaryExpression.operatorToken, right = binaryExpression.right; switch (operatorToken.kind) { - case 62 /* EqualsToken */: - case 75 /* AmpersandAmpersandEqualsToken */: - case 74 /* BarBarEqualsToken */: - case 76 /* QuestionQuestionEqualsToken */: + case 63 /* EqualsToken */: + case 76 /* AmpersandAmpersandEqualsToken */: + case 75 /* BarBarEqualsToken */: + case 77 /* QuestionQuestionEqualsToken */: return node === right ? getContextualTypeForAssignmentDeclaration(binaryExpression) : undefined; case 56 /* BarBarToken */: case 60 /* QuestionQuestionToken */: @@ -65982,16 +68428,16 @@ var ts; // In an assignment expression, the right operand is contextually typed by the type of the left operand. // Don't do this for assignment declarations unless there is a type tag on the assignment, to avoid circularity from checking the right operand. function getContextualTypeForAssignmentDeclaration(binaryExpression) { + var _a, _b; var kind = ts.getAssignmentDeclarationKind(binaryExpression); switch (kind) { case 0 /* None */: return getTypeOfExpression(binaryExpression.left); + case 4 /* ThisProperty */: + return getContextualTypeForThisPropertyAssignment(binaryExpression); case 5 /* Property */: - case 1 /* ExportsProperty */: - case 6 /* Prototype */: - case 3 /* PrototypeProperty */: if (isPossiblyAliasedThisProperty(binaryExpression, kind)) { - return getContextualTypeForThisPropertyAssignment(binaryExpression, kind); + return getContextualTypeForThisPropertyAssignment(binaryExpression); } // If `binaryExpression.left` was assigned a symbol, then this is a new declaration; otherwise it is an assignment to an existing declaration. // See `bindStaticPropertyAssignment` in `binder.ts`. @@ -66012,11 +68458,11 @@ var ts; var id = lhs.expression; var parentSymbol = resolveName(id, id.escapedText, 111551 /* Value */, undefined, id.escapedText, /*isUse*/ true); if (parentSymbol) { - var annotated = parentSymbol.valueDeclaration && ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration); - if (annotated) { + var annotated_1 = parentSymbol.valueDeclaration && ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration); + if (annotated_1) { var nameStr = ts.getElementOrPropertyAccessName(lhs); if (nameStr !== undefined) { - return getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated), nameStr); + return getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated_1), nameStr); } } return undefined; @@ -66024,9 +68470,15 @@ var ts; } return ts.isInJSFile(decl) ? undefined : getTypeOfExpression(binaryExpression.left); } + case 1 /* ExportsProperty */: + case 6 /* Prototype */: + case 3 /* PrototypeProperty */: + var valueDeclaration = (_a = binaryExpression.left.symbol) === null || _a === void 0 ? void 0 : _a.valueDeclaration; + // falls through case 2 /* ModuleExports */: - case 4 /* ThisProperty */: - return getContextualTypeForThisPropertyAssignment(binaryExpression, kind); + 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 */: @@ -66047,7 +68499,7 @@ var ts; var symbol = resolveName(declaration.left, name, 111551 /* Value */, undefined, undefined, /*isUse*/ true, /*excludeGlobals*/ true); return ts.isThisInitializedDeclaration(symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration); } - function getContextualTypeForThisPropertyAssignment(binaryExpression, kind) { + function getContextualTypeForThisPropertyAssignment(binaryExpression) { if (!binaryExpression.symbol) return getTypeOfExpression(binaryExpression.left); if (binaryExpression.symbol.valueDeclaration) { @@ -66059,8 +68511,6 @@ var ts; } } } - if (kind === 2 /* ModuleExports */) - return undefined; var thisAccess = ts.cast(binaryExpression.left, ts.isAccessExpression); if (!ts.isObjectLiteralMethod(ts.getThisContainer(thisAccess.expression, /*includeArrowFunctions*/ false))) { return undefined; @@ -66115,9 +68565,13 @@ var ts; } function getContextualTypeForObjectLiteralElement(element, contextFlags) { var objectLiteral = element.parent; + var propertyAssignmentType = ts.isPropertyAssignment(element) && getContextualTypeForVariableLikeDeclaration(element); + if (propertyAssignmentType) { + return propertyAssignmentType; + } var type = getApparentTypeOfContextualType(objectLiteral, contextFlags); if (type) { - if (!hasNonBindableDynamicName(element)) { + if (hasBindableName(element)) { // For a (non-symbol) computed property, there is no reason to look up the name // in the type. It will just be "__computed", which does not appear in any // SymbolTable. @@ -66197,25 +68651,25 @@ var ts; case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: - case 103 /* NullKeyword */: - case 78 /* Identifier */: - case 150 /* UndefinedKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: + case 104 /* NullKeyword */: + case 79 /* Identifier */: + case 151 /* UndefinedKeyword */: return true; - case 201 /* PropertyAccessExpression */: - case 207 /* ParenthesizedExpression */: + case 203 /* PropertyAccessExpression */: + case 209 /* ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: return !node.expression || isPossiblyDiscriminantValue(node.expression); } return false; } function discriminateContextualTypeByObjectMembers(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 288 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); + return getMatchingUnionConstituentForObjectLiteral(contextualType, node) || discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 290 /* 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); } function discriminateContextualTypeByJSXAttributes(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 280 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return checkExpression(prop.initializer); }), prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 282 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return checkExpression(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 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. @@ -66226,15 +68680,9 @@ var ts; var instantiatedType = instantiateContextualType(contextualType, node, contextFlags); if (instantiatedType && !(contextFlags && contextFlags & 2 /* NoConstraints */ && instantiatedType.flags & 8650752 /* TypeVariable */)) { var apparentType = mapType(instantiatedType, getApparentType, /*noReductions*/ true); - if (apparentType.flags & 1048576 /* Union */) { - if (ts.isObjectLiteralExpression(node)) { - return discriminateContextualTypeByObjectMembers(node, apparentType); - } - else if (ts.isJsxAttributes(node)) { - return discriminateContextualTypeByJSXAttributes(node, apparentType); - } - } - return apparentType; + return apparentType.flags & 1048576 /* Union */ && ts.isObjectLiteralExpression(node) ? discriminateContextualTypeByObjectMembers(node, apparentType) : + apparentType.flags & 1048576 /* Union */ && ts.isJsxAttributes(node) ? discriminateContextualTypeByJSXAttributes(node, apparentType) : + apparentType; } } // If the given contextual type contains instantiable types and if a mapper representing @@ -66301,58 +68749,60 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 249 /* VariableDeclaration */: - case 160 /* Parameter */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 198 /* BindingElement */: + case 251 /* VariableDeclaration */: + case 162 /* Parameter */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 200 /* BindingElement */: return getContextualTypeForInitializerExpression(node, contextFlags); - case 209 /* ArrowFunction */: - case 242 /* ReturnStatement */: + case 211 /* ArrowFunction */: + case 244 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 213 /* AwaitExpression */: + case 215 /* AwaitExpression */: return getContextualTypeForAwaitOperand(parent, contextFlags); - case 203 /* CallExpression */: - if (parent.expression.kind === 99 /* ImportKeyword */) { + case 205 /* CallExpression */: + if (parent.expression.kind === 100 /* ImportKeyword */) { return stringType; } /* falls through */ - case 204 /* NewExpression */: + case 206 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 206 /* TypeAssertionExpression */: - case 224 /* AsExpression */: + case 208 /* TypeAssertionExpression */: + case 226 /* AsExpression */: return ts.isConstTypeReference(parent.type) ? tryFindWhenConstTypeReference(parent) : getTypeFromTypeNode(parent.type); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node, contextFlags); - case 288 /* PropertyAssignment */: - case 289 /* ShorthandPropertyAssignment */: + case 290 /* PropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent, contextFlags); - case 290 /* SpreadAssignment */: - return getApparentTypeOfContextualType(parent.parent, contextFlags); - case 199 /* ArrayLiteralExpression */: { + case 292 /* SpreadAssignment */: + return getContextualType(parent.parent, contextFlags); + case 201 /* ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral, contextFlags); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node, contextFlags); - case 228 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 218 /* TemplateExpression */); + case 230 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 220 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 207 /* ParenthesizedExpression */: { + case 209 /* 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 ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent, contextFlags); } - case 283 /* JsxExpression */: + case 227 /* NonNullExpression */: + return getContextualType(parent, contextFlags); + case 285 /* JsxExpression */: return getContextualTypeForJsxExpression(parent); - case 280 /* JsxAttribute */: - case 282 /* JsxSpreadAttribute */: + case 282 /* JsxAttribute */: + case 284 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 275 /* JsxOpeningElement */: - case 274 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent, contextFlags); } return undefined; @@ -66388,14 +68838,14 @@ var ts; return propsType; } function getJsxPropsTypeForSignatureFromMember(sig, forcedLookupLocation) { - if (sig.unionSignatures) { + if (sig.compositeSignatures) { // JSX Elements using the legacy `props`-field based lookup (eg, react class components) need to treat the `props` member as an input // instead of an output position when resolving the signature. We need to go back to the input signatures of the composite signature, // get the type of `props` on each return type individually, and then _intersect them_, rather than union them (as would normally occur // for a union signature). It's an unfortunate quirk of looking in the output of the signature for the type we want to use for the input. // The default behavior of `getTypeOfFirstParameterOfSignatureWithFallback` when no `props` member name is defined is much more sane. var results = []; - for (var _i = 0, _a = sig.unionSignatures; _i < _a.length; _i++) { + for (var _i = 0, _a = sig.compositeSignatures; _i < _a.length; _i++) { var signature = _a[_i]; var instance = getReturnTypeOfSignature(signature); if (isTypeAny(instance)) { @@ -66407,7 +68857,7 @@ var ts; } results.push(propType); } - return getIntersectionType(results); + return getIntersectionType(results); // Same result for both union and intersection signatures } var instanceType = getReturnTypeOfSignature(sig); return isTypeAny(instanceType) ? instanceType : getTypeOfPropertyOfType(instanceType, forcedLookupLocation); @@ -66432,16 +68882,19 @@ var ts; function getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType) { var managedSym = getJsxLibraryManagedAttributes(ns); if (managedSym) { - var declaredManagedType = getDeclaredTypeOfSymbol(managedSym); + var declaredManagedType = getDeclaredTypeOfSymbol(managedSym); // fetches interface type, or initializes symbol links type parmaeters var ctorType = getStaticTypeOfReferencedJsxConstructor(context); + if (managedSym.flags & 524288 /* TypeAlias */) { + var params = getSymbolLinks(managedSym).typeParameters; + if (ts.length(params) >= 2) { + var args = fillMissingTypeArguments([ctorType, attributesType], params, 2, ts.isInJSFile(context)); + return getTypeAliasInstantiation(managedSym, args); + } + } if (ts.length(declaredManagedType.typeParameters) >= 2) { var args = fillMissingTypeArguments([ctorType, attributesType], declaredManagedType.typeParameters, 2, ts.isInJSFile(context)); return createTypeReference(declaredManagedType, args); } - else if (ts.length(declaredManagedType.aliasTypeArguments) >= 2) { - var args = fillMissingTypeArguments([ctorType, attributesType], declaredManagedType.aliasTypeArguments, 2, ts.isInJSFile(context)); - return getTypeAliasInstantiation(declaredManagedType.aliasSymbol, args); - } } return attributesType; } @@ -66486,16 +68939,93 @@ var ts; return apparentAttributesType; } } + function getIntersectedSignatures(signatures) { + return ts.getStrictOptionValue(compilerOptions, "noImplicitAny") + ? ts.reduceLeft(signatures, function (left, right) { + return left === right || !left ? left + : compareTypeParametersIdentical(left.typeParameters, right.typeParameters) ? combineSignaturesOfIntersectionMembers(left, right) + : undefined; + }) + : undefined; + } + function combineIntersectionThisParam(left, right, mapper) { + if (!left || !right) { + return left || right; + } + // A signature `this` type might be a read or a write position... It's very possible that it should be invariant + // and we should refuse to merge signatures if there are `this` types and they do not match. However, so as to be + // pessimistic when contextual typing, for now, we'll union the `this` types. + var thisType = getUnionType([getTypeOfSymbol(left), instantiateType(getTypeOfSymbol(right), mapper)]); + return createSymbolWithType(left, thisType); + } + function combineIntersectionParameters(left, right, mapper) { + var leftCount = getParameterCount(left); + var rightCount = getParameterCount(right); + var longest = leftCount >= rightCount ? left : right; + var shorter = longest === left ? right : left; + var longestCount = longest === left ? leftCount : rightCount; + var eitherHasEffectiveRest = (hasEffectiveRestParameter(left) || hasEffectiveRestParameter(right)); + var needsExtraRestElement = eitherHasEffectiveRest && !hasEffectiveRestParameter(longest); + var params = new Array(longestCount + (needsExtraRestElement ? 1 : 0)); + for (var i = 0; i < longestCount; i++) { + var longestParamType = tryGetTypeAtPosition(longest, i); + if (longest === right) { + longestParamType = instantiateType(longestParamType, mapper); + } + var shorterParamType = tryGetTypeAtPosition(shorter, i) || unknownType; + if (shorter === right) { + shorterParamType = instantiateType(shorterParamType, mapper); + } + var unionParamType = getUnionType([longestParamType, shorterParamType]); + var isRestParam = eitherHasEffectiveRest && !needsExtraRestElement && i === (longestCount - 1); + var isOptional = i >= getMinArgumentCount(longest) && i >= getMinArgumentCount(shorter); + var leftName = i >= leftCount ? undefined : getParameterNameAtPosition(left, i); + var rightName = i >= rightCount ? undefined : getParameterNameAtPosition(right, i); + var paramName = leftName === rightName ? leftName : + !leftName ? rightName : + !rightName ? leftName : + undefined; + var paramSymbol = createSymbol(1 /* FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* Optional */ : 0), paramName || "arg" + i); + paramSymbol.type = isRestParam ? createArrayType(unionParamType) : unionParamType; + params[i] = paramSymbol; + } + if (needsExtraRestElement) { + var restParamSymbol = createSymbol(1 /* FunctionScopedVariable */, "args"); + restParamSymbol.type = createArrayType(getTypeAtPosition(shorter, longestCount)); + if (shorter === right) { + restParamSymbol.type = instantiateType(restParamSymbol.type, mapper); + } + params[longestCount] = restParamSymbol; + } + return params; + } + function combineSignaturesOfIntersectionMembers(left, right) { + var typeParams = left.typeParameters || right.typeParameters; + var paramMapper; + if (left.typeParameters && right.typeParameters) { + paramMapper = createTypeMapper(right.typeParameters, left.typeParameters); + // We just use the type parameter defaults from the first signature + } + var declaration = left.declaration; + var params = combineIntersectionParameters(left, right, paramMapper); + var thisParam = combineIntersectionThisParam(left.thisParameter, right.thisParameter, paramMapper); + 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]); + if (paramMapper) { + result.mapper = left.compositeKind === 2097152 /* 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 */); - if (signatures.length === 1) { - var signature = signatures[0]; - if (!isAritySmaller(signature, node)) { - return signature; - } - } + var applicableByArity = ts.filter(signatures, function (s) { return !isAritySmaller(s, node); }); + return applicableByArity.length === 1 ? applicableByArity[0] : getIntersectedSignatures(applicableByArity); } /** If the contextual signature has fewer parameters than the function expression, do not use it */ function isAritySmaller(signature, target) { @@ -66512,7 +69042,7 @@ var ts; return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 208 /* FunctionExpression */ || node.kind === 209 /* ArrowFunction */; + return node.kind === 210 /* FunctionExpression */ || node.kind === 211 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -66526,7 +69056,7 @@ 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 !== 165 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 167 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var typeTagSignature = getSignatureOfTypeTag(node); if (typeTagSignature) { return typeTagSignature; @@ -66574,8 +69104,8 @@ var ts; return node.isSpread ? getIndexedAccessType(node.type, numberType) : node.type; } function hasDefaultValue(node) { - return (node.kind === 198 /* BindingElement */ && !!node.initializer) || - (node.kind === 216 /* BinaryExpression */ && node.operatorToken.kind === 62 /* EqualsToken */); + return (node.kind === 200 /* BindingElement */ && !!node.initializer) || + (node.kind === 218 /* BinaryExpression */ && node.operatorToken.kind === 63 /* EqualsToken */); } function checkArrayLiteral(node, checkMode, forceTuple) { var elements = node.elements; @@ -66585,9 +69115,10 @@ var ts; var contextualType = getApparentTypeOfContextualType(node); 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 === 220 /* SpreadElement */) { + if (e.kind === 222 /* SpreadElement */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(e, compilerOptions.downlevelIteration ? 1536 /* SpreadIncludes */ : 1024 /* SpreadArray */); } @@ -66620,17 +69151,22 @@ var ts; elementFlags.push(4 /* Rest */); } } + else if (strictOptionalProperties && e.kind === 224 /* OmittedExpression */) { + hasOmittedExpression = true; + elementTypes.push(missingType); + elementFlags.push(2 /* Optional */); + } else { var elementContextualType = getContextualTypeForElementExpression(contextualType, elementTypes.length); var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple); - elementTypes.push(type); - elementFlags.push(1 /* Required */); + elementTypes.push(addOptionality(type, /*isProperty*/ true, hasOmittedExpression)); + elementFlags.push(hasOmittedExpression ? 2 /* Optional */ : 1 /* Required */); } } if (inDestructuringPattern) { return createTupleType(elementTypes, elementFlags); } - if (forceTuple || inConstContext || contextualType && forEachType(contextualType, isTupleLikeType)) { + if (forceTuple || inConstContext || contextualType && someType(contextualType, isTupleLikeType)) { return createArrayLiteralType(createTupleType(elementTypes, elementFlags, /*readonly*/ inConstContext)); } return createArrayLiteralType(createArrayType(elementTypes.length ? @@ -66644,15 +69180,15 @@ var ts; var literalType = type.literalType; if (!literalType) { literalType = type.literalType = cloneTypeReference(type); - literalType.objectFlags |= 65536 /* ArrayLiteral */ | 1048576 /* ContainsObjectOrArrayLiteral */; + literalType.objectFlags |= 32768 /* ArrayLiteral */ | 262144 /* ContainsObjectOrArrayLiteral */; } return literalType; } function isNumericName(name) { switch (name.kind) { - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return isNumericComputedName(name); - case 78 /* Identifier */: + case 79 /* Identifier */: return isNumericLiteralName(name.escapedText); case 8 /* NumericLiteral */: case 10 /* StringLiteral */: @@ -66697,6 +69233,20 @@ var ts; var links = getNodeLinks(node.expression); if (!links.resolvedType) { links.resolvedType = checkExpression(node.expression); + // The computed property name of a non-static class field within a loop must be stored in a block-scoped binding. + // (It needs to be bound at class evaluation time.) + if (ts.isPropertyDeclaration(node.parent) && !ts.hasStaticModifier(node.parent) && ts.isClassExpression(node.parent.parent)) { + var container = ts.getEnclosingBlockScopeContainer(node.parent.parent); + 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 */; + // The generated variable which stores the computed field name must be block-scoped. + getNodeLinks(node).flags |= 524288 /* BlockScopedBindingInLoop */; + // The generated variable which stores the class must be block-scoped. + getNodeLinks(node.parent.parent).flags |= 524288 /* 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 */ || @@ -66704,9 +69254,6 @@ var ts; !isTypeAssignableTo(links.resolvedType, stringNumberSymbolType)) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } - else { - checkThatExpressionIsProperSymbolReference(node.expression, links.resolvedType, /*reportError*/ true); - } } return links.resolvedType; } @@ -66746,7 +69293,7 @@ var ts; var spread = emptyObjectType; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 196 /* ObjectBindingPattern */ || contextualType.pattern.kind === 200 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 198 /* ObjectBindingPattern */ || contextualType.pattern.kind === 202 /* ObjectLiteralExpression */); var inConstContext = isConstContext(node); var checkFlags = inConstContext ? 8 /* Readonly */ : 0; var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node); @@ -66761,7 +69308,7 @@ var ts; // which may never occur. for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; - if (elem.name && ts.isComputedPropertyName(elem.name) && !ts.isWellKnownSymbolSyntactically(elem.name)) { + if (elem.name && ts.isComputedPropertyName(elem.name)) { checkComputedPropertyName(elem.name); } } @@ -66769,16 +69316,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 === 158 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 160 /* ComputedPropertyName */ ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 288 /* PropertyAssignment */ || - memberDecl.kind === 289 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 290 /* PropertyAssignment */ || + memberDecl.kind === 291 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 288 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + var type = memberDecl.kind === 290 /* 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 === 289 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : + memberDecl.kind === 291 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJavascript) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -66790,7 +69337,7 @@ var ts; checkTypeAssignableTo(type, getTypeFromTypeNode(enumTag.typeExpression), memberDecl); } } - objectFlags |= ts.getObjectFlags(type) & 3670016 /* PropagatingFlags */; + objectFlags |= ts.getObjectFlags(type) & 917504 /* PropagatingFlags */; var nameType = computedNameType && isTypeUsableAsPropertyName(computedNameType) ? computedNameType : undefined; var prop = nameType ? createSymbol(4 /* Property */ | member.flags, getPropertyNameFromType(nameType), checkFlags | 4096 /* Late */) : @@ -66801,8 +69348,8 @@ var ts; 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 === 288 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 289 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 290 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 291 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216 /* Optional */; } @@ -66828,7 +69375,7 @@ var ts; member = prop; allPropertiesTable === null || allPropertiesTable === void 0 ? void 0 : allPropertiesTable.set(prop.escapedName, prop); } - else if (memberDecl.kind === 290 /* SpreadAssignment */) { + else if (memberDecl.kind === 292 /* SpreadAssignment */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } @@ -66840,15 +69387,20 @@ var ts; hasComputedNumberProperty = false; } var type = getReducedType(checkExpression(memberDecl.expression)); - if (!isValidSpreadType(type)) { - error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); - return errorType; + if (isValidSpreadType(type)) { + if (allPropertiesTable) { + checkSpreadPropOverrides(type, allPropertiesTable, memberDecl); + } + offset = propertiesArray.length; + if (spread === errorType) { + continue; + } + spread = getSpreadType(spread, type, node.symbol, objectFlags, inConstContext); } - if (allPropertiesTable) { - checkSpreadPropOverrides(type, allPropertiesTable, memberDecl); + else { + error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); + spread = errorType; } - spread = getSpreadType(spread, type, node.symbol, objectFlags, inConstContext); - offset = propertiesArray.length; continue; } else { @@ -66857,7 +69409,7 @@ 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 === 167 /* GetAccessor */ || memberDecl.kind === 168 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 169 /* GetAccessor */ || memberDecl.kind === 170 /* SetAccessor */); checkNodeDeferred(memberDecl); } if (computedNameType && !(computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */)) { @@ -66882,7 +69434,7 @@ 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 !== 290 /* SpreadAssignment */) { + if (contextualTypeHasPattern && node.parent.kind !== 292 /* 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)) { @@ -66894,6 +69446,9 @@ var ts; } } } + if (spread === errorType) { + return errorType; + } if (spread !== emptyObjectType) { if (propertiesArray.length > 0) { spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, objectFlags, inConstContext); @@ -66910,9 +69465,9 @@ var ts; var stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node, offset, propertiesArray, 0 /* String */) : undefined; var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, offset, propertiesArray, 1 /* Number */) : undefined; var result = createAnonymousType(node.symbol, propertiesTable, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); - result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 1048576 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 262144 /* ContainsObjectOrArrayLiteral */; if (isJSObjectLiteral) { - result.objectFlags |= 16384 /* JSLiteral */; + result.objectFlags |= 8192 /* JSLiteral */; } if (patternWithComputedProperties) { result.objectFlags |= 512 /* ObjectLiteralPatternWithComputedProperties */; @@ -66978,7 +69533,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 === 78 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); + return tagName.kind === 79 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); } function checkJsxAttribute(node, checkMode) { return node.initializer @@ -67002,14 +69557,14 @@ var ts; var hasSpreadAnyType = false; var typeToIntersect; var explicitlySpecifyChildrenAttribute = false; - var objectFlags = 4096 /* JsxAttributes */; + var objectFlags = 2048 /* 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) & 3670016 /* PropagatingFlags */; + objectFlags |= ts.getObjectFlags(exprType) & 917504 /* PropagatingFlags */; var attributeSymbol = createSymbol(4 /* Property */ | member.flags, member.escapedName); attributeSymbol.declarations = member.declarations; attributeSymbol.parent = member.parent; @@ -67025,7 +69580,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 282 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 284 /* JsxSpreadAttribute */); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, /*readonly*/ false); attributesTable = ts.createSymbolTable(); @@ -67051,7 +69606,7 @@ var ts; } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 273 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 275 /* 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); @@ -67067,7 +69622,7 @@ var ts; // 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); childrenPropSymbol.type = childrenTypes.length === 1 ? childrenTypes[0] : - childrenContextualType && forEachType(childrenContextualType, isTupleLikeType) ? createTupleType(childrenTypes) : + childrenContextualType && someType(childrenContextualType, isTupleLikeType) ? createTupleType(childrenTypes) : createArrayType(getUnionType(childrenTypes)); // Fake up a property declaration for the children childrenPropSymbol.valueDeclaration = ts.factory.createPropertySignature(/*modifiers*/ undefined, ts.unescapeLeadingUnderscores(jsxChildrenPropertyName), /*questionToken*/ undefined, /*type*/ undefined); @@ -67093,7 +69648,7 @@ var ts; function createJsxAttributesType() { objectFlags |= freshObjectLiteralFlag; var result = createAnonymousType(attributes.symbol, attributesTable, ts.emptyArray, ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); - result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 1048576 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 262144 /* ContainsObjectOrArrayLiteral */; return result; } } @@ -67108,7 +69663,7 @@ var ts; childrenTypes.push(stringType); } } - else if (child.kind === 283 /* JsxExpression */ && !child.expression) { + else if (child.kind === 285 /* JsxExpression */ && !child.expression) { continue; // empty jsx expressions don't *really* count as present children } else { @@ -67259,7 +69814,7 @@ var ts; else if (propertiesOfJsxElementAttribPropInterface.length === 1) { return propertiesOfJsxElementAttribPropInterface[0].escapedName; } - else if (propertiesOfJsxElementAttribPropInterface.length > 1) { + else if (propertiesOfJsxElementAttribPropInterface.length > 1 && jsxElementAttribPropInterfaceSym.declarations) { // More than one property on ElementAttributesProperty is an error error(jsxElementAttribPropInterfaceSym.declarations[0], ts.Diagnostics.The_global_type_JSX_0_may_not_have_more_than_one_property, ts.unescapeLeadingUnderscores(nameOfAttribPropContainer)); } @@ -67369,11 +69924,11 @@ var ts; if (!links.resolvedJsxElementAttributesType) { var symbol = getIntrinsicTagSymbol(node); if (links.jsxFlags & 1 /* IntrinsicNamedElement */) { - return links.resolvedJsxElementAttributesType = getTypeOfSymbol(symbol); + return links.resolvedJsxElementAttributesType = getTypeOfSymbol(symbol) || errorType; } else if (links.jsxFlags & 2 /* IntrinsicIndexedElement */) { return links.resolvedJsxElementAttributesType = - getIndexTypeOfType(getDeclaredTypeOfSymbol(symbol), 0 /* String */); + getIndexTypeOfType(getJsxType(JsxNames.IntrinsicElements, node), 0 /* String */) || errorType; } else { return links.resolvedJsxElementAttributesType = errorType; @@ -67526,9 +70081,12 @@ var ts; * @param type The type of the object whose property is being accessed. (Not the type of the property.) * @param prop The symbol for the property being accessed. */ - function checkPropertyAccessibility(node, isSuper, type, prop) { - var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 157 /* QualifiedName */ ? node.right : node.kind === 195 /* ImportType */ ? node : node.name; + function checkPropertyAccessibility(node, isSuper, writing, type, prop, reportError) { + if (reportError === void 0) { reportError = true; } + var flags = ts.getDeclarationModifierFlagsFromSymbol(prop, writing); + var errorNode = node.kind === 159 /* QualifiedName */ ? node.right : + node.kind === 197 /* ImportType */ ? node : + node.kind === 200 /* BindingElement */ && node.propertyName ? node.propertyName : node.name; if (isSuper) { // TS 1.0 spec (April 2014): 4.8.2 // - In a constructor, instance member function, instance member accessor, or @@ -67539,7 +70097,9 @@ var ts; // a super property access is permitted and must specify a public static member function of the base class. if (languageVersion < 2 /* ES2015 */) { if (symbolHasNonMethodDeclaration(prop)) { - error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); + if (reportError) { + error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); + } return false; } } @@ -67548,24 +70108,22 @@ var ts; // This error could mask a private property access error. But, a member // cannot simultaneously be private and abstract, so this will trigger an // additional error elsewhere. - error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(getDeclaringClass(prop))); + if (reportError) { + error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(getDeclaringClass(prop))); + } return false; } } // Referencing abstract properties within their own constructors is not allowed - if ((flags & 128 /* Abstract */) && ts.isThisProperty(node) && symbolHasNonMethodDeclaration(prop)) { + if ((flags & 128 /* Abstract */) && symbolHasNonMethodDeclaration(prop) && + (ts.isThisProperty(node) || ts.isThisInitializedObjectBindingExpression(node) || ts.isObjectBindingPattern(node.parent) && ts.isThisInitializedDeclaration(node.parent.parent))) { var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (declaringClassDeclaration && isNodeUsedDuringClassInitialization(node)) { - error(errorNode, ts.Diagnostics.Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor, symbolToString(prop), ts.getTextOfIdentifierOrLiteral(declaringClassDeclaration.name)); // TODO: GH#18217 - return false; - } - } - if (ts.isPropertyAccessExpression(node) && ts.isPrivateIdentifier(node.name)) { - if (!ts.getContainingClass(node)) { - error(errorNode, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); + if (reportError) { + error(errorNode, ts.Diagnostics.Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor, symbolToString(prop), ts.getTextOfIdentifierOrLiteral(declaringClassDeclaration.name)); // TODO: GH#18217 + } return false; } - return true; } // Public properties are otherwise accessible. if (!(flags & 24 /* NonPublicAccessibilityModifier */)) { @@ -67576,7 +70134,9 @@ var ts; if (flags & 8 /* Private */) { var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (!isNodeWithinClass(node, declaringClassDeclaration)) { - error(errorNode, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(getDeclaringClass(prop))); + if (reportError) { + error(errorNode, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(getDeclaringClass(prop))); + } return false; } return true; @@ -67590,7 +70150,7 @@ var ts; // of the property as base classes var enclosingClass = forEachEnclosingClass(node, function (enclosingDeclaration) { var enclosingClass = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingDeclaration)); - return isClassDerivedFromDeclaringClasses(enclosingClass, prop) ? enclosingClass : undefined; + return isClassDerivedFromDeclaringClasses(enclosingClass, prop, writing) ? enclosingClass : undefined; }); // A protected property is accessible if the property is within the declaring class or classes derived from it if (!enclosingClass) { @@ -67598,7 +70158,9 @@ var ts; // static member access is disallow var thisParameter = void 0; if (flags & 32 /* Static */ || !(thisParameter = getThisParameterFromNodeContext(node)) || !thisParameter.type) { - error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || type)); + if (reportError) { + error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || type)); + } return false; } var thisType = getTypeFromTypeNode(thisParameter.type); @@ -67613,7 +70175,9 @@ var ts; type = type.isThisType ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(type); // TODO: GH#18217 Use a different variable that's allowed to be undefined } if (!type || !hasBaseType(type, enclosingClass)) { - error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); + if (reportError) { + error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_This_is_an_instance_of_class_2, symbolToString(prop), typeToString(enclosingClass), typeToString(type)); + } return false; } return true; @@ -67669,20 +70233,20 @@ var ts; } return nonNullType; } - function checkPropertyAccessExpression(node) { - return node.flags & 32 /* OptionalChain */ ? checkPropertyAccessChain(node) : - checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullExpression(node.expression), node.name); + function checkPropertyAccessExpression(node, checkMode) { + return node.flags & 32 /* OptionalChain */ ? checkPropertyAccessChain(node, checkMode) : + checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullExpression(node.expression), node.name, checkMode); } - function checkPropertyAccessChain(node) { + function checkPropertyAccessChain(node, checkMode) { var leftType = checkExpression(node.expression); var nonOptionalType = getOptionalExpressionType(leftType, node.expression); - return propagateOptionalTypeMarker(checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullType(nonOptionalType, node.expression), node.name), node, nonOptionalType !== leftType); + return propagateOptionalTypeMarker(checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullType(nonOptionalType, node.expression), node.name, checkMode), node, nonOptionalType !== leftType); } - function checkQualifiedName(node) { - return checkPropertyAccessExpressionOrQualifiedName(node, node.left, checkNonNullExpression(node.left), node.right); + function checkQualifiedName(node, checkMode) { + return checkPropertyAccessExpressionOrQualifiedName(node, node.left, checkNonNullExpression(node.left), node.right, checkMode); } function isMethodAccessForCall(node) { - while (node.parent.kind === 207 /* ParenthesizedExpression */) { + while (node.parent.kind === 209 /* ParenthesizedExpression */) { node = node.parent; } return ts.isCallOrNewExpression(node.parent) && node.parent.expression === node; @@ -67717,14 +70281,13 @@ var ts; } var diagName = diagnosticName(right); if (propertyOnType) { - var typeValueDecl = propertyOnType.valueDeclaration; - var typeClass_1 = ts.getContainingClass(typeValueDecl); - ts.Debug.assert(!!typeClass_1); + var typeValueDecl = ts.Debug.checkDefined(propertyOnType.valueDeclaration); + var typeClass_1 = ts.Debug.checkDefined(ts.getContainingClass(typeValueDecl)); // We found a private identifier property with the same description. // Either: // - There is a lexically scoped private identifier AND it shadows the one we found on the type. // - It is an attempt to access the private identifier outside of the class. - if (lexicallyScopedIdentifier) { + if (lexicallyScopedIdentifier === null || lexicallyScopedIdentifier === void 0 ? void 0 : lexicallyScopedIdentifier.valueDeclaration) { var lexicalValueDecl = lexicallyScopedIdentifier.valueDeclaration; var lexicalClass = ts.getContainingClass(lexicalValueDecl); ts.Debug.assert(!!lexicalClass); @@ -67743,17 +70306,42 @@ var ts; return (isConstructorDeclaredProperty(prop) || ts.isThisProperty(node) && isAutoTypedProperty(prop)) && ts.getThisContainer(node, /*includeArrowFunctions*/ true) === getDeclaringConstructor(prop); } - function checkPropertyAccessExpressionOrQualifiedName(node, left, leftType, right) { + 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); - if (ts.isPrivateIdentifier(right)) { - checkExternalEmitHelpers(node, 524288 /* ClassPrivateFieldGet */); - } 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 (assignmentKind !== 1 /* Definite */) { + checkExternalEmitHelpers(node, 524288 /* ClassPrivateFieldGet */); + } + } var lexicallyScopedSymbol = lookupSymbolForPrivateIdentifierDeclaration(right.escapedText, right); + if (assignmentKind && lexicallyScopedSymbol && lexicallyScopedSymbol.valueDeclaration && ts.isMethodDeclaration(lexicallyScopedSymbol.valueDeclaration)) { + grammarErrorOnNode(right, ts.Diagnostics.Cannot_assign_to_private_method_0_Private_methods_are_not_writable, ts.idText(right)); + } + if ((lexicallyScopedSymbol === null || lexicallyScopedSymbol === void 0 ? void 0 : lexicallyScopedSymbol.valueDeclaration) && (compilerOptions.target === 99 /* ESNext */ && !useDefineForClassFields)) { + var lexicalClass_1 = ts.getContainingClass(lexicallyScopedSymbol.valueDeclaration); + var parentStaticFieldInitializer = ts.findAncestor(node, function (n) { + if (n === lexicalClass_1) + return "quit"; + if (ts.isPropertyDeclaration(n.parent) && ts.hasStaticModifier(n.parent) && n.parent.initializer === n && n.parent.parent === lexicalClass_1) { + return true; + } + return false; + }); + if (parentStaticFieldInitializer) { + var parentStaticFieldInitializerSymbol = getSymbolOfNode(parentStaticFieldInitializer.parent); + ts.Debug.assert(parentStaticFieldInitializerSymbol, "Initializer without declaration symbol"); + var diagnostic = error(node, ts.Diagnostics.Property_0_may_not_be_used_in_a_static_property_s_initializer_in_the_same_class_when_target_is_esnext_and_useDefineForClassFields_is_false, ts.symbolName(lexicallyScopedSymbol)); + ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(parentStaticFieldInitializer.parent, ts.Diagnostics.Initializer_for_property_0, ts.symbolName(parentStaticFieldInitializerSymbol))); + } + } if (isAnyLike) { if (lexicallyScopedSymbol) { return apparentType; @@ -67768,6 +70356,12 @@ var ts; if (!prop && checkPrivateIdentifierPropertyAccess(leftType, right, lexicallyScopedSymbol)) { return errorType; } + else { + var isSetonlyAccessor = prop && prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); + if (isSetonlyAccessor && assignmentKind !== 1 /* Definite */) { + error(node, ts.Diagnostics.Private_accessor_was_defined_without_a_getter); + } + } } else { if (isAnyLike) { @@ -67778,7 +70372,11 @@ var ts; } prop = getPropertyOfType(apparentType, right.escapedText); } - if (ts.isIdentifier(left) && parentSymbol && !(prop && isConstEnumOrConstEnumOnlyModule(prop))) { + // In `Foo.Bar.Baz`, 'Foo' is not referenced if 'Bar' is a const enum or a module containing only const enums. + // The exceptions are: + // 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)) || ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(node))) { markAliasReferenced(parentSymbol, node); } var propType; @@ -67811,44 +70409,50 @@ var ts; } } else { - if (getDeclarationNodeFlagsFromSymbol(prop) & 134217728 /* Deprecated */ && isUncalledFunctionReference(node, prop)) { - errorOrSuggestion(/* isError */ false, right, ts.Diagnostics._0_is_deprecated, right.escapedText); + if (prop.declarations && getDeclarationNodeFlagsFromSymbol(prop) & 134217728 /* Deprecated */ && isUncalledFunctionReference(node, prop)) { + addDeprecatedSuggestion(right, prop.declarations, right.escapedText); } checkPropertyNotUsedBeforeDeclaration(prop, node, right); - markPropertyAsReferenced(prop, node, left.kind === 107 /* ThisKeyword */); + markPropertyAsReferenced(prop, node, isSelfTypeAccess(left, parentSymbol)); getNodeLinks(node).resolvedSymbol = prop; - checkPropertyAccessibility(node, left.kind === 105 /* SuperKeyword */, apparentType, prop); + var writing = ts.isWriteAccess(node); + checkPropertyAccessibility(node, left.kind === 106 /* 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; } - propType = isThisPropertyAccessInConstructor(node, prop) ? autoType : getConstraintForLocation(getTypeOfSymbol(prop), node); + propType = isThisPropertyAccessInConstructor(node, prop) ? autoType : writing ? getSetAccessorTypeOfSymbol(prop) : getTypeOfSymbol(prop); } - return getFlowTypeOfAccessExpression(node, prop, propType, right); + return getFlowTypeOfAccessExpression(node, prop, propType, right, checkMode); } - function getFlowTypeOfAccessExpression(node, prop, propType, errorNode) { + function getFlowTypeOfAccessExpression(node, prop, propType, errorNode, checkMode) { // Only compute control flow type if this is a property access expression that isn't an // assignment target, and the referenced property was declared as a variable, property, // accessor, or optional method. var assignmentKind = ts.getAssignmentTargetKind(node); - if (!ts.isAccessExpression(node) || - assignmentKind === 1 /* Definite */ || - prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */)) { + if (assignmentKind === 1 /* Definite */) { + return removeMissingType(propType, !!(prop && prop.flags & 16777216 /* Optional */)); + } + if (prop && + !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) + && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */) + && !isDuplicatedCommonJSExport(prop.declarations)) { return propType; } if (propType === autoType) { return getFlowTypeOfProperty(node, prop); } + propType = getNarrowableTypeForReference(propType, node, checkMode); // If strict null checks and strict property initialization checks are enabled, if we have // a this.xxx property access, if the property is an instance property without an initializer, // and if we are in a constructor of the same class as the property declaration, assume that // the property is uninitialized at the top of the control flow. var assumeUninitialized = false; - if (strictNullChecks && strictPropertyInitialization && node.expression.kind === 107 /* ThisKeyword */) { + if (strictNullChecks && strictPropertyInitialization && ts.isAccessExpression(node) && node.expression.kind === 108 /* ThisKeyword */) { var declaration = prop && prop.valueDeclaration; if (declaration && isInstancePropertyWithoutInitializer(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 166 /* Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 8388608 /* Ambient */)) { + if (flowContainer.kind === 168 /* Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 8388608 /* Ambient */)) { assumeUninitialized = true; } } @@ -67875,13 +70479,14 @@ var ts; var diagnosticMessage; var declarationName = ts.idText(right); if (isInPropertyInitializer(node) + && !isOptionalPropertyDeclaration(valueDeclaration) && !(ts.isAccessExpression(node) && ts.isAccessExpression(node.expression)) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) - && !isPropertyDeclaredInAncestorClass(prop)) { + && (compilerOptions.useDefineForClassFields || !isPropertyDeclaredInAncestorClass(prop))) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 252 /* ClassDeclaration */ && - node.parent.kind !== 173 /* TypeReference */ && + else if (valueDeclaration.kind === 254 /* ClassDeclaration */ && + node.parent.kind !== 175 /* TypeReference */ && !(valueDeclaration.flags & 8388608 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); @@ -67893,22 +70498,22 @@ var ts; function isInPropertyInitializer(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return true; - case 288 /* PropertyAssignment */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 290 /* SpreadAssignment */: - case 158 /* ComputedPropertyName */: - case 228 /* TemplateSpan */: - case 283 /* JsxExpression */: - case 280 /* JsxAttribute */: - case 281 /* JsxAttributes */: - case 282 /* JsxSpreadAttribute */: - case 275 /* JsxOpeningElement */: - case 223 /* ExpressionWithTypeArguments */: - case 286 /* HeritageClause */: + case 290 /* PropertyAssignment */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 292 /* SpreadAssignment */: + case 160 /* ComputedPropertyName */: + case 230 /* TemplateSpan */: + case 285 /* JsxExpression */: + case 282 /* JsxAttribute */: + case 283 /* JsxAttributes */: + case 284 /* JsxSpreadAttribute */: + case 277 /* JsxOpeningElement */: + case 225 /* ExpressionWithTypeArguments */: + case 288 /* HeritageClause */: return false; default: return ts.isExpressionNode(node) ? false : "quit"; @@ -67980,7 +70585,10 @@ var ts; relatedInfo = suggestion.valueDeclaration && ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestedName); } else { - errorInfo = ts.chainDiagnosticMessages(elaborateNeverIntersection(errorInfo, containingType), ts.Diagnostics.Property_0_does_not_exist_on_type_1, missingProperty, container); + var diagnostic = containerSeemsToBeEmptyDomElement(containingType) + ? ts.Diagnostics.Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom + : ts.Diagnostics.Property_0_does_not_exist_on_type_1; + errorInfo = ts.chainDiagnosticMessages(elaborateNeverIntersection(errorInfo, containingType), diagnostic, missingProperty, container); } } } @@ -67991,9 +70599,14 @@ var ts; } diagnostics.add(resultDiagnostic); } + function containerSeemsToBeEmptyDomElement(containingType) { + return (compilerOptions.lib && !compilerOptions.lib.includes("dom")) && + everyContainedType(containingType, function (type) { return type.symbol && /^(EventTarget|Node|((HTML[a-zA-Z]*)?Element))$/.test(ts.unescapeLeadingUnderscores(type.symbol.escapedName)); }) && + isEmptyObjectType(containingType); + } function typeHasStaticProperty(propName, containingType) { var prop = containingType.symbol && getPropertyOfType(getTypeOfSymbol(containingType.symbol), propName); - return prop !== undefined && prop.valueDeclaration && ts.hasSyntacticModifier(prop.valueDeclaration, 32 /* Static */); + return prop !== undefined && !!prop.valueDeclaration && ts.hasSyntacticModifier(prop.valueDeclaration, 32 /* Static */); } function getSuggestedLibForNonExistentName(name) { var missingName = diagnosticName(name); @@ -68024,7 +70637,15 @@ var ts; } } function getSuggestedSymbolForNonexistentProperty(name, containingType) { - return getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 111551 /* Value */); + var props = getPropertiesOfType(containingType); + if (typeof name !== "string") { + var parent_2 = name.parent; + if (ts.isPropertyAccessExpression(parent_2)) { + props = ts.filter(props, function (prop) { return isValidPropertyAccessForCompletions(parent_2, containingType, prop); }); + } + name = ts.idText(name); + } + return getSpellingSuggestionForName(name, props, 111551 /* Value */); } function getSuggestedSymbolForNonexistentJSXAttribute(name, containingType) { var strName = ts.isString(name) ? name : ts.idText(name); @@ -68119,20 +70740,20 @@ var ts; return undefined; } } - function markPropertyAsReferenced(prop, nodeForCheckWriteOnly, isThisAccess) { + function markPropertyAsReferenced(prop, nodeForCheckWriteOnly, isSelfTypeAccess) { var valueDeclaration = prop && (prop.flags & 106500 /* ClassMember */) && prop.valueDeclaration; if (!valueDeclaration) { return; } var hasPrivateModifier = ts.hasEffectiveModifier(valueDeclaration, 8 /* Private */); - var hasPrivateIdentifier = ts.isNamedDeclaration(prop.valueDeclaration) && ts.isPrivateIdentifier(prop.valueDeclaration.name); + 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 */)) { return; } - if (isThisAccess) { + if (isSelfTypeAccess) { // Find any FunctionLikeDeclaration because those create a new 'this' binding. But this should only matter for methods (or getters/setters). var containingMethod = ts.findAncestor(nodeForCheckWriteOnly, ts.isFunctionLikeDeclaration); if (containingMethod && containingMethod.symbol === prop) { @@ -68141,18 +70762,22 @@ var ts; } (ts.getCheckFlags(prop) & 1 /* Instantiated */ ? getSymbolLinks(prop).target : prop).isReferenced = 67108863 /* All */; } + function isSelfTypeAccess(name, parent) { + return name.kind === 108 /* ThisKeyword */ + || !!parent && ts.isEntityNameExpression(name) && parent === getResolvedSymbol(ts.getFirstIdentifier(name)); + } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 201 /* PropertyAccessExpression */: - return isValidPropertyAccessWithType(node, node.expression.kind === 105 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); - case 157 /* QualifiedName */: + case 203 /* PropertyAccessExpression */: + return isValidPropertyAccessWithType(node, node.expression.kind === 106 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); + case 159 /* QualifiedName */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getWidenedType(checkExpression(node.left))); - case 195 /* ImportType */: + case 197 /* ImportType */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind === 201 /* PropertyAccessExpression */ && node.expression.kind === 105 /* SuperKeyword */, property.escapedName, type); + return isValidPropertyAccessWithType(node, node.kind === 203 /* PropertyAccessExpression */ && node.expression.kind === 106 /* SuperKeyword */, property.escapedName, type); // Previously we validated the 'this' type of methods but this adversely affected performance. See #31377 for more context. } function isValidPropertyAccessWithType(node, isSuper, propertyName, type) { @@ -68161,11 +70786,11 @@ var ts; } var prop = getPropertyOfType(type, propertyName); if (prop) { - if (ts.isPropertyAccessExpression(node) && prop.valueDeclaration && ts.isPrivateIdentifierPropertyDeclaration(prop.valueDeclaration)) { + if (prop.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(prop.valueDeclaration)) { var declClass_1 = ts.getContainingClass(prop.valueDeclaration); return !ts.isOptionalChain(node) && !!ts.findAncestor(node, function (parent) { return parent === declClass_1; }); } - return checkPropertyAccessibility(node, isSuper, type, prop); + return checkPropertyAccessibility(node, isSuper, /*writing*/ false, type, prop, /* reportError */ false); } // In js files properties of unions are allowed in completion return ts.isInJSFile(node) && (type.flags & 1048576 /* Union */) !== 0 && type.types.some(function (elementType) { return isValidPropertyAccessWithType(node, isSuper, propertyName, elementType); }); @@ -68175,13 +70800,13 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 250 /* VariableDeclarationList */) { + if (initializer.kind === 252 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 78 /* Identifier */) { + else if (initializer.kind === 79 /* Identifier */) { return getResolvedSymbol(initializer); } return undefined; @@ -68198,13 +70823,13 @@ var ts; */ function isForInVariableForNumericPropertyNames(expr) { var e = ts.skipParentheses(expr); - if (e.kind === 78 /* Identifier */) { + if (e.kind === 79 /* Identifier */) { var symbol = getResolvedSymbol(e); if (symbol.flags & 3 /* Variable */) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 238 /* ForInStatement */ && + if (node.kind === 240 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -68217,16 +70842,16 @@ var ts; } return false; } - function checkIndexedAccess(node) { - return node.flags & 32 /* OptionalChain */ ? checkElementAccessChain(node) : - checkElementAccessExpression(node, checkNonNullExpression(node.expression)); + function checkIndexedAccess(node, checkMode) { + return node.flags & 32 /* OptionalChain */ ? checkElementAccessChain(node, checkMode) : + checkElementAccessExpression(node, checkNonNullExpression(node.expression), checkMode); } - function checkElementAccessChain(node) { + function checkElementAccessChain(node, checkMode) { var exprType = checkExpression(node.expression); var nonOptionalType = getOptionalExpressionType(exprType, node.expression); - return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression)), node, nonOptionalType !== exprType); + return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression), checkMode), node, nonOptionalType !== exprType); } - function checkElementAccessExpression(node, exprType) { + function checkElementAccessExpression(node, exprType, checkMode) { var objectType = ts.getAssignmentTargetKind(node) !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; var indexExpression = node.argumentExpression; var indexType = checkExpression(indexExpression); @@ -68239,45 +70864,10 @@ var ts; } var effectiveIndexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType; var accessFlags = ts.isAssignmentTarget(node) ? - 2 /* Writing */ | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 1 /* NoIndexSignatures */ : 0) : - 0 /* None */; - var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, /*noUncheckedIndexedAccessCandidate*/ undefined, node, accessFlags | 16 /* ExpressionPosition */) || errorType; - return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, indexedAccessType.symbol, indexedAccessType, indexExpression), node); - } - function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) { - if (expressionType === errorType) { - // There is already an error, so no need to report one. - return false; - } - if (!ts.isWellKnownSymbolSyntactically(expression)) { - return false; - } - // Make sure the property type is the primitive symbol type - if ((expressionType.flags & 12288 /* ESSymbolLike */) === 0) { - if (reportError) { - error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression)); - } - return false; - } - // The name is Symbol., so make sure Symbol actually resolves to the - // global Symbol object - var leftHandSide = expression.expression; - var leftHandSideSymbol = getResolvedSymbol(leftHandSide); - if (!leftHandSideSymbol) { - return false; - } - var globalESSymbol = getGlobalESSymbolConstructorSymbol(/*reportErrors*/ true); - if (!globalESSymbol) { - // Already errored when we tried to look up the symbol - return false; - } - if (leftHandSideSymbol !== globalESSymbol) { - if (reportError) { - error(leftHandSide, ts.Diagnostics.Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object); - } - return false; - } - return true; + 4 /* Writing */ | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 2 /* NoIndexSignatures */ : 0) : + 32 /* ExpressionPosition */; + var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, accessFlags, node) || errorType; + return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, getNodeLinks(node).resolvedSymbol, indexedAccessType, indexExpression, checkMode), node); } function callLikeExpressionMayHaveTypeArguments(node) { return ts.isCallOrNewExpression(node) || ts.isTaggedTemplateExpression(node) || ts.isJsxOpeningLikeElement(node); @@ -68288,13 +70878,13 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 205 /* TaggedTemplateExpression */) { + if (node.kind === 207 /* TaggedTemplateExpression */) { checkExpression(node.template); } else if (ts.isJsxOpeningLikeElement(node)) { checkExpression(node.attributes); } - else if (node.kind !== 161 /* Decorator */) { + else if (node.kind !== 163 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -68358,7 +70948,7 @@ var ts; } } function isSpreadArgument(arg) { - return !!arg && (arg.kind === 220 /* SpreadElement */ || arg.kind === 227 /* SyntheticExpression */ && arg.isSpread); + return !!arg && (arg.kind === 222 /* SpreadElement */ || arg.kind === 229 /* SyntheticExpression */ && arg.isSpread); } function getSpreadArgumentIndex(args) { return ts.findIndex(args, isSpreadArgument); @@ -68375,9 +70965,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 === 205 /* TaggedTemplateExpression */) { + if (node.kind === 207 /* TaggedTemplateExpression */) { argCount = args.length; - if (node.template.kind === 218 /* TemplateExpression */) { + if (node.template.kind === 220 /* 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. @@ -68392,7 +70982,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 161 /* Decorator */) { + else if (node.kind === 163 /* Decorator */) { argCount = getDecoratorArgumentCount(node, signature); } else if (ts.isJsxOpeningLikeElement(node)) { @@ -68406,7 +70996,7 @@ var ts; } else if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 204 /* NewExpression */); + ts.Debug.assert(node.kind === 206 /* NewExpression */); return getMinArgumentCount(signature) === 0; } else { @@ -68481,7 +71071,7 @@ var ts; }); if (!inferenceContext) { applyToReturnTypes(contextualSignature, signature, function (source, target) { - inferTypes(context.inferences, source, target, 64 /* ReturnType */); + inferTypes(context.inferences, source, target, 128 /* ReturnType */); }); } return getSignatureInstantiation(signature, getInferredTypes(context), ts.isInJSFile(contextualSignature.declaration)); @@ -68492,6 +71082,15 @@ var ts; inferTypes(context.inferences, checkAttrType, paramType); return getInferredTypes(context); } + function getThisArgumentType(thisArgumentNode) { + if (!thisArgumentNode) { + return voidType; + } + var thisArgumentType = checkExpression(thisArgumentNode); + return ts.isOptionalChainRoot(thisArgumentNode.parent) ? getNonNullableType(thisArgumentType) : + ts.isOptionalChain(thisArgumentNode.parent) ? removeOptionalTypeMarker(thisArgumentType) : + thisArgumentType; + } function inferTypeArguments(node, signature, args, checkMode, context) { if (ts.isJsxOpeningLikeElement(node)) { return inferJsxTypeArguments(node, signature, checkMode, context); @@ -68500,7 +71099,7 @@ 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 !== 161 /* Decorator */) { + if (node.kind !== 163 /* Decorator */) { var contextualType = getContextualType(node, ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }) ? 8 /* SkipBindingPatterns */ : 0 /* None */); if (contextualType) { // We clone the inference context to avoid disturbing a resolution in progress for an @@ -68522,7 +71121,7 @@ var ts; instantiatedType; var inferenceTargetType = getReturnTypeOfSignature(signature); // Inferences made from return types have lower priority than all other inferences. - inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 64 /* ReturnType */); + inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* 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 // the source type uses the outer context's return mapper (which excludes inferences made from @@ -68544,12 +71143,11 @@ var ts; var thisType = getThisTypeOfSignature(signature); if (thisType) { var thisArgumentNode = getThisArgumentOfCall(node); - var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; - inferTypes(context.inferences, thisArgumentType, thisType); + inferTypes(context.inferences, getThisArgumentType(thisArgumentNode), thisType); } for (var i = 0; i < argCount; i++) { var arg = args[i]; - if (arg.kind !== 222 /* OmittedExpression */) { + if (arg.kind !== 224 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode); inferTypes(context.inferences, argType, paramType); @@ -68573,7 +71171,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 === 227 /* SyntheticExpression */ ? arg.type : + return getMutableArrayOrTupleType(arg.kind === 229 /* SyntheticExpression */ ? arg.type : checkExpressionWithContextualType(arg.expression, restType, context, checkMode)); } } @@ -68583,24 +71181,24 @@ var ts; for (var i = index; i < argCount; i++) { var arg = args[i]; if (isSpreadArgument(arg)) { - var spreadType = arg.kind === 227 /* SyntheticExpression */ ? arg.type : checkExpression(arg.expression); + var spreadType = arg.kind === 229 /* SyntheticExpression */ ? arg.type : checkExpression(arg.expression); if (isArrayLikeType(spreadType)) { types.push(spreadType); flags.push(8 /* Variadic */); } else { - types.push(checkIteratedTypeOrElementType(33 /* Spread */, spreadType, undefinedType, arg.kind === 220 /* SpreadElement */ ? arg.expression : arg)); + types.push(checkIteratedTypeOrElementType(33 /* Spread */, spreadType, undefinedType, arg.kind === 222 /* SpreadElement */ ? arg.expression : arg)); flags.push(4 /* Rest */); } } else { - var contextualType = getIndexedAccessType(restType, getLiteralType(i - index)); + var contextualType = getIndexedAccessType(restType, getLiteralType(i - index), 256 /* Contextual */); var argType = checkExpressionWithContextualType(arg, contextualType, context, checkMode); var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 131068 /* Primitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */); types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType)); flags.push(1 /* Required */); } - if (arg.kind === 227 /* SyntheticExpression */ && arg.tupleNameSource) { + if (arg.kind === 229 /* SyntheticExpression */ && arg.tupleNameSource) { names.push(arg.tupleNameSource); } } @@ -68744,24 +71342,12 @@ var ts; return undefined; } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 204 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 206 /* 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. var thisArgumentNode = getThisArgumentOfCall(node); - var thisArgumentType = void 0; - if (thisArgumentNode) { - thisArgumentType = checkExpression(thisArgumentNode); - if (ts.isOptionalChainRoot(thisArgumentNode.parent)) { - thisArgumentType = getNonNullableType(thisArgumentType); - } - else if (ts.isOptionalChain(thisArgumentNode.parent)) { - thisArgumentType = removeOptionalTypeMarker(thisArgumentType); - } - } - else { - thisArgumentType = voidType; - } + var thisArgumentType = getThisArgumentType(thisArgumentNode); var errorNode = reportErrors ? (thisArgumentNode || node) : undefined; var headMessage_1 = ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1; if (!checkTypeRelatedTo(thisArgumentType, thisType, relation, errorNode, headMessage_1, containingMessageChain, errorOutputContainer)) { @@ -68774,7 +71360,7 @@ 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 !== 222 /* OmittedExpression */) { + if (arg.kind !== 224 /* 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), @@ -68819,7 +71405,7 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 203 /* CallExpression */) { + if (node.kind === 205 /* CallExpression */) { var callee = ts.skipOuterExpressions(node.expression); if (ts.isAccessExpression(callee)) { return callee.expression; @@ -68836,17 +71422,17 @@ var ts; * Returns the effective arguments for an expression that works like a function invocation. */ function getEffectiveCallArguments(node) { - if (node.kind === 205 /* TaggedTemplateExpression */) { + if (node.kind === 207 /* TaggedTemplateExpression */) { var template = node.template; var args_3 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())]; - if (template.kind === 218 /* TemplateExpression */) { + if (template.kind === 220 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_3.push(span.expression); }); } return args_3; } - if (node.kind === 161 /* Decorator */) { + if (node.kind === 163 /* Decorator */) { return getEffectiveDecoratorArguments(node); } if (ts.isJsxOpeningLikeElement(node)) { @@ -68857,10 +71443,10 @@ var ts; if (spreadIndex >= 0) { // Create synthetic arguments from spreads of tuple types. var effectiveArgs_1 = args.slice(0, spreadIndex); - var _loop_20 = function (i) { + var _loop_21 = function (i) { var arg = args[i]; // We can call checkExpressionCached because spread expressions never have a contextual type. - var spreadType = arg.kind === 220 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression)); + var spreadType = arg.kind === 222 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression)); if (spreadType && isTupleType(spreadType)) { ts.forEach(getTypeArguments(spreadType), function (t, i) { var _a; @@ -68874,7 +71460,7 @@ var ts; } }; for (var i = spreadIndex; i < args.length; i++) { - _loop_20(i); + _loop_21(i); } return effectiveArgs_1; } @@ -68887,30 +71473,30 @@ var ts; var parent = node.parent; var expr = node.expression; switch (parent.kind) { - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* 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 160 /* Parameter */: + case 162 /* 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 === 166 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), + createSyntheticExpression(expr, parent.parent.kind === 168 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), createSyntheticExpression(expr, anyType), createSyntheticExpression(expr, numberType) ]; - case 163 /* PropertyDeclaration */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* 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 !== 163 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; + var hasPropDesc = parent.kind !== 165 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; return [ createSyntheticExpression(expr, getParentTypeOfClassElement(parent)), createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)), @@ -68924,17 +71510,17 @@ var ts; */ function getDecoratorArgumentCount(node, signature) { switch (node.parent.kind) { - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: return 1; - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return 2; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* 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 160 /* Parameter */: + case 162 /* Parameter */: return 3; default: return ts.Debug.fail(); @@ -68980,77 +71566,66 @@ var ts; return constructorSymbol === globalPromiseSymbol; } function getArgumentArityError(node, signatures, args) { - var min = Number.POSITIVE_INFINITY; - var max = Number.NEGATIVE_INFINITY; - var belowArgCount = Number.NEGATIVE_INFINITY; - var aboveArgCount = Number.POSITIVE_INFINITY; - var argCount = args.length; + var _a; + var spreadIndex = getSpreadArgumentIndex(args); + if (spreadIndex > -1) { + return ts.createDiagnosticForNode(args[spreadIndex], ts.Diagnostics.A_spread_argument_must_either_have_a_tuple_type_or_be_passed_to_a_rest_parameter); + } + var min = Number.POSITIVE_INFINITY; // smallest parameter count + var max = Number.NEGATIVE_INFINITY; // largest parameter count + var maxBelow = Number.NEGATIVE_INFINITY; // largest parameter count that is smaller than the number of arguments + var minAbove = Number.POSITIVE_INFINITY; // smallest parameter count that is larger than the number of arguments var closestSignature; for (var _i = 0, signatures_8 = signatures; _i < signatures_8.length; _i++) { var sig = signatures_8[_i]; - var minCount = getMinArgumentCount(sig); - var maxCount = getParameterCount(sig); - if (minCount < argCount && minCount > belowArgCount) - belowArgCount = minCount; - if (argCount < maxCount && maxCount < aboveArgCount) - aboveArgCount = maxCount; - if (minCount < min) { - min = minCount; + var minParameter = getMinArgumentCount(sig); + var maxParameter = getParameterCount(sig); + // smallest/largest parameter counts + if (minParameter < min) { + min = minParameter; closestSignature = sig; } - max = Math.max(max, maxCount); + max = Math.max(max, maxParameter); + // shortest parameter count *longer than the call*/longest parameter count *shorter than the call* + if (minParameter < args.length && minParameter > maxBelow) + maxBelow = minParameter; + if (args.length < maxParameter && maxParameter < minAbove) + minAbove = maxParameter; } var hasRestParameter = ts.some(signatures, hasEffectiveRestParameter); - var paramRange = hasRestParameter ? min : - min < max ? min + "-" + max : - min; - var hasSpreadArgument = getSpreadArgumentIndex(args) > -1; - if (argCount <= max && hasSpreadArgument) { - argCount--; - } - var spanArray; - var related; - var error = hasRestParameter || hasSpreadArgument ? - hasRestParameter && hasSpreadArgument ? - ts.Diagnostics.Expected_at_least_0_arguments_but_got_1_or_more : - hasRestParameter ? - ts.Diagnostics.Expected_at_least_0_arguments_but_got_1 : - ts.Diagnostics.Expected_0_arguments_but_got_1_or_more : - paramRange === 1 && argCount === 0 && isPromiseResolveArityError(node) ? - ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise : - ts.Diagnostics.Expected_0_arguments_but_got_1; - if (closestSignature && getMinArgumentCount(closestSignature) > argCount && closestSignature.declaration) { - var paramDecl = closestSignature.declaration.parameters[closestSignature.thisParameter ? argCount + 1 : argCount]; - if (paramDecl) { - related = ts.createDiagnosticForNode(paramDecl, ts.isBindingPattern(paramDecl.name) ? ts.Diagnostics.An_argument_matching_this_binding_pattern_was_not_provided : - ts.isRestParameter(paramDecl) ? ts.Diagnostics.Arguments_for_the_rest_parameter_0_were_not_provided : ts.Diagnostics.An_argument_for_0_was_not_provided, !paramDecl.name ? argCount : !ts.isBindingPattern(paramDecl.name) ? ts.idText(ts.getFirstIdentifier(paramDecl.name)) : undefined); - } - } - if (min < argCount && argCount < max) { - return getDiagnosticForCallNode(node, ts.Diagnostics.No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments, argCount, belowArgCount, aboveArgCount); - } - if (!hasSpreadArgument && argCount < min) { - var diagnostic_1 = getDiagnosticForCallNode(node, error, paramRange, argCount); - return related ? ts.addRelatedInfo(diagnostic_1, related) : diagnostic_1; - } - if (hasRestParameter || hasSpreadArgument) { - spanArray = ts.factory.createNodeArray(args); - if (hasSpreadArgument && argCount) { - var nextArg = ts.elementAt(args, getSpreadArgumentIndex(args) + 1) || undefined; - spanArray = ts.factory.createNodeArray(args.slice(max > argCount && nextArg ? args.indexOf(nextArg) : Math.min(max, args.length - 1))); + var parameterRange = hasRestParameter ? min + : min < max ? min + "-" + max + : min; + var error = hasRestParameter ? ts.Diagnostics.Expected_at_least_0_arguments_but_got_1 + : parameterRange === 1 && args.length === 0 && isPromiseResolveArityError(node) ? ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise + : ts.Diagnostics.Expected_0_arguments_but_got_1; + if (min < args.length && args.length < max) { + // between min and max, but with no matching overload + return getDiagnosticForCallNode(node, ts.Diagnostics.No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments, args.length, maxBelow, minAbove); + } + else if (args.length < min) { + // too short: put the error span on the call expression, not any of the args + var diagnostic = getDiagnosticForCallNode(node, error, parameterRange, args.length); + var parameter = (_a = closestSignature === null || closestSignature === void 0 ? void 0 : closestSignature.declaration) === null || _a === void 0 ? void 0 : _a.parameters[closestSignature.thisParameter ? args.length + 1 : args.length]; + if (parameter) { + var parameterError = ts.createDiagnosticForNode(parameter, ts.isBindingPattern(parameter.name) ? ts.Diagnostics.An_argument_matching_this_binding_pattern_was_not_provided + : ts.isRestParameter(parameter) ? ts.Diagnostics.Arguments_for_the_rest_parameter_0_were_not_provided + : ts.Diagnostics.An_argument_for_0_was_not_provided, !parameter.name ? args.length : !ts.isBindingPattern(parameter.name) ? ts.idText(ts.getFirstIdentifier(parameter.name)) : undefined); + return ts.addRelatedInfo(diagnostic, parameterError); } + return diagnostic; } else { - spanArray = ts.factory.createNodeArray(args.slice(max)); - } - var pos = ts.first(spanArray).pos; - var end = ts.last(spanArray).end; - if (end === pos) { - end++; + // too long; error goes on the excess parameters + var errorSpan = ts.factory.createNodeArray(args.slice(max)); + var pos = ts.first(errorSpan).pos; + var end = ts.last(errorSpan).end; + if (end === pos) { + end++; + } + ts.setTextRangePosEnd(errorSpan, pos, end); + return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), errorSpan, error, parameterRange, args.length); } - ts.setTextRangePosEnd(spanArray, pos, end); - var diagnostic = ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), spanArray, error, paramRange, argCount); - return related ? ts.addRelatedInfo(diagnostic, related) : diagnostic; } function getTypeArgumentArityError(node, signatures, typeArguments) { var argCount = typeArguments.length; @@ -69081,15 +71656,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 === 205 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 161 /* Decorator */; + var isTaggedTemplate = node.kind === 207 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 163 /* Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var reportErrors = !candidatesOutArray && produceDiagnostics; var typeArguments; if (!isDecorator) { typeArguments = node.typeArguments; // We already perform checking on the type arguments on the class declaration itself. - if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 105 /* SuperKeyword */) { + if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 106 /* SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } @@ -69144,7 +71719,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 === 203 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 205 /* 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 @@ -69198,7 +71773,7 @@ var ts; var min_3 = Number.MAX_VALUE; var minIndex = 0; var i_1 = 0; - var _loop_21 = function (c) { + var _loop_22 = 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); if (diags_2) { @@ -69216,7 +71791,7 @@ var ts; }; for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) { var c = candidatesForArgumentError_1[_a]; - _loop_21(c); + _loop_22(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"); @@ -69374,7 +71949,7 @@ var ts; } var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max; var parameters = []; - var _loop_22 = function (i) { + var _loop_23 = 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; }); @@ -69382,7 +71957,7 @@ var ts; parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); }))); }; for (var i = 0; i < maxNonRestParam; i++) { - _loop_22(i); + _loop_23(i); } var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; }); var flags = 0 /* None */; @@ -69463,7 +72038,7 @@ var ts; return maxParamsIndex; } function resolveCallExpression(node, candidatesOutArray, checkMode) { - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (isTypeAny(superType)) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { @@ -69574,7 +72149,7 @@ 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 */ | 131072 /* Never */)) && isTypeAssignableTo(funcType, globalFunctionType); + !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & 1048576 /* Union */) && !(getReducedType(apparentFuncType).flags & 131072 /* Never */) && isTypeAssignableTo(funcType, globalFunctionType); } function resolveNewExpression(node, candidatesOutArray, checkMode) { if (node.arguments && languageVersion < 1 /* ES5 */) { @@ -69689,7 +72264,7 @@ var ts; var declaration = signature.declaration; var modifiers = ts.getSelectedEffectiveModifierFlags(declaration, 24 /* NonPublicAccessibilityModifier */); // (1) Public constructors and (2) constructor functions are always accessible. - if (!modifiers || declaration.kind !== 166 /* Constructor */) { + if (!modifiers || declaration.kind !== 168 /* Constructor */) { return true; } var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(declaration.parent.symbol); @@ -69833,16 +72408,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 160 /* Parameter */: + case 162 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; default: return ts.Debug.fail(); @@ -69888,7 +72463,7 @@ var ts; // 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(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.factory.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.factory.createKeywordTypeNode(128 /* AnyKeyword */)); + var declaration = ts.factory.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.factory.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.factory.createKeywordTypeNode(129 /* AnyKeyword */)); var parameterSymbol = createSymbol(1 /* FunctionScopedVariable */, "props"); parameterSymbol.type = result; return createSignature(declaration, @@ -69937,16 +72512,16 @@ var ts; } function resolveSignature(node, candidatesOutArray, checkMode) { switch (node.kind) { - case 203 /* CallExpression */: + case 205 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray, checkMode); - case 204 /* NewExpression */: + case 206 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray, checkMode); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode); - case 161 /* Decorator */: + case 163 /* Decorator */: return resolveDecorator(node, candidatesOutArray, checkMode); - case 275 /* JsxOpeningElement */: - case 274 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode); } throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); @@ -70046,7 +72621,7 @@ var ts; else if (ts.isBinaryExpression(node.parent)) { var parentNode = node.parent; var parentNodeOperator = node.parent.operatorToken.kind; - if (parentNodeOperator === 62 /* EqualsToken */ && (allowDeclaration || parentNode.right === node)) { + if (parentNodeOperator === 63 /* EqualsToken */ && (allowDeclaration || parentNode.right === node)) { name = parentNode.left; decl = name; } @@ -70055,7 +72630,7 @@ var ts; name = parentNode.parent.name; decl = parentNode.parent; } - else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 62 /* EqualsToken */ && (allowDeclaration || parentNode.parent.right === parentNode)) { + else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 63 /* EqualsToken */ && (allowDeclaration || parentNode.parent.right === parentNode)) { name = parentNode.parent.left; decl = name; } @@ -70078,10 +72653,10 @@ var ts; return false; } var parent = node.parent; - while (parent && parent.kind === 201 /* PropertyAccessExpression */) { + while (parent && parent.kind === 203 /* PropertyAccessExpression */) { parent = parent.parent; } - if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 62 /* EqualsToken */) { + if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 63 /* EqualsToken */) { var right = ts.getInitializerOfBinaryExpression(parent); return ts.isObjectLiteralExpression(right) && right; } @@ -70102,15 +72677,15 @@ var ts; return nonInferrableType; } checkDeprecatedSignature(signature, node); - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { return voidType; } - if (node.kind === 204 /* NewExpression */) { + if (node.kind === 206 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 166 /* Constructor */ && - declaration.kind !== 170 /* ConstructSignature */ && - declaration.kind !== 175 /* ConstructorType */ && + declaration.kind !== 168 /* Constructor */ && + declaration.kind !== 172 /* ConstructSignature */ && + declaration.kind !== 177 /* ConstructorType */ && !ts.isJSDocConstructSignature(declaration) && !isJSConstructor(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any @@ -70130,7 +72705,7 @@ var ts; if (returnType.flags & 12288 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent)); } - if (node.kind === 203 /* CallExpression */ && node.parent.kind === 233 /* ExpressionStatement */ && + if (node.kind === 205 /* CallExpression */ && !node.questionDotToken && node.parent.kind === 235 /* ExpressionStatement */ && returnType.flags & 16384 /* 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); @@ -70144,7 +72719,7 @@ 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, undefined, undefined); - jsAssignmentType.objectFlags |= 16384 /* JSLiteral */; + jsAssignmentType.objectFlags |= 8192 /* JSLiteral */; return getIntersectionType([returnType, jsAssignmentType]); } } @@ -70153,26 +72728,27 @@ var ts; function checkDeprecatedSignature(signature, node) { if (signature.declaration && signature.declaration.flags & 134217728 /* Deprecated */) { var suggestionNode = getDeprecatedSuggestionNode(node); - errorOrSuggestion(/*isError*/ false, suggestionNode, ts.Diagnostics._0_is_deprecated, signatureToString(signature)); + var name = ts.tryGetPropertyAccessOrIdentifierToString(ts.getInvokedExpression(node)); + addDeprecatedSuggestionWithSignature(suggestionNode, signature.declaration, name, signatureToString(signature)); } } function getDeprecatedSuggestionNode(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 203 /* CallExpression */: - case 161 /* Decorator */: - case 204 /* NewExpression */: + case 205 /* CallExpression */: + case 163 /* Decorator */: + case 206 /* NewExpression */: return getDeprecatedSuggestionNode(node.expression); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return getDeprecatedSuggestionNode(node.tag); - case 275 /* JsxOpeningElement */: - case 274 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: return getDeprecatedSuggestionNode(node.tagName); - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: return node.argumentExpression; - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return node.name; - case 173 /* TypeReference */: + case 175 /* TypeReference */: var typeReference = node; return ts.isQualifiedName(typeReference.typeName) ? typeReference.typeName.right : typeReference; default: @@ -70223,10 +72799,11 @@ var ts; return createPromiseReturnType(node, anyType); } function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol) { + var _a; if (allowSyntheticDefaultImports && type && type !== errorType) { var synthType = type; if (!synthType.syntheticType) { - var file = ts.find(originalSymbol.declarations, ts.isSourceFile); + var file = (_a = originalSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, /*dontResolveAlias*/ false); if (hasSyntheticDefault) { var memberTable = ts.createSymbolTable(); @@ -70264,9 +72841,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 251 /* FunctionDeclaration */ + ? 253 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 249 /* VariableDeclaration */ + ? 251 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -70294,21 +72871,21 @@ var ts; case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: - case 199 /* ArrayLiteralExpression */: - case 200 /* ObjectLiteralExpression */: - case 218 /* TemplateExpression */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: + case 201 /* ArrayLiteralExpression */: + case 202 /* ObjectLiteralExpression */: + case 220 /* TemplateExpression */: return true; - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return isValidConstAssertionArgument(node.expression); - case 214 /* PrefixUnaryExpression */: + case 216 /* 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 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: var expr = node.expression; if (ts.isIdentifier(expr)) { var symbol = getSymbolAtLocation(expr); @@ -70350,10 +72927,10 @@ var ts; } function checkMetaProperty(node) { checkGrammarMetaProperty(node); - if (node.keywordToken === 102 /* NewKeyword */) { + if (node.keywordToken === 103 /* NewKeyword */) { return checkNewTargetMetaProperty(node); } - if (node.keywordToken === 99 /* ImportKeyword */) { + if (node.keywordToken === 100 /* ImportKeyword */) { return checkImportMetaProperty(node); } return ts.Debug.assertNever(node.keywordToken); @@ -70364,7 +72941,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 === 166 /* Constructor */) { + else if (container.kind === 168 /* Constructor */) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -70411,7 +72988,7 @@ var ts; return restParameter.escapedName; } function isValidDeclarationForTupleLabel(d) { - return d.kind === 192 /* NamedTupleMember */ || (ts.isParameter(d) && d.name && ts.isIdentifier(d.name)); + return d.kind === 194 /* NamedTupleMember */ || (ts.isParameter(d) && d.name && ts.isIdentifier(d.name)); } function getNameableDeclarationAtPosition(signature, pos) { var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); @@ -70576,7 +73153,14 @@ var ts; } } function assignContextualParameterTypes(signature, context) { - signature.typeParameters = context.typeParameters; + if (context.typeParameters) { + if (!signature.typeParameters) { + signature.typeParameters = context.typeParameters; + } + else { + return; // This signature has already has a contextual inference performed and cached on it! + } + } if (context.thisParameter) { var parameter = signature.thisParameter; if (!parameter || parameter.valueDeclaration && !parameter.valueDeclaration.type) { @@ -70617,7 +73201,7 @@ var ts; if (!links.type) { var declaration = parameter.valueDeclaration; links.type = type || getWidenedTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true); - if (declaration.name.kind !== 78 /* Identifier */) { + if (declaration.name.kind !== 79 /* 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); @@ -70632,7 +73216,7 @@ var ts; for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { var element = _a[_i]; if (!ts.isOmittedExpression(element)) { - if (element.name.kind === 78 /* Identifier */) { + if (element.name.kind === 79 /* Identifier */) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } else { @@ -70687,7 +73271,7 @@ var ts; var yieldType; var nextType; var fallbackReturnType = voidType; - if (func.body.kind !== 230 /* Block */) { // Async or normal arrow function + if (func.body.kind !== 232 /* Block */) { // Async or normal arrow function returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8 /* SkipGenericFunctions */); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any @@ -70872,7 +73456,7 @@ var ts; return links.isExhaustive !== undefined ? links.isExhaustive : (links.isExhaustive = computeExhaustiveSwitchStatement(node)); } function computeExhaustiveSwitchStatement(node) { - if (node.expression.kind === 211 /* TypeOfExpression */) { + if (node.expression.kind === 213 /* TypeOfExpression */) { var operandType = getTypeOfExpression(node.expression.expression); var witnesses = getSwitchClauseTypeOfWitnesses(node, /*retainDefault*/ false); // notEqualFacts states that the type of the switched value is not equal to every type in the switch. @@ -70935,11 +73519,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return true; - case 165 /* MethodDeclaration */: - return func.parent.kind === 200 /* ObjectLiteralExpression */; + case 167 /* MethodDeclaration */: + return func.parent.kind === 202 /* ObjectLiteralExpression */; default: return false; } @@ -70965,21 +73549,21 @@ var ts; } // 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 === 164 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 230 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 166 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 232 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 512 /* HasExplicitReturn */; + var errorNode = ts.getEffectiveReturnTypeNode(func) || func; if (type && type.flags & 131072 /* Never */) { - error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); + error(errorNode, ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); } else if (type && !hasExplicitReturn) { // minimal check: function has syntactic return type annotation and no explicit return statements in the body // this function does not conform to the specification. - // NOTE: having returnType !== undefined is a precondition for entering this branch so func.type will always be present - error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value); + error(errorNode, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value); } else if (type && strictNullChecks && !isTypeAssignableTo(undefinedType, type)) { - error(ts.getEffectiveReturnTypeNode(func) || func, ts.Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined); + error(errorNode, ts.Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined); } else if (compilerOptions.noImplicitReturns) { if (!type) { @@ -70994,11 +73578,11 @@ var ts; return; } } - error(ts.getEffectiveReturnTypeNode(func) || func, ts.Diagnostics.Not_all_code_paths_return_a_value); + error(errorNode, ts.Diagnostics.Not_all_code_paths_return_a_value); } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 165 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 167 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); checkNodeDeferred(node); // The identityMapper object is used to indicate that function expressions are wildcards if (checkMode && checkMode & 4 /* SkipContextSensitive */ && isContextSensitive(node)) { @@ -71014,7 +73598,7 @@ var ts; var returnType = getReturnTypeFromBody(node, checkMode); var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); var returnOnlyType = createAnonymousType(node.symbol, emptySymbols, [returnOnlySignature], ts.emptyArray, undefined, undefined); - returnOnlyType.objectFlags |= 2097152 /* NonInferrableType */; + returnOnlyType.objectFlags |= 524288 /* NonInferrableType */; return links.contextFreeType = returnOnlyType; } } @@ -71022,7 +73606,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 208 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 210 /* FunctionExpression */) { checkGrammarForGenerator(node); } contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -71068,7 +73652,7 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 165 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 167 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnType = getReturnTypeFromAnnotation(node); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); @@ -71081,7 +73665,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 230 /* Block */) { + if (node.body.kind === 232 /* Block */) { checkSourceElement(node.body); } else { @@ -71168,10 +73752,10 @@ var ts; // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && ts.isAccessExpression(expr) && - expr.expression.kind === 107 /* ThisKeyword */) { + expr.expression.kind === 108 /* 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 === 166 /* Constructor */ || isJSConstructor(ctor)))) { + if (!(ctor && (ctor.kind === 168 /* Constructor */ || isJSConstructor(ctor)))) { return true; } if (symbol.valueDeclaration) { @@ -71192,11 +73776,11 @@ var ts; if (ts.isAccessExpression(expr)) { // references through namespace import should be readonly var node = ts.skipParentheses(expr.expression); - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { var symbol_2 = getNodeLinks(node).resolvedSymbol; if (symbol_2.flags & 2097152 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol_2); - return !!declaration && declaration.kind === 263 /* NamespaceImport */; + return !!declaration && declaration.kind === 265 /* NamespaceImport */; } } } @@ -71205,7 +73789,7 @@ 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 !== 78 /* Identifier */ && !ts.isAccessExpression(node)) { + if (node.kind !== 79 /* Identifier */ && !ts.isAccessExpression(node)) { error(expr, invalidReferenceMessage); return false; } @@ -71277,7 +73861,7 @@ var ts; 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); var func = ts.getContainingFunction(node); - if (func && func.kind !== 166 /* Constructor */ && (ts.getFunctionFlags(func) & 2 /* Async */) === 0) { + if (func && func.kind !== 168 /* Constructor */ && (ts.getFunctionFlags(func) & 2 /* Async */) === 0) { var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); } @@ -71444,14 +74028,33 @@ var ts; rightType = checkNonNullType(rightType, right); // TypeScript 1.0 spec (April 2014): 4.15.5 // The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, - // and the right operand to be of type Any, an object type, or a type parameter type. + // and the right operand to be + // + // 1. assignable to the non-primitive type, + // 2. an unconstrained type parameter, + // 3. a union or intersection including one or more type parameters, whose constituents are all assignable to the + // the non-primitive type, or are unconstrainted type parameters, or have constraints assignable to the + // non-primitive type, or + // 4. a type parameter whose constraint is + // i. an object type, + // ii. the non-primitive type, or + // iii. a union or intersection with at least one constituent assignable to an object or non-primitive type. + // + // The divergent behavior for type parameters and unions containing type parameters is a workaround for type + // parameters not being narrowable. If the right operand is a concrete type, we can error if there is any chance + // it is a primitive. But if the operand is a type parameter, it cannot be narrowed, so we don't issue an error + // unless *all* instantiations would result in an error. + // // The result is always of the Boolean primitive type. if (!(allTypesAssignableToKind(leftType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) || isTypeAssignableToKind(leftType, 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 262144 /* TypeParameter */))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } - if (!allTypesAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */)) { - error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); + 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 */))) { + error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_not_be_a_primitive); } return booleanType; } @@ -71470,7 +74073,7 @@ var ts; if (rightIsThis === void 0) { rightIsThis = false; } var properties = node.properties; var property = properties[propertyIndex]; - if (property.kind === 288 /* PropertyAssignment */ || property.kind === 289 /* ShorthandPropertyAssignment */) { + if (property.kind === 290 /* PropertyAssignment */ || property.kind === 291 /* ShorthandPropertyAssignment */) { var name = property.name; var exprType = getLiteralTypeFromPropertyName(name); if (isTypeUsableAsPropertyName(exprType)) { @@ -71478,14 +74081,14 @@ var ts; var prop = getPropertyOfType(objectLiteralType, text); if (prop) { markPropertyAsReferenced(prop, property, rightIsThis); - checkPropertyAccessibility(property, /*isSuper*/ false, objectLiteralType, prop); + checkPropertyAccessibility(property, /*isSuper*/ false, /*writing*/ true, objectLiteralType, prop); } } - var elementType = getIndexedAccessType(objectLiteralType, exprType, /*noUncheckedIndexedAccessCandidate*/ undefined, name, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, 16 /* ExpressionPosition */); + var elementType = getIndexedAccessType(objectLiteralType, exprType, 32 /* ExpressionPosition */, name); var type = getFlowTypeOfDestructuring(property, elementType); - return checkDestructuringAssignment(property.kind === 289 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); + return checkDestructuringAssignment(property.kind === 291 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); } - else if (property.kind === 290 /* SpreadAssignment */) { + else if (property.kind === 292 /* SpreadAssignment */) { if (propertyIndex < properties.length - 1) { error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } @@ -71523,7 +74126,7 @@ var ts; var inBoundsType = compilerOptions.noUncheckedIndexedAccess ? undefined : possiblyOutOfBoundsType; for (var i = 0; i < elements.length; i++) { var type = possiblyOutOfBoundsType; - if (node.elements[i].kind === 220 /* SpreadElement */) { + if (node.elements[i].kind === 222 /* SpreadElement */) { type = inBoundsType = inBoundsType !== null && inBoundsType !== void 0 ? inBoundsType : (checkIteratedTypeOrElementType(65 /* Destructuring */, sourceType, undefinedType, node) || errorType); } checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, type, checkMode); @@ -71533,14 +74136,14 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 222 /* OmittedExpression */) { - if (element.kind !== 220 /* SpreadElement */) { + if (element.kind !== 224 /* OmittedExpression */) { + if (element.kind !== 222 /* SpreadElement */) { var indexType = getLiteralType(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 = 16 /* ExpressionPosition */ | (hasDefaultValue(element) ? 8 /* NoTupleBoundsCheck */ : 0); - var elementType_2 = getIndexedAccessTypeOrUndefined(sourceType, indexType, /*noUncheckedIndexedAccessCandidate*/ undefined, createSyntheticExpression(element, indexType), accessFlags) || errorType; + var accessFlags = 32 /* ExpressionPosition */ | (hasDefaultValue(element) ? 16 /* 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 type = getFlowTypeOfDestructuring(element, assignedType); return checkDestructuringAssignment(element, type, checkMode); @@ -71552,7 +74155,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 216 /* BinaryExpression */ && restExpression.operatorToken.kind === 62 /* EqualsToken */) { + if (restExpression.kind === 218 /* BinaryExpression */ && restExpression.operatorToken.kind === 63 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -71568,7 +74171,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) { var target; - if (exprOrAssignment.kind === 289 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 291 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove @@ -71584,24 +74187,24 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 216 /* BinaryExpression */ && target.operatorToken.kind === 62 /* EqualsToken */) { + if (target.kind === 218 /* BinaryExpression */ && target.operatorToken.kind === 63 /* EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 200 /* ObjectLiteralExpression */) { + if (target.kind === 202 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, rightIsThis); } - if (target.kind === 199 /* ArrayLiteralExpression */) { + if (target.kind === 201 /* 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 === 290 /* SpreadAssignment */ ? + var error = target.parent.kind === 292 /* 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 === 290 /* SpreadAssignment */ ? + var optionalError = target.parent.kind === 292 /* 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)) { @@ -71623,39 +74226,39 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: case 10 /* StringLiteral */: case 13 /* RegularExpressionLiteral */: - case 205 /* TaggedTemplateExpression */: - case 218 /* TemplateExpression */: + case 207 /* TaggedTemplateExpression */: + case 220 /* TemplateExpression */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: - case 103 /* NullKeyword */: - case 150 /* UndefinedKeyword */: - case 208 /* FunctionExpression */: - case 221 /* ClassExpression */: - case 209 /* ArrowFunction */: - case 199 /* ArrayLiteralExpression */: - case 200 /* ObjectLiteralExpression */: - case 211 /* TypeOfExpression */: - case 225 /* NonNullExpression */: - case 274 /* JsxSelfClosingElement */: - case 273 /* JsxElement */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: + case 104 /* NullKeyword */: + case 151 /* UndefinedKeyword */: + case 210 /* FunctionExpression */: + case 223 /* ClassExpression */: + case 211 /* ArrowFunction */: + case 201 /* ArrayLiteralExpression */: + case 202 /* ObjectLiteralExpression */: + case 213 /* TypeOfExpression */: + case 227 /* NonNullExpression */: + case 276 /* JsxSelfClosingElement */: + case 275 /* JsxElement */: return true; - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 214 /* PrefixUnaryExpression */: - case 215 /* PostfixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { @@ -71667,9 +74270,9 @@ var ts; } return false; // Some forms listed here for clarity - case 212 /* VoidExpression */: // Explicit opt-out - case 206 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 224 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 214 /* VoidExpression */: // Explicit opt-out + case 208 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 226 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } @@ -71677,84 +74280,111 @@ var ts; function isTypeEqualityComparableTo(source, target) { return (target.flags & 98304 /* Nullable */) !== 0 || isTypeComparableTo(source, target); } - var CheckBinaryExpressionState; - (function (CheckBinaryExpressionState) { - CheckBinaryExpressionState[CheckBinaryExpressionState["MaybeCheckLeft"] = 0] = "MaybeCheckLeft"; - CheckBinaryExpressionState[CheckBinaryExpressionState["CheckRight"] = 1] = "CheckRight"; - CheckBinaryExpressionState[CheckBinaryExpressionState["FinishCheck"] = 2] = "FinishCheck"; - })(CheckBinaryExpressionState || (CheckBinaryExpressionState = {})); - function checkBinaryExpression(node, checkMode) { - var workStacks = { - expr: [node], - state: [0 /* MaybeCheckLeft */], - leftType: [undefined] + function createCheckBinaryExpression() { + var trampoline = ts.createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, foldState); + return function (node, checkMode) { + var result = trampoline(node, checkMode); + ts.Debug.assertIsDefined(result); + return result; }; - var stackIndex = 0; - var lastResult; - while (stackIndex >= 0) { - node = workStacks.expr[stackIndex]; - switch (workStacks.state[stackIndex]) { - case 0 /* MaybeCheckLeft */: { - if (ts.isInJSFile(node) && ts.getAssignedExpandoInitializer(node)) { - finishInvocation(checkExpression(node.right, checkMode)); - break; - } - checkGrammarNullishCoalesceWithLogicalExpression(node); - var operator = node.operatorToken.kind; - if (operator === 62 /* EqualsToken */ && (node.left.kind === 200 /* ObjectLiteralExpression */ || node.left.kind === 199 /* ArrayLiteralExpression */)) { - finishInvocation(checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 107 /* ThisKeyword */)); - break; - } - advanceState(1 /* CheckRight */); - maybeCheckExpression(node.left); - break; - } - case 1 /* CheckRight */: { - var leftType = lastResult; - workStacks.leftType[stackIndex] = leftType; - var operator = node.operatorToken.kind; - if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { - if (operator === 55 /* AmpersandAmpersandToken */) { - var parent = ts.walkUpParenthesizedExpressions(node.parent); - checkTestingKnownTruthyCallableType(node.left, leftType, ts.isIfStatement(parent) ? parent.thenStatement : undefined); - } - checkTruthinessOfType(leftType, node.left); + function onEnter(node, state, checkMode) { + if (state) { + state.stackIndex++; + state.skip = false; + setLeftType(state, /*type*/ undefined); + setLastResult(state, /*type*/ undefined); + } + else { + state = { + checkMode: checkMode, + skip: false, + stackIndex: 0, + typeStack: [undefined, undefined], + }; + } + if (ts.isInJSFile(node) && ts.getAssignedExpandoInitializer(node)) { + state.skip = true; + setLastResult(state, checkExpression(node.right, checkMode)); + return state; + } + checkGrammarNullishCoalesceWithLogicalExpression(node); + var operator = node.operatorToken.kind; + if (operator === 63 /* EqualsToken */ && (node.left.kind === 202 /* ObjectLiteralExpression */ || node.left.kind === 201 /* ArrayLiteralExpression */)) { + state.skip = true; + setLastResult(state, checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 108 /* ThisKeyword */)); + return state; + } + return state; + } + function onLeft(left, state, _node) { + if (!state.skip) { + return maybeCheckExpression(state, left); + } + } + function onOperator(operatorToken, state, node) { + if (!state.skip) { + var leftType = getLastResult(state); + ts.Debug.assertIsDefined(leftType); + 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); + checkTestingKnownTruthyCallableOrAwaitableType(node.left, leftType, ts.isIfStatement(parent) ? parent.thenStatement : undefined); } - advanceState(2 /* FinishCheck */); - maybeCheckExpression(node.right); - break; + checkTruthinessOfType(leftType, node.left); } - case 2 /* FinishCheck */: { - var leftType = workStacks.leftType[stackIndex]; - var rightType = lastResult; - finishInvocation(checkBinaryLikeExpressionWorker(node.left, node.operatorToken, node.right, leftType, rightType, node)); - break; - } - default: return ts.Debug.fail("Invalid state " + workStacks.state[stackIndex] + " for checkBinaryExpression"); } } - return lastResult; - function finishInvocation(result) { - lastResult = result; - stackIndex--; - } - /** - * Note that `advanceState` sets the _current_ head state, and that `maybeCheckExpression` potentially pushes on a new - * head state; so `advanceState` must be called before any `maybeCheckExpression` during a state's execution. - */ - function advanceState(nextState) { - workStacks.state[stackIndex] = nextState; + function onRight(right, state, _node) { + if (!state.skip) { + return maybeCheckExpression(state, right); + } } - function maybeCheckExpression(node) { - if (ts.isBinaryExpression(node)) { - stackIndex++; - workStacks.expr[stackIndex] = node; - workStacks.state[stackIndex] = 0 /* MaybeCheckLeft */; - workStacks.leftType[stackIndex] = undefined; + function onExit(node, state) { + var result; + if (state.skip) { + result = getLastResult(state); } else { - lastResult = checkExpression(node, checkMode); + var leftType = getLeftType(state); + ts.Debug.assertIsDefined(leftType); + var rightType = getLastResult(state); + ts.Debug.assertIsDefined(rightType); + result = checkBinaryLikeExpressionWorker(node.left, node.operatorToken, node.right, leftType, rightType, node); + } + state.skip = false; + setLeftType(state, /*type*/ undefined); + setLastResult(state, /*type*/ undefined); + state.stackIndex--; + return result; + } + function foldState(state, result, _side) { + setLastResult(state, result); + return state; + } + function maybeCheckExpression(state, node) { + if (ts.isBinaryExpression(node)) { + return node; } + setLastResult(state, checkExpression(node, state.checkMode)); + } + function getLeftType(state) { + return state.typeStack[state.stackIndex]; + } + function setLeftType(state, type) { + state.typeStack[state.stackIndex] = type; + } + function getLastResult(state) { + return state.typeStack[state.stackIndex + 1]; + } + function setLastResult(state, type) { + // To reduce overhead, reuse the next stack entry to store the + // last result. This avoids the overhead of an additional property + // on `WorkArea` and reuses empty stack entries as we walk back up + // the stack. + state.typeStack[state.stackIndex + 1] = type; } } function checkGrammarNullishCoalesceWithLogicalExpression(node) { @@ -71772,8 +74402,8 @@ 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 === 62 /* EqualsToken */ && (left.kind === 200 /* ObjectLiteralExpression */ || left.kind === 199 /* ArrayLiteralExpression */)) { - return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 107 /* ThisKeyword */); + if (operator === 63 /* EqualsToken */ && (left.kind === 202 /* ObjectLiteralExpression */ || left.kind === 201 /* ArrayLiteralExpression */)) { + return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 108 /* ThisKeyword */); } var leftType; if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { @@ -71790,26 +74420,26 @@ var ts; switch (operator) { case 41 /* AsteriskToken */: case 42 /* AsteriskAsteriskToken */: - case 65 /* AsteriskEqualsToken */: - case 66 /* AsteriskAsteriskEqualsToken */: + case 66 /* AsteriskEqualsToken */: + case 67 /* AsteriskAsteriskEqualsToken */: case 43 /* SlashToken */: - case 67 /* SlashEqualsToken */: + case 68 /* SlashEqualsToken */: case 44 /* PercentToken */: - case 68 /* PercentEqualsToken */: + case 69 /* PercentEqualsToken */: case 40 /* MinusToken */: - case 64 /* MinusEqualsToken */: + case 65 /* MinusEqualsToken */: case 47 /* LessThanLessThanToken */: - case 69 /* LessThanLessThanEqualsToken */: + case 70 /* LessThanLessThanEqualsToken */: case 48 /* GreaterThanGreaterThanToken */: - case 70 /* GreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanEqualsToken */: case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: case 51 /* BarToken */: - case 73 /* BarEqualsToken */: + case 74 /* BarEqualsToken */: case 52 /* CaretToken */: - case 77 /* CaretEqualsToken */: + case 78 /* CaretEqualsToken */: case 50 /* AmpersandToken */: - case 72 /* AmpersandEqualsToken */: + case 73 /* AmpersandEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -71839,11 +74469,11 @@ var ts; else if (bothAreBigIntLike(leftType, rightType)) { switch (operator) { case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: reportOperatorError(); break; case 42 /* AsteriskAsteriskToken */: - case 66 /* AsteriskAsteriskEqualsToken */: + case 67 /* AsteriskAsteriskEqualsToken */: if (languageVersion < 3 /* ES2016 */) { error(errorNode, ts.Diagnostics.Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_later); } @@ -71861,7 +74491,7 @@ var ts; return resultType_1; } case 39 /* PlusToken */: - case 63 /* PlusEqualsToken */: + case 64 /* PlusEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -71904,7 +74534,7 @@ var ts; }); return anyType; } - if (operator === 63 /* PlusEqualsToken */) { + if (operator === 64 /* PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; @@ -71926,41 +74556,41 @@ var ts; case 37 /* ExclamationEqualsEqualsToken */: reportOperatorErrorUnless(function (left, right) { return isTypeEqualityComparableTo(left, right) || isTypeEqualityComparableTo(right, left); }); return booleanType; - case 101 /* InstanceOfKeyword */: + case 102 /* InstanceOfKeyword */: return checkInstanceOfExpression(left, right, leftType, rightType); - case 100 /* InKeyword */: + case 101 /* InKeyword */: return checkInExpression(left, right, leftType, rightType); case 55 /* AmpersandAmpersandToken */: - case 75 /* AmpersandAmpersandEqualsToken */: { + case 76 /* AmpersandAmpersandEqualsToken */: { var resultType_2 = getTypeFacts(leftType) & 4194304 /* Truthy */ ? getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) : leftType; - if (operator === 75 /* AmpersandAmpersandEqualsToken */) { + if (operator === 76 /* AmpersandAmpersandEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_2; } case 56 /* BarBarToken */: - case 74 /* BarBarEqualsToken */: { + case 75 /* BarBarEqualsToken */: { var resultType_3 = getTypeFacts(leftType) & 8388608 /* Falsy */ ? getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2 /* Subtype */) : leftType; - if (operator === 74 /* BarBarEqualsToken */) { + if (operator === 75 /* BarBarEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_3; } case 60 /* QuestionQuestionToken */: - case 76 /* QuestionQuestionEqualsToken */: { + case 77 /* QuestionQuestionEqualsToken */: { var resultType_4 = getTypeFacts(leftType) & 262144 /* EQUndefinedOrNull */ ? getUnionType([getNonNullableType(leftType), rightType], 2 /* Subtype */) : leftType; - if (operator === 76 /* QuestionQuestionEqualsToken */) { + if (operator === 77 /* QuestionQuestionEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_4; } - case 62 /* EqualsToken */: + case 63 /* EqualsToken */: var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0 /* None */; checkAssignmentDeclaration(declKind, rightType); if (isAssignmentDeclaration(declKind)) { @@ -72007,7 +74637,7 @@ var ts; if (propType.symbol && propType.symbol.flags & 32 /* Class */) { var name = prop.escapedName; var symbol = resolveName(prop.valueDeclaration, name, 788968 /* Type */, undefined, name, /*isUse*/ false); - if (symbol && symbol.declarations.some(ts.isJSDocTypedefTag)) { + 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); } @@ -72016,7 +74646,7 @@ var ts; } } function isEvalNode(node) { - return node.kind === 78 /* Identifier */ && node.escapedText === "eval"; + return node.kind === 79 /* Identifier */ && node.escapedText === "eval"; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { @@ -72032,13 +74662,13 @@ var ts; function getSuggestedBooleanOperator(operator) { switch (operator) { case 51 /* BarToken */: - case 73 /* BarEqualsToken */: + case 74 /* BarEqualsToken */: return 56 /* BarBarToken */; case 52 /* CaretToken */: - case 77 /* CaretEqualsToken */: + case 78 /* CaretEqualsToken */: return 37 /* ExclamationEqualsEqualsToken */; case 50 /* AmpersandToken */: - case 72 /* AmpersandEqualsToken */: + case 73 /* AmpersandEqualsToken */: return 55 /* AmpersandAmpersandToken */; default: return undefined; @@ -72202,7 +74832,7 @@ var ts; } function checkConditionalExpression(node, checkMode) { var type = checkTruthinessExpression(node.condition); - checkTestingKnownTruthyCallableType(node.condition, type, node.whenTrue); + checkTestingKnownTruthyCallableOrAwaitableType(node.condition, type, node.whenTrue); var type1 = checkExpression(node.whenTrue, checkMode); var type2 = checkExpression(node.whenFalse, checkMode); return getUnionType([type1, type2], 2 /* Subtype */); @@ -72219,10 +74849,14 @@ var ts; texts.push(span.literal.text); types.push(isTypeAssignableTo(type, templateConstraintType) ? type : stringType); } - return getFreshTypeOfLiteralType(getTemplateLiteralType(texts, types)); + return isConstContext(node) || someType(getContextualType(node) || 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 */)); } function getContextNode(node) { - if (node.kind === 281 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { + if (node.kind === 283 /* 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; @@ -72238,7 +74872,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, 134220672 /* FreshableLiteral */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ? + var result = maybeTypeOfKind(type, 2944 /* Literal */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ? getRegularTypeOfLiteralType(type) : type; return result; } @@ -72271,13 +74905,13 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 206 /* TypeAssertionExpression */ || node.kind === 224 /* AsExpression */; + return node.kind === 208 /* TypeAssertionExpression */ || node.kind === 226 /* AsExpression */; } function checkDeclarationInitializer(declaration, contextualType) { var initializer = ts.getEffectiveInitializer(declaration); var type = getQuickTypeOfExpression(initializer) || (contextualType ? checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, 0 /* Normal */) : checkExpressionCached(initializer)); - return ts.isParameter(declaration) && declaration.name.kind === 197 /* ArrayBindingPattern */ && + return ts.isParameter(declaration) && declaration.name.kind === 199 /* ArrayBindingPattern */ && isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ? padTupleType(type, declaration.name) : type; } @@ -72287,7 +74921,7 @@ 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 === 198 /* BindingElement */ && e.dotDotDotToken)) { + if (i < patternElements.length - 1 || !(e.kind === 200 /* BindingElement */ && e.dotDotDotToken)) { elementTypes.push(!ts.isOmittedExpression(e) && hasDefaultValue(e) ? getTypeFromBindingElement(e, /*includePatternInType*/ false, /*reportErrors*/ false) : anyType); elementFlags.push(2 /* Optional */); if (!ts.isOmittedExpression(e) && !hasDefaultValue(e)) { @@ -72300,7 +74934,7 @@ var ts; function widenTypeInferredFromInitializer(declaration, type) { var widened = ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || ts.isDeclarationReadonly(declaration) ? type : getWidenedLiteralType(type); if (ts.isInJSFile(declaration)) { - if (widened.flags & 98304 /* Nullable */) { + if (isEmptyLiteralType(widened)) { reportImplicitAny(declaration, anyType); return anyType; } @@ -72322,7 +74956,7 @@ var ts; // 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, 134217856 /* StringLikeLiteral */) || + 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 */) || @@ -72330,7 +74964,7 @@ var ts; } // 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 & (134217856 /* StringLikeLiteral */ | 4194304 /* Index */ | 268435456 /* StringMapping */) && maybeTypeOfKind(candidateType, 134217856 /* StringLikeLiteral */) || + 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 */) || @@ -72354,7 +74988,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 === 158 /* ComputedPropertyName */) { + if (node.name.kind === 160 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); @@ -72365,7 +74999,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 === 158 /* ComputedPropertyName */) { + if (node.name.kind === 160 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -72492,7 +75126,7 @@ var ts; len--; var s = baseName.slice(0, len); for (var index = 1; true; index++) { - var augmentedName = (s + index); + var augmentedName = s + index; if (!hasTypeParameterByName(typeParameters, augmentedName)) { return augmentedName; } @@ -72541,7 +75175,7 @@ var ts; var 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 !== 105 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { + if (ts.isCallExpression(expr) && expr.expression.kind !== 106 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { var type = ts.isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) : getReturnTypeOfSingleNonGenericCallSignature(checkNonNullExpression(expr.expression)); if (type) { @@ -72552,7 +75186,7 @@ var ts; return getTypeFromTypeNode(expr.type); } else if (node.kind === 8 /* NumericLiteral */ || node.kind === 10 /* StringLiteral */ || - node.kind === 109 /* TrueKeyword */ || node.kind === 94 /* FalseKeyword */) { + node.kind === 110 /* TrueKeyword */ || node.kind === 95 /* FalseKeyword */) { return checkExpression(node); } return undefined; @@ -72583,7 +75217,7 @@ var ts; } } function checkExpression(node, checkMode, forceTuple) { - ts.tracing.push("check" /* Check */, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end }); var saveCurrentNode = currentNode; currentNode = node; instantiationCount = 0; @@ -72593,7 +75227,7 @@ var ts; checkConstEnumAccess(node, type); } currentNode = saveCurrentNode; - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return type; } function checkConstEnumAccess(node, type) { @@ -72601,11 +75235,11 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 201 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 202 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 78 /* Identifier */ || node.kind === 157 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 176 /* TypeQuery */ && node.parent.exprName === node)) || - (node.parent.kind === 270 /* ExportSpecifier */); // We allow reexporting const enums + var ok = (node.parent.kind === 203 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 204 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 79 /* Identifier */ || node.kind === 159 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 178 /* TypeQuery */ && node.parent.exprName === node)) || + (node.parent.kind === 272 /* 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); } @@ -72620,7 +75254,7 @@ var ts; function checkParenthesizedExpression(node, checkMode) { var tag = ts.isInJSFile(node) ? ts.getJSDocTypeTag(node) : undefined; if (tag) { - return checkAssertionWorker(tag, tag.typeExpression.type, node.expression, checkMode); + return checkAssertionWorker(tag.typeExpression.type, tag.typeExpression.type, node.expression, checkMode); } return checkExpression(node.expression, checkMode); } @@ -72630,20 +75264,20 @@ 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 221 /* ClassExpression */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 223 /* ClassExpression */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 78 /* Identifier */: - return checkIdentifier(node); - case 107 /* ThisKeyword */: + case 79 /* Identifier */: + return checkIdentifier(node, checkMode); + case 108 /* ThisKeyword */: return checkThisExpression(node); - case 105 /* SuperKeyword */: + case 106 /* SuperKeyword */: return checkSuperExpression(node); - case 103 /* NullKeyword */: + case 104 /* NullKeyword */: return nullWideningType; case 14 /* NoSubstitutionTemplateLiteral */: case 10 /* StringLiteral */: @@ -72654,82 +75288,82 @@ var ts; case 9 /* BigIntLiteral */: checkGrammarBigIntLiteral(node); return getFreshTypeOfLiteralType(getBigIntLiteralType(node)); - case 109 /* TrueKeyword */: + case 110 /* TrueKeyword */: return trueType; - case 94 /* FalseKeyword */: + case 95 /* FalseKeyword */: return falseType; - case 218 /* TemplateExpression */: + case 220 /* TemplateExpression */: return checkTemplateExpression(node); case 13 /* RegularExpressionLiteral */: return globalRegExpType; - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode, forceTuple); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 201 /* PropertyAccessExpression */: - return checkPropertyAccessExpression(node); - case 157 /* QualifiedName */: - return checkQualifiedName(node); - case 202 /* ElementAccessExpression */: - return checkIndexedAccess(node); - case 203 /* CallExpression */: - if (node.expression.kind === 99 /* ImportKeyword */) { + case 203 /* PropertyAccessExpression */: + return checkPropertyAccessExpression(node, checkMode); + case 159 /* QualifiedName */: + return checkQualifiedName(node, checkMode); + case 204 /* ElementAccessExpression */: + return checkIndexedAccess(node, checkMode); + case 205 /* CallExpression */: + if (node.expression.kind === 100 /* ImportKeyword */) { return checkImportCallExpression(node); } // falls through - case 204 /* NewExpression */: + case 206 /* NewExpression */: return checkCallExpression(node, checkMode); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: return checkClassExpression(node); - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 211 /* TypeOfExpression */: + case 213 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 206 /* TypeAssertionExpression */: - case 224 /* AsExpression */: + case 208 /* TypeAssertionExpression */: + case 226 /* AsExpression */: return checkAssertion(node); - case 225 /* NonNullExpression */: + case 227 /* NonNullExpression */: return checkNonNullAssertion(node); - case 226 /* MetaProperty */: + case 228 /* MetaProperty */: return checkMetaProperty(node); - case 210 /* DeleteExpression */: + case 212 /* DeleteExpression */: return checkDeleteExpression(node); - case 212 /* VoidExpression */: + case 214 /* VoidExpression */: return checkVoidExpression(node); - case 213 /* AwaitExpression */: + case 215 /* AwaitExpression */: return checkAwaitExpression(node); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 220 /* SpreadElement */: + case 222 /* SpreadElement */: return checkSpreadExpression(node, checkMode); - case 222 /* OmittedExpression */: + case 224 /* OmittedExpression */: return undefinedWideningType; - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: return checkYieldExpression(node); - case 227 /* SyntheticExpression */: + case 229 /* SyntheticExpression */: return checkSyntheticExpression(node); - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: return checkJsxExpression(node, checkMode); - case 273 /* JsxElement */: + case 275 /* JsxElement */: return checkJsxElement(node, checkMode); - case 274 /* JsxSelfClosingElement */: + case 276 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 277 /* JsxFragment */: + case 279 /* JsxFragment */: return checkJsxFragment(node); - case 281 /* JsxAttributes */: + case 283 /* JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 275 /* JsxOpeningElement */: + case 277 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -72765,11 +75399,11 @@ var ts; checkGrammarDecoratorsAndModifiers(node); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); - if (ts.hasSyntacticModifier(node, 92 /* ParameterPropertyModifier */)) { - if (!(func.kind === 166 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */)) { + if (!(func.kind === 168 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } - if (func.kind === 166 /* Constructor */ && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") { + if (func.kind === 168 /* Constructor */ && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") { error(node.name, ts.Diagnostics.constructor_cannot_be_used_as_a_parameter_property_name); } } @@ -72780,13 +75414,13 @@ var ts; if (func.parameters.indexOf(node) !== 0) { error(node, ts.Diagnostics.A_0_parameter_must_be_the_first_parameter, node.name.escapedText); } - if (func.kind === 166 /* Constructor */ || func.kind === 170 /* ConstructSignature */ || func.kind === 175 /* ConstructorType */) { + if (func.kind === 168 /* Constructor */ || func.kind === 172 /* ConstructSignature */ || func.kind === 177 /* ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } - if (func.kind === 209 /* ArrowFunction */) { + if (func.kind === 211 /* ArrowFunction */) { error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter); } - if (func.kind === 167 /* GetAccessor */ || func.kind === 168 /* SetAccessor */) { + if (func.kind === 169 /* GetAccessor */ || func.kind === 170 /* SetAccessor */) { error(node, ts.Diagnostics.get_and_set_accessors_cannot_declare_this_parameters); } } @@ -72844,13 +75478,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 209 /* ArrowFunction */: - case 169 /* CallSignature */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 174 /* FunctionType */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 211 /* ArrowFunction */: + case 171 /* CallSignature */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 176 /* FunctionType */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: var parent = node.parent; if (node === parent.type) { return parent; @@ -72864,11 +75498,11 @@ var ts; continue; } var name = element.name; - if (name.kind === 78 /* Identifier */ && name.escapedText === predicateVariableName) { + if (name.kind === 79 /* 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 === 197 /* ArrayBindingPattern */ || name.kind === 196 /* ObjectBindingPattern */) { + else if (name.kind === 199 /* ArrayBindingPattern */ || name.kind === 198 /* ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -72877,13 +75511,13 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 171 /* IndexSignature */) { + if (node.kind === 173 /* 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 === 174 /* FunctionType */ || node.kind === 251 /* FunctionDeclaration */ || node.kind === 175 /* ConstructorType */ || - node.kind === 169 /* CallSignature */ || node.kind === 166 /* Constructor */ || - node.kind === 170 /* ConstructSignature */) { + else if (node.kind === 176 /* FunctionType */ || node.kind === 253 /* FunctionDeclaration */ || node.kind === 177 /* ConstructorType */ || + node.kind === 171 /* CallSignature */ || node.kind === 168 /* Constructor */ || + node.kind === 172 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); @@ -72913,10 +75547,10 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 170 /* ConstructSignature */: + case 172 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 169 /* CallSignature */: + case 171 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -72946,7 +75580,7 @@ var ts; checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 171 /* IndexSignature */ && node.kind !== 308 /* JSDocFunctionType */) { + if (node.kind !== 173 /* IndexSignature */ && node.kind !== 311 /* JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } @@ -72958,7 +75592,7 @@ 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 === 166 /* Constructor */) { + if (member.kind === 168 /* 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)) { @@ -72970,25 +75604,27 @@ var ts; var isStatic = ts.hasSyntacticModifier(member, 32 /* Static */); var name = member.name; if (!name) { - return; + continue; } - var names = ts.isPrivateIdentifier(name) ? privateIdentifiers : + var isPrivate = ts.isPrivateIdentifier(name); + var privateStaticFlags = isPrivate && isStatic ? 16 /* PrivateStatic */ : 0; + var names = isPrivate ? privateIdentifiers : isStatic ? staticNames : instanceNames; var memberName = name && ts.getPropertyNameForPropertyNameNode(name); if (memberName) { switch (member.kind) { - case 167 /* GetAccessor */: - addName(names, name, memberName, 1 /* GetAccessor */); + case 169 /* GetAccessor */: + addName(names, name, memberName, 1 /* GetAccessor */ | privateStaticFlags); break; - case 168 /* SetAccessor */: - addName(names, name, memberName, 2 /* SetAccessor */); + case 170 /* SetAccessor */: + addName(names, name, memberName, 2 /* SetAccessor */ | privateStaticFlags); break; - case 163 /* PropertyDeclaration */: - addName(names, name, memberName, 3 /* GetOrSetAccessor */); + case 165 /* PropertyDeclaration */: + addName(names, name, memberName, 3 /* GetOrSetAccessor */ | privateStaticFlags); break; - case 165 /* MethodDeclaration */: - addName(names, name, memberName, 8 /* Method */); + case 167 /* MethodDeclaration */: + addName(names, name, memberName, 8 /* Method */ | privateStaticFlags); break; } } @@ -72997,16 +75633,25 @@ var ts; function addName(names, location, name, meaning) { var prev = names.get(name); if (prev) { - if (prev & 8 /* Method */) { - if (meaning !== 8 /* Method */) { - error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); - } - } - else if (prev & meaning) { - error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); + // For private identifiers, do not allow mixing of static and instance members with the same name + if ((prev & 16 /* PrivateStatic */) !== (meaning & 16 /* PrivateStatic */)) { + error(location, ts.Diagnostics.Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name, ts.getTextOfNode(location)); } else { - names.set(name, prev | meaning); + var prevIsMethod = !!(prev & 8 /* Method */); + var isMethod = !!(meaning & 8 /* 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 */) { + error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); + } + else { + names.set(name, prev | meaning); + } } } else { @@ -73050,7 +75695,7 @@ 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 === 162 /* PropertySignature */) { + if (member.kind === 164 /* PropertySignature */) { var memberName = void 0; var name = member.name; switch (name.kind) { @@ -73058,7 +75703,7 @@ var ts; case 8 /* NumericLiteral */: memberName = name.text; break; - case 78 /* Identifier */: + case 79 /* Identifier */: memberName = ts.idText(name); break; default: @@ -73075,11 +75720,11 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 253 /* InterfaceDeclaration */) { + if (node.kind === 255 /* 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 - if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { + if (nodeSymbol.declarations && nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; } } @@ -73087,7 +75732,7 @@ var ts; // 3.7.4: An object type can contain at most one string index signature and one numeric index signature. // 8.5: A class declaration can have at most one string index member declaration and one numeric index member declaration var indexSymbol = getIndexSymbol(getSymbolOfNode(node)); - if (indexSymbol) { + if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) { var seenNumericIndexer = false; var seenStringIndexer = false; for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -73095,7 +75740,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 147 /* StringKeyword */: + case 148 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -73103,7 +75748,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 144 /* NumberKeyword */: + case 145 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -73121,11 +75766,13 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && !checkGrammarProperty(node)) checkGrammarComputedPropertyName(node.name); checkVariableLikeDeclaration(node); - // Private class fields transformation relies on WeakMaps. - if (ts.isPrivateIdentifier(node.name) && languageVersion < 99 /* ESNext */) { - for (var lexicalScope = ts.getEnclosingBlockScopeContainer(node); !!lexicalScope; lexicalScope = ts.getEnclosingBlockScopeContainer(lexicalScope)) { - getNodeLinks(lexicalScope).flags |= 67108864 /* ContainsClassWithPrivateIdentifiers */; - } + setNodeLinksForPrivateIdentifierScope(node); + if (ts.isPrivateIdentifier(node.name) && ts.hasStaticModifier(node) && node.initializer && languageVersion === 99 /* ESNext */ && !compilerOptions.useDefineForClassFields) { + error(node.initializer, ts.Diagnostics.Static_fields_with_private_names_can_t_have_initializers_when_the_useDefineForClassFields_flag_is_not_specified_with_a_target_of_esnext_Consider_adding_the_useDefineForClassFields_flag); + } + // property signatures already report "initializer not allowed in ambient context" elsewhere + if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 165 /* PropertyDeclaration */ && node.initializer) { + error(node, ts.Diagnostics.Property_0_cannot_have_an_initializer_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } function checkPropertySignature(node) { @@ -73138,16 +75785,34 @@ var ts; // Grammar checking if (!checkGrammarMethod(node)) checkGrammarComputedPropertyName(node.name); - if (ts.isPrivateIdentifier(node.name)) { - error(node, ts.Diagnostics.A_method_cannot_be_named_with_a_private_identifier); - } // Grammar checking for modifiers is done inside the function checkGrammarFunctionLikeDeclaration checkFunctionOrMethodDeclaration(node); - // Abstract methods cannot have an implementation. - // Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node. - if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 165 /* MethodDeclaration */ && node.body) { + // method signatures already report "implementation not allowed in ambient context" elsewhere + if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 167 /* 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 + if (ts.isPrivateIdentifier(node.name) && !ts.getContainingClass(node)) { + error(node, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); + } + setNodeLinksForPrivateIdentifierScope(node); + } + function setNodeLinksForPrivateIdentifierScope(node) { + if (ts.isPrivateIdentifier(node.name) && languageVersion < 99 /* ESNext */) { + for (var lexicalScope = ts.getEnclosingBlockScopeContainer(node); !!lexicalScope; lexicalScope = ts.getEnclosingBlockScopeContainer(lexicalScope)) { + getNodeLinks(lexicalScope).flags |= 67108864 /* 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 + // to transform private elements. + if (ts.isClassExpression(node.parent)) { + var enclosingIterationStatement = getEnclosingIterationStatement(node.parent); + if (enclosingIterationStatement) { + getNodeLinks(node.name).flags |= 524288 /* BlockScopedBindingInLoop */; + getNodeLinks(enclosingIterationStatement).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */; + } + } + } } function checkConstructorDeclaration(node) { // Grammar check on signature of constructor and modifier of the constructor is done in checkSignatureDeclaration function. @@ -73170,10 +75835,10 @@ var ts; return; } function isInstancePropertyWithInitializerOrPrivateIdentifierProperty(n) { - if (ts.isPrivateIdentifierPropertyDeclaration(n)) { + if (ts.isPrivateIdentifierClassElementDeclaration(n)) { return true; } - return n.kind === 163 /* PropertyDeclaration */ && + return n.kind === 165 /* PropertyDeclaration */ && !ts.hasSyntacticModifier(n, 32 /* Static */) && !!n.initializer; } @@ -73194,9 +75859,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 superCallShouldBeFirst = (compilerOptions.target !== 99 /* ESNext */ || !compilerOptions.useDefineForClassFields) && + var superCallShouldBeFirst = (compilerOptions.target !== 99 /* ESNext */ || !useDefineForClassFields) && (ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) || - ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 92 /* ParameterPropertyModifier */); })); + ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476 /* ParameterPropertyModifier */); })); // Skip past any prologue directives to find the first statement // to ensure that it was a super call. if (superCallShouldBeFirst) { @@ -73204,7 +75869,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_4 = statements; _i < statements_4.length; _i++) { var statement = statements_4[_i]; - if (statement.kind === 233 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 235 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -73229,7 +75894,7 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 167 /* GetAccessor */) { + if (node.kind === 169 /* GetAccessor */) { if (!(node.flags & 8388608 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* HasImplicitReturn */)) { if (!(node.flags & 512 /* HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); @@ -73239,45 +75904,42 @@ 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 === 158 /* ComputedPropertyName */) { + if (node.name.kind === 160 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } - if (ts.isPrivateIdentifier(node.name)) { - error(node.name, ts.Diagnostics.An_accessor_cannot_be_named_with_a_private_identifier); - } - if (!hasNonBindableDynamicName(node)) { + if (hasBindableName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. - var otherKind = node.kind === 167 /* GetAccessor */ ? 168 /* SetAccessor */ : 167 /* GetAccessor */; - var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); - if (otherAccessor) { - var nodeFlags = ts.getEffectiveModifierFlags(node); - var otherFlags = ts.getEffectiveModifierFlags(otherAccessor); - if ((nodeFlags & 28 /* AccessibilityModifier */) !== (otherFlags & 28 /* AccessibilityModifier */)) { - error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); + var symbol = getSymbolOfNode(node); + var getter = ts.getDeclarationOfKind(symbol, 169 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 170 /* SetAccessor */); + if (getter && setter && !(getNodeCheckFlags(getter) & 1 /* TypeChecked */)) { + getNodeLinks(getter).flags |= 1 /* TypeChecked */; + var getterFlags = ts.getEffectiveModifierFlags(getter); + var setterFlags = ts.getEffectiveModifierFlags(setter); + if ((getterFlags & 128 /* Abstract */) !== (setterFlags & 128 /* 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 */))) { + 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); } - if ((nodeFlags & 128 /* Abstract */) !== (otherFlags & 128 /* Abstract */)) { - error(node.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); + var getterType = getAnnotatedAccessorType(getter); + var setterType = getAnnotatedAccessorType(setter); + if (getterType && setterType) { + checkTypeAssignableTo(getterType, setterType, getter, ts.Diagnostics.The_return_type_of_a_get_accessor_must_be_assignable_to_its_set_accessor_type); } - // TypeScript 1.0 spec (April 2014): 4.5 - // If both accessors include type annotations, the specified types must be identical. - checkAccessorDeclarationTypesIdentical(node, otherAccessor, getAnnotatedAccessorType, ts.Diagnostics.get_and_set_accessor_must_have_the_same_type); - checkAccessorDeclarationTypesIdentical(node, otherAccessor, getThisTypeOfDeclaration, ts.Diagnostics.get_and_set_accessor_must_have_the_same_this_type); } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 167 /* GetAccessor */) { + if (node.kind === 169 /* GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } checkSourceElement(node.body); - } - function checkAccessorDeclarationTypesIdentical(first, second, getAnnotatedType, message) { - var firstType = getAnnotatedType(first); - var secondType = getAnnotatedType(second); - if (firstType && secondType && !isTypeIdenticalTo(firstType, secondType)) { - error(first, message); - } + setNodeLinksForPrivateIdentifierScope(node); } function checkMissingDeclaration(node) { checkDecorators(node); @@ -73314,7 +75976,7 @@ var ts; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 173 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 175 /* 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); @@ -73329,7 +75991,7 @@ var ts; var symbol = getNodeLinks(node).resolvedSymbol; if (symbol) { if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 134217728 /* Deprecated */); })) { - errorOrSuggestion(/* isError */ false, getDeprecatedSuggestionNode(node), ts.Diagnostics._0_is_deprecated, symbol.escapedName); + addDeprecatedSuggestion(getDeprecatedSuggestionNode(node), symbol.declarations, symbol.escapedName); } if (type.flags & 32 /* Enum */ && symbol.flags & 8 /* EnumMember */) { error(node, ts.Diagnostics.Enum_type_0_has_members_with_initializers_that_are_not_literals, typeToString(type)); @@ -73367,7 +76029,7 @@ 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 !== 192 /* NamedTupleMember */ && hasNamedElement) { + if (e.kind !== 194 /* NamedTupleMember */ && hasNamedElement) { grammarErrorOnNode(e, ts.Diagnostics.Tuple_members_must_all_have_names_or_all_not_have_names); break; } @@ -73416,7 +76078,7 @@ var ts; var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, /*stringsOnly*/ false))) { - if (accessNode.kind === 202 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 204 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && ts.getObjectFlags(objectType) & 32 /* Mapped */ && getMappedTypeModifiers(objectType) & 1 /* IncludeReadonly */) { error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); } @@ -73474,7 +76136,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 184 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 186 /* 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); @@ -73497,25 +76159,25 @@ var ts; if (node.dotDotDotToken && node.questionToken) { grammarErrorOnNode(node, ts.Diagnostics.A_tuple_member_cannot_be_both_optional_and_rest); } - if (node.type.kind === 180 /* OptionalType */) { + if (node.type.kind === 182 /* 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 === 181 /* RestType */) { + if (node.type.kind === 183 /* 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.isPrivateIdentifierPropertyDeclaration(node)) && !!(node.flags & 8388608 /* Ambient */); + return (ts.hasEffectiveModifier(node, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 8388608 /* 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 !== 253 /* InterfaceDeclaration */ && - n.parent.kind !== 252 /* ClassDeclaration */ && - n.parent.kind !== 221 /* ClassExpression */ && + if (n.parent.kind !== 255 /* InterfaceDeclaration */ && + n.parent.kind !== 254 /* ClassDeclaration */ && + n.parent.kind !== 223 /* ClassExpression */ && n.flags & 8388608 /* Ambient */) { if (!(flags & 2 /* 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 @@ -73611,7 +76273,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 === 165 /* MethodDeclaration */ || node.kind === 164 /* MethodSignature */) && + var reportError = (node.kind === 167 /* MethodDeclaration */ || node.kind === 166 /* MethodSignature */) && ts.hasSyntacticModifier(node, 32 /* Static */) !== ts.hasSyntacticModifier(subsequentNode, 32 /* Static */); // we can get here in two cases // 1. mixed static and instance class members @@ -73648,55 +76310,57 @@ var ts; var multipleConstructorImplementation = false; var hasNonAmbientClass = false; var functionDeclarations = []; - for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { - var current = declarations_4[_i]; - var node = current; - var inAmbientContext = node.flags & 8388608 /* Ambient */; - var inAmbientContextOrInterface = node.parent && (node.parent.kind === 253 /* InterfaceDeclaration */ || node.parent.kind === 177 /* TypeLiteral */) || inAmbientContext; - if (inAmbientContextOrInterface) { - // check if declarations are consecutive only if they are non-ambient - // 1. ambient declarations can be interleaved - // i.e. this is legal - // declare function foo(); - // declare function bar(); - // declare function foo(); - // 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 === 252 /* ClassDeclaration */ || node.kind === 221 /* ClassExpression */) && !inAmbientContext) { - hasNonAmbientClass = true; - } - if (node.kind === 251 /* FunctionDeclaration */ || node.kind === 165 /* MethodDeclaration */ || node.kind === 164 /* MethodSignature */ || node.kind === 166 /* Constructor */) { - functionDeclarations.push(node); - var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); - someNodeFlags |= currentNodeFlags; - allNodeFlags &= currentNodeFlags; - someHaveQuestionToken = someHaveQuestionToken || ts.hasQuestionToken(node); - allHaveQuestionToken = allHaveQuestionToken && ts.hasQuestionToken(node); - var bodyIsPresent = ts.nodeIsPresent(node.body); - if (bodyIsPresent && bodyDeclaration) { - if (isConstructor) { - multipleConstructorImplementation = true; + if (declarations) { + for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { + var current = declarations_4[_i]; + var node = current; + var inAmbientContext = node.flags & 8388608 /* Ambient */; + var inAmbientContextOrInterface = node.parent && (node.parent.kind === 255 /* InterfaceDeclaration */ || node.parent.kind === 179 /* TypeLiteral */) || inAmbientContext; + if (inAmbientContextOrInterface) { + // check if declarations are consecutive only if they are non-ambient + // 1. ambient declarations can be interleaved + // i.e. this is legal + // declare function foo(); + // declare function bar(); + // declare function foo(); + // 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 === 254 /* ClassDeclaration */ || node.kind === 223 /* ClassExpression */) && !inAmbientContext) { + hasNonAmbientClass = true; + } + if (node.kind === 253 /* FunctionDeclaration */ || node.kind === 167 /* MethodDeclaration */ || node.kind === 166 /* MethodSignature */ || node.kind === 168 /* Constructor */) { + functionDeclarations.push(node); + var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); + someNodeFlags |= currentNodeFlags; + allNodeFlags &= currentNodeFlags; + someHaveQuestionToken = someHaveQuestionToken || ts.hasQuestionToken(node); + allHaveQuestionToken = allHaveQuestionToken && ts.hasQuestionToken(node); + var bodyIsPresent = ts.nodeIsPresent(node.body); + if (bodyIsPresent && bodyDeclaration) { + if (isConstructor) { + multipleConstructorImplementation = true; + } + else { + duplicateFunctionDeclaration = true; + } + } + else if ((previousDeclaration === null || previousDeclaration === void 0 ? void 0 : previousDeclaration.parent) === node.parent && previousDeclaration.end !== node.pos) { + reportImplementationExpectedError(previousDeclaration); + } + if (bodyIsPresent) { + if (!bodyDeclaration) { + bodyDeclaration = node; + } } else { - duplicateFunctionDeclaration = true; + hasOverloads = true; } - } - else if ((previousDeclaration === null || previousDeclaration === void 0 ? void 0 : previousDeclaration.parent) === node.parent && previousDeclaration.end !== node.pos) { - reportImplementationExpectedError(previousDeclaration); - } - if (bodyIsPresent) { - if (!bodyDeclaration) { - bodyDeclaration = node; + previousDeclaration = node; + if (!inAmbientContextOrInterface) { + lastSeenNonAmbientDeclaration = node; } } - else { - hasOverloads = true; - } - previousDeclaration = node; - if (!inAmbientContextOrInterface) { - lastSeenNonAmbientDeclaration = node; - } } } if (multipleConstructorImplementation) { @@ -73709,13 +76373,18 @@ var ts; error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Duplicate_function_implementation); }); } - if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 /* Function */) { - // A non-ambient class cannot be an implementation for a non-constructor function/class merge - // TODO: The below just replicates our older error from when classes and functions were - // entirely unable to merge - a more helpful message like "Class declaration cannot implement overload list" - // might be warranted. :shrug: + if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 /* Function */ && declarations) { + var relatedDiagnostics_1 = ts.filter(declarations, function (d) { return d.kind === 254 /* ClassDeclaration */; }) + .map(function (d) { return ts.createDiagnosticForNode(d, ts.Diagnostics.Consider_adding_a_declare_modifier_to_this_class); }); ts.forEach(declarations, function (declaration) { - addDuplicateDeclarationError(declaration, ts.Diagnostics.Duplicate_identifier_0, ts.symbolName(symbol), declarations); + var diagnostic = declaration.kind === 254 /* ClassDeclaration */ + ? ts.Diagnostics.Class_declaration_cannot_implement_overload_list_for_0 + : declaration.kind === 253 /* FunctionDeclaration */ + ? ts.Diagnostics.Function_with_bodies_can_only_merge_with_classes_that_are_ambient + : undefined; + if (diagnostic) { + ts.addRelatedInfo.apply(void 0, __spreadArray([error(ts.getNameOfDeclaration(declaration) || declaration, diagnostic, ts.symbolName(symbol))], relatedDiagnostics_1)); + } }); } // Abstract methods can't have an implementation -- in particular, they don't need one. @@ -73724,8 +76393,10 @@ var ts; reportImplementationExpectedError(lastSeenNonAmbientDeclaration); } if (hasOverloads) { - checkFlagAgreementBetweenOverloads(declarations, bodyDeclaration, flagsToCheck, someNodeFlags, allNodeFlags); - checkQuestionTokenAgreementBetweenOverloads(declarations, bodyDeclaration, someHaveQuestionToken, allHaveQuestionToken); + if (declarations) { + checkFlagAgreementBetweenOverloads(declarations, bodyDeclaration, flagsToCheck, someNodeFlags, allNodeFlags); + checkQuestionTokenAgreementBetweenOverloads(declarations, bodyDeclaration, someHaveQuestionToken, allHaveQuestionToken); + } if (bodyDeclaration) { var signatures = getSignaturesOfSymbol(symbol); var bodySignature = getSignatureFromDeclaration(bodyDeclaration); @@ -73799,44 +76470,47 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: // A jsdoc typedef and callback are, by definition, type aliases. // falls through - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 325 /* JSDocEnumTag */: + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + case 333 /* JSDocEnumTag */: return 2 /* ExportType */; - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4 /* ExportNamespace */ | 1 /* ExportValue */ : 4 /* ExportNamespace */; - case 252 /* ClassDeclaration */: - case 255 /* EnumDeclaration */: - case 291 /* EnumMember */: + case 254 /* ClassDeclaration */: + case 257 /* EnumDeclaration */: + case 293 /* EnumMember */: return 2 /* ExportType */ | 1 /* ExportValue */; - case 297 /* SourceFile */: + case 299 /* SourceFile */: return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: + case 218 /* 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(d.expression)) { + if (!ts.isEntityNameExpression(expression)) { return 1 /* ExportValue */; } - d = d.expression; + d = expression; // The below options all declare an Alias, which is allowed to merge with other values within the importing module. // falls through - case 260 /* ImportEqualsDeclaration */: - case 263 /* NamespaceImport */: - case 262 /* ImportClause */: + case 262 /* ImportEqualsDeclaration */: + case 265 /* NamespaceImport */: + case 264 /* ImportClause */: var result_12 = 0 /* None */; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_12 |= getDeclarationSpaces(d); }); return result_12; - case 249 /* VariableDeclaration */: - case 198 /* BindingElement */: - case 251 /* FunctionDeclaration */: - case 265 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 - case 78 /* Identifier */: // https://github.com/microsoft/TypeScript/issues/36098 + case 251 /* VariableDeclaration */: + case 200 /* BindingElement */: + case 253 /* FunctionDeclaration */: + case 267 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 79 /* 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) @@ -74088,7 +76762,7 @@ var ts; var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* Value */, /*ignoreErrors*/ true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; if (promiseConstructorType === errorType) { - if (promiseConstructorName.kind === 78 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { + if (promiseConstructorName.kind === 79 /* 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 { @@ -74128,24 +76802,24 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 160 /* Parameter */: + case 162 /* Parameter */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages( /*details*/ undefined, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages( /*details*/ undefined, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -74166,7 +76840,7 @@ var ts; if (!typeName) return; var rootName = ts.getFirstIdentifier(typeName); - var meaning = (typeName.kind === 78 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; + var meaning = (typeName.kind === 79 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isRefernce*/ true); if (rootSymbol && rootSymbol.flags & 2097152 /* Alias */ @@ -74192,15 +76866,15 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 183 /* IntersectionType */: - case 182 /* UnionType */: + case 185 /* IntersectionType */: + case 184 /* UnionType */: return getEntityNameForDecoratorMetadataFromTypeList(node.types); - case 184 /* ConditionalType */: + case 186 /* ConditionalType */: return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]); - case 186 /* ParenthesizedType */: - case 192 /* NamedTupleMember */: + case 188 /* ParenthesizedType */: + case 194 /* NamedTupleMember */: return getEntityNameForDecoratorMetadata(node.type); - case 173 /* TypeReference */: + case 175 /* TypeReference */: return node.typeName; } } @@ -74209,13 +76883,13 @@ var ts; var commonEntityName; for (var _i = 0, types_23 = types; _i < types_23.length; _i++) { var typeNode = types_23[_i]; - while (typeNode.kind === 186 /* ParenthesizedType */ || typeNode.kind === 192 /* NamedTupleMember */) { + while (typeNode.kind === 188 /* ParenthesizedType */ || typeNode.kind === 194 /* NamedTupleMember */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 141 /* NeverKeyword */) { + if (typeNode.kind === 142 /* NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 191 /* LiteralType */ && typeNode.literal.kind === 103 /* NullKeyword */ || typeNode.kind === 150 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 193 /* LiteralType */ && typeNode.literal.kind === 104 /* NullKeyword */ || typeNode.kind === 151 /* 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); @@ -74261,14 +76935,14 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 160 /* Parameter */) { + if (node.kind === 162 /* Parameter */) { checkExternalEmitHelpers(firstDecorator, 32 /* Param */); } if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16 /* 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 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -74277,23 +76951,23 @@ var ts; } } break; - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - var otherKind = node.kind === 167 /* GetAccessor */ ? 168 /* SetAccessor */ : 167 /* GetAccessor */; + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + var otherKind = node.kind === 169 /* GetAccessor */ ? 170 /* SetAccessor */ : 169 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); break; - case 165 /* MethodDeclaration */: + case 167 /* 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 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 160 /* Parameter */: + case 162 /* Parameter */: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -74356,7 +77030,7 @@ var ts; else if (ts.findLast(ts.getJSDocTags(decl), ts.isJSDocParameterTag) === node && node.typeExpression && node.typeExpression.type && !isArrayType(getTypeFromTypeNode(node.typeExpression.type))) { - error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 157 /* QualifiedName */ ? node.name.right : node.name)); + error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 159 /* QualifiedName */ ? node.name.right : node.name)); } } } @@ -74398,27 +77072,28 @@ var ts; } function getIdentifierFromEntityNameExpression(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return node; - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return node.name; default: return undefined; } } function checkFunctionOrMethodDeclaration(node) { + var _a; checkDecorators(node); checkSignatureDeclaration(node); var functionFlags = ts.getFunctionFlags(node); // 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 === 158 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 160 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); } - if (!hasNonBindableDynamicName(node)) { + if (hasBindableName(node)) { // first we want to check the local symbol that contain this declaration // - if node.localSymbol !== undefined - this is current declaration is exported and localSymbol points to the local symbol // - if node.localSymbol === undefined - this node is non-exported so we can just pick the result of getSymbolOfNode @@ -74427,7 +77102,7 @@ var ts; // Since the javascript won't do semantic analysis like typescript, // if the javascript file comes before the typescript file and both contain same name functions, // checkFunctionOrConstructorSymbol wouldn't be called if we didnt ignore javascript function. - var firstDeclaration = ts.find(localSymbol.declarations, + 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 & 131072 /* JavaScriptFile */); }); // Only type check the symbol once @@ -74439,7 +77114,7 @@ var ts; checkFunctionOrConstructorSymbol(symbol); } } - var body = node.kind === 164 /* MethodSignature */ ? undefined : node.body; + var body = node.kind === 166 /* MethodSignature */ ? undefined : node.body; checkSourceElement(body); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node)); if (produceDiagnostics && !ts.getEffectiveReturnTypeNode(node)) { @@ -74481,42 +77156,42 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 297 /* SourceFile */: - case 256 /* ModuleDeclaration */: - case 230 /* Block */: - case 258 /* CaseBlock */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: + case 299 /* SourceFile */: + case 258 /* ModuleDeclaration */: + case 232 /* Block */: + case 260 /* CaseBlock */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 166 /* Constructor */: - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 168 /* Constructor */: + case 210 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 211 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: if (node.body) { // Don't report unused parameters in overloads checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 164 /* MethodSignature */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 254 /* TypeAliasDeclaration */: - case 253 /* InterfaceDeclaration */: + case 166 /* MethodSignature */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: + case 256 /* TypeAliasDeclaration */: + case 255 /* InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 185 /* InferType */: + case 187 /* InferType */: checkUnusedInferTypeParameter(node, addDiagnostic); break; default: @@ -74536,11 +77211,11 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 165 /* MethodDeclaration */: - case 163 /* PropertyDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - if (member.kind === 168 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { + case 167 /* MethodDeclaration */: + case 165 /* PropertyDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + if (member.kind === 170 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { // Already would have reported an error on the getter. break; } @@ -74551,7 +77226,7 @@ var ts; addDiagnostic(member, 0 /* Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); } break; - case 166 /* Constructor */: + case 168 /* 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 */)) { @@ -74559,8 +77234,8 @@ var ts; } } break; - case 171 /* IndexSignature */: - case 229 /* SemicolonClassElement */: + case 173 /* IndexSignature */: + case 231 /* SemicolonClassElement */: // Can't be private break; default: @@ -74577,7 +77252,8 @@ var ts; function checkUnusedTypeParameters(node, addDiagnostic) { // Only report errors on the last declaration for the type parameter container; // this ensures that all uses have been accounted for. - if (ts.last(getSymbolOfNode(node).declarations) !== node) + var declarations = getSymbolOfNode(node).declarations; + if (!declarations || ts.last(declarations) !== node) return; var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); var seenParentsWithEveryUnused = new ts.Set(); @@ -74587,7 +77263,7 @@ var ts; continue; var name = ts.idText(typeParameter.name); var parent = typeParameter.parent; - if (parent.kind !== 185 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { + if (parent.kind !== 187 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { if (ts.tryAddToSet(seenParentsWithEveryUnused, parent)) { var sourceFile = ts.getSourceFileOfNode(parent); var range = ts.isJSDocTemplateTag(parent) @@ -74596,12 +77272,14 @@ var ts; // Include the `<>` in the error message : ts.rangeOfTypeParameters(sourceFile, parent.typeParameters); var only = parent.typeParameters.length === 1; + //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)); } } 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)); } } @@ -74623,11 +77301,15 @@ var ts; return ts.tryCast(ts.getRootDeclaration(node), ts.isParameter); } function isValidUnusedLocalDeclaration(declaration) { - if (ts.isBindingElement(declaration) && isIdentifierThatStartsWithUnderscore(declaration.name)) { - return !!ts.findAncestor(declaration.parent, function (ancestor) { - return ts.isArrayBindingPattern(ancestor) || ts.isVariableDeclaration(ancestor) || ts.isVariableDeclarationList(ancestor) ? false : - ts.isForOfStatement(ancestor) ? true : "quit"; - }); + if (ts.isBindingElement(declaration)) { + if (ts.isObjectBindingPattern(declaration.parent)) { + /** + * ignore starts with underscore names _ + * const { a: _a } = { a: 1 } + */ + return !!(declaration.propertyName && isIdentifierThatStartsWithUnderscore(declaration.name)); + } + return isIdentifierThatStartsWithUnderscore(declaration.name); } return ts.isAmbientModule(declaration) || (ts.isVariableDeclaration(declaration) && ts.isForInOrOfStatement(declaration.parent.parent) || isImportedDeclaration(declaration)) && isIdentifierThatStartsWithUnderscore(declaration.name); @@ -74643,39 +77325,41 @@ var ts; if (local.flags & 262144 /* TypeParameter */ ? !(local.flags & 3 /* Variable */ && !(local.isReferenced & 3 /* Variable */)) : local.isReferenced || local.exportSymbol) { return; } - for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (isValidUnusedLocalDeclaration(declaration)) { - continue; - } - if (isImportedDeclaration(declaration)) { - addToGroup(unusedImports, importClauseFromImported(declaration), declaration, getNodeId); - } - else if (ts.isBindingElement(declaration) && ts.isObjectBindingPattern(declaration.parent)) { - // In `{ a, ...b }, `a` is considered used since it removes a property from `b`. `b` may still be unused though. - var lastElement = ts.last(declaration.parent.elements); - if (declaration === lastElement || !ts.last(declaration.parent.elements).dotDotDotToken) { - addToGroup(unusedDestructures, declaration.parent, declaration, getNodeId); + if (local.declarations) { + for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (isValidUnusedLocalDeclaration(declaration)) { + continue; } - } - else if (ts.isVariableDeclaration(declaration)) { - addToGroup(unusedVariables, declaration.parent, declaration, getNodeId); - } - else { - var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); - var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration); - if (parameter && name) { - if (!ts.isParameterPropertyDeclaration(parameter, parameter.parent) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { - if (ts.isBindingElement(declaration) && ts.isArrayBindingPattern(declaration.parent)) { - 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))); - } + if (isImportedDeclaration(declaration)) { + addToGroup(unusedImports, importClauseFromImported(declaration), declaration, getNodeId); + } + else if (ts.isBindingElement(declaration) && ts.isObjectBindingPattern(declaration.parent)) { + // In `{ a, ...b }, `a` is considered used since it removes a property from `b`. `b` may still be unused though. + var lastElement = ts.last(declaration.parent.elements); + if (declaration === lastElement || !ts.last(declaration.parent.elements).dotDotDotToken) { + addToGroup(unusedDestructures, declaration.parent, declaration, getNodeId); } } + else if (ts.isVariableDeclaration(declaration)) { + addToGroup(unusedVariables, declaration.parent, declaration, getNodeId); + } else { - errorUnusedLocal(declaration, ts.symbolName(local), addDiagnostic); + var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); + var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration); + if (parameter && name) { + if (!ts.isParameterPropertyDeclaration(parameter, parameter.parent) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { + if (ts.isBindingElement(declaration) && ts.isArrayBindingPattern(declaration.parent)) { + 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))); + } + } + } + else { + errorUnusedLocal(declaration, ts.symbolName(local), addDiagnostic); + } } } } @@ -74685,7 +77369,7 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 263 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 265 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { addDiagnostic(importDecl, 0 /* Local */, unuseds.length === 1 @@ -74703,7 +77387,7 @@ var ts; var bindingPattern = _a[0], bindingElements = _a[1]; var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* Parameter */ : 0 /* Local */; if (bindingPattern.elements.length === bindingElements.length) { - if (bindingElements.length === 1 && bindingPattern.parent.kind === 249 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 250 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 251 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 252 /* VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -74724,7 +77408,7 @@ var ts; if (declarationList.declarations.length === declarations.length) { addDiagnostic(declarationList, 0 /* 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 === 232 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 234 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { @@ -74736,24 +77420,24 @@ var ts; } function bindingNameText(name) { switch (name.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return ts.idText(name); - case 197 /* ArrayBindingPattern */: - case 196 /* ObjectBindingPattern */: + case 199 /* ArrayBindingPattern */: + case 198 /* ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 262 /* ImportClause */ || node.kind === 265 /* ImportSpecifier */ || node.kind === 263 /* NamespaceImport */; + return node.kind === 264 /* ImportClause */ || node.kind === 267 /* ImportSpecifier */ || node.kind === 265 /* NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 262 /* ImportClause */ ? decl : decl.kind === 263 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 264 /* ImportClause */ ? decl : decl.kind === 265 /* NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 230 /* Block */) { + if (node.kind === 232 /* Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -74783,12 +77467,12 @@ var ts; if (!(identifier && identifier.escapedText === name)) { return false; } - if (node.kind === 163 /* PropertyDeclaration */ || - node.kind === 162 /* PropertySignature */ || - node.kind === 165 /* MethodDeclaration */ || - node.kind === 164 /* MethodSignature */ || - node.kind === 167 /* GetAccessor */ || - node.kind === 168 /* SetAccessor */) { + if (node.kind === 165 /* PropertyDeclaration */ || + node.kind === 164 /* PropertySignature */ || + node.kind === 167 /* MethodDeclaration */ || + node.kind === 166 /* MethodSignature */ || + node.kind === 169 /* GetAccessor */ || + node.kind === 170 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -74797,7 +77481,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 160 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 162 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -74807,7 +77491,7 @@ var ts; function checkIfThisIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 78 /* Identifier */; + var isDeclaration_1 = node.kind !== 79 /* Identifier */; if (isDeclaration_1) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -74822,7 +77506,7 @@ var ts; function checkIfNewTargetIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 8 /* CaptureNewTarget */) { - var isDeclaration_2 = node.kind !== 78 /* Identifier */; + var isDeclaration_2 = node.kind !== 79 /* 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); } @@ -74834,10 +77518,11 @@ var ts; return false; }); } - function checkWeakMapCollision(node) { + function checkWeakMapSetCollision(node) { var enclosingBlockScope = ts.getEnclosingBlockScopeContainer(node); if (getNodeCheckFlags(enclosingBlockScope) & 67108864 /* ContainsClassWithPrivateIdentifiers */) { - errorSkippedOn("noEmit", node, ts.Diagnostics.Compiler_reserves_name_0_when_emitting_private_identifier_downlevel, "WeakMap"); + 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 checkCollisionWithRequireExportsInGeneratedCode(node, name) { @@ -74854,7 +77539,7 @@ var ts; } // 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 === 297 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 299 /* 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)); } @@ -74869,7 +77554,7 @@ var ts; } // 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 === 297 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* HasAsyncFunctions */) { + if (parent.kind === 299 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* 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)); } @@ -74904,7 +77589,7 @@ var ts; // 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 === 249 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 251 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -74916,17 +77601,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 250 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 232 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 252 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 234 /* 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 === 230 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 257 /* ModuleBlock */ || - container.kind === 256 /* ModuleDeclaration */ || - container.kind === 297 /* SourceFile */); + (container.kind === 232 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 259 /* ModuleBlock */ || + container.kind === 258 /* ModuleDeclaration */ || + container.kind === 299 /* 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 @@ -74957,18 +77642,18 @@ 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 === 158 /* ComputedPropertyName */) { + if (node.name.kind === 160 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 198 /* BindingElement */) { - if (node.parent.kind === 196 /* ObjectBindingPattern */ && languageVersion < 99 /* ESNext */) { + if (ts.isBindingElement(node)) { + if (ts.isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ES2018 */) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 158 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 160 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access @@ -74981,15 +77666,15 @@ var ts; var nameText = getPropertyNameFromType(exprType); var property = getPropertyOfType(parentType, nameText); if (property) { - markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined, /*isThisAccess*/ false); // A destructuring is never a write-only reference. - checkPropertyAccessibility(parent, !!parent.initializer && parent.initializer.kind === 105 /* SuperKeyword */, parentType, 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); } } } } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 197 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + if (node.name.kind === 199 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, 512 /* Read */); } ts.forEach(node.name.elements, checkSourceElement); @@ -75001,7 +77686,7 @@ var ts; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { - var needCheckInitializer = node.initializer && node.parent.parent.kind !== 238 /* ForInStatement */; + var needCheckInitializer = node.initializer && node.parent.parent.kind !== 240 /* ForInStatement */; var needCheckWidenedType = node.name.elements.length === 0; if (needCheckInitializer || needCheckWidenedType) { // Don't validate for-in initializer as it is already an error @@ -75029,7 +77714,7 @@ var ts; } // For a commonjs `const x = require`, validate the alias and exit var symbol = getSymbolOfNode(node); - if (symbol.flags & 2097152 /* Alias */ && ts.isRequireVariableDeclaration(node, /*requireStringLiteralLikeArgument*/ true)) { + if (symbol.flags & 2097152 /* Alias */ && ts.isRequireVariableDeclaration(node)) { checkAliasSymbol(node); return; } @@ -75043,11 +77728,11 @@ 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 !== 238 /* ForInStatement */) { + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 240 /* ForInStatement */) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); } } - if (symbol.declarations.length > 1) { + if (symbol.declarations && symbol.declarations.length > 1) { if (ts.some(symbol.declarations, function (d) { return d !== node && ts.isVariableLike(d) && !areDeclarationFlagsIdentical(d, node); })) { error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } @@ -75065,26 +77750,27 @@ var ts; if (node.initializer) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(node.initializer), declarationType, node, node.initializer, /*headMessage*/ undefined); } - if (!areDeclarationFlagsIdentical(node, symbol.valueDeclaration)) { + if (symbol.valueDeclaration && !areDeclarationFlagsIdentical(node, symbol.valueDeclaration)) { error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 163 /* PropertyDeclaration */ && node.kind !== 162 /* PropertySignature */) { + if (node.kind !== 165 /* PropertyDeclaration */ && node.kind !== 164 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 249 /* VariableDeclaration */ || node.kind === 198 /* BindingElement */) { + if (node.kind === 251 /* VariableDeclaration */ || node.kind === 200 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); - if (languageVersion < 99 /* ESNext */ && needCollisionCheckForIdentifier(node, node.name, "WeakMap")) { - potentialWeakMapCollisions.push(node); + if (languageVersion < 99 /* ESNext */ + && (needCollisionCheckForIdentifier(node, node.name, "WeakMap") || needCollisionCheckForIdentifier(node, node.name, "WeakSet"))) { + potentialWeakMapSetCollisions.push(node); } } } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 163 /* PropertyDeclaration */ || nextDeclaration.kind === 162 /* PropertySignature */ + var message = nextDeclaration.kind === 165 /* PropertyDeclaration */ || nextDeclaration.kind === 164 /* 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); @@ -75094,8 +77780,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 160 /* Parameter */ && right.kind === 249 /* VariableDeclaration */) || - (left.kind === 249 /* VariableDeclaration */ && right.kind === 160 /* Parameter */)) { + if ((left.kind === 162 /* Parameter */ && right.kind === 251 /* VariableDeclaration */) || + (left.kind === 251 /* VariableDeclaration */ && right.kind === 162 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -75111,10 +77797,10 @@ var ts; return ts.getSelectedEffectiveModifierFlags(left, interestingFlags) === ts.getSelectedEffectiveModifierFlags(right, interestingFlags); } function checkVariableDeclaration(node) { - ts.tracing.push("check" /* Check */, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end }); checkGrammarVariableDeclaration(node); checkVariableLikeDeclaration(node); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } function checkBindingElement(node) { checkGrammarBindingElement(node); @@ -75135,49 +77821,55 @@ var ts; // Grammar checking checkGrammarStatementInAmbientContext(node); var type = checkTruthinessExpression(node.expression); - checkTestingKnownTruthyCallableType(node.expression, type, node.thenStatement); + checkTestingKnownTruthyCallableOrAwaitableType(node.expression, type, node.thenStatement); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 231 /* EmptyStatement */) { + if (node.thenStatement.kind === 233 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); } - function checkTestingKnownTruthyCallableType(condExpr, type, body) { - if (!strictNullChecks) { + function checkTestingKnownTruthyCallableOrAwaitableType(condExpr, type, body) { + if (!strictNullChecks) + return; + if (getFalsyFlags(type)) return; - } var location = ts.isBinaryExpression(condExpr) ? condExpr.right : condExpr; var testedNode = ts.isIdentifier(location) ? location : ts.isPropertyAccessExpression(location) ? location.name : ts.isBinaryExpression(location) && ts.isIdentifier(location.right) ? location.right : undefined; - if (!testedNode) { - return; - } - var possiblyFalsy = getFalsyFlags(type); - if (possiblyFalsy) { + var isPropertyExpressionCast = ts.isPropertyAccessExpression(location) + && ts.isAssertionExpression(ts.skipParentheses(location.expression)); + if (!testedNode || isPropertyExpressionCast) { return; } // While it technically should be invalid for any known-truthy value - // to be tested, we de-scope to functions unrefenced 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. + // 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 */); - if (callSignatures.length === 0) { + var isPromise = !!getAwaitedTypeOfPromise(type); + if (callSignatures.length === 0 && !isPromise) { return; } var testedSymbol = getSymbolAtLocation(testedNode); if (!testedSymbol) { return; } - var isUsed = ts.isBinaryExpression(condExpr.parent) && isFunctionUsedInBinaryExpressionChain(condExpr.parent, testedSymbol) - || body && isFunctionUsedInConditionBody(condExpr, body, testedNode, testedSymbol); + var isUsed = ts.isBinaryExpression(condExpr.parent) && isSymbolUsedInBinaryExpressionChain(condExpr.parent, testedSymbol) + || body && isSymbolUsedInConditionBody(condExpr, body, testedNode, testedSymbol); if (!isUsed) { - error(location, ts.Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead); + if (isPromise) { + errorAndMaybeSuggestAwait(location, + /*maybeMissingAwait*/ true, ts.Diagnostics.This_condition_will_always_return_true_since_this_0_is_always_defined, getTypeNameForErrorDisplay(type)); + } + else { + error(location, ts.Diagnostics.This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_instead); + } } } - function isFunctionUsedInConditionBody(expr, body, testedNode, testedSymbol) { + function isSymbolUsedInConditionBody(expr, body, testedNode, testedSymbol) { return !!ts.forEachChild(body, function check(childNode) { if (ts.isIdentifier(childNode)) { var childSymbol = getSymbolAtLocation(childNode); @@ -75191,7 +77883,7 @@ var ts; var childExpression = childNode.parent; while (testedExpression && childExpression) { if (ts.isIdentifier(testedExpression) && ts.isIdentifier(childExpression) || - testedExpression.kind === 107 /* ThisKeyword */ && childExpression.kind === 107 /* ThisKeyword */) { + testedExpression.kind === 108 /* ThisKeyword */ && childExpression.kind === 108 /* ThisKeyword */) { return getSymbolAtLocation(testedExpression) === getSymbolAtLocation(childExpression); } else if (ts.isPropertyAccessExpression(testedExpression) && ts.isPropertyAccessExpression(childExpression)) { @@ -75214,7 +77906,7 @@ var ts; return ts.forEachChild(childNode, check); }); } - function isFunctionUsedInBinaryExpressionChain(node, testedSymbol) { + function isSymbolUsedInBinaryExpressionChain(node, testedSymbol) { while (ts.isBinaryExpression(node) && node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { var isUsed = ts.forEachChild(node.right, function visit(child) { if (ts.isIdentifier(child)) { @@ -75256,12 +77948,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 250 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 252 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 250 /* VariableDeclarationList */) { + if (node.initializer.kind === 252 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -75295,14 +77987,14 @@ var ts; // 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 === 250 /* VariableDeclarationList */) { + if (node.initializer.kind === 252 /* 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 === 199 /* ArrayLiteralExpression */ || varExpr.kind === 200 /* ObjectLiteralExpression */) { + if (varExpr.kind === 201 /* ArrayLiteralExpression */ || varExpr.kind === 202 /* 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. @@ -75334,7 +78026,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 === 250 /* VariableDeclarationList */) { + if (node.initializer.kind === 252 /* 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); @@ -75348,7 +78040,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 === 199 /* ArrayLiteralExpression */ || varExpr.kind === 200 /* ObjectLiteralExpression */) { + if (varExpr.kind === 201 /* ArrayLiteralExpression */ || varExpr.kind === 202 /* 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)) { @@ -75464,18 +78156,8 @@ 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 yieldType = getIterationTypeOfIterable(use, 0 /* Yield */, inputType, /*errorNode*/ undefined); - var _a = !(use & 4 /* AllowsStringInputFlag */) || hasStringConstituent - ? downlevelIteration - ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true] - : yieldType - ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false] - : [ts.Diagnostics.Type_0_is_not_an_array_type, true] - : downlevelIteration - ? [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] - : yieldType - ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false] - : [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type, true], defaultDiagnostic = _a[0], maybeMissingAwait = _a[1]; + var allowsStrings = !!(use & 4 /* AllowsStringInputFlag */) && !hasStringConstituent; + var _a = getIterationDiagnosticDetails(allowsStrings, downlevelIteration), defaultDiagnostic = _a[0], maybeMissingAwait = _a[1]; errorAndMaybeSuggestAwait(errorNode, maybeMissingAwait && !!getAwaitedTypeOfPromise(arrayType), defaultDiagnostic, typeToString(arrayType)); } return hasStringConstituent ? possibleOutOfBounds ? includeUndefinedInIndexSignature(stringType) : stringType : undefined; @@ -75489,6 +78171,40 @@ var ts; return getUnionType(possibleOutOfBounds ? [arrayElementType, stringType, undefinedType] : [arrayElementType, stringType], 2 /* Subtype */); } return (use & 128 /* PossiblyOutOfBounds */) ? includeUndefinedInIndexSignature(arrayElementType) : arrayElementType; + function getIterationDiagnosticDetails(allowsStrings, downlevelIteration) { + var _a; + if (downlevelIteration) { + return allowsStrings + ? [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); + if (yieldType) { + return [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false]; + } + if (isES2015OrLaterIterable((_a = inputType.symbol) === null || _a === void 0 ? void 0 : _a.escapedName)) { + return [ts.Diagnostics.Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher, true]; + } + return allowsStrings + ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type, true] + : [ts.Diagnostics.Type_0_is_not_an_array_type, true]; + } + } + function isES2015OrLaterIterable(n) { + switch (n) { + case "Float32Array": + case "Float64Array": + case "Int16Array": + case "Int32Array": + case "Int8Array": + case "NodeList": + case "Uint16Array": + case "Uint32Array": + case "Uint8Array": + case "Uint8ClampedArray": + return true; + } + return false; } /** * Gets the requested "iteration type" from an `Iterable`-like or `AsyncIterable`-like type. @@ -75732,6 +78448,11 @@ var ts; return setCachedIterationTypes(type, resolver.iterableCacheKey, createIterationTypes(yieldType, returnType, nextType)); } } + function getPropertyNameForKnownSymbolName(symbolName) { + var ctorType = getGlobalESSymbolConstructorSymbol(/*reportErrors*/ false); + var uniqueType = ctorType && getTypeOfPropertyOfType(getTypeOfSymbol(ctorType), ts.escapeLeadingUnderscores(symbolName)); + return uniqueType && isTypeUsableAsPropertyName(uniqueType) ? getPropertyNameFromType(uniqueType) : "__@" + symbolName; + } /** * Gets the *yield*, *return*, and *next* types of an `Iterable`-like or `AsyncIterable`-like * type from its members. @@ -75744,7 +78465,7 @@ var ts; */ function getIterationTypesOfIterableSlow(type, resolver, errorNode) { var _a; - var method = getPropertyOfType(type, ts.getPropertyNameForKnownSymbolName(resolver.iteratorSymbolName)); + var method = getPropertyOfType(type, getPropertyNameForKnownSymbolName(resolver.iteratorSymbolName)); var methodType = method && !(method.flags & 16777216 /* Optional */) ? getTypeOfSymbol(method) : undefined; if (isTypeAny(methodType)) { return setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes); @@ -76043,12 +78764,12 @@ var ts; var functionFlags = ts.getFunctionFlags(func); if (strictNullChecks || node.expression || returnType.flags & 131072 /* Never */) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; - if (func.kind === 168 /* SetAccessor */) { + if (func.kind === 170 /* SetAccessor */) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 166 /* Constructor */) { + else if (func.kind === 168 /* 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); } @@ -76066,7 +78787,7 @@ var ts; } } } - else if (func.kind !== 166 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 168 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, 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); } @@ -76095,7 +78816,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 === 285 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 287 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -76104,7 +78825,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 284 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 286 /* CaseClause */) { // TypeScript 1.0 spec (April 2014): 5.9 // In a 'switch' statement, each 'case' expression must be of a type that is comparable // to or from the type of the 'switch' expression. @@ -76136,7 +78857,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 245 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 247 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -76166,10 +78887,11 @@ var ts; // Grammar checking if (catchClause.variableDeclaration) { var declaration = catchClause.variableDeclaration; - if (declaration.type) { + var typeNode = ts.getEffectiveTypeAnnotationNode(ts.getRootDeclaration(declaration)); + if (typeNode) { var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false); if (type && !(type.flags & 3 /* AnyOrUnknown */)) { - grammarErrorOnFirstToken(declaration.type, ts.Diagnostics.Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified); + grammarErrorOnFirstToken(typeNode, ts.Diagnostics.Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified); } } else if (declaration.initializer) { @@ -76180,7 +78902,7 @@ var ts; if (blockLocals_1) { ts.forEachKey(catchClause.locals, function (caughtName) { var blockLocal = blockLocals_1.get(caughtName); - if (blockLocal && (blockLocal.flags & 2 /* BlockScopedVariable */) !== 0) { + if ((blockLocal === null || blockLocal === void 0 ? void 0 : blockLocal.valueDeclaration) && (blockLocal.flags & 2 /* BlockScopedVariable */) !== 0) { grammarErrorOnNode(blockLocal.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, caughtName); } }); @@ -76193,27 +78915,30 @@ var ts; checkBlock(node.finallyBlock); } } - function checkIndexConstraints(type) { - var declaredNumberIndexer = getIndexDeclarationOfSymbol(type.symbol, 1 /* Number */); - var declaredStringIndexer = getIndexDeclarationOfSymbol(type.symbol, 0 /* String */); + function checkIndexConstraints(type, isStatic) { + var _a, _b, _c, _d; + var declaredNumberIndexer = getIndexDeclarationOfSymbolTable(isStatic ? (_a = type.symbol) === null || _a === void 0 ? void 0 : _a.exports : (_b = type.symbol) === null || _b === void 0 ? void 0 : _b.members, 1 /* Number */); + var declaredStringIndexer = getIndexDeclarationOfSymbolTable(isStatic ? (_c = type.symbol) === null || _c === void 0 ? void 0 : _c.exports : (_d = type.symbol) === null || _d === void 0 ? void 0 : _d.members, 0 /* String */); var stringIndexType = getIndexTypeOfType(type, 0 /* String */); var numberIndexType = getIndexTypeOfType(type, 1 /* Number */); if (stringIndexType || numberIndexType) { ts.forEach(getPropertiesOfObjectType(type), function (prop) { - var propType = getTypeOfSymbol(prop); + if (isStatic && prop.flags & 4194304 /* Prototype */) + return; + var propType = getNonMissingTypeOfSymbol(prop); checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */); checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */); }); var classDeclaration = type.symbol.valueDeclaration; - if (ts.getObjectFlags(type) & 1 /* Class */ && ts.isClassLike(classDeclaration)) { - for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) { - var member = _a[_i]; + if (ts.getObjectFlags(type) & 1 /* Class */ && classDeclaration && ts.isClassLike(classDeclaration)) { + for (var _i = 0, _e = classDeclaration.members; _i < _e.length; _i++) { + var member = _e[_i]; // Only process instance properties with computed names here. // Static properties cannot be in conflict with indexers, // and properties with literal names were already checked. - if (!ts.hasSyntacticModifier(member, 32 /* Static */) && hasNonBindableDynamicName(member)) { + if (!ts.hasSyntacticModifier(member, 32 /* Static */) && !hasBindableName(member)) { var symbol = getSymbolOfNode(member); - var propType = getTypeOfSymbol(symbol); + var propType = getNonMissingTypeOfSymbol(symbol); checkIndexConstraintForProperty(symbol, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */); checkIndexConstraintForProperty(symbol, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */); } @@ -76226,7 +78951,7 @@ var ts; // condition 'errorNode === undefined' may appear if types does not declare nor string neither number indexer if (!errorNode && (ts.getObjectFlags(type) & 2 /* Interface */)) { var someBaseTypeHasBothIndexers = ts.forEach(getBaseTypes(type), function (base) { return getIndexTypeOfType(base, 0 /* String */) && getIndexTypeOfType(base, 1 /* Number */); }); - errorNode = someBaseTypeHasBothIndexers ? undefined : type.symbol.declarations[0]; + errorNode = someBaseTypeHasBothIndexers || !type.symbol.declarations ? undefined : type.symbol.declarations[0]; } } if (errorNode && !isTypeAssignableTo(numberIndexType, stringIndexType)) { // TODO: GH#18217 @@ -76250,8 +78975,8 @@ var ts; // this allows us to rule out cases when both property and indexer are inherited from the base class var errorNode; if (propDeclaration && name && - (propDeclaration.kind === 216 /* BinaryExpression */ || - name.kind === 158 /* ComputedPropertyName */ || + (propDeclaration.kind === 218 /* BinaryExpression */ || + name.kind === 160 /* ComputedPropertyName */ || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -76263,7 +78988,7 @@ var ts; // check if any base class already has both property and indexer. // check should be performed only if 'type' is the first type that brings property\indexer together var someBaseClassHasBothPropertyAndIndexer = ts.forEach(getBaseTypes(containingType), function (base) { return getPropertyOfObjectType(base, prop.escapedName) && getIndexTypeOfType(base, indexKind); }); - errorNode = someBaseClassHasBothPropertyAndIndexer ? undefined : containingType.symbol.declarations[0]; + errorNode = someBaseClassHasBothPropertyAndIndexer || !containingType.symbol.declarations ? undefined : containingType.symbol.declarations[0]; } if (errorNode && !isTypeAssignableTo(propertyType, indexType)) { var errorMessage = indexKind === 0 /* String */ @@ -76279,6 +79004,7 @@ var ts; switch (name.escapedText) { case "any": case "unknown": + case "never": case "number": case "bigint": case "boolean": @@ -76328,7 +79054,7 @@ var ts; function checkTypeParametersNotReferenced(root, typeParameters, index) { visit(root); function visit(node) { - if (node.kind === 173 /* TypeReference */) { + if (node.kind === 175 /* TypeReference */) { var type = getTypeFromTypeReference(node); if (type.flags & 262144 /* TypeParameter */) { for (var i = index; i < typeParameters.length; i++) { @@ -76343,14 +79069,14 @@ var ts; } /** Check that type parameter lists are identical across multiple declarations */ function checkTypeParameterListsIdentical(symbol) { - if (symbol.declarations.length === 1) { + if (symbol.declarations && symbol.declarations.length === 1) { return; } var links = getSymbolLinks(symbol); if (!links.typeParametersChecked) { links.typeParametersChecked = true; var declarations = getClassOrInterfaceDeclarationsOfSymbol(symbol); - if (declarations.length <= 1) { + if (!declarations || declarations.length <= 1) { return; } var type = getDeclaredTypeOfSymbol(symbol); @@ -76414,6 +79140,9 @@ var ts; registerForUnusedIdentifiersCheck(node); } function checkClassDeclaration(node) { + if (ts.some(node.decorators) && ts.some(node.members, function (p) { return ts.hasStaticModifier(p) && ts.isPrivateIdentifierClassElementDeclaration(p); })) { + grammarErrorOnNode(node.decorators[0], 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 */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } @@ -76442,7 +79171,8 @@ var ts; checkFunctionOrConstructorSymbol(symbol); checkClassForDuplicateDeclarations(node); // Only check for reserved static identifiers on non-ambient context. - if (!(node.flags & 8388608 /* Ambient */)) { + var nodeInAmbientContext = !!(node.flags & 8388608 /* Ambient */); + if (!nodeInAmbientContext) { checkClassForStaticPropertyNameConflicts(node); } var baseTypeNode = ts.getEffectiveBaseTypeNode(node); @@ -76502,6 +79232,7 @@ var ts; checkKindsOfPropertyMemberOverrides(type, baseType_1); } } + checkMembersForMissingOverrideModifier(node, type, typeWithThis, staticType); var implementedTypeNodes = ts.getEffectiveImplementsTypeNodes(node); if (implementedTypeNodes) { for (var _b = 0, implementedTypeNodes_1 = implementedTypeNodes; _b < implementedTypeNodes_1.length; _b++) { @@ -76531,14 +79262,79 @@ var ts; } if (produceDiagnostics) { checkIndexConstraints(type); + checkIndexConstraints(staticType, /*isStatic*/ true); checkTypeForDuplicateIndexSignatures(node); checkPropertyInitialization(node); } } + function checkMembersForMissingOverrideModifier(node, type, typeWithThis, staticType) { + var nodeInAmbientContext = !!(node.flags & 8388608 /* Ambient */); + var baseTypeNode = ts.getEffectiveBaseTypeNode(node); + 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_24 = function (member) { + if (ts.hasAmbientModifier(member)) { + return "continue"; + } + if (ts.isConstructorDeclaration(member)) { + ts.forEach(member.parameters, function (param) { + if (ts.isParameterPropertyDeclaration(param, member)) { + checkClassMember(param, /*memberIsParameterProperty*/ true); + } + }); + } + checkClassMember(member); + }; + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + _loop_24(member); + } + function checkClassMember(member, memberIsParameterProperty) { + var hasOverride = ts.hasOverrideModifier(member); + var hasStatic = ts.hasStaticModifier(member); + if (baseWithThis && (hasOverride || compilerOptions.noImplicitOverride)) { + var declaredProp = member.name && getSymbolAtLocation(member.name) || getSymbolAtLocation(member); + if (!declaredProp) { + return; + } + var thisType = hasStatic ? staticType : typeWithThis; + var baseType = hasStatic ? baseStaticType : baseWithThis; + var prop = getPropertyOfType(thisType, declaredProp.escapedName); + var baseProp = getPropertyOfType(baseType, declaredProp.escapedName); + var baseClassName = typeToString(baseWithThis); + if (prop && !baseProp && hasOverride) { + var suggestion = getSpellingSuggestionForName(ts.symbolName(declaredProp), ts.arrayFrom(getMembersOfSymbol(baseType.symbol).values()), 106500 /* ClassMember */); + suggestion ? + error(member, ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1, baseClassName, symbolToString(suggestion)) : + error(member, ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0, baseClassName); + } + else if (prop && (baseProp === null || baseProp === void 0 ? void 0 : baseProp.valueDeclaration) && compilerOptions.noImplicitOverride && !nodeInAmbientContext) { + var baseHasAbstract = ts.hasAbstractModifier(baseProp.valueDeclaration); + if (hasOverride) { + return; + } + if (!baseHasAbstract) { + var diag = memberIsParameterProperty ? + ts.Diagnostics.This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0 : + ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0; + error(member, diag, baseClassName); + } + else if (ts.hasAbstractModifier(member) && baseHasAbstract) { + error(member, ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0, baseClassName); + } + } + } + else if (hasOverride) { + var className = typeToString(type); + error(member, ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class, className); + } + } + } 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_23 = function (member) { + var _loop_25 = function (member) { if (ts.hasStaticModifier(member)) { return "continue"; } @@ -76557,7 +79353,7 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_23(member); + _loop_25(member); } if (!issuedMemberError) { // check again with diagnostics to generate a less-specific error @@ -76583,7 +79379,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 252 /* ClassDeclaration */ || d.kind === 253 /* InterfaceDeclaration */; + return d.kind === 254 /* ClassDeclaration */ || d.kind === 255 /* InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -76600,6 +79396,7 @@ var ts; // but not by other kinds of members. // Base class instance member variables and accessors can be overridden by // derived class instance member variables and accessors, but not by other kinds of members. + var _a, _b; // NOTE: assignability is checked in checkClassDeclaration var baseProperties = getPropertiesOfType(baseType); basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { @@ -76628,8 +79425,8 @@ var ts; // 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.) - for (var _a = 0, _b = getBaseTypes(type); _a < _b.length; _a++) { - var otherBaseType = _b[_a]; + for (var _c = 0, _d = getBaseTypes(type); _c < _d.length; _c++) { + var otherBaseType = _d[_c]; if (otherBaseType === baseType) continue; var baseSymbol_1 = getPropertyOfObjectType(otherBaseType, base.escapedName); @@ -76638,7 +79435,7 @@ var ts; continue basePropertyCheck; } } - if (derivedClassDecl.kind === 221 /* ClassExpression */) { + if (derivedClassDecl.kind === 223 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -76659,7 +79456,7 @@ var ts; if (basePropertyFlags && derivedPropertyFlags) { // property/accessor is overridden with property/accessor if (baseDeclarationFlags & 128 /* Abstract */ && !(base.valueDeclaration && ts.isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer) - || base.valueDeclaration && base.valueDeclaration.parent.kind === 253 /* InterfaceDeclaration */ + || base.valueDeclaration && base.valueDeclaration.parent.kind === 255 /* InterfaceDeclaration */ || derived.valueDeclaration && ts.isBinaryExpression(derived.valueDeclaration)) { // when the base property is abstract or from an interface, base/derived flags don't need to match // same when the derived property is from an assignment @@ -76673,13 +79470,13 @@ var ts; ts.Diagnostics._0_is_defined_as_a_property_in_class_1_but_is_overridden_here_in_2_as_an_accessor; error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_1, symbolToString(base), typeToString(baseType), typeToString(type)); } - else if (compilerOptions.useDefineForClassFields) { - var uninitialized = ts.find(derived.declarations, function (d) { return d.kind === 163 /* PropertyDeclaration */ && !d.initializer; }); + else if (useDefineForClassFields) { + var uninitialized = (_a = derived.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 165 /* PropertyDeclaration */ && !d.initializer; }); if (uninitialized && !(derived.flags & 33554432 /* Transient */) && !(baseDeclarationFlags & 128 /* Abstract */) && !(derivedDeclarationFlags & 128 /* Abstract */) - && !derived.declarations.some(function (d) { return !!(d.flags & 8388608 /* Ambient */); })) { + && !((_b = derived.declarations) === null || _b === void 0 ? void 0 : _b.some(function (d) { return !!(d.flags & 8388608 /* Ambient */); }))) { var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol)); var propName = uninitialized.name; if (uninitialized.exclamationToken @@ -76790,7 +79587,7 @@ var ts; } } function isInstancePropertyWithoutInitializer(node) { - return node.kind === 163 /* PropertyDeclaration */ && + return node.kind === 165 /* PropertyDeclaration */ && !ts.hasSyntacticModifier(node, 32 /* Static */ | 128 /* Abstract */) && !node.exclamationToken && !node.initializer; @@ -76814,7 +79611,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 253 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 255 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -76847,7 +79644,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0); checkExportsOnMergedDeclarations(node); checkTypeParameters(node.typeParameters); - if (node.type.kind === 136 /* IntrinsicKeyword */) { + if (node.type.kind === 137 /* 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); } @@ -76933,7 +79730,7 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { @@ -76943,7 +79740,7 @@ var ts; } } break; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { @@ -76972,22 +79769,22 @@ var ts; case 8 /* NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return evaluate(expr.expression); - case 78 /* Identifier */: + case 79 /* Identifier */: var identifier = expr; if (isInfinityOrNaNString(identifier.escapedText)) { return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 202 /* ElementAccessExpression */: - case 201 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: var ex = expr; if (isConstantMemberAccess(ex)) { var type = getTypeOfExpression(ex.expression); if (type.symbol && type.symbol.flags & 384 /* Enum */) { var name = void 0; - if (ex.kind === 201 /* PropertyAccessExpression */) { + if (ex.kind === 203 /* PropertyAccessExpression */) { name = ex.name.escapedText; } else { @@ -77005,7 +79802,7 @@ var ts; if (memberSymbol) { var declaration = memberSymbol.valueDeclaration; if (declaration !== member) { - if (isBlockScopedNameDeclaredBeforeUse(declaration, member)) { + if (declaration && isBlockScopedNameDeclaredBeforeUse(declaration, member)) { return getEnumMemberValue(declaration); } error(expr, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums); @@ -77019,9 +79816,9 @@ var ts; } } function isConstantMemberAccess(node) { - return node.kind === 78 /* Identifier */ || - node.kind === 201 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 202 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + return node.kind === 79 /* Identifier */ || + node.kind === 203 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 204 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && ts.isStringLiteralLike(node.argumentExpression); } function checkEnumDeclaration(node) { @@ -77045,7 +79842,7 @@ var ts; var enumSymbol = getSymbolOfNode(node); var firstDeclaration = ts.getDeclarationOfKind(enumSymbol, node.kind); if (node === firstDeclaration) { - if (enumSymbol.declarations.length > 1) { + if (enumSymbol.declarations && enumSymbol.declarations.length > 1) { var enumIsConst_1 = ts.isEnumConst(node); // check that const is placed\omitted on all enum declarations ts.forEach(enumSymbol.declarations, function (decl) { @@ -77057,7 +79854,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 !== 255 /* EnumDeclaration */) { + if (declaration.kind !== 257 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -77083,12 +79880,14 @@ var ts; } function getFirstNonAmbientClassOrFunctionDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { - var declaration = declarations_8[_i]; - if ((declaration.kind === 252 /* ClassDeclaration */ || - (declaration.kind === 251 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && - !(declaration.flags & 8388608 /* Ambient */)) { - return declaration; + if (declarations) { + for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { + var declaration = declarations_8[_i]; + if ((declaration.kind === 254 /* ClassDeclaration */ || + (declaration.kind === 253 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + !(declaration.flags & 8388608 /* Ambient */)) { + return declaration; + } } } return undefined; @@ -77136,8 +79935,9 @@ var ts; // The following checks only apply on a non-ambient instantiated module declaration. if (symbol.flags & 512 /* ValueModule */ && !inAmbientContext + && symbol.declarations && symbol.declarations.length > 1 - && isInstantiatedModule(node, !!compilerOptions.preserveConstEnums || !!compilerOptions.isolatedModules)) { + && isInstantiatedModule(node, ts.shouldPreserveConstEnums(compilerOptions))) { var firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol); if (firstNonAmbientClassOrFunc) { if (ts.getSourceFileOfNode(node) !== ts.getSourceFileOfNode(firstNonAmbientClassOrFunc)) { @@ -77149,7 +79949,7 @@ 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, 252 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 254 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -77198,40 +79998,41 @@ var ts; } } function checkModuleAugmentationElement(node, isGlobalAugmentation) { + var _a; switch (node.kind) { - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: // error each individual name in variable statement instead of marking the entire variable statement - for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; + for (var _i = 0, _b = node.declarationList.declarations; _i < _b.length; _i++) { + var decl = _b[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 266 /* ExportAssignment */: - case 267 /* ExportDeclaration */: + case 268 /* ExportAssignment */: + case 269 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 260 /* ImportEqualsDeclaration */: - case 261 /* ImportDeclaration */: + case 262 /* ImportEqualsDeclaration */: + case 263 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 198 /* BindingElement */: - case 249 /* VariableDeclaration */: + case 200 /* BindingElement */: + case 251 /* VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { - for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { - var el = _c[_b]; + for (var _c = 0, _d = name.elements; _c < _d.length; _c++) { + var el = _d[_c]; // mark individual names in binding pattern checkModuleAugmentationElement(el, isGlobalAugmentation); } break; } // falls through - case 252 /* ClassDeclaration */: - case 255 /* EnumDeclaration */: - case 251 /* FunctionDeclaration */: - case 253 /* InterfaceDeclaration */: - case 256 /* ModuleDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 254 /* ClassDeclaration */: + case 257 /* EnumDeclaration */: + case 253 /* FunctionDeclaration */: + case 255 /* InterfaceDeclaration */: + case 258 /* ModuleDeclaration */: + case 256 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -77244,7 +80045,7 @@ var ts; var reportError = !(symbol.flags & 33554432 /* Transient */); if (!reportError) { // symbol should not originate in augmentation - reportError = !!symbol.parent && ts.isExternalModuleAugmentation(symbol.parent.declarations[0]); + reportError = !!((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.declarations) && ts.isExternalModuleAugmentation(symbol.parent.declarations[0]); } } break; @@ -77252,20 +80053,20 @@ var ts; } function getFirstNonModuleExportsIdentifier(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return node; - case 157 /* QualifiedName */: + case 159 /* QualifiedName */: do { node = node.left; - } while (node.kind !== 78 /* Identifier */); + } while (node.kind !== 79 /* Identifier */); return node; - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: do { if (ts.isModuleExportsAccessExpression(node.expression) && !ts.isPrivateIdentifier(node.name)) { return node.name; } node = node.expression; - } while (node.kind !== 78 /* Identifier */); + } while (node.kind !== 79 /* Identifier */); return node; } } @@ -77279,9 +80080,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 257 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 297 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 267 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 259 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 299 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 269 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -77301,6 +80102,7 @@ var ts; return true; } function checkAliasSymbol(node) { + var _a; var symbol = getSymbolOfNode(node); var target = resolveAlias(symbol); if (target !== unknownSymbol) { @@ -77315,21 +80117,21 @@ var ts; (symbol.flags & 788968 /* Type */ ? 788968 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 270 /* ExportSpecifier */ ? + var message = node.kind === 272 /* 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)); } // Don't allow to re-export something with no value side when `--isolatedModules` is set. if (compilerOptions.isolatedModules - && node.kind === 270 /* ExportSpecifier */ + && node.kind === 272 /* ExportSpecifier */ && !node.parent.parent.isTypeOnly && !(target.flags & 111551 /* Value */) && !(node.flags & 8388608 /* Ambient */)) { error(node, ts.Diagnostics.Re_exporting_a_type_when_the_isolatedModules_flag_is_provided_requires_using_export_type); } - if (ts.isImportSpecifier(node) && ts.every(target.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 134217728 /* Deprecated */); })) { - errorOrSuggestion(/* isError */ false, node.name, ts.Diagnostics._0_is_deprecated, symbol.escapedName); + if (ts.isImportSpecifier(node) && ((_a = target.declarations) === null || _a === void 0 ? void 0 : _a.every(function (d) { return !!(ts.getCombinedNodeFlags(d) & 134217728 /* Deprecated */); }))) { + addDeprecatedSuggestion(node.name, target.declarations, symbol.escapedName); } } } @@ -77337,7 +80139,7 @@ var ts; checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); checkAliasSymbol(node); - if (node.kind === 265 /* ImportSpecifier */ && + if (node.kind === 267 /* ImportSpecifier */ && ts.idText(node.propertyName || node.name) === "default" && compilerOptions.esModuleInterop && moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015) { @@ -77359,7 +80161,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 263 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 265 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); if (moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015 && compilerOptions.esModuleInterop) { // import * as ns from "foo"; @@ -77387,7 +80189,7 @@ var ts; if (ts.hasSyntacticModifier(node, 1 /* Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 272 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 274 /* ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { if (target.flags & 111551 /* Value */) { @@ -77430,10 +80232,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 257 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 257 /* ModuleBlock */ && + var inAmbientExternalModule = node.parent.kind === 259 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 259 /* ModuleBlock */ && !node.moduleSpecifier && node.flags & 8388608 /* Ambient */; - if (node.parent.kind !== 297 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 299 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -77466,14 +80268,14 @@ var ts; } function checkGrammarExportDeclaration(node) { var _a; - var isTypeOnlyExportStar = node.isTypeOnly && ((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) !== 268 /* NamedExports */; + var isTypeOnlyExportStar = node.isTypeOnly && ((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) !== 270 /* NamedExports */; if (isTypeOnlyExportStar) { grammarErrorOnNode(node, ts.Diagnostics.Only_named_exports_may_use_export_type); } return !isTypeOnlyExportStar; } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 297 /* SourceFile */ || node.parent.kind === 257 /* ModuleBlock */ || node.parent.kind === 256 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 299 /* SourceFile */ || node.parent.kind === 259 /* ModuleBlock */ || node.parent.kind === 258 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -77523,7 +80325,7 @@ var ts; // 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 */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); - if (symbol && (symbol === undefinedSymbol || symbol === globalThisSymbol || isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { + 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 { @@ -77544,12 +80346,15 @@ var ts; } } function checkExportAssignment(node) { - if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { + var illegalContextMessage = node.isExportEquals + ? ts.Diagnostics.An_export_assignment_must_be_at_the_top_level_of_a_file_or_module_declaration + : ts.Diagnostics.A_default_export_must_be_at_the_top_level_of_a_file_or_module_declaration; + if (checkGrammarModuleElementContext(node, illegalContextMessage)) { // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 297 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 256 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 299 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 258 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -77562,7 +80367,7 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasEffectiveModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 78 /* Identifier */) { + if (node.expression.kind === 79 /* Identifier */) { var id = node.expression; var sym = resolveEntityName(id, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node); if (sym) { @@ -77609,7 +80414,7 @@ var ts; var exportEqualsSymbol = moduleSymbol.exports.get("export="); if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) { var declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration; - if (!isTopLevelInExternalModuleAugmentation(declaration) && !ts.isInJSFile(declaration)) { + if (declaration && !isTopLevelInExternalModuleAugmentation(declaration) && !ts.isInJSFile(declaration)) { error(declaration, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); } } @@ -77633,10 +80438,12 @@ var ts; return; } if (exportedDeclarationsCount > 1) { - for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { - var declaration = declarations_9[_i]; - if (isNotOverload(declaration)) { - diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Cannot_redeclare_exported_variable_0, ts.unescapeLeadingUnderscores(id))); + if (!isDuplicatedCommonJSExport(declarations)) { + for (var _i = 0, _b = declarations; _i < _b.length; _i++) { + var declaration = _b[_i]; + if (isNotOverload(declaration)) { + diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Cannot_redeclare_exported_variable_0, ts.unescapeLeadingUnderscores(id))); + } } } } @@ -77645,6 +80452,11 @@ var ts; links.exportsChecked = true; } } + function isDuplicatedCommonJSExport(declarations) { + return declarations + && declarations.length > 1 + && declarations.every(function (d) { return ts.isInJSFile(d) && ts.isAccessExpression(d) && (ts.isExportsIdentifier(d.expression) || ts.isModuleExportsAccessExpression(d.expression)); }); + } function checkSourceElement(node) { if (node) { var saveCurrentNode = currentNode; @@ -77666,171 +80478,171 @@ 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 256 /* ModuleDeclaration */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 251 /* FunctionDeclaration */: + case 258 /* ModuleDeclaration */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 253 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } - if (kind >= 232 /* FirstStatement */ && kind <= 248 /* LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { + if (kind >= 234 /* FirstStatement */ && kind <= 250 /* LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { errorOrSuggestion(compilerOptions.allowUnreachableCode === false, node, ts.Diagnostics.Unreachable_code_detected); } switch (kind) { - case 159 /* TypeParameter */: + case 161 /* TypeParameter */: return checkTypeParameter(node); - case 160 /* Parameter */: + case 162 /* Parameter */: return checkParameter(node); - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return checkPropertyDeclaration(node); - case 162 /* PropertySignature */: + case 164 /* PropertySignature */: return checkPropertySignature(node); - case 175 /* ConstructorType */: - case 174 /* FunctionType */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: + case 177 /* ConstructorType */: + case 176 /* FunctionType */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 173 /* IndexSignature */: return checkSignatureDeclaration(node); - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: return checkMethodDeclaration(node); - case 166 /* Constructor */: + case 168 /* Constructor */: return checkConstructorDeclaration(node); - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return checkAccessorDeclaration(node); - case 173 /* TypeReference */: + case 175 /* TypeReference */: return checkTypeReferenceNode(node); - case 172 /* TypePredicate */: + case 174 /* TypePredicate */: return checkTypePredicate(node); - case 176 /* TypeQuery */: + case 178 /* TypeQuery */: return checkTypeQuery(node); - case 177 /* TypeLiteral */: + case 179 /* TypeLiteral */: return checkTypeLiteral(node); - case 178 /* ArrayType */: + case 180 /* ArrayType */: return checkArrayType(node); - case 179 /* TupleType */: + case 181 /* TupleType */: return checkTupleType(node); - case 182 /* UnionType */: - case 183 /* IntersectionType */: + case 184 /* UnionType */: + case 185 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 186 /* ParenthesizedType */: - case 180 /* OptionalType */: - case 181 /* RestType */: + case 188 /* ParenthesizedType */: + case 182 /* OptionalType */: + case 183 /* RestType */: return checkSourceElement(node.type); - case 187 /* ThisType */: + case 189 /* ThisType */: return checkThisType(node); - case 188 /* TypeOperator */: + case 190 /* TypeOperator */: return checkTypeOperator(node); - case 184 /* ConditionalType */: + case 186 /* ConditionalType */: return checkConditionalType(node); - case 185 /* InferType */: + case 187 /* InferType */: return checkInferType(node); - case 193 /* TemplateLiteralType */: + case 195 /* TemplateLiteralType */: return checkTemplateLiteralType(node); - case 195 /* ImportType */: + case 197 /* ImportType */: return checkImportType(node); - case 192 /* NamedTupleMember */: + case 194 /* NamedTupleMember */: return checkNamedTupleMember(node); - case 315 /* JSDocAugmentsTag */: + case 322 /* JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 316 /* JSDocImplementsTag */: + case 323 /* JSDocImplementsTag */: return checkJSDocImplementsTag(node); - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 325 /* JSDocEnumTag */: + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + case 333 /* JSDocEnumTag */: return checkJSDocTypeAliasTag(node); - case 330 /* JSDocTemplateTag */: + case 338 /* JSDocTemplateTag */: return checkJSDocTemplateTag(node); - case 329 /* JSDocTypeTag */: + case 337 /* JSDocTypeTag */: return checkJSDocTypeTag(node); - case 326 /* JSDocParameterTag */: + case 334 /* JSDocParameterTag */: return checkJSDocParameterTag(node); - case 333 /* JSDocPropertyTag */: + case 341 /* JSDocPropertyTag */: return checkJSDocPropertyTag(node); - case 308 /* JSDocFunctionType */: + case 311 /* JSDocFunctionType */: checkJSDocFunctionType(node); // falls through - case 306 /* JSDocNonNullableType */: - case 305 /* JSDocNullableType */: - case 303 /* JSDocAllType */: - case 304 /* JSDocUnknownType */: - case 312 /* JSDocTypeLiteral */: + case 309 /* JSDocNonNullableType */: + case 308 /* JSDocNullableType */: + case 306 /* JSDocAllType */: + case 307 /* JSDocUnknownType */: + case 316 /* JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 309 /* JSDocVariadicType */: + case 312 /* JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 301 /* JSDocTypeExpression */: + case 303 /* JSDocTypeExpression */: return checkSourceElement(node.type); - case 189 /* IndexedAccessType */: + case 191 /* IndexedAccessType */: return checkIndexedAccessType(node); - case 190 /* MappedType */: + case 192 /* MappedType */: return checkMappedType(node); - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 230 /* Block */: - case 257 /* ModuleBlock */: + case 232 /* Block */: + case 259 /* ModuleBlock */: return checkBlock(node); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return checkVariableStatement(node); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: return checkExpressionStatement(node); - case 234 /* IfStatement */: + case 236 /* IfStatement */: return checkIfStatement(node); - case 235 /* DoStatement */: + case 237 /* DoStatement */: return checkDoStatement(node); - case 236 /* WhileStatement */: + case 238 /* WhileStatement */: return checkWhileStatement(node); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return checkForStatement(node); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return checkForInStatement(node); - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: return checkForOfStatement(node); - case 240 /* ContinueStatement */: - case 241 /* BreakStatement */: + case 242 /* ContinueStatement */: + case 243 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: return checkReturnStatement(node); - case 243 /* WithStatement */: + case 245 /* WithStatement */: return checkWithStatement(node); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: return checkSwitchStatement(node); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return checkLabeledStatement(node); - case 246 /* ThrowStatement */: + case 248 /* ThrowStatement */: return checkThrowStatement(node); - case 247 /* TryStatement */: + case 249 /* TryStatement */: return checkTryStatement(node); - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 198 /* BindingElement */: + case 200 /* BindingElement */: return checkBindingElement(node); - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: return checkClassDeclaration(node); - case 253 /* InterfaceDeclaration */: + case 255 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return checkImportDeclaration(node); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: return checkExportDeclaration(node); - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return checkExportAssignment(node); - case 231 /* EmptyStatement */: - case 248 /* DebuggerStatement */: + case 233 /* EmptyStatement */: + case 250 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 271 /* MissingDeclaration */: + case 273 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -77875,7 +80687,8 @@ var ts; if (ts.isJSDocTypeExpression(node.parent) && ts.isJSDocParameterTag(paramTag)) { // Else we will add a diagnostic, see `checkJSDocVariadicType`. var host_1 = ts.getHostSignatureFromJSDoc(paramTag); - if (host_1) { + var isCallbackTag = ts.isJSDocCallbackTag(paramTag.parent.parent); + if (host_1 || isCallbackTag) { /* Only return an array type if the corresponding parameter is marked as a rest parameter, or if there are no parameters. So in the following situation we will not create an array type: @@ -77883,7 +80696,9 @@ var ts; function f(a) {} Because `a` will just be of type `number | undefined`. A synthetic `...args` will also be added, which *will* get an array type. */ - var lastParamDeclaration = ts.lastOrUndefined(host_1.parameters); + var lastParamDeclaration = isCallbackTag + ? ts.lastOrUndefined(paramTag.parent.parent.typeExpression.parameters) + : ts.lastOrUndefined(host_1.parameters); var symbol = ts.getParameterSymbolFromJSDoc(paramTag); if (!lastParamDeclaration || symbol && lastParamDeclaration.symbol === symbol && ts.isRestParameter(lastParamDeclaration)) { @@ -77921,51 +80736,51 @@ var ts; } } function checkDeferredNode(node) { - ts.tracing.push("check" /* Check */, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end }); var saveCurrentNode = currentNode; currentNode = node; instantiationCount = 0; switch (node.kind) { - case 203 /* CallExpression */: - case 204 /* NewExpression */: - case 205 /* TaggedTemplateExpression */: - case 161 /* Decorator */: - case 275 /* JsxOpeningElement */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: + case 207 /* TaggedTemplateExpression */: + case 163 /* Decorator */: + case 277 /* 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 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: checkAccessorDeclaration(node); break; - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: checkClassExpressionDeferred(node); break; - case 274 /* JsxSelfClosingElement */: + case 276 /* JsxSelfClosingElement */: checkJsxSelfClosingElementDeferred(node); break; - case 273 /* JsxElement */: + case 275 /* JsxElement */: checkJsxElementDeferred(node); break; } currentNode = saveCurrentNode; - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } function checkSourceFile(node) { - ts.tracing.push("check" /* Check */, "checkSourceFile", { path: node.path }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkSourceFile", { path: node.path }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeCheck"); checkSourceFileWorker(node); ts.performance.mark("afterCheck"); ts.performance.measure("Check", "beforeCheck", "afterCheck"); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } function unusedIsError(kind, isAmbient) { if (isAmbient) { @@ -77994,7 +80809,7 @@ var ts; checkGrammarSourceFile(node); ts.clear(potentialThisCollisions); ts.clear(potentialNewTargetCollisions); - ts.clear(potentialWeakMapCollisions); + ts.clear(potentialWeakMapSetCollisions); ts.forEach(node.statements, checkSourceElement); checkSourceElement(node.endOfFileToken); checkDeferredNodes(node); @@ -78024,9 +80839,9 @@ var ts; ts.forEach(potentialNewTargetCollisions, checkIfNewTargetIsCapturedInEnclosingScope); ts.clear(potentialNewTargetCollisions); } - if (potentialWeakMapCollisions.length) { - ts.forEach(potentialWeakMapCollisions, checkWeakMapCollision); - ts.clear(potentialWeakMapCollisions); + if (potentialWeakMapSetCollisions.length) { + ts.forEach(potentialWeakMapSetCollisions, checkWeakMapSetCollision); + ts.clear(potentialWeakMapSetCollisions); } links.flags |= 1 /* TypeChecked */; } @@ -78098,17 +80913,17 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 297 /* SourceFile */: - if (!ts.isExternalOrCommonJsModule(location)) + case 299 /* SourceFile */: + if (!ts.isExternalModule(location)) break; // falls through - case 256 /* ModuleDeclaration */: - copySymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); + case 258 /* ModuleDeclaration */: + copyLocallyVisibleExportSymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); break; - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); @@ -78116,8 +80931,8 @@ 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 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: + case 254 /* ClassDeclaration */: + case 255 /* 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. @@ -78126,7 +80941,7 @@ var ts; copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* Type */); } break; - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -78166,27 +80981,37 @@ var ts; }); } } + function copyLocallyVisibleExportSymbols(source, meaning) { + if (meaning) { + source.forEach(function (symbol) { + // Similar condition as in `resolveNameHelper` + if (!ts.getDeclarationOfKind(symbol, 272 /* ExportSpecifier */) && !ts.getDeclarationOfKind(symbol, 271 /* NamespaceExport */)) { + copySymbol(symbol, meaning); + } + }); + } + } } function isTypeDeclarationName(name) { - return name.kind === 78 /* Identifier */ && + return name.kind === 79 /* Identifier */ && isTypeDeclaration(name.parent) && ts.getNameOfDeclaration(name.parent) === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 159 /* TypeParameter */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 255 /* EnumDeclaration */: - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 325 /* JSDocEnumTag */: + case 161 /* TypeParameter */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 257 /* EnumDeclaration */: + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + case 333 /* JSDocEnumTag */: return true; - case 262 /* ImportClause */: + case 264 /* ImportClause */: return node.isTypeOnly; - case 265 /* ImportSpecifier */: - case 270 /* ExportSpecifier */: + case 267 /* ImportSpecifier */: + case 272 /* ExportSpecifier */: return node.parent.parent.isTypeOnly; default: return false; @@ -78194,25 +81019,16 @@ var ts; } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(node) { - while (node.parent.kind === 157 /* QualifiedName */) { + while (node.parent.kind === 159 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 173 /* TypeReference */; + return node.parent.kind === 175 /* TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 201 /* PropertyAccessExpression */) { - node = node.parent; - } - return node.parent.kind === 223 /* ExpressionWithTypeArguments */; - } - function isJSDocEntryNameReference(node) { - while (node.parent.kind === 157 /* QualifiedName */) { + while (node.parent.kind === 203 /* PropertyAccessExpression */) { node = node.parent; } - while (node.parent.kind === 201 /* PropertyAccessExpression */) { - node = node.parent; - } - return node.parent.kind === 302 /* JSDocNameReference */; + return node.parent.kind === 225 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -78240,13 +81056,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 157 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 159 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 260 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 262 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 266 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 268 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -78272,7 +81088,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 195 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 197 /* ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -78282,17 +81098,17 @@ var ts; return getSymbolOfNode(name.parent); } if (ts.isInJSFile(name) && - name.parent.kind === 201 /* PropertyAccessExpression */ && + name.parent.kind === 203 /* PropertyAccessExpression */ && name.parent === name.parent.parent.left) { // Check if this is a special property assignment - if (!ts.isPrivateIdentifier(name)) { + if (!ts.isPrivateIdentifier(name) && !ts.isJSDocMemberName(name)) { var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(name); if (specialPropertyAssignmentSymbol) { return specialPropertyAssignmentSymbol; } } } - if (name.parent.kind === 266 /* ExportAssignment */ && ts.isEntityNameExpression(name)) { + if (name.parent.kind === 268 /* 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); @@ -78300,13 +81116,13 @@ var ts; return success; } } - else if (!ts.isPropertyAccessExpression(name) && !ts.isPrivateIdentifier(name) && isInRightSideOfImportOrExportAssignment(name)) { + 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, 260 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(name, 262 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(name, /*dontResolveAlias*/ true); } - if (!ts.isPropertyAccessExpression(name) && !ts.isPrivateIdentifier(name)) { + if (ts.isEntityName(name)) { var possibleImportNode = isImportTypeQualifierPart(name); if (possibleImportNode) { getTypeFromTypeNode(possibleImportNode); @@ -78314,13 +81130,13 @@ var ts; return sym === unknownSymbol ? undefined : sym; } } - while (ts.isRightSideOfQualifiedNameOrPropertyAccess(name)) { + while (ts.isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName(name)) { name = name.parent; } if (isHeritageClauseElementIdentifier(name)) { var meaning = 0 /* None */; // In an interface or class, we're definitely interested in a type. - if (name.parent.kind === 223 /* ExpressionWithTypeArguments */) { + if (name.parent.kind === 225 /* ExpressionWithTypeArguments */) { meaning = 788968 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(name.parent)) { @@ -78336,10 +81152,10 @@ var ts; return entityNameSymbol; } } - if (name.parent.kind === 326 /* JSDocParameterTag */) { + if (name.parent.kind === 334 /* JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(name.parent); } - if (name.parent.kind === 159 /* TypeParameter */ && name.parent.parent.kind === 330 /* JSDocTemplateTag */) { + if (name.parent.kind === 161 /* TypeParameter */ && name.parent.parent.kind === 338 /* JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJSFile(name)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(name.parent); return typeParameter && typeParameter.symbol; @@ -78349,43 +81165,81 @@ var ts; // Missing entity name. return undefined; } - if (name.kind === 78 /* Identifier */) { + 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 */) { if (ts.isJSXTagName(name) && isJsxIntrinsicIdentifier(name)) { var symbol = getIntrinsicTagSymbol(name.parent); return symbol === unknownSymbol ? undefined : symbol; } - return resolveEntityName(name, 111551 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); + var result = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ !isJSDoc_1, ts.getHostSignatureFromJSDoc(name)); + if (!result && isJSDoc_1) { + var container = ts.findAncestor(name, ts.or(ts.isClassLike, ts.isInterfaceDeclaration)); + if (container) { + return resolveJSDocMemberName(name, getSymbolOfNode(container)); + } + } + return result; } - else if (name.kind === 201 /* PropertyAccessExpression */ || name.kind === 157 /* QualifiedName */) { + else if (name.kind === 203 /* PropertyAccessExpression */ || name.kind === 159 /* QualifiedName */) { var links = getNodeLinks(name); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (name.kind === 201 /* PropertyAccessExpression */) { - checkPropertyAccessExpression(name); + if (name.kind === 203 /* PropertyAccessExpression */) { + checkPropertyAccessExpression(name, 0 /* Normal */); } else { - checkQualifiedName(name); + checkQualifiedName(name, 0 /* Normal */); + } + if (!links.resolvedSymbol && isJSDoc_1 && ts.isQualifiedName(name)) { + return resolveJSDocMemberName(name); } return links.resolvedSymbol; } + else if (ts.isJSDocMemberName(name)) { + return resolveJSDocMemberName(name); + } } else if (isTypeReferenceIdentifier(name)) { - var meaning = name.parent.kind === 173 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; + var meaning = name.parent.kind === 175 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; return resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (isJSDocEntryNameReference(name)) { - var meaning = 788968 /* Type */ | 1920 /* Namespace */ | 111551 /* Value */; - return resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true, ts.getHostSignatureFromJSDoc(name)); - } - if (name.parent.kind === 172 /* TypePredicate */) { + if (name.parent.kind === 174 /* TypePredicate */) { return resolveEntityName(name, /*meaning*/ 1 /* FunctionScopedVariable */); } - // Do we want to return undefined here? return undefined; } + /** + * Recursively resolve entity names and jsdoc instance references: + * 1. K#m as K.prototype.m for a class (or other value) K + * 2. K.m as K.prototype.m + * 3. I.m as I.m for a type I, or any other I.m that fails to resolve in (1) or (2) + * + * For unqualified names, a container K may be provided as a second argument. + */ + function resolveJSDocMemberName(name, container) { + if (ts.isEntityName(name)) { + // resolve static values first + var meaning = 788968 /* Type */ | 1920 /* Namespace */ | 111551 /* Value */; + var symbol = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true, ts.getHostSignatureFromJSDoc(name)); + if (!symbol && ts.isIdentifier(name) && container) { + symbol = getMergedSymbol(getSymbol(getExportsOfSymbol(container), name.escapedText, meaning)); + } + if (symbol) { + return symbol; + } + } + var left = ts.isIdentifier(name) ? container : resolveJSDocMemberName(name.left); + var right = ts.isIdentifier(name) ? name.escapedText : name.right.escapedText; + if (left) { + var proto = left.flags & 111551 /* Value */ && getPropertyOfType(getTypeOfSymbol(left), "prototype"); + var t = proto ? getTypeOfSymbol(proto) : getDeclaredTypeOfSymbol(left); + return getPropertyOfType(t, right); + } + } function getSymbolAtLocation(node, ignoreErrors) { - if (node.kind === 297 /* SourceFile */) { + if (node.kind === 299 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; @@ -78404,12 +81258,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(parent.parent); } - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfNameOrPropertyAccessExpression(node); } - else if (parent.kind === 198 /* BindingElement */ && - grandParent.kind === 196 /* ObjectBindingPattern */ && + else if (parent.kind === 200 /* BindingElement */ && + grandParent.kind === 198 /* ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText); @@ -78419,12 +81273,12 @@ var ts; } } switch (node.kind) { - case 78 /* Identifier */: - case 79 /* PrivateIdentifier */: - case 201 /* PropertyAccessExpression */: - case 157 /* QualifiedName */: + case 79 /* Identifier */: + case 80 /* PrivateIdentifier */: + case 203 /* PropertyAccessExpression */: + case 159 /* QualifiedName */: return getSymbolOfNameOrPropertyAccessExpression(node); - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -78436,14 +81290,14 @@ var ts; return checkExpression(node).symbol; } // falls through - case 187 /* ThisType */: + case 189 /* ThisType */: return getTypeFromThisTypeNode(node).symbol; - case 105 /* SuperKeyword */: + case 106 /* SuperKeyword */: return checkExpression(node).symbol; - case 132 /* ConstructorKeyword */: + case 133 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 166 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 168 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -78454,7 +81308,7 @@ var ts; // 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 === 261 /* ImportDeclaration */ || node.parent.kind === 267 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 263 /* ImportDeclaration */ || node.parent.kind === 269 /* 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); @@ -78471,21 +81325,21 @@ var ts; ? getTypeFromTypeNode(grandParent.objectType) : undefined; return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text)); - case 87 /* DefaultKeyword */: - case 97 /* FunctionKeyword */: + case 88 /* DefaultKeyword */: + case 98 /* FunctionKeyword */: case 38 /* EqualsGreaterThanToken */: - case 83 /* ClassKeyword */: + case 84 /* ClassKeyword */: return getSymbolOfNode(node.parent); - case 195 /* ImportType */: + case 197 /* ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal, ignoreErrors) : undefined; - case 92 /* ExportKeyword */: + case 93 /* ExportKeyword */: return ts.isExportAssignment(node.parent) ? ts.Debug.checkDefined(node.parent.symbol) : undefined; default: return undefined; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 289 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 291 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 111551 /* Value */ | 2097152 /* Alias */); } return undefined; @@ -78564,27 +81418,27 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfAssignmentPattern(expr) { - ts.Debug.assert(expr.kind === 200 /* ObjectLiteralExpression */ || expr.kind === 199 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 202 /* ObjectLiteralExpression */ || expr.kind === 201 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 239 /* ForOfStatement */) { + if (expr.parent.kind === 241 /* 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 === 216 /* BinaryExpression */) { + if (expr.parent.kind === 218 /* 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 === 288 /* PropertyAssignment */) { - var node_2 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); - var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_2) || errorType; - var propertyIndex = ts.indexOfNode(node_2.properties, expr.parent); - return checkObjectLiteralDestructuringPropertyAssignment(node_2, typeOfParentObjectLiteral, propertyIndex); + if (expr.parent.kind === 290 /* 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); + return checkObjectLiteralDestructuringPropertyAssignment(node_3, typeOfParentObjectLiteral, propertyIndex); } // Array literal assignment - array destructuring pattern var node = ts.cast(expr.parent, ts.isArrayLiteralExpression); @@ -78623,12 +81477,12 @@ var ts; function getClassElementPropertyKeyType(element) { var name = element.name; switch (name.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return getLiteralType(ts.idText(name)); case 8 /* NumericLiteral */: case 10 /* StringLiteral */: return getLiteralType(name.text); - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(name); return isTypeAssignableToKind(nameType, 12288 /* ESSymbolLike */) ? nameType : stringType; default: @@ -78725,6 +81579,7 @@ var ts; // When resolved as an expression identifier, if the given node references an exported entity, return the declaration // node of the exported entity's container. Otherwise, return undefined. function getReferencedExportContainer(nodeIn, prefixLocals) { + var _a; var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { // When resolving the export container for the name of a module or enum @@ -78745,7 +81600,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 297 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && ((_a = parentSymbol_1.valueDeclaration) === null || _a === void 0 ? void 0 : _a.kind) === 299 /* 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. @@ -78775,11 +81630,12 @@ var ts; return undefined; } function isSymbolOfDestructuredElementOfCatchBinding(symbol) { - return ts.isBindingElement(symbol.valueDeclaration) - && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 287 /* CatchClause */; + return symbol.valueDeclaration + && ts.isBindingElement(symbol.valueDeclaration) + && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 289 /* CatchClause */; } function isSymbolOfDeclarationWithCollidingName(symbol) { - if (symbol.flags & 418 /* BlockScoped */ && !ts.isSourceFile(symbol.valueDeclaration)) { + if (symbol.flags & 418 /* BlockScoped */ && symbol.valueDeclaration && !ts.isSourceFile(symbol.valueDeclaration)) { var links = getSymbolLinks(symbol); if (links.isDeclarationWithCollidingName === undefined) { var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); @@ -78807,7 +81663,7 @@ var ts; // they will not collide with anything var isDeclaredInLoop = nodeLinks_1.flags & 524288 /* BlockScopedBindingInLoop */; var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false); - var inLoopBodyBlock = container.kind === 230 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 232 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -78848,20 +81704,20 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 262 /* ImportClause */: - case 263 /* NamespaceImport */: - case 265 /* ImportSpecifier */: - case 270 /* ExportSpecifier */: + case 264 /* ImportClause */: + case 265 /* NamespaceImport */: + case 267 /* ImportSpecifier */: + case 272 /* ExportSpecifier */: var symbol = getSymbolOfNode(node) || unknownSymbol; return isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && (ts.isNamespaceExport(exportClause) || ts.some(exportClause.elements, isValueAliasDeclaration)); - case 266 /* ExportAssignment */: - return node.expression && node.expression.kind === 78 /* Identifier */ ? + case 268 /* ExportAssignment */: + return node.expression && node.expression.kind === 79 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : true; } @@ -78869,7 +81725,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 297 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 299 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -78884,7 +81740,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 */) && - (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target)); + (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target)); } function isConstEnumOrConstEnumOnlyModule(s) { return isConstEnumSymbol(s) || !!s.constEnumOnlyModule; @@ -78892,13 +81748,14 @@ var ts; function isReferencedAliasDeclaration(node, checkChildren) { if (isAliasSymbolDeclaration(node)) { var symbol = getSymbolOfNode(node); - if (symbol && getSymbolLinks(symbol).referenced) { + var links = symbol && getSymbolLinks(symbol); + if (links === null || links === void 0 ? void 0 : links.referenced) { return true; } var target = getSymbolLinks(symbol).target; // TODO: GH#18217 if (target && ts.getEffectiveModifierFlags(node) & 1 /* Export */ && target.flags & 111551 /* Value */ && - (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) { + (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) { // An `export import ... =` of a value symbol is always considered referenced return true; } @@ -78935,13 +81792,13 @@ var ts; !isOptionalParameter(parameter) && !ts.isJSDocParameterTag(parameter) && !!parameter.initializer && - !ts.hasSyntacticModifier(parameter, 92 /* ParameterPropertyModifier */); + !ts.hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */); } function isOptionalUninitializedParameterProperty(parameter) { return strictNullChecks && isOptionalParameter(parameter) && !parameter.initializer && - ts.hasSyntacticModifier(parameter, 92 /* ParameterPropertyModifier */); + ts.hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */); } function isOptionalUninitializedParameter(parameter) { return !!strictNullChecks && @@ -78976,15 +81833,15 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 291 /* EnumMember */: - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 293 /* EnumMember */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 291 /* EnumMember */) { + if (node.kind === 293 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -79072,7 +81929,7 @@ var ts; function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) { var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor); if (!declaration) { - return ts.factory.createToken(128 /* AnyKeyword */); + return ts.factory.createToken(129 /* AnyKeyword */); } // Get type of the symbol if this is the valid symbol otherwise get type at location var symbol = getSymbolOfNode(declaration); @@ -79091,7 +81948,7 @@ var ts; function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) { var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike); if (!signatureDeclaration) { - return ts.factory.createToken(128 /* AnyKeyword */); + return ts.factory.createToken(129 /* AnyKeyword */); } var signature = getSignatureFromDeclaration(signatureDeclaration); return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); @@ -79099,7 +81956,7 @@ var ts; function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) { var expr = ts.getParseTreeNode(exprIn, ts.isExpression); if (!expr) { - return ts.factory.createToken(128 /* AnyKeyword */); + return ts.factory.createToken(129 /* AnyKeyword */); } var type = getWidenedType(getRegularTypeOfExpression(expr)); return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); @@ -79137,8 +81994,7 @@ var ts; } function isLiteralConstDeclaration(node) { if (ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node)) { - var type = getTypeOfSymbol(getSymbolOfNode(node)); - return !!(type.flags & 2944 /* Literal */) && isFreshLiteralType(type); + return isFreshLiteralType(getTypeOfSymbol(getSymbolOfNode(node))); } return false; } @@ -79257,12 +82113,12 @@ var ts; getJsxFragmentFactoryEntity: getJsxFragmentFactoryEntity, getAllAccessorDeclarations: function (accessor) { accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); // TODO: GH#18217 - var otherKind = accessor.kind === 168 /* SetAccessor */ ? 167 /* GetAccessor */ : 168 /* SetAccessor */; + var otherKind = accessor.kind === 170 /* SetAccessor */ ? 169 /* GetAccessor */ : 170 /* 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 === 168 /* SetAccessor */ ? accessor : otherAccessor; - var getAccessor = accessor.kind === 167 /* GetAccessor */ ? accessor : otherAccessor; + var setAccessor = accessor.kind === 170 /* SetAccessor */ ? accessor : otherAccessor; + var getAccessor = accessor.kind === 169 /* GetAccessor */ ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -79278,7 +82134,7 @@ var ts; }, getDeclarationStatementsForSourceFile: function (node, flags, tracker, bundled) { var n = ts.getParseTreeNode(node); - ts.Debug.assert(n && n.kind === 297 /* SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); + ts.Debug.assert(n && n.kind === 299 /* SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); var sym = getSymbolOfNode(node); if (!sym) { return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker, bundled); @@ -79301,11 +82157,13 @@ var ts; var s = _a[_i]; if (s.mergeId) { var merged = getMergedSymbol(s); - for (var _b = 0, _c = merged.declarations; _b < _c.length; _b++) { - var d = _c[_b]; - var declFile = ts.getSourceFileOfNode(d); - if (declFile === importTarget) { - return true; + if (merged.declarations) { + for (var _b = 0, _c = merged.declarations; _b < _c.length; _b++) { + var d = _c[_b]; + var declFile = ts.getSourceFileOfNode(d); + if (declFile === importTarget) { + return true; + } } } } @@ -79313,7 +82171,7 @@ var ts; return false; } function isInHeritageClause(node) { - return node.parent && node.parent.kind === 223 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 286 /* HeritageClause */; + return node.parent && node.parent.kind === 225 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 288 /* HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -79325,7 +82183,7 @@ var ts; // 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 === 78 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 201 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { + if ((node.kind === 79 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 203 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); @@ -79334,10 +82192,7 @@ var ts; // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForSymbol(symbol, meaning) { // program does not have any files with type reference directives - bail out - if (!fileToDirective) { - return undefined; - } - if (!isSymbolFromTypeDeclarationFile(symbol)) { + if (!fileToDirective || !isSymbolFromTypeDeclarationFile(symbol)) { return undefined; } // check what declarations in the symbol can contribute to the target meaning @@ -79376,7 +82231,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 297 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 299 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -79404,12 +82259,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 256 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 258 /* 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, 297 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 299 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -79429,7 +82284,7 @@ var ts; // It is an error for a non-external-module (i.e. script) to declare its own `globalThis`. // We can't use `builtinGlobals` for this due to synthetic expando-namespace generation in JS files. var fileGlobalThisSymbol = file.locals.get("globalThis"); - if (fileGlobalThisSymbol) { + if (fileGlobalThisSymbol === null || fileGlobalThisSymbol === void 0 ? void 0 : fileGlobalThisSymbol.declarations) { for (var _d = 0, _e = fileGlobalThisSymbol.declarations; _d < _e.length; _d++) { var declaration = _e[_d]; diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0, "globalThis")); @@ -79553,6 +82408,16 @@ var ts; 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 */) { + 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 */) { + 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); + } + } } } } @@ -79602,14 +82467,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 165 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 167 /* 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 === 167 /* GetAccessor */ || node.kind === 168 /* SetAccessor */) { + else if (node.kind === 169 /* GetAccessor */ || node.kind === 170 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -79622,31 +82487,51 @@ var ts; if (quickResult !== undefined) { return quickResult; } - var lastStatic, lastDeclare, lastAsync, lastReadonly; + var lastStatic, lastDeclare, lastAsync, lastReadonly, lastOverride; var flags = 0 /* None */; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 142 /* ReadonlyKeyword */) { - if (node.kind === 162 /* PropertySignature */ || node.kind === 164 /* MethodSignature */) { + if (modifier.kind !== 143 /* ReadonlyKeyword */) { + if (node.kind === 164 /* PropertySignature */ || node.kind === 166 /* MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 171 /* IndexSignature */) { + if (node.kind === 173 /* IndexSignature */ && (modifier.kind !== 124 /* StaticKeyword */ || !ts.isClassLike(node.parent))) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 84 /* ConstKeyword */: - if (node.kind !== 255 /* EnumDeclaration */) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(84 /* ConstKeyword */)); + case 85 /* ConstKeyword */: + if (node.kind !== 257 /* EnumDeclaration */) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(85 /* ConstKeyword */)); } break; - case 122 /* PublicKeyword */: - case 121 /* ProtectedKeyword */: - case 120 /* PrivateKeyword */: + case 157 /* OverrideKeyword */: + // If node.kind === SyntaxKind.Parameter, checkParameter reports an error if it's not a parameter property. + if (flags & 16384 /* Override */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "override"); + } + else if (flags & 2 /* Ambient */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "override", "declare"); + } + else if (flags & 64 /* Readonly */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "override", "readonly"); + } + else if (flags & 256 /* Async */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "override", "async"); + } + flags |= 16384 /* Override */; + lastOverride = modifier; + break; + case 123 /* PublicKeyword */: + case 122 /* ProtectedKeyword */: + case 121 /* PrivateKeyword */: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); if (flags & 28 /* AccessibilityModifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); } + else if (flags & 16384 /* Override */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "override"); + } else if (flags & 32 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } @@ -79656,23 +82541,23 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 257 /* ModuleBlock */ || node.parent.kind === 297 /* SourceFile */) { + else if (node.parent.kind === 259 /* ModuleBlock */ || node.parent.kind === 299 /* 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 === 120 /* PrivateKeyword */) { + if (modifier.kind === 121 /* PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "abstract"); } } - else if (ts.isPrivateIdentifierPropertyDeclaration(node)) { + else if (ts.isPrivateIdentifierClassElementDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics.An_accessibility_modifier_cannot_be_used_with_a_private_identifier); } flags |= ts.modifierToFlag(modifier.kind); break; - case 123 /* StaticKeyword */: + case 124 /* StaticKeyword */: if (flags & 32 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } @@ -79682,33 +82567,33 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 257 /* ModuleBlock */ || node.parent.kind === 297 /* SourceFile */) { + else if (node.parent.kind === 259 /* ModuleBlock */ || node.parent.kind === 299 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 160 /* Parameter */) { + else if (node.kind === 162 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - else if (ts.isPrivateIdentifierPropertyDeclaration(node)) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "static"); + else if (flags & 16384 /* Override */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "override"); } flags |= 32 /* Static */; lastStatic = modifier; break; - case 142 /* ReadonlyKeyword */: + case 143 /* ReadonlyKeyword */: if (flags & 64 /* Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 163 /* PropertyDeclaration */ && node.kind !== 162 /* PropertySignature */ && node.kind !== 171 /* IndexSignature */ && node.kind !== 160 /* Parameter */) { - // If node.kind === SyntaxKind.Parameter, checkParameter report an error if it's not a parameter property. + else if (node.kind !== 165 /* PropertyDeclaration */ && node.kind !== 164 /* PropertySignature */ && node.kind !== 173 /* IndexSignature */ && node.kind !== 162 /* 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 */; lastReadonly = modifier; break; - case 92 /* ExportKeyword */: + case 93 /* ExportKeyword */: if (flags & 1 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -79724,53 +82609,56 @@ var ts; 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 === 160 /* Parameter */) { + else if (node.kind === 162 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; - case 87 /* DefaultKeyword */: - var container = node.parent.kind === 297 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 256 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + case 88 /* DefaultKeyword */: + var container = node.parent.kind === 299 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 258 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } flags |= 512 /* Default */; break; - case 133 /* DeclareKeyword */: + case 134 /* DeclareKeyword */: if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } + else if (flags & 16384 /* 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 === 160 /* Parameter */) { + else if (node.kind === 162 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 8388608 /* Ambient */) && node.parent.kind === 257 /* ModuleBlock */) { + else if ((node.parent.flags & 8388608 /* Ambient */) && node.parent.kind === 259 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } - else if (ts.isPrivateIdentifierPropertyDeclaration(node)) { + else if (ts.isPrivateIdentifierClassElementDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "declare"); } flags |= 2 /* Ambient */; lastDeclare = modifier; break; - case 125 /* AbstractKeyword */: + case 126 /* AbstractKeyword */: if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 252 /* ClassDeclaration */ && - node.kind !== 175 /* ConstructorType */) { - if (node.kind !== 165 /* MethodDeclaration */ && - node.kind !== 163 /* PropertyDeclaration */ && - node.kind !== 167 /* GetAccessor */ && - node.kind !== 168 /* SetAccessor */) { + if (node.kind !== 254 /* ClassDeclaration */ && + node.kind !== 177 /* ConstructorType */) { + if (node.kind !== 167 /* MethodDeclaration */ && + node.kind !== 165 /* PropertyDeclaration */ && + node.kind !== 169 /* GetAccessor */ && + node.kind !== 170 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 252 /* ClassDeclaration */ && ts.hasSyntacticModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 254 /* ClassDeclaration */ && ts.hasSyntacticModifier(node.parent, 128 /* Abstract */))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32 /* Static */) { @@ -79782,20 +82670,23 @@ var ts; if (flags & 256 /* Async */ && lastAsync) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "async", "abstract"); } + if (flags & 16384 /* Override */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "abstract", "override"); + } } - if (ts.isNamedDeclaration(node) && node.name.kind === 79 /* PrivateIdentifier */) { + if (ts.isNamedDeclaration(node) && node.name.kind === 80 /* PrivateIdentifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "abstract"); } flags |= 128 /* Abstract */; break; - case 129 /* AsyncKeyword */: + case 130 /* AsyncKeyword */: if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } else if (flags & 2 /* Ambient */ || node.parent.flags & 8388608 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 160 /* Parameter */) { + else if (node.kind === 162 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } if (flags & 128 /* Abstract */) { @@ -79806,13 +82697,16 @@ var ts; break; } } - if (node.kind === 166 /* Constructor */) { + if (node.kind === 168 /* Constructor */) { if (flags & 32 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } if (flags & 128 /* Abstract */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract"); // TODO: GH#18217 } + if (flags & 16384 /* Override */) { + return grammarErrorOnNode(lastOverride, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "override"); // TODO: GH#18217 + } else if (flags & 256 /* Async */) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); } @@ -79821,13 +82715,13 @@ var ts; } return false; } - else if ((node.kind === 261 /* ImportDeclaration */ || node.kind === 260 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 263 /* ImportDeclaration */ || node.kind === 262 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 160 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 162 /* Parameter */ && (flags & 16476 /* 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 === 160 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 162 /* Parameter */ && (flags & 16476 /* ParameterPropertyModifier */) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256 /* Async */) { @@ -79848,39 +82742,39 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 166 /* Constructor */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 171 /* IndexSignature */: - case 256 /* ModuleDeclaration */: - case 261 /* ImportDeclaration */: - case 260 /* ImportEqualsDeclaration */: - case 267 /* ExportDeclaration */: - case 266 /* ExportAssignment */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 160 /* Parameter */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 168 /* Constructor */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 173 /* IndexSignature */: + case 258 /* ModuleDeclaration */: + case 263 /* ImportDeclaration */: + case 262 /* ImportEqualsDeclaration */: + case 269 /* ExportDeclaration */: + case 268 /* ExportAssignment */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 162 /* Parameter */: return false; default: - if (node.parent.kind === 257 /* ModuleBlock */ || node.parent.kind === 297 /* SourceFile */) { + if (node.parent.kind === 259 /* ModuleBlock */ || node.parent.kind === 299 /* SourceFile */) { return false; } switch (node.kind) { - case 251 /* FunctionDeclaration */: - return nodeHasAnyModifiersExcept(node, 129 /* AsyncKeyword */); - case 252 /* ClassDeclaration */: - case 175 /* ConstructorType */: - return nodeHasAnyModifiersExcept(node, 125 /* AbstractKeyword */); - case 253 /* InterfaceDeclaration */: - case 232 /* VariableStatement */: - case 254 /* TypeAliasDeclaration */: + case 253 /* FunctionDeclaration */: + return nodeHasAnyModifiersExcept(node, 130 /* AsyncKeyword */); + case 254 /* ClassDeclaration */: + case 177 /* ConstructorType */: + return nodeHasAnyModifiersExcept(node, 126 /* AbstractKeyword */); + case 255 /* InterfaceDeclaration */: + case 234 /* VariableStatement */: + case 256 /* TypeAliasDeclaration */: return true; - case 255 /* EnumDeclaration */: - return nodeHasAnyModifiersExcept(node, 84 /* ConstKeyword */); + case 257 /* EnumDeclaration */: + return nodeHasAnyModifiersExcept(node, 85 /* ConstKeyword */); default: ts.Debug.fail(); } @@ -79891,10 +82785,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 165 /* MethodDeclaration */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -80013,7 +82907,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 147 /* StringKeyword */ && parameter.type.kind !== 144 /* NumberKeyword */) { + if (parameter.type.kind !== 148 /* StringKeyword */ && parameter.type.kind !== 145 /* NumberKeyword */) { var type = getTypeFromTypeNode(parameter.type); if (type.flags & 4 /* String */ || type.flags & 8 /* Number */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead, ts.getTextOfNode(parameter.name), typeToString(type), typeToString(node.type ? getTypeFromTypeNode(node.type) : anyType)); @@ -80055,7 +82949,7 @@ var ts; if (args) { for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 222 /* OmittedExpression */) { + if (arg.kind === 224 /* OmittedExpression */) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -80085,7 +82979,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 === 93 /* ExtendsKeyword */) { + if (heritageClause.token === 94 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -80098,7 +82992,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 116 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 117 /* ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -80114,14 +83008,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 93 /* ExtendsKeyword */) { + if (heritageClause.token === 94 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 116 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 117 /* ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -80132,20 +83026,20 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 158 /* ComputedPropertyName */) { + if (node.kind !== 160 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 216 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* CommaToken */) { + if (computedPropertyName.expression.kind === 218 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* 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 === 251 /* FunctionDeclaration */ || - node.kind === 208 /* FunctionExpression */ || - node.kind === 165 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 253 /* FunctionDeclaration */ || + node.kind === 210 /* FunctionExpression */ || + node.kind === 167 /* MethodDeclaration */); if (node.flags & 8388608 /* Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -80164,7 +83058,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 === 290 /* SpreadAssignment */) { + if (prop.kind === 292 /* SpreadAssignment */) { if (inDestructuring) { // a rest property cannot be destructured any further var expression = ts.skipParentheses(prop.expression); @@ -80175,24 +83069,24 @@ var ts; continue; } var name = prop.name; - if (name.kind === 158 /* ComputedPropertyName */) { + if (name.kind === 160 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 289 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 291 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern // outside of destructuring it is a syntax error return 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 === 79 /* PrivateIdentifier */) { - return grammarErrorOnNode(name, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); + if (name.kind === 80 /* 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 (prop.modifiers) { // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { // TODO: GH#19955 var mod = _c[_b]; - if (mod.kind !== 129 /* AsyncKeyword */ || prop.kind !== 165 /* MethodDeclaration */) { + if (mod.kind !== 130 /* AsyncKeyword */ || prop.kind !== 167 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -80207,10 +83101,10 @@ 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 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); // falls through - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8 /* NumericLiteral */) { @@ -80218,13 +83112,13 @@ var ts; } currentKind = 4 /* PropertyAssignment */; break; - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: currentKind = 8 /* Method */; break; - case 167 /* GetAccessor */: + case 169 /* GetAccessor */: currentKind = 1 /* GetAccessor */; break; - case 168 /* SetAccessor */: + case 170 /* SetAccessor */: currentKind = 2 /* SetAccessor */; break; default: @@ -80259,11 +83153,12 @@ var ts; } } function checkGrammarJsxElement(node) { + checkGrammarJsxName(node.tagName); checkGrammarTypeArguments(node, node.typeArguments); var seen = new ts.Map(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 282 /* JsxSpreadAttribute */) { + if (attr.kind === 284 /* JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -80273,11 +83168,32 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 283 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 285 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } } + function checkGrammarJsxName(node) { + if (ts.isPropertyAccessExpression(node)) { + var propName = node; + do { + var check_1 = checkGrammarJsxNestedIdentifier(propName.name); + if (check_1) { + return check_1; + } + propName = propName.expression; + } while (ts.isPropertyAccessExpression(propName)); + var check = checkGrammarJsxNestedIdentifier(propName); + if (check) { + return check; + } + } + function checkGrammarJsxNestedIdentifier(name) { + if (ts.isIdentifier(name) && ts.idText(name).indexOf(":") !== -1) { + return grammarErrorOnNode(name, ts.Diagnostics.JSX_property_access_expressions_cannot_include_JSX_namespace_names); + } + } + } function checkGrammarJsxExpression(node) { if (node.expression && ts.isCommaSequence(node.expression)) { return grammarErrorOnNode(node.expression, ts.Diagnostics.JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array); @@ -80287,25 +83203,42 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 239 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { - if ((forInOrOfStatement.flags & 32768 /* AwaitContext */) === 0 /* None */) { - // use of 'for-await-of' in non-async function + if (forInOrOfStatement.kind === 241 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if (!(forInOrOfStatement.flags & 32768 /* AwaitContext */)) { var sourceFile = ts.getSourceFileOfNode(forInOrOfStatement); - if (!hasParseDiagnostics(sourceFile)) { - var diagnostic = ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); - var func = ts.getContainingFunction(forInOrOfStatement); - if (func && func.kind !== 166 /* Constructor */) { - ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* 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); - } - diagnostics.add(diagnostic); - return true; + if (ts.isInTopLevelContext(forInOrOfStatement)) { + if (!hasParseDiagnostics(sourceFile)) { + if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) { + diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module)); + } + if ((moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) || languageVersion < 4 /* ES2017 */) { + diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher)); + } + } + } + else { + // use of 'for-await-of' in non-async function + 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 !== 168 /* Constructor */) { + ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* 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); + } + diagnostics.add(diagnostic); + return true; + } } return false; } } - if (forInOrOfStatement.initializer.kind === 250 /* VariableDeclarationList */) { + if (ts.isForOfStatement(forInOrOfStatement) && !(forInOrOfStatement.flags & 32768 /* 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 === 252 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -80320,20 +83253,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 238 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 240 /* 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 === 238 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 240 /* 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 === 238 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 240 /* 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); @@ -80343,26 +83276,34 @@ var ts; return false; } function checkGrammarAccessor(accessor) { - if (!(accessor.flags & 8388608 /* Ambient */)) { + if (!(accessor.flags & 8388608 /* Ambient */) && (accessor.parent.kind !== 179 /* TypeLiteral */) && (accessor.parent.kind !== 255 /* InterfaceDeclaration */)) { if (languageVersion < 1 /* 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)) { + 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 */)) { return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } } - if (accessor.body && ts.hasSyntacticModifier(accessor, 128 /* Abstract */)) { - return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation); + if (accessor.body) { + if (ts.hasSyntacticModifier(accessor, 128 /* Abstract */)) { + return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation); + } + if (accessor.parent.kind === 179 /* TypeLiteral */ || accessor.parent.kind === 255 /* InterfaceDeclaration */) { + return grammarErrorOnNode(accessor.body, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); + } } if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, accessor.kind === 167 /* GetAccessor */ ? + return grammarErrorOnNode(accessor.name, accessor.kind === 169 /* GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - if (accessor.kind === 168 /* SetAccessor */) { + if (accessor.kind === 170 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -80384,17 +83325,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 === 167 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 169 /* GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 167 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 169 /* GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } function checkGrammarTypeOperatorNode(node) { - if (node.operator === 151 /* UniqueKeyword */) { - if (node.type.kind !== 148 /* SymbolKeyword */) { - return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(148 /* SymbolKeyword */)); + if (node.operator === 152 /* UniqueKeyword */) { + if (node.type.kind !== 149 /* SymbolKeyword */) { + return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(149 /* SymbolKeyword */)); } var parent = ts.walkUpParenthesizedTypes(node.parent); if (ts.isInJSFile(parent) && ts.isJSDocTypeExpression(parent)) { @@ -80405,9 +83346,9 @@ var ts; } } switch (parent.kind) { - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: var decl = parent; - if (decl.name.kind !== 78 /* Identifier */) { + if (decl.name.kind !== 79 /* 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)) { @@ -80417,13 +83358,13 @@ var ts; return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: if (!ts.hasSyntacticModifier(parent, 32 /* Static */) || !ts.hasEffectiveModifier(parent, 64 /* Readonly */)) { 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 162 /* PropertySignature */: + case 164 /* PropertySignature */: if (!ts.hasSyntacticModifier(parent, 64 /* 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); } @@ -80432,9 +83373,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_not_allowed_here); } } - else if (node.operator === 142 /* ReadonlyKeyword */) { - if (node.type.kind !== 178 /* ArrayType */ && node.type.kind !== 179 /* TupleType */) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(148 /* SymbolKeyword */)); + else if (node.operator === 143 /* ReadonlyKeyword */) { + if (node.type.kind !== 180 /* ArrayType */ && node.type.kind !== 181 /* TupleType */) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(149 /* SymbolKeyword */)); } } } @@ -80447,10 +83388,10 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 165 /* MethodDeclaration */) { - if (node.parent.kind === 200 /* ObjectLiteralExpression */) { + if (node.kind === 167 /* MethodDeclaration */) { + if (node.parent.kind === 202 /* 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 === 129 /* AsyncKeyword */)) { + if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 130 /* AsyncKeyword */)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } else if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { @@ -80468,6 +83409,9 @@ var ts; } } if (ts.isClassLike(node.parent)) { + if (languageVersion < 2 /* 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 // for property declarations and accessors too, not just methods. // However, property declarations disallow computed names in general, @@ -80476,14 +83420,14 @@ var ts; if (node.flags & 8388608 /* 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 === 165 /* MethodDeclaration */ && !node.body) { + else if (node.kind === 167 /* 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 === 253 /* InterfaceDeclaration */) { + else if (node.parent.kind === 255 /* 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 === 177 /* TypeLiteral */) { + else if (node.parent.kind === 179 /* 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); } } @@ -80494,11 +83438,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 245 /* LabeledStatement */: + case 247 /* 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 === 240 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 242 /* 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); @@ -80506,8 +83450,8 @@ var ts; return false; } break; - case 244 /* SwitchStatement */: - if (node.kind === 241 /* BreakStatement */ && !node.label) { + case 246 /* SwitchStatement */: + if (node.kind === 243 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -80522,13 +83466,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 241 /* BreakStatement */ + var message = node.kind === 243 /* 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 === 241 /* BreakStatement */ + var message = node.kind === 243 /* 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); @@ -80552,12 +83496,12 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return ts.isStringOrNumericLiteralLike(expr) || - expr.kind === 214 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && + expr.kind === 216 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function isBigIntLiteralExpression(expr) { return expr.kind === 9 /* BigIntLiteral */ || - expr.kind === 214 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && + expr.kind === 216 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && expr.operand.kind === 9 /* BigIntLiteral */; } function isSimpleLiteralEnumReference(expr) { @@ -80571,7 +83515,7 @@ var ts; if (initializer) { var isInvalidInitializer = !(isStringOrNumberLiteralExpression(initializer) || isSimpleLiteralEnumReference(initializer) || - initializer.kind === 109 /* TrueKeyword */ || initializer.kind === 94 /* FalseKeyword */ || + initializer.kind === 110 /* TrueKeyword */ || initializer.kind === 95 /* FalseKeyword */ || isBigIntLiteralExpression(initializer)); var isConstOrReadonly = ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node); if (isConstOrReadonly && !node.type) { @@ -80588,7 +83532,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 238 /* ForInStatement */ && node.parent.parent.kind !== 239 /* ForOfStatement */) { + if (node.parent.parent.kind !== 240 /* ForInStatement */ && node.parent.parent.kind !== 241 /* ForOfStatement */) { if (node.flags & 8388608 /* Ambient */) { checkAmbientInitializer(node); } @@ -80601,7 +83545,7 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 232 /* VariableStatement */ || !node.type || node.initializer || node.flags & 8388608 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 234 /* VariableStatement */ || !node.type || node.initializer || node.flags & 8388608 /* Ambient */)) { var message = node.initializer ? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions : !node.type @@ -80624,7 +83568,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkESModuleMarker(name) { - if (name.kind === 78 /* Identifier */) { + if (name.kind === 79 /* 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); } @@ -80641,8 +83585,8 @@ var ts; return false; } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 78 /* Identifier */) { - if (name.originalKeywordKind === 118 /* LetKeyword */) { + if (name.kind === 79 /* Identifier */) { + if (name.originalKeywordKind === 119 /* LetKeyword */) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -80669,15 +83613,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 234 /* IfStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: - case 243 /* WithStatement */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: + case 236 /* IfStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: + case 245 /* WithStatement */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: return false; - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -80695,12 +83639,12 @@ var ts; function checkGrammarMetaProperty(node) { var escapedText = node.name.escapedText; switch (node.keywordToken) { - case 102 /* NewKeyword */: + case 103 /* 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 99 /* ImportKeyword */: + case 100 /* 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"); } @@ -80762,14 +83706,14 @@ var ts; if (ts.isStringLiteral(node.name) && node.name.text === "constructor") { return grammarErrorOnNode(node.name, ts.Diagnostics.Classes_may_not_have_a_field_named_constructor); } - if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { + 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)) { return grammarErrorOnNode(node.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher); } } - else if (node.parent.kind === 253 /* InterfaceDeclaration */) { + else if (node.parent.kind === 255 /* 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; } @@ -80777,7 +83721,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 177 /* TypeLiteral */) { + else if (node.parent.kind === 179 /* TypeLiteral */) { if (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)) { return true; } @@ -80811,13 +83755,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 253 /* InterfaceDeclaration */ || - node.kind === 254 /* TypeAliasDeclaration */ || - node.kind === 261 /* ImportDeclaration */ || - node.kind === 260 /* ImportEqualsDeclaration */ || - node.kind === 267 /* ExportDeclaration */ || - node.kind === 266 /* ExportAssignment */ || - node.kind === 259 /* NamespaceExportDeclaration */ || + if (node.kind === 255 /* InterfaceDeclaration */ || + node.kind === 256 /* TypeAliasDeclaration */ || + node.kind === 263 /* ImportDeclaration */ || + node.kind === 262 /* ImportEqualsDeclaration */ || + node.kind === 269 /* ExportDeclaration */ || + node.kind === 268 /* ExportAssignment */ || + node.kind === 261 /* NamespaceExportDeclaration */ || ts.hasSyntacticModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -80826,7 +83770,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 === 232 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 234 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -80849,7 +83793,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 === 230 /* Block */ || node.parent.kind === 257 /* ModuleBlock */ || node.parent.kind === 297 /* SourceFile */) { + if (node.parent.kind === 232 /* Block */ || node.parent.kind === 259 /* ModuleBlock */ || node.parent.kind === 299 /* SourceFile */) { var links_2 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_2.hasReportedStatementInAmbientContext) { @@ -80871,10 +83815,10 @@ var ts; if (languageVersion >= 1 /* ES5 */) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 191 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 193 /* LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 291 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 293 /* EnumMember */)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { @@ -80980,7 +83924,7 @@ var ts; } } function findBestTypeForObjectLiteral(source, unionTarget) { - if (ts.getObjectFlags(source) & 128 /* ObjectLiteral */ && forEachType(unionTarget, isArrayLikeType)) { + if (ts.getObjectFlags(source) & 128 /* ObjectLiteral */ && someType(unionTarget, isArrayLikeType)) { return ts.find(unionTarget.types, function (t) { return !isArrayLikeType(t); }); } } @@ -81032,6 +83976,10 @@ 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 */)) { + var match = getMatchingUnionConstituentForType(target, source); + if (match) { + return match; + } var sourceProperties = getPropertiesOfType(source); if (sourceProperties) { var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target); @@ -81049,33 +83997,19 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 251 /* FunctionDeclaration */ && declaration.kind !== 165 /* MethodDeclaration */) || + return (declaration.kind !== 253 /* FunctionDeclaration */ && declaration.kind !== 167 /* 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 265 /* ImportSpecifier */: - case 270 /* ExportSpecifier */: + case 267 /* ImportSpecifier */: + case 272 /* ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); } } - function isSomeImportDeclaration(decl) { - switch (decl.kind) { - case 262 /* ImportClause */: // For default import - case 260 /* ImportEqualsDeclaration */: - case 263 /* NamespaceImport */: - case 265 /* ImportSpecifier */: // For rename import `x as y` - return true; - case 78 /* Identifier */: - // For regular import, `decl` is an Identifier under the ImportSpecifier. - return decl.parent.kind === 265 /* ImportSpecifier */; - default: - return false; - } - } var JsxNames; (function (JsxNames) { JsxNames.JSX = "JSX"; @@ -81106,7 +84040,6 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var isTypeNodeOrTypeParameterDeclaration = ts.or(ts.isTypeNode, ts.isTypeParameterDeclaration); function visitNode(node, visitor, test, lift) { if (node === undefined || visitor === undefined) { return node; @@ -81295,6 +84228,24 @@ var ts; return updated; } ts.visitFunctionBody = visitFunctionBody; + /** + * Visits an iteration body, adding any block-scoped variables required by the transformation. + */ + function visitIterationBody(body, visitor, context) { + context.startBlockScope(); + var updated = visitNode(body, visitor, ts.isStatement, context.factory.liftToBlock); + var declarations = context.endBlockScope(); + if (ts.some(declarations)) { + if (ts.isBlock(updated)) { + declarations.push.apply(declarations, updated.statements); + return context.factory.updateBlock(updated, declarations); + } + declarations.push(updated); + return context.factory.createBlock(declarations); + } + return updated; + } + ts.visitIterationBody = visitIterationBody; function visitEachChild(node, visitor, context, nodesVisitor, tokenVisitor, nodeVisitor) { if (nodesVisitor === void 0) { nodesVisitor = visitNodes; } if (nodeVisitor === void 0) { nodeVisitor = visitNode; } @@ -81303,299 +84254,433 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 156 /* LastToken */) || kind === 187 /* ThisType */) { + if ((kind > 0 /* FirstToken */ && kind <= 158 /* LastToken */) || kind === 189 /* ThisType */) { return node; } var factory = context.factory; switch (kind) { // Names - case 78 /* Identifier */: - return factory.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration)); - case 157 /* QualifiedName */: + case 79 /* Identifier */: + ts.Debug.type(node); + return factory.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNodeOrTypeParameterDeclaration)); + case 159 /* QualifiedName */: + ts.Debug.type(node); return factory.updateQualifiedName(node, nodeVisitor(node.left, visitor, ts.isEntityName), nodeVisitor(node.right, visitor, ts.isIdentifier)); - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: + ts.Debug.type(node); return factory.updateComputedPropertyName(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Signature elements - case 159 /* TypeParameter */: + case 161 /* TypeParameter */: + ts.Debug.type(node); return factory.updateTypeParameterDeclaration(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.constraint, visitor, ts.isTypeNode), nodeVisitor(node.default, visitor, ts.isTypeNode)); - case 160 /* Parameter */: - return factory.updateParameterDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isToken), nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 161 /* Decorator */: + case 162 /* Parameter */: + ts.Debug.type(node); + return factory.updateParameterDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), 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 163 /* Decorator */: + ts.Debug.type(node); return factory.updateDecorator(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Type elements - case 162 /* PropertySignature */: - return factory.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isToken), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 163 /* PropertyDeclaration */: + case 164 /* 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 165 /* PropertyDeclaration */: + ts.Debug.type(node); return factory.updatePropertyDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), 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.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 164 /* MethodSignature */: - return factory.updateMethodSignature(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 165 /* MethodDeclaration */: - return factory.updateMethodDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isToken), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), 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 166 /* Constructor */: + nodeVisitor(node.questionToken || node.exclamationToken, tokenVisitor, ts.isQuestionOrExclamationToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); + case 166 /* 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 167 /* MethodDeclaration */: + ts.Debug.type(node); + return factory.updateMethodDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), 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 168 /* Constructor */: + ts.Debug.type(node); return factory.updateConstructorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 167 /* GetAccessor */: + case 169 /* GetAccessor */: + ts.Debug.type(node); return factory.updateGetAccessorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), 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 168 /* SetAccessor */: + case 170 /* SetAccessor */: + ts.Debug.type(node); return factory.updateSetAccessorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 169 /* CallSignature */: + case 171 /* 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 170 /* ConstructSignature */: + case 172 /* 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 171 /* IndexSignature */: + case 173 /* IndexSignature */: + ts.Debug.type(node); return factory.updateIndexSignature(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); // Types - case 172 /* TypePredicate */: - return factory.updateTypePredicateNode(node, nodeVisitor(node.assertsModifier, visitor), nodeVisitor(node.parameterName, visitor), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 173 /* TypeReference */: + case 174 /* 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 175 /* TypeReference */: + ts.Debug.type(node); return factory.updateTypeReferenceNode(node, nodeVisitor(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 174 /* FunctionType */: + case 176 /* 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 175 /* ConstructorType */: + case 177 /* 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 176 /* TypeQuery */: + case 178 /* TypeQuery */: + ts.Debug.type(node); return factory.updateTypeQueryNode(node, nodeVisitor(node.exprName, visitor, ts.isEntityName)); - case 177 /* TypeLiteral */: + case 179 /* TypeLiteral */: + ts.Debug.type(node); return factory.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 178 /* ArrayType */: + case 180 /* ArrayType */: + ts.Debug.type(node); return factory.updateArrayTypeNode(node, nodeVisitor(node.elementType, visitor, ts.isTypeNode)); - case 179 /* TupleType */: + case 181 /* TupleType */: + ts.Debug.type(node); return factory.updateTupleTypeNode(node, nodesVisitor(node.elements, visitor, ts.isTypeNode)); - case 180 /* OptionalType */: + case 182 /* OptionalType */: + ts.Debug.type(node); return factory.updateOptionalTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 181 /* RestType */: + case 183 /* RestType */: + ts.Debug.type(node); return factory.updateRestTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 182 /* UnionType */: + case 184 /* UnionType */: + ts.Debug.type(node); return factory.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 183 /* IntersectionType */: + case 185 /* IntersectionType */: + ts.Debug.type(node); return factory.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 184 /* ConditionalType */: + case 186 /* 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 185 /* InferType */: + case 187 /* InferType */: + ts.Debug.type(node); return factory.updateInferTypeNode(node, nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 195 /* ImportType */: + case 197 /* ImportType */: + ts.Debug.type(node); return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); - case 192 /* NamedTupleMember */: - return factory.updateNamedTupleMember(node, visitNode(node.dotDotDotToken, visitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode)); - case 186 /* ParenthesizedType */: + case 194 /* 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 188 /* ParenthesizedType */: + ts.Debug.type(node); return factory.updateParenthesizedType(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 188 /* TypeOperator */: + case 190 /* TypeOperator */: + ts.Debug.type(node); return factory.updateTypeOperatorNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 189 /* IndexedAccessType */: + case 191 /* IndexedAccessType */: + ts.Debug.type(node); return factory.updateIndexedAccessTypeNode(node, nodeVisitor(node.objectType, visitor, ts.isTypeNode), nodeVisitor(node.indexType, visitor, ts.isTypeNode)); - case 190 /* MappedType */: - return factory.updateMappedTypeNode(node, nodeVisitor(node.readonlyToken, tokenVisitor, ts.isToken), nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration), nodeVisitor(node.nameType, visitor, ts.isTypeNode), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 191 /* LiteralType */: + case 192 /* 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)); + case 193 /* LiteralType */: + ts.Debug.type(node); return factory.updateLiteralTypeNode(node, nodeVisitor(node.literal, visitor, ts.isExpression)); - case 193 /* TemplateLiteralType */: + case 195 /* TemplateLiteralType */: + ts.Debug.type(node); return factory.updateTemplateLiteralType(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateLiteralTypeSpan)); - case 194 /* TemplateLiteralTypeSpan */: + case 196 /* TemplateLiteralTypeSpan */: + ts.Debug.type(node); return factory.updateTemplateLiteralTypeSpan(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Binding patterns - case 196 /* ObjectBindingPattern */: + case 198 /* ObjectBindingPattern */: + ts.Debug.type(node); return factory.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 197 /* ArrayBindingPattern */: + case 199 /* ArrayBindingPattern */: + ts.Debug.type(node); return factory.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 198 /* BindingElement */: - return factory.updateBindingElement(node, nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isToken), nodeVisitor(node.propertyName, visitor, ts.isPropertyName), nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.initializer, visitor, ts.isExpression)); + case 200 /* 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 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: + ts.Debug.type(node); return factory.updateArrayLiteralExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: + ts.Debug.type(node); return factory.updateObjectLiteralExpression(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: if (node.flags & 32 /* OptionalChain */) { - return factory.updatePropertyAccessChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isToken), nodeVisitor(node.name, visitor, ts.isIdentifier)); + 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)); } - return factory.updatePropertyAccessExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.name, visitor, ts.isIdentifierOrPrivateIdentifier)); - case 202 /* ElementAccessExpression */: + ts.Debug.type(node); + return factory.updatePropertyAccessExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.name, visitor, ts.isMemberName)); + case 204 /* ElementAccessExpression */: if (node.flags & 32 /* OptionalChain */) { - return factory.updateElementAccessChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isToken), nodeVisitor(node.argumentExpression, visitor, ts.isExpression)); + 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 203 /* CallExpression */: + case 205 /* CallExpression */: if (node.flags & 32 /* OptionalChain */) { - return factory.updateCallChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); + 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 204 /* NewExpression */: + case 206 /* 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 205 /* TaggedTemplateExpression */: - return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), nodeVisitor(node.template, visitor, ts.isTemplateLiteral)); - case 206 /* TypeAssertionExpression */: + case 207 /* 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 208 /* TypeAssertionExpression */: + ts.Debug.type(node); return factory.updateTypeAssertion(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: + ts.Debug.type(node); return factory.updateParenthesizedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 208 /* FunctionExpression */: - return factory.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isToken), 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 209 /* ArrowFunction */: - 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.isToken), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 210 /* DeleteExpression */: + case 210 /* 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 211 /* 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 212 /* DeleteExpression */: + ts.Debug.type(node); return factory.updateDeleteExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 211 /* TypeOfExpression */: + case 213 /* TypeOfExpression */: + ts.Debug.type(node); return factory.updateTypeOfExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 212 /* VoidExpression */: + case 214 /* VoidExpression */: + ts.Debug.type(node); return factory.updateVoidExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 213 /* AwaitExpression */: + case 215 /* AwaitExpression */: + ts.Debug.type(node); return factory.updateAwaitExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: + ts.Debug.type(node); return factory.updatePrefixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression)); - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: + ts.Debug.type(node); return factory.updatePostfixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression)); - case 216 /* BinaryExpression */: - return factory.updateBinaryExpression(node, nodeVisitor(node.left, visitor, ts.isExpression), nodeVisitor(node.operatorToken, tokenVisitor, ts.isToken), nodeVisitor(node.right, visitor, ts.isExpression)); - case 217 /* ConditionalExpression */: - return factory.updateConditionalExpression(node, nodeVisitor(node.condition, visitor, ts.isExpression), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.whenTrue, visitor, ts.isExpression), nodeVisitor(node.colonToken, tokenVisitor, ts.isToken), nodeVisitor(node.whenFalse, visitor, ts.isExpression)); - case 218 /* TemplateExpression */: + case 218 /* 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 219 /* 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 220 /* TemplateExpression */: + ts.Debug.type(node); return factory.updateTemplateExpression(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 219 /* YieldExpression */: - return factory.updateYieldExpression(node, nodeVisitor(node.asteriskToken, tokenVisitor, ts.isToken), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 220 /* SpreadElement */: + case 221 /* YieldExpression */: + ts.Debug.type(node); + return factory.updateYieldExpression(node, nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.expression, visitor, ts.isExpression)); + case 222 /* SpreadElement */: + ts.Debug.type(node); return factory.updateSpreadElement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: + ts.Debug.type(node); return factory.updateClassExpression(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), 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.isClassElement)); - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: + ts.Debug.type(node); return factory.updateExpressionWithTypeArguments(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 224 /* AsExpression */: + case 226 /* AsExpression */: + ts.Debug.type(node); return factory.updateAsExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 225 /* NonNullExpression */: + case 227 /* NonNullExpression */: if (node.flags & 32 /* 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 226 /* MetaProperty */: + case 228 /* MetaProperty */: + ts.Debug.type(node); return factory.updateMetaProperty(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); // Misc - case 228 /* TemplateSpan */: + case 230 /* TemplateSpan */: + ts.Debug.type(node); return factory.updateTemplateSpan(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 230 /* Block */: + case 232 /* Block */: + ts.Debug.type(node); return factory.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: + ts.Debug.type(node); return factory.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: + ts.Debug.type(node); return factory.updateExpressionStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 234 /* IfStatement */: + case 236 /* 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 235 /* DoStatement */: - return factory.updateDoStatement(node, nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 236 /* WhileStatement */: - return factory.updateWhileStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 237 /* ForStatement */: - return factory.updateForStatement(node, nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.condition, visitor, ts.isExpression), nodeVisitor(node.incrementor, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 238 /* ForInStatement */: - return factory.updateForInStatement(node, nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 239 /* ForOfStatement */: - return factory.updateForOfStatement(node, nodeVisitor(node.awaitModifier, tokenVisitor, ts.isToken), nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 240 /* ContinueStatement */: + case 237 /* DoStatement */: + ts.Debug.type(node); + return factory.updateDoStatement(node, visitIterationBody(node.statement, visitor, context), nodeVisitor(node.expression, visitor, ts.isExpression)); + case 238 /* WhileStatement */: + ts.Debug.type(node); + return factory.updateWhileStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); + case 239 /* 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 240 /* 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 241 /* 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 242 /* ContinueStatement */: + ts.Debug.type(node); return factory.updateContinueStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier)); - case 241 /* BreakStatement */: + case 243 /* BreakStatement */: + ts.Debug.type(node); return factory.updateBreakStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier)); - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: + ts.Debug.type(node); return factory.updateReturnStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 243 /* WithStatement */: + case 245 /* WithStatement */: + ts.Debug.type(node); return factory.updateWithStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: + ts.Debug.type(node); return factory.updateSwitchStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.caseBlock, visitor, ts.isCaseBlock)); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: + ts.Debug.type(node); return factory.updateLabeledStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 246 /* ThrowStatement */: + case 248 /* ThrowStatement */: + ts.Debug.type(node); return factory.updateThrowStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 247 /* TryStatement */: + case 249 /* 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 249 /* VariableDeclaration */: - return factory.updateVariableDeclaration(node, nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.exclamationToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 250 /* VariableDeclarationList */: + case 251 /* 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 252 /* VariableDeclarationList */: + ts.Debug.type(node); return factory.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 251 /* FunctionDeclaration */: - return factory.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isToken), 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 252 /* ClassDeclaration */: + case 253 /* FunctionDeclaration */: + ts.Debug.type(node); + return factory.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), 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 254 /* ClassDeclaration */: + ts.Debug.type(node); return factory.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), 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.isClassElement)); - case 253 /* InterfaceDeclaration */: + case 255 /* InterfaceDeclaration */: + ts.Debug.type(node); return factory.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), 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 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: + ts.Debug.type(node); return factory.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), 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 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: + ts.Debug.type(node); return factory.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); - case 256 /* ModuleDeclaration */: - return factory.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.body, visitor, ts.isModuleBody)); - case 257 /* ModuleBlock */: + case 258 /* ModuleDeclaration */: + ts.Debug.type(node); + return factory.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isModuleName), nodeVisitor(node.body, visitor, ts.isModuleBody)); + case 259 /* ModuleBlock */: + ts.Debug.type(node); return factory.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 258 /* CaseBlock */: + case 260 /* CaseBlock */: + ts.Debug.type(node); return factory.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 259 /* NamespaceExportDeclaration */: + case 261 /* NamespaceExportDeclaration */: + ts.Debug.type(node); return factory.updateNamespaceExportDeclaration(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: + ts.Debug.type(node); return factory.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.moduleReference, visitor, ts.isModuleReference)); - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: + ts.Debug.type(node); return factory.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.importClause, visitor, ts.isImportClause), nodeVisitor(node.moduleSpecifier, visitor, ts.isExpression)); - case 262 /* ImportClause */: + case 264 /* ImportClause */: + ts.Debug.type(node); return factory.updateImportClause(node, node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: + ts.Debug.type(node); return factory.updateNamespaceImport(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 269 /* NamespaceExport */: + case 271 /* NamespaceExport */: + ts.Debug.type(node); return factory.updateNamespaceExport(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 264 /* NamedImports */: + case 266 /* NamedImports */: + ts.Debug.type(node); return factory.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 265 /* ImportSpecifier */: + case 267 /* ImportSpecifier */: + ts.Debug.type(node); return factory.updateImportSpecifier(node, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: + ts.Debug.type(node); return factory.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: + ts.Debug.type(node); return factory.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), node.isTypeOnly, nodeVisitor(node.exportClause, visitor, ts.isNamedExportBindings), nodeVisitor(node.moduleSpecifier, visitor, ts.isExpression)); - case 268 /* NamedExports */: + case 270 /* NamedExports */: + ts.Debug.type(node); return factory.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 270 /* ExportSpecifier */: + case 272 /* ExportSpecifier */: + ts.Debug.type(node); return factory.updateExportSpecifier(node, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier)); // Module references - case 272 /* ExternalModuleReference */: + case 274 /* ExternalModuleReference */: + ts.Debug.type(node); return factory.updateExternalModuleReference(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // JSX - case 273 /* JsxElement */: + case 275 /* 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 274 /* JsxSelfClosingElement */: + case 276 /* 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 275 /* JsxOpeningElement */: + case 277 /* 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 276 /* JsxClosingElement */: + case 278 /* JsxClosingElement */: + ts.Debug.type(node); return factory.updateJsxClosingElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 277 /* JsxFragment */: + case 279 /* 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 280 /* JsxAttribute */: + case 282 /* JsxAttribute */: + ts.Debug.type(node); return factory.updateJsxAttribute(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 281 /* JsxAttributes */: + case 283 /* JsxAttributes */: + ts.Debug.type(node); return factory.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 282 /* JsxSpreadAttribute */: + case 284 /* JsxSpreadAttribute */: + ts.Debug.type(node); return factory.updateJsxSpreadAttribute(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: + ts.Debug.type(node); return factory.updateJsxExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Clauses - case 284 /* CaseClause */: + case 286 /* CaseClause */: + ts.Debug.type(node); return factory.updateCaseClause(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 285 /* DefaultClause */: + case 287 /* DefaultClause */: + ts.Debug.type(node); return factory.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 286 /* HeritageClause */: + case 288 /* HeritageClause */: + ts.Debug.type(node); return factory.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 287 /* CatchClause */: + case 289 /* CatchClause */: + ts.Debug.type(node); return factory.updateCatchClause(node, nodeVisitor(node.variableDeclaration, visitor, ts.isVariableDeclaration), nodeVisitor(node.block, visitor, ts.isBlock)); // Property assignments - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: + ts.Debug.type(node); return factory.updatePropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: + ts.Debug.type(node); return factory.updateShorthandPropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 290 /* SpreadAssignment */: + case 292 /* SpreadAssignment */: + ts.Debug.type(node); return factory.updateSpreadAssignment(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Enum - case 291 /* EnumMember */: + case 293 /* 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 297 /* SourceFile */: + case 299 /* SourceFile */: + ts.Debug.type(node); return factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 336 /* PartiallyEmittedExpression */: + case 344 /* PartiallyEmittedExpression */: + ts.Debug.type(node); return factory.updatePartiallyEmittedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 337 /* CommaListExpression */: + case 345 /* CommaListExpression */: + ts.Debug.type(node); return factory.updateCommaListExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: // No need to visit nodes with no children. @@ -81627,6 +84712,7 @@ var ts; var sourcesContent; var names = []; var nameToNameIndexMap; + var mappingCharCodes = []; var mappings = ""; // Last recorded and encoded mappings var lastGeneratedLine = 0; @@ -81801,6 +84887,14 @@ var ts; || lastSourceCharacter !== pendingSourceCharacter || lastNameIndex !== pendingNameIndex; } + function appendMappingCharCode(charCode) { + mappingCharCodes.push(charCode); + // String.fromCharCode accepts its arguments on the stack, so we have to chunk the input, + // otherwise we can get stack overflows for large source maps + if (mappingCharCodes.length >= 1024) { + flushMappingBuffer(); + } + } function commitPendingMapping() { if (!hasPending || !shouldCommitMapping()) { return; @@ -81810,42 +84904,50 @@ var ts; if (lastGeneratedLine < pendingGeneratedLine) { // Emit line delimiters do { - mappings += ";"; + appendMappingCharCode(59 /* semicolon */); lastGeneratedLine++; - lastGeneratedCharacter = 0; } while (lastGeneratedLine < pendingGeneratedLine); + // Only need to set this once + lastGeneratedCharacter = 0; } else { ts.Debug.assertEqual(lastGeneratedLine, pendingGeneratedLine, "generatedLine cannot backtrack"); // Emit comma to separate the entry if (hasLast) { - mappings += ","; + appendMappingCharCode(44 /* comma */); } } // 1. Relative generated character - mappings += base64VLQFormatEncode(pendingGeneratedCharacter - lastGeneratedCharacter); + appendBase64VLQ(pendingGeneratedCharacter - lastGeneratedCharacter); lastGeneratedCharacter = pendingGeneratedCharacter; if (hasPendingSource) { // 2. Relative sourceIndex - mappings += base64VLQFormatEncode(pendingSourceIndex - lastSourceIndex); + appendBase64VLQ(pendingSourceIndex - lastSourceIndex); lastSourceIndex = pendingSourceIndex; // 3. Relative source line - mappings += base64VLQFormatEncode(pendingSourceLine - lastSourceLine); + appendBase64VLQ(pendingSourceLine - lastSourceLine); lastSourceLine = pendingSourceLine; // 4. Relative source character - mappings += base64VLQFormatEncode(pendingSourceCharacter - lastSourceCharacter); + appendBase64VLQ(pendingSourceCharacter - lastSourceCharacter); lastSourceCharacter = pendingSourceCharacter; if (hasPendingName) { // 5. Relative nameIndex - mappings += base64VLQFormatEncode(pendingNameIndex - lastNameIndex); + appendBase64VLQ(pendingNameIndex - lastNameIndex); lastNameIndex = pendingNameIndex; } } hasLast = true; exit(); } + function flushMappingBuffer() { + if (mappingCharCodes.length > 0) { + mappings += String.fromCharCode.apply(undefined, mappingCharCodes); + mappingCharCodes.length = 0; + } + } function toJSON() { commitPendingMapping(); + flushMappingBuffer(); return { version: 3, file: file, @@ -81856,10 +84958,33 @@ var ts; sourcesContent: sourcesContent, }; } + function appendBase64VLQ(inValue) { + // Add a new least significant bit that has the sign of the value. + // if negative number the least significant bit that gets added to the number has value 1 + // else least significant bit value that gets added is 0 + // eg. -1 changes to binary : 01 [1] => 3 + // +1 changes to binary : 01 [0] => 2 + if (inValue < 0) { + inValue = ((-inValue) << 1) + 1; + } + else { + inValue = inValue << 1; + } + // Encode 5 bits at a time starting from least significant bits + do { + var currentDigit = inValue & 31; // 11111 + inValue = inValue >> 5; + if (inValue > 0) { + // There are still more digits to decode, set the msb (6th bit) + currentDigit = currentDigit | 32; + } + appendMappingCharCode(base64FormatEncode(currentDigit)); + } while (inValue > 0); + } } ts.createSourceMapGenerator = createSourceMapGenerator; // Sometimes tools can see the following line as a source mapping url comment, so we mangle it a bit (the [M]) - var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)\s*$/; + var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)$/; var whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/; function getLineInfo(text, lineStarts) { return { @@ -81876,7 +85001,7 @@ var ts; var line = lineInfo.getLineText(index); var comment = sourceMapCommentRegExp.exec(line); if (comment) { - return comment[1]; + return ts.trimStringEnd(comment[1]); } // If we see a non-whitespace/map comment-like line, break, to avoid scanning up the entire file else if (!line.match(whitespaceOrMapCommentRegExp)) { @@ -82082,31 +85207,6 @@ var ts; ch === 47 /* slash */ ? 63 : -1; } - function base64VLQFormatEncode(inValue) { - // Add a new least significant bit that has the sign of the value. - // if negative number the least significant bit that gets added to the number has value 1 - // else least significant bit value that gets added is 0 - // eg. -1 changes to binary : 01 [1] => 3 - // +1 changes to binary : 01 [0] => 2 - if (inValue < 0) { - inValue = ((-inValue) << 1) + 1; - } - else { - inValue = inValue << 1; - } - // Encode 5 bits at a time starting from least significant bits - var encodedStr = ""; - do { - var currentDigit = inValue & 31; // 11111 - inValue = inValue >> 5; - if (inValue > 0) { - // There are still more digits to decode, set the msb (6th bit) - currentDigit = currentDigit | 32; - } - encodedStr = encodedStr + String.fromCharCode(base64FormatEncode(currentDigit)); - } while (inValue > 0); - return encodedStr; - } function isSourceMappedPosition(value) { return value.sourceIndex !== undefined && value.sourcePosition !== undefined; @@ -82270,7 +85370,7 @@ var ts; function chainBundle(context, transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 297 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 299 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return context.factory.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -82321,7 +85421,7 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" @@ -82334,13 +85434,13 @@ var ts; hasImportDefault = true; } break; - case 260 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 272 /* ExternalModuleReference */) { + case 262 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 274 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -82371,13 +85471,13 @@ var ts; addExportedNamesForExportDeclaration(node); } break; - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: if (ts.hasSyntacticModifier(node, 1 /* Export */)) { for (var _b = 0, _c = node.declarationList.declarations; _b < _c.length; _b++) { var decl = _c[_b]; @@ -82385,7 +85485,7 @@ var ts; } } break; - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: if (ts.hasSyntacticModifier(node, 1 /* Export */)) { if (ts.hasSyntacticModifier(node, 512 /* Default */)) { // export default function() { } @@ -82405,7 +85505,7 @@ var ts; } } break; - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: if (ts.hasSyntacticModifier(node, 1 /* Export */)) { if (ts.hasSyntacticModifier(node, 512 /* Default */)) { // export default class { } @@ -82499,32 +85599,31 @@ var ts; * any such locations */ function isSimpleInlineableExpression(expression) { - return !ts.isIdentifier(expression) && isSimpleCopiableExpression(expression) || - ts.isWellKnownSymbolSyntactically(expression); + return !ts.isIdentifier(expression) && isSimpleCopiableExpression(expression); } ts.isSimpleInlineableExpression = isSimpleInlineableExpression; function isCompoundAssignment(kind) { - return kind >= 63 /* FirstCompoundAssignment */ - && kind <= 77 /* LastCompoundAssignment */; + return kind >= 64 /* FirstCompoundAssignment */ + && kind <= 78 /* LastCompoundAssignment */; } ts.isCompoundAssignment = isCompoundAssignment; function getNonAssignmentOperatorForCompoundAssignment(kind) { switch (kind) { - case 63 /* PlusEqualsToken */: return 39 /* PlusToken */; - case 64 /* MinusEqualsToken */: return 40 /* MinusToken */; - case 65 /* AsteriskEqualsToken */: return 41 /* AsteriskToken */; - case 66 /* AsteriskAsteriskEqualsToken */: return 42 /* AsteriskAsteriskToken */; - case 67 /* SlashEqualsToken */: return 43 /* SlashToken */; - case 68 /* PercentEqualsToken */: return 44 /* PercentToken */; - case 69 /* LessThanLessThanEqualsToken */: return 47 /* LessThanLessThanToken */; - case 70 /* GreaterThanGreaterThanEqualsToken */: return 48 /* GreaterThanGreaterThanToken */; - case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 49 /* GreaterThanGreaterThanGreaterThanToken */; - case 72 /* AmpersandEqualsToken */: return 50 /* AmpersandToken */; - case 73 /* BarEqualsToken */: return 51 /* BarToken */; - case 77 /* CaretEqualsToken */: return 52 /* CaretToken */; - case 74 /* BarBarEqualsToken */: return 56 /* BarBarToken */; - case 75 /* AmpersandAmpersandEqualsToken */: return 55 /* AmpersandAmpersandToken */; - case 76 /* QuestionQuestionEqualsToken */: return 60 /* QuestionQuestionToken */; + 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 */; } } ts.getNonAssignmentOperatorForCompoundAssignment = getNonAssignmentOperatorForCompoundAssignment; @@ -82579,10 +85678,19 @@ var ts; * @param isStatic A value indicating whether the member should be a static or instance member. */ function isInitializedProperty(member) { - return member.kind === 163 /* PropertyDeclaration */ + return member.kind === 165 /* PropertyDeclaration */ && member.initializer !== undefined; } ts.isInitializedProperty = isInitializedProperty; + /** + * Gets a value indicating whether a class element is a private instance method or accessor. + * + * @param member The class element node. + */ + function isNonStaticMethodOrAccessorWithPrivateName(member) { + return !ts.hasStaticModifier(member) && ts.isMethodOrAccessor(member) && ts.isPrivateIdentifier(member.name); + } + ts.isNonStaticMethodOrAccessorWithPrivateName = isNonStaticMethodOrAccessorWithPrivateName; })(ts || (ts = {})); /*@internal*/ var ts; @@ -82856,8 +85964,8 @@ var ts; if (!ts.getRestIndicatorOfBindingOrAssignmentElement(element)) { var propertyName = ts.getPropertyNameOfBindingOrAssignmentElement(element); if (flattenContext.level >= 1 /* ObjectRest */ - && !(element.transformFlags & (8192 /* ContainsRestOrSpread */ | 16384 /* ContainsObjectRestOrSpread */)) - && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (8192 /* ContainsRestOrSpread */ | 16384 /* ContainsObjectRestOrSpread */)) + && !(element.transformFlags & (16384 /* ContainsRestOrSpread */ | 32768 /* ContainsObjectRestOrSpread */)) + && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (16384 /* ContainsRestOrSpread */ | 32768 /* ContainsObjectRestOrSpread */)) && !ts.isComputedPropertyName(propertyName)) { bindingElements = ts.append(bindingElements, ts.visitNode(element, flattenContext.visitor)); } @@ -82923,7 +86031,7 @@ var ts; if (flattenContext.level >= 1 /* 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 & 16384 /* ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) { + if (element.transformFlags & 32768 /* ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) { flattenContext.hasTransformedPriorElement = true; var temp = flattenContext.context.factory.createTempVariable(/*recordTempVariable*/ undefined); if (flattenContext.hoistTempVariables) { @@ -83181,8 +86289,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(201 /* PropertyAccessExpression */); - context.enableSubstitution(202 /* ElementAccessExpression */); + context.enableSubstitution(203 /* PropertyAccessExpression */); + context.enableSubstitution(204 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -83208,14 +86316,14 @@ var ts; var applicableSubstitutions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 298 /* Bundle */) { + if (node.kind === 300 /* 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 === 300 /* InputFiles */) { + if (prepend.kind === 302 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend, "js"); } return prepend; @@ -83266,16 +86374,16 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 297 /* SourceFile */: - case 258 /* CaseBlock */: - case 257 /* ModuleBlock */: - case 230 /* Block */: + case 299 /* SourceFile */: + case 260 /* CaseBlock */: + case 259 /* ModuleBlock */: + case 232 /* Block */: currentLexicalScope = node; currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 252 /* ClassDeclaration */: - case 251 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: + case 253 /* FunctionDeclaration */: if (ts.hasSyntacticModifier(node, 2 /* Ambient */)) { break; } @@ -83287,7 +86395,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 === 252 /* ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 254 /* ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* Default */)); } if (ts.isClassDeclaration(node)) { // XXX: should probably also cover interfaces and type aliases that can have type variables? @@ -83330,10 +86438,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: - case 260 /* ImportEqualsDeclaration */: - case 266 /* ExportAssignment */: - case 267 /* ExportDeclaration */: + case 263 /* ImportDeclaration */: + case 262 /* ImportEqualsDeclaration */: + case 268 /* ExportAssignment */: + case 269 /* ExportDeclaration */: return visitElidableStatement(node); default: return visitorWorker(node); @@ -83354,13 +86462,13 @@ var ts; return node; } switch (node.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return visitImportDeclaration(node); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return visitExportAssignment(node); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -83380,11 +86488,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 267 /* ExportDeclaration */ || - node.kind === 261 /* ImportDeclaration */ || - node.kind === 262 /* ImportClause */ || - (node.kind === 260 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 272 /* ExternalModuleReference */)) { + if (node.kind === 269 /* ExportDeclaration */ || + node.kind === 263 /* ImportDeclaration */ || + node.kind === 264 /* ImportClause */ || + (node.kind === 262 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 274 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -83408,29 +86516,29 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 166 /* Constructor */: + case 168 /* Constructor */: return visitConstructor(node); - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: // Property declarations are not TypeScript syntax, but they must be visited // for the decorator transformation. return visitPropertyDeclaration(node); - case 171 /* IndexSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 165 /* MethodDeclaration */: + case 173 /* IndexSignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 167 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 229 /* SemicolonClassElement */: + case 231 /* SemicolonClassElement */: return node; default: return ts.Debug.failBadSyntaxKind(node); } } function modifierVisitor(node) { - if (ts.modifierToFlag(node.kind) & 2270 /* TypeScriptModifier */) { + if (ts.modifierToFlag(node.kind) & 18654 /* TypeScriptModifier */) { return undefined; } - else if (currentNamespace && node.kind === 92 /* ExportKeyword */) { + else if (currentNamespace && node.kind === 93 /* ExportKeyword */) { return undefined; } return node; @@ -83447,71 +86555,71 @@ var ts; return factory.createNotEmittedStatement(node); } switch (node.kind) { - case 92 /* ExportKeyword */: - case 87 /* DefaultKeyword */: + case 93 /* ExportKeyword */: + case 88 /* DefaultKeyword */: // ES6 export and default modifiers are elided when inside a namespace. return currentNamespace ? undefined : node; - case 122 /* PublicKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 125 /* AbstractKeyword */: - case 84 /* ConstKeyword */: - case 133 /* DeclareKeyword */: - case 142 /* ReadonlyKeyword */: + case 123 /* PublicKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + case 126 /* AbstractKeyword */: + case 85 /* ConstKeyword */: + case 134 /* DeclareKeyword */: + case 143 /* ReadonlyKeyword */: // TypeScript accessibility and readonly modifiers are elided // falls through - case 178 /* ArrayType */: - case 179 /* TupleType */: - case 180 /* OptionalType */: - case 181 /* RestType */: - case 177 /* TypeLiteral */: - case 172 /* TypePredicate */: - case 159 /* TypeParameter */: - case 128 /* AnyKeyword */: - case 152 /* UnknownKeyword */: - case 131 /* BooleanKeyword */: - case 147 /* StringKeyword */: - case 144 /* NumberKeyword */: - case 141 /* NeverKeyword */: - case 113 /* VoidKeyword */: - case 148 /* SymbolKeyword */: - case 175 /* ConstructorType */: - case 174 /* FunctionType */: - case 176 /* TypeQuery */: - case 173 /* TypeReference */: - case 182 /* UnionType */: - case 183 /* IntersectionType */: - case 184 /* ConditionalType */: - case 186 /* ParenthesizedType */: - case 187 /* ThisType */: - case 188 /* TypeOperator */: - case 189 /* IndexedAccessType */: - case 190 /* MappedType */: - case 191 /* LiteralType */: + case 180 /* ArrayType */: + case 181 /* TupleType */: + case 182 /* OptionalType */: + case 183 /* RestType */: + case 179 /* TypeLiteral */: + case 174 /* TypePredicate */: + case 161 /* TypeParameter */: + case 129 /* AnyKeyword */: + case 153 /* UnknownKeyword */: + case 132 /* BooleanKeyword */: + case 148 /* StringKeyword */: + case 145 /* NumberKeyword */: + case 142 /* NeverKeyword */: + case 114 /* VoidKeyword */: + case 149 /* SymbolKeyword */: + case 177 /* ConstructorType */: + case 176 /* FunctionType */: + case 178 /* TypeQuery */: + case 175 /* TypeReference */: + case 184 /* UnionType */: + case 185 /* IntersectionType */: + case 186 /* ConditionalType */: + case 188 /* ParenthesizedType */: + case 189 /* ThisType */: + case 190 /* TypeOperator */: + case 191 /* IndexedAccessType */: + case 192 /* MappedType */: + case 193 /* LiteralType */: // TypeScript type nodes are elided. // falls through - case 171 /* IndexSignature */: + case 173 /* IndexSignature */: // TypeScript index signatures are elided. // falls through - case 161 /* Decorator */: + case 163 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. // falls through - case 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return undefined; - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: // TypeScript property declarations are elided. However their names are still visited, and can potentially be retained if they could have sideeffects return visitPropertyDeclaration(node); - case 259 /* NamespaceExportDeclaration */: + case 261 /* NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; - case 166 /* Constructor */: + case 168 /* Constructor */: return visitConstructor(node); - case 253 /* InterfaceDeclaration */: + case 255 /* 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 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: // This may be a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -83521,7 +86629,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: // This may be a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -83531,35 +86639,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 286 /* HeritageClause */: + case 288 /* HeritageClause */: // This may be a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 167 /* GetAccessor */: + case 169 /* GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 168 /* SetAccessor */: + case 170 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 160 /* Parameter */: + case 162 /* Parameter */: // This may be a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -83569,40 +86677,40 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 206 /* TypeAssertionExpression */: - case 224 /* AsExpression */: + case 208 /* TypeAssertionExpression */: + case 226 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return visitCallExpression(node); - case 204 /* NewExpression */: + case 206 /* NewExpression */: return visitNewExpression(node); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 225 /* NonNullExpression */: + case 227 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); - case 274 /* JsxSelfClosingElement */: + case 276 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node); - case 275 /* JsxOpeningElement */: + case 277 /* JsxOpeningElement */: return visitJsxJsxOpeningElement(node); default: // node contains some other TypeScript syntax @@ -83639,7 +86747,7 @@ var ts; if (ts.some(staticProperties)) facts |= 1 /* HasStaticInitializedProperties */; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 103 /* NullKeyword */) + if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */) facts |= 64 /* IsDerivedClass */; if (shouldEmitDecorateCallForClass(node)) facts |= 2 /* HasConstructorDecorators */; @@ -83656,7 +86764,7 @@ var ts; return facts; } function hasTypeScriptClassSyntax(node) { - return !!(node.transformFlags & 2048 /* ContainsTypeScriptClassSyntax */); + return !!(node.transformFlags & 4096 /* ContainsTypeScriptClassSyntax */); } function isClassLikeDeclarationWithTypeScriptSyntax(node) { return ts.some(node.decorators) @@ -84011,12 +87119,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -84169,7 +87277,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ true); var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 163 /* PropertyDeclaration */ + ? member.kind === 165 /* 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() @@ -84293,10 +87401,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 165 /* MethodDeclaration */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */ - || kind === 163 /* PropertyDeclaration */; + return kind === 167 /* MethodDeclaration */ + || kind === 169 /* GetAccessor */ + || kind === 170 /* SetAccessor */ + || kind === 165 /* PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -84306,7 +87414,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 165 /* MethodDeclaration */; + return node.kind === 167 /* MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -84317,12 +87425,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return true; } return false; @@ -84339,15 +87447,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 163 /* PropertyDeclaration */: - case 160 /* Parameter */: + case 165 /* PropertyDeclaration */: + case 162 /* Parameter */: return serializeTypeNode(node.type); - case 168 /* SetAccessor */: - case 167 /* GetAccessor */: + case 170 /* SetAccessor */: + case 169 /* GetAccessor */: return serializeTypeNode(getAccessorTypeNode(node)); - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 165 /* MethodDeclaration */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 167 /* MethodDeclaration */: return factory.createIdentifier("Function"); default: return factory.createVoidZero(); @@ -84384,7 +87492,7 @@ var ts; return factory.createArrayLiteralExpression(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 167 /* GetAccessor */) { + if (container && node.kind === 169 /* GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -84429,82 +87537,82 @@ var ts; return factory.createIdentifier("Object"); } switch (node.kind) { - case 113 /* VoidKeyword */: - case 150 /* UndefinedKeyword */: - case 141 /* NeverKeyword */: + case 114 /* VoidKeyword */: + case 151 /* UndefinedKeyword */: + case 142 /* NeverKeyword */: return factory.createVoidZero(); - case 186 /* ParenthesizedType */: + case 188 /* ParenthesizedType */: return serializeTypeNode(node.type); - case 174 /* FunctionType */: - case 175 /* ConstructorType */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: return factory.createIdentifier("Function"); - case 178 /* ArrayType */: - case 179 /* TupleType */: + case 180 /* ArrayType */: + case 181 /* TupleType */: return factory.createIdentifier("Array"); - case 172 /* TypePredicate */: - case 131 /* BooleanKeyword */: + case 174 /* TypePredicate */: + case 132 /* BooleanKeyword */: return factory.createIdentifier("Boolean"); - case 147 /* StringKeyword */: + case 148 /* StringKeyword */: return factory.createIdentifier("String"); - case 145 /* ObjectKeyword */: + case 146 /* ObjectKeyword */: return factory.createIdentifier("Object"); - case 191 /* LiteralType */: + case 193 /* LiteralType */: switch (node.literal.kind) { case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return factory.createIdentifier("String"); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: case 8 /* NumericLiteral */: return factory.createIdentifier("Number"); case 9 /* BigIntLiteral */: return getGlobalBigIntNameWithFallback(); - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: return factory.createIdentifier("Boolean"); - case 103 /* NullKeyword */: + case 104 /* NullKeyword */: return factory.createVoidZero(); default: return ts.Debug.failBadSyntaxKind(node.literal); } - case 144 /* NumberKeyword */: + case 145 /* NumberKeyword */: return factory.createIdentifier("Number"); - case 155 /* BigIntKeyword */: + case 156 /* BigIntKeyword */: return getGlobalBigIntNameWithFallback(); - case 148 /* SymbolKeyword */: + case 149 /* SymbolKeyword */: return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : factory.createIdentifier("Symbol"); - case 173 /* TypeReference */: + case 175 /* TypeReference */: return serializeTypeReferenceNode(node); - case 183 /* IntersectionType */: - case 182 /* UnionType */: + case 185 /* IntersectionType */: + case 184 /* UnionType */: return serializeTypeList(node.types); - case 184 /* ConditionalType */: + case 186 /* ConditionalType */: return serializeTypeList([node.trueType, node.falseType]); - case 188 /* TypeOperator */: - if (node.operator === 142 /* ReadonlyKeyword */) { + case 190 /* TypeOperator */: + if (node.operator === 143 /* ReadonlyKeyword */) { return serializeTypeNode(node.type); } break; - case 176 /* TypeQuery */: - case 189 /* IndexedAccessType */: - case 190 /* MappedType */: - case 177 /* TypeLiteral */: - case 128 /* AnyKeyword */: - case 152 /* UnknownKeyword */: - case 187 /* ThisType */: - case 195 /* ImportType */: + case 178 /* TypeQuery */: + case 191 /* IndexedAccessType */: + case 192 /* MappedType */: + case 179 /* TypeLiteral */: + case 129 /* AnyKeyword */: + case 153 /* UnknownKeyword */: + case 189 /* ThisType */: + case 197 /* ImportType */: break; // handle JSDoc types from an invalid parse - case 303 /* JSDocAllType */: - case 304 /* JSDocUnknownType */: - case 308 /* JSDocFunctionType */: - case 309 /* JSDocVariadicType */: - case 310 /* JSDocNamepathType */: + case 306 /* JSDocAllType */: + case 307 /* JSDocUnknownType */: + case 311 /* JSDocFunctionType */: + case 312 /* JSDocVariadicType */: + case 313 /* JSDocNamepathType */: break; - case 305 /* JSDocNullableType */: - case 306 /* JSDocNonNullableType */: - case 307 /* JSDocOptionalType */: + case 308 /* JSDocNullableType */: + case 309 /* JSDocNonNullableType */: + case 310 /* JSDocOptionalType */: return serializeTypeNode(node.type); default: return ts.Debug.failBadSyntaxKind(node); @@ -84517,13 +87625,13 @@ var ts; var serializedUnion; for (var _i = 0, types_24 = types; _i < types_24.length; _i++) { var typeNode = types_24[_i]; - while (typeNode.kind === 186 /* ParenthesizedType */) { + while (typeNode.kind === 188 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 141 /* NeverKeyword */) { + if (typeNode.kind === 142 /* NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 191 /* LiteralType */ && typeNode.literal.kind === 103 /* NullKeyword */ || typeNode.kind === 150 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 193 /* LiteralType */ && typeNode.literal.kind === 104 /* NullKeyword */ || typeNode.kind === 151 /* UndefinedKeyword */)) { continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks } var serializedIndividual = serializeTypeNode(typeNode); @@ -84605,12 +87713,12 @@ var ts; * @param node The entity name to serialize. */ function serializeEntityNameAsExpressionFallback(node) { - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { // A -> typeof A !== undefined && A var copied = serializeEntityNameAsExpression(node); return createCheckedValue(copied, copied); } - if (node.left.kind === 78 /* Identifier */) { + if (node.left.kind === 79 /* Identifier */) { // A.B -> typeof A !== undefined && A.B return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node)); } @@ -84626,14 +87734,14 @@ var ts; */ function serializeEntityNameAsExpression(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* 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 157 /* QualifiedName */: + case 159 /* QualifiedName */: return serializeQualifiedNameAsExpression(node); } } @@ -84724,7 +87832,7 @@ var ts; * @param node The HeritageClause to transform. */ function visitHeritageClause(node) { - if (node.token === 116 /* ImplementsKeyword */) { + if (node.token === 117 /* ImplementsKeyword */) { // implements clauses are elided return undefined; } @@ -85021,8 +88129,7 @@ var ts; */ function shouldEmitEnumDeclaration(node) { return !ts.isEnumConst(node) - || compilerOptions.preserveConstEnums - || compilerOptions.isolatedModules; + || ts.shouldPreserveConstEnums(compilerOptions); } /** * Visits an enum declaration. @@ -85156,7 +88263,7 @@ var ts; // If we can't find a parse tree node, assume the node is instantiated. return true; } - return ts.isInstantiatedModule(node, !!compilerOptions.preserveConstEnums || !!compilerOptions.isolatedModules); + return ts.isInstantiatedModule(node, ts.shouldPreserveConstEnums(compilerOptions)); } /** * Determines whether an exported declaration will have a qualified export name (e.g. `f.x` @@ -85207,12 +88314,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 === 297 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 299 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { // Adjust the source map emit to match the old emitter. - if (node.kind === 255 /* EnumDeclaration */) { + if (node.kind === 257 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -85337,7 +88444,7 @@ var ts; var statementsLocation; var blockLocation; if (node.body) { - if (node.body.kind === 257 /* ModuleBlock */) { + if (node.body.kind === 259 /* ModuleBlock */) { saveStateAndInvoke(node.body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = node.body.statements; blockLocation = node.body; @@ -85384,13 +88491,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 !== 257 /* ModuleBlock */) { + if (!node.body || node.body.kind !== 259 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 256 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 258 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -85440,7 +88547,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 263 /* NamespaceImport */) { + if (node.kind === 265 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -85674,7 +88781,7 @@ var ts; function enableSubstitutionForNonQualifiedEnumMembers() { if ((enabledSubstitutions & 8 /* NonQualifiedEnumMembers */) === 0) { enabledSubstitutions |= 8 /* NonQualifiedEnumMembers */; - context.enableSubstitution(78 /* Identifier */); + context.enableSubstitution(79 /* Identifier */); } } function enableSubstitutionForClassAliases() { @@ -85682,7 +88789,7 @@ var ts; enabledSubstitutions |= 1 /* ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(78 /* Identifier */); + context.enableSubstitution(79 /* Identifier */); // Keep track of class aliases. classAliases = []; } @@ -85692,17 +88799,17 @@ var ts; enabledSubstitutions |= 2 /* 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(78 /* Identifier */); - context.enableSubstitution(289 /* ShorthandPropertyAssignment */); + context.enableSubstitution(79 /* Identifier */); + context.enableSubstitution(291 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(256 /* ModuleDeclaration */); + context.enableEmitNotification(258 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 256 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 258 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 255 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 257 /* EnumDeclaration */; } /** * Hook for node emit. @@ -85761,11 +88868,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return substituteExpressionIdentifier(node); - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -85787,10 +88894,10 @@ var ts; if (declaration) { var classAlias = classAliases[declaration.id]; // TODO: GH#18217 if (classAlias) { - var clone_1 = factory.cloneNode(classAlias); - ts.setSourceMapRange(clone_1, node); - ts.setCommentRange(clone_1, node); - return clone_1; + var clone_2 = factory.cloneNode(classAlias); + ts.setSourceMapRange(clone_2, node); + ts.setCommentRange(clone_2, node); + return clone_2; } } } @@ -85803,9 +88910,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 !== 297 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 256 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 255 /* EnumDeclaration */); + if (container && container.kind !== 299 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 258 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 257 /* EnumDeclaration */); if (substitute) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(container), node), /*location*/ node); @@ -85857,10 +88964,12 @@ var ts; */ ClassPropertySubstitutionFlags[ClassPropertySubstitutionFlags["ClassAliases"] = 1] = "ClassAliases"; })(ClassPropertySubstitutionFlags || (ClassPropertySubstitutionFlags = {})); - var PrivateIdentifierPlacement; - (function (PrivateIdentifierPlacement) { - PrivateIdentifierPlacement[PrivateIdentifierPlacement["InstanceField"] = 0] = "InstanceField"; - })(PrivateIdentifierPlacement || (PrivateIdentifierPlacement = {})); + var PrivateIdentifierKind; + (function (PrivateIdentifierKind) { + PrivateIdentifierKind["Field"] = "f"; + PrivateIdentifierKind["Method"] = "m"; + PrivateIdentifierKind["Accessor"] = "a"; + })(PrivateIdentifierKind = ts.PrivateIdentifierKind || (ts.PrivateIdentifierKind = {})); /** * Transforms ECMAScript Class Syntax. * TypeScript parameter property syntax is transformed in the TypeScript transformer. @@ -85869,11 +88978,12 @@ var ts; * When --useDefineForClassFields is on, this transforms to ECMAScript semantics, with Object.defineProperty. */ function transformClassFields(context) { - var factory = context.factory, hoistVariableDeclaration = context.hoistVariableDeclaration, endLexicalEnvironment = context.endLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment; + var factory = context.factory, hoistVariableDeclaration = context.hoistVariableDeclaration, endLexicalEnvironment = context.endLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, addBlockScopedVariable = context.addBlockScopedVariable; var resolver = context.getEmitResolver(); var compilerOptions = context.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); - var shouldTransformPrivateFields = languageVersion < 99 /* ESNext */; + var useDefineForClassFields = ts.getUseDefineForClassFields(compilerOptions); + var shouldTransformPrivateElements = languageVersion < 99 /* ESNext */; var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; var enabledSubstitutions; @@ -85894,7 +89004,7 @@ var ts; function transformSourceFile(node) { var options = context.getCompilerOptions(); if (node.isDeclarationFile - || options.useDefineForClassFields && options.target === 99 /* ESNext */) { + || useDefineForClassFields && options.target === 99 /* ESNext */) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -85902,41 +89012,41 @@ var ts; return visited; } function visitor(node) { - if (!(node.transformFlags & 4194304 /* ContainsClassFields */)) + if (!(node.transformFlags & 8388608 /* ContainsClassFields */)) return node; switch (node.kind) { - case 221 /* ClassExpression */: - case 252 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 254 /* ClassDeclaration */: return visitClassLike(node); - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return visitPropertyDeclaration(node); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return visitVariableStatement(node); - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return visitPropertyAccessExpression(node); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return visitPrefixUnaryExpression(node); - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: return visitPostfixUnaryExpression(node, /*valueIsDiscarded*/ false); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return visitCallExpression(node); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return visitBinaryExpression(node); - case 79 /* PrivateIdentifier */: + case 80 /* PrivateIdentifier */: return visitPrivateIdentifier(node); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: return visitExpressionStatement(node); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return visitForStatement(node); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); } return ts.visitEachChild(node, visitor, context); } function visitorDestructuringTarget(node) { switch (node.kind) { - case 200 /* ObjectLiteralExpression */: - case 199 /* ArrayLiteralExpression */: + case 202 /* ObjectLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return visitAssignmentPattern(node); default: return visitor(node); @@ -85947,7 +89057,7 @@ var ts; * Replace it with an empty identifier to indicate a problem with the code. */ function visitPrivateIdentifier(node) { - if (!shouldTransformPrivateFields) { + if (!shouldTransformPrivateElements) { return node; } return ts.setOriginalNode(factory.createIdentifier(""), node); @@ -85959,20 +89069,19 @@ var ts; */ function classElementVisitor(node) { switch (node.kind) { - case 166 /* Constructor */: + case 168 /* Constructor */: // Constructors for classes using class fields are transformed in // `visitClassDeclaration` or `visitClassExpression`. return undefined; - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 165 /* MethodDeclaration */: - // Visit the name of the member (if it's a computed property name). - return ts.visitEachChild(node, classElementVisitor, context); - case 163 /* PropertyDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 167 /* MethodDeclaration */: + return visitMethodOrAccessorDeclaration(node); + case 165 /* PropertyDeclaration */: return visitPropertyDeclaration(node); - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 229 /* SemicolonClassElement */: + case 231 /* SemicolonClassElement */: return node; default: return visitor(node); @@ -85997,44 +89106,96 @@ var ts; } return node; } + function visitMethodOrAccessorDeclaration(node) { + ts.Debug.assert(!ts.some(node.decorators)); + if (!shouldTransformPrivateElements || !ts.isPrivateIdentifier(node.name)) { + return ts.visitEachChild(node, classElementVisitor, context); + } + // leave invalid code untransformed + var info = accessPrivateIdentifier(node.name); + ts.Debug.assert(info, "Undeclared private name for property declaration."); + if (!info.isValid) { + return node; + } + var functionName = getHoistedFunctionName(node); + if (functionName) { + getPendingExpressions().push(factory.createAssignment(functionName, factory.createFunctionExpression(ts.filter(node.modifiers, function (m) { return !ts.isStaticModifier(m); }), node.asteriskToken, functionName, + /* typeParameters */ undefined, ts.visitParameterList(node.parameters, classElementVisitor, context), + /* type */ undefined, ts.visitFunctionBody(node.body, classElementVisitor, context)))); + } + // remove method declaration from class + return undefined; + } + function getHoistedFunctionName(node) { + 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 */) { + return info.methodName; + } + if (info.kind === "a" /* Accessor */) { + if (ts.isGetAccessor(node)) { + return info.getterName; + } + if (ts.isSetAccessor(node)) { + return info.setterName; + } + } + } function visitPropertyDeclaration(node) { ts.Debug.assert(!ts.some(node.decorators)); - if (!shouldTransformPrivateFields && ts.isPrivateIdentifier(node.name)) { - // Initializer is elided as the field is initialized in transformConstructor. - return factory.updatePropertyDeclaration(node, - /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name, - /*questionOrExclamationToken*/ undefined, - /*type*/ undefined, - /*initializer*/ undefined); + if (ts.isPrivateIdentifier(node.name)) { + if (!shouldTransformPrivateElements) { + // Initializer is elided as the field is initialized in transformConstructor. + return factory.updatePropertyDeclaration(node, + /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name, + /*questionOrExclamationToken*/ undefined, + /*type*/ undefined, + /*initializer*/ undefined); + } + // leave invalid code untransformed + var info = accessPrivateIdentifier(node.name); + ts.Debug.assert(info, "Undeclared private name for property declaration."); + if (!info.isValid) { + return node; + } } // Create a temporary variable to store a computed property name (if necessary). // If it's not inlineable, then we emit an expression after the class which assigns // the property name to the temporary variable. - var expr = getPropertyNameExpressionIfNeeded(node.name, !!node.initializer || !!context.getCompilerOptions().useDefineForClassFields); + var expr = getPropertyNameExpressionIfNeeded(node.name, !!node.initializer || useDefineForClassFields); if (expr && !ts.isSimpleInlineableExpression(expr)) { getPendingExpressions().push(expr); } return undefined; } function createPrivateIdentifierAccess(info, receiver) { - receiver = ts.visitNode(receiver, visitor, ts.isExpression); - switch (info.placement) { - case 0 /* InstanceField */: - return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(ts.nodeIsSynthesized(receiver) ? receiver : factory.cloneNode(receiver), info.weakMapName); - default: return ts.Debug.fail("Unexpected private identifier placement"); + return createPrivateIdentifierAccessHelper(info, ts.visitNode(receiver, visitor, ts.isExpression)); + } + function createPrivateIdentifierAccessHelper(info, receiver) { + ts.setCommentRange(receiver, ts.moveRangePos(receiver, -1)); + switch (info.kind) { + case "a" /* Accessor */: + return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.getterName); + case "m" /* Method */: + return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.methodName); + case "f" /* Field */: + return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.variableName); + default: + ts.Debug.assertNever(info, "Unknown private element type"); } } function visitPropertyAccessExpression(node) { - if (shouldTransformPrivateFields && ts.isPrivateIdentifier(node.name)) { + if (shouldTransformPrivateElements && ts.isPrivateIdentifier(node.name)) { var privateIdentifierInfo = accessPrivateIdentifier(node.name); if (privateIdentifierInfo) { - return ts.setOriginalNode(createPrivateIdentifierAccess(privateIdentifierInfo, node.expression), node); + return ts.setTextRange(ts.setOriginalNode(createPrivateIdentifierAccess(privateIdentifierInfo, node.expression), node), node); } } return ts.visitEachChild(node, visitor, context); } function visitPrefixUnaryExpression(node) { - if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { + if (shouldTransformPrivateElements && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { var operator = node.operator === 45 /* PlusPlusToken */ ? 39 /* PlusToken */ : node.operator === 46 /* MinusMinusToken */ ? 40 /* MinusToken */ : undefined; @@ -86043,13 +89204,13 @@ var ts; var receiver = ts.visitNode(node.operand.expression, visitor, ts.isExpression); var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression; var existingValue = factory.createPrefixUnaryExpression(39 /* PlusToken */, createPrivateIdentifierAccess(info, readExpression)); - return ts.setOriginalNode(createPrivateIdentifierAssignment(info, initializeExpression || readExpression, factory.createBinaryExpression(existingValue, operator, factory.createNumericLiteral(1)), 62 /* EqualsToken */), node); + return ts.setOriginalNode(createPrivateIdentifierAssignment(info, initializeExpression || readExpression, factory.createBinaryExpression(existingValue, operator, factory.createNumericLiteral(1)), 63 /* EqualsToken */), node); } } return ts.visitEachChild(node, visitor, context); } function visitPostfixUnaryExpression(node, valueIsDiscarded) { - if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { + if (shouldTransformPrivateElements && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { var operator = node.operator === 45 /* PlusPlusToken */ ? 39 /* PlusToken */ : node.operator === 46 /* MinusMinusToken */ ? 40 /* MinusToken */ : undefined; @@ -86061,7 +89222,7 @@ var ts; // Create a temporary variable to store the value returned by the expression. var returnValue = valueIsDiscarded ? undefined : factory.createTempVariable(hoistVariableDeclaration); return ts.setOriginalNode(factory.inlineExpressions(ts.compact([ - createPrivateIdentifierAssignment(info, initializeExpression || readExpression, factory.createBinaryExpression(returnValue ? factory.createAssignment(returnValue, existingValue) : existingValue, operator, factory.createNumericLiteral(1)), 62 /* EqualsToken */), + createPrivateIdentifierAssignment(info, initializeExpression || readExpression, factory.createBinaryExpression(returnValue ? factory.createAssignment(returnValue, existingValue) : existingValue, operator, factory.createNumericLiteral(1)), 63 /* EqualsToken */), returnValue ])), node); } @@ -86070,7 +89231,7 @@ var ts; } function visitForStatement(node) { if (node.incrementor && ts.isPostfixUnaryExpression(node.incrementor)) { - return factory.updateForStatement(node, ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), visitPostfixUnaryExpression(node.incrementor, /*valueIsDiscarded*/ true), ts.visitNode(node.statement, visitor, ts.isStatement)); + return factory.updateForStatement(node, ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), visitPostfixUnaryExpression(node.incrementor, /*valueIsDiscarded*/ true), ts.visitIterationBody(node.statement, visitor, context)); } return ts.visitEachChild(node, visitor, context); } @@ -86090,16 +89251,21 @@ var ts; return { readExpression: readExpression, initializeExpression: initializeExpression }; } function visitCallExpression(node) { - if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.expression)) { + if (shouldTransformPrivateElements && ts.isPrivateIdentifierPropertyAccessExpression(node.expression)) { // Transform call expressions of private names to properly bind the `this` parameter. var _a = factory.createCallBinding(node.expression, hoistVariableDeclaration, languageVersion), thisArg = _a.thisArg, target = _a.target; + if (ts.isCallChain(node)) { + return factory.updateCallChain(node, factory.createPropertyAccessChain(ts.visitNode(target, visitor), node.questionDotToken, "call"), + /*questionDotToken*/ undefined, + /*typeArguments*/ undefined, __spreadArray([ts.visitNode(thisArg, visitor, ts.isExpression)], ts.visitNodes(node.arguments, visitor, ts.isExpression))); + } return factory.updateCallExpression(node, factory.createPropertyAccessExpression(ts.visitNode(target, visitor), "call"), /*typeArguments*/ undefined, __spreadArray([ts.visitNode(thisArg, visitor, ts.isExpression)], ts.visitNodes(node.arguments, visitor, ts.isExpression))); } return ts.visitEachChild(node, visitor, context); } function visitTaggedTemplateExpression(node) { - if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.tag)) { + if (shouldTransformPrivateElements && ts.isPrivateIdentifierPropertyAccessExpression(node.tag)) { // Bind the `this` correctly for tagged template literals when the tag is a private identifier property access. var _a = factory.createCallBinding(node.tag, hoistVariableDeclaration, languageVersion), thisArg = _a.thisArg, target = _a.target; return factory.updateTaggedTemplateExpression(node, factory.createCallExpression(factory.createPropertyAccessExpression(ts.visitNode(target, visitor), "bind"), @@ -86109,7 +89275,7 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitBinaryExpression(node) { - if (shouldTransformPrivateFields) { + if (shouldTransformPrivateElements) { if (ts.isDestructuringAssignment(node)) { var savedPendingExpressions = pendingExpressions; pendingExpressions = undefined; @@ -86123,29 +89289,31 @@ var ts; if (ts.isAssignmentExpression(node) && ts.isPrivateIdentifierPropertyAccessExpression(node.left)) { var info = accessPrivateIdentifier(node.left.name); if (info) { - return ts.setOriginalNode(createPrivateIdentifierAssignment(info, node.left.expression, node.right, node.operatorToken.kind), node); + return ts.setTextRange(ts.setOriginalNode(createPrivateIdentifierAssignment(info, node.left.expression, node.right, node.operatorToken.kind), node), node); } } } return ts.visitEachChild(node, visitor, context); } function createPrivateIdentifierAssignment(info, receiver, right, operator) { - switch (info.placement) { - case 0 /* InstanceField */: { - return createPrivateIdentifierInstanceFieldAssignment(info, receiver, right, operator); - } - default: return ts.Debug.fail("Unexpected private identifier placement"); - } - } - function createPrivateIdentifierInstanceFieldAssignment(info, receiver, right, operator) { receiver = ts.visitNode(receiver, visitor, ts.isExpression); right = ts.visitNode(right, visitor, ts.isExpression); if (ts.isCompoundAssignment(operator)) { var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression; - return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(initializeExpression || readExpression, info.weakMapName, factory.createBinaryExpression(context.getEmitHelperFactory().createClassPrivateFieldGetHelper(readExpression, info.weakMapName), ts.getNonAssignmentOperatorForCompoundAssignment(operator), right)); - } - else { - return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.weakMapName, right); + receiver = initializeExpression || readExpression; + right = factory.createBinaryExpression(createPrivateIdentifierAccessHelper(info, readExpression), ts.getNonAssignmentOperatorForCompoundAssignment(operator), right); + } + ts.setCommentRange(receiver, ts.moveRangePos(receiver, -1)); + switch (info.kind) { + case "a" /* Accessor */: + return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, info.setterName); + case "m" /* Method */: + return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, + /* f */ undefined); + case "f" /* Field */: + return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, info.variableName); + default: + ts.Debug.assertNever(info, "Unknown private element type"); } } /** @@ -86154,32 +89322,53 @@ var ts; function visitClassLike(node) { var savedPendingExpressions = pendingExpressions; pendingExpressions = undefined; - if (shouldTransformPrivateFields) { + if (shouldTransformPrivateElements) { startPrivateIdentifierEnvironment(); + var name = ts.getNameOfDeclaration(node); + if (name && ts.isIdentifier(name)) { + getPrivateIdentifierEnvironment().className = ts.idText(name); + } + var privateInstanceMethodsAndAccessors = getPrivateInstanceMethodsAndAccessors(node); + if (ts.some(privateInstanceMethodsAndAccessors)) { + getPrivateIdentifierEnvironment().weakSetName = createHoistedVariableForClass("instances", privateInstanceMethodsAndAccessors[0].name); + } } var result = ts.isClassDeclaration(node) ? visitClassDeclaration(node) : visitClassExpression(node); - if (shouldTransformPrivateFields) { + if (shouldTransformPrivateElements) { endPrivateIdentifierEnvironment(); } pendingExpressions = savedPendingExpressions; return result; } function doesClassElementNeedTransform(node) { - return ts.isPropertyDeclaration(node) || (shouldTransformPrivateFields && node.name && ts.isPrivateIdentifier(node.name)); + return ts.isPropertyDeclaration(node) || (shouldTransformPrivateElements && node.name && ts.isPrivateIdentifier(node.name)); + } + function getPrivateInstanceMethodsAndAccessors(node) { + return ts.filter(node.members, ts.isNonStaticMethodOrAccessorWithPrivateName); } function visitClassDeclaration(node) { if (!ts.forEach(node.members, doesClassElementNeedTransform)) { return ts.visitEachChild(node, visitor, context); } + var staticProperties = ts.getProperties(node, /*requireInitializer*/ false, /*isStatic*/ true); + var pendingPrivateStateAssignment; + if (shouldTransformPrivateElements && ts.some(node.members, function (m) { return ts.hasStaticModifier(m) && !!m.name && ts.isPrivateIdentifier(m.name); })) { + var temp = factory.createTempVariable(hoistVariableDeclaration, /* reservedInNestedScopes */ true); + getPrivateIdentifierEnvironment().classConstructor = factory.cloneNode(temp); + pendingPrivateStateAssignment = factory.createAssignment(temp, factory.getInternalName(node)); + } var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 103 /* NullKeyword */); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */); var statements = [ factory.updateClassDeclaration(node, /*decorators*/ undefined, node.modifiers, node.name, /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass)) ]; + if (pendingPrivateStateAssignment) { + getPendingExpressions().unshift(pendingPrivateStateAssignment); + } // Write any pending expressions from elided or moved computed property names if (ts.some(pendingExpressions)) { statements.push(factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))); @@ -86189,7 +89378,6 @@ var ts; // From ES6 specification: // HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using // a lexical declaration such as a LexicalDeclaration or a ClassDeclaration. - var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); if (ts.some(staticProperties)) { addPropertyStatements(statements, staticProperties, factory.getInternalName(node)); } @@ -86207,12 +89395,25 @@ var ts; // class declaration transformation. The VariableStatement visitor will insert // these statements after the class expression variable statement. var isDecoratedClassDeclaration = ts.isClassDeclaration(ts.getOriginalNode(node)); - var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); + var staticProperties = ts.getProperties(node, /*requireInitializer*/ false, /*isStatic*/ true); var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 103 /* NullKeyword */); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */); + var isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */; + var temp; + function createClassTempVar() { + var classCheckFlags = resolver.getNodeCheckFlags(node); + var isClassWithConstructorReference = classCheckFlags & 16777216 /* ClassWithConstructorReference */; + var requiresBlockScopedVar = classCheckFlags & 524288 /* BlockScopedBindingInLoop */; + return factory.createTempVariable(requiresBlockScopedVar ? addBlockScopedVariable : hoistVariableDeclaration, !!isClassWithConstructorReference); + } + if (shouldTransformPrivateElements && ts.some(node.members, function (m) { return ts.hasStaticModifier(m) && !!m.name && ts.isPrivateIdentifier(m.name); })) { + temp = createClassTempVar(); + getPrivateIdentifierEnvironment().classConstructor = factory.cloneNode(temp); + } var classExpression = factory.updateClassExpression(node, ts.visitNodes(node.decorators, visitor, ts.isDecorator), node.modifiers, node.name, /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass)); - if (ts.some(staticProperties) || ts.some(pendingExpressions)) { + var hasTransformableStatics = ts.some(staticProperties, function (p) { return !!p.initializer || (shouldTransformPrivateElements && ts.isPrivateIdentifier(p.name)); }); + if (hasTransformableStatics || ts.some(pendingExpressions)) { if (isDecoratedClassDeclaration) { ts.Debug.assertIsDefined(pendingStatements, "Decorated classes transformed by TypeScript are expected to be within a variable declaration."); // Write any pending expressions from elided or moved computed property names @@ -86222,12 +89423,14 @@ var ts; if (pendingStatements && ts.some(staticProperties)) { addPropertyStatements(pendingStatements, staticProperties, factory.getInternalName(node)); } + if (temp) { + return factory.inlineExpressions([factory.createAssignment(temp, classExpression), temp]); + } return classExpression; } else { var expressions = []; - var isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */; - var temp = factory.createTempVariable(hoistVariableDeclaration, !!isClassWithConstructorReference); + temp || (temp = createClassTempVar()); if (isClassWithConstructorReference) { // record an alias as the class name is not in scope for statics. enableSubstitutionForClassAliases(); @@ -86249,14 +89452,17 @@ var ts; return classExpression; } function transformClassMembers(node, isDerivedClass) { - if (shouldTransformPrivateFields) { + if (shouldTransformPrivateElements) { // Declare private names. for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (ts.isPrivateIdentifierPropertyDeclaration(member)) { - addPrivateIdentifierToEnvironment(member.name); + if (ts.isPrivateIdentifierClassElementDeclaration(member)) { + addPrivateIdentifierToEnvironment(member); } } + if (ts.some(getPrivateInstanceMethodsAndAccessors(node))) { + createBrandCheckWeakSetForPrivateMethods(); + } } var members = []; var constructor = transformConstructor(node, isDerivedClass); @@ -86266,21 +89472,27 @@ var ts; ts.addRange(members, ts.visitNodes(node.members, classElementVisitor, ts.isClassElement)); return ts.setTextRange(factory.createNodeArray(members), /*location*/ node.members); } - function isPropertyDeclarationThatRequiresConstructorStatement(member) { - if (!ts.isPropertyDeclaration(member) || ts.hasStaticModifier(member) || ts.hasSyntacticModifier(ts.getOriginalNode(member), 128 /* Abstract */)) { + function createBrandCheckWeakSetForPrivateMethods() { + var weakSetName = getPrivateIdentifierEnvironment().weakSetName; + ts.Debug.assert(weakSetName, "weakSetName should be set in private identifier environment"); + getPendingExpressions().push(factory.createAssignment(weakSetName, factory.createNewExpression(factory.createIdentifier("WeakSet"), + /*typeArguments*/ undefined, []))); + } + function isClassElementThatRequiresConstructorStatement(member) { + if (ts.hasStaticModifier(member) || ts.hasSyntacticModifier(ts.getOriginalNode(member), 128 /* Abstract */)) { return false; } - if (context.getCompilerOptions().useDefineForClassFields) { + 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 < 99 /* ESNext */; } - return ts.isInitializedProperty(member) || shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyDeclaration(member); + return ts.isInitializedProperty(member) || shouldTransformPrivateElements && ts.isPrivateIdentifierClassElementDeclaration(member); } function transformConstructor(node, isDerivedClass) { var constructor = ts.visitNode(ts.getFirstConstructorWithBody(node), visitor, ts.isConstructorDeclaration); - var properties = node.members.filter(isPropertyDeclarationThatRequiresConstructorStatement); - if (!ts.some(properties)) { + var elements = node.members.filter(isClassElementThatRequiresConstructorStatement); + if (!ts.some(elements)) { return constructor; } var parameters = ts.visitParameterList(constructor ? constructor.parameters : undefined, visitor, context); @@ -86293,13 +89505,14 @@ var ts; /*modifiers*/ undefined, parameters !== null && parameters !== void 0 ? parameters : [], body), constructor || node), constructor)); } function transformConstructorBody(node, constructor, isDerivedClass) { - var useDefineForClassFields = context.getCompilerOptions().useDefineForClassFields; var properties = ts.getProperties(node, /*requireInitializer*/ false, /*isStatic*/ false); if (!useDefineForClassFields) { properties = ts.filter(properties, function (property) { return !!property.initializer || ts.isPrivateIdentifier(property.name); }); } + var privateMethodsAndAccessors = getPrivateInstanceMethodsAndAccessors(node); + var needsConstructorBody = ts.some(properties) || ts.some(privateMethodsAndAccessors); // Only generate synthetic constructor when there are property initializers to move. - if (!constructor && !ts.some(properties)) { + if (!constructor && !needsConstructorBody) { return ts.visitFunctionBody(/*node*/ undefined, visitor, context); } resumeLexicalEnvironment(); @@ -86338,7 +89551,10 @@ var ts; indexOfFirstStatement = afterParameterProperties; } } - addPropertyStatements(statements, properties, factory.createThis()); + var receiver = factory.createThis(); + // private methods can be called in property initializers, they should execute first. + addMethodStatements(statements, privateMethodsAndAccessors, receiver); + addPropertyStatements(statements, properties, receiver); // Add existing statements, skipping the initial super call. if (constructor) { ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement)); @@ -86400,27 +89616,30 @@ var ts; function transformProperty(property, receiver) { var _a; // We generate a name here in order to reuse the value cached by the relocated computed name expression (which uses the same generated name) - var emitAssignment = !context.getCompilerOptions().useDefineForClassFields; + var emitAssignment = !useDefineForClassFields; var propertyName = ts.isComputedPropertyName(property.name) && !ts.isSimpleInlineableExpression(property.name.expression) ? factory.updateComputedPropertyName(property.name, factory.getGeneratedNameForNode(property.name)) : property.name; - if (shouldTransformPrivateFields && ts.isPrivateIdentifier(propertyName)) { + if (shouldTransformPrivateElements && ts.isPrivateIdentifier(propertyName)) { var privateIdentifierInfo = accessPrivateIdentifier(propertyName); if (privateIdentifierInfo) { - switch (privateIdentifierInfo.placement) { - case 0 /* InstanceField */: { - return createPrivateInstanceFieldInitializer(receiver, ts.visitNode(property.initializer, visitor, ts.isExpression), privateIdentifierInfo.weakMapName); + if (privateIdentifierInfo.kind === "f" /* Field */) { + if (!privateIdentifierInfo.isStatic) { + return createPrivateInstanceFieldInitializer(receiver, ts.visitNode(property.initializer, visitor, ts.isExpression), privateIdentifierInfo.brandCheckIdentifier); + } + else { + return createPrivateStaticFieldInitializer(privateIdentifierInfo.variableName, ts.visitNode(property.initializer, visitor, ts.isExpression)); } } + else { + return undefined; + } } else { ts.Debug.fail("Undeclared private name for property declaration."); } } - if (ts.isPrivateIdentifier(propertyName) && !property.initializer) { - return undefined; - } - if (ts.isPrivateIdentifier(propertyName) && !property.initializer) { + if ((ts.isPrivateIdentifier(propertyName) || ts.hasStaticModifier(property)) && !property.initializer) { return undefined; } var propertyOriginalNode = ts.getOriginalNode(property); @@ -86447,11 +89666,26 @@ var ts; enabledSubstitutions |= 1 /* ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(78 /* Identifier */); + context.enableSubstitution(79 /* Identifier */); // Keep track of class aliases. classAliases = []; } } + /** + * Generates brand-check initializer for private methods. + * + * @param statements Statement list that should be used to append new statements. + * @param methods An array of method declarations. + * @param receiver The receiver on which each method should be assigned. + */ + function addMethodStatements(statements, methods, receiver) { + if (!shouldTransformPrivateElements || !ts.some(methods)) { + return; + } + var weakSetName = getPrivateIdentifierEnvironment().weakSetName; + ts.Debug.assert(weakSetName, "weakSetName should be set in private identifier environment"); + statements.push(factory.createExpressionStatement(createPrivateInstanceMethodInitializer(receiver, weakSetName))); + } /** * Hooks node substitutions. * @@ -86467,7 +89701,7 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return substituteExpressionIdentifier(node); } return node; @@ -86487,10 +89721,10 @@ var ts; if (declaration) { var classAlias = classAliases[declaration.id]; // TODO: GH#18217 if (classAlias) { - var clone_2 = factory.cloneNode(classAlias); - ts.setSourceMapRange(clone_2, node); - ts.setCommentRange(clone_2, node); - return clone_2; + var clone_3 = factory.cloneNode(classAlias); + ts.setSourceMapRange(clone_3, node); + ts.setCommentRange(clone_3, node); + return clone_3; } } } @@ -86510,7 +89744,12 @@ var ts; var alreadyTransformed = ts.isAssignmentExpression(innerExpression) && ts.isGeneratedIdentifier(innerExpression.left); if (!alreadyTransformed && !inlinable && shouldHoist) { var generatedName = factory.getGeneratedNameForNode(name); - hoistVariableDeclaration(generatedName); + if (resolver.getNodeCheckFlags(name) & 524288 /* BlockScopedBindingInLoop */) { + addBlockScopedVariable(generatedName); + } + else { + hoistVariableDeclaration(generatedName); + } return factory.createAssignment(generatedName, expression); } return (inlinable || ts.isIdentifier(innerExpression)) ? undefined : expression; @@ -86524,22 +89763,164 @@ var ts; currentPrivateIdentifierEnvironment = privateIdentifierEnvironmentStack.pop(); } function getPrivateIdentifierEnvironment() { - return currentPrivateIdentifierEnvironment || (currentPrivateIdentifierEnvironment = new ts.Map()); + if (!currentPrivateIdentifierEnvironment) { + currentPrivateIdentifierEnvironment = { + className: "", + identifiers: new ts.Map() + }; + } + return currentPrivateIdentifierEnvironment; } function getPendingExpressions() { return pendingExpressions || (pendingExpressions = []); } - function addPrivateIdentifierToEnvironment(name) { - var text = ts.getTextOfPropertyName(name); - var weakMapName = factory.createUniqueName("_" + text.substring(1), 16 /* Optimistic */ | 8 /* ReservedInNestedScopes */); - hoistVariableDeclaration(weakMapName); - getPrivateIdentifierEnvironment().set(name.escapedText, { placement: 0 /* InstanceField */, weakMapName: weakMapName }); - getPendingExpressions().push(factory.createAssignment(weakMapName, factory.createNewExpression(factory.createIdentifier("WeakMap"), - /*typeArguments*/ undefined, []))); + function addPrivateIdentifierToEnvironment(node) { + var _a; + var text = ts.getTextOfPropertyName(node.name); + var env = getPrivateIdentifierEnvironment(); + var weakSetName = env.weakSetName, classConstructor = env.classConstructor; + var assignmentExpressions = []; + var privateName = node.name.escapedText; + var previousInfo = env.identifiers.get(privateName); + var isValid = !isReservedPrivateName(node.name) && previousInfo === undefined; + if (ts.hasStaticModifier(node)) { + ts.Debug.assert(classConstructor, "weakSetName should be set in private identifier environment"); + if (ts.isPropertyDeclaration(node)) { + var variableName = createHoistedVariableForPrivateName(text, node); + env.identifiers.set(privateName, { + kind: "f" /* Field */, + variableName: variableName, + brandCheckIdentifier: classConstructor, + isStatic: true, + isValid: isValid, + }); + } + else if (ts.isMethodDeclaration(node)) { + var functionName = createHoistedVariableForPrivateName(text, node); + env.identifiers.set(privateName, { + kind: "m" /* Method */, + methodName: functionName, + brandCheckIdentifier: classConstructor, + isStatic: true, + isValid: isValid, + }); + } + 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) { + previousInfo.getterName = getterName; + } + else { + env.identifiers.set(privateName, { + kind: "a" /* Accessor */, + getterName: getterName, + setterName: undefined, + brandCheckIdentifier: classConstructor, + isStatic: true, + isValid: isValid, + }); + } + } + 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) { + previousInfo.setterName = setterName; + } + else { + env.identifiers.set(privateName, { + kind: "a" /* Accessor */, + getterName: undefined, + setterName: setterName, + brandCheckIdentifier: classConstructor, + isStatic: true, + isValid: isValid, + }); + } + } + else { + ts.Debug.assertNever(node, "Unknown class element type."); + } + } + else if (ts.isPropertyDeclaration(node)) { + var weakMapName = createHoistedVariableForPrivateName(text, node); + env.identifiers.set(privateName, { + kind: "f" /* Field */, + brandCheckIdentifier: weakMapName, + isStatic: false, + variableName: undefined, + isValid: isValid, + }); + assignmentExpressions.push(factory.createAssignment(weakMapName, factory.createNewExpression(factory.createIdentifier("WeakMap"), + /*typeArguments*/ undefined, []))); + } + else if (ts.isMethodDeclaration(node)) { + ts.Debug.assert(weakSetName, "weakSetName should be set in private identifier environment"); + env.identifiers.set(privateName, { + kind: "m" /* Method */, + methodName: createHoistedVariableForPrivateName(text, node), + brandCheckIdentifier: weakSetName, + isStatic: false, + isValid: isValid, + }); + } + else if (ts.isAccessor(node)) { + 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) { + previousInfo.getterName = getterName; + } + else { + env.identifiers.set(privateName, { + kind: "a" /* Accessor */, + getterName: getterName, + setterName: undefined, + brandCheckIdentifier: weakSetName, + isStatic: false, + isValid: isValid, + }); + } + } + else { + var setterName = createHoistedVariableForPrivateName(text + "_set", node); + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && !previousInfo.isStatic && !previousInfo.setterName) { + previousInfo.setterName = setterName; + } + else { + env.identifiers.set(privateName, { + kind: "a" /* Accessor */, + getterName: undefined, + setterName: setterName, + brandCheckIdentifier: weakSetName, + isStatic: false, + isValid: isValid, + }); + } + } + } + else { + ts.Debug.assertNever(node, "Unknown class element type."); + } + (_a = getPendingExpressions()).push.apply(_a, assignmentExpressions); + } + 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 */) { + addBlockScopedVariable(identifier); + } + else { + hoistVariableDeclaration(identifier); + } + return identifier; + } + function createHoistedVariableForPrivateName(privateName, node) { + return createHoistedVariableForClass(privateName.substring(1), node.name); } function accessPrivateIdentifier(name) { if (currentPrivateIdentifierEnvironment) { - var info = currentPrivateIdentifierEnvironment.get(name.escapedText); + var info = currentPrivateIdentifierEnvironment.identifiers.get(name.escapedText); if (info) { return info; } @@ -86549,7 +89930,7 @@ var ts; if (!env) { continue; } - var info = env.get(name.escapedText); + var info = env.identifiers.get(name.escapedText); if (info) { return info; } @@ -86567,7 +89948,7 @@ 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, 62 /* EqualsToken */, node.expression)); + getPendingExpressions().push(factory.createBinaryExpression(receiver, 63 /* EqualsToken */, node.expression)); } return factory.createPropertyAccessExpression( // Explicit parens required because of v8 regression (https://bugs.chromium.org/p/v8/issues/detail?id=9560) @@ -86580,7 +89961,7 @@ var ts; /*dotDotDotToken*/ undefined, parameter, /*questionToken*/ undefined, /*type*/ undefined, - /*initializer*/ undefined)], factory.createBlock([factory.createExpressionStatement(createPrivateIdentifierAssignment(info, receiver, parameter, 62 /* EqualsToken */))])) + /*initializer*/ undefined)], factory.createBlock([factory.createExpressionStatement(createPrivateIdentifierAssignment(info, receiver, parameter, 63 /* EqualsToken */))])) ])), "value"); } function visitArrayAssignmentTarget(node) { @@ -86635,10 +90016,22 @@ var ts; } } ts.transformClassFields = transformClassFields; + function createPrivateStaticFieldInitializer(variableName, initializer) { + return ts.factory.createAssignment(variableName, ts.factory.createObjectLiteralExpression([ + ts.factory.createPropertyAssignment("value", initializer || ts.factory.createVoidZero()) + ])); + } function createPrivateInstanceFieldInitializer(receiver, initializer, weakMapName) { return ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(weakMapName, "set"), /*typeArguments*/ undefined, [receiver, initializer || ts.factory.createVoidZero()]); } + function createPrivateInstanceMethodInitializer(receiver, weakSetName) { + return ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(weakSetName, "add"), + /*typeArguments*/ undefined, [receiver]); + } + function isReservedPrivateName(node) { + return node.escapedText === "#constructor"; + } })(ts || (ts = {})); /*@internal*/ var ts; @@ -86721,38 +90114,38 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 64 /* ContainsES2017 */) === 0) { + if ((node.transformFlags & 128 /* ContainsES2017 */) === 0) { return node; } switch (node.kind) { - case 129 /* AsyncKeyword */: + case 130 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 213 /* AwaitExpression */: + case 215 /* AwaitExpression */: return visitAwaitExpression(node); - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitMethodDeclaration, node); - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitFunctionDeclaration, node); - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitFunctionExpression, node); - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return doWithContext(1 /* NonTopLevel */, visitArrowFunction, node); - case 201 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 105 /* SuperKeyword */) { + case 203 /* PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SuperKeyword */) { capturedSuperProperties.add(node.name.escapedText); } return ts.visitEachChild(node, visitor, context); - case 202 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 105 /* SuperKeyword */) { + case 204 /* ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 106 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 166 /* Constructor */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 168 /* Constructor */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitDefault, node); default: return ts.visitEachChild(node, visitor, context); @@ -86761,27 +90154,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return visitForStatementInAsyncBody(node); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return visitForInStatementInAsyncBody(node); - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return visitCatchClauseInAsyncBody(node); - case 230 /* Block */: - case 244 /* SwitchStatement */: - case 258 /* CaseBlock */: - case 284 /* CaseClause */: - case 285 /* DefaultClause */: - case 247 /* TryStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: - case 234 /* IfStatement */: - case 243 /* WithStatement */: - case 245 /* LabeledStatement */: + case 232 /* Block */: + case 246 /* SwitchStatement */: + case 260 /* CaseBlock */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: + case 249 /* TryStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: + case 236 /* IfStatement */: + case 245 /* WithStatement */: + case 247 /* LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -86823,18 +90216,18 @@ var ts; function visitForInStatementInAsyncBody(node) { return factory.updateForInStatement(node, isVariableDeclarationListWithCollidingName(node.initializer) ? visitVariableDeclarationListWithCollidingNames(node.initializer, /*hasReceiver*/ true) - : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, asyncBodyVisitor, ts.isStatement, factory.liftToBlock)); + : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitIterationBody(node.statement, asyncBodyVisitor, context)); } function visitForOfStatementInAsyncBody(node) { return factory.updateForOfStatement(node, ts.visitNode(node.awaitModifier, visitor, ts.isToken), isVariableDeclarationListWithCollidingName(node.initializer) ? visitVariableDeclarationListWithCollidingNames(node.initializer, /*hasReceiver*/ true) - : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, asyncBodyVisitor, ts.isStatement, factory.liftToBlock)); + : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitIterationBody(node.statement, asyncBodyVisitor, context)); } function visitForStatementInAsyncBody(node) { var initializer = node.initializer; // TODO: GH#18217 return factory.updateForStatement(node, isVariableDeclarationListWithCollidingName(initializer) ? visitVariableDeclarationListWithCollidingNames(initializer, /*hasReceiver*/ false) - : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitor, ts.isExpression), ts.visitNode(node.statement, asyncBodyVisitor, ts.isStatement, factory.liftToBlock)); + : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitor, ts.isExpression), ts.visitIterationBody(node.statement, asyncBodyVisitor, context)); } /** * Visits an AwaitExpression node. @@ -86986,7 +90379,7 @@ var ts; var original = ts.getOriginalNode(node, ts.isFunctionLike); var nodeType = original.type; var promiseConstructor = languageVersion < 2 /* ES2015 */ ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 209 /* ArrowFunction */; + var isArrowFunction = node.kind === 211 /* ArrowFunction */; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* 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 @@ -87077,17 +90470,17 @@ var ts; enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(203 /* CallExpression */); - context.enableSubstitution(201 /* PropertyAccessExpression */); - context.enableSubstitution(202 /* ElementAccessExpression */); + context.enableSubstitution(205 /* CallExpression */); + context.enableSubstitution(203 /* PropertyAccessExpression */); + context.enableSubstitution(204 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(252 /* ClassDeclaration */); - context.enableEmitNotification(165 /* MethodDeclaration */); - context.enableEmitNotification(167 /* GetAccessor */); - context.enableEmitNotification(168 /* SetAccessor */); - context.enableEmitNotification(166 /* Constructor */); + context.enableEmitNotification(254 /* ClassDeclaration */); + context.enableEmitNotification(167 /* MethodDeclaration */); + context.enableEmitNotification(169 /* GetAccessor */); + context.enableEmitNotification(170 /* SetAccessor */); + context.enableEmitNotification(168 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(232 /* VariableStatement */); + context.enableEmitNotification(234 /* VariableStatement */); } } /** @@ -87135,23 +90528,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -87171,11 +90564,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 252 /* ClassDeclaration */ - || kind === 166 /* Constructor */ - || kind === 165 /* MethodDeclaration */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */; + return kind === 254 /* ClassDeclaration */ + || kind === 168 /* Constructor */ + || kind === 167 /* MethodDeclaration */ + || kind === 169 /* GetAccessor */ + || kind === 170 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -87332,7 +90725,7 @@ var ts; return visitorWorker(node, /*expressionResultIsUnused*/ true); } function visitorNoAsyncModifier(node) { - if (node.kind === 129 /* AsyncKeyword */) { + if (node.kind === 130 /* AsyncKeyword */) { return undefined; } return node; @@ -87354,74 +90747,74 @@ var ts; * expression of an `ExpressionStatement`). */ function visitorWorker(node, expressionResultIsUnused) { - if ((node.transformFlags & 32 /* ContainsES2018 */) === 0) { + if ((node.transformFlags & 64 /* ContainsES2018 */) === 0) { return node; } switch (node.kind) { - case 213 /* AwaitExpression */: + case 215 /* AwaitExpression */: return visitAwaitExpression(node); - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: return visitYieldExpression(node); - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: return visitReturnStatement(node); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return visitLabeledStatement(node); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return visitBinaryExpression(node, expressionResultIsUnused); - case 337 /* CommaListExpression */: + case 345 /* CommaListExpression */: return visitCommaListExpression(node, expressionResultIsUnused); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return visitCatchClause(node); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return visitVariableStatement(node); - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 235 /* DoStatement */: - case 236 /* WhileStatement */: - case 238 /* ForInStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: + case 240 /* ForInStatement */: return doWithHierarchyFacts(visitDefault, node, 0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return doWithHierarchyFacts(visitForStatement, node, 0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - case 212 /* VoidExpression */: + case 214 /* VoidExpression */: return visitVoidExpression(node); - case 166 /* Constructor */: + case 168 /* Constructor */: return doWithHierarchyFacts(visitConstructorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: return doWithHierarchyFacts(visitMethodDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 167 /* GetAccessor */: + case 169 /* GetAccessor */: return doWithHierarchyFacts(visitGetAccessorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 168 /* SetAccessor */: + case 170 /* SetAccessor */: return doWithHierarchyFacts(visitSetAccessorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return doWithHierarchyFacts(visitFunctionDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: return doWithHierarchyFacts(visitFunctionExpression, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return doWithHierarchyFacts(visitArrowFunction, node, 2 /* ArrowFunctionExcludes */, 0 /* ArrowFunctionIncludes */); - case 160 /* Parameter */: + case 162 /* Parameter */: return visitParameter(node); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: return visitExpressionStatement(node); - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, expressionResultIsUnused); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 201 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 105 /* SuperKeyword */) { + case 203 /* PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SuperKeyword */) { capturedSuperProperties.add(node.name.escapedText); } return ts.visitEachChild(node, visitor, context); - case 202 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 105 /* SuperKeyword */) { + case 204 /* ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 106 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: return doWithHierarchyFacts(visitDefault, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); default: return ts.visitEachChild(node, visitor, context); @@ -87457,7 +90850,7 @@ var ts; function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2 /* Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 239 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 241 /* ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return factory.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement, factory.liftToBlock), node); @@ -87469,7 +90862,7 @@ var ts; var objects = []; for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) { var e = elements_4[_i]; - if (e.kind === 290 /* SpreadAssignment */) { + if (e.kind === 292 /* SpreadAssignment */) { if (chunkObject) { objects.push(factory.createObjectLiteralExpression(chunkObject)); chunkObject = undefined; @@ -87478,7 +90871,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 288 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 290 /* PropertyAssignment */ ? factory.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -87489,7 +90882,7 @@ var ts; return objects; } function visitObjectLiteralExpression(node) { - if (node.transformFlags & 16384 /* ContainsObjectRestOrSpread */) { + if (node.transformFlags & 32768 /* 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}); @@ -87512,7 +90905,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 !== 200 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 202 /* ObjectLiteralExpression */) { objects.unshift(factory.createObjectLiteralExpression()); } var expression = objects[0]; @@ -87562,7 +90955,7 @@ var ts; * expression of an `ExpressionStatement`). */ function visitBinaryExpression(node, expressionResultIsUnused) { - if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 16384 /* ContainsObjectRestOrSpread */) { + if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { return ts.flattenDestructuringAssignment(node, visitor, context, 1 /* ObjectRest */, !expressionResultIsUnused); } if (node.operatorToken.kind === 27 /* CommaToken */) { @@ -87593,7 +90986,7 @@ var ts; function visitCatchClause(node) { if (node.variableDeclaration && ts.isBindingPattern(node.variableDeclaration.name) && - node.variableDeclaration.name.transformFlags & 16384 /* ContainsObjectRestOrSpread */) { + node.variableDeclaration.name.transformFlags & 32768 /* 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 */); @@ -87634,14 +91027,14 @@ 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 & 16384 /* ContainsObjectRestOrSpread */) { + if (ts.isBindingPattern(node.name) && node.name.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { return ts.flattenDestructuringBinding(node, visitor, context, 1 /* ObjectRest */, /*rval*/ undefined, exportedVariableStatement); } return ts.visitEachChild(node, visitor, context); } function visitForStatement(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)); + 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.visitIterationBody(node.statement, visitor, context)); } function visitVoidExpression(node) { return ts.visitEachChild(node, visitorWithUnusedExpressionResult, context); @@ -87653,7 +91046,7 @@ var ts; */ function visitForOfStatement(node, outermostLabeledStatement) { var ancestorFacts = enterSubtree(0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - if (node.initializer.transformFlags & 16384 /* ContainsObjectRestOrSpread */) { + if (node.initializer.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { node = transformForOfStatementWithObjectRest(node); } var result = node.awaitModifier ? @@ -87691,7 +91084,7 @@ var ts; var bodyLocation; var statementsLocation; var statements = [ts.visitNode(binding, visitor, ts.isStatement)]; - var statement = ts.visitNode(node.statement, visitor, ts.isStatement); + var statement = ts.visitIterationBody(node.statement, visitor, context); if (ts.isBlock(statement)) { ts.addRange(statements, statement.statements); bodyLocation = statement; @@ -87753,7 +91146,7 @@ var ts; ])); } function visitParameter(node) { - if (node.transformFlags & 16384 /* ContainsObjectRestOrSpread */) { + if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { // Binding patterns are converted into a generated name and are // evaluated inside the function body. return factory.updateParameterDeclaration(node, @@ -87905,7 +91298,7 @@ var ts; function appendObjectRestAssignmentsIfNeeded(statements, node) { for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { var parameter = _a[_i]; - if (parameter.transformFlags & 16384 /* ContainsObjectRestOrSpread */) { + if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { var temp = factory.getGeneratedNameForNode(parameter); var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* ObjectRest */, temp, /*doNotRecordTempVariablesInLine*/ false, @@ -87925,17 +91318,17 @@ var ts; enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(203 /* CallExpression */); - context.enableSubstitution(201 /* PropertyAccessExpression */); - context.enableSubstitution(202 /* ElementAccessExpression */); + context.enableSubstitution(205 /* CallExpression */); + context.enableSubstitution(203 /* PropertyAccessExpression */); + context.enableSubstitution(204 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(252 /* ClassDeclaration */); - context.enableEmitNotification(165 /* MethodDeclaration */); - context.enableEmitNotification(167 /* GetAccessor */); - context.enableEmitNotification(168 /* SetAccessor */); - context.enableEmitNotification(166 /* Constructor */); + context.enableEmitNotification(254 /* ClassDeclaration */); + context.enableEmitNotification(167 /* MethodDeclaration */); + context.enableEmitNotification(169 /* GetAccessor */); + context.enableEmitNotification(170 /* SetAccessor */); + context.enableEmitNotification(168 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(232 /* VariableStatement */); + context.enableEmitNotification(234 /* VariableStatement */); } } /** @@ -87983,23 +91376,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -88019,11 +91412,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 252 /* ClassDeclaration */ - || kind === 166 /* Constructor */ - || kind === 165 /* MethodDeclaration */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */; + return kind === 254 /* ClassDeclaration */ + || kind === 168 /* Constructor */ + || kind === 167 /* MethodDeclaration */ + || kind === 169 /* GetAccessor */ + || kind === 170 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -88051,11 +91444,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 16 /* ContainsES2019 */) === 0) { + if ((node.transformFlags & 32 /* ContainsES2019 */) === 0) { return node; } switch (node.kind) { - case 287 /* CatchClause */: + case 289 /* CatchClause */: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -88083,25 +91476,29 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 8 /* ContainsES2020 */) === 0) { + if ((node.transformFlags & 16 /* ContainsES2020 */) === 0) { return node; } switch (node.kind) { - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: - case 203 /* CallExpression */: - if (node.flags & 32 /* OptionalChain */) { + case 205 /* CallExpression */: { + var updated = visitNonOptionalCallExpression(node, /*captureThisArg*/ false); + ts.Debug.assertNotNode(updated, ts.isSyntheticReference); + return updated; + } + case 203 /* PropertyAccessExpression */: + case 204 /* 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 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: if (node.operatorToken.kind === 60 /* QuestionQuestionToken */) { return transformNullishCoalescingExpression(node); } return ts.visitEachChild(node, visitor, context); - case 210 /* DeleteExpression */: + case 212 /* DeleteExpression */: return visitDeleteExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -88143,7 +91540,7 @@ var ts; thisArg = expression; } } - expression = node.kind === 201 /* PropertyAccessExpression */ + expression = node.kind === 203 /* 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; @@ -88153,14 +91550,23 @@ var ts; // If `node` is an optional chain, then it is the outermost chain of an optional expression. return visitOptionalExpression(node, captureThisArg, /*isDelete*/ false); } + if (ts.isParenthesizedExpression(node.expression) && ts.isOptionalChain(ts.skipParentheses(node.expression))) { + // capture thisArg for calls of parenthesized optional chains like `(foo?.bar)()` + var expression = visitNonOptionalParenthesizedExpression(node.expression, /*captureThisArg*/ true, /*isDelete*/ false); + var args = ts.visitNodes(node.arguments, visitor, ts.isExpression); + if (ts.isSyntheticReference(expression)) { + return ts.setTextRange(factory.createFunctionCallCall(expression.expression, expression.thisArg, args), node); + } + return factory.updateCallExpression(node, expression, /*typeArguments*/ undefined, args); + } return ts.visitEachChild(node, visitor, context); } function visitNonOptionalExpression(node, captureThisArg, isDelete) { switch (node.kind) { - case 207 /* ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete); - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete); - case 203 /* CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); + case 209 /* ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete); + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete); + case 205 /* CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); default: return ts.visitNode(node, visitor, ts.isExpression); } } @@ -88179,8 +91585,8 @@ var ts; for (var i = 0; i < chain.length; i++) { var segment = chain[i]; switch (segment.kind) { - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: if (i === chain.length - 1 && captureThisArg) { if (!ts.isSimpleCopiableExpression(rightExpression)) { thisArg = factory.createTempVariable(hoistVariableDeclaration); @@ -88190,13 +91596,13 @@ var ts; thisArg = rightExpression; } } - rightExpression = segment.kind === 201 /* PropertyAccessExpression */ + rightExpression = segment.kind === 203 /* PropertyAccessExpression */ ? factory.createPropertyAccessExpression(rightExpression, ts.visitNode(segment.name, visitor, ts.isIdentifier)) : factory.createElementAccessExpression(rightExpression, ts.visitNode(segment.argumentExpression, visitor, ts.isExpression)); break; - case 203 /* CallExpression */: + case 205 /* CallExpression */: if (i === 0 && leftThisArg) { - rightExpression = factory.createFunctionCallCall(rightExpression, leftThisArg.kind === 105 /* SuperKeyword */ ? factory.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); + rightExpression = factory.createFunctionCallCall(rightExpression, leftThisArg.kind === 106 /* SuperKeyword */ ? factory.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); } else { rightExpression = factory.createCallExpression(rightExpression, @@ -88237,7 +91643,7 @@ var ts; /*@internal*/ var ts; (function (ts) { - function transformESNext(context) { + function transformES2021(context) { var hoistVariableDeclaration = context.hoistVariableDeclaration, factory = context.factory; return ts.chainBundle(context, transformSourceFile); function transformSourceFile(node) { @@ -88247,11 +91653,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 4 /* ContainsESNext */) === 0) { + if ((node.transformFlags & 8 /* ContainsES2021 */) === 0) { return node; } switch (node.kind) { - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: var binaryExpression = node; if (ts.isLogicalOrCoalescingAssignmentExpression(binaryExpression)) { return transformLogicalAssignment(binaryExpression); @@ -88287,6 +91693,29 @@ var ts; return factory.createBinaryExpression(left, nonAssignmentOperator, factory.createParenthesizedExpression(factory.createAssignment(assignmentTarget, right))); } } + ts.transformES2021 = transformES2021; +})(ts || (ts = {})); +/*@internal*/ +var ts; +(function (ts) { + function transformESNext(context) { + return ts.chainBundle(context, transformSourceFile); + function transformSourceFile(node) { + if (node.isDeclarationFile) { + return node; + } + return ts.visitEachChild(node, visitor, context); + } + function visitor(node) { + if ((node.transformFlags & 4 /* ContainsESNext */) === 0) { + return node; + } + switch (node.kind) { + default: + return ts.visitEachChild(node, visitor, context); + } + } + } ts.transformESNext = transformESNext; })(ts || (ts = {})); /*@internal*/ @@ -88397,13 +91826,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 273 /* JsxElement */: + case 275 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 274 /* JsxSelfClosingElement */: + case 276 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 277 /* JsxFragment */: + case 279 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -88413,13 +91842,13 @@ var ts; switch (node.kind) { case 11 /* JsxText */: return visitJsxText(node); - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: return visitJsxExpression(node); - case 273 /* JsxElement */: + case 275 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 274 /* JsxSelfClosingElement */: + case 276 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 277 /* JsxFragment */: + case 279 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -88537,21 +91966,29 @@ var ts; // When there are no attributes, React wants "null" } else { - // Map spans of JsxAttribute nodes into object literals and spans - // of JsxSpreadAttribute nodes into expressions. - var segments = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread - ? ts.map(attrs, transformJsxSpreadAttributeToExpression) - : factory.createObjectLiteralExpression(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); })); - if (ts.isJsxSpreadAttribute(attrs[0])) { - // We must always emit at least one object literal before a spread - // argument.factory.createObjectLiteral - segments.unshift(factory.createObjectLiteralExpression()); + var target = compilerOptions.target; + if (target && target >= 5 /* ES2018 */) { + objectProperties = factory.createObjectLiteralExpression(ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { + return isSpread ? ts.map(attrs, transformJsxSpreadAttributeToSpreadAssignment) : ts.map(attrs, transformJsxAttributeToObjectLiteralElement); + }))); } - // Either emit one big object literal (no spread attribs), or - // a call to the __assign helper. - objectProperties = ts.singleOrUndefined(segments); - if (!objectProperties) { - objectProperties = emitHelpers().createAssignHelper(segments); + else { + // Map spans of JsxAttribute nodes into object literals and spans + // of JsxSpreadAttribute nodes into expressions. + var segments = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread + ? ts.map(attrs, transformJsxSpreadAttributeToExpression) + : factory.createObjectLiteralExpression(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); })); + if (ts.isJsxSpreadAttribute(attrs[0])) { + // We must always emit at least one object literal before a spread + // argument.factory.createObjectLiteral + segments.unshift(factory.createObjectLiteralExpression()); + } + // Either emit one big object literal (no spread attribs), or + // a call to the __assign helper. + objectProperties = ts.singleOrUndefined(segments); + if (!objectProperties) { + objectProperties = emitHelpers().createAssignHelper(segments); + } } } var callee = currentFileState.importSpecifier === undefined @@ -88583,6 +92020,9 @@ var ts; } return element; } + function transformJsxSpreadAttributeToSpreadAssignment(node) { + return factory.createSpreadAssignment(ts.visitNode(node.expression, visitor, ts.isExpression)); + } function transformJsxSpreadAttributeToExpression(node) { return ts.visitNode(node.expression, visitor, ts.isExpression); } @@ -88602,7 +92042,7 @@ var ts; var literal = factory.createStringLiteral(tryDecodeEntities(node.text) || node.text, singleQuote); return ts.setTextRange(literal, node); } - else if (node.kind === 283 /* JsxExpression */) { + else if (node.kind === 285 /* JsxExpression */) { if (node.expression === undefined) { return factory.createTrue(); } @@ -88696,7 +92136,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 273 /* JsxElement */) { + if (node.kind === 275 /* JsxElement */) { return getTagName(node.openingElement); } else { @@ -88998,11 +92438,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 128 /* ContainsES2016 */) === 0) { + if ((node.transformFlags & 256 /* ContainsES2016 */) === 0) { return node; } switch (node.kind) { - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -89010,7 +92450,7 @@ var ts; } function visitBinaryExpression(node) { switch (node.operatorToken.kind) { - case 66 /* AsteriskAsteriskEqualsToken */: + case 67 /* AsteriskAsteriskEqualsToken */: return visitExponentiationAssignmentExpression(node); case 42 /* AsteriskAsteriskToken */: return visitExponentiationExpression(node); @@ -89215,11 +92655,11 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 242 /* ReturnStatement */ + && node.kind === 244 /* ReturnStatement */ && !node.expression; } function isOrMayContainReturnCompletion(node) { - return node.transformFlags & 1048576 /* ContainsHoistedDeclarationOrCompletion */ + return node.transformFlags & 2097152 /* ContainsHoistedDeclarationOrCompletion */ && (ts.isReturnStatement(node) || ts.isIfStatement(node) || ts.isWithStatement(node) @@ -89234,7 +92674,7 @@ var ts; || ts.isBlock(node)); } function shouldVisitNode(node) { - return (node.transformFlags & 256 /* ContainsES2015 */) !== 0 + return (node.transformFlags & 512 /* ContainsES2015 */) !== 0 || convertedLoopState !== undefined || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && isOrMayContainReturnCompletion(node)) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatement(node)) @@ -89247,74 +92687,74 @@ var ts; return shouldVisitNode(node) ? visitorWorker(node, /*expressionResultIsUnused*/ true) : node; } function callExpressionVisitor(node) { - if (node.kind === 105 /* SuperKeyword */) { + if (node.kind === 106 /* SuperKeyword */) { return visitSuperKeyword(/*isExpressionOfCall*/ true); } return visitor(node); } function visitorWorker(node, expressionResultIsUnused) { switch (node.kind) { - case 123 /* StaticKeyword */: + case 124 /* StaticKeyword */: return undefined; // elide static keyword - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: return visitClassDeclaration(node); - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: return visitClassExpression(node); - case 160 /* Parameter */: + case 162 /* Parameter */: return visitParameter(node); - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return visitArrowFunction(node); - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: return visitFunctionExpression(node); - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 78 /* Identifier */: + case 79 /* Identifier */: return visitIdentifier(node); - case 250 /* VariableDeclarationList */: + case 252 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: return visitSwitchStatement(node); - case 258 /* CaseBlock */: + case 260 /* CaseBlock */: return visitCaseBlock(node); - case 230 /* Block */: + case 232 /* Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 241 /* BreakStatement */: - case 240 /* ContinueStatement */: + case 243 /* BreakStatement */: + case 242 /* ContinueStatement */: return visitBreakOrContinueStatement(node); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return visitLabeledStatement(node); - case 235 /* DoStatement */: - case 236 /* WhileStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: return visitExpressionStatement(node); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return visitCatchClause(node); - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return visitCallExpression(node); - case 204 /* NewExpression */: + case 206 /* NewExpression */: return visitNewExpression(node); - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, expressionResultIsUnused); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return visitBinaryExpression(node, expressionResultIsUnused); - case 337 /* CommaListExpression */: + case 345 /* CommaListExpression */: return visitCommaListExpression(node, expressionResultIsUnused); case 14 /* NoSubstitutionTemplateLiteral */: case 15 /* TemplateHead */: @@ -89325,30 +92765,30 @@ var ts; return visitStringLiteral(node); case 8 /* NumericLiteral */: return visitNumericLiteral(node); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 218 /* TemplateExpression */: + case 220 /* TemplateExpression */: return visitTemplateExpression(node); - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: return visitYieldExpression(node); - case 220 /* SpreadElement */: + case 222 /* SpreadElement */: return visitSpreadElement(node); - case 105 /* SuperKeyword */: + case 106 /* SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: return visitThisKeyword(node); - case 226 /* MetaProperty */: + case 228 /* MetaProperty */: return visitMetaProperty(node); - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return visitAccessorDeclaration(node); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return visitVariableStatement(node); - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: return visitReturnStatement(node); - case 212 /* VoidExpression */: + case 214 /* VoidExpression */: return visitVoidExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -89438,14 +92878,14 @@ 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 === 241 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 243 /* BreakStatement */ ? 2 /* Break */ : 4 /* 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 === 241 /* BreakStatement */) { + if (node.kind === 243 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -89456,7 +92896,7 @@ var ts; } } else { - if (node.kind === 241 /* BreakStatement */) { + if (node.kind === 243 /* BreakStatement */) { labelMarker = "break-" + label.escapedText; setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } @@ -89716,7 +93156,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 !== 103 /* NullKeyword */; + var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */; // When the subclass does not have a constructor, we synthesize a *default* constructor using the following // representation: // @@ -89768,7 +93208,7 @@ var ts; factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment()); insertCaptureNewTargetIfNeeded(prologue, constructor, /*copyOnWrite*/ false); if (isDerivedClass) { - if (superCallExpression && statementOffset === constructor.body.statements.length && !(constructor.body.transformFlags & 4096 /* ContainsLexicalThis */)) { + if (superCallExpression && statementOffset === constructor.body.statements.length && !(constructor.body.transformFlags & 8192 /* ContainsLexicalThis */)) { // If the subclass constructor does *not* contain `this` and *ends* with a `super()` call, we will use the // following representation: // @@ -89854,11 +93294,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 242 /* ReturnStatement */) { + if (statement.kind === 244 /* ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 234 /* IfStatement */) { + else if (statement.kind === 236 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -89866,7 +93306,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 230 /* Block */) { + else if (statement.kind === 232 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -90024,10 +93464,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 === 78 /* Identifier */ ? ts.setParent(ts.setTextRange(factory.cloneNode(parameter.name), parameter.name), parameter.name.parent) : factory.createTempVariable(/*recordTempVariable*/ undefined); + 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 */); // `expressionName` is the name of the parameter used in expressions. - var expressionName = parameter.name.kind === 78 /* Identifier */ ? factory.cloneNode(parameter.name) : declarationName; + var expressionName = parameter.name.kind === 79 /* Identifier */ ? factory.cloneNode(parameter.name) : declarationName; var restIndex = node.parameters.length - 1; var temp = factory.createLoopVariable(); // var param = []; @@ -90052,7 +93492,7 @@ var ts; ts.setEmitFlags(forStatement, 1048576 /* CustomPrologue */); ts.startOnNewLine(forStatement); prologueStatements.push(forStatement); - if (parameter.name.kind !== 78 /* Identifier */) { + if (parameter.name.kind !== 79 /* 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 */)); @@ -90068,7 +93508,7 @@ var ts; * @param node A node. */ function insertCaptureThisForNodeIfNeeded(statements, node) { - if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 209 /* ArrowFunction */) { + if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 211 /* ArrowFunction */) { insertCaptureThisForNode(statements, node, factory.createThis()); return true; } @@ -90090,25 +93530,25 @@ var ts; if (hierarchyFacts & 16384 /* NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return statements; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: // Methods and accessors cannot be constructors, so 'new.target' will // always return 'undefined'. newTarget = factory.createVoidZero(); break; - case 166 /* Constructor */: + case 168 /* 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"); break; - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 210 /* 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 */), 101 /* InstanceOfKeyword */, factory.getLocalName(node))), + 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"), /*colonToken*/ undefined, factory.createVoidZero()); break; @@ -90140,20 +93580,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 229 /* SemicolonClassElement */: + case 231 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 166 /* Constructor */: + case 168 /* Constructor */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -90182,7 +93622,7 @@ var ts; var memberFunction = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined, container); var propertyName = ts.visitNode(member.name, visitor, ts.isPropertyName); var e; - if (!ts.isPrivateIdentifier(propertyName) && context.getCompilerOptions().useDefineForClassFields) { + if (!ts.isPrivateIdentifier(propertyName) && ts.getUseDefineForClassFields(context.getCompilerOptions())) { var name = ts.isComputedPropertyName(propertyName) ? propertyName.expression : ts.isIdentifier(propertyName) ? factory.createStringLiteral(ts.unescapeLeadingUnderscores(propertyName.escapedText)) : propertyName; @@ -90274,7 +93714,7 @@ var ts; * @param node An ArrowFunction node. */ function visitArrowFunction(node) { - if (node.transformFlags & 4096 /* ContainsLexicalThis */) { + if (node.transformFlags & 8192 /* ContainsLexicalThis */) { hierarchyFacts |= 32768 /* CapturedLexicalThis */; } var savedConvertedLoopState = convertedLoopState; @@ -90356,7 +93796,7 @@ var ts; : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 251 /* FunctionDeclaration */ || node.kind === 208 /* FunctionExpression */)) { + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 253 /* FunctionDeclaration */ || node.kind === 210 /* FunctionExpression */)) { name = factory.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */); @@ -90402,7 +93842,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 209 /* ArrowFunction */); + ts.Debug.assert(node.kind === 211 /* 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 @@ -90537,7 +93977,7 @@ var ts; assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0 /* All */); } else { - assignment = factory.createBinaryExpression(decl.name, 62 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + assignment = factory.createBinaryExpression(decl.name, 63 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); ts.setTextRange(assignment, decl); } assignments = ts.append(assignments, assignment); @@ -90563,7 +94003,7 @@ var ts; * @param node A VariableDeclarationList node. */ function visitVariableDeclarationList(node) { - if (node.flags & 3 /* BlockScoped */ || node.transformFlags & 131072 /* ContainsBindingPattern */) { + if (node.flags & 3 /* BlockScoped */ || node.transformFlags & 262144 /* ContainsBindingPattern */) { if (node.flags & 3 /* BlockScoped */) { enableSubstitutionsForBlockScopedBindings(); } @@ -90576,7 +94016,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 & 131072 /* ContainsBindingPattern */ + if (node.transformFlags & 262144 /* ContainsBindingPattern */ && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.last(node.declarations).name))) { ts.setSourceMapRange(declarationList, getRangeUnion(declarations)); } @@ -90588,8 +94028,8 @@ var ts; // declarations may not be sorted by position. // pos should be the minimum* position over all nodes (that's not -1), end should be the maximum end over all nodes. var pos = -1, end = -1; - for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) { - var node = declarations_10[_i]; + for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { + var node = declarations_9[_i]; pos = pos === -1 ? node.pos : node.pos === -1 ? pos : Math.min(pos, node.pos); end = Math.max(end, node.end); } @@ -90709,14 +94149,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 235 /* DoStatement */: - case 236 /* WhileStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -90900,9 +94340,9 @@ var ts; var numInitialProperties = -1, hasComputed = false; for (var i = 0; i < properties.length; i++) { var property = properties[i]; - if ((property.transformFlags & 262144 /* ContainsYield */ && + if ((property.transformFlags & 524288 /* ContainsYield */ && hierarchyFacts & 4 /* AsyncFunctionBody */) - || (hasComputed = ts.Debug.checkDefined(property.name).kind === 158 /* ComputedPropertyName */)) { + || (hasComputed = ts.Debug.checkDefined(property.name).kind === 160 /* ComputedPropertyName */)) { numInitialProperties = i; break; } @@ -90954,7 +94394,7 @@ var ts; } visit(node.name); function visit(node) { - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { state.hoistedLocalVariables.push(node); } else { @@ -91005,24 +94445,24 @@ var ts; loop = convert(node, outermostLabeledStatement, bodyFunction.part, ancestorFacts); } else { - var clone_3 = convertIterationStatementCore(node, initializerFunction, factory.createBlock(bodyFunction.part, /*multiLine*/ true)); - loop = factory.restoreEnclosingLabel(clone_3, outermostLabeledStatement, convertedLoopState && resetLabel); + var clone_4 = convertIterationStatementCore(node, initializerFunction, factory.createBlock(bodyFunction.part, /*multiLine*/ true)); + loop = factory.restoreEnclosingLabel(clone_4, outermostLabeledStatement, convertedLoopState && resetLabel); } } else { - var clone_4 = convertIterationStatementCore(node, initializerFunction, ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - loop = factory.restoreEnclosingLabel(clone_4, outermostLabeledStatement, convertedLoopState && resetLabel); + var clone_5 = convertIterationStatementCore(node, initializerFunction, ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock)); + loop = factory.restoreEnclosingLabel(clone_5, outermostLabeledStatement, convertedLoopState && resetLabel); } statements.push(loop); return statements; } function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) { switch (node.kind) { - case 237 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); - case 238 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); - case 239 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); - case 235 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); - case 236 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); + case 239 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); + case 240 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); + case 241 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); + case 237 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); + case 238 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected"); } } @@ -91047,11 +94487,11 @@ var ts; function createConvertedLoopState(node) { var loopInitializer; switch (node.kind) { - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 250 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 252 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -91171,7 +94611,7 @@ var ts; */ function createFunctionForInitializerOfForStatement(node, currentState) { var functionName = factory.createUniqueName("_loop_init"); - var containsYield = (node.initializer.transformFlags & 262144 /* ContainsYield */) !== 0; + var containsYield = (node.initializer.transformFlags & 524288 /* ContainsYield */) !== 0; var emitFlags = 0 /* None */; if (currentState.containsLexicalThis) emitFlags |= 8 /* CapturesThis */; @@ -91286,7 +94726,7 @@ var ts; var loopBody = factory.createBlock(statements, /*multiLine*/ true); if (ts.isBlock(statement)) ts.setOriginalNode(loopBody, statement); - var containsYield = (node.statement.transformFlags & 262144 /* ContainsYield */) !== 0; + var containsYield = (node.statement.transformFlags & 524288 /* ContainsYield */) !== 0; var emitFlags = 524288 /* ReuseTempVariableScope */; if (currentState.containsLexicalThis) emitFlags |= 8 /* CapturesThis */; @@ -91322,7 +94762,7 @@ var ts; 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, 62 /* EqualsToken */, source); + return factory.createBinaryExpression(target, 63 /* EqualsToken */, source); } function copyOutParameters(outParams, partFlags, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { @@ -91459,20 +94899,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -91579,7 +95019,7 @@ var ts; var updated; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (node.kind === 167 /* GetAccessor */) { + if (node.kind === 169 /* GetAccessor */) { updated = factory.updateGetAccessorDeclaration(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); } else { @@ -91632,7 +95072,7 @@ var ts; return visitTypeScriptClassWrapper(node); } var expression = ts.skipOuterExpressions(node.expression); - if (expression.kind === 105 /* SuperKeyword */ || + if (expression.kind === 106 /* SuperKeyword */ || ts.isSuperProperty(expression) || ts.some(node.arguments, ts.isSpreadElement)) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); @@ -91759,15 +95199,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 & 8192 /* ContainsRestOrSpread */ || - node.expression.kind === 105 /* SuperKeyword */ || + if (node.transformFlags & 16384 /* ContainsRestOrSpread */ || + node.expression.kind === 106 /* SuperKeyword */ || ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) { var _a = factory.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { ts.setEmitFlags(thisArg, 4 /* NoSubstitution */); } var resultingCall = void 0; - if (node.transformFlags & 8192 /* ContainsRestOrSpread */) { + if (node.transformFlags & 16384 /* ContainsRestOrSpread */) { // [source] // f(...a, b) // x.m(...a, b) @@ -91781,7 +95221,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 === 105 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); + resultingCall = factory.createFunctionApplyCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); } else { // [source] @@ -91793,9 +95233,9 @@ 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 === 105 /* 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 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression)), node); } - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { var initializer = factory.createLogicalOr(resultingCall, createActualThis()); resultingCall = assignToCapturedThis ? factory.createAssignment(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), initializer) @@ -92042,7 +95482,7 @@ var ts; : factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */); } function visitMetaProperty(node) { - if (node.keywordToken === 102 /* NewKeyword */ && node.name.escapedText === "target") { + if (node.keywordToken === 103 /* NewKeyword */ && node.name.escapedText === "target") { hierarchyFacts |= 16384 /* NewTarget */; return factory.createUniqueName("_newTarget", 16 /* Optimistic */ | 32 /* FileLevel */); } @@ -92074,7 +95514,7 @@ var ts; function enableSubstitutionsForBlockScopedBindings() { if ((enabledSubstitutions & 2 /* BlockScopedBindings */) === 0) { enabledSubstitutions |= 2 /* BlockScopedBindings */; - context.enableSubstitution(78 /* Identifier */); + context.enableSubstitution(79 /* Identifier */); } } /** @@ -92084,14 +95524,14 @@ var ts; function enableSubstitutionsForCapturedThis() { if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { enabledSubstitutions |= 1 /* CapturedThis */; - context.enableSubstitution(107 /* ThisKeyword */); - context.enableEmitNotification(166 /* Constructor */); - context.enableEmitNotification(165 /* MethodDeclaration */); - context.enableEmitNotification(167 /* GetAccessor */); - context.enableEmitNotification(168 /* SetAccessor */); - context.enableEmitNotification(209 /* ArrowFunction */); - context.enableEmitNotification(208 /* FunctionExpression */); - context.enableEmitNotification(251 /* FunctionDeclaration */); + context.enableSubstitution(108 /* ThisKeyword */); + context.enableEmitNotification(168 /* Constructor */); + context.enableEmitNotification(167 /* MethodDeclaration */); + context.enableEmitNotification(169 /* GetAccessor */); + context.enableEmitNotification(170 /* SetAccessor */); + context.enableEmitNotification(211 /* ArrowFunction */); + context.enableEmitNotification(210 /* FunctionExpression */); + context.enableEmitNotification(253 /* FunctionDeclaration */); } } /** @@ -92132,10 +95572,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 198 /* BindingElement */: - case 252 /* ClassDeclaration */: - case 255 /* EnumDeclaration */: - case 249 /* VariableDeclaration */: + case 200 /* BindingElement */: + case 254 /* ClassDeclaration */: + case 257 /* EnumDeclaration */: + case 251 /* VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -92148,9 +95588,9 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return substituteExpressionIdentifier(node); - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: return substituteThisKeyword(node); } return node; @@ -92217,19 +95657,19 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 233 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 235 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 203 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 205 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 105 /* SuperKeyword */) { + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 106 /* SuperKeyword */) { return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 220 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 222 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -92255,15 +95695,15 @@ var ts; if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(275 /* JsxOpeningElement */); - context.enableEmitNotification(276 /* JsxClosingElement */); - context.enableEmitNotification(274 /* JsxSelfClosingElement */); + context.enableEmitNotification(277 /* JsxOpeningElement */); + context.enableEmitNotification(278 /* JsxClosingElement */); + context.enableEmitNotification(276 /* JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(201 /* PropertyAccessExpression */); - context.enableSubstitution(288 /* PropertyAssignment */); + context.enableSubstitution(203 /* PropertyAccessExpression */); + context.enableSubstitution(290 /* PropertyAssignment */); return ts.chainBundle(context, transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -92282,9 +95722,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 275 /* JsxOpeningElement */: - case 276 /* JsxClosingElement */: - case 274 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: + case 278 /* JsxClosingElement */: + case 276 /* JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -92344,7 +95784,7 @@ var ts; */ function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined); - if (token !== undefined && token >= 80 /* FirstReservedWord */ && token <= 115 /* LastReservedWord */) { + if (token !== undefined && token >= 81 /* FirstReservedWord */ && token <= 116 /* LastReservedWord */) { return ts.setTextRange(factory.createStringLiteralFromNode(name), name); } return undefined; @@ -92582,7 +96022,7 @@ var ts; var withBlockStack; // A stack containing `with` blocks. return ts.chainBundle(context, transformSourceFile); function transformSourceFile(node) { - if (node.isDeclarationFile || (node.transformFlags & 512 /* ContainsGenerator */) === 0) { + if (node.isDeclarationFile || (node.transformFlags & 1024 /* ContainsGenerator */) === 0) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -92605,7 +96045,7 @@ var ts; else if (ts.isFunctionLikeDeclaration(node) && node.asteriskToken) { return visitGenerator(node); } - else if (transformFlags & 512 /* ContainsGenerator */) { + else if (transformFlags & 1024 /* ContainsGenerator */) { return ts.visitEachChild(node, visitor, context); } else { @@ -92619,13 +96059,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 235 /* DoStatement */: + case 237 /* DoStatement */: return visitDoStatement(node); - case 236 /* WhileStatement */: + case 238 /* WhileStatement */: return visitWhileStatement(node); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: return visitSwitchStatement(node); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -92638,30 +96078,30 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: return visitFunctionExpression(node); - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return visitAccessorDeclaration(node); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return visitVariableStatement(node); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return visitForStatement(node); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return visitForInStatement(node); - case 241 /* BreakStatement */: + case 243 /* BreakStatement */: return visitBreakStatement(node); - case 240 /* ContinueStatement */: + case 242 /* ContinueStatement */: return visitContinueStatement(node); - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: return visitReturnStatement(node); default: - if (node.transformFlags & 262144 /* ContainsYield */) { + if (node.transformFlags & 524288 /* ContainsYield */) { return visitJavaScriptContainingYield(node); } - else if (node.transformFlags & (512 /* ContainsGenerator */ | 1048576 /* ContainsHoistedDeclarationOrCompletion */)) { + else if (node.transformFlags & (1024 /* ContainsGenerator */ | 2097152 /* ContainsHoistedDeclarationOrCompletion */)) { return ts.visitEachChild(node, visitor, context); } else { @@ -92676,23 +96116,23 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return visitBinaryExpression(node); - case 337 /* CommaListExpression */: + case 345 /* CommaListExpression */: return visitCommaListExpression(node); - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: return visitConditionalExpression(node); - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: return visitYieldExpression(node); - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return visitCallExpression(node); - case 204 /* NewExpression */: + case 206 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -92705,9 +96145,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -92866,7 +96306,7 @@ var ts; * @param node The node to visit. */ function visitVariableStatement(node) { - if (node.transformFlags & 262144 /* ContainsYield */) { + if (node.transformFlags & 524288 /* ContainsYield */) { transformAndEmitVariableDeclarationList(node.declarationList); return undefined; } @@ -92915,7 +96355,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -92927,7 +96367,7 @@ var ts; // _a.b = %sent%; target = factory.updatePropertyAccessExpression(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -93321,35 +96761,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 230 /* Block */: + case 232 /* Block */: return transformAndEmitBlock(node); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 234 /* IfStatement */: + case 236 /* IfStatement */: return transformAndEmitIfStatement(node); - case 235 /* DoStatement */: + case 237 /* DoStatement */: return transformAndEmitDoStatement(node); - case 236 /* WhileStatement */: + case 238 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return transformAndEmitForStatement(node); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 240 /* ContinueStatement */: + case 242 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 241 /* BreakStatement */: + case 243 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 243 /* WithStatement */: + case 245 /* WithStatement */: return transformAndEmitWithStatement(node); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 246 /* ThrowStatement */: + case 248 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 247 /* TryStatement */: + case 249 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -93569,7 +97009,7 @@ var ts; var variables = ts.getInitializedVariables(initializer); node = factory.updateForStatement(node, variables.length > 0 ? factory.inlineExpressions(ts.map(variables, transformInitializedVariable)) - : undefined, ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitor, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock)); + : undefined, ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitor, ts.isExpression), ts.visitIterationBody(node.statement, visitor, context)); } else { node = ts.visitEachChild(node, visitor, context); @@ -93779,7 +97219,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 285 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 287 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -93792,7 +97232,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 284 /* CaseClause */) { + if (clause.kind === 286 /* CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -93924,7 +97364,7 @@ var ts; } } function containsYield(node) { - return !!node && (node.transformFlags & 262144 /* ContainsYield */) !== 0; + return !!node && (node.transformFlags & 524288 /* ContainsYield */) !== 0; } function countInitialNodesWithoutYield(nodes) { var numNodes = nodes.length; @@ -93957,10 +97397,10 @@ var ts; var name = renamedCatchVariableDeclarations[ts.getOriginalNodeId(declaration)]; if (name) { // TODO(rbuckton): Does this need to be parented? - var clone_5 = ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent); - ts.setSourceMapRange(clone_5, node); - ts.setCommentRange(clone_5, node); - return clone_5; + var clone_6 = ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent); + ts.setSourceMapRange(clone_6, node); + ts.setCommentRange(clone_6, node); + return clone_6; } } } @@ -94106,7 +97546,7 @@ var ts; if (!renamedCatchVariables) { renamedCatchVariables = new ts.Map(); renamedCatchVariableDeclarations = []; - context.enableSubstitution(78 /* Identifier */); + context.enableSubstitution(79 /* Identifier */); } renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; @@ -94952,12 +98392,12 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(78 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(216 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(214 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(215 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(289 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(297 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(79 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. + context.enableSubstitution(218 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(216 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(217 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(291 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(299 /* 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. @@ -94973,7 +98413,7 @@ var ts; function transformSourceFile(node) { if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || - node.transformFlags & 2097152 /* ContainsDynamicImport */ || + node.transformFlags & 4194304 /* ContainsDynamicImport */ || (ts.isJsonSourceFile(node) && ts.hasJsonModuleEmitEnabled(compilerOptions) && ts.outFile(compilerOptions)))) { return node; } @@ -95285,23 +98725,23 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return visitImportDeclaration(node); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: return visitExportDeclaration(node); - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return visitExportAssignment(node); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return visitVariableStatement(node); - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: return visitClassDeclaration(node); - case 338 /* MergeDeclarationMarker */: + case 346 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 339 /* EndOfDeclarationMarker */: + case 347 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -95310,7 +98750,7 @@ var ts; function moduleExpressionElementVisitor(node) { // This visitor does not need to descend into the tree if there is no dynamic import or destructuring assignment, // as export/import statements are only transformed at the top level of a file. - if (!(node.transformFlags & 2097152 /* ContainsDynamicImport */) && !(node.transformFlags & 1024 /* ContainsDestructuringAssignment */)) { + if (!(node.transformFlags & 4194304 /* ContainsDynamicImport */) && !(node.transformFlags & 2048 /* ContainsDestructuringAssignment */)) { return node; } if (ts.isImportCall(node)) { @@ -95328,24 +98768,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 290 /* SpreadAssignment */: + case 292 /* SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -95380,7 +98820,7 @@ var ts; var firstArgument = ts.visitNode(ts.firstOrUndefined(node.arguments), moduleExpressionElementVisitor); // 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 & 4096 /* ContainsLexicalThis */); + var containsLexicalThis = !!(node.transformFlags & 8192 /* ContainsLexicalThis */); switch (compilerOptions.module) { case ts.ModuleKind.AMD: return createImportCallExpressionAMD(argument, containsLexicalThis); @@ -95873,7 +99313,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 232 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 234 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -95928,10 +99368,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 264 /* NamedImports */: + case 266 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding, /* liveBinding */ true); @@ -96127,8 +99567,8 @@ var ts; function modifierVisitor(node) { // Elide module-specific modifiers. switch (node.kind) { - case 92 /* ExportKeyword */: - case 87 /* DefaultKeyword */: + case 93 /* ExportKeyword */: + case 88 /* DefaultKeyword */: return undefined; } return node; @@ -96144,7 +99584,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 297 /* SourceFile */) { + if (node.kind === 299 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -96206,12 +99646,12 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return substituteExpressionIdentifier(node); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return substituteBinaryExpression(node); - case 215 /* PostfixUnaryExpression */: - case 214 /* PrefixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -96231,9 +99671,9 @@ var ts; } return node; } - if (!(ts.isGeneratedIdentifier(node) && !(node.autoGenerateFlags & 64 /* AllowNameSubstitution */)) && !ts.isLocalName(node)) { + else if (!(ts.isGeneratedIdentifier(node) && !(node.autoGenerateFlags & 64 /* AllowNameSubstitution */)) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 297 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 299 /* SourceFile */) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.cloneNode(node)), /*location*/ node); } @@ -96308,8 +99748,8 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 215 /* PostfixUnaryExpression */ - ? ts.setTextRange(factory.createBinaryExpression(node.operand, factory.createToken(node.operator === 45 /* PlusPlusToken */ ? 63 /* PlusEqualsToken */ : 64 /* MinusEqualsToken */), factory.createNumericLiteral(1)), + var expression = node.kind === 217 /* PostfixUnaryExpression */ + ? ts.setTextRange(factory.createPrefixUnaryExpression(node.operator, node.operand), /*location*/ node) : node; for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) { @@ -96318,6 +99758,12 @@ var ts; noSubstitution[ts.getNodeId(expression)] = true; expression = createExportExpression(exportName, expression); } + if (node.kind === 217 /* PostfixUnaryExpression */) { + noSubstitution[ts.getNodeId(expression)] = true; + expression = node.operator === 45 /* PlusPlusToken */ + ? factory.createSubtract(expression, factory.createNumericLiteral(1)) + : factory.createAdd(expression, factory.createNumericLiteral(1)); + } return expression; } } @@ -96359,13 +99805,13 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(78 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(289 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols - context.enableSubstitution(216 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(214 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(215 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(226 /* MetaProperty */); // Substitutes 'import.meta' - context.enableEmitNotification(297 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(79 /* Identifier */); // Substitutes expression identifiers for imported symbols. + context.enableSubstitution(291 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(218 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(216 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(217 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(228 /* MetaProperty */); // Substitutes 'import.meta' + context.enableEmitNotification(299 /* 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. @@ -96385,7 +99831,7 @@ var ts; * @param node The SourceFile node. */ function transformSourceFile(node) { - if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 2097152 /* ContainsDynamicImport */)) { + if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 4194304 /* ContainsDynamicImport */)) { return node; } var id = ts.getOriginalNodeId(node); @@ -96554,7 +100000,7 @@ 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 & 524288 /* ContainsAwait */ ? + var modifiers = node.transformFlags & 1048576 /* ContainsAwait */ ? factory.createModifiersFromModifierFlags(256 /* Async */) : undefined; var moduleObject = factory.createObjectLiteralExpression([ @@ -96589,7 +100035,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 267 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 269 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -96679,19 +100125,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(factory, entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(factory.createExpressionStatement(factory.createAssignment(importVariableName, parameterName))); break; - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { if (ts.isNamedExports(entry.exportClause)) { @@ -96750,13 +100196,13 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return visitImportDeclaration(node); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: return visitExportDeclaration(node); - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -96936,7 +100382,7 @@ 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 === 297 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 299 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -97000,7 +100446,7 @@ 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 === 232 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 234 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasSyntacticModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -97062,10 +100508,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 264 /* NamedImports */: + case 266 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -97245,43 +100691,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return visitVariableStatement(node); - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: return visitClassDeclaration(node); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return visitForStatement(node); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return visitForInStatement(node); - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: return visitForOfStatement(node); - case 235 /* DoStatement */: + case 237 /* DoStatement */: return visitDoStatement(node); - case 236 /* WhileStatement */: + case 238 /* WhileStatement */: return visitWhileStatement(node); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return visitLabeledStatement(node); - case 243 /* WithStatement */: + case 245 /* WithStatement */: return visitWithStatement(node); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: return visitSwitchStatement(node); - case 258 /* CaseBlock */: + case 260 /* CaseBlock */: return visitCaseBlock(node); - case 284 /* CaseClause */: + case 286 /* CaseClause */: return visitCaseClause(node); - case 285 /* DefaultClause */: + case 287 /* DefaultClause */: return visitDefaultClause(node); - case 247 /* TryStatement */: + case 249 /* TryStatement */: return visitTryStatement(node); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return visitCatchClause(node); - case 230 /* Block */: + case 232 /* Block */: return visitBlock(node); - case 338 /* MergeDeclarationMarker */: + case 346 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 339 /* EndOfDeclarationMarker */: + case 347 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -97295,7 +100741,7 @@ var ts; function visitForStatement(node) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = factory.updateForStatement(node, node.initializer && visitForInitializer(node.initializer), ts.visitNode(node.condition, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.incrementor, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement)); + node = factory.updateForStatement(node, node.initializer && visitForInitializer(node.initializer), ts.visitNode(node.condition, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.incrementor, destructuringAndImportCallVisitor, ts.isExpression), ts.visitIterationBody(node.statement, nestedElementVisitor, context)); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } @@ -97307,7 +100753,7 @@ var ts; function visitForInStatement(node) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = factory.updateForInStatement(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock)); + node = factory.updateForInStatement(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitIterationBody(node.statement, nestedElementVisitor, context)); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } @@ -97319,7 +100765,7 @@ var ts; function visitForOfStatement(node) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = factory.updateForOfStatement(node, node.awaitModifier, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock)); + node = factory.updateForOfStatement(node, node.awaitModifier, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitIterationBody(node.statement, nestedElementVisitor, context)); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } @@ -97360,7 +100806,7 @@ var ts; * @param node The node to visit. */ function visitDoStatement(node) { - return factory.updateDoStatement(node, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression)); + return factory.updateDoStatement(node, ts.visitIterationBody(node.statement, nestedElementVisitor, context), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression)); } /** * Visits the body of a WhileStatement to hoist declarations. @@ -97368,7 +100814,7 @@ var ts; * @param node The node to visit. */ function visitWhileStatement(node) { - return factory.updateWhileStatement(node, ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock)); + return factory.updateWhileStatement(node, ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitIterationBody(node.statement, nestedElementVisitor, context)); } /** * Visits the body of a LabeledStatement to hoist declarations. @@ -97469,7 +100915,7 @@ var ts; else if (ts.isImportCall(node)) { return visitImportCallExpression(node); } - else if ((node.transformFlags & 1024 /* ContainsDestructuringAssignment */) || (node.transformFlags & 2097152 /* ContainsDynamicImport */)) { + else if ((node.transformFlags & 2048 /* ContainsDestructuringAssignment */) || (node.transformFlags & 4194304 /* ContainsDynamicImport */)) { return ts.visitEachChild(node, destructuringAndImportCallVisitor, context); } else { @@ -97507,7 +100953,7 @@ var ts; return ts.visitEachChild(node, destructuringAndImportCallVisitor, context); } /** - * Determines whether the target of a destructuring assigment refers to an exported symbol. + * Determines whether the target of a destructuring assignment refers to an exported symbol. * * @param node The destructuring target. */ @@ -97532,7 +100978,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 297 /* SourceFile */; + return container !== undefined && container.kind === 299 /* SourceFile */; } else { return false; @@ -97548,8 +100994,8 @@ var ts; */ function modifierVisitor(node) { switch (node.kind) { - case 92 /* ExportKeyword */: - case 87 /* DefaultKeyword */: + case 93 /* ExportKeyword */: + case 88 /* DefaultKeyword */: return undefined; } return node; @@ -97565,7 +101011,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 297 /* SourceFile */) { + if (node.kind === 299 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -97615,7 +101061,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -97650,14 +101096,14 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return substituteExpressionIdentifier(node); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return substituteBinaryExpression(node); - case 214 /* PrefixUnaryExpression */: - case 215 /* PostfixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: return substituteUnaryExpression(node); - case 226 /* MetaProperty */: + case 228 /* MetaProperty */: return substituteMetaProperty(node); } return node; @@ -97751,14 +101197,14 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 215 /* PostfixUnaryExpression */ + var expression = node.kind === 217 /* PostfixUnaryExpression */ ? ts.setTextRange(factory.createPrefixUnaryExpression(node.operator, node.operand), node) : node; for (var _i = 0, exportedNames_5 = exportedNames; _i < exportedNames_5.length; _i++) { var exportName = exportedNames_5[_i]; expression = createExportExpression(exportName, preventSubstitution(expression)); } - if (node.kind === 215 /* PostfixUnaryExpression */) { + if (node.kind === 217 /* PostfixUnaryExpression */) { expression = node.operator === 45 /* PlusPlusToken */ ? factory.createSubtract(preventSubstitution(expression), factory.createNumericLiteral(1)) : factory.createAdd(preventSubstitution(expression), factory.createNumericLiteral(1)); @@ -97786,7 +101232,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 297 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 299 /* SourceFile */) { exportedNames = ts.append(exportedNames, factory.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -97826,8 +101272,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(297 /* SourceFile */); - context.enableSubstitution(78 /* Identifier */); + context.enableEmitNotification(299 /* SourceFile */); + context.enableSubstitution(79 /* Identifier */); var helperNameSubstitutions; return ts.chainBundle(context, transformSourceFile); function transformSourceFile(node) { @@ -97858,12 +101304,12 @@ var ts; } function visitor(node) { switch (node.kind) { - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: // Elide `import=` as it is not legal with --module ES6 return undefined; - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return visitExportAssignment(node); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: var exportDecl = node; return visitExportDeclaration(exportDecl); } @@ -97968,7 +101414,8 @@ var ts; ts.isTypeAliasDeclaration(node) || ts.isConstructorDeclaration(node) || ts.isIndexSignatureDeclaration(node) || - ts.isPropertyAccessExpression(node); + ts.isPropertyAccessExpression(node) || + ts.isJSDocTypeAlias(node); } ts.canProduceDiagnostics = canProduceDiagnostics; function createGetSymbolAccessibilityDiagnosticForNodeName(node) { @@ -97997,7 +101444,7 @@ var ts; 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 === 252 /* ClassDeclaration */) { + else if (node.parent.kind === 254 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -98026,7 +101473,7 @@ var ts; 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 === 252 /* ClassDeclaration */) { + else if (node.parent.kind === 254 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -98066,14 +101513,14 @@ var ts; else if (ts.isImportEqualsDeclaration(node)) { return getImportEntityNameVisibilityError; } - else if (ts.isTypeAliasDeclaration(node)) { + else if (ts.isTypeAliasDeclaration(node) || ts.isJSDocTypeAlias(node)) { return getTypeAliasDeclarationVisibilityError; } else { return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]); } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 249 /* VariableDeclaration */ || node.kind === 198 /* BindingElement */) { + if (node.kind === 251 /* VariableDeclaration */ || node.kind === 200 /* BindingElement */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -98082,8 +101529,8 @@ var ts; } // 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 === 163 /* PropertyDeclaration */ || node.kind === 201 /* PropertyAccessExpression */ || node.kind === 162 /* PropertySignature */ || - (node.kind === 160 /* Parameter */ && ts.hasSyntacticModifier(node.parent, 8 /* Private */))) { + else if (node.kind === 165 /* PropertyDeclaration */ || node.kind === 203 /* PropertyAccessExpression */ || node.kind === 164 /* PropertySignature */ || + (node.kind === 162 /* Parameter */ && ts.hasSyntacticModifier(node.parent, 8 /* Private */))) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.hasSyntacticModifier(node, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? @@ -98092,7 +101539,7 @@ var ts; 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 === 252 /* ClassDeclaration */ || node.kind === 160 /* Parameter */) { + else if (node.parent.kind === 254 /* ClassDeclaration */ || node.kind === 162 /* Parameter */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -98117,7 +101564,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 168 /* SetAccessor */) { + if (node.kind === 170 /* 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.hasSyntacticModifier(node, 32 /* Static */)) { @@ -98156,26 +101603,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 170 /* ConstructSignature */: + case 172 /* 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 169 /* CallSignature */: + case 171 /* 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 171 /* IndexSignature */: + case 173 /* 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 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: if (ts.hasSyntacticModifier(node, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -98183,7 +101630,7 @@ var ts; 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 === 252 /* ClassDeclaration */) { + else if (node.parent.kind === 254 /* ClassDeclaration */) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* 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 : @@ -98197,7 +101644,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -98222,30 +101669,30 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 166 /* Constructor */: + case 168 /* Constructor */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* 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 170 /* ConstructSignature */: - case 175 /* ConstructorType */: + case 172 /* ConstructSignature */: + case 177 /* 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 169 /* CallSignature */: + case 171 /* 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 171 /* IndexSignature */: + case 173 /* 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 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: if (ts.hasSyntacticModifier(node.parent, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -98253,7 +101700,7 @@ var ts; 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 === 252 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 254 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* 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 : @@ -98266,15 +101713,15 @@ 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 251 /* FunctionDeclaration */: - case 174 /* FunctionType */: + case 253 /* FunctionDeclaration */: + case 176 /* FunctionType */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* 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 168 /* SetAccessor */: - case 167 /* GetAccessor */: + case 170 /* SetAccessor */: + case 169 /* GetAccessor */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -98288,39 +101735,39 @@ var ts; // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 253 /* InterfaceDeclaration */: + case 255 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 190 /* MappedType */: + case 192 /* MappedType */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1; break; - case 175 /* ConstructorType */: - case 170 /* ConstructSignature */: + case 177 /* ConstructorType */: + case 172 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 169 /* CallSignature */: + case 171 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: if (ts.hasSyntacticModifier(node.parent, 32 /* Static */)) { 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 === 252 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 254 /* 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 174 /* FunctionType */: - case 251 /* FunctionDeclaration */: + case 176 /* FunctionType */: + case 253 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -98337,7 +101784,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 === 116 /* ImplementsKeyword */ ? + diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 117 /* 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; @@ -98359,11 +101806,13 @@ var ts; typeName: node.name }; } - function getTypeAliasDeclarationVisibilityError() { + function getTypeAliasDeclarationVisibilityError(symbolAccessibilityResult) { return { - diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, - errorNode: node.type, - typeName: node.name + diagnosticMessage: symbolAccessibilityResult.errorModuleName + ? ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1_from_module_2 + : ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, + errorNode: ts.isJSDocTypeAlias(node) ? ts.Debug.checkDefined(node.typeExpression) : node.type, + typeName: ts.isJSDocTypeAlias(node) ? ts.getNameOfDeclaration(node) : node.name, }; } } @@ -98384,7 +101833,7 @@ var ts; } function isInternalDeclaration(node, currentSourceFile) { var parseTreeNode = ts.getParseTreeNode(node); - if (parseTreeNode && parseTreeNode.kind === 160 /* Parameter */) { + if (parseTreeNode && parseTreeNode.kind === 162 /* Parameter */) { var paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode); var previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : undefined; var text = currentSourceFile.text; @@ -98446,6 +101895,7 @@ var ts; reportNonlocalAugmentation: reportNonlocalAugmentation }; var errorNameNode; + var errorFallbackNode; var currentSourceFile; var refs; var libs; @@ -98500,8 +101950,10 @@ var ts; else { context.addDiagnostic(ts.createDiagnosticForNode(symbolAccessibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, symbolAccessibilityResult.errorSymbolName, symbolAccessibilityResult.errorModuleName)); } + return true; } } + return false; } function trackExternalModuleSymbolOfImportTypeNode(symbol) { if (!isBundledEmit) { @@ -98510,13 +101962,14 @@ var ts; } function trackSymbol(symbol, enclosingDeclaration, meaning) { if (symbol.flags & 262144 /* TypeParameter */) - return; - handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, /*shouldComputeAliasesToMakeVisible*/ true)); + return false; + var issuedDiagnostic = handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, /*shouldComputeAliasesToMakeVisible*/ true)); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForSymbol(symbol, meaning)); + return issuedDiagnostic; } function reportPrivateInBaseOfClassExpression(propertyName) { - if (errorNameNode) { - context.addDiagnostic(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.Property_0_of_exported_class_expression_may_not_be_private_or_protected, propertyName)); + if (errorNameNode || errorFallbackNode) { + context.addDiagnostic(ts.createDiagnosticForNode((errorNameNode || errorFallbackNode), ts.Diagnostics.Property_0_of_exported_class_expression_may_not_be_private_or_protected, propertyName)); } } function reportInaccessibleUniqueSymbolError() { @@ -98540,35 +101993,38 @@ var ts; } } function reportTruncationError() { - if (errorNameNode) { - context.addDiagnostic(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_this_node_exceeds_the_maximum_length_the_compiler_will_serialize_An_explicit_type_annotation_is_needed)); + if (errorNameNode || errorFallbackNode) { + context.addDiagnostic(ts.createDiagnosticForNode((errorNameNode || errorFallbackNode), ts.Diagnostics.The_inferred_type_of_this_node_exceeds_the_maximum_length_the_compiler_will_serialize_An_explicit_type_annotation_is_needed)); } } function reportNonlocalAugmentation(containingFile, parentSymbol, symbol) { - var primaryDeclaration = ts.find(parentSymbol.declarations, function (d) { return ts.getSourceFileOfNode(d) === containingFile; }); + var _a; + var primaryDeclaration = (_a = parentSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.getSourceFileOfNode(d) === containingFile; }); var augmentingDeclarations = ts.filter(symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== containingFile; }); - for (var _i = 0, augmentingDeclarations_1 = augmentingDeclarations; _i < augmentingDeclarations_1.length; _i++) { - var augmentations = augmentingDeclarations_1[_i]; - context.addDiagnostic(ts.addRelatedInfo(ts.createDiagnosticForNode(augmentations, ts.Diagnostics.Declaration_augments_declaration_in_another_file_This_cannot_be_serialized), ts.createDiagnosticForNode(primaryDeclaration, ts.Diagnostics.This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_file))); + if (augmentingDeclarations) { + for (var _i = 0, augmentingDeclarations_1 = augmentingDeclarations; _i < augmentingDeclarations_1.length; _i++) { + var augmentations = augmentingDeclarations_1[_i]; + context.addDiagnostic(ts.addRelatedInfo(ts.createDiagnosticForNode(augmentations, ts.Diagnostics.Declaration_augments_declaration_in_another_file_This_cannot_be_serialized), ts.createDiagnosticForNode(primaryDeclaration, ts.Diagnostics.This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_file))); + } } } function transformDeclarationsForJS(sourceFile, bundled) { var oldDiag = getSymbolAccessibilityDiagnostic; - getSymbolAccessibilityDiagnostic = function (s) { return ({ + getSymbolAccessibilityDiagnostic = function (s) { return (s.errorNode && ts.canProduceDiagnostics(s.errorNode) ? ts.createGetSymbolAccessibilityDiagnosticForNode(s.errorNode)(s) : ({ diagnosticMessage: s.errorModuleName ? ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit : ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit, errorNode: s.errorNode || sourceFile - }); }; + })); }; var result = resolver.getDeclarationStatementsForSourceFile(sourceFile, declarationEmitNodeBuilderFlags, symbolTracker, bundled); getSymbolAccessibilityDiagnostic = oldDiag; return result; } function transformRoot(node) { - if (node.kind === 297 /* SourceFile */ && node.isDeclarationFile) { + if (node.kind === 299 /* SourceFile */ && node.isDeclarationFile) { return node; } - if (node.kind === 298 /* Bundle */) { + if (node.kind === 300 /* Bundle */) { isBundledEmit = true; refs = new ts.Map(); libs = new ts.Map(); @@ -98591,14 +102047,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(133 /* 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(134 /* 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 === 300 /* InputFiles */) { + if (prepend.kind === 302 /* InputFiles */) { var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal); hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib; collectReferences(sourceFile, refs); @@ -98690,7 +102146,7 @@ var ts; declFileName = paths.declarationFilePath || paths.jsFilePath || file.fileName; } if (declFileName) { - var specifier = ts.moduleSpecifiers.getModuleSpecifier(__assign(__assign({}, options), { baseUrl: options.baseUrl && ts.toPath(options.baseUrl, host.getCurrentDirectory(), host.getCanonicalFileName) }), currentSourceFile, ts.toPath(outputFilePath, host.getCurrentDirectory(), host.getCanonicalFileName), ts.toPath(declFileName, host.getCurrentDirectory(), host.getCanonicalFileName), host, + var specifier = ts.moduleSpecifiers.getModuleSpecifier(options, currentSourceFile, ts.toPath(outputFilePath, host.getCurrentDirectory(), host.getCanonicalFileName), ts.toPath(declFileName, host.getCurrentDirectory(), host.getCanonicalFileName), host, /*preferences*/ undefined); if (!ts.pathIsRelative(specifier)) { // If some compiler option/symlink/whatever allows access to the file containing the ambient module declaration @@ -98735,11 +102191,11 @@ var ts; return ret; } function filterBindingPatternInitializers(name) { - if (name.kind === 78 /* Identifier */) { + if (name.kind === 79 /* Identifier */) { return name; } else { - if (name.kind === 197 /* ArrayBindingPattern */) { + if (name.kind === 199 /* ArrayBindingPattern */) { return factory.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -98747,7 +102203,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 222 /* OmittedExpression */) { + if (elem.kind === 224 /* OmittedExpression */) { return elem; } return factory.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); @@ -98785,19 +102241,19 @@ var ts; // Literal const declarations will have an initializer ensured rather than a type return; } - var shouldUseResolverType = node.kind === 160 /* Parameter */ && + var shouldUseResolverType = node.kind === 162 /* 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(128 /* AnyKeyword */); + return type ? ts.visitNode(type, visitDeclarationSubtree) : factory.createKeywordTypeNode(129 /* AnyKeyword */); } - if (node.kind === 168 /* SetAccessor */) { + if (node.kind === 170 /* 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(128 /* AnyKeyword */); + return factory.createKeywordTypeNode(129 /* AnyKeyword */); } errorNameNode = node.name; var oldDiag; @@ -98805,12 +102261,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 249 /* VariableDeclaration */ || node.kind === 198 /* BindingElement */) { + if (node.kind === 251 /* VariableDeclaration */ || node.kind === 200 /* BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 160 /* Parameter */ - || node.kind === 163 /* PropertyDeclaration */ - || node.kind === 162 /* PropertySignature */) { + if (node.kind === 162 /* Parameter */ + || node.kind === 165 /* PropertyDeclaration */ + || node.kind === 164 /* PropertySignature */) { if (!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)); @@ -98821,30 +102277,39 @@ var ts; if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } - return returnValue || factory.createKeywordTypeNode(128 /* AnyKeyword */); + return returnValue || factory.createKeywordTypeNode(129 /* AnyKeyword */); } } function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 256 /* ModuleDeclaration */: - case 253 /* InterfaceDeclaration */: - case 252 /* ClassDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 255 /* EnumDeclaration */: + case 253 /* FunctionDeclaration */: + case 258 /* ModuleDeclaration */: + case 255 /* InterfaceDeclaration */: + case 254 /* ClassDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 257 /* EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return !getBindingNameVisible(node); - case 260 /* ImportEqualsDeclaration */: - case 261 /* ImportDeclaration */: - case 267 /* ExportDeclaration */: - case 266 /* ExportAssignment */: + case 262 /* ImportEqualsDeclaration */: + case 263 /* ImportDeclaration */: + case 269 /* ExportDeclaration */: + case 268 /* ExportAssignment */: return false; } return false; } + // If the ExpandoFunctionDeclaration have multiple overloads, then we only need to emit properties for the last one. + function shouldEmitFunctionProperties(input) { + var _a; + if (input.body) { + return true; + } + var overloadSignatures = (_a = input.symbol.declarations) === null || _a === void 0 ? void 0 : _a.filter(function (decl) { return ts.isFunctionDeclaration(decl) && !decl.body; }); + return !overloadSignatures || overloadSignatures.indexOf(input) === overloadSignatures.length - 1; + } function getBindingNameVisible(elem) { if (ts.isOmittedExpression(elem)) { return false; @@ -98921,7 +102386,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 256 /* ModuleDeclaration */ && parent.kind !== 195 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 258 /* ModuleDeclaration */ && parent.kind !== 197 /* ImportType */); if (ts.isStringLiteralLike(input)) { if (isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); @@ -98941,7 +102406,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 272 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 274 /* ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return factory.updateImportEqualsDeclaration(decl, @@ -98968,7 +102433,7 @@ var ts; return visibleDefaultBinding && factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier)); } - if (decl.importClause.namedBindings.kind === 263 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 265 /* 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, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier)) : undefined; @@ -99063,7 +102528,7 @@ var ts; // We'd see a TDZ violation at runtime var canProduceDiagnostic = ts.canProduceDiagnostics(input); var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 177 /* TypeLiteral */ || input.kind === 190 /* MappedType */) && input.parent.kind !== 254 /* TypeAliasDeclaration */); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 179 /* TypeLiteral */ || input.kind === 192 /* MappedType */) && input.parent.kind !== 256 /* 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 */)) { @@ -99084,21 +102549,21 @@ var ts; } if (isProcessedComponent(input)) { switch (input.kind) { - case 223 /* ExpressionWithTypeArguments */: { + case 225 /* 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 173 /* TypeReference */: { + case 175 /* TypeReference */: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(factory.updateTypeReferenceNode(node, node.typeName, node.typeArguments)); } - case 170 /* ConstructSignature */: + case 172 /* ConstructSignature */: return cleanup(factory.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 166 /* Constructor */: { + case 168 /* Constructor */: { // A constructor declaration may not have a type annotation var ctor = factory.createConstructorDeclaration( /*decorators*/ undefined, @@ -99106,7 +102571,7 @@ var ts; /*body*/ undefined); return cleanup(ctor); } - case 165 /* MethodDeclaration */: { + case 167 /* MethodDeclaration */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } @@ -99116,7 +102581,7 @@ var ts; /*body*/ undefined); return cleanup(sig); } - case 167 /* GetAccessor */: { + case 169 /* GetAccessor */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } @@ -99125,7 +102590,7 @@ var ts; /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* Private */)), ensureType(input, accessorType), /*body*/ undefined)); } - case 168 /* SetAccessor */: { + case 170 /* SetAccessor */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } @@ -99133,31 +102598,31 @@ var ts; /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* Private */)), /*body*/ undefined)); } - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } return cleanup(factory.updatePropertyDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type), ensureNoInitializer(input))); - case 162 /* PropertySignature */: + case 164 /* 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 164 /* MethodSignature */: { + case 166 /* 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 169 /* CallSignature */: { + case 171 /* CallSignature */: { return cleanup(factory.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 171 /* IndexSignature */: { + case 173 /* IndexSignature */: { return cleanup(factory.updateIndexSignature(input, - /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || factory.createKeywordTypeNode(128 /* AnyKeyword */))); + /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || factory.createKeywordTypeNode(129 /* AnyKeyword */))); } - case 249 /* VariableDeclaration */: { + case 251 /* VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -99165,13 +102630,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 159 /* TypeParameter */: { + case 161 /* TypeParameter */: { if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) { return cleanup(factory.updateTypeParameterDeclaration(input, input.name, /*constraint*/ undefined, /*defaultType*/ undefined)); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 184 /* ConditionalType */: { + case 186 /* 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); @@ -99183,13 +102648,13 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(factory.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 174 /* FunctionType */: { + case 176 /* FunctionType */: { return cleanup(factory.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 175 /* ConstructorType */: { + case 177 /* ConstructorType */: { return cleanup(factory.updateConstructorTypeNode(input, ensureModifiers(input), ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 195 /* ImportType */: { + case 197 /* ImportType */: { if (!ts.isLiteralImportTypeNode(input)) return cleanup(input); return cleanup(factory.updateImportTypeNode(input, factory.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); @@ -99221,7 +102686,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 165 /* MethodDeclaration */ && ts.hasEffectiveModifier(node.parent, 8 /* Private */); + return node.parent.kind === 167 /* MethodDeclaration */ && ts.hasEffectiveModifier(node.parent, 8 /* Private */); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -99231,7 +102696,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 267 /* ExportDeclaration */: { + case 269 /* ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } @@ -99241,13 +102706,13 @@ var ts; return factory.updateExportDeclaration(input, /*decorators*/ undefined, input.modifiers, input.isTypeOnly, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 266 /* ExportAssignment */: { + case 268 /* 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 === 78 /* Identifier */) { + if (input.expression.kind === 79 /* Identifier */) { return input; } else { @@ -99256,8 +102721,10 @@ var ts; diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0, errorNode: input }); }; + errorFallbackNode = input; var varDecl = factory.createVariableDeclaration(newId, /*exclamationToken*/ undefined, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); - var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(133 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); + errorFallbackNode = undefined; + var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(134 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); return [statement, factory.updateExportAssignment(input, input.decorators, input.modifiers, newId)]; } } @@ -99273,17 +102740,17 @@ var ts; // 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) & (11263 /* All */ ^ 1 /* Export */)); + var modifiers = factory.createModifiersFromModifierFlags(ts.getEffectiveModifierFlags(statement) & (27647 /* All */ ^ 1 /* Export */)); return factory.updateModifiers(statement, modifiers); } function transformTopLevelDeclaration(input) { if (shouldStripInternal(input)) return; switch (input.kind) { - case 260 /* ImportEqualsDeclaration */: { + case 262 /* ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 261 /* ImportDeclaration */: { + case 263 /* ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -99304,20 +102771,20 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 254 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 256 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all return cleanup(factory.updateTypeAliasDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 253 /* InterfaceDeclaration */: { + case 255 /* InterfaceDeclaration */: { return cleanup(factory.updateInterfaceDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 251 /* FunctionDeclaration */: { + case 253 /* FunctionDeclaration */: { // Generators lose their generator-ness, excepting their return type var clean = cleanup(factory.updateFunctionDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), /*asteriskToken*/ undefined, input.name, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), /*body*/ undefined)); - if (clean && resolver.isExpandoFunctionDeclaration(input)) { + 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(/*decorators*/ undefined, /*modifiers*/ undefined, clean.name || factory.createIdentifier("_default"), factory.createModuleBlock([]), 16 /* Namespace */); @@ -99326,7 +102793,7 @@ var ts; fakespace_1.symbol = props[0].parent; var exportMappings_1 = []; var declarations = ts.mapDefined(props, function (p) { - if (!ts.isPropertyAccessExpression(p.valueDeclaration)) { + if (!p.valueDeclaration || !ts.isPropertyAccessExpression(p.valueDeclaration)) { return undefined; // TODO GH#33569: Handle element access expressions that created late bound names (rather than silently omitting them) } getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p.valueDeclaration); @@ -99339,7 +102806,7 @@ var ts; exportMappings_1.push([name, nameStr]); } var varDecl = factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, type, /*initializer*/ undefined); - return factory.createVariableStatement(isNonContextualKeywordName ? undefined : [factory.createToken(92 /* ExportKeyword */)], factory.createVariableDeclarationList([varDecl])); + return factory.createVariableStatement(isNonContextualKeywordName ? undefined : [factory.createToken(93 /* ExportKeyword */)], factory.createVariableDeclarationList([varDecl])); }); if (!exportMappings_1.length) { declarations = ts.mapDefined(declarations, function (declaration) { return factory.updateModifiers(declaration, 0 /* None */); }); @@ -99378,10 +102845,10 @@ var ts; return clean; } } - case 256 /* ModuleDeclaration */: { + case 258 /* ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 257 /* ModuleBlock */) { + if (inner && inner.kind === 259 /* ModuleBlock */) { var oldNeedsScopeFix = needsScopeFixMarker; var oldHasScopeFix = resultHasScopeMarker; resultHasScopeMarker = false; @@ -99424,7 +102891,9 @@ var ts; /*decorators*/ undefined, mods, input.name, body)); } } - case 252 /* ClassDeclaration */: { + case 254 /* ClassDeclaration */: { + errorNameNode = input.name; + errorFallbackNode = input; var modifiers = factory.createNodeArray(ensureModifiers(input)); var typeParameters = ensureTypeParams(input, input.typeParameters); var ctor = ts.getFirstConstructorWithBody(input); @@ -99432,10 +102901,10 @@ var ts; if (ctor) { var oldDiag_1 = getSymbolAccessibilityDiagnostic; parameterProperties = ts.compact(ts.flatMap(ctor.parameters, function (param) { - if (!ts.hasSyntacticModifier(param, 92 /* ParameterPropertyModifier */) || shouldStripInternal(param)) + if (!ts.hasSyntacticModifier(param, 16476 /* ParameterPropertyModifier */) || shouldStripInternal(param)) return; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(param); - if (param.name.kind === 78 /* Identifier */) { + if (param.name.kind === 79 /* Identifier */) { return preserveJsDoc(factory.createPropertyDeclaration( /*decorators*/ undefined, ensureModifiers(param), param.name, param.questionToken, ensureType(param, param.type), ensureNoInitializer(param)), param); } @@ -99477,7 +102946,7 @@ 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 !== 103 /* NullKeyword */) { + if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 104 /* 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 */); @@ -99487,16 +102956,16 @@ var ts; 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(133 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(134 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); var heritageClauses = factory.createNodeArray(ts.map(input.heritageClauses, function (clause) { - if (clause.token === 93 /* ExtendsKeyword */) { + if (clause.token === 94 /* 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 === 103 /* 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 /* NullKeyword */; })), visitDeclarationSubtree)); })); return [statement, cleanup(factory.updateClassDeclaration(input, /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members))]; // TODO: GH#18217 @@ -99507,10 +102976,10 @@ var ts; /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 232 /* VariableStatement */: { + case 234 /* VariableStatement */: { return cleanup(transformVariableStatement(input)); } - case 255 /* EnumDeclaration */: { + case 257 /* EnumDeclaration */: { return cleanup(factory.updateEnumDeclaration(input, /*decorators*/ undefined, factory.createNodeArray(ensureModifiers(input)), input.name, factory.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -99529,12 +102998,14 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 256 /* ModuleDeclaration */) { + if (input.kind === 258 /* ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { return node; } + errorFallbackNode = undefined; + errorNameNode = undefined; return node && ts.setOriginalNode(preserveJsDoc(node, input), input); } } @@ -99550,7 +103021,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 222 /* OmittedExpression */) { + if (e.kind === 224 /* OmittedExpression */) { return; } if (e.name) { @@ -99598,9 +103069,9 @@ var ts; return factory.createModifiersFromModifierFlags(newFlags); } function ensureModifierFlags(node) { - var mask = 11263 /* All */ ^ (4 /* Public */ | 256 /* Async */); // No async modifiers in declaration files + var mask = 27647 /* 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 === 297 /* SourceFile */; + var parentIsFile = node.parent.kind === 299 /* SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= 2 /* Ambient */; additions = 0 /* None */; @@ -99623,13 +103094,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 === 93 /* ExtendsKeyword */ && t.expression.kind === 103 /* NullKeyword */); + return ts.isEntityNameExpression(t.expression) || (clause.token === 94 /* ExtendsKeyword */ && t.expression.kind === 104 /* NullKeyword */); })), visitDeclarationSubtree)); }), function (clause) { return clause.types && !!clause.types.length; })); } } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 253 /* InterfaceDeclaration */) { + if (node.kind === 255 /* InterfaceDeclaration */) { return true; } return false; @@ -99639,7 +103110,7 @@ var ts; return ts.factory.createModifiersFromModifierFlags(maskModifierFlags(node, modifierMask, modifierAdditions)); } function maskModifierFlags(node, modifierMask, modifierAdditions) { - if (modifierMask === void 0) { modifierMask = 11263 /* All */ ^ 4 /* Public */; } + if (modifierMask === void 0) { modifierMask = 27647 /* All */ ^ 4 /* Public */; } if (modifierAdditions === void 0) { modifierAdditions = 0 /* None */; } var flags = (ts.getEffectiveModifierFlags(node) & modifierMask) | modifierAdditions; if (flags & 512 /* Default */ && !(flags & 1 /* Export */)) { @@ -99654,7 +103125,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 167 /* GetAccessor */ + return accessor.kind === 169 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -99663,52 +103134,52 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: return !ts.hasEffectiveModifier(node, 8 /* Private */); - case 160 /* Parameter */: - case 249 /* VariableDeclaration */: + case 162 /* Parameter */: + case 251 /* VariableDeclaration */: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 256 /* ModuleDeclaration */: - case 260 /* ImportEqualsDeclaration */: - case 253 /* InterfaceDeclaration */: - case 252 /* ClassDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 255 /* EnumDeclaration */: - case 232 /* VariableStatement */: - case 261 /* ImportDeclaration */: - case 267 /* ExportDeclaration */: - case 266 /* ExportAssignment */: + case 253 /* FunctionDeclaration */: + case 258 /* ModuleDeclaration */: + case 262 /* ImportEqualsDeclaration */: + case 255 /* InterfaceDeclaration */: + case 254 /* ClassDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 257 /* EnumDeclaration */: + case 234 /* VariableStatement */: + case 263 /* ImportDeclaration */: + case 269 /* ExportDeclaration */: + case 268 /* ExportAssignment */: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { - case 170 /* ConstructSignature */: - case 166 /* Constructor */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 164 /* MethodSignature */: - case 169 /* CallSignature */: - case 171 /* IndexSignature */: - case 249 /* VariableDeclaration */: - case 159 /* TypeParameter */: - case 223 /* ExpressionWithTypeArguments */: - case 173 /* TypeReference */: - case 184 /* ConditionalType */: - case 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 195 /* ImportType */: + case 172 /* ConstructSignature */: + case 168 /* Constructor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 166 /* MethodSignature */: + case 171 /* CallSignature */: + case 173 /* IndexSignature */: + case 251 /* VariableDeclaration */: + case 161 /* TypeParameter */: + case 225 /* ExpressionWithTypeArguments */: + case 175 /* TypeReference */: + case 186 /* ConditionalType */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: + case 197 /* ImportType */: return true; } return false; @@ -99764,6 +103235,9 @@ var ts; if (languageVersion < 99 /* ESNext */) { transformers.push(ts.transformESNext); } + if (languageVersion < 8 /* ES2021 */) { + transformers.push(ts.transformES2021); + } if (languageVersion < 7 /* ES2020 */) { transformers.push(ts.transformES2020); } @@ -99840,7 +103314,7 @@ 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(341 /* Count */); + var enabledSyntaxKindFeatures = new Array(349 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentStatements; @@ -99851,6 +103325,9 @@ var ts; var lexicalEnvironmentFlagsStack = []; var lexicalEnvironmentStackOffset = 0; var lexicalEnvironmentSuspended = false; + var blockScopedVariableDeclarationsStack = []; + var blockScopeStackOffset = 0; + var blockScopedVariableDeclarations; var emitHelpers; var onSubstituteNode = noEmitSubstitution; var onEmitNode = noEmitNotification; @@ -99873,6 +103350,9 @@ var ts; hoistVariableDeclaration: hoistVariableDeclaration, hoistFunctionDeclaration: hoistFunctionDeclaration, addInitializationStatement: addInitializationStatement, + startBlockScope: startBlockScope, + endBlockScope: endBlockScope, + addBlockScopedVariable: addBlockScopedVariable, requestEmitHelper: requestEmitHelper, readEmitHelpers: readEmitHelpers, enableSubstitution: enableSubstitution, @@ -99916,9 +103396,9 @@ var ts; var transformed = []; for (var _a = 0, nodes_3 = nodes; _a < nodes_3.length; _a++) { var node = nodes_3[_a]; - ts.tracing.push("emit" /* Emit */, "transformNodes", node.kind === 297 /* 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" /* Emit */, "transformNodes", node.kind === 299 /* SourceFile */ ? { path: node.path } : { kind: node.kind, pos: node.pos, end: node.end }); transformed.push((allowDtsFiles ? transformation : transformRoot)(node)); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } // prevent modification of the lexical environment. state = 2 /* Completed */; @@ -100133,6 +103613,38 @@ var ts; function getLexicalEnvironmentFlags() { return lexicalEnvironmentFlags; } + /** + * 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."); + blockScopedVariableDeclarationsStack[blockScopeStackOffset] = blockScopedVariableDeclarations; + blockScopeStackOffset++; + blockScopedVariableDeclarations = undefined; + } + /** + * 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."); + var statements = ts.some(blockScopedVariableDeclarations) ? + [ + factory.createVariableStatement( + /*modifiers*/ undefined, factory.createVariableDeclarationList(blockScopedVariableDeclarations.map(function (identifier) { return factory.createVariableDeclaration(identifier); }), 1 /* Let */)) + ] : undefined; + blockScopeStackOffset--; + blockScopedVariableDeclarations = blockScopedVariableDeclarationsStack[blockScopeStackOffset]; + if (blockScopeStackOffset === 0) { + blockScopedVariableDeclarationsStack = []; + } + return statements; + } + function addBlockScopedVariable(name) { + ts.Debug.assert(blockScopeStackOffset > 0, "Cannot add a block scoped variable outside of an iteration body."); + (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."); @@ -100174,35 +103686,37 @@ var ts; } ts.transformNodes = transformNodes; ts.nullTransformationContext = { - get factory() { return ts.factory; }, - enableEmitNotification: ts.noop, - enableSubstitution: ts.noop, - endLexicalEnvironment: ts.returnUndefined, + factory: ts.factory, getCompilerOptions: function () { return ({}); }, - getEmitHost: ts.notImplemented, getEmitResolver: ts.notImplemented, + getEmitHost: ts.notImplemented, getEmitHelperFactory: ts.notImplemented, + startLexicalEnvironment: ts.noop, + resumeLexicalEnvironment: ts.noop, + suspendLexicalEnvironment: ts.noop, + endLexicalEnvironment: ts.returnUndefined, setLexicalEnvironmentFlags: ts.noop, getLexicalEnvironmentFlags: function () { return 0; }, - hoistFunctionDeclaration: ts.noop, hoistVariableDeclaration: ts.noop, + hoistFunctionDeclaration: ts.noop, addInitializationStatement: ts.noop, - isEmitNotificationEnabled: ts.notImplemented, - isSubstitutionEnabled: ts.notImplemented, - onEmitNode: ts.noop, - onSubstituteNode: ts.notImplemented, - readEmitHelpers: ts.notImplemented, + startBlockScope: ts.noop, + endBlockScope: ts.returnUndefined, + addBlockScopedVariable: ts.noop, requestEmitHelper: ts.noop, - resumeLexicalEnvironment: ts.noop, - startLexicalEnvironment: ts.noop, - suspendLexicalEnvironment: ts.noop, + readEmitHelpers: ts.notImplemented, + enableSubstitution: ts.noop, + enableEmitNotification: ts.noop, + isSubstitutionEnabled: ts.notImplemented, + isEmitNotificationEnabled: ts.notImplemented, + onSubstituteNode: noEmitSubstitution, + onEmitNode: noEmitNotification, addDiagnostic: ts.noop, }; })(ts || (ts = {})); var ts; (function (ts) { var brackets = createBracketsMap(); - var syntheticParent = { pos: -1, end: -1 }; /*@internal*/ function isBuildInfoFile(file) { return ts.fileExtensionIs(file, ".tsbuildinfo" /* TsBuildInfo */); @@ -100288,7 +103802,7 @@ var ts; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 298 /* Bundle */) { + if (sourceFile.kind === 300 /* Bundle */) { return getOutputPathsForBundle(options, forceDtsPaths); } else { @@ -100514,15 +104028,15 @@ var ts; sourceFiles: sourceFileOrBundle.sourceFiles.map(function (file) { return relativeToBuildInfo(ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory())); }) }; } - ts.tracing.push("emit" /* Emit */, "emitJsFileOrBundle", { jsFilePath: jsFilePath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitJsFileOrBundle", { jsFilePath: jsFilePath }); emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo); - ts.tracing.pop(); - ts.tracing.push("emit" /* Emit */, "emitDeclarationFileOrBundle", { declarationFilePath: declarationFilePath }); + 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 }); emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo); - ts.tracing.pop(); - ts.tracing.push("emit" /* Emit */, "emitBuildInfo", { buildInfoPath: buildInfoPath }); + 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 }); emitBuildInfo(bundleBuildInfo, buildInfoPath); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); if (!emitSkipped && emittedFilesList) { if (!emitOnlyDtsFiles) { if (jsFilePath) { @@ -100649,13 +104163,13 @@ var ts; 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: compilerOptions.declarationMap, + sourceMap: !forceDtsEmit && compilerOptions.declarationMap, sourceRoot: compilerOptions.sourceRoot, mapRoot: compilerOptions.mapRoot, extendedDiagnostics: compilerOptions.extendedDiagnostics, // Explicitly do not passthru either `inline` option }); - if (forceDtsEmit && declarationTransform.transformed[0].kind === 297 /* SourceFile */) { + if (forceDtsEmit && declarationTransform.transformed[0].kind === 299 /* SourceFile */) { var sourceFile = declarationTransform.transformed[0]; exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; } @@ -100666,7 +104180,7 @@ var ts; } function collectLinkedAliases(node) { if (ts.isExportAssignment(node)) { - if (node.expression.kind === 78 /* Identifier */) { + if (node.expression.kind === 79 /* Identifier */) { resolver.collectLinkedAliases(node.expression, /*setVisibility*/ true); } return; @@ -100678,8 +104192,8 @@ var ts; ts.forEachChild(node, collectLinkedAliases); } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) { - var bundle = sourceFileOrBundle.kind === 298 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 297 /* SourceFile */ ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 300 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 299 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; var sourceMapGenerator; if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { @@ -100720,7 +104234,7 @@ var ts; } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { return (mapOptions.sourceMap || mapOptions.inlineSourceMap) - && (sourceFileOrBundle.kind !== 297 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); + && (sourceFileOrBundle.kind !== 299 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); } function getSourceRoot(mapOptions) { // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the @@ -100779,7 +104293,7 @@ var ts; ts.emitFiles = emitFiles; /*@internal*/ function getBuildInfoText(buildInfo) { - return JSON.stringify(buildInfo, undefined, 2); + return JSON.stringify(buildInfo); } ts.getBuildInfoText = getBuildInfoText; /*@internal*/ @@ -100960,7 +104474,7 @@ var ts; function createPrinter(printerOptions, handlers) { if (printerOptions === void 0) { printerOptions = {}; } if (handlers === void 0) { handlers = {}; } - var hasGlobalName = handlers.hasGlobalName, _a = handlers.onEmitNode, onEmitNode = _a === void 0 ? ts.noEmitNotification : _a, isEmitNotificationEnabled = handlers.isEmitNotificationEnabled, _b = handlers.substituteNode, substituteNode = _b === void 0 ? ts.noEmitSubstitution : _b, onBeforeEmitNodeArray = handlers.onBeforeEmitNodeArray, onAfterEmitNodeArray = handlers.onAfterEmitNodeArray, onBeforeEmitToken = handlers.onBeforeEmitToken, onAfterEmitToken = handlers.onAfterEmitToken; + var hasGlobalName = handlers.hasGlobalName, _a = handlers.onEmitNode, onEmitNode = _a === void 0 ? ts.noEmitNotification : _a, isEmitNotificationEnabled = handlers.isEmitNotificationEnabled, _b = handlers.substituteNode, substituteNode = _b === void 0 ? ts.noEmitSubstitution : _b, onBeforeEmitNode = handlers.onBeforeEmitNode, onAfterEmitNode = handlers.onAfterEmitNode, onBeforeEmitNodeArray = handlers.onBeforeEmitNodeArray, onAfterEmitNodeArray = handlers.onAfterEmitNodeArray, onBeforeEmitToken = handlers.onBeforeEmitToken, onAfterEmitToken = handlers.onAfterEmitToken; var extendedDiagnostics = !!printerOptions.extendedDiagnostics; var newLine = ts.getNewLineCharacter(printerOptions); var moduleKind = ts.getEmitModuleKind(printerOptions); @@ -100999,9 +104513,11 @@ var ts; var detachedCommentsInfo; var hasWrittenComment = false; var commentsDisabled = !!printerOptions.removeComments; - var lastNode; var lastSubstitution; + var currentParenthesizerRule; var _c = ts.performance.createTimerIf(extendedDiagnostics, "commentTime", "beforeComment", "afterComment"), enterComment = _c.enter, exitComment = _c.exit; + var parenthesizer = ts.factory.parenthesizer; + var emitBinaryExpression = createEmitBinaryExpression(); reset(); return { // public API @@ -101029,9 +104545,9 @@ var ts; break; } switch (node.kind) { - case 297 /* SourceFile */: return printFile(node); - case 298 /* Bundle */: return printBundle(node); - case 299 /* UnparsedSource */: return printUnparsedSource(node); + case 299 /* SourceFile */: return printFile(node); + case 300 /* Bundle */: return printBundle(node); + case 301 /* UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -101065,7 +104581,7 @@ var ts; if (sourceFile) { setSourceFile(sourceFile); } - emitList(syntheticParent, nodes, format); + emitList(/*parentNode*/ undefined, nodes, format); reset(); writer = previousWriter; } @@ -101200,7 +104716,7 @@ var ts; if (sourceFile) { setSourceFile(sourceFile); } - pipelineEmit(hint, node); + pipelineEmit(hint, node, /*parenthesizerRule*/ undefined); } function setSourceFile(sourceFile) { currentSourceFile = sourceFile; @@ -101228,51 +104744,54 @@ var ts; currentSourceFile = undefined; currentLineMap = undefined; detachedCommentsInfo = undefined; - lastNode = undefined; - lastSubstitution = undefined; setWriter(/*output*/ undefined, /*_sourceMapGenerator*/ undefined); } function getCurrentLineMap() { return currentLineMap || (currentLineMap = ts.getLineStarts(currentSourceFile)); } - function emit(node) { + function emit(node, parenthesizerRule) { if (node === undefined) return; var prevSourceFileTextKind = recordBundleFileInternalSectionStart(node); - var substitute = pipelineEmit(4 /* Unspecified */, node); + pipelineEmit(4 /* Unspecified */, node, parenthesizerRule); recordBundleFileInternalSectionEnd(prevSourceFileTextKind); - return substitute; } function emitIdentifierName(node) { if (node === undefined) return; - return pipelineEmit(2 /* IdentifierName */, node); + pipelineEmit(2 /* IdentifierName */, node, /*parenthesizerRule*/ undefined); } - function emitExpression(node) { + function emitExpression(node, parenthesizerRule) { if (node === undefined) return; - return pipelineEmit(1 /* Expression */, node); + pipelineEmit(1 /* Expression */, node, parenthesizerRule); } function emitJsxAttributeValue(node) { - return pipelineEmit(ts.isStringLiteral(node) ? 6 /* JsxAttributeValue */ : 4 /* Unspecified */, node); + pipelineEmit(ts.isStringLiteral(node) ? 6 /* JsxAttributeValue */ : 4 /* Unspecified */, node); } - function pipelineEmit(emitHint, node) { - var savedLastNode = lastNode; - var savedLastSubstitution = lastSubstitution; - var savedPreserveSourceNewlines = preserveSourceNewlines; - lastNode = node; - lastSubstitution = undefined; - if (preserveSourceNewlines && !!(ts.getEmitFlags(node) & 134217728 /* IgnoreSourceNewlines */)) { + function beforeEmitNode(node) { + if (preserveSourceNewlines && (ts.getEmitFlags(node) & 134217728 /* IgnoreSourceNewlines */)) { preserveSourceNewlines = false; } + } + function afterEmitNode(savedPreserveSourceNewlines) { + preserveSourceNewlines = savedPreserveSourceNewlines; + } + function pipelineEmit(emitHint, node, parenthesizerRule) { + currentParenthesizerRule = parenthesizerRule; var pipelinePhase = getPipelinePhase(0 /* Notification */, emitHint, node); pipelinePhase(emitHint, node); - ts.Debug.assert(lastNode === node); - var substitute = lastSubstitution; - lastNode = savedLastNode; - lastSubstitution = savedLastSubstitution; - preserveSourceNewlines = savedPreserveSourceNewlines; - return substitute || node; + currentParenthesizerRule = undefined; + } + function shouldEmitComments(node) { + return !commentsDisabled && !ts.isSourceFile(node); + } + function shouldEmitSourceMaps(node) { + return !sourceMapsDisabled && + !ts.isSourceFile(node) && + !ts.isInJsonFile(node) && + !ts.isUnparsedSource(node) && + !ts.isUnparsedPrepend(node); } function getPipelinePhase(phase, emitHint, node) { switch (phase) { @@ -101282,18 +104801,21 @@ var ts; } // falls through case 1 /* Substitution */: - if (substituteNode !== ts.noEmitSubstitution && (lastSubstitution = substituteNode(emitHint, node)) !== node) { + if (substituteNode !== ts.noEmitSubstitution && (lastSubstitution = substituteNode(emitHint, node) || node) !== node) { + if (currentParenthesizerRule) { + lastSubstitution = currentParenthesizerRule(lastSubstitution); + } return pipelineEmitWithSubstitution; } // falls through case 2 /* Comments */: - if (!commentsDisabled && node.kind !== 297 /* SourceFile */) { + if (shouldEmitComments(node)) { return pipelineEmitWithComments; } // falls through case 3 /* SourceMaps */: - if (!sourceMapsDisabled && node.kind !== 297 /* SourceFile */ && !ts.isInJsonFile(node)) { - return pipelineEmitWithSourceMap; + if (shouldEmitSourceMaps(node)) { + return pipelineEmitWithSourceMaps; } // falls through case 4 /* Emit */: @@ -101306,13 +104828,25 @@ var ts; return getPipelinePhase(currentPhase + 1, emitHint, node); } function pipelineEmitWithNotification(hint, node) { - ts.Debug.assert(lastNode === node); var pipelinePhase = getNextPipelinePhase(0 /* Notification */, hint, node); onEmitNode(hint, node, pipelinePhase); - ts.Debug.assert(lastNode === node); } function pipelineEmitWithHint(hint, node) { - ts.Debug.assert(lastNode === node || lastSubstitution === node); + onBeforeEmitNode === null || onBeforeEmitNode === void 0 ? void 0 : onBeforeEmitNode(node); + if (preserveSourceNewlines) { + var savedPreserveSourceNewlines = preserveSourceNewlines; + beforeEmitNode(node); + pipelineEmitWithHintWorker(hint, node); + afterEmitNode(savedPreserveSourceNewlines); + } + else { + pipelineEmitWithHintWorker(hint, node); + } + onAfterEmitNode === null || onAfterEmitNode === void 0 ? void 0 : onAfterEmitNode(node); + // clear the parenthesizer rule as we ascend + currentParenthesizerRule = undefined; + } + function pipelineEmitWithHintWorker(hint, node) { if (hint === 0 /* SourceFile */) return emitSourceFile(ts.cast(node, ts.isSourceFile)); if (hint === 2 /* IdentifierName */) @@ -101326,308 +104860,337 @@ var ts; return emitEmptyStatement(/*isEmbeddedStatement*/ true); } if (hint === 4 /* Unspecified */) { - if (ts.isKeyword(node.kind)) - return writeTokenNode(node, writeKeyword); switch (node.kind) { // Pseudo-literals case 15 /* TemplateHead */: case 16 /* TemplateMiddle */: case 17 /* TemplateTail */: return emitLiteral(node, /*jsxAttributeEscape*/ false); - case 299 /* UnparsedSource */: - case 293 /* UnparsedPrepend */: - return emitUnparsedSourceOrPrepend(node); - case 292 /* UnparsedPrologue */: - return writeUnparsedNode(node); - case 294 /* UnparsedText */: - case 295 /* UnparsedInternalText */: - return emitUnparsedTextLike(node); - case 296 /* UnparsedSyntheticReference */: - return emitUnparsedSyntheticReference(node); // Identifiers - case 78 /* Identifier */: + case 79 /* Identifier */: return emitIdentifier(node); // PrivateIdentifiers - case 79 /* PrivateIdentifier */: + case 80 /* PrivateIdentifier */: return emitPrivateIdentifier(node); // Parse tree nodes // Names - case 157 /* QualifiedName */: + case 159 /* QualifiedName */: return emitQualifiedName(node); - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 159 /* TypeParameter */: + case 161 /* TypeParameter */: return emitTypeParameter(node); - case 160 /* Parameter */: + case 162 /* Parameter */: return emitParameter(node); - case 161 /* Decorator */: + case 163 /* Decorator */: return emitDecorator(node); // Type members - case 162 /* PropertySignature */: + case 164 /* PropertySignature */: return emitPropertySignature(node); - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return emitPropertyDeclaration(node); - case 164 /* MethodSignature */: + case 166 /* MethodSignature */: return emitMethodSignature(node); - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: return emitMethodDeclaration(node); - case 166 /* Constructor */: + case 168 /* Constructor */: return emitConstructor(node); - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return emitAccessorDeclaration(node); - case 169 /* CallSignature */: + case 171 /* CallSignature */: return emitCallSignature(node); - case 170 /* ConstructSignature */: + case 172 /* ConstructSignature */: return emitConstructSignature(node); - case 171 /* IndexSignature */: + case 173 /* IndexSignature */: return emitIndexSignature(node); - case 194 /* TemplateLiteralTypeSpan */: - return emitTemplateTypeSpan(node); // Types - case 172 /* TypePredicate */: + case 174 /* TypePredicate */: return emitTypePredicate(node); - case 173 /* TypeReference */: + case 175 /* TypeReference */: return emitTypeReference(node); - case 174 /* FunctionType */: + case 176 /* FunctionType */: return emitFunctionType(node); - case 308 /* JSDocFunctionType */: - return emitJSDocFunctionType(node); - case 175 /* ConstructorType */: + case 177 /* ConstructorType */: return emitConstructorType(node); - case 176 /* TypeQuery */: + case 178 /* TypeQuery */: return emitTypeQuery(node); - case 177 /* TypeLiteral */: + case 179 /* TypeLiteral */: return emitTypeLiteral(node); - case 178 /* ArrayType */: + case 180 /* ArrayType */: return emitArrayType(node); - case 179 /* TupleType */: + case 181 /* TupleType */: return emitTupleType(node); - case 180 /* OptionalType */: + case 182 /* OptionalType */: return emitOptionalType(node); - case 182 /* UnionType */: + // SyntaxKind.RestType is handled below + case 184 /* UnionType */: return emitUnionType(node); - case 183 /* IntersectionType */: + case 185 /* IntersectionType */: return emitIntersectionType(node); - case 184 /* ConditionalType */: + case 186 /* ConditionalType */: return emitConditionalType(node); - case 185 /* InferType */: + case 187 /* InferType */: return emitInferType(node); - case 186 /* ParenthesizedType */: + case 188 /* ParenthesizedType */: return emitParenthesizedType(node); - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 187 /* ThisType */: + case 189 /* ThisType */: return emitThisType(); - case 188 /* TypeOperator */: + case 190 /* TypeOperator */: return emitTypeOperator(node); - case 189 /* IndexedAccessType */: + case 191 /* IndexedAccessType */: return emitIndexedAccessType(node); - case 190 /* MappedType */: + case 192 /* MappedType */: return emitMappedType(node); - case 191 /* LiteralType */: + case 193 /* LiteralType */: return emitLiteralType(node); - case 193 /* TemplateLiteralType */: + case 194 /* NamedTupleMember */: + return emitNamedTupleMember(node); + case 195 /* TemplateLiteralType */: return emitTemplateType(node); - case 195 /* ImportType */: + case 196 /* TemplateLiteralTypeSpan */: + return emitTemplateTypeSpan(node); + case 197 /* ImportType */: return emitImportTypeNode(node); - case 303 /* JSDocAllType */: - writePunctuation("*"); - return; - case 304 /* JSDocUnknownType */: - writePunctuation("?"); - return; - case 305 /* JSDocNullableType */: - return emitJSDocNullableType(node); - case 306 /* JSDocNonNullableType */: - return emitJSDocNonNullableType(node); - case 307 /* JSDocOptionalType */: - return emitJSDocOptionalType(node); - case 181 /* RestType */: - case 309 /* JSDocVariadicType */: - return emitRestOrJSDocVariadicType(node); - case 192 /* NamedTupleMember */: - return emitNamedTupleMember(node); // Binding patterns - case 196 /* ObjectBindingPattern */: + case 198 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 197 /* ArrayBindingPattern */: + case 199 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 198 /* BindingElement */: + case 200 /* BindingElement */: return emitBindingElement(node); // Misc - case 228 /* TemplateSpan */: + case 230 /* TemplateSpan */: return emitTemplateSpan(node); - case 229 /* SemicolonClassElement */: + case 231 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 230 /* Block */: + case 232 /* Block */: return emitBlock(node); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return emitVariableStatement(node); - case 231 /* EmptyStatement */: + case 233 /* EmptyStatement */: return emitEmptyStatement(/*isEmbeddedStatement*/ false); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: return emitExpressionStatement(node); - case 234 /* IfStatement */: + case 236 /* IfStatement */: return emitIfStatement(node); - case 235 /* DoStatement */: + case 237 /* DoStatement */: return emitDoStatement(node); - case 236 /* WhileStatement */: + case 238 /* WhileStatement */: return emitWhileStatement(node); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return emitForStatement(node); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return emitForInStatement(node); - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: return emitForOfStatement(node); - case 240 /* ContinueStatement */: + case 242 /* ContinueStatement */: return emitContinueStatement(node); - case 241 /* BreakStatement */: + case 243 /* BreakStatement */: return emitBreakStatement(node); - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: return emitReturnStatement(node); - case 243 /* WithStatement */: + case 245 /* WithStatement */: return emitWithStatement(node); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: return emitSwitchStatement(node); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return emitLabeledStatement(node); - case 246 /* ThrowStatement */: + case 248 /* ThrowStatement */: return emitThrowStatement(node); - case 247 /* TryStatement */: + case 249 /* TryStatement */: return emitTryStatement(node); - case 248 /* DebuggerStatement */: + case 250 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 250 /* VariableDeclarationList */: + case 252 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: return emitClassDeclaration(node); - case 253 /* InterfaceDeclaration */: + case 255 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 257 /* ModuleBlock */: + case 259 /* ModuleBlock */: return emitModuleBlock(node); - case 258 /* CaseBlock */: + case 260 /* CaseBlock */: return emitCaseBlock(node); - case 259 /* NamespaceExportDeclaration */: + case 261 /* NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return emitImportDeclaration(node); - case 262 /* ImportClause */: + case 264 /* ImportClause */: return emitImportClause(node); - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: return emitNamespaceImport(node); - case 269 /* NamespaceExport */: + case 271 /* NamespaceExport */: return emitNamespaceExport(node); - case 264 /* NamedImports */: + case 266 /* NamedImports */: return emitNamedImports(node); - case 265 /* ImportSpecifier */: + case 267 /* ImportSpecifier */: return emitImportSpecifier(node); - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return emitExportAssignment(node); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: return emitExportDeclaration(node); - case 268 /* NamedExports */: + case 270 /* NamedExports */: return emitNamedExports(node); - case 270 /* ExportSpecifier */: + case 272 /* ExportSpecifier */: return emitExportSpecifier(node); - case 271 /* MissingDeclaration */: + case 273 /* MissingDeclaration */: return; // Module references - case 272 /* ExternalModuleReference */: + case 274 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 11 /* JsxText */: return emitJsxText(node); - case 275 /* JsxOpeningElement */: - case 278 /* JsxOpeningFragment */: + case 277 /* JsxOpeningElement */: + case 280 /* JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 276 /* JsxClosingElement */: - case 279 /* JsxClosingFragment */: + case 278 /* JsxClosingElement */: + case 281 /* JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 280 /* JsxAttribute */: + case 282 /* JsxAttribute */: return emitJsxAttribute(node); - case 281 /* JsxAttributes */: + case 283 /* JsxAttributes */: return emitJsxAttributes(node); - case 282 /* JsxSpreadAttribute */: + case 284 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 284 /* CaseClause */: + case 286 /* CaseClause */: return emitCaseClause(node); - case 285 /* DefaultClause */: + case 287 /* DefaultClause */: return emitDefaultClause(node); - case 286 /* HeritageClause */: + case 288 /* HeritageClause */: return emitHeritageClause(node); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 290 /* SpreadAssignment */: + case 292 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 291 /* EnumMember */: + case 293 /* EnumMember */: return emitEnumMember(node); + // Unparsed + case 294 /* UnparsedPrologue */: + return writeUnparsedNode(node); + case 301 /* UnparsedSource */: + case 295 /* UnparsedPrepend */: + return emitUnparsedSourceOrPrepend(node); + case 296 /* UnparsedText */: + case 297 /* UnparsedInternalText */: + return emitUnparsedTextLike(node); + case 298 /* UnparsedSyntheticReference */: + return emitUnparsedSyntheticReference(node); + // Top-level nodes + case 299 /* SourceFile */: + return emitSourceFile(node); + case 300 /* Bundle */: + return ts.Debug.fail("Bundles should be printed using printBundle"); + // SyntaxKind.UnparsedSource (handled above) + case 302 /* InputFiles */: + return ts.Debug.fail("InputFiles should not be printed"); // JSDoc nodes (only used in codefixes currently) - case 326 /* JSDocParameterTag */: - case 333 /* JSDocPropertyTag */: + case 303 /* JSDocTypeExpression */: + return emitJSDocTypeExpression(node); + case 304 /* JSDocNameReference */: + return emitJSDocNameReference(node); + case 306 /* JSDocAllType */: + return writePunctuation("*"); + case 307 /* JSDocUnknownType */: + return writePunctuation("?"); + case 308 /* JSDocNullableType */: + return emitJSDocNullableType(node); + case 309 /* JSDocNonNullableType */: + return emitJSDocNonNullableType(node); + case 310 /* JSDocOptionalType */: + return emitJSDocOptionalType(node); + case 311 /* JSDocFunctionType */: + return emitJSDocFunctionType(node); + case 183 /* RestType */: + case 312 /* JSDocVariadicType */: + return emitRestOrJSDocVariadicType(node); + case 313 /* JSDocNamepathType */: + return; + case 314 /* JSDocComment */: + return emitJSDoc(node); + case 316 /* JSDocTypeLiteral */: + return emitJSDocTypeLiteral(node); + case 317 /* JSDocSignature */: + return emitJSDocSignature(node); + case 321 /* JSDocTag */: + case 326 /* JSDocClassTag */: + return emitJSDocSimpleTag(node); + case 322 /* JSDocAugmentsTag */: + case 323 /* JSDocImplementsTag */: + return emitJSDocHeritageTag(node); + case 324 /* JSDocAuthorTag */: + case 325 /* JSDocDeprecatedTag */: + return; + // SyntaxKind.JSDocClassTag (see JSDocTag, above) + case 327 /* JSDocPublicTag */: + case 328 /* JSDocPrivateTag */: + case 329 /* JSDocProtectedTag */: + case 330 /* JSDocReadonlyTag */: + case 331 /* JSDocOverrideTag */: + return; + case 332 /* JSDocCallbackTag */: + return emitJSDocCallbackTag(node); + // SyntaxKind.JSDocEnumTag (see below) + case 334 /* JSDocParameterTag */: + case 341 /* JSDocPropertyTag */: return emitJSDocPropertyLikeTag(node); - case 327 /* JSDocReturnTag */: - case 329 /* JSDocTypeTag */: - case 328 /* JSDocThisTag */: - case 325 /* JSDocEnumTag */: + case 333 /* JSDocEnumTag */: + case 335 /* JSDocReturnTag */: + case 336 /* JSDocThisTag */: + case 337 /* JSDocTypeTag */: return emitJSDocSimpleTypedTag(node); - case 316 /* JSDocImplementsTag */: - case 315 /* JSDocAugmentsTag */: - return emitJSDocHeritageTag(node); - case 330 /* JSDocTemplateTag */: + case 338 /* JSDocTemplateTag */: return emitJSDocTemplateTag(node); - case 331 /* JSDocTypedefTag */: + case 339 /* JSDocTypedefTag */: return emitJSDocTypedefTag(node); - case 324 /* JSDocCallbackTag */: - return emitJSDocCallbackTag(node); - case 313 /* JSDocSignature */: - return emitJSDocSignature(node); - case 312 /* JSDocTypeLiteral */: - return emitJSDocTypeLiteral(node); - case 319 /* JSDocClassTag */: - case 314 /* JSDocTag */: - return emitJSDocSimpleTag(node); - case 332 /* JSDocSeeTag */: + case 340 /* JSDocSeeTag */: return emitJSDocSeeTag(node); - case 302 /* JSDocNameReference */: - return emitJSDocNameReference(node); - case 311 /* JSDocComment */: - return emitJSDoc(node); - // Transformation nodes (ignored) + // SyntaxKind.JSDocPropertyTag (see JSDocParameterTag, above) + // Transformation nodes + case 343 /* NotEmittedStatement */: + case 347 /* EndOfDeclarationMarker */: + case 346 /* MergeDeclarationMarker */: + return; } if (ts.isExpression(node)) { hint = 1 /* Expression */; if (substituteNode !== ts.noEmitSubstitution) { - lastSubstitution = node = substituteNode(hint, node); + var substitute = substituteNode(hint, node) || node; + if (substitute !== node) { + node = substitute; + if (currentParenthesizerRule) { + node = currentParenthesizerRule(node); + } + } } } - else if (ts.isToken(node)) { - return writeTokenNode(node, writePunctuation); - } } if (hint === 1 /* Expression */) { switch (node.kind) { @@ -101640,86 +105203,94 @@ var ts; case 14 /* NoSubstitutionTemplateLiteral */: return emitLiteral(node, /*jsxAttributeEscape*/ false); // Identifiers - case 78 /* Identifier */: + case 79 /* Identifier */: return emitIdentifier(node); - // Reserved words - case 94 /* FalseKeyword */: - case 103 /* NullKeyword */: - case 105 /* SuperKeyword */: - case 109 /* TrueKeyword */: - case 107 /* ThisKeyword */: - case 99 /* ImportKeyword */: - writeTokenNode(node, writeKeyword); - return; // Expressions - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return emitCallExpression(node); - case 204 /* NewExpression */: + case 206 /* NewExpression */: return emitNewExpression(node); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 206 /* TypeAssertionExpression */: + case 208 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: return emitFunctionExpression(node); - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return emitArrowFunction(node); - case 210 /* DeleteExpression */: + case 212 /* DeleteExpression */: return emitDeleteExpression(node); - case 211 /* TypeOfExpression */: + case 213 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 212 /* VoidExpression */: + case 214 /* VoidExpression */: return emitVoidExpression(node); - case 213 /* AwaitExpression */: + case 215 /* AwaitExpression */: return emitAwaitExpression(node); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return emitBinaryExpression(node); - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: return emitConditionalExpression(node); - case 218 /* TemplateExpression */: + case 220 /* TemplateExpression */: return emitTemplateExpression(node); - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: return emitYieldExpression(node); - case 220 /* SpreadElement */: - return emitSpreadExpression(node); - case 221 /* ClassExpression */: + case 222 /* SpreadElement */: + return emitSpreadElement(node); + case 223 /* ClassExpression */: return emitClassExpression(node); - case 222 /* OmittedExpression */: + case 224 /* OmittedExpression */: return; - case 224 /* AsExpression */: + case 226 /* AsExpression */: return emitAsExpression(node); - case 225 /* NonNullExpression */: + case 227 /* NonNullExpression */: return emitNonNullExpression(node); - case 226 /* MetaProperty */: + case 228 /* MetaProperty */: return emitMetaProperty(node); + case 229 /* SyntheticExpression */: + return ts.Debug.fail("SyntheticExpression should never be printed."); // JSX - case 273 /* JsxElement */: + case 275 /* JsxElement */: return emitJsxElement(node); - case 274 /* JsxSelfClosingElement */: + case 276 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 277 /* JsxFragment */: + case 279 /* JsxFragment */: return emitJsxFragment(node); + // Synthesized list + case 342 /* SyntaxList */: + return ts.Debug.fail("SyntaxList should not be printed"); // Transformation nodes - case 336 /* PartiallyEmittedExpression */: + case 343 /* NotEmittedStatement */: + return; + case 344 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 337 /* CommaListExpression */: + case 345 /* CommaListExpression */: return emitCommaList(node); + case 346 /* MergeDeclarationMarker */: + case 347 /* EndOfDeclarationMarker */: + return; + case 348 /* SyntheticReferenceExpression */: + return ts.Debug.fail("SyntheticReferenceExpression should not be printed"); } } + if (ts.isKeyword(node.kind)) + return writeTokenNode(node, writeKeyword); + if (ts.isTokenKind(node.kind)) + return writeTokenNode(node, writePunctuation); + ts.Debug.fail("Unhandled SyntaxKind: " + ts.Debug.formatSyntaxKind(node.kind) + "."); } function emitMappedTypeParameter(node) { emit(node.name); @@ -101729,10 +105300,11 @@ var ts; emit(node.constraint); } function pipelineEmitWithSubstitution(hint, node) { - ts.Debug.assert(lastNode === node || lastSubstitution === node); var pipelinePhase = getNextPipelinePhase(1 /* Substitution */, hint, node); - pipelinePhase(hint, lastSubstitution); - ts.Debug.assert(lastNode === node || lastSubstitution === node); + ts.Debug.assertIsDefined(lastSubstitution); + node = lastSubstitution; + lastSubstitution = undefined; + pipelinePhase(hint, node); } function getHelpersFromBundledSourceFiles(bundle) { var result; @@ -101758,7 +105330,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 298 /* Bundle */ ? node : undefined; + var bundle = node.kind === 300 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -101858,7 +105430,7 @@ var ts; var pos = getTextPosWithWriteLine(); writeUnparsedNode(unparsed); if (bundleFileInfo) { - updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 294 /* UnparsedText */ ? + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 296 /* UnparsedText */ ? "text" /* Text */ : "internal" /* Internal */); } @@ -101895,7 +105467,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { emitExpression(node); } else { @@ -101904,7 +105476,7 @@ var ts; } function emitComputedPropertyName(node) { writePunctuation("["); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfComputedPropertyName); writePunctuation("]"); } // @@ -101931,18 +105503,18 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 308 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 311 /* JSDocFunctionType */ && !node.name) { emit(node.type); } else { emitTypeAnnotation(node.type); } // The comment position has to fallback to any present node within the parameterdeclaration because as it turns out, the parser can make parameter declarations with _just_ an initializer. - emitInitializer(node.initializer, node.type ? node.type.end : node.questionToken ? node.questionToken.end : node.name ? node.name.end : node.modifiers ? node.modifiers.end : node.decorators ? node.decorators.end : node.pos, node); + emitInitializer(node.initializer, node.type ? node.type.end : node.questionToken ? node.questionToken.end : node.name ? node.name.end : node.modifiers ? node.modifiers.end : node.decorators ? node.decorators.end : node.pos, node, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitDecorator(decorator) { writePunctuation("@"); - emitExpression(decorator.expression); + emitExpression(decorator.expression, parenthesizer.parenthesizeLeftSideOfAccess); } // // Type members @@ -101993,7 +105565,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeKeyword(node.kind === 167 /* GetAccessor */ ? "get" : "set"); + writeKeyword(node.kind === 169 /* GetAccessor */ ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -102107,7 +105679,7 @@ var ts; writePunctuation("}"); } function emitArrayType(node) { - emit(node.elementType); + emit(node.elementType, parenthesizer.parenthesizeElementTypeOfArrayType); writePunctuation("["); writePunctuation("]"); } @@ -102130,21 +105702,21 @@ var ts; emit(node.type); } function emitOptionalType(node) { - emit(node.type); + emit(node.type, parenthesizer.parenthesizeElementTypeOfArrayType); writePunctuation("?"); } function emitUnionType(node) { - emitList(node, node.types, 516 /* UnionTypeConstituents */); + emitList(node, node.types, 516 /* UnionTypeConstituents */, parenthesizer.parenthesizeMemberOfElementType); } function emitIntersectionType(node) { - emitList(node, node.types, 520 /* IntersectionTypeConstituents */); + emitList(node, node.types, 520 /* IntersectionTypeConstituents */, parenthesizer.parenthesizeMemberOfElementType); } function emitConditionalType(node) { - emit(node.checkType); + emit(node.checkType, parenthesizer.parenthesizeMemberOfConditionalType); writeSpace(); writeKeyword("extends"); writeSpace(); - emit(node.extendsType); + emit(node.extendsType, parenthesizer.parenthesizeMemberOfConditionalType); writeSpace(); writePunctuation("?"); writeSpace(); @@ -102170,10 +105742,10 @@ var ts; function emitTypeOperator(node) { writeTokenText(node.operator, writeKeyword); writeSpace(); - emit(node.type); + emit(node.type, parenthesizer.parenthesizeMemberOfElementType); } function emitIndexedAccessType(node) { - emit(node.objectType); + emit(node.objectType, parenthesizer.parenthesizeMemberOfElementType); writePunctuation("["); emit(node.indexType); writePunctuation("]"); @@ -102190,7 +105762,7 @@ var ts; } if (node.readonlyToken) { emit(node.readonlyToken); - if (node.readonlyToken.kind !== 142 /* ReadonlyKeyword */) { + if (node.readonlyToken.kind !== 143 /* ReadonlyKeyword */) { writeKeyword("readonly"); } writeSpace(); @@ -102266,7 +105838,7 @@ var ts; writeSpace(); } emit(node.name); - emitInitializer(node.initializer, node.name.end, node); + emitInitializer(node.initializer, node.name.end, node, parenthesizer.parenthesizeExpressionForDisallowedComma); } // // Expressions @@ -102274,7 +105846,7 @@ var ts; function emitArrayLiteralExpression(node) { var elements = node.elements; var preferNewLine = node.multiLine ? 65536 /* PreferNewLine */ : 0 /* None */; - emitExpressionList(node, elements, 8914 /* ArrayLiteralExpressionElements */ | preferNewLine); + emitExpressionList(node, elements, 8914 /* ArrayLiteralExpressionElements */ | preferNewLine, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitObjectLiteralExpression(node) { ts.forEach(node.properties, generateMemberNames); @@ -102290,13 +105862,13 @@ var ts; } } function emitPropertyAccessExpression(node) { - var expression = ts.cast(emitExpression(node.expression), ts.isExpression); + emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); var token = node.questionDotToken || ts.setTextRangePosEnd(ts.factory.createToken(24 /* 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 */ && - mayNeedDotDotForPropertyAccess(expression) && + mayNeedDotDotForPropertyAccess(node.expression) && !writer.hasTrailingComment() && !writer.hasTrailingWhitespace(); if (shouldEmitDotDot) { @@ -102332,27 +105904,27 @@ var ts; } } function emitElementAccessExpression(node) { - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); emit(node.questionDotToken); emitTokenWithComment(22 /* OpenBracketToken */, node.expression.end, writePunctuation, node); emitExpression(node.argumentExpression); emitTokenWithComment(23 /* CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); } function emitCallExpression(node) { - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); emit(node.questionDotToken); emitTypeArguments(node, node.typeArguments); - emitExpressionList(node, node.arguments, 2576 /* CallExpressionArguments */); + emitExpressionList(node, node.arguments, 2576 /* CallExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitNewExpression(node) { - emitTokenWithComment(102 /* NewKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(103 /* NewKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfNew); emitTypeArguments(node, node.typeArguments); - emitExpressionList(node, node.arguments, 18960 /* NewExpressionArguments */); + emitExpressionList(node, node.arguments, 18960 /* NewExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitTaggedTemplateExpression(node) { - emitExpression(node.tag); + emitExpression(node.tag, parenthesizer.parenthesizeLeftSideOfAccess); emitTypeArguments(node, node.typeArguments); writeSpace(); emitExpression(node.template); @@ -102361,12 +105933,12 @@ var ts; writePunctuation("<"); emit(node.type); writePunctuation(">"); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitParenthesizedExpression(node) { var openParenPos = emitTokenWithComment(20 /* OpenParenToken */, node.pos, writePunctuation, node); var indented = writeLineSeparatorsAndIndentBefore(node.expression, node); - emitExpression(node.expression); + emitExpression(node.expression, /*parenthesizerRules*/ undefined); writeLineSeparatorsAfter(node.expression, node); decreaseIndentIf(indented); emitTokenWithComment(21 /* CloseParenToken */, node.expression ? node.expression.end : openParenPos, writePunctuation, node); @@ -102388,31 +105960,31 @@ var ts; emit(node.equalsGreaterThanToken); } function emitDeleteExpression(node) { - emitTokenWithComment(88 /* DeleteKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(89 /* DeleteKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitTypeOfExpression(node) { - emitTokenWithComment(111 /* TypeOfKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(112 /* TypeOfKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitVoidExpression(node) { - emitTokenWithComment(113 /* VoidKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(114 /* VoidKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitAwaitExpression(node) { - emitTokenWithComment(130 /* AwaitKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(131 /* AwaitKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitPrefixUnaryExpression(node) { writeTokenText(node.operator, writeOperator); if (shouldEmitWhitespaceBeforeOperand(node)) { writeSpace(); } - emitExpression(node.operand); + emitExpression(node.operand, parenthesizer.parenthesizeOperandOfPrefixUnary); } function shouldEmitWhitespaceBeforeOperand(node) { // In some cases, we need to emit a space between the operator and the operand. One obvious case @@ -102428,84 +106000,101 @@ 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 === 214 /* PrefixUnaryExpression */ + return operand.kind === 216 /* 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 */))); } function emitPostfixUnaryExpression(node) { - emitExpression(node.operand); + emitExpression(node.operand, parenthesizer.parenthesizeOperandOfPostfixUnary); writeTokenText(node.operator, writeOperator); } - var EmitBinaryExpressionState; - (function (EmitBinaryExpressionState) { - EmitBinaryExpressionState[EmitBinaryExpressionState["EmitLeft"] = 0] = "EmitLeft"; - EmitBinaryExpressionState[EmitBinaryExpressionState["EmitRight"] = 1] = "EmitRight"; - EmitBinaryExpressionState[EmitBinaryExpressionState["FinishEmit"] = 2] = "FinishEmit"; - })(EmitBinaryExpressionState || (EmitBinaryExpressionState = {})); - /** - * emitBinaryExpression includes an embedded work stack to attempt to handle as many nested binary expressions - * as possible without creating any additional stack frames. This can only be done when the emit pipeline does - * not require notification/substitution/comment/sourcemap decorations. - */ - function emitBinaryExpression(node) { - var nodeStack = [node]; - var stateStack = [0 /* EmitLeft */]; - var stackIndex = 0; - while (stackIndex >= 0) { - node = nodeStack[stackIndex]; - switch (stateStack[stackIndex]) { - case 0 /* EmitLeft */: { - maybePipelineEmitExpression(node.left); - break; - } - case 1 /* EmitRight */: { - var isCommaOperator = node.operatorToken.kind !== 27 /* CommaToken */; - var linesBeforeOperator = getLinesBetweenNodes(node, node.left, node.operatorToken); - var linesAfterOperator = getLinesBetweenNodes(node, node.operatorToken, node.right); - writeLinesAndIndent(linesBeforeOperator, isCommaOperator); - emitLeadingCommentsOfPosition(node.operatorToken.pos); - writeTokenNode(node.operatorToken, node.operatorToken.kind === 100 /* InKeyword */ ? writeKeyword : writeOperator); - emitTrailingCommentsOfPosition(node.operatorToken.end, /*prefixSpace*/ true); // Binary operators should have a space before the comment starts - writeLinesAndIndent(linesAfterOperator, /*writeSpaceIfNotIndenting*/ true); - maybePipelineEmitExpression(node.right); - break; - } - case 2 /* FinishEmit */: { - var linesBeforeOperator = getLinesBetweenNodes(node, node.left, node.operatorToken); - var linesAfterOperator = getLinesBetweenNodes(node, node.operatorToken, node.right); - decreaseIndentIf(linesBeforeOperator, linesAfterOperator); - stackIndex--; - break; - } - default: return ts.Debug.fail("Invalid state " + stateStack[stackIndex] + " for emitBinaryExpressionWorker"); + function createEmitBinaryExpression() { + return ts.createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, /*foldState*/ undefined); + function onEnter(node, state) { + if (state) { + state.stackIndex++; + state.preserveSourceNewlinesStack[state.stackIndex] = preserveSourceNewlines; + state.containerPosStack[state.stackIndex] = containerPos; + state.containerEndStack[state.stackIndex] = containerEnd; + state.declarationListContainerEndStack[state.stackIndex] = declarationListContainerEnd; + var emitComments_1 = state.shouldEmitCommentsStack[state.stackIndex] = shouldEmitComments(node); + var emitSourceMaps = state.shouldEmitSourceMapsStack[state.stackIndex] = shouldEmitSourceMaps(node); + onBeforeEmitNode === null || onBeforeEmitNode === void 0 ? void 0 : onBeforeEmitNode(node); + if (emitComments_1) + emitCommentsBeforeNode(node); + if (emitSourceMaps) + emitSourceMapsBeforeNode(node); + beforeEmitNode(node); } - } - function maybePipelineEmitExpression(next) { - // Advance the state of this unit of work, - stateStack[stackIndex]++; - // Then actually do the work of emitting the node `next` returned by the prior state - // The following section should be identical to `pipelineEmit` save it assumes EmitHint.Expression and offloads - // binary expression handling, where possible, to the contained work queue - // #region trampolinePipelineEmit - var savedLastNode = lastNode; - var savedLastSubstitution = lastSubstitution; - lastNode = next; - lastSubstitution = undefined; + else { + state = { + stackIndex: 0, + preserveSourceNewlinesStack: [undefined], + containerPosStack: [-1], + containerEndStack: [-1], + declarationListContainerEndStack: [-1], + shouldEmitCommentsStack: [false], + shouldEmitSourceMapsStack: [false], + }; + } + return state; + } + function onLeft(next, _workArea, parent) { + return maybeEmitExpression(next, parent, "left"); + } + function onOperator(operatorToken, _state, node) { + var isCommaOperator = operatorToken.kind !== 27 /* 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); + emitTrailingCommentsOfPosition(operatorToken.end, /*prefixSpace*/ true); // Binary operators should have a space before the comment starts + writeLinesAndIndent(linesAfterOperator, /*writeSpaceIfNotIndenting*/ true); + } + function onRight(next, _workArea, parent) { + return maybeEmitExpression(next, parent, "right"); + } + function onExit(node, state) { + var linesBeforeOperator = getLinesBetweenNodes(node, node.left, node.operatorToken); + var linesAfterOperator = getLinesBetweenNodes(node, node.operatorToken, node.right); + decreaseIndentIf(linesBeforeOperator, linesAfterOperator); + if (state.stackIndex > 0) { + var savedPreserveSourceNewlines = state.preserveSourceNewlinesStack[state.stackIndex]; + var savedContainerPos = state.containerPosStack[state.stackIndex]; + var savedContainerEnd = state.containerEndStack[state.stackIndex]; + var savedDeclarationListContainerEnd = state.declarationListContainerEndStack[state.stackIndex]; + var shouldEmitComments_1 = state.shouldEmitCommentsStack[state.stackIndex]; + var shouldEmitSourceMaps_1 = state.shouldEmitSourceMapsStack[state.stackIndex]; + afterEmitNode(savedPreserveSourceNewlines); + if (shouldEmitSourceMaps_1) + emitSourceMapsAfterNode(node); + if (shouldEmitComments_1) + emitCommentsAfterNode(node, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd); + onAfterEmitNode === null || onAfterEmitNode === void 0 ? void 0 : onAfterEmitNode(node); + state.stackIndex--; + } + } + function maybeEmitExpression(next, parent, side) { + var parenthesizerRule = side === "left" ? + parenthesizer.getParenthesizeLeftSideOfBinaryForOperator(parent.operatorToken.kind) : + parenthesizer.getParenthesizeRightSideOfBinaryForOperator(parent.operatorToken.kind); var pipelinePhase = getPipelinePhase(0 /* Notification */, 1 /* Expression */, next); - if (pipelinePhase === pipelineEmitWithHint && ts.isBinaryExpression(next)) { - // If the target pipeline phase is emit directly, and the next node's also a binary expression, - // skip all the intermediate indirection and push the expression directly onto the work stack - stackIndex++; - stateStack[stackIndex] = 0 /* EmitLeft */; - nodeStack[stackIndex] = next; + if (pipelinePhase === pipelineEmitWithSubstitution) { + ts.Debug.assertIsDefined(lastSubstitution); + next = parenthesizerRule(ts.cast(lastSubstitution, ts.isExpression)); + pipelinePhase = getNextPipelinePhase(1 /* Substitution */, 1 /* Expression */, next); + lastSubstitution = undefined; } - else { - pipelinePhase(1 /* Expression */, next); + if (pipelinePhase === pipelineEmitWithComments || + pipelinePhase === pipelineEmitWithSourceMaps || + pipelinePhase === pipelineEmitWithHint) { + if (ts.isBinaryExpression(next)) { + return next; + } } - ts.Debug.assert(lastNode === next); - lastNode = savedLastNode; - lastSubstitution = savedLastSubstitution; - // #endregion trampolinePipelineEmit + currentParenthesizerRule = parenthesizerRule; + pipelinePhase(1 /* Expression */, next); } } function emitConditionalExpression(node) { @@ -102513,16 +106102,16 @@ var ts; var linesAfterQuestion = getLinesBetweenNodes(node, node.questionToken, node.whenTrue); var linesBeforeColon = getLinesBetweenNodes(node, node.whenTrue, node.colonToken); var linesAfterColon = getLinesBetweenNodes(node, node.colonToken, node.whenFalse); - emitExpression(node.condition); + emitExpression(node.condition, parenthesizer.parenthesizeConditionOfConditionalExpression); writeLinesAndIndent(linesBeforeQuestion, /*writeSpaceIfNotIndenting*/ true); emit(node.questionToken); writeLinesAndIndent(linesAfterQuestion, /*writeSpaceIfNotIndenting*/ true); - emitExpression(node.whenTrue); + emitExpression(node.whenTrue, parenthesizer.parenthesizeBranchOfConditionalExpression); decreaseIndentIf(linesBeforeQuestion, linesAfterQuestion); writeLinesAndIndent(linesBeforeColon, /*writeSpaceIfNotIndenting*/ true); emit(node.colonToken); writeLinesAndIndent(linesAfterColon, /*writeSpaceIfNotIndenting*/ true); - emitExpression(node.whenFalse); + emitExpression(node.whenFalse, parenthesizer.parenthesizeBranchOfConditionalExpression); decreaseIndentIf(linesBeforeColon, linesAfterColon); } function emitTemplateExpression(node) { @@ -102530,24 +106119,24 @@ var ts; emitList(node, node.templateSpans, 262144 /* TemplateExpressionSpans */); } function emitYieldExpression(node) { - emitTokenWithComment(124 /* YieldKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(125 /* YieldKeyword */, node.pos, writeKeyword, node); emit(node.asteriskToken); - emitExpressionWithLeadingSpace(node.expression); + emitExpressionWithLeadingSpace(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); } - function emitSpreadExpression(node) { + function emitSpreadElement(node) { emitTokenWithComment(25 /* DotDotDotToken */, node.pos, writePunctuation, node); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitClassExpression(node) { generateNameIfNeeded(node.name); emitClassDeclarationOrExpression(node); } function emitExpressionWithTypeArguments(node) { - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); emitTypeArguments(node, node.typeArguments); } function emitAsExpression(node) { - emitExpression(node.expression); + emitExpression(node.expression, /*parenthesizerRules*/ undefined); if (node.type) { writeSpace(); writeKeyword("as"); @@ -102556,7 +106145,7 @@ var ts; } } function emitNonNullExpression(node) { - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); writeOperator("!"); } function emitMetaProperty(node) { @@ -102599,7 +106188,7 @@ var ts; } } function emitExpressionStatement(node) { - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfExpressionStatement); // Emit semicolon in non json files // or if json file that created synthesized expression(eg.define expression statement when --out and amd code generation) if (!ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) { @@ -102607,7 +106196,7 @@ var ts; } } function emitIfStatement(node) { - var openParenPos = emitTokenWithComment(98 /* IfKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(99 /* IfKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -102615,8 +106204,8 @@ var ts; emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { writeLineOrSpace(node, node.thenStatement, node.elseStatement); - emitTokenWithComment(90 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 234 /* IfStatement */) { + emitTokenWithComment(91 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); + if (node.elseStatement.kind === 236 /* IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -102626,14 +106215,14 @@ var ts; } } function emitWhileClause(node, startPos) { - var openParenPos = emitTokenWithComment(114 /* WhileKeyword */, startPos, writeKeyword, node); + var openParenPos = emitTokenWithComment(115 /* WhileKeyword */, startPos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); } function emitDoStatement(node) { - emitTokenWithComment(89 /* DoKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(90 /* DoKeyword */, node.pos, writeKeyword, node); emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement) && !preserveSourceNewlines) { writeSpace(); @@ -102649,7 +106238,7 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { - var openParenPos = emitTokenWithComment(96 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); var pos = emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node); emitForBinding(node.initializer); @@ -102661,25 +106250,25 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { - var openParenPos = emitTokenWithComment(96 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(100 /* InKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(101 /* InKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { - var openParenPos = emitTokenWithComment(96 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitWithTrailingSpace(node.awaitModifier); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(156 /* OfKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(158 /* OfKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); @@ -102687,7 +106276,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 250 /* VariableDeclarationList */) { + if (node.kind === 252 /* VariableDeclarationList */) { emit(node); } else { @@ -102696,12 +106285,12 @@ var ts; } } function emitContinueStatement(node) { - emitTokenWithComment(85 /* ContinueKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(86 /* ContinueKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } function emitBreakStatement(node) { - emitTokenWithComment(80 /* BreakKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(81 /* BreakKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } @@ -102724,18 +106313,18 @@ var ts; } pos = writeTokenText(token, writer, pos); if (isSimilarNode && contextNode.end !== pos) { - var isJsxExprContext = contextNode.kind === 283 /* JsxExpression */; + var isJsxExprContext = contextNode.kind === 285 /* JsxExpression */; emitTrailingCommentsOfPosition(pos, /*prefixSpace*/ !isJsxExprContext, /*forceNoNewline*/ isJsxExprContext); } return pos; } function emitReturnStatement(node) { - emitTokenWithComment(104 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); + emitTokenWithComment(105 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); emitExpressionWithLeadingSpace(node.expression); writeTrailingSemicolon(); } function emitWithStatement(node) { - var openParenPos = emitTokenWithComment(115 /* WithKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(116 /* WithKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -102743,7 +106332,7 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { - var openParenPos = emitTokenWithComment(106 /* SwitchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(107 /* SwitchKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -102758,12 +106347,12 @@ var ts; emit(node.statement); } function emitThrowStatement(node) { - emitTokenWithComment(108 /* ThrowKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(109 /* ThrowKeyword */, node.pos, writeKeyword, node); emitExpressionWithLeadingSpace(node.expression); writeTrailingSemicolon(); } function emitTryStatement(node) { - emitTokenWithComment(110 /* TryKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(111 /* TryKeyword */, node.pos, writeKeyword, node); writeSpace(); emit(node.tryBlock); if (node.catchClause) { @@ -102772,13 +106361,13 @@ var ts; } if (node.finallyBlock) { writeLineOrSpace(node, node.catchClause || node.tryBlock, node.finallyBlock); - emitTokenWithComment(95 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); + emitTokenWithComment(96 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); writeSpace(); emit(node.finallyBlock); } } function emitDebuggerStatement(node) { - writeToken(86 /* DebuggerKeyword */, node.pos, writeKeyword); + writeToken(87 /* DebuggerKeyword */, node.pos, writeKeyword); writeTrailingSemicolon(); } // @@ -102788,7 +106377,7 @@ var ts; emit(node.name); emit(node.exclamationToken); emitTypeAnnotation(node.type); - emitInitializer(node.initializer, node.type ? node.type.end : node.name.end, node); + emitInitializer(node.initializer, node.type ? node.type.end : node.name.end, node, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitVariableDeclarationList(node) { writeKeyword(ts.isLet(node) ? "let" : ts.isVarConst(node) ? "const" : "var"); @@ -102807,9 +106396,6 @@ var ts; emitIdentifierName(node.name); emitSignatureAndBody(node, emitSignatureHead); } - function emitBlockCallback(_hint, body) { - emitBlockFunctionBody(body); - } function emitSignatureAndBody(node, emitSignatureHead) { var body = node.body; if (body) { @@ -102822,12 +106408,7 @@ var ts; ts.forEach(node.parameters, generateNames); generateNames(node.body); emitSignatureHead(node); - if (onEmitNode) { - onEmitNode(4 /* Unspecified */, body, emitBlockCallback); - } - else { - emitBlockFunctionBody(body); - } + emitBlockFunctionBody(body); popNameGenerationScope(node); if (indentedFlag) { decreaseIndent(); @@ -102836,7 +106417,7 @@ var ts; else { emitSignatureHead(node); writeSpace(); - emitExpression(body); + emitExpression(body, parenthesizer.parenthesizeConciseBodyOfArrowFunction); } } else { @@ -102880,6 +106461,7 @@ var ts; return true; } function emitBlockFunctionBody(body) { + onBeforeEmitNode === null || onBeforeEmitNode === void 0 ? void 0 : onBeforeEmitNode(body); writeSpace(); writePunctuation("{"); increaseIndent(); @@ -102894,6 +106476,7 @@ var ts; } decreaseIndent(); writeToken(19 /* CloseBraceToken */, body.statements.end, writePunctuation, body); + onAfterEmitNode === null || onAfterEmitNode === void 0 ? void 0 : onAfterEmitNode(body); } function emitBlockFunctionBodyOnSingleLine(body) { emitBlockFunctionBodyWorker(body, /*emitBlockFunctionBodyOnSingleLine*/ true); @@ -102909,7 +106492,7 @@ var ts; increaseIndent(); } else { - emitList(body, body.statements, 1 /* MultiLineFunctionBodyStatements */, statementOffset); + emitList(body, body.statements, 1 /* MultiLineFunctionBodyStatements */, /*parenthesizerRule*/ undefined, statementOffset); } } function emitClassDeclaration(node) { @@ -102984,7 +106567,7 @@ var ts; var body = node.body; if (!body) return writeTrailingSemicolon(); - while (body.kind === 256 /* ModuleDeclaration */) { + while (body && ts.isModuleDeclaration(body)) { writePunctuation("."); emit(body.name); body = body.body; @@ -103005,21 +106588,21 @@ var ts; } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(99 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(100 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.isTypeOnly) { - emitTokenWithComment(149 /* TypeKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(150 /* TypeKeyword */, node.pos, writeKeyword, node); writeSpace(); } emit(node.name); writeSpace(); - emitTokenWithComment(62 /* EqualsToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(63 /* EqualsToken */, node.name.end, writePunctuation, node); writeSpace(); emitModuleReference(node.moduleReference); writeTrailingSemicolon(); } function emitModuleReference(node) { - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { emitExpression(node); } else { @@ -103028,12 +106611,12 @@ var ts; } function emitImportDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(99 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(100 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.importClause) { emit(node.importClause); writeSpace(); - emitTokenWithComment(153 /* FromKeyword */, node.importClause.end, writeKeyword, node); + emitTokenWithComment(154 /* FromKeyword */, node.importClause.end, writeKeyword, node); writeSpace(); } emitExpression(node.moduleSpecifier); @@ -103041,7 +106624,7 @@ var ts; } function emitImportClause(node) { if (node.isTypeOnly) { - emitTokenWithComment(149 /* TypeKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(150 /* TypeKeyword */, node.pos, writeKeyword, node); writeSpace(); } emit(node.name); @@ -103054,7 +106637,7 @@ var ts; function emitNamespaceImport(node) { var asPos = emitTokenWithComment(41 /* AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(126 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(127 /* AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -103065,23 +106648,25 @@ var ts; emitImportOrExportSpecifier(node); } function emitExportAssignment(node) { - var nextPos = emitTokenWithComment(92 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isExportEquals) { - emitTokenWithComment(62 /* EqualsToken */, nextPos, writeOperator, node); + emitTokenWithComment(63 /* EqualsToken */, nextPos, writeOperator, node); } else { - emitTokenWithComment(87 /* DefaultKeyword */, nextPos, writeKeyword, node); + emitTokenWithComment(88 /* DefaultKeyword */, nextPos, writeKeyword, node); } writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, node.isExportEquals ? + parenthesizer.getParenthesizeRightSideOfBinaryForOperator(63 /* EqualsToken */) : + parenthesizer.parenthesizeExpressionOfExportDefault); writeTrailingSemicolon(); } function emitExportDeclaration(node) { - var nextPos = emitTokenWithComment(92 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isTypeOnly) { - nextPos = emitTokenWithComment(149 /* TypeKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(150 /* TypeKeyword */, nextPos, writeKeyword, node); writeSpace(); } if (node.exportClause) { @@ -103093,18 +106678,18 @@ var ts; if (node.moduleSpecifier) { writeSpace(); var fromPos = node.exportClause ? node.exportClause.end : nextPos; - emitTokenWithComment(153 /* FromKeyword */, fromPos, writeKeyword, node); + emitTokenWithComment(154 /* FromKeyword */, fromPos, writeKeyword, node); writeSpace(); emitExpression(node.moduleSpecifier); } writeTrailingSemicolon(); } function emitNamespaceExportDeclaration(node) { - var nextPos = emitTokenWithComment(92 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(126 /* AsKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(127 /* AsKeyword */, nextPos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(140 /* NamespaceKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(141 /* NamespaceKeyword */, nextPos, writeKeyword, node); writeSpace(); emit(node.name); writeTrailingSemicolon(); @@ -103112,7 +106697,7 @@ var ts; function emitNamespaceExport(node) { var asPos = emitTokenWithComment(41 /* AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(126 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(127 /* AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -103131,7 +106716,7 @@ var ts; if (node.propertyName) { emit(node.propertyName); writeSpace(); - emitTokenWithComment(126 /* AsKeyword */, node.propertyName.end, writeKeyword, node); + emitTokenWithComment(127 /* AsKeyword */, node.propertyName.end, writeKeyword, node); writeSpace(); } emit(node.name); @@ -103233,7 +106818,7 @@ var ts; } } function emitJsxTagName(node) { - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { emitExpression(node); } else { @@ -103244,13 +106829,13 @@ var ts; // Clauses // function emitCaseClause(node) { - emitTokenWithComment(81 /* CaseKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(82 /* CaseKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); emitCaseOrDefaultClauseRest(node, node.statements, node.expression.end); } function emitDefaultClause(node) { - var pos = emitTokenWithComment(87 /* DefaultKeyword */, node.pos, writeKeyword, node); + var pos = emitTokenWithComment(88 /* DefaultKeyword */, node.pos, writeKeyword, node); emitCaseOrDefaultClauseRest(node, node.statements, pos); } function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) { @@ -103278,7 +106863,7 @@ var ts; emitList(node, node.types, 528 /* HeritageClauseTypes */); } function emitCatchClause(node) { - var openParenPos = emitTokenWithComment(82 /* CatchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(83 /* CatchKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.variableDeclaration) { emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); @@ -103307,7 +106892,7 @@ var ts; var commentRange = ts.getCommentRange(initializer); emitTrailingCommentsOfPosition(commentRange.pos); } - emitExpression(initializer); + emitExpression(initializer, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitShorthandPropertyAssignment(node) { emit(node.name); @@ -103315,13 +106900,13 @@ var ts; writeSpace(); writePunctuation("="); writeSpace(); - emitExpression(node.objectAssignmentInitializer); + emitExpression(node.objectAssignmentInitializer, parenthesizer.parenthesizeExpressionForDisallowedComma); } } function emitSpreadAssignment(node) { if (node.expression) { emitTokenWithComment(25 /* DotDotDotToken */, node.pos, writePunctuation, node); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); } } // @@ -103329,7 +106914,7 @@ var ts; // function emitEnumMember(node) { emit(node.name); - emitInitializer(node.initializer, node.name.end, node); + emitInitializer(node.initializer, node.name.end, node, parenthesizer.parenthesizeExpressionForDisallowedComma); } // // JSDoc @@ -103337,18 +106922,21 @@ var ts; function emitJSDoc(node) { write("/**"); if (node.comment) { - var lines = node.comment.split(/\r\n?|\n/g); - for (var _a = 0, lines_2 = lines; _a < lines_2.length; _a++) { - var line = lines_2[_a]; - writeLine(); - writeSpace(); - writePunctuation("*"); - writeSpace(); - write(line); + var text = ts.getTextOfJSDocComment(node.comment); + if (text) { + var lines = text.split(/\r\n?|\n/g); + for (var _a = 0, lines_2 = lines; _a < lines_2.length; _a++) { + var line = lines_2[_a]; + writeLine(); + writeSpace(); + writePunctuation("*"); + writeSpace(); + write(line); + } } } if (node.tags) { - if (node.tags.length === 1 && node.tags[0].kind === 329 /* JSDocTypeTag */ && !node.comment) { + if (node.tags.length === 1 && node.tags[0].kind === 337 /* JSDocTypeTag */ && !node.comment) { writeSpace(); emit(node.tags[0]); } @@ -103393,7 +106981,7 @@ var ts; function emitJSDocTypedefTag(tag) { emitJSDocTagName(tag.tagName); if (tag.typeExpression) { - if (tag.typeExpression.kind === 301 /* JSDocTypeExpression */) { + if (tag.typeExpression.kind === 303 /* JSDocTypeExpression */) { emitJSDocTypeExpression(tag.typeExpression); } else { @@ -103412,7 +107000,7 @@ var ts; emit(tag.fullName); } emitJSDocComment(tag.comment); - if (tag.typeExpression && tag.typeExpression.kind === 312 /* JSDocTypeLiteral */) { + if (tag.typeExpression && tag.typeExpression.kind === 316 /* JSDocTypeLiteral */) { emitJSDocTypeLiteral(tag.typeExpression); } } @@ -103465,9 +107053,10 @@ var ts; emit(tagName); } function emitJSDocComment(comment) { - if (comment) { + var text = ts.getTextOfJSDocComment(comment); + if (text) { writeSpace(); - write(comment); + write(text); } } function emitJSDocTypeExpression(typeExpression) { @@ -103570,7 +107159,7 @@ var ts; emitHelpers(node); var index = ts.findIndex(statements, function (statement) { return !ts.isPrologueDirective(statement); }); emitTripleSlashDirectivesIfNeeded(node); - emitList(node, statements, 1 /* MultiLine */, index === -1 ? statements.length : index); + emitList(node, statements, 1 /* MultiLine */, /*parenthesizerRule*/ undefined, index === -1 ? statements.length : index); popNameGenerationScope(node); } // Transformation nodes @@ -103578,7 +107167,7 @@ var ts; emitExpression(node.expression); } function emitCommaList(node) { - emitExpressionList(node, node.elements, 528 /* CommaListElements */); + emitExpressionList(node, node.elements, 528 /* CommaListElements */, /*parenthesizerRule*/ undefined); } /** * Emits any prologue directives at the start of a Statement list, returning the @@ -103724,12 +107313,12 @@ var ts; emit(node); } } - function emitInitializer(node, equalCommentStartPos, container) { + function emitInitializer(node, equalCommentStartPos, container, parenthesizerRule) { if (node) { writeSpace(); - emitTokenWithComment(62 /* EqualsToken */, equalCommentStartPos, writeOperator, container); + emitTokenWithComment(63 /* EqualsToken */, equalCommentStartPos, writeOperator, container); writeSpace(); - emitExpression(node); + emitExpression(node, parenthesizerRule); } } function emitNodeWithPrefix(prefix, prefixWriter, node, emit) { @@ -103744,10 +107333,10 @@ var ts; emit(node); } } - function emitExpressionWithLeadingSpace(node) { + function emitExpressionWithLeadingSpace(node, parenthesizerRule) { if (node) { writeSpace(); - emitExpression(node); + emitExpression(node, parenthesizerRule); } } function emitWithTrailingSpace(node) { @@ -103777,7 +107366,7 @@ var ts; emitList(parentNode, decorators, 2146305 /* Decorators */); } function emitTypeArguments(parentNode, typeArguments) { - emitList(parentNode, typeArguments, 53776 /* TypeArguments */); + emitList(parentNode, typeArguments, 53776 /* TypeArguments */, parenthesizer.parenthesizeMemberOfElementType); } function emitTypeParameters(parentNode, typeParameters) { if (ts.isFunctionLike(parentNode) && parentNode.typeArguments) { // Quick info uses type arguments in place of type parameters on instantiated signatures @@ -103816,12 +107405,6 @@ var ts; function emitParametersForIndexSignature(parentNode, parameters) { emitList(parentNode, parameters, 8848 /* IndexSignatureParameters */); } - function emitList(parentNode, children, format, start, count) { - emitNodeList(emit, parentNode, children, format, start, count); - } - function emitExpressionList(parentNode, children, format, start, count) { - emitNodeList(emitExpression, parentNode, children, format, start, count); // TODO: GH#18217 - } function writeDelimiter(format) { switch (format & 60 /* DelimitersMask */) { case 0 /* None */: @@ -103844,7 +107427,13 @@ var ts; break; } } - function emitNodeList(emit, parentNode, children, format, start, count) { + function emitList(parentNode, children, format, parenthesizerRule, start, count) { + emitNodeList(emit, parentNode, children, format, parenthesizerRule, start, count); + } + function emitExpressionList(parentNode, children, format, parenthesizerRule, start, count) { + emitNodeList(emitExpression, parentNode, children, format, parenthesizerRule, start, count); + } + function emitNodeList(emit, parentNode, children, format, parenthesizerRule, start, count) { if (start === void 0) { start = 0; } if (count === void 0) { count = children ? children.length - start : 0; } var isUndefined = children === undefined; @@ -103863,8 +107452,7 @@ var ts; } if (format & 15360 /* BracketsMask */) { writePunctuation(getOpeningBracket(format)); - if (isEmpty && !isUndefined) { - // TODO: GH#18217 + if (isEmpty && children) { emitTrailingCommentsOfPosition(children.pos, /*prefixSpace*/ true); // Emit comments within empty bracketed lists } } @@ -103873,7 +107461,7 @@ var ts; } if (isEmpty) { // Write a line terminator if the parent node was multi-line - if (format & 1 /* MultiLine */ && !(preserveSourceNewlines && ts.rangeIsOnSingleLine(parentNode, currentSourceFile))) { + if (format & 1 /* MultiLine */ && !(preserveSourceNewlines && (!parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) { writeLine(); } else if (format & 256 /* SpaceBetweenBraces */ && !(format & 524288 /* NoSpaceIfEmpty */)) { @@ -103881,6 +107469,7 @@ var ts; } } else { + ts.Debug.type(children); // Write the opening line terminator or leading whitespace. var mayEmitInterveningComments = (format & 262144 /* NoInterveningComments */) === 0; var shouldEmitInterveningComments = mayEmitInterveningComments; @@ -103915,7 +107504,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.end) { + if (format & 60 /* DelimitersMask */ && previousSibling.end !== (parentNode ? parentNode.end : -1)) { emitLeadingCommentsOfPosition(previousSibling.end); } writeDelimiter(format); @@ -103948,7 +107537,12 @@ var ts; shouldEmitInterveningComments = mayEmitInterveningComments; } nextListElementPos = child.pos; - emit(child); + if (emit.length === 1) { + emit(child); + } + else { + emit(child, parenthesizerRule); + } if (shouldDecreaseIndentAfterEmit) { decreaseIndent(); shouldDecreaseIndentAfterEmit = false; @@ -103973,7 +107567,7 @@ var ts; // 2 // /* end of element 2 */ // ]; - if (previousSibling && parentNode.end !== previousSibling.end && (format & 60 /* DelimitersMask */) && !skipTrailingComments) { + if (previousSibling && (parentNode ? parentNode.end : -1) !== previousSibling.end && (format & 60 /* DelimitersMask */) && !skipTrailingComments) { emitLeadingCommentsOfPosition(hasTrailingComma && (children === null || children === void 0 ? void 0 : children.end) ? children.end : previousSibling.end); } // Decrease the indent, if requested. @@ -103994,8 +107588,7 @@ var ts; onAfterEmitNodeArray(children); } if (format & 15360 /* BracketsMask */) { - if (isEmpty && !isUndefined) { - // TODO: GH#18217 + if (isEmpty && children) { emitLeadingCommentsOfPosition(children.end); // Emit leading comments within empty lists } writePunctuation(getClosingBracket(format)); @@ -104126,7 +107719,7 @@ var ts; } var firstChild_1 = children[0]; if (firstChild_1 === undefined) { - return ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; + return !parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; } if (firstChild_1.pos === nextListElementPos) { // If this child starts at the beginning of a list item in a parent list, its leading @@ -104150,7 +107743,8 @@ var ts; // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } - if (!ts.positionIsSynthesized(parentNode.pos) && + if (parentNode && + !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(firstChild_1) && (!firstChild_1.parent || ts.getOriginalNode(firstChild_1.parent) === ts.getOriginalNode(parentNode))) { if (preserveSourceNewlines) { @@ -104173,10 +107767,10 @@ var ts; // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } - else if (!ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode) && previousNode.parent === nextNode.parent) { - if (preserveSourceNewlines) { - return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); - } + else if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) { + return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); + } + else if (!preserveSourceNewlines && !ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) { return ts.rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile) ? 0 : 1; } else if (synthesizedNodeStartsOnNewLine(previousNode, format) || synthesizedNodeStartsOnNewLine(nextNode, format)) { @@ -104195,9 +107789,9 @@ var ts; } var lastChild = ts.lastOrUndefined(children); if (lastChild === undefined) { - return ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; + return !parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; } - if (!ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) { + if (parentNode && !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) { if (preserveSourceNewlines) { var end_1 = ts.isNodeArray(children) && !ts.positionIsSynthesized(children.end) ? children.end : lastChild.end; return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenPositionAndNextNonWhitespaceCharacter(end_1, parentNode.end, currentSourceFile, includeComments); }); @@ -104283,7 +107877,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 207 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 209 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -104353,84 +107947,84 @@ var ts; if (!node) return; switch (node.kind) { - case 230 /* Block */: + case 232 /* Block */: ts.forEach(node.statements, generateNames); break; - case 245 /* LabeledStatement */: - case 243 /* WithStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: + case 247 /* LabeledStatement */: + case 245 /* WithStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: generateNames(node.statement); break; - case 234 /* IfStatement */: + case 236 /* IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 237 /* ForStatement */: - case 239 /* ForOfStatement */: - case 238 /* ForInStatement */: + case 239 /* ForStatement */: + case 241 /* ForOfStatement */: + case 240 /* ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: generateNames(node.caseBlock); break; - case 258 /* CaseBlock */: + case 260 /* CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 284 /* CaseClause */: - case 285 /* DefaultClause */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 247 /* TryStatement */: + case 249 /* TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 287 /* CatchClause */: + case 289 /* CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: generateNames(node.declarationList); break; - case 250 /* VariableDeclarationList */: + case 252 /* VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 249 /* VariableDeclaration */: - case 160 /* Parameter */: - case 198 /* BindingElement */: - case 252 /* ClassDeclaration */: + case 251 /* VariableDeclaration */: + case 162 /* Parameter */: + case 200 /* BindingElement */: + case 254 /* ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 196 /* ObjectBindingPattern */: - case 197 /* ArrayBindingPattern */: + case 198 /* ObjectBindingPattern */: + case 199 /* ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: generateNames(node.importClause); break; - case 262 /* ImportClause */: + case 264 /* ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: generateNameIfNeeded(node.name); break; - case 269 /* NamespaceExport */: + case 271 /* NamespaceExport */: generateNameIfNeeded(node.name); break; - case 264 /* NamedImports */: + case 266 /* NamedImports */: ts.forEach(node.elements, generateNames); break; - case 265 /* ImportSpecifier */: + case 267 /* ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -104439,12 +108033,12 @@ var ts; if (!node) return; switch (node.kind) { - case 288 /* PropertyAssignment */: - case 289 /* ShorthandPropertyAssignment */: - case 163 /* PropertyDeclaration */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 290 /* PropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: + case 165 /* PropertyDeclaration */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: generateNameIfNeeded(node.name); break; } @@ -104624,25 +108218,25 @@ var ts; */ function generateNameForNode(node, flags) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 256 /* ModuleDeclaration */: - case 255 /* EnumDeclaration */: + case 258 /* ModuleDeclaration */: + case 257 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 261 /* ImportDeclaration */: - case 267 /* ExportDeclaration */: + case 263 /* ImportDeclaration */: + case 269 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 251 /* FunctionDeclaration */: - case 252 /* ClassDeclaration */: - case 266 /* ExportAssignment */: + case 253 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: + case 268 /* ExportAssignment */: return generateNameForExportDefault(); - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: return generateNameForClassExpression(); - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return generateNameForMethodOrAccessor(node); - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return makeTempVariableName(0 /* Auto */, /*reserveInNestedScopes*/ true); default: return makeTempVariableName(0 /* Auto */); @@ -104685,25 +108279,45 @@ var ts; } // Comments function pipelineEmitWithComments(hint, node) { - ts.Debug.assert(lastNode === node || lastSubstitution === node); + var pipelinePhase = getNextPipelinePhase(2 /* Comments */, hint, node); + var savedContainerPos = containerPos; + var savedContainerEnd = containerEnd; + var savedDeclarationListContainerEnd = declarationListContainerEnd; + emitCommentsBeforeNode(node); + pipelinePhase(hint, node); + emitCommentsAfterNode(node, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd); + } + function emitCommentsBeforeNode(node) { + var emitFlags = ts.getEmitFlags(node); + var commentRange = ts.getCommentRange(node); + // Emit leading comments + emitLeadingCommentsOfNode(node, emitFlags, commentRange.pos, commentRange.end); + if (emitFlags & 2048 /* NoNestedComments */) { + commentsDisabled = true; + } + } + function emitCommentsAfterNode(node, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd) { + var emitFlags = ts.getEmitFlags(node); + var commentRange = ts.getCommentRange(node); + // Emit trailing comments + if (emitFlags & 2048 /* NoNestedComments */) { + commentsDisabled = false; + } + emitTrailingCommentsOfNode(node, emitFlags, commentRange.pos, commentRange.end, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd); + } + function emitLeadingCommentsOfNode(node, emitFlags, pos, end) { enterComment(); hasWrittenComment = false; - var emitFlags = ts.getEmitFlags(node); - var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; - var isEmittedNode = node.kind !== 335 /* NotEmittedStatement */; // 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 */; // Save current container state on the stack. - var savedContainerPos = containerPos; - var savedContainerEnd = containerEnd; - var savedDeclarationListContainerEnd = declarationListContainerEnd; 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); + emitLeadingComments(pos, /*isEmittedNode*/ node.kind !== 343 /* NotEmittedStatement */); } if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512 /* NoLeadingComments */) !== 0)) { // Advance the container position if comments get emitted or if they've been disabled explicitly using NoLeadingComments. @@ -104714,23 +108328,17 @@ var ts; 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 === 250 /* VariableDeclarationList */) { + if (node.kind === 252 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } } ts.forEach(ts.getSyntheticLeadingComments(node), emitLeadingSynthesizedComment); exitComment(); - var pipelinePhase = getNextPipelinePhase(2 /* Comments */, hint, node); - if (emitFlags & 2048 /* NoNestedComments */) { - commentsDisabled = true; - pipelinePhase(hint, node); - commentsDisabled = false; - } - else { - pipelinePhase(hint, node); - } + } + function emitTrailingCommentsOfNode(node, emitFlags, pos, end, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd) { enterComment(); + var skipTrailingComments = end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0 || node.kind === 11 /* JsxText */; ts.forEach(ts.getSyntheticTrailingComments(node), emitTrailingSynthesizedComment); if ((pos > 0 || end > 0) && pos !== end) { // Restore previous container state. @@ -104739,12 +108347,11 @@ 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 && isEmittedNode) { + if (!skipTrailingComments && node.kind !== 343 /* NotEmittedStatement */) { emitTrailingComments(end); } } exitComment(); - ts.Debug.assert(lastNode === node || lastSubstitution === node); } function emitLeadingSynthesizedComment(comment) { if (comment.hasLeadingNewline || comment.kind === 2 /* SingleLineCommentTrivia */) { @@ -104804,6 +108411,23 @@ var ts; } exitComment(); } + function siblingNodePositionsAreComparable(previousNode, nextNode) { + if (ts.nodeIsSynthesized(previousNode) || ts.nodeIsSynthesized(nextNode)) { + return false; + } + if (nextNode.pos < previousNode.end) { + return false; + } + previousNode = ts.getOriginalNode(previousNode); + nextNode = ts.getOriginalNode(nextNode); + var parent = previousNode.parent; + if (!parent || parent !== nextNode.parent) { + return false; + } + var parentNodeArray = ts.getContainingNodeArray(previousNode); + var prevNodeIndex = parentNodeArray === null || parentNodeArray === void 0 ? void 0 : parentNodeArray.indexOf(previousNode); + return prevNodeIndex !== undefined && prevNodeIndex > -1 && parentNodeArray.indexOf(nextNode) === prevNodeIndex + 1; + } function emitLeadingComments(pos, isEmittedNode) { hasWrittenComment = false; if (isEmittedNode) { @@ -104976,42 +108600,49 @@ var ts; } return node.parsedSourceMap || undefined; } - function pipelineEmitWithSourceMap(hint, node) { - ts.Debug.assert(lastNode === node || lastSubstitution === node); + function pipelineEmitWithSourceMaps(hint, node) { var pipelinePhase = getNextPipelinePhase(3 /* SourceMaps */, hint, node); - if (ts.isUnparsedSource(node) || ts.isUnparsedPrepend(node)) { - pipelinePhase(hint, node); - } - else if (ts.isUnparsedNode(node)) { + emitSourceMapsBeforeNode(node); + pipelinePhase(hint, node); + emitSourceMapsAfterNode(node); + } + function emitSourceMapsBeforeNode(node) { + var emitFlags = ts.getEmitFlags(node); + var sourceMapRange = ts.getSourceMapRange(node); + // Emit leading sourcemap + if (ts.isUnparsedNode(node)) { + ts.Debug.assertIsDefined(node.parent, "UnparsedNodes must have parent pointers"); var parsed = getParsedSourceMap(node.parent); if (parsed && sourceMapGenerator) { sourceMapGenerator.appendSourceMap(writer.getLine(), writer.getColumn(), parsed, node.parent.sourceMapPath, node.parent.getLineAndCharacterOfPosition(node.pos), node.parent.getLineAndCharacterOfPosition(node.end)); } - pipelinePhase(hint, node); } else { - var _a = ts.getSourceMapRange(node), pos = _a.pos, end = _a.end, _b = _a.source, source = _b === void 0 ? sourceMapSource : _b; - var emitFlags = ts.getEmitFlags(node); - if (node.kind !== 335 /* NotEmittedStatement */ + var source = sourceMapRange.source || sourceMapSource; + if (node.kind !== 343 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 - && pos >= 0) { - emitSourcePos(source, skipSourceTrivia(source, pos)); + && sourceMapRange.pos >= 0) { + emitSourcePos(sourceMapRange.source || sourceMapSource, skipSourceTrivia(source, sourceMapRange.pos)); } if (emitFlags & 64 /* NoNestedSourceMaps */) { sourceMapsDisabled = true; - pipelinePhase(hint, node); - sourceMapsDisabled = false; } - else { - pipelinePhase(hint, node); + } + } + function emitSourceMapsAfterNode(node) { + var emitFlags = ts.getEmitFlags(node); + var sourceMapRange = ts.getSourceMapRange(node); + // Emit trailing sourcemap + if (!ts.isUnparsedNode(node)) { + if (emitFlags & 64 /* NoNestedSourceMaps */) { + sourceMapsDisabled = false; } - if (node.kind !== 335 /* NotEmittedStatement */ + if (node.kind !== 343 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 - && end >= 0) { - emitSourcePos(source, end); + && sourceMapRange.end >= 0) { + emitSourcePos(sourceMapRange.source || sourceMapSource, sourceMapRange.end); } } - ts.Debug.assert(lastNode === node || lastSubstitution === node); } /** * Skips trivia such as comments and white-space that can be optionally overridden by the source-map source @@ -105163,12 +108794,22 @@ var ts; return ts.getBaseFileName(ts.normalizePath(fileName)); } function createCachedFileSystemEntries(rootDir, rootDirPath) { - var resultFromHost = { - files: ts.map(host.readDirectory(rootDir, /*extensions*/ undefined, /*exclude*/ undefined, /*include*/ ["*.*"]), getBaseNameOfFileName) || [], - directories: host.getDirectories(rootDir) || [] - }; - cachedReadDirectoryResult.set(ts.ensureTrailingDirectorySeparator(rootDirPath), resultFromHost); - return resultFromHost; + var _a; + if (!host.realpath || ts.ensureTrailingDirectorySeparator(toPath(host.realpath(rootDir))) === rootDirPath) { + var resultFromHost = { + files: ts.map(host.readDirectory(rootDir, /*extensions*/ undefined, /*exclude*/ undefined, /*include*/ ["*.*"]), getBaseNameOfFileName) || [], + directories: host.getDirectories(rootDir) || [] + }; + cachedReadDirectoryResult.set(ts.ensureTrailingDirectorySeparator(rootDirPath), resultFromHost); + return resultFromHost; + } + // If the directory is symlink do not cache the result + if ((_a = host.directoryExists) === null || _a === void 0 ? void 0 : _a.call(host, rootDir)) { + cachedReadDirectoryResult.set(rootDirPath, false); + return false; + } + // Non existing directory + return undefined; } /** * If the readDirectory result was already cached, it returns that @@ -105243,17 +108884,32 @@ var ts; } function readDirectory(rootDir, extensions, excludes, includes, depth) { var rootDirPath = toPath(rootDir); - var result = tryReadDirectory(rootDir, rootDirPath); - if (result) { + var rootResult = tryReadDirectory(rootDir, rootDirPath); + var rootSymLinkResult; + if (rootResult !== undefined) { return ts.matchFiles(rootDir, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, depth, getFileSystemEntries, realpath); } return host.readDirectory(rootDir, extensions, excludes, includes, depth); function getFileSystemEntries(dir) { var path = toPath(dir); if (path === rootDirPath) { - return result; - } - return tryReadDirectory(dir, path) || ts.emptyFileSystemEntries; + return rootResult || getFileSystemEntriesFromHost(dir, path); + } + var result = tryReadDirectory(dir, path); + return result !== undefined ? + result || getFileSystemEntriesFromHost(dir, path) : + ts.emptyFileSystemEntries; + } + function getFileSystemEntriesFromHost(dir, path) { + if (rootSymLinkResult && path === rootDirPath) + return rootSymLinkResult; + var result = { + files: ts.map(host.readDirectory(dir, /*extensions*/ undefined, /*exclude*/ undefined, /*include*/ ["*.*"]), getBaseNameOfFileName) || ts.emptyArray, + directories: host.getDirectories(dir) || ts.emptyArray + }; + if (path === rootDirPath) + rootSymLinkResult = result; + return result; } } function realpath(s) { @@ -105261,7 +108917,7 @@ var ts; } function addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath) { var existingResult = getCachedFileSystemEntries(fileOrDirectoryPath); - if (existingResult) { + if (existingResult !== undefined) { // Just clear the cache for now // For now just clear the cache, since this could mean that multiple level entries might need to be re-evaluated clearCache(); @@ -105321,9 +108977,9 @@ var ts; /** * Updates the map of shared extended config file watches with a new set of extended config files from a base config file of the project */ - function updateSharedExtendedConfigFileWatcher(projectPath, parsed, extendedConfigFilesMap, createExtendedConfigFileWatch, toPath) { + function updateSharedExtendedConfigFileWatcher(projectPath, options, extendedConfigFilesMap, createExtendedConfigFileWatch, toPath) { var _a; - var extendedConfigs = ts.arrayToMap(((_a = parsed === null || parsed === void 0 ? void 0 : parsed.options.configFile) === null || _a === void 0 ? void 0 : _a.extendedSourceFiles) || ts.emptyArray, toPath); + var extendedConfigs = ts.arrayToMap(((_a = options === null || options === void 0 ? void 0 : options.configFile) === null || _a === void 0 ? void 0 : _a.extendedSourceFiles) || ts.emptyArray, toPath); // remove project from all unrelated watchers extendedConfigFilesMap.forEach(function (watcher, extendedConfigFilePath) { if (!extendedConfigs.has(extendedConfigFilePath)) { @@ -105341,12 +108997,12 @@ var ts; // start watching previously unseen extended config extendedConfigFilesMap.set(extendedConfigFilePath, { projects: new ts.Set([projectPath]), - fileWatcher: createExtendedConfigFileWatch(extendedConfigFileName, extendedConfigFilePath), + watcher: createExtendedConfigFileWatch(extendedConfigFileName, extendedConfigFilePath), close: function () { var existing = extendedConfigFilesMap.get(extendedConfigFilePath); if (!existing || existing.projects.size !== 0) return; - existing.fileWatcher.close(); + existing.watcher.close(); extendedConfigFilesMap.delete(extendedConfigFilePath); }, }); @@ -105354,6 +109010,31 @@ var ts; }); } ts.updateSharedExtendedConfigFileWatcher = updateSharedExtendedConfigFileWatcher; + /** + * Remove the project from the extended config file watchers and close not needed watches + */ + function clearSharedExtendedConfigFileWatcher(projectPath, extendedConfigFilesMap) { + extendedConfigFilesMap.forEach(function (watcher) { + if (watcher.projects.delete(projectPath)) + watcher.close(); + }); + } + ts.clearSharedExtendedConfigFileWatcher = clearSharedExtendedConfigFileWatcher; + /** + * Clean the extendsConfigCache when extended config file has changed + */ + function cleanExtendedConfigCache(extendedConfigCache, extendedConfigFilePath, toPath) { + if (!extendedConfigCache.delete(extendedConfigFilePath)) + return; + extendedConfigCache.forEach(function (_a, key) { + var _b; + var extendedResult = _a.extendedResult; + if ((_b = extendedResult.extendedSourceFiles) === null || _b === void 0 ? void 0 : _b.some(function (extendedFile) { return toPath(extendedFile) === extendedConfigFilePath; })) { + cleanExtendedConfigCache(extendedConfigCache, key, toPath); + } + }); + } + ts.cleanExtendedConfigCache = cleanExtendedConfigCache; /** * Updates the existing missing file watches with the new set of missing files after new program is created */ @@ -105405,7 +109086,7 @@ var ts; ts.updateWatchingWildcardDirectories = updateWatchingWildcardDirectories; /* @internal */ function isIgnoredFileFromWildCardWatching(_a) { - 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; + 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); @@ -105428,7 +109109,7 @@ var ts; return false; // We want to ignore emit file check if file is not going to be emitted next to source file // In that case we follow config file inclusion rules - if (options.outFile || options.outDir) + if (ts.outFile(options) || options.outDir) return false; // File if emitted next to input needs to be ignored if (ts.fileExtensionIs(fileOrDirectoryPath, ".d.ts" /* Dts */)) { @@ -105441,7 +109122,8 @@ var ts; } // just check if sourceFile with the name exists var filePathWithoutExtension = ts.removeFileExtension(fileOrDirectoryPath); - var realProgram = isBuilderProgram(program) ? program.getProgramOrUndefined() : program; + 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); @@ -105451,7 +109133,9 @@ var ts; function hasSourceFile(file) { return realProgram ? !!realProgram.getSourceFileByPath(file) : - program.getState().fileInfos.has(file); + builderProgram ? + builderProgram.getState().fileInfos.has(file) : + !!ts.find(program, function (rootFile) { return toPath(rootFile) === file; }); } } ts.isIgnoredFileFromWildCardWatching = isIgnoredFileFromWildCardWatching; @@ -105924,8 +109608,8 @@ var ts; var lineStart = ts.getPositionOfLineAndCharacter(file, i, 0); var lineEnd = i < lastLineInFile ? ts.getPositionOfLineAndCharacter(file, i + 1, 0) : file.text.length; var lineContent = file.text.slice(lineStart, lineEnd); - lineContent = lineContent.replace(/\s+$/g, ""); // trim from end - lineContent = lineContent.replace("\t", " "); // convert tabs to single spaces + lineContent = ts.trimStringEnd(lineContent); // trim from end + lineContent = lineContent.replace(/\t/g, " "); // convert tabs to single spaces // Output the gutter and the actual contents of the line. context += indent + formatColorAndReset(ts.padLeft(i + 1 + "", gutterWidth), gutterStyleSequence) + gutterSeparator; context += lineContent + host.getNewLine(); @@ -106130,38 +109814,31 @@ var ts; * Determines if program structure is upto date or needs to be recreated */ /* @internal */ - function isProgramUptoDate(program, rootFileNames, newOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, projectReferences) { + function isProgramUptoDate(program, rootFileNames, newOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences) { // If we haven't created a program yet or have changed automatic type directives, then it is not up-to-date - if (!program || (hasChangedAutomaticTypeDirectiveNames === null || hasChangedAutomaticTypeDirectiveNames === void 0 ? void 0 : hasChangedAutomaticTypeDirectiveNames())) { + if (!program || (hasChangedAutomaticTypeDirectiveNames === null || hasChangedAutomaticTypeDirectiveNames === void 0 ? void 0 : hasChangedAutomaticTypeDirectiveNames())) return false; - } // If root file names don't match - if (!ts.arrayIsEqualTo(program.getRootFileNames(), rootFileNames)) { + if (!ts.arrayIsEqualTo(program.getRootFileNames(), rootFileNames)) return false; - } var seenResolvedRefs; // If project references don't match - if (!ts.arrayIsEqualTo(program.getProjectReferences(), projectReferences, projectReferenceUptoDate)) { + if (!ts.arrayIsEqualTo(program.getProjectReferences(), projectReferences, projectReferenceUptoDate)) return false; - } // If any file is not up-to-date, then the whole program is not up-to-date - if (program.getSourceFiles().some(sourceFileNotUptoDate)) { + if (program.getSourceFiles().some(sourceFileNotUptoDate)) return false; - } // If any of the missing file paths are now created - if (program.getMissingFilePaths().some(fileExists)) { + if (program.getMissingFilePaths().some(fileExists)) return false; - } var currentOptions = program.getCompilerOptions(); // If the compilation settings do no match, then the program is not up-to-date - if (!ts.compareDataObjects(currentOptions, newOptions)) { + if (!ts.compareDataObjects(currentOptions, newOptions)) return false; - } // If everything matches but the text of config file is changed, // error locations can change for program options, so update the program - if (currentOptions.configFile && newOptions.configFile) { + if (currentOptions.configFile && newOptions.configFile) return currentOptions.configFile.text === newOptions.configFile.text; - } return true; function sourceFileNotUptoDate(sourceFile) { return !sourceFileVersionUptoDate(sourceFile) || @@ -106171,21 +109848,25 @@ var ts; return sourceFile.version === getSourceVersion(sourceFile.resolvedPath, sourceFile.fileName); } function projectReferenceUptoDate(oldRef, newRef, index) { - if (!ts.projectReferenceIsEqualTo(oldRef, newRef)) { - return false; - } - return resolvedProjectReferenceUptoDate(program.getResolvedProjectReferences()[index], oldRef); + return ts.projectReferenceIsEqualTo(oldRef, newRef) && + resolvedProjectReferenceUptoDate(program.getResolvedProjectReferences()[index], oldRef); } function resolvedProjectReferenceUptoDate(oldResolvedRef, oldRef) { if (oldResolvedRef) { - if (ts.contains(seenResolvedRefs, oldResolvedRef)) { - // Assume true + // Assume true + if (ts.contains(seenResolvedRefs, oldResolvedRef)) return true; - } - // If sourceFile for the oldResolvedRef existed, check the version for uptodate - if (!sourceFileVersionUptoDate(oldResolvedRef.sourceFile)) { + var refPath_1 = resolveProjectReferencePath(oldRef); + var newParsedCommandLine = getParsedCommandLine(refPath_1); + // Check if config file exists + if (!newParsedCommandLine) + return false; + // If change in source file + if (oldResolvedRef.commandLine.options.configFile !== newParsedCommandLine.options.configFile) + return false; + // check file names + if (!ts.arrayIsEqualTo(oldResolvedRef.commandLine.fileNames, newParsedCommandLine.fileNames)) return false; - } // Add to seen before checking the referenced paths of this config file (seenResolvedRefs || (seenResolvedRefs = [])).push(oldResolvedRef); // If child project references are upto date, this project reference is uptodate @@ -106195,7 +109876,8 @@ var ts; } // In old program, not able to resolve project reference path, // so if config file doesnt exist, it is uptodate. - return !fileExists(resolveProjectReferencePath(oldRef)); + var refPath = resolveProjectReferencePath(oldRef); + return !getParsedCommandLine(refPath); } } ts.isProgramUptoDate = isProgramUptoDate; @@ -106212,10 +109894,7 @@ var ts; return false; // If any compiler options change, we can't reuse old source file even if version match // The change in options like these could result in change in syntax tree or `sourceFile.bindDiagnostics`. - var oldOptions = program.getCompilerOptions(); - return !!ts.sourceFileAffectingCompilerOptions.some(function (option) { - return !ts.isJsonEqual(ts.getCompilerOptionValue(oldOptions, option), ts.getCompilerOptionValue(newOptions, option)); - }); + return ts.optionsHaveChanges(program.getCompilerOptions(), newOptions, ts.sourceFileAffectingCompilerOptions); } function createCreateProgramOptions(rootNames, options, host, oldProgram, configFileParsingDiagnostics) { return { @@ -106259,7 +109938,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.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" /* Program */, "createProgram", { configFilePath: options.configFilePath, rootDir: options.rootDir }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeProgram"); var host = createProgramOptions.host || createCompilerHost(options); var configParsingHost = parseConfigHostFromCompilerHostLike(host); @@ -106274,6 +109953,7 @@ var ts; var hasEmitBlockingDiagnostics = new ts.Map(); var _compilerOptionsObjectLiteralSyntax; var moduleResolutionCache; + var typeReferenceDirectiveResolutionCache; var actualResolveModuleNamesWorker; var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse; if (host.resolveModuleNames) { @@ -106288,7 +109968,7 @@ var ts; }); }; } else { - moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, function (x) { return host.getCanonicalFileName(x); }, options); + moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName, options); var loader_1 = function (moduleName, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache, redirectedReference).resolvedModule; }; // TODO: GH#18217 actualResolveModuleNamesWorker = function (moduleNames, containingFile, _reusedNames, redirectedReference) { return loadWithLocalCache(ts.Debug.checkEachDefined(moduleNames), containingFile, redirectedReference, loader_1); }; } @@ -106297,7 +109977,8 @@ var ts; actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options); }; } else { - var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference).resolvedTypeReferenceDirective; }; // TODO: GH#18217 + typeReferenceDirectiveResolutionCache = ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, /*options*/ undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache()); + var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache).resolvedTypeReferenceDirective; }; // TODO: GH#18217 actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { return loadWithLocalCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, loader_2); }; } // Map from a stringified PackageId to the source file with that id. @@ -106335,15 +110016,15 @@ var ts; getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect, forEachResolvedProjectReference: forEachResolvedProjectReference }), onProgramCreateComplete = _d.onProgramCreateComplete, fileExists = _d.fileExists, directoryExists = _d.directoryExists; - ts.tracing.push("program" /* Program */, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram }); var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options); - ts.tracing.pop(); + 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.push("program" /* Program */, "tryReuseStructureFromOldProgram", {}); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "tryReuseStructureFromOldProgram", {}); structureIsReused = tryReuseStructureFromOldProgram(); // eslint-disable-line prefer-const - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); if (structureIsReused !== 2 /* Completely */) { processingDefaultLibFiles = []; processingOtherFiles = []; @@ -106381,13 +110062,13 @@ var ts; }); } } - ts.tracing.push("program" /* Program */, "processRootFiles", { count: rootNames.length }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* 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.pop(); + 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.push("program" /* Program */, "processTypeReferences", { count: typeReferences.length }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* 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); @@ -106395,7 +110076,7 @@ var ts; for (var i = 0; i < typeReferences.length; i++) { processTypeReferenceDirective(typeReferences[i], resolutions[i], { kind: ts.FileIncludeKind.AutomaticTypeDirectiveFile, typeReference: typeReferences[i], packageId: (_b = resolutions[i]) === null || _b === void 0 ? void 0 : _b.packageId }); } - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } // Do not process the default library if: // - The '--noLib' flag is used. @@ -106436,12 +110117,25 @@ var ts; host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path)); } } - oldProgram.forEachResolvedProjectReference(function (resolvedProjectReference) { - if (!getResolvedProjectReferenceByPath(resolvedProjectReference.sourceFile.path)) { - host.onReleaseOldSourceFile(resolvedProjectReference.sourceFile, oldProgram.getCompilerOptions(), /*hasSourceFileByPath*/ false); + if (!host.getParsedCommandLine) { + oldProgram.forEachResolvedProjectReference(function (resolvedProjectReference) { + if (!getResolvedProjectReferenceByPath(resolvedProjectReference.sourceFile.path)) { + host.onReleaseOldSourceFile(resolvedProjectReference.sourceFile, oldProgram.getCompilerOptions(), /*hasSourceFileByPath*/ false); + } + }); + } + } + // Release commandlines that new program does not use + if (oldProgram && host.onReleaseParsedCommandLine) { + forEachProjectReference(oldProgram.getProjectReferences(), oldProgram.getResolvedProjectReferences(), function (oldResolvedRef, parent, index) { + var oldReference = (parent === null || parent === void 0 ? void 0 : parent.commandLine.projectReferences[index]) || oldProgram.getProjectReferences()[index]; + var oldRefPath = resolveProjectReferencePath(oldReference); + if (!(projectReferenceRedirects === null || projectReferenceRedirects === void 0 ? void 0 : projectReferenceRedirects.has(toPath(oldRefPath)))) { + host.onReleaseParsedCommandLine(oldRefPath, oldResolvedRef, oldProgram.getCompilerOptions()); } }); } + typeReferenceDirectiveResolutionCache = undefined; // unconditionally set oldProgram to undefined to prevent it from being captured in closure oldProgram = undefined; var program = { @@ -106470,7 +110164,6 @@ var ts; getNodeCount: function () { return getDiagnosticsProducingTypeChecker().getNodeCount(); }, getIdentifierCount: function () { return getDiagnosticsProducingTypeChecker().getIdentifierCount(); }, getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); }, - getTypeCatalog: function () { return getDiagnosticsProducingTypeChecker().getTypeCatalog(); }, getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); }, getInstantiationCount: function () { return getDiagnosticsProducingTypeChecker().getInstantiationCount(); }, getRelationCacheSizes: function () { return getDiagnosticsProducingTypeChecker().getRelationCacheSizes(); }, @@ -106518,19 +110211,19 @@ var ts; verifyCompilerOptions(); ts.performance.mark("afterProgram"); ts.performance.measure("Program", "beforeProgram", "afterProgram"); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return program; function resolveModuleNamesWorker(moduleNames, containingFile, reusedNames) { if (!moduleNames.length) return ts.emptyArray; var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory); var redirectedReference = getRedirectReferenceForResolution(containingFile); - ts.tracing.push("program" /* Program */, "resolveModuleNamesWorker", { containingFileName: containingFileName }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveModuleNamesWorker", { containingFileName: containingFileName }); ts.performance.mark("beforeResolveModule"); var result = actualResolveModuleNamesWorker(moduleNames, containingFileName, reusedNames, redirectedReference); ts.performance.mark("afterResolveModule"); ts.performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule"); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; } function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile) { @@ -106538,12 +110231,12 @@ var ts; return []; var containingFileName = !ts.isString(containingFile) ? ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile; var redirectedReference = !ts.isString(containingFile) ? getRedirectReferenceForResolution(containingFile) : undefined; - ts.tracing.push("program" /* Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName }); ts.performance.mark("beforeResolveTypeReference"); var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference); ts.performance.mark("afterResolveTypeReference"); ts.performance.measure("ResolveTypeReference", "beforeResolveTypeReference", "afterResolveTypeReference"); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; } function getRedirectReferenceForResolution(file) { @@ -106670,7 +110363,9 @@ var ts; var oldResolvedModule = ts.getResolvedModule(oldSourceFile, moduleName); if (oldResolvedModule) { if (ts.isTraceEnabled(options, host)) { - ts.trace(host, ts.Diagnostics.Reusing_resolution_of_module_0_to_file_1_from_old_program, moduleName, ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory)); + ts.trace(host, oldResolvedModule.packageId ? + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 : + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2, moduleName, ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory), oldResolvedModule.resolvedFileName, oldResolvedModule.packageId && ts.packageIdToString(oldResolvedModule.packageId)); } (result || (result = new Array(moduleNames.length)))[i] = oldResolvedModule; (reusedNames || (reusedNames = [])).push(moduleName); @@ -106753,7 +110448,9 @@ var ts; var newResolvedRef = parseProjectReferenceConfigFile(newRef); if (oldResolvedRef) { // Resolved project reference has gone missing or changed - return !newResolvedRef || newResolvedRef.sourceFile !== oldResolvedRef.sourceFile; + return !newResolvedRef || + newResolvedRef.sourceFile !== oldResolvedRef.sourceFile || + !ts.arrayIsEqualTo(oldResolvedRef.commandLine.fileNames, newResolvedRef.commandLine.fileNames); } else { // A previously-unresolved reference may be resolved now @@ -106781,9 +110478,6 @@ var ts; if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) { return 0 /* Not */; } - if (!ts.arrayIsEqualTo(options.types, oldOptions.types)) { - return 0 /* Not */; - } // Check if any referenced project tsconfig files are different if (!canReuseProjectReferences()) { return 0 /* Not */; @@ -106858,7 +110552,7 @@ var ts; // The `newSourceFile` object was created for the new program. if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) { // 'lib' references has changed. Matches behavior in changesAffectModuleResolution - return 0 /* Not */; + structureIsReused = 1 /* SafeModules */; } if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { // value of no-default-lib has changed @@ -106943,7 +110637,7 @@ var ts; if (structureIsReused !== 2 /* Completely */) { return structureIsReused; } - if ((_a = host.hasChangedAutomaticTypeDirectiveNames) === null || _a === void 0 ? void 0 : _a.call(host)) { + if (ts.changesAffectingProgramStructure(oldOptions, options) || ((_a = host.hasChangedAutomaticTypeDirectiveNames) === null || _a === void 0 ? void 0 : _a.call(host))) { return 1 /* SafeModules */; } missingFilePaths = oldProgram.getMissingFilePaths(); @@ -107015,7 +110709,7 @@ var ts; } function emitBuildInfo(writeFileCallback) { ts.Debug.assert(!ts.outFile(options)); - ts.tracing.push("emit" /* Emit */, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeEmit"); var emitResult = ts.emitFiles(ts.notImplementedResolver, getEmitHost(writeFileCallback), /*targetSourceFile*/ undefined, @@ -107024,7 +110718,7 @@ var ts; /*onlyBuildInfo*/ true); ts.performance.mark("afterEmit"); ts.performance.measure("Emit", "beforeEmit", "afterEmit"); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return emitResult; } function getResolvedProjectReferences() { @@ -107070,9 +110764,9 @@ var ts; return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ false)); } function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) { - 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" /* 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.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; } function isEmitBlocked(emitFileName) { @@ -107276,22 +110970,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 160 /* Parameter */: - case 163 /* PropertyDeclaration */: - case 165 /* MethodDeclaration */: + case 162 /* Parameter */: + case 165 /* PropertyDeclaration */: + case 167 /* 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 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: - case 209 /* ArrowFunction */: - case 249 /* VariableDeclaration */: + case 166 /* MethodSignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 210 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 211 /* ArrowFunction */: + case 251 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files)); @@ -107299,58 +110993,58 @@ var ts; } } switch (node.kind) { - case 262 /* ImportClause */: + case 264 /* 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 267 /* ExportDeclaration */: + case 269 /* 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 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_TypeScript_files)); return "skip"; - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 286 /* HeritageClause */: + case 288 /* HeritageClause */: var heritageClause = node; - if (heritageClause.token === 116 /* ImplementsKeyword */) { + if (heritageClause.token === 117 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 253 /* InterfaceDeclaration */: - var interfaceKeyword = ts.tokenToString(117 /* InterfaceKeyword */); + case 255 /* InterfaceDeclaration */: + var interfaceKeyword = ts.tokenToString(118 /* InterfaceKeyword */); ts.Debug.assertIsDefined(interfaceKeyword); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, interfaceKeyword)); return "skip"; - case 256 /* ModuleDeclaration */: - var moduleKeyword = node.flags & 16 /* Namespace */ ? ts.tokenToString(140 /* NamespaceKeyword */) : ts.tokenToString(139 /* ModuleKeyword */); + case 258 /* ModuleDeclaration */: + var moduleKeyword = node.flags & 16 /* Namespace */ ? ts.tokenToString(141 /* NamespaceKeyword */) : ts.tokenToString(140 /* ModuleKeyword */); ts.Debug.assertIsDefined(moduleKeyword); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, moduleKeyword)); return "skip"; - case 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_aliases_can_only_be_used_in_TypeScript_files)); return "skip"; - case 255 /* EnumDeclaration */: - var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(91 /* EnumKeyword */)); + case 257 /* EnumDeclaration */: + var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(92 /* EnumKeyword */)); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, enumKeyword)); return "skip"; - case 225 /* NonNullExpression */: + case 227 /* NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Non_null_assertions_can_only_be_used_in_TypeScript_files)); return "skip"; - case 224 /* AsExpression */: + case 226 /* AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.Type_assertion_expressions_can_only_be_used_in_TypeScript_files)); return "skip"; - case 206 /* TypeAssertionExpression */: + case 208 /* TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } } @@ -107359,53 +111053,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 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: - case 209 /* ArrowFunction */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 167 /* MethodDeclaration */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 210 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 211 /* 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 232 /* VariableStatement */: + case 234 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - checkModifiers(parent.modifiers, parent.kind === 232 /* VariableStatement */); + checkModifiers(parent.modifiers, parent.kind === 234 /* VariableStatement */); return "skip"; } break; - case 163 /* PropertyDeclaration */: + case 165 /* 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 (modifier.kind !== 123 /* StaticKeyword */) { + if (modifier.kind !== 124 /* 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 160 /* Parameter */: + case 162 /* Parameter */: // Check modifiers of parameter declaration if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Parameter_modifiers_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 203 /* CallExpression */: - case 204 /* NewExpression */: - case 223 /* ExpressionWithTypeArguments */: - case 274 /* JsxSelfClosingElement */: - case 275 /* JsxOpeningElement */: - case 205 /* TaggedTemplateExpression */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: + case 225 /* ExpressionWithTypeArguments */: + case 276 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: + case 207 /* TaggedTemplateExpression */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_arguments_can_only_be_used_in_TypeScript_files)); @@ -107418,24 +111112,25 @@ var ts; for (var _i = 0, modifiers_2 = modifiers; _i < modifiers_2.length; _i++) { var modifier = modifiers_2[_i]; switch (modifier.kind) { - case 84 /* ConstKeyword */: + case 85 /* ConstKeyword */: if (isConstValid) { continue; } // to report error, // falls through - case 122 /* PublicKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 142 /* ReadonlyKeyword */: - case 133 /* DeclareKeyword */: - case 125 /* AbstractKeyword */: + case 123 /* PublicKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + case 143 /* ReadonlyKeyword */: + case 134 /* DeclareKeyword */: + case 126 /* AbstractKeyword */: + case 157 /* OverrideKeyword */: 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 123 /* StaticKeyword */: - case 92 /* ExportKeyword */: - case 87 /* DefaultKeyword */: + case 124 /* StaticKeyword */: + case 93 /* ExportKeyword */: + case 88 /* DefaultKeyword */: } } } @@ -107506,8 +111201,8 @@ var ts; return a.fileName === b.fileName; } function moduleNameIsEqualTo(a, b) { - return a.kind === 78 /* Identifier */ - ? b.kind === 78 /* Identifier */ && a.escapedText === b.escapedText + return a.kind === 79 /* Identifier */ + ? b.kind === 79 /* Identifier */ && a.escapedText === b.escapedText : b.kind === 10 /* StringLiteral */ && a.text === b.text; } function createSyntheticImport(text, file) { @@ -107733,13 +111428,13 @@ var ts; } // Get source file from normalized fileName function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, reason, packageId) { - ts.tracing.push("program" /* Program */, "findSourceFile", { + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "findSourceFile", { fileName: fileName, isDefaultLib: isDefaultLib || undefined, fileIncludeKind: ts.FileIncludeKind[reason.kind], }); var result = findSourceFileWorker(fileName, path, isDefaultLib, ignoreNoDefaultLib, reason, packageId); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; } function findSourceFileWorker(fileName, path, isDefaultLib, ignoreNoDefaultLib, reason, packageId) { @@ -107998,9 +111693,9 @@ var ts; } } function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, reason) { - 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" /* Program */, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolveModuleNamesReusingOldState, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined }); processTypeReferenceDirectiveWorker(typeReferenceDirective, resolvedTypeReferenceDirective, reason); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } function processTypeReferenceDirectiveWorker(typeReferenceDirective, resolvedTypeReferenceDirective, reason) { // If we already found this library as a primary reference - nothing to do @@ -108071,12 +111766,14 @@ var ts; return host.getCanonicalFileName(fileName); } function processImportedModules(file) { + var _a; collectExternalModuleReferences(file); if (file.imports.length || file.moduleAugmentations.length) { // Because global augmentation doesn't have string literal name, we can check for global augmentation as such. var moduleNames = getModuleNames(file); var resolutions = resolveModuleNamesReusingOldState(moduleNames, file); ts.Debug.assert(resolutions.length === moduleNames.length); + var optionsForFile = (useSourceOfProjectReferenceRedirect ? (_a = getRedirectReferenceForResolution(file)) === null || _a === void 0 ? void 0 : _a.commandLine.options : undefined) || options; for (var index = 0; index < moduleNames.length; index++) { var resolution = resolutions[index]; ts.setResolvedModule(file, moduleNames[index], resolution); @@ -108099,11 +111796,11 @@ var ts; // Don't add the file if it has a bad extension (e.g. 'tsx' if we don't have '--allowJs') // This may still end up being an untyped module -- the file won't be included but imports will be allowed. var shouldAddFile = resolvedFileName - && !getResolutionDiagnostic(options, resolution) - && !options.noResolve + && !getResolutionDiagnostic(optionsForFile, resolution) + && !optionsForFile.noResolve && index < file.imports.length && !elideImport - && !(isJsFile && !ts.getAllowJSCompilerOption(options)) + && !(isJsFile && !ts.getAllowJSCompilerOption(optionsForFile)) && (ts.isInJSFile(file.imports[index]) || !(file.imports[index].flags & 4194304 /* JSDoc */)); if (elideImport) { modulesWithElidedImports.set(file.path, true); @@ -108189,6 +111886,9 @@ var ts; if (options.strictPropertyInitialization && !ts.getStrictOptionValue(options, "strictNullChecks")) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictPropertyInitialization", "strictNullChecks"); } + if (options.strictOptionalProperties && !ts.getStrictOptionValue(options, "strictNullChecks")) { + createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictOptionalProperties", "strictNullChecks"); + } if (options.isolatedModules) { if (options.out) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules"); @@ -108306,6 +112006,9 @@ var ts; if (options.module === ts.ModuleKind.None && languageVersion < 2 /* 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 */; }); if (firstNonExternalModuleSourceFile) { var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); @@ -108336,9 +112039,10 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Option_resolveJsonModule_can_only_be_specified_when_module_code_generation_is_commonjs_amd_es2015_or_esNext, "resolveJsonModule", "module"); } } - // there has to be common source directory if user specified --outdir || --sourceRoot + // there has to be common source directory if user specified --outdir || --rootDir || --sourceRoot // if user specified --mapRoot, there needs to be common source directory if there would be multiple files being emitted if (options.outDir || // there is --outDir specified + options.rootDir || // there is --rootDir specified options.sourceRoot || // there is --sourceRoot specified options.mapRoot) { // there is --mapRoot specified // Precalculate and cache the common source directory @@ -108835,7 +112539,7 @@ var ts; } function handleDirectoryCouldBeSymlink(directory) { var _a; - if (!host.getResolvedProjectReferences()) + if (!host.getResolvedProjectReferences() || ts.containsIgnoredPath(directory)) return; // Because we already watch node_modules, handle symlinks in there if (!originalRealpath || !ts.stringContains(directory, ts.nodeModulesPathPart)) @@ -108852,7 +112556,7 @@ var ts; symlinkCache.setSymlinkedDirectory(directoryPath, false); return; } - symlinkCache.setSymlinkedDirectory(directoryPath, { + symlinkCache.setSymlinkedDirectory(directory, { real: ts.ensureTrailingDirectorySeparator(real), realPath: realPath }); @@ -109128,12 +112832,15 @@ var ts; // From ambient modules for (var _f = 0, _g = program.getTypeChecker().getAmbientModules(); _f < _g.length; _f++) { var ambientModule = _g[_f]; - if (ambientModule.declarations.length > 1) { + if (ambientModule.declarations && ambientModule.declarations.length > 1) { addReferenceFromAmbientModule(ambientModule); } } return referencedFiles; function addReferenceFromAmbientModule(symbol) { + if (!symbol.declarations) { + return; + } // Add any file other than our own as reference for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; @@ -109158,7 +112865,7 @@ var ts; /** * Creates the state of file references and signature for the new program from oldState if it is safe */ - function create(newProgram, getCanonicalFileName, oldState) { + function create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) { var fileInfos = new ts.Map(); var referencedMap = newProgram.getCompilerOptions().module !== ts.ModuleKind.None ? new ts.Map() : undefined; var exportedModulesMap = referencedMap ? new ts.Map() : undefined; @@ -109184,13 +112891,14 @@ var ts; } } } - fileInfos.set(sourceFile.resolvedPath, { version: version_2, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) }); + fileInfos.set(sourceFile.resolvedPath, { version: version_2, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) || undefined }); } return { fileInfos: fileInfos, referencedMap: referencedMap, exportedModulesMap: exportedModulesMap, - hasCalledUpdateShapeSignature: hasCalledUpdateShapeSignature + hasCalledUpdateShapeSignature: hasCalledUpdateShapeSignature, + useFileVersionAsSignature: !disableUseFileVersionAsSignature && !useOldState }; } BuilderState.create = create; @@ -109212,6 +112920,7 @@ var ts; referencedMap: state.referencedMap && new ts.Map(state.referencedMap), exportedModulesMap: state.exportedModulesMap && new ts.Map(state.exportedModulesMap), hasCalledUpdateShapeSignature: new ts.Set(state.hasCalledUpdateShapeSignature), + useFileVersionAsSignature: state.useFileVersionAsSignature, }; } BuilderState.clone = clone; @@ -109267,23 +112976,12 @@ var ts; return ts.Debug.fail(); var prevSignature = info.signature; var latestSignature; - if (sourceFile.isDeclarationFile) { - latestSignature = sourceFile.version; - if (exportedModulesMapCache && latestSignature !== prevSignature) { - // All the references in this file are exported - var references = state.referencedMap ? state.referencedMap.get(sourceFile.resolvedPath) : undefined; - exportedModulesMapCache.set(sourceFile.resolvedPath, references || false); - } - } - else { + if (!sourceFile.isDeclarationFile && !state.useFileVersionAsSignature) { var emitOutput_1 = getFileEmitOutput(programOfThisState, sourceFile, /*emitOnlyDtsFiles*/ true, cancellationToken, /*customTransformers*/ undefined, /*forceDtsEmit*/ true); - var firstDts_1 = emitOutput_1.outputFiles && - programOfThisState.getCompilerOptions().declarationMap ? - emitOutput_1.outputFiles.length > 1 ? emitOutput_1.outputFiles[1] : undefined : - emitOutput_1.outputFiles.length > 0 ? emitOutput_1.outputFiles[0] : undefined; + var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles); if (firstDts_1) { ts.Debug.assert(ts.fileExtensionIs(firstDts_1.name, ".d.ts" /* Dts */), "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 = (computeHash || ts.generateDjb2Hash)(firstDts_1.text); @@ -109291,12 +112989,18 @@ var ts; updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache); } } - else { - latestSignature = prevSignature; // TODO: GH#18217 + } + // Default is to use file version as signature + if (latestSignature === undefined) { + latestSignature = sourceFile.version; + if (exportedModulesMapCache && latestSignature !== prevSignature) { + // All the references in this file are exported + var references = state.referencedMap ? state.referencedMap.get(sourceFile.resolvedPath) : undefined; + exportedModulesMapCache.set(sourceFile.resolvedPath, references || false); } } cacheToUpdateSignature.set(sourceFile.resolvedPath, latestSignature); - return !prevSignature || latestSignature !== prevSignature; + return latestSignature !== prevSignature; } BuilderState.updateShapeSignature = updateShapeSignature; /** @@ -109416,7 +113120,7 @@ var ts; */ function isFileAffectingGlobalScope(sourceFile) { return containsGlobalScopeAugmentation(sourceFile) || - !ts.isExternalModule(sourceFile) && !containsOnlyAmbientModules(sourceFile); + !ts.isExternalOrCommonJsModule(sourceFile) && !containsOnlyAmbientModules(sourceFile); } /** * Gets all files of the program excluding the default library file @@ -109504,8 +113208,8 @@ var ts; /** * Create the state so that we can iterate on changedFiles/affected files */ - function createBuilderProgramState(newProgram, getCanonicalFileName, oldState) { - var state = ts.BuilderState.create(newProgram, getCanonicalFileName, oldState); + function createBuilderProgramState(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) { + var state = ts.BuilderState.create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature); state.program = newProgram; var compilerOptions = newProgram.getCompilerOptions(); state.compilerOptions = compilerOptions; @@ -109743,6 +113447,7 @@ var ts; * 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) { + var _a; removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath); // If affected files is everything except default library, then nothing more to do if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) { @@ -109756,8 +113461,15 @@ var ts; removeSemanticDiagnosticsOf(state, f.resolvedPath); }); } + // 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, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap); return; } + else { + ts.Debug.assert(state.hasCalledUpdateShapeSignature.has(affectedFile.resolvedPath) || ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.has(affectedFile.resolvedPath)), "Signature not updated for affected file: " + affectedFile.fileName); + } if (!state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) { forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash); }); } @@ -109969,83 +113681,116 @@ var ts; return undefined; var currentDirectory = ts.Debug.checkDefined(state.program).getCurrentDirectory(); var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory)); - var fileInfos = {}; - state.fileInfos.forEach(function (value, key) { + var fileNames = []; + var fileNameToFileId = new ts.Map(); + var fileIdsList; + var fileNamesToFileIdListId; + var fileInfos = ts.arrayFrom(state.fileInfos.entries(), function (_a) { + var key = _a[0], value = _a[1]; + // Ensure fileId + var fileId = toFileId(key); + ts.Debug.assert(fileNames[fileId - 1] === relativeToBuildInfo(key)); var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key); - fileInfos[relativeToBuildInfo(key)] = signature === undefined ? value : { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope }; + var actualSignature = signature !== null && signature !== void 0 ? signature : value.signature; + return value.version === actualSignature ? + value.affectsGlobalScope ? + { version: value.version, signature: undefined, affectsGlobalScope: true } : + value.version : + actualSignature !== undefined ? + signature === undefined ? + value : + { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope } : + { version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope }; }); - var result = { - fileInfos: fileInfos, - options: convertToReusableCompilerOptions(state.compilerOptions, relativeToBuildInfoEnsuringAbsolutePath) - }; + var referencedMap; if (state.referencedMap) { - var referencedMap = {}; - for (var _i = 0, _a = ts.arrayFrom(state.referencedMap.keys()).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) { - var key = _a[_i]; - referencedMap[relativeToBuildInfo(key)] = ts.arrayFrom(state.referencedMap.get(key).keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive); - } - result.referencedMap = referencedMap; + referencedMap = ts.arrayFrom(state.referencedMap.keys()).sort(ts.compareStringsCaseSensitive).map(function (key) { return [ + toFileId(key), + toFileIdListId(state.referencedMap.get(key)) + ]; }); } + var exportedModulesMap; if (state.exportedModulesMap) { - var exportedModulesMap = {}; - for (var _b = 0, _c = ts.arrayFrom(state.exportedModulesMap.keys()).sort(ts.compareStringsCaseSensitive); _b < _c.length; _b++) { - var key = _c[_b]; + exportedModulesMap = ts.mapDefined(ts.arrayFrom(state.exportedModulesMap.keys()).sort(ts.compareStringsCaseSensitive), function (key) { var newValue = state.currentAffectedFilesExportedModulesMap && state.currentAffectedFilesExportedModulesMap.get(key); // Not in temporary cache, use existing value if (newValue === undefined) - exportedModulesMap[relativeToBuildInfo(key)] = ts.arrayFrom(state.exportedModulesMap.get(key).keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive); + return [toFileId(key), toFileIdListId(state.exportedModulesMap.get(key))]; // Value in cache and has updated value map, use that else if (newValue) - exportedModulesMap[relativeToBuildInfo(key)] = ts.arrayFrom(newValue.keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive); - } - result.exportedModulesMap = exportedModulesMap; + return [toFileId(key), toFileIdListId(newValue)]; + }); } + var semanticDiagnosticsPerFile; if (state.semanticDiagnosticsPerFile) { - var semanticDiagnosticsPerFile = []; - for (var _d = 0, _e = ts.arrayFrom(state.semanticDiagnosticsPerFile.keys()).sort(ts.compareStringsCaseSensitive); _d < _e.length; _d++) { - var key = _e[_d]; + for (var _i = 0, _a = ts.arrayFrom(state.semanticDiagnosticsPerFile.keys()).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) { + var key = _a[_i]; var value = state.semanticDiagnosticsPerFile.get(key); - semanticDiagnosticsPerFile.push(value.length ? + (semanticDiagnosticsPerFile || (semanticDiagnosticsPerFile = [])).push(value.length ? [ - relativeToBuildInfo(key), + toFileId(key), state.hasReusableDiagnostic ? value : convertToReusableDiagnostics(value, relativeToBuildInfo) ] : - relativeToBuildInfo(key)); + toFileId(key)); } - result.semanticDiagnosticsPerFile = semanticDiagnosticsPerFile; } + var affectedFilesPendingEmit; if (state.affectedFilesPendingEmit) { - var affectedFilesPendingEmit = []; var seenFiles = new ts.Set(); - for (var _f = 0, _g = state.affectedFilesPendingEmit.slice(state.affectedFilesPendingEmitIndex).sort(ts.compareStringsCaseSensitive); _f < _g.length; _f++) { - var path = _g[_f]; + for (var _b = 0, _c = state.affectedFilesPendingEmit.slice(state.affectedFilesPendingEmitIndex).sort(ts.compareStringsCaseSensitive); _b < _c.length; _b++) { + var path = _c[_b]; if (ts.tryAddToSet(seenFiles, path)) { - affectedFilesPendingEmit.push([relativeToBuildInfo(path), state.affectedFilesPendingEmitKind.get(path)]); + (affectedFilesPendingEmit || (affectedFilesPendingEmit = [])).push([toFileId(path), state.affectedFilesPendingEmitKind.get(path)]); } } - result.affectedFilesPendingEmit = affectedFilesPendingEmit; } - return result; + return { + fileNames: fileNames, + fileInfos: fileInfos, + options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, relativeToBuildInfoEnsuringAbsolutePath), + fileIdsList: fileIdsList, + referencedMap: referencedMap, + exportedModulesMap: exportedModulesMap, + semanticDiagnosticsPerFile: semanticDiagnosticsPerFile, + affectedFilesPendingEmit: affectedFilesPendingEmit, + }; function relativeToBuildInfoEnsuringAbsolutePath(path) { return relativeToBuildInfo(ts.getNormalizedAbsolutePath(path, currentDirectory)); } function relativeToBuildInfo(path) { return ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(buildInfoDirectory, path, getCanonicalFileName)); } + function toFileId(path) { + var fileId = fileNameToFileId.get(path); + if (fileId === undefined) { + fileNames.push(relativeToBuildInfo(path)); + fileNameToFileId.set(path, fileId = fileNames.length); + } + return fileId; + } + function toFileIdListId(set) { + var fileIds = ts.arrayFrom(set.keys(), toFileId).sort(ts.compareValues); + var key = fileIds.join(); + var fileIdListId = fileNamesToFileIdListId === null || fileNamesToFileIdListId === void 0 ? void 0 : fileNamesToFileIdListId.get(key); + if (fileIdListId === undefined) { + (fileIdsList || (fileIdsList = [])).push(fileIds); + (fileNamesToFileIdListId || (fileNamesToFileIdListId = new ts.Map())).set(key, fileIdListId = fileIdsList.length); + } + return fileIdListId; + } } - function convertToReusableCompilerOptions(options, relativeToBuildInfo) { - var result = {}; + function convertToProgramBuildInfoCompilerOptions(options, relativeToBuildInfo) { + var result; var optionsNameMap = ts.getOptionsNameMap().optionsNameMap; - for (var name in options) { - if (ts.hasProperty(options, name)) { - result[name] = convertToReusableCompilerOptionValue(optionsNameMap.get(name.toLowerCase()), options[name], relativeToBuildInfo); + for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) { + var name = _a[_i]; + var optionInfo = optionsNameMap.get(name.toLowerCase()); + if ((optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsEmit) || (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsSemanticDiagnostics) || name === "skipLibCheck" || name === "skipDefaultLibCheck") { + (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfo); } } - if (result.configFilePath) { - result.configFilePath = relativeToBuildInfo(result.configFilePath); - } return result; } function convertToReusableCompilerOptionValue(option, value, relativeToBuildInfo) { @@ -110137,15 +113882,16 @@ var ts; * Computing hash to for signature verification */ var computeHash = ts.maybeBind(host, host.createHash); - var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState); + var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState, host.disableUseFileVersionAsSignature); var backupState; 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; oldState = undefined; - var builderProgram = createRedirectedBuilderProgram(state, configFileParsingDiagnostics); - builderProgram.getState = function () { return state; }; + var getState = function () { return state; }; + var builderProgram = createRedirectedBuilderProgram(getState, configFileParsingDiagnostics); + builderProgram.getState = getState; builderProgram.backupState = function () { ts.Debug.assert(backupState === undefined); backupState = cloneBuilderProgramState(state); @@ -110361,37 +114107,31 @@ var ts; state.affectedFilesPendingEmitIndex = 0; } } - function getMapOfReferencedSet(mapLike, toPath) { - if (!mapLike) - return undefined; - var map = new ts.Map(); - // Copies keys/values from template. Note that for..in will not throw if - // template is undefined, and instead will just exit the loop. - for (var key in mapLike) { - if (ts.hasProperty(mapLike, key)) { - map.set(toPath(key), new ts.Set(mapLike[key].map(toPath))); - } - } - return map; + function toBuilderStateFileInfo(fileInfo) { + return ts.isString(fileInfo) ? + { version: fileInfo, signature: fileInfo, affectsGlobalScope: undefined } : + ts.isString(fileInfo.signature) ? + fileInfo : + { version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope }; } + ts.toBuilderStateFileInfo = toBuilderStateFileInfo; function createBuildProgramUsingProgramBuildInfo(program, buildInfoPath, host) { + var _a; var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory())); var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames()); + var filePaths = program.fileNames.map(toPath); + var filePathsSetList = (_a = program.fileIdsList) === null || _a === void 0 ? void 0 : _a.map(function (fileIds) { return new ts.Set(fileIds.map(toFilePath)); }); var fileInfos = new ts.Map(); - for (var key in program.fileInfos) { - if (ts.hasProperty(program.fileInfos, key)) { - fileInfos.set(toPath(key), program.fileInfos[key]); - } - } + program.fileInfos.forEach(function (fileInfo, index) { return fileInfos.set(toFilePath(index + 1), toBuilderStateFileInfo(fileInfo)); }); var state = { fileInfos: fileInfos, - compilerOptions: ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath), - referencedMap: getMapOfReferencedSet(program.referencedMap, toPath), - exportedModulesMap: getMapOfReferencedSet(program.exportedModulesMap, toPath), - semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, function (value) { return toPath(ts.isString(value) ? value : value[0]); }, function (value) { return ts.isString(value) ? ts.emptyArray : value[1]; }), + compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {}, + referencedMap: toMapOfReferencedSet(program.referencedMap), + exportedModulesMap: toMapOfReferencedSet(program.exportedModulesMap), + semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, function (value) { return toFilePath(ts.isNumber(value) ? value : value[0]); }, function (value) { return ts.isNumber(value) ? ts.emptyArray : value[1]; }), hasReusableDiagnostic: true, - affectedFilesPendingEmit: ts.map(program.affectedFilesPendingEmit, function (value) { return toPath(value[0]); }), - affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toPath(value[0]); }, function (value) { return value[1]; }), + affectedFilesPendingEmit: ts.map(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }), + affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }, function (value) { return value[1]; }), affectedFilesPendingEmitIndex: program.affectedFilesPendingEmit && 0, }; return { @@ -110424,17 +114164,26 @@ var ts; function toAbsolutePath(path) { return ts.getNormalizedAbsolutePath(path, buildInfoDirectory); } + function toFilePath(fileId) { + return filePaths[fileId - 1]; + } + function toFilePathsSet(fileIdsListId) { + return filePathsSetList[fileIdsListId - 1]; + } + function toMapOfReferencedSet(referenceMap) { + return referenceMap && ts.arrayToMap(referenceMap, function (value) { return toFilePath(value[0]); }, function (value) { return toFilePathsSet(value[1]); }); + } } ts.createBuildProgramUsingProgramBuildInfo = createBuildProgramUsingProgramBuildInfo; - function createRedirectedBuilderProgram(state, configFileParsingDiagnostics) { + function createRedirectedBuilderProgram(getState, configFileParsingDiagnostics) { return { getState: ts.notImplemented, backupState: ts.noop, restoreState: ts.noop, getProgram: getProgram, - getProgramOrUndefined: function () { return state.program; }, - releaseProgram: function () { return state.program = undefined; }, - getCompilerOptions: function () { return state.compilerOptions; }, + getProgramOrUndefined: function () { return getState().program; }, + releaseProgram: function () { return getState().program = undefined; }, + getCompilerOptions: function () { return getState().compilerOptions; }, getSourceFile: function (fileName) { return getProgram().getSourceFile(fileName); }, getSourceFiles: function () { return getProgram().getSourceFiles(); }, getOptionsDiagnostics: function (cancellationToken) { return getProgram().getOptionsDiagnostics(cancellationToken); }, @@ -110450,7 +114199,7 @@ var ts; close: ts.noop, }; function getProgram() { - return ts.Debug.checkDefined(state.program); + return ts.Debug.checkDefined(getState().program); } } ts.createRedirectedBuilderProgram = createRedirectedBuilderProgram; @@ -110467,7 +114216,7 @@ var ts; ts.createEmitAndSemanticDiagnosticsBuilderProgram = createEmitAndSemanticDiagnosticsBuilderProgram; function createAbstractBuilder(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences) { var _a = ts.getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences), newProgram = _a.newProgram, newConfigFileParsingDiagnostics = _a.configFileParsingDiagnostics; - return ts.createRedirectedBuilderProgram({ program: newProgram, compilerOptions: newProgram.getCompilerOptions() }, newConfigFileParsingDiagnostics); + return ts.createRedirectedBuilderProgram(function () { return ({ program: newProgram, compilerOptions: newProgram.getCompilerOptions() }); }, newConfigFileParsingDiagnostics); } ts.createAbstractBuilder = createAbstractBuilder; })(ts || (ts = {})); @@ -110536,9 +114285,9 @@ var ts; var resolutionsWithFailedLookups = []; var resolvedFileToResolution = ts.createMultiMap(); var hasChangedAutomaticTypeDirectiveNames = false; - var failedLookupChecks = []; - var startsWithPathChecks = []; - var isInDirectoryChecks = []; + var failedLookupChecks; + var startsWithPathChecks; + var isInDirectoryChecks; var getCurrentDirectory = ts.memoize(function () { return resolutionHost.getCurrentDirectory(); }); // TODO: GH#18217 var cachedDirectoryStructureHost = resolutionHost.getCachedDirectoryStructureHost(); // The resolvedModuleNames and resolvedTypeReferenceDirectives are the cache of resolutions per file. @@ -110547,9 +114296,12 @@ var ts; var resolvedModuleNames = new ts.Map(); var perDirectoryResolvedModuleNames = ts.createCacheWithRedirects(); var nonRelativeModuleNameCache = ts.createCacheWithRedirects(); - var moduleResolutionCache = ts.createModuleResolutionCacheWithMaps(perDirectoryResolvedModuleNames, nonRelativeModuleNameCache, getCurrentDirectory(), resolutionHost.getCanonicalFileName); + var moduleResolutionCache = ts.createModuleResolutionCache(getCurrentDirectory(), resolutionHost.getCanonicalFileName, + /*options*/ undefined, perDirectoryResolvedModuleNames, nonRelativeModuleNameCache); var resolvedTypeReferenceDirectives = new ts.Map(); var perDirectoryResolvedTypeReferenceDirectives = ts.createCacheWithRedirects(); + var typeReferenceDirectiveResolutionCache = ts.createTypeReferenceDirectiveResolutionCache(getCurrentDirectory(), resolutionHost.getCanonicalFileName, + /*options*/ undefined, moduleResolutionCache.getPackageJsonInfoCache(), perDirectoryResolvedTypeReferenceDirectives); /** * These are the extensions that failed lookup files will have by default, * any other extension of failed lookup will be store that path in custom failed lookup path @@ -110581,6 +114333,7 @@ var ts; invalidateResolutionsOfFailedLookupLocations: invalidateResolutionsOfFailedLookupLocations, setFilesWithInvalidatedNonRelativeUnresolvedImports: setFilesWithInvalidatedNonRelativeUnresolvedImports, createHasInvalidatedResolution: createHasInvalidatedResolution, + isFileWithInvalidatedNonRelativeUnresolvedImports: isFileWithInvalidatedNonRelativeUnresolvedImports, updateTypeRootsWatch: updateTypeRootsWatch, closeTypeRootsWatch: closeTypeRootsWatch, clear: clear @@ -110606,9 +114359,9 @@ var ts; resolvedTypeReferenceDirectives.clear(); resolvedFileToResolution.clear(); resolutionsWithFailedLookups.length = 0; - failedLookupChecks.length = 0; - startsWithPathChecks.length = 0; - isInDirectoryChecks.length = 0; + failedLookupChecks = undefined; + startsWithPathChecks = undefined; + isInDirectoryChecks = undefined; // perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update // (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution) clearPerDirectoryResolutions(); @@ -110644,9 +114397,8 @@ var ts; isFileWithInvalidatedNonRelativeUnresolvedImports(path); }; } function clearPerDirectoryResolutions() { - perDirectoryResolvedModuleNames.clear(); - nonRelativeModuleNameCache.clear(); - perDirectoryResolvedTypeReferenceDirectives.clear(); + moduleResolutionCache.clear(); + typeReferenceDirectiveResolutionCache.clear(); nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions); nonRelativeExternalModuleResolutions.clear(); } @@ -110673,7 +114425,7 @@ var ts; if (globalCache !== undefined && !ts.isExternalModuleNameRelative(moduleName) && !(primaryResult.resolvedModule && ts.extensionIsTS(primaryResult.resolvedModule.extension))) { // create different collection of failed lookup locations for second pass // if it will fail and we've already found something during the first pass - we don't want to pollute its results - var _b = ts.loadModuleFromGlobalCache(ts.Debug.checkDefined(resolutionHost.globalCacheResolutionModuleName)(moduleName), resolutionHost.projectName, compilerOptions, host, globalCache), resolvedModule = _b.resolvedModule, failedLookupLocations = _b.failedLookupLocations; + var _b = ts.loadModuleFromGlobalCache(ts.Debug.checkDefined(resolutionHost.globalCacheResolutionModuleName)(moduleName), resolutionHost.projectName, compilerOptions, host, globalCache, moduleResolutionCache), resolvedModule = _b.resolvedModule, failedLookupLocations = _b.failedLookupLocations; if (resolvedModule) { // Modify existing resolution so its saved in the directory cache as well primaryResult.resolvedModule = resolvedModule; @@ -110684,8 +114436,11 @@ var ts; // Default return the result from the first pass return primaryResult; } + function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference) { + return ts.resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache); + } function resolveNamesWithLocalCache(_a) { - var _b; + var _b, _c, _d; var names = _a.names, containingFile = _a.containingFile, redirectedReference = _a.redirectedReference, cache = _a.cache, perDirectoryCacheWithRedirects = _a.perDirectoryCacheWithRedirects, loader = _a.loader, getResolutionWithResolvedFileName = _a.getResolutionWithResolvedFileName, shouldRetryResolution = _a.shouldRetryResolution, reusedNames = _a.reusedNames, logChanges = _a.logChanges; var path = resolutionHost.toPath(containingFile); var resolutionsInFile = cache.get(path) || cache.set(path, new ts.Map()).get(path); @@ -110718,9 +114473,24 @@ var ts; var resolutionInDirectory = perDirectoryResolution.get(name); if (resolutionInDirectory) { resolution = resolutionInDirectory; + var host = ((_b = resolutionHost.getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(resolutionHost)) || resolutionHost; + if (ts.isTraceEnabled(compilerOptions, host)) { + var resolved = getResolutionWithResolvedFileName(resolution); + ts.trace(host, loader === resolveModuleName ? + (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ? + resolved.packagetId ? + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4 : + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3 : + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_not_resolved : + (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ? + resolved.packagetId ? + ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4 : + ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3 : + ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_not_resolved, name, containingFile, ts.getDirectoryPath(containingFile), resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName, (resolved === null || resolved === void 0 ? void 0 : resolved.packagetId) && ts.packageIdToString(resolved.packagetId)); + } } else { - resolution = loader(name, containingFile, compilerOptions, ((_b = resolutionHost.getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(resolutionHost)) || resolutionHost, redirectedReference); + resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference); perDirectoryResolution.set(name, resolution); } resolutionsInFile.set(name, resolution); @@ -110734,6 +114504,23 @@ var ts; logChanges = false; } } + else { + var host = ((_d = resolutionHost.getCompilerHost) === null || _d === void 0 ? void 0 : _d.call(resolutionHost)) || resolutionHost; + if (ts.isTraceEnabled(compilerOptions, host) && !seenNamesInFile.has(name)) { + var resolved = getResolutionWithResolvedFileName(resolution); + ts.trace(host, loader === resolveModuleName ? + (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ? + resolved.packagetId ? + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 : + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2 : + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_not_resolved : + (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ? + resolved.packagetId ? + ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 : + ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2 : + ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_not_resolved, name, containingFile, resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName, (resolved === null || resolved === void 0 ? void 0 : resolved.packagetId) && ts.packageIdToString(resolved.packagetId)); + } + } ts.Debug.assert(resolution !== undefined && !resolution.isInvalidated); seenNamesInFile.set(name, true); resolvedModules.push(getResolutionWithResolvedFileName(resolution)); @@ -110771,7 +114558,7 @@ var ts; redirectedReference: redirectedReference, cache: resolvedTypeReferenceDirectives, perDirectoryCacheWithRedirects: perDirectoryResolvedTypeReferenceDirectives, - loader: ts.resolveTypeReferenceDirective, + loader: resolveTypeReferenceDirective, getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective, shouldRetryResolution: function (resolution) { return resolution.resolvedTypeReferenceDirective === undefined; }, }); @@ -111046,7 +114833,7 @@ var ts; if (isCreatingWatchedDirectory) { // Watching directory is created // Invalidate any resolution has failed lookup in this directory - isInDirectoryChecks.push(fileOrDirectoryPath); + (isInDirectoryChecks || (isInDirectoryChecks = [])).push(fileOrDirectoryPath); } else { // If something to do with folder/file starting with "." in node_modules folder, skip it @@ -111064,8 +114851,8 @@ var ts; if (isNodeModulesAtTypesDirectory(fileOrDirectoryPath) || ts.isNodeModulesDirectory(fileOrDirectoryPath) || isNodeModulesAtTypesDirectory(dirOfFileOrDirectory) || ts.isNodeModulesDirectory(dirOfFileOrDirectory)) { // Invalidate any resolution from this directory - failedLookupChecks.push(fileOrDirectoryPath); - startsWithPathChecks.push(fileOrDirectoryPath); + (failedLookupChecks || (failedLookupChecks = [])).push(fileOrDirectoryPath); + (startsWithPathChecks || (startsWithPathChecks = new ts.Set())).add(fileOrDirectoryPath); } else { if (!isPathWithDefaultFailedLookupExtension(fileOrDirectoryPath) && !customFailedLookupPaths.has(fileOrDirectoryPath)) { @@ -111076,27 +114863,33 @@ var ts; return false; } // Resolution need to be invalidated if failed lookup location is same as the file or directory getting created - failedLookupChecks.push(fileOrDirectoryPath); + (failedLookupChecks || (failedLookupChecks = [])).push(fileOrDirectoryPath); + // If the invalidated file is from a node_modules package, invalidate everything else + // in the package since we might not get notifications for other files in the package. + // This hardens our logic against unreliable file watchers. + var packagePath = ts.parseNodeModuleFromPath(fileOrDirectoryPath); + if (packagePath) + (startsWithPathChecks || (startsWithPathChecks = new ts.Set())).add(packagePath); } } resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations(); } function invalidateResolutionsOfFailedLookupLocations() { - if (!failedLookupChecks.length && !startsWithPathChecks.length && !isInDirectoryChecks.length) { + if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks) { return false; } var invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution); - failedLookupChecks.length = 0; - startsWithPathChecks.length = 0; - isInDirectoryChecks.length = 0; + failedLookupChecks = undefined; + startsWithPathChecks = undefined; + isInDirectoryChecks = undefined; return invalidated; } function canInvalidateFailedLookupResolution(resolution) { return resolution.failedLookupLocations.some(function (location) { var locationPath = resolutionHost.toPath(location); return ts.contains(failedLookupChecks, locationPath) || - startsWithPathChecks.some(function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath); }) || - isInDirectoryChecks.some(function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath); }); + ts.firstDefinedIterator((startsWithPathChecks === null || startsWithPathChecks === void 0 ? void 0 : startsWithPathChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath) ? true : undefined; }) || + (isInDirectoryChecks === null || isInDirectoryChecks === void 0 ? void 0 : isInDirectoryChecks.some(function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath); })); }); } function closeTypeRootsWatch() { @@ -111247,6 +115040,9 @@ var ts; return [ambient]; var info = getInfo(importingSourceFile.path, host); var moduleSourceFile = ts.getSourceFileOfNode(moduleSymbol.valueDeclaration || ts.getNonAugmentationDeclaration(moduleSymbol)); + if (!moduleSourceFile) { + return []; + } var modulePaths = getAllModulePaths(importingSourceFile.path, moduleSourceFile.originalFileName, host); var preferences = getPreferences(userPreferences, compilerOptions, importingSourceFile); var existingSpecifier = ts.forEach(modulePaths, function (modulePath) { return ts.forEach(host.getFileIncludeReasons().get(ts.toPath(modulePath.path, host.getCurrentDirectory(), info.getCanonicalFileName)), function (reason) { @@ -111317,7 +115113,7 @@ var ts; if (!baseUrl && !paths || relativePreference === 0 /* Relative */) { return relativePath; } - var baseDirectory = ts.getPathsBasePath(compilerOptions, host) || baseUrl; + var baseDirectory = ts.getNormalizedAbsolutePath(ts.getPathsBasePath(compilerOptions, host) || baseUrl, host.getCurrentDirectory()); var relativeToBaseUrl = getRelativePathIfInDirectory(moduleFileName, baseDirectory, getCanonicalFileName); if (!relativeToBaseUrl) { return relativePath; @@ -111332,7 +115128,9 @@ var ts; return nonRelative; } if (relativePreference === 3 /* ExternalNonRelative */) { - var projectDirectory = host.getCurrentDirectory(); + var projectDirectory = compilerOptions.configFilePath ? + ts.toPath(ts.getDirectoryPath(compilerOptions.configFilePath), host.getCurrentDirectory(), info.getCanonicalFileName) : + info.getCanonicalFileName(host.getCurrentDirectory()); var modulePath = ts.toPath(moduleFileName, projectDirectory, getCanonicalFileName); var sourceIsInternal = ts.startsWith(sourceDirectory, projectDirectory); var targetIsInternal = ts.startsWith(modulePath, projectDirectory); @@ -111384,12 +115182,8 @@ var ts; return ts.pathIsRelative(text) ? ts.hasJSFileExtension(text) : undefined; }) || false; } - function numberOfDirectorySeparators(str) { - var match = str.match(/\//g); - return match ? match.length : 0; - } function comparePathsByRedirectAndNumberOfDirectorySeparators(a, b) { - return ts.compareBooleans(b.isRedirect, a.isRedirect) || ts.compareValues(numberOfDirectorySeparators(a.path), numberOfDirectorySeparators(b.path)); + return ts.compareBooleans(b.isRedirect, a.isRedirect) || ts.compareNumberOfDirectorySeparators(a.path, b.path); } function getNearestAncestorDirectoryWithPackageJson(host, fileName) { if (host.getNearestAncestorDirectoryWithPackageJson) { @@ -111403,40 +115197,49 @@ var ts; var getCanonicalFileName = ts.hostGetCanonicalFileName(host); var cwd = host.getCurrentDirectory(); var referenceRedirect = host.isSourceOfProjectReferenceRedirect(importedFileName) ? host.getProjectReferenceRedirect(importedFileName) : undefined; - var redirects = host.redirectTargetsMap.get(ts.toPath(importedFileName, cwd, getCanonicalFileName)) || ts.emptyArray; + var importedPath = ts.toPath(importedFileName, cwd, getCanonicalFileName); + var redirects = host.redirectTargetsMap.get(importedPath) || ts.emptyArray; var importedFileNames = __spreadArray(__spreadArray(__spreadArray([], (referenceRedirect ? [referenceRedirect] : ts.emptyArray)), [importedFileName]), redirects); var targets = importedFileNames.map(function (f) { return ts.getNormalizedAbsolutePath(f, cwd); }); + var shouldFilterIgnoredPaths = !ts.every(targets, ts.containsIgnoredPath); if (!preferSymlinks) { - var result_15 = ts.forEach(targets, function (p) { return cb(p, referenceRedirect === p); }); + // Symlinks inside ignored paths are already filtered out of the symlink cache, + // so we only need to remove them from the realpath filenames. + var result_15 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); }); if (result_15) return result_15; } var links = host.getSymlinkCache ? host.getSymlinkCache() : ts.discoverProbableSymlinks(host.getSourceFiles(), getCanonicalFileName, cwd); - var symlinkedDirectories = links.getSymlinkedDirectories(); - var useCaseSensitiveFileNames = !host.useCaseSensitiveFileNames || host.useCaseSensitiveFileNames(); - var result = symlinkedDirectories && ts.forEachEntry(symlinkedDirectories, function (resolved, path) { - if (resolved === false) - return undefined; - if (ts.startsWithDirectory(importingFileName, resolved.realPath, getCanonicalFileName)) { - return undefined; // Don't want to a package to globally import from itself + var symlinkedDirectories = links.getSymlinkedDirectoriesByRealpath(); + var fullImportedFileName = ts.getNormalizedAbsolutePath(importedFileName, cwd); + var result = symlinkedDirectories && ts.forEachAncestorDirectory(ts.getDirectoryPath(fullImportedFileName), function (realPathDirectory) { + var symlinkDirectories = symlinkedDirectories.get(ts.ensureTrailingDirectorySeparator(ts.toPath(realPathDirectory, cwd, getCanonicalFileName))); + if (!symlinkDirectories) + return undefined; // Continue to ancestor directory + // Don't want to a package to globally import from itself (importNameCodeFix_symlink_own_package.ts) + if (ts.startsWithDirectory(importingFileName, realPathDirectory, getCanonicalFileName)) { + return false; // Stop search, each ancestor directory will also hit this condition } return ts.forEach(targets, function (target) { - if (!ts.containsPath(resolved.real, target, !useCaseSensitiveFileNames)) { + if (!ts.startsWithDirectory(target, realPathDirectory, getCanonicalFileName)) { return; } - var relative = ts.getRelativePathFromDirectory(resolved.real, target, getCanonicalFileName); - var option = ts.resolvePath(path, relative); - if (!host.fileExists || host.fileExists(option)) { + var relative = ts.getRelativePathFromDirectory(realPathDirectory, target, getCanonicalFileName); + for (var _i = 0, symlinkDirectories_1 = symlinkDirectories; _i < symlinkDirectories_1.length; _i++) { + var symlinkDirectory = symlinkDirectories_1[_i]; + var option = ts.resolvePath(symlinkDirectory, relative); var result_16 = cb(option, target === referenceRedirect); + shouldFilterIgnoredPaths = true; // We found a non-ignored path in symlinks, so we can reject ignored-path realpaths if (result_16) return result_16; } }); }); - return result || - (preferSymlinks ? ts.forEach(targets, function (p) { return cb(p, p === referenceRedirect); }) : undefined); + return result || (preferSymlinks + ? ts.forEach(targets, function (p) { return shouldFilterIgnoredPaths && ts.containsIgnoredPath(p) ? undefined : cb(p, p === referenceRedirect); }) + : undefined); } moduleSpecifiers.forEachFileNameOfModule = forEachFileNameOfModule; /** @@ -111444,8 +115247,14 @@ var ts; * Symlinks will be returned first so they are preferred over the real path. */ function getAllModulePaths(importingFileName, importedFileName, host) { - var cwd = host.getCurrentDirectory(); + var _a; + var cache = (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host); var getCanonicalFileName = ts.hostGetCanonicalFileName(host); + if (cache) { + var cached = cache.get(importingFileName, ts.toPath(importedFileName, host.getCurrentDirectory(), getCanonicalFileName)); + if (typeof cached === "object") + return cached; + } var allFileNames = new ts.Map(); var importedFileFromNodeModules = false; forEachFileNameOfModule(importingFileName, importedFileName, host, @@ -111457,7 +115266,7 @@ var ts; }); // Sort by paths closest to importing file Name directory var sortedPaths = []; - var _loop_24 = function (directory) { + var _loop_26 = function (directory) { var directoryStart = ts.ensureTrailingDirectorySeparator(directory); var pathsInDirectory; allFileNames.forEach(function (_a, fileName) { @@ -111480,10 +115289,10 @@ var ts; out_directory_1 = directory; }; var out_directory_1; - for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0;) { - var state_7 = _loop_24(directory); + for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) { + var state_9 = _loop_26(directory); directory = out_directory_1; - if (state_7 === "break") + if (state_9 === "break") break; } if (allFileNames.size) { @@ -111492,10 +115301,14 @@ var ts; remainingPaths.sort(comparePathsByRedirectAndNumberOfDirectorySeparators); sortedPaths.push.apply(sortedPaths, remainingPaths); } + if (cache) { + cache.set(importingFileName, ts.toPath(importedFileName, host.getCurrentDirectory(), getCanonicalFileName), sortedPaths); + } return sortedPaths; } function tryGetModuleNameFromAmbientModule(moduleSymbol, checker) { - var decl = ts.find(moduleSymbol.declarations, function (d) { return ts.isNonGlobalAmbientModule(d) && (!ts.isExternalModuleAugmentation(d) || !ts.isExternalModuleNameRelative(ts.getTextOfIdentifierOrLiteral(d.name))); }); + var _a; + var decl = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.isNonGlobalAmbientModule(d) && (!ts.isExternalModuleAugmentation(d) || !ts.isExternalModuleNameRelative(ts.getTextOfIdentifierOrLiteral(d.name))); }); if (decl) { return decl.name.text; } @@ -111551,7 +115364,7 @@ var ts; ts.startsWith(relativeToBaseUrl, prefix) && ts.endsWith(relativeToBaseUrl, suffix) || !suffix && relativeToBaseUrl === ts.removeTrailingDirectorySeparator(prefix)) { - var matchedStar = relativeToBaseUrl.substr(prefix.length, relativeToBaseUrl.length - suffix.length); + var matchedStar = relativeToBaseUrl.substr(prefix.length, relativeToBaseUrl.length - suffix.length - prefix.length); return key.replace("*", matchedStar); } } @@ -111855,10 +115668,10 @@ var ts; } ts.createWatchStatusReporter = createWatchStatusReporter; /** Parses config file using System interface */ - function parseConfigFileWithSystem(configFileName, optionsToExtend, watchOptionsToExtend, system, reportDiagnostic) { + function parseConfigFileWithSystem(configFileName, optionsToExtend, extendedConfigCache, watchOptionsToExtend, system, reportDiagnostic) { var host = system; host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(system, reportDiagnostic, diagnostic); }; - var result = ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtend, host, /*extendedConfigCache*/ undefined, watchOptionsToExtend); + var result = ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtend, host, extendedConfigCache, watchOptionsToExtend); host.onUnRecoverableConfigFileDiagnostic = undefined; // TODO: GH#18217 return result; } @@ -112126,7 +115939,10 @@ var ts; MissingFile: "Missing file", WildcardDirectory: "Wild card directory", FailedLookupLocations: "Failed Lookup Locations", - TypeRoots: "Type roots" + TypeRoots: "Type roots", + ConfigFileOfReferencedProject: "Config file of referened project", + ExtendedConfigOfReferencedProject: "Extended config file of referenced project", + WildcardDirectoryOfReferencedProject: "Wild card directory of referenced project", }; function createWatchFactory(host, options) { var watchLogLevel = host.trace ? options.extendedDiagnostics ? ts.WatchLogLevel.Verbose : options.diagnostics ? ts.WatchLogLevel.TriggerOnly : ts.WatchLogLevel.None : ts.WatchLogLevel.None; @@ -112173,6 +115989,7 @@ var ts; getEnvironmentVariable: ts.maybeBind(host, host.getEnvironmentVariable) || (function () { return ""; }), createHash: ts.maybeBind(host, host.createHash), readDirectory: ts.maybeBind(host, host.readDirectory), + disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature, }; function writeFile(fileName, text, writeByteOrderMark, onError) { try { @@ -112230,7 +116047,8 @@ var ts; createDirectory: function (path) { return system.createDirectory(path); }, writeFile: function (path, data, writeByteOrderMark) { return system.writeFile(path, data, writeByteOrderMark); }, createHash: ts.maybeBind(system, system.createHash), - createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram + createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram, + disableUseFileVersionAsSignature: system.disableUseFileVersionAsSignature, }; } ts.createProgramHost = createProgramHost; @@ -112318,6 +116136,7 @@ var ts; if (system === void 0) { system = ts.sys; } var host = ts.createCompilerHostWorker(options, /*setParentNodes*/ undefined, system); host.createHash = ts.maybeBind(system, system.createHash); + host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature; ts.setGetSourceFileAsHashVersioned(host, system); ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); }); return host; @@ -112361,11 +116180,13 @@ var ts; function createWatchProgram(host) { var builderProgram; var reloadLevel; // level to indicate if the program needs to be reloaded from config file/just filenames etc - var extendedConfigFilesMap; // Map of file watchers for the extended config files var missingFilesMap; // Map of file watchers for the missing files var watchedWildcardDirectories; // map of watchers for the wild card directories in the config file var timerToUpdateProgram; // timer callback to recompile the program var timerToInvalidateFailedLookupResolutions; // timer callback to invalidate resolutions for changes in failed lookup locations + 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 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 var hasChangedCompilerOptions = false; // True if the compiler options have changed between compilations @@ -112415,6 +116236,7 @@ var ts; compilerHost.getNewLine = function () { return newLine; }; compilerHost.fileExists = fileExists; compilerHost.onReleaseOldSourceFile = onReleaseOldSourceFile; + compilerHost.onReleaseParsedCommandLine = onReleaseParsedCommandLine; // Members for ResolutionCacheHost compilerHost.toPath = toPath; compilerHost.getCompilationSettings = function () { return compilerOptions; }; @@ -112428,6 +116250,7 @@ var ts; compilerHost.fileIsOpen = ts.returnFalse; compilerHost.getCurrentProgram = getCurrentProgram; compilerHost.writeLog = writeLog; + compilerHost.getParsedCommandLine = getParsedCommandLine; // Cache for the module resolution var resolutionCache = ts.createResolutionCache(compilerHost, configFileName ? ts.getDirectoryPath(ts.getNormalizedAbsolutePath(configFileName, currentDirectory)) : @@ -112458,7 +116281,8 @@ var ts; // Update the wild card directory watch watchConfigFileWildCardDirectories(); // Update extended config file watch - watchExtendedConfigFiles(); + if (configFileName) + updateExtendedConfigFilesWatches(toPath(configFileName), compilerOptions, watchOptions, ts.WatchType.ExtendedConfigFile); return configFileName ? { getCurrentProgram: getCurrentBuilderProgram, getProgram: updateProgram, close: close } : { getCurrentProgram: getCurrentBuilderProgram, getProgram: updateProgram, updateRootFileNames: updateRootFileNames, close: close }; @@ -112475,9 +116299,11 @@ var ts; configFileWatcher.close(); configFileWatcher = undefined; } - if (extendedConfigFilesMap) { - ts.clearMap(extendedConfigFilesMap, ts.closeFileWatcher); - extendedConfigFilesMap = undefined; + extendedConfigCache === null || extendedConfigCache === void 0 ? void 0 : extendedConfigCache.clear(); + extendedConfigCache = undefined; + if (sharedExtendedConfigFileWatchers) { + ts.clearMap(sharedExtendedConfigFileWatchers, ts.closeFileWatcherOf); + sharedExtendedConfigFileWatchers = undefined; } if (watchedWildcardDirectories) { ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcherOf); @@ -112487,6 +116313,17 @@ var ts; ts.clearMap(missingFilesMap, ts.closeFileWatcher); missingFilesMap = undefined; } + if (parsedConfigs) { + ts.clearMap(parsedConfigs, function (config) { + var _a; + (_a = config.watcher) === null || _a === void 0 ? void 0 : _a.close(); + config.watcher = undefined; + if (config.watchedDirectories) + ts.clearMap(config.watchedDirectories, ts.closeFileWatcherOf); + config.watchedDirectories = undefined; + }); + parsedConfigs = undefined; + } } function getCurrentBuilderProgram() { return builderProgram; @@ -112506,7 +116343,7 @@ var ts; } // All resolutions are invalid if user provided resolutions var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution); - if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, projectReferences)) { + if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) { if (hasChangedConfigFileParsingErrors) { builderProgram = createProgram(/*rootNames*/ undefined, /*options*/ undefined, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences); hasChangedConfigFileParsingErrors = false; @@ -112525,6 +116362,8 @@ var ts; writeLog("CreatingProgramWith::"); writeLog(" roots: " + JSON.stringify(rootFileNames)); writeLog(" options: " + JSON.stringify(compilerOptions)); + if (projectReferences) + writeLog(" projectReferences: " + JSON.stringify(projectReferences)); var needsUpdateInTypeRootWatch = hasChangedCompilerOptions || !getCurrentProgram(); hasChangedCompilerOptions = false; hasChangedConfigFileParsingErrors = false; @@ -112747,10 +116586,10 @@ var ts; // Update the wild card directory watch watchConfigFileWildCardDirectories(); // Update extended config file watch - watchExtendedConfigFiles(); + updateExtendedConfigFilesWatches(toPath(configFileName), compilerOptions, watchOptions, ts.WatchType.ExtendedConfigFile); } function parseConfigFile() { - setConfigFileParsingResult(ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtendForConfigFile, parseConfigFileHost, /*extendedConfigCache*/ undefined, watchOptionsToExtend, extraFileExtensions)); // TODO: GH#18217 + setConfigFileParsingResult(ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtendForConfigFile, parseConfigFileHost, extendedConfigCache || (extendedConfigCache = new ts.Map()), watchOptionsToExtend, extraFileExtensions)); // TODO: GH#18217 } function setConfigFileParsingResult(configFileParseResult) { rootFileNames = configFileParseResult.fileNames; @@ -112762,6 +116601,56 @@ var ts; canConfigFileJsonReportNoInputFiles = ts.canJsonReportNoInputFiles(configFileParseResult.raw); hasChangedConfigFileParsingErrors = true; } + function getParsedCommandLine(configFileName) { + var configPath = toPath(configFileName); + var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(configPath); + if (config) { + if (!config.reloadLevel) + return config.parsedCommandLine; + // With host implementing getParsedCommandLine we cant just update file names + if (config.parsedCommandLine && config.reloadLevel === ts.ConfigFileProgramReloadLevel.Partial && !host.getParsedCommandLine) { + writeLog("Reloading new file names and options"); + var fileNames = ts.getFileNamesFromConfigSpecs(config.parsedCommandLine.options.configFile.configFileSpecs, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), compilerOptions, parseConfigFileHost); + config.parsedCommandLine = __assign(__assign({}, config.parsedCommandLine), { fileNames: fileNames }); + config.reloadLevel = undefined; + return config.parsedCommandLine; + } + } + writeLog("Loading config file: " + configFileName); + var parsedCommandLine = host.getParsedCommandLine ? + host.getParsedCommandLine(configFileName) : + getParsedCommandLineFromConfigFileHost(configFileName); + if (config) { + config.parsedCommandLine = parsedCommandLine; + config.reloadLevel = undefined; + } + else { + (parsedConfigs || (parsedConfigs = new ts.Map())).set(configPath, config = { parsedCommandLine: parsedCommandLine }); + } + watchReferencedProject(configFileName, configPath, config); + return parsedCommandLine; + } + function getParsedCommandLineFromConfigFileHost(configFileName) { + // Ignore the file absent errors + var onUnRecoverableConfigFileDiagnostic = parseConfigFileHost.onUnRecoverableConfigFileDiagnostic; + parseConfigFileHost.onUnRecoverableConfigFileDiagnostic = ts.noop; + var parsedCommandLine = ts.getParsedCommandLineOfConfigFile(configFileName, + /*optionsToExtend*/ undefined, parseConfigFileHost, extendedConfigCache || (extendedConfigCache = new ts.Map()), watchOptionsToExtend); + parseConfigFileHost.onUnRecoverableConfigFileDiagnostic = onUnRecoverableConfigFileDiagnostic; + return parsedCommandLine; + } + function onReleaseParsedCommandLine(fileName) { + var _a; + var path = toPath(fileName); + var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(path); + if (!config) + return; + parsedConfigs.delete(path); + if (config.watchedDirectories) + ts.clearMap(config.watchedDirectories, ts.closeFileWatcherOf); + (_a = config.watcher) === null || _a === void 0 ? void 0 : _a.close(); + ts.clearSharedExtendedConfigFileWatcher(path, sharedExtendedConfigFileWatchers); + } function watchFilePath(path, file, callback, pollingInterval, options, watchType) { return watchFile(file, function (fileName, eventKind) { return callback(fileName, eventKind, path); }, pollingInterval, options, watchType); } @@ -112771,7 +116660,6 @@ var ts; if (eventKind === ts.FileWatcherEventKind.Deleted && sourceFilesCache.has(path)) { resolutionCache.invalidateResolutionOfFile(path); } - resolutionCache.removeResolutionsFromProjectReferenceRedirects(path); nextSourceFileVersion(path); // Update the program scheduleProgramUpdate(); @@ -112782,7 +116670,10 @@ var ts; } } function watchMissingFilePath(missingFilePath) { - return watchFilePath(missingFilePath, missingFilePath, onMissingFileChange, ts.PollingInterval.Medium, watchOptions, ts.WatchType.MissingFile); + // If watching missing referenced config file, we are already watching it so no need for separate watcher + return (parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.has(missingFilePath)) ? + ts.noopFileWatcher : + watchFilePath(missingFilePath, missingFilePath, onMissingFileChange, ts.PollingInterval.Medium, watchOptions, ts.WatchType.MissingFile); } function onMissingFileChange(fileName, eventKind, missingFilePath) { updateCachedSystemWithFile(fileName, missingFilePath, eventKind); @@ -112819,10 +116710,11 @@ var ts; configFileName: configFileName, extraFileExtensions: extraFileExtensions, options: compilerOptions, - program: getCurrentBuilderProgram(), + program: getCurrentBuilderProgram() || rootFileNames, currentDirectory: currentDirectory, useCaseSensitiveFileNames: useCaseSensitiveFileNames, - writeLog: writeLog + writeLog: writeLog, + toPath: toPath, })) return; // Reload is pending, do the reload @@ -112833,18 +116725,87 @@ var ts; } }, flags, watchOptions, ts.WatchType.WildcardDirectory); } - function watchExtendedConfigFiles() { - var _a; - // Update the extended config files watcher - ts.mutateMap(extendedConfigFilesMap || (extendedConfigFilesMap = new ts.Map()), ts.arrayToMap(((_a = compilerOptions.configFile) === null || _a === void 0 ? void 0 : _a.extendedSourceFiles) || ts.emptyArray, toPath), { - // Watch the extended config files - createNewValue: watchExtendedConfigFile, - // Config files that are no longer extended should no longer be watched. - onDeleteValue: ts.closeFileWatcher - }); + function updateExtendedConfigFilesWatches(forProjectPath, options, watchOptions, watchType) { + ts.updateSharedExtendedConfigFileWatcher(forProjectPath, options, sharedExtendedConfigFileWatchers || (sharedExtendedConfigFileWatchers = new ts.Map()), function (extendedConfigFileName, extendedConfigFilePath) { return watchFile(extendedConfigFileName, function (_fileName, eventKind) { + var _a; + updateCachedSystemWithFile(extendedConfigFileName, extendedConfigFilePath, eventKind); + // Update extended config cache + if (extendedConfigCache) + ts.cleanExtendedConfigCache(extendedConfigCache, extendedConfigFilePath, toPath); + // Update projects + var projects = (_a = sharedExtendedConfigFileWatchers.get(extendedConfigFilePath)) === null || _a === void 0 ? void 0 : _a.projects; + // If there are no referenced projects this extended config file watcher depend on ignore + if (!(projects === null || projects === void 0 ? void 0 : projects.size)) + return; + projects.forEach(function (projectPath) { + if (toPath(configFileName) === projectPath) { + // If this is the config file of the project, reload completely + reloadLevel = ts.ConfigFileProgramReloadLevel.Full; + } + else { + // Reload config for the referenced projects and remove the resolutions from referenced projects since the config file changed + var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(projectPath); + if (config) + config.reloadLevel = ts.ConfigFileProgramReloadLevel.Full; + resolutionCache.removeResolutionsFromProjectReferenceRedirects(projectPath); + } + scheduleProgramUpdate(); + }); + }, ts.PollingInterval.High, watchOptions, watchType); }, toPath); } - function watchExtendedConfigFile(extendedConfigFile) { - return watchFile(extendedConfigFile, scheduleProgramReload, ts.PollingInterval.High, watchOptions, ts.WatchType.ExtendedConfigFile); + function watchReferencedProject(configFileName, configPath, commandLine) { + var _a, _b, _c, _d, _e; + // Watch file + commandLine.watcher || (commandLine.watcher = watchFile(configFileName, function (_fileName, eventKind) { + updateCachedSystemWithFile(configFileName, configPath, eventKind); + var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(configPath); + if (config) + config.reloadLevel = ts.ConfigFileProgramReloadLevel.Full; + resolutionCache.removeResolutionsFromProjectReferenceRedirects(configPath); + scheduleProgramUpdate(); + }, ts.PollingInterval.High, ((_a = commandLine.parsedCommandLine) === null || _a === void 0 ? void 0 : _a.watchOptions) || watchOptions, ts.WatchType.ConfigFileOfReferencedProject)); + // Watch Wild card + if ((_b = commandLine.parsedCommandLine) === null || _b === void 0 ? void 0 : _b.wildcardDirectories) { + ts.updateWatchingWildcardDirectories(commandLine.watchedDirectories || (commandLine.watchedDirectories = new ts.Map()), new ts.Map(ts.getEntries((_c = commandLine.parsedCommandLine) === null || _c === void 0 ? void 0 : _c.wildcardDirectories)), function (directory, flags) { + var _a; + return watchDirectory(directory, function (fileOrDirectory) { + var fileOrDirectoryPath = toPath(fileOrDirectory); + // Since the file existence changed, update the sourceFiles cache + if (cachedDirectoryStructureHost) { + cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); + } + nextSourceFileVersion(fileOrDirectoryPath); + var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(configPath); + if (!(config === null || config === void 0 ? void 0 : config.parsedCommandLine)) + return; + if (ts.isIgnoredFileFromWildCardWatching({ + watchedDirPath: toPath(directory), + fileOrDirectory: fileOrDirectory, + fileOrDirectoryPath: fileOrDirectoryPath, + configFileName: configFileName, + options: config.parsedCommandLine.options, + program: config.parsedCommandLine.fileNames, + currentDirectory: currentDirectory, + useCaseSensitiveFileNames: useCaseSensitiveFileNames, + writeLog: writeLog, + toPath: toPath, + })) + return; + // Reload is pending, do the reload + if (config.reloadLevel !== ts.ConfigFileProgramReloadLevel.Full) { + config.reloadLevel = ts.ConfigFileProgramReloadLevel.Partial; + // Schedule Update the program + scheduleProgramUpdate(); + } + }, flags, ((_a = commandLine.parsedCommandLine) === null || _a === void 0 ? void 0 : _a.watchOptions) || watchOptions, ts.WatchType.WildcardDirectoryOfReferencedProject); + }); + } + else if (commandLine.watchedDirectories) { + ts.clearMap(commandLine.watchedDirectories, ts.closeFileWatcherOf); + commandLine.watchedDirectories = undefined; + } + // Watch extended config files + updateExtendedConfigFilesWatches(configPath, (_d = commandLine.parsedCommandLine) === null || _d === void 0 ? void 0 : _d.options, ((_e = commandLine.parsedCommandLine) === null || _e === void 0 ? void 0 : _e.watchOptions) || watchOptions, ts.WatchType.ExtendedConfigOfReferencedProject); } } ts.createWatchProgram = createWatchProgram; @@ -113004,12 +116965,19 @@ var ts; compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames); compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives); 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) { var loader_3 = function (moduleName, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference).resolvedModule; }; compilerHost.resolveModuleNames = function (moduleNames, containingFile, _reusedNames, redirectedReference) { return ts.loadWithLocalCache(ts.Debug.checkEachDefined(moduleNames), containingFile, redirectedReference, loader_3); }; } + if (!compilerHost.resolveTypeReferenceDirectives) { + var loader_4 = function (moduleName, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache).resolvedTypeReferenceDirective; }; + compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { + return ts.loadWithLocalCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, loader_4); + }; + } var _a = ts.createWatchFactory(hostWithWatch, options), watchFile = _a.watchFile, watchDirectory = _a.watchDirectory, writeLog = _a.writeLog; var state = { host: host, @@ -113034,6 +117002,7 @@ var ts; projectErrorsReported: new ts.Map(), compilerHost: compilerHost, moduleResolutionCache: moduleResolutionCache, + typeReferenceDirectiveResolutionCache: typeReferenceDirectiveResolutionCache, // Mutable state buildOrder: undefined, readFileWithCache: function (f) { return host.readFile(f); }, @@ -113072,6 +117041,10 @@ var ts; function isParsedCommandLine(entry) { return !!entry.options; } + function getCachedParsedConfigFile(state, configFilePath) { + var value = state.configFileCache.get(configFilePath); + return value && isParsedCommandLine(value) ? value : undefined; + } function parseConfigFile(state, configFileName, configFilePath) { var configFileCache = state.configFileCache; var value = configFileCache.get(configFilePath); @@ -113217,7 +117190,7 @@ var ts; function disableCache(state) { if (!state.cache) return; - var cache = state.cache, host = state.host, compilerHost = state.compilerHost, extendedConfigCache = state.extendedConfigCache, moduleResolutionCache = state.moduleResolutionCache; + var cache = state.cache, host = state.host, compilerHost = state.compilerHost, extendedConfigCache = state.extendedConfigCache, moduleResolutionCache = state.moduleResolutionCache, typeReferenceDirectiveResolutionCache = state.typeReferenceDirectiveResolutionCache; host.readFile = cache.originalReadFile; host.fileExists = cache.originalFileExists; host.directoryExists = cache.originalDirectoryExists; @@ -113226,10 +117199,8 @@ var ts; compilerHost.getSourceFile = cache.originalGetSourceFile; state.readFileWithCache = cache.originalReadFileWithCache; extendedConfigCache.clear(); - if (moduleResolutionCache) { - moduleResolutionCache.directoryToModuleNameMap.clear(); - moduleResolutionCache.moduleNameToDirectoryMap.clear(); - } + moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.clear(); + typeReferenceDirectiveResolutionCache === null || typeReferenceDirectiveResolutionCache === void 0 ? void 0 : typeReferenceDirectiveResolutionCache.clear(); state.cache = undefined; } function clearProjectStatus(state, resolved) { @@ -113396,6 +117367,7 @@ var ts; return withProgramOrUndefined(action) || ts.emptyArray; } function createProgram() { + var _a, _b; ts.Debug.assert(program === undefined); if (state.options.dry) { reportStatus(state, ts.Diagnostics.A_non_dry_build_would_build_project_0, project); @@ -113415,7 +117387,8 @@ var ts; var host = state.host, compilerHost = state.compilerHost; state.projectCompilerOptions = config.options; // Update module resolution cache if needed - updateModuleResolutionCache(state, project, config); + (_a = state.moduleResolutionCache) === null || _a === void 0 ? void 0 : _a.update(config.options); + (_b = state.typeReferenceDirectiveResolutionCache) === null || _b === void 0 ? void 0 : _b.update(config.options); // Create program program = host.createProgram(config.fileNames, config.options, compilerHost, getOldProgram(state, projectPath, config), ts.getConfigFileParsingDiagnostics(config), config.projectReferences); if (state.watch) { @@ -113590,7 +117563,7 @@ var ts; emitBundle(writeFile, customTransformers); break; case BuildStep.BuildInvalidatedProjectOfBundle: - ts.Debug.checkDefined(invalidatedProjectOfBundle).done(cancellationToken); + ts.Debug.checkDefined(invalidatedProjectOfBundle).done(cancellationToken, writeFile, customTransformers); step = BuildStep.Done; break; case BuildStep.QueueReferencingProjects: @@ -113732,34 +117705,9 @@ var ts; afterProgramDone(state, program, config); return { buildResult: buildResult, step: BuildStep.QueueReferencingProjects }; } - function updateModuleResolutionCache(state, proj, config) { - if (!state.moduleResolutionCache) - return; - // Update module resolution cache if needed - var moduleResolutionCache = state.moduleResolutionCache; - var projPath = toPath(state, proj); - if (moduleResolutionCache.directoryToModuleNameMap.redirectsMap.size === 0) { - // The own map will be for projectCompilerOptions - ts.Debug.assert(moduleResolutionCache.moduleNameToDirectoryMap.redirectsMap.size === 0); - moduleResolutionCache.directoryToModuleNameMap.redirectsMap.set(projPath, moduleResolutionCache.directoryToModuleNameMap.ownMap); - moduleResolutionCache.moduleNameToDirectoryMap.redirectsMap.set(projPath, moduleResolutionCache.moduleNameToDirectoryMap.ownMap); - } - else { - // Set correct own map - ts.Debug.assert(moduleResolutionCache.moduleNameToDirectoryMap.redirectsMap.size > 0); - var ref = { - sourceFile: config.options.configFile, - commandLine: config - }; - moduleResolutionCache.directoryToModuleNameMap.setOwnMap(moduleResolutionCache.directoryToModuleNameMap.getOrCreateMapOfCacheRedirects(ref)); - moduleResolutionCache.moduleNameToDirectoryMap.setOwnMap(moduleResolutionCache.moduleNameToDirectoryMap.getOrCreateMapOfCacheRedirects(ref)); - } - moduleResolutionCache.directoryToModuleNameMap.setOwnOptions(config.options); - moduleResolutionCache.moduleNameToDirectoryMap.setOwnOptions(config.options); - } function checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName) { // Check tsconfig time - var tsconfigTime = state.host.getModifiedTime(configFile) || ts.missingFileModifiedTime; + var tsconfigTime = ts.getModifiedTime(state.host, configFile); if (oldestOutputFileTime < tsconfigTime) { return { type: ts.UpToDateStatusType.OutOfDateWithSelf, @@ -113769,6 +117717,7 @@ var ts; } } function getUpToDateStatusWorker(state, project, resolvedPath) { + var force = !!state.options.force; var newestInputFileName = undefined; var newestInputFileTime = minimumDate; var host = state.host; @@ -113781,10 +117730,13 @@ var ts; reason: inputFile + " does not exist" }; } - var inputTime = host.getModifiedTime(inputFile) || ts.missingFileModifiedTime; - if (inputTime > newestInputFileTime) { - newestInputFileName = inputFile; - newestInputFileTime = inputTime; + if (!force) { + var inputTime = ts.getModifiedTime(host, inputFile); + host.getModifiedTime(inputFile); + if (inputTime > newestInputFileTime) { + newestInputFileName = inputFile; + newestInputFileTime = inputTime; + } } } // Container if no files are specified in the project @@ -113803,36 +117755,38 @@ var ts; var missingOutputFileName; var newestDeclarationFileContentChangedTime = minimumDate; var isOutOfDateWithInputs = false; - for (var _b = 0, outputs_1 = outputs; _b < outputs_1.length; _b++) { - var output = outputs_1[_b]; - // Output is missing; can stop checking - // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status - if (!host.fileExists(output)) { - missingOutputFileName = output; - break; - } - var outputTime = host.getModifiedTime(output) || ts.missingFileModifiedTime; - if (outputTime < oldestOutputFileTime) { - oldestOutputFileTime = outputTime; - oldestOutputFileName = output; - } - // If an output is older than the newest input, we can stop checking - // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status - if (outputTime < newestInputFileTime) { - isOutOfDateWithInputs = true; - break; - } - if (outputTime > newestOutputFileTime) { - newestOutputFileTime = outputTime; - newestOutputFileName = output; - } - // Keep track of when the most recent time a .d.ts file was changed. - // In addition to file timestamps, we also keep track of when a .d.ts file - // had its file touched but not had its contents changed - this allows us - // to skip a downstream typecheck - if (isDeclarationFile(output)) { - var outputModifiedTime = host.getModifiedTime(output) || ts.missingFileModifiedTime; - newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime); + if (!force) { + for (var _b = 0, outputs_1 = outputs; _b < outputs_1.length; _b++) { + var output = outputs_1[_b]; + // Output is missing; can stop checking + // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status + if (!host.fileExists(output)) { + missingOutputFileName = output; + break; + } + var outputTime = ts.getModifiedTime(host, output); + if (outputTime < oldestOutputFileTime) { + oldestOutputFileTime = outputTime; + oldestOutputFileName = output; + } + // If an output is older than the newest input, we can stop checking + // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status + if (outputTime < newestInputFileTime) { + isOutOfDateWithInputs = true; + break; + } + if (outputTime > newestOutputFileTime) { + newestOutputFileTime = outputTime; + newestOutputFileName = output; + } + // Keep track of when the most recent time a .d.ts file was changed. + // In addition to file timestamps, we also keep track of when a .d.ts file + // had its file touched but not had its contents changed - this allows us + // to skip a downstream typecheck + if (isDeclarationFile(output)) { + var outputModifiedTime = ts.getModifiedTime(host, output); + newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime); + } } } var pseudoUpToDate = false; @@ -113868,7 +117822,8 @@ var ts; }; } // Check oldest output file name only if there is no missing output file name - if (!missingOutputFileName) { + // (a check we will have skipped if this is a forced build) + if (!force && !missingOutputFileName) { // If the upstream project's newest file is older than our oldest output, we // can't be out of date because of it if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) { @@ -113914,7 +117869,7 @@ var ts; if (extendedConfigStatus) return extendedConfigStatus; } - if (!state.buildInfoChecked.has(resolvedPath)) { + if (!force && !state.buildInfoChecked.has(resolvedPath)) { state.buildInfoChecked.set(resolvedPath, true); var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options); if (buildInfoPath) { @@ -113959,6 +117914,8 @@ var ts; return actual; } function updateOutputTimestampsWorker(state, proj, priorNewestUpdateTime, verboseMessage, skipOutputs) { + if (proj.options.noEmit) + return priorNewestUpdateTime; var host = state.host; var outputs = ts.getAllProjectOutputs(proj, !host.useCaseSensitiveFileNames()); if (!skipOutputs || outputs.length !== skipOutputs.size) { @@ -113974,7 +117931,7 @@ var ts; reportStatus(state, verboseMessage, proj.options.configFilePath); } if (isDeclarationFile(file)) { - priorNewestUpdateTime = newer(priorNewestUpdateTime, host.getModifiedTime(file) || ts.missingFileModifiedTime); + priorNewestUpdateTime = newer(priorNewestUpdateTime, ts.getModifiedTime(host, file)); } host.setModifiedTime(file, now); } @@ -114056,7 +118013,7 @@ var ts; } } } - function build(state, project, cancellationToken, onlyReferences) { + function build(state, project, cancellationToken, writeFile, getCustomTransformers, onlyReferences) { var buildOrder = getBuildOrderFor(state, project, onlyReferences); if (!buildOrder) return ts.ExitStatus.InvalidProject_OutputsSkipped; @@ -114068,7 +118025,7 @@ var ts; if (!invalidatedProject) break; reportQueue = false; - invalidatedProject.done(cancellationToken); + invalidatedProject.done(cancellationToken, writeFile, getCustomTransformers === null || getCustomTransformers === void 0 ? void 0 : getCustomTransformers(invalidatedProject.project)); if (!state.diagnostics.has(invalidatedProject.projectPath)) successfulProjects++; } @@ -114103,8 +118060,14 @@ var ts; continue; } var outputs = ts.getAllProjectOutputs(parsed, !host.useCaseSensitiveFileNames()); + if (!outputs.length) + continue; + var inputFileNames = new ts.Set(parsed.fileNames.map(function (f) { return toPath(state, f); })); for (var _a = 0, outputs_3 = outputs; _a < outputs_3.length; _a++) { var output = outputs_3[_a]; + // If output name is same as input file name, do not delete and ignore the error + if (inputFileNames.has(toPath(state, output))) + continue; if (host.fileExists(output)) { if (filesToDelete) { filesToDelete.push(output); @@ -114180,7 +118143,7 @@ var ts; }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.ConfigFile, resolved)); } function watchExtendedConfigFiles(state, resolvedPath, parsed) { - ts.updateSharedExtendedConfigFileWatcher(resolvedPath, parsed, state.allWatchedExtendedConfigFiles, function (extendedConfigFileName, extendedConfigFilePath) { return state.watchFile(extendedConfigFileName, function () { + ts.updateSharedExtendedConfigFileWatcher(resolvedPath, parsed === null || parsed === void 0 ? void 0 : parsed.options, state.allWatchedExtendedConfigFiles, function (extendedConfigFileName, extendedConfigFilePath) { return state.watchFile(extendedConfigFileName, function () { var _a; return (_a = state.allWatchedExtendedConfigFiles.get(extendedConfigFilePath)) === null || _a === void 0 ? void 0 : _a.projects.forEach(function (projectConfigFilePath) { return invalidateProjectAndScheduleBuilds(state, projectConfigFilePath, ts.ConfigFileProgramReloadLevel.Full); @@ -114191,6 +118154,7 @@ var ts; if (!state.watch) return; ts.updateWatchingWildcardDirectories(getOrCreateValueMapFromConfigFileMap(state.allWatchedWildcardDirectories, resolvedPath), new ts.Map(ts.getEntries(parsed.wildcardDirectories)), function (dir, flags) { return state.watchDirectory(dir, function (fileOrDirectory) { + var _a; if (ts.isIgnoredFileFromWildCardWatching({ watchedDirPath: toPath(state, dir), fileOrDirectory: fileOrDirectory, @@ -114198,9 +118162,10 @@ var ts; configFileName: resolved, currentDirectory: state.currentDirectory, options: parsed.options, - program: state.builderPrograms.get(resolvedPath), + program: state.builderPrograms.get(resolvedPath) || ((_a = getCachedParsedConfigFile(state, resolvedPath)) === null || _a === void 0 ? void 0 : _a.fileNames), useCaseSensitiveFileNames: state.parseConfigFileHost.useCaseSensitiveFileNames, - writeLog: function (s) { return state.writeLog(s); } + writeLog: function (s) { return state.writeLog(s); }, + toPath: function (fileName) { return toPath(state, fileName); } })) return; invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.Partial); @@ -114235,19 +118200,16 @@ var ts; } function stopWatching(state) { ts.clearMap(state.allWatchedConfigFiles, ts.closeFileWatcher); - ts.clearMap(state.allWatchedExtendedConfigFiles, function (watcher) { - watcher.projects.clear(); - watcher.close(); - }); + ts.clearMap(state.allWatchedExtendedConfigFiles, ts.closeFileWatcherOf); ts.clearMap(state.allWatchedWildcardDirectories, function (watchedWildcardDirectories) { return ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcherOf); }); ts.clearMap(state.allWatchedInputFiles, function (watchedWildcardDirectories) { return ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcher); }); } function createSolutionBuilderWorker(watch, hostOrHostWithWatch, rootNames, options, baseWatchOptions) { var state = createSolutionBuilderState(watch, hostOrHostWithWatch, rootNames, options, baseWatchOptions); return { - build: function (project, cancellationToken) { return build(state, project, cancellationToken); }, + build: function (project, cancellationToken, writeFile, getCustomTransformers) { return build(state, project, cancellationToken, writeFile, getCustomTransformers); }, clean: function (project) { return clean(state, project); }, - buildReferences: function (project, cancellationToken) { return build(state, project, cancellationToken, /*onlyReferences*/ true); }, + buildReferences: function (project, cancellationToken, writeFile, getCustomTransformers) { return build(state, project, cancellationToken, writeFile, getCustomTransformers, /*onlyReferences*/ true); }, cleanReferences: function (project) { return clean(state, project, /*onlyReferences*/ true); }, getNextInvalidatedProject: function (cancellationToken) { setupInitialBuild(state, cancellationToken); @@ -114337,6 +118299,9 @@ var ts; } } function reportUpToDateStatus(state, configFileName, status) { + if (state.options.force && (status.type === ts.UpToDateStatusType.UpToDate || status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes)) { + return reportStatus(state, ts.Diagnostics.Project_0_is_being_forcibly_rebuilt, relName(state, configFileName)); + } switch (status.type) { case ts.UpToDateStatusType.OutOfDateWithSelf: return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, relName(state, configFileName), relName(state, status.outOfDateOutputFileName), relName(state, status.newerInputFileName)); @@ -114886,6 +118851,9 @@ var ts; SymbolDisplayPartKind[SymbolDisplayPartKind["enumMemberName"] = 19] = "enumMemberName"; SymbolDisplayPartKind[SymbolDisplayPartKind["functionName"] = 20] = "functionName"; SymbolDisplayPartKind[SymbolDisplayPartKind["regularExpressionLiteral"] = 21] = "regularExpressionLiteral"; + SymbolDisplayPartKind[SymbolDisplayPartKind["link"] = 22] = "link"; + SymbolDisplayPartKind[SymbolDisplayPartKind["linkName"] = 23] = "linkName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["linkText"] = 24] = "linkText"; })(SymbolDisplayPartKind = ts.SymbolDisplayPartKind || (ts.SymbolDisplayPartKind = {})); var OutliningSpanKind; (function (OutliningSpanKind) { @@ -114996,6 +118964,12 @@ var ts; ScriptElementKind["jsxAttribute"] = "JSX attribute"; /** String literal */ ScriptElementKind["string"] = "string"; + /** Jsdoc @link: in `{@link C link text}`, the before and after text "{@link " and "}" */ + ScriptElementKind["link"] = "link"; + /** Jsdoc @link: in `{@link C link text}`, the entity name "C" */ + ScriptElementKind["linkName"] = "link name"; + /** Jsdoc @link: in `{@link C link text}`, the link text "link text" */ + ScriptElementKind["linkText"] = "link text"; })(ScriptElementKind = ts.ScriptElementKind || (ts.ScriptElementKind = {})); var ScriptElementKindModifier; (function (ScriptElementKindModifier) { @@ -115088,37 +119062,37 @@ var ts; })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return ts.isInJSFile(node) && ts.getJSDocEnumTag(node) ? 7 /* All */ : 1 /* Value */; - case 160 /* Parameter */: - case 198 /* BindingElement */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 288 /* PropertyAssignment */: - case 289 /* ShorthandPropertyAssignment */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 287 /* CatchClause */: - case 280 /* JsxAttribute */: + case 162 /* Parameter */: + case 200 /* BindingElement */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 290 /* PropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 289 /* CatchClause */: + case 282 /* JsxAttribute */: return 1 /* Value */; - case 159 /* TypeParameter */: - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 177 /* TypeLiteral */: + case 161 /* TypeParameter */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 179 /* TypeLiteral */: return 2 /* Type */; - case 331 /* JSDocTypedefTag */: + case 339 /* 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 291 /* EnumMember */: - case 252 /* ClassDeclaration */: + case 293 /* EnumMember */: + case 254 /* ClassDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -115128,16 +119102,16 @@ var ts; else { return 4 /* Namespace */; } - case 255 /* EnumDeclaration */: - case 264 /* NamedImports */: - case 265 /* ImportSpecifier */: - case 260 /* ImportEqualsDeclaration */: - case 261 /* ImportDeclaration */: - case 266 /* ExportAssignment */: - case 267 /* ExportDeclaration */: + case 257 /* EnumDeclaration */: + case 266 /* NamedImports */: + case 267 /* ImportSpecifier */: + case 262 /* ImportEqualsDeclaration */: + case 263 /* ImportDeclaration */: + case 268 /* ExportAssignment */: + case 269 /* ExportDeclaration */: return 7 /* All */; // An external module can be a Value - case 297 /* SourceFile */: + case 299 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 7 /* All */; @@ -115145,13 +119119,13 @@ var ts; ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { node = getAdjustedReferenceLocation(node); - if (node.kind === 297 /* SourceFile */) { + if (node.kind === 299 /* SourceFile */) { return 1 /* Value */; } - else if (node.parent.kind === 266 /* ExportAssignment */ - || node.parent.kind === 272 /* ExternalModuleReference */ - || node.parent.kind === 265 /* ImportSpecifier */ - || node.parent.kind === 262 /* ImportClause */ + else if (node.parent.kind === 268 /* ExportAssignment */ + || node.parent.kind === 274 /* ExternalModuleReference */ + || node.parent.kind === 267 /* ImportSpecifier */ + || node.parent.kind === 264 /* ImportClause */ || ts.isImportEqualsDeclaration(node.parent) && node === node.parent.name) { return 7 /* All */; } @@ -115161,7 +119135,7 @@ var ts; else if (ts.isDeclarationName(node)) { return getMeaningFromDeclaration(node.parent); } - else if (ts.isEntityName(node) && ts.isJSDocNameReference(node.parent)) { + else if (ts.isEntityName(node) && ts.findAncestor(node, ts.or(ts.isJSDocNameReference, ts.isJSDocLinkLike, ts.isJSDocMemberName))) { return 7 /* All */; } else if (isTypeReference(node)) { @@ -115187,11 +119161,11 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - var name = node.kind === 157 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; - return name && name.parent.kind === 260 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; + var name = node.kind === 159 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; + return name && name.parent.kind === 262 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; } function isInRightSideOfInternalImportEqualsDeclaration(node) { - while (node.parent.kind === 157 /* QualifiedName */) { + while (node.parent.kind === 159 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -115203,27 +119177,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 157 /* QualifiedName */) { - while (root.parent && root.parent.kind === 157 /* QualifiedName */) { + if (root.parent.kind === 159 /* QualifiedName */) { + while (root.parent && root.parent.kind === 159 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 173 /* TypeReference */ && !isLastClause; + return root.parent.kind === 175 /* TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 201 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 201 /* PropertyAccessExpression */) { + if (root.parent.kind === 203 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 203 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 223 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 286 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 225 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 288 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 252 /* ClassDeclaration */ && root.parent.parent.token === 116 /* ImplementsKeyword */) || - (decl.kind === 253 /* InterfaceDeclaration */ && root.parent.parent.token === 93 /* ExtendsKeyword */); + return (decl.kind === 254 /* ClassDeclaration */ && root.parent.parent.token === 117 /* ImplementsKeyword */) || + (decl.kind === 255 /* InterfaceDeclaration */ && root.parent.parent.token === 94 /* ExtendsKeyword */); } return false; } @@ -115232,17 +119206,17 @@ var ts; node = node.parent; } switch (node.kind) { - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: return !ts.isExpressionNode(node); - case 187 /* ThisType */: + case 189 /* ThisType */: return true; } switch (node.parent.kind) { - case 173 /* TypeReference */: + case 175 /* TypeReference */: return true; - case 195 /* ImportType */: + case 197 /* ImportType */: return !node.parent.isTypeOf; - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: return !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent); } return false; @@ -115309,7 +119283,7 @@ var ts; ts.climbPastPropertyOrElementAccess = climbPastPropertyOrElementAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 245 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { + if (referenceNode.kind === 247 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -115370,22 +119344,22 @@ var ts; ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { switch (node.parent.kind) { - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 288 /* PropertyAssignment */: - case 291 /* EnumMember */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 256 /* ModuleDeclaration */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 290 /* PropertyAssignment */: + case 293 /* EnumMember */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 258 /* ModuleDeclaration */: return ts.getNameOfDeclaration(node.parent) === node; - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: return node.parent.argumentExpression === node; - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return true; - case 191 /* LiteralType */: - return node.parent.parent.kind === 189 /* IndexedAccessType */; + case 193 /* LiteralType */: + return node.parent.parent.kind === 191 /* IndexedAccessType */; default: return false; } @@ -115409,17 +119383,17 @@ var ts; return undefined; } switch (node.kind) { - case 297 /* SourceFile */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - case 256 /* ModuleDeclaration */: + case 299 /* SourceFile */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 257 /* EnumDeclaration */: + case 258 /* ModuleDeclaration */: return node; } } @@ -115427,54 +119401,54 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 297 /* SourceFile */: + case 299 /* SourceFile */: return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return "module" /* moduleElement */; - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: return "class" /* classElement */; - case 253 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; - case 254 /* TypeAliasDeclaration */: - case 324 /* JSDocCallbackTag */: - case 331 /* JSDocTypedefTag */: + case 255 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; + case 256 /* TypeAliasDeclaration */: + case 332 /* JSDocCallbackTag */: + case 339 /* JSDocTypedefTag */: return "type" /* typeElement */; - case 255 /* EnumDeclaration */: return "enum" /* enumElement */; - case 249 /* VariableDeclaration */: + case 257 /* EnumDeclaration */: return "enum" /* enumElement */; + case 251 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 198 /* BindingElement */: + case 200 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 209 /* ArrowFunction */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: return "function" /* functionElement */; - case 167 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; - case 168 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 169 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; + case 170 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: return "method" /* memberFunctionElement */; - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: var initializer = node.initializer; return ts.isFunctionLike(initializer) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */; - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 289 /* ShorthandPropertyAssignment */: - case 290 /* SpreadAssignment */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 291 /* ShorthandPropertyAssignment */: + case 292 /* SpreadAssignment */: return "property" /* memberVariableElement */; - case 171 /* IndexSignature */: return "index" /* indexSignatureElement */; - case 170 /* ConstructSignature */: return "construct" /* constructSignatureElement */; - case 169 /* CallSignature */: return "call" /* callSignatureElement */; - case 166 /* Constructor */: return "constructor" /* constructorImplementationElement */; - case 159 /* TypeParameter */: return "type parameter" /* typeParameterElement */; - case 291 /* EnumMember */: return "enum member" /* enumMemberElement */; - case 160 /* Parameter */: return ts.hasSyntacticModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; - case 260 /* ImportEqualsDeclaration */: - case 265 /* ImportSpecifier */: - case 270 /* ExportSpecifier */: - case 263 /* NamespaceImport */: - case 269 /* NamespaceExport */: + case 173 /* IndexSignature */: return "index" /* indexSignatureElement */; + case 172 /* ConstructSignature */: return "construct" /* constructSignatureElement */; + case 171 /* CallSignature */: return "call" /* callSignatureElement */; + case 168 /* Constructor */: return "constructor" /* constructorImplementationElement */; + case 161 /* TypeParameter */: return "type parameter" /* typeParameterElement */; + case 293 /* EnumMember */: return "enum member" /* enumMemberElement */; + case 162 /* Parameter */: return ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; + case 262 /* ImportEqualsDeclaration */: + case 267 /* ImportSpecifier */: + case 272 /* ExportSpecifier */: + case 265 /* NamespaceImport */: + case 271 /* NamespaceExport */: return "alias" /* alias */; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: var kind = ts.getAssignmentDeclarationKind(node); var right = node.right; switch (kind) { @@ -115501,9 +119475,9 @@ var ts; return "" /* unknown */; } } - case 78 /* Identifier */: + case 79 /* Identifier */: return ts.isImportClause(node.parent) ? "alias" /* alias */ : "" /* unknown */; - case 266 /* ExportAssignment */: + case 268 /* 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; @@ -115521,12 +119495,12 @@ var ts; ts.getNodeKind = getNodeKind; function isThis(node) { switch (node.kind) { - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: // case SyntaxKind.ThisType: TODO: GH#9267 return true; - case 78 /* Identifier */: + case 79 /* Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 160 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 162 /* Parameter */; default: return false; } @@ -115591,42 +119565,42 @@ var ts; return false; } switch (n.kind) { - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - case 200 /* ObjectLiteralExpression */: - case 196 /* ObjectBindingPattern */: - case 177 /* TypeLiteral */: - case 230 /* Block */: - case 257 /* ModuleBlock */: - case 258 /* CaseBlock */: - case 264 /* NamedImports */: - case 268 /* NamedExports */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 257 /* EnumDeclaration */: + case 202 /* ObjectLiteralExpression */: + case 198 /* ObjectBindingPattern */: + case 179 /* TypeLiteral */: + case 232 /* Block */: + case 259 /* ModuleBlock */: + case 260 /* CaseBlock */: + case 266 /* NamedImports */: + case 270 /* NamedExports */: return nodeEndsWith(n, 19 /* CloseBraceToken */, sourceFile); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 204 /* NewExpression */: + case 206 /* NewExpression */: if (!n.arguments) { return true; } // falls through - case 203 /* CallExpression */: - case 207 /* ParenthesizedExpression */: - case 186 /* ParenthesizedType */: + case 205 /* CallExpression */: + case 209 /* ParenthesizedExpression */: + case 188 /* ParenthesizedType */: return nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile); - case 174 /* FunctionType */: - case 175 /* ConstructorType */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 170 /* ConstructSignature */: - case 169 /* CallSignature */: - case 209 /* ArrowFunction */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 172 /* ConstructSignature */: + case 171 /* CallSignature */: + case 211 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -115636,65 +119610,65 @@ 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 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return !!n.body && isCompletedNode(n.body, sourceFile); - case 234 /* IfStatement */: + case 236 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 26 /* SemicolonToken */, sourceFile); - case 199 /* ArrayLiteralExpression */: - case 197 /* ArrayBindingPattern */: - case 202 /* ElementAccessExpression */: - case 158 /* ComputedPropertyName */: - case 179 /* TupleType */: + case 201 /* ArrayLiteralExpression */: + case 199 /* ArrayBindingPattern */: + case 204 /* ElementAccessExpression */: + case 160 /* ComputedPropertyName */: + case 181 /* TupleType */: return nodeEndsWith(n, 23 /* CloseBracketToken */, sourceFile); - case 171 /* IndexSignature */: + case 173 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 23 /* CloseBracketToken */, sourceFile); - case 284 /* CaseClause */: - case 285 /* DefaultClause */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 236 /* WhileStatement */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 238 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 235 /* DoStatement */: + case 237 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; - return hasChildOfKind(n, 114 /* WhileKeyword */, sourceFile) + return hasChildOfKind(n, 115 /* WhileKeyword */, sourceFile) ? nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile) : isCompletedNode(n.statement, sourceFile); - case 176 /* TypeQuery */: + case 178 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 211 /* TypeOfExpression */: - case 210 /* DeleteExpression */: - case 212 /* VoidExpression */: - case 219 /* YieldExpression */: - case 220 /* SpreadElement */: + case 213 /* TypeOfExpression */: + case 212 /* DeleteExpression */: + case 214 /* VoidExpression */: + case 221 /* YieldExpression */: + case 222 /* SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 218 /* TemplateExpression */: + case 220 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 228 /* TemplateSpan */: + case 230 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 267 /* ExportDeclaration */: - case 261 /* ImportDeclaration */: + case 269 /* ExportDeclaration */: + case 263 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -115754,13 +119728,13 @@ var ts; } ts.findContainingList = findContainingList; function isDefaultModifier(node) { - return node.kind === 87 /* DefaultKeyword */; + return node.kind === 88 /* DefaultKeyword */; } function isClassKeyword(node) { - return node.kind === 83 /* ClassKeyword */; + return node.kind === 84 /* ClassKeyword */; } function isFunctionKeyword(node) { - return node.kind === 97 /* FunctionKeyword */; + return node.kind === 98 /* FunctionKeyword */; } function getAdjustedLocationForClass(node) { if (ts.isNamedDeclaration(node)) { @@ -115820,11 +119794,11 @@ var ts; function getAdjustedLocationForDeclaration(node, forRename) { if (!forRename) { switch (node.kind) { - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: return getAdjustedLocationForClass(node); - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: return getAdjustedLocationForFunction(node); } } @@ -115914,30 +119888,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 !== 87 /* DefaultKeyword */) ? ts.contains(parent.modifiers, node) : - node.kind === 83 /* ClassKeyword */ ? ts.isClassDeclaration(parent) || ts.isClassExpression(node) : - node.kind === 97 /* FunctionKeyword */ ? ts.isFunctionDeclaration(parent) || ts.isFunctionExpression(node) : - node.kind === 117 /* InterfaceKeyword */ ? ts.isInterfaceDeclaration(parent) : - node.kind === 91 /* EnumKeyword */ ? ts.isEnumDeclaration(parent) : - node.kind === 149 /* TypeKeyword */ ? ts.isTypeAliasDeclaration(parent) : - node.kind === 140 /* NamespaceKeyword */ || node.kind === 139 /* ModuleKeyword */ ? ts.isModuleDeclaration(parent) : - node.kind === 99 /* ImportKeyword */ ? ts.isImportEqualsDeclaration(parent) : - node.kind === 134 /* GetKeyword */ ? ts.isGetAccessorDeclaration(parent) : - node.kind === 146 /* SetKeyword */ && ts.isSetAccessorDeclaration(parent)) { + if (ts.isModifier(node) && (forRename || node.kind !== 88 /* DefaultKeyword */) ? 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 === 150 /* TypeKeyword */ ? ts.isTypeAliasDeclaration(parent) : + node.kind === 141 /* NamespaceKeyword */ || node.kind === 140 /* ModuleKeyword */ ? ts.isModuleDeclaration(parent) : + node.kind === 100 /* ImportKeyword */ ? ts.isImportEqualsDeclaration(parent) : + node.kind === 135 /* GetKeyword */ ? ts.isGetAccessorDeclaration(parent) : + node.kind === 147 /* SetKeyword */ && ts.isSetAccessorDeclaration(parent)) { var location = getAdjustedLocationForDeclaration(parent, forRename); if (location) { return location; } } // /**/ [|name|] ... - if ((node.kind === 112 /* VarKeyword */ || node.kind === 84 /* ConstKeyword */ || node.kind === 118 /* LetKeyword */) && + if ((node.kind === 113 /* VarKeyword */ || node.kind === 85 /* ConstKeyword */ || node.kind === 119 /* LetKeyword */) && ts.isVariableDeclarationList(parent) && parent.declarations.length === 1) { var decl = parent.declarations[0]; if (ts.isIdentifier(decl.name)) { return decl.name; } } - if (node.kind === 149 /* TypeKeyword */) { + if (node.kind === 150 /* TypeKeyword */) { // import /**/type [|name|] from ...; // import /**/type { [|name|] } from ...; // import /**/type { propertyName as [|name|] } from ...; @@ -115963,7 +119937,7 @@ var ts; // import * /**/as [|name|] ... // export { propertyName /**/as [|name|] } ... // export * /**/as [|name|] ... - if (node.kind === 126 /* AsKeyword */) { + if (node.kind === 127 /* AsKeyword */) { if (ts.isImportSpecifier(parent) && parent.propertyName || ts.isExportSpecifier(parent) && parent.propertyName || ts.isNamespaceImport(parent) || @@ -115979,13 +119953,13 @@ var ts; // /**/import { propertyName as [|name|] } from ...; // /**/import ... from "[|module|]"; // /**/import "[|module|]"; - if (node.kind === 99 /* ImportKeyword */ && ts.isImportDeclaration(parent)) { + if (node.kind === 100 /* ImportKeyword */ && ts.isImportDeclaration(parent)) { var location = getAdjustedLocationForImportDeclaration(parent, forRename); if (location) { return location; } } - if (node.kind === 92 /* ExportKeyword */) { + if (node.kind === 93 /* ExportKeyword */) { // /**/export { [|name|] } ...; // /**/export { propertyName as [|name|] } ...; // /**/export * from "[|module|]"; @@ -116004,12 +119978,12 @@ var ts; } } // import name = /**/require("[|module|]"); - if (node.kind === 143 /* RequireKeyword */ && ts.isExternalModuleReference(parent)) { + if (node.kind === 144 /* RequireKeyword */ && ts.isExternalModuleReference(parent)) { return parent.expression; } // import ... /**/from "[|module|]"; // export ... /**/from "[|module|]"; - if (node.kind === 153 /* FromKeyword */ && (ts.isImportDeclaration(parent) || ts.isExportDeclaration(parent)) && parent.moduleSpecifier) { + if (node.kind === 154 /* FromKeyword */ && (ts.isImportDeclaration(parent) || ts.isExportDeclaration(parent)) && parent.moduleSpecifier) { return parent.moduleSpecifier; } // class ... /**/extends [|name|] ... @@ -116017,13 +119991,13 @@ var ts; // class ... /**/implements name1, name2 ... // interface ... /**/extends [|name|] ... // interface ... /**/extends name1, name2 ... - if ((node.kind === 93 /* ExtendsKeyword */ || node.kind === 116 /* ImplementsKeyword */) && ts.isHeritageClause(parent) && parent.token === node.kind) { + if ((node.kind === 94 /* ExtendsKeyword */ || node.kind === 117 /* ImplementsKeyword */) && ts.isHeritageClause(parent) && parent.token === node.kind) { var location = getAdjustedLocationForHeritageClause(parent); if (location) { return location; } } - if (node.kind === 93 /* ExtendsKeyword */) { + if (node.kind === 94 /* ExtendsKeyword */) { // ... ... if (ts.isTypeParameterDeclaration(parent) && parent.constraint && ts.isTypeReferenceNode(parent.constraint)) { return parent.constraint.typeName; @@ -116034,20 +120008,20 @@ var ts; } } // ... T extends /**/infer [|U|] ? ... - if (node.kind === 135 /* InferKeyword */ && ts.isInferTypeNode(parent)) { + if (node.kind === 136 /* InferKeyword */ && ts.isInferTypeNode(parent)) { return parent.typeParameter.name; } // { [ [|K|] /**/in keyof T]: ... } - if (node.kind === 100 /* InKeyword */ && ts.isTypeParameterDeclaration(parent) && ts.isMappedTypeNode(parent.parent)) { + if (node.kind === 101 /* InKeyword */ && ts.isTypeParameterDeclaration(parent) && ts.isMappedTypeNode(parent.parent)) { return parent.name; } // /**/keyof [|T|] - if (node.kind === 138 /* KeyOfKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 138 /* KeyOfKeyword */ && + if (node.kind === 139 /* KeyOfKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 139 /* KeyOfKeyword */ && ts.isTypeReferenceNode(parent.type)) { return parent.type.typeName; } // /**/readonly [|name|][] - if (node.kind === 142 /* ReadonlyKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 142 /* ReadonlyKeyword */ && + if (node.kind === 143 /* ReadonlyKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 143 /* ReadonlyKeyword */ && ts.isArrayTypeNode(parent.type) && ts.isTypeReferenceNode(parent.type.elementType)) { return parent.type.elementType.typeName; } @@ -116062,29 +120036,29 @@ var ts; // /**/yield [|name|] // /**/yield obj.[|name|] // /**/delete obj.[|name|] - if (node.kind === 102 /* NewKeyword */ && ts.isNewExpression(parent) || - node.kind === 113 /* VoidKeyword */ && ts.isVoidExpression(parent) || - node.kind === 111 /* TypeOfKeyword */ && ts.isTypeOfExpression(parent) || - node.kind === 130 /* AwaitKeyword */ && ts.isAwaitExpression(parent) || - node.kind === 124 /* YieldKeyword */ && ts.isYieldExpression(parent) || - node.kind === 88 /* DeleteKeyword */ && ts.isDeleteExpression(parent)) { + if (node.kind === 103 /* NewKeyword */ && ts.isNewExpression(parent) || + node.kind === 114 /* VoidKeyword */ && ts.isVoidExpression(parent) || + node.kind === 112 /* TypeOfKeyword */ && ts.isTypeOfExpression(parent) || + node.kind === 131 /* AwaitKeyword */ && ts.isAwaitExpression(parent) || + node.kind === 125 /* YieldKeyword */ && ts.isYieldExpression(parent) || + node.kind === 89 /* DeleteKeyword */ && ts.isDeleteExpression(parent)) { if (parent.expression) { return ts.skipOuterExpressions(parent.expression); } } // left /**/in [|name|] // left /**/instanceof [|name|] - if ((node.kind === 100 /* InKeyword */ || node.kind === 101 /* InstanceOfKeyword */) && ts.isBinaryExpression(parent) && parent.operatorToken === node) { + if ((node.kind === 101 /* InKeyword */ || node.kind === 102 /* InstanceOfKeyword */) && ts.isBinaryExpression(parent) && parent.operatorToken === node) { return ts.skipOuterExpressions(parent.right); } // left /**/as [|name|] - if (node.kind === 126 /* AsKeyword */ && ts.isAsExpression(parent) && ts.isTypeReferenceNode(parent.type)) { + if (node.kind === 127 /* AsKeyword */ && ts.isAsExpression(parent) && ts.isTypeReferenceNode(parent.type)) { return parent.type.typeName; } // for (... /**/in [|name|]) // for (... /**/of [|name|]) - if (node.kind === 100 /* InKeyword */ && ts.isForInStatement(parent) || - node.kind === 156 /* OfKeyword */ && ts.isForOfStatement(parent)) { + if (node.kind === 101 /* InKeyword */ && ts.isForInStatement(parent) || + node.kind === 158 /* OfKeyword */ && ts.isForOfStatement(parent)) { return ts.skipOuterExpressions(parent.expression); } } @@ -116153,6 +120127,21 @@ var ts; return current; } } + /** + * Returns the first token where position is in [start, end), + * excluding `JsxText` tokens containing only whitespace. + */ + function findFirstNonJsxWhitespaceToken(sourceFile, position) { + var tokenAtPosition = getTokenAtPosition(sourceFile, position); + while (isWhiteSpaceOnlyJsxText(tokenAtPosition)) { + var nextToken = findNextToken(tokenAtPosition, tokenAtPosition.parent, sourceFile); + if (!nextToken) + return; + tokenAtPosition = nextToken; + } + return tokenAtPosition; + } + ts.findFirstNonJsxWhitespaceToken = findFirstNonJsxWhitespaceToken; /** * The token on the left of the position is the token that strictly includes the position * or sits to the left of the cursor if it is on a boundary. For example @@ -116239,7 +120228,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 297 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); + ts.Debug.assert(startNode !== undefined || n.kind === 299 /* SourceFile */ || n.kind === 1 /* 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. @@ -116312,17 +120301,17 @@ var ts; return true; } //
{ |
or
- if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 283 /* JsxExpression */) { + if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 285 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 283 /* JsxExpression */) { + if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 285 /* JsxExpression */) { return true; } //
|
- if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 276 /* JsxClosingElement */) { + if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 278 /* JsxClosingElement */) { return true; } return false; @@ -116353,17 +120342,17 @@ var ts; function isInsideJsxElement(sourceFile, position) { function isInsideJsxElementTraversal(node) { while (node) { - if (node.kind >= 274 /* JsxSelfClosingElement */ && node.kind <= 283 /* JsxExpression */ + if (node.kind >= 276 /* JsxSelfClosingElement */ && node.kind <= 285 /* JsxExpression */ || node.kind === 11 /* JsxText */ || node.kind === 29 /* LessThanToken */ || node.kind === 31 /* GreaterThanToken */ - || node.kind === 78 /* Identifier */ + || node.kind === 79 /* Identifier */ || node.kind === 19 /* CloseBraceToken */ || node.kind === 18 /* OpenBraceToken */ || node.kind === 43 /* SlashToken */) { node = node.parent; } - else if (node.kind === 273 /* JsxElement */) { + else if (node.kind === 275 /* JsxElement */) { if (position > node.getStart(sourceFile)) return true; node = node.parent; @@ -116502,16 +120491,16 @@ var ts; break; case 38 /* EqualsGreaterThanToken */: // falls through - case 78 /* Identifier */: + case 79 /* Identifier */: case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: // falls through - case 111 /* TypeOfKeyword */: - case 93 /* ExtendsKeyword */: - case 138 /* KeyOfKeyword */: + case 112 /* TypeOfKeyword */: + case 94 /* ExtendsKeyword */: + case 139 /* KeyOfKeyword */: case 24 /* DotToken */: case 51 /* BarToken */: case 57 /* QuestionToken */: @@ -116571,16 +120560,16 @@ var ts; result.push("deprecated" /* deprecatedModifier */); if (node.flags & 8388608 /* Ambient */) result.push("declare" /* ambientModifier */); - if (node.kind === 266 /* ExportAssignment */) + if (node.kind === 268 /* ExportAssignment */) result.push("export" /* exportedModifier */); return result.length > 0 ? result.join(",") : "" /* none */; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 173 /* TypeReference */ || node.kind === 203 /* CallExpression */) { + if (node.kind === 175 /* TypeReference */ || node.kind === 205 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 252 /* ClassDeclaration */ || node.kind === 253 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 254 /* ClassDeclaration */ || node.kind === 255 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; @@ -116600,7 +120589,7 @@ var ts; } ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; function isPunctuation(kind) { - return 18 /* FirstPunctuation */ <= kind && kind <= 77 /* LastPunctuation */; + return 18 /* FirstPunctuation */ <= kind && kind <= 78 /* LastPunctuation */; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position, sourceFile) { @@ -116610,9 +120599,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 122 /* PublicKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: + case 123 /* PublicKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: return true; } return false; @@ -116625,18 +120614,18 @@ var ts; } ts.cloneCompilerOptions = cloneCompilerOptions; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 199 /* ArrayLiteralExpression */ || - node.kind === 200 /* ObjectLiteralExpression */) { + if (node.kind === 201 /* ArrayLiteralExpression */ || + node.kind === 202 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 216 /* BinaryExpression */ && + if (node.parent.kind === 218 /* BinaryExpression */ && node.parent.left === node && - node.parent.operatorToken.kind === 62 /* EqualsToken */) { + node.parent.operatorToken.kind === 63 /* EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 239 /* ForOfStatement */ && + if (node.parent.kind === 241 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -116644,7 +120633,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 288 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 290 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -116706,32 +120695,32 @@ var ts; } ts.createTextChange = createTextChange; ts.typeKeywords = [ - 128 /* AnyKeyword */, - 127 /* AssertsKeyword */, - 155 /* BigIntKeyword */, - 131 /* BooleanKeyword */, - 94 /* FalseKeyword */, - 135 /* InferKeyword */, - 138 /* KeyOfKeyword */, - 141 /* NeverKeyword */, - 103 /* NullKeyword */, - 144 /* NumberKeyword */, - 145 /* ObjectKeyword */, - 142 /* ReadonlyKeyword */, - 147 /* StringKeyword */, - 148 /* SymbolKeyword */, - 109 /* TrueKeyword */, - 113 /* VoidKeyword */, - 150 /* UndefinedKeyword */, - 151 /* UniqueKeyword */, - 152 /* UnknownKeyword */, + 129 /* AnyKeyword */, + 128 /* AssertsKeyword */, + 156 /* BigIntKeyword */, + 132 /* BooleanKeyword */, + 95 /* FalseKeyword */, + 136 /* InferKeyword */, + 139 /* KeyOfKeyword */, + 142 /* NeverKeyword */, + 104 /* NullKeyword */, + 145 /* NumberKeyword */, + 146 /* ObjectKeyword */, + 143 /* ReadonlyKeyword */, + 148 /* StringKeyword */, + 149 /* SymbolKeyword */, + 110 /* TrueKeyword */, + 114 /* VoidKeyword */, + 151 /* UndefinedKeyword */, + 152 /* UniqueKeyword */, + 153 /* UnknownKeyword */, ]; function isTypeKeyword(kind) { return ts.contains(ts.typeKeywords, kind); } ts.isTypeKeyword = isTypeKeyword; function isTypeKeywordToken(node) { - return node.kind === 149 /* TypeKeyword */; + return node.kind === 150 /* TypeKeyword */; } ts.isTypeKeywordToken = isTypeKeywordToken; /** True if the symbol is for an external module, as opposed to a namespace. */ @@ -116764,7 +120753,7 @@ var ts; } ts.skipConstraint = skipConstraint; function getNameFromPropertyName(name) { - return name.kind === 158 /* ComputedPropertyName */ + return name.kind === 160 /* 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); @@ -116783,7 +120772,7 @@ var ts; } ts.compilerOptionsIndicateEs6Modules = compilerOptionsIndicateEs6Modules; function createModuleSpecifierResolutionHost(program, host) { - // Mix in `getProbableSymlinks` from Program when host doesn't have it + // Mix in `getSymlinkCache` from Program when host doesn't have it // in order for non-Project hosts to have a symlinks cache. return { fileExists: function (fileName) { return program.fileExists(fileName); }, @@ -116791,6 +120780,7 @@ var ts; readFile: ts.maybeBind(host, host.readFile), useCaseSensitiveFileNames: ts.maybeBind(host, host.useCaseSensitiveFileNames), getSymlinkCache: ts.maybeBind(host, host.getSymlinkCache) || program.getSymlinkCache, + getModuleSpecifierCache: ts.maybeBind(host, host.getModuleSpecifierCache), getGlobalTypingsCacheLocation: ts.maybeBind(host, host.getGlobalTypingsCacheLocation), getSourceFiles: function () { return program.getSourceFiles(); }, redirectTargetsMap: program.redirectTargetsMap, @@ -116861,10 +120851,17 @@ var ts; } return ts.firstDefined(symbol.declarations, function (decl) { var name = ts.getNameOfDeclaration(decl); - return name && name.kind === 78 /* Identifier */ ? name.escapedText : undefined; + return name && name.kind === 79 /* Identifier */ ? name.escapedText : undefined; }); } ts.symbolEscapedNameNoDefault = symbolEscapedNameNoDefault; + function isModuleSpecifierLike(node) { + return ts.isStringLiteralLike(node) && (ts.isExternalModuleReference(node.parent) || + ts.isImportDeclaration(node.parent) || + ts.isRequireCall(node.parent, /*requireStringLiteralLikeArgument*/ false) && node.parent.arguments[0] === node || + ts.isImportCall(node.parent) && node.parent.arguments[0] === node); + } + ts.isModuleSpecifierLike = isModuleSpecifierLike; function isObjectBindingElementWithoutPropertyName(bindingElement) { return ts.isBindingElement(bindingElement) && ts.isObjectBindingPattern(bindingElement.parent) && @@ -116898,7 +120895,7 @@ var ts; ts.findModifier = findModifier; function insertImports(changes, sourceFile, imports, blankLineBetween) { var decl = ts.isArray(imports) ? imports[0] : imports; - var importKindPredicate = decl.kind === 232 /* VariableStatement */ ? ts.isRequireVariableStatement : ts.isAnyImportSyntax; + var importKindPredicate = decl.kind === 234 /* 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) { @@ -116976,7 +120973,7 @@ var ts; // Display-part writer helpers // #region function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 160 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 162 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -117024,7 +121021,7 @@ var ts; increaseIndent: function () { indent++; }, decreaseIndent: function () { indent--; }, clear: resetWriter, - trackSymbol: ts.noop, + trackSymbol: function () { return false; }, reportInaccessibleThisError: ts.noop, reportInaccessibleUniqueSymbolError: ts.noop, reportPrivateInBaseOfClassExpression: ts.noop, @@ -117139,6 +121136,14 @@ var ts; return displayPart(ts.tokenToString(kind), ts.SymbolDisplayPartKind.operator); } ts.operatorPart = operatorPart; + function parameterNamePart(text) { + return displayPart(text, ts.SymbolDisplayPartKind.parameterName); + } + ts.parameterNamePart = parameterNamePart; + function propertyNamePart(text) { + return displayPart(text, ts.SymbolDisplayPartKind.propertyName); + } + ts.propertyNamePart = propertyNamePart; function textOrKeywordPart(text) { var kind = ts.stringToToken(text); return kind === undefined @@ -117150,6 +121155,61 @@ var ts; return displayPart(text, ts.SymbolDisplayPartKind.text); } ts.textPart = textPart; + function typeAliasNamePart(text) { + return displayPart(text, ts.SymbolDisplayPartKind.aliasName); + } + ts.typeAliasNamePart = typeAliasNamePart; + function typeParameterNamePart(text) { + return displayPart(text, ts.SymbolDisplayPartKind.typeParameterName); + } + ts.typeParameterNamePart = typeParameterNamePart; + function linkTextPart(text) { + return displayPart(text, ts.SymbolDisplayPartKind.linkText); + } + ts.linkTextPart = linkTextPart; + function linkNamePart(name, target) { + return { + text: ts.getTextOfNode(name), + kind: ts.SymbolDisplayPartKind[ts.SymbolDisplayPartKind.linkName], + target: { + fileName: ts.getSourceFileOfNode(target).fileName, + textSpan: createTextSpanFromNode(target), + }, + }; + } + ts.linkNamePart = linkNamePart; + function linkPart(text) { + return displayPart(text, ts.SymbolDisplayPartKind.link); + } + ts.linkPart = linkPart; + function buildLinkParts(link, checker) { + var _a; + var prefix = ts.isJSDocLink(link) ? "link" + : ts.isJSDocLinkCode(link) ? "linkcode" + : "linkplain"; + var parts = [linkPart("{@" + prefix + " ")]; + if (!link.name) { + if (link.text) { + parts.push(linkTextPart(link.text)); + } + } + else { + var symbol = checker === null || checker === void 0 ? void 0 : checker.getSymbolAtLocation(link.name); + var decl = (symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration) || ((_a = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]); + if (decl) { + parts.push(linkNamePart(link.name, decl)); + if (link.text) { + parts.push(linkTextPart(link.text)); + } + } + else { + parts.push(linkTextPart(ts.getTextOfNode(link.name) + " " + link.text)); + } + } + parts.push(linkPart("}")); + return parts; + } + ts.buildLinkParts = buildLinkParts; var carriageReturnLineFeed = "\r\n"; /** * The default is CRLF. @@ -117435,21 +121495,23 @@ var ts; } /* @internal */ function needsParentheses(expression) { - return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 27 /* CommaToken */ || ts.isObjectLiteralExpression(expression); + return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 27 /* CommaToken */ + || ts.isObjectLiteralExpression(expression) + || ts.isAsExpression(expression) && ts.isObjectLiteralExpression(expression.expression); } ts.needsParentheses = needsParentheses; function getContextualTypeFromParent(node, checker) { var parent = node.parent; switch (parent.kind) { - case 204 /* NewExpression */: + case 206 /* NewExpression */: return checker.getContextualType(parent); - case 216 /* BinaryExpression */: { + case 218 /* 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 284 /* CaseClause */: + case 286 /* CaseClause */: return parent.expression === node ? getSwitchedType(parent, checker) : undefined; default: return checker.getContextualType(node); @@ -117460,7 +121522,7 @@ 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("'", "\\'").replace('\\"', '"') + "'" : quoted; + return quotePreference === 0 /* Single */ ? "'" + ts.stripQuotes(quoted).replace(/'/g, "\\'").replace(/\\"/g, '"') + "'" : quoted; } ts.quote = quote; function isEqualityOperatorKind(kind) { @@ -117479,8 +121541,8 @@ var ts; switch (node.kind) { case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 218 /* TemplateExpression */: - case 205 /* TaggedTemplateExpression */: + case 220 /* TemplateExpression */: + case 207 /* TaggedTemplateExpression */: return true; default: return false; @@ -117503,6 +121565,7 @@ var ts; var res = checker.typeToTypeNode(type, enclosingScope, 1 /* NoTruncation */, { trackSymbol: function (symbol, declaration, meaning) { typeIsAccessible = typeIsAccessible && checker.isSymbolAccessible(symbol, declaration, meaning, /*shouldComputeAliasToMarkVisible*/ false).accessibility === 0 /* Accessible */; + return !typeIsAccessible; }, reportInaccessibleThisError: notAccessible, reportPrivateInBaseOfClassExpression: notAccessible, @@ -117513,41 +121576,41 @@ var ts; } ts.getTypeNodeIfAccessible = getTypeNodeIfAccessible; function syntaxRequiresTrailingCommaOrSemicolonOrASI(kind) { - return kind === 169 /* CallSignature */ - || kind === 170 /* ConstructSignature */ - || kind === 171 /* IndexSignature */ - || kind === 162 /* PropertySignature */ - || kind === 164 /* MethodSignature */; + return kind === 171 /* CallSignature */ + || kind === 172 /* ConstructSignature */ + || kind === 173 /* IndexSignature */ + || kind === 164 /* PropertySignature */ + || kind === 166 /* MethodSignature */; } ts.syntaxRequiresTrailingCommaOrSemicolonOrASI = syntaxRequiresTrailingCommaOrSemicolonOrASI; function syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI(kind) { - return kind === 251 /* FunctionDeclaration */ - || kind === 166 /* Constructor */ - || kind === 165 /* MethodDeclaration */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */; + return kind === 253 /* FunctionDeclaration */ + || kind === 168 /* Constructor */ + || kind === 167 /* MethodDeclaration */ + || kind === 169 /* GetAccessor */ + || kind === 170 /* SetAccessor */; } ts.syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI = syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI; function syntaxRequiresTrailingModuleBlockOrSemicolonOrASI(kind) { - return kind === 256 /* ModuleDeclaration */; + return kind === 258 /* ModuleDeclaration */; } ts.syntaxRequiresTrailingModuleBlockOrSemicolonOrASI = syntaxRequiresTrailingModuleBlockOrSemicolonOrASI; function syntaxRequiresTrailingSemicolonOrASI(kind) { - return kind === 232 /* VariableStatement */ - || kind === 233 /* ExpressionStatement */ - || kind === 235 /* DoStatement */ - || kind === 240 /* ContinueStatement */ - || kind === 241 /* BreakStatement */ - || kind === 242 /* ReturnStatement */ - || kind === 246 /* ThrowStatement */ - || kind === 248 /* DebuggerStatement */ - || kind === 163 /* PropertyDeclaration */ - || kind === 254 /* TypeAliasDeclaration */ - || kind === 261 /* ImportDeclaration */ - || kind === 260 /* ImportEqualsDeclaration */ - || kind === 267 /* ExportDeclaration */ - || kind === 259 /* NamespaceExportDeclaration */ - || kind === 266 /* ExportAssignment */; + return kind === 234 /* VariableStatement */ + || kind === 235 /* ExpressionStatement */ + || kind === 237 /* DoStatement */ + || kind === 242 /* ContinueStatement */ + || kind === 243 /* BreakStatement */ + || kind === 244 /* ReturnStatement */ + || kind === 248 /* ThrowStatement */ + || kind === 250 /* DebuggerStatement */ + || kind === 165 /* PropertyDeclaration */ + || kind === 256 /* TypeAliasDeclaration */ + || kind === 263 /* ImportDeclaration */ + || kind === 262 /* ImportEqualsDeclaration */ + || kind === 269 /* ExportDeclaration */ + || kind === 261 /* NamespaceExportDeclaration */ + || kind === 268 /* ExportAssignment */; } ts.syntaxRequiresTrailingSemicolonOrASI = syntaxRequiresTrailingSemicolonOrASI; ts.syntaxMayBeASICandidate = ts.or(syntaxRequiresTrailingCommaOrSemicolonOrASI, syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI, syntaxRequiresTrailingModuleBlockOrSemicolonOrASI, syntaxRequiresTrailingSemicolonOrASI); @@ -117577,7 +121640,7 @@ var ts; return false; } // See comment in parser’s `parseDoStatement` - if (node.kind === 235 /* DoStatement */) { + if (node.kind === 237 /* DoStatement */) { return true; } var topNode = ts.findAncestor(node, function (ancestor) { return !ancestor.parent; }); @@ -117751,6 +121814,94 @@ var ts; } } ts.createPackageJsonInfo = createPackageJsonInfo; + function createPackageJsonImportFilter(fromFile, host) { + var packageJsons = ((host.getPackageJsonsVisibleToFile && host.getPackageJsonsVisibleToFile(fromFile.fileName)) || getPackageJsonsVisibleToFile(fromFile.fileName, host)).filter(function (p) { return p.parseable; }); + var usesNodeCoreModules; + return { allowsImportingAmbientModule: allowsImportingAmbientModule, allowsImportingSourceFile: allowsImportingSourceFile, allowsImportingSpecifier: allowsImportingSpecifier }; + function moduleSpecifierIsCoveredByPackageJson(specifier) { + var packageName = getNodeModuleRootSpecifier(specifier); + for (var _i = 0, packageJsons_1 = packageJsons; _i < packageJsons_1.length; _i++) { + var packageJson = packageJsons_1[_i]; + if (packageJson.has(packageName) || packageJson.has(ts.getTypesPackageName(packageName))) { + return true; + } + } + return false; + } + function allowsImportingAmbientModule(moduleSymbol, moduleSpecifierResolutionHost) { + if (!packageJsons.length || !moduleSymbol.valueDeclaration) { + return true; + } + var declaringSourceFile = moduleSymbol.valueDeclaration.getSourceFile(); + var declaringNodeModuleName = getNodeModulesPackageNameFromFileName(declaringSourceFile.fileName, moduleSpecifierResolutionHost); + if (typeof declaringNodeModuleName === "undefined") { + return true; + } + var declaredModuleSpecifier = ts.stripQuotes(moduleSymbol.getName()); + if (isAllowedCoreNodeModulesImport(declaredModuleSpecifier)) { + return true; + } + return moduleSpecifierIsCoveredByPackageJson(declaringNodeModuleName) + || moduleSpecifierIsCoveredByPackageJson(declaredModuleSpecifier); + } + function allowsImportingSourceFile(sourceFile, moduleSpecifierResolutionHost) { + if (!packageJsons.length) { + return true; + } + var moduleSpecifier = getNodeModulesPackageNameFromFileName(sourceFile.fileName, moduleSpecifierResolutionHost); + if (!moduleSpecifier) { + return true; + } + return moduleSpecifierIsCoveredByPackageJson(moduleSpecifier); + } + function allowsImportingSpecifier(moduleSpecifier) { + if (!packageJsons.length || isAllowedCoreNodeModulesImport(moduleSpecifier)) { + return true; + } + if (ts.pathIsRelative(moduleSpecifier) || ts.isRootedDiskPath(moduleSpecifier)) { + return true; + } + return moduleSpecifierIsCoveredByPackageJson(moduleSpecifier); + } + function isAllowedCoreNodeModulesImport(moduleSpecifier) { + // If we’re in JavaScript, it can be difficult to tell whether the user wants to import + // from Node core modules or not. We can start by seeing if the user is actually using + // any node core modules, as opposed to simply having @types/node accidentally as a + // dependency of a dependency. + if (ts.isSourceFileJS(fromFile) && ts.JsTyping.nodeCoreModules.has(moduleSpecifier)) { + if (usesNodeCoreModules === undefined) { + usesNodeCoreModules = consumesNodeCoreModules(fromFile); + } + if (usesNodeCoreModules) { + return true; + } + } + return false; + } + function getNodeModulesPackageNameFromFileName(importedFileName, moduleSpecifierResolutionHost) { + if (!ts.stringContains(importedFileName, "node_modules")) { + return undefined; + } + var specifier = ts.moduleSpecifiers.getNodeModulesPackageName(host.getCompilationSettings(), fromFile.path, importedFileName, moduleSpecifierResolutionHost); + if (!specifier) { + return undefined; + } + // Paths here are not node_modules, so we don’t care about them; + // returning anything will trigger a lookup in package.json. + if (!ts.pathIsRelative(specifier) && !ts.isRootedDiskPath(specifier)) { + return getNodeModuleRootSpecifier(specifier); + } + } + function getNodeModuleRootSpecifier(fullSpecifier) { + var components = ts.getPathComponents(ts.getPackageNameFromTypesPackageName(fullSpecifier)).slice(1); + // Scoped packages + if (ts.startsWith(components[0], "@")) { + return components[0] + "/" + components[1]; + } + return components[0]; + } + } + ts.createPackageJsonImportFilter = createPackageJsonImportFilter; function tryParseJson(text) { try { return JSON.parse(text); @@ -117827,9 +121978,9 @@ var ts; } ts.firstOrOnly = firstOrOnly; function getNameForExportedSymbol(symbol, scriptTarget) { - if (symbol.escapedName === "export=" /* ExportEquals */ || symbol.escapedName === "default" /* Default */) { + if (!(symbol.flags & 33554432 /* Transient */) && (symbol.escapedName === "export=" /* ExportEquals */ || symbol.escapedName === "default" /* Default */)) { // Name of "export default foo;" is "foo". Name of "export default 0" is the filename converted to camelCase. - return ts.firstDefined(symbol.declarations, function (d) { return ts.isExportAssignment(d) && ts.isIdentifier(d.expression) ? d.expression.text : undefined; }) + 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; }) || ts.codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget); } return symbol.name; @@ -117893,6 +122044,188 @@ var ts; return ts.isInJSFile(declaration) || !ts.findAncestor(declaration, ts.isGlobalScopeAugmentation); } ts.isNonGlobalDeclaration = isNonGlobalDeclaration; + var ImportKind; + (function (ImportKind) { + ImportKind[ImportKind["Named"] = 0] = "Named"; + ImportKind[ImportKind["Default"] = 1] = "Default"; + ImportKind[ImportKind["Namespace"] = 2] = "Namespace"; + ImportKind[ImportKind["CommonJS"] = 3] = "CommonJS"; + })(ImportKind = ts.ImportKind || (ts.ImportKind = {})); + var ExportKind; + (function (ExportKind) { + ExportKind[ExportKind["Named"] = 0] = "Named"; + ExportKind[ExportKind["Default"] = 1] = "Default"; + ExportKind[ExportKind["ExportEquals"] = 2] = "ExportEquals"; + ExportKind[ExportKind["UMD"] = 3] = "UMD"; + })(ExportKind = ts.ExportKind || (ts.ExportKind = {})); + function createExportMapCache() { + var cache; + var projectVersion; + var usableByFileName; + var wrapped = { + isEmpty: function () { + return !cache; + }, + clear: function () { + cache = undefined; + projectVersion = undefined; + }, + set: function (suggestions, version) { + cache = suggestions; + if (version) { + projectVersion = version; + } + }, + get: function (file, checker, version) { + if (usableByFileName && file !== usableByFileName) { + return undefined; + } + if (version && projectVersion === version) { + return cache; + } + cache === null || cache === void 0 ? void 0 : cache.forEach(function (infos) { + var _a, _b, _c; + for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) { + var info = infos_1[_i]; + // If the symbol/moduleSymbol was a merged symbol, it will have a new identity + // in the checker, even though the symbols to merge are the same (guaranteed by + // cache invalidation in synchronizeHostData). + if ((_a = info.symbol.declarations) === null || _a === void 0 ? void 0 : _a.length) { + info.symbol = checker.getMergedSymbol(info.exportKind === 1 /* Default */ + ? (_b = info.symbol.declarations[0].localSymbol) !== null && _b !== void 0 ? _b : info.symbol.declarations[0].symbol + : info.symbol.declarations[0].symbol); + } + if ((_c = info.moduleSymbol.declarations) === null || _c === void 0 ? void 0 : _c.length) { + info.moduleSymbol = checker.getMergedSymbol(info.moduleSymbol.declarations[0].symbol); + } + } + }); + return cache; + }, + onFileChanged: function (oldSourceFile, newSourceFile, typeAcquisitionEnabled) { + if (fileIsGlobalOnly(oldSourceFile) && fileIsGlobalOnly(newSourceFile)) { + // File is purely global; doesn't affect export map + return false; + } + if (usableByFileName && usableByFileName !== newSourceFile.path || + // If ATA is enabled, auto-imports uses existing imports to guess whether you want auto-imports from node. + // Adding or removing imports from node could change the outcome of that guess, so could change the suggestions list. + typeAcquisitionEnabled && consumesNodeCoreModules(oldSourceFile) !== consumesNodeCoreModules(newSourceFile) || + // Module agumentation and ambient module changes can add or remove exports available to be auto-imported. + // Changes elsewhere in the file can change the *type* of an export in a module augmentation, + // but type info is gathered in getCompletionEntryDetails, which doesn’t use the cache. + !ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations) || + !ambientModuleDeclarationsAreEqual(oldSourceFile, newSourceFile)) { + this.clear(); + return true; + } + usableByFileName = newSourceFile.path; + return false; + }, + }; + if (ts.Debug.isDebugging) { + Object.defineProperty(wrapped, "__cache", { get: function () { return cache; } }); + } + return wrapped; + function fileIsGlobalOnly(file) { + return !file.commonJsModuleIndicator && !file.externalModuleIndicator && !file.moduleAugmentations && !file.ambientModuleNames; + } + function ambientModuleDeclarationsAreEqual(oldSourceFile, newSourceFile) { + if (!ts.arrayIsEqualTo(oldSourceFile.ambientModuleNames, newSourceFile.ambientModuleNames)) { + return false; + } + var oldFileStatementIndex = -1; + var newFileStatementIndex = -1; + var _loop_1 = function (ambientModuleName) { + var isMatchingModuleDeclaration = function (node) { return ts.isNonGlobalAmbientModule(node) && node.name.text === ambientModuleName; }; + oldFileStatementIndex = ts.findIndex(oldSourceFile.statements, isMatchingModuleDeclaration, oldFileStatementIndex + 1); + newFileStatementIndex = ts.findIndex(newSourceFile.statements, isMatchingModuleDeclaration, newFileStatementIndex + 1); + if (oldSourceFile.statements[oldFileStatementIndex] !== newSourceFile.statements[newFileStatementIndex]) { + return { value: false }; + } + }; + for (var _i = 0, _a = newSourceFile.ambientModuleNames; _i < _a.length; _i++) { + var ambientModuleName = _a[_i]; + var state_1 = _loop_1(ambientModuleName); + if (typeof state_1 === "object") + return state_1.value; + } + return true; + } + } + ts.createExportMapCache = createExportMapCache; + function createModuleSpecifierCache() { + var cache; + var importingFileName; + var wrapped = { + get: function (fromFileName, toFileName) { + if (!cache || fromFileName !== importingFileName) + return undefined; + return cache.get(toFileName); + }, + set: function (fromFileName, toFileName, moduleSpecifiers) { + if (cache && fromFileName !== importingFileName) { + cache.clear(); + } + importingFileName = fromFileName; + (cache || (cache = new ts.Map())).set(toFileName, moduleSpecifiers); + }, + clear: function () { + cache = undefined; + importingFileName = undefined; + }, + count: function () { + return cache ? cache.size : 0; + } + }; + if (ts.Debug.isDebugging) { + Object.defineProperty(wrapped, "__cache", { get: function () { return cache; } }); + } + return wrapped; + } + ts.createModuleSpecifierCache = createModuleSpecifierCache; + function isImportableFile(program, from, to, packageJsonFilter, moduleSpecifierResolutionHost, moduleSpecifierCache) { + var _a; + if (from === to) + return false; + var cachedResult = moduleSpecifierCache === null || moduleSpecifierCache === void 0 ? void 0 : moduleSpecifierCache.get(from.path, to.path); + if (cachedResult !== undefined) { + return !!cachedResult; + } + var getCanonicalFileName = ts.hostGetCanonicalFileName(moduleSpecifierResolutionHost); + var globalTypingsCache = (_a = moduleSpecifierResolutionHost.getGlobalTypingsCacheLocation) === null || _a === void 0 ? void 0 : _a.call(moduleSpecifierResolutionHost); + var hasImportablePath = !!ts.moduleSpecifiers.forEachFileNameOfModule(from.fileName, to.fileName, moduleSpecifierResolutionHost, + /*preferSymlinks*/ false, function (toPath) { + var toFile = program.getSourceFile(toPath); + // Determine to import using toPath only if toPath is what we were looking at + // or there doesnt exist the file in the program by the symlink + return (toFile === to || !toFile) && + isImportablePath(from.fileName, toPath, getCanonicalFileName, globalTypingsCache); + }); + if (packageJsonFilter) { + var isImportable = hasImportablePath && packageJsonFilter.allowsImportingSourceFile(to, moduleSpecifierResolutionHost); + moduleSpecifierCache === null || moduleSpecifierCache === void 0 ? void 0 : moduleSpecifierCache.set(from.path, to.path, isImportable); + return isImportable; + } + return hasImportablePath; + } + ts.isImportableFile = isImportableFile; + /** + * Don't include something from a `node_modules` that isn't actually reachable by a global import. + * A relative import to node_modules is usually a bad idea. + */ + function isImportablePath(fromPath, toPath, getCanonicalFileName, globalCachePath) { + // If it's in a `node_modules` but is not reachable from here via a global import, don't bother. + var toNodeModules = ts.forEachAncestorDirectory(toPath, function (ancestor) { return ts.getBaseFileName(ancestor) === "node_modules" ? ancestor : undefined; }); + var toNodeModulesParent = toNodeModules && ts.getDirectoryPath(getCanonicalFileName(toNodeModules)); + return toNodeModulesParent === undefined + || ts.startsWith(getCanonicalFileName(fromPath), toNodeModulesParent) + || (!!globalCachePath && ts.startsWith(getCanonicalFileName(globalCachePath), toNodeModulesParent)); + } + function isDeprecatedDeclaration(decl) { + return !!(ts.getCombinedNodeFlagsAlwaysIncludeJSDoc(decl) & 8192 /* Deprecated */); + } + ts.isDeprecatedDeclaration = isDeprecatedDeclaration; // #endregion })(ts || (ts = {})); var ts; @@ -117976,13 +122309,13 @@ var ts; function handleToken() { switch (token) { case 43 /* SlashToken */: - case 67 /* SlashEqualsToken */: + case 68 /* SlashEqualsToken */: if (!noRegexTable[lastNonTriviaToken] && scanner.reScanSlashToken() === 13 /* RegularExpressionLiteral */) { token = 13 /* RegularExpressionLiteral */; } break; case 29 /* LessThanToken */: - if (lastNonTriviaToken === 78 /* Identifier */) { + if (lastNonTriviaToken === 79 /* 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++; @@ -117995,16 +122328,16 @@ var ts; angleBracketStack--; } break; - case 128 /* AnyKeyword */: - case 147 /* StringKeyword */: - case 144 /* NumberKeyword */: - case 131 /* BooleanKeyword */: - case 148 /* SymbolKeyword */: + case 129 /* AnyKeyword */: + case 148 /* StringKeyword */: + case 145 /* NumberKeyword */: + case 132 /* BooleanKeyword */: + case 149 /* 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 = 78 /* Identifier */; + token = 79 /* Identifier */; } break; case 15 /* TemplateHead */: @@ -118043,14 +122376,14 @@ var ts; break; } if (lastNonTriviaToken === 24 /* DotToken */) { - token = 78 /* Identifier */; + token = 79 /* 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 = 78 /* Identifier */; + token = 79 /* Identifier */; } } } @@ -118064,19 +122397,19 @@ 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([ - 78 /* Identifier */, + 79 /* Identifier */, 10 /* StringLiteral */, 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 13 /* RegularExpressionLiteral */, - 107 /* ThisKeyword */, + 108 /* ThisKeyword */, 45 /* PlusPlusToken */, 46 /* MinusMinusToken */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 19 /* CloseBraceToken */, - 109 /* TrueKeyword */, - 94 /* FalseKeyword */, + 110 /* TrueKeyword */, + 95 /* FalseKeyword */, ], function (token) { return token; }, function () { return true; }); function getNewEndOfLineState(scanner, token, lastOnTemplateStack) { switch (token) { @@ -118188,10 +122521,10 @@ var ts; return true; } switch (keyword2) { - case 134 /* GetKeyword */: - case 146 /* SetKeyword */: - case 132 /* ConstructorKeyword */: - case 123 /* StaticKeyword */: + case 135 /* GetKeyword */: + case 147 /* SetKeyword */: + case 133 /* ConstructorKeyword */: + case 124 /* 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. @@ -118236,9 +122569,9 @@ var ts; case 31 /* GreaterThanToken */: case 32 /* LessThanEqualsToken */: case 33 /* GreaterThanEqualsToken */: - case 101 /* InstanceOfKeyword */: - case 100 /* InKeyword */: - case 126 /* AsKeyword */: + case 102 /* InstanceOfKeyword */: + case 101 /* InKeyword */: + case 127 /* AsKeyword */: case 34 /* EqualsEqualsToken */: case 35 /* ExclamationEqualsToken */: case 36 /* EqualsEqualsEqualsToken */: @@ -118248,23 +122581,23 @@ var ts; case 51 /* BarToken */: case 55 /* AmpersandAmpersandToken */: case 56 /* BarBarToken */: - case 73 /* BarEqualsToken */: - case 72 /* AmpersandEqualsToken */: - case 77 /* CaretEqualsToken */: - case 69 /* LessThanLessThanEqualsToken */: - case 70 /* GreaterThanGreaterThanEqualsToken */: - case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 63 /* PlusEqualsToken */: - case 64 /* MinusEqualsToken */: - case 65 /* AsteriskEqualsToken */: - case 67 /* SlashEqualsToken */: - case 68 /* PercentEqualsToken */: - case 62 /* EqualsToken */: + 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 74 /* BarBarEqualsToken */: - case 75 /* AmpersandAmpersandEqualsToken */: - case 76 /* QuestionQuestionEqualsToken */: + case 75 /* BarBarEqualsToken */: + case 76 /* AmpersandAmpersandEqualsToken */: + case 77 /* QuestionQuestionEqualsToken */: return true; default: return false; @@ -118290,7 +122623,7 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5 /* operator */; } - else if (token >= 18 /* FirstPunctuation */ && token <= 77 /* LastPunctuation */) { + else if (token >= 18 /* FirstPunctuation */ && token <= 78 /* LastPunctuation */) { return 10 /* punctuation */; } switch (token) { @@ -118309,7 +122642,7 @@ var ts; case 5 /* WhitespaceTrivia */: case 4 /* NewLineTrivia */: return 8 /* whiteSpace */; - case 78 /* Identifier */: + case 79 /* Identifier */: default: if (ts.isTemplateLiteralKind(token)) { return 6 /* stringLiteral */; @@ -118334,13 +122667,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 256 /* ModuleDeclaration */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 251 /* FunctionDeclaration */: - case 221 /* ClassExpression */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 258 /* ModuleDeclaration */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 253 /* FunctionDeclaration */: + case 223 /* ClassExpression */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } } @@ -118547,10 +122880,11 @@ var ts; pushClassification(start, width, 1 /* comment */); } function classifyJSDocComment(docComment) { + var _a, _b, _c, _d, _e, _f, _g; var pos = docComment.pos; if (docComment.tags) { - for (var _i = 0, _a = docComment.tags; _i < _a.length; _i++) { - var tag = _a[_i]; + for (var _i = 0, _h = docComment.tags; _i < _h.length; _i++) { + var tag = _h[_i]; // As we walk through each tag, classify the portion of text from the end of // the last tag (or the start of the entire doc comment) as 'comment'. if (tag.pos !== pos) { @@ -118559,22 +122893,56 @@ var ts; pushClassification(tag.pos, 1, 10 /* punctuation */); // "@" pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); // e.g. "param" pos = tag.tagName.end; + var commentStart = tag.tagName.end; switch (tag.kind) { - case 326 /* JSDocParameterTag */: - processJSDocParameterTag(tag); + case 334 /* 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 330 /* JSDocTemplateTag */: + case 341 /* JSDocPropertyTag */: + var prop = tag; + commentStart = prop.isNameFirst && ((_b = prop.typeExpression) === null || _b === void 0 ? void 0 : _b.end) || prop.name.end; + break; + case 338 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); pos = tag.end; + commentStart = tag.typeParameters.end; + break; + case 339 /* JSDocTypedefTag */: + var type = tag; + commentStart = ((_c = type.typeExpression) === null || _c === void 0 ? void 0 : _c.kind) === 303 /* 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 329 /* JSDocTypeTag */: + case 332 /* JSDocCallbackTag */: + commentStart = tag.typeExpression.end; + break; + case 337 /* JSDocTypeTag */: processElement(tag.typeExpression); pos = tag.end; + commentStart = tag.typeExpression.end; + break; + case 336 /* JSDocThisTag */: + case 333 /* JSDocEnumTag */: + commentStart = tag.typeExpression.end; break; - case 327 /* JSDocReturnTag */: + case 335 /* JSDocReturnTag */: processElement(tag.typeExpression); pos = tag.end; + commentStart = ((_f = tag.typeExpression) === null || _f === void 0 ? void 0 : _f.end) || commentStart; break; + case 340 /* JSDocSeeTag */: + commentStart = ((_g = tag.name) === null || _g === void 0 ? void 0 : _g.end) || commentStart; + break; + case 322 /* JSDocAugmentsTag */: + case 323 /* JSDocImplementsTag */: + commentStart = tag.class.end; + break; + } + if (typeof tag.comment === "object") { + pushCommentRange(tag.comment.pos, tag.comment.end - tag.comment.pos); + } + else if (typeof tag.comment === "string") { + pushCommentRange(commentStart, tag.end - commentStart); } } } @@ -118602,7 +122970,8 @@ var ts; } function tryClassifyTripleSlashComment(start, width) { var tripleSlashXMLCommentRegEx = /^(\/\/\/\s*)(<)(?:(\S+)((?:[^/]|\/[^>])*)(\/>)?)?/im; - var attributeRegex = /(\S+)(\s*)(=)(\s*)('[^']+'|"[^"]+")/img; + // Require a leading whitespace character (the parser already does) to prevent terrible backtracking performance + var attributeRegex = /(\s)(\S+)(\s*)(=)(\s*)('[^']+'|"[^"]+")/img; var text = sourceFile.text.substr(start, width); var match = tripleSlashXMLCommentRegEx.exec(text); if (!match) { @@ -118630,25 +122999,25 @@ var ts; if (!attrMatch) { break; } - var newAttrPos = pos + attrMatch.index; + var newAttrPos = pos + attrMatch.index + attrMatch[1].length; // whitespace if (newAttrPos > attrPos) { pushCommentRange(attrPos, newAttrPos - attrPos); attrPos = newAttrPos; } - pushClassification(attrPos, attrMatch[1].length, 22 /* jsxAttribute */); // attribute name - attrPos += attrMatch[1].length; - if (attrMatch[2].length) { - pushCommentRange(attrPos, attrMatch[2].length); // whitespace - attrPos += attrMatch[2].length; + pushClassification(attrPos, attrMatch[2].length, 22 /* jsxAttribute */); // attribute name + attrPos += attrMatch[2].length; + if (attrMatch[3].length) { + pushCommentRange(attrPos, attrMatch[3].length); // whitespace + attrPos += attrMatch[3].length; } - pushClassification(attrPos, attrMatch[3].length, 5 /* operator */); // = - attrPos += attrMatch[3].length; - if (attrMatch[4].length) { - pushCommentRange(attrPos, attrMatch[4].length); // whitespace - attrPos += attrMatch[4].length; + pushClassification(attrPos, attrMatch[4].length, 5 /* operator */); // = + attrPos += attrMatch[4].length; + if (attrMatch[5].length) { + pushCommentRange(attrPos, attrMatch[5].length); // whitespace + attrPos += attrMatch[5].length; } - pushClassification(attrPos, attrMatch[5].length, 24 /* jsxAttributeStringLiteralValue */); // attribute value - attrPos += attrMatch[5].length; + pushClassification(attrPos, attrMatch[6].length, 24 /* jsxAttributeStringLiteralValue */); // attribute value + attrPos += attrMatch[6].length; } pos += match[4].length; if (pos > attrPos) { @@ -118722,22 +123091,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 275 /* JsxOpeningElement */: + case 277 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 276 /* JsxClosingElement */: + case 278 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 274 /* JsxSelfClosingElement */: + case 276 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 280 /* JsxAttribute */: + case 282 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -118764,19 +123133,19 @@ var ts; if (ts.isPunctuation(tokenKind)) { if (token) { var parent = token.parent; - if (tokenKind === 62 /* EqualsToken */) { + if (tokenKind === 63 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (parent.kind === 249 /* VariableDeclaration */ || - parent.kind === 163 /* PropertyDeclaration */ || - parent.kind === 160 /* Parameter */ || - parent.kind === 280 /* JsxAttribute */) { + if (parent.kind === 251 /* VariableDeclaration */ || + parent.kind === 165 /* PropertyDeclaration */ || + parent.kind === 162 /* Parameter */ || + parent.kind === 282 /* JsxAttribute */) { return 5 /* operator */; } } - if (parent.kind === 216 /* BinaryExpression */ || - parent.kind === 214 /* PrefixUnaryExpression */ || - parent.kind === 215 /* PostfixUnaryExpression */ || - parent.kind === 217 /* ConditionalExpression */) { + if (parent.kind === 218 /* BinaryExpression */ || + parent.kind === 216 /* PrefixUnaryExpression */ || + parent.kind === 217 /* PostfixUnaryExpression */ || + parent.kind === 219 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -118789,7 +123158,7 @@ var ts; return 25 /* bigintLiteral */; } else if (tokenKind === 10 /* StringLiteral */) { - return token && token.parent.kind === 280 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + return token && token.parent.kind === 282 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } else if (tokenKind === 13 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. @@ -118802,35 +123171,35 @@ var ts; else if (tokenKind === 11 /* JsxText */) { return 23 /* jsxText */; } - else if (tokenKind === 78 /* Identifier */) { + else if (tokenKind === 79 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 159 /* TypeParameter */: + case 161 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 253 /* InterfaceDeclaration */: + case 255 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 160 /* Parameter */: + case 162 /* Parameter */: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; } @@ -118932,13 +123301,13 @@ var ts; var inJSXElement = false; function visit(node) { switch (node.kind) { - case 256 /* ModuleDeclaration */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 251 /* FunctionDeclaration */: - case 221 /* ClassExpression */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 258 /* ModuleDeclaration */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 253 /* FunctionDeclaration */: + case 223 /* ClassExpression */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } if (!node || !ts.textSpanIntersectsWith(span, node.pos, node.getFullWidth()) || node.getFullWidth() === 0) { @@ -119084,25 +123453,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([ - [249 /* VariableDeclaration */, 7 /* variable */], - [160 /* Parameter */, 6 /* parameter */], - [163 /* PropertyDeclaration */, 9 /* property */], - [256 /* ModuleDeclaration */, 3 /* namespace */], - [255 /* EnumDeclaration */, 1 /* enum */], - [291 /* EnumMember */, 8 /* enumMember */], - [252 /* ClassDeclaration */, 0 /* class */], - [165 /* MethodDeclaration */, 11 /* member */], - [251 /* FunctionDeclaration */, 10 /* function */], - [208 /* FunctionExpression */, 10 /* function */], - [164 /* MethodSignature */, 11 /* member */], - [167 /* GetAccessor */, 9 /* property */], - [168 /* SetAccessor */, 9 /* property */], - [162 /* PropertySignature */, 9 /* property */], - [253 /* InterfaceDeclaration */, 2 /* interface */], - [254 /* TypeAliasDeclaration */, 5 /* type */], - [159 /* TypeParameter */, 4 /* typeParameter */], - [288 /* PropertyAssignment */, 9 /* property */], - [289 /* ShorthandPropertyAssignment */, 9 /* property */] + [251 /* VariableDeclaration */, 7 /* variable */], + [162 /* Parameter */, 6 /* parameter */], + [165 /* PropertyDeclaration */, 9 /* property */], + [258 /* ModuleDeclaration */, 3 /* namespace */], + [257 /* EnumDeclaration */, 1 /* enum */], + [293 /* EnumMember */, 8 /* enumMember */], + [254 /* ClassDeclaration */, 0 /* class */], + [167 /* MethodDeclaration */, 11 /* member */], + [253 /* FunctionDeclaration */, 10 /* function */], + [210 /* FunctionExpression */, 10 /* function */], + [166 /* MethodSignature */, 11 /* member */], + [169 /* GetAccessor */, 9 /* property */], + [170 /* SetAccessor */, 9 /* property */], + [164 /* PropertySignature */, 9 /* property */], + [255 /* InterfaceDeclaration */, 2 /* interface */], + [256 /* TypeAliasDeclaration */, 5 /* type */], + [161 /* TypeParameter */, 4 /* typeParameter */], + [290 /* PropertyAssignment */, 9 /* property */], + [291 /* ShorthandPropertyAssignment */, 9 /* property */] ]); })(v2020 = classifier.v2020 || (classifier.v2020 = {})); })(classifier = ts.classifier || (ts.classifier = {})); @@ -119122,12 +123491,12 @@ var ts; if (ts.isInString(sourceFile, position, contextToken)) { if (!contextToken || !ts.isStringLiteralLike(contextToken)) return undefined; - var entries = getStringLiteralCompletionEntries(sourceFile, contextToken, position, checker, options, host); - return convertStringLiteralCompletions(entries, contextToken, sourceFile, checker, log, preferences); + var entries = getStringLiteralCompletionEntries(sourceFile, contextToken, position, checker, options, host, preferences); + return convertStringLiteralCompletions(entries, contextToken, sourceFile, checker, log, options, preferences); } } StringCompletions.getStringLiteralCompletions = getStringLiteralCompletions; - function convertStringLiteralCompletions(completion, contextToken, sourceFile, checker, log, preferences) { + function convertStringLiteralCompletions(completion, contextToken, sourceFile, checker, log, options, preferences) { if (completion === undefined) { return undefined; } @@ -119137,7 +123506,7 @@ var ts; return convertPathCompletions(completion.paths); case 1 /* Properties */: { var entries = []; - Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, sourceFile, sourceFile, checker, 99 /* ESNext */, log, 4 /* String */, preferences); // Target will not be used, so arbitrary + Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, sourceFile, sourceFile, checker, 99 /* ESNext */, log, 4 /* String */, preferences, options); // Target will not be used, so arbitrary return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: completion.hasIndexSignature, optionalReplacementSpan: optionalReplacementSpan, entries: entries }; } case 2 /* Types */: { @@ -119154,10 +123523,10 @@ var ts; return ts.Debug.assertNever(completion); } } - function getStringLiteralCompletionDetails(name, sourceFile, position, contextToken, checker, options, host, cancellationToken) { + function getStringLiteralCompletionDetails(name, sourceFile, position, contextToken, checker, options, host, cancellationToken, preferences) { if (!contextToken || !ts.isStringLiteralLike(contextToken)) return undefined; - var completions = getStringLiteralCompletionEntries(sourceFile, contextToken, position, checker, options, host); + var completions = getStringLiteralCompletionEntries(sourceFile, contextToken, position, checker, options, host, preferences); return completions && stringLiteralCompletionDetails(name, contextToken, completions, sourceFile, checker, cancellationToken); } StringCompletions.getStringLiteralCompletionDetails = getStringLiteralCompletionDetails; @@ -119206,13 +123575,13 @@ var ts; StringLiteralCompletionKind[StringLiteralCompletionKind["Properties"] = 1] = "Properties"; StringLiteralCompletionKind[StringLiteralCompletionKind["Types"] = 2] = "Types"; })(StringLiteralCompletionKind || (StringLiteralCompletionKind = {})); - function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host) { + function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host, preferences) { var parent = walkUpParentheses(node.parent); switch (parent.kind) { - case 191 /* LiteralType */: { + case 193 /* LiteralType */: { var grandParent = walkUpParentheses(parent.parent); switch (grandParent.kind) { - case 173 /* TypeReference */: { + case 175 /* TypeReference */: { var typeReference_1 = grandParent; var typeArgument = ts.findAncestor(parent, function (n) { return n.parent === typeReference_1; }); if (typeArgument) { @@ -119220,7 +123589,7 @@ var ts; } return undefined; } - case 189 /* IndexedAccessType */: + case 191 /* IndexedAccessType */: // Get all apparent property names // i.e. interface Foo { // foo: string; @@ -119232,9 +123601,9 @@ var ts; return undefined; } return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(objectType)); - case 195 /* ImportType */: - return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) }; - case 182 /* UnionType */: { + case 197 /* ImportType */: + return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) }; + case 184 /* UnionType */: { if (!ts.isTypeReferenceNode(grandParent.parent)) { return undefined; } @@ -119246,7 +123615,7 @@ var ts; return undefined; } } - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: if (ts.isObjectLiteralExpression(parent.parent) && parent.name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { @@ -119263,7 +123632,7 @@ var ts; return stringLiteralCompletionsForObjectLiteral(typeChecker, parent.parent); } return fromContextualType(); - case 202 /* ElementAccessExpression */: { + case 204 /* ElementAccessExpression */: { var _b = parent, expression = _b.expression, argumentExpression = _b.argumentExpression; if (node === ts.skipParentheses(argumentExpression)) { // Get all names of properties on the expression @@ -119276,8 +123645,8 @@ var ts; } return undefined; } - case 203 /* CallExpression */: - case 204 /* NewExpression */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: if (!ts.isRequireCall(parent, /*checkArgumentIsStringLiteralLike*/ false) && !ts.isImportCall(parent)) { var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(node, position, sourceFile); // Get string literal completions from specialized signatures of the target @@ -119286,16 +123655,16 @@ var ts; return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo, typeChecker) : fromContextualType(); } // falls through (is `require("")` or `import("")`) - case 261 /* ImportDeclaration */: - case 267 /* ExportDeclaration */: - case 272 /* ExternalModuleReference */: + case 263 /* ImportDeclaration */: + case 269 /* ExportDeclaration */: + case 274 /* 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) }; + return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) }; default: return fromContextualType(); } @@ -119307,9 +123676,9 @@ var ts; } function walkUpParentheses(node) { switch (node.kind) { - case 186 /* ParenthesizedType */: + case 188 /* ParenthesizedType */: return ts.walkUpParenthesizedTypes(node); - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return ts.walkUpParenthesizedExpressions(node); default: return node; @@ -119337,7 +123706,7 @@ var ts; function stringLiteralCompletionsFromProperties(type) { return type && { kind: 1 /* Properties */, - symbols: ts.filter(type.getApparentProperties(), function (prop) { return !(prop.valueDeclaration && ts.isPrivateIdentifierPropertyDeclaration(prop.valueDeclaration)); }), + symbols: ts.filter(type.getApparentProperties(), function (prop) { return !(prop.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(prop.valueDeclaration)); }), hasIndexSignature: ts.hasIndexSignature(type) }; } @@ -119375,23 +123744,23 @@ var ts; return Math.max(name.indexOf(ts.directorySeparator), name.indexOf(ts.altDirectorySeparator)) !== -1 ? { name: name, kind: kind, extension: extension, span: wholeSpan } : { name: name, kind: kind, extension: extension, span: span }; }); } - function getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) { - return addReplacementSpans(node.text, node.getStart(sourceFile) + 1, getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker)); + function getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) { + return addReplacementSpans(node.text, node.getStart(sourceFile) + 1, getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker, preferences)); } - function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker) { + function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker, preferences) { var literalValue = ts.normalizeSlashes(node.text); 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) + ? getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, preferences) : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, compilerOptions, host, typeChecker); } function getExtensionOptions(compilerOptions, includeExtensions) { if (includeExtensions === void 0) { includeExtensions = false; } return { extensions: getSupportedExtensionsForModuleResolution(compilerOptions), includeExtensions: includeExtensions }; } - function getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath) { - var extensionOptions = getExtensionOptions(compilerOptions); + function getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, preferences) { + var extensionOptions = getExtensionOptions(compilerOptions, preferences.importModuleSpecifierEnding === "js"); if (compilerOptions.rootDirs) { return getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, extensionOptions, compilerOptions, host, scriptPath); } @@ -119508,7 +123877,7 @@ var ts; continue; var patterns = paths[path]; if (patterns) { - var _loop_1 = function (name, kind, extension) { + var _loop_2 = function (name, kind, extension) { // Path mappings may provide a duplicate way to get to something we've already added, so don't add again. if (!result.some(function (entry) { return entry.name === name; })) { result.push(nameAndKind(name, kind, extension)); @@ -119516,7 +123885,7 @@ var ts; }; for (var _i = 0, _a = getCompletionsForPathMapping(path, patterns, fragment, baseDirectory, fileExtensions, host); _i < _a.length; _i++) { var _b = _a[_i], name = _b.name, kind = _b.kind, extension = _b.extension; - _loop_1(name, kind, extension); + _loop_2(name, kind, extension); } } } @@ -119551,7 +123920,7 @@ var ts; // (But do if we didn't find anything, e.g. 'package.json' missing.) var foundGlobal = false; if (fragmentDirectory === undefined) { - var _loop_2 = function (moduleName) { + 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)); @@ -119559,7 +123928,7 @@ var ts; }; for (var _b = 0, _c = enumerateNodeModulesVisibleToScript(host, scriptPath); _b < _c.length; _b++) { var moduleName = _c[_b]; - _loop_2(moduleName); + _loop_3(moduleName); } } if (!foundGlobal) { @@ -119594,8 +123963,8 @@ var ts; if (!host.readDirectory) { return undefined; } - var parsed = ts.hasZeroOrOneAsteriskCharacter(pattern) ? ts.tryParsePattern(pattern) : undefined; - if (!parsed) { + var parsed = ts.tryParsePattern(pattern); + if (parsed === undefined || ts.isString(parsed)) { return undefined; } // The prefix has two effective parts: the directory path and the base component after the filepath that is not a @@ -119782,7 +124151,26 @@ var ts; SortText["GlobalsOrKeywords"] = "5"; SortText["AutoImportSuggestions"] = "6"; SortText["JavascriptIdentifiers"] = "7"; + SortText["DeprecatedLocalDeclarationPriority"] = "8"; + SortText["DeprecatedLocationPriority"] = "9"; + SortText["DeprecatedOptionalMember"] = "10"; + SortText["DeprecatedMemberDeclaredBySpreadAssignment"] = "11"; + SortText["DeprecatedSuggestedClassMembers"] = "12"; + SortText["DeprecatedGlobalsOrKeywords"] = "13"; + SortText["DeprecatedAutoImportSuggestions"] = "14"; })(SortText = Completions.SortText || (Completions.SortText = {})); + var SortTextId; + (function (SortTextId) { + SortTextId[SortTextId["LocalDeclarationPriority"] = 0] = "LocalDeclarationPriority"; + SortTextId[SortTextId["LocationPriority"] = 1] = "LocationPriority"; + SortTextId[SortTextId["OptionalMember"] = 2] = "OptionalMember"; + SortTextId[SortTextId["MemberDeclaredBySpreadAssignment"] = 3] = "MemberDeclaredBySpreadAssignment"; + SortTextId[SortTextId["SuggestedClassMembers"] = 4] = "SuggestedClassMembers"; + SortTextId[SortTextId["GlobalsOrKeywords"] = 5] = "GlobalsOrKeywords"; + SortTextId[SortTextId["AutoImportSuggestions"] = 6] = "AutoImportSuggestions"; + })(SortTextId || (SortTextId = {})); + // for JavaScript identifiers since they are preferred over deprecated symbols + var DeprecatedSortTextStart = SortTextId.AutoImportSuggestions + 2; /** * Special values for `CompletionInfo['source']` used to disambiguate * completion items with the same `name`. (Each completion item must @@ -119806,6 +124194,7 @@ var ts; SymbolOriginInfoKind[SymbolOriginInfoKind["Export"] = 4] = "Export"; SymbolOriginInfoKind[SymbolOriginInfoKind["Promise"] = 8] = "Promise"; SymbolOriginInfoKind[SymbolOriginInfoKind["Nullable"] = 16] = "Nullable"; + SymbolOriginInfoKind[SymbolOriginInfoKind["ResolvedExport"] = 32] = "ResolvedExport"; SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberNoExport"] = 2] = "SymbolMemberNoExport"; SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberExport"] = 6] = "SymbolMemberExport"; })(SymbolOriginInfoKind || (SymbolOriginInfoKind = {})); @@ -119818,8 +124207,14 @@ var ts; function originIsExport(origin) { return !!(origin && origin.kind & 4 /* Export */); } + function originIsResolvedExport(origin) { + return !!(origin && origin.kind === 32 /* ResolvedExport */); + } + function originIncludesSymbolName(origin) { + return originIsExport(origin) || originIsResolvedExport(origin); + } function originIsPackageJsonImport(origin) { - return originIsExport(origin) && !!origin.isFromPackageJson; + return (originIsExport(origin) || originIsResolvedExport(origin)) && !!origin.isFromPackageJson; } function originIsPromise(origin) { return !!(origin.kind & 8 /* Promise */); @@ -119845,52 +124240,6 @@ var ts; GlobalsSearch[GlobalsSearch["Success"] = 1] = "Success"; GlobalsSearch[GlobalsSearch["Fail"] = 2] = "Fail"; })(GlobalsSearch || (GlobalsSearch = {})); - function createImportSuggestionsForFileCache() { - var cache; - var projectVersion; - var fileName; - return { - isEmpty: function () { - return !cache; - }, - clear: function () { - cache = undefined; - fileName = undefined; - projectVersion = undefined; - }, - set: function (file, suggestions, version) { - cache = suggestions; - fileName = file; - if (version) { - projectVersion = version; - } - }, - get: function (file, checker, version) { - if (file !== fileName) { - return undefined; - } - if (version) { - return projectVersion === version ? cache : undefined; - } - ts.forEach(cache, function (suggestion) { - var _a, _b, _c; - // If the symbol/moduleSymbol was a merged symbol, it will have a new identity - // in the checker, even though the symbols to merge are the same (guaranteed by - // cache invalidation in synchronizeHostData). - if ((_a = suggestion.symbol.declarations) === null || _a === void 0 ? void 0 : _a.length) { - suggestion.symbol = checker.getMergedSymbol(suggestion.origin.isDefaultExport - ? (_b = suggestion.symbol.declarations[0].localSymbol) !== null && _b !== void 0 ? _b : suggestion.symbol.declarations[0].symbol - : suggestion.symbol.declarations[0].symbol); - } - if ((_c = suggestion.origin.moduleSymbol.declarations) === null || _c === void 0 ? void 0 : _c.length) { - suggestion.origin.moduleSymbol = checker.getMergedSymbol(suggestion.origin.moduleSymbol.declarations[0].symbol); - } - }); - return cache; - }, - }; - } - Completions.createImportSuggestionsForFileCache = createImportSuggestionsForFileCache; function getCompletionsAtPosition(host, program, log, sourceFile, position, preferences, triggerCharacter) { var typeChecker = program.getTypeChecker(); var compilerOptions = program.getCompilerOptions(); @@ -119898,12 +124247,19 @@ var ts; if (triggerCharacter && !ts.isInString(sourceFile, position, contextToken) && !isValidTrigger(sourceFile, triggerCharacter, contextToken, position)) { return undefined; } + if (triggerCharacter === " ") { + // `isValidTrigger` ensures we are at `import |` + if (preferences.includeCompletionsForImportStatements && preferences.includeCompletionsWithInsertText) { + return { isGlobalCompletion: true, isMemberCompletion: false, isNewIdentifierLocation: true, isIncomplete: true, entries: [] }; + } + return undefined; + } var stringCompletions = Completions.StringCompletions.getStringLiteralCompletions(sourceFile, position, contextToken, typeChecker, compilerOptions, host, log, preferences); if (stringCompletions) { return stringCompletions; } if (contextToken && ts.isBreakOrContinueStatement(contextToken.parent) - && (contextToken.kind === 80 /* BreakKeyword */ || contextToken.kind === 85 /* ContinueKeyword */ || contextToken.kind === 78 /* Identifier */)) { + && (contextToken.kind === 81 /* BreakKeyword */ || contextToken.kind === 86 /* ContinueKeyword */ || contextToken.kind === 79 /* Identifier */)) { return getLabelCompletionAtPosition(contextToken.parent); } var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, preferences, /*detailsEntryId*/ undefined, host); @@ -119921,6 +124277,8 @@ var ts; return jsdocCompletionInfo(ts.JsDoc.getJSDocTagCompletions()); case 3 /* JsDocParameterName */: return jsdocCompletionInfo(ts.JsDoc.getJSDocParameterNameCompletions(completionData.tag)); + case 4 /* Keywords */: + return specificKeywordCompletionInfo(completionData.keywords); default: return ts.Debug.assertNever(completionData); } @@ -119929,33 +124287,36 @@ var ts; function jsdocCompletionInfo(entries) { return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: entries }; } + function specificKeywordCompletionInfo(keywords) { + return { + isGlobalCompletion: false, + isMemberCompletion: false, + isNewIdentifierLocation: false, + entries: keywords.map(function (k) { return ({ + name: ts.tokenToString(k), + kind: "keyword" /* keyword */, + kindModifiers: "" /* none */, + sortText: SortText.GlobalsOrKeywords, + }); }), + }; + } function getOptionalReplacementSpan(location) { // StringLiteralLike locations are handled separately in stringCompletions.ts - return (location === null || location === void 0 ? void 0 : location.kind) === 78 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined; + return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined; } function completionInfoFromData(sourceFile, typeChecker, compilerOptions, log, completionData, preferences) { - var symbols = completionData.symbols, 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, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextMap = completionData.symbolToSortTextMap; - if (location && location.parent && ts.isJsxClosingElement(location.parent)) { - // In the TypeScript JSX element, if such element is not defined. When users query for completion at closing tag, - // instead of simply giving unknown value, the completion will return the tag-name of an associated opening-element. - // For example: - // var x =
" with type any - // And at `
` (with a closing `>`), the completion list will contain "div". - var tagName = location.parent.parent.openingElement.tagName; - var hasClosingAngleBracket = !!ts.findChildOfKind(location.parent, 31 /* GreaterThanToken */, sourceFile); - var entry = { - name: tagName.getFullText(sourceFile) + (hasClosingAngleBracket ? "" : ">"), - kind: "class" /* classElement */, - kindModifiers: undefined, - sortText: SortText.LocationPriority, - }; - return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: false, optionalReplacementSpan: getOptionalReplacementSpan(location), entries: [entry] }; + var symbols = completionData.symbols, 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, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextIdMap = completionData.symbolToSortTextIdMap; + // Verify if the file is JSX language variant + if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) { + var completionInfo = getJsxClosingTagCompletion(location, sourceFile); + if (completionInfo) { + return completionInfo; + } } var entries = []; if (isUncheckedFile(sourceFile, compilerOptions)) { var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, - /* contextToken */ undefined, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, propertyAccessToConvert, completionData.isJsxIdentifierExpected, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap); + /* contextToken */ undefined, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap); getJSCompletionEntries(sourceFile, location.pos, uniqueNames, compilerOptions.target, entries); // TODO: GH#18217 } else { @@ -119963,7 +124324,7 @@ var ts; return undefined; } getCompletionEntriesFromSymbols(symbols, entries, - /* contextToken */ undefined, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, propertyAccessToConvert, completionData.isJsxIdentifierExpected, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap); + /* contextToken */ undefined, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap); } if (keywordFilters !== 0 /* None */) { var entryNames = new ts.Set(entries.map(function (e) { return e.name; })); @@ -119999,6 +124360,49 @@ var ts; return false; } } + function getJsxClosingTagCompletion(location, sourceFile) { + // We wanna walk up the tree till we find a JSX closing element + var jsxClosingElement = ts.findAncestor(location, function (node) { + switch (node.kind) { + case 278 /* JsxClosingElement */: + return true; + case 43 /* SlashToken */: + case 31 /* GreaterThanToken */: + case 79 /* Identifier */: + case 203 /* PropertyAccessExpression */: + return false; + default: + return "quit"; + } + }); + if (jsxClosingElement) { + // In the TypeScript JSX element, if such element is not defined. When users query for completion at closing tag, + // instead of simply giving unknown value, the completion will return the tag-name of an associated opening-element. + // For example: + // var x =
" with type any + // And at `
` (with a closing `>`), the completion list will contain "div". + // And at property access expressions ` ` the completion will + // return full closing tag with an optional replacement span + // For example: + // 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 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 */, + kindModifiers: undefined, + sortText: SortText.LocationPriority, + }; + return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: false, optionalReplacementSpan: replacementSpan, entries: [entry] }; + } + return; + } function getJSCompletionEntries(sourceFile, position, uniqueNames, target, entries) { ts.getNameTable(sourceFile).forEach(function (pos, name) { // Skip identifiers produced only from the current location @@ -120025,9 +124429,13 @@ var ts; function createCompletionEntryForLiteral(sourceFile, preferences, literal) { return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority }; } - function createCompletionEntry(symbol, sortText, contextToken, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, preferences) { + function createCompletionEntry(symbol, sortText, contextToken, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences) { + var _a; var insertText; var replacementSpan = ts.getReplacementSpanForContextToken(contextToken); + var data; + var isSnippet; + var sourceDisplay; var insertQuestionDot = origin && originIsNullableMember(origin); var useBraces = origin && originIsSymbolMember(origin) || needsConvertPropertyAccess; if (origin && originIsThisType(origin)) { @@ -120071,9 +124479,24 @@ var ts; insertText = needsConvertPropertyAccess ? "" + awaitText + insertText : "" + awaitText + (insertQuestionDot ? "?." : ".") + insertText; replacementSpan = ts.createTextSpanFromBounds(propertyAccessToConvert.getStart(sourceFile), propertyAccessToConvert.end); } + if (originIsResolvedExport(origin)) { + ts.Debug.assertIsDefined(importCompletionNode); + (_a = getInsertTextAndReplacementSpanForImportCompletion(name, importCompletionNode, origin, useSemicolons, options, preferences), insertText = _a.insertText, replacementSpan = _a.replacementSpan); + sourceDisplay = [ts.textPart(origin.moduleSpecifier)]; + isSnippet = preferences.includeCompletionsWithSnippetText ? true : undefined; + } if (insertText !== undefined && !preferences.includeCompletionsWithInsertText) { return undefined; } + if (originIsExport(origin) || originIsResolvedExport(origin)) { + data = { + exportName: origin.exportName, + fileName: origin.fileName, + ambientModuleName: origin.fileName ? undefined : ts.stripQuotes(origin.moduleSymbol.name), + isPackageJsonImport: origin.isFromPackageJson ? true : undefined, + moduleSpecifier: originIsResolvedExport(origin) ? origin.moduleSpecifier : undefined, + }; + } // TODO(drosen): Right now we just permit *all* semantic meanings when calling // 'getSymbolKind' which is permissible given that it is backwards compatible; but // really we should consider passing the meaning for the node so that we don't report @@ -120091,9 +124514,30 @@ var ts; isRecommended: isRecommendedCompletionMatch(symbol, recommendedCompletion, typeChecker) || undefined, insertText: insertText, replacementSpan: replacementSpan, + sourceDisplay: sourceDisplay, + isSnippet: isSnippet, isPackageJsonImport: originIsPackageJsonImport(origin) || undefined, + isImportStatementCompletion: originIsResolvedExport(origin) || undefined, + data: data, }; } + function getInsertTextAndReplacementSpanForImportCompletion(name, importCompletionNode, origin, useSemicolons, options, preferences) { + var sourceFile = importCompletionNode.getSourceFile(); + var replacementSpan = ts.createTextSpanFromNode(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 tabStop = preferences.includeCompletionsWithSnippetText ? "$1" : ""; + var importKind = ts.codefix.getImportKind(sourceFile, exportKind, options); + var suffix = useSemicolons ? ";" : ""; + switch (importKind) { + case 3 /* CommonJS */: return { replacementSpan: replacementSpan, insertText: "import " + name + tabStop + " = require(" + quotedModuleSpecifier + ")" + suffix }; + case 1 /* Default */: return { replacementSpan: replacementSpan, insertText: "import " + name + tabStop + " from " + quotedModuleSpecifier + suffix }; + case 2 /* Namespace */: return { replacementSpan: replacementSpan, insertText: "import * as " + name + tabStop + " from " + quotedModuleSpecifier + suffix }; + case 0 /* Named */: return { replacementSpan: replacementSpan, insertText: "import { " + name + tabStop + " } from " + quotedModuleSpecifier + suffix }; + } + } function quotePropertyName(sourceFile, preferences, name) { if (/^\d+$/.test(name)) { return name; @@ -120108,29 +124552,34 @@ var ts; if (originIsExport(origin)) { return ts.stripQuotes(origin.moduleSymbol.name); } + if (originIsResolvedExport(origin)) { + return origin.moduleSpecifier; + } if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 1 /* ThisType */) { return CompletionSource.ThisProperty; } } - function getCompletionEntriesFromSymbols(symbols, entries, contextToken, location, sourceFile, typeChecker, target, log, kind, preferences, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap) { + function getCompletionEntriesFromSymbols(symbols, entries, contextToken, location, sourceFile, typeChecker, target, log, kind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap) { + var _a; var start = ts.timestamp(); + var variableDeclaration = getVariableDeclaration(location); + var useSemicolons = ts.probablyUsesSemicolons(sourceFile); // Tracks unique names. // Value is set to false for global variables or completions from external module exports, because we can have multiple of those; // true otherwise. Based on the order we add things we will always see locals first, then globals, then module exports. // So adding a completion for a local will prevent us from adding completions for external module exports sharing the same name. var uniques = new ts.Map(); - for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) { - var symbol = symbols_1[_i]; - var origin = symbolToOriginInfoMap ? symbolToOriginInfoMap[ts.getSymbolId(symbol)] : undefined; + for (var i = 0; i < symbols.length; i++) { + 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) { + if (!info || uniques.get(info.name) || kind === 1 /* Global */ && symbolToSortTextIdMap && !shouldIncludeSymbol(symbol, symbolToSortTextIdMap)) { continue; } var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess; - if (uniques.get(name)) { - continue; - } - var entry = createCompletionEntry(symbol, symbolToSortTextMap && symbolToSortTextMap[ts.getSymbolId(symbol)] || SortText.LocationPriority, contextToken, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, preferences); + var sortTextId = (_a = symbolToSortTextIdMap === null || symbolToSortTextIdMap === void 0 ? void 0 : symbolToSortTextIdMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : SortTextId.LocationPriority; + var sortText = (isDeprecated(symbol, typeChecker) ? DeprecatedSortTextStart + sortTextId : sortTextId).toString(); + var entry = createCompletionEntry(symbol, sortText, contextToken, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences); if (!entry) { continue; } @@ -120147,6 +124596,46 @@ var ts; has: function (name) { return uniques.has(name); }, add: function (name) { return uniques.set(name, true); }, }; + function shouldIncludeSymbol(symbol, symbolToSortTextIdMap) { + if (!ts.isSourceFile(location)) { + // export = /**/ here we want to get all meanings, so any symbol is ok + if (ts.isExportAssignment(location.parent)) { + return true; + } + // Filter out variables from their own initializers + // `const a = /* no 'a' here */` + if (variableDeclaration && symbol.valueDeclaration === variableDeclaration) { + return false; + } + // External modules can have global export declarations that will be + // available as global keywords in all scopes. But if the external module + // already has an explicit export and user only wants to user explicit + // module imports then the global keywords will be filtered out so auto + // import suggestions will win in the completion + var symbolOrigin = ts.skipAlias(symbol, typeChecker); + // We only want to filter out the global keywords + // Auto Imports are not available for scripts so this conditional is always false + if (!!sourceFile.externalModuleIndicator + && !compilerOptions.allowUmdGlobalAccess + && symbolToSortTextIdMap[ts.getSymbolId(symbol)] === SortTextId.GlobalsOrKeywords + && (symbolToSortTextIdMap[ts.getSymbolId(symbolOrigin)] === SortTextId.AutoImportSuggestions + || symbolToSortTextIdMap[ts.getSymbolId(symbolOrigin)] === SortTextId.LocationPriority)) { + return false; + } + // Continue with origin symbol + symbol = 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 !!(symbol.flags & 1920 /* Namespace */); + } + if (isTypeOnlyLocation) { + // It's a type, but you can reach it by namespace.type as well + return symbolCanBeReferencedAtTypeLocation(symbol, typeChecker); + } + } + // expressions are value space (which includes the value namespaces) + return !!(ts.getCombinedLocalAndExportSymbolFlags(symbol) & 111551 /* Value */); + } } Completions.getCompletionEntriesFromSymbols = getCompletionEntriesFromSymbols; function getLabelCompletionAtPosition(node) { @@ -120180,6 +124669,20 @@ var ts; return entries; } function getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host, preferences) { + if (entryId.data) { + var autoImport = getAutoImportSymbolFromCompletionEntryData(entryId.name, entryId.data, program, host); + if (autoImport) { + return { + type: "symbol", + symbol: autoImport.symbol, + location: ts.getTouchingPropertyName(sourceFile, position), + previousToken: ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined), + isJsxInitializer: false, + isTypeOnlyLocation: false, + origin: autoImport.origin, + }; + } + } var compilerOptions = program.getCompilerOptions(); var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId, host); if (!completionData) { @@ -120196,11 +124699,11 @@ var ts; // We don't need to perform character checks here because we're only comparing the // name against 'entryName' (which is known to be good), not building a new // completion entry. - return ts.firstDefined(symbols, function (symbol) { - var origin = symbolToOriginInfoMap[ts.getSymbolId(symbol)]; + return ts.firstDefined(symbols, function (symbol, index) { + var origin = symbolToOriginInfoMap[index]; var info = getCompletionEntryDisplayNameForSymbol(symbol, compilerOptions.target, origin, completionKind, completionData.isJsxIdentifierExpected); return info && info.name === entryId.name && getSourceFromOrigin(origin) === entryId.source - ? { type: "symbol", symbol: symbol, location: location, symbolToOriginInfoMap: symbolToOriginInfoMap, previousToken: previousToken, isJsxInitializer: isJsxInitializer, isTypeOnlyLocation: isTypeOnlyLocation } + ? { type: "symbol", symbol: symbol, location: location, origin: origin, previousToken: previousToken, isJsxInitializer: isJsxInitializer, isTypeOnlyLocation: isTypeOnlyLocation } : undefined; }) || { type: "none" }; } @@ -120210,7 +124713,7 @@ var ts; var name = entryId.name; var contextToken = ts.findPrecedingToken(position, sourceFile); if (ts.isInString(sourceFile, position, contextToken)) { - return Completions.StringCompletions.getStringLiteralCompletionDetails(name, sourceFile, position, contextToken, typeChecker, compilerOptions, host, cancellationToken); + return Completions.StringCompletions.getStringLiteralCompletionDetails(name, sourceFile, position, contextToken, typeChecker, compilerOptions, host, cancellationToken, preferences); } // Compute all the completion symbols again. var symbolCompletion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host, preferences); @@ -120224,13 +124727,15 @@ var ts; return ts.JsDoc.getJSDocTagCompletionDetails(name); case 3 /* JsDocParameterName */: return ts.JsDoc.getJSDocParameterNameCompletionDetails(name); + case 4 /* Keywords */: + return request.keywords.indexOf(ts.stringToToken(name)) > -1 ? createSimpleDetails(name, "keyword" /* keyword */, ts.SymbolDisplayPartKind.keyword) : undefined; default: return ts.Debug.assertNever(request); } } case "symbol": { - var symbol = symbolCompletion.symbol, location = symbolCompletion.location, symbolToOriginInfoMap = symbolCompletion.symbolToOriginInfoMap, previousToken = symbolCompletion.previousToken; - var _a = getCompletionEntryCodeActionsAndSourceDisplay(symbolToOriginInfoMap, symbol, program, typeChecker, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences), codeActions = _a.codeActions, sourceDisplay = _a.sourceDisplay; + var symbol = symbolCompletion.symbol, location = symbolCompletion.location, origin = symbolCompletion.origin, previousToken = symbolCompletion.previousToken; + var _a = getCompletionEntryCodeActionsAndSourceDisplay(origin, symbol, program, typeChecker, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, entryId.data), codeActions = _a.codeActions, sourceDisplay = _a.sourceDisplay; return createCompletionDetailsForSymbol(symbol, typeChecker, sourceFile, location, cancellationToken, codeActions, sourceDisplay); // TODO: GH#18217 } case "literal": { @@ -120256,15 +124761,17 @@ var ts; } Completions.createCompletionDetailsForSymbol = createCompletionDetailsForSymbol; function createCompletionDetails(name, kindModifiers, kind, displayParts, documentation, tags, codeActions, source) { - return { name: name, kindModifiers: kindModifiers, kind: kind, displayParts: displayParts, documentation: documentation, tags: tags, codeActions: codeActions, source: source }; + return { name: name, kindModifiers: kindModifiers, kind: kind, displayParts: displayParts, documentation: documentation, tags: tags, codeActions: codeActions, source: source, sourceDisplay: source }; } Completions.createCompletionDetails = createCompletionDetails; - function getCompletionEntryCodeActionsAndSourceDisplay(symbolToOriginInfoMap, symbol, program, checker, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences) { - var symbolOriginInfo = symbolToOriginInfoMap[ts.getSymbolId(symbol)]; - if (!symbolOriginInfo || !originIsExport(symbolOriginInfo)) { + function getCompletionEntryCodeActionsAndSourceDisplay(origin, symbol, program, checker, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, data) { + if (data === null || data === void 0 ? void 0 : data.moduleSpecifier) { + return { codeActions: undefined, sourceDisplay: [ts.textPart(data.moduleSpecifier)] }; + } + if (!origin || !originIsExport(origin)) { return { codeActions: undefined, sourceDisplay: undefined }; } - var moduleSymbol = symbolOriginInfo.moduleSymbol; + var moduleSymbol = origin.moduleSymbol; var exportedSymbol = checker.getMergedSymbol(ts.skipAlias(symbol.exportSymbol || symbol, checker)); var _a = ts.codefix.getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, ts.getNameForExportedSymbol(symbol, compilerOptions.target), host, program, formatContext, previousToken && ts.isIdentifier(previousToken) ? previousToken.getStart(sourceFile) : position, preferences), moduleSpecifier = _a.moduleSpecifier, codeAction = _a.codeAction; return { sourceDisplay: [ts.textPart(moduleSpecifier)], codeActions: [codeAction] }; @@ -120280,6 +124787,7 @@ var ts; CompletionDataKind[CompletionDataKind["JsDocTagName"] = 1] = "JsDocTagName"; CompletionDataKind[CompletionDataKind["JsDocTag"] = 2] = "JsDocTag"; CompletionDataKind[CompletionDataKind["JsDocParameterName"] = 3] = "JsDocParameterName"; + CompletionDataKind[CompletionDataKind["Keywords"] = 4] = "Keywords"; })(CompletionDataKind || (CompletionDataKind = {})); var CompletionKind; (function (CompletionKind) { @@ -120303,25 +124811,25 @@ var ts; function getContextualType(previousToken, position, sourceFile, checker) { var parent = previousToken.parent; switch (previousToken.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return ts.getContextualTypeFromParent(previousToken, checker); - case 62 /* EqualsToken */: + case 63 /* EqualsToken */: switch (parent.kind) { - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return checker.getContextualType(parent.initializer); // TODO: GH#18217 - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return checker.getTypeAtLocation(parent.left); - case 280 /* JsxAttribute */: + case 282 /* JsxAttribute */: return checker.getContextualTypeForJsxAttribute(parent); default: return undefined; } - case 102 /* NewKeyword */: + case 103 /* NewKeyword */: return checker.getContextualType(parent); - case 81 /* CaseKeyword */: + case 82 /* CaseKeyword */: return ts.getSwitchedType(ts.cast(parent, ts.isCaseClause), checker); case 18 /* OpenBraceToken */: - return ts.isJsxExpression(parent) && parent.parent.kind !== 273 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; + return ts.isJsxExpression(parent) && parent.parent.kind !== 275 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; default: var argInfo = ts.SignatureHelp.getArgumentInfoForCompletions(previousToken, position, sourceFile); return argInfo ? @@ -120340,7 +124848,8 @@ var ts; return symbol.parent && (isModuleSymbol(symbol.parent) ? symbol : getFirstSymbolInChain(symbol.parent, enclosingDeclaration, checker)); } function isModuleSymbol(symbol) { - return symbol.declarations.some(function (d) { return d.kind === 297 /* SourceFile */; }); + var _a; + return !!((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d.kind === 299 /* SourceFile */; })); } function getCompletionData(program, log, sourceFile, isUncheckedFile, position, preferences, detailsEntryId, host) { var typeChecker = program.getTypeChecker(); @@ -120391,11 +124900,11 @@ var ts; if (tag.tagName.pos <= position && position <= tag.tagName.end) { return { kind: 1 /* JsDocTagName */ }; } - if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 301 /* JSDocTypeExpression */) { + if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 303 /* JSDocTypeExpression */) { currentToken = ts.getTokenAtPosition(sourceFile, position); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 333 /* JSDocPropertyTag */ || + (currentToken.parent.kind !== 341 /* JSDocPropertyTag */ || currentToken.parent.name !== currentToken))) { // Use as type location if inside tag's type expression insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression); @@ -120420,7 +124929,7 @@ var ts; var contextToken = previousToken; // Check if the caret is at the end of an identifier; this is a partial identifier that we want to complete: e.g. a.toS| // Skip this partial identifier and adjust the contextToken to the token that precedes it. - if (contextToken && position <= contextToken.end && (ts.isIdentifierOrPrivateIdentifier(contextToken) || ts.isKeyword(contextToken.kind))) { + if (contextToken && position <= contextToken.end && (ts.isMemberName(contextToken) || ts.isKeyword(contextToken.kind))) { var start_1 = ts.timestamp(); contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile, /*startNode*/ undefined); // TODO: GH#18217 log("getCompletionData: Get previous token 2: " + (ts.timestamp() - start_1)); @@ -120436,10 +124945,22 @@ var ts; var isStartingCloseTag = false; var isJsxInitializer = false; var isJsxIdentifierExpected = false; + var importCompletionNode; var location = ts.getTouchingPropertyName(sourceFile, position); if (contextToken) { + var importCompletionCandidate = getImportCompletionNode(contextToken); + if (importCompletionCandidate === 154 /* FromKeyword */) { + return { kind: 4 /* Keywords */, keywords: [154 /* FromKeyword */] }; + } + // Import statement completions use `insertText`, and also require the `data` property of `CompletionEntryIdentifier` + // added in TypeScript 4.3 to be sent back from the client during `getCompletionEntryDetails`. Since this feature + // 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. + if (importCompletionCandidate && preferences.includeCompletionsForImportStatements && preferences.includeCompletionsWithInsertText) { + importCompletionNode = importCompletionCandidate; + } // Bail out if this is a known invalid completion location - if (isCompletionListBlocker(contextToken)) { + if (!importCompletionNode && isCompletionListBlocker(contextToken)) { log("Returning an empty list because completion was requested in an invalid position."); return undefined; } @@ -120448,7 +124969,7 @@ var ts; isRightOfDot = contextToken.kind === 24 /* DotToken */; isRightOfQuestionDot = contextToken.kind === 28 /* QuestionDotToken */; switch (parent.kind) { - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: propertyAccessToConvert = parent; node = propertyAccessToConvert.expression; if ((ts.isCallExpression(node) || ts.isFunctionLike(node)) && @@ -120461,14 +124982,14 @@ var ts; return undefined; } break; - case 157 /* QualifiedName */: + case 159 /* QualifiedName */: node = parent.left; break; - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: node = parent.name; break; - case 195 /* ImportType */: - case 226 /* MetaProperty */: + case 197 /* ImportType */: + case 228 /* MetaProperty */: node = parent; break; default: @@ -120477,11 +124998,11 @@ var ts; return undefined; } } - else if (sourceFile.languageVariant === 1 /* JSX */) { + else if (!importCompletionNode && sourceFile.languageVariant === 1 /* 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 === 201 /* PropertyAccessExpression */) { + if (parent && parent.kind === 203 /* PropertyAccessExpression */) { contextToken = parent; parent = parent.parent; } @@ -120489,45 +125010,45 @@ var ts; if (currentToken.parent === location) { switch (currentToken.kind) { case 31 /* GreaterThanToken */: - if (currentToken.parent.kind === 273 /* JsxElement */ || currentToken.parent.kind === 275 /* JsxOpeningElement */) { + if (currentToken.parent.kind === 275 /* JsxElement */ || currentToken.parent.kind === 277 /* JsxOpeningElement */) { location = currentToken; } break; case 43 /* SlashToken */: - if (currentToken.parent.kind === 274 /* JsxSelfClosingElement */) { + if (currentToken.parent.kind === 276 /* JsxSelfClosingElement */) { location = currentToken; } break; } } switch (parent.kind) { - case 276 /* JsxClosingElement */: + case 278 /* JsxClosingElement */: if (contextToken.kind === 43 /* SlashToken */) { isStartingCloseTag = true; location = contextToken; } break; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: if (!binaryExpressionMayBeOpenTag(parent)) { break; } // falls through - case 274 /* JsxSelfClosingElement */: - case 273 /* JsxElement */: - case 275 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: + case 275 /* JsxElement */: + case 277 /* JsxOpeningElement */: isJsxIdentifierExpected = true; if (contextToken.kind === 29 /* LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } break; - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: // For `
`, `parent` will be `{true}` and `previousToken` will be `}` if (previousToken.kind === 19 /* CloseBraceToken */ && currentToken.kind === 31 /* GreaterThanToken */) { isJsxIdentifierExpected = true; } break; - case 280 /* JsxAttribute */: + case 282 /* JsxAttribute */: // For `
`, `parent` will be JsxAttribute and `previousToken` will be its initializer if (parent.initializer === previousToken && previousToken.end < position) { @@ -120535,16 +125056,16 @@ var ts; break; } switch (previousToken.kind) { - case 62 /* EqualsToken */: + case 63 /* EqualsToken */: isJsxInitializer = true; break; - case 78 /* Identifier */: + case 79 /* 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, 62 /* EqualsToken */, sourceFile)) { + ts.findChildOfKind(parent, 63 /* EqualsToken */, sourceFile)) { isJsxInitializer = previousToken; } } @@ -120560,9 +125081,12 @@ var ts; // This also gets mutated in nested-functions after the return var symbols = []; var symbolToOriginInfoMap = []; - var symbolToSortTextMap = []; - var importSuggestionsCache = host.getImportSuggestionsCache && host.getImportSuggestionsCache(); + var symbolToSortTextIdMap = []; + var seenPropertySymbols = new ts.Map(); var isTypeOnly = isTypeOnlyCompletion(); + var getModuleSpecifierResolutionHost = ts.memoizeOne(function (isFromPackageJson) { + return ts.createModuleSpecifierResolutionHost(isFromPackageJson ? host.getPackageJsonAutoImportProvider() : program, host); + }); if (isRightOfDot || isRightOfQuestionDot) { getTypeScriptMemberSymbols(); } @@ -120571,7 +125095,7 @@ var ts; ts.Debug.assertEachIsDefined(tagSymbols, "getJsxIntrinsicTagNames() should all be defined"); tryGetGlobalSymbols(); symbols = tagSymbols.concat(symbols); - completionKind = 3 /* MemberLike */; + completionKind = 1 /* Global */; keywordFilters = 0 /* None */; } else if (isStartingCloseTag) { @@ -120580,7 +125104,7 @@ var ts; if (tagSymbol) { symbols = [tagSymbol]; } - completionKind = 3 /* MemberLike */; + completionKind = 1 /* Global */; keywordFilters = 0 /* None */; } else { @@ -120610,17 +125134,18 @@ var ts; previousToken: previousToken, isJsxInitializer: isJsxInitializer, insideJsDocTagTypeExpression: insideJsDocTagTypeExpression, - symbolToSortTextMap: symbolToSortTextMap, + symbolToSortTextIdMap: symbolToSortTextIdMap, isTypeOnlyLocation: isTypeOnly, isJsxIdentifierExpected: isJsxIdentifierExpected, + importCompletionNode: importCompletionNode, }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 326 /* JSDocParameterTag */: - case 333 /* JSDocPropertyTag */: - case 327 /* JSDocReturnTag */: - case 329 /* JSDocTypeTag */: - case 331 /* JSDocTypedefTag */: + case 334 /* JSDocParameterTag */: + case 341 /* JSDocPropertyTag */: + case 335 /* JSDocReturnTag */: + case 337 /* JSDocTypeTag */: + case 339 /* JSDocTypedefTag */: return true; default: return false; @@ -120647,11 +125172,11 @@ var ts; // Extract module or enum members var exportedSymbols = typeChecker.getExportsOfModule(symbol); ts.Debug.assertEachIsDefined(exportedSymbols, "getExportsOfModule() should all be defined"); - var isValidValueAccess_1 = function (symbol) { return typeChecker.isValidPropertyAccess(isImportType ? node : (node.parent), symbol.name); }; - var isValidTypeAccess_1 = function (symbol) { return symbolCanBeReferencedAtTypeLocation(symbol); }; + var isValidValueAccess_1 = function (symbol) { return typeChecker.isValidPropertyAccess(isImportType ? node : node.parent, symbol.name); }; + 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) { return !!(symbol.flags & 1920 /* Namespace */) && !symbol.declarations.every(function (d) { return d.parent === node.parent; }); } + ? 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; })); } : isRhsOfImportDeclaration ? // Any kind is allowed when dotting off namespace in internal import equals declaration function (symbol) { return isValidTypeAccess_1(symbol) || isValidValueAccess_1(symbol); } : @@ -120665,7 +125190,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 !== 297 /* SourceFile */ && d.kind !== 256 /* ModuleDeclaration */ && d.kind !== 255 /* EnumDeclaration */; })) { + symbol.declarations.some(function (d) { return d.kind !== 299 /* SourceFile */ && d.kind !== 258 /* ModuleDeclaration */ && d.kind !== 257 /* EnumDeclaration */; })) { var type = typeChecker.getTypeOfSymbolAtLocation(symbol, node).getNonOptionalType(); var insertQuestionDot = false; if (type.isNullableType()) { @@ -120685,8 +125210,8 @@ var ts; } } } - if (ts.isMetaProperty(node) && (node.keywordToken === 102 /* NewKeyword */ || node.keywordToken === 99 /* ImportKeyword */) && contextToken === node.getChildAt(1)) { - var completion = (node.keywordToken === 102 /* NewKeyword */) ? "target" : "meta"; + if (ts.isMetaProperty(node) && (node.keywordToken === 103 /* NewKeyword */ || node.keywordToken === 100 /* ImportKeyword */) && contextToken === node.getChildAt(1)) { + var completion = (node.keywordToken === 103 /* NewKeyword */) ? "target" : "meta"; symbols.push(typeChecker.createSymbol(4 /* Property */, ts.escapeLeadingUnderscores(completion))); return; } @@ -120712,7 +125237,7 @@ var ts; if (isRightOfQuestionDot && ts.some(type.getCallSignatures())) { isNewIdentifierLocation = true; } - var propertyAccess = node.kind === 195 /* ImportType */ ? node : node.parent; + var propertyAccess = node.kind === 197 /* ImportType */ ? node : node.parent; if (isUncheckedFile) { // 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 @@ -120751,13 +125276,24 @@ var ts; var nameSymbol = leftMostName && typeChecker.getSymbolAtLocation(leftMostName); // If this is nested like for `namespace N { export const sym = Symbol(); }`, we'll add the completion for `N`. var firstAccessibleSymbol = nameSymbol && getFirstSymbolInChain(nameSymbol, contextToken, typeChecker); - if (firstAccessibleSymbol && !symbolToOriginInfoMap[ts.getSymbolId(firstAccessibleSymbol)]) { + if (firstAccessibleSymbol && ts.addToSeen(seenPropertySymbols, ts.getSymbolId(firstAccessibleSymbol))) { + var index = symbols.length; symbols.push(firstAccessibleSymbol); var moduleSymbol = firstAccessibleSymbol.parent; - symbolToOriginInfoMap[ts.getSymbolId(firstAccessibleSymbol)] = - !moduleSymbol || !ts.isExternalModuleSymbol(moduleSymbol) - ? { kind: getNullableSymbolOriginInfoKind(2 /* SymbolMemberNoExport */) } - : { kind: getNullableSymbolOriginInfoKind(6 /* SymbolMemberExport */), moduleSymbol: moduleSymbol, isDefaultExport: false }; + if (!moduleSymbol || !ts.isExternalModuleSymbol(moduleSymbol)) { + symbolToOriginInfoMap[index] = { kind: getNullableSymbolOriginInfoKind(2 /* SymbolMemberNoExport */) }; + } + else { + var origin = { + kind: getNullableSymbolOriginInfoKind(6 /* SymbolMemberExport */), + moduleSymbol: moduleSymbol, + isDefaultExport: false, + symbolName: firstAccessibleSymbol.name, + exportName: firstAccessibleSymbol.name, + fileName: ts.isExternalModuleNameRelative(ts.stripQuotes(moduleSymbol.name)) ? ts.cast(moduleSymbol.valueDeclaration, ts.isSourceFile).fileName : undefined, + }; + symbolToOriginInfoMap[index] = origin; + } } else if (preferences.includeCompletionsWithInsertText) { addSymbolOriginInfo(symbol); @@ -120772,16 +125308,16 @@ var ts; } function addSymbolSortInfo(symbol) { if (isStaticProperty(symbol)) { - symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.LocalDeclarationPriority; + symbolToSortTextIdMap[ts.getSymbolId(symbol)] = SortTextId.LocalDeclarationPriority; } } function addSymbolOriginInfo(symbol) { if (preferences.includeCompletionsWithInsertText) { - if (insertAwait && !symbolToOriginInfoMap[ts.getSymbolId(symbol)]) { - symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: getNullableSymbolOriginInfoKind(8 /* Promise */) }; + if (insertAwait && ts.addToSeen(seenPropertySymbols, ts.getSymbolId(symbol))) { + symbolToOriginInfoMap[symbols.length] = { kind: getNullableSymbolOriginInfoKind(8 /* Promise */) }; } else if (insertQuestionDot) { - symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: 16 /* Nullable */ }; + symbolToOriginInfoMap[symbols.length] = { kind: 16 /* Nullable */ }; } } } @@ -120794,7 +125330,9 @@ var ts; return ts.isIdentifier(e) ? e : ts.isPropertyAccessExpression(e) ? getLeftMostName(e.expression) : undefined; } function tryGetGlobalSymbols() { - var result = tryGetObjectLikeCompletionSymbols() + var result = tryGetObjectTypeLiteralInTypeArgumentCompletionSymbols() + || tryGetObjectLikeCompletionSymbols() + || tryGetImportCompletionSymbols() || tryGetImportOrExportClauseCompletionSymbols() || tryGetLocalNamedExportCompletionSymbols() || tryGetConstructorCompletion() @@ -120827,11 +125365,17 @@ var ts; isNewIdentifierLocation = false; return 1 /* Success */; } + function tryGetImportCompletionSymbols() { + if (!importCompletionNode) + return 0 /* Continue */; + collectAutoImports(/*resolveModuleSpecifiers*/ true); + return 1 /* Success */; + } function getGlobalCompletions() { keywordFilters = tryGetFunctionLikeBodyCompletionContainer(contextToken) ? 5 /* FunctionLikeBodyKeywords */ : 1 /* All */; // Get all entities in the current scope. completionKind = 1 /* Global */; - isNewIdentifierLocation = isNewIdentifierDefinitionLocation(contextToken); + isNewIdentifierLocation = isNewIdentifierDefinitionLocation(); if (previousToken !== contextToken) { ts.Debug.assert(!!previousToken, "Expected 'contextToken' to be defined when different from 'previousToken'."); } @@ -120868,50 +125412,36 @@ var ts; var symbolMeanings = (isTypeOnly ? 0 /* None */ : 111551 /* Value */) | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */; symbols = typeChecker.getSymbolsInScope(scopeNode, symbolMeanings); ts.Debug.assertEachIsDefined(symbols, "getSymbolsInScope() should all be defined"); - for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) { - var symbol = symbols_2[_i]; + for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) { + var symbol = symbols_1[_i]; if (!typeChecker.isArgumentsSymbol(symbol) && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === sourceFile; })) { - symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.GlobalsOrKeywords; + symbolToSortTextIdMap[ts.getSymbolId(symbol)] = SortTextId.GlobalsOrKeywords; } } // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions` - if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 297 /* SourceFile */) { + if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 299 /* SourceFile */) { var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false); if (thisType && !isProbablyGlobalType(thisType, sourceFile, typeChecker)) { for (var _a = 0, _b = getPropertiesForCompletion(thisType, typeChecker); _a < _b.length; _a++) { var symbol = _b[_a]; - symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: 1 /* ThisType */ }; + symbolToOriginInfoMap[symbols.length] = { kind: 1 /* ThisType */ }; symbols.push(symbol); - symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.SuggestedClassMembers; + symbolToSortTextIdMap[ts.getSymbolId(symbol)] = SortTextId.SuggestedClassMembers; } } } - if (shouldOfferImportCompletions()) { - var lowerCaseTokenText_1 = previousToken && ts.isIdentifier(previousToken) ? previousToken.text.toLowerCase() : ""; - var autoImportSuggestions = getSymbolsFromOtherSourceFileExports(program.getCompilerOptions().target, host); - if (!detailsEntryId && importSuggestionsCache) { - importSuggestionsCache.set(sourceFile.fileName, autoImportSuggestions, host.getProjectVersion && host.getProjectVersion()); - } - autoImportSuggestions.forEach(function (_a) { - var symbol = _a.symbol, symbolName = _a.symbolName, skipFilter = _a.skipFilter, origin = _a.origin; - if (detailsEntryId) { - if (detailsEntryId.source && ts.stripQuotes(origin.moduleSymbol.name) !== detailsEntryId.source) { - return; - } - } - else if (!skipFilter && !stringContainsCharactersInOrder(symbolName.toLowerCase(), lowerCaseTokenText_1)) { - return; - } - var symbolId = ts.getSymbolId(symbol); - symbols.push(symbol); - symbolToOriginInfoMap[symbolId] = origin; - symbolToSortTextMap[symbolId] = SortText.AutoImportSuggestions; - }); + collectAutoImports(/*resolveModuleSpecifier*/ false); + if (isTypeOnly) { + keywordFilters = contextToken && ts.isAssertionExpression(contextToken.parent) + ? 6 /* TypeAssertionKeywords */ + : 7 /* TypeKeywords */; } - filterGlobalCompletion(symbols); } function shouldOfferImportCompletions() { + // If already typing an import statement, provide completions for it. + if (importCompletionNode) + return true; // If current completion is for non-contextual Object literal shortahands, ignore auto-import symbols if (isNonContextualObjectLiteral) return false; @@ -120929,42 +125459,15 @@ var ts; } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { - case 297 /* SourceFile */: - case 218 /* TemplateExpression */: - case 283 /* JsxExpression */: - case 230 /* Block */: + case 299 /* SourceFile */: + case 220 /* TemplateExpression */: + case 285 /* JsxExpression */: + case 232 /* Block */: return true; default: return ts.isStatement(scopeNode); } } - function filterGlobalCompletion(symbols) { - var isTypeOnly = isTypeOnlyCompletion(); - if (isTypeOnly) { - keywordFilters = contextToken && ts.isAssertionExpression(contextToken.parent) - ? 6 /* TypeAssertionKeywords */ - : 7 /* TypeKeywords */; - } - ts.filterMutate(symbols, function (symbol) { - if (!ts.isSourceFile(location)) { - // export = /**/ here we want to get all meanings, so any symbol is ok - if (ts.isExportAssignment(location.parent)) { - return true; - } - symbol = ts.skipAlias(symbol, typeChecker); - // import m = /**/ <-- It can only access namespace (if typing import = x. this would get member symbols and not namespace) - if (ts.isInRightSideOfInternalImportEqualsDeclaration(location)) { - return !!(symbol.flags & 1920 /* Namespace */); - } - if (isTypeOnly) { - // It's a type, but you can reach it by namespace.type as well - return symbolCanBeReferencedAtTypeLocation(symbol); - } - } - // expressions are value space (which includes the value namespaces) - return !!(ts.getCombinedLocalAndExportSymbolFlags(symbol) & 111551 /* Value */); - }); - } function isTypeOnlyCompletion() { return insideJsDocTagTypeExpression || !isContextTokenValueLocation(contextToken) && @@ -120974,191 +125477,105 @@ var ts; } function isContextTokenValueLocation(contextToken) { return contextToken && - contextToken.kind === 111 /* TypeOfKeyword */ && - (contextToken.parent.kind === 176 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent)); + ((contextToken.kind === 112 /* TypeOfKeyword */ && + (contextToken.parent.kind === 178 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent))) || + (contextToken.kind === 128 /* AssertsKeyword */ && contextToken.parent.kind === 174 /* TypePredicate */)); } function isContextTokenTypeLocation(contextToken) { if (contextToken) { var parentKind = contextToken.parent.kind; switch (contextToken.kind) { case 58 /* ColonToken */: - return parentKind === 163 /* PropertyDeclaration */ || - parentKind === 162 /* PropertySignature */ || - parentKind === 160 /* Parameter */ || - parentKind === 249 /* VariableDeclaration */ || + return parentKind === 165 /* PropertyDeclaration */ || + parentKind === 164 /* PropertySignature */ || + parentKind === 162 /* Parameter */ || + parentKind === 251 /* VariableDeclaration */ || ts.isFunctionLikeKind(parentKind); - case 62 /* EqualsToken */: - return parentKind === 254 /* TypeAliasDeclaration */; - case 126 /* AsKeyword */: - return parentKind === 224 /* AsExpression */; + case 63 /* EqualsToken */: + return parentKind === 256 /* TypeAliasDeclaration */; + case 127 /* AsKeyword */: + return parentKind === 226 /* AsExpression */; case 29 /* LessThanToken */: - return parentKind === 173 /* TypeReference */ || - parentKind === 206 /* TypeAssertionExpression */; - case 93 /* ExtendsKeyword */: - return parentKind === 159 /* TypeParameter */; + return parentKind === 175 /* TypeReference */ || + parentKind === 208 /* TypeAssertionExpression */; + case 94 /* ExtendsKeyword */: + return parentKind === 161 /* TypeParameter */; } } return false; } - /** True if symbol is a type or a module containing at least one type. */ - function symbolCanBeReferencedAtTypeLocation(symbol, seenModules) { - if (seenModules === void 0) { seenModules = new ts.Map(); } - var sym = ts.skipAlias(symbol.exportSymbol || symbol, typeChecker); - return !!(sym.flags & 788968 /* Type */) || - !!(sym.flags & 1536 /* Module */) && - ts.addToSeen(seenModules, ts.getSymbolId(sym)) && - typeChecker.getExportsOfModule(sym).some(function (e) { return symbolCanBeReferencedAtTypeLocation(e, seenModules); }); - } - /** - * Gathers symbols that can be imported from other files, de-duplicating along the way. Symbols can be "duplicates" - * if re-exported from another module, e.g. `export { foo } from "./a"`. That syntax creates a fresh symbol, but - * it’s just an alias to the first, and both have the same name, so we generally want to filter those aliases out, - * if and only if the the first can be imported (it may be excluded due to package.json filtering in - * `codefix.forEachExternalModuleToImportFrom`). - * - * Example. Imagine a chain of node_modules re-exporting one original symbol: - * - * ```js - * node_modules/x/index.js node_modules/y/index.js node_modules/z/index.js - * +-----------------------+ +--------------------------+ +--------------------------+ - * | | | | | | - * | export const foo = 0; | <--- | export { foo } from 'x'; | <--- | export { foo } from 'y'; | - * | | | | | | - * +-----------------------+ +--------------------------+ +--------------------------+ - * ``` - * - * Also imagine three buckets, which we’ll reference soon: - * - * ```md - * | | | | | | - * | **Bucket A** | | **Bucket B** | | **Bucket C** | - * | Symbols to | | Aliases to symbols | | Symbols to return | - * | definitely | | in Buckets A or C | | if nothing better | - * | return | | (don’t return these) | | comes along | - * |__________________| |______________________| |___________________| - * ``` - * - * We _probably_ want to show `foo` from 'x', but not from 'y' or 'z'. However, if 'x' is not in a package.json, it - * will not appear in a `forEachExternalModuleToImportFrom` iteration. Furthermore, the order of iterations is not - * guaranteed, as it is host-dependent. Therefore, when presented with the symbol `foo` from module 'y' alone, we - * may not be sure whether or not it should go in the list. So, we’ll take the following steps: - * - * 1. Resolve alias `foo` from 'y' to the export declaration in 'x', get the symbol there, and see if that symbol is - * already in Bucket A (symbols we already know will be returned). If it is, put `foo` from 'y' in Bucket B - * (symbols that are aliases to symbols in Bucket A). If it’s not, put it in Bucket C. - * 2. Next, imagine we see `foo` from module 'z'. Again, we resolve the alias to the nearest export, which is in 'y'. - * At this point, if that nearest export from 'y' is in _any_ of the three buckets, we know the symbol in 'z' - * should never be returned in the final list, so put it in Bucket B. - * 3. Next, imagine we see `foo` from module 'x', the original. Syntactically, it doesn’t look like a re-export, so - * we can just check Bucket C to see if we put any aliases to the original in there. If they exist, throw them out. - * Put this symbol in Bucket A. - * 4. After we’ve iterated through every symbol of every module, any symbol left in Bucket C means that step 3 didn’t - * occur for that symbol---that is, the original symbol is not in Bucket A, so we should include the alias. Move - * everything from Bucket C to Bucket A. - */ - function getSymbolsFromOtherSourceFileExports(target, host) { - var cached = importSuggestionsCache && importSuggestionsCache.get(sourceFile.fileName, typeChecker, detailsEntryId && host.getProjectVersion ? host.getProjectVersion() : undefined); - if (cached) { - log("getSymbolsFromOtherSourceFileExports: Using cached list"); - return cached; - } - var startTime = ts.timestamp(); - log("getSymbolsFromOtherSourceFileExports: Recomputing list" + (detailsEntryId ? " for details entry" : "")); - var seenResolvedModules = new ts.Map(); - var seenExports = new ts.Map(); - /** Bucket B */ - var aliasesToAlreadyIncludedSymbols = new ts.Map(); - /** Bucket C */ - var aliasesToReturnIfOriginalsAreMissing = new ts.Map(); - /** Bucket A */ - var results = []; - /** Ids present in `results` for faster lookup */ - var resultSymbolIds = new ts.Map(); - ts.codefix.forEachExternalModuleToImportFrom(program, host, sourceFile, !detailsEntryId, /*useAutoImportProvider*/ true, function (moduleSymbol, _, program, isFromPackageJson) { - // Perf -- ignore other modules if this is a request for details - if (detailsEntryId && detailsEntryId.source && ts.stripQuotes(moduleSymbol.name) !== detailsEntryId.source) { - return; - } - var typeChecker = program.getTypeChecker(); - var resolvedModuleSymbol = typeChecker.resolveExternalModuleSymbol(moduleSymbol); - // resolvedModuleSymbol may be a namespace. A namespace may be `export =` by multiple module declarations, but only keep the first one. - if (!ts.addToSeen(seenResolvedModules, ts.getSymbolId(resolvedModuleSymbol))) { + /** Mutates `symbols`, `symbolToOriginInfoMap`, and `symbolToSortTextIdMap` */ + function collectAutoImports(resolveModuleSpecifiers) { + var _a, _b, _c, _d, _e; + if (!shouldOfferImportCompletions()) + return; + ts.Debug.assert(!(detailsEntryId === null || detailsEntryId === void 0 ? void 0 : detailsEntryId.data)); + var start = ts.timestamp(); + var moduleSpecifierCache = (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host); + (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, "collectAutoImports: starting, " + (resolveModuleSpecifiers ? "" : "not ") + "resolving module specifiers"); + if (moduleSpecifierCache) { + (_c = host.log) === null || _c === void 0 ? void 0 : _c.call(host, "collectAutoImports: module specifier cache size: " + moduleSpecifierCache.count()); + } + var lowerCaseTokenText = previousToken && ts.isIdentifier(previousToken) ? previousToken.text.toLowerCase() : ""; + var exportInfo = ts.codefix.getSymbolToExportInfoMap(sourceFile, host, program); + var packageJsonAutoImportProvider = (_d = host.getPackageJsonAutoImportProvider) === null || _d === void 0 ? void 0 : _d.call(host); + var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, host); + exportInfo.forEach(function (info, key) { + var symbolName = key.substring(0, key.indexOf("|")); + if (!detailsEntryId && ts.isStringANonContextualKeyword(symbolName)) return; - } - // Don't add another completion for `export =` of a symbol that's already global. - // So in `declare namespace foo {} declare module "foo" { export = foo; }`, there will just be the global completion for `foo`. - if (resolvedModuleSymbol !== moduleSymbol && ts.every(resolvedModuleSymbol.declarations, ts.isNonGlobalDeclaration)) { - pushSymbol(resolvedModuleSymbol, moduleSymbol, isFromPackageJson, /*skipFilter*/ true); - } - for (var _i = 0, _a = typeChecker.getExportsAndPropertiesOfModule(moduleSymbol); _i < _a.length; _i++) { - var symbol = _a[_i]; - var symbolId = ts.getSymbolId(symbol).toString(); - // `getExportsAndPropertiesOfModule` can include duplicates - if (!ts.addToSeen(seenExports, symbolId)) { - continue; - } - // If this is `export { _break as break };` (a keyword) -- skip this and prefer the keyword completion. - if (ts.some(symbol.declarations, function (d) { return ts.isExportSpecifier(d) && !!d.propertyName && ts.isIdentifierANonContextualKeyword(d.name); })) { - continue; - } - // If `symbol.parent !== moduleSymbol`, this is an `export * from "foo"` re-export. Those don't create new symbols. - var isExportStarFromReExport = typeChecker.getMergedSymbol(symbol.parent) !== resolvedModuleSymbol; - // If `!!d.parent.parent.moduleSpecifier`, this is `export { foo } from "foo"` re-export, which creates a new symbol (thus isn't caught by the first check). - if (isExportStarFromReExport || ts.some(symbol.declarations, function (d) { return ts.isExportSpecifier(d) && !d.propertyName && !!d.parent.parent.moduleSpecifier; })) { - // Walk the export chain back one module (step 1 or 2 in diagrammed example). - // Or, in the case of `export * from "foo"`, `symbol` already points to the original export, so just use that. - var nearestExportSymbol = isExportStarFromReExport ? symbol : getNearestExportSymbol(symbol); - if (!nearestExportSymbol) - continue; - var nearestExportSymbolId = ts.getSymbolId(nearestExportSymbol).toString(); - var symbolHasBeenSeen = resultSymbolIds.has(nearestExportSymbolId) || aliasesToAlreadyIncludedSymbols.has(nearestExportSymbolId); - if (!symbolHasBeenSeen) { - aliasesToReturnIfOriginalsAreMissing.set(nearestExportSymbolId, { alias: symbol, moduleSymbol: moduleSymbol, isFromPackageJson: isFromPackageJson }); - aliasesToAlreadyIncludedSymbols.set(symbolId, true); - } - else { - // Perf - we know this symbol is an alias to one that’s already covered in `symbols`, so store it here - // in case another symbol re-exports this one; that way we can short-circuit as soon as we see this symbol id. - ts.addToSeen(aliasesToAlreadyIncludedSymbols, symbolId); - } - } - else { - // This is not a re-export, so see if we have any aliases pending and remove them (step 3 in diagrammed example) - aliasesToReturnIfOriginalsAreMissing.delete(symbolId); - pushSymbol(symbol, moduleSymbol, isFromPackageJson, /*skipFilter*/ false); - } + var isCompletionDetailsMatch = detailsEntryId && ts.some(info, function (i) { return detailsEntryId.source === ts.stripQuotes(i.moduleSymbol.name); }); + if (isCompletionDetailsMatch || isNameMatch(symbolName)) { + // If we don't need to resolve module specifiers, we can use any re-export that is importable at all + // (We need to ensure that at least one is importable to show a completion.) + var _a = resolveModuleSpecifiers + ? ts.codefix.getModuleSpecifierForBestExportInfo(info, sourceFile, program, host, preferences) + : { moduleSpecifier: undefined, exportInfo: ts.find(info, isImportableExportInfo) }, moduleSpecifier = _a.moduleSpecifier, exportInfo_1 = _a.exportInfo; + if (!exportInfo_1) + return; + var moduleFile = ts.tryCast(exportInfo_1.moduleSymbol.valueDeclaration, ts.isSourceFile); + var isDefaultExport = exportInfo_1.exportKind === 1 /* Default */; + var symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(exportInfo_1.symbol) || exportInfo_1.symbol; + pushAutoImportSymbol(symbol, { + kind: resolveModuleSpecifiers ? 32 /* ResolvedExport */ : 4 /* Export */, + moduleSpecifier: moduleSpecifier, + symbolName: symbolName, + exportName: exportInfo_1.exportKind === 2 /* ExportEquals */ ? "export=" /* ExportEquals */ : exportInfo_1.symbol.name, + fileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName, + isDefaultExport: isDefaultExport, + moduleSymbol: exportInfo_1.moduleSymbol, + isFromPackageJson: exportInfo_1.isFromPackageJson, + }); } }); - // By this point, any potential duplicates that were actually duplicates have been - // removed, so the rest need to be added. (Step 4 in diagrammed example) - aliasesToReturnIfOriginalsAreMissing.forEach(function (_a) { - var alias = _a.alias, moduleSymbol = _a.moduleSymbol, isFromPackageJson = _a.isFromPackageJson; - return pushSymbol(alias, moduleSymbol, isFromPackageJson, /*skipFilter*/ false); - }); - log("getSymbolsFromOtherSourceFileExports: " + (ts.timestamp() - startTime)); - return results; - function pushSymbol(symbol, moduleSymbol, isFromPackageJson, skipFilter) { - var isDefaultExport = symbol.escapedName === "default" /* Default */; - if (isDefaultExport) { - symbol = ts.getLocalSymbolForExportDefault(symbol) || symbol; + (_e = host.log) === null || _e === void 0 ? void 0 : _e.call(host, "collectAutoImports: done in " + (ts.timestamp() - start) + " ms"); + function isNameMatch(symbolName) { + var lowerCaseSymbolName = symbolName.toLowerCase(); + if (resolveModuleSpecifiers && lowerCaseTokenText) { + // Use a more restrictive filter if resolving module specifiers since resolving module specifiers is expensive. + return lowerCaseTokenText[0] === lowerCaseSymbolName[0] && stringContainsCharactersInOrder(lowerCaseSymbolName, lowerCaseTokenText); } - if (typeChecker.isUndefinedSymbol(symbol)) { - return; + return stringContainsCharactersInOrder(lowerCaseSymbolName, lowerCaseTokenText); + } + function isImportableExportInfo(info) { + var moduleFile = ts.tryCast(info.moduleSymbol.valueDeclaration, ts.isSourceFile); + if (!moduleFile) { + return packageJsonFilter + ? packageJsonFilter.allowsImportingAmbientModule(info.moduleSymbol, getModuleSpecifierResolutionHost(info.isFromPackageJson)) + : true; } - ts.addToSeen(resultSymbolIds, ts.getSymbolId(symbol)); - var origin = { kind: 4 /* Export */, moduleSymbol: moduleSymbol, isDefaultExport: isDefaultExport, isFromPackageJson: isFromPackageJson }; - results.push({ - symbol: symbol, - symbolName: ts.getNameForExportedSymbol(symbol, target), - origin: origin, - skipFilter: skipFilter, - }); + return ts.isImportableFile(info.isFromPackageJson ? packageJsonAutoImportProvider : program, sourceFile, moduleFile, packageJsonFilter, getModuleSpecifierResolutionHost(info.isFromPackageJson), moduleSpecifierCache); } } - function getNearestExportSymbol(fromSymbol) { - return findAlias(typeChecker, fromSymbol, function (alias) { - return ts.some(alias.declarations, function (d) { return ts.isExportSpecifier(d) || !!d.localSymbol; }); - }); + function pushAutoImportSymbol(symbol, origin) { + var symbolId = ts.getSymbolId(symbol); + if (symbolToSortTextIdMap[symbolId] === SortTextId.GlobalsOrKeywords) { + // If an auto-importable symbol is available as a global, don't add the auto import + return; + } + symbolToOriginInfoMap[symbols.length] = origin; + symbolToSortTextIdMap[symbolId] = importCompletionNode ? SortTextId.LocationPriority : SortTextId.AutoImportSuggestions; + symbols.push(symbol); } /** * True if you could remove some characters in `a` to get `b`. @@ -121170,7 +125587,8 @@ var ts; return true; } var characterIndex = 0; - for (var strIndex = 0; strIndex < str.length; strIndex++) { + var len = str.length; + for (var strIndex = 0; strIndex < len; strIndex++) { if (str.charCodeAt(strIndex) === characters.charCodeAt(characterIndex)) { characterIndex++; if (characterIndex === characters.length) { @@ -121206,7 +125624,7 @@ var ts; return true; } if (contextToken.kind === 31 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 275 /* JsxOpeningElement */) { + if (contextToken.parent.kind === 277 /* JsxOpeningElement */) { // Two possibilities: // 1.
/**/ // - contextToken: GreaterThanToken (before cursor) @@ -121216,54 +125634,56 @@ var ts; // - contextToken: GreaterThanToken (before cursor) // - location: GreaterThanToken (after cursor) // - same parent (JSXOpeningElement) - return location.parent.kind !== 275 /* JsxOpeningElement */; + return location.parent.kind !== 277 /* JsxOpeningElement */; } - if (contextToken.parent.kind === 276 /* JsxClosingElement */ || contextToken.parent.kind === 274 /* JsxSelfClosingElement */) { - return !!contextToken.parent.parent && contextToken.parent.parent.kind === 273 /* JsxElement */; + if (contextToken.parent.kind === 278 /* JsxClosingElement */ || contextToken.parent.kind === 276 /* JsxSelfClosingElement */) { + return !!contextToken.parent.parent && contextToken.parent.parent.kind === 275 /* JsxElement */; } } return false; } - function isNewIdentifierDefinitionLocation(previousToken) { - if (previousToken) { - var containingNodeKind = previousToken.parent.kind; + function isNewIdentifierDefinitionLocation() { + if (contextToken) { + var containingNodeKind = contextToken.parent.kind; // Previous token may have been a keyword that was converted to an identifier. - switch (keywordForNode(previousToken)) { + switch (keywordForNode(contextToken)) { case 27 /* CommaToken */: - return containingNodeKind === 203 /* CallExpression */ // func( a, | - || containingNodeKind === 166 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 204 /* NewExpression */ // new C(a, | - || containingNodeKind === 199 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 216 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 174 /* FunctionType */; // var x: (s: string, list| + return containingNodeKind === 205 /* CallExpression */ // func( a, | + || containingNodeKind === 168 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 206 /* NewExpression */ // new C(a, | + || containingNodeKind === 201 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 218 /* BinaryExpression */ // const x = (a, | + || containingNodeKind === 176 /* FunctionType */ // var x: (s: string, list| + || containingNodeKind === 202 /* ObjectLiteralExpression */; // const obj = { x, | case 20 /* OpenParenToken */: - return containingNodeKind === 203 /* CallExpression */ // func( | - || containingNodeKind === 166 /* Constructor */ // constructor( | - || containingNodeKind === 204 /* NewExpression */ // new C(a| - || containingNodeKind === 207 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 186 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + return containingNodeKind === 205 /* CallExpression */ // func( | + || containingNodeKind === 168 /* Constructor */ // constructor( | + || containingNodeKind === 206 /* NewExpression */ // new C(a| + || containingNodeKind === 209 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 188 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case 22 /* OpenBracketToken */: - return containingNodeKind === 199 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 171 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 158 /* ComputedPropertyName */; // [ | /* this can become an index signature */ - case 139 /* ModuleKeyword */: // module | - case 140 /* NamespaceKeyword */: // namespace | + return containingNodeKind === 201 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 173 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 160 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + case 140 /* ModuleKeyword */: // module | + case 141 /* NamespaceKeyword */: // namespace | return true; case 24 /* DotToken */: - return containingNodeKind === 256 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 258 /* ModuleDeclaration */; // module A.| case 18 /* OpenBraceToken */: - return containingNodeKind === 252 /* ClassDeclaration */; // class A{ | - case 62 /* EqualsToken */: - return containingNodeKind === 249 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 216 /* BinaryExpression */; // x = a| + return containingNodeKind === 254 /* ClassDeclaration */ // class A { | + || containingNodeKind === 202 /* ObjectLiteralExpression */; // const obj = { | + case 63 /* EqualsToken */: + return containingNodeKind === 251 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 218 /* BinaryExpression */; // x = a| case 15 /* TemplateHead */: - return containingNodeKind === 218 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 220 /* TemplateExpression */; // `aa ${| case 16 /* TemplateMiddle */: - return containingNodeKind === 228 /* TemplateSpan */; // `aa ${10} dd ${| - case 122 /* PublicKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - return containingNodeKind === 163 /* PropertyDeclaration */; // class A{ public | + return containingNodeKind === 230 /* TemplateSpan */; // `aa ${10} dd ${| + case 123 /* PublicKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + return containingNodeKind === 165 /* PropertyDeclaration */; // class A{ public | } } return false; @@ -121276,6 +125696,25 @@ var ts; return (ts.isRegularExpressionLiteral(contextToken) || ts.isStringTextContainingNode(contextToken)) && (ts.rangeContainsPositionExclusive(ts.createTextRangeFromSpan(ts.createTextSpanFromNode(contextToken)), position) || position === contextToken.end && (!!contextToken.isUnterminated || ts.isRegularExpressionLiteral(contextToken))); } + function tryGetObjectTypeLiteralInTypeArgumentCompletionSymbols() { + var typeLiteralNode = tryGetTypeLiteralNode(contextToken); + if (!typeLiteralNode) + return 0 /* Continue */; + var intersectionTypeNode = ts.isIntersectionTypeNode(typeLiteralNode.parent) ? typeLiteralNode.parent : undefined; + var containerTypeNode = intersectionTypeNode || typeLiteralNode; + var containerExpectedType = getConstraintOfTypeArgumentProperty(containerTypeNode, typeChecker); + if (!containerExpectedType) + return 0 /* 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.filter(members, function (s) { return !existingMemberEscapedNames.has(s.escapedName); }); + completionKind = 0 /* ObjectPropertyDeclaration */; + isNewIdentifierLocation = true; + return 1 /* Success */; + } /** * Aggregates relevant symbols for completion in object literals and object binding patterns. * Relevant symbols are stored in the captured 'symbols' variable. @@ -121290,7 +125729,7 @@ var ts; completionKind = 0 /* ObjectPropertyDeclaration */; var typeMembers; var existingMembers; - if (objectLikeContainer.kind === 200 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 202 /* ObjectLiteralExpression */) { var instantiatedType = tryGetObjectLiteralContextualType(objectLikeContainer, typeChecker); // Check completions for Object property value shorthand if (instantiatedType === undefined) { @@ -121315,7 +125754,7 @@ var ts; } } else { - ts.Debug.assert(objectLikeContainer.kind === 196 /* ObjectBindingPattern */); + ts.Debug.assert(objectLikeContainer.kind === 198 /* ObjectBindingPattern */); // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -121326,12 +125765,12 @@ 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.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 239 /* ForOfStatement */; - if (!canGetType && rootDeclaration.kind === 160 /* Parameter */) { + var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 241 /* ForOfStatement */; + if (!canGetType && rootDeclaration.kind === 162 /* Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 165 /* MethodDeclaration */ || rootDeclaration.parent.kind === 168 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 167 /* MethodDeclaration */ || rootDeclaration.parent.kind === 170 /* SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -121378,9 +125817,9 @@ var ts; if (!namedImportsOrExports) return 0 /* Continue */; // try to show exported member for imported/re-exported module - var moduleSpecifier = (namedImportsOrExports.kind === 264 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; + var moduleSpecifier = (namedImportsOrExports.kind === 266 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; if (!moduleSpecifier) - return namedImportsOrExports.kind === 264 /* NamedImports */ ? 2 /* Fail */ : 0 /* Continue */; + return namedImportsOrExports.kind === 266 /* NamedImports */ ? 2 /* Fail */ : 0 /* Continue */; var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); // TODO: GH#18217 if (!moduleSpecifierSymbol) return 2 /* Fail */; @@ -121415,7 +125854,7 @@ var ts; var _a, _b; symbols.push(symbol); if ((_b = (_a = localsContainer.symbol) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.has(name)) { - symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.OptionalMember; + symbolToSortTextIdMap[ts.getSymbolId(symbol)] = SortTextId.OptionalMember; } }); return 1 /* Success */; @@ -121440,7 +125879,7 @@ var ts; var classElement = contextToken.kind === 26 /* SemicolonToken */ ? contextToken.parent.parent : contextToken.parent; var classElementModifierFlags = ts.isClassElement(classElement) ? ts.getEffectiveModifierFlags(classElement) : 0 /* None */; // If this is context token is not something we are editing now, consider if this would lead to be modifier - if (contextToken.kind === 78 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { + if (contextToken.kind === 79 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { switch (contextToken.getText()) { case "private": classElementModifierFlags = classElementModifierFlags | 8 /* Private */; @@ -121448,12 +125887,16 @@ var ts; case "static": classElementModifierFlags = classElementModifierFlags | 32 /* Static */; break; + case "override": + classElementModifierFlags = classElementModifierFlags | 16384 /* Override */; + break; } } // No member list for private methods if (!(classElementModifierFlags & 8 /* Private */)) { // List of property symbols of base type that are not private and already implemented - var baseSymbols = ts.flatMap(ts.getAllSuperTypeNodes(decl), function (baseTypeNode) { + var baseTypeNodes = ts.isClassLike(decl) && classElementModifierFlags & 16384 /* 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 */ ? (type === null || type === void 0 ? void 0 : type.symbol) && typeChecker.getPropertiesOfType(typeChecker.getTypeOfSymbolAtLocation(type.symbol, decl)) : @@ -121479,7 +125922,7 @@ var ts; break; case 41 /* AsteriskToken */: return ts.isMethodDeclaration(parent) ? ts.tryCast(parent.parent, ts.isObjectLiteralExpression) : undefined; - case 78 /* Identifier */: + case 79 /* Identifier */: return contextToken.text === "async" && ts.isShorthandPropertyAssignment(contextToken.parent) ? contextToken.parent.parent : undefined; } @@ -121532,12 +125975,12 @@ var ts; case 31 /* GreaterThanToken */: // End of a type argument list case 30 /* LessThanSlashToken */: case 43 /* SlashToken */: - case 78 /* Identifier */: - case 201 /* PropertyAccessExpression */: - case 281 /* JsxAttributes */: - case 280 /* JsxAttribute */: - case 282 /* JsxSpreadAttribute */: - if (parent && (parent.kind === 274 /* JsxSelfClosingElement */ || parent.kind === 275 /* JsxOpeningElement */)) { + case 79 /* Identifier */: + case 203 /* PropertyAccessExpression */: + case 283 /* JsxAttributes */: + case 282 /* JsxAttribute */: + case 284 /* JsxSpreadAttribute */: + if (parent && (parent.kind === 276 /* JsxSelfClosingElement */ || parent.kind === 277 /* JsxOpeningElement */)) { if (contextToken.kind === 31 /* GreaterThanToken */) { var precedingToken = ts.findPrecedingToken(contextToken.pos, sourceFile, /*startNode*/ undefined); if (!parent.typeArguments || (precedingToken && precedingToken.kind === 43 /* SlashToken */)) @@ -121545,7 +125988,7 @@ var ts; } return parent; } - else if (parent.kind === 280 /* JsxAttribute */) { + else if (parent.kind === 282 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -121557,7 +126000,7 @@ var ts; // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement case 10 /* StringLiteral */: - if (parent && ((parent.kind === 280 /* JsxAttribute */) || (parent.kind === 282 /* JsxSpreadAttribute */))) { + if (parent && ((parent.kind === 282 /* JsxAttribute */) || (parent.kind === 284 /* JsxSpreadAttribute */))) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -121567,8 +126010,8 @@ var ts; break; case 19 /* CloseBraceToken */: if (parent && - parent.kind === 283 /* JsxExpression */ && - parent.parent && parent.parent.kind === 280 /* JsxAttribute */) { + parent.kind === 285 /* JsxExpression */ && + parent.parent && parent.parent.kind === 282 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -121576,7 +126019,7 @@ var ts; // each JsxAttribute can have initializer as JsxExpression return parent.parent.parent.parent; } - if (parent && parent.kind === 282 /* JsxSpreadAttribute */) { + if (parent && parent.kind === 284 /* JsxSpreadAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -121596,67 +126039,67 @@ var ts; var containingNodeKind = parent.kind; switch (contextToken.kind) { case 27 /* CommaToken */: - return containingNodeKind === 249 /* VariableDeclaration */ || + return containingNodeKind === 251 /* VariableDeclaration */ || isVariableDeclarationListButNotTypeArgument(contextToken) || - containingNodeKind === 232 /* VariableStatement */ || - containingNodeKind === 255 /* EnumDeclaration */ || // enum a { foo, | + containingNodeKind === 234 /* VariableStatement */ || + containingNodeKind === 257 /* EnumDeclaration */ || // enum a { foo, | isFunctionLikeButNotConstructor(containingNodeKind) || - containingNodeKind === 253 /* InterfaceDeclaration */ || // interface A= contextToken.pos); case 24 /* DotToken */: - return containingNodeKind === 197 /* ArrayBindingPattern */; // var [.| + return containingNodeKind === 199 /* ArrayBindingPattern */; // var [.| case 58 /* ColonToken */: - return containingNodeKind === 198 /* BindingElement */; // var {x :html| + return containingNodeKind === 200 /* BindingElement */; // var {x :html| case 22 /* OpenBracketToken */: - return containingNodeKind === 197 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 199 /* ArrayBindingPattern */; // var [x| case 20 /* OpenParenToken */: - return containingNodeKind === 287 /* CatchClause */ || + return containingNodeKind === 289 /* CatchClause */ || isFunctionLikeButNotConstructor(containingNodeKind); case 18 /* OpenBraceToken */: - return containingNodeKind === 255 /* EnumDeclaration */; // enum a { | + return containingNodeKind === 257 /* EnumDeclaration */; // enum a { | case 29 /* LessThanToken */: - return containingNodeKind === 252 /* ClassDeclaration */ || // class A< | - containingNodeKind === 221 /* ClassExpression */ || // var C = class D< | - containingNodeKind === 253 /* InterfaceDeclaration */ || // interface A< | - containingNodeKind === 254 /* TypeAliasDeclaration */ || // type List< | + return containingNodeKind === 254 /* ClassDeclaration */ || // class A< | + containingNodeKind === 223 /* ClassExpression */ || // var C = class D< | + containingNodeKind === 255 /* InterfaceDeclaration */ || // interface A< | + containingNodeKind === 256 /* TypeAliasDeclaration */ || // type List< | ts.isFunctionLikeKind(containingNodeKind); - case 123 /* StaticKeyword */: - return containingNodeKind === 163 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); + case 124 /* StaticKeyword */: + return containingNodeKind === 165 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); case 25 /* DotDotDotToken */: - return containingNodeKind === 160 /* Parameter */ || - (!!parent.parent && parent.parent.kind === 197 /* ArrayBindingPattern */); // var [...z| - case 122 /* PublicKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - return containingNodeKind === 160 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); - case 126 /* AsKeyword */: - return containingNodeKind === 265 /* ImportSpecifier */ || - containingNodeKind === 270 /* ExportSpecifier */ || - containingNodeKind === 263 /* NamespaceImport */; - case 134 /* GetKeyword */: - case 146 /* SetKeyword */: + return containingNodeKind === 162 /* Parameter */ || + (!!parent.parent && parent.parent.kind === 199 /* ArrayBindingPattern */); // var [...z| + case 123 /* PublicKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + return containingNodeKind === 162 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); + case 127 /* AsKeyword */: + return containingNodeKind === 267 /* ImportSpecifier */ || + containingNodeKind === 272 /* ExportSpecifier */ || + containingNodeKind === 265 /* NamespaceImport */; + case 135 /* GetKeyword */: + case 147 /* SetKeyword */: return !isFromObjectTypeDeclaration(contextToken); - case 83 /* ClassKeyword */: - case 91 /* EnumKeyword */: - case 117 /* InterfaceKeyword */: - case 97 /* FunctionKeyword */: - case 112 /* VarKeyword */: - case 99 /* ImportKeyword */: - case 118 /* LetKeyword */: - case 84 /* ConstKeyword */: - case 135 /* InferKeyword */: - case 149 /* TypeKeyword */: // type htm| + 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 136 /* InferKeyword */: + case 150 /* TypeKeyword */: // type htm| return true; case 41 /* AsteriskToken */: return ts.isFunctionLike(contextToken.parent) && !ts.isMethodDeclaration(contextToken.parent); } - // If the previous token is keyword correspoding to class member completion keyword + // If the previous token is keyword corresponding to class member completion keyword // there will be completion available here if (isClassMemberCompletionKeyword(keywordForNode(contextToken)) && isFromObjectTypeDeclaration(contextToken)) { return false; @@ -121674,23 +126117,48 @@ var ts; } // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(contextToken)) { - case 125 /* AbstractKeyword */: - case 83 /* ClassKeyword */: - case 84 /* ConstKeyword */: - case 133 /* DeclareKeyword */: - case 91 /* EnumKeyword */: - case 97 /* FunctionKeyword */: - case 117 /* InterfaceKeyword */: - case 118 /* LetKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 122 /* PublicKeyword */: - case 123 /* StaticKeyword */: - case 112 /* VarKeyword */: + case 126 /* AbstractKeyword */: + case 84 /* ClassKeyword */: + case 85 /* ConstKeyword */: + case 134 /* 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 */: return true; - case 129 /* AsyncKeyword */: + case 130 /* AsyncKeyword */: return ts.isPropertyDeclaration(contextToken.parent); } + // If we are inside a class declaration, and `constructor` is totally not present, + // but we request a completion manually at a whitespace... + var ancestorClassLike = ts.findAncestor(contextToken.parent, ts.isClassLike); + if (ancestorClassLike && contextToken === previousToken && isPreviousPropertyDeclarationTerminated(contextToken, position)) { + return false; // Don't block completions. + } + var ancestorPropertyDeclaraion = ts.getAncestor(contextToken.parent, 165 /* PropertyDeclaration */); + // If we are inside a class declaration and typing `constructor` after property declaration... + if (ancestorPropertyDeclaraion + && contextToken !== previousToken + && ts.isClassLike(previousToken.parent.parent) + // And the cursor is at the token... + && position <= previousToken.end) { + // If we are sure that the previous property declaration is terminated according to newline or semicolon... + if (isPreviousPropertyDeclarationTerminated(contextToken, previousToken.end)) { + return false; // Don't block completions. + } + else if (contextToken.kind !== 63 /* 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) + || ts.hasType(ancestorPropertyDeclaraion))) { + return true; + } + } return ts.isDeclarationName(contextToken) && !ts.isShorthandPropertyAssignment(contextToken.parent) && !ts.isJsxAttribute(contextToken.parent) @@ -121698,8 +126166,13 @@ var ts; // If `contextToken !== previousToken`, this is `class C ex/**/`. && !(ts.isClassLike(contextToken.parent) && (contextToken !== previousToken || position > previousToken.end)); } + function isPreviousPropertyDeclarationTerminated(contextToken, position) { + return contextToken.kind !== 63 /* EqualsToken */ && + (contextToken.kind === 26 /* SemicolonToken */ + || !ts.positionsAreOnSameLine(contextToken.end, position, sourceFile)); + } function isFunctionLikeButNotConstructor(kind) { - return ts.isFunctionLikeKind(kind) && kind !== 166 /* Constructor */; + return ts.isFunctionLikeKind(kind) && kind !== 168 /* Constructor */; } function isDotOfNumericLiteral(contextToken) { if (contextToken.kind === 8 /* NumericLiteral */) { @@ -121709,7 +126182,7 @@ var ts; return false; } function isVariableDeclarationListButNotTypeArgument(node) { - return node.parent.kind === 250 /* VariableDeclarationList */ + return node.parent.kind === 252 /* VariableDeclarationList */ && !ts.isPossiblyTypeArgumentPosition(node, sourceFile, typeChecker); } /** @@ -121727,13 +126200,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 !== 288 /* PropertyAssignment */ && - m.kind !== 289 /* ShorthandPropertyAssignment */ && - m.kind !== 198 /* BindingElement */ && - m.kind !== 165 /* MethodDeclaration */ && - m.kind !== 167 /* GetAccessor */ && - m.kind !== 168 /* SetAccessor */ && - m.kind !== 290 /* SpreadAssignment */) { + if (m.kind !== 290 /* PropertyAssignment */ && + m.kind !== 291 /* ShorthandPropertyAssignment */ && + m.kind !== 200 /* BindingElement */ && + m.kind !== 167 /* MethodDeclaration */ && + m.kind !== 169 /* GetAccessor */ && + m.kind !== 170 /* SetAccessor */ && + m.kind !== 292 /* SpreadAssignment */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -121746,7 +126219,7 @@ var ts; } else if (ts.isBindingElement(m) && m.propertyName) { // include only identifiers in completion list - if (m.propertyName.kind === 78 /* Identifier */) { + if (m.propertyName.kind === 79 /* Identifier */) { existingName = m.propertyName.escapedText; } } @@ -121779,8 +126252,10 @@ var ts; // Set SortText to OptionalMember if it is an optional member function setSortTextToOptionalMember() { symbols.forEach(function (m) { + var _a; if (m.flags & 16777216 /* Optional */) { - symbolToSortTextMap[ts.getSymbolId(m)] = symbolToSortTextMap[ts.getSymbolId(m)] || SortText.OptionalMember; + var symbolId = ts.getSymbolId(m); + symbolToSortTextIdMap[symbolId] = (_a = symbolToSortTextIdMap[symbolId]) !== null && _a !== void 0 ? _a : SortTextId.OptionalMember; } }); } @@ -121792,7 +126267,7 @@ var ts; for (var _i = 0, contextualMemberSymbols_1 = contextualMemberSymbols; _i < contextualMemberSymbols_1.length; _i++) { var contextualMemberSymbol = contextualMemberSymbols_1[_i]; if (membersDeclaredBySpreadAssignment.has(contextualMemberSymbol.name)) { - symbolToSortTextMap[ts.getSymbolId(contextualMemberSymbol)] = SortText.MemberDeclaredBySpreadAssignment; + symbolToSortTextIdMap[ts.getSymbolId(contextualMemberSymbol)] = SortTextId.MemberDeclaredBySpreadAssignment; } } } @@ -121806,10 +126281,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 !== 163 /* PropertyDeclaration */ && - m.kind !== 165 /* MethodDeclaration */ && - m.kind !== 167 /* GetAccessor */ && - m.kind !== 168 /* SetAccessor */) { + if (m.kind !== 165 /* PropertyDeclaration */ && + m.kind !== 167 /* MethodDeclaration */ && + m.kind !== 169 /* GetAccessor */ && + m.kind !== 170 /* SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -121833,7 +126308,7 @@ var ts; return !existingMemberNames.has(propertySymbol.escapedName) && !!propertySymbol.declarations && !(ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 8 /* Private */) && - !(propertySymbol.valueDeclaration && ts.isPrivateIdentifierPropertyDeclaration(propertySymbol.valueDeclaration)); + !(propertySymbol.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(propertySymbol.valueDeclaration)); }); } /** @@ -121851,7 +126326,7 @@ var ts; if (isCurrentlyEditingNode(attr)) { continue; } - if (attr.kind === 280 /* JsxAttribute */) { + if (attr.kind === 282 /* JsxAttribute */) { seenNames.add(attr.name.escapedText); } else if (ts.isJsxSpreadAttribute(attr)) { @@ -121866,8 +126341,35 @@ var ts; return node.getStart(sourceFile) <= position && position <= node.getEnd(); } } + function getAutoImportSymbolFromCompletionEntryData(name, data, program, host) { + var containingProgram = data.isPackageJsonImport ? host.getPackageJsonAutoImportProvider() : program; + var checker = containingProgram.getTypeChecker(); + var moduleSymbol = data.ambientModuleName ? checker.tryFindAmbientModule(data.ambientModuleName) : + data.fileName ? checker.getMergedSymbol(ts.Debug.checkDefined(containingProgram.getSourceFile(data.fileName)).symbol) : + undefined; + if (!moduleSymbol) + return undefined; + var symbol = data.exportName === "export=" /* ExportEquals */ + ? checker.resolveExternalModuleSymbol(moduleSymbol) + : checker.tryGetMemberInModuleExportsAndProperties(data.exportName, moduleSymbol); + if (!symbol) + return undefined; + var isDefaultExport = data.exportName === "default" /* Default */; + symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(symbol) || symbol; + return { + symbol: symbol, + origin: { + kind: data.moduleSpecifier ? 32 /* ResolvedExport */ : 4 /* Export */, + moduleSymbol: moduleSymbol, + symbolName: name, + isDefaultExport: isDefaultExport, + exportName: data.exportName, + fileName: data.fileName, + } + }; + } function getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind, jsxIdentifierExpected) { - var name = originIsExport(origin) ? ts.getNameForExportedSymbol(symbol, target) : symbol.name; + var name = originIncludesSymbolName(origin) ? origin.symbolName : symbol.name; 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) @@ -121877,7 +126379,7 @@ var ts; return undefined; } var validNameResult = { name: name, needsConvertPropertyAccess: false }; - if (ts.isIdentifierText(name, target, jsxIdentifierExpected ? 1 /* JSX */ : 0 /* Standard */) || symbol.valueDeclaration && ts.isPrivateIdentifierPropertyDeclaration(symbol.valueDeclaration)) { + if (ts.isIdentifierText(name, target, jsxIdentifierExpected ? 1 /* JSX */ : 0 /* Standard */) || symbol.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(symbol.valueDeclaration)) { return validNameResult; } switch (kind) { @@ -121901,7 +126403,7 @@ var ts; var _keywordCompletions = []; var allKeywordsCompletions = ts.memoize(function () { var res = []; - for (var i = 80 /* FirstKeyword */; i <= 156 /* LastKeyword */; i++) { + for (var i = 81 /* FirstKeyword */; i <= 158 /* LastKeyword */; i++) { res.push({ name: ts.tokenToString(i), kind: "keyword" /* keyword */, @@ -121927,11 +126429,11 @@ var ts; return false; case 1 /* All */: return isFunctionLikeBodyKeyword(kind) - || kind === 133 /* DeclareKeyword */ - || kind === 139 /* ModuleKeyword */ - || kind === 149 /* TypeKeyword */ - || kind === 140 /* NamespaceKeyword */ - || ts.isTypeKeyword(kind) && kind !== 150 /* UndefinedKeyword */; + || kind === 134 /* DeclareKeyword */ + || kind === 140 /* ModuleKeyword */ + || kind === 150 /* TypeKeyword */ + || kind === 141 /* NamespaceKeyword */ + || ts.isTypeKeyword(kind) && kind !== 151 /* UndefinedKeyword */; case 5 /* FunctionLikeBodyKeywords */: return isFunctionLikeBodyKeyword(kind); case 2 /* ClassElementKeywords */: @@ -121941,7 +126443,7 @@ var ts; case 4 /* ConstructorParameterKeywords */: return ts.isParameterPropertyModifier(kind); case 6 /* TypeAssertionKeywords */: - return ts.isTypeKeyword(kind) || kind === 84 /* ConstKeyword */; + return ts.isTypeKeyword(kind) || kind === 85 /* ConstKeyword */; case 7 /* TypeKeywords */: return ts.isTypeKeyword(kind); default: @@ -121951,57 +126453,59 @@ var ts; } function isTypeScriptOnlyKeyword(kind) { switch (kind) { - case 125 /* AbstractKeyword */: - case 128 /* AnyKeyword */: - case 155 /* BigIntKeyword */: - case 131 /* BooleanKeyword */: - case 133 /* DeclareKeyword */: - case 91 /* EnumKeyword */: - case 154 /* GlobalKeyword */: - case 116 /* ImplementsKeyword */: - case 135 /* InferKeyword */: - case 117 /* InterfaceKeyword */: - case 137 /* IsKeyword */: - case 138 /* KeyOfKeyword */: - case 139 /* ModuleKeyword */: - case 140 /* NamespaceKeyword */: - case 141 /* NeverKeyword */: - case 144 /* NumberKeyword */: - case 145 /* ObjectKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 122 /* PublicKeyword */: - case 142 /* ReadonlyKeyword */: - case 147 /* StringKeyword */: - case 148 /* SymbolKeyword */: - case 149 /* TypeKeyword */: - case 151 /* UniqueKeyword */: - case 152 /* UnknownKeyword */: + case 126 /* AbstractKeyword */: + case 129 /* AnyKeyword */: + case 156 /* BigIntKeyword */: + case 132 /* BooleanKeyword */: + case 134 /* DeclareKeyword */: + case 92 /* EnumKeyword */: + case 155 /* GlobalKeyword */: + case 117 /* ImplementsKeyword */: + case 136 /* InferKeyword */: + case 118 /* InterfaceKeyword */: + case 138 /* IsKeyword */: + case 139 /* KeyOfKeyword */: + case 140 /* ModuleKeyword */: + case 141 /* NamespaceKeyword */: + case 142 /* NeverKeyword */: + case 145 /* NumberKeyword */: + case 146 /* ObjectKeyword */: + case 157 /* OverrideKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + case 123 /* PublicKeyword */: + case 143 /* ReadonlyKeyword */: + case 148 /* StringKeyword */: + case 149 /* SymbolKeyword */: + case 150 /* TypeKeyword */: + case 152 /* UniqueKeyword */: + case 153 /* UnknownKeyword */: return true; default: return false; } } function isInterfaceOrTypeLiteralCompletionKeyword(kind) { - return kind === 142 /* ReadonlyKeyword */; + return kind === 143 /* ReadonlyKeyword */; } function isClassMemberCompletionKeyword(kind) { switch (kind) { - case 125 /* AbstractKeyword */: - case 132 /* ConstructorKeyword */: - case 134 /* GetKeyword */: - case 146 /* SetKeyword */: - case 129 /* AsyncKeyword */: - case 133 /* DeclareKeyword */: + case 126 /* AbstractKeyword */: + case 133 /* ConstructorKeyword */: + case 135 /* GetKeyword */: + case 147 /* SetKeyword */: + case 130 /* AsyncKeyword */: + case 134 /* DeclareKeyword */: + case 157 /* OverrideKeyword */: return true; default: return ts.isClassMemberModifier(kind); } } function isFunctionLikeBodyKeyword(kind) { - return kind === 129 /* AsyncKeyword */ - || kind === 130 /* AwaitKeyword */ - || kind === 126 /* AsKeyword */ + return kind === 130 /* AsyncKeyword */ + || kind === 131 /* AwaitKeyword */ + || kind === 127 /* AsKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind); } function keywordForNode(node) { @@ -122053,7 +126557,7 @@ var ts; function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location, position) { // class c { method() { } | method2() { } } switch (location.kind) { - case 334 /* SyntaxList */: + case 342 /* SyntaxList */: return ts.tryCast(location.parent, ts.isObjectTypeDeclaration); case 1 /* EndOfFileToken */: var cls = ts.tryCast(ts.lastOrUndefined(ts.cast(location.parent, ts.isSourceFile).statements), ts.isObjectTypeDeclaration); @@ -122061,7 +126565,7 @@ var ts; return cls; } break; - case 78 /* Identifier */: { + case 79 /* Identifier */: { // class c { public prop = c| } if (ts.isPropertyDeclaration(location.parent) && location.parent.initializer === location) { return undefined; @@ -122074,8 +126578,14 @@ var ts; } if (!contextToken) return undefined; + // class C { blah; constructor/**/ } and so on + if (location.kind === 133 /* 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 62 /* EqualsToken */: // class c { public prop = | /* global completions */ } + case 63 /* EqualsToken */: // class c { public prop = | /* global completions */ } return undefined; case 26 /* SemicolonToken */: // class c {getValue(): number; | } case 19 /* CloseBraceToken */: // class c { method() { } | } @@ -122099,6 +126609,44 @@ var ts; ? contextToken.parent.parent : undefined; } } + function tryGetTypeLiteralNode(node) { + if (!node) + return undefined; + var parent = node.parent; + switch (node.kind) { + case 18 /* OpenBraceToken */: + if (ts.isTypeLiteralNode(parent)) { + return parent; + } + break; + case 26 /* SemicolonToken */: + case 27 /* CommaToken */: + case 79 /* Identifier */: + if (parent.kind === 164 /* PropertySignature */ && ts.isTypeLiteralNode(parent.parent)) { + return parent.parent; + } + break; + } + return undefined; + } + function getConstraintOfTypeArgumentProperty(node, checker) { + if (!node) + return undefined; + if (ts.isTypeNode(node) && ts.isTypeReferenceType(node.parent)) { + return checker.getTypeArgumentConstraint(node); + } + var t = getConstraintOfTypeArgumentProperty(node.parent, checker); + if (!t) + return undefined; + switch (node.kind) { + case 164 /* PropertySignature */: + return checker.getTypeOfPropertyOfContextualType(t, node.symbol.escapedName); + case 185 /* IntersectionType */: + case 179 /* TypeLiteral */: + case 184 /* UnionType */: + return t; + } + } // TODO: GH#19856 Would like to return `node is Node & { parent: (ClassElement | TypeElement) & { parent: ObjectTypeDeclaration } }` but then compilation takes > 10 minutes function isFromObjectTypeDeclaration(node) { return node.parent && ts.isClassOrTypeElement(node.parent) && ts.isObjectTypeDeclaration(node.parent.parent); @@ -122122,6 +126670,8 @@ var ts; return !!contextToken && (ts.isStringLiteralLike(contextToken) ? !!ts.tryGetImportFromModuleSpecifier(contextToken) : contextToken.kind === 43 /* SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); + case " ": + return !!contextToken && ts.isImportKeyword(contextToken) && contextToken.parent.kind === 299 /* SourceFile */; default: return ts.Debug.assertNever(triggerCharacter); } @@ -122130,14 +126680,6 @@ var ts; var left = _a.left; return ts.nodeIsMissing(left); } - function findAlias(typeChecker, symbol, predicate) { - var currentAlias = symbol; - while (currentAlias.flags & 2097152 /* Alias */ && (currentAlias = typeChecker.getImmediateAliasedSymbol(currentAlias))) { - if (predicate(currentAlias)) { - return currentAlias; - } - } - } /** Determines if a type is exactly the same type resolved by the global 'self', 'global', or 'globalThis'. */ 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 @@ -122164,11 +126706,71 @@ var ts; if (type) { return type; } - if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 /* EqualsToken */) { + if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* EqualsToken */ && node === node.parent.left) { + // Object literal is assignment pattern: ({ | } = x) return typeChecker.getTypeAtLocation(node.parent); } return undefined; } + function getImportCompletionNode(contextToken) { + var candidate = getCandidate(); + return candidate === 154 /* FromKeyword */ || candidate && ts.rangeIsOnSingleLine(candidate, candidate.getSourceFile()) ? candidate : undefined; + function getCandidate() { + var parent = contextToken.parent; + if (ts.isImportEqualsDeclaration(parent)) { + return isModuleSpecifierMissingOrEmpty(parent.moduleReference) ? parent : undefined; + } + if (ts.isNamedImports(parent) || ts.isNamespaceImport(parent)) { + if (isModuleSpecifierMissingOrEmpty(parent.parent.parent.moduleSpecifier) && (ts.isNamespaceImport(parent) || parent.elements.length < 2) && !parent.parent.name) { + // At `import { ... } |` or `import * as Foo |`, the only possible completion is `from` + return contextToken.kind === 19 /* CloseBraceToken */ || contextToken.kind === 79 /* Identifier */ + ? 154 /* FromKeyword */ + : parent.parent.parent; + } + return undefined; + } + if (ts.isImportKeyword(contextToken) && ts.isSourceFile(parent)) { + // A lone import keyword with nothing following it does not parse as a statement at all + return contextToken; + } + if (ts.isImportKeyword(contextToken) && ts.isImportDeclaration(parent)) { + // `import s| from` + return isModuleSpecifierMissingOrEmpty(parent.moduleSpecifier) ? parent : undefined; + } + return undefined; + } + } + function isModuleSpecifierMissingOrEmpty(specifier) { + var _a; + if (ts.nodeIsMissing(specifier)) + return true; + return !((_a = ts.tryCast(ts.isExternalModuleReference(specifier) ? specifier.expression : specifier, ts.isStringLiteralLike)) === null || _a === void 0 ? void 0 : _a.text); + } + function getVariableDeclaration(property) { + var variableDeclaration = ts.findAncestor(property, function (node) { + return ts.isFunctionBlock(node) || isArrowFunctionBody(node) || ts.isBindingPattern(node) + ? "quit" + : ts.isVariableDeclaration(node); + }); + return variableDeclaration; + } + function isArrowFunctionBody(node) { + return node.parent && ts.isArrowFunction(node.parent) && node.parent.body === node; + } + ; + /** True if symbol is a type or a module containing at least one type. */ + function symbolCanBeReferencedAtTypeLocation(symbol, checker, seenModules) { + if (seenModules === void 0) { seenModules = new ts.Map(); } + var sym = ts.skipAlias(symbol.exportSymbol || symbol, checker); + return !!(sym.flags & 788968 /* Type */) || + !!(sym.flags & 1536 /* Module */) && + ts.addToSeen(seenModules, ts.getSymbolId(sym)) && + checker.getExportsOfModule(sym).some(function (e) { return symbolCanBeReferencedAtTypeLocation(e, checker, seenModules); }); + } + function isDeprecated(symbol, checker) { + var declarations = ts.skipAlias(symbol, checker).declarations; + return !!ts.length(declarations) && ts.every(declarations, ts.isDeprecatedDeclaration); + } })(Completions = ts.Completions || (ts.Completions = {})); })(ts || (ts = {})); var ts; @@ -122203,10 +126805,13 @@ var ts; if (!referenceEntries) return undefined; var map = ts.arrayToMultiMap(referenceEntries.map(ts.FindAllReferences.toHighlightSpan), function (e) { return e.fileName; }, function (e) { return e.span; }); - return ts.arrayFrom(map.entries(), function (_a) { + var getCanonicalFileName = ts.createGetCanonicalFileName(program.useCaseSensitiveFileNames()); + return ts.mapDefined(ts.arrayFrom(map.entries()), function (_a) { var fileName = _a[0], highlightSpans = _a[1]; if (!sourceFilesSet.has(fileName)) { - ts.Debug.assert(program.redirectTargetsMap.has(fileName)); + if (!program.redirectTargetsMap.has(ts.toPath(fileName, program.getCurrentDirectory(), getCanonicalFileName))) { + return undefined; + } var redirectTarget_1 = program.getSourceFile(fileName); var redirect = ts.find(sourceFilesToSearch, function (f) { return !!f.redirectInfo && f.redirectInfo.redirectTarget === redirectTarget_1; }); fileName = redirect.fileName; @@ -122221,44 +126826,44 @@ var ts; } function getHighlightSpans(node, sourceFile) { switch (node.kind) { - case 98 /* IfKeyword */: - case 90 /* ElseKeyword */: + case 99 /* IfKeyword */: + case 91 /* ElseKeyword */: return ts.isIfStatement(node.parent) ? getIfElseOccurrences(node.parent, sourceFile) : undefined; - case 104 /* ReturnKeyword */: + case 105 /* ReturnKeyword */: return useParent(node.parent, ts.isReturnStatement, getReturnOccurrences); - case 108 /* ThrowKeyword */: + case 109 /* ThrowKeyword */: return useParent(node.parent, ts.isThrowStatement, getThrowOccurrences); - case 110 /* TryKeyword */: - case 82 /* CatchKeyword */: - case 95 /* FinallyKeyword */: - var tryStatement = node.kind === 82 /* CatchKeyword */ ? node.parent.parent : node.parent; + case 111 /* TryKeyword */: + case 83 /* CatchKeyword */: + case 96 /* FinallyKeyword */: + var tryStatement = node.kind === 83 /* CatchKeyword */ ? node.parent.parent : node.parent; return useParent(tryStatement, ts.isTryStatement, getTryCatchFinallyOccurrences); - case 106 /* SwitchKeyword */: + case 107 /* SwitchKeyword */: return useParent(node.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); - case 81 /* CaseKeyword */: - case 87 /* DefaultKeyword */: { + case 82 /* CaseKeyword */: + case 88 /* DefaultKeyword */: { if (ts.isDefaultClause(node.parent) || ts.isCaseClause(node.parent)) { return useParent(node.parent.parent.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); } return undefined; } - case 80 /* BreakKeyword */: - case 85 /* ContinueKeyword */: + case 81 /* BreakKeyword */: + case 86 /* ContinueKeyword */: return useParent(node.parent, ts.isBreakOrContinueStatement, getBreakOrContinueStatementOccurrences); - case 96 /* ForKeyword */: - case 114 /* WhileKeyword */: - case 89 /* DoKeyword */: + case 97 /* ForKeyword */: + case 115 /* WhileKeyword */: + case 90 /* DoKeyword */: return useParent(node.parent, function (n) { return ts.isIterationStatement(n, /*lookInLabeledStatements*/ true); }, getLoopBreakContinueOccurrences); - case 132 /* ConstructorKeyword */: - return getFromAllDeclarations(ts.isConstructorDeclaration, [132 /* ConstructorKeyword */]); - case 134 /* GetKeyword */: - case 146 /* SetKeyword */: - return getFromAllDeclarations(ts.isAccessor, [134 /* GetKeyword */, 146 /* SetKeyword */]); - case 130 /* AwaitKeyword */: + case 133 /* ConstructorKeyword */: + return getFromAllDeclarations(ts.isConstructorDeclaration, [133 /* ConstructorKeyword */]); + case 135 /* GetKeyword */: + case 147 /* SetKeyword */: + return getFromAllDeclarations(ts.isAccessor, [135 /* GetKeyword */, 147 /* SetKeyword */]); + case 131 /* AwaitKeyword */: return useParent(node.parent, ts.isAwaitExpression, getAsyncAndAwaitOccurrences); - case 129 /* AsyncKeyword */: + case 130 /* AsyncKeyword */: return highlightSpans(getAsyncAndAwaitOccurrences(node)); - case 124 /* YieldKeyword */: + case 125 /* YieldKeyword */: return highlightSpans(getYieldOccurrences(node)); default: return ts.isModifierKind(node.kind) && (ts.isDeclaration(node.parent) || ts.isVariableStatement(node.parent)) @@ -122301,7 +126906,7 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (ts.isFunctionBlock(parent) || parent.kind === 297 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 299 /* SourceFile */) { return parent; } // A throw-statement is only owned by a try-statement if the try-statement has @@ -122333,16 +126938,16 @@ var ts; function getBreakOrContinueOwner(statement) { return ts.findAncestor(statement, function (node) { switch (node.kind) { - case 244 /* SwitchStatement */: - if (statement.kind === 240 /* ContinueStatement */) { + case 246 /* SwitchStatement */: + if (statement.kind === 242 /* ContinueStatement */) { return false; } // falls through - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 236 /* WhileStatement */: - case 235 /* DoStatement */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 238 /* WhileStatement */: + case 237 /* DoStatement */: return !statement.label || isLabeledBy(node, statement.label.escapedText); default: // Don't cross function boundaries. @@ -122358,11 +126963,11 @@ var ts; // Types of node whose children might have modifiers. var container = declaration.parent; switch (container.kind) { - case 257 /* ModuleBlock */: - case 297 /* SourceFile */: - case 230 /* Block */: - case 284 /* CaseClause */: - case 285 /* DefaultClause */: + case 259 /* ModuleBlock */: + case 299 /* SourceFile */: + case 232 /* Block */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 128 /* Abstract */ && ts.isClassDeclaration(declaration)) { return __spreadArray(__spreadArray([], declaration.members), [declaration]); @@ -122370,14 +126975,14 @@ var ts; else { return container.statements; } - case 166 /* Constructor */: - case 165 /* MethodDeclaration */: - case 251 /* FunctionDeclaration */: + case 168 /* Constructor */: + case 167 /* MethodDeclaration */: + case 253 /* FunctionDeclaration */: return __spreadArray(__spreadArray([], container.parameters), (ts.isClassLike(container.parent) ? container.parent.members : [])); - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 177 /* TypeLiteral */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: + case 179 /* 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. @@ -122392,7 +126997,7 @@ var ts; } return nodes; // Syntactically invalid positions that the parser might produce anyway - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return undefined; default: ts.Debug.assertNever(container, "Invalid container kind."); @@ -122411,12 +127016,12 @@ var ts; } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 96 /* ForKeyword */, 114 /* WhileKeyword */, 89 /* DoKeyword */)) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 97 /* ForKeyword */, 115 /* WhileKeyword */, 90 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 235 /* DoStatement */) { + if (loopNode.kind === 237 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 114 /* WhileKeyword */)) { + if (pushKeywordIf(keywords, loopTokens[i], 115 /* WhileKeyword */)) { break; } } @@ -122424,7 +127029,7 @@ var ts; } ts.forEach(aggregateAllBreakAndContinueStatements(loopNode.statement), function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 80 /* BreakKeyword */, 85 /* ContinueKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 81 /* BreakKeyword */, 86 /* ContinueKeyword */); } }); return keywords; @@ -122433,13 +127038,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -122447,13 +127052,13 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 106 /* SwitchKeyword */); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 107 /* 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(), 81 /* CaseKeyword */, 87 /* DefaultKeyword */); + pushKeywordIf(keywords, clause.getFirstToken(), 82 /* CaseKeyword */, 88 /* DefaultKeyword */); ts.forEach(aggregateAllBreakAndContinueStatements(clause), function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 80 /* BreakKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 81 /* BreakKeyword */); } }); }); @@ -122461,13 +127066,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement, sourceFile) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 110 /* TryKeyword */); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 111 /* TryKeyword */); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 82 /* CatchKeyword */); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 83 /* CatchKeyword */); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 95 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 95 /* FinallyKeyword */); + var finallyKeyword = ts.findChildOfKind(tryStatement, 96 /* FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 96 /* FinallyKeyword */); } return keywords; } @@ -122478,13 +127083,13 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - keywords.push(ts.findChildOfKind(throwStatement, 108 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 109 /* 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, 104 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 105 /* ReturnKeyword */, sourceFile)); }); } return keywords; @@ -122496,11 +127101,11 @@ var ts; } var keywords = []; ts.forEachReturnStatement(ts.cast(func.body, ts.isBlock), function (returnStatement) { - keywords.push(ts.findChildOfKind(returnStatement, 104 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 105 /* 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, 108 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 109 /* ThrowKeyword */, sourceFile)); }); return keywords; } @@ -122512,13 +127117,13 @@ var ts; var keywords = []; if (func.modifiers) { func.modifiers.forEach(function (modifier) { - pushKeywordIf(keywords, modifier, 129 /* AsyncKeyword */); + pushKeywordIf(keywords, modifier, 130 /* AsyncKeyword */); }); } ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isAwaitExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 130 /* AwaitKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 131 /* AwaitKeyword */); } }); }); @@ -122533,7 +127138,7 @@ var ts; ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isYieldExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 124 /* YieldKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 125 /* YieldKeyword */); } }); }); @@ -122552,7 +127157,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 === 90 /* ElseKeyword */ && i < keywords.length - 1) { + if (keywords[i].kind === 91 /* ElseKeyword */ && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. var shouldCombineElseAndIf = true; @@ -122587,10 +127192,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], 98 /* IfKeyword */); + pushKeywordIf(keywords, children[0], 99 /* 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], 90 /* ElseKeyword */)) { + if (pushKeywordIf(keywords, children[i], 91 /* ElseKeyword */)) { break; } } @@ -122612,6 +127217,9 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + function isDocumentRegistryEntry(entry) { + return !!entry.sourceFile; + } function createDocumentRegistry(useCaseSensitiveFileNames, currentDirectory) { return createDocumentRegistryInternal(useCaseSensitiveFileNames, currentDirectory); } @@ -122628,10 +127236,16 @@ var ts; var entries = buckets.get(name); var sourceFiles = []; entries.forEach(function (entry, name) { - sourceFiles.push({ - name: name, - refCount: entry.languageServiceRefCount - }); + if (isDocumentRegistryEntry(entry)) { + sourceFiles.push({ + name: name, + scriptKind: entry.sourceFile.scriptKind, + refCount: entry.languageServiceRefCount + }); + } + else { + entry.forEach(function (value, scriptKind) { return sourceFiles.push({ name: name, scriptKind: scriptKind, refCount: value.languageServiceRefCount }); }); + } }); sourceFiles.sort(function (x, y) { return y.refCount - x.refCount; }); return { @@ -122657,10 +127271,17 @@ var ts; function updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind) { return acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, /*acquiring*/ false, scriptKind); } + 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); + return entry; + } function acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, acquiring, scriptKind) { - var bucket = ts.getOrUpdate(buckets, key, function () { return new ts.Map(); }); - var entry = bucket.get(path); + scriptKind = ts.ensureScriptKind(fileName, scriptKind); var scriptTarget = scriptKind === 6 /* JSON */ ? 100 /* JSON */ : compilationSettings.target || 1 /* ES5 */; + var bucket = ts.getOrUpdate(buckets, key, function () { return new ts.Map(); }); + var bucketEntry = bucket.get(path); + var entry = bucketEntry && getDocumentRegistryEntry(bucketEntry, scriptKind); if (!entry && externalCache) { var sourceFile = externalCache.getDocument(key, path); if (sourceFile) { @@ -122669,7 +127290,7 @@ var ts; sourceFile: sourceFile, languageServiceRefCount: 0 }; - bucket.set(path, entry); + setBucketEntry(); } } if (!entry) { @@ -122682,7 +127303,7 @@ var ts; sourceFile: sourceFile, languageServiceRefCount: 1, }; - bucket.set(path, entry); + setBucketEntry(); } else { // We have an entry for this file. However, it may be for a different version of @@ -122705,25 +127326,49 @@ var ts; } ts.Debug.assert(entry.languageServiceRefCount !== 0); return entry.sourceFile; + function setBucketEntry() { + if (!bucketEntry) { + bucket.set(path, entry); + } + else if (isDocumentRegistryEntry(bucketEntry)) { + var scriptKindMap = new ts.Map(); + scriptKindMap.set(bucketEntry.sourceFile.scriptKind, bucketEntry); + scriptKindMap.set(scriptKind, entry); + bucket.set(path, scriptKindMap); + } + else { + bucketEntry.set(scriptKind, entry); + } + } } - function releaseDocument(fileName, compilationSettings) { + function releaseDocument(fileName, compilationSettings, scriptKind) { var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); var key = getKeyForCompilationSettings(compilationSettings); - return releaseDocumentWithKey(path, key); + return releaseDocumentWithKey(path, key, scriptKind); } - function releaseDocumentWithKey(path, key) { + function releaseDocumentWithKey(path, key, scriptKind) { var bucket = ts.Debug.checkDefined(buckets.get(key)); - var entry = bucket.get(path); + var bucketEntry = bucket.get(path); + var entry = getDocumentRegistryEntry(bucketEntry, scriptKind); entry.languageServiceRefCount--; ts.Debug.assert(entry.languageServiceRefCount >= 0); if (entry.languageServiceRefCount === 0) { - bucket.delete(path); + if (isDocumentRegistryEntry(bucketEntry)) { + bucket.delete(path); + } + else { + bucketEntry.delete(scriptKind); + if (bucketEntry.size === 1) { + bucket.set(path, ts.firstDefinedIterator(bucketEntry.values(), ts.identity)); + } + } } } - function getLanguageServiceRefCounts(path) { + function getLanguageServiceRefCounts(path, scriptKind) { return ts.arrayFrom(buckets.entries(), function (_a) { var key = _a[0], bucket = _a[1]; - var entry = bucket.get(path); + var bucketEntry = bucket.get(path); + var entry = bucketEntry && getDocumentRegistryEntry(bucketEntry, scriptKind); return [key, entry && entry.languageServiceRefCount]; }); } @@ -122786,10 +127431,12 @@ var ts; return sourceFiles; } // Module augmentations may use this module's exports without importing it. - for (var _i = 0, _a = exportingModuleSymbol.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - if (ts.isExternalModuleAugmentation(decl) && sourceFilesSet.has(decl.getSourceFile().fileName)) { - addIndirectUser(decl); + if (exportingModuleSymbol.declarations) { + for (var _i = 0, _a = exportingModuleSymbol.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + if (ts.isExternalModuleAugmentation(decl) && sourceFilesSet.has(decl.getSourceFile().fileName)) { + addIndirectUser(decl); + } } } // This may return duplicates (if there are multiple module declarations in a single source file, all importing the same thing as a namespace), but `State.markSearchedSymbol` will handle that. @@ -122806,43 +127453,43 @@ var ts; if (cancellationToken) cancellationToken.throwIfCancellationRequested(); switch (direct.kind) { - case 203 /* CallExpression */: + case 205 /* CallExpression */: if (ts.isImportCall(direct)) { handleImportCall(direct); break; } if (!isAvailableThroughGlobal) { var parent = direct.parent; - if (exportKind === 2 /* ExportEquals */ && parent.kind === 249 /* VariableDeclaration */) { + if (exportKind === 2 /* ExportEquals */ && parent.kind === 251 /* VariableDeclaration */) { var name = parent.name; - if (name.kind === 78 /* Identifier */) { + if (name.kind === 79 /* Identifier */) { directImports.push(name); break; } } } break; - case 78 /* Identifier */: // for 'const x = require("y"); + case 79 /* Identifier */: // for 'const x = require("y"); break; // TODO: GH#23879 - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: handleNamespaceImport(direct, direct.name, ts.hasSyntacticModifier(direct, 1 /* Export */), /*alreadyAddedDirect*/ false); break; - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: directImports.push(direct); var namedBindings = direct.importClause && direct.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 263 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 265 /* 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 267 /* ExportDeclaration */: + case 269 /* 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 === 269 /* NamespaceExport */) { + else if (direct.exportClause.kind === 271 /* NamespaceExport */) { // `export * as foo from "foo"` add to indirect uses addIndirectUser(getSourceFileLikeForImportDeclaration(direct), /** addTransitiveDependencies */ true); } @@ -122851,7 +127498,7 @@ var ts; directImports.push(direct); } break; - case 195 /* ImportType */: + case 197 /* ImportType */: // Only check for typeof import('xyz') if (direct.isTypeOf && !direct.qualifier && isExported(direct)) { addIndirectUser(direct.getSourceFile(), /** addTransitiveDependencies */ true); @@ -122873,7 +127520,7 @@ var ts; return ts.findAncestor(node, function (node) { if (stopAtAmbientModule && isAmbientModuleDeclaration(node)) return "quit"; - return ts.some(node.modifiers, function (mod) { return mod.kind === 92 /* ExportKeyword */; }); + return ts.some(node.modifiers, function (mod) { return mod.kind === 93 /* ExportKeyword */; }); }); } function handleNamespaceImport(importDeclaration, name, isReExport, alreadyAddedDirect) { @@ -122884,7 +127531,7 @@ var ts; } else if (!isAvailableThroughGlobal) { var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); - ts.Debug.assert(sourceFileLike.kind === 297 /* SourceFile */ || sourceFileLike.kind === 256 /* ModuleDeclaration */); + ts.Debug.assert(sourceFileLike.kind === 299 /* SourceFile */ || sourceFileLike.kind === 258 /* ModuleDeclaration */); if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { addIndirectUser(sourceFileLike, /** addTransitiveDependencies */ true); } @@ -122940,17 +127587,17 @@ var ts; } return { importSearches: importSearches, singleReferences: singleReferences }; function handleImport(decl) { - if (decl.kind === 260 /* ImportEqualsDeclaration */) { + if (decl.kind === 262 /* ImportEqualsDeclaration */) { if (isExternalModuleImportEquals(decl)) { handleNamespaceImportLike(decl.name); } return; } - if (decl.kind === 78 /* Identifier */) { + if (decl.kind === 79 /* Identifier */) { handleNamespaceImportLike(decl); return; } - if (decl.kind === 195 /* ImportType */) { + if (decl.kind === 197 /* ImportType */) { if (decl.qualifier) { var firstIdentifier = ts.getFirstIdentifier(decl.qualifier); if (firstIdentifier.escapedText === ts.symbolName(exportSymbol)) { @@ -122966,7 +127613,7 @@ var ts; if (decl.moduleSpecifier.kind !== 10 /* StringLiteral */) { return; } - if (decl.kind === 267 /* ExportDeclaration */) { + if (decl.kind === 269 /* ExportDeclaration */) { if (decl.exportClause && ts.isNamedExports(decl.exportClause)) { searchForNamedImport(decl.exportClause); } @@ -122975,10 +127622,10 @@ var ts; var _a = decl.importClause || { name: undefined, namedBindings: undefined }, name = _a.name, namedBindings = _a.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: handleNamespaceImportLike(namedBindings.name); break; - case 264 /* NamedImports */: + case 266 /* NamedImports */: // 'default' might be accessed as a named import `{ default as foo }`. if (exportKind === 0 /* Named */ || exportKind === 1 /* Default */) { searchForNamedImport(namedBindings); @@ -123028,7 +127675,7 @@ var ts; } } else { - var localSymbol = element.kind === 270 /* ExportSpecifier */ && element.propertyName + var localSymbol = element.kind === 272 /* 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); @@ -123057,7 +127704,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.kind === 297 /* SourceFile */) { + if ((searchSourceFile === null || searchSourceFile === void 0 ? void 0 : searchSourceFile.kind) === 299 /* SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { var ref = _b[_a]; if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) { @@ -123105,7 +127752,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 === 297 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return ts.forEach(sourceFileLike.kind === 299 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); }); } @@ -123120,15 +127767,15 @@ var ts; else { forEachPossibleImportOrExportStatement(sourceFile, function (statement) { switch (statement.kind) { - case 267 /* ExportDeclaration */: - case 261 /* ImportDeclaration */: { + case 269 /* ExportDeclaration */: + case 263 /* ImportDeclaration */: { var decl = statement; if (decl.moduleSpecifier && ts.isStringLiteral(decl.moduleSpecifier)) { action(decl, decl.moduleSpecifier); } break; } - case 260 /* ImportEqualsDeclaration */: { + case 262 /* ImportEqualsDeclaration */: { var decl = statement; if (isExternalModuleImportEquals(decl)) { action(decl, decl.moduleReference.expression); @@ -123149,14 +127796,15 @@ var ts; function getImportOrExportSymbol(node, symbol, checker, comingFromExport) { return comingFromExport ? getExport() : getExport() || getImport(); function getExport() { + var _a; var parent = node.parent; - var grandParent = parent.parent; + var grandparent = parent.parent; if (symbol.exportSymbol) { - if (parent.kind === 201 /* PropertyAccessExpression */) { + if (parent.kind === 203 /* 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 symbol.declarations.some(function (d) { return d === parent; }) && ts.isBinaryExpression(grandParent) - ? getSpecialPropertyExport(grandParent, /*useLhsSymbol*/ false) + return ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d === parent; })) && ts.isBinaryExpression(grandparent) + ? getSpecialPropertyExport(grandparent, /*useLhsSymbol*/ false) : undefined; } else { @@ -123186,15 +127834,15 @@ var ts; return getExportAssignmentExport(parent); } // If we are in `export = class A {};` (or `export = class A {};`) at `A`, `parent.parent` is the export assignment. - else if (ts.isExportAssignment(grandParent)) { - return getExportAssignmentExport(grandParent); + else if (ts.isExportAssignment(grandparent)) { + return getExportAssignmentExport(grandparent); } // Similar for `module.exports =` and `exports.A =`. else if (ts.isBinaryExpression(parent)) { return getSpecialPropertyExport(parent, /*useLhsSymbol*/ true); } - else if (ts.isBinaryExpression(grandParent)) { - return getSpecialPropertyExport(grandParent, /*useLhsSymbol*/ true); + else if (ts.isBinaryExpression(grandparent)) { + return getSpecialPropertyExport(grandparent, /*useLhsSymbol*/ true); } else if (ts.isJSDocTypedefTag(parent)) { return exportInfo(symbol, 0 /* Named */); @@ -123202,9 +127850,10 @@ var ts; } function getExportAssignmentExport(ex) { // Get the symbol for the `export =` node; its parent is the module it's the export of. - var exportingModuleSymbol = ts.Debug.checkDefined(ex.symbol.parent, "Expected export symbol to have a parent"); + if (!ex.symbol.parent) + return undefined; var exportKind = ex.isExportEquals ? 2 /* ExportEquals */ : 1 /* Default */; - return { kind: 1 /* Export */, symbol: symbol, exportInfo: { exportingModuleSymbol: exportingModuleSymbol, exportKind: exportKind } }; + return { kind: 1 /* Export */, symbol: symbol, exportInfo: { exportingModuleSymbol: ex.symbol.parent, exportKind: exportKind } }; } function getSpecialPropertyExport(node, useLhsSymbol) { var kind; @@ -123258,7 +127907,7 @@ var ts; if (importedSymbol.flags & 2097152 /* Alias */) { return ts.Debug.checkDefined(checker.getImmediateAliasedSymbol(importedSymbol)); } - var decl = importedSymbol.valueDeclaration; + var decl = ts.Debug.checkDefined(importedSymbol.valueDeclaration); if (ts.isExportAssignment(decl)) { // `export = class {}` return ts.Debug.checkDefined(decl.expression.symbol); } @@ -123285,17 +127934,17 @@ var ts; function isNodeImport(node) { var parent = node.parent; switch (parent.kind) { - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return parent.name === node && isExternalModuleImportEquals(parent); - case 265 /* ImportSpecifier */: + case 267 /* 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 262 /* ImportClause */: - case 263 /* NamespaceImport */: + case 264 /* ImportClause */: + case 265 /* NamespaceImport */: ts.Debug.assert(parent.name === node); return true; - case 198 /* BindingElement */: - return ts.isInJSFile(node) && ts.isRequireVariableDeclaration(parent, /*requireStringLiteralLikeArgument*/ true); + case 200 /* BindingElement */: + return ts.isInJSFile(node) && ts.isRequireVariableDeclaration(parent); default: return false; } @@ -123319,7 +127968,8 @@ var ts; return checker.getExportSpecifierLocalTargetSymbol(declaration); } else if (ts.isPropertyAccessExpression(declaration) && ts.isModuleExportsAccessExpression(declaration.expression) && !ts.isPrivateIdentifier(declaration.name)) { - return checker.getExportSpecifierLocalTargetSymbol(declaration.name); + // Export of form 'module.exports.propName = expr'; + return checker.getSymbolAtLocation(declaration); } else if (ts.isShorthandPropertyAssignment(declaration) && ts.isBinaryExpression(declaration.parent.parent) @@ -123334,21 +127984,21 @@ var ts; return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol); } function getSourceFileLikeForImportDeclaration(node) { - if (node.kind === 203 /* CallExpression */) { + if (node.kind === 205 /* CallExpression */) { return node.getSourceFile(); } var parent = node.parent; - if (parent.kind === 297 /* SourceFile */) { + if (parent.kind === 299 /* SourceFile */) { return parent; } - ts.Debug.assert(parent.kind === 257 /* ModuleBlock */); + ts.Debug.assert(parent.kind === 259 /* ModuleBlock */); return ts.cast(parent.parent, isAmbientModuleDeclaration); } function isAmbientModuleDeclaration(node) { - return node.kind === 256 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; + return node.kind === 258 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; } function isExternalModuleImportEquals(eq) { - return eq.moduleReference.kind === 272 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; + return eq.moduleReference.kind === 274 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); @@ -123442,7 +128092,7 @@ var ts; ((ts.isImportOrExportSpecifier(node.parent) || ts.isBindingElement(node.parent)) && node.parent.propertyName === node) || // Is default export - (node.kind === 87 /* DefaultKeyword */ && ts.hasSyntacticModifier(node.parent, 513 /* ExportDefault */))) { + (node.kind === 88 /* DefaultKeyword */ && ts.hasSyntacticModifier(node.parent, 513 /* ExportDefault */))) { return getContextNode(node.parent); } return undefined; @@ -123451,7 +128101,7 @@ var ts; if (!node) return undefined; switch (node.kind) { - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return !ts.isVariableDeclarationList(node.parent) || node.parent.declarations.length !== 1 ? node : ts.isVariableStatement(node.parent.parent) ? @@ -123459,28 +128109,28 @@ var ts; ts.isForInOrOfStatement(node.parent.parent) ? getContextNode(node.parent.parent) : node.parent; - case 198 /* BindingElement */: + case 200 /* BindingElement */: return getContextNode(node.parent.parent); - case 265 /* ImportSpecifier */: + case 267 /* ImportSpecifier */: return node.parent.parent.parent; - case 270 /* ExportSpecifier */: - case 263 /* NamespaceImport */: + case 272 /* ExportSpecifier */: + case 265 /* NamespaceImport */: return node.parent.parent; - case 262 /* ImportClause */: - case 269 /* NamespaceExport */: + case 264 /* ImportClause */: + case 271 /* NamespaceExport */: return node.parent; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return ts.isExpressionStatement(node.parent) ? node.parent : node; - case 239 /* ForOfStatement */: - case 238 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 240 /* ForInStatement */: return { start: node.initializer, end: node.expression }; - case 288 /* PropertyAssignment */: - case 289 /* ShorthandPropertyAssignment */: + case 290 /* PropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent) ? getContextNode(ts.findAncestor(node.parent, function (node) { return ts.isBinaryExpression(node) || ts.isForInOrOfStatement(node); @@ -123537,10 +128187,10 @@ var ts; var node = ts.getTouchingPropertyName(sourceFile, position); var referenceEntries; var entries = getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position); - if (node.parent.kind === 201 /* PropertyAccessExpression */ - || node.parent.kind === 198 /* BindingElement */ - || node.parent.kind === 202 /* ElementAccessExpression */ - || node.kind === 105 /* SuperKeyword */) { + if (node.parent.kind === 203 /* PropertyAccessExpression */ + || node.parent.kind === 200 /* BindingElement */ + || node.parent.kind === 204 /* ElementAccessExpression */ + || node.kind === 106 /* SuperKeyword */) { referenceEntries = entries && __spreadArray([], entries); } else { @@ -123563,18 +128213,18 @@ var ts; } FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) { - if (node.kind === 297 /* SourceFile */) { + if (node.kind === 299 /* 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 === 289 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 291 /* ShorthandPropertyAssignment */) { var result_1 = []; Core.getReferenceEntriesForShorthandPropertyAssignment(node, checker, function (node) { return result_1.push(nodeEntry(node)); }); return result_1; } - else if (node.kind === 105 /* SuperKeyword */ || ts.isSuperProperty(node.parent)) { + else if (node.kind === 106 /* 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); @@ -123744,13 +128394,13 @@ var ts; if (symbol) { return getDefinitionKindAndDisplayParts(symbol, checker, node); } - else if (node.kind === 200 /* ObjectLiteralExpression */) { + else if (node.kind === 202 /* ObjectLiteralExpression */) { return { kind: "interface" /* interfaceElement */, displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(21 /* CloseParenToken */)] }; } - else if (node.kind === 221 /* ClassExpression */) { + else if (node.kind === 223 /* ClassExpression */) { return { kind: "local class" /* localClassElement */, displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(21 /* CloseParenToken */)] @@ -123794,13 +128444,13 @@ var ts; /** 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 === 87 /* DefaultKeyword */ || ts.isWriteAccess(node); + return !!decl && declarationIsWriteAccess(decl) || node.kind === 88 /* DefaultKeyword */ || ts.isWriteAccess(node); } function isDefinitionForReference(node) { - return node.kind === 87 /* DefaultKeyword */ + return node.kind === 88 /* DefaultKeyword */ || !!ts.getDeclarationFromName(node) || ts.isLiteralComputedPropertyDeclarationName(node) - || (node.kind === 132 /* ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent)); + || (node.kind === 133 /* ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent)); } /** * True if 'decl' provides a value, as in `function f() {}`; @@ -123811,47 +128461,47 @@ var ts; if (!!(decl.flags & 8388608 /* Ambient */)) return true; switch (decl.kind) { - case 216 /* BinaryExpression */: - case 198 /* BindingElement */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 87 /* DefaultKeyword */: - case 255 /* EnumDeclaration */: - case 291 /* EnumMember */: - case 270 /* ExportSpecifier */: - case 262 /* ImportClause */: // default import - case 260 /* ImportEqualsDeclaration */: - case 265 /* ImportSpecifier */: - case 253 /* InterfaceDeclaration */: - case 324 /* JSDocCallbackTag */: - case 331 /* JSDocTypedefTag */: - case 280 /* JsxAttribute */: - case 256 /* ModuleDeclaration */: - case 259 /* NamespaceExportDeclaration */: - case 263 /* NamespaceImport */: - case 269 /* NamespaceExport */: - case 160 /* Parameter */: - case 289 /* ShorthandPropertyAssignment */: - case 254 /* TypeAliasDeclaration */: - case 159 /* TypeParameter */: + case 218 /* BinaryExpression */: + case 200 /* BindingElement */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 88 /* DefaultKeyword */: + case 257 /* EnumDeclaration */: + case 293 /* EnumMember */: + case 272 /* ExportSpecifier */: + case 264 /* ImportClause */: // default import + case 262 /* ImportEqualsDeclaration */: + case 267 /* ImportSpecifier */: + case 255 /* InterfaceDeclaration */: + case 332 /* JSDocCallbackTag */: + case 339 /* JSDocTypedefTag */: + case 282 /* JsxAttribute */: + case 258 /* ModuleDeclaration */: + case 261 /* NamespaceExportDeclaration */: + case 265 /* NamespaceImport */: + case 271 /* NamespaceExport */: + case 162 /* Parameter */: + case 291 /* ShorthandPropertyAssignment */: + case 256 /* TypeAliasDeclaration */: + case 161 /* TypeParameter */: return true; - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: // In `({ x: y } = 0);`, `x` is not a write access. (Won't call this function for `y`.) return !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(decl.parent); - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 166 /* Constructor */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 168 /* Constructor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return !!decl.body; - case 249 /* VariableDeclaration */: - case 163 /* PropertyDeclaration */: + case 251 /* VariableDeclaration */: + case 165 /* PropertyDeclaration */: return !!decl.initializer || ts.isCatchClause(decl.parent); - case 164 /* MethodSignature */: - case 162 /* PropertySignature */: - case 333 /* JSDocPropertyTag */: - case 326 /* JSDocParameterTag */: + case 166 /* MethodSignature */: + case 164 /* PropertySignature */: + case 341 /* JSDocPropertyTag */: + case 334 /* JSDocParameterTag */: return false; default: return ts.Debug.failBadSyntaxKind(decl); @@ -123873,7 +128523,7 @@ var ts; } if (ts.isSourceFile(node)) { var resolvedRef = ts.GoToDefinition.getReferenceAtPosition(node, position, program); - if (!resolvedRef) { + if (!(resolvedRef === null || resolvedRef === void 0 ? void 0 : resolvedRef.file)) { return undefined; } var moduleSymbol = program.getTypeChecker().getMergedSymbol(resolvedRef.file.symbol); @@ -123902,7 +128552,7 @@ var ts; if (!symbol) { // String literal might be a property (and thus have a symbol), so do this here rather than in getReferencedSymbolsSpecial. if (!options.implementations && ts.isStringLiteralLike(node)) { - if (ts.isRequireCall(node.parent, /*requireStringLiteralLikeArgument*/ true) || ts.isExternalModuleReference(node.parent) || ts.isImportDeclaration(node.parent) || ts.isImportCall(node.parent)) { + if (ts.isModuleSpecifierLike(node)) { var fileIncludeReasons = program.getFileIncludeReasons(); var referencedFileName = (_b = (_a = node.getSourceFile().resolvedModules) === null || _a === void 0 ? void 0 : _a.get(node.text)) === null || _b === void 0 ? void 0 : _b.resolvedFileName; var referencedFile = referencedFileName ? program.getSourceFile(referencedFileName) : undefined; @@ -124003,7 +128653,7 @@ var ts; result = references; continue; } - var _loop_3 = function (entry) { + var _loop_4 = function (entry) { if (!entry.definition || entry.definition.type !== 0 /* Symbol */) { result.push(entry); return "continue"; @@ -124035,7 +128685,7 @@ var ts; }; for (var _b = 0, references_2 = references; _b < references_2.length; _b++) { var entry = references_2[_b]; - _loop_3(entry); + _loop_4(entry); } } return result; @@ -124072,10 +128722,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; switch (decl.kind) { - case 297 /* SourceFile */: + case 299 /* 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 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: if (sourceFilesSet.has(decl.getSourceFile().fileName)) { references.push(nodeEntry(decl.name)); } @@ -124087,14 +128737,14 @@ var ts; } } var exported = symbol.exports.get("export=" /* ExportEquals */); - if (exported) { + 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]; var sourceFile = decl.getSourceFile(); 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, 92 /* ExportKeyword */, sourceFile)) : + ts.isExportAssignment(decl) ? ts.Debug.checkDefined(ts.findChildOfKind(decl, 93 /* ExportKeyword */, sourceFile)) : ts.getNameOfDeclaration(decl) || decl; references.push(nodeEntry(node)); } @@ -124104,25 +128754,25 @@ var ts; } /** As in a `readonly prop: any` or `constructor(readonly prop: any)`, not a `readonly any[]`. */ function isReadonlyTypeOperator(node) { - return node.kind === 142 /* ReadonlyKeyword */ + return node.kind === 143 /* ReadonlyKeyword */ && ts.isTypeOperatorNode(node.parent) - && node.parent.operator === 142 /* ReadonlyKeyword */; + && node.parent.operator === 143 /* 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 === 113 /* VoidKeyword */ && ts.isVoidExpression(node.parent)) { + if (node.kind === 114 /* 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 === 142 /* ReadonlyKeyword */ && !isReadonlyTypeOperator(node)) { + if (node.kind === 143 /* 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 === 142 /* ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined); + return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken, node.kind === 143 /* ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined); } // Labels if (ts.isJumpStatementTarget(node)) { @@ -124138,7 +128788,7 @@ var ts; if (ts.isThis(node)) { return getReferencesForThisKeyword(node, sourceFiles, cancellationToken); } - if (node.kind === 105 /* SuperKeyword */) { + if (node.kind === 106 /* SuperKeyword */) { return getReferencesForSuperKeyword(node); } return undefined; @@ -124150,14 +128800,14 @@ var ts; var searchMeaning = node ? getIntersectingMeaningFromDeclarations(node, symbol) : 7 /* All */; var result = []; var state = new State(sourceFiles, sourceFilesSet, node ? getSpecialSearchKind(node) : 0 /* None */, checker, cancellationToken, searchMeaning, options, result); - var exportSpecifier = !isForRenameWithPrefixAndSuffixText(options) ? undefined : ts.find(symbol.declarations, ts.isExportSpecifier); + 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 === 87 /* DefaultKeyword */) { + else if (node && node.kind === 88 /* DefaultKeyword */ && symbol.escapedName === "default" /* Default */ && symbol.parent) { addReference(node, symbol, state); - searchForImportsOfExport(node, symbol, { exportingModuleSymbol: ts.Debug.checkDefined(symbol.parent, "Expected export symbol to have a parent"), exportKind: 1 /* Default */ }, state); + searchForImportsOfExport(node, symbol, { exportingModuleSymbol: symbol.parent, exportKind: 1 /* 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] }); @@ -124183,10 +128833,10 @@ var ts; } function getSpecialSearchKind(node) { switch (node.kind) { - case 166 /* Constructor */: - case 132 /* ConstructorKeyword */: + case 168 /* Constructor */: + case 133 /* ConstructorKeyword */: return 1 /* Constructor */; - case 78 /* Identifier */: + case 79 /* Identifier */: if (ts.isClassLike(node.parent)) { ts.Debug.assert(node.parent.name === node); return 2 /* Class */; @@ -124314,8 +128964,8 @@ var ts; var sourceId = ts.getNodeId(sourceFile); var seenSymbols = this.sourceFileToSeenSymbols[sourceId] || (this.sourceFileToSeenSymbols[sourceId] = new ts.Set()); var anyNewSymbols = false; - for (var _i = 0, symbols_3 = symbols; _i < symbols_3.length; _i++) { - var sym = symbols_3[_i]; + for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) { + var sym = symbols_2[_i]; anyNewSymbols = ts.tryAddToSet(seenSymbols, ts.getSymbolId(sym)) || anyNewSymbols; } return anyNewSymbols; @@ -124372,7 +129022,9 @@ var ts; for (var _c = 0, _d = getPossibleSymbolReferenceNodes(indirectUser, isDefaultExport ? "default" : exportName); _c < _d.length; _c++) { var node = _d[_c]; // Import specifiers should be handled by importSearches - if (ts.isIdentifier(node) && !ts.isImportOrExportSpecifier(node.parent) && checker.getSymbolAtLocation(node) === exportSymbol) { + var symbol = checker.getSymbolAtLocation(node); + var hasExportAssignmentDeclaration = ts.some(symbol === null || symbol === void 0 ? void 0 : symbol.declarations, function (d) { return ts.tryCast(d, ts.isExportAssignment) ? true : false; }); + if (ts.isIdentifier(node) && !ts.isImportOrExportSpecifier(node.parent) && (symbol === exportSymbol || hasExportAssignmentDeclaration)) { cb(node); } } @@ -124424,7 +129076,7 @@ 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 === 208 /* FunctionExpression */ || valueDeclaration.kind === 221 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 210 /* FunctionExpression */ || valueDeclaration.kind === 223 /* ClassExpression */)) { return valueDeclaration; } if (!declarations) { @@ -124432,9 +129084,9 @@ var ts; } // 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.isPrivateIdentifierPropertyDeclaration(d); }); + var privateDeclaration = ts.find(declarations, function (d) { return ts.hasEffectiveModifier(d, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(d); }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 252 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 254 /* ClassDeclaration */); } // Else this is a public property and could be accessed from anywhere. return undefined; @@ -124463,7 +129115,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (!container || container.kind === 297 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { + if (!container || container.kind === 299 /* 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; @@ -124579,8 +129231,12 @@ var ts; function isValidReferencePosition(node, searchSymbolName) { // Compare the length so we filter out strict superstrings of the symbol we are looking for switch (node.kind) { - case 79 /* PrivateIdentifier */: - case 78 /* Identifier */: + case 80 /* PrivateIdentifier */: + if (ts.isJSDocMemberName(node.parent)) { + return true; + } + // falls through I guess + case 79 /* Identifier */: return node.text.length === searchSymbolName.length; case 14 /* NoSubstitutionTemplateLiteral */: case 10 /* StringLiteral */: { @@ -124590,7 +129246,7 @@ var ts; } case 8 /* NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.text.length === searchSymbolName.length; - case 87 /* DefaultKeyword */: + case 88 /* DefaultKeyword */: return "default".length === searchSymbolName.length; default: return false; @@ -124656,7 +129312,7 @@ var ts; return; } if (ts.isExportSpecifier(parent)) { - ts.Debug.assert(referenceLocation.kind === 78 /* Identifier */); + ts.Debug.assert(referenceLocation.kind === 79 /* Identifier */); getReferencesAtExportSpecifier(referenceLocation, referenceSymbol, parent, search, state, addReferencesHere); return; } @@ -124679,6 +129335,10 @@ var ts; default: ts.Debug.assertNever(state.specialSearchKind); } + // Use the parent symbol if the location is commonjs require syntax on javascript files only. + referenceSymbol = ts.isInJSFile(referenceLocation) && referenceLocation.parent.kind === 200 /* BindingElement */ && ts.isRequireVariableDeclaration(referenceLocation.parent) + ? referenceLocation.parent.symbol + : referenceSymbol; getImportOrExportReferences(referenceLocation, referenceSymbol, search, state); } function getReferencesAtExportSpecifier(referenceLocation, referenceSymbol, exportSpecifier, search, state, addReferencesHere, alwaysGetReferences) { @@ -124712,8 +129372,8 @@ var ts; } // For `export { foo as bar }`, rename `foo`, but not `bar`. if (!isForRenameWithPrefixAndSuffixText(state.options) || alwaysGetReferences) { - var isDefaultExport = referenceLocation.originalKeywordKind === 87 /* DefaultKeyword */ - || exportSpecifier.name.originalKeywordKind === 87 /* DefaultKeyword */; + var isDefaultExport = referenceLocation.originalKeywordKind === 88 /* DefaultKeyword */ + || exportSpecifier.name.originalKeywordKind === 88 /* DefaultKeyword */; var exportKind = isDefaultExport ? 1 /* Default */ : 0 /* Named */; var exportSymbol = ts.Debug.checkDefined(exportSpecifier.symbol); var exportInfo = FindAllReferences.getExportInfo(exportSymbol, exportKind, state.checker); @@ -124794,7 +129454,7 @@ var ts; } var pusher = function () { return state.referenceAdder(search.symbol); }; if (ts.isClassLike(referenceLocation.parent)) { - ts.Debug.assert(referenceLocation.kind === 87 /* DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); + ts.Debug.assert(referenceLocation.kind === 88 /* DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); // This is the class declaration containing the constructor. findOwnConstructorReferences(search.symbol, sourceFile, pusher()); } @@ -124821,7 +129481,7 @@ var ts; } if (member.body) { member.body.forEachChild(function cb(node) { - if (node.kind === 107 /* ThisKeyword */) { + if (node.kind === 108 /* ThisKeyword */) { addRef(node); } else if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) { @@ -124840,18 +129500,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, 132 /* ConstructorKeyword */, sourceFile); - ts.Debug.assert(decl.kind === 166 /* Constructor */ && !!ctrKeyword); + var ctrKeyword = ts.findChildOfKind(decl, 133 /* ConstructorKeyword */, sourceFile); + ts.Debug.assert(decl.kind === 168 /* Constructor */ && !!ctrKeyword); addNode(ctrKeyword); } } if (classSymbol.exports) { classSymbol.exports.forEach(function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 165 /* MethodDeclaration */) { + if (decl && decl.kind === 167 /* MethodDeclaration */) { var body = decl.body; if (body) { - forEachDescendantOfKind(body, 107 /* ThisKeyword */, function (thisKeyword) { + forEachDescendantOfKind(body, 108 /* ThisKeyword */, function (thisKeyword) { if (ts.isNewExpressionTarget(thisKeyword)) { addNode(thisKeyword); } @@ -124872,10 +129532,10 @@ var ts; } for (var _i = 0, _a = constructor.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 166 /* Constructor */); + ts.Debug.assert(decl.kind === 168 /* Constructor */); var body = decl.body; if (body) { - forEachDescendantOfKind(body, 105 /* SuperKeyword */, function (node) { + forEachDescendantOfKind(body, 106 /* SuperKeyword */, function (node) { if (ts.isCallExpressionTarget(node)) { addNode(node); } @@ -124899,10 +129559,10 @@ var ts; addReference(refNode); return; } - if (refNode.kind !== 78 /* Identifier */) { + if (refNode.kind !== 79 /* Identifier */) { return; } - if (refNode.parent.kind === 289 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 291 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference); } @@ -124922,7 +129582,7 @@ var ts; } else if (ts.isFunctionLike(typeHavingNode) && typeHavingNode.body) { var body = typeHavingNode.body; - if (body.kind === 230 /* Block */) { + if (body.kind === 232 /* Block */) { ts.forEachReturnStatement(body, function (returnStatement) { if (returnStatement.expression) addIfImplementation(returnStatement.expression); @@ -124950,13 +129610,13 @@ var ts; */ function isImplementationExpression(node) { switch (node.kind) { - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return isImplementationExpression(node.expression); - case 209 /* ArrowFunction */: - case 208 /* FunctionExpression */: - case 200 /* ObjectLiteralExpression */: - case 221 /* ClassExpression */: - case 199 /* ArrayLiteralExpression */: + case 211 /* ArrowFunction */: + case 210 /* FunctionExpression */: + case 202 /* ObjectLiteralExpression */: + case 223 /* ClassExpression */: + case 201 /* ArrayLiteralExpression */: return true; default: return false; @@ -125009,13 +129669,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -125024,7 +129684,7 @@ var ts; } var sourceFile = searchSpaceNode.getSourceFile(); var references = ts.mapDefined(getPossibleSymbolReferenceNodes(sourceFile, "super", searchSpaceNode), function (node) { - if (node.kind !== 105 /* SuperKeyword */) { + if (node.kind !== 106 /* SuperKeyword */) { return; } var container = ts.getSuperContainer(node, /*stopOnFunctions*/ false); @@ -125036,41 +129696,43 @@ var ts; return [{ definition: { type: 0 /* Symbol */, symbol: searchSpaceNode.symbol }, references: references }]; } function isParameterName(node) { - return node.kind === 78 /* Identifier */ && node.parent.kind === 160 /* Parameter */ && node.parent.name === node; + return node.kind === 79 /* Identifier */ && node.parent.kind === 162 /* 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 */; switch (searchSpaceNode.kind) { - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { + staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); + searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning object literals break; } // falls through - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 297 /* SourceFile */: + case 299 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode) || isParameterName(thisOrSuperKeyword)) { return undefined; } // falls through - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 210 /* 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 === 297 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { + var references = ts.flatMap(searchSpaceNode.kind === 299 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { if (!ts.isThis(node)) { @@ -125078,19 +129740,20 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: return searchSpaceNode.symbol === container.symbol; - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: return ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol; - case 221 /* ClassExpression */: - case 252 /* ClassDeclaration */: - // Make sure the container belongs to the same class + case 223 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 202 /* 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.getSyntacticModifierFlags(container) & 32 /* Static */) === staticFlag; - case 297 /* SourceFile */: - return container.kind === 297 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); + case 299 /* SourceFile */: + return container.kind === 299 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); } }); }).map(function (n) { return nodeEntry(n); }); @@ -125200,7 +129863,7 @@ var ts; 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]); } - var exportSpecifier = ts.getDeclarationOfKind(symbol, 270 /* ExportSpecifier */); + var exportSpecifier = ts.getDeclarationOfKind(symbol, 272 /* ExportSpecifier */); if (!isForRenamePopulateSearchSymbolSet || exportSpecifier && !exportSpecifier.propertyName) { var localSymbol = exportSpecifier && checker.getExportSpecifierLocalTargetSymbol(exportSpecifier); if (localSymbol) { @@ -125245,7 +129908,7 @@ var ts; }); } function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker) { - var bindingElement = ts.getDeclarationOfKind(symbol, 198 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 200 /* BindingElement */); if (bindingElement && ts.isObjectBindingElementWithoutPropertyName(bindingElement)) { return ts.getPropertySymbolFromBindingElement(checker, bindingElement); } @@ -125449,7 +130112,7 @@ var ts; return ts.Debug.checkDefined(node.modifiers && ts.find(node.modifiers, isDefaultModifier)); } function isDefaultModifier(node) { - return node.kind === 87 /* DefaultKeyword */; + return node.kind === 88 /* DefaultKeyword */; } /** Gets the symbol for a call hierarchy declaration. */ function getSymbolOfCallHierarchyDeclaration(typeChecker, node) { @@ -125498,16 +130161,16 @@ var ts; return; } switch (node.kind) { - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 165 /* MethodDeclaration */: - if (node.parent.kind === 200 /* ObjectLiteralExpression */) { + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 167 /* MethodDeclaration */: + if (node.parent.kind === 202 /* 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 251 /* FunctionDeclaration */: - case 252 /* ClassDeclaration */: - case 256 /* ModuleDeclaration */: + case 253 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: + case 258 /* ModuleDeclaration */: if (ts.isModuleBlock(node.parent) && ts.isIdentifier(node.parent.parent.name)) { return node.parent.parent.name.getText(); } @@ -125712,56 +130375,56 @@ var ts; return; } switch (node.kind) { - case 78 /* Identifier */: - case 260 /* ImportEqualsDeclaration */: - case 261 /* ImportDeclaration */: - case 267 /* ExportDeclaration */: - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 79 /* Identifier */: + case 262 /* ImportEqualsDeclaration */: + case 263 /* ImportDeclaration */: + case 269 /* ExportDeclaration */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: // do not descend into nodes that cannot contain callable nodes return; - case 206 /* TypeAssertionExpression */: - case 224 /* AsExpression */: + case 208 /* TypeAssertionExpression */: + case 226 /* AsExpression */: // do not descend into the type side of an assertion collect(node.expression); return; - case 249 /* VariableDeclaration */: - case 160 /* Parameter */: + case 251 /* VariableDeclaration */: + case 162 /* Parameter */: // do not descend into the type of a variable or parameter declaration collect(node.name); collect(node.initializer); return; - case 203 /* CallExpression */: + case 205 /* CallExpression */: // do not descend into the type arguments of a call expression recordCallSite(node); collect(node.expression); ts.forEach(node.arguments, collect); return; - case 204 /* NewExpression */: + case 206 /* NewExpression */: // do not descend into the type arguments of a new expression recordCallSite(node); collect(node.expression); ts.forEach(node.arguments, collect); return; - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: // do not descend into the type arguments of a tagged template expression recordCallSite(node); collect(node.tag); collect(node.template); return; - case 275 /* JsxOpeningElement */: - case 274 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: // do not descend into the type arguments of a JsxOpeningLikeElement recordCallSite(node); collect(node.tagName); collect(node.attributes); return; - case 161 /* Decorator */: + case 163 /* Decorator */: recordCallSite(node); collect(node.expression); return; - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: recordCallSite(node); ts.forEachChild(node, collect); break; @@ -125811,22 +130474,22 @@ var ts; var callSites = []; var collect = createCallSiteCollector(program, callSites); switch (node.kind) { - case 297 /* SourceFile */: + case 299 /* SourceFile */: collectCallSitesOfSourceFile(node, collect); break; - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: collectCallSitesOfModuleDeclaration(node, collect); break; - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: collectCallSitesOfFunctionLikeDeclaration(program.getTypeChecker(), node, collect); break; - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: collectCallSitesOfClassLikeDeclaration(node, collect); break; default: @@ -125959,7 +130622,7 @@ var ts; } function updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName) { var allFiles = program.getSourceFiles(); - var _loop_4 = function (sourceFile) { + var _loop_5 = function (sourceFile) { var newFromOld = oldToNew(sourceFile.fileName); var newImportFromPath = newFromOld !== null && newFromOld !== void 0 ? newFromOld : sourceFile.fileName; var newImportFromDirectory = ts.getDirectoryPath(newImportFromPath); @@ -125976,7 +130639,7 @@ var ts; }, function (importLiteral) { var importedModuleSymbol = program.getTypeChecker().getSymbolAtLocation(importLiteral); // No need to update if it's an ambient module^M - if (importedModuleSymbol && importedModuleSymbol.declarations.some(function (d) { return ts.isAmbientModule(d); })) + if ((importedModuleSymbol === null || importedModuleSymbol === void 0 ? void 0 : importedModuleSymbol.declarations) && importedModuleSymbol.declarations.some(function (d) { return ts.isAmbientModule(d); })) return undefined; var toImport = oldFromNew !== undefined // If we're at the new location (file was already renamed), need to redo module resolution starting from the old location. @@ -125991,7 +130654,7 @@ var ts; }; for (var _i = 0, allFiles_1 = allFiles; _i < allFiles_1.length; _i++) { var sourceFile = allFiles_1[_i]; - _loop_4(sourceFile); + _loop_5(sourceFile); } } function combineNormal(pathA, pathB) { @@ -126082,8 +130745,10 @@ var ts; (function (GoToDefinition) { function getDefinitionAtPosition(program, sourceFile, position) { var resolvedRef = getReferenceAtPosition(sourceFile, position, program); - if (resolvedRef) { - return [getDefinitionInfoForFileReference(resolvedRef.reference.fileName, resolvedRef.file.fileName)]; + var fileReferenceDefinition = resolvedRef && [getDefinitionInfoForFileReference(resolvedRef.reference.fileName, resolvedRef.fileName, resolvedRef.unverified)] || ts.emptyArray; + if (resolvedRef === null || resolvedRef === void 0 ? void 0 : resolvedRef.file) { + // If `file` is missing, do a symbol-based lookup as well + return fileReferenceDefinition; } var node = ts.getTouchingPropertyName(sourceFile, position); if (node === sourceFile) { @@ -126100,7 +130765,7 @@ var ts; // Could not find a symbol e.g. node is string or number keyword, // or the symbol was an internal symbol and does not have a declaration e.g. undefined symbol if (!symbol) { - return getDefinitionInfoForIndexSignatures(node, typeChecker); + return ts.concatenate(fileReferenceDefinition, getDefinitionInfoForIndexSignatures(node, typeChecker)); } var calledDeclaration = tryGetSignatureDeclaration(typeChecker, node); // Don't go to the component constructor definition for a JSX element, just go to the component definition. @@ -126114,7 +130779,7 @@ var ts; else { var defs = getDefinitionFromSymbol(typeChecker, symbol, node, calledDeclaration) || ts.emptyArray; // For a 'super()' call, put the signature first, else put the variable first. - return node.kind === 105 /* SuperKeyword */ ? __spreadArray([sigInfo], defs) : __spreadArray(__spreadArray([], defs), [sigInfo]); + return node.kind === 106 /* SuperKeyword */ ? __spreadArray([sigInfo], defs) : __spreadArray(__spreadArray([], defs), [sigInfo]); } } // Because name in short-hand property assignment has two different meanings: property name and property value, @@ -126122,9 +130787,10 @@ 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 === 289 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 291 /* ShorthandPropertyAssignment */) { var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); - return shorthandSymbol_1 ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node); }) : []; + 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); }) : ts.emptyArray; + return ts.concatenate(definitions, getDefinitionFromObjectLiteralElement(typeChecker, node) || ts.emptyArray); } // If the node is the name of a BindingElement within an ObjectBindingPattern instead of just returning the // declaration the symbol (which is itself), we should try to get to the original type of the ObjectBindingPattern @@ -126146,25 +130812,7 @@ var ts; return prop && getDefinitionFromSymbol(typeChecker, prop, node); }); } - // If the current location we want to find its definition is in an object literal, try to get the contextual type for the - // object literal, lookup the property symbol in the contextual type, and use this for goto-definition. - // For example - // interface Props{ - // /*first*/prop1: number - // prop2: boolean - // } - // function Foo(arg: Props) {} - // Foo( { pr/*1*/op1: 10, prop2: true }) - var element = ts.getContainingObjectLiteralElement(node); - if (element) { - var contextualType = element && typeChecker.getContextualType(element.parent); - if (contextualType) { - return ts.flatMap(ts.getPropertySymbolsFromContextualType(element, typeChecker, contextualType, /*unionSymbolOk*/ false), function (propertySymbol) { - return getDefinitionFromSymbol(typeChecker, propertySymbol, node); - }); - } - } - return getDefinitionFromSymbol(typeChecker, symbol, node); + return ts.concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node)); } GoToDefinition.getDefinitionAtPosition = getDefinitionAtPosition; /** @@ -126178,22 +130826,60 @@ var ts; || ts.isAssignmentExpression(calledDeclaration.parent) || (!ts.isCallLikeExpression(calledDeclaration.parent) && s === calledDeclaration.parent.symbol); } + // If the current location we want to find its definition is in an object literal, try to get the contextual type for the + // object literal, lookup the property symbol in the contextual type, and use this for goto-definition. + // For example + // interface Props{ + // /*first*/prop1: number + // prop2: boolean + // } + // function Foo(arg: Props) {} + // Foo( { pr/*1*/op1: 10, prop2: true }) + function getDefinitionFromObjectLiteralElement(typeChecker, node) { + var element = ts.getContainingObjectLiteralElement(node); + if (element) { + var contextualType = element && typeChecker.getContextualType(element.parent); + if (contextualType) { + return ts.flatMap(ts.getPropertySymbolsFromContextualType(element, typeChecker, contextualType, /*unionSymbolOk*/ false), function (propertySymbol) { + return getDefinitionFromSymbol(typeChecker, propertySymbol, node); + }); + } + } + } function getReferenceAtPosition(sourceFile, position, program) { + var _a, _b; var referencePath = findReferenceInPosition(sourceFile.referencedFiles, position); if (referencePath) { var file = program.getSourceFileFromReference(sourceFile, referencePath); - return file && { reference: referencePath, file: file }; + return file && { reference: referencePath, fileName: file.fileName, file: file, unverified: false }; } var typeReferenceDirective = findReferenceInPosition(sourceFile.typeReferenceDirectives, position); if (typeReferenceDirective) { var reference = program.getResolvedTypeReferenceDirectives().get(typeReferenceDirective.fileName); var file = reference && program.getSourceFile(reference.resolvedFileName); // TODO:GH#18217 - return file && { reference: typeReferenceDirective, file: file }; + return file && { reference: typeReferenceDirective, fileName: file.fileName, file: file, unverified: false }; } var libReferenceDirective = findReferenceInPosition(sourceFile.libReferenceDirectives, position); if (libReferenceDirective) { var file = program.getLibFileFromReference(libReferenceDirective); - return file && { reference: libReferenceDirective, file: file }; + return file && { reference: libReferenceDirective, fileName: file.fileName, file: file, unverified: false }; + } + if ((_a = sourceFile.resolvedModules) === null || _a === void 0 ? void 0 : _a.size) { + var node = ts.getTokenAtPosition(sourceFile, position); + if (ts.isModuleSpecifierLike(node) && ts.isExternalModuleNameRelative(node.text) && sourceFile.resolvedModules.has(node.text)) { + var verifiedFileName = (_b = sourceFile.resolvedModules.get(node.text)) === null || _b === void 0 ? void 0 : _b.resolvedFileName; + var fileName = verifiedFileName || ts.resolvePath(ts.getDirectoryPath(sourceFile.fileName), node.text); + return { + file: program.getSourceFile(fileName), + fileName: fileName, + reference: { + pos: node.getStart(), + end: node.getEnd(), + fileName: node.text + }, + unverified: !verifiedFileName, + }; + } } return undefined; } @@ -126264,7 +130950,7 @@ var ts; // get the aliased symbol instead. This allows for goto def on an import e.g. // import {A, B} from "mod"; // to jump to the implementation directly. - if (symbol && symbol.flags & 2097152 /* Alias */ && shouldSkipAlias(node, symbol.declarations[0])) { + if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.flags & 2097152 /* Alias */ && shouldSkipAlias(node, symbol.declarations[0])) { var aliased = checker.getAliasedSymbol(symbol); if (aliased.declarations) { return aliased; @@ -126278,21 +130964,21 @@ var ts; // (2) when the aliased symbol is originating from an import. // function shouldSkipAlias(node, declaration) { - if (node.kind !== 78 /* Identifier */) { + if (node.kind !== 79 /* Identifier */) { return false; } if (node.parent === declaration) { return true; } switch (declaration.kind) { - case 262 /* ImportClause */: - case 260 /* ImportEqualsDeclaration */: + case 264 /* ImportClause */: + case 262 /* ImportEqualsDeclaration */: return true; - case 265 /* ImportSpecifier */: - return declaration.parent.kind === 264 /* NamedImports */; - case 198 /* BindingElement */: - case 249 /* VariableDeclaration */: - return ts.isInJSFile(declaration) && ts.isRequireVariableDeclaration(declaration, /*requireStringLiteralLikeArgument*/ true); + case 267 /* ImportSpecifier */: + return declaration.parent.kind === 266 /* NamedImports */; + case 200 /* BindingElement */: + case 251 /* VariableDeclaration */: + return ts.isInJSFile(declaration) && ts.isRequireVariableDeclaration(declaration); default: return false; } @@ -126307,7 +130993,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 === 132 /* ConstructorKeyword */)) { + if (symbol.flags & 32 /* Class */ && !(symbol.flags & (16 /* Function */ | 3 /* Variable */)) && (ts.isNewExpressionTarget(node) || node.kind === 133 /* 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); } @@ -126344,7 +131030,38 @@ var ts; var sourceFile = name.getSourceFile(); var 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: !checker.isDeclarationVisible(declaration) }); + containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration) }); + } + function isDefinitionVisible(checker, declaration) { + if (checker.isDeclarationVisible(declaration)) + return true; + if (!declaration.parent) + return false; + // Variable initializers are visible if variable is visible + if (ts.hasInitializer(declaration.parent) && declaration.parent.initializer === declaration) + 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 165 /* PropertyDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 167 /* MethodDeclaration */: + // Private/protected properties/methods are not visible + if (ts.hasEffectiveModifier(declaration, 8 /* Private */)) + return false; + // Public properties/methods are visible if its parents are visible, so: + // falls through + case 168 /* Constructor */: + case 290 /* PropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: + case 202 /* ObjectLiteralExpression */: + case 223 /* ClassExpression */: + case 211 /* ArrowFunction */: + case 210 /* FunctionExpression */: + return isDefinitionVisible(checker, declaration.parent); + default: + return false; + } } function createDefinitionFromSignatureDeclaration(typeChecker, decl) { return createDefinitionInfo(decl, typeChecker, decl.symbol, decl); @@ -126353,14 +131070,15 @@ var ts; return ts.find(refs, function (ref) { return ts.textRangeContainsPositionInclusive(ref, pos); }); } GoToDefinition.findReferenceInPosition = findReferenceInPosition; - function getDefinitionInfoForFileReference(name, targetFileName) { + function getDefinitionInfoForFileReference(name, targetFileName, unverified) { return { fileName: targetFileName, textSpan: ts.createTextSpanFromBounds(0, 0), kind: "script" /* scriptElement */, name: name, containerName: undefined, - containerKind: undefined, // TODO: GH#18217 + containerKind: undefined, + unverified: unverified, }; } /** Returns a CallLikeExpression where `node` is the target being invoked. */ @@ -126377,9 +131095,9 @@ var ts; } function isConstructorLike(node) { switch (node.kind) { - case 166 /* Constructor */: - case 175 /* ConstructorType */: - case 170 /* ConstructSignature */: + case 168 /* Constructor */: + case 177 /* ConstructorType */: + case 172 /* ConstructSignature */: return true; default: return false; @@ -126436,6 +131154,7 @@ var ts; "kind", "lends", "license", + "link", "listens", "member", "memberof", @@ -126473,78 +131192,115 @@ var ts; ]; var jsDocTagNameCompletionEntries; var jsDocTagCompletionEntries; - function getJsDocCommentsFromDeclarations(declarations) { + function getJsDocCommentsFromDeclarations(declarations, checker) { // Only collect doc comments from duplicate declarations once: // In case of a union property there might be same declaration multiple times // which only varies in type parameter // Eg. const a: Array | Array; a.length // The property length will have two declarations of property length coming // from Array - Array and Array - var documentationComment = []; + var parts = []; ts.forEachUnique(declarations, function (declaration) { for (var _i = 0, _a = getCommentHavingNodes(declaration); _i < _a.length; _i++) { var comment = _a[_i].comment; if (comment === undefined) continue; - ts.pushIfUnique(documentationComment, comment); + var newparts = getDisplayPartsFromComment(comment, checker); + if (!ts.contains(parts, newparts, isIdenticalListOfDisplayParts)) { + parts.push(newparts); + } } }); - return ts.intersperse(ts.map(documentationComment, ts.textPart), ts.lineBreakPart()); + return ts.flatten(ts.intersperse(parts, [ts.lineBreakPart()])); } JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; + function isIdenticalListOfDisplayParts(parts1, parts2) { + return ts.arraysEqual(parts1, parts2, function (p1, p2) { return p1.kind === p2.kind && p1.text === p2.text; }); + } function getCommentHavingNodes(declaration) { switch (declaration.kind) { - case 326 /* JSDocParameterTag */: - case 333 /* JSDocPropertyTag */: + case 334 /* JSDocParameterTag */: + case 341 /* JSDocPropertyTag */: return [declaration]; - case 324 /* JSDocCallbackTag */: - case 331 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + case 339 /* JSDocTypedefTag */: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); } } - function getJsDocTagsFromDeclarations(declarations) { + function getJsDocTagsFromDeclarations(declarations, checker) { // Only collect doc comments from duplicate declarations once. var tags = []; ts.forEachUnique(declarations, function (declaration) { for (var _i = 0, _a = ts.getJSDocTags(declaration); _i < _a.length; _i++) { var tag = _a[_i]; - tags.push({ name: tag.tagName.text, text: getCommentText(tag) }); + tags.push({ name: tag.tagName.text, text: getCommentDisplayParts(tag, checker) }); } }); return tags; } JsDoc.getJsDocTagsFromDeclarations = getJsDocTagsFromDeclarations; - function getCommentText(tag) { - var comment = tag.comment; - switch (tag.kind) { - case 316 /* JSDocImplementsTag */: + function getDisplayPartsFromComment(comment, checker) { + if (typeof comment === "string") { + return [ts.textPart(comment)]; + } + return ts.flatMap(comment, function (node) { return node.kind === 315 /* 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 323 /* JSDocImplementsTag */: return withNode(tag.class); - case 315 /* JSDocAugmentsTag */: + case 322 /* JSDocAugmentsTag */: return withNode(tag.class); - case 330 /* JSDocTemplateTag */: - return withList(tag.typeParameters); - case 329 /* JSDocTypeTag */: + case 338 /* JSDocTemplateTag */: + return addComment(tag.typeParameters.map(function (tp) { return tp.getText(); }).join(", ")); + case 337 /* JSDocTypeTag */: return withNode(tag.typeExpression); - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 333 /* JSDocPropertyTag */: - case 326 /* JSDocParameterTag */: - case 332 /* JSDocSeeTag */: + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + case 341 /* JSDocPropertyTag */: + case 334 /* JSDocParameterTag */: + case 340 /* JSDocSeeTag */: var name = tag.name; - return name ? withNode(name) : comment; + return name ? withNode(name) + : comment === undefined ? undefined + : getDisplayPartsFromComment(comment, checker); default: - return comment; + return comment === undefined ? undefined : getDisplayPartsFromComment(comment, checker); } function withNode(node) { return addComment(node.getText()); } - function withList(list) { - return addComment(list.map(function (x) { return x.getText(); }).join(", ")); - } function addComment(s) { - return comment === undefined ? s : s + " " + comment; + if (comment) { + if (s.match(/^https?$/)) { + return __spreadArray([ts.textPart(s)], getDisplayPartsFromComment(comment, checker)); + } + else { + return __spreadArray([namePart(s), ts.spacePart()], getDisplayPartsFromComment(comment, checker)); + } + } + else { + return [ts.textPart(s)]; + } + } + } + function getTagNameDisplayPart(kind) { + switch (kind) { + case 334 /* JSDocParameterTag */: + return ts.parameterNamePart; + case 341 /* JSDocPropertyTag */: + return ts.propertyNamePart; + case 338 /* JSDocTemplateTag */: + return ts.typeParameterNamePart; + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + return ts.typeAliasNamePart; + default: + return ts.textPart; } } function getJSDocTagNameCompletions() { @@ -126638,7 +131394,7 @@ var ts; * @param position The (character-indexed) position in the file where the check should * be performed. */ - function getDocCommentTemplateAtPosition(newLine, sourceFile, position) { + function getDocCommentTemplateAtPosition(newLine, sourceFile, position, options) { var tokenAtPos = ts.getTokenAtPosition(sourceFile, position); var existingDocComment = ts.findAncestor(tokenAtPos, ts.isJSDoc); if (existingDocComment && (existingDocComment.comment !== undefined || ts.length(existingDocComment.tags))) { @@ -126650,7 +131406,7 @@ var ts; if (!existingDocComment && tokenStart < position) { return undefined; } - var commentOwnerInfo = getCommentOwnerInfo(tokenAtPos); + var commentOwnerInfo = getCommentOwnerInfo(tokenAtPos, options); if (!commentOwnerInfo) { return undefined; } @@ -126692,7 +131448,7 @@ 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 === 78 /* Identifier */ ? name.text : "param" + i; + var paramName = name.kind === 79 /* Identifier */ ? name.text : "param" + i; var type = isJavaScriptFile ? (dotDotDotToken ? "{...any} " : "{any} ") : ""; return indentationStr + " * @param " + type + paramName + newLine; }).join(""); @@ -126700,76 +131456,77 @@ var ts; function returnsDocComment(indentationStr, newLine) { return indentationStr + " * @returns" + newLine; } - function getCommentOwnerInfo(tokenAtPos) { - return ts.forEachAncestor(tokenAtPos, getCommentOwnerInfoWorker); + function getCommentOwnerInfo(tokenAtPos, options) { + return ts.forEachAncestor(tokenAtPos, function (n) { return getCommentOwnerInfoWorker(n, options); }); } - function getCommentOwnerInfoWorker(commentOwner) { + function getCommentOwnerInfoWorker(commentOwner, options) { switch (commentOwner.kind) { - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: - case 164 /* MethodSignature */: - case 209 /* ArrowFunction */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 167 /* MethodDeclaration */: + case 168 /* Constructor */: + case 166 /* MethodSignature */: + case 211 /* ArrowFunction */: var host = commentOwner; - return { commentOwner: commentOwner, parameters: host.parameters, hasReturn: hasReturn(host) }; - case 288 /* PropertyAssignment */: - return getCommentOwnerInfoWorker(commentOwner.initializer); - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 162 /* PropertySignature */: - case 255 /* EnumDeclaration */: - case 291 /* EnumMember */: - case 254 /* TypeAliasDeclaration */: + return { commentOwner: commentOwner, parameters: host.parameters, hasReturn: hasReturn(host, options) }; + case 290 /* PropertyAssignment */: + return getCommentOwnerInfoWorker(commentOwner.initializer, options); + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 164 /* PropertySignature */: + case 257 /* EnumDeclaration */: + case 293 /* EnumMember */: + case 256 /* TypeAliasDeclaration */: return { commentOwner: commentOwner }; - case 232 /* VariableStatement */: { + case 234 /* VariableStatement */: { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; var host_1 = varDeclarations.length === 1 && varDeclarations[0].initializer ? getRightHandSideOfAssignment(varDeclarations[0].initializer) : undefined; return host_1 - ? { commentOwner: commentOwner, parameters: host_1.parameters, hasReturn: hasReturn(host_1) } + ? { commentOwner: commentOwner, parameters: host_1.parameters, hasReturn: hasReturn(host_1, options) } : { commentOwner: commentOwner }; } - case 297 /* SourceFile */: + case 299 /* SourceFile */: return "quit"; - case 256 /* ModuleDeclaration */: + case 258 /* 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 === 256 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; - case 233 /* ExpressionStatement */: - return getCommentOwnerInfoWorker(commentOwner.expression); - case 216 /* BinaryExpression */: { + return commentOwner.parent.kind === 258 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; + case 235 /* ExpressionStatement */: + return getCommentOwnerInfoWorker(commentOwner.expression, options); + case 218 /* BinaryExpression */: { var be = commentOwner; if (ts.getAssignmentDeclarationKind(be) === 0 /* None */) { return "quit"; } return ts.isFunctionLike(be.right) - ? { commentOwner: commentOwner, parameters: be.right.parameters, hasReturn: hasReturn(be.right) } + ? { commentOwner: commentOwner, parameters: be.right.parameters, hasReturn: hasReturn(be.right, options) } : { commentOwner: commentOwner }; } - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: var init = commentOwner.initializer; if (init && (ts.isFunctionExpression(init) || ts.isArrowFunction(init))) { - return { commentOwner: commentOwner, parameters: init.parameters, hasReturn: hasReturn(init) }; + return { commentOwner: commentOwner, parameters: init.parameters, hasReturn: hasReturn(init, options) }; } } } - function hasReturn(node) { - return ts.isArrowFunction(node) && ts.isExpression(node.body) - || ts.isFunctionLikeDeclaration(node) && node.body && ts.isBlock(node.body) && !!ts.forEachReturnStatement(node.body, function (n) { return n; }); + function hasReturn(node, options) { + return !!(options === null || options === void 0 ? void 0 : options.generateReturnInDocTemplate) && + (ts.isArrowFunction(node) && ts.isExpression(node.body) + || ts.isFunctionLikeDeclaration(node) && node.body && ts.isBlock(node.body) && !!ts.forEachReturnStatement(node.body, function (n) { return n; })); } function getRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 207 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 209 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return rightHandSide; - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: return ts.find(rightHandSide.members, ts.isConstructorDeclaration); } } @@ -126785,7 +131542,7 @@ var ts; if (!patternMatcher) return ts.emptyArray; var rawItems = []; - var _loop_5 = function (sourceFile) { + var _loop_6 = function (sourceFile) { cancellationToken.throwIfCancellationRequested(); if (excludeDtsFiles && sourceFile.isDeclarationFile) { return "continue"; @@ -126797,7 +131554,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_5(sourceFile); + _loop_6(sourceFile); } rawItems.sort(compareNavigateToItems); return (maxResultCount === undefined ? rawItems : rawItems.slice(0, maxResultCount)).map(createNavigateToItem); @@ -126828,9 +131585,9 @@ var ts; } function shouldKeepItem(declaration, checker) { switch (declaration.kind) { - case 262 /* ImportClause */: - case 265 /* ImportSpecifier */: - case 260 /* ImportEqualsDeclaration */: + case 264 /* ImportClause */: + case 267 /* ImportSpecifier */: + case 262 /* ImportEqualsDeclaration */: var importer = checker.getSymbolAtLocation(declaration.name); // TODO: GH#18217 var imported = checker.getAliasedSymbol(importer); return importer.escapedName !== imported.escapedName; @@ -126840,7 +131597,7 @@ var ts; } function tryAddSingleDeclarationName(declaration, containers) { var name = ts.getNameOfDeclaration(declaration); - return !!name && (pushLiteral(name, containers) || name.kind === 158 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); + return !!name && (pushLiteral(name, containers) || name.kind === 160 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); } // Only added the names of computed properties if they're simple dotted expressions, like: // @@ -126857,7 +131614,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 === 158 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { + if (name && name.kind === 160 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { return ts.emptyArray; } // Don't include the last portion. @@ -127057,6 +131814,28 @@ var ts; addChildrenRecursively(child); endNode(); } + function addNodeWithRecursiveInitializer(node) { + if (node.initializer && isFunctionOrClassExpression(node.initializer)) { + startNode(node); + ts.forEachChild(node.initializer, addChildrenRecursively); + endNode(); + } + else { + addNodeWithRecursiveChild(node, node.initializer); + } + } + /** + * Historically, we've elided dynamic names from the nav tree (including late bound names), + * but included certain "well known" symbol names. While we no longer distinguish those well-known + * symbols from other unique symbols, we do the below to retain those members in the nav tree. + */ + function hasNavigationBarName(node) { + return !ts.hasDynamicName(node) || + (node.kind !== 218 /* BinaryExpression */ && + ts.isPropertyAccessExpression(node.name.expression) && + ts.isIdentifier(node.name.expression.expression) && + ts.idText(node.name.expression.expression) === "Symbol"); + } /** Look for navigation bar items in node's subtree, adding them to the current `parent`. */ function addChildrenRecursively(node) { var _a; @@ -127065,7 +131844,7 @@ var ts; return; } switch (node.kind) { - case 166 /* Constructor */: + case 168 /* 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); @@ -127077,21 +131856,25 @@ var ts; } } break; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 164 /* MethodSignature */: - if (!ts.hasDynamicName(node)) { + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 166 /* MethodSignature */: + if (hasNavigationBarName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - if (!ts.hasDynamicName(node)) { + case 165 /* PropertyDeclaration */: + if (hasNavigationBarName(node)) { + addNodeWithRecursiveInitializer(node); + } + break; + case 164 /* PropertySignature */: + if (hasNavigationBarName(node)) { addLeafNode(node); } break; - case 262 /* ImportClause */: + case 264 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -127103,7 +131886,7 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 263 /* NamespaceImport */) { + if (namedBindings.kind === 265 /* NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -127114,32 +131897,27 @@ var ts; } } break; - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: addNodeWithRecursiveChild(node, node.name); break; - case 290 /* SpreadAssignment */: + case 292 /* 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 198 /* BindingElement */: - case 288 /* PropertyAssignment */: - case 249 /* VariableDeclaration */: - var _e = node, name = _e.name, initializer = _e.initializer; - if (ts.isBindingPattern(name)) { - addChildrenRecursively(name); - } - else if (initializer && isFunctionOrClassExpression(initializer)) { - // Add a node for the VariableDeclaration, but not for the initializer. - startNode(node); - ts.forEachChild(initializer, addChildrenRecursively); - endNode(); + case 200 /* BindingElement */: + case 290 /* PropertyAssignment */: + case 251 /* VariableDeclaration */: { + var child = node; + if (ts.isBindingPattern(child.name)) { + addChildrenRecursively(child.name); } else { - addNodeWithRecursiveChild(node, initializer); + addNodeWithRecursiveInitializer(child); } break; - case 251 /* FunctionDeclaration */: + } + case 253 /* FunctionDeclaration */: var nameNode = node.name; // If we see a function declaration track as a possible ES5 class if (nameNode && ts.isIdentifier(nameNode)) { @@ -127147,34 +131925,34 @@ var ts; } addNodeWithRecursiveChild(node, node.body); break; - case 209 /* ArrowFunction */: - case 208 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 210 /* FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: startNode(node); - for (var _f = 0, _g = node.members; _f < _g.length; _f++) { - var member = _g[_f]; + for (var _e = 0, _f = node.members; _e < _f.length; _e++) { + var member = _f[_e]; if (!isComputedProperty(member)) { addLeafNode(member); } } endNode(); break; - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: startNode(node); - for (var _h = 0, _j = node.members; _h < _j.length; _h++) { - var member = _j[_h]; + for (var _g = 0, _h = node.members; _g < _h.length; _g++) { + var member = _h[_g]; addChildrenRecursively(member); } endNode(); break; - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 266 /* ExportAssignment */: { + case 268 /* 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; @@ -127188,16 +131966,16 @@ var ts; } break; } - case 270 /* ExportSpecifier */: - case 260 /* ImportEqualsDeclaration */: - case 171 /* IndexSignature */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 254 /* TypeAliasDeclaration */: + case 272 /* ExportSpecifier */: + case 262 /* ImportEqualsDeclaration */: + case 173 /* IndexSignature */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 256 /* TypeAliasDeclaration */: addLeafNode(node); break; - case 203 /* CallExpression */: - case 216 /* BinaryExpression */: { + case 205 /* CallExpression */: + case 218 /* BinaryExpression */: { var special = ts.getAssignmentDeclarationKind(node); switch (special) { case 1 /* ExportsProperty */: @@ -127249,7 +132027,7 @@ var ts; defineCall.arguments[0] : defineCall.arguments[0].expression; var memberName = defineCall.arguments[1]; - var _k = startNestedNodes(node, className), depth = _k[0], classNameIdentifier = _k[1]; + var _j = startNestedNodes(node, className), depth = _j[0], classNameIdentifier = _j[1]; startNode(node, classNameIdentifier); startNode(node, ts.setTextRange(ts.factory.createIdentifier(memberName.text), memberName)); addChildrenRecursively(node.arguments[2]); @@ -127439,13 +132217,14 @@ var ts; return false; } switch (a.kind) { - case 163 /* PropertyDeclaration */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return ts.hasSyntacticModifier(a, 32 /* Static */) === ts.hasSyntacticModifier(b, 32 /* Static */); - case 256 /* ModuleDeclaration */: - return areSameModule(a, b); + case 258 /* ModuleDeclaration */: + return areSameModule(a, b) + && getFullyQualifiedModuleName(a) === getFullyQualifiedModuleName(b); default: return true; } @@ -127462,8 +132241,7 @@ var ts; // We use 1 NavNode to represent 'A.B.C', but there are multiple source nodes. // Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'! function areSameModule(a, b) { - // TODO: GH#18217 - return a.body.kind === b.body.kind && (a.body.kind !== 256 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); + return a.body.kind === b.body.kind && (a.body.kind !== 258 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); } /** Merge source into target. Source should be thrown away after this is called. */ function merge(target, source) { @@ -127493,7 +132271,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 256 /* ModuleDeclaration */) { + if (node.kind === 258 /* ModuleDeclaration */) { return getModuleName(node); } var declName = ts.getNameOfDeclaration(node); @@ -127502,16 +132280,16 @@ var ts; return propertyName && ts.unescapeLeadingUnderscores(propertyName); } switch (node.kind) { - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 221 /* ClassExpression */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 223 /* ClassExpression */: return getFunctionOrClassName(node); default: return undefined; } } function getItemName(node, name) { - if (node.kind === 256 /* ModuleDeclaration */) { + if (node.kind === 258 /* ModuleDeclaration */) { return cleanText(getModuleName(node)); } if (name) { @@ -127523,18 +132301,18 @@ var ts; } } switch (node.kind) { - case 297 /* SourceFile */: + case 299 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return ts.isExportAssignment(node) && node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; - case 209 /* ArrowFunction */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 211 /* ArrowFunction */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: if (ts.getSyntacticModifierFlags(node) & 512 /* Default */) { return "default"; } @@ -127542,13 +132320,13 @@ var ts; // (eg: "app\n.onactivated"), so we should remove the whitespace for readability in the // navigation bar. return getFunctionOrClassName(node); - case 166 /* Constructor */: + case 168 /* Constructor */: return "constructor"; - case 170 /* ConstructSignature */: + case 172 /* ConstructSignature */: return "new()"; - case 169 /* CallSignature */: + case 171 /* CallSignature */: return "()"; - case 171 /* IndexSignature */: + case 173 /* IndexSignature */: return "[]"; default: return ""; @@ -127581,19 +132359,19 @@ var ts; } // Some nodes are otherwise important enough to always include in the primary navigation menu. switch (navigationBarNodeKind(item)) { - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 255 /* EnumDeclaration */: - case 253 /* InterfaceDeclaration */: - case 256 /* ModuleDeclaration */: - case 297 /* SourceFile */: - case 254 /* TypeAliasDeclaration */: - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 257 /* EnumDeclaration */: + case 255 /* InterfaceDeclaration */: + case 258 /* ModuleDeclaration */: + case 299 /* SourceFile */: + case 256 /* TypeAliasDeclaration */: + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: return true; - case 209 /* ArrowFunction */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -127603,10 +132381,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 257 /* ModuleBlock */: - case 297 /* SourceFile */: - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: + case 259 /* ModuleBlock */: + case 299 /* SourceFile */: + case 167 /* MethodDeclaration */: + case 168 /* Constructor */: return true; default: return false; @@ -127663,9 +132441,12 @@ var ts; if (ts.isAmbientModule(moduleDeclaration)) { return ts.getTextOfNode(moduleDeclaration.name); } + return getFullyQualifiedModuleName(moduleDeclaration); + } + 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 === 256 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 258 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); } @@ -127679,13 +132460,13 @@ var ts; return decl.body && ts.isModuleDeclaration(decl.body) ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 158 /* ComputedPropertyName */; + return !member.name || member.name.kind === 160 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 297 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); + return node.kind === 299 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { - if (node.parent && node.parent.kind === 249 /* VariableDeclaration */) { + if (node.parent && node.parent.kind === 251 /* VariableDeclaration */) { node = node.parent; } return ts.getNodeModifiers(node); @@ -127700,7 +132481,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 === 62 /* EqualsToken */) { + else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */) { return nodeText(parent.left).replace(whiteSpaceRegex, ""); } // See if it is a property assignment, and if so use the property name @@ -127743,9 +132524,9 @@ var ts; } function isFunctionOrClassExpression(node) { switch (node.kind) { - case 209 /* ArrowFunction */: - case 208 /* FunctionExpression */: - case 221 /* ClassExpression */: + case 211 /* ArrowFunction */: + case 210 /* FunctionExpression */: + case 223 /* ClassExpression */: return true; default: return false; @@ -127774,9 +132555,9 @@ var ts; * 2) Coalescing imports from the same module * 3) Sorting imports */ - function organizeImports(sourceFile, formatContext, host, program, preferences) { + function organizeImports(sourceFile, formatContext, host, program, preferences, skipDestructiveCodeActions) { var changeTracker = ts.textChanges.ChangeTracker.fromContext({ host: host, formatContext: formatContext, preferences: preferences }); - var coalesceAndOrganizeImports = function (importGroup) { return ts.stableSort(coalesceImports(removeUnusedImports(importGroup, sourceFile, program)), function (s1, s2) { return compareImportsOrRequireStatements(s1, s2); }); }; + var coalesceAndOrganizeImports = function (importGroup) { return ts.stableSort(coalesceImports(removeUnusedImports(importGroup, sourceFile, program, skipDestructiveCodeActions)), function (s1, s2) { return compareImportsOrRequireStatements(s1, s2); }); }; // All of the old ImportDeclarations in the file, in syntactic order. var topLevelImportDecls = sourceFile.statements.filter(ts.isImportDeclaration); organizeImportsWorker(topLevelImportDecls, coalesceAndOrganizeImports); @@ -127811,26 +132592,35 @@ var ts; ? coalesce(importGroup) : importGroup; }); - // Delete or replace the first import. + // Delete all nodes if there are no imports. if (newImportDecls.length === 0) { - changeTracker.delete(sourceFile, oldImportDecls[0]); + // Consider the first node to have trailingTrivia as we want to exclude the + // "header" comment. + changeTracker.deleteNodes(sourceFile, oldImportDecls, { + trailingTriviaOption: ts.textChanges.TrailingTriviaOption.Include, + }, /*hasTrailingComment*/ true); } else { // Note: Delete the surrounding trivia because it will have been retained in newImportDecls. - changeTracker.replaceNodeWithNodes(sourceFile, oldImportDecls[0], newImportDecls, { + var replaceOptions = { leadingTriviaOption: ts.textChanges.LeadingTriviaOption.Exclude, trailingTriviaOption: ts.textChanges.TrailingTriviaOption.Include, suffix: ts.getNewLineOrDefaultFromHost(host, formatContext.options), - }); - } - // Delete any subsequent imports. - for (var i = 1; i < oldImportDecls.length; i++) { - changeTracker.deleteNode(sourceFile, oldImportDecls[i]); + }; + changeTracker.replaceNodeWithNodes(sourceFile, oldImportDecls[0], newImportDecls, replaceOptions); + var hasTrailingComment = changeTracker.nodeHasTrailingComment(sourceFile, oldImportDecls[0], replaceOptions); + changeTracker.deleteNodes(sourceFile, oldImportDecls.slice(1), { + trailingTriviaOption: ts.textChanges.TrailingTriviaOption.Include, + }, hasTrailingComment); } } } OrganizeImports.organizeImports = organizeImports; - function removeUnusedImports(oldImports, sourceFile, program) { + function removeUnusedImports(oldImports, sourceFile, program, skipDestructiveCodeActions) { + // As a precaution, consider unused import detection to be destructive (GH #43051) + if (skipDestructiveCodeActions) { + return oldImports; + } var typeChecker = program.getTypeChecker(); var jsxNamespace = typeChecker.getJsxNamespace(sourceFile); var jsxFragmentFactory = typeChecker.getJsxFragmentFactory(sourceFile); @@ -128101,11 +132891,11 @@ var ts; function getModuleSpecifierExpression(declaration) { var _a; switch (declaration.kind) { - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return (_a = ts.tryCast(declaration.moduleReference, ts.isExternalModuleReference)) === null || _a === void 0 ? void 0 : _a.expression; - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return declaration.moduleSpecifier; - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return declaration.declarationList.declarations[0].initializer.arguments[0]; } } @@ -128144,19 +132934,19 @@ var ts; function getImportKindOrder(s1) { var _a; switch (s1.kind) { - case 261 /* ImportDeclaration */: + case 263 /* 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) === 263 /* NamespaceImport */) + if (((_a = s1.importClause.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 265 /* NamespaceImport */) return 2; if (s1.importClause.name) return 3; return 4; - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return 5; - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return 6; } } @@ -128194,7 +132984,7 @@ var ts; } var lastImport = current - 1; if (lastImport !== firstImport) { - out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 99 /* ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* Imports */)); + out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 100 /* ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* Imports */)); } } function visitNonImportNode(n) { @@ -128258,8 +133048,15 @@ var ts; } } } - var regionDelimiterRegExp = /^\s*\/\/\s*#(end)?region(?:\s+(.*))?(?:\r)?$/; + var regionDelimiterRegExp = /^#(end)?region(?:\s+(.*))?(?:\r)?$/; function isRegionDelimiter(lineText) { + // We trim the leading whitespace and // without the regex since the + // multiple potential whitespace matches can make for some gnarly backtracking behavior + lineText = ts.trimStringStart(lineText); + if (!ts.startsWith(lineText, "\/\/")) { + return null; // eslint-disable-line no-null/no-null + } + lineText = ts.trimString(lineText.slice(2)); return regionDelimiterRegExp.exec(lineText); } function addOutliningForLeadingCommentsForNode(n, sourceFile, cancellationToken, out) { @@ -128312,7 +133109,7 @@ var ts; } function getOutliningSpanForNode(n, sourceFile) { switch (n.kind) { - case 230 /* Block */: + case 232 /* Block */: if (ts.isFunctionLike(n.parent)) { return functionSpan(n.parent, n, sourceFile); } @@ -128320,23 +133117,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 235 /* DoStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 237 /* ForStatement */: - case 234 /* IfStatement */: - case 236 /* WhileStatement */: - case 243 /* WithStatement */: - case 287 /* CatchClause */: + case 237 /* DoStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 239 /* ForStatement */: + case 236 /* IfStatement */: + case 238 /* WhileStatement */: + case 245 /* WithStatement */: + case 289 /* CatchClause */: return spanForNode(n.parent); - case 247 /* TryStatement */: + case 249 /* 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, 95 /* FinallyKeyword */, sourceFile); + var node = ts.findChildOfKind(tryStatement, 96 /* FinallyKeyword */, sourceFile); if (node) return spanForNode(node); } @@ -128346,40 +133143,40 @@ var ts; // the span of the block, independent of any parent span. return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* Code */); } - case 257 /* ModuleBlock */: + case 259 /* ModuleBlock */: return spanForNode(n.parent); - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - case 258 /* CaseBlock */: - case 177 /* TypeLiteral */: - case 196 /* ObjectBindingPattern */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: + case 257 /* EnumDeclaration */: + case 260 /* CaseBlock */: + case 179 /* TypeLiteral */: + case 198 /* ObjectBindingPattern */: return spanForNode(n); - case 179 /* TupleType */: + case 181 /* TupleType */: return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isTupleTypeNode(n.parent), 22 /* OpenBracketToken */); - case 284 /* CaseClause */: - case 285 /* DefaultClause */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: return spanForNodeArray(n.statements); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return spanForObjectOrArrayLiteral(n); - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return spanForObjectOrArrayLiteral(n, 22 /* OpenBracketToken */); - case 273 /* JsxElement */: + case 275 /* JsxElement */: return spanForJSXElement(n); - case 277 /* JsxFragment */: + case 279 /* JsxFragment */: return spanForJSXFragment(n); - case 274 /* JsxSelfClosingElement */: - case 275 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: return spanForJSXAttributes(n.attributes); - case 218 /* TemplateExpression */: + case 220 /* TemplateExpression */: case 14 /* NoSubstitutionTemplateLiteral */: return spanForTemplateLiteral(n); - case 197 /* ArrayBindingPattern */: + case 199 /* ArrayBindingPattern */: return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isBindingElement(n.parent), 22 /* OpenBracketToken */); - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return spanForArrowFunction(n); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return spanForCallExpression(n); } function spanForCallExpression(node) { @@ -128446,7 +133243,7 @@ var ts; 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 !== 209 /* ArrowFunction */); + return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 211 /* ArrowFunction */); } function spanBetweenTokens(openToken, closeToken, hintSpanNode, sourceFile, autoCollapse, useFullStart) { if (autoCollapse === void 0) { autoCollapse = false; } @@ -128749,15 +133546,15 @@ var ts; // Assumes 'value' is already lowercase. function indexOfIgnoringCase(str, value) { var n = str.length - value.length; - var _loop_6 = function (start) { + var _loop_7 = 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_1 = _loop_6(start); - if (typeof state_1 === "object") - return state_1.value; + var state_2 = _loop_7(start); + if (typeof state_2 === "object") + return state_2.value; } return -1; } @@ -128990,10 +133787,10 @@ var ts; */ function tryConsumeDeclare() { var token = ts.scanner.getToken(); - if (token === 133 /* DeclareKeyword */) { + if (token === 134 /* DeclareKeyword */) { // declare module "mod" token = nextToken(); - if (token === 139 /* ModuleKeyword */) { + if (token === 140 /* ModuleKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { recordAmbientExternalModule(); @@ -129011,7 +133808,7 @@ var ts; return false; } var token = ts.scanner.getToken(); - if (token === 99 /* ImportKeyword */) { + if (token === 100 /* ImportKeyword */) { token = nextToken(); if (token === 20 /* OpenParenToken */) { token = nextToken(); @@ -129027,21 +133824,21 @@ var ts; return true; } else { - if (token === 149 /* TypeKeyword */) { + if (token === 150 /* TypeKeyword */) { var skipTypeKeyword = ts.scanner.lookAhead(function () { var token = ts.scanner.scan(); - return token !== 153 /* FromKeyword */ && (token === 41 /* AsteriskToken */ || + return token !== 154 /* FromKeyword */ && (token === 41 /* AsteriskToken */ || token === 18 /* OpenBraceToken */ || - token === 78 /* Identifier */ || + token === 79 /* Identifier */ || ts.isKeyword(token)); }); if (skipTypeKeyword) { token = nextToken(); } } - if (token === 78 /* Identifier */ || ts.isKeyword(token)) { + if (token === 79 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 153 /* FromKeyword */) { + if (token === 154 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // import d from "mod"; @@ -129049,7 +133846,7 @@ var ts; return true; } } - else if (token === 62 /* EqualsToken */) { + else if (token === 63 /* EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } @@ -129072,7 +133869,7 @@ var ts; } if (token === 19 /* CloseBraceToken */) { token = nextToken(); - if (token === 153 /* FromKeyword */) { + if (token === 154 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // import {a as A} from "mod"; @@ -129084,11 +133881,11 @@ var ts; } else if (token === 41 /* AsteriskToken */) { token = nextToken(); - if (token === 126 /* AsKeyword */) { + if (token === 127 /* AsKeyword */) { token = nextToken(); - if (token === 78 /* Identifier */ || ts.isKeyword(token)) { + if (token === 79 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 153 /* FromKeyword */) { + if (token === 154 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // import * as NS from "mod" @@ -129106,10 +133903,10 @@ var ts; } function tryConsumeExport() { var token = ts.scanner.getToken(); - if (token === 92 /* ExportKeyword */) { + if (token === 93 /* ExportKeyword */) { markAsExternalModuleIfTopLevel(); token = nextToken(); - if (token === 149 /* TypeKeyword */) { + if (token === 150 /* TypeKeyword */) { var skipTypeKeyword = ts.scanner.lookAhead(function () { var token = ts.scanner.scan(); return token === 41 /* AsteriskToken */ || @@ -129128,7 +133925,7 @@ var ts; } if (token === 19 /* CloseBraceToken */) { token = nextToken(); - if (token === 153 /* FromKeyword */) { + if (token === 154 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // export {a as A} from "mod"; @@ -129140,7 +133937,7 @@ var ts; } else if (token === 41 /* AsteriskToken */) { token = nextToken(); - if (token === 153 /* FromKeyword */) { + if (token === 154 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // export * from "mod" @@ -129148,21 +133945,21 @@ var ts; } } } - else if (token === 99 /* ImportKeyword */) { + else if (token === 100 /* ImportKeyword */) { token = nextToken(); - if (token === 149 /* TypeKeyword */) { + if (token === 150 /* TypeKeyword */) { var skipTypeKeyword = ts.scanner.lookAhead(function () { var token = ts.scanner.scan(); - return token === 78 /* Identifier */ || + return token === 79 /* Identifier */ || ts.isKeyword(token); }); if (skipTypeKeyword) { token = nextToken(); } } - if (token === 78 /* Identifier */ || ts.isKeyword(token)) { + if (token === 79 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 62 /* EqualsToken */) { + if (token === 63 /* EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } @@ -129176,7 +133973,7 @@ var ts; function tryConsumeRequireCall(skipCurrentToken, allowTemplateLiterals) { if (allowTemplateLiterals === void 0) { allowTemplateLiterals = false; } var token = skipCurrentToken ? nextToken() : ts.scanner.getToken(); - if (token === 143 /* RequireKeyword */) { + if (token === 144 /* RequireKeyword */) { token = nextToken(); if (token === 20 /* OpenParenToken */) { token = nextToken(); @@ -129192,7 +133989,7 @@ var ts; } function tryConsumeDefine() { var token = ts.scanner.getToken(); - if (token === 78 /* Identifier */ && ts.scanner.getTokenValue() === "define") { + if (token === 79 /* Identifier */ && ts.scanner.getTokenValue() === "define") { token = nextToken(); if (token !== 20 /* OpenParenToken */) { return true; @@ -129309,7 +134106,7 @@ var ts; function getRenameInfo(program, sourceFile, position, options) { var node = ts.getAdjustedRenameLocation(ts.getTouchingPropertyName(sourceFile, position)); if (nodeIsEligibleForRename(node)) { - var renameInfo = getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, function (declaration) { return program.isSourceFileDefaultLibrary(declaration.getSourceFile()); }, options); + var renameInfo = getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, program, options); if (renameInfo) { return renameInfo; } @@ -129317,7 +134114,7 @@ var ts; return getRenameInfoError(ts.Diagnostics.You_cannot_rename_this_element); } Rename.getRenameInfo = getRenameInfo; - function getRenameInfoForNode(node, typeChecker, sourceFile, isDefinedInLibraryFile, options) { + function getRenameInfoForNode(node, typeChecker, sourceFile, program, options) { var symbol = typeChecker.getSymbolAtLocation(node); if (!symbol) { if (ts.isStringLiteralLike(node)) { @@ -129337,29 +134134,33 @@ var ts; if (!declarations || declarations.length === 0) return; // Disallow rename for elements that are defined in the standard TypeScript library. - if (declarations.some(isDefinedInLibraryFile)) { + if (declarations.some(function (declaration) { return isDefinedInLibraryFile(program, declaration); })) { 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 === 87 /* DefaultKeyword */ && symbol.parent && symbol.parent.flags & 1536 /* Module */) { + if (ts.isIdentifier(node) && node.originalKeywordKind === 88 /* DefaultKeyword */ && symbol.parent && symbol.parent.flags & 1536 /* Module */) { return undefined; } if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) { return options && options.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined; } var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); - var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 158 /* ComputedPropertyName */) + var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 160 /* ComputedPropertyName */) ? ts.stripQuotes(ts.getTextOfIdentifierOrLiteral(node)) : undefined; var displayName = specifierName || typeChecker.symbolToString(symbol); var fullDisplayName = specifierName || typeChecker.getFullyQualifiedName(symbol); return getRenameInfoSuccess(displayName, fullDisplayName, kind, ts.SymbolDisplay.getSymbolModifiers(typeChecker, symbol), node, sourceFile); } + function isDefinedInLibraryFile(program, declaration) { + var sourceFile = declaration.getSourceFile(); + return program.isSourceFileDefaultLibrary(sourceFile) && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Dts */); + } function getRenameInfoForModule(node, sourceFile, moduleSymbol) { if (!ts.isExternalModuleNameRelative(node.text)) { return getRenameInfoError(ts.Diagnostics.You_cannot_rename_a_module_via_a_global_import); } - var moduleSourceFile = ts.find(moduleSymbol.declarations, ts.isSourceFile); + var moduleSourceFile = moduleSymbol.declarations && ts.find(moduleSymbol.declarations, ts.isSourceFile); if (!moduleSourceFile) return undefined; var withoutIndex = ts.endsWith(node.text, "/index") || ts.endsWith(node.text, "/index.js") ? undefined : ts.tryRemoveSuffix(ts.removeFileExtension(moduleSourceFile.fileName), "/index"); @@ -129404,11 +134205,11 @@ var ts; } function nodeIsEligibleForRename(node) { switch (node.kind) { - case 78 /* Identifier */: - case 79 /* PrivateIdentifier */: + case 79 /* Identifier */: + case 80 /* PrivateIdentifier */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: return true; case 8 /* NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node); @@ -129440,6 +134241,10 @@ var ts; if (ts.getTokenPosOfNode(node, sourceFile, /*includeJsDoc*/ true) > pos) { break outer; } + var comment = ts.singleOrUndefined(ts.getTrailingCommentRanges(sourceFile.text, node.end)); + if (comment && comment.kind === 2 /* SingleLineCommentTrivia */) { + pushSelectionCommentRange(comment.pos, comment.end); + } if (positionShouldSnapToNode(sourceFile, pos, node)) { // 1. Blocks are effectively redundant with SyntaxLists. // 2. TemplateSpans, along with the SyntaxLists containing them, are a somewhat unintuitive grouping @@ -129502,6 +134307,14 @@ var ts; } } } + function pushSelectionCommentRange(start, end) { + pushSelectionRange(start, end); + var pos = start; + while (sourceFile.text.charCodeAt(pos) === 47 /* slash */) { + pos++; + } + pushSelectionRange(pos, end); + } } SmartSelectionRange.getSmartSelectionRange = getSmartSelectionRange; /** @@ -129558,14 +134371,14 @@ var ts; ts.Debug.assertEqual(closeBraceToken.kind, 19 /* CloseBraceToken */); // Group `-/+readonly` and `-/+?` var groupedWithPlusMinusTokens = groupChildren(children, function (child) { - return child === node.readonlyToken || child.kind === 142 /* ReadonlyKeyword */ || + return child === node.readonlyToken || child.kind === 143 /* ReadonlyKeyword */ || child === node.questionToken || child.kind === 57 /* QuestionToken */; }); // Group type parameter with surrounding brackets var groupedWithBrackets = groupChildren(groupedWithPlusMinusTokens, function (_a) { var kind = _a.kind; return kind === 22 /* OpenBracketToken */ || - kind === 159 /* TypeParameter */ || + kind === 161 /* TypeParameter */ || kind === 23 /* CloseBracketToken */; }); return [ @@ -129598,14 +134411,14 @@ var ts; }); return splitChildren(groupedWithQuestionToken, function (_a) { var kind = _a.kind; - return kind === 62 /* EqualsToken */; + return kind === 63 /* EqualsToken */; }); } // Pivot on '=' if (ts.isBindingElement(node)) { return splitChildren(node.getChildren(), function (_a) { var kind = _a.kind; - return kind === 62 /* EqualsToken */; + return kind === 63 /* EqualsToken */; }); } return node.getChildren(); @@ -129679,22 +134492,22 @@ var ts; return kind === 18 /* OpenBraceToken */ || kind === 22 /* OpenBracketToken */ || kind === 20 /* OpenParenToken */ - || kind === 275 /* JsxOpeningElement */; + || kind === 277 /* JsxOpeningElement */; } function isListCloser(token) { var kind = token && token.kind; return kind === 19 /* CloseBraceToken */ || kind === 23 /* CloseBracketToken */ || kind === 21 /* CloseParenToken */ - || kind === 276 /* JsxClosingElement */; + || kind === 278 /* JsxClosingElement */; } function getEndPos(sourceFile, node) { switch (node.kind) { - case 326 /* JSDocParameterTag */: - case 324 /* JSDocCallbackTag */: - case 333 /* JSDocPropertyTag */: - case 331 /* JSDocTypedefTag */: - case 328 /* JSDocThisTag */: + case 334 /* JSDocParameterTag */: + case 332 /* JSDocCallbackTag */: + case 341 /* JSDocPropertyTag */: + case 339 /* JSDocTypedefTag */: + case 336 /* JSDocThisTag */: return sourceFile.getLineEndOfPosition(node.getStart()); default: return node.getEnd(); @@ -129904,10 +134717,10 @@ var ts; } return undefined; } - else if (ts.isTemplateHead(node) && parent.parent.kind === 205 /* TaggedTemplateExpression */) { + else if (ts.isTemplateHead(node) && parent.parent.kind === 207 /* TaggedTemplateExpression */) { var templateExpression = parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 218 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 220 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position, sourceFile) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } @@ -129976,17 +134789,17 @@ var ts; return undefined; var parent = startingToken.parent; switch (parent.kind) { - case 207 /* ParenthesizedExpression */: - case 165 /* MethodDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 209 /* ParenthesizedExpression */: + case 167 /* MethodDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: var info = getArgumentOrParameterListInfo(startingToken, 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 216 /* BinaryExpression */: { + case 218 /* BinaryExpression */: { var highestBinary = getHighestBinary(parent); var contextualType_1 = checker.getContextualType(highestBinary); var argumentIndex_1 = startingToken.kind === 20 /* OpenParenToken */ ? 0 : countBinaryExpressionParameters(parent) - 1; @@ -130110,7 +134923,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 === 218 /* TemplateExpression */) { + if (template.kind === 220 /* TemplateExpression */) { var lastSpan = ts.last(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -130119,7 +134932,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node, position, sourceFile, checker, isManuallyInvoked) { - var _loop_7 = function (n) { + var _loop_8 = 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); }); @@ -130129,9 +134942,9 @@ var ts; } }; for (var n = node; !ts.isSourceFile(n) && (isManuallyInvoked || !ts.isBlock(n)); n = n.parent) { - var state_2 = _loop_7(n); - if (typeof state_2 === "object") - return state_2.value; + var state_3 = _loop_8(n); + if (typeof state_3 === "object") + return state_3.value; } return undefined; } @@ -130181,7 +134994,19 @@ var ts; itemsSeen += item.length; } ts.Debug.assert(selectedItemIndex !== -1); // If candidates is non-empty it should always include bestSignature. We check for an empty candidates before calling this function. - return { items: ts.flatMapToMutable(items, ts.identity), applicableSpan: applicableSpan, selectedItemIndex: selectedItemIndex, argumentIndex: argumentIndex, argumentCount: argumentCount }; + var help = { items: ts.flatMapToMutable(items, ts.identity), applicableSpan: applicableSpan, selectedItemIndex: selectedItemIndex, argumentIndex: argumentIndex, argumentCount: argumentCount }; + var selected = help.items[selectedItemIndex]; + if (selected.isVariadic) { + var firstRest = ts.findIndex(selected.parameters, function (p) { return !!p.isRest; }); + if (-1 < firstRest && firstRest < selected.parameters.length - 1) { + // We don't have any code to get this correct; instead, don't highlight a current parameter AT ALL + help.argumentIndex = selected.parameters.length; + } + else { + help.argumentIndex = Math.min(help.argumentIndex, selected.parameters.length - 1); + } + } + return help; } function createTypeHelpItems(symbol, _a, sourceFile, checker) { var argumentCount = _a.argumentCount, applicableSpan = _a.argumentsSpan, invocation = _a.invocation, argumentIndex = _a.argumentIndex; @@ -130196,7 +135021,7 @@ var ts; var printer = ts.createPrinter({ removeComments: true }); var parameters = typeParameters.map(function (t) { return createSignatureHelpParameterForTypeParameter(t, checker, enclosingDeclaration, sourceFile, printer); }); var documentation = symbol.getDocumentationComment(checker); - var tags = symbol.getJsDocTags(); + var tags = symbol.getJsDocTags(checker); var prefixDisplayParts = __spreadArray(__spreadArray([], typeSymbolDisplay), [ts.punctuationPart(29 /* LessThanToken */)]); return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(31 /* GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; } @@ -130239,7 +135064,6 @@ var ts; }); } function itemInfoForParameters(candidateSignature, checker, enclosingDeclaration, sourceFile) { - var isVariadic = checker.hasEffectiveRestParameter(candidateSignature); var printer = ts.createPrinter({ removeComments: true }); var typeParameterParts = ts.mapToDisplayParts(function (writer) { if (candidateSignature.typeParameters && candidateSignature.typeParameters.length) { @@ -130248,14 +135072,15 @@ var ts; } }); var lists = checker.getExpandedParameters(candidateSignature); - return lists.map(function (parameterList) { - return { - isVariadic: isVariadic && (lists.length === 1 || !!(parameterList[parameterList.length - 1].checkFlags & 32768 /* RestParameter */)), - parameters: parameterList.map(function (p) { return createSignatureHelpParameterForParameter(p, checker, enclosingDeclaration, sourceFile, printer); }), - prefix: __spreadArray(__spreadArray([], typeParameterParts), [ts.punctuationPart(20 /* OpenParenToken */)]), - suffix: [ts.punctuationPart(21 /* CloseParenToken */)] - }; - }); + 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 */); }; + 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), [ts.punctuationPart(20 /* OpenParenToken */)]), + suffix: [ts.punctuationPart(21 /* CloseParenToken */)] + }); }); } function createSignatureHelpParameterForParameter(parameter, checker, enclosingDeclaration, sourceFile, printer) { var displayParts = ts.mapToDisplayParts(function (writer) { @@ -130263,14 +135088,15 @@ var ts; printer.writeNode(4 /* Unspecified */, param, sourceFile, writer); }); var isOptional = checker.isOptionalParameter(parameter.valueDeclaration); - return { name: parameter.name, documentation: parameter.getDocumentationComment(checker), displayParts: displayParts, isOptional: isOptional }; + var isRest = !!(parameter.checkFlags & 32768 /* 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); }); - return { name: typeParameter.symbol.name, documentation: typeParameter.symbol.getDocumentationComment(checker), displayParts: displayParts, isOptional: false }; + return { name: typeParameter.symbol.name, documentation: typeParameter.symbol.getDocumentationComment(checker), displayParts: displayParts, isOptional: false, isRest: false }; } })(SignatureHelp = ts.SignatureHelp || (ts.SignatureHelp = {})); })(ts || (ts = {})); @@ -130480,7 +135306,7 @@ var ts; diags.push(ts.createDiagnosticForNode(node.name || node, ts.Diagnostics.JSDoc_types_may_be_moved_to_TypeScript_types)); } } - if (ts.isFunctionLikeDeclaration(node)) { + if (canBeConvertedToAsync(node)) { addConvertToAsyncFunctionDiagnostics(node, checker, diags); } node.forEachChild(check); @@ -130491,11 +135317,11 @@ var ts; function containsTopLevelCommonjs(sourceFile) { return sourceFile.statements.some(function (statement) { switch (statement.kind) { - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return statement.declarationList.declarations.some(function (decl) { return !!decl.initializer && ts.isRequireCall(propertyAccessLeftHandSide(decl.initializer), /*checkArgumentIsStringLiteralLike*/ true); }); - case 233 /* ExpressionStatement */: { + case 235 /* ExpressionStatement */: { var expression = statement.expression; if (!ts.isBinaryExpression(expression)) return ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true); @@ -130512,12 +135338,12 @@ var ts; } function importNameForConvertToDefaultImport(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: var importClause = node.importClause, moduleSpecifier = node.moduleSpecifier; - return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 263 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) + return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 265 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) ? importClause.namedBindings.name : undefined; - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return node.name; default: return undefined; @@ -130533,35 +135359,35 @@ var ts; return !ts.isAsyncFunction(node) && node.body && ts.isBlock(node.body) && - hasReturnStatementWithPromiseHandler(node.body) && + hasReturnStatementWithPromiseHandler(node.body, checker) && returnsPromise(node, checker); } function returnsPromise(node, checker) { - var functionType = checker.getTypeAtLocation(node); - var callSignatures = checker.getSignaturesOfType(functionType, 0 /* Call */); - var returnType = callSignatures.length ? checker.getReturnTypeOfSignature(callSignatures[0]) : undefined; + var signature = checker.getSignatureFromDeclaration(node); + var returnType = signature ? checker.getReturnTypeOfSignature(signature) : undefined; return !!returnType && !!checker.getPromisedTypeOfPromise(returnType); } + ts.returnsPromise = returnsPromise; function getErrorNodeFromCommonJsIndicator(commonJsModuleIndicator) { return ts.isBinaryExpression(commonJsModuleIndicator) ? commonJsModuleIndicator.left : commonJsModuleIndicator; } - function hasReturnStatementWithPromiseHandler(body) { - return !!ts.forEachReturnStatement(body, isReturnStatementWithFixablePromiseHandler); + function hasReturnStatementWithPromiseHandler(body, checker) { + return !!ts.forEachReturnStatement(body, function (statement) { return isReturnStatementWithFixablePromiseHandler(statement, checker); }); } - function isReturnStatementWithFixablePromiseHandler(node) { - return ts.isReturnStatement(node) && !!node.expression && isFixablePromiseHandler(node.expression); + function isReturnStatementWithFixablePromiseHandler(node, checker) { + return ts.isReturnStatement(node) && !!node.expression && isFixablePromiseHandler(node.expression, checker); } ts.isReturnStatementWithFixablePromiseHandler = isReturnStatementWithFixablePromiseHandler; // Should be kept up to date with transformExpression in convertToAsyncFunction.ts - function isFixablePromiseHandler(node) { + function isFixablePromiseHandler(node, checker) { // ensure outermost call exists and is a promise handler - if (!isPromiseHandler(node) || !node.arguments.every(isFixablePromiseArgument)) { + if (!isPromiseHandler(node) || !node.arguments.every(function (arg) { return isFixablePromiseArgument(arg, checker); })) { return false; } // ensure all chained calls are valid var currentNode = node.expression; while (isPromiseHandler(currentNode) || ts.isPropertyAccessExpression(currentNode)) { - if (ts.isCallExpression(currentNode) && !currentNode.arguments.every(isFixablePromiseArgument)) { + if (ts.isCallExpression(currentNode) && !currentNode.arguments.every(function (arg) { return isFixablePromiseArgument(arg, checker); })) { return false; } currentNode = currentNode.expression; @@ -130579,21 +135405,34 @@ var ts; if (node.arguments.length < 2) return true; return ts.some(node.arguments, function (arg) { - return arg.kind === 103 /* NullKeyword */ || + return arg.kind === 104 /* NullKeyword */ || ts.isIdentifier(arg) && arg.text === "undefined"; }); } // should be kept up to date with getTransformationBody in convertToAsyncFunction.ts - function isFixablePromiseArgument(arg) { + function isFixablePromiseArgument(arg, checker) { switch (arg.kind) { - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + var functionFlags = ts.getFunctionFlags(arg); + if (functionFlags & 1 /* Generator */) { + return false; + } + // falls through + case 211 /* ArrowFunction */: visitedNestedConvertibleFunctions.set(getKeyFromNode(arg), true); // falls through - case 103 /* NullKeyword */: - case 78 /* Identifier */: // identifier includes undefined + case 104 /* NullKeyword */: return true; + case 79 /* Identifier */: + case 203 /* PropertyAccessExpression */: { + var symbol = checker.getSymbolAtLocation(arg); + if (!symbol) { + return false; + } + return checker.isUndefinedSymbol(symbol) || + ts.some(ts.skipAlias(symbol, checker).declarations, function (d) { return ts.isFunctionLike(d) || ts.hasInitializer(d) && !!d.initializer && ts.isFunctionLike(d.initializer); }); + } default: return false; } @@ -130603,18 +135442,30 @@ var ts; } function canBeConvertedToClass(node, checker) { var _a, _b, _c, _d; - if (node.kind === 208 /* FunctionExpression */) { + if (node.kind === 210 /* 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 === 251 /* FunctionDeclaration */) { + if (node.kind === 253 /* FunctionDeclaration */) { return !!((_d = node.symbol.members) === null || _d === void 0 ? void 0 : _d.size); } return false; } + function canBeConvertedToAsync(node) { + switch (node.kind) { + case 253 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + return true; + default: + return false; + } + } + ts.canBeConvertedToAsync = canBeConvertedToAsync; })(ts || (ts = {})); /* @internal */ var ts; @@ -130630,7 +135481,7 @@ var ts; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); if (flags & 32 /* Class */) { - return ts.getDeclarationOfKind(symbol, 221 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 223 /* ClassExpression */) ? "local class" /* localClassElement */ : "class" /* classElement */; } if (flags & 384 /* Enum */) @@ -130665,7 +135516,7 @@ var ts; if (typeChecker.isArgumentsSymbol(symbol)) { return "local var" /* localVariableElement */; } - if (location.kind === 107 /* ThisKeyword */ && ts.isExpression(location)) { + if (location.kind === 108 /* ThisKeyword */ && ts.isExpression(location)) { return "parameter" /* parameterElement */; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); @@ -130714,11 +135565,11 @@ var ts; // If we requested completions after `x.` at the top-level, we may be at a source file location. switch (location.parent && location.parent.kind) { // If we've typed a character of the attribute name, will be 'JsxAttribute', else will be 'JsxOpeningElement'. - case 275 /* JsxOpeningElement */: - case 273 /* JsxElement */: - case 274 /* JsxSelfClosingElement */: - return location.kind === 78 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; - case 280 /* JsxAttribute */: + case 277 /* JsxOpeningElement */: + case 275 /* JsxElement */: + case 276 /* JsxSelfClosingElement */: + return location.kind === 79 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; + case 282 /* JsxAttribute */: return "JSX attribute" /* jsxAttribute */; default: return "property" /* memberVariableElement */; @@ -130726,14 +135577,11 @@ var ts; } return "" /* unknown */; } - function isDeprecatedDeclaration(decl) { - return !!(ts.getCombinedNodeFlagsAlwaysIncludeJSDoc(decl) & 8192 /* Deprecated */); - } 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) && isDeprecatedDeclaration(declaration) && ts.some(declarations, function (d) { return !isDeprecatedDeclaration(d); }) + var excludeFlags = ts.length(declarations) && ts.isDeprecatedDeclaration(declaration) && ts.some(declarations, function (d) { return !ts.isDeprecatedDeclaration(d); }) ? 8192 /* Deprecated */ : 0 /* None */; var modifiers = ts.getNodeModifiers(declaration, excludeFlags); @@ -130764,6 +135612,7 @@ var ts; SymbolDisplay.getSymbolModifiers = getSymbolModifiers; // TODO(drosen): Currently completion entry details passes the SemanticMeaning.All instead of using semanticMeaning of location function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, enclosingDeclaration, location, semanticMeaning, alias) { + var _a; if (semanticMeaning === void 0) { semanticMeaning = ts.getMeaningFromLocation(location); } var displayParts = []; var documentation = []; @@ -130771,14 +135620,14 @@ var ts; var symbolFlags = ts.getCombinedLocalAndExportSymbolFlags(symbol); var symbolKind = semanticMeaning & 1 /* Value */ ? getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) : "" /* unknown */; var hasAddedSymbolInfo = false; - var isThisExpression = location.kind === 107 /* ThisKeyword */ && ts.isInExpressionContext(location); + var isThisExpression = location.kind === 108 /* ThisKeyword */ && ts.isInExpressionContext(location); var type; var printer; var documentationFromAlias; var tagsFromAlias; var hasMultipleSignatures = false; - if (location.kind === 107 /* ThisKeyword */ && !isThisExpression) { - return { displayParts: [ts.keywordPart(107 /* ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* primitiveType */, tags: undefined }; + if (location.kind === 108 /* ThisKeyword */ && !isThisExpression) { + return { displayParts: [ts.keywordPart(108 /* ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* 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 */) { @@ -130787,8 +135636,8 @@ var ts; symbolKind = "property" /* memberVariableElement */; } var signature = void 0; - type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol.exportSymbol || symbol, location); - if (location.parent && location.parent.kind === 201 /* PropertyAccessExpression */) { + type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); + if (location.parent && location.parent.kind === 203 /* 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)) { @@ -130808,9 +135657,9 @@ var ts; } if (callExpressionLike) { signature = typeChecker.getResolvedSignature(callExpressionLike); // TODO: GH#18217 - var useConstructSignatures = callExpressionLike.kind === 204 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 105 /* SuperKeyword */); + var useConstructSignatures = callExpressionLike.kind === 206 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 106 /* SuperKeyword */); var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); - if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { + if (signature && !ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { // Get the first signature if there is one -- allSignatures may contain // either the original signature or its target, so check for either signature = allSignatures.length ? allSignatures[0] : undefined; @@ -130827,10 +135676,10 @@ var ts; displayParts.push(ts.spacePart()); if (useConstructSignatures) { if (signature.flags & 4 /* Abstract */) { - displayParts.push(ts.keywordPart(125 /* AbstractKeyword */)); + displayParts.push(ts.keywordPart(126 /* AbstractKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(102 /* NewKeyword */)); + displayParts.push(ts.keywordPart(103 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -130855,10 +135704,10 @@ var ts; } if (useConstructSignatures) { if (signature.flags & 4 /* Abstract */) { - displayParts.push(ts.keywordPart(125 /* AbstractKeyword */)); + displayParts.push(ts.keywordPart(126 /* AbstractKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(102 /* NewKeyword */)); + displayParts.push(ts.keywordPart(103 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addSignatureDisplayParts(signature, allSignatures, 262144 /* WriteArrowStyleSignature */); @@ -130872,32 +135721,34 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* Accessor */)) || // name of function declaration - (location.kind === 132 /* ConstructorKeyword */ && location.parent.kind === 166 /* Constructor */)) { // At constructor keyword of constructor declaration + (location.kind === 133 /* ConstructorKeyword */ && location.parent.kind === 168 /* 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 === 132 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); + return declaration === (location.kind === 133 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); }); if (locationIsSymbolDeclaration) { - var allSignatures = functionDeclaration_1.kind === 166 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration_1.kind === 168 /* 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 === 166 /* Constructor */) { + if (functionDeclaration_1.kind === 168 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = "constructor" /* constructorImplementationElement */; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 169 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 171 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } - addSignatureDisplayParts(signature, allSignatures); + if (signature) { + addSignatureDisplayParts(signature, allSignatures); + } hasAddedSymbolInfo = true; hasMultipleSignatures = allSignatures.length > 1; } @@ -130905,7 +135756,7 @@ var ts; } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { addAliasPrefixIfNecessary(); - if (ts.getDeclarationOfKind(symbol, 221 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 223 /* 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 @@ -130913,7 +135764,7 @@ var ts; } else { // Class declaration has name which is not local. - displayParts.push(ts.keywordPart(83 /* ClassKeyword */)); + displayParts.push(ts.keywordPart(84 /* ClassKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); @@ -130921,37 +135772,37 @@ var ts; } if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(117 /* InterfaceKeyword */)); + displayParts.push(ts.keywordPart(118 /* InterfaceKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if ((symbolFlags & 524288 /* TypeAlias */) && (semanticMeaning & 2 /* Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(149 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(150 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(62 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* EqualsToken */)); displayParts.push(ts.spacePart()); ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 8388608 /* InTypeAlias */)); } if (symbolFlags & 384 /* Enum */) { prefixNextMeaning(); if (ts.some(symbol.declarations, function (d) { return ts.isEnumDeclaration(d) && ts.isEnumConst(d); })) { - displayParts.push(ts.keywordPart(84 /* ConstKeyword */)); + displayParts.push(ts.keywordPart(85 /* ConstKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(91 /* EnumKeyword */)); + displayParts.push(ts.keywordPart(92 /* EnumKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536 /* Module */ && !isThisExpression) { prefixNextMeaning(); - var declaration = ts.getDeclarationOfKind(symbol, 256 /* ModuleDeclaration */); - var isNamespace = declaration && declaration.name && declaration.name.kind === 78 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 140 /* NamespaceKeyword */ : 139 /* ModuleKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 258 /* ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 79 /* Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 141 /* NamespaceKeyword */ : 140 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } @@ -130970,7 +135821,7 @@ var ts; } else { // Method/function type parameter - var decl = ts.getDeclarationOfKind(symbol, 159 /* TypeParameter */); + var decl = ts.getDeclarationOfKind(symbol, 161 /* TypeParameter */); if (decl === undefined) return ts.Debug.fail(); var declaration = decl.parent; @@ -130978,21 +135829,21 @@ var ts; if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); var signature = typeChecker.getSignatureFromDeclaration(declaration); // TODO: GH#18217 - if (declaration.kind === 170 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(102 /* NewKeyword */)); + if (declaration.kind === 172 /* ConstructSignature */) { + displayParts.push(ts.keywordPart(103 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 169 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 171 /* CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 254 /* TypeAliasDeclaration */) { + else if (declaration.kind === 256 /* TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path addInPrefix(); - displayParts.push(ts.keywordPart(149 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(150 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -131003,12 +135854,12 @@ var ts; if (symbolFlags & 8 /* EnumMember */) { symbolKind = "enum member" /* enumMemberElement */; addPrefixForAnyFunctionOrVar(symbol, "enum member"); - var declaration = symbol.declarations[0]; - if (declaration.kind === 291 /* EnumMember */) { + var declaration = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]; + if ((declaration === null || declaration === void 0 ? void 0 : declaration.kind) === 293 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(62 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* EqualsToken */)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(ts.getTextOfConstantValue(constantValue), typeof constantValue === "number" ? ts.SymbolDisplayPartKind.numericLiteral : ts.SymbolDisplayPartKind.stringLiteral)); } @@ -131034,37 +135885,39 @@ var ts; } else { documentationFromAlias = resolvedSymbol.getContextualDocumentationComment(resolvedNode, typeChecker); - tagsFromAlias = resolvedSymbol.getJsDocTags(); + tagsFromAlias = resolvedSymbol.getJsDocTags(typeChecker); } } } - switch (symbol.declarations[0].kind) { - case 259 /* NamespaceExportDeclaration */: - displayParts.push(ts.keywordPart(92 /* ExportKeyword */)); - displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(140 /* NamespaceKeyword */)); - break; - case 266 /* ExportAssignment */: - displayParts.push(ts.keywordPart(92 /* ExportKeyword */)); - displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 62 /* EqualsToken */ : 87 /* DefaultKeyword */)); - break; - case 270 /* ExportSpecifier */: - displayParts.push(ts.keywordPart(92 /* ExportKeyword */)); - break; - default: - displayParts.push(ts.keywordPart(99 /* ImportKeyword */)); + if (symbol.declarations) { + switch (symbol.declarations[0].kind) { + case 261 /* NamespaceExportDeclaration */: + displayParts.push(ts.keywordPart(93 /* ExportKeyword */)); + displayParts.push(ts.spacePart()); + displayParts.push(ts.keywordPart(141 /* NamespaceKeyword */)); + break; + case 268 /* ExportAssignment */: + displayParts.push(ts.keywordPart(93 /* ExportKeyword */)); + displayParts.push(ts.spacePart()); + displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 63 /* EqualsToken */ : 88 /* DefaultKeyword */)); + break; + case 272 /* ExportSpecifier */: + displayParts.push(ts.keywordPart(93 /* ExportKeyword */)); + break; + default: + displayParts.push(ts.keywordPart(100 /* ImportKeyword */)); + } } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 260 /* ImportEqualsDeclaration */) { + if (declaration.kind === 262 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(62 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(143 /* RequireKeyword */)); + displayParts.push(ts.keywordPart(144 /* RequireKeyword */)); displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); @@ -131073,7 +135926,7 @@ var ts; var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(62 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* EqualsToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -131087,7 +135940,7 @@ var ts; if (type) { if (isThisExpression) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(107 /* ThisKeyword */)); + displayParts.push(ts.keywordPart(108 /* ThisKeyword */)); } else { addPrefixForAnyFunctionOrVar(symbol, symbolKind); @@ -131145,10 +135998,10 @@ var ts; // 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 && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 297 /* SourceFile */; })) { - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 216 /* BinaryExpression */) { + if (symbol.parent && symbol.declarations && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 299 /* SourceFile */; })) { + for (var _i = 0, _b = symbol.declarations; _i < _b.length; _i++) { + var declaration = _b[_i]; + if (!declaration.parent || declaration.parent.kind !== 218 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -131156,7 +136009,7 @@ var ts; continue; } documentation = rhsSymbol.getDocumentationComment(typeChecker); - tags = rhsSymbol.getJsDocTags(); + tags = rhsSymbol.getJsDocTags(typeChecker); if (documentation.length > 0) { break; } @@ -131164,7 +136017,7 @@ var ts; } } if (tags.length === 0 && !hasMultipleSignatures) { - tags = symbol.getJsDocTags(); + tags = symbol.getJsDocTags(typeChecker); } if (documentation.length === 0 && documentationFromAlias) { documentation = documentationFromAlias; @@ -131193,7 +136046,7 @@ var ts; } function addInPrefix() { displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(100 /* InKeyword */)); + displayParts.push(ts.keywordPart(101 /* InKeyword */)); displayParts.push(ts.spacePart()); } function addFullSymbolName(symbolToDisplay, enclosingDeclaration) { @@ -131266,16 +136119,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 208 /* FunctionExpression */) { + if (declaration.kind === 210 /* FunctionExpression */) { return true; } - if (declaration.kind !== 249 /* VariableDeclaration */ && declaration.kind !== 251 /* FunctionDeclaration */) { + if (declaration.kind !== 251 /* VariableDeclaration */ && declaration.kind !== 253 /* 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 === 297 /* SourceFile */ || parent.kind === 257 /* ModuleBlock */) { + if (parent.kind === 299 /* SourceFile */ || parent.kind === 259 /* ModuleBlock */) { return false; } } @@ -131377,11 +136230,10 @@ var ts; /*@internal*/ function fixupCompilerOptions(options, diagnostics) { // Lazily create this value to fix module loading errors. - commandLineOptionsStringToEnum = commandLineOptionsStringToEnum || ts.filter(ts.optionDeclarations, function (o) { - return typeof o.type === "object" && !ts.forEachEntry(o.type, function (v) { return typeof v !== "number"; }); - }); + 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_8 = function (opt) { + var _loop_9 = function (opt) { if (!ts.hasProperty(options, opt.name)) { return "continue"; } @@ -131400,7 +136252,7 @@ var ts; }; for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) { var opt = commandLineOptionsStringToEnum_1[_i]; - _loop_8(opt); + _loop_9(opt); } return options; } @@ -131565,8 +136417,8 @@ var ts; function shouldRescanGreaterThanToken(node) { switch (node.kind) { case 33 /* GreaterThanEqualsToken */: - case 70 /* GreaterThanGreaterThanEqualsToken */: - case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanEqualsToken */: + case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: case 49 /* GreaterThanGreaterThanGreaterThanToken */: case 48 /* GreaterThanGreaterThanToken */: return true; @@ -131576,25 +136428,18 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 280 /* JsxAttribute */: - case 275 /* JsxOpeningElement */: - case 276 /* JsxClosingElement */: - case 274 /* JsxSelfClosingElement */: + case 282 /* JsxAttribute */: + case 277 /* JsxOpeningElement */: + case 278 /* JsxClosingElement */: + case 276 /* 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 === 78 /* Identifier */; + return ts.isKeyword(node.kind) || node.kind === 79 /* Identifier */; } } return false; } function shouldRescanJsxText(node) { - var isJSXText = ts.isJsxText(node); - if (isJSXText) { - var containingElement = ts.findAncestor(node.parent, function (p) { return ts.isJsxElement(p); }); - if (!containingElement) - return false; // should never happen - return !ts.isParenthesizedExpression(containingElement.parent); - } - return false; + return ts.isJsxText(node); } function shouldRescanSlashToken(container) { return container.kind === 13 /* RegularExpressionLiteral */; @@ -131607,7 +136452,7 @@ var ts; return node.parent && ts.isJsxAttribute(node.parent) && node.parent.initializer === node; } function startsWithSlashToken(t) { - return t === 43 /* SlashToken */ || t === 67 /* SlashEqualsToken */; + return t === 43 /* SlashToken */ || t === 68 /* SlashEqualsToken */; } function readTokenInfo(n) { ts.Debug.assert(isOnToken()); @@ -131691,7 +136536,7 @@ var ts; return scanner.scanJsxIdentifier(); case 5 /* RescanJsxText */: lastScanAction = 5 /* RescanJsxText */; - return scanner.reScanJsxToken(); + return scanner.reScanJsxToken(/* allowMultilineJsxText */ false); case 6 /* RescanJsxAttributeValue */: lastScanAction = 6 /* RescanJsxAttributeValue */; return scanner.reScanJsxAttributeValue(); @@ -131780,7 +136625,7 @@ var ts; (function (formatting) { function getAllRules() { var allTokens = []; - for (var token = 0 /* FirstToken */; token <= 156 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 158 /* LastToken */; token++) { if (token !== 1 /* EndOfFileToken */) { allTokens.push(token); } @@ -131795,27 +136640,27 @@ var ts; var anyToken = { tokens: allTokens, isSpecific: false }; var anyTokenIncludingMultilineComments = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens), [3 /* MultiLineCommentTrivia */])); var anyTokenIncludingEOF = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens), [1 /* EndOfFileToken */])); - var keywords = tokenRangeFromRange(80 /* FirstKeyword */, 156 /* LastKeyword */); - var binaryOperators = tokenRangeFromRange(29 /* FirstBinaryOperator */, 77 /* LastBinaryOperator */); - var binaryKeywordOperators = [100 /* InKeyword */, 101 /* InstanceOfKeyword */, 156 /* OfKeyword */, 126 /* AsKeyword */, 137 /* IsKeyword */]; + var keywords = tokenRangeFromRange(81 /* FirstKeyword */, 158 /* LastKeyword */); + var binaryOperators = tokenRangeFromRange(29 /* FirstBinaryOperator */, 78 /* LastBinaryOperator */); + var binaryKeywordOperators = [101 /* InKeyword */, 102 /* InstanceOfKeyword */, 158 /* OfKeyword */, 127 /* AsKeyword */, 138 /* IsKeyword */]; var unaryPrefixOperators = [45 /* PlusPlusToken */, 46 /* MinusMinusToken */, 54 /* TildeToken */, 53 /* ExclamationToken */]; var unaryPrefixExpressions = [ - 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 78 /* Identifier */, 20 /* OpenParenToken */, - 22 /* OpenBracketToken */, 18 /* OpenBraceToken */, 107 /* ThisKeyword */, 102 /* NewKeyword */ + 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 79 /* Identifier */, 20 /* OpenParenToken */, + 22 /* OpenBracketToken */, 18 /* OpenBraceToken */, 108 /* ThisKeyword */, 103 /* NewKeyword */ ]; - var unaryPreincrementExpressions = [78 /* Identifier */, 20 /* OpenParenToken */, 107 /* ThisKeyword */, 102 /* NewKeyword */]; - var unaryPostincrementExpressions = [78 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 102 /* NewKeyword */]; - var unaryPredecrementExpressions = [78 /* Identifier */, 20 /* OpenParenToken */, 107 /* ThisKeyword */, 102 /* NewKeyword */]; - var unaryPostdecrementExpressions = [78 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 102 /* 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([78 /* Identifier */], ts.typeKeywords); + var typeNames = __spreadArray([79 /* Identifier */], ts.typeKeywords); // 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([78 /* Identifier */, 3 /* MultiLineCommentTrivia */, 83 /* ClassKeyword */, 92 /* ExportKeyword */, 99 /* ImportKeyword */]); + var typeScriptOpenBraceLeftTokenRange = tokenRangeFrom([79 /* Identifier */, 3 /* MultiLineCommentTrivia */, 84 /* ClassKeyword */, 93 /* ExportKeyword */, 100 /* ImportKeyword */]); // Place a space before open brace in a control flow construct - var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 89 /* DoKeyword */, 110 /* TryKeyword */, 95 /* FinallyKeyword */, 90 /* ElseKeyword */]); + var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 90 /* DoKeyword */, 111 /* TryKeyword */, 96 /* FinallyKeyword */, 91 /* ElseKeyword */]); // These rules are higher in priority than user-configurable var highPriorityCommonRules = [ // Leave comments alone @@ -131830,7 +136675,7 @@ var ts; 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", 99 /* ImportKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 16 /* DeleteSpace */), + rule("NoSpaceBetweenImportParenInImportType", 100 /* ImportKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 16 /* DeleteSpace */), // Special handling of unary operators. // Prefix operators generally shouldn't have a space between // them and their target unary expression. @@ -131857,79 +136702,79 @@ var ts; rule("SpaceAfterCloseBrace", 19 /* CloseBraceToken */, anyTokenExcept(21 /* CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 4 /* 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 */, 90 /* ElseKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBetweenCloseBraceAndWhile", 19 /* CloseBraceToken */, 114 /* WhileKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + 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 */), // 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", 97 /* FunctionKeyword */, 41 /* AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 16 /* DeleteSpace */), - rule("SpaceAfterStarInGeneratorDeclaration", 41 /* AsteriskToken */, 78 /* Identifier */, [isFunctionDeclarationOrFunctionExpressionContext], 4 /* InsertSpace */), - rule("SpaceAfterFunctionInFuncDecl", 97 /* FunctionKeyword */, anyToken, [isFunctionDeclContext], 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 */), // Insert new line after { and before } in multi-line contexts. rule("NewLineAfterOpenBraceInBlockContext", 18 /* OpenBraceToken */, anyToken, [isMultilineBlockContext], 8 /* 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", [134 /* GetKeyword */, 146 /* SetKeyword */], 78 /* Identifier */, [isFunctionDeclContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenYieldKeywordAndStar", 124 /* YieldKeyword */, 41 /* AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 16 /* DeleteSpace */), - rule("SpaceBetweenYieldOrYieldStarAndOperand", [124 /* YieldKeyword */, 41 /* AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 4 /* InsertSpace */), - rule("NoSpaceBetweenReturnAndSemicolon", 104 /* ReturnKeyword */, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("SpaceAfterCertainKeywords", [112 /* VarKeyword */, 108 /* ThrowKeyword */, 102 /* NewKeyword */, 88 /* DeleteKeyword */, 104 /* ReturnKeyword */, 111 /* TypeOfKeyword */, 130 /* AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceAfterLetConstInVariableDeclaration", [118 /* LetKeyword */, 84 /* ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 4 /* InsertSpace */), + rule("SpaceAfterGetSetInMember", [135 /* GetKeyword */, 147 /* 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 */, 131 /* 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 */), // 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", 113 /* VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 4 /* InsertSpace */), + rule("SpaceAfterVoidOperator", 114 /* VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 4 /* InsertSpace */), // Async-await - rule("SpaceBetweenAsyncAndOpenParen", 129 /* AsyncKeyword */, 20 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBetweenAsyncAndFunctionKeyword", 129 /* AsyncKeyword */, [97 /* FunctionKeyword */, 78 /* Identifier */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenAsyncAndOpenParen", 130 /* AsyncKeyword */, 20 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenAsyncAndFunctionKeyword", 130 /* AsyncKeyword */, [98 /* FunctionKeyword */, 79 /* Identifier */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Template string - rule("NoSpaceBetweenTagAndTemplateString", [78 /* Identifier */, 21 /* CloseParenToken */], [14 /* NoSubstitutionTemplateLiteral */, 15 /* TemplateHead */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBetweenTagAndTemplateString", [79 /* Identifier */, 21 /* CloseParenToken */], [14 /* NoSubstitutionTemplateLiteral */, 15 /* TemplateHead */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // JSX opening elements - rule("SpaceBeforeJsxAttribute", anyToken, 78 /* Identifier */, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + 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, 62 /* EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterEqualInJsxAttribute", 62 /* EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeEqualInJsxAttribute", anyToken, 63 /* EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterEqualInJsxAttribute", 63 /* EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // TypeScript-specific rules // Use of module as a function call. e.g.: import m2 = module("m2"); - rule("NoSpaceAfterModuleImport", [139 /* ModuleKeyword */, 143 /* RequireKeyword */], 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterModuleImport", [140 /* ModuleKeyword */, 144 /* RequireKeyword */], 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Add a space around certain TypeScript keywords rule("SpaceAfterCertainTypeScriptKeywords", [ - 125 /* AbstractKeyword */, - 83 /* ClassKeyword */, - 133 /* DeclareKeyword */, - 87 /* DefaultKeyword */, - 91 /* EnumKeyword */, - 92 /* ExportKeyword */, - 93 /* ExtendsKeyword */, - 134 /* GetKeyword */, - 116 /* ImplementsKeyword */, - 99 /* ImportKeyword */, - 117 /* InterfaceKeyword */, - 139 /* ModuleKeyword */, - 140 /* NamespaceKeyword */, - 120 /* PrivateKeyword */, - 122 /* PublicKeyword */, - 121 /* ProtectedKeyword */, - 142 /* ReadonlyKeyword */, - 146 /* SetKeyword */, - 123 /* StaticKeyword */, - 149 /* TypeKeyword */, - 153 /* FromKeyword */, - 138 /* KeyOfKeyword */, - 135 /* InferKeyword */, + 126 /* AbstractKeyword */, + 84 /* ClassKeyword */, + 134 /* DeclareKeyword */, + 88 /* DefaultKeyword */, + 92 /* EnumKeyword */, + 93 /* ExportKeyword */, + 94 /* ExtendsKeyword */, + 135 /* GetKeyword */, + 117 /* ImplementsKeyword */, + 100 /* ImportKeyword */, + 118 /* InterfaceKeyword */, + 140 /* ModuleKeyword */, + 141 /* NamespaceKeyword */, + 121 /* PrivateKeyword */, + 123 /* PublicKeyword */, + 122 /* ProtectedKeyword */, + 143 /* ReadonlyKeyword */, + 147 /* SetKeyword */, + 124 /* StaticKeyword */, + 150 /* TypeKeyword */, + 154 /* FromKeyword */, + 139 /* KeyOfKeyword */, + 136 /* InferKeyword */, ], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [93 /* ExtendsKeyword */, 116 /* ImplementsKeyword */, 153 /* FromKeyword */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [94 /* ExtendsKeyword */, 117 /* ImplementsKeyword */, 154 /* FromKeyword */], [isNonJsxSameLineTokenContext], 4 /* 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 */), // Lambda expressions rule("SpaceBeforeArrow", anyToken, 38 /* EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), rule("SpaceAfterArrow", 38 /* EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Optional parameters and let args - rule("NoSpaceAfterEllipsis", 25 /* DotDotDotToken */, 78 /* Identifier */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterEllipsis", 25 /* DotDotDotToken */, 79 /* Identifier */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), rule("NoSpaceAfterOptionalParameters", 57 /* QuestionToken */, [21 /* CloseParenToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */), // Remove spaces in empty interface literals. e.g.: x: {} rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 16 /* DeleteSpace */), @@ -131940,38 +136785,38 @@ var ts; 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 */), // decorators - rule("SpaceBeforeAt", [21 /* CloseParenToken */, 78 /* Identifier */], 59 /* AtToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeAt", [21 /* CloseParenToken */, 79 /* Identifier */], 59 /* AtToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), rule("NoSpaceAfterAt", 59 /* AtToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Insert space after @ in decorator rule("SpaceAfterDecorator", anyToken, [ - 125 /* AbstractKeyword */, - 78 /* Identifier */, - 92 /* ExportKeyword */, - 87 /* DefaultKeyword */, - 83 /* ClassKeyword */, - 123 /* StaticKeyword */, - 122 /* PublicKeyword */, - 120 /* PrivateKeyword */, - 121 /* ProtectedKeyword */, - 134 /* GetKeyword */, - 146 /* SetKeyword */, + 126 /* AbstractKeyword */, + 79 /* Identifier */, + 93 /* ExportKeyword */, + 88 /* DefaultKeyword */, + 84 /* ClassKeyword */, + 124 /* StaticKeyword */, + 123 /* PublicKeyword */, + 121 /* PrivateKeyword */, + 122 /* ProtectedKeyword */, + 135 /* GetKeyword */, + 147 /* SetKeyword */, 22 /* OpenBracketToken */, 41 /* AsteriskToken */, ], [isEndOfDecoratorContextOnSameLine], 4 /* InsertSpace */), rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 53 /* ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterNewKeywordOnConstructorSignature", 102 /* NewKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterNewKeywordOnConstructorSignature", 103 /* NewKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 16 /* DeleteSpace */), rule("SpaceLessThanAndNonJSXTypeAnnotation", 29 /* LessThanToken */, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext], 4 /* 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", 132 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceAfterConstructor", 132 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterConstructor", 133 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceAfterConstructor", 133 /* 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 */), // Insert space after function keyword for anonymous functions - rule("SpaceAfterAnonymousFunctionKeyword", [97 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 4 /* InsertSpace */), - rule("NoSpaceAfterAnonymousFunctionKeyword", [97 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 16 /* DeleteSpace */), + 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 */), // 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 */), @@ -132040,16 +136885,16 @@ var ts; rule("SpaceBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), rule("NoSpaceBeforeComma", anyToken, 27 /* CommaToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // No space before and after indexer `x[]` - rule("NoSpaceBeforeOpenBracket", anyTokenExcept(129 /* AsyncKeyword */, 81 /* CaseKeyword */), 22 /* OpenBracketToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeOpenBracket", anyTokenExcept(130 /* 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 */), // Remove extra space between for and await - rule("SpaceBetweenForAndAwaitKeyword", 96 /* ForKeyword */, 130 /* AwaitKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenForAndAwaitKeyword", 97 /* ForKeyword */, 131 /* AwaitKeyword */, [isNonJsxSameLineTokenContext], 4 /* 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 */, 89 /* DoKeyword */, 90 /* ElseKeyword */, 81 /* CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 4 /* InsertSpace */), + rule("SpaceBetweenStatements", [21 /* CloseParenToken */, 90 /* DoKeyword */, 91 /* ElseKeyword */, 82 /* CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 4 /* InsertSpace */), // This low-pri rule takes care of "try {", "catch {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. - rule("SpaceAfterTryCatchFinally", [110 /* TryKeyword */, 82 /* CatchKeyword */, 95 /* FinallyKeyword */], 18 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceAfterTryCatchFinally", [111 /* TryKeyword */, 83 /* CatchKeyword */, 96 /* FinallyKeyword */], 18 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), ]; return __spreadArray(__spreadArray(__spreadArray([], highPriorityCommonRules), userConfigurableRules), lowPriorityCommonRules); } @@ -132108,51 +136953,51 @@ var ts; return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; }; } function isForContext(context) { - return context.contextNode.kind === 237 /* ForStatement */; + return context.contextNode.kind === 239 /* ForStatement */; } function isNotForContext(context) { return !isForContext(context); } function isBinaryOpContext(context) { switch (context.contextNode.kind) { - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return context.contextNode.operatorToken.kind !== 27 /* CommaToken */; - case 217 /* ConditionalExpression */: - case 184 /* ConditionalType */: - case 224 /* AsExpression */: - case 270 /* ExportSpecifier */: - case 265 /* ImportSpecifier */: - case 172 /* TypePredicate */: - case 182 /* UnionType */: - case 183 /* IntersectionType */: + case 219 /* ConditionalExpression */: + case 186 /* ConditionalType */: + case 226 /* AsExpression */: + case 272 /* ExportSpecifier */: + case 267 /* ImportSpecifier */: + case 174 /* TypePredicate */: + case 184 /* UnionType */: + case 185 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 198 /* BindingElement */: + case 200 /* BindingElement */: // equals in type X = ... // falls through - case 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: // equal in import a = module('a'); // falls through - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: // equal in let a = 0 // falls through - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: // equal in p = 0 // falls through - case 160 /* Parameter */: - case 291 /* EnumMember */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - return context.currentTokenSpan.kind === 62 /* EqualsToken */ || context.nextTokenSpan.kind === 62 /* EqualsToken */; + case 162 /* Parameter */: + case 293 /* EnumMember */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + return context.currentTokenSpan.kind === 63 /* EqualsToken */ || context.nextTokenSpan.kind === 63 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: // "in" keyword in [P in keyof T]: T[P] // falls through - case 159 /* TypeParameter */: - return context.currentTokenSpan.kind === 100 /* InKeyword */ || context.nextTokenSpan.kind === 100 /* InKeyword */ || context.currentTokenSpan.kind === 62 /* EqualsToken */ || context.nextTokenSpan.kind === 62 /* EqualsToken */; + case 161 /* TypeParameter */: + return context.currentTokenSpan.kind === 101 /* InKeyword */ || context.nextTokenSpan.kind === 101 /* InKeyword */ || context.currentTokenSpan.kind === 63 /* EqualsToken */ || context.nextTokenSpan.kind === 63 /* EqualsToken */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 239 /* ForOfStatement */: - return context.currentTokenSpan.kind === 156 /* OfKeyword */ || context.nextTokenSpan.kind === 156 /* OfKeyword */; + case 241 /* ForOfStatement */: + return context.currentTokenSpan.kind === 158 /* OfKeyword */ || context.nextTokenSpan.kind === 158 /* OfKeyword */; } return false; } @@ -132164,22 +137009,22 @@ var ts; } function isTypeAnnotationContext(context) { var contextKind = context.contextNode.kind; - return contextKind === 163 /* PropertyDeclaration */ || - contextKind === 162 /* PropertySignature */ || - contextKind === 160 /* Parameter */ || - contextKind === 249 /* VariableDeclaration */ || + return contextKind === 165 /* PropertyDeclaration */ || + contextKind === 164 /* PropertySignature */ || + contextKind === 162 /* Parameter */ || + contextKind === 251 /* VariableDeclaration */ || ts.isFunctionLikeKind(contextKind); } function isConditionalOperatorContext(context) { - return context.contextNode.kind === 217 /* ConditionalExpression */ || - context.contextNode.kind === 184 /* ConditionalType */; + return context.contextNode.kind === 219 /* ConditionalExpression */ || + context.contextNode.kind === 186 /* ConditionalType */; } function isSameLineTokenOrBeforeBlockContext(context) { return context.TokensAreOnSameLine() || isBeforeBlockContext(context); } function isBraceWrappedContext(context) { - return context.contextNode.kind === 196 /* ObjectBindingPattern */ || - context.contextNode.kind === 190 /* MappedType */ || + return context.contextNode.kind === 198 /* ObjectBindingPattern */ || + context.contextNode.kind === 192 /* MappedType */ || isSingleLineBlockContext(context); } // This check is done before an open brace in a control construct, a function, or a typescript block declaration @@ -132205,34 +137050,34 @@ var ts; return true; } switch (node.kind) { - case 230 /* Block */: - case 258 /* CaseBlock */: - case 200 /* ObjectLiteralExpression */: - case 257 /* ModuleBlock */: + case 232 /* Block */: + case 260 /* CaseBlock */: + case 202 /* ObjectLiteralExpression */: + case 259 /* ModuleBlock */: return true; } return false; } function isFunctionDeclContext(context) { switch (context.contextNode.kind) { - case 251 /* FunctionDeclaration */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 253 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: // falls through - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: // case SyntaxKind.MethodSignature: // falls through - case 169 /* CallSignature */: - case 208 /* FunctionExpression */: - case 166 /* Constructor */: - case 209 /* ArrowFunction */: + case 171 /* CallSignature */: + case 210 /* FunctionExpression */: + case 168 /* Constructor */: + case 211 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: // falls through - case 253 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one + case 255 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one return true; } return false; @@ -132241,40 +137086,40 @@ var ts; return !isFunctionDeclContext(context); } function isFunctionDeclarationOrFunctionExpressionContext(context) { - return context.contextNode.kind === 251 /* FunctionDeclaration */ || context.contextNode.kind === 208 /* FunctionExpression */; + return context.contextNode.kind === 253 /* FunctionDeclaration */ || context.contextNode.kind === 210 /* FunctionExpression */; } function isTypeScriptDeclWithBlockContext(context) { return nodeIsTypeScriptDeclWithBlockContext(context.contextNode); } function nodeIsTypeScriptDeclWithBlockContext(node) { switch (node.kind) { - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - case 177 /* TypeLiteral */: - case 256 /* ModuleDeclaration */: - case 267 /* ExportDeclaration */: - case 268 /* NamedExports */: - case 261 /* ImportDeclaration */: - case 264 /* NamedImports */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: + case 257 /* EnumDeclaration */: + case 179 /* TypeLiteral */: + case 258 /* ModuleDeclaration */: + case 269 /* ExportDeclaration */: + case 270 /* NamedExports */: + case 263 /* ImportDeclaration */: + case 266 /* NamedImports */: return true; } return false; } function isAfterCodeBlockContext(context) { switch (context.currentTokenParent.kind) { - case 252 /* ClassDeclaration */: - case 256 /* ModuleDeclaration */: - case 255 /* EnumDeclaration */: - case 287 /* CatchClause */: - case 257 /* ModuleBlock */: - case 244 /* SwitchStatement */: + case 254 /* ClassDeclaration */: + case 258 /* ModuleDeclaration */: + case 257 /* EnumDeclaration */: + case 289 /* CatchClause */: + case 259 /* ModuleBlock */: + case 246 /* SwitchStatement */: return true; - case 230 /* Block */: { + case 232 /* 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 !== 209 /* ArrowFunction */ && blockParent.kind !== 208 /* FunctionExpression */) { + if (!blockParent || blockParent.kind !== 211 /* ArrowFunction */ && blockParent.kind !== 210 /* FunctionExpression */) { return true; } } @@ -132283,32 +137128,32 @@ var ts; } function isControlDeclContext(context) { switch (context.contextNode.kind) { - case 234 /* IfStatement */: - case 244 /* SwitchStatement */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 236 /* WhileStatement */: - case 247 /* TryStatement */: - case 235 /* DoStatement */: - case 243 /* WithStatement */: + case 236 /* IfStatement */: + case 246 /* SwitchStatement */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 238 /* WhileStatement */: + case 249 /* TryStatement */: + case 237 /* DoStatement */: + case 245 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: // falls through - case 287 /* CatchClause */: + case 289 /* CatchClause */: return true; default: return false; } } function isObjectContext(context) { - return context.contextNode.kind === 200 /* ObjectLiteralExpression */; + return context.contextNode.kind === 202 /* ObjectLiteralExpression */; } function isFunctionCallContext(context) { - return context.contextNode.kind === 203 /* CallExpression */; + return context.contextNode.kind === 205 /* CallExpression */; } function isNewContext(context) { - return context.contextNode.kind === 204 /* NewExpression */; + return context.contextNode.kind === 206 /* NewExpression */; } function isFunctionCallOrNewContext(context) { return isFunctionCallContext(context) || isNewContext(context); @@ -132323,10 +137168,10 @@ var ts; return context.nextTokenSpan.kind !== 21 /* CloseParenToken */; } function isArrowFunctionContext(context) { - return context.contextNode.kind === 209 /* ArrowFunction */; + return context.contextNode.kind === 211 /* ArrowFunction */; } function isImportTypeContext(context) { - return context.contextNode.kind === 195 /* ImportType */; + return context.contextNode.kind === 197 /* ImportType */; } function isNonJsxSameLineTokenContext(context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 11 /* JsxText */; @@ -132335,19 +137180,19 @@ var ts; return context.contextNode.kind !== 11 /* JsxText */; } function isNonJsxElementOrFragmentContext(context) { - return context.contextNode.kind !== 273 /* JsxElement */ && context.contextNode.kind !== 277 /* JsxFragment */; + return context.contextNode.kind !== 275 /* JsxElement */ && context.contextNode.kind !== 279 /* JsxFragment */; } function isJsxExpressionContext(context) { - return context.contextNode.kind === 283 /* JsxExpression */ || context.contextNode.kind === 282 /* JsxSpreadAttribute */; + return context.contextNode.kind === 285 /* JsxExpression */ || context.contextNode.kind === 284 /* JsxSpreadAttribute */; } function isNextTokenParentJsxAttribute(context) { - return context.nextTokenParent.kind === 280 /* JsxAttribute */; + return context.nextTokenParent.kind === 282 /* JsxAttribute */; } function isJsxAttributeContext(context) { - return context.contextNode.kind === 280 /* JsxAttribute */; + return context.contextNode.kind === 282 /* JsxAttribute */; } function isJsxSelfClosingElementContext(context) { - return context.contextNode.kind === 274 /* JsxSelfClosingElement */; + return context.contextNode.kind === 276 /* JsxSelfClosingElement */; } function isNotBeforeBlockInFunctionDeclarationContext(context) { return !isFunctionDeclContext(context) && !isBeforeBlockContext(context); @@ -132362,45 +137207,45 @@ var ts; while (ts.isExpressionNode(node)) { node = node.parent; } - return node.kind === 161 /* Decorator */; + return node.kind === 163 /* Decorator */; } function isStartOfVariableDeclarationList(context) { - return context.currentTokenParent.kind === 250 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 252 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; } function isNotFormatOnEnter(context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; } function isModuleDeclContext(context) { - return context.contextNode.kind === 256 /* ModuleDeclaration */; + return context.contextNode.kind === 258 /* ModuleDeclaration */; } function isObjectTypeContext(context) { - return context.contextNode.kind === 177 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 179 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; } function isConstructorSignatureContext(context) { - return context.contextNode.kind === 170 /* ConstructSignature */; + return context.contextNode.kind === 172 /* ConstructSignature */; } function isTypeArgumentOrParameterOrAssertion(token, parent) { if (token.kind !== 29 /* LessThanToken */ && token.kind !== 31 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 173 /* TypeReference */: - case 206 /* TypeAssertionExpression */: - case 254 /* TypeAliasDeclaration */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 203 /* CallExpression */: - case 204 /* NewExpression */: - case 223 /* ExpressionWithTypeArguments */: + case 175 /* TypeReference */: + case 208 /* TypeAssertionExpression */: + case 256 /* TypeAliasDeclaration */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: + case 225 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -132411,28 +137256,28 @@ var ts; isTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); } function isTypeAssertionContext(context) { - return context.contextNode.kind === 206 /* TypeAssertionExpression */; + return context.contextNode.kind === 208 /* TypeAssertionExpression */; } function isVoidOpContext(context) { - return context.currentTokenSpan.kind === 113 /* VoidKeyword */ && context.currentTokenParent.kind === 212 /* VoidExpression */; + return context.currentTokenSpan.kind === 114 /* VoidKeyword */ && context.currentTokenParent.kind === 214 /* VoidExpression */; } function isYieldOrYieldStarWithOperand(context) { - return context.contextNode.kind === 219 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 221 /* YieldExpression */ && context.contextNode.expression !== undefined; } function isNonNullAssertionContext(context) { - return context.contextNode.kind === 225 /* NonNullExpression */; + return context.contextNode.kind === 227 /* NonNullExpression */; } function isNotStatementConditionContext(context) { return !isStatementConditionContext(context); } function isStatementConditionContext(context) { switch (context.contextNode.kind) { - case 234 /* IfStatement */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: + case 236 /* IfStatement */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: return true; default: return false; @@ -132457,12 +137302,12 @@ var ts; return nextTokenKind === 19 /* CloseBraceToken */ || nextTokenKind === 1 /* EndOfFileToken */; } - if (nextTokenKind === 229 /* SemicolonClassElement */ || + if (nextTokenKind === 231 /* SemicolonClassElement */ || nextTokenKind === 26 /* SemicolonToken */) { return false; } - if (context.contextNode.kind === 253 /* InterfaceDeclaration */ || - context.contextNode.kind === 254 /* TypeAliasDeclaration */) { + if (context.contextNode.kind === 255 /* InterfaceDeclaration */ || + context.contextNode.kind === 256 /* TypeAliasDeclaration */) { // Can’t remove semicolon after `foo`; it would parse as a method declaration: // // interface I { @@ -132476,9 +137321,9 @@ var ts; if (ts.isPropertyDeclaration(context.currentTokenParent)) { return !context.currentTokenParent.initializer; } - return context.currentTokenParent.kind !== 237 /* ForStatement */ - && context.currentTokenParent.kind !== 231 /* EmptyStatement */ - && context.currentTokenParent.kind !== 229 /* SemicolonClassElement */ + return context.currentTokenParent.kind !== 239 /* ForStatement */ + && context.currentTokenParent.kind !== 233 /* EmptyStatement */ + && context.currentTokenParent.kind !== 231 /* SemicolonClassElement */ && nextTokenKind !== 22 /* OpenBracketToken */ && nextTokenKind !== 20 /* OpenParenToken */ && nextTokenKind !== 39 /* PlusToken */ @@ -132486,7 +137331,7 @@ var ts; && nextTokenKind !== 43 /* SlashToken */ && nextTokenKind !== 13 /* RegularExpressionLiteral */ && nextTokenKind !== 27 /* CommaToken */ - && nextTokenKind !== 218 /* TemplateExpression */ + && nextTokenKind !== 220 /* TemplateExpression */ && nextTokenKind !== 15 /* TemplateHead */ && nextTokenKind !== 14 /* NoSubstitutionTemplateLiteral */ && nextTokenKind !== 24 /* DotToken */; @@ -132577,12 +137422,12 @@ var ts; return map; } function getRuleBucketIndex(row, column) { - ts.Debug.assert(row <= 156 /* LastKeyword */ && column <= 156 /* LastKeyword */, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 158 /* LastKeyword */ && column <= 158 /* LastKeyword */, "Must compute formatting context from tokens"); return (row * mapRowLength) + column; } var maskBitSize = 5; var mask = 31; // MaskBitSize bits - var mapRowLength = 156 /* LastToken */ + 1; + var mapRowLength = 158 /* LastToken */ + 1; var RulesPosition; (function (RulesPosition) { RulesPosition[RulesPosition["StopRulesSpecific"] = 0] = "StopRulesSpecific"; @@ -132770,17 +137615,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 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: var body = parent.body; - return !!body && body.kind === 257 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 297 /* SourceFile */: - case 230 /* Block */: - case 257 /* ModuleBlock */: + return !!body && body.kind === 259 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 299 /* SourceFile */: + case 232 /* Block */: + case 259 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -132934,14 +137779,17 @@ var ts; processNode(enclosingNode, enclosingNode, startLine, undecoratedStartLine, initialIndentation, delta); } if (!formattingScanner.isOnToken()) { + var indentation = formatting.SmartIndenter.nodeWillIndentChild(options, enclosingNode, /*child*/ undefined, sourceFile, /*indentByDefault*/ false) + ? initialIndentation + options.indentSize + : initialIndentation; var leadingTrivia = formattingScanner.getCurrentLeadingTrivia(); if (leadingTrivia) { - indentTriviaItems(leadingTrivia, initialIndentation, /*indentNextTokenOrTrivia*/ false, function (item) { return processRange(item, sourceFile.getLineAndCharacterOfPosition(item.pos), enclosingNode, enclosingNode, /*dynamicIndentation*/ undefined); }); - if (options.trimTrailingWhitespace !== false) { - trimTrailingWhitespacesForRemainingRange(); - } + indentTriviaItems(leadingTrivia, indentation, /*indentNextTokenOrTrivia*/ false, function (item) { return processRange(item, sourceFile.getLineAndCharacterOfPosition(item.pos), enclosingNode, enclosingNode, /*dynamicIndentation*/ undefined); }); } } + if (options.trimTrailingWhitespace !== false) { + trimTrailingWhitespacesForRemainingRange(); + } return edits; // local functions /** Tries to compute the indentation for a list element. @@ -132988,10 +137836,9 @@ var ts; // - we need to get the indentation on last line and the delta of parent return { indentation: indentationOnLastIndentedLine, delta: parentDynamicIndentation.getDelta(node) }; } - else if (formatting.SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement(parent, node, startLine, sourceFile)) { - return { indentation: parentDynamicIndentation.getIndentation(), delta: delta }; - } - else if (formatting.SmartIndenter.argumentStartsOnSameLineAsPreviousArgument(parent, node, startLine, sourceFile)) { + else if (formatting.SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement(parent, node, startLine, sourceFile) || + formatting.SmartIndenter.childIsUnindentedBranchOfConditionalExpression(parent, node, startLine, sourceFile) || + formatting.SmartIndenter.argumentStartsOnSameLineAsPreviousArgument(parent, node, startLine, sourceFile)) { return { indentation: parentDynamicIndentation.getIndentation(), delta: delta }; } else { @@ -133007,19 +137854,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 252 /* ClassDeclaration */: return 83 /* ClassKeyword */; - case 253 /* InterfaceDeclaration */: return 117 /* InterfaceKeyword */; - case 251 /* FunctionDeclaration */: return 97 /* FunctionKeyword */; - case 255 /* EnumDeclaration */: return 255 /* EnumDeclaration */; - case 167 /* GetAccessor */: return 134 /* GetKeyword */; - case 168 /* SetAccessor */: return 146 /* SetKeyword */; - case 165 /* MethodDeclaration */: + case 254 /* ClassDeclaration */: return 84 /* ClassKeyword */; + case 255 /* InterfaceDeclaration */: return 118 /* InterfaceKeyword */; + case 253 /* FunctionDeclaration */: return 98 /* FunctionKeyword */; + case 257 /* EnumDeclaration */: return 257 /* EnumDeclaration */; + case 169 /* GetAccessor */: return 135 /* GetKeyword */; + case 170 /* SetAccessor */: return 147 /* SetKeyword */; + case 167 /* MethodDeclaration */: if (node.asteriskToken) { return 41 /* AsteriskToken */; } // falls through - case 163 /* PropertyDeclaration */: - case 160 /* Parameter */: + case 165 /* PropertyDeclaration */: + case 162 /* Parameter */: var name = ts.getNameOfDeclaration(node); if (name) { return name.kind; @@ -133069,22 +137916,23 @@ var ts; case 18 /* OpenBraceToken */: case 19 /* CloseBraceToken */: case 21 /* CloseParenToken */: - case 90 /* ElseKeyword */: - case 114 /* WhileKeyword */: + case 91 /* ElseKeyword */: + case 115 /* WhileKeyword */: case 59 /* AtToken */: return false; case 43 /* SlashToken */: case 31 /* GreaterThanToken */: switch (container.kind) { - case 275 /* JsxOpeningElement */: - case 276 /* JsxClosingElement */: - case 274 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: + case 278 /* JsxClosingElement */: + case 276 /* JsxSelfClosingElement */: + case 225 /* ExpressionWithTypeArguments */: return false; } break; case 22 /* OpenBracketToken */: case 23 /* CloseBracketToken */: - if (container.kind !== 190 /* MappedType */) { + if (container.kind !== 192 /* MappedType */) { return false; } break; @@ -133129,11 +137977,6 @@ var ts; if (tokenInfo.token.end > node.end) { break; } - if (node.kind === 11 /* JsxText */) { - // Intentation rules for jsx text are handled by `indentMultilineCommentOrJsxText` inside `processChildNode`; just fastforward past it here - formattingScanner.advance(); - continue; - } consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation, node); } if (!node.parent && formattingScanner.isOnEOF()) { @@ -133192,27 +138035,11 @@ var ts; return inheritedIndentation; } } - var effectiveParentStartLine = child.kind === 161 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 163 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); - if (child.kind === 11 /* JsxText */) { - var range = { pos: child.getStart(), end: child.getEnd() }; - if (range.pos !== range.end) { // don't indent zero-width jsx text - var siblings = parent.getChildren(sourceFile); - var currentIndex = ts.findIndex(siblings, function (arg) { return arg.pos === child.pos; }); - var previousNode = siblings[currentIndex - 1]; - if (previousNode) { - // The jsx text needs no indentation whatsoever if it ends on the same line the previous sibling ends on - if (sourceFile.getLineAndCharacterOfPosition(range.end).line !== sourceFile.getLineAndCharacterOfPosition(previousNode.end).line) { - // The first line is (already) "indented" if the text starts on the same line as the previous sibling element ends on - var firstLineIsIndented = sourceFile.getLineAndCharacterOfPosition(range.pos).line === sourceFile.getLineAndCharacterOfPosition(previousNode.end).line; - indentMultilineCommentOrJsxText(range, childIndentation.indentation, firstLineIsIndented, /*indentFinalLine*/ false, /*jsxStyle*/ true); - } - } - } - } childContextNode = node; - if (isFirstListItem && parent.kind === 199 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 201 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -133336,7 +138163,7 @@ var ts; switch (triviaItem.kind) { case 3 /* MultiLineCommentTrivia */: if (triviaInRange) { - indentMultilineCommentOrJsxText(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia); + indentMultilineComment(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia); } indentNextTokenOrTrivia = false; break; @@ -133453,7 +138280,7 @@ var ts; function indentationIsDifferent(indentationString, startLinePosition) { return indentationString !== sourceFile.text.substr(startLinePosition, indentationString.length); } - function indentMultilineCommentOrJsxText(commentRange, indentation, firstLineIsIndented, indentFinalLine, jsxTextStyleIndent) { + function indentMultilineComment(commentRange, indentation, firstLineIsIndented, indentFinalLine) { if (indentFinalLine === void 0) { indentFinalLine = true; } // split comment in lines var startLine = sourceFile.getLineAndCharacterOfPosition(commentRange.pos).line; @@ -133491,13 +138318,6 @@ var ts; var nonWhitespaceCharacterAndColumn = i === 0 ? nonWhitespaceColumnInFirstPart : formatting.SmartIndenter.findFirstNonWhitespaceCharacterAndColumn(parts[i].pos, parts[i].end, sourceFile, options); - if (jsxTextStyleIndent) { - // skip adding indentation to blank lines - if (ts.isLineBreak(sourceFile.text.charCodeAt(ts.getStartPositionOfLine(startLine, sourceFile)))) - continue; - // reset delta on every line - delta = indentation - nonWhitespaceCharacterAndColumn.column; - } var newIndentation = nonWhitespaceCharacterAndColumn.column + delta; if (newIndentation > 0) { var indentationString = getIndentationString(newIndentation, options); @@ -133652,12 +138472,12 @@ var ts; formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment; function getOpenTokenForList(node, list) { switch (node.kind) { - case 166 /* Constructor */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 209 /* ArrowFunction */: + case 168 /* Constructor */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 211 /* ArrowFunction */: if (node.typeParameters === list) { return 29 /* LessThanToken */; } @@ -133665,8 +138485,8 @@ var ts; return 20 /* OpenParenToken */; } break; - case 203 /* CallExpression */: - case 204 /* NewExpression */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: if (node.typeArguments === list) { return 29 /* LessThanToken */; } @@ -133674,12 +138494,12 @@ var ts; return 20 /* OpenParenToken */; } break; - case 173 /* TypeReference */: + case 175 /* TypeReference */: if (node.typeArguments === list) { return 29 /* LessThanToken */; } break; - case 177 /* TypeLiteral */: + case 179 /* TypeLiteral */: return 18 /* OpenBraceToken */; } return 0 /* Unknown */; @@ -133797,7 +138617,7 @@ var ts; if (options.indentStyle === ts.IndentStyle.Block) { return getBlockIndent(sourceFile, position, options); } - if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 216 /* BinaryExpression */) { + if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 218 /* 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 */) { @@ -133880,6 +138700,7 @@ var ts; } SmartIndenter.getBaseIndentation = getBaseIndentation; function getIndentationForNodeWorker(current, currentStart, ignoreActualIndentationRange, indentationDelta, sourceFile, isNextChild, options) { + var _a; var parent = current.parent; // Walk up the tree and collect indentation for parent-child node pairs. Indentation is not added if // * parent and child nodes start on the same line, or @@ -133895,7 +138716,25 @@ var ts; childStartsOnTheSameLineWithElseInIfStatement(parent, current, currentStart.line, sourceFile); if (useActualIndentation) { // check if current node is a list item - if yes, take indentation from it - var actualIndentation = getActualIndentationForListItem(current, sourceFile, options, !parentAndChildShareLine); + var firstListChild = (_a = getContainingList(current, sourceFile)) === null || _a === void 0 ? void 0 : _a[0]; + // A list indents its children if the children begin on a later line than the list itself: + // + // f1( L0 - List start + // { L1 - First child start: indented, along with all other children + // prop: 0 + // }, + // { + // prop: 1 + // } + // ) + // + // f2({ L0 - List start and first child start: children are not indented. + // prop: 0 Object properties are indented only one level, because the list + // }, { itself contributes nothing. + // prop: 1 L3 - The indentation of the second object literal is best understood by + // }) 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 */) { return actualIndentation + indentationDelta; } @@ -133951,7 +138790,7 @@ 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 === 297 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 299 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -133999,8 +138838,8 @@ var ts; } SmartIndenter.isArgumentAndStartLineOverlapsExpressionBeingCalled = isArgumentAndStartLineOverlapsExpressionBeingCalled; function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 234 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 90 /* ElseKeyword */, sourceFile); + if (parent.kind === 236 /* IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 91 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -134008,6 +138847,49 @@ var ts; return false; } SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement = childStartsOnTheSameLineWithElseInIfStatement; + // A multiline conditional typically increases the indentation of its whenTrue and whenFalse children: + // + // condition + // ? whenTrue + // : whenFalse; + // + // However, that indentation does not apply if the subexpressions themselves span multiple lines, + // applying their own indentation: + // + // (() => { + // return complexCalculationForCondition(); + // })() ? { + // whenTrue: 'multiline object literal' + // } : ( + // whenFalse('multiline parenthesized expression') + // ); + // + // In these cases, we must discard the indentation increase that would otherwise be applied to the + // whenTrue and whenFalse children to avoid double-indenting their contents. To identify this scenario, + // we check for the whenTrue branch beginning on the line that the condition ends, and the whenFalse + // branch beginning on the line that the whenTrue branch ends. + function childIsUnindentedBranchOfConditionalExpression(parent, child, childStartLine, sourceFile) { + if (ts.isConditionalExpression(parent) && (child === parent.whenTrue || child === parent.whenFalse)) { + var conditionEndLine = ts.getLineAndCharacterOfPosition(sourceFile, parent.condition.end).line; + if (child === parent.whenTrue) { + return childStartLine === conditionEndLine; + } + else { + // On the whenFalse side, we have to look at the whenTrue side, because if that one was + // indented, whenFalse must also be indented: + // + // const y = true + // ? 1 : ( L1: whenTrue indented because it's on a new line + // 0 L2: indented two stops, one because whenTrue was indented + // ); and one because of the parentheses spanning multiple lines + var trueStartLine = getStartLineAndCharacterForNode(parent.whenTrue, sourceFile).line; + var trueEndLine = ts.getLineAndCharacterOfPosition(sourceFile, parent.whenTrue.end).line; + return conditionEndLine === trueStartLine && trueEndLine === childStartLine; + } + } + return false; + } + SmartIndenter.childIsUnindentedBranchOfConditionalExpression = childIsUnindentedBranchOfConditionalExpression; function argumentStartsOnSameLineAsPreviousArgument(parent, child, childStartLine, sourceFile) { if (ts.isCallOrNewExpression(parent)) { if (!parent.arguments) @@ -134037,40 +138919,40 @@ var ts; } function getListByRange(start, end, node, sourceFile) { switch (node.kind) { - case 173 /* TypeReference */: + case 175 /* TypeReference */: return getList(node.typeArguments); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return getList(node.properties); - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return getList(node.elements); - case 177 /* TypeLiteral */: + case 179 /* TypeLiteral */: return getList(node.members); - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 169 /* CallSignature */: - case 166 /* Constructor */: - case 175 /* ConstructorType */: - case 170 /* ConstructSignature */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 171 /* CallSignature */: + case 168 /* Constructor */: + case 177 /* ConstructorType */: + case 172 /* ConstructSignature */: return getList(node.typeParameters) || getList(node.parameters); - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 330 /* JSDocTemplateTag */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 338 /* JSDocTemplateTag */: return getList(node.typeParameters); - case 204 /* NewExpression */: - case 203 /* CallExpression */: + case 206 /* NewExpression */: + case 205 /* CallExpression */: return getList(node.typeArguments) || getList(node.arguments); - case 250 /* VariableDeclarationList */: + case 252 /* VariableDeclarationList */: return getList(node.declarations); - case 264 /* NamedImports */: - case 268 /* NamedExports */: + case 266 /* NamedImports */: + case 270 /* NamedExports */: return getList(node.elements); - case 196 /* ObjectBindingPattern */: - case 197 /* ArrayBindingPattern */: + case 198 /* ObjectBindingPattern */: + case 199 /* ArrayBindingPattern */: return getList(node.elements); } function getList(list) { @@ -134093,7 +138975,7 @@ var ts; return findColumnForFirstNonWhitespaceCharacterInLine(sourceFile.getLineAndCharacterOfPosition(list.pos), sourceFile, options); } function getActualIndentationForListItem(node, sourceFile, options, listIndentsChild) { - if (node.parent && node.parent.kind === 250 /* VariableDeclarationList */) { + if (node.parent && node.parent.kind === 252 /* VariableDeclarationList */) { // VariableDeclarationList has no wrapping tokens return -1 /* Unknown */; } @@ -134166,94 +139048,94 @@ var ts; function nodeWillIndentChild(settings, parent, child, sourceFile, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 233 /* ExpressionStatement */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 199 /* ArrayLiteralExpression */: - case 230 /* Block */: - case 257 /* ModuleBlock */: - case 200 /* ObjectLiteralExpression */: - case 177 /* TypeLiteral */: - case 190 /* MappedType */: - case 179 /* TupleType */: - case 258 /* CaseBlock */: - case 285 /* DefaultClause */: - case 284 /* CaseClause */: - case 207 /* ParenthesizedExpression */: - case 201 /* PropertyAccessExpression */: - case 203 /* CallExpression */: - case 204 /* NewExpression */: - case 232 /* VariableStatement */: - case 266 /* ExportAssignment */: - case 242 /* ReturnStatement */: - case 217 /* ConditionalExpression */: - case 197 /* ArrayBindingPattern */: - case 196 /* ObjectBindingPattern */: - case 275 /* JsxOpeningElement */: - case 278 /* JsxOpeningFragment */: - case 274 /* JsxSelfClosingElement */: - case 283 /* JsxExpression */: - case 164 /* MethodSignature */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 160 /* Parameter */: - case 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 186 /* ParenthesizedType */: - case 205 /* TaggedTemplateExpression */: - case 213 /* AwaitExpression */: - case 268 /* NamedExports */: - case 264 /* NamedImports */: - case 270 /* ExportSpecifier */: - case 265 /* ImportSpecifier */: - case 163 /* PropertyDeclaration */: + case 235 /* ExpressionStatement */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: + case 257 /* EnumDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 201 /* ArrayLiteralExpression */: + case 232 /* Block */: + case 259 /* ModuleBlock */: + case 202 /* ObjectLiteralExpression */: + case 179 /* TypeLiteral */: + case 192 /* MappedType */: + case 181 /* TupleType */: + case 260 /* CaseBlock */: + case 287 /* DefaultClause */: + case 286 /* CaseClause */: + case 209 /* ParenthesizedExpression */: + case 203 /* PropertyAccessExpression */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: + case 234 /* VariableStatement */: + case 268 /* ExportAssignment */: + case 244 /* ReturnStatement */: + case 219 /* ConditionalExpression */: + case 199 /* ArrayBindingPattern */: + case 198 /* ObjectBindingPattern */: + case 277 /* JsxOpeningElement */: + case 280 /* JsxOpeningFragment */: + case 276 /* JsxSelfClosingElement */: + case 285 /* JsxExpression */: + case 166 /* MethodSignature */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 162 /* Parameter */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: + case 188 /* ParenthesizedType */: + case 207 /* TaggedTemplateExpression */: + case 215 /* AwaitExpression */: + case 270 /* NamedExports */: + case 266 /* NamedImports */: + case 272 /* ExportSpecifier */: + case 267 /* ImportSpecifier */: + case 165 /* PropertyDeclaration */: return true; - case 249 /* VariableDeclaration */: - case 288 /* PropertyAssignment */: - case 216 /* BinaryExpression */: - if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 200 /* ObjectLiteralExpression */) { // TODO: GH#18217 + case 251 /* VariableDeclaration */: + case 290 /* PropertyAssignment */: + case 218 /* BinaryExpression */: + if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 202 /* ObjectLiteralExpression */) { // TODO: GH#18217 return rangeIsOnOneLine(sourceFile, child); } - if (parent.kind !== 216 /* BinaryExpression */) { + if (parent.kind !== 218 /* BinaryExpression */) { return true; } break; - case 235 /* DoStatement */: - case 236 /* WhileStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 237 /* ForStatement */: - case 234 /* IfStatement */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - return childKind !== 230 /* Block */; - case 209 /* ArrowFunction */: - if (sourceFile && childKind === 207 /* ParenthesizedExpression */) { + case 237 /* DoStatement */: + case 238 /* WhileStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 239 /* ForStatement */: + case 236 /* IfStatement */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 167 /* MethodDeclaration */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + return childKind !== 232 /* Block */; + case 211 /* ArrowFunction */: + if (sourceFile && childKind === 209 /* ParenthesizedExpression */) { return rangeIsOnOneLine(sourceFile, child); } - return childKind !== 230 /* Block */; - case 267 /* ExportDeclaration */: - return childKind !== 268 /* NamedExports */; - case 261 /* ImportDeclaration */: - return childKind !== 262 /* ImportClause */ || - (!!child.namedBindings && child.namedBindings.kind !== 264 /* NamedImports */); - case 273 /* JsxElement */: - return childKind !== 276 /* JsxClosingElement */; - case 277 /* JsxFragment */: - return childKind !== 279 /* JsxClosingFragment */; - case 183 /* IntersectionType */: - case 182 /* UnionType */: - if (childKind === 177 /* TypeLiteral */ || childKind === 179 /* TupleType */) { + return childKind !== 232 /* Block */; + case 269 /* ExportDeclaration */: + return childKind !== 270 /* NamedExports */; + case 263 /* ImportDeclaration */: + return childKind !== 264 /* ImportClause */ || + (!!child.namedBindings && child.namedBindings.kind !== 266 /* NamedImports */); + case 275 /* JsxElement */: + return childKind !== 278 /* JsxClosingElement */; + case 279 /* JsxFragment */: + return childKind !== 281 /* JsxClosingFragment */; + case 185 /* IntersectionType */: + case 184 /* UnionType */: + if (childKind === 179 /* TypeLiteral */ || childKind === 181 /* TupleType */) { return false; } - // falls through + break; } // No explicit rule for given nodes so the result will follow the default value argument return indentByDefault; @@ -134261,11 +139143,11 @@ var ts; SmartIndenter.nodeWillIndentChild = nodeWillIndentChild; function isControlFlowEndingStatement(kind, parent) { switch (kind) { - case 242 /* ReturnStatement */: - case 246 /* ThrowStatement */: - case 240 /* ContinueStatement */: - case 241 /* BreakStatement */: - return parent.kind !== 230 /* Block */; + case 244 /* ReturnStatement */: + case 248 /* ThrowStatement */: + case 242 /* ContinueStatement */: + case 243 /* BreakStatement */: + return parent.kind !== 232 /* Block */; default: return false; } @@ -134373,7 +139255,9 @@ var ts; function getAdjustedRange(sourceFile, startNode, endNode, options) { return { pos: getAdjustedStartPosition(sourceFile, startNode, options), end: getAdjustedEndPosition(sourceFile, endNode, options) }; } - function getAdjustedStartPosition(sourceFile, node, options) { + function getAdjustedStartPosition(sourceFile, node, options, hasTrailingComment) { + var _a, _b; + if (hasTrailingComment === void 0) { hasTrailingComment = false; } var leadingTriviaOption = options.leadingTriviaOption; if (leadingTriviaOption === LeadingTriviaOption.Exclude) { return node.getStart(sourceFile); @@ -134404,6 +139288,15 @@ var ts; // when b is deleted - we delete it return leadingTriviaOption === LeadingTriviaOption.IncludeAll ? fullStart : start; } + // if node has a trailing comments, use comment end position as the text has already been included. + if (hasTrailingComment) { + // Check first for leading comments as if the node is the first import, we want to exclude the trivia; + // otherwise we get the trailing comments. + var comment = ((_a = ts.getLeadingCommentRanges(sourceFile.text, fullStart)) === null || _a === void 0 ? void 0 : _a[0]) || ((_b = ts.getTrailingCommentRanges(sourceFile.text, fullStart)) === null || _b === void 0 ? void 0 : _b[0]); + if (comment) { + return ts.skipTrivia(sourceFile.text, comment.end, /*stopAfterLineBreak*/ true, /*stopAtComments*/ true); + } + } // get start position of the line following the line that contains fullstart position // (but only if the fullstart isn't the very beginning of the file) var nextLineStart = fullStart > 0 ? 1 : 0; @@ -134412,6 +139305,35 @@ var ts; adjustedStartPosition = skipWhitespacesAndLineBreaks(sourceFile.text, adjustedStartPosition); return ts.getStartPositionOfLine(ts.getLineOfLocalPosition(sourceFile, adjustedStartPosition), sourceFile); } + /** Return the end position of a multiline comment of it is on another line; otherwise returns `undefined`; */ + function getEndPositionOfMultilineTrailingComment(sourceFile, node, options) { + var end = node.end; + var trailingTriviaOption = options.trailingTriviaOption; + if (trailingTriviaOption === TrailingTriviaOption.Include) { + // If the trailing comment is a multiline comment that extends to the next lines, + // return the end of the comment and track it for the next nodes to adjust. + var comments = ts.getTrailingCommentRanges(sourceFile.text, end); + if (comments) { + var nodeEndLine = ts.getLineOfLocalPosition(sourceFile, node.end); + for (var _i = 0, comments_2 = comments; _i < comments_2.length; _i++) { + 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) { + break; + } + // Get the end line of the comment and compare against the end line of the node. + // If the comment end line position and the multiline comment extends to multiple lines, + // then is safe to return the end position. + var commentEndLine = ts.getLineOfLocalPosition(sourceFile, comment.end); + if (commentEndLine > nodeEndLine) { + return ts.skipTrivia(sourceFile.text, comment.end, /*stopAfterLineBreak*/ true, /*stopAtComments*/ true); + } + } + } + } + return undefined; + } function getAdjustedEndPosition(sourceFile, node, options) { var _a; var end = node.end; @@ -134427,6 +139349,10 @@ var ts; } return end; } + var multilineEndPosition = getEndPositionOfMultilineTrailingComment(sourceFile, node, options); + if (multilineEndPosition) { + return multilineEndPosition; + } var newEnd = ts.skipTrivia(sourceFile.text, end, /*stopAfterLineBreak*/ true); return newEnd !== end && (trailingTriviaOption === TrailingTriviaOption.Include || ts.isLineBreak(sourceFile.text.charCodeAt(newEnd - 1))) ? newEnd @@ -134436,14 +139362,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 === 200 /* ObjectLiteralExpression */)); - } - function spaces(count) { - var s = ""; - for (var i = 0; i < count; i++) { - s += " "; - } - return s; + return !!candidate && !!node.parent && (candidate.kind === 27 /* CommaToken */ || (candidate.kind === 26 /* SemicolonToken */ && node.parent.kind === 202 /* ObjectLiteralExpression */)); } function isThisTypeAnnotatable(containingFunction) { return ts.isFunctionExpression(containingFunction) || ts.isFunctionDeclaration(containingFunction); @@ -134489,6 +139408,17 @@ var ts; if (options === void 0) { options = { leadingTriviaOption: LeadingTriviaOption.IncludeAll }; } this.deleteRange(sourceFile, getAdjustedRange(sourceFile, node, node, options)); }; + ChangeTracker.prototype.deleteNodes = function (sourceFile, nodes, options, hasTrailingComment) { + if (options === void 0) { options = { leadingTriviaOption: LeadingTriviaOption.IncludeAll }; } + // When deleting multiple nodes we need to track if the end position is including multiline trailing comments. + for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { + var node = nodes_1[_i]; + var pos = getAdjustedStartPosition(sourceFile, node, options, hasTrailingComment); + var end = getAdjustedEndPosition(sourceFile, node, options); + this.deleteRange(sourceFile, { pos: pos, end: end }); + hasTrailingComment = !!getEndPositionOfMultilineTrailingComment(sourceFile, node, options); + } + }; ChangeTracker.prototype.deleteModifier = function (sourceFile, modifier) { this.deleteRange(sourceFile, { pos: modifier.getStart(sourceFile), end: ts.skipTrivia(sourceFile.text, modifier.end, /*stopAfterLineBreak*/ true) }); }; @@ -134531,6 +139461,10 @@ var ts; if (options === void 0) { options = useNonAdjustedPositions; } this.replaceRangeWithNodes(sourceFile, getAdjustedRange(sourceFile, startNode, endNode, options), newNodes, options); }; + ChangeTracker.prototype.nodeHasTrailingComment = function (sourceFile, oldNode, configurableEnd) { + if (configurableEnd === void 0) { configurableEnd = useNonAdjustedPositions; } + return !!getEndPositionOfMultilineTrailingComment(sourceFile, oldNode, configurableEnd); + }; ChangeTracker.prototype.nextCommaToken = function (sourceFile, node) { var next = ts.findNextToken(node, node.parent, sourceFile); return next && next.kind === 27 /* CommaToken */ ? next : undefined; @@ -134635,7 +139569,7 @@ var ts; } } else { - endNode = (_a = (node.kind === 249 /* VariableDeclaration */ ? node.exclamationToken : node.questionToken)) !== null && _a !== void 0 ? _a : node.name; + endNode = (_a = (node.kind === 251 /* VariableDeclaration */ ? node.exclamationToken : node.questionToken)) !== null && _a !== void 0 ? _a : node.name; } this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " }); return true; @@ -134677,6 +139611,15 @@ var ts; this.insertNodeBefore(sourceFile, firstStatement, newStatement); } }; + ChangeTracker.prototype.insertNodeAtConstructorStartAfterSuperCall = function (sourceFile, ctr, newStatement) { + var superCallStatement = ts.find(ctr.body.statements, function (stmt) { return ts.isExpressionStatement(stmt) && ts.isSuperCall(stmt.expression); }); + if (!superCallStatement || !ctr.body.multiLine) { + this.replaceConstructorBody(sourceFile, ctr, __spreadArray(__spreadArray([], ctr.body.statements), [newStatement])); + } + else { + this.insertNodeAfter(sourceFile, superCallStatement, newStatement); + } + }; ChangeTracker.prototype.insertNodeAtConstructorEnd = function (sourceFile, ctr, newStatement) { var lastStatement = ts.lastOrUndefined(ctr.body.statements); if (!lastStatement || !ctr.body.multiLine) { @@ -134792,18 +139735,18 @@ var ts; }; ChangeTracker.prototype.getInsertNodeAfterOptionsWorker = function (node) { switch (node.kind) { - case 252 /* ClassDeclaration */: - case 256 /* ModuleDeclaration */: + case 254 /* ClassDeclaration */: + case 258 /* ModuleDeclaration */: return { prefix: this.newLineCharacter, suffix: this.newLineCharacter }; - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: case 10 /* StringLiteral */: - case 78 /* Identifier */: + case 79 /* Identifier */: return { prefix: ", " }; - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: return { suffix: "," + this.newLineCharacter }; - case 92 /* ExportKeyword */: + case 93 /* ExportKeyword */: return { prefix: " " }; - case 160 /* Parameter */: + case 162 /* Parameter */: return {}; default: ts.Debug.assert(ts.isStatement(node) || ts.isClassOrTypeElement(node)); // Else we haven't handled this kind of node yet -- add it @@ -134812,12 +139755,12 @@ var ts; }; ChangeTracker.prototype.insertName = function (sourceFile, node, name) { ts.Debug.assert(!node.name); - if (node.kind === 209 /* ArrowFunction */) { + if (node.kind === 211 /* ArrowFunction */) { var arrow = ts.findChildOfKind(node, 38 /* EqualsGreaterThanToken */, sourceFile); var lparen = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); if (lparen) { // `() => {}` --> `function f() {}` - this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.factory.createToken(97 /* FunctionKeyword */), ts.factory.createIdentifier(name)], { joiner: " " }); + this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.factory.createToken(98 /* FunctionKeyword */), ts.factory.createIdentifier(name)], { joiner: " " }); deleteNode(this, sourceFile, arrow); } else { @@ -134826,14 +139769,14 @@ var ts; // Replacing full range of arrow to get rid of the leading space -- replace ` =>` with `)` this.replaceRange(sourceFile, arrow, ts.factory.createToken(21 /* CloseParenToken */)); } - if (node.body.kind !== 230 /* Block */) { + if (node.body.kind !== 232 /* Block */) { // `() => 0` => `function f() { return 0; }` - this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.factory.createToken(18 /* OpenBraceToken */), ts.factory.createToken(104 /* ReturnKeyword */)], { joiner: " ", suffix: " " }); + 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: " " }); } } else { - var pos = ts.findChildOfKind(node, node.kind === 208 /* FunctionExpression */ ? 97 /* FunctionKeyword */ : 83 /* ClassKeyword */, sourceFile).end; + var pos = ts.findChildOfKind(node, node.kind === 210 /* FunctionExpression */ ? 98 /* FunctionKeyword */ : 84 /* ClassKeyword */, sourceFile).end; this.insertNodeAt(sourceFile, pos, ts.factory.createIdentifier(name), { prefix: " " }); } }; @@ -134865,47 +139808,22 @@ var ts; // a, b, c // create change for adding 'e' after 'a' as // - find start of next element after a (it is b) - // - use this start as start and end position in final change - // - build text of change by formatting the text of node + separator + whitespace trivia of b + // - use next element start as start and end position in final change + // - build text of change by formatting the text of node + whitespace trivia of b // in multiline case it will work as // a, // b, // c, // result - '*' denotes leading trivia that will be inserted after new text (displayed as '#') - // a,* - // ***insertedtext# + // a, + // insertedtext# // ###b, // c, - // find line and character of the next element - var lineAndCharOfNextElement = ts.getLineAndCharacterOfPosition(sourceFile, skipWhitespacesAndLineBreaks(sourceFile.text, containingList[index + 1].getFullStart())); - // find line and character of the token that precedes next element (usually it is separator) - var lineAndCharOfNextToken = ts.getLineAndCharacterOfPosition(sourceFile, nextToken.end); - var prefix = void 0; - var startPos = void 0; - if (lineAndCharOfNextToken.line === lineAndCharOfNextElement.line) { - // next element is located on the same line with separator: - // a,$$$$b - // ^ ^ - // | |-next element - // |-separator - // where $$$ is some leading trivia - // for a newly inserted node we'll maintain the same relative position comparing to separator and replace leading trivia with spaces - // a, x,$$$$b - // ^ ^ ^ - // | | |-next element - // | |-new inserted node padded with spaces - // |-separator - startPos = nextToken.end; - prefix = spaces(lineAndCharOfNextElement.character - lineAndCharOfNextToken.character); - } - else { - // next element is located on different line that separator - // let insert position be the beginning of the line that contains next element - startPos = ts.getStartPositionOfLine(lineAndCharOfNextElement.line, sourceFile); - } + 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, containingList[index + 1].getStart(sourceFile)); - this.replaceRange(sourceFile, ts.createRange(startPos, containingList[index + 1].getStart(sourceFile)), newNode, { prefix: prefix, suffix: suffix }); + var suffix = "" + ts.tokenToString(nextToken.kind) + sourceFile.text.substring(nextToken.end, startPos); + this.insertNodesAt(sourceFile, startPos, [newNode], { suffix: suffix }); } } else { @@ -134977,7 +139895,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_9 = function (sourceFile, node) { + var _loop_10 = 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)); @@ -134990,7 +139908,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_9(sourceFile, node); + _loop_10(sourceFile, node); } deletedNodesInLists.forEach(function (node) { var sourceFile = node.getSourceFile(); @@ -135049,14 +139967,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_10 = function (i) { + var _loop_11 = 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); }); }; // verify that change intervals do not overlap, except possibly at end points. for (var i = 0; i < normalized.length - 1; i++) { - _loop_10(i); + _loop_11(i); } var textChanges = ts.mapDefined(normalized, function (c) { var span = ts.createTextSpanFromRange(c.range); @@ -135170,11 +140088,12 @@ var ts; function createWriter(newLine) { var lastNonTriviaPosition = 0; var writer = ts.createTextWriter(newLine); - var onEmitNode = function (hint, node, printCallback) { + var onBeforeEmitNode = function (node) { if (node) { setPos(node, lastNonTriviaPosition); } - printCallback(hint, node); + }; + var onAfterEmitNode = function (node) { if (node) { setEnd(node, lastNonTriviaPosition); } @@ -135293,7 +140212,8 @@ var ts; lastNonTriviaPosition = 0; } return { - onEmitNode: onEmitNode, + onBeforeEmitNode: onBeforeEmitNode, + onAfterEmitNode: onAfterEmitNode, onBeforeEmitNodeArray: onBeforeEmitNodeArray, onAfterEmitNodeArray: onAfterEmitNodeArray, onBeforeEmitToken: onBeforeEmitToken, @@ -135408,14 +140328,14 @@ var ts; } textChanges_3.isValidLocationToAddComment = isValidLocationToAddComment; function needSemicolonBetween(a, b) { - return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 158 /* ComputedPropertyName */ + return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 160 /* 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 160 /* Parameter */: { + case 162 /* Parameter */: { var oldFunction = node.parent; if (ts.isArrowFunction(oldFunction) && oldFunction.parameters.length === 1 && @@ -135430,15 +140350,17 @@ var ts; } break; } - case 261 /* ImportDeclaration */: - case 260 /* ImportEqualsDeclaration */: + case 263 /* ImportDeclaration */: + case 262 /* 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 }); + deleteNode(changes, sourceFile, node, { + leadingTriviaOption: isFirstImport ? LeadingTriviaOption.Exclude : ts.hasJSDocNodes(node) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine, + }); break; - case 198 /* BindingElement */: + case 200 /* BindingElement */: var pattern = node.parent; - var preserveComma = pattern.kind === 197 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); + var preserveComma = pattern.kind === 199 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); if (preserveComma) { deleteNode(changes, sourceFile, node); } @@ -135446,13 +140368,13 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node); break; - case 159 /* TypeParameter */: + case 161 /* TypeParameter */: deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); break; - case 265 /* ImportSpecifier */: + case 267 /* ImportSpecifier */: var namedImports = node.parent; if (namedImports.elements.length === 1) { deleteImportBinding(changes, sourceFile, namedImports); @@ -135461,21 +140383,25 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: deleteImportBinding(changes, sourceFile, node); break; case 26 /* SemicolonToken */: deleteNode(changes, sourceFile, node, { trailingTriviaOption: TrailingTriviaOption.Exclude }); break; - case 97 /* FunctionKeyword */: + case 98 /* FunctionKeyword */: deleteNode(changes, sourceFile, node, { leadingTriviaOption: LeadingTriviaOption.Exclude }); break; - case 252 /* ClassDeclaration */: - case 251 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: + case 253 /* FunctionDeclaration */: deleteNode(changes, sourceFile, node, { leadingTriviaOption: ts.hasJSDocNodes(node) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine }); break; default: - if (ts.isImportClause(node.parent) && node.parent.name === node) { + if (!node.parent) { + // a misbehaving client can reach here with the SourceFile node + deleteNode(changes, sourceFile, node); + } + else if (ts.isImportClause(node.parent) && node.parent.name === node) { deleteDefaultImport(changes, sourceFile, node.parent); } else if (ts.isCallExpression(node.parent) && ts.contains(node.parent.arguments, node)) { @@ -135518,13 +140444,13 @@ var ts; // Delete the entire import declaration // |import * as ns from './file'| // |import { a } from './file'| - var importDecl = ts.getAncestor(node, 261 /* ImportDeclaration */); + var importDecl = ts.getAncestor(node, 263 /* ImportDeclaration */); deleteNode(changes, sourceFile, importDecl); } } function deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node) { var parent = node.parent; - if (parent.kind === 287 /* CatchClause */) { + if (parent.kind === 289 /* 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)); return; @@ -135535,14 +140461,14 @@ var ts; } var gp = parent.parent; switch (gp.kind) { - case 239 /* ForOfStatement */: - case 238 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 240 /* ForInStatement */: changes.replaceNode(sourceFile, node, ts.factory.createObjectLiteralExpression()); break; - case 237 /* ForStatement */: + case 239 /* ForStatement */: deleteNode(changes, sourceFile, parent); break; - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: deleteNode(changes, sourceFile, gp, { leadingTriviaOption: ts.hasJSDocNodes(gp) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine }); break; default: @@ -135598,6 +140524,10 @@ var ts; return createCodeFixActionWorker(fixName, diagnosticToString(description), changes, fixId, diagnosticToString(fixAllDescription), command); } codefix.createCodeFixAction = createCodeFixAction; + function createCodeFixActionMaybeFixAll(fixName, changes, description, fixId, fixAllDescription, command) { + return createCodeFixActionWorker(fixName, diagnosticToString(description), changes, fixId, fixAllDescription && diagnosticToString(fixAllDescription), command); + } + codefix.createCodeFixActionMaybeFixAll = createCodeFixActionMaybeFixAll; function createCodeFixActionWorker(fixName, description, changes, fixId, fixAllDescription, command) { return { fixName: fixName, description: description, changes: changes, fixId: fixId, fixAllDescription: fixAllDescription, commands: command ? [command] : undefined }; } @@ -135724,8 +140654,8 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, pos); var assertion = ts.Debug.checkDefined(ts.findAncestor(token, function (n) { return ts.isAsExpression(n) || ts.isTypeAssertionExpression(n); }), "Expected to find an assertion expression"); var replacement = ts.isAsExpression(assertion) - ? ts.factory.createAsExpression(assertion.expression, ts.factory.createKeywordTypeNode(152 /* UnknownKeyword */)) - : ts.factory.createTypeAssertion(ts.factory.createKeywordTypeNode(152 /* UnknownKeyword */), assertion.expression); + ? ts.factory.createAsExpression(assertion.expression, ts.factory.createKeywordTypeNode(153 /* UnknownKeyword */)) + : ts.factory.createTypeAssertion(ts.factory.createKeywordTypeNode(153 /* UnknownKeyword */), assertion.expression); changeTracker.replaceNode(sourceFile, assertion.expression, replacement); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -135736,7 +140666,10 @@ var ts; var codefix; (function (codefix) { codefix.registerCodeFix({ - errorCodes: [ts.Diagnostics.await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module.code], + errorCodes: [ + ts.Diagnostics.await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module.code, + ts.Diagnostics.for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module.code, + ], getCodeActions: function (context) { var sourceFile = context.sourceFile; var changes = ts.textChanges.ChangeTracker.with(context, function (changes) { @@ -135849,6 +140782,7 @@ var ts; ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1.code, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2.code, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap.code, + ts.Diagnostics.This_condition_will_always_return_true_since_this_0_is_always_defined.code, ts.Diagnostics.Type_0_is_not_an_array_type.code, ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type.code, ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators.code, @@ -135947,14 +140881,14 @@ var ts; } var isCompleteFix = identifiers.isCompleteFix; var initializers; - var _loop_11 = function (identifier) { + var _loop_12 = 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, 232 /* VariableStatement */); + var variableStatement = ts.getAncestor(declaration, 234 /* VariableStatement */); if (!declaration || !variableStatement || declaration.type || !declaration.initializer || @@ -135980,7 +140914,7 @@ var ts; }; for (var _i = 0, _a = identifiers.identifiers; _i < _a.length; _i++) { var identifier = _a[_i]; - _loop_11(identifier); + _loop_12(identifier); } return initializers && { initializers: initializers, @@ -136032,10 +140966,10 @@ var ts; function isInsideAwaitableBody(node) { return node.kind & 32768 /* AwaitContext */ || !!ts.findAncestor(node, function (ancestor) { return ancestor.parent && ts.isArrowFunction(ancestor.parent) && ancestor.parent.body === ancestor || - ts.isBlock(ancestor) && (ancestor.parent.kind === 251 /* FunctionDeclaration */ || - ancestor.parent.kind === 208 /* FunctionExpression */ || - ancestor.parent.kind === 209 /* ArrowFunction */ || - ancestor.parent.kind === 165 /* MethodDeclaration */); + ts.isBlock(ancestor) && (ancestor.parent.kind === 253 /* FunctionDeclaration */ || + ancestor.parent.kind === 210 /* FunctionExpression */ || + ancestor.parent.kind === 211 /* ArrowFunction */ || + ancestor.parent.kind === 167 /* MethodDeclaration */); }); } function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite, fixedDeclarations) { @@ -136124,7 +141058,7 @@ var ts; if (forInitializer) return applyChange(changeTracker, forInitializer, sourceFile, fixedNodes); var parent = token.parent; - if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 62 /* EqualsToken */ && ts.isExpressionStatement(parent.parent)) { + if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isExpressionStatement(parent.parent)) { return applyChange(changeTracker, token, sourceFile, fixedNodes); } if (ts.isArrayLiteralExpression(parent)) { @@ -136148,16 +141082,16 @@ var ts; } function applyChange(changeTracker, initializer, sourceFile, fixedNodes) { if (!fixedNodes || ts.tryAddToSet(fixedNodes, initializer)) { - changeTracker.insertModifierBefore(sourceFile, 84 /* ConstKeyword */, initializer); + changeTracker.insertModifierBefore(sourceFile, 85 /* ConstKeyword */, initializer); } } function isPossiblyPartOfDestructuring(node) { switch (node.kind) { - case 78 /* Identifier */: - case 199 /* ArrayLiteralExpression */: - case 200 /* ObjectLiteralExpression */: - case 288 /* PropertyAssignment */: - case 289 /* ShorthandPropertyAssignment */: + case 79 /* Identifier */: + case 201 /* ArrayLiteralExpression */: + case 202 /* ObjectLiteralExpression */: + case 290 /* PropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return true; default: return false; @@ -136171,8 +141105,8 @@ var ts; } function isPossiblyPartOfCommaSeperatedInitializer(node) { switch (node.kind) { - case 78 /* Identifier */: - case 216 /* BinaryExpression */: + case 79 /* Identifier */: + case 218 /* BinaryExpression */: case 27 /* CommaToken */: return true; default: @@ -136186,7 +141120,7 @@ var ts; if (expression.operatorToken.kind === 27 /* CommaToken */) { return ts.every([expression.left, expression.right], function (expression) { return expressionCouldBeVariableDeclaration(expression, checker); }); } - return expression.operatorToken.kind === 62 /* EqualsToken */ + return expression.operatorToken.kind === 63 /* EqualsToken */ && ts.isIdentifier(expression.left) && !checker.getSymbolAtLocation(expression.left); } @@ -136221,9 +141155,9 @@ var ts; return; } var declaration = token.parent; - if (declaration.kind === 163 /* PropertyDeclaration */ && + if (declaration.kind === 165 /* PropertyDeclaration */ && (!fixedNodes || ts.tryAddToSet(fixedNodes, declaration))) { - changeTracker.insertModifierBefore(sourceFile, 133 /* DeclareKeyword */, declaration); + changeTracker.insertModifierBefore(sourceFile, 134 /* DeclareKeyword */, declaration); } } })(codefix = ts.codefix || (ts.codefix = {})); @@ -136358,26 +141292,26 @@ var ts; } function isDeclarationWithType(node) { return ts.isFunctionLikeDeclaration(node) || - node.kind === 249 /* VariableDeclaration */ || - node.kind === 162 /* PropertySignature */ || - node.kind === 163 /* PropertyDeclaration */; + node.kind === 251 /* VariableDeclaration */ || + node.kind === 164 /* PropertySignature */ || + node.kind === 165 /* PropertyDeclaration */; } function transformJSDocType(node) { switch (node.kind) { - case 303 /* JSDocAllType */: - case 304 /* JSDocUnknownType */: + case 306 /* JSDocAllType */: + case 307 /* JSDocUnknownType */: return ts.factory.createTypeReferenceNode("any", ts.emptyArray); - case 307 /* JSDocOptionalType */: + case 310 /* JSDocOptionalType */: return transformJSDocOptionalType(node); - case 306 /* JSDocNonNullableType */: + case 309 /* JSDocNonNullableType */: return transformJSDocType(node.type); - case 305 /* JSDocNullableType */: + case 308 /* JSDocNullableType */: return transformJSDocNullableType(node); - case 309 /* JSDocVariadicType */: + case 312 /* JSDocVariadicType */: return transformJSDocVariadicType(node); - case 308 /* JSDocFunctionType */: + case 311 /* JSDocFunctionType */: return transformJSDocFunctionType(node); - case 173 /* TypeReference */: + case 175 /* TypeReference */: return transformJSDocTypeReference(node); default: var visited = ts.visitEachChild(node, transformJSDocType, ts.nullTransformationContext); @@ -136398,11 +141332,11 @@ 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(128 /* AnyKeyword */)); + return ts.factory.createFunctionTypeNode(ts.emptyArray, node.parameters.map(transformJSDocParameter), (_a = node.type) !== null && _a !== void 0 ? _a : ts.factory.createKeywordTypeNode(129 /* AnyKeyword */)); } function transformJSDocParameter(node) { var index = node.parent.parameters.indexOf(node); - var isRest = node.type.kind === 309 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 + var isRest = node.type.kind === 312 /* 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; return ts.factory.createParameterDeclaration(node.decorators, node.modifiers, dotdotdot, name, node.questionToken, ts.visitNode(node.type, transformJSDocType), node.initializer); @@ -136442,8 +141376,8 @@ var ts; var index = ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 144 /* NumberKeyword */ ? "n" : "s", - /*questionToken*/ undefined, ts.factory.createTypeReferenceNode(node.typeArguments[0].kind === 144 /* NumberKeyword */ ? "number" : "string", []), + /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 145 /* NumberKeyword */ ? "n" : "s", + /*questionToken*/ undefined, ts.factory.createTypeReferenceNode(node.typeArguments[0].kind === 145 /* NumberKeyword */ ? "number" : "string", []), /*initializer*/ undefined); var indexSignature = ts.factory.createTypeLiteralNode([ts.factory.createIndexSignature(/*decorators*/ undefined, /*modifiers*/ undefined, [index], node.typeArguments[1])]); ts.setEmitFlags(indexSignature, 1 /* SingleLine */); @@ -136473,7 +141407,7 @@ var ts; }); function doChange(changes, sourceFile, position, checker, preferences, compilerOptions) { var ctorSymbol = checker.getSymbolAtLocation(ts.getTokenAtPosition(sourceFile, position)); - if (!ctorSymbol || !(ctorSymbol.flags & (16 /* Function */ | 3 /* Variable */))) { + if (!ctorSymbol || !ctorSymbol.valueDeclaration || !(ctorSymbol.flags & (16 /* Function */ | 3 /* Variable */))) { // Bad input return undefined; } @@ -136500,7 +141434,7 @@ var ts; // all instance members are stored in the "member" array of symbol if (symbol.members) { symbol.members.forEach(function (member, key) { - if (key === "constructor") { + if (key === "constructor" && member.valueDeclaration) { // fn.prototype.constructor = fn changes.delete(sourceFile, member.valueDeclaration.parent); return; @@ -136514,13 +141448,13 @@ var ts; // all static members are stored in the "exports" array of symbol if (symbol.exports) { symbol.exports.forEach(function (member) { - if (member.name === "prototype") { + if (member.name === "prototype" && member.declarations) { var firstDeclaration = member.declarations[0]; // only one "x.prototype = { ... }" will pass if (member.declarations.length === 1 && ts.isPropertyAccessExpression(firstDeclaration) && ts.isBinaryExpression(firstDeclaration.parent) && - firstDeclaration.parent.operatorToken.kind === 62 /* EqualsToken */ && + firstDeclaration.parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isObjectLiteralExpression(firstDeclaration.parent.right)) { var prototypes = firstDeclaration.parent.right; var memberElement = createClassElement(prototypes.symbol, /** modifiers */ undefined); @@ -136530,7 +141464,7 @@ var ts; } } else { - var memberElement = createClassElement(member, [ts.factory.createToken(123 /* StaticKeyword */)]); + var memberElement = createClassElement(member, [ts.factory.createToken(124 /* StaticKeyword */)]); if (memberElement) { memberElements.push.apply(memberElements, memberElement); } @@ -136576,7 +141510,7 @@ var ts; return members; } // delete the entire statement if this expression is the sole expression to take care of the semicolon at the end - var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 233 /* ExpressionStatement */ + var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 235 /* ExpressionStatement */ ? assignmentBinaryExpression.parent : assignmentBinaryExpression; changes.delete(sourceFile, nodeToDelete); if (!assignmentExpr) { @@ -136627,7 +141561,7 @@ var ts; return createArrowFunctionExpressionMember(members, expression, name); } function createFunctionExpressionMember(members, functionExpression, name) { - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 129 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 130 /* AsyncKeyword */)); var method = ts.factory.createMethodDeclaration(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined, /*typeParameters*/ undefined, functionExpression.parameters, /*type*/ undefined, functionExpression.body); ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); @@ -136637,14 +141571,14 @@ var ts; var arrowFunctionBody = arrowFunction.body; var bodyBlock; // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 230 /* Block */) { + if (arrowFunctionBody.kind === 232 /* Block */) { bodyBlock = arrowFunctionBody; } // case 2: () => [1,2,3] else { bodyBlock = ts.factory.createBlock([ts.factory.createReturnStatement(arrowFunctionBody)]); } - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 129 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 130 /* AsyncKeyword */)); var method = ts.factory.createMethodDeclaration(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined, /*typeParameters*/ undefined, arrowFunction.parameters, /*type*/ undefined, bodyBlock); ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); @@ -136661,7 +141595,7 @@ var ts; if (initializer.body) { memberElements.unshift(ts.factory.createConstructorDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, initializer.parameters, initializer.body)); } - var modifiers = getModifierKindFromSource(node.parent.parent, 92 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(node.parent.parent, 93 /* ExportKeyword */); var cls = ts.factory.createClassDeclaration(/*decorators*/ undefined, modifiers, node.name, /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); // Don't call copyComments here because we'll already leave them in place @@ -136672,7 +141606,7 @@ var ts; if (node.body) { memberElements.unshift(ts.factory.createConstructorDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, node.parameters, node.body)); } - var modifiers = getModifierKindFromSource(node, 92 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(node, 93 /* ExportKeyword */); var cls = ts.factory.createClassDeclaration(/*decorators*/ undefined, modifiers, node.name, /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); // Don't call copyComments here because we'll already leave them in place @@ -136739,7 +141673,7 @@ var ts; functionToConvert = tokenAtPosition.parent.initializer; } else { - functionToConvert = ts.tryCast(ts.getContainingFunction(ts.getTokenAtPosition(sourceFile, position)), ts.isFunctionLikeDeclaration); + functionToConvert = ts.tryCast(ts.getContainingFunction(ts.getTokenAtPosition(sourceFile, position)), ts.canBeConvertedToAsync); } if (!functionToConvert) { return; @@ -136748,7 +141682,10 @@ var ts; var isInJavascript = ts.isInJSFile(functionToConvert); var setOfExpressionsToReturn = getAllPromiseExpressionsToReturn(functionToConvert, checker); var functionToConvertRenamed = renameCollidingVarNames(functionToConvert, checker, synthNamesMap); - var returnStatements = functionToConvertRenamed.body && ts.isBlock(functionToConvertRenamed.body) ? getReturnStatementsWithPromiseHandlers(functionToConvertRenamed.body) : ts.emptyArray; + if (!ts.returnsPromise(functionToConvertRenamed, checker)) { + return; + } + var returnStatements = functionToConvertRenamed.body && ts.isBlock(functionToConvertRenamed.body) ? getReturnStatementsWithPromiseHandlers(functionToConvertRenamed.body, checker) : ts.emptyArray; var transformer = { checker: checker, synthNamesMap: synthNamesMap, setOfExpressionsToReturn: setOfExpressionsToReturn, isInJSFile: isInJavascript }; if (!returnStatements.length) { return; @@ -136757,8 +141694,8 @@ var ts; functionToConvert.decorators ? ts.skipTrivia(sourceFile.text, functionToConvert.decorators.end) : functionToConvert.getStart(sourceFile); var options = functionToConvert.modifiers ? { prefix: " " } : { suffix: " " }; - changes.insertModifierAt(sourceFile, pos, 129 /* AsyncKeyword */, options); - var _loop_12 = function (returnStatement) { + changes.insertModifierAt(sourceFile, pos, 130 /* AsyncKeyword */, options); + var _loop_13 = function (returnStatement) { ts.forEachChild(returnStatement, function visit(node) { if (ts.isCallExpression(node)) { var newNodes = transformExpression(node, transformer); @@ -136771,13 +141708,13 @@ var ts; }; for (var _i = 0, returnStatements_1 = returnStatements; _i < returnStatements_1.length; _i++) { var returnStatement = returnStatements_1[_i]; - _loop_12(returnStatement); + _loop_13(returnStatement); } } - function getReturnStatementsWithPromiseHandlers(body) { + function getReturnStatementsWithPromiseHandlers(body, checker) { var res = []; ts.forEachReturnStatement(body, function (ret) { - if (ts.isReturnStatementWithFixablePromiseHandler(ret)) + if (ts.isReturnStatementWithFixablePromiseHandler(ret, checker)) res.push(ret); }); return res; @@ -136848,7 +141785,10 @@ var ts; // so we push an entry for 'response'. if (lastCallSignature && !ts.isParameter(node.parent) && !ts.isFunctionLikeDeclaration(node.parent) && !synthNamesMap.has(symbolIdString)) { var firstParameter = ts.firstOrUndefined(lastCallSignature.parameters); - var ident = firstParameter && ts.isParameter(firstParameter.valueDeclaration) && ts.tryCast(firstParameter.valueDeclaration.name, ts.isIdentifier) || ts.factory.createUniqueName("result", 16 /* Optimistic */); + 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 */); var synthName = getNewNameIfConflict(ident, collidingSymbolMap); synthNamesMap.set(symbolIdString, synthName); collidingSymbolMap.add(ident.text, symbol); @@ -137023,10 +141963,11 @@ var ts; function getTransformationBody(func, prevArgName, argName, parent, transformer) { var _a, _b, _c, _d, _e; switch (func.kind) { - case 103 /* NullKeyword */: + case 104 /* NullKeyword */: // do not produce a transformed statement for a null argument break; - case 78 /* Identifier */: // identifier includes undefined + case 203 /* PropertyAccessExpression */: + case 79 /* Identifier */: // identifier includes undefined if (!argName) { // undefined was argument passed to promise handler break; @@ -137047,8 +141988,8 @@ var ts; prevArgName.types.push(returnType); } return varDeclOrAssignment; - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: { + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: { var funcBody = func.body; var returnType_1 = (_c = getLastCallSignature(transformer.checker.getTypeAtLocation(func), transformer.checker)) === null || _c === void 0 ? void 0 : _c.getReturnType(); // Arrow functions with block bodies { } will enter this control flow @@ -137059,7 +142000,7 @@ var ts; var statement = _f[_i]; if (ts.isReturnStatement(statement)) { seenReturnStatement = true; - if (ts.isReturnStatementWithFixablePromiseHandler(statement)) { + if (ts.isReturnStatementWithFixablePromiseHandler(statement, transformer.checker)) { refactoredStmts = refactoredStmts.concat(getInnerTransformationBody(transformer, [statement], prevArgName)); } else { @@ -137076,7 +142017,7 @@ var ts; : removeReturns(refactoredStmts, prevArgName, transformer, seenReturnStatement); } else { - var innerRetStmts = ts.isFixablePromiseHandler(funcBody) ? [ts.factory.createReturnStatement(funcBody)] : ts.emptyArray; + var innerRetStmts = ts.isFixablePromiseHandler(funcBody, transformer.checker) ? [ts.factory.createReturnStatement(funcBody)] : ts.emptyArray; var innerCbBody = getInnerTransformationBody(transformer, innerRetStmts, prevArgName); if (innerCbBody.length > 0) { return innerCbBody; @@ -137169,6 +142110,9 @@ var ts; else if (ts.isIdentifier(funcNode)) { name = getMapEntryOrDefault(funcNode); } + else if (ts.isPropertyAccessExpression(funcNode) && ts.isIdentifier(funcNode.name)) { + name = getMapEntryOrDefault(funcNode.name); + } // return undefined argName when arg is null or undefined // eslint-disable-next-line no-in-operator if (!name || "identifier" in name && name.identifier.text === "undefined") { @@ -137264,10 +142208,10 @@ var ts; } var importNode = ts.importFromModuleSpecifier(moduleSpecifier); switch (importNode.kind) { - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier, quotePreference)); break; - case 203 /* CallExpression */: + case 205 /* CallExpression */: if (ts.isRequireCall(importNode, /*checkArgumentIsStringLiteralLike*/ false)) { changes.replaceNode(importingFile, importNode, ts.factory.createPropertyAccessExpression(ts.getSynthesizedDeepClone(importNode), "default")); } @@ -137327,29 +142271,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 === 62 /* EqualsToken */); + cb(node, ts.isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === 63 /* EqualsToken */); } node.forEachChild(recur); }); } function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, useSitesToUnqualify, quotePreference) { switch (statement.kind) { - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, quotePreference); return false; - case 233 /* ExpressionStatement */: { + case 235 /* ExpressionStatement */: { var expression = statement.expression; switch (expression.kind) { - case 203 /* CallExpression */: { + case 205 /* 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 216 /* BinaryExpression */: { + case 218 /* BinaryExpression */: { var operatorToken = expression.operatorToken; - return operatorToken.kind === 62 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports, useSitesToUnqualify); + return operatorToken.kind === 63 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports, useSitesToUnqualify); } } } @@ -137396,8 +142340,8 @@ var ts; /** Converts `const name = require("moduleSpecifier").propertyName` */ function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers, quotePreference) { switch (name.kind) { - case 196 /* ObjectBindingPattern */: - case 197 /* ArrayBindingPattern */: { + case 198 /* ObjectBindingPattern */: + case 199 /* ArrayBindingPattern */: { // `const [a, b] = require("c").d` --> `import { d } from "c"; const [a, b] = d;` var tmp = makeUniqueName(propertyName, identifiers); return convertedImports([ @@ -137405,7 +142349,7 @@ var ts; makeConst(/*modifiers*/ undefined, name, ts.factory.createIdentifier(tmp)), ]); } - case 78 /* Identifier */: + case 79 /* Identifier */: // `const a = require("b").c` --> `import { c as a } from "./b"; return convertedImports([makeSingleImport(name.text, propertyName, moduleSpecifier, quotePreference)]); default: @@ -137448,17 +142392,17 @@ var ts; function tryChangeModuleExportsObject(object, useSitesToUnqualify) { var statements = ts.mapAllOrFail(object.properties, function (prop) { switch (prop.kind) { - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: // TODO: Maybe we should handle this? See fourslash test `refactorConvertToEs6Module_export_object_shorthand.ts`. // falls through - case 289 /* ShorthandPropertyAssignment */: - case 290 /* SpreadAssignment */: + case 291 /* ShorthandPropertyAssignment */: + case 292 /* SpreadAssignment */: return undefined; - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: return !ts.isIdentifier(prop.name) ? undefined : convertExportsDotXEquals_replaceNode(prop.name.text, prop.initializer, useSitesToUnqualify); - case 165 /* MethodDeclaration */: - return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.factory.createToken(92 /* ExportKeyword */)], prop, useSitesToUnqualify); + case 167 /* MethodDeclaration */: + return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.factory.createToken(93 /* ExportKeyword */)], prop, useSitesToUnqualify); default: ts.Debug.assertNever(prop, "Convert to ES6 got invalid prop kind " + prop.kind); } @@ -137505,7 +142449,7 @@ 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(92 /* ExportKeyword */), { suffix: " " }); + changes.replaceRange(sourceFile, { pos: left.getStart(sourceFile), end: right.getStart(sourceFile) }, ts.factory.createToken(93 /* ExportKeyword */), { suffix: " " }); if (!right.name) changes.insertName(sourceFile, right, name); var semi = ts.findChildOfKind(parent, 26 /* SemicolonToken */, sourceFile); @@ -137514,14 +142458,14 @@ var ts; } 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(92 /* ExportKeyword */), ts.factory.createToken(84 /* ConstKeyword */)], { joiner: " ", suffix: " " }); + changes.replaceNodeRangeWithNodes(sourceFile, left.expression, ts.findChildOfKind(left, 24 /* DotToken */, sourceFile), [ts.factory.createToken(93 /* ExportKeyword */), ts.factory.createToken(85 /* 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(92 /* ExportKeyword */)]; + var modifiers = [ts.factory.createToken(93 /* ExportKeyword */)]; switch (exported.kind) { - case 208 /* FunctionExpression */: { + case 210 /* FunctionExpression */: { var expressionName = exported.name; if (expressionName && expressionName.text !== name) { // `exports.f = function g() {}` -> `export const f = function g() {}` @@ -137529,10 +142473,10 @@ var ts; } } // falls through - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: // `exports.f = function() {}` --> `export function f() {}` return functionExpressionToDeclaration(name, modifiers, exported, useSitesToUnqualify); - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: // `exports.C = class {}` --> `export class C {}` return classExpressionToDeclaration(name, modifiers, exported, useSitesToUnqualify); default: @@ -137552,7 +142496,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 === 201 /* PropertyAccessExpression */) { + if (original.kind === 203 /* 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); @@ -137567,7 +142511,7 @@ var ts; */ function convertSingleImport(name, moduleSpecifier, checker, identifiers, target, quotePreference) { switch (name.kind) { - case 196 /* ObjectBindingPattern */: { + case 198 /* 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 @@ -137580,7 +142524,7 @@ var ts; } } // falls through -- object destructuring has an interesting pattern and must be a variable declaration - case 197 /* ArrayBindingPattern */: { + case 199 /* ArrayBindingPattern */: { /* import x from "x"; const [a, b, c] = x; @@ -137591,7 +142535,7 @@ var ts; makeConst(/*modifiers*/ undefined, ts.getSynthesizedDeepClone(name), ts.factory.createIdentifier(tmp)), ]); } - case 78 /* Identifier */: + case 79 /* Identifier */: return convertSingleIdentifierImport(name, moduleSpecifier, checker, identifiers, quotePreference); default: return ts.Debug.assertNever(name, "Convert to ES6 module got invalid name kind " + name.kind); @@ -137599,7 +142543,9 @@ var ts; } /** * Convert `import x = require("x").` - * Also converts uses like `x.y()` to `y()` and uses a named import. + * Also: + * - Convert `x.default()` to `x()` to handle ES6 default export + * - Converts uses like `x.y()` to `y()` and uses a named import. */ function convertSingleIdentifierImport(name, moduleSpecifier, checker, identifiers, quotePreference) { var nameSymbol = checker.getSymbolAtLocation(name); @@ -137616,14 +142562,21 @@ var ts; } var parent = use.parent; if (ts.isPropertyAccessExpression(parent)) { - var expression = parent.expression, propertyName = parent.name.text; - ts.Debug.assert(expression === use, "Didn't expect expression === use"); // Else shouldn't have been in `collectIdentifiers` - var idName = namedBindingsNames.get(propertyName); - if (idName === undefined) { - idName = makeUniqueName(propertyName, identifiers); - namedBindingsNames.set(propertyName, idName); + var propertyName = parent.name.text; + if (propertyName === "default") { + needDefaultImport = true; + var importDefaultName = use.getText(); + (useSitesToUnqualify !== null && useSitesToUnqualify !== void 0 ? useSitesToUnqualify : (useSitesToUnqualify = new ts.Map())).set(parent, ts.factory.createIdentifier(importDefaultName)); + } + else { + ts.Debug.assert(parent.expression === use, "Didn't expect expression === use"); // Else shouldn't have been in `collectIdentifiers` + var idName = namedBindingsNames.get(propertyName); + if (idName === undefined) { + idName = makeUniqueName(propertyName, identifiers); + namedBindingsNames.set(propertyName, idName); + } + (useSitesToUnqualify !== null && useSitesToUnqualify !== void 0 ? useSitesToUnqualify : (useSitesToUnqualify = new ts.Map())).set(parent, ts.factory.createIdentifier(idName)); } - (useSitesToUnqualify !== null && useSitesToUnqualify !== void 0 ? useSitesToUnqualify : (useSitesToUnqualify = new ts.Map())).set(parent, ts.factory.createIdentifier(idName)); } else { needDefaultImport = true; @@ -137664,11 +142617,11 @@ var ts; function isFreeIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return parent.name !== node; - case 198 /* BindingElement */: + case 200 /* BindingElement */: return parent.propertyName !== node; - case 265 /* ImportSpecifier */: + case 267 /* ImportSpecifier */: return parent.propertyName !== node; default: return true; @@ -137782,7 +142735,7 @@ var ts; var exportDeclaration = exportClause.parent; var typeExportSpecifiers = getTypeExportSpecifiers(exportSpecifier, context); if (typeExportSpecifiers.length === exportClause.elements.length) { - changes.insertModifierBefore(context.sourceFile, 149 /* TypeKeyword */, exportClause); + changes.insertModifierBefore(context.sourceFile, 150 /* TypeKeyword */, exportClause); } else { var valueExportDeclaration = ts.factory.updateExportDeclaration(exportDeclaration, exportDeclaration.decorators, exportDeclaration.modifiers, @@ -138145,87 +143098,138 @@ var ts; ImportFixKind[ImportFixKind["AddToExisting"] = 2] = "AddToExisting"; ImportFixKind[ImportFixKind["AddNew"] = 3] = "AddNew"; })(ImportFixKind || (ImportFixKind = {})); - var ImportKind; - (function (ImportKind) { - ImportKind[ImportKind["Named"] = 0] = "Named"; - ImportKind[ImportKind["Default"] = 1] = "Default"; - ImportKind[ImportKind["Namespace"] = 2] = "Namespace"; - ImportKind[ImportKind["CommonJS"] = 3] = "CommonJS"; - })(ImportKind || (ImportKind = {})); function getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, symbolName, host, program, formatContext, position, preferences) { var compilerOptions = program.getCompilerOptions(); var exportInfos = ts.pathIsBareSpecifier(ts.stripQuotes(moduleSymbol.name)) - ? [getSymbolExportInfoForSymbol(exportedSymbol, moduleSymbol, sourceFile, program, host)] + ? [getSymbolExportInfoForSymbol(exportedSymbol, moduleSymbol, program, host)] : getAllReExportingModules(sourceFile, exportedSymbol, moduleSymbol, symbolName, host, program, /*useAutoImportProvider*/ true); var useRequire = shouldUseRequire(sourceFile, program); var preferTypeOnlyImport = compilerOptions.importsNotUsedAsValues === 2 /* Error */ && !ts.isSourceFileJS(sourceFile) && ts.isValidTypeOnlyAliasUseSite(ts.getTokenAtPosition(sourceFile, position)); - var moduleSpecifier = ts.first(getNewImportInfos(program, sourceFile, position, preferTypeOnlyImport, useRequire, exportInfos, host, preferences)).moduleSpecifier; var fix = getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, preferTypeOnlyImport, useRequire, host, preferences); - return { moduleSpecifier: moduleSpecifier, codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, ts.getQuotePreference(sourceFile, preferences))) }; + return { moduleSpecifier: fix.moduleSpecifier, codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, ts.getQuotePreference(sourceFile, preferences))) }; } codefix.getImportCompletionAction = getImportCompletionAction; function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, preferTypeOnlyImport, useRequire, host, preferences) { ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol"); - // We sort the best codefixes first, so taking `first` is best. - return ts.first(getFixForImport(exportInfos, symbolName, position, preferTypeOnlyImport, useRequire, program, sourceFile, host, preferences)); + return getBestFix(getImportFixes(exportInfos, symbolName, position, preferTypeOnlyImport, useRequire, program, sourceFile, host, preferences), sourceFile, host); } function codeFixActionToCodeAction(_a) { var description = _a.description, changes = _a.changes, commands = _a.commands; return { description: description, changes: changes, commands: commands }; } - function getSymbolExportInfoForSymbol(symbol, moduleSymbol, importingFile, program, host) { + function getSymbolExportInfoForSymbol(symbol, moduleSymbol, program, host) { var _a, _b; var compilerOptions = program.getCompilerOptions(); - var mainProgramInfo = getInfoWithChecker(program.getTypeChecker()); + var mainProgramInfo = getInfoWithChecker(program.getTypeChecker(), /*isFromPackageJson*/ false); if (mainProgramInfo) { return mainProgramInfo; } var autoImportProvider = (_b = (_a = host.getPackageJsonAutoImportProvider) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getTypeChecker(); - return ts.Debug.checkDefined(autoImportProvider && getInfoWithChecker(autoImportProvider), "Could not find symbol in specified module for code actions"); - function getInfoWithChecker(checker) { - var defaultInfo = getDefaultLikeExportInfo(importingFile, moduleSymbol, checker, compilerOptions); + return ts.Debug.checkDefined(autoImportProvider && getInfoWithChecker(autoImportProvider, /*isFromPackageJson*/ true), "Could not find symbol in specified module for code actions"); + function getInfoWithChecker(checker, isFromPackageJson) { + var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); if (defaultInfo && ts.skipAlias(defaultInfo.symbol, checker) === symbol) { - return { moduleSymbol: moduleSymbol, importKind: defaultInfo.kind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(symbol, checker) }; + return { symbol: defaultInfo.symbol, moduleSymbol: moduleSymbol, exportKind: defaultInfo.exportKind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(symbol, checker), isFromPackageJson: isFromPackageJson }; } var named = checker.tryGetMemberInModuleExportsAndProperties(symbol.name, moduleSymbol); if (named && ts.skipAlias(named, checker) === symbol) { - return { moduleSymbol: moduleSymbol, importKind: 0 /* Named */, exportedSymbolIsTypeOnly: isTypeOnlySymbol(symbol, checker) }; + return { symbol: named, moduleSymbol: moduleSymbol, exportKind: 0 /* Named */, exportedSymbolIsTypeOnly: isTypeOnlySymbol(symbol, checker), isFromPackageJson: isFromPackageJson }; } } } function getAllReExportingModules(importingFile, exportedSymbol, exportingModuleSymbol, symbolName, host, program, useAutoImportProvider) { var result = []; var compilerOptions = program.getCompilerOptions(); - forEachExternalModuleToImportFrom(program, host, importingFile, /*filterByPackageJson*/ false, useAutoImportProvider, function (moduleSymbol, moduleFile, program) { + var getModuleSpecifierResolutionHost = ts.memoizeOne(function (isFromPackageJson) { + return ts.createModuleSpecifierResolutionHost(isFromPackageJson ? host.getPackageJsonAutoImportProvider() : program, host); + }); + forEachExternalModuleToImportFrom(program, host, useAutoImportProvider, function (moduleSymbol, moduleFile, program, isFromPackageJson) { var checker = program.getTypeChecker(); // Don't import from a re-export when looking "up" like to `./index` or `../index`. if (moduleFile && moduleSymbol !== exportingModuleSymbol && ts.startsWith(importingFile.fileName, ts.getDirectoryPath(moduleFile.fileName))) { return; } - var defaultInfo = getDefaultLikeExportInfo(importingFile, moduleSymbol, checker, compilerOptions); - if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, compilerOptions.target) === symbolName) && ts.skipAlias(defaultInfo.symbol, checker) === exportedSymbol) { - result.push({ moduleSymbol: moduleSymbol, importKind: defaultInfo.kind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(defaultInfo.symbol, checker) }); + var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); + if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, compilerOptions.target) === symbolName) && ts.skipAlias(defaultInfo.symbol, checker) === exportedSymbol && isImportable(program, moduleFile, isFromPackageJson)) { + result.push({ symbol: defaultInfo.symbol, moduleSymbol: moduleSymbol, exportKind: defaultInfo.exportKind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(defaultInfo.symbol, checker), isFromPackageJson: isFromPackageJson }); } for (var _i = 0, _a = checker.getExportsAndPropertiesOfModule(moduleSymbol); _i < _a.length; _i++) { var exported = _a[_i]; - if (exported.name === symbolName && ts.skipAlias(exported, checker) === exportedSymbol) { - result.push({ moduleSymbol: moduleSymbol, importKind: 0 /* Named */, exportedSymbolIsTypeOnly: isTypeOnlySymbol(exported, checker) }); + if (exported.name === symbolName && ts.skipAlias(exported, checker) === exportedSymbol && isImportable(program, moduleFile, isFromPackageJson)) { + result.push({ symbol: exported, moduleSymbol: moduleSymbol, exportKind: 0 /* Named */, exportedSymbolIsTypeOnly: isTypeOnlySymbol(exported, checker), isFromPackageJson: isFromPackageJson }); } } }); return result; + function isImportable(program, moduleFile, isFromPackageJson) { + var _a; + return !moduleFile || ts.isImportableFile(program, importingFile, moduleFile, /*packageJsonFilter*/ undefined, getModuleSpecifierResolutionHost(isFromPackageJson), (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host)); + } + } + function getModuleSpecifierForBestExportInfo(exportInfo, importingFile, program, host, preferences) { + return getBestFix(getNewImportFixes(program, importingFile, /*position*/ undefined, /*preferTypeOnlyImport*/ false, /*useRequire*/ false, exportInfo, host, preferences), importingFile, host); } + codefix.getModuleSpecifierForBestExportInfo = getModuleSpecifierForBestExportInfo; + function getSymbolToExportInfoMap(importingFile, host, program) { + var _a, _b, _c, _d, _e, _f, _g, _h; + var start = ts.timestamp(); + // Pulling the AutoImportProvider project will trigger its updateGraph if pending, + // which will invalidate the export map cache if things change, so pull it before + // checking the cache. + (_a = host.getPackageJsonAutoImportProvider) === null || _a === void 0 ? void 0 : _a.call(host); + var cache = (_b = host.getExportMapCache) === null || _b === void 0 ? void 0 : _b.call(host); + if (cache) { + var cached = cache.get(importingFile.path, program.getTypeChecker(), (_c = host.getProjectVersion) === null || _c === void 0 ? void 0 : _c.call(host)); + if (cached) { + (_d = host.log) === null || _d === void 0 ? void 0 : _d.call(host, "getSymbolToExportInfoMap: cache hit"); + return cached; + } + else { + (_e = host.log) === null || _e === void 0 ? void 0 : _e.call(host, "getSymbolToExportInfoMap: cache miss or empty; calculating new results"); + } + } + var result = ts.createMultiMap(); + var compilerOptions = program.getCompilerOptions(); + var target = ts.getEmitScriptTarget(compilerOptions); + forEachExternalModuleToImportFrom(program, host, /*useAutoImportProvider*/ true, function (moduleSymbol, _moduleFile, program, isFromPackageJson) { + var checker = program.getTypeChecker(); + var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); + if (defaultInfo) { + var name = ts.getNameForExportedSymbol(ts.getLocalSymbolForExportDefault(defaultInfo.symbol) || defaultInfo.symbol, target); + result.add(key(name, defaultInfo.symbol, moduleSymbol, checker), { symbol: defaultInfo.symbol, moduleSymbol: moduleSymbol, exportKind: defaultInfo.exportKind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(defaultInfo.symbol, checker), isFromPackageJson: isFromPackageJson }); + } + var seenExports = new ts.Map(); + for (var _i = 0, _a = checker.getExportsAndPropertiesOfModule(moduleSymbol); _i < _a.length; _i++) { + var exported = _a[_i]; + if (exported !== (defaultInfo === null || defaultInfo === void 0 ? void 0 : defaultInfo.symbol) && ts.addToSeen(seenExports, exported)) { + result.add(key(ts.getNameForExportedSymbol(exported, target), exported, moduleSymbol, checker), { symbol: exported, moduleSymbol: moduleSymbol, exportKind: 0 /* Named */, exportedSymbolIsTypeOnly: isTypeOnlySymbol(exported, checker), isFromPackageJson: isFromPackageJson }); + } + } + }); + if (cache) { + (_f = host.log) === null || _f === void 0 ? void 0 : _f.call(host, "getSymbolToExportInfoMap: caching results"); + cache.set(result, (_g = host.getProjectVersion) === null || _g === void 0 ? void 0 : _g.call(host)); + } + (_h = host.log) === null || _h === void 0 ? void 0 : _h.call(host, "getSymbolToExportInfoMap: done in " + (ts.timestamp() - start) + " ms"); + return result; + function key(name, alias, moduleSymbol, checker) { + var moduleName = ts.stripQuotes(moduleSymbol.name); + var moduleKey = ts.isExternalModuleNameRelative(moduleName) ? "/" : moduleName; + return name + "|" + ts.getSymbolId(ts.skipAlias(alias, checker)) + "|" + moduleKey; + } + } + codefix.getSymbolToExportInfoMap = getSymbolToExportInfoMap; function isTypeOnlySymbol(s, checker) { return !(ts.skipAlias(s, checker).flags & 111551 /* Value */); } function isTypeOnlyPosition(sourceFile, position) { return ts.isValidTypeOnlyAliasUseSite(ts.getTokenAtPosition(sourceFile, position)); } - function getFixForImport(exportInfos, symbolName, + function getImportFixes(exportInfos, symbolName, /** undefined only for missing JSX namespace */ position, preferTypeOnlyImport, useRequire, program, sourceFile, host, preferences) { var checker = program.getTypeChecker(); - var existingImports = ts.flatMap(exportInfos, function (info) { return getExistingImportDeclarations(info, checker, sourceFile); }); + var existingImports = ts.flatMap(exportInfos, function (info) { return getExistingImportDeclarations(info, checker, sourceFile, program.getCompilerOptions()); }); var useNamespace = position === undefined ? undefined : tryUseExistingNamespaceImport(existingImports, symbolName, position, checker); var addToExisting = tryAddToExistingImport(existingImports, position !== undefined && isTypeOnlyPosition(sourceFile, position)); // Don't bother providing an action to add a new import if we can add to an existing one. @@ -138248,10 +143252,11 @@ var ts; return ts.firstDefined(existingImports, function (_a) { var declaration = _a.declaration; var namespacePrefix = getNamespaceLikeImportText(declaration); - if (namespacePrefix) { + var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration); + if (namespacePrefix && moduleSpecifier) { var moduleSymbol = getTargetModuleFromNamespaceLikeImport(declaration, checker); if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(symbolName))) { - return { kind: 0 /* UseNamespace */, namespacePrefix: namespacePrefix, position: position }; + return { kind: 0 /* UseNamespace */, namespacePrefix: namespacePrefix, position: position, moduleSpecifier: moduleSpecifier }; } } }); @@ -138259,11 +143264,11 @@ var ts; function getTargetModuleFromNamespaceLikeImport(declaration, checker) { var _a; switch (declaration.kind) { - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return checker.resolveExternalModuleName(declaration.initializer.arguments[0]); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return checker.getAliasedSymbol(declaration.symbol); - case 261 /* ImportDeclaration */: + case 263 /* 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: @@ -138273,11 +143278,11 @@ var ts; function getNamespaceLikeImportText(declaration) { var _a, _b, _c; switch (declaration.kind) { - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return (_a = ts.tryCast(declaration.name, ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text; - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return declaration.name.text; - case 261 /* ImportDeclaration */: + case 263 /* 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); @@ -138286,31 +143291,38 @@ var ts; function tryAddToExistingImport(existingImports, canUseTypeOnlyImport) { return ts.firstDefined(existingImports, function (_a) { var declaration = _a.declaration, importKind = _a.importKind; - if (declaration.kind === 260 /* ImportEqualsDeclaration */) + if (declaration.kind === 262 /* ImportEqualsDeclaration */) return undefined; - if (declaration.kind === 249 /* VariableDeclaration */) { - return (importKind === 0 /* Named */ || importKind === 1 /* Default */) && declaration.name.kind === 196 /* ObjectBindingPattern */ + if (declaration.kind === 251 /* VariableDeclaration */) { + return (importKind === 0 /* Named */ || importKind === 1 /* Default */) && declaration.name.kind === 198 /* ObjectBindingPattern */ ? { kind: 2 /* AddToExisting */, importClauseOrBindingPattern: declaration.name, importKind: importKind, moduleSpecifier: declaration.initializer.arguments[0].text, canUseTypeOnlyImport: false } : undefined; } var importClause = declaration.importClause; - if (!importClause) + if (!importClause || !ts.isStringLiteralLike(declaration.moduleSpecifier)) return undefined; var name = importClause.name, namedBindings = importClause.namedBindings; - return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 264 /* NamedImports */) - ? { kind: 2 /* AddToExisting */, importClauseOrBindingPattern: importClause, importKind: importKind, moduleSpecifier: declaration.moduleSpecifier.getText(), canUseTypeOnlyImport: canUseTypeOnlyImport } + // 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)) + return undefined; + return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 266 /* NamedImports */) + ? { kind: 2 /* AddToExisting */, importClauseOrBindingPattern: importClause, importKind: importKind, moduleSpecifier: declaration.moduleSpecifier.text, canUseTypeOnlyImport: canUseTypeOnlyImport } : undefined; }); } - function getExistingImportDeclarations(_a, checker, sourceFile) { - var moduleSymbol = _a.moduleSymbol, importKind = _a.importKind, exportedSymbolIsTypeOnly = _a.exportedSymbolIsTypeOnly; + function getExistingImportDeclarations(_a, checker, importingFile, compilerOptions) { + var moduleSymbol = _a.moduleSymbol, exportKind = _a.exportKind, exportedSymbolIsTypeOnly = _a.exportedSymbolIsTypeOnly; // Can't use an es6 import for a type in JS. - return exportedSymbolIsTypeOnly && ts.isSourceFileJS(sourceFile) ? ts.emptyArray : ts.mapDefined(sourceFile.imports, function (moduleSpecifier) { + if (exportedSymbolIsTypeOnly && ts.isSourceFileJS(importingFile)) + return ts.emptyArray; + var importKind = getImportKind(importingFile, exportKind, compilerOptions); + return ts.mapDefined(importingFile.imports, function (moduleSpecifier) { var i = ts.importFromModuleSpecifier(moduleSpecifier); - if (ts.isRequireVariableDeclaration(i.parent, /*requireStringLiteralLikeArgument*/ true)) { + if (ts.isRequireVariableDeclaration(i.parent)) { return checker.resolveExternalModuleName(moduleSpecifier) === moduleSymbol ? { declaration: i.parent, importKind: importKind } : undefined; } - if (i.kind === 261 /* ImportDeclaration */ || i.kind === 260 /* ImportEqualsDeclaration */) { + if (i.kind === 263 /* ImportDeclaration */ || i.kind === 262 /* ImportEqualsDeclaration */) { return checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind } : undefined; } }); @@ -138343,45 +143355,29 @@ var ts; // 5. Literally nothing to go on return true; } - function getNewImportInfos(program, sourceFile, position, preferTypeOnlyImport, useRequire, moduleSymbols, host, preferences) { + function getNewImportFixes(program, sourceFile, position, preferTypeOnlyImport, useRequire, moduleSymbols, host, preferences) { var isJs = ts.isSourceFileJS(sourceFile); var compilerOptions = program.getCompilerOptions(); - var allowsImportingSpecifier = createAutoImportFilter(sourceFile, program, host).allowsImportingSpecifier; - var choicesForEachExportingModule = ts.flatMap(moduleSymbols, function (_a) { - var moduleSymbol = _a.moduleSymbol, importKind = _a.importKind, exportedSymbolIsTypeOnly = _a.exportedSymbolIsTypeOnly; - return ts.moduleSpecifiers.getModuleSpecifiers(moduleSymbol, program.getTypeChecker(), compilerOptions, sourceFile, ts.createModuleSpecifierResolutionHost(program, host), preferences) + var moduleSpecifierResolutionHost = ts.createModuleSpecifierResolutionHost(program, host); + return ts.flatMap(moduleSymbols, function (exportInfo) { + return ts.moduleSpecifiers.getModuleSpecifiers(exportInfo.moduleSymbol, program.getTypeChecker(), compilerOptions, sourceFile, moduleSpecifierResolutionHost, preferences) .map(function (moduleSpecifier) { // `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types. - return exportedSymbolIsTypeOnly && isJs - ? { kind: 1 /* ImportType */, moduleSpecifier: moduleSpecifier, position: ts.Debug.checkDefined(position, "position should be defined") } - : { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind, useRequire: useRequire, typeOnly: preferTypeOnlyImport }; + return exportInfo.exportedSymbolIsTypeOnly && isJs && position !== undefined + ? { kind: 1 /* ImportType */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo } + : { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: getImportKind(sourceFile, exportInfo.exportKind, compilerOptions), useRequire: useRequire, typeOnly: preferTypeOnlyImport, exportInfo: exportInfo }; }); }); - // Sort by presence in package.json, then shortest paths first - return ts.sort(choicesForEachExportingModule, function (a, b) { - var allowsImportingA = allowsImportingSpecifier(a.moduleSpecifier); - var allowsImportingB = allowsImportingSpecifier(b.moduleSpecifier); - if (allowsImportingA && !allowsImportingB) { - return -1; - } - if (allowsImportingB && !allowsImportingA) { - return 1; - } - return a.moduleSpecifier.length - b.moduleSpecifier.length; - }); } function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, preferTypeOnlyImport, useRequire, host, preferences) { var existingDeclaration = ts.firstDefined(existingImports, function (info) { return newImportInfoFromExistingSpecifier(info, preferTypeOnlyImport, useRequire); }); - return existingDeclaration ? [existingDeclaration] : getNewImportInfos(program, sourceFile, position, preferTypeOnlyImport, useRequire, exportInfos, host, preferences); + return existingDeclaration ? [existingDeclaration] : getNewImportFixes(program, sourceFile, position, preferTypeOnlyImport, useRequire, exportInfos, host, preferences); } function newImportInfoFromExistingSpecifier(_a, preferTypeOnlyImport, useRequire) { var declaration = _a.declaration, importKind = _a.importKind; - var moduleSpecifier = declaration.kind === 261 /* ImportDeclaration */ ? declaration.moduleSpecifier : - declaration.kind === 249 /* VariableDeclaration */ ? declaration.initializer.arguments[0] : - declaration.moduleReference.kind === 272 /* ExternalModuleReference */ ? declaration.moduleReference.expression : - undefined; - return moduleSpecifier && ts.isStringLiteral(moduleSpecifier) - ? { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier.text, importKind: importKind, typeOnly: preferTypeOnlyImport, useRequire: useRequire } + var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration); + return moduleSpecifier + ? { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind, typeOnly: preferTypeOnlyImport, useRequire: useRequire } : undefined; } function getFixesInfo(context, errorCode, pos, useAutoImportProvider) { @@ -138389,7 +143385,28 @@ var ts; var info = errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code ? getFixesInfoForUMDImport(context, symbolToken) : ts.isIdentifier(symbolToken) ? getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider) : undefined; - return info && __assign(__assign({}, info), { fixes: ts.sort(info.fixes, function (a, b) { return a.kind - b.kind; }) }); + return info && __assign(__assign({}, info), { fixes: sortFixes(info.fixes, context.sourceFile, context.host) }); + } + function sortFixes(fixes, sourceFile, host) { + var allowsImportingSpecifier = ts.createPackageJsonImportFilter(sourceFile, host).allowsImportingSpecifier; + return ts.sort(fixes, function (a, b) { return ts.compareValues(a.kind, b.kind) || compareModuleSpecifiers(a, b, allowsImportingSpecifier); }); + } + function getBestFix(fixes, sourceFile, host) { + // 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 */) { + return fixes[0]; + } + var allowsImportingSpecifier = ts.createPackageJsonImportFilter(sourceFile, host).allowsImportingSpecifier; + return fixes.reduce(function (best, fix) { + return compareModuleSpecifiers(fix, best, allowsImportingSpecifier) === -1 /* LessThan */ ? fix : best; + }); + } + function compareModuleSpecifiers(a, b, allowsImportingSpecifier) { + if (a.kind !== 0 /* UseNamespace */ && b.kind !== 0 /* UseNamespace */) { + return ts.compareBooleans(allowsImportingSpecifier(a.moduleSpecifier), allowsImportingSpecifier(b.moduleSpecifier)) + || ts.compareNumberOfDirectorySeparators(a.moduleSpecifier, b.moduleSpecifier); + } + return 0 /* EqualTo */; } function getFixesInfoForUMDImport(_a, token) { var sourceFile = _a.sourceFile, program = _a.program, host = _a.host, preferences = _a.preferences; @@ -138399,9 +143416,9 @@ var ts; return undefined; var symbol = checker.getAliasedSymbol(umdSymbol); var symbolName = umdSymbol.name; - var exportInfos = [{ moduleSymbol: symbol, importKind: getUmdImportKind(sourceFile, program.getCompilerOptions()), exportedSymbolIsTypeOnly: false }]; + var exportInfos = [{ symbol: umdSymbol, moduleSymbol: symbol, exportKind: 3 /* UMD */, exportedSymbolIsTypeOnly: false, isFromPackageJson: false }]; var useRequire = shouldUseRequire(sourceFile, program); - var fixes = getFixForImport(exportInfos, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, /*preferTypeOnlyImport*/ false, useRequire, program, sourceFile, host, preferences); + var fixes = getImportFixes(exportInfos, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, /*preferTypeOnlyImport*/ false, useRequire, program, sourceFile, host, preferences); return { fixes: fixes, symbolName: symbolName }; } function getUmdSymbol(token, checker) { @@ -138415,6 +143432,16 @@ var ts; ? ts.tryCast(checker.resolveName(checker.getJsxNamespace(parent), ts.isJsxOpeningLikeElement(parent) ? token : parent, 111551 /* Value */, /*excludeGlobals*/ false), ts.isUMDExportSymbol) : undefined; } + function getImportKind(importingFile, exportKind, compilerOptions) { + switch (exportKind) { + case 0 /* Named */: return 0 /* Named */; + case 1 /* Default */: return 1 /* Default */; + case 2 /* ExportEquals */: return getExportEqualsImportKind(importingFile, compilerOptions); + case 3 /* UMD */: return getUmdImportKind(importingFile, compilerOptions); + default: return ts.Debug.assertNever(exportKind); + } + } + codefix.getImportKind = getImportKind; function getUmdImportKind(importingFile, compilerOptions) { // Import a synthetic `default` if enabled. if (ts.getAllowSyntheticDefaultImports(compilerOptions)) { @@ -138444,22 +143471,22 @@ var ts; function getFixesInfoForNonUMDImport(_a, symbolToken, useAutoImportProvider) { var sourceFile = _a.sourceFile, program = _a.program, cancellationToken = _a.cancellationToken, host = _a.host, preferences = _a.preferences; var checker = program.getTypeChecker(); - var symbolName = getSymbolName(sourceFile, checker, symbolToken); + var compilerOptions = program.getCompilerOptions(); + var symbolName = getSymbolName(sourceFile, checker, symbolToken, compilerOptions); // "default" is a keyword and not a legal identifier for the import, so we don't expect it here ts.Debug.assert(symbolName !== "default" /* Default */, "'default' isn't a legal identifier and couldn't occur here"); - var compilerOptions = program.getCompilerOptions(); var preferTypeOnlyImport = compilerOptions.importsNotUsedAsValues === 2 /* Error */ && ts.isValidTypeOnlyAliasUseSite(symbolToken); var useRequire = shouldUseRequire(sourceFile, program); var exportInfos = getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host); var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfos.entries(), function (_a) { var _ = _a[0], exportInfos = _a[1]; - return getFixForImport(exportInfos, symbolName, symbolToken.getStart(sourceFile), preferTypeOnlyImport, useRequire, program, sourceFile, host, preferences); + return getImportFixes(exportInfos, symbolName, symbolToken.getStart(sourceFile), preferTypeOnlyImport, useRequire, program, sourceFile, host, preferences); })); return { fixes: fixes, symbolName: symbolName }; } - function getSymbolName(sourceFile, checker, symbolToken) { + function getSymbolName(sourceFile, checker, symbolToken, compilerOptions) { var parent = symbolToken.parent; - if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken) { + if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken && compilerOptions.jsx !== 4 /* ReactJSX */ && compilerOptions.jsx !== 5 /* ReactJSXDev */) { var jsxNamespace = checker.getJsxNamespace(sourceFile); if (ts.isIntrinsicJsxName(symbolToken.text) || !checker.resolveName(jsxNamespace, parent, 111551 /* Value */, /*excludeGlobals*/ true)) { return jsxNamespace; @@ -138468,43 +143495,55 @@ var ts; return symbolToken.text; } // Returns a map from an exported symbol's ID to a list of every way it's (re-)exported. - function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, sourceFile, program, useAutoImportProvider, host) { + function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, fromFile, program, useAutoImportProvider, host) { + var _a; // For each original symbol, keep all re-exports of that symbol together so we can call `getCodeActionsForImport` on the whole group at once. // Maps symbol id to info for modules providing that symbol (original export + re-exports). var originalSymbolToExportInfos = ts.createMultiMap(); - function addSymbol(moduleSymbol, exportedSymbol, importKind, checker) { - originalSymbolToExportInfos.add(ts.getUniqueSymbolId(exportedSymbol, checker).toString(), { moduleSymbol: moduleSymbol, importKind: importKind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(exportedSymbol, checker) }); + var packageJsonFilter = ts.createPackageJsonImportFilter(fromFile, host); + var moduleSpecifierCache = (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host); + var getModuleSpecifierResolutionHost = ts.memoizeOne(function (isFromPackageJson) { + return ts.createModuleSpecifierResolutionHost(isFromPackageJson ? host.getPackageJsonAutoImportProvider() : program, host); + }); + function addSymbol(moduleSymbol, toFile, exportedSymbol, exportKind, program, isFromPackageJson) { + var moduleSpecifierResolutionHost = getModuleSpecifierResolutionHost(isFromPackageJson); + if (toFile && ts.isImportableFile(program, fromFile, toFile, packageJsonFilter, moduleSpecifierResolutionHost, moduleSpecifierCache) || + !toFile && packageJsonFilter.allowsImportingAmbientModule(moduleSymbol, moduleSpecifierResolutionHost)) { + var checker = program.getTypeChecker(); + originalSymbolToExportInfos.add(ts.getUniqueSymbolId(exportedSymbol, checker).toString(), { symbol: exportedSymbol, moduleSymbol: moduleSymbol, exportKind: exportKind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(exportedSymbol, checker), isFromPackageJson: isFromPackageJson }); + } } - forEachExternalModuleToImportFrom(program, host, sourceFile, /*filterByPackageJson*/ true, useAutoImportProvider, function (moduleSymbol, _, program) { + forEachExternalModuleToImportFrom(program, host, useAutoImportProvider, function (moduleSymbol, sourceFile, program, isFromPackageJson) { var checker = program.getTypeChecker(); cancellationToken.throwIfCancellationRequested(); var compilerOptions = program.getCompilerOptions(); - var defaultInfo = getDefaultLikeExportInfo(sourceFile, moduleSymbol, checker, compilerOptions); + var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, compilerOptions.target) === symbolName) && symbolHasMeaning(defaultInfo.symbolForMeaning, currentTokenMeaning)) { - addSymbol(moduleSymbol, defaultInfo.symbol, defaultInfo.kind, checker); + addSymbol(moduleSymbol, sourceFile, defaultInfo.symbol, defaultInfo.exportKind, program, isFromPackageJson); } // check exports with the same name var exportSymbolWithIdenticalName = checker.tryGetMemberInModuleExportsAndProperties(symbolName, moduleSymbol); if (exportSymbolWithIdenticalName && symbolHasMeaning(exportSymbolWithIdenticalName, currentTokenMeaning)) { - addSymbol(moduleSymbol, exportSymbolWithIdenticalName, 0 /* Named */, checker); + addSymbol(moduleSymbol, sourceFile, exportSymbolWithIdenticalName, 0 /* Named */, program, isFromPackageJson); } }); return originalSymbolToExportInfos; } - function getDefaultLikeExportInfo(importingFile, moduleSymbol, checker, compilerOptions) { - var exported = getDefaultLikeExportWorker(importingFile, moduleSymbol, checker, compilerOptions); + function getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions) { + var exported = getDefaultLikeExportWorker(moduleSymbol, checker); if (!exported) return undefined; - var symbol = exported.symbol, kind = exported.kind; - var info = getDefaultExportInfoWorker(symbol, moduleSymbol, checker, compilerOptions); - return info && __assign({ symbol: symbol, kind: kind }, info); + var symbol = exported.symbol, exportKind = exported.exportKind; + var info = getDefaultExportInfoWorker(symbol, checker, compilerOptions); + return info && __assign({ symbol: symbol, exportKind: exportKind }, info); } - function getDefaultLikeExportWorker(importingFile, moduleSymbol, checker, compilerOptions) { + 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); if (defaultExport) - return { symbol: defaultExport, kind: 1 /* Default */ }; - var exportEquals = checker.resolveExternalModuleSymbol(moduleSymbol); - return exportEquals === moduleSymbol ? undefined : { symbol: exportEquals, kind: getExportEqualsImportKind(importingFile, compilerOptions) }; + return { symbol: defaultExport, exportKind: 1 /* Default */ }; } function getExportEqualsImportKind(importingFile, compilerOptions) { var allowSyntheticDefaults = ts.getAllowSyntheticDefaultImports(compilerOptions); @@ -138523,7 +143562,8 @@ var ts; // on how to handle it. for (var _i = 0, _a = importingFile.statements; _i < _a.length; _i++) { var statement = _a[_i]; - if (ts.isImportEqualsDeclaration(statement)) { + // `import foo` parses as an ImportEqualsDeclaration even though it could be an ImportDeclaration + if (ts.isImportEqualsDeclaration(statement) && !ts.nodeIsMissing(statement.moduleReference)) { return 3 /* CommonJS */; } } @@ -138531,7 +143571,7 @@ var ts; // allowSyntheticDefaultImports/esModuleInterop is enabled. return allowSyntheticDefaults ? 1 /* Default */ : 3 /* CommonJS */; } - function getDefaultExportInfoWorker(defaultExport, moduleSymbol, checker, compilerOptions) { + function getDefaultExportInfoWorker(defaultExport, checker, compilerOptions) { var localSymbol = ts.getLocalSymbolForExportDefault(defaultExport); if (localSymbol) return { symbolForMeaning: localSymbol, name: localSymbol.name }; @@ -138545,21 +143585,20 @@ var ts; // but we can still offer completions for it. // - `aliased.parent` will be undefined if the module is exporting `globalThis.something`, // or another expression that resolves to a global. - return getDefaultExportInfoWorker(aliased, aliased.parent, checker, compilerOptions); + return getDefaultExportInfoWorker(aliased, checker, compilerOptions); } } if (defaultExport.escapedName !== "default" /* Default */ && defaultExport.escapedName !== "export=" /* ExportEquals */) { return { symbolForMeaning: defaultExport, name: defaultExport.getName() }; } - return { symbolForMeaning: defaultExport, name: moduleSymbolToValidIdentifier(moduleSymbol, compilerOptions.target) }; + return { symbolForMeaning: defaultExport, name: ts.getNameForExportedSymbol(defaultExport, compilerOptions.target) }; } function getNameForExportDefault(symbol) { return symbol.declarations && ts.firstDefined(symbol.declarations, function (declaration) { + var _a; if (ts.isExportAssignment(declaration)) { - if (ts.isIdentifier(declaration.expression)) { - return declaration.expression.text; - } + 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"); @@ -138602,7 +143641,7 @@ var ts; } } function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports, canUseTypeOnlyImport) { - if (clause.kind === 196 /* ObjectBindingPattern */) { + if (clause.kind === 198 /* ObjectBindingPattern */) { if (defaultImport) { addElementToBindingPattern(clause, defaultImport, "default"); } @@ -138729,48 +143768,23 @@ var ts; var declarations = _a.declarations; return ts.some(declarations, function (decl) { return !!(ts.getMeaningFromDeclaration(decl) & meaning); }); } - function forEachExternalModuleToImportFrom(program, host, from, filterByPackageJson, useAutoImportProvider, cb) { + function forEachExternalModuleToImportFrom(program, host, useAutoImportProvider, cb) { var _a, _b; - forEachExternalModuleToImportFromInProgram(program, host, from, filterByPackageJson, function (module, file) { return cb(module, file, program, /*isFromPackageJson*/ false); }); + forEachExternalModule(program.getTypeChecker(), program.getSourceFiles(), function (module, file) { return cb(module, file, program, /*isFromPackageJson*/ false); }); var autoImportProvider = useAutoImportProvider && ((_a = host.getPackageJsonAutoImportProvider) === null || _a === void 0 ? void 0 : _a.call(host)); if (autoImportProvider) { var start = ts.timestamp(); - forEachExternalModuleToImportFromInProgram(autoImportProvider, host, from, filterByPackageJson, function (module, file) { return cb(module, file, autoImportProvider, /*isFromPackageJson*/ true); }); + forEachExternalModule(autoImportProvider.getTypeChecker(), autoImportProvider.getSourceFiles(), 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)); } } codefix.forEachExternalModuleToImportFrom = forEachExternalModuleToImportFrom; - function forEachExternalModuleToImportFromInProgram(program, host, from, filterByPackageJson, cb) { - var _a; - var filteredCount = 0; - var moduleSpecifierResolutionHost = ts.createModuleSpecifierResolutionHost(program, host); - var packageJson = filterByPackageJson && createAutoImportFilter(from, program, host, moduleSpecifierResolutionHost); - forEachExternalModule(program.getTypeChecker(), program.getSourceFiles(), function (module, sourceFile) { - if (sourceFile === undefined) { - if (!packageJson || packageJson.allowsImportingAmbientModule(module)) { - cb(module, sourceFile); - } - else if (packageJson) { - filteredCount++; - } - } - else if (sourceFile && - sourceFile !== from && - isImportableFile(program, from, sourceFile, moduleSpecifierResolutionHost)) { - if (!packageJson || packageJson.allowsImportingSourceFile(sourceFile)) { - cb(module, sourceFile); - } - else if (packageJson) { - filteredCount++; - } - } - }); - (_a = host.log) === null || _a === void 0 ? void 0 : _a.call(host, "forEachExternalModuleToImportFrom: filtered out " + filteredCount + " modules by package.json contents"); - } function forEachExternalModule(checker, allSourceFiles, cb) { for (var _i = 0, _a = checker.getAmbientModules(); _i < _a.length; _i++) { var ambient = _a[_i]; - cb(ambient, /*sourceFile*/ undefined); + if (!ts.stringContains(ambient.name, "*")) { + cb(ambient, /*sourceFile*/ undefined); + } } for (var _b = 0, allSourceFiles_1 = allSourceFiles; _b < allSourceFiles_1.length; _b++) { var sourceFile = allSourceFiles_1[_b]; @@ -138779,31 +143793,6 @@ var ts; } } } - function isImportableFile(program, from, to, moduleSpecifierResolutionHost) { - var _a; - var getCanonicalFileName = ts.hostGetCanonicalFileName(moduleSpecifierResolutionHost); - var globalTypingsCache = (_a = moduleSpecifierResolutionHost.getGlobalTypingsCacheLocation) === null || _a === void 0 ? void 0 : _a.call(moduleSpecifierResolutionHost); - return !!ts.moduleSpecifiers.forEachFileNameOfModule(from.fileName, to.fileName, moduleSpecifierResolutionHost, - /*preferSymlinks*/ false, function (toPath) { - var toFile = program.getSourceFile(toPath); - // Determine to import using toPath only if toPath is what we were looking at - // or there doesnt exist the file in the program by the symlink - return (toFile === to || !toFile) && - isImportablePath(from.fileName, toPath, getCanonicalFileName, globalTypingsCache); - }); - } - /** - * Don't include something from a `node_modules` that isn't actually reachable by a global import. - * A relative import to node_modules is usually a bad idea. - */ - function isImportablePath(fromPath, toPath, getCanonicalFileName, globalCachePath) { - // If it's in a `node_modules` but is not reachable from here via a global import, don't bother. - var toNodeModules = ts.forEachAncestorDirectory(toPath, function (ancestor) { return ts.getBaseFileName(ancestor) === "node_modules" ? ancestor : undefined; }); - var toNodeModulesParent = toNodeModules && ts.getDirectoryPath(getCanonicalFileName(toNodeModules)); - return toNodeModulesParent === undefined - || ts.startsWith(getCanonicalFileName(fromPath), toNodeModulesParent) - || (!!globalCachePath && ts.startsWith(getCanonicalFileName(globalCachePath), toNodeModulesParent)); - } function moduleSymbolToValidIdentifier(moduleSymbol, target) { return moduleSpecifierToValidIdentifier(ts.removeFileExtension(ts.stripQuotes(moduleSymbol.name)), target); } @@ -138835,99 +143824,122 @@ var ts; return !ts.isStringANonContextualKeyword(res) ? res || "_" : "_" + res; } codefix.moduleSpecifierToValidIdentifier = moduleSpecifierToValidIdentifier; - function createAutoImportFilter(fromFile, program, host, moduleSpecifierResolutionHost) { - if (moduleSpecifierResolutionHost === void 0) { moduleSpecifierResolutionHost = ts.createModuleSpecifierResolutionHost(program, host); } - var packageJsons = ((host.getPackageJsonsVisibleToFile && host.getPackageJsonsVisibleToFile(fromFile.fileName)) || ts.getPackageJsonsVisibleToFile(fromFile.fileName, host)).filter(function (p) { return p.parseable; }); - var usesNodeCoreModules; - return { allowsImportingAmbientModule: allowsImportingAmbientModule, allowsImportingSourceFile: allowsImportingSourceFile, allowsImportingSpecifier: allowsImportingSpecifier, moduleSpecifierResolutionHost: moduleSpecifierResolutionHost }; - function moduleSpecifierIsCoveredByPackageJson(specifier) { - var packageName = getNodeModuleRootSpecifier(specifier); - for (var _i = 0, packageJsons_1 = packageJsons; _i < packageJsons_1.length; _i++) { - var packageJson = packageJsons_1[_i]; - if (packageJson.has(packageName) || packageJson.has(ts.getTypesPackageName(packageName))) { - return true; + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var codefix; + (function (codefix) { + var _a; + var fixName = "fixOverrideModifier"; + var fixAddOverrideId = "fixAddOverrideModifier"; + var fixRemoveOverrideId = "fixRemoveOverrideModifier"; + var errorCodes = [ + ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0.code, + ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class.code, + ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0.code, + ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0.code, + ts.Diagnostics.This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0.code + ]; + var errorCodeFixIdMap = (_a = {}, + _a[ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0.code] = [ + ts.Diagnostics.Add_override_modifier, fixAddOverrideId, ts.Diagnostics.Add_all_missing_override_modifiers, + ], + _a[ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class.code] = [ + ts.Diagnostics.Remove_override_modifier, fixRemoveOverrideId, ts.Diagnostics.Remove_all_unnecessary_override_modifiers + ], + _a[ts.Diagnostics.This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0.code] = [ + ts.Diagnostics.Add_override_modifier, fixAddOverrideId, ts.Diagnostics.Add_all_missing_override_modifiers, + ], + _a[ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0.code] = [ + ts.Diagnostics.Add_override_modifier, fixAddOverrideId, ts.Diagnostics.Remove_all_unnecessary_override_modifiers + ], + _a[ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0.code] = [ + ts.Diagnostics.Remove_override_modifier, fixRemoveOverrideId, ts.Diagnostics.Remove_all_unnecessary_override_modifiers + ], + _a); + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var errorCode = context.errorCode, span = context.span, sourceFile = context.sourceFile; + var info = errorCodeFixIdMap[errorCode]; + if (!info) + return ts.emptyArray; + var descriptions = info[0], fixId = info[1], fixAllDescriptions = info[2]; + if (ts.isSourceFileJS(sourceFile)) + return ts.emptyArray; + var changes = ts.textChanges.ChangeTracker.with(context, function (changes) { return dispatchChanges(changes, context, errorCode, span.start); }); + return [ + codefix.createCodeFixActionMaybeFixAll(fixName, changes, descriptions, fixId, fixAllDescriptions) + ]; + }, + fixIds: [fixName, fixAddOverrideId, fixRemoveOverrideId], + getAllCodeActions: function (context) { + return codefix.codeFixAll(context, errorCodes, function (changes, diag) { + var code = diag.code, start = diag.start, file = diag.file; + var info = errorCodeFixIdMap[code]; + if (!info || info[1] !== context.fixId || ts.isSourceFileJS(file)) { + return; } - } - return false; - } - function allowsImportingAmbientModule(moduleSymbol) { - if (!packageJsons.length) { - return true; - } - var declaringSourceFile = moduleSymbol.valueDeclaration.getSourceFile(); - var declaringNodeModuleName = getNodeModulesPackageNameFromFileName(declaringSourceFile.fileName); - if (typeof declaringNodeModuleName === "undefined") { - return true; - } - var declaredModuleSpecifier = ts.stripQuotes(moduleSymbol.getName()); - if (isAllowedCoreNodeModulesImport(declaredModuleSpecifier)) { - return true; - } - return moduleSpecifierIsCoveredByPackageJson(declaringNodeModuleName) - || moduleSpecifierIsCoveredByPackageJson(declaredModuleSpecifier); - } - function allowsImportingSourceFile(sourceFile) { - if (!packageJsons.length) { - return true; - } - var moduleSpecifier = getNodeModulesPackageNameFromFileName(sourceFile.fileName); - if (!moduleSpecifier) { - return true; - } - return moduleSpecifierIsCoveredByPackageJson(moduleSpecifier); + dispatchChanges(changes, context, code, start); + }); } - /** - * Use for a specific module specifier that has already been resolved. - * Use `allowsImportingAmbientModule` or `allowsImportingSourceFile` to resolve - * the best module specifier for a given module _and_ determine if it’s importable. - */ - function allowsImportingSpecifier(moduleSpecifier) { - if (!packageJsons.length || isAllowedCoreNodeModulesImport(moduleSpecifier)) { - return true; - } - if (ts.pathIsRelative(moduleSpecifier) || ts.isRootedDiskPath(moduleSpecifier)) { + }); + function dispatchChanges(changeTracker, context, errorCode, pos) { + switch (errorCode) { + case ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0.code: + case ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0.code: + case ts.Diagnostics.This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0.code: + return doAddOverrideModifierChange(changeTracker, context.sourceFile, pos); + case ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0.code: + case ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class.code: + return doRemoveOverrideModifierChange(changeTracker, context.sourceFile, pos); + default: + ts.Debug.fail("Unexpected error code: " + errorCode); + } + } + function doAddOverrideModifierChange(changeTracker, sourceFile, pos) { + var classElement = findContainerClassElementLike(sourceFile, pos); + var modifiers = classElement.modifiers || ts.emptyArray; + var staticModifier = ts.find(modifiers, ts.isStaticModifier); + var accessibilityModifier = ts.find(modifiers, function (m) { return ts.isAccessibilityModifier(m.kind); }); + var modifierPos = staticModifier ? staticModifier.end : + accessibilityModifier ? accessibilityModifier.end : + classElement.decorators ? ts.skipTrivia(sourceFile.text, classElement.decorators.end) : classElement.getStart(sourceFile); + var options = accessibilityModifier || staticModifier ? { prefix: " " } : { suffix: " " }; + changeTracker.insertModifierAt(sourceFile, modifierPos, 157 /* OverrideKeyword */, options); + } + function doRemoveOverrideModifierChange(changeTracker, sourceFile, pos) { + var classElement = findContainerClassElementLike(sourceFile, pos); + var overrideModifier = classElement.modifiers && ts.find(classElement.modifiers, function (modifier) { return modifier.kind === 157 /* OverrideKeyword */; }); + ts.Debug.assertIsDefined(overrideModifier); + changeTracker.deleteModifier(sourceFile, overrideModifier); + } + function isClassElementLikeHasJSDoc(node) { + switch (node.kind) { + case 168 /* Constructor */: + case 165 /* PropertyDeclaration */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return true; - } - return moduleSpecifierIsCoveredByPackageJson(moduleSpecifier); - } - function isAllowedCoreNodeModulesImport(moduleSpecifier) { - // If we’re in JavaScript, it can be difficult to tell whether the user wants to import - // from Node core modules or not. We can start by seeing if the user is actually using - // any node core modules, as opposed to simply having @types/node accidentally as a - // dependency of a dependency. - if (ts.isSourceFileJS(fromFile) && ts.JsTyping.nodeCoreModules.has(moduleSpecifier)) { - if (usesNodeCoreModules === undefined) { - usesNodeCoreModules = ts.consumesNodeCoreModules(fromFile); - } - if (usesNodeCoreModules) { - return true; - } - } - return false; - } - function getNodeModulesPackageNameFromFileName(importedFileName) { - if (!ts.stringContains(importedFileName, "node_modules")) { - return undefined; - } - var specifier = ts.moduleSpecifiers.getNodeModulesPackageName(host.getCompilationSettings(), fromFile.path, importedFileName, moduleSpecifierResolutionHost); - if (!specifier) { - return undefined; - } - // Paths here are not node_modules, so we don’t care about them; - // returning anything will trigger a lookup in package.json. - if (!ts.pathIsRelative(specifier) && !ts.isRootedDiskPath(specifier)) { - return getNodeModuleRootSpecifier(specifier); - } - } - function getNodeModuleRootSpecifier(fullSpecifier) { - var components = ts.getPathComponents(ts.getPackageNameFromTypesPackageName(fullSpecifier)).slice(1); - // Scoped packages - if (ts.startsWith(components[0], "@")) { - return components[0] + "/" + components[1]; - } - return components[0]; + case 162 /* Parameter */: + return ts.isParameterPropertyDeclaration(node, node.parent); + default: + return false; } } + function findContainerClassElementLike(sourceFile, pos) { + var token = ts.getTokenAtPosition(sourceFile, pos); + var classElement = ts.findAncestor(token, function (node) { + if (ts.isClassLike(node)) + return "quit"; + return isClassElementLikeHasJSDoc(node); + }); + ts.Debug.assert(classElement && isClassElementLikeHasJSDoc(classElement)); + return classElement; + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -138988,12 +144000,12 @@ var ts; }); function doChange(changes, sourceFile, pos, checker) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 107 /* ThisKeyword */); + ts.Debug.assert(token.kind === 108 /* ThisKeyword */); var fn = ts.getThisContainer(token, /*includeArrowFunctions*/ false); 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.assertDefined(ts.findChildOfKind(fn, 97 /* FunctionKeyword */, sourceFile)); + var fnKeyword = ts.Debug.assertDefined(ts.findChildOfKind(fn, 98 /* FunctionKeyword */, sourceFile)); var name = fn.name; var body = ts.Debug.assertDefined(fn.body); // Should be defined because the function contained a 'this' expression if (ts.isFunctionExpression(fn)) { @@ -139012,7 +144024,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(84 /* ConstKeyword */)); + changes.replaceNode(sourceFile, fnKeyword, ts.factory.createToken(85 /* ConstKeyword */)); changes.insertText(sourceFile, name.end, " = "); changes.insertText(sourceFile, body.pos, " =>"); return [ts.Diagnostics.Convert_function_declaration_0_to_arrow_function, name.text]; @@ -139043,7 +144055,7 @@ var ts; }); function getNamedTupleMember(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - return ts.findAncestor(token, function (t) { return t.kind === 192 /* NamedTupleMember */; }); + return ts.findAncestor(token, function (t) { return t.kind === 194 /* NamedTupleMember */; }); } function doChange(changes, sourceFile, namedTupleMember) { if (!namedTupleMember) { @@ -139052,11 +144064,11 @@ var ts; var unwrappedType = namedTupleMember.type; var sawOptional = false; var sawRest = false; - while (unwrappedType.kind === 180 /* OptionalType */ || unwrappedType.kind === 181 /* RestType */ || unwrappedType.kind === 186 /* ParenthesizedType */) { - if (unwrappedType.kind === 180 /* OptionalType */) { + while (unwrappedType.kind === 182 /* OptionalType */ || unwrappedType.kind === 183 /* RestType */ || unwrappedType.kind === 188 /* ParenthesizedType */) { + if (unwrappedType.kind === 182 /* OptionalType */) { sawOptional = true; } - else if (unwrappedType.kind === 181 /* RestType */) { + else if (unwrappedType.kind === 183 /* RestType */) { sawRest = true; } unwrappedType = unwrappedType.type; @@ -139120,7 +144132,7 @@ var ts; var checker = context.program.getTypeChecker(); var suggestedSymbol; if (ts.isPropertyAccessExpression(parent) && parent.name === node) { - ts.Debug.assert(ts.isIdentifierOrPrivateIdentifier(node), "Expected an identifier for spelling (property access)"); + ts.Debug.assert(ts.isMemberName(node), "Expected an identifier for spelling (property access)"); var containingType = checker.getTypeAtLocation(parent.expression); if (parent.flags & 32 /* OptionalChain */) { containingType = checker.getNonNullableType(containingType); @@ -139159,7 +144171,7 @@ var ts; var suggestion = ts.symbolName(suggestedSymbol); if (!ts.isIdentifierText(suggestion, target) && ts.isPropertyAccessExpression(node.parent)) { var valDecl = suggestedSymbol.valueDeclaration; - if (ts.isNamedDeclaration(valDecl) && ts.isPrivateIdentifier(valDecl.name)) { + if (valDecl && ts.isNamedDeclaration(valDecl) && ts.isPrivateIdentifier(valDecl.name)) { changes.replaceNode(sourceFile, node, ts.factory.createIdentifier(suggestion)); } else { @@ -139356,19 +144368,19 @@ var ts; } function getVariableLikeInitializer(declaration) { switch (declaration.kind) { - case 249 /* VariableDeclaration */: - case 160 /* Parameter */: - case 198 /* BindingElement */: - case 163 /* PropertyDeclaration */: - case 288 /* PropertyAssignment */: + case 251 /* VariableDeclaration */: + case 162 /* Parameter */: + case 200 /* BindingElement */: + case 165 /* PropertyDeclaration */: + case 290 /* PropertyAssignment */: return declaration.initializer; - case 280 /* JsxAttribute */: + case 282 /* JsxAttribute */: return declaration.initializer && (ts.isJsxExpression(declaration.initializer) ? declaration.initializer.expression : undefined); - case 289 /* ShorthandPropertyAssignment */: - case 162 /* PropertySignature */: - case 291 /* EnumMember */: - case 333 /* JSDocPropertyTag */: - case 326 /* JSDocParameterTag */: + case 291 /* ShorthandPropertyAssignment */: + case 164 /* PropertySignature */: + case 293 /* EnumMember */: + case 341 /* JSDocPropertyTag */: + case 334 /* JSDocParameterTag */: return undefined; } } @@ -139469,7 +144481,7 @@ var ts; }); typeDeclToMembers.forEach(function (infos, classDeclaration) { var supers = codefix.getAllSupers(classDeclaration, checker); - var _loop_13 = function (info) { + var _loop_14 = function (info) { // If some superclass added this property, don't add it again. if (supers.some(function (superClassOrInterface) { var superInfos = typeDeclToMembers.get(superClassOrInterface); @@ -139494,9 +144506,9 @@ var ts; } } }; - for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) { - var info = infos_1[_i]; - _loop_13(info); + for (var _i = 0, infos_2 = infos; _i < infos_2.length; _i++) { + var info = infos_2[_i]; + _loop_14(info); } }); })); @@ -139586,7 +144598,7 @@ var ts; function addMissingMemberInJs(changeTracker, declSourceFile, classDeclaration, token, makeStatic) { var tokenName = token.text; if (makeStatic) { - if (classDeclaration.kind === 221 /* ClassExpression */) { + if (classDeclaration.kind === 223 /* ClassExpression */) { return; } var className = classDeclaration.name.getText(); @@ -139638,17 +144650,17 @@ var ts; } function getTypeNode(checker, classDeclaration, token) { var typeNode; - if (token.parent.parent.kind === 216 /* BinaryExpression */) { + if (token.parent.parent.kind === 218 /* 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, classDeclaration, /*flags*/ undefined); + typeNode = checker.typeToTypeNode(widenedType, classDeclaration, 1 /* NoTruncation */); } else { var contextualType = checker.getContextualType(token.parent); - typeNode = contextualType ? checker.typeToTypeNode(contextualType, /*enclosingDeclaration*/ undefined, /*flags*/ undefined) : undefined; + typeNode = contextualType ? checker.typeToTypeNode(contextualType, /*enclosingDeclaration*/ undefined, 1 /* NoTruncation */) : undefined; } - return typeNode || ts.factory.createKeywordTypeNode(128 /* AnyKeyword */); + return typeNode || ts.factory.createKeywordTypeNode(129 /* AnyKeyword */); } function addPropertyDeclaration(changeTracker, declSourceFile, classDeclaration, tokenName, typeNode, modifierFlags) { var property = ts.factory.createPropertyDeclaration( @@ -139677,7 +144689,7 @@ var ts; } function createAddIndexSignatureAction(context, declSourceFile, classDeclaration, tokenName, typeNode) { // Index signatures cannot have the static modifier. - var stringTypeNode = ts.factory.createKeywordTypeNode(147 /* StringKeyword */); + var stringTypeNode = ts.factory.createKeywordTypeNode(148 /* StringKeyword */); var indexingParameter = ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -139710,7 +144722,7 @@ var ts; } function addMethodDeclaration(context, changes, callExpression, name, modifierFlags, parentDeclaration, sourceFile) { var importAdder = codefix.createImportAdder(sourceFile, context.program, context.preferences, context.host); - var methodDeclaration = codefix.createSignatureDeclarationFromCallExpression(165 /* MethodDeclaration */, context, importAdder, callExpression, name, modifierFlags, parentDeclaration); + var methodDeclaration = codefix.createSignatureDeclarationFromCallExpression(167 /* MethodDeclaration */, context, importAdder, callExpression, name, modifierFlags, parentDeclaration); var containingMethodDeclaration = ts.findAncestor(callExpression, function (n) { return ts.isMethodDeclaration(n) || ts.isConstructorDeclaration(n); }); if (containingMethodDeclaration && containingMethodDeclaration.parent === parentDeclaration) { changes.insertNodeAfter(sourceFile, containingMethodDeclaration, methodDeclaration); @@ -139739,7 +144751,7 @@ var ts; } function addFunctionDeclaration(changes, context, info) { var importAdder = codefix.createImportAdder(context.sourceFile, context.program, context.preferences, context.host); - var functionDeclaration = codefix.createSignatureDeclarationFromCallExpression(251 /* FunctionDeclaration */, context, importAdder, info.call, info.token, info.modifierFlags, info.parentDeclaration); + var functionDeclaration = codefix.createSignatureDeclarationFromCallExpression(253 /* FunctionDeclaration */, context, importAdder, info.call, ts.idText(info.token), info.modifierFlags, info.parentDeclaration); changes.insertNodeAtEndOfScope(info.sourceFile, info.parentDeclaration, functionDeclaration); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -139826,7 +144838,10 @@ var ts; return { type: "install package", file: fileName, packageName: packageName }; } function tryGetImportedPackageName(sourceFile, pos) { - var moduleName = ts.cast(ts.getTokenAtPosition(sourceFile, pos), ts.isStringLiteral).text; + var moduleSpecifierText = ts.tryCast(ts.getTokenAtPosition(sourceFile, pos), ts.isStringLiteral); + if (!moduleSpecifierText) + return undefined; + var moduleName = moduleSpecifierText.text; var packageName = ts.parsePackageName(moduleName).packageName; return ts.isExternalModuleNameRelative(packageName) ? undefined : packageName; } @@ -139932,7 +144947,7 @@ var ts; } function getNodes(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - if (token.kind !== 107 /* ThisKeyword */) + if (token.kind !== 108 /* ThisKeyword */) return undefined; var constructor = ts.getContainingFunction(token); var superCall = findSuperCall(constructor.body); @@ -140056,7 +145071,10 @@ var ts; var codefix; (function (codefix) { codefix.registerCodeFix({ - errorCodes: [ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher.code], + errorCodes: [ + ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher.code, + ts.Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher.code, + ], getCodeActions: function (context) { var compilerOptions = context.program.getCompilerOptions(); var configFile = compilerOptions.configFile; @@ -140152,14 +145170,14 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, pos); var heritageClauses = ts.getContainingClass(token).heritageClauses; var extendsToken = heritageClauses[0].getFirstToken(); - return extendsToken.kind === 93 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; + return extendsToken.kind === 94 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; } function doChanges(changes, sourceFile, extendsToken, heritageClauses) { - changes.replaceNode(sourceFile, extendsToken, ts.factory.createToken(116 /* ImplementsKeyword */)); + changes.replaceNode(sourceFile, extendsToken, ts.factory.createToken(117 /* ImplementsKeyword */)); // If there is already an implements clause, replace the implements keyword with a comma. if (heritageClauses.length === 2 && - heritageClauses[0].token === 93 /* ExtendsKeyword */ && - heritageClauses[1].token === 116 /* ImplementsKeyword */) { + heritageClauses[0].token === 94 /* ExtendsKeyword */ && + heritageClauses[1].token === 117 /* ImplementsKeyword */) { var implementsToken = heritageClauses[1].getFirstToken(); var implementsFullStart = implementsToken.getFullStart(); changes.replaceRange(sourceFile, { pos: implementsFullStart, end: implementsFullStart }, ts.factory.createToken(27 /* CommaToken */)); @@ -140335,7 +145353,7 @@ var ts; ]; } var result = []; - if (token.kind === 135 /* InferKeyword */) { + if (token.kind === 136 /* 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)); @@ -140377,7 +145395,7 @@ var ts; break; } case fixIdDelete: { - if (token.kind === 135 /* InferKeyword */ || isImport(token)) { + if (token.kind === 136 /* InferKeyword */ || isImport(token)) { break; // Can't delete } else if (ts.isJSDocTemplateTag(token)) { @@ -140406,7 +145424,7 @@ var ts; break; } case fixIdInfer: - if (token.kind === 135 /* InferKeyword */) { + if (token.kind === 136 /* InferKeyword */) { changeInferToUnknown(changes, sourceFile, token); } break; @@ -140417,7 +145435,7 @@ var ts; }, }); function changeInferToUnknown(changes, sourceFile, token) { - changes.replaceNode(sourceFile, token.parent, ts.factory.createKeywordTypeNode(152 /* UnknownKeyword */)); + changes.replaceNode(sourceFile, token.parent, ts.factory.createKeywordTypeNode(153 /* UnknownKeyword */)); } function createDeleteFix(changes, diag) { return codefix.createCodeFixAction(fixName, changes, diag, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations); @@ -140426,18 +145444,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 === 99 /* ImportKeyword */ - || token.kind === 78 /* Identifier */ && (token.parent.kind === 265 /* ImportSpecifier */ || token.parent.kind === 262 /* ImportClause */); + return token.kind === 100 /* ImportKeyword */ + || token.kind === 79 /* Identifier */ && (token.parent.kind === 267 /* ImportSpecifier */ || token.parent.kind === 264 /* ImportClause */); } /** Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing. */ function tryGetFullImport(token) { - return token.kind === 99 /* ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; + return token.kind === 100 /* 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 === 232 /* VariableStatement */ ? node.parent : node); + changes.delete(sourceFile, node.parent.kind === 234 /* VariableStatement */ ? node.parent : node); } function deleteDestructuringElements(changes, sourceFile, node) { ts.forEach(node.elements, function (n) { return changes.delete(sourceFile, n); }); @@ -140446,7 +145464,7 @@ 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 === 135 /* InferKeyword */) { + if (token.kind === 136 /* InferKeyword */) { token = ts.cast(token.parent, ts.isInferTypeNode).typeParameter.name; } if (ts.isIdentifier(token) && canPrefix(token)) { @@ -140462,14 +145480,14 @@ var ts; } function canPrefix(token) { switch (token.parent.kind) { - case 160 /* Parameter */: - case 159 /* TypeParameter */: + case 162 /* Parameter */: + case 161 /* TypeParameter */: return true; - case 249 /* VariableDeclaration */: { + case 251 /* VariableDeclaration */: { var varDecl = token.parent; switch (varDecl.parent.parent.kind) { - case 239 /* ForOfStatement */: - case 238 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 240 /* ForInStatement */: return true; } } @@ -140493,8 +145511,10 @@ var ts; if (ts.isParameter(parent)) { tryDeleteParameter(changes, sourceFile, parent, checker, sourceFiles, program, cancellationToken, isFixAll); } - else if (!isFixAll || !(ts.isIdentifier(token) && ts.FindAllReferences.Core.isSymbolReferencedInFile(token, checker, sourceFile))) { - changes.delete(sourceFile, ts.isImportClause(parent) ? token : ts.isComputedPropertyName(parent) ? parent.parent : parent); + else if (!(isFixAll && ts.isIdentifier(token) && ts.FindAllReferences.Core.isSymbolReferencedInFile(token, checker, sourceFile))) { + var node = ts.isImportClause(parent) ? token : ts.isComputedPropertyName(parent) ? parent.parent : parent; + ts.Debug.assert(node !== sourceFile, "should not delete whole source file"); + changes.delete(sourceFile, node); } } function tryDeleteParameter(changes, sourceFile, parameter, checker, sourceFiles, program, cancellationToken, isFixAll) { @@ -140517,8 +145537,8 @@ var ts; function mayDeleteParameter(checker, sourceFile, parameter, sourceFiles, program, cancellationToken, isFixAll) { var parent = parameter.parent; switch (parent.kind) { - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: + case 167 /* MethodDeclaration */: + case 168 /* 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); @@ -140548,17 +145568,17 @@ var ts; } } return true; - case 251 /* FunctionDeclaration */: { + case 253 /* FunctionDeclaration */: { if (parent.name && isCallbackLike(checker, sourceFile, parent.name)) { return isLastParameter(parent, parameter, isFixAll); } return true; } - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 210 /* FunctionExpression */: + case 211 /* 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 168 /* SetAccessor */: + case 170 /* SetAccessor */: // Setter must have a parameter return false; default: @@ -140616,7 +145636,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 234 /* IfStatement */: + case 236 /* IfStatement */: if (container.elseStatement) { if (ts.isBlock(statement.parent)) { break; @@ -140627,8 +145647,8 @@ var ts; return; } // falls through - case 236 /* WhileStatement */: - case 237 /* ForStatement */: + case 238 /* WhileStatement */: + case 239 /* ForStatement */: changes.delete(sourceFile, container); return; } @@ -140701,7 +145721,7 @@ 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 === 305 /* JSDocNullableType */) { + if (typeNode.kind === 308 /* 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)); @@ -140721,7 +145741,7 @@ var ts; if (!info) return; var typeNode = info.typeNode, type = info.type; - var fixedType = typeNode.kind === 305 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; + var fixedType = typeNode.kind === 308 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; doChange(changes, sourceFile, typeNode, fixedType, checker); }); } @@ -140738,22 +145758,22 @@ var ts; // NOTE: Some locations are not handled yet: // MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments switch (node.kind) { - case 224 /* AsExpression */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 251 /* FunctionDeclaration */: - case 167 /* GetAccessor */: - case 171 /* IndexSignature */: - case 190 /* MappedType */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 160 /* Parameter */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 168 /* SetAccessor */: - case 254 /* TypeAliasDeclaration */: - case 206 /* TypeAssertionExpression */: - case 249 /* VariableDeclaration */: + case 226 /* AsExpression */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 253 /* FunctionDeclaration */: + case 169 /* GetAccessor */: + case 173 /* IndexSignature */: + case 192 /* MappedType */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 162 /* Parameter */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 170 /* SetAccessor */: + case 256 /* TypeAliasDeclaration */: + case 208 /* TypeAssertionExpression */: + case 251 /* VariableDeclaration */: return true; default: return false; @@ -140768,7 +145788,7 @@ var ts; (function (codefix) { var fixId = "fixMissingCallParentheses"; var errorCodes = [ - ts.Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead.code, + ts.Diagnostics.This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_instead.code, ]; codefix.registerCodeFix({ errorCodes: errorCodes, @@ -140814,7 +145834,7 @@ var ts; var fixId = "fixAwaitInSyncFunction"; var errorCodes = [ ts.Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code, - ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator.code, + ts.Diagnostics.for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code, ]; codefix.registerCodeFix({ errorCodes: errorCodes, @@ -140855,14 +145875,14 @@ var ts; } var insertBefore; switch (containingFunction.kind) { - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: insertBefore = containingFunction.name; break; - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - insertBefore = ts.findChildOfKind(containingFunction, 97 /* FunctionKeyword */, sourceFile); + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + insertBefore = ts.findChildOfKind(containingFunction, 98 /* FunctionKeyword */, sourceFile); break; - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: insertBefore = ts.findChildOfKind(containingFunction, 20 /* OpenParenToken */, sourceFile) || ts.first(containingFunction.parameters); break; default: @@ -140877,11 +145897,11 @@ var ts; var insertBefore = _a.insertBefore, returnType = _a.returnType; if (returnType) { var entityName = ts.getEntityNameFromTypeNode(returnType); - if (!entityName || entityName.kind !== 78 /* Identifier */ || entityName.text !== "Promise") { + if (!entityName || entityName.kind !== 79 /* Identifier */ || entityName.text !== "Promise") { changes.replaceNode(sourceFile, returnType, ts.factory.createTypeReferenceNode("Promise", ts.factory.createNodeArray([returnType]))); } } - changes.insertModifierBefore(sourceFile, 129 /* AsyncKeyword */, insertBefore); + changes.insertModifierBefore(sourceFile, 130 /* AsyncKeyword */, insertBefore); } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -141041,7 +146061,7 @@ var ts; return errorCode; } function doChange(changes, sourceFile, token, errorCode, program, cancellationToken, markSeen, host, preferences) { - if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 78 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 107 /* ThisKeyword */) { + if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 79 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 108 /* ThisKeyword */) { return undefined; } var parent = token.parent; @@ -141061,7 +146081,7 @@ var ts; var typeNode = ts.getTypeNodeIfAccessible(type, parent, program, host); if (typeNode) { // Note that the codefix will never fire with an existing `@type` tag, so there is no need to merge tags - var typeTag = ts.factory.createJSDocTypeTag(/*tagName*/ undefined, ts.factory.createJSDocTypeExpression(typeNode), /*comment*/ ""); + var typeTag = ts.factory.createJSDocTypeTag(/*tagName*/ undefined, ts.factory.createJSDocTypeExpression(typeNode), /*comment*/ undefined); addJSDocTags(changes, sourceFile, ts.cast(parent.parent.parent, ts.isExpressionStatement), [typeTag]); } importAdder.writeFixes(changes); @@ -141195,13 +146215,13 @@ 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 !== 162 /* PropertySignature */) { + if (ts.isInJSFile(sourceFile) && declaration.kind !== 164 /* PropertySignature */) { var parent = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : declaration; if (!parent) { return; } var typeExpression = ts.factory.createJSDocTypeExpression(typeNode); - var typeTag = ts.isGetAccessorDeclaration(declaration) ? ts.factory.createJSDocReturnTag(/*tagName*/ undefined, typeExpression, "") : ts.factory.createJSDocTypeTag(/*tagName*/ undefined, typeExpression, ""); + var typeTag = ts.isGetAccessorDeclaration(declaration) ? ts.factory.createJSDocReturnTag(/*tagName*/ undefined, typeExpression, /*comment*/ undefined) : ts.factory.createJSDocTypeTag(/*tagName*/ undefined, typeExpression, /*comment*/ undefined); addJSDocTags(changes, sourceFile, parent, [typeTag]); } else if (!tryReplaceImportTypeNodeWithAutoImport(typeNode, declaration, sourceFile, changes, importAdder, ts.getEmitScriptTarget(program.getCompilerOptions()))) { @@ -141256,13 +146276,13 @@ var ts; else { var paramTags = ts.map(inferences, function (_a) { var name = _a.name, typeNode = _a.typeNode, isOptional = _a.isOptional; - return ts.factory.createJSDocParameterTag(/*tagName*/ undefined, name, /*isBracketed*/ !!isOptional, ts.factory.createJSDocTypeExpression(typeNode), /* isNameFirst */ false, ""); + return ts.factory.createJSDocParameterTag(/*tagName*/ undefined, name, /*isBracketed*/ !!isOptional, ts.factory.createJSDocTypeExpression(typeNode), /* isNameFirst */ false, /*comment*/ undefined); }); addJSDocTags(changes, sourceFile, signature, paramTags); } } function addJSDocTags(changes, sourceFile, parent, newTags) { - var comments = ts.mapDefined(parent.jsDoc, function (j) { return j.comment; }); + var comments = ts.flatMap(parent.jsDoc, function (j) { return typeof j.comment === "string" ? ts.factory.createJSDocText(j.comment) : j.comment; }); var oldTags = ts.flatMapToMutable(parent.jsDoc, function (j) { return j.tags; }); var unmergedNewTags = newTags.filter(function (newTag) { return !oldTags || !oldTags.some(function (tag, i) { var merged = tryMergeJsdocTags(tag, newTag); @@ -141270,15 +146290,15 @@ var ts; oldTags[i] = merged; return !!merged; }); }); - var tag = ts.factory.createJSDocComment(comments.join("\n"), ts.factory.createNodeArray(__spreadArray(__spreadArray([], (oldTags || ts.emptyArray)), unmergedNewTags))); - var jsDocNode = parent.kind === 209 /* ArrowFunction */ ? getJsDocNodeForArrowFunction(parent) : parent; + var tag = ts.factory.createJSDocComment(ts.factory.createNodeArray(ts.intersperse(comments, ts.factory.createJSDocText("\n"))), ts.factory.createNodeArray(__spreadArray(__spreadArray([], (oldTags || ts.emptyArray)), unmergedNewTags))); + var jsDocNode = parent.kind === 211 /* ArrowFunction */ ? getJsDocNodeForArrowFunction(parent) : parent; jsDocNode.jsDoc = parent.jsDoc; jsDocNode.jsDocCache = parent.jsDocCache; changes.insertJsdocCommentBefore(sourceFile, jsDocNode, tag); } codefix.addJSDocTags = addJSDocTags; function getJsDocNodeForArrowFunction(signature) { - if (signature.parent.kind === 163 /* PropertyDeclaration */) { + if (signature.parent.kind === 165 /* PropertyDeclaration */) { return signature.parent; } return signature.parent.parent; @@ -141288,14 +146308,14 @@ var ts; return undefined; } switch (oldTag.kind) { - case 326 /* JSDocParameterTag */: { + case 334 /* 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 327 /* JSDocReturnTag */: + case 335 /* JSDocReturnTag */: return ts.factory.createJSDocReturnTag(/*tagName*/ undefined, newTag.typeExpression, oldTag.comment); } } @@ -141320,19 +146340,19 @@ var ts; function getFunctionReferences(containingFunction, sourceFile, program, cancellationToken) { var searchToken; switch (containingFunction.kind) { - case 166 /* Constructor */: - searchToken = ts.findChildOfKind(containingFunction, 132 /* ConstructorKeyword */, sourceFile); + case 168 /* Constructor */: + searchToken = ts.findChildOfKind(containingFunction, 133 /* ConstructorKeyword */, sourceFile); break; - case 209 /* ArrowFunction */: - case 208 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 210 /* FunctionExpression */: var parent = containingFunction.parent; searchToken = (ts.isVariableDeclaration(parent) || ts.isPropertyDeclaration(parent)) && ts.isIdentifier(parent.name) ? parent.name : containingFunction.name; break; - case 251 /* FunctionDeclaration */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 253 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: searchToken = containingFunction.name; break; } @@ -141474,24 +146494,24 @@ var ts; node = node.parent; } switch (node.parent.kind) { - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: inferTypeFromExpressionStatement(node, usage); break; - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: usage.isNumber = true; break; - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: inferTypeFromPrefixUnaryExpression(node.parent, usage); break; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: inferTypeFromBinaryExpression(node, node.parent, usage); break; - case 284 /* CaseClause */: - case 285 /* DefaultClause */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: inferTypeFromSwitchStatementLabel(node.parent, usage); break; - case 203 /* CallExpression */: - case 204 /* NewExpression */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: if (node.parent.expression === node) { inferTypeFromCallExpression(node.parent, usage); } @@ -141499,20 +146519,20 @@ var ts; inferTypeFromContextualType(node, usage); } break; - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: inferTypeFromPropertyAccessExpression(node.parent, usage); break; - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: inferTypeFromPropertyElementExpression(node.parent, node, usage); break; - case 288 /* PropertyAssignment */: - case 289 /* ShorthandPropertyAssignment */: + case 290 /* PropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: inferTypeFromPropertyAssignment(node.parent, usage); break; - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: inferTypeFromPropertyDeclaration(node.parent, usage); break; - case 249 /* VariableDeclaration */: { + case 251 /* 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. @@ -141570,17 +146590,17 @@ var ts; case 52 /* CaretToken */: // CompoundAssignmentOperator // falls through - case 64 /* MinusEqualsToken */: - case 66 /* AsteriskAsteriskEqualsToken */: - case 65 /* AsteriskEqualsToken */: - case 67 /* SlashEqualsToken */: - case 68 /* PercentEqualsToken */: - case 72 /* AmpersandEqualsToken */: - case 73 /* BarEqualsToken */: - case 77 /* CaretEqualsToken */: - case 69 /* LessThanLessThanEqualsToken */: - case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 70 /* GreaterThanGreaterThanEqualsToken */: + 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 */: // AdditiveOperator // falls through case 40 /* MinusToken */: @@ -141598,7 +146618,7 @@ var ts; usage.isNumber = true; } break; - case 63 /* PlusEqualsToken */: + case 64 /* PlusEqualsToken */: case 39 /* PlusToken */: var otherOperandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); if (otherOperandType.flags & 1056 /* EnumLike */) { @@ -141618,14 +146638,14 @@ var ts; } break; // AssignmentOperators - case 62 /* EqualsToken */: + case 63 /* EqualsToken */: case 34 /* EqualsEqualsToken */: case 36 /* EqualsEqualsEqualsToken */: case 37 /* ExclamationEqualsEqualsToken */: case 35 /* ExclamationEqualsToken */: addCandidateType(usage, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); break; - case 100 /* InKeyword */: + case 101 /* InKeyword */: if (node === parent.left) { usage.isString = true; } @@ -141634,7 +146654,7 @@ var ts; case 56 /* BarBarToken */: case 60 /* QuestionQuestionToken */: if (node === parent.left && - (node.parent.parent.kind === 249 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { + (node.parent.parent.kind === 251 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { // var x = x || {}; // TODO: use getFalsyflagsOfType addCandidateType(usage, checker.getTypeAtLocation(parent.right)); @@ -141642,7 +146662,7 @@ var ts; break; case 55 /* AmpersandAmpersandToken */: case 27 /* CommaToken */: - case 101 /* InstanceOfKeyword */: + case 102 /* InstanceOfKeyword */: // nothing to infer here break; } @@ -141662,7 +146682,7 @@ var ts; } } calculateUsageOfNode(parent, call.return_); - if (parent.kind === 203 /* CallExpression */) { + if (parent.kind === 205 /* CallExpression */) { (usage.calls || (usage.calls = [])).push(call); } else { @@ -141765,7 +146785,7 @@ var ts; var anon = anons_1[_i]; for (var _a = 0, _b = checker.getPropertiesOfType(anon); _a < _b.length; _a++) { var p = _b[_a]; - props.add(p.name, checker.getTypeOfSymbolAtLocation(p, p.valueDeclaration)); + 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 */)); @@ -141906,12 +146926,13 @@ var ts; if (!usageParam) { break; } - var genericParamType = checker.getTypeOfSymbolAtLocation(genericParam, genericParam.valueDeclaration); + var genericParamType = genericParam.valueDeclaration ? checker.getTypeOfSymbolAtLocation(genericParam, genericParam.valueDeclaration) : checker.getAnyType(); var elementType = isRest && checker.getElementTypeOfArrayType(genericParamType); if (elementType) { genericParamType = elementType; } - var targetType = usageParam.type || checker.getTypeOfSymbolAtLocation(usageParam, usageParam.valueDeclaration); + var targetType = usageParam.type + || (usageParam.valueDeclaration ? checker.getTypeOfSymbolAtLocation(usageParam, usageParam.valueDeclaration) : checker.getAnyType()); types.push.apply(types, inferTypeParameters(genericParamType, targetType, typeParameter)); } var genericReturn = checker.getReturnTypeOfSignature(genericSig); @@ -141925,7 +146946,7 @@ var ts; function getSignatureFromCalls(calls) { var parameters = []; var length = Math.max.apply(Math, calls.map(function (c) { return c.argumentTypes.length; })); - var _loop_14 = function (i) { + var _loop_15 = function (i) { var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i)); symbol.type = combineTypes(calls.map(function (call) { return call.argumentTypes[i] || checker.getUndefinedType(); })); if (calls.some(function (call) { return call.argumentTypes[i] === undefined; })) { @@ -141934,10 +146955,9 @@ var ts; parameters.push(symbol); }; for (var i = 0; i < length; i++) { - _loop_14(i); + _loop_15(i); } var returnType = combineFromUsage(combineUsages(calls.map(function (call) { return call.return_; }))); - // TODO: GH#18217 return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, 0 /* None */); } function addCandidateType(usage, type) { @@ -142081,7 +147101,7 @@ var ts; codefix.createMissingMemberNodes = createMissingMemberNodes; function getNoopSymbolTrackerWithResolver(context) { return { - trackSymbol: ts.noop, + trackSymbol: function () { return false; }, moduleResolverHost: ts.getModuleSpecifierResolverHost(context.program, context.host), }; } @@ -142105,8 +147125,8 @@ var ts; var ambient = !!(enclosingDeclaration.flags & 8388608 /* Ambient */); var quotePreference = ts.getQuotePreference(sourceFile, preferences); switch (declaration.kind) { - case 162 /* PropertySignature */: - case 163 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 165 /* PropertyDeclaration */: var flags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : undefined; var typeNode = checker.typeToTypeNode(type, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context)); if (importAdder) { @@ -142120,8 +147140,8 @@ var ts; /*decorators*/ undefined, modifiers, name, optional ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeNode, /*initializer*/ undefined)); break; - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: { + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: { var typeNode_1 = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); var allAccessors = ts.getAllAccessorDeclarations(declarations, declaration); var orderedAccessors = allAccessors.secondAccessor @@ -142150,8 +147170,8 @@ var ts; } break; } - case 164 /* MethodSignature */: - case 165 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 167 /* 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 @@ -142181,7 +147201,7 @@ var ts; } else { ts.Debug.assert(declarations.length === signatures.length, "Declarations and signatures should match count"); - addClassElement(createMethodImplementingSignatures(signatures, name, optional, modifiers, quotePreference)); + addClassElement(createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional, modifiers, quotePreference)); } } break; @@ -142197,7 +147217,7 @@ var ts; var checker = program.getTypeChecker(); var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions()); var flags = 1 /* NoTruncation */ | 1073741824 /* NoUndefinedOptionalParameterType */ | 256 /* SuppressAnyReturnType */ | (quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : 0); - var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, 165 /* MethodDeclaration */, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context)); + var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, 167 /* MethodDeclaration */, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context)); if (!signatureDeclaration) { return undefined; } @@ -142281,7 +147301,7 @@ var ts; var type = isJs || contextualType === undefined ? undefined : checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker); - if (kind === 165 /* MethodDeclaration */) { + if (kind === 167 /* MethodDeclaration */) { return ts.factory.createMethodDeclaration( /*decorators*/ undefined, modifiers, asteriskToken, name, /*questionToken*/ undefined, typeParameters, parameters, type, ts.isInterfaceDeclaration(contextNode) ? undefined : createStubbedMethodBody(quotePreference)); @@ -142311,13 +147331,13 @@ var ts; /*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(128 /* AnyKeyword */), + /*type*/ inJs ? undefined : types && types[i] || ts.factory.createKeywordTypeNode(129 /* AnyKeyword */), /*initializer*/ undefined); parameters.push(newParameter); } return parameters; } - function createMethodImplementingSignatures(signatures, name, optional, modifiers, quotePreference) { + function createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional, modifiers, quotePreference) { /** This is *a* signature with the maximal number of arguments, * such that if there is a "maximal" signature without rest arguments, * this is one of them. @@ -142339,7 +147359,7 @@ var ts; var maxArgsParameterSymbolNames = maxArgsSignature.parameters.map(function (symbol) { return symbol.name; }); var parameters = createDummyParameters(maxNonRestArgs, maxArgsParameterSymbolNames, /* types */ undefined, minArgumentCount, /*inJs*/ false); if (someSigHasRestParameter) { - var anyArrayType = ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(128 /* AnyKeyword */)); + var anyArrayType = ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(129 /* AnyKeyword */)); var restParameter = ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createToken(25 /* DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest", @@ -142348,8 +147368,13 @@ var ts; parameters.push(restParameter); } return createStubbedMethod(modifiers, name, optional, - /*typeParameters*/ undefined, parameters, - /*returnType*/ undefined, quotePreference); + /*typeParameters*/ undefined, parameters, getReturnTypeFromSignatures(signatures, checker, context, enclosingDeclaration), quotePreference); + } + function getReturnTypeFromSignatures(signatures, checker, context, enclosingDeclaration) { + if (ts.length(signatures)) { + var type = checker.getUnionType(ts.map(signatures, checker.getReturnTypeOfSignature)); + return checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); + } } function createStubbedMethod(modifiers, name, optional, typeParameters, parameters, returnType, quotePreference) { return ts.factory.createMethodDeclaration( @@ -142369,10 +147394,10 @@ var ts; codefix.createStubbedBody = createStubbedBody; function createVisibilityModifier(flags) { if (flags & 4 /* Public */) { - return ts.factory.createToken(122 /* PublicKeyword */); + return ts.factory.createToken(123 /* PublicKeyword */); } else if (flags & 16 /* Protected */) { - return ts.factory.createToken(121 /* ProtectedKeyword */); + return ts.factory.createToken(122 /* ProtectedKeyword */); } return undefined; } @@ -142445,7 +147470,7 @@ var ts; } codefix.tryGetAutoImportableReferenceFromTypeNode = tryGetAutoImportableReferenceFromTypeNode; function replaceFirstIdentifierOfEntityName(name, newIdentifier) { - if (name.kind === 78 /* Identifier */) { + if (name.kind === 79 /* Identifier */) { return newIdentifier; } return ts.factory.createQualifiedName(replaceFirstIdentifierOfEntityName(name.left, newIdentifier), name.right); @@ -142476,13 +147501,13 @@ var ts; if (ts.isClassLike(container)) { var modifierFlags = ts.getEffectiveModifierFlags(declaration); if (ts.isSourceFileJS(file)) { - var modifiers = createModifiers(modifierFlags); + var modifiers = ts.createModifiers(modifierFlags); accessorModifiers = modifiers; fieldModifiers = modifiers; } else { - accessorModifiers = createModifiers(prepareModifierFlagsForAccessor(modifierFlags)); - fieldModifiers = createModifiers(prepareModifierFlagsForField(modifierFlags)); + accessorModifiers = ts.createModifiers(prepareModifierFlagsForAccessor(modifierFlags)); + fieldModifiers = ts.createModifiers(prepareModifierFlagsForField(modifierFlags)); } } updateFieldDeclaration(changeTracker, file, declaration, type, fieldName, fieldModifiers); @@ -142517,9 +147542,6 @@ var ts; var leftHead = isStatic ? container.name : ts.factory.createThis(); // TODO: GH#18217 return ts.isIdentifier(fieldName) ? ts.factory.createPropertyAccessExpression(leftHead, fieldName) : ts.factory.createElementAccessExpression(leftHead, ts.factory.createStringLiteralFromNode(fieldName)); } - function createModifiers(modifierFlags) { - return modifierFlags ? ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(modifierFlags)) : undefined; - } function prepareModifierFlagsForAccessor(modifierFlags) { modifierFlags &= ~64 /* Readonly */; // avoid Readonly modifier because it will convert to get accessor modifierFlags &= ~8 /* Private */; @@ -142564,7 +147586,7 @@ var ts; isStatic: ts.hasStaticModifier(declaration), isReadonly: ts.hasEffectiveReadonlyModifier(declaration), type: getDeclarationType(declaration, program), - container: declaration.kind === 160 /* Parameter */ ? declaration.parent.parent : declaration.parent, + container: declaration.kind === 162 /* Parameter */ ? declaration.parent.parent : declaration.parent, originalName: declaration.name.text, declaration: declaration, fieldName: fieldName, @@ -142620,13 +147642,13 @@ var ts; return; constructor.body.forEachChild(function recur(node) { if (ts.isElementAccessExpression(node) && - node.expression.kind === 107 /* ThisKeyword */ && + node.expression.kind === 108 /* 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 === 107 /* ThisKeyword */ && node.name.text === originalName && ts.isWriteAccess(node)) { + if (ts.isPropertyAccessExpression(node) && node.expression.kind === 108 /* ThisKeyword */ && node.name.text === originalName && ts.isWriteAccess(node)) { changeTracker.replaceNode(file, node.name, ts.factory.createIdentifier(fieldName)); } if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) { @@ -142641,7 +147663,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), [ts.factory.createKeywordTypeNode(150 /* UndefinedKeyword */)])); + return ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], types), [ts.factory.createKeywordTypeNode(151 /* UndefinedKeyword */)])); } } return typeNode; @@ -142654,7 +147676,7 @@ var ts; if (!superSymbol) break; var symbol = superSymbol.flags & 2097152 /* Alias */ ? checker.getAliasedSymbol(superSymbol) : superSymbol; - var superDecl = ts.find(symbol.declarations, ts.isClassLike); + var superDecl = symbol.declarations && ts.find(symbol.declarations, ts.isClassLike); if (!superDecl) break; res.push(superDecl); @@ -142700,7 +147722,7 @@ var ts; }); function getActionsForUsageOfInvalidImport(context) { var sourceFile = context.sourceFile; - var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 203 /* CallExpression */ : 204 /* NewExpression */; + var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 205 /* CallExpression */ : 206 /* NewExpression */; var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start), function (a) { return a.kind === targetKind; }); if (!node) { return []; @@ -142819,7 +147841,7 @@ var ts; return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_undefined_type_to_property_0, propertyDeclaration.name.getText()], fixIdAddUndefinedType, ts.Diagnostics.Add_undefined_type_to_all_uninitialized_properties); } function addUndefinedType(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) { - var undefinedTypeNode = ts.factory.createKeywordTypeNode(150 /* UndefinedKeyword */); + var undefinedTypeNode = ts.factory.createKeywordTypeNode(151 /* UndefinedKeyword */); var type = propertyDeclaration.type; // TODO: GH#18217 var types = ts.isUnionTypeNode(type) ? type.types.concat(undefinedTypeNode) : [type, undefinedTypeNode]; changeTracker.replaceNode(propertyDeclarationSourceFile, type, ts.factory.createUnionTypeNode(types)); @@ -143033,8 +148055,8 @@ var ts; }); function getImportTypeNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 99 /* ImportKeyword */, "This token should be an ImportKeyword"); - ts.Debug.assert(token.parent.kind === 195 /* ImportType */, "Token parent should be an ImportType"); + ts.Debug.assert(token.kind === 100 /* ImportKeyword */, "This token should be an ImportKeyword"); + ts.Debug.assert(token.parent.kind === 197 /* ImportType */, "Token parent should be an ImportType"); return token.parent; } function doChange(changes, sourceFile, importType) { @@ -143053,10 +148075,6 @@ var ts; codefix.registerCodeFix({ errorCodes: errorCodes, getCodeActions: function (context) { - var jsx = context.program.getCompilerOptions().jsx; - if (jsx !== 2 /* React */ && jsx !== 3 /* ReactNative */) { - return undefined; - } var sourceFile = context.sourceFile, span = context.span; var node = findNodeToFix(sourceFile, span.start); if (!node) @@ -143166,7 +148184,7 @@ var ts; var otherMembers = members.filter(function (member) { return !ts.isIndexSignatureDeclaration(member); }); var parameter = ts.first(indexSignature.parameters); var mappedTypeParameter = ts.factory.createTypeParameterDeclaration(ts.cast(parameter.name, ts.isIdentifier), parameter.type); - var mappedIntersectionType = ts.factory.createMappedTypeNode(ts.hasEffectiveReadonlyModifier(indexSignature) ? ts.factory.createModifier(142 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, + var mappedIntersectionType = ts.factory.createMappedTypeNode(ts.hasEffectiveReadonlyModifier(indexSignature) ? ts.factory.createModifier(143 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, /*nameType*/ undefined, indexSignature.questionToken, indexSignature.type); var intersectionType = ts.factory.createIntersectionTypeNode(__spreadArray(__spreadArray(__spreadArray([], ts.getAllSuperTypeNodes(container)), [ mappedIntersectionType @@ -143223,7 +148241,7 @@ var ts; }, }); function makeChange(changeTracker, sourceFile, span) { - var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 130 /* AwaitKeyword */; }); + var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 131 /* AwaitKeyword */; }); var awaitExpression = awaitKeyword && ts.tryCast(awaitKeyword.parent, ts.isAwaitExpression); if (!awaitExpression) { return; @@ -143234,7 +148252,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 !== 102 /* NewKeyword */) { + if (precedingToken && precedingToken.kind !== 103 /* NewKeyword */) { expressionToReplace = awaitExpression.parent; } } @@ -143301,7 +148319,7 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, pos); var checker = program.getTypeChecker(); var symbol = checker.getSymbolAtLocation(token); - if (symbol) { + if (symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration) { return symbol.valueDeclaration.parent.parent; } } @@ -143396,7 +148414,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(113 /* VoidKeyword */)]).types[0]); + ts.isParenthesizedTypeNode(ts.factory.createUnionTypeNode([typeArgument, ts.factory.createKeywordTypeNode(114 /* VoidKeyword */)]).types[0]); if (needsParens) { changes.insertText(sourceFile, typeArgument.pos, "("); } @@ -143488,7 +148506,7 @@ var ts; ; function getInfo(context, considerPartialSpans) { if (considerPartialSpans === void 0) { considerPartialSpans = true; } - var file = context.file; + 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); @@ -143496,23 +148514,31 @@ var ts; return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_export_statement) }; } var exportingModuleSymbol = ts.isSourceFile(exportNode.parent) ? exportNode.parent.symbol : exportNode.parent.parent.symbol; - var flags = ts.getSyntacticModifierFlags(exportNode); + var flags = ts.getSyntacticModifierFlags(exportNode) || ((ts.isExportAssignment(exportNode) && !exportNode.isExportEquals) ? 513 /* ExportDefault */ : 0 /* None */); var wasDefault = !!(flags & 512 /* Default */); // If source file already has a default export, don't offer refactor. if (!(flags & 1 /* Export */) || !wasDefault && exportingModuleSymbol.exports.has("default" /* Default */)) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.This_file_already_has_a_default_export) }; } + var checker = program.getTypeChecker(); + var noSymbolError = function (id) { + return (ts.isIdentifier(id) && checker.getSymbolAtLocation(id)) ? undefined + : { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Can_only_convert_named_export) }; + }; switch (exportNode.kind) { - case 251 /* FunctionDeclaration */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 256 /* ModuleDeclaration */: { + case 253 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 257 /* EnumDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 258 /* ModuleDeclaration */: { var node = exportNode; - return node.name && ts.isIdentifier(node.name) ? { exportNode: node, exportName: node.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; + if (!node.name) + return undefined; + return noSymbolError(node.name) + || { exportNode: node, exportName: node.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol }; } - case 232 /* VariableStatement */: { + case 234 /* VariableStatement */: { var vs = exportNode; // Must be `export const x = something;`. if (!(vs.declarationList.flags & 2 /* Const */) || vs.declarationList.declarations.length !== 1) { @@ -143522,7 +148548,15 @@ var ts; if (!decl.initializer) return undefined; ts.Debug.assert(!wasDefault, "Can't have a default flag here"); - return ts.isIdentifier(decl.name) ? { exportNode: vs, exportName: decl.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; + return noSymbolError(decl.name) + || { exportNode: vs, exportName: decl.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol }; + } + case 268 /* ExportAssignment */: { + var node = exportNode; + if (node.isExportEquals) + return undefined; + return noSymbolError(node.expression) + || { exportNode: node, exportName: node.expression, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol }; } default: return undefined; @@ -143535,17 +148569,24 @@ var ts; function changeExport(exportingSourceFile, _a, changes, checker) { var wasDefault = _a.wasDefault, exportNode = _a.exportNode, exportName = _a.exportName; if (wasDefault) { - changes.delete(exportingSourceFile, ts.Debug.checkDefined(ts.findModifier(exportNode, 87 /* DefaultKeyword */), "Should find a default keyword in modifier list")); + if (ts.isExportAssignment(exportNode) && !exportNode.isExportEquals) { + var exp = exportNode.expression; + var spec = makeExportSpecifier(exp.text, exp.text); + changes.replaceNode(exportingSourceFile, exportNode, ts.factory.createExportDeclaration(/*decorators*/ undefined, /*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")); + } } else { - var exportKeyword = ts.Debug.checkDefined(ts.findModifier(exportNode, 92 /* ExportKeyword */), "Should find an export keyword in modifier list"); + var exportKeyword = ts.Debug.checkDefined(ts.findModifier(exportNode, 93 /* ExportKeyword */), "Should find an export keyword in modifier list"); switch (exportNode.kind) { - case 251 /* FunctionDeclaration */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.factory.createToken(87 /* DefaultKeyword */)); + case 253 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.factory.createToken(88 /* DefaultKeyword */)); break; - case 232 /* VariableStatement */: + case 234 /* 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) { @@ -143554,15 +148595,15 @@ var ts; break; } // falls through - case 255 /* EnumDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 256 /* ModuleDeclaration */: + case 257 /* EnumDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 258 /* 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.assertNever(exportNode, "Unexpected exportNode kind " + exportNode.kind); + ts.Debug.fail("Unexpected exportNode kind " + exportNode.kind); } } } @@ -143583,18 +148624,18 @@ var ts; function changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName) { var parent = ref.parent; switch (parent.kind) { - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: // `a.default` --> `a.foo` changes.replaceNode(importingSourceFile, ref, ts.factory.createIdentifier(exportName)); break; - case 265 /* ImportSpecifier */: - case 270 /* ExportSpecifier */: { + case 267 /* ImportSpecifier */: + case 272 /* 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 262 /* ImportClause */: { + case 264 /* ImportClause */: { var clause = parent; ts.Debug.assert(clause.name === ref, "Import clause name should match provided ref"); var spec = makeImportSpecifier(exportName, ref.text); @@ -143603,7 +148644,7 @@ var ts; // `import foo from "./a";` --> `import { foo } from "./a";` changes.replaceNode(importingSourceFile, ref, ts.factory.createNamedImports([spec])); } - else if (namedBindings.kind === 263 /* NamespaceImport */) { + else if (namedBindings.kind === 265 /* 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 */; @@ -143624,11 +148665,11 @@ var ts; function changeNamedToDefaultImport(importingSourceFile, ref, changes) { var parent = ref.parent; switch (parent.kind) { - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: // `a.foo` --> `a.default` changes.replaceNode(importingSourceFile, ref, ts.factory.createIdentifier("default")); break; - case 265 /* ImportSpecifier */: { + case 267 /* 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); @@ -143641,7 +148682,7 @@ var ts; } break; } - case 270 /* ExportSpecifier */: { + case 272 /* 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";` @@ -143687,7 +148728,7 @@ var ts; if (!info) return ts.emptyArray; if (!refactor.isRefactorErrorInfo(info)) { - var namespaceImport = info.kind === 263 /* NamespaceImport */; + var namespaceImport = info.kind === 265 /* NamespaceImport */; var action = namespaceImport ? namespaceToNamedAction : namedToNamespaceAction; return [{ name: refactorName, description: action.description, actions: [action] }]; } @@ -143729,7 +148770,7 @@ var ts; } function doChange(sourceFile, program, changes, toConvert) { var checker = program.getTypeChecker(); - if (toConvert.kind === 263 /* NamespaceImport */) { + if (toConvert.kind === 265 /* NamespaceImport */) { doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())); } else { @@ -143794,7 +148835,7 @@ var ts; }); var namespaceImportName = namespaceNameConflicts ? ts.getUniqueName(preferredName, sourceFile) : preferredName; var neededNamedImports = []; - var _loop_15 = function (element) { + var _loop_16 = 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); @@ -143813,7 +148854,7 @@ var ts; }; for (var _i = 0, _a = toConvert.elements; _i < _a.length; _i++) { var element = _a[_i]; - _loop_15(element); + _loop_16(element); } changes.replaceNode(sourceFile, toConvert, ts.factory.createNamespaceImport(ts.factory.createIdentifier(namespaceImportName))); if (neededNamedImports.length) { @@ -144130,27 +149171,27 @@ var ts; var lastDeclaration = signatureDecls[signatureDecls.length - 1]; var updated = lastDeclaration; switch (lastDeclaration.kind) { - case 164 /* MethodSignature */: { + case 166 /* MethodSignature */: { updated = ts.factory.updateMethodSignature(lastDeclaration, lastDeclaration.modifiers, lastDeclaration.name, lastDeclaration.questionToken, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 165 /* MethodDeclaration */: { + case 167 /* MethodDeclaration */: { updated = ts.factory.updateMethodDeclaration(lastDeclaration, lastDeclaration.decorators, lastDeclaration.modifiers, lastDeclaration.asteriskToken, lastDeclaration.name, lastDeclaration.questionToken, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type, lastDeclaration.body); break; } - case 169 /* CallSignature */: { + case 171 /* CallSignature */: { updated = ts.factory.updateCallSignature(lastDeclaration, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 166 /* Constructor */: { + case 168 /* Constructor */: { updated = ts.factory.updateConstructorDeclaration(lastDeclaration, lastDeclaration.decorators, lastDeclaration.modifiers, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.body); break; } - case 170 /* ConstructSignature */: { + case 172 /* ConstructSignature */: { updated = ts.factory.updateConstructSignature(lastDeclaration, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 251 /* FunctionDeclaration */: { + case 253 /* FunctionDeclaration */: { updated = ts.factory.updateFunctionDeclaration(lastDeclaration, lastDeclaration.decorators, lastDeclaration.modifiers, lastDeclaration.asteriskToken, lastDeclaration.name, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type, lastDeclaration.body); break; } @@ -144182,7 +149223,7 @@ var ts; } 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(128 /* AnyKeyword */)), p); + var result = ts.setTextRange(ts.factory.createNamedTupleMember(p.dotDotDotToken, p.name, p.questionToken, p.type || ts.factory.createKeywordTypeNode(129 /* AnyKeyword */)), p); var parameterDocComment = p.symbol && p.symbol.getDocumentationComment(checker); if (parameterDocComment) { var newComment = ts.displayPartsToString(parameterDocComment); @@ -144202,12 +149243,12 @@ var ts; } function isConvertableSignatureDeclaration(d) { switch (d.kind) { - case 164 /* MethodSignature */: - case 165 /* MethodDeclaration */: - case 169 /* CallSignature */: - case 166 /* Constructor */: - case 170 /* ConstructSignature */: - case 251 /* FunctionDeclaration */: + case 166 /* MethodSignature */: + case 167 /* MethodDeclaration */: + case 171 /* CallSignature */: + case 168 /* Constructor */: + case 172 /* ConstructSignature */: + case 253 /* FunctionDeclaration */: return true; } return false; @@ -144347,7 +149388,6 @@ var ts; }; } } - // Skip these since we don't have a way to report errors yet if (refactor.refactorKindBeginsWith(extractConstantAction.kind, requestedRefactor)) { if (constantExtraction.errors.length === 0) { // Don't issue refactorings with duplicated names. @@ -144479,24 +149519,28 @@ var ts; /** * getRangeToExtract takes a span inside a text file and returns either an expression or an array * of statements representing the minimum set of nodes needed to extract the entire span. This - * process may fail, in which case a set of errors is returned instead (these are currently - * not shown to the user, but can be used by us diagnostically) + * process may fail, in which case a set of errors is returned instead. These errors are shown to + * users if they have the provideRefactorNotApplicableReason option set. */ // exported only for tests - function getRangeToExtract(sourceFile, span, considerEmptySpans) { - if (considerEmptySpans === void 0) { considerEmptySpans = true; } + function getRangeToExtract(sourceFile, span, invoked) { + if (invoked === void 0) { invoked = true; } var length = span.length; - if (length === 0 && !considerEmptySpans) { + if (length === 0 && !invoked) { return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractEmpty)] }; } - var cursorRequest = length === 0 && considerEmptySpans; + var cursorRequest = length === 0 && invoked; + var startToken = ts.findFirstNonJsxWhitespaceToken(sourceFile, span.start); + var endToken = ts.findTokenOnLeftOfPosition(sourceFile, ts.textSpanEnd(span)); + /* If the refactoring command is invoked through a keyboard action it's safe to assume that the user is actively looking for + refactoring actions at the span location. As they may not know the exact range that will trigger a refactoring, we expand the + searched span to cover a real node range making it more likely that something useful will show up. */ + var adjustedSpan = startToken && endToken && invoked ? getAdjustedSpanFromNodes(startToken, endToken, sourceFile) : span; // Walk up starting from the the start position until we find a non-SourceFile node that subsumes the selected span. // This may fail (e.g. you select two statements in the root of a source file) - var startToken = ts.getTokenAtPosition(sourceFile, span.start); - var start = cursorRequest ? getExtractableParent(startToken) : ts.getParentNodeInSpan(startToken, sourceFile, span); + var start = cursorRequest ? getExtractableParent(startToken) : ts.getParentNodeInSpan(startToken, sourceFile, adjustedSpan); // Do the same for the ending position - var endToken = ts.findTokenOnLeftOfPosition(sourceFile, ts.textSpanEnd(span)); - var end = cursorRequest ? start : ts.getParentNodeInSpan(endToken, sourceFile, span); + var end = cursorRequest ? start : ts.getParentNodeInSpan(endToken, sourceFile, adjustedSpan); var declarations = []; // We'll modify these flags as we walk the tree to collect data // about what things need to be done as part of the extraction. @@ -144505,6 +149549,9 @@ var ts; // cannot find either start or end node return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] }; } + if (ts.isJSDoc(start)) { + return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractJSDoc)] }; + } if (start.parent !== end.parent) { // start and end nodes belong to different subtrees return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] }; @@ -144539,9 +149586,6 @@ var ts; } return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations } }; } - if (ts.isJSDoc(start)) { - return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractJSDoc)] }; - } if (ts.isReturnStatement(start) && !start.expression) { // Makes no sense to extract an expression-less return statement. return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] }; @@ -144594,20 +149638,20 @@ var ts; function checkForStaticContext(nodeToCheck, containingClass) { var current = nodeToCheck; while (current !== containingClass) { - if (current.kind === 163 /* PropertyDeclaration */) { + if (current.kind === 165 /* PropertyDeclaration */) { if (ts.hasSyntacticModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 160 /* Parameter */) { + else if (current.kind === 162 /* Parameter */) { var ctorOrMethod = ts.getContainingFunction(current); - if (ctorOrMethod.kind === 166 /* Constructor */) { + if (ctorOrMethod.kind === 168 /* Constructor */) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 165 /* MethodDeclaration */) { + else if (current.kind === 167 /* MethodDeclaration */) { if (ts.hasSyntacticModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } @@ -144650,7 +149694,7 @@ var ts; return true; } if (ts.isDeclaration(node)) { - var declaringNode = (node.kind === 249 /* VariableDeclaration */) ? node.parent.parent : node; + var declaringNode = (node.kind === 251 /* VariableDeclaration */) ? node.parent.parent : node; if (ts.hasSyntacticModifier(declaringNode, 1 /* 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`! @@ -144662,16 +149706,16 @@ var ts; } // Some things can't be extracted in certain situations switch (node.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractImport)); return true; - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractExportedEntity)); return true; - case 105 /* SuperKeyword */: + case 106 /* 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 === 203 /* CallExpression */) { + if (node.parent.kind === 205 /* CallExpression */) { // Super constructor call var containingClass_1 = ts.getContainingClass(node); // TODO:GH#18217 if (containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) { @@ -144683,7 +149727,7 @@ var ts; rangeFacts |= RangeFacts.UsesThis; } break; - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: // check if arrow function uses this ts.forEachChild(node, function check(n) { if (ts.isThis(n)) { @@ -144697,39 +149741,39 @@ var ts; } }); // falls through - case 252 /* ClassDeclaration */: - case 251 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: + case 253 /* 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 221 /* ClassExpression */: - case 208 /* FunctionExpression */: - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 223 /* ClassExpression */: + case 210 /* FunctionExpression */: + case 167 /* MethodDeclaration */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: // do not dive into functions or classes return false; } var savedPermittedJumps = permittedJumps; switch (node.kind) { - case 234 /* IfStatement */: + case 236 /* IfStatement */: permittedJumps = 0 /* None */; break; - case 247 /* TryStatement */: + case 249 /* TryStatement */: // forbid all jumps inside try blocks permittedJumps = 0 /* None */; break; - case 230 /* Block */: - if (node.parent && node.parent.kind === 247 /* TryStatement */ && node.parent.finallyBlock === node) { + case 232 /* Block */: + if (node.parent && node.parent.kind === 249 /* TryStatement */ && node.parent.finallyBlock === node) { // allow unconditional returns from finally blocks permittedJumps = 4 /* Return */; } break; - case 285 /* DefaultClause */: - case 284 /* CaseClause */: + case 287 /* DefaultClause */: + case 286 /* CaseClause */: // allow unlabeled break inside case clauses permittedJumps |= 1 /* Break */; break; @@ -144741,19 +149785,19 @@ var ts; break; } switch (node.kind) { - case 187 /* ThisType */: - case 107 /* ThisKeyword */: + case 189 /* ThisType */: + case 108 /* ThisKeyword */: rangeFacts |= RangeFacts.UsesThis; break; - case 245 /* LabeledStatement */: { + case 247 /* LabeledStatement */: { var label = node.label; (seenLabels || (seenLabels = [])).push(label.escapedText); ts.forEachChild(node, visit); seenLabels.pop(); break; } - case 241 /* BreakStatement */: - case 240 /* ContinueStatement */: { + case 243 /* BreakStatement */: + case 242 /* ContinueStatement */: { var label = node.label; if (label) { if (!ts.contains(seenLabels, label.escapedText)) { @@ -144762,20 +149806,20 @@ var ts; } } else { - if (!(permittedJumps & (node.kind === 241 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { + if (!(permittedJumps & (node.kind === 243 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { // attempt to break or continue in a forbidden context (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractRangeContainingConditionalBreakOrContinueStatements)); } } break; } - case 213 /* AwaitExpression */: + case 215 /* AwaitExpression */: rangeFacts |= RangeFacts.IsAsyncFunction; break; - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: rangeFacts |= RangeFacts.IsGenerator; break; - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: if (permittedJumps & 4 /* Return */) { rangeFacts |= RangeFacts.HasReturn; } @@ -144792,6 +149836,18 @@ var ts; } } extractSymbol.getRangeToExtract = getRangeToExtract; + /** + * Includes the final semicolon so that the span covers statements in cases where it would otherwise + * only cover the declaration list. + */ + function getAdjustedSpanFromNodes(startNode, endNode, sourceFile) { + var start = startNode.getStart(sourceFile); + var end = endNode.getEnd(); + if (sourceFile.text.charCodeAt(end) === 59 /* semicolon */) { + end++; + } + return { start: start, length: end - start }; + } function getStatementOrExpressionRange(node) { if (ts.isStatement(node)) { return [node]; @@ -144829,7 +149885,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 === 160 /* Parameter */) { + if (current.kind === 162 /* 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; } @@ -144840,7 +149896,7 @@ var ts; // * Module/namespace or source file if (isScope(current)) { scopes.push(current); - if (current.kind === 297 /* SourceFile */) { + if (current.kind === 299 /* SourceFile */) { return scopes; } } @@ -144930,32 +149986,32 @@ var ts; } function getDescriptionForFunctionLikeDeclaration(scope) { switch (scope.kind) { - case 166 /* Constructor */: + case 168 /* Constructor */: return "constructor"; - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: return scope.name ? "function '" + scope.name.text + "'" : ts.ANONYMOUS; - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return "arrow function"; - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: return "method '" + scope.name.getText() + "'"; - case 167 /* GetAccessor */: + case 169 /* GetAccessor */: return "'get " + scope.name.getText() + "'"; - case 168 /* SetAccessor */: + case 170 /* SetAccessor */: return "'set " + scope.name.getText() + "'"; default: throw ts.Debug.assertNever(scope, "Unexpected scope kind " + scope.kind); } } function getDescriptionForClassLikeDeclaration(scope) { - return scope.kind === 252 /* ClassDeclaration */ + return scope.kind === 254 /* ClassDeclaration */ ? scope.name ? "class '" + scope.name.text + "'" : "anonymous class declaration" : scope.name ? "class expression '" + scope.name.text + "'" : "anonymous class expression"; } function getDescriptionForModuleLikeDeclaration(scope) { - return scope.kind === 257 /* ModuleBlock */ + return scope.kind === 259 /* ModuleBlock */ ? "namespace '" + scope.parent.name.getText() + "'" : scope.externalModuleIndicator ? 0 /* Module */ : 1 /* Global */; } @@ -145023,12 +150079,12 @@ var ts; var newFunction; if (ts.isClassLike(scope)) { // always create private method in TypeScript files - var modifiers = isJS ? [] : [ts.factory.createModifier(120 /* PrivateKeyword */)]; + var modifiers = isJS ? [] : [ts.factory.createModifier(121 /* PrivateKeyword */)]; if (range.facts & RangeFacts.InStaticRegion) { - modifiers.push(ts.factory.createModifier(123 /* StaticKeyword */)); + modifiers.push(ts.factory.createModifier(124 /* StaticKeyword */)); } if (range.facts & RangeFacts.IsAsyncFunction) { - modifiers.push(ts.factory.createModifier(129 /* AsyncKeyword */)); + modifiers.push(ts.factory.createModifier(130 /* AsyncKeyword */)); } newFunction = ts.factory.createMethodDeclaration( /*decorators*/ undefined, modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* AsteriskToken */) : undefined, functionName, @@ -145036,7 +150092,7 @@ var ts; } else { newFunction = ts.factory.createFunctionDeclaration( - /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.factory.createToken(129 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body); + /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.factory.createToken(130 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* 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; @@ -145181,9 +150237,9 @@ var ts; while (ts.isParenthesizedTypeNode(withoutParens)) { withoutParens = withoutParens.type; } - return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 150 /* UndefinedKeyword */; }) + return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 151 /* UndefinedKeyword */; }) ? clone - : ts.factory.createUnionTypeNode([clone, ts.factory.createKeywordTypeNode(150 /* UndefinedKeyword */)]); + : ts.factory.createUnionTypeNode([clone, ts.factory.createKeywordTypeNode(151 /* UndefinedKeyword */)]); } } /** @@ -145208,11 +150264,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(120 /* PrivateKeyword */)); + modifiers.push(ts.factory.createModifier(121 /* PrivateKeyword */)); if (rangeFacts & RangeFacts.InStaticRegion) { - modifiers.push(ts.factory.createModifier(123 /* StaticKeyword */)); + modifiers.push(ts.factory.createModifier(124 /* StaticKeyword */)); } - modifiers.push(ts.factory.createModifier(142 /* ReadonlyKeyword */)); + modifiers.push(ts.factory.createModifier(143 /* ReadonlyKeyword */)); var newVariable = ts.factory.createPropertyDeclaration( /*decorators*/ undefined, modifiers, localNameText, /*questionToken*/ undefined, variableType, initializer); @@ -145244,7 +150300,7 @@ var ts; var localReference = ts.factory.createIdentifier(localNameText); changeTracker.replaceNode(context.file, node, localReference); } - else if (node.parent.kind === 233 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { + else if (node.parent.kind === 235 /* 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( @@ -145263,7 +150319,7 @@ var ts; changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariableStatement, /*blankLineBetween*/ false); } // Consume - if (node.parent.kind === 233 /* ExpressionStatement */) { + if (node.parent.kind === 235 /* ExpressionStatement */) { // If the parent is an expression statement, delete it. changeTracker.delete(context.file, node.parent); } @@ -145590,7 +150646,7 @@ var ts; var scope = scopes_1[_i]; usagesPerScope.push({ usages: new ts.Map(), typeParameterUsages: new ts.Map(), substitutions: new ts.Map() }); substitutionsPerScope.push(new ts.Map()); - functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 251 /* FunctionDeclaration */ + functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 253 /* FunctionDeclaration */ ? [ts.createDiagnosticForNode(scope, Messages.cannotExtractToOtherFunctionLike)] : []); var constantErrors = []; @@ -145653,7 +150709,7 @@ var ts; : ts.getEnclosingBlockScopeContainer(scopes[0]); ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations); } - var _loop_16 = function (i) { + var _loop_17 = 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 @@ -145693,7 +150749,7 @@ var ts; } }; for (var i = 0; i < scopes.length; i++) { - _loop_16(i); + _loop_17(i); } return { target: target, usagesPerScope: usagesPerScope, functionErrorsPerScope: functionErrorsPerScope, constantErrorsPerScope: constantErrorsPerScope, exposedVariableDeclarations: exposedVariableDeclarations }; function isInGenericContext(node) { @@ -145909,37 +150965,37 @@ var ts; function isExtractableExpression(node) { var parent = node.parent; switch (parent.kind) { - case 291 /* EnumMember */: + case 293 /* EnumMember */: return false; } switch (node.kind) { case 10 /* StringLiteral */: - return parent.kind !== 261 /* ImportDeclaration */ && - parent.kind !== 265 /* ImportSpecifier */; - case 220 /* SpreadElement */: - case 196 /* ObjectBindingPattern */: - case 198 /* BindingElement */: + return parent.kind !== 263 /* ImportDeclaration */ && + parent.kind !== 267 /* ImportSpecifier */; + case 222 /* SpreadElement */: + case 198 /* ObjectBindingPattern */: + case 200 /* BindingElement */: return false; - case 78 /* Identifier */: - return parent.kind !== 198 /* BindingElement */ && - parent.kind !== 265 /* ImportSpecifier */ && - parent.kind !== 270 /* ExportSpecifier */; + case 79 /* Identifier */: + return parent.kind !== 200 /* BindingElement */ && + parent.kind !== 267 /* ImportSpecifier */ && + parent.kind !== 272 /* ExportSpecifier */; } return true; } function isBlockLike(node) { switch (node.kind) { - case 230 /* Block */: - case 297 /* SourceFile */: - case 257 /* ModuleBlock */: - case 284 /* CaseClause */: + case 232 /* Block */: + case 299 /* SourceFile */: + case 259 /* ModuleBlock */: + case 286 /* CaseClause */: return true; default: return false; } } function isInJSXContent(node) { - return (ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node) || ts.isJsxFragment(node)) && ts.isJsxElement(node.parent); + return (ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node) || ts.isJsxFragment(node)) && (ts.isJsxElement(node.parent) || ts.isJsxFragment(node.parent)); } })(extractSymbol = refactor.extractSymbol || (refactor.extractSymbol = {})); })(refactor = ts.refactor || (ts.refactor = {})); @@ -146074,7 +151130,7 @@ var ts; if (ts.isTypeReferenceNode(node)) { if (ts.isIdentifier(node.typeName)) { var symbol = checker.resolveName(node.typeName.text, node.typeName, 262144 /* TypeParameter */, /* excludeGlobals */ true); - if (symbol) { + if (symbol === null || symbol === void 0 ? void 0 : symbol.declarations) { var declaration = ts.cast(ts.first(symbol.declarations), ts.isTypeParameterDeclaration); if (rangeContainsSkipTrivia(statement, declaration, file) && !rangeContainsSkipTrivia(selection, declaration, file)) { ts.pushIfUnique(result, declaration); @@ -146097,7 +151153,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); - if (symbol && rangeContainsSkipTrivia(statement, symbol.valueDeclaration, file) && !rangeContainsSkipTrivia(selection, symbol.valueDeclaration, file)) { + if ((symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration) && rangeContainsSkipTrivia(statement, symbol.valueDeclaration, file) && !rangeContainsSkipTrivia(selection, symbol.valueDeclaration, file)) { return true; } } @@ -146317,11 +151373,11 @@ var ts; } function isPureImport(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return true; - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return !ts.hasSyntacticModifier(node, 1 /* Export */); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return node.declarationList.declarations.every(function (d) { return !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); }); default: return false; @@ -146382,10 +151438,10 @@ var ts; } function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) { var checker = program.getTypeChecker(); - var _loop_17 = function (sourceFile) { + var _loop_18 = function (sourceFile) { if (sourceFile === oldFile) return "continue"; - var _loop_18 = function (statement) { + var _loop_19 = function (statement) { forEachImportInStatement(statement, function (importNode) { if (checker.getSymbolAtLocation(moduleSpecifierFromImport(importNode)) !== oldFile.symbol) return; @@ -146407,22 +151463,22 @@ var ts; }; for (var _b = 0, _c = sourceFile.statements; _b < _c.length; _b++) { var statement = _c[_b]; - _loop_18(statement); + _loop_19(statement); } }; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; - _loop_17(sourceFile); + _loop_18(sourceFile); } } function getNamespaceLikeImport(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: - return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 263 /* NamespaceImport */ ? + case 263 /* ImportDeclaration */: + return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 265 /* NamespaceImport */ ? node.importClause.namedBindings.name : undefined; - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return node.name; - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return ts.tryCast(node.name, ts.isIdentifier); default: return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); @@ -146453,20 +151509,20 @@ var ts; var newNamespaceId = ts.factory.createIdentifier(newNamespaceName); var newModuleString = ts.factory.createStringLiteral(newModuleSpecifier); switch (node.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, ts.factory.createNamespaceImport(newNamespaceId)), newModuleString); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return ts.factory.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, newNamespaceId, ts.factory.createExternalModuleReference(newModuleString)); - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return ts.factory.createVariableDeclaration(newNamespaceId, /*exclamationToken*/ undefined, /*type*/ undefined, createRequireCall(newModuleString)); default: return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); } } function moduleSpecifierFromImport(i) { - return (i.kind === 261 /* ImportDeclaration */ ? i.moduleSpecifier - : i.kind === 260 /* ImportEqualsDeclaration */ ? i.moduleReference.expression + return (i.kind === 263 /* ImportDeclaration */ ? i.moduleSpecifier + : i.kind === 262 /* ImportEqualsDeclaration */ ? i.moduleReference.expression : i.initializer.arguments[0]); } function forEachImportInStatement(statement, cb) { @@ -146536,15 +151592,15 @@ var ts; } function deleteUnusedImports(sourceFile, importDecl, changes, isUnused) { switch (importDecl.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused); break; - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: if (isUnused(importDecl.name)) { changes.delete(sourceFile, importDecl); } break; - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: deleteUnusedImportsInVariableDeclaration(sourceFile, importDecl, changes, isUnused); break; default: @@ -146557,7 +151613,7 @@ var ts; var _a = importDecl.importClause, name = _a.name, namedBindings = _a.namedBindings; var defaultUnused = !name || isUnused(name); var namedBindingsUnused = !namedBindings || - (namedBindings.kind === 263 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); + (namedBindings.kind === 265 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); if (defaultUnused && namedBindingsUnused) { changes.delete(sourceFile, importDecl); } @@ -146569,7 +151625,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 === 264 /* NamedImports */) { + else if (namedBindings.kind === 266 /* NamedImports */) { for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) { var element = _b[_i]; if (isUnused(element.name)) @@ -146582,14 +151638,14 @@ var ts; function deleteUnusedImportsInVariableDeclaration(sourceFile, varDecl, changes, isUnused) { var name = varDecl.name; switch (name.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: if (isUnused(name)) { changes.delete(sourceFile, name); } break; - case 197 /* ArrayBindingPattern */: + case 199 /* ArrayBindingPattern */: break; - case 196 /* ObjectBindingPattern */: + case 198 /* 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); } @@ -146617,6 +151673,9 @@ var ts; var oldFileNamedImports = []; var markSeenTop = ts.nodeSeenTracker(); // Needed because multiple declarations may appear in `const x = 0, y = 1;`. newFileImportsFromOldFile.forEach(function (symbol) { + if (!symbol.declarations) { + return; + } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; if (!isTopLevelDeclaration(decl)) @@ -146716,14 +151775,14 @@ var ts; // Below should all be utilities function isInImport(decl) { switch (decl.kind) { - case 260 /* ImportEqualsDeclaration */: - case 265 /* ImportSpecifier */: - case 262 /* ImportClause */: - case 263 /* NamespaceImport */: + case 262 /* ImportEqualsDeclaration */: + case 267 /* ImportSpecifier */: + case 264 /* ImportClause */: + case 265 /* NamespaceImport */: return true; - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return isVariableDeclarationInImport(decl); - case 198 /* BindingElement */: + case 200 /* BindingElement */: return ts.isVariableDeclaration(decl.parent.parent) && isVariableDeclarationInImport(decl.parent.parent); default: return false; @@ -146735,7 +151794,7 @@ var ts; } function filterImport(i, moduleSpecifier, keep) { switch (i.kind) { - case 261 /* ImportDeclaration */: { + case 263 /* ImportDeclaration */: { var clause = i.importClause; if (!clause) return undefined; @@ -146745,9 +151804,9 @@ var ts; ? ts.factory.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, defaultImport, namedBindings), moduleSpecifier) : undefined; } - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return keep(i.name) ? i : undefined; - case 249 /* VariableDeclaration */: { + case 251 /* VariableDeclaration */: { var name = filterBindingName(i.name, keep); return name ? makeVariableStatement(name, i.type, createRequireCall(moduleSpecifier), i.parent.flags) : undefined; } @@ -146756,7 +151815,7 @@ var ts; } } function filterNamedBindings(namedBindings, keep) { - if (namedBindings.kind === 263 /* NamespaceImport */) { + if (namedBindings.kind === 265 /* NamespaceImport */) { return keep(namedBindings.name) ? namedBindings : undefined; } else { @@ -146766,11 +151825,11 @@ var ts; } function filterBindingName(name, keep) { switch (name.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return keep(name) ? name : undefined; - case 197 /* ArrayBindingPattern */: + case 199 /* ArrayBindingPattern */: return name; - case 196 /* ObjectBindingPattern */: { + case 198 /* 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; @@ -146827,13 +151886,13 @@ var ts; } function isNonVariableTopLevelDeclaration(node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 252 /* ClassDeclaration */: - case 256 /* ModuleDeclaration */: - case 255 /* EnumDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 253 /* InterfaceDeclaration */: - case 260 /* ImportEqualsDeclaration */: + case 253 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: + case 258 /* ModuleDeclaration */: + case 257 /* EnumDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 255 /* InterfaceDeclaration */: + case 262 /* ImportEqualsDeclaration */: return true; default: return false; @@ -146841,17 +151900,17 @@ var ts; } function forEachTopLevelDeclaration(statement, cb) { switch (statement.kind) { - case 251 /* FunctionDeclaration */: - case 252 /* ClassDeclaration */: - case 256 /* ModuleDeclaration */: - case 255 /* EnumDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 253 /* InterfaceDeclaration */: - case 260 /* ImportEqualsDeclaration */: + case 253 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: + case 258 /* ModuleDeclaration */: + case 257 /* EnumDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 255 /* InterfaceDeclaration */: + case 262 /* ImportEqualsDeclaration */: return cb(statement); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return ts.firstDefined(statement.declarationList.declarations, function (decl) { return forEachTopLevelDeclarationInBindingName(decl.name, cb); }); - case 233 /* ExpressionStatement */: { + case 235 /* ExpressionStatement */: { var expression = statement.expression; return ts.isBinaryExpression(expression) && ts.getAssignmentDeclarationKind(expression) === 1 /* ExportsProperty */ ? cb(statement) @@ -146861,10 +151920,10 @@ var ts; } function forEachTopLevelDeclarationInBindingName(name, cb) { switch (name.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return cb(ts.cast(name.parent, function (x) { return ts.isVariableDeclaration(x) || ts.isBindingElement(x); })); - case 197 /* ArrayBindingPattern */: - case 196 /* ObjectBindingPattern */: + case 199 /* ArrayBindingPattern */: + case 198 /* 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); @@ -146875,9 +151934,9 @@ var ts; } function getTopLevelDeclarationStatement(d) { switch (d.kind) { - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return d.parent.parent; - case 198 /* BindingElement */: + case 200 /* BindingElement */: return getTopLevelDeclarationStatement(ts.cast(d.parent.parent, function (p) { return ts.isVariableDeclaration(p) || ts.isBindingElement(p); })); default: return d; @@ -146908,25 +151967,25 @@ var ts; return useEs6Exports ? [addEs6Export(decl)] : addCommonjsExport(decl); } function addEs6Export(d) { - var modifiers = ts.concatenate([ts.factory.createModifier(92 /* ExportKeyword */)], d.modifiers); + var modifiers = ts.concatenate([ts.factory.createModifier(93 /* ExportKeyword */)], d.modifiers); switch (d.kind) { - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return ts.factory.updateFunctionDeclaration(d, d.decorators, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body); - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: return ts.factory.updateClassDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return ts.factory.updateVariableStatement(d, modifiers, d.declarationList); - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return ts.factory.updateModuleDeclaration(d, d.decorators, modifiers, d.name, d.body); - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: return ts.factory.updateEnumDeclaration(d, d.decorators, modifiers, d.name, d.members); - case 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: return ts.factory.updateTypeAliasDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.type); - case 253 /* InterfaceDeclaration */: + case 255 /* InterfaceDeclaration */: return ts.factory.updateInterfaceDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return ts.factory.updateImportEqualsDeclaration(d, d.decorators, modifiers, d.isTypeOnly, d.name, d.moduleReference); - case 233 /* ExpressionStatement */: + case 235 /* 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); @@ -146937,18 +151996,18 @@ var ts; } function getNamesToExportInCommonJS(decl) { switch (decl.kind) { - case 251 /* FunctionDeclaration */: - case 252 /* ClassDeclaration */: + case 253 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: return [decl.name.text]; // TODO: GH#18217 - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return ts.mapDefined(decl.declarationList.declarations, function (d) { return ts.isIdentifier(d.name) ? d.name.text : undefined; }); - case 256 /* ModuleDeclaration */: - case 255 /* EnumDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 253 /* InterfaceDeclaration */: - case 260 /* ImportEqualsDeclaration */: + case 258 /* ModuleDeclaration */: + case 257 /* EnumDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 255 /* InterfaceDeclaration */: + case 262 /* ImportEqualsDeclaration */: return ts.emptyArray; - case 233 /* ExpressionStatement */: + case 235 /* 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); @@ -146956,7 +152015,7 @@ var ts; } /** 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)), 62 /* EqualsToken */, ts.factory.createIdentifier(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))); } })(refactor = ts.refactor || (ts.refactor = {})); })(ts || (ts = {})); @@ -147117,13 +152176,13 @@ var ts; return { edits: [] }; // TODO: GH#30113 } function doChange(sourceFile, program, host, changes, functionDeclaration, groupedReferences) { - var newParamDeclaration = ts.map(createNewParameters(functionDeclaration, program, host), function (param) { return ts.getSynthesizedDeepClone(param); }); - changes.replaceNodeRangeWithNodes(sourceFile, ts.first(functionDeclaration.parameters), ts.last(functionDeclaration.parameters), newParamDeclaration, { joiner: ", ", - // indentation is set to 0 because otherwise the object parameter will be indented if there is a `this` parameter - indentation: 0, - leadingTriviaOption: ts.textChanges.LeadingTriviaOption.IncludeAll, - trailingTriviaOption: ts.textChanges.TrailingTriviaOption.Include - }); + var signature = groupedReferences.signature; + var newFunctionDeclarationParams = ts.map(createNewParameters(functionDeclaration, program, host), function (param) { return ts.getSynthesizedDeepClone(param); }); + if (signature) { + var newSignatureParams = ts.map(createNewParameters(signature, program, host), function (param) { return ts.getSynthesizedDeepClone(param); }); + replaceParameters(signature, newSignatureParams); + } + replaceParameters(functionDeclaration, newFunctionDeclarationParams); var functionCalls = ts.sortAndDeduplicate(groupedReferences.functionCalls, /*comparer*/ function (a, b) { return ts.compareValues(a.pos, b.pos); }); for (var _i = 0, functionCalls_1 = functionCalls; _i < functionCalls_1.length; _i++) { var call = functionCalls_1[_i]; @@ -147132,6 +152191,15 @@ var ts; changes.replaceNodeRange(ts.getSourceFileOfNode(call), ts.first(call.arguments), ts.last(call.arguments), newArgument, { leadingTriviaOption: ts.textChanges.LeadingTriviaOption.IncludeAll, trailingTriviaOption: ts.textChanges.TrailingTriviaOption.Include }); } } + function replaceParameters(declarationOrSignature, parameterDeclarations) { + changes.replaceNodeRangeWithNodes(sourceFile, ts.first(declarationOrSignature.parameters), ts.last(declarationOrSignature.parameters), parameterDeclarations, { + joiner: ", ", + // indentation is set to 0 because otherwise the object parameter will be indented if there is a `this` parameter + indentation: 0, + leadingTriviaOption: ts.textChanges.LeadingTriviaOption.IncludeAll, + trailingTriviaOption: ts.textChanges.TrailingTriviaOption.Include + }); + } } function getGroupedReferences(functionDeclaration, program, cancellationToken) { var functionNames = getFunctionNames(functionDeclaration); @@ -147150,12 +152218,38 @@ var ts; var functionSymbols = ts.map(functionNames, getSymbolTargetAtLocation); var classSymbols = ts.map(classNames, getSymbolTargetAtLocation); var isConstructor = ts.isConstructorDeclaration(functionDeclaration); + 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 !== 1 /* Node */) { + if (entry.kind === 0 /* Span */) { groupedReferences.valid = false; continue; } + /* Declarations in object literals may be implementations of method signatures which have a different symbol from the declaration + For example: + interface IFoo { m(a: number): void } + const foo: IFoo = { m(a: number): void {} } + In these cases we get the symbol for the signature from the contextual type. + */ + if (ts.contains(contextualSymbols, getSymbolTargetAtLocation(entry.node))) { + if (isValidMethodSignature(entry.node.parent)) { + groupedReferences.signature = entry.node.parent; + continue; + } + var call = entryToFunctionCall(entry); + if (call) { + groupedReferences.functionCalls.push(call); + continue; + } + } + var contextualSymbol = getSymbolForContextualType(entry.node, checker); + if (contextualSymbol && ts.contains(contextualSymbols, contextualSymbol)) { + var decl = entryToDeclaration(entry); + if (decl) { + groupedReferences.declarations.push(decl); + continue; + } + } /* We compare symbols because in some cases find all references wil return a reference that may or may not be to the refactored function. Example from the refactorConvertParamsToDestructuredObject_methodCallUnion.ts test: class A { foo(a: number, b: number) { return a + b; } } @@ -147218,6 +152312,19 @@ var ts; return symbol && ts.getSymbolTarget(symbol, checker); } } + /** + * Gets the symbol for the contextual type of the node if it is not a union or intersection. + */ + function getSymbolForContextualType(node, checker) { + var element = ts.getContainingObjectLiteralElement(node); + 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 */)) { + return symbol; + } + } + } function entryToImportOrExport(entry) { var node = entry.node; if (ts.isImportSpecifier(node.parent) @@ -147243,15 +152350,15 @@ var ts; var parent = functionReference.parent; switch (parent.kind) { // foo(...) or super(...) or new Foo(...) - case 203 /* CallExpression */: - case 204 /* NewExpression */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: var callOrNewExpression = ts.tryCast(parent, ts.isCallOrNewExpression); if (callOrNewExpression && callOrNewExpression.expression === functionReference) { return callOrNewExpression; } break; // x.foo(...) - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.parent && propertyAccessExpression.name === functionReference) { var callOrNewExpression_1 = ts.tryCast(propertyAccessExpression.parent, ts.isCallOrNewExpression); @@ -147261,7 +152368,7 @@ var ts; } break; // x["foo"](...) - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.parent && elementAccessExpression.argumentExpression === functionReference) { var callOrNewExpression_2 = ts.tryCast(elementAccessExpression.parent, ts.isCallOrNewExpression); @@ -147280,14 +152387,14 @@ var ts; var parent = reference.parent; switch (parent.kind) { // `C.foo` - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.expression === reference) { return propertyAccessExpression; } break; // `C["foo"]` - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.expression === reference) { return elementAccessExpression; @@ -147325,15 +152432,24 @@ var ts; } return false; } + function isValidMethodSignature(node) { + return ts.isMethodSignature(node) && (ts.isInterfaceDeclaration(node.parent) || ts.isTypeLiteralNode(node.parent)); + } function isValidFunctionDeclaration(functionDeclaration, checker) { + var _a; if (!isValidParameterNodeArray(functionDeclaration.parameters, checker)) return false; switch (functionDeclaration.kind) { - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return hasNameOrDefault(functionDeclaration) && isSingleImplementation(functionDeclaration, checker); - case 165 /* MethodDeclaration */: + case 167 /* 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 166 /* Constructor */: + case 168 /* Constructor */: if (ts.isClassDeclaration(functionDeclaration.parent)) { return hasNameOrDefault(functionDeclaration.parent) && isSingleImplementation(functionDeclaration, checker); } @@ -147341,8 +152457,8 @@ var ts; return isValidVariableDeclaration(functionDeclaration.parent.parent) && isSingleImplementation(functionDeclaration, checker); } - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return isValidVariableDeclaration(functionDeclaration.parent); } return false; @@ -147352,7 +152468,7 @@ var ts; } function hasNameOrDefault(functionOrClassDeclaration) { if (!functionOrClassDeclaration.name) { - var defaultKeyword = ts.findModifier(functionOrClassDeclaration, 87 /* DefaultKeyword */); + var defaultKeyword = ts.findModifier(functionOrClassDeclaration, 88 /* DefaultKeyword */); return !!defaultKeyword; } return true; @@ -147492,15 +152608,15 @@ var ts; } function getClassNames(constructorDeclaration) { switch (constructorDeclaration.parent.kind) { - case 252 /* ClassDeclaration */: + case 254 /* 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, 87 /* DefaultKeyword */), "Nameless class declaration should be a default export"); + var defaultModifier = ts.Debug.checkDefined(ts.findModifier(classDeclaration, 88 /* DefaultKeyword */), "Nameless class declaration should be a default export"); return [defaultModifier]; - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: var classExpression = constructorDeclaration.parent; var variableDeclaration = constructorDeclaration.parent.parent; var className = classExpression.name; @@ -147511,25 +152627,25 @@ var ts; } function getFunctionNames(functionDeclaration) { switch (functionDeclaration.kind) { - case 251 /* FunctionDeclaration */: + case 253 /* 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, 87 /* DefaultKeyword */), "Nameless function declaration should be a default export"); + var defaultModifier = ts.Debug.checkDefined(ts.findModifier(functionDeclaration, 88 /* DefaultKeyword */), "Nameless function declaration should be a default export"); return [defaultModifier]; - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: return [functionDeclaration.name]; - case 166 /* Constructor */: - var ctrKeyword = ts.Debug.checkDefined(ts.findChildOfKind(functionDeclaration, 132 /* ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); - if (functionDeclaration.parent.kind === 221 /* ClassExpression */) { + case 168 /* Constructor */: + var ctrKeyword = ts.Debug.checkDefined(ts.findChildOfKind(functionDeclaration, 133 /* ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); + if (functionDeclaration.parent.kind === 223 /* ClassExpression */) { var variableDeclaration = functionDeclaration.parent.parent; return [variableDeclaration.name, ctrKeyword]; } return [ctrKeyword]; - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return [functionDeclaration.parent.name]; - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: if (functionDeclaration.name) return [functionDeclaration.name, functionDeclaration.parent.name]; return [functionDeclaration.parent.name]; @@ -147615,16 +152731,16 @@ var ts; } } function isNotEqualsOperator(node) { - return node.operatorToken.kind !== 62 /* EqualsToken */; + return node.operatorToken.kind !== 63 /* EqualsToken */; } function getParentBinaryExpression(expr) { var container = ts.findAncestor(expr.parent, function (n) { switch (n.kind) { - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: return false; - case 218 /* TemplateExpression */: - case 216 /* BinaryExpression */: + case 220 /* TemplateExpression */: + case 218 /* BinaryExpression */: return !(ts.isBinaryExpression(n.parent) && isNotEqualsOperator(n.parent)); default: return "quit"; @@ -147701,7 +152817,7 @@ var ts; var templateSpans = []; var templateHead = ts.factory.createTemplateHead(headText); copyCommentFromStringLiterals(headIndexes, templateHead); - var _loop_19 = function (i) { + var _loop_20 = function (i) { var currentNode = getExpressionFromParenthesesOrExpression(nodes[i]); copyOperatorComments(i, currentNode); var _c = concatConsecutiveString(i + 1, nodes), newIndex = _c[0], subsequentText = _c[1], stringIndexes = _c[2]; @@ -147725,7 +152841,7 @@ var ts; }; var out_i_1; for (var i = begin; i < nodes.length; i++) { - _loop_19(i); + _loop_20(i); i = out_i_1; } return ts.factory.createTemplateExpression(templateHead, templateSpans); @@ -147925,7 +153041,9 @@ var ts; var body = convertToBlock(func.body); var variableDeclaration = variableInfo.variableDeclaration, variableDeclarationList = variableInfo.variableDeclarationList, statement = variableInfo.statement, name = variableInfo.name; ts.suppressLeadingTrivia(statement); - var newNode = ts.factory.createFunctionDeclaration(func.decorators, statement.modifiers, func.asteriskToken, name, func.typeParameters, func.parameters, func.type, body); + var modifiersFlags = (ts.getCombinedModifierFlags(variableDeclaration) & 1 /* Export */) | ts.getEffectiveModifierFlags(func); + var modifiers = ts.factory.createModifiersFromModifierFlags(modifiersFlags); + var newNode = ts.factory.createFunctionDeclaration(func.decorators, ts.length(modifiers) ? modifiers : undefined, func.asteriskToken, name, func.typeParameters, func.parameters, func.type, body); if (variableDeclarationList.declarations.length === 1) { return ts.textChanges.ChangeTracker.with(context, function (t) { return t.replaceNode(file, statement, newNode); }); } @@ -147983,9 +153101,7 @@ var ts; function getEditsForAction(context) { var info = getInfo(context); if (info && !refactor.isRefactorErrorInfo(info)) { - var edits = ts.textChanges.ChangeTracker.with(context, function (t) { - return t.tryInsertTypeAnnotation(context.file, info.declaration, info.returnTypeNode); - }); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, t, info.declaration, info.returnTypeNode); }); return { renameFilename: undefined, renameLocation: undefined, edits: edits }; } return undefined; @@ -148010,11 +153126,26 @@ var ts; } return ts.emptyArray; } + function doChange(sourceFile, changes, declaration, typeNode) { + var closeParen = ts.findChildOfKind(declaration, 21 /* 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.insertNodeAt(sourceFile, endNode.end, typeNode, { prefix: ": " }); + } + } function getInfo(context) { if (ts.isInJSFile(context.file) || !refactor.refactorKindBeginsWith(inferReturnTypeAction.kind, context.kind)) return; var token = ts.getTokenAtPosition(context.file, context.startPosition); - var declaration = ts.findAncestor(token, isConvertibleDeclaration); + 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" : + isConvertibleDeclaration(n); + }); if (!declaration || !declaration.body || declaration.type) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Return_type_must_be_inferred_from_a_function) }; } @@ -148023,7 +153154,6 @@ var ts; if (!returnType) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_determine_function_return_type) }; } - ; var returnTypeNode = typeChecker.typeToTypeNode(returnType, declaration, 1 /* NoTruncation */); if (returnTypeNode) { return { declaration: declaration, returnTypeNode: returnTypeNode }; @@ -148031,10 +153161,10 @@ var ts; } function isConvertibleDeclaration(node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 167 /* MethodDeclaration */: return true; default: return false; @@ -148061,8 +153191,8 @@ var ts; ts.servicesVersion = "0.8"; function createNode(kind, pos, end, parent) { var node = ts.isNodeKind(kind) ? new NodeObject(kind, pos, end) : - kind === 78 /* Identifier */ ? new IdentifierObject(78 /* Identifier */, pos, end) : - kind === 79 /* PrivateIdentifier */ ? new PrivateIdentifierObject(79 /* PrivateIdentifier */, pos, end) : + kind === 79 /* Identifier */ ? new IdentifierObject(79 /* Identifier */, pos, end) : + kind === 80 /* PrivateIdentifier */ ? new PrivateIdentifierObject(80 /* PrivateIdentifier */, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; node.flags = parent.flags & 25358336 /* ContextFlags */; @@ -148136,8 +153266,8 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 301 /* FirstJSDocNode */ || kid.kind > 333 /* LastJSDocNode */; }); - return child.kind < 157 /* FirstNode */ ? + var child = ts.find(children, function (kid) { return kid.kind < 303 /* FirstJSDocNode */ || kid.kind > 341 /* LastJSDocNode */; }); + return child.kind < 159 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; @@ -148148,7 +153278,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 157 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 159 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; NodeObject.prototype.forEachChild = function (cbNode, cbNodeArray) { return ts.forEachChild(this, cbNode, cbNodeArray); @@ -148194,7 +153324,7 @@ var ts; var token = ts.scanner.scan(); var textPos = ts.scanner.getTextPos(); if (textPos <= end) { - if (token === 78 /* Identifier */) { + if (token === 79 /* Identifier */) { ts.Debug.fail("Did not expect " + ts.Debug.formatSyntaxKind(parent.kind) + " to have an Identifier in its trivia"); } nodes.push(createNode(token, pos, textPos, parent)); @@ -148206,11 +153336,11 @@ var ts; } } function createSyntaxList(nodes, parent) { - var list = createNode(334 /* SyntaxList */, nodes.pos, nodes.end, parent); + var list = createNode(342 /* SyntaxList */, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; - for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { - var node = nodes_1[_i]; + for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) { + var node = nodes_2[_i]; addSyntheticNodes(list._children, pos, node.pos, parent); list._children.push(node); pos = node.end; @@ -148317,13 +153447,13 @@ var ts; }; SymbolObject.prototype.getContextualDocumentationComment = function (context, checker) { switch (context === null || context === void 0 ? void 0 : context.kind) { - case 167 /* GetAccessor */: + case 169 /* GetAccessor */: if (!this.contextualGetAccessorDocumentationComment) { this.contextualGetAccessorDocumentationComment = ts.emptyArray; this.contextualGetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isGetAccessor), checker); } return this.contextualGetAccessorDocumentationComment; - case 168 /* SetAccessor */: + case 170 /* SetAccessor */: if (!this.contextualSetAccessorDocumentationComment) { this.contextualSetAccessorDocumentationComment = ts.emptyArray; this.contextualSetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isSetAccessor), checker); @@ -148333,9 +153463,9 @@ var ts; return this.getDocumentationComment(checker); } }; - SymbolObject.prototype.getJsDocTags = function () { + SymbolObject.prototype.getJsDocTags = function (checker) { if (this.tags === undefined) { - this.tags = ts.JsDoc.getJsDocTagsFromDeclarations(this.declarations); + this.tags = ts.JsDoc.getJsDocTagsFromDeclarations(this.declarations, checker); } return this.tags; }; @@ -148354,7 +153484,7 @@ var ts; __extends(IdentifierObject, _super); function IdentifierObject(_kind, pos, end) { var _this = _super.call(this, pos, end) || this; - _this.kind = 78 /* Identifier */; + _this.kind = 79 /* Identifier */; return _this; } Object.defineProperty(IdentifierObject.prototype, "text", { @@ -148366,7 +153496,7 @@ var ts; }); return IdentifierObject; }(TokenOrIdentifierObject)); - IdentifierObject.prototype.kind = 78 /* Identifier */; + IdentifierObject.prototype.kind = 79 /* Identifier */; var PrivateIdentifierObject = /** @class */ (function (_super) { __extends(PrivateIdentifierObject, _super); function PrivateIdentifierObject(_kind, pos, end) { @@ -148381,7 +153511,7 @@ var ts; }); return PrivateIdentifierObject; }(TokenOrIdentifierObject)); - PrivateIdentifierObject.prototype.kind = 79 /* PrivateIdentifier */; + PrivateIdentifierObject.prototype.kind = 80 /* PrivateIdentifier */; var TypeObject = /** @class */ (function () { function TypeObject(checker, flags) { this.checker = checker; @@ -148496,7 +153626,7 @@ var ts; }; SignatureObject.prototype.getJsDocTags = function () { if (this.jsDocTags === undefined) { - this.jsDocTags = this.declaration ? getJsDocTags([this.declaration], this.checker) : []; + this.jsDocTags = this.declaration ? getJsDocTagsOfSignature(this.declaration, this.checker) : []; } return this.jsDocTags; }; @@ -148510,29 +153640,34 @@ var ts; function hasJSDocInheritDocTag(node) { return ts.getJSDocTags(node).some(function (tag) { return tag.tagName.text === "inheritDoc"; }); } - function getJsDocTags(declarations, checker) { - var tags = ts.JsDoc.getJsDocTagsFromDeclarations(declarations); - if (tags.length === 0 || declarations.some(hasJSDocInheritDocTag)) { - ts.forEachUnique(declarations, function (declaration) { - var inheritedTags = findBaseOfDeclaration(checker, declaration, function (symbol) { return symbol.getJsDocTags(); }); - if (inheritedTags) { - tags = __spreadArray(__spreadArray([], inheritedTags), tags); - } - }); + function getJsDocTagsOfSignature(declaration, checker) { + var tags = ts.JsDoc.getJsDocTagsFromDeclarations([declaration], checker); + if (tags.length === 0 || hasJSDocInheritDocTag(declaration)) { + var inheritedTags = findBaseOfDeclaration(checker, declaration, function (symbol) { var _a; return ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.length) === 1 ? symbol.getJsDocTags() : undefined; }); + if (inheritedTags) { + tags = __spreadArray(__spreadArray([], inheritedTags), tags); + } } return tags; } function getDocumentationComment(declarations, checker) { if (!declarations) return ts.emptyArray; - var doc = ts.JsDoc.getJsDocCommentsFromDeclarations(declarations); + var doc = ts.JsDoc.getJsDocCommentsFromDeclarations(declarations, checker); if (checker && (doc.length === 0 || declarations.some(hasJSDocInheritDocTag))) { - ts.forEachUnique(declarations, function (declaration) { - var inheritedDocs = findBaseOfDeclaration(checker, declaration, function (symbol) { return symbol.getDocumentationComment(checker); }); + var seenSymbols_1 = new ts.Set(); + for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { + var declaration = declarations_4[_i]; + var inheritedDocs = findBaseOfDeclaration(checker, declaration, function (symbol) { + if (!seenSymbols_1.has(symbol)) { + seenSymbols_1.add(symbol); + return symbol.getDocumentationComment(checker); + } + }); // TODO: GH#16312 Return a ReadonlyArray, avoid copying inheritedDocs if (inheritedDocs) doc = doc.length === 0 ? inheritedDocs.slice() : inheritedDocs.concat(ts.lineBreakPart(), doc); - }); + } } return doc; } @@ -148546,7 +153681,7 @@ var ts; __extends(SourceFileObject, _super); function SourceFileObject(kind, pos, end) { var _this = _super.call(this, kind, pos, end) || this; - _this.kind = 297 /* SourceFile */; + _this.kind = 299 /* SourceFile */; return _this; } SourceFileObject.prototype.update = function (newText, textChangeRange) { @@ -148605,10 +153740,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -148628,31 +153763,31 @@ var ts; } ts.forEachChild(node, visit); break; - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 255 /* EnumDeclaration */: - case 256 /* ModuleDeclaration */: - case 260 /* ImportEqualsDeclaration */: - case 270 /* ExportSpecifier */: - case 265 /* ImportSpecifier */: - case 262 /* ImportClause */: - case 263 /* NamespaceImport */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 177 /* TypeLiteral */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 257 /* EnumDeclaration */: + case 258 /* ModuleDeclaration */: + case 262 /* ImportEqualsDeclaration */: + case 272 /* ExportSpecifier */: + case 267 /* ImportSpecifier */: + case 264 /* ImportClause */: + case 265 /* NamespaceImport */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 179 /* TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 160 /* Parameter */: + case 162 /* Parameter */: // Only consider parameter properties - if (!ts.hasSyntacticModifier(node, 92 /* ParameterPropertyModifier */)) { + if (!ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */)) { break; } // falls through - case 249 /* VariableDeclaration */: - case 198 /* BindingElement */: { + case 251 /* VariableDeclaration */: + case 200 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -148663,12 +153798,12 @@ var ts; } } // falls through - case 291 /* EnumMember */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 293 /* EnumMember */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: addDeclaration(node); break; - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; var exportDeclaration = node; @@ -148681,7 +153816,7 @@ var ts; } } break; - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -148693,7 +153828,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 263 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 265 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -148702,7 +153837,7 @@ var ts; } } break; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) !== 0 /* None */) { addDeclaration(node); } @@ -148796,15 +153931,7 @@ var ts; var fileName = rootFileNames_1[_i]; this.createEntry(fileName, ts.toPath(fileName, this.currentDirectory, getCanonicalFileName)); } - // store the compilation settings - this._compilationSettings = host.getCompilationSettings() || getDefaultCompilerOptions(); } - HostCache.prototype.compilationSettings = function () { - return this._compilationSettings; - }; - HostCache.prototype.getProjectReferences = function () { - return this.host.getProjectReferences && this.host.getProjectReferences(); - }; HostCache.prototype.createEntry = function (fileName, path) { var entry; var scriptSnapshot = this.host.getScriptSnapshot(fileName); @@ -148954,7 +154081,7 @@ var ts; }; CancellationTokenObject.prototype.throwIfCancellationRequested = function () { if (this.isCancellationRequested()) { - ts.tracing.instant("session" /* Session */, "cancellationThrown", { kind: "CancellationTokenObject" }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "cancellationThrown", { kind: "CancellationTokenObject" }); throw new ts.OperationCanceledException(); } }; @@ -148984,7 +154111,7 @@ var ts; }; ThrottledCancellationToken.prototype.throwIfCancellationRequested = function () { if (this.isCancellationRequested()) { - ts.tracing.instant("session" /* Session */, "cancellationThrown", { kind: "ThrottledCancellationToken" }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "cancellationThrown", { kind: "ThrottledCancellationToken" }); throw new ts.OperationCanceledException(); } }; @@ -149084,7 +154211,7 @@ var ts; return sourceFile; } function synchronizeHostData() { - var _a, _b; + var _a, _b, _c; ts.Debug.assert(languageServiceMode !== ts.LanguageServiceMode.Syntactic); // perform fast check if host supports it if (host.getProjectVersion) { @@ -149105,11 +154232,22 @@ var ts; // Get a fresh cache of the host information var hostCache = new HostCache(host, getCanonicalFileName); var rootFileNames = hostCache.getRootFileNames(); + var newSettings = host.getCompilationSettings() || getDefaultCompilerOptions(); var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse; var hasChangedAutomaticTypeDirectiveNames = ts.maybeBind(host, host.hasChangedAutomaticTypeDirectiveNames); - var projectReferences = hostCache.getProjectReferences(); + var projectReferences = (_b = host.getProjectReferences) === null || _b === void 0 ? void 0 : _b.call(host); + var parsedCommandLines; + var parseConfigHost = { + useCaseSensitiveFileNames: useCaseSensitiveFileNames, + fileExists: fileExists, + readFile: readFile, + readDirectory: readDirectory, + trace: ts.maybeBind(host, host.trace), + getCurrentDirectory: function () { return currentDirectory; }, + onUnRecoverableConfigFileDiagnostic: ts.noop, + }; // If the program is already up-to-date, we can reuse it - if (ts.isProgramUptoDate(program, rootFileNames, hostCache.compilationSettings(), function (_path, fileName) { return host.getScriptVersion(fileName); }, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, projectReferences)) { + if (ts.isProgramUptoDate(program, rootFileNames, newSettings, function (_path, fileName) { return host.getScriptVersion(fileName); }, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) { return; } // IMPORTANT - It is critical from this moment onward that we do not check @@ -149117,7 +154255,6 @@ var ts; // instance. If we cancel midway through, we may end up in an inconsistent state where // the program points to old source files that have been invalidated because of // incremental parsing. - var newSettings = hostCache.compilationSettings(); // Now create a new compiler var compilerHost = { getSourceFile: getOrCreateSourceFile, @@ -149139,19 +154276,18 @@ var ts; getDirectories: function (path) { return host.getDirectories ? host.getDirectories(path) : []; }, - readDirectory: function (path, extensions, exclude, include, depth) { - ts.Debug.checkDefined(host.readDirectory, "'LanguageServiceHost.readDirectory' must be implemented to correctly process 'projectReferences'"); - return host.readDirectory(path, extensions, exclude, include, depth); - }, + readDirectory: readDirectory, onReleaseOldSourceFile: onReleaseOldSourceFile, + onReleaseParsedCommandLine: onReleaseParsedCommandLine, hasInvalidatedResolution: hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames: hasChangedAutomaticTypeDirectiveNames, - trace: ts.maybeBind(host, host.trace), + trace: parseConfigHost.trace, resolveModuleNames: ts.maybeBind(host, host.resolveModuleNames), resolveTypeReferenceDirectives: ts.maybeBind(host, host.resolveTypeReferenceDirectives), useSourceOfProjectReferenceRedirect: ts.maybeBind(host, host.useSourceOfProjectReferenceRedirect), + getParsedCommandLine: getParsedCommandLine, }; - (_b = host.setCompilerHost) === null || _b === void 0 ? void 0 : _b.call(host, compilerHost); + (_c = host.setCompilerHost) === null || _c === void 0 ? void 0 : _c.call(host, compilerHost); var documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings); var options = { rootNames: rootFileNames, @@ -149164,6 +154300,7 @@ var ts; // hostCache is captured in the closure for 'getOrCreateSourceFile' but it should not be used past this point. // It needs to be cleared to allow all collected snapshots to be released hostCache = undefined; + parsedCommandLines = undefined; // We reset this cache on structure invalidation so we don't hold on to outdated files for long; however we can't use the `compilerHost` above, // Because it only functions until `hostCache` is cleared, while we'll potentially need the functionality to lazily read sourcemap files during // the course of whatever called `synchronizeHostData` @@ -149172,6 +154309,36 @@ var ts; // pointers set property. program.getTypeChecker(); return; + function getParsedCommandLine(fileName) { + var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); + var existing = parsedCommandLines === null || parsedCommandLines === void 0 ? void 0 : parsedCommandLines.get(path); + if (existing !== undefined) + return existing || undefined; + var result = host.getParsedCommandLine ? + host.getParsedCommandLine(fileName) : + getParsedCommandLineOfConfigFileUsingSourceFile(fileName); + (parsedCommandLines || (parsedCommandLines = new ts.Map())).set(path, result || false); + return result; + } + function getParsedCommandLineOfConfigFileUsingSourceFile(configFileName) { + var result = getOrCreateSourceFile(configFileName, 100 /* JSON */); + if (!result) + return undefined; + result.path = ts.toPath(configFileName, currentDirectory, getCanonicalFileName); + result.resolvedPath = result.path; + result.originalFileName = result.fileName; + return ts.parseJsonSourceFileConfigFileContent(result, parseConfigHost, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), + /*optionsToExtend*/ undefined, ts.getNormalizedAbsolutePath(configFileName, currentDirectory)); + } + function onReleaseParsedCommandLine(configFileName, oldResolvedRef, oldOptions) { + var _a; + if (host.getParsedCommandLine) { + (_a = host.onReleaseParsedCommandLine) === null || _a === void 0 ? void 0 : _a.call(host, configFileName, oldResolvedRef, oldOptions); + } + else if (oldResolvedRef) { + onReleaseOldSourceFile(oldResolvedRef.sourceFile, oldOptions); + } + } function fileExists(fileName) { var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); var entry = hostCache && hostCache.getEntryByPath(path); @@ -149188,11 +154355,15 @@ var ts; } return host.readFile && host.readFile(fileName); } + function readDirectory(path, extensions, exclude, include, depth) { + ts.Debug.checkDefined(host.readDirectory, "'LanguageServiceHost.readDirectory' must be implemented to correctly process 'projectReferences'"); + return host.readDirectory(path, extensions, exclude, include, depth); + } // Release any files we have acquired in the old program but are // not part of the new program. function onReleaseOldSourceFile(oldSourceFile, oldOptions) { var oldSettingsKey = documentRegistry.getKeyForCompilationSettings(oldOptions); - documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, oldSettingsKey); + documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, oldSettingsKey, oldSourceFile.scriptKind); } function getOrCreateSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile) { return getOrCreateSourceFileByPath(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), languageVersion, onError, shouldCreateNewSourceFile); @@ -149237,8 +154408,13 @@ var ts; // We do not support the scenario where a host can modify a registered // file's script kind, i.e. in one project some file is treated as ".ts" // and in another as ".js" - ts.Debug.assertEqual(hostFileInformation.scriptKind, oldSourceFile.scriptKind, "Registered script kind should match new script kind."); - return documentRegistry.updateDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind); + if (hostFileInformation.scriptKind === oldSourceFile.scriptKind) { + return documentRegistry.updateDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind); + } + 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); + } } // We didn't already have the file. Fall through and acquire it from the registry. } @@ -149267,7 +154443,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); + return documentRegistry.releaseDocumentWithKey(f.resolvedPath, key_1, f.scriptKind); }); program = undefined; // TODO: GH#18217 } @@ -149310,10 +154486,10 @@ var ts; synchronizeHostData(); return ts.Completions.getCompletionsAtPosition(host, program, log, getValidSourceFile(fileName), position, fullPreferences, options.triggerCharacter); } - function getCompletionEntryDetails(fileName, position, name, formattingOptions, source, preferences) { + function getCompletionEntryDetails(fileName, position, name, formattingOptions, source, preferences, data) { if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); - return ts.Completions.getCompletionEntryDetails(program, log, getValidSourceFile(fileName), position, { name: name, source: source }, host, (formattingOptions && ts.formatting.getFormatContext(formattingOptions, host)), // TODO: GH#18217 + return ts.Completions.getCompletionEntryDetails(program, log, getValidSourceFile(fileName), position, { name: name, source: source, data: data }, host, (formattingOptions && ts.formatting.getFormatContext(formattingOptions, host)), // TODO: GH#18217 preferences, cancellationToken); } function getCompletionEntrySymbol(fileName, position, name, source, preferences) { @@ -149340,7 +154516,7 @@ var ts; 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, - tags: type_2.symbol ? type_2.symbol.getJsDocTags() : undefined + tags: type_2.symbol ? type_2.symbol.getJsDocTags(typeChecker) : undefined }; } var _a = typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { @@ -149359,19 +154535,23 @@ var ts; if (ts.isNewExpression(node.parent) && node.pos === node.parent.pos) { return node.parent.expression; } + if (ts.isNamedTupleMember(node.parent) && node.pos === node.parent.pos) { + return node.parent; + } return node; } function shouldGetType(sourceFile, node, position) { switch (node.kind) { - case 78 /* Identifier */: - return !ts.isLabelName(node) && !ts.isTagName(node); - case 201 /* PropertyAccessExpression */: - case 157 /* QualifiedName */: + case 79 /* Identifier */: + return !ts.isLabelName(node) && !ts.isTagName(node) && !ts.isConstTypeReference(node.parent); + case 203 /* PropertyAccessExpression */: + case 159 /* QualifiedName */: // Don't return quickInfo if inside the comment in `a/**/.b` return !ts.isInComment(sourceFile, position); - case 107 /* ThisKeyword */: - case 187 /* ThisType */: - case 105 /* SuperKeyword */: + case 108 /* ThisKeyword */: + case 189 /* ThisType */: + case 106 /* SuperKeyword */: + case 194 /* NamedTupleMember */: return true; default: return false; @@ -149476,16 +154656,16 @@ var ts; return undefined; } switch (node.kind) { - case 201 /* PropertyAccessExpression */: - case 157 /* QualifiedName */: + case 203 /* PropertyAccessExpression */: + case 159 /* QualifiedName */: case 10 /* StringLiteral */: - case 94 /* FalseKeyword */: - case 109 /* TrueKeyword */: - case 103 /* NullKeyword */: - case 105 /* SuperKeyword */: - case 107 /* ThisKeyword */: - case 187 /* ThisType */: - case 78 /* Identifier */: + case 95 /* FalseKeyword */: + case 110 /* TrueKeyword */: + case 104 /* NullKeyword */: + case 106 /* SuperKeyword */: + case 108 /* ThisKeyword */: + case 189 /* ThisType */: + case 79 /* Identifier */: break; // Cant create the text span default: @@ -149501,7 +154681,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 === 256 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 258 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -149529,15 +154709,7 @@ var ts; function getNavigationTree(fileName) { return ts.NavigationBar.getNavigationTree(syntaxTreeCache.getCurrentSourceFile(fileName), cancellationToken); } - function isTsOrTsxFile(fileName) { - var kind = ts.getScriptKind(fileName, host); - return kind === 3 /* TS */ || kind === 4 /* TSX */; - } function getSemanticClassifications(fileName, span, format) { - if (!isTsOrTsxFile(fileName)) { - // do not run semantic classification on non-ts-or-tsx files - return []; - } synchronizeHostData(); var responseFormat = format || "original" /* Original */; if (responseFormat === "2020" /* TwentyTwenty */) { @@ -149548,10 +154720,6 @@ var ts; } } function getEncodedSemanticClassifications(fileName, span, format) { - if (!isTsOrTsxFile(fileName)) { - // do not run semantic classification on non-ts-or-tsx files - return { spans: [], endOfLineState: 0 /* None */ }; - } synchronizeHostData(); var responseFormat = format || "original" /* Original */; if (responseFormat === "original" /* Original */) { @@ -149642,13 +154810,13 @@ var ts; var formatContext = ts.formatting.getFormatContext(formatOptions, host); return ts.codefix.getAllFixes({ fixId: fixId, sourceFile: sourceFile, program: program, host: host, cancellationToken: cancellationToken, formatContext: formatContext, preferences: preferences }); } - function organizeImports(scope, formatOptions, preferences) { + function organizeImports(args, formatOptions, preferences) { if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); - ts.Debug.assert(scope.type === "file"); - var sourceFile = getValidSourceFile(scope.fileName); + ts.Debug.assert(args.type === "file"); + var sourceFile = getValidSourceFile(args.fileName); var formatContext = ts.formatting.getFormatContext(formatOptions, host); - return ts.OrganizeImports.organizeImports(sourceFile, formatContext, host, program, preferences); + return ts.OrganizeImports.organizeImports(sourceFile, formatContext, host, program, preferences, args.skipDestructiveCodeActions); } function getEditsForFileRename(oldFilePath, newFilePath, formatOptions, preferences) { if (preferences === void 0) { preferences = ts.emptyOptions; } @@ -149665,8 +154833,8 @@ var ts; ? host.installPackage({ fileName: getPath(action.file), packageName: action.packageName }) : Promise.reject("Host does not implement `installPackage`"); } - function getDocCommentTemplateAtPosition(fileName, position) { - return ts.JsDoc.getDocCommentTemplateAtPosition(ts.getNewLineOrDefaultFromHost(host), syntaxTreeCache.getCurrentSourceFile(fileName), position); + function getDocCommentTemplateAtPosition(fileName, position, options) { + return ts.JsDoc.getDocCommentTemplateAtPosition(ts.getNewLineOrDefaultFromHost(host), syntaxTreeCache.getCurrentSourceFile(fileName), position, options); } function isValidBraceCompletionAtPosition(fileName, position, openingBrace) { // '<' is currently not supported, figuring out if we're in a Generic Type vs. a comparison is too @@ -150081,6 +155249,16 @@ var ts; var file = getValidSourceFile(fileName); return ts.refactor.getEditsForRefactor(getRefactorContext(file, positionOrRange, preferences, formatOptions), refactorName, actionName); } + function toLineColumnOffset(fileName, position) { + // Go to Definition supports returning a zero-length span at position 0 for + // non-existent files. We need to special-case the conversion of position 0 + // to avoid a crash trying to get the text for that file, since this function + // otherwise assumes that 'fileName' is the name of a file that exists. + if (position === 0) { + return { line: 0, character: 0 }; + } + return sourceMapper.toLineColumnOffset(fileName, position); + } function prepareCallHierarchy(fileName, position) { synchronizeHostData(); var declarations = ts.CallHierarchy.resolveCallHierarchyDeclaration(program, ts.getTouchingPropertyName(getValidSourceFile(fileName), position)); @@ -150153,7 +155331,7 @@ var ts; getAutoImportProvider: getAutoImportProvider, getApplicableRefactors: getApplicableRefactors, getEditsForRefactor: getEditsForRefactor, - toLineColumnOffset: sourceMapper.toLineColumnOffset, + toLineColumnOffset: toLineColumnOffset, getSourceMapper: function () { return sourceMapper; }, clearSourceMapperCache: function () { return sourceMapper.clearCache(); }, prepareCallHierarchy: prepareCallHierarchy, @@ -150224,7 +155402,7 @@ var ts; */ function literalIsName(node) { return ts.isDeclarationName(node) || - node.parent.kind === 272 /* ExternalModuleReference */ || + node.parent.kind === 274 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node); } @@ -150242,13 +155420,13 @@ var ts; case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: - if (node.parent.kind === 158 /* ComputedPropertyName */) { + if (node.parent.kind === 160 /* ComputedPropertyName */) { return ts.isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; } // falls through - case 78 /* Identifier */: + case 79 /* Identifier */: return ts.isObjectLiteralElement(node.parent) && - (node.parent.parent.kind === 200 /* ObjectLiteralExpression */ || node.parent.parent.kind === 281 /* JsxAttributes */) && + (node.parent.parent.kind === 202 /* ObjectLiteralExpression */ || node.parent.parent.kind === 283 /* JsxAttributes */) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -150290,7 +155468,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 202 /* ElementAccessExpression */ && + node.parent.kind === 204 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -150370,114 +155548,114 @@ var ts; if (node) { var parent = node.parent; switch (node.kind) { - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 249 /* VariableDeclaration */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 251 /* VariableDeclaration */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: return spanInVariableDeclaration(node); - case 160 /* Parameter */: + case 162 /* Parameter */: return spanInParameterDeclaration(node); - case 251 /* FunctionDeclaration */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 166 /* Constructor */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 253 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 168 /* Constructor */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 230 /* Block */: + case 232 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // falls through - case 257 /* ModuleBlock */: + case 259 /* ModuleBlock */: return spanInBlock(node); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return spanInBlock(node.block); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 236 /* WhileStatement */: + case 238 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 235 /* DoStatement */: + case 237 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 248 /* DebuggerStatement */: + case 250 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 234 /* IfStatement */: + case 236 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 241 /* BreakStatement */: - case 240 /* ContinueStatement */: + case 243 /* BreakStatement */: + case 242 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return spanInForStatement(node); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 284 /* CaseClause */: - case 285 /* DefaultClause */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 247 /* TryStatement */: + case 249 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 246 /* ThrowStatement */: + case 248 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } // falls through - case 252 /* ClassDeclaration */: - case 255 /* EnumDeclaration */: - case 291 /* EnumMember */: - case 198 /* BindingElement */: + case 254 /* ClassDeclaration */: + case 257 /* EnumDeclaration */: + case 293 /* EnumMember */: + case 200 /* BindingElement */: // span on complete node return textSpan(node); - case 243 /* WithStatement */: + case 245 /* WithStatement */: // span in statement return spanInNode(node.statement); - case 161 /* Decorator */: + case 163 /* Decorator */: return spanInNodeArray(parent.decorators); - case 196 /* ObjectBindingPattern */: - case 197 /* ArrayBindingPattern */: + case 198 /* ObjectBindingPattern */: + case 199 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: return undefined; // Tokens: case 26 /* SemicolonToken */: @@ -150501,13 +155679,13 @@ var ts; case 29 /* LessThanToken */: return spanInGreaterThanOrLessThanToken(node); // Keywords: - case 114 /* WhileKeyword */: + case 115 /* WhileKeyword */: return spanInWhileKeyword(node); - case 90 /* ElseKeyword */: - case 82 /* CatchKeyword */: - case 95 /* FinallyKeyword */: + case 91 /* ElseKeyword */: + case 83 /* CatchKeyword */: + case 96 /* FinallyKeyword */: return spanInNextNode(node); - case 156 /* OfKeyword */: + case 158 /* OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -150519,14 +155697,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 === 78 /* Identifier */ || - node.kind === 220 /* SpreadElement */ || - node.kind === 288 /* PropertyAssignment */ || - node.kind === 289 /* ShorthandPropertyAssignment */) && + if ((node.kind === 79 /* Identifier */ || + node.kind === 222 /* SpreadElement */ || + node.kind === 290 /* PropertyAssignment */ || + node.kind === 291 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(parent)) { return textSpan(node); } - if (node.kind === 216 /* BinaryExpression */) { + if (node.kind === 218 /* 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 @@ -150535,7 +155713,7 @@ var ts; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(left); } - if (operatorToken.kind === 62 /* EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { + if (operatorToken.kind === 63 /* EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { // Set breakpoint on assignment expression element of destructuring pattern // a = expression of // [a = expression, b, c] = someExpression or @@ -150548,22 +155726,22 @@ var ts; } if (ts.isExpressionNode(node)) { switch (parent.kind) { - case 235 /* DoStatement */: + case 237 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 161 /* Decorator */: + case 163 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 237 /* ForStatement */: - case 239 /* ForOfStatement */: + case 239 /* ForStatement */: + case 241 /* ForOfStatement */: return textSpan(node); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: if (node.parent.operatorToken.kind === 27 /* CommaToken */) { // If this is a comma expression, the breakpoint is possible in this expression return textSpan(node); } break; - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -150572,21 +155750,21 @@ var ts; } } switch (node.parent.kind) { - case 288 /* PropertyAssignment */: + case 290 /* 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 206 /* TypeAssertionExpression */: + case 208 /* TypeAssertionExpression */: // Breakpoint in type assertion goes to its operand if (node.parent.type === node) { return spanInNextNode(node.parent.type); } break; - case 249 /* VariableDeclaration */: - case 160 /* Parameter */: { + case 251 /* VariableDeclaration */: + case 162 /* 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)) { @@ -150594,7 +155772,7 @@ var ts; } break; } - case 216 /* BinaryExpression */: { + case 218 /* BinaryExpression */: { var left = node.parent.left; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left) && node !== left) { // If initializer of destructuring assignment move to previous token @@ -150624,7 +155802,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 238 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 240 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } var parent = variableDeclaration.parent; @@ -150636,7 +155814,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasSyntacticModifier(variableDeclaration, 1 /* Export */) || - parent.parent.kind === 239 /* ForOfStatement */) { + parent.parent.kind === 241 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } if (ts.isVariableDeclarationList(variableDeclaration.parent) && @@ -150677,7 +155855,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasSyntacticModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 252 /* ClassDeclaration */ && functionDeclaration.kind !== 166 /* Constructor */); + (functionDeclaration.parent.kind === 254 /* ClassDeclaration */ && functionDeclaration.kind !== 168 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -150700,26 +155878,26 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement // falls through - case 236 /* WhileStatement */: - case 234 /* IfStatement */: - case 238 /* ForInStatement */: + case 238 /* WhileStatement */: + case 236 /* IfStatement */: + case 240 /* 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 237 /* ForStatement */: - case 239 /* ForOfStatement */: + case 239 /* ForStatement */: + case 241 /* 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 === 250 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 252 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -150744,21 +155922,21 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 222 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 224 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 198 /* BindingElement */) { + if (bindingPattern.parent.kind === 200 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 197 /* ArrayBindingPattern */ && node.kind !== 196 /* ObjectBindingPattern */); - var elements = node.kind === 199 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 222 /* OmittedExpression */ ? element : undefined; }); + ts.Debug.assert(node.kind !== 199 /* ArrayBindingPattern */ && node.kind !== 198 /* ObjectBindingPattern */); + var elements = node.kind === 201 /* ArrayLiteralExpression */ ? node.elements : node.properties; + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 224 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -150766,18 +155944,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 === 216 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 218 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 258 /* CaseBlock */: + case 260 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -150785,25 +155963,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 257 /* ModuleBlock */: + case 259 /* ModuleBlock */: // If this is not an instantiated module block, no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } // falls through - case 255 /* EnumDeclaration */: - case 252 /* ClassDeclaration */: + case 257 /* EnumDeclaration */: + case 254 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 230 /* Block */: + case 232 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // falls through - case 287 /* CatchClause */: + case 289 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 258 /* CaseBlock */: + case 260 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -150811,7 +155989,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 196 /* ObjectBindingPattern */: + case 198 /* 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); @@ -150827,7 +156005,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 197 /* ArrayBindingPattern */: + case 199 /* 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); @@ -150842,12 +156020,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 235 /* DoStatement */ || // Go to while keyword and do action instead - node.parent.kind === 203 /* CallExpression */ || - node.parent.kind === 204 /* NewExpression */) { + if (node.parent.kind === 237 /* DoStatement */ || // Go to while keyword and do action instead + node.parent.kind === 205 /* CallExpression */ || + node.parent.kind === 206 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 207 /* ParenthesizedExpression */) { + if (node.parent.kind === 209 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -150856,21 +156034,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 166 /* Constructor */: - case 236 /* WhileStatement */: - case 235 /* DoStatement */: - case 237 /* ForStatement */: - case 239 /* ForOfStatement */: - case 203 /* CallExpression */: - case 204 /* NewExpression */: - case 207 /* ParenthesizedExpression */: + case 210 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 211 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 168 /* Constructor */: + case 238 /* WhileStatement */: + case 237 /* DoStatement */: + case 239 /* ForStatement */: + case 241 /* ForOfStatement */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: + case 209 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -150880,20 +156058,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 288 /* PropertyAssignment */ || - node.parent.kind === 160 /* Parameter */) { + node.parent.kind === 290 /* PropertyAssignment */ || + node.parent.kind === 162 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 206 /* TypeAssertionExpression */) { + if (node.parent.kind === 208 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 235 /* DoStatement */) { + if (node.parent.kind === 237 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -150901,7 +156079,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 239 /* ForOfStatement */) { + if (node.parent.kind === 241 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -151442,11 +156620,11 @@ var ts; return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ", " + preferences + ")", function () { return _this.languageService.getCompletionsAtPosition(fileName, position, preferences); }); }; /** Get a string based representation of a completion list entry details */ - LanguageServiceShimObject.prototype.getCompletionEntryDetails = function (fileName, position, entryName, formatOptions, source, preferences) { + LanguageServiceShimObject.prototype.getCompletionEntryDetails = function (fileName, position, entryName, formatOptions, source, preferences, data) { var _this = this; return this.forwardJSONCall("getCompletionEntryDetails('" + fileName + "', " + position + ", '" + entryName + "')", function () { var localOptions = formatOptions === undefined ? undefined : JSON.parse(formatOptions); - return _this.languageService.getCompletionEntryDetails(fileName, position, entryName, localOptions, source, preferences); + return _this.languageService.getCompletionEntryDetails(fileName, position, entryName, localOptions, source, preferences, data); }); }; LanguageServiceShimObject.prototype.getFormattingEditsForRange = function (fileName, start, end, options /*Services.FormatCodeOptions*/) { @@ -151470,9 +156648,9 @@ var ts; return _this.languageService.getFormattingEditsAfterKeystroke(fileName, position, key, localOptions); }); }; - LanguageServiceShimObject.prototype.getDocCommentTemplateAtPosition = function (fileName, position) { + LanguageServiceShimObject.prototype.getDocCommentTemplateAtPosition = function (fileName, position, options) { var _this = this; - return this.forwardJSONCall("getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position); }); + return this.forwardJSONCall("getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position, options); }); }; /// NAVIGATE TO /** Return a list of symbols that are interesting to navigate to */ @@ -152484,7 +157662,7 @@ var ts; } else { type = operatorOrType; - operator = 138 /* KeyOfKeyword */; + operator = 139 /* KeyOfKeyword */; } return ts.factory.createTypeOperatorNode(operator, type); }, factoryDeprecation); @@ -152612,7 +157790,7 @@ var ts; }, factoryDeprecation); /** @deprecated Use `factory.createJSDocParameterTag` or the factory supplied by your transformation context instead. */ ts.createJSDocParamTag = ts.Debug.deprecate(function createJSDocParamTag(name, isBracketed, typeExpression, comment) { - return ts.factory.createJSDocParameterTag(/*tagName*/ undefined, name, isBracketed, typeExpression, /*isNameFirst*/ false, comment); + return ts.factory.createJSDocParameterTag(/*tagName*/ undefined, name, isBracketed, typeExpression, /*isNameFirst*/ false, comment ? ts.factory.createNodeArray([ts.factory.createJSDocText(comment)]) : undefined); }, factoryDeprecation); /** @deprecated Use `factory.createComma` or the factory supplied by your transformation context instead. */ ts.createComma = ts.Debug.deprecate(function createComma(left, right) { @@ -152662,9 +157840,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 === 297 /* SourceFile */ ? ts.parseBaseNodeFactory.createBaseSourceFileNode(kind) : - kind === 78 /* Identifier */ ? ts.parseBaseNodeFactory.createBaseIdentifierNode(kind) : - kind === 79 /* PrivateIdentifier */ ? ts.parseBaseNodeFactory.createBasePrivateIdentifierNode(kind) : + return ts.setTextRangePosEnd(kind === 299 /* SourceFile */ ? ts.parseBaseNodeFactory.createBaseSourceFileNode(kind) : + kind === 79 /* Identifier */ ? ts.parseBaseNodeFactory.createBaseIdentifierNode(kind) : + kind === 80 /* 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." }); @@ -152691,13 +157869,30 @@ var ts; // #region Renamed node Tests /** @deprecated Use `isTypeAssertionExpression` instead. */ ts.isTypeAssertion = ts.Debug.deprecate(function isTypeAssertion(node) { - return node.kind === 206 /* TypeAssertionExpression */; + return node.kind === 208 /* TypeAssertionExpression */; }, { since: "4.0", warnAfter: "4.1", message: "Use `isTypeAssertionExpression` instead." }); // #endregion + // DEPRECATION: Renamed node tests + // DEPRECATION PLAN: + // - soft: 4.2 + // - warn: 4.3 + // - error: TBD + // #region Renamed node Tests + /** + * @deprecated Use `isMemberName` instead. + */ + ts.isIdentifierOrPrivateIdentifier = ts.Debug.deprecate(function isIdentifierOrPrivateIdentifier(node) { + return ts.isMemberName(node); + }, { + since: "4.2", + warnAfter: "4.3", + message: "Use `isMemberName` instead." + }); + // #endregion Renamed node Tests })(ts || (ts = {})); //# sourceMappingURL=typescriptServices.js.map diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index 4f9a74223a677..37a9b22226a71 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -81,7 +81,7 @@ var ts; (function (ts) { // WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values. // If changing the text in this section, be sure to test `configurePrerelease` too. - ts.versionMajorMinor = "4.2"; + ts.versionMajorMinor = "4.4"; // 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 @@ -1928,10 +1928,46 @@ var ts; * Takes a string like "jquery-min.4.2.3" and returns "jquery" */ function removeMinAndVersionNumbers(fileName) { - // Match a "." or "-" followed by a version number or 'min' at the end of the name - var trailingMinOrVersion = /[.-]((min)|(\d+(\.\d+)*))$/; - // The "min" or version may both be present, in either order, so try applying the above twice. - return fileName.replace(trailingMinOrVersion, "").replace(trailingMinOrVersion, ""); + // We used to use the regex /[.-]((min)|(\d+(\.\d+)*))$/ and would just .replace it twice. + // Unfortunately, that regex has O(n^2) performance because v8 doesn't match from the end of the string. + // Instead, we now essentially scan the filename (backwards) ourselves. + var end = fileName.length; + for (var pos = end - 1; pos > 0; pos--) { + var ch = fileName.charCodeAt(pos); + if (ch >= 48 /* _0 */ && ch <= 57 /* _9 */) { + // Match a \d+ segment + do { + --pos; + ch = fileName.charCodeAt(pos); + } while (pos > 0 && ch >= 48 /* _0 */ && ch <= 57 /* _9 */); + } + else if (pos > 4 && (ch === 110 /* n */ || ch === 78 /* N */)) { + // Looking for "min" or "min" + // Already matched the 'n' + --pos; + ch = fileName.charCodeAt(pos); + if (ch !== 105 /* i */ && ch !== 73 /* I */) { + break; + } + --pos; + ch = fileName.charCodeAt(pos); + if (ch !== 109 /* m */ && ch !== 77 /* M */) { + break; + } + --pos; + ch = fileName.charCodeAt(pos); + } + else { + // This character is not part of either suffix pattern + break; + } + if (ch !== 45 /* minus */ && ch !== 46 /* dot */) { + break; + } + end = pos; + } + // end might be fileName.length, in which case this should internally no-op + return end === fileName.length ? fileName : fileName.slice(0, end); } ts.removeMinAndVersionNumbers = removeMinAndVersionNumbers; /** Remove an item from an array, moving everything to its right one space left. */ @@ -2172,6 +2208,33 @@ var ts; return array.slice(0, index); } ts.takeWhile = takeWhile; + /** + * Removes the leading and trailing white space and line terminator characters from a string. + */ + ts.trimString = !!String.prototype.trim ? (function (s) { return s.trim(); }) : function (s) { return ts.trimStringEnd(ts.trimStringStart(s)); }; + /** + * Returns a copy with trailing whitespace removed. + */ + ts.trimStringEnd = !!String.prototype.trimEnd ? (function (s) { return s.trimEnd(); }) : trimEndImpl; + /** + * Returns a copy with leading whitespace removed. + */ + ts.trimStringStart = !!String.prototype.trimStart ? (function (s) { return s.trimStart(); }) : function (s) { return s.replace(/^\s+/g, ""); }; + /** + * https://jsbench.me/gjkoxld4au/1 + * The simple regex for this, /\s+$/g is O(n^2) in v8. + * The native .trimEnd method is by far best, but since that's technically ES2019, + * we provide a (still much faster than the simple regex) fallback. + */ + function trimEndImpl(s) { + var end = s.length - 1; + while (end >= 0) { + if (!ts.isWhiteSpaceLike(s.charCodeAt(end))) + break; + end--; + } + return s.slice(0, end + 1); + } })(ts || (ts = {})); /* @internal */ var ts; @@ -2389,6 +2452,8 @@ var ts; } } Debug.assertMissingNode = assertMissingNode; + function type(_value) { } + Debug.type = type; function getFunctionName(func) { if (typeof func !== "function") { return ""; @@ -2566,6 +2631,9 @@ var ts; // An `Array` with extra properties is rendered as `[A, B, prop1: 1, prop2: 2]`. Most of // these aren't immediately useful so we trim off the `prop1: ..., prop2: ...` part from the // formatted string. + // This regex can trigger slow backtracking because of overlapping potential captures. + // 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; } @@ -2650,11 +2718,11 @@ var ts; this.objectFlags & 8 /* Tuple */ ? "TupleType" : this.objectFlags & 16 /* Anonymous */ ? "AnonymousType" : this.objectFlags & 32 /* Mapped */ ? "MappedType" : - this.objectFlags & 2048 /* ReverseMapped */ ? "ReverseMappedType" : + this.objectFlags & 1024 /* ReverseMapped */ ? "ReverseMappedType" : this.objectFlags & 256 /* EvolvingArray */ ? "EvolvingArrayType" : "ObjectType" : "Type"; - var remainingObjectFlags = this.flags & 524288 /* Object */ ? this.objectFlags & ~2367 /* ObjectTypeKindMask */ : 0; + var remainingObjectFlags = this.flags & 524288 /* Object */ ? this.objectFlags & ~1343 /* ObjectTypeKindMask */ : 0; return "" + typeHeader + (this.symbol ? " '" + ts.symbolName(this.symbol) + "'" : "") + (remainingObjectFlags ? " (" + formatObjectFlags(remainingObjectFlags) + ")" : ""); } }, @@ -3014,7 +3082,7 @@ var ts; // range-set ::= range ( logical-or range ) * // range ::= hyphen | simple ( ' ' simple ) * | '' // logical-or ::= ( ' ' ) * '||' ( ' ' ) * - var logicalOrRegExp = /\s*\|\|\s*/g; + var logicalOrRegExp = /\|\|/g; var whitespaceRegExp = /\s+/g; // https://github.com/npm/node-semver#range-grammar // @@ -3037,14 +3105,15 @@ var ts; // primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial // tilde ::= '~' partial // caret ::= '^' partial - var rangeRegExp = /^\s*(~|\^|<|<=|>|>=|=)?\s*([a-z0-9-+.*]+)$/i; + var rangeRegExp = /^(~|\^|<|<=|>|>=|=)?\s*([a-z0-9-+.*]+)$/i; function parseRange(text) { var alternatives = []; - for (var _i = 0, _a = text.trim().split(logicalOrRegExp); _i < _a.length; _i++) { + for (var _i = 0, _a = ts.trimString(text).split(logicalOrRegExp); _i < _a.length; _i++) { var range = _a[_i]; if (!range) continue; var comparators = []; + range = ts.trimString(range); var match = hyphenRegExp.exec(range); if (match) { if (!parseHyphen(match[1], match[2], comparators)) @@ -3053,7 +3122,7 @@ var ts; else { for (var _b = 0, _c = range.split(whitespaceRegExp); _b < _c.length; _b++) { var simple = _c[_b]; - var match_1 = rangeRegExp.exec(simple); + var match_1 = rangeRegExp.exec(ts.trimString(simple)); if (!match_1 || !parseComparator(match_1[1], match_1[2], comparators)) return undefined; } @@ -3200,16 +3269,22 @@ var ts; typeof PerformanceObserver === "function" && hasRequiredAPI(performance, PerformanceObserver)) { return { + // For now we always write native performance events when running in the browser. We may + // make this conditional in the future if we find that native web performance hooks + // in the browser also slow down compilation. + shouldWriteNativeEvents: true, performance: performance, PerformanceObserver: PerformanceObserver }; } } function tryGetNodePerformanceHooks() { - if (typeof module === "object" && typeof require === "function") { + if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof module === "object" && typeof require === "function") { try { - var _a = require("perf_hooks"), performance_1 = _a.performance, PerformanceObserver_1 = _a.PerformanceObserver; - if (hasRequiredAPI(performance_1, PerformanceObserver_1)) { + var performance_1; + var _a = require("perf_hooks"), nodePerformance_1 = _a.performance, PerformanceObserver_1 = _a.PerformanceObserver; + if (hasRequiredAPI(nodePerformance_1, PerformanceObserver_1)) { + performance_1 = nodePerformance_1; // There is a bug in Node's performance.measure prior to 12.16.3/13.13.0 that does not // match the Web Performance API specification. Node's implementation did not allow // optional `start` and `end` arguments for `performance.measure`. @@ -3217,27 +3292,26 @@ var ts; var version_1 = new ts.Version(process.versions.node); var range = new ts.VersionRange("<12.16.3 || 13 <13.13"); if (range.test(version_1)) { - return { - performance: { - get timeOrigin() { return performance_1.timeOrigin; }, - now: function () { return performance_1.now(); }, - mark: function (name) { return performance_1.mark(name); }, - measure: function (name, start, end) { - if (start === void 0) { start = "nodeStart"; } - if (end === undefined) { - end = "__performance.measure-fix__"; - performance_1.mark(end); - } - performance_1.measure(name, start, end); - if (end === "__performance.measure-fix__") { - performance_1.clearMarks("__performance.measure-fix__"); - } + performance_1 = { + get timeOrigin() { return nodePerformance_1.timeOrigin; }, + now: function () { return nodePerformance_1.now(); }, + mark: function (name) { return nodePerformance_1.mark(name); }, + measure: function (name, start, end) { + if (start === void 0) { start = "nodeStart"; } + if (end === undefined) { + end = "__performance.measure-fix__"; + nodePerformance_1.mark(end); + } + nodePerformance_1.measure(name, start, end); + if (end === "__performance.measure-fix__") { + nodePerformance_1.clearMarks("__performance.measure-fix__"); } - }, - PerformanceObserver: PerformanceObserver_1 + } }; } return { + // By default, only write native events when generating a cpu profile or using the v8 profiler. + shouldWriteNativeEvents: false, performance: performance_1, PerformanceObserver: PerformanceObserver_1 }; @@ -3268,7 +3342,6 @@ var ts; var performance; (function (performance) { var perfHooks; - var perfObserver; // when set, indicates the implementation of `Performance` to use for user timing. // when unset, indicates user timing is unavailable or disabled. var performanceImpl; @@ -3299,6 +3372,9 @@ var ts; } performance.createTimer = createTimer; performance.nullTimer = { enter: ts.noop, exit: ts.noop }; + var enabled = false; + var timeorigin = ts.timestamp(); + var marks = new ts.Map(); var counts = new ts.Map(); var durations = new ts.Map(); /** @@ -3307,7 +3383,13 @@ var ts; * @param markName The name of the mark. */ function mark(markName) { - performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.mark(markName); + var _a; + if (enabled) { + var count = (_a = counts.get(markName)) !== null && _a !== void 0 ? _a : 0; + counts.set(markName, count + 1); + marks.set(markName, ts.timestamp()); + performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.mark(markName); + } } performance.mark = mark; /** @@ -3320,7 +3402,14 @@ var ts; * used. */ function measure(measureName, startMarkName, endMarkName) { - performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.measure(measureName, startMarkName, endMarkName); + var _a, _b; + if (enabled) { + var end = (_a = (endMarkName !== undefined ? marks.get(endMarkName) : undefined)) !== null && _a !== void 0 ? _a : ts.timestamp(); + var start = (_b = (startMarkName !== undefined ? marks.get(startMarkName) : undefined)) !== null && _b !== void 0 ? _b : timeorigin; + var previousDuration = durations.get(measureName) || 0; + durations.set(measureName, previousDuration + (end - start)); + performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.measure(measureName, startMarkName, endMarkName); + } } performance.measure = measure; /** @@ -3354,40 +3443,41 @@ var ts; * Indicates whether the performance API is enabled. */ function isEnabled() { - return !!performanceImpl; + return enabled; } performance.isEnabled = isEnabled; /** Enables (and resets) performance measurements for the compiler. */ - function enable() { - if (!performanceImpl) { + function enable(system) { + var _a; + if (system === void 0) { system = ts.sys; } + if (!enabled) { + enabled = true; perfHooks || (perfHooks = ts.tryGetNativePerformanceHooks()); - if (!perfHooks) - return false; - perfObserver || (perfObserver = new perfHooks.PerformanceObserver(updateStatisticsFromList)); - perfObserver.observe({ entryTypes: ["mark", "measure"] }); - performanceImpl = perfHooks.performance; + if (perfHooks) { + timeorigin = perfHooks.performance.timeOrigin; + // NodeJS's Web Performance API is currently slower than expected, but we'd still like + // to be able to leverage native trace events when node is run with either `--cpu-prof` + // or `--prof`, if we're running with our own `--generateCpuProfile` flag, or when + // running in debug mode (since its possible to generate a cpu profile while debugging). + if (perfHooks.shouldWriteNativeEvents || ((_a = system === null || system === void 0 ? void 0 : system.cpuProfilingEnabled) === null || _a === void 0 ? void 0 : _a.call(system)) || (system === null || system === void 0 ? void 0 : system.debugMode)) { + performanceImpl = perfHooks.performance; + } + } } return true; } performance.enable = enable; /** Disables performance measurements for the compiler. */ function disable() { - perfObserver === null || perfObserver === void 0 ? void 0 : perfObserver.disconnect(); - performanceImpl = undefined; - counts.clear(); - durations.clear(); - } - performance.disable = disable; - function updateStatisticsFromList(list) { - for (var _i = 0, _a = list.getEntriesByType("mark"); _i < _a.length; _i++) { - var mark_1 = _a[_i]; - counts.set(mark_1.name, (counts.get(mark_1.name) || 0) + 1); - } - for (var _b = 0, _c = list.getEntriesByType("measure"); _b < _c.length; _b++) { - var measure_1 = _c[_b]; - durations.set(measure_1.name, (durations.get(measure_1.name) || 0) + measure_1.duration); + if (enabled) { + marks.clear(); + counts.clear(); + durations.clear(); + performanceImpl = undefined; + enabled = false; } } + performance.disable = disable; })(performance = ts.performance || (ts.performance = {})); })(ts || (ts = {})); /* @internal */ @@ -3431,40 +3521,35 @@ var ts; /** Performance logger that will generate ETW events if possible - check for `logEvent` member, as `etwModule` will be `{}` when browserified */ ts.perfLogger = etwModule && etwModule.logEvent ? etwModule : nullLogger; })(ts || (ts = {})); +/* Tracing events for the compiler. */ /*@internal*/ -/** Tracing events for the compiler. */ var ts; (function (ts) { - var tracing; - (function (tracing) { - var Mode; - (function (Mode) { - Mode[Mode["Project"] = 0] = "Project"; - Mode[Mode["Build"] = 1] = "Build"; - Mode[Mode["Server"] = 2] = "Server"; - })(Mode = tracing.Mode || (tracing.Mode = {})); + // enable the above using startTracing() + // `tracingEnabled` should never be used directly, only through the above + var tracingEnabled; + (function (tracingEnabled) { var fs; var traceCount = 0; - var traceFd; + var traceFd = 0; var mode; + var typeCatalog = []; // NB: id is index + 1 var legendPath; var legend = []; ; - /** Starts tracing for the given project (unless the `fs` module is unavailable). */ + /** Starts tracing for the given project. */ function startTracing(tracingMode, traceDir, configFilePath) { - ts.Debug.assert(!traceFd, "Tracing already started"); + ts.Debug.assert(!ts.tracing, "Tracing already started"); if (fs === undefined) { try { fs = require("fs"); } - catch (_a) { - fs = false; + catch (e) { + throw new Error("tracing requires having fs\n(original error: " + (e.message || e) + ")"); } } - if (!fs) { - return; - } mode = tracingMode; + typeCatalog.length = 0; if (legendPath === undefined) { legendPath = ts.combinePaths(traceDir, "legend.json"); } @@ -3472,9 +3557,9 @@ var ts; if (!fs.existsSync(traceDir)) { fs.mkdirSync(traceDir, { recursive: true }); } - var countPart = mode === 1 /* Build */ ? "." + process.pid + "-" + ++traceCount : - mode === 2 /* Server */ ? "." + process.pid : - ""; + var countPart = mode === "build" ? "." + process.pid + "-" + ++traceCount + : mode === "server" ? "." + process.pid + : ""; var tracePath = ts.combinePaths(traceDir, "trace" + countPart + ".json"); var typesPath = ts.combinePaths(traceDir, "types" + countPart + ".json"); legend.push({ @@ -3483,25 +3568,22 @@ var ts; typesPath: typesPath, }); traceFd = fs.openSync(tracePath, "w"); + ts.tracing = tracingEnabled; // only when traceFd is properly set // Start with a prefix that contains some metadata that the devtools profiler expects (also avoids a warning on import) var meta = { cat: "__metadata", ph: "M", ts: 1000 * ts.timestamp(), pid: 1, tid: 1 }; fs.writeSync(traceFd, "[\n" + [__assign({ name: "process_name", args: { name: "tsc" } }, meta), __assign({ name: "thread_name", args: { name: "Main" } }, meta), __assign(__assign({ name: "TracingStartedInBrowser" }, meta), { cat: "disabled-by-default-devtools.timeline" })] .map(function (v) { return JSON.stringify(v); }).join(",\n")); } - tracing.startTracing = startTracing; - /** Stops tracing for the in-progress project and dumps the type catalog (unless the `fs` module is unavailable). */ - function stopTracing(typeCatalog) { - if (!traceFd) { - ts.Debug.assert(!fs, "Tracing is not in progress"); - return; - } - ts.Debug.assert(fs); - ts.Debug.assert(!!typeCatalog === (mode !== 2 /* Server */)); // Have a type catalog iff not in server mode + tracingEnabled.startTracing = startTracing; + /** Stops tracing for the in-progress project and dumps the type catalog. */ + function stopTracing() { + ts.Debug.assert(ts.tracing, "Tracing is not in progress"); + ts.Debug.assert(!!typeCatalog.length === (mode !== "server")); // Have a type catalog iff not in server mode fs.writeSync(traceFd, "\n]\n"); fs.closeSync(traceFd); - traceFd = undefined; - if (typeCatalog) { + ts.tracing = undefined; + if (typeCatalog.length) { dumpTypes(typeCatalog); } else { @@ -3510,11 +3592,13 @@ var ts; legend[legend.length - 1].typesPath = undefined; } } - tracing.stopTracing = stopTracing; - function isTracing() { - return !!traceFd; + tracingEnabled.stopTracing = stopTracing; + function recordType(type) { + if (mode !== "server") { + typeCatalog.push(type); + } } - tracing.isTracing = isTracing; + tracingEnabled.recordType = recordType; var Phase; (function (Phase) { Phase["Parse"] = "parse"; @@ -3524,13 +3608,11 @@ var ts; Phase["CheckTypes"] = "checkTypes"; Phase["Emit"] = "emit"; Phase["Session"] = "session"; - })(Phase = tracing.Phase || (tracing.Phase = {})); + })(Phase = tracingEnabled.Phase || (tracingEnabled.Phase = {})); function instant(phase, name, args) { - if (!traceFd) - return; writeEvent("I", phase, name, args, "\"s\":\"g\""); } - tracing.instant = instant; + tracingEnabled.instant = instant; var eventStack = []; /** * @param separateBeginAndEnd - used for special cases where we need the trace point even if the event @@ -3540,47 +3622,42 @@ var ts; */ function push(phase, name, args, separateBeginAndEnd) { if (separateBeginAndEnd === void 0) { separateBeginAndEnd = false; } - if (!traceFd) - return; if (separateBeginAndEnd) { writeEvent("B", phase, name, args); } eventStack.push({ phase: phase, name: name, args: args, time: 1000 * ts.timestamp(), separateBeginAndEnd: separateBeginAndEnd }); } - tracing.push = push; + tracingEnabled.push = push; function pop() { - if (!traceFd) - return; ts.Debug.assert(eventStack.length > 0); writeStackEvent(eventStack.length - 1, 1000 * ts.timestamp()); eventStack.length--; } - tracing.pop = pop; + tracingEnabled.pop = pop; function popAll() { - if (!traceFd) - return; var endTime = 1000 * ts.timestamp(); for (var i = eventStack.length - 1; i >= 0; i--) { writeStackEvent(i, endTime); } eventStack.length = 0; } - tracing.popAll = popAll; + tracingEnabled.popAll = popAll; + // sample every 10ms + var sampleInterval = 1000 * 10; function writeStackEvent(index, endTime) { var _a = eventStack[index], phase = _a.phase, name = _a.name, args = _a.args, time = _a.time, separateBeginAndEnd = _a.separateBeginAndEnd; if (separateBeginAndEnd) { writeEvent("E", phase, name, args, /*extras*/ undefined, endTime); } - else { + // test if [time,endTime) straddles a sampling point + else if (sampleInterval - (time % sampleInterval) <= endTime - time) { writeEvent("X", phase, name, args, "\"dur\":" + (endTime - time), time); } } function writeEvent(eventType, phase, name, args, extras, time) { if (time === void 0) { time = 1000 * ts.timestamp(); } - ts.Debug.assert(traceFd); - ts.Debug.assert(fs); // In server mode, there's no easy way to dump type information, so we drop events that would require it. - if (mode === 2 /* Server */ && phase === "checkTypes" /* CheckTypes */) + if (mode === "server" && phase === "checkTypes" /* CheckTypes */) return; ts.performance.mark("beginTracing"); fs.writeSync(traceFd, ",\n{\"pid\":1,\"tid\":1,\"ph\":\"" + eventType + "\",\"cat\":\"" + phase + "\",\"ts\":" + time + ",\"name\":\"" + name + "\""); @@ -3592,15 +3669,24 @@ var ts; ts.performance.mark("endTracing"); ts.performance.measure("Tracing", "beginTracing", "endTracing"); } - function indexFromOne(lc) { - return { - line: lc.line + 1, - character: lc.character + 1, - }; + function getLocation(node) { + var file = ts.getSourceFileOfNode(node); + return !file + ? undefined + : { + path: file.path, + start: indexFromOne(ts.getLineAndCharacterOfPosition(file, node.pos)), + end: indexFromOne(ts.getLineAndCharacterOfPosition(file, node.end)), + }; + function indexFromOne(lc) { + return { + line: lc.line + 1, + character: lc.character + 1, + }; + } } function dumpTypes(types) { - var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r; - ts.Debug.assert(fs); + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x; ts.performance.mark("beginDumpTypes"); var typesPath = legend[legend.length - 1].typesPath; var typesFd = fs.openSync(typesPath, "w"); @@ -3612,15 +3698,13 @@ var ts; var type = types[i]; var objectFlags = type.objectFlags; var symbol = (_a = type.aliasSymbol) !== null && _a !== void 0 ? _a : type.symbol; - var firstDeclaration = (_b = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _b === void 0 ? void 0 : _b[0]; - var firstFile = firstDeclaration && ts.getSourceFileOfNode(firstDeclaration); // 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 */)) { try { - display = (_c = type.checker) === null || _c === void 0 ? void 0 : _c.typeToString(type); + display = (_b = type.checker) === null || _b === void 0 ? void 0 : _b.typeToString(type); } - catch (_s) { + catch (_y) { display = undefined; } } @@ -3628,26 +3712,52 @@ var ts; if (type.flags & 8388608 /* IndexedAccess */) { var indexedAccessType = type; indexedAccessProperties = { - indexedAccessObjectType: (_d = indexedAccessType.objectType) === null || _d === void 0 ? void 0 : _d.id, - indexedAccessIndexType: (_e = indexedAccessType.indexType) === null || _e === void 0 ? void 0 : _e.id, + indexedAccessObjectType: (_c = indexedAccessType.objectType) === null || _c === void 0 ? void 0 : _c.id, + indexedAccessIndexType: (_d = indexedAccessType.indexType) === null || _d === void 0 ? void 0 : _d.id, }; } var referenceProperties = {}; if (objectFlags & 4 /* Reference */) { var referenceType = type; referenceProperties = { - instantiatedType: (_f = referenceType.target) === null || _f === void 0 ? void 0 : _f.id, - typeArguments: (_g = referenceType.resolvedTypeArguments) === null || _g === void 0 ? void 0 : _g.map(function (t) { return t.id; }), + instantiatedType: (_e = referenceType.target) === null || _e === void 0 ? void 0 : _e.id, + typeArguments: (_f = referenceType.resolvedTypeArguments) === null || _f === void 0 ? void 0 : _f.map(function (t) { return t.id; }), + referenceLocation: getLocation(referenceType.node), }; } var conditionalProperties = {}; if (type.flags & 16777216 /* Conditional */) { var conditionalType = type; conditionalProperties = { - conditionalCheckType: (_h = conditionalType.checkType) === null || _h === void 0 ? void 0 : _h.id, - conditionalExtendsType: (_j = conditionalType.extendsType) === null || _j === void 0 ? void 0 : _j.id, - conditionalTrueType: (_l = (_k = conditionalType.resolvedTrueType) === null || _k === void 0 ? void 0 : _k.id) !== null && _l !== void 0 ? _l : -1, - conditionalFalseType: (_o = (_m = conditionalType.resolvedFalseType) === null || _m === void 0 ? void 0 : _m.id) !== null && _o !== void 0 ? _o : -1, + conditionalCheckType: (_g = conditionalType.checkType) === null || _g === void 0 ? void 0 : _g.id, + conditionalExtendsType: (_h = conditionalType.extendsType) === null || _h === void 0 ? void 0 : _h.id, + conditionalTrueType: (_k = (_j = conditionalType.resolvedTrueType) === null || _j === void 0 ? void 0 : _j.id) !== null && _k !== void 0 ? _k : -1, + conditionalFalseType: (_m = (_l = conditionalType.resolvedFalseType) === null || _l === void 0 ? void 0 : _l.id) !== null && _m !== void 0 ? _m : -1, + }; + } + var substitutionProperties = {}; + if (type.flags & 33554432 /* Substitution */) { + var substitutionType = type; + substitutionProperties = { + substitutionBaseType: (_o = substitutionType.baseType) === null || _o === void 0 ? void 0 : _o.id, + substituteType: (_p = substitutionType.substitute) === null || _p === void 0 ? void 0 : _p.id, + }; + } + var reverseMappedProperties = {}; + if (objectFlags & 1024 /* ReverseMapped */) { + var reverseMappedType = type; + reverseMappedProperties = { + reverseMappedSourceType: (_q = reverseMappedType.source) === null || _q === void 0 ? void 0 : _q.id, + reverseMappedMappedType: (_r = reverseMappedType.mappedType) === null || _r === void 0 ? void 0 : _r.id, + reverseMappedConstraintType: (_s = reverseMappedType.constraintType) === null || _s === void 0 ? void 0 : _s.id, + }; + } + var evolvingArrayProperties = {}; + if (objectFlags & 256 /* EvolvingArray */) { + var evolvingArrayType = type; + evolvingArrayProperties = { + evolvingArrayElementType: evolvingArrayType.elementType.id, + evolvingArrayFinalType: (_t = evolvingArrayType.finalArrayType) === null || _t === void 0 ? void 0 : _t.id, }; } // We can't print out an arbitrary object, so just assign each one a unique number. @@ -3661,11 +3771,7 @@ var ts; recursionIdentityMap.set(recursionIdentity, recursionToken); } } - var descriptor = __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, unionTypes: (type.flags & 1048576 /* Union */) ? (_p = type.types) === null || _p === void 0 ? void 0 : _p.map(function (t) { return t.id; }) : undefined, intersectionTypes: (type.flags & 2097152 /* Intersection */) ? type.types.map(function (t) { return t.id; }) : undefined, aliasTypeArguments: (_q = type.aliasTypeArguments) === null || _q === void 0 ? void 0 : _q.map(function (t) { return t.id; }), keyofType: (type.flags & 4194304 /* Index */) ? (_r = type.type) === null || _r === void 0 ? void 0 : _r.id : undefined }, indexedAccessProperties), referenceProperties), conditionalProperties), { firstDeclaration: firstDeclaration && { - path: firstFile.path, - start: indexFromOne(ts.getLineAndCharacterOfPosition(firstFile, firstDeclaration.pos)), - end: indexFromOne(ts.getLineAndCharacterOfPosition(ts.getSourceFileOfNode(firstDeclaration), firstDeclaration.end)), - }, 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 /* 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 }); fs.writeSync(typesFd, JSON.stringify(descriptor)); if (i < numTypes - 1) { fs.writeSync(typesFd, ",\n"); @@ -3680,11 +3786,13 @@ var ts; if (!legendPath) { return; } - ts.Debug.assert(fs); fs.writeFileSync(legendPath, JSON.stringify(legend)); } - tracing.dumpLegend = dumpLegend; - })(tracing = ts.tracing || (ts.tracing = {})); + tracingEnabled.dumpLegend = dumpLegend; + })(tracingEnabled || (tracingEnabled = {})); + // define after tracingEnabled is initialized + ts.startTracing = tracingEnabled.startTracing; + ts.dumpTracingLegend = tracingEnabled.dumpLegend; })(ts || (ts = {})); var ts; (function (ts) { @@ -3761,331 +3869,337 @@ var ts; SyntaxKind[SyntaxKind["QuestionQuestionToken"] = 60] = "QuestionQuestionToken"; /** Only the JSDoc scanner produces BacktickToken. The normal scanner produces NoSubstitutionTemplateLiteral and related kinds. */ SyntaxKind[SyntaxKind["BacktickToken"] = 61] = "BacktickToken"; + /** Only the JSDoc scanner produces HashToken. The normal scanner produces PrivateIdentifier. */ + SyntaxKind[SyntaxKind["HashToken"] = 62] = "HashToken"; // Assignments - SyntaxKind[SyntaxKind["EqualsToken"] = 62] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 63] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 64] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 65] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 66] = "AsteriskAsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 67] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 68] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 69] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 70] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 71] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 72] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 73] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["BarBarEqualsToken"] = 74] = "BarBarEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandEqualsToken"] = 75] = "AmpersandAmpersandEqualsToken"; - SyntaxKind[SyntaxKind["QuestionQuestionEqualsToken"] = 76] = "QuestionQuestionEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 77] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 63] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 64] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 65] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 66] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 67] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 68] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 69] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 70] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 71] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 72] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 73] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 74] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["BarBarEqualsToken"] = 75] = "BarBarEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandEqualsToken"] = 76] = "AmpersandAmpersandEqualsToken"; + SyntaxKind[SyntaxKind["QuestionQuestionEqualsToken"] = 77] = "QuestionQuestionEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 78] = "CaretEqualsToken"; // Identifiers and PrivateIdentifiers - SyntaxKind[SyntaxKind["Identifier"] = 78] = "Identifier"; - SyntaxKind[SyntaxKind["PrivateIdentifier"] = 79] = "PrivateIdentifier"; + SyntaxKind[SyntaxKind["Identifier"] = 79] = "Identifier"; + SyntaxKind[SyntaxKind["PrivateIdentifier"] = 80] = "PrivateIdentifier"; // Reserved words - SyntaxKind[SyntaxKind["BreakKeyword"] = 80] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 81] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 82] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 83] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 84] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 85] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 86] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 87] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 88] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 89] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 90] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 91] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 92] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 93] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 94] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 95] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 96] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 97] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 98] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 99] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 100] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 101] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 102] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 103] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 104] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 105] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 106] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 107] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 108] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 109] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 110] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 111] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 112] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 113] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 114] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 115] = "WithKeyword"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 81] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 82] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 83] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 84] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 85] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 86] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 87] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 88] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 89] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 90] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 91] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 92] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 93] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 94] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 95] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 96] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 97] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 98] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 99] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 100] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 101] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 102] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 103] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 104] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 105] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 106] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 107] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 108] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 109] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 110] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 111] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 112] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 113] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 114] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 115] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 116] = "WithKeyword"; // Strict mode reserved words - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 116] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 117] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 118] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 119] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 120] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 121] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 122] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 123] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 124] = "YieldKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 117] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 118] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 119] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 120] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 121] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 122] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 123] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 124] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 125] = "YieldKeyword"; // Contextual keywords - SyntaxKind[SyntaxKind["AbstractKeyword"] = 125] = "AbstractKeyword"; - SyntaxKind[SyntaxKind["AsKeyword"] = 126] = "AsKeyword"; - SyntaxKind[SyntaxKind["AssertsKeyword"] = 127] = "AssertsKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 128] = "AnyKeyword"; - SyntaxKind[SyntaxKind["AsyncKeyword"] = 129] = "AsyncKeyword"; - SyntaxKind[SyntaxKind["AwaitKeyword"] = 130] = "AwaitKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 131] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 132] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 133] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 134] = "GetKeyword"; - SyntaxKind[SyntaxKind["InferKeyword"] = 135] = "InferKeyword"; - SyntaxKind[SyntaxKind["IntrinsicKeyword"] = 136] = "IntrinsicKeyword"; - SyntaxKind[SyntaxKind["IsKeyword"] = 137] = "IsKeyword"; - SyntaxKind[SyntaxKind["KeyOfKeyword"] = 138] = "KeyOfKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 139] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["NamespaceKeyword"] = 140] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["NeverKeyword"] = 141] = "NeverKeyword"; - SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 142] = "ReadonlyKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 143] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 144] = "NumberKeyword"; - SyntaxKind[SyntaxKind["ObjectKeyword"] = 145] = "ObjectKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 146] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 147] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 148] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 149] = "TypeKeyword"; - SyntaxKind[SyntaxKind["UndefinedKeyword"] = 150] = "UndefinedKeyword"; - SyntaxKind[SyntaxKind["UniqueKeyword"] = 151] = "UniqueKeyword"; - SyntaxKind[SyntaxKind["UnknownKeyword"] = 152] = "UnknownKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 153] = "FromKeyword"; - SyntaxKind[SyntaxKind["GlobalKeyword"] = 154] = "GlobalKeyword"; - SyntaxKind[SyntaxKind["BigIntKeyword"] = 155] = "BigIntKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 156] = "OfKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 126] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 127] = "AsKeyword"; + SyntaxKind[SyntaxKind["AssertsKeyword"] = 128] = "AssertsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 129] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 130] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 131] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 132] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 133] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 134] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 135] = "GetKeyword"; + SyntaxKind[SyntaxKind["InferKeyword"] = 136] = "InferKeyword"; + SyntaxKind[SyntaxKind["IntrinsicKeyword"] = 137] = "IntrinsicKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 138] = "IsKeyword"; + SyntaxKind[SyntaxKind["KeyOfKeyword"] = 139] = "KeyOfKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 140] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 141] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 142] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 143] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 144] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 145] = "NumberKeyword"; + SyntaxKind[SyntaxKind["ObjectKeyword"] = 146] = "ObjectKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 147] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 148] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 149] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 150] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 151] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["UniqueKeyword"] = 152] = "UniqueKeyword"; + SyntaxKind[SyntaxKind["UnknownKeyword"] = 153] = "UnknownKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 154] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 155] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["BigIntKeyword"] = 156] = "BigIntKeyword"; + SyntaxKind[SyntaxKind["OverrideKeyword"] = 157] = "OverrideKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 158] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 157] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 158] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 159] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 160] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 159] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 160] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 161] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 161] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 162] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 163] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 162] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 163] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 164] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 165] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 166] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 167] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 168] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 169] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 170] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 171] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 164] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 165] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 166] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 167] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 168] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 169] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 170] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 171] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 172] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 173] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 172] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 173] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 174] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 175] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 176] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 177] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 178] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 179] = "TupleType"; - SyntaxKind[SyntaxKind["OptionalType"] = 180] = "OptionalType"; - SyntaxKind[SyntaxKind["RestType"] = 181] = "RestType"; - SyntaxKind[SyntaxKind["UnionType"] = 182] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 183] = "IntersectionType"; - SyntaxKind[SyntaxKind["ConditionalType"] = 184] = "ConditionalType"; - SyntaxKind[SyntaxKind["InferType"] = 185] = "InferType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 186] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 187] = "ThisType"; - SyntaxKind[SyntaxKind["TypeOperator"] = 188] = "TypeOperator"; - SyntaxKind[SyntaxKind["IndexedAccessType"] = 189] = "IndexedAccessType"; - SyntaxKind[SyntaxKind["MappedType"] = 190] = "MappedType"; - SyntaxKind[SyntaxKind["LiteralType"] = 191] = "LiteralType"; - SyntaxKind[SyntaxKind["NamedTupleMember"] = 192] = "NamedTupleMember"; - SyntaxKind[SyntaxKind["TemplateLiteralType"] = 193] = "TemplateLiteralType"; - SyntaxKind[SyntaxKind["TemplateLiteralTypeSpan"] = 194] = "TemplateLiteralTypeSpan"; - SyntaxKind[SyntaxKind["ImportType"] = 195] = "ImportType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 174] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 175] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 176] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 177] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 178] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 179] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 180] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 181] = "TupleType"; + SyntaxKind[SyntaxKind["OptionalType"] = 182] = "OptionalType"; + SyntaxKind[SyntaxKind["RestType"] = 183] = "RestType"; + SyntaxKind[SyntaxKind["UnionType"] = 184] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 185] = "IntersectionType"; + SyntaxKind[SyntaxKind["ConditionalType"] = 186] = "ConditionalType"; + SyntaxKind[SyntaxKind["InferType"] = 187] = "InferType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 188] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 189] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 190] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 191] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 192] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 193] = "LiteralType"; + SyntaxKind[SyntaxKind["NamedTupleMember"] = 194] = "NamedTupleMember"; + SyntaxKind[SyntaxKind["TemplateLiteralType"] = 195] = "TemplateLiteralType"; + SyntaxKind[SyntaxKind["TemplateLiteralTypeSpan"] = 196] = "TemplateLiteralTypeSpan"; + SyntaxKind[SyntaxKind["ImportType"] = 197] = "ImportType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 196] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 197] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 198] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 198] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 199] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 200] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 199] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 200] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 201] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 202] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 203] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 204] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 205] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 206] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 207] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 208] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 209] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 210] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 211] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 212] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 213] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 214] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 215] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 216] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 217] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 218] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 219] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElement"] = 220] = "SpreadElement"; - SyntaxKind[SyntaxKind["ClassExpression"] = 221] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 222] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 223] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 224] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 225] = "NonNullExpression"; - SyntaxKind[SyntaxKind["MetaProperty"] = 226] = "MetaProperty"; - SyntaxKind[SyntaxKind["SyntheticExpression"] = 227] = "SyntheticExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 201] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 202] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 203] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 204] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 205] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 206] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 207] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 208] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 209] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 210] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 211] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 212] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 213] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 214] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 215] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 216] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 217] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 218] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 219] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 220] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 221] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 222] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 223] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 224] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 225] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 226] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 227] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 228] = "MetaProperty"; + SyntaxKind[SyntaxKind["SyntheticExpression"] = 229] = "SyntheticExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 228] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 229] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 230] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 231] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 230] = "Block"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 231] = "EmptyStatement"; - SyntaxKind[SyntaxKind["VariableStatement"] = 232] = "VariableStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 233] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 234] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 235] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 236] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 237] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 238] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 239] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 240] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 241] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 242] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 243] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 244] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 245] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 246] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 247] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 248] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 249] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 250] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 251] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 252] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 253] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 254] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 255] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 256] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 257] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 258] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 259] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 260] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 261] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 262] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 263] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 264] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 265] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 266] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 267] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 268] = "NamedExports"; - SyntaxKind[SyntaxKind["NamespaceExport"] = 269] = "NamespaceExport"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 270] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 271] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 232] = "Block"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 233] = "EmptyStatement"; + SyntaxKind[SyntaxKind["VariableStatement"] = 234] = "VariableStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 235] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 236] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 237] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 238] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 239] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 240] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 241] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 242] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 243] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 244] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 245] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 246] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 247] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 248] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 249] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 250] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 251] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 252] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 253] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 254] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 255] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 256] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 257] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 258] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 259] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 260] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 261] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 262] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 263] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 264] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 265] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 266] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 267] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 268] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 269] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 270] = "NamedExports"; + SyntaxKind[SyntaxKind["NamespaceExport"] = 271] = "NamespaceExport"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 272] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 273] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 272] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 274] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 273] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 274] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 275] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 276] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxFragment"] = 277] = "JsxFragment"; - SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 278] = "JsxOpeningFragment"; - SyntaxKind[SyntaxKind["JsxClosingFragment"] = 279] = "JsxClosingFragment"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 280] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxAttributes"] = 281] = "JsxAttributes"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 282] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 283] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 275] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 276] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 277] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 278] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxFragment"] = 279] = "JsxFragment"; + SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 280] = "JsxOpeningFragment"; + SyntaxKind[SyntaxKind["JsxClosingFragment"] = 281] = "JsxClosingFragment"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 282] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 283] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 284] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 285] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 284] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 285] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 286] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 287] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 286] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 287] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 288] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 289] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 288] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 289] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 290] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 290] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 291] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 292] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 291] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 293] = "EnumMember"; // Unparsed - SyntaxKind[SyntaxKind["UnparsedPrologue"] = 292] = "UnparsedPrologue"; - SyntaxKind[SyntaxKind["UnparsedPrepend"] = 293] = "UnparsedPrepend"; - SyntaxKind[SyntaxKind["UnparsedText"] = 294] = "UnparsedText"; - SyntaxKind[SyntaxKind["UnparsedInternalText"] = 295] = "UnparsedInternalText"; - SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 296] = "UnparsedSyntheticReference"; + SyntaxKind[SyntaxKind["UnparsedPrologue"] = 294] = "UnparsedPrologue"; + SyntaxKind[SyntaxKind["UnparsedPrepend"] = 295] = "UnparsedPrepend"; + SyntaxKind[SyntaxKind["UnparsedText"] = 296] = "UnparsedText"; + SyntaxKind[SyntaxKind["UnparsedInternalText"] = 297] = "UnparsedInternalText"; + SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 298] = "UnparsedSyntheticReference"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 297] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 298] = "Bundle"; - SyntaxKind[SyntaxKind["UnparsedSource"] = 299] = "UnparsedSource"; - SyntaxKind[SyntaxKind["InputFiles"] = 300] = "InputFiles"; + SyntaxKind[SyntaxKind["SourceFile"] = 299] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 300] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 301] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 302] = "InputFiles"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 301] = "JSDocTypeExpression"; - SyntaxKind[SyntaxKind["JSDocNameReference"] = 302] = "JSDocNameReference"; - // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 303] = "JSDocAllType"; - // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 304] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 305] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 306] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 307] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 308] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 309] = "JSDocVariadicType"; - // https://jsdoc.app/about-namepaths.html - SyntaxKind[SyntaxKind["JSDocNamepathType"] = 310] = "JSDocNamepathType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 311] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 312] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocSignature"] = 313] = "JSDocSignature"; - SyntaxKind[SyntaxKind["JSDocTag"] = 314] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 315] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocImplementsTag"] = 316] = "JSDocImplementsTag"; - SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 317] = "JSDocAuthorTag"; - SyntaxKind[SyntaxKind["JSDocDeprecatedTag"] = 318] = "JSDocDeprecatedTag"; - SyntaxKind[SyntaxKind["JSDocClassTag"] = 319] = "JSDocClassTag"; - SyntaxKind[SyntaxKind["JSDocPublicTag"] = 320] = "JSDocPublicTag"; - SyntaxKind[SyntaxKind["JSDocPrivateTag"] = 321] = "JSDocPrivateTag"; - SyntaxKind[SyntaxKind["JSDocProtectedTag"] = 322] = "JSDocProtectedTag"; - SyntaxKind[SyntaxKind["JSDocReadonlyTag"] = 323] = "JSDocReadonlyTag"; - SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 324] = "JSDocCallbackTag"; - SyntaxKind[SyntaxKind["JSDocEnumTag"] = 325] = "JSDocEnumTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 326] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 327] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocThisTag"] = 328] = "JSDocThisTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 329] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 330] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 331] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocSeeTag"] = 332] = "JSDocSeeTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 333] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 303] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocNameReference"] = 304] = "JSDocNameReference"; + SyntaxKind[SyntaxKind["JSDocMemberName"] = 305] = "JSDocMemberName"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 306] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 307] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 308] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 309] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 310] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 311] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 312] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocNamepathType"] = 313] = "JSDocNamepathType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 314] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocText"] = 315] = "JSDocText"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 316] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 317] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocLink"] = 318] = "JSDocLink"; + SyntaxKind[SyntaxKind["JSDocLinkCode"] = 319] = "JSDocLinkCode"; + SyntaxKind[SyntaxKind["JSDocLinkPlain"] = 320] = "JSDocLinkPlain"; + SyntaxKind[SyntaxKind["JSDocTag"] = 321] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 322] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocImplementsTag"] = 323] = "JSDocImplementsTag"; + SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 324] = "JSDocAuthorTag"; + SyntaxKind[SyntaxKind["JSDocDeprecatedTag"] = 325] = "JSDocDeprecatedTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 326] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocPublicTag"] = 327] = "JSDocPublicTag"; + SyntaxKind[SyntaxKind["JSDocPrivateTag"] = 328] = "JSDocPrivateTag"; + SyntaxKind[SyntaxKind["JSDocProtectedTag"] = 329] = "JSDocProtectedTag"; + SyntaxKind[SyntaxKind["JSDocReadonlyTag"] = 330] = "JSDocReadonlyTag"; + SyntaxKind[SyntaxKind["JSDocOverrideTag"] = 331] = "JSDocOverrideTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 332] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocEnumTag"] = 333] = "JSDocEnumTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 334] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 335] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocThisTag"] = 336] = "JSDocThisTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 337] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 338] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 339] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocSeeTag"] = 340] = "JSDocSeeTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 341] = "JSDocPropertyTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 334] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 342] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 335] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 336] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["CommaListExpression"] = 337] = "CommaListExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 338] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 339] = "EndOfDeclarationMarker"; - SyntaxKind[SyntaxKind["SyntheticReferenceExpression"] = 340] = "SyntheticReferenceExpression"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 343] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 344] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 345] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 346] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 347] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["SyntheticReferenceExpression"] = 348] = "SyntheticReferenceExpression"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 341] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 349] = "Count"; // Markers - SyntaxKind[SyntaxKind["FirstAssignment"] = 62] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 77] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 63] = "FirstCompoundAssignment"; - SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 77] = "LastCompoundAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 80] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 115] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 80] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 156] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 116] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 124] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 172] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 195] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 63] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 78] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 64] = "FirstCompoundAssignment"; + SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 78] = "LastCompoundAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 81] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 116] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 81] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 158] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 117] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 125] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 174] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 197] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 18] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 77] = "LastPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 78] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 156] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 158] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; @@ -4093,16 +4207,16 @@ var ts; SyntaxKind[SyntaxKind["FirstTemplateToken"] = 14] = "FirstTemplateToken"; SyntaxKind[SyntaxKind["LastTemplateToken"] = 17] = "LastTemplateToken"; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 29] = "FirstBinaryOperator"; - SyntaxKind[SyntaxKind["LastBinaryOperator"] = 77] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstStatement"] = 232] = "FirstStatement"; - SyntaxKind[SyntaxKind["LastStatement"] = 248] = "LastStatement"; - SyntaxKind[SyntaxKind["FirstNode"] = 157] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 301] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 333] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 314] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 333] = "LastJSDocTagNode"; - /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 125] = "FirstContextualKeyword"; - /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 156] = "LastContextualKeyword"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 78] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstStatement"] = 234] = "FirstStatement"; + SyntaxKind[SyntaxKind["LastStatement"] = 250] = "LastStatement"; + SyntaxKind[SyntaxKind["FirstNode"] = 159] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 303] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 341] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 321] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 341] = "LastJSDocTagNode"; + /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 126] = "FirstContextualKeyword"; + /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 158] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); var NodeFlags; (function (NodeFlags) { @@ -4172,14 +4286,15 @@ var ts; ModifierFlags[ModifierFlags["Const"] = 2048] = "Const"; ModifierFlags[ModifierFlags["HasComputedJSDocModifiers"] = 4096] = "HasComputedJSDocModifiers"; ModifierFlags[ModifierFlags["Deprecated"] = 8192] = "Deprecated"; + ModifierFlags[ModifierFlags["Override"] = 16384] = "Override"; ModifierFlags[ModifierFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; ModifierFlags[ModifierFlags["AccessibilityModifier"] = 28] = "AccessibilityModifier"; // Accessibility modifiers and 'readonly' can be attached to a parameter in a constructor to make it a property. - ModifierFlags[ModifierFlags["ParameterPropertyModifier"] = 92] = "ParameterPropertyModifier"; + ModifierFlags[ModifierFlags["ParameterPropertyModifier"] = 16476] = "ParameterPropertyModifier"; ModifierFlags[ModifierFlags["NonPublicAccessibilityModifier"] = 24] = "NonPublicAccessibilityModifier"; - ModifierFlags[ModifierFlags["TypeScriptModifier"] = 2270] = "TypeScriptModifier"; + ModifierFlags[ModifierFlags["TypeScriptModifier"] = 18654] = "TypeScriptModifier"; ModifierFlags[ModifierFlags["ExportDefault"] = 513] = "ExportDefault"; - ModifierFlags[ModifierFlags["All"] = 11263] = "All"; + ModifierFlags[ModifierFlags["All"] = 27647] = "All"; })(ModifierFlags = ts.ModifierFlags || (ts.ModifierFlags = {})); var JsxFlags; (function (JsxFlags) { @@ -4360,6 +4475,8 @@ var ts; NodeBuilderFlags[NodeBuilderFlags["NoUndefinedOptionalParameterType"] = 1073741824] = "NoUndefinedOptionalParameterType"; // Error handling NodeBuilderFlags[NodeBuilderFlags["AllowThisInObjectLiteral"] = 32768] = "AllowThisInObjectLiteral"; + NodeBuilderFlags[NodeBuilderFlags["AllowQualifiedNameInPlaceOfIdentifier"] = 65536] = "AllowQualifiedNameInPlaceOfIdentifier"; + /** @deprecated AllowQualifedNameInPlaceOfIdentifier. Use AllowQualifiedNameInPlaceOfIdentifier instead. */ NodeBuilderFlags[NodeBuilderFlags["AllowQualifedNameInPlaceOfIdentifier"] = 65536] = "AllowQualifedNameInPlaceOfIdentifier"; NodeBuilderFlags[NodeBuilderFlags["AllowAnonymousIdentifier"] = 131072] = "AllowAnonymousIdentifier"; NodeBuilderFlags[NodeBuilderFlags["AllowEmptyUnionOrIntersection"] = 262144] = "AllowEmptyUnionOrIntersection"; @@ -4374,7 +4491,6 @@ var ts; NodeBuilderFlags[NodeBuilderFlags["InObjectTypeLiteral"] = 4194304] = "InObjectTypeLiteral"; NodeBuilderFlags[NodeBuilderFlags["InTypeAlias"] = 8388608] = "InTypeAlias"; NodeBuilderFlags[NodeBuilderFlags["InInitialEntityName"] = 16777216] = "InInitialEntityName"; - NodeBuilderFlags[NodeBuilderFlags["InReverseMappedType"] = 33554432] = "InReverseMappedType"; })(NodeBuilderFlags = ts.NodeBuilderFlags || (ts.NodeBuilderFlags = {})); // Ensure the shared flags between this and `NodeBuilderFlags` stay in alignment var TypeFormatFlags; @@ -4679,10 +4795,6 @@ var ts; TypeFlags[TypeFlags["Unit"] = 109440] = "Unit"; TypeFlags[TypeFlags["StringOrNumberLiteral"] = 384] = "StringOrNumberLiteral"; /* @internal */ - TypeFlags[TypeFlags["StringLikeLiteral"] = 134217856] = "StringLikeLiteral"; - /* @internal */ - TypeFlags[TypeFlags["FreshableLiteral"] = 134220672] = "FreshableLiteral"; - /* @internal */ TypeFlags[TypeFlags["StringOrNumberLiteralOrUnique"] = 8576] = "StringOrNumberLiteralOrUnique"; /* @internal */ TypeFlags[TypeFlags["DefinitelyFalsy"] = 117632] = "DefinitelyFalsy"; @@ -4731,6 +4843,9 @@ var ts; /* @internal */ TypeFlags[TypeFlags["IncludesEmptyObject"] = 16777216] = "IncludesEmptyObject"; })(TypeFlags = ts.TypeFlags || (ts.TypeFlags = {})); + // Types included in TypeFlags.ObjectFlagsType have an objectFlags property. Some ObjectFlags + // are specific to certain types and reuse the same bit position. Those ObjectFlags require a check + // for a certain TypeFlags value to determine their meaning. var ObjectFlags; (function (ObjectFlags) { ObjectFlags[ObjectFlags["Class"] = 1] = "Class"; @@ -4743,50 +4858,59 @@ var ts; ObjectFlags[ObjectFlags["ObjectLiteral"] = 128] = "ObjectLiteral"; ObjectFlags[ObjectFlags["EvolvingArray"] = 256] = "EvolvingArray"; ObjectFlags[ObjectFlags["ObjectLiteralPatternWithComputedProperties"] = 512] = "ObjectLiteralPatternWithComputedProperties"; - ObjectFlags[ObjectFlags["ContainsSpread"] = 1024] = "ContainsSpread"; - ObjectFlags[ObjectFlags["ReverseMapped"] = 2048] = "ReverseMapped"; - ObjectFlags[ObjectFlags["JsxAttributes"] = 4096] = "JsxAttributes"; - ObjectFlags[ObjectFlags["MarkerType"] = 8192] = "MarkerType"; - ObjectFlags[ObjectFlags["JSLiteral"] = 16384] = "JSLiteral"; - ObjectFlags[ObjectFlags["FreshLiteral"] = 32768] = "FreshLiteral"; - ObjectFlags[ObjectFlags["ArrayLiteral"] = 65536] = "ArrayLiteral"; - ObjectFlags[ObjectFlags["ObjectRestType"] = 131072] = "ObjectRestType"; + ObjectFlags[ObjectFlags["ReverseMapped"] = 1024] = "ReverseMapped"; + ObjectFlags[ObjectFlags["JsxAttributes"] = 2048] = "JsxAttributes"; + ObjectFlags[ObjectFlags["MarkerType"] = 4096] = "MarkerType"; + ObjectFlags[ObjectFlags["JSLiteral"] = 8192] = "JSLiteral"; + ObjectFlags[ObjectFlags["FreshLiteral"] = 16384] = "FreshLiteral"; + ObjectFlags[ObjectFlags["ArrayLiteral"] = 32768] = "ArrayLiteral"; /* @internal */ - ObjectFlags[ObjectFlags["PrimitiveUnion"] = 262144] = "PrimitiveUnion"; + ObjectFlags[ObjectFlags["PrimitiveUnion"] = 65536] = "PrimitiveUnion"; /* @internal */ - ObjectFlags[ObjectFlags["ContainsWideningType"] = 524288] = "ContainsWideningType"; + ObjectFlags[ObjectFlags["ContainsWideningType"] = 131072] = "ContainsWideningType"; /* @internal */ - ObjectFlags[ObjectFlags["ContainsObjectOrArrayLiteral"] = 1048576] = "ContainsObjectOrArrayLiteral"; + ObjectFlags[ObjectFlags["ContainsObjectOrArrayLiteral"] = 262144] = "ContainsObjectOrArrayLiteral"; /* @internal */ - ObjectFlags[ObjectFlags["NonInferrableType"] = 2097152] = "NonInferrableType"; + ObjectFlags[ObjectFlags["NonInferrableType"] = 524288] = "NonInferrableType"; /* @internal */ - ObjectFlags[ObjectFlags["IsGenericObjectTypeComputed"] = 4194304] = "IsGenericObjectTypeComputed"; + ObjectFlags[ObjectFlags["CouldContainTypeVariablesComputed"] = 1048576] = "CouldContainTypeVariablesComputed"; /* @internal */ - ObjectFlags[ObjectFlags["IsGenericObjectType"] = 8388608] = "IsGenericObjectType"; + ObjectFlags[ObjectFlags["CouldContainTypeVariables"] = 2097152] = "CouldContainTypeVariables"; + ObjectFlags[ObjectFlags["ClassOrInterface"] = 3] = "ClassOrInterface"; /* @internal */ - ObjectFlags[ObjectFlags["IsGenericIndexTypeComputed"] = 16777216] = "IsGenericIndexTypeComputed"; + ObjectFlags[ObjectFlags["RequiresWidening"] = 393216] = "RequiresWidening"; /* @internal */ - ObjectFlags[ObjectFlags["IsGenericIndexType"] = 33554432] = "IsGenericIndexType"; + ObjectFlags[ObjectFlags["PropagatingFlags"] = 917504] = "PropagatingFlags"; + // Object flags that uniquely identify the kind of ObjectType /* @internal */ - ObjectFlags[ObjectFlags["CouldContainTypeVariablesComputed"] = 67108864] = "CouldContainTypeVariablesComputed"; + ObjectFlags[ObjectFlags["ObjectTypeKindMask"] = 1343] = "ObjectTypeKindMask"; + // Flags that require TypeFlags.Object + ObjectFlags[ObjectFlags["ContainsSpread"] = 4194304] = "ContainsSpread"; + ObjectFlags[ObjectFlags["ObjectRestType"] = 8388608] = "ObjectRestType"; /* @internal */ - ObjectFlags[ObjectFlags["CouldContainTypeVariables"] = 134217728] = "CouldContainTypeVariables"; + ObjectFlags[ObjectFlags["IsClassInstanceClone"] = 16777216] = "IsClassInstanceClone"; + // Flags that require TypeFlags.Object and ObjectFlags.Reference /* @internal */ - ObjectFlags[ObjectFlags["ContainsIntersections"] = 268435456] = "ContainsIntersections"; + ObjectFlags[ObjectFlags["IdenticalBaseTypeCalculated"] = 33554432] = "IdenticalBaseTypeCalculated"; /* @internal */ - ObjectFlags[ObjectFlags["IsNeverIntersectionComputed"] = 268435456] = "IsNeverIntersectionComputed"; + ObjectFlags[ObjectFlags["IdenticalBaseTypeExists"] = 67108864] = "IdenticalBaseTypeExists"; + // Flags that require TypeFlags.UnionOrIntersection or TypeFlags.Substitution /* @internal */ - ObjectFlags[ObjectFlags["IsNeverIntersection"] = 536870912] = "IsNeverIntersection"; + ObjectFlags[ObjectFlags["IsGenericObjectTypeComputed"] = 4194304] = "IsGenericObjectTypeComputed"; /* @internal */ - ObjectFlags[ObjectFlags["IsClassInstanceClone"] = 1073741824] = "IsClassInstanceClone"; - ObjectFlags[ObjectFlags["ClassOrInterface"] = 3] = "ClassOrInterface"; + ObjectFlags[ObjectFlags["IsGenericObjectType"] = 8388608] = "IsGenericObjectType"; + /* @internal */ + ObjectFlags[ObjectFlags["IsGenericIndexTypeComputed"] = 16777216] = "IsGenericIndexTypeComputed"; + /* @internal */ + ObjectFlags[ObjectFlags["IsGenericIndexType"] = 33554432] = "IsGenericIndexType"; + // Flags that require TypeFlags.Union /* @internal */ - ObjectFlags[ObjectFlags["RequiresWidening"] = 1572864] = "RequiresWidening"; + ObjectFlags[ObjectFlags["ContainsIntersections"] = 67108864] = "ContainsIntersections"; + // Flags that require TypeFlags.Intersection /* @internal */ - ObjectFlags[ObjectFlags["PropagatingFlags"] = 3670016] = "PropagatingFlags"; - // Object flags that uniquely identify the kind of ObjectType + ObjectFlags[ObjectFlags["IsNeverIntersectionComputed"] = 67108864] = "IsNeverIntersectionComputed"; /* @internal */ - ObjectFlags[ObjectFlags["ObjectTypeKindMask"] = 2367] = "ObjectTypeKindMask"; + ObjectFlags[ObjectFlags["IsNeverIntersection"] = 134217728] = "IsNeverIntersection"; })(ObjectFlags = ts.ObjectFlags || (ts.ObjectFlags = {})); /* @internal */ var VarianceFlags; @@ -4813,6 +4937,21 @@ var ts; ElementFlags[ElementFlags["NonRest"] = 11] = "NonRest"; })(ElementFlags = ts.ElementFlags || (ts.ElementFlags = {})); /* @internal */ + var AccessFlags; + (function (AccessFlags) { + AccessFlags[AccessFlags["None"] = 0] = "None"; + AccessFlags[AccessFlags["IncludeUndefined"] = 1] = "IncludeUndefined"; + AccessFlags[AccessFlags["NoIndexSignatures"] = 2] = "NoIndexSignatures"; + AccessFlags[AccessFlags["Writing"] = 4] = "Writing"; + AccessFlags[AccessFlags["CacheSymbol"] = 8] = "CacheSymbol"; + AccessFlags[AccessFlags["NoTupleBoundsCheck"] = 16] = "NoTupleBoundsCheck"; + AccessFlags[AccessFlags["ExpressionPosition"] = 32] = "ExpressionPosition"; + AccessFlags[AccessFlags["ReportDeprecated"] = 64] = "ReportDeprecated"; + AccessFlags[AccessFlags["SuppressNoImplicitAnyError"] = 128] = "SuppressNoImplicitAnyError"; + AccessFlags[AccessFlags["Contextual"] = 256] = "Contextual"; + AccessFlags[AccessFlags["Persistent"] = 1] = "Persistent"; + })(AccessFlags = ts.AccessFlags || (ts.AccessFlags = {})); + /* @internal */ var JsxReferenceKind; (function (JsxReferenceKind) { JsxReferenceKind[JsxReferenceKind["Component"] = 0] = "Component"; @@ -4860,16 +4999,17 @@ var ts; (function (InferencePriority) { InferencePriority[InferencePriority["NakedTypeVariable"] = 1] = "NakedTypeVariable"; InferencePriority[InferencePriority["SpeculativeTuple"] = 2] = "SpeculativeTuple"; - InferencePriority[InferencePriority["HomomorphicMappedType"] = 4] = "HomomorphicMappedType"; - InferencePriority[InferencePriority["PartialHomomorphicMappedType"] = 8] = "PartialHomomorphicMappedType"; - InferencePriority[InferencePriority["MappedTypeConstraint"] = 16] = "MappedTypeConstraint"; - InferencePriority[InferencePriority["ContravariantConditional"] = 32] = "ContravariantConditional"; - InferencePriority[InferencePriority["ReturnType"] = 64] = "ReturnType"; - InferencePriority[InferencePriority["LiteralKeyof"] = 128] = "LiteralKeyof"; - InferencePriority[InferencePriority["NoConstraints"] = 256] = "NoConstraints"; - InferencePriority[InferencePriority["AlwaysStrict"] = 512] = "AlwaysStrict"; - InferencePriority[InferencePriority["MaxValue"] = 1024] = "MaxValue"; - InferencePriority[InferencePriority["PriorityImpliesCombination"] = 208] = "PriorityImpliesCombination"; + InferencePriority[InferencePriority["SubstituteSource"] = 4] = "SubstituteSource"; + InferencePriority[InferencePriority["HomomorphicMappedType"] = 8] = "HomomorphicMappedType"; + InferencePriority[InferencePriority["PartialHomomorphicMappedType"] = 16] = "PartialHomomorphicMappedType"; + InferencePriority[InferencePriority["MappedTypeConstraint"] = 32] = "MappedTypeConstraint"; + InferencePriority[InferencePriority["ContravariantConditional"] = 64] = "ContravariantConditional"; + InferencePriority[InferencePriority["ReturnType"] = 128] = "ReturnType"; + InferencePriority[InferencePriority["LiteralKeyof"] = 256] = "LiteralKeyof"; + InferencePriority[InferencePriority["NoConstraints"] = 512] = "NoConstraints"; + InferencePriority[InferencePriority["AlwaysStrict"] = 1024] = "AlwaysStrict"; + InferencePriority[InferencePriority["MaxValue"] = 2048] = "MaxValue"; + InferencePriority[InferencePriority["PriorityImpliesCombination"] = 416] = "PriorityImpliesCombination"; InferencePriority[InferencePriority["Circularity"] = -1] = "Circularity"; })(InferencePriority = ts.InferencePriority || (ts.InferencePriority = {})); /* @internal */ @@ -4947,20 +5087,23 @@ var ts; WatchFileKind[WatchFileKind["FixedPollingInterval"] = 0] = "FixedPollingInterval"; WatchFileKind[WatchFileKind["PriorityPollingInterval"] = 1] = "PriorityPollingInterval"; WatchFileKind[WatchFileKind["DynamicPriorityPolling"] = 2] = "DynamicPriorityPolling"; - WatchFileKind[WatchFileKind["UseFsEvents"] = 3] = "UseFsEvents"; - WatchFileKind[WatchFileKind["UseFsEventsOnParentDirectory"] = 4] = "UseFsEventsOnParentDirectory"; + WatchFileKind[WatchFileKind["FixedChunkSizePolling"] = 3] = "FixedChunkSizePolling"; + WatchFileKind[WatchFileKind["UseFsEvents"] = 4] = "UseFsEvents"; + WatchFileKind[WatchFileKind["UseFsEventsOnParentDirectory"] = 5] = "UseFsEventsOnParentDirectory"; })(WatchFileKind = ts.WatchFileKind || (ts.WatchFileKind = {})); var WatchDirectoryKind; (function (WatchDirectoryKind) { WatchDirectoryKind[WatchDirectoryKind["UseFsEvents"] = 0] = "UseFsEvents"; WatchDirectoryKind[WatchDirectoryKind["FixedPollingInterval"] = 1] = "FixedPollingInterval"; WatchDirectoryKind[WatchDirectoryKind["DynamicPriorityPolling"] = 2] = "DynamicPriorityPolling"; + WatchDirectoryKind[WatchDirectoryKind["FixedChunkSizePolling"] = 3] = "FixedChunkSizePolling"; })(WatchDirectoryKind = ts.WatchDirectoryKind || (ts.WatchDirectoryKind = {})); var PollingWatchKind; (function (PollingWatchKind) { PollingWatchKind[PollingWatchKind["FixedInterval"] = 0] = "FixedInterval"; PollingWatchKind[PollingWatchKind["PriorityInterval"] = 1] = "PriorityInterval"; PollingWatchKind[PollingWatchKind["DynamicPriority"] = 2] = "DynamicPriority"; + PollingWatchKind[PollingWatchKind["FixedChunkSize"] = 3] = "FixedChunkSize"; })(PollingWatchKind = ts.PollingWatchKind || (ts.PollingWatchKind = {})); var ModuleKind; (function (ModuleKind) { @@ -5021,6 +5164,7 @@ var ts; ScriptTarget[ScriptTarget["ES2018"] = 5] = "ES2018"; ScriptTarget[ScriptTarget["ES2019"] = 6] = "ES2019"; ScriptTarget[ScriptTarget["ES2020"] = 7] = "ES2020"; + ScriptTarget[ScriptTarget["ES2021"] = 8] = "ES2021"; ScriptTarget[ScriptTarget["ESNext"] = 99] = "ESNext"; ScriptTarget[ScriptTarget["JSON"] = 100] = "JSON"; ScriptTarget[ScriptTarget["Latest"] = 99] = "Latest"; @@ -5183,29 +5327,30 @@ var ts; TransformFlags[TransformFlags["ContainsTypeScript"] = 1] = "ContainsTypeScript"; TransformFlags[TransformFlags["ContainsJsx"] = 2] = "ContainsJsx"; TransformFlags[TransformFlags["ContainsESNext"] = 4] = "ContainsESNext"; - TransformFlags[TransformFlags["ContainsES2020"] = 8] = "ContainsES2020"; - TransformFlags[TransformFlags["ContainsES2019"] = 16] = "ContainsES2019"; - TransformFlags[TransformFlags["ContainsES2018"] = 32] = "ContainsES2018"; - TransformFlags[TransformFlags["ContainsES2017"] = 64] = "ContainsES2017"; - TransformFlags[TransformFlags["ContainsES2016"] = 128] = "ContainsES2016"; - TransformFlags[TransformFlags["ContainsES2015"] = 256] = "ContainsES2015"; - TransformFlags[TransformFlags["ContainsGenerator"] = 512] = "ContainsGenerator"; - TransformFlags[TransformFlags["ContainsDestructuringAssignment"] = 1024] = "ContainsDestructuringAssignment"; + TransformFlags[TransformFlags["ContainsES2021"] = 8] = "ContainsES2021"; + TransformFlags[TransformFlags["ContainsES2020"] = 16] = "ContainsES2020"; + TransformFlags[TransformFlags["ContainsES2019"] = 32] = "ContainsES2019"; + TransformFlags[TransformFlags["ContainsES2018"] = 64] = "ContainsES2018"; + TransformFlags[TransformFlags["ContainsES2017"] = 128] = "ContainsES2017"; + TransformFlags[TransformFlags["ContainsES2016"] = 256] = "ContainsES2016"; + TransformFlags[TransformFlags["ContainsES2015"] = 512] = "ContainsES2015"; + TransformFlags[TransformFlags["ContainsGenerator"] = 1024] = "ContainsGenerator"; + TransformFlags[TransformFlags["ContainsDestructuringAssignment"] = 2048] = "ContainsDestructuringAssignment"; // Markers // - Flags used to indicate that a subtree contains a specific transformation. - TransformFlags[TransformFlags["ContainsTypeScriptClassSyntax"] = 2048] = "ContainsTypeScriptClassSyntax"; - TransformFlags[TransformFlags["ContainsLexicalThis"] = 4096] = "ContainsLexicalThis"; - TransformFlags[TransformFlags["ContainsRestOrSpread"] = 8192] = "ContainsRestOrSpread"; - TransformFlags[TransformFlags["ContainsObjectRestOrSpread"] = 16384] = "ContainsObjectRestOrSpread"; - TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 32768] = "ContainsComputedPropertyName"; - TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 65536] = "ContainsBlockScopedBinding"; - TransformFlags[TransformFlags["ContainsBindingPattern"] = 131072] = "ContainsBindingPattern"; - TransformFlags[TransformFlags["ContainsYield"] = 262144] = "ContainsYield"; - TransformFlags[TransformFlags["ContainsAwait"] = 524288] = "ContainsAwait"; - TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 1048576] = "ContainsHoistedDeclarationOrCompletion"; - TransformFlags[TransformFlags["ContainsDynamicImport"] = 2097152] = "ContainsDynamicImport"; - TransformFlags[TransformFlags["ContainsClassFields"] = 4194304] = "ContainsClassFields"; - TransformFlags[TransformFlags["ContainsPossibleTopLevelAwait"] = 8388608] = "ContainsPossibleTopLevelAwait"; + TransformFlags[TransformFlags["ContainsTypeScriptClassSyntax"] = 4096] = "ContainsTypeScriptClassSyntax"; + TransformFlags[TransformFlags["ContainsLexicalThis"] = 8192] = "ContainsLexicalThis"; + TransformFlags[TransformFlags["ContainsRestOrSpread"] = 16384] = "ContainsRestOrSpread"; + TransformFlags[TransformFlags["ContainsObjectRestOrSpread"] = 32768] = "ContainsObjectRestOrSpread"; + TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 65536] = "ContainsComputedPropertyName"; + TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 131072] = "ContainsBlockScopedBinding"; + TransformFlags[TransformFlags["ContainsBindingPattern"] = 262144] = "ContainsBindingPattern"; + TransformFlags[TransformFlags["ContainsYield"] = 524288] = "ContainsYield"; + TransformFlags[TransformFlags["ContainsAwait"] = 1048576] = "ContainsAwait"; + TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 2097152] = "ContainsHoistedDeclarationOrCompletion"; + TransformFlags[TransformFlags["ContainsDynamicImport"] = 4194304] = "ContainsDynamicImport"; + TransformFlags[TransformFlags["ContainsClassFields"] = 8388608] = "ContainsClassFields"; + TransformFlags[TransformFlags["ContainsPossibleTopLevelAwait"] = 16777216] = "ContainsPossibleTopLevelAwait"; // 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 @@ -5215,37 +5360,38 @@ var ts; TransformFlags[TransformFlags["AssertTypeScript"] = 1] = "AssertTypeScript"; TransformFlags[TransformFlags["AssertJsx"] = 2] = "AssertJsx"; TransformFlags[TransformFlags["AssertESNext"] = 4] = "AssertESNext"; - TransformFlags[TransformFlags["AssertES2020"] = 8] = "AssertES2020"; - TransformFlags[TransformFlags["AssertES2019"] = 16] = "AssertES2019"; - TransformFlags[TransformFlags["AssertES2018"] = 32] = "AssertES2018"; - TransformFlags[TransformFlags["AssertES2017"] = 64] = "AssertES2017"; - TransformFlags[TransformFlags["AssertES2016"] = 128] = "AssertES2016"; - TransformFlags[TransformFlags["AssertES2015"] = 256] = "AssertES2015"; - TransformFlags[TransformFlags["AssertGenerator"] = 512] = "AssertGenerator"; - TransformFlags[TransformFlags["AssertDestructuringAssignment"] = 1024] = "AssertDestructuringAssignment"; + TransformFlags[TransformFlags["AssertES2021"] = 8] = "AssertES2021"; + TransformFlags[TransformFlags["AssertES2020"] = 16] = "AssertES2020"; + TransformFlags[TransformFlags["AssertES2019"] = 32] = "AssertES2019"; + TransformFlags[TransformFlags["AssertES2018"] = 64] = "AssertES2018"; + TransformFlags[TransformFlags["AssertES2017"] = 128] = "AssertES2017"; + TransformFlags[TransformFlags["AssertES2016"] = 256] = "AssertES2016"; + TransformFlags[TransformFlags["AssertES2015"] = 512] = "AssertES2015"; + TransformFlags[TransformFlags["AssertGenerator"] = 1024] = "AssertGenerator"; + TransformFlags[TransformFlags["AssertDestructuringAssignment"] = 2048] = "AssertDestructuringAssignment"; // 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"] = 547309568] = "ArrowFunctionExcludes"; - TransformFlags[TransformFlags["FunctionExcludes"] = 547313664] = "FunctionExcludes"; - TransformFlags[TransformFlags["ConstructorExcludes"] = 547311616] = "ConstructorExcludes"; - TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 538923008] = "MethodOrAccessorExcludes"; - TransformFlags[TransformFlags["PropertyExcludes"] = 536875008] = "PropertyExcludes"; - TransformFlags[TransformFlags["ClassExcludes"] = 536905728] = "ClassExcludes"; - TransformFlags[TransformFlags["ModuleExcludes"] = 546379776] = "ModuleExcludes"; + TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 557748224] = "ArrowFunctionExcludes"; + TransformFlags[TransformFlags["FunctionExcludes"] = 557756416] = "FunctionExcludes"; + TransformFlags[TransformFlags["ConstructorExcludes"] = 557752320] = "ConstructorExcludes"; + TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 540975104] = "MethodOrAccessorExcludes"; + TransformFlags[TransformFlags["PropertyExcludes"] = 536879104] = "PropertyExcludes"; + TransformFlags[TransformFlags["ClassExcludes"] = 536940544] = "ClassExcludes"; + TransformFlags[TransformFlags["ModuleExcludes"] = 555888640] = "ModuleExcludes"; TransformFlags[TransformFlags["TypeExcludes"] = -2] = "TypeExcludes"; - TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 536922112] = "ObjectLiteralExcludes"; - TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 536879104] = "ArrayLiteralOrCallOrNewExcludes"; - TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 537018368] = "VariableDeclarationListExcludes"; + TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 536973312] = "ObjectLiteralExcludes"; + TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 536887296] = "ArrayLiteralOrCallOrNewExcludes"; + TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 537165824] = "VariableDeclarationListExcludes"; TransformFlags[TransformFlags["ParameterExcludes"] = 536870912] = "ParameterExcludes"; - TransformFlags[TransformFlags["CatchClauseExcludes"] = 536887296] = "CatchClauseExcludes"; - TransformFlags[TransformFlags["BindingPatternExcludes"] = 536879104] = "BindingPatternExcludes"; + TransformFlags[TransformFlags["CatchClauseExcludes"] = 536903680] = "CatchClauseExcludes"; + TransformFlags[TransformFlags["BindingPatternExcludes"] = 536887296] = "BindingPatternExcludes"; // Propagating flags // - Bitmasks for flags that should propagate from a child - TransformFlags[TransformFlags["PropertyNamePropagatingFlags"] = 4096] = "PropertyNamePropagatingFlags"; + TransformFlags[TransformFlags["PropertyNamePropagatingFlags"] = 8192] = "PropertyNamePropagatingFlags"; // Masks // - Additional bitmasks })(TransformFlags = ts.TransformFlags || (ts.TransformFlags = {})); @@ -5843,6 +5989,11 @@ var ts; * Normalize path separators, converting `\` into `/`. */ function normalizeSlashes(path) { + var index = path.indexOf("\\"); + if (index === -1) { + return path; + } + backslashRegExp.lastIndex = index; // prime regex with known position return path.replace(backslashRegExp, ts.directorySeparator); } ts.normalizeSlashes = normalizeSlashes; @@ -5953,6 +6104,19 @@ var ts; ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath; function normalizePath(path) { path = normalizeSlashes(path); + // Most paths don't require normalization + if (!relativePathSegmentRegExp.test(path)) { + return path; + } + // Some paths only require cleanup of `/./` or leading `./` + var simplified = path.replace(/\/\.\//g, "/").replace(/^\.\//, ""); + if (simplified !== path) { + path = simplified; + if (!relativePathSegmentRegExp.test(path)) { + return path; + } + } + // Other paths require full normalization var normalized = getPathFromPathComponents(reducePathComponents(getPathComponents(path))); return normalized && hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalized) : normalized; } @@ -6021,7 +6185,7 @@ var ts; ts.changeAnyExtension = changeAnyExtension; //// Path Comparisons // check path for these segments: '', '.'. '..' - var relativePathSegmentRegExp = /(^|\/)\.{0,2}($|\/)/; + var relativePathSegmentRegExp = /(?:\/\/)|(?:^|\/)\.\.?(?:$|\/)/; function comparePathsWorker(a, b, componentComparer) { if (a === b) return 0 /* EqualTo */; @@ -6113,7 +6277,7 @@ var ts; * Determines whether `fileName` starts with the specified `directoryName` using the provided path canonicalization callback. * Comparison is case-sensitive between the canonical paths. * - * @deprecated Use `containsPath` if possible. + * Use `containsPath` if file names are not already reduced and absolute. */ function startsWithDirectory(fileName, directoryName, getCanonicalFileName) { var canonicalFileName = getCanonicalFileName(fileName); @@ -6233,6 +6397,11 @@ var ts; })(PollingInterval = ts.PollingInterval || (ts.PollingInterval = {})); /* @internal */ ts.missingFileModifiedTime = new Date(0); // Any subsequent modification will occur after this time + /* @internal */ + function getModifiedTime(host, fileName) { + return host.getModifiedTime(fileName) || ts.missingFileModifiedTime; + } + ts.getModifiedTime = getModifiedTime; function createPollingIntervalBasedLevels(levels) { var _a; return _a = {}, @@ -6289,6 +6458,51 @@ var ts; } } ts.setCustomPollingValues = setCustomPollingValues; + function pollWatchedFileQueue(host, queue, pollIndex, chunkSize, callbackOnWatchFileStat) { + var definedValueCopyToIndex = pollIndex; + // Max visit would be all elements of the queue + for (var canVisit = queue.length; chunkSize && canVisit; nextPollIndex(), canVisit--) { + var watchedFile = queue[pollIndex]; + if (!watchedFile) { + continue; + } + else if (watchedFile.isClosed) { + queue[pollIndex] = undefined; + continue; + } + // Only files polled count towards chunkSize + chunkSize--; + var fileChanged = onWatchedFileStat(watchedFile, getModifiedTime(host, watchedFile.fileName)); + if (watchedFile.isClosed) { + // Closed watcher as part of callback + queue[pollIndex] = undefined; + continue; + } + callbackOnWatchFileStat === null || callbackOnWatchFileStat === void 0 ? void 0 : callbackOnWatchFileStat(watchedFile, pollIndex, fileChanged); + // Defragment the queue while we are at it + if (queue[pollIndex]) { + // Copy this file to the non hole location + if (definedValueCopyToIndex < pollIndex) { + queue[definedValueCopyToIndex] = watchedFile; + queue[pollIndex] = undefined; + } + definedValueCopyToIndex++; + } + } + // Return next poll index + return pollIndex; + function nextPollIndex() { + pollIndex++; + if (pollIndex === queue.length) { + if (definedValueCopyToIndex < pollIndex) { + // There are holes from definedValueCopyToIndex to end of queue, change queue size + queue.length = definedValueCopyToIndex; + } + pollIndex = 0; + definedValueCopyToIndex = 0; + } + } + } /* @internal */ function createDynamicPriorityPollingWatchFile(host) { var watchedFiles = []; @@ -6302,7 +6516,7 @@ var ts; fileName: fileName, callback: callback, unchangedPolls: 0, - mtime: getModifiedTime(fileName) + mtime: getModifiedTime(host, fileName) }; watchedFiles.push(file); addToPollingIntervalQueue(file, defaultPollingInterval); @@ -6345,25 +6559,9 @@ var ts; } } function pollQueue(queue, pollingInterval, pollIndex, chunkSize) { - // Max visit would be all elements of the queue - var needsVisit = queue.length; - var definedValueCopyToIndex = pollIndex; - for (var polled = 0; polled < chunkSize && needsVisit > 0; nextPollIndex(), needsVisit--) { - var watchedFile = queue[pollIndex]; - if (!watchedFile) { - continue; - } - else if (watchedFile.isClosed) { - queue[pollIndex] = undefined; - continue; - } - polled++; - var fileChanged = onWatchedFileStat(watchedFile, getModifiedTime(watchedFile.fileName)); - if (watchedFile.isClosed) { - // Closed watcher as part of callback - queue[pollIndex] = undefined; - } - else if (fileChanged) { + return pollWatchedFileQueue(host, queue, pollIndex, chunkSize, onWatchFileStat); + function onWatchFileStat(watchedFile, pollIndex, fileChanged) { + if (fileChanged) { watchedFile.unchangedPolls = 0; // Changed files go to changedFilesInLastPoll queue if (queue !== changedFilesInLastPoll) { @@ -6385,27 +6583,6 @@ var ts; queue[pollIndex] = undefined; addToPollingIntervalQueue(watchedFile, pollingInterval === PollingInterval.Low ? PollingInterval.Medium : PollingInterval.High); } - if (queue[pollIndex]) { - // Copy this file to the non hole location - if (definedValueCopyToIndex < pollIndex) { - queue[definedValueCopyToIndex] = watchedFile; - queue[pollIndex] = undefined; - } - definedValueCopyToIndex++; - } - } - // Return next poll index - return pollIndex; - function nextPollIndex() { - pollIndex++; - if (pollIndex === queue.length) { - if (definedValueCopyToIndex < pollIndex) { - // There are holes from nextDefinedValueIndex to end of queue, change queue size - queue.length = definedValueCopyToIndex; - } - pollIndex = 0; - definedValueCopyToIndex = 0; - } } } function pollingIntervalQueue(pollingInterval) { @@ -6434,9 +6611,6 @@ var ts; function scheduleNextPoll(pollingInterval) { pollingIntervalQueue(pollingInterval).pollScheduled = host.setTimeout(pollingInterval === PollingInterval.Low ? pollLowPollingIntervalQueue : pollPollingIntervalQueue, pollingInterval, pollingIntervalQueue(pollingInterval)); } - function getModifiedTime(fileName) { - return host.getModifiedTime(fileName) || ts.missingFileModifiedTime; - } } ts.createDynamicPriorityPollingWatchFile = createDynamicPriorityPollingWatchFile; function createUseFsEventsOnParentDirectoryWatchFile(fsWatch, useCaseSensitiveFileNames) { @@ -6487,6 +6661,37 @@ var ts; return watcher; } } + function createFixedChunkSizePollingWatchFile(host) { + var watchedFiles = []; + var pollIndex = 0; + var pollScheduled; + return watchFile; + function watchFile(fileName, callback) { + var file = { + fileName: fileName, + callback: callback, + mtime: getModifiedTime(host, fileName) + }; + watchedFiles.push(file); + scheduleNextPoll(); + return { + close: function () { + file.isClosed = true; + ts.unorderedRemoveItem(watchedFiles, file); + } + }; + } + function pollQueue() { + pollScheduled = undefined; + pollIndex = pollWatchedFileQueue(host, watchedFiles, pollIndex, pollingChunkSize[PollingInterval.Low]); + scheduleNextPoll(); + } + function scheduleNextPoll() { + if (!watchedFiles.length || pollScheduled) + return; + pollScheduled = host.setTimeout(pollQueue, PollingInterval.High); + } + } /* @internal */ function createSingleFileWatcherPerName(watchFile, useCaseSensitiveFileNames) { var cache = new ts.Map(); @@ -6809,8 +7014,9 @@ var ts; } /*@internal*/ function createSystemWatchFunctions(_a) { - var pollingWatchFile = _a.pollingWatchFile, getModifiedTime = _a.getModifiedTime, setTimeout = _a.setTimeout, clearTimeout = _a.clearTimeout, fsWatch = _a.fsWatch, fileExists = _a.fileExists, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, getCurrentDirectory = _a.getCurrentDirectory, fsSupportsRecursiveFsWatch = _a.fsSupportsRecursiveFsWatch, directoryExists = _a.directoryExists, getAccessibleSortedChildDirectories = _a.getAccessibleSortedChildDirectories, realpath = _a.realpath, tscWatchFile = _a.tscWatchFile, useNonPollingWatchers = _a.useNonPollingWatchers, tscWatchDirectory = _a.tscWatchDirectory; + var pollingWatchFile = _a.pollingWatchFile, getModifiedTime = _a.getModifiedTime, setTimeout = _a.setTimeout, clearTimeout = _a.clearTimeout, fsWatch = _a.fsWatch, fileExists = _a.fileExists, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, getCurrentDirectory = _a.getCurrentDirectory, fsSupportsRecursiveFsWatch = _a.fsSupportsRecursiveFsWatch, directoryExists = _a.directoryExists, getAccessibleSortedChildDirectories = _a.getAccessibleSortedChildDirectories, realpath = _a.realpath, tscWatchFile = _a.tscWatchFile, useNonPollingWatchers = _a.useNonPollingWatchers, tscWatchDirectory = _a.tscWatchDirectory, defaultWatchFileKind = _a.defaultWatchFileKind; var dynamicPollingWatchFile; + var fixedChunkSizePollingWatchFile; var nonPollingWatchFile; var hostRecursiveDirectoryWatcher; return { @@ -6827,6 +7033,8 @@ var ts; return pollingWatchFile(fileName, callback, pollingInterval, /*options*/ undefined); case ts.WatchFileKind.DynamicPriorityPolling: return ensureDynamicPollingWatchFile()(fileName, callback, pollingInterval, /*options*/ undefined); + case ts.WatchFileKind.FixedChunkSizePolling: + return ensureFixedChunkSizePollingWatchFile()(fileName, callback, /* pollingInterval */ undefined, /*options*/ undefined); case ts.WatchFileKind.UseFsEvents: return fsWatch(fileName, 0 /* File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists), /*recursive*/ false, pollingInterval, ts.getFallbackOptions(options)); @@ -6840,8 +7048,10 @@ var ts; } } function ensureDynamicPollingWatchFile() { - return dynamicPollingWatchFile || - (dynamicPollingWatchFile = createDynamicPriorityPollingWatchFile({ getModifiedTime: getModifiedTime, setTimeout: setTimeout })); + return dynamicPollingWatchFile || (dynamicPollingWatchFile = createDynamicPriorityPollingWatchFile({ getModifiedTime: getModifiedTime, setTimeout: setTimeout })); + } + function ensureFixedChunkSizePollingWatchFile() { + return fixedChunkSizePollingWatchFile || (fixedChunkSizePollingWatchFile = createFixedChunkSizePollingWatchFile({ getModifiedTime: getModifiedTime, setTimeout: setTimeout })); } function updateOptionsForWatchFile(options, useNonPollingWatchers) { if (options && options.watchFile !== undefined) @@ -6867,7 +7077,7 @@ var ts; // Use notifications from FS to watch with falling back to fs.watchFile generateWatchFileOptions(ts.WatchFileKind.UseFsEventsOnParentDirectory, ts.PollingWatchKind.PriorityInterval, options) : // Default to do not use fixed polling interval - { watchFile: ts.WatchFileKind.FixedPollingInterval }; + { watchFile: (defaultWatchFileKind === null || defaultWatchFileKind === void 0 ? void 0 : defaultWatchFileKind()) || ts.WatchFileKind.FixedPollingInterval }; } } function generateWatchFileOptions(watchFile, fallbackPolling, options) { @@ -6908,6 +7118,10 @@ var ts; case ts.WatchDirectoryKind.DynamicPriorityPolling: return ensureDynamicPollingWatchFile()(directoryName, function () { return callback(directoryName); }, PollingInterval.Medium, /*options*/ undefined); + case ts.WatchDirectoryKind.FixedChunkSizePolling: + return ensureFixedChunkSizePollingWatchFile()(directoryName, function () { return callback(directoryName); }, + /* 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)); default: @@ -6986,13 +7200,13 @@ var ts; } var activeSession; var profilePath = "./profile.cpuprofile"; - var realpathSync = (_a = _fs.realpathSync.native) !== null && _a !== void 0 ? _a : _fs.realpathSync; var Buffer = require("buffer").Buffer; var nodeVersion = getNodeMajorVersion(); var isNode4OrLater = nodeVersion >= 4; var isLinuxOrMacOs = process.platform === "linux" || process.platform === "darwin"; var platform = _os.platform(); var useCaseSensitiveFileNames = isFileSystemCaseSensitive(); + var realpathSync = useCaseSensitiveFileNames ? ((_a = _fs.realpathSync.native) !== null && _a !== void 0 ? _a : _fs.realpathSync) : _fs.realpathSync; var fsSupportsRecursiveFsWatch = isNode4OrLater && (process.platform === "win32" || process.platform === "darwin"); var getCurrentDirectory = ts.memoize(function () { return process.cwd(); }); var _c = createSystemWatchFunctions({ @@ -7013,6 +7227,7 @@ var ts; tscWatchFile: process.env.TSC_WATCHFILE, useNonPollingWatchers: process.env.TSC_NONPOLLING_WATCHER, tscWatchDirectory: process.env.TSC_WATCHDIRECTORY, + defaultWatchFileKind: function () { var _a, _b; return (_b = (_a = sys).defaultWatchFileKind) === null || _b === void 0 ? void 0 : _b.call(_a); }, }), watchFile = _c.watchFile, watchDirectory = _c.watchDirectory; var nodeSystem = { args: process.argv.slice(2), @@ -7081,6 +7296,7 @@ var ts; }, enableCPUProfiler: enableCPUProfiler, disableCPUProfiler: disableCPUProfiler, + cpuProfilingEnabled: function () { return !!activeSession || ts.contains(process.execArgv, "--cpu-prof") || ts.contains(process.execArgv, "--prof"); }, realpath: realpath, debugMode: !!process.env.NODE_INSPECTOR_IPC || !!process.env.VSCODE_INSPECTOR_OPTIONS || ts.some(process.execArgv, function (arg) { return /^--(inspect|debug)(-brk)?(=\d+)?$/i.test(arg); }), tryEnableSourceMapsForHost: function () { @@ -7330,7 +7546,7 @@ var ts; return event === "rename" && (!relativeName || relativeName === lastDirectoryPart || - relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length) && + (relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) !== -1 && relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length)) && !fileSystemEntryExists(fileOrDirectory, entryKind) ? invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry) : callback(event, relativeName); @@ -7640,9 +7856,10 @@ var ts; Invalid_use_of_0_in_strict_mode: diag(1100, ts.DiagnosticCategory.Error, "Invalid_use_of_0_in_strict_mode_1100", "Invalid use of '{0}' in strict mode."), with_statements_are_not_allowed_in_strict_mode: diag(1101, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_strict_mode_1101", "'with' statements are not allowed in strict mode."), delete_cannot_be_called_on_an_identifier_in_strict_mode: diag(1102, ts.DiagnosticCategory.Error, "delete_cannot_be_called_on_an_identifier_in_strict_mode_1102", "'delete' cannot be called on an identifier in strict mode."), - A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator: diag(1103, ts.DiagnosticCategory.Error, "A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator_1103", "A 'for-await-of' statement is only allowed within an async function or async generator."), + for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1103, ts.DiagnosticCategory.Error, "for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1103", "'for await' loops are only allowed within async functions and at the top levels of modules."), A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: diag(1104, ts.DiagnosticCategory.Error, "A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement_1104", "A 'continue' statement can only be used within an enclosing iteration statement."), A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: diag(1105, ts.DiagnosticCategory.Error, "A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement_1105", "A 'break' statement can only be used within an enclosing iteration or switch statement."), + The_left_hand_side_of_a_for_of_statement_may_not_be_async: diag(1106, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_of_statement_may_not_be_async_1106", "The left-hand side of a 'for...of' statement may not be 'async'."), Jump_target_cannot_cross_function_boundary: diag(1107, ts.DiagnosticCategory.Error, "Jump_target_cannot_cross_function_boundary_1107", "Jump target cannot cross function boundary."), A_return_statement_can_only_be_used_within_a_function_body: diag(1108, ts.DiagnosticCategory.Error, "A_return_statement_can_only_be_used_within_a_function_body_1108", "A 'return' statement can only be used within a function body."), Expression_expected: diag(1109, ts.DiagnosticCategory.Error, "Expression_expected_1109", "Expression expected."), @@ -7689,7 +7906,7 @@ var ts; A_yield_expression_is_only_allowed_in_a_generator_body: diag(1163, ts.DiagnosticCategory.Error, "A_yield_expression_is_only_allowed_in_a_generator_body_1163", "A 'yield' expression is only allowed in a generator body."), Computed_property_names_are_not_allowed_in_enums: diag(1164, ts.DiagnosticCategory.Error, "Computed_property_names_are_not_allowed_in_enums_1164", "Computed property names are not allowed in enums."), A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1165, ts.DiagnosticCategory.Error, "A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_t_1165", "A computed property name in an ambient context must refer to an expression whose type is a literal type or a 'unique symbol' type."), - A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1166, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_1166", "A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type."), + A_computed_property_name_in_a_class_property_declaration_must_have_a_simple_literal_type_or_a_unique_symbol_type: diag(1166, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_class_property_declaration_must_have_a_simple_literal_type_or_a_unique_1166", "A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type."), A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1168, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_ty_1168", "A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type."), A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1169, ts.DiagnosticCategory.Error, "A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_1169", "A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type."), A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1170, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type__1170", "A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type."), @@ -7749,7 +7966,7 @@ var ts; A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: diag(1228, ts.DiagnosticCategory.Error, "A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods_1228", "A type predicate is only allowed in return type position for functions and methods."), A_type_predicate_cannot_reference_a_rest_parameter: diag(1229, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_a_rest_parameter_1229", "A type predicate cannot reference a rest parameter."), A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: diag(1230, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_element_0_in_a_binding_pattern_1230", "A type predicate cannot reference element '{0}' in a binding pattern."), - An_export_assignment_can_only_be_used_in_a_module: diag(1231, ts.DiagnosticCategory.Error, "An_export_assignment_can_only_be_used_in_a_module_1231", "An export assignment can only be used in a module."), + An_export_assignment_must_be_at_the_top_level_of_a_file_or_module_declaration: diag(1231, ts.DiagnosticCategory.Error, "An_export_assignment_must_be_at_the_top_level_of_a_file_or_module_declaration_1231", "An export assignment must be at the top level of a file or module declaration."), An_import_declaration_can_only_be_used_in_a_namespace_or_module: diag(1232, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_in_a_namespace_or_module_1232", "An import declaration can only be used in a namespace or module."), An_export_declaration_can_only_be_used_in_a_module: diag(1233, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_in_a_module_1233", "An export declaration can only be used in a module."), An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: diag(1234, ts.DiagnosticCategory.Error, "An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file_1234", "An ambient module declaration is only allowed at the top level in a file."), @@ -7775,6 +7992,7 @@ var ts; A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_reference: diag(1254, ts.DiagnosticCategory.Error, "A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_refere_1254", "A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference."), A_definite_assignment_assertion_is_not_permitted_in_this_context: diag(1255, ts.DiagnosticCategory.Error, "A_definite_assignment_assertion_is_not_permitted_in_this_context_1255", "A definite assignment assertion '!' is not permitted in this context."), A_required_element_cannot_follow_an_optional_element: diag(1257, ts.DiagnosticCategory.Error, "A_required_element_cannot_follow_an_optional_element_1257", "A required element cannot follow an optional element."), + A_default_export_must_be_at_the_top_level_of_a_file_or_module_declaration: diag(1258, ts.DiagnosticCategory.Error, "A_default_export_must_be_at_the_top_level_of_a_file_or_module_declaration_1258", "A default export must be at the top level of a file or module declaration."), Module_0_can_only_be_default_imported_using_the_1_flag: diag(1259, ts.DiagnosticCategory.Error, "Module_0_can_only_be_default_imported_using_the_1_flag_1259", "Module '{0}' can only be default-imported using the '{1}' flag"), Keywords_cannot_contain_escape_characters: diag(1260, ts.DiagnosticCategory.Error, "Keywords_cannot_contain_escape_characters_1260", "Keywords cannot contain escape characters."), Already_included_file_name_0_differs_from_file_name_1_only_in_casing: diag(1261, ts.DiagnosticCategory.Error, "Already_included_file_name_0_differs_from_file_name_1_only_in_casing_1261", "Already included file name '{0}' differs from file name '{1}' only in casing."), @@ -7783,6 +8001,7 @@ var ts; Declarations_with_definite_assignment_assertions_must_also_have_type_annotations: diag(1264, ts.DiagnosticCategory.Error, "Declarations_with_definite_assignment_assertions_must_also_have_type_annotations_1264", "Declarations with definite assignment assertions must also have type annotations."), A_rest_element_cannot_follow_another_rest_element: diag(1265, ts.DiagnosticCategory.Error, "A_rest_element_cannot_follow_another_rest_element_1265", "A rest element cannot follow another rest element."), An_optional_element_cannot_follow_a_rest_element: diag(1266, ts.DiagnosticCategory.Error, "An_optional_element_cannot_follow_a_rest_element_1266", "An optional element cannot follow a rest element."), + Property_0_cannot_have_an_initializer_because_it_is_marked_abstract: diag(1267, ts.DiagnosticCategory.Error, "Property_0_cannot_have_an_initializer_because_it_is_marked_abstract_1267", "Property '{0}' cannot have an initializer because it is marked abstract."), with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1308, ts.DiagnosticCategory.Error, "await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1308", "'await' expressions are only allowed within async functions and at the top levels of modules."), 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: diag(1312, ts.DiagnosticCategory.Error, "Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_1312", "Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern."), @@ -7861,7 +8080,7 @@ var ts; Constructor_type_notation_must_be_parenthesized_when_used_in_an_intersection_type: diag(1388, ts.DiagnosticCategory.Error, "Constructor_type_notation_must_be_parenthesized_when_used_in_an_intersection_type_1388", "Constructor type notation must be parenthesized when used in an intersection type."), _0_is_not_allowed_as_a_variable_declaration_name: diag(1389, ts.DiagnosticCategory.Error, "_0_is_not_allowed_as_a_variable_declaration_name_1389", "'{0}' is not allowed as a variable declaration name."), Provides_a_root_package_name_when_using_outFile_with_declarations: diag(1390, ts.DiagnosticCategory.Message, "Provides_a_root_package_name_when_using_outFile_with_declarations_1390", "Provides a root package name when using outFile with declarations."), - The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_declaration_emit: diag(1391, ts.DiagnosticCategory.Error, "The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_de_1391", "The `bundledPackageName` option must be provided when using outFile and node module resolution with declaration emit."), + The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_declaration_emit: diag(1391, ts.DiagnosticCategory.Error, "The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_de_1391", "The 'bundledPackageName' option must be provided when using outFile and node module resolution with declaration emit."), An_import_alias_cannot_use_import_type: diag(1392, ts.DiagnosticCategory.Error, "An_import_alias_cannot_use_import_type_1392", "An import alias cannot use 'import type'"), Imported_via_0_from_file_1: diag(1393, ts.DiagnosticCategory.Message, "Imported_via_0_from_file_1_1393", "Imported via {0} from file '{1}'"), Imported_via_0_from_file_1_with_packageId_2: diag(1394, ts.DiagnosticCategory.Message, "Imported_via_0_from_file_1_with_packageId_2_1394", "Imported via {0} from file '{1}' with packageId '{2}'"), @@ -7901,6 +8120,9 @@ var ts; File_is_output_of_project_reference_source_0: diag(1428, ts.DiagnosticCategory.Message, "File_is_output_of_project_reference_source_0_1428", "File is output of project reference source '{0}'"), File_redirects_to_file_0: diag(1429, ts.DiagnosticCategory.Message, "File_redirects_to_file_0_1429", "File redirects to file '{0}'"), The_file_is_in_the_program_because_Colon: diag(1430, ts.DiagnosticCategory.Message, "The_file_is_in_the_program_because_Colon_1430", "The file is in the program because:"), + for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module: diag(1431, ts.DiagnosticCategory.Error, "for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_1431", "'for await' loops are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module."), + Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher: diag(1432, ts.DiagnosticCategory.Error, "Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_1432", "Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher."), + Decorators_may_not_be_applied_to_this_parameters: diag(1433, ts.DiagnosticCategory.Error, "Decorators_may_not_be_applied_to_this_parameters_1433", "Decorators may not be applied to 'this' parameters."), 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), @@ -7968,7 +8190,7 @@ var ts; The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2358, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter."), The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: diag(2359, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type."), The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: diag(2360, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol_2360", "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'."), - The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2361, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter_2361", "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter."), + The_right_hand_side_of_an_in_expression_must_not_be_a_primitive: diag(2361, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_in_expression_must_not_be_a_primitive_2361", "The right-hand side of an 'in' expression must not be a primitive."), The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2362, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2362", "The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."), The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2363, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2363", "The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."), The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: diag(2364, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", "The left-hand side of an assignment expression must be a variable or a property access."), @@ -7986,8 +8208,7 @@ var ts; A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_parameter_properties_or_private_identifiers: diag(2376, ts.DiagnosticCategory.Error, "A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_proper_2376", "A 'super' call must be the first statement in the constructor when a class contains initialized properties, parameter properties, or private identifiers."), Constructors_for_derived_classes_must_contain_a_super_call: diag(2377, ts.DiagnosticCategory.Error, "Constructors_for_derived_classes_must_contain_a_super_call_2377", "Constructors for derived classes must contain a 'super' call."), A_get_accessor_must_return_a_value: diag(2378, ts.DiagnosticCategory.Error, "A_get_accessor_must_return_a_value_2378", "A 'get' accessor must return a value."), - Getter_and_setter_accessors_do_not_agree_in_visibility: diag(2379, ts.DiagnosticCategory.Error, "Getter_and_setter_accessors_do_not_agree_in_visibility_2379", "Getter and setter accessors do not agree in visibility."), - get_and_set_accessor_must_have_the_same_type: diag(2380, ts.DiagnosticCategory.Error, "get_and_set_accessor_must_have_the_same_type_2380", "'get' and 'set' accessor must have the same type."), + The_return_type_of_a_get_accessor_must_be_assignable_to_its_set_accessor_type: diag(2380, ts.DiagnosticCategory.Error, "The_return_type_of_a_get_accessor_must_be_assignable_to_its_set_accessor_type_2380", "The return type of a 'get' accessor must be assignable to its 'set' accessor type"), A_signature_with_an_implementation_cannot_use_a_string_literal_type: diag(2381, ts.DiagnosticCategory.Error, "A_signature_with_an_implementation_cannot_use_a_string_literal_type_2381", "A signature with an implementation cannot use a string literal type."), Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: diag(2382, ts.DiagnosticCategory.Error, "Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature_2382", "Specialized overload signature is not assignable to any non-specialized signature."), Overload_signatures_must_all_be_exported_or_non_exported: diag(2383, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_exported_or_non_exported_2383", "Overload signatures must all be exported or non-exported."), @@ -8050,7 +8271,7 @@ var ts; Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2: diag(2443, ts.DiagnosticCategory.Error, "Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2_2443", "Property '{0}' is protected but type '{1}' is not a class derived from '{2}'."), Property_0_is_protected_in_type_1_but_public_in_type_2: diag(2444, ts.DiagnosticCategory.Error, "Property_0_is_protected_in_type_1_but_public_in_type_2_2444", "Property '{0}' is protected in type '{1}' but public in type '{2}'."), Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses: diag(2445, ts.DiagnosticCategory.Error, "Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses_2445", "Property '{0}' is protected and only accessible within class '{1}' and its subclasses."), - Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: diag(2446, ts.DiagnosticCategory.Error, "Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_2446", "Property '{0}' is protected and only accessible through an instance of class '{1}'."), + Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_This_is_an_instance_of_class_2: diag(2446, ts.DiagnosticCategory.Error, "Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_This_is_an_instance_of_cl_2446", "Property '{0}' is protected and only accessible through an instance of class '{1}'. This is an instance of class '{2}'."), The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: diag(2447, ts.DiagnosticCategory.Error, "The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead_2447", "The '{0}' operator is not allowed for boolean types. Consider using '{1}' instead."), Block_scoped_variable_0_used_before_its_declaration: diag(2448, ts.DiagnosticCategory.Error, "Block_scoped_variable_0_used_before_its_declaration_2448", "Block-scoped variable '{0}' used before its declaration."), Class_0_used_before_its_declaration: diag(2449, ts.DiagnosticCategory.Error, "Class_0_used_before_its_declaration_2449", "Class '{0}' used before its declaration."), @@ -8150,14 +8371,13 @@ var ts; The_type_returned_by_the_0_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_property: diag(2547, ts.DiagnosticCategory.Error, "The_type_returned_by_the_0_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_pro_2547", "The type returned by the '{0}()' method of an async iterator must be a promise for a type with a 'value' property."), Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator: diag(2548, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator_2548", "Type '{0}' is not an array type or does not have a '[Symbol.iterator]()' method that returns an iterator."), Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator: diag(2549, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns__2549", "Type '{0}' is not an array type or a string type or does not have a '[Symbol.iterator]()' method that returns an iterator."), - Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2_or_later: diag(2550, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_c_2550", "Property '{0}' does not exist on type '{1}'. Do you need to change your target library? Try changing the `lib` compiler option to '{2}' or later."), + Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2_or_later: diag(2550, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_c_2550", "Property '{0}' does not exist on type '{1}'. Do you need to change your target library? Try changing the 'lib' compiler option to '{2}' or later."), Property_0_does_not_exist_on_type_1_Did_you_mean_2: diag(2551, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Did_you_mean_2_2551", "Property '{0}' does not exist on type '{1}'. Did you mean '{2}'?"), Cannot_find_name_0_Did_you_mean_1: diag(2552, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Did_you_mean_1_2552", "Cannot find name '{0}'. Did you mean '{1}'?"), Computed_values_are_not_permitted_in_an_enum_with_string_valued_members: diag(2553, ts.DiagnosticCategory.Error, "Computed_values_are_not_permitted_in_an_enum_with_string_valued_members_2553", "Computed values are not permitted in an enum with string valued members."), Expected_0_arguments_but_got_1: diag(2554, ts.DiagnosticCategory.Error, "Expected_0_arguments_but_got_1_2554", "Expected {0} arguments, but got {1}."), Expected_at_least_0_arguments_but_got_1: diag(2555, ts.DiagnosticCategory.Error, "Expected_at_least_0_arguments_but_got_1_2555", "Expected at least {0} arguments, but got {1}."), - Expected_0_arguments_but_got_1_or_more: diag(2556, ts.DiagnosticCategory.Error, "Expected_0_arguments_but_got_1_or_more_2556", "Expected {0} arguments, but got {1} or more."), - Expected_at_least_0_arguments_but_got_1_or_more: diag(2557, ts.DiagnosticCategory.Error, "Expected_at_least_0_arguments_but_got_1_or_more_2557", "Expected at least {0} arguments, but got {1} or more."), + A_spread_argument_must_either_have_a_tuple_type_or_be_passed_to_a_rest_parameter: diag(2556, ts.DiagnosticCategory.Error, "A_spread_argument_must_either_have_a_tuple_type_or_be_passed_to_a_rest_parameter_2556", "A spread argument must either have a tuple type or be passed to a rest parameter."), Expected_0_type_arguments_but_got_1: diag(2558, ts.DiagnosticCategory.Error, "Expected_0_type_arguments_but_got_1_2558", "Expected {0} type arguments, but got {1}."), Type_0_has_no_properties_in_common_with_type_1: diag(2559, ts.DiagnosticCategory.Error, "Type_0_has_no_properties_in_common_with_type_1_2559", "Type '{0}' has no properties in common with type '{1}'."), Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it: diag(2560, ts.DiagnosticCategory.Error, "Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it_2560", "Value of type '{0}' has no properties in common with type '{1}'. Did you mean to call it?"), @@ -8180,17 +8400,17 @@ var ts; Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode: diag(2580, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashno_2580", "Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`."), Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery: diag(2581, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slash_2581", "Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i --save-dev @types/jquery`."), Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_types_Slashjest_or_npm_i_save_dev_types_Slashmocha: diag(2582, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_type_2582", "Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`."), - Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_1_or_later: diag(2583, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2583", "Cannot find name '{0}'. Do you need to change your target library? Try changing the `lib` compiler option to '{1}' or later."), - Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_include_dom: diag(2584, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2584", "Cannot find name '{0}'. Do you need to change your target library? Try changing the `lib` compiler option to include 'dom'."), - _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: diag(2585, ts.DiagnosticCategory.Error, "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_2585", "'{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."), + Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_1_or_later: diag(2583, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2583", "Cannot find name '{0}'. Do you need to change your target library? Try changing the 'lib' compiler option to '{1}' or later."), + Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_include_dom: diag(2584, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2584", "Cannot find name '{0}'. Do you need to change your target library? Try changing the 'lib' compiler option to include 'dom'."), + _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: diag(2585, ts.DiagnosticCategory.Error, "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_2585", "'{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."), Enum_type_0_circularly_references_itself: diag(2586, ts.DiagnosticCategory.Error, "Enum_type_0_circularly_references_itself_2586", "Enum type '{0}' circularly references itself."), JSDoc_type_0_circularly_references_itself: diag(2587, ts.DiagnosticCategory.Error, "JSDoc_type_0_circularly_references_itself_2587", "JSDoc type '{0}' circularly references itself."), Cannot_assign_to_0_because_it_is_a_constant: diag(2588, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_a_constant_2588", "Cannot assign to '{0}' because it is a constant."), Type_instantiation_is_excessively_deep_and_possibly_infinite: diag(2589, ts.DiagnosticCategory.Error, "Type_instantiation_is_excessively_deep_and_possibly_infinite_2589", "Type instantiation is excessively deep and possibly infinite."), Expression_produces_a_union_type_that_is_too_complex_to_represent: diag(2590, ts.DiagnosticCategory.Error, "Expression_produces_a_union_type_that_is_too_complex_to_represent_2590", "Expression produces a union type that is too complex to represent."), - Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode_and_then_add_node_to_the_types_field_in_your_tsconfig: diag(2591, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashno_2591", "Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node` and then add `node` to the types field in your tsconfig."), - Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery_and_then_add_jquery_to_the_types_field_in_your_tsconfig: diag(2592, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slash_2592", "Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i --save-dev @types/jquery` and then add `jquery` to the types field in your tsconfig."), - Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_types_Slashjest_or_npm_i_save_dev_types_Slashmocha_and_then_add_jest_or_mocha_to_the_types_field_in_your_tsconfig: diag(2593, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_type_2593", "Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode_and_then_add_node_to_the_types_field_in_your_tsconfig: diag(2591, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashno_2591", "Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node` and then add 'node' to the types field in your tsconfig."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery_and_then_add_jquery_to_the_types_field_in_your_tsconfig: diag(2592, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slash_2592", "Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i --save-dev @types/jquery` and then add 'jquery' to the types field in your tsconfig."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_types_Slashjest_or_npm_i_save_dev_types_Slashmocha_and_then_add_jest_or_mocha_to_the_types_field_in_your_tsconfig: diag(2593, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_type_2593", "Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig."), This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag: diag(2594, ts.DiagnosticCategory.Error, "This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the__2594", "This module is declared with using 'export =', and can only be used with a default import when using the '{0}' flag."), _0_can_only_be_imported_by_using_a_default_import: diag(2595, ts.DiagnosticCategory.Error, "_0_can_only_be_imported_by_using_a_default_import_2595", "'{0}' can only be imported by using a default import."), _0_can_only_be_imported_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import: diag(2596, ts.DiagnosticCategory.Error, "_0_can_only_be_imported_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import_2596", "'{0}' can only be imported by turning on the 'esModuleInterop' flag and using a default import."), @@ -8223,6 +8443,12 @@ var ts; Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target: diag(2625, ts.DiagnosticCategory.Error, "Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target_2625", "Variadic element at position {0} in source does not match element at position {1} in target."), Type_at_position_0_in_source_is_not_compatible_with_type_at_position_1_in_target: diag(2626, ts.DiagnosticCategory.Error, "Type_at_position_0_in_source_is_not_compatible_with_type_at_position_1_in_target_2626", "Type at position {0} in source is not compatible with type at position {1} in target."), Type_at_positions_0_through_1_in_source_is_not_compatible_with_type_at_position_2_in_target: diag(2627, ts.DiagnosticCategory.Error, "Type_at_positions_0_through_1_in_source_is_not_compatible_with_type_at_position_2_in_target_2627", "Type at positions {0} through {1} in source is not compatible with type at position {2} in target."), + Cannot_assign_to_0_because_it_is_an_enum: diag(2628, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_an_enum_2628", "Cannot assign to '{0}' because it is an enum."), + Cannot_assign_to_0_because_it_is_a_class: diag(2629, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_a_class_2629", "Cannot assign to '{0}' because it is a class."), + Cannot_assign_to_0_because_it_is_a_function: diag(2630, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_a_function_2630", "Cannot assign to '{0}' because it is a function."), + Cannot_assign_to_0_because_it_is_a_namespace: diag(2631, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_a_namespace_2631", "Cannot assign to '{0}' because it is a namespace."), + Cannot_assign_to_0_because_it_is_an_import: diag(2632, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_an_import_2632", "Cannot assign to '{0}' because it is an import."), + JSX_property_access_expressions_cannot_include_JSX_namespace_names: diag(2633, ts.DiagnosticCategory.Error, "JSX_property_access_expressions_cannot_include_JSX_namespace_names_2633", "JSX property access expressions cannot include JSX namespace names"), Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: diag(2649, ts.DiagnosticCategory.Error, "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", "Cannot augment module '{0}' with value exports because it resolves to a non-module entity."), A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: diag(2651, ts.DiagnosticCategory.Error, "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums."), Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: diag(2652, ts.DiagnosticCategory.Error, "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead."), @@ -8269,7 +8495,7 @@ var ts; Namespace_0_has_no_exported_member_1: diag(2694, ts.DiagnosticCategory.Error, "Namespace_0_has_no_exported_member_1_2694", "Namespace '{0}' has no exported member '{1}'."), Left_side_of_comma_operator_is_unused_and_has_no_side_effects: diag(2695, ts.DiagnosticCategory.Error, "Left_side_of_comma_operator_is_unused_and_has_no_side_effects_2695", "Left side of comma operator is unused and has no side effects.", /*reportsUnnecessary*/ true), The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead: diag(2696, ts.DiagnosticCategory.Error, "The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead_2696", "The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?"), - An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: diag(2697, ts.DiagnosticCategory.Error, "An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_in_2697", "An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option."), + An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: diag(2697, ts.DiagnosticCategory.Error, "An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_in_2697", "An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your '--lib' option."), Spread_types_may_only_be_created_from_object_types: diag(2698, ts.DiagnosticCategory.Error, "Spread_types_may_only_be_created_from_object_types_2698", "Spread types may only be created from object types."), Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1: diag(2699, ts.DiagnosticCategory.Error, "Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1_2699", "Static property '{0}' conflicts with built-in property 'Function.{0}' of constructor function '{1}'."), Rest_types_may_only_be_created_from_object_types: diag(2700, ts.DiagnosticCategory.Error, "Rest_types_may_only_be_created_from_object_types_2700", "Rest types may only be created from object types."), @@ -8277,14 +8503,14 @@ var ts; _0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here: diag(2702, ts.DiagnosticCategory.Error, "_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here_2702", "'{0}' only refers to a type, but is being used as a namespace here."), The_operand_of_a_delete_operator_must_be_a_property_reference: diag(2703, ts.DiagnosticCategory.Error, "The_operand_of_a_delete_operator_must_be_a_property_reference_2703", "The operand of a 'delete' operator must be a property reference."), The_operand_of_a_delete_operator_cannot_be_a_read_only_property: diag(2704, ts.DiagnosticCategory.Error, "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704", "The operand of a 'delete' operator cannot be a read-only property."), - 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: diag(2705, ts.DiagnosticCategory.Error, "An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_de_2705", "An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option."), + 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: diag(2705, ts.DiagnosticCategory.Error, "An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_de_2705", "An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option."), Required_type_parameters_may_not_follow_optional_type_parameters: diag(2706, ts.DiagnosticCategory.Error, "Required_type_parameters_may_not_follow_optional_type_parameters_2706", "Required type parameters may not follow optional type parameters."), Generic_type_0_requires_between_1_and_2_type_arguments: diag(2707, ts.DiagnosticCategory.Error, "Generic_type_0_requires_between_1_and_2_type_arguments_2707", "Generic type '{0}' requires between {1} and {2} type arguments."), Cannot_use_namespace_0_as_a_value: diag(2708, ts.DiagnosticCategory.Error, "Cannot_use_namespace_0_as_a_value_2708", "Cannot use namespace '{0}' as a value."), Cannot_use_namespace_0_as_a_type: diag(2709, ts.DiagnosticCategory.Error, "Cannot_use_namespace_0_as_a_type_2709", "Cannot use namespace '{0}' as a type."), _0_are_specified_twice_The_attribute_named_0_will_be_overwritten: diag(2710, ts.DiagnosticCategory.Error, "_0_are_specified_twice_The_attribute_named_0_will_be_overwritten_2710", "'{0}' are specified twice. The attribute named '{0}' will be overwritten."), - A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: diag(2711, ts.DiagnosticCategory.Error, "A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES20_2711", "A dynamic import call returns a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option."), - A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option: diag(2712, ts.DiagnosticCategory.Error, "A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declarat_2712", "A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option."), + A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: diag(2711, ts.DiagnosticCategory.Error, "A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES20_2711", "A dynamic import call returns a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your '--lib' option."), + A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option: diag(2712, ts.DiagnosticCategory.Error, "A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declarat_2712", "A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option."), 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: diag(2713, ts.DiagnosticCategory.Error, "Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_p_2713", "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}\"]'?"), The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context: diag(2714, ts.DiagnosticCategory.Error, "The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context_2714", "The expression of an export assignment must be an identifier or qualified name in an ambient context."), Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor: diag(2715, ts.DiagnosticCategory.Error, "Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor_2715", "Abstract property '{0}' in class '{1}' cannot be accessed in the constructor."), @@ -8346,7 +8572,7 @@ var ts; The_last_overload_is_declared_here: diag(2771, ts.DiagnosticCategory.Error, "The_last_overload_is_declared_here_2771", "The last overload is declared here."), Overload_0_of_1_2_gave_the_following_error: diag(2772, ts.DiagnosticCategory.Error, "Overload_0_of_1_2_gave_the_following_error_2772", "Overload {0} of {1}, '{2}', gave the following error."), Did_you_forget_to_use_await: diag(2773, ts.DiagnosticCategory.Error, "Did_you_forget_to_use_await_2773", "Did you forget to use 'await'?"), - This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead: diag(2774, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it__2774", "This condition will always return true since the function is always defined. Did you mean to call it instead?"), + This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_instead: diag(2774, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_2774", "This condition will always return true since this function is always defined. Did you mean to call it instead?"), Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation: diag(2775, ts.DiagnosticCategory.Error, "Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation_2775", "Assertions require every name in the call target to be declared with an explicit type annotation."), Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name: diag(2776, ts.DiagnosticCategory.Error, "Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name_2776", "Assertions require the call target to be an identifier or qualified name."), The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access: diag(2777, ts.DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access_2777", "The operand of an increment or decrement operator may not be an optional property access."), @@ -8370,6 +8596,23 @@ var ts; The_intrinsic_keyword_can_only_be_used_to_declare_compiler_provided_intrinsic_types: diag(2795, ts.DiagnosticCategory.Error, "The_intrinsic_keyword_can_only_be_used_to_declare_compiler_provided_intrinsic_types_2795", "The 'intrinsic' keyword can only be used to declare compiler provided intrinsic types."), It_is_likely_that_you_are_missing_a_comma_to_separate_these_two_template_expressions_They_form_a_tagged_template_expression_which_cannot_be_invoked: diag(2796, ts.DiagnosticCategory.Error, "It_is_likely_that_you_are_missing_a_comma_to_separate_these_two_template_expressions_They_form_a_tag_2796", "It is likely that you are missing a comma to separate these two template expressions. They form a tagged template expression which cannot be invoked."), A_mixin_class_that_extends_from_a_type_variable_containing_an_abstract_construct_signature_must_also_be_declared_abstract: diag(2797, ts.DiagnosticCategory.Error, "A_mixin_class_that_extends_from_a_type_variable_containing_an_abstract_construct_signature_must_also_2797", "A mixin class that extends from a type variable containing an abstract construct signature must also be declared 'abstract'."), + The_declaration_was_marked_as_deprecated_here: diag(2798, ts.DiagnosticCategory.Error, "The_declaration_was_marked_as_deprecated_here_2798", "The declaration was marked as deprecated here."), + Type_produces_a_tuple_type_that_is_too_large_to_represent: diag(2799, ts.DiagnosticCategory.Error, "Type_produces_a_tuple_type_that_is_too_large_to_represent_2799", "Type produces a tuple type that is too large to represent."), + Expression_produces_a_tuple_type_that_is_too_large_to_represent: diag(2800, ts.DiagnosticCategory.Error, "Expression_produces_a_tuple_type_that_is_too_large_to_represent_2800", "Expression produces a tuple type that is too large to represent."), + This_condition_will_always_return_true_since_this_0_is_always_defined: diag(2801, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_this_0_is_always_defined_2801", "This condition will always return true since this '{0}' is always defined."), + Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher: diag(2802, ts.DiagnosticCategory.Error, "Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es201_2802", "Type '{0}' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher."), + Cannot_assign_to_private_method_0_Private_methods_are_not_writable: diag(2803, ts.DiagnosticCategory.Error, "Cannot_assign_to_private_method_0_Private_methods_are_not_writable_2803", "Cannot assign to private method '{0}'. Private methods are not writable."), + Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name: diag(2804, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name_2804", "Duplicate identifier '{0}'. Static and instance elements cannot share the same private name."), + Static_fields_with_private_names_can_t_have_initializers_when_the_useDefineForClassFields_flag_is_not_specified_with_a_target_of_esnext_Consider_adding_the_useDefineForClassFields_flag: diag(2805, ts.DiagnosticCategory.Error, "Static_fields_with_private_names_can_t_have_initializers_when_the_useDefineForClassFields_flag_is_no_2805", "Static fields with private names can't have initializers when the '--useDefineForClassFields' flag is not specified with a '--target' of 'esnext'. Consider adding the '--useDefineForClassFields' flag."), + Private_accessor_was_defined_without_a_getter: diag(2806, ts.DiagnosticCategory.Error, "Private_accessor_was_defined_without_a_getter_2806", "Private accessor was defined without a getter."), + 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: diag(2807, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807", "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}'."), + A_get_accessor_must_be_at_least_as_accessible_as_the_setter: diag(2808, ts.DiagnosticCategory.Error, "A_get_accessor_must_be_at_least_as_accessible_as_the_setter_2808", "A get accessor must be at least as accessible as the setter"), + 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: diag(2809, ts.DiagnosticCategory.Error, "Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_d_2809", "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."), + Property_0_may_not_be_used_in_a_static_property_s_initializer_in_the_same_class_when_target_is_esnext_and_useDefineForClassFields_is_false: diag(2810, ts.DiagnosticCategory.Error, "Property_0_may_not_be_used_in_a_static_property_s_initializer_in_the_same_class_when_target_is_esnex_2810", "Property '{0}' may not be used in a static property's initializer in the same class when 'target' is 'esnext' and 'useDefineForClassFields' is 'false'."), + Initializer_for_property_0: diag(2811, ts.DiagnosticCategory.Error, "Initializer_for_property_0_2811", "Initializer for property '{0}'"), + Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom: diag(2812, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom_2812", "Property '{0}' does not exist on type '{1}'. Try changing the 'lib' compiler option to include 'dom'."), + Class_declaration_cannot_implement_overload_list_for_0: diag(2813, ts.DiagnosticCategory.Error, "Class_declaration_cannot_implement_overload_list_for_0_2813", "Class declaration cannot implement overload list for '{0}'."), + Function_with_bodies_can_only_merge_with_classes_that_are_ambient: diag(2814, ts.DiagnosticCategory.Error, "Function_with_bodies_can_only_merge_with_classes_that_are_ambient_2814", "Function with bodies can only merge with classes that are ambient."), 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}'."), @@ -8442,6 +8685,7 @@ var ts; Exported_type_alias_0_has_or_is_using_private_name_1: diag(4081, ts.DiagnosticCategory.Error, "Exported_type_alias_0_has_or_is_using_private_name_1_4081", "Exported type alias '{0}' has or is using private name '{1}'."), Default_export_of_the_module_has_or_is_using_private_name_0: diag(4082, ts.DiagnosticCategory.Error, "Default_export_of_the_module_has_or_is_using_private_name_0_4082", "Default export of the module has or is using private name '{0}'."), Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1: diag(4083, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1_4083", "Type parameter '{0}' of exported type alias has or is using private name '{1}'."), + Exported_type_alias_0_has_or_is_using_private_name_1_from_module_2: diag(4084, ts.DiagnosticCategory.Error, "Exported_type_alias_0_has_or_is_using_private_name_1_from_module_2_4084", "Exported type alias '{0}' has or is using private name '{1}' from module {2}."), Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict: diag(4090, ts.DiagnosticCategory.Error, "Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_librar_4090", "Conflicting definitions for '{0}' found at '{1}' and '{2}'. Consider installing a specific version of this library to resolve the conflict."), Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: diag(4091, ts.DiagnosticCategory.Error, "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4091", "Parameter '{0}' of index signature from exported interface has or is using name '{1}' from private module '{2}'."), Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1: diag(4092, ts.DiagnosticCategory.Error, "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1_4092", "Parameter '{0}' of index signature from exported interface has or is using private name '{1}'."), @@ -8463,6 +8707,12 @@ var ts; Type_arguments_for_0_circularly_reference_themselves: diag(4109, ts.DiagnosticCategory.Error, "Type_arguments_for_0_circularly_reference_themselves_4109", "Type arguments for '{0}' circularly reference themselves."), Tuple_type_arguments_circularly_reference_themselves: diag(4110, ts.DiagnosticCategory.Error, "Tuple_type_arguments_circularly_reference_themselves_4110", "Tuple type arguments circularly reference themselves."), Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0: diag(4111, ts.DiagnosticCategory.Error, "Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0_4111", "Property '{0}' comes from an index signature, so it must be accessed with ['{0}']."), + This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class: diag(4112, ts.DiagnosticCategory.Error, "This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another__4112", "This member cannot have an 'override' modifier because its containing class '{0}' does not extend another class."), + This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0: diag(4113, ts.DiagnosticCategory.Error, "This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0_4113", "This member cannot have an 'override' modifier because it is not declared in the base class '{0}'."), + This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0: diag(4114, ts.DiagnosticCategory.Error, "This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0_4114", "This member must have an 'override' modifier because it overrides a member in the base class '{0}'."), + This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0: diag(4115, ts.DiagnosticCategory.Error, "This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0_4115", "This parameter property must have an 'override' modifier because it overrides a member in base class '{0}'."), + This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0: diag(4116, ts.DiagnosticCategory.Error, "This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared__4116", "This member must have an 'override' modifier because it overrides an abstract method that is declared in the base class '{0}'."), + This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1: diag(4117, ts.DiagnosticCategory.Error, "This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0_Did_you__4117", "This member cannot have an 'override' modifier because it is not declared in the base class '{0}'. Did you mean '{1}'?"), The_current_host_does_not_support_the_0_option: diag(5001, ts.DiagnosticCategory.Error, "The_current_host_does_not_support_the_0_option_5001", "The current host does not support the '{0}' option."), Cannot_find_the_common_subdirectory_path_for_the_input_files: diag(5009, ts.DiagnosticCategory.Error, "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", "Cannot find the common subdirectory path for the input files."), File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5010, ts.DiagnosticCategory.Error, "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", "File specification cannot end in a recursive directory wildcard ('**'): '{0}'."), @@ -8497,7 +8747,7 @@ var ts; Option_resolveJsonModule_can_only_be_specified_when_module_code_generation_is_commonjs_amd_es2015_or_esNext: diag(5071, ts.DiagnosticCategory.Error, "Option_resolveJsonModule_can_only_be_specified_when_module_code_generation_is_commonjs_amd_es2015_or_5071", "Option '--resolveJsonModule' can only be specified when module code generation is 'commonjs', 'amd', 'es2015' or 'esNext'."), Unknown_build_option_0: diag(5072, ts.DiagnosticCategory.Error, "Unknown_build_option_0_5072", "Unknown build option '{0}'."), Build_option_0_requires_a_value_of_type_1: diag(5073, ts.DiagnosticCategory.Error, "Build_option_0_requires_a_value_of_type_1_5073", "Build option '{0}' requires a value of type {1}."), - Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified: diag(5074, ts.DiagnosticCategory.Error, "Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBui_5074", "Option '--incremental' can only be specified using tsconfig, emitting to single file or when option `--tsBuildInfoFile` is specified."), + Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified: diag(5074, ts.DiagnosticCategory.Error, "Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBui_5074", "Option '--incremental' can only be specified using tsconfig, emitting to single file or when option '--tsBuildInfoFile' is specified."), _0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2: diag(5075, ts.DiagnosticCategory.Error, "_0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_5075", "'{0}' is assignable to the constraint of type '{1}', but '{1}' could be instantiated with a different subtype of constraint '{2}'."), _0_and_1_operations_cannot_be_mixed_without_parentheses: diag(5076, ts.DiagnosticCategory.Error, "_0_and_1_operations_cannot_be_mixed_without_parentheses_5076", "'{0}' and '{1}' operations cannot be mixed without parentheses."), Unknown_build_option_0_Did_you_mean_1: diag(5077, ts.DiagnosticCategory.Error, "Unknown_build_option_0_Did_you_mean_1_5077", "Unknown build option '{0}'. Did you mean '{1}'?"), @@ -8510,10 +8760,14 @@ var ts; Tuple_members_must_all_have_names_or_all_not_have_names: diag(5084, ts.DiagnosticCategory.Error, "Tuple_members_must_all_have_names_or_all_not_have_names_5084", "Tuple members must all have names or all not have names."), A_tuple_member_cannot_be_both_optional_and_rest: diag(5085, ts.DiagnosticCategory.Error, "A_tuple_member_cannot_be_both_optional_and_rest_5085", "A tuple member cannot be both optional and rest."), A_labeled_tuple_element_is_declared_as_optional_with_a_question_mark_after_the_name_and_before_the_colon_rather_than_after_the_type: diag(5086, ts.DiagnosticCategory.Error, "A_labeled_tuple_element_is_declared_as_optional_with_a_question_mark_after_the_name_and_before_the_c_5086", "A labeled tuple element is declared as optional with a question mark after the name and before the colon, rather than after the type."), - A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type: diag(5087, ts.DiagnosticCategory.Error, "A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type_5087", "A labeled tuple element is declared as rest with a `...` before the name, rather than before the type."), + A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type: diag(5087, ts.DiagnosticCategory.Error, "A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type_5087", "A labeled tuple element is declared as rest with a '...' before the name, rather than before the type."), The_inferred_type_of_0_references_a_type_with_a_cyclic_structure_which_cannot_be_trivially_serialized_A_type_annotation_is_necessary: diag(5088, ts.DiagnosticCategory.Error, "The_inferred_type_of_0_references_a_type_with_a_cyclic_structure_which_cannot_be_trivially_serialize_5088", "The inferred type of '{0}' references a type with a cyclic structure which cannot be trivially serialized. A type annotation is necessary."), Option_0_cannot_be_specified_when_option_jsx_is_1: diag(5089, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_when_option_jsx_is_1_5089", "Option '{0}' cannot be specified when option 'jsx' is '{1}'."), Non_relative_paths_are_not_allowed_when_baseUrl_is_not_set_Did_you_forget_a_leading_Slash: diag(5090, ts.DiagnosticCategory.Error, "Non_relative_paths_are_not_allowed_when_baseUrl_is_not_set_Did_you_forget_a_leading_Slash_5090", "Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?"), + Option_preserveConstEnums_cannot_be_disabled_when_isolatedModules_is_enabled: diag(5091, ts.DiagnosticCategory.Error, "Option_preserveConstEnums_cannot_be_disabled_when_isolatedModules_is_enabled_5091", "Option 'preserveConstEnums' cannot be disabled when 'isolatedModules' is enabled."), + The_root_value_of_a_0_file_must_be_an_object: diag(5092, ts.DiagnosticCategory.Error, "The_root_value_of_a_0_file_must_be_an_object_5092", "The root value of a '{0}' file must be an object."), + Compiler_option_0_may_only_be_used_with_build: diag(5093, ts.DiagnosticCategory.Error, "Compiler_option_0_may_only_be_used_with_build_5093", "Compiler option '--{0}' may only be used with '--build'."), + Compiler_option_0_may_not_be_used_with_build: diag(5094, ts.DiagnosticCategory.Error, "Compiler_option_0_may_not_be_used_with_build_5094", "Compiler option '--{0}' may not be used with '--build'."), Generates_a_sourcemap_for_each_corresponding_d_ts_file: diag(6000, ts.DiagnosticCategory.Message, "Generates_a_sourcemap_for_each_corresponding_d_ts_file_6000", "Generates a sourcemap for each corresponding '.d.ts' file."), Concatenate_and_emit_output_to_single_file: diag(6001, ts.DiagnosticCategory.Message, "Concatenate_and_emit_output_to_single_file_6001", "Concatenate and emit output to single file."), Generates_corresponding_d_ts_file: diag(6002, ts.DiagnosticCategory.Message, "Generates_corresponding_d_ts_file_6002", "Generates corresponding '.d.ts' file."), @@ -8529,7 +8783,7 @@ var ts; Skip_type_checking_of_declaration_files: diag(6012, ts.DiagnosticCategory.Message, "Skip_type_checking_of_declaration_files_6012", "Skip type checking of declaration files."), Do_not_resolve_the_real_path_of_symlinks: diag(6013, ts.DiagnosticCategory.Message, "Do_not_resolve_the_real_path_of_symlinks_6013", "Do not resolve the real path of symlinks."), Only_emit_d_ts_declaration_files: diag(6014, ts.DiagnosticCategory.Message, "Only_emit_d_ts_declaration_files_6014", "Only emit '.d.ts' declaration files."), - Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_or_ESNEXT: diag(6015, ts.DiagnosticCategory.Message, "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_or_6015", "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'."), + Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_ES2021_or_ESNEXT: diag(6015, ts.DiagnosticCategory.Message, "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_ES_6015", "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'."), Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_es2020_or_ESNext: diag(6016, ts.DiagnosticCategory.Message, "Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_es2020_or_ESNext_6016", "Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'."), Print_this_message: diag(6017, ts.DiagnosticCategory.Message, "Print_this_message_6017", "Print this message."), Print_the_compiler_s_version: diag(6019, ts.DiagnosticCategory.Message, "Print_the_compiler_s_version_6019", "Print the compiler's version."), @@ -8672,19 +8926,12 @@ var ts; Show_all_compiler_options: diag(6169, ts.DiagnosticCategory.Message, "Show_all_compiler_options_6169", "Show all compiler options."), Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file: diag(6170, ts.DiagnosticCategory.Message, "Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file_6170", "[Deprecated] Use '--outFile' instead. Concatenate and emit output to single file"), Command_line_Options: diag(6171, ts.DiagnosticCategory.Message, "Command_line_Options_6171", "Command-line Options"), - Basic_Options: diag(6172, ts.DiagnosticCategory.Message, "Basic_Options_6172", "Basic Options"), - Strict_Type_Checking_Options: diag(6173, ts.DiagnosticCategory.Message, "Strict_Type_Checking_Options_6173", "Strict Type-Checking Options"), - Module_Resolution_Options: diag(6174, ts.DiagnosticCategory.Message, "Module_Resolution_Options_6174", "Module Resolution Options"), - Source_Map_Options: diag(6175, ts.DiagnosticCategory.Message, "Source_Map_Options_6175", "Source Map Options"), - Additional_Checks: diag(6176, ts.DiagnosticCategory.Message, "Additional_Checks_6176", "Additional Checks"), - Experimental_Options: diag(6177, ts.DiagnosticCategory.Message, "Experimental_Options_6177", "Experimental Options"), - Advanced_Options: diag(6178, ts.DiagnosticCategory.Message, "Advanced_Options_6178", "Advanced Options"), Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3: diag(6179, ts.DiagnosticCategory.Message, "Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3_6179", "Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'."), Enable_all_strict_type_checking_options: diag(6180, ts.DiagnosticCategory.Message, "Enable_all_strict_type_checking_options_6180", "Enable all strict type-checking options."), List_of_language_service_plugins: diag(6181, ts.DiagnosticCategory.Message, "List_of_language_service_plugins_6181", "List of language service plugins."), Scoped_package_detected_looking_in_0: diag(6182, ts.DiagnosticCategory.Message, "Scoped_package_detected_looking_in_0_6182", "Scoped package detected, looking in '{0}'"), - Reusing_resolution_of_module_0_to_file_1_from_old_program: diag(6183, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_to_file_1_from_old_program_6183", "Reusing resolution of module '{0}' to file '{1}' from old program."), - Reusing_module_resolutions_originating_in_0_since_resolutions_are_unchanged_from_old_program: diag(6184, ts.DiagnosticCategory.Message, "Reusing_module_resolutions_originating_in_0_since_resolutions_are_unchanged_from_old_program_6184", "Reusing module resolutions originating in '{0}' since resolutions are unchanged from old program."), + Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2: diag(6183, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_6183", "Reusing resolution of module '{0}' from '{1}' of old program, it was successfully resolved to '{2}'."), + Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3: diag(6184, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package__6184", "Reusing resolution of module '{0}' from '{1}' of old program, it was successfully resolved to '{2}' with Package ID '{3}'."), Disable_strict_checking_of_generic_signatures_in_function_types: diag(6185, ts.DiagnosticCategory.Message, "Disable_strict_checking_of_generic_signatures_in_function_types_6185", "Disable strict checking of generic signatures in function types."), Enable_strict_checking_of_function_types: diag(6186, ts.DiagnosticCategory.Message, "Enable_strict_checking_of_function_types_6186", "Enable strict checking of function types."), Enable_strict_checking_of_property_initialization_in_classes: diag(6187, ts.DiagnosticCategory.Message, "Enable_strict_checking_of_property_initialization_in_classes_6187", "Enable strict checking of property initialization in classes."), @@ -8724,9 +8971,9 @@ var ts; Emit_class_fields_with_Define_instead_of_Set: diag(6222, ts.DiagnosticCategory.Message, "Emit_class_fields_with_Define_instead_of_Set_6222", "Emit class fields with Define instead of Set."), Generates_a_CPU_profile: diag(6223, ts.DiagnosticCategory.Message, "Generates_a_CPU_profile_6223", "Generates a CPU profile."), Disable_solution_searching_for_this_project: diag(6224, ts.DiagnosticCategory.Message, "Disable_solution_searching_for_this_project_6224", "Disable solution searching for this project."), - Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_DynamicPriorityPolling_UseFsEvents_UseFsEventsOnParentDirectory: diag(6225, ts.DiagnosticCategory.Message, "Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_Dynami_6225", "Specify strategy for watching file: 'FixedPollingInterval' (default), 'PriorityPollingInterval', 'DynamicPriorityPolling', 'UseFsEvents', 'UseFsEventsOnParentDirectory'."), - Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling: diag(6226, ts.DiagnosticCategory.Message, "Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively__6226", "Specify strategy for watching directory on platforms that don't support recursive watching natively: 'UseFsEvents' (default), 'FixedPollingInterval', 'DynamicPriorityPolling'."), - Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority: diag(6227, ts.DiagnosticCategory.Message, "Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_6227", "Specify strategy for creating a polling watch when it fails to create using file system events: 'FixedInterval' (default), 'PriorityInterval', 'DynamicPriority'."), + Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_DynamicPriorityPolling_FixedChunkSizePolling_UseFsEvents_UseFsEventsOnParentDirectory: diag(6225, ts.DiagnosticCategory.Message, "Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_Dynami_6225", "Specify strategy for watching file: 'FixedPollingInterval' (default), 'PriorityPollingInterval', 'DynamicPriorityPolling', 'FixedChunkSizePolling', 'UseFsEvents', 'UseFsEventsOnParentDirectory'."), + Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling_FixedChunkSizePolling: diag(6226, ts.DiagnosticCategory.Message, "Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively__6226", "Specify strategy for watching directory on platforms that don't support recursive watching natively: 'UseFsEvents' (default), 'FixedPollingInterval', 'DynamicPriorityPolling', 'FixedChunkSizePolling'."), + Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority_FixedChunkSize: diag(6227, ts.DiagnosticCategory.Message, "Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_6227", "Specify strategy for creating a polling watch when it fails to create using file system events: 'FixedInterval' (default), 'PriorityInterval', 'DynamicPriority', 'FixedChunkSize'."), Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively: diag(6228, ts.DiagnosticCategory.Message, "Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_supp_6228", "Synchronously call callbacks and update the state of directory watchers on platforms that don't support recursive watching natively."), Tag_0_expects_at_least_1_arguments_but_the_JSX_factory_2_provides_at_most_3: diag(6229, ts.DiagnosticCategory.Error, "Tag_0_expects_at_least_1_arguments_but_the_JSX_factory_2_provides_at_most_3_6229", "Tag '{0}' expects at least '{1}' arguments, but the JSX factory '{2}' provides at most '{3}'."), Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line: diag(6230, ts.DiagnosticCategory.Error, "Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line_6230", "Option '{0}' can only be specified in 'tsconfig.json' file or set to 'false' or 'null' on command line."), @@ -8737,7 +8984,26 @@ var ts; Disable_loading_referenced_projects: diag(6235, ts.DiagnosticCategory.Message, "Disable_loading_referenced_projects_6235", "Disable loading referenced projects."), Arguments_for_the_rest_parameter_0_were_not_provided: diag(6236, ts.DiagnosticCategory.Error, "Arguments_for_the_rest_parameter_0_were_not_provided_6236", "Arguments for the rest parameter '{0}' were not provided."), Generates_an_event_trace_and_a_list_of_types: diag(6237, ts.DiagnosticCategory.Message, "Generates_an_event_trace_and_a_list_of_types_6237", "Generates an event trace and a list of types."), - Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react: diag(6238, ts.DiagnosticCategory.Error, "Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react_6238", "Specify the module specifier to be used to import the `jsx` and `jsxs` factory functions from. eg, react"), + Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react: diag(6238, ts.DiagnosticCategory.Error, "Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react_6238", "Specify the module specifier to be used to import the 'jsx' and 'jsxs' factory functions from. eg, react"), + File_0_exists_according_to_earlier_cached_lookups: diag(6239, ts.DiagnosticCategory.Message, "File_0_exists_according_to_earlier_cached_lookups_6239", "File '{0}' exists according to earlier cached lookups."), + File_0_does_not_exist_according_to_earlier_cached_lookups: diag(6240, ts.DiagnosticCategory.Message, "File_0_does_not_exist_according_to_earlier_cached_lookups_6240", "File '{0}' does not exist according to earlier cached lookups."), + Resolution_for_type_reference_directive_0_was_found_in_cache_from_location_1: diag(6241, ts.DiagnosticCategory.Message, "Resolution_for_type_reference_directive_0_was_found_in_cache_from_location_1_6241", "Resolution for type reference directive '{0}' was found in cache from location '{1}'."), + Resolving_type_reference_directive_0_containing_file_1: diag(6242, ts.DiagnosticCategory.Message, "Resolving_type_reference_directive_0_containing_file_1_6242", "======== Resolving type reference directive '{0}', containing file '{1}'. ========"), + Enable_strict_checking_of_optional_properties: diag(6243, ts.DiagnosticCategory.Message, "Enable_strict_checking_of_optional_properties_6243", "Enable strict checking of optional properties."), + Modules: diag(6244, ts.DiagnosticCategory.Message, "Modules_6244", "Modules"), + File_Management: diag(6245, ts.DiagnosticCategory.Message, "File_Management_6245", "File Management"), + Emit: diag(6246, ts.DiagnosticCategory.Message, "Emit_6246", "Emit"), + JavaScript_Support: diag(6247, ts.DiagnosticCategory.Message, "JavaScript_Support_6247", "JavaScript Support"), + Type_Checking: diag(6248, ts.DiagnosticCategory.Message, "Type_Checking_6248", "Type Checking"), + Editor_Support: diag(6249, ts.DiagnosticCategory.Message, "Editor_Support_6249", "Editor Support"), + Watch_and_Build_Modes: diag(6250, ts.DiagnosticCategory.Message, "Watch_and_Build_Modes_6250", "Watch and Build Modes"), + Compiler_Diagnostics: diag(6251, ts.DiagnosticCategory.Message, "Compiler_Diagnostics_6251", "Compiler Diagnostics"), + Interop_Constraints: diag(6252, ts.DiagnosticCategory.Message, "Interop_Constraints_6252", "Interop Constraints"), + Backwards_Compatibility: diag(6253, ts.DiagnosticCategory.Message, "Backwards_Compatibility_6253", "Backwards Compatibility"), + Language_and_Environment: diag(6254, ts.DiagnosticCategory.Message, "Language_and_Environment_6254", "Language and Environment"), + Projects: diag(6255, ts.DiagnosticCategory.Message, "Projects_6255", "Projects"), + Output_Formatting: diag(6256, ts.DiagnosticCategory.Message, "Output_Formatting_6256", "Output Formatting"), + Completeness: diag(6257, ts.DiagnosticCategory.Message, "Completeness_6257", "Completeness"), Projects_to_reference: diag(6300, ts.DiagnosticCategory.Message, "Projects_to_reference_6300", "Projects to reference"), Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"), Composite_projects_may_not_disable_declaration_emit: diag(6304, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_declaration_emit_6304", "Composite projects may not disable declaration emit."), @@ -8782,16 +9048,31 @@ var ts; Skipping_build_of_project_0_because_its_dependency_1_was_not_built: diag(6382, ts.DiagnosticCategory.Message, "Skipping_build_of_project_0_because_its_dependency_1_was_not_built_6382", "Skipping build of project '{0}' because its dependency '{1}' was not built"), Project_0_can_t_be_built_because_its_dependency_1_was_not_built: diag(6383, ts.DiagnosticCategory.Message, "Project_0_can_t_be_built_because_its_dependency_1_was_not_built_6383", "Project '{0}' can't be built because its dependency '{1}' was not built"), Have_recompiles_in_incremental_and_watch_assume_that_changes_within_a_file_will_only_affect_files_directly_depending_on_it: diag(6384, ts.DiagnosticCategory.Message, "Have_recompiles_in_incremental_and_watch_assume_that_changes_within_a_file_will_only_affect_files_di_6384", "Have recompiles in '--incremental' and '--watch' assume that changes within a file will only affect files directly depending on it."), - _0_is_deprecated: diag(6385, ts.DiagnosticCategory.Suggestion, "_0_is_deprecated_6385", "'{0}' is deprecated", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ undefined, /*reportsDeprecated*/ true), + _0_is_deprecated: diag(6385, ts.DiagnosticCategory.Suggestion, "_0_is_deprecated_6385", "'{0}' is deprecated.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ undefined, /*reportsDeprecated*/ true), Performance_timings_for_diagnostics_or_extendedDiagnostics_are_not_available_in_this_session_A_native_implementation_of_the_Web_Performance_API_could_not_be_found: diag(6386, ts.DiagnosticCategory.Message, "Performance_timings_for_diagnostics_or_extendedDiagnostics_are_not_available_in_this_session_A_nativ_6386", "Performance timings for '--diagnostics' or '--extendedDiagnostics' are not available in this session. A native implementation of the Web Performance API could not be found."), + The_signature_0_of_1_is_deprecated: diag(6387, ts.DiagnosticCategory.Suggestion, "The_signature_0_of_1_is_deprecated_6387", "The signature '{0}' of '{1}' is deprecated.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ undefined, /*reportsDeprecated*/ true), + Project_0_is_being_forcibly_rebuilt: diag(6388, ts.DiagnosticCategory.Message, "Project_0_is_being_forcibly_rebuilt_6388", "Project '{0}' is being forcibly rebuilt"), + Reusing_resolution_of_module_0_from_1_of_old_program_it_was_not_resolved: diag(6389, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_of_old_program_it_was_not_resolved_6389", "Reusing resolution of module '{0}' from '{1}' of old program, it was not resolved."), + Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2: diag(6390, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved__6390", "Reusing resolution of type reference directive '{0}' from '{1}' of old program, it was successfully resolved to '{2}'."), + Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3: diag(6391, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved__6391", "Reusing resolution of type reference directive '{0}' from '{1}' of old program, it was successfully resolved to '{2}' with Package ID '{3}'."), + Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_not_resolved: diag(6392, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_not_resolved_6392", "Reusing resolution of type reference directive '{0}' from '{1}' of old program, it was not resolved."), + Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3: diag(6393, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_6393", "Reusing resolution of module '{0}' from '{1}' found in cache from location '{2}', it was successfully resolved to '{3}'."), + Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4: diag(6394, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_6394", "Reusing resolution of module '{0}' from '{1}' found in cache from location '{2}', it was successfully resolved to '{3}' with Package ID '{4}'."), + Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_not_resolved: diag(6395, ts.DiagnosticCategory.Message, "Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_not_resolved_6395", "Reusing resolution of module '{0}' from '{1}' found in cache from location '{2}', it was not resolved."), + Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3: diag(6396, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_succes_6396", "Reusing resolution of type reference directive '{0}' from '{1}' found in cache from location '{2}', it was successfully resolved to '{3}'."), + Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4: diag(6397, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_succes_6397", "Reusing resolution of type reference directive '{0}' from '{1}' found in cache from location '{2}', it was successfully resolved to '{3}' with Package ID '{4}'."), + Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_not_resolved: diag(6398, ts.DiagnosticCategory.Message, "Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_not_re_6398", "Reusing resolution of type reference directive '{0}' from '{1}' found in cache from location '{2}', it was not resolved."), The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"), The_expected_type_comes_from_this_index_signature: diag(6501, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."), The_expected_type_comes_from_the_return_type_of_this_signature: diag(6502, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_the_return_type_of_this_signature_6502", "The expected type comes from the return type of this signature."), Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing: diag(6503, ts.DiagnosticCategory.Message, "Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing_6503", "Print names of files that are part of the compilation and then stop processing."), File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option: diag(6504, ts.DiagnosticCategory.Error, "File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option_6504", "File '{0}' is a JavaScript file. Did you mean to enable the 'allowJs' option?"), Print_names_of_files_and_the_reason_they_are_part_of_the_compilation: diag(6505, ts.DiagnosticCategory.Message, "Print_names_of_files_and_the_reason_they_are_part_of_the_compilation_6505", "Print names of files and the reason they are part of the compilation."), - Require_undeclared_properties_from_index_signatures_to_use_element_accesses: diag(6803, ts.DiagnosticCategory.Error, "Require_undeclared_properties_from_index_signatures_to_use_element_accesses_6803", "Require undeclared properties from index signatures to use element accesses."), + Consider_adding_a_declare_modifier_to_this_class: diag(6506, ts.DiagnosticCategory.Message, "Consider_adding_a_declare_modifier_to_this_class_6506", "Consider adding a 'declare' modifier to this class."), Include_undefined_in_index_signature_results: diag(6800, ts.DiagnosticCategory.Message, "Include_undefined_in_index_signature_results_6800", "Include 'undefined' in index signature results"), + Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier: diag(6801, ts.DiagnosticCategory.Message, "Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier_6801", "Ensure overriding members in derived classes are marked with an 'override' modifier."), + Require_undeclared_properties_from_index_signatures_to_use_element_accesses: diag(6802, ts.DiagnosticCategory.Message, "Require_undeclared_properties_from_index_signatures_to_use_element_accesses_6802", "Require undeclared properties from index signatures to use element accesses."), + Type_catch_clause_variables_as_unknown_instead_of_any: diag(6803, ts.DiagnosticCategory.Message, "Type_catch_clause_variables_as_unknown_instead_of_any_6803", "Type catch clause variables as 'unknown' instead of 'any'."), Variable_0_implicitly_has_an_1_type: diag(7005, ts.DiagnosticCategory.Error, "Variable_0_implicitly_has_an_1_type_7005", "Variable '{0}' implicitly has an '{1}' type."), Parameter_0_implicitly_has_an_1_type: diag(7006, ts.DiagnosticCategory.Error, "Parameter_0_implicitly_has_an_1_type_7006", "Parameter '{0}' implicitly has an '{1}' type."), Member_0_implicitly_has_an_1_type: diag(7008, ts.DiagnosticCategory.Error, "Member_0_implicitly_has_an_1_type_7008", "Member '{0}' implicitly has an '{1}' type."), @@ -8824,7 +9105,7 @@ var ts; Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for_all_imports_Implies_allowSyntheticDefaultImports: diag(7037, ts.DiagnosticCategory.Message, "Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for__7037", "Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'."), Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead: diag(7038, ts.DiagnosticCategory.Message, "Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cau_7038", "Type originates at this import. A namespace-style import cannot be called or constructed, and will cause a failure at runtime. Consider using a default import or import require here instead."), Mapped_object_type_implicitly_has_an_any_template_type: diag(7039, ts.DiagnosticCategory.Error, "Mapped_object_type_implicitly_has_an_any_template_type_7039", "Mapped object type implicitly has an 'any' template type."), - If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_1: diag(7040, ts.DiagnosticCategory.Error, "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040", "If the '{0}' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}`"), + If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_1: diag(7040, ts.DiagnosticCategory.Error, "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040", "If the '{0}' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}'"), The_containing_arrow_function_captures_the_global_value_of_this: diag(7041, ts.DiagnosticCategory.Error, "The_containing_arrow_function_captures_the_global_value_of_this_7041", "The containing arrow function captures the global value of 'this'."), Module_0_was_resolved_to_1_but_resolveJsonModule_is_not_used: diag(7042, ts.DiagnosticCategory.Error, "Module_0_was_resolved_to_1_but_resolveJsonModule_is_not_used_7042", "Module '{0}' was resolved to '{1}', but '--resolveJsonModule' is not used."), Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage: diag(7043, ts.DiagnosticCategory.Suggestion, "Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7043", "Variable '{0}' implicitly has an '{1}' type, but a better type may be inferred from usage."), @@ -8864,7 +9145,7 @@ var ts; JSDoc_0_is_not_attached_to_a_class: diag(8022, ts.DiagnosticCategory.Error, "JSDoc_0_is_not_attached_to_a_class_8022", "JSDoc '@{0}' is not attached to a class."), JSDoc_0_1_does_not_match_the_extends_2_clause: diag(8023, ts.DiagnosticCategory.Error, "JSDoc_0_1_does_not_match_the_extends_2_clause_8023", "JSDoc '@{0} {1}' does not match the 'extends {2}' clause."), JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name: diag(8024, ts.DiagnosticCategory.Error, "JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_8024", "JSDoc '@param' tag has name '{0}', but there is no parameter with that name."), - Class_declarations_cannot_have_more_than_one_augments_or_extends_tag: diag(8025, ts.DiagnosticCategory.Error, "Class_declarations_cannot_have_more_than_one_augments_or_extends_tag_8025", "Class declarations cannot have more than one `@augments` or `@extends` tag."), + Class_declarations_cannot_have_more_than_one_augments_or_extends_tag: diag(8025, ts.DiagnosticCategory.Error, "Class_declarations_cannot_have_more_than_one_augments_or_extends_tag_8025", "Class declarations cannot have more than one '@augments' or '@extends' tag."), Expected_0_type_arguments_provide_these_with_an_extends_tag: diag(8026, ts.DiagnosticCategory.Error, "Expected_0_type_arguments_provide_these_with_an_extends_tag_8026", "Expected {0} type arguments; provide these with an '@extends' tag."), Expected_0_1_type_arguments_provide_these_with_an_extends_tag: diag(8027, ts.DiagnosticCategory.Error, "Expected_0_1_type_arguments_provide_these_with_an_extends_tag_8027", "Expected {0}-{1} type arguments; provide these with an '@extends' tag."), JSDoc_may_only_appear_in_the_last_parameter_of_a_signature: diag(8028, ts.DiagnosticCategory.Error, "JSDoc_may_only_appear_in_the_last_parameter_of_a_signature_8028", "JSDoc '...' may only appear in the last parameter of a signature."), @@ -9109,6 +9390,11 @@ var ts; Add_all_missing_function_declarations: diag(95157, ts.DiagnosticCategory.Message, "Add_all_missing_function_declarations_95157", "Add all missing function declarations"), Method_not_implemented: diag(95158, ts.DiagnosticCategory.Message, "Method_not_implemented_95158", "Method not implemented."), Function_not_implemented: diag(95159, ts.DiagnosticCategory.Message, "Function_not_implemented_95159", "Function not implemented."), + Add_override_modifier: diag(95160, ts.DiagnosticCategory.Message, "Add_override_modifier_95160", "Add 'override' modifier"), + Remove_override_modifier: diag(95161, ts.DiagnosticCategory.Message, "Remove_override_modifier_95161", "Remove 'override' modifier"), + Add_all_missing_override_modifiers: diag(95162, ts.DiagnosticCategory.Message, "Add_all_missing_override_modifiers_95162", "Add all missing 'override' modifiers"), + Remove_all_unnecessary_override_modifiers: diag(95163, ts.DiagnosticCategory.Message, "Remove_all_unnecessary_override_modifiers_95163", "Remove all unnecessary 'override' modifiers"), + Can_only_convert_named_export: diag(95164, ts.DiagnosticCategory.Message, "Can_only_convert_named_export_95164", "Can only convert named export"), No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, ts.DiagnosticCategory.Error, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."), Classes_may_not_have_a_field_named_constructor: diag(18006, ts.DiagnosticCategory.Error, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."), JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, ts.DiagnosticCategory.Error, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"), @@ -9123,8 +9409,6 @@ var ts; The_shadowing_declaration_of_0_is_defined_here: diag(18017, ts.DiagnosticCategory.Error, "The_shadowing_declaration_of_0_is_defined_here_18017", "The shadowing declaration of '{0}' is defined here"), The_declaration_of_0_that_you_probably_intended_to_use_is_defined_here: diag(18018, ts.DiagnosticCategory.Error, "The_declaration_of_0_that_you_probably_intended_to_use_is_defined_here_18018", "The declaration of '{0}' that you probably intended to use is defined here"), _0_modifier_cannot_be_used_with_a_private_identifier: diag(18019, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_with_a_private_identifier_18019", "'{0}' modifier cannot be used with a private identifier."), - A_method_cannot_be_named_with_a_private_identifier: diag(18022, ts.DiagnosticCategory.Error, "A_method_cannot_be_named_with_a_private_identifier_18022", "A method cannot be named with a private identifier."), - An_accessor_cannot_be_named_with_a_private_identifier: diag(18023, ts.DiagnosticCategory.Error, "An_accessor_cannot_be_named_with_a_private_identifier_18023", "An accessor cannot be named with a private identifier."), An_enum_member_cannot_be_named_with_a_private_identifier: diag(18024, ts.DiagnosticCategory.Error, "An_enum_member_cannot_be_named_with_a_private_identifier_18024", "An enum member cannot be named with a private identifier."), can_only_be_used_at_the_start_of_a_file: diag(18026, ts.DiagnosticCategory.Error, "can_only_be_used_at_the_start_of_a_file_18026", "'#!' can only be used at the start of a file."), Compiler_reserves_name_0_when_emitting_private_identifier_downlevel: diag(18027, ts.DiagnosticCategory.Error, "Compiler_reserves_name_0_when_emitting_private_identifier_downlevel_18027", "Compiler reserves name '{0}' when emitting private identifier downlevel."), @@ -9136,6 +9420,7 @@ var ts; 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: diag(18033, ts.DiagnosticCategory.Error, "Only_numeric_enums_can_have_computed_members_but_this_expression_has_type_0_If_you_do_not_need_exhau_18033", "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."), Specify_the_JSX_fragment_factory_function_to_use_when_targeting_react_JSX_emit_with_jsxFactory_compiler_option_is_specified_e_g_Fragment: diag(18034, ts.DiagnosticCategory.Message, "Specify_the_JSX_fragment_factory_function_to_use_when_targeting_react_JSX_emit_with_jsxFactory_compi_18034", "Specify the JSX fragment factory function to use when targeting 'react' JSX emit with 'jsxFactory' compiler option is specified, e.g. 'Fragment'."), Invalid_value_for_jsxFragmentFactory_0_is_not_a_valid_identifier_or_qualified_name: diag(18035, ts.DiagnosticCategory.Error, "Invalid_value_for_jsxFragmentFactory_0_is_not_a_valid_identifier_or_qualified_name_18035", "Invalid value for 'jsxFragmentFactory'. '{0}' is not a valid identifier or qualified-name."), + Class_decorators_can_t_be_used_with_static_private_identifier_Consider_removing_the_experimental_decorator: diag(18036, ts.DiagnosticCategory.Error, "Class_decorators_can_t_be_used_with_static_private_identifier_Consider_removing_the_experimental_dec_18036", "Class decorators can't be used with static private identifier. Consider removing the experimental decorator."), }; })(ts || (ts = {})); var ts; @@ -9143,7 +9428,7 @@ var ts; var _a; /* @internal */ function tokenIsIdentifierOrKeyword(token) { - return token >= 78 /* Identifier */; + return token >= 79 /* Identifier */; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; /* @internal */ @@ -9152,87 +9437,88 @@ var ts; } ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan; var textToKeywordObj = (_a = { - abstract: 125 /* AbstractKeyword */, - any: 128 /* AnyKeyword */, - as: 126 /* AsKeyword */, - asserts: 127 /* AssertsKeyword */, - bigint: 155 /* BigIntKeyword */, - boolean: 131 /* BooleanKeyword */, - break: 80 /* BreakKeyword */, - case: 81 /* CaseKeyword */, - catch: 82 /* CatchKeyword */, - class: 83 /* ClassKeyword */, - continue: 85 /* ContinueKeyword */, - const: 84 /* ConstKeyword */ + abstract: 126 /* AbstractKeyword */, + any: 129 /* AnyKeyword */, + as: 127 /* AsKeyword */, + asserts: 128 /* AssertsKeyword */, + bigint: 156 /* BigIntKeyword */, + boolean: 132 /* BooleanKeyword */, + break: 81 /* BreakKeyword */, + case: 82 /* CaseKeyword */, + catch: 83 /* CatchKeyword */, + class: 84 /* ClassKeyword */, + continue: 86 /* ContinueKeyword */, + const: 85 /* ConstKeyword */ }, - _a["" + "constructor"] = 132 /* ConstructorKeyword */, - _a.debugger = 86 /* DebuggerKeyword */, - _a.declare = 133 /* DeclareKeyword */, - _a.default = 87 /* DefaultKeyword */, - _a.delete = 88 /* DeleteKeyword */, - _a.do = 89 /* DoKeyword */, - _a.else = 90 /* ElseKeyword */, - _a.enum = 91 /* EnumKeyword */, - _a.export = 92 /* ExportKeyword */, - _a.extends = 93 /* ExtendsKeyword */, - _a.false = 94 /* FalseKeyword */, - _a.finally = 95 /* FinallyKeyword */, - _a.for = 96 /* ForKeyword */, - _a.from = 153 /* FromKeyword */, - _a.function = 97 /* FunctionKeyword */, - _a.get = 134 /* GetKeyword */, - _a.if = 98 /* IfKeyword */, - _a.implements = 116 /* ImplementsKeyword */, - _a.import = 99 /* ImportKeyword */, - _a.in = 100 /* InKeyword */, - _a.infer = 135 /* InferKeyword */, - _a.instanceof = 101 /* InstanceOfKeyword */, - _a.interface = 117 /* InterfaceKeyword */, - _a.intrinsic = 136 /* IntrinsicKeyword */, - _a.is = 137 /* IsKeyword */, - _a.keyof = 138 /* KeyOfKeyword */, - _a.let = 118 /* LetKeyword */, - _a.module = 139 /* ModuleKeyword */, - _a.namespace = 140 /* NamespaceKeyword */, - _a.never = 141 /* NeverKeyword */, - _a.new = 102 /* NewKeyword */, - _a.null = 103 /* NullKeyword */, - _a.number = 144 /* NumberKeyword */, - _a.object = 145 /* ObjectKeyword */, - _a.package = 119 /* PackageKeyword */, - _a.private = 120 /* PrivateKeyword */, - _a.protected = 121 /* ProtectedKeyword */, - _a.public = 122 /* PublicKeyword */, - _a.readonly = 142 /* ReadonlyKeyword */, - _a.require = 143 /* RequireKeyword */, - _a.global = 154 /* GlobalKeyword */, - _a.return = 104 /* ReturnKeyword */, - _a.set = 146 /* SetKeyword */, - _a.static = 123 /* StaticKeyword */, - _a.string = 147 /* StringKeyword */, - _a.super = 105 /* SuperKeyword */, - _a.switch = 106 /* SwitchKeyword */, - _a.symbol = 148 /* SymbolKeyword */, - _a.this = 107 /* ThisKeyword */, - _a.throw = 108 /* ThrowKeyword */, - _a.true = 109 /* TrueKeyword */, - _a.try = 110 /* TryKeyword */, - _a.type = 149 /* TypeKeyword */, - _a.typeof = 111 /* TypeOfKeyword */, - _a.undefined = 150 /* UndefinedKeyword */, - _a.unique = 151 /* UniqueKeyword */, - _a.unknown = 152 /* UnknownKeyword */, - _a.var = 112 /* VarKeyword */, - _a.void = 113 /* VoidKeyword */, - _a.while = 114 /* WhileKeyword */, - _a.with = 115 /* WithKeyword */, - _a.yield = 124 /* YieldKeyword */, - _a.async = 129 /* AsyncKeyword */, - _a.await = 130 /* AwaitKeyword */, - _a.of = 156 /* OfKeyword */, + _a["" + "constructor"] = 133 /* ConstructorKeyword */, + _a.debugger = 87 /* DebuggerKeyword */, + _a.declare = 134 /* 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 = 154 /* FromKeyword */, + _a.function = 98 /* FunctionKeyword */, + _a.get = 135 /* GetKeyword */, + _a.if = 99 /* IfKeyword */, + _a.implements = 117 /* ImplementsKeyword */, + _a.import = 100 /* ImportKeyword */, + _a.in = 101 /* InKeyword */, + _a.infer = 136 /* InferKeyword */, + _a.instanceof = 102 /* InstanceOfKeyword */, + _a.interface = 118 /* InterfaceKeyword */, + _a.intrinsic = 137 /* IntrinsicKeyword */, + _a.is = 138 /* IsKeyword */, + _a.keyof = 139 /* KeyOfKeyword */, + _a.let = 119 /* LetKeyword */, + _a.module = 140 /* ModuleKeyword */, + _a.namespace = 141 /* NamespaceKeyword */, + _a.never = 142 /* NeverKeyword */, + _a.new = 103 /* NewKeyword */, + _a.null = 104 /* NullKeyword */, + _a.number = 145 /* NumberKeyword */, + _a.object = 146 /* ObjectKeyword */, + _a.package = 120 /* PackageKeyword */, + _a.private = 121 /* PrivateKeyword */, + _a.protected = 122 /* ProtectedKeyword */, + _a.public = 123 /* PublicKeyword */, + _a.override = 157 /* OverrideKeyword */, + _a.readonly = 143 /* ReadonlyKeyword */, + _a.require = 144 /* RequireKeyword */, + _a.global = 155 /* GlobalKeyword */, + _a.return = 105 /* ReturnKeyword */, + _a.set = 147 /* SetKeyword */, + _a.static = 124 /* StaticKeyword */, + _a.string = 148 /* StringKeyword */, + _a.super = 106 /* SuperKeyword */, + _a.switch = 107 /* SwitchKeyword */, + _a.symbol = 149 /* SymbolKeyword */, + _a.this = 108 /* ThisKeyword */, + _a.throw = 109 /* ThrowKeyword */, + _a.true = 110 /* TrueKeyword */, + _a.try = 111 /* TryKeyword */, + _a.type = 150 /* TypeKeyword */, + _a.typeof = 112 /* TypeOfKeyword */, + _a.undefined = 151 /* UndefinedKeyword */, + _a.unique = 152 /* UniqueKeyword */, + _a.unknown = 153 /* UnknownKeyword */, + _a.var = 113 /* VarKeyword */, + _a.void = 114 /* VoidKeyword */, + _a.while = 115 /* WhileKeyword */, + _a.with = 116 /* WithKeyword */, + _a.yield = 125 /* YieldKeyword */, + _a.async = 130 /* AsyncKeyword */, + _a.await = 131 /* AwaitKeyword */, + _a.of = 158 /* OfKeyword */, _a); var textToKeyword = new ts.Map(ts.getEntries(textToKeywordObj)); - var textToToken = new ts.Map(ts.getEntries(__assign(__assign({}, 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 */, "=": 62 /* EqualsToken */, "+=": 63 /* PlusEqualsToken */, "-=": 64 /* MinusEqualsToken */, "*=": 65 /* AsteriskEqualsToken */, "**=": 66 /* AsteriskAsteriskEqualsToken */, "/=": 67 /* SlashEqualsToken */, "%=": 68 /* PercentEqualsToken */, "<<=": 69 /* LessThanLessThanEqualsToken */, ">>=": 70 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 72 /* AmpersandEqualsToken */, "|=": 73 /* BarEqualsToken */, "^=": 77 /* CaretEqualsToken */, "||=": 74 /* BarBarEqualsToken */, "&&=": 75 /* AmpersandAmpersandEqualsToken */, "??=": 76 /* QuestionQuestionEqualsToken */, "@": 59 /* AtToken */, "`": 61 /* BacktickToken */ }))); + var textToToken = new ts.Map(ts.getEntries(__assign(__assign({}, 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 */ }))); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers IdentifierStart :: @@ -9288,13 +9574,13 @@ var ts; var unicodeESNextIdentifierStart = [65, 90, 97, 122, 170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 895, 895, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1327, 1329, 1366, 1369, 1369, 1376, 1416, 1488, 1514, 1519, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2144, 2154, 2208, 2228, 2230, 2237, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2432, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2556, 2556, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2809, 2809, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3129, 3133, 3133, 3160, 3162, 3168, 3169, 3200, 3200, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3412, 3414, 3423, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3718, 3722, 3724, 3747, 3749, 3749, 3751, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5109, 5112, 5117, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5880, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6264, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6430, 6480, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7296, 7304, 7312, 7354, 7357, 7359, 7401, 7404, 7406, 7411, 7413, 7414, 7418, 7418, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8472, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12443, 12447, 12449, 12538, 12540, 12543, 12549, 12591, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40943, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42653, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42943, 42946, 42950, 42999, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43261, 43262, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43488, 43492, 43494, 43503, 43514, 43518, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43646, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43824, 43866, 43868, 43879, 43888, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 65536, 65547, 65549, 65574, 65576, 65594, 65596, 65597, 65599, 65613, 65616, 65629, 65664, 65786, 65856, 65908, 66176, 66204, 66208, 66256, 66304, 66335, 66349, 66378, 66384, 66421, 66432, 66461, 66464, 66499, 66504, 66511, 66513, 66517, 66560, 66717, 66736, 66771, 66776, 66811, 66816, 66855, 66864, 66915, 67072, 67382, 67392, 67413, 67424, 67431, 67584, 67589, 67592, 67592, 67594, 67637, 67639, 67640, 67644, 67644, 67647, 67669, 67680, 67702, 67712, 67742, 67808, 67826, 67828, 67829, 67840, 67861, 67872, 67897, 67968, 68023, 68030, 68031, 68096, 68096, 68112, 68115, 68117, 68119, 68121, 68149, 68192, 68220, 68224, 68252, 68288, 68295, 68297, 68324, 68352, 68405, 68416, 68437, 68448, 68466, 68480, 68497, 68608, 68680, 68736, 68786, 68800, 68850, 68864, 68899, 69376, 69404, 69415, 69415, 69424, 69445, 69600, 69622, 69635, 69687, 69763, 69807, 69840, 69864, 69891, 69926, 69956, 69956, 69968, 70002, 70006, 70006, 70019, 70066, 70081, 70084, 70106, 70106, 70108, 70108, 70144, 70161, 70163, 70187, 70272, 70278, 70280, 70280, 70282, 70285, 70287, 70301, 70303, 70312, 70320, 70366, 70405, 70412, 70415, 70416, 70419, 70440, 70442, 70448, 70450, 70451, 70453, 70457, 70461, 70461, 70480, 70480, 70493, 70497, 70656, 70708, 70727, 70730, 70751, 70751, 70784, 70831, 70852, 70853, 70855, 70855, 71040, 71086, 71128, 71131, 71168, 71215, 71236, 71236, 71296, 71338, 71352, 71352, 71424, 71450, 71680, 71723, 71840, 71903, 71935, 71935, 72096, 72103, 72106, 72144, 72161, 72161, 72163, 72163, 72192, 72192, 72203, 72242, 72250, 72250, 72272, 72272, 72284, 72329, 72349, 72349, 72384, 72440, 72704, 72712, 72714, 72750, 72768, 72768, 72818, 72847, 72960, 72966, 72968, 72969, 72971, 73008, 73030, 73030, 73056, 73061, 73063, 73064, 73066, 73097, 73112, 73112, 73440, 73458, 73728, 74649, 74752, 74862, 74880, 75075, 77824, 78894, 82944, 83526, 92160, 92728, 92736, 92766, 92880, 92909, 92928, 92975, 92992, 92995, 93027, 93047, 93053, 93071, 93760, 93823, 93952, 94026, 94032, 94032, 94099, 94111, 94176, 94177, 94179, 94179, 94208, 100343, 100352, 101106, 110592, 110878, 110928, 110930, 110948, 110951, 110960, 111355, 113664, 113770, 113776, 113788, 113792, 113800, 113808, 113817, 119808, 119892, 119894, 119964, 119966, 119967, 119970, 119970, 119973, 119974, 119977, 119980, 119982, 119993, 119995, 119995, 119997, 120003, 120005, 120069, 120071, 120074, 120077, 120084, 120086, 120092, 120094, 120121, 120123, 120126, 120128, 120132, 120134, 120134, 120138, 120144, 120146, 120485, 120488, 120512, 120514, 120538, 120540, 120570, 120572, 120596, 120598, 120628, 120630, 120654, 120656, 120686, 120688, 120712, 120714, 120744, 120746, 120770, 120772, 120779, 123136, 123180, 123191, 123197, 123214, 123214, 123584, 123627, 124928, 125124, 125184, 125251, 125259, 125259, 126464, 126467, 126469, 126495, 126497, 126498, 126500, 126500, 126503, 126503, 126505, 126514, 126516, 126519, 126521, 126521, 126523, 126523, 126530, 126530, 126535, 126535, 126537, 126537, 126539, 126539, 126541, 126543, 126545, 126546, 126548, 126548, 126551, 126551, 126553, 126553, 126555, 126555, 126557, 126557, 126559, 126559, 126561, 126562, 126564, 126564, 126567, 126570, 126572, 126578, 126580, 126583, 126585, 126588, 126590, 126590, 126592, 126601, 126603, 126619, 126625, 126627, 126629, 126633, 126635, 126651, 131072, 173782, 173824, 177972, 177984, 178205, 178208, 183969, 183984, 191456, 194560, 195101]; var unicodeESNextIdentifierPart = [48, 57, 65, 90, 95, 95, 97, 122, 170, 170, 181, 181, 183, 183, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 895, 895, 902, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1327, 1329, 1366, 1369, 1369, 1376, 1416, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1519, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2045, 2045, 2048, 2093, 2112, 2139, 2144, 2154, 2208, 2228, 2230, 2237, 2259, 2273, 2275, 2403, 2406, 2415, 2417, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2556, 2556, 2558, 2558, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2809, 2815, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3072, 3084, 3086, 3088, 3090, 3112, 3114, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3162, 3168, 3171, 3174, 3183, 3200, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3328, 3331, 3333, 3340, 3342, 3344, 3346, 3396, 3398, 3400, 3402, 3406, 3412, 3415, 3423, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3558, 3567, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3718, 3722, 3724, 3747, 3749, 3749, 3751, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4969, 4977, 4992, 5007, 5024, 5109, 5112, 5117, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5880, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6264, 6272, 6314, 6320, 6389, 6400, 6430, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6618, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6832, 6845, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7296, 7304, 7312, 7354, 7357, 7359, 7376, 7378, 7380, 7418, 7424, 7673, 7675, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8472, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12447, 12449, 12538, 12540, 12543, 12549, 12591, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40943, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42737, 42775, 42783, 42786, 42888, 42891, 42943, 42946, 42950, 42999, 43047, 43072, 43123, 43136, 43205, 43216, 43225, 43232, 43255, 43259, 43259, 43261, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43488, 43518, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43824, 43866, 43868, 43879, 43888, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65071, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 65536, 65547, 65549, 65574, 65576, 65594, 65596, 65597, 65599, 65613, 65616, 65629, 65664, 65786, 65856, 65908, 66045, 66045, 66176, 66204, 66208, 66256, 66272, 66272, 66304, 66335, 66349, 66378, 66384, 66426, 66432, 66461, 66464, 66499, 66504, 66511, 66513, 66517, 66560, 66717, 66720, 66729, 66736, 66771, 66776, 66811, 66816, 66855, 66864, 66915, 67072, 67382, 67392, 67413, 67424, 67431, 67584, 67589, 67592, 67592, 67594, 67637, 67639, 67640, 67644, 67644, 67647, 67669, 67680, 67702, 67712, 67742, 67808, 67826, 67828, 67829, 67840, 67861, 67872, 67897, 67968, 68023, 68030, 68031, 68096, 68099, 68101, 68102, 68108, 68115, 68117, 68119, 68121, 68149, 68152, 68154, 68159, 68159, 68192, 68220, 68224, 68252, 68288, 68295, 68297, 68326, 68352, 68405, 68416, 68437, 68448, 68466, 68480, 68497, 68608, 68680, 68736, 68786, 68800, 68850, 68864, 68903, 68912, 68921, 69376, 69404, 69415, 69415, 69424, 69456, 69600, 69622, 69632, 69702, 69734, 69743, 69759, 69818, 69840, 69864, 69872, 69881, 69888, 69940, 69942, 69951, 69956, 69958, 69968, 70003, 70006, 70006, 70016, 70084, 70089, 70092, 70096, 70106, 70108, 70108, 70144, 70161, 70163, 70199, 70206, 70206, 70272, 70278, 70280, 70280, 70282, 70285, 70287, 70301, 70303, 70312, 70320, 70378, 70384, 70393, 70400, 70403, 70405, 70412, 70415, 70416, 70419, 70440, 70442, 70448, 70450, 70451, 70453, 70457, 70459, 70468, 70471, 70472, 70475, 70477, 70480, 70480, 70487, 70487, 70493, 70499, 70502, 70508, 70512, 70516, 70656, 70730, 70736, 70745, 70750, 70751, 70784, 70853, 70855, 70855, 70864, 70873, 71040, 71093, 71096, 71104, 71128, 71133, 71168, 71232, 71236, 71236, 71248, 71257, 71296, 71352, 71360, 71369, 71424, 71450, 71453, 71467, 71472, 71481, 71680, 71738, 71840, 71913, 71935, 71935, 72096, 72103, 72106, 72151, 72154, 72161, 72163, 72164, 72192, 72254, 72263, 72263, 72272, 72345, 72349, 72349, 72384, 72440, 72704, 72712, 72714, 72758, 72760, 72768, 72784, 72793, 72818, 72847, 72850, 72871, 72873, 72886, 72960, 72966, 72968, 72969, 72971, 73014, 73018, 73018, 73020, 73021, 73023, 73031, 73040, 73049, 73056, 73061, 73063, 73064, 73066, 73102, 73104, 73105, 73107, 73112, 73120, 73129, 73440, 73462, 73728, 74649, 74752, 74862, 74880, 75075, 77824, 78894, 82944, 83526, 92160, 92728, 92736, 92766, 92768, 92777, 92880, 92909, 92912, 92916, 92928, 92982, 92992, 92995, 93008, 93017, 93027, 93047, 93053, 93071, 93760, 93823, 93952, 94026, 94031, 94087, 94095, 94111, 94176, 94177, 94179, 94179, 94208, 100343, 100352, 101106, 110592, 110878, 110928, 110930, 110948, 110951, 110960, 111355, 113664, 113770, 113776, 113788, 113792, 113800, 113808, 113817, 113821, 113822, 119141, 119145, 119149, 119154, 119163, 119170, 119173, 119179, 119210, 119213, 119362, 119364, 119808, 119892, 119894, 119964, 119966, 119967, 119970, 119970, 119973, 119974, 119977, 119980, 119982, 119993, 119995, 119995, 119997, 120003, 120005, 120069, 120071, 120074, 120077, 120084, 120086, 120092, 120094, 120121, 120123, 120126, 120128, 120132, 120134, 120134, 120138, 120144, 120146, 120485, 120488, 120512, 120514, 120538, 120540, 120570, 120572, 120596, 120598, 120628, 120630, 120654, 120656, 120686, 120688, 120712, 120714, 120744, 120746, 120770, 120772, 120779, 120782, 120831, 121344, 121398, 121403, 121452, 121461, 121461, 121476, 121476, 121499, 121503, 121505, 121519, 122880, 122886, 122888, 122904, 122907, 122913, 122915, 122916, 122918, 122922, 123136, 123180, 123184, 123197, 123200, 123209, 123214, 123214, 123584, 123641, 124928, 125124, 125136, 125142, 125184, 125259, 125264, 125273, 126464, 126467, 126469, 126495, 126497, 126498, 126500, 126500, 126503, 126503, 126505, 126514, 126516, 126519, 126521, 126521, 126523, 126523, 126530, 126530, 126535, 126535, 126537, 126537, 126539, 126539, 126541, 126543, 126545, 126546, 126548, 126548, 126551, 126551, 126553, 126553, 126555, 126555, 126557, 126557, 126559, 126559, 126561, 126562, 126564, 126564, 126567, 126570, 126572, 126578, 126580, 126583, 126585, 126588, 126590, 126590, 126592, 126601, 126603, 126619, 126625, 126627, 126629, 126633, 126635, 126651, 131072, 173782, 173824, 177972, 177984, 178205, 178208, 183969, 183984, 191456, 194560, 195101, 917760, 917999]; /** - * Test for whether a single line comment's text contains a directive. + * Test for whether a single line comment with leading whitespace trimmed's text contains a directive. */ - var commentDirectiveRegExSingleLine = /^\s*\/\/\/?\s*@(ts-expect-error|ts-ignore)/; + var commentDirectiveRegExSingleLine = /^\/\/\/?\s*@(ts-expect-error|ts-ignore)/; /** - * Test for whether a multi-line comment's last line contains a directive. + * Test for whether a multi-line comment with leading whitespace trimmed's last line contains a directive. */ - var commentDirectiveRegExMultiLine = /^\s*(?:\/|\*)*\s*@(ts-expect-error|ts-ignore)/; + var commentDirectiveRegExMultiLine = /^(?:\/|\*)*\s*@(ts-expect-error|ts-ignore)/; function lookupInUnicodeMap(code, map) { // Bail out quickly if it couldn't possibly be in the map. if (code < map[0]) { @@ -9545,11 +9831,11 @@ var ts; } ts.couldStartTrivia = couldStartTrivia; /* @internal */ - function skipTrivia(text, pos, stopAfterLineBreak, stopAtComments) { - if (stopAtComments === void 0) { stopAtComments = false; } + function skipTrivia(text, pos, stopAfterLineBreak, stopAtComments, inJSDoc) { if (ts.positionIsSynthesized(pos)) { return pos; } + var canConsumeStar = false; // Keep in sync with couldStartTrivia while (true) { var ch = text.charCodeAt(pos); @@ -9564,6 +9850,7 @@ var ts; if (stopAfterLineBreak) { return pos; } + canConsumeStar = !!inJSDoc; continue; case 9 /* tab */: case 11 /* verticalTab */: @@ -9583,6 +9870,7 @@ var ts; } pos++; } + canConsumeStar = false; continue; } if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { @@ -9594,6 +9882,7 @@ var ts; } pos++; } + canConsumeStar = false; continue; } break; @@ -9603,12 +9892,21 @@ var ts; case 62 /* greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos); + canConsumeStar = false; continue; } break; case 35 /* hash */: if (pos === 0 && isShebangTrivia(text, pos)) { pos = scanShebangTrivia(text, pos); + canConsumeStar = false; + continue; + } + break; + case 42 /* asterisk */: + if (canConsumeStar) { + pos++; + canConsumeStar = false; continue; } break; @@ -9896,8 +10194,8 @@ var ts; 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 === 78 /* Identifier */ || token > 115 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 80 /* FirstReservedWord */ && token <= 115 /* LastReservedWord */; }, + 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; }, getCommentDirectives: function () { return commentDirectives; }, getNumericLiteralFlags: function () { return tokenFlags & 1008 /* NumericLiteralFlags */; }, @@ -9912,7 +10210,9 @@ var ts; reScanJsxAttributeValue: reScanJsxAttributeValue, reScanJsxToken: reScanJsxToken, reScanLessThanToken: reScanLessThanToken, + reScanHashToken: reScanHashToken, reScanQuestionToken: reScanQuestionToken, + reScanInvalidIdentifier: reScanInvalidIdentifier, scanJsxToken: scanJsxToken, scanJsDocToken: scanJsDocToken, scan: scan, @@ -10421,7 +10721,7 @@ var ts; } } } - return token = 78 /* Identifier */; + return token = 79 /* Identifier */; } function scanBinaryOrOctalDigits(base) { var value = ""; @@ -10570,19 +10870,19 @@ var ts; return token = scanTemplateAndSetTokenValue(/* isTaggedTemplate */ false); case 37 /* percent */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 68 /* PercentEqualsToken */; + return pos += 2, token = 69 /* 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 = 75 /* AmpersandAmpersandEqualsToken */; + return pos += 3, token = 76 /* AmpersandAmpersandEqualsToken */; } return pos += 2, token = 55 /* AmpersandAmpersandToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 72 /* AmpersandEqualsToken */; + return pos += 2, token = 73 /* AmpersandEqualsToken */; } pos++; return token = 50 /* AmpersandToken */; @@ -10594,11 +10894,11 @@ var ts; return token = 21 /* CloseParenToken */; case 42 /* asterisk */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 65 /* AsteriskEqualsToken */; + return pos += 2, token = 66 /* AsteriskEqualsToken */; } if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 66 /* AsteriskAsteriskEqualsToken */; + return pos += 3, token = 67 /* AsteriskAsteriskEqualsToken */; } return pos += 2, token = 42 /* AsteriskAsteriskToken */; } @@ -10614,7 +10914,7 @@ var ts; return pos += 2, token = 45 /* PlusPlusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 63 /* PlusEqualsToken */; + return pos += 2, token = 64 /* PlusEqualsToken */; } pos++; return token = 39 /* PlusToken */; @@ -10626,7 +10926,7 @@ var ts; return pos += 2, token = 46 /* MinusMinusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 64 /* MinusEqualsToken */; + return pos += 2, token = 65 /* MinusEqualsToken */; } pos++; return token = 40 /* MinusToken */; @@ -10694,7 +10994,7 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 67 /* SlashEqualsToken */; + return pos += 2, token = 68 /* SlashEqualsToken */; } pos++; return token = 43 /* SlashToken */; @@ -10771,7 +11071,7 @@ var ts; } if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 69 /* LessThanLessThanEqualsToken */; + return pos += 3, token = 70 /* LessThanLessThanEqualsToken */; } return pos += 2, token = 47 /* LessThanLessThanToken */; } @@ -10805,7 +11105,7 @@ var ts; return pos += 2, token = 38 /* EqualsGreaterThanToken */; } pos++; - return token = 62 /* EqualsToken */; + return token = 63 /* EqualsToken */; case 62 /* greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -10824,7 +11124,7 @@ var ts; } if (text.charCodeAt(pos + 1) === 63 /* question */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 76 /* QuestionQuestionEqualsToken */; + return pos += 3, token = 77 /* QuestionQuestionEqualsToken */; } return pos += 2, token = 60 /* QuestionQuestionToken */; } @@ -10838,7 +11138,7 @@ var ts; return token = 23 /* CloseBracketToken */; case 94 /* caret */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 77 /* CaretEqualsToken */; + return pos += 2, token = 78 /* CaretEqualsToken */; } pos++; return token = 52 /* CaretToken */; @@ -10857,12 +11157,12 @@ var ts; } if (text.charCodeAt(pos + 1) === 124 /* bar */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 74 /* BarBarEqualsToken */; + return pos += 3, token = 75 /* BarBarEqualsToken */; } return pos += 2, token = 56 /* BarBarToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 73 /* BarEqualsToken */; + return pos += 2, token = 74 /* BarEqualsToken */; } pos++; return token = 51 /* BarToken */; @@ -10900,30 +11200,12 @@ var ts; return token = 0 /* Unknown */; } pos++; - if (isIdentifierStart(ch = text.charCodeAt(pos), languageVersion)) { - pos++; - while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion)) - pos++; - tokenValue = text.substring(tokenPos, pos); - if (ch === 92 /* backslash */) { - tokenValue += scanIdentifierParts(); - } - } - else { - tokenValue = "#"; - error(ts.Diagnostics.Invalid_character); - } - return token = 79 /* PrivateIdentifier */; + scanIdentifier(codePointAt(text, pos), languageVersion); + return token = 80 /* PrivateIdentifier */; default: - if (isIdentifierStart(ch, languageVersion)) { - pos += charSize(ch); - while (pos < end && isIdentifierPart(ch = codePointAt(text, pos), languageVersion)) - pos += charSize(ch); - tokenValue = text.substring(tokenPos, pos); - if (ch === 92 /* backslash */) { - tokenValue += scanIdentifierParts(); - } - return token = getIdentifierToken(); + var identifierKind = scanIdentifier(ch, languageVersion); + if (identifierKind) { + return token = identifierKind; } else if (isWhiteSpaceSingleLine(ch)) { pos += charSize(ch); @@ -10940,17 +11222,42 @@ var ts; } } } + function reScanInvalidIdentifier() { + ts.Debug.assert(token === 0 /* 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 */); + if (identifierKind) { + return token = identifierKind; + } + pos += charSize(ch); + return token; // Still `SyntaKind.Unknown` + } + function scanIdentifier(startCharacter, languageVersion) { + var ch = startCharacter; + if (isIdentifierStart(ch, languageVersion)) { + pos += charSize(ch); + while (pos < end && isIdentifierPart(ch = codePointAt(text, pos), languageVersion)) + pos += charSize(ch); + tokenValue = text.substring(tokenPos, pos); + if (ch === 92 /* 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 = 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + return pos += 3, token = 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */; } return pos += 2, token = 49 /* GreaterThanGreaterThanGreaterThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 70 /* GreaterThanGreaterThanEqualsToken */; + return pos += 2, token = 71 /* GreaterThanGreaterThanEqualsToken */; } pos++; return token = 48 /* GreaterThanGreaterThanToken */; @@ -10963,12 +11270,12 @@ var ts; return token; } function reScanAsteriskEqualsToken() { - ts.Debug.assert(token === 65 /* AsteriskEqualsToken */, "'reScanAsteriskEqualsToken' should only be called on a '*='"); + ts.Debug.assert(token === 66 /* AsteriskEqualsToken */, "'reScanAsteriskEqualsToken' should only be called on a '*='"); pos = tokenPos + 1; - return token = 62 /* EqualsToken */; + return token = 63 /* EqualsToken */; } function reScanSlashToken() { - if (token === 43 /* SlashToken */ || token === 67 /* SlashEqualsToken */) { + if (token === 43 /* SlashToken */ || token === 68 /* SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -11018,7 +11325,7 @@ var ts; return token; } function appendIfCommentDirective(commentDirectives, text, commentDirectiveRegEx, lineStart) { - var type = getDirectiveFromComment(text, commentDirectiveRegEx); + var type = getDirectiveFromComment(ts.trimStringStart(text), commentDirectiveRegEx); if (type === undefined) { return commentDirectives; } @@ -11052,9 +11359,10 @@ var ts; pos = tokenPos; return token = scanTemplateAndSetTokenValue(/* isTaggedTemplate */ true); } - function reScanJsxToken() { + function reScanJsxToken(allowMultilineJsxText) { + if (allowMultilineJsxText === void 0) { allowMultilineJsxText = true; } pos = tokenPos = startPos; - return token = scanJsxToken(); + return token = scanJsxToken(allowMultilineJsxText); } function reScanLessThanToken() { if (token === 47 /* LessThanLessThanToken */) { @@ -11063,12 +11371,20 @@ var ts; } return token; } + function reScanHashToken() { + if (token === 80 /* PrivateIdentifier */) { + pos = tokenPos + 1; + return token = 62 /* HashToken */; + } + return token; + } function reScanQuestionToken() { ts.Debug.assert(token === 60 /* QuestionQuestionToken */, "'reScanQuestionToken' should only be called on a '??'"); pos = tokenPos + 1; return token = 57 /* QuestionToken */; } - function scanJsxToken() { + function scanJsxToken(allowMultilineJsxText) { + if (allowMultilineJsxText === void 0) { allowMultilineJsxText = true; } startPos = tokenPos = pos; if (pos >= end) { return token = 1 /* EndOfFileToken */; @@ -11088,15 +11404,9 @@ var ts; } // First non-whitespace character on this line. var firstNonWhitespace = 0; - var lastNonWhitespace = -1; // These initial values are special because the first line is: // firstNonWhitespace = 0 to indicate that we want leading whitespace, while (pos < end) { - // We want to keep track of the last non-whitespace (but including - // newlines character for hitting the end of the JSX Text region) - if (!isWhiteSpaceSingleLine(char)) { - lastNonWhitespace = pos; - } char = text.charCodeAt(pos); if (char === 123 /* openBrace */) { break; @@ -11114,8 +11424,6 @@ var ts; if (char === 125 /* closeBrace */) { error(ts.Diagnostics.Unexpected_token_Did_you_mean_or_rbrace, pos, 1); } - if (lastNonWhitespace > 0) - lastNonWhitespace++; // FirstNonWhitespace is 0, then we only see whitespaces so far. If we see a linebreak, we want to ignore that whitespaces. // i.e (- : whitespace) //
---- @@ -11125,13 +11433,17 @@ var ts; if (isLineBreak(char) && firstNonWhitespace === 0) { firstNonWhitespace = -1; } + else if (!allowMultilineJsxText && isLineBreak(char) && firstNonWhitespace > 0) { + // Stop JsxText on each line during formatting. This allows the formatter to + // indent each line correctly. + break; + } else if (!isWhiteSpaceLike(char)) { firstNonWhitespace = pos; } pos++; } - var endPosition = lastNonWhitespace === -1 ? pos : lastNonWhitespace; - tokenValue = text.substring(startPos, endPosition); + tokenValue = text.substring(startPos, pos); return firstNonWhitespace === -1 ? 12 /* JsxTextAllWhiteSpaces */ : 11 /* JsxText */; } // Scans a JSX identifier; these differ from normal identifiers in that @@ -11154,6 +11466,7 @@ var ts; tokenValue += ":"; pos++; namespaceSeparator = true; + token = 79 /* Identifier */; // swap from keyword kind to identifier kind continue; } var oldPos = pos; @@ -11228,13 +11541,15 @@ var ts; case 62 /* greaterThan */: return token = 31 /* GreaterThanToken */; case 61 /* equals */: - return token = 62 /* EqualsToken */; + 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 */: pos--; var extendedCookedChar = peekExtendedUnicodeEscape(); @@ -11410,6 +11725,8 @@ var ts; switch (options.target) { case 99 /* ESNext */: return "lib.esnext.full.d.ts"; + case 8 /* ES2021 */: + return "lib.es2021.full.d.ts"; case 7 /* ES2020 */: return "lib.es2020.full.d.ts"; case 6 /* ES2019 */: @@ -11628,9 +11945,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 159 /* TypeParameter */) { + if (d && d.kind === 161 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (isFunctionLike(current) || isClassLike(current) || current.kind === 253 /* InterfaceDeclaration */) { + if (isFunctionLike(current) || isClassLike(current) || current.kind === 255 /* InterfaceDeclaration */) { return current; } } @@ -11638,7 +11955,7 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node, parent) { - return ts.hasSyntacticModifier(node, 92 /* ParameterPropertyModifier */) && parent.kind === 166 /* Constructor */; + return ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */) && parent.kind === 168 /* Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -11668,14 +11985,14 @@ var ts; node = walkUpBindingElementsAndPatterns(node); } var flags = getFlags(node); - if (node.kind === 249 /* VariableDeclaration */) { + if (node.kind === 251 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 250 /* VariableDeclarationList */) { + if (node && node.kind === 252 /* VariableDeclarationList */) { flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 232 /* VariableStatement */) { + if (node && node.kind === 234 /* VariableStatement */) { flags |= getFlags(node); } return flags; @@ -11693,19 +12010,22 @@ var ts; // nodes like variable declarations and binding elements can returned a view of their flags // that includes the modifiers from their container. i.e. flags like export/declare aren't // stored on the variable declaration directly, but on the containing variable statement - // (if it has one). Similarly, flags for let/const are store on the variable declaration + // (if it has one). Similarly, flags for let/const are stored on the variable declaration // list. By calling this function, all those flags are combined so that the client can treat // the node as if it actually had those flags. function getCombinedNodeFlags(node) { return getCombinedFlags(node, function (n) { return n.flags; }); } ts.getCombinedNodeFlags = getCombinedNodeFlags; + /* @internal */ + ts.supportedLocaleDirectories = ["cs", "de", "es", "fr", "it", "ja", "ko", "pl", "pt-br", "ru", "tr", "zh-cn", "zh-tw"]; /** * Checks to see if the locale is in the appropriate format, * and if it is, attempts to set the appropriate language. */ function validateLocaleAndSetLanguage(locale, sys, errors) { - var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase()); + var lowerCaseLocale = locale.toLowerCase(); + var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(lowerCaseLocale); if (!matchResult) { if (errors) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1, "en", "ja-jp")); @@ -11716,7 +12036,7 @@ var ts; var territory = matchResult[3]; // First try the entire locale, then fall back to just language if that's all we have. // Either ways do not fail, and fallback to the English diagnostic strings. - if (!trySetLanguageAndTerritory(language, territory, errors)) { + if (ts.contains(ts.supportedLocaleDirectories, lowerCaseLocale) && !trySetLanguageAndTerritory(language, territory, errors)) { trySetLanguageAndTerritory(language, /*territory*/ undefined, errors); } // Set the UI locale for string collation @@ -11823,7 +12143,7 @@ var ts; } ts.idText = idText; function symbolName(symbol) { - if (symbol.valueDeclaration && isPrivateIdentifierPropertyDeclaration(symbol.valueDeclaration)) { + if (symbol.valueDeclaration && isPrivateIdentifierClassElementDeclaration(symbol.valueDeclaration)) { return idText(symbol.valueDeclaration.name); } return unescapeLeadingUnderscores(symbol.escapedName); @@ -11845,30 +12165,30 @@ var ts; } // Covers remaining cases (returning undefined if none match). switch (hostNode.kind) { - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } break; - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: var expr = hostNode.expression; - if (expr.kind === 216 /* BinaryExpression */ && expr.operatorToken.kind === 62 /* EqualsToken */) { + if (expr.kind === 218 /* BinaryExpression */ && expr.operatorToken.kind === 63 /* EqualsToken */) { expr = expr.left; } switch (expr.kind) { - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return expr.name; - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; } } break; - case 207 /* ParenthesizedExpression */: { + case 209 /* ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 245 /* LabeledStatement */: { + case 247 /* LabeledStatement */: { if (isDeclaration(hostNode.statement) || isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -11903,18 +12223,18 @@ var ts; /** @internal */ function getNonAssignedNameOfDeclaration(declaration) { switch (declaration.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return declaration; - case 333 /* JSDocPropertyTag */: - case 326 /* JSDocParameterTag */: { + case 341 /* JSDocPropertyTag */: + case 334 /* JSDocParameterTag */: { var name = declaration.name; - if (name.kind === 157 /* QualifiedName */) { + if (name.kind === 159 /* QualifiedName */) { return name.right; } break; } - case 203 /* CallExpression */: - case 216 /* BinaryExpression */: { + case 205 /* CallExpression */: + case 218 /* BinaryExpression */: { var expr_1 = declaration; switch (ts.getAssignmentDeclarationKind(expr_1)) { case 1 /* ExportsProperty */: @@ -11930,15 +12250,15 @@ var ts; return undefined; } } - case 331 /* JSDocTypedefTag */: + case 339 /* JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 325 /* JSDocEnumTag */: + case 333 /* JSDocEnumTag */: return nameForNamelessJSDocTypedef(declaration); - case 266 /* ExportAssignment */: { + case 268 /* ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: var expr = declaration; if (ts.isBindableStaticElementAccessExpression(expr)) { return expr.argumentExpression; @@ -11951,7 +12271,7 @@ var ts; if (declaration === undefined) return undefined; return getNonAssignedNameOfDeclaration(declaration) || - (ts.isFunctionExpression(declaration) || ts.isClassExpression(declaration) ? getAssignedName(declaration) : undefined); + (ts.isFunctionExpression(declaration) || ts.isArrowFunction(declaration) || ts.isClassExpression(declaration) ? getAssignedName(declaration) : undefined); } ts.getNameOfDeclaration = getNameOfDeclaration; /*@internal*/ @@ -12104,6 +12424,10 @@ var ts; return getFirstJSDocTag(node, ts.isJSDocReadonlyTag, /*noCache*/ true); } ts.getJSDocReadonlyTagNoCache = getJSDocReadonlyTagNoCache; + function getJSDocOverrideTagNoCache(node) { + return getFirstJSDocTag(node, ts.isJSDocOverrideTag, /*noCache*/ true); + } + ts.getJSDocOverrideTagNoCache = getJSDocOverrideTagNoCache; /** Gets the JSDoc deprecated tag for the node if present */ function getJSDocDeprecatedTag(node) { return getFirstJSDocTag(node, ts.isJSDocDeprecatedTag); @@ -12224,6 +12548,15 @@ var ts; return getJSDocTags(node).filter(function (doc) { return doc.kind === kind; }); } ts.getAllJSDocTagsOfKind = getAllJSDocTagsOfKind; + /** 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) { + // TODO: Other kinds here + return c.kind === 315 /* JSDocText */ ? c.text : "{@link " + (c.name ? ts.entityNameToString(c.name) + " " : "") + c.text + "}"; + }).join(""); + } + ts.getTextOfJSDocComment = getTextOfJSDocComment; /** * Gets the effective type parameters. If the node was parsed in a * JavaScript file, gets the type parameters from the `@template` tag from JSDoc. @@ -12233,7 +12566,7 @@ var ts; return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 311 /* JSDocComment */); + ts.Debug.assert(node.parent.kind === 314 /* JSDocComment */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -12259,13 +12592,13 @@ var ts; } ts.getEffectiveConstraintOfTypeParameter = getEffectiveConstraintOfTypeParameter; // #region - function isIdentifierOrPrivateIdentifier(node) { - return node.kind === 78 /* Identifier */ || node.kind === 79 /* PrivateIdentifier */; + function isMemberName(node) { + return node.kind === 79 /* Identifier */ || node.kind === 80 /* PrivateIdentifier */; } - ts.isIdentifierOrPrivateIdentifier = isIdentifierOrPrivateIdentifier; + ts.isMemberName = isMemberName; /* @internal */ function isGetOrSetAccessorDeclaration(node) { - return node.kind === 168 /* SetAccessor */ || node.kind === 167 /* GetAccessor */; + return node.kind === 170 /* SetAccessor */ || node.kind === 169 /* GetAccessor */; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; function isPropertyAccessChain(node) { @@ -12283,10 +12616,10 @@ var ts; function isOptionalChain(node) { var kind = node.kind; return !!(node.flags & 32 /* OptionalChain */) && - (kind === 201 /* PropertyAccessExpression */ - || kind === 202 /* ElementAccessExpression */ - || kind === 203 /* CallExpression */ - || kind === 225 /* NonNullExpression */); + (kind === 203 /* PropertyAccessExpression */ + || kind === 204 /* ElementAccessExpression */ + || kind === 205 /* CallExpression */ + || kind === 227 /* NonNullExpression */); } ts.isOptionalChain = isOptionalChain; /* @internal */ @@ -12321,7 +12654,7 @@ var ts; } ts.isOutermostOptionalChain = isOutermostOptionalChain; function isNullishCoalesce(node) { - return node.kind === 216 /* BinaryExpression */ && node.operatorToken.kind === 60 /* QuestionQuestionToken */; + return node.kind === 218 /* BinaryExpression */ && node.operatorToken.kind === 60 /* QuestionQuestionToken */; } ts.isNullishCoalesce = isNullishCoalesce; function isConstTypeReference(node) { @@ -12338,17 +12671,17 @@ var ts; } ts.isNonNullChain = isNonNullChain; function isBreakOrContinueStatement(node) { - return node.kind === 241 /* BreakStatement */ || node.kind === 240 /* ContinueStatement */; + return node.kind === 243 /* BreakStatement */ || node.kind === 242 /* ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isNamedExportBindings(node) { - return node.kind === 269 /* NamespaceExport */ || node.kind === 268 /* NamedExports */; + return node.kind === 271 /* NamespaceExport */ || node.kind === 270 /* NamedExports */; } ts.isNamedExportBindings = isNamedExportBindings; function isUnparsedTextLike(node) { switch (node.kind) { - case 294 /* UnparsedText */: - case 295 /* UnparsedInternalText */: + case 296 /* UnparsedText */: + case 297 /* UnparsedInternalText */: return true; default: return false; @@ -12357,12 +12690,12 @@ var ts; ts.isUnparsedTextLike = isUnparsedTextLike; function isUnparsedNode(node) { return isUnparsedTextLike(node) || - node.kind === 292 /* UnparsedPrologue */ || - node.kind === 296 /* UnparsedSyntheticReference */; + node.kind === 294 /* UnparsedPrologue */ || + node.kind === 298 /* UnparsedSyntheticReference */; } ts.isUnparsedNode = isUnparsedNode; function isJSDocPropertyLikeTag(node) { - return node.kind === 333 /* JSDocPropertyTag */ || node.kind === 326 /* JSDocParameterTag */; + return node.kind === 341 /* JSDocPropertyTag */ || node.kind === 334 /* JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; // #endregion @@ -12378,16 +12711,25 @@ var ts; ts.isNode = isNode; /* @internal */ function isNodeKind(kind) { - return kind >= 157 /* FirstNode */; + return kind >= 159 /* FirstNode */; } ts.isNodeKind = isNodeKind; + /** + * True if kind is of some token syntax kind. + * For example, this is true for an IfKeyword but not for an IfStatement. + * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. + */ + function isTokenKind(kind) { + return kind >= 0 /* FirstToken */ && kind <= 158 /* LastToken */; + } + ts.isTokenKind = isTokenKind; /** * True if node is of some token syntax kind. * For example, this is true for an IfKeyword but not for an IfStatement. * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. */ function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 156 /* LastToken */; + return isTokenKind(n.kind); } ts.isToken = isToken; // Node Arrays @@ -12428,13 +12770,13 @@ var ts; ts.isImportOrExportSpecifier = isImportOrExportSpecifier; function isTypeOnlyImportOrExportDeclaration(node) { switch (node.kind) { - case 265 /* ImportSpecifier */: - case 270 /* ExportSpecifier */: + case 267 /* ImportSpecifier */: + case 272 /* ExportSpecifier */: return node.parent.parent.isTypeOnly; - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: return node.parent.isTypeOnly; - case 262 /* ImportClause */: - case 260 /* ImportEqualsDeclaration */: + case 264 /* ImportClause */: + case 262 /* ImportEqualsDeclaration */: return node.isTypeOnly; default: return false; @@ -12453,10 +12795,10 @@ var ts; ts.isGeneratedIdentifier = isGeneratedIdentifier; // Private Identifiers /*@internal*/ - function isPrivateIdentifierPropertyDeclaration(node) { - return ts.isPropertyDeclaration(node) && ts.isPrivateIdentifier(node.name); + function isPrivateIdentifierClassElementDeclaration(node) { + return (ts.isPropertyDeclaration(node) || isMethodOrAccessor(node)) && ts.isPrivateIdentifier(node.name); } - ts.isPrivateIdentifierPropertyDeclaration = isPrivateIdentifierPropertyDeclaration; + ts.isPrivateIdentifierClassElementDeclaration = isPrivateIdentifierClassElementDeclaration; /*@internal*/ function isPrivateIdentifierPropertyAccessExpression(node) { return ts.isPropertyAccessExpression(node) && ts.isPrivateIdentifier(node.name); @@ -12466,17 +12808,18 @@ var ts; /* @internal */ function isModifierKind(token) { switch (token) { - case 125 /* AbstractKeyword */: - case 129 /* AsyncKeyword */: - case 84 /* ConstKeyword */: - case 133 /* DeclareKeyword */: - case 87 /* DefaultKeyword */: - case 92 /* ExportKeyword */: - case 122 /* PublicKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 142 /* ReadonlyKeyword */: - case 123 /* StaticKeyword */: + case 126 /* AbstractKeyword */: + case 130 /* AsyncKeyword */: + case 85 /* ConstKeyword */: + case 134 /* DeclareKeyword */: + case 88 /* DefaultKeyword */: + case 93 /* ExportKeyword */: + case 123 /* PublicKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + case 143 /* ReadonlyKeyword */: + case 124 /* StaticKeyword */: + case 157 /* OverrideKeyword */: return true; } return false; @@ -12484,12 +12827,12 @@ var ts; ts.isModifierKind = isModifierKind; /* @internal */ function isParameterPropertyModifier(kind) { - return !!(ts.modifierToFlag(kind) & 92 /* ParameterPropertyModifier */); + return !!(ts.modifierToFlag(kind) & 16476 /* ParameterPropertyModifier */); } ts.isParameterPropertyModifier = isParameterPropertyModifier; /* @internal */ function isClassMemberModifier(idToken) { - return isParameterPropertyModifier(idToken) || idToken === 123 /* StaticKeyword */; + return isParameterPropertyModifier(idToken) || idToken === 124 /* StaticKeyword */ || idToken === 157 /* OverrideKeyword */; } ts.isClassMemberModifier = isClassMemberModifier; function isModifier(node) { @@ -12498,29 +12841,29 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 157 /* QualifiedName */ - || kind === 78 /* Identifier */; + return kind === 159 /* QualifiedName */ + || kind === 79 /* Identifier */; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 78 /* Identifier */ - || kind === 79 /* PrivateIdentifier */ + return kind === 79 /* Identifier */ + || kind === 80 /* PrivateIdentifier */ || kind === 10 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 158 /* ComputedPropertyName */; + || kind === 160 /* ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; - return kind === 78 /* Identifier */ - || kind === 196 /* ObjectBindingPattern */ - || kind === 197 /* ArrayBindingPattern */; + return kind === 79 /* Identifier */ + || kind === 198 /* ObjectBindingPattern */ + || kind === 199 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions function isFunctionLike(node) { - return node && isFunctionLikeKind(node.kind); + return !!node && isFunctionLikeKind(node.kind); } ts.isFunctionLike = isFunctionLike; /* @internal */ @@ -12530,13 +12873,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 251 /* FunctionDeclaration */: - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 253 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return true; default: return false; @@ -12545,14 +12888,14 @@ var ts; /* @internal */ function isFunctionLikeKind(kind) { switch (kind) { - case 164 /* MethodSignature */: - case 169 /* CallSignature */: - case 313 /* JSDocSignature */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: - case 174 /* FunctionType */: - case 308 /* JSDocFunctionType */: - case 175 /* ConstructorType */: + case 166 /* MethodSignature */: + case 171 /* CallSignature */: + case 317 /* JSDocSignature */: + case 172 /* ConstructSignature */: + case 173 /* IndexSignature */: + case 176 /* FunctionType */: + case 311 /* JSDocFunctionType */: + case 177 /* ConstructorType */: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -12567,29 +12910,29 @@ var ts; // Classes function isClassElement(node) { var kind = node.kind; - return kind === 166 /* Constructor */ - || kind === 163 /* PropertyDeclaration */ - || kind === 165 /* MethodDeclaration */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */ - || kind === 171 /* IndexSignature */ - || kind === 229 /* SemicolonClassElement */; + return kind === 168 /* Constructor */ + || kind === 165 /* PropertyDeclaration */ + || kind === 167 /* MethodDeclaration */ + || kind === 169 /* GetAccessor */ + || kind === 170 /* SetAccessor */ + || kind === 173 /* IndexSignature */ + || kind === 231 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 252 /* ClassDeclaration */ || node.kind === 221 /* ClassExpression */); + return node && (node.kind === 254 /* ClassDeclaration */ || node.kind === 223 /* ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 167 /* GetAccessor */ || node.kind === 168 /* SetAccessor */); + return node && (node.kind === 169 /* GetAccessor */ || node.kind === 170 /* SetAccessor */); } ts.isAccessor = isAccessor; /* @internal */ function isMethodOrAccessor(node) { switch (node.kind) { - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return true; default: return false; @@ -12599,11 +12942,11 @@ var ts; // Type members function isTypeElement(node) { var kind = node.kind; - return kind === 170 /* ConstructSignature */ - || kind === 169 /* CallSignature */ - || kind === 162 /* PropertySignature */ - || kind === 164 /* MethodSignature */ - || kind === 171 /* IndexSignature */; + return kind === 172 /* ConstructSignature */ + || kind === 171 /* CallSignature */ + || kind === 164 /* PropertySignature */ + || kind === 166 /* MethodSignature */ + || kind === 173 /* IndexSignature */; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -12612,12 +12955,12 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 288 /* PropertyAssignment */ - || kind === 289 /* ShorthandPropertyAssignment */ - || kind === 290 /* SpreadAssignment */ - || kind === 165 /* MethodDeclaration */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */; + return kind === 290 /* PropertyAssignment */ + || kind === 291 /* ShorthandPropertyAssignment */ + || kind === 292 /* SpreadAssignment */ + || kind === 167 /* MethodDeclaration */ + || kind === 169 /* GetAccessor */ + || kind === 170 /* SetAccessor */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type @@ -12632,8 +12975,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 174 /* FunctionType */: - case 175 /* ConstructorType */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: return true; } return false; @@ -12644,8 +12987,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 197 /* ArrayBindingPattern */ - || kind === 196 /* ObjectBindingPattern */; + return kind === 199 /* ArrayBindingPattern */ + || kind === 198 /* ObjectBindingPattern */; } return false; } @@ -12653,15 +12996,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 199 /* ArrayLiteralExpression */ - || kind === 200 /* ObjectLiteralExpression */; + return kind === 201 /* ArrayLiteralExpression */ + || kind === 202 /* ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 198 /* BindingElement */ - || kind === 222 /* OmittedExpression */; + return kind === 200 /* BindingElement */ + || kind === 224 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -12670,9 +13013,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 249 /* VariableDeclaration */: - case 160 /* Parameter */: - case 198 /* BindingElement */: + case 251 /* VariableDeclaration */: + case 162 /* Parameter */: + case 200 /* BindingElement */: return true; } return false; @@ -12693,8 +13036,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 196 /* ObjectBindingPattern */: - case 200 /* ObjectLiteralExpression */: + case 198 /* ObjectBindingPattern */: + case 202 /* ObjectLiteralExpression */: return true; } return false; @@ -12706,8 +13049,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 197 /* ArrayBindingPattern */: - case 199 /* ArrayLiteralExpression */: + case 199 /* ArrayBindingPattern */: + case 201 /* ArrayLiteralExpression */: return true; } return false; @@ -12716,26 +13059,26 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 201 /* PropertyAccessExpression */ - || kind === 157 /* QualifiedName */ - || kind === 195 /* ImportType */; + return kind === 203 /* PropertyAccessExpression */ + || kind === 159 /* QualifiedName */ + || kind === 197 /* ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 201 /* PropertyAccessExpression */ - || kind === 157 /* QualifiedName */; + return kind === 203 /* PropertyAccessExpression */ + || kind === 159 /* QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 275 /* JsxOpeningElement */: - case 274 /* JsxSelfClosingElement */: - case 203 /* CallExpression */: - case 204 /* NewExpression */: - case 205 /* TaggedTemplateExpression */: - case 161 /* Decorator */: + case 277 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: + case 207 /* TaggedTemplateExpression */: + case 163 /* Decorator */: return true; default: return false; @@ -12743,12 +13086,12 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 203 /* CallExpression */ || node.kind === 204 /* NewExpression */; + return node.kind === 205 /* CallExpression */ || node.kind === 206 /* NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 218 /* TemplateExpression */ + return kind === 220 /* TemplateExpression */ || kind === 14 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; @@ -12759,34 +13102,34 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: - case 204 /* NewExpression */: - case 203 /* CallExpression */: - case 273 /* JsxElement */: - case 274 /* JsxSelfClosingElement */: - case 277 /* JsxFragment */: - case 205 /* TaggedTemplateExpression */: - case 199 /* ArrayLiteralExpression */: - case 207 /* ParenthesizedExpression */: - case 200 /* ObjectLiteralExpression */: - case 221 /* ClassExpression */: - case 208 /* FunctionExpression */: - case 78 /* Identifier */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: + case 206 /* NewExpression */: + case 205 /* CallExpression */: + case 275 /* JsxElement */: + case 276 /* JsxSelfClosingElement */: + case 279 /* JsxFragment */: + case 207 /* TaggedTemplateExpression */: + case 201 /* ArrayLiteralExpression */: + case 209 /* ParenthesizedExpression */: + case 202 /* ObjectLiteralExpression */: + case 223 /* ClassExpression */: + case 210 /* FunctionExpression */: + case 79 /* Identifier */: case 13 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 218 /* TemplateExpression */: - case 94 /* FalseKeyword */: - case 103 /* NullKeyword */: - case 107 /* ThisKeyword */: - case 109 /* TrueKeyword */: - case 105 /* SuperKeyword */: - case 225 /* NonNullExpression */: - case 226 /* MetaProperty */: - case 99 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression + case 220 /* TemplateExpression */: + case 95 /* FalseKeyword */: + case 104 /* NullKeyword */: + case 108 /* ThisKeyword */: + case 110 /* TrueKeyword */: + case 106 /* SuperKeyword */: + case 227 /* NonNullExpression */: + case 228 /* MetaProperty */: + case 100 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: return false; @@ -12799,13 +13142,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 214 /* PrefixUnaryExpression */: - case 215 /* PostfixUnaryExpression */: - case 210 /* DeleteExpression */: - case 211 /* TypeOfExpression */: - case 212 /* VoidExpression */: - case 213 /* AwaitExpression */: - case 206 /* TypeAssertionExpression */: + case 216 /* PrefixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: + case 212 /* DeleteExpression */: + case 213 /* TypeOfExpression */: + case 214 /* VoidExpression */: + case 215 /* AwaitExpression */: + case 208 /* TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -12814,9 +13157,9 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: return true; - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return expr.operator === 45 /* PlusPlusToken */ || expr.operator === 46 /* MinusMinusToken */; default: @@ -12835,15 +13178,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 217 /* ConditionalExpression */: - case 219 /* YieldExpression */: - case 209 /* ArrowFunction */: - case 216 /* BinaryExpression */: - case 220 /* SpreadElement */: - case 224 /* AsExpression */: - case 222 /* OmittedExpression */: - case 337 /* CommaListExpression */: - case 336 /* PartiallyEmittedExpression */: + case 219 /* ConditionalExpression */: + case 221 /* YieldExpression */: + case 211 /* ArrowFunction */: + case 218 /* BinaryExpression */: + case 222 /* SpreadElement */: + case 226 /* AsExpression */: + case 224 /* OmittedExpression */: + case 345 /* CommaListExpression */: + case 344 /* PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -12851,8 +13194,8 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 206 /* TypeAssertionExpression */ - || kind === 224 /* AsExpression */; + return kind === 208 /* TypeAssertionExpression */ + || kind === 226 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ @@ -12863,13 +13206,13 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: return true; - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -12898,7 +13241,7 @@ var ts; ts.isExternalModuleIndicator = isExternalModuleIndicator; /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 238 /* ForInStatement */ || node.kind === 239 /* ForOfStatement */; + return node.kind === 240 /* ForInStatement */ || node.kind === 241 /* ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -12922,114 +13265,114 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 257 /* ModuleBlock */ - || kind === 256 /* ModuleDeclaration */ - || kind === 78 /* Identifier */; + return kind === 259 /* ModuleBlock */ + || kind === 258 /* ModuleDeclaration */ + || kind === 79 /* Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 257 /* ModuleBlock */ - || kind === 256 /* ModuleDeclaration */; + return kind === 259 /* ModuleBlock */ + || kind === 258 /* ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; - return kind === 78 /* Identifier */ - || kind === 256 /* ModuleDeclaration */; + return kind === 79 /* Identifier */ + || kind === 258 /* ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 264 /* NamedImports */ - || kind === 263 /* NamespaceImport */; + return kind === 266 /* NamedImports */ + || kind === 265 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 256 /* ModuleDeclaration */ || node.kind === 255 /* EnumDeclaration */; + return node.kind === 258 /* ModuleDeclaration */ || node.kind === 257 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 209 /* ArrowFunction */ - || kind === 198 /* BindingElement */ - || kind === 252 /* ClassDeclaration */ - || kind === 221 /* ClassExpression */ - || kind === 166 /* Constructor */ - || kind === 255 /* EnumDeclaration */ - || kind === 291 /* EnumMember */ - || kind === 270 /* ExportSpecifier */ - || kind === 251 /* FunctionDeclaration */ - || kind === 208 /* FunctionExpression */ - || kind === 167 /* GetAccessor */ - || kind === 262 /* ImportClause */ - || kind === 260 /* ImportEqualsDeclaration */ - || kind === 265 /* ImportSpecifier */ - || kind === 253 /* InterfaceDeclaration */ - || kind === 280 /* JsxAttribute */ - || kind === 165 /* MethodDeclaration */ - || kind === 164 /* MethodSignature */ - || kind === 256 /* ModuleDeclaration */ - || kind === 259 /* NamespaceExportDeclaration */ - || kind === 263 /* NamespaceImport */ - || kind === 269 /* NamespaceExport */ - || kind === 160 /* Parameter */ - || kind === 288 /* PropertyAssignment */ - || kind === 163 /* PropertyDeclaration */ - || kind === 162 /* PropertySignature */ - || kind === 168 /* SetAccessor */ - || kind === 289 /* ShorthandPropertyAssignment */ - || kind === 254 /* TypeAliasDeclaration */ - || kind === 159 /* TypeParameter */ - || kind === 249 /* VariableDeclaration */ - || kind === 331 /* JSDocTypedefTag */ - || kind === 324 /* JSDocCallbackTag */ - || kind === 333 /* JSDocPropertyTag */; + return kind === 211 /* ArrowFunction */ + || kind === 200 /* BindingElement */ + || kind === 254 /* ClassDeclaration */ + || kind === 223 /* ClassExpression */ + || kind === 168 /* Constructor */ + || kind === 257 /* EnumDeclaration */ + || kind === 293 /* EnumMember */ + || kind === 272 /* ExportSpecifier */ + || kind === 253 /* FunctionDeclaration */ + || kind === 210 /* FunctionExpression */ + || kind === 169 /* GetAccessor */ + || kind === 264 /* ImportClause */ + || kind === 262 /* ImportEqualsDeclaration */ + || kind === 267 /* ImportSpecifier */ + || kind === 255 /* InterfaceDeclaration */ + || kind === 282 /* JsxAttribute */ + || kind === 167 /* MethodDeclaration */ + || kind === 166 /* MethodSignature */ + || kind === 258 /* ModuleDeclaration */ + || kind === 261 /* NamespaceExportDeclaration */ + || kind === 265 /* NamespaceImport */ + || kind === 271 /* NamespaceExport */ + || kind === 162 /* Parameter */ + || kind === 290 /* PropertyAssignment */ + || kind === 165 /* PropertyDeclaration */ + || kind === 164 /* PropertySignature */ + || kind === 170 /* SetAccessor */ + || kind === 291 /* ShorthandPropertyAssignment */ + || kind === 256 /* TypeAliasDeclaration */ + || kind === 161 /* TypeParameter */ + || kind === 251 /* VariableDeclaration */ + || kind === 339 /* JSDocTypedefTag */ + || kind === 332 /* JSDocCallbackTag */ + || kind === 341 /* JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - return kind === 251 /* FunctionDeclaration */ - || kind === 271 /* MissingDeclaration */ - || kind === 252 /* ClassDeclaration */ - || kind === 253 /* InterfaceDeclaration */ - || kind === 254 /* TypeAliasDeclaration */ - || kind === 255 /* EnumDeclaration */ - || kind === 256 /* ModuleDeclaration */ - || kind === 261 /* ImportDeclaration */ - || kind === 260 /* ImportEqualsDeclaration */ - || kind === 267 /* ExportDeclaration */ - || kind === 266 /* ExportAssignment */ - || kind === 259 /* NamespaceExportDeclaration */; + return kind === 253 /* FunctionDeclaration */ + || kind === 273 /* MissingDeclaration */ + || kind === 254 /* ClassDeclaration */ + || kind === 255 /* InterfaceDeclaration */ + || kind === 256 /* TypeAliasDeclaration */ + || kind === 257 /* EnumDeclaration */ + || kind === 258 /* ModuleDeclaration */ + || kind === 263 /* ImportDeclaration */ + || kind === 262 /* ImportEqualsDeclaration */ + || kind === 269 /* ExportDeclaration */ + || kind === 268 /* ExportAssignment */ + || kind === 261 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 241 /* BreakStatement */ - || kind === 240 /* ContinueStatement */ - || kind === 248 /* DebuggerStatement */ - || kind === 235 /* DoStatement */ - || kind === 233 /* ExpressionStatement */ - || kind === 231 /* EmptyStatement */ - || kind === 238 /* ForInStatement */ - || kind === 239 /* ForOfStatement */ - || kind === 237 /* ForStatement */ - || kind === 234 /* IfStatement */ - || kind === 245 /* LabeledStatement */ - || kind === 242 /* ReturnStatement */ - || kind === 244 /* SwitchStatement */ - || kind === 246 /* ThrowStatement */ - || kind === 247 /* TryStatement */ - || kind === 232 /* VariableStatement */ - || kind === 236 /* WhileStatement */ - || kind === 243 /* WithStatement */ - || kind === 335 /* NotEmittedStatement */ - || kind === 339 /* EndOfDeclarationMarker */ - || kind === 338 /* MergeDeclarationMarker */; + return kind === 243 /* BreakStatement */ + || kind === 242 /* ContinueStatement */ + || kind === 250 /* DebuggerStatement */ + || kind === 237 /* DoStatement */ + || kind === 235 /* ExpressionStatement */ + || kind === 233 /* EmptyStatement */ + || kind === 240 /* ForInStatement */ + || kind === 241 /* ForOfStatement */ + || kind === 239 /* ForStatement */ + || kind === 236 /* IfStatement */ + || kind === 247 /* LabeledStatement */ + || kind === 244 /* ReturnStatement */ + || kind === 246 /* SwitchStatement */ + || kind === 248 /* ThrowStatement */ + || kind === 249 /* TryStatement */ + || kind === 234 /* VariableStatement */ + || kind === 238 /* WhileStatement */ + || kind === 245 /* WithStatement */ + || kind === 343 /* NotEmittedStatement */ + || kind === 347 /* EndOfDeclarationMarker */ + || kind === 346 /* MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { - if (node.kind === 159 /* TypeParameter */) { - return (node.parent && node.parent.kind !== 330 /* JSDocTemplateTag */) || ts.isInJSFile(node); + if (node.kind === 161 /* TypeParameter */) { + return (node.parent && node.parent.kind !== 338 /* JSDocTemplateTag */) || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -13056,10 +13399,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 230 /* Block */) + if (node.kind !== 232 /* Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 247 /* TryStatement */ || node.parent.kind === 287 /* CatchClause */) { + if (node.parent.kind === 249 /* TryStatement */ || node.parent.kind === 289 /* CatchClause */) { return false; } } @@ -13073,88 +13416,94 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 230 /* Block */; + || kind === 232 /* Block */; } ts.isStatementOrBlock = isStatementOrBlock; // Module references /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 272 /* ExternalModuleReference */ - || kind === 157 /* QualifiedName */ - || kind === 78 /* Identifier */; + return kind === 274 /* ExternalModuleReference */ + || kind === 159 /* QualifiedName */ + || kind === 79 /* Identifier */; } ts.isModuleReference = isModuleReference; // JSX /* @internal */ function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 107 /* ThisKeyword */ - || kind === 78 /* Identifier */ - || kind === 201 /* PropertyAccessExpression */; + return kind === 108 /* ThisKeyword */ + || kind === 79 /* Identifier */ + || kind === 203 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 273 /* JsxElement */ - || kind === 283 /* JsxExpression */ - || kind === 274 /* JsxSelfClosingElement */ + return kind === 275 /* JsxElement */ + || kind === 285 /* JsxExpression */ + || kind === 276 /* JsxSelfClosingElement */ || kind === 11 /* JsxText */ - || kind === 277 /* JsxFragment */; + || kind === 279 /* JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 280 /* JsxAttribute */ - || kind === 282 /* JsxSpreadAttribute */; + return kind === 282 /* JsxAttribute */ + || kind === 284 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 10 /* StringLiteral */ - || kind === 283 /* JsxExpression */; + || kind === 285 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 275 /* JsxOpeningElement */ - || kind === 274 /* JsxSelfClosingElement */; + return kind === 277 /* JsxOpeningElement */ + || kind === 276 /* JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 284 /* CaseClause */ - || kind === 285 /* DefaultClause */; + return kind === 286 /* CaseClause */ + || kind === 287 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 301 /* FirstJSDocNode */ && node.kind <= 333 /* LastJSDocNode */; + return node.kind >= 303 /* FirstJSDocNode */ && node.kind <= 341 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 311 /* JSDocComment */ || node.kind === 310 /* JSDocNamepathType */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 314 /* JSDocComment */ + || node.kind === 313 /* JSDocNamepathType */ + || node.kind === 315 /* JSDocText */ + || isJSDocLinkLike(node) + || isJSDocTag(node) + || ts.isJSDocTypeLiteral(node) + || ts.isJSDocSignature(node); } ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode; // TODO: determine what this does before making it public. /* @internal */ function isJSDocTag(node) { - return node.kind >= 314 /* FirstJSDocTagNode */ && node.kind <= 333 /* LastJSDocTagNode */; + return node.kind >= 321 /* FirstJSDocTagNode */ && node.kind <= 341 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 168 /* SetAccessor */; + return node.kind === 170 /* SetAccessor */; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 167 /* GetAccessor */; + return node.kind === 169 /* GetAccessor */; } ts.isGetAccessor = isGetAccessor; /** True if has jsdoc nodes attached to it. */ @@ -13180,13 +13529,13 @@ var ts; /** True if has initializer node attached to it. */ function hasOnlyExpressionInitializer(node) { switch (node.kind) { - case 249 /* VariableDeclaration */: - case 160 /* Parameter */: - case 198 /* BindingElement */: - case 162 /* PropertySignature */: - case 163 /* PropertyDeclaration */: - case 288 /* PropertyAssignment */: - case 291 /* EnumMember */: + case 251 /* VariableDeclaration */: + case 162 /* Parameter */: + case 200 /* BindingElement */: + case 164 /* PropertySignature */: + case 165 /* PropertyDeclaration */: + case 290 /* PropertyAssignment */: + case 293 /* EnumMember */: return true; default: return false; @@ -13194,12 +13543,12 @@ var ts; } ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { - return node.kind === 280 /* JsxAttribute */ || node.kind === 282 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); + return node.kind === 282 /* JsxAttribute */ || node.kind === 284 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); } ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 173 /* TypeReference */ || node.kind === 223 /* ExpressionWithTypeArguments */; + return node.kind === 175 /* TypeReference */ || node.kind === 225 /* ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -13231,6 +13580,10 @@ var ts; return node.kind === 10 /* StringLiteral */ || node.kind === 14 /* NoSubstitutionTemplateLiteral */; } ts.isStringLiteralLike = isStringLiteralLike; + function isJSDocLinkLike(node) { + return node.kind === 318 /* JSDocLink */ || node.kind === 319 /* JSDocLinkCode */ || node.kind === 320 /* JSDocLinkPlain */; + } + ts.isJSDocLinkLike = isJSDocLinkLike; // #endregion })(ts || (ts = {})); /* @internal */ @@ -13315,7 +13668,7 @@ var ts; increaseIndent: ts.noop, decreaseIndent: ts.noop, clear: function () { return str = ""; }, - trackSymbol: ts.noop, + trackSymbol: function () { return false; }, reportInaccessibleThisError: ts.noop, reportInaccessibleUniqueSymbolError: ts.noop, reportPrivateInBaseOfClassExpression: ts.noop, @@ -13327,11 +13680,19 @@ var ts; } ts.changesAffectModuleResolution = changesAffectModuleResolution; function optionsHaveModuleResolutionChanges(oldOptions, newOptions) { - return ts.moduleResolutionOptionDeclarations.some(function (o) { + return optionsHaveChanges(oldOptions, newOptions, ts.moduleResolutionOptionDeclarations); + } + ts.optionsHaveModuleResolutionChanges = optionsHaveModuleResolutionChanges; + function changesAffectingProgramStructure(oldOptions, newOptions) { + return optionsHaveChanges(oldOptions, newOptions, ts.optionsAffectingProgramStructure); + } + ts.changesAffectingProgramStructure = changesAffectingProgramStructure; + function optionsHaveChanges(oldOptions, newOptions, optionDeclarations) { + return oldOptions !== newOptions && optionDeclarations.some(function (o) { return !isJsonEqual(getCompilerOptionValue(oldOptions, o), getCompilerOptionValue(newOptions, o)); }); } - ts.optionsHaveModuleResolutionChanges = optionsHaveModuleResolutionChanges; + ts.optionsHaveChanges = optionsHaveChanges; function forEachAncestor(node, callback) { while (true) { var res = callback(node); @@ -13438,7 +13799,9 @@ var ts; } ts.packageIdToString = packageIdToString; function typeDirectiveIsEqualTo(oldResolution, newResolution) { - return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.primary === newResolution.primary; + return oldResolution.resolvedFileName === newResolution.resolvedFileName + && oldResolution.primary === newResolution.primary + && oldResolution.originalPath === newResolution.originalPath; } ts.typeDirectiveIsEqualTo = typeDirectiveIsEqualTo; function hasChangesInResolutions(names, newResolutions, oldResolutions, comparer) { @@ -13480,7 +13843,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 297 /* SourceFile */) { + while (node && node.kind !== 299 /* SourceFile */) { node = node.parent; } return node; @@ -13488,11 +13851,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 230 /* Block */: - case 258 /* CaseBlock */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: + case 232 /* Block */: + case 260 /* CaseBlock */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: return true; } return false; @@ -13630,10 +13993,10 @@ var ts; commentPos + 2 < commentEnd && text.charCodeAt(commentPos + 2) === 47 /* slash */) { var textSubStr = text.substring(commentPos, commentEnd); - return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) || - textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) || - textSubStr.match(fullTripleSlashReferenceTypeReferenceDirectiveRegEx) || - textSubStr.match(defaultLibReferenceRegEx) ? + return ts.fullTripleSlashReferencePathRegEx.test(textSubStr) || + ts.fullTripleSlashAMDReferencePathRegEx.test(textSubStr) || + fullTripleSlashReferenceTypeReferenceDirectiveRegEx.test(textSubStr) || + defaultLibReferenceRegEx.test(textSubStr) ? true : false; } return false; @@ -13688,10 +14051,12 @@ 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 === 334 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 342 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } - return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); + return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, + /*stopAfterLineBreak*/ false, + /*stopAtComments*/ false, isInJSDoc(node)); } ts.getTokenPosOfNode = getTokenPosOfNode; function getNonDecoratorTokenPosOfNode(node, sourceFile) { @@ -13721,7 +14086,7 @@ var ts; var text = sourceText.substring(includeTrivia ? node.pos : ts.skipTrivia(sourceText, node.pos), node.end); if (isJSDocTypeExpressionOrChild(node)) { // strip space + asterisk at line start - text = text.replace(/(^|\r?\n|\r)\s*\*\s*/g, "$1"); + text = text.split(/\r\n|\n|\r/).map(function (line) { return ts.trimStringStart(line.replace(/^\s*\*/, "")); }).join("\n"); } return text; } @@ -13810,9 +14175,11 @@ var ts; DataView: ["setBigInt64", "setBigUint64", "getBigInt64", "getBigUint64"], RelativeTimeFormat: ["format", "formatToParts", "resolvedOptions"] }, - esnext: { + es2021: { PromiseConstructor: ["any"], - String: ["replaceAll"], + String: ["replaceAll"] + }, + esnext: { NumberFormat: ["formatToParts"] } }; @@ -13905,7 +14272,7 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 249 /* VariableDeclaration */ && node.parent.kind === 287 /* CatchClause */; + return node.kind === 251 /* VariableDeclaration */ && node.parent.kind === 289 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { @@ -13937,11 +14304,11 @@ 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 === 256 /* ModuleDeclaration */ && (!node.body); + return !!node && node.kind === 258 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 297 /* SourceFile */ || - node.kind === 256 /* ModuleDeclaration */ || + return node.kind === 299 /* SourceFile */ || + node.kind === 258 /* ModuleDeclaration */ || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -13958,16 +14325,17 @@ 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 297 /* SourceFile */: + case 299 /* SourceFile */: return ts.isExternalModule(node.parent); - case 257 /* ModuleBlock */: + case 259 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; } ts.isModuleAugmentationExternal = isModuleAugmentationExternal; function getNonAugmentationDeclaration(symbol) { - return ts.find(symbol.declarations, function (d) { return !isExternalModuleAugmentation(d) && !(ts.isModuleDeclaration(d) && isGlobalScopeAugmentation(d)); }); + var _a; + return (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return !isExternalModuleAugmentation(d) && !(ts.isModuleDeclaration(d) && isGlobalScopeAugmentation(d)); }); } ts.getNonAugmentationDeclaration = getNonAugmentationDeclaration; function isEffectiveExternalModule(node, compilerOptions) { @@ -14013,22 +14381,22 @@ var ts; ts.isEffectiveStrictModeSourceFile = isEffectiveStrictModeSourceFile; function isBlockScope(node, parentNode) { switch (node.kind) { - case 297 /* SourceFile */: - case 258 /* CaseBlock */: - case 287 /* CatchClause */: - case 256 /* ModuleDeclaration */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 166 /* Constructor */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 299 /* SourceFile */: + case 260 /* CaseBlock */: + case 289 /* CatchClause */: + case 258 /* ModuleDeclaration */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 168 /* Constructor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return true; - case 230 /* Block */: + case 232 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return !ts.isFunctionLike(parentNode); @@ -14038,9 +14406,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 324 /* JSDocCallbackTag */: - case 331 /* JSDocTypedefTag */: - case 313 /* JSDocSignature */: + case 332 /* JSDocCallbackTag */: + case 339 /* JSDocTypedefTag */: + case 317 /* JSDocSignature */: return true; default: ts.assertType(node); @@ -14050,25 +14418,25 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isDeclarationWithTypeParameterChildren(node) { switch (node.kind) { - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 164 /* MethodSignature */: - case 171 /* IndexSignature */: - case 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 308 /* JSDocFunctionType */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 330 /* JSDocTemplateTag */: - case 251 /* FunctionDeclaration */: - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 166 /* MethodSignature */: + case 173 /* IndexSignature */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: + case 311 /* JSDocFunctionType */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 338 /* JSDocTemplateTag */: + case 253 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return true; default: ts.assertType(node); @@ -14078,8 +14446,8 @@ var ts; ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren; function isAnyImportSyntax(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: - case 260 /* ImportEqualsDeclaration */: + case 263 /* ImportDeclaration */: + case 262 /* ImportEqualsDeclaration */: return true; default: return false; @@ -14088,15 +14456,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: - case 260 /* ImportEqualsDeclaration */: - case 232 /* VariableStatement */: - case 252 /* ClassDeclaration */: - case 251 /* FunctionDeclaration */: - case 256 /* ModuleDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: + case 263 /* ImportDeclaration */: + case 262 /* ImportEqualsDeclaration */: + case 234 /* VariableStatement */: + case 254 /* ClassDeclaration */: + case 253 /* FunctionDeclaration */: + case 258 /* ModuleDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 255 /* InterfaceDeclaration */: + case 257 /* EnumDeclaration */: return true; default: return false; @@ -14129,19 +14497,19 @@ var ts; } ts.getNameFromIndexInfo = getNameFromIndexInfo; function isComputedNonLiteralName(name) { - return name.kind === 158 /* ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression); + return name.kind === 160 /* ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression); } ts.isComputedNonLiteralName = isComputedNonLiteralName; function getTextOfPropertyName(name) { switch (name.kind) { - case 78 /* Identifier */: - case 79 /* PrivateIdentifier */: + case 79 /* Identifier */: + case 80 /* PrivateIdentifier */: return name.escapedText; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: if (isStringOrNumericLiteralLike(name.expression)) return ts.escapeLeadingUnderscores(name.expression.text); return ts.Debug.fail("Text of property name cannot be read from non-literal-valued ComputedPropertyNames"); @@ -14152,20 +14520,22 @@ var ts; ts.getTextOfPropertyName = getTextOfPropertyName; function entityNameToString(name) { switch (name.kind) { - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: return "this"; - case 79 /* PrivateIdentifier */: - case 78 /* Identifier */: + case 80 /* PrivateIdentifier */: + case 79 /* Identifier */: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 157 /* QualifiedName */: + case 159 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 201 /* PropertyAccessExpression */: + case 203 /* 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 305 /* JSDocMemberName */: + return entityNameToString(name.left) + entityNameToString(name.right); default: return ts.Debug.assertNever(name); } @@ -14245,7 +14615,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 230 /* Block */) { + if (node.body && node.body.kind === 232 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -14259,7 +14629,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 297 /* SourceFile */: + case 299 /* 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 @@ -14268,28 +14638,28 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 249 /* VariableDeclaration */: - case 198 /* BindingElement */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 256 /* ModuleDeclaration */: - case 255 /* EnumDeclaration */: - case 291 /* EnumMember */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 254 /* TypeAliasDeclaration */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 251 /* VariableDeclaration */: + case 200 /* BindingElement */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: + case 258 /* ModuleDeclaration */: + case 257 /* EnumDeclaration */: + case 293 /* EnumMember */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 256 /* TypeAliasDeclaration */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: errorNode = node.name; break; - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); - case 284 /* CaseClause */: - case 285 /* DefaultClause */: + case 286 /* CaseClause */: + case 287 /* 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); @@ -14341,16 +14711,16 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 203 /* CallExpression */ && n.expression.kind === 105 /* SuperKeyword */; + return n.kind === 205 /* CallExpression */ && n.expression.kind === 106 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 203 /* CallExpression */ && n.expression.kind === 99 /* ImportKeyword */; + return n.kind === 205 /* CallExpression */ && n.expression.kind === 100 /* ImportKeyword */; } ts.isImportCall = isImportCall; function isImportMeta(n) { return ts.isMetaProperty(n) - && n.keywordToken === 99 /* ImportKeyword */ + && n.keywordToken === 100 /* ImportKeyword */ && n.name.escapedText === "meta"; } ts.isImportMeta = isImportMeta; @@ -14359,7 +14729,7 @@ var ts; } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 233 /* ExpressionStatement */ + return node.kind === 235 /* ExpressionStatement */ && node.expression.kind === 10 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; @@ -14387,11 +14757,12 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 160 /* Parameter */ || - node.kind === 159 /* TypeParameter */ || - node.kind === 208 /* FunctionExpression */ || - node.kind === 209 /* ArrowFunction */ || - node.kind === 207 /* ParenthesizedExpression */) ? + var commentRanges = (node.kind === 162 /* Parameter */ || + node.kind === 161 /* TypeParameter */ || + node.kind === 210 /* FunctionExpression */ || + node.kind === 211 /* ArrowFunction */ || + node.kind === 209 /* ParenthesizedExpression */ || + node.kind === 251 /* VariableDeclaration */) ? 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 '/**/' @@ -14402,53 +14773,53 @@ var ts; }); } ts.getJSDocCommentRanges = getJSDocCommentRanges; - ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; - var fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; - ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; - var defaultLibReferenceRegEx = /^(\/\/\/\s*/; + ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; + var fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; + ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; + var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (172 /* FirstTypeNode */ <= node.kind && node.kind <= 195 /* LastTypeNode */) { + if (174 /* FirstTypeNode */ <= node.kind && node.kind <= 197 /* LastTypeNode */) { return true; } switch (node.kind) { - case 128 /* AnyKeyword */: - case 152 /* UnknownKeyword */: - case 144 /* NumberKeyword */: - case 155 /* BigIntKeyword */: - case 147 /* StringKeyword */: - case 131 /* BooleanKeyword */: - case 148 /* SymbolKeyword */: - case 145 /* ObjectKeyword */: - case 150 /* UndefinedKeyword */: - case 141 /* NeverKeyword */: + case 129 /* AnyKeyword */: + case 153 /* UnknownKeyword */: + case 145 /* NumberKeyword */: + case 156 /* BigIntKeyword */: + case 148 /* StringKeyword */: + case 132 /* BooleanKeyword */: + case 149 /* SymbolKeyword */: + case 146 /* ObjectKeyword */: + case 151 /* UndefinedKeyword */: + case 142 /* NeverKeyword */: return true; - case 113 /* VoidKeyword */: - return node.parent.kind !== 212 /* VoidExpression */; - case 223 /* ExpressionWithTypeArguments */: + case 114 /* VoidKeyword */: + return node.parent.kind !== 214 /* VoidExpression */; + case 225 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 159 /* TypeParameter */: - return node.parent.kind === 190 /* MappedType */ || node.parent.kind === 185 /* InferType */; + case 161 /* TypeParameter */: + return node.parent.kind === 192 /* MappedType */ || node.parent.kind === 187 /* InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container - case 78 /* Identifier */: + case 79 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 157 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 159 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 201 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 203 /* 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 === 78 /* Identifier */ || node.kind === 157 /* QualifiedName */ || node.kind === 201 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 79 /* Identifier */ || node.kind === 159 /* QualifiedName */ || node.kind === 203 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through - case 157 /* QualifiedName */: - case 201 /* PropertyAccessExpression */: - case 107 /* ThisKeyword */: { + case 159 /* QualifiedName */: + case 203 /* PropertyAccessExpression */: + case 108 /* ThisKeyword */: { var parent = node.parent; - if (parent.kind === 176 /* TypeQuery */) { + if (parent.kind === 178 /* TypeQuery */) { return false; } - if (parent.kind === 195 /* ImportType */) { + if (parent.kind === 197 /* ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -14457,40 +14828,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 (172 /* FirstTypeNode */ <= parent.kind && parent.kind <= 195 /* LastTypeNode */) { + if (174 /* FirstTypeNode */ <= parent.kind && parent.kind <= 197 /* LastTypeNode */) { return true; } switch (parent.kind) { - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 159 /* TypeParameter */: + case 161 /* TypeParameter */: return node === parent.constraint; - case 330 /* JSDocTemplateTag */: + case 338 /* JSDocTemplateTag */: return node === parent.constraint; - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 160 /* Parameter */: - case 249 /* VariableDeclaration */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 162 /* Parameter */: + case 251 /* VariableDeclaration */: return node === parent.type; - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 166 /* Constructor */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 168 /* Constructor */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return node === parent.type; - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 173 /* IndexSignature */: return node === parent.type; - case 206 /* TypeAssertionExpression */: + case 208 /* TypeAssertionExpression */: return node === parent.type; - case 203 /* CallExpression */: - case 204 /* NewExpression */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: return ts.contains(parent.typeArguments, node); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -14515,23 +14886,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: return visitor(node); - case 258 /* CaseBlock */: - case 230 /* Block */: - case 234 /* IfStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 243 /* WithStatement */: - case 244 /* SwitchStatement */: - case 284 /* CaseClause */: - case 285 /* DefaultClause */: - case 245 /* LabeledStatement */: - case 247 /* TryStatement */: - case 287 /* CatchClause */: + case 260 /* CaseBlock */: + case 232 /* Block */: + case 236 /* IfStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 245 /* WithStatement */: + case 246 /* SwitchStatement */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: + case 247 /* LabeledStatement */: + case 249 /* TryStatement */: + case 289 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -14541,23 +14912,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 255 /* EnumDeclaration */: - case 253 /* InterfaceDeclaration */: - case 256 /* ModuleDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 257 /* EnumDeclaration */: + case 255 /* InterfaceDeclaration */: + case 258 /* ModuleDeclaration */: + case 256 /* 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 === 158 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 160 /* 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); @@ -14580,10 +14951,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 178 /* ArrayType */) { + if (node && node.kind === 180 /* ArrayType */) { return node.elementType; } - else if (node && node.kind === 173 /* TypeReference */) { + else if (node && node.kind === 175 /* TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -14593,12 +14964,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 253 /* InterfaceDeclaration */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 177 /* TypeLiteral */: + case 255 /* InterfaceDeclaration */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 179 /* TypeLiteral */: return node.members; - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return node.properties; } } @@ -14606,14 +14977,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 198 /* BindingElement */: - case 291 /* EnumMember */: - case 160 /* Parameter */: - case 288 /* PropertyAssignment */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 289 /* ShorthandPropertyAssignment */: - case 249 /* VariableDeclaration */: + case 200 /* BindingElement */: + case 293 /* EnumMember */: + case 162 /* Parameter */: + case 290 /* PropertyAssignment */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 291 /* ShorthandPropertyAssignment */: + case 251 /* VariableDeclaration */: return true; } } @@ -14625,8 +14996,8 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 250 /* VariableDeclarationList */ - && node.parent.parent.kind === 232 /* VariableStatement */; + return node.parent.kind === 252 /* VariableDeclarationList */ + && node.parent.parent.kind === 234 /* VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { @@ -14637,13 +15008,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: return true; } return false; @@ -14654,7 +15025,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 245 /* LabeledStatement */) { + if (node.statement.kind !== 247 /* LabeledStatement */) { return node.statement; } node = node.statement; @@ -14662,17 +15033,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 230 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 232 /* Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 165 /* MethodDeclaration */ && node.parent.kind === 200 /* ObjectLiteralExpression */; + return node && node.kind === 167 /* MethodDeclaration */ && node.parent.kind === 202 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 165 /* MethodDeclaration */ && - (node.parent.kind === 200 /* ObjectLiteralExpression */ || - node.parent.kind === 221 /* ClassExpression */); + return node.kind === 167 /* MethodDeclaration */ && + (node.parent.kind === 202 /* ObjectLiteralExpression */ || + node.parent.kind === 223 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -14685,7 +15056,7 @@ var ts; ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 288 /* PropertyAssignment */) { + if (property.kind === 290 /* PropertyAssignment */) { var propName = getTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -14734,14 +15105,14 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 297 /* SourceFile */); + ts.Debug.assert(node.kind !== 299 /* 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 158 /* ComputedPropertyName */: + case 160 /* 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 @@ -14756,9 +15127,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 161 /* Decorator */: + case 163 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 160 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 162 /* 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; @@ -14769,26 +15140,26 @@ var ts; node = node.parent; } break; - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 256 /* ModuleDeclaration */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: - case 255 /* EnumDeclaration */: - case 297 /* SourceFile */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 258 /* ModuleDeclaration */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 173 /* IndexSignature */: + case 257 /* EnumDeclaration */: + case 299 /* SourceFile */: return node; } } @@ -14807,9 +15178,9 @@ var ts; var container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { switch (container.kind) { - case 166 /* Constructor */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: + case 168 /* Constructor */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: return container; } } @@ -14831,27 +15202,27 @@ var ts; return node; } switch (node.kind) { - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: node = node.parent; break; - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: if (!stopOnFunctions) { continue; } // falls through - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return node; - case 161 /* Decorator */: + case 163 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 160 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 162 /* 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; @@ -14867,21 +15238,21 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 208 /* FunctionExpression */ || func.kind === 209 /* ArrowFunction */) { + if (func.kind === 210 /* FunctionExpression */ || func.kind === 211 /* ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 207 /* ParenthesizedExpression */) { + while (parent.kind === 209 /* ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 203 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 205 /* CallExpression */ && parent.expression === prev) { return parent; } } } ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperOrSuperProperty(node) { - return node.kind === 105 /* SuperKeyword */ + return node.kind === 106 /* SuperKeyword */ || isSuperProperty(node); } ts.isSuperOrSuperProperty = isSuperOrSuperProperty; @@ -14890,8 +15261,8 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 201 /* PropertyAccessExpression */ || kind === 202 /* ElementAccessExpression */) - && node.expression.kind === 105 /* SuperKeyword */; + return (kind === 203 /* PropertyAccessExpression */ || kind === 204 /* ElementAccessExpression */) + && node.expression.kind === 106 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; /** @@ -14899,26 +15270,34 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 201 /* PropertyAccessExpression */ || kind === 202 /* ElementAccessExpression */) - && node.expression.kind === 107 /* ThisKeyword */; + return (kind === 203 /* PropertyAccessExpression */ || kind === 204 /* ElementAccessExpression */) + && node.expression.kind === 108 /* 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) === 107 /* ThisKeyword */; + return !!node && ts.isVariableDeclaration(node) && ((_a = node.initializer) === null || _a === void 0 ? void 0 : _a.kind) === 108 /* 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 */; + } + ts.isThisInitializedObjectBindingExpression = isThisInitializedObjectBindingExpression; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 173 /* TypeReference */: + case 175 /* TypeReference */: return node.typeName; - case 223 /* ExpressionWithTypeArguments */: + case 225 /* 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 78 /* Identifier */: - case 157 /* QualifiedName */: + case 79 /* Identifier */: + case 159 /* QualifiedName */: return node; } return undefined; @@ -14926,10 +15305,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return node.tag; - case 275 /* JsxOpeningElement */: - case 274 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -14942,25 +15321,25 @@ var ts; return false; } switch (node.kind) { - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: // classes are valid targets return true; - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 252 /* ClassDeclaration */; - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 165 /* MethodDeclaration */: + return parent.kind === 254 /* ClassDeclaration */; + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 167 /* 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 === 252 /* ClassDeclaration */; - case 160 /* Parameter */: + && parent.kind === 254 /* ClassDeclaration */; + case 162 /* 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 === 166 /* Constructor */ - || parent.kind === 165 /* MethodDeclaration */ - || parent.kind === 168 /* SetAccessor */) - && grandparent.kind === 252 /* ClassDeclaration */; + && (parent.kind === 168 /* Constructor */ + || parent.kind === 167 /* MethodDeclaration */ + || parent.kind === 170 /* SetAccessor */) + && grandparent.kind === 254 /* ClassDeclaration */; } return false; } @@ -14976,10 +15355,10 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 - case 165 /* MethodDeclaration */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 170 /* SetAccessor */: return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); // TODO: GH#18217 default: return false; @@ -14988,9 +15367,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 275 /* JsxOpeningElement */ || - parent.kind === 274 /* JsxSelfClosingElement */ || - parent.kind === 276 /* JsxClosingElement */) { + if (parent.kind === 277 /* JsxOpeningElement */ || + parent.kind === 276 /* JsxSelfClosingElement */ || + parent.kind === 278 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -14998,49 +15377,54 @@ var ts; ts.isJSXTagName = isJSXTagName; function isExpressionNode(node) { switch (node.kind) { - case 105 /* SuperKeyword */: - case 103 /* NullKeyword */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: + case 106 /* SuperKeyword */: + case 104 /* NullKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: case 13 /* RegularExpressionLiteral */: - case 199 /* ArrayLiteralExpression */: - case 200 /* ObjectLiteralExpression */: - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: - case 203 /* CallExpression */: - case 204 /* NewExpression */: - case 205 /* TaggedTemplateExpression */: - case 224 /* AsExpression */: - case 206 /* TypeAssertionExpression */: - case 225 /* NonNullExpression */: - case 207 /* ParenthesizedExpression */: - case 208 /* FunctionExpression */: - case 221 /* ClassExpression */: - case 209 /* ArrowFunction */: - case 212 /* VoidExpression */: - case 210 /* DeleteExpression */: - case 211 /* TypeOfExpression */: - case 214 /* PrefixUnaryExpression */: - case 215 /* PostfixUnaryExpression */: - case 216 /* BinaryExpression */: - case 217 /* ConditionalExpression */: - case 220 /* SpreadElement */: - case 218 /* TemplateExpression */: - case 222 /* OmittedExpression */: - case 273 /* JsxElement */: - case 274 /* JsxSelfClosingElement */: - case 277 /* JsxFragment */: - case 219 /* YieldExpression */: - case 213 /* AwaitExpression */: - case 226 /* MetaProperty */: + case 201 /* ArrayLiteralExpression */: + case 202 /* ObjectLiteralExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: + case 207 /* TaggedTemplateExpression */: + case 226 /* AsExpression */: + case 208 /* TypeAssertionExpression */: + case 227 /* NonNullExpression */: + case 209 /* ParenthesizedExpression */: + case 210 /* FunctionExpression */: + case 223 /* ClassExpression */: + case 211 /* ArrowFunction */: + case 214 /* VoidExpression */: + case 212 /* DeleteExpression */: + case 213 /* TypeOfExpression */: + case 216 /* PrefixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: + case 218 /* BinaryExpression */: + case 219 /* ConditionalExpression */: + case 222 /* SpreadElement */: + case 220 /* TemplateExpression */: + case 224 /* OmittedExpression */: + case 275 /* JsxElement */: + case 276 /* JsxSelfClosingElement */: + case 279 /* JsxFragment */: + case 221 /* YieldExpression */: + case 215 /* AwaitExpression */: + case 228 /* MetaProperty */: return true; - case 157 /* QualifiedName */: - while (node.parent.kind === 157 /* QualifiedName */) { + case 159 /* QualifiedName */: + while (node.parent.kind === 159 /* QualifiedName */) { + node = node.parent; + } + return node.parent.kind === 178 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); + case 305 /* JSDocMemberName */: + while (ts.isJSDocMemberName(node.parent)) { node = node.parent; } - return node.parent.kind === 176 /* TypeQuery */ || isJSXTagName(node); - case 78 /* Identifier */: - if (node.parent.kind === 176 /* TypeQuery */ || isJSXTagName(node)) { + return node.parent.kind === 178 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); + case 79 /* Identifier */: + if (node.parent.kind === 178 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node)) { return true; } // falls through @@ -15048,7 +15432,7 @@ var ts; case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: return isInExpressionContext(node); default: return false; @@ -15058,49 +15442,49 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 249 /* VariableDeclaration */: - case 160 /* Parameter */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 291 /* EnumMember */: - case 288 /* PropertyAssignment */: - case 198 /* BindingElement */: + case 251 /* VariableDeclaration */: + case 162 /* Parameter */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 293 /* EnumMember */: + case 290 /* PropertyAssignment */: + case 200 /* BindingElement */: return parent.initializer === node; - case 233 /* ExpressionStatement */: - case 234 /* IfStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: - case 242 /* ReturnStatement */: - case 243 /* WithStatement */: - case 244 /* SwitchStatement */: - case 284 /* CaseClause */: - case 246 /* ThrowStatement */: + case 235 /* ExpressionStatement */: + case 236 /* IfStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: + case 244 /* ReturnStatement */: + case 245 /* WithStatement */: + case 246 /* SwitchStatement */: + case 286 /* CaseClause */: + case 248 /* ThrowStatement */: return parent.expression === node; - case 237 /* ForStatement */: + case 239 /* ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 250 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 252 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 250 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 252 /* VariableDeclarationList */) || forInStatement.expression === node; - case 206 /* TypeAssertionExpression */: - case 224 /* AsExpression */: + case 208 /* TypeAssertionExpression */: + case 226 /* AsExpression */: return node === parent.expression; - case 228 /* TemplateSpan */: + case 230 /* TemplateSpan */: return node === parent.expression; - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return node === parent.expression; - case 161 /* Decorator */: - case 283 /* JsxExpression */: - case 282 /* JsxSpreadAttribute */: - case 290 /* SpreadAssignment */: + case 163 /* Decorator */: + case 285 /* JsxExpression */: + case 284 /* JsxSpreadAttribute */: + case 292 /* SpreadAssignment */: return true; - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return parent.objectAssignmentInitializer === node; default: return isExpressionNode(parent); @@ -15108,14 +15492,18 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isPartOfTypeQuery(node) { - while (node.kind === 157 /* QualifiedName */ || node.kind === 78 /* Identifier */) { + while (node.kind === 159 /* QualifiedName */ || node.kind === 79 /* Identifier */) { node = node.parent; } - return node.kind === 176 /* TypeQuery */; + return node.kind === 178 /* TypeQuery */; } ts.isPartOfTypeQuery = isPartOfTypeQuery; + function isNamespaceReexportDeclaration(node) { + return ts.isNamespaceExport(node) && !!node.parent.moduleSpecifier; + } + ts.isNamespaceReexportDeclaration = isNamespaceReexportDeclaration; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 260 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 272 /* ExternalModuleReference */; + return node.kind === 262 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 274 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -15124,12 +15512,11 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function getExternalModuleRequireArgument(node) { - return isRequireVariableDeclaration(node, /*requireStringLiteralLikeArgument*/ true) - && getLeftmostAccessExpression(node.initializer).arguments[0]; + return isRequireVariableDeclaration(node) && getLeftmostAccessExpression(node.initializer).arguments[0]; } ts.getExternalModuleRequireArgument = getExternalModuleRequireArgument; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 260 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 272 /* ExternalModuleReference */; + return node.kind === 262 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 274 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJS(file) { @@ -15161,15 +15548,15 @@ var ts; ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && node.typeArguments && node.typeArguments.length === 2 && - (node.typeArguments[0].kind === 147 /* StringKeyword */ || node.typeArguments[0].kind === 144 /* NumberKeyword */); + (node.typeArguments[0].kind === 148 /* StringKeyword */ || node.typeArguments[0].kind === 145 /* NumberKeyword */); } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, requireStringLiteralLikeArgument) { - if (callExpression.kind !== 203 /* CallExpression */) { + if (callExpression.kind !== 205 /* CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; - if (expression.kind !== 78 /* Identifier */ || expression.escapedText !== "require") { + if (expression.kind !== 79 /* Identifier */ || expression.escapedText !== "require") { return false; } if (args.length !== 1) { @@ -15179,18 +15566,21 @@ var ts; return !requireStringLiteralLikeArgument || ts.isStringLiteralLike(arg); } ts.isRequireCall = isRequireCall; - function isRequireVariableDeclaration(node, requireStringLiteralLikeArgument) { - if (node.kind === 198 /* BindingElement */) { + /** + * Returns true if the node is a VariableDeclaration initialized to a require call (see `isRequireCall`). + * This function does not test if the node is in a JavaScript file or not. + */ + function isRequireVariableDeclaration(node) { + if (node.kind === 200 /* BindingElement */) { node = node.parent.parent; } - return ts.isVariableDeclaration(node) && !!node.initializer && isRequireCall(getLeftmostAccessExpression(node.initializer), requireStringLiteralLikeArgument); + return ts.isVariableDeclaration(node) && !!node.initializer && isRequireCall(getLeftmostAccessExpression(node.initializer), /*requireStringLiteralLikeArgument*/ true); } ts.isRequireVariableDeclaration = isRequireVariableDeclaration; - function isRequireVariableStatement(node, requireStringLiteralLikeArgument) { - if (requireStringLiteralLikeArgument === void 0) { requireStringLiteralLikeArgument = true; } + function isRequireVariableStatement(node) { return ts.isVariableStatement(node) && node.declarationList.declarations.length > 0 - && ts.every(node.declarationList.declarations, function (decl) { return isRequireVariableDeclaration(decl, requireStringLiteralLikeArgument); }); + && ts.every(node.declarationList.declarations, function (decl) { return isRequireVariableDeclaration(decl); }); } ts.isRequireVariableStatement = isRequireVariableStatement; function isSingleOrDoubleQuote(charCode) { @@ -15236,7 +15626,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 === 62 /* EqualsToken */) { + if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* EqualsToken */) { var isPrototypeAssignment = isPrototypeAccess(node.parent.left); return getExpandoInitializer(node.parent.right, isPrototypeAssignment) || getDefaultedExpandoInitializer(node.parent.left, node.parent.right, isPrototypeAssignment); @@ -15262,11 +15652,11 @@ var ts; function getExpandoInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 208 /* FunctionExpression */ || e.kind === 209 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 210 /* FunctionExpression */ || e.kind === 211 /* ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 208 /* FunctionExpression */ || - initializer.kind === 221 /* ClassExpression */ || - initializer.kind === 209 /* ArrowFunction */) { + if (initializer.kind === 210 /* FunctionExpression */ || + initializer.kind === 223 /* ClassExpression */ || + initializer.kind === 211 /* ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -15292,7 +15682,7 @@ var ts; } function isDefaultedExpandoInitializer(node) { var name = ts.isVariableDeclaration(node.parent) ? node.parent.name : - ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 /* EqualsToken */ ? node.parent.left : + ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* EqualsToken */ ? node.parent.left : undefined; return name && getExpandoInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left); } @@ -15301,7 +15691,7 @@ var ts; 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 === 62 /* EqualsToken */ && ts.isIdentifier(parent.left)) { + if (parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isIdentifier(parent.left)) { return parent.left; } } @@ -15324,7 +15714,7 @@ var ts; return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(initializer); } if (ts.isIdentifier(name) && isLiteralLikeAccess(initializer) && - (initializer.expression.kind === 107 /* ThisKeyword */ || + (initializer.expression.kind === 108 /* ThisKeyword */ || ts.isIdentifier(initializer.expression) && (initializer.expression.escapedText === "window" || initializer.expression.escapedText === "self" || @@ -15387,20 +15777,19 @@ var ts; ts.isLiteralLikeAccess = isLiteralLikeAccess; /** x[0] OR x['a'] OR x[Symbol.y] */ function isLiteralLikeElementAccess(node) { - return ts.isElementAccessExpression(node) && (isStringOrNumericLiteralLike(node.argumentExpression) || - isWellKnownSymbolSyntactically(node.argumentExpression)); + return ts.isElementAccessExpression(node) && isStringOrNumericLiteralLike(node.argumentExpression); } ts.isLiteralLikeElementAccess = isLiteralLikeElementAccess; /** Any series of property and element accesses. */ function isBindableStaticAccessExpression(node, excludeThisKeyword) { - return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 107 /* ThisKeyword */ || ts.isIdentifier(node.name) && isBindableStaticNameExpression(node.expression, /*excludeThisKeyword*/ true)) + return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 108 /* 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 === 107 /* ThisKeyword */) || + && ((!excludeThisKeyword && node.expression.kind === 108 /* ThisKeyword */) || isEntityNameExpression(node.expression) || isBindableStaticAccessExpression(node.expression, /*excludeThisKeyword*/ true)); } @@ -15430,7 +15819,7 @@ var ts; } return 7 /* ObjectDefinePropertyValue */; } - if (expr.operatorToken.kind !== 62 /* EqualsToken */ || !isAccessExpression(expr.left) || isVoidZero(getRightMostAssignedExpression(expr))) { + if (expr.operatorToken.kind !== 63 /* EqualsToken */ || !isAccessExpression(expr.left) || isVoidZero(getRightMostAssignedExpression(expr))) { return 0 /* None */; } if (isBindableStaticNameExpression(expr.left.expression, /*excludeThisKeyword*/ true) && getElementOrPropertyAccessName(expr.left) === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { @@ -15468,14 +15857,11 @@ var ts; return ts.escapeLeadingUnderscores(name.text); } } - if (ts.isElementAccessExpression(node) && isWellKnownSymbolSyntactically(node.argumentExpression)) { - return getPropertyNameForKnownSymbolName(ts.idText(node.argumentExpression.name)); - } return undefined; } ts.getElementOrPropertyAccessName = getElementOrPropertyAccessName; function getAssignmentDeclarationPropertyAccessKind(lhs) { - if (lhs.expression.kind === 107 /* ThisKeyword */) { + if (lhs.expression.kind === 108 /* ThisKeyword */) { return 4 /* ThisProperty */; } else if (isModuleExportsAccessExpression(lhs)) { @@ -15520,7 +15906,7 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJSFile(expr) && - expr.parent && expr.parent.kind === 233 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 235 /* ExpressionStatement */ && (!ts.isElementAccessExpression(expr) || isLiteralLikeElementAccess(expr)) && !!ts.getJSDocTypeTag(expr.parent); } @@ -15541,23 +15927,37 @@ var ts; return false; } var decl = symbol.valueDeclaration; - return decl.kind === 251 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); + return decl.kind === 253 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); } ts.isFunctionSymbol = isFunctionSymbol; + function tryGetModuleSpecifierFromDeclaration(node) { + var _a, _b, _c; + switch (node.kind) { + case 251 /* VariableDeclaration */: + return node.initializer.arguments[0].text; + case 263 /* ImportDeclaration */: + return (_a = ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike)) === null || _a === void 0 ? void 0 : _a.text; + case 262 /* ImportEqualsDeclaration */: + return (_c = ts.tryCast((_b = ts.tryCast(node.moduleReference, ts.isExternalModuleReference)) === null || _b === void 0 ? void 0 : _b.expression, ts.isStringLiteralLike)) === null || _c === void 0 ? void 0 : _c.text; + default: + ts.Debug.assertNever(node); + } + } + ts.tryGetModuleSpecifierFromDeclaration = tryGetModuleSpecifierFromDeclaration; function importFromModuleSpecifier(node) { return tryGetImportFromModuleSpecifier(node) || ts.Debug.failBadSyntaxKind(node.parent); } ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 261 /* ImportDeclaration */: - case 267 /* ExportDeclaration */: + case 263 /* ImportDeclaration */: + case 269 /* ExportDeclaration */: return node.parent; - case 272 /* ExternalModuleReference */: + case 274 /* ExternalModuleReference */: return node.parent.parent; - case 203 /* CallExpression */: + case 205 /* CallExpression */: return isImportCall(node.parent) || isRequireCall(node.parent, /*checkArg*/ false) ? node.parent : undefined; - case 191 /* LiteralType */: + case 193 /* LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -15567,15 +15967,17 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: - case 267 /* ExportDeclaration */: + case 263 /* ImportDeclaration */: + case 269 /* ExportDeclaration */: return node.moduleSpecifier; - case 260 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 272 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 195 /* ImportType */: + case 262 /* ImportEqualsDeclaration */: + return node.moduleReference.kind === 274 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 197 /* ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; - case 203 /* CallExpression */: + case 205 /* CallExpression */: return node.arguments[0]; + case 258 /* ModuleDeclaration */: + return node.name.kind === 10 /* StringLiteral */ ? node.name : undefined; default: return ts.Debug.assertNever(node); } @@ -15583,11 +15985,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return node; - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: return node.exportClause && ts.tryCast(node.exportClause, ts.isNamespaceExport); default: return ts.Debug.assertNever(node); @@ -15595,7 +15997,7 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 261 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 263 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function forEachImportClauseDeclaration(node, action) { @@ -15616,13 +16018,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 160 /* Parameter */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 289 /* ShorthandPropertyAssignment */: - case 288 /* PropertyAssignment */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 162 /* Parameter */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 291 /* ShorthandPropertyAssignment */: + case 290 /* PropertyAssignment */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -15636,7 +16038,7 @@ var ts; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 331 /* JSDocTypedefTag */ || node.kind === 324 /* JSDocCallbackTag */ || node.kind === 325 /* JSDocEnumTag */; + return node.kind === 339 /* JSDocTypedefTag */ || node.kind === 332 /* JSDocCallbackTag */ || node.kind === 333 /* JSDocEnumTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -15646,7 +16048,7 @@ var ts; function getSourceOfAssignment(node) { return ts.isExpressionStatement(node) && ts.isBinaryExpression(node.expression) && - node.expression.operatorToken.kind === 62 /* EqualsToken */ + node.expression.operatorToken.kind === 63 /* EqualsToken */ ? getRightMostAssignedExpression(node.expression) : undefined; } @@ -15661,12 +16063,12 @@ var ts; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return node.initializer; - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: return node.initializer; } } @@ -15678,7 +16080,7 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 256 /* ModuleDeclaration */ + node.body.kind === 258 /* ModuleDeclaration */ ? node.body : undefined; } @@ -15693,11 +16095,11 @@ var ts; if (ts.hasJSDocNodes(node)) { result = ts.append(result, ts.last(node.jsDoc)); } - if (node.kind === 160 /* Parameter */) { + if (node.kind === 162 /* Parameter */) { result = ts.addRange(result, (noCache ? ts.getJSDocParameterTagsNoCache : ts.getJSDocParameterTags)(node)); break; } - if (node.kind === 159 /* TypeParameter */) { + if (node.kind === 161 /* TypeParameter */) { result = ts.addRange(result, (noCache ? ts.getJSDocTypeParameterTagsNoCache : ts.getJSDocTypeParameterTags)(node)); break; } @@ -15708,12 +16110,13 @@ var ts; ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; function getNextJSDocCommentLocation(node) { var parent = node.parent; - if (parent.kind === 288 /* PropertyAssignment */ || - parent.kind === 266 /* ExportAssignment */ || - parent.kind === 163 /* PropertyDeclaration */ || - parent.kind === 233 /* ExpressionStatement */ && node.kind === 201 /* PropertyAccessExpression */ || + if (parent.kind === 290 /* PropertyAssignment */ || + parent.kind === 268 /* ExportAssignment */ || + parent.kind === 165 /* PropertyDeclaration */ || + parent.kind === 235 /* ExpressionStatement */ && node.kind === 203 /* PropertyAccessExpression */ || + parent.kind === 244 /* ReturnStatement */ || getNestedModuleDeclaration(parent) || - ts.isBinaryExpression(node) && node.operatorToken.kind === 62 /* EqualsToken */) { + ts.isBinaryExpression(node) && node.operatorToken.kind === 63 /* EqualsToken */) { return parent; } // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. @@ -15724,7 +16127,7 @@ var ts; // var x = function(name) { return name.length; } else if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node || - ts.isBinaryExpression(parent) && parent.operatorToken.kind === 62 /* EqualsToken */)) { + ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */)) { return parent.parent; } else if (parent.parent && parent.parent.parent && @@ -15748,7 +16151,7 @@ var ts; if (!decl) { return undefined; } - var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 78 /* Identifier */ && p.name.escapedText === name; }); + var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 79 /* Identifier */ && p.name.escapedText === name; }); return parameter && parameter.symbol; } ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc; @@ -15798,7 +16201,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 === 309 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 312 /* JSDocVariadicType */; } ts.isRestParameter = isRestParameter; function hasTypeArguments(node) { @@ -15815,31 +16218,34 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 62 /* EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* Definite */ : 2 /* Compound */ : + binaryOperator === 63 /* EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; - case 214 /* PrefixUnaryExpression */: - case 215 /* PostfixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; return unaryOperator === 45 /* PlusPlusToken */ || unaryOperator === 46 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 207 /* ParenthesizedExpression */: - case 199 /* ArrayLiteralExpression */: - case 220 /* SpreadElement */: - case 225 /* NonNullExpression */: + case 209 /* ParenthesizedExpression */: + case 201 /* ArrayLiteralExpression */: + case 222 /* SpreadElement */: + case 227 /* NonNullExpression */: node = parent; break; - case 289 /* ShorthandPropertyAssignment */: + case 292 /* SpreadAssignment */: + node = parent.parent; + break; + case 291 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } node = parent.parent; break; - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: if (parent.name === node) { return 0 /* None */; } @@ -15866,22 +16272,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 230 /* Block */: - case 232 /* VariableStatement */: - case 243 /* WithStatement */: - case 234 /* IfStatement */: - case 244 /* SwitchStatement */: - case 258 /* CaseBlock */: - case 284 /* CaseClause */: - case 285 /* DefaultClause */: - case 245 /* LabeledStatement */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: - case 247 /* TryStatement */: - case 287 /* CatchClause */: + case 232 /* Block */: + case 234 /* VariableStatement */: + case 245 /* WithStatement */: + case 236 /* IfStatement */: + case 246 /* SwitchStatement */: + case 260 /* CaseBlock */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: + case 247 /* LabeledStatement */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: + case 249 /* TryStatement */: + case 289 /* CatchClause */: return true; } return false; @@ -15898,11 +16304,11 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 186 /* ParenthesizedType */); + return walkUp(node, 188 /* ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 207 /* ParenthesizedExpression */); + return walkUp(node, 209 /* ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; /** @@ -15912,7 +16318,7 @@ var ts; */ function walkUpParenthesizedTypesAndGetParentAndChild(node) { var child; - while (node && node.kind === 186 /* ParenthesizedType */) { + while (node && node.kind === 188 /* ParenthesizedType */) { child = node; node = node.parent; } @@ -15923,19 +16329,13 @@ var ts; return ts.skipOuterExpressions(node, 1 /* Parentheses */); } ts.skipParentheses = skipParentheses; - function skipParenthesesUp(node) { - while (node.kind === 207 /* ParenthesizedExpression */) { - node = node.parent; - } - return node; - } // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped function isDeleteTarget(node) { - if (node.kind !== 201 /* PropertyAccessExpression */ && node.kind !== 202 /* ElementAccessExpression */) { + if (node.kind !== 203 /* PropertyAccessExpression */ && node.kind !== 204 /* ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 210 /* DeleteExpression */; + return node && node.kind === 212 /* DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -15962,7 +16362,7 @@ var ts; if (ts.isComputedPropertyName(parent)) return parent.parent; // falls through - case 78 /* Identifier */: + case 79 /* Identifier */: if (ts.isDeclaration(parent)) { return parent.name === name ? parent : undefined; } @@ -15979,7 +16379,7 @@ var ts; ? binExp : undefined; } - case 79 /* PrivateIdentifier */: + case 80 /* PrivateIdentifier */: return ts.isDeclaration(parent) && parent.name === name ? parent : undefined; default: return undefined; @@ -15988,7 +16388,7 @@ var ts; ts.getDeclarationFromName = getDeclarationFromName; function isLiteralComputedPropertyDeclarationName(node) { return isStringOrNumericLiteralLike(node) && - node.parent.kind === 158 /* ComputedPropertyName */ && + node.parent.kind === 160 /* ComputedPropertyName */ && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -15996,26 +16396,26 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 291 /* EnumMember */: - case 288 /* PropertyAssignment */: - case 201 /* PropertyAccessExpression */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 293 /* EnumMember */: + case 290 /* PropertyAssignment */: + case 203 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 157 /* QualifiedName */: + case 159 /* QualifiedName */: // Name on right hand side of dot in a type query or type reference return parent.right === node; - case 198 /* BindingElement */: - case 265 /* ImportSpecifier */: + case 200 /* BindingElement */: + case 267 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 270 /* ExportSpecifier */: - case 280 /* JsxAttribute */: + case 272 /* ExportSpecifier */: + case 282 /* JsxAttribute */: // Any name in an export specifier or JSX Attribute return true; } @@ -16035,33 +16435,33 @@ var ts; // {} // {name: } function isAliasSymbolDeclaration(node) { - return node.kind === 260 /* ImportEqualsDeclaration */ || - node.kind === 259 /* NamespaceExportDeclaration */ || - node.kind === 262 /* ImportClause */ && !!node.name || - node.kind === 263 /* NamespaceImport */ || - node.kind === 269 /* NamespaceExport */ || - node.kind === 265 /* ImportSpecifier */ || - node.kind === 270 /* ExportSpecifier */ || - node.kind === 266 /* ExportAssignment */ && exportAssignmentIsAlias(node) || + return node.kind === 262 /* ImportEqualsDeclaration */ || + node.kind === 261 /* NamespaceExportDeclaration */ || + node.kind === 264 /* ImportClause */ && !!node.name || + node.kind === 265 /* NamespaceImport */ || + node.kind === 271 /* NamespaceExport */ || + node.kind === 267 /* ImportSpecifier */ || + node.kind === 272 /* ExportSpecifier */ || + node.kind === 268 /* ExportAssignment */ && exportAssignmentIsAlias(node) || ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) || - ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62 /* EqualsToken */ && isAliasableExpression(node.parent.right) || - node.kind === 289 /* ShorthandPropertyAssignment */ || - node.kind === 288 /* PropertyAssignment */ && isAliasableExpression(node.initializer); + ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* EqualsToken */ && isAliasableExpression(node.parent.right) || + node.kind === 291 /* ShorthandPropertyAssignment */ || + node.kind === 290 /* PropertyAssignment */ && isAliasableExpression(node.initializer); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getAliasDeclarationFromName(node) { switch (node.parent.kind) { - case 262 /* ImportClause */: - case 265 /* ImportSpecifier */: - case 263 /* NamespaceImport */: - case 270 /* ExportSpecifier */: - case 266 /* ExportAssignment */: - case 260 /* ImportEqualsDeclaration */: + case 264 /* ImportClause */: + case 267 /* ImportSpecifier */: + case 265 /* NamespaceImport */: + case 272 /* ExportSpecifier */: + case 268 /* ExportAssignment */: + case 262 /* ImportEqualsDeclaration */: return node.parent; - case 157 /* QualifiedName */: + case 159 /* QualifiedName */: do { node = node.parent; - } while (node.parent.kind === 157 /* QualifiedName */); + } while (node.parent.kind === 159 /* QualifiedName */); return getAliasDeclarationFromName(node); } } @@ -16080,7 +16480,7 @@ var ts; } ts.getExportAssignmentExpression = getExportAssignmentExpression; function getPropertyAssignmentAliasLikeExpression(node) { - return node.kind === 289 /* ShorthandPropertyAssignment */ ? node.name : node.kind === 288 /* PropertyAssignment */ ? node.initializer : + return node.kind === 291 /* ShorthandPropertyAssignment */ ? node.name : node.kind === 290 /* PropertyAssignment */ ? node.initializer : node.parent.right; } ts.getPropertyAssignmentAliasLikeExpression = getPropertyAssignmentAliasLikeExpression; @@ -16097,7 +16497,7 @@ var ts; } ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode; function getClassExtendsHeritageElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 93 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 94 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement; @@ -16106,7 +16506,7 @@ var ts; return ts.getJSDocImplementsTags(node).map(function (n) { return n.class; }); } else { - var heritageClause = getHeritageClause(node.heritageClauses, 116 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 117 /* ImplementsKeyword */); return heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.types; } } @@ -16119,7 +16519,7 @@ var ts; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 93 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 94 /* ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -16146,11 +16546,11 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 80 /* FirstKeyword */ <= token && token <= 156 /* LastKeyword */; + return 81 /* FirstKeyword */ <= token && token <= 158 /* LastKeyword */; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 125 /* FirstContextualKeyword */ <= token && token <= 156 /* LastContextualKeyword */; + return 126 /* FirstContextualKeyword */ <= token && token <= 158 /* LastContextualKeyword */; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { @@ -16158,7 +16558,7 @@ var ts; } ts.isNonContextualKeyword = isNonContextualKeyword; function isFutureReservedKeyword(token) { - return 116 /* FirstFutureReservedWord */ <= token && token <= 124 /* LastFutureReservedWord */; + return 117 /* FirstFutureReservedWord */ <= token && token <= 125 /* LastFutureReservedWord */; } ts.isFutureReservedKeyword = isFutureReservedKeyword; function isStringANonContextualKeyword(name) { @@ -16194,14 +16594,14 @@ var ts; } var flags = 0 /* Normal */; switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 165 /* MethodDeclaration */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 167 /* MethodDeclaration */: if (node.asteriskToken) { flags |= 1 /* Generator */; } // falls through - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: if (hasSyntacticModifier(node, 256 /* Async */)) { flags |= 2 /* Async */; } @@ -16215,10 +16615,10 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 167 /* MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined && hasSyntacticModifier(node, 256 /* Async */); @@ -16241,9 +16641,6 @@ var ts; * 3. The computed name is *not* expressed as a NumericLiteral. * 4. The computed name is *not* expressed as a PlusToken or MinusToken * immediately followed by a NumericLiteral. - * 5. The computed name is *not* expressed as `Symbol.`, where `` - * is a property of the Symbol constructor that denotes a built-in - * Symbol. */ function hasDynamicName(declaration) { var name = ts.getNameOfDeclaration(declaration); @@ -16251,38 +16648,25 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - if (!(name.kind === 158 /* ComputedPropertyName */ || name.kind === 202 /* ElementAccessExpression */)) { + if (!(name.kind === 160 /* ComputedPropertyName */ || name.kind === 204 /* ElementAccessExpression */)) { return false; } var expr = ts.isElementAccessExpression(name) ? skipParentheses(name.argumentExpression) : name.expression; return !isStringOrNumericLiteralLike(expr) && - !isSignedNumericLiteral(expr) && - !isWellKnownSymbolSyntactically(expr); + !isSignedNumericLiteral(expr); } ts.isDynamicName = isDynamicName; - /** - * Checks if the expression is of the form: - * Symbol.name - * where Symbol is literally the word "Symbol", and name is any identifierName - */ - function isWellKnownSymbolSyntactically(node) { - return ts.isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression); - } - ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { switch (name.kind) { - case 78 /* Identifier */: - case 79 /* PrivateIdentifier */: + case 79 /* Identifier */: + case 80 /* PrivateIdentifier */: return name.escapedText; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: var nameExpression = name.expression; - if (isWellKnownSymbolSyntactically(nameExpression)) { - return getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); - } - else if (isStringOrNumericLiteralLike(nameExpression)) { + if (isStringOrNumericLiteralLike(nameExpression)) { return ts.escapeLeadingUnderscores(nameExpression.text); } else if (isSignedNumericLiteral(nameExpression)) { @@ -16299,7 +16683,7 @@ var ts; ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; function isPropertyNameLiteral(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: @@ -16310,21 +16694,17 @@ var ts; } ts.isPropertyNameLiteral = isPropertyNameLiteral; function getTextOfIdentifierOrLiteral(node) { - return ts.isIdentifierOrPrivateIdentifier(node) ? ts.idText(node) : node.text; + return ts.isMemberName(node) ? ts.idText(node) : node.text; } ts.getTextOfIdentifierOrLiteral = getTextOfIdentifierOrLiteral; function getEscapedTextOfIdentifierOrLiteral(node) { - return ts.isIdentifierOrPrivateIdentifier(node) ? node.escapedText : ts.escapeLeadingUnderscores(node.text); + return ts.isMemberName(node) ? node.escapedText : ts.escapeLeadingUnderscores(node.text); } ts.getEscapedTextOfIdentifierOrLiteral = getEscapedTextOfIdentifierOrLiteral; function getPropertyNameForUniqueESSymbol(symbol) { return "__@" + ts.getSymbolId(symbol) + "@" + symbol.escapedName; } ts.getPropertyNameForUniqueESSymbol = getPropertyNameForUniqueESSymbol; - function getPropertyNameForKnownSymbolName(symbolName) { - return "__@" + symbolName; - } - ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; function getSymbolNameForPrivateIdentifier(containingClassSymbol, description) { return "__#" + ts.getSymbolId(containingClassSymbol) + "@" + description; } @@ -16337,7 +16717,7 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 78 /* Identifier */ && node.escapedText === "Symbol"; + return node.kind === 79 /* Identifier */ && node.escapedText === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isPushOrUnshiftIdentifier(node) { @@ -16346,11 +16726,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 160 /* Parameter */; + return root.kind === 162 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 198 /* BindingElement */) { + while (node.kind === 200 /* BindingElement */) { node = node.parent.parent; } return node; @@ -16358,15 +16738,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 166 /* Constructor */ - || kind === 208 /* FunctionExpression */ - || kind === 251 /* FunctionDeclaration */ - || kind === 209 /* ArrowFunction */ - || kind === 165 /* MethodDeclaration */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */ - || kind === 256 /* ModuleDeclaration */ - || kind === 297 /* SourceFile */; + return kind === 168 /* Constructor */ + || kind === 210 /* FunctionExpression */ + || kind === 253 /* FunctionDeclaration */ + || kind === 211 /* ArrowFunction */ + || kind === 167 /* MethodDeclaration */ + || kind === 169 /* GetAccessor */ + || kind === 170 /* SetAccessor */ + || kind === 258 /* ModuleDeclaration */ + || kind === 299 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -16385,41 +16765,41 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 204 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 206 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 204 /* NewExpression */: + case 206 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 214 /* PrefixUnaryExpression */: - case 211 /* TypeOfExpression */: - case 212 /* VoidExpression */: - case 210 /* DeleteExpression */: - case 213 /* AwaitExpression */: - case 217 /* ConditionalExpression */: - case 219 /* YieldExpression */: + case 216 /* PrefixUnaryExpression */: + case 213 /* TypeOfExpression */: + case 214 /* VoidExpression */: + case 212 /* DeleteExpression */: + case 215 /* AwaitExpression */: + case 219 /* ConditionalExpression */: + case 221 /* YieldExpression */: return 1 /* Right */; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: switch (operator) { case 42 /* AsteriskAsteriskToken */: - case 62 /* EqualsToken */: - case 63 /* PlusEqualsToken */: - case 64 /* MinusEqualsToken */: - case 66 /* AsteriskAsteriskEqualsToken */: - case 65 /* AsteriskEqualsToken */: - case 67 /* SlashEqualsToken */: - case 68 /* PercentEqualsToken */: - case 69 /* LessThanLessThanEqualsToken */: - case 70 /* GreaterThanGreaterThanEqualsToken */: - case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 72 /* AmpersandEqualsToken */: - case 77 /* CaretEqualsToken */: - case 73 /* BarEqualsToken */: - case 74 /* BarBarEqualsToken */: - case 75 /* AmpersandAmpersandEqualsToken */: - case 76 /* QuestionQuestionEqualsToken */: + 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 */; } } @@ -16428,15 +16808,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 204 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 206 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 216 /* BinaryExpression */) { + if (expression.kind === 218 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 214 /* PrefixUnaryExpression */ || expression.kind === 215 /* PostfixUnaryExpression */) { + else if (expression.kind === 216 /* PrefixUnaryExpression */ || expression.kind === 217 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -16615,81 +16995,82 @@ var ts; })(OperatorPrecedence = ts.OperatorPrecedence || (ts.OperatorPrecedence = {})); function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 337 /* CommaListExpression */: + case 345 /* CommaListExpression */: return 0 /* Comma */; - case 220 /* SpreadElement */: + case 222 /* SpreadElement */: return 1 /* Spread */; - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: return 2 /* Yield */; - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: return 4 /* Conditional */; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: switch (operatorKind) { case 27 /* CommaToken */: return 0 /* Comma */; - case 62 /* EqualsToken */: - case 63 /* PlusEqualsToken */: - case 64 /* MinusEqualsToken */: - case 66 /* AsteriskAsteriskEqualsToken */: - case 65 /* AsteriskEqualsToken */: - case 67 /* SlashEqualsToken */: - case 68 /* PercentEqualsToken */: - case 69 /* LessThanLessThanEqualsToken */: - case 70 /* GreaterThanGreaterThanEqualsToken */: - case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 72 /* AmpersandEqualsToken */: - case 77 /* CaretEqualsToken */: - case 73 /* BarEqualsToken */: - case 74 /* BarBarEqualsToken */: - case 75 /* AmpersandAmpersandEqualsToken */: - case 76 /* QuestionQuestionEqualsToken */: + 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 */; default: return getBinaryOperatorPrecedence(operatorKind); } // TODO: Should prefix `++` and `--` be moved to the `Update` precedence? - case 206 /* TypeAssertionExpression */: - case 225 /* NonNullExpression */: - case 214 /* PrefixUnaryExpression */: - case 211 /* TypeOfExpression */: - case 212 /* VoidExpression */: - case 210 /* DeleteExpression */: - case 213 /* AwaitExpression */: + case 208 /* TypeAssertionExpression */: + case 227 /* NonNullExpression */: + case 216 /* PrefixUnaryExpression */: + case 213 /* TypeOfExpression */: + case 214 /* VoidExpression */: + case 212 /* DeleteExpression */: + case 215 /* AwaitExpression */: return 16 /* Unary */; - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: return 17 /* Update */; - case 203 /* CallExpression */: + case 205 /* CallExpression */: return 18 /* LeftHandSide */; - case 204 /* NewExpression */: + case 206 /* NewExpression */: return hasArguments ? 19 /* Member */ : 18 /* LeftHandSide */; - case 205 /* TaggedTemplateExpression */: - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 207 /* TaggedTemplateExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: + case 228 /* MetaProperty */: return 19 /* Member */; - case 224 /* AsExpression */: + case 226 /* AsExpression */: return 11 /* Relational */; - case 107 /* ThisKeyword */: - case 105 /* SuperKeyword */: - case 78 /* Identifier */: - case 103 /* NullKeyword */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: + case 108 /* ThisKeyword */: + case 106 /* SuperKeyword */: + case 79 /* Identifier */: + case 104 /* NullKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: - case 199 /* ArrayLiteralExpression */: - case 200 /* ObjectLiteralExpression */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 221 /* ClassExpression */: + case 201 /* ArrayLiteralExpression */: + case 202 /* ObjectLiteralExpression */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 223 /* ClassExpression */: case 13 /* RegularExpressionLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 218 /* TemplateExpression */: - case 207 /* ParenthesizedExpression */: - case 222 /* OmittedExpression */: - case 273 /* JsxElement */: - case 274 /* JsxSelfClosingElement */: - case 277 /* JsxFragment */: + case 220 /* TemplateExpression */: + case 209 /* ParenthesizedExpression */: + case 224 /* OmittedExpression */: + case 275 /* JsxElement */: + case 276 /* JsxSelfClosingElement */: + case 279 /* JsxFragment */: return 20 /* Primary */; default: return -1 /* Invalid */; @@ -16719,9 +17100,9 @@ var ts; case 31 /* GreaterThanToken */: case 32 /* LessThanEqualsToken */: case 33 /* GreaterThanEqualsToken */: - case 101 /* InstanceOfKeyword */: - case 100 /* InKeyword */: - case 126 /* AsKeyword */: + case 102 /* InstanceOfKeyword */: + case 101 /* InKeyword */: + case 127 /* AsKeyword */: return 11 /* Relational */; case 47 /* LessThanLessThanToken */: case 48 /* GreaterThanGreaterThanToken */: @@ -16745,7 +17126,7 @@ var ts; function getSemanticJsxChildren(children) { return ts.filter(children, function (i) { switch (i.kind) { - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: return !!i.expression; case 11 /* JsxText */: return !i.containsOnlyTriviaWhiteSpaces; @@ -17047,7 +17428,7 @@ var ts; reportInaccessibleThisError: ts.noop, reportPrivateInBaseOfClassExpression: ts.noop, reportInaccessibleUniqueSymbolError: ts.noop, - trackSymbol: ts.noop, + trackSymbol: function () { return false; }, writeKeyword: write, writeOperator: write, writeParameter: write, @@ -17139,11 +17520,20 @@ var ts; return file.moduleName || getExternalModuleNameFromPath(host, file.fileName, referenceFile && referenceFile.fileName); } ts.getResolvedExternalModuleName = getResolvedExternalModuleName; + function getCanonicalAbsolutePath(host, path) { + return host.getCanonicalFileName(ts.getNormalizedAbsolutePath(path, host.getCurrentDirectory())); + } function getExternalModuleNameFromDeclaration(host, resolver, declaration) { var file = resolver.getExternalModuleFileFromDeclaration(declaration); if (!file || file.isDeclarationFile) { return undefined; } + // If the declaration already uses a non-relative name, and is outside the common source directory, continue to use it + var specifier = getExternalModuleName(declaration); + if (specifier && ts.isStringLiteralLike(specifier) && !ts.pathIsRelative(specifier.text) && + getCanonicalAbsolutePath(host, file.path).indexOf(getCanonicalAbsolutePath(host, ts.ensureTrailingDirectorySeparator(host.getCommonSourceDirectory()))) === -1) { + return undefined; + } return getResolvedExternalModuleName(host, file); } ts.getExternalModuleNameFromDeclaration = getExternalModuleNameFromDeclaration; @@ -17227,8 +17617,8 @@ var ts; return !(options.noEmitForJsFiles && isSourceFileJS(sourceFile)) && !sourceFile.isDeclarationFile && !host.isSourceFileFromExternalLibrary(sourceFile) && - !(isJsonSourceFile(sourceFile) && host.getResolvedProjectReferenceToRedirect(sourceFile.fileName)) && - (forceDtsEmit || !host.isSourceOfProjectReferenceRedirect(sourceFile.fileName)); + (forceDtsEmit || (!(isJsonSourceFile(sourceFile) && host.getResolvedProjectReferenceToRedirect(sourceFile.fileName)) && + !host.isSourceOfProjectReferenceRedirect(sourceFile.fileName))); } ts.sourceFileMayBeEmitted = sourceFileMayBeEmitted; function getSourceFilePathInNewDir(fileName, host, newDirPath) { @@ -17308,11 +17698,11 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return !!node && node.kind === 78 /* Identifier */ && identifierIsThisKeyword(node); + return !!node && node.kind === 79 /* Identifier */ && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 107 /* ThisKeyword */; + return id.originalKeywordKind === 108 /* ThisKeyword */; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -17323,10 +17713,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 167 /* GetAccessor */) { + if (accessor.kind === 169 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 168 /* SetAccessor */) { + else if (accessor.kind === 170 /* SetAccessor */) { setAccessor = accessor; } else { @@ -17346,10 +17736,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 167 /* GetAccessor */ && !getAccessor) { + if (member.kind === 169 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 168 /* SetAccessor */ && !setAccessor) { + if (member.kind === 170 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -17398,7 +17788,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 === 311 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 314 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -17574,7 +17964,7 @@ var ts; ts.writeCommentRange = writeCommentRange; function writeTrimmedCurrentLine(text, commentEnd, writer, newLine, pos, nextLineStart) { var end = Math.min(commentEnd, nextLineStart - 1); - var currentLineText = text.substring(pos, end).replace(/^\s+|\s+$/g, ""); + var currentLineText = ts.trimString(text.substring(pos, end)); if (currentLineText) { // trimmed forward and ending spaces text writer.writeComment(currentLineText); @@ -17621,6 +18011,18 @@ var ts; return hasSyntacticModifier(node, 32 /* Static */); } ts.hasStaticModifier = hasStaticModifier; + function hasOverrideModifier(node) { + return hasEffectiveModifier(node, 16384 /* Override */); + } + ts.hasOverrideModifier = hasOverrideModifier; + function hasAbstractModifier(node) { + return hasSyntacticModifier(node, 128 /* Abstract */); + } + ts.hasAbstractModifier = hasAbstractModifier; + function hasAmbientModifier(node) { + return hasSyntacticModifier(node, 2 /* Ambient */); + } + ts.hasAmbientModifier = hasAmbientModifier; function hasEffectiveReadonlyModifier(node) { return hasEffectiveModifier(node, 64 /* Readonly */); } @@ -17634,7 +18036,7 @@ var ts; } ts.getSelectedSyntacticModifierFlags = getSelectedSyntacticModifierFlags; function getModifierFlagsWorker(node, includeJSDoc, alwaysIncludeJSDoc) { - if (node.kind >= 0 /* FirstToken */ && node.kind <= 156 /* LastToken */) { + if (node.kind >= 0 /* FirstToken */ && node.kind <= 158 /* LastToken */) { return 0 /* None */; } if (!(node.modifierFlagsCache & 536870912 /* HasComputedFlags */)) { @@ -17679,6 +18081,8 @@ var ts; flags |= 16 /* Protected */; if (ts.getJSDocReadonlyTagNoCache(node)) flags |= 64 /* Readonly */; + if (ts.getJSDocOverrideTagNoCache(node)) + flags |= 16384 /* Override */; } if (ts.getJSDocDeprecatedTagNoCache(node)) flags |= 8192 /* Deprecated */; @@ -17701,7 +18105,7 @@ var ts; */ function getSyntacticModifierFlagsNoCache(node) { var flags = modifiersToFlags(node.modifiers); - if (node.flags & 4 /* NestedNamespace */ || (node.kind === 78 /* Identifier */ && node.isInJSDocNamespace)) { + if (node.flags & 4 /* NestedNamespace */ || (node.kind === 79 /* Identifier */ && node.isInJSDocNamespace)) { flags |= 1 /* Export */; } return flags; @@ -17720,21 +18124,26 @@ var ts; ts.modifiersToFlags = modifiersToFlags; function modifierToFlag(token) { switch (token) { - case 123 /* StaticKeyword */: return 32 /* Static */; - case 122 /* PublicKeyword */: return 4 /* Public */; - case 121 /* ProtectedKeyword */: return 16 /* Protected */; - case 120 /* PrivateKeyword */: return 8 /* Private */; - case 125 /* AbstractKeyword */: return 128 /* Abstract */; - case 92 /* ExportKeyword */: return 1 /* Export */; - case 133 /* DeclareKeyword */: return 2 /* Ambient */; - case 84 /* ConstKeyword */: return 2048 /* Const */; - case 87 /* DefaultKeyword */: return 512 /* Default */; - case 129 /* AsyncKeyword */: return 256 /* Async */; - case 142 /* ReadonlyKeyword */: return 64 /* Readonly */; + 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 134 /* DeclareKeyword */: return 2 /* Ambient */; + case 85 /* ConstKeyword */: return 2048 /* Const */; + case 88 /* DefaultKeyword */: return 512 /* Default */; + case 130 /* AsyncKeyword */: return 256 /* Async */; + case 143 /* ReadonlyKeyword */: return 64 /* Readonly */; + case 157 /* OverrideKeyword */: return 16384 /* Override */; } return 0 /* None */; } ts.modifierToFlag = modifierToFlag; + function createModifiers(modifierFlags) { + return modifierFlags ? ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(modifierFlags)) : undefined; + } + ts.createModifiers = createModifiers; function isLogicalOperator(token) { return token === 56 /* BarBarToken */ || token === 55 /* AmpersandAmpersandToken */ @@ -17742,9 +18151,9 @@ var ts; } ts.isLogicalOperator = isLogicalOperator; function isLogicalOrCoalescingAssignmentOperator(token) { - return token === 74 /* BarBarEqualsToken */ - || token === 75 /* AmpersandAmpersandEqualsToken */ - || token === 76 /* QuestionQuestionEqualsToken */; + return token === 75 /* BarBarEqualsToken */ + || token === 76 /* AmpersandAmpersandEqualsToken */ + || token === 77 /* QuestionQuestionEqualsToken */; } ts.isLogicalOrCoalescingAssignmentOperator = isLogicalOrCoalescingAssignmentOperator; function isLogicalOrCoalescingAssignmentExpression(expr) { @@ -17752,7 +18161,7 @@ var ts; } ts.isLogicalOrCoalescingAssignmentExpression = isLogicalOrCoalescingAssignmentExpression; function isAssignmentOperator(token) { - return token >= 62 /* FirstAssignment */ && token <= 77 /* LastAssignment */; + return token >= 63 /* FirstAssignment */ && token <= 78 /* LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ @@ -17765,23 +18174,27 @@ var ts; return ts.isExpressionWithTypeArguments(node) && ts.isHeritageClause(node.parent) && ts.isClassLike(node.parent.parent) - ? { class: node.parent.parent, isImplements: node.parent.token === 116 /* ImplementsKeyword */ } + ? { class: node.parent.parent, isImplements: node.parent.token === 117 /* ImplementsKeyword */ } : undefined; } ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments = tryGetClassImplementingOrExtendingExpressionWithTypeArguments; function isAssignmentExpression(node, excludeCompoundAssignment) { return ts.isBinaryExpression(node) && (excludeCompoundAssignment - ? node.operatorToken.kind === 62 /* EqualsToken */ + ? node.operatorToken.kind === 63 /* EqualsToken */ : isAssignmentOperator(node.operatorToken.kind)) && ts.isLeftHandSideExpression(node.left); } ts.isAssignmentExpression = isAssignmentExpression; + function isLeftHandSideOfAssignment(node) { + return isAssignmentExpression(node.parent) && node.parent.left === node; + } + ts.isLeftHandSideOfAssignment = isLeftHandSideOfAssignment; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 200 /* ObjectLiteralExpression */ - || kind === 199 /* ArrayLiteralExpression */; + return kind === 202 /* ObjectLiteralExpression */ + || kind === 201 /* ArrayLiteralExpression */; } return false; } @@ -17791,30 +18204,33 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { - return node.kind === 78 /* Identifier */ || isPropertyAccessEntityNameExpression(node); + return node.kind === 79 /* Identifier */ || isPropertyAccessEntityNameExpression(node); } ts.isEntityNameExpression = isEntityNameExpression; function getFirstIdentifier(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return node; - case 157 /* QualifiedName */: + case 159 /* QualifiedName */: do { node = node.left; - } while (node.kind !== 78 /* Identifier */); + } while (node.kind !== 79 /* Identifier */); return node; - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: do { node = node.expression; - } while (node.kind !== 78 /* Identifier */); + } while (node.kind !== 79 /* Identifier */); return node; } } ts.getFirstIdentifier = getFirstIdentifier; function isDottedName(node) { - return node.kind === 78 /* Identifier */ || node.kind === 107 /* ThisKeyword */ || node.kind === 105 /* SuperKeyword */ || - node.kind === 201 /* PropertyAccessExpression */ && isDottedName(node.expression) || - node.kind === 207 /* ParenthesizedExpression */ && isDottedName(node.expression); + return node.kind === 79 /* Identifier */ + || node.kind === 108 /* ThisKeyword */ + || node.kind === 106 /* SuperKeyword */ + || node.kind === 228 /* MetaProperty */ + || node.kind === 203 /* PropertyAccessExpression */ && isDottedName(node.expression) + || node.kind === 209 /* ParenthesizedExpression */ && isDottedName(node.expression); } ts.isDottedName = isDottedName; function isPropertyAccessEntityNameExpression(node) { @@ -17828,6 +18244,12 @@ var ts; return baseStr + "." + entityNameToString(expr.name); } } + else if (ts.isElementAccessExpression(expr)) { + var baseStr = tryGetPropertyAccessOrIdentifierToString(expr.expression); + if (baseStr !== undefined && ts.isPropertyName(expr.argumentExpression)) { + return baseStr + "." + getPropertyNameForPropertyNameNode(expr.argumentExpression); + } + } else if (ts.isIdentifier(expr)) { return ts.unescapeLeadingUnderscores(expr.escapedText); } @@ -17839,22 +18261,28 @@ var ts; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 157 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 201 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 159 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 203 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; + function isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName(node) { + return ts.isQualifiedName(node.parent) && node.parent.right === node + || ts.isPropertyAccessExpression(node.parent) && node.parent.name === node + || ts.isJSDocMemberName(node.parent) && node.parent.right === node; + } + ts.isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName = isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName; function isEmptyObjectLiteral(expression) { - return expression.kind === 200 /* ObjectLiteralExpression */ && + return expression.kind === 202 /* ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 199 /* ArrayLiteralExpression */ && + return expression.kind === 201 /* ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; function getLocalSymbolForExportDefault(symbol) { - if (!isExportDefaultSymbol(symbol)) + if (!isExportDefaultSymbol(symbol) || !symbol.declarations) return undefined; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; @@ -18181,8 +18609,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 255 /* EnumDeclaration */: - case 256 /* ModuleDeclaration */: + case 257 /* EnumDeclaration */: + case 258 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -18209,9 +18637,11 @@ var ts; return symbol.flags & 33554432 /* Transient */ ? symbol.checkFlags : 0; } ts.getCheckFlags = getCheckFlags; - function getDeclarationModifierFlagsFromSymbol(s) { + function getDeclarationModifierFlagsFromSymbol(s, isWrite) { + if (isWrite === void 0) { isWrite = false; } if (s.valueDeclaration) { - var flags = ts.getCombinedModifierFlags(s.valueDeclaration); + var declaration = (isWrite && s.declarations && ts.find(s.declarations, function (d) { return d.kind === 170 /* SetAccessor */; })) || s.valueDeclaration; + var flags = ts.getCombinedModifierFlags(declaration); return s.parent && s.parent.flags & 32 /* Class */ ? flags : flags & ~28 /* AccessibilityModifier */; } if (getCheckFlags(s) & 6 /* Synthetic */) { @@ -18259,35 +18689,35 @@ var ts; if (!parent) return 0 /* Read */; switch (parent.kind) { - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return accessKind(parent); - case 215 /* PostfixUnaryExpression */: - case 214 /* PrefixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: var operator = parent.operator; return operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? - operatorToken.kind === 62 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() + operatorToken.kind === 63 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() : 0 /* Read */; - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return parent.name !== node ? 0 /* Read */ : accessKind(parent); - case 288 /* PropertyAssignment */: { + case 290 /* 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 289 /* ShorthandPropertyAssignment */: + case 291 /* 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 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return accessKind(parent); default: return 0 /* 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 && skipParenthesesUp(parent.parent).kind === 233 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && walkUpParenthesizedExpressions(parent.parent).kind === 235 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; } } function reverseAccessKind(a) { @@ -18375,7 +18805,8 @@ var ts; } ts.isAbstractConstructorSymbol = isAbstractConstructorSymbol; function getClassLikeDeclarationOfSymbol(symbol) { - return ts.find(symbol.declarations, ts.isClassLike); + var _a; + return (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isClassLike); } ts.getClassLikeDeclarationOfSymbol = getClassLikeDeclarationOfSymbol; function getObjectFlags(type) { @@ -18418,7 +18849,6 @@ var ts; ts.getLastChild = getLastChild; function addToSeen(seen, key, value) { if (value === void 0) { value = true; } - key = String(key); if (seen.has(key)) { return false; } @@ -18431,37 +18861,37 @@ var ts; } ts.isObjectTypeDeclaration = isObjectTypeDeclaration; function isTypeNodeKind(kind) { - return (kind >= 172 /* FirstTypeNode */ && kind <= 195 /* LastTypeNode */) - || kind === 128 /* AnyKeyword */ - || kind === 152 /* UnknownKeyword */ - || kind === 144 /* NumberKeyword */ - || kind === 155 /* BigIntKeyword */ - || kind === 145 /* ObjectKeyword */ - || kind === 131 /* BooleanKeyword */ - || kind === 147 /* StringKeyword */ - || kind === 148 /* SymbolKeyword */ - || kind === 113 /* VoidKeyword */ - || kind === 150 /* UndefinedKeyword */ - || kind === 141 /* NeverKeyword */ - || kind === 223 /* ExpressionWithTypeArguments */ - || kind === 303 /* JSDocAllType */ - || kind === 304 /* JSDocUnknownType */ - || kind === 305 /* JSDocNullableType */ - || kind === 306 /* JSDocNonNullableType */ - || kind === 307 /* JSDocOptionalType */ - || kind === 308 /* JSDocFunctionType */ - || kind === 309 /* JSDocVariadicType */; + return (kind >= 174 /* FirstTypeNode */ && kind <= 197 /* LastTypeNode */) + || kind === 129 /* AnyKeyword */ + || kind === 153 /* UnknownKeyword */ + || kind === 145 /* NumberKeyword */ + || kind === 156 /* BigIntKeyword */ + || kind === 146 /* ObjectKeyword */ + || kind === 132 /* BooleanKeyword */ + || kind === 148 /* StringKeyword */ + || kind === 149 /* SymbolKeyword */ + || kind === 114 /* VoidKeyword */ + || kind === 151 /* UndefinedKeyword */ + || kind === 142 /* NeverKeyword */ + || kind === 225 /* ExpressionWithTypeArguments */ + || kind === 306 /* JSDocAllType */ + || kind === 307 /* JSDocUnknownType */ + || kind === 308 /* JSDocNullableType */ + || kind === 309 /* JSDocNonNullableType */ + || kind === 310 /* JSDocOptionalType */ + || kind === 311 /* JSDocFunctionType */ + || kind === 312 /* JSDocVariadicType */; } ts.isTypeNodeKind = isTypeNodeKind; function isAccessExpression(node) { - return node.kind === 201 /* PropertyAccessExpression */ || node.kind === 202 /* ElementAccessExpression */; + return node.kind === 203 /* PropertyAccessExpression */ || node.kind === 204 /* ElementAccessExpression */; } ts.isAccessExpression = isAccessExpression; function getNameOfAccessExpression(node) { - if (node.kind === 201 /* PropertyAccessExpression */) { + if (node.kind === 203 /* PropertyAccessExpression */) { return node.name; } - ts.Debug.assert(node.kind === 202 /* ElementAccessExpression */); + ts.Debug.assert(node.kind === 204 /* ElementAccessExpression */); return node.argumentExpression; } ts.getNameOfAccessExpression = getNameOfAccessExpression; @@ -18476,7 +18906,7 @@ var ts; } ts.isBundleFileTextLike = isBundleFileTextLike; function isNamedImportsOrExports(node) { - return node.kind === 264 /* NamedImports */ || node.kind === 268 /* NamedExports */; + return node.kind === 266 /* NamedImports */ || node.kind === 270 /* NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function getLeftmostAccessExpression(expr) { @@ -18489,28 +18919,28 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: node = node.operand; continue; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: node = node.left; continue; - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: node = node.condition; continue; - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: node = node.tag; continue; - case 203 /* CallExpression */: + case 205 /* CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 224 /* AsExpression */: - case 202 /* ElementAccessExpression */: - case 201 /* PropertyAccessExpression */: - case 225 /* NonNullExpression */: - case 336 /* PartiallyEmittedExpression */: + case 226 /* AsExpression */: + case 204 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 227 /* NonNullExpression */: + case 344 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -18529,7 +18959,7 @@ var ts; } function Type(checker, flags) { this.flags = flags; - if (ts.Debug.isDebugging || ts.tracing.isTracing()) { + if (ts.Debug.isDebugging || ts.tracing) { this.checker = checker; } } @@ -18873,6 +19303,10 @@ var ts; return !!(compilerOptions.declaration || compilerOptions.composite); } ts.getEmitDeclarations = getEmitDeclarations; + function shouldPreserveConstEnums(compilerOptions) { + return !!(compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); + } + ts.shouldPreserveConstEnums = shouldPreserveConstEnums; function isIncrementalCompilation(options) { return !!(options.incremental || options.composite); } @@ -18885,14 +19319,16 @@ var ts; return compilerOptions.allowJs === undefined ? !!compilerOptions.checkJs : compilerOptions.allowJs; } ts.getAllowJSCompilerOption = getAllowJSCompilerOption; + function getUseDefineForClassFields(compilerOptions) { + return compilerOptions.useDefineForClassFields === undefined ? compilerOptions.target === 99 /* ESNext */ : compilerOptions.useDefineForClassFields; + } + ts.getUseDefineForClassFields = getUseDefineForClassFields; function compilerOptionsAffectSemanticDiagnostics(newOptions, oldOptions) { - return oldOptions !== newOptions && - ts.semanticDiagnosticsOptionDeclarations.some(function (option) { return !isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); }); + return optionsHaveChanges(oldOptions, newOptions, ts.semanticDiagnosticsOptionDeclarations); } ts.compilerOptionsAffectSemanticDiagnostics = compilerOptionsAffectSemanticDiagnostics; function compilerOptionsAffectEmit(newOptions, oldOptions) { - return oldOptions !== newOptions && - ts.affectsEmitOptionDeclarations.some(function (option) { return !isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); }); + return optionsHaveChanges(oldOptions, newOptions, ts.affectsEmitOptionDeclarations); } ts.compilerOptionsAffectEmit = compilerOptionsAffectEmit; function getCompilerOptionValue(options, option) { @@ -18906,7 +19342,7 @@ var ts; 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[0] : jsxImportSourcePragmas; + var jsxImportSourcePragma = ts.isArray(jsxImportSourcePragmas) ? jsxImportSourcePragmas[jsxImportSourcePragmas.length - 1] : jsxImportSourcePragmas; return compilerOptions.jsx === 4 /* ReactJSX */ || compilerOptions.jsx === 5 /* ReactJSXDev */ || compilerOptions.jsxImportSource || @@ -18935,37 +19371,65 @@ var ts; return true; } ts.hasZeroOrOneAsteriskCharacter = hasZeroOrOneAsteriskCharacter; - function createSymlinkCache() { + function createSymlinkCache(cwd, getCanonicalFileName) { var symlinkedDirectories; + var symlinkedDirectoriesByRealpath; var symlinkedFiles; return { getSymlinkedFiles: function () { return symlinkedFiles; }, getSymlinkedDirectories: function () { return symlinkedDirectories; }, + getSymlinkedDirectoriesByRealpath: function () { return symlinkedDirectoriesByRealpath; }, setSymlinkedFile: function (path, real) { return (symlinkedFiles || (symlinkedFiles = new ts.Map())).set(path, real); }, - setSymlinkedDirectory: function (path, directory) { return (symlinkedDirectories || (symlinkedDirectories = new ts.Map())).set(path, directory); }, + setSymlinkedDirectory: function (symlink, real) { + // Large, interconnected dependency graphs in pnpm will have a huge number of symlinks + // where both the realpath and the symlink path are inside node_modules/.pnpm. Since + // this path is never a candidate for a module specifier, we can ignore it entirely. + var symlinkPath = ts.toPath(symlink, cwd, getCanonicalFileName); + if (!containsIgnoredPath(symlinkPath)) { + symlinkPath = ts.ensureTrailingDirectorySeparator(symlinkPath); + if (real !== false && !(symlinkedDirectories === null || symlinkedDirectories === void 0 ? void 0 : symlinkedDirectories.has(symlinkPath))) { + (symlinkedDirectoriesByRealpath || (symlinkedDirectoriesByRealpath = ts.createMultiMap())).add(ts.ensureTrailingDirectorySeparator(real.realPath), symlink); + } + (symlinkedDirectories || (symlinkedDirectories = new ts.Map())).set(symlinkPath, real); + } + }, + setSymlinkedDirectoryFromSymlinkedFile: function (symlink, real) { + this.setSymlinkedFile(ts.toPath(symlink, cwd, getCanonicalFileName), real); + var _a = guessDirectorySymlink(real, symlink, cwd, getCanonicalFileName) || ts.emptyArray, commonResolved = _a[0], commonOriginal = _a[1]; + if (commonResolved && commonOriginal) { + this.setSymlinkedDirectory(commonOriginal, { + real: commonResolved, + realPath: ts.toPath(commonResolved, cwd, getCanonicalFileName), + }); + } + }, }; } ts.createSymlinkCache = createSymlinkCache; function discoverProbableSymlinks(files, getCanonicalFileName, cwd) { - var cache = createSymlinkCache(); - var symlinks = ts.flatten(ts.mapDefined(files, function (sf) { - return sf.resolvedModules && ts.compact(ts.arrayFrom(ts.mapIterator(sf.resolvedModules.values(), function (res) { - return res && res.originalPath && res.resolvedFileName !== res.originalPath ? [res.resolvedFileName, res.originalPath] : undefined; + var cache = createSymlinkCache(cwd, getCanonicalFileName); + var symlinks = ts.flatMap(files, function (sf) { + var pairs = sf.resolvedModules && ts.arrayFrom(ts.mapDefinedIterator(sf.resolvedModules.values(), function (res) { + return (res === null || res === void 0 ? void 0 : res.originalPath) ? [res.resolvedFileName, res.originalPath] : undefined; + })); + return ts.concatenate(pairs, sf.resolvedTypeReferenceDirectiveNames && ts.arrayFrom(ts.mapDefinedIterator(sf.resolvedTypeReferenceDirectiveNames.values(), function (res) { + return (res === null || res === void 0 ? void 0 : res.originalPath) && res.resolvedFileName ? [res.resolvedFileName, res.originalPath] : undefined; }))); - })); + }); for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) { var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1]; + cache.setSymlinkedFile(ts.toPath(originalPath, cwd, getCanonicalFileName), resolvedPath); var _b = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName) || ts.emptyArray, commonResolved = _b[0], commonOriginal = _b[1]; if (commonResolved && commonOriginal) { - cache.setSymlinkedDirectory(ts.toPath(commonOriginal, cwd, getCanonicalFileName), { real: commonResolved, realPath: ts.toPath(commonResolved, cwd, getCanonicalFileName) }); + cache.setSymlinkedDirectory(commonOriginal, { real: commonResolved, realPath: ts.toPath(commonResolved, cwd, getCanonicalFileName) }); } } return cache; } ts.discoverProbableSymlinks = discoverProbableSymlinks; function guessDirectorySymlink(a, b, cwd, getCanonicalFileName) { - var aParts = ts.getPathComponents(ts.toPath(a, cwd, getCanonicalFileName)); - var bParts = ts.getPathComponents(ts.toPath(b, cwd, getCanonicalFileName)); + var aParts = ts.getPathComponents(ts.getNormalizedAbsolutePath(a, cwd)); + var bParts = ts.getPathComponents(ts.getNormalizedAbsolutePath(b, cwd)); var isDirectory = false; while (!isNodeModulesOrScopedPackageDirectory(aParts[aParts.length - 2], getCanonicalFileName) && !isNodeModulesOrScopedPackageDirectory(bParts[bParts.length - 2], getCanonicalFileName) && @@ -19349,6 +19813,14 @@ var ts; return false; } ts.isSupportedSourceFileName = isSupportedSourceFileName; + function numberOfDirectorySeparators(str) { + var match = str.match(/\//g); + return match ? match.length : 0; + } + function compareNumberOfDirectorySeparators(path1, path2) { + return ts.compareValues(numberOfDirectorySeparators(path1), numberOfDirectorySeparators(path2)); + } + ts.compareNumberOfDirectorySeparators = compareNumberOfDirectorySeparators; /** * Extension boundaries by priority. Lower numbers indicate higher priorities, and are * aligned to the offset of the highest priority extension in the @@ -19423,16 +19895,27 @@ var ts; return ts.changeAnyExtension(path, newExtension, extensionsToRemove, /*ignoreCase*/ false); } ts.changeExtension = changeExtension; + /** + * Returns the input if there are no stars, a pattern if there is exactly one, + * and undefined if there are more. + */ function tryParsePattern(pattern) { - // This should be verified outside of here and a proper error thrown. - ts.Debug.assert(hasZeroOrOneAsteriskCharacter(pattern)); var indexOfStar = pattern.indexOf("*"); - return indexOfStar === -1 ? undefined : { - prefix: pattern.substr(0, indexOfStar), - suffix: pattern.substr(indexOfStar + 1) - }; + if (indexOfStar === -1) { + return pattern; + } + return pattern.indexOf("*", indexOfStar + 1) !== -1 + ? undefined + : { + prefix: pattern.substr(0, indexOfStar), + suffix: pattern.substr(indexOfStar + 1) + }; } ts.tryParsePattern = tryParsePattern; + function tryParsePatterns(paths) { + return ts.mapDefined(ts.getOwnKeys(paths), function (path) { return tryParsePattern(path); }); + } + ts.tryParsePatterns = tryParsePatterns; function positionIsSynthesized(pos) { // This is a fast way of testing the following conditions: // pos === undefined || pos === null || isNaN(pos) || pos < 0; @@ -19474,23 +19957,19 @@ var ts; directories: ts.emptyArray }; /** - * patternStrings contains both pattern strings (containing "*") and regular strings. + * patternOrStrings contains both patterns (containing "*") and regular strings. * Return an exact match if possible, or a pattern match, or undefined. * (These are verified by verifyCompilerOptions to have 0 or 1 "*" characters.) */ - function matchPatternOrExact(patternStrings, candidate) { + function matchPatternOrExact(patternOrStrings, candidate) { var patterns = []; - for (var _i = 0, patternStrings_1 = patternStrings; _i < patternStrings_1.length; _i++) { - var patternString = patternStrings_1[_i]; - if (!hasZeroOrOneAsteriskCharacter(patternString)) - continue; - var pattern = tryParsePattern(patternString); - if (pattern) { - patterns.push(pattern); + for (var _i = 0, patternOrStrings_1 = patternOrStrings; _i < patternOrStrings_1.length; _i++) { + var patternOrString = patternOrStrings_1[_i]; + if (patternOrString === candidate) { + return candidate; } - else if (patternString === candidate) { - // pattern was matched as is - no need to search further - return patternString; + if (!ts.isString(patternOrString)) { + patterns.push(patternOrString); } } return ts.findBestPatternMatch(patterns, function (_) { return _; }, candidate); @@ -19645,38 +20124,38 @@ var ts; } ts.isValidTypeOnlyAliasUseSite = isValidTypeOnlyAliasUseSite; function typeOnlyDeclarationIsExport(typeOnlyDeclaration) { - return typeOnlyDeclaration.kind === 270 /* ExportSpecifier */; + return typeOnlyDeclaration.kind === 272 /* ExportSpecifier */; } ts.typeOnlyDeclarationIsExport = typeOnlyDeclarationIsExport; function isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(node) { - while (node.kind === 78 /* Identifier */ || node.kind === 201 /* PropertyAccessExpression */) { + while (node.kind === 79 /* Identifier */ || node.kind === 203 /* PropertyAccessExpression */) { node = node.parent; } - if (node.kind !== 158 /* ComputedPropertyName */) { + if (node.kind !== 160 /* ComputedPropertyName */) { return false; } if (hasSyntacticModifier(node.parent, 128 /* Abstract */)) { return true; } var containerKind = node.parent.parent.kind; - return containerKind === 253 /* InterfaceDeclaration */ || containerKind === 177 /* TypeLiteral */; + return containerKind === 255 /* InterfaceDeclaration */ || containerKind === 179 /* 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 !== 78 /* Identifier */) + if (node.kind !== 79 /* Identifier */) return false; var heritageClause = ts.findAncestor(node.parent, function (parent) { switch (parent.kind) { - case 286 /* HeritageClause */: + case 288 /* HeritageClause */: return true; - case 201 /* PropertyAccessExpression */: - case 223 /* ExpressionWithTypeArguments */: + case 203 /* PropertyAccessExpression */: + case 225 /* ExpressionWithTypeArguments */: return false; default: return "quit"; } }); - return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 116 /* ImplementsKeyword */ || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 253 /* InterfaceDeclaration */; + return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 117 /* ImplementsKeyword */ || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 255 /* InterfaceDeclaration */; } function isIdentifierTypeReference(node) { return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName); @@ -19829,6 +20308,76 @@ var ts; } } ts.expressionResultIsUnused = expressionResultIsUnused; + function containsIgnoredPath(path) { + return ts.some(ts.ignoredPaths, function (p) { return ts.stringContains(path, p); }); + } + ts.containsIgnoredPath = containsIgnoredPath; + function getContainingNodeArray(node) { + if (!node.parent) + return undefined; + switch (node.kind) { + case 161 /* TypeParameter */: + var parent_1 = node.parent; + return parent_1.kind === 187 /* InferType */ ? undefined : parent_1.typeParameters; + case 162 /* Parameter */: + return node.parent.parameters; + case 196 /* TemplateLiteralTypeSpan */: + return node.parent.templateSpans; + case 230 /* TemplateSpan */: + return node.parent.templateSpans; + case 163 /* Decorator */: + return node.parent.decorators; + case 288 /* HeritageClause */: + return node.parent.heritageClauses; + } + var parent = node.parent; + if (ts.isJSDocTag(node)) { + return ts.isJSDocTypeLiteral(node.parent) ? undefined : node.parent.tags; + } + switch (parent.kind) { + case 179 /* TypeLiteral */: + case 255 /* InterfaceDeclaration */: + return ts.isTypeElement(node) ? parent.members : undefined; + case 184 /* UnionType */: + case 185 /* IntersectionType */: + return parent.types; + case 181 /* TupleType */: + case 201 /* ArrayLiteralExpression */: + case 345 /* CommaListExpression */: + case 266 /* NamedImports */: + case 270 /* NamedExports */: + return parent.elements; + case 202 /* ObjectLiteralExpression */: + case 283 /* JsxAttributes */: + return parent.properties; + case 205 /* CallExpression */: + case 206 /* NewExpression */: + return ts.isTypeNode(node) ? parent.typeArguments : + parent.expression === node ? undefined : + parent.arguments; + case 275 /* JsxElement */: + case 279 /* JsxFragment */: + return ts.isJsxChild(node) ? parent.children : undefined; + case 277 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: + return ts.isTypeNode(node) ? parent.typeArguments : undefined; + case 232 /* Block */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: + case 259 /* ModuleBlock */: + return parent.statements; + case 260 /* CaseBlock */: + return parent.clauses; + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + return ts.isClassElement(node) ? parent.members : undefined; + case 257 /* EnumDeclaration */: + return ts.isEnumMember(node) ? parent.members : undefined; + case 299 /* SourceFile */: + return parent.statements; + } + } + ts.getContainingNodeArray = getContainingNodeArray; })(ts || (ts = {})); /* @internal */ var ts; @@ -19873,7 +20422,11 @@ var ts; var ts; (function (ts) { function createParenthesizerRules(factory) { + var binaryLeftOperandParenthesizerCache; + var binaryRightOperandParenthesizerCache; return { + getParenthesizeLeftSideOfBinaryForOperator: getParenthesizeLeftSideOfBinaryForOperator, + getParenthesizeRightSideOfBinaryForOperator: getParenthesizeRightSideOfBinaryForOperator, parenthesizeLeftSideOfBinary: parenthesizeLeftSideOfBinary, parenthesizeRightSideOfBinary: parenthesizeRightSideOfBinary, parenthesizeExpressionOfComputedPropertyName: parenthesizeExpressionOfComputedPropertyName, @@ -19894,6 +20447,24 @@ var ts; parenthesizeConstituentTypesOfUnionOrIntersectionType: parenthesizeConstituentTypesOfUnionOrIntersectionType, parenthesizeTypeArguments: parenthesizeTypeArguments, }; + function getParenthesizeLeftSideOfBinaryForOperator(operatorKind) { + binaryLeftOperandParenthesizerCache || (binaryLeftOperandParenthesizerCache = new ts.Map()); + var parenthesizerRule = binaryLeftOperandParenthesizerCache.get(operatorKind); + if (!parenthesizerRule) { + parenthesizerRule = function (node) { return parenthesizeLeftSideOfBinary(operatorKind, node); }; + binaryLeftOperandParenthesizerCache.set(operatorKind, parenthesizerRule); + } + return parenthesizerRule; + } + function getParenthesizeRightSideOfBinaryForOperator(operatorKind) { + binaryRightOperandParenthesizerCache || (binaryRightOperandParenthesizerCache = new ts.Map()); + var parenthesizerRule = binaryRightOperandParenthesizerCache.get(operatorKind); + if (!parenthesizerRule) { + parenthesizerRule = function (node) { return parenthesizeRightSideOfBinary(operatorKind, /*leftSide*/ undefined, node); }; + binaryRightOperandParenthesizerCache.set(operatorKind, parenthesizerRule); + } + return parenthesizerRule; + } /** * Determines whether the operand to a BinaryExpression needs to be parenthesized. * @@ -19920,10 +20491,10 @@ 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(216 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(216 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(218 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(218 /* BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); - if (!isLeftSideOfBinary && operand.kind === 209 /* ArrowFunction */ && binaryOperatorPrecedence > 3 /* Assignment */) { + if (!isLeftSideOfBinary && operand.kind === 211 /* ArrowFunction */ && binaryOperatorPrecedence > 3 /* Assignment */) { // We need to parenthesize arrow functions on the right side to avoid it being // parsed as parenthesized expression: `a && (() => {})` return true; @@ -19935,7 +20506,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 219 /* YieldExpression */) { + && operand.kind === 221 /* YieldExpression */) { return false; } return true; @@ -20023,7 +20594,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 216 /* BinaryExpression */ && node.operatorToken.kind === 39 /* PlusToken */) { + if (node.kind === 218 /* BinaryExpression */ && node.operatorToken.kind === 39 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -20049,7 +20620,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 === 207 /* ParenthesizedExpression */) { + if (skipped.kind === 209 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -20066,7 +20637,7 @@ var ts; return ts.isCommaSequence(expression) ? factory.createParenthesizedExpression(expression) : expression; } function parenthesizeConditionOfConditionalExpression(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(217 /* ConditionalExpression */, 57 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(219 /* ConditionalExpression */, 57 /* QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) !== 1 /* GreaterThan */) { @@ -20099,8 +20670,8 @@ var ts; var needsParens = ts.isCommaSequence(check); if (!needsParens) { switch (ts.getLeftmostExpression(check, /*stopAtCallExpression*/ false).kind) { - case 221 /* ClassExpression */: - case 208 /* FunctionExpression */: + case 223 /* ClassExpression */: + case 210 /* FunctionExpression */: needsParens = true; } } @@ -20113,9 +20684,9 @@ var ts; function parenthesizeExpressionOfNew(expression) { var leftmostExpr = ts.getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 203 /* CallExpression */: + case 205 /* CallExpression */: return factory.createParenthesizedExpression(expression); - case 204 /* NewExpression */: + case 206 /* NewExpression */: return !leftmostExpr.arguments ? factory.createParenthesizedExpression(expression) : expression; // TODO(rbuckton): Verify this assertion holds @@ -20135,7 +20706,7 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 204 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 206 /* NewExpression */ || emittedExpression.arguments)) { // TODO(rbuckton): Verify whether this assertion holds. return expression; } @@ -20157,7 +20728,7 @@ var ts; function parenthesizeExpressionForDisallowedComma(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(216 /* BinaryExpression */, 27 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(218 /* BinaryExpression */, 27 /* CommaToken */); // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(factory.createParenthesizedExpression(expression), expression); } @@ -20166,44 +20737,44 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 208 /* FunctionExpression */ || kind === 209 /* ArrowFunction */) { + if (kind === 210 /* FunctionExpression */ || kind === 211 /* 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 */); } } var leftmostExpressionKind = ts.getLeftmostExpression(emittedExpression, /*stopAtCallExpressions*/ false).kind; - if (leftmostExpressionKind === 200 /* ObjectLiteralExpression */ || leftmostExpressionKind === 208 /* FunctionExpression */) { + if (leftmostExpressionKind === 202 /* ObjectLiteralExpression */ || leftmostExpressionKind === 210 /* 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 === 200 /* ObjectLiteralExpression */)) { + if (!ts.isBlock(body) && (ts.isCommaSequence(body) || ts.getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 202 /* ObjectLiteralExpression */)) { // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return ts.setTextRange(factory.createParenthesizedExpression(body), body); } return body; } function parenthesizeMemberOfConditionalType(member) { - return member.kind === 184 /* ConditionalType */ ? factory.createParenthesizedType(member) : member; + return member.kind === 186 /* ConditionalType */ ? factory.createParenthesizedType(member) : member; } function parenthesizeMemberOfElementType(member) { switch (member.kind) { - case 182 /* UnionType */: - case 183 /* IntersectionType */: - case 174 /* FunctionType */: - case 175 /* ConstructorType */: + case 184 /* UnionType */: + case 185 /* IntersectionType */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: return factory.createParenthesizedType(member); } return parenthesizeMemberOfConditionalType(member); } function parenthesizeElementTypeOfArrayType(member) { switch (member.kind) { - case 176 /* TypeQuery */: - case 188 /* TypeOperator */: - case 185 /* InferType */: + case 178 /* TypeQuery */: + case 190 /* TypeOperator */: + case 187 /* InferType */: return factory.createParenthesizedType(member); } return parenthesizeMemberOfElementType(member); @@ -20222,6 +20793,8 @@ var ts; } ts.createParenthesizerRules = createParenthesizerRules; ts.nullParenthesizerRules = { + getParenthesizeLeftSideOfBinaryForOperator: function (_) { return ts.identity; }, + getParenthesizeRightSideOfBinaryForOperator: function (_) { return ts.identity; }, parenthesizeLeftSideOfBinary: function (_binaryOperator, leftSide) { return leftSide; }, parenthesizeRightSideOfBinary: function (_binaryOperator, _leftSide, rightSide) { return rightSide; }, parenthesizeExpressionOfComputedPropertyName: ts.identity, @@ -20307,11 +20880,11 @@ var ts; } function convertToAssignmentPattern(node) { switch (node.kind) { - case 197 /* ArrayBindingPattern */: - case 199 /* ArrayLiteralExpression */: + case 199 /* ArrayBindingPattern */: + case 201 /* ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 196 /* ObjectBindingPattern */: - case 200 /* ObjectLiteralExpression */: + case 198 /* ObjectBindingPattern */: + case 202 /* ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -20652,18 +21225,18 @@ var ts; createExternalModuleReference: createExternalModuleReference, updateExternalModuleReference: updateExternalModuleReference, // lazily load factory members for JSDoc types with similar structure - get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(303 /* JSDocAllType */); }, - get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(304 /* JSDocUnknownType */); }, - get createJSDocNonNullableType() { return getJSDocUnaryTypeCreateFunction(306 /* JSDocNonNullableType */); }, - get updateJSDocNonNullableType() { return getJSDocUnaryTypeUpdateFunction(306 /* JSDocNonNullableType */); }, - get createJSDocNullableType() { return getJSDocUnaryTypeCreateFunction(305 /* JSDocNullableType */); }, - get updateJSDocNullableType() { return getJSDocUnaryTypeUpdateFunction(305 /* JSDocNullableType */); }, - get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(307 /* JSDocOptionalType */); }, - get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(307 /* JSDocOptionalType */); }, - get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(309 /* JSDocVariadicType */); }, - get updateJSDocVariadicType() { return getJSDocUnaryTypeUpdateFunction(309 /* JSDocVariadicType */); }, - get createJSDocNamepathType() { return getJSDocUnaryTypeCreateFunction(310 /* JSDocNamepathType */); }, - get updateJSDocNamepathType() { return getJSDocUnaryTypeUpdateFunction(310 /* JSDocNamepathType */); }, + get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(306 /* JSDocAllType */); }, + get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(307 /* JSDocUnknownType */); }, + get createJSDocNonNullableType() { return getJSDocUnaryTypeCreateFunction(309 /* JSDocNonNullableType */); }, + get updateJSDocNonNullableType() { return getJSDocUnaryTypeUpdateFunction(309 /* JSDocNonNullableType */); }, + get createJSDocNullableType() { return getJSDocUnaryTypeCreateFunction(308 /* JSDocNullableType */); }, + get updateJSDocNullableType() { return getJSDocUnaryTypeUpdateFunction(308 /* JSDocNullableType */); }, + get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(310 /* JSDocOptionalType */); }, + get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(310 /* JSDocOptionalType */); }, + get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(312 /* JSDocVariadicType */); }, + get updateJSDocVariadicType() { return getJSDocUnaryTypeUpdateFunction(312 /* JSDocVariadicType */); }, + get createJSDocNamepathType() { return getJSDocUnaryTypeCreateFunction(313 /* JSDocNamepathType */); }, + get updateJSDocNamepathType() { return getJSDocUnaryTypeUpdateFunction(313 /* JSDocNamepathType */); }, createJSDocFunctionType: createJSDocFunctionType, updateJSDocFunctionType: updateJSDocFunctionType, createJSDocTypeLiteral: createJSDocTypeLiteral, @@ -20690,31 +21263,43 @@ var ts; updateJSDocSeeTag: updateJSDocSeeTag, createJSDocNameReference: createJSDocNameReference, updateJSDocNameReference: updateJSDocNameReference, + createJSDocMemberName: createJSDocMemberName, + updateJSDocMemberName: updateJSDocMemberName, + createJSDocLink: createJSDocLink, + updateJSDocLink: updateJSDocLink, + createJSDocLinkCode: createJSDocLinkCode, + updateJSDocLinkCode: updateJSDocLinkCode, + createJSDocLinkPlain: createJSDocLinkPlain, + updateJSDocLinkPlain: updateJSDocLinkPlain, // lazily load factory members for JSDoc tags with similar structure - get createJSDocTypeTag() { return getJSDocTypeLikeTagCreateFunction(329 /* JSDocTypeTag */); }, - get updateJSDocTypeTag() { return getJSDocTypeLikeTagUpdateFunction(329 /* JSDocTypeTag */); }, - get createJSDocReturnTag() { return getJSDocTypeLikeTagCreateFunction(327 /* JSDocReturnTag */); }, - get updateJSDocReturnTag() { return getJSDocTypeLikeTagUpdateFunction(327 /* JSDocReturnTag */); }, - get createJSDocThisTag() { return getJSDocTypeLikeTagCreateFunction(328 /* JSDocThisTag */); }, - get updateJSDocThisTag() { return getJSDocTypeLikeTagUpdateFunction(328 /* JSDocThisTag */); }, - get createJSDocEnumTag() { return getJSDocTypeLikeTagCreateFunction(325 /* JSDocEnumTag */); }, - get updateJSDocEnumTag() { return getJSDocTypeLikeTagUpdateFunction(325 /* JSDocEnumTag */); }, - get createJSDocAuthorTag() { return getJSDocSimpleTagCreateFunction(317 /* JSDocAuthorTag */); }, - get updateJSDocAuthorTag() { return getJSDocSimpleTagUpdateFunction(317 /* JSDocAuthorTag */); }, - get createJSDocClassTag() { return getJSDocSimpleTagCreateFunction(319 /* JSDocClassTag */); }, - get updateJSDocClassTag() { return getJSDocSimpleTagUpdateFunction(319 /* JSDocClassTag */); }, - get createJSDocPublicTag() { return getJSDocSimpleTagCreateFunction(320 /* JSDocPublicTag */); }, - get updateJSDocPublicTag() { return getJSDocSimpleTagUpdateFunction(320 /* JSDocPublicTag */); }, - get createJSDocPrivateTag() { return getJSDocSimpleTagCreateFunction(321 /* JSDocPrivateTag */); }, - get updateJSDocPrivateTag() { return getJSDocSimpleTagUpdateFunction(321 /* JSDocPrivateTag */); }, - get createJSDocProtectedTag() { return getJSDocSimpleTagCreateFunction(322 /* JSDocProtectedTag */); }, - get updateJSDocProtectedTag() { return getJSDocSimpleTagUpdateFunction(322 /* JSDocProtectedTag */); }, - get createJSDocReadonlyTag() { return getJSDocSimpleTagCreateFunction(323 /* JSDocReadonlyTag */); }, - get updateJSDocReadonlyTag() { return getJSDocSimpleTagUpdateFunction(323 /* JSDocReadonlyTag */); }, - get createJSDocDeprecatedTag() { return getJSDocSimpleTagCreateFunction(318 /* JSDocDeprecatedTag */); }, - get updateJSDocDeprecatedTag() { return getJSDocSimpleTagUpdateFunction(318 /* JSDocDeprecatedTag */); }, + get createJSDocTypeTag() { return getJSDocTypeLikeTagCreateFunction(337 /* JSDocTypeTag */); }, + get updateJSDocTypeTag() { return getJSDocTypeLikeTagUpdateFunction(337 /* JSDocTypeTag */); }, + get createJSDocReturnTag() { return getJSDocTypeLikeTagCreateFunction(335 /* JSDocReturnTag */); }, + get updateJSDocReturnTag() { return getJSDocTypeLikeTagUpdateFunction(335 /* JSDocReturnTag */); }, + get createJSDocThisTag() { return getJSDocTypeLikeTagCreateFunction(336 /* JSDocThisTag */); }, + get updateJSDocThisTag() { return getJSDocTypeLikeTagUpdateFunction(336 /* JSDocThisTag */); }, + get createJSDocEnumTag() { return getJSDocTypeLikeTagCreateFunction(333 /* JSDocEnumTag */); }, + get updateJSDocEnumTag() { return getJSDocTypeLikeTagUpdateFunction(333 /* JSDocEnumTag */); }, + get createJSDocAuthorTag() { return getJSDocSimpleTagCreateFunction(324 /* JSDocAuthorTag */); }, + get updateJSDocAuthorTag() { return getJSDocSimpleTagUpdateFunction(324 /* JSDocAuthorTag */); }, + get createJSDocClassTag() { return getJSDocSimpleTagCreateFunction(326 /* JSDocClassTag */); }, + get updateJSDocClassTag() { return getJSDocSimpleTagUpdateFunction(326 /* JSDocClassTag */); }, + get createJSDocPublicTag() { return getJSDocSimpleTagCreateFunction(327 /* JSDocPublicTag */); }, + get updateJSDocPublicTag() { return getJSDocSimpleTagUpdateFunction(327 /* JSDocPublicTag */); }, + get createJSDocPrivateTag() { return getJSDocSimpleTagCreateFunction(328 /* JSDocPrivateTag */); }, + get updateJSDocPrivateTag() { return getJSDocSimpleTagUpdateFunction(328 /* JSDocPrivateTag */); }, + get createJSDocProtectedTag() { return getJSDocSimpleTagCreateFunction(329 /* JSDocProtectedTag */); }, + get updateJSDocProtectedTag() { return getJSDocSimpleTagUpdateFunction(329 /* JSDocProtectedTag */); }, + get createJSDocReadonlyTag() { return getJSDocSimpleTagCreateFunction(330 /* JSDocReadonlyTag */); }, + get updateJSDocReadonlyTag() { return getJSDocSimpleTagUpdateFunction(330 /* JSDocReadonlyTag */); }, + get createJSDocOverrideTag() { return getJSDocSimpleTagCreateFunction(331 /* JSDocOverrideTag */); }, + get updateJSDocOverrideTag() { return getJSDocSimpleTagUpdateFunction(331 /* JSDocOverrideTag */); }, + get createJSDocDeprecatedTag() { return getJSDocSimpleTagCreateFunction(325 /* JSDocDeprecatedTag */); }, + get updateJSDocDeprecatedTag() { return getJSDocSimpleTagUpdateFunction(325 /* JSDocDeprecatedTag */); }, createJSDocUnknownTag: createJSDocUnknownTag, updateJSDocUnknownTag: updateJSDocUnknownTag, + createJSDocText: createJSDocText, + updateJSDocText: updateJSDocText, createJSDocComment: createJSDocComment, updateJSDocComment: updateJSDocComment, createJsxElement: createJsxElement, @@ -20779,7 +21364,7 @@ var ts; cloneNode: cloneNode, // Lazily load factory methods for common operator factories and utilities get createComma() { return getBinaryCreateFunction(27 /* CommaToken */); }, - get createAssignment() { return getBinaryCreateFunction(62 /* EqualsToken */); }, + get createAssignment() { return getBinaryCreateFunction(63 /* EqualsToken */); }, get createLogicalOr() { return getBinaryCreateFunction(56 /* BarBarToken */); }, get createLogicalAnd() { return getBinaryCreateFunction(55 /* AmpersandAmpersandToken */); }, get createBitwiseOr() { return getBinaryCreateFunction(51 /* BarToken */); }, @@ -20898,11 +21483,11 @@ var ts; // don't propagate child flags. if (name) { switch (node.kind) { - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 163 /* PropertyDeclaration */: - case 288 /* PropertyAssignment */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 290 /* PropertyAssignment */: if (ts.isIdentifier(name)) { node.transformFlags |= propagateIdentifierNameFlags(name); break; @@ -20943,7 +21528,7 @@ var ts; function createBaseFunctionLikeDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type, body) { var node = createBaseSignatureDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type); node.body = body; - node.transformFlags |= propagateChildFlags(node.body) & ~8388608 /* ContainsPossibleTopLevelAwait */; + node.transformFlags |= propagateChildFlags(node.body) & ~16777216 /* ContainsPossibleTopLevelAwait */; if (!body) node.transformFlags |= 1 /* ContainsTypeScript */; return node; @@ -20996,7 +21581,7 @@ var ts; var node = createBaseLiteral(8 /* NumericLiteral */, typeof value === "number" ? value + "" : value); node.numericLiteralFlags = numericLiteralFlags; if (numericLiteralFlags & 384 /* BinaryOrOctalSpecifier */) - node.transformFlags |= 256 /* ContainsES2015 */; + node.transformFlags |= 512 /* ContainsES2015 */; return node; } // @api @@ -21015,7 +21600,7 @@ var ts; var node = createBaseStringLiteral(text, isSingleQuote); node.hasExtendedUnicodeEscape = hasExtendedUnicodeEscape; if (hasExtendedUnicodeEscape) - node.transformFlags |= 256 /* ContainsES2015 */; + node.transformFlags |= 512 /* ContainsES2015 */; return node; } // @api @@ -21048,10 +21633,10 @@ var ts; if (originalKeywordKind === undefined && text) { originalKeywordKind = ts.stringToToken(text); } - if (originalKeywordKind === 78 /* Identifier */) { + if (originalKeywordKind === 79 /* Identifier */) { originalKeywordKind = undefined; } - var node = baseFactory.createBaseIdentifierNode(78 /* Identifier */); + var node = baseFactory.createBaseIdentifierNode(79 /* Identifier */); node.originalKeywordKind = originalKeywordKind; node.escapedText = ts.escapeLeadingUnderscores(text); return node; @@ -21070,8 +21655,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 === 130 /* AwaitKeyword */) { - node.transformFlags |= 8388608 /* ContainsPossibleTopLevelAwait */; + if (node.originalKeywordKind === 131 /* AwaitKeyword */) { + node.transformFlags |= 16777216 /* ContainsPossibleTopLevelAwait */; } return node; } @@ -21094,8 +21679,11 @@ var ts; } /** Create a unique temporary variable for use in a loop. */ // @api - function createLoopVariable() { - return createBaseGeneratedIdentifier("", 2 /* Loop */); + function createLoopVariable(reservedInNestedScopes) { + var flags = 2 /* Loop */; + if (reservedInNestedScopes) + flags |= 8 /* ReservedInNestedScopes */; + return createBaseGeneratedIdentifier("", flags); } /** Create a unique name based on the supplied text. */ // @api @@ -21118,9 +21706,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(79 /* PrivateIdentifier */); + var node = baseFactory.createBasePrivateIdentifierNode(80 /* PrivateIdentifier */); node.escapedText = ts.escapeLeadingUnderscores(text); - node.transformFlags |= 4194304 /* ContainsClassFields */; + node.transformFlags |= 8388608 /* ContainsClassFields */; return node; } // @@ -21130,46 +21718,47 @@ var ts; return baseFactory.createBaseTokenNode(kind); } function createToken(token) { - ts.Debug.assert(token >= 0 /* FirstToken */ && token <= 156 /* LastToken */, "Invalid token"); + ts.Debug.assert(token >= 0 /* FirstToken */ && token <= 158 /* 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 !== 78 /* Identifier */, "Invalid token. Use 'createIdentifier' to create identifiers"); + ts.Debug.assert(token !== 79 /* Identifier */, "Invalid token. Use 'createIdentifier' to create identifiers"); var node = createBaseToken(token); var transformFlags = 0 /* None */; switch (token) { - case 129 /* AsyncKeyword */: + case 130 /* AsyncKeyword */: // 'async' modifier is ES2017 (async functions) or ES2018 (async generators) transformFlags = - 64 /* ContainsES2017 */ | - 32 /* ContainsES2018 */; + 128 /* ContainsES2017 */ | + 64 /* ContainsES2018 */; break; - case 122 /* PublicKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 142 /* ReadonlyKeyword */: - case 125 /* AbstractKeyword */: - case 133 /* DeclareKeyword */: - case 84 /* ConstKeyword */: - case 128 /* AnyKeyword */: - case 144 /* NumberKeyword */: - case 155 /* BigIntKeyword */: - case 141 /* NeverKeyword */: - case 145 /* ObjectKeyword */: - case 147 /* StringKeyword */: - case 131 /* BooleanKeyword */: - case 148 /* SymbolKeyword */: - case 113 /* VoidKeyword */: - case 152 /* UnknownKeyword */: - case 150 /* UndefinedKeyword */: // `undefined` is an Identifier in the expression case. + case 123 /* PublicKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + case 143 /* ReadonlyKeyword */: + case 126 /* AbstractKeyword */: + case 134 /* DeclareKeyword */: + case 85 /* ConstKeyword */: + case 129 /* AnyKeyword */: + case 145 /* NumberKeyword */: + case 156 /* BigIntKeyword */: + case 142 /* NeverKeyword */: + case 146 /* ObjectKeyword */: + case 157 /* OverrideKeyword */: + case 148 /* StringKeyword */: + case 132 /* BooleanKeyword */: + case 149 /* SymbolKeyword */: + case 114 /* VoidKeyword */: + case 153 /* UnknownKeyword */: + case 151 /* UndefinedKeyword */: // `undefined` is an Identifier in the expression case. transformFlags = 1 /* ContainsTypeScript */; break; - case 123 /* StaticKeyword */: - case 105 /* SuperKeyword */: - transformFlags = 256 /* ContainsES2015 */; + case 124 /* StaticKeyword */: + case 106 /* SuperKeyword */: + transformFlags = 512 /* ContainsES2015 */; break; - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: // 'this' indicates a lexical 'this' - transformFlags = 4096 /* ContainsLexicalThis */; + transformFlags = 8192 /* ContainsLexicalThis */; break; } if (transformFlags) { @@ -21182,23 +21771,23 @@ var ts; // // @api function createSuper() { - return createToken(105 /* SuperKeyword */); + return createToken(106 /* SuperKeyword */); } // @api function createThis() { - return createToken(107 /* ThisKeyword */); + return createToken(108 /* ThisKeyword */); } // @api function createNull() { - return createToken(103 /* NullKeyword */); + return createToken(104 /* NullKeyword */); } // @api function createTrue() { - return createToken(109 /* TrueKeyword */); + return createToken(110 /* TrueKeyword */); } // @api function createFalse() { - return createToken(94 /* FalseKeyword */); + return createToken(95 /* FalseKeyword */); } // // Modifiers @@ -21211,37 +21800,40 @@ var ts; function createModifiersFromModifierFlags(flags) { var result = []; if (flags & 1 /* Export */) { - result.push(createModifier(92 /* ExportKeyword */)); + result.push(createModifier(93 /* ExportKeyword */)); } if (flags & 2 /* Ambient */) { - result.push(createModifier(133 /* DeclareKeyword */)); + result.push(createModifier(134 /* DeclareKeyword */)); } if (flags & 512 /* Default */) { - result.push(createModifier(87 /* DefaultKeyword */)); + result.push(createModifier(88 /* DefaultKeyword */)); } if (flags & 2048 /* Const */) { - result.push(createModifier(84 /* ConstKeyword */)); + result.push(createModifier(85 /* ConstKeyword */)); } if (flags & 4 /* Public */) { - result.push(createModifier(122 /* PublicKeyword */)); + result.push(createModifier(123 /* PublicKeyword */)); } if (flags & 8 /* Private */) { - result.push(createModifier(120 /* PrivateKeyword */)); + result.push(createModifier(121 /* PrivateKeyword */)); } if (flags & 16 /* Protected */) { - result.push(createModifier(121 /* ProtectedKeyword */)); + result.push(createModifier(122 /* ProtectedKeyword */)); } if (flags & 128 /* Abstract */) { - result.push(createModifier(125 /* AbstractKeyword */)); + result.push(createModifier(126 /* AbstractKeyword */)); } if (flags & 32 /* Static */) { - result.push(createModifier(123 /* StaticKeyword */)); + result.push(createModifier(124 /* StaticKeyword */)); + } + if (flags & 16384 /* Override */) { + result.push(createModifier(157 /* OverrideKeyword */)); } if (flags & 64 /* Readonly */) { - result.push(createModifier(142 /* ReadonlyKeyword */)); + result.push(createModifier(143 /* ReadonlyKeyword */)); } if (flags & 256 /* Async */) { - result.push(createModifier(129 /* AsyncKeyword */)); + result.push(createModifier(130 /* AsyncKeyword */)); } return result; } @@ -21250,7 +21842,7 @@ var ts; // // @api function createQualifiedName(left, right) { - var node = createBaseNode(157 /* QualifiedName */); + var node = createBaseNode(159 /* QualifiedName */); node.left = left; node.right = asName(right); node.transformFlags |= @@ -21267,12 +21859,12 @@ var ts; } // @api function createComputedPropertyName(expression) { - var node = createBaseNode(158 /* ComputedPropertyName */); + var node = createBaseNode(160 /* ComputedPropertyName */); node.expression = parenthesizerRules().parenthesizeExpressionOfComputedPropertyName(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 256 /* ContainsES2015 */ | - 32768 /* ContainsComputedPropertyName */; + 512 /* ContainsES2015 */ | + 65536 /* ContainsComputedPropertyName */; return node; } // @api @@ -21286,7 +21878,7 @@ var ts; // // @api function createTypeParameterDeclaration(name, constraint, defaultType) { - var node = createBaseNamedDeclaration(159 /* TypeParameter */, + var node = createBaseNamedDeclaration(161 /* TypeParameter */, /*decorators*/ undefined, /*modifiers*/ undefined, name); node.constraint = constraint; @@ -21304,7 +21896,7 @@ var ts; } // @api function createParameterDeclaration(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(160 /* Parameter */, decorators, modifiers, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); + var node = createBaseVariableLikeDeclaration(162 /* Parameter */, decorators, modifiers, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.dotDotDotToken = dotDotDotToken; node.questionToken = questionToken; if (ts.isThisIdentifier(node.name)) { @@ -21316,10 +21908,10 @@ var ts; propagateChildFlags(node.questionToken); if (questionToken) node.transformFlags |= 1 /* ContainsTypeScript */; - if (ts.modifiersToFlags(node.modifiers) & 92 /* ParameterPropertyModifier */) - node.transformFlags |= 2048 /* ContainsTypeScriptClassSyntax */; + if (ts.modifiersToFlags(node.modifiers) & 16476 /* ParameterPropertyModifier */) + node.transformFlags |= 4096 /* ContainsTypeScriptClassSyntax */; if (initializer || dotDotDotToken) - node.transformFlags |= 256 /* ContainsES2015 */; + node.transformFlags |= 512 /* ContainsES2015 */; } return node; } @@ -21337,12 +21929,12 @@ var ts; } // @api function createDecorator(expression) { - var node = createBaseNode(161 /* Decorator */); + var node = createBaseNode(163 /* Decorator */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= propagateChildFlags(node.expression) | 1 /* ContainsTypeScript */ | - 2048 /* ContainsTypeScriptClassSyntax */; + 4096 /* ContainsTypeScriptClassSyntax */; return node; } // @api @@ -21356,7 +21948,7 @@ var ts; // // @api function createPropertySignature(modifiers, name, questionToken, type) { - var node = createBaseNamedDeclaration(162 /* PropertySignature */, + var node = createBaseNamedDeclaration(164 /* PropertySignature */, /*decorators*/ undefined, modifiers, name); node.type = type; node.questionToken = questionToken; @@ -21374,15 +21966,15 @@ var ts; } // @api function createPropertyDeclaration(decorators, modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(163 /* PropertyDeclaration */, decorators, modifiers, name, type, initializer); + var node = createBaseVariableLikeDeclaration(165 /* PropertyDeclaration */, decorators, 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) | - 4194304 /* ContainsClassFields */; + 8388608 /* ContainsClassFields */; if (ts.isComputedPropertyName(node.name) || (ts.hasStaticModifier(node) && node.initializer)) { - node.transformFlags |= 2048 /* ContainsTypeScriptClassSyntax */; + node.transformFlags |= 4096 /* ContainsTypeScriptClassSyntax */; } if (questionOrExclamationToken || ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { node.transformFlags |= 1 /* ContainsTypeScript */; @@ -21403,7 +21995,7 @@ var ts; } // @api function createMethodSignature(modifiers, name, questionToken, typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(164 /* MethodSignature */, + var node = createBaseSignatureDeclaration(166 /* MethodSignature */, /*decorators*/ undefined, modifiers, name, typeParameters, parameters, type); node.questionToken = questionToken; node.transformFlags = 1 /* ContainsTypeScript */; @@ -21422,26 +22014,26 @@ var ts; } // @api function createMethodDeclaration(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(165 /* MethodDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(167 /* MethodDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; node.questionToken = questionToken; node.transformFlags |= propagateChildFlags(node.asteriskToken) | propagateChildFlags(node.questionToken) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; if (questionToken) { node.transformFlags |= 1 /* ContainsTypeScript */; } if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { if (asteriskToken) { - node.transformFlags |= 32 /* ContainsES2018 */; + node.transformFlags |= 64 /* ContainsES2018 */; } else { - node.transformFlags |= 64 /* ContainsES2017 */; + node.transformFlags |= 128 /* ContainsES2017 */; } } else if (asteriskToken) { - node.transformFlags |= 512 /* ContainsGenerator */; + node.transformFlags |= 1024 /* ContainsGenerator */; } return node; } @@ -21461,11 +22053,11 @@ var ts; } // @api function createConstructorDeclaration(decorators, modifiers, parameters, body) { - var node = createBaseFunctionLikeDeclaration(166 /* Constructor */, decorators, modifiers, + var node = createBaseFunctionLikeDeclaration(168 /* Constructor */, decorators, modifiers, /*name*/ undefined, /*typeParameters*/ undefined, parameters, /*type*/ undefined, body); - node.transformFlags |= 256 /* ContainsES2015 */; + node.transformFlags |= 512 /* ContainsES2015 */; return node; } // @api @@ -21479,7 +22071,7 @@ var ts; } // @api function createGetAccessorDeclaration(decorators, modifiers, name, parameters, type, body) { - return createBaseFunctionLikeDeclaration(167 /* GetAccessor */, decorators, modifiers, name, + return createBaseFunctionLikeDeclaration(169 /* GetAccessor */, decorators, modifiers, name, /*typeParameters*/ undefined, parameters, type, body); } // @api @@ -21495,7 +22087,7 @@ var ts; } // @api function createSetAccessorDeclaration(decorators, modifiers, name, parameters, body) { - return createBaseFunctionLikeDeclaration(168 /* SetAccessor */, decorators, modifiers, name, + return createBaseFunctionLikeDeclaration(170 /* SetAccessor */, decorators, modifiers, name, /*typeParameters*/ undefined, parameters, /*type*/ undefined, body); } @@ -21511,7 +22103,7 @@ var ts; } // @api function createCallSignature(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(169 /* CallSignature */, + var node = createBaseSignatureDeclaration(171 /* CallSignature */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); @@ -21528,7 +22120,7 @@ var ts; } // @api function createConstructSignature(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(170 /* ConstructSignature */, + var node = createBaseSignatureDeclaration(172 /* ConstructSignature */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); @@ -21545,7 +22137,7 @@ var ts; } // @api function createIndexSignature(decorators, modifiers, parameters, type) { - var node = createBaseSignatureDeclaration(171 /* IndexSignature */, decorators, modifiers, + var node = createBaseSignatureDeclaration(173 /* IndexSignature */, decorators, modifiers, /*name*/ undefined, /*typeParameters*/ undefined, parameters, type); node.transformFlags = 1 /* ContainsTypeScript */; @@ -21562,7 +22154,7 @@ var ts; } // @api function createTemplateLiteralTypeSpan(type, literal) { - var node = createBaseNode(194 /* TemplateLiteralTypeSpan */); + var node = createBaseNode(196 /* TemplateLiteralTypeSpan */); node.type = type; node.literal = literal; node.transformFlags = 1 /* ContainsTypeScript */; @@ -21584,7 +22176,7 @@ var ts; } // @api function createTypePredicateNode(assertsModifier, parameterName, type) { - var node = createBaseNode(172 /* TypePredicate */); + var node = createBaseNode(174 /* TypePredicate */); node.assertsModifier = assertsModifier; node.parameterName = asName(parameterName); node.type = type; @@ -21601,7 +22193,7 @@ var ts; } // @api function createTypeReferenceNode(typeName, typeArguments) { - var node = createBaseNode(173 /* TypeReference */); + var node = createBaseNode(175 /* TypeReference */); node.typeName = asName(typeName); node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(createNodeArray(typeArguments)); node.transformFlags = 1 /* ContainsTypeScript */; @@ -21616,7 +22208,7 @@ var ts; } // @api function createFunctionTypeNode(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(174 /* FunctionType */, + var node = createBaseSignatureDeclaration(176 /* FunctionType */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); @@ -21642,7 +22234,7 @@ var ts; ts.Debug.fail("Incorrect number of arguments specified."); } function createConstructorTypeNode1(modifiers, typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(175 /* ConstructorType */, + var node = createBaseSignatureDeclaration(177 /* ConstructorType */, /*decorators*/ undefined, modifiers, /*name*/ undefined, typeParameters, parameters, type); node.transformFlags = 1 /* ContainsTypeScript */; @@ -21676,7 +22268,7 @@ var ts; } // @api function createTypeQueryNode(exprName) { - var node = createBaseNode(176 /* TypeQuery */); + var node = createBaseNode(178 /* TypeQuery */); node.exprName = exprName; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -21689,7 +22281,7 @@ var ts; } // @api function createTypeLiteralNode(members) { - var node = createBaseNode(177 /* TypeLiteral */); + var node = createBaseNode(179 /* TypeLiteral */); node.members = createNodeArray(members); node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -21702,7 +22294,7 @@ var ts; } // @api function createArrayTypeNode(elementType) { - var node = createBaseNode(178 /* ArrayType */); + var node = createBaseNode(180 /* ArrayType */); node.elementType = parenthesizerRules().parenthesizeElementTypeOfArrayType(elementType); node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -21715,7 +22307,7 @@ var ts; } // @api function createTupleTypeNode(elements) { - var node = createBaseNode(179 /* TupleType */); + var node = createBaseNode(181 /* TupleType */); node.elements = createNodeArray(elements); node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -21728,7 +22320,7 @@ var ts; } // @api function createNamedTupleMember(dotDotDotToken, name, questionToken, type) { - var node = createBaseNode(192 /* NamedTupleMember */); + var node = createBaseNode(194 /* NamedTupleMember */); node.dotDotDotToken = dotDotDotToken; node.name = name; node.questionToken = questionToken; @@ -21747,7 +22339,7 @@ var ts; } // @api function createOptionalTypeNode(type) { - var node = createBaseNode(180 /* OptionalType */); + var node = createBaseNode(182 /* OptionalType */); node.type = parenthesizerRules().parenthesizeElementTypeOfArrayType(type); node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -21760,7 +22352,7 @@ var ts; } // @api function createRestTypeNode(type) { - var node = createBaseNode(181 /* RestType */); + var node = createBaseNode(183 /* RestType */); node.type = type; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -21784,7 +22376,7 @@ var ts; } // @api function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(182 /* UnionType */, types); + return createUnionOrIntersectionTypeNode(184 /* UnionType */, types); } // @api function updateUnionTypeNode(node, types) { @@ -21792,7 +22384,7 @@ var ts; } // @api function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(183 /* IntersectionType */, types); + return createUnionOrIntersectionTypeNode(185 /* IntersectionType */, types); } // @api function updateIntersectionTypeNode(node, types) { @@ -21800,7 +22392,7 @@ var ts; } // @api function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createBaseNode(184 /* ConditionalType */); + var node = createBaseNode(186 /* ConditionalType */); node.checkType = parenthesizerRules().parenthesizeMemberOfConditionalType(checkType); node.extendsType = parenthesizerRules().parenthesizeMemberOfConditionalType(extendsType); node.trueType = trueType; @@ -21819,7 +22411,7 @@ var ts; } // @api function createInferTypeNode(typeParameter) { - var node = createBaseNode(185 /* InferType */); + var node = createBaseNode(187 /* InferType */); node.typeParameter = typeParameter; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -21832,7 +22424,7 @@ var ts; } // @api function createTemplateLiteralType(head, templateSpans) { - var node = createBaseNode(193 /* TemplateLiteralType */); + var node = createBaseNode(195 /* TemplateLiteralType */); node.head = head; node.templateSpans = createNodeArray(templateSpans); node.transformFlags = 1 /* ContainsTypeScript */; @@ -21848,7 +22440,7 @@ var ts; // @api function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { if (isTypeOf === void 0) { isTypeOf = false; } - var node = createBaseNode(195 /* ImportType */); + var node = createBaseNode(197 /* ImportType */); node.argument = argument; node.qualifier = qualifier; node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); @@ -21868,7 +22460,7 @@ var ts; } // @api function createParenthesizedType(type) { - var node = createBaseNode(186 /* ParenthesizedType */); + var node = createBaseNode(188 /* ParenthesizedType */); node.type = type; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -21881,13 +22473,13 @@ var ts; } // @api function createThisTypeNode() { - var node = createBaseNode(187 /* ThisType */); + var node = createBaseNode(189 /* ThisType */); node.transformFlags = 1 /* ContainsTypeScript */; return node; } // @api function createTypeOperatorNode(operator, type) { - var node = createBaseNode(188 /* TypeOperator */); + var node = createBaseNode(190 /* TypeOperator */); node.operator = operator; node.type = parenthesizerRules().parenthesizeMemberOfElementType(type); node.transformFlags = 1 /* ContainsTypeScript */; @@ -21901,7 +22493,7 @@ var ts; } // @api function createIndexedAccessTypeNode(objectType, indexType) { - var node = createBaseNode(189 /* IndexedAccessType */); + var node = createBaseNode(191 /* IndexedAccessType */); node.objectType = parenthesizerRules().parenthesizeMemberOfElementType(objectType); node.indexType = indexType; node.transformFlags = 1 /* ContainsTypeScript */; @@ -21916,7 +22508,7 @@ var ts; } // @api function createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type) { - var node = createBaseNode(190 /* MappedType */); + var node = createBaseNode(192 /* MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.nameType = nameType; @@ -21937,7 +22529,7 @@ var ts; } // @api function createLiteralTypeNode(literal) { - var node = createBaseNode(191 /* LiteralType */); + var node = createBaseNode(193 /* LiteralType */); node.literal = literal; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -21953,16 +22545,16 @@ var ts; // // @api function createObjectBindingPattern(elements) { - var node = createBaseNode(196 /* ObjectBindingPattern */); + var node = createBaseNode(198 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements) | - 256 /* ContainsES2015 */ | - 131072 /* ContainsBindingPattern */; - if (node.transformFlags & 8192 /* ContainsRestOrSpread */) { + 512 /* ContainsES2015 */ | + 262144 /* ContainsBindingPattern */; + if (node.transformFlags & 16384 /* ContainsRestOrSpread */) { node.transformFlags |= - 32 /* ContainsES2018 */ | - 16384 /* ContainsObjectRestOrSpread */; + 64 /* ContainsES2018 */ | + 32768 /* ContainsObjectRestOrSpread */; } return node; } @@ -21974,12 +22566,12 @@ var ts; } // @api function createArrayBindingPattern(elements) { - var node = createBaseNode(197 /* ArrayBindingPattern */); + var node = createBaseNode(199 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements) | - 256 /* ContainsES2015 */ | - 131072 /* ContainsBindingPattern */; + 512 /* ContainsES2015 */ | + 262144 /* ContainsBindingPattern */; return node; } // @api @@ -21990,21 +22582,21 @@ var ts; } // @api function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createBaseBindingLikeDeclaration(198 /* BindingElement */, + var node = createBaseBindingLikeDeclaration(200 /* BindingElement */, /*decorators*/ undefined, - /*modifiers*/ undefined, name, initializer); + /*modifiers*/ undefined, name, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.propertyName = asName(propertyName); node.dotDotDotToken = dotDotDotToken; node.transformFlags |= propagateChildFlags(node.dotDotDotToken) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; if (node.propertyName) { node.transformFlags |= ts.isIdentifier(node.propertyName) ? propagateIdentifierNameFlags(node.propertyName) : propagateChildFlags(node.propertyName); } if (dotDotDotToken) - node.transformFlags |= 8192 /* ContainsRestOrSpread */; + node.transformFlags |= 16384 /* ContainsRestOrSpread */; return node; } // @api @@ -22026,7 +22618,7 @@ var ts; } // @api function createArrayLiteralExpression(elements, multiLine) { - var node = createBaseExpression(199 /* ArrayLiteralExpression */); + var node = createBaseExpression(201 /* ArrayLiteralExpression */); node.elements = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(elements)); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.elements); @@ -22040,7 +22632,7 @@ var ts; } // @api function createObjectLiteralExpression(properties, multiLine) { - var node = createBaseExpression(200 /* ObjectLiteralExpression */); + var node = createBaseExpression(202 /* ObjectLiteralExpression */); node.properties = createNodeArray(properties); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.properties); @@ -22054,7 +22646,7 @@ var ts; } // @api function createPropertyAccessExpression(expression, name) { - var node = createBaseExpression(201 /* PropertyAccessExpression */); + var node = createBaseExpression(203 /* PropertyAccessExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.name = asName(name); node.transformFlags = @@ -22066,8 +22658,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 |= - 64 /* ContainsES2017 */ | - 32 /* ContainsES2018 */; + 128 /* ContainsES2017 */ | + 64 /* ContainsES2018 */; } return node; } @@ -22083,13 +22675,13 @@ var ts; } // @api function createPropertyAccessChain(expression, questionDotToken, name) { - var node = createBaseExpression(201 /* PropertyAccessExpression */); + var node = createBaseExpression(203 /* PropertyAccessExpression */); node.flags |= 32 /* OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.questionDotToken = questionDotToken; node.name = asName(name); node.transformFlags |= - 8 /* ContainsES2020 */ | + 16 /* ContainsES2020 */ | propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | (ts.isIdentifier(node.name) ? @@ -22110,7 +22702,7 @@ var ts; } // @api function createElementAccessExpression(expression, index) { - var node = createBaseExpression(202 /* ElementAccessExpression */); + var node = createBaseExpression(204 /* ElementAccessExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.argumentExpression = asExpression(index); node.transformFlags |= @@ -22120,8 +22712,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 |= - 64 /* ContainsES2017 */ | - 32 /* ContainsES2018 */; + 128 /* ContainsES2017 */ | + 64 /* ContainsES2018 */; } return node; } @@ -22137,7 +22729,7 @@ var ts; } // @api function createElementAccessChain(expression, questionDotToken, index) { - var node = createBaseExpression(202 /* ElementAccessExpression */); + var node = createBaseExpression(204 /* ElementAccessExpression */); node.flags |= 32 /* OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.questionDotToken = questionDotToken; @@ -22146,7 +22738,7 @@ var ts; propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | propagateChildFlags(node.argumentExpression) | - 8 /* ContainsES2020 */; + 16 /* ContainsES2020 */; return node; } // @api @@ -22162,7 +22754,7 @@ var ts; } // @api function createCallExpression(expression, typeArguments, argumentsArray) { - var node = createBaseExpression(203 /* CallExpression */); + var node = createBaseExpression(205 /* CallExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray)); @@ -22174,10 +22766,10 @@ var ts; node.transformFlags |= 1 /* ContainsTypeScript */; } if (ts.isImportKeyword(node.expression)) { - node.transformFlags |= 2097152 /* ContainsDynamicImport */; + node.transformFlags |= 4194304 /* ContainsDynamicImport */; } else if (ts.isSuperProperty(node.expression)) { - node.transformFlags |= 4096 /* ContainsLexicalThis */; + node.transformFlags |= 8192 /* ContainsLexicalThis */; } return node; } @@ -22194,7 +22786,7 @@ var ts; } // @api function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) { - var node = createBaseExpression(203 /* CallExpression */); + var node = createBaseExpression(205 /* CallExpression */); node.flags |= 32 /* OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.questionDotToken = questionDotToken; @@ -22205,12 +22797,12 @@ var ts; propagateChildFlags(node.questionDotToken) | propagateChildrenFlags(node.typeArguments) | propagateChildrenFlags(node.arguments) | - 8 /* ContainsES2020 */; + 16 /* ContainsES2020 */; if (node.typeArguments) { node.transformFlags |= 1 /* ContainsTypeScript */; } if (ts.isSuperProperty(node.expression)) { - node.transformFlags |= 4096 /* ContainsLexicalThis */; + node.transformFlags |= 8192 /* ContainsLexicalThis */; } return node; } @@ -22226,7 +22818,7 @@ var ts; } // @api function createNewExpression(expression, typeArguments, argumentsArray) { - var node = createBaseExpression(204 /* NewExpression */); + var node = createBaseExpression(206 /* NewExpression */); node.expression = parenthesizerRules().parenthesizeExpressionOfNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(argumentsArray) : undefined; @@ -22234,7 +22826,7 @@ var ts; propagateChildFlags(node.expression) | propagateChildrenFlags(node.typeArguments) | propagateChildrenFlags(node.arguments) | - 8 /* ContainsES2020 */; + 16 /* ContainsES2020 */; if (node.typeArguments) { node.transformFlags |= 1 /* ContainsTypeScript */; } @@ -22250,7 +22842,7 @@ var ts; } // @api function createTaggedTemplateExpression(tag, typeArguments, template) { - var node = createBaseExpression(205 /* TaggedTemplateExpression */); + var node = createBaseExpression(207 /* TaggedTemplateExpression */); node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag); node.typeArguments = asNodeArray(typeArguments); node.template = template; @@ -22258,12 +22850,12 @@ var ts; propagateChildFlags(node.tag) | propagateChildrenFlags(node.typeArguments) | propagateChildFlags(node.template) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; if (node.typeArguments) { node.transformFlags |= 1 /* ContainsTypeScript */; } if (ts.hasInvalidEscape(node.template)) { - node.transformFlags |= 32 /* ContainsES2018 */; + node.transformFlags |= 64 /* ContainsES2018 */; } return node; } @@ -22277,7 +22869,7 @@ var ts; } // @api function createTypeAssertion(type, expression) { - var node = createBaseExpression(206 /* TypeAssertionExpression */); + var node = createBaseExpression(208 /* TypeAssertionExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.type = type; node.transformFlags |= @@ -22295,7 +22887,7 @@ var ts; } // @api function createParenthesizedExpression(expression) { - var node = createBaseExpression(207 /* ParenthesizedExpression */); + var node = createBaseExpression(209 /* ParenthesizedExpression */); node.expression = expression; node.transformFlags = propagateChildFlags(node.expression); return node; @@ -22308,7 +22900,7 @@ var ts; } // @api function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(208 /* FunctionExpression */, + var node = createBaseFunctionLikeDeclaration(210 /* FunctionExpression */, /*decorators*/ undefined, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; node.transformFlags |= propagateChildFlags(node.asteriskToken); @@ -22317,14 +22909,14 @@ var ts; } if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { if (node.asteriskToken) { - node.transformFlags |= 32 /* ContainsES2018 */; + node.transformFlags |= 64 /* ContainsES2018 */; } else { - node.transformFlags |= 64 /* ContainsES2017 */; + node.transformFlags |= 128 /* ContainsES2017 */; } } else if (node.asteriskToken) { - node.transformFlags |= 512 /* ContainsGenerator */; + node.transformFlags |= 1024 /* ContainsGenerator */; } return node; } @@ -22342,15 +22934,15 @@ var ts; } // @api function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createBaseFunctionLikeDeclaration(209 /* ArrowFunction */, + var node = createBaseFunctionLikeDeclaration(211 /* ArrowFunction */, /*decorators*/ undefined, modifiers, /*name*/ undefined, typeParameters, parameters, type, parenthesizerRules().parenthesizeConciseBodyOfArrowFunction(body)); node.equalsGreaterThanToken = equalsGreaterThanToken !== null && equalsGreaterThanToken !== void 0 ? equalsGreaterThanToken : createToken(38 /* EqualsGreaterThanToken */); node.transformFlags |= propagateChildFlags(node.equalsGreaterThanToken) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { - node.transformFlags |= 64 /* ContainsES2017 */; + node.transformFlags |= 128 /* ContainsES2017 */; } return node; } @@ -22367,7 +22959,7 @@ var ts; } // @api function createDeleteExpression(expression) { - var node = createBaseExpression(210 /* DeleteExpression */); + var node = createBaseExpression(212 /* DeleteExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -22380,7 +22972,7 @@ var ts; } // @api function createTypeOfExpression(expression) { - var node = createBaseExpression(211 /* TypeOfExpression */); + var node = createBaseExpression(213 /* TypeOfExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -22393,7 +22985,7 @@ var ts; } // @api function createVoidExpression(expression) { - var node = createBaseExpression(212 /* VoidExpression */); + var node = createBaseExpression(214 /* VoidExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -22406,13 +22998,13 @@ var ts; } // @api function createAwaitExpression(expression) { - var node = createBaseExpression(213 /* AwaitExpression */); + var node = createBaseExpression(215 /* AwaitExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 64 /* ContainsES2017 */ | - 32 /* ContainsES2018 */ | - 524288 /* ContainsAwait */; + 128 /* ContainsES2017 */ | + 64 /* ContainsES2018 */ | + 1048576 /* ContainsAwait */; return node; } // @api @@ -22423,7 +23015,7 @@ var ts; } // @api function createPrefixUnaryExpression(operator, operand) { - var node = createBaseExpression(214 /* PrefixUnaryExpression */); + var node = createBaseExpression(216 /* PrefixUnaryExpression */); node.operator = operator; node.operand = parenthesizerRules().parenthesizeOperandOfPrefixUnary(operand); node.transformFlags |= propagateChildFlags(node.operand); @@ -22437,7 +23029,7 @@ var ts; } // @api function createPostfixUnaryExpression(operand, operator) { - var node = createBaseExpression(215 /* PostfixUnaryExpression */); + var node = createBaseExpression(217 /* PostfixUnaryExpression */); node.operator = operator; node.operand = parenthesizerRules().parenthesizeOperandOfPostfixUnary(operand); node.transformFlags = propagateChildFlags(node.operand); @@ -22451,7 +23043,7 @@ var ts; } // @api function createBinaryExpression(left, operator, right) { - var node = createBaseExpression(216 /* BinaryExpression */); + var node = createBaseExpression(218 /* BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = parenthesizerRules().parenthesizeLeftSideOfBinary(operatorKind, left); @@ -22462,45 +23054,45 @@ var ts; propagateChildFlags(node.operatorToken) | propagateChildFlags(node.right); if (operatorKind === 60 /* QuestionQuestionToken */) { - node.transformFlags |= 8 /* ContainsES2020 */; + node.transformFlags |= 16 /* ContainsES2020 */; } - else if (operatorKind === 62 /* EqualsToken */) { + else if (operatorKind === 63 /* EqualsToken */) { if (ts.isObjectLiteralExpression(node.left)) { node.transformFlags |= - 256 /* ContainsES2015 */ | - 32 /* ContainsES2018 */ | - 1024 /* ContainsDestructuringAssignment */ | + 512 /* ContainsES2015 */ | + 64 /* ContainsES2018 */ | + 2048 /* ContainsDestructuringAssignment */ | propagateAssignmentPatternFlags(node.left); } else if (ts.isArrayLiteralExpression(node.left)) { node.transformFlags |= - 256 /* ContainsES2015 */ | - 1024 /* ContainsDestructuringAssignment */ | + 512 /* ContainsES2015 */ | + 2048 /* ContainsDestructuringAssignment */ | propagateAssignmentPatternFlags(node.left); } } - else if (operatorKind === 42 /* AsteriskAsteriskToken */ || operatorKind === 66 /* AsteriskAsteriskEqualsToken */) { - node.transformFlags |= 128 /* ContainsES2016 */; + else if (operatorKind === 42 /* AsteriskAsteriskToken */ || operatorKind === 67 /* AsteriskAsteriskEqualsToken */) { + node.transformFlags |= 256 /* ContainsES2016 */; } else if (ts.isLogicalOrCoalescingAssignmentOperator(operatorKind)) { - node.transformFlags |= 4 /* ContainsESNext */; + node.transformFlags |= 8 /* ContainsES2021 */; } return node; } function propagateAssignmentPatternFlags(node) { - if (node.transformFlags & 16384 /* ContainsObjectRestOrSpread */) - return 16384 /* ContainsObjectRestOrSpread */; - if (node.transformFlags & 32 /* ContainsES2018 */) { + if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) + return 32768 /* ContainsObjectRestOrSpread */; + if (node.transformFlags & 64 /* 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 & 16384 /* ContainsObjectRestOrSpread */) { - return 16384 /* ContainsObjectRestOrSpread */; + if (target.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { + return 32768 /* ContainsObjectRestOrSpread */; } - if (target.transformFlags & 32 /* ContainsES2018 */) { + if (target.transformFlags & 64 /* ContainsES2018 */) { var flags_1 = propagateAssignmentPatternFlags(target); if (flags_1) return flags_1; @@ -22520,7 +23112,7 @@ var ts; } // @api function createConditionalExpression(condition, questionToken, whenTrue, colonToken, whenFalse) { - var node = createBaseExpression(217 /* ConditionalExpression */); + var node = createBaseExpression(219 /* ConditionalExpression */); node.condition = parenthesizerRules().parenthesizeConditionOfConditionalExpression(condition); node.questionToken = questionToken !== null && questionToken !== void 0 ? questionToken : createToken(57 /* QuestionToken */); node.whenTrue = parenthesizerRules().parenthesizeBranchOfConditionalExpression(whenTrue); @@ -22546,13 +23138,13 @@ var ts; } // @api function createTemplateExpression(head, templateSpans) { - var node = createBaseExpression(218 /* TemplateExpression */); + var node = createBaseExpression(220 /* TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); node.transformFlags |= propagateChildFlags(node.head) | propagateChildrenFlags(node.templateSpans) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; return node; } // @api @@ -22591,9 +23183,9 @@ var ts; node.text = text; node.rawText = rawText; node.templateFlags = templateFlags & 2048 /* TemplateLiteralLikeFlags */; - node.transformFlags |= 256 /* ContainsES2015 */; + node.transformFlags |= 512 /* ContainsES2015 */; if (node.templateFlags) { - node.transformFlags |= 32 /* ContainsES2018 */; + node.transformFlags |= 64 /* ContainsES2018 */; } return node; } @@ -22616,15 +23208,15 @@ var ts; // @api function createYieldExpression(asteriskToken, expression) { ts.Debug.assert(!asteriskToken || !!expression, "A `YieldExpression` with an asteriskToken must have an expression."); - var node = createBaseExpression(219 /* YieldExpression */); + var node = createBaseExpression(221 /* YieldExpression */); node.expression = expression && parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.asteriskToken = asteriskToken; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.asteriskToken) | - 256 /* ContainsES2015 */ | - 32 /* ContainsES2018 */ | - 262144 /* ContainsYield */; + 512 /* ContainsES2015 */ | + 64 /* ContainsES2018 */ | + 524288 /* ContainsYield */; return node; } // @api @@ -22636,12 +23228,12 @@ var ts; } // @api function createSpreadElement(expression) { - var node = createBaseExpression(220 /* SpreadElement */); + var node = createBaseExpression(222 /* SpreadElement */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 256 /* ContainsES2015 */ | - 8192 /* ContainsRestOrSpread */; + 512 /* ContainsES2015 */ | + 16384 /* ContainsRestOrSpread */; return node; } // @api @@ -22652,8 +23244,8 @@ var ts; } // @api function createClassExpression(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseClassLikeDeclaration(221 /* ClassExpression */, decorators, modifiers, name, typeParameters, heritageClauses, members); - node.transformFlags |= 256 /* ContainsES2015 */; + var node = createBaseClassLikeDeclaration(223 /* ClassExpression */, decorators, modifiers, name, typeParameters, heritageClauses, members); + node.transformFlags |= 512 /* ContainsES2015 */; return node; } // @api @@ -22669,17 +23261,17 @@ var ts; } // @api function createOmittedExpression() { - return createBaseExpression(222 /* OmittedExpression */); + return createBaseExpression(224 /* OmittedExpression */); } // @api function createExpressionWithTypeArguments(expression, typeArguments) { - var node = createBaseNode(223 /* ExpressionWithTypeArguments */); + var node = createBaseNode(225 /* ExpressionWithTypeArguments */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); node.transformFlags |= propagateChildFlags(node.expression) | propagateChildrenFlags(node.typeArguments) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; return node; } // @api @@ -22691,7 +23283,7 @@ var ts; } // @api function createAsExpression(expression, type) { - var node = createBaseExpression(224 /* AsExpression */); + var node = createBaseExpression(226 /* AsExpression */); node.expression = expression; node.type = type; node.transformFlags |= @@ -22709,7 +23301,7 @@ var ts; } // @api function createNonNullExpression(expression) { - var node = createBaseExpression(225 /* NonNullExpression */); + var node = createBaseExpression(227 /* NonNullExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= propagateChildFlags(node.expression) | @@ -22727,7 +23319,7 @@ var ts; } // @api function createNonNullChain(expression) { - var node = createBaseExpression(225 /* NonNullExpression */); + var node = createBaseExpression(227 /* NonNullExpression */); node.flags |= 32 /* OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= @@ -22744,15 +23336,15 @@ var ts; } // @api function createMetaProperty(keywordToken, name) { - var node = createBaseExpression(226 /* MetaProperty */); + var node = createBaseExpression(228 /* MetaProperty */); node.keywordToken = keywordToken; node.name = name; node.transformFlags |= propagateChildFlags(node.name); switch (keywordToken) { - case 102 /* NewKeyword */: - node.transformFlags |= 256 /* ContainsES2015 */; + case 103 /* NewKeyword */: + node.transformFlags |= 512 /* ContainsES2015 */; break; - case 99 /* ImportKeyword */: + case 100 /* ImportKeyword */: node.transformFlags |= 4 /* ContainsESNext */; break; default: @@ -22771,13 +23363,13 @@ var ts; // // @api function createTemplateSpan(expression, literal) { - var node = createBaseNode(228 /* TemplateSpan */); + var node = createBaseNode(230 /* TemplateSpan */); node.expression = expression; node.literal = literal; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.literal) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; return node; } // @api @@ -22789,8 +23381,8 @@ var ts; } // @api function createSemicolonClassElement() { - var node = createBaseNode(229 /* SemicolonClassElement */); - node.transformFlags |= 256 /* ContainsES2015 */; + var node = createBaseNode(231 /* SemicolonClassElement */); + node.transformFlags |= 512 /* ContainsES2015 */; return node; } // @@ -22798,7 +23390,7 @@ var ts; // // @api function createBlock(statements, multiLine) { - var node = createBaseNode(230 /* Block */); + var node = createBaseNode(232 /* Block */); node.statements = createNodeArray(statements); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.statements); @@ -22812,7 +23404,7 @@ var ts; } // @api function createVariableStatement(modifiers, declarationList) { - var node = createBaseDeclaration(232 /* VariableStatement */, /*decorators*/ undefined, modifiers); + var node = createBaseDeclaration(234 /* VariableStatement */, /*decorators*/ undefined, modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; node.transformFlags |= propagateChildFlags(node.declarationList); @@ -22830,11 +23422,11 @@ var ts; } // @api function createEmptyStatement() { - return createBaseNode(231 /* EmptyStatement */); + return createBaseNode(233 /* EmptyStatement */); } // @api function createExpressionStatement(expression) { - var node = createBaseNode(233 /* ExpressionStatement */); + var node = createBaseNode(235 /* ExpressionStatement */); node.expression = parenthesizerRules().parenthesizeExpressionOfExpressionStatement(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -22847,7 +23439,7 @@ var ts; } // @api function createIfStatement(expression, thenStatement, elseStatement) { - var node = createBaseNode(234 /* IfStatement */); + var node = createBaseNode(236 /* IfStatement */); node.expression = expression; node.thenStatement = asEmbeddedStatement(thenStatement); node.elseStatement = asEmbeddedStatement(elseStatement); @@ -22867,7 +23459,7 @@ var ts; } // @api function createDoStatement(statement, expression) { - var node = createBaseNode(235 /* DoStatement */); + var node = createBaseNode(237 /* DoStatement */); node.statement = asEmbeddedStatement(statement); node.expression = expression; node.transformFlags |= @@ -22884,7 +23476,7 @@ var ts; } // @api function createWhileStatement(expression, statement) { - var node = createBaseNode(236 /* WhileStatement */); + var node = createBaseNode(238 /* WhileStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -22901,7 +23493,7 @@ var ts; } // @api function createForStatement(initializer, condition, incrementor, statement) { - var node = createBaseNode(237 /* ForStatement */); + var node = createBaseNode(239 /* ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -22924,7 +23516,7 @@ var ts; } // @api function createForInStatement(initializer, expression, statement) { - var node = createBaseNode(238 /* ForInStatement */); + var node = createBaseNode(240 /* ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = asEmbeddedStatement(statement); @@ -22944,7 +23536,7 @@ var ts; } // @api function createForOfStatement(awaitModifier, initializer, expression, statement) { - var node = createBaseNode(239 /* ForOfStatement */); + var node = createBaseNode(241 /* ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); @@ -22954,9 +23546,9 @@ var ts; propagateChildFlags(node.initializer) | propagateChildFlags(node.expression) | propagateChildFlags(node.statement) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; if (awaitModifier) - node.transformFlags |= 32 /* ContainsES2018 */; + node.transformFlags |= 64 /* ContainsES2018 */; return node; } // @api @@ -22970,11 +23562,11 @@ var ts; } // @api function createContinueStatement(label) { - var node = createBaseNode(240 /* ContinueStatement */); + var node = createBaseNode(242 /* ContinueStatement */); node.label = asName(label); node.transformFlags |= propagateChildFlags(node.label) | - 1048576 /* ContainsHoistedDeclarationOrCompletion */; + 2097152 /* ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -22985,11 +23577,11 @@ var ts; } // @api function createBreakStatement(label) { - var node = createBaseNode(241 /* BreakStatement */); + var node = createBaseNode(243 /* BreakStatement */); node.label = asName(label); node.transformFlags |= propagateChildFlags(node.label) | - 1048576 /* ContainsHoistedDeclarationOrCompletion */; + 2097152 /* ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -23000,13 +23592,13 @@ var ts; } // @api function createReturnStatement(expression) { - var node = createBaseNode(242 /* ReturnStatement */); + var node = createBaseNode(244 /* ReturnStatement */); node.expression = expression; // return in an ES2018 async generator must be awaited node.transformFlags |= propagateChildFlags(node.expression) | - 32 /* ContainsES2018 */ | - 1048576 /* ContainsHoistedDeclarationOrCompletion */; + 64 /* ContainsES2018 */ | + 2097152 /* ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -23017,7 +23609,7 @@ var ts; } // @api function createWithStatement(expression, statement) { - var node = createBaseNode(243 /* WithStatement */); + var node = createBaseNode(245 /* WithStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -23034,7 +23626,7 @@ var ts; } // @api function createSwitchStatement(expression, caseBlock) { - var node = createBaseNode(244 /* SwitchStatement */); + var node = createBaseNode(246 /* SwitchStatement */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.caseBlock = caseBlock; node.transformFlags |= @@ -23051,7 +23643,7 @@ var ts; } // @api function createLabeledStatement(label, statement) { - var node = createBaseNode(245 /* LabeledStatement */); + var node = createBaseNode(247 /* LabeledStatement */); node.label = asName(label); node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -23068,7 +23660,7 @@ var ts; } // @api function createThrowStatement(expression) { - var node = createBaseNode(246 /* ThrowStatement */); + var node = createBaseNode(248 /* ThrowStatement */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -23081,7 +23673,7 @@ var ts; } // @api function createTryStatement(tryBlock, catchClause, finallyBlock) { - var node = createBaseNode(247 /* TryStatement */); + var node = createBaseNode(249 /* TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -23101,11 +23693,11 @@ var ts; } // @api function createDebuggerStatement() { - return createBaseNode(248 /* DebuggerStatement */); + return createBaseNode(250 /* DebuggerStatement */); } // @api function createVariableDeclaration(name, exclamationToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(249 /* VariableDeclaration */, + var node = createBaseVariableLikeDeclaration(251 /* VariableDeclaration */, /*decorators*/ undefined, /*modifiers*/ undefined, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.exclamationToken = exclamationToken; @@ -23127,16 +23719,16 @@ var ts; // @api function createVariableDeclarationList(declarations, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createBaseNode(250 /* VariableDeclarationList */); + var node = createBaseNode(252 /* VariableDeclarationList */); node.flags |= flags & 3 /* BlockScoped */; node.declarations = createNodeArray(declarations); node.transformFlags |= propagateChildrenFlags(node.declarations) | - 1048576 /* ContainsHoistedDeclarationOrCompletion */; + 2097152 /* ContainsHoistedDeclarationOrCompletion */; if (flags & 3 /* BlockScoped */) { node.transformFlags |= - 256 /* ContainsES2015 */ | - 65536 /* ContainsBlockScopedBinding */; + 512 /* ContainsES2015 */ | + 131072 /* ContainsBlockScopedBinding */; } return node; } @@ -23148,7 +23740,7 @@ var ts; } // @api function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(251 /* FunctionDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(253 /* FunctionDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; if (!node.body || ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { node.transformFlags = 1 /* ContainsTypeScript */; @@ -23156,17 +23748,17 @@ var ts; else { node.transformFlags |= propagateChildFlags(node.asteriskToken) | - 1048576 /* ContainsHoistedDeclarationOrCompletion */; + 2097152 /* ContainsHoistedDeclarationOrCompletion */; if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { if (node.asteriskToken) { - node.transformFlags |= 32 /* ContainsES2018 */; + node.transformFlags |= 64 /* ContainsES2018 */; } else { - node.transformFlags |= 64 /* ContainsES2017 */; + node.transformFlags |= 128 /* ContainsES2017 */; } } else if (node.asteriskToken) { - node.transformFlags |= 512 /* ContainsGenerator */; + node.transformFlags |= 1024 /* ContainsGenerator */; } } return node; @@ -23186,13 +23778,13 @@ var ts; } // @api function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseClassLikeDeclaration(252 /* ClassDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses, members); + var node = createBaseClassLikeDeclaration(254 /* ClassDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses, members); if (ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { node.transformFlags = 1 /* ContainsTypeScript */; } else { - node.transformFlags |= 256 /* ContainsES2015 */; - if (node.transformFlags & 2048 /* ContainsTypeScriptClassSyntax */) { + node.transformFlags |= 512 /* ContainsES2015 */; + if (node.transformFlags & 4096 /* ContainsTypeScriptClassSyntax */) { node.transformFlags |= 1 /* ContainsTypeScript */; } } @@ -23211,7 +23803,7 @@ var ts; } // @api function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseInterfaceOrClassLikeDeclaration(253 /* InterfaceDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses); + var node = createBaseInterfaceOrClassLikeDeclaration(255 /* InterfaceDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses); node.members = createNodeArray(members); node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -23229,7 +23821,7 @@ var ts; } // @api function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createBaseGenericNamedDeclaration(254 /* TypeAliasDeclaration */, decorators, modifiers, name, typeParameters); + var node = createBaseGenericNamedDeclaration(256 /* TypeAliasDeclaration */, decorators, modifiers, name, typeParameters); node.type = type; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -23246,12 +23838,12 @@ var ts; } // @api function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createBaseNamedDeclaration(255 /* EnumDeclaration */, decorators, modifiers, name); + var node = createBaseNamedDeclaration(257 /* EnumDeclaration */, decorators, modifiers, name); node.members = createNodeArray(members); node.transformFlags |= propagateChildrenFlags(node.members) | 1 /* ContainsTypeScript */; - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await` + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await` return node; } // @api @@ -23266,7 +23858,7 @@ var ts; // @api function createModuleDeclaration(decorators, modifiers, name, body, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createBaseDeclaration(256 /* ModuleDeclaration */, decorators, modifiers); + var node = createBaseDeclaration(258 /* ModuleDeclaration */, decorators, modifiers); node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 1024 /* GlobalAugmentation */); node.name = name; node.body = body; @@ -23279,7 +23871,7 @@ var ts; propagateChildFlags(node.body) | 1 /* ContainsTypeScript */; } - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`. + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`. return node; } // @api @@ -23293,7 +23885,7 @@ var ts; } // @api function createModuleBlock(statements) { - var node = createBaseNode(257 /* ModuleBlock */); + var node = createBaseNode(259 /* ModuleBlock */); node.statements = createNodeArray(statements); node.transformFlags |= propagateChildrenFlags(node.statements); return node; @@ -23306,7 +23898,7 @@ var ts; } // @api function createCaseBlock(clauses) { - var node = createBaseNode(258 /* CaseBlock */); + var node = createBaseNode(260 /* CaseBlock */); node.clauses = createNodeArray(clauses); node.transformFlags |= propagateChildrenFlags(node.clauses); return node; @@ -23319,7 +23911,7 @@ var ts; } // @api function createNamespaceExportDeclaration(name) { - var node = createBaseNamedDeclaration(259 /* NamespaceExportDeclaration */, + var node = createBaseNamedDeclaration(261 /* NamespaceExportDeclaration */, /*decorators*/ undefined, /*modifiers*/ undefined, name); node.transformFlags = 1 /* ContainsTypeScript */; @@ -23333,13 +23925,13 @@ var ts; } // @api function createImportEqualsDeclaration(decorators, modifiers, isTypeOnly, name, moduleReference) { - var node = createBaseNamedDeclaration(260 /* ImportEqualsDeclaration */, decorators, modifiers, name); + var node = createBaseNamedDeclaration(262 /* ImportEqualsDeclaration */, decorators, modifiers, name); node.isTypeOnly = isTypeOnly; node.moduleReference = moduleReference; node.transformFlags |= propagateChildFlags(node.moduleReference); if (!ts.isExternalModuleReference(node.moduleReference)) node.transformFlags |= 1 /* ContainsTypeScript */; - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // Import= declaration is always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Import= declaration is always parsed in an Await context return node; } // @api @@ -23354,13 +23946,13 @@ var ts; } // @api function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createBaseDeclaration(261 /* ImportDeclaration */, decorators, modifiers); + var node = createBaseDeclaration(263 /* ImportDeclaration */, decorators, modifiers); node.importClause = importClause; node.moduleSpecifier = moduleSpecifier; node.transformFlags |= propagateChildFlags(node.importClause) | propagateChildFlags(node.moduleSpecifier); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23374,7 +23966,7 @@ var ts; } // @api function createImportClause(isTypeOnly, name, namedBindings) { - var node = createBaseNode(262 /* ImportClause */); + var node = createBaseNode(264 /* ImportClause */); node.isTypeOnly = isTypeOnly; node.name = name; node.namedBindings = namedBindings; @@ -23384,7 +23976,7 @@ var ts; if (isTypeOnly) { node.transformFlags |= 1 /* ContainsTypeScript */; } - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23397,10 +23989,10 @@ var ts; } // @api function createNamespaceImport(name) { - var node = createBaseNode(263 /* NamespaceImport */); + var node = createBaseNode(265 /* NamespaceImport */); node.name = name; node.transformFlags |= propagateChildFlags(node.name); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23411,12 +24003,12 @@ var ts; } // @api function createNamespaceExport(name) { - var node = createBaseNode(269 /* NamespaceExport */); + var node = createBaseNode(271 /* NamespaceExport */); node.name = name; node.transformFlags |= propagateChildFlags(node.name) | 4 /* ContainsESNext */; - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23427,10 +24019,10 @@ var ts; } // @api function createNamedImports(elements) { - var node = createBaseNode(264 /* NamedImports */); + var node = createBaseNode(266 /* NamedImports */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23441,13 +24033,13 @@ var ts; } // @api function createImportSpecifier(propertyName, name) { - var node = createBaseNode(265 /* ImportSpecifier */); + var node = createBaseNode(267 /* ImportSpecifier */); node.propertyName = propertyName; node.name = name; node.transformFlags |= propagateChildFlags(node.propertyName) | propagateChildFlags(node.name); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23459,13 +24051,13 @@ var ts; } // @api function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createBaseDeclaration(266 /* ExportAssignment */, decorators, modifiers); + var node = createBaseDeclaration(268 /* ExportAssignment */, decorators, modifiers); node.isExportEquals = isExportEquals; node.expression = isExportEquals - ? parenthesizerRules().parenthesizeRightSideOfBinary(62 /* EqualsToken */, /*leftSide*/ undefined, expression) + ? parenthesizerRules().parenthesizeRightSideOfBinary(63 /* EqualsToken */, /*leftSide*/ undefined, expression) : parenthesizerRules().parenthesizeExpressionOfExportDefault(expression); node.transformFlags |= propagateChildFlags(node.expression); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23478,14 +24070,14 @@ var ts; } // @api function createExportDeclaration(decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier) { - var node = createBaseDeclaration(267 /* ExportDeclaration */, decorators, modifiers); + var node = createBaseDeclaration(269 /* ExportDeclaration */, decorators, modifiers); node.isTypeOnly = isTypeOnly; node.exportClause = exportClause; node.moduleSpecifier = moduleSpecifier; node.transformFlags |= propagateChildFlags(node.exportClause) | propagateChildFlags(node.moduleSpecifier); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23500,10 +24092,10 @@ var ts; } // @api function createNamedExports(elements) { - var node = createBaseNode(268 /* NamedExports */); + var node = createBaseNode(270 /* NamedExports */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23514,13 +24106,13 @@ var ts; } // @api function createExportSpecifier(propertyName, name) { - var node = createBaseNode(270 /* ExportSpecifier */); + var node = createBaseNode(272 /* ExportSpecifier */); node.propertyName = asName(propertyName); node.name = asName(name); node.transformFlags |= propagateChildFlags(node.propertyName) | propagateChildFlags(node.name); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23532,7 +24124,7 @@ var ts; } // @api function createMissingDeclaration() { - var node = createBaseDeclaration(271 /* MissingDeclaration */, + var node = createBaseDeclaration(273 /* MissingDeclaration */, /*decorators*/ undefined, /*modifiers*/ undefined); return node; @@ -23542,10 +24134,10 @@ var ts; // // @api function createExternalModuleReference(expression) { - var node = createBaseNode(272 /* ExternalModuleReference */); + var node = createBaseNode(274 /* ExternalModuleReference */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23587,7 +24179,7 @@ var ts; } // @api function createJSDocFunctionType(parameters, type) { - var node = createBaseSignatureDeclaration(308 /* JSDocFunctionType */, + var node = createBaseSignatureDeclaration(311 /* JSDocFunctionType */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, @@ -23604,7 +24196,7 @@ var ts; // @api function createJSDocTypeLiteral(propertyTags, isArrayType) { if (isArrayType === void 0) { isArrayType = false; } - var node = createBaseNode(312 /* JSDocTypeLiteral */); + var node = createBaseNode(316 /* JSDocTypeLiteral */); node.jsDocPropertyTags = asNodeArray(propertyTags); node.isArrayType = isArrayType; return node; @@ -23618,7 +24210,7 @@ var ts; } // @api function createJSDocTypeExpression(type) { - var node = createBaseNode(301 /* JSDocTypeExpression */); + var node = createBaseNode(303 /* JSDocTypeExpression */); node.type = type; return node; } @@ -23630,7 +24222,7 @@ var ts; } // @api function createJSDocSignature(typeParameters, parameters, type) { - var node = createBaseNode(313 /* JSDocSignature */); + var node = createBaseNode(317 /* JSDocSignature */); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; @@ -23659,7 +24251,7 @@ var ts; } // @api function createJSDocTemplateTag(tagName, constraint, typeParameters, comment) { - var node = createBaseJSDocTag(330 /* JSDocTemplateTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("template"), comment); + var node = createBaseJSDocTag(338 /* JSDocTemplateTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("template"), comment); node.constraint = constraint; node.typeParameters = createNodeArray(typeParameters); return node; @@ -23676,7 +24268,7 @@ var ts; } // @api function createJSDocTypedefTag(tagName, typeExpression, fullName, comment) { - var node = createBaseJSDocTag(331 /* JSDocTypedefTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("typedef"), comment); + var node = createBaseJSDocTag(339 /* JSDocTypedefTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("typedef"), comment); node.typeExpression = typeExpression; node.fullName = fullName; node.name = ts.getJSDocTypeAliasName(fullName); @@ -23694,7 +24286,7 @@ var ts; } // @api function createJSDocParameterTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) { - var node = createBaseJSDocTag(326 /* JSDocParameterTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("param"), comment); + var node = createBaseJSDocTag(334 /* JSDocParameterTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("param"), comment); node.typeExpression = typeExpression; node.name = name; node.isNameFirst = !!isNameFirst; @@ -23715,7 +24307,7 @@ var ts; } // @api function createJSDocPropertyTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) { - var node = createBaseJSDocTag(333 /* JSDocPropertyTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("prop"), comment); + var node = createBaseJSDocTag(341 /* JSDocPropertyTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("prop"), comment); node.typeExpression = typeExpression; node.name = name; node.isNameFirst = !!isNameFirst; @@ -23736,7 +24328,7 @@ var ts; } // @api function createJSDocCallbackTag(tagName, typeExpression, fullName, comment) { - var node = createBaseJSDocTag(324 /* JSDocCallbackTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("callback"), comment); + var node = createBaseJSDocTag(332 /* JSDocCallbackTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("callback"), comment); node.typeExpression = typeExpression; node.fullName = fullName; node.name = ts.getJSDocTypeAliasName(fullName); @@ -23754,7 +24346,7 @@ var ts; } // @api function createJSDocAugmentsTag(tagName, className, comment) { - var node = createBaseJSDocTag(315 /* JSDocAugmentsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("augments"), comment); + var node = createBaseJSDocTag(322 /* JSDocAugmentsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("augments"), comment); node.class = className; return node; } @@ -23769,13 +24361,13 @@ var ts; } // @api function createJSDocImplementsTag(tagName, className, comment) { - var node = createBaseJSDocTag(316 /* JSDocImplementsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("implements"), comment); + var node = createBaseJSDocTag(323 /* JSDocImplementsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("implements"), comment); node.class = className; return node; } // @api function createJSDocSeeTag(tagName, name, comment) { - var node = createBaseJSDocTag(332 /* JSDocSeeTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("see"), comment); + var node = createBaseJSDocTag(340 /* JSDocSeeTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("see"), comment); node.name = name; return node; } @@ -23789,7 +24381,7 @@ var ts; } // @api function createJSDocNameReference(name) { - var node = createBaseNode(302 /* JSDocNameReference */); + var node = createBaseNode(304 /* JSDocNameReference */); node.name = name; return node; } @@ -23800,6 +24392,62 @@ var ts; : node; } // @api + function createJSDocMemberName(left, right) { + var node = createBaseNode(305 /* JSDocMemberName */); + node.left = left; + node.right = right; + node.transformFlags |= + propagateChildFlags(node.left) | + propagateChildFlags(node.right); + return node; + } + // @api + function updateJSDocMemberName(node, left, right) { + return node.left !== left + || node.right !== right + ? update(createJSDocMemberName(left, right), node) + : node; + } + // @api + function createJSDocLink(name, text) { + var node = createBaseNode(318 /* JSDocLink */); + node.name = name; + node.text = text; + return node; + } + // @api + function updateJSDocLink(node, name, text) { + return node.name !== name + ? update(createJSDocLink(name, text), node) + : node; + } + // @api + function createJSDocLinkCode(name, text) { + var node = createBaseNode(319 /* JSDocLinkCode */); + node.name = name; + node.text = text; + return node; + } + // @api + function updateJSDocLinkCode(node, name, text) { + return node.name !== name + ? update(createJSDocLinkCode(name, text), node) + : node; + } + // @api + function createJSDocLinkPlain(name, text) { + var node = createBaseNode(320 /* JSDocLinkPlain */); + node.name = name; + node.text = text; + return node; + } + // @api + function updateJSDocLinkPlain(node, name, text) { + return node.name !== name + ? update(createJSDocLinkPlain(name, text), node) + : node; + } + // @api function updateJSDocImplementsTag(node, tagName, className, comment) { if (tagName === void 0) { tagName = getDefaultTagName(node); } return node.tagName !== tagName @@ -23860,7 +24508,7 @@ var ts; } // @api function createJSDocUnknownTag(tagName, comment) { - var node = createBaseJSDocTag(314 /* JSDocTag */, tagName, comment); + var node = createBaseJSDocTag(321 /* JSDocTag */, tagName, comment); return node; } // @api @@ -23871,8 +24519,20 @@ var ts; : node; } // @api + function createJSDocText(text) { + var node = createBaseNode(315 /* JSDocText */); + node.text = text; + return node; + } + // @api + function updateJSDocText(node, text) { + return node.text !== text + ? update(createJSDocText(text), node) + : node; + } + // @api function createJSDocComment(comment, tags) { - var node = createBaseNode(311 /* JSDocComment */); + var node = createBaseNode(314 /* JSDocComment */); node.comment = comment; node.tags = asNodeArray(tags); return node; @@ -23889,7 +24549,7 @@ var ts; // // @api function createJsxElement(openingElement, children, closingElement) { - var node = createBaseNode(273 /* JsxElement */); + var node = createBaseNode(275 /* JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -23910,7 +24570,7 @@ var ts; } // @api function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createBaseNode(274 /* JsxSelfClosingElement */); + var node = createBaseNode(276 /* JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -23934,7 +24594,7 @@ var ts; } // @api function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createBaseNode(275 /* JsxOpeningElement */); + var node = createBaseNode(277 /* JsxOpeningElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -23958,7 +24618,7 @@ var ts; } // @api function createJsxClosingElement(tagName) { - var node = createBaseNode(276 /* JsxClosingElement */); + var node = createBaseNode(278 /* JsxClosingElement */); node.tagName = tagName; node.transformFlags |= propagateChildFlags(node.tagName) | @@ -23973,7 +24633,7 @@ var ts; } // @api function createJsxFragment(openingFragment, children, closingFragment) { - var node = createBaseNode(277 /* JsxFragment */); + var node = createBaseNode(279 /* JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -24009,19 +24669,19 @@ var ts; } // @api function createJsxOpeningFragment() { - var node = createBaseNode(278 /* JsxOpeningFragment */); + var node = createBaseNode(280 /* JsxOpeningFragment */); node.transformFlags |= 2 /* ContainsJsx */; return node; } // @api function createJsxJsxClosingFragment() { - var node = createBaseNode(279 /* JsxClosingFragment */); + var node = createBaseNode(281 /* JsxClosingFragment */); node.transformFlags |= 2 /* ContainsJsx */; return node; } // @api function createJsxAttribute(name, initializer) { - var node = createBaseNode(280 /* JsxAttribute */); + var node = createBaseNode(282 /* JsxAttribute */); node.name = name; node.initializer = initializer; node.transformFlags |= @@ -24039,7 +24699,7 @@ var ts; } // @api function createJsxAttributes(properties) { - var node = createBaseNode(281 /* JsxAttributes */); + var node = createBaseNode(283 /* JsxAttributes */); node.properties = createNodeArray(properties); node.transformFlags |= propagateChildrenFlags(node.properties) | @@ -24054,7 +24714,7 @@ var ts; } // @api function createJsxSpreadAttribute(expression) { - var node = createBaseNode(282 /* JsxSpreadAttribute */); + var node = createBaseNode(284 /* JsxSpreadAttribute */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression) | @@ -24069,7 +24729,7 @@ var ts; } // @api function createJsxExpression(dotDotDotToken, expression) { - var node = createBaseNode(283 /* JsxExpression */); + var node = createBaseNode(285 /* JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; node.transformFlags |= @@ -24089,7 +24749,7 @@ var ts; // // @api function createCaseClause(expression, statements) { - var node = createBaseNode(284 /* CaseClause */); + var node = createBaseNode(286 /* CaseClause */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.statements = createNodeArray(statements); node.transformFlags |= @@ -24106,7 +24766,7 @@ var ts; } // @api function createDefaultClause(statements) { - var node = createBaseNode(285 /* DefaultClause */); + var node = createBaseNode(287 /* DefaultClause */); node.statements = createNodeArray(statements); node.transformFlags = propagateChildrenFlags(node.statements); return node; @@ -24119,15 +24779,15 @@ var ts; } // @api function createHeritageClause(token, types) { - var node = createBaseNode(286 /* HeritageClause */); + var node = createBaseNode(288 /* HeritageClause */); node.token = token; node.types = createNodeArray(types); node.transformFlags |= propagateChildrenFlags(node.types); switch (token) { - case 93 /* ExtendsKeyword */: - node.transformFlags |= 256 /* ContainsES2015 */; + case 94 /* ExtendsKeyword */: + node.transformFlags |= 512 /* ContainsES2015 */; break; - case 116 /* ImplementsKeyword */: + case 117 /* ImplementsKeyword */: node.transformFlags |= 1 /* ContainsTypeScript */; break; default: @@ -24143,7 +24803,7 @@ var ts; } // @api function createCatchClause(variableDeclaration, block) { - var node = createBaseNode(287 /* CatchClause */); + var node = createBaseNode(289 /* CatchClause */); variableDeclaration = !ts.isString(variableDeclaration) ? variableDeclaration : createVariableDeclaration(variableDeclaration, /*exclamationToken*/ undefined, /*type*/ undefined, @@ -24154,7 +24814,7 @@ var ts; propagateChildFlags(node.variableDeclaration) | propagateChildFlags(node.block); if (!variableDeclaration) - node.transformFlags |= 16 /* ContainsES2019 */; + node.transformFlags |= 32 /* ContainsES2019 */; return node; } // @api @@ -24169,7 +24829,7 @@ var ts; // // @api function createPropertyAssignment(name, initializer) { - var node = createBaseNamedDeclaration(288 /* PropertyAssignment */, + var node = createBaseNamedDeclaration(290 /* PropertyAssignment */, /*decorators*/ undefined, /*modifiers*/ undefined, name); node.initializer = parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); @@ -24199,13 +24859,13 @@ var ts; } // @api function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createBaseNamedDeclaration(289 /* ShorthandPropertyAssignment */, + var node = createBaseNamedDeclaration(291 /* ShorthandPropertyAssignment */, /*decorators*/ undefined, /*modifiers*/ undefined, name); node.objectAssignmentInitializer = objectAssignmentInitializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(objectAssignmentInitializer); node.transformFlags |= propagateChildFlags(node.objectAssignmentInitializer) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; return node; } function finishUpdateShorthandPropertyAssignment(updated, original) { @@ -24231,12 +24891,12 @@ var ts; } // @api function createSpreadAssignment(expression) { - var node = createBaseNode(290 /* SpreadAssignment */); + var node = createBaseNode(292 /* SpreadAssignment */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 32 /* ContainsES2018 */ | - 16384 /* ContainsObjectRestOrSpread */; + 64 /* ContainsES2018 */ | + 32768 /* ContainsObjectRestOrSpread */; return node; } // @api @@ -24250,7 +24910,7 @@ var ts; // // @api function createEnumMember(name, initializer) { - var node = createBaseNode(291 /* EnumMember */); + var node = createBaseNode(293 /* EnumMember */); node.name = asName(name); node.initializer = initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); node.transformFlags |= @@ -24271,7 +24931,7 @@ var ts; // // @api function createSourceFile(statements, endOfFileToken, flags) { - var node = baseFactory.createBaseSourceFileNode(297 /* SourceFile */); + var node = baseFactory.createBaseSourceFileNode(299 /* SourceFile */); node.statements = createNodeArray(statements); node.endOfFileToken = endOfFileToken; node.flags |= flags; @@ -24288,7 +24948,7 @@ var ts; return node; } function cloneSourceFileWithChanges(source, statements, isDeclarationFile, referencedFiles, typeReferences, hasNoDefaultLib, libReferences) { - var node = baseFactory.createBaseSourceFileNode(297 /* SourceFile */); + var node = baseFactory.createBaseSourceFileNode(299 /* SourceFile */); for (var p in source) { if (p === "emitNode" || ts.hasProperty(node, p) || !ts.hasProperty(source, p)) continue; @@ -24326,7 +24986,7 @@ var ts; // @api function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = createBaseNode(298 /* Bundle */); + var node = createBaseNode(300 /* Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; @@ -24341,7 +25001,7 @@ var ts; } // @api function createUnparsedSource(prologues, syntheticReferences, texts) { - var node = createBaseNode(299 /* UnparsedSource */); + var node = createBaseNode(301 /* UnparsedSource */); node.prologues = prologues; node.syntheticReferences = syntheticReferences; node.texts = texts; @@ -24359,28 +25019,28 @@ var ts; } // @api function createUnparsedPrologue(data) { - return createBaseUnparsedNode(292 /* UnparsedPrologue */, data); + return createBaseUnparsedNode(294 /* UnparsedPrologue */, data); } // @api function createUnparsedPrepend(data, texts) { - var node = createBaseUnparsedNode(293 /* UnparsedPrepend */, data); + var node = createBaseUnparsedNode(295 /* UnparsedPrepend */, data); node.texts = texts; return node; } // @api function createUnparsedTextLike(data, internal) { - return createBaseUnparsedNode(internal ? 295 /* UnparsedInternalText */ : 294 /* UnparsedText */, data); + return createBaseUnparsedNode(internal ? 297 /* UnparsedInternalText */ : 296 /* UnparsedText */, data); } // @api function createUnparsedSyntheticReference(section) { - var node = createBaseNode(296 /* UnparsedSyntheticReference */); + var node = createBaseNode(298 /* UnparsedSyntheticReference */); node.data = section.data; node.section = section; return node; } // @api function createInputFiles() { - var node = createBaseNode(300 /* InputFiles */); + var node = createBaseNode(302 /* InputFiles */); node.javascriptText = ""; node.declarationText = ""; return node; @@ -24391,7 +25051,7 @@ var ts; // @api function createSyntheticExpression(type, isSpread, tupleNameSource) { if (isSpread === void 0) { isSpread = false; } - var node = createBaseNode(227 /* SyntheticExpression */); + var node = createBaseNode(229 /* SyntheticExpression */); node.type = type; node.isSpread = isSpread; node.tupleNameSource = tupleNameSource; @@ -24399,7 +25059,7 @@ var ts; } // @api function createSyntaxList(children) { - var node = createBaseNode(334 /* SyntaxList */); + var node = createBaseNode(342 /* SyntaxList */); node._children = children; return node; } @@ -24414,7 +25074,7 @@ var ts; */ // @api function createNotEmittedStatement(original) { - var node = createBaseNode(335 /* NotEmittedStatement */); + var node = createBaseNode(343 /* NotEmittedStatement */); node.original = original; ts.setTextRange(node, original); return node; @@ -24428,7 +25088,7 @@ var ts; */ // @api function createPartiallyEmittedExpression(expression, original) { - var node = createBaseNode(336 /* PartiallyEmittedExpression */); + var node = createBaseNode(344 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; node.transformFlags |= @@ -24456,7 +25116,7 @@ var ts; } // @api function createCommaListExpression(elements) { - var node = createBaseNode(337 /* CommaListExpression */); + var node = createBaseNode(345 /* CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); node.transformFlags |= propagateChildrenFlags(node.elements); return node; @@ -24473,7 +25133,7 @@ var ts; */ // @api function createEndOfDeclarationMarker(original) { - var node = createBaseNode(339 /* EndOfDeclarationMarker */); + var node = createBaseNode(347 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -24484,14 +25144,14 @@ var ts; */ // @api function createMergeDeclarationMarker(original) { - var node = createBaseNode(338 /* MergeDeclarationMarker */); + var node = createBaseNode(346 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; } // @api function createSyntheticReferenceExpression(expression, thisArg) { - var node = createBaseNode(340 /* SyntheticReferenceExpression */); + var node = createBaseNode(348 /* SyntheticReferenceExpression */); node.expression = expression; node.thisArg = thisArg; node.transformFlags |= @@ -24513,9 +25173,9 @@ var ts; if (node === undefined) { return node; } - var clone = ts.isSourceFile(node) ? baseFactory.createBaseSourceFileNode(297 /* SourceFile */) : - ts.isIdentifier(node) ? baseFactory.createBaseIdentifierNode(78 /* Identifier */) : - ts.isPrivateIdentifier(node) ? baseFactory.createBasePrivateIdentifierNode(79 /* PrivateIdentifier */) : + var clone = ts.isSourceFile(node) ? baseFactory.createBaseSourceFileNode(299 /* SourceFile */) : + ts.isIdentifier(node) ? baseFactory.createBaseIdentifierNode(79 /* Identifier */) : + ts.isPrivateIdentifier(node) ? baseFactory.createBasePrivateIdentifierNode(80 /* PrivateIdentifier */) : !ts.isNodeKind(node.kind) ? baseFactory.createBaseTokenNode(node.kind) : baseFactory.createBaseNode(node.kind); clone.flags |= (node.flags & ~8 /* Synthesized */); @@ -24620,11 +25280,11 @@ var ts; } function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 207 /* ParenthesizedExpression */: return updateParenthesizedExpression(outerExpression, expression); - case 206 /* TypeAssertionExpression */: return updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 224 /* AsExpression */: return updateAsExpression(outerExpression, expression, outerExpression.type); - case 225 /* NonNullExpression */: return updateNonNullExpression(outerExpression, expression); - case 336 /* PartiallyEmittedExpression */: return updatePartiallyEmittedExpression(outerExpression, expression); + case 209 /* ParenthesizedExpression */: return updateParenthesizedExpression(outerExpression, expression); + case 208 /* TypeAssertionExpression */: return updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 226 /* AsExpression */: return updateAsExpression(outerExpression, expression, outerExpression.type); + case 227 /* NonNullExpression */: return updateNonNullExpression(outerExpression, expression); + case 344 /* PartiallyEmittedExpression */: return updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -24671,20 +25331,20 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = ts.skipParentheses(node); switch (target.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return cacheIdentifiers; - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: return false; - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -25087,23 +25747,24 @@ var ts; } function getDefaultTagNameForKind(kind) { switch (kind) { - case 329 /* JSDocTypeTag */: return "type"; - case 327 /* JSDocReturnTag */: return "returns"; - case 328 /* JSDocThisTag */: return "this"; - case 325 /* JSDocEnumTag */: return "enum"; - case 317 /* JSDocAuthorTag */: return "author"; - case 319 /* JSDocClassTag */: return "class"; - case 320 /* JSDocPublicTag */: return "public"; - case 321 /* JSDocPrivateTag */: return "private"; - case 322 /* JSDocProtectedTag */: return "protected"; - case 323 /* JSDocReadonlyTag */: return "readonly"; - case 330 /* JSDocTemplateTag */: return "template"; - case 331 /* JSDocTypedefTag */: return "typedef"; - case 326 /* JSDocParameterTag */: return "param"; - case 333 /* JSDocPropertyTag */: return "prop"; - case 324 /* JSDocCallbackTag */: return "callback"; - case 315 /* JSDocAugmentsTag */: return "augments"; - case 316 /* JSDocImplementsTag */: return "implements"; + case 337 /* JSDocTypeTag */: return "type"; + case 335 /* JSDocReturnTag */: return "returns"; + case 336 /* JSDocThisTag */: return "this"; + case 333 /* JSDocEnumTag */: return "enum"; + case 324 /* JSDocAuthorTag */: return "author"; + case 326 /* JSDocClassTag */: return "class"; + case 327 /* JSDocPublicTag */: return "public"; + case 328 /* JSDocPrivateTag */: return "private"; + case 329 /* JSDocProtectedTag */: return "protected"; + case 330 /* JSDocReadonlyTag */: return "readonly"; + case 331 /* JSDocOverrideTag */: return "override"; + case 338 /* JSDocTemplateTag */: return "template"; + case 339 /* JSDocTypedefTag */: return "typedef"; + case 334 /* JSDocParameterTag */: return "param"; + case 341 /* JSDocPropertyTag */: return "prop"; + case 332 /* JSDocCallbackTag */: return "callback"; + case 322 /* JSDocAugmentsTag */: return "augments"; + case 323 /* JSDocImplementsTag */: return "implements"; default: return ts.Debug.fail("Unsupported kind: " + ts.Debug.formatSyntaxKind(kind)); } @@ -25156,10 +25817,10 @@ var ts; } function propagateIdentifierNameFlags(node) { // An IdentifierName is allowed to be `await` - return propagateChildFlags(node) & ~8388608 /* ContainsPossibleTopLevelAwait */; + return propagateChildFlags(node) & ~16777216 /* ContainsPossibleTopLevelAwait */; } function propagatePropertyNameFlagsOfChild(node, transformFlags) { - return transformFlags | (node.transformFlags & 4096 /* PropertyNamePropagatingFlags */); + return transformFlags | (node.transformFlags & 8192 /* PropertyNamePropagatingFlags */); } function propagateChildFlags(child) { if (!child) @@ -25183,69 +25844,69 @@ var ts; */ /* @internal */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 172 /* FirstTypeNode */ && kind <= 195 /* LastTypeNode */) { + if (kind >= 174 /* FirstTypeNode */ && kind <= 197 /* LastTypeNode */) { return -2 /* TypeExcludes */; } switch (kind) { - case 203 /* CallExpression */: - case 204 /* NewExpression */: - case 199 /* ArrayLiteralExpression */: - return 536879104 /* ArrayLiteralOrCallOrNewExcludes */; - case 256 /* ModuleDeclaration */: - return 546379776 /* ModuleExcludes */; - case 160 /* Parameter */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: + case 201 /* ArrayLiteralExpression */: + return 536887296 /* ArrayLiteralOrCallOrNewExcludes */; + case 258 /* ModuleDeclaration */: + return 555888640 /* ModuleExcludes */; + case 162 /* Parameter */: return 536870912 /* ParameterExcludes */; - case 209 /* ArrowFunction */: - return 547309568 /* ArrowFunctionExcludes */; - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: - return 547313664 /* FunctionExcludes */; - case 250 /* VariableDeclarationList */: - return 537018368 /* VariableDeclarationListExcludes */; - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - return 536905728 /* ClassExcludes */; - case 166 /* Constructor */: - return 547311616 /* ConstructorExcludes */; - case 163 /* PropertyDeclaration */: - return 536875008 /* PropertyExcludes */; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - return 538923008 /* MethodOrAccessorExcludes */; - case 128 /* AnyKeyword */: - case 144 /* NumberKeyword */: - case 155 /* BigIntKeyword */: - case 141 /* NeverKeyword */: - case 147 /* StringKeyword */: - case 145 /* ObjectKeyword */: - case 131 /* BooleanKeyword */: - case 148 /* SymbolKeyword */: - case 113 /* VoidKeyword */: - case 159 /* TypeParameter */: - case 162 /* PropertySignature */: - case 164 /* MethodSignature */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 211 /* ArrowFunction */: + return 557748224 /* ArrowFunctionExcludes */; + case 210 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + return 557756416 /* FunctionExcludes */; + case 252 /* VariableDeclarationList */: + return 537165824 /* VariableDeclarationListExcludes */; + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + return 536940544 /* ClassExcludes */; + case 168 /* Constructor */: + return 557752320 /* ConstructorExcludes */; + case 165 /* PropertyDeclaration */: + return 536879104 /* PropertyExcludes */; + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + return 540975104 /* MethodOrAccessorExcludes */; + case 129 /* AnyKeyword */: + case 145 /* NumberKeyword */: + case 156 /* BigIntKeyword */: + case 142 /* NeverKeyword */: + case 148 /* StringKeyword */: + case 146 /* ObjectKeyword */: + case 132 /* BooleanKeyword */: + case 149 /* SymbolKeyword */: + case 114 /* VoidKeyword */: + case 161 /* TypeParameter */: + case 164 /* PropertySignature */: + case 166 /* MethodSignature */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 173 /* IndexSignature */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: return -2 /* TypeExcludes */; - case 200 /* ObjectLiteralExpression */: - return 536922112 /* ObjectLiteralExcludes */; - case 287 /* CatchClause */: - return 536887296 /* CatchClauseExcludes */; - case 196 /* ObjectBindingPattern */: - case 197 /* ArrayBindingPattern */: - return 536879104 /* BindingPatternExcludes */; - case 206 /* TypeAssertionExpression */: - case 224 /* AsExpression */: - case 336 /* PartiallyEmittedExpression */: - case 207 /* ParenthesizedExpression */: - case 105 /* SuperKeyword */: + case 202 /* ObjectLiteralExpression */: + return 536973312 /* ObjectLiteralExcludes */; + case 289 /* CatchClause */: + return 536903680 /* CatchClauseExcludes */; + case 198 /* ObjectBindingPattern */: + case 199 /* ArrayBindingPattern */: + return 536887296 /* BindingPatternExcludes */; + case 208 /* TypeAssertionExpression */: + case 226 /* AsExpression */: + case 344 /* PartiallyEmittedExpression */: + case 209 /* ParenthesizedExpression */: + case 106 /* SuperKeyword */: return 536870912 /* OuterExpressionExcludes */; - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: return 536870912 /* PropertyAccessExcludes */; default: return 536870912 /* NodeExcludes */; @@ -25544,7 +26205,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 === 297 /* SourceFile */) { + if (node.kind === 299 /* 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."); @@ -26031,13 +26692,27 @@ var ts; /*typeArguments*/ undefined, [moduleExpression, exportsExpression]); } // Class Fields Helpers - function createClassPrivateFieldGetHelper(receiver, privateField) { + function createClassPrivateFieldGetHelper(receiver, state, kind, f) { context.requestEmitHelper(ts.classPrivateFieldGetHelper); - return factory.createCallExpression(getUnscopedHelperName("__classPrivateFieldGet"), /*typeArguments*/ undefined, [receiver, privateField]); + var args; + if (!f) { + args = [receiver, state, factory.createStringLiteral(kind)]; + } + else { + args = [receiver, state, factory.createStringLiteral(kind), f]; + } + return factory.createCallExpression(getUnscopedHelperName("__classPrivateFieldGet"), /*typeArguments*/ undefined, args); } - function createClassPrivateFieldSetHelper(receiver, privateField, value) { + function createClassPrivateFieldSetHelper(receiver, state, value, kind, f) { context.requestEmitHelper(ts.classPrivateFieldSetHelper); - return factory.createCallExpression(getUnscopedHelperName("__classPrivateFieldSet"), /*typeArguments*/ undefined, [receiver, privateField, value]); + var args; + if (!f) { + args = [receiver, state, value, factory.createStringLiteral(kind)]; + } + else { + args = [receiver, state, value, factory.createStringLiteral(kind), f]; + } + return factory.createCallExpression(getUnscopedHelperName("__classPrivateFieldSet"), /*typeArguments*/ undefined, args); } } ts.createEmitHelperFactory = createEmitHelperFactory; @@ -26277,7 +26952,6 @@ var ts; scoped: false, text: "\n var __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n };" }; - // emit output for the __export helper function ts.exportStarHelper = { name: "typescript:export-star", importName: "__exportStar", @@ -26286,18 +26960,116 @@ var ts; priority: 2, text: "\n var __exportStar = (this && this.__exportStar) || function(m, exports) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\n };" }; - // Class fields helpers + /** + * Parameters: + * @param receiver — The object from which the private member will be read. + * @param state — One of the following: + * - A WeakMap used to read a private instance field. + * - A WeakSet used as an instance brand for private instance methods and accessors. + * - A function value that should be the undecorated class constructor used to brand check private static fields, methods, and accessors. + * @param kind — (optional pre TS 4.3, required for TS 4.3+) One of the following values: + * - undefined — Indicates a private instance field (pre TS 4.3). + * - "f" — Indicates a private field (instance or static). + * - "m" — Indicates a private method (instance or static). + * - "a" — Indicates a private accessor (instance or static). + * @param f — (optional pre TS 4.3) Depends on the arguments for state and kind: + * - If kind is "m", this should be the function corresponding to the static or instance method. + * - If kind is "a", this should be the function corresponding to the getter method, or undefined if the getter was not defined. + * - If kind is "f" and state is a function, this should be an object holding the value of a static field, or undefined if the static field declaration has not yet been evaluated. + * Usage: + * This helper will only ever be used by the compiler in the following ways: + * + * Reading from a private instance field (pre TS 4.3): + * __classPrivateFieldGet(, ) + * + * Reading from a private instance field (TS 4.3+): + * __classPrivateFieldGet(, , "f") + * + * Reading from a private instance get accessor (when defined, TS 4.3+): + * __classPrivateFieldGet(, , "a", ) + * + * Reading from a private instance get accessor (when not defined, TS 4.3+): + * __classPrivateFieldGet(, , "a", void 0) + * NOTE: This always results in a runtime error. + * + * Reading from a private instance method (TS 4.3+): + * __classPrivateFieldGet(, , "m", ) + * + * Reading from a private static field (TS 4.3+): + * __classPrivateFieldGet(, , "f", <{ value: any }>) + * + * Reading from a private static get accessor (when defined, TS 4.3+): + * __classPrivateFieldGet(, , "a", ) + * + * Reading from a private static get accessor (when not defined, TS 4.3+): + * __classPrivateFieldGet(, , "a", void 0) + * NOTE: This always results in a runtime error. + * + * Reading from a private static method (TS 4.3+): + * __classPrivateFieldGet(, , "m", ) + */ ts.classPrivateFieldGetHelper = { name: "typescript:classPrivateFieldGet", importName: "__classPrivateFieldGet", scoped: false, - text: "\n var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, privateMap) {\n if (!privateMap.has(receiver)) {\n throw new TypeError(\"attempted to get private field on non-instance\");\n }\n return privateMap.get(receiver);\n };" + text: "\n var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n };" }; + /** + * Parameters: + * @param receiver — The object on which the private member will be set. + * @param state — One of the following: + * - A WeakMap used to store a private instance field. + * - A WeakSet used as an instance brand for private instance methods and accessors. + * - A function value that should be the undecorated class constructor used to brand check private static fields, methods, and accessors. + * @param value — The value to set. + * @param kind — (optional pre TS 4.3, required for TS 4.3+) One of the following values: + * - undefined — Indicates a private instance field (pre TS 4.3). + * - "f" — Indicates a private field (instance or static). + * - "m" — Indicates a private method (instance or static). + * - "a" — Indicates a private accessor (instance or static). + * @param f — (optional pre TS 4.3) Depends on the arguments for state and kind: + * - If kind is "m", this should be the function corresponding to the static or instance method. + * - If kind is "a", this should be the function corresponding to the setter method, or undefined if the setter was not defined. + * - If kind is "f" and state is a function, this should be an object holding the value of a static field, or undefined if the static field declaration has not yet been evaluated. + * Usage: + * This helper will only ever be used by the compiler in the following ways: + * + * Writing to a private instance field (pre TS 4.3): + * __classPrivateFieldSet(, , ) + * + * Writing to a private instance field (TS 4.3+): + * __classPrivateFieldSet(, , , "f") + * + * Writing to a private instance set accessor (when defined, TS 4.3+): + * __classPrivateFieldSet(, , , "a", ) + * + * Writing to a private instance set accessor (when not defined, TS 4.3+): + * __classPrivateFieldSet(, , , "a", void 0) + * NOTE: This always results in a runtime error. + * + * Writing to a private instance method (TS 4.3+): + * __classPrivateFieldSet(, , , "m", ) + * NOTE: This always results in a runtime error. + * + * Writing to a private static field (TS 4.3+): + * __classPrivateFieldSet(, , , "f", <{ value: any }>) + * + * Writing to a private static set accessor (when defined, TS 4.3+): + * __classPrivateFieldSet(, , , "a", ) + * + * Writing to a private static set accessor (when not defined, TS 4.3+): + * __classPrivateFieldSet(, , , "a", void 0) + * NOTE: This always results in a runtime error. + * + * Writing to a private static method (TS 4.3+): + * __classPrivateFieldSet(, , , "m", ) + * NOTE: This always results in a runtime error. + */ ts.classPrivateFieldSetHelper = { name: "typescript:classPrivateFieldSet", importName: "__classPrivateFieldSet", scoped: false, - text: "\n var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, privateMap, value) {\n if (!privateMap.has(receiver)) {\n throw new TypeError(\"attempted to set private field on non-instance\");\n }\n privateMap.set(receiver, value);\n return value;\n };" + text: "\n var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\n };" }; var allUnscopedEmitHelpers; function getAllUnscopedEmitHelpers() { @@ -26386,626 +27158,688 @@ var ts; return node.kind === 17 /* TemplateTail */; } ts.isTemplateTail = isTemplateTail; + // Punctuation + function isDotDotDotToken(node) { + return node.kind === 25 /* DotDotDotToken */; + } + ts.isDotDotDotToken = isDotDotDotToken; + /*@internal*/ + function isCommaToken(node) { + return node.kind === 27 /* CommaToken */; + } + ts.isCommaToken = isCommaToken; + function isPlusToken(node) { + return node.kind === 39 /* PlusToken */; + } + ts.isPlusToken = isPlusToken; + function isMinusToken(node) { + return node.kind === 40 /* MinusToken */; + } + ts.isMinusToken = isMinusToken; + function isAsteriskToken(node) { + return node.kind === 41 /* AsteriskToken */; + } + ts.isAsteriskToken = isAsteriskToken; + /*@internal*/ + function isExclamationToken(node) { + return node.kind === 53 /* ExclamationToken */; + } + ts.isExclamationToken = isExclamationToken; + /*@internal*/ + function isQuestionToken(node) { + return node.kind === 57 /* QuestionToken */; + } + ts.isQuestionToken = isQuestionToken; + /*@internal*/ + function isColonToken(node) { + return node.kind === 58 /* ColonToken */; + } + ts.isColonToken = isColonToken; + /*@internal*/ + function isQuestionDotToken(node) { + return node.kind === 28 /* QuestionDotToken */; + } + ts.isQuestionDotToken = isQuestionDotToken; + /*@internal*/ + function isEqualsGreaterThanToken(node) { + return node.kind === 38 /* EqualsGreaterThanToken */; + } + ts.isEqualsGreaterThanToken = isEqualsGreaterThanToken; // Identifiers function isIdentifier(node) { - return node.kind === 78 /* Identifier */; + return node.kind === 79 /* Identifier */; } ts.isIdentifier = isIdentifier; - // Names - function isQualifiedName(node) { - return node.kind === 157 /* QualifiedName */; - } - ts.isQualifiedName = isQualifiedName; - function isComputedPropertyName(node) { - return node.kind === 158 /* ComputedPropertyName */; - } - ts.isComputedPropertyName = isComputedPropertyName; function isPrivateIdentifier(node) { - return node.kind === 79 /* PrivateIdentifier */; + return node.kind === 80 /* PrivateIdentifier */; } ts.isPrivateIdentifier = isPrivateIdentifier; - // Tokens + // Reserved Words + /* @internal */ + function isExportModifier(node) { + return node.kind === 93 /* ExportKeyword */; + } + ts.isExportModifier = isExportModifier; + /* @internal */ + function isAsyncModifier(node) { + return node.kind === 130 /* AsyncKeyword */; + } + ts.isAsyncModifier = isAsyncModifier; + /* @internal */ + function isAssertsKeyword(node) { + return node.kind === 128 /* AssertsKeyword */; + } + ts.isAssertsKeyword = isAssertsKeyword; + /* @internal */ + function isAwaitKeyword(node) { + return node.kind === 131 /* AwaitKeyword */; + } + ts.isAwaitKeyword = isAwaitKeyword; + /* @internal */ + function isReadonlyKeyword(node) { + return node.kind === 143 /* ReadonlyKeyword */; + } + ts.isReadonlyKeyword = isReadonlyKeyword; + /* @internal */ + function isStaticModifier(node) { + return node.kind === 124 /* StaticKeyword */; + } + ts.isStaticModifier = isStaticModifier; /*@internal*/ function isSuperKeyword(node) { - return node.kind === 105 /* SuperKeyword */; + return node.kind === 106 /* SuperKeyword */; } ts.isSuperKeyword = isSuperKeyword; /*@internal*/ function isImportKeyword(node) { - return node.kind === 99 /* ImportKeyword */; + return node.kind === 100 /* ImportKeyword */; } ts.isImportKeyword = isImportKeyword; - /*@internal*/ - function isCommaToken(node) { - return node.kind === 27 /* CommaToken */; - } - ts.isCommaToken = isCommaToken; - /*@internal*/ - function isQuestionToken(node) { - return node.kind === 57 /* QuestionToken */; + // Names + function isQualifiedName(node) { + return node.kind === 159 /* QualifiedName */; } - ts.isQuestionToken = isQuestionToken; - /*@internal*/ - function isExclamationToken(node) { - return node.kind === 53 /* ExclamationToken */; + ts.isQualifiedName = isQualifiedName; + function isComputedPropertyName(node) { + return node.kind === 160 /* ComputedPropertyName */; } - ts.isExclamationToken = isExclamationToken; + ts.isComputedPropertyName = isComputedPropertyName; // Signature elements function isTypeParameterDeclaration(node) { - return node.kind === 159 /* TypeParameter */; + return node.kind === 161 /* TypeParameter */; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; // TODO(rbuckton): Rename to 'isParameterDeclaration' function isParameter(node) { - return node.kind === 160 /* Parameter */; + return node.kind === 162 /* Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 161 /* Decorator */; + return node.kind === 163 /* Decorator */; } ts.isDecorator = isDecorator; // TypeMember function isPropertySignature(node) { - return node.kind === 162 /* PropertySignature */; + return node.kind === 164 /* PropertySignature */; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 163 /* PropertyDeclaration */; + return node.kind === 165 /* PropertyDeclaration */; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 164 /* MethodSignature */; + return node.kind === 166 /* MethodSignature */; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 165 /* MethodDeclaration */; + return node.kind === 167 /* MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isConstructorDeclaration(node) { - return node.kind === 166 /* Constructor */; + return node.kind === 168 /* Constructor */; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 167 /* GetAccessor */; + return node.kind === 169 /* GetAccessor */; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 168 /* SetAccessor */; + return node.kind === 170 /* SetAccessor */; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 169 /* CallSignature */; + return node.kind === 171 /* CallSignature */; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 170 /* ConstructSignature */; + return node.kind === 172 /* ConstructSignature */; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 171 /* IndexSignature */; + return node.kind === 173 /* IndexSignature */; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; // Type function isTypePredicateNode(node) { - return node.kind === 172 /* TypePredicate */; + return node.kind === 174 /* TypePredicate */; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 173 /* TypeReference */; + return node.kind === 175 /* TypeReference */; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 174 /* FunctionType */; + return node.kind === 176 /* FunctionType */; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 175 /* ConstructorType */; + return node.kind === 177 /* ConstructorType */; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 176 /* TypeQuery */; + return node.kind === 178 /* TypeQuery */; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 177 /* TypeLiteral */; + return node.kind === 179 /* TypeLiteral */; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 178 /* ArrayType */; + return node.kind === 180 /* ArrayType */; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 179 /* TupleType */; + return node.kind === 181 /* TupleType */; } ts.isTupleTypeNode = isTupleTypeNode; function isNamedTupleMember(node) { - return node.kind === 192 /* NamedTupleMember */; + return node.kind === 194 /* NamedTupleMember */; } ts.isNamedTupleMember = isNamedTupleMember; function isOptionalTypeNode(node) { - return node.kind === 180 /* OptionalType */; + return node.kind === 182 /* OptionalType */; } ts.isOptionalTypeNode = isOptionalTypeNode; function isRestTypeNode(node) { - return node.kind === 181 /* RestType */; + return node.kind === 183 /* RestType */; } ts.isRestTypeNode = isRestTypeNode; function isUnionTypeNode(node) { - return node.kind === 182 /* UnionType */; + return node.kind === 184 /* UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 183 /* IntersectionType */; + return node.kind === 185 /* IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 184 /* ConditionalType */; + return node.kind === 186 /* ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 185 /* InferType */; + return node.kind === 187 /* InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 186 /* ParenthesizedType */; + return node.kind === 188 /* ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 187 /* ThisType */; + return node.kind === 189 /* ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 188 /* TypeOperator */; + return node.kind === 190 /* TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 189 /* IndexedAccessType */; + return node.kind === 191 /* IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 190 /* MappedType */; + return node.kind === 192 /* MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 191 /* LiteralType */; + return node.kind === 193 /* LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 195 /* ImportType */; + return node.kind === 197 /* ImportType */; } ts.isImportTypeNode = isImportTypeNode; function isTemplateLiteralTypeSpan(node) { - return node.kind === 194 /* TemplateLiteralTypeSpan */; + return node.kind === 196 /* TemplateLiteralTypeSpan */; } ts.isTemplateLiteralTypeSpan = isTemplateLiteralTypeSpan; function isTemplateLiteralTypeNode(node) { - return node.kind === 193 /* TemplateLiteralType */; + return node.kind === 195 /* TemplateLiteralType */; } ts.isTemplateLiteralTypeNode = isTemplateLiteralTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 196 /* ObjectBindingPattern */; + return node.kind === 198 /* ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 197 /* ArrayBindingPattern */; + return node.kind === 199 /* ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 198 /* BindingElement */; + return node.kind === 200 /* BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 199 /* ArrayLiteralExpression */; + return node.kind === 201 /* ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 200 /* ObjectLiteralExpression */; + return node.kind === 202 /* ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 201 /* PropertyAccessExpression */; + return node.kind === 203 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 202 /* ElementAccessExpression */; + return node.kind === 204 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 203 /* CallExpression */; + return node.kind === 205 /* CallExpression */; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 204 /* NewExpression */; + return node.kind === 206 /* NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 205 /* TaggedTemplateExpression */; + return node.kind === 207 /* TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertionExpression(node) { - return node.kind === 206 /* TypeAssertionExpression */; + return node.kind === 208 /* TypeAssertionExpression */; } ts.isTypeAssertionExpression = isTypeAssertionExpression; function isParenthesizedExpression(node) { - return node.kind === 207 /* ParenthesizedExpression */; + return node.kind === 209 /* ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function isFunctionExpression(node) { - return node.kind === 208 /* FunctionExpression */; + return node.kind === 210 /* FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 209 /* ArrowFunction */; + return node.kind === 211 /* ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 210 /* DeleteExpression */; + return node.kind === 212 /* DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 211 /* TypeOfExpression */; + return node.kind === 213 /* TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 212 /* VoidExpression */; + return node.kind === 214 /* VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 213 /* AwaitExpression */; + return node.kind === 215 /* AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 214 /* PrefixUnaryExpression */; + return node.kind === 216 /* PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 215 /* PostfixUnaryExpression */; + return node.kind === 217 /* PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 216 /* BinaryExpression */; + return node.kind === 218 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 217 /* ConditionalExpression */; + return node.kind === 219 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 218 /* TemplateExpression */; + return node.kind === 220 /* TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 219 /* YieldExpression */; + return node.kind === 221 /* YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 220 /* SpreadElement */; + return node.kind === 222 /* SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 221 /* ClassExpression */; + return node.kind === 223 /* ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 222 /* OmittedExpression */; + return node.kind === 224 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 223 /* ExpressionWithTypeArguments */; + return node.kind === 225 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 224 /* AsExpression */; + return node.kind === 226 /* AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 225 /* NonNullExpression */; + return node.kind === 227 /* NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 226 /* MetaProperty */; + return node.kind === 228 /* MetaProperty */; } ts.isMetaProperty = isMetaProperty; function isSyntheticExpression(node) { - return node.kind === 227 /* SyntheticExpression */; + return node.kind === 229 /* SyntheticExpression */; } ts.isSyntheticExpression = isSyntheticExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 336 /* PartiallyEmittedExpression */; + return node.kind === 344 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isCommaListExpression(node) { - return node.kind === 337 /* CommaListExpression */; + return node.kind === 345 /* CommaListExpression */; } ts.isCommaListExpression = isCommaListExpression; // Misc function isTemplateSpan(node) { - return node.kind === 228 /* TemplateSpan */; + return node.kind === 230 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 229 /* SemicolonClassElement */; + return node.kind === 231 /* SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Elements function isBlock(node) { - return node.kind === 230 /* Block */; + return node.kind === 232 /* Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 232 /* VariableStatement */; + return node.kind === 234 /* VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 231 /* EmptyStatement */; + return node.kind === 233 /* EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 233 /* ExpressionStatement */; + return node.kind === 235 /* ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 234 /* IfStatement */; + return node.kind === 236 /* IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 235 /* DoStatement */; + return node.kind === 237 /* DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 236 /* WhileStatement */; + return node.kind === 238 /* WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 237 /* ForStatement */; + return node.kind === 239 /* ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 238 /* ForInStatement */; + return node.kind === 240 /* ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 239 /* ForOfStatement */; + return node.kind === 241 /* ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 240 /* ContinueStatement */; + return node.kind === 242 /* ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 241 /* BreakStatement */; + return node.kind === 243 /* BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isReturnStatement(node) { - return node.kind === 242 /* ReturnStatement */; + return node.kind === 244 /* ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 243 /* WithStatement */; + return node.kind === 245 /* WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 244 /* SwitchStatement */; + return node.kind === 246 /* SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 245 /* LabeledStatement */; + return node.kind === 247 /* LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 246 /* ThrowStatement */; + return node.kind === 248 /* ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 247 /* TryStatement */; + return node.kind === 249 /* TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 248 /* DebuggerStatement */; + return node.kind === 250 /* DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 249 /* VariableDeclaration */; + return node.kind === 251 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 250 /* VariableDeclarationList */; + return node.kind === 252 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 251 /* FunctionDeclaration */; + return node.kind === 253 /* FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 252 /* ClassDeclaration */; + return node.kind === 254 /* ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 253 /* InterfaceDeclaration */; + return node.kind === 255 /* InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 254 /* TypeAliasDeclaration */; + return node.kind === 256 /* TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 255 /* EnumDeclaration */; + return node.kind === 257 /* EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 256 /* ModuleDeclaration */; + return node.kind === 258 /* ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 257 /* ModuleBlock */; + return node.kind === 259 /* ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 258 /* CaseBlock */; + return node.kind === 260 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 259 /* NamespaceExportDeclaration */; + return node.kind === 261 /* NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 260 /* ImportEqualsDeclaration */; + return node.kind === 262 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 261 /* ImportDeclaration */; + return node.kind === 263 /* ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 262 /* ImportClause */; + return node.kind === 264 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 263 /* NamespaceImport */; + return node.kind === 265 /* NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamespaceExport(node) { - return node.kind === 269 /* NamespaceExport */; + return node.kind === 271 /* NamespaceExport */; } ts.isNamespaceExport = isNamespaceExport; function isNamedImports(node) { - return node.kind === 264 /* NamedImports */; + return node.kind === 266 /* NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 265 /* ImportSpecifier */; + return node.kind === 267 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 266 /* ExportAssignment */; + return node.kind === 268 /* ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 267 /* ExportDeclaration */; + return node.kind === 269 /* ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 268 /* NamedExports */; + return node.kind === 270 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 270 /* ExportSpecifier */; + return node.kind === 272 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 271 /* MissingDeclaration */; + return node.kind === 273 /* MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; function isNotEmittedStatement(node) { - return node.kind === 335 /* NotEmittedStatement */; + return node.kind === 343 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ function isSyntheticReference(node) { - return node.kind === 340 /* SyntheticReferenceExpression */; + return node.kind === 348 /* SyntheticReferenceExpression */; } ts.isSyntheticReference = isSyntheticReference; /* @internal */ function isMergeDeclarationMarker(node) { - return node.kind === 338 /* MergeDeclarationMarker */; + return node.kind === 346 /* MergeDeclarationMarker */; } ts.isMergeDeclarationMarker = isMergeDeclarationMarker; /* @internal */ function isEndOfDeclarationMarker(node) { - return node.kind === 339 /* EndOfDeclarationMarker */; + return node.kind === 347 /* EndOfDeclarationMarker */; } ts.isEndOfDeclarationMarker = isEndOfDeclarationMarker; // Module References function isExternalModuleReference(node) { - return node.kind === 272 /* ExternalModuleReference */; + return node.kind === 274 /* ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 273 /* JsxElement */; + return node.kind === 275 /* JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 274 /* JsxSelfClosingElement */; + return node.kind === 276 /* JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 275 /* JsxOpeningElement */; + return node.kind === 277 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 276 /* JsxClosingElement */; + return node.kind === 278 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 277 /* JsxFragment */; + return node.kind === 279 /* JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 278 /* JsxOpeningFragment */; + return node.kind === 280 /* JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 279 /* JsxClosingFragment */; + return node.kind === 281 /* JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 280 /* JsxAttribute */; + return node.kind === 282 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 281 /* JsxAttributes */; + return node.kind === 283 /* JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 282 /* JsxSpreadAttribute */; + return node.kind === 284 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 283 /* JsxExpression */; + return node.kind === 285 /* JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 284 /* CaseClause */; + return node.kind === 286 /* CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 285 /* DefaultClause */; + return node.kind === 287 /* DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 286 /* HeritageClause */; + return node.kind === 288 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 287 /* CatchClause */; + return node.kind === 289 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 288 /* PropertyAssignment */; + return node.kind === 290 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 289 /* ShorthandPropertyAssignment */; + return node.kind === 291 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 290 /* SpreadAssignment */; + return node.kind === 292 /* SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 291 /* EnumMember */; + return node.kind === 293 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Unparsed // TODO(rbuckton): isUnparsedPrologue function isUnparsedPrepend(node) { - return node.kind === 293 /* UnparsedPrepend */; + return node.kind === 295 /* UnparsedPrepend */; } ts.isUnparsedPrepend = isUnparsedPrepend; // TODO(rbuckton): isUnparsedText @@ -27013,156 +27847,176 @@ var ts; // TODO(rbuckton): isUnparsedSyntheticReference // Top-level nodes function isSourceFile(node) { - return node.kind === 297 /* SourceFile */; + return node.kind === 299 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 298 /* Bundle */; + return node.kind === 300 /* Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 299 /* UnparsedSource */; + return node.kind === 301 /* UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; // TODO(rbuckton): isInputFiles // JSDoc Elements function isJSDocTypeExpression(node) { - return node.kind === 301 /* JSDocTypeExpression */; + return node.kind === 303 /* JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocNameReference(node) { - return node.kind === 302 /* JSDocNameReference */; + return node.kind === 304 /* JSDocNameReference */; } ts.isJSDocNameReference = isJSDocNameReference; + function isJSDocMemberName(node) { + return node.kind === 305 /* JSDocMemberName */; + } + ts.isJSDocMemberName = isJSDocMemberName; + function isJSDocLink(node) { + return node.kind === 318 /* JSDocLink */; + } + ts.isJSDocLink = isJSDocLink; + function isJSDocLinkCode(node) { + return node.kind === 319 /* JSDocLinkCode */; + } + ts.isJSDocLinkCode = isJSDocLinkCode; + function isJSDocLinkPlain(node) { + return node.kind === 320 /* JSDocLinkPlain */; + } + ts.isJSDocLinkPlain = isJSDocLinkPlain; function isJSDocAllType(node) { - return node.kind === 303 /* JSDocAllType */; + return node.kind === 306 /* JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 304 /* JSDocUnknownType */; + return node.kind === 307 /* JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 305 /* JSDocNullableType */; + return node.kind === 308 /* JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 306 /* JSDocNonNullableType */; + return node.kind === 309 /* JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 307 /* JSDocOptionalType */; + return node.kind === 310 /* JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 308 /* JSDocFunctionType */; + return node.kind === 311 /* JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 309 /* JSDocVariadicType */; + return node.kind === 312 /* JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDocNamepathType(node) { - return node.kind === 310 /* JSDocNamepathType */; + return node.kind === 313 /* JSDocNamepathType */; } ts.isJSDocNamepathType = isJSDocNamepathType; function isJSDoc(node) { - return node.kind === 311 /* JSDocComment */; + return node.kind === 314 /* JSDocComment */; } ts.isJSDoc = isJSDoc; function isJSDocTypeLiteral(node) { - return node.kind === 312 /* JSDocTypeLiteral */; + return node.kind === 316 /* JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocSignature(node) { - return node.kind === 313 /* JSDocSignature */; + return node.kind === 317 /* JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; // JSDoc Tags function isJSDocAugmentsTag(node) { - return node.kind === 315 /* JSDocAugmentsTag */; + return node.kind === 322 /* JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocAuthorTag(node) { - return node.kind === 317 /* JSDocAuthorTag */; + return node.kind === 324 /* JSDocAuthorTag */; } ts.isJSDocAuthorTag = isJSDocAuthorTag; function isJSDocClassTag(node) { - return node.kind === 319 /* JSDocClassTag */; + return node.kind === 326 /* JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocCallbackTag(node) { - return node.kind === 324 /* JSDocCallbackTag */; + return node.kind === 332 /* JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocPublicTag(node) { - return node.kind === 320 /* JSDocPublicTag */; + return node.kind === 327 /* JSDocPublicTag */; } ts.isJSDocPublicTag = isJSDocPublicTag; function isJSDocPrivateTag(node) { - return node.kind === 321 /* JSDocPrivateTag */; + return node.kind === 328 /* JSDocPrivateTag */; } ts.isJSDocPrivateTag = isJSDocPrivateTag; function isJSDocProtectedTag(node) { - return node.kind === 322 /* JSDocProtectedTag */; + return node.kind === 329 /* JSDocProtectedTag */; } ts.isJSDocProtectedTag = isJSDocProtectedTag; function isJSDocReadonlyTag(node) { - return node.kind === 323 /* JSDocReadonlyTag */; + return node.kind === 330 /* JSDocReadonlyTag */; } ts.isJSDocReadonlyTag = isJSDocReadonlyTag; + function isJSDocOverrideTag(node) { + return node.kind === 331 /* JSDocOverrideTag */; + } + ts.isJSDocOverrideTag = isJSDocOverrideTag; function isJSDocDeprecatedTag(node) { - return node.kind === 318 /* JSDocDeprecatedTag */; + return node.kind === 325 /* JSDocDeprecatedTag */; } ts.isJSDocDeprecatedTag = isJSDocDeprecatedTag; function isJSDocSeeTag(node) { - return node.kind === 332 /* JSDocSeeTag */; + return node.kind === 340 /* JSDocSeeTag */; } ts.isJSDocSeeTag = isJSDocSeeTag; function isJSDocEnumTag(node) { - return node.kind === 325 /* JSDocEnumTag */; + return node.kind === 333 /* JSDocEnumTag */; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocParameterTag(node) { - return node.kind === 326 /* JSDocParameterTag */; + return node.kind === 334 /* JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 327 /* JSDocReturnTag */; + return node.kind === 335 /* JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocThisTag(node) { - return node.kind === 328 /* JSDocThisTag */; + return node.kind === 336 /* JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocTypeTag(node) { - return node.kind === 329 /* JSDocTypeTag */; + return node.kind === 337 /* JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 330 /* JSDocTemplateTag */; + return node.kind === 338 /* JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 331 /* JSDocTypedefTag */; + return node.kind === 339 /* JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocUnknownTag(node) { - return node.kind === 314 /* JSDocTag */; + return node.kind === 321 /* JSDocTag */; } ts.isJSDocUnknownTag = isJSDocUnknownTag; function isJSDocPropertyTag(node) { - return node.kind === 333 /* JSDocPropertyTag */; + return node.kind === 341 /* JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocImplementsTag(node) { - return node.kind === 316 /* JSDocImplementsTag */; + return node.kind === 323 /* JSDocImplementsTag */; } ts.isJSDocImplementsTag = isJSDocImplementsTag; // Synthesized list /* @internal */ function isSyntaxList(n) { - return n.kind === 334 /* SyntaxList */; + return n.kind === 342 /* SyntaxList */; } ts.isSyntaxList = isSyntaxList; })(ts || (ts = {})); @@ -27179,7 +28033,7 @@ var ts; return ts.setTextRange(factory.createElementAccessExpression(target, memberName.expression), location); } else { - var expression = ts.setTextRange(ts.isIdentifierOrPrivateIdentifier(memberName) + var expression = ts.setTextRange(ts.isMemberName(memberName) ? factory.createPropertyAccessExpression(target, memberName) : factory.createElementAccessExpression(target, memberName), memberName); ts.getOrCreateEmitNode(expression).flags |= 64 /* NoNestedSourceMaps */; @@ -27361,14 +28215,14 @@ var ts; ts.Debug.failBadSyntaxKind(property.name, "Private identifiers are not allowed in object literals."); } switch (property.kind) { - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return createExpressionForAccessorDeclaration(factory, node.properties, property, receiver, !!node.multiLine); - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: return createExpressionForPropertyAssignment(factory, property, receiver); - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(factory, property, receiver); - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: return createExpressionForMethodDeclaration(factory, property, receiver); } } @@ -27421,21 +28275,21 @@ var ts; } ts.startsWithUseStrict = startsWithUseStrict; function isCommaSequence(node) { - return node.kind === 216 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || - node.kind === 337 /* CommaListExpression */; + return node.kind === 218 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || + node.kind === 345 /* CommaListExpression */; } ts.isCommaSequence = isCommaSequence; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 15 /* All */; } switch (node.kind) { - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return (kinds & 1 /* Parentheses */) !== 0; - case 206 /* TypeAssertionExpression */: - case 224 /* AsExpression */: + case 208 /* TypeAssertionExpression */: + case 226 /* AsExpression */: return (kinds & 2 /* TypeAssertions */) !== 0; - case 225 /* NonNullExpression */: + case 227 /* NonNullExpression */: return (kinds & 4 /* NonNullAssertions */) !== 0; - case 336 /* PartiallyEmittedExpression */: + case 344 /* PartiallyEmittedExpression */: return (kinds & 8 /* PartiallyEmittedExpressions */) !== 0; } return false; @@ -27556,10 +28410,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : factory.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 261 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 263 /* ImportDeclaration */ && node.importClause) { return factory.getGeneratedNameForNode(node); } - if (node.kind === 267 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 269 /* ExportDeclaration */ && node.moduleSpecifier) { return factory.getGeneratedNameForNode(node); } return undefined; @@ -27678,7 +28532,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -27690,11 +28544,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 290 /* SpreadAssignment */: + case 292 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -27726,12 +28580,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 160 /* Parameter */: - case 198 /* BindingElement */: + case 162 /* Parameter */: + case 200 /* BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 220 /* SpreadElement */: - case 290 /* SpreadAssignment */: + case 222 /* SpreadElement */: + case 292 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -27749,7 +28603,7 @@ var ts; ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement; function tryGetPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 198 /* BindingElement */: + case 200 /* BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -27764,7 +28618,7 @@ var ts; : propertyName; } break; - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -27779,7 +28633,7 @@ var ts; : propertyName; } break; - case 290 /* SpreadAssignment */: + case 292 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` if (bindingElement.name && ts.isPrivateIdentifier(bindingElement.name)) { return ts.Debug.failBadSyntaxKind(bindingElement.name); @@ -27802,13 +28656,13 @@ var ts; */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 196 /* ObjectBindingPattern */: - case 197 /* ArrayBindingPattern */: - case 199 /* ArrayLiteralExpression */: + case 198 /* ObjectBindingPattern */: + case 199 /* ArrayBindingPattern */: + case 201 /* ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -27829,46 +28683,294 @@ var ts; ts.getJSDocTypeAliasName = getJSDocTypeAliasName; function canHaveModifiers(node) { var kind = node.kind; - return kind === 160 /* Parameter */ - || kind === 162 /* PropertySignature */ - || kind === 163 /* PropertyDeclaration */ - || kind === 164 /* MethodSignature */ - || kind === 165 /* MethodDeclaration */ - || kind === 166 /* Constructor */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */ - || kind === 171 /* IndexSignature */ - || kind === 208 /* FunctionExpression */ - || kind === 209 /* ArrowFunction */ - || kind === 221 /* ClassExpression */ - || kind === 232 /* VariableStatement */ - || kind === 251 /* FunctionDeclaration */ - || kind === 252 /* ClassDeclaration */ - || kind === 253 /* InterfaceDeclaration */ - || kind === 254 /* TypeAliasDeclaration */ - || kind === 255 /* EnumDeclaration */ - || kind === 256 /* ModuleDeclaration */ - || kind === 260 /* ImportEqualsDeclaration */ - || kind === 261 /* ImportDeclaration */ - || kind === 266 /* ExportAssignment */ - || kind === 267 /* ExportDeclaration */; + return kind === 162 /* Parameter */ + || kind === 164 /* PropertySignature */ + || kind === 165 /* PropertyDeclaration */ + || kind === 166 /* MethodSignature */ + || kind === 167 /* MethodDeclaration */ + || kind === 168 /* Constructor */ + || kind === 169 /* GetAccessor */ + || kind === 170 /* SetAccessor */ + || kind === 173 /* IndexSignature */ + || kind === 210 /* FunctionExpression */ + || kind === 211 /* ArrowFunction */ + || kind === 223 /* ClassExpression */ + || kind === 234 /* VariableStatement */ + || kind === 253 /* FunctionDeclaration */ + || kind === 254 /* ClassDeclaration */ + || kind === 255 /* InterfaceDeclaration */ + || kind === 256 /* TypeAliasDeclaration */ + || kind === 257 /* EnumDeclaration */ + || kind === 258 /* ModuleDeclaration */ + || kind === 262 /* ImportEqualsDeclaration */ + || kind === 263 /* ImportDeclaration */ + || kind === 268 /* ExportAssignment */ + || kind === 269 /* ExportDeclaration */; } ts.canHaveModifiers = canHaveModifiers; - /* @internal */ - function isExportModifier(node) { - return node.kind === 92 /* ExportKeyword */; - } - ts.isExportModifier = isExportModifier; - /* @internal */ - function isAsyncModifier(node) { - return node.kind === 129 /* AsyncKeyword */; - } - ts.isAsyncModifier = isAsyncModifier; - /* @internal */ - function isStaticModifier(node) { - return node.kind === 123 /* StaticKeyword */; + ts.isTypeNodeOrTypeParameterDeclaration = ts.or(ts.isTypeNode, ts.isTypeParameterDeclaration); + ts.isQuestionOrExclamationToken = ts.or(ts.isQuestionToken, ts.isExclamationToken); + ts.isIdentifierOrThisTypeNode = ts.or(ts.isIdentifier, ts.isThisTypeNode); + ts.isReadonlyKeywordOrPlusOrMinusToken = ts.or(ts.isReadonlyKeyword, ts.isPlusToken, ts.isMinusToken); + ts.isQuestionOrPlusOrMinusToken = ts.or(ts.isQuestionToken, ts.isPlusToken, ts.isMinusToken); + 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 */ + || ts.isLiteralExpression(node) + || ts.isPrefixUnaryExpression(node); + } + ts.isLiteralTypeLikeExpression = isLiteralTypeLikeExpression; + function isExponentiationOperator(kind) { + return kind === 42 /* AsteriskAsteriskToken */; + } + function isMultiplicativeOperator(kind) { + return kind === 41 /* AsteriskToken */ + || kind === 43 /* SlashToken */ + || kind === 44 /* PercentToken */; + } + function isMultiplicativeOperatorOrHigher(kind) { + return isExponentiationOperator(kind) + || isMultiplicativeOperator(kind); + } + function isAdditiveOperator(kind) { + return kind === 39 /* PlusToken */ + || kind === 40 /* MinusToken */; + } + function isAdditiveOperatorOrHigher(kind) { + return isAdditiveOperator(kind) + || isMultiplicativeOperatorOrHigher(kind); + } + function isShiftOperator(kind) { + return kind === 47 /* LessThanLessThanToken */ + || kind === 48 /* GreaterThanGreaterThanToken */ + || kind === 49 /* 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 */; + } + function isRelationalOperatorOrHigher(kind) { + return isRelationalOperator(kind) + || isShiftOperatorOrHigher(kind); + } + function isEqualityOperator(kind) { + return kind === 34 /* EqualsEqualsToken */ + || kind === 36 /* EqualsEqualsEqualsToken */ + || kind === 35 /* ExclamationEqualsToken */ + || kind === 37 /* ExclamationEqualsEqualsToken */; + } + function isEqualityOperatorOrHigher(kind) { + return isEqualityOperator(kind) + || isRelationalOperatorOrHigher(kind); + } + function isBitwiseOperator(kind) { + return kind === 50 /* AmpersandToken */ + || kind === 51 /* BarToken */ + || kind === 52 /* CaretToken */; + } + function isBitwiseOperatorOrHigher(kind) { + return isBitwiseOperator(kind) + || isEqualityOperatorOrHigher(kind); + } + // NOTE: The version in utilities includes ExclamationToken, which is not a binary operator. + function isLogicalOperator(kind) { + return kind === 55 /* AmpersandAmpersandToken */ + || kind === 56 /* BarBarToken */; + } + function isLogicalOperatorOrHigher(kind) { + return isLogicalOperator(kind) + || isBitwiseOperatorOrHigher(kind); + } + function isAssignmentOperatorOrHigher(kind) { + return kind === 60 /* QuestionQuestionToken */ + || isLogicalOperatorOrHigher(kind) + || ts.isAssignmentOperator(kind); + } + function isBinaryOperator(kind) { + return isAssignmentOperatorOrHigher(kind) + || kind === 27 /* CommaToken */; + } + function isBinaryOperatorToken(node) { + return isBinaryOperator(node.kind); + } + ts.isBinaryOperatorToken = isBinaryOperatorToken; + var BinaryExpressionState; + (function (BinaryExpressionState) { + /** + * Handles walking into a `BinaryExpression`. + * @param machine State machine handler functions + * @param frame The current frame + * @returns The new frame + */ + function enter(machine, stackIndex, stateStack, nodeStack, userStateStack, _resultHolder, outerState) { + var prevUserState = stackIndex > 0 ? userStateStack[stackIndex - 1] : undefined; + ts.Debug.assertEqual(stateStack[stackIndex], enter); + userStateStack[stackIndex] = machine.onEnter(nodeStack[stackIndex], prevUserState, outerState); + stateStack[stackIndex] = nextState(machine, enter); + return stackIndex; + } + BinaryExpressionState.enter = enter; + /** + * Handles walking the `left` side of a `BinaryExpression`. + * @param machine State machine handler functions + * @param frame The current frame + * @returns The new frame + */ + function left(machine, stackIndex, stateStack, nodeStack, userStateStack, _resultHolder, _outerState) { + ts.Debug.assertEqual(stateStack[stackIndex], left); + ts.Debug.assertIsDefined(machine.onLeft); + stateStack[stackIndex] = nextState(machine, left); + var nextNode = machine.onLeft(nodeStack[stackIndex].left, userStateStack[stackIndex], nodeStack[stackIndex]); + if (nextNode) { + checkCircularity(stackIndex, nodeStack, nextNode); + return pushStack(stackIndex, stateStack, nodeStack, userStateStack, nextNode); + } + return stackIndex; + } + BinaryExpressionState.left = left; + /** + * Handles walking the `operatorToken` of a `BinaryExpression`. + * @param machine State machine handler functions + * @param frame The current frame + * @returns The new frame + */ + function operator(machine, stackIndex, stateStack, nodeStack, userStateStack, _resultHolder, _outerState) { + ts.Debug.assertEqual(stateStack[stackIndex], operator); + ts.Debug.assertIsDefined(machine.onOperator); + stateStack[stackIndex] = nextState(machine, operator); + machine.onOperator(nodeStack[stackIndex].operatorToken, userStateStack[stackIndex], nodeStack[stackIndex]); + return stackIndex; + } + BinaryExpressionState.operator = operator; + /** + * Handles walking the `right` side of a `BinaryExpression`. + * @param machine State machine handler functions + * @param frame The current frame + * @returns The new frame + */ + function right(machine, stackIndex, stateStack, nodeStack, userStateStack, _resultHolder, _outerState) { + ts.Debug.assertEqual(stateStack[stackIndex], right); + ts.Debug.assertIsDefined(machine.onRight); + stateStack[stackIndex] = nextState(machine, right); + var nextNode = machine.onRight(nodeStack[stackIndex].right, userStateStack[stackIndex], nodeStack[stackIndex]); + if (nextNode) { + checkCircularity(stackIndex, nodeStack, nextNode); + return pushStack(stackIndex, stateStack, nodeStack, userStateStack, nextNode); + } + return stackIndex; + } + BinaryExpressionState.right = right; + /** + * Handles walking out of a `BinaryExpression`. + * @param machine State machine handler functions + * @param frame The current frame + * @returns The new frame + */ + function exit(machine, stackIndex, stateStack, nodeStack, userStateStack, resultHolder, _outerState) { + ts.Debug.assertEqual(stateStack[stackIndex], exit); + stateStack[stackIndex] = nextState(machine, exit); + var result = machine.onExit(nodeStack[stackIndex], userStateStack[stackIndex]); + if (stackIndex > 0) { + stackIndex--; + if (machine.foldState) { + var side = stateStack[stackIndex] === exit ? "right" : "left"; + userStateStack[stackIndex] = machine.foldState(userStateStack[stackIndex], result, side); + } + } + else { + resultHolder.value = result; + } + return stackIndex; + } + BinaryExpressionState.exit = exit; + /** + * Handles a frame that is already done. + * @returns The `done` state. + */ + function done(_machine, stackIndex, stateStack, _nodeStack, _userStateStack, _resultHolder, _outerState) { + ts.Debug.assertEqual(stateStack[stackIndex], done); + return stackIndex; + } + BinaryExpressionState.done = done; + function nextState(machine, currentState) { + switch (currentState) { + case enter: + if (machine.onLeft) + return left; + // falls through + case left: + if (machine.onOperator) + return operator; + // falls through + case operator: + if (machine.onRight) + return right; + // falls through + case right: return exit; + case exit: return done; + case done: return done; + default: ts.Debug.fail("Invalid state"); + } + } + BinaryExpressionState.nextState = nextState; + function pushStack(stackIndex, stateStack, nodeStack, userStateStack, node) { + stackIndex++; + stateStack[stackIndex] = enter; + nodeStack[stackIndex] = node; + userStateStack[stackIndex] = undefined; + return stackIndex; + } + function checkCircularity(stackIndex, nodeStack, node) { + if (ts.Debug.shouldAssert(2 /* Aggressive */)) { + while (stackIndex >= 0) { + ts.Debug.assert(nodeStack[stackIndex] !== node, "Circular traversal detected."); + stackIndex--; + } + } + } + })(BinaryExpressionState || (BinaryExpressionState = {})); + /** + * Holds state machine handler functions + */ + var BinaryExpressionStateMachine = /** @class */ (function () { + function BinaryExpressionStateMachine(onEnter, onLeft, onOperator, onRight, onExit, foldState) { + this.onEnter = onEnter; + this.onLeft = onLeft; + this.onOperator = onOperator; + this.onRight = onRight; + this.onExit = onExit; + this.foldState = foldState; + } + return BinaryExpressionStateMachine; + }()); + function createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, foldState) { + var machine = new BinaryExpressionStateMachine(onEnter, onLeft, onOperator, onRight, onExit, foldState); + return trampoline; + function trampoline(node, outerState) { + var resultHolder = { value: undefined }; + var stateStack = [BinaryExpressionState.enter]; + var nodeStack = [node]; + var userStateStack = [undefined]; + var stackIndex = 0; + while (stateStack[stackIndex] !== BinaryExpressionState.done) { + stackIndex = stateStack[stackIndex](machine, stackIndex, stateStack, nodeStack, userStateStack, resultHolder, outerState); + } + ts.Debug.assertEqual(stackIndex, 0); + return resultHolder.value; + } } - ts.isStaticModifier = isStaticModifier; + ts.createBinaryExpressionTrampoline = createBinaryExpressionTrampoline; })(ts || (ts = {})); var ts; (function (ts) { @@ -27950,19 +29052,19 @@ 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 <= 156 /* LastToken */) { + if (!node || node.kind <= 158 /* LastToken */) { return; } switch (node.kind) { - case 157 /* QualifiedName */: + case 159 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 159 /* TypeParameter */: + case 161 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -27970,9 +29072,9 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 290 /* SpreadAssignment */: + case 292 /* SpreadAssignment */: return visitNode(cbNode, node.expression); - case 160 /* Parameter */: + case 162 /* Parameter */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -27980,7 +29082,7 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -27988,51 +29090,51 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 162 /* PropertySignature */: + case 164 /* PropertySignature */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.initializer); - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 198 /* BindingElement */: + case 200 /* BindingElement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 173 /* 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 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: - case 209 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 210 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 211 /* ArrowFunction */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -28044,374 +29146,395 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 173 /* TypeReference */: + case 175 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 172 /* TypePredicate */: + case 174 /* TypePredicate */: return visitNode(cbNode, node.assertsModifier) || visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 176 /* TypeQuery */: + case 178 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 177 /* TypeLiteral */: + case 179 /* TypeLiteral */: return visitNodes(cbNode, cbNodes, node.members); - case 178 /* ArrayType */: + case 180 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 179 /* TupleType */: + case 181 /* TupleType */: return visitNodes(cbNode, cbNodes, node.elements); - case 182 /* UnionType */: - case 183 /* IntersectionType */: + case 184 /* UnionType */: + case 185 /* IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 184 /* ConditionalType */: + case 186 /* ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 185 /* InferType */: + case 187 /* InferType */: return visitNode(cbNode, node.typeParameter); - case 195 /* ImportType */: + case 197 /* ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 186 /* ParenthesizedType */: - case 188 /* TypeOperator */: + case 188 /* ParenthesizedType */: + case 190 /* TypeOperator */: return visitNode(cbNode, node.type); - case 189 /* IndexedAccessType */: + case 191 /* IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 190 /* MappedType */: + case 192 /* MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.nameType) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 191 /* LiteralType */: + case 193 /* LiteralType */: return visitNode(cbNode, node.literal); - case 192 /* NamedTupleMember */: + case 194 /* NamedTupleMember */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 196 /* ObjectBindingPattern */: - case 197 /* ArrayBindingPattern */: + case 198 /* ObjectBindingPattern */: + case 199 /* ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.name); - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.argumentExpression); - case 203 /* CallExpression */: - case 204 /* NewExpression */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 206 /* TypeAssertionExpression */: + case 208 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 210 /* DeleteExpression */: + case 212 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 211 /* TypeOfExpression */: + case 213 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 212 /* VoidExpression */: + case 214 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 213 /* AwaitExpression */: + case 215 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 224 /* AsExpression */: + case 226 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 225 /* NonNullExpression */: + case 227 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 226 /* MetaProperty */: + case 228 /* MetaProperty */: return visitNode(cbNode, node.name); - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 220 /* SpreadElement */: + case 222 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 230 /* Block */: - case 257 /* ModuleBlock */: + case 232 /* Block */: + case 259 /* ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 297 /* SourceFile */: + case 299 /* SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 250 /* VariableDeclarationList */: + case 252 /* VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 234 /* IfStatement */: + case 236 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 235 /* DoStatement */: + case 237 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 236 /* WhileStatement */: + case 238 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 240 /* ContinueStatement */: - case 241 /* BreakStatement */: + case 242 /* ContinueStatement */: + case 243 /* BreakStatement */: return visitNode(cbNode, node.label); - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 243 /* WithStatement */: + case 245 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 258 /* CaseBlock */: + case 260 /* CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 284 /* CaseClause */: + case 286 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 285 /* DefaultClause */: + case 287 /* DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 246 /* ThrowStatement */: + case 248 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 247 /* TryStatement */: + case 249 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 161 /* Decorator */: + case 163 /* Decorator */: return visitNode(cbNode, node.expression); - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: 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 253 /* InterfaceDeclaration */: + case 255 /* 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 254 /* TypeAliasDeclaration */: + case 256 /* 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 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 291 /* EnumMember */: + case 293 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 262 /* ImportClause */: + case 264 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 259 /* NamespaceExportDeclaration */: + case 261 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 269 /* NamespaceExport */: + case 271 /* NamespaceExport */: return visitNode(cbNode, node.name); - case 264 /* NamedImports */: - case 268 /* NamedExports */: + case 266 /* NamedImports */: + case 270 /* NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 265 /* ImportSpecifier */: - case 270 /* ExportSpecifier */: + case 267 /* ImportSpecifier */: + case 272 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 218 /* TemplateExpression */: + case 220 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 228 /* TemplateSpan */: + case 230 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 193 /* TemplateLiteralType */: + case 195 /* TemplateLiteralType */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 194 /* TemplateLiteralTypeSpan */: + case 196 /* TemplateLiteralTypeSpan */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.literal); - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 286 /* HeritageClause */: + case 288 /* HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 272 /* ExternalModuleReference */: + case 274 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 271 /* MissingDeclaration */: + case 273 /* MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 337 /* CommaListExpression */: + case 345 /* CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 273 /* JsxElement */: + case 275 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 277 /* JsxFragment */: + case 279 /* JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 274 /* JsxSelfClosingElement */: - case 275 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 281 /* JsxAttributes */: + case 283 /* JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 280 /* JsxAttribute */: + case 282 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 282 /* JsxSpreadAttribute */: + case 284 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 276 /* JsxClosingElement */: + case 278 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 180 /* OptionalType */: - case 181 /* RestType */: - case 301 /* JSDocTypeExpression */: - case 306 /* JSDocNonNullableType */: - case 305 /* JSDocNullableType */: - case 307 /* JSDocOptionalType */: - case 309 /* JSDocVariadicType */: + case 182 /* OptionalType */: + case 183 /* RestType */: + case 303 /* JSDocTypeExpression */: + case 309 /* JSDocNonNullableType */: + case 308 /* JSDocNullableType */: + case 310 /* JSDocOptionalType */: + case 312 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 308 /* JSDocFunctionType */: + case 311 /* JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 311 /* JSDocComment */: - return visitNodes(cbNode, cbNodes, node.tags); - case 332 /* JSDocSeeTag */: + case 314 /* JSDocComment */: + return (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) + || visitNodes(cbNode, cbNodes, node.tags); + case 340 /* JSDocSeeTag */: return visitNode(cbNode, node.tagName) || - visitNode(cbNode, node.name); - case 302 /* JSDocNameReference */: + visitNode(cbNode, node.name) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 304 /* JSDocNameReference */: return visitNode(cbNode, node.name); - case 326 /* JSDocParameterTag */: - case 333 /* JSDocPropertyTag */: + case 305 /* JSDocMemberName */: + return visitNode(cbNode, node.left) || + visitNode(cbNode, node.right); + case 334 /* JSDocParameterTag */: + case 341 /* JSDocPropertyTag */: return visitNode(cbNode, node.tagName) || (node.isNameFirst ? visitNode(cbNode, node.name) || - visitNode(cbNode, node.typeExpression) + visitNode(cbNode, node.typeExpression) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) : visitNode(cbNode, node.typeExpression) || - visitNode(cbNode, node.name)); - case 317 /* JSDocAuthorTag */: - return visitNode(cbNode, node.tagName); - case 316 /* JSDocImplementsTag */: + visitNode(cbNode, node.name)) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 324 /* JSDocAuthorTag */: + return visitNode(cbNode, node.tagName) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 323 /* JSDocImplementsTag */: return visitNode(cbNode, node.tagName) || - visitNode(cbNode, node.class); - case 315 /* JSDocAugmentsTag */: + visitNode(cbNode, node.class) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 322 /* JSDocAugmentsTag */: return visitNode(cbNode, node.tagName) || - visitNode(cbNode, node.class); - case 330 /* JSDocTemplateTag */: + visitNode(cbNode, node.class) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 338 /* JSDocTemplateTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.constraint) || - visitNodes(cbNode, cbNodes, node.typeParameters); - case 331 /* JSDocTypedefTag */: + visitNodes(cbNode, cbNodes, node.typeParameters) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 339 /* JSDocTypedefTag */: return visitNode(cbNode, node.tagName) || (node.typeExpression && - node.typeExpression.kind === 301 /* JSDocTypeExpression */ + node.typeExpression.kind === 303 /* JSDocTypeExpression */ ? visitNode(cbNode, node.typeExpression) || - visitNode(cbNode, node.fullName) + visitNode(cbNode, node.fullName) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) : visitNode(cbNode, node.fullName) || - visitNode(cbNode, node.typeExpression)); - case 324 /* JSDocCallbackTag */: + visitNode(cbNode, node.typeExpression)) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 332 /* JSDocCallbackTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.fullName) || - visitNode(cbNode, node.typeExpression); - case 327 /* JSDocReturnTag */: - case 329 /* JSDocTypeTag */: - case 328 /* JSDocThisTag */: - case 325 /* JSDocEnumTag */: + visitNode(cbNode, node.typeExpression) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 335 /* JSDocReturnTag */: + case 337 /* JSDocTypeTag */: + case 336 /* JSDocThisTag */: + case 333 /* JSDocEnumTag */: return visitNode(cbNode, node.tagName) || - visitNode(cbNode, node.typeExpression); - case 313 /* JSDocSignature */: + visitNode(cbNode, node.typeExpression) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 317 /* JSDocSignature */: return ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 312 /* JSDocTypeLiteral */: + case 318 /* JSDocLink */: + case 319 /* JSDocLinkCode */: + case 320 /* JSDocLinkPlain */: + return visitNode(cbNode, node.name); + case 316 /* JSDocTypeLiteral */: return ts.forEach(node.jsDocPropertyTags, cbNode); - case 314 /* JSDocTag */: - case 319 /* JSDocClassTag */: - case 320 /* JSDocPublicTag */: - case 321 /* JSDocPrivateTag */: - case 322 /* JSDocProtectedTag */: - case 323 /* JSDocReadonlyTag */: - return visitNode(cbNode, node.tagName); - case 336 /* PartiallyEmittedExpression */: + case 321 /* JSDocTag */: + case 326 /* JSDocClassTag */: + case 327 /* JSDocPublicTag */: + case 328 /* JSDocPrivateTag */: + case 329 /* JSDocProtectedTag */: + case 330 /* JSDocReadonlyTag */: + case 325 /* JSDocDeprecatedTag */: + return visitNode(cbNode, node.tagName) + || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 344 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -28431,62 +29554,58 @@ var ts; * and while doing so, handles traversing the structure without relying on the callstack to encode the tree structure. */ function forEachChildRecursively(rootNode, cbNode, cbNodes) { - var stack = [rootNode]; - while (stack.length) { - var parent = stack.pop(); - var res = visitAllPossibleChildren(parent, gatherPossibleChildren(parent)); - if (res) { - return res; - } - } - return; - function gatherPossibleChildren(node) { - var children = []; - forEachChild(node, addWorkItem, addWorkItem); // By using a stack above and `unshift` here, we emulate a depth-first preorder traversal - return children; - function addWorkItem(n) { - children.unshift(n); - } - } - function visitAllPossibleChildren(parent, children) { - for (var _i = 0, children_5 = children; _i < children_5.length; _i++) { - var child = children_5[_i]; - if (ts.isArray(child)) { - if (cbNodes) { - var res = cbNodes(child, parent); - if (res) { - if (res === "skip") - continue; - return res; - } - } - for (var i = child.length - 1; i >= 0; i--) { - var realChild = child[i]; - var res = cbNode(realChild, parent); - if (res) { - if (res === "skip") - continue; - return res; - } - stack.push(realChild); - } - } - else { - stack.push(child); - var res = cbNode(child, parent); + var queue = gatherPossibleChildren(rootNode); + var parents = []; // tracks parent references for elements in queue + while (parents.length < queue.length) { + parents.push(rootNode); + } + while (queue.length !== 0) { + var current = queue.pop(); + var parent = parents.pop(); + if (ts.isArray(current)) { + if (cbNodes) { + var res = cbNodes(current, parent); if (res) { if (res === "skip") continue; return res; } } + for (var i = current.length - 1; i >= 0; --i) { + queue.push(current[i]); + parents.push(parent); + } + } + else { + var res = cbNode(current, parent); + if (res) { + if (res === "skip") + continue; + return res; + } + if (current.kind >= 159 /* 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]; + queue.push(child); + parents.push(current); + } + } } } } ts.forEachChildRecursively = forEachChildRecursively; + function gatherPossibleChildren(node) { + var children = []; + forEachChild(node, addWorkItem, addWorkItem); // By using a stack above and `unshift` here, we emulate a depth-first preorder traversal + return children; + function addWorkItem(n) { + children.unshift(n); + } + } function createSourceFile(fileName, sourceText, languageVersion, setParentNodes, scriptKind) { if (setParentNodes === void 0) { setParentNodes = false; } - ts.tracing.push("parse" /* Parse */, "createSourceFile", { path: fileName }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* Parse */, "createSourceFile", { path: fileName }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeParse"); var result; ts.perfLogger.logStartParseSourceFile(fileName); @@ -28499,7 +29618,7 @@ var ts; ts.perfLogger.logStopParseSourceFile(); ts.performance.mark("afterParse"); ts.performance.measure("Parse", "beforeParse", "afterParse"); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; } ts.createSourceFile = createSourceFile; @@ -28681,11 +29800,12 @@ var ts; // attached to the EOF token. var parseErrorBeforeNextFinishedNode = false; function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes, scriptKind) { + var _a; if (setParentNodes === void 0) { setParentNodes = false; } scriptKind = ts.ensureScriptKind(fileName, scriptKind); if (scriptKind === 6 /* JSON */) { var result_3 = parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes); - ts.convertToObjectWorker(result_3, result_3.parseDiagnostics, /*returnValue*/ false, /*knownRootOptions*/ undefined, /*jsonConversionNotifier*/ undefined); + 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; result_3.typeReferenceDirectives = ts.emptyArray; result_3.libReferenceDirectives = ts.emptyArray; @@ -28725,35 +29845,54 @@ var ts; endOfFileToken = parseTokenNode(); } else { - var expression = void 0; - switch (token()) { - case 22 /* OpenBracketToken */: - expression = parseArrayLiteralExpression(); - break; - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: - case 103 /* NullKeyword */: - expression = parseTokenNode(); - break; - case 40 /* MinusToken */: - if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 58 /* ColonToken */; })) { - expression = parsePrefixUnaryExpression(); - } - else { - expression = parseObjectLiteralExpression(); - } - break; - case 8 /* NumericLiteral */: - case 10 /* StringLiteral */: - if (lookAhead(function () { return nextToken() !== 58 /* ColonToken */; })) { - expression = parseLiteralNode(); + // 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 */) { + var expression_1 = void 0; + switch (token()) { + case 22 /* OpenBracketToken */: + expression_1 = parseArrayLiteralExpression(); + break; + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: + case 104 /* NullKeyword */: + expression_1 = parseTokenNode(); + break; + case 40 /* MinusToken */: + if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 58 /* ColonToken */; })) { + expression_1 = parsePrefixUnaryExpression(); + } + else { + expression_1 = parseObjectLiteralExpression(); + } + break; + case 8 /* NumericLiteral */: + case 10 /* StringLiteral */: + if (lookAhead(function () { return nextToken() !== 58 /* ColonToken */; })) { + expression_1 = parseLiteralNode(); + break; + } + // falls through + default: + expression_1 = parseObjectLiteralExpression(); break; + } + // Error recovery: collect multiple top-level expressions + if (expressions && ts.isArray(expressions)) { + expressions.push(expression_1); + } + else if (expressions) { + expressions = [expressions, expression_1]; + } + else { + expressions = expression_1; + if (token() !== 1 /* EndOfFileToken */) { + parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token); } - // falls through - default: - expression = parseObjectLiteralExpression(); - break; + } } + var expression = ts.isArray(expressions) ? finishNode(factory.createArrayLiteralExpression(expressions), pos) : ts.Debug.checkDefined(expressions); var statement = factory.createExpressionStatement(expression); finishNode(statement, pos); statements = createNodeArray([statement], pos); @@ -28948,7 +30087,7 @@ var ts; return factory.updateSourceFile(sourceFile, ts.setTextRange(factory.createNodeArray(statements), sourceFile.statements)); function containsPossibleTopLevelAwait(node) { return !(node.flags & 32768 /* AwaitContext */) - && !!(node.transformFlags & 8388608 /* ContainsPossibleTopLevelAwait */); + && !!(node.transformFlags & 16777216 /* ContainsPossibleTopLevelAwait */); } function findNextStatementWithAwait(statements, start) { for (var i = start; i < statements.length; i++) { @@ -28989,7 +30128,7 @@ var ts; ts.setTextRangePosWidth(sourceFile, 0, sourceText.length); setExternalModuleIndicator(sourceFile); // If we parsed this as an external module, it may contain top-level await - if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 8388608 /* ContainsPossibleTopLevelAwait */) { + if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 16777216 /* ContainsPossibleTopLevelAwait */) { sourceFile = reparseTopLevelAwait(sourceFile); } sourceFile.text = sourceText; @@ -29169,6 +30308,9 @@ var ts; function reScanLessThanToken() { return currentToken = scanner.reScanLessThanToken(); } + function reScanHashToken() { + return currentToken = scanner.reScanHashToken(); + } function scanJsxIdentifier() { return currentToken = scanner.scanJsxIdentifier(); } @@ -29223,27 +30365,27 @@ var ts; return speculationHelper(callback, 0 /* TryParse */); } function isBindingIdentifier() { - if (token() === 78 /* Identifier */) { + if (token() === 79 /* Identifier */) { return true; } - return token() > 115 /* LastReservedWord */; + return token() > 116 /* LastReservedWord */; } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token() === 78 /* Identifier */) { + if (token() === 79 /* 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() === 124 /* YieldKeyword */ && inYieldContext()) { + if (token() === 125 /* 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() === 130 /* AwaitKeyword */ && inAwaitContext()) { + if (token() === 131 /* AwaitKeyword */ && inAwaitContext()) { return false; } - return token() > 115 /* LastReservedWord */; + return token() > 116 /* LastReservedWord */; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -29356,11 +30498,11 @@ var ts; parseErrorAtCurrentToken(diagnosticMessage, arg0); } var pos = getNodePos(); - var result = kind === 78 /* Identifier */ ? factory.createIdentifier("", /*typeArguments*/ undefined, /*originalKeywordKind*/ undefined) : + var result = kind === 79 /* 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 === 271 /* MissingDeclaration */ ? factory.createMissingDeclaration() : + kind === 273 /* MissingDeclaration */ ? factory.createMissingDeclaration() : factory.createToken(kind); return finishNode(result, pos); } @@ -29375,8 +30517,8 @@ var ts; // with magic property names like '__proto__'. The 'identifiers' object is used to share a single string instance for // each identifier in order to reduce memory consumption. function createIdentifier(isIdentifier, diagnosticMessage, privateIdentifierDiagnosticMessage) { - identifierCount++; if (isIdentifier) { + identifierCount++; var pos = getNodePos(); // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker var originalKeywordKind = token(); @@ -29384,10 +30526,15 @@ var ts; nextTokenWithoutCheck(); return finishNode(factory.createIdentifier(text, /*typeArguments*/ undefined, originalKeywordKind), pos); } - if (token() === 79 /* PrivateIdentifier */) { + if (token() === 80 /* 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 */; })) { + // 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 isReservedWord = scanner.isReservedWord(); @@ -29395,7 +30542,7 @@ var ts; var defaultMessage = isReservedWord ? ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here : ts.Diagnostics.Identifier_expected; - return createMissingNode(78 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg); + return createMissingNode(79 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg); } function parseBindingIdentifier(privateIdentifierDiagnosticMessage) { return createIdentifier(isBindingIdentifier(), /*diagnosticMessage*/ undefined, privateIdentifierDiagnosticMessage); @@ -29420,7 +30567,7 @@ var ts; if (allowComputedPropertyNames && token() === 22 /* OpenBracketToken */) { return parseComputedPropertyName(); } - if (token() === 79 /* PrivateIdentifier */) { + if (token() === 80 /* PrivateIdentifier */) { return parsePrivateIdentifier(); } return parseIdentifierName(); @@ -29466,24 +30613,24 @@ var ts; } function nextTokenCanFollowModifier() { switch (token()) { - case 84 /* ConstKeyword */: + case 85 /* ConstKeyword */: // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 91 /* EnumKeyword */; - case 92 /* ExportKeyword */: + return nextToken() === 92 /* EnumKeyword */; + case 93 /* ExportKeyword */: nextToken(); - if (token() === 87 /* DefaultKeyword */) { + if (token() === 88 /* DefaultKeyword */) { return lookAhead(nextTokenCanFollowDefaultKeyword); } - if (token() === 149 /* TypeKeyword */) { + if (token() === 150 /* TypeKeyword */) { return lookAhead(nextTokenCanFollowExportModifier); } return canFollowExportModifier(); - case 87 /* DefaultKeyword */: + case 88 /* DefaultKeyword */: return nextTokenCanFollowDefaultKeyword(); - case 123 /* StaticKeyword */: + case 124 /* StaticKeyword */: return nextTokenIsOnSameLineAndCanFollowModifier(); - case 134 /* GetKeyword */: - case 146 /* SetKeyword */: + case 135 /* GetKeyword */: + case 147 /* SetKeyword */: nextToken(); return canFollowModifier(); default: @@ -29492,7 +30639,7 @@ var ts; } function canFollowExportModifier() { return token() !== 41 /* AsteriskToken */ - && token() !== 126 /* AsKeyword */ + && token() !== 127 /* AsKeyword */ && token() !== 18 /* OpenBraceToken */ && canFollowModifier(); } @@ -29512,10 +30659,10 @@ var ts; } function nextTokenCanFollowDefaultKeyword() { nextToken(); - return token() === 83 /* ClassKeyword */ || token() === 97 /* FunctionKeyword */ || - token() === 117 /* InterfaceKeyword */ || - (token() === 125 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || - (token() === 129 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 84 /* ClassKeyword */ || token() === 98 /* FunctionKeyword */ || + token() === 118 /* InterfaceKeyword */ || + (token() === 126 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || + (token() === 130 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -29535,7 +30682,7 @@ var ts; // outer module. We just want to consume and move on. return !(token() === 26 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); case 2 /* SwitchClauses */: - return token() === 81 /* CaseKeyword */ || token() === 87 /* DefaultKeyword */; + return token() === 82 /* CaseKeyword */ || token() === 88 /* DefaultKeyword */; case 4 /* TypeMembers */: return lookAhead(isTypeMemberStart); case 5 /* ClassMembers */: @@ -29621,7 +30768,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 93 /* ExtendsKeyword */ || next === 116 /* ImplementsKeyword */; + return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 94 /* ExtendsKeyword */ || next === 117 /* ImplementsKeyword */; } return true; } @@ -29638,8 +30785,8 @@ var ts; return ts.tokenIsIdentifierOrKeywordOrGreaterThan(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 116 /* ImplementsKeyword */ || - token() === 93 /* ExtendsKeyword */) { + if (token() === 117 /* ImplementsKeyword */ || + token() === 94 /* ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -29669,14 +30816,14 @@ var ts; case 23 /* ImportOrExportSpecifiers */: return token() === 19 /* CloseBraceToken */; case 3 /* SwitchClauseStatements */: - return token() === 19 /* CloseBraceToken */ || token() === 81 /* CaseKeyword */ || token() === 87 /* DefaultKeyword */; + return token() === 19 /* CloseBraceToken */ || token() === 82 /* CaseKeyword */ || token() === 88 /* DefaultKeyword */; case 7 /* HeritageClauseElement */: - return token() === 18 /* OpenBraceToken */ || token() === 93 /* ExtendsKeyword */ || token() === 116 /* ImplementsKeyword */; + return token() === 18 /* OpenBraceToken */ || token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; case 8 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); case 19 /* TypeParameters */: // Tokens other than '>' are here for better error recovery - return token() === 31 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 93 /* ExtendsKeyword */ || token() === 116 /* ImplementsKeyword */; + return token() === 31 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; case 11 /* ArgumentExpressions */: // Tokens other than ')' are here for better error recovery return token() === 21 /* CloseParenToken */ || token() === 26 /* SemicolonToken */; @@ -29742,8 +30889,7 @@ var ts; var listPos = getNodePos(); while (!isListTerminator(kind)) { if (isListElement(kind, /*inErrorRecovery*/ false)) { - var element = parseListElement(kind, parseElement); - list.push(element); + list.push(parseListElement(kind, parseElement)); continue; } if (abortParsingListOrMoveToNextToken(kind)) { @@ -29893,20 +31039,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 166 /* Constructor */: - case 171 /* IndexSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 163 /* PropertyDeclaration */: - case 229 /* SemicolonClassElement */: + case 168 /* Constructor */: + case 173 /* IndexSignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 231 /* SemicolonClassElement */: return true; - case 165 /* MethodDeclaration */: + case 167 /* 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 === 78 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 132 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 79 /* Identifier */ && + methodDeclaration.name.originalKeywordKind === 133 /* ConstructorKeyword */; return !nameIsConstructor; } } @@ -29915,8 +31061,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 284 /* CaseClause */: - case 285 /* DefaultClause */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: return true; } } @@ -29925,58 +31071,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 232 /* VariableStatement */: - case 230 /* Block */: - case 234 /* IfStatement */: - case 233 /* ExpressionStatement */: - case 246 /* ThrowStatement */: - case 242 /* ReturnStatement */: - case 244 /* SwitchStatement */: - case 241 /* BreakStatement */: - case 240 /* ContinueStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 237 /* ForStatement */: - case 236 /* WhileStatement */: - case 243 /* WithStatement */: - case 231 /* EmptyStatement */: - case 247 /* TryStatement */: - case 245 /* LabeledStatement */: - case 235 /* DoStatement */: - case 248 /* DebuggerStatement */: - case 261 /* ImportDeclaration */: - case 260 /* ImportEqualsDeclaration */: - case 267 /* ExportDeclaration */: - case 266 /* ExportAssignment */: - case 256 /* ModuleDeclaration */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 253 /* FunctionDeclaration */: + case 234 /* VariableStatement */: + case 232 /* Block */: + case 236 /* IfStatement */: + case 235 /* ExpressionStatement */: + case 248 /* ThrowStatement */: + case 244 /* ReturnStatement */: + case 246 /* SwitchStatement */: + case 243 /* BreakStatement */: + case 242 /* ContinueStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 239 /* ForStatement */: + case 238 /* WhileStatement */: + case 245 /* WithStatement */: + case 233 /* EmptyStatement */: + case 249 /* TryStatement */: + case 247 /* LabeledStatement */: + case 237 /* DoStatement */: + case 250 /* DebuggerStatement */: + case 263 /* ImportDeclaration */: + case 262 /* ImportEqualsDeclaration */: + case 269 /* ExportDeclaration */: + case 268 /* ExportAssignment */: + case 258 /* ModuleDeclaration */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 257 /* EnumDeclaration */: + case 256 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 291 /* EnumMember */; + return node.kind === 293 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 170 /* ConstructSignature */: - case 164 /* MethodSignature */: - case 171 /* IndexSignature */: - case 162 /* PropertySignature */: - case 169 /* CallSignature */: + case 172 /* ConstructSignature */: + case 166 /* MethodSignature */: + case 173 /* IndexSignature */: + case 164 /* PropertySignature */: + case 171 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 249 /* VariableDeclaration */) { + if (node.kind !== 251 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -29997,7 +31143,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 160 /* Parameter */) { + if (node.kind !== 162 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -30164,12 +31310,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(78 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } } - if (token() === 79 /* PrivateIdentifier */) { + if (token() === 80 /* PrivateIdentifier */) { var node = parsePrivateIdentifier(); - return allowPrivateIdentifiers ? node : createMissingNode(78 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return allowPrivateIdentifiers ? node : createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } @@ -30278,14 +31424,14 @@ var ts; // If true, we should abort parsing an error function. function typeHasArrowFunctionBlockingParseError(node) { switch (node.kind) { - case 173 /* TypeReference */: + case 175 /* TypeReference */: return ts.nodeIsMissing(node.typeName); - case 174 /* FunctionType */: - case 175 /* ConstructorType */: { + case 176 /* FunctionType */: + case 177 /* ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 186 /* ParenthesizedType */: + case 188 /* ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -30327,7 +31473,7 @@ var ts; token() === 19 /* CloseBraceToken */ || token() === 21 /* CloseParenToken */ || token() === 31 /* GreaterThanToken */ || - token() === 62 /* EqualsToken */ || + token() === 63 /* EqualsToken */ || token() === 51 /* BarToken */) { return finishNode(factory.createJSDocUnknownType(), pos); } @@ -30349,7 +31495,7 @@ var ts; function parseJSDocParameter() { var pos = getNodePos(); var name; - if (token() === 107 /* ThisKeyword */ || token() === 102 /* NewKeyword */) { + if (token() === 108 /* ThisKeyword */ || token() === 103 /* NewKeyword */) { name = parseIdentifierName(); parseExpected(58 /* ColonToken */); } @@ -30365,7 +31511,7 @@ var ts; function parseJSDocType() { scanner.setInJSDocType(true); var pos = getNodePos(); - if (parseOptional(139 /* ModuleKeyword */)) { + if (parseOptional(140 /* 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) { @@ -30388,7 +31534,7 @@ var ts; if (hasDotDotDot) { type = finishNode(factory.createJSDocVariadicType(type), pos); } - if (token() === 62 /* EqualsToken */) { + if (token() === 63 /* EqualsToken */) { nextToken(); return finishNode(factory.createJSDocOptionalType(type), pos); } @@ -30396,7 +31542,7 @@ var ts; } function parseTypeQuery() { var pos = getNodePos(); - parseExpected(111 /* TypeOfKeyword */); + parseExpected(112 /* TypeOfKeyword */); return finishNode(factory.createTypeQueryNode(parseEntityName(/*allowReservedWords*/ true)), pos); } function parseTypeParameter() { @@ -30404,7 +31550,7 @@ var ts; var name = parseIdentifier(); var constraint; var expression; - if (parseOptional(93 /* ExtendsKeyword */)) { + if (parseOptional(94 /* 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 @@ -30423,7 +31569,7 @@ var ts; expression = parseUnaryExpressionOrHigher(); } } - var defaultType = parseOptional(62 /* EqualsToken */) ? parseType() : undefined; + var defaultType = parseOptional(63 /* EqualsToken */) ? parseType() : undefined; var node = factory.createTypeParameterDeclaration(name, constraint, defaultType); node.expression = expression; return finishNode(node, pos); @@ -30466,19 +31612,21 @@ var ts; function parseParameterWorker(inOuterAwaitContext) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - if (token() === 107 /* ThisKeyword */) { - var node_1 = factory.createParameterDeclaration( - /*decorators*/ undefined, + // 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 node_1 = factory.createParameterDeclaration(decorators, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, createIdentifier(/*isIdentifier*/ true), /*questionToken*/ undefined, parseTypeAnnotation(), /*initializer*/ undefined); + if (decorators) { + parseErrorAtRange(decorators[0], ts.Diagnostics.Decorators_may_not_be_applied_to_this_parameters); + } return withJSDoc(finishNode(node_1, pos), hasJSDoc); } - // 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(); var savedTopLevel = topLevel; topLevel = false; var modifiers = parseModifiers(); @@ -30565,14 +31713,14 @@ var ts; function parseSignatureMember(kind) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - if (kind === 170 /* ConstructSignature */) { - parseExpected(102 /* NewKeyword */); + if (kind === 172 /* ConstructSignature */) { + parseExpected(103 /* NewKeyword */); } var typeParameters = parseTypeParameters(); var parameters = parseParameters(4 /* Type */); var type = parseReturnType(58 /* ColonToken */, /*isType*/ true); parseTypeMemberSemicolon(); - var node = kind === 169 /* CallSignature */ + var node = kind === 171 /* CallSignature */ ? factory.createCallSignature(typeParameters, parameters, type) : factory.createConstructSignature(typeParameters, parameters, type); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -30655,7 +31803,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() === 62 /* EqualsToken */) + if (token() === 63 /* EqualsToken */) node.initializer = parseInitializer(); } parseTypeMemberSemicolon(); @@ -30663,7 +31811,10 @@ var ts; } function isTypeMemberStart() { // Return true if we have the start of a signature member - if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + if (token() === 20 /* OpenParenToken */ || + token() === 29 /* LessThanToken */ || + token() === 135 /* GetKeyword */ || + token() === 147 /* SetKeyword */) { return true; } var idToken = false; @@ -30695,14 +31846,20 @@ var ts; } function parseTypeMember() { if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { - return parseSignatureMember(169 /* CallSignature */); + return parseSignatureMember(171 /* CallSignature */); } - if (token() === 102 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(170 /* ConstructSignature */); + if (token() === 103 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { + return parseSignatureMember(172 /* ConstructSignature */); } var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiers(); + if (parseContextualModifier(135 /* GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 169 /* GetAccessor */); + } + if (parseContextualModifier(147 /* SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 170 /* SetAccessor */); + } if (isIndexSignature()) { return parseIndexSignatureDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers); } @@ -30742,17 +31899,17 @@ var ts; function isStartOfMappedType() { nextToken(); if (token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { - return nextToken() === 142 /* ReadonlyKeyword */; + return nextToken() === 143 /* ReadonlyKeyword */; } - if (token() === 142 /* ReadonlyKeyword */) { + if (token() === 143 /* ReadonlyKeyword */) { nextToken(); } - return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 100 /* InKeyword */; + return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 101 /* InKeyword */; } function parseMappedTypeParameter() { var pos = getNodePos(); var name = parseIdentifierName(); - parseExpected(100 /* InKeyword */); + parseExpected(101 /* InKeyword */); var type = parseType(); return finishNode(factory.createTypeParameterDeclaration(name, type, /*defaultType*/ undefined), pos); } @@ -30760,15 +31917,15 @@ var ts; var pos = getNodePos(); parseExpected(18 /* OpenBraceToken */); var readonlyToken; - if (token() === 142 /* ReadonlyKeyword */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { + if (token() === 143 /* ReadonlyKeyword */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { readonlyToken = parseTokenNode(); - if (readonlyToken.kind !== 142 /* ReadonlyKeyword */) { - parseExpected(142 /* ReadonlyKeyword */); + if (readonlyToken.kind !== 143 /* ReadonlyKeyword */) { + parseExpected(143 /* ReadonlyKeyword */); } } parseExpected(22 /* OpenBracketToken */); var typeParameter = parseMappedTypeParameter(); - var nameType = parseOptional(126 /* AsKeyword */) ? parseType() : undefined; + var nameType = parseOptional(127 /* AsKeyword */) ? parseType() : undefined; parseExpected(23 /* CloseBracketToken */); var questionToken; if (token() === 57 /* QuestionToken */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { @@ -30832,10 +31989,10 @@ var ts; } function parseModifiersForConstructorType() { var modifiers; - if (token() === 125 /* AbstractKeyword */) { + if (token() === 126 /* AbstractKeyword */) { var pos = getNodePos(); nextToken(); - var modifier = finishNode(factory.createToken(125 /* AbstractKeyword */), pos); + var modifier = finishNode(factory.createToken(126 /* AbstractKeyword */), pos); modifiers = createNodeArray([modifier], pos); } return modifiers; @@ -30844,7 +32001,7 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiersForConstructorType(); - var isConstructorType = parseOptional(102 /* NewKeyword */); + var isConstructorType = parseOptional(103 /* NewKeyword */); var typeParameters = parseTypeParameters(); var parameters = parseParameters(4 /* Type */); var type = parseReturnType(38 /* EqualsGreaterThanToken */, /*isType*/ false); @@ -30864,7 +32021,7 @@ var ts; if (negative) { nextToken(); } - var expression = token() === 109 /* TrueKeyword */ || token() === 94 /* FalseKeyword */ || token() === 103 /* NullKeyword */ ? + var expression = token() === 110 /* TrueKeyword */ || token() === 95 /* FalseKeyword */ || token() === 104 /* NullKeyword */ ? parseTokenNode() : parseLiteralLikeNode(token()); if (negative) { @@ -30874,13 +32031,13 @@ var ts; } function isStartOfTypeOfImportType() { nextToken(); - return token() === 99 /* ImportKeyword */; + return token() === 100 /* ImportKeyword */; } function parseImportType() { sourceFlags |= 1048576 /* PossiblyContainsDynamicImport */; var pos = getNodePos(); - var isTypeOf = parseOptional(111 /* TypeOfKeyword */); - parseExpected(99 /* ImportKeyword */); + var isTypeOf = parseOptional(112 /* TypeOfKeyword */); + parseExpected(100 /* ImportKeyword */); parseExpected(20 /* OpenParenToken */); var type = parseType(); parseExpected(21 /* CloseParenToken */); @@ -30894,19 +32051,19 @@ var ts; } function parseNonArrayType() { switch (token()) { - case 128 /* AnyKeyword */: - case 152 /* UnknownKeyword */: - case 147 /* StringKeyword */: - case 144 /* NumberKeyword */: - case 155 /* BigIntKeyword */: - case 148 /* SymbolKeyword */: - case 131 /* BooleanKeyword */: - case 150 /* UndefinedKeyword */: - case 141 /* NeverKeyword */: - case 145 /* ObjectKeyword */: + case 129 /* AnyKeyword */: + case 153 /* UnknownKeyword */: + case 148 /* StringKeyword */: + case 145 /* NumberKeyword */: + case 156 /* BigIntKeyword */: + case 149 /* SymbolKeyword */: + case 132 /* BooleanKeyword */: + case 151 /* UndefinedKeyword */: + case 142 /* NeverKeyword */: + case 146 /* ObjectKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. return tryParse(parseKeywordAndNoDot) || parseTypeReference(); - case 65 /* AsteriskEqualsToken */: + case 66 /* AsteriskEqualsToken */: // If there is '*=', treat it as * followed by postfix = scanner.reScanAsteriskEqualsToken(); // falls through @@ -30918,7 +32075,7 @@ var ts; // falls through case 57 /* QuestionToken */: return parseJSDocUnknownOrNullableType(); - case 97 /* FunctionKeyword */: + case 98 /* FunctionKeyword */: return parseJSDocFunctionType(); case 53 /* ExclamationToken */: return parseJSDocNonNullableType(); @@ -30926,24 +32083,24 @@ var ts; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: - case 103 /* NullKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: + case 104 /* NullKeyword */: return parseLiteralTypeNode(); case 40 /* MinusToken */: return lookAhead(nextTokenIsNumericOrBigIntLiteral) ? parseLiteralTypeNode(/*negative*/ true) : parseTypeReference(); - case 113 /* VoidKeyword */: + case 114 /* VoidKeyword */: return parseTokenNode(); - case 107 /* ThisKeyword */: { + case 108 /* ThisKeyword */: { var thisKeyword = parseThisTypeNode(); - if (token() === 137 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 138 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 111 /* TypeOfKeyword */: + case 112 /* TypeOfKeyword */: return lookAhead(isStartOfTypeOfImportType) ? parseImportType() : parseTypeQuery(); case 18 /* OpenBraceToken */: return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral(); @@ -30951,9 +32108,9 @@ var ts; return parseTupleType(); case 20 /* OpenParenToken */: return parseParenthesizedType(); - case 99 /* ImportKeyword */: + case 100 /* ImportKeyword */: return parseImportType(); - case 127 /* AssertsKeyword */: + case 128 /* AssertsKeyword */: return lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? parseAssertsTypePredicate() : parseTypeReference(); case 15 /* TemplateHead */: return parseTemplateType(); @@ -30963,44 +32120,44 @@ var ts; } function isStartOfType(inStartOfParameter) { switch (token()) { - case 128 /* AnyKeyword */: - case 152 /* UnknownKeyword */: - case 147 /* StringKeyword */: - case 144 /* NumberKeyword */: - case 155 /* BigIntKeyword */: - case 131 /* BooleanKeyword */: - case 142 /* ReadonlyKeyword */: - case 148 /* SymbolKeyword */: - case 151 /* UniqueKeyword */: - case 113 /* VoidKeyword */: - case 150 /* UndefinedKeyword */: - case 103 /* NullKeyword */: - case 107 /* ThisKeyword */: - case 111 /* TypeOfKeyword */: - case 141 /* NeverKeyword */: + case 129 /* AnyKeyword */: + case 153 /* UnknownKeyword */: + case 148 /* StringKeyword */: + case 145 /* NumberKeyword */: + case 156 /* BigIntKeyword */: + case 132 /* BooleanKeyword */: + case 143 /* ReadonlyKeyword */: + case 149 /* SymbolKeyword */: + case 152 /* UniqueKeyword */: + case 114 /* VoidKeyword */: + case 151 /* UndefinedKeyword */: + case 104 /* NullKeyword */: + case 108 /* ThisKeyword */: + case 112 /* TypeOfKeyword */: + case 142 /* NeverKeyword */: case 18 /* OpenBraceToken */: case 22 /* OpenBracketToken */: case 29 /* LessThanToken */: case 51 /* BarToken */: case 50 /* AmpersandToken */: - case 102 /* NewKeyword */: + case 103 /* NewKeyword */: case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: - case 145 /* ObjectKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: + case 146 /* ObjectKeyword */: case 41 /* AsteriskToken */: case 57 /* QuestionToken */: case 53 /* ExclamationToken */: case 25 /* DotDotDotToken */: - case 135 /* InferKeyword */: - case 99 /* ImportKeyword */: - case 127 /* AssertsKeyword */: + case 136 /* InferKeyword */: + case 100 /* ImportKeyword */: + case 128 /* AssertsKeyword */: case 14 /* NoSubstitutionTemplateLiteral */: case 15 /* TemplateHead */: return true; - case 97 /* FunctionKeyword */: + case 98 /* FunctionKeyword */: return !inStartOfParameter; case 40 /* MinusToken */: return !inStartOfParameter && lookAhead(nextTokenIsNumericOrBigIntLiteral); @@ -31064,17 +32221,17 @@ var ts; } function parseInferType() { var pos = getNodePos(); - parseExpected(135 /* InferKeyword */); + parseExpected(136 /* InferKeyword */); return finishNode(factory.createInferTypeNode(parseTypeParameterOfInferType()), pos); } function parseTypeOperatorOrHigher() { var operator = token(); switch (operator) { - case 138 /* KeyOfKeyword */: - case 151 /* UniqueKeyword */: - case 142 /* ReadonlyKeyword */: + case 139 /* KeyOfKeyword */: + case 152 /* UniqueKeyword */: + case 143 /* ReadonlyKeyword */: return parseTypeOperator(operator); - case 135 /* InferKeyword */: + case 136 /* InferKeyword */: return parseInferType(); } return parsePostfixTypeOrHigher(); @@ -31124,7 +32281,7 @@ var ts; } function nextTokenIsNewKeyword() { nextToken(); - return token() === 102 /* NewKeyword */; + return token() === 103 /* NewKeyword */; } function isStartOfFunctionTypeOrConstructorType() { if (token() === 29 /* LessThanToken */) { @@ -31133,15 +32290,15 @@ var ts; if (token() === 20 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType)) { return true; } - return token() === 102 /* NewKeyword */ || - token() === 125 /* AbstractKeyword */ && lookAhead(nextTokenIsNewKeyword); + return token() === 103 /* NewKeyword */ || + token() === 126 /* AbstractKeyword */ && lookAhead(nextTokenIsNewKeyword); } function skipParameterStart() { if (ts.isModifierKind(token())) { // Skip modifiers parseModifiers(); } - if (isIdentifier() || token() === 107 /* ThisKeyword */) { + if (isIdentifier() || token() === 108 /* ThisKeyword */) { nextToken(); return true; } @@ -31164,7 +32321,7 @@ var ts; // 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() === 62 /* EqualsToken */) { + token() === 57 /* QuestionToken */ || token() === 63 /* EqualsToken */) { // ( xxx : // ( xxx , // ( xxx ? @@ -31194,16 +32351,16 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 137 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 138 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } } function parseAssertsTypePredicate() { var pos = getNodePos(); - var assertsModifier = parseExpectedToken(127 /* AssertsKeyword */); - var parameterName = token() === 107 /* ThisKeyword */ ? parseThisTypeNode() : parseIdentifier(); - var type = parseOptional(137 /* IsKeyword */) ? parseType() : undefined; + var assertsModifier = parseExpectedToken(128 /* AssertsKeyword */); + var parameterName = token() === 108 /* ThisKeyword */ ? parseThisTypeNode() : parseIdentifier(); + var type = parseOptional(138 /* IsKeyword */) ? parseType() : undefined; return finishNode(factory.createTypePredicateNode(assertsModifier, parameterName, type), pos); } function parseType() { @@ -31217,7 +32374,7 @@ var ts; } var pos = getNodePos(); var type = parseUnionTypeOrHigher(); - if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(93 /* ExtendsKeyword */)) { + if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(94 /* ExtendsKeyword */)) { // The type following 'extends' is not permitted to be another conditional type var extendsType = parseTypeWorker(/*noConditionalTypes*/ true); parseExpected(57 /* QuestionToken */); @@ -31234,11 +32391,11 @@ var ts; // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token()) { - case 107 /* ThisKeyword */: - case 105 /* SuperKeyword */: - case 103 /* NullKeyword */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: + case 108 /* ThisKeyword */: + case 106 /* SuperKeyword */: + case 104 /* NullKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: @@ -31247,14 +32404,14 @@ var ts; case 20 /* OpenParenToken */: case 22 /* OpenBracketToken */: case 18 /* OpenBraceToken */: - case 97 /* FunctionKeyword */: - case 83 /* ClassKeyword */: - case 102 /* NewKeyword */: + case 98 /* FunctionKeyword */: + case 84 /* ClassKeyword */: + case 103 /* NewKeyword */: case 43 /* SlashToken */: - case 67 /* SlashEqualsToken */: - case 78 /* Identifier */: + case 68 /* SlashEqualsToken */: + case 79 /* Identifier */: return true; - case 99 /* ImportKeyword */: + case 100 /* ImportKeyword */: return lookAhead(nextTokenIsOpenParenOrLessThanOrDot); default: return isIdentifier(); @@ -31269,15 +32426,15 @@ var ts; case 40 /* MinusToken */: case 54 /* TildeToken */: case 53 /* ExclamationToken */: - case 88 /* DeleteKeyword */: - case 111 /* TypeOfKeyword */: - case 113 /* VoidKeyword */: + case 89 /* DeleteKeyword */: + case 112 /* TypeOfKeyword */: + case 114 /* VoidKeyword */: case 45 /* PlusPlusToken */: case 46 /* MinusMinusToken */: case 29 /* LessThanToken */: - case 130 /* AwaitKeyword */: - case 124 /* YieldKeyword */: - case 79 /* PrivateIdentifier */: + case 131 /* AwaitKeyword */: + case 125 /* YieldKeyword */: + case 80 /* 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. @@ -31296,8 +32453,8 @@ var ts; function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. return token() !== 18 /* OpenBraceToken */ && - token() !== 97 /* FunctionKeyword */ && - token() !== 83 /* ClassKeyword */ && + token() !== 98 /* FunctionKeyword */ && + token() !== 84 /* ClassKeyword */ && token() !== 59 /* AtToken */ && isStartOfExpression(); } @@ -31322,7 +32479,7 @@ var ts; return expr; } function parseInitializer() { - return parseOptional(62 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; + return parseOptional(63 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; } function parseAssignmentExpressionOrHigher() { // AssignmentExpression[in,yield]: @@ -31368,7 +32525,7 @@ var ts; // 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 === 78 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { + if (expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(pos, expr, /*asyncModifier*/ undefined); } // Now see if we might be in cases '2' or '3'. @@ -31384,7 +32541,7 @@ var ts; return parseConditionalExpressionRest(expr, pos); } function isYieldExpression() { - if (token() === 124 /* YieldKeyword */) { + if (token() === 125 /* 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()) { @@ -31464,7 +32621,7 @@ 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() === 129 /* AsyncKeyword */) { + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */ || token() === 130 /* AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } if (token() === 38 /* EqualsGreaterThanToken */) { @@ -31477,7 +32634,7 @@ var ts; return 0 /* False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 129 /* AsyncKeyword */) { + if (token() === 130 /* AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0 /* False */; @@ -31521,13 +32678,13 @@ var ts; // 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 !== 129 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { + if (ts.isModifierKind(second) && second !== 130 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { return 1 /* 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 !== 107 /* ThisKeyword */) { + if (!isIdentifier() && second !== 108 /* ThisKeyword */) { return 0 /* False */; } switch (nextToken()) { @@ -31538,13 +32695,13 @@ var ts; case 57 /* 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() === 62 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { + if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 63 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { return 1 /* True */; } // Otherwise it is definitely not a lambda. return 0 /* False */; case 27 /* CommaToken */: - case 62 /* EqualsToken */: + case 63 /* EqualsToken */: case 21 /* CloseParenToken */: // If we have "(a," or "(a=" or "(a)" this *could* be an arrow function return 2 /* Unknown */; @@ -31563,10 +32720,10 @@ var ts; if (languageVariant === 1 /* JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 93 /* ExtendsKeyword */) { + if (third === 94 /* ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 62 /* EqualsToken */: + case 63 /* EqualsToken */: case 31 /* GreaterThanToken */: return false; default: @@ -31600,7 +32757,7 @@ var ts; } function tryParseAsyncSimpleArrowFunctionExpression() { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" - if (token() === 129 /* AsyncKeyword */) { + if (token() === 130 /* AsyncKeyword */) { if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) { var pos = getNodePos(); var asyncModifier = parseModifiersForArrowFunction(); @@ -31614,7 +32771,7 @@ 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() === 129 /* AsyncKeyword */) { + if (token() === 130 /* 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" @@ -31623,7 +32780,7 @@ var ts; } // Check for un-parenthesized AsyncArrowFunction var expr = parseBinaryExpressionOrHigher(0 /* Lowest */); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 78 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { + if (!scanner.hasPrecedingLineBreak() && expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { return 1 /* True */; } } @@ -31688,8 +32845,8 @@ var ts; return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */); } if (token() !== 26 /* SemicolonToken */ && - token() !== 97 /* FunctionKeyword */ && - token() !== 83 /* ClassKeyword */ && + token() !== 98 /* FunctionKeyword */ && + token() !== 84 /* ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -31727,7 +32884,7 @@ var ts; var colonToken; return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher), colonToken = parseExpectedToken(58 /* ColonToken */), ts.nodeIsPresent(colonToken) ? parseAssignmentExpressionOrHigher() - : createMissingNode(78 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */))), pos); + : createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */))), pos); } function parseBinaryExpressionOrHigher(precedence) { var pos = getNodePos(); @@ -31735,7 +32892,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand, pos); } function isInOrOfKeyword(t) { - return t === 100 /* InKeyword */ || t === 156 /* OfKeyword */; + return t === 101 /* InKeyword */ || t === 158 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand, pos) { while (true) { @@ -31770,10 +32927,10 @@ var ts; if (!consumeCurrentOperator) { break; } - if (token() === 100 /* InKeyword */ && inDisallowInContext()) { + if (token() === 101 /* InKeyword */ && inDisallowInContext()) { break; } - if (token() === 126 /* AsKeyword */) { + if (token() === 127 /* AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -31794,7 +32951,7 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 100 /* InKeyword */) { + if (inDisallowInContext() && token() === 101 /* InKeyword */) { return false; } return ts.getBinaryOperatorPrecedence(token()) > 0; @@ -31822,7 +32979,7 @@ var ts; return finishNode(factory.createVoidExpression(nextTokenAnd(parseSimpleUnaryExpression)), pos); } function isAwaitExpression() { - if (token() === 130 /* AwaitKeyword */) { + if (token() === 131 /* AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -31875,7 +33032,7 @@ var ts; if (token() === 42 /* AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 206 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 208 /* 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 { @@ -31905,18 +33062,18 @@ var ts; case 54 /* TildeToken */: case 53 /* ExclamationToken */: return parsePrefixUnaryExpression(); - case 88 /* DeleteKeyword */: + case 89 /* DeleteKeyword */: return parseDeleteExpression(); - case 111 /* TypeOfKeyword */: + case 112 /* TypeOfKeyword */: return parseTypeOfExpression(); - case 113 /* VoidKeyword */: + case 114 /* VoidKeyword */: return parseVoidExpression(); case 29 /* LessThanToken */: // This is modified UnaryExpression grammar in TypeScript // UnaryExpression (modified): // < type > UnaryExpression return parseTypeAssertion(); - case 130 /* AwaitKeyword */: + case 131 /* AwaitKeyword */: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -31943,10 +33100,10 @@ var ts; case 40 /* MinusToken */: case 54 /* TildeToken */: case 53 /* ExclamationToken */: - case 88 /* DeleteKeyword */: - case 111 /* TypeOfKeyword */: - case 113 /* VoidKeyword */: - case 130 /* AwaitKeyword */: + case 89 /* DeleteKeyword */: + case 112 /* TypeOfKeyword */: + case 114 /* VoidKeyword */: + case 131 /* AwaitKeyword */: return false; case 29 /* LessThanToken */: // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression @@ -32022,7 +33179,7 @@ var ts; // or starts the beginning of the first four CallExpression productions. var pos = getNodePos(); var expression; - if (token() === 99 /* ImportKeyword */) { + if (token() === 100 /* 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: @@ -32036,7 +33193,7 @@ var ts; // This is an 'import.*' metaproperty (i.e. 'import.meta') nextToken(); // advance past the 'import' nextToken(); // advance past the dot - expression = finishNode(factory.createMetaProperty(99 /* ImportKeyword */, parseIdentifierName()), pos); + expression = finishNode(factory.createMetaProperty(100 /* ImportKeyword */, parseIdentifierName()), pos); sourceFlags |= 2097152 /* PossiblyContainsImportMeta */; } else { @@ -32044,7 +33201,7 @@ var ts; } } else { - expression = token() === 105 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); + expression = token() === 106 /* 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 @@ -32122,23 +33279,45 @@ var ts; // 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); } - function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext, topInvalidNodePosition) { + function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext, topInvalidNodePosition, openingTag) { var pos = getNodePos(); var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 275 /* JsxOpeningElement */) { + if (opening.kind === 277 /* JsxOpeningElement */) { var children = parseJsxChildren(opening); - var closingElement = parseJsxClosingElement(inExpressionContext); - if (!tagNamesAreEquivalent(opening.tagName, closingElement.tagName)) { - parseErrorAtRange(closingElement, ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNodeFromSourceText(sourceText, opening.tagName)); + var closingElement = void 0; + var lastChild = children[children.length - 1]; + if ((lastChild === null || lastChild === void 0 ? void 0 : lastChild.kind) === 275 /* JsxElement */ + && !tagNamesAreEquivalent(lastChild.openingElement.tagName, lastChild.closingElement.tagName) + && tagNamesAreEquivalent(opening.tagName, lastChild.closingElement.tagName)) { + // when an unclosed JsxOpeningElement incorrectly parses its parent's JsxClosingElement, + // restructure (
(...
)) --> (
(...)
) + // (no need to error; the parent will error) + var end = lastChild.openingElement.end; // newly-created children and closing are both zero-width end/end + var newLast = finishNode(factory.createJsxElement(lastChild.openingElement, createNodeArray([], end, end), finishNode(factory.createJsxClosingElement(finishNode(factory.createIdentifier(""), end, end)), end, end)), lastChild.openingElement.pos, end); + children = createNodeArray(__spreadArray(__spreadArray([], children.slice(0, children.length - 1)), [newLast]), children.pos, end); + closingElement = lastChild.closingElement; + } + else { + closingElement = parseJsxClosingElement(opening, inExpressionContext); + if (!tagNamesAreEquivalent(opening.tagName, closingElement.tagName)) { + if (openingTag && ts.isJsxOpeningElement(openingTag) && tagNamesAreEquivalent(closingElement.tagName, openingTag.tagName)) { + // opening incorrectly matched with its parent's closing -- put error on opening + parseErrorAtRange(opening.tagName, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, opening.tagName)); + } + else { + // other opening/closing mismatches -- put error on closing + parseErrorAtRange(closingElement.tagName, ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNodeFromSourceText(sourceText, opening.tagName)); + } + } } result = finishNode(factory.createJsxElement(opening, children, closingElement), pos); } - else if (opening.kind === 278 /* JsxOpeningFragment */) { + else if (opening.kind === 280 /* JsxOpeningFragment */) { result = finishNode(factory.createJsxFragment(opening, parseJsxChildren(opening), parseJsxClosingFragment(inExpressionContext)), pos); } else { - ts.Debug.assert(opening.kind === 274 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 276 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -32192,7 +33371,7 @@ var ts; case 18 /* OpenBraceToken */: return parseJsxExpression(/*inExpressionContext*/ false); case 29 /* LessThanToken */: - return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ false); + return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ false, /*topInvalidNodePosition*/ undefined, openingTag); default: return ts.Debug.assertNever(token); } @@ -32207,6 +33386,13 @@ var ts; if (!child) break; list.push(child); + if (ts.isJsxOpeningElement(openingTag) + && (child === null || child === void 0 ? void 0 : child.kind) === 275 /* 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 + break; + } } parsingContext = saveParsingContext; return createNodeArray(list, listPos); @@ -32236,12 +33422,14 @@ var ts; } else { parseExpected(43 /* SlashToken */); - if (inExpressionContext) { - parseExpected(31 /* GreaterThanToken */); - } - else { - parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); - scanJsxText(); + if (parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { + // manually advance the scanner in order to look for jsx text inside jsx + if (inExpressionContext) { + nextToken(); + } + else { + scanJsxText(); + } } node = factory.createJsxSelfClosingElement(tagName, typeArguments, attributes); } @@ -32255,7 +33443,7 @@ 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() === 107 /* ThisKeyword */ ? + var expression = token() === 108 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); while (parseOptional(24 /* DotToken */)) { expression = finishNode(factory.createPropertyAccessExpression(expression, parseRightSideOfDot(/*allowIdentifierNames*/ true, /*allowPrivateIdentifiers*/ false)), pos); @@ -32292,7 +33480,7 @@ var ts; } scanJsxIdentifier(); var pos = getNodePos(); - return finishNode(factory.createJsxAttribute(parseIdentifierName(), token() !== 62 /* EqualsToken */ ? undefined : + return finishNode(factory.createJsxAttribute(parseIdentifierName(), token() !== 63 /* EqualsToken */ ? undefined : scanJsxAttributeValue() === 10 /* StringLiteral */ ? parseLiteralNode() : parseJsxExpression(/*inExpressionContext*/ true)), pos); } @@ -32304,16 +33492,18 @@ var ts; parseExpected(19 /* CloseBraceToken */); return finishNode(factory.createJsxSpreadAttribute(expression), pos); } - function parseJsxClosingElement(inExpressionContext) { + function parseJsxClosingElement(open, inExpressionContext) { var pos = getNodePos(); parseExpected(30 /* LessThanSlashToken */); var tagName = parseJsxElementName(); - if (inExpressionContext) { - parseExpected(31 /* GreaterThanToken */); - } - else { - parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); - scanJsxText(); + if (parseExpected(31 /* 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(); + } + else { + scanJsxText(); + } } return finishNode(factory.createJsxClosingElement(tagName), pos); } @@ -32323,12 +33513,14 @@ var ts; if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); } - if (inExpressionContext) { - parseExpected(31 /* GreaterThanToken */); - } - else { - parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); - scanJsxText(); + if (parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { + // manually advance the scanner in order to look for jsx text inside jsx + if (inExpressionContext) { + nextToken(); + } + else { + scanJsxText(); + } } return finishNode(factory.createJsxJsxClosingFragment(), pos); } @@ -32385,7 +33577,7 @@ var ts; function parseElementAccessExpressionRest(pos, expression, questionDotToken) { var argumentExpression; if (token() === 23 /* CloseBracketToken */) { - argumentExpression = createMissingNode(78 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); + argumentExpression = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); } else { var argument = allowInAnd(parseExpression); @@ -32480,7 +33672,7 @@ var ts; } if (questionDotToken) { // We failed to parse anything, so report a missing identifier here. - var name = createMissingNode(78 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected); + var name = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected); expression = finishNode(factory.createPropertyAccessChain(expression, questionDotToken, name), pos); } break; @@ -32561,11 +33753,11 @@ var ts; case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 107 /* ThisKeyword */: - case 105 /* SuperKeyword */: - case 103 /* NullKeyword */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: + case 108 /* ThisKeyword */: + case 106 /* SuperKeyword */: + case 104 /* NullKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: return parseTokenNode(); case 20 /* OpenParenToken */: return parseParenthesizedExpression(); @@ -32573,7 +33765,7 @@ var ts; return parseArrayLiteralExpression(); case 18 /* OpenBraceToken */: return parseObjectLiteralExpression(); - case 129 /* AsyncKeyword */: + case 130 /* 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. @@ -32581,14 +33773,14 @@ var ts; break; } return parseFunctionExpression(); - case 83 /* ClassKeyword */: + case 84 /* ClassKeyword */: return parseClassExpression(); - case 97 /* FunctionKeyword */: + case 98 /* FunctionKeyword */: return parseFunctionExpression(); - case 102 /* NewKeyword */: + case 103 /* NewKeyword */: return parseNewExpressionOrNewDotTarget(); case 43 /* SlashToken */: - case 67 /* SlashEqualsToken */: + case 68 /* SlashEqualsToken */: if (reScanSlashToken() === 13 /* RegularExpressionLiteral */) { return parseLiteralNode(); } @@ -32637,11 +33829,11 @@ var ts; } var decorators = parseDecorators(); var modifiers = parseModifiers(); - if (parseContextualModifier(134 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 167 /* GetAccessor */); + if (parseContextualModifier(135 /* GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 169 /* GetAccessor */); } - if (parseContextualModifier(146 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 168 /* SetAccessor */); + if (parseContextualModifier(147 /* SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 170 /* SetAccessor */); } var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); @@ -32660,7 +33852,7 @@ var ts; var node; var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* ColonToken */); if (isShorthandPropertyAssignment) { - var equalsToken = parseOptionalToken(62 /* EqualsToken */); + var equalsToken = parseOptionalToken(63 /* EqualsToken */); var objectAssignmentInitializer = equalsToken ? allowInAnd(parseAssignmentExpressionOrHigher) : undefined; node = factory.createShorthandPropertyAssignment(name, objectAssignmentInitializer); // Save equals token for error reporting. @@ -32706,7 +33898,7 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiers(); - parseExpected(97 /* FunctionKeyword */); + 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 */; @@ -32729,10 +33921,10 @@ var ts; } function parseNewExpressionOrNewDotTarget() { var pos = getNodePos(); - parseExpected(102 /* NewKeyword */); + parseExpected(103 /* NewKeyword */); if (parseOptional(24 /* DotToken */)) { var name = parseIdentifierName(); - return finishNode(factory.createMetaProperty(102 /* NewKeyword */, name), pos); + return finishNode(factory.createMetaProperty(103 /* NewKeyword */, name), pos); } var expressionPos = getNodePos(); var expression = parsePrimaryExpression(); @@ -32759,6 +33951,7 @@ var ts; // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { var pos = getNodePos(); + var hasJSDoc = hasPrecedingJSDocComment(); var openBracePosition = scanner.getTokenPos(); if (parseExpected(18 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { var multiLine = scanner.hasPrecedingLineBreak(); @@ -32769,11 +33962,16 @@ var ts; ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here)); } } - return finishNode(factory.createBlock(statements, multiLine), pos); + var result = withJSDoc(finishNode(factory.createBlock(statements, multiLine), pos), hasJSDoc); + if (token() === 63 /* 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(); + } + return result; } else { var statements = createMissingList(); - return finishNode(factory.createBlock(statements, /*multiLine*/ undefined), pos); + return withJSDoc(finishNode(factory.createBlock(statements, /*multiLine*/ undefined), pos), hasJSDoc); } } function parseFunctionBlock(flags, diagnosticMessage) { @@ -32800,24 +33998,27 @@ var ts; } function parseEmptyStatement() { var pos = getNodePos(); + var hasJSDoc = hasPrecedingJSDocComment(); parseExpected(26 /* SemicolonToken */); - return finishNode(factory.createEmptyStatement(), pos); + return withJSDoc(finishNode(factory.createEmptyStatement(), pos), hasJSDoc); } function parseIfStatement() { var pos = getNodePos(); - parseExpected(98 /* IfKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(99 /* IfKeyword */); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); var thenStatement = parseStatement(); - var elseStatement = parseOptional(90 /* ElseKeyword */) ? parseStatement() : undefined; - return finishNode(factory.createIfStatement(expression, thenStatement, elseStatement), pos); + var elseStatement = parseOptional(91 /* ElseKeyword */) ? parseStatement() : undefined; + return withJSDoc(finishNode(factory.createIfStatement(expression, thenStatement, elseStatement), pos), hasJSDoc); } function parseDoStatement() { var pos = getNodePos(); - parseExpected(89 /* DoKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(90 /* DoKeyword */); var statement = parseStatement(); - parseExpected(114 /* WhileKeyword */); + parseExpected(115 /* WhileKeyword */); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); @@ -32826,25 +34027,27 @@ var ts; // 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 */); - return finishNode(factory.createDoStatement(statement, expression), pos); + return withJSDoc(finishNode(factory.createDoStatement(statement, expression), pos), hasJSDoc); } function parseWhileStatement() { var pos = getNodePos(); - parseExpected(114 /* WhileKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(115 /* WhileKeyword */); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); var statement = parseStatement(); - return finishNode(factory.createWhileStatement(expression, statement), pos); + return withJSDoc(finishNode(factory.createWhileStatement(expression, statement), pos), hasJSDoc); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(96 /* ForKeyword */); - var awaitToken = parseOptionalToken(130 /* AwaitKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(97 /* ForKeyword */); + var awaitToken = parseOptionalToken(131 /* AwaitKeyword */); parseExpected(20 /* OpenParenToken */); var initializer; if (token() !== 26 /* SemicolonToken */) { - if (token() === 112 /* VarKeyword */ || token() === 118 /* LetKeyword */ || token() === 84 /* ConstKeyword */) { + if (token() === 113 /* VarKeyword */ || token() === 119 /* LetKeyword */ || token() === 85 /* ConstKeyword */) { initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { @@ -32852,12 +34055,12 @@ var ts; } } var node; - if (awaitToken ? parseExpected(156 /* OfKeyword */) : parseOptional(156 /* OfKeyword */)) { + if (awaitToken ? parseExpected(158 /* OfKeyword */) : parseOptional(158 /* OfKeyword */)) { var expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(21 /* CloseParenToken */); node = factory.createForOfStatement(awaitToken, initializer, expression, parseStatement()); } - else if (parseOptional(100 /* InKeyword */)) { + else if (parseOptional(101 /* InKeyword */)) { var expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); node = factory.createForInStatement(initializer, expression, parseStatement()); @@ -32874,37 +34077,40 @@ var ts; parseExpected(21 /* CloseParenToken */); node = factory.createForStatement(initializer, condition, incrementor, parseStatement()); } - return finishNode(node, pos); + return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseBreakOrContinueStatement(kind) { var pos = getNodePos(); - parseExpected(kind === 241 /* BreakStatement */ ? 80 /* BreakKeyword */ : 85 /* ContinueKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(kind === 243 /* BreakStatement */ ? 81 /* BreakKeyword */ : 86 /* ContinueKeyword */); var label = canParseSemicolon() ? undefined : parseIdentifier(); parseSemicolon(); - var node = kind === 241 /* BreakStatement */ + var node = kind === 243 /* BreakStatement */ ? factory.createBreakStatement(label) : factory.createContinueStatement(label); - return finishNode(node, pos); + return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseReturnStatement() { var pos = getNodePos(); - parseExpected(104 /* ReturnKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(105 /* ReturnKeyword */); var expression = canParseSemicolon() ? undefined : allowInAnd(parseExpression); parseSemicolon(); - return finishNode(factory.createReturnStatement(expression), pos); + return withJSDoc(finishNode(factory.createReturnStatement(expression), pos), hasJSDoc); } function parseWithStatement() { var pos = getNodePos(); - parseExpected(115 /* WithKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(116 /* WithKeyword */); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); var statement = doInsideOfContext(16777216 /* InWithStatement */, parseStatement); - return finishNode(factory.createWithStatement(expression, statement), pos); + return withJSDoc(finishNode(factory.createWithStatement(expression, statement), pos), hasJSDoc); } function parseCaseClause() { var pos = getNodePos(); - parseExpected(81 /* CaseKeyword */); + parseExpected(82 /* CaseKeyword */); var expression = allowInAnd(parseExpression); parseExpected(58 /* ColonToken */); var statements = parseList(3 /* SwitchClauseStatements */, parseStatement); @@ -32912,13 +34118,13 @@ var ts; } function parseDefaultClause() { var pos = getNodePos(); - parseExpected(87 /* DefaultKeyword */); + parseExpected(88 /* DefaultKeyword */); parseExpected(58 /* ColonToken */); var statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(factory.createDefaultClause(statements), pos); } function parseCaseOrDefaultClause() { - return token() === 81 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token() === 82 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseCaseBlock() { var pos = getNodePos(); @@ -32929,18 +34135,20 @@ var ts; } function parseSwitchStatement() { var pos = getNodePos(); - parseExpected(106 /* SwitchKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(107 /* SwitchKeyword */); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); var caseBlock = parseCaseBlock(); - return finishNode(factory.createSwitchStatement(expression, caseBlock), pos); + return withJSDoc(finishNode(factory.createSwitchStatement(expression, caseBlock), pos), hasJSDoc); } function parseThrowStatement() { // ThrowStatement[Yield] : // throw [no LineTerminator here]Expression[In, ?Yield]; var pos = getNodePos(); - parseExpected(108 /* ThrowKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(109 /* 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. @@ -32952,26 +34160,27 @@ var ts; expression = finishNode(factory.createIdentifier(""), getNodePos()); } parseSemicolon(); - return finishNode(factory.createThrowStatement(expression), pos); + return withJSDoc(finishNode(factory.createThrowStatement(expression), pos), hasJSDoc); } // TODO: Review for error recovery function parseTryStatement() { var pos = getNodePos(); - parseExpected(110 /* TryKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(111 /* TryKeyword */); var tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); - var catchClause = token() === 82 /* CatchKeyword */ ? parseCatchClause() : undefined; + var catchClause = token() === 83 /* 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() === 95 /* FinallyKeyword */) { - parseExpected(95 /* FinallyKeyword */); + if (!catchClause || token() === 96 /* FinallyKeyword */) { + parseExpected(96 /* FinallyKeyword */); finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } - return finishNode(factory.createTryStatement(tryBlock, catchClause, finallyBlock), pos); + return withJSDoc(finishNode(factory.createTryStatement(tryBlock, catchClause, finallyBlock), pos), hasJSDoc); } function parseCatchClause() { var pos = getNodePos(); - parseExpected(82 /* CatchKeyword */); + parseExpected(83 /* CatchKeyword */); var variableDeclaration; if (parseOptional(20 /* OpenParenToken */)) { variableDeclaration = parseVariableDeclaration(); @@ -32986,9 +34195,10 @@ var ts; } function parseDebuggerStatement() { var pos = getNodePos(); - parseExpected(86 /* DebuggerKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(87 /* DebuggerKeyword */); parseSemicolon(); - return finishNode(factory.createDebuggerStatement(), pos); + return withJSDoc(finishNode(factory.createDebuggerStatement(), pos), hasJSDoc); } function parseExpressionOrLabeledStatement() { // Avoiding having to do the lookahead for a labeled statement by just trying to parse @@ -33018,11 +34228,11 @@ var ts; } function nextTokenIsClassKeywordOnSameLine() { nextToken(); - return token() === 83 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 84 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 97 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 98 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine() { nextToken(); @@ -33031,12 +34241,12 @@ var ts; function isDeclaration() { while (true) { switch (token()) { - case 112 /* VarKeyword */: - case 118 /* LetKeyword */: - case 84 /* ConstKeyword */: - case 97 /* FunctionKeyword */: - case 83 /* ClassKeyword */: - case 91 /* EnumKeyword */: + case 113 /* VarKeyword */: + case 119 /* LetKeyword */: + case 85 /* ConstKeyword */: + case 98 /* FunctionKeyword */: + case 84 /* ClassKeyword */: + case 92 /* 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 @@ -33059,44 +34269,44 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 117 /* InterfaceKeyword */: - case 149 /* TypeKeyword */: + case 118 /* InterfaceKeyword */: + case 150 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 139 /* ModuleKeyword */: - case 140 /* NamespaceKeyword */: + case 140 /* ModuleKeyword */: + case 141 /* NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 125 /* AbstractKeyword */: - case 129 /* AsyncKeyword */: - case 133 /* DeclareKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 122 /* PublicKeyword */: - case 142 /* ReadonlyKeyword */: + case 126 /* AbstractKeyword */: + case 130 /* AsyncKeyword */: + case 134 /* DeclareKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + case 123 /* PublicKeyword */: + case 143 /* ReadonlyKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 154 /* GlobalKeyword */: + case 155 /* GlobalKeyword */: nextToken(); - return token() === 18 /* OpenBraceToken */ || token() === 78 /* Identifier */ || token() === 92 /* ExportKeyword */; - case 99 /* ImportKeyword */: + return token() === 18 /* OpenBraceToken */ || token() === 79 /* Identifier */ || token() === 93 /* ExportKeyword */; + case 100 /* ImportKeyword */: nextToken(); return token() === 10 /* StringLiteral */ || token() === 41 /* AsteriskToken */ || token() === 18 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); - case 92 /* ExportKeyword */: + case 93 /* ExportKeyword */: var currentToken_1 = nextToken(); - if (currentToken_1 === 149 /* TypeKeyword */) { + if (currentToken_1 === 150 /* TypeKeyword */) { currentToken_1 = lookAhead(nextToken); } - if (currentToken_1 === 62 /* EqualsToken */ || currentToken_1 === 41 /* AsteriskToken */ || - currentToken_1 === 18 /* OpenBraceToken */ || currentToken_1 === 87 /* DefaultKeyword */ || - currentToken_1 === 126 /* AsKeyword */) { + if (currentToken_1 === 63 /* EqualsToken */ || currentToken_1 === 41 /* AsteriskToken */ || + currentToken_1 === 18 /* OpenBraceToken */ || currentToken_1 === 88 /* DefaultKeyword */ || + currentToken_1 === 127 /* AsKeyword */) { return true; } continue; - case 123 /* StaticKeyword */: + case 124 /* StaticKeyword */: nextToken(); continue; default: @@ -33112,48 +34322,48 @@ var ts; case 59 /* AtToken */: case 26 /* SemicolonToken */: case 18 /* OpenBraceToken */: - case 112 /* VarKeyword */: - case 118 /* LetKeyword */: - case 97 /* FunctionKeyword */: - case 83 /* ClassKeyword */: - case 91 /* EnumKeyword */: - case 98 /* IfKeyword */: - case 89 /* DoKeyword */: - case 114 /* WhileKeyword */: - case 96 /* ForKeyword */: - case 85 /* ContinueKeyword */: - case 80 /* BreakKeyword */: - case 104 /* ReturnKeyword */: - case 115 /* WithKeyword */: - case 106 /* SwitchKeyword */: - case 108 /* ThrowKeyword */: - case 110 /* TryKeyword */: - case 86 /* DebuggerKeyword */: + 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 */: // '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 82 /* CatchKeyword */: - case 95 /* FinallyKeyword */: + case 83 /* CatchKeyword */: + case 96 /* FinallyKeyword */: return true; - case 99 /* ImportKeyword */: + case 100 /* ImportKeyword */: return isStartOfDeclaration() || lookAhead(nextTokenIsOpenParenOrLessThanOrDot); - case 84 /* ConstKeyword */: - case 92 /* ExportKeyword */: + case 85 /* ConstKeyword */: + case 93 /* ExportKeyword */: return isStartOfDeclaration(); - case 129 /* AsyncKeyword */: - case 133 /* DeclareKeyword */: - case 117 /* InterfaceKeyword */: - case 139 /* ModuleKeyword */: - case 140 /* NamespaceKeyword */: - case 149 /* TypeKeyword */: - case 154 /* GlobalKeyword */: + case 130 /* AsyncKeyword */: + case 134 /* DeclareKeyword */: + case 118 /* InterfaceKeyword */: + case 140 /* ModuleKeyword */: + case 141 /* NamespaceKeyword */: + case 150 /* TypeKeyword */: + case 155 /* GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 122 /* PublicKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 123 /* StaticKeyword */: - case 142 /* ReadonlyKeyword */: + case 123 /* PublicKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + case 124 /* StaticKeyword */: + case 143 /* 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); @@ -33176,64 +34386,64 @@ var ts; return parseEmptyStatement(); case 18 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); - case 112 /* VarKeyword */: + case 113 /* VarKeyword */: return parseVariableStatement(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 118 /* LetKeyword */: + case 119 /* LetKeyword */: if (isLetDeclaration()) { return parseVariableStatement(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); } break; - case 97 /* FunctionKeyword */: + case 98 /* FunctionKeyword */: return parseFunctionDeclaration(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 83 /* ClassKeyword */: + case 84 /* ClassKeyword */: return parseClassDeclaration(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 98 /* IfKeyword */: + case 99 /* IfKeyword */: return parseIfStatement(); - case 89 /* DoKeyword */: + case 90 /* DoKeyword */: return parseDoStatement(); - case 114 /* WhileKeyword */: + case 115 /* WhileKeyword */: return parseWhileStatement(); - case 96 /* ForKeyword */: + case 97 /* ForKeyword */: return parseForOrForInOrForOfStatement(); - case 85 /* ContinueKeyword */: - return parseBreakOrContinueStatement(240 /* ContinueStatement */); - case 80 /* BreakKeyword */: - return parseBreakOrContinueStatement(241 /* BreakStatement */); - case 104 /* ReturnKeyword */: + case 86 /* ContinueKeyword */: + return parseBreakOrContinueStatement(242 /* ContinueStatement */); + case 81 /* BreakKeyword */: + return parseBreakOrContinueStatement(243 /* BreakStatement */); + case 105 /* ReturnKeyword */: return parseReturnStatement(); - case 115 /* WithKeyword */: + case 116 /* WithKeyword */: return parseWithStatement(); - case 106 /* SwitchKeyword */: + case 107 /* SwitchKeyword */: return parseSwitchStatement(); - case 108 /* ThrowKeyword */: + case 109 /* ThrowKeyword */: return parseThrowStatement(); - case 110 /* TryKeyword */: + case 111 /* TryKeyword */: // Include 'catch' and 'finally' for error recovery. // falls through - case 82 /* CatchKeyword */: - case 95 /* FinallyKeyword */: + case 83 /* CatchKeyword */: + case 96 /* FinallyKeyword */: return parseTryStatement(); - case 86 /* DebuggerKeyword */: + case 87 /* DebuggerKeyword */: return parseDebuggerStatement(); case 59 /* AtToken */: return parseDeclaration(); - case 129 /* AsyncKeyword */: - case 117 /* InterfaceKeyword */: - case 149 /* TypeKeyword */: - case 139 /* ModuleKeyword */: - case 140 /* NamespaceKeyword */: - case 133 /* DeclareKeyword */: - case 84 /* ConstKeyword */: - case 91 /* EnumKeyword */: - case 92 /* ExportKeyword */: - case 99 /* ImportKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 122 /* PublicKeyword */: - case 125 /* AbstractKeyword */: - case 123 /* StaticKeyword */: - case 142 /* ReadonlyKeyword */: - case 154 /* GlobalKeyword */: + case 130 /* AsyncKeyword */: + case 118 /* InterfaceKeyword */: + case 150 /* TypeKeyword */: + case 140 /* ModuleKeyword */: + case 141 /* NamespaceKeyword */: + case 134 /* 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 143 /* ReadonlyKeyword */: + case 155 /* GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -33242,7 +34452,7 @@ var ts; return parseExpressionOrLabeledStatement(); } function isDeclareModifier(modifier) { - return modifier.kind === 133 /* DeclareKeyword */; + return modifier.kind === 134 /* DeclareKeyword */; } function parseDeclaration() { // TODO: Can we hold onto the parsed decorators/modifiers and advance the scanner @@ -33283,33 +34493,33 @@ var ts; } function parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers) { switch (token()) { - case 112 /* VarKeyword */: - case 118 /* LetKeyword */: - case 84 /* ConstKeyword */: + case 113 /* VarKeyword */: + case 119 /* LetKeyword */: + case 85 /* ConstKeyword */: return parseVariableStatement(pos, hasJSDoc, decorators, modifiers); - case 97 /* FunctionKeyword */: + case 98 /* FunctionKeyword */: return parseFunctionDeclaration(pos, hasJSDoc, decorators, modifiers); - case 83 /* ClassKeyword */: + case 84 /* ClassKeyword */: return parseClassDeclaration(pos, hasJSDoc, decorators, modifiers); - case 117 /* InterfaceKeyword */: + case 118 /* InterfaceKeyword */: return parseInterfaceDeclaration(pos, hasJSDoc, decorators, modifiers); - case 149 /* TypeKeyword */: + case 150 /* TypeKeyword */: return parseTypeAliasDeclaration(pos, hasJSDoc, decorators, modifiers); - case 91 /* EnumKeyword */: + case 92 /* EnumKeyword */: return parseEnumDeclaration(pos, hasJSDoc, decorators, modifiers); - case 154 /* GlobalKeyword */: - case 139 /* ModuleKeyword */: - case 140 /* NamespaceKeyword */: + case 155 /* GlobalKeyword */: + case 140 /* ModuleKeyword */: + case 141 /* NamespaceKeyword */: return parseModuleDeclaration(pos, hasJSDoc, decorators, modifiers); - case 99 /* ImportKeyword */: + case 100 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers); - case 92 /* ExportKeyword */: + case 93 /* ExportKeyword */: nextToken(); switch (token()) { - case 87 /* DefaultKeyword */: - case 62 /* EqualsToken */: + case 88 /* DefaultKeyword */: + case 63 /* EqualsToken */: return parseExportAssignment(pos, hasJSDoc, decorators, modifiers); - case 126 /* AsKeyword */: + case 127 /* AsKeyword */: return parseNamespaceExportDeclaration(pos, hasJSDoc, decorators, modifiers); default: return parseExportDeclaration(pos, hasJSDoc, decorators, modifiers); @@ -33318,7 +34528,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(271 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(273 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); ts.setTextRangePos(missing, pos); missing.decorators = decorators; missing.modifiers = modifiers; @@ -33383,7 +34593,7 @@ var ts; function isBindingIdentifierOrPrivateIdentifierOrPattern() { return token() === 18 /* OpenBraceToken */ || token() === 22 /* OpenBracketToken */ - || token() === 79 /* PrivateIdentifier */ + || token() === 80 /* PrivateIdentifier */ || isBindingIdentifier(); } function parseIdentifierOrPattern(privateIdentifierDiagnosticMessage) { @@ -33400,27 +34610,28 @@ var ts; } function parseVariableDeclaration(allowExclamation) { var pos = getNodePos(); + var hasJSDoc = hasPrecedingJSDocComment(); var name = parseIdentifierOrPattern(ts.Diagnostics.Private_identifiers_are_not_allowed_in_variable_declarations); var exclamationToken; - if (allowExclamation && name.kind === 78 /* Identifier */ && + if (allowExclamation && name.kind === 79 /* Identifier */ && token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { exclamationToken = parseTokenNode(); } var type = parseTypeAnnotation(); var initializer = isInOrOfKeyword(token()) ? undefined : parseInitializer(); var node = factory.createVariableDeclaration(name, exclamationToken, type, initializer); - return finishNode(node, pos); + return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseVariableDeclarationList(inForStatementInitializer) { var pos = getNodePos(); var flags = 0; switch (token()) { - case 112 /* VarKeyword */: + case 113 /* VarKeyword */: break; - case 118 /* LetKeyword */: + case 119 /* LetKeyword */: flags |= 1 /* Let */; break; - case 84 /* ConstKeyword */: + case 85 /* ConstKeyword */: flags |= 2 /* Const */; break; default: @@ -33437,7 +34648,7 @@ var ts; // this context. // The checker will then give an error that there is an empty declaration list. var declarations; - if (token() === 156 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 158 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { declarations = createMissingList(); } else { @@ -33462,7 +34673,7 @@ var ts; function parseFunctionDeclaration(pos, hasJSDoc, decorators, modifiers) { var savedAwaitContext = inAwaitContext(); var modifierFlags = ts.modifiersToFlags(modifiers); - parseExpected(97 /* FunctionKeyword */); + parseExpected(98 /* FunctionKeyword */); var asteriskToken = parseOptionalToken(41 /* 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(); @@ -33479,8 +34690,8 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseConstructorName() { - if (token() === 132 /* ConstructorKeyword */) { - return parseExpected(132 /* ConstructorKeyword */); + if (token() === 133 /* ConstructorKeyword */) { + return parseExpected(133 /* ConstructorKeyword */); } if (token() === 10 /* StringLiteral */ && lookAhead(nextToken) === 20 /* OpenParenToken */) { return tryParse(function () { @@ -33541,12 +34752,12 @@ var ts; var parameters = parseParameters(0 /* None */); var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); var body = parseFunctionBlockOrSemicolon(0 /* None */); - var node = kind === 167 /* GetAccessor */ + var node = kind === 169 /* GetAccessor */ ? factory.createGetAccessorDeclaration(decorators, modifiers, name, parameters, type, body) : factory.createSetAccessorDeclaration(decorators, modifiers, name, parameters, body); // Keep track of `typeParameters` (for both) and `type` (for setters) if they were parsed those indicate grammar errors node.typeParameters = typeParameters; - if (type && node.kind === 168 /* SetAccessor */) + if (type && node.kind === 170 /* SetAccessor */) node.type = type; return withJSDoc(finishNode(node, pos), hasJSDoc); } @@ -33585,7 +34796,7 @@ var ts; // 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 === 146 /* SetKeyword */ || idToken === 134 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 147 /* SetKeyword */ || idToken === 135 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along @@ -33595,7 +34806,7 @@ var ts; case 29 /* LessThanToken */: // Generic Method declaration case 53 /* ExclamationToken */: // Non-null assertion on property name case 58 /* ColonToken */: // Type Annotation for declaration - case 62 /* EqualsToken */: // Initializer for declaration + case 63 /* EqualsToken */: // Initializer for declaration case 57 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. return true; default: @@ -33610,7 +34821,7 @@ var ts; return false; } function parseDecoratorExpression() { - if (inAwaitContext() && token() === 130 /* AwaitKeyword */) { + if (inAwaitContext() && token() === 131 /* 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(); @@ -33640,7 +34851,7 @@ var ts; function tryParseModifier(permitInvalidConstAsModifier) { var pos = getNodePos(); var kind = token(); - if (token() === 84 /* ConstKeyword */ && permitInvalidConstAsModifier) { + if (token() === 85 /* 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)) { @@ -33671,10 +34882,10 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 129 /* AsyncKeyword */) { + if (token() === 130 /* AsyncKeyword */) { var pos = getNodePos(); nextToken(); - var modifier = finishNode(factory.createToken(129 /* AsyncKeyword */), pos); + var modifier = finishNode(factory.createToken(130 /* AsyncKeyword */), pos); modifiers = createNodeArray([modifier], pos); } return modifiers; @@ -33688,13 +34899,13 @@ var ts; var hasJSDoc = hasPrecedingJSDocComment(); var decorators = parseDecorators(); var modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true); - if (parseContextualModifier(134 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 167 /* GetAccessor */); + if (parseContextualModifier(135 /* GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 169 /* GetAccessor */); } - if (parseContextualModifier(146 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 168 /* SetAccessor */); + if (parseContextualModifier(147 /* SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 170 /* SetAccessor */); } - if (token() === 132 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { + if (token() === 133 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { var constructorDeclaration = tryParseConstructorDeclaration(pos, hasJSDoc, decorators, modifiers); if (constructorDeclaration) { return constructorDeclaration; @@ -33724,21 +34935,21 @@ var ts; } if (decorators || modifiers) { // treat this as a property declaration with a missing name. - var name = createMissingNode(78 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var name = createMissingNode(79 /* 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, 221 /* ClassExpression */); + return parseClassDeclarationOrExpression(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined, 223 /* ClassExpression */); } function parseClassDeclaration(pos, hasJSDoc, decorators, modifiers) { - return parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, 252 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, 254 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, kind) { var savedAwaitContext = inAwaitContext(); - parseExpected(83 /* ClassKeyword */); + parseExpected(84 /* 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(); @@ -33756,7 +34967,7 @@ var ts; members = createMissingList(); } setAwaitContext(savedAwaitContext); - var node = kind === 252 /* ClassDeclaration */ + var node = kind === 254 /* ClassDeclaration */ ? factory.createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) : factory.createClassExpression(decorators, modifiers, name, typeParameters, heritageClauses, members); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -33772,7 +34983,7 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 116 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 117 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); } function parseHeritageClauses() { // ClassTail[Yield,Await] : (Modified) See 14.5 @@ -33785,7 +34996,7 @@ var ts; function parseHeritageClause() { var pos = getNodePos(); var tok = token(); - ts.Debug.assert(tok === 93 /* ExtendsKeyword */ || tok === 116 /* ImplementsKeyword */); // isListElement() should ensure this. + ts.Debug.assert(tok === 94 /* ExtendsKeyword */ || tok === 117 /* ImplementsKeyword */); // isListElement() should ensure this. nextToken(); var types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(factory.createHeritageClause(tok, types), pos); @@ -33801,13 +35012,13 @@ var ts; parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */) : undefined; } function isHeritageClause() { - return token() === 93 /* ExtendsKeyword */ || token() === 116 /* ImplementsKeyword */; + return token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; } function parseClassMembers() { return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(117 /* InterfaceKeyword */); + parseExpected(118 /* InterfaceKeyword */); var name = parseIdentifier(); var typeParameters = parseTypeParameters(); var heritageClauses = parseHeritageClauses(); @@ -33816,11 +35027,11 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseTypeAliasDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(149 /* TypeKeyword */); + parseExpected(150 /* TypeKeyword */); var name = parseIdentifier(); var typeParameters = parseTypeParameters(); - parseExpected(62 /* EqualsToken */); - var type = token() === 136 /* IntrinsicKeyword */ && tryParse(parseKeywordAndNoDot) || parseType(); + parseExpected(63 /* EqualsToken */); + var type = token() === 137 /* IntrinsicKeyword */ && tryParse(parseKeywordAndNoDot) || parseType(); parseSemicolon(); var node = factory.createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -33837,7 +35048,7 @@ var ts; return withJSDoc(finishNode(factory.createEnumMember(name, initializer), pos), hasJSDoc); } function parseEnumDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(91 /* EnumKeyword */); + parseExpected(92 /* EnumKeyword */); var name = parseIdentifier(); var members; if (parseExpected(18 /* OpenBraceToken */)) { @@ -33876,7 +35087,7 @@ var ts; function parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers) { var flags = 0; var name; - if (token() === 154 /* GlobalKeyword */) { + if (token() === 155 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation name = parseIdentifier(); flags |= 1024 /* GlobalAugmentation */; @@ -33897,15 +35108,15 @@ var ts; } function parseModuleDeclaration(pos, hasJSDoc, decorators, modifiers) { var flags = 0; - if (token() === 154 /* GlobalKeyword */) { + if (token() === 155 /* GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers); } - else if (parseOptional(140 /* NamespaceKeyword */)) { + else if (parseOptional(141 /* NamespaceKeyword */)) { flags |= 16 /* Namespace */; } else { - parseExpected(139 /* ModuleKeyword */); + parseExpected(140 /* ModuleKeyword */); if (token() === 10 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers); } @@ -33913,7 +35124,7 @@ var ts; return parseModuleOrNamespaceDeclaration(pos, hasJSDoc, decorators, modifiers, flags); } function isExternalModuleReference() { - return token() === 143 /* RequireKeyword */ && + return token() === 144 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { @@ -33923,8 +35134,8 @@ var ts; return nextToken() === 43 /* SlashToken */; } function parseNamespaceExportDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(126 /* AsKeyword */); - parseExpected(140 /* NamespaceKeyword */); + parseExpected(127 /* AsKeyword */); + parseExpected(141 /* NamespaceKeyword */); var name = parseIdentifier(); parseSemicolon(); var node = factory.createNamespaceExportDeclaration(name); @@ -33934,7 +35145,7 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseImportDeclarationOrImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(99 /* ImportKeyword */); + parseExpected(100 /* 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; @@ -33942,7 +35153,7 @@ var ts; identifier = parseIdentifier(); } var isTypeOnly = false; - if (token() !== 153 /* FromKeyword */ && + if (token() !== 154 /* FromKeyword */ && (identifier === null || identifier === void 0 ? void 0 : identifier.escapedText) === "type" && (isIdentifier() || tokenAfterImportDefinitelyProducesImportDeclaration())) { isTypeOnly = true; @@ -33960,7 +35171,7 @@ var ts; token() === 18 /* OpenBraceToken */ // import { ) { importClause = parseImportClause(identifier, afterImportPos, isTypeOnly); - parseExpected(153 /* FromKeyword */); + parseExpected(154 /* FromKeyword */); } var moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -33973,10 +35184,10 @@ var ts; function tokenAfterImportedIdentifierDefinitelyProducesImportDeclaration() { // In `import id ___`, the current token decides whether to produce // an ImportDeclaration or ImportEqualsDeclaration. - return token() === 27 /* CommaToken */ || token() === 153 /* FromKeyword */; + return token() === 27 /* CommaToken */ || token() === 154 /* FromKeyword */; } function parseImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers, identifier, isTypeOnly) { - parseExpected(62 /* EqualsToken */); + parseExpected(63 /* EqualsToken */); var moduleReference = parseModuleReference(); parseSemicolon(); var node = factory.createImportEqualsDeclaration(decorators, modifiers, isTypeOnly, identifier, moduleReference); @@ -33995,7 +35206,7 @@ var ts; var namedBindings; if (!identifier || parseOptional(27 /* CommaToken */)) { - namedBindings = token() === 41 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(264 /* NamedImports */); + namedBindings = token() === 41 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(266 /* NamedImports */); } return finishNode(factory.createImportClause(isTypeOnly, identifier, namedBindings), pos); } @@ -34006,7 +35217,7 @@ var ts; } function parseExternalModuleReference() { var pos = getNodePos(); - parseExpected(143 /* RequireKeyword */); + parseExpected(144 /* RequireKeyword */); parseExpected(20 /* OpenParenToken */); var expression = parseModuleSpecifier(); parseExpected(21 /* CloseParenToken */); @@ -34030,7 +35241,7 @@ var ts; // * as ImportedBinding var pos = getNodePos(); parseExpected(41 /* AsteriskToken */); - parseExpected(126 /* AsKeyword */); + parseExpected(127 /* AsKeyword */); var name = parseIdentifier(); return finishNode(factory.createNamespaceImport(name), pos); } @@ -34043,16 +35254,16 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - var node = kind === 264 /* NamedImports */ + var node = kind === 266 /* NamedImports */ ? factory.createNamedImports(parseBracketedList(23 /* ImportOrExportSpecifiers */, parseImportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */)) : factory.createNamedExports(parseBracketedList(23 /* ImportOrExportSpecifiers */, parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */)); return finishNode(node, pos); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(270 /* ExportSpecifier */); + return parseImportOrExportSpecifier(272 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(265 /* ImportSpecifier */); + return parseImportOrExportSpecifier(267 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var pos = getNodePos(); @@ -34068,9 +35279,9 @@ var ts; var identifierName = parseIdentifierName(); var propertyName; var name; - if (token() === 126 /* AsKeyword */) { + if (token() === 127 /* AsKeyword */) { propertyName = identifierName; - parseExpected(126 /* AsKeyword */); + parseExpected(127 /* AsKeyword */); checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -34079,10 +35290,10 @@ var ts; else { name = identifierName; } - if (kind === 265 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 267 /* ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } - var node = kind === 265 /* ImportSpecifier */ + var node = kind === 267 /* ImportSpecifier */ ? factory.createImportSpecifier(propertyName, name) : factory.createExportSpecifier(propertyName, name); return finishNode(node, pos); @@ -34095,22 +35306,22 @@ var ts; setAwaitContext(/*value*/ true); var exportClause; var moduleSpecifier; - var isTypeOnly = parseOptional(149 /* TypeKeyword */); + var isTypeOnly = parseOptional(150 /* TypeKeyword */); var namespaceExportPos = getNodePos(); if (parseOptional(41 /* AsteriskToken */)) { - if (parseOptional(126 /* AsKeyword */)) { + if (parseOptional(127 /* AsKeyword */)) { exportClause = parseNamespaceExport(namespaceExportPos); } - parseExpected(153 /* FromKeyword */); + parseExpected(154 /* FromKeyword */); moduleSpecifier = parseModuleSpecifier(); } else { - exportClause = parseNamedImportsOrExports(268 /* NamedExports */); + exportClause = parseNamedImportsOrExports(270 /* 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() === 153 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(153 /* FromKeyword */); + if (token() === 154 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(154 /* FromKeyword */); moduleSpecifier = parseModuleSpecifier(); } } @@ -34123,11 +35334,11 @@ var ts; var savedAwaitContext = inAwaitContext(); setAwaitContext(/*value*/ true); var isExportEquals; - if (parseOptional(62 /* EqualsToken */)) { + if (parseOptional(63 /* EqualsToken */)) { isExportEquals = true; } else { - parseExpected(87 /* DefaultKeyword */); + parseExpected(88 /* DefaultKeyword */); } var expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -34143,7 +35354,7 @@ var ts; getImportMetaIfNecessary(sourceFile); } function isAnExternalModuleIndicatorNode(node) { - return hasModifierOfKind(node, 92 /* ExportKeyword */) + return hasModifierOfKind(node, 93 /* ExportKeyword */) || ts.isImportEqualsDeclaration(node) && ts.isExternalModuleReference(node.moduleReference) || ts.isImportDeclaration(node) || ts.isExportAssignment(node) @@ -34162,7 +35373,7 @@ var ts; return ts.some(node.modifiers, function (m) { return m.kind === kind; }); } function isImportMeta(node) { - return ts.isMetaProperty(node) && node.keywordToken === 99 /* ImportKeyword */ && node.name.escapedText === "meta"; + return ts.isMetaProperty(node) && node.keywordToken === 100 /* ImportKeyword */ && node.name.escapedText === "meta"; } var ParsingContext; (function (ParsingContext) { @@ -34230,7 +35441,13 @@ var ts; function parseJSDocNameReference() { var pos = getNodePos(); var hasBrace = parseOptional(18 /* OpenBraceToken */); + var p2 = getNodePos(); var entityName = parseEntityName(/* allowReservedWords*/ false); + while (token() === 80 /* PrivateIdentifier */) { + reScanHashToken(); // rescan #id as # id + nextTokenJSDoc(); // then skip the # + entityName = finishNode(factory.createJSDocMemberName(entityName, parseIdentifier()), p2); + } if (hasBrace) { parseExpectedJSDoc(19 /* CloseBraceToken */); } @@ -34294,7 +35511,10 @@ var ts; var tags; var tagsPos; var tagsEnd; + var linkEnd; + var commentsPos; var comments = []; + var parts = []; // + 3 for leading /**, - 5 in total for /** */ return scanner.scanRange(start + 3, length - 5, function () { // Initially we can parse out a tag. We also have seen a starting asterisk. @@ -34323,6 +35543,8 @@ var ts; case 59 /* AtToken */: if (state === 0 /* BeginningOfLine */ || state === 1 /* SawAsterisk */) { removeTrailingWhitespace(comments); + if (!commentsPos) + commentsPos = getNodePos(); addTag(parseTag(indent)); // 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 @@ -34365,6 +35587,22 @@ var ts; break; case 1 /* EndOfFileToken */: break loop; + case 18 /* OpenBraceToken */: + state = 2 /* SavingComments */; + var commentEnd = scanner.getStartPos(); + var linkStart = scanner.getTextPos() - 1; + var link = parseJSDocLink(linkStart); + if (link) { + if (!linkEnd) { + removeLeadingNewlines(comments); + } + parts.push(finishNode(factory.createJSDocText(comments.join("")), linkEnd !== null && linkEnd !== void 0 ? linkEnd : start, commentEnd)); + parts.push(link); + comments = []; + linkEnd = scanner.getTextPos(); + break; + } + // fallthrough if it's not a {@link sequence default: // 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 @@ -34375,9 +35613,14 @@ var ts; } nextTokenJSDoc(); } - removeLeadingNewlines(comments); removeTrailingWhitespace(comments); - return createJSDocComment(); + if (parts.length && comments.length) { + parts.push(finishNode(factory.createJSDocText(comments.join("")), linkEnd !== null && linkEnd !== void 0 ? linkEnd : start, commentsPos)); + } + if (parts.length && tags) + ts.Debug.assertIsDefined(commentsPos, "having parsed tags implies that the end of the comment span should be set"); + var tagsArray = tags && createNodeArray(tags, tagsPos, tagsEnd); + return finishNode(factory.createJSDocComment(parts.length ? createNodeArray(parts, start, commentsPos) : comments.length ? comments.join("") : undefined, tagsArray), start, end); }); function removeLeadingNewlines(comments) { while (comments.length && (comments[0] === "\n" || comments[0] === "\r")) { @@ -34389,11 +35632,6 @@ var ts; comments.pop(); } } - function createJSDocComment() { - var comment = comments.length ? comments.join("") : undefined; - var tagsArray = tags && createNodeArray(tags, tagsPos, tagsEnd); - return finishNode(factory.createJSDocComment(comment, tagsArray), start, end); - } function isNextNonwhitespaceTokenEndOfFile() { // We must use infinite lookahead, as there could be any number of newlines :( while (true) { @@ -34473,6 +35711,9 @@ var ts; case "readonly": tag = parseSimpleTag(start, factory.createJSDocReadonlyTag, tagName, margin, indentText); break; + case "override": + tag = parseSimpleTag(start, factory.createJSDocOverrideTag, tagName, margin, indentText); + break; case "deprecated": hasDeprecatedTag = true; tag = parseSimpleTag(start, factory.createJSDocDeprecatedTag, tagName, margin, indentText); @@ -34520,8 +35761,12 @@ var ts; return parseTagComments(margin, indentText.slice(margin)); } function parseTagComments(indent, initialMargin) { + var commentsPos = getNodePos(); var comments = []; + var parts = []; + var linkEnd; var state = 0 /* BeginningOfLine */; + var previousWhitespace = true; var margin; function pushComment(text) { if (!margin) { @@ -34547,7 +35792,9 @@ var ts; indent = 0; break; case 59 /* AtToken */: - if (state === 3 /* SavingBackticks */) { + if (state === 3 /* SavingBackticks */ + || state === 2 /* 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; } @@ -34571,13 +35818,18 @@ var ts; break; case 18 /* OpenBraceToken */: state = 2 /* SavingComments */; - if (lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenText() === "link"; })) { - pushComment(scanner.getTokenText()); - nextTokenJSDoc(); + var commentEnd = scanner.getStartPos(); + var linkStart = scanner.getTextPos() - 1; + var link = parseJSDocLink(linkStart); + if (link) { + parts.push(finishNode(factory.createJSDocText(comments.join("")), linkEnd !== null && linkEnd !== void 0 ? linkEnd : commentsPos, commentEnd)); + parts.push(link); + comments = []; + linkEnd = scanner.getTextPos(); + } + else { pushComment(scanner.getTokenText()); - nextTokenJSDoc(); } - pushComment(scanner.getTokenText()); break; case 61 /* BacktickToken */: if (state === 3 /* SavingBackticks */) { @@ -34604,15 +35856,67 @@ var ts; pushComment(scanner.getTokenText()); break; } + previousWhitespace = token() === 5 /* WhitespaceTrivia */; tok = nextTokenJSDoc(); } removeLeadingNewlines(comments); removeTrailingWhitespace(comments); - return comments.length === 0 ? undefined : comments.join(""); + if (parts.length) { + if (comments.length) { + parts.push(finishNode(factory.createJSDocText(comments.join("")), linkEnd !== null && linkEnd !== void 0 ? linkEnd : commentsPos)); + } + return createNodeArray(parts, commentsPos, scanner.getTextPos()); + } + else if (comments.length) { + return comments.join(""); + } + } + function isNextJSDocTokenWhitespace() { + var next = nextTokenJSDoc(); + return next === 5 /* WhitespaceTrivia */ || next === 4 /* NewLineTrivia */; + } + function parseJSDocLink(start) { + var linkType = tryParse(parseJSDocLinkPrefix); + if (!linkType) { + return undefined; + } + nextTokenJSDoc(); // start at token after link, then skip any whitespace + skipWhitespace(); + // parseEntityName logs an error for non-identifier, so create a MissingNode ourselves to avoid the error + var p2 = getNodePos(); + var name = ts.tokenIsIdentifierOrKeyword(token()) + ? parseEntityName(/*allowReservedWords*/ true) + : undefined; + if (name) { + while (token() === 80 /* 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 */) { + text.push(scanner.getTokenText()); + nextTokenJSDoc(); + } + var create = linkType === "link" ? factory.createJSDocLink + : linkType === "linkcode" ? factory.createJSDocLinkCode + : factory.createJSDocLinkPlain; + return finishNode(create(name, text.join("")), start, scanner.getTextPos()); + } + function parseJSDocLinkPrefix() { + skipWhitespaceOrAsterisk(); + if (token() === 18 /* OpenBraceToken */ + && nextTokenJSDoc() === 59 /* AtToken */ + && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc())) { + var kind = scanner.getTokenValue(); + if (kind === "link" || kind === "linkcode" || kind === "linkplain") { + return kind; + } + } } function parseUnknownTag(start, tagName, indent, indentText) { - var end = getNodePos(); - return finishNode(factory.createJSDocUnknownTag(tagName, parseTrailingTagComments(start, end, indent, indentText)), start, end); + return finishNode(factory.createJSDocUnknownTag(tagName, parseTrailingTagComments(start, getNodePos(), indent, indentText)), start); } function addTag(tag) { if (!tag) { @@ -34646,7 +35950,7 @@ var ts; if (isBracketed) { skipWhitespace(); // May have an optional default, e.g. '[foo = 42]' - if (parseOptionalToken(62 /* EqualsToken */)) { + if (parseOptionalToken(63 /* EqualsToken */)) { parseExpression(); } parseExpected(23 /* CloseBracketToken */); @@ -34655,9 +35959,9 @@ var ts; } function isObjectOrObjectArrayTypeReference(node) { switch (node.kind) { - case 145 /* ObjectKeyword */: + case 146 /* ObjectKeyword */: return true; - case 178 /* ArrayType */: + case 180 /* ArrayType */: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && !node.typeArguments; @@ -34668,11 +35972,11 @@ var ts; var isNameFirst = !typeExpression; skipWhitespaceOrAsterisk(); var _a = parseBracketNameInPropertyAndParamTag(), name = _a.name, isBracketed = _a.isBracketed; - skipWhitespace(); - if (isNameFirst) { + var indentText = skipWhitespaceOrAsterisk(); + if (isNameFirst && !lookAhead(parseJSDocLinkPrefix)) { typeExpression = tryParseTypeExpression(); } - var comment = parseTagComments(indent + scanner.getStartPos() - start); + var comment = parseTrailingTagComments(start, getNodePos(), indent, indentText); var nestedTypeLiteral = target !== 4 /* CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { typeExpression = nestedTypeLiteral; @@ -34689,12 +35993,12 @@ var ts; var child = void 0; var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 326 /* JSDocParameterTag */ || child.kind === 333 /* JSDocPropertyTag */) { + if (child.kind === 334 /* JSDocParameterTag */ || child.kind === 341 /* JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - var literal = finishNode(factory.createJSDocTypeLiteral(children, typeExpression.type.kind === 178 /* ArrayType */), pos); + var literal = finishNode(factory.createJSDocTypeLiteral(children, typeExpression.type.kind === 180 /* ArrayType */), pos); return finishNode(factory.createJSDocTypeExpression(literal), pos); } } @@ -34704,27 +36008,34 @@ var ts; parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } var typeExpression = tryParseTypeExpression(); - var end = getNodePos(); - return finishNode(factory.createJSDocReturnTag(tagName, typeExpression, parseTrailingTagComments(start, end, indent, indentText)), start, end); + return finishNode(factory.createJSDocReturnTag(tagName, typeExpression, parseTrailingTagComments(start, getNodePos(), indent, indentText)), start); } function parseTypeTag(start, tagName, indent, indentText) { if (ts.some(tags, ts.isJSDocTypeTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } var typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); - var end = getNodePos(); - var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, end, indent, indentText) : undefined; - return finishNode(factory.createJSDocTypeTag(tagName, typeExpression, comments), start, end); + var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, getNodePos(), indent, indentText) : undefined; + return finishNode(factory.createJSDocTypeTag(tagName, typeExpression, comments), start); } function parseSeeTag(start, tagName, indent, indentText) { - var nameExpression = parseJSDocNameReference(); - var end = getNodePos(); - var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, end, indent, indentText) : undefined; - return finishNode(factory.createJSDocSeeTag(tagName, nameExpression, comments), start, end); + var isLink = lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenValue() === "link"; }); + var nameExpression = isLink ? undefined : parseJSDocNameReference(); + var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, getNodePos(), indent, indentText) : undefined; + return finishNode(factory.createJSDocSeeTag(tagName, nameExpression, comments), start); } function parseAuthorTag(start, tagName, indent, indentText) { - var comments = parseAuthorNameAndEmail() + (parseTrailingTagComments(start, end, indent, indentText) || ""); - return finishNode(factory.createJSDocAuthorTag(tagName, comments || undefined), start); + var commentStart = getNodePos(); + var textOnly = parseAuthorNameAndEmail(); + var commentEnd = scanner.getStartPos(); + var comments = parseTrailingTagComments(start, commentEnd, indent, indentText); + if (!comments) { + commentEnd = scanner.getStartPos(); + } + var allParts = typeof comments !== "string" + ? createNodeArray(ts.concatenate([finishNode(textOnly, commentStart, commentEnd)], comments), commentStart) // cast away readonly + : textOnly.text + comments; + return finishNode(factory.createJSDocAuthorTag(tagName, allParts), start); } function parseAuthorNameAndEmail() { var comments = []; @@ -34745,17 +36056,15 @@ var ts; comments.push(scanner.getTokenText()); token = nextTokenJSDoc(); } - return comments.join(""); + return factory.createJSDocText(comments.join("")); } function parseImplementsTag(start, tagName, margin, indentText) { var className = parseExpressionWithTypeArgumentsForAugments(); - var end = getNodePos(); - return finishNode(factory.createJSDocImplementsTag(tagName, className, parseTrailingTagComments(start, end, margin, indentText)), start, end); + return finishNode(factory.createJSDocImplementsTag(tagName, className, parseTrailingTagComments(start, getNodePos(), margin, indentText)), start); } function parseAugmentsTag(start, tagName, margin, indentText) { var className = parseExpressionWithTypeArgumentsForAugments(); - var end = getNodePos(); - return finishNode(factory.createJSDocAugmentsTag(tagName, className, parseTrailingTagComments(start, end, margin, indentText)), start, end); + return finishNode(factory.createJSDocAugmentsTag(tagName, className, parseTrailingTagComments(start, getNodePos(), margin, indentText)), start); } function parseExpressionWithTypeArgumentsForAugments() { var usedBrace = parseOptional(18 /* OpenBraceToken */); @@ -34779,20 +36088,17 @@ var ts; return node; } function parseSimpleTag(start, createTag, tagName, margin, indentText) { - var end = getNodePos(); - return finishNode(createTag(tagName, parseTrailingTagComments(start, end, margin, indentText)), start, end); + return finishNode(createTag(tagName, parseTrailingTagComments(start, getNodePos(), margin, indentText)), start); } function parseThisTag(start, tagName, margin, indentText) { var typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); - var end = getNodePos(); - return finishNode(factory.createJSDocThisTag(tagName, typeExpression, parseTrailingTagComments(start, end, margin, indentText)), start, end); + return finishNode(factory.createJSDocThisTag(tagName, typeExpression, parseTrailingTagComments(start, getNodePos(), margin, indentText)), start); } function parseEnumTag(start, tagName, margin, indentText) { var typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); - var end = getNodePos(); - return finishNode(factory.createJSDocEnumTag(tagName, typeExpression, parseTrailingTagComments(start, end, margin, indentText)), start, end); + return finishNode(factory.createJSDocEnumTag(tagName, typeExpression, parseTrailingTagComments(start, getNodePos(), margin, indentText)), start); } function parseTypedefTag(start, tagName, indent, indentText) { var _a; @@ -34809,7 +36115,7 @@ var ts; var hasChildren = false; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { hasChildren = true; - if (child.kind === 329 /* JSDocTypeTag */) { + if (child.kind === 337 /* JSDocTypeTag */) { if (childTypeTag) { parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags); var lastError = ts.lastOrUndefined(parseDiagnostics); @@ -34827,7 +36133,7 @@ var ts; } } if (hasChildren) { - var isArrayType = typeExpression && typeExpression.type.kind === 178 /* ArrayType */; + var isArrayType = typeExpression && typeExpression.type.kind === 180 /* ArrayType */; var jsdocTypeLiteral = factory.createJSDocTypeLiteral(jsDocPropertyTags, isArrayType); typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? childTypeTag.typeExpression : @@ -34880,17 +36186,16 @@ var ts; var returnTag = tryParse(function () { if (parseOptionalJsdoc(59 /* AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 327 /* JSDocReturnTag */) { + if (tag && tag.kind === 335 /* JSDocReturnTag */) { return tag; } } }); var typeExpression = finishNode(factory.createJSDocSignature(/*typeParameters*/ undefined, parameters, returnTag), start); - var end = getNodePos(); if (!comment) { - comment = parseTrailingTagComments(start, end, indent, indentText); + comment = parseTrailingTagComments(start, getNodePos(), indent, indentText); } - return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start, end); + return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start); } function escapedTextsEqual(a, b) { while (!ts.isIdentifier(a) || !ts.isIdentifier(b)) { @@ -34915,7 +36220,7 @@ var ts; case 59 /* AtToken */: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 326 /* JSDocParameterTag */ || child.kind === 333 /* JSDocPropertyTag */) && + if (child && (child.kind === 334 /* JSDocParameterTag */ || child.kind === 341 /* JSDocPropertyTag */) && target !== 4 /* CallbackParameter */ && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; @@ -34934,7 +36239,7 @@ var ts; } seenAsterisk = true; break; - case 78 /* Identifier */: + case 79 /* Identifier */: canParseTag = false; break; case 1 /* EndOfFileToken */: @@ -34972,6 +36277,9 @@ var ts; function parseTemplateTagTypeParameter() { var typeParameterPos = getNodePos(); var name = parseJSDocIdentifierName(ts.Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces); + if (ts.nodeIsMissing(name)) { + return undefined; + } return finishNode(factory.createTypeParameterDeclaration(name, /*constraint*/ undefined, /*defaultType*/ undefined), typeParameterPos); } function parseTemplateTagTypeParameters() { @@ -34979,7 +36287,10 @@ var ts; var typeParameters = []; do { skipWhitespace(); - typeParameters.push(parseTemplateTagTypeParameter()); + var node = parseTemplateTagTypeParameter(); + if (node !== undefined) { + typeParameters.push(node); + } skipWhitespaceOrAsterisk(); } while (parseOptionalJsdoc(27 /* CommaToken */)); return createNodeArray(typeParameters, pos); @@ -34998,8 +36309,7 @@ var ts; // TODO: Consider only parsing a single type parameter if there is a constraint. var constraint = token() === 18 /* OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; var typeParameters = parseTemplateTagTypeParameters(); - var end = getNodePos(); - return finishNode(factory.createJSDocTemplateTag(tagName, constraint, typeParameters, parseTrailingTagComments(start, end, indent, indentText)), start, end); + return finishNode(factory.createJSDocTemplateTag(tagName, constraint, typeParameters, parseTrailingTagComments(start, getNodePos(), indent, indentText)), start); } function parseOptionalJsdoc(t) { if (token() === t) { @@ -35027,7 +36337,7 @@ var ts; } function parseJSDocIdentifierName(message) { if (!ts.tokenIsIdentifierOrKeyword(token())) { - return createMissingNode(78 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); + return createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); } identifierCount++; var pos = scanner.getTokenPos(); @@ -35200,7 +36510,7 @@ var ts; switch (node.kind) { case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - case 78 /* Identifier */: + case 79 /* Identifier */: return true; } return false; @@ -35674,7 +36984,7 @@ var ts; if (namedArgRegExCache.has(name)) { return namedArgRegExCache.get(name); } - var result = new RegExp("(\\s" + name + "\\s*=\\s*)('|\")(.+?)\\2", "im"); + var result = new RegExp("(\\s" + name + "\\s*=\\s*)(?:(?:'([^']*)')|(?:\"([^\"]*)\"))", "im"); namedArgRegExCache.set(name, result); return result; } @@ -35698,16 +37008,17 @@ var ts; return; // Missing required argument, don't parse } else if (matchResult) { + var value = matchResult[2] || matchResult[3]; if (arg.captureSpan) { - var startPos = range.pos + matchResult.index + matchResult[1].length + matchResult[2].length; + var startPos = range.pos + matchResult.index + matchResult[1].length + 1; argument[arg.name] = { - value: matchResult[3], + value: value, pos: startPos, - end: startPos + matchResult[3].length + end: startPos + value.length }; } else { - argument[arg.name] = matchResult[3]; + argument[arg.name] = value; } } } @@ -35723,7 +37034,7 @@ var ts; return addPragmaForMatch(pragmas, range, 2 /* SingleLine */, singleLine); } if (range.kind === 3 /* MultiLineCommentTrivia */) { - var multiLinePragmaRegEx = /\s*@(\S+)\s*(.*)\s*$/gim; // Defined inline since it uses the "g" flag, which keeps a persistent index (for iterating) + 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); @@ -35750,7 +37061,7 @@ var ts; return {}; if (!pragma.args) return {}; - var args = text.split(/\s+/); + var args = ts.trimString(text).split(/\s+/); var argMap = {}; for (var i = 0; i < pragma.args.length; i++) { var argument = pragma.args[i]; @@ -35769,10 +37080,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 78 /* Identifier */) { + if (lhs.kind === 79 /* Identifier */) { return lhs.escapedText === rhs.escapedText; } - if (lhs.kind === 107 /* ThisKeyword */) { + if (lhs.kind === 108 /* ThisKeyword */) { return true; } // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only @@ -35814,6 +37125,7 @@ var ts; ["es2018", "lib.es2018.d.ts"], ["es2019", "lib.es2019.d.ts"], ["es2020", "lib.es2020.d.ts"], + ["es2021", "lib.es2021.d.ts"], ["esnext", "lib.esnext.d.ts"], // Host only ["dom", "lib.dom.d.ts"], @@ -35853,14 +37165,17 @@ var ts; ["es2020.string", "lib.es2020.string.d.ts"], ["es2020.symbol.wellknown", "lib.es2020.symbol.wellknown.d.ts"], ["es2020.intl", "lib.es2020.intl.d.ts"], + ["es2021.promise", "lib.es2021.promise.d.ts"], + ["es2021.string", "lib.es2021.string.d.ts"], + ["es2021.weakref", "lib.es2021.weakref.d.ts"], ["esnext.array", "lib.es2019.array.d.ts"], ["esnext.symbol", "lib.es2019.symbol.d.ts"], ["esnext.asynciterable", "lib.es2018.asynciterable.d.ts"], ["esnext.intl", "lib.esnext.intl.d.ts"], ["esnext.bigint", "lib.es2020.bigint.d.ts"], - ["esnext.string", "lib.esnext.string.d.ts"], - ["esnext.promise", "lib.esnext.promise.d.ts"], - ["esnext.weakref", "lib.esnext.weakref.d.ts"] + ["esnext.string", "lib.es2021.string.d.ts"], + ["esnext.promise", "lib.es2021.promise.d.ts"], + ["esnext.weakref", "lib.es2021.weakref.d.ts"] ]; /** * An array of supported "lib" reference file names used to determine the order for inclusion @@ -35884,11 +37199,12 @@ var ts; fixedpollinginterval: ts.WatchFileKind.FixedPollingInterval, prioritypollinginterval: ts.WatchFileKind.PriorityPollingInterval, dynamicprioritypolling: ts.WatchFileKind.DynamicPriorityPolling, + fixedchunksizepolling: ts.WatchFileKind.FixedChunkSizePolling, usefsevents: ts.WatchFileKind.UseFsEvents, usefseventsonparentdirectory: ts.WatchFileKind.UseFsEventsOnParentDirectory, })), - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_DynamicPriorityPolling_UseFsEvents_UseFsEventsOnParentDirectory, + category: ts.Diagnostics.Watch_and_Build_Modes, + description: ts.Diagnostics.Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_DynamicPriorityPolling_FixedChunkSizePolling_UseFsEvents_UseFsEventsOnParentDirectory, }, { name: "watchDirectory", @@ -35896,9 +37212,10 @@ var ts; usefsevents: ts.WatchDirectoryKind.UseFsEvents, fixedpollinginterval: ts.WatchDirectoryKind.FixedPollingInterval, dynamicprioritypolling: ts.WatchDirectoryKind.DynamicPriorityPolling, + fixedchunksizepolling: ts.WatchDirectoryKind.FixedChunkSizePolling, })), - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling, + category: ts.Diagnostics.Watch_and_Build_Modes, + description: ts.Diagnostics.Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling_FixedChunkSizePolling, }, { name: "fallbackPolling", @@ -35906,14 +37223,15 @@ var ts; fixedinterval: ts.PollingWatchKind.FixedInterval, priorityinterval: ts.PollingWatchKind.PriorityInterval, dynamicpriority: ts.PollingWatchKind.DynamicPriority, + fixedchunksize: ts.PollingWatchKind.FixedChunkSize, })), - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority, + category: ts.Diagnostics.Watch_and_Build_Modes, + description: ts.Diagnostics.Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority_FixedChunkSize, }, { name: "synchronousWatchDirectory", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Watch_and_Build_Modes, description: ts.Diagnostics.Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively, }, { @@ -35925,7 +37243,7 @@ var ts; isFilePath: true, extraValidation: specToDiagnostic }, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Watch_and_Build_Modes, description: ts.Diagnostics.Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively, }, { @@ -35937,7 +37255,7 @@ var ts; isFilePath: true, extraValidation: specToDiagnostic }, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Watch_and_Build_Modes, description: ts.Diagnostics.Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively, }, ]; @@ -35961,6 +37279,7 @@ var ts; shortName: "w", type: "boolean", showInSimplifiedHelpView: true, + isCommandLineOnly: true, category: ts.Diagnostics.Command_line_Options, description: ts.Diagnostics.Watch_input_files, }, @@ -35968,49 +37287,50 @@ var ts; name: "preserveWatchOutput", type: "boolean", showInSimplifiedHelpView: false, - category: ts.Diagnostics.Command_line_Options, + category: ts.Diagnostics.Output_Formatting, description: ts.Diagnostics.Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen, }, { name: "listFiles", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Print_names_of_files_part_of_the_compilation }, { name: "explainFiles", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Print_names_of_files_and_the_reason_they_are_part_of_the_compilation - }, { + }, + { name: "listEmittedFiles", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Print_names_of_generated_files_part_of_the_compilation }, { name: "pretty", type: "boolean", showInSimplifiedHelpView: true, - category: ts.Diagnostics.Command_line_Options, + category: ts.Diagnostics.Output_Formatting, description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental }, { name: "traceResolution", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Enable_tracing_of_the_name_resolution_process }, { name: "diagnostics", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Show_diagnostic_information }, { name: "extendedDiagnostics", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Show_verbose_diagnostic_information }, { @@ -36018,7 +37338,7 @@ var ts; type: "string", isFilePath: true, paramType: ts.Diagnostics.FILE_OR_DIRECTORY, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Generates_a_CPU_profile }, { @@ -36027,14 +37347,14 @@ var ts; isFilePath: true, isCommandLineOnly: true, paramType: ts.Diagnostics.DIRECTORY, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Compiler_Diagnostics, description: ts.Diagnostics.Generates_an_event_trace_and_a_list_of_types }, { name: "incremental", shortName: "i", type: "boolean", - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Projects, description: ts.Diagnostics.Enable_incremental_compilation, transpileOptionValue: undefined }, @@ -36043,13 +37363,14 @@ var ts; type: "boolean", affectsSemanticDiagnostics: true, affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Watch_and_Build_Modes, description: ts.Diagnostics.Have_recompiles_in_incremental_and_watch_assume_that_changes_within_a_file_will_only_affect_files_directly_depending_on_it }, { name: "locale", type: "string", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Command_line_Options, + isCommandLineOnly: true, description: ts.Diagnostics.The_locale_used_when_displaying_messages_to_the_user_e_g_en_us }, ]; @@ -36067,6 +37388,7 @@ var ts; es2018: 5 /* ES2018 */, es2019: 6 /* ES2019 */, es2020: 7 /* ES2020 */, + es2021: 8 /* ES2021 */, esnext: 99 /* ESNext */, })), affectsSourceFile: true, @@ -36074,11 +37396,11 @@ var ts; affectsEmit: true, paramType: ts.Diagnostics.VERSION, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_or_ESNEXT, + category: ts.Diagnostics.Language_and_Environment, + description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_ES2021_or_ESNEXT, }; - /* @internal */ - ts.optionDeclarations = __spreadArray(__spreadArray([], ts.commonOptionsWithBuild), [ + var commandOptionsWithoutBuild = [ + // CommandLine only options { name: "all", type: "boolean", @@ -36155,7 +37477,7 @@ var ts; affectsEmit: true, paramType: ts.Diagnostics.KIND, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_es2020_or_ESNext, }, { @@ -36165,9 +37487,9 @@ var ts; name: "lib", type: ts.libMap }, - affectsModuleResolution: true, + affectsProgramStructure: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation, transpileOptionValue: undefined }, @@ -36176,13 +37498,13 @@ var ts; type: "boolean", affectsModuleResolution: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.JavaScript_Support, description: ts.Diagnostics.Allow_javascript_files_to_be_compiled }, { name: "checkJs", type: "boolean", - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.JavaScript_Support, description: ts.Diagnostics.Report_errors_in_js_files }, { @@ -36193,7 +37515,7 @@ var ts; affectsModuleResolution: true, paramType: ts.Diagnostics.KIND, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_react_react_jsx_or_react_jsxdev, }, { @@ -36202,7 +37524,7 @@ var ts; type: "boolean", affectsEmit: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Generates_corresponding_d_ts_file, transpileOptionValue: undefined }, @@ -36211,7 +37533,7 @@ var ts; type: "boolean", affectsEmit: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Generates_a_sourcemap_for_each_corresponding_d_ts_file, transpileOptionValue: undefined }, @@ -36219,7 +37541,7 @@ var ts; name: "emitDeclarationOnly", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Only_emit_d_ts_declaration_files, transpileOptionValue: undefined }, @@ -36228,7 +37550,7 @@ var ts; type: "boolean", affectsEmit: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Generates_corresponding_map_file, }, { @@ -36238,7 +37560,7 @@ var ts; isFilePath: true, paramType: ts.Diagnostics.FILE, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, transpileOptionValue: undefined }, @@ -36249,7 +37571,7 @@ var ts; isFilePath: true, paramType: ts.Diagnostics.DIRECTORY, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Redirect_output_structure_to_the_directory, }, { @@ -36258,7 +37580,7 @@ var ts; affectsEmit: true, isFilePath: true, paramType: ts.Diagnostics.LOCATION, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, }, { @@ -36266,7 +37588,7 @@ var ts; type: "boolean", affectsEmit: true, isTSConfigOnly: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Projects, description: ts.Diagnostics.Enable_project_compilation, transpileOptionValue: undefined }, @@ -36276,7 +37598,7 @@ var ts; affectsEmit: true, isFilePath: true, paramType: ts.Diagnostics.FILE, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Projects, description: ts.Diagnostics.Specify_file_to_store_incremental_compilation_information, transpileOptionValue: undefined }, @@ -36285,14 +37607,14 @@ var ts; type: "boolean", affectsEmit: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Do_not_emit_comments_to_output, }, { name: "noEmit", type: "boolean", showInSimplifiedHelpView: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Do_not_emit_outputs, transpileOptionValue: undefined }, @@ -36300,7 +37622,7 @@ var ts; name: "importHelpers", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Import_emit_helpers_from_tslib }, { @@ -36312,20 +37634,20 @@ var ts; })), affectsEmit: true, affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types }, { name: "downlevelIteration", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3 }, { name: "isolatedModules", type: "boolean", - category: ts.Diagnostics.Basic_Options, + category: ts.Diagnostics.Interop_Constraints, description: ts.Diagnostics.Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule, transpileOptionValue: true }, @@ -36334,7 +37656,7 @@ var ts; name: "strict", type: "boolean", showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Enable_all_strict_type_checking_options }, { @@ -36343,7 +37665,7 @@ var ts; affectsSemanticDiagnostics: true, strictFlag: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type }, { @@ -36352,7 +37674,7 @@ var ts; affectsSemanticDiagnostics: true, strictFlag: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Enable_strict_null_checks }, { @@ -36361,7 +37683,7 @@ var ts; affectsSemanticDiagnostics: true, strictFlag: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Enable_strict_checking_of_function_types }, { @@ -36369,7 +37691,7 @@ var ts; type: "boolean", strictFlag: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Enable_strict_bind_call_and_apply_methods_on_functions }, { @@ -36378,25 +37700,43 @@ var ts; affectsSemanticDiagnostics: true, strictFlag: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Enable_strict_checking_of_property_initialization_in_classes }, + { + name: "strictOptionalProperties", + type: "boolean", + affectsSemanticDiagnostics: true, + strictFlag: true, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Type_Checking, + description: ts.Diagnostics.Enable_strict_checking_of_optional_properties + }, { name: "noImplicitThis", type: "boolean", affectsSemanticDiagnostics: true, strictFlag: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, }, + { + name: "useUnknownInCatchVariables", + type: "boolean", + affectsSemanticDiagnostics: true, + strictFlag: true, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Type_Checking, + description: ts.Diagnostics.Type_catch_clause_variables_as_unknown_instead_of_any, + }, { name: "alwaysStrict", type: "boolean", affectsSourceFile: true, strictFlag: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Strict_Type_Checking_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file }, // Additional Checks @@ -36405,7 +37745,7 @@ var ts; type: "boolean", affectsSemanticDiagnostics: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Additional_Checks, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Report_errors_on_unused_locals, }, { @@ -36413,7 +37753,7 @@ var ts; type: "boolean", affectsSemanticDiagnostics: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Additional_Checks, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Report_errors_on_unused_parameters, }, { @@ -36421,7 +37761,7 @@ var ts; type: "boolean", affectsSemanticDiagnostics: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Additional_Checks, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value }, { @@ -36430,7 +37770,7 @@ var ts; affectsBindDiagnostics: true, affectsSemanticDiagnostics: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Additional_Checks, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement }, { @@ -36438,14 +37778,22 @@ var ts; type: "boolean", affectsSemanticDiagnostics: true, showInSimplifiedHelpView: false, - category: ts.Diagnostics.Additional_Checks, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Include_undefined_in_index_signature_results }, + { + name: "noImplicitOverride", + type: "boolean", + affectsSemanticDiagnostics: true, + showInSimplifiedHelpView: false, + category: ts.Diagnostics.Type_Checking, + description: ts.Diagnostics.Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier + }, { name: "noPropertyAccessFromIndexSignature", type: "boolean", showInSimplifiedHelpView: false, - category: ts.Diagnostics.Additional_Checks, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Require_undeclared_properties_from_index_signatures_to_use_element_accesses }, // Module Resolution @@ -36457,7 +37805,7 @@ var ts; })), affectsModuleResolution: true, paramType: ts.Diagnostics.STRATEGY, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, }, { @@ -36465,7 +37813,7 @@ var ts; type: "string", affectsModuleResolution: true, isFilePath: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Base_directory_to_resolve_non_absolute_module_names }, { @@ -36475,7 +37823,7 @@ var ts; type: "object", affectsModuleResolution: true, isTSConfigOnly: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl, transpileOptionValue: undefined }, @@ -36491,7 +37839,7 @@ var ts; isFilePath: true }, affectsModuleResolution: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime, transpileOptionValue: undefined }, @@ -36504,7 +37852,7 @@ var ts; isFilePath: true }, affectsModuleResolution: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.List_of_folders_to_include_type_definitions_from }, { @@ -36514,9 +37862,9 @@ var ts; name: "types", type: "string" }, - affectsModuleResolution: true, + affectsProgramStructure: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation, transpileOptionValue: undefined }, @@ -36524,7 +37872,7 @@ var ts; name: "allowSyntheticDefaultImports", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Interop_Constraints, description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking }, { @@ -36533,20 +37881,20 @@ var ts; affectsSemanticDiagnostics: true, affectsEmit: true, showInSimplifiedHelpView: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Interop_Constraints, description: ts.Diagnostics.Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for_all_imports_Implies_allowSyntheticDefaultImports }, { name: "preserveSymlinks", type: "boolean", - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Interop_Constraints, description: ts.Diagnostics.Do_not_resolve_the_real_path_of_symlinks, }, { name: "allowUmdGlobalAccess", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Module_Resolution_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Allow_accessing_UMD_globals_from_modules, }, // Source Maps @@ -36555,7 +37903,7 @@ var ts; type: "string", affectsEmit: true, paramType: ts.Diagnostics.LOCATION, - category: ts.Diagnostics.Source_Map_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, }, { @@ -36563,21 +37911,21 @@ var ts; type: "string", affectsEmit: true, paramType: ts.Diagnostics.LOCATION, - category: ts.Diagnostics.Source_Map_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, }, { name: "inlineSourceMap", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Source_Map_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file }, { name: "inlineSources", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Source_Map_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap_to_be_set }, // Experimental @@ -36585,7 +37933,7 @@ var ts; name: "experimentalDecorators", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Experimental_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators }, { @@ -36593,20 +37941,20 @@ var ts; type: "boolean", affectsSemanticDiagnostics: true, affectsEmit: true, - category: ts.Diagnostics.Experimental_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators }, // Advanced { name: "jsxFactory", type: "string", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h }, { name: "jsxFragmentFactory", type: "string", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Specify_the_JSX_fragment_factory_function_to_use_when_targeting_react_JSX_emit_with_jsxFactory_compiler_option_is_specified_e_g_Fragment }, { @@ -36615,14 +37963,14 @@ var ts; affectsSemanticDiagnostics: true, affectsEmit: true, affectsModuleResolution: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react }, { name: "resolveJsonModule", type: "boolean", affectsModuleResolution: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Include_modules_imported_with_json_extension }, { @@ -36631,7 +37979,7 @@ var ts; affectsEmit: true, isFilePath: false, // for correct behaviour, please use outFile - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Backwards_Compatibility, paramType: ts.Diagnostics.FILE, description: ts.Diagnostics.Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file, transpileOptionValue: undefined @@ -36640,26 +37988,26 @@ var ts; name: "reactNamespace", type: "string", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react_JSX_emit }, { name: "skipDefaultLibCheck", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Completeness, description: ts.Diagnostics.Deprecated_Use_skipLibCheck_instead_Skip_type_checking_of_default_library_declaration_files }, { name: "charset", type: "string", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Backwards_Compatibility, description: ts.Diagnostics.The_character_set_of_the_input_files }, { name: "emitBOM", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files }, { @@ -36670,21 +38018,21 @@ var ts; })), affectsEmit: true, paramType: ts.Diagnostics.NEWLINE, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, }, { name: "noErrorTruncation", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Output_Formatting, description: ts.Diagnostics.Do_not_truncate_error_messages }, { name: "noLib", type: "boolean", - affectsModuleResolution: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Language_and_Environment, + affectsProgramStructure: true, description: ts.Diagnostics.Do_not_include_the_default_library_file_lib_d_ts, // We are not returning a sourceFile for lib file when asked by the program, // so pass --noLib to avoid reporting a file not found error. @@ -36694,7 +38042,7 @@ var ts; name: "noResolve", type: "boolean", affectsModuleResolution: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Modules, description: ts.Diagnostics.Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files, // We are not doing a full typecheck, we are not resolving the whole context, // so pass --noResolve to avoid reporting missing file errors. @@ -36704,56 +38052,56 @@ var ts; name: "stripInternal", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation, }, { name: "disableSizeLimit", type: "boolean", - affectsSourceFile: true, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Disable_size_limitations_on_JavaScript_projects + affectsProgramStructure: true, + category: ts.Diagnostics.Editor_Support, + description: ts.Diagnostics.JavaScript_Support }, { name: "disableSourceOfProjectReferenceRedirect", type: "boolean", isTSConfigOnly: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Projects, description: ts.Diagnostics.Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects }, { name: "disableSolutionSearching", type: "boolean", isTSConfigOnly: true, - category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Disable_solution_searching_for_this_project + category: ts.Diagnostics.Projects, + description: ts.Diagnostics.Projects }, { name: "disableReferencedProjectLoad", type: "boolean", isTSConfigOnly: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Projects, description: ts.Diagnostics.Disable_loading_referenced_projects }, { name: "noImplicitUseStrict", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Backwards_Compatibility, description: ts.Diagnostics.Do_not_emit_use_strict_directives_in_module_output }, { name: "noEmitHelpers", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Do_not_generate_custom_helper_functions_like_extends_in_compiled_output }, { name: "noEmitOnError", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, transpileOptionValue: undefined }, @@ -36761,7 +38109,7 @@ var ts; name: "preserveConstEnums", type: "boolean", affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code }, { @@ -36770,14 +38118,14 @@ var ts; affectsEmit: true, isFilePath: true, paramType: ts.Diagnostics.DIRECTORY, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Emit, description: ts.Diagnostics.Output_directory_for_generated_declaration_files, transpileOptionValue: undefined }, { name: "skipLibCheck", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Completeness, description: ts.Diagnostics.Skip_type_checking_of_declaration_files, }, { @@ -36785,7 +38133,7 @@ var ts; type: "boolean", affectsBindDiagnostics: true, affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Do_not_report_errors_on_unused_labels }, { @@ -36793,42 +38141,42 @@ var ts; type: "boolean", affectsBindDiagnostics: true, affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Do_not_report_errors_on_unreachable_code }, { name: "suppressExcessPropertyErrors", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Backwards_Compatibility, description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals, }, { name: "suppressImplicitAnyIndexErrors", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Backwards_Compatibility, description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, }, { name: "forceConsistentCasingInFileNames", type: "boolean", affectsModuleResolution: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Interop_Constraints, description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file }, { name: "maxNodeModuleJsDepth", type: "number", affectsModuleResolution: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.JavaScript_Support, description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files }, { name: "noStrictGenericChecks", type: "boolean", affectsSemanticDiagnostics: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Backwards_Compatibility, description: ts.Diagnostics.Disable_strict_checking_of_generic_signatures_in_function_types, }, { @@ -36836,13 +38184,13 @@ var ts; type: "boolean", affectsSemanticDiagnostics: true, affectsEmit: true, - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Emit_class_fields_with_Define_instead_of_Set, }, { name: "keyofStringsOnly", type: "boolean", - category: ts.Diagnostics.Advanced_Options, + category: ts.Diagnostics.Backwards_Compatibility, description: ts.Diagnostics.Resolve_keyof_to_string_valued_property_names_only_no_numbers_or_symbols, }, { @@ -36854,9 +38202,12 @@ var ts; name: "plugin", type: "object" }, - description: ts.Diagnostics.List_of_language_service_plugins + description: ts.Diagnostics.List_of_language_service_plugins, + category: ts.Diagnostics.Editor_Support, }, - ]); + ]; + /* @internal */ + ts.optionDeclarations = __spreadArray(__spreadArray([], ts.commonOptionsWithBuild), commandOptionsWithoutBuild); /* @internal */ ts.semanticDiagnosticsOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsSemanticDiagnostics; }); /* @internal */ @@ -36868,11 +38219,12 @@ var ts; return !!option.affectsSourceFile || !!option.affectsModuleResolution || !!option.affectsBindDiagnostics; }); /* @internal */ + ts.optionsAffectingProgramStructure = ts.optionDeclarations.filter(function (option) { return !!option.affectsProgramStructure; }); + /* @internal */ ts.transpileOptionValueCompilerOptions = ts.optionDeclarations.filter(function (option) { return ts.hasProperty(option, "transpileOptionValue"); }); - /* @internal */ - ts.buildOpts = __spreadArray(__spreadArray([], ts.commonOptionsWithBuild), [ + var commandOptionsOnlyBuild = [ { name: "verbose", shortName: "v", @@ -36900,7 +38252,9 @@ var ts; description: ts.Diagnostics.Delete_the_outputs_of_all_projects, type: "boolean" } - ]); + ]; + /* @internal */ + ts.buildOpts = __spreadArray(__spreadArray([], ts.commonOptionsWithBuild), commandOptionsOnlyBuild); /* @internal */ ts.typeAcquisitionDeclarations = [ { @@ -36954,6 +38308,10 @@ var ts; return optionsNameMapCache || (optionsNameMapCache = createOptionNameMap(ts.optionDeclarations)); } ts.getOptionsNameMap = getOptionsNameMap; + var compilerOptionsAlternateMode = { + diagnostic: ts.Diagnostics.Compiler_option_0_may_only_be_used_with_build, + getOptionsNameMap: getBuildOptionsNameMap + }; /* @internal */ ts.defaultInitCompilerOptions = { module: ts.ModuleKind.CommonJS, @@ -36987,13 +38345,13 @@ var ts; } /* @internal */ function parseCustomTypeOption(opt, value, errors) { - return convertJsonOptionOfCustomType(opt, trimString(value || ""), errors); + return convertJsonOptionOfCustomType(opt, ts.trimString(value || ""), errors); } ts.parseCustomTypeOption = parseCustomTypeOption; /* @internal */ function parseListTypeOption(opt, value, errors) { if (value === void 0) { value = ""; } - value = trimString(value); + value = ts.trimString(value); if (ts.startsWith(value, "-")) { return undefined; } @@ -37015,6 +38373,10 @@ var ts; return option.name; } function createUnknownOptionError(unknownOption, diagnostics, createDiagnostics, unknownOptionErrorText) { + var _a; + if ((_a = diagnostics.alternateMode) === null || _a === void 0 ? void 0 : _a.getOptionsNameMap().optionsNameMap.has(unknownOption.toLowerCase())) { + return createDiagnostics(diagnostics.alternateMode.diagnostic, unknownOption); + } var possibleOption = ts.getSpellingSuggestion(unknownOption, diagnostics.optionDeclarations, getOptionName); return possibleOption ? createDiagnostics(diagnostics.unknownDidYouMeanDiagnostic, unknownOptionErrorText || unknownOption, possibleOption.name) : @@ -37169,6 +38531,7 @@ var ts; } /*@internal*/ ts.compilerOptionsDidYouMeanDiagnostics = { + alternateMode: compilerOptionsAlternateMode, getOptionsNameMap: getOptionsNameMap, optionDeclarations: ts.optionDeclarations, unknownOptionDiagnostic: ts.Diagnostics.Unknown_compiler_option_0, @@ -37201,7 +38564,12 @@ var ts; function getBuildOptionsNameMap() { return buildOptionsNameMapCache || (buildOptionsNameMapCache = createOptionNameMap(ts.buildOpts)); } + var buildOptionsAlternateMode = { + diagnostic: ts.Diagnostics.Compiler_option_0_may_not_be_used_with_build, + getOptionsNameMap: getOptionsNameMap + }; var buildOptionsDidYouMeanDiagnostics = { + alternateMode: buildOptionsAlternateMode, getOptionsNameMap: getBuildOptionsNameMap, optionDeclarations: ts.buildOpts, unknownOptionDiagnostic: ts.Diagnostics.Unknown_build_option_0, @@ -37277,7 +38645,7 @@ var ts; function parseConfigFileTextToJson(fileName, jsonText) { var jsonSourceFile = ts.parseJsonText(fileName, jsonText); return { - config: convertToObject(jsonSourceFile, jsonSourceFile.parseDiagnostics), + config: convertConfigFileToObject(jsonSourceFile, jsonSourceFile.parseDiagnostics, /*reportOptionsErrors*/ false, /*optionsIterator*/ undefined), error: jsonSourceFile.parseDiagnostics.length ? jsonSourceFile.parseDiagnostics[0] : undefined }; } @@ -37367,7 +38735,8 @@ var ts; }, { name: "extends", - type: "string" + type: "string", + category: ts.Diagnostics.File_Management, }, { name: "references", @@ -37375,7 +38744,8 @@ var ts; element: { name: "references", type: "object" - } + }, + category: ts.Diagnostics.Projects, }, { name: "files", @@ -37383,7 +38753,8 @@ var ts; element: { name: "files", type: "string" - } + }, + category: ts.Diagnostics.File_Management, }, { name: "include", @@ -37391,7 +38762,8 @@ var ts; element: { name: "include", type: "string" - } + }, + category: ts.Diagnostics.File_Management, }, { name: "exclude", @@ -37399,7 +38771,8 @@ var ts; element: { name: "exclude", type: "string" - } + }, + category: ts.Diagnostics.File_Management, }, ts.compileOnSaveCommandLineOption ]) @@ -37407,11 +38780,31 @@ var ts; } return _tsconfigRootOptions; } + function convertConfigFileToObject(sourceFile, errors, reportOptionsErrors, optionsIterator) { + 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 !== 202 /* 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 + // array is a well-formed configuration object, made into an array element by stray characters. + if (ts.isArrayLiteralExpression(rootExpression)) { + var firstObject = ts.find(rootExpression.elements, ts.isObjectLiteralExpression); + if (firstObject) { + return convertToObjectWorker(sourceFile, firstObject, errors, /*returnValue*/ true, knownRootOptions, optionsIterator); + } + } + return {}; + } + return convertToObjectWorker(sourceFile, rootExpression, errors, /*returnValue*/ true, knownRootOptions, optionsIterator); + } /** * Convert the json syntax tree into the json value */ function convertToObject(sourceFile, errors) { - return convertToObjectWorker(sourceFile, errors, /*returnValue*/ true, /*knownRootOptions*/ undefined, /*jsonConversionNotifier*/ undefined); + var _a; + return convertToObjectWorker(sourceFile, (_a = sourceFile.statements[0]) === null || _a === void 0 ? void 0 : _a.expression, errors, /*returnValue*/ true, /*knownRootOptions*/ undefined, /*jsonConversionNotifier*/ undefined); } ts.convertToObject = convertToObject; /** @@ -37420,18 +38813,18 @@ var ts; * Otherwise it just checks the errors and returns undefined */ /*@internal*/ - function convertToObjectWorker(sourceFile, errors, returnValue, knownRootOptions, jsonConversionNotifier) { - if (!sourceFile.statements.length) { + function convertToObjectWorker(sourceFile, rootExpression, errors, returnValue, knownRootOptions, jsonConversionNotifier) { + if (!rootExpression) { return returnValue ? {} : undefined; } - return convertPropertyValueToJson(sourceFile.statements[0].expression, knownRootOptions); + return convertPropertyValueToJson(rootExpression, knownRootOptions); function isRootOptionMap(knownOptions) { return knownRootOptions && knownRootOptions.elementOptions === knownOptions; } function convertObjectLiteralExpressionToJson(node, knownOptions, extraKeyDiagnostics, parentOption) { var result = returnValue ? {} : undefined; var _loop_4 = function (element) { - if (element.kind !== 288 /* PropertyAssignment */) { + if (element.kind !== 290 /* PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); return "continue"; } @@ -37498,13 +38891,13 @@ var ts; function convertPropertyValueToJson(valueExpression, option) { var invalidReported; switch (valueExpression.kind) { - case 109 /* TrueKeyword */: + case 110 /* TrueKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return validateValue(/*value*/ true); - case 94 /* FalseKeyword */: + case 95 /* FalseKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return validateValue(/*value*/ false); - case 103 /* NullKeyword */: + case 104 /* 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 */: @@ -37525,13 +38918,13 @@ var ts; case 8 /* NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return validateValue(Number(valueExpression.text)); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: if (valueExpression.operator !== 40 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { break; // not valid JSON syntax } reportInvalidOptionValue(option && option.type !== "number"); return validateValue(-Number(valueExpression.operand.text)); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -37548,7 +38941,7 @@ var ts; return validateValue(convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined)); } - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return validateValue(convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element)); } @@ -37686,7 +39079,7 @@ var ts; if (ts.hasProperty(options, name)) { // tsconfig only options cannot be specified via command line, // so we can assume that only types that can appear here string | number | boolean - if (optionsNameMap.has(name) && optionsNameMap.get(name).category === ts.Diagnostics.Command_line_Options) { + if (optionsNameMap.has(name) && (optionsNameMap.get(name).category === ts.Diagnostics.Command_line_Options || optionsNameMap.get(name).category === ts.Diagnostics.Output_Formatting)) { return "continue"; } var value = options[name]; @@ -37752,13 +39145,11 @@ var ts; function makePadding(paddingLength) { return Array(paddingLength + 1).join(" "); } - function isAllowedOption(_a) { - var category = _a.category, name = _a.name; - // Skip options which do not have a category or have category `Command_line_Options` - // Exclude all possible `Advanced_Options` in tsconfig.json which were NOT defined in command line - return category !== undefined - && category !== ts.Diagnostics.Command_line_Options - && (category !== ts.Diagnostics.Advanced_Options || compilerOptionsMap.has(name)); + function isAllowedOptionForOutput(_a) { + var category = _a.category, name = _a.name, isCommandLineOnly = _a.isCommandLineOnly; + // Skip options which do not have a category or have categories which are more niche + var categoriesToSkip = [ts.Diagnostics.Command_line_Options, ts.Diagnostics.Editor_Support, ts.Diagnostics.Compiler_Diagnostics, ts.Diagnostics.Backwards_Compatibility, ts.Diagnostics.Watch_and_Build_Modes, ts.Diagnostics.Output_Formatting]; + return !isCommandLineOnly && category !== undefined && (!categoriesToSkip.includes(category) || compilerOptionsMap.has(name)); } function writeConfigurations() { // Filter applicable options to place in the file @@ -37766,7 +39157,7 @@ var ts; for (var _i = 0, optionDeclarations_1 = ts.optionDeclarations; _i < optionDeclarations_1.length; _i++) { var option = optionDeclarations_1[_i]; var category = option.category; - if (isAllowedOption(option)) { + if (isAllowedOptionForOutput(option)) { categorizedOptions.add(ts.getLocaleSpecificMessage(category), option); } } @@ -37983,6 +39374,7 @@ var ts; validatedFilesSpec: ts.filter(filesSpecs, ts.isString), validatedIncludeSpecs: validatedIncludeSpecs, validatedExcludeSpecs: validatedExcludeSpecs, + pathPatterns: undefined, // Initialized on first use }; } function getFileNames(basePath) { @@ -38096,14 +39488,14 @@ var ts; if (ownConfig.extendedConfigPath) { // copy the resolution stack so it is never reused between branches in potential diamond-problem scenarios. resolutionStack = resolutionStack.concat([resolvedPath]); - var extendedConfig = getExtendedConfig(sourceFile, ownConfig.extendedConfigPath, host, basePath, resolutionStack, errors, extendedConfigCache); + var extendedConfig = getExtendedConfig(sourceFile, ownConfig.extendedConfigPath, host, resolutionStack, errors, extendedConfigCache); if (extendedConfig && isSuccessfulParsedTsconfig(extendedConfig)) { var baseRaw_1 = extendedConfig.raw; var raw_1 = ownConfig.raw; + var relativeDifference_1; var setPropertyInRawIfNotUndefined = function (propertyName) { - var value = raw_1[propertyName] || baseRaw_1[propertyName]; - if (value) { - raw_1[propertyName] = value; + if (!raw_1[propertyName] && baseRaw_1[propertyName]) { + raw_1[propertyName] = ts.map(baseRaw_1[propertyName], function (path) { return ts.isRootedDiskPath(path) ? path : ts.combinePaths(relativeDifference_1 || (relativeDifference_1 = ts.convertToRelativePath(ts.getDirectoryPath(ownConfig.extendedConfigPath), basePath, ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames))), path); }); } }; setPropertyInRawIfNotUndefined("include"); @@ -38185,7 +39577,7 @@ var ts; } } }; - var json = convertToObjectWorker(sourceFile, errors, /*returnValue*/ true, getTsconfigRootOptionsMap(), optionsIterator); + var json = convertConfigFileToObject(sourceFile, errors, /*reportOptionsErrors*/ true, optionsIterator); if (!typeAcquisition) { if (typingOptionstypeAcquisition) { typeAcquisition = (typingOptionstypeAcquisition.enableAutoDiscovery !== undefined) ? @@ -38223,7 +39615,7 @@ var ts; errors.push(createDiagnostic(ts.Diagnostics.File_0_not_found, extendedConfig)); return undefined; } - function getExtendedConfig(sourceFile, extendedConfigPath, host, basePath, resolutionStack, errors, extendedConfigCache) { + function getExtendedConfig(sourceFile, extendedConfigPath, host, resolutionStack, errors, extendedConfigCache) { var _a; var path = host.useCaseSensitiveFileNames ? extendedConfigPath : ts.toFileNameLowerCase(extendedConfigPath); var value; @@ -38235,22 +39627,7 @@ var ts; else { extendedResult = readJsonConfigFile(extendedConfigPath, function (path) { return host.readFile(path); }); if (!extendedResult.parseDiagnostics.length) { - var extendedDirname = ts.getDirectoryPath(extendedConfigPath); - extendedConfig = parseConfig(/*json*/ undefined, extendedResult, host, extendedDirname, ts.getBaseFileName(extendedConfigPath), resolutionStack, errors, extendedConfigCache); - if (isSuccessfulParsedTsconfig(extendedConfig)) { - // Update the paths to reflect base path - var relativeDifference_1 = ts.convertToRelativePath(extendedDirname, basePath, ts.identity); - var updatePath_1 = function (path) { return ts.isRootedDiskPath(path) ? path : ts.combinePaths(relativeDifference_1, path); }; - var mapPropertiesInRawIfNotUndefined = function (propertyName) { - if (raw_2[propertyName]) { - raw_2[propertyName] = ts.map(raw_2[propertyName], updatePath_1); - } - }; - var raw_2 = extendedConfig.raw; - mapPropertiesInRawIfNotUndefined("include"); - mapPropertiesInRawIfNotUndefined("exclude"); - mapPropertiesInRawIfNotUndefined("files"); - } + extendedConfig = parseConfig(/*json*/ undefined, extendedResult, host, ts.getDirectoryPath(extendedConfigPath), ts.getBaseFileName(extendedConfigPath), resolutionStack, errors, extendedConfigCache); } if (extendedConfigCache) { extendedConfigCache.set(path, { extendedResult: extendedResult, extendedConfig: extendedConfig }); @@ -38395,9 +39772,6 @@ var ts; function convertJsonOptionOfListType(option, values, basePath, errors) { return ts.filter(ts.map(values, function (v) { return convertJsonOption(option.element, v, basePath, errors); }), function (v) { return !!v; }); } - function trimString(s) { - return typeof s.trim === "function" ? s.trim() : s.replace(/^[\s]+|[\s]+$/g, ""); - } /** * Tests for a path that ends in a recursive directory wildcard. * Matches **, \**, **\, and \**\, but not a**b. @@ -38410,34 +39784,6 @@ var ts; * \/?$ # matches an optional trailing directory separator at the end of the string. */ var invalidTrailingRecursionPattern = /(^|\/)\*\*\/?$/; - /** - * Tests for a path where .. appears after a recursive directory wildcard. - * Matches **\..\*, **\a\..\*, and **\.., but not ..\**\* - * - * NOTE: used \ in place of / above to avoid issues with multiline comments. - * - * Breakdown: - * (^|\/) # matches either the beginning of the string or a directory separator. - * \*\*\/ # matches a recursive directory wildcard "**" followed by a directory separator. - * (.*\/)? # optionally matches any number of characters followed by a directory separator. - * \.\. # matches a parent directory path component ".." - * ($|\/) # matches either the end of the string or a directory separator. - */ - var invalidDotDotAfterRecursiveWildcardPattern = /(^|\/)\*\*\/(.*\/)?\.\.($|\/)/; - /** - * Tests for a path containing a wildcard character in a directory component of the path. - * Matches \*\, \?\, and \a*b\, but not \a\ or \a\*. - * - * NOTE: used \ in place of / above to avoid issues with multiline comments. - * - * Breakdown: - * \/ # matches a directory separator. - * [^/]*? # matches any number of characters excluding directory separators (non-greedy). - * [*?] # matches either a wildcard character (* or ?) - * [^/]* # matches any number of characters excluding directory separators (greedy). - * \/ # matches a directory separator. - */ - var watchRecursivePattern = /\/[^/]*?[*?][^/]*\//; /** * Matches the portion of a wildcard path that does not contain wildcards. * Matches \a of \a\*, or \a\b\c of \a\b\c\?\d. @@ -38478,7 +39824,7 @@ var ts; // via wildcard of *.json kind var wildCardJsonFileMap = new ts.Map(); var validatedFilesSpec = configFileSpecs.validatedFilesSpec, validatedIncludeSpecs = configFileSpecs.validatedIncludeSpecs, validatedExcludeSpecs = configFileSpecs.validatedExcludeSpecs; - // Rather than requery this for each file and filespec, we query the supported extensions + // Rather than re-query this for each file and filespec, we query the supported extensions // once and store it on the expansion context. var supportedExtensions = ts.getSupportedExtensions(options, extraFileExtensions); var supportedExtensionsWithJsonIfResolveJsonModule = ts.getSuppoertedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions); @@ -38556,9 +39902,22 @@ var ts; return matchesExcludeWorker(pathToCheck, validatedExcludeSpecs, useCaseSensitiveFileNames, currentDirectory, basePath); } ts.isExcludedFile = isExcludedFile; + function invalidDotDotAfterRecursiveWildcard(s) { + // We used to use the regex /(^|\/)\*\*\/(.*\/)?\.\.($|\/)/ to check for this case, but + // in v8, that has polynomial performance because the recursive wildcard match - **/ - + // can be matched in many arbitrary positions when multiple are present, resulting + // in bad backtracking (and we don't care which is matched - just that some /.. segment + // comes after some **/ segment). + var wildcardIndex = ts.startsWith(s, "**/") ? 0 : s.indexOf("/**/"); + if (wildcardIndex === -1) { + return false; + } + var lastDotIndex = ts.endsWith(s, "/..") ? s.length : s.lastIndexOf("/../"); + return lastDotIndex > wildcardIndex; + } /* @internal */ function matchesExclude(pathToCheck, excludeSpecs, useCaseSensitiveFileNames, currentDirectory) { - return matchesExcludeWorker(pathToCheck, ts.filter(excludeSpecs, function (spec) { return !invalidDotDotAfterRecursiveWildcardPattern.test(spec); }), useCaseSensitiveFileNames, currentDirectory); + return matchesExcludeWorker(pathToCheck, ts.filter(excludeSpecs, function (spec) { return !invalidDotDotAfterRecursiveWildcard(spec); }), useCaseSensitiveFileNames, currentDirectory); } ts.matchesExclude = matchesExclude; function matchesExcludeWorker(pathToCheck, excludeSpecs, useCaseSensitiveFileNames, currentDirectory, basePath) { @@ -38591,7 +39950,7 @@ var ts; if (disallowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) { return [ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec]; } - else if (invalidDotDotAfterRecursiveWildcardPattern.test(spec)) { + else if (invalidDotDotAfterRecursiveWildcard(spec)) { return [ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec]; } } @@ -38652,9 +40011,18 @@ var ts; function getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames) { var match = wildcardDirectoryPattern.exec(spec); if (match) { + // We check this with a few `indexOf` calls because 3 `indexOf`/`lastIndexOf` calls is + // less algorithmically complex (roughly O(3n) worst-case) than the regex we used to use, + // \/[^/]*?[*?][^/]*\/ which was polynominal in v8, since arbitrary sequences of wildcard + // characters could match any of the central patterns, resulting in bad backtracking. + var questionWildcardIndex = spec.indexOf("?"); + var starWildcardIndex = spec.indexOf("*"); + var lastDirectorySeperatorIndex = spec.lastIndexOf(ts.directorySeparator); return { key: useCaseSensitiveFileNames ? match[0] : ts.toFileNameLowerCase(match[0]), - flags: watchRecursivePattern.test(spec) ? 1 /* Recursive */ : 0 /* None */ + flags: (questionWildcardIndex !== -1 && questionWildcardIndex < lastDirectorySeperatorIndex) + || (starWildcardIndex !== -1 && starWildcardIndex < lastDirectorySeperatorIndex) + ? 1 /* Recursive */ : 0 /* None */ }; } if (ts.isImplicitGlob(spec)) { @@ -38947,13 +40315,24 @@ var ts; * This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups * is assumed to be the same as root directory of the project. */ - function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference) { + function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, cache) { var traceEnabled = isTraceEnabled(options, host); if (redirectedReference) { options = redirectedReference.commandLine.options; } - var failedLookupLocations = []; - var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations }; + var containingDirectory = containingFile ? ts.getDirectoryPath(containingFile) : undefined; + var perFolderCache = containingDirectory ? cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference) : undefined; + var result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName); + if (result) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1, typeReferenceDirectiveName, containingFile); + if (redirectedReference) + trace(host, ts.Diagnostics.Using_compiler_options_of_project_reference_redirect_0, redirectedReference.sourceFile.fileName); + trace(host, ts.Diagnostics.Resolution_for_type_reference_directive_0_was_found_in_cache_from_location_1, typeReferenceDirectiveName, containingDirectory); + traceResult(result); + } + return result; + } var typeRoots = getEffectiveTypeRoots(options, host); if (traceEnabled) { if (containingFile === undefined) { @@ -38976,6 +40355,8 @@ var ts; trace(host, ts.Diagnostics.Using_compiler_options_of_project_reference_redirect_0, redirectedReference.sourceFile.fileName); } } + var failedLookupLocations = []; + var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache }; var resolved = primaryLookup(); var primary = true; if (!resolved) { @@ -38986,17 +40367,31 @@ var ts; if (resolved) { var fileName = resolved.fileName, packageId = resolved.packageId; var resolvedFileName = options.preserveSymlinks ? fileName : realPath(fileName, host, traceEnabled); - if (traceEnabled) { - if (packageId) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3, typeReferenceDirectiveName, resolvedFileName, ts.packageIdToString(packageId), primary); - } - else { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFileName, primary); - } + resolvedTypeReferenceDirective = { + primary: primary, + resolvedFileName: resolvedFileName, + originalPath: fileName === resolvedFileName ? undefined : fileName, + packageId: packageId, + isExternalLibraryImport: pathContainsNodeModules(fileName), + }; + } + result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations }; + perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, result); + if (traceEnabled) + traceResult(result); + return result; + function traceResult(result) { + var _a; + if (!((_a = result.resolvedTypeReferenceDirective) === null || _a === void 0 ? void 0 : _a.resolvedFileName)) { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); + } + else if (result.resolvedTypeReferenceDirective.packageId) { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3, typeReferenceDirectiveName, result.resolvedTypeReferenceDirective.resolvedFileName, ts.packageIdToString(result.resolvedTypeReferenceDirective.packageId), result.resolvedTypeReferenceDirective.primary); + } + else { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, result.resolvedTypeReferenceDirective.resolvedFileName, result.resolvedTypeReferenceDirective.primary); } - resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolvedFileName, packageId: packageId, isExternalLibraryImport: pathContainsNodeModules(fileName) }; } - return { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations }; function primaryLookup() { // Check primary library paths if (typeRoots && typeRoots.length) { @@ -39026,20 +40421,16 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); } - var result = void 0; + var result_4; if (!ts.isExternalModuleNameRelative(typeReferenceDirectiveName)) { var searchResult = loadModuleFromNearestNodeModulesDirectory(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, moduleResolutionState, /*cache*/ undefined, /*redirectedReference*/ undefined); - result = searchResult && searchResult.value; + result_4 = searchResult && searchResult.value; } else { var candidate = ts.normalizePathAndParts(ts.combinePaths(initialLocationForSecondaryLookup, typeReferenceDirectiveName)).path; - result = nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, /*onlyRecordFailures*/ false, moduleResolutionState, /*considerPackageJson*/ true); - } - var resolvedFile = resolvedTypeScriptOnly(result); - if (!resolvedFile && traceEnabled) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); + result_4 = nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, /*onlyRecordFailures*/ false, moduleResolutionState, /*considerPackageJson*/ true); } - return resolvedFile; + return resolvedTypeScriptOnly(result_4); } else { if (traceEnabled) { @@ -39094,22 +40485,21 @@ var ts; return result; } ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; - function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options) { - return createModuleResolutionCacheWithMaps(createCacheWithRedirects(options), createCacheWithRedirects(options), currentDirectory, getCanonicalFileName); - } - ts.createModuleResolutionCache = createModuleResolutionCache; /*@internal*/ function createCacheWithRedirects(options) { var ownMap = new ts.Map(); var redirectsMap = new ts.Map(); return { - ownMap: ownMap, + getOwnMap: getOwnMap, redirectsMap: redirectsMap, getOrCreateMapOfCacheRedirects: getOrCreateMapOfCacheRedirects, clear: clear, setOwnOptions: setOwnOptions, setOwnMap: setOwnMap }; + function getOwnMap() { + return ownMap; + } function setOwnOptions(newOptions) { options = newOptions; } @@ -39135,26 +40525,88 @@ var ts; } } ts.createCacheWithRedirects = createCacheWithRedirects; - /*@internal*/ - function createModuleResolutionCacheWithMaps(directoryToModuleNameMap, moduleNameToDirectoryMap, currentDirectory, getCanonicalFileName) { - return { getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, directoryToModuleNameMap: directoryToModuleNameMap, moduleNameToDirectoryMap: moduleNameToDirectoryMap }; + function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName) { + var cache; + return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear }; + function getPackageJsonInfo(packageJsonPath) { + return cache === null || cache === void 0 ? void 0 : cache.get(ts.toPath(packageJsonPath, currentDirectory, getCanonicalFileName)); + } + function setPackageJsonInfo(packageJsonPath, info) { + (cache || (cache = new ts.Map())).set(ts.toPath(packageJsonPath, currentDirectory, getCanonicalFileName), info); + } + function clear() { + cache = undefined; + } + } + function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) { + var cache = cacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference); + var result = cache.get(key); + if (!result) { + result = create(); + cache.set(key, result); + } + return result; + } + function updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap) { + if (!options.configFile) + return; + if (directoryToModuleNameMap.redirectsMap.size === 0) { + // The own map will be for projectCompilerOptions + ts.Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.redirectsMap.size === 0); + ts.Debug.assert(directoryToModuleNameMap.getOwnMap().size === 0); + ts.Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.getOwnMap().size === 0); + directoryToModuleNameMap.redirectsMap.set(options.configFile.path, directoryToModuleNameMap.getOwnMap()); + moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.redirectsMap.set(options.configFile.path, moduleNameToDirectoryMap.getOwnMap()); + } + else { + // Set correct own map + ts.Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.redirectsMap.size > 0); + var ref = { + sourceFile: options.configFile, + commandLine: { options: options } + }; + directoryToModuleNameMap.setOwnMap(directoryToModuleNameMap.getOrCreateMapOfCacheRedirects(ref)); + moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.setOwnMap(moduleNameToDirectoryMap.getOrCreateMapOfCacheRedirects(ref)); + } + directoryToModuleNameMap.setOwnOptions(options); + moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.setOwnOptions(options); + } + function createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap) { + return { + getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, + clear: clear, + update: update, + }; + function clear() { + directoryToModuleNameMap.clear(); + } + function update(options) { + updateRedirectsMap(options, directoryToModuleNameMap); + } function getOrCreateCacheForDirectory(directoryName, redirectedReference) { var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName); return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, function () { return new ts.Map(); }); } + } + function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options, directoryToModuleNameMap, moduleNameToDirectoryMap) { + var preDirectoryResolutionCache = 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; } }); + function clear() { + preDirectoryResolutionCache.clear(); + moduleNameToDirectoryMap.clear(); + packageJsonInfoCache.clear(); + } + function update(options) { + updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap); + } function getOrCreateCacheForModuleName(nonRelativeModuleName, redirectedReference) { ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName)); return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, nonRelativeModuleName, createPerModuleNameCache); } - function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) { - var cache = cacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference); - var result = cache.get(key); - if (!result) { - result = create(); - cache.set(key, result); - } - return result; - } function createPerModuleNameCache() { var directoryPathMap = new ts.Map(); return { get: get, set: set }; @@ -39221,7 +40673,17 @@ var ts; } } } - ts.createModuleResolutionCacheWithMaps = createModuleResolutionCacheWithMaps; + ts.createModuleResolutionCache = createModuleResolutionCache; + function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache, directoryToModuleNameMap) { + var preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options))); + packageJsonInfoCache || (packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName)); + return __assign(__assign(__assign({}, packageJsonInfoCache), preDirectoryResolutionCache), { clear: clear }); + function clear() { + preDirectoryResolutionCache.clear(); + packageJsonInfoCache.clear(); + } + } + ts.createTypeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache; function resolveModuleNameFromCache(moduleName, containingFile, cache) { var containingDirectory = ts.getDirectoryPath(containingFile); var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); @@ -39370,7 +40832,8 @@ var ts; } } function tryLoadModuleUsingPathsIfEligible(extensions, moduleName, loader, state) { - var _a = state.compilerOptions, baseUrl = _a.baseUrl, paths = _a.paths; + var _a; + var _b = state.compilerOptions, baseUrl = _b.baseUrl, paths = _b.paths, configFile = _b.configFile; if (paths && !ts.pathIsRelative(moduleName)) { if (state.traceEnabled) { if (baseUrl) { @@ -39379,7 +40842,8 @@ var ts; trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); } var baseDirectory = ts.getPathsBasePath(state.compilerOptions, state.host); // Always defined when 'paths' is defined - return tryLoadModuleUsingPaths(extensions, moduleName, baseDirectory, paths, loader, /*onlyRecordFailures*/ false, state); + var pathPatterns = (configFile === null || configFile === void 0 ? void 0 : configFile.configFileSpecs) ? (_a = configFile.configFileSpecs).pathPatterns || (_a.pathPatterns = ts.tryParsePatterns(paths)) : undefined; + return tryLoadModuleUsingPaths(extensions, moduleName, baseDirectory, paths, pathPatterns, loader, /*onlyRecordFailures*/ false, state); } } function tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, state) { @@ -39499,7 +40963,7 @@ var ts; var _a, _b; var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations }; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache }; var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); }); return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, state.resultFromCache); function tryResolve(extensions) { @@ -39559,7 +41023,7 @@ var ts; } var resolvedFromFile = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state); if (resolvedFromFile) { - var packageDirectory = considerPackageJson ? parseNodeModuleFromPath(resolvedFromFile) : undefined; + var packageDirectory = considerPackageJson ? parseNodeModuleFromPath(resolvedFromFile.path) : undefined; var packageInfo = packageDirectory ? getPackageJsonInfo(packageDirectory, /*onlyRecordFailures*/ false, state) : undefined; return withPackageId(packageInfo, resolvedFromFile); } @@ -39592,8 +41056,9 @@ var ts; * For `/node_modules/@types/foo/bar/index.d.ts` this is packageDirectory: "@types/foo" * For `/node_modules/foo/bar/index.d.ts` this is packageDirectory: "foo" */ + /* @internal */ function parseNodeModuleFromPath(resolved) { - var path = ts.normalizePath(resolved.path); + var path = ts.normalizePath(resolved); var idx = path.lastIndexOf(ts.nodeModulesPathPart); if (idx === -1) { return undefined; @@ -39605,6 +41070,7 @@ var ts; } return path.slice(0, indexAfterPackageName); } + ts.parseNodeModuleFromPath = parseNodeModuleFromPath; function moveToNextDirectorySeparatorIfAvailable(path, prevSeparatorIndex) { var nextSeparatorIndex = path.indexOf(ts.directorySeparator, prevSeparatorIndex + 1); return nextSeparatorIndex === -1 ? prevSeparatorIndex : nextSeparatorIndex; @@ -39688,21 +41154,43 @@ var ts; return withPackageId(packageInfo, loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJsonContent, versionPaths)); } function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) { + var _a, _b, _c; var host = state.host, traceEnabled = state.traceEnabled; - var directoryExists = !onlyRecordFailures && ts.directoryProbablyExists(packageDirectory, host); var packageJsonPath = ts.combinePaths(packageDirectory, "package.json"); + if (onlyRecordFailures) { + state.failedLookupLocations.push(packageJsonPath); + return undefined; + } + var existing = (_a = state.packageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.getPackageJsonInfo(packageJsonPath); + if (existing !== undefined) { + if (typeof existing !== "boolean") { + if (traceEnabled) + trace(host, ts.Diagnostics.File_0_exists_according_to_earlier_cached_lookups, packageJsonPath); + return existing; + } + else { + if (existing && traceEnabled) + trace(host, ts.Diagnostics.File_0_does_not_exist_according_to_earlier_cached_lookups, packageJsonPath); + state.failedLookupLocations.push(packageJsonPath); + return undefined; + } + } + var directoryExists = ts.directoryProbablyExists(packageDirectory, host); if (directoryExists && host.fileExists(packageJsonPath)) { var packageJsonContent = ts.readJson(packageJsonPath, host); if (traceEnabled) { trace(host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); } var versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state); - return { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths }; + var result = { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths }; + (_b = state.packageJsonInfoCache) === null || _b === void 0 ? void 0 : _b.setPackageJsonInfo(packageJsonPath, result); + return result; } else { if (directoryExists && traceEnabled) { trace(host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); } + (_c = state.packageJsonInfoCache) === null || _c === void 0 ? void 0 : _c.setPackageJsonInfo(packageJsonPath, directoryExists); // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results state.failedLookupLocations.push(packageJsonPath); } @@ -39753,7 +41241,7 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2, versionPaths.version, ts.version, moduleName); } - var result = tryLoadModuleUsingPaths(extensions, moduleName, candidate, versionPaths.paths, loader, onlyRecordFailuresForPackageFile || onlyRecordFailuresForIndex, state); + var result = tryLoadModuleUsingPaths(extensions, moduleName, candidate, versionPaths.paths, /*pathPatterns*/ undefined, loader, onlyRecordFailuresForPackageFile || onlyRecordFailuresForIndex, state); if (result) { return removeIgnoredPackageId(result.value); } @@ -39860,7 +41348,7 @@ var ts; trace(state.host, ts.Diagnostics.package_json_has_a_typesVersions_entry_0_that_matches_compiler_version_1_looking_for_a_pattern_to_match_module_name_2, packageInfo.versionPaths.version, ts.version, rest); } var packageDirectoryExists = nodeModulesDirectoryExists && ts.directoryProbablyExists(packageDirectory, state.host); - var fromPaths = tryLoadModuleUsingPaths(extensions, rest, packageDirectory, packageInfo.versionPaths.paths, loader, !packageDirectoryExists, state); + var fromPaths = tryLoadModuleUsingPaths(extensions, rest, packageDirectory, packageInfo.versionPaths.paths, /*pathPatterns*/ undefined, loader, !packageDirectoryExists, state); if (fromPaths) { return fromPaths.value; } @@ -39868,8 +41356,9 @@ var ts; } return loader(extensions, candidate, !nodeModulesDirectoryExists, state); } - function tryLoadModuleUsingPaths(extensions, moduleName, baseDirectory, paths, loader, onlyRecordFailures, state) { - var matchedPattern = ts.matchPatternOrExact(ts.getOwnKeys(paths), moduleName); + function tryLoadModuleUsingPaths(extensions, moduleName, baseDirectory, paths, pathPatterns, loader, onlyRecordFailures, state) { + pathPatterns || (pathPatterns = ts.tryParsePatterns(paths)); + var matchedPattern = ts.matchPatternOrExact(pathPatterns, moduleName); if (matchedPattern) { var matchedStar_1 = ts.isString(matchedPattern) ? undefined : ts.matchedText(matchedPattern, moduleName); var matchedPatternText = ts.isString(matchedPattern) ? matchedPattern : ts.patternText(matchedPattern); @@ -39951,7 +41440,7 @@ var ts; function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) { var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations }; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache }; var containingDirectory = ts.getDirectoryPath(containingFile); var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); // No originalPath because classic resolution doesn't resolve realPath @@ -39992,13 +41481,13 @@ var ts; * This is the minumum code needed to expose that functionality; the rest is in the host. */ /* @internal */ - function loadModuleFromGlobalCache(moduleName, projectName, compilerOptions, host, globalCache) { + function loadModuleFromGlobalCache(moduleName, projectName, compilerOptions, host, globalCache, packageJsonInfoCache) { var traceEnabled = isTraceEnabled(compilerOptions, host); if (traceEnabled) { trace(host, ts.Diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2, projectName, moduleName, globalCache); } var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations }; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: packageJsonInfoCache }; var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, /*typesScopeOnly*/ false); return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, state.resultFromCache); } @@ -40044,26 +41533,26 @@ var ts; // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: return 0 /* NonInstantiated */; // 2. const enum declarations - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: if (ts.isEnumConst(node)) { return 2 /* ConstEnumOnly */; } break; // 3. non-exported import declarations - case 261 /* ImportDeclaration */: - case 260 /* ImportEqualsDeclaration */: + case 263 /* ImportDeclaration */: + case 262 /* ImportEqualsDeclaration */: if (!(ts.hasSyntacticModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } break; // 4. Export alias declarations pointing at only uninstantiated modules or things uninstantiated modules contain - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: var exportDeclaration = node; - if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 268 /* NamedExports */) { + if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 270 /* NamedExports */) { var state = 0 /* NonInstantiated */; for (var _i = 0, _a = exportDeclaration.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; @@ -40079,7 +41568,7 @@ var ts; } break; // 5. other uninstantiated module declarations. - case 257 /* ModuleBlock */: { + case 259 /* ModuleBlock */: { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateCached(n, visited); @@ -40101,9 +41590,9 @@ var ts; }); return state_1; } - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return getModuleInstanceState(node, visited); - case 78 /* Identifier */: + case 79 /* Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should // be considered the same as type alias if (node.isInJSDocNamespace) { @@ -40173,14 +41662,14 @@ var ts; } var binder = createBinder(); function bindSourceFile(file, options) { - ts.tracing.push("bind" /* Bind */, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("bind" /* Bind */, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeBind"); ts.perfLogger.logStartBindFile("" + file.fileName); binder(file, options); ts.perfLogger.logStopBindFile(); ts.performance.mark("afterBind"); ts.performance.measure("Bind", "beforeBind", "afterBind"); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } ts.bindSourceFile = bindSourceFile; function createBinder() { @@ -40219,6 +41708,7 @@ var ts; var classifiableNames; var unreachableFlow = { flags: 1 /* Unreachable */ }; var reportedUnreachableFlow = { flags: 1 /* 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) * If so, the node _must_ be in the current file (as that's the only way anything could have traversed to it to yield it as the error node) @@ -40301,7 +41791,7 @@ var ts; // 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 === 266 /* ExportAssignment */) { + if (node.kind === 268 /* ExportAssignment */) { return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; } var name = ts.getNameOfDeclaration(node); @@ -40310,7 +41800,7 @@ var ts; var moduleName = ts.getTextOfIdentifierOrLiteral(name); return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); } - if (name.kind === 158 /* ComputedPropertyName */) { + if (name.kind === 160 /* ComputedPropertyName */) { var nameExpression = name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteralLike(nameExpression)) { @@ -40319,11 +41809,9 @@ var ts; if (ts.isSignedNumericLiteral(nameExpression)) { return ts.tokenToString(nameExpression.operator) + nameExpression.operand.text; } - ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); - return ts.getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); - } - if (ts.isWellKnownSymbolSyntactically(name)) { - return ts.getPropertyNameForKnownSymbolName(ts.idText(name.name)); + else { + ts.Debug.fail("Only computed properties with literal names have declaration names"); + } } if (ts.isPrivateIdentifier(name)) { // containingClass exists because private names only allowed inside classes @@ -40338,36 +41826,36 @@ var ts; return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 166 /* Constructor */: + case 168 /* Constructor */: return "__constructor" /* Constructor */; - case 174 /* FunctionType */: - case 169 /* CallSignature */: - case 313 /* JSDocSignature */: + case 176 /* FunctionType */: + case 171 /* CallSignature */: + case 317 /* JSDocSignature */: return "__call" /* Call */; - case 175 /* ConstructorType */: - case 170 /* ConstructSignature */: + case 177 /* ConstructorType */: + case 172 /* ConstructSignature */: return "__new" /* New */; - case 171 /* IndexSignature */: + case 173 /* IndexSignature */: return "__index" /* Index */; - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: return "__export" /* ExportStar */; - case 297 /* SourceFile */: + case 299 /* SourceFile */: // json file should behave as // module.exports = ... return "export=" /* ExportEquals */; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */) { // module.exports = ... return "export=" /* ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 308 /* JSDocFunctionType */: + case 311 /* JSDocFunctionType */: return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); - case 160 /* Parameter */: + case 162 /* 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 === 308 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); + ts.Debug.assert(node.parent.kind === 311 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); var functionType = node.parent; var index = functionType.parameters.indexOf(node); return "arg" + index; @@ -40467,7 +41955,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 === 266 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 268 /* ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; messageNeedsName_1 = false; multipleDefaultExports_1 = true; @@ -40506,7 +41994,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = !!(ts.getCombinedModifierFlags(node) & 1 /* Export */) || jsdocTreatAsExported(node); if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 270 /* ExportSpecifier */ || (node.kind === 260 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 272 /* ExportSpecifier */ || (node.kind === 262 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -40595,7 +42083,7 @@ var ts; // 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 !== 209 /* ArrowFunction */) { + if (node.kind !== 211 /* ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -40628,7 +42116,7 @@ var ts; } // We create a return control flow graph for IIFEs and constructors. For constructors // we use the return control flow graph in strict property initialization checks. - currentReturnTarget = isIIFE || node.kind === 166 /* Constructor */ || (ts.isInJSFile(node) && (node.kind === 251 /* FunctionDeclaration */ || node.kind === 208 /* FunctionExpression */)) ? createBranchLabel() : undefined; + currentReturnTarget = isIIFE || node.kind === 168 /* Constructor */ || (ts.isInJSFile(node) && (node.kind === 253 /* FunctionDeclaration */ || node.kind === 210 /* FunctionExpression */)) ? createBranchLabel() : undefined; currentExceptionTarget = undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; @@ -40643,13 +42131,14 @@ var ts; node.flags |= 512 /* HasExplicitReturn */; node.endFlowNode = currentFlow; } - if (node.kind === 297 /* SourceFile */) { + if (node.kind === 299 /* SourceFile */) { node.flags |= emitFlags; + node.endFlowNode = currentFlow; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 166 /* Constructor */ || (ts.isInJSFile(node) && (node.kind === 251 /* FunctionDeclaration */ || node.kind === 208 /* FunctionExpression */))) { + if (node.kind === 168 /* Constructor */ || (ts.isInJSFile(node) && (node.kind === 253 /* FunctionDeclaration */ || node.kind === 210 /* FunctionExpression */))) { node.returnFlowNode = currentFlow; } } @@ -40676,8 +42165,8 @@ var ts; blockScopeContainer = savedBlockScopeContainer; } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 251 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 251 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 253 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 253 /* FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -40700,59 +42189,59 @@ var ts; inAssignmentPattern = saveInAssignmentPattern; return; } - if (node.kind >= 232 /* FirstStatement */ && node.kind <= 248 /* LastStatement */ && !options.allowUnreachableCode) { + if (node.kind >= 234 /* FirstStatement */ && node.kind <= 250 /* LastStatement */ && !options.allowUnreachableCode) { node.flowNode = currentFlow; } switch (node.kind) { - case 236 /* WhileStatement */: + case 238 /* WhileStatement */: bindWhileStatement(node); break; - case 235 /* DoStatement */: + case 237 /* DoStatement */: bindDoStatement(node); break; - case 237 /* ForStatement */: + case 239 /* ForStatement */: bindForStatement(node); break; - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 234 /* IfStatement */: + case 236 /* IfStatement */: bindIfStatement(node); break; - case 242 /* ReturnStatement */: - case 246 /* ThrowStatement */: + case 244 /* ReturnStatement */: + case 248 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 241 /* BreakStatement */: - case 240 /* ContinueStatement */: + case 243 /* BreakStatement */: + case 242 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 247 /* TryStatement */: + case 249 /* TryStatement */: bindTryStatement(node); break; - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: bindSwitchStatement(node); break; - case 258 /* CaseBlock */: + case 260 /* CaseBlock */: bindCaseBlock(node); break; - case 284 /* CaseClause */: + case 286 /* CaseClause */: bindCaseClause(node); break; - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: bindExpressionStatement(node); break; - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: bindLabeledStatement(node); break; - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: if (ts.isDestructuringAssignment(node)) { // Carry over whether we are in an assignment pattern to // binary expressions that could actually be an initializer @@ -40762,47 +42251,47 @@ var ts; } bindBinaryExpressionFlow(node); break; - case 210 /* DeleteExpression */: + case 212 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: bindAccessExpressionFlow(node); break; - case 203 /* CallExpression */: + case 205 /* CallExpression */: bindCallExpressionFlow(node); break; - case 225 /* NonNullExpression */: + case 227 /* NonNullExpression */: bindNonNullExpressionFlow(node); break; - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 325 /* JSDocEnumTag */: + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + case 333 /* JSDocEnumTag */: bindJSDocTypeAlias(node); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 297 /* SourceFile */: { + case 299 /* SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; } - case 230 /* Block */: - case 257 /* ModuleBlock */: + case 232 /* Block */: + case 259 /* ModuleBlock */: bindEachFunctionsFirst(node.statements); break; - case 198 /* BindingElement */: + case 200 /* BindingElement */: bindBindingElementFlow(node); break; - case 200 /* ObjectLiteralExpression */: - case 199 /* ArrayLiteralExpression */: - case 288 /* PropertyAssignment */: - case 220 /* SpreadElement */: + case 202 /* ObjectLiteralExpression */: + case 201 /* ArrayLiteralExpression */: + case 290 /* PropertyAssignment */: + case 222 /* 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; @@ -40816,32 +42305,32 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 78 /* Identifier */: - case 79 /* PrivateIdentifier */: - case 107 /* ThisKeyword */: - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 79 /* Identifier */: + case 80 /* PrivateIdentifier */: + case 108 /* ThisKeyword */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: return containsNarrowableReference(expr); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return hasNarrowableArgument(expr); - case 207 /* ParenthesizedExpression */: - case 225 /* NonNullExpression */: + case 209 /* ParenthesizedExpression */: + case 227 /* NonNullExpression */: return isNarrowingExpression(expr.expression); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return expr.operator === 53 /* ExclamationToken */ && isNarrowingExpression(expr.operand); - case 211 /* TypeOfExpression */: + case 213 /* TypeOfExpression */: return isNarrowingExpression(expr.expression); } return false; } function isNarrowableReference(expr) { - return expr.kind === 78 /* Identifier */ || expr.kind === 79 /* PrivateIdentifier */ || expr.kind === 107 /* ThisKeyword */ || expr.kind === 105 /* SuperKeyword */ || - (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) || - ts.isBinaryExpression(expr) && expr.operatorToken.kind === 27 /* CommaToken */ && isNarrowableReference(expr.right) || - ts.isElementAccessExpression(expr) && ts.isStringOrNumericLiteralLike(expr.argumentExpression) && isNarrowableReference(expr.expression) || - ts.isAssignmentExpression(expr) && isNarrowableReference(expr.left); + 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.isElementAccessExpression(expr) && ts.isStringOrNumericLiteralLike(expr.argumentExpression) && isNarrowableReference(expr.expression) + || ts.isAssignmentExpression(expr) && isNarrowableReference(expr.left); } function containsNarrowableReference(expr) { return isNarrowableReference(expr) || ts.isOptionalChain(expr) && containsNarrowableReference(expr.expression); @@ -40855,7 +42344,7 @@ var ts; } } } - if (expr.expression.kind === 201 /* PropertyAccessExpression */ && + if (expr.expression.kind === 203 /* PropertyAccessExpression */ && containsNarrowableReference(expr.expression.expression)) { return true; } @@ -40869,10 +42358,10 @@ var ts; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 62 /* EqualsToken */: - case 74 /* BarBarEqualsToken */: - case 75 /* AmpersandAmpersandEqualsToken */: - case 76 /* QuestionQuestionEqualsToken */: + case 63 /* EqualsToken */: + case 75 /* BarBarEqualsToken */: + case 76 /* AmpersandAmpersandEqualsToken */: + case 77 /* QuestionQuestionEqualsToken */: return containsNarrowableReference(expr.left); case 34 /* EqualsEqualsToken */: case 35 /* ExclamationEqualsToken */: @@ -40880,9 +42369,9 @@ var ts; case 37 /* ExclamationEqualsEqualsToken */: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 101 /* InstanceOfKeyword */: + case 102 /* InstanceOfKeyword */: return isNarrowableOperand(expr.left); - case 100 /* InKeyword */: + case 101 /* InKeyword */: return isNarrowableInOperands(expr.left, expr.right); case 27 /* CommaToken */: return isNarrowingExpression(expr.right); @@ -40891,11 +42380,11 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: switch (expr.operatorToken.kind) { - case 62 /* EqualsToken */: + case 63 /* EqualsToken */: return isNarrowableOperand(expr.left); case 27 /* CommaToken */: return isNarrowableOperand(expr.right); @@ -40929,8 +42418,8 @@ var ts; if (!expression) { return flags & 32 /* TrueCondition */ ? antecedent : unreachableFlow; } - if ((expression.kind === 109 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || - expression.kind === 94 /* FalseKeyword */ && flags & 32 /* TrueCondition */) && + if ((expression.kind === 110 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || + expression.kind === 95 /* FalseKeyword */ && flags & 32 /* TrueCondition */) && !ts.isExpressionOfOptionalChainRoot(expression) && !ts.isNullishCoalesce(expression.parent)) { return unreachableFlow; } @@ -40969,26 +42458,26 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 234 /* IfStatement */: - case 236 /* WhileStatement */: - case 235 /* DoStatement */: + case 236 /* IfStatement */: + case 238 /* WhileStatement */: + case 237 /* DoStatement */: return parent.expression === node; - case 237 /* ForStatement */: - case 217 /* ConditionalExpression */: + case 239 /* ForStatement */: + case 219 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 207 /* ParenthesizedExpression */) { + if (node.kind === 209 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 214 /* PrefixUnaryExpression */ && node.operator === 53 /* ExclamationToken */) { + else if (node.kind === 216 /* PrefixUnaryExpression */ && node.operator === 53 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 216 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || + return node.kind === 218 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 56 /* BarBarToken */ || node.operatorToken.kind === 60 /* QuestionQuestionToken */); } @@ -41035,7 +42524,7 @@ var ts; } function setContinueTarget(node, target) { var label = activeLabelList; - while (label && node.parent.kind === 245 /* LabeledStatement */) { + while (label && node.parent.kind === 247 /* LabeledStatement */) { label.continueTarget = target; label = label.next; node = node.parent; @@ -41086,12 +42575,12 @@ var ts; bind(node.expression); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 239 /* ForOfStatement */) { + if (node.kind === 241 /* ForOfStatement */) { bind(node.awaitModifier); } addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 250 /* VariableDeclarationList */) { + if (node.initializer.kind !== 252 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -41113,7 +42602,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 242 /* ReturnStatement */) { + if (node.kind === 244 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -41130,7 +42619,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 241 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 243 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -41235,7 +42724,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 285 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 287 /* 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. @@ -41283,9 +42772,9 @@ var ts; function maybeBindExpressionFlowIfCall(node) { // A top level or LHS of 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 === 203 /* CallExpression */) { + if (node.kind === 205 /* CallExpression */) { var call = node; - if (ts.isDottedName(call.expression) && call.expression.kind !== 105 /* SuperKeyword */) { + if (call.expression.kind !== 106 /* SuperKeyword */ && ts.isDottedName(call.expression)) { currentFlow = createFlowCall(currentFlow, call); } } @@ -41309,7 +42798,7 @@ var ts; currentFlow = finishFlowLabel(postStatementLabel); } function bindDestructuringTargetFlow(node) { - if (node.kind === 216 /* BinaryExpression */ && node.operatorToken.kind === 62 /* EqualsToken */) { + if (node.kind === 218 /* BinaryExpression */ && node.operatorToken.kind === 63 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -41320,10 +42809,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowMutation(16 /* Assignment */, currentFlow, node); } - else if (node.kind === 199 /* ArrayLiteralExpression */) { + else if (node.kind === 201 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 220 /* SpreadElement */) { + if (e.kind === 222 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -41331,16 +42820,16 @@ var ts; } } } - else if (node.kind === 200 /* ObjectLiteralExpression */) { + else if (node.kind === 202 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 288 /* PropertyAssignment */) { + if (p.kind === 290 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 289 /* ShorthandPropertyAssignment */) { + else if (p.kind === 291 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 290 /* SpreadAssignment */) { + else if (p.kind === 292 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -41348,7 +42837,7 @@ var ts; } function bindLogicalLikeExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 75 /* AmpersandAmpersandEqualsToken */) { + if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 76 /* AmpersandAmpersandEqualsToken */) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -41405,128 +42894,102 @@ var ts; } bindAssignmentTargetFlow(node.left); } - var BindBinaryExpressionFlowState; - (function (BindBinaryExpressionFlowState) { - BindBinaryExpressionFlowState[BindBinaryExpressionFlowState["BindThenBindChildren"] = 0] = "BindThenBindChildren"; - BindBinaryExpressionFlowState[BindBinaryExpressionFlowState["MaybeBindLeft"] = 1] = "MaybeBindLeft"; - BindBinaryExpressionFlowState[BindBinaryExpressionFlowState["BindToken"] = 2] = "BindToken"; - BindBinaryExpressionFlowState[BindBinaryExpressionFlowState["BindRight"] = 3] = "BindRight"; - BindBinaryExpressionFlowState[BindBinaryExpressionFlowState["FinishBind"] = 4] = "FinishBind"; - })(BindBinaryExpressionFlowState || (BindBinaryExpressionFlowState = {})); - function bindBinaryExpressionFlow(node) { - var workStacks = { - expr: [node], - state: [1 /* MaybeBindLeft */], - inStrictMode: [undefined], - parent: [undefined], - }; - var stackIndex = 0; - while (stackIndex >= 0) { - node = workStacks.expr[stackIndex]; - switch (workStacks.state[stackIndex]) { - case 0 /* BindThenBindChildren */: { - // This state is used only when recuring, to emulate the work that `bind` does before - // reaching `bindChildren`. A normal call to `bindBinaryExpressionFlow` will already have done this work. - ts.setParent(node, parent); - var saveInStrictMode = inStrictMode; - bindWorker(node); - var saveParent = parent; - parent = node; - advanceState(1 /* MaybeBindLeft */, saveInStrictMode, saveParent); - break; - } - case 1 /* MaybeBindLeft */: { - var operator = node.operatorToken.kind; - // TODO: bindLogicalExpression is recursive - if we want to handle deeply nested `&&` expressions - // 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 - if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */ || - ts.isLogicalOrCoalescingAssignmentOperator(operator)) { - if (isTopLevelLogicalExpression(node)) { - var postExpressionLabel = createBranchLabel(); - bindLogicalLikeExpression(node, postExpressionLabel, postExpressionLabel); - currentFlow = finishFlowLabel(postExpressionLabel); - } - else { - bindLogicalLikeExpression(node, currentTrueTarget, currentFalseTarget); - } - completeNode(); - } - else { - advanceState(2 /* BindToken */); - maybeBind(node.left); - } - break; + function createBindBinaryExpressionFlow() { + return ts.createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, /*foldState*/ undefined); + function onEnter(node, state) { + if (state) { + state.stackIndex++; + // Emulate the work that `bind` does before reaching `bindChildren`. A normal call to + // `bindBinaryExpressionFlow` will already have done this work. + ts.setParent(node, parent); + var saveInStrictMode = inStrictMode; + bindWorker(node); + var saveParent = parent; + parent = node; + state.skip = false; + state.inStrictModeStack[state.stackIndex] = saveInStrictMode; + state.parentStack[state.stackIndex] = saveParent; + } + else { + state = { + stackIndex: 0, + skip: false, + inStrictModeStack: [undefined], + parentStack: [undefined] + }; + } + // TODO: bindLogicalExpression is recursive - if we want to handle deeply nested `&&` expressions + // 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 */ || + ts.isLogicalOrCoalescingAssignmentOperator(operator)) { + if (isTopLevelLogicalExpression(node)) { + var postExpressionLabel = createBranchLabel(); + bindLogicalLikeExpression(node, postExpressionLabel, postExpressionLabel); + currentFlow = finishFlowLabel(postExpressionLabel); } - case 2 /* BindToken */: { - if (node.operatorToken.kind === 27 /* CommaToken */) { - maybeBindExpressionFlowIfCall(node.left); - } - advanceState(3 /* BindRight */); - maybeBind(node.operatorToken); - break; + else { + bindLogicalLikeExpression(node, currentTrueTarget, currentFalseTarget); } - case 3 /* BindRight */: { - advanceState(4 /* FinishBind */); - maybeBind(node.right); - break; + state.skip = true; + } + return state; + } + function onLeft(left, state, _node) { + if (!state.skip) { + return maybeBind(left); + } + } + function onOperator(operatorToken, state, node) { + if (!state.skip) { + if (operatorToken.kind === 27 /* CommaToken */) { + maybeBindExpressionFlowIfCall(node.left); } - case 4 /* FinishBind */: { - var operator = node.operatorToken.kind; - if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { - bindAssignmentTargetFlow(node.left); - if (operator === 62 /* EqualsToken */ && node.left.kind === 202 /* ElementAccessExpression */) { - var elementAccess = node.left; - if (isNarrowableOperand(elementAccess.expression)) { - currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node); - } + bind(operatorToken); + } + } + function onRight(right, state, _node) { + if (!state.skip) { + return maybeBind(right); + } + } + function onExit(node, state) { + if (!state.skip) { + var operator = node.operatorToken.kind; + if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { + bindAssignmentTargetFlow(node.left); + if (operator === 63 /* EqualsToken */ && node.left.kind === 204 /* ElementAccessExpression */) { + var elementAccess = node.left; + if (isNarrowableOperand(elementAccess.expression)) { + currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node); } } - completeNode(); - break; } - default: return ts.Debug.fail("Invalid state " + workStacks.state[stackIndex] + " for bindBinaryExpressionFlow"); } - } - /** - * Note that `advanceState` sets the _current_ head state, and that `maybeBind` potentially pushes on a new - * head state; so `advanceState` must be called before any `maybeBind` during a state's execution. - */ - function advanceState(state, isInStrictMode, parent) { - workStacks.state[stackIndex] = state; - if (isInStrictMode !== undefined) { - workStacks.inStrictMode[stackIndex] = isInStrictMode; + var savedInStrictMode = state.inStrictModeStack[state.stackIndex]; + var savedParent = state.parentStack[state.stackIndex]; + if (savedInStrictMode !== undefined) { + inStrictMode = savedInStrictMode; } - if (parent !== undefined) { - workStacks.parent[stackIndex] = parent; + if (savedParent !== undefined) { + parent = savedParent; } + state.skip = false; + state.stackIndex--; } - function completeNode() { - if (workStacks.inStrictMode[stackIndex] !== undefined) { - inStrictMode = workStacks.inStrictMode[stackIndex]; - parent = workStacks.parent[stackIndex]; - } - stackIndex--; - } - /** - * If `node` is a BinaryExpression, adds it to the local work stack, otherwise recursively binds it - */ function maybeBind(node) { if (node && ts.isBinaryExpression(node) && !ts.isDestructuringAssignment(node)) { - stackIndex++; - workStacks.expr[stackIndex] = node; - workStacks.state[stackIndex] = 0 /* BindThenBindChildren */; - workStacks.inStrictMode[stackIndex] = undefined; - workStacks.parent[stackIndex] = undefined; - } - else { - bind(node); + return node; } + bind(node); } } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 201 /* PropertyAccessExpression */) { + if (node.expression.kind === 203 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -41583,7 +43046,7 @@ var ts; } function bindJSDocTypeAlias(node) { ts.setParent(node.tagName, node); - if (node.kind !== 325 /* JSDocEnumTag */ && node.fullName) { + if (node.kind !== 333 /* JSDocEnumTag */ && node.fullName) { ts.setParent(node.fullName, node); ts.setParentRecursive(node.fullName, /*incremental*/ false); } @@ -41591,7 +43054,7 @@ var ts; function bindJSDocClassTag(node) { bindEachChild(node); var host = ts.getHostSignatureFromJSDoc(node); - if (host && host.kind !== 165 /* MethodDeclaration */) { + if (host && host.kind !== 167 /* MethodDeclaration */) { addDeclarationToSymbol(host.symbol, host, 32 /* Class */); } } @@ -41604,15 +43067,15 @@ var ts; } function bindOptionalChainRest(node) { switch (node.kind) { - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: bind(node.questionDotToken); bind(node.name); break; - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: bind(node.questionDotToken); bind(node.argumentExpression); break; - case 203 /* CallExpression */: + case 205 /* CallExpression */: bind(node.questionDotToken); bindEach(node.typeArguments); bindEach(node.arguments); @@ -41677,19 +43140,19 @@ 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 === 208 /* FunctionExpression */ || expr.kind === 209 /* ArrowFunction */) { + if (expr.kind === 210 /* FunctionExpression */ || expr.kind === 211 /* ArrowFunction */) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); } else { bindEachChild(node); - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { currentFlow = createFlowCall(currentFlow, node); } } } - if (node.expression.kind === 201 /* PropertyAccessExpression */) { + if (node.expression.kind === 203 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (ts.isIdentifier(propertyAccess.name) && isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node); @@ -41698,54 +43161,54 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 221 /* ClassExpression */: - case 252 /* ClassDeclaration */: - case 255 /* EnumDeclaration */: - case 200 /* ObjectLiteralExpression */: - case 177 /* TypeLiteral */: - case 312 /* JSDocTypeLiteral */: - case 281 /* JsxAttributes */: + case 223 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 257 /* EnumDeclaration */: + case 202 /* ObjectLiteralExpression */: + case 179 /* TypeLiteral */: + case 316 /* JSDocTypeLiteral */: + case 283 /* JsxAttributes */: return 1 /* IsContainer */; - case 253 /* InterfaceDeclaration */: + case 255 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 256 /* ModuleDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 190 /* MappedType */: + case 258 /* ModuleDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 192 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 297 /* SourceFile */: + case 299 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } // falls through - case 166 /* Constructor */: - case 251 /* FunctionDeclaration */: - case 164 /* MethodSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 169 /* CallSignature */: - case 313 /* JSDocSignature */: - case 308 /* JSDocFunctionType */: - case 174 /* FunctionType */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: - case 175 /* ConstructorType */: + case 168 /* Constructor */: + case 253 /* FunctionDeclaration */: + case 166 /* MethodSignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 171 /* CallSignature */: + case 317 /* JSDocSignature */: + case 311 /* JSDocFunctionType */: + case 176 /* FunctionType */: + case 172 /* ConstructSignature */: + case 173 /* IndexSignature */: + case 177 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 257 /* ModuleBlock */: + case 259 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 287 /* CatchClause */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 258 /* CaseBlock */: + case 289 /* CatchClause */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: + case 260 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 230 /* Block */: + case 232 /* 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 @@ -41778,45 +43241,45 @@ 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 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 297 /* SourceFile */: + case 299 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 221 /* ClassExpression */: - case 252 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 254 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 177 /* TypeLiteral */: - case 312 /* JSDocTypeLiteral */: - case 200 /* ObjectLiteralExpression */: - case 253 /* InterfaceDeclaration */: - case 281 /* JsxAttributes */: + case 179 /* TypeLiteral */: + case 316 /* JSDocTypeLiteral */: + case 202 /* ObjectLiteralExpression */: + case 255 /* InterfaceDeclaration */: + case 283 /* 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 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 313 /* JSDocSignature */: - case 171 /* IndexSignature */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 308 /* JSDocFunctionType */: - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 254 /* TypeAliasDeclaration */: - case 190 /* MappedType */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 317 /* JSDocSignature */: + case 173 /* IndexSignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 311 /* JSDocFunctionType */: + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + case 256 /* TypeAliasDeclaration */: + case 192 /* 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 @@ -41863,15 +43326,13 @@ var ts; var pattern = void 0; if (node.name.kind === 10 /* StringLiteral */) { var text = node.name.text; - if (ts.hasZeroOrOneAsteriskCharacter(text)) { - pattern = ts.tryParsePattern(text); - } - else { + 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 */); - file.patternAmbientModules = ts.append(file.patternAmbientModules, pattern && { pattern: pattern, symbol: symbol }); + file.patternAmbientModules = ts.append(file.patternAmbientModules, pattern && !ts.isString(pattern) ? { pattern: pattern, symbol: symbol } : undefined); } } else { @@ -41917,7 +43378,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 === 290 /* SpreadAssignment */ || prop.name.kind !== 78 /* Identifier */) { + if (prop.kind === 292 /* SpreadAssignment */ || prop.name.kind !== 79 /* Identifier */) { continue; } var identifier = prop.name; @@ -41929,7 +43390,7 @@ var ts; // 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 === 288 /* PropertyAssignment */ || prop.kind === 289 /* ShorthandPropertyAssignment */ || prop.kind === 165 /* MethodDeclaration */ + var currentKind = prop.kind === 290 /* PropertyAssignment */ || prop.kind === 291 /* ShorthandPropertyAssignment */ || prop.kind === 167 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.escapedText); @@ -41961,10 +43422,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 297 /* SourceFile */: + case 299 /* SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -41989,9 +43450,9 @@ var ts; var saveCurrentFlow = currentFlow; for (var _i = 0, delayedTypeAliases_1 = delayedTypeAliases; _i < delayedTypeAliases_1.length; _i++) { var typeAlias = delayedTypeAliases_1[_i]; - var host = ts.getJSDocHost(typeAlias); - container = (host && ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1 /* IsContainer */); })) || file; - blockScopeContainer = (host && ts.getEnclosingBlockScopeContainer(host)) || file; + var host = typeAlias.parent.parent; + container = ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1 /* IsContainer */); }) || file; + blockScopeContainer = ts.getEnclosingBlockScopeContainer(host) || file; currentFlow = initFlowNode({ flags: 2 /* Start */ }); parent = typeAlias; bind(typeAlias.typeExpression); @@ -42032,7 +43493,7 @@ var ts; container = oldContainer; } } - else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 78 /* Identifier */) { + else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 79 /* Identifier */) { parent = typeAlias.parent; bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); } @@ -42057,11 +43518,11 @@ var ts; !ts.isIdentifierName(node)) { // strict mode identifiers if (inStrictMode && - node.originalKeywordKind >= 116 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 124 /* LastFutureReservedWord */) { + node.originalKeywordKind >= 117 /* FirstFutureReservedWord */ && + node.originalKeywordKind <= 125 /* LastFutureReservedWord */) { file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); } - else if (node.originalKeywordKind === 130 /* AwaitKeyword */) { + else if (node.originalKeywordKind === 131 /* 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))); } @@ -42069,7 +43530,7 @@ var ts; 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 === 124 /* YieldKeyword */ && node.flags & 8192 /* YieldContext */) { + else if (node.originalKeywordKind === 125 /* YieldKeyword */ && node.flags & 8192 /* YieldContext */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node))); } } @@ -42111,7 +43572,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 78 /* Identifier */) { + if (inStrictMode && node.expression.kind === 79 /* 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); @@ -42122,7 +43583,7 @@ var ts; return ts.isIdentifier(node) && (node.escapedText === "eval" || node.escapedText === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 78 /* Identifier */) { + if (name && name.kind === 79 /* 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 @@ -42163,8 +43624,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 297 /* SourceFile */ && - blockScopeContainer.kind !== 256 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 299 /* SourceFile */ && + blockScopeContainer.kind !== 258 /* ModuleDeclaration */ && !ts.isFunctionLike(blockScopeContainer)) { // We check first if the name is inside class declaration or class expression; if so give explicit message // otherwise report generic error message. @@ -42259,7 +43720,7 @@ 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 > 156 /* LastToken */) { + if (node.kind > 158 /* LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -42321,7 +43782,7 @@ var ts; function bindWorker(node) { switch (node.kind) { /* Strict mode checks */ - case 78 /* Identifier */: + case 79 /* 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. @@ -42334,18 +43795,24 @@ var ts; break; } // falls through - case 107 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 289 /* ShorthandPropertyAssignment */)) { + case 108 /* ThisKeyword */: + if (currentFlow && (ts.isExpression(node) || parent.kind === 291 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkContextualIdentifier(node); - case 105 /* SuperKeyword */: + case 159 /* QualifiedName */: + if (currentFlow && ts.isPartOfTypeQuery(node)) { + node.flowNode = currentFlow; + } + break; + case 228 /* MetaProperty */: + case 106 /* SuperKeyword */: node.flowNode = currentFlow; break; - case 79 /* PrivateIdentifier */: + case 80 /* PrivateIdentifier */: return checkPrivateIdentifier(node); - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: var expr = node; if (currentFlow && isNarrowableReference(expr)) { expr.flowNode = currentFlow; @@ -42360,7 +43827,7 @@ var ts; declareSymbol(file.locals, /*parent*/ undefined, expr.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 111550 /* FunctionScopedVariableExcludes */); } break; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: var specialKind = ts.getAssignmentDeclarationKind(node); switch (specialKind) { case 1 /* ExportsProperty */: @@ -42396,78 +43863,78 @@ var ts; ts.Debug.fail("Unknown binary expression special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return checkStrictModeCatchClause(node); - case 210 /* DeleteExpression */: + case 212 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 243 /* WithStatement */: + case 245 /* WithStatement */: return checkStrictModeWithStatement(node); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return checkStrictModeLabeledStatement(node); - case 187 /* ThisType */: + case 189 /* ThisType */: seenThisKeyword = true; return; - case 172 /* TypePredicate */: + case 174 /* TypePredicate */: break; // Binding the children will handle everything - case 159 /* TypeParameter */: + case 161 /* TypeParameter */: return bindTypeParameter(node); - case 160 /* Parameter */: + case 162 /* Parameter */: return bindParameter(node); - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 198 /* BindingElement */: + case 200 /* BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: return bindPropertyWorker(node); - case 288 /* PropertyAssignment */: - case 289 /* ShorthandPropertyAssignment */: + case 290 /* PropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 291 /* EnumMember */: + case 293 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 173 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 167 /* MethodDeclaration */: + case 166 /* 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 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return bindFunctionDeclaration(node); - case 166 /* Constructor */: + case 168 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 167 /* GetAccessor */: + case 169 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 46015 /* GetAccessorExcludes */); - case 168 /* SetAccessor */: + case 170 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 78783 /* SetAccessorExcludes */); - case 174 /* FunctionType */: - case 308 /* JSDocFunctionType */: - case 313 /* JSDocSignature */: - case 175 /* ConstructorType */: + case 176 /* FunctionType */: + case 311 /* JSDocFunctionType */: + case 317 /* JSDocSignature */: + case 177 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 177 /* TypeLiteral */: - case 312 /* JSDocTypeLiteral */: - case 190 /* MappedType */: + case 179 /* TypeLiteral */: + case 316 /* JSDocTypeLiteral */: + case 192 /* MappedType */: return bindAnonymousTypeWorker(node); - case 319 /* JSDocClassTag */: + case 326 /* JSDocClassTag */: return bindJSDocClassTag(node); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return bindFunctionExpression(node); - case 203 /* CallExpression */: + case 205 /* CallExpression */: var assignmentKind = ts.getAssignmentDeclarationKind(node); switch (assignmentKind) { case 7 /* ObjectDefinePropertyValue */: @@ -42486,65 +43953,65 @@ var ts; } break; // Members of classes, interfaces, and modules - case 221 /* ClassExpression */: - case 252 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 254 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 253 /* InterfaceDeclaration */: + case 255 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 788872 /* InterfaceExcludes */); - case 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 281 /* JsxAttributes */: + case 283 /* JsxAttributes */: return bindJsxAttributes(node); - case 280 /* JsxAttribute */: + case 282 /* JsxAttribute */: return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); // Imports and exports - case 260 /* ImportEqualsDeclaration */: - case 263 /* NamespaceImport */: - case 265 /* ImportSpecifier */: - case 270 /* ExportSpecifier */: + case 262 /* ImportEqualsDeclaration */: + case 265 /* NamespaceImport */: + case 267 /* ImportSpecifier */: + case 272 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 259 /* NamespaceExportDeclaration */: + case 261 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 262 /* ImportClause */: + case 264 /* ImportClause */: return bindImportClause(node); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: return bindExportDeclaration(node); - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return bindExportAssignment(node); - case 297 /* SourceFile */: + case 299 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 230 /* Block */: + case 232 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // falls through - case 257 /* ModuleBlock */: + case 259 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 326 /* JSDocParameterTag */: - if (node.parent.kind === 313 /* JSDocSignature */) { + case 334 /* JSDocParameterTag */: + if (node.parent.kind === 317 /* JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 312 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 316 /* JSDocTypeLiteral */) { break; } // falls through - case 333 /* JSDocPropertyTag */: + case 341 /* JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 307 /* JSDocOptionalType */ ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 310 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 325 /* JSDocEnumTag */: + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + case 333 /* JSDocEnumTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -42572,8 +44039,8 @@ var ts; } function bindExportAssignment(node) { if (!container.symbol || !container.symbol.exports) { - // Export assignment in some sort of block construct - bindAnonymousDeclaration(node, 2097152 /* Alias */, getDeclarationName(node)); + // Incorrect export assignment in some sort of block construct + bindAnonymousDeclaration(node, 111551 /* Value */, getDeclarationName(node)); } else { var flags = ts.exportAssignmentIsAlias(node) @@ -42707,11 +44174,11 @@ var ts; } var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 210 /* 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 === 62 /* EqualsToken */) { + if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 63 /* EqualsToken */) { var l = thisContainer.parent.left; if (ts.isBindableStaticAccessExpression(l) && ts.isPrototypeAccess(l.expression)) { constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer); @@ -42730,11 +44197,11 @@ var ts; addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* Class */); } break; - case 166 /* Constructor */: - case 163 /* PropertyDeclaration */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 168 /* Constructor */: + case 165 /* PropertyDeclaration */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: // this.foo assignment in a JavaScript class // Bind this property to the containing class var containingClass = thisContainer.parent; @@ -42746,7 +44213,7 @@ var ts; declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* None */, /*isReplaceableByMethod*/ true); } break; - case 297 /* SourceFile */: + case 299 /* 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; @@ -42772,10 +44239,10 @@ var ts; } } function bindSpecialPropertyDeclaration(node) { - if (node.expression.kind === 107 /* ThisKeyword */) { + if (node.expression.kind === 108 /* ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 297 /* SourceFile */) { + else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 299 /* SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -42815,7 +44282,7 @@ var ts; } function bindObjectDefinePropertyAssignment(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); - var isToplevel = node.parent.parent.kind === 297 /* SourceFile */; + var isToplevel = node.parent.parent.kind === 299 /* SourceFile */; namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ false); } @@ -42924,8 +44391,8 @@ var ts; } function isTopLevelNamespaceAssignment(propertyAccess) { return ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 297 /* SourceFile */ - : propertyAccess.parent.parent.kind === 297 /* SourceFile */; + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 299 /* SourceFile */ + : propertyAccess.parent.parent.kind === 299 /* SourceFile */; } function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) { var namespaceSymbol = lookupSymbolForPropertyAccess(name, container) || lookupSymbolForPropertyAccess(name, blockScopeContainer); @@ -43004,7 +44471,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 252 /* ClassDeclaration */) { + if (node.kind === 254 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899503 /* ClassExcludes */); } else { @@ -43046,7 +44513,7 @@ var ts; checkStrictModeEvalOrArguments(node, node.name); } if (!ts.isBindingPattern(node.name)) { - if (ts.isInJSFile(node) && ts.isRequireVariableDeclaration(node, /*requireStringLiteralLikeArgument*/ true) && !ts.getJSDocTypeTag(node)) { + if (ts.isInJSFile(node) && ts.isRequireVariableDeclaration(node) && !ts.getJSDocTypeTag(node)) { declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); } else if (ts.isBlockOrCatchScoped(node)) { @@ -43070,7 +44537,7 @@ var ts; } } function bindParameter(node) { - if (node.kind === 326 /* JSDocParameterTag */ && container.kind !== 313 /* JSDocSignature */) { + if (node.kind === 334 /* JSDocParameterTag */ && container.kind !== 317 /* JSDocSignature */) { return; } if (inStrictMode && !(node.flags & 8388608 /* Ambient */)) { @@ -43147,7 +44614,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } } - else if (node.parent.kind === 185 /* InferType */) { + else if (node.parent.kind === 187 /* InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { @@ -43166,7 +44633,7 @@ var ts; // reachability checks function shouldReportErrorOnModuleDeclaration(node) { var instanceState = getModuleInstanceState(node); - return instanceState === 1 /* Instantiated */ || (instanceState === 2 /* ConstEnumOnly */ && !!options.preserveConstEnums); + return instanceState === 1 /* Instantiated */ || (instanceState === 2 /* ConstEnumOnly */ && ts.shouldPreserveConstEnums(options)); } function checkUnreachable(node) { if (!(currentFlow.flags & 1 /* Unreachable */)) { @@ -43175,11 +44642,11 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 231 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 233 /* EmptyStatement */) || // report error on class declarations - node.kind === 252 /* ClassDeclaration */ || + node.kind === 254 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 256 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); + (node.kind === 258 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -43223,12 +44690,12 @@ var ts; } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: return true; - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return getModuleInstanceState(s) !== 1 /* Instantiated */; - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: return ts.hasSyntacticModifier(s, 2048 /* Const */); default: return false; @@ -43428,7 +44895,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 === 176 /* TypeQuery */) { + if (d.type && d.type.kind === 178 /* TypeQuery */) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); @@ -43598,15 +45065,6 @@ var ts; CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions"; CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp"; })(CheckMode || (CheckMode = {})); - var AccessFlags; - (function (AccessFlags) { - AccessFlags[AccessFlags["None"] = 0] = "None"; - AccessFlags[AccessFlags["NoIndexSignatures"] = 1] = "NoIndexSignatures"; - AccessFlags[AccessFlags["Writing"] = 2] = "Writing"; - AccessFlags[AccessFlags["CacheSymbol"] = 4] = "CacheSymbol"; - AccessFlags[AccessFlags["NoTupleBoundsCheck"] = 8] = "NoTupleBoundsCheck"; - AccessFlags[AccessFlags["ExpressionPosition"] = 16] = "ExpressionPosition"; - })(AccessFlags || (AccessFlags = {})); var SignatureCheckMode; (function (SignatureCheckMode) { SignatureCheckMode[SignatureCheckMode["BivariantCallback"] = 1] = "BivariantCallback"; @@ -43655,6 +45113,7 @@ var ts; DeclarationMeaning[DeclarationMeaning["SetAccessor"] = 2] = "SetAccessor"; DeclarationMeaning[DeclarationMeaning["PropertyAssignment"] = 4] = "PropertyAssignment"; DeclarationMeaning[DeclarationMeaning["Method"] = 8] = "Method"; + DeclarationMeaning[DeclarationMeaning["PrivateStatic"] = 16] = "PrivateStatic"; DeclarationMeaning[DeclarationMeaning["GetOrSetAccessor"] = 3] = "GetOrSetAccessor"; DeclarationMeaning[DeclarationMeaning["PropertyAssignmentOrMethod"] = 12] = "PropertyAssignmentOrMethod"; })(DeclarationMeaning || (DeclarationMeaning = {})); @@ -43746,21 +45205,24 @@ var ts; var instantiationCount = 0; var instantiationDepth = 0; var currentNode; - var typeCatalog = []; // NB: id is index + 1 var emptySymbols = ts.createSymbolTable(); var arrayVariances = [1 /* Covariant */]; var compilerOptions = host.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var moduleKind = ts.getEmitModuleKind(compilerOptions); + var useDefineForClassFields = ts.getUseDefineForClassFields(compilerOptions); var allowSyntheticDefaultImports = ts.getAllowSyntheticDefaultImports(compilerOptions); var strictNullChecks = ts.getStrictOptionValue(compilerOptions, "strictNullChecks"); var strictFunctionTypes = ts.getStrictOptionValue(compilerOptions, "strictFunctionTypes"); var strictBindCallApply = ts.getStrictOptionValue(compilerOptions, "strictBindCallApply"); var strictPropertyInitialization = ts.getStrictOptionValue(compilerOptions, "strictPropertyInitialization"); + var strictOptionalProperties = ts.getStrictOptionValue(compilerOptions, "strictOptionalProperties"); var noImplicitAny = ts.getStrictOptionValue(compilerOptions, "noImplicitAny"); var noImplicitThis = ts.getStrictOptionValue(compilerOptions, "noImplicitThis"); + var useUnknownInCatchVariables = ts.getStrictOptionValue(compilerOptions, "useUnknownInCatchVariables"); var keyofStringsOnly = !!compilerOptions.keyofStringsOnly; - var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 32768 /* FreshLiteral */; + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 16384 /* FreshLiteral */; + var checkBinaryExpression = createCheckBinaryExpression(); var emitResolver = createResolver(); var nodeBuilder = createNodeBuilder(); var globals = ts.createSymbolTable(); @@ -43783,7 +45245,6 @@ var ts; getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); }, getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); }, getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount") + symbolCount; }, - getTypeCatalog: function () { return typeCatalog; }, getTypeCount: function () { return typeCount; }, getInstantiationCount: function () { return totalInstantiationCount; }, getRelationCacheSizes: function () { return ({ @@ -43947,6 +45408,7 @@ var ts; return node && getContextualTypeForJsxAttribute(node); }, isContextSensitive: isContextSensitive, + getTypeOfPropertyOfContextualType: getTypeOfPropertyOfContextualType, getFullyQualifiedName: getFullyQualifiedName, getResolvedSignature: function (node, candidatesOutArray, argumentCount) { return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 0 /* Normal */); @@ -43990,6 +45452,7 @@ var ts; }, tryGetMemberInModuleExports: function (name, symbol) { return tryGetMemberInModuleExports(ts.escapeLeadingUnderscores(name), symbol); }, tryGetMemberInModuleExportsAndProperties: function (name, symbol) { return tryGetMemberInModuleExportsAndProperties(ts.escapeLeadingUnderscores(name), symbol); }, + tryFindAmbientModule: function (moduleName) { return tryFindAmbientModule(moduleName, /*withAugmentations*/ true); }, tryFindAmbientModuleWithoutAugmentations: function (moduleName) { // we deliberately exclude augmentations // since we are only interested in declarations of the module itself @@ -44108,6 +45571,7 @@ var ts; var templateLiteralTypes = new ts.Map(); var stringMappingTypes = new ts.Map(); var substitutionTypes = new ts.Map(); + var subtypeReductionCache = new ts.Map(); var evolvingArrayTypes = []; var undefinedProperties = new ts.Map(); var unknownSymbol = createSymbol(4 /* Property */, "unknown"); @@ -44116,14 +45580,15 @@ var ts; var autoType = createIntrinsicType(1 /* Any */, "any"); var wildcardType = createIntrinsicType(1 /* Any */, "any"); var errorType = createIntrinsicType(1 /* Any */, "error"); - var nonInferrableAnyType = createIntrinsicType(1 /* Any */, "any", 524288 /* ContainsWideningType */); + var nonInferrableAnyType = createIntrinsicType(1 /* Any */, "any", 131072 /* ContainsWideningType */); var intrinsicMarkerType = createIntrinsicType(1 /* Any */, "intrinsic"); var unknownType = createIntrinsicType(2 /* Unknown */, "unknown"); var undefinedType = createIntrinsicType(32768 /* Undefined */, "undefined"); - var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* Undefined */, "undefined", 524288 /* ContainsWideningType */); + var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* Undefined */, "undefined", 131072 /* ContainsWideningType */); var optionalType = createIntrinsicType(32768 /* Undefined */, "undefined"); + var missingType = strictOptionalProperties ? createIntrinsicType(32768 /* Undefined */, "undefined") : undefinedType; var nullType = createIntrinsicType(65536 /* Null */, "null"); - var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* Null */, "null", 524288 /* ContainsWideningType */); + var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* Null */, "null", 131072 /* ContainsWideningType */); var stringType = createIntrinsicType(4 /* String */, "string"); var numberType = createIntrinsicType(8 /* Number */, "number"); var bigintType = createIntrinsicType(64 /* BigInt */, "bigint"); @@ -44149,7 +45614,7 @@ var ts; var voidType = createIntrinsicType(16384 /* Void */, "void"); var neverType = createIntrinsicType(131072 /* Never */, "never"); var silentNeverType = createIntrinsicType(131072 /* Never */, "never"); - var nonInferrableType = createIntrinsicType(131072 /* Never */, "never", 2097152 /* NonInferrableType */); + var nonInferrableType = createIntrinsicType(131072 /* Never */, "never", 524288 /* NonInferrableType */); var implicitNeverType = createIntrinsicType(131072 /* Never */, "never"); var unreachableNeverType = createIntrinsicType(131072 /* Never */, "never"); var nonPrimitiveType = createIntrinsicType(67108864 /* NonPrimitive */, "object"); @@ -44161,7 +45626,7 @@ var ts; var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? wildcardType : t; }); var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var emptyJsxObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); - emptyJsxObjectType.objectFlags |= 4096 /* JsxAttributes */; + emptyJsxObjectType.objectFlags |= 2048 /* JsxAttributes */; var emptyTypeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); emptyTypeLiteralSymbol.members = ts.createSymbolTable(); var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); @@ -44170,7 +45635,7 @@ var ts; var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); // The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated // in getPropagatingFlagsOfTypes, and it is checked in inferFromTypes. - anyFunctionType.objectFlags |= 2097152 /* NonInferrableType */; + anyFunctionType.objectFlags |= 524288 /* NonInferrableType */; var noConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var circularConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var resolvingDefaultType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); @@ -44250,6 +45715,7 @@ var ts; // This allows users to just specify library files they want to used through --lib // and they will not get an error from not having unrelated library files var deferredGlobalESSymbolConstructorSymbol; + var deferredGlobalESSymbolConstructorTypeSymbol; var deferredGlobalESSymbolType; var deferredGlobalTypedPropertyDescriptorType; var deferredGlobalPromiseType; @@ -44301,7 +45767,7 @@ var ts; var flowNodePostSuper = []; var potentialThisCollisions = []; var potentialNewTargetCollisions = []; - var potentialWeakMapCollisions = []; + var potentialWeakMapSetCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); var suggestionDiagnostics = ts.createDiagnosticCollection(); @@ -44448,9 +45914,28 @@ var ts; } return diagnostic; } + function addDeprecatedSuggestionWorker(declarations, diagnostic) { + var deprecatedTag = Array.isArray(declarations) ? ts.forEach(declarations, ts.getJSDocDeprecatedTag) : ts.getJSDocDeprecatedTag(declarations); + if (deprecatedTag) { + ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(deprecatedTag, ts.Diagnostics.The_declaration_was_marked_as_deprecated_here)); + } + // We call `addRelatedInfo()` before adding the diagnostic to prevent duplicates. + suggestionDiagnostics.add(diagnostic); + return diagnostic; + } + function addDeprecatedSuggestion(location, declarations, deprecatedEntity) { + var diagnostic = ts.createDiagnosticForNode(location, ts.Diagnostics._0_is_deprecated, deprecatedEntity); + return addDeprecatedSuggestionWorker(declarations, diagnostic); + } + function addDeprecatedSuggestionWithSignature(location, declaration, deprecatedEntity, signatureString) { + var diagnostic = deprecatedEntity + ? ts.createDiagnosticForNode(location, ts.Diagnostics.The_signature_0_of_1_is_deprecated, signatureString, deprecatedEntity) + : ts.createDiagnosticForNode(location, ts.Diagnostics._0_is_deprecated, signatureString); + return addDeprecatedSuggestionWorker(declaration, diagnostic); + } function createSymbol(flags, name, checkFlags) { symbolCount++; - var symbol = (new Symbol(flags | 33554432 /* Transient */, name)); + var symbol = new Symbol(flags | 33554432 /* Transient */, name); symbol.checkFlags = checkFlags || 0; return symbol; } @@ -44561,7 +46046,7 @@ var ts; // as we will already report a "Declaration name conflicts..." error, and this error // won't make much sense. if (target !== globalThisSymbol) { - error(ts.getNameOfDeclaration(source.declarations[0]), ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); + error(source.declarations && ts.getNameOfDeclaration(source.declarations[0]), ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); } } else { // error @@ -44595,9 +46080,11 @@ var ts; } return target; function addDuplicateLocations(locs, symbol) { - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - ts.pushIfUnique(locs, decl); + if (symbol.declarations) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + ts.pushIfUnique(locs, decl); + } } } } @@ -44643,9 +46130,9 @@ var ts; }); } function mergeModuleAugmentation(moduleName) { - var _a, _b; + var _a, _b, _c; var moduleAugmentation = moduleName.parent; - if (moduleAugmentation.symbol.declarations[0] !== moduleAugmentation) { + if (((_a = moduleAugmentation.symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]) !== moduleAugmentation) { // this is a combined symbol for multiple augmentations within the same file. // its symbol already has accumulated information for all declarations // so we need to add it just once - do the work only for first declaration @@ -44682,11 +46169,11 @@ var ts; patternAmbientModuleAugmentations.set(moduleName.text, merged); } else { - if (((_a = mainModule_1.exports) === null || _a === void 0 ? void 0 : _a.get("__export" /* ExportStar */)) && ((_b = moduleAugmentation.symbol.exports) === null || _b === void 0 ? void 0 : _b.size)) { + 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)) { // 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 */); - for (var _i = 0, _c = ts.arrayFrom(moduleAugmentation.symbol.exports.entries()); _i < _c.length; _i++) { - var _d = _c[_i], key = _d[0], value = _d[1]; + 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)) { mergeSymbol(resolvedExports.get(key), value); } @@ -44727,7 +46214,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = new NodeLinks()); } function isGlobalSourceFile(node) { - return node.kind === 297 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 299 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -44786,17 +46273,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 === 198 /* BindingElement */) { + if (declaration.kind === 200 /* 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, 198 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 200 /* 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, 249 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 251 /* VariableDeclaration */), usage); } - else if (declaration.kind === 249 /* VariableDeclaration */) { + else if (declaration.kind === 251 /* VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -44810,7 +46297,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 !(compilerOptions.target === 99 /* ESNext */ && !!compilerOptions.useDefineForClassFields + return !(compilerOptions.target === 99 /* ESNext */ && useDefineForClassFields && ts.getContainingClass(declaration) === ts.getContainingClass(usage) && isUsedInFunctionOrInstanceProperty(usage, declaration)); } @@ -44826,19 +46313,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 === 270 /* ExportSpecifier */ || (usage.parent.kind === 266 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 272 /* ExportSpecifier */ || (usage.parent.kind === 268 /* 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 === 266 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 268 /* ExportAssignment */ && usage.isExportEquals) { return true; } if (!!(usage.flags & 4194304 /* JSDoc */) || isInTypeQuery(usage) || usageInTypeDeclaration()) { return true; } if (isUsedInFunctionOrInstanceProperty(usage, declaration)) { - if (compilerOptions.target === 99 /* ESNext */ && !!compilerOptions.useDefineForClassFields + if (compilerOptions.target === 99 /* ESNext */ && useDefineForClassFields && ts.getContainingClass(declaration) && (ts.isPropertyDeclaration(declaration) || ts.isParameterPropertyDeclaration(declaration, declaration.parent))) { return !isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, /*stopAtAnyPropertyDeclaration*/ true); @@ -44853,9 +46340,9 @@ var ts; } function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { switch (declaration.parent.parent.kind) { - case 232 /* VariableStatement */: - case 237 /* ForStatement */: - case 239 /* ForOfStatement */: + case 234 /* VariableStatement */: + case 239 /* ForStatement */: + case 241 /* 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)) { @@ -44876,16 +46363,16 @@ var ts; return true; } var initializerOfProperty = current.parent && - current.parent.kind === 163 /* PropertyDeclaration */ && + current.parent.kind === 165 /* PropertyDeclaration */ && current.parent.initializer === current; if (initializerOfProperty) { if (ts.hasSyntacticModifier(current.parent, 32 /* Static */)) { - if (declaration.kind === 165 /* MethodDeclaration */) { + if (declaration.kind === 167 /* MethodDeclaration */) { return true; } } else { - var isDeclarationInstanceProperty = declaration.kind === 163 /* PropertyDeclaration */ && !ts.hasSyntacticModifier(declaration, 32 /* Static */); + var isDeclarationInstanceProperty = declaration.kind === 165 /* PropertyDeclaration */ && !ts.hasSyntacticModifier(declaration, 32 /* Static */); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -44907,19 +46394,19 @@ var ts; return "quit"; } switch (node.kind) { - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return true; - case 163 /* PropertyDeclaration */: + case 165 /* 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 230 /* Block */: + case 232 /* Block */: switch (node.parent.kind) { - case 167 /* GetAccessor */: - case 165 /* MethodDeclaration */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 167 /* MethodDeclaration */: + case 170 /* SetAccessor */: return true; default: return false; @@ -44934,7 +46421,11 @@ var ts; function useOuterVariableScopeInParameter(result, location, lastLocation) { var target = ts.getEmitScriptTarget(compilerOptions); var functionLocation = location; - if (ts.isParameter(lastLocation) && functionLocation.body && result.valueDeclaration.pos >= functionLocation.body.pos && result.valueDeclaration.end <= functionLocation.body.end) { + if (ts.isParameter(lastLocation) + && functionLocation.body + && result.valueDeclaration + && result.valueDeclaration.pos >= functionLocation.body.pos + && result.valueDeclaration.end <= functionLocation.body.end) { // check for several cases where we introduce temporaries that require moving the name/initializer of the parameter to the body // - static field in a class expression // - optional chaining pre-es2020 @@ -44955,21 +46446,21 @@ var ts; } function requiresScopeChangeWorker(node) { switch (node.kind) { - case 209 /* ArrowFunction */: - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: - case 166 /* Constructor */: + case 211 /* ArrowFunction */: + case 210 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 168 /* Constructor */: // do not descend into these return false; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 288 /* PropertyAssignment */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 290 /* PropertyAssignment */: return requiresScopeChangeWorker(node.name); - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: // static properties in classes introduce temporary variables if (ts.hasStaticModifier(node)) { - return target < 99 /* ESNext */ || !compilerOptions.useDefineForClassFields; + return target < 99 /* ESNext */ || !useDefineForClassFields; } return requiresScopeChangeWorker(node.name); default: @@ -44998,6 +46489,7 @@ var ts; return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSymbol, suggestedNameNotFoundMessage); } function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, lookup, suggestedNameNotFoundMessage) { + var _a; var originalLocation = location; // needed for did-you-mean error reporting, which gathers candidates starting from the original location var result; var lastLocation; @@ -45020,12 +46512,12 @@ 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 !== 311 /* JSDocComment */) { + if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 314 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || - lastLocation.kind === 160 /* Parameter */ || - lastLocation.kind === 159 /* TypeParameter */ + lastLocation.kind === 162 /* Parameter */ || + lastLocation.kind === 161 /* TypeParameter */ // local types not visible outside the function body : false; } @@ -45040,13 +46532,13 @@ var ts; // however it is detected separately when checking initializers of parameters // to make sure that they reference no variables declared after them. useResult = - lastLocation.kind === 160 /* Parameter */ || + lastLocation.kind === 162 /* Parameter */ || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } } - else if (location.kind === 184 /* ConditionalType */) { + else if (location.kind === 186 /* 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; @@ -45061,14 +46553,14 @@ var ts; } withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation); switch (location.kind) { - case 297 /* SourceFile */: + case 299 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports || emptySymbols; - if (location.kind === 297 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 8388608 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) { + if (location.kind === 299 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 8388608 /* 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 */)) { @@ -45092,13 +46584,13 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 /* Alias */ && - (ts.getDeclarationOfKind(moduleExport, 270 /* ExportSpecifier */) || ts.getDeclarationOfKind(moduleExport, 269 /* NamespaceExport */))) { + (ts.getDeclarationOfKind(moduleExport, 272 /* ExportSpecifier */) || ts.getDeclarationOfKind(moduleExport, 271 /* 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 (ts.isSourceFile(location) && location.commonJsModuleIndicator && !result.declarations.some(ts.isJSDocTypeAlias)) { + if (ts.isSourceFile(location) && location.commonJsModuleIndicator && !((_a = result.declarations) === null || _a === void 0 ? void 0 : _a.some(ts.isJSDocTypeAlias))) { result = undefined; } else { @@ -45106,12 +46598,12 @@ var ts; } } break; - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 163 /* PropertyDeclaration */: + case 165 /* 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 @@ -45128,9 +46620,9 @@ var ts; } } break; - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* 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! @@ -45149,7 +46641,7 @@ var ts; } break loop; } - if (location.kind === 221 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 223 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -45157,9 +46649,9 @@ var ts; } } break; - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: // The type parameters of a class are not in scope in the base class expression. - if (lastLocation === location.expression && location.parent.token === 93 /* ExtendsKeyword */) { + if (lastLocation === location.expression && location.parent.token === 94 /* ExtendsKeyword */) { var container = location.parent.parent; if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968 /* Type */))) { if (nameNotFoundMessage) { @@ -45177,9 +46669,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 253 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 255 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -45187,24 +46679,24 @@ var ts; } } break; - case 209 /* ArrowFunction */: + case 211 /* 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 (compilerOptions.target >= 2 /* ES2015 */) { break; } // falls through - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 251 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 253 /* FunctionDeclaration */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -45217,7 +46709,7 @@ var ts; } } break; - case 161 /* Decorator */: + case 163 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -45226,7 +46718,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 === 160 /* Parameter */) { + if (location.parent && location.parent.kind === 162 /* Parameter */) { location = location.parent; } // @@ -45241,20 +46733,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 === 252 /* ClassDeclaration */)) { + if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 254 /* ClassDeclaration */)) { location = location.parent; } break; - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 325 /* JSDocEnumTag */: + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + case 333 /* 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 160 /* Parameter */: + case 162 /* Parameter */: if (lastLocation && (lastLocation === location.initializer || lastLocation === location.name && ts.isBindingPattern(lastLocation))) { if (!associatedDeclarationForContainingInitializerOrBindingName) { @@ -45262,7 +46754,7 @@ var ts; } } break; - case 198 /* BindingElement */: + case 200 /* BindingElement */: if (lastLocation && (lastLocation === location.initializer || lastLocation === location.name && ts.isBindingPattern(lastLocation))) { if (ts.isParameterDeclaration(location) && !associatedDeclarationForContainingInitializerOrBindingName) { @@ -45270,7 +46762,7 @@ var ts; } } break; - case 185 /* InferType */: + case 187 /* InferType */: if (meaning & 262144 /* TypeParameter */) { var parameterName = location.typeParameter.name; if (parameterName && name === parameterName.escapedText) { @@ -45294,7 +46786,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 297 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 299 /* SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -45323,6 +46815,10 @@ var ts; var suggestion = void 0; if (suggestedNameNotFoundMessage && suggestionCount < maximumSuggestionCount) { suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning); + var isGlobalScopeAugmentationDeclaration = suggestion && suggestion.valueDeclaration && ts.isAmbientModule(suggestion.valueDeclaration) && ts.isGlobalScopeAugmentation(suggestion.valueDeclaration); + if (isGlobalScopeAugmentationDeclaration) { + suggestion = undefined; + } if (suggestion) { var suggestionName = symbolToString(suggestion); var diagnostic = error(errorLocation, suggestedNameNotFoundMessage, diagnosticName(nameArg), suggestionName); @@ -45349,7 +46845,7 @@ var ts; } // Perform extra checks only if error reporting was requested if (nameNotFoundMessage) { - if (propertyWithInvalidInitializer && !(compilerOptions.target === 99 /* ESNext */ && compilerOptions.useDefineForClassFields)) { + if (propertyWithInvalidInitializer && !(compilerOptions.target === 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. @@ -45419,10 +46915,10 @@ var ts; } } function getIsDeferredContext(location, lastLocation) { - if (location.kind !== 209 /* ArrowFunction */ && location.kind !== 208 /* FunctionExpression */) { + if (location.kind !== 211 /* ArrowFunction */ && location.kind !== 210 /* 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 === 163 /* PropertyDeclaration */ && !ts.hasSyntacticModifier(location, 32 /* Static */))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred + (location.kind === 165 /* PropertyDeclaration */ && !ts.hasSyntacticModifier(location, 32 /* Static */))) && (!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; @@ -45435,12 +46931,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 256 /* ModuleDeclaration */: // For `namespace N { N; }` + case 253 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 257 /* EnumDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 258 /* ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -45450,12 +46946,14 @@ var ts; return ts.isString(nameArg) ? ts.unescapeLeadingUnderscores(nameArg) : ts.declarationNameToString(nameArg); } function isTypeParameterSymbolDeclaredInContainer(symbol, container) { - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - if (decl.kind === 159 /* 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)); // TODO: GH#18217 + if (symbol.declarations) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + if (decl.kind === 161 /* 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)); // TODO: GH#18217 + } } } } @@ -45507,10 +47005,10 @@ var ts; */ function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 78 /* Identifier */: - case 201 /* PropertyAccessExpression */: + case 79 /* Identifier */: + case 203 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -45554,7 +47052,7 @@ 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 === 270 /* ExportSpecifier */) { + if (isPrimitiveTypeName(name) && errorLocation.parent.kind === 272 /* ExportSpecifier */) { error(errorLocation, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, name); return true; } @@ -45623,13 +47121,14 @@ var ts; return false; } 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 */) { // constructor functions aren't block scoped return; } // Block-scoped variables cannot be used before their definition - var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 255 /* 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 === 257 /* EnumDeclaration */); }); if (declaration === undefined) return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration"); if (!(declaration.flags & 8388608 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { @@ -45646,7 +47145,7 @@ var ts; } else { ts.Debug.assert(!!(result.flags & 128 /* ConstEnum */)); - if (compilerOptions.preserveConstEnums) { + if (ts.shouldPreserveConstEnums(compilerOptions)) { diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName); } } @@ -45664,20 +47163,20 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return node; - case 262 /* ImportClause */: + case 264 /* ImportClause */: return node.parent; - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: return node.parent.parent; - case 265 /* ImportSpecifier */: + case 267 /* ImportSpecifier */: return node.parent.parent.parent; default: return undefined; } } function getDeclarationOfAliasSymbol(symbol) { - return ts.find(symbol.declarations, isAliasSymbolDeclaration); + return symbol.declarations && ts.findLast(symbol.declarations, isAliasSymbolDeclaration); } /** * An alias symbol is created by one of the following declarations: @@ -45692,25 +47191,26 @@ var ts; * module.exports = * {} * {name: } + * const { x } = require ... */ function isAliasSymbolDeclaration(node) { - return node.kind === 260 /* ImportEqualsDeclaration */ - || node.kind === 259 /* NamespaceExportDeclaration */ - || node.kind === 262 /* ImportClause */ && !!node.name - || node.kind === 263 /* NamespaceImport */ - || node.kind === 269 /* NamespaceExport */ - || node.kind === 265 /* ImportSpecifier */ - || node.kind === 270 /* ExportSpecifier */ - || node.kind === 266 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) + return node.kind === 262 /* ImportEqualsDeclaration */ + || node.kind === 261 /* NamespaceExportDeclaration */ + || node.kind === 264 /* ImportClause */ && !!node.name + || node.kind === 265 /* NamespaceImport */ + || node.kind === 271 /* NamespaceExport */ + || node.kind === 267 /* ImportSpecifier */ + || node.kind === 272 /* ExportSpecifier */ + || node.kind === 268 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) || ts.isBinaryExpression(node) && ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && ts.exportAssignmentIsAlias(node) || ts.isAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node - && node.parent.operatorToken.kind === 62 /* EqualsToken */ + && node.parent.operatorToken.kind === 63 /* EqualsToken */ && isAliasableOrJsExpression(node.parent.right) - || node.kind === 289 /* ShorthandPropertyAssignment */ - || node.kind === 288 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer) - || ts.isRequireVariableDeclaration(node, /*requireStringLiteralLikeArgument*/ true); + || node.kind === 291 /* ShorthandPropertyAssignment */ + || node.kind === 290 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer) + || ts.isRequireVariableDeclaration(node); } function isAliasableOrJsExpression(e) { return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e); @@ -45723,7 +47223,7 @@ var ts; ? resolveSymbol(getPropertyOfType(resolveExternalModuleTypeByLiteral(name), commonJSPropertyAccess.name.escapedText)) : undefined; } - if (ts.isVariableDeclaration(node) || node.moduleReference.kind === 272 /* ExternalModuleReference */) { + if (ts.isVariableDeclaration(node) || node.moduleReference.kind === 274 /* ExternalModuleReference */) { var immediate = resolveExternalModuleName(node, ts.getExternalModuleRequireArgument(node) || ts.getExternalModuleImportEqualsDeclarationExpression(node)); var resolved_4 = resolveExternalModuleSymbol(immediate); markSymbolOfAliasDeclarationIfTypeOnly(node, immediate, resolved_4, /*overwriteEmpty*/ false); @@ -45790,6 +47290,7 @@ var ts; return !file.externalModuleIndicator && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), /*sourceNode*/ undefined, dontResolveAlias); } function getTargetOfImportClause(node, dontResolveAlias) { + var _a; var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier); if (moduleSymbol) { var exportDefaultSymbol = void 0; @@ -45799,7 +47300,7 @@ var ts; else { exportDefaultSymbol = resolveExportByName(moduleSymbol, "default" /* Default */, node, dontResolveAlias); } - var file = ts.find(moduleSymbol.declarations, ts.isSourceFile); + var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); var hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias); if (!exportDefaultSymbol && !hasSyntheticDefault) { if (hasExportAssignmentSymbol(moduleSymbol)) { @@ -45807,7 +47308,9 @@ var ts; var exportEqualsSymbol = moduleSymbol.exports.get("export=" /* 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); - ts.addRelatedInfo(err, ts.createDiagnosticForNode(exportAssignment, ts.Diagnostics.This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag, compilerOptionName)); + if (exportAssignment) { + ts.addRelatedInfo(err, ts.createDiagnosticForNode(exportAssignment, ts.Diagnostics.This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag, compilerOptionName)); + } } else { reportNonDefaultExport(moduleSymbol, node); @@ -45824,7 +47327,7 @@ var ts; } } function reportNonDefaultExport(moduleSymbol, node) { - var _a, _b; + var _a, _b, _c; if ((_a = moduleSymbol.exports) === null || _a === void 0 ? void 0 : _a.has(node.symbol.escapedName)) { error(node.name, ts.Diagnostics.Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead, symbolToString(moduleSymbol), symbolToString(node.symbol)); } @@ -45832,7 +47335,7 @@ var ts; 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 */); if (exportStar) { - var defaultExport = ts.find(exportStar.declarations, function (decl) { + 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 */))); @@ -45910,7 +47413,7 @@ var ts; } } function getExternalModuleMember(node, specifier, dontResolveAlias) { - var _a; + var _a, _b; if (dontResolveAlias === void 0) { dontResolveAlias = false; } var moduleSpecifier = ts.getExternalModuleRequireArgument(node) || node.moduleSpecifier; var moduleSymbol = resolveExternalModuleName(node, moduleSpecifier); // TODO: GH#18217 @@ -45919,7 +47422,7 @@ var ts; return undefined; } var suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || compilerOptions.esModuleInterop); - var targetSymbol = resolveESModuleSymbol(moduleSymbol, moduleSpecifier, dontResolveAlias, suppressInteropError); + var targetSymbol = resolveESModuleSymbol(moduleSymbol, moduleSpecifier, /*dontResolveAlias*/ false, suppressInteropError); if (targetSymbol) { if (name.escapedText) { if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { @@ -45937,7 +47440,7 @@ var ts; symbolFromVariable = resolveSymbol(symbolFromVariable, dontResolveAlias); var symbolFromModule = getExportOfModule(targetSymbol, name, specifier, dontResolveAlias); if (symbolFromModule === undefined && name.escapedText === "default" /* Default */) { - var file = ts.find(moduleSymbol.declarations, ts.isSourceFile); + var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); if (canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias)) { symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias); } @@ -45957,7 +47460,7 @@ var ts; } } else { - if ((_a = moduleSymbol.exports) === null || _a === void 0 ? void 0 : _a.has("default" /* Default */)) { + if ((_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* 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 { @@ -45970,8 +47473,8 @@ var ts; } } function reportNonExportedMember(node, name, declarationName, moduleSymbol, moduleName) { - var _a; - var localSymbol = (_a = moduleSymbol.valueDeclaration.locals) === null || _a === void 0 ? void 0 : _a.get(name.escapedText); + var _a, _b; + 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 */); @@ -45983,9 +47486,11 @@ var ts; var exportedSymbol = exports ? ts.find(symbolsToArray(exports), function (symbol) { return !!getSymbolIfSameReference(symbol, localSymbol); }) : undefined; var diagnostic = exportedSymbol ? error(name, ts.Diagnostics.Module_0_declares_1_locally_but_it_is_exported_as_2, moduleName, declarationName, symbolToString(exportedSymbol)) : error(name, ts.Diagnostics.Module_0_declares_1_locally_but_it_is_not_exported, moduleName, declarationName); - ts.addRelatedInfo.apply(void 0, __spreadArray([diagnostic], ts.map(localSymbol.declarations, function (decl, index) { - return ts.createDiagnosticForNode(decl, index === 0 ? ts.Diagnostics._0_is_declared_here : ts.Diagnostics.and_here, declarationName); - }))); + if (localSymbol.declarations) { + ts.addRelatedInfo.apply(void 0, __spreadArray([diagnostic], ts.map(localSymbol.declarations, function (decl, index) { + return ts.createDiagnosticForNode(decl, index === 0 ? ts.Diagnostics._0_is_declared_here : ts.Diagnostics.and_here, declarationName); + }))); + } } } else { @@ -46064,7 +47569,7 @@ var ts; return getTargetOfAliasLikeExpression(expression, dontRecursivelyResolve); } function getTargetOfAccessExpression(node, dontRecursivelyResolve) { - if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62 /* EqualsToken */)) { + if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* EqualsToken */)) { return undefined; } return getTargetOfAliasLikeExpression(node.parent.right, dontRecursivelyResolve); @@ -46072,31 +47577,31 @@ var ts; function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 260 /* ImportEqualsDeclaration */: - case 249 /* VariableDeclaration */: + case 262 /* ImportEqualsDeclaration */: + case 251 /* VariableDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 262 /* ImportClause */: + case 264 /* ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 269 /* NamespaceExport */: + case 271 /* NamespaceExport */: return getTargetOfNamespaceExport(node, dontRecursivelyResolve); - case 265 /* ImportSpecifier */: - case 198 /* BindingElement */: + case 267 /* ImportSpecifier */: + case 200 /* BindingElement */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 270 /* ExportSpecifier */: + case 272 /* ExportSpecifier */: return getTargetOfExportSpecifier(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 266 /* ExportAssignment */: - case 216 /* BinaryExpression */: + case 268 /* ExportAssignment */: + case 218 /* BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 259 /* NamespaceExportDeclaration */: + case 261 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return resolveEntityName(node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve); - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: return getTargetOfPropertyAssignment(node, dontRecursivelyResolve); - case 202 /* ElementAccessExpression */: - case 201 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: return getTargetOfAccessExpression(node, dontRecursivelyResolve); default: return ts.Debug.fail(); @@ -46244,17 +47749,17 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 78 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 79 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 78 /* Identifier */ || entityName.parent.kind === 157 /* QualifiedName */) { + if (entityName.kind === 79 /* Identifier */ || entityName.parent.kind === 159 /* QualifiedName */) { return resolveEntityName(entityName, 1920 /* 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 === 260 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 262 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } @@ -46270,7 +47775,7 @@ var ts; } var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 111551 /* Value */ : 0); var symbol; - if (name.kind === 78 /* Identifier */) { + if (name.kind === 79 /* 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)); @@ -46278,9 +47783,9 @@ var ts; return getMergedSymbol(symbolFromJSPrototype); } } - else if (name.kind === 157 /* QualifiedName */ || name.kind === 201 /* PropertyAccessExpression */) { - var left = name.kind === 157 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 157 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 159 /* QualifiedName */ || name.kind === 203 /* PropertyAccessExpression */) { + var left = name.kind === 159 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 159 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -46288,18 +47793,17 @@ var ts; else if (namespace === unknownSymbol) { return namespace; } - if (ts.isInJSFile(name)) { - if (namespace.valueDeclaration && - ts.isVariableDeclaration(namespace.valueDeclaration) && - namespace.valueDeclaration.initializer && - isCommonJsRequire(namespace.valueDeclaration.initializer)) { - var moduleName = namespace.valueDeclaration.initializer.arguments[0]; - var moduleSym = resolveExternalModuleName(moduleName, moduleName); - if (moduleSym) { - var resolvedModuleSymbol = resolveExternalModuleSymbol(moduleSym); - if (resolvedModuleSymbol) { - namespace = resolvedModuleSymbol; - } + if (namespace.valueDeclaration && + ts.isInJSFile(namespace.valueDeclaration) && + ts.isVariableDeclaration(namespace.valueDeclaration) && + namespace.valueDeclaration.initializer && + isCommonJsRequire(namespace.valueDeclaration.initializer)) { + var moduleName = namespace.valueDeclaration.initializer.arguments[0]; + var moduleSym = resolveExternalModuleName(moduleName, moduleName); + if (moduleSym) { + var resolvedModuleSymbol = resolveExternalModuleSymbol(moduleSym); + if (resolvedModuleSymbol) { + namespace = resolvedModuleSymbol; } } } @@ -46320,7 +47824,7 @@ var ts; 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 === 266 /* ExportAssignment */)) { + if (!ts.nodeIsSynthesized(name) && ts.isEntityName(name) && (symbol.flags & 2097152 /* Alias */ || name.parent.kind === 268 /* ExportAssignment */)) { markSymbolOfAliasDeclarationIfTypeOnly(ts.getAliasDeclarationFromName(name), symbol, /*finalTarget*/ undefined, /*overwriteEmpty*/ true); } return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol); @@ -46557,7 +48061,7 @@ var ts; function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias, suppressInteropError) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!suppressInteropError && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 297 /* SourceFile */)) { + if (!suppressInteropError && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 299 /* SourceFile */)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; @@ -46608,7 +48112,10 @@ var ts; var exports = getExportsOfModuleAsArray(moduleSymbol); var exportEquals = resolveExternalModuleSymbol(moduleSymbol); if (exportEquals !== moduleSymbol) { - ts.addRange(exports, getPropertiesOfType(getTypeOfSymbol(exportEquals))); + var type = getTypeOfSymbol(exportEquals); + if (shouldTreatPropertiesOfExternalModuleAsExports(type)) { + ts.addRange(exports, getPropertiesOfType(type)); + } } return exports; } @@ -46628,11 +48135,14 @@ var ts; return undefined; } var type = getTypeOfSymbol(exportEquals); - return type.flags & 131068 /* Primitive */ || - ts.getObjectFlags(type) & 1 /* Class */ || - isArrayOrTupleLikeType(type) - ? undefined - : getPropertyOfType(type, memberName); + return shouldTreatPropertiesOfExternalModuleAsExports(type) ? getPropertyOfType(type, memberName) : undefined; + } + function shouldTreatPropertiesOfExternalModuleAsExports(resolvedExternalModuleType) { + return !(resolvedExternalModuleType.flags & 131068 /* Primitive */ || + ts.getObjectFlags(resolvedExternalModuleType) & 1 /* 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 */) : @@ -46690,11 +48200,13 @@ var ts; if (exportStars) { var nestedSymbols = ts.createSymbolTable(); var lookupTable_1 = new ts.Map(); - for (var _i = 0, _a = exportStars.declarations; _i < _a.length; _i++) { - var node = _a[_i]; - var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); - var exportedSymbols = visit(resolvedModule); - extendExportSymbols(nestedSymbols, exportedSymbols, lookupTable_1, node); + if (exportStars.declarations) { + for (var _i = 0, _a = exportStars.declarations; _i < _a.length; _i++) { + var node = _a[_i]; + var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); + var exportedSymbols = visit(resolvedModule); + extendExportSymbols(nestedSymbols, exportedSymbols, lookupTable_1, node); + } } lookupTable_1.forEach(function (_a, id) { var exportsWithDuplicate = _a.exportsWithDuplicate; @@ -46777,17 +48289,34 @@ var ts; var additionalContainers = ts.mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer); var reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration); var objectLiteralContainer = getVariableDeclarationOfObjectLiteral(container, meaning); - if (enclosingDeclaration && getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* Namespace */, /*externalOnly*/ false)) { + if (enclosingDeclaration && + container.flags & getQualifiedLeftMeaning(meaning) && + getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* 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 } - var res = ts.append(ts.append(additionalContainers, container), objectLiteralContainer); - return ts.concatenate(res, reexportContainers); + // 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 */ + ? forEachSymbolTableInScope(enclosingDeclaration, function (t) { + return ts.forEachEntry(t, function (s) { + if (s.flags & getQualifiedLeftMeaning(meaning) && getTypeOfSymbol(s) === getDeclaredTypeOfSymbol(container)) { + return s; + } + }); + }) : undefined; + var res = firstVariableMatch ? __spreadArray(__spreadArray([firstVariableMatch], additionalContainers), [container]) : __spreadArray(__spreadArray([], additionalContainers), [container]); + res = ts.append(res, objectLiteralContainer); + res = ts.addRange(res, reexportContainers); + return res; } var candidates = ts.mapDefined(symbol.declarations, function (d) { if (!ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent)) { return getSymbolOfNode(d.parent); } - if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 62 /* 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 /* 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)); } @@ -46859,7 +48388,7 @@ var ts; var members = node.members; for (var _i = 0, members_3 = members; _i < members_3.length; _i++) { var member = members_3[_i]; - if (member.kind === 166 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 168 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -46868,7 +48397,9 @@ var ts; var result = new Type(checker, flags); typeCount++; result.id = typeCount; - typeCatalog.push(result); + if (produceDiagnostics) { // Only record types from one checker + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.recordType(result); + } return result; } function createOriginType(flags) { @@ -46928,14 +48459,23 @@ var ts; }); return result || ts.emptyArray; } + function getNamedOrIndexSignatureMembers(members) { + var result = getNamedMembers(members); + var index = getIndexSymbolFromSymbolTable(members); + return index ? ts.concatenate(result, [index]) : result; + } function setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { - type.members = members; - type.properties = members === emptySymbols ? ts.emptyArray : getNamedMembers(members); - type.callSignatures = callSignatures; - type.constructSignatures = constructSignatures; - type.stringIndexInfo = stringIndexInfo; - type.numberIndexInfo = numberIndexInfo; - return type; + var resolved = type; + resolved.members = members; + resolved.properties = ts.emptyArray; + resolved.callSignatures = callSignatures; + resolved.constructSignatures = constructSignatures; + resolved.stringIndexInfo = stringIndexInfo; + resolved.numberIndexInfo = numberIndexInfo; + // This can loop back to getPropertyOfType() which would crash if `callSignatures` & `constructSignatures` are not initialized. + if (members !== emptySymbols) + resolved.properties = getNamedMembers(members); + return resolved; } function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { return setStructuredTypeMembers(createObjectType(16 /* Anonymous */, symbol), members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); @@ -46958,28 +48498,28 @@ var ts; var _loop_8 = function (location) { // Locals of a source file are not in scope (because they get merged into the global symbol table) if (location.locals && !isGlobalSourceFile(location)) { - if (result = callback(location.locals)) { + if (result = callback(location.locals, /*ignoreQualification*/ undefined, /*isLocalNameLookup*/ true, location)) { return { value: result }; } } switch (location.kind) { - case 297 /* SourceFile */: + case 299 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 256 /* ModuleDeclaration */: + case 258 /* 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 // to one another anyway) - if (result = callback((sym === null || sym === void 0 ? void 0 : sym.exports) || emptySymbols)) { + if (result = callback((sym === null || sym === void 0 ? void 0 : sym.exports) || emptySymbols, /*ignoreQualification*/ undefined, /*isLocalNameLookup*/ true, location)) { return { value: result }; } break; - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* 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 @@ -46994,7 +48534,7 @@ var ts; (table_1 || (table_1 = ts.createSymbolTable())).set(key, memberSymbol); } }); - if (table_1 && (result = callback(table_1))) { + if (table_1 && (result = callback(table_1, /*ignoreQualification*/ undefined, /*isLocalNameLookup*/ false, location))) { return { value: result }; } break; @@ -47005,7 +48545,7 @@ var ts; if (typeof state_2 === "object") return state_2.value; } - return callback(globals); + return callback(globals, /*ignoreQualification*/ undefined, /*isLocalNameLookup*/ true); } function getQualifiedLeftMeaning(rightMeaning) { // If we are looking in value space, the parent meaning is value, other wise it is namespace @@ -47016,20 +48556,30 @@ var ts; if (!(symbol && !isPropertyOrMethodDeclarationSymbol(symbol))) { return undefined; } + var links = getSymbolLinks(symbol); + 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; + if (cache.has(key)) { + return cache.get(key); + } var id = getSymbolId(symbol); var visitedSymbolTables = visitedSymbolTablesMap.get(id); if (!visitedSymbolTables) { visitedSymbolTablesMap.set(id, visitedSymbolTables = []); } - return forEachSymbolTableInScope(enclosingDeclaration, getAccessibleSymbolChainFromSymbolTable); + var result = forEachSymbolTableInScope(enclosingDeclaration, getAccessibleSymbolChainFromSymbolTable); + cache.set(key, result); + return result; /** * @param {ignoreQualification} boolean Set when a symbol is being looked for through the exports of another symbol (meaning we have a route to qualify it already) */ - function getAccessibleSymbolChainFromSymbolTable(symbols, ignoreQualification) { + function getAccessibleSymbolChainFromSymbolTable(symbols, ignoreQualification, isLocalNameLookup) { if (!ts.pushIfUnique(visitedSymbolTables, symbols)) { return undefined; } - var result = trySymbolTable(symbols, ignoreQualification); + var result = trySymbolTable(symbols, ignoreQualification, isLocalNameLookup); visitedSymbolTables.pop(); return result; } @@ -47047,7 +48597,7 @@ var ts; !ts.some(symbolFromSymbolTable.declarations, hasNonGlobalAugmentationExternalModuleSymbol) && (ignoreQualification || canQualifySymbol(getMergedSymbol(symbolFromSymbolTable), meaning)); } - function trySymbolTable(symbols, ignoreQualification) { + function trySymbolTable(symbols, ignoreQualification, isLocalNameLookup) { // If symbol is directly available by its name in the symbol table if (isAccessible(symbols.get(symbol.escapedName), /*resolvedAliasSymbol*/ undefined, ignoreQualification)) { return [symbol]; @@ -47060,9 +48610,11 @@ var ts; && !(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)) + // If we're looking up a local name to reference directly, omit namespace reexports, otherwise when we're trawling through an export list to make a dotted name, we can keep it + && (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, 270 /* ExportSpecifier */))) { + && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 272 /* ExportSpecifier */))) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); var candidate = getCandidateListForSymbol(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification); if (candidate) { @@ -47106,7 +48658,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, 270 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 272 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -47121,10 +48673,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 163 /* PropertyDeclaration */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: continue; default: return false; @@ -47162,7 +48714,7 @@ var ts; return hasAccessibleDeclarations; } } - else if (allowModules) { + if (allowModules) { if (ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { if (shouldComputeAliasesToMakeVisible) { earlyModuleBail = true; @@ -47236,7 +48788,8 @@ var ts; return { accessibility: 2 /* CannotBeNamed */, errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning), - errorModuleName: symbolToString(symbolExternalModule) + errorModuleName: symbolToString(symbolExternalModule), + errorNode: ts.isInJSFile(enclosingDeclaration) ? enclosingDeclaration : undefined, }; } } @@ -47253,14 +48806,14 @@ var ts; return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 297 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 299 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 297 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 299 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; - if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 78 /* Identifier */; }), getIsDeclarationVisible)) { + if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 79 /* Identifier */; }), getIsDeclarationVisible)) { return undefined; } return { accessibility: 0 /* Accessible */, aliasesToMakeVisible: aliasesToMakeVisible }; @@ -47312,14 +48865,14 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 176 /* TypeQuery */ || + if (entityName.parent.kind === 178 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) || - entityName.parent.kind === 158 /* ComputedPropertyName */) { + entityName.parent.kind === 160 /* ComputedPropertyName */) { // Typeof value meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 157 /* QualifiedName */ || entityName.kind === 201 /* PropertyAccessExpression */ || - entityName.parent.kind === 260 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 159 /* QualifiedName */ || entityName.kind === 203 /* PropertyAccessExpression */ || + entityName.parent.kind === 262 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -47360,7 +48913,7 @@ var ts; 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) === 297 /* SourceFile */ ? ts.createPrinter({ removeComments: true, neverAsciiEscape: true }) : ts.createPrinter({ removeComments: true }); + var printer = (enclosingDeclaration === null || enclosingDeclaration === void 0 ? void 0 : enclosingDeclaration.kind) === 299 /* 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); return writer; @@ -47372,10 +48925,10 @@ var ts; function signatureToStringWorker(writer) { var sigOutput; if (flags & 262144 /* WriteArrowStyleSignature */) { - sigOutput = kind === 1 /* Construct */ ? 175 /* ConstructorType */ : 174 /* FunctionType */; + sigOutput = kind === 1 /* Construct */ ? 177 /* ConstructorType */ : 176 /* FunctionType */; } else { - sigOutput = kind === 1 /* Construct */ ? 170 /* ConstructSignature */ : 169 /* CallSignature */; + sigOutput = kind === 1 /* Construct */ ? 172 /* ConstructSignature */ : 171 /* CallSignature */; } var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); @@ -47415,14 +48968,14 @@ var ts; return typeToString(type, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */); } function symbolValueDeclarationIsContextSensitive(symbol) { - return symbol && symbol.valueDeclaration && ts.isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration); + 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 */; } function isClassInstanceSide(type) { - return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || !!(ts.getObjectFlags(type) & 1073741824 /* IsClassInstanceClone */)); + return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288 /* Object */) && !!(ts.getObjectFlags(type) & 16777216 /* IsClassInstanceClone */))); } function createNodeBuilder() { return { @@ -47461,7 +49014,7 @@ var ts; enclosingDeclaration: enclosingDeclaration, flags: flags || 0 /* None */, // If no full tracker is provided, fake up a dummy one with a basic limited-functionality moduleResolverHost - tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: ts.noop, moduleResolverHost: flags & 134217728 /* DoNotIncludeSymbolChain */ ? { + tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: function () { return false; }, moduleResolverHost: flags & 134217728 /* DoNotIncludeSymbolChain */ ? { getCommonSourceDirectory: !!host.getCommonSourceDirectory ? function () { return host.getCommonSourceDirectory(); } : function () { return ""; }, getSourceFiles: function () { return host.getSourceFiles(); }, getCurrentDirectory: function () { return host.getCurrentDirectory(); }, @@ -47474,17 +49027,46 @@ var ts; getFileIncludeReasons: function () { return host.getFileIncludeReasons(); }, } : undefined }, encounteredError: false, + reportedDiagnostic: false, visitedTypes: undefined, symbolDepth: undefined, inferTypeParameters: undefined, approximateLength: 0 }; + context.tracker = wrapSymbolTrackerToReportForContext(context, context.tracker); var resultingNode = cb(context); if (context.truncating && context.flags & 1 /* 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; } + function wrapSymbolTrackerToReportForContext(context, tracker) { + var oldTrackSymbol = tracker.trackSymbol; + return __assign(__assign({}, tracker), { reportCyclicStructureError: wrapReportedDiagnostic(tracker.reportCyclicStructureError), reportInaccessibleThisError: wrapReportedDiagnostic(tracker.reportInaccessibleThisError), reportInaccessibleUniqueSymbolError: wrapReportedDiagnostic(tracker.reportInaccessibleUniqueSymbolError), reportLikelyUnsafeImportRequiredError: wrapReportedDiagnostic(tracker.reportLikelyUnsafeImportRequiredError), reportNonlocalAugmentation: wrapReportedDiagnostic(tracker.reportNonlocalAugmentation), reportPrivateInBaseOfClassExpression: wrapReportedDiagnostic(tracker.reportPrivateInBaseOfClassExpression), trackSymbol: oldTrackSymbol && (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var result = oldTrackSymbol.apply(void 0, args); + if (result) { + context.reportedDiagnostic = true; + } + return result; + }) }); + function wrapReportedDiagnostic(method) { + if (!method) { + return method; + } + return (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + context.reportedDiagnostic = true; + return method.apply(void 0, args); + }); + } + } function checkTruncationLength(context) { if (context.truncating) return context.truncating; @@ -47502,33 +49084,33 @@ var ts; return undefined; // TODO: GH#18217 } context.approximateLength += 3; - return ts.factory.createKeywordTypeNode(128 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(129 /* AnyKeyword */); } if (!(context.flags & 536870912 /* NoTypeReduction */)) { type = getReducedType(type); } if (type.flags & 1 /* Any */) { context.approximateLength += 3; - return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 136 /* IntrinsicKeyword */ : 128 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 137 /* IntrinsicKeyword */ : 129 /* AnyKeyword */); } if (type.flags & 2 /* Unknown */) { - return ts.factory.createKeywordTypeNode(152 /* UnknownKeyword */); + return ts.factory.createKeywordTypeNode(153 /* UnknownKeyword */); } if (type.flags & 4 /* String */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(147 /* StringKeyword */); + return ts.factory.createKeywordTypeNode(148 /* StringKeyword */); } if (type.flags & 8 /* Number */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(144 /* NumberKeyword */); + return ts.factory.createKeywordTypeNode(145 /* NumberKeyword */); } if (type.flags & 64 /* BigInt */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(155 /* BigIntKeyword */); + return ts.factory.createKeywordTypeNode(156 /* BigIntKeyword */); } if (type.flags & 16 /* Boolean */) { context.approximateLength += 7; - return ts.factory.createKeywordTypeNode(131 /* BooleanKeyword */); + return ts.factory.createKeywordTypeNode(132 /* BooleanKeyword */); } if (type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */)) { var parentSymbol = getParentOfSymbol(type.symbol); @@ -47582,15 +49164,15 @@ var ts; } } context.approximateLength += 13; - return ts.factory.createTypeOperatorNode(151 /* UniqueKeyword */, ts.factory.createKeywordTypeNode(148 /* SymbolKeyword */)); + return ts.factory.createTypeOperatorNode(152 /* UniqueKeyword */, ts.factory.createKeywordTypeNode(149 /* SymbolKeyword */)); } if (type.flags & 16384 /* Void */) { context.approximateLength += 4; - return ts.factory.createKeywordTypeNode(113 /* VoidKeyword */); + return ts.factory.createKeywordTypeNode(114 /* VoidKeyword */); } if (type.flags & 32768 /* Undefined */) { context.approximateLength += 9; - return ts.factory.createKeywordTypeNode(150 /* UndefinedKeyword */); + return ts.factory.createKeywordTypeNode(151 /* UndefinedKeyword */); } if (type.flags & 65536 /* Null */) { context.approximateLength += 4; @@ -47598,15 +49180,15 @@ var ts; } if (type.flags & 131072 /* Never */) { context.approximateLength += 5; - return ts.factory.createKeywordTypeNode(141 /* NeverKeyword */); + return ts.factory.createKeywordTypeNode(142 /* NeverKeyword */); } if (type.flags & 4096 /* ESSymbol */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(148 /* SymbolKeyword */); + return ts.factory.createKeywordTypeNode(149 /* SymbolKeyword */); } if (type.flags & 67108864 /* NonPrimitive */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(145 /* ObjectKeyword */); + return ts.factory.createKeywordTypeNode(146 /* ObjectKeyword */); } if (isThisTypeParameter(type)) { if (context.flags & 4194304 /* InObjectTypeLiteral */) { @@ -47676,7 +49258,7 @@ var ts; var indexedType = type.type; context.approximateLength += 6; var indexTypeNode = typeToTypeNodeHelper(indexedType, context); - return ts.factory.createTypeOperatorNode(138 /* KeyOfKeyword */, indexTypeNode); + return ts.factory.createTypeOperatorNode(139 /* KeyOfKeyword */, indexTypeNode); } if (type.flags & 134217728 /* TemplateLiteral */) { var texts_1 = type.texts; @@ -47733,14 +49315,14 @@ 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` - appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(138 /* KeyOfKeyword */, typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context)); + appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(139 /* KeyOfKeyword */, 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(getTemplateTypeFromMappedType(type), context); + var templateTypeNode = typeToTypeNodeHelper(removeMissingType(getTemplateTypeFromMappedType(type), !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), context); var mappedTypeNode = ts.factory.createMappedTypeNode(readonlyToken, typeParameterNode, nameTypeNode, questionToken, templateTypeNode); context.approximateLength += 10; return ts.setEmitFlags(mappedTypeNode, 1 /* SingleLine */); @@ -47756,7 +49338,9 @@ var ts; return symbolToTypeNode(symbol, context, isInstanceType); } // Always use 'typeof T' for type of class, enum, and module objects - else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 221 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || + else if (symbol.flags & 32 /* Class */ + && !getBaseTypeVariableOfClass(symbol) + && !(symbol.valueDeclaration && symbol.valueDeclaration.kind === 223 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, isInstanceType); @@ -47787,7 +49371,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 297 /* SourceFile */ || declaration.parent.kind === 257 /* ModuleBlock */; + return declaration.parent.kind === 299 /* SourceFile */ || declaration.parent.kind === 259 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -47797,6 +49381,7 @@ var ts; } } 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) : @@ -47810,6 +49395,19 @@ var ts; if (id && !context.symbolDepth) { context.symbolDepth = new ts.Map(); } + var links = context.enclosingDeclaration && getNodeLinks(context.enclosingDeclaration); + var key = getTypeId(type) + "|" + context.flags; + if (links) { + links.serializedTypes || (links.serializedTypes = new ts.Map()); + } + var cachedResult = (_a = links === null || links === void 0 ? void 0 : links.serializedTypes) === null || _a === void 0 ? void 0 : _a.get(key); + if (cachedResult) { + if (cachedResult.truncating) { + context.truncating = true; + } + context.approximateLength += cachedResult.addedLength; + return deepCloneOrReuseNode(cachedResult); + } var depth; if (id) { depth = context.symbolDepth.get(id) || 0; @@ -47819,12 +49417,27 @@ var ts; context.symbolDepth.set(id, depth + 1); } context.visitedTypes.add(typeId); + var startLength = context.approximateLength; var result = transform(type); + var addedLength = context.approximateLength - startLength; + if (!context.reportedDiagnostic && !context.encounteredError) { + if (context.truncating) { + result.truncating = true; + } + result.addedLength = addedLength; + (_b = links === null || links === void 0 ? void 0 : links.serializedTypes) === null || _b === void 0 ? void 0 : _b.set(key, result); + } context.visitedTypes.delete(typeId); if (id) { context.symbolDepth.set(id, depth); } return result; + function deepCloneOrReuseNode(node) { + if (!ts.nodeIsSynthesized(node) && ts.getParseTreeNode(node) === node) { + return node; + } + return ts.setTextRange(ts.factory.cloneNode(ts.visitEachChild(node, deepCloneOrReuseNode, ts.nullTransformationContext)), node); + } } function createTypeNodeFromObjectType(type) { if (isGenericMappedType(type) || type.containsError) { @@ -47838,12 +49451,12 @@ var ts; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 174 /* FunctionType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 176 /* FunctionType */, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 175 /* ConstructorType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 177 /* ConstructorType */, context); return signatureNode; } } @@ -47887,9 +49500,10 @@ var ts; } var elementType = typeToTypeNodeHelper(typeArguments[0], context); var arrayType = ts.factory.createArrayTypeNode(elementType); - return type.target === globalArrayType ? arrayType : ts.factory.createTypeOperatorNode(142 /* ReadonlyKeyword */, arrayType); + return type.target === globalArrayType ? arrayType : ts.factory.createTypeOperatorNode(143 /* 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 */)); }); if (typeArguments.length > 0) { var arity = getTypeReferenceArity(type); var tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, arity), context); @@ -47911,12 +49525,12 @@ var ts; } } var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode(tupleConstituentNodes), 1 /* SingleLine */); - return type.target.readonly ? ts.factory.createTypeOperatorNode(142 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + return type.target.readonly ? ts.factory.createTypeOperatorNode(143 /* 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(142 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + return type.target.readonly ? ts.factory.createTypeOperatorNode(143 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } context.encounteredError = true; return undefined; // TODO: GH#18217 @@ -48023,17 +49637,17 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 169 /* CallSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 171 /* CallSignature */, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; if (signature.flags & 4 /* Abstract */) continue; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 170 /* ConstructSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 172 /* ConstructSignature */, context)); } if (resolvedType.stringIndexInfo) { var indexSignature = void 0; - if (resolvedType.objectFlags & 2048 /* ReverseMapped */) { + if (resolvedType.objectFlags & 1024 /* ReverseMapped */) { indexSignature = indexInfoToIndexSignatureDeclarationHelper(createIndexInfo(anyType, resolvedType.stringIndexInfo.isReadonly, resolvedType.stringIndexInfo.declaration), 0 /* String */, context, createElidedInformationPlaceholder(context)); } else { @@ -48075,17 +49689,31 @@ var ts; if (!(context.flags & 1 /* NoTruncation */)) { return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier("..."), /*typeArguments*/ undefined); } - return ts.factory.createKeywordTypeNode(128 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(129 /* AnyKeyword */); + } + function shouldUsePlaceholderForProperty(propertySymbol, context) { + var _a; + // Use placeholders for reverse mapped types we've either already descended into, or which + // are nested reverse mappings within a mapping over a non-anonymous type. The later is a restriction mostly just to + // reduce the blowup in printback size from doing, eg, a deep reverse mapping over `Window`. + // 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 */) + && (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 */))); } function addPropertyToElementList(propertySymbol, context, typeElements) { + var _a; var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */); - var propertyType = propertyIsReverseMapped && context.flags & 33554432 /* InReverseMappedType */ ? - anyType : getTypeOfSymbol(propertySymbol); + var propertyType = shouldUsePlaceholderForProperty(propertySymbol, context) ? + anyType : getNonMissingTypeOfSymbol(propertySymbol); var saveEnclosingDeclaration = context.enclosingDeclaration; context.enclosingDeclaration = undefined; if (context.tracker.trackSymbol && ts.getCheckFlags(propertySymbol) & 4096 /* Late */ && isLateBoundName(propertySymbol.escapedName)) { var decl = ts.first(propertySymbol.declarations); - if (hasLateBindableName(decl)) { + if (propertySymbol.declarations && hasLateBindableName(decl)) { if (ts.isBinaryExpression(decl)) { var name = ts.getNameOfDeclaration(decl); if (name && ts.isElementAccessExpression(name) && ts.isPropertyAccessEntityNameExpression(name.argumentExpression)) { @@ -48097,30 +49725,35 @@ var ts; } } } - context.enclosingDeclaration = saveEnclosingDeclaration; + context.enclosingDeclaration = propertySymbol.valueDeclaration || ((_a = propertySymbol.declarations) === null || _a === void 0 ? void 0 : _a[0]) || saveEnclosingDeclaration; 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 */); for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { var signature = signatures_1[_i]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 164 /* MethodSignature */, context, { name: propertyName, questionToken: optionalToken }); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 166 /* MethodSignature */, context, { name: propertyName, questionToken: optionalToken }); typeElements.push(preserveCommentsOn(methodDeclaration)); } } else { - var savedFlags = context.flags; - context.flags |= propertyIsReverseMapped ? 33554432 /* InReverseMappedType */ : 0; var propertyTypeNode = void 0; - if (propertyIsReverseMapped && !!(savedFlags & 33554432 /* InReverseMappedType */)) { + if (shouldUsePlaceholderForProperty(propertySymbol, context)) { propertyTypeNode = createElidedInformationPlaceholder(context); } else { - propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.factory.createKeywordTypeNode(128 /* AnyKeyword */); + if (propertyIsReverseMapped) { + context.reverseMappedStack || (context.reverseMappedStack = []); + context.reverseMappedStack.push(propertySymbol); + } + propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.factory.createKeywordTypeNode(129 /* AnyKeyword */); + if (propertyIsReverseMapped) { + context.reverseMappedStack.pop(); + } } - context.flags = savedFlags; - var modifiers = isReadonlySymbol(propertySymbol) ? [ts.factory.createToken(142 /* ReadonlyKeyword */)] : undefined; + var modifiers = isReadonlySymbol(propertySymbol) ? [ts.factory.createToken(143 /* ReadonlyKeyword */)] : undefined; if (modifiers) { context.approximateLength += 9; } @@ -48128,9 +49761,10 @@ var ts; typeElements.push(preserveCommentsOn(propertySignature)); } function preserveCommentsOn(node) { - if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 333 /* JSDocPropertyTag */; })) { - var d = ts.find(propertySymbol.declarations, function (d) { return d.kind === 333 /* JSDocPropertyTag */; }); - var commentText = d.comment; + var _a; + if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 341 /* JSDocPropertyTag */; })) { + var d = (_a = propertySymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 341 /* 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 }]); } @@ -48159,25 +49793,25 @@ var ts; var mayHaveNameCollisions = !(context.flags & 64 /* 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_4 = []; + var result_5 = []; var i = 0; for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { var type = types_2[_i]; i++; if (checkTruncationLength(context) && (i + 2 < types.length - 1)) { - result_4.push(ts.factory.createTypeReferenceNode("... " + (types.length - i) + " more ...", /*typeArguments*/ undefined)); + result_5.push(ts.factory.createTypeReferenceNode("... " + (types.length - i) + " more ...", /*typeArguments*/ undefined)); var typeNode_1 = typeToTypeNodeHelper(types[types.length - 1], context); if (typeNode_1) { - result_4.push(typeNode_1); + result_5.push(typeNode_1); } break; } context.approximateLength += 2; // Account for whitespace + separator var typeNode = typeToTypeNodeHelper(type, context); if (typeNode) { - result_4.push(typeNode); + result_5.push(typeNode); if (seenNames && ts.isIdentifierTypeReference(typeNode)) { - seenNames.add(typeNode.typeName.escapedText, [type, result_4.length - 1]); + seenNames.add(typeNode.typeName.escapedText, [type, result_5.length - 1]); } } } @@ -48199,13 +49833,13 @@ var ts; })) { for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { var _a = types_3[_i], type = _a[0], resultIndex = _a[1]; - result_4[resultIndex] = typeToTypeNodeHelper(type, context); + result_5[resultIndex] = typeToTypeNodeHelper(type, context); } } }); context.flags = saveContextFlags; } - return result_4; + return result_5; } } function typesAreSameReference(a, b) { @@ -48215,7 +49849,7 @@ var ts; } function indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context, typeNode) { var name = ts.getNameFromIndexInfo(indexInfo) || "x"; - var indexerTypeNode = ts.factory.createKeywordTypeNode(kind === 0 /* String */ ? 147 /* StringKeyword */ : 144 /* NumberKeyword */); + var indexerTypeNode = ts.factory.createKeywordTypeNode(kind === 0 /* String */ ? 148 /* StringKeyword */ : 145 /* NumberKeyword */); var indexingParameter = ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -48230,13 +49864,14 @@ var ts; } context.approximateLength += (name.length + 4); return ts.factory.createIndexSignature( - /*decorators*/ undefined, indexInfo.isReadonly ? [ts.factory.createToken(142 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); + /*decorators*/ undefined, indexInfo.isReadonly ? [ts.factory.createToken(143 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); } function signatureToSignatureDeclarationHelper(signature, kind, context, options) { var _a, _b, _c, _d; var suppressAny = context.flags & 256 /* SuppressAnyReturnType */; if (suppressAny) context.flags &= ~256 /* 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) { @@ -48247,7 +49882,7 @@ 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 === 166 /* Constructor */, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); }); + 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 === 168 /* Constructor */, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -48256,7 +49891,7 @@ var ts; var typePredicate = getTypePredicateOfSignature(signature); if (typePredicate) { var assertsModifier = typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? - ts.factory.createToken(127 /* AssertsKeyword */) : + ts.factory.createToken(128 /* AssertsKeyword */) : undefined; var parameterName = typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.setEmitFlags(ts.factory.createIdentifier(typePredicate.parameterName), 16777216 /* NoAsciiEscaping */) : @@ -48270,29 +49905,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(128 /* AnyKeyword */); + returnTypeNode = ts.factory.createKeywordTypeNode(129 /* AnyKeyword */); } } var modifiers = options === null || options === void 0 ? void 0 : options.modifiers; - if ((kind === 175 /* ConstructorType */) && signature.flags & 4 /* Abstract */) { + if ((kind === 177 /* ConstructorType */) && signature.flags & 4 /* Abstract */) { var flags = ts.modifiersToFlags(modifiers); modifiers = ts.factory.createModifiersFromModifierFlags(flags | 128 /* Abstract */); } - context.approximateLength += 3; // Usually a signature contributes a few more characters than this, but 3 is the minimum - var node = kind === 169 /* CallSignature */ ? ts.factory.createCallSignature(typeParameters, parameters, returnTypeNode) : - kind === 170 /* ConstructSignature */ ? ts.factory.createConstructSignature(typeParameters, parameters, returnTypeNode) : - kind === 164 /* 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 === 165 /* MethodDeclaration */ ? ts.factory.createMethodDeclaration(/*decorators*/ undefined, 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 === 166 /* Constructor */ ? ts.factory.createConstructorDeclaration(/*decorators*/ undefined, modifiers, parameters, /*body*/ undefined) : - kind === 167 /* GetAccessor */ ? ts.factory.createGetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_c = options === null || options === void 0 ? void 0 : options.name) !== null && _c !== void 0 ? _c : ts.factory.createIdentifier(""), parameters, returnTypeNode, /*body*/ undefined) : - kind === 168 /* SetAccessor */ ? ts.factory.createSetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_d = options === null || options === void 0 ? void 0 : options.name) !== null && _d !== void 0 ? _d : ts.factory.createIdentifier(""), parameters, /*body*/ undefined) : - kind === 171 /* IndexSignature */ ? ts.factory.createIndexSignature(/*decorators*/ undefined, modifiers, parameters, returnTypeNode) : - kind === 308 /* JSDocFunctionType */ ? ts.factory.createJSDocFunctionType(parameters, returnTypeNode) : - kind === 174 /* FunctionType */ ? ts.factory.createFunctionTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : - kind === 175 /* ConstructorType */ ? ts.factory.createConstructorTypeNode(modifiers, typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : - kind === 251 /* FunctionDeclaration */ ? ts.factory.createFunctionDeclaration(/*decorators*/ undefined, 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 === 208 /* 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 === 209 /* ArrowFunction */ ? ts.factory.createArrowFunction(modifiers, typeParameters, parameters, returnTypeNode, /*equalsGreaterThanToken*/ undefined, ts.factory.createBlock([])) : + var node = kind === 171 /* CallSignature */ ? ts.factory.createCallSignature(typeParameters, parameters, returnTypeNode) : + kind === 172 /* ConstructSignature */ ? ts.factory.createConstructSignature(typeParameters, parameters, returnTypeNode) : + kind === 166 /* 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 === 167 /* MethodDeclaration */ ? ts.factory.createMethodDeclaration(/*decorators*/ undefined, 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 === 168 /* Constructor */ ? ts.factory.createConstructorDeclaration(/*decorators*/ undefined, modifiers, parameters, /*body*/ undefined) : + kind === 169 /* GetAccessor */ ? ts.factory.createGetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_c = options === null || options === void 0 ? void 0 : options.name) !== null && _c !== void 0 ? _c : ts.factory.createIdentifier(""), parameters, returnTypeNode, /*body*/ undefined) : + kind === 170 /* SetAccessor */ ? ts.factory.createSetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_d = options === null || options === void 0 ? void 0 : options.name) !== null && _d !== void 0 ? _d : ts.factory.createIdentifier(""), parameters, /*body*/ undefined) : + kind === 173 /* IndexSignature */ ? ts.factory.createIndexSignature(/*decorators*/ undefined, modifiers, parameters, returnTypeNode) : + kind === 311 /* JSDocFunctionType */ ? ts.factory.createJSDocFunctionType(parameters, returnTypeNode) : + kind === 176 /* FunctionType */ ? ts.factory.createFunctionTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : + kind === 177 /* ConstructorType */ ? ts.factory.createConstructorTypeNode(modifiers, typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : + kind === 253 /* FunctionDeclaration */ ? ts.factory.createFunctionDeclaration(/*decorators*/ undefined, 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 === 210 /* 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 === 211 /* 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); @@ -48314,9 +49948,9 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags, privateSymbolVisitor, bundledImports) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 160 /* Parameter */); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 162 /* Parameter */); if (!parameterDeclaration && !ts.isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 326 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 334 /* JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -48330,8 +49964,8 @@ var ts; var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* RestParameter */; var dotDotDotToken = isRest ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined; var name = parameterDeclaration ? parameterDeclaration.name ? - parameterDeclaration.name.kind === 78 /* Identifier */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : - parameterDeclaration.name.kind === 157 /* QualifiedName */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 79 /* Identifier */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 159 /* QualifiedName */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : cloneBindingName(parameterDeclaration.name) : ts.symbolName(parameterSymbol) : ts.symbolName(parameterSymbol); @@ -48496,11 +50130,11 @@ var ts; } function getSpecifierForModuleSymbol(symbol, context) { var _a; - var file = ts.getDeclarationOfKind(symbol, 297 /* SourceFile */); + var file = ts.getDeclarationOfKind(symbol, 299 /* SourceFile */); if (!file) { var equivalentFileSymbol = ts.firstDefined(symbol.declarations, function (d) { return getFileSymbolIfFileSymbolExportEqualsContainer(d, symbol); }); if (equivalentFileSymbol) { - file = ts.getDeclarationOfKind(equivalentFileSymbol, 297 /* SourceFile */); + file = ts.getDeclarationOfKind(equivalentFileSymbol, 299 /* SourceFile */); } } if (file && file.moduleName !== undefined) { @@ -48511,8 +50145,8 @@ var ts; if (context.tracker.trackReferencedAmbientModule) { var ambientDecls = ts.filter(symbol.declarations, ts.isAmbientModule); if (ts.length(ambientDecls)) { - for (var _i = 0, ambientDecls_1 = ambientDecls; _i < ambientDecls_1.length; _i++) { - var decl = ambientDecls_1[_i]; + for (var _i = 0, _b = ambientDecls; _i < _b.length; _i++) { + var decl = _b[_i]; context.tracker.trackReferencedAmbientModule(decl, symbol); } } @@ -48539,7 +50173,7 @@ var ts; // specifier preference var moduleResolverHost = context.tracker.moduleResolverHost; var specifierCompilerOptions = isBundle_1 ? __assign(__assign({}, compilerOptions), { baseUrl: moduleResolverHost.getCommonSourceDirectory() }) : compilerOptions; - specifier = ts.first(ts.moduleSpecifiers.getModuleSpecifiers(symbol, checker, specifierCompilerOptions, contextFile, moduleResolverHost, { importModuleSpecifierPreference: isBundle_1 ? "non-relative" : "relative", importModuleSpecifierEnding: isBundle_1 ? "minimal" : undefined })); + specifier = ts.first(ts.moduleSpecifiers.getModuleSpecifiers(symbol, checker, specifierCompilerOptions, contextFile, moduleResolverHost, { importModuleSpecifierPreference: isBundle_1 ? "non-relative" : "project-relative", importModuleSpecifierEnding: isBundle_1 ? "minimal" : undefined })); (_a = links.specifierCache) !== null && _a !== void 0 ? _a : (links.specifierCache = new ts.Map()); links.specifierCache.set(contextFile.path, specifier); } @@ -48652,7 +50286,7 @@ var ts; return false; } function typeParameterToName(type, context) { - var _a; + var _a, _b; if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && context.typeParameterNames) { var cached = context.typeParameterNames.get(getTypeId(type)); if (cached) { @@ -48660,22 +50294,25 @@ var ts; } } var result = symbolToName(type.symbol, context, 788968 /* Type */, /*expectsIdentifier*/ true); - if (!(result.kind & 78 /* Identifier */)) { + if (!(result.kind & 79 /* Identifier */)) { return ts.factory.createIdentifier("(Missing type parameter)"); } if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { var rawtext = result.escapedText; - var i = 0; + var i = ((_a = context.typeParameterNamesByTextNextNameCount) === null || _a === void 0 ? void 0 : _a.get(rawtext)) || 0; var text = rawtext; - while (((_a = context.typeParameterNamesByText) === null || _a === void 0 ? void 0 : _a.has(text)) || typeParameterShadowsNameInScope(text, context, type)) { + while (((_b = context.typeParameterNamesByText) === null || _b === void 0 ? void 0 : _b.has(text)) || typeParameterShadowsNameInScope(text, context, type)) { i++; text = rawtext + "_" + i; } if (text !== rawtext) { result = ts.factory.createIdentifier(text, result.typeArguments); } + // avoiding iterations of the above loop turns out to be worth it when `i` starts to get large, so we cache the max + // `i` we've used thus far, to save work later + (context.typeParameterNamesByTextNextNameCount || (context.typeParameterNamesByTextNextNameCount = new ts.Map())).set(rawtext, i); (context.typeParameterNames || (context.typeParameterNames = new ts.Map())).set(getTypeId(type), result); - (context.typeParameterNamesByText || (context.typeParameterNamesByText = new ts.Set())).add(result.escapedText); + (context.typeParameterNamesByText || (context.typeParameterNamesByText = new ts.Set())).add(rawtext); } return result; } @@ -48683,7 +50320,7 @@ var ts; var chain = lookupSymbolChain(symbol, context, meaning); if (expectsIdentifier && chain.length !== 1 && !context.encounteredError - && !(context.flags & 65536 /* AllowQualifedNameInPlaceOfIdentifier */)) { + && !(context.flags & 65536 /* AllowQualifiedNameInPlaceOfIdentifier */)) { context.encounteredError = true; } return createEntityNameFromSymbolChain(chain, chain.length - 1); @@ -48763,9 +50400,6 @@ var ts; if (fromNameType) { return fromNameType; } - if (ts.isKnownSymbol(symbol)) { - return ts.factory.createComputedPropertyName(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("Symbol"), symbol.escapedName.substr(3))); - } var rawName = ts.unescapeLeadingUnderscores(symbol.escapedName); var stringNamed = !!ts.length(symbol.declarations) && ts.every(symbol.declarations, isStringNamed); return createPropertyNameNodeForIdentifierOrLiteral(rawName, stringNamed, singleQuote); @@ -48817,6 +50451,7 @@ var ts; if (initial.typeParameterSymbolList) { initial.typeParameterSymbolList = new ts.Set(initial.typeParameterSymbolList); } + initial.tracker = wrapSymbolTrackerToReportForContext(initial, initial.tracker); return initial; } function getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration) { @@ -48832,13 +50467,13 @@ var ts; function serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled) { if (type !== errorType && enclosingDeclaration) { var declWithExistingAnnotation = getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration); - if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation)) { + if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation) && !ts.isGetAccessorDeclaration(declWithExistingAnnotation)) { // try to reuse the existing annotation var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation); if (getTypeFromTypeNode(existing) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) { - var result_5 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled); - if (result_5) { - return result_5; + var result_6 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled); + if (result_6) { + return result_6; } } } @@ -48855,10 +50490,14 @@ var ts; function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) { if (type !== errorType && context.enclosingDeclaration) { var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); - if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation && instantiateType(getTypeFromTypeNode(annotation), signature.mapper) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) { - var result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled); - if (result) { - return result; + 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; + if (thisInstantiated === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) { + var result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled); + if (result) { + return result; + } } } } @@ -48902,17 +50541,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 === 310 /* JSDocNamepathType */) { - return ts.factory.createKeywordTypeNode(128 /* AnyKeyword */); + if (ts.isJSDocAllType(node) || node.kind === 313 /* JSDocNamepathType */) { + return ts.factory.createKeywordTypeNode(129 /* AnyKeyword */); } if (ts.isJSDocUnknownType(node)) { - return ts.factory.createKeywordTypeNode(152 /* UnknownKeyword */); + return ts.factory.createKeywordTypeNode(153 /* 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(150 /* UndefinedKeyword */)]); + return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createKeywordTypeNode(151 /* UndefinedKeyword */)]); } if (ts.isJSDocNonNullableType(node)) { return ts.visitNode(node.type, visitExistingNodeTreeSymbols); @@ -48926,11 +50565,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(128 /* AnyKeyword */)); + /*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(129 /* AnyKeyword */)); })); } if (ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "") { - return ts.setOriginalNode(ts.factory.createKeywordTypeNode(128 /* AnyKeyword */), node); + return ts.setOriginalNode(ts.factory.createKeywordTypeNode(129 /* AnyKeyword */), node); } if ((ts.isExpressionWithTypeArguments(node) || ts.isTypeReferenceNode(node)) && ts.isJSDocIndexSignature(node)) { return ts.factory.createTypeLiteralNode([ts.factory.createIndexSignature( @@ -48947,13 +50586,13 @@ var ts; return ts.factory.createConstructorTypeNode(node.modifiers, 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( /*decorators*/ undefined, /*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(128 /* AnyKeyword */)); + /*initializer*/ undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(129 /* AnyKeyword */)); } else { return ts.factory.createFunctionTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.map(node.parameters, function (p, i) { return ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, getEffectiveDotDotDotForParameter(p), getNameForJSDocFunctionParameter(p, i), p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), - /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(128 /* AnyKeyword */)); + /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(129 /* AnyKeyword */)); } } if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(getTypeReferenceName(node), 788968 /* Type */, /*ignoreErrors*/ true))) { @@ -49021,8 +50660,8 @@ var ts; } } function symbolTableToDeclarationStatements(symbolTable, context, bundled) { - var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.factory.createPropertyDeclaration, 165 /* MethodDeclaration */, /*useAcessors*/ true); - var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type) { return ts.factory.createPropertySignature(mods, name, question, type); }, 164 /* MethodSignature */, /*useAcessors*/ false); + var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.factory.createPropertyDeclaration, 167 /* MethodDeclaration */, /*useAcessors*/ true); + var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type) { return ts.factory.createPropertySignature(mods, name, question, type); }, 166 /* 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 @@ -49034,7 +50673,7 @@ var ts; var deferredPrivatesStack = []; 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); + var accessibleResult = isSymbolAccessible(sym, decl, meaning, /*computeAliases*/ false); if (accessibleResult.accessibility === 0 /* 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); @@ -49043,9 +50682,11 @@ var ts; } } else if (oldcontext.tracker && oldcontext.tracker.trackSymbol) { - oldcontext.tracker.trackSymbol(sym, decl, meaning); + return oldcontext.tracker.trackSymbol(sym, decl, meaning); } + return false; } }) }); + context.tracker = wrapSymbolTrackerToReportForContext(context, context.tracker); ts.forEachEntry(symbolTable, function (symbol, name) { var baseName = ts.unescapeLeadingUnderscores(name); void getInternalSymbolName(symbol, baseName); // Called to cache values into `usedSymbolNames` and `remappedSymbolNames` @@ -49060,7 +50701,7 @@ var ts; visitSymbolTable(symbolTable); return mergeRedundantStatements(results); function isIdentifierAndNotUndefined(node) { - return !!node && node.kind === 78 /* Identifier */; + return !!node && node.kind === 79 /* Identifier */; } function getNamesOfDeclaration(statement) { if (ts.isVariableStatement(statement)) { @@ -49229,6 +50870,9 @@ var ts; var oldContext = context; context = cloneNodeBuilderContext(context); var result = serializeSymbolWorker(symbol, isPrivate, propertyAsAlias); + if (context.reportedDiagnostic) { + oldcontext.reportedDiagnostic = context.reportedDiagnostic; // hoist diagnostic result into outer context + } context = oldContext; return result; } @@ -49243,6 +50887,7 @@ var ts; // If it's a class/interface/function: emit a class/interface/function with a `default` modifier // These forms can merge, eg (`export default 12; export default interface A {}`) function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias) { + var _a, _b; var symbolName = ts.unescapeLeadingUnderscores(symbol.escapedName); var isDefault = symbol.escapedName === "default" /* Default */; if (isPrivate && !(context.flags & 131072 /* AllowAnonymousIdentifier */) && ts.isStringANonContextualKeyword(symbolName) && !isDefault) { @@ -49301,9 +50946,9 @@ var ts; if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) { textRange = textRange.parent.parent; } - var propertyAccessRequire = ts.find(symbol.declarations, ts.isPropertyAccessExpression); + var propertyAccessRequire = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isPropertyAccessExpression); if (propertyAccessRequire && ts.isBinaryExpression(propertyAccessRequire.parent) && ts.isIdentifier(propertyAccessRequire.parent.right) - && type.symbol && ts.isSourceFile(type.symbol.valueDeclaration)) { + && ((_b = type.symbol) === null || _b === void 0 ? void 0 : _b.valueDeclaration) && ts.isSourceFile(type.symbol.valueDeclaration)) { var alias = localName === propertyAccessRequire.parent.right.escapedText ? undefined : propertyAccessRequire.parent.right; addResult(ts.factory.createExportDeclaration( /*decorators*/ undefined, @@ -49353,7 +50998,10 @@ var ts; serializeEnum(symbol, symbolName, modifierFlags); } if (symbol.flags & 32 /* Class */) { - if (symbol.flags & 4 /* Property */ && ts.isBinaryExpression(symbol.valueDeclaration.parent) && ts.isClassExpression(symbol.valueDeclaration.parent.right)) { + if (symbol.flags & 4 /* Property */ + && symbol.valueDeclaration + && ts.isBinaryExpression(symbol.valueDeclaration.parent) + && ts.isClassExpression(symbol.valueDeclaration.parent.right)) { // Looks like a `module.exports.Sub = class {}` - if we serialize `symbol` as a class, the result will have no members, // since the classiness is actually from the target of the effective alias the symbol is. yes. A BlockScopedVariable|Class|Property // _really_ acts like an Alias, and none of a BlockScopedVariable, Class, or Property. This is the travesty of JS binding today. @@ -49379,12 +51027,14 @@ var ts; if (symbol.flags & 8388608 /* ExportStar */) { // synthesize export * from "moduleReference" // Straightforward - only one thing to do - make an export declaration - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var node = _a[_i]; - var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); - if (!resolvedModule) - continue; - addResult(ts.factory.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, /*exportClause*/ undefined, ts.factory.createStringLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0 /* None */); + if (symbol.declarations) { + for (var _i = 0, _c = symbol.declarations; _i < _c.length; _i++) { + var node = _c[_i]; + var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); + if (!resolvedModule) + continue; + addResult(ts.factory.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, /*exportClause*/ undefined, ts.factory.createStringLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0 /* None */); + } } } if (needsPostExportDefault) { @@ -49422,15 +51072,16 @@ var ts; function addResult(node, additionalModifierFlags) { if (ts.canHaveModifiers(node)) { var newModifierFlags = 0 /* None */; + var enclosingDeclaration_1 = context.enclosingDeclaration && + (ts.isJSDocTypeAlias(context.enclosingDeclaration) ? ts.getSourceFileOfNode(context.enclosingDeclaration) : context.enclosingDeclaration); if (additionalModifierFlags & 1 /* Export */ && - context.enclosingDeclaration && - (isExportingScope(context.enclosingDeclaration) || ts.isModuleDeclaration(context.enclosingDeclaration)) && + 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 */; } if (addingDeclare && !(newModifierFlags & 1 /* Export */) && - (!context.enclosingDeclaration || !(context.enclosingDeclaration.flags & 8388608 /* Ambient */)) && + (!enclosingDeclaration_1 || !(enclosingDeclaration_1.flags & 8388608 /* 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 */; @@ -49445,19 +51096,23 @@ var ts; results.push(node); } function serializeTypeAlias(symbol, symbolName, modifierFlags) { + var _a; var aliasType = getDeclaredTypeOfTypeAlias(symbol); var typeParams = getSymbolLinks(symbol).typeParameters; var typeParamDecls = ts.map(typeParams, function (p) { return typeParameterToDeclaration(p, context); }); - var jsdocAliasDecl = ts.find(symbol.declarations, ts.isJSDocTypeAlias); - var commentText = jsdocAliasDecl ? jsdocAliasDecl.comment || jsdocAliasDecl.parent.comment : undefined; + 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 */; + 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(/*decorators*/ undefined, /*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); context.flags = oldFlags; + context.enclosingDeclaration = oldEnclosingDecl; } function serializeInterface(symbol, symbolName, modifierFlags) { var interfaceType = getDeclaredTypeOfClassOrInterface(symbol); @@ -49466,10 +51121,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, 169 /* CallSignature */); - var constructSignatures = serializeSignatures(1 /* Construct */, interfaceType, baseType, 170 /* ConstructSignature */); + var callSignatures = serializeSignatures(0 /* Call */, interfaceType, baseType, 171 /* CallSignature */); + var constructSignatures = serializeSignatures(1 /* Construct */, interfaceType, baseType, 172 /* ConstructSignature */); var indexSignatures = serializeIndexSignatures(interfaceType, baseType); - var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.factory.createHeritageClause(93 /* ExtendsKeyword */, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b, 111551 /* Value */); }))]; + var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.factory.createHeritageClause(94 /* ExtendsKeyword */, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b, 111551 /* Value */); }))]; addResult(ts.factory.createInterfaceDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, heritageClauses, __spreadArray(__spreadArray(__spreadArray(__spreadArray([], indexSignatures), constructSignatures), callSignatures), members)), modifierFlags); @@ -49536,9 +51191,8 @@ var ts; 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, 251 /* FunctionDeclaration */, context, { name: ts.factory.createIdentifier(localName), privateSymbolVisitor: includePrivateSymbol, bundledImports: bundled }); - // for expressions assigned to `var`s, use the `var` as the text range - addResult(ts.setTextRange(decl, sig.declaration && ts.isVariableDeclaration(sig.declaration.parent) && sig.declaration.parent.parent || sig.declaration), modifierFlags); + var decl = signatureToSignatureDeclarationHelper(sig, 253 /* 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)) { @@ -49546,6 +51200,18 @@ var ts; 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 */) { + return signature.declaration.parent; + } + // for expressions assigned to `var`s, use the `var` as the text range + if (ts.isVariableDeclaration(signature.declaration.parent) && signature.declaration.parent.parent) { + return signature.declaration.parent.parent; + } + } + return signature.declaration; + } function serializeAsNamespaceDeclaration(props, localName, modifierFlags, suppressNewPrivateContext) { if (ts.length(props)) { var localVsRemoteMap = ts.arrayToMultiMap(props, function (p) { @@ -49632,8 +51298,8 @@ var ts; return undefined; } function serializeAsClass(symbol, localName, modifierFlags) { - var _a; - var originalDecl = ts.find(symbol.declarations, ts.isClassLike); + var _a, _b; + var originalDecl = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isClassLike); var oldEnclosing = context.enclosingDeclaration; context.enclosingDeclaration = originalDecl || oldEnclosing; var localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -49644,25 +51310,25 @@ var ts; var implementsExpressions = originalImplements && sanitizeJSDocImplements(originalImplements) || ts.mapDefined(getImplementsTypes(classType), serializeImplementedType); var staticType = getTypeOfSymbol(symbol); - var isClass = !!((_a = staticType.symbol) === null || _a === void 0 ? void 0 : _a.valueDeclaration) && ts.isClassLike(staticType.symbol.valueDeclaration); + var isClass = !!((_b = staticType.symbol) === null || _b === void 0 ? void 0 : _b.valueDeclaration) && ts.isClassLike(staticType.symbol.valueDeclaration); var staticBaseType = isClass ? getBaseConstructorTypeOfClass(staticType) : anyType; - var heritageClauses = __spreadArray(__spreadArray([], !ts.length(baseTypes) ? [] : [ts.factory.createHeritageClause(93 /* ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))]), !ts.length(implementsExpressions) ? [] : [ts.factory.createHeritageClause(116 /* ImplementsKeyword */, implementsExpressions)]); + var heritageClauses = __spreadArray(__spreadArray([], !ts.length(baseTypes) ? [] : [ts.factory.createHeritageClause(94 /* ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))]), !ts.length(implementsExpressions) ? [] : [ts.factory.createHeritageClause(117 /* ImplementsKeyword */, implementsExpressions)]); var symbolProps = getNonInterhitedProperties(classType, baseTypes, getPropertiesOfType(classType)); var publicSymbolProps = ts.filter(symbolProps, function (s) { // `valueDeclaration` could be undefined if inherited from // a union/intersection base type, but inherited properties // don't matter here. var valueDecl = s.valueDeclaration; - return valueDecl && !(ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name)); + return !!valueDecl && !(ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name)); }); var hasPrivateIdentifier = ts.some(symbolProps, function (s) { // `valueDeclaration` could be undefined if inherited from // a union/intersection base type, but inherited properties // don't matter here. var valueDecl = s.valueDeclaration; - return valueDecl && ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name); + return !!valueDecl && ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name); }); // Boil down all private properties into a single one. var privateProperties = hasPrivateIdentifier ? @@ -49685,7 +51351,7 @@ var ts; !ts.some(getSignaturesOfType(staticType, 1 /* Construct */)); var constructors = isNonConstructableClassLikeInJsFile ? [ts.factory.createConstructorDeclaration(/*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(8 /* Private */), [], /*body*/ undefined)] : - serializeSignatures(1 /* Construct */, staticType, staticBaseType, 166 /* Constructor */); + serializeSignatures(1 /* Construct */, staticType, staticBaseType, 168 /* Constructor */); var indexSignatures = serializeIndexSignatures(classType, baseTypes[0]); context.enclosingDeclaration = oldEnclosing; addResult(ts.setTextRange(ts.factory.createClassDeclaration( @@ -49712,8 +51378,8 @@ var ts; var targetName = getInternalSymbolName(target, verbatimTargetName); includePrivateSymbol(target); // the target may be within the same scope - attempt to serialize it first switch (node.kind) { - case 198 /* BindingElement */: - if (((_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.kind) === 249 /* VariableDeclaration */) { + case 200 /* BindingElement */: + if (((_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.kind) === 251 /* VariableDeclaration */) { // const { SomeClass } = require('./lib'); var specifier_1 = getSpecifierForModuleSymbol(target.parent || target, context); // './lib' var propertyName = node.propertyName; @@ -49725,13 +51391,13 @@ var ts; // 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 289 /* ShorthandPropertyAssignment */: - if (((_e = (_d = node.parent) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.kind) === 216 /* BinaryExpression */) { + case 291 /* ShorthandPropertyAssignment */: + if (((_e = (_d = node.parent) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.kind) === 218 /* BinaryExpression */) { // module.exports = { SomeClass } serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), targetName); } break; - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: // commonjs require: const x = require('y') if (ts.isPropertyAccessExpression(node.initializer)) { // const x = require('y').z @@ -49751,7 +51417,7 @@ var ts; break; } // else fall through and treat commonjs require just like import= - case 260 /* ImportEqualsDeclaration */: + case 262 /* 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)) { @@ -49768,13 +51434,13 @@ var ts; ? symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false) : ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)))), isLocalImport ? modifierFlags : 0 /* None */); break; - case 259 /* NamespaceExportDeclaration */: + case 261 /* 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 */); break; - case 262 /* ImportClause */: + case 264 /* ImportClause */: addResult(ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, ts.factory.createIdentifier(localName), /*namedBindings*/ undefined), @@ -49783,18 +51449,18 @@ var ts; // In such cases, the `target` refers to the module itself already ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context))), 0 /* None */); break; - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: addResult(ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*importClause*/ undefined, ts.factory.createNamespaceImport(ts.factory.createIdentifier(localName))), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* None */); break; - case 269 /* NamespaceExport */: + case 271 /* NamespaceExport */: addResult(ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, ts.factory.createNamespaceExport(ts.factory.createIdentifier(localName)), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* None */); break; - case 265 /* ImportSpecifier */: + case 267 /* ImportSpecifier */: addResult(ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause( @@ -49803,7 +51469,7 @@ var ts; ts.factory.createImportSpecifier(localName !== verbatimTargetName ? ts.factory.createIdentifier(verbatimTargetName) : undefined, ts.factory.createIdentifier(localName)) ])), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context))), 0 /* None */); break; - case 270 /* ExportSpecifier */: + case 272 /* 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; @@ -49811,12 +51477,12 @@ var ts; // another file serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), specifier ? verbatimTargetName : targetName, specifier && ts.isStringLiteralLike(specifier) ? ts.factory.createStringLiteral(specifier.text) : undefined); break; - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: serializeMaybeAliasAssignment(symbol); break; - case 216 /* BinaryExpression */: - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 218 /* BinaryExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* 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 @@ -49871,7 +51537,7 @@ var ts; // a visibility error here (as they're not visible within any scope), but we want to hoist them // into the containing scope anyway, so we want to skip the visibility checks. var oldTrack = context.tracker.trackSymbol; - context.tracker.trackSymbol = ts.noop; + context.tracker.trackSymbol = function () { return false; }; if (isExportAssignmentCompatibleSymbolName) { results.push(ts.factory.createExportAssignment( /*decorators*/ undefined, @@ -49950,6 +51616,7 @@ var ts; } function makeSerializePropertySymbol(createProperty, methodKind, useAccessors) { 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 */))) { @@ -49966,7 +51633,7 @@ var ts; } var flag = (modifierFlags & ~256 /* Async */) | (isStatic ? 32 /* Static */ : 0); var name = getPropertyNameNodeForSymbol(p, context); - var firstPropertyLikeDecl = ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isAccessor, ts.isVariableDeclaration, ts.isPropertySignature, ts.isBinaryExpression, ts.isPropertyAccessExpression)); + 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) { var result = []; if (p.flags & 65536 /* SetAccessor */) { @@ -49976,13 +51643,13 @@ var ts; /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "arg", /*questionToken*/ undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled))], - /*body*/ undefined), ts.find(p.declarations, ts.isSetAccessor) || firstPropertyLikeDecl)); + /*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 */; result.push(ts.setTextRange(ts.factory.createGetAccessorDeclaration( /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(flag), name, [], isPrivate_1 ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), - /*body*/ undefined), ts.find(p.declarations, ts.isGetAccessor) || firstPropertyLikeDecl)); + /*body*/ undefined), ((_c = p.declarations) === null || _c === void 0 ? void 0 : _c.find(ts.isGetAccessor)) || firstPropertyLikeDecl)); } return result; } @@ -49993,7 +51660,7 @@ var ts; /*decorators*/ undefined, 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), // TODO: https://github.com/microsoft/TypeScript/pull/32372#discussion_r328386357 // interface members can't have initializers, however class members _can_ - /*initializer*/ undefined), ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isVariableDeclaration)) || firstPropertyLikeDecl); + /*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 */)) { var type = getTypeOfSymbol(p); @@ -50002,7 +51669,7 @@ var ts; return ts.setTextRange(createProperty( /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | flag), name, p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, /*type*/ undefined, - /*initializer*/ undefined), ts.find(p.declarations, ts.isFunctionLikeDeclaration) || signatures[0] && signatures[0].declaration || p.declarations[0]); + /*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]); } var results_1 = []; for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { @@ -50013,7 +51680,8 @@ var ts; questionToken: p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, modifiers: flag ? ts.factory.createModifiersFromModifierFlags(flag) : undefined }); - results_1.push(ts.setTextRange(decl, sig.declaration)); + var location = sig.declaration && ts.isPrototypePropertyAssignment(sig.declaration.parent) ? sig.declaration.parent : sig.declaration; + results_1.push(ts.setTextRange(decl, location)); } return results_1; } @@ -50184,7 +51852,7 @@ var ts; if (flags === void 0) { flags = 16384 /* 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(127 /* 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 /* 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 printer = ts.createPrinter({ removeComments: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); @@ -50229,9 +51897,9 @@ var ts; return "public"; } function getTypeAliasForTypeLiteral(type) { - if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { + if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */ && type.symbol.declarations) { var node = ts.walkUpParenthesizedTypes(type.symbol.declarations[0].parent); - if (node.kind === 254 /* TypeAliasDeclaration */) { + if (node.kind === 256 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -50239,11 +51907,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 257 /* ModuleBlock */ && + node.parent.kind === 259 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 297 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 299 /* SourceFile */ || ts.isAmbientModule(location); } function getNameOfSymbolFromNameType(symbol, context) { var nameType = getSymbolLinks(symbol).nameType; @@ -50302,17 +51970,17 @@ var ts; if (!declaration) { declaration = symbol.declarations[0]; // Declaration may be nameless, but we'll try anyway } - if (declaration.parent && declaration.parent.kind === 249 /* VariableDeclaration */) { + if (declaration.parent && declaration.parent.kind === 251 /* VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } switch (declaration.kind) { - case 221 /* ClassExpression */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 223 /* ClassExpression */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { context.encounteredError = true; } - return declaration.kind === 221 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; + return declaration.kind === 223 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var name = getNameOfSymbolFromNameType(symbol, context); @@ -50329,28 +51997,28 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 324 /* JSDocCallbackTag */: - case 331 /* JSDocTypedefTag */: - case 325 /* JSDocEnumTag */: + case 332 /* JSDocCallbackTag */: + case 339 /* JSDocTypedefTag */: + case 333 /* 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 198 /* BindingElement */: + case 200 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 249 /* VariableDeclaration */: + case 251 /* 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 256 /* ModuleDeclaration */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 251 /* FunctionDeclaration */: - case 255 /* EnumDeclaration */: - case 260 /* ImportEqualsDeclaration */: + case 258 /* ModuleDeclaration */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 253 /* FunctionDeclaration */: + case 257 /* EnumDeclaration */: + case 262 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; @@ -50358,55 +52026,55 @@ var ts; 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 !== 260 /* ImportEqualsDeclaration */ && parent.kind !== 297 /* SourceFile */ && parent.flags & 8388608 /* Ambient */)) { + !(node.kind !== 262 /* ImportEqualsDeclaration */ && parent.kind !== 299 /* SourceFile */ && parent.flags & 8388608 /* Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent); - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: if (ts.hasEffectiveModifier(node, 8 /* Private */ | 16 /* Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so: // falls through - case 166 /* Constructor */: - case 170 /* ConstructSignature */: - case 169 /* CallSignature */: - case 171 /* IndexSignature */: - case 160 /* Parameter */: - case 257 /* ModuleBlock */: - case 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 177 /* TypeLiteral */: - case 173 /* TypeReference */: - case 178 /* ArrayType */: - case 179 /* TupleType */: - case 182 /* UnionType */: - case 183 /* IntersectionType */: - case 186 /* ParenthesizedType */: - case 192 /* NamedTupleMember */: + case 168 /* Constructor */: + case 172 /* ConstructSignature */: + case 171 /* CallSignature */: + case 173 /* IndexSignature */: + case 162 /* Parameter */: + case 259 /* ModuleBlock */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: + case 179 /* TypeLiteral */: + case 175 /* TypeReference */: + case 180 /* ArrayType */: + case 181 /* TupleType */: + case 184 /* UnionType */: + case 185 /* IntersectionType */: + case 188 /* ParenthesizedType */: + case 194 /* 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 262 /* ImportClause */: - case 263 /* NamespaceImport */: - case 265 /* ImportSpecifier */: + case 264 /* ImportClause */: + case 265 /* NamespaceImport */: + case 267 /* ImportSpecifier */: return false; // Type parameters are always visible - case 159 /* TypeParameter */: + case 161 /* TypeParameter */: // Source file and namespace export are always visible // falls through - case 297 /* SourceFile */: - case 259 /* NamespaceExportDeclaration */: + case 299 /* SourceFile */: + case 261 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return false; default: return false; @@ -50415,10 +52083,10 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 266 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 268 /* ExportAssignment */) { exportSymbol = resolveName(node, node.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 270 /* ExportSpecifier */) { + else if (node.parent.kind === 272 /* ExportSpecifier */) { exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } var result; @@ -50523,12 +52191,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 249 /* VariableDeclaration */: - case 250 /* VariableDeclarationList */: - case 265 /* ImportSpecifier */: - case 264 /* NamedImports */: - case 263 /* NamespaceImport */: - case 262 /* ImportClause */: + case 251 /* VariableDeclaration */: + case 252 /* VariableDeclarationList */: + case 267 /* ImportSpecifier */: + case 266 /* NamedImports */: + case 265 /* NamespaceImport */: + case 264 /* ImportClause */: return false; default: return true; @@ -50591,9 +52259,16 @@ var ts; var stringIndexInfo = getIndexInfoOfType(source, 0 /* String */); var numberIndexInfo = getIndexInfoOfType(source, 1 /* Number */); var result = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); - result.objectFlags |= 131072 /* ObjectRestType */; + result.objectFlags |= 8388608 /* ObjectRestType */; return result; } + function isGenericTypeWithUndefinedConstraint(type) { + return !!(type.flags & 465829888 /* Instantiable */) && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 32768 /* 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 */); + } // Determine the control flow type associated with a destructuring declaration or assignment. The following // forms of destructuring are possible: // let { x } = obj; // BindingElement @@ -50628,23 +52303,23 @@ var ts; function getParentElementAccess(node) { var ancestor = node.parent.parent; switch (ancestor.kind) { - case 198 /* BindingElement */: - case 288 /* PropertyAssignment */: + case 200 /* BindingElement */: + case 290 /* PropertyAssignment */: return getSyntheticElementAccess(ancestor); - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return getSyntheticElementAccess(node.parent); - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return ancestor.initializer; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return ancestor.right; } } function getDestructuringPropertyName(node) { var parent = node.parent; - if (node.kind === 198 /* BindingElement */ && parent.kind === 196 /* ObjectBindingPattern */) { + if (node.kind === 200 /* BindingElement */ && parent.kind === 198 /* ObjectBindingPattern */) { return getLiteralPropertyNameText(node.propertyName || node.name); } - if (node.kind === 288 /* PropertyAssignment */ || node.kind === 289 /* ShorthandPropertyAssignment */) { + if (node.kind === 290 /* PropertyAssignment */ || node.kind === 291 /* ShorthandPropertyAssignment */) { return getLiteralPropertyNameText(node.name); } return "" + parent.elements.indexOf(node); @@ -50670,7 +52345,7 @@ var ts; parentType = getTypeWithFacts(parentType, 524288 /* NEUndefined */); } var type; - if (pattern.kind === 196 /* ObjectBindingPattern */) { + if (pattern.kind === 198 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { parentType = getReducedType(parentType); if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { @@ -50690,7 +52365,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 = getConstraintForLocation(getIndexedAccessType(parentType, indexType, /*noUncheckedIndexedAccessCandidate*/ undefined, name, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, 16 /* ExpressionPosition */), declaration.name); + var declaredType = getIndexedAccessType(parentType, indexType, 32 /* ExpressionPosition */, name); type = getFlowTypeOfDestructuring(declaration, declaredType); } } @@ -50710,8 +52385,8 @@ var ts; } else if (isArrayLikeType(parentType)) { var indexType = getLiteralType(index_2); - var accessFlags = hasDefaultValue(declaration) ? 8 /* NoTupleBoundsCheck */ : 0; - var declaredType = getConstraintForLocation(getIndexedAccessTypeOrUndefined(parentType, indexType, /*noUncheckedIndexedAccessCandidate*/ undefined, declaration.name, accessFlags | 16 /* ExpressionPosition */) || errorType, declaration.name); + var accessFlags = 32 /* ExpressionPosition */ | (hasDefaultValue(declaration) ? 16 /* NoTupleBoundsCheck */ : 0); + var declaredType = getIndexedAccessTypeOrUndefined(parentType, indexType, accessFlags, declaration.name) || errorType; type = getFlowTypeOfDestructuring(declaration, declaredType); } else { @@ -50724,11 +52399,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 && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 32768 /* Undefined */) ? - getTypeWithFacts(type, 524288 /* NEUndefined */) : - type; + return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 32768 /* Undefined */) ? getNonUndefinedType(type) : type; } - return widenTypeInferredFromInitializer(declaration, getUnionType([getTypeWithFacts(type, 524288 /* NEUndefined */), checkDeclarationInitializer(declaration)], 2 /* Subtype */)); + return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration)], 2 /* Subtype */)); } function getTypeForDeclarationFromJSDocComment(declaration) { var jsdocType = ts.getJSDocType(declaration); @@ -50739,25 +52412,26 @@ var ts; } function isNullOrUndefined(node) { var expr = ts.skipParentheses(node); - return expr.kind === 103 /* NullKeyword */ || expr.kind === 78 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; + return expr.kind === 104 /* NullKeyword */ || expr.kind === 79 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 199 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 201 /* ArrayLiteralExpression */ && expr.elements.length === 0; } - function addOptionality(type, optional) { - if (optional === void 0) { optional = true; } - return strictNullChecks && optional ? getOptionalType(type) : type; + function addOptionality(type, isProperty, isOptional) { + if (isProperty === void 0) { isProperty = false; } + if (isOptional === void 0) { isOptional = true; } + return strictNullChecks && isOptional ? getOptionalType(type, isProperty) : type; } // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { // 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 === 238 /* ForInStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 240 /* ForInStatement */) { var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression))); return indexType.flags & (262144 /* TypeParameter */ | 4194304 /* Index */) ? getExtractStringType(indexType) : stringType; } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 239 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 241 /* 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, @@ -50768,13 +52442,14 @@ var ts; if (ts.isBindingPattern(declaration.parent)) { return getTypeForBindingElement(declaration); } - var isOptional = includeOptionality && (ts.isParameter(declaration) && isJSDocOptionalParameter(declaration) - || isOptionalJSDocPropertyLikeTag(declaration) - || !ts.isBindingElement(declaration) && !ts.isVariableDeclaration(declaration) && !!declaration.questionToken); + var isProperty = ts.isPropertyDeclaration(declaration) || ts.isPropertySignature(declaration); + var isOptional = includeOptionality && (isProperty && !!declaration.questionToken || + ts.isParameter(declaration) && (!!declaration.questionToken || isJSDocOptionalParameter(declaration)) || + isOptionalJSDocPropertyLikeTag(declaration)); // Use type from type annotation if one is present var declaredType = tryGetTypeFromEffectiveTypeNode(declaration); if (declaredType) { - return addOptionality(declaredType, isOptional); + return addOptionality(declaredType, isProperty, isOptional); } if ((noImplicitAny || ts.isInJSFile(declaration)) && ts.isVariableDeclaration(declaration) && !ts.isBindingPattern(declaration.name) && @@ -50794,8 +52469,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 === 168 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 167 /* GetAccessor */); + if (func.kind === 170 /* SetAccessor */ && hasBindableName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 169 /* GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -50818,7 +52493,7 @@ var ts; // Use contextual parameter type if one is available var type = declaration.symbol.escapedName === "this" /* This */ ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration); if (type) { - return addOptionality(type, isOptional); + return addOptionality(type, /*isProperty*/ false, isOptional); } } // Use the type of the initializer expression if one is present and the declaration is @@ -50831,7 +52506,7 @@ var ts; } } var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration)); - return addOptionality(type, isOptional); + return addOptionality(type, isProperty, isOptional); } if (ts.isPropertyDeclaration(declaration) && !ts.hasStaticModifier(declaration) && (noImplicitAny || ts.isInJSFile(declaration))) { // We have a property declaration with no type annotation or initializer, in noImplicitAny mode or a .js file. @@ -50840,7 +52515,7 @@ var ts; var type = constructor ? getFlowTypeInConstructor(declaration.symbol, constructor) : ts.getEffectiveModifierFlags(declaration) & 2 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : undefined; - return type && addOptionality(type, isOptional); + return type && addOptionality(type, /*isProperty*/ true, isOptional); } if (ts.isJsxAttribute(declaration)) { // if JSX attribute doesn't have initializer, by default the attribute will have boolean value of true. @@ -50866,7 +52541,7 @@ var ts; links.isConstructorDeclaredProperty = !!getDeclaringConstructor(symbol) && ts.every(symbol.declarations, function (declaration) { return ts.isBinaryExpression(declaration) && isPossiblyAliasedThisProperty(declaration) && - (declaration.left.kind !== 202 /* ElementAccessExpression */ || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) && + (declaration.left.kind !== 204 /* ElementAccessExpression */ || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) && !getAnnotatedTypeForAssignmentDeclaration(/*declaredType*/ undefined, declaration, symbol, declaration); }); } @@ -50882,13 +52557,33 @@ var ts; !declaration.initializer && (noImplicitAny || ts.isInJSFile(declaration)); } function getDeclaringConstructor(symbol) { + if (!symbol.declarations) { + return; + } 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 === 166 /* Constructor */ || isJSConstructor(container))) { + if (container && (container.kind === 168 /* Constructor */ || isJSConstructor(container))) { return container; } } + ; + } + /** Create a synthetic property access flow node after the last statement of the file */ + function getFlowTypeFromCommonJSExport(symbol) { + var file = ts.getSourceFileOfNode(symbol.declarations[0]); + var accessName = ts.unescapeLeadingUnderscores(symbol.escapedName); + var areAllModuleExports = symbol.declarations.every(function (d) { return ts.isInJSFile(d) && ts.isAccessExpression(d) && ts.isModuleExportsAccessExpression(d.expression); }); + var reference = areAllModuleExports + ? ts.factory.createPropertyAccessExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("module"), ts.factory.createIdentifier("exports")), accessName) + : ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("exports"), accessName); + if (areAllModuleExports) { + ts.setParent(reference.expression.expression, reference.expression); + } + ts.setParent(reference.expression, reference); + ts.setParent(reference, file); + reference.flowNode = file.endFlowNode; + return getFlowTypeOfReference(reference, autoType, undefinedType); } function getFlowTypeInConstructor(symbol, constructor) { var accessName = ts.startsWith(symbol.escapedName, "__#") @@ -50906,7 +52601,10 @@ var ts; return everyType(flowType, isNullableType) ? undefined : convertAutoToAny(flowType); } function getFlowTypeOfProperty(reference, prop) { - var initialType = prop && (!isAutoTypedProperty(prop) || ts.getEffectiveModifierFlags(prop.valueDeclaration) & 2 /* Ambient */) && getTypeOfPropertyInBaseClass(prop) || undefinedType; + var initialType = (prop === null || prop === void 0 ? void 0 : prop.valueDeclaration) + && (!isAutoTypedProperty(prop) || ts.getEffectiveModifierFlags(prop.valueDeclaration) & 2 /* Ambient */) + && getTypeOfPropertyInBaseClass(prop) + || undefinedType; return getFlowTypeOfReference(reference, autoType, initialType); } function getWidenedTypeForAssignmentDeclaration(symbol, resolvedSymbol) { @@ -50917,7 +52615,7 @@ var ts; if (tag && tag.typeExpression) { return getTypeFromTypeNode(tag.typeExpression); } - var containerObjectType = getJSContainerObjectType(symbol.valueDeclaration, symbol, container); + var containerObjectType = symbol.valueDeclaration && getJSContainerObjectType(symbol.valueDeclaration, symbol, container); return containerObjectType || getWidenedLiteralType(checkExpressionCached(container)); } var type; @@ -50929,40 +52627,42 @@ var ts; type = getFlowTypeInConstructor(symbol, getDeclaringConstructor(symbol)); } if (!type) { - var jsdocType = void 0; var types = void 0; - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration : - ts.isAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : - undefined; - if (!expression) { - continue; // Non-assignment declaration merged in (eg, an Identifier to mark the thing as a namespace) - skip over it and pull type info from elsewhere - } - var kind = ts.isAccessExpression(expression) - ? ts.getAssignmentDeclarationPropertyAccessKind(expression) - : ts.getAssignmentDeclarationKind(expression); - if (kind === 4 /* ThisProperty */ || ts.isBinaryExpression(expression) && isPossiblyAliasedThisProperty(expression, kind)) { - if (isDeclarationInConstructor(expression)) { - definedInConstructor = true; + if (symbol.declarations) { + var jsdocType = void 0; + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration : + ts.isAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : + undefined; + if (!expression) { + continue; // Non-assignment declaration merged in (eg, an Identifier to mark the thing as a namespace) - skip over it and pull type info from elsewhere + } + var kind = ts.isAccessExpression(expression) + ? ts.getAssignmentDeclarationPropertyAccessKind(expression) + : ts.getAssignmentDeclarationKind(expression); + if (kind === 4 /* ThisProperty */ || ts.isBinaryExpression(expression) && isPossiblyAliasedThisProperty(expression, kind)) { + if (isDeclarationInConstructor(expression)) { + definedInConstructor = true; + } + else { + definedInMethod = true; + } } - else { - definedInMethod = true; + if (!ts.isCallExpression(expression)) { + jsdocType = getAnnotatedTypeForAssignmentDeclaration(jsdocType, expression, symbol, declaration); + } + if (!jsdocType) { + (types || (types = [])).push((ts.isBinaryExpression(expression) || ts.isCallExpression(expression)) ? getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) : neverType); } } - if (!ts.isCallExpression(expression)) { - jsdocType = getAnnotatedTypeForAssignmentDeclaration(jsdocType, expression, symbol, declaration); - } - if (!jsdocType) { - (types || (types = [])).push((ts.isBinaryExpression(expression) || ts.isCallExpression(expression)) ? getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) : neverType); - } + type = jsdocType; } - type = jsdocType; if (!type) { if (!ts.length(types)) { return errorType; // No types from any declarations :( } - var constructorTypes = definedInConstructor ? getConstructorDefinedThisAssignmentTypes(types, symbol.declarations) : undefined; + var constructorTypes = definedInConstructor && symbol.declarations ? getConstructorDefinedThisAssignmentTypes(types, symbol.declarations) : undefined; // use only the constructor types unless they were only assigned null | undefined (including widening variants) if (definedInMethod) { var propType = getTypeOfPropertyInBaseClass(symbol); @@ -50975,8 +52675,8 @@ var ts; type = getUnionType(sourceTypes, 2 /* Subtype */); } } - var widened = getWidenedType(addOptionality(type, definedInMethod && !definedInConstructor)); - if (filterType(widened, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) === neverType) { + var widened = getWidenedType(addOptionality(type, /*isProperty*/ false, definedInMethod && !definedInConstructor)); + if (symbol.valueDeclaration && filterType(widened, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) === neverType) { reportImplicitAny(symbol.valueDeclaration, anyType); return anyType; } @@ -51000,10 +52700,11 @@ var ts; mergeSymbolTable(exports, s.exports); } var type = createAnonymousType(symbol, exports, ts.emptyArray, ts.emptyArray, undefined, undefined); - type.objectFlags |= 16384 /* JSLiteral */; + type.objectFlags |= 8192 /* JSLiteral */; return type; } function getAnnotatedTypeForAssignmentDeclaration(declaredType, expression, symbol, declaration) { + var _a; var typeNode = ts.getEffectiveTypeAnnotationNode(expression.parent); if (typeNode) { var type = getWidenedType(getTypeFromTypeNode(typeNode)); @@ -51014,10 +52715,13 @@ var ts; errorNextVariableOrPropertyDeclarationMustHaveSameType(/*firstDeclaration*/ undefined, declaredType, declaration, type); } } - if (symbol.parent) { + if ((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.valueDeclaration) { var typeNode_2 = ts.getEffectiveTypeAnnotationNode(symbol.parent.valueDeclaration); if (typeNode_2) { - return getTypeOfPropertyOfType(getTypeFromTypeNode(typeNode_2), symbol.escapedName); + var annotationSymbol = getPropertyOfType(getTypeFromTypeNode(typeNode_2), symbol.escapedName); + if (annotationSymbol) { + return getNonMissingTypeOfSymbol(annotationSymbol); + } } } return declaredType; @@ -51078,7 +52782,7 @@ var ts; // but we may have a JS file with `module.exports = { a: true }` along with a TypeScript module augmentation // declaring an `export const a: number`. In that case, we issue a duplicate identifier error, because // it's unclear what that's supposed to mean, so it's probably a mistake. - if (ts.getSourceFileOfNode(s.valueDeclaration) !== ts.getSourceFileOfNode(exportedMember.valueDeclaration)) { + if (s.valueDeclaration && exportedMember.valueDeclaration && ts.getSourceFileOfNode(s.valueDeclaration) !== ts.getSourceFileOfNode(exportedMember.valueDeclaration)) { var unescapedName = ts.unescapeLeadingUnderscores(s.escapedName); var exportedMemberName = ((_a = ts.tryCast(exportedMember.valueDeclaration, ts.isNamedDeclaration)) === null || _a === void 0 ? void 0 : _a.name) || exportedMember.valueDeclaration; ts.addRelatedInfo(error(s.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0, unescapedName), ts.createDiagnosticForNode(exportedMemberName, ts.Diagnostics._0_was_also_declared_here, unescapedName)); @@ -51100,9 +52804,9 @@ var ts; }); var result = createAnonymousType(initialSize !== members_4.size ? undefined : exportedType.symbol, // Only set the type's symbol if it looks to be the same as the original type members_4, exportedType.callSignatures, exportedType.constructSignatures, exportedType.stringIndexInfo, exportedType.numberIndexInfo); - result.objectFlags |= (ts.getObjectFlags(type) & 16384 /* JSLiteral */); // Propagate JSLiteral flag + result.objectFlags |= (ts.getObjectFlags(type) & 8192 /* JSLiteral */); // Propagate JSLiteral flag if (result.symbol && result.symbol.flags & 32 /* Class */ && type === getDeclaredTypeOfClassOrInterface(result.symbol)) { - result.objectFlags |= 1073741824 /* IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type + result.objectFlags |= 16777216 /* IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type } return result; } @@ -51114,16 +52818,16 @@ var ts; } function containsSameNamedThisProperty(thisProperty, expression) { return ts.isPropertyAccessExpression(thisProperty) - && thisProperty.expression.kind === 107 /* ThisKeyword */ + && thisProperty.expression.kind === 108 /* 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 === 166 /* Constructor */ || - thisContainer.kind === 251 /* FunctionDeclaration */ || - (thisContainer.kind === 208 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + return thisContainer.kind === 168 /* Constructor */ || + thisContainer.kind === 253 /* FunctionDeclaration */ || + (thisContainer.kind === 210 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); } function getConstructorDefinedThisAssignmentTypes(types, declarations) { ts.Debug.assert(types.length === declarations.length); @@ -51161,7 +52865,7 @@ var ts; function getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) { var members = ts.createSymbolTable(); var stringIndexInfo; - var objectFlags = 128 /* ObjectLiteral */ | 1048576 /* ContainsObjectOrArrayLiteral */; + var objectFlags = 128 /* ObjectLiteral */ | 262144 /* ContainsObjectOrArrayLiteral */; ts.forEach(pattern.elements, function (e) { var name = e.propertyName || e.name; if (e.dotDotDotToken) { @@ -51185,7 +52889,7 @@ var ts; result.objectFlags |= objectFlags; if (includePatternInType) { result.pattern = pattern; - result.objectFlags |= 1048576 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= 262144 /* ContainsObjectOrArrayLiteral */; } return result; } @@ -51193,7 +52897,7 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - var restElement = lastElement && lastElement.kind === 198 /* BindingElement */ && lastElement.dotDotDotToken ? lastElement : undefined; + var restElement = lastElement && lastElement.kind === 200 /* BindingElement */ && lastElement.dotDotDotToken ? lastElement : undefined; if (elements.length === 0 || elements.length === 1 && restElement) { return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; } @@ -51204,7 +52908,7 @@ var ts; if (includePatternInType) { result = cloneTypeReference(result); result.pattern = pattern; - result.objectFlags |= 1048576 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= 262144 /* ContainsObjectOrArrayLiteral */; } return result; } @@ -51218,7 +52922,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 196 /* ObjectBindingPattern */ + return pattern.kind === 198 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -51234,8 +52938,17 @@ var ts; function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) { return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true), declaration, reportErrors); } + function isGlobalSymbolConstructor(node) { + var symbol = getSymbolOfNode(node); + var globalSymbol = getGlobalESSymbolConstructorTypeSymbol(/*reportErrors*/ false); + return globalSymbol && symbol && symbol === globalSymbol; + } 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)) { + type = getESSymbolLikeTypeForNode(declaration); + } if (reportErrors) { reportErrorsFromWidening(declaration, type); } @@ -51257,7 +52970,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 160 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 162 /* Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(declaration) { @@ -51288,19 +53001,31 @@ var ts; if (symbol === requireSymbol) { return anyType; } - if (symbol.flags & 134217728 /* ModuleExports */) { + if (symbol.flags & 134217728 /* ModuleExports */ && symbol.valueDeclaration) { var fileSymbol = getSymbolOfNode(ts.getSourceFileOfNode(symbol.valueDeclaration)); + var result = createSymbol(fileSymbol.flags, "exports"); + result.declarations = fileSymbol.declarations ? fileSymbol.declarations.slice() : []; + result.parent = symbol; + result.target = fileSymbol; + if (fileSymbol.valueDeclaration) + result.valueDeclaration = fileSymbol.valueDeclaration; + if (fileSymbol.members) + result.members = new ts.Map(fileSymbol.members); + if (fileSymbol.exports) + result.exports = new ts.Map(fileSymbol.exports); var members = ts.createSymbolTable(); - members.set("exports", fileSymbol); + members.set("exports", result); return createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, undefined, undefined); } // Handle catch clause variables + ts.Debug.assertIsDefined(symbol.valueDeclaration); var declaration = symbol.valueDeclaration; if (ts.isCatchClauseVariableDeclarationOrBindingElement(declaration)) { - var decl = declaration; - if (!decl.type) - return anyType; - var type_1 = getTypeOfNode(decl.type); + var typeNode = ts.getEffectiveTypeAnnotationNode(declaration); + if (typeNode === undefined) { + return useUnknownInCatchVariables ? unknownType : anyType; + } + var type_1 = getTypeOfNode(typeNode); // an errorType will make `checkTryStatement` issue an error return isTypeAny(type_1) || type_1 === unknownType ? type_1 : errorType; } @@ -51320,7 +53045,7 @@ var ts; return reportCircularityError(symbol); } var type; - if (declaration.kind === 266 /* ExportAssignment */) { + if (declaration.kind === 268 /* ExportAssignment */) { type = widenTypeForVariableLikeDeclaration(checkExpressionCached(declaration.expression), declaration); } else if (ts.isBinaryExpression(declaration) || @@ -51375,7 +53100,7 @@ var ts; type = getTypeOfEnumMember(symbol); } else if (ts.isAccessor(declaration)) { - type = resolveTypeOfAccessors(symbol); + type = resolveTypeOfAccessors(symbol) || ts.Debug.fail("Non-write accessor resolution must always produce a type"); } else { return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.formatSyntaxKind(declaration.kind) + " for " + ts.Debug.formatSymbol(symbol)); @@ -51391,7 +53116,7 @@ var ts; } function getAnnotatedAccessorTypeNode(accessor) { if (accessor) { - if (accessor.kind === 167 /* GetAccessor */) { + if (accessor.kind === 169 /* GetAccessor */) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation; } @@ -51415,63 +53140,78 @@ var ts; } function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); - return links.type || (links.type = getTypeOfAccessorsWorker(symbol)); + return links.type || (links.type = getTypeOfAccessorsWorker(symbol) || ts.Debug.fail("Read type of accessor must always produce a type")); + } + function getTypeOfSetAccessor(symbol) { + var links = getSymbolLinks(symbol); + return links.writeType || (links.writeType = getTypeOfAccessorsWorker(symbol, /*writing*/ true)); } - function getTypeOfAccessorsWorker(symbol) { + function getTypeOfAccessorsWorker(symbol, writing) { + if (writing === void 0) { writing = false; } if (!pushTypeResolution(symbol, 0 /* Type */)) { return errorType; } - var type = resolveTypeOfAccessors(symbol); + var type = resolveTypeOfAccessors(symbol, writing); if (!popTypeResolution()) { type = anyType; if (noImplicitAny) { - var getter = ts.getDeclarationOfKind(symbol, 167 /* GetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 169 /* GetAccessor */); error(getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } return type; } - function resolveTypeOfAccessors(symbol) { - var getter = ts.getDeclarationOfKind(symbol, 167 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 168 /* SetAccessor */); + function resolveTypeOfAccessors(symbol, writing) { + if (writing === void 0) { writing = false; } + var getter = ts.getDeclarationOfKind(symbol, 169 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 170 /* SetAccessor */); + var setterType = getAnnotatedAccessorType(setter); + // For write operations, prioritize type annotations on the setter + if (writing && setterType) { + return instantiateTypeIfNeeded(setterType, symbol); + } + // Else defer to the getter type if (getter && ts.isInJSFile(getter)) { var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { - return jsDocType; + return instantiateTypeIfNeeded(jsDocType, symbol); } } - // First try to see if the user specified a return type on the get-accessor. - var getterReturnType = getAnnotatedAccessorType(getter); - if (getterReturnType) { - return getterReturnType; + // Try to see if the user specified a return type on the get-accessor. + var getterType = getAnnotatedAccessorType(getter); + if (getterType) { + return instantiateTypeIfNeeded(getterType, symbol); } - else { - // If the user didn't specify a return type, try to use the set-accessor's parameter type. - var setterParameterType = getAnnotatedAccessorType(setter); - if (setterParameterType) { - return setterParameterType; + // If the user didn't specify a return type, try to use the set-accessor's parameter type. + if (setterType) { + return setterType; + } + // If there are no specified types, try to infer it from the body of the get accessor if it exists. + if (getter && getter.body) { + var returnTypeFromBody = getReturnTypeFromBody(getter); + return instantiateTypeIfNeeded(returnTypeFromBody, symbol); + } + // Otherwise, fall back to 'any'. + if (setter) { + if (!isPrivateWithinAmbient(setter)) { + errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol)); } - else { - // If there are no specified types, try to infer it from the body of the get accessor if it exists. - if (getter && getter.body) { - return getReturnTypeFromBody(getter); - } - // Otherwise, fall back to 'any'. - else { - if (setter) { - if (!isPrivateWithinAmbient(setter)) { - errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol)); - } - } - else { - ts.Debug.assert(!!getter, "there must exist a getter as we are current checking either setter or getter in this function"); - if (!isPrivateWithinAmbient(getter)) { - errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol)); - } - } - return anyType; - } + return anyType; + } + else if (getter) { + ts.Debug.assert(!!getter, "there must exist a getter as we are current checking either setter or getter in this function"); + if (!isPrivateWithinAmbient(getter)) { + errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol)); } + return anyType; + } + return undefined; + function instantiateTypeIfNeeded(type, symbol) { + if (ts.getCheckFlags(symbol) & 1 /* Instantiated */) { + var links = getSymbolLinks(symbol); + return instantiateType(type, links.mapper); + } + return type; } } function getBaseTypeVariableOfClass(symbol) { @@ -51501,9 +53241,9 @@ var ts; if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { return anyType; } - else if (declaration && (declaration.kind === 216 /* BinaryExpression */ || + else if (declaration && (declaration.kind === 218 /* BinaryExpression */ || ts.isAccessExpression(declaration) && - declaration.parent.kind === 216 /* BinaryExpression */)) { + declaration.parent.kind === 218 /* BinaryExpression */)) { return getWidenedTypeForAssignmentDeclaration(symbol); } else if (symbol.flags & 512 /* ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { @@ -51537,14 +53277,16 @@ var ts; var links = getSymbolLinks(symbol); if (!links.type) { var targetSymbol = resolveAlias(symbol); + var exportSymbol = symbol.declarations && getTargetOfAliasDeclaration(getDeclarationOfAliasSymbol(symbol), /*dontResolveAlias*/ true); // It only makes sense to get the type of a value symbol. If the result of resolving // the alias is not a value, then it has no type. To get the type associated with a // type symbol, call getDeclaredTypeOfSymbol. // This check is important because without it, a call to getTypeOfSymbol could end // up recursively calling getTypeOfAlias, causing a stack overflow. - links.type = targetSymbol.flags & 111551 /* Value */ - ? getTypeOfSymbol(targetSymbol) - : errorType; + links.type = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.declarations) && isDuplicatedCommonJSExport(exportSymbol.declarations) && symbol.declarations.length ? getFlowTypeFromCommonJSExport(exportSymbol) + : isDuplicatedCommonJSExport(symbol.declarations) ? autoType + : targetSymbol.flags & 111551 /* Value */ ? getTypeOfSymbol(targetSymbol) + : errorType; } return links.type; } @@ -51570,7 +53312,7 @@ var ts; return errorType; } // Check if variable has initializer that circularly references the variable itself - if (noImplicitAny && (declaration.kind !== 160 /* Parameter */ || declaration.initializer)) { + if (noImplicitAny && (declaration.kind !== 162 /* 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 @@ -51587,6 +53329,15 @@ var ts; } return links.type; } + function getSetAccessorTypeOfSymbol(symbol) { + if (symbol.flags & 98304 /* Accessor */) { + var type = getTypeOfSetAccessor(symbol); + if (type) { + return type; + } + } + return getTypeOfSymbol(symbol); + } function getTypeOfSymbol(symbol) { var checkFlags = ts.getCheckFlags(symbol); if (checkFlags & 65536 /* DeferredType */) { @@ -51618,6 +53369,9 @@ var ts; } return errorType; } + function getNonMissingTypeOfSymbol(symbol) { + return removeMissingType(getTypeOfSymbol(symbol), !!(symbol.flags & 16777216 /* Optional */)); + } function isReferenceToType(type, target) { return type !== undefined && target !== undefined @@ -51669,66 +53423,72 @@ var ts; return undefined; } switch (node.kind) { - case 232 /* VariableStatement */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 164 /* MethodSignature */: - case 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 308 /* JSDocFunctionType */: - case 251 /* FunctionDeclaration */: - case 165 /* MethodDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 254 /* TypeAliasDeclaration */: - case 330 /* JSDocTemplateTag */: - case 331 /* JSDocTypedefTag */: - case 325 /* JSDocEnumTag */: - case 324 /* JSDocCallbackTag */: - case 190 /* MappedType */: - case 184 /* ConditionalType */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 255 /* InterfaceDeclaration */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 166 /* MethodSignature */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: + case 311 /* JSDocFunctionType */: + case 253 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 256 /* TypeAliasDeclaration */: + case 338 /* JSDocTemplateTag */: + case 339 /* JSDocTypedefTag */: + case 333 /* JSDocEnumTag */: + case 332 /* JSDocCallbackTag */: + case 192 /* MappedType */: + case 186 /* ConditionalType */: { var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 190 /* MappedType */) { + if (node.kind === 192 /* MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 184 /* ConditionalType */) { + else if (node.kind === 186 /* ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } - else if (node.kind === 232 /* VariableStatement */ && !ts.isInJSFile(node)) { - break; - } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 252 /* ClassDeclaration */ || node.kind === 221 /* ClassExpression */ || node.kind === 253 /* InterfaceDeclaration */ || isJSConstructor(node)) && + (node.kind === 254 /* ClassDeclaration */ || node.kind === 223 /* ClassExpression */ || node.kind === 255 /* InterfaceDeclaration */ || isJSConstructor(node)) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; - case 326 /* JSDocParameterTag */: + } + case 334 /* JSDocParameterTag */: var paramSymbol = ts.getParameterSymbolFromJSDoc(node); if (paramSymbol) { node = paramSymbol.valueDeclaration; } break; + case 314 /* JSDocComment */: { + var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); + return node.tags + ? appendTypeParameters(outerTypeParameters, ts.flatMap(node.tags, function (t) { return ts.isJSDocTemplateTag(t) ? t.typeParameters : undefined; })) + : outerTypeParameters; + } } } } // 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, 253 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 255 /* InterfaceDeclaration */); ts.Debug.assert(!!declaration, "Class was missing valueDeclaration -OR- non-class had no interface declarations"); return getOuterTypeParameters(declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, // interface, or type alias. function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { + if (!symbol.declarations) { + return; + } var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 253 /* InterfaceDeclaration */ || - node.kind === 252 /* ClassDeclaration */ || - node.kind === 221 /* ClassExpression */ || + if (node.kind === 255 /* InterfaceDeclaration */ || + node.kind === 254 /* ClassDeclaration */ || + node.kind === 223 /* ClassExpression */ || isJSConstructor(node) || ts.isTypeAlias(node)) { var declaration = node; @@ -51822,7 +53582,9 @@ var ts; ctorReturn = getReturnTypeOfSignature(ctorSig[0]); } } - ts.addRelatedInfo(err, ts.createDiagnosticForNode(baseConstructorType.symbol.declarations[0], ts.Diagnostics.Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1, symbolToString(baseConstructorType.symbol), typeToString(ctorReturn))); + if (baseConstructorType.symbol.declarations) { + ts.addRelatedInfo(err, ts.createDiagnosticForNode(baseConstructorType.symbol.declarations[0], ts.Diagnostics.Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1, symbolToString(baseConstructorType.symbol), typeToString(ctorReturn))); + } } return type.resolvedBaseConstructorType = errorType; } @@ -51832,20 +53594,22 @@ var ts; } function getImplementsTypes(type) { var resolvedImplementsTypes = ts.emptyArray; - for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - var implementsTypeNodes = ts.getEffectiveImplementsTypeNodes(declaration); - if (!implementsTypeNodes) - continue; - for (var _b = 0, implementsTypeNodes_1 = implementsTypeNodes; _b < implementsTypeNodes_1.length; _b++) { - var node = implementsTypeNodes_1[_b]; - var implementsType = getTypeFromTypeNode(node); - if (implementsType !== errorType) { - if (resolvedImplementsTypes === ts.emptyArray) { - resolvedImplementsTypes = [implementsType]; - } - else { - resolvedImplementsTypes.push(implementsType); + if (type.symbol.declarations) { + for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + var implementsTypeNodes = ts.getEffectiveImplementsTypeNodes(declaration); + if (!implementsTypeNodes) + continue; + for (var _b = 0, implementsTypeNodes_1 = implementsTypeNodes; _b < implementsTypeNodes_1.length; _b++) { + var node = implementsTypeNodes_1[_b]; + var implementsType = getTypeFromTypeNode(node); + if (implementsType !== errorType) { + if (resolvedImplementsTypes === ts.emptyArray) { + resolvedImplementsTypes = [implementsType]; + } + else { + resolvedImplementsTypes.push(implementsType); + } } } } @@ -51872,10 +53636,10 @@ var ts; else { ts.Debug.fail("type must be class or interface"); } - if (!popTypeResolution()) { + if (!popTypeResolution() && type.symbol.declarations) { for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 252 /* ClassDeclaration */ || declaration.kind === 253 /* InterfaceDeclaration */) { + if (declaration.kind === 254 /* ClassDeclaration */ || declaration.kind === 255 /* InterfaceDeclaration */) { reportCircularBaseType(declaration, type); } } @@ -51968,29 +53732,31 @@ var ts; } function resolveBaseTypesOfInterface(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray; - for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 253 /* 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)); - if (baseType !== errorType) { - if (isValidBaseType(baseType)) { - if (type !== baseType && !hasBaseType(baseType, type)) { - if (type.resolvedBaseTypes === ts.emptyArray) { - type.resolvedBaseTypes = [baseType]; + if (type.symbol.declarations) { + for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 255 /* 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)); + if (baseType !== errorType) { + if (isValidBaseType(baseType)) { + if (type !== baseType && !hasBaseType(baseType, type)) { + if (type.resolvedBaseTypes === ts.emptyArray) { + type.resolvedBaseTypes = [baseType]; + } + else { + type.resolvedBaseTypes.push(baseType); + } } else { - type.resolvedBaseTypes.push(baseType); + reportCircularBaseType(declaration, type); } } else { - reportCircularBaseType(declaration, type); + error(node, ts.Diagnostics.An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_members); } } - else { - error(node, ts.Diagnostics.An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_members); - } } } } @@ -52004,9 +53770,12 @@ var ts; * and if none of the base interfaces have a "this" type. */ function isThislessInterface(symbol) { + if (!symbol.declarations) { + return true; + } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 253 /* InterfaceDeclaration */) { + if (declaration.kind === 255 /* InterfaceDeclaration */) { if (declaration.flags & 128 /* ContainsThis */) { return false; } @@ -52031,7 +53800,7 @@ var ts; var originalLinks = links; if (!links.declaredType) { var kind = symbol.flags & 32 /* Class */ ? 1 /* Class */ : 2 /* Interface */; - var merged = mergeJSSymbols(symbol, getAssignedClassSymbol(symbol.valueDeclaration)); + var merged = mergeJSSymbols(symbol, symbol.valueDeclaration && getAssignedClassSymbol(symbol.valueDeclaration)); if (merged) { // note:we overwrite links because we just cloned the symbol symbol = links = merged; @@ -52061,6 +53830,7 @@ var ts; return links.declaredType; } function getDeclaredTypeOfTypeAlias(symbol) { + var _a; var links = getSymbolLinks(symbol); if (!links.declaredType) { // Note that we use the links object as the target here because the symbol object is used as the unique @@ -52068,7 +53838,7 @@ var ts; if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { return errorType; } - var declaration = ts.Debug.checkDefined(ts.find(symbol.declarations, ts.isTypeAlias), "Type alias symbol with no valid declaration found"); + 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"); var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type; // If typeNode is missing, we will error in checkJSDocTypedefTag. var type = typeNode ? getTypeFromTypeNode(typeNode) : errorType; @@ -52084,7 +53854,12 @@ var ts; } else { type = errorType; - error(ts.isNamedDeclaration(declaration) ? declaration.name : declaration || declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); + if (declaration.kind === 333 /* 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)); + } } links.declaredType = type; } @@ -52094,7 +53869,7 @@ var ts; if (ts.isStringLiteralLike(expr)) { return true; } - else if (expr.kind === 216 /* BinaryExpression */) { + else if (expr.kind === 218 /* BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -52109,12 +53884,12 @@ var ts; case 8 /* NumericLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return true; - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return expr.operator === 40 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; - case 78 /* Identifier */: + case 79 /* Identifier */: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -52126,16 +53901,18 @@ var ts; return links.enumKind; } var hasNonLiteralMember = false; - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 255 /* 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 */; - } - if (!isLiteralEnumMember(member)) { - hasNonLiteralMember = true; + if (symbol.declarations) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 257 /* 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 */; + } + if (!isLiteralEnumMember(member)) { + hasNonLiteralMember = true; + } } } } @@ -52153,15 +53930,17 @@ var ts; if (getEnumKind(symbol) === 1 /* Literal */) { enumCount++; var memberTypeList = []; - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 255 /* EnumDeclaration */) { - for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { - var member = _c[_b]; - var value = getEnumMemberValue(member); - var memberType = getFreshTypeOfLiteralType(getLiteralType(value !== undefined ? value : 0, enumCount, getSymbolOfNode(member))); - getSymbolLinks(getSymbolOfNode(member)).declaredType = memberType; - memberTypeList.push(getRegularTypeOfLiteralType(memberType)); + if (symbol.declarations) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 257 /* EnumDeclaration */) { + for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { + var member = _c[_b]; + var value = getEnumMemberValue(member); + var memberType = getFreshTypeOfLiteralType(getLiteralType(value !== undefined ? value : 0, enumCount, getSymbolOfNode(member))); + getSymbolLinks(getSymbolOfNode(member)).declaredType = memberType; + memberTypeList.push(getRegularTypeOfLiteralType(memberType)); + } } } } @@ -52227,22 +54006,22 @@ var ts; */ function isThislessType(node) { switch (node.kind) { - case 128 /* AnyKeyword */: - case 152 /* UnknownKeyword */: - case 147 /* StringKeyword */: - case 144 /* NumberKeyword */: - case 155 /* BigIntKeyword */: - case 131 /* BooleanKeyword */: - case 148 /* SymbolKeyword */: - case 145 /* ObjectKeyword */: - case 113 /* VoidKeyword */: - case 150 /* UndefinedKeyword */: - case 141 /* NeverKeyword */: - case 191 /* LiteralType */: + case 129 /* AnyKeyword */: + case 153 /* UnknownKeyword */: + case 148 /* StringKeyword */: + case 145 /* NumberKeyword */: + case 156 /* BigIntKeyword */: + case 132 /* BooleanKeyword */: + case 149 /* SymbolKeyword */: + case 146 /* ObjectKeyword */: + case 114 /* VoidKeyword */: + case 151 /* UndefinedKeyword */: + case 142 /* NeverKeyword */: + case 193 /* LiteralType */: return true; - case 178 /* ArrayType */: + case 180 /* ArrayType */: return isThislessType(node.elementType); - case 173 /* TypeReference */: + case 175 /* TypeReference */: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -52268,7 +54047,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 166 /* Constructor */ || (!!returnType && isThislessType(returnType))) && + return (node.kind === 168 /* Constructor */ || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -52284,14 +54063,14 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: return isThislessVariableLikeDeclaration(declaration); - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return isThislessFunctionLikeDeclaration(declaration); } } @@ -52317,7 +54096,7 @@ var ts; } } function isStaticPrivateIdentifierProperty(s) { - return !!s.valueDeclaration && ts.isPrivateIdentifierPropertyDeclaration(s.valueDeclaration) && ts.hasSyntacticModifier(s.valueDeclaration, 32 /* Static */); + return !!s.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(s.valueDeclaration) && ts.hasSyntacticModifier(s.valueDeclaration, 32 /* Static */); } function resolveDeclaredMembers(type) { if (!type.declaredProperties) { @@ -52369,10 +54148,10 @@ var ts; return !!name && isLateBindableName(name); } /** - * Indicates whether a declaration has a dynamic name that cannot be late-bound. + * Indicates whether a declaration has an early-bound name or a dynamic name that can be late-bound. */ - function hasNonBindableDynamicName(node) { - return ts.hasDynamicName(node) && !hasLateBindableName(node); + function hasBindableName(node) { + return !ts.hasDynamicName(node) || hasLateBindableName(node); } /** * Indicates whether a declaration name is a dynamic name that cannot be late-bound. @@ -52642,7 +54421,8 @@ var ts; sig.resolvedMinArgumentCount = undefined; sig.target = undefined; sig.mapper = undefined; - sig.unionSignatures = undefined; + sig.compositeSignatures = undefined; + sig.compositeKind = undefined; return sig; } function cloneSignature(sig) { @@ -52650,12 +54430,14 @@ var ts; /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* PropagatingFlags */); result.target = sig.target; result.mapper = sig.mapper; - result.unionSignatures = sig.unionSignatures; + result.compositeSignatures = sig.compositeSignatures; + result.compositeKind = sig.compositeKind; return result; } function createUnionSignature(signature, unionSignatures) { var result = cloneSignature(signature); - result.unionSignatures = unionSignatures; + result.compositeSignatures = unionSignatures; + result.compositeKind = 1048576 /* Union */; result.target = undefined; result.mapper = undefined; return result; @@ -52814,7 +54596,7 @@ var ts; if (signatures !== masterList) { var signature_1 = signatures[0]; ts.Debug.assert(!!signature_1, "getUnionSignatures bails early on empty signature lists and should not have empty lists on second pass"); - results = signature_1.typeParameters && ts.some(results, function (s) { return !!s.typeParameters && !compareTypeParametersIdentical(signature_1.typeParameters, s.typeParameters); }) ? undefined : ts.map(results, function (sig) { return combineSignaturesOfUnionMembers(sig, signature_1); }); + results = !!signature_1.typeParameters && ts.some(results, function (s) { return !!s.typeParameters && !compareTypeParametersIdentical(signature_1.typeParameters, s.typeParameters); }) ? undefined : ts.map(results, function (sig) { return combineSignaturesOfUnionMembers(sig, signature_1); }); if (!results) { return "break"; } @@ -52831,9 +54613,12 @@ var ts; return result || ts.emptyArray; } function compareTypeParametersIdentical(sourceParams, targetParams) { - if (sourceParams.length !== targetParams.length) { + if (ts.length(sourceParams) !== ts.length(targetParams)) { return false; } + if (!sourceParams || !targetParams) { + return true; + } var mapper = createTypeMapper(targetParams, sourceParams); for (var i = 0; i < sourceParams.length; i++) { var source = sourceParams[i]; @@ -52915,9 +54700,10 @@ var ts; var result = createSignature(declaration, typeParams, thisParam, params, /*resolvedReturnType*/ undefined, /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* PropagatingFlags */); - result.unionSignatures = ts.concatenate(left.unionSignatures || [left], [right]); + result.compositeKind = 1048576 /* Union */; + result.compositeSignatures = ts.concatenate(left.compositeKind !== 2097152 /* Intersection */ && left.compositeSignatures || [left], [right]); if (paramMapper) { - result.mapper = left.mapper && left.unionSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; + result.mapper = left.compositeKind !== 2097152 /* Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; } return result; } @@ -53050,6 +54836,7 @@ var ts; // Combinations of function, class, enum and module var members = emptySymbols; var stringIndexInfo = void 0; + var numberIndexInfo = void 0; if (symbol.exports) { members = getExportsOfSymbol(symbol); if (symbol === globalThisSymbol) { @@ -53062,20 +54849,31 @@ var ts; members = varsOnly_1; } } + var baseConstructorIndexInfo = void 0; setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, undefined, undefined); if (symbol.flags & 32 /* Class */) { var classType = getDeclaredTypeOfClassOrInterface(symbol); var baseConstructorType = getBaseConstructorTypeOfClass(classType); if (baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 8650752 /* TypeVariable */)) { - members = ts.createSymbolTable(getNamedMembers(members)); + members = ts.createSymbolTable(getNamedOrIndexSignatureMembers(members)); addInheritedMembers(members, getPropertiesOfType(baseConstructorType)); } else if (baseConstructorType === anyType) { - stringIndexInfo = createIndexInfo(anyType, /*isReadonly*/ false); + baseConstructorIndexInfo = createIndexInfo(anyType, /*isReadonly*/ false); + } + } + var indexSymbol = getIndexSymbolFromSymbolTable(members); + if (indexSymbol) { + stringIndexInfo = getIndexInfoOfIndexSymbol(indexSymbol, 0 /* String */); + numberIndexInfo = getIndexInfoOfIndexSymbol(indexSymbol, 1 /* Number */); + } + else { + stringIndexInfo = baseConstructorIndexInfo; + if (symbol.flags & 384 /* Enum */ && (getDeclaredTypeOfSymbol(symbol).flags & 32 /* Enum */ || + ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296 /* NumberLike */); }))) { + numberIndexInfo = enumNumberIndexInfo; } } - var numberIndexInfo = symbol.flags & 384 /* Enum */ && (getDeclaredTypeOfSymbol(symbol).flags & 32 /* Enum */ || - ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296 /* NumberLike */); })) ? enumNumberIndexInfo : undefined; setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); // We resolve the members before computing the signatures because a signature may use // typeof with a qualified name expression that circularly references the type we are @@ -53100,6 +54898,18 @@ var ts; } } } + function replaceIndexedAccess(instantiable, type, replacement) { + // map type.indexType to 0 + // map type.objectType to `[TReplacement]` + // thus making the indexed access `[TReplacement][0]` or `TReplacement` + return instantiateType(instantiable, createTypeMapper([type.indexType, type.objectType], [getLiteralType(0), createTupleType([replacement])])); + } + function getIndexInfoOfIndexSymbol(indexSymbol, indexKind) { + var declaration = getIndexDeclarationOfIndexSymbol(indexSymbol, indexKind); + if (!declaration) + return undefined; + return createIndexInfo(declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasEffectiveModifier(declaration, 64 /* Readonly */), declaration); + } function resolveReverseMappedTypeMembers(type) { var indexInfo = getIndexInfoOfType(type.source, 0 /* String */); var modifiers = getMappedTypeModifiers(type.mappedType); @@ -53114,8 +54924,21 @@ var ts; inferredProp.declarations = prop.declarations; inferredProp.nameType = getSymbolLinks(prop).nameType; inferredProp.propertyType = getTypeOfSymbol(prop); - inferredProp.mappedType = type.mappedType; - inferredProp.constraintType = type.constraintType; + if (type.constraintType.type.flags & 8388608 /* IndexedAccess */ + && type.constraintType.type.objectType.flags & 262144 /* TypeParameter */ + && type.constraintType.type.indexType.flags & 262144 /* 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 + var newTypeParam = type.constraintType.type.objectType; + var newMappedType = replaceIndexedAccess(type.mappedType, type.constraintType.type, newTypeParam); + inferredProp.mappedType = newMappedType; + inferredProp.constraintType = getIndexType(newTypeParam); + } + else { + inferredProp.mappedType = type.mappedType; + inferredProp.constraintType = type.constraintType; + } members.set(prop.escapedName, inferredProp); } setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, undefined); @@ -53242,7 +55065,7 @@ 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) : + var type = strictNullChecks && symbol.flags & 16777216 /* Optional */ && !maybeTypeOfKind(propType, 32768 /* Undefined */ | 16384 /* Void */) ? getOptionalType(propType, /*isProperty*/ true) : symbol.checkFlags & 524288 /* StripOptional */ ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : propType; if (!popTypeResolution()) { @@ -53269,7 +55092,7 @@ var ts; function getTemplateTypeFromMappedType(type) { return type.templateType || (type.templateType = type.declaration.type ? - instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), type.mapper) : + instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), /*isProperty*/ true, !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), type.mapper) : errorType); } function getConstraintDeclarationForMappedType(type) { @@ -53277,8 +55100,8 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 188 /* TypeOperator */ && - constraintDeclaration.operator === 138 /* KeyOfKeyword */; + return constraintDeclaration.kind === 190 /* TypeOperator */ && + constraintDeclaration.operator === 139 /* KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { @@ -53329,7 +55152,7 @@ var ts; else if (type.objectFlags & 3 /* ClassOrInterface */) { resolveClassOrInterfaceMembers(type); } - else if (type.objectFlags & 2048 /* ReverseMapped */) { + else if (type.objectFlags & 1024 /* ReverseMapped */) { resolveReverseMappedTypeMembers(type); } else if (type.objectFlags & 16 /* Anonymous */) { @@ -53445,14 +55268,14 @@ var ts; function getConstraintFromIndexedAccess(type) { var indexConstraint = getSimplifiedTypeOrConstraint(type.indexType); if (indexConstraint && indexConstraint !== type.indexType) { - var indexedAccess = getIndexedAccessTypeOrUndefined(type.objectType, indexConstraint, type.noUncheckedIndexedAccessCandidate); + var indexedAccess = getIndexedAccessTypeOrUndefined(type.objectType, indexConstraint, type.accessFlags); if (indexedAccess) { return indexedAccess; } } var objectConstraint = getSimplifiedTypeOrConstraint(type.objectType); if (objectConstraint && objectConstraint !== type.objectType) { - return getIndexedAccessTypeOrUndefined(objectConstraint, type.indexType, type.noUncheckedIndexedAccessCandidate); + return getIndexedAccessTypeOrUndefined(objectConstraint, type.indexType, type.accessFlags); } return undefined; } @@ -53613,12 +55436,22 @@ var ts; if (t.flags & 3145728 /* UnionOrIntersection */) { var types = t.types; var baseTypes = []; + var different = false; for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { var type_3 = types_8[_i]; var baseType = getBaseConstraint(type_3); if (baseType) { + if (baseType !== type_3) { + different = true; + } baseTypes.push(baseType); } + else { + different = true; + } + } + if (!different) { + return t; } return t.flags & 1048576 /* Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) : t.flags & 2097152 /* Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) : @@ -53639,7 +55472,7 @@ var ts; if (t.flags & 8388608 /* IndexedAccess */) { var baseObjectType = getBaseConstraint(t.objectType); var baseIndexType = getBaseConstraint(t.indexType); - var baseIndexedAccess = baseObjectType && baseIndexType && getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, t.noUncheckedIndexedAccessCandidate); + var baseIndexedAccess = baseObjectType && baseIndexType && getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, t.accessFlags); return baseIndexedAccess && getBaseConstraint(baseIndexedAccess); } if (t.flags & 16777216 /* Conditional */) { @@ -53738,6 +55571,7 @@ var ts; return getReducedType(getApparentType(getReducedType(type))); } function createUnionOrIntersectionProperty(containingType, name, skipObjectFunctionPropertyAugment) { + var _a, _b; var singleProp; var propSet; var indexTypes; @@ -53746,8 +55580,9 @@ var ts; var optionalFlag = isUnion ? 0 /* None */ : 16777216 /* Optional */; var syntheticFlag = 4 /* SyntheticMethod */; var checkFlags = 0; - for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { - var current = _a[_i]; + var mergedInstantiations = false; + for (var _i = 0, _c = containingType.types; _i < _c.length; _i++) { + var current = _c[_i]; var type = getApparentType(current); if (!(type === errorType || type.flags & 131072 /* Never */)) { var prop = getPropertyOfType(type, name, skipObjectFunctionPropertyAugment); @@ -53763,13 +55598,25 @@ var ts; singleProp = prop; } else if (prop !== singleProp) { - if (!propSet) { - propSet = new ts.Map(); - propSet.set(getSymbolId(singleProp), singleProp); + var isInstantiation = (getTargetSymbol(prop) || prop) === (getTargetSymbol(singleProp) || singleProp); + // 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 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[]` + mergedInstantiations = !!singleProp.parent && !!ts.length(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(singleProp.parent)); } - var id = getSymbolId(prop); - if (!propSet.has(id)) { - propSet.set(id, prop); + else { + if (!propSet) { + propSet = new ts.Map(); + propSet.set(getSymbolId(singleProp), singleProp); + } + var id = getSymbolId(prop); + if (!propSet.has(id)) { + propSet.set(id, prop); + } } } checkFlags |= (isReadonlySymbol(prop) ? 8 /* Readonly */ : 0) | @@ -53787,7 +55634,7 @@ var ts; checkFlags |= 32 /* WritePartial */ | (indexInfo.isReadonly ? 8 /* Readonly */ : 0); indexTypes = ts.append(indexTypes, isTupleType(type) ? getRestTypeOfTupleType(type) || undefinedType : indexInfo.type); } - else if (isObjectLiteralType(type)) { + else if (isObjectLiteralType(type) && !(ts.getObjectFlags(type) & 4194304 /* ContainsSpread */)) { checkFlags |= 32 /* WritePartial */; indexTypes = ts.append(indexTypes, undefinedType); } @@ -53803,7 +55650,19 @@ var ts; return undefined; } if (!propSet && !(checkFlags & 16 /* ReadPartial */) && !indexTypes) { - return singleProp; + 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!) + // They also have a `.containingType` set, which affects some services endpoints behavior, like `getRootSymbol` + var clone_1 = createSymbolWithType(singleProp, singleProp.type); + clone_1.parent = (_b = (_a = singleProp.valueDeclaration) === null || _a === void 0 ? void 0 : _a.symbol) === null || _b === void 0 ? void 0 : _b.parent; + clone_1.containingType = containingType; + clone_1.mapper = singleProp.mapper; + return clone_1; + } + else { + return singleProp; + } } var props = propSet ? ts.arrayFrom(propSet.values()) : [singleProp]; var declarations; @@ -53812,8 +55671,8 @@ var ts; var propTypes = []; var firstValueDeclaration; var hasNonUniformValueDeclaration = false; - for (var _b = 0, props_1 = props; _b < props_1.length; _b++) { - var prop = props_1[_b]; + for (var _d = 0, props_1 = props; _d < props_1.length; _d++) { + var prop = props_1[_d]; if (!firstValueDeclaration) { firstValueDeclaration = prop.valueDeclaration; } @@ -53890,15 +55749,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 & 268435456 /* ContainsIntersections */) { + if (type.flags & 1048576 /* Union */ && type.objectFlags & 67108864 /* ContainsIntersections */) { return type.resolvedReducedType || (type.resolvedReducedType = getReducedUnionType(type)); } else if (type.flags & 2097152 /* Intersection */) { - if (!(type.objectFlags & 268435456 /* IsNeverIntersectionComputed */)) { - type.objectFlags |= 268435456 /* IsNeverIntersectionComputed */ | - (ts.some(getPropertiesOfUnionOrIntersectionType(type), isNeverReducedProperty) ? 536870912 /* IsNeverIntersection */ : 0); + if (!(type.objectFlags & 67108864 /* IsNeverIntersectionComputed */)) { + type.objectFlags |= 67108864 /* IsNeverIntersectionComputed */ | + (ts.some(getPropertiesOfUnionOrIntersectionType(type), isNeverReducedProperty) ? 134217728 /* IsNeverIntersection */ : 0); } - return type.objectFlags & 536870912 /* IsNeverIntersection */ ? neverType : type; + return type.objectFlags & 134217728 /* IsNeverIntersection */ ? neverType : type; } return type; } @@ -53928,7 +55787,7 @@ var ts; return !prop.valueDeclaration && !!(ts.getCheckFlags(prop) & 1024 /* ContainsPrivate */); } function elaborateNeverIntersection(errorInfo, type) { - if (ts.getObjectFlags(type) & 536870912 /* IsNeverIntersection */) { + if (type.flags & 2097152 /* Intersection */ && ts.getObjectFlags(type) & 134217728 /* 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)); @@ -54015,7 +55874,8 @@ var ts; for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) { var prop = _a[_i]; if (kind === 0 /* String */ || isNumericLiteralName(prop.escapedName)) { - propTypes.push(getTypeOfSymbol(prop)); + var propType = getTypeOfSymbol(prop); + propTypes.push(prop.flags & 16777216 /* Optional */ ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : propType); } } if (kind === 0 /* String */) { @@ -54049,10 +55909,10 @@ 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 === 307 /* JSDocOptionalType */ + node.type && node.type.kind === 310 /* JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 307 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 310 /* JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -54084,12 +55944,15 @@ var ts; } return false; } + function isOptionalPropertyDeclaration(node) { + return ts.isPropertyDeclaration(node) && node.questionToken; + } function isOptionalJSDocPropertyLikeTag(node) { if (!ts.isJSDocPropertyLikeTag(node)) { return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 307 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 310 /* JSDocOptionalType */; } function createTypePredicate(kind, parameterName, parameterIndex, type) { return { kind: kind, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; @@ -54171,7 +56034,7 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 191 /* LiteralType */) { + if (type && type.kind === 193 /* LiteralType */) { flags |= 2 /* HasLiteralTypes */; } // Record a new minimum argument count if this is not an optional parameter @@ -54184,16 +56047,16 @@ 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 === 167 /* GetAccessor */ || declaration.kind === 168 /* SetAccessor */) && - !hasNonBindableDynamicName(declaration) && + if ((declaration.kind === 169 /* GetAccessor */ || declaration.kind === 170 /* SetAccessor */) && + hasBindableName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 167 /* GetAccessor */ ? 168 /* SetAccessor */ : 167 /* GetAccessor */; + var otherKind = declaration.kind === 169 /* GetAccessor */ ? 170 /* SetAccessor */ : 169 /* GetAccessor */; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 166 /* Constructor */ ? + var classType = declaration.kind === 168 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); @@ -54238,8 +56101,7 @@ var ts; if (!(ts.isInJSFile(node) && ts.isFunctionLikeDeclaration(node))) return undefined; var typeTag = ts.getJSDocTypeTag(node); - var signature = typeTag && typeTag.typeExpression && getSingleCallSignature(getTypeFromTypeNode(typeTag.typeExpression)); - return signature && getErasedSignature(signature); + return (typeTag === null || typeTag === void 0 ? void 0 : typeTag.typeExpression) && getSingleCallSignature(getTypeFromTypeNode(typeTag.typeExpression)); } function getReturnTypeOfTypeTag(node) { var signature = getSignatureOfTypeTag(node); @@ -54260,16 +56122,16 @@ var ts; if (!node) return false; switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return node.escapedText === argumentsSymbol.escapedName && getResolvedSymbol(node) === argumentsSymbol; - case 163 /* PropertyDeclaration */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - return node.name.kind === 158 /* ComputedPropertyName */ + case 165 /* PropertyDeclaration */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + return node.name.kind === 160 /* ComputedPropertyName */ && traverse(node.name); - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: return traverse(node.expression); default: return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); @@ -54277,7 +56139,7 @@ var ts; } } function getSignaturesOfSymbol(symbol) { - if (!symbol) + if (!symbol || !symbol.declarations) return ts.emptyArray; var result = []; for (var i = 0; i < symbol.declarations.length; i++) { @@ -54318,8 +56180,8 @@ var ts; var targetTypePredicate = getTypePredicateOfSignature(signature.target); signature.resolvedTypePredicate = targetTypePredicate ? instantiateTypePredicate(targetTypePredicate, signature.mapper) : noTypePredicate; } - else if (signature.unionSignatures) { - signature.resolvedTypePredicate = getUnionTypePredicate(signature.unionSignatures) || noTypePredicate; + else if (signature.compositeSignatures) { + signature.resolvedTypePredicate = getUnionOrIntersectionTypePredicate(signature.compositeSignatures, signature.compositeKind) || noTypePredicate; } else { var type = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); @@ -54341,17 +56203,20 @@ var ts; function createTypePredicateFromTypePredicateNode(node, signature) { var parameterName = node.parameterName; var type = node.type && getTypeFromTypeNode(node.type); - return parameterName.kind === 187 /* ThisType */ ? + return parameterName.kind === 189 /* 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); } + function getUnionOrIntersectionType(types, kind, unionReduction) { + return kind !== 2097152 /* Intersection */ ? getUnionType(types, unionReduction) : getIntersectionType(types); + } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { if (!pushTypeResolution(signature, 3 /* ResolvedReturnType */)) { return errorType; } var type = signature.target ? instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper) : - signature.unionSignatures ? instantiateType(getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature), 2 /* Subtype */), signature.mapper) : + signature.compositeSignatures ? instantiateType(getUnionOrIntersectionType(ts.map(signature.compositeSignatures, getReturnTypeOfSignature), signature.compositeKind, 2 /* Subtype */), signature.mapper) : getReturnTypeFromAnnotation(signature.declaration) || (ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration)); if (signature.flags & 8 /* IsInnerCallChain */) { @@ -54384,7 +56249,7 @@ var ts; return signature.resolvedReturnType; } function getReturnTypeFromAnnotation(declaration) { - if (declaration.kind === 166 /* Constructor */) { + if (declaration.kind === 168 /* Constructor */) { return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)); } if (ts.isJSDocConstructSignature(declaration)) { @@ -54394,12 +56259,12 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 167 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { + if (declaration.kind === 169 /* GetAccessor */ && hasBindableName(declaration)) { var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration); if (jsDocType) { return jsDocType; } - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 168 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 170 /* SetAccessor */); var setterType = getAnnotatedAccessorType(setter); if (setterType) { return setterType; @@ -54476,9 +56341,20 @@ var ts; function getBaseSignature(signature) { var typeParameters = signature.typeParameters; if (typeParameters) { - var typeEraser_1 = createTypeEraser(typeParameters); - var baseConstraints = ts.map(typeParameters, function (tp) { return instantiateType(getBaseConstraintOfType(tp), typeEraser_1) || unknownType; }); - return instantiateSignature(signature, createTypeMapper(typeParameters, baseConstraints), /*eraseTypeParameters*/ true); + if (signature.baseSignatureCache) { + return signature.baseSignatureCache; + } + var typeEraser = createTypeEraser(typeParameters); + var baseConstraintMapper_1 = createTypeMapper(typeParameters, ts.map(typeParameters, function (tp) { return getConstraintOfTypeParameter(tp) || unknownType; })); + var baseConstraints = ts.map(typeParameters, function (tp) { return instantiateType(tp, baseConstraintMapper_1) || unknownType; }); + // Run N type params thru the immediate constraint mapper up to N times + // This way any noncircular interdependent type parameters are definitely resolved to their external dependencies + for (var i = 0; i < typeParameters.length - 1; i++) { + baseConstraints = instantiateTypes(baseConstraints, baseConstraintMapper_1); + } + // and then apply a type eraser to remove any remaining circularly dependent type parameters + baseConstraints = instantiateTypes(baseConstraints, typeEraser); + return signature.baseSignatureCache = instantiateSignature(signature, createTypeMapper(typeParameters, baseConstraints), /*eraseTypeParameters*/ true); } return signature; } @@ -54489,7 +56365,7 @@ var ts; // will result in a different declaration kind. if (!signature.isolatedSignatureType) { var kind = signature.declaration ? signature.declaration.kind : 0 /* Unknown */; - var isConstructor = kind === 166 /* Constructor */ || kind === 170 /* ConstructSignature */ || kind === 175 /* ConstructorType */; + var isConstructor = kind === 168 /* Constructor */ || kind === 172 /* ConstructSignature */ || kind === 177 /* ConstructorType */; var type = createObjectType(16 /* Anonymous */); type.members = emptySymbols; type.properties = ts.emptyArray; @@ -54500,12 +56376,22 @@ var ts; return signature.isolatedSignatureType; } function getIndexSymbol(symbol) { - return symbol.members.get("__index" /* Index */); + return symbol.members ? getIndexSymbolFromSymbolTable(symbol.members) : undefined; + } + function getIndexSymbolFromSymbolTable(symbolTable) { + return symbolTable.get("__index" /* Index */); } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 144 /* NumberKeyword */ : 147 /* StringKeyword */; - var indexSymbol = getIndexSymbol(symbol); - if (indexSymbol) { + var indexSymbol = symbol && getIndexSymbol(symbol); + return indexSymbol && getIndexDeclarationOfIndexSymbol(indexSymbol, kind); + } + function getIndexDeclarationOfSymbolTable(symbolTable, kind) { + var indexSymbol = symbolTable && getIndexSymbolFromSymbolTable(symbolTable); + return indexSymbol && getIndexDeclarationOfIndexSymbol(indexSymbol, kind); + } + function getIndexDeclarationOfIndexSymbol(indexSymbol, kind) { + var syntaxKind = kind === 1 /* Number */ ? 145 /* NumberKeyword */ : 148 /* StringKeyword */; + if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; var node = ts.cast(decl, ts.isIndexSignatureDeclaration); @@ -54533,17 +56419,18 @@ var ts; return ts.mapDefined(ts.filter(type.symbol && type.symbol.declarations, ts.isTypeParameterDeclaration), ts.getEffectiveConstraintOfTypeParameter)[0]; } function getInferredTypeParameterConstraint(typeParameter) { + var _a; var inferences; - if (typeParameter.symbol) { - for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.parent.kind === 185 /* InferType */) { + 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 === 187 /* 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 _b = ts.walkUpParenthesizedTypesAndGetParentAndChild(declaration.parent.parent), _c = _b[0], childTypeParameter = _c === void 0 ? declaration.parent : _c, grandParent = _b[1]; - if (grandParent.kind === 173 /* TypeReference */) { + var _c = ts.walkUpParenthesizedTypesAndGetParentAndChild(declaration.parent.parent), _d = _c[0], childTypeParameter = _d === void 0 ? declaration.parent : _d, grandParent = _c[1]; + if (grandParent.kind === 175 /* TypeReference */) { var typeReference = grandParent; var typeParameters = getTypeParametersForTypeReference(typeReference); if (typeParameters) { @@ -54568,21 +56455,32 @@ 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 === 160 /* Parameter */ && grandParent.dotDotDotToken || - grandParent.kind === 181 /* RestType */ || - grandParent.kind === 192 /* NamedTupleMember */ && grandParent.dotDotDotToken) { + else if (grandParent.kind === 162 /* Parameter */ && grandParent.dotDotDotToken || + grandParent.kind === 183 /* RestType */ || + grandParent.kind === 194 /* 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 === 194 /* TemplateLiteralTypeSpan */) { + else if (grandParent.kind === 196 /* 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 === 159 /* TypeParameter */ && grandParent.parent.kind === 190 /* MappedType */) { + else if (grandParent.kind === 161 /* TypeParameter */ && grandParent.parent.kind === 192 /* 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 === 192 /* MappedType */ && grandParent.type && + ts.skipParentheses(grandParent.type) === declaration.parent && grandParent.parent.kind === 186 /* ConditionalType */ && + grandParent.parent.extendsType === grandParent && grandParent.parent.checkType.kind === 192 /* 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))); + } } } } @@ -54605,7 +56503,7 @@ var ts; if (type.flags & 1 /* Any */ && type !== errorType) { // 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 === 190 /* MappedType */ ? keyofConstraintType : unknownType; + type = constraintDeclaration.parent.parent.kind === 192 /* MappedType */ ? keyofConstraintType : unknownType; } typeParameter.constraint = type; } @@ -54614,7 +56512,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - var tp = ts.getDeclarationOfKind(typeParameter.symbol, 159 /* TypeParameter */); + var tp = ts.getDeclarationOfKind(typeParameter.symbol, 161 /* TypeParameter */); var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getHostSignatureFromJSDoc(tp.parent) : tp.parent; return host && getSymbolOfNode(host); } @@ -54641,6 +56539,9 @@ var ts; } return result; } + function getAliasId(aliasSymbol, aliasTypeArguments) { + return aliasSymbol ? "@" + getSymbolId(aliasSymbol) + (aliasTypeArguments ? ":" + 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 @@ -54653,7 +56554,7 @@ var ts; result |= ts.getObjectFlags(type); } } - return result & 3670016 /* PropagatingFlags */; + return result & 917504 /* PropagatingFlags */; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); @@ -54675,15 +56576,18 @@ var ts; type.resolvedTypeArguments = source.resolvedTypeArguments; return type; } - function createDeferredTypeReference(target, node, mapper) { - var aliasSymbol = getAliasSymbolForTypeNode(node); - var aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); + function createDeferredTypeReference(target, node, mapper, aliasSymbol, aliasTypeArguments) { + if (!aliasSymbol) { + aliasSymbol = getAliasSymbolForTypeNode(node); + var localAliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); + aliasTypeArguments = mapper ? instantiateTypes(localAliasTypeArguments, mapper) : localAliasTypeArguments; + } var type = createObjectType(4 /* Reference */, target.symbol); type.target = target; type.node = node; type.mapper = mapper; type.aliasSymbol = aliasSymbol; - type.aliasTypeArguments = mapper ? instantiateTypes(aliasTypeArguments, mapper) : aliasTypeArguments; + type.aliasTypeArguments = aliasTypeArguments; return type; } function getTypeArguments(type) { @@ -54694,8 +56598,8 @@ var ts; } var node = type.node; var typeArguments = !node ? ts.emptyArray : - node.kind === 173 /* TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : - node.kind === 178 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : + node.kind === 175 /* TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : + node.kind === 180 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); if (popTypeResolution()) { type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments; @@ -54737,7 +56641,7 @@ var ts; return errorType; } } - if (node.kind === 173 /* TypeReference */ && isDeferredTypeReferenceNode(node, ts.length(node.typeArguments) !== typeParameters.length)) { + if (node.kind === 175 /* 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 @@ -54748,17 +56652,17 @@ var ts; } return checkNoTypeArguments(node, symbol) ? type : errorType; } - function getTypeAliasInstantiation(symbol, typeArguments) { + function getTypeAliasInstantiation(symbol, typeArguments, aliasSymbol, aliasTypeArguments) { var type = getDeclaredTypeOfSymbol(symbol); if (type === intrinsicMarkerType && intrinsicTypeKinds.has(symbol.escapedName) && typeArguments && typeArguments.length === 1) { return getStringMappingType(symbol, typeArguments[0]); } var links = getSymbolLinks(symbol); var typeParameters = links.typeParameters; - var id = getTypeListId(typeArguments); + var id = getTypeListId(typeArguments) + getAliasId(aliasSymbol, aliasTypeArguments); var instantiation = links.instantiations.get(id); if (!instantiation) { - links.instantiations.set(id, instantiation = instantiateType(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters), ts.isInJSFile(symbol.valueDeclaration))))); + links.instantiations.set(id, instantiation = instantiateTypeWithAlias(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters), ts.isInJSFile(symbol.valueDeclaration))), aliasSymbol, aliasTypeArguments)); } return instantiation; } @@ -54779,15 +56683,26 @@ var ts; ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); return errorType; } - return getTypeAliasInstantiation(symbol, typeArgumentsFromTypeReferenceNode(node)); + // We refrain from associating a local type alias with an instantiation of a top-level type alias + // because the local alias may end up being referenced in an inferred return type where it is not + // accessible--which in turn may lead to a large structural expansion of the type when generating + // a .d.ts file. See #43622 for an example. + var aliasSymbol = getAliasSymbolForTypeNode(node); + var newAliasSymbol = aliasSymbol && (isLocalTypeAlias(symbol) || !isLocalTypeAlias(aliasSymbol)) ? aliasSymbol : undefined; + return getTypeAliasInstantiation(symbol, typeArgumentsFromTypeReferenceNode(node), newAliasSymbol, getTypeArgumentsForAliasSymbol(newAliasSymbol)); } return checkNoTypeArguments(node, symbol) ? type : errorType; } + function isLocalTypeAlias(symbol) { + var _a; + var declaration = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isTypeAlias); + return !!(declaration && ts.getContainingFunction(declaration)); + } function getTypeReferenceName(node) { switch (node.kind) { - case 173 /* TypeReference */: + case 175 /* TypeReference */: return node.typeName; - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -54843,7 +56758,7 @@ var ts; var valueType = getTypeOfSymbol(symbol); var typeType = valueType; if (symbol.valueDeclaration) { - var isImportTypeWithQualifier = node.kind === 195 /* ImportType */ && node.qualifier; + var isImportTypeWithQualifier = node.kind === 197 /* 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); @@ -54869,7 +56784,7 @@ var ts; return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 179 /* TupleType */ && node.elements.length === 1; + return node.kind === 181 /* TupleType */ && node.elements.length === 1; } function getImpliedConstraint(type, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(type, checkNode.elements[0], extendsNode.elements[0]) : @@ -54878,9 +56793,17 @@ var ts; } function getConditionalFlowTypeOfType(type, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 311 /* JSDocComment */) { + var covariant = true; + while (node && !ts.isStatement(node) && node.kind !== 314 /* JSDocComment */) { var parent = node.parent; - if (parent.kind === 184 /* ConditionalType */ && node === parent.trueType) { + // 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 === 162 /* 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 === 186 /* ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(type, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -54891,7 +56814,7 @@ var ts; return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type; } function isJSDocTypeReference(node) { - return !!(node.flags & 4194304 /* JSDoc */) && (node.kind === 173 /* TypeReference */ || node.kind === 195 /* ImportType */); + return !!(node.flags & 4194304 /* JSDoc */) && (node.kind === 175 /* TypeReference */ || node.kind === 197 /* ImportType */); } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -55001,13 +56924,15 @@ var ts; function getTypeOfGlobalSymbol(symbol, arity) { function getTypeDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { - var declaration = declarations_3[_i]; - switch (declaration.kind) { - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - return declaration; + if (declarations) { + for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { + var declaration = declarations_3[_i]; + switch (declaration.kind) { + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 257 /* EnumDeclaration */: + return declaration; + } } } } @@ -55051,6 +56976,9 @@ var ts; function getGlobalESSymbolConstructorSymbol(reportErrors) { return deferredGlobalESSymbolConstructorSymbol || (deferredGlobalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol", reportErrors)); } + function getGlobalESSymbolConstructorTypeSymbol(reportErrors) { + return deferredGlobalESSymbolConstructorTypeSymbol || (deferredGlobalESSymbolConstructorTypeSymbol = getGlobalTypeSymbol("SymbolConstructor", reportErrors)); + } function getGlobalESSymbolType(reportErrors) { return deferredGlobalESSymbolType || (deferredGlobalESSymbolType = getGlobalType("Symbol", /*arity*/ 0, reportErrors)) || emptyObjectType; } @@ -55127,11 +57055,11 @@ var ts; } function getTupleElementFlags(node) { switch (node.kind) { - case 180 /* OptionalType */: + case 182 /* OptionalType */: return 2 /* Optional */; - case 181 /* RestType */: + case 183 /* RestType */: return getRestTypeElementFlags(node); - case 192 /* NamedTupleMember */: + case 194 /* NamedTupleMember */: return node.questionToken ? 2 /* Optional */ : node.dotDotDotToken ? getRestTypeElementFlags(node) : 1 /* Required */; @@ -55149,14 +57077,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 !== 192 /* NamedTupleMember */; }); + var missingName = ts.some(node.elements, function (e) { return e.kind !== 194 /* 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 === 178 /* ArrayType */ ? mayResolveTypeAlias(node.elementType) : - node.kind === 179 /* TupleType */ ? ts.some(node.elements, mayResolveTypeAlias) : + return !!getAliasSymbolForTypeNode(node) || isResolvedByTypeAlias(node) && (node.kind === 180 /* ArrayType */ ? mayResolveTypeAlias(node.elementType) : + node.kind === 181 /* 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 @@ -55165,18 +57093,18 @@ var ts; function isResolvedByTypeAlias(node) { var parent = node.parent; switch (parent.kind) { - case 186 /* ParenthesizedType */: - case 192 /* NamedTupleMember */: - case 173 /* TypeReference */: - case 182 /* UnionType */: - case 183 /* IntersectionType */: - case 189 /* IndexedAccessType */: - case 184 /* ConditionalType */: - case 188 /* TypeOperator */: - case 178 /* ArrayType */: - case 179 /* TupleType */: + case 188 /* ParenthesizedType */: + case 194 /* NamedTupleMember */: + case 175 /* TypeReference */: + case 184 /* UnionType */: + case 185 /* IntersectionType */: + case 191 /* IndexedAccessType */: + case 186 /* ConditionalType */: + case 190 /* TypeOperator */: + case 180 /* ArrayType */: + case 181 /* TupleType */: return isResolvedByTypeAlias(parent); - case 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: return true; } return false; @@ -55185,28 +57113,28 @@ var ts; // of a type alias. function mayResolveTypeAlias(node) { switch (node.kind) { - case 173 /* TypeReference */: + case 175 /* TypeReference */: return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node.typeName, 788968 /* Type */).flags & 524288 /* TypeAlias */); - case 176 /* TypeQuery */: + case 178 /* TypeQuery */: return true; - case 188 /* TypeOperator */: - return node.operator !== 151 /* UniqueKeyword */ && mayResolveTypeAlias(node.type); - case 186 /* ParenthesizedType */: - case 180 /* OptionalType */: - case 192 /* NamedTupleMember */: - case 307 /* JSDocOptionalType */: - case 305 /* JSDocNullableType */: - case 306 /* JSDocNonNullableType */: - case 301 /* JSDocTypeExpression */: + case 190 /* TypeOperator */: + return node.operator !== 152 /* UniqueKeyword */ && mayResolveTypeAlias(node.type); + case 188 /* ParenthesizedType */: + case 182 /* OptionalType */: + case 194 /* NamedTupleMember */: + case 310 /* JSDocOptionalType */: + case 308 /* JSDocNullableType */: + case 309 /* JSDocNonNullableType */: + case 303 /* JSDocTypeExpression */: return mayResolveTypeAlias(node.type); - case 181 /* RestType */: - return node.type.kind !== 178 /* ArrayType */ || mayResolveTypeAlias(node.type.elementType); - case 182 /* UnionType */: - case 183 /* IntersectionType */: + case 183 /* RestType */: + return node.type.kind !== 180 /* ArrayType */ || mayResolveTypeAlias(node.type.elementType); + case 184 /* UnionType */: + case 185 /* IntersectionType */: return ts.some(node.types, mayResolveTypeAlias); - case 189 /* IndexedAccessType */: + case 191 /* IndexedAccessType */: return mayResolveTypeAlias(node.objectType) || mayResolveTypeAlias(node.indexType); - case 184 /* ConditionalType */: + case 186 /* ConditionalType */: return mayResolveTypeAlias(node.checkType) || mayResolveTypeAlias(node.extendsType) || mayResolveTypeAlias(node.trueType) || mayResolveTypeAlias(node.falseType); } @@ -55219,19 +57147,19 @@ var ts; if (target === emptyGenericType) { links.resolvedType = emptyObjectType; } - else if (!(node.kind === 179 /* TupleType */ && ts.some(node.elements, function (e) { return !!(getTupleElementFlags(e) & 8 /* Variadic */); })) && isDeferredTypeReferenceNode(node)) { - links.resolvedType = node.kind === 179 /* TupleType */ && node.elements.length === 0 ? target : + else if (!(node.kind === 181 /* TupleType */ && ts.some(node.elements, function (e) { return !!(getTupleElementFlags(e) & 8 /* Variadic */); })) && isDeferredTypeReferenceNode(node)) { + links.resolvedType = node.kind === 181 /* TupleType */ && node.elements.length === 0 ? target : createDeferredTypeReference(target, node, /*mapper*/ undefined); } else { - var elementTypes = node.kind === 178 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); + var elementTypes = node.kind === 180 /* 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 === 142 /* ReadonlyKeyword */; + return ts.isTypeOperatorNode(node) && node.operator === 143 /* ReadonlyKeyword */; } function createTupleType(elementTypes, elementFlags, readonly, namedMemberDeclarations) { if (readonly === void 0) { readonly = false; } @@ -55356,8 +57284,15 @@ var ts; addElement(type, 8 /* Variadic */, (_a = target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]); } else if (isTupleType(type)) { + var elements = getTypeArguments(type); + if (elements.length + expandedTypes.length >= 10000) { + error(currentNode, ts.isPartOfTypeNode(currentNode) + ? ts.Diagnostics.Type_produces_a_tuple_type_that_is_too_large_to_represent + : ts.Diagnostics.Expression_produces_a_tuple_type_that_is_too_large_to_represent); + return { value: errorType }; + } // Spread variadic elements with tuple types into the resulting tuple. - ts.forEach(getTypeArguments(type), function (t, n) { var _a; return addElement(t, type.target.elementFlags[n], (_a = type.target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[n]); }); + ts.forEach(elements, function (t, n) { var _a; return addElement(t, type.target.elementFlags[n], (_a = type.target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[n]); }); } else { // Treat everything else as an array type and create a rest element. @@ -55370,7 +57305,9 @@ var ts; } }; for (var i = 0; i < elementTypes.length; i++) { - _loop_13(i); + var state_4 = _loop_13(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++) { @@ -55429,8 +57366,7 @@ var ts; return type.elementFlags.length - ts.findLastIndex(type.elementFlags, function (f) { return !(f & flags); }) - 1; } function getTypeFromOptionalTypeNode(node) { - var type = getTypeFromTypeNode(node.type); - return strictNullChecks ? getOptionalType(type) : type; + return addOptionality(getTypeFromTypeNode(node.type), /*isProperty*/ true); } function getTypeId(type) { return type.id; @@ -55459,7 +57395,7 @@ var ts; if (type === wildcardType) includes |= 8388608 /* IncludesWildcard */; if (!strictNullChecks && flags & 98304 /* Nullable */) { - if (!(ts.getObjectFlags(type) & 524288 /* ContainsWideningType */)) + if (!(ts.getObjectFlags(type) & 131072 /* ContainsWideningType */)) includes |= 4194304 /* IncludesNonWideningType */; } else { @@ -55481,67 +57417,76 @@ var ts; } return includes; } - function isSetOfLiteralsFromSameEnum(types) { - var first = types[0]; - if (first.flags & 1024 /* EnumLiteral */) { - var firstEnum = getParentOfSymbol(first.symbol); - for (var i = 1; i < types.length; i++) { - var other = types[i]; - if (!(other.flags & 1024 /* EnumLiteral */) || (firstEnum !== getParentOfSymbol(other.symbol))) { - return false; - } - } - return true; + function removeSubtypes(types, hasObjectTypes) { + var id = getTypeListId(types); + var match = subtypeReductionCache.get(id); + if (match) { + return match; } - return false; - } - function removeSubtypes(types, primitivesOnly) { + // 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 len = types.length; - if (len === 0 || isSetOfLiteralsFromSameEnum(types)) { - return true; - } var i = len; var count = 0; while (i > 0) { i--; var source = types[i]; - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var target = types_11[_i]; - if (source !== target) { - if (count === 100000) { - // After 100000 subtype checks we estimate the remaining amount of work by assuming the - // same ratio of checks per element. If the estimated number of remaining type checks is - // greater than an upper limit we deem the union type too complex to represent. The - // upper limit is 25M for unions of primitives only, and 1M otherwise. This for example - // caps union types at 5000 unique literal types and 1000 unique object types. - var estimatedCount = (count / (len - i)) * len; - if (estimatedCount > (primitivesOnly ? 25000000 : 1000000)) { - ts.tracing.instant("checkTypes" /* 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 false; + if (hasEmptyObject || source.flags & 469499904 /* 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 */) ? + ts.find(getPropertiesOfType(source), function (p) { return isUnitType(getTypeOfSymbol(p)); }) : + undefined; + var keyPropertyType = keyProperty && getRegularTypeOfLiteralType(getTypeOfSymbol(keyProperty)); + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var target = types_11[_i]; + if (source !== target) { + if (count === 100000) { + // After 100000 subtype checks we estimate the remaining amount of work by assuming the + // same ratio of checks per element. If the estimated number of remaining type checks is + // greater than 1M we deem the union type too complex to represent. This for example + // 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; }) }); + 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 */)) { + 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 */) || + isTypeDerivedFrom(source, target))) { + ts.orderedRemoveItemAt(types, i); + break; } - } - count++; - if (isTypeRelatedTo(source, target, strictSubtypeRelation) && (!(ts.getObjectFlags(getTargetType(source)) & 1 /* Class */) || - !(ts.getObjectFlags(getTargetType(target)) & 1 /* Class */) || - isTypeDerivedFrom(source, target))) { - ts.orderedRemoveItemAt(types, i); - break; } } } } - return true; + subtypeReductionCache.set(id, types); + return types; } - function removeRedundantLiteralTypes(types, includes) { + function removeRedundantLiteralTypes(types, includes, reduceVoidUndefined) { var i = types.length; while (i > 0) { i--; var t = types[i]; - var remove = t.flags & 134217856 /* StringLikeLiteral */ && includes & 4 /* String */ || - t.flags & 256 /* NumberLiteral */ && includes & 8 /* Number */ || - t.flags & 2048 /* BigIntLiteral */ && includes & 64 /* BigInt */ || - t.flags & 8192 /* UniqueESSymbol */ && includes & 4096 /* ESSymbol */ || + var flags = t.flags; + var remove = flags & 128 /* StringLiteral */ && 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 */ || isFreshLiteralType(t) && containsType(types, t.regularType); if (remove) { ts.orderedRemoveItemAt(types, i); @@ -55573,7 +57518,7 @@ var ts; if (t.flags & 1048576 /* Union */) { var origin = t.origin; if (t.aliasSymbol || origin && !(origin.flags & 1048576 /* Union */)) { - namedUnions.push(t); + ts.pushIfUnique(namedUnions, t); } else if (origin && origin.flags & 1048576 /* Union */) { addNamedUnions(namedUnions, origin.types); @@ -55607,20 +57552,23 @@ var ts; if (includes & 3 /* AnyOrUnknown */) { return includes & 1 /* Any */ ? includes & 8388608 /* IncludesWildcard */ ? wildcardType : anyType : unknownType; } - switch (unionReduction) { - case 1 /* Literal */: - if (includes & (134220672 /* FreshableLiteral */ | 8192 /* UniqueESSymbol */)) { - removeRedundantLiteralTypes(typeSet, includes); - } - if (includes & 128 /* StringLiteral */ && includes & 134217728 /* TemplateLiteral */) { - removeStringLiteralsMatchedByTemplateLiterals(typeSet); - } - break; - case 2 /* Subtype */: - if (!removeSubtypes(typeSet, !(includes & 262144 /* IncludesStructuredOrInstantiable */))) { - return errorType; - } - break; + if (strictOptionalProperties && includes & 32768 /* 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 */) || includes & 16384 /* Void */ && includes & 32768 /* Undefined */) { + removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2 /* Subtype */)); + } + if (includes & 128 /* StringLiteral */ && includes & 134217728 /* TemplateLiteral */) { + removeStringLiteralsMatchedByTemplateLiterals(typeSet); + } + if (unionReduction === 2 /* Subtype */) { + typeSet = removeSubtypes(typeSet, !!(includes & 524288 /* Object */)); + if (!typeSet) { + return errorType; + } } if (typeSet.length === 0) { return includes & 65536 /* Null */ ? includes & 4194304 /* IncludesNonWideningType */ ? nullType : nullWideningType : @@ -55655,18 +57603,23 @@ var ts; origin = createOriginUnionOrIntersectionType(1048576 /* Union */, reducedTypes); } } - var objectFlags = (includes & 468598819 /* NotPrimitiveUnion */ ? 0 : 262144 /* PrimitiveUnion */) | - (includes & 2097152 /* Intersection */ ? 268435456 /* ContainsIntersections */ : 0); + var objectFlags = (includes & 468598819 /* NotPrimitiveUnion */ ? 0 : 65536 /* PrimitiveUnion */) | + (includes & 2097152 /* Intersection */ ? 67108864 /* ContainsIntersections */ : 0); return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin); } - function getUnionTypePredicate(signatures) { + function getUnionOrIntersectionTypePredicate(signatures, kind) { var first; var types = []; 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 */) { - continue; + if (kind !== 2097152 /* Intersection */) { + continue; + } + else { + return; // intersections demand all members be type predicates for the result to have a predicate + } } if (first) { if (!typePredicateKindsMatch(first, pred)) { @@ -55680,11 +57633,11 @@ var ts; types.push(pred.type); } if (!first) { - // No union signatures had a type predicate. + // No signatures had a type predicate. return undefined; } - var unionType = getUnionType(types); - return createTypePredicate(first.kind, first.parameterName, first.parameterIndex, unionType); + var compositeType = getUnionOrIntersectionType(types, kind); + return createTypePredicate(first.kind, first.parameterName, first.parameterIndex, compositeType); } function typePredicateKindsMatch(a, b) { return a.kind === b.kind && a.parameterIndex === b.parameterIndex; @@ -55709,8 +57662,8 @@ var ts; var typeKey = !origin ? getTypeListId(types) : origin.flags & 1048576 /* Union */ ? "|" + getTypeListId(origin.types) : origin.flags & 2097152 /* Intersection */ ? "&" + getTypeListId(origin.types) : - "#" + origin.type.id; - var id = typeKey + (aliasSymbol ? "@" + getSymbolId(aliasSymbol) : ""); + "#" + 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 + var id = typeKey + getAliasId(aliasSymbol, aliasTypeArguments); var type = unionTypes.get(id); if (!type) { type = createUnionType(types, aliasSymbol, aliasTypeArguments, origin); @@ -55836,7 +57789,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) & 262144 /* PrimitiveUnion */); }); + var index = ts.findIndex(types, function (t) { return !!(ts.getObjectFlags(t) & 65536 /* PrimitiveUnion */); }); if (index < 0) { return false; } @@ -55845,7 +57798,7 @@ var ts; // the unionTypes array. while (i < types.length) { var t = types[i]; - if (ts.getObjectFlags(t) & 262144 /* PrimitiveUnion */) { + if (ts.getObjectFlags(t) & 65536 /* PrimitiveUnion */) { (unionTypes || (unionTypes = [types[index]])).push(t); ts.orderedRemoveItemAt(types, i); } @@ -55874,14 +57827,14 @@ var ts; } } // Finally replace the first union with the result - types[index] = getUnionTypeFromSortedList(result, 262144 /* PrimitiveUnion */); + types[index] = getUnionTypeFromSortedList(result, 65536 /* PrimitiveUnion */); return true; } function createIntersectionType(types, aliasSymbol, aliasTypeArguments) { var result = createType(2097152 /* Intersection */); result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */); result.types = types; - result.aliasSymbol = aliasSymbol; // See comment in `getUnionTypeFromSortedList`. + result.aliasSymbol = aliasSymbol; result.aliasTypeArguments = aliasTypeArguments; return result; } @@ -55942,7 +57895,7 @@ var ts; if (typeSet.length === 1) { return typeSet[0]; } - var id = getTypeListId(typeSet) + (aliasSymbol ? "@" + getSymbolId(aliasSymbol) : ""); + var id = getTypeListId(typeSet) + getAliasId(aliasSymbol, aliasTypeArguments); var result = intersectionTypes.get(id); if (!result) { if (includes & 1048576 /* Union */) { @@ -55985,7 +57938,7 @@ var ts; function checkCrossProductUnion(types) { var size = getCrossProductUnionSize(types); if (size >= 100000) { - 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" /* 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; } @@ -56035,23 +57988,36 @@ var ts; type.resolvedStringIndexType || (type.resolvedStringIndexType = createIndexType(type, /*stringsOnly*/ true)) : type.resolvedIndexType || (type.resolvedIndexType = createIndexType(type, /*stringsOnly*/ false)); } + function instantiateTypeAsMappedNameType(nameType, type, t) { + return instantiateType(nameType, appendTypeMapping(type.mapper, getTypeParameterFromMappedType(type), t)); + } function getIndexTypeForMappedType(type, noIndexSignatures) { var constraint = filterType(getConstraintTypeFromMappedType(type), function (t) { return !(noIndexSignatures && t.flags & (1 /* Any */ | 4 /* String */)); }); var nameType = type.declaration.nameType && getTypeFromTypeNode(type.declaration.nameType); + // If the constraint is exclusively string/number/never type(s), we need to pull the property names from the modified type and run them through the `nameType` mapper as well + // since they won't appear in the constraint, due to subtype reducing with the string/number index types + var properties = nameType && everyType(constraint, function (t) { return !!(t.flags & (4 /* String */ | 8 /* Number */ | 131072 /* Never */)); }) && getPropertiesOfType(getApparentType(getModifiersTypeFromMappedType(type))); return nameType ? - mapType(constraint, function (t) { return instantiateType(nameType, appendTypeMapping(type.mapper, getTypeParameterFromMappedType(type), t)); }) : + getUnionType([mapType(constraint, function (t) { return instantiateTypeAsMappedNameType(nameType, type, t); }), mapType(getUnionType(ts.map(properties || ts.emptyArray, function (p) { return getLiteralTypeFromProperty(p, 8576 /* StringOrNumberLiteralOrUnique */); })), function (t) { return instantiateTypeAsMappedNameType(nameType, type, t); })]) : constraint; } // Ordinarily we reduce a keyof M, where M is a mapped type { [P in K as N

]: X }, to simply N. This however presumes - // that N distributes over union types, i.e. that N is equivalent to N | N | N. That presumption may not - // be true when N is a non-distributive conditional type or an instantiable type with a non-distributive conditional type as - // a constituent. In those cases, we cannot reduce keyof M and need to preserve it as is. - function maybeNonDistributiveNameType(type) { - return !!(type && (type.flags & 16777216 /* Conditional */ && (!type.root.isDistributive || maybeNonDistributiveNameType(type.checkType)) || - type.flags & (3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */) && ts.some(type.types, maybeNonDistributiveNameType) || - type.flags & (4194304 /* Index */ | 268435456 /* StringMapping */) && maybeNonDistributiveNameType(type.type) || - type.flags & 8388608 /* IndexedAccess */ && maybeNonDistributiveNameType(type.indexType) || - type.flags & 33554432 /* Substitution */ && maybeNonDistributiveNameType(type.substitute))); + // that N distributes over union types, i.e. that N is equivalent to N | N | N. Specifically, we only + // want to perform the reduction when the name type of a mapped type is distributive with respect to the type variable + // introduced by the 'in' clause of the mapped type. Note that non-generic types are considered to be distributive because + // they're the same type regardless of what's being distributed over. + function hasDistributiveNameType(mappedType) { + 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) : + false; + } } function getLiteralTypeFromPropertyName(name) { if (ts.isPrivateIdentifier(name)) { @@ -56069,13 +58035,13 @@ var ts; function getLiteralTypeFromProperty(prop, include) { if (!(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24 /* NonPublicAccessibilityModifier */)) { var type = getSymbolLinks(getLateBoundSymbol(prop)).nameType; - if (!type && !ts.isKnownSymbol(prop)) { + if (!type) { if (prop.escapedName === "default" /* Default */) { type = getLiteralType("default"); } else { var name = prop.valueDeclaration && ts.getNameOfDeclaration(prop.valueDeclaration); - type = name && getLiteralTypeFromPropertyName(name) || getLiteralType(ts.symbolName(prop)); + type = name && getLiteralTypeFromPropertyName(name) || (!ts.isKnownSymbol(prop) ? getLiteralType(ts.symbolName(prop)) : undefined); } } if (type && type.flags & include) { @@ -56099,7 +58065,7 @@ var ts; type = getReducedType(type); return type.flags & 1048576 /* Union */ ? 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) && maybeNonDistributiveNameType(getNameTypeFromMappedType(type)) ? getIndexTypeForGenericType(type, stringsOnly) : + type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) ? getIndexTypeForGenericType(type, stringsOnly) : ts.getObjectFlags(type) & 32 /* Mapped */ ? getIndexTypeForMappedType(type, noIndexSignatures) : type === wildcardType ? wildcardType : type.flags & 2 /* Unknown */ ? neverType : @@ -56124,15 +58090,15 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { switch (node.operator) { - case 138 /* KeyOfKeyword */: + case 139 /* KeyOfKeyword */: links.resolvedType = getIndexType(getTypeFromTypeNode(node.type)); break; - case 151 /* UniqueKeyword */: - links.resolvedType = node.type.kind === 148 /* SymbolKeyword */ + case 152 /* UniqueKeyword */: + links.resolvedType = node.type.kind === 149 /* SymbolKeyword */ ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent)) : errorType; break; - case 142 /* ReadonlyKeyword */: + case 143 /* ReadonlyKeyword */: links.resolvedType = getTypeFromTypeNode(node.type); break; default: @@ -56175,7 +58141,6 @@ var ts; var type = templateLiteralTypes.get(id); if (!type) { templateLiteralTypes.set(id, type = createTemplateLiteralType(newTexts, newTypes)); - type.regularType = type; } return type; function addSpans(texts, types) { @@ -56207,10 +58172,8 @@ var ts; 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 */ ? type.intrinsicName : - type.flags & 65536 /* Null */ ? "null" : - type.flags & 32768 /* Undefined */ ? "undefined" : - undefined; + type.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) ? type.intrinsicName : + undefined; } function createTemplateLiteralType(texts, types) { var type = createType(134217728 /* TemplateLiteral */); @@ -56247,13 +58210,13 @@ var ts; result.type = type; return result; } - function createIndexedAccessType(objectType, indexType, aliasSymbol, aliasTypeArguments, shouldIncludeUndefined) { + function createIndexedAccessType(objectType, indexType, accessFlags, aliasSymbol, aliasTypeArguments) { var type = createType(8388608 /* IndexedAccess */); type.objectType = objectType; type.indexType = indexType; + type.accessFlags = accessFlags; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; - type.noUncheckedIndexedAccessCandidate = shouldIncludeUndefined; return type; } /** @@ -56269,7 +58232,7 @@ var ts; if (noImplicitAny) { return false; // Flag is meaningless under `noImplicitAny` mode } - if (ts.getObjectFlags(type) & 16384 /* JSLiteral */) { + if (ts.getObjectFlags(type) & 8192 /* JSLiteral */) { return true; } if (type.flags & 1048576 /* Union */) { @@ -56279,20 +58242,18 @@ var ts; return ts.some(type.types, isJSLiteralType); } if (type.flags & 465829888 /* Instantiable */) { - return isJSLiteralType(getResolvedBaseConstraint(type)); + var constraint = getResolvedBaseConstraint(type); + return constraint !== type && isJSLiteralType(constraint); } return false; } function getPropertyNameFromIndex(indexType, accessNode) { - var accessExpression = accessNode && accessNode.kind === 202 /* ElementAccessExpression */ ? accessNode : undefined; return isTypeUsableAsPropertyName(indexType) ? getPropertyNameFromType(indexType) : - accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? - ts.getPropertyNameForKnownSymbolName(ts.idText(accessExpression.argumentExpression.name)) : - accessNode && ts.isPropertyName(accessNode) ? - // late bound names are handled in the first branch, so here we only need to handle normal names - ts.getPropertyNameForPropertyNameNode(accessNode) : - undefined; + accessNode && ts.isPropertyName(accessNode) ? + // late bound names are handled in the first branch, so here we only need to handle normal names + ts.getPropertyNameForPropertyNameNode(accessNode) : + undefined; } function isUncalledFunctionReference(node, symbol) { if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { @@ -56304,24 +58265,27 @@ var ts; } return true; } - function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, suppressNoImplicitAnyError, accessNode, accessFlags, noUncheckedIndexedAccessCandidate, reportDeprecated) { + function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, accessNode, accessFlags) { var _a; - var accessExpression = accessNode && accessNode.kind === 202 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 204 /* ElementAccessExpression */ ? accessNode : undefined; var propName = accessNode && ts.isPrivateIdentifier(accessNode) ? undefined : getPropertyNameFromIndex(indexType, accessNode); if (propName !== undefined) { + if (accessFlags & 256 /* Contextual */) { + return getTypeOfPropertyOfContextualType(objectType, propName) || anyType; + } var prop = getPropertyOfType(objectType, propName); if (prop) { - if (reportDeprecated && accessNode && getDeclarationNodeFlagsFromSymbol(prop) & 134217728 /* Deprecated */ && isUncalledFunctionReference(accessNode, prop)) { + if (accessFlags & 64 /* ReportDeprecated */ && accessNode && prop.declarations && getDeclarationNodeFlagsFromSymbol(prop) & 134217728 /* Deprecated */ && 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); - errorOrSuggestion(/* isError */ false, deprecatedNode, ts.Diagnostics._0_is_deprecated, propName); + addDeprecatedSuggestion(deprecatedNode, prop.declarations, propName); } if (accessExpression) { - markPropertyAsReferenced(prop, accessExpression, /*isThisAccess*/ accessExpression.expression.kind === 107 /* ThisKeyword */); + markPropertyAsReferenced(prop, accessExpression, isSelfTypeAccess(accessExpression.expression, objectType.symbol)); if (isAssignmentToReadonlyEntity(accessExpression, prop, ts.getAssignmentTargetKind(accessExpression))) { error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(prop)); return undefined; } - if (accessFlags & 4 /* CacheSymbol */) { + if (accessFlags & 8 /* CacheSymbol */) { getNodeLinks(accessNode).resolvedSymbol = prop; } if (isThisPropertyAccessInConstructor(accessExpression, prop)) { @@ -56334,7 +58298,7 @@ var ts; propType; } if (everyType(objectType, isTupleType) && isNumericLiteralName(propName) && +propName >= 0) { - if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 8 /* NoTupleBoundsCheck */)) { + if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 16 /* NoTupleBoundsCheck */)) { var indexNode = getIndexNodeForAccessExpression(accessNode); if (isTupleType(objectType)) { error(indexNode, ts.Diagnostics.Tuple_type_0_of_length_1_has_no_element_at_index_2, typeToString(objectType), getTypeReferenceArity(objectType), ts.unescapeLeadingUnderscores(propName)); @@ -56346,7 +58310,7 @@ var ts; errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, 1 /* Number */)); return mapType(objectType, function (t) { var restType = getRestTypeOfTupleType(t) || undefinedType; - return noUncheckedIndexedAccessCandidate ? getUnionType([restType, undefinedType]) : restType; + return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([restType, undefinedType]) : restType; }); } } @@ -56357,7 +58321,7 @@ var ts; var stringIndexInfo = getIndexInfoOfType(objectType, 0 /* String */); var indexInfo = isTypeAssignableToKind(indexType, 296 /* NumberLike */) && getIndexInfoOfType(objectType, 1 /* Number */) || stringIndexInfo; if (indexInfo) { - if (accessFlags & 1 /* NoIndexSignatures */ && indexInfo === stringIndexInfo) { + if (accessFlags & 2 /* NoIndexSignatures */ && indexInfo === stringIndexInfo) { if (accessExpression) { error(accessExpression, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(originalObjectType)); } @@ -56366,10 +58330,10 @@ var ts; if (accessNode && !isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) { var indexNode = getIndexNodeForAccessExpression(accessNode); error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); - return noUncheckedIndexedAccessCandidate ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; + return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; } errorIfWritingToReadonlyIndex(indexInfo); - return noUncheckedIndexedAccessCandidate ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; + return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; } if (indexType.flags & 131072 /* Never */) { return neverType; @@ -56393,7 +58357,7 @@ var ts; if (objectType.symbol === globalThisSymbol && propName !== undefined && globalThisSymbol.exports.has(propName) && (globalThisSymbol.exports.get(propName).flags & 418 /* BlockScoped */)) { error(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType)); } - else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !suppressNoImplicitAnyError) { + else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !(accessFlags & 128 /* 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) + "]"); @@ -56466,13 +58430,13 @@ var ts; } } function getIndexNodeForAccessExpression(accessNode) { - return accessNode.kind === 202 /* ElementAccessExpression */ ? accessNode.argumentExpression : - accessNode.kind === 189 /* IndexedAccessType */ ? accessNode.indexType : - accessNode.kind === 158 /* ComputedPropertyName */ ? accessNode.expression : + return accessNode.kind === 204 /* ElementAccessExpression */ ? accessNode.argumentExpression : + accessNode.kind === 191 /* IndexedAccessType */ ? accessNode.indexType : + accessNode.kind === 160 /* ComputedPropertyName */ ? accessNode.expression : accessNode; } function isPatternLiteralPlaceholderType(type) { - return templateConstraintType.types.indexOf(type) !== -1 || !!(type.flags & 1 /* Any */); + return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */)); } function isPatternLiteralType(type) { return !!(type.flags & 134217728 /* TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType); @@ -56485,6 +58449,13 @@ var ts; } return !!(type.objectFlags & 8388608 /* IsGenericObjectType */); } + if (type.flags & 33554432 /* Substitution */) { + if (!(type.objectFlags & 4194304 /* IsGenericObjectTypeComputed */)) { + type.objectFlags |= 4194304 /* IsGenericObjectTypeComputed */ | + (isGenericObjectType(type.substitute) || isGenericObjectType(type.baseType) ? 8388608 /* IsGenericObjectType */ : 0); + } + return !!(type.objectFlags & 8388608 /* IsGenericObjectType */); + } return !!(type.flags & 58982400 /* InstantiableNonPrimitive */) || isGenericMappedType(type) || isGenericTupleType(type); } function isGenericIndexType(type) { @@ -56495,6 +58466,13 @@ var ts; } return !!(type.objectFlags & 33554432 /* IsGenericIndexType */); } + if (type.flags & 33554432 /* Substitution */) { + if (!(type.objectFlags & 16777216 /* IsGenericIndexTypeComputed */)) { + type.objectFlags |= 16777216 /* IsGenericIndexTypeComputed */ | + (isGenericIndexType(type.substitute) || isGenericIndexType(type.baseType) ? 33554432 /* IsGenericIndexType */ : 0); + } + return !!(type.objectFlags & 33554432 /* IsGenericIndexType */); + } return !!(type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */)) && !isPatternLiteralType(type); } function isThisTypeParameter(type) { @@ -56570,6 +58548,12 @@ var ts; } return type[cache] = type; } + function isConditionalTypeAlwaysTrueDisregardingInferTypes(type) { + var extendsInferParamMapper = type.root.inferTypeParameters && createTypeMapper(type.root.inferTypeParameters, ts.map(type.root.inferTypeParameters, function () { return wildcardType; })); + var checkType = type.checkType; + var extendsType = type.extendsType; + return isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(instantiateType(extendsType, extendsInferParamMapper))); + } function getSimplifiedConditionalType(type, writing) { var checkType = type.checkType; var extendsType = type.extendsType; @@ -56605,9 +58589,9 @@ var ts; var templateMapper = combineTypeMappers(objectType.mapper, mapper); return instantiateType(getTemplateTypeFromMappedType(objectType), templateMapper); } - function getIndexedAccessType(objectType, indexType, noUncheckedIndexedAccessCandidate, accessNode, aliasSymbol, aliasTypeArguments, accessFlags) { + function getIndexedAccessType(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) { if (accessFlags === void 0) { accessFlags = 0 /* None */; } - return getIndexedAccessTypeOrUndefined(objectType, indexType, noUncheckedIndexedAccessCandidate, accessNode, accessFlags, aliasSymbol, aliasTypeArguments) || (accessNode ? errorType : unknownType); + return getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) || (accessNode ? errorType : unknownType); } function indexTypeLessThan(indexType, limit) { return everyType(indexType, function (t) { @@ -56621,36 +58605,38 @@ var ts; return false; }); } - function getIndexedAccessTypeOrUndefined(objectType, indexType, noUncheckedIndexedAccessCandidate, accessNode, accessFlags, aliasSymbol, aliasTypeArguments) { + function getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) { if (accessFlags === void 0) { accessFlags = 0 /* None */; } if (objectType === wildcardType || indexType === wildcardType) { return wildcardType; } - var shouldIncludeUndefined = noUncheckedIndexedAccessCandidate || - (!!compilerOptions.noUncheckedIndexedAccess && - (accessFlags & (2 /* Writing */ | 16 /* ExpressionPosition */)) === 16 /* ExpressionPosition */); // 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 */)) { 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 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 !== 189 /* IndexedAccessType */ ? + if (isGenericIndexType(indexType) || (accessNode && accessNode.kind !== 191 /* IndexedAccessType */ ? isGenericTupleType(objectType) && !indexTypeLessThan(indexType, objectType.target.fixedLength) : isGenericObjectType(objectType) && !(isTupleType(objectType) && indexTypeLessThan(indexType, objectType.target.fixedLength)))) { if (objectType.flags & 3 /* AnyOrUnknown */) { return objectType; } // Defer the operation by creating an indexed access type. - var id = objectType.id + "," + indexType.id + (shouldIncludeUndefined ? "?" : "") + (aliasSymbol ? "@" + getSymbolId(aliasSymbol) : ""); + var persistentAccessFlags = accessFlags & 1 /* Persistent */; + var id = objectType.id + "," + indexType.id + "," + persistentAccessFlags + getAliasId(aliasSymbol, aliasTypeArguments); var type = indexedAccessTypes.get(id); if (!type) { - indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType, aliasSymbol, aliasTypeArguments, shouldIncludeUndefined)); + indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType, persistentAccessFlags, aliasSymbol, aliasTypeArguments)); } return type; } @@ -56663,7 +58649,7 @@ var ts; 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, wasMissingProp, accessNode, accessFlags, shouldIncludeUndefined); + var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, indexType, accessNode, accessFlags | (wasMissingProp ? 128 /* SuppressNoImplicitAnyError */ : 0)); if (propType) { propTypes.push(propType); } @@ -56679,11 +58665,11 @@ var ts; if (wasMissingProp) { return undefined; } - return accessFlags & 2 /* Writing */ + return accessFlags & 4 /* Writing */ ? getIntersectionType(propTypes, aliasSymbol, aliasTypeArguments) : getUnionType(propTypes, 1 /* Literal */, aliasSymbol, aliasTypeArguments); } - return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, /* supressNoImplicitAnyError */ false, accessNode, accessFlags | 4 /* CacheSymbol */, shouldIncludeUndefined, /* reportDeprecated */ true); + return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, accessNode, accessFlags | 8 /* CacheSymbol */ | 64 /* ReportDeprecated */); } function getTypeFromIndexedAccessTypeNode(node) { var links = getNodeLinks(node); @@ -56691,7 +58677,7 @@ var ts; var objectType = getTypeFromTypeNode(node.objectType); var indexType = getTypeFromTypeNode(node.indexType); var potentialAlias = getAliasSymbolForTypeNode(node); - var resolved = getIndexedAccessType(objectType, indexType, /*noUncheckedIndexedAccessCandidate*/ undefined, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias)); + var resolved = getIndexedAccessType(objectType, indexType, 0 /* None */, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias)); links.resolvedType = resolved.flags & 8388608 /* IndexedAccess */ && resolved.objectType === objectType && resolved.indexType === indexType ? @@ -56723,16 +58709,32 @@ var ts; } return type; } - function getConditionalType(root, mapper) { + function isTypicalNondistributiveConditional(root) { + return !root.isDistributive + && root.node.checkType.kind === 181 /* TupleType */ + && ts.length(root.node.checkType.elements) === 1 + && root.node.extendsType.kind === 181 /* TupleType */ + && ts.length(root.node.extendsType.elements) === 1; + } + /** + * We syntactually check for common nondistributive conditional shapes and unwrap them into + * the intended comparison - we do this so we can check if the unwrapped types are generic or + * not and appropriately defer condition calculation + */ + function unwrapNondistributiveConditionalTuple(root, type) { + return isTypicalNondistributiveConditional(root) && isTupleType(type) ? getTypeArguments(type)[0] : type; + } + function getConditionalType(root, mapper, aliasSymbol, aliasTypeArguments) { var result; var extraTypes; // We loop here for an immediately nested conditional type in the false position, effectively treating // types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for // purposes of resolution. This means such types aren't subject to the instatiation depth limiter. while (true) { - var checkType = instantiateType(root.checkType, mapper); + var isUnwrapped = isTypicalNondistributiveConditional(root); + var checkType = instantiateType(unwrapNondistributiveConditionalTuple(root, getActualTypeVariable(root.checkType)), mapper); var checkTypeInstantiable = isGenericObjectType(checkType) || isGenericIndexType(checkType); - var extendsType = instantiateType(root.extendsType, mapper); + var extendsType = instantiateType(unwrapNondistributiveConditionalTuple(root, root.extendsType), mapper); if (checkType === wildcardType || extendsType === wildcardType) { return wildcardType; } @@ -56743,21 +58745,24 @@ 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, extendsType, 256 /* NoConstraints */ | 512 /* AlwaysStrict */); + inferTypes(context.inferences, checkType, extendsType, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */); } - combinedMapper = mergeTypeMappers(mapper, context.mapper); + // It's possible for 'infer T' type paramteters to be given uninstantiated constraints when the + // those type parameters are used in type references (see getInferredTypeParameterConstraint). For + // that reason we need context.mapper to be first in the combined mapper. See #42636 for examples. + combinedMapper = mapper ? combineTypeMappers(context.mapper, mapper) : context.mapper; } // Instantiate the extends type including inferences for 'infer T' type parameters - var inferredExtendsType = combinedMapper ? instantiateType(root.extendsType, combinedMapper) : extendsType; + var inferredExtendsType = combinedMapper ? instantiateType(unwrapNondistributiveConditionalTuple(root, root.extendsType), combinedMapper) : extendsType; // We attempt to resolve the conditional type only when the check and extends types are non-generic if (!checkTypeInstantiable && !isGenericObjectType(inferredExtendsType) && !isGenericIndexType(inferredExtendsType)) { // Return falseType for a definitely false extends check. We check an instantiations of the two // 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 */ || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) { + if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && ((checkType.flags & 1 /* Any */ && !isUnwrapped) || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) { // Return union of trueType and falseType for 'any' since it matches anything - if (checkType.flags & 1 /* Any */) { + if (checkType.flags & 1 /* 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 @@ -56786,12 +58791,12 @@ var ts; // Return a deferred type for a check that is neither definitely true nor definitely false result = createType(16777216 /* Conditional */); result.root = root; - result.checkType = checkType; - result.extendsType = extendsType; + result.checkType = instantiateType(root.checkType, mapper); + result.extendsType = instantiateType(root.extendsType, mapper); result.mapper = mapper; result.combinedMapper = combinedMapper; - result.aliasSymbol = root.aliasSymbol; - result.aliasTypeArguments = instantiateTypes(root.aliasTypeArguments, mapper); // TODO: GH#18217 + result.aliasSymbol = aliasSymbol || root.aliasSymbol; + result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(root.aliasTypeArguments, mapper); // TODO: GH#18217 break; } return extraTypes ? getUnionType(ts.append(extraTypes, result)) : result; @@ -56950,7 +58955,7 @@ var ts; } function getAliasSymbolForTypeNode(node) { var host = node.parent; - while (ts.isParenthesizedTypeNode(host) || ts.isJSDocTypeExpression(host) || ts.isTypeOperatorNode(host) && host.operator === 142 /* ReadonlyKeyword */) { + while (ts.isParenthesizedTypeNode(host) || ts.isJSDocTypeExpression(host) || ts.isTypeOperatorNode(host) && host.operator === 143 /* ReadonlyKeyword */) { host = host.parent; } return ts.isTypeAlias(host) ? getSymbolOfNode(host) : undefined; @@ -56989,7 +58994,7 @@ var ts; 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)); - result.type = isSetonlyAccessor ? undefinedType : getUnionType([getTypeOfSymbol(prop), undefinedType]); + result.type = isSetonlyAccessor ? undefinedType : addOptionality(getTypeOfSymbol(prop), /*isProperty*/ true); result.declarations = prop.declarations; result.nameType = getSymbolLinks(prop).nameType; result.syntheticOrigin = prop; @@ -56997,7 +59002,7 @@ var ts; } } var spread = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfoOfType(type, 0 /* String */), getIndexInfoOfType(type, 1 /* Number */)); - spread.objectFlags |= 128 /* ObjectLiteral */ | 1048576 /* ContainsObjectOrArrayLiteral */; + spread.objectFlags |= 128 /* ObjectLiteral */ | 262144 /* ContainsObjectOrArrayLiteral */; return spread; } } @@ -57103,14 +59108,15 @@ var ts; } } var spread = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfoWithReadonly(stringIndexInfo, readonly), getIndexInfoWithReadonly(numberIndexInfo, readonly)); - spread.objectFlags |= 128 /* ObjectLiteral */ | 1048576 /* ContainsObjectOrArrayLiteral */ | 1024 /* ContainsSpread */ | objectFlags; + spread.objectFlags |= 128 /* ObjectLiteral */ | 262144 /* ContainsObjectOrArrayLiteral */ | 4194304 /* ContainsSpread */ | objectFlags; return spread; } /** We approximate own properties as non-methods plus methods that are inside the object literal */ function isSpreadableProperty(prop) { - return !ts.some(prop.declarations, ts.isPrivateIdentifierPropertyDeclaration) && + var _a; + return !ts.some(prop.declarations, ts.isPrivateIdentifierClassElementDeclaration) && (!(prop.flags & (8192 /* Method */ | 32768 /* GetAccessor */ | 65536 /* SetAccessor */)) || - !prop.declarations.some(function (decl) { return ts.isClassLike(decl.parent); })); + !((_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 */); @@ -57135,11 +59141,9 @@ var ts; return type; } function getFreshTypeOfLiteralType(type) { - if (type.flags & 134220672 /* FreshableLiteral */) { + if (type.flags & 2944 /* Literal */) { if (!type.freshType) { - var freshType = type.flags & 134217728 /* TemplateLiteral */ ? - createTemplateLiteralType(type.texts, type.types) : - createLiteralType(type.flags, type.value, type.symbol); + var freshType = createLiteralType(type.flags, type.value, type.symbol); freshType.regularType = type; freshType.freshType = freshType; type.freshType = freshType; @@ -57149,12 +59153,12 @@ var ts; return type; } function getRegularTypeOfLiteralType(type) { - return type.flags & 134220672 /* FreshableLiteral */ ? type.regularType : + return type.flags & 2944 /* Literal */ ? type.regularType : type.flags & 1048576 /* Union */ ? (type.regularType || (type.regularType = mapType(type, getRegularTypeOfLiteralType))) : type; } function isFreshLiteralType(type) { - return !!(type.flags & 134220672 /* FreshableLiteral */) && type.freshType === type; + return !!(type.flags & 2944 /* Literal */) && type.freshType === type; } function getLiteralType(value, enumId, symbol) { // We store all literal types in a single map with keys of the form '#NNN' and '@SSS', @@ -57174,7 +59178,7 @@ var ts; return type; } function getTypeFromLiteralTypeNode(node) { - if (node.literal.kind === 103 /* NullKeyword */) { + if (node.literal.kind === 104 /* NullKeyword */) { return nullType; } var links = getNodeLinks(node); @@ -57200,7 +59204,7 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 253 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 255 /* InterfaceDeclaration */)) { if (!ts.hasSyntacticModifier(container, 32 /* Static */) && (!ts.isConstructorDeclaration(container) || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; @@ -57235,17 +59239,17 @@ var ts; } function getArrayElementTypeNode(node) { switch (node.kind) { - case 186 /* ParenthesizedType */: + case 188 /* ParenthesizedType */: return getArrayElementTypeNode(node.type); - case 179 /* TupleType */: + case 181 /* TupleType */: if (node.elements.length === 1) { node = node.elements[0]; - if (node.kind === 181 /* RestType */ || node.kind === 192 /* NamedTupleMember */ && node.dotDotDotToken) { + if (node.kind === 183 /* RestType */ || node.kind === 194 /* NamedTupleMember */ && node.dotDotDotToken) { return getArrayElementTypeNode(node.type); } } break; - case 178 /* ArrayType */: + case 180 /* ArrayType */: return node.elementType; } return undefined; @@ -57254,107 +59258,106 @@ var ts; var links = getNodeLinks(node); return links.resolvedType || (links.resolvedType = node.dotDotDotToken ? getTypeFromRestTypeNode(node) : - node.questionToken && strictNullChecks ? getOptionalType(getTypeFromTypeNode(node.type)) : - getTypeFromTypeNode(node.type)); + addOptionality(getTypeFromTypeNode(node.type), /*isProperty*/ true, !!node.questionToken)); } function getTypeFromTypeNode(node) { return getConditionalFlowTypeOfType(getTypeFromTypeNodeWorker(node), node); } function getTypeFromTypeNodeWorker(node) { switch (node.kind) { - case 128 /* AnyKeyword */: - case 303 /* JSDocAllType */: - case 304 /* JSDocUnknownType */: + case 129 /* AnyKeyword */: + case 306 /* JSDocAllType */: + case 307 /* JSDocUnknownType */: return anyType; - case 152 /* UnknownKeyword */: + case 153 /* UnknownKeyword */: return unknownType; - case 147 /* StringKeyword */: + case 148 /* StringKeyword */: return stringType; - case 144 /* NumberKeyword */: + case 145 /* NumberKeyword */: return numberType; - case 155 /* BigIntKeyword */: + case 156 /* BigIntKeyword */: return bigintType; - case 131 /* BooleanKeyword */: + case 132 /* BooleanKeyword */: return booleanType; - case 148 /* SymbolKeyword */: + case 149 /* SymbolKeyword */: return esSymbolType; - case 113 /* VoidKeyword */: + case 114 /* VoidKeyword */: return voidType; - case 150 /* UndefinedKeyword */: + case 151 /* UndefinedKeyword */: return undefinedType; - case 103 /* NullKeyword */: + case 104 /* 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 141 /* NeverKeyword */: + case 142 /* NeverKeyword */: return neverType; - case 145 /* ObjectKeyword */: + case 146 /* ObjectKeyword */: return node.flags & 131072 /* JavaScriptFile */ && !noImplicitAny ? anyType : nonPrimitiveType; - case 136 /* IntrinsicKeyword */: + case 137 /* IntrinsicKeyword */: return intrinsicMarkerType; - case 187 /* ThisType */: - case 107 /* ThisKeyword */: + case 189 /* ThisType */: + case 108 /* 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 191 /* LiteralType */: + case 193 /* LiteralType */: return getTypeFromLiteralTypeNode(node); - case 173 /* TypeReference */: + case 175 /* TypeReference */: return getTypeFromTypeReference(node); - case 172 /* TypePredicate */: + case 174 /* TypePredicate */: return node.assertsModifier ? voidType : booleanType; - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 176 /* TypeQuery */: + case 178 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 178 /* ArrayType */: - case 179 /* TupleType */: + case 180 /* ArrayType */: + case 181 /* TupleType */: return getTypeFromArrayOrTupleTypeNode(node); - case 180 /* OptionalType */: + case 182 /* OptionalType */: return getTypeFromOptionalTypeNode(node); - case 182 /* UnionType */: + case 184 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 183 /* IntersectionType */: + case 185 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 305 /* JSDocNullableType */: + case 308 /* JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 307 /* JSDocOptionalType */: + case 310 /* JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 192 /* NamedTupleMember */: + case 194 /* NamedTupleMember */: return getTypeFromNamedTupleTypeNode(node); - case 186 /* ParenthesizedType */: - case 306 /* JSDocNonNullableType */: - case 301 /* JSDocTypeExpression */: + case 188 /* ParenthesizedType */: + case 309 /* JSDocNonNullableType */: + case 303 /* JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 181 /* RestType */: + case 183 /* RestType */: return getTypeFromRestTypeNode(node); - case 309 /* JSDocVariadicType */: + case 312 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); - case 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 177 /* TypeLiteral */: - case 312 /* JSDocTypeLiteral */: - case 308 /* JSDocFunctionType */: - case 313 /* JSDocSignature */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: + case 179 /* TypeLiteral */: + case 316 /* JSDocTypeLiteral */: + case 311 /* JSDocFunctionType */: + case 317 /* JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 188 /* TypeOperator */: + case 190 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 189 /* IndexedAccessType */: + case 191 /* IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 190 /* MappedType */: + case 192 /* MappedType */: return getTypeFromMappedTypeNode(node); - case 184 /* ConditionalType */: + case 186 /* ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 185 /* InferType */: + case 187 /* InferType */: return getTypeFromInferTypeNode(node); - case 193 /* TemplateLiteralType */: + case 195 /* TemplateLiteralType */: return getTypeFromTemplateTypeNode(node); - case 195 /* ImportType */: + case 197 /* 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 78 /* Identifier */: - case 157 /* QualifiedName */: - case 201 /* PropertyAccessExpression */: + case 79 /* Identifier */: + case 159 /* QualifiedName */: + case 203 /* PropertyAccessExpression */: var symbol = getSymbolAtLocation(node); return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType; default: @@ -57507,7 +59510,7 @@ var ts; } return result; } - function getObjectTypeInstantiation(type, mapper) { + function getObjectTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) { var declaration = type.objectFlags & 4 /* Reference */ ? type.node : type.symbol.declarations[0]; var links = getNodeLinks(declaration); var target = type.objectFlags & 4 /* Reference */ ? links.resolvedType : @@ -57524,8 +59527,9 @@ var ts; outerTypeParameters = ts.addRange(outerTypeParameters, templateTagParameters); } typeParameters = outerTypeParameters || ts.emptyArray; - typeParameters = (target.objectFlags & 4 /* Reference */ || target.symbol.flags & 2048 /* TypeLiteral */) && !target.aliasTypeArguments ? - ts.filter(typeParameters, function (tp) { return isTypeParameterPossiblyReferenced(tp, declaration); }) : + var allDeclarations_1 = type.objectFlags & 4 /* Reference */ ? [declaration] : type.symbol.declarations; + typeParameters = (target.objectFlags & 4 /* Reference */ || target.symbol.flags & 8192 /* Method */ || target.symbol.flags & 2048 /* TypeLiteral */) && !target.aliasTypeArguments ? + ts.filter(typeParameters, function (tp) { return ts.some(allDeclarations_1, function (d) { return isTypeParameterPossiblyReferenced(tp, d); }); }) : typeParameters; links.outerTypeParameters = typeParameters; } @@ -57535,17 +59539,19 @@ var ts; // instantiation cache key from the type IDs of the type arguments. var combinedMapper_1 = combineTypeMappers(type.mapper, mapper); var typeArguments = ts.map(typeParameters, function (t) { return getMappedType(t, combinedMapper_1); }); - var id = getTypeListId(typeArguments); + var newAliasSymbol = aliasSymbol || type.aliasSymbol; + var newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper); + var id = getTypeListId(typeArguments) + getAliasId(newAliasSymbol, newAliasTypeArguments); if (!target.instantiations) { target.instantiations = new ts.Map(); - target.instantiations.set(getTypeListId(typeParameters), target); + target.instantiations.set(getTypeListId(typeParameters) + getAliasId(target.aliasSymbol, target.aliasTypeArguments), target); } var result = target.instantiations.get(id); if (!result) { var newMapper = createTypeMapper(typeParameters, typeArguments); - result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper) : - target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper) : - instantiateAnonymousType(target, newMapper); + result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : + target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : + instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments); target.instantiations.set(id, result); } return result; @@ -57553,9 +59559,8 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 157 /* QualifiedName */ || - node.parent.kind === 173 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || - node.parent.kind === 195 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); + return !(node.parent.kind === 175 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || + node.parent.kind === 197 /* 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 @@ -57564,22 +59569,28 @@ 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 === 230 /* Block */ || n.kind === 184 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { + if (!n || n.kind === 232 /* Block */ || n.kind === 186 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { return true; } } - return !!ts.forEachChild(node, containsReference); + return containsReference(node); } return true; function containsReference(node) { switch (node.kind) { - case 187 /* ThisType */: + case 189 /* ThisType */: return !!tp.isThisType; - case 78 /* Identifier */: + case 79 /* Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNodeWorker(node) === tp; // use worker because we're looking for === equality - case 176 /* TypeQuery */: + case 178 /* TypeQuery */: return true; + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + return !node.type && !!node.body || + ts.some(node.typeParameters, containsReference) || + ts.some(node.parameters, containsReference) || + !!node.type && containsReference(node.type); } return !!ts.forEachChild(node, containsReference); } @@ -57594,7 +59605,7 @@ var ts; } return undefined; } - function instantiateMappedType(type, mapper) { + function instantiateMappedType(type, mapper, aliasSymbol, aliasTypeArguments) { // For a homomorphic mapped type { [P in keyof T]: X }, where T is some type variable, the mapping // operation depends on T as follows: // * If T is a primitive type no mapping is performed and the result is simply T. @@ -57609,7 +59620,7 @@ var ts; if (typeVariable) { var mappedTypeVariable = instantiateType(typeVariable, mapper); if (typeVariable !== mappedTypeVariable) { - return mapType(getReducedType(mappedTypeVariable), function (t) { + return mapTypeWithAlias(getReducedType(mappedTypeVariable), function (t) { if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && t !== errorType) { if (!type.declaration.nameType) { if (isArrayType(t)) { @@ -57625,11 +59636,11 @@ var ts; return instantiateAnonymousType(type, prependTypeMapping(typeVariable, t, mapper)); } return t; - }); + }, aliasSymbol, aliasTypeArguments); } } // If the constraint type of the instantiation is the wildcard type, return the wildcard type. - return instantiateType(getConstraintTypeFromMappedType(type), mapper) === wildcardType ? wildcardType : instantiateAnonymousType(type, mapper); + 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; @@ -57672,11 +59683,11 @@ 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) : + return strictNullChecks && modifiers & 4 /* IncludeOptional */ && !maybeTypeOfKind(propType, 32768 /* Undefined */ | 16384 /* Void */) ? getOptionalType(propType, /*isProperty*/ true) : strictNullChecks && modifiers & 8 /* ExcludeOptional */ && isOptional ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : propType; } - function instantiateAnonymousType(type, mapper) { + function instantiateAnonymousType(type, mapper, aliasSymbol, aliasTypeArguments) { var result = createObjectType(type.objectFlags | 64 /* Instantiated */, type.symbol); if (type.objectFlags & 32 /* Mapped */) { result.declaration = type.declaration; @@ -57689,29 +59700,29 @@ var ts; } result.target = type; result.mapper = mapper; - result.aliasSymbol = type.aliasSymbol; - result.aliasTypeArguments = instantiateTypes(type.aliasTypeArguments, mapper); + result.aliasSymbol = aliasSymbol || type.aliasSymbol; + result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper); return result; } - function getConditionalTypeInstantiation(type, mapper) { + function getConditionalTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) { var root = type.root; if (root.outerTypeParameters) { // We are instantiating a conditional type that has one or more type parameters in scope. Apply the // mapper to the type parameters to produce the effective list of type arguments, and compute the // instantiation cache key from the type IDs of the type arguments. var typeArguments = ts.map(root.outerTypeParameters, function (t) { return getMappedType(t, mapper); }); - var id = getTypeListId(typeArguments); + var id = getTypeListId(typeArguments) + getAliasId(aliasSymbol, aliasTypeArguments); var result = root.instantiations.get(id); if (!result) { var newMapper = createTypeMapper(root.outerTypeParameters, typeArguments); - result = instantiateConditionalType(root, newMapper); + result = instantiateConditionalType(root, newMapper, aliasSymbol, aliasTypeArguments); root.instantiations.set(id, result); } return result; } return type; } - function instantiateConditionalType(root, mapper) { + function instantiateConditionalType(root, mapper, aliasSymbol, aliasTypeArguments) { // Check if we have a conditional type where the check type is a naked type parameter. If so, // the conditional type is distributive over union types and when T is instantiated to a union // type A | B, we produce (A extends U ? X : Y) | (B extends U ? X : Y). @@ -57719,31 +59730,34 @@ var ts; var checkType_1 = root.checkType; var instantiatedType = getMappedType(checkType_1, mapper); if (checkType_1 !== instantiatedType && instantiatedType.flags & (1048576 /* Union */ | 131072 /* Never */)) { - return mapType(instantiatedType, function (t) { return getConditionalType(root, prependTypeMapping(checkType_1, t, mapper)); }); + return mapTypeWithAlias(instantiatedType, function (t) { return getConditionalType(root, prependTypeMapping(checkType_1, t, mapper)); }, aliasSymbol, aliasTypeArguments); } } - return getConditionalType(root, mapper); + return getConditionalType(root, mapper, aliasSymbol, aliasTypeArguments); } function instantiateType(type, mapper) { - if (!(type && mapper && couldContainTypeVariables(type))) { + return type && mapper ? instantiateTypeWithAlias(type, mapper, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined) : type; + } + function instantiateTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments) { + if (!couldContainTypeVariables(type)) { return type; } if (instantiationDepth === 50 || instantiationCount >= 5000000) { // We have reached 50 recursive type instantiations and there is a very high likelyhood we're dealing // with a combination of infinite generic types that perpetually generate new type identities. We stop // the recursion here by yielding the error type. - 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" /* CheckTypes */, "instantiateType_DepthLimit", { typeId: type.id, instantiationDepth: instantiationDepth, instantiationCount: instantiationCount }); error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite); return errorType; } totalInstantiationCount++; instantiationCount++; instantiationDepth++; - var result = instantiateTypeWorker(type, mapper); + var result = instantiateTypeWorker(type, mapper, aliasSymbol, aliasTypeArguments); instantiationDepth--; return result; } - function instantiateTypeWorker(type, mapper) { + function instantiateTypeWorker(type, mapper, aliasSymbol, aliasTypeArguments) { var flags = type.flags; if (flags & 262144 /* TypeParameter */) { return getMappedType(type, mapper); @@ -57751,12 +59765,15 @@ var ts; if (flags & 524288 /* Object */) { var objectFlags = type.objectFlags; if (objectFlags & (4 /* Reference */ | 16 /* Anonymous */ | 32 /* Mapped */)) { - if (objectFlags & 4 /* Reference */ && !(type.node)) { + if (objectFlags & 4 /* Reference */ && !type.node) { var resolvedTypeArguments = type.resolvedTypeArguments; var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper); return newTypeArguments !== resolvedTypeArguments ? createNormalizedTypeReference(type.target, newTypeArguments) : type; } - return getObjectTypeInstantiation(type, mapper); + if (objectFlags & 1024 /* ReverseMapped */) { + return instantiateReverseMappedType(type, mapper); + } + return getObjectTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments); } return type; } @@ -57764,10 +59781,14 @@ var ts; var origin = type.flags & 1048576 /* Union */ ? type.origin : undefined; var types = origin && origin.flags & 3145728 /* UnionOrIntersection */ ? origin.types : type.types; var newTypes = instantiateTypes(types, mapper); - return newTypes === types ? type : - flags & 2097152 /* Intersection */ || origin && origin.flags & 2097152 /* Intersection */ ? - getIntersectionType(newTypes, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) : - getUnionType(newTypes, 1 /* Literal */, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, 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 */ ? + getIntersectionType(newTypes, newAliasSymbol, newAliasTypeArguments) : + getUnionType(newTypes, 1 /* Literal */, newAliasSymbol, newAliasTypeArguments); } if (flags & 4194304 /* Index */) { return getIndexType(instantiateType(type.type, mapper)); @@ -57779,10 +59800,12 @@ var ts; return getStringMappingType(type.symbol, instantiateType(type.type, mapper)); } if (flags & 8388608 /* IndexedAccess */) { - return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper), type.noUncheckedIndexedAccessCandidate, /*accessNode*/ undefined, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); + 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 */) { - return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper)); + return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper), aliasSymbol, aliasTypeArguments); } if (flags & 33554432 /* Substitution */) { var maybeVariable = instantiateType(type.baseType, mapper); @@ -57799,6 +59822,21 @@ var ts; } return type; } + function instantiateReverseMappedType(type, mapper) { + var innerMappedType = instantiateType(type.mappedType, mapper); + if (!(ts.getObjectFlags(innerMappedType) & 32 /* Mapped */)) { + return type; + } + var innerIndexType = instantiateType(type.constraintType, mapper); + if (!(innerIndexType.flags & 4194304 /* Index */)) { + return type; + } + var instantiated = inferTypeForHomomorphicMappedType(instantiateType(type.source, mapper), innerMappedType, innerIndexType); + if (instantiated) { + return instantiated; + } + return type; // Nested invocation of `inferTypeForHomomorphicMappedType` or the `source` instantiated into something unmappable + } function getPermissiveInstantiation(type) { return type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */) ? type : type.permissiveInstantiation || (type.permissiveInstantiation = instantiateType(type, permissiveMapper)); @@ -57825,35 +59863,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 !== 165 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 167 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: - case 251 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 253 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type return isContextSensitiveFunctionLikeDeclaration(node); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return (node.operatorToken.kind === 56 /* BarBarToken */ || node.operatorToken.kind === 60 /* QuestionQuestionToken */) && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return isContextSensitive(node.expression); - case 281 /* JsxAttributes */: + case 283 /* JsxAttributes */: return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive); - case 280 /* JsxAttribute */: { + case 282 /* 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 283 /* JsxExpression */: { + case 285 /* JsxExpression */: { // It is possible to that node.expression is undefined (e.g

) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -57872,7 +59910,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 209 /* ArrowFunction */) { + if (node.kind !== 211 /* 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); @@ -57885,7 +59923,7 @@ 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 !== 230 /* Block */ && isContextSensitive(node.body); + return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 232 /* Block */ && isContextSensitive(node.body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && @@ -57988,23 +60026,23 @@ var ts; return true; } switch (node.kind) { - case 283 /* JsxExpression */: - case 207 /* ParenthesizedExpression */: + case 285 /* JsxExpression */: + case 209 /* ParenthesizedExpression */: return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 62 /* EqualsToken */: + case 63 /* EqualsToken */: case 27 /* CommaToken */: return elaborateError(node.right, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); } break; - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 281 /* JsxAttributes */: + case 283 /* JsxAttributes */: return elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer); } return false; @@ -58105,7 +60143,14 @@ var ts; if (!targetPropType || targetPropType.flags & 8388608 /* IndexedAccess */) continue; // Don't elaborate on indexes on generic variables var sourcePropType = getIndexedAccessTypeOrUndefined(source, nameType); - if (sourcePropType && !checkTypeRelatedTo(sourcePropType, targetPropType, relation, /*errorNode*/ undefined)) { + if (!sourcePropType) + continue; + var propName = getPropertyNameFromIndex(nameType, /*accessNode*/ undefined); + var targetIsOptional = !!(propName && (getPropertyOfType(target, propName) || unknownSymbol).flags & 16777216 /* Optional */); + var sourceIsOptional = !!(propName && (getPropertyOfType(source, propName) || unknownSymbol).flags & 16777216 /* Optional */); + targetPropType = removeMissingType(targetPropType, targetIsOptional); + sourcePropType = removeMissingType(sourcePropType, targetIsOptional && sourceIsOptional); + if (!checkTypeRelatedTo(sourcePropType, targetPropType, relation, /*errorNode*/ undefined)) { var elaborated = next && elaborateError(next, sourcePropType, targetPropType, relation, /*headMessage*/ undefined, containingMessageChain, errorOutputContainer); if (elaborated) { reportedError = true; @@ -58204,7 +60249,7 @@ var ts; } function getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic) { switch (child.kind) { - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: // child is of the type of the expression return { errorNode: child, innerExpression: child.expression, nameType: nameType }; case 11 /* JsxText */: @@ -58213,9 +60258,9 @@ var ts; } // child is a string return { errorNode: child, innerExpression: undefined, nameType: nameType, errorMessage: getInvalidTextDiagnostic() }; - case 273 /* JsxElement */: - case 274 /* JsxSelfClosingElement */: - case 277 /* JsxFragment */: + case 275 /* JsxElement */: + case 276 /* JsxSelfClosingElement */: + case 279 /* JsxFragment */: // child is of type JSX.Element return { errorNode: child, innerExpression: child, nameType: nameType }; default: @@ -58363,11 +60408,11 @@ var ts; } _b = prop.kind; switch (_b) { - case 168 /* SetAccessor */: return [3 /*break*/, 2]; - case 167 /* GetAccessor */: return [3 /*break*/, 2]; - case 165 /* MethodDeclaration */: return [3 /*break*/, 2]; - case 289 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; - case 288 /* PropertyAssignment */: return [3 /*break*/, 4]; + case 170 /* SetAccessor */: return [3 /*break*/, 2]; + case 169 /* GetAccessor */: return [3 /*break*/, 2]; + case 167 /* MethodDeclaration */: return [3 /*break*/, 2]; + case 291 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 290 /* PropertyAssignment */: return [3 /*break*/, 4]; } return [3 /*break*/, 6]; case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; @@ -58444,8 +60489,8 @@ var ts; return 0 /* False */; } var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - var strictVariance = !(checkMode & 3 /* Callback */) && strictFunctionTypes && kind !== 165 /* MethodDeclaration */ && - kind !== 164 /* MethodSignature */ && kind !== 166 /* Constructor */; + var strictVariance = !(checkMode & 3 /* Callback */) && strictFunctionTypes && kind !== 167 /* MethodDeclaration */ && + kind !== 166 /* MethodSignature */ && kind !== 168 /* Constructor */; var result = -1 /* True */; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { @@ -58678,7 +60723,7 @@ var ts; // 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 */ || t & 256 /* NumberLiteral */ && t & 1024 /* EnumLiteral */)) + if (s & (8 /* Number */ | 256 /* NumberLiteral */) && !(s & 1024 /* EnumLiteral */) && (t & 32 /* Enum */ || relation === assignableRelation && t & 256 /* NumberLiteral */ && t & 1024 /* EnumLiteral */)) return true; } return false; @@ -58715,7 +60760,7 @@ var ts; return false; } function isIgnoredJsxProperty(source, sourceProp) { - return ts.getObjectFlags(source) & 4096 /* JsxAttributes */ && !isUnhyphenatedJsxName(sourceProp.escapedName); + return ts.getObjectFlags(source) & 2048 /* JsxAttributes */ && !isUnhyphenatedJsxName(sourceProp.escapedName); } function getNormalizedType(type, writing) { while (true) { @@ -58725,6 +60770,7 @@ var ts; type.flags & 33554432 /* Substitution */ ? writing ? type.baseType : type.substitute : type.flags & 25165824 /* Simplifiable */ ? getSimplifiedType(type, writing) : type; + t = getSingleBaseForNonAugmentingSubtype(t) || t; if (t === type) break; type = t; @@ -58762,7 +60808,7 @@ var ts; reportIncompatibleStack(); } if (overflow) { - ts.tracing.instant("checkTypes" /* CheckTypes */, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: depth }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: depth }); 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); @@ -58898,6 +60944,14 @@ var ts; } break; } + case ts.Diagnostics.Type_at_position_0_in_source_is_not_compatible_with_type_at_position_1_in_target.code: { + secondaryRootErrors.unshift([ts.Diagnostics.Type_at_position_0_in_source_is_not_compatible_with_type_at_position_1_in_target, args[0], args[1]]); + break; + } + case ts.Diagnostics.Type_at_positions_0_through_1_in_source_is_not_compatible_with_type_at_position_2_in_target.code: { + secondaryRootErrors.unshift([ts.Diagnostics.Type_at_positions_0_through_1_in_source_is_not_compatible_with_type_at_position_2_in_target, args[0], args[1], args[2]]); + break; + } default: return ts.Debug.fail("Unhandled Diagnostic: " + msg.code); } @@ -58958,6 +61012,7 @@ var ts; reportError(ts.Diagnostics._0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2, needsOriginalSource ? sourceType : generalizedSourceType, targetType, typeToString(constraint)); } else { + errorInfo = undefined; reportError(ts.Diagnostics._0_could_be_instantiated_with_an_arbitrary_type_which_could_be_unrelated_to_1, targetType, generalizedSourceType); } } @@ -59033,7 +61088,7 @@ var ts; if (isSimpleTypeRelatedTo(originalSource, originalTarget, relation, reportErrors ? reportError : undefined)) { return -1 /* True */; } - reportErrorResults(originalSource, originalTarget, 0 /* False */, !!(ts.getObjectFlags(originalSource) & 4096 /* JsxAttributes */)); + reportErrorResults(originalSource, originalTarget, 0 /* False */, !!(ts.getObjectFlags(originalSource) & 2048 /* JsxAttributes */)); return 0 /* False */; } // Normalize the source and target types: Turn fresh literal types into regular literal types, @@ -59068,16 +61123,16 @@ var ts; target.types.length <= 3 && maybeTypeOfKind(target, 98304 /* Nullable */)) { var nullStrippedTarget = extractTypesOfKind(target, ~98304 /* Nullable */); if (!(nullStrippedTarget.flags & (1048576 /* Union */ | 131072 /* Never */))) { - if (source === nullStrippedTarget) - return -1 /* True */; - target = nullStrippedTarget; + target = getNormalizedType(nullStrippedTarget, /*writing*/ true); } + if (source === nullStrippedTarget) + return -1 /* True */; } if (relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return -1 /* True */; - var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096 /* JsxAttributes */); - var isPerformingExcessPropertyChecks = !(intersectionState & 2 /* Target */) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 32768 /* FreshLiteral */); + var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* JsxAttributes */); + var isPerformingExcessPropertyChecks = !(intersectionState & 2 /* Target */) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 16384 /* FreshLiteral */); if (isPerformingExcessPropertyChecks) { if (hasExcessProperties(source, target, reportErrors)) { if (reportErrors) { @@ -59162,7 +61217,7 @@ var ts; // We suppress recursive intersection property checks because they can generate lots of work when relating // recursive intersections that are structurally similar but not exactly identical. See #37854. if (result && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) || - isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 2097152 /* NonInferrableType */); }))) { + isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 524288 /* NonInferrableType */); }))) { inPropertyCheck = true; result &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */); inPropertyCheck = false; @@ -59171,8 +61226,10 @@ var ts; return result; function reportErrorResults(source, target, result, isComparingJsxAttributes) { if (!result && reportErrors) { - source = originalSource.aliasSymbol ? originalSource : source; - target = originalTarget.aliasSymbol ? originalTarget : target; + var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource); + var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget); + source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source; + target = (originalTarget.aliasSymbol || targetHasBase) ? originalTarget : target; var maybeSuppress = overrideNextErrorInfo > 0; if (maybeSuppress) { overrideNextErrorInfo--; @@ -59213,13 +61270,13 @@ var ts; } } function traceUnionsOrIntersectionsTooLarge(source, target) { - if (!ts.tracing.isTracing()) { + if (!ts.tracing) { return; } if ((source.flags & 3145728 /* UnionOrIntersection */) && (target.flags & 3145728 /* UnionOrIntersection */)) { var sourceUnionOrIntersection = source; var targetUnionOrIntersection = target; - if (sourceUnionOrIntersection.objectFlags & targetUnionOrIntersection.objectFlags & 262144 /* PrimitiveUnion */) { + if (sourceUnionOrIntersection.objectFlags & targetUnionOrIntersection.objectFlags & 65536 /* PrimitiveUnion */) { // There's a fast path for comparing primitive unions return; } @@ -59244,11 +61301,11 @@ var ts; } traceUnionsOrIntersectionsTooLarge(source, target); if (flags & 3145728 /* UnionOrIntersection */) { - var result_6 = eachTypeRelatedToSomeType(source, target); - if (result_6) { - result_6 &= eachTypeRelatedToSomeType(target, source); + var result_7 = eachTypeRelatedToSomeType(source, target); + if (result_7) { + result_7 &= eachTypeRelatedToSomeType(target, source); } - return result_6; + return result_7; } return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None */); } @@ -59262,10 +61319,11 @@ var ts; return getUnionType(ts.reduceLeft(types, appendPropType, /*initial*/ undefined) || ts.emptyArray); } function hasExcessProperties(source, target, reportErrors) { - if (!isExcessPropertyCheckTarget(target) || !noImplicitAny && ts.getObjectFlags(target) & 16384 /* JSLiteral */) { + var _a; + if (!isExcessPropertyCheckTarget(target) || !noImplicitAny && ts.getObjectFlags(target) & 8192 /* 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) & 4096 /* JsxAttributes */); + var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* JsxAttributes */); if ((relation === assignableRelation || relation === comparableRelation) && (isTypeSubsetOf(globalObjectType, target) || (!isComparingJsxAttributes && isEmptyObjectType(target)))) { return false; @@ -59308,7 +61366,7 @@ var ts; } else { // use the property's value declaration if the property is assigned inside the literal itself - var objectLiteralDeclaration_1 = source.symbol && ts.firstOrUndefined(source.symbol.declarations); + var objectLiteralDeclaration_1 = ((_a = source.symbol) === null || _a === void 0 ? void 0 : _a.declarations) && ts.firstOrUndefined(source.symbol.declarations); var suggestion = void 0; if (prop.valueDeclaration && ts.findAncestor(prop.valueDeclaration, function (d) { return d === objectLiteralDeclaration_1; }) && ts.getSourceFileOfNode(objectLiteralDeclaration_1) === ts.getSourceFileOfNode(errorNode)) { var propDeclaration = prop.valueDeclaration; @@ -59337,11 +61395,11 @@ var ts; } } }; - for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) { - var prop = _a[_i]; - var state_4 = _loop_16(prop); - if (typeof state_4 === "object") - return state_4.value; + for (var _i = 0, _b = getPropertiesOfType(source); _i < _b.length; _i++) { + var prop = _b[_i]; + var state_5 = _loop_16(prop); + if (typeof state_5 === "object") + return state_5.value; } return false; } @@ -59363,8 +61421,17 @@ var ts; } function typeRelatedToSomeType(source, target, reportErrors) { var targetTypes = target.types; - if (target.flags & 1048576 /* Union */ && containsType(targetTypes, source)) { - return -1 /* True */; + if (target.flags & 1048576 /* Union */) { + if (containsType(targetTypes, source)) { + return -1 /* True */; + } + var match = getMatchingUnionConstituentForType(target, source); + if (match) { + var related = isRelatedTo(source, match, /*reportErrors*/ false); + if (related) { + return related; + } + } } for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { var type = targetTypes_1[_i]; @@ -59538,9 +61605,16 @@ var ts; targetStack = []; } else { + // generate a key where all type parameter id positions are replaced with unconstrained type parameter ids + // this isn't perfect - nested type references passed as type arguments will muck up the indexes and thus + // prevent finding matches- but it should hit up the common cases + var broadestEquivalentId = id.split(",").map(function (i) { return i.replace(/-\d+/g, function (_match, offset) { + var index = ts.length(id.slice(0, offset).match(/[-=]/g) || undefined); + return "=" + index; + }); }).join(","); for (var i = 0; i < maybeCount; i++) { // If source and target are already being compared, consider them related with assumptions - if (id === maybeKeys[i]) { + if (id === maybeKeys[i] || broadestEquivalentId === maybeKeys[i]) { return 3 /* Maybe */; } } @@ -59570,7 +61644,7 @@ var ts; }; } if (expandingFlags === 3 /* Both */) { - ts.tracing.instant("checkTypes" /* CheckTypes */, "recursiveTypeRelatedTo_DepthLimit", { + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "recursiveTypeRelatedTo_DepthLimit", { sourceId: source.id, sourceIdStack: sourceStack.map(function (t) { return t.id; }), targetId: target.id, @@ -59605,9 +61679,9 @@ var ts; return result; } function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) { - 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" /* CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id }); var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; } function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState) { @@ -59629,8 +61703,21 @@ var ts; if (target.flags & 2097152 /* Intersection */) { return typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2 /* Target */); } - // Source is an intersection. Check to see if any constituents of the intersection are immediately related - // to the 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 */) { + var constraints = ts.sameMap(source.types, function (t) { return t.flags & 131068 /* Primitive */ ? t : getBaseConstraintOfType(t) || unknownType; }); + if (constraints !== source.types) { + source = getIntersectionType(constraints); + if (!(source.flags & 2097152 /* Intersection */)) { + return isRelatedTo(source, target, /*reportErrors*/ false); + } + } + } + // Check to see if any constituents of the intersection are immediately related to the target. // // Don't report errors though. Checking whether a constituent is related to the source is not actually // useful and leads to some confusing error messages. Instead it is better to let the below checks @@ -59650,21 +61737,21 @@ var ts; if (flags & 4194304 /* Index */) { return isRelatedTo(source.type, target.type, /*reportErrors*/ false); } - var result_7 = 0 /* False */; + var result_8 = 0 /* False */; if (flags & 8388608 /* IndexedAccess */) { - if (result_7 = isRelatedTo(source.objectType, target.objectType, /*reportErrors*/ false)) { - if (result_7 &= isRelatedTo(source.indexType, target.indexType, /*reportErrors*/ false)) { - return result_7; + if (result_8 = isRelatedTo(source.objectType, target.objectType, /*reportErrors*/ false)) { + if (result_8 &= isRelatedTo(source.indexType, target.indexType, /*reportErrors*/ false)) { + return result_8; } } } if (flags & 16777216 /* Conditional */) { if (source.root.isDistributive === target.root.isDistributive) { - if (result_7 = isRelatedTo(source.checkType, target.checkType, /*reportErrors*/ false)) { - if (result_7 &= isRelatedTo(source.extendsType, target.extendsType, /*reportErrors*/ false)) { - if (result_7 &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), /*reportErrors*/ false)) { - if (result_7 &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), /*reportErrors*/ false)) { - return result_7; + if (result_8 = isRelatedTo(source.checkType, target.checkType, /*reportErrors*/ false)) { + if (result_8 &= isRelatedTo(source.extendsType, target.extendsType, /*reportErrors*/ false)) { + if (result_8 &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), /*reportErrors*/ false)) { + if (result_8 &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), /*reportErrors*/ false)) { + return result_8; } } } @@ -59744,6 +61831,20 @@ var ts; } } else if (target.flags & 8388608 /* IndexedAccess */) { + if (source.flags & 8388608 /* 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, reportErrors)) { + result &= isRelatedTo(source.indexType, target.indexType, reportErrors); + } + if (result) { + resetErrorInfo(saveErrorInfo); + return result; + } + if (reportErrors) { + originalErrorInfo = errorInfo; + } + } // A type S is related to a type T[K] if S is related to C, where C is the base // constraint of T[K] for writing. if (relation === assignableRelation || relation === comparableRelation) { @@ -59752,13 +61853,26 @@ var ts; var baseObjectType = getBaseConstraintOfType(objectType) || objectType; var baseIndexType = getBaseConstraintOfType(indexType) || indexType; if (!isGenericObjectType(baseObjectType) && !isGenericIndexType(baseIndexType)) { - var accessFlags = 2 /* Writing */ | (baseObjectType !== objectType ? 1 /* NoIndexSignatures */ : 0); - var constraint = getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, target.noUncheckedIndexedAccessCandidate, /*accessNode*/ undefined, accessFlags); - if (constraint && (result = isRelatedTo(source, constraint, reportErrors))) { - return result; + var accessFlags = 4 /* Writing */ | (baseObjectType !== objectType ? 2 /* 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, reportErrors)) { + return result; + } + // prefer the shorter chain of the constraint comparison chain, and the direct comparison chain + if (reportErrors && originalErrorInfo && errorInfo) { + errorInfo = countMessageChainBreadth([originalErrorInfo]) <= countMessageChainBreadth([errorInfo]) ? originalErrorInfo : errorInfo; + } } } } + if (reportErrors) { + originalErrorInfo = undefined; + } } else if (isGenericMappedType(target) && !target.declaration.nameType) { // A source type T is related to a target type { [P in X]: T[P] } @@ -59802,27 +61916,48 @@ var ts; } } } - else if (target.flags & 134217728 /* TemplateLiteral */ && source.flags & 128 /* StringLiteral */) { - if (isPatternLiteralType(target)) { - // match all non-`string` segments - var result_8 = inferLiteralsFromTemplateLiteralType(source, target); - if (result_8 && ts.every(result_8, function (r, i) { return isStringLiteralTypeValueParsableAsType(r, target.types[i]); })) { - return -1 /* True */; - } + else if (target.flags & 16777216 /* Conditional */) { + var c = target; + // Check if the conditional is always true or always false but still deferred for distribution purposes + var skipTrue = !isTypeAssignableTo(getPermissiveInstantiation(c.checkType), getPermissiveInstantiation(c.extendsType)); + var skipFalse = !skipTrue && isConditionalTypeAlwaysTrueDisregardingInferTypes(c); + // Instantiate with a replacement mapper if the conditional is distributive, replacing the check type with a clone of itself, + // this way {x: string | number, y: string | number} -> (T extends T ? { x: T, y: T } : never) appropriately _fails_ when + // T = string | number (since that will end up distributing and producing `{x: string, y: string} | {x: number, y: number}`, + // to which `{x: string | number, y: string | number}` isn't assignable) + var distributionMapper = void 0; + var checkVar = getActualTypeVariable(c.root.checkType); + if (c.root.isDistributive && checkVar.flags & 262144 /* TypeParameter */) { + var newParam = cloneTypeParameter(checkVar); + distributionMapper = prependTypeMapping(checkVar, newParam, c.mapper); + newParam.mapper = distributionMapper; + } + // TODO: Find a nice way to include potential conditional type breakdowns in error output, if they seem good (they usually don't) + var localResult = void 0; + if (skipTrue || (localResult = isRelatedTo(source, distributionMapper ? instantiateType(getTypeFromTypeNode(c.root.node.trueType), distributionMapper) : getTrueTypeFromConditionalType(c), /*reportErrors*/ false))) { + if (!skipFalse) { + localResult = (localResult || 3 /* Maybe */) & isRelatedTo(source, distributionMapper ? instantiateType(getTypeFromTypeNode(c.root.node.falseType), distributionMapper) : getFalseTypeFromConditionalType(c), /*reportErrors*/ false); + } + } + if (localResult) { + resetErrorInfo(saveErrorInfo); + return localResult; } } - if (source.flags & 8650752 /* TypeVariable */) { - if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) { - // 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, reportErrors)) { - result &= isRelatedTo(source.indexType, target.indexType, reportErrors); - } - if (result) { - resetErrorInfo(saveErrorInfo); - return result; - } + else if (target.flags & 134217728 /* TemplateLiteral */) { + if (source.flags & 134217728 /* TemplateLiteral */) { + // 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)); } - else { + var result_9 = inferTypesFromTemplateLiteralType(source, target); + if (result_9 && ts.every(result_9, function (r, i) { return isValidTypeForTemplateLiteralPlaceholder(r, target.types[i]); })) { + return -1 /* True */; + } + } + if (source.flags & 8650752 /* TypeVariable */) { + // IndexedAccess comparisons are handled above in the `target.flags & TypeFlage.IndexedAccess` branch + if (!(source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */)) { var constraint = getConstraintOfType(source); if (!constraint || (source.flags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) { // A type variable with no constraint is not related to the non-primitive object type. @@ -59837,7 +61972,7 @@ var ts; 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, reportErrors, /*headMessage*/ undefined, intersectionState)) { + else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, reportErrors && !(target.flags & source.flags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) { resetErrorInfo(saveErrorInfo); return result; } @@ -59850,17 +61985,10 @@ var ts; } } else if (source.flags & 134217728 /* TemplateLiteral */) { - if (target.flags & 134217728 /* TemplateLiteral */) { - if (source.texts.length === target.texts.length && - source.types.length === target.types.length && - ts.every(source.texts, function (t, i) { return t === target.texts[i]; }) && - ts.every(instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)).types, function (t, i) { return !!(target.types[i].flags & (1 /* Any */ | 4 /* String */)) || !!isRelatedTo(t, target.types[i], /*reportErrors*/ false); })) { - return -1 /* True */; - } - } - else { - var constraint = getBaseConstraintOfType(source); - if (result = isRelatedTo(constraint && constraint !== source ? constraint : stringType, target, reportErrors)) { + if (!(target.flags & 134217728 /* TemplateLiteral */)) { + var baseConstraint = getBaseConstraintOfType(source); + var constraint = baseConstraint && baseConstraint !== source ? baseConstraint : stringType; + if (result = isRelatedTo(constraint, target, reportErrors)) { resetErrorInfo(saveErrorInfo); return result; } @@ -59892,7 +62020,7 @@ var ts; 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 */, isRelatedTo); - inferTypes(ctx.inferences, target.extendsType, sourceExtends, 256 /* NoConstraints */ | 512 /* AlwaysStrict */); + inferTypes(ctx.inferences, target.extendsType, sourceExtends, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */); sourceExtends = instantiateType(sourceExtends, ctx.mapper); mapper = ctx.mapper; } @@ -59950,7 +62078,7 @@ var ts; return 0 /* False */; } if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && source.target === target.target && - !(ts.getObjectFlags(source) & 8192 /* MarkerType */ || ts.getObjectFlags(target) & 8192 /* MarkerType */)) { + !(ts.getObjectFlags(source) & 4096 /* MarkerType */ || ts.getObjectFlags(target) & 4096 /* MarkerType */)) { // 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 // information for the type parameters and relate the type arguments accordingly. @@ -59978,7 +62106,7 @@ var ts; } // 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) & 32768 /* FreshLiteral */ && !isEmptyObjectType(source)) { + else if ((relation === subtypeRelation || relation === strictSubtypeRelation) && isEmptyObjectType(target) && ts.getObjectFlags(target) & 16384 /* FreshLiteral */ && !isEmptyObjectType(source)) { return 0 /* False */; } // Even if relationship doesn't hold for unions, intersections, or generic type references, @@ -60016,14 +62144,19 @@ var ts; if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */) && target.flags & 1048576 /* Union */) { var objectOnlyTarget = extractTypesOfKind(target, 524288 /* Object */ | 2097152 /* Intersection */ | 33554432 /* Substitution */); if (objectOnlyTarget.flags & 1048576 /* Union */) { - var result_9 = typeRelatedToDiscriminatedType(source, objectOnlyTarget); - if (result_9) { - return result_9; + var result_10 = typeRelatedToDiscriminatedType(source, objectOnlyTarget); + if (result_10) { + return result_10; } } } } return 0 /* False */; + function countMessageChainBreadth(info) { + if (!info) + return 0; + return ts.reduceLeft(info, function (value, chain) { return value + 1 + countMessageChainBreadth(chain.next); }, 0); + } function relateVariances(sourceTypeArguments, targetTypeArguments, variances, intersectionState) { if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors, intersectionState)) { return result; @@ -60085,13 +62218,13 @@ var ts; var modifiersRelated = relation === comparableRelation || (relation === identityRelation ? getMappedTypeModifiers(source) === getMappedTypeModifiers(target) : getCombinedMappedTypeOptionality(source) <= getCombinedMappedTypeOptionality(target)); if (modifiersRelated) { - var result_10; + var result_11; var targetConstraint = getConstraintTypeFromMappedType(target); var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), makeFunctionTypeMapper(getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMarkers : reportUnreliableMarkers)); - if (result_10 = isRelatedTo(targetConstraint, sourceConstraint, reportErrors)) { + if (result_11 = isRelatedTo(targetConstraint, sourceConstraint, 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), reportErrors); + return result_11 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), reportErrors); } } } @@ -60119,10 +62252,10 @@ var ts; var numCombinations = 1; for (var _i = 0, sourcePropertiesFiltered_1 = sourcePropertiesFiltered; _i < sourcePropertiesFiltered_1.length; _i++) { var sourceProperty = sourcePropertiesFiltered_1[_i]; - numCombinations *= countTypes(getTypeOfSymbol(sourceProperty)); + numCombinations *= countTypes(getNonMissingTypeOfSymbol(sourceProperty)); if (numCombinations > 25) { // We've reached the complexity limit. - ts.tracing.instant("checkTypes" /* CheckTypes */, "typeRelatedToDiscriminatedType_DepthLimit", { sourceId: source.id, targetId: target.id, numCombinations: numCombinations }); + 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 */; } } @@ -60131,7 +62264,7 @@ var ts; var excludedProperties = new ts.Set(); for (var i = 0; i < sourcePropertiesFiltered.length; i++) { var sourceProperty = sourcePropertiesFiltered[i]; - var sourcePropertyType = getTypeOfSymbol(sourceProperty); + var sourcePropertyType = getNonMissingTypeOfSymbol(sourceProperty); sourceDiscriminantTypes[i] = sourcePropertyType.flags & 1048576 /* Union */ ? sourcePropertyType.types : [sourcePropertyType]; @@ -60161,8 +62294,8 @@ var ts; } }; for (var i = 0; i < sourcePropertiesFiltered.length; i++) { - var state_6 = _loop_18(i); - switch (state_6) { + var state_7 = _loop_18(i); + switch (state_7) { case "continue-outer": continue outer; } } @@ -60175,9 +62308,9 @@ var ts; }; for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) { var combination = discriminantCombinations_1[_a]; - var state_5 = _loop_17(combination); - if (typeof state_5 === "object") - return state_5.value; + var state_6 = _loop_17(combination); + if (typeof state_6 === "object") + return state_6.value; } // Compare the remaining non-discriminant properties of each match. var result = -1 /* True */; @@ -60224,46 +62357,9 @@ var ts; } function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState) { var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* Partial */); - var source = getTypeOfSourceProperty(sourceProp); - if (ts.getCheckFlags(targetProp) & 65536 /* DeferredType */ && !getSymbolLinks(targetProp).type) { - // Rather than resolving (and normalizing) the type, relate constituent-by-constituent without performing normalization or seconadary passes - var links = getSymbolLinks(targetProp); - ts.Debug.assertIsDefined(links.deferralParent); - ts.Debug.assertIsDefined(links.deferralConstituents); - var unionParent = !!(links.deferralParent.flags & 1048576 /* Union */); - var result_11 = unionParent ? 0 /* False */ : -1 /* True */; - var targetTypes = links.deferralConstituents; - for (var _i = 0, targetTypes_3 = targetTypes; _i < targetTypes_3.length; _i++) { - var targetType = targetTypes_3[_i]; - var related = isRelatedTo(source, targetType, /*reportErrors*/ false, /*headMessage*/ undefined, unionParent ? 0 : 2 /* Target */); - if (!unionParent) { - if (!related) { - // Can't assign to a target individually - have to fallback to assigning to the _whole_ intersection (which forces normalization) - return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); - } - result_11 &= related; - } - else { - if (related) { - return related; - } - } - } - if (unionParent && !result_11 && targetIsOptional) { - result_11 = isRelatedTo(source, undefinedType); - } - if (unionParent && !result_11 && reportErrors) { - // The easiest way to get the right errors here is to un-defer (which may be costly) - // If it turns out this is too costly too often, we can replicate the error handling logic within - // typeRelatedToSomeType without the discriminatable type branch (as that requires a manifest union - // type on which to hand discriminable properties, which we are expressly trying to avoid here) - return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); - } - return result_11; - } - else { - return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors, /*headMessage*/ undefined, intersectionState); - } + var effectiveTarget = addOptionality(getNonMissingTypeOfSymbol(targetProp), /*isProperty*/ false, targetIsOptional); + var effectiveSource = getTypeOfSourceProperty(sourceProp); + return isRelatedTo(effectiveSource, effectiveTarget, reportErrors, /*headMessage*/ undefined, intersectionState); } function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState, skipOptional) { var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp); @@ -60392,7 +62488,7 @@ var ts; } return 0 /* False */; } - if (!targetRestFlag && sourceRestFlag) { + if (!targetRestFlag && (sourceRestFlag || targetArity < sourceArity)) { if (reportErrors) { if (sourceMinLength < targetMinLength) { reportError(ts.Diagnostics.Target_requires_0_element_s_but_source_may_have_fewer, targetMinLength); @@ -60440,10 +62536,11 @@ var ts; } } var sourceType = !isTupleType(source) ? sourceTypeArguments[0] : - i < startCount || i >= targetArity - endCount ? sourceTypeArguments[sourceIndex] : + i < startCount || i >= targetArity - endCount ? removeMissingType(sourceTypeArguments[sourceIndex], !!(sourceFlags & targetFlags & 2 /* Optional */)) : getElementTypeOfSliceOfTupleType(source, startCount, endCount) || neverType; var targetType = targetTypeArguments[i]; - var targetCheckType = sourceFlags & 8 /* Variadic */ && targetFlags & 4 /* Rest */ ? createArrayType(targetType) : targetType; + var targetCheckType = sourceFlags & 8 /* Variadic */ && targetFlags & 4 /* Rest */ ? createArrayType(targetType) : + removeMissingType(targetType, !!(targetFlags & 2 /* Optional */)); var related = isRelatedTo(sourceType, targetCheckType, reportErrors, /*headMessage*/ undefined, intersectionState); if (!related) { if (reportErrors) { @@ -60477,7 +62574,7 @@ var ts; var sourceProp = _a[_i]; if (!getPropertyOfObjectType(target, sourceProp.escapedName)) { var sourceType = getTypeOfSymbol(sourceProp); - if (!(sourceType === undefinedType || sourceType === undefinedWideningType || sourceType === optionalType)) { + if (!(sourceType.flags & 32768 /* Undefined */)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(sourceProp), typeToString(target)); } @@ -60496,7 +62593,7 @@ var ts; if (!(targetProp.flags & 4194304 /* Prototype */) && (!numericNamesOnly || isNumericLiteralName(name) || name === "length")) { var sourceProp = getPropertyOfType(source, name); if (sourceProp && sourceProp !== targetProp) { - var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, intersectionState, relation === comparableRelation); + var related = propertyRelatedTo(source, target, sourceProp, targetProp, getNonMissingTypeOfSymbol, reportErrors, intersectionState, relation === comparableRelation); if (!related) { return 0 /* False */; } @@ -60590,7 +62687,7 @@ var ts; 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) === 166 /* Constructor */ || ((_b = sourceSignature.declaration) === null || _b === void 0 ? void 0 : _b.kind) === 166 /* Constructor */)) { + (((_a = targetSignature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 168 /* Constructor */ || ((_b = sourceSignature.declaration) === null || _b === void 0 ? void 0 : _b.kind) === 168 /* Constructor */)) { var constructSignatureToString = function (signature) { return signatureToString(signature, /*enclosingDeclaration*/ undefined, 262144 /* WriteArrowStyleSignature */, kind); }; @@ -60698,10 +62795,17 @@ var ts; return indexTypesIdenticalTo(source, target, kind); } var targetType = getIndexTypeOfType(target, kind); - if (!targetType || targetType.flags & 1 /* Any */ && !sourceIsPrimitive) { - // Index signature of type any permits assignment from everything but primitives + if (!targetType) { return -1 /* True */; } + if (targetType.flags & 1 /* Any */ && !sourceIsPrimitive) { + // An index signature of type `any` permits assignment from everything but primitives, + // provided that there is also a `string` index signature of type `any`. + var stringIndexType = kind === 0 /* String */ ? targetType : getIndexTypeOfType(target, 0 /* String */); + if (stringIndexType && stringIndexType.flags & 1 /* Any */) { + return -1 /* True */; + } + } if (isGenericMappedType(source)) { // A generic mapped type { [P in K]: T } is related to a type with an index signature // { [x: string]: U }, and optionally with an index signature { [x: number]: V }, @@ -60856,7 +62960,7 @@ var ts; // type, and flag the result as a marker type reference. function getMarkerTypeReference(type, source, target) { var result = createTypeReference(type, ts.map(type.typeParameters, function (t) { return t === source ? target : t; })); - result.objectFlags |= 8192 /* MarkerType */; + result.objectFlags |= 4096 /* MarkerType */; return result; } function getAliasVariances(symbol) { @@ -60877,7 +62981,7 @@ var ts; if (typeParameters === void 0) { typeParameters = ts.emptyArray; } var variances = cache.variances; if (!variances) { - ts.tracing.push("checkTypes" /* CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: (_c = (_a = cache.id) !== null && _a !== void 0 ? _a : (_b = cache.declaredType) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : -1 }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: (_c = (_a = cache.id) !== null && _a !== void 0 ? _a : (_b = cache.declaredType) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : -1 }); // The emptyArray singleton is used to signal a recursive invocation. cache.variances = ts.emptyArray; variances = []; @@ -60916,7 +63020,7 @@ var ts; _loop_19(tp); } cache.variances = variances; - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } return variances; } @@ -60944,7 +63048,7 @@ var ts; return !!(ts.getObjectFlags(type) & 4 /* Reference */) && !type.node; } function isTypeReferenceWithGenericArguments(type) { - return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); + return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return !!(t.flags & 262144 /* TypeParameter */) || isTypeReferenceWithGenericArguments(t); }); } /** * getTypeReferenceId(A) returns "111=0-12=1" @@ -61030,8 +63134,8 @@ var ts; } // 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) { - return forEachProperty(prop, function (p) { return ts.getDeclarationModifierFlagsFromSymbol(p) & 16 /* Protected */ ? + function isClassDerivedFromDeclaringClasses(checkClass, prop, writing) { + return forEachProperty(prop, function (p) { return ts.getDeclarationModifierFlagsFromSymbol(p, writing) & 16 /* 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 @@ -61049,23 +63153,26 @@ var ts; function isDeeplyNestedType(type, stack, depth) { if (depth >= 5) { var identity_1 = getRecursionIdentity(type); - if (identity_1) { - var count = 0; - for (var i = 0; i < depth; i++) { - if (getRecursionIdentity(stack[i]) === identity_1) { - count++; - if (count >= 5) { - return true; - } + var count = 0; + for (var i = 0; i < depth; i++) { + if (getRecursionIdentity(stack[i]) === identity_1) { + count++; + if (count >= 5) { + return true; } } } } return false; } - // Types with constituents that could circularly reference the type have a recursion identity. The recursion - // identity is some object that is common to instantiations of the type with the same origin. + // The recursion identity of a type is an object identity that is shared among multiple instantiations of the type. + // We track recursion identities in order to identify deeply nested and possibly infinite type instantiations with + // the same origin. For example, when type parameters are in scope in an object type such as { x: T }, all + // instantiations of that type have the same recursion identity. The default recursion identity is the object + // identity of the type, meaning that every type is unique. Generally, types with constituents that could circularly + // 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) { // Deferred type references are tracked through their associated AST node. This gives us finer @@ -61083,6 +63190,9 @@ var ts; return type.target; } } + if (type.flags & 262144 /* TypeParameter */) { + return type.symbol; + } if (type.flags & 8388608 /* IndexedAccess */) { // Identity is the leftmost object type in a chain of indexed accesses, eg, in A[P][Q] it is A do { @@ -61094,7 +63204,7 @@ var ts; // The root object represents the origin of the conditional type return type.root; } - return undefined; + return type; } function isPropertyIdenticalTo(sourceProp, targetProp) { return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0 /* False */; @@ -61233,6 +63343,9 @@ var ts; // 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; }); @@ -61267,9 +63380,35 @@ var ts; // 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); } + function getSingleBaseForNonAugmentingSubtype(type) { + if (!(ts.getObjectFlags(type) & 4 /* Reference */) || !(ts.getObjectFlags(type.target) & 3 /* ClassOrInterface */)) { + return undefined; + } + if (ts.getObjectFlags(type) & 33554432 /* IdenticalBaseTypeCalculated */) { + return ts.getObjectFlags(type) & 67108864 /* IdenticalBaseTypeExists */ ? type.cachedEquivalentBaseType : undefined; + } + type.objectFlags |= 33554432 /* IdenticalBaseTypeCalculated */; + var target = type.target; + var bases = getBaseTypes(target); + if (bases.length !== 1) { + return undefined; + } + if (getMembersOfSymbol(type.symbol).size) { + return undefined; // If the interface has any members, they may subtype members in the base, so we should do a full structural comparison + } + var instantiatedBase = !ts.length(target.typeParameters) ? bases[0] : instantiateType(bases[0], createTypeMapper(target.typeParameters, getTypeArguments(type).slice(0, target.typeParameters.length))); + if (ts.length(getTypeArguments(type)) > ts.length(target.typeParameters)) { + instantiatedBase = getTypeWithThisArgument(instantiatedBase, ts.last(getTypeArguments(type))); + } + type.objectFlags |= 67108864 /* IdenticalBaseTypeExists */; + return type.cachedEquivalentBaseType = instantiatedBase; + } + function isEmptyLiteralType(type) { + return strictNullChecks ? type === implicitNeverType : type === undefinedWideningType; + } function isEmptyArrayLiteralType(type) { - var elementType = isArrayType(type) ? getTypeArguments(type)[0] : undefined; - return elementType === undefinedWideningType || elementType === implicitNeverType; + var elementType = getElementTypeOfArrayType(type); + return !!elementType && isEmptyLiteralType(elementType); } function isTupleLikeType(type) { return isTupleType(type) || !!getPropertyOfType(type, "0"); @@ -61293,6 +63432,13 @@ var ts; function isUnitType(type) { return !!(type.flags & 109440 /* Unit */); } + function isUnitLikeType(type) { + return type.flags & 2097152 /* Intersection */ ? ts.some(type.types, isUnitType) : + !!(type.flags & 109440 /* Unit */); + } + function extractUnitType(type) { + return type.flags & 2097152 /* 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) : @@ -61300,7 +63446,7 @@ var ts; } function getBaseTypeOfLiteralType(type) { return type.flags & 1024 /* EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : - type.flags & 134217856 /* StringLikeLiteral */ ? stringType : + type.flags & 128 /* StringLiteral */ ? stringType : type.flags & 256 /* NumberLiteral */ ? numberType : type.flags & 2048 /* BigIntLiteral */ ? bigintType : type.flags & 512 /* BooleanLiteral */ ? booleanType : @@ -61309,7 +63455,7 @@ var ts; } function getWidenedLiteralType(type) { return type.flags & 1024 /* EnumLiteral */ && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(type) : - type.flags & 134217856 /* StringLikeLiteral */ && isFreshLiteralType(type) ? stringType : + 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 : @@ -61438,19 +63584,23 @@ var ts; missing === 65536 /* Null */ ? getUnionType([type, nullType]) : getUnionType([type, undefinedType, nullType]); } - function getOptionalType(type) { + function getOptionalType(type, isProperty) { + if (isProperty === void 0) { isProperty = false; } ts.Debug.assert(strictNullChecks); - return type.flags & 32768 /* Undefined */ ? type : getUnionType([type, undefinedType]); + return type.flags & 32768 /* Undefined */ ? type : getUnionType([type, isProperty ? missingType : undefinedType]); } function getGlobalNonNullableTypeInstantiation(type) { + // First reduce away any constituents that are assignable to 'undefined' or 'null'. This not only eliminates + // 'undefined' and 'null', but also higher-order types such as a type parameter 'U extends undefined | null' + // that isn't eliminated by a NonNullable instantiation. + var reducedType = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); if (!deferredGlobalNonNullableTypeAlias) { deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288 /* TypeAlias */, /*diagnostic*/ undefined) || unknownSymbol; } - // Use NonNullable global type alias if available to improve quick info/declaration emit - if (deferredGlobalNonNullableTypeAlias !== unknownSymbol) { - return getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]); - } - return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); // Type alias unavailable, fall back to non-higher-order behavior + // If the NonNullable type is available, return an instantiation. Otherwise just return the reduced type. + return deferredGlobalNonNullableTypeAlias !== unknownSymbol ? + getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [reducedType]) : + reducedType; } function getNonNullableType(type) { return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type; @@ -61472,6 +63622,12 @@ var ts; ts.isOptionalChain(expression) ? removeOptionalTypeMarker(exprType) : exprType; } + function removeMissingType(type, isOptional) { + return strictOptionalProperties && isOptional ? filterType(type, function (t) { return t !== missingType; }) : type; + } + function containsMissingType(type) { + return strictOptionalProperties && (type === missingType || type.flags & 1048576 /* Union */ && containsType(type.types, missingType)); + } /** * Is source potentially coercible to target type under `==`. * Assumes that `source` is a constituent of a union, hence @@ -61503,7 +63659,7 @@ var ts; function isObjectTypeWithInferableIndex(type) { return type.flags & 2097152 /* Intersection */ ? ts.every(type.types, isObjectTypeWithInferableIndex) : !!(type.symbol && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 && - !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 2048 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); + !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 1024 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); } function createSymbolWithType(source, type) { var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */); @@ -61536,7 +63692,7 @@ var ts; * Leave signatures alone since they are not subject to the check. */ function getRegularTypeOfObjectLiteral(type) { - if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 32768 /* FreshLiteral */)) { + if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 16384 /* FreshLiteral */)) { return type; } var regularType = type.regularType; @@ -61547,7 +63703,7 @@ var ts; var members = transformTypeOfMembers(type, getRegularTypeOfObjectLiteral); var regularNew = createAnonymousType(resolved.symbol, members, resolved.callSignatures, resolved.constructSignatures, resolved.stringIndexInfo, resolved.numberIndexInfo); regularNew.flags = resolved.flags; - regularNew.objectFlags |= resolved.objectFlags & ~32768 /* FreshLiteral */; + regularNew.objectFlags |= resolved.objectFlags & ~16384 /* FreshLiteral */; type.regularType = regularNew; return regularNew; } @@ -61577,7 +63733,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) & 1024 /* ContainsSpread */)) { + if (isObjectLiteralType(t) && !(ts.getObjectFlags(t) & 4194304 /* ContainsSpread */)) { for (var _b = 0, _c = getPropertiesOfType(t); _b < _c.length; _b++) { var prop = _c[_b]; names.set(prop.escapedName, prop); @@ -61604,7 +63760,7 @@ var ts; if (cached) { return cached; } - var result = createSymbolWithType(prop, undefinedType); + var result = createSymbolWithType(prop, missingType); result.flags |= 16777216 /* Optional */; undefinedProperties.set(prop.escapedName, result); return result; @@ -61626,14 +63782,14 @@ var ts; var stringIndexInfo = getIndexInfoOfType(type, 0 /* String */); var numberIndexInfo = getIndexInfoOfType(type, 1 /* Number */); var result = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, stringIndexInfo && createIndexInfo(getWidenedType(stringIndexInfo.type), stringIndexInfo.isReadonly), numberIndexInfo && createIndexInfo(getWidenedType(numberIndexInfo.type), numberIndexInfo.isReadonly)); - result.objectFlags |= (ts.getObjectFlags(type) & (16384 /* JSLiteral */ | 2097152 /* NonInferrableType */)); // Retain js literal flag through widening + result.objectFlags |= (ts.getObjectFlags(type) & (8192 /* JSLiteral */ | 524288 /* 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) & 1572864 /* RequiresWidening */) { + if (ts.getObjectFlags(type) & 393216 /* RequiresWidening */) { if (context === undefined && type.widened) { return type.widened; } @@ -61678,7 +63834,7 @@ var ts; */ function reportWideningErrorsInType(type) { var errorReported = false; - if (ts.getObjectFlags(type) & 524288 /* ContainsWideningType */) { + if (ts.getObjectFlags(type) & 131072 /* ContainsWideningType */) { if (type.flags & 1048576 /* Union */) { if (ts.some(type.types, isEmptyObjectType)) { errorReported = true; @@ -61704,7 +63860,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) & 524288 /* ContainsWideningType */) { + if (ts.getObjectFlags(t) & 131072 /* ContainsWideningType */) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, symbolToString(p), typeToString(getWidenedType(t))); } @@ -61723,12 +63879,12 @@ var ts; } var diagnostic; switch (declaration.kind) { - case 216 /* BinaryExpression */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 218 /* BinaryExpression */: + case 165 /* PropertyDeclaration */: + case 164 /* 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 160 /* Parameter */: + case 162 /* Parameter */: var param = declaration; if (ts.isIdentifier(param.name) && (ts.isCallSignatureDeclaration(param.parent) || ts.isMethodSignature(param.parent) || ts.isFunctionTypeNode(param.parent)) && @@ -61743,23 +63899,23 @@ 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 198 /* BindingElement */: + case 200 /* 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 308 /* JSDocFunctionType */: + case 311 /* JSDocFunctionType */: error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; - case 251 /* FunctionDeclaration */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 253 /* FunctionDeclaration */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: if (noImplicitAny && !declaration.name) { if (wideningKind === 3 /* 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); @@ -61773,7 +63929,7 @@ var ts; wideningKind === 3 /* 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 190 /* MappedType */: + case 192 /* MappedType */: if (noImplicitAny) { error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); } @@ -61784,7 +63940,7 @@ var ts; errorOrSuggestion(noImplicitAny, declaration, diagnostic, ts.declarationNameToString(ts.getNameOfDeclaration(declaration)), typeAsString); } function reportErrorsFromWidening(declaration, type, wideningKind) { - if (produceDiagnostics && noImplicitAny && ts.getObjectFlags(type) & 524288 /* ContainsWideningType */ && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) { + if (produceDiagnostics && noImplicitAny && ts.getObjectFlags(type) & 131072 /* ContainsWideningType */ && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) { // Report implicit any error within type if possible, otherwise report error on declaration if (!reportWideningErrorsInType(type)) { reportImplicitAny(declaration, type, wideningKind); @@ -61900,23 +64056,23 @@ var ts; // results for union and intersection types for performance reasons. function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); - if (objectFlags & 67108864 /* CouldContainTypeVariablesComputed */) { - return !!(objectFlags & 134217728 /* CouldContainTypeVariables */); + if (objectFlags & 1048576 /* CouldContainTypeVariablesComputed */) { + return !!(objectFlags & 2097152 /* 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 */ | 131072 /* ObjectRestType */)) || + objectFlags & (32 /* Mapped */ | 1024 /* ReverseMapped */ | 8388608 /* ObjectRestType */)) || type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && !isNonGenericTopLevelType(type) && ts.some(type.types, couldContainTypeVariables)); if (type.flags & 3899393 /* ObjectFlagsType */) { - type.objectFlags |= 67108864 /* CouldContainTypeVariablesComputed */ | (result ? 134217728 /* CouldContainTypeVariables */ : 0); + type.objectFlags |= 1048576 /* CouldContainTypeVariablesComputed */ | (result ? 2097152 /* CouldContainTypeVariables */ : 0); } return result; } function isNonGenericTopLevelType(type) { if (type.aliasSymbol && !type.aliasTypeArguments) { - var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 254 /* TypeAliasDeclaration */); - return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 297 /* SourceFile */ ? true : n.kind === 256 /* ModuleDeclaration */ ? false : "quit"; })); + var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 256 /* TypeAliasDeclaration */); + return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 299 /* SourceFile */ ? true : n.kind === 258 /* ModuleDeclaration */ ? false : "quit"; })); } return false; } @@ -61969,7 +64125,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) & 2097152 /* NonInferrableType */) || + return !(ts.getObjectFlags(type) & 524288 /* NonInferrableType */) || isObjectLiteralType(type) && ts.some(getPropertiesOfType(type), function (prop) { return isPartiallyInferableType(getTypeOfSymbol(prop)); }) || isTupleType(type) && ts.some(getTypeArguments(type), isPartiallyInferableType); } @@ -61993,14 +64149,18 @@ var ts; } // 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(2048 /* ReverseMapped */ | 16 /* Anonymous */, /*symbol*/ undefined); + var reversed = createObjectType(1024 /* ReverseMapped */ | 16 /* Anonymous */, /*symbol*/ undefined); reversed.source = source; reversed.mappedType = target; reversed.constraintType = constraint; return reversed; } function getTypeOfReverseMappedSymbol(symbol) { - return inferReverseMappedType(symbol.propertyType, symbol.mappedType, symbol.constraintType); + var links = getSymbolLinks(symbol); + if (!links.type) { + links.type = inferReverseMappedType(symbol.propertyType, symbol.mappedType, symbol.constraintType); + } + return links.type; } function inferReverseMappedType(sourceType, target, constraint) { var typeParameter = getIndexedAccessType(constraint.type, getTypeParameterFromMappedType(target)); @@ -62092,51 +64252,113 @@ var ts; // * 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 */); } - function isStringLiteralTypeValueParsableAsType(s, target) { - if (target.flags & 1048576 /* Union */) { - return !!forEachType(target, function (t) { return isStringLiteralTypeValueParsableAsType(s, t); }); - } - switch (target) { - case stringType: return true; - case numberType: return s.value !== "" && isFinite(+(s.value)); - case bigintType: return s.value !== "" && isValidBigIntString(s.value); - // the next 4 should be handled in `getTemplateLiteralType`, as they are all exactly one value, but are here for completeness, just in case - // this function is ever used on types which don't come from template literal holes - case trueType: return s.value === "true"; - case falseType: return s.value === "false"; - case undefinedType: return s.value === "undefined"; - case nullType: return s.value === "null"; - default: return !!(target.flags & 1 /* Any */); - } - } - function inferLiteralsFromTemplateLiteralType(source, target) { - var value = source.value; - var texts = target.texts; - var lastIndex = texts.length - 1; - var startText = texts[0]; - var endText = texts[lastIndex]; - if (!(value.startsWith(startText) && value.slice(startText.length).endsWith(endText))) + function isValidTypeForTemplateLiteralPlaceholder(source, target) { + if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) { + return true; + } + if (source.flags & 128 /* StringLiteral */) { + var value = source.value; + return !!(target.flags & 8 /* Number */ && value !== "" && isFinite(+value) || + target.flags & 64 /* BigInt */ && value !== "" && isValidBigIntString(value) || + target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName); + } + if (source.flags & 134217728 /* 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 */ ? + ts.arraysEqual(source.texts, target.texts) ? ts.map(source.types, getStringLikeTypeForType) : + inferFromLiteralPartsToTemplateLiteral(source.texts, source.types, target) : + undefined; + } + function getStringLikeTypeForType(type) { + return type.flags & (1 /* Any */ | 402653316 /* 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 + // with one text part and zero type parts. The function returns an array of inferred string or template literal types + // corresponding to the placeholders in the target template literal, or undefined if the source doesn't match the target. + // + // We first check that the starting source text part matches the starting target text part, and that the ending source + // text part ends matches the ending target text part. We then iterate through the remaining target text parts, finding + // a match for each in the source and inferring string or template literal types created from the segments of the source + // that occur between the matches. During this iteration, seg holds the index of the current text part in the sourceTexts + // array and pos holds the current character position in the current text part. + // + // Consider inference from type `<<${string}>.<${number}-${number}>>` to type `<${string}.${string}>`, i.e. + // sourceTexts = ['<<', '>.<', '-', '>>'] + // sourceTypes = [string, number, number] + // target.texts = ['<', '.', '>'] + // We first match '<' in the target to the start of '<<' in the source and '>' in the target to the end of '>>' in + // the source. The first match for the '.' in target occurs at character 1 in the source text part at index 1, and thus + // the first inference is the template literal type `<${string}>`. The remainder of the source makes up the second + // inference, the template literal type `<${number}-${number}>`. + function inferFromLiteralPartsToTemplateLiteral(sourceTexts, sourceTypes, target) { + var lastSourceIndex = sourceTexts.length - 1; + var sourceStartText = sourceTexts[0]; + var sourceEndText = sourceTexts[lastSourceIndex]; + var targetTexts = target.texts; + var lastTargetIndex = targetTexts.length - 1; + var targetStartText = targetTexts[0]; + var targetEndText = targetTexts[lastTargetIndex]; + if (lastSourceIndex === 0 && sourceStartText.length < targetStartText.length + targetEndText.length || + !sourceStartText.startsWith(targetStartText) || !sourceEndText.endsWith(targetEndText)) return undefined; + var remainingEndText = sourceEndText.slice(0, sourceEndText.length - targetEndText.length); var matches = []; - var str = value.slice(startText.length, value.length - endText.length); - var pos = 0; - for (var i = 1; i < lastIndex; i++) { - var delim = texts[i]; - var delimPos = delim.length > 0 ? str.indexOf(delim, pos) : pos < str.length ? pos + 1 : -1; - if (delimPos < 0) + var seg = 0; + var pos = targetStartText.length; + for (var i = 1; i < lastTargetIndex; i++) { + var delim = targetTexts[i]; + if (delim.length > 0) { + var s = seg; + var p = pos; + while (true) { + p = getSourceText(s).indexOf(delim, p); + if (p >= 0) + break; + s++; + if (s === sourceTexts.length) + return undefined; + p = 0; + } + addMatch(s, p); + pos += delim.length; + } + else if (pos < getSourceText(seg).length) { + addMatch(seg, pos + 1); + } + else if (seg < lastSourceIndex) { + addMatch(seg + 1, 0); + } + else { return undefined; - matches.push(getLiteralType(str.slice(pos, delimPos))); - pos = delimPos + delim.length; + } } - matches.push(getLiteralType(str.slice(pos))); + addMatch(lastSourceIndex, getSourceText(lastSourceIndex).length); return matches; + function getSourceText(index) { + return index < lastSourceIndex ? sourceTexts[index] : remainingEndText; + } + function addMatch(s, p) { + var matchType = s === seg ? + getLiteralType(getSourceText(s).slice(pos, p)) : + getTemplateLiteralType(__spreadArray(__spreadArray([sourceTexts[seg].slice(pos)], sourceTexts.slice(seg + 1, s)), [getSourceText(s).slice(0, p)]), sourceTypes.slice(seg, s)); + matches.push(matchType); + seg = s; + pos = p; + } } function inferTypes(inferences, originalSource, originalTarget, priority, contravariant) { if (priority === void 0) { priority = 0; } if (contravariant === void 0) { contravariant = false; } var bivariant = false; var propagationType; - var inferencePriority = 1024 /* MaxValue */; + var inferencePriority = 2048 /* MaxValue */; var allowComplexConstraintInference = true; var visited; var sourceStack; @@ -62223,8 +64445,8 @@ var ts; // 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 (ts.getObjectFlags(source) & 2097152 /* NonInferrableType */ || source === nonInferrableAnyType || source === silentNeverType || - (priority & 64 /* ReturnType */ && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) { + if (ts.getObjectFlags(source) & 524288 /* NonInferrableType */ || source === nonInferrableAnyType || source === silentNeverType || + (priority & 128 /* ReturnType */ && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) { return; } var inference = getInferenceInfoForType(target); @@ -62251,7 +64473,7 @@ var ts; clearCachedInferences(inferences); } } - if (!(priority & 64 /* ReturnType */) && target.flags & 262144 /* TypeParameter */ && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) { + if (!(priority & 128 /* ReturnType */) && target.flags & 262144 /* TypeParameter */ && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) { inference.topLevel = false; clearCachedInferences(inferences); } @@ -62291,7 +64513,7 @@ var ts; else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 4194304 /* Index */) { var empty = createEmptyObjectTypeFromStringLiteral(source); contravariant = !contravariant; - inferWithPriority(empty, target.type, 128 /* LiteralKeyof */); + inferWithPriority(empty, target.type, 256 /* LiteralKeyof */); contravariant = !contravariant; } else if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) { @@ -62303,6 +64525,13 @@ var ts; inferFromTypes(source.type, target.type); } } + else if (source.flags & 33554432 /* Substitution */) { + inferFromTypes(source.baseType, target); + var oldPriority = priority; + priority |= 4 /* SubstituteSource */; + inferFromTypes(source.substitute, target); // Make substitute inference at a lower priority + priority = oldPriority; + } else if (target.flags & 16777216 /* Conditional */) { invokeOnce(source, target, inferToConditionalType); } @@ -62322,7 +64551,7 @@ var ts; } else { source = getReducedType(source); - if (!(priority & 256 /* NoConstraints */ && source.flags & (2097152 /* Intersection */ | 465829888 /* Instantiable */))) { + if (!(priority & 512 /* NoConstraints */ && source.flags & (2097152 /* Intersection */ | 465829888 /* 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` @@ -62360,26 +64589,22 @@ var ts; } (visited || (visited = new ts.Map())).set(key, -1 /* Circularity */); var saveInferencePriority = inferencePriority; - inferencePriority = 1024 /* MaxValue */; + inferencePriority = 2048 /* 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) || source; - var targetIdentity = getRecursionIdentity(target) || target; - if (sourceIdentity && ts.contains(sourceStack, sourceIdentity)) + var sourceIdentity = getRecursionIdentity(source); + var targetIdentity = getRecursionIdentity(target); + if (ts.contains(sourceStack, sourceIdentity)) expandingFlags |= 1 /* Source */; - if (targetIdentity && ts.contains(targetStack, targetIdentity)) + if (ts.contains(targetStack, targetIdentity)) expandingFlags |= 2 /* Target */; if (expandingFlags !== 3 /* Both */) { - if (sourceIdentity) - (sourceStack || (sourceStack = [])).push(sourceIdentity); - if (targetIdentity) - (targetStack || (targetStack = [])).push(targetIdentity); + (sourceStack || (sourceStack = [])).push(sourceIdentity); + (targetStack || (targetStack = [])).push(targetIdentity); action(source, target); - if (targetIdentity) - targetStack.pop(); - if (sourceIdentity) - sourceStack.pop(); + targetStack.pop(); + sourceStack.pop(); } else { inferencePriority = -1 /* Circularity */; @@ -62419,7 +64644,7 @@ var ts; } } function inferFromContravariantTypes(source, target) { - if (strictFunctionTypes || priority & 512 /* AlwaysStrict */) { + if (strictFunctionTypes || priority & 1024 /* AlwaysStrict */) { contravariant = !contravariant; inferFromTypes(source, target); contravariant = !contravariant; @@ -62471,7 +64696,7 @@ var ts; else { for (var i = 0; i < sources.length; i++) { var saveInferencePriority = inferencePriority; - inferencePriority = 1024 /* MaxValue */; + inferencePriority = 2048 /* MaxValue */; inferFromTypes(sources[i], t); if (inferencePriority === priority) matched_1[i] = true; @@ -62550,9 +64775,9 @@ 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) & 2097152 /* NonInferrableType */ ? - 8 /* PartialHomomorphicMappedType */ : - 4 /* HomomorphicMappedType */); + inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 524288 /* NonInferrableType */ ? + 16 /* PartialHomomorphicMappedType */ : + 8 /* HomomorphicMappedType */); } } return true; @@ -62560,7 +64785,7 @@ var ts; if (constraintType.flags & 262144 /* 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, 16 /* MappedTypeConstraint */); + inferWithPriority(getIndexType(source), constraintType, 32 /* 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 @@ -62589,16 +64814,14 @@ var ts; } else { var savePriority = priority; - priority |= contravariant ? 32 /* ContravariantConditional */ : 0; + priority |= contravariant ? 64 /* ContravariantConditional */ : 0; var targetTypes = [getTrueTypeFromConditionalType(target), getFalseTypeFromConditionalType(target)]; inferToMultipleTypes(source, targetTypes, target.flags); priority = savePriority; } } function inferToTemplateLiteralType(source, target) { - var matches = source.flags & 128 /* StringLiteral */ ? inferLiteralsFromTemplateLiteralType(source, target) : - source.flags & 134217728 /* TemplateLiteral */ && ts.arraysEqual(source.texts, target.texts) ? source.types : - undefined; + var matches = inferTypesFromTemplateLiteralType(source, target); var types = target.types; for (var i = 0; i < types.length; i++) { inferFromTypes(matches ? matches[i] : neverType, types[i]); @@ -62714,7 +64937,7 @@ var ts; var sourceLen = sourceSignatures.length; var targetLen = targetSignatures.length; var len = sourceLen < targetLen ? sourceLen : targetLen; - var skipParameters = !!(ts.getObjectFlags(source) & 2097152 /* NonInferrableType */); + var skipParameters = !!(ts.getObjectFlags(source) & 524288 /* NonInferrableType */); for (var i = 0; i < len; i++) { inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i]), skipParameters); } @@ -62724,19 +64947,21 @@ var ts; 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 === 165 /* MethodDeclaration */ || kind === 164 /* MethodSignature */ || kind === 166 /* Constructor */; + bivariant = bivariant || kind === 167 /* MethodDeclaration */ || kind === 166 /* MethodSignature */ || kind === 168 /* Constructor */; applyToParameterTypes(source, target, inferFromContravariantTypes); 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 targetStringIndexType = getIndexTypeOfType(target, 0 /* String */); if (targetStringIndexType) { var sourceIndexType = getIndexTypeOfType(source, 0 /* String */) || getImplicitIndexTypeOfType(source, 0 /* String */); if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetStringIndexType); + inferWithPriority(sourceIndexType, targetStringIndexType, priority); } } var targetNumberIndexType = getIndexTypeOfType(target, 1 /* Number */); @@ -62745,13 +64970,13 @@ var ts; getIndexTypeOfType(source, 0 /* String */) || getImplicitIndexTypeOfType(source, 1 /* Number */); if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetNumberIndexType); + inferWithPriority(sourceIndexType, targetNumberIndexType, priority); } } } } function isTypeOrBaseIdenticalTo(s, t) { - return isTypeIdenticalTo(s, t) || !!(t.flags & 4 /* String */ && s.flags & 134217856 /* StringLikeLiteral */ || t.flags & 8 /* Number */ && s.flags & 256 /* NumberLiteral */); + return isTypeIdenticalTo(s, t) || !!(t.flags & 4 /* String */ && s.flags & 128 /* StringLiteral */ || t.flags & 8 /* Number */ && s.flags & 256 /* NumberLiteral */); } function isTypeCloselyMatchedBy(s, t) { return !!(s.flags & 524288 /* Object */ && t.flags & 524288 /* Object */ && s.symbol && s.symbol === t.symbol || @@ -62765,7 +64990,7 @@ var ts; return !!(ts.getObjectFlags(type) & 128 /* ObjectLiteral */); } function isObjectOrArrayLiteralType(type) { - return !!(ts.getObjectFlags(type) & (128 /* ObjectLiteral */ | 65536 /* ArrayLiteral */)); + return !!(ts.getObjectFlags(type) & (128 /* ObjectLiteral */ | 32768 /* ArrayLiteral */)); } function unionObjectAndArrayLiteralCandidates(candidates) { if (candidates.length > 1) { @@ -62778,7 +65003,7 @@ var ts; return candidates; } function getContravariantInference(inference) { - return inference.priority & 208 /* PriorityImpliesCombination */ ? getIntersectionType(inference.contraCandidates) : getCommonSubtype(inference.contraCandidates); + return inference.priority & 416 /* 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. @@ -62795,7 +65020,7 @@ 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 & 208 /* PriorityImpliesCombination */ ? + var unwidenedType = inference.priority & 416 /* PriorityImpliesCombination */ ? getUnionType(baseCandidates, 2 /* Subtype */) : getCommonSupertype(baseCandidates); return getWidenedType(unwidenedType); @@ -62904,7 +65129,7 @@ var ts; case "BigUint64Array": return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_1_or_later; default: - if (node.parent.kind === 289 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 291 /* ShorthandPropertyAssignment */) { return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer; } else { @@ -62925,26 +65150,27 @@ 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 === 176 /* TypeQuery */ ? true : n.kind === 78 /* Identifier */ || n.kind === 157 /* QualifiedName */ ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 178 /* TypeQuery */ ? true : n.kind === 79 /* Identifier */ || n.kind === 159 /* 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 // leftmost identifier followed by zero or more property names separated by dots. - // The result is undefined if the reference isn't a dotted name. We prefix nodes - // occurring in an apparent type position with '@' because the control flow type - // of such nodes may be based on the apparent type instead of the declared type. + // The result is undefined if the reference isn't a dotted name. function getFlowCacheKey(node, declaredType, initialType, flowContainer) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: var symbol = getResolvedSymbol(node); - return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + (isConstraintPosition(node) ? "@" : "") + getSymbolId(symbol) : undefined; - case 107 /* ThisKeyword */: + return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + getSymbolId(symbol) : undefined; + case 108 /* ThisKeyword */: return "0|" + (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType); - case 225 /* NonNullExpression */: - case 207 /* ParenthesizedExpression */: + case 227 /* NonNullExpression */: + case 209 /* ParenthesizedExpression */: return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 159 /* QualifiedName */: + var left = getFlowCacheKey(node.left, declaredType, initialType, flowContainer); + return left && left + "." + node.right.escapedText; + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: var propName = getAccessedPropertyName(node); if (propName !== undefined) { var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); @@ -62955,32 +65181,40 @@ var ts; } function isMatchingReference(source, target) { switch (target.kind) { - case 207 /* ParenthesizedExpression */: - case 225 /* NonNullExpression */: + case 209 /* ParenthesizedExpression */: + case 227 /* NonNullExpression */: return isMatchingReference(source, target.expression); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return (ts.isAssignmentExpression(target) && isMatchingReference(source, target.left)) || (ts.isBinaryExpression(target) && target.operatorToken.kind === 27 /* CommaToken */ && isMatchingReference(source, target.right)); } switch (source.kind) { - case 78 /* Identifier */: - case 79 /* PrivateIdentifier */: - return target.kind === 78 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 249 /* VariableDeclaration */ || target.kind === 198 /* BindingElement */) && + case 228 /* MetaProperty */: + return target.kind === 228 /* MetaProperty */ + && source.keywordToken === target.keywordToken + && source.name.escapedText === target.name.escapedText; + case 79 /* Identifier */: + case 80 /* PrivateIdentifier */: + return target.kind === 79 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 251 /* VariableDeclaration */ || target.kind === 200 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 107 /* ThisKeyword */: - return target.kind === 107 /* ThisKeyword */; - case 105 /* SuperKeyword */: - return target.kind === 105 /* SuperKeyword */; - case 225 /* NonNullExpression */: - case 207 /* ParenthesizedExpression */: + case 108 /* ThisKeyword */: + return target.kind === 108 /* ThisKeyword */; + case 106 /* SuperKeyword */: + return target.kind === 106 /* SuperKeyword */; + case 227 /* NonNullExpression */: + case 209 /* ParenthesizedExpression */: return isMatchingReference(source.expression, target); - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: return ts.isAccessExpression(target) && getAccessedPropertyName(source) === getAccessedPropertyName(target) && isMatchingReference(source.expression, target.expression); - case 216 /* BinaryExpression */: + case 159 /* QualifiedName */: + return ts.isAccessExpression(target) && + source.right.escapedText === getAccessedPropertyName(target) && + isMatchingReference(source.left, target.expression); + case 218 /* BinaryExpression */: return (ts.isBinaryExpression(source) && source.operatorToken.kind === 27 /* CommaToken */ && isMatchingReference(source.right, target)); } return false; @@ -62988,11 +65222,11 @@ var ts; // Given a source x, check if target matches x or is an && operation with an operand that matches x. function containsTruthyCheck(source, target) { return isMatchingReference(source, target) || - (target.kind === 216 /* BinaryExpression */ && target.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && + (target.kind === 218 /* BinaryExpression */ && target.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && (containsTruthyCheck(source, target.left) || containsTruthyCheck(source, target.right))); } function getAccessedPropertyName(access) { - return access.kind === 201 /* PropertyAccessExpression */ ? access.name.escapedText : + return access.kind === 203 /* PropertyAccessExpression */ ? access.name.escapedText : ts.isStringOrNumericLiteralLike(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) : undefined; } @@ -63042,6 +65276,86 @@ var ts; } return result; } + // Given a set of constituent types and a property name, create and return a map keyed by the literal + // types of the property by that name in each constituent type. No map is returned if some key property + // has a non-literal type or if less than 10 or less than 50% of the constituents have a unique key. + // Entries with duplicate keys have unknownType as the value. + function mapTypesByKeyProperty(types, name) { + var map = new ts.Map(); + var count = 0; + var _loop_20 = function (type) { + if (type.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) { + var discriminant = getTypeOfPropertyOfType(type, name); + if (discriminant) { + if (!isLiteralType(discriminant)) { + return { value: undefined }; + } + var duplicate_1 = false; + forEachType(discriminant, function (t) { + var id = getTypeId(getRegularTypeOfLiteralType(t)); + var existing = map.get(id); + if (!existing) { + map.set(id, type); + } + else if (existing !== unknownType) { + map.set(id, unknownType); + duplicate_1 = true; + } + }); + if (!duplicate_1) + count++; + } + } + }; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var type = types_17[_i]; + var state_8 = _loop_20(type); + if (typeof state_8 === "object") + return state_8.value; + } + return count >= 10 && count * 2 >= types.length ? map : undefined; + } + // Return the name of a discriminant property for which it was possible and feasible to construct a map of + // constituent types keyed by the literal types of the property by that name in each constituent type. + function getKeyPropertyName(unionType) { + var types = unionType.types; + // We only construct maps for large unions with non-primitive constituents. + if (types.length < 10 || ts.getObjectFlags(unionType) & 65536 /* PrimitiveUnion */) { + 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 */) ? + ts.forEach(getPropertiesOfType(t), function (p) { return isUnitType(getTypeOfSymbol(p)) ? p.escapedName : undefined; }) : + undefined; + }); + var mapByKeyProperty = keyPropertyName && mapTypesByKeyProperty(types, keyPropertyName); + unionType.keyPropertyName = mapByKeyProperty ? keyPropertyName : ""; + unionType.constituentMap = mapByKeyProperty; + } + return unionType.keyPropertyName.length ? unionType.keyPropertyName : undefined; + } + // Given a union type for which getKeyPropertyName returned a non-undefined result, return the constituent + // that corresponds to the given key type for that property name. + function getConstituentTypeForKeyType(unionType, keyType) { + var _a; + var result = (_a = unionType.constituentMap) === null || _a === void 0 ? void 0 : _a.get(getTypeId(getRegularTypeOfLiteralType(keyType))); + return result !== unknownType ? result : undefined; + } + function getMatchingUnionConstituentForType(unionType, type) { + var keyPropertyName = getKeyPropertyName(unionType); + var propType = keyPropertyName && getTypeOfPropertyOfType(type, keyPropertyName); + return propType && getConstituentTypeForKeyType(unionType, propType); + } + function getMatchingUnionConstituentForObjectLiteral(unionType, node) { + var keyPropertyName = getKeyPropertyName(unionType); + var propNode = keyPropertyName && ts.find(node.properties, function (p) { return p.symbol && p.kind === 290 /* PropertyAssignment */ && + p.symbol.escapedName === keyPropertyName && isPossiblyDiscriminantValue(p.initializer); }); + var propType = propNode && getTypeOfExpression(propNode.initializer); + return propType && getConstituentTypeForKeyType(unionType, propType); + } function isOrContainsMatchingReference(source, target) { return isMatchingReference(source, target) || containsMatchingReference(source, target); } @@ -63054,7 +65368,7 @@ var ts; } } } - if (expression.expression.kind === 201 /* PropertyAccessExpression */ && + if (expression.expression.kind === 203 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, expression.expression.expression)) { return true; } @@ -63101,14 +65415,6 @@ var ts; } return declaredType; } - function getTypeFactsOfTypes(types) { - var result = 0 /* None */; - for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { - var t = types_17[_i]; - result |= getTypeFacts(t); - } - return result; - } function isFunctionObjectType(type) { // We do a quick check for a "bind" property before performing the more expensive subtype // check. This gives us a quicker out in the common case where an object type is not a function. @@ -63116,7 +65422,8 @@ var ts; return !!(resolved.callSignatures.length || resolved.constructSignatures.length || resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType)); } - function getTypeFacts(type) { + function getTypeFacts(type, ignoreObjects) { + if (ignoreObjects === void 0) { ignoreObjects = false; } var flags = type.flags; if (flags & 4 /* String */) { return strictNullChecks ? 16317953 /* StringStrictFacts */ : 16776705 /* StringFacts */; @@ -63153,7 +65460,7 @@ var ts; (type === falseType || type === regularFalseType) ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ : (type === falseType || type === regularFalseType) ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */; } - if (flags & 524288 /* Object */) { + if (flags & 524288 /* Object */ && !ignoreObjects) { return ts.getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type) ? strictNullChecks ? 16318463 /* EmptyObjectStrictFacts */ : 16777215 /* EmptyObjectFacts */ : isFunctionObjectType(type) ? @@ -63176,11 +65483,17 @@ var ts; return 0 /* None */; } if (flags & 465829888 /* Instantiable */) { - return !isPatternLiteralType(type) ? getTypeFacts(getBaseConstraintOfType(type) || unknownType) : + return !isPatternLiteralType(type) ? getTypeFacts(getBaseConstraintOfType(type) || unknownType, ignoreObjects) : strictNullChecks ? 7929345 /* NonEmptyStringStrictFacts */ : 16776705 /* NonEmptyStringFacts */; } - if (flags & 3145728 /* UnionOrIntersection */) { - return getTypeFactsOfTypes(type.types); + if (flags & 1048576 /* Union */) { + return ts.reduceLeft(type.types, function (facts, t) { return facts | getTypeFacts(t, ignoreObjects); }, 0 /* None */); + } + if (flags & 2097152 /* Intersection */) { + // 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. + ignoreObjects || (ignoreObjects = maybeTypeOfKind(type, 131068 /* Primitive */)); + return ts.reduceLeft(type.types, function (facts, t) { return facts & getTypeFacts(t, ignoreObjects); }, 16777215 /* All */); } return 16777215 /* All */; } @@ -63188,18 +65501,16 @@ var ts; return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; }); } function getTypeWithDefault(type, defaultExpression) { - if (defaultExpression) { - var defaultType = getTypeOfExpression(defaultExpression); - return getUnionType([getTypeWithFacts(type, 524288 /* NEUndefined */), defaultType]); - } - return type; + return defaultExpression ? + getUnionType([getNonUndefinedType(type), getTypeOfExpression(defaultExpression)]) : + type; } function getTypeOfDestructuredProperty(type, name) { var nameType = getLiteralTypeFromPropertyName(name); if (!isTypeUsableAsPropertyName(nameType)) return errorType; var text = getPropertyNameFromType(nameType); - return getConstraintForLocation(getTypeOfPropertyOfType(type, text), name) || + return getTypeOfPropertyOfType(type, text) || isNumericLiteralName(text) && includeUndefinedInIndexSignature(getIndexTypeOfType(type, 1 /* Number */)) || includeUndefinedInIndexSignature(getIndexTypeOfType(type, 0 /* String */)) || errorType; @@ -63220,15 +65531,15 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 199 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 288 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 201 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 290 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 216 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 239 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 218 /* BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 241 /* ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -63245,21 +65556,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return stringType; - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: return checkRightHandSideOfForOf(parent) || errorType; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 210 /* DeleteExpression */: + case 212 /* DeleteExpression */: return undefinedType; - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 220 /* SpreadElement */: + case 222 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -63267,7 +65578,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 196 /* ObjectBindingPattern */ ? + var type = pattern.kind === 198 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -63285,35 +65596,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 238 /* ForInStatement */) { + if (node.parent.parent.kind === 240 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 239 /* ForOfStatement */) { + if (node.parent.parent.kind === 241 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 249 /* VariableDeclaration */ ? + return node.kind === 251 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function isEmptyArrayAssignment(node) { - return node.kind === 249 /* VariableDeclaration */ && node.initializer && + return node.kind === 251 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 198 /* BindingElement */ && node.parent.kind === 216 /* BinaryExpression */ && + node.kind !== 200 /* BindingElement */ && node.parent.kind === 218 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 62 /* EqualsToken */: - case 74 /* BarBarEqualsToken */: - case 75 /* AmpersandAmpersandEqualsToken */: - case 76 /* QuestionQuestionEqualsToken */: + case 63 /* EqualsToken */: + case 75 /* BarBarEqualsToken */: + case 76 /* AmpersandAmpersandEqualsToken */: + case 77 /* QuestionQuestionEqualsToken */: return getReferenceCandidate(node.left); case 27 /* CommaToken */: return getReferenceCandidate(node.right); @@ -63323,13 +65634,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 207 /* ParenthesizedExpression */ || - parent.kind === 216 /* BinaryExpression */ && parent.operatorToken.kind === 62 /* EqualsToken */ && parent.left === node || - parent.kind === 216 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? + return parent.kind === 209 /* ParenthesizedExpression */ || + parent.kind === 218 /* BinaryExpression */ && parent.operatorToken.kind === 63 /* EqualsToken */ && parent.left === node || + parent.kind === 218 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 284 /* CaseClause */) { + if (clause.kind === 286 /* CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -63349,7 +65660,7 @@ var ts; var witnesses = []; for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) { var clause = _a[_i]; - if (clause.kind === 284 /* CaseClause */) { + if (clause.kind === 286 /* CaseClause */) { if (ts.isStringLiteralLike(clause.expression)) { witnesses.push(clause.expression.text); continue; @@ -63385,14 +65696,40 @@ var ts; function forEachType(type, f) { return type.flags & 1048576 /* Union */ ? ts.forEach(type.types, f) : f(type); } + function someType(type, f) { + return type.flags & 1048576 /* Union */ ? ts.some(type.types, f) : f(type); + } function everyType(type, f) { return type.flags & 1048576 /* Union */ ? ts.every(type.types, f) : f(type); } + function everyContainedType(type, f) { + return type.flags & 3145728 /* UnionOrIntersection */ ? ts.every(type.types, f) : f(type); + } function filterType(type, f) { if (type.flags & 1048576 /* Union */) { var types = type.types; var filtered = ts.filter(types, f); - return filtered === types ? type : getUnionTypeFromSortedList(filtered, type.objectFlags); + if (filtered === types) { + return type; + } + var origin = type.origin; + var newOrigin = void 0; + if (origin && origin.flags & 1048576 /* 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); }); + if (originTypes.length - originFiltered.length === types.length - filtered.length) { + if (originFiltered.length === 1) { + return originFiltered[0]; + } + newOrigin = createOriginUnionOrIntersectionType(1048576 /* Union */, originFiltered); + } + } + return getUnionTypeFromSortedList(filtered, type.objectFlags, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, newOrigin); } return type.flags & 131072 /* Never */ || f(type) ? type : neverType; } @@ -63425,6 +65762,11 @@ var ts; } return changed ? mappedTypes && getUnionType(mappedTypes, noReductions ? 0 /* None */ : 1 /* Literal */) : type; } + function mapTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments) { + return type.flags & 1048576 /* Union */ && aliasSymbol ? + getUnionType(ts.map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments) : + mapType(type, mapper); + } function getConstituentCount(type) { return type.flags & 3145728 /* UnionOrIntersection */ ? type.types.length : 1; } @@ -63510,21 +65852,21 @@ var ts; var root = getReferenceRoot(node); var parent = root.parent; var isLengthPushOrUnshift = ts.isPropertyAccessExpression(parent) && (parent.name.escapedText === "length" || - parent.parent.kind === 203 /* CallExpression */ + parent.parent.kind === 205 /* CallExpression */ && ts.isIdentifier(parent.name) && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 202 /* ElementAccessExpression */ && + var isElementAssignment = parent.kind === 204 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 216 /* BinaryExpression */ && - parent.parent.operatorToken.kind === 62 /* EqualsToken */ && + parent.parent.kind === 218 /* BinaryExpression */ && + parent.parent.operatorToken.kind === 63 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* NumberLike */); return isLengthPushOrUnshift || isElementAssignment; } function isDeclarationWithExplicitTypeAnnotation(declaration) { - return (declaration.kind === 249 /* VariableDeclaration */ || declaration.kind === 160 /* Parameter */ || - declaration.kind === 163 /* PropertyDeclaration */ || declaration.kind === 162 /* PropertySignature */) && + return (declaration.kind === 251 /* VariableDeclaration */ || declaration.kind === 162 /* Parameter */ || + declaration.kind === 165 /* PropertyDeclaration */ || declaration.kind === 164 /* PropertySignature */) && !!ts.getEffectiveTypeAnnotationNode(declaration); } function getExplicitTypeOfSymbol(symbol, diagnostic) { @@ -63543,7 +65885,7 @@ var ts; if (isDeclarationWithExplicitTypeAnnotation(declaration)) { return getTypeOfSymbol(symbol); } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 239 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 241 /* ForOfStatement */) { var statement = declaration.parent.parent; var expressionType = getTypeOfDottedName(statement.expression, /*diagnostic*/ undefined); if (expressionType) { @@ -63564,18 +65906,32 @@ var ts; function getTypeOfDottedName(node, diagnostic) { if (!(node.flags & 16777216 /* InWithStatement */)) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node)); return getExplicitTypeOfSymbol(symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol, diagnostic); - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: return getExplicitThisType(node); - case 105 /* SuperKeyword */: + case 106 /* SuperKeyword */: return checkSuperExpression(node); - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: { var type = getTypeOfDottedName(node.expression, diagnostic); - var prop = type && getPropertyOfType(type, node.name.escapedText); - return prop && getExplicitTypeOfSymbol(prop, diagnostic); - case 207 /* ParenthesizedExpression */: + if (type) { + var name = node.name; + var prop = void 0; + if (ts.isPrivateIdentifier(name)) { + if (!type.symbol) { + return undefined; + } + prop = getPropertyOfType(type, ts.getSymbolNameForPrivateIdentifier(type.symbol, name.escapedText)); + } + else { + prop = getPropertyOfType(type, name.escapedText); + } + return prop && getExplicitTypeOfSymbol(prop, diagnostic); + } + return undefined; + } + case 209 /* ParenthesizedExpression */: return getTypeOfDottedName(node.expression, diagnostic); } } @@ -63589,10 +65945,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 === 233 /* ExpressionStatement */) { + if (node.parent.kind === 235 /* ExpressionStatement */) { funcType = getTypeOfDottedName(node.expression, /*diagnostic*/ undefined); } - else if (node.expression.kind !== 105 /* SuperKeyword */) { + else if (node.expression.kind !== 106 /* SuperKeyword */) { if (ts.isOptionalChain(node)) { funcType = checkNonNullType(getOptionalExpressionType(checkExpression(node.expression), node.expression), node.expression); } @@ -63633,7 +65989,7 @@ var ts; } function isFalseExpression(expr) { var node = ts.skipParentheses(expr); - return node.kind === 94 /* FalseKeyword */ || node.kind === 216 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && (isFalseExpression(node.left) || isFalseExpression(node.right)) || + return node.kind === 95 /* FalseKeyword */ || node.kind === 218 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && (isFalseExpression(node.left) || isFalseExpression(node.right)) || node.operatorToken.kind === 56 /* BarBarToken */ && isFalseExpression(node.left) && isFalseExpression(node.right)); } function isReachableFlowNodeWorker(flow, noCacheCheck) { @@ -63721,7 +66077,7 @@ var ts; flow = flow.antecedent; } else if (flags & 512 /* Call */) { - if (flow.node.expression.kind === 105 /* SuperKeyword */) { + if (flow.node.expression.kind === 106 /* SuperKeyword */) { return true; } flow = flow.antecedent; @@ -63768,7 +66124,7 @@ var ts; // 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 === 225 /* NonNullExpression */ && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { + if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 227 /* NonNullExpression */ && !(resultType.flags & 131072 /* Never */) && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { return declaredType; } return resultType; @@ -63783,7 +66139,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.instant("checkTypes" /* CheckTypes */, "getTypeAtFlowNode_DepthLimit", { flowId: flow.id }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "getTypeAtFlowNode_DepthLimit", { flowId: flow.id }); flowAnalysisDisabled = true; reportFlowControlError(reference); return errorType; @@ -63852,9 +66208,9 @@ var ts; // Check if we should continue with the control flow of the containing function. var container = flow.node; if (container && container !== flowContainer && - reference.kind !== 201 /* PropertyAccessExpression */ && - reference.kind !== 202 /* ElementAccessExpression */ && - reference.kind !== 107 /* ThisKeyword */) { + reference.kind !== 203 /* PropertyAccessExpression */ && + reference.kind !== 204 /* ElementAccessExpression */ && + reference.kind !== 108 /* ThisKeyword */) { flow = container.flowNode; continue; } @@ -63878,7 +66234,7 @@ var ts; } function getInitialOrAssignedType(flow) { var node = flow.node; - return getConstraintForLocation(node.kind === 249 /* VariableDeclaration */ || node.kind === 198 /* BindingElement */ ? + return getNarrowableTypeForReference(node.kind === 251 /* VariableDeclaration */ || node.kind === 200 /* BindingElement */ ? getInitialType(node) : getAssignedType(node), reference); } @@ -63918,14 +66274,14 @@ 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 === 208 /* FunctionExpression */ || init.kind === 209 /* ArrowFunction */)) { + if (init && (init.kind === 210 /* FunctionExpression */ || init.kind === 211 /* 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 === 238 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { + if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 240 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); } // Assignment doesn't affect reference @@ -63933,10 +66289,10 @@ var ts; } function narrowTypeByAssertion(type, expr) { var node = ts.skipParentheses(expr); - if (node.kind === 94 /* FalseKeyword */) { + if (node.kind === 95 /* FalseKeyword */) { return unreachableNeverType; } - if (node.kind === 216 /* BinaryExpression */) { + if (node.kind === 218 /* BinaryExpression */) { if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { return narrowTypeByAssertion(narrowTypeByAssertion(type, node.left), node.right); } @@ -63967,7 +66323,7 @@ var ts; function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 203 /* CallExpression */ ? + var expr = node.kind === 205 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -63975,7 +66331,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 203 /* CallExpression */) { + if (node.kind === 205 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -64023,7 +66379,7 @@ var ts; if (isMatchingReference(reference, expr)) { type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } - else if (expr.kind === 211 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { + else if (expr.kind === 213 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } else { @@ -64031,12 +66387,12 @@ var ts; if (optionalChainContainsReference(expr, reference)) { type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & (32768 /* Undefined */ | 131072 /* Never */)); }); } - else if (expr.kind === 211 /* TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) { + else if (expr.kind === 213 /* 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"); }); } } if (isMatchingReferenceDiscriminant(expr, type)) { - type = narrowTypeByDiscriminant(type, expr, function (t) { return narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd); }); + type = narrowTypeBySwitchOnDiscriminantProperty(type, expr, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } } return createFlowType(type, isIncomplete(flowType)); @@ -64207,16 +66563,42 @@ var ts; if (propName === undefined) { return type; } - var propType = getTypeOfPropertyOfType(type, propName); + var removeNullable = strictNullChecks && ts.isOptionalChain(access) && maybeTypeOfKind(type, 98304 /* Nullable */); + var propType = getTypeOfPropertyOfType(removeNullable ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type, propName); if (!propType) { return type; } + propType = removeNullable ? getOptionalType(propType) : propType; var narrowedPropType = narrowType(propType); return filterType(type, function (t) { var discriminantType = getTypeOfPropertyOrIndexSignature(t, propName); return !(discriminantType.flags & 131072 /* Never */) && isTypeComparableTo(discriminantType, narrowedPropType); }); } + function narrowTypeByDiscriminantProperty(type, access, operator, value, assumeTrue) { + if ((operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) && type.flags & 1048576 /* Union */) { + var keyPropertyName = getKeyPropertyName(type); + if (keyPropertyName && keyPropertyName === getAccessedPropertyName(access)) { + var candidate_2 = getConstituentTypeForKeyType(type, getTypeOfExpression(value)); + if (candidate_2) { + return operator === (assumeTrue ? 36 /* EqualsEqualsEqualsToken */ : 37 /* ExclamationEqualsEqualsToken */) ? candidate_2 : + isUnitType(getTypeOfPropertyOfType(candidate_2, keyPropertyName) || unknownType) ? filterType(type, function (t) { return t !== candidate_2; }) : + type; + } + } + } + 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)) { + var clauseTypes = getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd); + var candidate = getUnionType(ts.map(clauseTypes, function (t) { return getConstituentTypeForKeyType(type, t) || unknownType; })); + if (candidate !== unknownType) { + return candidate; + } + } + return narrowTypeByDiscriminant(type, access, function (t) { return narrowTypeBySwitchOnDiscriminant(t, switchStatement, clauseStart, clauseEnd); }); + } function narrowTypeByTruthiness(type, expr, assumeTrue) { if (isMatchingReference(reference, expr)) { return getTypeWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); @@ -64240,7 +66622,8 @@ var ts; return !assumeTrue; } function narrowByInKeyword(type, literal, assumeTrue) { - if (type.flags & (1048576 /* Union */ | 524288 /* Object */) + if (type.flags & 1048576 /* Union */ + || type.flags & 524288 /* Object */ && declaredType !== type || isThisTypeParameter(type) || type.flags & 2097152 /* Intersection */ && ts.every(type.types, function (t) { return t.symbol !== globalThisSymbol; })) { var propName_1 = ts.escapeLeadingUnderscores(literal.text); @@ -64250,57 +66633,63 @@ var ts; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 62 /* EqualsToken */: - case 74 /* BarBarEqualsToken */: - case 75 /* AmpersandAmpersandEqualsToken */: - case 76 /* QuestionQuestionEqualsToken */: + case 63 /* EqualsToken */: + case 75 /* BarBarEqualsToken */: + case 76 /* AmpersandAmpersandEqualsToken */: + case 77 /* QuestionQuestionEqualsToken */: return narrowTypeByTruthiness(narrowType(type, expr.right, assumeTrue), expr.left, assumeTrue); case 34 /* EqualsEqualsToken */: case 35 /* ExclamationEqualsToken */: case 36 /* EqualsEqualsEqualsToken */: case 37 /* ExclamationEqualsEqualsToken */: - var operator_1 = expr.operatorToken.kind; - var left_1 = getReferenceCandidate(expr.left); - var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 211 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { - return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); + var operator = expr.operatorToken.kind; + var left = getReferenceCandidate(expr.left); + var right = getReferenceCandidate(expr.right); + if (left.kind === 213 /* TypeOfExpression */ && ts.isStringLiteralLike(right)) { + return narrowTypeByTypeof(type, left, operator, right, assumeTrue); } - if (right_1.kind === 211 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { - return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); + if (right.kind === 213 /* TypeOfExpression */ && ts.isStringLiteralLike(left)) { + return narrowTypeByTypeof(type, right, operator, left, assumeTrue); } - if (isMatchingReference(reference, left_1)) { - return narrowTypeByEquality(type, operator_1, right_1, assumeTrue); + if (isMatchingReference(reference, left)) { + return narrowTypeByEquality(type, operator, right, assumeTrue); } - if (isMatchingReference(reference, right_1)) { - return narrowTypeByEquality(type, operator_1, left_1, assumeTrue); + if (isMatchingReference(reference, right)) { + return narrowTypeByEquality(type, operator, left, assumeTrue); } if (strictNullChecks) { - if (optionalChainContainsReference(left_1, reference)) { - type = narrowTypeByOptionalChainContainment(type, operator_1, right_1, assumeTrue); + if (optionalChainContainsReference(left, reference)) { + type = narrowTypeByOptionalChainContainment(type, operator, right, assumeTrue); } - else if (optionalChainContainsReference(right_1, reference)) { - type = narrowTypeByOptionalChainContainment(type, operator_1, left_1, assumeTrue); + else if (optionalChainContainsReference(right, reference)) { + type = narrowTypeByOptionalChainContainment(type, operator, left, assumeTrue); } } - if (isMatchingReferenceDiscriminant(left_1, type)) { - return narrowTypeByDiscriminant(type, left_1, function (t) { return narrowTypeByEquality(t, operator_1, right_1, assumeTrue); }); + if (isMatchingReferenceDiscriminant(left, type)) { + return narrowTypeByDiscriminantProperty(type, left, operator, right, assumeTrue); } - if (isMatchingReferenceDiscriminant(right_1, type)) { - return narrowTypeByDiscriminant(type, right_1, function (t) { return narrowTypeByEquality(t, operator_1, left_1, assumeTrue); }); + if (isMatchingReferenceDiscriminant(right, type)) { + return narrowTypeByDiscriminantProperty(type, right, operator, left, assumeTrue); } - if (isMatchingConstructorReference(left_1)) { - return narrowTypeByConstructor(type, operator_1, right_1, assumeTrue); + if (isMatchingConstructorReference(left)) { + return narrowTypeByConstructor(type, operator, right, assumeTrue); } - if (isMatchingConstructorReference(right_1)) { - return narrowTypeByConstructor(type, operator_1, left_1, assumeTrue); + if (isMatchingConstructorReference(right)) { + return narrowTypeByConstructor(type, operator, left, assumeTrue); } break; - case 101 /* InstanceOfKeyword */: + case 102 /* InstanceOfKeyword */: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 100 /* InKeyword */: + case 101 /* InKeyword */: var target = getReferenceCandidate(expr.right); - if (ts.isStringLiteralLike(expr.left) && isMatchingReference(reference, target)) { - return narrowByInKeyword(type, expr.left, assumeTrue); + if (ts.isStringLiteralLike(expr.left)) { + if (containsMissingType(type) && ts.isAccessExpression(reference) && isMatchingReference(reference.expression, target) && + getAccessedPropertyName(reference) === ts.escapeLeadingUnderscores(expr.left.text)) { + return getTypeWithFacts(type, assumeTrue ? 524288 /* NEUndefined */ : 65536 /* EQUndefined */); + } + if (isMatchingReference(reference, target)) { + return narrowByInKeyword(type, expr.left, assumeTrue); + } } break; case 27 /* CommaToken */: @@ -64357,13 +66746,12 @@ var ts; } if (assumeTrue) { var filterFn = operator === 34 /* EqualsEqualsToken */ ? - (function (t) { return areTypesComparable(t, valueType) || isCoercibleUnderDoubleEquals(t, valueType); }) : + function (t) { return areTypesComparable(t, valueType) || isCoercibleUnderDoubleEquals(t, valueType); } : function (t) { return areTypesComparable(t, valueType); }; return replacePrimitivesWithLiterals(filterType(type, filterFn), valueType); } if (isUnitType(valueType)) { - var regularType_1 = getRegularTypeOfLiteralType(valueType); - return filterType(type, function (t) { return isUnitType(t) ? !areTypesComparable(t, valueType) : getRegularTypeOfLiteralType(t) !== regularType_1; }); + return filterType(type, function (t) { return !(isUnitLikeType(t) && areTypesComparable(t, valueType)); }); } return type; } @@ -64385,7 +66773,7 @@ var ts; if (assumeTrue && type.flags & 2 /* Unknown */ && literal.text === "object") { // The pattern x && typeof x === 'object', where x is of type unknown, narrows x to type object. We don't // need to check for the reverse typeof x === 'object' && x since that already narrows correctly. - if (typeOfExpr.parent.parent.kind === 216 /* BinaryExpression */) { + if (typeOfExpr.parent.parent.kind === 218 /* BinaryExpression */) { var expr = typeOfExpr.parent.parent; if (expr.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && expr.right === typeOfExpr.parent && containsTruthyCheck(reference, expr.left)) { return nonPrimitiveType; @@ -64441,7 +66829,7 @@ var ts; if (!hasDefaultClause) { return caseType; } - var defaultType = filterType(type, function (t) { return !(isUnitType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(t))); }); + var defaultType = filterType(type, function (t) { return !(isUnitLikeType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(extractUnitType(t)))); }); return caseType.flags & 131072 /* Never */ ? defaultType : getUnionType([caseType, defaultType]); } function getImpliedTypeFromTypeofGuard(type, text) { @@ -64623,7 +67011,16 @@ var ts; } function getNarrowedType(type, candidate, assumeTrue, isRelated) { if (!assumeTrue) { - return filterType(type, function (t) { return !isRelated(t, candidate); }); + return filterType(type, function (t) { + if (!isRelated(t, candidate)) { + return true; + } + var constraint = getBaseConstraintOfType(t); + if (constraint && constraint !== t) { + return !isRelated(constraint, candidate); + } + return false; + }); } // 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. @@ -64633,10 +67030,15 @@ var ts; return assignableType; } } - // If the candidate type is a subtype of the target type, narrow to the candidate type, - // if the target type is a subtype of the candidate type, narrow to the target type, - // otherwise, narrow to an intersection of the two types. - return isTypeSubtypeOf(candidate, type) ? candidate : isTypeSubtypeOf(type, candidate) ? type : getIntersectionType([type, 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]); } function narrowTypeByCallExpression(type, callExpression, assumeTrue) { if (hasMatchingArgument(callExpression, reference)) { @@ -64646,6 +67048,16 @@ var ts; return narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue); } } + if (containsMissingType(type) && ts.isAccessExpression(reference) && ts.isPropertyAccessExpression(callExpression.expression)) { + var callAccess = callExpression.expression; + if (isMatchingReference(reference.expression, getReferenceCandidate(callAccess.expression)) && + 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 type; } function narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue) { @@ -64676,20 +67088,20 @@ var ts; return narrowTypeByOptionality(type, expr, assumeTrue); } switch (expr.kind) { - case 78 /* Identifier */: - case 107 /* ThisKeyword */: - case 105 /* SuperKeyword */: - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 79 /* Identifier */: + case 108 /* ThisKeyword */: + case 106 /* SuperKeyword */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return narrowTypeByCallExpression(type, expr, assumeTrue); - case 207 /* ParenthesizedExpression */: - case 225 /* NonNullExpression */: + case 209 /* ParenthesizedExpression */: + case 227 /* NonNullExpression */: return narrowType(type, expr.expression, assumeTrue); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: if (expr.operator === 53 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } @@ -64713,34 +67125,40 @@ 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 === 78 /* Identifier */) { + if (location.kind === 79 /* Identifier */ || location.kind === 80 /* PrivateIdentifier */) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } - if (ts.isExpressionNode(location) && !ts.isAssignmentTarget(location)) { + if (ts.isExpressionNode(location) && (!ts.isAssignmentTarget(location) || ts.isWriteAccess(location))) { var type = getTypeOfExpression(location); if (getExportSymbolOfValueSymbolIfExported(getNodeLinks(location).resolvedSymbol) === symbol) { return type; } } } + if (ts.isDeclarationName(location) && ts.isSetAccessor(location.parent) && getAnnotatedAccessorTypeNode(location.parent)) { + return resolveTypeOfAccessors(location.parent.symbol, /*writing*/ true); + } // The location isn't a reference to the given symbol, meaning we're being asked // a hypothetical question of what type the symbol would have if there was a reference // to it at the given location. Since we have no control flow information for the // hypothetical reference (control flow information is created and attached by the // binder), we simply return the declared type of the symbol. - return getTypeOfSymbol(symbol); + return getNonMissingTypeOfSymbol(symbol); } function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 257 /* ModuleBlock */ || - node.kind === 297 /* SourceFile */ || - node.kind === 163 /* PropertyDeclaration */; + node.kind === 259 /* ModuleBlock */ || + node.kind === 299 /* SourceFile */ || + node.kind === 165 /* PropertyDeclaration */; }); } // Check if a parameter is assigned anywhere within its declaring function. function isParameterAssigned(symbol) { + if (!symbol.valueDeclaration) { + return false; + } var func = ts.getRootDeclaration(symbol.valueDeclaration).parent; var links = getNodeLinks(func); if (!(links.flags & 8388608 /* AssignmentsMarked */)) { @@ -64755,10 +67173,10 @@ var ts; return !!ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !!(getNodeLinks(node).flags & 8388608 /* AssignmentsMarked */); }); } function markParameterAssignments(node) { - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 160 /* Parameter */) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 162 /* Parameter */) { symbol.isAssigned = true; } } @@ -64774,7 +67192,7 @@ var ts; function removeOptionalityFromDeclaredType(declaredType, declaration) { if (pushTypeResolution(declaration.symbol, 2 /* DeclaredType */)) { var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 160 /* Parameter */ && + declaration.kind === 162 /* Parameter */ && declaration.initializer && getFalsyFlags(declaredType) & 32768 /* Undefined */ && !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* Undefined */); @@ -64788,23 +67206,40 @@ var ts; } function isConstraintPosition(node) { var parent = node.parent; - return parent.kind === 201 /* PropertyAccessExpression */ || - parent.kind === 203 /* CallExpression */ && parent.expression === node || - parent.kind === 202 /* ElementAccessExpression */ && parent.expression === node || - parent.kind === 198 /* BindingElement */ && parent.name === node && !!parent.initializer; - } - function typeHasNullableConstraint(type) { - return type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 98304 /* Nullable */); - } - function getConstraintForLocation(type, node) { - // When a node is the left hand expression of a property access, element access, or call expression, - // and the type of the node includes type variables with constraints that are nullable, we fetch the - // apparent type of the node *before* performing control flow analysis such that narrowings apply to - // the constraint type. - if (type && isConstraintPosition(node) && forEachType(type, typeHasNullableConstraint)) { - return mapType(getWidenedType(type), getBaseConstraintOrType); - } - return type; + // In an element access obj[x], we consider obj to be in a constraint position only when x is not + // of 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 === 203 /* PropertyAccessExpression */ || + parent.kind === 205 /* CallExpression */ && parent.expression === node || + parent.kind === 204 /* ElementAccessExpression */ && parent.expression === node && + !isGenericIndexType(getTypeOfExpression(parent.argumentExpression)); + } + function isGenericTypeWithUnionConstraint(type) { + return !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */)); + } + function containsGenericType(type) { + return !!(type.flags & 465829888 /* Instantiable */ || type.flags & 3145728 /* UnionOrIntersection */ && ts.some(type.types, containsGenericType)); + } + function hasNonBindingPatternContextualTypeWithNoGenericTypes(node) { + // Computing the contextual type for a child of a JSX element involves resolving the type of the + // element's tag name, so we exclude that here to avoid circularities. + var contextualType = (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) && + !((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && + getContextualType(node, 8 /* SkipBindingPatterns */); + return contextualType && !someType(contextualType, containsGenericType); + } + function getNarrowableTypeForReference(type, reference, checkMode) { + // When the type of a reference is or contains an instantiable type with a union type constraint, and + // when the reference is in a constraint position (where it is known we'll obtain the apparent type) or + // has a contextual type containing no top-level instantiables (meaning constraints will determine + // assignability), we substitute constraints for all instantiables in the type of the reference to give + // 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 */) && + someType(type, isGenericTypeWithUnionConstraint) && + (isConstraintPosition(reference) || hasNonBindingPatternContextualTypeWithNoGenericTypes(reference)); + return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type; } function isExportOrExportExpression(location) { return !!ts.findAncestor(location, function (e) { return e.parent && ts.isExportAssignment(e.parent) && e.parent.expression === e && ts.isEntityNameExpression(e); }); @@ -64813,7 +67248,12 @@ var ts; if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) { var target = resolveAlias(symbol); if (target.flags & 111551 /* Value */) { - if (compilerOptions.preserveConstEnums && isExportOrExportExpression(location) || !isConstEnumOrConstEnumOnlyModule(target)) { + // 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. + if (compilerOptions.isolatedModules || + ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(location) || + !isConstEnumOrConstEnumOnlyModule(target)) { markAliasSymbolAsReferenced(symbol); } else { @@ -64822,7 +67262,7 @@ var ts; } } } - function checkIdentifier(node) { + function checkIdentifier(node, checkMode) { var symbol = getResolvedSymbol(node); if (symbol === unknownSymbol) { return errorType; @@ -64836,7 +67276,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 209 /* ArrowFunction */) { + if (container.kind === 211 /* 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 */)) { @@ -64853,15 +67293,15 @@ var ts; } var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); var sourceSymbol = localOrExportSymbol.flags & 2097152 /* Alias */ ? resolveAlias(localOrExportSymbol) : localOrExportSymbol; - if (getDeclarationNodeFlagsFromSymbol(sourceSymbol) & 134217728 /* Deprecated */ && isUncalledFunctionReference(node, sourceSymbol)) { - errorOrSuggestion(/* isError */ false, node, ts.Diagnostics._0_is_deprecated, node.escapedText); + if (sourceSymbol.declarations && getDeclarationNodeFlagsFromSymbol(sourceSymbol) & 134217728 /* Deprecated */ && isUncalledFunctionReference(node, sourceSymbol)) { + addDeprecatedSuggestion(node, sourceSymbol.declarations, node.escapedText); } var declaration = localOrExportSymbol.valueDeclaration; - if (localOrExportSymbol.flags & 32 /* Class */) { + if (declaration && localOrExportSymbol.flags & 32 /* 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 === 252 /* ClassDeclaration */ + if (declaration.kind === 254 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -64873,14 +67313,14 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 221 /* ClassExpression */) { + else if (declaration.kind === 223 /* 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 !== 297 /* SourceFile */) { + while (container.kind !== 299 /* SourceFile */) { if (container.parent === declaration) { - if (container.kind === 163 /* PropertyDeclaration */ && ts.hasSyntacticModifier(container, 32 /* Static */)) { + if (container.kind === 165 /* PropertyDeclaration */ && ts.hasSyntacticModifier(container, 32 /* Static */)) { getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; } @@ -64891,12 +67331,18 @@ var ts; } } checkNestedBlockScopedBinding(node, symbol); - var type = getConstraintForLocation(getTypeOfSymbol(localOrExportSymbol), node); + var type = getTypeOfSymbol(localOrExportSymbol); var assignmentKind = ts.getAssignmentTargetKind(node); if (assignmentKind) { if (!(localOrExportSymbol.flags & 3 /* Variable */) && !(ts.isInJSFile(node) && localOrExportSymbol.flags & 512 /* ValueModule */)) { - error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_not_a_variable, symbolToString(symbol)); + 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 + : ts.Diagnostics.Cannot_assign_to_0_because_it_is_not_a_variable; + error(node, assignmentError, symbolToString(symbol)); return errorType; } if (isReadonlySymbol(localOrExportSymbol)) { @@ -64918,7 +67364,7 @@ var ts; } } else if (isAlias) { - declaration = ts.find(symbol.declarations, isSomeImportDeclaration); + declaration = getDeclarationOfAliasSymbol(symbol); } else { return type; @@ -64926,10 +67372,11 @@ var ts; if (!declaration) { return type; } + type = getNarrowableTypeForReference(type, node, checkMode); // 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 === 160 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 162 /* Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; @@ -64938,8 +67385,8 @@ var ts; // 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 === 208 /* FunctionExpression */ || - flowContainer.kind === 209 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 210 /* FunctionExpression */ || + flowContainer.kind === 211 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -64948,9 +67395,9 @@ var ts; // 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 === 270 /* ExportSpecifier */) || - node.parent.kind === 225 /* NonNullExpression */ || - declaration.kind === 249 /* VariableDeclaration */ && declaration.exclamationToken || + isInTypeQuery(node) || node.parent.kind === 272 /* ExportSpecifier */) || + node.parent.kind === 227 /* NonNullExpression */ || + declaration.kind === 251 /* VariableDeclaration */ && declaration.exclamationToken || declaration.flags & 8388608 /* Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : @@ -64975,17 +67422,21 @@ var ts; } return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } - function isInsideFunction(node, threshold) { - return !!ts.findAncestor(node, function (n) { return n === threshold ? "quit" : ts.isFunctionLike(n); }); + 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); }); } function getPartOfForStatementContainingNode(node, container) { return ts.findAncestor(node, function (n) { return n === container ? "quit" : n === container.initializer || n === container.condition || n === container.incrementor || n === container.statement; }); } + function getEnclosingIterationStatement(node) { + 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 || + !symbol.valueDeclaration || ts.isSourceFile(symbol.valueDeclaration) || - symbol.valueDeclaration.parent.kind === 287 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 289 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -64993,22 +67444,14 @@ var ts; // 2. walk from the declaration up to the boundary of lexical environment and check // if there is an iteration statement in between declaration and boundary (is binding/class declared inside iteration statement) var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); - var usedInFunction = isInsideFunction(node.parent, container); - var current = container; - var containedInIterationStatement = false; - while (current && !ts.nodeStartsNewLexicalEnvironment(current)) { - if (ts.isIterationStatement(current, /*lookInLabeledStatements*/ false)) { - containedInIterationStatement = true; - break; - } - current = current.parent; - } - if (containedInIterationStatement) { - if (usedInFunction) { + var isCaptured = isInsideFunctionOrInstancePropertyInitializer(node, container); + var enclosingIterationStatement = getEnclosingIterationStatement(container); + if (enclosingIterationStatement) { + if (isCaptured) { // 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, 250 /* VariableDeclarationList */); + var varDeclList = ts.getAncestor(symbol.valueDeclaration, 252 /* VariableDeclarationList */); if (varDeclList && varDeclList.parent === container) { var part = getPartOfForStatementContainingNode(node.parent, container); if (part) { @@ -65023,13 +67466,13 @@ var ts; } } if (capturesBlockScopeBindingInLoopBody) { - getNodeLinks(current).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */; + getNodeLinks(enclosingIterationStatement).flags |= 65536 /* 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, 250 /* VariableDeclarationList */); + var varDeclList = ts.getAncestor(symbol.valueDeclaration, 252 /* VariableDeclarationList */); if (varDeclList && varDeclList.parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NeedsLoopOutParameter */; } @@ -65037,7 +67480,7 @@ var ts; // set 'declared inside loop' bit on the block-scoped binding getNodeLinks(symbol.valueDeclaration).flags |= 524288 /* BlockScopedBindingInLoop */; } - if (usedInFunction) { + if (isCaptured) { getNodeLinks(symbol.valueDeclaration).flags |= 262144 /* CapturedBlockScopedBinding */; } } @@ -65048,7 +67491,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 207 /* ParenthesizedExpression */) { + while (current.parent.kind === 209 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -65056,7 +67499,7 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 214 /* PrefixUnaryExpression */ || current.parent.kind === 215 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 216 /* PrefixUnaryExpression */ || current.parent.kind === 217 /* PostfixUnaryExpression */)) { var expr = current.parent; isAssigned = expr.operator === 45 /* PlusPlusToken */ || expr.operator === 46 /* MinusMinusToken */; } @@ -65069,7 +67512,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 163 /* PropertyDeclaration */ || container.kind === 166 /* Constructor */) { + if (container.kind === 165 /* PropertyDeclaration */ || container.kind === 168 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -65109,37 +67552,37 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var capturedByArrowFunction = false; - if (container.kind === 166 /* Constructor */) { + if (container.kind === 168 /* 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 === 209 /* ArrowFunction */) { + if (container.kind === 211 /* ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); capturedByArrowFunction = true; } switch (container.kind) { - case 256 /* ModuleDeclaration */: + case 258 /* 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 255 /* EnumDeclaration */: + case 257 /* 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 166 /* Constructor */: + case 168 /* 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 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - if (ts.hasSyntacticModifier(container, 32 /* Static */) && !(compilerOptions.target === 99 /* ESNext */ && compilerOptions.useDefineForClassFields)) { + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + if (ts.hasSyntacticModifier(container, 32 /* Static */) && !(compilerOptions.target === 99 /* ESNext */ && useDefineForClassFields)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } break; - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -65227,7 +67670,7 @@ var ts; } function getClassNameFromPrototypeMethod(container) { // Check if it's the RHS of a x.prototype.y = function [name]() { .... } - if (container.kind === 208 /* FunctionExpression */ && + if (container.kind === 210 /* FunctionExpression */ && ts.isBinaryExpression(container.parent) && ts.getAssignmentDeclarationKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = container' @@ -65237,16 +67680,16 @@ var ts; .expression; // x } // x.prototype = { method() { } } - else if (container.kind === 165 /* MethodDeclaration */ && - container.parent.kind === 200 /* ObjectLiteralExpression */ && + else if (container.kind === 167 /* MethodDeclaration */ && + container.parent.kind === 202 /* ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent) === 6 /* Prototype */) { return container.parent.parent.left.expression; } // x.prototype = { method: function() { } } - else if (container.kind === 208 /* FunctionExpression */ && - container.parent.kind === 288 /* PropertyAssignment */ && - container.parent.parent.kind === 200 /* ObjectLiteralExpression */ && + else if (container.kind === 210 /* FunctionExpression */ && + container.parent.kind === 290 /* PropertyAssignment */ && + container.parent.parent.kind === 202 /* ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* Prototype */) { return container.parent.parent.parent.left.expression; @@ -65254,7 +67697,7 @@ var ts; // Object.defineProperty(x, "method", { value: function() { } }); // Object.defineProperty(x, "method", { set: (x: () => void) => void }); // Object.defineProperty(x, "method", { get: () => function() { }) }); - else if (container.kind === 208 /* FunctionExpression */ && + else if (container.kind === 210 /* 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") && @@ -65279,7 +67722,7 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 308 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 311 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -65293,16 +67736,16 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 160 /* Parameter */ && n.parent === constructorDecl; }); + return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 162 /* Parameter */ && n.parent === constructorDecl; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 203 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 205 /* 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 === 209 /* ArrowFunction */) { + while (container && container.kind === 211 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -65315,14 +67758,14 @@ var ts; // class B { // [super.foo()]() {} // } - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 158 /* ComputedPropertyName */; }); - if (current && current.kind === 158 /* ComputedPropertyName */) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 160 /* ComputedPropertyName */; }); + if (current && current.kind === 160 /* 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 === 200 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 202 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -65330,7 +67773,7 @@ var ts; } return errorType; } - if (!isCallExpression && immediateContainer.kind === 166 /* Constructor */) { + if (!isCallExpression && immediateContainer.kind === 168 /* 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.hasSyntacticModifier(container, 32 /* Static */) || isCallExpression) { @@ -65399,7 +67842,7 @@ 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 === 165 /* MethodDeclaration */ && ts.hasSyntacticModifier(container, 256 /* Async */)) { + if (container.kind === 167 /* MethodDeclaration */ && ts.hasSyntacticModifier(container, 256 /* Async */)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; } @@ -65413,7 +67856,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 200 /* ObjectLiteralExpression */) { + if (container.parent.kind === 202 /* ObjectLiteralExpression */) { if (languageVersion < 2 /* ES2015 */) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return errorType; @@ -65434,7 +67877,7 @@ var ts; if (!baseClassType) { return errorType; } - if (container.kind === 166 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 168 /* 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; @@ -65449,7 +67892,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 === 166 /* Constructor */; + return container.kind === 168 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -65457,21 +67900,21 @@ 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 === 200 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 202 /* ObjectLiteralExpression */) { if (ts.hasSyntacticModifier(container, 32 /* Static */)) { - return container.kind === 165 /* MethodDeclaration */ || - container.kind === 164 /* MethodSignature */ || - container.kind === 167 /* GetAccessor */ || - container.kind === 168 /* SetAccessor */; + return container.kind === 167 /* MethodDeclaration */ || + container.kind === 166 /* MethodSignature */ || + container.kind === 169 /* GetAccessor */ || + container.kind === 170 /* SetAccessor */; } else { - return container.kind === 165 /* MethodDeclaration */ || - container.kind === 164 /* MethodSignature */ || - container.kind === 167 /* GetAccessor */ || - container.kind === 168 /* SetAccessor */ || - container.kind === 163 /* PropertyDeclaration */ || - container.kind === 162 /* PropertySignature */ || - container.kind === 166 /* Constructor */; + return container.kind === 167 /* MethodDeclaration */ || + container.kind === 166 /* MethodSignature */ || + container.kind === 169 /* GetAccessor */ || + container.kind === 170 /* SetAccessor */ || + container.kind === 165 /* PropertyDeclaration */ || + container.kind === 164 /* PropertySignature */ || + container.kind === 168 /* Constructor */; } } } @@ -65479,10 +67922,10 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 165 /* MethodDeclaration */ || - func.kind === 167 /* GetAccessor */ || - func.kind === 168 /* SetAccessor */) && func.parent.kind === 200 /* ObjectLiteralExpression */ ? func.parent : - func.kind === 208 /* FunctionExpression */ && func.parent.kind === 288 /* PropertyAssignment */ ? func.parent.parent : + return (func.kind === 167 /* MethodDeclaration */ || + func.kind === 169 /* GetAccessor */ || + func.kind === 170 /* SetAccessor */) && func.parent.kind === 202 /* ObjectLiteralExpression */ ? func.parent : + func.kind === 210 /* FunctionExpression */ && func.parent.kind === 290 /* PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { @@ -65494,7 +67937,7 @@ var ts; }); } function getContextualThisParameterType(func) { - if (func.kind === 209 /* ArrowFunction */) { + if (func.kind === 211 /* ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -65521,7 +67964,7 @@ var ts; if (thisType) { return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral))); } - if (literal.parent.kind !== 288 /* PropertyAssignment */) { + if (literal.parent.kind !== 290 /* PropertyAssignment */) { break; } literal = literal.parent.parent; @@ -65535,7 +67978,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 === 216 /* BinaryExpression */ && parent.operatorToken.kind === 62 /* EqualsToken */) { + if (parent.kind === 218 /* BinaryExpression */ && parent.operatorToken.kind === 63 /* EqualsToken */) { var target = parent.left; if (ts.isAccessExpression(target)) { var expression = target.expression; @@ -65588,11 +68031,11 @@ var ts; return getTypeFromTypeNode(typeNode); } switch (declaration.kind) { - case 160 /* Parameter */: + case 162 /* Parameter */: return getContextuallyTypedParameterType(declaration); - case 198 /* BindingElement */: + case 200 /* BindingElement */: return getContextualTypeForBindingElement(declaration); - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: if (ts.hasSyntacticModifier(declaration, 32 /* Static */)) { return getContextualTypeForStaticPropertyDeclaration(declaration); } @@ -65603,10 +68046,10 @@ var ts; var parent = declaration.parent.parent; var name = declaration.propertyName || declaration.name; var parentType = getContextualTypeForVariableLikeDeclaration(parent) || - parent.kind !== 198 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent); + parent.kind !== 200 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent); if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name)) return undefined; - if (parent.name.kind === 197 /* ArrayBindingPattern */) { + if (parent.name.kind === 199 /* ArrayBindingPattern */) { var index = ts.indexOfNode(declaration.parent.elements, declaration); if (index < 0) return undefined; @@ -65740,10 +68183,13 @@ var ts; if (ts.isJsxOpeningLikeElement(callTarget) && argIndex === 0) { return getEffectiveFirstArgumentForJsxSignature(signature, callTarget); } - return getTypeAtPosition(signature, argIndex); + var restIndex = signature.parameters.length - 1; + return signatureHasRestParameter(signature) && argIndex >= restIndex ? + getIndexedAccessType(getTypeOfSymbol(signature.parameters[restIndex]), getLiteralType(argIndex - restIndex), 256 /* Contextual */) : + getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 205 /* TaggedTemplateExpression */) { + if (template.parent.kind === 207 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -65752,10 +68198,10 @@ var ts; var binaryExpression = node.parent; var left = binaryExpression.left, operatorToken = binaryExpression.operatorToken, right = binaryExpression.right; switch (operatorToken.kind) { - case 62 /* EqualsToken */: - case 75 /* AmpersandAmpersandEqualsToken */: - case 74 /* BarBarEqualsToken */: - case 76 /* QuestionQuestionEqualsToken */: + case 63 /* EqualsToken */: + case 76 /* AmpersandAmpersandEqualsToken */: + case 75 /* BarBarEqualsToken */: + case 77 /* QuestionQuestionEqualsToken */: return node === right ? getContextualTypeForAssignmentDeclaration(binaryExpression) : undefined; case 56 /* BarBarToken */: case 60 /* QuestionQuestionToken */: @@ -65777,16 +68223,16 @@ var ts; // In an assignment expression, the right operand is contextually typed by the type of the left operand. // Don't do this for assignment declarations unless there is a type tag on the assignment, to avoid circularity from checking the right operand. function getContextualTypeForAssignmentDeclaration(binaryExpression) { + var _a, _b; var kind = ts.getAssignmentDeclarationKind(binaryExpression); switch (kind) { case 0 /* None */: return getTypeOfExpression(binaryExpression.left); + case 4 /* ThisProperty */: + return getContextualTypeForThisPropertyAssignment(binaryExpression); case 5 /* Property */: - case 1 /* ExportsProperty */: - case 6 /* Prototype */: - case 3 /* PrototypeProperty */: if (isPossiblyAliasedThisProperty(binaryExpression, kind)) { - return getContextualTypeForThisPropertyAssignment(binaryExpression, kind); + return getContextualTypeForThisPropertyAssignment(binaryExpression); } // If `binaryExpression.left` was assigned a symbol, then this is a new declaration; otherwise it is an assignment to an existing declaration. // See `bindStaticPropertyAssignment` in `binder.ts`. @@ -65807,11 +68253,11 @@ var ts; var id = lhs.expression; var parentSymbol = resolveName(id, id.escapedText, 111551 /* Value */, undefined, id.escapedText, /*isUse*/ true); if (parentSymbol) { - var annotated = parentSymbol.valueDeclaration && ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration); - if (annotated) { + var annotated_1 = parentSymbol.valueDeclaration && ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration); + if (annotated_1) { var nameStr = ts.getElementOrPropertyAccessName(lhs); if (nameStr !== undefined) { - return getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated), nameStr); + return getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated_1), nameStr); } } return undefined; @@ -65819,9 +68265,15 @@ var ts; } return ts.isInJSFile(decl) ? undefined : getTypeOfExpression(binaryExpression.left); } + case 1 /* ExportsProperty */: + case 6 /* Prototype */: + case 3 /* PrototypeProperty */: + var valueDeclaration = (_a = binaryExpression.left.symbol) === null || _a === void 0 ? void 0 : _a.valueDeclaration; + // falls through case 2 /* ModuleExports */: - case 4 /* ThisProperty */: - return getContextualTypeForThisPropertyAssignment(binaryExpression, kind); + 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 */: @@ -65842,7 +68294,7 @@ var ts; var symbol = resolveName(declaration.left, name, 111551 /* Value */, undefined, undefined, /*isUse*/ true, /*excludeGlobals*/ true); return ts.isThisInitializedDeclaration(symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration); } - function getContextualTypeForThisPropertyAssignment(binaryExpression, kind) { + function getContextualTypeForThisPropertyAssignment(binaryExpression) { if (!binaryExpression.symbol) return getTypeOfExpression(binaryExpression.left); if (binaryExpression.symbol.valueDeclaration) { @@ -65854,8 +68306,6 @@ var ts; } } } - if (kind === 2 /* ModuleExports */) - return undefined; var thisAccess = ts.cast(binaryExpression.left, ts.isAccessExpression); if (!ts.isObjectLiteralMethod(ts.getThisContainer(thisAccess.expression, /*includeArrowFunctions*/ false))) { return undefined; @@ -65910,9 +68360,13 @@ var ts; } function getContextualTypeForObjectLiteralElement(element, contextFlags) { var objectLiteral = element.parent; + var propertyAssignmentType = ts.isPropertyAssignment(element) && getContextualTypeForVariableLikeDeclaration(element); + if (propertyAssignmentType) { + return propertyAssignmentType; + } var type = getApparentTypeOfContextualType(objectLiteral, contextFlags); if (type) { - if (!hasNonBindableDynamicName(element)) { + if (hasBindableName(element)) { // For a (non-symbol) computed property, there is no reason to look up the name // in the type. It will just be "__computed", which does not appear in any // SymbolTable. @@ -65992,25 +68446,25 @@ var ts; case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: - case 103 /* NullKeyword */: - case 78 /* Identifier */: - case 150 /* UndefinedKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: + case 104 /* NullKeyword */: + case 79 /* Identifier */: + case 151 /* UndefinedKeyword */: return true; - case 201 /* PropertyAccessExpression */: - case 207 /* ParenthesizedExpression */: + case 203 /* PropertyAccessExpression */: + case 209 /* ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: return !node.expression || isPossiblyDiscriminantValue(node.expression); } return false; } function discriminateContextualTypeByObjectMembers(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 288 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); + return getMatchingUnionConstituentForObjectLiteral(contextualType, node) || discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 290 /* 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); } function discriminateContextualTypeByJSXAttributes(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 280 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return checkExpression(prop.initializer); }), prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 282 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return checkExpression(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 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. @@ -66021,15 +68475,9 @@ var ts; var instantiatedType = instantiateContextualType(contextualType, node, contextFlags); if (instantiatedType && !(contextFlags && contextFlags & 2 /* NoConstraints */ && instantiatedType.flags & 8650752 /* TypeVariable */)) { var apparentType = mapType(instantiatedType, getApparentType, /*noReductions*/ true); - if (apparentType.flags & 1048576 /* Union */) { - if (ts.isObjectLiteralExpression(node)) { - return discriminateContextualTypeByObjectMembers(node, apparentType); - } - else if (ts.isJsxAttributes(node)) { - return discriminateContextualTypeByJSXAttributes(node, apparentType); - } - } - return apparentType; + return apparentType.flags & 1048576 /* Union */ && ts.isObjectLiteralExpression(node) ? discriminateContextualTypeByObjectMembers(node, apparentType) : + apparentType.flags & 1048576 /* Union */ && ts.isJsxAttributes(node) ? discriminateContextualTypeByJSXAttributes(node, apparentType) : + apparentType; } } // If the given contextual type contains instantiable types and if a mapper representing @@ -66096,58 +68544,60 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 249 /* VariableDeclaration */: - case 160 /* Parameter */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 198 /* BindingElement */: + case 251 /* VariableDeclaration */: + case 162 /* Parameter */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 200 /* BindingElement */: return getContextualTypeForInitializerExpression(node, contextFlags); - case 209 /* ArrowFunction */: - case 242 /* ReturnStatement */: + case 211 /* ArrowFunction */: + case 244 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 213 /* AwaitExpression */: + case 215 /* AwaitExpression */: return getContextualTypeForAwaitOperand(parent, contextFlags); - case 203 /* CallExpression */: - if (parent.expression.kind === 99 /* ImportKeyword */) { + case 205 /* CallExpression */: + if (parent.expression.kind === 100 /* ImportKeyword */) { return stringType; } /* falls through */ - case 204 /* NewExpression */: + case 206 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 206 /* TypeAssertionExpression */: - case 224 /* AsExpression */: + case 208 /* TypeAssertionExpression */: + case 226 /* AsExpression */: return ts.isConstTypeReference(parent.type) ? tryFindWhenConstTypeReference(parent) : getTypeFromTypeNode(parent.type); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node, contextFlags); - case 288 /* PropertyAssignment */: - case 289 /* ShorthandPropertyAssignment */: + case 290 /* PropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent, contextFlags); - case 290 /* SpreadAssignment */: - return getApparentTypeOfContextualType(parent.parent, contextFlags); - case 199 /* ArrayLiteralExpression */: { + case 292 /* SpreadAssignment */: + return getContextualType(parent.parent, contextFlags); + case 201 /* ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral, contextFlags); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node, contextFlags); - case 228 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 218 /* TemplateExpression */); + case 230 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 220 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 207 /* ParenthesizedExpression */: { + case 209 /* 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 ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent, contextFlags); } - case 283 /* JsxExpression */: + case 227 /* NonNullExpression */: + return getContextualType(parent, contextFlags); + case 285 /* JsxExpression */: return getContextualTypeForJsxExpression(parent); - case 280 /* JsxAttribute */: - case 282 /* JsxSpreadAttribute */: + case 282 /* JsxAttribute */: + case 284 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 275 /* JsxOpeningElement */: - case 274 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent, contextFlags); } return undefined; @@ -66183,14 +68633,14 @@ var ts; return propsType; } function getJsxPropsTypeForSignatureFromMember(sig, forcedLookupLocation) { - if (sig.unionSignatures) { + if (sig.compositeSignatures) { // JSX Elements using the legacy `props`-field based lookup (eg, react class components) need to treat the `props` member as an input // instead of an output position when resolving the signature. We need to go back to the input signatures of the composite signature, // get the type of `props` on each return type individually, and then _intersect them_, rather than union them (as would normally occur // for a union signature). It's an unfortunate quirk of looking in the output of the signature for the type we want to use for the input. // The default behavior of `getTypeOfFirstParameterOfSignatureWithFallback` when no `props` member name is defined is much more sane. var results = []; - for (var _i = 0, _a = sig.unionSignatures; _i < _a.length; _i++) { + for (var _i = 0, _a = sig.compositeSignatures; _i < _a.length; _i++) { var signature = _a[_i]; var instance = getReturnTypeOfSignature(signature); if (isTypeAny(instance)) { @@ -66202,7 +68652,7 @@ var ts; } results.push(propType); } - return getIntersectionType(results); + return getIntersectionType(results); // Same result for both union and intersection signatures } var instanceType = getReturnTypeOfSignature(sig); return isTypeAny(instanceType) ? instanceType : getTypeOfPropertyOfType(instanceType, forcedLookupLocation); @@ -66227,16 +68677,19 @@ var ts; function getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType) { var managedSym = getJsxLibraryManagedAttributes(ns); if (managedSym) { - var declaredManagedType = getDeclaredTypeOfSymbol(managedSym); + var declaredManagedType = getDeclaredTypeOfSymbol(managedSym); // fetches interface type, or initializes symbol links type parmaeters var ctorType = getStaticTypeOfReferencedJsxConstructor(context); + if (managedSym.flags & 524288 /* TypeAlias */) { + var params = getSymbolLinks(managedSym).typeParameters; + if (ts.length(params) >= 2) { + var args = fillMissingTypeArguments([ctorType, attributesType], params, 2, ts.isInJSFile(context)); + return getTypeAliasInstantiation(managedSym, args); + } + } if (ts.length(declaredManagedType.typeParameters) >= 2) { var args = fillMissingTypeArguments([ctorType, attributesType], declaredManagedType.typeParameters, 2, ts.isInJSFile(context)); return createTypeReference(declaredManagedType, args); } - else if (ts.length(declaredManagedType.aliasTypeArguments) >= 2) { - var args = fillMissingTypeArguments([ctorType, attributesType], declaredManagedType.aliasTypeArguments, 2, ts.isInJSFile(context)); - return getTypeAliasInstantiation(declaredManagedType.aliasSymbol, args); - } } return attributesType; } @@ -66281,16 +68734,93 @@ var ts; return apparentAttributesType; } } + function getIntersectedSignatures(signatures) { + return ts.getStrictOptionValue(compilerOptions, "noImplicitAny") + ? ts.reduceLeft(signatures, function (left, right) { + return left === right || !left ? left + : compareTypeParametersIdentical(left.typeParameters, right.typeParameters) ? combineSignaturesOfIntersectionMembers(left, right) + : undefined; + }) + : undefined; + } + function combineIntersectionThisParam(left, right, mapper) { + if (!left || !right) { + return left || right; + } + // A signature `this` type might be a read or a write position... It's very possible that it should be invariant + // and we should refuse to merge signatures if there are `this` types and they do not match. However, so as to be + // pessimistic when contextual typing, for now, we'll union the `this` types. + var thisType = getUnionType([getTypeOfSymbol(left), instantiateType(getTypeOfSymbol(right), mapper)]); + return createSymbolWithType(left, thisType); + } + function combineIntersectionParameters(left, right, mapper) { + var leftCount = getParameterCount(left); + var rightCount = getParameterCount(right); + var longest = leftCount >= rightCount ? left : right; + var shorter = longest === left ? right : left; + var longestCount = longest === left ? leftCount : rightCount; + var eitherHasEffectiveRest = (hasEffectiveRestParameter(left) || hasEffectiveRestParameter(right)); + var needsExtraRestElement = eitherHasEffectiveRest && !hasEffectiveRestParameter(longest); + var params = new Array(longestCount + (needsExtraRestElement ? 1 : 0)); + for (var i = 0; i < longestCount; i++) { + var longestParamType = tryGetTypeAtPosition(longest, i); + if (longest === right) { + longestParamType = instantiateType(longestParamType, mapper); + } + var shorterParamType = tryGetTypeAtPosition(shorter, i) || unknownType; + if (shorter === right) { + shorterParamType = instantiateType(shorterParamType, mapper); + } + var unionParamType = getUnionType([longestParamType, shorterParamType]); + var isRestParam = eitherHasEffectiveRest && !needsExtraRestElement && i === (longestCount - 1); + var isOptional = i >= getMinArgumentCount(longest) && i >= getMinArgumentCount(shorter); + var leftName = i >= leftCount ? undefined : getParameterNameAtPosition(left, i); + var rightName = i >= rightCount ? undefined : getParameterNameAtPosition(right, i); + var paramName = leftName === rightName ? leftName : + !leftName ? rightName : + !rightName ? leftName : + undefined; + var paramSymbol = createSymbol(1 /* FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* Optional */ : 0), paramName || "arg" + i); + paramSymbol.type = isRestParam ? createArrayType(unionParamType) : unionParamType; + params[i] = paramSymbol; + } + if (needsExtraRestElement) { + var restParamSymbol = createSymbol(1 /* FunctionScopedVariable */, "args"); + restParamSymbol.type = createArrayType(getTypeAtPosition(shorter, longestCount)); + if (shorter === right) { + restParamSymbol.type = instantiateType(restParamSymbol.type, mapper); + } + params[longestCount] = restParamSymbol; + } + return params; + } + function combineSignaturesOfIntersectionMembers(left, right) { + var typeParams = left.typeParameters || right.typeParameters; + var paramMapper; + if (left.typeParameters && right.typeParameters) { + paramMapper = createTypeMapper(right.typeParameters, left.typeParameters); + // We just use the type parameter defaults from the first signature + } + var declaration = left.declaration; + var params = combineIntersectionParameters(left, right, paramMapper); + var thisParam = combineIntersectionThisParam(left.thisParameter, right.thisParameter, paramMapper); + 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]); + if (paramMapper) { + result.mapper = left.compositeKind === 2097152 /* 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 */); - if (signatures.length === 1) { - var signature = signatures[0]; - if (!isAritySmaller(signature, node)) { - return signature; - } - } + var applicableByArity = ts.filter(signatures, function (s) { return !isAritySmaller(s, node); }); + return applicableByArity.length === 1 ? applicableByArity[0] : getIntersectedSignatures(applicableByArity); } /** If the contextual signature has fewer parameters than the function expression, do not use it */ function isAritySmaller(signature, target) { @@ -66307,7 +68837,7 @@ var ts; return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 208 /* FunctionExpression */ || node.kind === 209 /* ArrowFunction */; + return node.kind === 210 /* FunctionExpression */ || node.kind === 211 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -66321,7 +68851,7 @@ 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 !== 165 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 167 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var typeTagSignature = getSignatureOfTypeTag(node); if (typeTagSignature) { return typeTagSignature; @@ -66369,8 +68899,8 @@ var ts; return node.isSpread ? getIndexedAccessType(node.type, numberType) : node.type; } function hasDefaultValue(node) { - return (node.kind === 198 /* BindingElement */ && !!node.initializer) || - (node.kind === 216 /* BinaryExpression */ && node.operatorToken.kind === 62 /* EqualsToken */); + return (node.kind === 200 /* BindingElement */ && !!node.initializer) || + (node.kind === 218 /* BinaryExpression */ && node.operatorToken.kind === 63 /* EqualsToken */); } function checkArrayLiteral(node, checkMode, forceTuple) { var elements = node.elements; @@ -66380,9 +68910,10 @@ var ts; var contextualType = getApparentTypeOfContextualType(node); 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 === 220 /* SpreadElement */) { + if (e.kind === 222 /* SpreadElement */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(e, compilerOptions.downlevelIteration ? 1536 /* SpreadIncludes */ : 1024 /* SpreadArray */); } @@ -66415,17 +68946,22 @@ var ts; elementFlags.push(4 /* Rest */); } } + else if (strictOptionalProperties && e.kind === 224 /* OmittedExpression */) { + hasOmittedExpression = true; + elementTypes.push(missingType); + elementFlags.push(2 /* Optional */); + } else { var elementContextualType = getContextualTypeForElementExpression(contextualType, elementTypes.length); var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple); - elementTypes.push(type); - elementFlags.push(1 /* Required */); + elementTypes.push(addOptionality(type, /*isProperty*/ true, hasOmittedExpression)); + elementFlags.push(hasOmittedExpression ? 2 /* Optional */ : 1 /* Required */); } } if (inDestructuringPattern) { return createTupleType(elementTypes, elementFlags); } - if (forceTuple || inConstContext || contextualType && forEachType(contextualType, isTupleLikeType)) { + if (forceTuple || inConstContext || contextualType && someType(contextualType, isTupleLikeType)) { return createArrayLiteralType(createTupleType(elementTypes, elementFlags, /*readonly*/ inConstContext)); } return createArrayLiteralType(createArrayType(elementTypes.length ? @@ -66439,15 +68975,15 @@ var ts; var literalType = type.literalType; if (!literalType) { literalType = type.literalType = cloneTypeReference(type); - literalType.objectFlags |= 65536 /* ArrayLiteral */ | 1048576 /* ContainsObjectOrArrayLiteral */; + literalType.objectFlags |= 32768 /* ArrayLiteral */ | 262144 /* ContainsObjectOrArrayLiteral */; } return literalType; } function isNumericName(name) { switch (name.kind) { - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return isNumericComputedName(name); - case 78 /* Identifier */: + case 79 /* Identifier */: return isNumericLiteralName(name.escapedText); case 8 /* NumericLiteral */: case 10 /* StringLiteral */: @@ -66492,6 +69028,20 @@ var ts; var links = getNodeLinks(node.expression); if (!links.resolvedType) { links.resolvedType = checkExpression(node.expression); + // The computed property name of a non-static class field within a loop must be stored in a block-scoped binding. + // (It needs to be bound at class evaluation time.) + if (ts.isPropertyDeclaration(node.parent) && !ts.hasStaticModifier(node.parent) && ts.isClassExpression(node.parent.parent)) { + var container = ts.getEnclosingBlockScopeContainer(node.parent.parent); + 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 */; + // The generated variable which stores the computed field name must be block-scoped. + getNodeLinks(node).flags |= 524288 /* BlockScopedBindingInLoop */; + // The generated variable which stores the class must be block-scoped. + getNodeLinks(node.parent.parent).flags |= 524288 /* 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 */ || @@ -66499,9 +69049,6 @@ var ts; !isTypeAssignableTo(links.resolvedType, stringNumberSymbolType)) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } - else { - checkThatExpressionIsProperSymbolReference(node.expression, links.resolvedType, /*reportError*/ true); - } } return links.resolvedType; } @@ -66541,7 +69088,7 @@ var ts; var spread = emptyObjectType; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 196 /* ObjectBindingPattern */ || contextualType.pattern.kind === 200 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 198 /* ObjectBindingPattern */ || contextualType.pattern.kind === 202 /* ObjectLiteralExpression */); var inConstContext = isConstContext(node); var checkFlags = inConstContext ? 8 /* Readonly */ : 0; var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node); @@ -66556,7 +69103,7 @@ var ts; // which may never occur. for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; - if (elem.name && ts.isComputedPropertyName(elem.name) && !ts.isWellKnownSymbolSyntactically(elem.name)) { + if (elem.name && ts.isComputedPropertyName(elem.name)) { checkComputedPropertyName(elem.name); } } @@ -66564,16 +69111,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 === 158 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 160 /* ComputedPropertyName */ ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 288 /* PropertyAssignment */ || - memberDecl.kind === 289 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 290 /* PropertyAssignment */ || + memberDecl.kind === 291 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 288 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + var type = memberDecl.kind === 290 /* 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 === 289 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : + memberDecl.kind === 291 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJavascript) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -66585,7 +69132,7 @@ var ts; checkTypeAssignableTo(type, getTypeFromTypeNode(enumTag.typeExpression), memberDecl); } } - objectFlags |= ts.getObjectFlags(type) & 3670016 /* PropagatingFlags */; + objectFlags |= ts.getObjectFlags(type) & 917504 /* PropagatingFlags */; var nameType = computedNameType && isTypeUsableAsPropertyName(computedNameType) ? computedNameType : undefined; var prop = nameType ? createSymbol(4 /* Property */ | member.flags, getPropertyNameFromType(nameType), checkFlags | 4096 /* Late */) : @@ -66596,8 +69143,8 @@ var ts; 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 === 288 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 289 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 290 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 291 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216 /* Optional */; } @@ -66623,7 +69170,7 @@ var ts; member = prop; allPropertiesTable === null || allPropertiesTable === void 0 ? void 0 : allPropertiesTable.set(prop.escapedName, prop); } - else if (memberDecl.kind === 290 /* SpreadAssignment */) { + else if (memberDecl.kind === 292 /* SpreadAssignment */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } @@ -66635,15 +69182,20 @@ var ts; hasComputedNumberProperty = false; } var type = getReducedType(checkExpression(memberDecl.expression)); - if (!isValidSpreadType(type)) { - error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); - return errorType; + if (isValidSpreadType(type)) { + if (allPropertiesTable) { + checkSpreadPropOverrides(type, allPropertiesTable, memberDecl); + } + offset = propertiesArray.length; + if (spread === errorType) { + continue; + } + spread = getSpreadType(spread, type, node.symbol, objectFlags, inConstContext); } - if (allPropertiesTable) { - checkSpreadPropOverrides(type, allPropertiesTable, memberDecl); + else { + error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); + spread = errorType; } - spread = getSpreadType(spread, type, node.symbol, objectFlags, inConstContext); - offset = propertiesArray.length; continue; } else { @@ -66652,7 +69204,7 @@ 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 === 167 /* GetAccessor */ || memberDecl.kind === 168 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 169 /* GetAccessor */ || memberDecl.kind === 170 /* SetAccessor */); checkNodeDeferred(memberDecl); } if (computedNameType && !(computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */)) { @@ -66677,7 +69229,7 @@ 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 !== 290 /* SpreadAssignment */) { + if (contextualTypeHasPattern && node.parent.kind !== 292 /* 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)) { @@ -66689,6 +69241,9 @@ var ts; } } } + if (spread === errorType) { + return errorType; + } if (spread !== emptyObjectType) { if (propertiesArray.length > 0) { spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, objectFlags, inConstContext); @@ -66705,9 +69260,9 @@ var ts; var stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node, offset, propertiesArray, 0 /* String */) : undefined; var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, offset, propertiesArray, 1 /* Number */) : undefined; var result = createAnonymousType(node.symbol, propertiesTable, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); - result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 1048576 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 262144 /* ContainsObjectOrArrayLiteral */; if (isJSObjectLiteral) { - result.objectFlags |= 16384 /* JSLiteral */; + result.objectFlags |= 8192 /* JSLiteral */; } if (patternWithComputedProperties) { result.objectFlags |= 512 /* ObjectLiteralPatternWithComputedProperties */; @@ -66773,7 +69328,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 === 78 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); + return tagName.kind === 79 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); } function checkJsxAttribute(node, checkMode) { return node.initializer @@ -66797,14 +69352,14 @@ var ts; var hasSpreadAnyType = false; var typeToIntersect; var explicitlySpecifyChildrenAttribute = false; - var objectFlags = 4096 /* JsxAttributes */; + var objectFlags = 2048 /* 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) & 3670016 /* PropagatingFlags */; + objectFlags |= ts.getObjectFlags(exprType) & 917504 /* PropagatingFlags */; var attributeSymbol = createSymbol(4 /* Property */ | member.flags, member.escapedName); attributeSymbol.declarations = member.declarations; attributeSymbol.parent = member.parent; @@ -66820,7 +69375,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 282 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 284 /* JsxSpreadAttribute */); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, /*readonly*/ false); attributesTable = ts.createSymbolTable(); @@ -66846,7 +69401,7 @@ var ts; } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 273 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 275 /* 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); @@ -66862,7 +69417,7 @@ var ts; // 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); childrenPropSymbol.type = childrenTypes.length === 1 ? childrenTypes[0] : - childrenContextualType && forEachType(childrenContextualType, isTupleLikeType) ? createTupleType(childrenTypes) : + childrenContextualType && someType(childrenContextualType, isTupleLikeType) ? createTupleType(childrenTypes) : createArrayType(getUnionType(childrenTypes)); // Fake up a property declaration for the children childrenPropSymbol.valueDeclaration = ts.factory.createPropertySignature(/*modifiers*/ undefined, ts.unescapeLeadingUnderscores(jsxChildrenPropertyName), /*questionToken*/ undefined, /*type*/ undefined); @@ -66888,7 +69443,7 @@ var ts; function createJsxAttributesType() { objectFlags |= freshObjectLiteralFlag; var result = createAnonymousType(attributes.symbol, attributesTable, ts.emptyArray, ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); - result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 1048576 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 262144 /* ContainsObjectOrArrayLiteral */; return result; } } @@ -66903,7 +69458,7 @@ var ts; childrenTypes.push(stringType); } } - else if (child.kind === 283 /* JsxExpression */ && !child.expression) { + else if (child.kind === 285 /* JsxExpression */ && !child.expression) { continue; // empty jsx expressions don't *really* count as present children } else { @@ -67054,7 +69609,7 @@ var ts; else if (propertiesOfJsxElementAttribPropInterface.length === 1) { return propertiesOfJsxElementAttribPropInterface[0].escapedName; } - else if (propertiesOfJsxElementAttribPropInterface.length > 1) { + else if (propertiesOfJsxElementAttribPropInterface.length > 1 && jsxElementAttribPropInterfaceSym.declarations) { // More than one property on ElementAttributesProperty is an error error(jsxElementAttribPropInterfaceSym.declarations[0], ts.Diagnostics.The_global_type_JSX_0_may_not_have_more_than_one_property, ts.unescapeLeadingUnderscores(nameOfAttribPropContainer)); } @@ -67164,11 +69719,11 @@ var ts; if (!links.resolvedJsxElementAttributesType) { var symbol = getIntrinsicTagSymbol(node); if (links.jsxFlags & 1 /* IntrinsicNamedElement */) { - return links.resolvedJsxElementAttributesType = getTypeOfSymbol(symbol); + return links.resolvedJsxElementAttributesType = getTypeOfSymbol(symbol) || errorType; } else if (links.jsxFlags & 2 /* IntrinsicIndexedElement */) { return links.resolvedJsxElementAttributesType = - getIndexTypeOfType(getDeclaredTypeOfSymbol(symbol), 0 /* String */); + getIndexTypeOfType(getJsxType(JsxNames.IntrinsicElements, node), 0 /* String */) || errorType; } else { return links.resolvedJsxElementAttributesType = errorType; @@ -67321,9 +69876,12 @@ var ts; * @param type The type of the object whose property is being accessed. (Not the type of the property.) * @param prop The symbol for the property being accessed. */ - function checkPropertyAccessibility(node, isSuper, type, prop) { - var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 157 /* QualifiedName */ ? node.right : node.kind === 195 /* ImportType */ ? node : node.name; + function checkPropertyAccessibility(node, isSuper, writing, type, prop, reportError) { + if (reportError === void 0) { reportError = true; } + var flags = ts.getDeclarationModifierFlagsFromSymbol(prop, writing); + var errorNode = node.kind === 159 /* QualifiedName */ ? node.right : + node.kind === 197 /* ImportType */ ? node : + node.kind === 200 /* BindingElement */ && node.propertyName ? node.propertyName : node.name; if (isSuper) { // TS 1.0 spec (April 2014): 4.8.2 // - In a constructor, instance member function, instance member accessor, or @@ -67334,7 +69892,9 @@ var ts; // a super property access is permitted and must specify a public static member function of the base class. if (languageVersion < 2 /* ES2015 */) { if (symbolHasNonMethodDeclaration(prop)) { - error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); + if (reportError) { + error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); + } return false; } } @@ -67343,24 +69903,22 @@ var ts; // This error could mask a private property access error. But, a member // cannot simultaneously be private and abstract, so this will trigger an // additional error elsewhere. - error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(getDeclaringClass(prop))); + if (reportError) { + error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(getDeclaringClass(prop))); + } return false; } } // Referencing abstract properties within their own constructors is not allowed - if ((flags & 128 /* Abstract */) && ts.isThisProperty(node) && symbolHasNonMethodDeclaration(prop)) { + if ((flags & 128 /* Abstract */) && symbolHasNonMethodDeclaration(prop) && + (ts.isThisProperty(node) || ts.isThisInitializedObjectBindingExpression(node) || ts.isObjectBindingPattern(node.parent) && ts.isThisInitializedDeclaration(node.parent.parent))) { var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (declaringClassDeclaration && isNodeUsedDuringClassInitialization(node)) { - error(errorNode, ts.Diagnostics.Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor, symbolToString(prop), ts.getTextOfIdentifierOrLiteral(declaringClassDeclaration.name)); // TODO: GH#18217 - return false; - } - } - if (ts.isPropertyAccessExpression(node) && ts.isPrivateIdentifier(node.name)) { - if (!ts.getContainingClass(node)) { - error(errorNode, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); + if (reportError) { + error(errorNode, ts.Diagnostics.Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor, symbolToString(prop), ts.getTextOfIdentifierOrLiteral(declaringClassDeclaration.name)); // TODO: GH#18217 + } return false; } - return true; } // Public properties are otherwise accessible. if (!(flags & 24 /* NonPublicAccessibilityModifier */)) { @@ -67371,7 +69929,9 @@ var ts; if (flags & 8 /* Private */) { var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (!isNodeWithinClass(node, declaringClassDeclaration)) { - error(errorNode, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(getDeclaringClass(prop))); + if (reportError) { + error(errorNode, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(getDeclaringClass(prop))); + } return false; } return true; @@ -67385,7 +69945,7 @@ var ts; // of the property as base classes var enclosingClass = forEachEnclosingClass(node, function (enclosingDeclaration) { var enclosingClass = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingDeclaration)); - return isClassDerivedFromDeclaringClasses(enclosingClass, prop) ? enclosingClass : undefined; + return isClassDerivedFromDeclaringClasses(enclosingClass, prop, writing) ? enclosingClass : undefined; }); // A protected property is accessible if the property is within the declaring class or classes derived from it if (!enclosingClass) { @@ -67393,7 +69953,9 @@ var ts; // static member access is disallow var thisParameter = void 0; if (flags & 32 /* Static */ || !(thisParameter = getThisParameterFromNodeContext(node)) || !thisParameter.type) { - error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || type)); + if (reportError) { + error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || type)); + } return false; } var thisType = getTypeFromTypeNode(thisParameter.type); @@ -67408,7 +69970,9 @@ var ts; type = type.isThisType ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(type); // TODO: GH#18217 Use a different variable that's allowed to be undefined } if (!type || !hasBaseType(type, enclosingClass)) { - error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); + if (reportError) { + error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_This_is_an_instance_of_class_2, symbolToString(prop), typeToString(enclosingClass), typeToString(type)); + } return false; } return true; @@ -67464,20 +70028,20 @@ var ts; } return nonNullType; } - function checkPropertyAccessExpression(node) { - return node.flags & 32 /* OptionalChain */ ? checkPropertyAccessChain(node) : - checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullExpression(node.expression), node.name); + function checkPropertyAccessExpression(node, checkMode) { + return node.flags & 32 /* OptionalChain */ ? checkPropertyAccessChain(node, checkMode) : + checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullExpression(node.expression), node.name, checkMode); } - function checkPropertyAccessChain(node) { + function checkPropertyAccessChain(node, checkMode) { var leftType = checkExpression(node.expression); var nonOptionalType = getOptionalExpressionType(leftType, node.expression); - return propagateOptionalTypeMarker(checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullType(nonOptionalType, node.expression), node.name), node, nonOptionalType !== leftType); + return propagateOptionalTypeMarker(checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullType(nonOptionalType, node.expression), node.name, checkMode), node, nonOptionalType !== leftType); } - function checkQualifiedName(node) { - return checkPropertyAccessExpressionOrQualifiedName(node, node.left, checkNonNullExpression(node.left), node.right); + function checkQualifiedName(node, checkMode) { + return checkPropertyAccessExpressionOrQualifiedName(node, node.left, checkNonNullExpression(node.left), node.right, checkMode); } function isMethodAccessForCall(node) { - while (node.parent.kind === 207 /* ParenthesizedExpression */) { + while (node.parent.kind === 209 /* ParenthesizedExpression */) { node = node.parent; } return ts.isCallOrNewExpression(node.parent) && node.parent.expression === node; @@ -67512,14 +70076,13 @@ var ts; } var diagName = diagnosticName(right); if (propertyOnType) { - var typeValueDecl = propertyOnType.valueDeclaration; - var typeClass_1 = ts.getContainingClass(typeValueDecl); - ts.Debug.assert(!!typeClass_1); + var typeValueDecl = ts.Debug.checkDefined(propertyOnType.valueDeclaration); + var typeClass_1 = ts.Debug.checkDefined(ts.getContainingClass(typeValueDecl)); // We found a private identifier property with the same description. // Either: // - There is a lexically scoped private identifier AND it shadows the one we found on the type. // - It is an attempt to access the private identifier outside of the class. - if (lexicallyScopedIdentifier) { + if (lexicallyScopedIdentifier === null || lexicallyScopedIdentifier === void 0 ? void 0 : lexicallyScopedIdentifier.valueDeclaration) { var lexicalValueDecl = lexicallyScopedIdentifier.valueDeclaration; var lexicalClass = ts.getContainingClass(lexicalValueDecl); ts.Debug.assert(!!lexicalClass); @@ -67538,17 +70101,42 @@ var ts; return (isConstructorDeclaredProperty(prop) || ts.isThisProperty(node) && isAutoTypedProperty(prop)) && ts.getThisContainer(node, /*includeArrowFunctions*/ true) === getDeclaringConstructor(prop); } - function checkPropertyAccessExpressionOrQualifiedName(node, left, leftType, right) { + 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); - if (ts.isPrivateIdentifier(right)) { - checkExternalEmitHelpers(node, 524288 /* ClassPrivateFieldGet */); - } 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 (assignmentKind !== 1 /* Definite */) { + checkExternalEmitHelpers(node, 524288 /* ClassPrivateFieldGet */); + } + } var lexicallyScopedSymbol = lookupSymbolForPrivateIdentifierDeclaration(right.escapedText, right); + if (assignmentKind && lexicallyScopedSymbol && lexicallyScopedSymbol.valueDeclaration && ts.isMethodDeclaration(lexicallyScopedSymbol.valueDeclaration)) { + grammarErrorOnNode(right, ts.Diagnostics.Cannot_assign_to_private_method_0_Private_methods_are_not_writable, ts.idText(right)); + } + if ((lexicallyScopedSymbol === null || lexicallyScopedSymbol === void 0 ? void 0 : lexicallyScopedSymbol.valueDeclaration) && (compilerOptions.target === 99 /* ESNext */ && !useDefineForClassFields)) { + var lexicalClass_1 = ts.getContainingClass(lexicallyScopedSymbol.valueDeclaration); + var parentStaticFieldInitializer = ts.findAncestor(node, function (n) { + if (n === lexicalClass_1) + return "quit"; + if (ts.isPropertyDeclaration(n.parent) && ts.hasStaticModifier(n.parent) && n.parent.initializer === n && n.parent.parent === lexicalClass_1) { + return true; + } + return false; + }); + if (parentStaticFieldInitializer) { + var parentStaticFieldInitializerSymbol = getSymbolOfNode(parentStaticFieldInitializer.parent); + ts.Debug.assert(parentStaticFieldInitializerSymbol, "Initializer without declaration symbol"); + var diagnostic = error(node, ts.Diagnostics.Property_0_may_not_be_used_in_a_static_property_s_initializer_in_the_same_class_when_target_is_esnext_and_useDefineForClassFields_is_false, ts.symbolName(lexicallyScopedSymbol)); + ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(parentStaticFieldInitializer.parent, ts.Diagnostics.Initializer_for_property_0, ts.symbolName(parentStaticFieldInitializerSymbol))); + } + } if (isAnyLike) { if (lexicallyScopedSymbol) { return apparentType; @@ -67563,6 +70151,12 @@ var ts; if (!prop && checkPrivateIdentifierPropertyAccess(leftType, right, lexicallyScopedSymbol)) { return errorType; } + else { + var isSetonlyAccessor = prop && prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); + if (isSetonlyAccessor && assignmentKind !== 1 /* Definite */) { + error(node, ts.Diagnostics.Private_accessor_was_defined_without_a_getter); + } + } } else { if (isAnyLike) { @@ -67573,7 +70167,11 @@ var ts; } prop = getPropertyOfType(apparentType, right.escapedText); } - if (ts.isIdentifier(left) && parentSymbol && !(prop && isConstEnumOrConstEnumOnlyModule(prop))) { + // In `Foo.Bar.Baz`, 'Foo' is not referenced if 'Bar' is a const enum or a module containing only const enums. + // The exceptions are: + // 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)) || ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(node))) { markAliasReferenced(parentSymbol, node); } var propType; @@ -67606,44 +70204,50 @@ var ts; } } else { - if (getDeclarationNodeFlagsFromSymbol(prop) & 134217728 /* Deprecated */ && isUncalledFunctionReference(node, prop)) { - errorOrSuggestion(/* isError */ false, right, ts.Diagnostics._0_is_deprecated, right.escapedText); + if (prop.declarations && getDeclarationNodeFlagsFromSymbol(prop) & 134217728 /* Deprecated */ && isUncalledFunctionReference(node, prop)) { + addDeprecatedSuggestion(right, prop.declarations, right.escapedText); } checkPropertyNotUsedBeforeDeclaration(prop, node, right); - markPropertyAsReferenced(prop, node, left.kind === 107 /* ThisKeyword */); + markPropertyAsReferenced(prop, node, isSelfTypeAccess(left, parentSymbol)); getNodeLinks(node).resolvedSymbol = prop; - checkPropertyAccessibility(node, left.kind === 105 /* SuperKeyword */, apparentType, prop); + var writing = ts.isWriteAccess(node); + checkPropertyAccessibility(node, left.kind === 106 /* 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; } - propType = isThisPropertyAccessInConstructor(node, prop) ? autoType : getConstraintForLocation(getTypeOfSymbol(prop), node); + propType = isThisPropertyAccessInConstructor(node, prop) ? autoType : writing ? getSetAccessorTypeOfSymbol(prop) : getTypeOfSymbol(prop); } - return getFlowTypeOfAccessExpression(node, prop, propType, right); + return getFlowTypeOfAccessExpression(node, prop, propType, right, checkMode); } - function getFlowTypeOfAccessExpression(node, prop, propType, errorNode) { + function getFlowTypeOfAccessExpression(node, prop, propType, errorNode, checkMode) { // Only compute control flow type if this is a property access expression that isn't an // assignment target, and the referenced property was declared as a variable, property, // accessor, or optional method. var assignmentKind = ts.getAssignmentTargetKind(node); - if (!ts.isAccessExpression(node) || - assignmentKind === 1 /* Definite */ || - prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */)) { + if (assignmentKind === 1 /* Definite */) { + return removeMissingType(propType, !!(prop && prop.flags & 16777216 /* Optional */)); + } + if (prop && + !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) + && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */) + && !isDuplicatedCommonJSExport(prop.declarations)) { return propType; } if (propType === autoType) { return getFlowTypeOfProperty(node, prop); } + propType = getNarrowableTypeForReference(propType, node, checkMode); // If strict null checks and strict property initialization checks are enabled, if we have // a this.xxx property access, if the property is an instance property without an initializer, // and if we are in a constructor of the same class as the property declaration, assume that // the property is uninitialized at the top of the control flow. var assumeUninitialized = false; - if (strictNullChecks && strictPropertyInitialization && node.expression.kind === 107 /* ThisKeyword */) { + if (strictNullChecks && strictPropertyInitialization && ts.isAccessExpression(node) && node.expression.kind === 108 /* ThisKeyword */) { var declaration = prop && prop.valueDeclaration; if (declaration && isInstancePropertyWithoutInitializer(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 166 /* Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 8388608 /* Ambient */)) { + if (flowContainer.kind === 168 /* Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 8388608 /* Ambient */)) { assumeUninitialized = true; } } @@ -67670,13 +70274,14 @@ var ts; var diagnosticMessage; var declarationName = ts.idText(right); if (isInPropertyInitializer(node) + && !isOptionalPropertyDeclaration(valueDeclaration) && !(ts.isAccessExpression(node) && ts.isAccessExpression(node.expression)) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) - && !isPropertyDeclaredInAncestorClass(prop)) { + && (compilerOptions.useDefineForClassFields || !isPropertyDeclaredInAncestorClass(prop))) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 252 /* ClassDeclaration */ && - node.parent.kind !== 173 /* TypeReference */ && + else if (valueDeclaration.kind === 254 /* ClassDeclaration */ && + node.parent.kind !== 175 /* TypeReference */ && !(valueDeclaration.flags & 8388608 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); @@ -67688,22 +70293,22 @@ var ts; function isInPropertyInitializer(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return true; - case 288 /* PropertyAssignment */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 290 /* SpreadAssignment */: - case 158 /* ComputedPropertyName */: - case 228 /* TemplateSpan */: - case 283 /* JsxExpression */: - case 280 /* JsxAttribute */: - case 281 /* JsxAttributes */: - case 282 /* JsxSpreadAttribute */: - case 275 /* JsxOpeningElement */: - case 223 /* ExpressionWithTypeArguments */: - case 286 /* HeritageClause */: + case 290 /* PropertyAssignment */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 292 /* SpreadAssignment */: + case 160 /* ComputedPropertyName */: + case 230 /* TemplateSpan */: + case 285 /* JsxExpression */: + case 282 /* JsxAttribute */: + case 283 /* JsxAttributes */: + case 284 /* JsxSpreadAttribute */: + case 277 /* JsxOpeningElement */: + case 225 /* ExpressionWithTypeArguments */: + case 288 /* HeritageClause */: return false; default: return ts.isExpressionNode(node) ? false : "quit"; @@ -67775,7 +70380,10 @@ var ts; relatedInfo = suggestion.valueDeclaration && ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestedName); } else { - errorInfo = ts.chainDiagnosticMessages(elaborateNeverIntersection(errorInfo, containingType), ts.Diagnostics.Property_0_does_not_exist_on_type_1, missingProperty, container); + var diagnostic = containerSeemsToBeEmptyDomElement(containingType) + ? ts.Diagnostics.Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom + : ts.Diagnostics.Property_0_does_not_exist_on_type_1; + errorInfo = ts.chainDiagnosticMessages(elaborateNeverIntersection(errorInfo, containingType), diagnostic, missingProperty, container); } } } @@ -67786,9 +70394,14 @@ var ts; } diagnostics.add(resultDiagnostic); } + function containerSeemsToBeEmptyDomElement(containingType) { + return (compilerOptions.lib && !compilerOptions.lib.includes("dom")) && + everyContainedType(containingType, function (type) { return type.symbol && /^(EventTarget|Node|((HTML[a-zA-Z]*)?Element))$/.test(ts.unescapeLeadingUnderscores(type.symbol.escapedName)); }) && + isEmptyObjectType(containingType); + } function typeHasStaticProperty(propName, containingType) { var prop = containingType.symbol && getPropertyOfType(getTypeOfSymbol(containingType.symbol), propName); - return prop !== undefined && prop.valueDeclaration && ts.hasSyntacticModifier(prop.valueDeclaration, 32 /* Static */); + return prop !== undefined && !!prop.valueDeclaration && ts.hasSyntacticModifier(prop.valueDeclaration, 32 /* Static */); } function getSuggestedLibForNonExistentName(name) { var missingName = diagnosticName(name); @@ -67819,7 +70432,15 @@ var ts; } } function getSuggestedSymbolForNonexistentProperty(name, containingType) { - return getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 111551 /* Value */); + var props = getPropertiesOfType(containingType); + if (typeof name !== "string") { + var parent_2 = name.parent; + if (ts.isPropertyAccessExpression(parent_2)) { + props = ts.filter(props, function (prop) { return isValidPropertyAccessForCompletions(parent_2, containingType, prop); }); + } + name = ts.idText(name); + } + return getSpellingSuggestionForName(name, props, 111551 /* Value */); } function getSuggestedSymbolForNonexistentJSXAttribute(name, containingType) { var strName = ts.isString(name) ? name : ts.idText(name); @@ -67914,20 +70535,20 @@ var ts; return undefined; } } - function markPropertyAsReferenced(prop, nodeForCheckWriteOnly, isThisAccess) { + function markPropertyAsReferenced(prop, nodeForCheckWriteOnly, isSelfTypeAccess) { var valueDeclaration = prop && (prop.flags & 106500 /* ClassMember */) && prop.valueDeclaration; if (!valueDeclaration) { return; } var hasPrivateModifier = ts.hasEffectiveModifier(valueDeclaration, 8 /* Private */); - var hasPrivateIdentifier = ts.isNamedDeclaration(prop.valueDeclaration) && ts.isPrivateIdentifier(prop.valueDeclaration.name); + 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 */)) { return; } - if (isThisAccess) { + if (isSelfTypeAccess) { // Find any FunctionLikeDeclaration because those create a new 'this' binding. But this should only matter for methods (or getters/setters). var containingMethod = ts.findAncestor(nodeForCheckWriteOnly, ts.isFunctionLikeDeclaration); if (containingMethod && containingMethod.symbol === prop) { @@ -67936,18 +70557,22 @@ var ts; } (ts.getCheckFlags(prop) & 1 /* Instantiated */ ? getSymbolLinks(prop).target : prop).isReferenced = 67108863 /* All */; } + function isSelfTypeAccess(name, parent) { + return name.kind === 108 /* ThisKeyword */ + || !!parent && ts.isEntityNameExpression(name) && parent === getResolvedSymbol(ts.getFirstIdentifier(name)); + } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 201 /* PropertyAccessExpression */: - return isValidPropertyAccessWithType(node, node.expression.kind === 105 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); - case 157 /* QualifiedName */: + case 203 /* PropertyAccessExpression */: + return isValidPropertyAccessWithType(node, node.expression.kind === 106 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); + case 159 /* QualifiedName */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getWidenedType(checkExpression(node.left))); - case 195 /* ImportType */: + case 197 /* ImportType */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind === 201 /* PropertyAccessExpression */ && node.expression.kind === 105 /* SuperKeyword */, property.escapedName, type); + return isValidPropertyAccessWithType(node, node.kind === 203 /* PropertyAccessExpression */ && node.expression.kind === 106 /* SuperKeyword */, property.escapedName, type); // Previously we validated the 'this' type of methods but this adversely affected performance. See #31377 for more context. } function isValidPropertyAccessWithType(node, isSuper, propertyName, type) { @@ -67956,11 +70581,11 @@ var ts; } var prop = getPropertyOfType(type, propertyName); if (prop) { - if (ts.isPropertyAccessExpression(node) && prop.valueDeclaration && ts.isPrivateIdentifierPropertyDeclaration(prop.valueDeclaration)) { + if (prop.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(prop.valueDeclaration)) { var declClass_1 = ts.getContainingClass(prop.valueDeclaration); return !ts.isOptionalChain(node) && !!ts.findAncestor(node, function (parent) { return parent === declClass_1; }); } - return checkPropertyAccessibility(node, isSuper, type, prop); + return checkPropertyAccessibility(node, isSuper, /*writing*/ false, type, prop, /* reportError */ false); } // In js files properties of unions are allowed in completion return ts.isInJSFile(node) && (type.flags & 1048576 /* Union */) !== 0 && type.types.some(function (elementType) { return isValidPropertyAccessWithType(node, isSuper, propertyName, elementType); }); @@ -67970,13 +70595,13 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 250 /* VariableDeclarationList */) { + if (initializer.kind === 252 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 78 /* Identifier */) { + else if (initializer.kind === 79 /* Identifier */) { return getResolvedSymbol(initializer); } return undefined; @@ -67993,13 +70618,13 @@ var ts; */ function isForInVariableForNumericPropertyNames(expr) { var e = ts.skipParentheses(expr); - if (e.kind === 78 /* Identifier */) { + if (e.kind === 79 /* Identifier */) { var symbol = getResolvedSymbol(e); if (symbol.flags & 3 /* Variable */) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 238 /* ForInStatement */ && + if (node.kind === 240 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -68012,16 +70637,16 @@ var ts; } return false; } - function checkIndexedAccess(node) { - return node.flags & 32 /* OptionalChain */ ? checkElementAccessChain(node) : - checkElementAccessExpression(node, checkNonNullExpression(node.expression)); + function checkIndexedAccess(node, checkMode) { + return node.flags & 32 /* OptionalChain */ ? checkElementAccessChain(node, checkMode) : + checkElementAccessExpression(node, checkNonNullExpression(node.expression), checkMode); } - function checkElementAccessChain(node) { + function checkElementAccessChain(node, checkMode) { var exprType = checkExpression(node.expression); var nonOptionalType = getOptionalExpressionType(exprType, node.expression); - return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression)), node, nonOptionalType !== exprType); + return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression), checkMode), node, nonOptionalType !== exprType); } - function checkElementAccessExpression(node, exprType) { + function checkElementAccessExpression(node, exprType, checkMode) { var objectType = ts.getAssignmentTargetKind(node) !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; var indexExpression = node.argumentExpression; var indexType = checkExpression(indexExpression); @@ -68034,45 +70659,10 @@ var ts; } var effectiveIndexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType; var accessFlags = ts.isAssignmentTarget(node) ? - 2 /* Writing */ | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 1 /* NoIndexSignatures */ : 0) : - 0 /* None */; - var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, /*noUncheckedIndexedAccessCandidate*/ undefined, node, accessFlags | 16 /* ExpressionPosition */) || errorType; - return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, indexedAccessType.symbol, indexedAccessType, indexExpression), node); - } - function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) { - if (expressionType === errorType) { - // There is already an error, so no need to report one. - return false; - } - if (!ts.isWellKnownSymbolSyntactically(expression)) { - return false; - } - // Make sure the property type is the primitive symbol type - if ((expressionType.flags & 12288 /* ESSymbolLike */) === 0) { - if (reportError) { - error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression)); - } - return false; - } - // The name is Symbol., so make sure Symbol actually resolves to the - // global Symbol object - var leftHandSide = expression.expression; - var leftHandSideSymbol = getResolvedSymbol(leftHandSide); - if (!leftHandSideSymbol) { - return false; - } - var globalESSymbol = getGlobalESSymbolConstructorSymbol(/*reportErrors*/ true); - if (!globalESSymbol) { - // Already errored when we tried to look up the symbol - return false; - } - if (leftHandSideSymbol !== globalESSymbol) { - if (reportError) { - error(leftHandSide, ts.Diagnostics.Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object); - } - return false; - } - return true; + 4 /* Writing */ | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 2 /* NoIndexSignatures */ : 0) : + 32 /* ExpressionPosition */; + var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, accessFlags, node) || errorType; + return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, getNodeLinks(node).resolvedSymbol, indexedAccessType, indexExpression, checkMode), node); } function callLikeExpressionMayHaveTypeArguments(node) { return ts.isCallOrNewExpression(node) || ts.isTaggedTemplateExpression(node) || ts.isJsxOpeningLikeElement(node); @@ -68083,13 +70673,13 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 205 /* TaggedTemplateExpression */) { + if (node.kind === 207 /* TaggedTemplateExpression */) { checkExpression(node.template); } else if (ts.isJsxOpeningLikeElement(node)) { checkExpression(node.attributes); } - else if (node.kind !== 161 /* Decorator */) { + else if (node.kind !== 163 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -68153,7 +70743,7 @@ var ts; } } function isSpreadArgument(arg) { - return !!arg && (arg.kind === 220 /* SpreadElement */ || arg.kind === 227 /* SyntheticExpression */ && arg.isSpread); + return !!arg && (arg.kind === 222 /* SpreadElement */ || arg.kind === 229 /* SyntheticExpression */ && arg.isSpread); } function getSpreadArgumentIndex(args) { return ts.findIndex(args, isSpreadArgument); @@ -68170,9 +70760,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 === 205 /* TaggedTemplateExpression */) { + if (node.kind === 207 /* TaggedTemplateExpression */) { argCount = args.length; - if (node.template.kind === 218 /* TemplateExpression */) { + if (node.template.kind === 220 /* 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. @@ -68187,7 +70777,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 161 /* Decorator */) { + else if (node.kind === 163 /* Decorator */) { argCount = getDecoratorArgumentCount(node, signature); } else if (ts.isJsxOpeningLikeElement(node)) { @@ -68201,7 +70791,7 @@ var ts; } else if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 204 /* NewExpression */); + ts.Debug.assert(node.kind === 206 /* NewExpression */); return getMinArgumentCount(signature) === 0; } else { @@ -68276,7 +70866,7 @@ var ts; }); if (!inferenceContext) { applyToReturnTypes(contextualSignature, signature, function (source, target) { - inferTypes(context.inferences, source, target, 64 /* ReturnType */); + inferTypes(context.inferences, source, target, 128 /* ReturnType */); }); } return getSignatureInstantiation(signature, getInferredTypes(context), ts.isInJSFile(contextualSignature.declaration)); @@ -68287,6 +70877,15 @@ var ts; inferTypes(context.inferences, checkAttrType, paramType); return getInferredTypes(context); } + function getThisArgumentType(thisArgumentNode) { + if (!thisArgumentNode) { + return voidType; + } + var thisArgumentType = checkExpression(thisArgumentNode); + return ts.isOptionalChainRoot(thisArgumentNode.parent) ? getNonNullableType(thisArgumentType) : + ts.isOptionalChain(thisArgumentNode.parent) ? removeOptionalTypeMarker(thisArgumentType) : + thisArgumentType; + } function inferTypeArguments(node, signature, args, checkMode, context) { if (ts.isJsxOpeningLikeElement(node)) { return inferJsxTypeArguments(node, signature, checkMode, context); @@ -68295,7 +70894,7 @@ 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 !== 161 /* Decorator */) { + if (node.kind !== 163 /* Decorator */) { var contextualType = getContextualType(node, ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }) ? 8 /* SkipBindingPatterns */ : 0 /* None */); if (contextualType) { // We clone the inference context to avoid disturbing a resolution in progress for an @@ -68317,7 +70916,7 @@ var ts; instantiatedType; var inferenceTargetType = getReturnTypeOfSignature(signature); // Inferences made from return types have lower priority than all other inferences. - inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 64 /* ReturnType */); + inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* 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 // the source type uses the outer context's return mapper (which excludes inferences made from @@ -68339,12 +70938,11 @@ var ts; var thisType = getThisTypeOfSignature(signature); if (thisType) { var thisArgumentNode = getThisArgumentOfCall(node); - var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; - inferTypes(context.inferences, thisArgumentType, thisType); + inferTypes(context.inferences, getThisArgumentType(thisArgumentNode), thisType); } for (var i = 0; i < argCount; i++) { var arg = args[i]; - if (arg.kind !== 222 /* OmittedExpression */) { + if (arg.kind !== 224 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode); inferTypes(context.inferences, argType, paramType); @@ -68368,7 +70966,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 === 227 /* SyntheticExpression */ ? arg.type : + return getMutableArrayOrTupleType(arg.kind === 229 /* SyntheticExpression */ ? arg.type : checkExpressionWithContextualType(arg.expression, restType, context, checkMode)); } } @@ -68378,24 +70976,24 @@ var ts; for (var i = index; i < argCount; i++) { var arg = args[i]; if (isSpreadArgument(arg)) { - var spreadType = arg.kind === 227 /* SyntheticExpression */ ? arg.type : checkExpression(arg.expression); + var spreadType = arg.kind === 229 /* SyntheticExpression */ ? arg.type : checkExpression(arg.expression); if (isArrayLikeType(spreadType)) { types.push(spreadType); flags.push(8 /* Variadic */); } else { - types.push(checkIteratedTypeOrElementType(33 /* Spread */, spreadType, undefinedType, arg.kind === 220 /* SpreadElement */ ? arg.expression : arg)); + types.push(checkIteratedTypeOrElementType(33 /* Spread */, spreadType, undefinedType, arg.kind === 222 /* SpreadElement */ ? arg.expression : arg)); flags.push(4 /* Rest */); } } else { - var contextualType = getIndexedAccessType(restType, getLiteralType(i - index)); + var contextualType = getIndexedAccessType(restType, getLiteralType(i - index), 256 /* Contextual */); var argType = checkExpressionWithContextualType(arg, contextualType, context, checkMode); var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 131068 /* Primitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */); types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType)); flags.push(1 /* Required */); } - if (arg.kind === 227 /* SyntheticExpression */ && arg.tupleNameSource) { + if (arg.kind === 229 /* SyntheticExpression */ && arg.tupleNameSource) { names.push(arg.tupleNameSource); } } @@ -68539,24 +71137,12 @@ var ts; return undefined; } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 204 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 206 /* 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. var thisArgumentNode = getThisArgumentOfCall(node); - var thisArgumentType = void 0; - if (thisArgumentNode) { - thisArgumentType = checkExpression(thisArgumentNode); - if (ts.isOptionalChainRoot(thisArgumentNode.parent)) { - thisArgumentType = getNonNullableType(thisArgumentType); - } - else if (ts.isOptionalChain(thisArgumentNode.parent)) { - thisArgumentType = removeOptionalTypeMarker(thisArgumentType); - } - } - else { - thisArgumentType = voidType; - } + var thisArgumentType = getThisArgumentType(thisArgumentNode); var errorNode = reportErrors ? (thisArgumentNode || node) : undefined; var headMessage_1 = ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1; if (!checkTypeRelatedTo(thisArgumentType, thisType, relation, errorNode, headMessage_1, containingMessageChain, errorOutputContainer)) { @@ -68569,7 +71155,7 @@ 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 !== 222 /* OmittedExpression */) { + if (arg.kind !== 224 /* 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), @@ -68614,7 +71200,7 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 203 /* CallExpression */) { + if (node.kind === 205 /* CallExpression */) { var callee = ts.skipOuterExpressions(node.expression); if (ts.isAccessExpression(callee)) { return callee.expression; @@ -68631,17 +71217,17 @@ var ts; * Returns the effective arguments for an expression that works like a function invocation. */ function getEffectiveCallArguments(node) { - if (node.kind === 205 /* TaggedTemplateExpression */) { + if (node.kind === 207 /* TaggedTemplateExpression */) { var template = node.template; var args_3 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())]; - if (template.kind === 218 /* TemplateExpression */) { + if (template.kind === 220 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_3.push(span.expression); }); } return args_3; } - if (node.kind === 161 /* Decorator */) { + if (node.kind === 163 /* Decorator */) { return getEffectiveDecoratorArguments(node); } if (ts.isJsxOpeningLikeElement(node)) { @@ -68652,10 +71238,10 @@ var ts; if (spreadIndex >= 0) { // Create synthetic arguments from spreads of tuple types. var effectiveArgs_1 = args.slice(0, spreadIndex); - var _loop_20 = function (i) { + var _loop_21 = function (i) { var arg = args[i]; // We can call checkExpressionCached because spread expressions never have a contextual type. - var spreadType = arg.kind === 220 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression)); + var spreadType = arg.kind === 222 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression)); if (spreadType && isTupleType(spreadType)) { ts.forEach(getTypeArguments(spreadType), function (t, i) { var _a; @@ -68669,7 +71255,7 @@ var ts; } }; for (var i = spreadIndex; i < args.length; i++) { - _loop_20(i); + _loop_21(i); } return effectiveArgs_1; } @@ -68682,30 +71268,30 @@ var ts; var parent = node.parent; var expr = node.expression; switch (parent.kind) { - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* 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 160 /* Parameter */: + case 162 /* 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 === 166 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), + createSyntheticExpression(expr, parent.parent.kind === 168 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), createSyntheticExpression(expr, anyType), createSyntheticExpression(expr, numberType) ]; - case 163 /* PropertyDeclaration */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* 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 !== 163 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; + var hasPropDesc = parent.kind !== 165 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; return [ createSyntheticExpression(expr, getParentTypeOfClassElement(parent)), createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)), @@ -68719,17 +71305,17 @@ var ts; */ function getDecoratorArgumentCount(node, signature) { switch (node.parent.kind) { - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: return 1; - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return 2; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* 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 160 /* Parameter */: + case 162 /* Parameter */: return 3; default: return ts.Debug.fail(); @@ -68775,77 +71361,66 @@ var ts; return constructorSymbol === globalPromiseSymbol; } function getArgumentArityError(node, signatures, args) { - var min = Number.POSITIVE_INFINITY; - var max = Number.NEGATIVE_INFINITY; - var belowArgCount = Number.NEGATIVE_INFINITY; - var aboveArgCount = Number.POSITIVE_INFINITY; - var argCount = args.length; + var _a; + var spreadIndex = getSpreadArgumentIndex(args); + if (spreadIndex > -1) { + return ts.createDiagnosticForNode(args[spreadIndex], ts.Diagnostics.A_spread_argument_must_either_have_a_tuple_type_or_be_passed_to_a_rest_parameter); + } + var min = Number.POSITIVE_INFINITY; // smallest parameter count + var max = Number.NEGATIVE_INFINITY; // largest parameter count + var maxBelow = Number.NEGATIVE_INFINITY; // largest parameter count that is smaller than the number of arguments + var minAbove = Number.POSITIVE_INFINITY; // smallest parameter count that is larger than the number of arguments var closestSignature; for (var _i = 0, signatures_8 = signatures; _i < signatures_8.length; _i++) { var sig = signatures_8[_i]; - var minCount = getMinArgumentCount(sig); - var maxCount = getParameterCount(sig); - if (minCount < argCount && minCount > belowArgCount) - belowArgCount = minCount; - if (argCount < maxCount && maxCount < aboveArgCount) - aboveArgCount = maxCount; - if (minCount < min) { - min = minCount; + var minParameter = getMinArgumentCount(sig); + var maxParameter = getParameterCount(sig); + // smallest/largest parameter counts + if (minParameter < min) { + min = minParameter; closestSignature = sig; } - max = Math.max(max, maxCount); + max = Math.max(max, maxParameter); + // shortest parameter count *longer than the call*/longest parameter count *shorter than the call* + if (minParameter < args.length && minParameter > maxBelow) + maxBelow = minParameter; + if (args.length < maxParameter && maxParameter < minAbove) + minAbove = maxParameter; } var hasRestParameter = ts.some(signatures, hasEffectiveRestParameter); - var paramRange = hasRestParameter ? min : - min < max ? min + "-" + max : - min; - var hasSpreadArgument = getSpreadArgumentIndex(args) > -1; - if (argCount <= max && hasSpreadArgument) { - argCount--; - } - var spanArray; - var related; - var error = hasRestParameter || hasSpreadArgument ? - hasRestParameter && hasSpreadArgument ? - ts.Diagnostics.Expected_at_least_0_arguments_but_got_1_or_more : - hasRestParameter ? - ts.Diagnostics.Expected_at_least_0_arguments_but_got_1 : - ts.Diagnostics.Expected_0_arguments_but_got_1_or_more : - paramRange === 1 && argCount === 0 && isPromiseResolveArityError(node) ? - ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise : - ts.Diagnostics.Expected_0_arguments_but_got_1; - if (closestSignature && getMinArgumentCount(closestSignature) > argCount && closestSignature.declaration) { - var paramDecl = closestSignature.declaration.parameters[closestSignature.thisParameter ? argCount + 1 : argCount]; - if (paramDecl) { - related = ts.createDiagnosticForNode(paramDecl, ts.isBindingPattern(paramDecl.name) ? ts.Diagnostics.An_argument_matching_this_binding_pattern_was_not_provided : - ts.isRestParameter(paramDecl) ? ts.Diagnostics.Arguments_for_the_rest_parameter_0_were_not_provided : ts.Diagnostics.An_argument_for_0_was_not_provided, !paramDecl.name ? argCount : !ts.isBindingPattern(paramDecl.name) ? ts.idText(ts.getFirstIdentifier(paramDecl.name)) : undefined); - } - } - if (min < argCount && argCount < max) { - return getDiagnosticForCallNode(node, ts.Diagnostics.No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments, argCount, belowArgCount, aboveArgCount); - } - if (!hasSpreadArgument && argCount < min) { - var diagnostic_1 = getDiagnosticForCallNode(node, error, paramRange, argCount); - return related ? ts.addRelatedInfo(diagnostic_1, related) : diagnostic_1; - } - if (hasRestParameter || hasSpreadArgument) { - spanArray = ts.factory.createNodeArray(args); - if (hasSpreadArgument && argCount) { - var nextArg = ts.elementAt(args, getSpreadArgumentIndex(args) + 1) || undefined; - spanArray = ts.factory.createNodeArray(args.slice(max > argCount && nextArg ? args.indexOf(nextArg) : Math.min(max, args.length - 1))); + var parameterRange = hasRestParameter ? min + : min < max ? min + "-" + max + : min; + var error = hasRestParameter ? ts.Diagnostics.Expected_at_least_0_arguments_but_got_1 + : parameterRange === 1 && args.length === 0 && isPromiseResolveArityError(node) ? ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise + : ts.Diagnostics.Expected_0_arguments_but_got_1; + if (min < args.length && args.length < max) { + // between min and max, but with no matching overload + return getDiagnosticForCallNode(node, ts.Diagnostics.No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments, args.length, maxBelow, minAbove); + } + else if (args.length < min) { + // too short: put the error span on the call expression, not any of the args + var diagnostic = getDiagnosticForCallNode(node, error, parameterRange, args.length); + var parameter = (_a = closestSignature === null || closestSignature === void 0 ? void 0 : closestSignature.declaration) === null || _a === void 0 ? void 0 : _a.parameters[closestSignature.thisParameter ? args.length + 1 : args.length]; + if (parameter) { + var parameterError = ts.createDiagnosticForNode(parameter, ts.isBindingPattern(parameter.name) ? ts.Diagnostics.An_argument_matching_this_binding_pattern_was_not_provided + : ts.isRestParameter(parameter) ? ts.Diagnostics.Arguments_for_the_rest_parameter_0_were_not_provided + : ts.Diagnostics.An_argument_for_0_was_not_provided, !parameter.name ? args.length : !ts.isBindingPattern(parameter.name) ? ts.idText(ts.getFirstIdentifier(parameter.name)) : undefined); + return ts.addRelatedInfo(diagnostic, parameterError); } + return diagnostic; } else { - spanArray = ts.factory.createNodeArray(args.slice(max)); - } - var pos = ts.first(spanArray).pos; - var end = ts.last(spanArray).end; - if (end === pos) { - end++; + // too long; error goes on the excess parameters + var errorSpan = ts.factory.createNodeArray(args.slice(max)); + var pos = ts.first(errorSpan).pos; + var end = ts.last(errorSpan).end; + if (end === pos) { + end++; + } + ts.setTextRangePosEnd(errorSpan, pos, end); + return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), errorSpan, error, parameterRange, args.length); } - ts.setTextRangePosEnd(spanArray, pos, end); - var diagnostic = ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), spanArray, error, paramRange, argCount); - return related ? ts.addRelatedInfo(diagnostic, related) : diagnostic; } function getTypeArgumentArityError(node, signatures, typeArguments) { var argCount = typeArguments.length; @@ -68876,15 +71451,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 === 205 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 161 /* Decorator */; + var isTaggedTemplate = node.kind === 207 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 163 /* Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var reportErrors = !candidatesOutArray && produceDiagnostics; var typeArguments; if (!isDecorator) { typeArguments = node.typeArguments; // We already perform checking on the type arguments on the class declaration itself. - if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 105 /* SuperKeyword */) { + if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 106 /* SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } @@ -68939,7 +71514,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 === 203 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 205 /* 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 @@ -68993,7 +71568,7 @@ var ts; var min_3 = Number.MAX_VALUE; var minIndex = 0; var i_1 = 0; - var _loop_21 = function (c) { + var _loop_22 = 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); if (diags_2) { @@ -69011,7 +71586,7 @@ var ts; }; for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) { var c = candidatesForArgumentError_1[_a]; - _loop_21(c); + _loop_22(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"); @@ -69169,7 +71744,7 @@ var ts; } var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max; var parameters = []; - var _loop_22 = function (i) { + var _loop_23 = 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; }); @@ -69177,7 +71752,7 @@ var ts; parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); }))); }; for (var i = 0; i < maxNonRestParam; i++) { - _loop_22(i); + _loop_23(i); } var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; }); var flags = 0 /* None */; @@ -69258,7 +71833,7 @@ var ts; return maxParamsIndex; } function resolveCallExpression(node, candidatesOutArray, checkMode) { - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (isTypeAny(superType)) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { @@ -69369,7 +71944,7 @@ 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 */ | 131072 /* Never */)) && isTypeAssignableTo(funcType, globalFunctionType); + !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & 1048576 /* Union */) && !(getReducedType(apparentFuncType).flags & 131072 /* Never */) && isTypeAssignableTo(funcType, globalFunctionType); } function resolveNewExpression(node, candidatesOutArray, checkMode) { if (node.arguments && languageVersion < 1 /* ES5 */) { @@ -69484,7 +72059,7 @@ var ts; var declaration = signature.declaration; var modifiers = ts.getSelectedEffectiveModifierFlags(declaration, 24 /* NonPublicAccessibilityModifier */); // (1) Public constructors and (2) constructor functions are always accessible. - if (!modifiers || declaration.kind !== 166 /* Constructor */) { + if (!modifiers || declaration.kind !== 168 /* Constructor */) { return true; } var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(declaration.parent.symbol); @@ -69628,16 +72203,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 160 /* Parameter */: + case 162 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; default: return ts.Debug.fail(); @@ -69683,7 +72258,7 @@ var ts; // 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(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.factory.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.factory.createKeywordTypeNode(128 /* AnyKeyword */)); + var declaration = ts.factory.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.factory.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.factory.createKeywordTypeNode(129 /* AnyKeyword */)); var parameterSymbol = createSymbol(1 /* FunctionScopedVariable */, "props"); parameterSymbol.type = result; return createSignature(declaration, @@ -69732,16 +72307,16 @@ var ts; } function resolveSignature(node, candidatesOutArray, checkMode) { switch (node.kind) { - case 203 /* CallExpression */: + case 205 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray, checkMode); - case 204 /* NewExpression */: + case 206 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray, checkMode); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode); - case 161 /* Decorator */: + case 163 /* Decorator */: return resolveDecorator(node, candidatesOutArray, checkMode); - case 275 /* JsxOpeningElement */: - case 274 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode); } throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); @@ -69841,7 +72416,7 @@ var ts; else if (ts.isBinaryExpression(node.parent)) { var parentNode = node.parent; var parentNodeOperator = node.parent.operatorToken.kind; - if (parentNodeOperator === 62 /* EqualsToken */ && (allowDeclaration || parentNode.right === node)) { + if (parentNodeOperator === 63 /* EqualsToken */ && (allowDeclaration || parentNode.right === node)) { name = parentNode.left; decl = name; } @@ -69850,7 +72425,7 @@ var ts; name = parentNode.parent.name; decl = parentNode.parent; } - else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 62 /* EqualsToken */ && (allowDeclaration || parentNode.parent.right === parentNode)) { + else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 63 /* EqualsToken */ && (allowDeclaration || parentNode.parent.right === parentNode)) { name = parentNode.parent.left; decl = name; } @@ -69873,10 +72448,10 @@ var ts; return false; } var parent = node.parent; - while (parent && parent.kind === 201 /* PropertyAccessExpression */) { + while (parent && parent.kind === 203 /* PropertyAccessExpression */) { parent = parent.parent; } - if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 62 /* EqualsToken */) { + if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 63 /* EqualsToken */) { var right = ts.getInitializerOfBinaryExpression(parent); return ts.isObjectLiteralExpression(right) && right; } @@ -69897,15 +72472,15 @@ var ts; return nonInferrableType; } checkDeprecatedSignature(signature, node); - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { return voidType; } - if (node.kind === 204 /* NewExpression */) { + if (node.kind === 206 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 166 /* Constructor */ && - declaration.kind !== 170 /* ConstructSignature */ && - declaration.kind !== 175 /* ConstructorType */ && + declaration.kind !== 168 /* Constructor */ && + declaration.kind !== 172 /* ConstructSignature */ && + declaration.kind !== 177 /* ConstructorType */ && !ts.isJSDocConstructSignature(declaration) && !isJSConstructor(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any @@ -69925,7 +72500,7 @@ var ts; if (returnType.flags & 12288 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent)); } - if (node.kind === 203 /* CallExpression */ && node.parent.kind === 233 /* ExpressionStatement */ && + if (node.kind === 205 /* CallExpression */ && !node.questionDotToken && node.parent.kind === 235 /* ExpressionStatement */ && returnType.flags & 16384 /* 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); @@ -69939,7 +72514,7 @@ 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, undefined, undefined); - jsAssignmentType.objectFlags |= 16384 /* JSLiteral */; + jsAssignmentType.objectFlags |= 8192 /* JSLiteral */; return getIntersectionType([returnType, jsAssignmentType]); } } @@ -69948,26 +72523,27 @@ var ts; function checkDeprecatedSignature(signature, node) { if (signature.declaration && signature.declaration.flags & 134217728 /* Deprecated */) { var suggestionNode = getDeprecatedSuggestionNode(node); - errorOrSuggestion(/*isError*/ false, suggestionNode, ts.Diagnostics._0_is_deprecated, signatureToString(signature)); + var name = ts.tryGetPropertyAccessOrIdentifierToString(ts.getInvokedExpression(node)); + addDeprecatedSuggestionWithSignature(suggestionNode, signature.declaration, name, signatureToString(signature)); } } function getDeprecatedSuggestionNode(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 203 /* CallExpression */: - case 161 /* Decorator */: - case 204 /* NewExpression */: + case 205 /* CallExpression */: + case 163 /* Decorator */: + case 206 /* NewExpression */: return getDeprecatedSuggestionNode(node.expression); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return getDeprecatedSuggestionNode(node.tag); - case 275 /* JsxOpeningElement */: - case 274 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: + case 276 /* JsxSelfClosingElement */: return getDeprecatedSuggestionNode(node.tagName); - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: return node.argumentExpression; - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return node.name; - case 173 /* TypeReference */: + case 175 /* TypeReference */: var typeReference = node; return ts.isQualifiedName(typeReference.typeName) ? typeReference.typeName.right : typeReference; default: @@ -70018,10 +72594,11 @@ var ts; return createPromiseReturnType(node, anyType); } function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol) { + var _a; if (allowSyntheticDefaultImports && type && type !== errorType) { var synthType = type; if (!synthType.syntheticType) { - var file = ts.find(originalSymbol.declarations, ts.isSourceFile); + var file = (_a = originalSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, /*dontResolveAlias*/ false); if (hasSyntheticDefault) { var memberTable = ts.createSymbolTable(); @@ -70059,9 +72636,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 251 /* FunctionDeclaration */ + ? 253 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 249 /* VariableDeclaration */ + ? 251 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -70089,21 +72666,21 @@ var ts; case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: - case 199 /* ArrayLiteralExpression */: - case 200 /* ObjectLiteralExpression */: - case 218 /* TemplateExpression */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: + case 201 /* ArrayLiteralExpression */: + case 202 /* ObjectLiteralExpression */: + case 220 /* TemplateExpression */: return true; - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return isValidConstAssertionArgument(node.expression); - case 214 /* PrefixUnaryExpression */: + case 216 /* 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 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: var expr = node.expression; if (ts.isIdentifier(expr)) { var symbol = getSymbolAtLocation(expr); @@ -70145,10 +72722,10 @@ var ts; } function checkMetaProperty(node) { checkGrammarMetaProperty(node); - if (node.keywordToken === 102 /* NewKeyword */) { + if (node.keywordToken === 103 /* NewKeyword */) { return checkNewTargetMetaProperty(node); } - if (node.keywordToken === 99 /* ImportKeyword */) { + if (node.keywordToken === 100 /* ImportKeyword */) { return checkImportMetaProperty(node); } return ts.Debug.assertNever(node.keywordToken); @@ -70159,7 +72736,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 === 166 /* Constructor */) { + else if (container.kind === 168 /* Constructor */) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -70206,7 +72783,7 @@ var ts; return restParameter.escapedName; } function isValidDeclarationForTupleLabel(d) { - return d.kind === 192 /* NamedTupleMember */ || (ts.isParameter(d) && d.name && ts.isIdentifier(d.name)); + return d.kind === 194 /* NamedTupleMember */ || (ts.isParameter(d) && d.name && ts.isIdentifier(d.name)); } function getNameableDeclarationAtPosition(signature, pos) { var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); @@ -70371,7 +72948,14 @@ var ts; } } function assignContextualParameterTypes(signature, context) { - signature.typeParameters = context.typeParameters; + if (context.typeParameters) { + if (!signature.typeParameters) { + signature.typeParameters = context.typeParameters; + } + else { + return; // This signature has already has a contextual inference performed and cached on it! + } + } if (context.thisParameter) { var parameter = signature.thisParameter; if (!parameter || parameter.valueDeclaration && !parameter.valueDeclaration.type) { @@ -70412,7 +72996,7 @@ var ts; if (!links.type) { var declaration = parameter.valueDeclaration; links.type = type || getWidenedTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true); - if (declaration.name.kind !== 78 /* Identifier */) { + if (declaration.name.kind !== 79 /* 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); @@ -70427,7 +73011,7 @@ var ts; for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { var element = _a[_i]; if (!ts.isOmittedExpression(element)) { - if (element.name.kind === 78 /* Identifier */) { + if (element.name.kind === 79 /* Identifier */) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } else { @@ -70482,7 +73066,7 @@ var ts; var yieldType; var nextType; var fallbackReturnType = voidType; - if (func.body.kind !== 230 /* Block */) { // Async or normal arrow function + if (func.body.kind !== 232 /* Block */) { // Async or normal arrow function returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8 /* SkipGenericFunctions */); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any @@ -70667,7 +73251,7 @@ var ts; return links.isExhaustive !== undefined ? links.isExhaustive : (links.isExhaustive = computeExhaustiveSwitchStatement(node)); } function computeExhaustiveSwitchStatement(node) { - if (node.expression.kind === 211 /* TypeOfExpression */) { + if (node.expression.kind === 213 /* TypeOfExpression */) { var operandType = getTypeOfExpression(node.expression.expression); var witnesses = getSwitchClauseTypeOfWitnesses(node, /*retainDefault*/ false); // notEqualFacts states that the type of the switched value is not equal to every type in the switch. @@ -70730,11 +73314,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return true; - case 165 /* MethodDeclaration */: - return func.parent.kind === 200 /* ObjectLiteralExpression */; + case 167 /* MethodDeclaration */: + return func.parent.kind === 202 /* ObjectLiteralExpression */; default: return false; } @@ -70760,21 +73344,21 @@ var ts; } // 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 === 164 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 230 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 166 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 232 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 512 /* HasExplicitReturn */; + var errorNode = ts.getEffectiveReturnTypeNode(func) || func; if (type && type.flags & 131072 /* Never */) { - error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); + error(errorNode, ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); } else if (type && !hasExplicitReturn) { // minimal check: function has syntactic return type annotation and no explicit return statements in the body // this function does not conform to the specification. - // NOTE: having returnType !== undefined is a precondition for entering this branch so func.type will always be present - error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value); + error(errorNode, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value); } else if (type && strictNullChecks && !isTypeAssignableTo(undefinedType, type)) { - error(ts.getEffectiveReturnTypeNode(func) || func, ts.Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined); + error(errorNode, ts.Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined); } else if (compilerOptions.noImplicitReturns) { if (!type) { @@ -70789,11 +73373,11 @@ var ts; return; } } - error(ts.getEffectiveReturnTypeNode(func) || func, ts.Diagnostics.Not_all_code_paths_return_a_value); + error(errorNode, ts.Diagnostics.Not_all_code_paths_return_a_value); } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 165 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 167 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); checkNodeDeferred(node); // The identityMapper object is used to indicate that function expressions are wildcards if (checkMode && checkMode & 4 /* SkipContextSensitive */ && isContextSensitive(node)) { @@ -70809,7 +73393,7 @@ var ts; var returnType = getReturnTypeFromBody(node, checkMode); var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); var returnOnlyType = createAnonymousType(node.symbol, emptySymbols, [returnOnlySignature], ts.emptyArray, undefined, undefined); - returnOnlyType.objectFlags |= 2097152 /* NonInferrableType */; + returnOnlyType.objectFlags |= 524288 /* NonInferrableType */; return links.contextFreeType = returnOnlyType; } } @@ -70817,7 +73401,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 208 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 210 /* FunctionExpression */) { checkGrammarForGenerator(node); } contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -70863,7 +73447,7 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 165 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 167 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnType = getReturnTypeFromAnnotation(node); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); @@ -70876,7 +73460,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 230 /* Block */) { + if (node.body.kind === 232 /* Block */) { checkSourceElement(node.body); } else { @@ -70963,10 +73547,10 @@ var ts; // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && ts.isAccessExpression(expr) && - expr.expression.kind === 107 /* ThisKeyword */) { + expr.expression.kind === 108 /* 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 === 166 /* Constructor */ || isJSConstructor(ctor)))) { + if (!(ctor && (ctor.kind === 168 /* Constructor */ || isJSConstructor(ctor)))) { return true; } if (symbol.valueDeclaration) { @@ -70987,11 +73571,11 @@ var ts; if (ts.isAccessExpression(expr)) { // references through namespace import should be readonly var node = ts.skipParentheses(expr.expression); - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { var symbol_2 = getNodeLinks(node).resolvedSymbol; if (symbol_2.flags & 2097152 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol_2); - return !!declaration && declaration.kind === 263 /* NamespaceImport */; + return !!declaration && declaration.kind === 265 /* NamespaceImport */; } } } @@ -71000,7 +73584,7 @@ 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 !== 78 /* Identifier */ && !ts.isAccessExpression(node)) { + if (node.kind !== 79 /* Identifier */ && !ts.isAccessExpression(node)) { error(expr, invalidReferenceMessage); return false; } @@ -71072,7 +73656,7 @@ var ts; 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); var func = ts.getContainingFunction(node); - if (func && func.kind !== 166 /* Constructor */ && (ts.getFunctionFlags(func) & 2 /* Async */) === 0) { + if (func && func.kind !== 168 /* Constructor */ && (ts.getFunctionFlags(func) & 2 /* Async */) === 0) { var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); } @@ -71239,14 +73823,33 @@ var ts; rightType = checkNonNullType(rightType, right); // TypeScript 1.0 spec (April 2014): 4.15.5 // The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, - // and the right operand to be of type Any, an object type, or a type parameter type. + // and the right operand to be + // + // 1. assignable to the non-primitive type, + // 2. an unconstrained type parameter, + // 3. a union or intersection including one or more type parameters, whose constituents are all assignable to the + // the non-primitive type, or are unconstrainted type parameters, or have constraints assignable to the + // non-primitive type, or + // 4. a type parameter whose constraint is + // i. an object type, + // ii. the non-primitive type, or + // iii. a union or intersection with at least one constituent assignable to an object or non-primitive type. + // + // The divergent behavior for type parameters and unions containing type parameters is a workaround for type + // parameters not being narrowable. If the right operand is a concrete type, we can error if there is any chance + // it is a primitive. But if the operand is a type parameter, it cannot be narrowed, so we don't issue an error + // unless *all* instantiations would result in an error. + // // The result is always of the Boolean primitive type. if (!(allTypesAssignableToKind(leftType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) || isTypeAssignableToKind(leftType, 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 262144 /* TypeParameter */))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } - if (!allTypesAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */)) { - error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); + 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 */))) { + error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_not_be_a_primitive); } return booleanType; } @@ -71265,7 +73868,7 @@ var ts; if (rightIsThis === void 0) { rightIsThis = false; } var properties = node.properties; var property = properties[propertyIndex]; - if (property.kind === 288 /* PropertyAssignment */ || property.kind === 289 /* ShorthandPropertyAssignment */) { + if (property.kind === 290 /* PropertyAssignment */ || property.kind === 291 /* ShorthandPropertyAssignment */) { var name = property.name; var exprType = getLiteralTypeFromPropertyName(name); if (isTypeUsableAsPropertyName(exprType)) { @@ -71273,14 +73876,14 @@ var ts; var prop = getPropertyOfType(objectLiteralType, text); if (prop) { markPropertyAsReferenced(prop, property, rightIsThis); - checkPropertyAccessibility(property, /*isSuper*/ false, objectLiteralType, prop); + checkPropertyAccessibility(property, /*isSuper*/ false, /*writing*/ true, objectLiteralType, prop); } } - var elementType = getIndexedAccessType(objectLiteralType, exprType, /*noUncheckedIndexedAccessCandidate*/ undefined, name, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, 16 /* ExpressionPosition */); + var elementType = getIndexedAccessType(objectLiteralType, exprType, 32 /* ExpressionPosition */, name); var type = getFlowTypeOfDestructuring(property, elementType); - return checkDestructuringAssignment(property.kind === 289 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); + return checkDestructuringAssignment(property.kind === 291 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); } - else if (property.kind === 290 /* SpreadAssignment */) { + else if (property.kind === 292 /* SpreadAssignment */) { if (propertyIndex < properties.length - 1) { error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } @@ -71318,7 +73921,7 @@ var ts; var inBoundsType = compilerOptions.noUncheckedIndexedAccess ? undefined : possiblyOutOfBoundsType; for (var i = 0; i < elements.length; i++) { var type = possiblyOutOfBoundsType; - if (node.elements[i].kind === 220 /* SpreadElement */) { + if (node.elements[i].kind === 222 /* SpreadElement */) { type = inBoundsType = inBoundsType !== null && inBoundsType !== void 0 ? inBoundsType : (checkIteratedTypeOrElementType(65 /* Destructuring */, sourceType, undefinedType, node) || errorType); } checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, type, checkMode); @@ -71328,14 +73931,14 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 222 /* OmittedExpression */) { - if (element.kind !== 220 /* SpreadElement */) { + if (element.kind !== 224 /* OmittedExpression */) { + if (element.kind !== 222 /* SpreadElement */) { var indexType = getLiteralType(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 = 16 /* ExpressionPosition */ | (hasDefaultValue(element) ? 8 /* NoTupleBoundsCheck */ : 0); - var elementType_2 = getIndexedAccessTypeOrUndefined(sourceType, indexType, /*noUncheckedIndexedAccessCandidate*/ undefined, createSyntheticExpression(element, indexType), accessFlags) || errorType; + var accessFlags = 32 /* ExpressionPosition */ | (hasDefaultValue(element) ? 16 /* 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 type = getFlowTypeOfDestructuring(element, assignedType); return checkDestructuringAssignment(element, type, checkMode); @@ -71347,7 +73950,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 216 /* BinaryExpression */ && restExpression.operatorToken.kind === 62 /* EqualsToken */) { + if (restExpression.kind === 218 /* BinaryExpression */ && restExpression.operatorToken.kind === 63 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -71363,7 +73966,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) { var target; - if (exprOrAssignment.kind === 289 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 291 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove @@ -71379,24 +73982,24 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 216 /* BinaryExpression */ && target.operatorToken.kind === 62 /* EqualsToken */) { + if (target.kind === 218 /* BinaryExpression */ && target.operatorToken.kind === 63 /* EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 200 /* ObjectLiteralExpression */) { + if (target.kind === 202 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, rightIsThis); } - if (target.kind === 199 /* ArrayLiteralExpression */) { + if (target.kind === 201 /* 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 === 290 /* SpreadAssignment */ ? + var error = target.parent.kind === 292 /* 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 === 290 /* SpreadAssignment */ ? + var optionalError = target.parent.kind === 292 /* 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)) { @@ -71418,39 +74021,39 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: case 10 /* StringLiteral */: case 13 /* RegularExpressionLiteral */: - case 205 /* TaggedTemplateExpression */: - case 218 /* TemplateExpression */: + case 207 /* TaggedTemplateExpression */: + case 220 /* TemplateExpression */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: - case 103 /* NullKeyword */: - case 150 /* UndefinedKeyword */: - case 208 /* FunctionExpression */: - case 221 /* ClassExpression */: - case 209 /* ArrowFunction */: - case 199 /* ArrayLiteralExpression */: - case 200 /* ObjectLiteralExpression */: - case 211 /* TypeOfExpression */: - case 225 /* NonNullExpression */: - case 274 /* JsxSelfClosingElement */: - case 273 /* JsxElement */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: + case 104 /* NullKeyword */: + case 151 /* UndefinedKeyword */: + case 210 /* FunctionExpression */: + case 223 /* ClassExpression */: + case 211 /* ArrowFunction */: + case 201 /* ArrayLiteralExpression */: + case 202 /* ObjectLiteralExpression */: + case 213 /* TypeOfExpression */: + case 227 /* NonNullExpression */: + case 276 /* JsxSelfClosingElement */: + case 275 /* JsxElement */: return true; - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 214 /* PrefixUnaryExpression */: - case 215 /* PostfixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { @@ -71462,9 +74065,9 @@ var ts; } return false; // Some forms listed here for clarity - case 212 /* VoidExpression */: // Explicit opt-out - case 206 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 224 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 214 /* VoidExpression */: // Explicit opt-out + case 208 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 226 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } @@ -71472,84 +74075,111 @@ var ts; function isTypeEqualityComparableTo(source, target) { return (target.flags & 98304 /* Nullable */) !== 0 || isTypeComparableTo(source, target); } - var CheckBinaryExpressionState; - (function (CheckBinaryExpressionState) { - CheckBinaryExpressionState[CheckBinaryExpressionState["MaybeCheckLeft"] = 0] = "MaybeCheckLeft"; - CheckBinaryExpressionState[CheckBinaryExpressionState["CheckRight"] = 1] = "CheckRight"; - CheckBinaryExpressionState[CheckBinaryExpressionState["FinishCheck"] = 2] = "FinishCheck"; - })(CheckBinaryExpressionState || (CheckBinaryExpressionState = {})); - function checkBinaryExpression(node, checkMode) { - var workStacks = { - expr: [node], - state: [0 /* MaybeCheckLeft */], - leftType: [undefined] + function createCheckBinaryExpression() { + var trampoline = ts.createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, foldState); + return function (node, checkMode) { + var result = trampoline(node, checkMode); + ts.Debug.assertIsDefined(result); + return result; }; - var stackIndex = 0; - var lastResult; - while (stackIndex >= 0) { - node = workStacks.expr[stackIndex]; - switch (workStacks.state[stackIndex]) { - case 0 /* MaybeCheckLeft */: { - if (ts.isInJSFile(node) && ts.getAssignedExpandoInitializer(node)) { - finishInvocation(checkExpression(node.right, checkMode)); - break; - } - checkGrammarNullishCoalesceWithLogicalExpression(node); - var operator = node.operatorToken.kind; - if (operator === 62 /* EqualsToken */ && (node.left.kind === 200 /* ObjectLiteralExpression */ || node.left.kind === 199 /* ArrayLiteralExpression */)) { - finishInvocation(checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 107 /* ThisKeyword */)); - break; - } - advanceState(1 /* CheckRight */); - maybeCheckExpression(node.left); - break; - } - case 1 /* CheckRight */: { - var leftType = lastResult; - workStacks.leftType[stackIndex] = leftType; - var operator = node.operatorToken.kind; - if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { - if (operator === 55 /* AmpersandAmpersandToken */) { - var parent = ts.walkUpParenthesizedExpressions(node.parent); - checkTestingKnownTruthyCallableType(node.left, leftType, ts.isIfStatement(parent) ? parent.thenStatement : undefined); - } - checkTruthinessOfType(leftType, node.left); + function onEnter(node, state, checkMode) { + if (state) { + state.stackIndex++; + state.skip = false; + setLeftType(state, /*type*/ undefined); + setLastResult(state, /*type*/ undefined); + } + else { + state = { + checkMode: checkMode, + skip: false, + stackIndex: 0, + typeStack: [undefined, undefined], + }; + } + if (ts.isInJSFile(node) && ts.getAssignedExpandoInitializer(node)) { + state.skip = true; + setLastResult(state, checkExpression(node.right, checkMode)); + return state; + } + checkGrammarNullishCoalesceWithLogicalExpression(node); + var operator = node.operatorToken.kind; + if (operator === 63 /* EqualsToken */ && (node.left.kind === 202 /* ObjectLiteralExpression */ || node.left.kind === 201 /* ArrayLiteralExpression */)) { + state.skip = true; + setLastResult(state, checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 108 /* ThisKeyword */)); + return state; + } + return state; + } + function onLeft(left, state, _node) { + if (!state.skip) { + return maybeCheckExpression(state, left); + } + } + function onOperator(operatorToken, state, node) { + if (!state.skip) { + var leftType = getLastResult(state); + ts.Debug.assertIsDefined(leftType); + 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); + checkTestingKnownTruthyCallableOrAwaitableType(node.left, leftType, ts.isIfStatement(parent) ? parent.thenStatement : undefined); } - advanceState(2 /* FinishCheck */); - maybeCheckExpression(node.right); - break; + checkTruthinessOfType(leftType, node.left); } - case 2 /* FinishCheck */: { - var leftType = workStacks.leftType[stackIndex]; - var rightType = lastResult; - finishInvocation(checkBinaryLikeExpressionWorker(node.left, node.operatorToken, node.right, leftType, rightType, node)); - break; - } - default: return ts.Debug.fail("Invalid state " + workStacks.state[stackIndex] + " for checkBinaryExpression"); } } - return lastResult; - function finishInvocation(result) { - lastResult = result; - stackIndex--; - } - /** - * Note that `advanceState` sets the _current_ head state, and that `maybeCheckExpression` potentially pushes on a new - * head state; so `advanceState` must be called before any `maybeCheckExpression` during a state's execution. - */ - function advanceState(nextState) { - workStacks.state[stackIndex] = nextState; + function onRight(right, state, _node) { + if (!state.skip) { + return maybeCheckExpression(state, right); + } } - function maybeCheckExpression(node) { - if (ts.isBinaryExpression(node)) { - stackIndex++; - workStacks.expr[stackIndex] = node; - workStacks.state[stackIndex] = 0 /* MaybeCheckLeft */; - workStacks.leftType[stackIndex] = undefined; + function onExit(node, state) { + var result; + if (state.skip) { + result = getLastResult(state); } else { - lastResult = checkExpression(node, checkMode); + var leftType = getLeftType(state); + ts.Debug.assertIsDefined(leftType); + var rightType = getLastResult(state); + ts.Debug.assertIsDefined(rightType); + result = checkBinaryLikeExpressionWorker(node.left, node.operatorToken, node.right, leftType, rightType, node); + } + state.skip = false; + setLeftType(state, /*type*/ undefined); + setLastResult(state, /*type*/ undefined); + state.stackIndex--; + return result; + } + function foldState(state, result, _side) { + setLastResult(state, result); + return state; + } + function maybeCheckExpression(state, node) { + if (ts.isBinaryExpression(node)) { + return node; } + setLastResult(state, checkExpression(node, state.checkMode)); + } + function getLeftType(state) { + return state.typeStack[state.stackIndex]; + } + function setLeftType(state, type) { + state.typeStack[state.stackIndex] = type; + } + function getLastResult(state) { + return state.typeStack[state.stackIndex + 1]; + } + function setLastResult(state, type) { + // To reduce overhead, reuse the next stack entry to store the + // last result. This avoids the overhead of an additional property + // on `WorkArea` and reuses empty stack entries as we walk back up + // the stack. + state.typeStack[state.stackIndex + 1] = type; } } function checkGrammarNullishCoalesceWithLogicalExpression(node) { @@ -71567,8 +74197,8 @@ 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 === 62 /* EqualsToken */ && (left.kind === 200 /* ObjectLiteralExpression */ || left.kind === 199 /* ArrayLiteralExpression */)) { - return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 107 /* ThisKeyword */); + if (operator === 63 /* EqualsToken */ && (left.kind === 202 /* ObjectLiteralExpression */ || left.kind === 201 /* ArrayLiteralExpression */)) { + return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 108 /* ThisKeyword */); } var leftType; if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { @@ -71585,26 +74215,26 @@ var ts; switch (operator) { case 41 /* AsteriskToken */: case 42 /* AsteriskAsteriskToken */: - case 65 /* AsteriskEqualsToken */: - case 66 /* AsteriskAsteriskEqualsToken */: + case 66 /* AsteriskEqualsToken */: + case 67 /* AsteriskAsteriskEqualsToken */: case 43 /* SlashToken */: - case 67 /* SlashEqualsToken */: + case 68 /* SlashEqualsToken */: case 44 /* PercentToken */: - case 68 /* PercentEqualsToken */: + case 69 /* PercentEqualsToken */: case 40 /* MinusToken */: - case 64 /* MinusEqualsToken */: + case 65 /* MinusEqualsToken */: case 47 /* LessThanLessThanToken */: - case 69 /* LessThanLessThanEqualsToken */: + case 70 /* LessThanLessThanEqualsToken */: case 48 /* GreaterThanGreaterThanToken */: - case 70 /* GreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanEqualsToken */: case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: case 51 /* BarToken */: - case 73 /* BarEqualsToken */: + case 74 /* BarEqualsToken */: case 52 /* CaretToken */: - case 77 /* CaretEqualsToken */: + case 78 /* CaretEqualsToken */: case 50 /* AmpersandToken */: - case 72 /* AmpersandEqualsToken */: + case 73 /* AmpersandEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -71634,11 +74264,11 @@ var ts; else if (bothAreBigIntLike(leftType, rightType)) { switch (operator) { case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: reportOperatorError(); break; case 42 /* AsteriskAsteriskToken */: - case 66 /* AsteriskAsteriskEqualsToken */: + case 67 /* AsteriskAsteriskEqualsToken */: if (languageVersion < 3 /* ES2016 */) { error(errorNode, ts.Diagnostics.Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_later); } @@ -71656,7 +74286,7 @@ var ts; return resultType_1; } case 39 /* PlusToken */: - case 63 /* PlusEqualsToken */: + case 64 /* PlusEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -71699,7 +74329,7 @@ var ts; }); return anyType; } - if (operator === 63 /* PlusEqualsToken */) { + if (operator === 64 /* PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; @@ -71721,41 +74351,41 @@ var ts; case 37 /* ExclamationEqualsEqualsToken */: reportOperatorErrorUnless(function (left, right) { return isTypeEqualityComparableTo(left, right) || isTypeEqualityComparableTo(right, left); }); return booleanType; - case 101 /* InstanceOfKeyword */: + case 102 /* InstanceOfKeyword */: return checkInstanceOfExpression(left, right, leftType, rightType); - case 100 /* InKeyword */: + case 101 /* InKeyword */: return checkInExpression(left, right, leftType, rightType); case 55 /* AmpersandAmpersandToken */: - case 75 /* AmpersandAmpersandEqualsToken */: { + case 76 /* AmpersandAmpersandEqualsToken */: { var resultType_2 = getTypeFacts(leftType) & 4194304 /* Truthy */ ? getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) : leftType; - if (operator === 75 /* AmpersandAmpersandEqualsToken */) { + if (operator === 76 /* AmpersandAmpersandEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_2; } case 56 /* BarBarToken */: - case 74 /* BarBarEqualsToken */: { + case 75 /* BarBarEqualsToken */: { var resultType_3 = getTypeFacts(leftType) & 8388608 /* Falsy */ ? getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2 /* Subtype */) : leftType; - if (operator === 74 /* BarBarEqualsToken */) { + if (operator === 75 /* BarBarEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_3; } case 60 /* QuestionQuestionToken */: - case 76 /* QuestionQuestionEqualsToken */: { + case 77 /* QuestionQuestionEqualsToken */: { var resultType_4 = getTypeFacts(leftType) & 262144 /* EQUndefinedOrNull */ ? getUnionType([getNonNullableType(leftType), rightType], 2 /* Subtype */) : leftType; - if (operator === 76 /* QuestionQuestionEqualsToken */) { + if (operator === 77 /* QuestionQuestionEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_4; } - case 62 /* EqualsToken */: + case 63 /* EqualsToken */: var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0 /* None */; checkAssignmentDeclaration(declKind, rightType); if (isAssignmentDeclaration(declKind)) { @@ -71802,7 +74432,7 @@ var ts; if (propType.symbol && propType.symbol.flags & 32 /* Class */) { var name = prop.escapedName; var symbol = resolveName(prop.valueDeclaration, name, 788968 /* Type */, undefined, name, /*isUse*/ false); - if (symbol && symbol.declarations.some(ts.isJSDocTypedefTag)) { + 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); } @@ -71811,7 +74441,7 @@ var ts; } } function isEvalNode(node) { - return node.kind === 78 /* Identifier */ && node.escapedText === "eval"; + return node.kind === 79 /* Identifier */ && node.escapedText === "eval"; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { @@ -71827,13 +74457,13 @@ var ts; function getSuggestedBooleanOperator(operator) { switch (operator) { case 51 /* BarToken */: - case 73 /* BarEqualsToken */: + case 74 /* BarEqualsToken */: return 56 /* BarBarToken */; case 52 /* CaretToken */: - case 77 /* CaretEqualsToken */: + case 78 /* CaretEqualsToken */: return 37 /* ExclamationEqualsEqualsToken */; case 50 /* AmpersandToken */: - case 72 /* AmpersandEqualsToken */: + case 73 /* AmpersandEqualsToken */: return 55 /* AmpersandAmpersandToken */; default: return undefined; @@ -71997,7 +74627,7 @@ var ts; } function checkConditionalExpression(node, checkMode) { var type = checkTruthinessExpression(node.condition); - checkTestingKnownTruthyCallableType(node.condition, type, node.whenTrue); + checkTestingKnownTruthyCallableOrAwaitableType(node.condition, type, node.whenTrue); var type1 = checkExpression(node.whenTrue, checkMode); var type2 = checkExpression(node.whenFalse, checkMode); return getUnionType([type1, type2], 2 /* Subtype */); @@ -72014,10 +74644,14 @@ var ts; texts.push(span.literal.text); types.push(isTypeAssignableTo(type, templateConstraintType) ? type : stringType); } - return getFreshTypeOfLiteralType(getTemplateLiteralType(texts, types)); + return isConstContext(node) || someType(getContextualType(node) || 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 */)); } function getContextNode(node) { - if (node.kind === 281 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { + if (node.kind === 283 /* 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; @@ -72033,7 +74667,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, 134220672 /* FreshableLiteral */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ? + var result = maybeTypeOfKind(type, 2944 /* Literal */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ? getRegularTypeOfLiteralType(type) : type; return result; } @@ -72066,13 +74700,13 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 206 /* TypeAssertionExpression */ || node.kind === 224 /* AsExpression */; + return node.kind === 208 /* TypeAssertionExpression */ || node.kind === 226 /* AsExpression */; } function checkDeclarationInitializer(declaration, contextualType) { var initializer = ts.getEffectiveInitializer(declaration); var type = getQuickTypeOfExpression(initializer) || (contextualType ? checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, 0 /* Normal */) : checkExpressionCached(initializer)); - return ts.isParameter(declaration) && declaration.name.kind === 197 /* ArrayBindingPattern */ && + return ts.isParameter(declaration) && declaration.name.kind === 199 /* ArrayBindingPattern */ && isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ? padTupleType(type, declaration.name) : type; } @@ -72082,7 +74716,7 @@ 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 === 198 /* BindingElement */ && e.dotDotDotToken)) { + if (i < patternElements.length - 1 || !(e.kind === 200 /* BindingElement */ && e.dotDotDotToken)) { elementTypes.push(!ts.isOmittedExpression(e) && hasDefaultValue(e) ? getTypeFromBindingElement(e, /*includePatternInType*/ false, /*reportErrors*/ false) : anyType); elementFlags.push(2 /* Optional */); if (!ts.isOmittedExpression(e) && !hasDefaultValue(e)) { @@ -72095,7 +74729,7 @@ var ts; function widenTypeInferredFromInitializer(declaration, type) { var widened = ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || ts.isDeclarationReadonly(declaration) ? type : getWidenedLiteralType(type); if (ts.isInJSFile(declaration)) { - if (widened.flags & 98304 /* Nullable */) { + if (isEmptyLiteralType(widened)) { reportImplicitAny(declaration, anyType); return anyType; } @@ -72117,7 +74751,7 @@ var ts; // 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, 134217856 /* StringLikeLiteral */) || + 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 */) || @@ -72125,7 +74759,7 @@ var ts; } // 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 & (134217856 /* StringLikeLiteral */ | 4194304 /* Index */ | 268435456 /* StringMapping */) && maybeTypeOfKind(candidateType, 134217856 /* StringLikeLiteral */) || + 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 */) || @@ -72149,7 +74783,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 === 158 /* ComputedPropertyName */) { + if (node.name.kind === 160 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); @@ -72160,7 +74794,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 === 158 /* ComputedPropertyName */) { + if (node.name.kind === 160 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -72287,7 +74921,7 @@ var ts; len--; var s = baseName.slice(0, len); for (var index = 1; true; index++) { - var augmentedName = (s + index); + var augmentedName = s + index; if (!hasTypeParameterByName(typeParameters, augmentedName)) { return augmentedName; } @@ -72336,7 +74970,7 @@ var ts; var 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 !== 105 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { + if (ts.isCallExpression(expr) && expr.expression.kind !== 106 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { var type = ts.isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) : getReturnTypeOfSingleNonGenericCallSignature(checkNonNullExpression(expr.expression)); if (type) { @@ -72347,7 +74981,7 @@ var ts; return getTypeFromTypeNode(expr.type); } else if (node.kind === 8 /* NumericLiteral */ || node.kind === 10 /* StringLiteral */ || - node.kind === 109 /* TrueKeyword */ || node.kind === 94 /* FalseKeyword */) { + node.kind === 110 /* TrueKeyword */ || node.kind === 95 /* FalseKeyword */) { return checkExpression(node); } return undefined; @@ -72378,7 +75012,7 @@ var ts; } } function checkExpression(node, checkMode, forceTuple) { - ts.tracing.push("check" /* Check */, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end }); var saveCurrentNode = currentNode; currentNode = node; instantiationCount = 0; @@ -72388,7 +75022,7 @@ var ts; checkConstEnumAccess(node, type); } currentNode = saveCurrentNode; - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return type; } function checkConstEnumAccess(node, type) { @@ -72396,11 +75030,11 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 201 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 202 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 78 /* Identifier */ || node.kind === 157 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 176 /* TypeQuery */ && node.parent.exprName === node)) || - (node.parent.kind === 270 /* ExportSpecifier */); // We allow reexporting const enums + var ok = (node.parent.kind === 203 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 204 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 79 /* Identifier */ || node.kind === 159 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 178 /* TypeQuery */ && node.parent.exprName === node)) || + (node.parent.kind === 272 /* 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); } @@ -72415,7 +75049,7 @@ var ts; function checkParenthesizedExpression(node, checkMode) { var tag = ts.isInJSFile(node) ? ts.getJSDocTypeTag(node) : undefined; if (tag) { - return checkAssertionWorker(tag, tag.typeExpression.type, node.expression, checkMode); + return checkAssertionWorker(tag.typeExpression.type, tag.typeExpression.type, node.expression, checkMode); } return checkExpression(node.expression, checkMode); } @@ -72425,20 +75059,20 @@ 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 221 /* ClassExpression */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 223 /* ClassExpression */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 78 /* Identifier */: - return checkIdentifier(node); - case 107 /* ThisKeyword */: + case 79 /* Identifier */: + return checkIdentifier(node, checkMode); + case 108 /* ThisKeyword */: return checkThisExpression(node); - case 105 /* SuperKeyword */: + case 106 /* SuperKeyword */: return checkSuperExpression(node); - case 103 /* NullKeyword */: + case 104 /* NullKeyword */: return nullWideningType; case 14 /* NoSubstitutionTemplateLiteral */: case 10 /* StringLiteral */: @@ -72449,82 +75083,82 @@ var ts; case 9 /* BigIntLiteral */: checkGrammarBigIntLiteral(node); return getFreshTypeOfLiteralType(getBigIntLiteralType(node)); - case 109 /* TrueKeyword */: + case 110 /* TrueKeyword */: return trueType; - case 94 /* FalseKeyword */: + case 95 /* FalseKeyword */: return falseType; - case 218 /* TemplateExpression */: + case 220 /* TemplateExpression */: return checkTemplateExpression(node); case 13 /* RegularExpressionLiteral */: return globalRegExpType; - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode, forceTuple); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 201 /* PropertyAccessExpression */: - return checkPropertyAccessExpression(node); - case 157 /* QualifiedName */: - return checkQualifiedName(node); - case 202 /* ElementAccessExpression */: - return checkIndexedAccess(node); - case 203 /* CallExpression */: - if (node.expression.kind === 99 /* ImportKeyword */) { + case 203 /* PropertyAccessExpression */: + return checkPropertyAccessExpression(node, checkMode); + case 159 /* QualifiedName */: + return checkQualifiedName(node, checkMode); + case 204 /* ElementAccessExpression */: + return checkIndexedAccess(node, checkMode); + case 205 /* CallExpression */: + if (node.expression.kind === 100 /* ImportKeyword */) { return checkImportCallExpression(node); } // falls through - case 204 /* NewExpression */: + case 206 /* NewExpression */: return checkCallExpression(node, checkMode); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: return checkClassExpression(node); - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 211 /* TypeOfExpression */: + case 213 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 206 /* TypeAssertionExpression */: - case 224 /* AsExpression */: + case 208 /* TypeAssertionExpression */: + case 226 /* AsExpression */: return checkAssertion(node); - case 225 /* NonNullExpression */: + case 227 /* NonNullExpression */: return checkNonNullAssertion(node); - case 226 /* MetaProperty */: + case 228 /* MetaProperty */: return checkMetaProperty(node); - case 210 /* DeleteExpression */: + case 212 /* DeleteExpression */: return checkDeleteExpression(node); - case 212 /* VoidExpression */: + case 214 /* VoidExpression */: return checkVoidExpression(node); - case 213 /* AwaitExpression */: + case 215 /* AwaitExpression */: return checkAwaitExpression(node); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 220 /* SpreadElement */: + case 222 /* SpreadElement */: return checkSpreadExpression(node, checkMode); - case 222 /* OmittedExpression */: + case 224 /* OmittedExpression */: return undefinedWideningType; - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: return checkYieldExpression(node); - case 227 /* SyntheticExpression */: + case 229 /* SyntheticExpression */: return checkSyntheticExpression(node); - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: return checkJsxExpression(node, checkMode); - case 273 /* JsxElement */: + case 275 /* JsxElement */: return checkJsxElement(node, checkMode); - case 274 /* JsxSelfClosingElement */: + case 276 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 277 /* JsxFragment */: + case 279 /* JsxFragment */: return checkJsxFragment(node); - case 281 /* JsxAttributes */: + case 283 /* JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 275 /* JsxOpeningElement */: + case 277 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -72560,11 +75194,11 @@ var ts; checkGrammarDecoratorsAndModifiers(node); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); - if (ts.hasSyntacticModifier(node, 92 /* ParameterPropertyModifier */)) { - if (!(func.kind === 166 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */)) { + if (!(func.kind === 168 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } - if (func.kind === 166 /* Constructor */ && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") { + if (func.kind === 168 /* Constructor */ && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") { error(node.name, ts.Diagnostics.constructor_cannot_be_used_as_a_parameter_property_name); } } @@ -72575,13 +75209,13 @@ var ts; if (func.parameters.indexOf(node) !== 0) { error(node, ts.Diagnostics.A_0_parameter_must_be_the_first_parameter, node.name.escapedText); } - if (func.kind === 166 /* Constructor */ || func.kind === 170 /* ConstructSignature */ || func.kind === 175 /* ConstructorType */) { + if (func.kind === 168 /* Constructor */ || func.kind === 172 /* ConstructSignature */ || func.kind === 177 /* ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } - if (func.kind === 209 /* ArrowFunction */) { + if (func.kind === 211 /* ArrowFunction */) { error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter); } - if (func.kind === 167 /* GetAccessor */ || func.kind === 168 /* SetAccessor */) { + if (func.kind === 169 /* GetAccessor */ || func.kind === 170 /* SetAccessor */) { error(node, ts.Diagnostics.get_and_set_accessors_cannot_declare_this_parameters); } } @@ -72639,13 +75273,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 209 /* ArrowFunction */: - case 169 /* CallSignature */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 174 /* FunctionType */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 211 /* ArrowFunction */: + case 171 /* CallSignature */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 176 /* FunctionType */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: var parent = node.parent; if (node === parent.type) { return parent; @@ -72659,11 +75293,11 @@ var ts; continue; } var name = element.name; - if (name.kind === 78 /* Identifier */ && name.escapedText === predicateVariableName) { + if (name.kind === 79 /* 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 === 197 /* ArrayBindingPattern */ || name.kind === 196 /* ObjectBindingPattern */) { + else if (name.kind === 199 /* ArrayBindingPattern */ || name.kind === 198 /* ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -72672,13 +75306,13 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 171 /* IndexSignature */) { + if (node.kind === 173 /* 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 === 174 /* FunctionType */ || node.kind === 251 /* FunctionDeclaration */ || node.kind === 175 /* ConstructorType */ || - node.kind === 169 /* CallSignature */ || node.kind === 166 /* Constructor */ || - node.kind === 170 /* ConstructSignature */) { + else if (node.kind === 176 /* FunctionType */ || node.kind === 253 /* FunctionDeclaration */ || node.kind === 177 /* ConstructorType */ || + node.kind === 171 /* CallSignature */ || node.kind === 168 /* Constructor */ || + node.kind === 172 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); @@ -72708,10 +75342,10 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 170 /* ConstructSignature */: + case 172 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 169 /* CallSignature */: + case 171 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -72741,7 +75375,7 @@ var ts; checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 171 /* IndexSignature */ && node.kind !== 308 /* JSDocFunctionType */) { + if (node.kind !== 173 /* IndexSignature */ && node.kind !== 311 /* JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } @@ -72753,7 +75387,7 @@ 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 === 166 /* Constructor */) { + if (member.kind === 168 /* 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)) { @@ -72765,25 +75399,27 @@ var ts; var isStatic = ts.hasSyntacticModifier(member, 32 /* Static */); var name = member.name; if (!name) { - return; + continue; } - var names = ts.isPrivateIdentifier(name) ? privateIdentifiers : + var isPrivate = ts.isPrivateIdentifier(name); + var privateStaticFlags = isPrivate && isStatic ? 16 /* PrivateStatic */ : 0; + var names = isPrivate ? privateIdentifiers : isStatic ? staticNames : instanceNames; var memberName = name && ts.getPropertyNameForPropertyNameNode(name); if (memberName) { switch (member.kind) { - case 167 /* GetAccessor */: - addName(names, name, memberName, 1 /* GetAccessor */); + case 169 /* GetAccessor */: + addName(names, name, memberName, 1 /* GetAccessor */ | privateStaticFlags); break; - case 168 /* SetAccessor */: - addName(names, name, memberName, 2 /* SetAccessor */); + case 170 /* SetAccessor */: + addName(names, name, memberName, 2 /* SetAccessor */ | privateStaticFlags); break; - case 163 /* PropertyDeclaration */: - addName(names, name, memberName, 3 /* GetOrSetAccessor */); + case 165 /* PropertyDeclaration */: + addName(names, name, memberName, 3 /* GetOrSetAccessor */ | privateStaticFlags); break; - case 165 /* MethodDeclaration */: - addName(names, name, memberName, 8 /* Method */); + case 167 /* MethodDeclaration */: + addName(names, name, memberName, 8 /* Method */ | privateStaticFlags); break; } } @@ -72792,16 +75428,25 @@ var ts; function addName(names, location, name, meaning) { var prev = names.get(name); if (prev) { - if (prev & 8 /* Method */) { - if (meaning !== 8 /* Method */) { - error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); - } - } - else if (prev & meaning) { - error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); + // For private identifiers, do not allow mixing of static and instance members with the same name + if ((prev & 16 /* PrivateStatic */) !== (meaning & 16 /* PrivateStatic */)) { + error(location, ts.Diagnostics.Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name, ts.getTextOfNode(location)); } else { - names.set(name, prev | meaning); + var prevIsMethod = !!(prev & 8 /* Method */); + var isMethod = !!(meaning & 8 /* 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 */) { + error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); + } + else { + names.set(name, prev | meaning); + } } } else { @@ -72845,7 +75490,7 @@ 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 === 162 /* PropertySignature */) { + if (member.kind === 164 /* PropertySignature */) { var memberName = void 0; var name = member.name; switch (name.kind) { @@ -72853,7 +75498,7 @@ var ts; case 8 /* NumericLiteral */: memberName = name.text; break; - case 78 /* Identifier */: + case 79 /* Identifier */: memberName = ts.idText(name); break; default: @@ -72870,11 +75515,11 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 253 /* InterfaceDeclaration */) { + if (node.kind === 255 /* 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 - if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { + if (nodeSymbol.declarations && nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; } } @@ -72882,7 +75527,7 @@ var ts; // 3.7.4: An object type can contain at most one string index signature and one numeric index signature. // 8.5: A class declaration can have at most one string index member declaration and one numeric index member declaration var indexSymbol = getIndexSymbol(getSymbolOfNode(node)); - if (indexSymbol) { + if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) { var seenNumericIndexer = false; var seenStringIndexer = false; for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -72890,7 +75535,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 147 /* StringKeyword */: + case 148 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -72898,7 +75543,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 144 /* NumberKeyword */: + case 145 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -72916,11 +75561,13 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && !checkGrammarProperty(node)) checkGrammarComputedPropertyName(node.name); checkVariableLikeDeclaration(node); - // Private class fields transformation relies on WeakMaps. - if (ts.isPrivateIdentifier(node.name) && languageVersion < 99 /* ESNext */) { - for (var lexicalScope = ts.getEnclosingBlockScopeContainer(node); !!lexicalScope; lexicalScope = ts.getEnclosingBlockScopeContainer(lexicalScope)) { - getNodeLinks(lexicalScope).flags |= 67108864 /* ContainsClassWithPrivateIdentifiers */; - } + setNodeLinksForPrivateIdentifierScope(node); + if (ts.isPrivateIdentifier(node.name) && ts.hasStaticModifier(node) && node.initializer && languageVersion === 99 /* ESNext */ && !compilerOptions.useDefineForClassFields) { + error(node.initializer, ts.Diagnostics.Static_fields_with_private_names_can_t_have_initializers_when_the_useDefineForClassFields_flag_is_not_specified_with_a_target_of_esnext_Consider_adding_the_useDefineForClassFields_flag); + } + // property signatures already report "initializer not allowed in ambient context" elsewhere + if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 165 /* PropertyDeclaration */ && node.initializer) { + error(node, ts.Diagnostics.Property_0_cannot_have_an_initializer_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } function checkPropertySignature(node) { @@ -72933,16 +75580,34 @@ var ts; // Grammar checking if (!checkGrammarMethod(node)) checkGrammarComputedPropertyName(node.name); - if (ts.isPrivateIdentifier(node.name)) { - error(node, ts.Diagnostics.A_method_cannot_be_named_with_a_private_identifier); - } // Grammar checking for modifiers is done inside the function checkGrammarFunctionLikeDeclaration checkFunctionOrMethodDeclaration(node); - // Abstract methods cannot have an implementation. - // Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node. - if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 165 /* MethodDeclaration */ && node.body) { + // method signatures already report "implementation not allowed in ambient context" elsewhere + if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 167 /* 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 + if (ts.isPrivateIdentifier(node.name) && !ts.getContainingClass(node)) { + error(node, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); + } + setNodeLinksForPrivateIdentifierScope(node); + } + function setNodeLinksForPrivateIdentifierScope(node) { + if (ts.isPrivateIdentifier(node.name) && languageVersion < 99 /* ESNext */) { + for (var lexicalScope = ts.getEnclosingBlockScopeContainer(node); !!lexicalScope; lexicalScope = ts.getEnclosingBlockScopeContainer(lexicalScope)) { + getNodeLinks(lexicalScope).flags |= 67108864 /* 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 + // to transform private elements. + if (ts.isClassExpression(node.parent)) { + var enclosingIterationStatement = getEnclosingIterationStatement(node.parent); + if (enclosingIterationStatement) { + getNodeLinks(node.name).flags |= 524288 /* BlockScopedBindingInLoop */; + getNodeLinks(enclosingIterationStatement).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */; + } + } + } } function checkConstructorDeclaration(node) { // Grammar check on signature of constructor and modifier of the constructor is done in checkSignatureDeclaration function. @@ -72965,10 +75630,10 @@ var ts; return; } function isInstancePropertyWithInitializerOrPrivateIdentifierProperty(n) { - if (ts.isPrivateIdentifierPropertyDeclaration(n)) { + if (ts.isPrivateIdentifierClassElementDeclaration(n)) { return true; } - return n.kind === 163 /* PropertyDeclaration */ && + return n.kind === 165 /* PropertyDeclaration */ && !ts.hasSyntacticModifier(n, 32 /* Static */) && !!n.initializer; } @@ -72989,9 +75654,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 superCallShouldBeFirst = (compilerOptions.target !== 99 /* ESNext */ || !compilerOptions.useDefineForClassFields) && + var superCallShouldBeFirst = (compilerOptions.target !== 99 /* ESNext */ || !useDefineForClassFields) && (ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) || - ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 92 /* ParameterPropertyModifier */); })); + ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476 /* ParameterPropertyModifier */); })); // Skip past any prologue directives to find the first statement // to ensure that it was a super call. if (superCallShouldBeFirst) { @@ -72999,7 +75664,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_4 = statements; _i < statements_4.length; _i++) { var statement = statements_4[_i]; - if (statement.kind === 233 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 235 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -73024,7 +75689,7 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 167 /* GetAccessor */) { + if (node.kind === 169 /* GetAccessor */) { if (!(node.flags & 8388608 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* HasImplicitReturn */)) { if (!(node.flags & 512 /* HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); @@ -73034,45 +75699,42 @@ 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 === 158 /* ComputedPropertyName */) { + if (node.name.kind === 160 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } - if (ts.isPrivateIdentifier(node.name)) { - error(node.name, ts.Diagnostics.An_accessor_cannot_be_named_with_a_private_identifier); - } - if (!hasNonBindableDynamicName(node)) { + if (hasBindableName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. - var otherKind = node.kind === 167 /* GetAccessor */ ? 168 /* SetAccessor */ : 167 /* GetAccessor */; - var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); - if (otherAccessor) { - var nodeFlags = ts.getEffectiveModifierFlags(node); - var otherFlags = ts.getEffectiveModifierFlags(otherAccessor); - if ((nodeFlags & 28 /* AccessibilityModifier */) !== (otherFlags & 28 /* AccessibilityModifier */)) { - error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); + var symbol = getSymbolOfNode(node); + var getter = ts.getDeclarationOfKind(symbol, 169 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 170 /* SetAccessor */); + if (getter && setter && !(getNodeCheckFlags(getter) & 1 /* TypeChecked */)) { + getNodeLinks(getter).flags |= 1 /* TypeChecked */; + var getterFlags = ts.getEffectiveModifierFlags(getter); + var setterFlags = ts.getEffectiveModifierFlags(setter); + if ((getterFlags & 128 /* Abstract */) !== (setterFlags & 128 /* 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 */))) { + 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); } - if ((nodeFlags & 128 /* Abstract */) !== (otherFlags & 128 /* Abstract */)) { - error(node.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); + var getterType = getAnnotatedAccessorType(getter); + var setterType = getAnnotatedAccessorType(setter); + if (getterType && setterType) { + checkTypeAssignableTo(getterType, setterType, getter, ts.Diagnostics.The_return_type_of_a_get_accessor_must_be_assignable_to_its_set_accessor_type); } - // TypeScript 1.0 spec (April 2014): 4.5 - // If both accessors include type annotations, the specified types must be identical. - checkAccessorDeclarationTypesIdentical(node, otherAccessor, getAnnotatedAccessorType, ts.Diagnostics.get_and_set_accessor_must_have_the_same_type); - checkAccessorDeclarationTypesIdentical(node, otherAccessor, getThisTypeOfDeclaration, ts.Diagnostics.get_and_set_accessor_must_have_the_same_this_type); } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 167 /* GetAccessor */) { + if (node.kind === 169 /* GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } checkSourceElement(node.body); - } - function checkAccessorDeclarationTypesIdentical(first, second, getAnnotatedType, message) { - var firstType = getAnnotatedType(first); - var secondType = getAnnotatedType(second); - if (firstType && secondType && !isTypeIdenticalTo(firstType, secondType)) { - error(first, message); - } + setNodeLinksForPrivateIdentifierScope(node); } function checkMissingDeclaration(node) { checkDecorators(node); @@ -73109,7 +75771,7 @@ var ts; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 173 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 175 /* 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); @@ -73124,7 +75786,7 @@ var ts; var symbol = getNodeLinks(node).resolvedSymbol; if (symbol) { if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 134217728 /* Deprecated */); })) { - errorOrSuggestion(/* isError */ false, getDeprecatedSuggestionNode(node), ts.Diagnostics._0_is_deprecated, symbol.escapedName); + addDeprecatedSuggestion(getDeprecatedSuggestionNode(node), symbol.declarations, symbol.escapedName); } if (type.flags & 32 /* Enum */ && symbol.flags & 8 /* EnumMember */) { error(node, ts.Diagnostics.Enum_type_0_has_members_with_initializers_that_are_not_literals, typeToString(type)); @@ -73162,7 +75824,7 @@ 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 !== 192 /* NamedTupleMember */ && hasNamedElement) { + if (e.kind !== 194 /* NamedTupleMember */ && hasNamedElement) { grammarErrorOnNode(e, ts.Diagnostics.Tuple_members_must_all_have_names_or_all_not_have_names); break; } @@ -73211,7 +75873,7 @@ var ts; var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, /*stringsOnly*/ false))) { - if (accessNode.kind === 202 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 204 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && ts.getObjectFlags(objectType) & 32 /* Mapped */ && getMappedTypeModifiers(objectType) & 1 /* IncludeReadonly */) { error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); } @@ -73269,7 +75931,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 184 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 186 /* 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); @@ -73292,25 +75954,25 @@ var ts; if (node.dotDotDotToken && node.questionToken) { grammarErrorOnNode(node, ts.Diagnostics.A_tuple_member_cannot_be_both_optional_and_rest); } - if (node.type.kind === 180 /* OptionalType */) { + if (node.type.kind === 182 /* 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 === 181 /* RestType */) { + if (node.type.kind === 183 /* 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.isPrivateIdentifierPropertyDeclaration(node)) && !!(node.flags & 8388608 /* Ambient */); + return (ts.hasEffectiveModifier(node, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 8388608 /* 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 !== 253 /* InterfaceDeclaration */ && - n.parent.kind !== 252 /* ClassDeclaration */ && - n.parent.kind !== 221 /* ClassExpression */ && + if (n.parent.kind !== 255 /* InterfaceDeclaration */ && + n.parent.kind !== 254 /* ClassDeclaration */ && + n.parent.kind !== 223 /* ClassExpression */ && n.flags & 8388608 /* Ambient */) { if (!(flags & 2 /* 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 @@ -73406,7 +76068,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 === 165 /* MethodDeclaration */ || node.kind === 164 /* MethodSignature */) && + var reportError = (node.kind === 167 /* MethodDeclaration */ || node.kind === 166 /* MethodSignature */) && ts.hasSyntacticModifier(node, 32 /* Static */) !== ts.hasSyntacticModifier(subsequentNode, 32 /* Static */); // we can get here in two cases // 1. mixed static and instance class members @@ -73443,55 +76105,57 @@ var ts; var multipleConstructorImplementation = false; var hasNonAmbientClass = false; var functionDeclarations = []; - for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { - var current = declarations_4[_i]; - var node = current; - var inAmbientContext = node.flags & 8388608 /* Ambient */; - var inAmbientContextOrInterface = node.parent && (node.parent.kind === 253 /* InterfaceDeclaration */ || node.parent.kind === 177 /* TypeLiteral */) || inAmbientContext; - if (inAmbientContextOrInterface) { - // check if declarations are consecutive only if they are non-ambient - // 1. ambient declarations can be interleaved - // i.e. this is legal - // declare function foo(); - // declare function bar(); - // declare function foo(); - // 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 === 252 /* ClassDeclaration */ || node.kind === 221 /* ClassExpression */) && !inAmbientContext) { - hasNonAmbientClass = true; - } - if (node.kind === 251 /* FunctionDeclaration */ || node.kind === 165 /* MethodDeclaration */ || node.kind === 164 /* MethodSignature */ || node.kind === 166 /* Constructor */) { - functionDeclarations.push(node); - var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); - someNodeFlags |= currentNodeFlags; - allNodeFlags &= currentNodeFlags; - someHaveQuestionToken = someHaveQuestionToken || ts.hasQuestionToken(node); - allHaveQuestionToken = allHaveQuestionToken && ts.hasQuestionToken(node); - var bodyIsPresent = ts.nodeIsPresent(node.body); - if (bodyIsPresent && bodyDeclaration) { - if (isConstructor) { - multipleConstructorImplementation = true; + if (declarations) { + for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { + var current = declarations_4[_i]; + var node = current; + var inAmbientContext = node.flags & 8388608 /* Ambient */; + var inAmbientContextOrInterface = node.parent && (node.parent.kind === 255 /* InterfaceDeclaration */ || node.parent.kind === 179 /* TypeLiteral */) || inAmbientContext; + if (inAmbientContextOrInterface) { + // check if declarations are consecutive only if they are non-ambient + // 1. ambient declarations can be interleaved + // i.e. this is legal + // declare function foo(); + // declare function bar(); + // declare function foo(); + // 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 === 254 /* ClassDeclaration */ || node.kind === 223 /* ClassExpression */) && !inAmbientContext) { + hasNonAmbientClass = true; + } + if (node.kind === 253 /* FunctionDeclaration */ || node.kind === 167 /* MethodDeclaration */ || node.kind === 166 /* MethodSignature */ || node.kind === 168 /* Constructor */) { + functionDeclarations.push(node); + var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); + someNodeFlags |= currentNodeFlags; + allNodeFlags &= currentNodeFlags; + someHaveQuestionToken = someHaveQuestionToken || ts.hasQuestionToken(node); + allHaveQuestionToken = allHaveQuestionToken && ts.hasQuestionToken(node); + var bodyIsPresent = ts.nodeIsPresent(node.body); + if (bodyIsPresent && bodyDeclaration) { + if (isConstructor) { + multipleConstructorImplementation = true; + } + else { + duplicateFunctionDeclaration = true; + } + } + else if ((previousDeclaration === null || previousDeclaration === void 0 ? void 0 : previousDeclaration.parent) === node.parent && previousDeclaration.end !== node.pos) { + reportImplementationExpectedError(previousDeclaration); + } + if (bodyIsPresent) { + if (!bodyDeclaration) { + bodyDeclaration = node; + } } else { - duplicateFunctionDeclaration = true; + hasOverloads = true; } - } - else if ((previousDeclaration === null || previousDeclaration === void 0 ? void 0 : previousDeclaration.parent) === node.parent && previousDeclaration.end !== node.pos) { - reportImplementationExpectedError(previousDeclaration); - } - if (bodyIsPresent) { - if (!bodyDeclaration) { - bodyDeclaration = node; + previousDeclaration = node; + if (!inAmbientContextOrInterface) { + lastSeenNonAmbientDeclaration = node; } } - else { - hasOverloads = true; - } - previousDeclaration = node; - if (!inAmbientContextOrInterface) { - lastSeenNonAmbientDeclaration = node; - } } } if (multipleConstructorImplementation) { @@ -73504,13 +76168,18 @@ var ts; error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Duplicate_function_implementation); }); } - if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 /* Function */) { - // A non-ambient class cannot be an implementation for a non-constructor function/class merge - // TODO: The below just replicates our older error from when classes and functions were - // entirely unable to merge - a more helpful message like "Class declaration cannot implement overload list" - // might be warranted. :shrug: + if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 /* Function */ && declarations) { + var relatedDiagnostics_1 = ts.filter(declarations, function (d) { return d.kind === 254 /* ClassDeclaration */; }) + .map(function (d) { return ts.createDiagnosticForNode(d, ts.Diagnostics.Consider_adding_a_declare_modifier_to_this_class); }); ts.forEach(declarations, function (declaration) { - addDuplicateDeclarationError(declaration, ts.Diagnostics.Duplicate_identifier_0, ts.symbolName(symbol), declarations); + var diagnostic = declaration.kind === 254 /* ClassDeclaration */ + ? ts.Diagnostics.Class_declaration_cannot_implement_overload_list_for_0 + : declaration.kind === 253 /* FunctionDeclaration */ + ? ts.Diagnostics.Function_with_bodies_can_only_merge_with_classes_that_are_ambient + : undefined; + if (diagnostic) { + ts.addRelatedInfo.apply(void 0, __spreadArray([error(ts.getNameOfDeclaration(declaration) || declaration, diagnostic, ts.symbolName(symbol))], relatedDiagnostics_1)); + } }); } // Abstract methods can't have an implementation -- in particular, they don't need one. @@ -73519,8 +76188,10 @@ var ts; reportImplementationExpectedError(lastSeenNonAmbientDeclaration); } if (hasOverloads) { - checkFlagAgreementBetweenOverloads(declarations, bodyDeclaration, flagsToCheck, someNodeFlags, allNodeFlags); - checkQuestionTokenAgreementBetweenOverloads(declarations, bodyDeclaration, someHaveQuestionToken, allHaveQuestionToken); + if (declarations) { + checkFlagAgreementBetweenOverloads(declarations, bodyDeclaration, flagsToCheck, someNodeFlags, allNodeFlags); + checkQuestionTokenAgreementBetweenOverloads(declarations, bodyDeclaration, someHaveQuestionToken, allHaveQuestionToken); + } if (bodyDeclaration) { var signatures = getSignaturesOfSymbol(symbol); var bodySignature = getSignatureFromDeclaration(bodyDeclaration); @@ -73594,44 +76265,47 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: // A jsdoc typedef and callback are, by definition, type aliases. // falls through - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 325 /* JSDocEnumTag */: + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + case 333 /* JSDocEnumTag */: return 2 /* ExportType */; - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4 /* ExportNamespace */ | 1 /* ExportValue */ : 4 /* ExportNamespace */; - case 252 /* ClassDeclaration */: - case 255 /* EnumDeclaration */: - case 291 /* EnumMember */: + case 254 /* ClassDeclaration */: + case 257 /* EnumDeclaration */: + case 293 /* EnumMember */: return 2 /* ExportType */ | 1 /* ExportValue */; - case 297 /* SourceFile */: + case 299 /* SourceFile */: return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: + case 218 /* 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(d.expression)) { + if (!ts.isEntityNameExpression(expression)) { return 1 /* ExportValue */; } - d = d.expression; + d = expression; // The below options all declare an Alias, which is allowed to merge with other values within the importing module. // falls through - case 260 /* ImportEqualsDeclaration */: - case 263 /* NamespaceImport */: - case 262 /* ImportClause */: + case 262 /* ImportEqualsDeclaration */: + case 265 /* NamespaceImport */: + case 264 /* ImportClause */: var result_12 = 0 /* None */; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_12 |= getDeclarationSpaces(d); }); return result_12; - case 249 /* VariableDeclaration */: - case 198 /* BindingElement */: - case 251 /* FunctionDeclaration */: - case 265 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 - case 78 /* Identifier */: // https://github.com/microsoft/TypeScript/issues/36098 + case 251 /* VariableDeclaration */: + case 200 /* BindingElement */: + case 253 /* FunctionDeclaration */: + case 267 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 79 /* 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) @@ -73883,7 +76557,7 @@ var ts; var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* Value */, /*ignoreErrors*/ true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; if (promiseConstructorType === errorType) { - if (promiseConstructorName.kind === 78 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { + if (promiseConstructorName.kind === 79 /* 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 { @@ -73923,24 +76597,24 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 160 /* Parameter */: + case 162 /* Parameter */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages( /*details*/ undefined, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages( /*details*/ undefined, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -73961,7 +76635,7 @@ var ts; if (!typeName) return; var rootName = ts.getFirstIdentifier(typeName); - var meaning = (typeName.kind === 78 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; + var meaning = (typeName.kind === 79 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isRefernce*/ true); if (rootSymbol && rootSymbol.flags & 2097152 /* Alias */ @@ -73987,15 +76661,15 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 183 /* IntersectionType */: - case 182 /* UnionType */: + case 185 /* IntersectionType */: + case 184 /* UnionType */: return getEntityNameForDecoratorMetadataFromTypeList(node.types); - case 184 /* ConditionalType */: + case 186 /* ConditionalType */: return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]); - case 186 /* ParenthesizedType */: - case 192 /* NamedTupleMember */: + case 188 /* ParenthesizedType */: + case 194 /* NamedTupleMember */: return getEntityNameForDecoratorMetadata(node.type); - case 173 /* TypeReference */: + case 175 /* TypeReference */: return node.typeName; } } @@ -74004,13 +76678,13 @@ var ts; var commonEntityName; for (var _i = 0, types_23 = types; _i < types_23.length; _i++) { var typeNode = types_23[_i]; - while (typeNode.kind === 186 /* ParenthesizedType */ || typeNode.kind === 192 /* NamedTupleMember */) { + while (typeNode.kind === 188 /* ParenthesizedType */ || typeNode.kind === 194 /* NamedTupleMember */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 141 /* NeverKeyword */) { + if (typeNode.kind === 142 /* NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 191 /* LiteralType */ && typeNode.literal.kind === 103 /* NullKeyword */ || typeNode.kind === 150 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 193 /* LiteralType */ && typeNode.literal.kind === 104 /* NullKeyword */ || typeNode.kind === 151 /* 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); @@ -74056,14 +76730,14 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 160 /* Parameter */) { + if (node.kind === 162 /* Parameter */) { checkExternalEmitHelpers(firstDecorator, 32 /* Param */); } if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16 /* 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 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -74072,23 +76746,23 @@ var ts; } } break; - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - var otherKind = node.kind === 167 /* GetAccessor */ ? 168 /* SetAccessor */ : 167 /* GetAccessor */; + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + var otherKind = node.kind === 169 /* GetAccessor */ ? 170 /* SetAccessor */ : 169 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); break; - case 165 /* MethodDeclaration */: + case 167 /* 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 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 160 /* Parameter */: + case 162 /* Parameter */: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -74151,7 +76825,7 @@ var ts; else if (ts.findLast(ts.getJSDocTags(decl), ts.isJSDocParameterTag) === node && node.typeExpression && node.typeExpression.type && !isArrayType(getTypeFromTypeNode(node.typeExpression.type))) { - error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 157 /* QualifiedName */ ? node.name.right : node.name)); + error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 159 /* QualifiedName */ ? node.name.right : node.name)); } } } @@ -74193,27 +76867,28 @@ var ts; } function getIdentifierFromEntityNameExpression(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return node; - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return node.name; default: return undefined; } } function checkFunctionOrMethodDeclaration(node) { + var _a; checkDecorators(node); checkSignatureDeclaration(node); var functionFlags = ts.getFunctionFlags(node); // 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 === 158 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 160 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); } - if (!hasNonBindableDynamicName(node)) { + if (hasBindableName(node)) { // first we want to check the local symbol that contain this declaration // - if node.localSymbol !== undefined - this is current declaration is exported and localSymbol points to the local symbol // - if node.localSymbol === undefined - this node is non-exported so we can just pick the result of getSymbolOfNode @@ -74222,7 +76897,7 @@ var ts; // Since the javascript won't do semantic analysis like typescript, // if the javascript file comes before the typescript file and both contain same name functions, // checkFunctionOrConstructorSymbol wouldn't be called if we didnt ignore javascript function. - var firstDeclaration = ts.find(localSymbol.declarations, + 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 & 131072 /* JavaScriptFile */); }); // Only type check the symbol once @@ -74234,7 +76909,7 @@ var ts; checkFunctionOrConstructorSymbol(symbol); } } - var body = node.kind === 164 /* MethodSignature */ ? undefined : node.body; + var body = node.kind === 166 /* MethodSignature */ ? undefined : node.body; checkSourceElement(body); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node)); if (produceDiagnostics && !ts.getEffectiveReturnTypeNode(node)) { @@ -74276,42 +76951,42 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 297 /* SourceFile */: - case 256 /* ModuleDeclaration */: - case 230 /* Block */: - case 258 /* CaseBlock */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: + case 299 /* SourceFile */: + case 258 /* ModuleDeclaration */: + case 232 /* Block */: + case 260 /* CaseBlock */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 166 /* Constructor */: - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 168 /* Constructor */: + case 210 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 211 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: if (node.body) { // Don't report unused parameters in overloads checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 164 /* MethodSignature */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 254 /* TypeAliasDeclaration */: - case 253 /* InterfaceDeclaration */: + case 166 /* MethodSignature */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: + case 256 /* TypeAliasDeclaration */: + case 255 /* InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 185 /* InferType */: + case 187 /* InferType */: checkUnusedInferTypeParameter(node, addDiagnostic); break; default: @@ -74331,11 +77006,11 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 165 /* MethodDeclaration */: - case 163 /* PropertyDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - if (member.kind === 168 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { + case 167 /* MethodDeclaration */: + case 165 /* PropertyDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + if (member.kind === 170 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { // Already would have reported an error on the getter. break; } @@ -74346,7 +77021,7 @@ var ts; addDiagnostic(member, 0 /* Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); } break; - case 166 /* Constructor */: + case 168 /* 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 */)) { @@ -74354,8 +77029,8 @@ var ts; } } break; - case 171 /* IndexSignature */: - case 229 /* SemicolonClassElement */: + case 173 /* IndexSignature */: + case 231 /* SemicolonClassElement */: // Can't be private break; default: @@ -74372,7 +77047,8 @@ var ts; function checkUnusedTypeParameters(node, addDiagnostic) { // Only report errors on the last declaration for the type parameter container; // this ensures that all uses have been accounted for. - if (ts.last(getSymbolOfNode(node).declarations) !== node) + var declarations = getSymbolOfNode(node).declarations; + if (!declarations || ts.last(declarations) !== node) return; var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); var seenParentsWithEveryUnused = new ts.Set(); @@ -74382,7 +77058,7 @@ var ts; continue; var name = ts.idText(typeParameter.name); var parent = typeParameter.parent; - if (parent.kind !== 185 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { + if (parent.kind !== 187 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { if (ts.tryAddToSet(seenParentsWithEveryUnused, parent)) { var sourceFile = ts.getSourceFileOfNode(parent); var range = ts.isJSDocTemplateTag(parent) @@ -74391,12 +77067,14 @@ var ts; // Include the `<>` in the error message : ts.rangeOfTypeParameters(sourceFile, parent.typeParameters); var only = parent.typeParameters.length === 1; + //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)); } } 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)); } } @@ -74418,11 +77096,15 @@ var ts; return ts.tryCast(ts.getRootDeclaration(node), ts.isParameter); } function isValidUnusedLocalDeclaration(declaration) { - if (ts.isBindingElement(declaration) && isIdentifierThatStartsWithUnderscore(declaration.name)) { - return !!ts.findAncestor(declaration.parent, function (ancestor) { - return ts.isArrayBindingPattern(ancestor) || ts.isVariableDeclaration(ancestor) || ts.isVariableDeclarationList(ancestor) ? false : - ts.isForOfStatement(ancestor) ? true : "quit"; - }); + if (ts.isBindingElement(declaration)) { + if (ts.isObjectBindingPattern(declaration.parent)) { + /** + * ignore starts with underscore names _ + * const { a: _a } = { a: 1 } + */ + return !!(declaration.propertyName && isIdentifierThatStartsWithUnderscore(declaration.name)); + } + return isIdentifierThatStartsWithUnderscore(declaration.name); } return ts.isAmbientModule(declaration) || (ts.isVariableDeclaration(declaration) && ts.isForInOrOfStatement(declaration.parent.parent) || isImportedDeclaration(declaration)) && isIdentifierThatStartsWithUnderscore(declaration.name); @@ -74438,39 +77120,41 @@ var ts; if (local.flags & 262144 /* TypeParameter */ ? !(local.flags & 3 /* Variable */ && !(local.isReferenced & 3 /* Variable */)) : local.isReferenced || local.exportSymbol) { return; } - for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (isValidUnusedLocalDeclaration(declaration)) { - continue; - } - if (isImportedDeclaration(declaration)) { - addToGroup(unusedImports, importClauseFromImported(declaration), declaration, getNodeId); - } - else if (ts.isBindingElement(declaration) && ts.isObjectBindingPattern(declaration.parent)) { - // In `{ a, ...b }, `a` is considered used since it removes a property from `b`. `b` may still be unused though. - var lastElement = ts.last(declaration.parent.elements); - if (declaration === lastElement || !ts.last(declaration.parent.elements).dotDotDotToken) { - addToGroup(unusedDestructures, declaration.parent, declaration, getNodeId); + if (local.declarations) { + for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (isValidUnusedLocalDeclaration(declaration)) { + continue; } - } - else if (ts.isVariableDeclaration(declaration)) { - addToGroup(unusedVariables, declaration.parent, declaration, getNodeId); - } - else { - var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); - var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration); - if (parameter && name) { - if (!ts.isParameterPropertyDeclaration(parameter, parameter.parent) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { - if (ts.isBindingElement(declaration) && ts.isArrayBindingPattern(declaration.parent)) { - 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))); - } + if (isImportedDeclaration(declaration)) { + addToGroup(unusedImports, importClauseFromImported(declaration), declaration, getNodeId); + } + else if (ts.isBindingElement(declaration) && ts.isObjectBindingPattern(declaration.parent)) { + // In `{ a, ...b }, `a` is considered used since it removes a property from `b`. `b` may still be unused though. + var lastElement = ts.last(declaration.parent.elements); + if (declaration === lastElement || !ts.last(declaration.parent.elements).dotDotDotToken) { + addToGroup(unusedDestructures, declaration.parent, declaration, getNodeId); } } + else if (ts.isVariableDeclaration(declaration)) { + addToGroup(unusedVariables, declaration.parent, declaration, getNodeId); + } else { - errorUnusedLocal(declaration, ts.symbolName(local), addDiagnostic); + var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); + var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration); + if (parameter && name) { + if (!ts.isParameterPropertyDeclaration(parameter, parameter.parent) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { + if (ts.isBindingElement(declaration) && ts.isArrayBindingPattern(declaration.parent)) { + 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))); + } + } + } + else { + errorUnusedLocal(declaration, ts.symbolName(local), addDiagnostic); + } } } } @@ -74480,7 +77164,7 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 263 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 265 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { addDiagnostic(importDecl, 0 /* Local */, unuseds.length === 1 @@ -74498,7 +77182,7 @@ var ts; var bindingPattern = _a[0], bindingElements = _a[1]; var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* Parameter */ : 0 /* Local */; if (bindingPattern.elements.length === bindingElements.length) { - if (bindingElements.length === 1 && bindingPattern.parent.kind === 249 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 250 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 251 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 252 /* VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -74519,7 +77203,7 @@ var ts; if (declarationList.declarations.length === declarations.length) { addDiagnostic(declarationList, 0 /* 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 === 232 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 234 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { @@ -74531,24 +77215,24 @@ var ts; } function bindingNameText(name) { switch (name.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return ts.idText(name); - case 197 /* ArrayBindingPattern */: - case 196 /* ObjectBindingPattern */: + case 199 /* ArrayBindingPattern */: + case 198 /* ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 262 /* ImportClause */ || node.kind === 265 /* ImportSpecifier */ || node.kind === 263 /* NamespaceImport */; + return node.kind === 264 /* ImportClause */ || node.kind === 267 /* ImportSpecifier */ || node.kind === 265 /* NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 262 /* ImportClause */ ? decl : decl.kind === 263 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 264 /* ImportClause */ ? decl : decl.kind === 265 /* NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 230 /* Block */) { + if (node.kind === 232 /* Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -74578,12 +77262,12 @@ var ts; if (!(identifier && identifier.escapedText === name)) { return false; } - if (node.kind === 163 /* PropertyDeclaration */ || - node.kind === 162 /* PropertySignature */ || - node.kind === 165 /* MethodDeclaration */ || - node.kind === 164 /* MethodSignature */ || - node.kind === 167 /* GetAccessor */ || - node.kind === 168 /* SetAccessor */) { + if (node.kind === 165 /* PropertyDeclaration */ || + node.kind === 164 /* PropertySignature */ || + node.kind === 167 /* MethodDeclaration */ || + node.kind === 166 /* MethodSignature */ || + node.kind === 169 /* GetAccessor */ || + node.kind === 170 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -74592,7 +77276,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 160 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 162 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -74602,7 +77286,7 @@ var ts; function checkIfThisIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 78 /* Identifier */; + var isDeclaration_1 = node.kind !== 79 /* Identifier */; if (isDeclaration_1) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -74617,7 +77301,7 @@ var ts; function checkIfNewTargetIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 8 /* CaptureNewTarget */) { - var isDeclaration_2 = node.kind !== 78 /* Identifier */; + var isDeclaration_2 = node.kind !== 79 /* 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); } @@ -74629,10 +77313,11 @@ var ts; return false; }); } - function checkWeakMapCollision(node) { + function checkWeakMapSetCollision(node) { var enclosingBlockScope = ts.getEnclosingBlockScopeContainer(node); if (getNodeCheckFlags(enclosingBlockScope) & 67108864 /* ContainsClassWithPrivateIdentifiers */) { - errorSkippedOn("noEmit", node, ts.Diagnostics.Compiler_reserves_name_0_when_emitting_private_identifier_downlevel, "WeakMap"); + 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 checkCollisionWithRequireExportsInGeneratedCode(node, name) { @@ -74649,7 +77334,7 @@ var ts; } // 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 === 297 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 299 /* 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)); } @@ -74664,7 +77349,7 @@ var ts; } // 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 === 297 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* HasAsyncFunctions */) { + if (parent.kind === 299 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* 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)); } @@ -74699,7 +77384,7 @@ var ts; // 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 === 249 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 251 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -74711,17 +77396,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 250 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 232 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 252 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 234 /* 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 === 230 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 257 /* ModuleBlock */ || - container.kind === 256 /* ModuleDeclaration */ || - container.kind === 297 /* SourceFile */); + (container.kind === 232 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 259 /* ModuleBlock */ || + container.kind === 258 /* ModuleDeclaration */ || + container.kind === 299 /* 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 @@ -74752,18 +77437,18 @@ 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 === 158 /* ComputedPropertyName */) { + if (node.name.kind === 160 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 198 /* BindingElement */) { - if (node.parent.kind === 196 /* ObjectBindingPattern */ && languageVersion < 99 /* ESNext */) { + if (ts.isBindingElement(node)) { + if (ts.isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ES2018 */) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 158 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 160 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access @@ -74776,15 +77461,15 @@ var ts; var nameText = getPropertyNameFromType(exprType); var property = getPropertyOfType(parentType, nameText); if (property) { - markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined, /*isThisAccess*/ false); // A destructuring is never a write-only reference. - checkPropertyAccessibility(parent, !!parent.initializer && parent.initializer.kind === 105 /* SuperKeyword */, parentType, 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); } } } } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 197 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + if (node.name.kind === 199 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, 512 /* Read */); } ts.forEach(node.name.elements, checkSourceElement); @@ -74796,7 +77481,7 @@ var ts; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { - var needCheckInitializer = node.initializer && node.parent.parent.kind !== 238 /* ForInStatement */; + var needCheckInitializer = node.initializer && node.parent.parent.kind !== 240 /* ForInStatement */; var needCheckWidenedType = node.name.elements.length === 0; if (needCheckInitializer || needCheckWidenedType) { // Don't validate for-in initializer as it is already an error @@ -74824,7 +77509,7 @@ var ts; } // For a commonjs `const x = require`, validate the alias and exit var symbol = getSymbolOfNode(node); - if (symbol.flags & 2097152 /* Alias */ && ts.isRequireVariableDeclaration(node, /*requireStringLiteralLikeArgument*/ true)) { + if (symbol.flags & 2097152 /* Alias */ && ts.isRequireVariableDeclaration(node)) { checkAliasSymbol(node); return; } @@ -74838,11 +77523,11 @@ 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 !== 238 /* ForInStatement */) { + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 240 /* ForInStatement */) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); } } - if (symbol.declarations.length > 1) { + if (symbol.declarations && symbol.declarations.length > 1) { if (ts.some(symbol.declarations, function (d) { return d !== node && ts.isVariableLike(d) && !areDeclarationFlagsIdentical(d, node); })) { error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } @@ -74860,26 +77545,27 @@ var ts; if (node.initializer) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(node.initializer), declarationType, node, node.initializer, /*headMessage*/ undefined); } - if (!areDeclarationFlagsIdentical(node, symbol.valueDeclaration)) { + if (symbol.valueDeclaration && !areDeclarationFlagsIdentical(node, symbol.valueDeclaration)) { error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 163 /* PropertyDeclaration */ && node.kind !== 162 /* PropertySignature */) { + if (node.kind !== 165 /* PropertyDeclaration */ && node.kind !== 164 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 249 /* VariableDeclaration */ || node.kind === 198 /* BindingElement */) { + if (node.kind === 251 /* VariableDeclaration */ || node.kind === 200 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); - if (languageVersion < 99 /* ESNext */ && needCollisionCheckForIdentifier(node, node.name, "WeakMap")) { - potentialWeakMapCollisions.push(node); + if (languageVersion < 99 /* ESNext */ + && (needCollisionCheckForIdentifier(node, node.name, "WeakMap") || needCollisionCheckForIdentifier(node, node.name, "WeakSet"))) { + potentialWeakMapSetCollisions.push(node); } } } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 163 /* PropertyDeclaration */ || nextDeclaration.kind === 162 /* PropertySignature */ + var message = nextDeclaration.kind === 165 /* PropertyDeclaration */ || nextDeclaration.kind === 164 /* 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); @@ -74889,8 +77575,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 160 /* Parameter */ && right.kind === 249 /* VariableDeclaration */) || - (left.kind === 249 /* VariableDeclaration */ && right.kind === 160 /* Parameter */)) { + if ((left.kind === 162 /* Parameter */ && right.kind === 251 /* VariableDeclaration */) || + (left.kind === 251 /* VariableDeclaration */ && right.kind === 162 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -74906,10 +77592,10 @@ var ts; return ts.getSelectedEffectiveModifierFlags(left, interestingFlags) === ts.getSelectedEffectiveModifierFlags(right, interestingFlags); } function checkVariableDeclaration(node) { - ts.tracing.push("check" /* Check */, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end }); checkGrammarVariableDeclaration(node); checkVariableLikeDeclaration(node); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } function checkBindingElement(node) { checkGrammarBindingElement(node); @@ -74930,49 +77616,55 @@ var ts; // Grammar checking checkGrammarStatementInAmbientContext(node); var type = checkTruthinessExpression(node.expression); - checkTestingKnownTruthyCallableType(node.expression, type, node.thenStatement); + checkTestingKnownTruthyCallableOrAwaitableType(node.expression, type, node.thenStatement); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 231 /* EmptyStatement */) { + if (node.thenStatement.kind === 233 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); } - function checkTestingKnownTruthyCallableType(condExpr, type, body) { - if (!strictNullChecks) { + function checkTestingKnownTruthyCallableOrAwaitableType(condExpr, type, body) { + if (!strictNullChecks) + return; + if (getFalsyFlags(type)) return; - } var location = ts.isBinaryExpression(condExpr) ? condExpr.right : condExpr; var testedNode = ts.isIdentifier(location) ? location : ts.isPropertyAccessExpression(location) ? location.name : ts.isBinaryExpression(location) && ts.isIdentifier(location.right) ? location.right : undefined; - if (!testedNode) { - return; - } - var possiblyFalsy = getFalsyFlags(type); - if (possiblyFalsy) { + var isPropertyExpressionCast = ts.isPropertyAccessExpression(location) + && ts.isAssertionExpression(ts.skipParentheses(location.expression)); + if (!testedNode || isPropertyExpressionCast) { return; } // While it technically should be invalid for any known-truthy value - // to be tested, we de-scope to functions unrefenced 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. + // 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 */); - if (callSignatures.length === 0) { + var isPromise = !!getAwaitedTypeOfPromise(type); + if (callSignatures.length === 0 && !isPromise) { return; } var testedSymbol = getSymbolAtLocation(testedNode); if (!testedSymbol) { return; } - var isUsed = ts.isBinaryExpression(condExpr.parent) && isFunctionUsedInBinaryExpressionChain(condExpr.parent, testedSymbol) - || body && isFunctionUsedInConditionBody(condExpr, body, testedNode, testedSymbol); + var isUsed = ts.isBinaryExpression(condExpr.parent) && isSymbolUsedInBinaryExpressionChain(condExpr.parent, testedSymbol) + || body && isSymbolUsedInConditionBody(condExpr, body, testedNode, testedSymbol); if (!isUsed) { - error(location, ts.Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead); + if (isPromise) { + errorAndMaybeSuggestAwait(location, + /*maybeMissingAwait*/ true, ts.Diagnostics.This_condition_will_always_return_true_since_this_0_is_always_defined, getTypeNameForErrorDisplay(type)); + } + else { + error(location, ts.Diagnostics.This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_instead); + } } } - function isFunctionUsedInConditionBody(expr, body, testedNode, testedSymbol) { + function isSymbolUsedInConditionBody(expr, body, testedNode, testedSymbol) { return !!ts.forEachChild(body, function check(childNode) { if (ts.isIdentifier(childNode)) { var childSymbol = getSymbolAtLocation(childNode); @@ -74986,7 +77678,7 @@ var ts; var childExpression = childNode.parent; while (testedExpression && childExpression) { if (ts.isIdentifier(testedExpression) && ts.isIdentifier(childExpression) || - testedExpression.kind === 107 /* ThisKeyword */ && childExpression.kind === 107 /* ThisKeyword */) { + testedExpression.kind === 108 /* ThisKeyword */ && childExpression.kind === 108 /* ThisKeyword */) { return getSymbolAtLocation(testedExpression) === getSymbolAtLocation(childExpression); } else if (ts.isPropertyAccessExpression(testedExpression) && ts.isPropertyAccessExpression(childExpression)) { @@ -75009,7 +77701,7 @@ var ts; return ts.forEachChild(childNode, check); }); } - function isFunctionUsedInBinaryExpressionChain(node, testedSymbol) { + function isSymbolUsedInBinaryExpressionChain(node, testedSymbol) { while (ts.isBinaryExpression(node) && node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { var isUsed = ts.forEachChild(node.right, function visit(child) { if (ts.isIdentifier(child)) { @@ -75051,12 +77743,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 250 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 252 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 250 /* VariableDeclarationList */) { + if (node.initializer.kind === 252 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -75090,14 +77782,14 @@ var ts; // 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 === 250 /* VariableDeclarationList */) { + if (node.initializer.kind === 252 /* 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 === 199 /* ArrayLiteralExpression */ || varExpr.kind === 200 /* ObjectLiteralExpression */) { + if (varExpr.kind === 201 /* ArrayLiteralExpression */ || varExpr.kind === 202 /* 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. @@ -75129,7 +77821,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 === 250 /* VariableDeclarationList */) { + if (node.initializer.kind === 252 /* 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); @@ -75143,7 +77835,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 === 199 /* ArrayLiteralExpression */ || varExpr.kind === 200 /* ObjectLiteralExpression */) { + if (varExpr.kind === 201 /* ArrayLiteralExpression */ || varExpr.kind === 202 /* 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)) { @@ -75259,18 +77951,8 @@ 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 yieldType = getIterationTypeOfIterable(use, 0 /* Yield */, inputType, /*errorNode*/ undefined); - var _a = !(use & 4 /* AllowsStringInputFlag */) || hasStringConstituent - ? downlevelIteration - ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true] - : yieldType - ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false] - : [ts.Diagnostics.Type_0_is_not_an_array_type, true] - : downlevelIteration - ? [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] - : yieldType - ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false] - : [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type, true], defaultDiagnostic = _a[0], maybeMissingAwait = _a[1]; + var allowsStrings = !!(use & 4 /* AllowsStringInputFlag */) && !hasStringConstituent; + var _a = getIterationDiagnosticDetails(allowsStrings, downlevelIteration), defaultDiagnostic = _a[0], maybeMissingAwait = _a[1]; errorAndMaybeSuggestAwait(errorNode, maybeMissingAwait && !!getAwaitedTypeOfPromise(arrayType), defaultDiagnostic, typeToString(arrayType)); } return hasStringConstituent ? possibleOutOfBounds ? includeUndefinedInIndexSignature(stringType) : stringType : undefined; @@ -75284,6 +77966,40 @@ var ts; return getUnionType(possibleOutOfBounds ? [arrayElementType, stringType, undefinedType] : [arrayElementType, stringType], 2 /* Subtype */); } return (use & 128 /* PossiblyOutOfBounds */) ? includeUndefinedInIndexSignature(arrayElementType) : arrayElementType; + function getIterationDiagnosticDetails(allowsStrings, downlevelIteration) { + var _a; + if (downlevelIteration) { + return allowsStrings + ? [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); + if (yieldType) { + return [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false]; + } + if (isES2015OrLaterIterable((_a = inputType.symbol) === null || _a === void 0 ? void 0 : _a.escapedName)) { + return [ts.Diagnostics.Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher, true]; + } + return allowsStrings + ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type, true] + : [ts.Diagnostics.Type_0_is_not_an_array_type, true]; + } + } + function isES2015OrLaterIterable(n) { + switch (n) { + case "Float32Array": + case "Float64Array": + case "Int16Array": + case "Int32Array": + case "Int8Array": + case "NodeList": + case "Uint16Array": + case "Uint32Array": + case "Uint8Array": + case "Uint8ClampedArray": + return true; + } + return false; } /** * Gets the requested "iteration type" from an `Iterable`-like or `AsyncIterable`-like type. @@ -75527,6 +78243,11 @@ var ts; return setCachedIterationTypes(type, resolver.iterableCacheKey, createIterationTypes(yieldType, returnType, nextType)); } } + function getPropertyNameForKnownSymbolName(symbolName) { + var ctorType = getGlobalESSymbolConstructorSymbol(/*reportErrors*/ false); + var uniqueType = ctorType && getTypeOfPropertyOfType(getTypeOfSymbol(ctorType), ts.escapeLeadingUnderscores(symbolName)); + return uniqueType && isTypeUsableAsPropertyName(uniqueType) ? getPropertyNameFromType(uniqueType) : "__@" + symbolName; + } /** * Gets the *yield*, *return*, and *next* types of an `Iterable`-like or `AsyncIterable`-like * type from its members. @@ -75539,7 +78260,7 @@ var ts; */ function getIterationTypesOfIterableSlow(type, resolver, errorNode) { var _a; - var method = getPropertyOfType(type, ts.getPropertyNameForKnownSymbolName(resolver.iteratorSymbolName)); + var method = getPropertyOfType(type, getPropertyNameForKnownSymbolName(resolver.iteratorSymbolName)); var methodType = method && !(method.flags & 16777216 /* Optional */) ? getTypeOfSymbol(method) : undefined; if (isTypeAny(methodType)) { return setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes); @@ -75838,12 +78559,12 @@ var ts; var functionFlags = ts.getFunctionFlags(func); if (strictNullChecks || node.expression || returnType.flags & 131072 /* Never */) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; - if (func.kind === 168 /* SetAccessor */) { + if (func.kind === 170 /* SetAccessor */) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 166 /* Constructor */) { + else if (func.kind === 168 /* 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); } @@ -75861,7 +78582,7 @@ var ts; } } } - else if (func.kind !== 166 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 168 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, 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); } @@ -75890,7 +78611,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 === 285 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 287 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -75899,7 +78620,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 284 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 286 /* CaseClause */) { // TypeScript 1.0 spec (April 2014): 5.9 // In a 'switch' statement, each 'case' expression must be of a type that is comparable // to or from the type of the 'switch' expression. @@ -75931,7 +78652,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 245 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 247 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -75961,10 +78682,11 @@ var ts; // Grammar checking if (catchClause.variableDeclaration) { var declaration = catchClause.variableDeclaration; - if (declaration.type) { + var typeNode = ts.getEffectiveTypeAnnotationNode(ts.getRootDeclaration(declaration)); + if (typeNode) { var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false); if (type && !(type.flags & 3 /* AnyOrUnknown */)) { - grammarErrorOnFirstToken(declaration.type, ts.Diagnostics.Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified); + grammarErrorOnFirstToken(typeNode, ts.Diagnostics.Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified); } } else if (declaration.initializer) { @@ -75975,7 +78697,7 @@ var ts; if (blockLocals_1) { ts.forEachKey(catchClause.locals, function (caughtName) { var blockLocal = blockLocals_1.get(caughtName); - if (blockLocal && (blockLocal.flags & 2 /* BlockScopedVariable */) !== 0) { + if ((blockLocal === null || blockLocal === void 0 ? void 0 : blockLocal.valueDeclaration) && (blockLocal.flags & 2 /* BlockScopedVariable */) !== 0) { grammarErrorOnNode(blockLocal.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, caughtName); } }); @@ -75988,27 +78710,30 @@ var ts; checkBlock(node.finallyBlock); } } - function checkIndexConstraints(type) { - var declaredNumberIndexer = getIndexDeclarationOfSymbol(type.symbol, 1 /* Number */); - var declaredStringIndexer = getIndexDeclarationOfSymbol(type.symbol, 0 /* String */); + function checkIndexConstraints(type, isStatic) { + var _a, _b, _c, _d; + var declaredNumberIndexer = getIndexDeclarationOfSymbolTable(isStatic ? (_a = type.symbol) === null || _a === void 0 ? void 0 : _a.exports : (_b = type.symbol) === null || _b === void 0 ? void 0 : _b.members, 1 /* Number */); + var declaredStringIndexer = getIndexDeclarationOfSymbolTable(isStatic ? (_c = type.symbol) === null || _c === void 0 ? void 0 : _c.exports : (_d = type.symbol) === null || _d === void 0 ? void 0 : _d.members, 0 /* String */); var stringIndexType = getIndexTypeOfType(type, 0 /* String */); var numberIndexType = getIndexTypeOfType(type, 1 /* Number */); if (stringIndexType || numberIndexType) { ts.forEach(getPropertiesOfObjectType(type), function (prop) { - var propType = getTypeOfSymbol(prop); + if (isStatic && prop.flags & 4194304 /* Prototype */) + return; + var propType = getNonMissingTypeOfSymbol(prop); checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */); checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */); }); var classDeclaration = type.symbol.valueDeclaration; - if (ts.getObjectFlags(type) & 1 /* Class */ && ts.isClassLike(classDeclaration)) { - for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) { - var member = _a[_i]; + if (ts.getObjectFlags(type) & 1 /* Class */ && classDeclaration && ts.isClassLike(classDeclaration)) { + for (var _i = 0, _e = classDeclaration.members; _i < _e.length; _i++) { + var member = _e[_i]; // Only process instance properties with computed names here. // Static properties cannot be in conflict with indexers, // and properties with literal names were already checked. - if (!ts.hasSyntacticModifier(member, 32 /* Static */) && hasNonBindableDynamicName(member)) { + if (!ts.hasSyntacticModifier(member, 32 /* Static */) && !hasBindableName(member)) { var symbol = getSymbolOfNode(member); - var propType = getTypeOfSymbol(symbol); + var propType = getNonMissingTypeOfSymbol(symbol); checkIndexConstraintForProperty(symbol, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */); checkIndexConstraintForProperty(symbol, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */); } @@ -76021,7 +78746,7 @@ var ts; // condition 'errorNode === undefined' may appear if types does not declare nor string neither number indexer if (!errorNode && (ts.getObjectFlags(type) & 2 /* Interface */)) { var someBaseTypeHasBothIndexers = ts.forEach(getBaseTypes(type), function (base) { return getIndexTypeOfType(base, 0 /* String */) && getIndexTypeOfType(base, 1 /* Number */); }); - errorNode = someBaseTypeHasBothIndexers ? undefined : type.symbol.declarations[0]; + errorNode = someBaseTypeHasBothIndexers || !type.symbol.declarations ? undefined : type.symbol.declarations[0]; } } if (errorNode && !isTypeAssignableTo(numberIndexType, stringIndexType)) { // TODO: GH#18217 @@ -76045,8 +78770,8 @@ var ts; // this allows us to rule out cases when both property and indexer are inherited from the base class var errorNode; if (propDeclaration && name && - (propDeclaration.kind === 216 /* BinaryExpression */ || - name.kind === 158 /* ComputedPropertyName */ || + (propDeclaration.kind === 218 /* BinaryExpression */ || + name.kind === 160 /* ComputedPropertyName */ || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -76058,7 +78783,7 @@ var ts; // check if any base class already has both property and indexer. // check should be performed only if 'type' is the first type that brings property\indexer together var someBaseClassHasBothPropertyAndIndexer = ts.forEach(getBaseTypes(containingType), function (base) { return getPropertyOfObjectType(base, prop.escapedName) && getIndexTypeOfType(base, indexKind); }); - errorNode = someBaseClassHasBothPropertyAndIndexer ? undefined : containingType.symbol.declarations[0]; + errorNode = someBaseClassHasBothPropertyAndIndexer || !containingType.symbol.declarations ? undefined : containingType.symbol.declarations[0]; } if (errorNode && !isTypeAssignableTo(propertyType, indexType)) { var errorMessage = indexKind === 0 /* String */ @@ -76074,6 +78799,7 @@ var ts; switch (name.escapedText) { case "any": case "unknown": + case "never": case "number": case "bigint": case "boolean": @@ -76123,7 +78849,7 @@ var ts; function checkTypeParametersNotReferenced(root, typeParameters, index) { visit(root); function visit(node) { - if (node.kind === 173 /* TypeReference */) { + if (node.kind === 175 /* TypeReference */) { var type = getTypeFromTypeReference(node); if (type.flags & 262144 /* TypeParameter */) { for (var i = index; i < typeParameters.length; i++) { @@ -76138,14 +78864,14 @@ var ts; } /** Check that type parameter lists are identical across multiple declarations */ function checkTypeParameterListsIdentical(symbol) { - if (symbol.declarations.length === 1) { + if (symbol.declarations && symbol.declarations.length === 1) { return; } var links = getSymbolLinks(symbol); if (!links.typeParametersChecked) { links.typeParametersChecked = true; var declarations = getClassOrInterfaceDeclarationsOfSymbol(symbol); - if (declarations.length <= 1) { + if (!declarations || declarations.length <= 1) { return; } var type = getDeclaredTypeOfSymbol(symbol); @@ -76209,6 +78935,9 @@ var ts; registerForUnusedIdentifiersCheck(node); } function checkClassDeclaration(node) { + if (ts.some(node.decorators) && ts.some(node.members, function (p) { return ts.hasStaticModifier(p) && ts.isPrivateIdentifierClassElementDeclaration(p); })) { + grammarErrorOnNode(node.decorators[0], 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 */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } @@ -76237,7 +78966,8 @@ var ts; checkFunctionOrConstructorSymbol(symbol); checkClassForDuplicateDeclarations(node); // Only check for reserved static identifiers on non-ambient context. - if (!(node.flags & 8388608 /* Ambient */)) { + var nodeInAmbientContext = !!(node.flags & 8388608 /* Ambient */); + if (!nodeInAmbientContext) { checkClassForStaticPropertyNameConflicts(node); } var baseTypeNode = ts.getEffectiveBaseTypeNode(node); @@ -76297,6 +79027,7 @@ var ts; checkKindsOfPropertyMemberOverrides(type, baseType_1); } } + checkMembersForMissingOverrideModifier(node, type, typeWithThis, staticType); var implementedTypeNodes = ts.getEffectiveImplementsTypeNodes(node); if (implementedTypeNodes) { for (var _b = 0, implementedTypeNodes_1 = implementedTypeNodes; _b < implementedTypeNodes_1.length; _b++) { @@ -76326,14 +79057,79 @@ var ts; } if (produceDiagnostics) { checkIndexConstraints(type); + checkIndexConstraints(staticType, /*isStatic*/ true); checkTypeForDuplicateIndexSignatures(node); checkPropertyInitialization(node); } } + function checkMembersForMissingOverrideModifier(node, type, typeWithThis, staticType) { + var nodeInAmbientContext = !!(node.flags & 8388608 /* Ambient */); + var baseTypeNode = ts.getEffectiveBaseTypeNode(node); + 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_24 = function (member) { + if (ts.hasAmbientModifier(member)) { + return "continue"; + } + if (ts.isConstructorDeclaration(member)) { + ts.forEach(member.parameters, function (param) { + if (ts.isParameterPropertyDeclaration(param, member)) { + checkClassMember(param, /*memberIsParameterProperty*/ true); + } + }); + } + checkClassMember(member); + }; + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + _loop_24(member); + } + function checkClassMember(member, memberIsParameterProperty) { + var hasOverride = ts.hasOverrideModifier(member); + var hasStatic = ts.hasStaticModifier(member); + if (baseWithThis && (hasOverride || compilerOptions.noImplicitOverride)) { + var declaredProp = member.name && getSymbolAtLocation(member.name) || getSymbolAtLocation(member); + if (!declaredProp) { + return; + } + var thisType = hasStatic ? staticType : typeWithThis; + var baseType = hasStatic ? baseStaticType : baseWithThis; + var prop = getPropertyOfType(thisType, declaredProp.escapedName); + var baseProp = getPropertyOfType(baseType, declaredProp.escapedName); + var baseClassName = typeToString(baseWithThis); + if (prop && !baseProp && hasOverride) { + var suggestion = getSpellingSuggestionForName(ts.symbolName(declaredProp), ts.arrayFrom(getMembersOfSymbol(baseType.symbol).values()), 106500 /* ClassMember */); + suggestion ? + error(member, ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1, baseClassName, symbolToString(suggestion)) : + error(member, ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0, baseClassName); + } + else if (prop && (baseProp === null || baseProp === void 0 ? void 0 : baseProp.valueDeclaration) && compilerOptions.noImplicitOverride && !nodeInAmbientContext) { + var baseHasAbstract = ts.hasAbstractModifier(baseProp.valueDeclaration); + if (hasOverride) { + return; + } + if (!baseHasAbstract) { + var diag = memberIsParameterProperty ? + ts.Diagnostics.This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0 : + ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0; + error(member, diag, baseClassName); + } + else if (ts.hasAbstractModifier(member) && baseHasAbstract) { + error(member, ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0, baseClassName); + } + } + } + else if (hasOverride) { + var className = typeToString(type); + error(member, ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class, className); + } + } + } 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_23 = function (member) { + var _loop_25 = function (member) { if (ts.hasStaticModifier(member)) { return "continue"; } @@ -76352,7 +79148,7 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_23(member); + _loop_25(member); } if (!issuedMemberError) { // check again with diagnostics to generate a less-specific error @@ -76378,7 +79174,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 252 /* ClassDeclaration */ || d.kind === 253 /* InterfaceDeclaration */; + return d.kind === 254 /* ClassDeclaration */ || d.kind === 255 /* InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -76395,6 +79191,7 @@ var ts; // but not by other kinds of members. // Base class instance member variables and accessors can be overridden by // derived class instance member variables and accessors, but not by other kinds of members. + var _a, _b; // NOTE: assignability is checked in checkClassDeclaration var baseProperties = getPropertiesOfType(baseType); basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { @@ -76423,8 +79220,8 @@ var ts; // 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.) - for (var _a = 0, _b = getBaseTypes(type); _a < _b.length; _a++) { - var otherBaseType = _b[_a]; + for (var _c = 0, _d = getBaseTypes(type); _c < _d.length; _c++) { + var otherBaseType = _d[_c]; if (otherBaseType === baseType) continue; var baseSymbol_1 = getPropertyOfObjectType(otherBaseType, base.escapedName); @@ -76433,7 +79230,7 @@ var ts; continue basePropertyCheck; } } - if (derivedClassDecl.kind === 221 /* ClassExpression */) { + if (derivedClassDecl.kind === 223 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -76454,7 +79251,7 @@ var ts; if (basePropertyFlags && derivedPropertyFlags) { // property/accessor is overridden with property/accessor if (baseDeclarationFlags & 128 /* Abstract */ && !(base.valueDeclaration && ts.isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer) - || base.valueDeclaration && base.valueDeclaration.parent.kind === 253 /* InterfaceDeclaration */ + || base.valueDeclaration && base.valueDeclaration.parent.kind === 255 /* InterfaceDeclaration */ || derived.valueDeclaration && ts.isBinaryExpression(derived.valueDeclaration)) { // when the base property is abstract or from an interface, base/derived flags don't need to match // same when the derived property is from an assignment @@ -76468,13 +79265,13 @@ var ts; ts.Diagnostics._0_is_defined_as_a_property_in_class_1_but_is_overridden_here_in_2_as_an_accessor; error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_1, symbolToString(base), typeToString(baseType), typeToString(type)); } - else if (compilerOptions.useDefineForClassFields) { - var uninitialized = ts.find(derived.declarations, function (d) { return d.kind === 163 /* PropertyDeclaration */ && !d.initializer; }); + else if (useDefineForClassFields) { + var uninitialized = (_a = derived.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 165 /* PropertyDeclaration */ && !d.initializer; }); if (uninitialized && !(derived.flags & 33554432 /* Transient */) && !(baseDeclarationFlags & 128 /* Abstract */) && !(derivedDeclarationFlags & 128 /* Abstract */) - && !derived.declarations.some(function (d) { return !!(d.flags & 8388608 /* Ambient */); })) { + && !((_b = derived.declarations) === null || _b === void 0 ? void 0 : _b.some(function (d) { return !!(d.flags & 8388608 /* Ambient */); }))) { var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol)); var propName = uninitialized.name; if (uninitialized.exclamationToken @@ -76585,7 +79382,7 @@ var ts; } } function isInstancePropertyWithoutInitializer(node) { - return node.kind === 163 /* PropertyDeclaration */ && + return node.kind === 165 /* PropertyDeclaration */ && !ts.hasSyntacticModifier(node, 32 /* Static */ | 128 /* Abstract */) && !node.exclamationToken && !node.initializer; @@ -76609,7 +79406,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 253 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 255 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -76642,7 +79439,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0); checkExportsOnMergedDeclarations(node); checkTypeParameters(node.typeParameters); - if (node.type.kind === 136 /* IntrinsicKeyword */) { + if (node.type.kind === 137 /* 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); } @@ -76728,7 +79525,7 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { @@ -76738,7 +79535,7 @@ var ts; } } break; - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { @@ -76767,22 +79564,22 @@ var ts; case 8 /* NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return evaluate(expr.expression); - case 78 /* Identifier */: + case 79 /* Identifier */: var identifier = expr; if (isInfinityOrNaNString(identifier.escapedText)) { return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 202 /* ElementAccessExpression */: - case 201 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: var ex = expr; if (isConstantMemberAccess(ex)) { var type = getTypeOfExpression(ex.expression); if (type.symbol && type.symbol.flags & 384 /* Enum */) { var name = void 0; - if (ex.kind === 201 /* PropertyAccessExpression */) { + if (ex.kind === 203 /* PropertyAccessExpression */) { name = ex.name.escapedText; } else { @@ -76800,7 +79597,7 @@ var ts; if (memberSymbol) { var declaration = memberSymbol.valueDeclaration; if (declaration !== member) { - if (isBlockScopedNameDeclaredBeforeUse(declaration, member)) { + if (declaration && isBlockScopedNameDeclaredBeforeUse(declaration, member)) { return getEnumMemberValue(declaration); } error(expr, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums); @@ -76814,9 +79611,9 @@ var ts; } } function isConstantMemberAccess(node) { - return node.kind === 78 /* Identifier */ || - node.kind === 201 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 202 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + return node.kind === 79 /* Identifier */ || + node.kind === 203 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 204 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && ts.isStringLiteralLike(node.argumentExpression); } function checkEnumDeclaration(node) { @@ -76840,7 +79637,7 @@ var ts; var enumSymbol = getSymbolOfNode(node); var firstDeclaration = ts.getDeclarationOfKind(enumSymbol, node.kind); if (node === firstDeclaration) { - if (enumSymbol.declarations.length > 1) { + if (enumSymbol.declarations && enumSymbol.declarations.length > 1) { var enumIsConst_1 = ts.isEnumConst(node); // check that const is placed\omitted on all enum declarations ts.forEach(enumSymbol.declarations, function (decl) { @@ -76852,7 +79649,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 !== 255 /* EnumDeclaration */) { + if (declaration.kind !== 257 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -76878,12 +79675,14 @@ var ts; } function getFirstNonAmbientClassOrFunctionDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { - var declaration = declarations_8[_i]; - if ((declaration.kind === 252 /* ClassDeclaration */ || - (declaration.kind === 251 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && - !(declaration.flags & 8388608 /* Ambient */)) { - return declaration; + if (declarations) { + for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { + var declaration = declarations_8[_i]; + if ((declaration.kind === 254 /* ClassDeclaration */ || + (declaration.kind === 253 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + !(declaration.flags & 8388608 /* Ambient */)) { + return declaration; + } } } return undefined; @@ -76931,8 +79730,9 @@ var ts; // The following checks only apply on a non-ambient instantiated module declaration. if (symbol.flags & 512 /* ValueModule */ && !inAmbientContext + && symbol.declarations && symbol.declarations.length > 1 - && isInstantiatedModule(node, !!compilerOptions.preserveConstEnums || !!compilerOptions.isolatedModules)) { + && isInstantiatedModule(node, ts.shouldPreserveConstEnums(compilerOptions))) { var firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol); if (firstNonAmbientClassOrFunc) { if (ts.getSourceFileOfNode(node) !== ts.getSourceFileOfNode(firstNonAmbientClassOrFunc)) { @@ -76944,7 +79744,7 @@ 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, 252 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 254 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -76993,40 +79793,41 @@ var ts; } } function checkModuleAugmentationElement(node, isGlobalAugmentation) { + var _a; switch (node.kind) { - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: // error each individual name in variable statement instead of marking the entire variable statement - for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; + for (var _i = 0, _b = node.declarationList.declarations; _i < _b.length; _i++) { + var decl = _b[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 266 /* ExportAssignment */: - case 267 /* ExportDeclaration */: + case 268 /* ExportAssignment */: + case 269 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 260 /* ImportEqualsDeclaration */: - case 261 /* ImportDeclaration */: + case 262 /* ImportEqualsDeclaration */: + case 263 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 198 /* BindingElement */: - case 249 /* VariableDeclaration */: + case 200 /* BindingElement */: + case 251 /* VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { - for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { - var el = _c[_b]; + for (var _c = 0, _d = name.elements; _c < _d.length; _c++) { + var el = _d[_c]; // mark individual names in binding pattern checkModuleAugmentationElement(el, isGlobalAugmentation); } break; } // falls through - case 252 /* ClassDeclaration */: - case 255 /* EnumDeclaration */: - case 251 /* FunctionDeclaration */: - case 253 /* InterfaceDeclaration */: - case 256 /* ModuleDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 254 /* ClassDeclaration */: + case 257 /* EnumDeclaration */: + case 253 /* FunctionDeclaration */: + case 255 /* InterfaceDeclaration */: + case 258 /* ModuleDeclaration */: + case 256 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -77039,7 +79840,7 @@ var ts; var reportError = !(symbol.flags & 33554432 /* Transient */); if (!reportError) { // symbol should not originate in augmentation - reportError = !!symbol.parent && ts.isExternalModuleAugmentation(symbol.parent.declarations[0]); + reportError = !!((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.declarations) && ts.isExternalModuleAugmentation(symbol.parent.declarations[0]); } } break; @@ -77047,20 +79848,20 @@ var ts; } function getFirstNonModuleExportsIdentifier(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return node; - case 157 /* QualifiedName */: + case 159 /* QualifiedName */: do { node = node.left; - } while (node.kind !== 78 /* Identifier */); + } while (node.kind !== 79 /* Identifier */); return node; - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: do { if (ts.isModuleExportsAccessExpression(node.expression) && !ts.isPrivateIdentifier(node.name)) { return node.name; } node = node.expression; - } while (node.kind !== 78 /* Identifier */); + } while (node.kind !== 79 /* Identifier */); return node; } } @@ -77074,9 +79875,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 257 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 297 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 267 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 259 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 299 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 269 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -77096,6 +79897,7 @@ var ts; return true; } function checkAliasSymbol(node) { + var _a; var symbol = getSymbolOfNode(node); var target = resolveAlias(symbol); if (target !== unknownSymbol) { @@ -77110,21 +79912,21 @@ var ts; (symbol.flags & 788968 /* Type */ ? 788968 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 270 /* ExportSpecifier */ ? + var message = node.kind === 272 /* 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)); } // Don't allow to re-export something with no value side when `--isolatedModules` is set. if (compilerOptions.isolatedModules - && node.kind === 270 /* ExportSpecifier */ + && node.kind === 272 /* ExportSpecifier */ && !node.parent.parent.isTypeOnly && !(target.flags & 111551 /* Value */) && !(node.flags & 8388608 /* Ambient */)) { error(node, ts.Diagnostics.Re_exporting_a_type_when_the_isolatedModules_flag_is_provided_requires_using_export_type); } - if (ts.isImportSpecifier(node) && ts.every(target.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 134217728 /* Deprecated */); })) { - errorOrSuggestion(/* isError */ false, node.name, ts.Diagnostics._0_is_deprecated, symbol.escapedName); + if (ts.isImportSpecifier(node) && ((_a = target.declarations) === null || _a === void 0 ? void 0 : _a.every(function (d) { return !!(ts.getCombinedNodeFlags(d) & 134217728 /* Deprecated */); }))) { + addDeprecatedSuggestion(node.name, target.declarations, symbol.escapedName); } } } @@ -77132,7 +79934,7 @@ var ts; checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); checkAliasSymbol(node); - if (node.kind === 265 /* ImportSpecifier */ && + if (node.kind === 267 /* ImportSpecifier */ && ts.idText(node.propertyName || node.name) === "default" && compilerOptions.esModuleInterop && moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015) { @@ -77154,7 +79956,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 263 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 265 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); if (moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015 && compilerOptions.esModuleInterop) { // import * as ns from "foo"; @@ -77182,7 +79984,7 @@ var ts; if (ts.hasSyntacticModifier(node, 1 /* Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 272 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 274 /* ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { if (target.flags & 111551 /* Value */) { @@ -77225,10 +80027,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 257 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 257 /* ModuleBlock */ && + var inAmbientExternalModule = node.parent.kind === 259 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 259 /* ModuleBlock */ && !node.moduleSpecifier && node.flags & 8388608 /* Ambient */; - if (node.parent.kind !== 297 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 299 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -77261,14 +80063,14 @@ var ts; } function checkGrammarExportDeclaration(node) { var _a; - var isTypeOnlyExportStar = node.isTypeOnly && ((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) !== 268 /* NamedExports */; + var isTypeOnlyExportStar = node.isTypeOnly && ((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) !== 270 /* NamedExports */; if (isTypeOnlyExportStar) { grammarErrorOnNode(node, ts.Diagnostics.Only_named_exports_may_use_export_type); } return !isTypeOnlyExportStar; } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 297 /* SourceFile */ || node.parent.kind === 257 /* ModuleBlock */ || node.parent.kind === 256 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 299 /* SourceFile */ || node.parent.kind === 259 /* ModuleBlock */ || node.parent.kind === 258 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -77318,7 +80120,7 @@ var ts; // 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 */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); - if (symbol && (symbol === undefinedSymbol || symbol === globalThisSymbol || isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { + 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 { @@ -77339,12 +80141,15 @@ var ts; } } function checkExportAssignment(node) { - if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { + var illegalContextMessage = node.isExportEquals + ? ts.Diagnostics.An_export_assignment_must_be_at_the_top_level_of_a_file_or_module_declaration + : ts.Diagnostics.A_default_export_must_be_at_the_top_level_of_a_file_or_module_declaration; + if (checkGrammarModuleElementContext(node, illegalContextMessage)) { // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 297 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 256 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 299 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 258 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -77357,7 +80162,7 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasEffectiveModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 78 /* Identifier */) { + if (node.expression.kind === 79 /* Identifier */) { var id = node.expression; var sym = resolveEntityName(id, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node); if (sym) { @@ -77404,7 +80209,7 @@ var ts; var exportEqualsSymbol = moduleSymbol.exports.get("export="); if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) { var declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration; - if (!isTopLevelInExternalModuleAugmentation(declaration) && !ts.isInJSFile(declaration)) { + if (declaration && !isTopLevelInExternalModuleAugmentation(declaration) && !ts.isInJSFile(declaration)) { error(declaration, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); } } @@ -77428,10 +80233,12 @@ var ts; return; } if (exportedDeclarationsCount > 1) { - for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { - var declaration = declarations_9[_i]; - if (isNotOverload(declaration)) { - diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Cannot_redeclare_exported_variable_0, ts.unescapeLeadingUnderscores(id))); + if (!isDuplicatedCommonJSExport(declarations)) { + for (var _i = 0, _b = declarations; _i < _b.length; _i++) { + var declaration = _b[_i]; + if (isNotOverload(declaration)) { + diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Cannot_redeclare_exported_variable_0, ts.unescapeLeadingUnderscores(id))); + } } } } @@ -77440,6 +80247,11 @@ var ts; links.exportsChecked = true; } } + function isDuplicatedCommonJSExport(declarations) { + return declarations + && declarations.length > 1 + && declarations.every(function (d) { return ts.isInJSFile(d) && ts.isAccessExpression(d) && (ts.isExportsIdentifier(d.expression) || ts.isModuleExportsAccessExpression(d.expression)); }); + } function checkSourceElement(node) { if (node) { var saveCurrentNode = currentNode; @@ -77461,171 +80273,171 @@ 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 256 /* ModuleDeclaration */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 251 /* FunctionDeclaration */: + case 258 /* ModuleDeclaration */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 253 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } - if (kind >= 232 /* FirstStatement */ && kind <= 248 /* LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { + if (kind >= 234 /* FirstStatement */ && kind <= 250 /* LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { errorOrSuggestion(compilerOptions.allowUnreachableCode === false, node, ts.Diagnostics.Unreachable_code_detected); } switch (kind) { - case 159 /* TypeParameter */: + case 161 /* TypeParameter */: return checkTypeParameter(node); - case 160 /* Parameter */: + case 162 /* Parameter */: return checkParameter(node); - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return checkPropertyDeclaration(node); - case 162 /* PropertySignature */: + case 164 /* PropertySignature */: return checkPropertySignature(node); - case 175 /* ConstructorType */: - case 174 /* FunctionType */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: + case 177 /* ConstructorType */: + case 176 /* FunctionType */: + case 171 /* CallSignature */: + case 172 /* ConstructSignature */: + case 173 /* IndexSignature */: return checkSignatureDeclaration(node); - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: return checkMethodDeclaration(node); - case 166 /* Constructor */: + case 168 /* Constructor */: return checkConstructorDeclaration(node); - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return checkAccessorDeclaration(node); - case 173 /* TypeReference */: + case 175 /* TypeReference */: return checkTypeReferenceNode(node); - case 172 /* TypePredicate */: + case 174 /* TypePredicate */: return checkTypePredicate(node); - case 176 /* TypeQuery */: + case 178 /* TypeQuery */: return checkTypeQuery(node); - case 177 /* TypeLiteral */: + case 179 /* TypeLiteral */: return checkTypeLiteral(node); - case 178 /* ArrayType */: + case 180 /* ArrayType */: return checkArrayType(node); - case 179 /* TupleType */: + case 181 /* TupleType */: return checkTupleType(node); - case 182 /* UnionType */: - case 183 /* IntersectionType */: + case 184 /* UnionType */: + case 185 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 186 /* ParenthesizedType */: - case 180 /* OptionalType */: - case 181 /* RestType */: + case 188 /* ParenthesizedType */: + case 182 /* OptionalType */: + case 183 /* RestType */: return checkSourceElement(node.type); - case 187 /* ThisType */: + case 189 /* ThisType */: return checkThisType(node); - case 188 /* TypeOperator */: + case 190 /* TypeOperator */: return checkTypeOperator(node); - case 184 /* ConditionalType */: + case 186 /* ConditionalType */: return checkConditionalType(node); - case 185 /* InferType */: + case 187 /* InferType */: return checkInferType(node); - case 193 /* TemplateLiteralType */: + case 195 /* TemplateLiteralType */: return checkTemplateLiteralType(node); - case 195 /* ImportType */: + case 197 /* ImportType */: return checkImportType(node); - case 192 /* NamedTupleMember */: + case 194 /* NamedTupleMember */: return checkNamedTupleMember(node); - case 315 /* JSDocAugmentsTag */: + case 322 /* JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 316 /* JSDocImplementsTag */: + case 323 /* JSDocImplementsTag */: return checkJSDocImplementsTag(node); - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 325 /* JSDocEnumTag */: + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + case 333 /* JSDocEnumTag */: return checkJSDocTypeAliasTag(node); - case 330 /* JSDocTemplateTag */: + case 338 /* JSDocTemplateTag */: return checkJSDocTemplateTag(node); - case 329 /* JSDocTypeTag */: + case 337 /* JSDocTypeTag */: return checkJSDocTypeTag(node); - case 326 /* JSDocParameterTag */: + case 334 /* JSDocParameterTag */: return checkJSDocParameterTag(node); - case 333 /* JSDocPropertyTag */: + case 341 /* JSDocPropertyTag */: return checkJSDocPropertyTag(node); - case 308 /* JSDocFunctionType */: + case 311 /* JSDocFunctionType */: checkJSDocFunctionType(node); // falls through - case 306 /* JSDocNonNullableType */: - case 305 /* JSDocNullableType */: - case 303 /* JSDocAllType */: - case 304 /* JSDocUnknownType */: - case 312 /* JSDocTypeLiteral */: + case 309 /* JSDocNonNullableType */: + case 308 /* JSDocNullableType */: + case 306 /* JSDocAllType */: + case 307 /* JSDocUnknownType */: + case 316 /* JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 309 /* JSDocVariadicType */: + case 312 /* JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 301 /* JSDocTypeExpression */: + case 303 /* JSDocTypeExpression */: return checkSourceElement(node.type); - case 189 /* IndexedAccessType */: + case 191 /* IndexedAccessType */: return checkIndexedAccessType(node); - case 190 /* MappedType */: + case 192 /* MappedType */: return checkMappedType(node); - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 230 /* Block */: - case 257 /* ModuleBlock */: + case 232 /* Block */: + case 259 /* ModuleBlock */: return checkBlock(node); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return checkVariableStatement(node); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: return checkExpressionStatement(node); - case 234 /* IfStatement */: + case 236 /* IfStatement */: return checkIfStatement(node); - case 235 /* DoStatement */: + case 237 /* DoStatement */: return checkDoStatement(node); - case 236 /* WhileStatement */: + case 238 /* WhileStatement */: return checkWhileStatement(node); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return checkForStatement(node); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return checkForInStatement(node); - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: return checkForOfStatement(node); - case 240 /* ContinueStatement */: - case 241 /* BreakStatement */: + case 242 /* ContinueStatement */: + case 243 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: return checkReturnStatement(node); - case 243 /* WithStatement */: + case 245 /* WithStatement */: return checkWithStatement(node); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: return checkSwitchStatement(node); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return checkLabeledStatement(node); - case 246 /* ThrowStatement */: + case 248 /* ThrowStatement */: return checkThrowStatement(node); - case 247 /* TryStatement */: + case 249 /* TryStatement */: return checkTryStatement(node); - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 198 /* BindingElement */: + case 200 /* BindingElement */: return checkBindingElement(node); - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: return checkClassDeclaration(node); - case 253 /* InterfaceDeclaration */: + case 255 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return checkImportDeclaration(node); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: return checkExportDeclaration(node); - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return checkExportAssignment(node); - case 231 /* EmptyStatement */: - case 248 /* DebuggerStatement */: + case 233 /* EmptyStatement */: + case 250 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 271 /* MissingDeclaration */: + case 273 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -77670,7 +80482,8 @@ var ts; if (ts.isJSDocTypeExpression(node.parent) && ts.isJSDocParameterTag(paramTag)) { // Else we will add a diagnostic, see `checkJSDocVariadicType`. var host_1 = ts.getHostSignatureFromJSDoc(paramTag); - if (host_1) { + var isCallbackTag = ts.isJSDocCallbackTag(paramTag.parent.parent); + if (host_1 || isCallbackTag) { /* Only return an array type if the corresponding parameter is marked as a rest parameter, or if there are no parameters. So in the following situation we will not create an array type: @@ -77678,7 +80491,9 @@ var ts; function f(a) {} Because `a` will just be of type `number | undefined`. A synthetic `...args` will also be added, which *will* get an array type. */ - var lastParamDeclaration = ts.lastOrUndefined(host_1.parameters); + var lastParamDeclaration = isCallbackTag + ? ts.lastOrUndefined(paramTag.parent.parent.typeExpression.parameters) + : ts.lastOrUndefined(host_1.parameters); var symbol = ts.getParameterSymbolFromJSDoc(paramTag); if (!lastParamDeclaration || symbol && lastParamDeclaration.symbol === symbol && ts.isRestParameter(lastParamDeclaration)) { @@ -77716,51 +80531,51 @@ var ts; } } function checkDeferredNode(node) { - ts.tracing.push("check" /* Check */, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end }); var saveCurrentNode = currentNode; currentNode = node; instantiationCount = 0; switch (node.kind) { - case 203 /* CallExpression */: - case 204 /* NewExpression */: - case 205 /* TaggedTemplateExpression */: - case 161 /* Decorator */: - case 275 /* JsxOpeningElement */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: + case 207 /* TaggedTemplateExpression */: + case 163 /* Decorator */: + case 277 /* 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 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: checkAccessorDeclaration(node); break; - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: checkClassExpressionDeferred(node); break; - case 274 /* JsxSelfClosingElement */: + case 276 /* JsxSelfClosingElement */: checkJsxSelfClosingElementDeferred(node); break; - case 273 /* JsxElement */: + case 275 /* JsxElement */: checkJsxElementDeferred(node); break; } currentNode = saveCurrentNode; - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } function checkSourceFile(node) { - ts.tracing.push("check" /* Check */, "checkSourceFile", { path: node.path }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkSourceFile", { path: node.path }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeCheck"); checkSourceFileWorker(node); ts.performance.mark("afterCheck"); ts.performance.measure("Check", "beforeCheck", "afterCheck"); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } function unusedIsError(kind, isAmbient) { if (isAmbient) { @@ -77789,7 +80604,7 @@ var ts; checkGrammarSourceFile(node); ts.clear(potentialThisCollisions); ts.clear(potentialNewTargetCollisions); - ts.clear(potentialWeakMapCollisions); + ts.clear(potentialWeakMapSetCollisions); ts.forEach(node.statements, checkSourceElement); checkSourceElement(node.endOfFileToken); checkDeferredNodes(node); @@ -77819,9 +80634,9 @@ var ts; ts.forEach(potentialNewTargetCollisions, checkIfNewTargetIsCapturedInEnclosingScope); ts.clear(potentialNewTargetCollisions); } - if (potentialWeakMapCollisions.length) { - ts.forEach(potentialWeakMapCollisions, checkWeakMapCollision); - ts.clear(potentialWeakMapCollisions); + if (potentialWeakMapSetCollisions.length) { + ts.forEach(potentialWeakMapSetCollisions, checkWeakMapSetCollision); + ts.clear(potentialWeakMapSetCollisions); } links.flags |= 1 /* TypeChecked */; } @@ -77893,17 +80708,17 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 297 /* SourceFile */: - if (!ts.isExternalOrCommonJsModule(location)) + case 299 /* SourceFile */: + if (!ts.isExternalModule(location)) break; // falls through - case 256 /* ModuleDeclaration */: - copySymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); + case 258 /* ModuleDeclaration */: + copyLocallyVisibleExportSymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); break; - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); @@ -77911,8 +80726,8 @@ 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 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: + case 254 /* ClassDeclaration */: + case 255 /* 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. @@ -77921,7 +80736,7 @@ var ts; copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* Type */); } break; - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -77961,27 +80776,37 @@ var ts; }); } } + function copyLocallyVisibleExportSymbols(source, meaning) { + if (meaning) { + source.forEach(function (symbol) { + // Similar condition as in `resolveNameHelper` + if (!ts.getDeclarationOfKind(symbol, 272 /* ExportSpecifier */) && !ts.getDeclarationOfKind(symbol, 271 /* NamespaceExport */)) { + copySymbol(symbol, meaning); + } + }); + } + } } function isTypeDeclarationName(name) { - return name.kind === 78 /* Identifier */ && + return name.kind === 79 /* Identifier */ && isTypeDeclaration(name.parent) && ts.getNameOfDeclaration(name.parent) === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 159 /* TypeParameter */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 255 /* EnumDeclaration */: - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 325 /* JSDocEnumTag */: + case 161 /* TypeParameter */: + case 254 /* ClassDeclaration */: + case 255 /* InterfaceDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 257 /* EnumDeclaration */: + case 339 /* JSDocTypedefTag */: + case 332 /* JSDocCallbackTag */: + case 333 /* JSDocEnumTag */: return true; - case 262 /* ImportClause */: + case 264 /* ImportClause */: return node.isTypeOnly; - case 265 /* ImportSpecifier */: - case 270 /* ExportSpecifier */: + case 267 /* ImportSpecifier */: + case 272 /* ExportSpecifier */: return node.parent.parent.isTypeOnly; default: return false; @@ -77989,25 +80814,16 @@ var ts; } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(node) { - while (node.parent.kind === 157 /* QualifiedName */) { + while (node.parent.kind === 159 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 173 /* TypeReference */; + return node.parent.kind === 175 /* TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 201 /* PropertyAccessExpression */) { + while (node.parent.kind === 203 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent.kind === 223 /* ExpressionWithTypeArguments */; - } - function isJSDocEntryNameReference(node) { - while (node.parent.kind === 157 /* QualifiedName */) { - node = node.parent; - } - while (node.parent.kind === 201 /* PropertyAccessExpression */) { - node = node.parent; - } - return node.parent.kind === 302 /* JSDocNameReference */; + return node.parent.kind === 225 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -78035,13 +80851,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 157 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 159 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 260 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 262 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 266 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 268 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -78067,7 +80883,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 195 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 197 /* ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -78077,17 +80893,17 @@ var ts; return getSymbolOfNode(name.parent); } if (ts.isInJSFile(name) && - name.parent.kind === 201 /* PropertyAccessExpression */ && + name.parent.kind === 203 /* PropertyAccessExpression */ && name.parent === name.parent.parent.left) { // Check if this is a special property assignment - if (!ts.isPrivateIdentifier(name)) { + if (!ts.isPrivateIdentifier(name) && !ts.isJSDocMemberName(name)) { var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(name); if (specialPropertyAssignmentSymbol) { return specialPropertyAssignmentSymbol; } } } - if (name.parent.kind === 266 /* ExportAssignment */ && ts.isEntityNameExpression(name)) { + if (name.parent.kind === 268 /* 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); @@ -78095,13 +80911,13 @@ var ts; return success; } } - else if (!ts.isPropertyAccessExpression(name) && !ts.isPrivateIdentifier(name) && isInRightSideOfImportOrExportAssignment(name)) { + 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, 260 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(name, 262 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(name, /*dontResolveAlias*/ true); } - if (!ts.isPropertyAccessExpression(name) && !ts.isPrivateIdentifier(name)) { + if (ts.isEntityName(name)) { var possibleImportNode = isImportTypeQualifierPart(name); if (possibleImportNode) { getTypeFromTypeNode(possibleImportNode); @@ -78109,13 +80925,13 @@ var ts; return sym === unknownSymbol ? undefined : sym; } } - while (ts.isRightSideOfQualifiedNameOrPropertyAccess(name)) { + while (ts.isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName(name)) { name = name.parent; } if (isHeritageClauseElementIdentifier(name)) { var meaning = 0 /* None */; // In an interface or class, we're definitely interested in a type. - if (name.parent.kind === 223 /* ExpressionWithTypeArguments */) { + if (name.parent.kind === 225 /* ExpressionWithTypeArguments */) { meaning = 788968 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(name.parent)) { @@ -78131,10 +80947,10 @@ var ts; return entityNameSymbol; } } - if (name.parent.kind === 326 /* JSDocParameterTag */) { + if (name.parent.kind === 334 /* JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(name.parent); } - if (name.parent.kind === 159 /* TypeParameter */ && name.parent.parent.kind === 330 /* JSDocTemplateTag */) { + if (name.parent.kind === 161 /* TypeParameter */ && name.parent.parent.kind === 338 /* JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJSFile(name)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(name.parent); return typeParameter && typeParameter.symbol; @@ -78144,43 +80960,81 @@ var ts; // Missing entity name. return undefined; } - if (name.kind === 78 /* Identifier */) { + 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 */) { if (ts.isJSXTagName(name) && isJsxIntrinsicIdentifier(name)) { var symbol = getIntrinsicTagSymbol(name.parent); return symbol === unknownSymbol ? undefined : symbol; } - return resolveEntityName(name, 111551 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); + var result = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ !isJSDoc_1, ts.getHostSignatureFromJSDoc(name)); + if (!result && isJSDoc_1) { + var container = ts.findAncestor(name, ts.or(ts.isClassLike, ts.isInterfaceDeclaration)); + if (container) { + return resolveJSDocMemberName(name, getSymbolOfNode(container)); + } + } + return result; } - else if (name.kind === 201 /* PropertyAccessExpression */ || name.kind === 157 /* QualifiedName */) { + else if (name.kind === 203 /* PropertyAccessExpression */ || name.kind === 159 /* QualifiedName */) { var links = getNodeLinks(name); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (name.kind === 201 /* PropertyAccessExpression */) { - checkPropertyAccessExpression(name); + if (name.kind === 203 /* PropertyAccessExpression */) { + checkPropertyAccessExpression(name, 0 /* Normal */); } else { - checkQualifiedName(name); + checkQualifiedName(name, 0 /* Normal */); + } + if (!links.resolvedSymbol && isJSDoc_1 && ts.isQualifiedName(name)) { + return resolveJSDocMemberName(name); } return links.resolvedSymbol; } + else if (ts.isJSDocMemberName(name)) { + return resolveJSDocMemberName(name); + } } else if (isTypeReferenceIdentifier(name)) { - var meaning = name.parent.kind === 173 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; + var meaning = name.parent.kind === 175 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; return resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (isJSDocEntryNameReference(name)) { - var meaning = 788968 /* Type */ | 1920 /* Namespace */ | 111551 /* Value */; - return resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true, ts.getHostSignatureFromJSDoc(name)); - } - if (name.parent.kind === 172 /* TypePredicate */) { + if (name.parent.kind === 174 /* TypePredicate */) { return resolveEntityName(name, /*meaning*/ 1 /* FunctionScopedVariable */); } - // Do we want to return undefined here? return undefined; } + /** + * Recursively resolve entity names and jsdoc instance references: + * 1. K#m as K.prototype.m for a class (or other value) K + * 2. K.m as K.prototype.m + * 3. I.m as I.m for a type I, or any other I.m that fails to resolve in (1) or (2) + * + * For unqualified names, a container K may be provided as a second argument. + */ + function resolveJSDocMemberName(name, container) { + if (ts.isEntityName(name)) { + // resolve static values first + var meaning = 788968 /* Type */ | 1920 /* Namespace */ | 111551 /* Value */; + var symbol = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true, ts.getHostSignatureFromJSDoc(name)); + if (!symbol && ts.isIdentifier(name) && container) { + symbol = getMergedSymbol(getSymbol(getExportsOfSymbol(container), name.escapedText, meaning)); + } + if (symbol) { + return symbol; + } + } + var left = ts.isIdentifier(name) ? container : resolveJSDocMemberName(name.left); + var right = ts.isIdentifier(name) ? name.escapedText : name.right.escapedText; + if (left) { + var proto = left.flags & 111551 /* Value */ && getPropertyOfType(getTypeOfSymbol(left), "prototype"); + var t = proto ? getTypeOfSymbol(proto) : getDeclaredTypeOfSymbol(left); + return getPropertyOfType(t, right); + } + } function getSymbolAtLocation(node, ignoreErrors) { - if (node.kind === 297 /* SourceFile */) { + if (node.kind === 299 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; @@ -78199,12 +81053,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(parent.parent); } - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfNameOrPropertyAccessExpression(node); } - else if (parent.kind === 198 /* BindingElement */ && - grandParent.kind === 196 /* ObjectBindingPattern */ && + else if (parent.kind === 200 /* BindingElement */ && + grandParent.kind === 198 /* ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText); @@ -78214,12 +81068,12 @@ var ts; } } switch (node.kind) { - case 78 /* Identifier */: - case 79 /* PrivateIdentifier */: - case 201 /* PropertyAccessExpression */: - case 157 /* QualifiedName */: + case 79 /* Identifier */: + case 80 /* PrivateIdentifier */: + case 203 /* PropertyAccessExpression */: + case 159 /* QualifiedName */: return getSymbolOfNameOrPropertyAccessExpression(node); - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -78231,14 +81085,14 @@ var ts; return checkExpression(node).symbol; } // falls through - case 187 /* ThisType */: + case 189 /* ThisType */: return getTypeFromThisTypeNode(node).symbol; - case 105 /* SuperKeyword */: + case 106 /* SuperKeyword */: return checkExpression(node).symbol; - case 132 /* ConstructorKeyword */: + case 133 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 166 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 168 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -78249,7 +81103,7 @@ var ts; // 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 === 261 /* ImportDeclaration */ || node.parent.kind === 267 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 263 /* ImportDeclaration */ || node.parent.kind === 269 /* 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); @@ -78266,21 +81120,21 @@ var ts; ? getTypeFromTypeNode(grandParent.objectType) : undefined; return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text)); - case 87 /* DefaultKeyword */: - case 97 /* FunctionKeyword */: + case 88 /* DefaultKeyword */: + case 98 /* FunctionKeyword */: case 38 /* EqualsGreaterThanToken */: - case 83 /* ClassKeyword */: + case 84 /* ClassKeyword */: return getSymbolOfNode(node.parent); - case 195 /* ImportType */: + case 197 /* ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal, ignoreErrors) : undefined; - case 92 /* ExportKeyword */: + case 93 /* ExportKeyword */: return ts.isExportAssignment(node.parent) ? ts.Debug.checkDefined(node.parent.symbol) : undefined; default: return undefined; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 289 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 291 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 111551 /* Value */ | 2097152 /* Alias */); } return undefined; @@ -78359,27 +81213,27 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfAssignmentPattern(expr) { - ts.Debug.assert(expr.kind === 200 /* ObjectLiteralExpression */ || expr.kind === 199 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 202 /* ObjectLiteralExpression */ || expr.kind === 201 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 239 /* ForOfStatement */) { + if (expr.parent.kind === 241 /* 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 === 216 /* BinaryExpression */) { + if (expr.parent.kind === 218 /* 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 === 288 /* PropertyAssignment */) { - var node_2 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); - var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_2) || errorType; - var propertyIndex = ts.indexOfNode(node_2.properties, expr.parent); - return checkObjectLiteralDestructuringPropertyAssignment(node_2, typeOfParentObjectLiteral, propertyIndex); + if (expr.parent.kind === 290 /* 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); + return checkObjectLiteralDestructuringPropertyAssignment(node_3, typeOfParentObjectLiteral, propertyIndex); } // Array literal assignment - array destructuring pattern var node = ts.cast(expr.parent, ts.isArrayLiteralExpression); @@ -78418,12 +81272,12 @@ var ts; function getClassElementPropertyKeyType(element) { var name = element.name; switch (name.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return getLiteralType(ts.idText(name)); case 8 /* NumericLiteral */: case 10 /* StringLiteral */: return getLiteralType(name.text); - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(name); return isTypeAssignableToKind(nameType, 12288 /* ESSymbolLike */) ? nameType : stringType; default: @@ -78520,6 +81374,7 @@ var ts; // When resolved as an expression identifier, if the given node references an exported entity, return the declaration // node of the exported entity's container. Otherwise, return undefined. function getReferencedExportContainer(nodeIn, prefixLocals) { + var _a; var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { // When resolving the export container for the name of a module or enum @@ -78540,7 +81395,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 297 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && ((_a = parentSymbol_1.valueDeclaration) === null || _a === void 0 ? void 0 : _a.kind) === 299 /* 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. @@ -78570,11 +81425,12 @@ var ts; return undefined; } function isSymbolOfDestructuredElementOfCatchBinding(symbol) { - return ts.isBindingElement(symbol.valueDeclaration) - && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 287 /* CatchClause */; + return symbol.valueDeclaration + && ts.isBindingElement(symbol.valueDeclaration) + && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 289 /* CatchClause */; } function isSymbolOfDeclarationWithCollidingName(symbol) { - if (symbol.flags & 418 /* BlockScoped */ && !ts.isSourceFile(symbol.valueDeclaration)) { + if (symbol.flags & 418 /* BlockScoped */ && symbol.valueDeclaration && !ts.isSourceFile(symbol.valueDeclaration)) { var links = getSymbolLinks(symbol); if (links.isDeclarationWithCollidingName === undefined) { var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); @@ -78602,7 +81458,7 @@ var ts; // they will not collide with anything var isDeclaredInLoop = nodeLinks_1.flags & 524288 /* BlockScopedBindingInLoop */; var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false); - var inLoopBodyBlock = container.kind === 230 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 232 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -78643,20 +81499,20 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 262 /* ImportClause */: - case 263 /* NamespaceImport */: - case 265 /* ImportSpecifier */: - case 270 /* ExportSpecifier */: + case 264 /* ImportClause */: + case 265 /* NamespaceImport */: + case 267 /* ImportSpecifier */: + case 272 /* ExportSpecifier */: var symbol = getSymbolOfNode(node) || unknownSymbol; return isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && (ts.isNamespaceExport(exportClause) || ts.some(exportClause.elements, isValueAliasDeclaration)); - case 266 /* ExportAssignment */: - return node.expression && node.expression.kind === 78 /* Identifier */ ? + case 268 /* ExportAssignment */: + return node.expression && node.expression.kind === 79 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : true; } @@ -78664,7 +81520,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 297 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 299 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -78679,7 +81535,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 */) && - (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target)); + (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target)); } function isConstEnumOrConstEnumOnlyModule(s) { return isConstEnumSymbol(s) || !!s.constEnumOnlyModule; @@ -78687,13 +81543,14 @@ var ts; function isReferencedAliasDeclaration(node, checkChildren) { if (isAliasSymbolDeclaration(node)) { var symbol = getSymbolOfNode(node); - if (symbol && getSymbolLinks(symbol).referenced) { + var links = symbol && getSymbolLinks(symbol); + if (links === null || links === void 0 ? void 0 : links.referenced) { return true; } var target = getSymbolLinks(symbol).target; // TODO: GH#18217 if (target && ts.getEffectiveModifierFlags(node) & 1 /* Export */ && target.flags & 111551 /* Value */ && - (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target))) { + (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) { // An `export import ... =` of a value symbol is always considered referenced return true; } @@ -78730,13 +81587,13 @@ var ts; !isOptionalParameter(parameter) && !ts.isJSDocParameterTag(parameter) && !!parameter.initializer && - !ts.hasSyntacticModifier(parameter, 92 /* ParameterPropertyModifier */); + !ts.hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */); } function isOptionalUninitializedParameterProperty(parameter) { return strictNullChecks && isOptionalParameter(parameter) && !parameter.initializer && - ts.hasSyntacticModifier(parameter, 92 /* ParameterPropertyModifier */); + ts.hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */); } function isOptionalUninitializedParameter(parameter) { return !!strictNullChecks && @@ -78771,15 +81628,15 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 291 /* EnumMember */: - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 293 /* EnumMember */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 291 /* EnumMember */) { + if (node.kind === 293 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -78867,7 +81724,7 @@ var ts; function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) { var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor); if (!declaration) { - return ts.factory.createToken(128 /* AnyKeyword */); + return ts.factory.createToken(129 /* AnyKeyword */); } // Get type of the symbol if this is the valid symbol otherwise get type at location var symbol = getSymbolOfNode(declaration); @@ -78886,7 +81743,7 @@ var ts; function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) { var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike); if (!signatureDeclaration) { - return ts.factory.createToken(128 /* AnyKeyword */); + return ts.factory.createToken(129 /* AnyKeyword */); } var signature = getSignatureFromDeclaration(signatureDeclaration); return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); @@ -78894,7 +81751,7 @@ var ts; function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) { var expr = ts.getParseTreeNode(exprIn, ts.isExpression); if (!expr) { - return ts.factory.createToken(128 /* AnyKeyword */); + return ts.factory.createToken(129 /* AnyKeyword */); } var type = getWidenedType(getRegularTypeOfExpression(expr)); return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); @@ -78932,8 +81789,7 @@ var ts; } function isLiteralConstDeclaration(node) { if (ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node)) { - var type = getTypeOfSymbol(getSymbolOfNode(node)); - return !!(type.flags & 2944 /* Literal */) && isFreshLiteralType(type); + return isFreshLiteralType(getTypeOfSymbol(getSymbolOfNode(node))); } return false; } @@ -79052,12 +81908,12 @@ var ts; getJsxFragmentFactoryEntity: getJsxFragmentFactoryEntity, getAllAccessorDeclarations: function (accessor) { accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); // TODO: GH#18217 - var otherKind = accessor.kind === 168 /* SetAccessor */ ? 167 /* GetAccessor */ : 168 /* SetAccessor */; + var otherKind = accessor.kind === 170 /* SetAccessor */ ? 169 /* GetAccessor */ : 170 /* 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 === 168 /* SetAccessor */ ? accessor : otherAccessor; - var getAccessor = accessor.kind === 167 /* GetAccessor */ ? accessor : otherAccessor; + var setAccessor = accessor.kind === 170 /* SetAccessor */ ? accessor : otherAccessor; + var getAccessor = accessor.kind === 169 /* GetAccessor */ ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -79073,7 +81929,7 @@ var ts; }, getDeclarationStatementsForSourceFile: function (node, flags, tracker, bundled) { var n = ts.getParseTreeNode(node); - ts.Debug.assert(n && n.kind === 297 /* SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); + ts.Debug.assert(n && n.kind === 299 /* SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); var sym = getSymbolOfNode(node); if (!sym) { return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker, bundled); @@ -79096,11 +81952,13 @@ var ts; var s = _a[_i]; if (s.mergeId) { var merged = getMergedSymbol(s); - for (var _b = 0, _c = merged.declarations; _b < _c.length; _b++) { - var d = _c[_b]; - var declFile = ts.getSourceFileOfNode(d); - if (declFile === importTarget) { - return true; + if (merged.declarations) { + for (var _b = 0, _c = merged.declarations; _b < _c.length; _b++) { + var d = _c[_b]; + var declFile = ts.getSourceFileOfNode(d); + if (declFile === importTarget) { + return true; + } } } } @@ -79108,7 +81966,7 @@ var ts; return false; } function isInHeritageClause(node) { - return node.parent && node.parent.kind === 223 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 286 /* HeritageClause */; + return node.parent && node.parent.kind === 225 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 288 /* HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -79120,7 +81978,7 @@ var ts; // 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 === 78 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 201 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { + if ((node.kind === 79 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 203 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); @@ -79129,10 +81987,7 @@ var ts; // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForSymbol(symbol, meaning) { // program does not have any files with type reference directives - bail out - if (!fileToDirective) { - return undefined; - } - if (!isSymbolFromTypeDeclarationFile(symbol)) { + if (!fileToDirective || !isSymbolFromTypeDeclarationFile(symbol)) { return undefined; } // check what declarations in the symbol can contribute to the target meaning @@ -79171,7 +82026,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 297 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 299 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -79199,12 +82054,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 256 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 258 /* 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, 297 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 299 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -79224,7 +82079,7 @@ var ts; // It is an error for a non-external-module (i.e. script) to declare its own `globalThis`. // We can't use `builtinGlobals` for this due to synthetic expando-namespace generation in JS files. var fileGlobalThisSymbol = file.locals.get("globalThis"); - if (fileGlobalThisSymbol) { + if (fileGlobalThisSymbol === null || fileGlobalThisSymbol === void 0 ? void 0 : fileGlobalThisSymbol.declarations) { for (var _d = 0, _e = fileGlobalThisSymbol.declarations; _d < _e.length; _d++) { var declaration = _e[_d]; diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0, "globalThis")); @@ -79348,6 +82203,16 @@ var ts; 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 */) { + 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 */) { + 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); + } + } } } } @@ -79397,14 +82262,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 165 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 167 /* 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 === 167 /* GetAccessor */ || node.kind === 168 /* SetAccessor */) { + else if (node.kind === 169 /* GetAccessor */ || node.kind === 170 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -79417,31 +82282,51 @@ var ts; if (quickResult !== undefined) { return quickResult; } - var lastStatic, lastDeclare, lastAsync, lastReadonly; + var lastStatic, lastDeclare, lastAsync, lastReadonly, lastOverride; var flags = 0 /* None */; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 142 /* ReadonlyKeyword */) { - if (node.kind === 162 /* PropertySignature */ || node.kind === 164 /* MethodSignature */) { + if (modifier.kind !== 143 /* ReadonlyKeyword */) { + if (node.kind === 164 /* PropertySignature */ || node.kind === 166 /* MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 171 /* IndexSignature */) { + if (node.kind === 173 /* IndexSignature */ && (modifier.kind !== 124 /* StaticKeyword */ || !ts.isClassLike(node.parent))) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 84 /* ConstKeyword */: - if (node.kind !== 255 /* EnumDeclaration */) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(84 /* ConstKeyword */)); + case 85 /* ConstKeyword */: + if (node.kind !== 257 /* EnumDeclaration */) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(85 /* ConstKeyword */)); } break; - case 122 /* PublicKeyword */: - case 121 /* ProtectedKeyword */: - case 120 /* PrivateKeyword */: + case 157 /* OverrideKeyword */: + // If node.kind === SyntaxKind.Parameter, checkParameter reports an error if it's not a parameter property. + if (flags & 16384 /* Override */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "override"); + } + else if (flags & 2 /* Ambient */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "override", "declare"); + } + else if (flags & 64 /* Readonly */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "override", "readonly"); + } + else if (flags & 256 /* Async */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "override", "async"); + } + flags |= 16384 /* Override */; + lastOverride = modifier; + break; + case 123 /* PublicKeyword */: + case 122 /* ProtectedKeyword */: + case 121 /* PrivateKeyword */: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); if (flags & 28 /* AccessibilityModifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); } + else if (flags & 16384 /* Override */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "override"); + } else if (flags & 32 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } @@ -79451,23 +82336,23 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 257 /* ModuleBlock */ || node.parent.kind === 297 /* SourceFile */) { + else if (node.parent.kind === 259 /* ModuleBlock */ || node.parent.kind === 299 /* 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 === 120 /* PrivateKeyword */) { + if (modifier.kind === 121 /* PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "abstract"); } } - else if (ts.isPrivateIdentifierPropertyDeclaration(node)) { + else if (ts.isPrivateIdentifierClassElementDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics.An_accessibility_modifier_cannot_be_used_with_a_private_identifier); } flags |= ts.modifierToFlag(modifier.kind); break; - case 123 /* StaticKeyword */: + case 124 /* StaticKeyword */: if (flags & 32 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } @@ -79477,33 +82362,33 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 257 /* ModuleBlock */ || node.parent.kind === 297 /* SourceFile */) { + else if (node.parent.kind === 259 /* ModuleBlock */ || node.parent.kind === 299 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 160 /* Parameter */) { + else if (node.kind === 162 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - else if (ts.isPrivateIdentifierPropertyDeclaration(node)) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "static"); + else if (flags & 16384 /* Override */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "override"); } flags |= 32 /* Static */; lastStatic = modifier; break; - case 142 /* ReadonlyKeyword */: + case 143 /* ReadonlyKeyword */: if (flags & 64 /* Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 163 /* PropertyDeclaration */ && node.kind !== 162 /* PropertySignature */ && node.kind !== 171 /* IndexSignature */ && node.kind !== 160 /* Parameter */) { - // If node.kind === SyntaxKind.Parameter, checkParameter report an error if it's not a parameter property. + else if (node.kind !== 165 /* PropertyDeclaration */ && node.kind !== 164 /* PropertySignature */ && node.kind !== 173 /* IndexSignature */ && node.kind !== 162 /* 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 */; lastReadonly = modifier; break; - case 92 /* ExportKeyword */: + case 93 /* ExportKeyword */: if (flags & 1 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -79519,53 +82404,56 @@ var ts; 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 === 160 /* Parameter */) { + else if (node.kind === 162 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; - case 87 /* DefaultKeyword */: - var container = node.parent.kind === 297 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 256 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + case 88 /* DefaultKeyword */: + var container = node.parent.kind === 299 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 258 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } flags |= 512 /* Default */; break; - case 133 /* DeclareKeyword */: + case 134 /* DeclareKeyword */: if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } + else if (flags & 16384 /* 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 === 160 /* Parameter */) { + else if (node.kind === 162 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 8388608 /* Ambient */) && node.parent.kind === 257 /* ModuleBlock */) { + else if ((node.parent.flags & 8388608 /* Ambient */) && node.parent.kind === 259 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } - else if (ts.isPrivateIdentifierPropertyDeclaration(node)) { + else if (ts.isPrivateIdentifierClassElementDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "declare"); } flags |= 2 /* Ambient */; lastDeclare = modifier; break; - case 125 /* AbstractKeyword */: + case 126 /* AbstractKeyword */: if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 252 /* ClassDeclaration */ && - node.kind !== 175 /* ConstructorType */) { - if (node.kind !== 165 /* MethodDeclaration */ && - node.kind !== 163 /* PropertyDeclaration */ && - node.kind !== 167 /* GetAccessor */ && - node.kind !== 168 /* SetAccessor */) { + if (node.kind !== 254 /* ClassDeclaration */ && + node.kind !== 177 /* ConstructorType */) { + if (node.kind !== 167 /* MethodDeclaration */ && + node.kind !== 165 /* PropertyDeclaration */ && + node.kind !== 169 /* GetAccessor */ && + node.kind !== 170 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 252 /* ClassDeclaration */ && ts.hasSyntacticModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 254 /* ClassDeclaration */ && ts.hasSyntacticModifier(node.parent, 128 /* Abstract */))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32 /* Static */) { @@ -79577,20 +82465,23 @@ var ts; if (flags & 256 /* Async */ && lastAsync) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "async", "abstract"); } + if (flags & 16384 /* Override */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "abstract", "override"); + } } - if (ts.isNamedDeclaration(node) && node.name.kind === 79 /* PrivateIdentifier */) { + if (ts.isNamedDeclaration(node) && node.name.kind === 80 /* PrivateIdentifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "abstract"); } flags |= 128 /* Abstract */; break; - case 129 /* AsyncKeyword */: + case 130 /* AsyncKeyword */: if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } else if (flags & 2 /* Ambient */ || node.parent.flags & 8388608 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 160 /* Parameter */) { + else if (node.kind === 162 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } if (flags & 128 /* Abstract */) { @@ -79601,13 +82492,16 @@ var ts; break; } } - if (node.kind === 166 /* Constructor */) { + if (node.kind === 168 /* Constructor */) { if (flags & 32 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } if (flags & 128 /* Abstract */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract"); // TODO: GH#18217 } + if (flags & 16384 /* Override */) { + return grammarErrorOnNode(lastOverride, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "override"); // TODO: GH#18217 + } else if (flags & 256 /* Async */) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); } @@ -79616,13 +82510,13 @@ var ts; } return false; } - else if ((node.kind === 261 /* ImportDeclaration */ || node.kind === 260 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 263 /* ImportDeclaration */ || node.kind === 262 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 160 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 162 /* Parameter */ && (flags & 16476 /* 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 === 160 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 162 /* Parameter */ && (flags & 16476 /* ParameterPropertyModifier */) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256 /* Async */) { @@ -79643,39 +82537,39 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 166 /* Constructor */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 171 /* IndexSignature */: - case 256 /* ModuleDeclaration */: - case 261 /* ImportDeclaration */: - case 260 /* ImportEqualsDeclaration */: - case 267 /* ExportDeclaration */: - case 266 /* ExportAssignment */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 160 /* Parameter */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 168 /* Constructor */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: + case 173 /* IndexSignature */: + case 258 /* ModuleDeclaration */: + case 263 /* ImportDeclaration */: + case 262 /* ImportEqualsDeclaration */: + case 269 /* ExportDeclaration */: + case 268 /* ExportAssignment */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: + case 162 /* Parameter */: return false; default: - if (node.parent.kind === 257 /* ModuleBlock */ || node.parent.kind === 297 /* SourceFile */) { + if (node.parent.kind === 259 /* ModuleBlock */ || node.parent.kind === 299 /* SourceFile */) { return false; } switch (node.kind) { - case 251 /* FunctionDeclaration */: - return nodeHasAnyModifiersExcept(node, 129 /* AsyncKeyword */); - case 252 /* ClassDeclaration */: - case 175 /* ConstructorType */: - return nodeHasAnyModifiersExcept(node, 125 /* AbstractKeyword */); - case 253 /* InterfaceDeclaration */: - case 232 /* VariableStatement */: - case 254 /* TypeAliasDeclaration */: + case 253 /* FunctionDeclaration */: + return nodeHasAnyModifiersExcept(node, 130 /* AsyncKeyword */); + case 254 /* ClassDeclaration */: + case 177 /* ConstructorType */: + return nodeHasAnyModifiersExcept(node, 126 /* AbstractKeyword */); + case 255 /* InterfaceDeclaration */: + case 234 /* VariableStatement */: + case 256 /* TypeAliasDeclaration */: return true; - case 255 /* EnumDeclaration */: - return nodeHasAnyModifiersExcept(node, 84 /* ConstKeyword */); + case 257 /* EnumDeclaration */: + return nodeHasAnyModifiersExcept(node, 85 /* ConstKeyword */); default: ts.Debug.fail(); } @@ -79686,10 +82580,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 165 /* MethodDeclaration */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 167 /* MethodDeclaration */: + case 253 /* FunctionDeclaration */: + case 210 /* FunctionExpression */: + case 211 /* ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -79808,7 +82702,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 147 /* StringKeyword */ && parameter.type.kind !== 144 /* NumberKeyword */) { + if (parameter.type.kind !== 148 /* StringKeyword */ && parameter.type.kind !== 145 /* NumberKeyword */) { var type = getTypeFromTypeNode(parameter.type); if (type.flags & 4 /* String */ || type.flags & 8 /* Number */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead, ts.getTextOfNode(parameter.name), typeToString(type), typeToString(node.type ? getTypeFromTypeNode(node.type) : anyType)); @@ -79850,7 +82744,7 @@ var ts; if (args) { for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 222 /* OmittedExpression */) { + if (arg.kind === 224 /* OmittedExpression */) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -79880,7 +82774,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 === 93 /* ExtendsKeyword */) { + if (heritageClause.token === 94 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -79893,7 +82787,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 116 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 117 /* ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -79909,14 +82803,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 93 /* ExtendsKeyword */) { + if (heritageClause.token === 94 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 116 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 117 /* ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -79927,20 +82821,20 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 158 /* ComputedPropertyName */) { + if (node.kind !== 160 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 216 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* CommaToken */) { + if (computedPropertyName.expression.kind === 218 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* 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 === 251 /* FunctionDeclaration */ || - node.kind === 208 /* FunctionExpression */ || - node.kind === 165 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 253 /* FunctionDeclaration */ || + node.kind === 210 /* FunctionExpression */ || + node.kind === 167 /* MethodDeclaration */); if (node.flags & 8388608 /* Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -79959,7 +82853,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 === 290 /* SpreadAssignment */) { + if (prop.kind === 292 /* SpreadAssignment */) { if (inDestructuring) { // a rest property cannot be destructured any further var expression = ts.skipParentheses(prop.expression); @@ -79970,24 +82864,24 @@ var ts; continue; } var name = prop.name; - if (name.kind === 158 /* ComputedPropertyName */) { + if (name.kind === 160 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 289 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 291 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern // outside of destructuring it is a syntax error return 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 === 79 /* PrivateIdentifier */) { - return grammarErrorOnNode(name, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); + if (name.kind === 80 /* 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 (prop.modifiers) { // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { // TODO: GH#19955 var mod = _c[_b]; - if (mod.kind !== 129 /* AsyncKeyword */ || prop.kind !== 165 /* MethodDeclaration */) { + if (mod.kind !== 130 /* AsyncKeyword */ || prop.kind !== 167 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -80002,10 +82896,10 @@ 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 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); // falls through - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8 /* NumericLiteral */) { @@ -80013,13 +82907,13 @@ var ts; } currentKind = 4 /* PropertyAssignment */; break; - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: currentKind = 8 /* Method */; break; - case 167 /* GetAccessor */: + case 169 /* GetAccessor */: currentKind = 1 /* GetAccessor */; break; - case 168 /* SetAccessor */: + case 170 /* SetAccessor */: currentKind = 2 /* SetAccessor */; break; default: @@ -80054,11 +82948,12 @@ var ts; } } function checkGrammarJsxElement(node) { + checkGrammarJsxName(node.tagName); checkGrammarTypeArguments(node, node.typeArguments); var seen = new ts.Map(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 282 /* JsxSpreadAttribute */) { + if (attr.kind === 284 /* JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -80068,11 +82963,32 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 283 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 285 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } } + function checkGrammarJsxName(node) { + if (ts.isPropertyAccessExpression(node)) { + var propName = node; + do { + var check_1 = checkGrammarJsxNestedIdentifier(propName.name); + if (check_1) { + return check_1; + } + propName = propName.expression; + } while (ts.isPropertyAccessExpression(propName)); + var check = checkGrammarJsxNestedIdentifier(propName); + if (check) { + return check; + } + } + function checkGrammarJsxNestedIdentifier(name) { + if (ts.isIdentifier(name) && ts.idText(name).indexOf(":") !== -1) { + return grammarErrorOnNode(name, ts.Diagnostics.JSX_property_access_expressions_cannot_include_JSX_namespace_names); + } + } + } function checkGrammarJsxExpression(node) { if (node.expression && ts.isCommaSequence(node.expression)) { return grammarErrorOnNode(node.expression, ts.Diagnostics.JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array); @@ -80082,25 +82998,42 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 239 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { - if ((forInOrOfStatement.flags & 32768 /* AwaitContext */) === 0 /* None */) { - // use of 'for-await-of' in non-async function + if (forInOrOfStatement.kind === 241 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if (!(forInOrOfStatement.flags & 32768 /* AwaitContext */)) { var sourceFile = ts.getSourceFileOfNode(forInOrOfStatement); - if (!hasParseDiagnostics(sourceFile)) { - var diagnostic = ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); - var func = ts.getContainingFunction(forInOrOfStatement); - if (func && func.kind !== 166 /* Constructor */) { - ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* 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); - } - diagnostics.add(diagnostic); - return true; + if (ts.isInTopLevelContext(forInOrOfStatement)) { + if (!hasParseDiagnostics(sourceFile)) { + if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) { + diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module)); + } + if ((moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) || languageVersion < 4 /* ES2017 */) { + diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher)); + } + } + } + else { + // use of 'for-await-of' in non-async function + 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 !== 168 /* Constructor */) { + ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* 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); + } + diagnostics.add(diagnostic); + return true; + } } return false; } } - if (forInOrOfStatement.initializer.kind === 250 /* VariableDeclarationList */) { + if (ts.isForOfStatement(forInOrOfStatement) && !(forInOrOfStatement.flags & 32768 /* 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 === 252 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -80115,20 +83048,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 238 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 240 /* 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 === 238 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 240 /* 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 === 238 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 240 /* 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); @@ -80138,26 +83071,34 @@ var ts; return false; } function checkGrammarAccessor(accessor) { - if (!(accessor.flags & 8388608 /* Ambient */)) { + if (!(accessor.flags & 8388608 /* Ambient */) && (accessor.parent.kind !== 179 /* TypeLiteral */) && (accessor.parent.kind !== 255 /* InterfaceDeclaration */)) { if (languageVersion < 1 /* 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)) { + 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 */)) { return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } } - if (accessor.body && ts.hasSyntacticModifier(accessor, 128 /* Abstract */)) { - return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation); + if (accessor.body) { + if (ts.hasSyntacticModifier(accessor, 128 /* Abstract */)) { + return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation); + } + if (accessor.parent.kind === 179 /* TypeLiteral */ || accessor.parent.kind === 255 /* InterfaceDeclaration */) { + return grammarErrorOnNode(accessor.body, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); + } } if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, accessor.kind === 167 /* GetAccessor */ ? + return grammarErrorOnNode(accessor.name, accessor.kind === 169 /* GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - if (accessor.kind === 168 /* SetAccessor */) { + if (accessor.kind === 170 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -80179,17 +83120,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 === 167 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 169 /* GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 167 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 169 /* GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } function checkGrammarTypeOperatorNode(node) { - if (node.operator === 151 /* UniqueKeyword */) { - if (node.type.kind !== 148 /* SymbolKeyword */) { - return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(148 /* SymbolKeyword */)); + if (node.operator === 152 /* UniqueKeyword */) { + if (node.type.kind !== 149 /* SymbolKeyword */) { + return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(149 /* SymbolKeyword */)); } var parent = ts.walkUpParenthesizedTypes(node.parent); if (ts.isInJSFile(parent) && ts.isJSDocTypeExpression(parent)) { @@ -80200,9 +83141,9 @@ var ts; } } switch (parent.kind) { - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: var decl = parent; - if (decl.name.kind !== 78 /* Identifier */) { + if (decl.name.kind !== 79 /* 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)) { @@ -80212,13 +83153,13 @@ var ts; return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: if (!ts.hasSyntacticModifier(parent, 32 /* Static */) || !ts.hasEffectiveModifier(parent, 64 /* Readonly */)) { 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 162 /* PropertySignature */: + case 164 /* PropertySignature */: if (!ts.hasSyntacticModifier(parent, 64 /* 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); } @@ -80227,9 +83168,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_not_allowed_here); } } - else if (node.operator === 142 /* ReadonlyKeyword */) { - if (node.type.kind !== 178 /* ArrayType */ && node.type.kind !== 179 /* TupleType */) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(148 /* SymbolKeyword */)); + else if (node.operator === 143 /* ReadonlyKeyword */) { + if (node.type.kind !== 180 /* ArrayType */ && node.type.kind !== 181 /* TupleType */) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(149 /* SymbolKeyword */)); } } } @@ -80242,10 +83183,10 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 165 /* MethodDeclaration */) { - if (node.parent.kind === 200 /* ObjectLiteralExpression */) { + if (node.kind === 167 /* MethodDeclaration */) { + if (node.parent.kind === 202 /* 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 === 129 /* AsyncKeyword */)) { + if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 130 /* AsyncKeyword */)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } else if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { @@ -80263,6 +83204,9 @@ var ts; } } if (ts.isClassLike(node.parent)) { + if (languageVersion < 2 /* 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 // for property declarations and accessors too, not just methods. // However, property declarations disallow computed names in general, @@ -80271,14 +83215,14 @@ var ts; if (node.flags & 8388608 /* 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 === 165 /* MethodDeclaration */ && !node.body) { + else if (node.kind === 167 /* 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 === 253 /* InterfaceDeclaration */) { + else if (node.parent.kind === 255 /* 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 === 177 /* TypeLiteral */) { + else if (node.parent.kind === 179 /* 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); } } @@ -80289,11 +83233,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 245 /* LabeledStatement */: + case 247 /* 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 === 240 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 242 /* 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); @@ -80301,8 +83245,8 @@ var ts; return false; } break; - case 244 /* SwitchStatement */: - if (node.kind === 241 /* BreakStatement */ && !node.label) { + case 246 /* SwitchStatement */: + if (node.kind === 243 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -80317,13 +83261,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 241 /* BreakStatement */ + var message = node.kind === 243 /* 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 === 241 /* BreakStatement */ + var message = node.kind === 243 /* 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); @@ -80347,12 +83291,12 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return ts.isStringOrNumericLiteralLike(expr) || - expr.kind === 214 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && + expr.kind === 216 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function isBigIntLiteralExpression(expr) { return expr.kind === 9 /* BigIntLiteral */ || - expr.kind === 214 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && + expr.kind === 216 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && expr.operand.kind === 9 /* BigIntLiteral */; } function isSimpleLiteralEnumReference(expr) { @@ -80366,7 +83310,7 @@ var ts; if (initializer) { var isInvalidInitializer = !(isStringOrNumberLiteralExpression(initializer) || isSimpleLiteralEnumReference(initializer) || - initializer.kind === 109 /* TrueKeyword */ || initializer.kind === 94 /* FalseKeyword */ || + initializer.kind === 110 /* TrueKeyword */ || initializer.kind === 95 /* FalseKeyword */ || isBigIntLiteralExpression(initializer)); var isConstOrReadonly = ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node); if (isConstOrReadonly && !node.type) { @@ -80383,7 +83327,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 238 /* ForInStatement */ && node.parent.parent.kind !== 239 /* ForOfStatement */) { + if (node.parent.parent.kind !== 240 /* ForInStatement */ && node.parent.parent.kind !== 241 /* ForOfStatement */) { if (node.flags & 8388608 /* Ambient */) { checkAmbientInitializer(node); } @@ -80396,7 +83340,7 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 232 /* VariableStatement */ || !node.type || node.initializer || node.flags & 8388608 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 234 /* VariableStatement */ || !node.type || node.initializer || node.flags & 8388608 /* Ambient */)) { var message = node.initializer ? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions : !node.type @@ -80419,7 +83363,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkESModuleMarker(name) { - if (name.kind === 78 /* Identifier */) { + if (name.kind === 79 /* 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); } @@ -80436,8 +83380,8 @@ var ts; return false; } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 78 /* Identifier */) { - if (name.originalKeywordKind === 118 /* LetKeyword */) { + if (name.kind === 79 /* Identifier */) { + if (name.originalKeywordKind === 119 /* LetKeyword */) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -80464,15 +83408,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 234 /* IfStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: - case 243 /* WithStatement */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: + case 236 /* IfStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: + case 245 /* WithStatement */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: return false; - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -80490,12 +83434,12 @@ var ts; function checkGrammarMetaProperty(node) { var escapedText = node.name.escapedText; switch (node.keywordToken) { - case 102 /* NewKeyword */: + case 103 /* 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 99 /* ImportKeyword */: + case 100 /* 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"); } @@ -80557,14 +83501,14 @@ var ts; if (ts.isStringLiteral(node.name) && node.name.text === "constructor") { return grammarErrorOnNode(node.name, ts.Diagnostics.Classes_may_not_have_a_field_named_constructor); } - if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { + 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)) { return grammarErrorOnNode(node.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher); } } - else if (node.parent.kind === 253 /* InterfaceDeclaration */) { + else if (node.parent.kind === 255 /* 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; } @@ -80572,7 +83516,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 177 /* TypeLiteral */) { + else if (node.parent.kind === 179 /* TypeLiteral */) { if (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)) { return true; } @@ -80606,13 +83550,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 253 /* InterfaceDeclaration */ || - node.kind === 254 /* TypeAliasDeclaration */ || - node.kind === 261 /* ImportDeclaration */ || - node.kind === 260 /* ImportEqualsDeclaration */ || - node.kind === 267 /* ExportDeclaration */ || - node.kind === 266 /* ExportAssignment */ || - node.kind === 259 /* NamespaceExportDeclaration */ || + if (node.kind === 255 /* InterfaceDeclaration */ || + node.kind === 256 /* TypeAliasDeclaration */ || + node.kind === 263 /* ImportDeclaration */ || + node.kind === 262 /* ImportEqualsDeclaration */ || + node.kind === 269 /* ExportDeclaration */ || + node.kind === 268 /* ExportAssignment */ || + node.kind === 261 /* NamespaceExportDeclaration */ || ts.hasSyntacticModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -80621,7 +83565,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 === 232 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 234 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -80644,7 +83588,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 === 230 /* Block */ || node.parent.kind === 257 /* ModuleBlock */ || node.parent.kind === 297 /* SourceFile */) { + if (node.parent.kind === 232 /* Block */ || node.parent.kind === 259 /* ModuleBlock */ || node.parent.kind === 299 /* SourceFile */) { var links_2 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_2.hasReportedStatementInAmbientContext) { @@ -80666,10 +83610,10 @@ var ts; if (languageVersion >= 1 /* ES5 */) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 191 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 193 /* LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 291 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 293 /* EnumMember */)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { @@ -80775,7 +83719,7 @@ var ts; } } function findBestTypeForObjectLiteral(source, unionTarget) { - if (ts.getObjectFlags(source) & 128 /* ObjectLiteral */ && forEachType(unionTarget, isArrayLikeType)) { + if (ts.getObjectFlags(source) & 128 /* ObjectLiteral */ && someType(unionTarget, isArrayLikeType)) { return ts.find(unionTarget.types, function (t) { return !isArrayLikeType(t); }); } } @@ -80827,6 +83771,10 @@ 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 */)) { + var match = getMatchingUnionConstituentForType(target, source); + if (match) { + return match; + } var sourceProperties = getPropertiesOfType(source); if (sourceProperties) { var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target); @@ -80844,33 +83792,19 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 251 /* FunctionDeclaration */ && declaration.kind !== 165 /* MethodDeclaration */) || + return (declaration.kind !== 253 /* FunctionDeclaration */ && declaration.kind !== 167 /* 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 265 /* ImportSpecifier */: - case 270 /* ExportSpecifier */: + case 267 /* ImportSpecifier */: + case 272 /* ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); } } - function isSomeImportDeclaration(decl) { - switch (decl.kind) { - case 262 /* ImportClause */: // For default import - case 260 /* ImportEqualsDeclaration */: - case 263 /* NamespaceImport */: - case 265 /* ImportSpecifier */: // For rename import `x as y` - return true; - case 78 /* Identifier */: - // For regular import, `decl` is an Identifier under the ImportSpecifier. - return decl.parent.kind === 265 /* ImportSpecifier */; - default: - return false; - } - } var JsxNames; (function (JsxNames) { JsxNames.JSX = "JSX"; @@ -80901,7 +83835,6 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var isTypeNodeOrTypeParameterDeclaration = ts.or(ts.isTypeNode, ts.isTypeParameterDeclaration); function visitNode(node, visitor, test, lift) { if (node === undefined || visitor === undefined) { return node; @@ -81090,6 +84023,24 @@ var ts; return updated; } ts.visitFunctionBody = visitFunctionBody; + /** + * Visits an iteration body, adding any block-scoped variables required by the transformation. + */ + function visitIterationBody(body, visitor, context) { + context.startBlockScope(); + var updated = visitNode(body, visitor, ts.isStatement, context.factory.liftToBlock); + var declarations = context.endBlockScope(); + if (ts.some(declarations)) { + if (ts.isBlock(updated)) { + declarations.push.apply(declarations, updated.statements); + return context.factory.updateBlock(updated, declarations); + } + declarations.push(updated); + return context.factory.createBlock(declarations); + } + return updated; + } + ts.visitIterationBody = visitIterationBody; function visitEachChild(node, visitor, context, nodesVisitor, tokenVisitor, nodeVisitor) { if (nodesVisitor === void 0) { nodesVisitor = visitNodes; } if (nodeVisitor === void 0) { nodeVisitor = visitNode; } @@ -81098,299 +84049,433 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 156 /* LastToken */) || kind === 187 /* ThisType */) { + if ((kind > 0 /* FirstToken */ && kind <= 158 /* LastToken */) || kind === 189 /* ThisType */) { return node; } var factory = context.factory; switch (kind) { // Names - case 78 /* Identifier */: - return factory.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration)); - case 157 /* QualifiedName */: + case 79 /* Identifier */: + ts.Debug.type(node); + return factory.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNodeOrTypeParameterDeclaration)); + case 159 /* QualifiedName */: + ts.Debug.type(node); return factory.updateQualifiedName(node, nodeVisitor(node.left, visitor, ts.isEntityName), nodeVisitor(node.right, visitor, ts.isIdentifier)); - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: + ts.Debug.type(node); return factory.updateComputedPropertyName(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Signature elements - case 159 /* TypeParameter */: + case 161 /* TypeParameter */: + ts.Debug.type(node); return factory.updateTypeParameterDeclaration(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.constraint, visitor, ts.isTypeNode), nodeVisitor(node.default, visitor, ts.isTypeNode)); - case 160 /* Parameter */: - return factory.updateParameterDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isToken), nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 161 /* Decorator */: + case 162 /* Parameter */: + ts.Debug.type(node); + return factory.updateParameterDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), 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 163 /* Decorator */: + ts.Debug.type(node); return factory.updateDecorator(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Type elements - case 162 /* PropertySignature */: - return factory.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isToken), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 163 /* PropertyDeclaration */: + case 164 /* 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 165 /* PropertyDeclaration */: + ts.Debug.type(node); return factory.updatePropertyDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), 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.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 164 /* MethodSignature */: - return factory.updateMethodSignature(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 165 /* MethodDeclaration */: - return factory.updateMethodDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isToken), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), 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 166 /* Constructor */: + nodeVisitor(node.questionToken || node.exclamationToken, tokenVisitor, ts.isQuestionOrExclamationToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); + case 166 /* 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 167 /* MethodDeclaration */: + ts.Debug.type(node); + return factory.updateMethodDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), 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 168 /* Constructor */: + ts.Debug.type(node); return factory.updateConstructorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 167 /* GetAccessor */: + case 169 /* GetAccessor */: + ts.Debug.type(node); return factory.updateGetAccessorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), 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 168 /* SetAccessor */: + case 170 /* SetAccessor */: + ts.Debug.type(node); return factory.updateSetAccessorDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 169 /* CallSignature */: + case 171 /* 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 170 /* ConstructSignature */: + case 172 /* 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 171 /* IndexSignature */: + case 173 /* IndexSignature */: + ts.Debug.type(node); return factory.updateIndexSignature(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); // Types - case 172 /* TypePredicate */: - return factory.updateTypePredicateNode(node, nodeVisitor(node.assertsModifier, visitor), nodeVisitor(node.parameterName, visitor), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 173 /* TypeReference */: + case 174 /* 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 175 /* TypeReference */: + ts.Debug.type(node); return factory.updateTypeReferenceNode(node, nodeVisitor(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 174 /* FunctionType */: + case 176 /* 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 175 /* ConstructorType */: + case 177 /* 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 176 /* TypeQuery */: + case 178 /* TypeQuery */: + ts.Debug.type(node); return factory.updateTypeQueryNode(node, nodeVisitor(node.exprName, visitor, ts.isEntityName)); - case 177 /* TypeLiteral */: + case 179 /* TypeLiteral */: + ts.Debug.type(node); return factory.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 178 /* ArrayType */: + case 180 /* ArrayType */: + ts.Debug.type(node); return factory.updateArrayTypeNode(node, nodeVisitor(node.elementType, visitor, ts.isTypeNode)); - case 179 /* TupleType */: + case 181 /* TupleType */: + ts.Debug.type(node); return factory.updateTupleTypeNode(node, nodesVisitor(node.elements, visitor, ts.isTypeNode)); - case 180 /* OptionalType */: + case 182 /* OptionalType */: + ts.Debug.type(node); return factory.updateOptionalTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 181 /* RestType */: + case 183 /* RestType */: + ts.Debug.type(node); return factory.updateRestTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 182 /* UnionType */: + case 184 /* UnionType */: + ts.Debug.type(node); return factory.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 183 /* IntersectionType */: + case 185 /* IntersectionType */: + ts.Debug.type(node); return factory.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 184 /* ConditionalType */: + case 186 /* 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 185 /* InferType */: + case 187 /* InferType */: + ts.Debug.type(node); return factory.updateInferTypeNode(node, nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 195 /* ImportType */: + case 197 /* ImportType */: + ts.Debug.type(node); return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); - case 192 /* NamedTupleMember */: - return factory.updateNamedTupleMember(node, visitNode(node.dotDotDotToken, visitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode)); - case 186 /* ParenthesizedType */: + case 194 /* 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 188 /* ParenthesizedType */: + ts.Debug.type(node); return factory.updateParenthesizedType(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 188 /* TypeOperator */: + case 190 /* TypeOperator */: + ts.Debug.type(node); return factory.updateTypeOperatorNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 189 /* IndexedAccessType */: + case 191 /* IndexedAccessType */: + ts.Debug.type(node); return factory.updateIndexedAccessTypeNode(node, nodeVisitor(node.objectType, visitor, ts.isTypeNode), nodeVisitor(node.indexType, visitor, ts.isTypeNode)); - case 190 /* MappedType */: - return factory.updateMappedTypeNode(node, nodeVisitor(node.readonlyToken, tokenVisitor, ts.isToken), nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration), nodeVisitor(node.nameType, visitor, ts.isTypeNode), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 191 /* LiteralType */: + case 192 /* 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)); + case 193 /* LiteralType */: + ts.Debug.type(node); return factory.updateLiteralTypeNode(node, nodeVisitor(node.literal, visitor, ts.isExpression)); - case 193 /* TemplateLiteralType */: + case 195 /* TemplateLiteralType */: + ts.Debug.type(node); return factory.updateTemplateLiteralType(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateLiteralTypeSpan)); - case 194 /* TemplateLiteralTypeSpan */: + case 196 /* TemplateLiteralTypeSpan */: + ts.Debug.type(node); return factory.updateTemplateLiteralTypeSpan(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Binding patterns - case 196 /* ObjectBindingPattern */: + case 198 /* ObjectBindingPattern */: + ts.Debug.type(node); return factory.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 197 /* ArrayBindingPattern */: + case 199 /* ArrayBindingPattern */: + ts.Debug.type(node); return factory.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 198 /* BindingElement */: - return factory.updateBindingElement(node, nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isToken), nodeVisitor(node.propertyName, visitor, ts.isPropertyName), nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.initializer, visitor, ts.isExpression)); + case 200 /* 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 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: + ts.Debug.type(node); return factory.updateArrayLiteralExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: + ts.Debug.type(node); return factory.updateObjectLiteralExpression(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: if (node.flags & 32 /* OptionalChain */) { - return factory.updatePropertyAccessChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isToken), nodeVisitor(node.name, visitor, ts.isIdentifier)); + 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)); } - return factory.updatePropertyAccessExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.name, visitor, ts.isIdentifierOrPrivateIdentifier)); - case 202 /* ElementAccessExpression */: + ts.Debug.type(node); + return factory.updatePropertyAccessExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.name, visitor, ts.isMemberName)); + case 204 /* ElementAccessExpression */: if (node.flags & 32 /* OptionalChain */) { - return factory.updateElementAccessChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isToken), nodeVisitor(node.argumentExpression, visitor, ts.isExpression)); + 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 203 /* CallExpression */: + case 205 /* CallExpression */: if (node.flags & 32 /* OptionalChain */) { - return factory.updateCallChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); + 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 204 /* NewExpression */: + case 206 /* 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 205 /* TaggedTemplateExpression */: - return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), nodeVisitor(node.template, visitor, ts.isTemplateLiteral)); - case 206 /* TypeAssertionExpression */: + case 207 /* 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 208 /* TypeAssertionExpression */: + ts.Debug.type(node); return factory.updateTypeAssertion(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: + ts.Debug.type(node); return factory.updateParenthesizedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 208 /* FunctionExpression */: - return factory.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isToken), 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 209 /* ArrowFunction */: - 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.isToken), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 210 /* DeleteExpression */: + case 210 /* 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 211 /* 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 212 /* DeleteExpression */: + ts.Debug.type(node); return factory.updateDeleteExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 211 /* TypeOfExpression */: + case 213 /* TypeOfExpression */: + ts.Debug.type(node); return factory.updateTypeOfExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 212 /* VoidExpression */: + case 214 /* VoidExpression */: + ts.Debug.type(node); return factory.updateVoidExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 213 /* AwaitExpression */: + case 215 /* AwaitExpression */: + ts.Debug.type(node); return factory.updateAwaitExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: + ts.Debug.type(node); return factory.updatePrefixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression)); - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: + ts.Debug.type(node); return factory.updatePostfixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression)); - case 216 /* BinaryExpression */: - return factory.updateBinaryExpression(node, nodeVisitor(node.left, visitor, ts.isExpression), nodeVisitor(node.operatorToken, tokenVisitor, ts.isToken), nodeVisitor(node.right, visitor, ts.isExpression)); - case 217 /* ConditionalExpression */: - return factory.updateConditionalExpression(node, nodeVisitor(node.condition, visitor, ts.isExpression), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.whenTrue, visitor, ts.isExpression), nodeVisitor(node.colonToken, tokenVisitor, ts.isToken), nodeVisitor(node.whenFalse, visitor, ts.isExpression)); - case 218 /* TemplateExpression */: + case 218 /* 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 219 /* 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 220 /* TemplateExpression */: + ts.Debug.type(node); return factory.updateTemplateExpression(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 219 /* YieldExpression */: - return factory.updateYieldExpression(node, nodeVisitor(node.asteriskToken, tokenVisitor, ts.isToken), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 220 /* SpreadElement */: + case 221 /* YieldExpression */: + ts.Debug.type(node); + return factory.updateYieldExpression(node, nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.expression, visitor, ts.isExpression)); + case 222 /* SpreadElement */: + ts.Debug.type(node); return factory.updateSpreadElement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: + ts.Debug.type(node); return factory.updateClassExpression(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), 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.isClassElement)); - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: + ts.Debug.type(node); return factory.updateExpressionWithTypeArguments(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 224 /* AsExpression */: + case 226 /* AsExpression */: + ts.Debug.type(node); return factory.updateAsExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 225 /* NonNullExpression */: + case 227 /* NonNullExpression */: if (node.flags & 32 /* 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 226 /* MetaProperty */: + case 228 /* MetaProperty */: + ts.Debug.type(node); return factory.updateMetaProperty(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); // Misc - case 228 /* TemplateSpan */: + case 230 /* TemplateSpan */: + ts.Debug.type(node); return factory.updateTemplateSpan(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 230 /* Block */: + case 232 /* Block */: + ts.Debug.type(node); return factory.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: + ts.Debug.type(node); return factory.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: + ts.Debug.type(node); return factory.updateExpressionStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 234 /* IfStatement */: + case 236 /* 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 235 /* DoStatement */: - return factory.updateDoStatement(node, nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 236 /* WhileStatement */: - return factory.updateWhileStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 237 /* ForStatement */: - return factory.updateForStatement(node, nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.condition, visitor, ts.isExpression), nodeVisitor(node.incrementor, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 238 /* ForInStatement */: - return factory.updateForInStatement(node, nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 239 /* ForOfStatement */: - return factory.updateForOfStatement(node, nodeVisitor(node.awaitModifier, tokenVisitor, ts.isToken), nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 240 /* ContinueStatement */: + case 237 /* DoStatement */: + ts.Debug.type(node); + return factory.updateDoStatement(node, visitIterationBody(node.statement, visitor, context), nodeVisitor(node.expression, visitor, ts.isExpression)); + case 238 /* WhileStatement */: + ts.Debug.type(node); + return factory.updateWhileStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); + case 239 /* 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 240 /* 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 241 /* 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 242 /* ContinueStatement */: + ts.Debug.type(node); return factory.updateContinueStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier)); - case 241 /* BreakStatement */: + case 243 /* BreakStatement */: + ts.Debug.type(node); return factory.updateBreakStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier)); - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: + ts.Debug.type(node); return factory.updateReturnStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 243 /* WithStatement */: + case 245 /* WithStatement */: + ts.Debug.type(node); return factory.updateWithStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: + ts.Debug.type(node); return factory.updateSwitchStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.caseBlock, visitor, ts.isCaseBlock)); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: + ts.Debug.type(node); return factory.updateLabeledStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 246 /* ThrowStatement */: + case 248 /* ThrowStatement */: + ts.Debug.type(node); return factory.updateThrowStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 247 /* TryStatement */: + case 249 /* 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 249 /* VariableDeclaration */: - return factory.updateVariableDeclaration(node, nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.exclamationToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 250 /* VariableDeclarationList */: + case 251 /* 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 252 /* VariableDeclarationList */: + ts.Debug.type(node); return factory.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 251 /* FunctionDeclaration */: - return factory.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isToken), 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 252 /* ClassDeclaration */: + case 253 /* FunctionDeclaration */: + ts.Debug.type(node); + return factory.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), 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 254 /* ClassDeclaration */: + ts.Debug.type(node); return factory.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), 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.isClassElement)); - case 253 /* InterfaceDeclaration */: + case 255 /* InterfaceDeclaration */: + ts.Debug.type(node); return factory.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), 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 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: + ts.Debug.type(node); return factory.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), 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 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: + ts.Debug.type(node); return factory.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); - case 256 /* ModuleDeclaration */: - return factory.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.body, visitor, ts.isModuleBody)); - case 257 /* ModuleBlock */: + case 258 /* ModuleDeclaration */: + ts.Debug.type(node); + return factory.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isModuleName), nodeVisitor(node.body, visitor, ts.isModuleBody)); + case 259 /* ModuleBlock */: + ts.Debug.type(node); return factory.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 258 /* CaseBlock */: + case 260 /* CaseBlock */: + ts.Debug.type(node); return factory.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 259 /* NamespaceExportDeclaration */: + case 261 /* NamespaceExportDeclaration */: + ts.Debug.type(node); return factory.updateNamespaceExportDeclaration(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: + ts.Debug.type(node); return factory.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.moduleReference, visitor, ts.isModuleReference)); - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: + ts.Debug.type(node); return factory.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.importClause, visitor, ts.isImportClause), nodeVisitor(node.moduleSpecifier, visitor, ts.isExpression)); - case 262 /* ImportClause */: + case 264 /* ImportClause */: + ts.Debug.type(node); return factory.updateImportClause(node, node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: + ts.Debug.type(node); return factory.updateNamespaceImport(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 269 /* NamespaceExport */: + case 271 /* NamespaceExport */: + ts.Debug.type(node); return factory.updateNamespaceExport(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 264 /* NamedImports */: + case 266 /* NamedImports */: + ts.Debug.type(node); return factory.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 265 /* ImportSpecifier */: + case 267 /* ImportSpecifier */: + ts.Debug.type(node); return factory.updateImportSpecifier(node, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: + ts.Debug.type(node); return factory.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: + ts.Debug.type(node); return factory.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), node.isTypeOnly, nodeVisitor(node.exportClause, visitor, ts.isNamedExportBindings), nodeVisitor(node.moduleSpecifier, visitor, ts.isExpression)); - case 268 /* NamedExports */: + case 270 /* NamedExports */: + ts.Debug.type(node); return factory.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 270 /* ExportSpecifier */: + case 272 /* ExportSpecifier */: + ts.Debug.type(node); return factory.updateExportSpecifier(node, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier)); // Module references - case 272 /* ExternalModuleReference */: + case 274 /* ExternalModuleReference */: + ts.Debug.type(node); return factory.updateExternalModuleReference(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // JSX - case 273 /* JsxElement */: + case 275 /* 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 274 /* JsxSelfClosingElement */: + case 276 /* 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 275 /* JsxOpeningElement */: + case 277 /* 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 276 /* JsxClosingElement */: + case 278 /* JsxClosingElement */: + ts.Debug.type(node); return factory.updateJsxClosingElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 277 /* JsxFragment */: + case 279 /* 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 280 /* JsxAttribute */: + case 282 /* JsxAttribute */: + ts.Debug.type(node); return factory.updateJsxAttribute(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 281 /* JsxAttributes */: + case 283 /* JsxAttributes */: + ts.Debug.type(node); return factory.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 282 /* JsxSpreadAttribute */: + case 284 /* JsxSpreadAttribute */: + ts.Debug.type(node); return factory.updateJsxSpreadAttribute(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: + ts.Debug.type(node); return factory.updateJsxExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Clauses - case 284 /* CaseClause */: + case 286 /* CaseClause */: + ts.Debug.type(node); return factory.updateCaseClause(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 285 /* DefaultClause */: + case 287 /* DefaultClause */: + ts.Debug.type(node); return factory.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 286 /* HeritageClause */: + case 288 /* HeritageClause */: + ts.Debug.type(node); return factory.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 287 /* CatchClause */: + case 289 /* CatchClause */: + ts.Debug.type(node); return factory.updateCatchClause(node, nodeVisitor(node.variableDeclaration, visitor, ts.isVariableDeclaration), nodeVisitor(node.block, visitor, ts.isBlock)); // Property assignments - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: + ts.Debug.type(node); return factory.updatePropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: + ts.Debug.type(node); return factory.updateShorthandPropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 290 /* SpreadAssignment */: + case 292 /* SpreadAssignment */: + ts.Debug.type(node); return factory.updateSpreadAssignment(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Enum - case 291 /* EnumMember */: + case 293 /* 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 297 /* SourceFile */: + case 299 /* SourceFile */: + ts.Debug.type(node); return factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 336 /* PartiallyEmittedExpression */: + case 344 /* PartiallyEmittedExpression */: + ts.Debug.type(node); return factory.updatePartiallyEmittedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 337 /* CommaListExpression */: + case 345 /* CommaListExpression */: + ts.Debug.type(node); return factory.updateCommaListExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: // No need to visit nodes with no children. @@ -81422,6 +84507,7 @@ var ts; var sourcesContent; var names = []; var nameToNameIndexMap; + var mappingCharCodes = []; var mappings = ""; // Last recorded and encoded mappings var lastGeneratedLine = 0; @@ -81596,6 +84682,14 @@ var ts; || lastSourceCharacter !== pendingSourceCharacter || lastNameIndex !== pendingNameIndex; } + function appendMappingCharCode(charCode) { + mappingCharCodes.push(charCode); + // String.fromCharCode accepts its arguments on the stack, so we have to chunk the input, + // otherwise we can get stack overflows for large source maps + if (mappingCharCodes.length >= 1024) { + flushMappingBuffer(); + } + } function commitPendingMapping() { if (!hasPending || !shouldCommitMapping()) { return; @@ -81605,42 +84699,50 @@ var ts; if (lastGeneratedLine < pendingGeneratedLine) { // Emit line delimiters do { - mappings += ";"; + appendMappingCharCode(59 /* semicolon */); lastGeneratedLine++; - lastGeneratedCharacter = 0; } while (lastGeneratedLine < pendingGeneratedLine); + // Only need to set this once + lastGeneratedCharacter = 0; } else { ts.Debug.assertEqual(lastGeneratedLine, pendingGeneratedLine, "generatedLine cannot backtrack"); // Emit comma to separate the entry if (hasLast) { - mappings += ","; + appendMappingCharCode(44 /* comma */); } } // 1. Relative generated character - mappings += base64VLQFormatEncode(pendingGeneratedCharacter - lastGeneratedCharacter); + appendBase64VLQ(pendingGeneratedCharacter - lastGeneratedCharacter); lastGeneratedCharacter = pendingGeneratedCharacter; if (hasPendingSource) { // 2. Relative sourceIndex - mappings += base64VLQFormatEncode(pendingSourceIndex - lastSourceIndex); + appendBase64VLQ(pendingSourceIndex - lastSourceIndex); lastSourceIndex = pendingSourceIndex; // 3. Relative source line - mappings += base64VLQFormatEncode(pendingSourceLine - lastSourceLine); + appendBase64VLQ(pendingSourceLine - lastSourceLine); lastSourceLine = pendingSourceLine; // 4. Relative source character - mappings += base64VLQFormatEncode(pendingSourceCharacter - lastSourceCharacter); + appendBase64VLQ(pendingSourceCharacter - lastSourceCharacter); lastSourceCharacter = pendingSourceCharacter; if (hasPendingName) { // 5. Relative nameIndex - mappings += base64VLQFormatEncode(pendingNameIndex - lastNameIndex); + appendBase64VLQ(pendingNameIndex - lastNameIndex); lastNameIndex = pendingNameIndex; } } hasLast = true; exit(); } + function flushMappingBuffer() { + if (mappingCharCodes.length > 0) { + mappings += String.fromCharCode.apply(undefined, mappingCharCodes); + mappingCharCodes.length = 0; + } + } function toJSON() { commitPendingMapping(); + flushMappingBuffer(); return { version: 3, file: file, @@ -81651,10 +84753,33 @@ var ts; sourcesContent: sourcesContent, }; } + function appendBase64VLQ(inValue) { + // Add a new least significant bit that has the sign of the value. + // if negative number the least significant bit that gets added to the number has value 1 + // else least significant bit value that gets added is 0 + // eg. -1 changes to binary : 01 [1] => 3 + // +1 changes to binary : 01 [0] => 2 + if (inValue < 0) { + inValue = ((-inValue) << 1) + 1; + } + else { + inValue = inValue << 1; + } + // Encode 5 bits at a time starting from least significant bits + do { + var currentDigit = inValue & 31; // 11111 + inValue = inValue >> 5; + if (inValue > 0) { + // There are still more digits to decode, set the msb (6th bit) + currentDigit = currentDigit | 32; + } + appendMappingCharCode(base64FormatEncode(currentDigit)); + } while (inValue > 0); + } } ts.createSourceMapGenerator = createSourceMapGenerator; // Sometimes tools can see the following line as a source mapping url comment, so we mangle it a bit (the [M]) - var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)\s*$/; + var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)$/; var whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/; function getLineInfo(text, lineStarts) { return { @@ -81671,7 +84796,7 @@ var ts; var line = lineInfo.getLineText(index); var comment = sourceMapCommentRegExp.exec(line); if (comment) { - return comment[1]; + return ts.trimStringEnd(comment[1]); } // If we see a non-whitespace/map comment-like line, break, to avoid scanning up the entire file else if (!line.match(whitespaceOrMapCommentRegExp)) { @@ -81877,31 +85002,6 @@ var ts; ch === 47 /* slash */ ? 63 : -1; } - function base64VLQFormatEncode(inValue) { - // Add a new least significant bit that has the sign of the value. - // if negative number the least significant bit that gets added to the number has value 1 - // else least significant bit value that gets added is 0 - // eg. -1 changes to binary : 01 [1] => 3 - // +1 changes to binary : 01 [0] => 2 - if (inValue < 0) { - inValue = ((-inValue) << 1) + 1; - } - else { - inValue = inValue << 1; - } - // Encode 5 bits at a time starting from least significant bits - var encodedStr = ""; - do { - var currentDigit = inValue & 31; // 11111 - inValue = inValue >> 5; - if (inValue > 0) { - // There are still more digits to decode, set the msb (6th bit) - currentDigit = currentDigit | 32; - } - encodedStr = encodedStr + String.fromCharCode(base64FormatEncode(currentDigit)); - } while (inValue > 0); - return encodedStr; - } function isSourceMappedPosition(value) { return value.sourceIndex !== undefined && value.sourcePosition !== undefined; @@ -82065,7 +85165,7 @@ var ts; function chainBundle(context, transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 297 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 299 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return context.factory.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -82116,7 +85216,7 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" @@ -82129,13 +85229,13 @@ var ts; hasImportDefault = true; } break; - case 260 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 272 /* ExternalModuleReference */) { + case 262 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 274 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -82166,13 +85266,13 @@ var ts; addExportedNamesForExportDeclaration(node); } break; - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: if (ts.hasSyntacticModifier(node, 1 /* Export */)) { for (var _b = 0, _c = node.declarationList.declarations; _b < _c.length; _b++) { var decl = _c[_b]; @@ -82180,7 +85280,7 @@ var ts; } } break; - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: if (ts.hasSyntacticModifier(node, 1 /* Export */)) { if (ts.hasSyntacticModifier(node, 512 /* Default */)) { // export default function() { } @@ -82200,7 +85300,7 @@ var ts; } } break; - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: if (ts.hasSyntacticModifier(node, 1 /* Export */)) { if (ts.hasSyntacticModifier(node, 512 /* Default */)) { // export default class { } @@ -82294,32 +85394,31 @@ var ts; * any such locations */ function isSimpleInlineableExpression(expression) { - return !ts.isIdentifier(expression) && isSimpleCopiableExpression(expression) || - ts.isWellKnownSymbolSyntactically(expression); + return !ts.isIdentifier(expression) && isSimpleCopiableExpression(expression); } ts.isSimpleInlineableExpression = isSimpleInlineableExpression; function isCompoundAssignment(kind) { - return kind >= 63 /* FirstCompoundAssignment */ - && kind <= 77 /* LastCompoundAssignment */; + return kind >= 64 /* FirstCompoundAssignment */ + && kind <= 78 /* LastCompoundAssignment */; } ts.isCompoundAssignment = isCompoundAssignment; function getNonAssignmentOperatorForCompoundAssignment(kind) { switch (kind) { - case 63 /* PlusEqualsToken */: return 39 /* PlusToken */; - case 64 /* MinusEqualsToken */: return 40 /* MinusToken */; - case 65 /* AsteriskEqualsToken */: return 41 /* AsteriskToken */; - case 66 /* AsteriskAsteriskEqualsToken */: return 42 /* AsteriskAsteriskToken */; - case 67 /* SlashEqualsToken */: return 43 /* SlashToken */; - case 68 /* PercentEqualsToken */: return 44 /* PercentToken */; - case 69 /* LessThanLessThanEqualsToken */: return 47 /* LessThanLessThanToken */; - case 70 /* GreaterThanGreaterThanEqualsToken */: return 48 /* GreaterThanGreaterThanToken */; - case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 49 /* GreaterThanGreaterThanGreaterThanToken */; - case 72 /* AmpersandEqualsToken */: return 50 /* AmpersandToken */; - case 73 /* BarEqualsToken */: return 51 /* BarToken */; - case 77 /* CaretEqualsToken */: return 52 /* CaretToken */; - case 74 /* BarBarEqualsToken */: return 56 /* BarBarToken */; - case 75 /* AmpersandAmpersandEqualsToken */: return 55 /* AmpersandAmpersandToken */; - case 76 /* QuestionQuestionEqualsToken */: return 60 /* QuestionQuestionToken */; + 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 */; } } ts.getNonAssignmentOperatorForCompoundAssignment = getNonAssignmentOperatorForCompoundAssignment; @@ -82374,10 +85473,19 @@ var ts; * @param isStatic A value indicating whether the member should be a static or instance member. */ function isInitializedProperty(member) { - return member.kind === 163 /* PropertyDeclaration */ + return member.kind === 165 /* PropertyDeclaration */ && member.initializer !== undefined; } ts.isInitializedProperty = isInitializedProperty; + /** + * Gets a value indicating whether a class element is a private instance method or accessor. + * + * @param member The class element node. + */ + function isNonStaticMethodOrAccessorWithPrivateName(member) { + return !ts.hasStaticModifier(member) && ts.isMethodOrAccessor(member) && ts.isPrivateIdentifier(member.name); + } + ts.isNonStaticMethodOrAccessorWithPrivateName = isNonStaticMethodOrAccessorWithPrivateName; })(ts || (ts = {})); /*@internal*/ var ts; @@ -82651,8 +85759,8 @@ var ts; if (!ts.getRestIndicatorOfBindingOrAssignmentElement(element)) { var propertyName = ts.getPropertyNameOfBindingOrAssignmentElement(element); if (flattenContext.level >= 1 /* ObjectRest */ - && !(element.transformFlags & (8192 /* ContainsRestOrSpread */ | 16384 /* ContainsObjectRestOrSpread */)) - && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (8192 /* ContainsRestOrSpread */ | 16384 /* ContainsObjectRestOrSpread */)) + && !(element.transformFlags & (16384 /* ContainsRestOrSpread */ | 32768 /* ContainsObjectRestOrSpread */)) + && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (16384 /* ContainsRestOrSpread */ | 32768 /* ContainsObjectRestOrSpread */)) && !ts.isComputedPropertyName(propertyName)) { bindingElements = ts.append(bindingElements, ts.visitNode(element, flattenContext.visitor)); } @@ -82718,7 +85826,7 @@ var ts; if (flattenContext.level >= 1 /* 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 & 16384 /* ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) { + if (element.transformFlags & 32768 /* ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) { flattenContext.hasTransformedPriorElement = true; var temp = flattenContext.context.factory.createTempVariable(/*recordTempVariable*/ undefined); if (flattenContext.hoistTempVariables) { @@ -82976,8 +86084,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(201 /* PropertyAccessExpression */); - context.enableSubstitution(202 /* ElementAccessExpression */); + context.enableSubstitution(203 /* PropertyAccessExpression */); + context.enableSubstitution(204 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -83003,14 +86111,14 @@ var ts; var applicableSubstitutions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 298 /* Bundle */) { + if (node.kind === 300 /* 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 === 300 /* InputFiles */) { + if (prepend.kind === 302 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend, "js"); } return prepend; @@ -83061,16 +86169,16 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 297 /* SourceFile */: - case 258 /* CaseBlock */: - case 257 /* ModuleBlock */: - case 230 /* Block */: + case 299 /* SourceFile */: + case 260 /* CaseBlock */: + case 259 /* ModuleBlock */: + case 232 /* Block */: currentLexicalScope = node; currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 252 /* ClassDeclaration */: - case 251 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: + case 253 /* FunctionDeclaration */: if (ts.hasSyntacticModifier(node, 2 /* Ambient */)) { break; } @@ -83082,7 +86190,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 === 252 /* ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 254 /* ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* Default */)); } if (ts.isClassDeclaration(node)) { // XXX: should probably also cover interfaces and type aliases that can have type variables? @@ -83125,10 +86233,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: - case 260 /* ImportEqualsDeclaration */: - case 266 /* ExportAssignment */: - case 267 /* ExportDeclaration */: + case 263 /* ImportDeclaration */: + case 262 /* ImportEqualsDeclaration */: + case 268 /* ExportAssignment */: + case 269 /* ExportDeclaration */: return visitElidableStatement(node); default: return visitorWorker(node); @@ -83149,13 +86257,13 @@ var ts; return node; } switch (node.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return visitImportDeclaration(node); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return visitExportAssignment(node); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -83175,11 +86283,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 267 /* ExportDeclaration */ || - node.kind === 261 /* ImportDeclaration */ || - node.kind === 262 /* ImportClause */ || - (node.kind === 260 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 272 /* ExternalModuleReference */)) { + if (node.kind === 269 /* ExportDeclaration */ || + node.kind === 263 /* ImportDeclaration */ || + node.kind === 264 /* ImportClause */ || + (node.kind === 262 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 274 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -83203,29 +86311,29 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 166 /* Constructor */: + case 168 /* Constructor */: return visitConstructor(node); - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: // Property declarations are not TypeScript syntax, but they must be visited // for the decorator transformation. return visitPropertyDeclaration(node); - case 171 /* IndexSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 165 /* MethodDeclaration */: + case 173 /* IndexSignature */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 167 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 229 /* SemicolonClassElement */: + case 231 /* SemicolonClassElement */: return node; default: return ts.Debug.failBadSyntaxKind(node); } } function modifierVisitor(node) { - if (ts.modifierToFlag(node.kind) & 2270 /* TypeScriptModifier */) { + if (ts.modifierToFlag(node.kind) & 18654 /* TypeScriptModifier */) { return undefined; } - else if (currentNamespace && node.kind === 92 /* ExportKeyword */) { + else if (currentNamespace && node.kind === 93 /* ExportKeyword */) { return undefined; } return node; @@ -83242,71 +86350,71 @@ var ts; return factory.createNotEmittedStatement(node); } switch (node.kind) { - case 92 /* ExportKeyword */: - case 87 /* DefaultKeyword */: + case 93 /* ExportKeyword */: + case 88 /* DefaultKeyword */: // ES6 export and default modifiers are elided when inside a namespace. return currentNamespace ? undefined : node; - case 122 /* PublicKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 125 /* AbstractKeyword */: - case 84 /* ConstKeyword */: - case 133 /* DeclareKeyword */: - case 142 /* ReadonlyKeyword */: + case 123 /* PublicKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + case 126 /* AbstractKeyword */: + case 85 /* ConstKeyword */: + case 134 /* DeclareKeyword */: + case 143 /* ReadonlyKeyword */: // TypeScript accessibility and readonly modifiers are elided // falls through - case 178 /* ArrayType */: - case 179 /* TupleType */: - case 180 /* OptionalType */: - case 181 /* RestType */: - case 177 /* TypeLiteral */: - case 172 /* TypePredicate */: - case 159 /* TypeParameter */: - case 128 /* AnyKeyword */: - case 152 /* UnknownKeyword */: - case 131 /* BooleanKeyword */: - case 147 /* StringKeyword */: - case 144 /* NumberKeyword */: - case 141 /* NeverKeyword */: - case 113 /* VoidKeyword */: - case 148 /* SymbolKeyword */: - case 175 /* ConstructorType */: - case 174 /* FunctionType */: - case 176 /* TypeQuery */: - case 173 /* TypeReference */: - case 182 /* UnionType */: - case 183 /* IntersectionType */: - case 184 /* ConditionalType */: - case 186 /* ParenthesizedType */: - case 187 /* ThisType */: - case 188 /* TypeOperator */: - case 189 /* IndexedAccessType */: - case 190 /* MappedType */: - case 191 /* LiteralType */: + case 180 /* ArrayType */: + case 181 /* TupleType */: + case 182 /* OptionalType */: + case 183 /* RestType */: + case 179 /* TypeLiteral */: + case 174 /* TypePredicate */: + case 161 /* TypeParameter */: + case 129 /* AnyKeyword */: + case 153 /* UnknownKeyword */: + case 132 /* BooleanKeyword */: + case 148 /* StringKeyword */: + case 145 /* NumberKeyword */: + case 142 /* NeverKeyword */: + case 114 /* VoidKeyword */: + case 149 /* SymbolKeyword */: + case 177 /* ConstructorType */: + case 176 /* FunctionType */: + case 178 /* TypeQuery */: + case 175 /* TypeReference */: + case 184 /* UnionType */: + case 185 /* IntersectionType */: + case 186 /* ConditionalType */: + case 188 /* ParenthesizedType */: + case 189 /* ThisType */: + case 190 /* TypeOperator */: + case 191 /* IndexedAccessType */: + case 192 /* MappedType */: + case 193 /* LiteralType */: // TypeScript type nodes are elided. // falls through - case 171 /* IndexSignature */: + case 173 /* IndexSignature */: // TypeScript index signatures are elided. // falls through - case 161 /* Decorator */: + case 163 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. // falls through - case 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return undefined; - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: // TypeScript property declarations are elided. However their names are still visited, and can potentially be retained if they could have sideeffects return visitPropertyDeclaration(node); - case 259 /* NamespaceExportDeclaration */: + case 261 /* NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; - case 166 /* Constructor */: + case 168 /* Constructor */: return visitConstructor(node); - case 253 /* InterfaceDeclaration */: + case 255 /* 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 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: // This may be a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -83316,7 +86424,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: // This may be a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -83326,35 +86434,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 286 /* HeritageClause */: + case 288 /* HeritageClause */: // This may be a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 167 /* GetAccessor */: + case 169 /* GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 168 /* SetAccessor */: + case 170 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 160 /* Parameter */: + case 162 /* Parameter */: // This may be a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -83364,40 +86472,40 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 206 /* TypeAssertionExpression */: - case 224 /* AsExpression */: + case 208 /* TypeAssertionExpression */: + case 226 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return visitCallExpression(node); - case 204 /* NewExpression */: + case 206 /* NewExpression */: return visitNewExpression(node); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 225 /* NonNullExpression */: + case 227 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); - case 274 /* JsxSelfClosingElement */: + case 276 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node); - case 275 /* JsxOpeningElement */: + case 277 /* JsxOpeningElement */: return visitJsxJsxOpeningElement(node); default: // node contains some other TypeScript syntax @@ -83434,7 +86542,7 @@ var ts; if (ts.some(staticProperties)) facts |= 1 /* HasStaticInitializedProperties */; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 103 /* NullKeyword */) + if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */) facts |= 64 /* IsDerivedClass */; if (shouldEmitDecorateCallForClass(node)) facts |= 2 /* HasConstructorDecorators */; @@ -83451,7 +86559,7 @@ var ts; return facts; } function hasTypeScriptClassSyntax(node) { - return !!(node.transformFlags & 2048 /* ContainsTypeScriptClassSyntax */); + return !!(node.transformFlags & 4096 /* ContainsTypeScriptClassSyntax */); } function isClassLikeDeclarationWithTypeScriptSyntax(node) { return ts.some(node.decorators) @@ -83806,12 +86914,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -83964,7 +87072,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ true); var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 163 /* PropertyDeclaration */ + ? member.kind === 165 /* 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() @@ -84088,10 +87196,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 165 /* MethodDeclaration */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */ - || kind === 163 /* PropertyDeclaration */; + return kind === 167 /* MethodDeclaration */ + || kind === 169 /* GetAccessor */ + || kind === 170 /* SetAccessor */ + || kind === 165 /* PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -84101,7 +87209,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 165 /* MethodDeclaration */; + return node.kind === 167 /* MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -84112,12 +87220,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return true; } return false; @@ -84134,15 +87242,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 163 /* PropertyDeclaration */: - case 160 /* Parameter */: + case 165 /* PropertyDeclaration */: + case 162 /* Parameter */: return serializeTypeNode(node.type); - case 168 /* SetAccessor */: - case 167 /* GetAccessor */: + case 170 /* SetAccessor */: + case 169 /* GetAccessor */: return serializeTypeNode(getAccessorTypeNode(node)); - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 165 /* MethodDeclaration */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 167 /* MethodDeclaration */: return factory.createIdentifier("Function"); default: return factory.createVoidZero(); @@ -84179,7 +87287,7 @@ var ts; return factory.createArrayLiteralExpression(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 167 /* GetAccessor */) { + if (container && node.kind === 169 /* GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -84224,82 +87332,82 @@ var ts; return factory.createIdentifier("Object"); } switch (node.kind) { - case 113 /* VoidKeyword */: - case 150 /* UndefinedKeyword */: - case 141 /* NeverKeyword */: + case 114 /* VoidKeyword */: + case 151 /* UndefinedKeyword */: + case 142 /* NeverKeyword */: return factory.createVoidZero(); - case 186 /* ParenthesizedType */: + case 188 /* ParenthesizedType */: return serializeTypeNode(node.type); - case 174 /* FunctionType */: - case 175 /* ConstructorType */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: return factory.createIdentifier("Function"); - case 178 /* ArrayType */: - case 179 /* TupleType */: + case 180 /* ArrayType */: + case 181 /* TupleType */: return factory.createIdentifier("Array"); - case 172 /* TypePredicate */: - case 131 /* BooleanKeyword */: + case 174 /* TypePredicate */: + case 132 /* BooleanKeyword */: return factory.createIdentifier("Boolean"); - case 147 /* StringKeyword */: + case 148 /* StringKeyword */: return factory.createIdentifier("String"); - case 145 /* ObjectKeyword */: + case 146 /* ObjectKeyword */: return factory.createIdentifier("Object"); - case 191 /* LiteralType */: + case 193 /* LiteralType */: switch (node.literal.kind) { case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return factory.createIdentifier("String"); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: case 8 /* NumericLiteral */: return factory.createIdentifier("Number"); case 9 /* BigIntLiteral */: return getGlobalBigIntNameWithFallback(); - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: + case 110 /* TrueKeyword */: + case 95 /* FalseKeyword */: return factory.createIdentifier("Boolean"); - case 103 /* NullKeyword */: + case 104 /* NullKeyword */: return factory.createVoidZero(); default: return ts.Debug.failBadSyntaxKind(node.literal); } - case 144 /* NumberKeyword */: + case 145 /* NumberKeyword */: return factory.createIdentifier("Number"); - case 155 /* BigIntKeyword */: + case 156 /* BigIntKeyword */: return getGlobalBigIntNameWithFallback(); - case 148 /* SymbolKeyword */: + case 149 /* SymbolKeyword */: return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : factory.createIdentifier("Symbol"); - case 173 /* TypeReference */: + case 175 /* TypeReference */: return serializeTypeReferenceNode(node); - case 183 /* IntersectionType */: - case 182 /* UnionType */: + case 185 /* IntersectionType */: + case 184 /* UnionType */: return serializeTypeList(node.types); - case 184 /* ConditionalType */: + case 186 /* ConditionalType */: return serializeTypeList([node.trueType, node.falseType]); - case 188 /* TypeOperator */: - if (node.operator === 142 /* ReadonlyKeyword */) { + case 190 /* TypeOperator */: + if (node.operator === 143 /* ReadonlyKeyword */) { return serializeTypeNode(node.type); } break; - case 176 /* TypeQuery */: - case 189 /* IndexedAccessType */: - case 190 /* MappedType */: - case 177 /* TypeLiteral */: - case 128 /* AnyKeyword */: - case 152 /* UnknownKeyword */: - case 187 /* ThisType */: - case 195 /* ImportType */: + case 178 /* TypeQuery */: + case 191 /* IndexedAccessType */: + case 192 /* MappedType */: + case 179 /* TypeLiteral */: + case 129 /* AnyKeyword */: + case 153 /* UnknownKeyword */: + case 189 /* ThisType */: + case 197 /* ImportType */: break; // handle JSDoc types from an invalid parse - case 303 /* JSDocAllType */: - case 304 /* JSDocUnknownType */: - case 308 /* JSDocFunctionType */: - case 309 /* JSDocVariadicType */: - case 310 /* JSDocNamepathType */: + case 306 /* JSDocAllType */: + case 307 /* JSDocUnknownType */: + case 311 /* JSDocFunctionType */: + case 312 /* JSDocVariadicType */: + case 313 /* JSDocNamepathType */: break; - case 305 /* JSDocNullableType */: - case 306 /* JSDocNonNullableType */: - case 307 /* JSDocOptionalType */: + case 308 /* JSDocNullableType */: + case 309 /* JSDocNonNullableType */: + case 310 /* JSDocOptionalType */: return serializeTypeNode(node.type); default: return ts.Debug.failBadSyntaxKind(node); @@ -84312,13 +87420,13 @@ var ts; var serializedUnion; for (var _i = 0, types_24 = types; _i < types_24.length; _i++) { var typeNode = types_24[_i]; - while (typeNode.kind === 186 /* ParenthesizedType */) { + while (typeNode.kind === 188 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 141 /* NeverKeyword */) { + if (typeNode.kind === 142 /* NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 191 /* LiteralType */ && typeNode.literal.kind === 103 /* NullKeyword */ || typeNode.kind === 150 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 193 /* LiteralType */ && typeNode.literal.kind === 104 /* NullKeyword */ || typeNode.kind === 151 /* UndefinedKeyword */)) { continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks } var serializedIndividual = serializeTypeNode(typeNode); @@ -84400,12 +87508,12 @@ var ts; * @param node The entity name to serialize. */ function serializeEntityNameAsExpressionFallback(node) { - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { // A -> typeof A !== undefined && A var copied = serializeEntityNameAsExpression(node); return createCheckedValue(copied, copied); } - if (node.left.kind === 78 /* Identifier */) { + if (node.left.kind === 79 /* Identifier */) { // A.B -> typeof A !== undefined && A.B return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node)); } @@ -84421,14 +87529,14 @@ var ts; */ function serializeEntityNameAsExpression(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* 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 157 /* QualifiedName */: + case 159 /* QualifiedName */: return serializeQualifiedNameAsExpression(node); } } @@ -84519,7 +87627,7 @@ var ts; * @param node The HeritageClause to transform. */ function visitHeritageClause(node) { - if (node.token === 116 /* ImplementsKeyword */) { + if (node.token === 117 /* ImplementsKeyword */) { // implements clauses are elided return undefined; } @@ -84816,8 +87924,7 @@ var ts; */ function shouldEmitEnumDeclaration(node) { return !ts.isEnumConst(node) - || compilerOptions.preserveConstEnums - || compilerOptions.isolatedModules; + || ts.shouldPreserveConstEnums(compilerOptions); } /** * Visits an enum declaration. @@ -84951,7 +88058,7 @@ var ts; // If we can't find a parse tree node, assume the node is instantiated. return true; } - return ts.isInstantiatedModule(node, !!compilerOptions.preserveConstEnums || !!compilerOptions.isolatedModules); + return ts.isInstantiatedModule(node, ts.shouldPreserveConstEnums(compilerOptions)); } /** * Determines whether an exported declaration will have a qualified export name (e.g. `f.x` @@ -85002,12 +88109,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 === 297 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 299 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { // Adjust the source map emit to match the old emitter. - if (node.kind === 255 /* EnumDeclaration */) { + if (node.kind === 257 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -85132,7 +88239,7 @@ var ts; var statementsLocation; var blockLocation; if (node.body) { - if (node.body.kind === 257 /* ModuleBlock */) { + if (node.body.kind === 259 /* ModuleBlock */) { saveStateAndInvoke(node.body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = node.body.statements; blockLocation = node.body; @@ -85179,13 +88286,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 !== 257 /* ModuleBlock */) { + if (!node.body || node.body.kind !== 259 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 256 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 258 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -85235,7 +88342,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 263 /* NamespaceImport */) { + if (node.kind === 265 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -85469,7 +88576,7 @@ var ts; function enableSubstitutionForNonQualifiedEnumMembers() { if ((enabledSubstitutions & 8 /* NonQualifiedEnumMembers */) === 0) { enabledSubstitutions |= 8 /* NonQualifiedEnumMembers */; - context.enableSubstitution(78 /* Identifier */); + context.enableSubstitution(79 /* Identifier */); } } function enableSubstitutionForClassAliases() { @@ -85477,7 +88584,7 @@ var ts; enabledSubstitutions |= 1 /* ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(78 /* Identifier */); + context.enableSubstitution(79 /* Identifier */); // Keep track of class aliases. classAliases = []; } @@ -85487,17 +88594,17 @@ var ts; enabledSubstitutions |= 2 /* 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(78 /* Identifier */); - context.enableSubstitution(289 /* ShorthandPropertyAssignment */); + context.enableSubstitution(79 /* Identifier */); + context.enableSubstitution(291 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(256 /* ModuleDeclaration */); + context.enableEmitNotification(258 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 256 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 258 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 255 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 257 /* EnumDeclaration */; } /** * Hook for node emit. @@ -85556,11 +88663,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return substituteExpressionIdentifier(node); - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -85582,10 +88689,10 @@ var ts; if (declaration) { var classAlias = classAliases[declaration.id]; // TODO: GH#18217 if (classAlias) { - var clone_1 = factory.cloneNode(classAlias); - ts.setSourceMapRange(clone_1, node); - ts.setCommentRange(clone_1, node); - return clone_1; + var clone_2 = factory.cloneNode(classAlias); + ts.setSourceMapRange(clone_2, node); + ts.setCommentRange(clone_2, node); + return clone_2; } } } @@ -85598,9 +88705,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 !== 297 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 256 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 255 /* EnumDeclaration */); + if (container && container.kind !== 299 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 258 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 257 /* EnumDeclaration */); if (substitute) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(container), node), /*location*/ node); @@ -85652,10 +88759,12 @@ var ts; */ ClassPropertySubstitutionFlags[ClassPropertySubstitutionFlags["ClassAliases"] = 1] = "ClassAliases"; })(ClassPropertySubstitutionFlags || (ClassPropertySubstitutionFlags = {})); - var PrivateIdentifierPlacement; - (function (PrivateIdentifierPlacement) { - PrivateIdentifierPlacement[PrivateIdentifierPlacement["InstanceField"] = 0] = "InstanceField"; - })(PrivateIdentifierPlacement || (PrivateIdentifierPlacement = {})); + var PrivateIdentifierKind; + (function (PrivateIdentifierKind) { + PrivateIdentifierKind["Field"] = "f"; + PrivateIdentifierKind["Method"] = "m"; + PrivateIdentifierKind["Accessor"] = "a"; + })(PrivateIdentifierKind = ts.PrivateIdentifierKind || (ts.PrivateIdentifierKind = {})); /** * Transforms ECMAScript Class Syntax. * TypeScript parameter property syntax is transformed in the TypeScript transformer. @@ -85664,11 +88773,12 @@ var ts; * When --useDefineForClassFields is on, this transforms to ECMAScript semantics, with Object.defineProperty. */ function transformClassFields(context) { - var factory = context.factory, hoistVariableDeclaration = context.hoistVariableDeclaration, endLexicalEnvironment = context.endLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment; + var factory = context.factory, hoistVariableDeclaration = context.hoistVariableDeclaration, endLexicalEnvironment = context.endLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, addBlockScopedVariable = context.addBlockScopedVariable; var resolver = context.getEmitResolver(); var compilerOptions = context.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); - var shouldTransformPrivateFields = languageVersion < 99 /* ESNext */; + var useDefineForClassFields = ts.getUseDefineForClassFields(compilerOptions); + var shouldTransformPrivateElements = languageVersion < 99 /* ESNext */; var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; var enabledSubstitutions; @@ -85689,7 +88799,7 @@ var ts; function transformSourceFile(node) { var options = context.getCompilerOptions(); if (node.isDeclarationFile - || options.useDefineForClassFields && options.target === 99 /* ESNext */) { + || useDefineForClassFields && options.target === 99 /* ESNext */) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -85697,41 +88807,41 @@ var ts; return visited; } function visitor(node) { - if (!(node.transformFlags & 4194304 /* ContainsClassFields */)) + if (!(node.transformFlags & 8388608 /* ContainsClassFields */)) return node; switch (node.kind) { - case 221 /* ClassExpression */: - case 252 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 254 /* ClassDeclaration */: return visitClassLike(node); - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return visitPropertyDeclaration(node); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return visitVariableStatement(node); - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return visitPropertyAccessExpression(node); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return visitPrefixUnaryExpression(node); - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: return visitPostfixUnaryExpression(node, /*valueIsDiscarded*/ false); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return visitCallExpression(node); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return visitBinaryExpression(node); - case 79 /* PrivateIdentifier */: + case 80 /* PrivateIdentifier */: return visitPrivateIdentifier(node); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: return visitExpressionStatement(node); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return visitForStatement(node); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); } return ts.visitEachChild(node, visitor, context); } function visitorDestructuringTarget(node) { switch (node.kind) { - case 200 /* ObjectLiteralExpression */: - case 199 /* ArrayLiteralExpression */: + case 202 /* ObjectLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return visitAssignmentPattern(node); default: return visitor(node); @@ -85742,7 +88852,7 @@ var ts; * Replace it with an empty identifier to indicate a problem with the code. */ function visitPrivateIdentifier(node) { - if (!shouldTransformPrivateFields) { + if (!shouldTransformPrivateElements) { return node; } return ts.setOriginalNode(factory.createIdentifier(""), node); @@ -85754,20 +88864,19 @@ var ts; */ function classElementVisitor(node) { switch (node.kind) { - case 166 /* Constructor */: + case 168 /* Constructor */: // Constructors for classes using class fields are transformed in // `visitClassDeclaration` or `visitClassExpression`. return undefined; - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 165 /* MethodDeclaration */: - // Visit the name of the member (if it's a computed property name). - return ts.visitEachChild(node, classElementVisitor, context); - case 163 /* PropertyDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 167 /* MethodDeclaration */: + return visitMethodOrAccessorDeclaration(node); + case 165 /* PropertyDeclaration */: return visitPropertyDeclaration(node); - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 229 /* SemicolonClassElement */: + case 231 /* SemicolonClassElement */: return node; default: return visitor(node); @@ -85792,44 +88901,96 @@ var ts; } return node; } + function visitMethodOrAccessorDeclaration(node) { + ts.Debug.assert(!ts.some(node.decorators)); + if (!shouldTransformPrivateElements || !ts.isPrivateIdentifier(node.name)) { + return ts.visitEachChild(node, classElementVisitor, context); + } + // leave invalid code untransformed + var info = accessPrivateIdentifier(node.name); + ts.Debug.assert(info, "Undeclared private name for property declaration."); + if (!info.isValid) { + return node; + } + var functionName = getHoistedFunctionName(node); + if (functionName) { + getPendingExpressions().push(factory.createAssignment(functionName, factory.createFunctionExpression(ts.filter(node.modifiers, function (m) { return !ts.isStaticModifier(m); }), node.asteriskToken, functionName, + /* typeParameters */ undefined, ts.visitParameterList(node.parameters, classElementVisitor, context), + /* type */ undefined, ts.visitFunctionBody(node.body, classElementVisitor, context)))); + } + // remove method declaration from class + return undefined; + } + function getHoistedFunctionName(node) { + 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 */) { + return info.methodName; + } + if (info.kind === "a" /* Accessor */) { + if (ts.isGetAccessor(node)) { + return info.getterName; + } + if (ts.isSetAccessor(node)) { + return info.setterName; + } + } + } function visitPropertyDeclaration(node) { ts.Debug.assert(!ts.some(node.decorators)); - if (!shouldTransformPrivateFields && ts.isPrivateIdentifier(node.name)) { - // Initializer is elided as the field is initialized in transformConstructor. - return factory.updatePropertyDeclaration(node, - /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name, - /*questionOrExclamationToken*/ undefined, - /*type*/ undefined, - /*initializer*/ undefined); + if (ts.isPrivateIdentifier(node.name)) { + if (!shouldTransformPrivateElements) { + // Initializer is elided as the field is initialized in transformConstructor. + return factory.updatePropertyDeclaration(node, + /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name, + /*questionOrExclamationToken*/ undefined, + /*type*/ undefined, + /*initializer*/ undefined); + } + // leave invalid code untransformed + var info = accessPrivateIdentifier(node.name); + ts.Debug.assert(info, "Undeclared private name for property declaration."); + if (!info.isValid) { + return node; + } } // Create a temporary variable to store a computed property name (if necessary). // If it's not inlineable, then we emit an expression after the class which assigns // the property name to the temporary variable. - var expr = getPropertyNameExpressionIfNeeded(node.name, !!node.initializer || !!context.getCompilerOptions().useDefineForClassFields); + var expr = getPropertyNameExpressionIfNeeded(node.name, !!node.initializer || useDefineForClassFields); if (expr && !ts.isSimpleInlineableExpression(expr)) { getPendingExpressions().push(expr); } return undefined; } function createPrivateIdentifierAccess(info, receiver) { - receiver = ts.visitNode(receiver, visitor, ts.isExpression); - switch (info.placement) { - case 0 /* InstanceField */: - return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(ts.nodeIsSynthesized(receiver) ? receiver : factory.cloneNode(receiver), info.weakMapName); - default: return ts.Debug.fail("Unexpected private identifier placement"); + return createPrivateIdentifierAccessHelper(info, ts.visitNode(receiver, visitor, ts.isExpression)); + } + function createPrivateIdentifierAccessHelper(info, receiver) { + ts.setCommentRange(receiver, ts.moveRangePos(receiver, -1)); + switch (info.kind) { + case "a" /* Accessor */: + return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.getterName); + case "m" /* Method */: + return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.methodName); + case "f" /* Field */: + return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.variableName); + default: + ts.Debug.assertNever(info, "Unknown private element type"); } } function visitPropertyAccessExpression(node) { - if (shouldTransformPrivateFields && ts.isPrivateIdentifier(node.name)) { + if (shouldTransformPrivateElements && ts.isPrivateIdentifier(node.name)) { var privateIdentifierInfo = accessPrivateIdentifier(node.name); if (privateIdentifierInfo) { - return ts.setOriginalNode(createPrivateIdentifierAccess(privateIdentifierInfo, node.expression), node); + return ts.setTextRange(ts.setOriginalNode(createPrivateIdentifierAccess(privateIdentifierInfo, node.expression), node), node); } } return ts.visitEachChild(node, visitor, context); } function visitPrefixUnaryExpression(node) { - if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { + if (shouldTransformPrivateElements && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { var operator = node.operator === 45 /* PlusPlusToken */ ? 39 /* PlusToken */ : node.operator === 46 /* MinusMinusToken */ ? 40 /* MinusToken */ : undefined; @@ -85838,13 +88999,13 @@ var ts; var receiver = ts.visitNode(node.operand.expression, visitor, ts.isExpression); var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression; var existingValue = factory.createPrefixUnaryExpression(39 /* PlusToken */, createPrivateIdentifierAccess(info, readExpression)); - return ts.setOriginalNode(createPrivateIdentifierAssignment(info, initializeExpression || readExpression, factory.createBinaryExpression(existingValue, operator, factory.createNumericLiteral(1)), 62 /* EqualsToken */), node); + return ts.setOriginalNode(createPrivateIdentifierAssignment(info, initializeExpression || readExpression, factory.createBinaryExpression(existingValue, operator, factory.createNumericLiteral(1)), 63 /* EqualsToken */), node); } } return ts.visitEachChild(node, visitor, context); } function visitPostfixUnaryExpression(node, valueIsDiscarded) { - if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { + if (shouldTransformPrivateElements && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { var operator = node.operator === 45 /* PlusPlusToken */ ? 39 /* PlusToken */ : node.operator === 46 /* MinusMinusToken */ ? 40 /* MinusToken */ : undefined; @@ -85856,7 +89017,7 @@ var ts; // Create a temporary variable to store the value returned by the expression. var returnValue = valueIsDiscarded ? undefined : factory.createTempVariable(hoistVariableDeclaration); return ts.setOriginalNode(factory.inlineExpressions(ts.compact([ - createPrivateIdentifierAssignment(info, initializeExpression || readExpression, factory.createBinaryExpression(returnValue ? factory.createAssignment(returnValue, existingValue) : existingValue, operator, factory.createNumericLiteral(1)), 62 /* EqualsToken */), + createPrivateIdentifierAssignment(info, initializeExpression || readExpression, factory.createBinaryExpression(returnValue ? factory.createAssignment(returnValue, existingValue) : existingValue, operator, factory.createNumericLiteral(1)), 63 /* EqualsToken */), returnValue ])), node); } @@ -85865,7 +89026,7 @@ var ts; } function visitForStatement(node) { if (node.incrementor && ts.isPostfixUnaryExpression(node.incrementor)) { - return factory.updateForStatement(node, ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), visitPostfixUnaryExpression(node.incrementor, /*valueIsDiscarded*/ true), ts.visitNode(node.statement, visitor, ts.isStatement)); + return factory.updateForStatement(node, ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), visitPostfixUnaryExpression(node.incrementor, /*valueIsDiscarded*/ true), ts.visitIterationBody(node.statement, visitor, context)); } return ts.visitEachChild(node, visitor, context); } @@ -85885,16 +89046,21 @@ var ts; return { readExpression: readExpression, initializeExpression: initializeExpression }; } function visitCallExpression(node) { - if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.expression)) { + if (shouldTransformPrivateElements && ts.isPrivateIdentifierPropertyAccessExpression(node.expression)) { // Transform call expressions of private names to properly bind the `this` parameter. var _a = factory.createCallBinding(node.expression, hoistVariableDeclaration, languageVersion), thisArg = _a.thisArg, target = _a.target; + if (ts.isCallChain(node)) { + return factory.updateCallChain(node, factory.createPropertyAccessChain(ts.visitNode(target, visitor), node.questionDotToken, "call"), + /*questionDotToken*/ undefined, + /*typeArguments*/ undefined, __spreadArray([ts.visitNode(thisArg, visitor, ts.isExpression)], ts.visitNodes(node.arguments, visitor, ts.isExpression))); + } return factory.updateCallExpression(node, factory.createPropertyAccessExpression(ts.visitNode(target, visitor), "call"), /*typeArguments*/ undefined, __spreadArray([ts.visitNode(thisArg, visitor, ts.isExpression)], ts.visitNodes(node.arguments, visitor, ts.isExpression))); } return ts.visitEachChild(node, visitor, context); } function visitTaggedTemplateExpression(node) { - if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.tag)) { + if (shouldTransformPrivateElements && ts.isPrivateIdentifierPropertyAccessExpression(node.tag)) { // Bind the `this` correctly for tagged template literals when the tag is a private identifier property access. var _a = factory.createCallBinding(node.tag, hoistVariableDeclaration, languageVersion), thisArg = _a.thisArg, target = _a.target; return factory.updateTaggedTemplateExpression(node, factory.createCallExpression(factory.createPropertyAccessExpression(ts.visitNode(target, visitor), "bind"), @@ -85904,7 +89070,7 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitBinaryExpression(node) { - if (shouldTransformPrivateFields) { + if (shouldTransformPrivateElements) { if (ts.isDestructuringAssignment(node)) { var savedPendingExpressions = pendingExpressions; pendingExpressions = undefined; @@ -85918,29 +89084,31 @@ var ts; if (ts.isAssignmentExpression(node) && ts.isPrivateIdentifierPropertyAccessExpression(node.left)) { var info = accessPrivateIdentifier(node.left.name); if (info) { - return ts.setOriginalNode(createPrivateIdentifierAssignment(info, node.left.expression, node.right, node.operatorToken.kind), node); + return ts.setTextRange(ts.setOriginalNode(createPrivateIdentifierAssignment(info, node.left.expression, node.right, node.operatorToken.kind), node), node); } } } return ts.visitEachChild(node, visitor, context); } function createPrivateIdentifierAssignment(info, receiver, right, operator) { - switch (info.placement) { - case 0 /* InstanceField */: { - return createPrivateIdentifierInstanceFieldAssignment(info, receiver, right, operator); - } - default: return ts.Debug.fail("Unexpected private identifier placement"); - } - } - function createPrivateIdentifierInstanceFieldAssignment(info, receiver, right, operator) { receiver = ts.visitNode(receiver, visitor, ts.isExpression); right = ts.visitNode(right, visitor, ts.isExpression); if (ts.isCompoundAssignment(operator)) { var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression; - return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(initializeExpression || readExpression, info.weakMapName, factory.createBinaryExpression(context.getEmitHelperFactory().createClassPrivateFieldGetHelper(readExpression, info.weakMapName), ts.getNonAssignmentOperatorForCompoundAssignment(operator), right)); - } - else { - return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.weakMapName, right); + receiver = initializeExpression || readExpression; + right = factory.createBinaryExpression(createPrivateIdentifierAccessHelper(info, readExpression), ts.getNonAssignmentOperatorForCompoundAssignment(operator), right); + } + ts.setCommentRange(receiver, ts.moveRangePos(receiver, -1)); + switch (info.kind) { + case "a" /* Accessor */: + return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, info.setterName); + case "m" /* Method */: + return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, + /* f */ undefined); + case "f" /* Field */: + return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, info.variableName); + default: + ts.Debug.assertNever(info, "Unknown private element type"); } } /** @@ -85949,32 +89117,53 @@ var ts; function visitClassLike(node) { var savedPendingExpressions = pendingExpressions; pendingExpressions = undefined; - if (shouldTransformPrivateFields) { + if (shouldTransformPrivateElements) { startPrivateIdentifierEnvironment(); + var name = ts.getNameOfDeclaration(node); + if (name && ts.isIdentifier(name)) { + getPrivateIdentifierEnvironment().className = ts.idText(name); + } + var privateInstanceMethodsAndAccessors = getPrivateInstanceMethodsAndAccessors(node); + if (ts.some(privateInstanceMethodsAndAccessors)) { + getPrivateIdentifierEnvironment().weakSetName = createHoistedVariableForClass("instances", privateInstanceMethodsAndAccessors[0].name); + } } var result = ts.isClassDeclaration(node) ? visitClassDeclaration(node) : visitClassExpression(node); - if (shouldTransformPrivateFields) { + if (shouldTransformPrivateElements) { endPrivateIdentifierEnvironment(); } pendingExpressions = savedPendingExpressions; return result; } function doesClassElementNeedTransform(node) { - return ts.isPropertyDeclaration(node) || (shouldTransformPrivateFields && node.name && ts.isPrivateIdentifier(node.name)); + return ts.isPropertyDeclaration(node) || (shouldTransformPrivateElements && node.name && ts.isPrivateIdentifier(node.name)); + } + function getPrivateInstanceMethodsAndAccessors(node) { + return ts.filter(node.members, ts.isNonStaticMethodOrAccessorWithPrivateName); } function visitClassDeclaration(node) { if (!ts.forEach(node.members, doesClassElementNeedTransform)) { return ts.visitEachChild(node, visitor, context); } + var staticProperties = ts.getProperties(node, /*requireInitializer*/ false, /*isStatic*/ true); + var pendingPrivateStateAssignment; + if (shouldTransformPrivateElements && ts.some(node.members, function (m) { return ts.hasStaticModifier(m) && !!m.name && ts.isPrivateIdentifier(m.name); })) { + var temp = factory.createTempVariable(hoistVariableDeclaration, /* reservedInNestedScopes */ true); + getPrivateIdentifierEnvironment().classConstructor = factory.cloneNode(temp); + pendingPrivateStateAssignment = factory.createAssignment(temp, factory.getInternalName(node)); + } var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 103 /* NullKeyword */); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */); var statements = [ factory.updateClassDeclaration(node, /*decorators*/ undefined, node.modifiers, node.name, /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass)) ]; + if (pendingPrivateStateAssignment) { + getPendingExpressions().unshift(pendingPrivateStateAssignment); + } // Write any pending expressions from elided or moved computed property names if (ts.some(pendingExpressions)) { statements.push(factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))); @@ -85984,7 +89173,6 @@ var ts; // From ES6 specification: // HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using // a lexical declaration such as a LexicalDeclaration or a ClassDeclaration. - var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); if (ts.some(staticProperties)) { addPropertyStatements(statements, staticProperties, factory.getInternalName(node)); } @@ -86002,12 +89190,25 @@ var ts; // class declaration transformation. The VariableStatement visitor will insert // these statements after the class expression variable statement. var isDecoratedClassDeclaration = ts.isClassDeclaration(ts.getOriginalNode(node)); - var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); + var staticProperties = ts.getProperties(node, /*requireInitializer*/ false, /*isStatic*/ true); var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 103 /* NullKeyword */); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */); + var isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */; + var temp; + function createClassTempVar() { + var classCheckFlags = resolver.getNodeCheckFlags(node); + var isClassWithConstructorReference = classCheckFlags & 16777216 /* ClassWithConstructorReference */; + var requiresBlockScopedVar = classCheckFlags & 524288 /* BlockScopedBindingInLoop */; + return factory.createTempVariable(requiresBlockScopedVar ? addBlockScopedVariable : hoistVariableDeclaration, !!isClassWithConstructorReference); + } + if (shouldTransformPrivateElements && ts.some(node.members, function (m) { return ts.hasStaticModifier(m) && !!m.name && ts.isPrivateIdentifier(m.name); })) { + temp = createClassTempVar(); + getPrivateIdentifierEnvironment().classConstructor = factory.cloneNode(temp); + } var classExpression = factory.updateClassExpression(node, ts.visitNodes(node.decorators, visitor, ts.isDecorator), node.modifiers, node.name, /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass)); - if (ts.some(staticProperties) || ts.some(pendingExpressions)) { + var hasTransformableStatics = ts.some(staticProperties, function (p) { return !!p.initializer || (shouldTransformPrivateElements && ts.isPrivateIdentifier(p.name)); }); + if (hasTransformableStatics || ts.some(pendingExpressions)) { if (isDecoratedClassDeclaration) { ts.Debug.assertIsDefined(pendingStatements, "Decorated classes transformed by TypeScript are expected to be within a variable declaration."); // Write any pending expressions from elided or moved computed property names @@ -86017,12 +89218,14 @@ var ts; if (pendingStatements && ts.some(staticProperties)) { addPropertyStatements(pendingStatements, staticProperties, factory.getInternalName(node)); } + if (temp) { + return factory.inlineExpressions([factory.createAssignment(temp, classExpression), temp]); + } return classExpression; } else { var expressions = []; - var isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */; - var temp = factory.createTempVariable(hoistVariableDeclaration, !!isClassWithConstructorReference); + temp || (temp = createClassTempVar()); if (isClassWithConstructorReference) { // record an alias as the class name is not in scope for statics. enableSubstitutionForClassAliases(); @@ -86044,14 +89247,17 @@ var ts; return classExpression; } function transformClassMembers(node, isDerivedClass) { - if (shouldTransformPrivateFields) { + if (shouldTransformPrivateElements) { // Declare private names. for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (ts.isPrivateIdentifierPropertyDeclaration(member)) { - addPrivateIdentifierToEnvironment(member.name); + if (ts.isPrivateIdentifierClassElementDeclaration(member)) { + addPrivateIdentifierToEnvironment(member); } } + if (ts.some(getPrivateInstanceMethodsAndAccessors(node))) { + createBrandCheckWeakSetForPrivateMethods(); + } } var members = []; var constructor = transformConstructor(node, isDerivedClass); @@ -86061,21 +89267,27 @@ var ts; ts.addRange(members, ts.visitNodes(node.members, classElementVisitor, ts.isClassElement)); return ts.setTextRange(factory.createNodeArray(members), /*location*/ node.members); } - function isPropertyDeclarationThatRequiresConstructorStatement(member) { - if (!ts.isPropertyDeclaration(member) || ts.hasStaticModifier(member) || ts.hasSyntacticModifier(ts.getOriginalNode(member), 128 /* Abstract */)) { + function createBrandCheckWeakSetForPrivateMethods() { + var weakSetName = getPrivateIdentifierEnvironment().weakSetName; + ts.Debug.assert(weakSetName, "weakSetName should be set in private identifier environment"); + getPendingExpressions().push(factory.createAssignment(weakSetName, factory.createNewExpression(factory.createIdentifier("WeakSet"), + /*typeArguments*/ undefined, []))); + } + function isClassElementThatRequiresConstructorStatement(member) { + if (ts.hasStaticModifier(member) || ts.hasSyntacticModifier(ts.getOriginalNode(member), 128 /* Abstract */)) { return false; } - if (context.getCompilerOptions().useDefineForClassFields) { + 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 < 99 /* ESNext */; } - return ts.isInitializedProperty(member) || shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyDeclaration(member); + return ts.isInitializedProperty(member) || shouldTransformPrivateElements && ts.isPrivateIdentifierClassElementDeclaration(member); } function transformConstructor(node, isDerivedClass) { var constructor = ts.visitNode(ts.getFirstConstructorWithBody(node), visitor, ts.isConstructorDeclaration); - var properties = node.members.filter(isPropertyDeclarationThatRequiresConstructorStatement); - if (!ts.some(properties)) { + var elements = node.members.filter(isClassElementThatRequiresConstructorStatement); + if (!ts.some(elements)) { return constructor; } var parameters = ts.visitParameterList(constructor ? constructor.parameters : undefined, visitor, context); @@ -86088,13 +89300,14 @@ var ts; /*modifiers*/ undefined, parameters !== null && parameters !== void 0 ? parameters : [], body), constructor || node), constructor)); } function transformConstructorBody(node, constructor, isDerivedClass) { - var useDefineForClassFields = context.getCompilerOptions().useDefineForClassFields; var properties = ts.getProperties(node, /*requireInitializer*/ false, /*isStatic*/ false); if (!useDefineForClassFields) { properties = ts.filter(properties, function (property) { return !!property.initializer || ts.isPrivateIdentifier(property.name); }); } + var privateMethodsAndAccessors = getPrivateInstanceMethodsAndAccessors(node); + var needsConstructorBody = ts.some(properties) || ts.some(privateMethodsAndAccessors); // Only generate synthetic constructor when there are property initializers to move. - if (!constructor && !ts.some(properties)) { + if (!constructor && !needsConstructorBody) { return ts.visitFunctionBody(/*node*/ undefined, visitor, context); } resumeLexicalEnvironment(); @@ -86133,7 +89346,10 @@ var ts; indexOfFirstStatement = afterParameterProperties; } } - addPropertyStatements(statements, properties, factory.createThis()); + var receiver = factory.createThis(); + // private methods can be called in property initializers, they should execute first. + addMethodStatements(statements, privateMethodsAndAccessors, receiver); + addPropertyStatements(statements, properties, receiver); // Add existing statements, skipping the initial super call. if (constructor) { ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement)); @@ -86195,27 +89411,30 @@ var ts; function transformProperty(property, receiver) { var _a; // We generate a name here in order to reuse the value cached by the relocated computed name expression (which uses the same generated name) - var emitAssignment = !context.getCompilerOptions().useDefineForClassFields; + var emitAssignment = !useDefineForClassFields; var propertyName = ts.isComputedPropertyName(property.name) && !ts.isSimpleInlineableExpression(property.name.expression) ? factory.updateComputedPropertyName(property.name, factory.getGeneratedNameForNode(property.name)) : property.name; - if (shouldTransformPrivateFields && ts.isPrivateIdentifier(propertyName)) { + if (shouldTransformPrivateElements && ts.isPrivateIdentifier(propertyName)) { var privateIdentifierInfo = accessPrivateIdentifier(propertyName); if (privateIdentifierInfo) { - switch (privateIdentifierInfo.placement) { - case 0 /* InstanceField */: { - return createPrivateInstanceFieldInitializer(receiver, ts.visitNode(property.initializer, visitor, ts.isExpression), privateIdentifierInfo.weakMapName); + if (privateIdentifierInfo.kind === "f" /* Field */) { + if (!privateIdentifierInfo.isStatic) { + return createPrivateInstanceFieldInitializer(receiver, ts.visitNode(property.initializer, visitor, ts.isExpression), privateIdentifierInfo.brandCheckIdentifier); + } + else { + return createPrivateStaticFieldInitializer(privateIdentifierInfo.variableName, ts.visitNode(property.initializer, visitor, ts.isExpression)); } } + else { + return undefined; + } } else { ts.Debug.fail("Undeclared private name for property declaration."); } } - if (ts.isPrivateIdentifier(propertyName) && !property.initializer) { - return undefined; - } - if (ts.isPrivateIdentifier(propertyName) && !property.initializer) { + if ((ts.isPrivateIdentifier(propertyName) || ts.hasStaticModifier(property)) && !property.initializer) { return undefined; } var propertyOriginalNode = ts.getOriginalNode(property); @@ -86242,11 +89461,26 @@ var ts; enabledSubstitutions |= 1 /* ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(78 /* Identifier */); + context.enableSubstitution(79 /* Identifier */); // Keep track of class aliases. classAliases = []; } } + /** + * Generates brand-check initializer for private methods. + * + * @param statements Statement list that should be used to append new statements. + * @param methods An array of method declarations. + * @param receiver The receiver on which each method should be assigned. + */ + function addMethodStatements(statements, methods, receiver) { + if (!shouldTransformPrivateElements || !ts.some(methods)) { + return; + } + var weakSetName = getPrivateIdentifierEnvironment().weakSetName; + ts.Debug.assert(weakSetName, "weakSetName should be set in private identifier environment"); + statements.push(factory.createExpressionStatement(createPrivateInstanceMethodInitializer(receiver, weakSetName))); + } /** * Hooks node substitutions. * @@ -86262,7 +89496,7 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return substituteExpressionIdentifier(node); } return node; @@ -86282,10 +89516,10 @@ var ts; if (declaration) { var classAlias = classAliases[declaration.id]; // TODO: GH#18217 if (classAlias) { - var clone_2 = factory.cloneNode(classAlias); - ts.setSourceMapRange(clone_2, node); - ts.setCommentRange(clone_2, node); - return clone_2; + var clone_3 = factory.cloneNode(classAlias); + ts.setSourceMapRange(clone_3, node); + ts.setCommentRange(clone_3, node); + return clone_3; } } } @@ -86305,7 +89539,12 @@ var ts; var alreadyTransformed = ts.isAssignmentExpression(innerExpression) && ts.isGeneratedIdentifier(innerExpression.left); if (!alreadyTransformed && !inlinable && shouldHoist) { var generatedName = factory.getGeneratedNameForNode(name); - hoistVariableDeclaration(generatedName); + if (resolver.getNodeCheckFlags(name) & 524288 /* BlockScopedBindingInLoop */) { + addBlockScopedVariable(generatedName); + } + else { + hoistVariableDeclaration(generatedName); + } return factory.createAssignment(generatedName, expression); } return (inlinable || ts.isIdentifier(innerExpression)) ? undefined : expression; @@ -86319,22 +89558,164 @@ var ts; currentPrivateIdentifierEnvironment = privateIdentifierEnvironmentStack.pop(); } function getPrivateIdentifierEnvironment() { - return currentPrivateIdentifierEnvironment || (currentPrivateIdentifierEnvironment = new ts.Map()); + if (!currentPrivateIdentifierEnvironment) { + currentPrivateIdentifierEnvironment = { + className: "", + identifiers: new ts.Map() + }; + } + return currentPrivateIdentifierEnvironment; } function getPendingExpressions() { return pendingExpressions || (pendingExpressions = []); } - function addPrivateIdentifierToEnvironment(name) { - var text = ts.getTextOfPropertyName(name); - var weakMapName = factory.createUniqueName("_" + text.substring(1), 16 /* Optimistic */ | 8 /* ReservedInNestedScopes */); - hoistVariableDeclaration(weakMapName); - getPrivateIdentifierEnvironment().set(name.escapedText, { placement: 0 /* InstanceField */, weakMapName: weakMapName }); - getPendingExpressions().push(factory.createAssignment(weakMapName, factory.createNewExpression(factory.createIdentifier("WeakMap"), - /*typeArguments*/ undefined, []))); + function addPrivateIdentifierToEnvironment(node) { + var _a; + var text = ts.getTextOfPropertyName(node.name); + var env = getPrivateIdentifierEnvironment(); + var weakSetName = env.weakSetName, classConstructor = env.classConstructor; + var assignmentExpressions = []; + var privateName = node.name.escapedText; + var previousInfo = env.identifiers.get(privateName); + var isValid = !isReservedPrivateName(node.name) && previousInfo === undefined; + if (ts.hasStaticModifier(node)) { + ts.Debug.assert(classConstructor, "weakSetName should be set in private identifier environment"); + if (ts.isPropertyDeclaration(node)) { + var variableName = createHoistedVariableForPrivateName(text, node); + env.identifiers.set(privateName, { + kind: "f" /* Field */, + variableName: variableName, + brandCheckIdentifier: classConstructor, + isStatic: true, + isValid: isValid, + }); + } + else if (ts.isMethodDeclaration(node)) { + var functionName = createHoistedVariableForPrivateName(text, node); + env.identifiers.set(privateName, { + kind: "m" /* Method */, + methodName: functionName, + brandCheckIdentifier: classConstructor, + isStatic: true, + isValid: isValid, + }); + } + 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) { + previousInfo.getterName = getterName; + } + else { + env.identifiers.set(privateName, { + kind: "a" /* Accessor */, + getterName: getterName, + setterName: undefined, + brandCheckIdentifier: classConstructor, + isStatic: true, + isValid: isValid, + }); + } + } + 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) { + previousInfo.setterName = setterName; + } + else { + env.identifiers.set(privateName, { + kind: "a" /* Accessor */, + getterName: undefined, + setterName: setterName, + brandCheckIdentifier: classConstructor, + isStatic: true, + isValid: isValid, + }); + } + } + else { + ts.Debug.assertNever(node, "Unknown class element type."); + } + } + else if (ts.isPropertyDeclaration(node)) { + var weakMapName = createHoistedVariableForPrivateName(text, node); + env.identifiers.set(privateName, { + kind: "f" /* Field */, + brandCheckIdentifier: weakMapName, + isStatic: false, + variableName: undefined, + isValid: isValid, + }); + assignmentExpressions.push(factory.createAssignment(weakMapName, factory.createNewExpression(factory.createIdentifier("WeakMap"), + /*typeArguments*/ undefined, []))); + } + else if (ts.isMethodDeclaration(node)) { + ts.Debug.assert(weakSetName, "weakSetName should be set in private identifier environment"); + env.identifiers.set(privateName, { + kind: "m" /* Method */, + methodName: createHoistedVariableForPrivateName(text, node), + brandCheckIdentifier: weakSetName, + isStatic: false, + isValid: isValid, + }); + } + else if (ts.isAccessor(node)) { + 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) { + previousInfo.getterName = getterName; + } + else { + env.identifiers.set(privateName, { + kind: "a" /* Accessor */, + getterName: getterName, + setterName: undefined, + brandCheckIdentifier: weakSetName, + isStatic: false, + isValid: isValid, + }); + } + } + else { + var setterName = createHoistedVariableForPrivateName(text + "_set", node); + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && !previousInfo.isStatic && !previousInfo.setterName) { + previousInfo.setterName = setterName; + } + else { + env.identifiers.set(privateName, { + kind: "a" /* Accessor */, + getterName: undefined, + setterName: setterName, + brandCheckIdentifier: weakSetName, + isStatic: false, + isValid: isValid, + }); + } + } + } + else { + ts.Debug.assertNever(node, "Unknown class element type."); + } + (_a = getPendingExpressions()).push.apply(_a, assignmentExpressions); + } + 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 */) { + addBlockScopedVariable(identifier); + } + else { + hoistVariableDeclaration(identifier); + } + return identifier; + } + function createHoistedVariableForPrivateName(privateName, node) { + return createHoistedVariableForClass(privateName.substring(1), node.name); } function accessPrivateIdentifier(name) { if (currentPrivateIdentifierEnvironment) { - var info = currentPrivateIdentifierEnvironment.get(name.escapedText); + var info = currentPrivateIdentifierEnvironment.identifiers.get(name.escapedText); if (info) { return info; } @@ -86344,7 +89725,7 @@ var ts; if (!env) { continue; } - var info = env.get(name.escapedText); + var info = env.identifiers.get(name.escapedText); if (info) { return info; } @@ -86362,7 +89743,7 @@ 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, 62 /* EqualsToken */, node.expression)); + getPendingExpressions().push(factory.createBinaryExpression(receiver, 63 /* EqualsToken */, node.expression)); } return factory.createPropertyAccessExpression( // Explicit parens required because of v8 regression (https://bugs.chromium.org/p/v8/issues/detail?id=9560) @@ -86375,7 +89756,7 @@ var ts; /*dotDotDotToken*/ undefined, parameter, /*questionToken*/ undefined, /*type*/ undefined, - /*initializer*/ undefined)], factory.createBlock([factory.createExpressionStatement(createPrivateIdentifierAssignment(info, receiver, parameter, 62 /* EqualsToken */))])) + /*initializer*/ undefined)], factory.createBlock([factory.createExpressionStatement(createPrivateIdentifierAssignment(info, receiver, parameter, 63 /* EqualsToken */))])) ])), "value"); } function visitArrayAssignmentTarget(node) { @@ -86430,10 +89811,22 @@ var ts; } } ts.transformClassFields = transformClassFields; + function createPrivateStaticFieldInitializer(variableName, initializer) { + return ts.factory.createAssignment(variableName, ts.factory.createObjectLiteralExpression([ + ts.factory.createPropertyAssignment("value", initializer || ts.factory.createVoidZero()) + ])); + } function createPrivateInstanceFieldInitializer(receiver, initializer, weakMapName) { return ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(weakMapName, "set"), /*typeArguments*/ undefined, [receiver, initializer || ts.factory.createVoidZero()]); } + function createPrivateInstanceMethodInitializer(receiver, weakSetName) { + return ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(weakSetName, "add"), + /*typeArguments*/ undefined, [receiver]); + } + function isReservedPrivateName(node) { + return node.escapedText === "#constructor"; + } })(ts || (ts = {})); /*@internal*/ var ts; @@ -86516,38 +89909,38 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 64 /* ContainsES2017 */) === 0) { + if ((node.transformFlags & 128 /* ContainsES2017 */) === 0) { return node; } switch (node.kind) { - case 129 /* AsyncKeyword */: + case 130 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 213 /* AwaitExpression */: + case 215 /* AwaitExpression */: return visitAwaitExpression(node); - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitMethodDeclaration, node); - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitFunctionDeclaration, node); - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitFunctionExpression, node); - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return doWithContext(1 /* NonTopLevel */, visitArrowFunction, node); - case 201 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 105 /* SuperKeyword */) { + case 203 /* PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SuperKeyword */) { capturedSuperProperties.add(node.name.escapedText); } return ts.visitEachChild(node, visitor, context); - case 202 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 105 /* SuperKeyword */) { + case 204 /* ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 106 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 166 /* Constructor */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 168 /* Constructor */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitDefault, node); default: return ts.visitEachChild(node, visitor, context); @@ -86556,27 +89949,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return visitForStatementInAsyncBody(node); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return visitForInStatementInAsyncBody(node); - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return visitCatchClauseInAsyncBody(node); - case 230 /* Block */: - case 244 /* SwitchStatement */: - case 258 /* CaseBlock */: - case 284 /* CaseClause */: - case 285 /* DefaultClause */: - case 247 /* TryStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: - case 234 /* IfStatement */: - case 243 /* WithStatement */: - case 245 /* LabeledStatement */: + case 232 /* Block */: + case 246 /* SwitchStatement */: + case 260 /* CaseBlock */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: + case 249 /* TryStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: + case 236 /* IfStatement */: + case 245 /* WithStatement */: + case 247 /* LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -86618,18 +90011,18 @@ var ts; function visitForInStatementInAsyncBody(node) { return factory.updateForInStatement(node, isVariableDeclarationListWithCollidingName(node.initializer) ? visitVariableDeclarationListWithCollidingNames(node.initializer, /*hasReceiver*/ true) - : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, asyncBodyVisitor, ts.isStatement, factory.liftToBlock)); + : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitIterationBody(node.statement, asyncBodyVisitor, context)); } function visitForOfStatementInAsyncBody(node) { return factory.updateForOfStatement(node, ts.visitNode(node.awaitModifier, visitor, ts.isToken), isVariableDeclarationListWithCollidingName(node.initializer) ? visitVariableDeclarationListWithCollidingNames(node.initializer, /*hasReceiver*/ true) - : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, asyncBodyVisitor, ts.isStatement, factory.liftToBlock)); + : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitIterationBody(node.statement, asyncBodyVisitor, context)); } function visitForStatementInAsyncBody(node) { var initializer = node.initializer; // TODO: GH#18217 return factory.updateForStatement(node, isVariableDeclarationListWithCollidingName(initializer) ? visitVariableDeclarationListWithCollidingNames(initializer, /*hasReceiver*/ false) - : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitor, ts.isExpression), ts.visitNode(node.statement, asyncBodyVisitor, ts.isStatement, factory.liftToBlock)); + : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitor, ts.isExpression), ts.visitIterationBody(node.statement, asyncBodyVisitor, context)); } /** * Visits an AwaitExpression node. @@ -86781,7 +90174,7 @@ var ts; var original = ts.getOriginalNode(node, ts.isFunctionLike); var nodeType = original.type; var promiseConstructor = languageVersion < 2 /* ES2015 */ ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 209 /* ArrowFunction */; + var isArrowFunction = node.kind === 211 /* ArrowFunction */; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* 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 @@ -86872,17 +90265,17 @@ var ts; enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(203 /* CallExpression */); - context.enableSubstitution(201 /* PropertyAccessExpression */); - context.enableSubstitution(202 /* ElementAccessExpression */); + context.enableSubstitution(205 /* CallExpression */); + context.enableSubstitution(203 /* PropertyAccessExpression */); + context.enableSubstitution(204 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(252 /* ClassDeclaration */); - context.enableEmitNotification(165 /* MethodDeclaration */); - context.enableEmitNotification(167 /* GetAccessor */); - context.enableEmitNotification(168 /* SetAccessor */); - context.enableEmitNotification(166 /* Constructor */); + context.enableEmitNotification(254 /* ClassDeclaration */); + context.enableEmitNotification(167 /* MethodDeclaration */); + context.enableEmitNotification(169 /* GetAccessor */); + context.enableEmitNotification(170 /* SetAccessor */); + context.enableEmitNotification(168 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(232 /* VariableStatement */); + context.enableEmitNotification(234 /* VariableStatement */); } } /** @@ -86930,23 +90323,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -86966,11 +90359,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 252 /* ClassDeclaration */ - || kind === 166 /* Constructor */ - || kind === 165 /* MethodDeclaration */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */; + return kind === 254 /* ClassDeclaration */ + || kind === 168 /* Constructor */ + || kind === 167 /* MethodDeclaration */ + || kind === 169 /* GetAccessor */ + || kind === 170 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -87127,7 +90520,7 @@ var ts; return visitorWorker(node, /*expressionResultIsUnused*/ true); } function visitorNoAsyncModifier(node) { - if (node.kind === 129 /* AsyncKeyword */) { + if (node.kind === 130 /* AsyncKeyword */) { return undefined; } return node; @@ -87149,74 +90542,74 @@ var ts; * expression of an `ExpressionStatement`). */ function visitorWorker(node, expressionResultIsUnused) { - if ((node.transformFlags & 32 /* ContainsES2018 */) === 0) { + if ((node.transformFlags & 64 /* ContainsES2018 */) === 0) { return node; } switch (node.kind) { - case 213 /* AwaitExpression */: + case 215 /* AwaitExpression */: return visitAwaitExpression(node); - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: return visitYieldExpression(node); - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: return visitReturnStatement(node); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return visitLabeledStatement(node); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return visitBinaryExpression(node, expressionResultIsUnused); - case 337 /* CommaListExpression */: + case 345 /* CommaListExpression */: return visitCommaListExpression(node, expressionResultIsUnused); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return visitCatchClause(node); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return visitVariableStatement(node); - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 235 /* DoStatement */: - case 236 /* WhileStatement */: - case 238 /* ForInStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: + case 240 /* ForInStatement */: return doWithHierarchyFacts(visitDefault, node, 0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return doWithHierarchyFacts(visitForStatement, node, 0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - case 212 /* VoidExpression */: + case 214 /* VoidExpression */: return visitVoidExpression(node); - case 166 /* Constructor */: + case 168 /* Constructor */: return doWithHierarchyFacts(visitConstructorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: return doWithHierarchyFacts(visitMethodDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 167 /* GetAccessor */: + case 169 /* GetAccessor */: return doWithHierarchyFacts(visitGetAccessorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 168 /* SetAccessor */: + case 170 /* SetAccessor */: return doWithHierarchyFacts(visitSetAccessorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return doWithHierarchyFacts(visitFunctionDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: return doWithHierarchyFacts(visitFunctionExpression, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return doWithHierarchyFacts(visitArrowFunction, node, 2 /* ArrowFunctionExcludes */, 0 /* ArrowFunctionIncludes */); - case 160 /* Parameter */: + case 162 /* Parameter */: return visitParameter(node); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: return visitExpressionStatement(node); - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, expressionResultIsUnused); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 201 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 105 /* SuperKeyword */) { + case 203 /* PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SuperKeyword */) { capturedSuperProperties.add(node.name.escapedText); } return ts.visitEachChild(node, visitor, context); - case 202 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 105 /* SuperKeyword */) { + case 204 /* ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 106 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: return doWithHierarchyFacts(visitDefault, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); default: return ts.visitEachChild(node, visitor, context); @@ -87252,7 +90645,7 @@ var ts; function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2 /* Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 239 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 241 /* ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return factory.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement, factory.liftToBlock), node); @@ -87264,7 +90657,7 @@ var ts; var objects = []; for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) { var e = elements_4[_i]; - if (e.kind === 290 /* SpreadAssignment */) { + if (e.kind === 292 /* SpreadAssignment */) { if (chunkObject) { objects.push(factory.createObjectLiteralExpression(chunkObject)); chunkObject = undefined; @@ -87273,7 +90666,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 288 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 290 /* PropertyAssignment */ ? factory.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -87284,7 +90677,7 @@ var ts; return objects; } function visitObjectLiteralExpression(node) { - if (node.transformFlags & 16384 /* ContainsObjectRestOrSpread */) { + if (node.transformFlags & 32768 /* 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}); @@ -87307,7 +90700,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 !== 200 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 202 /* ObjectLiteralExpression */) { objects.unshift(factory.createObjectLiteralExpression()); } var expression = objects[0]; @@ -87357,7 +90750,7 @@ var ts; * expression of an `ExpressionStatement`). */ function visitBinaryExpression(node, expressionResultIsUnused) { - if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 16384 /* ContainsObjectRestOrSpread */) { + if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { return ts.flattenDestructuringAssignment(node, visitor, context, 1 /* ObjectRest */, !expressionResultIsUnused); } if (node.operatorToken.kind === 27 /* CommaToken */) { @@ -87388,7 +90781,7 @@ var ts; function visitCatchClause(node) { if (node.variableDeclaration && ts.isBindingPattern(node.variableDeclaration.name) && - node.variableDeclaration.name.transformFlags & 16384 /* ContainsObjectRestOrSpread */) { + node.variableDeclaration.name.transformFlags & 32768 /* 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 */); @@ -87429,14 +90822,14 @@ 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 & 16384 /* ContainsObjectRestOrSpread */) { + if (ts.isBindingPattern(node.name) && node.name.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { return ts.flattenDestructuringBinding(node, visitor, context, 1 /* ObjectRest */, /*rval*/ undefined, exportedVariableStatement); } return ts.visitEachChild(node, visitor, context); } function visitForStatement(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)); + 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.visitIterationBody(node.statement, visitor, context)); } function visitVoidExpression(node) { return ts.visitEachChild(node, visitorWithUnusedExpressionResult, context); @@ -87448,7 +90841,7 @@ var ts; */ function visitForOfStatement(node, outermostLabeledStatement) { var ancestorFacts = enterSubtree(0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - if (node.initializer.transformFlags & 16384 /* ContainsObjectRestOrSpread */) { + if (node.initializer.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { node = transformForOfStatementWithObjectRest(node); } var result = node.awaitModifier ? @@ -87486,7 +90879,7 @@ var ts; var bodyLocation; var statementsLocation; var statements = [ts.visitNode(binding, visitor, ts.isStatement)]; - var statement = ts.visitNode(node.statement, visitor, ts.isStatement); + var statement = ts.visitIterationBody(node.statement, visitor, context); if (ts.isBlock(statement)) { ts.addRange(statements, statement.statements); bodyLocation = statement; @@ -87548,7 +90941,7 @@ var ts; ])); } function visitParameter(node) { - if (node.transformFlags & 16384 /* ContainsObjectRestOrSpread */) { + if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { // Binding patterns are converted into a generated name and are // evaluated inside the function body. return factory.updateParameterDeclaration(node, @@ -87700,7 +91093,7 @@ var ts; function appendObjectRestAssignmentsIfNeeded(statements, node) { for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { var parameter = _a[_i]; - if (parameter.transformFlags & 16384 /* ContainsObjectRestOrSpread */) { + if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { var temp = factory.getGeneratedNameForNode(parameter); var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* ObjectRest */, temp, /*doNotRecordTempVariablesInLine*/ false, @@ -87720,17 +91113,17 @@ var ts; enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(203 /* CallExpression */); - context.enableSubstitution(201 /* PropertyAccessExpression */); - context.enableSubstitution(202 /* ElementAccessExpression */); + context.enableSubstitution(205 /* CallExpression */); + context.enableSubstitution(203 /* PropertyAccessExpression */); + context.enableSubstitution(204 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(252 /* ClassDeclaration */); - context.enableEmitNotification(165 /* MethodDeclaration */); - context.enableEmitNotification(167 /* GetAccessor */); - context.enableEmitNotification(168 /* SetAccessor */); - context.enableEmitNotification(166 /* Constructor */); + context.enableEmitNotification(254 /* ClassDeclaration */); + context.enableEmitNotification(167 /* MethodDeclaration */); + context.enableEmitNotification(169 /* GetAccessor */); + context.enableEmitNotification(170 /* SetAccessor */); + context.enableEmitNotification(168 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(232 /* VariableStatement */); + context.enableEmitNotification(234 /* VariableStatement */); } } /** @@ -87778,23 +91171,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -87814,11 +91207,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 252 /* ClassDeclaration */ - || kind === 166 /* Constructor */ - || kind === 165 /* MethodDeclaration */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */; + return kind === 254 /* ClassDeclaration */ + || kind === 168 /* Constructor */ + || kind === 167 /* MethodDeclaration */ + || kind === 169 /* GetAccessor */ + || kind === 170 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -87846,11 +91239,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 16 /* ContainsES2019 */) === 0) { + if ((node.transformFlags & 32 /* ContainsES2019 */) === 0) { return node; } switch (node.kind) { - case 287 /* CatchClause */: + case 289 /* CatchClause */: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -87878,25 +91271,29 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 8 /* ContainsES2020 */) === 0) { + if ((node.transformFlags & 16 /* ContainsES2020 */) === 0) { return node; } switch (node.kind) { - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: - case 203 /* CallExpression */: - if (node.flags & 32 /* OptionalChain */) { + case 205 /* CallExpression */: { + var updated = visitNonOptionalCallExpression(node, /*captureThisArg*/ false); + ts.Debug.assertNotNode(updated, ts.isSyntheticReference); + return updated; + } + case 203 /* PropertyAccessExpression */: + case 204 /* 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 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: if (node.operatorToken.kind === 60 /* QuestionQuestionToken */) { return transformNullishCoalescingExpression(node); } return ts.visitEachChild(node, visitor, context); - case 210 /* DeleteExpression */: + case 212 /* DeleteExpression */: return visitDeleteExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -87938,7 +91335,7 @@ var ts; thisArg = expression; } } - expression = node.kind === 201 /* PropertyAccessExpression */ + expression = node.kind === 203 /* 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; @@ -87948,14 +91345,23 @@ var ts; // If `node` is an optional chain, then it is the outermost chain of an optional expression. return visitOptionalExpression(node, captureThisArg, /*isDelete*/ false); } + if (ts.isParenthesizedExpression(node.expression) && ts.isOptionalChain(ts.skipParentheses(node.expression))) { + // capture thisArg for calls of parenthesized optional chains like `(foo?.bar)()` + var expression = visitNonOptionalParenthesizedExpression(node.expression, /*captureThisArg*/ true, /*isDelete*/ false); + var args = ts.visitNodes(node.arguments, visitor, ts.isExpression); + if (ts.isSyntheticReference(expression)) { + return ts.setTextRange(factory.createFunctionCallCall(expression.expression, expression.thisArg, args), node); + } + return factory.updateCallExpression(node, expression, /*typeArguments*/ undefined, args); + } return ts.visitEachChild(node, visitor, context); } function visitNonOptionalExpression(node, captureThisArg, isDelete) { switch (node.kind) { - case 207 /* ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete); - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete); - case 203 /* CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); + case 209 /* ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete); + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete); + case 205 /* CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); default: return ts.visitNode(node, visitor, ts.isExpression); } } @@ -87974,8 +91380,8 @@ var ts; for (var i = 0; i < chain.length; i++) { var segment = chain[i]; switch (segment.kind) { - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 203 /* PropertyAccessExpression */: + case 204 /* ElementAccessExpression */: if (i === chain.length - 1 && captureThisArg) { if (!ts.isSimpleCopiableExpression(rightExpression)) { thisArg = factory.createTempVariable(hoistVariableDeclaration); @@ -87985,13 +91391,13 @@ var ts; thisArg = rightExpression; } } - rightExpression = segment.kind === 201 /* PropertyAccessExpression */ + rightExpression = segment.kind === 203 /* PropertyAccessExpression */ ? factory.createPropertyAccessExpression(rightExpression, ts.visitNode(segment.name, visitor, ts.isIdentifier)) : factory.createElementAccessExpression(rightExpression, ts.visitNode(segment.argumentExpression, visitor, ts.isExpression)); break; - case 203 /* CallExpression */: + case 205 /* CallExpression */: if (i === 0 && leftThisArg) { - rightExpression = factory.createFunctionCallCall(rightExpression, leftThisArg.kind === 105 /* SuperKeyword */ ? factory.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); + rightExpression = factory.createFunctionCallCall(rightExpression, leftThisArg.kind === 106 /* SuperKeyword */ ? factory.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); } else { rightExpression = factory.createCallExpression(rightExpression, @@ -88032,7 +91438,7 @@ var ts; /*@internal*/ var ts; (function (ts) { - function transformESNext(context) { + function transformES2021(context) { var hoistVariableDeclaration = context.hoistVariableDeclaration, factory = context.factory; return ts.chainBundle(context, transformSourceFile); function transformSourceFile(node) { @@ -88042,11 +91448,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 4 /* ContainsESNext */) === 0) { + if ((node.transformFlags & 8 /* ContainsES2021 */) === 0) { return node; } switch (node.kind) { - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: var binaryExpression = node; if (ts.isLogicalOrCoalescingAssignmentExpression(binaryExpression)) { return transformLogicalAssignment(binaryExpression); @@ -88082,6 +91488,29 @@ var ts; return factory.createBinaryExpression(left, nonAssignmentOperator, factory.createParenthesizedExpression(factory.createAssignment(assignmentTarget, right))); } } + ts.transformES2021 = transformES2021; +})(ts || (ts = {})); +/*@internal*/ +var ts; +(function (ts) { + function transformESNext(context) { + return ts.chainBundle(context, transformSourceFile); + function transformSourceFile(node) { + if (node.isDeclarationFile) { + return node; + } + return ts.visitEachChild(node, visitor, context); + } + function visitor(node) { + if ((node.transformFlags & 4 /* ContainsESNext */) === 0) { + return node; + } + switch (node.kind) { + default: + return ts.visitEachChild(node, visitor, context); + } + } + } ts.transformESNext = transformESNext; })(ts || (ts = {})); /*@internal*/ @@ -88192,13 +91621,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 273 /* JsxElement */: + case 275 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 274 /* JsxSelfClosingElement */: + case 276 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 277 /* JsxFragment */: + case 279 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -88208,13 +91637,13 @@ var ts; switch (node.kind) { case 11 /* JsxText */: return visitJsxText(node); - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: return visitJsxExpression(node); - case 273 /* JsxElement */: + case 275 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 274 /* JsxSelfClosingElement */: + case 276 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 277 /* JsxFragment */: + case 279 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -88332,21 +91761,29 @@ var ts; // When there are no attributes, React wants "null" } else { - // Map spans of JsxAttribute nodes into object literals and spans - // of JsxSpreadAttribute nodes into expressions. - var segments = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread - ? ts.map(attrs, transformJsxSpreadAttributeToExpression) - : factory.createObjectLiteralExpression(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); })); - if (ts.isJsxSpreadAttribute(attrs[0])) { - // We must always emit at least one object literal before a spread - // argument.factory.createObjectLiteral - segments.unshift(factory.createObjectLiteralExpression()); + var target = compilerOptions.target; + if (target && target >= 5 /* ES2018 */) { + objectProperties = factory.createObjectLiteralExpression(ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { + return isSpread ? ts.map(attrs, transformJsxSpreadAttributeToSpreadAssignment) : ts.map(attrs, transformJsxAttributeToObjectLiteralElement); + }))); } - // Either emit one big object literal (no spread attribs), or - // a call to the __assign helper. - objectProperties = ts.singleOrUndefined(segments); - if (!objectProperties) { - objectProperties = emitHelpers().createAssignHelper(segments); + else { + // Map spans of JsxAttribute nodes into object literals and spans + // of JsxSpreadAttribute nodes into expressions. + var segments = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread + ? ts.map(attrs, transformJsxSpreadAttributeToExpression) + : factory.createObjectLiteralExpression(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); })); + if (ts.isJsxSpreadAttribute(attrs[0])) { + // We must always emit at least one object literal before a spread + // argument.factory.createObjectLiteral + segments.unshift(factory.createObjectLiteralExpression()); + } + // Either emit one big object literal (no spread attribs), or + // a call to the __assign helper. + objectProperties = ts.singleOrUndefined(segments); + if (!objectProperties) { + objectProperties = emitHelpers().createAssignHelper(segments); + } } } var callee = currentFileState.importSpecifier === undefined @@ -88378,6 +91815,9 @@ var ts; } return element; } + function transformJsxSpreadAttributeToSpreadAssignment(node) { + return factory.createSpreadAssignment(ts.visitNode(node.expression, visitor, ts.isExpression)); + } function transformJsxSpreadAttributeToExpression(node) { return ts.visitNode(node.expression, visitor, ts.isExpression); } @@ -88397,7 +91837,7 @@ var ts; var literal = factory.createStringLiteral(tryDecodeEntities(node.text) || node.text, singleQuote); return ts.setTextRange(literal, node); } - else if (node.kind === 283 /* JsxExpression */) { + else if (node.kind === 285 /* JsxExpression */) { if (node.expression === undefined) { return factory.createTrue(); } @@ -88491,7 +91931,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 273 /* JsxElement */) { + if (node.kind === 275 /* JsxElement */) { return getTagName(node.openingElement); } else { @@ -88793,11 +92233,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 128 /* ContainsES2016 */) === 0) { + if ((node.transformFlags & 256 /* ContainsES2016 */) === 0) { return node; } switch (node.kind) { - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -88805,7 +92245,7 @@ var ts; } function visitBinaryExpression(node) { switch (node.operatorToken.kind) { - case 66 /* AsteriskAsteriskEqualsToken */: + case 67 /* AsteriskAsteriskEqualsToken */: return visitExponentiationAssignmentExpression(node); case 42 /* AsteriskAsteriskToken */: return visitExponentiationExpression(node); @@ -89010,11 +92450,11 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 242 /* ReturnStatement */ + && node.kind === 244 /* ReturnStatement */ && !node.expression; } function isOrMayContainReturnCompletion(node) { - return node.transformFlags & 1048576 /* ContainsHoistedDeclarationOrCompletion */ + return node.transformFlags & 2097152 /* ContainsHoistedDeclarationOrCompletion */ && (ts.isReturnStatement(node) || ts.isIfStatement(node) || ts.isWithStatement(node) @@ -89029,7 +92469,7 @@ var ts; || ts.isBlock(node)); } function shouldVisitNode(node) { - return (node.transformFlags & 256 /* ContainsES2015 */) !== 0 + return (node.transformFlags & 512 /* ContainsES2015 */) !== 0 || convertedLoopState !== undefined || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && isOrMayContainReturnCompletion(node)) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatement(node)) @@ -89042,74 +92482,74 @@ var ts; return shouldVisitNode(node) ? visitorWorker(node, /*expressionResultIsUnused*/ true) : node; } function callExpressionVisitor(node) { - if (node.kind === 105 /* SuperKeyword */) { + if (node.kind === 106 /* SuperKeyword */) { return visitSuperKeyword(/*isExpressionOfCall*/ true); } return visitor(node); } function visitorWorker(node, expressionResultIsUnused) { switch (node.kind) { - case 123 /* StaticKeyword */: + case 124 /* StaticKeyword */: return undefined; // elide static keyword - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: return visitClassDeclaration(node); - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: return visitClassExpression(node); - case 160 /* Parameter */: + case 162 /* Parameter */: return visitParameter(node); - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return visitArrowFunction(node); - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: return visitFunctionExpression(node); - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 78 /* Identifier */: + case 79 /* Identifier */: return visitIdentifier(node); - case 250 /* VariableDeclarationList */: + case 252 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: return visitSwitchStatement(node); - case 258 /* CaseBlock */: + case 260 /* CaseBlock */: return visitCaseBlock(node); - case 230 /* Block */: + case 232 /* Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 241 /* BreakStatement */: - case 240 /* ContinueStatement */: + case 243 /* BreakStatement */: + case 242 /* ContinueStatement */: return visitBreakOrContinueStatement(node); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return visitLabeledStatement(node); - case 235 /* DoStatement */: - case 236 /* WhileStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: return visitExpressionStatement(node); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return visitCatchClause(node); - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return visitCallExpression(node); - case 204 /* NewExpression */: + case 206 /* NewExpression */: return visitNewExpression(node); - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, expressionResultIsUnused); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return visitBinaryExpression(node, expressionResultIsUnused); - case 337 /* CommaListExpression */: + case 345 /* CommaListExpression */: return visitCommaListExpression(node, expressionResultIsUnused); case 14 /* NoSubstitutionTemplateLiteral */: case 15 /* TemplateHead */: @@ -89120,30 +92560,30 @@ var ts; return visitStringLiteral(node); case 8 /* NumericLiteral */: return visitNumericLiteral(node); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 218 /* TemplateExpression */: + case 220 /* TemplateExpression */: return visitTemplateExpression(node); - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: return visitYieldExpression(node); - case 220 /* SpreadElement */: + case 222 /* SpreadElement */: return visitSpreadElement(node); - case 105 /* SuperKeyword */: + case 106 /* SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: return visitThisKeyword(node); - case 226 /* MetaProperty */: + case 228 /* MetaProperty */: return visitMetaProperty(node); - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return visitAccessorDeclaration(node); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return visitVariableStatement(node); - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: return visitReturnStatement(node); - case 212 /* VoidExpression */: + case 214 /* VoidExpression */: return visitVoidExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -89233,14 +92673,14 @@ 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 === 241 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 243 /* BreakStatement */ ? 2 /* Break */ : 4 /* 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 === 241 /* BreakStatement */) { + if (node.kind === 243 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -89251,7 +92691,7 @@ var ts; } } else { - if (node.kind === 241 /* BreakStatement */) { + if (node.kind === 243 /* BreakStatement */) { labelMarker = "break-" + label.escapedText; setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } @@ -89511,7 +92951,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 !== 103 /* NullKeyword */; + var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */; // When the subclass does not have a constructor, we synthesize a *default* constructor using the following // representation: // @@ -89563,7 +93003,7 @@ var ts; factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment()); insertCaptureNewTargetIfNeeded(prologue, constructor, /*copyOnWrite*/ false); if (isDerivedClass) { - if (superCallExpression && statementOffset === constructor.body.statements.length && !(constructor.body.transformFlags & 4096 /* ContainsLexicalThis */)) { + if (superCallExpression && statementOffset === constructor.body.statements.length && !(constructor.body.transformFlags & 8192 /* ContainsLexicalThis */)) { // If the subclass constructor does *not* contain `this` and *ends* with a `super()` call, we will use the // following representation: // @@ -89649,11 +93089,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 242 /* ReturnStatement */) { + if (statement.kind === 244 /* ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 234 /* IfStatement */) { + else if (statement.kind === 236 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -89661,7 +93101,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 230 /* Block */) { + else if (statement.kind === 232 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -89819,10 +93259,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 === 78 /* Identifier */ ? ts.setParent(ts.setTextRange(factory.cloneNode(parameter.name), parameter.name), parameter.name.parent) : factory.createTempVariable(/*recordTempVariable*/ undefined); + 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 */); // `expressionName` is the name of the parameter used in expressions. - var expressionName = parameter.name.kind === 78 /* Identifier */ ? factory.cloneNode(parameter.name) : declarationName; + var expressionName = parameter.name.kind === 79 /* Identifier */ ? factory.cloneNode(parameter.name) : declarationName; var restIndex = node.parameters.length - 1; var temp = factory.createLoopVariable(); // var param = []; @@ -89847,7 +93287,7 @@ var ts; ts.setEmitFlags(forStatement, 1048576 /* CustomPrologue */); ts.startOnNewLine(forStatement); prologueStatements.push(forStatement); - if (parameter.name.kind !== 78 /* Identifier */) { + if (parameter.name.kind !== 79 /* 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 */)); @@ -89863,7 +93303,7 @@ var ts; * @param node A node. */ function insertCaptureThisForNodeIfNeeded(statements, node) { - if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 209 /* ArrowFunction */) { + if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 211 /* ArrowFunction */) { insertCaptureThisForNode(statements, node, factory.createThis()); return true; } @@ -89885,25 +93325,25 @@ var ts; if (hierarchyFacts & 16384 /* NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return statements; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: // Methods and accessors cannot be constructors, so 'new.target' will // always return 'undefined'. newTarget = factory.createVoidZero(); break; - case 166 /* Constructor */: + case 168 /* 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"); break; - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 210 /* 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 */), 101 /* InstanceOfKeyword */, factory.getLocalName(node))), + 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"), /*colonToken*/ undefined, factory.createVoidZero()); break; @@ -89935,20 +93375,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 229 /* SemicolonClassElement */: + case 231 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 166 /* Constructor */: + case 168 /* Constructor */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -89977,7 +93417,7 @@ var ts; var memberFunction = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined, container); var propertyName = ts.visitNode(member.name, visitor, ts.isPropertyName); var e; - if (!ts.isPrivateIdentifier(propertyName) && context.getCompilerOptions().useDefineForClassFields) { + if (!ts.isPrivateIdentifier(propertyName) && ts.getUseDefineForClassFields(context.getCompilerOptions())) { var name = ts.isComputedPropertyName(propertyName) ? propertyName.expression : ts.isIdentifier(propertyName) ? factory.createStringLiteral(ts.unescapeLeadingUnderscores(propertyName.escapedText)) : propertyName; @@ -90069,7 +93509,7 @@ var ts; * @param node An ArrowFunction node. */ function visitArrowFunction(node) { - if (node.transformFlags & 4096 /* ContainsLexicalThis */) { + if (node.transformFlags & 8192 /* ContainsLexicalThis */) { hierarchyFacts |= 32768 /* CapturedLexicalThis */; } var savedConvertedLoopState = convertedLoopState; @@ -90151,7 +93591,7 @@ var ts; : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 251 /* FunctionDeclaration */ || node.kind === 208 /* FunctionExpression */)) { + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 253 /* FunctionDeclaration */ || node.kind === 210 /* FunctionExpression */)) { name = factory.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */); @@ -90197,7 +93637,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 209 /* ArrowFunction */); + ts.Debug.assert(node.kind === 211 /* 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 @@ -90332,7 +93772,7 @@ var ts; assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0 /* All */); } else { - assignment = factory.createBinaryExpression(decl.name, 62 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + assignment = factory.createBinaryExpression(decl.name, 63 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); ts.setTextRange(assignment, decl); } assignments = ts.append(assignments, assignment); @@ -90358,7 +93798,7 @@ var ts; * @param node A VariableDeclarationList node. */ function visitVariableDeclarationList(node) { - if (node.flags & 3 /* BlockScoped */ || node.transformFlags & 131072 /* ContainsBindingPattern */) { + if (node.flags & 3 /* BlockScoped */ || node.transformFlags & 262144 /* ContainsBindingPattern */) { if (node.flags & 3 /* BlockScoped */) { enableSubstitutionsForBlockScopedBindings(); } @@ -90371,7 +93811,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 & 131072 /* ContainsBindingPattern */ + if (node.transformFlags & 262144 /* ContainsBindingPattern */ && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.last(node.declarations).name))) { ts.setSourceMapRange(declarationList, getRangeUnion(declarations)); } @@ -90383,8 +93823,8 @@ var ts; // declarations may not be sorted by position. // pos should be the minimum* position over all nodes (that's not -1), end should be the maximum end over all nodes. var pos = -1, end = -1; - for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) { - var node = declarations_10[_i]; + for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { + var node = declarations_9[_i]; pos = pos === -1 ? node.pos : node.pos === -1 ? pos : Math.min(pos, node.pos); end = Math.max(end, node.end); } @@ -90504,14 +93944,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 235 /* DoStatement */: - case 236 /* WhileStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -90695,9 +94135,9 @@ var ts; var numInitialProperties = -1, hasComputed = false; for (var i = 0; i < properties.length; i++) { var property = properties[i]; - if ((property.transformFlags & 262144 /* ContainsYield */ && + if ((property.transformFlags & 524288 /* ContainsYield */ && hierarchyFacts & 4 /* AsyncFunctionBody */) - || (hasComputed = ts.Debug.checkDefined(property.name).kind === 158 /* ComputedPropertyName */)) { + || (hasComputed = ts.Debug.checkDefined(property.name).kind === 160 /* ComputedPropertyName */)) { numInitialProperties = i; break; } @@ -90749,7 +94189,7 @@ var ts; } visit(node.name); function visit(node) { - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { state.hoistedLocalVariables.push(node); } else { @@ -90800,24 +94240,24 @@ var ts; loop = convert(node, outermostLabeledStatement, bodyFunction.part, ancestorFacts); } else { - var clone_3 = convertIterationStatementCore(node, initializerFunction, factory.createBlock(bodyFunction.part, /*multiLine*/ true)); - loop = factory.restoreEnclosingLabel(clone_3, outermostLabeledStatement, convertedLoopState && resetLabel); + var clone_4 = convertIterationStatementCore(node, initializerFunction, factory.createBlock(bodyFunction.part, /*multiLine*/ true)); + loop = factory.restoreEnclosingLabel(clone_4, outermostLabeledStatement, convertedLoopState && resetLabel); } } else { - var clone_4 = convertIterationStatementCore(node, initializerFunction, ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - loop = factory.restoreEnclosingLabel(clone_4, outermostLabeledStatement, convertedLoopState && resetLabel); + var clone_5 = convertIterationStatementCore(node, initializerFunction, ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock)); + loop = factory.restoreEnclosingLabel(clone_5, outermostLabeledStatement, convertedLoopState && resetLabel); } statements.push(loop); return statements; } function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) { switch (node.kind) { - case 237 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); - case 238 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); - case 239 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); - case 235 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); - case 236 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); + case 239 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); + case 240 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); + case 241 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); + case 237 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); + case 238 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected"); } } @@ -90842,11 +94282,11 @@ var ts; function createConvertedLoopState(node) { var loopInitializer; switch (node.kind) { - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: + case 239 /* ForStatement */: + case 240 /* ForInStatement */: + case 241 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 250 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 252 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -90966,7 +94406,7 @@ var ts; */ function createFunctionForInitializerOfForStatement(node, currentState) { var functionName = factory.createUniqueName("_loop_init"); - var containsYield = (node.initializer.transformFlags & 262144 /* ContainsYield */) !== 0; + var containsYield = (node.initializer.transformFlags & 524288 /* ContainsYield */) !== 0; var emitFlags = 0 /* None */; if (currentState.containsLexicalThis) emitFlags |= 8 /* CapturesThis */; @@ -91081,7 +94521,7 @@ var ts; var loopBody = factory.createBlock(statements, /*multiLine*/ true); if (ts.isBlock(statement)) ts.setOriginalNode(loopBody, statement); - var containsYield = (node.statement.transformFlags & 262144 /* ContainsYield */) !== 0; + var containsYield = (node.statement.transformFlags & 524288 /* ContainsYield */) !== 0; var emitFlags = 524288 /* ReuseTempVariableScope */; if (currentState.containsLexicalThis) emitFlags |= 8 /* CapturesThis */; @@ -91117,7 +94557,7 @@ var ts; 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, 62 /* EqualsToken */, source); + return factory.createBinaryExpression(target, 63 /* EqualsToken */, source); } function copyOutParameters(outParams, partFlags, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { @@ -91254,20 +94694,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -91374,7 +94814,7 @@ var ts; var updated; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (node.kind === 167 /* GetAccessor */) { + if (node.kind === 169 /* GetAccessor */) { updated = factory.updateGetAccessorDeclaration(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); } else { @@ -91427,7 +94867,7 @@ var ts; return visitTypeScriptClassWrapper(node); } var expression = ts.skipOuterExpressions(node.expression); - if (expression.kind === 105 /* SuperKeyword */ || + if (expression.kind === 106 /* SuperKeyword */ || ts.isSuperProperty(expression) || ts.some(node.arguments, ts.isSpreadElement)) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); @@ -91554,15 +94994,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 & 8192 /* ContainsRestOrSpread */ || - node.expression.kind === 105 /* SuperKeyword */ || + if (node.transformFlags & 16384 /* ContainsRestOrSpread */ || + node.expression.kind === 106 /* SuperKeyword */ || ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) { var _a = factory.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { ts.setEmitFlags(thisArg, 4 /* NoSubstitution */); } var resultingCall = void 0; - if (node.transformFlags & 8192 /* ContainsRestOrSpread */) { + if (node.transformFlags & 16384 /* ContainsRestOrSpread */) { // [source] // f(...a, b) // x.m(...a, b) @@ -91576,7 +95016,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 === 105 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); + resultingCall = factory.createFunctionApplyCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); } else { // [source] @@ -91588,9 +95028,9 @@ 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 === 105 /* 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 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression)), node); } - if (node.expression.kind === 105 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SuperKeyword */) { var initializer = factory.createLogicalOr(resultingCall, createActualThis()); resultingCall = assignToCapturedThis ? factory.createAssignment(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), initializer) @@ -91837,7 +95277,7 @@ var ts; : factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */); } function visitMetaProperty(node) { - if (node.keywordToken === 102 /* NewKeyword */ && node.name.escapedText === "target") { + if (node.keywordToken === 103 /* NewKeyword */ && node.name.escapedText === "target") { hierarchyFacts |= 16384 /* NewTarget */; return factory.createUniqueName("_newTarget", 16 /* Optimistic */ | 32 /* FileLevel */); } @@ -91869,7 +95309,7 @@ var ts; function enableSubstitutionsForBlockScopedBindings() { if ((enabledSubstitutions & 2 /* BlockScopedBindings */) === 0) { enabledSubstitutions |= 2 /* BlockScopedBindings */; - context.enableSubstitution(78 /* Identifier */); + context.enableSubstitution(79 /* Identifier */); } } /** @@ -91879,14 +95319,14 @@ var ts; function enableSubstitutionsForCapturedThis() { if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { enabledSubstitutions |= 1 /* CapturedThis */; - context.enableSubstitution(107 /* ThisKeyword */); - context.enableEmitNotification(166 /* Constructor */); - context.enableEmitNotification(165 /* MethodDeclaration */); - context.enableEmitNotification(167 /* GetAccessor */); - context.enableEmitNotification(168 /* SetAccessor */); - context.enableEmitNotification(209 /* ArrowFunction */); - context.enableEmitNotification(208 /* FunctionExpression */); - context.enableEmitNotification(251 /* FunctionDeclaration */); + context.enableSubstitution(108 /* ThisKeyword */); + context.enableEmitNotification(168 /* Constructor */); + context.enableEmitNotification(167 /* MethodDeclaration */); + context.enableEmitNotification(169 /* GetAccessor */); + context.enableEmitNotification(170 /* SetAccessor */); + context.enableEmitNotification(211 /* ArrowFunction */); + context.enableEmitNotification(210 /* FunctionExpression */); + context.enableEmitNotification(253 /* FunctionDeclaration */); } } /** @@ -91927,10 +95367,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 198 /* BindingElement */: - case 252 /* ClassDeclaration */: - case 255 /* EnumDeclaration */: - case 249 /* VariableDeclaration */: + case 200 /* BindingElement */: + case 254 /* ClassDeclaration */: + case 257 /* EnumDeclaration */: + case 251 /* VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -91943,9 +95383,9 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return substituteExpressionIdentifier(node); - case 107 /* ThisKeyword */: + case 108 /* ThisKeyword */: return substituteThisKeyword(node); } return node; @@ -92012,19 +95452,19 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 233 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 235 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 203 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 205 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 105 /* SuperKeyword */) { + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 106 /* SuperKeyword */) { return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 220 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 222 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -92050,15 +95490,15 @@ var ts; if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(275 /* JsxOpeningElement */); - context.enableEmitNotification(276 /* JsxClosingElement */); - context.enableEmitNotification(274 /* JsxSelfClosingElement */); + context.enableEmitNotification(277 /* JsxOpeningElement */); + context.enableEmitNotification(278 /* JsxClosingElement */); + context.enableEmitNotification(276 /* JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(201 /* PropertyAccessExpression */); - context.enableSubstitution(288 /* PropertyAssignment */); + context.enableSubstitution(203 /* PropertyAccessExpression */); + context.enableSubstitution(290 /* PropertyAssignment */); return ts.chainBundle(context, transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -92077,9 +95517,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 275 /* JsxOpeningElement */: - case 276 /* JsxClosingElement */: - case 274 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: + case 278 /* JsxClosingElement */: + case 276 /* JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -92139,7 +95579,7 @@ var ts; */ function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined); - if (token !== undefined && token >= 80 /* FirstReservedWord */ && token <= 115 /* LastReservedWord */) { + if (token !== undefined && token >= 81 /* FirstReservedWord */ && token <= 116 /* LastReservedWord */) { return ts.setTextRange(factory.createStringLiteralFromNode(name), name); } return undefined; @@ -92377,7 +95817,7 @@ var ts; var withBlockStack; // A stack containing `with` blocks. return ts.chainBundle(context, transformSourceFile); function transformSourceFile(node) { - if (node.isDeclarationFile || (node.transformFlags & 512 /* ContainsGenerator */) === 0) { + if (node.isDeclarationFile || (node.transformFlags & 1024 /* ContainsGenerator */) === 0) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -92400,7 +95840,7 @@ var ts; else if (ts.isFunctionLikeDeclaration(node) && node.asteriskToken) { return visitGenerator(node); } - else if (transformFlags & 512 /* ContainsGenerator */) { + else if (transformFlags & 1024 /* ContainsGenerator */) { return ts.visitEachChild(node, visitor, context); } else { @@ -92414,13 +95854,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 235 /* DoStatement */: + case 237 /* DoStatement */: return visitDoStatement(node); - case 236 /* WhileStatement */: + case 238 /* WhileStatement */: return visitWhileStatement(node); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: return visitSwitchStatement(node); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -92433,30 +95873,30 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: return visitFunctionExpression(node); - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return visitAccessorDeclaration(node); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return visitVariableStatement(node); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return visitForStatement(node); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return visitForInStatement(node); - case 241 /* BreakStatement */: + case 243 /* BreakStatement */: return visitBreakStatement(node); - case 240 /* ContinueStatement */: + case 242 /* ContinueStatement */: return visitContinueStatement(node); - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: return visitReturnStatement(node); default: - if (node.transformFlags & 262144 /* ContainsYield */) { + if (node.transformFlags & 524288 /* ContainsYield */) { return visitJavaScriptContainingYield(node); } - else if (node.transformFlags & (512 /* ContainsGenerator */ | 1048576 /* ContainsHoistedDeclarationOrCompletion */)) { + else if (node.transformFlags & (1024 /* ContainsGenerator */ | 2097152 /* ContainsHoistedDeclarationOrCompletion */)) { return ts.visitEachChild(node, visitor, context); } else { @@ -92471,23 +95911,23 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return visitBinaryExpression(node); - case 337 /* CommaListExpression */: + case 345 /* CommaListExpression */: return visitCommaListExpression(node); - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: return visitConditionalExpression(node); - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: return visitYieldExpression(node); - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return visitCallExpression(node); - case 204 /* NewExpression */: + case 206 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -92500,9 +95940,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -92661,7 +96101,7 @@ var ts; * @param node The node to visit. */ function visitVariableStatement(node) { - if (node.transformFlags & 262144 /* ContainsYield */) { + if (node.transformFlags & 524288 /* ContainsYield */) { transformAndEmitVariableDeclarationList(node.declarationList); return undefined; } @@ -92710,7 +96150,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -92722,7 +96162,7 @@ var ts; // _a.b = %sent%; target = factory.updatePropertyAccessExpression(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -93116,35 +96556,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 230 /* Block */: + case 232 /* Block */: return transformAndEmitBlock(node); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 234 /* IfStatement */: + case 236 /* IfStatement */: return transformAndEmitIfStatement(node); - case 235 /* DoStatement */: + case 237 /* DoStatement */: return transformAndEmitDoStatement(node); - case 236 /* WhileStatement */: + case 238 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return transformAndEmitForStatement(node); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 240 /* ContinueStatement */: + case 242 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 241 /* BreakStatement */: + case 243 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 243 /* WithStatement */: + case 245 /* WithStatement */: return transformAndEmitWithStatement(node); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 246 /* ThrowStatement */: + case 248 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 247 /* TryStatement */: + case 249 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -93364,7 +96804,7 @@ var ts; var variables = ts.getInitializedVariables(initializer); node = factory.updateForStatement(node, variables.length > 0 ? factory.inlineExpressions(ts.map(variables, transformInitializedVariable)) - : undefined, ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitor, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock)); + : undefined, ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitor, ts.isExpression), ts.visitIterationBody(node.statement, visitor, context)); } else { node = ts.visitEachChild(node, visitor, context); @@ -93574,7 +97014,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 285 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 287 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -93587,7 +97027,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 284 /* CaseClause */) { + if (clause.kind === 286 /* CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -93719,7 +97159,7 @@ var ts; } } function containsYield(node) { - return !!node && (node.transformFlags & 262144 /* ContainsYield */) !== 0; + return !!node && (node.transformFlags & 524288 /* ContainsYield */) !== 0; } function countInitialNodesWithoutYield(nodes) { var numNodes = nodes.length; @@ -93752,10 +97192,10 @@ var ts; var name = renamedCatchVariableDeclarations[ts.getOriginalNodeId(declaration)]; if (name) { // TODO(rbuckton): Does this need to be parented? - var clone_5 = ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent); - ts.setSourceMapRange(clone_5, node); - ts.setCommentRange(clone_5, node); - return clone_5; + var clone_6 = ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent); + ts.setSourceMapRange(clone_6, node); + ts.setCommentRange(clone_6, node); + return clone_6; } } } @@ -93901,7 +97341,7 @@ var ts; if (!renamedCatchVariables) { renamedCatchVariables = new ts.Map(); renamedCatchVariableDeclarations = []; - context.enableSubstitution(78 /* Identifier */); + context.enableSubstitution(79 /* Identifier */); } renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; @@ -94747,12 +98187,12 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(78 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(216 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(214 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(215 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(289 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(297 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(79 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. + context.enableSubstitution(218 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(216 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(217 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(291 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(299 /* 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. @@ -94768,7 +98208,7 @@ var ts; function transformSourceFile(node) { if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || - node.transformFlags & 2097152 /* ContainsDynamicImport */ || + node.transformFlags & 4194304 /* ContainsDynamicImport */ || (ts.isJsonSourceFile(node) && ts.hasJsonModuleEmitEnabled(compilerOptions) && ts.outFile(compilerOptions)))) { return node; } @@ -95080,23 +98520,23 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return visitImportDeclaration(node); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: return visitExportDeclaration(node); - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return visitExportAssignment(node); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return visitVariableStatement(node); - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: return visitClassDeclaration(node); - case 338 /* MergeDeclarationMarker */: + case 346 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 339 /* EndOfDeclarationMarker */: + case 347 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -95105,7 +98545,7 @@ var ts; function moduleExpressionElementVisitor(node) { // This visitor does not need to descend into the tree if there is no dynamic import or destructuring assignment, // as export/import statements are only transformed at the top level of a file. - if (!(node.transformFlags & 2097152 /* ContainsDynamicImport */) && !(node.transformFlags & 1024 /* ContainsDestructuringAssignment */)) { + if (!(node.transformFlags & 4194304 /* ContainsDynamicImport */) && !(node.transformFlags & 2048 /* ContainsDestructuringAssignment */)) { return node; } if (ts.isImportCall(node)) { @@ -95123,24 +98563,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 290 /* SpreadAssignment */: + case 292 /* SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -95175,7 +98615,7 @@ var ts; var firstArgument = ts.visitNode(ts.firstOrUndefined(node.arguments), moduleExpressionElementVisitor); // 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 & 4096 /* ContainsLexicalThis */); + var containsLexicalThis = !!(node.transformFlags & 8192 /* ContainsLexicalThis */); switch (compilerOptions.module) { case ts.ModuleKind.AMD: return createImportCallExpressionAMD(argument, containsLexicalThis); @@ -95668,7 +99108,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 232 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 234 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -95723,10 +99163,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 264 /* NamedImports */: + case 266 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding, /* liveBinding */ true); @@ -95922,8 +99362,8 @@ var ts; function modifierVisitor(node) { // Elide module-specific modifiers. switch (node.kind) { - case 92 /* ExportKeyword */: - case 87 /* DefaultKeyword */: + case 93 /* ExportKeyword */: + case 88 /* DefaultKeyword */: return undefined; } return node; @@ -95939,7 +99379,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 297 /* SourceFile */) { + if (node.kind === 299 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -96001,12 +99441,12 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return substituteExpressionIdentifier(node); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return substituteBinaryExpression(node); - case 215 /* PostfixUnaryExpression */: - case 214 /* PrefixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -96026,9 +99466,9 @@ var ts; } return node; } - if (!(ts.isGeneratedIdentifier(node) && !(node.autoGenerateFlags & 64 /* AllowNameSubstitution */)) && !ts.isLocalName(node)) { + else if (!(ts.isGeneratedIdentifier(node) && !(node.autoGenerateFlags & 64 /* AllowNameSubstitution */)) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 297 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 299 /* SourceFile */) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.cloneNode(node)), /*location*/ node); } @@ -96103,8 +99543,8 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 215 /* PostfixUnaryExpression */ - ? ts.setTextRange(factory.createBinaryExpression(node.operand, factory.createToken(node.operator === 45 /* PlusPlusToken */ ? 63 /* PlusEqualsToken */ : 64 /* MinusEqualsToken */), factory.createNumericLiteral(1)), + var expression = node.kind === 217 /* PostfixUnaryExpression */ + ? ts.setTextRange(factory.createPrefixUnaryExpression(node.operator, node.operand), /*location*/ node) : node; for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) { @@ -96113,6 +99553,12 @@ var ts; noSubstitution[ts.getNodeId(expression)] = true; expression = createExportExpression(exportName, expression); } + if (node.kind === 217 /* PostfixUnaryExpression */) { + noSubstitution[ts.getNodeId(expression)] = true; + expression = node.operator === 45 /* PlusPlusToken */ + ? factory.createSubtract(expression, factory.createNumericLiteral(1)) + : factory.createAdd(expression, factory.createNumericLiteral(1)); + } return expression; } } @@ -96154,13 +99600,13 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(78 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(289 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols - context.enableSubstitution(216 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(214 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(215 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(226 /* MetaProperty */); // Substitutes 'import.meta' - context.enableEmitNotification(297 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(79 /* Identifier */); // Substitutes expression identifiers for imported symbols. + context.enableSubstitution(291 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(218 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(216 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(217 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(228 /* MetaProperty */); // Substitutes 'import.meta' + context.enableEmitNotification(299 /* 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. @@ -96180,7 +99626,7 @@ var ts; * @param node The SourceFile node. */ function transformSourceFile(node) { - if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 2097152 /* ContainsDynamicImport */)) { + if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 4194304 /* ContainsDynamicImport */)) { return node; } var id = ts.getOriginalNodeId(node); @@ -96349,7 +99795,7 @@ 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 & 524288 /* ContainsAwait */ ? + var modifiers = node.transformFlags & 1048576 /* ContainsAwait */ ? factory.createModifiersFromModifierFlags(256 /* Async */) : undefined; var moduleObject = factory.createObjectLiteralExpression([ @@ -96384,7 +99830,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 267 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 269 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -96474,19 +99920,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(factory, entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(factory.createExpressionStatement(factory.createAssignment(importVariableName, parameterName))); break; - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { if (ts.isNamedExports(entry.exportClause)) { @@ -96545,13 +99991,13 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return visitImportDeclaration(node); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: return visitExportDeclaration(node); - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -96731,7 +100177,7 @@ 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 === 297 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 299 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -96795,7 +100241,7 @@ 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 === 232 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 234 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasSyntacticModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -96857,10 +100303,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 264 /* NamedImports */: + case 266 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -97040,43 +100486,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return visitVariableStatement(node); - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: return visitClassDeclaration(node); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return visitForStatement(node); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return visitForInStatement(node); - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: return visitForOfStatement(node); - case 235 /* DoStatement */: + case 237 /* DoStatement */: return visitDoStatement(node); - case 236 /* WhileStatement */: + case 238 /* WhileStatement */: return visitWhileStatement(node); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return visitLabeledStatement(node); - case 243 /* WithStatement */: + case 245 /* WithStatement */: return visitWithStatement(node); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: return visitSwitchStatement(node); - case 258 /* CaseBlock */: + case 260 /* CaseBlock */: return visitCaseBlock(node); - case 284 /* CaseClause */: + case 286 /* CaseClause */: return visitCaseClause(node); - case 285 /* DefaultClause */: + case 287 /* DefaultClause */: return visitDefaultClause(node); - case 247 /* TryStatement */: + case 249 /* TryStatement */: return visitTryStatement(node); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return visitCatchClause(node); - case 230 /* Block */: + case 232 /* Block */: return visitBlock(node); - case 338 /* MergeDeclarationMarker */: + case 346 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 339 /* EndOfDeclarationMarker */: + case 347 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -97090,7 +100536,7 @@ var ts; function visitForStatement(node) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = factory.updateForStatement(node, node.initializer && visitForInitializer(node.initializer), ts.visitNode(node.condition, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.incrementor, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement)); + node = factory.updateForStatement(node, node.initializer && visitForInitializer(node.initializer), ts.visitNode(node.condition, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.incrementor, destructuringAndImportCallVisitor, ts.isExpression), ts.visitIterationBody(node.statement, nestedElementVisitor, context)); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } @@ -97102,7 +100548,7 @@ var ts; function visitForInStatement(node) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = factory.updateForInStatement(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock)); + node = factory.updateForInStatement(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitIterationBody(node.statement, nestedElementVisitor, context)); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } @@ -97114,7 +100560,7 @@ var ts; function visitForOfStatement(node) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = factory.updateForOfStatement(node, node.awaitModifier, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock)); + node = factory.updateForOfStatement(node, node.awaitModifier, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitIterationBody(node.statement, nestedElementVisitor, context)); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } @@ -97155,7 +100601,7 @@ var ts; * @param node The node to visit. */ function visitDoStatement(node) { - return factory.updateDoStatement(node, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression)); + return factory.updateDoStatement(node, ts.visitIterationBody(node.statement, nestedElementVisitor, context), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression)); } /** * Visits the body of a WhileStatement to hoist declarations. @@ -97163,7 +100609,7 @@ var ts; * @param node The node to visit. */ function visitWhileStatement(node) { - return factory.updateWhileStatement(node, ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock)); + return factory.updateWhileStatement(node, ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitIterationBody(node.statement, nestedElementVisitor, context)); } /** * Visits the body of a LabeledStatement to hoist declarations. @@ -97264,7 +100710,7 @@ var ts; else if (ts.isImportCall(node)) { return visitImportCallExpression(node); } - else if ((node.transformFlags & 1024 /* ContainsDestructuringAssignment */) || (node.transformFlags & 2097152 /* ContainsDynamicImport */)) { + else if ((node.transformFlags & 2048 /* ContainsDestructuringAssignment */) || (node.transformFlags & 4194304 /* ContainsDynamicImport */)) { return ts.visitEachChild(node, destructuringAndImportCallVisitor, context); } else { @@ -97302,7 +100748,7 @@ var ts; return ts.visitEachChild(node, destructuringAndImportCallVisitor, context); } /** - * Determines whether the target of a destructuring assigment refers to an exported symbol. + * Determines whether the target of a destructuring assignment refers to an exported symbol. * * @param node The destructuring target. */ @@ -97327,7 +100773,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 297 /* SourceFile */; + return container !== undefined && container.kind === 299 /* SourceFile */; } else { return false; @@ -97343,8 +100789,8 @@ var ts; */ function modifierVisitor(node) { switch (node.kind) { - case 92 /* ExportKeyword */: - case 87 /* DefaultKeyword */: + case 93 /* ExportKeyword */: + case 88 /* DefaultKeyword */: return undefined; } return node; @@ -97360,7 +100806,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 297 /* SourceFile */) { + if (node.kind === 299 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -97410,7 +100856,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -97445,14 +100891,14 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return substituteExpressionIdentifier(node); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return substituteBinaryExpression(node); - case 214 /* PrefixUnaryExpression */: - case 215 /* PostfixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: return substituteUnaryExpression(node); - case 226 /* MetaProperty */: + case 228 /* MetaProperty */: return substituteMetaProperty(node); } return node; @@ -97546,14 +100992,14 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 215 /* PostfixUnaryExpression */ + var expression = node.kind === 217 /* PostfixUnaryExpression */ ? ts.setTextRange(factory.createPrefixUnaryExpression(node.operator, node.operand), node) : node; for (var _i = 0, exportedNames_5 = exportedNames; _i < exportedNames_5.length; _i++) { var exportName = exportedNames_5[_i]; expression = createExportExpression(exportName, preventSubstitution(expression)); } - if (node.kind === 215 /* PostfixUnaryExpression */) { + if (node.kind === 217 /* PostfixUnaryExpression */) { expression = node.operator === 45 /* PlusPlusToken */ ? factory.createSubtract(preventSubstitution(expression), factory.createNumericLiteral(1)) : factory.createAdd(preventSubstitution(expression), factory.createNumericLiteral(1)); @@ -97581,7 +101027,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 297 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 299 /* SourceFile */) { exportedNames = ts.append(exportedNames, factory.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -97621,8 +101067,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(297 /* SourceFile */); - context.enableSubstitution(78 /* Identifier */); + context.enableEmitNotification(299 /* SourceFile */); + context.enableSubstitution(79 /* Identifier */); var helperNameSubstitutions; return ts.chainBundle(context, transformSourceFile); function transformSourceFile(node) { @@ -97653,12 +101099,12 @@ var ts; } function visitor(node) { switch (node.kind) { - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: // Elide `import=` as it is not legal with --module ES6 return undefined; - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return visitExportAssignment(node); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: var exportDecl = node; return visitExportDeclaration(exportDecl); } @@ -97763,7 +101209,8 @@ var ts; ts.isTypeAliasDeclaration(node) || ts.isConstructorDeclaration(node) || ts.isIndexSignatureDeclaration(node) || - ts.isPropertyAccessExpression(node); + ts.isPropertyAccessExpression(node) || + ts.isJSDocTypeAlias(node); } ts.canProduceDiagnostics = canProduceDiagnostics; function createGetSymbolAccessibilityDiagnosticForNodeName(node) { @@ -97792,7 +101239,7 @@ var ts; 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 === 252 /* ClassDeclaration */) { + else if (node.parent.kind === 254 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -97821,7 +101268,7 @@ var ts; 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 === 252 /* ClassDeclaration */) { + else if (node.parent.kind === 254 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -97861,14 +101308,14 @@ var ts; else if (ts.isImportEqualsDeclaration(node)) { return getImportEntityNameVisibilityError; } - else if (ts.isTypeAliasDeclaration(node)) { + else if (ts.isTypeAliasDeclaration(node) || ts.isJSDocTypeAlias(node)) { return getTypeAliasDeclarationVisibilityError; } else { return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]); } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 249 /* VariableDeclaration */ || node.kind === 198 /* BindingElement */) { + if (node.kind === 251 /* VariableDeclaration */ || node.kind === 200 /* BindingElement */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -97877,8 +101324,8 @@ var ts; } // 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 === 163 /* PropertyDeclaration */ || node.kind === 201 /* PropertyAccessExpression */ || node.kind === 162 /* PropertySignature */ || - (node.kind === 160 /* Parameter */ && ts.hasSyntacticModifier(node.parent, 8 /* Private */))) { + else if (node.kind === 165 /* PropertyDeclaration */ || node.kind === 203 /* PropertyAccessExpression */ || node.kind === 164 /* PropertySignature */ || + (node.kind === 162 /* Parameter */ && ts.hasSyntacticModifier(node.parent, 8 /* Private */))) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.hasSyntacticModifier(node, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? @@ -97887,7 +101334,7 @@ var ts; 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 === 252 /* ClassDeclaration */ || node.kind === 160 /* Parameter */) { + else if (node.parent.kind === 254 /* ClassDeclaration */ || node.kind === 162 /* Parameter */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -97912,7 +101359,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 168 /* SetAccessor */) { + if (node.kind === 170 /* 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.hasSyntacticModifier(node, 32 /* Static */)) { @@ -97951,26 +101398,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 170 /* ConstructSignature */: + case 172 /* 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 169 /* CallSignature */: + case 171 /* 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 171 /* IndexSignature */: + case 173 /* 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 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: if (ts.hasSyntacticModifier(node, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -97978,7 +101425,7 @@ var ts; 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 === 252 /* ClassDeclaration */) { + else if (node.parent.kind === 254 /* ClassDeclaration */) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* 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 : @@ -97992,7 +101439,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -98017,30 +101464,30 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 166 /* Constructor */: + case 168 /* Constructor */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* 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 170 /* ConstructSignature */: - case 175 /* ConstructorType */: + case 172 /* ConstructSignature */: + case 177 /* 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 169 /* CallSignature */: + case 171 /* 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 171 /* IndexSignature */: + case 173 /* 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 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: if (ts.hasSyntacticModifier(node.parent, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -98048,7 +101495,7 @@ var ts; 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 === 252 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 254 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* 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 : @@ -98061,15 +101508,15 @@ 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 251 /* FunctionDeclaration */: - case 174 /* FunctionType */: + case 253 /* FunctionDeclaration */: + case 176 /* FunctionType */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* 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 168 /* SetAccessor */: - case 167 /* GetAccessor */: + case 170 /* SetAccessor */: + case 169 /* GetAccessor */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -98083,39 +101530,39 @@ var ts; // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 253 /* InterfaceDeclaration */: + case 255 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 190 /* MappedType */: + case 192 /* MappedType */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1; break; - case 175 /* ConstructorType */: - case 170 /* ConstructSignature */: + case 177 /* ConstructorType */: + case 172 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 169 /* CallSignature */: + case 171 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 167 /* MethodDeclaration */: + case 166 /* MethodSignature */: if (ts.hasSyntacticModifier(node.parent, 32 /* Static */)) { 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 === 252 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 254 /* 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 174 /* FunctionType */: - case 251 /* FunctionDeclaration */: + case 176 /* FunctionType */: + case 253 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -98132,7 +101579,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 === 116 /* ImplementsKeyword */ ? + diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 117 /* 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; @@ -98154,11 +101601,13 @@ var ts; typeName: node.name }; } - function getTypeAliasDeclarationVisibilityError() { + function getTypeAliasDeclarationVisibilityError(symbolAccessibilityResult) { return { - diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, - errorNode: node.type, - typeName: node.name + diagnosticMessage: symbolAccessibilityResult.errorModuleName + ? ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1_from_module_2 + : ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, + errorNode: ts.isJSDocTypeAlias(node) ? ts.Debug.checkDefined(node.typeExpression) : node.type, + typeName: ts.isJSDocTypeAlias(node) ? ts.getNameOfDeclaration(node) : node.name, }; } } @@ -98179,7 +101628,7 @@ var ts; } function isInternalDeclaration(node, currentSourceFile) { var parseTreeNode = ts.getParseTreeNode(node); - if (parseTreeNode && parseTreeNode.kind === 160 /* Parameter */) { + if (parseTreeNode && parseTreeNode.kind === 162 /* Parameter */) { var paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode); var previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : undefined; var text = currentSourceFile.text; @@ -98241,6 +101690,7 @@ var ts; reportNonlocalAugmentation: reportNonlocalAugmentation }; var errorNameNode; + var errorFallbackNode; var currentSourceFile; var refs; var libs; @@ -98295,8 +101745,10 @@ var ts; else { context.addDiagnostic(ts.createDiagnosticForNode(symbolAccessibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, symbolAccessibilityResult.errorSymbolName, symbolAccessibilityResult.errorModuleName)); } + return true; } } + return false; } function trackExternalModuleSymbolOfImportTypeNode(symbol) { if (!isBundledEmit) { @@ -98305,13 +101757,14 @@ var ts; } function trackSymbol(symbol, enclosingDeclaration, meaning) { if (symbol.flags & 262144 /* TypeParameter */) - return; - handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, /*shouldComputeAliasesToMakeVisible*/ true)); + return false; + var issuedDiagnostic = handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, /*shouldComputeAliasesToMakeVisible*/ true)); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForSymbol(symbol, meaning)); + return issuedDiagnostic; } function reportPrivateInBaseOfClassExpression(propertyName) { - if (errorNameNode) { - context.addDiagnostic(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.Property_0_of_exported_class_expression_may_not_be_private_or_protected, propertyName)); + if (errorNameNode || errorFallbackNode) { + context.addDiagnostic(ts.createDiagnosticForNode((errorNameNode || errorFallbackNode), ts.Diagnostics.Property_0_of_exported_class_expression_may_not_be_private_or_protected, propertyName)); } } function reportInaccessibleUniqueSymbolError() { @@ -98335,35 +101788,38 @@ var ts; } } function reportTruncationError() { - if (errorNameNode) { - context.addDiagnostic(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_this_node_exceeds_the_maximum_length_the_compiler_will_serialize_An_explicit_type_annotation_is_needed)); + if (errorNameNode || errorFallbackNode) { + context.addDiagnostic(ts.createDiagnosticForNode((errorNameNode || errorFallbackNode), ts.Diagnostics.The_inferred_type_of_this_node_exceeds_the_maximum_length_the_compiler_will_serialize_An_explicit_type_annotation_is_needed)); } } function reportNonlocalAugmentation(containingFile, parentSymbol, symbol) { - var primaryDeclaration = ts.find(parentSymbol.declarations, function (d) { return ts.getSourceFileOfNode(d) === containingFile; }); + var _a; + var primaryDeclaration = (_a = parentSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.getSourceFileOfNode(d) === containingFile; }); var augmentingDeclarations = ts.filter(symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== containingFile; }); - for (var _i = 0, augmentingDeclarations_1 = augmentingDeclarations; _i < augmentingDeclarations_1.length; _i++) { - var augmentations = augmentingDeclarations_1[_i]; - context.addDiagnostic(ts.addRelatedInfo(ts.createDiagnosticForNode(augmentations, ts.Diagnostics.Declaration_augments_declaration_in_another_file_This_cannot_be_serialized), ts.createDiagnosticForNode(primaryDeclaration, ts.Diagnostics.This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_file))); + if (augmentingDeclarations) { + for (var _i = 0, augmentingDeclarations_1 = augmentingDeclarations; _i < augmentingDeclarations_1.length; _i++) { + var augmentations = augmentingDeclarations_1[_i]; + context.addDiagnostic(ts.addRelatedInfo(ts.createDiagnosticForNode(augmentations, ts.Diagnostics.Declaration_augments_declaration_in_another_file_This_cannot_be_serialized), ts.createDiagnosticForNode(primaryDeclaration, ts.Diagnostics.This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_file))); + } } } function transformDeclarationsForJS(sourceFile, bundled) { var oldDiag = getSymbolAccessibilityDiagnostic; - getSymbolAccessibilityDiagnostic = function (s) { return ({ + getSymbolAccessibilityDiagnostic = function (s) { return (s.errorNode && ts.canProduceDiagnostics(s.errorNode) ? ts.createGetSymbolAccessibilityDiagnosticForNode(s.errorNode)(s) : ({ diagnosticMessage: s.errorModuleName ? ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit : ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit, errorNode: s.errorNode || sourceFile - }); }; + })); }; var result = resolver.getDeclarationStatementsForSourceFile(sourceFile, declarationEmitNodeBuilderFlags, symbolTracker, bundled); getSymbolAccessibilityDiagnostic = oldDiag; return result; } function transformRoot(node) { - if (node.kind === 297 /* SourceFile */ && node.isDeclarationFile) { + if (node.kind === 299 /* SourceFile */ && node.isDeclarationFile) { return node; } - if (node.kind === 298 /* Bundle */) { + if (node.kind === 300 /* Bundle */) { isBundledEmit = true; refs = new ts.Map(); libs = new ts.Map(); @@ -98386,14 +101842,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(133 /* 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(134 /* 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 === 300 /* InputFiles */) { + if (prepend.kind === 302 /* InputFiles */) { var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal); hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib; collectReferences(sourceFile, refs); @@ -98485,7 +101941,7 @@ var ts; declFileName = paths.declarationFilePath || paths.jsFilePath || file.fileName; } if (declFileName) { - var specifier = ts.moduleSpecifiers.getModuleSpecifier(__assign(__assign({}, options), { baseUrl: options.baseUrl && ts.toPath(options.baseUrl, host.getCurrentDirectory(), host.getCanonicalFileName) }), currentSourceFile, ts.toPath(outputFilePath, host.getCurrentDirectory(), host.getCanonicalFileName), ts.toPath(declFileName, host.getCurrentDirectory(), host.getCanonicalFileName), host, + var specifier = ts.moduleSpecifiers.getModuleSpecifier(options, currentSourceFile, ts.toPath(outputFilePath, host.getCurrentDirectory(), host.getCanonicalFileName), ts.toPath(declFileName, host.getCurrentDirectory(), host.getCanonicalFileName), host, /*preferences*/ undefined); if (!ts.pathIsRelative(specifier)) { // If some compiler option/symlink/whatever allows access to the file containing the ambient module declaration @@ -98530,11 +101986,11 @@ var ts; return ret; } function filterBindingPatternInitializers(name) { - if (name.kind === 78 /* Identifier */) { + if (name.kind === 79 /* Identifier */) { return name; } else { - if (name.kind === 197 /* ArrayBindingPattern */) { + if (name.kind === 199 /* ArrayBindingPattern */) { return factory.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -98542,7 +101998,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 222 /* OmittedExpression */) { + if (elem.kind === 224 /* OmittedExpression */) { return elem; } return factory.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); @@ -98580,19 +102036,19 @@ var ts; // Literal const declarations will have an initializer ensured rather than a type return; } - var shouldUseResolverType = node.kind === 160 /* Parameter */ && + var shouldUseResolverType = node.kind === 162 /* 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(128 /* AnyKeyword */); + return type ? ts.visitNode(type, visitDeclarationSubtree) : factory.createKeywordTypeNode(129 /* AnyKeyword */); } - if (node.kind === 168 /* SetAccessor */) { + if (node.kind === 170 /* 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(128 /* AnyKeyword */); + return factory.createKeywordTypeNode(129 /* AnyKeyword */); } errorNameNode = node.name; var oldDiag; @@ -98600,12 +102056,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 249 /* VariableDeclaration */ || node.kind === 198 /* BindingElement */) { + if (node.kind === 251 /* VariableDeclaration */ || node.kind === 200 /* BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 160 /* Parameter */ - || node.kind === 163 /* PropertyDeclaration */ - || node.kind === 162 /* PropertySignature */) { + if (node.kind === 162 /* Parameter */ + || node.kind === 165 /* PropertyDeclaration */ + || node.kind === 164 /* PropertySignature */) { if (!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)); @@ -98616,30 +102072,39 @@ var ts; if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } - return returnValue || factory.createKeywordTypeNode(128 /* AnyKeyword */); + return returnValue || factory.createKeywordTypeNode(129 /* AnyKeyword */); } } function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 256 /* ModuleDeclaration */: - case 253 /* InterfaceDeclaration */: - case 252 /* ClassDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 255 /* EnumDeclaration */: + case 253 /* FunctionDeclaration */: + case 258 /* ModuleDeclaration */: + case 255 /* InterfaceDeclaration */: + case 254 /* ClassDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 257 /* EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return !getBindingNameVisible(node); - case 260 /* ImportEqualsDeclaration */: - case 261 /* ImportDeclaration */: - case 267 /* ExportDeclaration */: - case 266 /* ExportAssignment */: + case 262 /* ImportEqualsDeclaration */: + case 263 /* ImportDeclaration */: + case 269 /* ExportDeclaration */: + case 268 /* ExportAssignment */: return false; } return false; } + // If the ExpandoFunctionDeclaration have multiple overloads, then we only need to emit properties for the last one. + function shouldEmitFunctionProperties(input) { + var _a; + if (input.body) { + return true; + } + var overloadSignatures = (_a = input.symbol.declarations) === null || _a === void 0 ? void 0 : _a.filter(function (decl) { return ts.isFunctionDeclaration(decl) && !decl.body; }); + return !overloadSignatures || overloadSignatures.indexOf(input) === overloadSignatures.length - 1; + } function getBindingNameVisible(elem) { if (ts.isOmittedExpression(elem)) { return false; @@ -98716,7 +102181,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 256 /* ModuleDeclaration */ && parent.kind !== 195 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 258 /* ModuleDeclaration */ && parent.kind !== 197 /* ImportType */); if (ts.isStringLiteralLike(input)) { if (isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); @@ -98736,7 +102201,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 272 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 274 /* ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return factory.updateImportEqualsDeclaration(decl, @@ -98763,7 +102228,7 @@ var ts; return visibleDefaultBinding && factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier)); } - if (decl.importClause.namedBindings.kind === 263 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 265 /* 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, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier)) : undefined; @@ -98858,7 +102323,7 @@ var ts; // We'd see a TDZ violation at runtime var canProduceDiagnostic = ts.canProduceDiagnostics(input); var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 177 /* TypeLiteral */ || input.kind === 190 /* MappedType */) && input.parent.kind !== 254 /* TypeAliasDeclaration */); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 179 /* TypeLiteral */ || input.kind === 192 /* MappedType */) && input.parent.kind !== 256 /* 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 */)) { @@ -98879,21 +102344,21 @@ var ts; } if (isProcessedComponent(input)) { switch (input.kind) { - case 223 /* ExpressionWithTypeArguments */: { + case 225 /* 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 173 /* TypeReference */: { + case 175 /* TypeReference */: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(factory.updateTypeReferenceNode(node, node.typeName, node.typeArguments)); } - case 170 /* ConstructSignature */: + case 172 /* ConstructSignature */: return cleanup(factory.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 166 /* Constructor */: { + case 168 /* Constructor */: { // A constructor declaration may not have a type annotation var ctor = factory.createConstructorDeclaration( /*decorators*/ undefined, @@ -98901,7 +102366,7 @@ var ts; /*body*/ undefined); return cleanup(ctor); } - case 165 /* MethodDeclaration */: { + case 167 /* MethodDeclaration */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } @@ -98911,7 +102376,7 @@ var ts; /*body*/ undefined); return cleanup(sig); } - case 167 /* GetAccessor */: { + case 169 /* GetAccessor */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } @@ -98920,7 +102385,7 @@ var ts; /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* Private */)), ensureType(input, accessorType), /*body*/ undefined)); } - case 168 /* SetAccessor */: { + case 170 /* SetAccessor */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } @@ -98928,31 +102393,31 @@ var ts; /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* Private */)), /*body*/ undefined)); } - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } return cleanup(factory.updatePropertyDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type), ensureNoInitializer(input))); - case 162 /* PropertySignature */: + case 164 /* 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 164 /* MethodSignature */: { + case 166 /* 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 169 /* CallSignature */: { + case 171 /* CallSignature */: { return cleanup(factory.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 171 /* IndexSignature */: { + case 173 /* IndexSignature */: { return cleanup(factory.updateIndexSignature(input, - /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || factory.createKeywordTypeNode(128 /* AnyKeyword */))); + /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || factory.createKeywordTypeNode(129 /* AnyKeyword */))); } - case 249 /* VariableDeclaration */: { + case 251 /* VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -98960,13 +102425,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 159 /* TypeParameter */: { + case 161 /* TypeParameter */: { if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) { return cleanup(factory.updateTypeParameterDeclaration(input, input.name, /*constraint*/ undefined, /*defaultType*/ undefined)); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 184 /* ConditionalType */: { + case 186 /* 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); @@ -98978,13 +102443,13 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(factory.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 174 /* FunctionType */: { + case 176 /* FunctionType */: { return cleanup(factory.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 175 /* ConstructorType */: { + case 177 /* ConstructorType */: { return cleanup(factory.updateConstructorTypeNode(input, ensureModifiers(input), ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 195 /* ImportType */: { + case 197 /* ImportType */: { if (!ts.isLiteralImportTypeNode(input)) return cleanup(input); return cleanup(factory.updateImportTypeNode(input, factory.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); @@ -99016,7 +102481,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 165 /* MethodDeclaration */ && ts.hasEffectiveModifier(node.parent, 8 /* Private */); + return node.parent.kind === 167 /* MethodDeclaration */ && ts.hasEffectiveModifier(node.parent, 8 /* Private */); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -99026,7 +102491,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 267 /* ExportDeclaration */: { + case 269 /* ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } @@ -99036,13 +102501,13 @@ var ts; return factory.updateExportDeclaration(input, /*decorators*/ undefined, input.modifiers, input.isTypeOnly, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 266 /* ExportAssignment */: { + case 268 /* 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 === 78 /* Identifier */) { + if (input.expression.kind === 79 /* Identifier */) { return input; } else { @@ -99051,8 +102516,10 @@ var ts; diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0, errorNode: input }); }; + errorFallbackNode = input; var varDecl = factory.createVariableDeclaration(newId, /*exclamationToken*/ undefined, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); - var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(133 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); + errorFallbackNode = undefined; + var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(134 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); return [statement, factory.updateExportAssignment(input, input.decorators, input.modifiers, newId)]; } } @@ -99068,17 +102535,17 @@ var ts; // 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) & (11263 /* All */ ^ 1 /* Export */)); + var modifiers = factory.createModifiersFromModifierFlags(ts.getEffectiveModifierFlags(statement) & (27647 /* All */ ^ 1 /* Export */)); return factory.updateModifiers(statement, modifiers); } function transformTopLevelDeclaration(input) { if (shouldStripInternal(input)) return; switch (input.kind) { - case 260 /* ImportEqualsDeclaration */: { + case 262 /* ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 261 /* ImportDeclaration */: { + case 263 /* ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -99099,20 +102566,20 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 254 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 256 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all return cleanup(factory.updateTypeAliasDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 253 /* InterfaceDeclaration */: { + case 255 /* InterfaceDeclaration */: { return cleanup(factory.updateInterfaceDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 251 /* FunctionDeclaration */: { + case 253 /* FunctionDeclaration */: { // Generators lose their generator-ness, excepting their return type var clean = cleanup(factory.updateFunctionDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), /*asteriskToken*/ undefined, input.name, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), /*body*/ undefined)); - if (clean && resolver.isExpandoFunctionDeclaration(input)) { + 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(/*decorators*/ undefined, /*modifiers*/ undefined, clean.name || factory.createIdentifier("_default"), factory.createModuleBlock([]), 16 /* Namespace */); @@ -99121,7 +102588,7 @@ var ts; fakespace_1.symbol = props[0].parent; var exportMappings_1 = []; var declarations = ts.mapDefined(props, function (p) { - if (!ts.isPropertyAccessExpression(p.valueDeclaration)) { + if (!p.valueDeclaration || !ts.isPropertyAccessExpression(p.valueDeclaration)) { return undefined; // TODO GH#33569: Handle element access expressions that created late bound names (rather than silently omitting them) } getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p.valueDeclaration); @@ -99134,7 +102601,7 @@ var ts; exportMappings_1.push([name, nameStr]); } var varDecl = factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, type, /*initializer*/ undefined); - return factory.createVariableStatement(isNonContextualKeywordName ? undefined : [factory.createToken(92 /* ExportKeyword */)], factory.createVariableDeclarationList([varDecl])); + return factory.createVariableStatement(isNonContextualKeywordName ? undefined : [factory.createToken(93 /* ExportKeyword */)], factory.createVariableDeclarationList([varDecl])); }); if (!exportMappings_1.length) { declarations = ts.mapDefined(declarations, function (declaration) { return factory.updateModifiers(declaration, 0 /* None */); }); @@ -99173,10 +102640,10 @@ var ts; return clean; } } - case 256 /* ModuleDeclaration */: { + case 258 /* ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 257 /* ModuleBlock */) { + if (inner && inner.kind === 259 /* ModuleBlock */) { var oldNeedsScopeFix = needsScopeFixMarker; var oldHasScopeFix = resultHasScopeMarker; resultHasScopeMarker = false; @@ -99219,7 +102686,9 @@ var ts; /*decorators*/ undefined, mods, input.name, body)); } } - case 252 /* ClassDeclaration */: { + case 254 /* ClassDeclaration */: { + errorNameNode = input.name; + errorFallbackNode = input; var modifiers = factory.createNodeArray(ensureModifiers(input)); var typeParameters = ensureTypeParams(input, input.typeParameters); var ctor = ts.getFirstConstructorWithBody(input); @@ -99227,10 +102696,10 @@ var ts; if (ctor) { var oldDiag_1 = getSymbolAccessibilityDiagnostic; parameterProperties = ts.compact(ts.flatMap(ctor.parameters, function (param) { - if (!ts.hasSyntacticModifier(param, 92 /* ParameterPropertyModifier */) || shouldStripInternal(param)) + if (!ts.hasSyntacticModifier(param, 16476 /* ParameterPropertyModifier */) || shouldStripInternal(param)) return; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(param); - if (param.name.kind === 78 /* Identifier */) { + if (param.name.kind === 79 /* Identifier */) { return preserveJsDoc(factory.createPropertyDeclaration( /*decorators*/ undefined, ensureModifiers(param), param.name, param.questionToken, ensureType(param, param.type), ensureNoInitializer(param)), param); } @@ -99272,7 +102741,7 @@ 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 !== 103 /* NullKeyword */) { + if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 104 /* 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 */); @@ -99282,16 +102751,16 @@ var ts; 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(133 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(134 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); var heritageClauses = factory.createNodeArray(ts.map(input.heritageClauses, function (clause) { - if (clause.token === 93 /* ExtendsKeyword */) { + if (clause.token === 94 /* 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 === 103 /* 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 /* NullKeyword */; })), visitDeclarationSubtree)); })); return [statement, cleanup(factory.updateClassDeclaration(input, /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members))]; // TODO: GH#18217 @@ -99302,10 +102771,10 @@ var ts; /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 232 /* VariableStatement */: { + case 234 /* VariableStatement */: { return cleanup(transformVariableStatement(input)); } - case 255 /* EnumDeclaration */: { + case 257 /* EnumDeclaration */: { return cleanup(factory.updateEnumDeclaration(input, /*decorators*/ undefined, factory.createNodeArray(ensureModifiers(input)), input.name, factory.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -99324,12 +102793,14 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 256 /* ModuleDeclaration */) { + if (input.kind === 258 /* ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { return node; } + errorFallbackNode = undefined; + errorNameNode = undefined; return node && ts.setOriginalNode(preserveJsDoc(node, input), input); } } @@ -99345,7 +102816,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 222 /* OmittedExpression */) { + if (e.kind === 224 /* OmittedExpression */) { return; } if (e.name) { @@ -99393,9 +102864,9 @@ var ts; return factory.createModifiersFromModifierFlags(newFlags); } function ensureModifierFlags(node) { - var mask = 11263 /* All */ ^ (4 /* Public */ | 256 /* Async */); // No async modifiers in declaration files + var mask = 27647 /* 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 === 297 /* SourceFile */; + var parentIsFile = node.parent.kind === 299 /* SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= 2 /* Ambient */; additions = 0 /* None */; @@ -99418,13 +102889,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 === 93 /* ExtendsKeyword */ && t.expression.kind === 103 /* NullKeyword */); + return ts.isEntityNameExpression(t.expression) || (clause.token === 94 /* ExtendsKeyword */ && t.expression.kind === 104 /* NullKeyword */); })), visitDeclarationSubtree)); }), function (clause) { return clause.types && !!clause.types.length; })); } } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 253 /* InterfaceDeclaration */) { + if (node.kind === 255 /* InterfaceDeclaration */) { return true; } return false; @@ -99434,7 +102905,7 @@ var ts; return ts.factory.createModifiersFromModifierFlags(maskModifierFlags(node, modifierMask, modifierAdditions)); } function maskModifierFlags(node, modifierMask, modifierAdditions) { - if (modifierMask === void 0) { modifierMask = 11263 /* All */ ^ 4 /* Public */; } + if (modifierMask === void 0) { modifierMask = 27647 /* All */ ^ 4 /* Public */; } if (modifierAdditions === void 0) { modifierAdditions = 0 /* None */; } var flags = (ts.getEffectiveModifierFlags(node) & modifierMask) | modifierAdditions; if (flags & 512 /* Default */ && !(flags & 1 /* Export */)) { @@ -99449,7 +102920,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 167 /* GetAccessor */ + return accessor.kind === 169 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -99458,52 +102929,52 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: return !ts.hasEffectiveModifier(node, 8 /* Private */); - case 160 /* Parameter */: - case 249 /* VariableDeclaration */: + case 162 /* Parameter */: + case 251 /* VariableDeclaration */: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 256 /* ModuleDeclaration */: - case 260 /* ImportEqualsDeclaration */: - case 253 /* InterfaceDeclaration */: - case 252 /* ClassDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 255 /* EnumDeclaration */: - case 232 /* VariableStatement */: - case 261 /* ImportDeclaration */: - case 267 /* ExportDeclaration */: - case 266 /* ExportAssignment */: + case 253 /* FunctionDeclaration */: + case 258 /* ModuleDeclaration */: + case 262 /* ImportEqualsDeclaration */: + case 255 /* InterfaceDeclaration */: + case 254 /* ClassDeclaration */: + case 256 /* TypeAliasDeclaration */: + case 257 /* EnumDeclaration */: + case 234 /* VariableStatement */: + case 263 /* ImportDeclaration */: + case 269 /* ExportDeclaration */: + case 268 /* ExportAssignment */: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { - case 170 /* ConstructSignature */: - case 166 /* Constructor */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 164 /* MethodSignature */: - case 169 /* CallSignature */: - case 171 /* IndexSignature */: - case 249 /* VariableDeclaration */: - case 159 /* TypeParameter */: - case 223 /* ExpressionWithTypeArguments */: - case 173 /* TypeReference */: - case 184 /* ConditionalType */: - case 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 195 /* ImportType */: + case 172 /* ConstructSignature */: + case 168 /* Constructor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 165 /* PropertyDeclaration */: + case 164 /* PropertySignature */: + case 166 /* MethodSignature */: + case 171 /* CallSignature */: + case 173 /* IndexSignature */: + case 251 /* VariableDeclaration */: + case 161 /* TypeParameter */: + case 225 /* ExpressionWithTypeArguments */: + case 175 /* TypeReference */: + case 186 /* ConditionalType */: + case 176 /* FunctionType */: + case 177 /* ConstructorType */: + case 197 /* ImportType */: return true; } return false; @@ -99559,6 +103030,9 @@ var ts; if (languageVersion < 99 /* ESNext */) { transformers.push(ts.transformESNext); } + if (languageVersion < 8 /* ES2021 */) { + transformers.push(ts.transformES2021); + } if (languageVersion < 7 /* ES2020 */) { transformers.push(ts.transformES2020); } @@ -99635,7 +103109,7 @@ 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(341 /* Count */); + var enabledSyntaxKindFeatures = new Array(349 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentStatements; @@ -99646,6 +103120,9 @@ var ts; var lexicalEnvironmentFlagsStack = []; var lexicalEnvironmentStackOffset = 0; var lexicalEnvironmentSuspended = false; + var blockScopedVariableDeclarationsStack = []; + var blockScopeStackOffset = 0; + var blockScopedVariableDeclarations; var emitHelpers; var onSubstituteNode = noEmitSubstitution; var onEmitNode = noEmitNotification; @@ -99668,6 +103145,9 @@ var ts; hoistVariableDeclaration: hoistVariableDeclaration, hoistFunctionDeclaration: hoistFunctionDeclaration, addInitializationStatement: addInitializationStatement, + startBlockScope: startBlockScope, + endBlockScope: endBlockScope, + addBlockScopedVariable: addBlockScopedVariable, requestEmitHelper: requestEmitHelper, readEmitHelpers: readEmitHelpers, enableSubstitution: enableSubstitution, @@ -99711,9 +103191,9 @@ var ts; var transformed = []; for (var _a = 0, nodes_3 = nodes; _a < nodes_3.length; _a++) { var node = nodes_3[_a]; - ts.tracing.push("emit" /* Emit */, "transformNodes", node.kind === 297 /* 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" /* Emit */, "transformNodes", node.kind === 299 /* SourceFile */ ? { path: node.path } : { kind: node.kind, pos: node.pos, end: node.end }); transformed.push((allowDtsFiles ? transformation : transformRoot)(node)); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } // prevent modification of the lexical environment. state = 2 /* Completed */; @@ -99928,6 +103408,38 @@ var ts; function getLexicalEnvironmentFlags() { return lexicalEnvironmentFlags; } + /** + * 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."); + blockScopedVariableDeclarationsStack[blockScopeStackOffset] = blockScopedVariableDeclarations; + blockScopeStackOffset++; + blockScopedVariableDeclarations = undefined; + } + /** + * 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."); + var statements = ts.some(blockScopedVariableDeclarations) ? + [ + factory.createVariableStatement( + /*modifiers*/ undefined, factory.createVariableDeclarationList(blockScopedVariableDeclarations.map(function (identifier) { return factory.createVariableDeclaration(identifier); }), 1 /* Let */)) + ] : undefined; + blockScopeStackOffset--; + blockScopedVariableDeclarations = blockScopedVariableDeclarationsStack[blockScopeStackOffset]; + if (blockScopeStackOffset === 0) { + blockScopedVariableDeclarationsStack = []; + } + return statements; + } + function addBlockScopedVariable(name) { + ts.Debug.assert(blockScopeStackOffset > 0, "Cannot add a block scoped variable outside of an iteration body."); + (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."); @@ -99969,35 +103481,37 @@ var ts; } ts.transformNodes = transformNodes; ts.nullTransformationContext = { - get factory() { return ts.factory; }, - enableEmitNotification: ts.noop, - enableSubstitution: ts.noop, - endLexicalEnvironment: ts.returnUndefined, + factory: ts.factory, getCompilerOptions: function () { return ({}); }, - getEmitHost: ts.notImplemented, getEmitResolver: ts.notImplemented, + getEmitHost: ts.notImplemented, getEmitHelperFactory: ts.notImplemented, + startLexicalEnvironment: ts.noop, + resumeLexicalEnvironment: ts.noop, + suspendLexicalEnvironment: ts.noop, + endLexicalEnvironment: ts.returnUndefined, setLexicalEnvironmentFlags: ts.noop, getLexicalEnvironmentFlags: function () { return 0; }, - hoistFunctionDeclaration: ts.noop, hoistVariableDeclaration: ts.noop, + hoistFunctionDeclaration: ts.noop, addInitializationStatement: ts.noop, - isEmitNotificationEnabled: ts.notImplemented, - isSubstitutionEnabled: ts.notImplemented, - onEmitNode: ts.noop, - onSubstituteNode: ts.notImplemented, - readEmitHelpers: ts.notImplemented, + startBlockScope: ts.noop, + endBlockScope: ts.returnUndefined, + addBlockScopedVariable: ts.noop, requestEmitHelper: ts.noop, - resumeLexicalEnvironment: ts.noop, - startLexicalEnvironment: ts.noop, - suspendLexicalEnvironment: ts.noop, + readEmitHelpers: ts.notImplemented, + enableSubstitution: ts.noop, + enableEmitNotification: ts.noop, + isSubstitutionEnabled: ts.notImplemented, + isEmitNotificationEnabled: ts.notImplemented, + onSubstituteNode: noEmitSubstitution, + onEmitNode: noEmitNotification, addDiagnostic: ts.noop, }; })(ts || (ts = {})); var ts; (function (ts) { var brackets = createBracketsMap(); - var syntheticParent = { pos: -1, end: -1 }; /*@internal*/ function isBuildInfoFile(file) { return ts.fileExtensionIs(file, ".tsbuildinfo" /* TsBuildInfo */); @@ -100083,7 +103597,7 @@ var ts; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 298 /* Bundle */) { + if (sourceFile.kind === 300 /* Bundle */) { return getOutputPathsForBundle(options, forceDtsPaths); } else { @@ -100309,15 +103823,15 @@ var ts; sourceFiles: sourceFileOrBundle.sourceFiles.map(function (file) { return relativeToBuildInfo(ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory())); }) }; } - ts.tracing.push("emit" /* Emit */, "emitJsFileOrBundle", { jsFilePath: jsFilePath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitJsFileOrBundle", { jsFilePath: jsFilePath }); emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo); - ts.tracing.pop(); - ts.tracing.push("emit" /* Emit */, "emitDeclarationFileOrBundle", { declarationFilePath: declarationFilePath }); + 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 }); emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo); - ts.tracing.pop(); - ts.tracing.push("emit" /* Emit */, "emitBuildInfo", { buildInfoPath: buildInfoPath }); + 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 }); emitBuildInfo(bundleBuildInfo, buildInfoPath); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); if (!emitSkipped && emittedFilesList) { if (!emitOnlyDtsFiles) { if (jsFilePath) { @@ -100444,13 +103958,13 @@ var ts; 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: compilerOptions.declarationMap, + sourceMap: !forceDtsEmit && compilerOptions.declarationMap, sourceRoot: compilerOptions.sourceRoot, mapRoot: compilerOptions.mapRoot, extendedDiagnostics: compilerOptions.extendedDiagnostics, // Explicitly do not passthru either `inline` option }); - if (forceDtsEmit && declarationTransform.transformed[0].kind === 297 /* SourceFile */) { + if (forceDtsEmit && declarationTransform.transformed[0].kind === 299 /* SourceFile */) { var sourceFile = declarationTransform.transformed[0]; exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; } @@ -100461,7 +103975,7 @@ var ts; } function collectLinkedAliases(node) { if (ts.isExportAssignment(node)) { - if (node.expression.kind === 78 /* Identifier */) { + if (node.expression.kind === 79 /* Identifier */) { resolver.collectLinkedAliases(node.expression, /*setVisibility*/ true); } return; @@ -100473,8 +103987,8 @@ var ts; ts.forEachChild(node, collectLinkedAliases); } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) { - var bundle = sourceFileOrBundle.kind === 298 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 297 /* SourceFile */ ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 300 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 299 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; var sourceMapGenerator; if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { @@ -100515,7 +104029,7 @@ var ts; } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { return (mapOptions.sourceMap || mapOptions.inlineSourceMap) - && (sourceFileOrBundle.kind !== 297 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); + && (sourceFileOrBundle.kind !== 299 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); } function getSourceRoot(mapOptions) { // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the @@ -100574,7 +104088,7 @@ var ts; ts.emitFiles = emitFiles; /*@internal*/ function getBuildInfoText(buildInfo) { - return JSON.stringify(buildInfo, undefined, 2); + return JSON.stringify(buildInfo); } ts.getBuildInfoText = getBuildInfoText; /*@internal*/ @@ -100755,7 +104269,7 @@ var ts; function createPrinter(printerOptions, handlers) { if (printerOptions === void 0) { printerOptions = {}; } if (handlers === void 0) { handlers = {}; } - var hasGlobalName = handlers.hasGlobalName, _a = handlers.onEmitNode, onEmitNode = _a === void 0 ? ts.noEmitNotification : _a, isEmitNotificationEnabled = handlers.isEmitNotificationEnabled, _b = handlers.substituteNode, substituteNode = _b === void 0 ? ts.noEmitSubstitution : _b, onBeforeEmitNodeArray = handlers.onBeforeEmitNodeArray, onAfterEmitNodeArray = handlers.onAfterEmitNodeArray, onBeforeEmitToken = handlers.onBeforeEmitToken, onAfterEmitToken = handlers.onAfterEmitToken; + var hasGlobalName = handlers.hasGlobalName, _a = handlers.onEmitNode, onEmitNode = _a === void 0 ? ts.noEmitNotification : _a, isEmitNotificationEnabled = handlers.isEmitNotificationEnabled, _b = handlers.substituteNode, substituteNode = _b === void 0 ? ts.noEmitSubstitution : _b, onBeforeEmitNode = handlers.onBeforeEmitNode, onAfterEmitNode = handlers.onAfterEmitNode, onBeforeEmitNodeArray = handlers.onBeforeEmitNodeArray, onAfterEmitNodeArray = handlers.onAfterEmitNodeArray, onBeforeEmitToken = handlers.onBeforeEmitToken, onAfterEmitToken = handlers.onAfterEmitToken; var extendedDiagnostics = !!printerOptions.extendedDiagnostics; var newLine = ts.getNewLineCharacter(printerOptions); var moduleKind = ts.getEmitModuleKind(printerOptions); @@ -100794,9 +104308,11 @@ var ts; var detachedCommentsInfo; var hasWrittenComment = false; var commentsDisabled = !!printerOptions.removeComments; - var lastNode; var lastSubstitution; + var currentParenthesizerRule; var _c = ts.performance.createTimerIf(extendedDiagnostics, "commentTime", "beforeComment", "afterComment"), enterComment = _c.enter, exitComment = _c.exit; + var parenthesizer = ts.factory.parenthesizer; + var emitBinaryExpression = createEmitBinaryExpression(); reset(); return { // public API @@ -100824,9 +104340,9 @@ var ts; break; } switch (node.kind) { - case 297 /* SourceFile */: return printFile(node); - case 298 /* Bundle */: return printBundle(node); - case 299 /* UnparsedSource */: return printUnparsedSource(node); + case 299 /* SourceFile */: return printFile(node); + case 300 /* Bundle */: return printBundle(node); + case 301 /* UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -100860,7 +104376,7 @@ var ts; if (sourceFile) { setSourceFile(sourceFile); } - emitList(syntheticParent, nodes, format); + emitList(/*parentNode*/ undefined, nodes, format); reset(); writer = previousWriter; } @@ -100995,7 +104511,7 @@ var ts; if (sourceFile) { setSourceFile(sourceFile); } - pipelineEmit(hint, node); + pipelineEmit(hint, node, /*parenthesizerRule*/ undefined); } function setSourceFile(sourceFile) { currentSourceFile = sourceFile; @@ -101023,51 +104539,54 @@ var ts; currentSourceFile = undefined; currentLineMap = undefined; detachedCommentsInfo = undefined; - lastNode = undefined; - lastSubstitution = undefined; setWriter(/*output*/ undefined, /*_sourceMapGenerator*/ undefined); } function getCurrentLineMap() { return currentLineMap || (currentLineMap = ts.getLineStarts(currentSourceFile)); } - function emit(node) { + function emit(node, parenthesizerRule) { if (node === undefined) return; var prevSourceFileTextKind = recordBundleFileInternalSectionStart(node); - var substitute = pipelineEmit(4 /* Unspecified */, node); + pipelineEmit(4 /* Unspecified */, node, parenthesizerRule); recordBundleFileInternalSectionEnd(prevSourceFileTextKind); - return substitute; } function emitIdentifierName(node) { if (node === undefined) return; - return pipelineEmit(2 /* IdentifierName */, node); + pipelineEmit(2 /* IdentifierName */, node, /*parenthesizerRule*/ undefined); } - function emitExpression(node) { + function emitExpression(node, parenthesizerRule) { if (node === undefined) return; - return pipelineEmit(1 /* Expression */, node); + pipelineEmit(1 /* Expression */, node, parenthesizerRule); } function emitJsxAttributeValue(node) { - return pipelineEmit(ts.isStringLiteral(node) ? 6 /* JsxAttributeValue */ : 4 /* Unspecified */, node); + pipelineEmit(ts.isStringLiteral(node) ? 6 /* JsxAttributeValue */ : 4 /* Unspecified */, node); } - function pipelineEmit(emitHint, node) { - var savedLastNode = lastNode; - var savedLastSubstitution = lastSubstitution; - var savedPreserveSourceNewlines = preserveSourceNewlines; - lastNode = node; - lastSubstitution = undefined; - if (preserveSourceNewlines && !!(ts.getEmitFlags(node) & 134217728 /* IgnoreSourceNewlines */)) { + function beforeEmitNode(node) { + if (preserveSourceNewlines && (ts.getEmitFlags(node) & 134217728 /* IgnoreSourceNewlines */)) { preserveSourceNewlines = false; } + } + function afterEmitNode(savedPreserveSourceNewlines) { + preserveSourceNewlines = savedPreserveSourceNewlines; + } + function pipelineEmit(emitHint, node, parenthesizerRule) { + currentParenthesizerRule = parenthesizerRule; var pipelinePhase = getPipelinePhase(0 /* Notification */, emitHint, node); pipelinePhase(emitHint, node); - ts.Debug.assert(lastNode === node); - var substitute = lastSubstitution; - lastNode = savedLastNode; - lastSubstitution = savedLastSubstitution; - preserveSourceNewlines = savedPreserveSourceNewlines; - return substitute || node; + currentParenthesizerRule = undefined; + } + function shouldEmitComments(node) { + return !commentsDisabled && !ts.isSourceFile(node); + } + function shouldEmitSourceMaps(node) { + return !sourceMapsDisabled && + !ts.isSourceFile(node) && + !ts.isInJsonFile(node) && + !ts.isUnparsedSource(node) && + !ts.isUnparsedPrepend(node); } function getPipelinePhase(phase, emitHint, node) { switch (phase) { @@ -101077,18 +104596,21 @@ var ts; } // falls through case 1 /* Substitution */: - if (substituteNode !== ts.noEmitSubstitution && (lastSubstitution = substituteNode(emitHint, node)) !== node) { + if (substituteNode !== ts.noEmitSubstitution && (lastSubstitution = substituteNode(emitHint, node) || node) !== node) { + if (currentParenthesizerRule) { + lastSubstitution = currentParenthesizerRule(lastSubstitution); + } return pipelineEmitWithSubstitution; } // falls through case 2 /* Comments */: - if (!commentsDisabled && node.kind !== 297 /* SourceFile */) { + if (shouldEmitComments(node)) { return pipelineEmitWithComments; } // falls through case 3 /* SourceMaps */: - if (!sourceMapsDisabled && node.kind !== 297 /* SourceFile */ && !ts.isInJsonFile(node)) { - return pipelineEmitWithSourceMap; + if (shouldEmitSourceMaps(node)) { + return pipelineEmitWithSourceMaps; } // falls through case 4 /* Emit */: @@ -101101,13 +104623,25 @@ var ts; return getPipelinePhase(currentPhase + 1, emitHint, node); } function pipelineEmitWithNotification(hint, node) { - ts.Debug.assert(lastNode === node); var pipelinePhase = getNextPipelinePhase(0 /* Notification */, hint, node); onEmitNode(hint, node, pipelinePhase); - ts.Debug.assert(lastNode === node); } function pipelineEmitWithHint(hint, node) { - ts.Debug.assert(lastNode === node || lastSubstitution === node); + onBeforeEmitNode === null || onBeforeEmitNode === void 0 ? void 0 : onBeforeEmitNode(node); + if (preserveSourceNewlines) { + var savedPreserveSourceNewlines = preserveSourceNewlines; + beforeEmitNode(node); + pipelineEmitWithHintWorker(hint, node); + afterEmitNode(savedPreserveSourceNewlines); + } + else { + pipelineEmitWithHintWorker(hint, node); + } + onAfterEmitNode === null || onAfterEmitNode === void 0 ? void 0 : onAfterEmitNode(node); + // clear the parenthesizer rule as we ascend + currentParenthesizerRule = undefined; + } + function pipelineEmitWithHintWorker(hint, node) { if (hint === 0 /* SourceFile */) return emitSourceFile(ts.cast(node, ts.isSourceFile)); if (hint === 2 /* IdentifierName */) @@ -101121,308 +104655,337 @@ var ts; return emitEmptyStatement(/*isEmbeddedStatement*/ true); } if (hint === 4 /* Unspecified */) { - if (ts.isKeyword(node.kind)) - return writeTokenNode(node, writeKeyword); switch (node.kind) { // Pseudo-literals case 15 /* TemplateHead */: case 16 /* TemplateMiddle */: case 17 /* TemplateTail */: return emitLiteral(node, /*jsxAttributeEscape*/ false); - case 299 /* UnparsedSource */: - case 293 /* UnparsedPrepend */: - return emitUnparsedSourceOrPrepend(node); - case 292 /* UnparsedPrologue */: - return writeUnparsedNode(node); - case 294 /* UnparsedText */: - case 295 /* UnparsedInternalText */: - return emitUnparsedTextLike(node); - case 296 /* UnparsedSyntheticReference */: - return emitUnparsedSyntheticReference(node); // Identifiers - case 78 /* Identifier */: + case 79 /* Identifier */: return emitIdentifier(node); // PrivateIdentifiers - case 79 /* PrivateIdentifier */: + case 80 /* PrivateIdentifier */: return emitPrivateIdentifier(node); // Parse tree nodes // Names - case 157 /* QualifiedName */: + case 159 /* QualifiedName */: return emitQualifiedName(node); - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 159 /* TypeParameter */: + case 161 /* TypeParameter */: return emitTypeParameter(node); - case 160 /* Parameter */: + case 162 /* Parameter */: return emitParameter(node); - case 161 /* Decorator */: + case 163 /* Decorator */: return emitDecorator(node); // Type members - case 162 /* PropertySignature */: + case 164 /* PropertySignature */: return emitPropertySignature(node); - case 163 /* PropertyDeclaration */: + case 165 /* PropertyDeclaration */: return emitPropertyDeclaration(node); - case 164 /* MethodSignature */: + case 166 /* MethodSignature */: return emitMethodSignature(node); - case 165 /* MethodDeclaration */: + case 167 /* MethodDeclaration */: return emitMethodDeclaration(node); - case 166 /* Constructor */: + case 168 /* Constructor */: return emitConstructor(node); - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return emitAccessorDeclaration(node); - case 169 /* CallSignature */: + case 171 /* CallSignature */: return emitCallSignature(node); - case 170 /* ConstructSignature */: + case 172 /* ConstructSignature */: return emitConstructSignature(node); - case 171 /* IndexSignature */: + case 173 /* IndexSignature */: return emitIndexSignature(node); - case 194 /* TemplateLiteralTypeSpan */: - return emitTemplateTypeSpan(node); // Types - case 172 /* TypePredicate */: + case 174 /* TypePredicate */: return emitTypePredicate(node); - case 173 /* TypeReference */: + case 175 /* TypeReference */: return emitTypeReference(node); - case 174 /* FunctionType */: + case 176 /* FunctionType */: return emitFunctionType(node); - case 308 /* JSDocFunctionType */: - return emitJSDocFunctionType(node); - case 175 /* ConstructorType */: + case 177 /* ConstructorType */: return emitConstructorType(node); - case 176 /* TypeQuery */: + case 178 /* TypeQuery */: return emitTypeQuery(node); - case 177 /* TypeLiteral */: + case 179 /* TypeLiteral */: return emitTypeLiteral(node); - case 178 /* ArrayType */: + case 180 /* ArrayType */: return emitArrayType(node); - case 179 /* TupleType */: + case 181 /* TupleType */: return emitTupleType(node); - case 180 /* OptionalType */: + case 182 /* OptionalType */: return emitOptionalType(node); - case 182 /* UnionType */: + // SyntaxKind.RestType is handled below + case 184 /* UnionType */: return emitUnionType(node); - case 183 /* IntersectionType */: + case 185 /* IntersectionType */: return emitIntersectionType(node); - case 184 /* ConditionalType */: + case 186 /* ConditionalType */: return emitConditionalType(node); - case 185 /* InferType */: + case 187 /* InferType */: return emitInferType(node); - case 186 /* ParenthesizedType */: + case 188 /* ParenthesizedType */: return emitParenthesizedType(node); - case 223 /* ExpressionWithTypeArguments */: + case 225 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 187 /* ThisType */: + case 189 /* ThisType */: return emitThisType(); - case 188 /* TypeOperator */: + case 190 /* TypeOperator */: return emitTypeOperator(node); - case 189 /* IndexedAccessType */: + case 191 /* IndexedAccessType */: return emitIndexedAccessType(node); - case 190 /* MappedType */: + case 192 /* MappedType */: return emitMappedType(node); - case 191 /* LiteralType */: + case 193 /* LiteralType */: return emitLiteralType(node); - case 193 /* TemplateLiteralType */: + case 194 /* NamedTupleMember */: + return emitNamedTupleMember(node); + case 195 /* TemplateLiteralType */: return emitTemplateType(node); - case 195 /* ImportType */: + case 196 /* TemplateLiteralTypeSpan */: + return emitTemplateTypeSpan(node); + case 197 /* ImportType */: return emitImportTypeNode(node); - case 303 /* JSDocAllType */: - writePunctuation("*"); - return; - case 304 /* JSDocUnknownType */: - writePunctuation("?"); - return; - case 305 /* JSDocNullableType */: - return emitJSDocNullableType(node); - case 306 /* JSDocNonNullableType */: - return emitJSDocNonNullableType(node); - case 307 /* JSDocOptionalType */: - return emitJSDocOptionalType(node); - case 181 /* RestType */: - case 309 /* JSDocVariadicType */: - return emitRestOrJSDocVariadicType(node); - case 192 /* NamedTupleMember */: - return emitNamedTupleMember(node); // Binding patterns - case 196 /* ObjectBindingPattern */: + case 198 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 197 /* ArrayBindingPattern */: + case 199 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 198 /* BindingElement */: + case 200 /* BindingElement */: return emitBindingElement(node); // Misc - case 228 /* TemplateSpan */: + case 230 /* TemplateSpan */: return emitTemplateSpan(node); - case 229 /* SemicolonClassElement */: + case 231 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 230 /* Block */: + case 232 /* Block */: return emitBlock(node); - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: return emitVariableStatement(node); - case 231 /* EmptyStatement */: + case 233 /* EmptyStatement */: return emitEmptyStatement(/*isEmbeddedStatement*/ false); - case 233 /* ExpressionStatement */: + case 235 /* ExpressionStatement */: return emitExpressionStatement(node); - case 234 /* IfStatement */: + case 236 /* IfStatement */: return emitIfStatement(node); - case 235 /* DoStatement */: + case 237 /* DoStatement */: return emitDoStatement(node); - case 236 /* WhileStatement */: + case 238 /* WhileStatement */: return emitWhileStatement(node); - case 237 /* ForStatement */: + case 239 /* ForStatement */: return emitForStatement(node); - case 238 /* ForInStatement */: + case 240 /* ForInStatement */: return emitForInStatement(node); - case 239 /* ForOfStatement */: + case 241 /* ForOfStatement */: return emitForOfStatement(node); - case 240 /* ContinueStatement */: + case 242 /* ContinueStatement */: return emitContinueStatement(node); - case 241 /* BreakStatement */: + case 243 /* BreakStatement */: return emitBreakStatement(node); - case 242 /* ReturnStatement */: + case 244 /* ReturnStatement */: return emitReturnStatement(node); - case 243 /* WithStatement */: + case 245 /* WithStatement */: return emitWithStatement(node); - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: return emitSwitchStatement(node); - case 245 /* LabeledStatement */: + case 247 /* LabeledStatement */: return emitLabeledStatement(node); - case 246 /* ThrowStatement */: + case 248 /* ThrowStatement */: return emitThrowStatement(node); - case 247 /* TryStatement */: + case 249 /* TryStatement */: return emitTryStatement(node); - case 248 /* DebuggerStatement */: + case 250 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 249 /* VariableDeclaration */: + case 251 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 250 /* VariableDeclarationList */: + case 252 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 252 /* ClassDeclaration */: + case 254 /* ClassDeclaration */: return emitClassDeclaration(node); - case 253 /* InterfaceDeclaration */: + case 255 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 255 /* EnumDeclaration */: + case 257 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 256 /* ModuleDeclaration */: + case 258 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 257 /* ModuleBlock */: + case 259 /* ModuleBlock */: return emitModuleBlock(node); - case 258 /* CaseBlock */: + case 260 /* CaseBlock */: return emitCaseBlock(node); - case 259 /* NamespaceExportDeclaration */: + case 261 /* NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: return emitImportDeclaration(node); - case 262 /* ImportClause */: + case 264 /* ImportClause */: return emitImportClause(node); - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: return emitNamespaceImport(node); - case 269 /* NamespaceExport */: + case 271 /* NamespaceExport */: return emitNamespaceExport(node); - case 264 /* NamedImports */: + case 266 /* NamedImports */: return emitNamedImports(node); - case 265 /* ImportSpecifier */: + case 267 /* ImportSpecifier */: return emitImportSpecifier(node); - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: return emitExportAssignment(node); - case 267 /* ExportDeclaration */: + case 269 /* ExportDeclaration */: return emitExportDeclaration(node); - case 268 /* NamedExports */: + case 270 /* NamedExports */: return emitNamedExports(node); - case 270 /* ExportSpecifier */: + case 272 /* ExportSpecifier */: return emitExportSpecifier(node); - case 271 /* MissingDeclaration */: + case 273 /* MissingDeclaration */: return; // Module references - case 272 /* ExternalModuleReference */: + case 274 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 11 /* JsxText */: return emitJsxText(node); - case 275 /* JsxOpeningElement */: - case 278 /* JsxOpeningFragment */: + case 277 /* JsxOpeningElement */: + case 280 /* JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 276 /* JsxClosingElement */: - case 279 /* JsxClosingFragment */: + case 278 /* JsxClosingElement */: + case 281 /* JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 280 /* JsxAttribute */: + case 282 /* JsxAttribute */: return emitJsxAttribute(node); - case 281 /* JsxAttributes */: + case 283 /* JsxAttributes */: return emitJsxAttributes(node); - case 282 /* JsxSpreadAttribute */: + case 284 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 283 /* JsxExpression */: + case 285 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 284 /* CaseClause */: + case 286 /* CaseClause */: return emitCaseClause(node); - case 285 /* DefaultClause */: + case 287 /* DefaultClause */: return emitDefaultClause(node); - case 286 /* HeritageClause */: + case 288 /* HeritageClause */: return emitHeritageClause(node); - case 287 /* CatchClause */: + case 289 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 288 /* PropertyAssignment */: + case 290 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 289 /* ShorthandPropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 290 /* SpreadAssignment */: + case 292 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 291 /* EnumMember */: + case 293 /* EnumMember */: return emitEnumMember(node); + // Unparsed + case 294 /* UnparsedPrologue */: + return writeUnparsedNode(node); + case 301 /* UnparsedSource */: + case 295 /* UnparsedPrepend */: + return emitUnparsedSourceOrPrepend(node); + case 296 /* UnparsedText */: + case 297 /* UnparsedInternalText */: + return emitUnparsedTextLike(node); + case 298 /* UnparsedSyntheticReference */: + return emitUnparsedSyntheticReference(node); + // Top-level nodes + case 299 /* SourceFile */: + return emitSourceFile(node); + case 300 /* Bundle */: + return ts.Debug.fail("Bundles should be printed using printBundle"); + // SyntaxKind.UnparsedSource (handled above) + case 302 /* InputFiles */: + return ts.Debug.fail("InputFiles should not be printed"); // JSDoc nodes (only used in codefixes currently) - case 326 /* JSDocParameterTag */: - case 333 /* JSDocPropertyTag */: + case 303 /* JSDocTypeExpression */: + return emitJSDocTypeExpression(node); + case 304 /* JSDocNameReference */: + return emitJSDocNameReference(node); + case 306 /* JSDocAllType */: + return writePunctuation("*"); + case 307 /* JSDocUnknownType */: + return writePunctuation("?"); + case 308 /* JSDocNullableType */: + return emitJSDocNullableType(node); + case 309 /* JSDocNonNullableType */: + return emitJSDocNonNullableType(node); + case 310 /* JSDocOptionalType */: + return emitJSDocOptionalType(node); + case 311 /* JSDocFunctionType */: + return emitJSDocFunctionType(node); + case 183 /* RestType */: + case 312 /* JSDocVariadicType */: + return emitRestOrJSDocVariadicType(node); + case 313 /* JSDocNamepathType */: + return; + case 314 /* JSDocComment */: + return emitJSDoc(node); + case 316 /* JSDocTypeLiteral */: + return emitJSDocTypeLiteral(node); + case 317 /* JSDocSignature */: + return emitJSDocSignature(node); + case 321 /* JSDocTag */: + case 326 /* JSDocClassTag */: + return emitJSDocSimpleTag(node); + case 322 /* JSDocAugmentsTag */: + case 323 /* JSDocImplementsTag */: + return emitJSDocHeritageTag(node); + case 324 /* JSDocAuthorTag */: + case 325 /* JSDocDeprecatedTag */: + return; + // SyntaxKind.JSDocClassTag (see JSDocTag, above) + case 327 /* JSDocPublicTag */: + case 328 /* JSDocPrivateTag */: + case 329 /* JSDocProtectedTag */: + case 330 /* JSDocReadonlyTag */: + case 331 /* JSDocOverrideTag */: + return; + case 332 /* JSDocCallbackTag */: + return emitJSDocCallbackTag(node); + // SyntaxKind.JSDocEnumTag (see below) + case 334 /* JSDocParameterTag */: + case 341 /* JSDocPropertyTag */: return emitJSDocPropertyLikeTag(node); - case 327 /* JSDocReturnTag */: - case 329 /* JSDocTypeTag */: - case 328 /* JSDocThisTag */: - case 325 /* JSDocEnumTag */: + case 333 /* JSDocEnumTag */: + case 335 /* JSDocReturnTag */: + case 336 /* JSDocThisTag */: + case 337 /* JSDocTypeTag */: return emitJSDocSimpleTypedTag(node); - case 316 /* JSDocImplementsTag */: - case 315 /* JSDocAugmentsTag */: - return emitJSDocHeritageTag(node); - case 330 /* JSDocTemplateTag */: + case 338 /* JSDocTemplateTag */: return emitJSDocTemplateTag(node); - case 331 /* JSDocTypedefTag */: + case 339 /* JSDocTypedefTag */: return emitJSDocTypedefTag(node); - case 324 /* JSDocCallbackTag */: - return emitJSDocCallbackTag(node); - case 313 /* JSDocSignature */: - return emitJSDocSignature(node); - case 312 /* JSDocTypeLiteral */: - return emitJSDocTypeLiteral(node); - case 319 /* JSDocClassTag */: - case 314 /* JSDocTag */: - return emitJSDocSimpleTag(node); - case 332 /* JSDocSeeTag */: + case 340 /* JSDocSeeTag */: return emitJSDocSeeTag(node); - case 302 /* JSDocNameReference */: - return emitJSDocNameReference(node); - case 311 /* JSDocComment */: - return emitJSDoc(node); - // Transformation nodes (ignored) + // SyntaxKind.JSDocPropertyTag (see JSDocParameterTag, above) + // Transformation nodes + case 343 /* NotEmittedStatement */: + case 347 /* EndOfDeclarationMarker */: + case 346 /* MergeDeclarationMarker */: + return; } if (ts.isExpression(node)) { hint = 1 /* Expression */; if (substituteNode !== ts.noEmitSubstitution) { - lastSubstitution = node = substituteNode(hint, node); + var substitute = substituteNode(hint, node) || node; + if (substitute !== node) { + node = substitute; + if (currentParenthesizerRule) { + node = currentParenthesizerRule(node); + } + } } } - else if (ts.isToken(node)) { - return writeTokenNode(node, writePunctuation); - } } if (hint === 1 /* Expression */) { switch (node.kind) { @@ -101435,86 +104998,94 @@ var ts; case 14 /* NoSubstitutionTemplateLiteral */: return emitLiteral(node, /*jsxAttributeEscape*/ false); // Identifiers - case 78 /* Identifier */: + case 79 /* Identifier */: return emitIdentifier(node); - // Reserved words - case 94 /* FalseKeyword */: - case 103 /* NullKeyword */: - case 105 /* SuperKeyword */: - case 109 /* TrueKeyword */: - case 107 /* ThisKeyword */: - case 99 /* ImportKeyword */: - writeTokenNode(node, writeKeyword); - return; // Expressions - case 199 /* ArrayLiteralExpression */: + case 201 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 200 /* ObjectLiteralExpression */: + case 202 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 201 /* PropertyAccessExpression */: + case 203 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 202 /* ElementAccessExpression */: + case 204 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 203 /* CallExpression */: + case 205 /* CallExpression */: return emitCallExpression(node); - case 204 /* NewExpression */: + case 206 /* NewExpression */: return emitNewExpression(node); - case 205 /* TaggedTemplateExpression */: + case 207 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 206 /* TypeAssertionExpression */: + case 208 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 207 /* ParenthesizedExpression */: + case 209 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 208 /* FunctionExpression */: + case 210 /* FunctionExpression */: return emitFunctionExpression(node); - case 209 /* ArrowFunction */: + case 211 /* ArrowFunction */: return emitArrowFunction(node); - case 210 /* DeleteExpression */: + case 212 /* DeleteExpression */: return emitDeleteExpression(node); - case 211 /* TypeOfExpression */: + case 213 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 212 /* VoidExpression */: + case 214 /* VoidExpression */: return emitVoidExpression(node); - case 213 /* AwaitExpression */: + case 215 /* AwaitExpression */: return emitAwaitExpression(node); - case 214 /* PrefixUnaryExpression */: + case 216 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 215 /* PostfixUnaryExpression */: + case 217 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 216 /* BinaryExpression */: + case 218 /* BinaryExpression */: return emitBinaryExpression(node); - case 217 /* ConditionalExpression */: + case 219 /* ConditionalExpression */: return emitConditionalExpression(node); - case 218 /* TemplateExpression */: + case 220 /* TemplateExpression */: return emitTemplateExpression(node); - case 219 /* YieldExpression */: + case 221 /* YieldExpression */: return emitYieldExpression(node); - case 220 /* SpreadElement */: - return emitSpreadExpression(node); - case 221 /* ClassExpression */: + case 222 /* SpreadElement */: + return emitSpreadElement(node); + case 223 /* ClassExpression */: return emitClassExpression(node); - case 222 /* OmittedExpression */: + case 224 /* OmittedExpression */: return; - case 224 /* AsExpression */: + case 226 /* AsExpression */: return emitAsExpression(node); - case 225 /* NonNullExpression */: + case 227 /* NonNullExpression */: return emitNonNullExpression(node); - case 226 /* MetaProperty */: + case 228 /* MetaProperty */: return emitMetaProperty(node); + case 229 /* SyntheticExpression */: + return ts.Debug.fail("SyntheticExpression should never be printed."); // JSX - case 273 /* JsxElement */: + case 275 /* JsxElement */: return emitJsxElement(node); - case 274 /* JsxSelfClosingElement */: + case 276 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 277 /* JsxFragment */: + case 279 /* JsxFragment */: return emitJsxFragment(node); + // Synthesized list + case 342 /* SyntaxList */: + return ts.Debug.fail("SyntaxList should not be printed"); // Transformation nodes - case 336 /* PartiallyEmittedExpression */: + case 343 /* NotEmittedStatement */: + return; + case 344 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 337 /* CommaListExpression */: + case 345 /* CommaListExpression */: return emitCommaList(node); + case 346 /* MergeDeclarationMarker */: + case 347 /* EndOfDeclarationMarker */: + return; + case 348 /* SyntheticReferenceExpression */: + return ts.Debug.fail("SyntheticReferenceExpression should not be printed"); } } + if (ts.isKeyword(node.kind)) + return writeTokenNode(node, writeKeyword); + if (ts.isTokenKind(node.kind)) + return writeTokenNode(node, writePunctuation); + ts.Debug.fail("Unhandled SyntaxKind: " + ts.Debug.formatSyntaxKind(node.kind) + "."); } function emitMappedTypeParameter(node) { emit(node.name); @@ -101524,10 +105095,11 @@ var ts; emit(node.constraint); } function pipelineEmitWithSubstitution(hint, node) { - ts.Debug.assert(lastNode === node || lastSubstitution === node); var pipelinePhase = getNextPipelinePhase(1 /* Substitution */, hint, node); - pipelinePhase(hint, lastSubstitution); - ts.Debug.assert(lastNode === node || lastSubstitution === node); + ts.Debug.assertIsDefined(lastSubstitution); + node = lastSubstitution; + lastSubstitution = undefined; + pipelinePhase(hint, node); } function getHelpersFromBundledSourceFiles(bundle) { var result; @@ -101553,7 +105125,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 298 /* Bundle */ ? node : undefined; + var bundle = node.kind === 300 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -101653,7 +105225,7 @@ var ts; var pos = getTextPosWithWriteLine(); writeUnparsedNode(unparsed); if (bundleFileInfo) { - updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 294 /* UnparsedText */ ? + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 296 /* UnparsedText */ ? "text" /* Text */ : "internal" /* Internal */); } @@ -101690,7 +105262,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { emitExpression(node); } else { @@ -101699,7 +105271,7 @@ var ts; } function emitComputedPropertyName(node) { writePunctuation("["); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfComputedPropertyName); writePunctuation("]"); } // @@ -101726,18 +105298,18 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 308 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 311 /* JSDocFunctionType */ && !node.name) { emit(node.type); } else { emitTypeAnnotation(node.type); } // The comment position has to fallback to any present node within the parameterdeclaration because as it turns out, the parser can make parameter declarations with _just_ an initializer. - emitInitializer(node.initializer, node.type ? node.type.end : node.questionToken ? node.questionToken.end : node.name ? node.name.end : node.modifiers ? node.modifiers.end : node.decorators ? node.decorators.end : node.pos, node); + emitInitializer(node.initializer, node.type ? node.type.end : node.questionToken ? node.questionToken.end : node.name ? node.name.end : node.modifiers ? node.modifiers.end : node.decorators ? node.decorators.end : node.pos, node, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitDecorator(decorator) { writePunctuation("@"); - emitExpression(decorator.expression); + emitExpression(decorator.expression, parenthesizer.parenthesizeLeftSideOfAccess); } // // Type members @@ -101788,7 +105360,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeKeyword(node.kind === 167 /* GetAccessor */ ? "get" : "set"); + writeKeyword(node.kind === 169 /* GetAccessor */ ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -101902,7 +105474,7 @@ var ts; writePunctuation("}"); } function emitArrayType(node) { - emit(node.elementType); + emit(node.elementType, parenthesizer.parenthesizeElementTypeOfArrayType); writePunctuation("["); writePunctuation("]"); } @@ -101925,21 +105497,21 @@ var ts; emit(node.type); } function emitOptionalType(node) { - emit(node.type); + emit(node.type, parenthesizer.parenthesizeElementTypeOfArrayType); writePunctuation("?"); } function emitUnionType(node) { - emitList(node, node.types, 516 /* UnionTypeConstituents */); + emitList(node, node.types, 516 /* UnionTypeConstituents */, parenthesizer.parenthesizeMemberOfElementType); } function emitIntersectionType(node) { - emitList(node, node.types, 520 /* IntersectionTypeConstituents */); + emitList(node, node.types, 520 /* IntersectionTypeConstituents */, parenthesizer.parenthesizeMemberOfElementType); } function emitConditionalType(node) { - emit(node.checkType); + emit(node.checkType, parenthesizer.parenthesizeMemberOfConditionalType); writeSpace(); writeKeyword("extends"); writeSpace(); - emit(node.extendsType); + emit(node.extendsType, parenthesizer.parenthesizeMemberOfConditionalType); writeSpace(); writePunctuation("?"); writeSpace(); @@ -101965,10 +105537,10 @@ var ts; function emitTypeOperator(node) { writeTokenText(node.operator, writeKeyword); writeSpace(); - emit(node.type); + emit(node.type, parenthesizer.parenthesizeMemberOfElementType); } function emitIndexedAccessType(node) { - emit(node.objectType); + emit(node.objectType, parenthesizer.parenthesizeMemberOfElementType); writePunctuation("["); emit(node.indexType); writePunctuation("]"); @@ -101985,7 +105557,7 @@ var ts; } if (node.readonlyToken) { emit(node.readonlyToken); - if (node.readonlyToken.kind !== 142 /* ReadonlyKeyword */) { + if (node.readonlyToken.kind !== 143 /* ReadonlyKeyword */) { writeKeyword("readonly"); } writeSpace(); @@ -102061,7 +105633,7 @@ var ts; writeSpace(); } emit(node.name); - emitInitializer(node.initializer, node.name.end, node); + emitInitializer(node.initializer, node.name.end, node, parenthesizer.parenthesizeExpressionForDisallowedComma); } // // Expressions @@ -102069,7 +105641,7 @@ var ts; function emitArrayLiteralExpression(node) { var elements = node.elements; var preferNewLine = node.multiLine ? 65536 /* PreferNewLine */ : 0 /* None */; - emitExpressionList(node, elements, 8914 /* ArrayLiteralExpressionElements */ | preferNewLine); + emitExpressionList(node, elements, 8914 /* ArrayLiteralExpressionElements */ | preferNewLine, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitObjectLiteralExpression(node) { ts.forEach(node.properties, generateMemberNames); @@ -102085,13 +105657,13 @@ var ts; } } function emitPropertyAccessExpression(node) { - var expression = ts.cast(emitExpression(node.expression), ts.isExpression); + emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); var token = node.questionDotToken || ts.setTextRangePosEnd(ts.factory.createToken(24 /* 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 */ && - mayNeedDotDotForPropertyAccess(expression) && + mayNeedDotDotForPropertyAccess(node.expression) && !writer.hasTrailingComment() && !writer.hasTrailingWhitespace(); if (shouldEmitDotDot) { @@ -102127,27 +105699,27 @@ var ts; } } function emitElementAccessExpression(node) { - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); emit(node.questionDotToken); emitTokenWithComment(22 /* OpenBracketToken */, node.expression.end, writePunctuation, node); emitExpression(node.argumentExpression); emitTokenWithComment(23 /* CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); } function emitCallExpression(node) { - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); emit(node.questionDotToken); emitTypeArguments(node, node.typeArguments); - emitExpressionList(node, node.arguments, 2576 /* CallExpressionArguments */); + emitExpressionList(node, node.arguments, 2576 /* CallExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitNewExpression(node) { - emitTokenWithComment(102 /* NewKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(103 /* NewKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfNew); emitTypeArguments(node, node.typeArguments); - emitExpressionList(node, node.arguments, 18960 /* NewExpressionArguments */); + emitExpressionList(node, node.arguments, 18960 /* NewExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitTaggedTemplateExpression(node) { - emitExpression(node.tag); + emitExpression(node.tag, parenthesizer.parenthesizeLeftSideOfAccess); emitTypeArguments(node, node.typeArguments); writeSpace(); emitExpression(node.template); @@ -102156,12 +105728,12 @@ var ts; writePunctuation("<"); emit(node.type); writePunctuation(">"); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitParenthesizedExpression(node) { var openParenPos = emitTokenWithComment(20 /* OpenParenToken */, node.pos, writePunctuation, node); var indented = writeLineSeparatorsAndIndentBefore(node.expression, node); - emitExpression(node.expression); + emitExpression(node.expression, /*parenthesizerRules*/ undefined); writeLineSeparatorsAfter(node.expression, node); decreaseIndentIf(indented); emitTokenWithComment(21 /* CloseParenToken */, node.expression ? node.expression.end : openParenPos, writePunctuation, node); @@ -102183,31 +105755,31 @@ var ts; emit(node.equalsGreaterThanToken); } function emitDeleteExpression(node) { - emitTokenWithComment(88 /* DeleteKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(89 /* DeleteKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitTypeOfExpression(node) { - emitTokenWithComment(111 /* TypeOfKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(112 /* TypeOfKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitVoidExpression(node) { - emitTokenWithComment(113 /* VoidKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(114 /* VoidKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitAwaitExpression(node) { - emitTokenWithComment(130 /* AwaitKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(131 /* AwaitKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitPrefixUnaryExpression(node) { writeTokenText(node.operator, writeOperator); if (shouldEmitWhitespaceBeforeOperand(node)) { writeSpace(); } - emitExpression(node.operand); + emitExpression(node.operand, parenthesizer.parenthesizeOperandOfPrefixUnary); } function shouldEmitWhitespaceBeforeOperand(node) { // In some cases, we need to emit a space between the operator and the operand. One obvious case @@ -102223,84 +105795,101 @@ 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 === 214 /* PrefixUnaryExpression */ + return operand.kind === 216 /* 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 */))); } function emitPostfixUnaryExpression(node) { - emitExpression(node.operand); + emitExpression(node.operand, parenthesizer.parenthesizeOperandOfPostfixUnary); writeTokenText(node.operator, writeOperator); } - var EmitBinaryExpressionState; - (function (EmitBinaryExpressionState) { - EmitBinaryExpressionState[EmitBinaryExpressionState["EmitLeft"] = 0] = "EmitLeft"; - EmitBinaryExpressionState[EmitBinaryExpressionState["EmitRight"] = 1] = "EmitRight"; - EmitBinaryExpressionState[EmitBinaryExpressionState["FinishEmit"] = 2] = "FinishEmit"; - })(EmitBinaryExpressionState || (EmitBinaryExpressionState = {})); - /** - * emitBinaryExpression includes an embedded work stack to attempt to handle as many nested binary expressions - * as possible without creating any additional stack frames. This can only be done when the emit pipeline does - * not require notification/substitution/comment/sourcemap decorations. - */ - function emitBinaryExpression(node) { - var nodeStack = [node]; - var stateStack = [0 /* EmitLeft */]; - var stackIndex = 0; - while (stackIndex >= 0) { - node = nodeStack[stackIndex]; - switch (stateStack[stackIndex]) { - case 0 /* EmitLeft */: { - maybePipelineEmitExpression(node.left); - break; - } - case 1 /* EmitRight */: { - var isCommaOperator = node.operatorToken.kind !== 27 /* CommaToken */; - var linesBeforeOperator = getLinesBetweenNodes(node, node.left, node.operatorToken); - var linesAfterOperator = getLinesBetweenNodes(node, node.operatorToken, node.right); - writeLinesAndIndent(linesBeforeOperator, isCommaOperator); - emitLeadingCommentsOfPosition(node.operatorToken.pos); - writeTokenNode(node.operatorToken, node.operatorToken.kind === 100 /* InKeyword */ ? writeKeyword : writeOperator); - emitTrailingCommentsOfPosition(node.operatorToken.end, /*prefixSpace*/ true); // Binary operators should have a space before the comment starts - writeLinesAndIndent(linesAfterOperator, /*writeSpaceIfNotIndenting*/ true); - maybePipelineEmitExpression(node.right); - break; - } - case 2 /* FinishEmit */: { - var linesBeforeOperator = getLinesBetweenNodes(node, node.left, node.operatorToken); - var linesAfterOperator = getLinesBetweenNodes(node, node.operatorToken, node.right); - decreaseIndentIf(linesBeforeOperator, linesAfterOperator); - stackIndex--; - break; - } - default: return ts.Debug.fail("Invalid state " + stateStack[stackIndex] + " for emitBinaryExpressionWorker"); + function createEmitBinaryExpression() { + return ts.createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, /*foldState*/ undefined); + function onEnter(node, state) { + if (state) { + state.stackIndex++; + state.preserveSourceNewlinesStack[state.stackIndex] = preserveSourceNewlines; + state.containerPosStack[state.stackIndex] = containerPos; + state.containerEndStack[state.stackIndex] = containerEnd; + state.declarationListContainerEndStack[state.stackIndex] = declarationListContainerEnd; + var emitComments_1 = state.shouldEmitCommentsStack[state.stackIndex] = shouldEmitComments(node); + var emitSourceMaps = state.shouldEmitSourceMapsStack[state.stackIndex] = shouldEmitSourceMaps(node); + onBeforeEmitNode === null || onBeforeEmitNode === void 0 ? void 0 : onBeforeEmitNode(node); + if (emitComments_1) + emitCommentsBeforeNode(node); + if (emitSourceMaps) + emitSourceMapsBeforeNode(node); + beforeEmitNode(node); } - } - function maybePipelineEmitExpression(next) { - // Advance the state of this unit of work, - stateStack[stackIndex]++; - // Then actually do the work of emitting the node `next` returned by the prior state - // The following section should be identical to `pipelineEmit` save it assumes EmitHint.Expression and offloads - // binary expression handling, where possible, to the contained work queue - // #region trampolinePipelineEmit - var savedLastNode = lastNode; - var savedLastSubstitution = lastSubstitution; - lastNode = next; - lastSubstitution = undefined; + else { + state = { + stackIndex: 0, + preserveSourceNewlinesStack: [undefined], + containerPosStack: [-1], + containerEndStack: [-1], + declarationListContainerEndStack: [-1], + shouldEmitCommentsStack: [false], + shouldEmitSourceMapsStack: [false], + }; + } + return state; + } + function onLeft(next, _workArea, parent) { + return maybeEmitExpression(next, parent, "left"); + } + function onOperator(operatorToken, _state, node) { + var isCommaOperator = operatorToken.kind !== 27 /* 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); + emitTrailingCommentsOfPosition(operatorToken.end, /*prefixSpace*/ true); // Binary operators should have a space before the comment starts + writeLinesAndIndent(linesAfterOperator, /*writeSpaceIfNotIndenting*/ true); + } + function onRight(next, _workArea, parent) { + return maybeEmitExpression(next, parent, "right"); + } + function onExit(node, state) { + var linesBeforeOperator = getLinesBetweenNodes(node, node.left, node.operatorToken); + var linesAfterOperator = getLinesBetweenNodes(node, node.operatorToken, node.right); + decreaseIndentIf(linesBeforeOperator, linesAfterOperator); + if (state.stackIndex > 0) { + var savedPreserveSourceNewlines = state.preserveSourceNewlinesStack[state.stackIndex]; + var savedContainerPos = state.containerPosStack[state.stackIndex]; + var savedContainerEnd = state.containerEndStack[state.stackIndex]; + var savedDeclarationListContainerEnd = state.declarationListContainerEndStack[state.stackIndex]; + var shouldEmitComments_1 = state.shouldEmitCommentsStack[state.stackIndex]; + var shouldEmitSourceMaps_1 = state.shouldEmitSourceMapsStack[state.stackIndex]; + afterEmitNode(savedPreserveSourceNewlines); + if (shouldEmitSourceMaps_1) + emitSourceMapsAfterNode(node); + if (shouldEmitComments_1) + emitCommentsAfterNode(node, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd); + onAfterEmitNode === null || onAfterEmitNode === void 0 ? void 0 : onAfterEmitNode(node); + state.stackIndex--; + } + } + function maybeEmitExpression(next, parent, side) { + var parenthesizerRule = side === "left" ? + parenthesizer.getParenthesizeLeftSideOfBinaryForOperator(parent.operatorToken.kind) : + parenthesizer.getParenthesizeRightSideOfBinaryForOperator(parent.operatorToken.kind); var pipelinePhase = getPipelinePhase(0 /* Notification */, 1 /* Expression */, next); - if (pipelinePhase === pipelineEmitWithHint && ts.isBinaryExpression(next)) { - // If the target pipeline phase is emit directly, and the next node's also a binary expression, - // skip all the intermediate indirection and push the expression directly onto the work stack - stackIndex++; - stateStack[stackIndex] = 0 /* EmitLeft */; - nodeStack[stackIndex] = next; + if (pipelinePhase === pipelineEmitWithSubstitution) { + ts.Debug.assertIsDefined(lastSubstitution); + next = parenthesizerRule(ts.cast(lastSubstitution, ts.isExpression)); + pipelinePhase = getNextPipelinePhase(1 /* Substitution */, 1 /* Expression */, next); + lastSubstitution = undefined; } - else { - pipelinePhase(1 /* Expression */, next); + if (pipelinePhase === pipelineEmitWithComments || + pipelinePhase === pipelineEmitWithSourceMaps || + pipelinePhase === pipelineEmitWithHint) { + if (ts.isBinaryExpression(next)) { + return next; + } } - ts.Debug.assert(lastNode === next); - lastNode = savedLastNode; - lastSubstitution = savedLastSubstitution; - // #endregion trampolinePipelineEmit + currentParenthesizerRule = parenthesizerRule; + pipelinePhase(1 /* Expression */, next); } } function emitConditionalExpression(node) { @@ -102308,16 +105897,16 @@ var ts; var linesAfterQuestion = getLinesBetweenNodes(node, node.questionToken, node.whenTrue); var linesBeforeColon = getLinesBetweenNodes(node, node.whenTrue, node.colonToken); var linesAfterColon = getLinesBetweenNodes(node, node.colonToken, node.whenFalse); - emitExpression(node.condition); + emitExpression(node.condition, parenthesizer.parenthesizeConditionOfConditionalExpression); writeLinesAndIndent(linesBeforeQuestion, /*writeSpaceIfNotIndenting*/ true); emit(node.questionToken); writeLinesAndIndent(linesAfterQuestion, /*writeSpaceIfNotIndenting*/ true); - emitExpression(node.whenTrue); + emitExpression(node.whenTrue, parenthesizer.parenthesizeBranchOfConditionalExpression); decreaseIndentIf(linesBeforeQuestion, linesAfterQuestion); writeLinesAndIndent(linesBeforeColon, /*writeSpaceIfNotIndenting*/ true); emit(node.colonToken); writeLinesAndIndent(linesAfterColon, /*writeSpaceIfNotIndenting*/ true); - emitExpression(node.whenFalse); + emitExpression(node.whenFalse, parenthesizer.parenthesizeBranchOfConditionalExpression); decreaseIndentIf(linesBeforeColon, linesAfterColon); } function emitTemplateExpression(node) { @@ -102325,24 +105914,24 @@ var ts; emitList(node, node.templateSpans, 262144 /* TemplateExpressionSpans */); } function emitYieldExpression(node) { - emitTokenWithComment(124 /* YieldKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(125 /* YieldKeyword */, node.pos, writeKeyword, node); emit(node.asteriskToken); - emitExpressionWithLeadingSpace(node.expression); + emitExpressionWithLeadingSpace(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); } - function emitSpreadExpression(node) { + function emitSpreadElement(node) { emitTokenWithComment(25 /* DotDotDotToken */, node.pos, writePunctuation, node); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitClassExpression(node) { generateNameIfNeeded(node.name); emitClassDeclarationOrExpression(node); } function emitExpressionWithTypeArguments(node) { - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); emitTypeArguments(node, node.typeArguments); } function emitAsExpression(node) { - emitExpression(node.expression); + emitExpression(node.expression, /*parenthesizerRules*/ undefined); if (node.type) { writeSpace(); writeKeyword("as"); @@ -102351,7 +105940,7 @@ var ts; } } function emitNonNullExpression(node) { - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); writeOperator("!"); } function emitMetaProperty(node) { @@ -102394,7 +105983,7 @@ var ts; } } function emitExpressionStatement(node) { - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfExpressionStatement); // Emit semicolon in non json files // or if json file that created synthesized expression(eg.define expression statement when --out and amd code generation) if (!ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) { @@ -102402,7 +105991,7 @@ var ts; } } function emitIfStatement(node) { - var openParenPos = emitTokenWithComment(98 /* IfKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(99 /* IfKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -102410,8 +105999,8 @@ var ts; emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { writeLineOrSpace(node, node.thenStatement, node.elseStatement); - emitTokenWithComment(90 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 234 /* IfStatement */) { + emitTokenWithComment(91 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); + if (node.elseStatement.kind === 236 /* IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -102421,14 +106010,14 @@ var ts; } } function emitWhileClause(node, startPos) { - var openParenPos = emitTokenWithComment(114 /* WhileKeyword */, startPos, writeKeyword, node); + var openParenPos = emitTokenWithComment(115 /* WhileKeyword */, startPos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); } function emitDoStatement(node) { - emitTokenWithComment(89 /* DoKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(90 /* DoKeyword */, node.pos, writeKeyword, node); emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement) && !preserveSourceNewlines) { writeSpace(); @@ -102444,7 +106033,7 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { - var openParenPos = emitTokenWithComment(96 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); var pos = emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node); emitForBinding(node.initializer); @@ -102456,25 +106045,25 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { - var openParenPos = emitTokenWithComment(96 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(100 /* InKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(101 /* InKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { - var openParenPos = emitTokenWithComment(96 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitWithTrailingSpace(node.awaitModifier); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(156 /* OfKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(158 /* OfKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); @@ -102482,7 +106071,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 250 /* VariableDeclarationList */) { + if (node.kind === 252 /* VariableDeclarationList */) { emit(node); } else { @@ -102491,12 +106080,12 @@ var ts; } } function emitContinueStatement(node) { - emitTokenWithComment(85 /* ContinueKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(86 /* ContinueKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } function emitBreakStatement(node) { - emitTokenWithComment(80 /* BreakKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(81 /* BreakKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } @@ -102519,18 +106108,18 @@ var ts; } pos = writeTokenText(token, writer, pos); if (isSimilarNode && contextNode.end !== pos) { - var isJsxExprContext = contextNode.kind === 283 /* JsxExpression */; + var isJsxExprContext = contextNode.kind === 285 /* JsxExpression */; emitTrailingCommentsOfPosition(pos, /*prefixSpace*/ !isJsxExprContext, /*forceNoNewline*/ isJsxExprContext); } return pos; } function emitReturnStatement(node) { - emitTokenWithComment(104 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); + emitTokenWithComment(105 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); emitExpressionWithLeadingSpace(node.expression); writeTrailingSemicolon(); } function emitWithStatement(node) { - var openParenPos = emitTokenWithComment(115 /* WithKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(116 /* WithKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -102538,7 +106127,7 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { - var openParenPos = emitTokenWithComment(106 /* SwitchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(107 /* SwitchKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -102553,12 +106142,12 @@ var ts; emit(node.statement); } function emitThrowStatement(node) { - emitTokenWithComment(108 /* ThrowKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(109 /* ThrowKeyword */, node.pos, writeKeyword, node); emitExpressionWithLeadingSpace(node.expression); writeTrailingSemicolon(); } function emitTryStatement(node) { - emitTokenWithComment(110 /* TryKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(111 /* TryKeyword */, node.pos, writeKeyword, node); writeSpace(); emit(node.tryBlock); if (node.catchClause) { @@ -102567,13 +106156,13 @@ var ts; } if (node.finallyBlock) { writeLineOrSpace(node, node.catchClause || node.tryBlock, node.finallyBlock); - emitTokenWithComment(95 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); + emitTokenWithComment(96 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); writeSpace(); emit(node.finallyBlock); } } function emitDebuggerStatement(node) { - writeToken(86 /* DebuggerKeyword */, node.pos, writeKeyword); + writeToken(87 /* DebuggerKeyword */, node.pos, writeKeyword); writeTrailingSemicolon(); } // @@ -102583,7 +106172,7 @@ var ts; emit(node.name); emit(node.exclamationToken); emitTypeAnnotation(node.type); - emitInitializer(node.initializer, node.type ? node.type.end : node.name.end, node); + emitInitializer(node.initializer, node.type ? node.type.end : node.name.end, node, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitVariableDeclarationList(node) { writeKeyword(ts.isLet(node) ? "let" : ts.isVarConst(node) ? "const" : "var"); @@ -102602,9 +106191,6 @@ var ts; emitIdentifierName(node.name); emitSignatureAndBody(node, emitSignatureHead); } - function emitBlockCallback(_hint, body) { - emitBlockFunctionBody(body); - } function emitSignatureAndBody(node, emitSignatureHead) { var body = node.body; if (body) { @@ -102617,12 +106203,7 @@ var ts; ts.forEach(node.parameters, generateNames); generateNames(node.body); emitSignatureHead(node); - if (onEmitNode) { - onEmitNode(4 /* Unspecified */, body, emitBlockCallback); - } - else { - emitBlockFunctionBody(body); - } + emitBlockFunctionBody(body); popNameGenerationScope(node); if (indentedFlag) { decreaseIndent(); @@ -102631,7 +106212,7 @@ var ts; else { emitSignatureHead(node); writeSpace(); - emitExpression(body); + emitExpression(body, parenthesizer.parenthesizeConciseBodyOfArrowFunction); } } else { @@ -102675,6 +106256,7 @@ var ts; return true; } function emitBlockFunctionBody(body) { + onBeforeEmitNode === null || onBeforeEmitNode === void 0 ? void 0 : onBeforeEmitNode(body); writeSpace(); writePunctuation("{"); increaseIndent(); @@ -102689,6 +106271,7 @@ var ts; } decreaseIndent(); writeToken(19 /* CloseBraceToken */, body.statements.end, writePunctuation, body); + onAfterEmitNode === null || onAfterEmitNode === void 0 ? void 0 : onAfterEmitNode(body); } function emitBlockFunctionBodyOnSingleLine(body) { emitBlockFunctionBodyWorker(body, /*emitBlockFunctionBodyOnSingleLine*/ true); @@ -102704,7 +106287,7 @@ var ts; increaseIndent(); } else { - emitList(body, body.statements, 1 /* MultiLineFunctionBodyStatements */, statementOffset); + emitList(body, body.statements, 1 /* MultiLineFunctionBodyStatements */, /*parenthesizerRule*/ undefined, statementOffset); } } function emitClassDeclaration(node) { @@ -102779,7 +106362,7 @@ var ts; var body = node.body; if (!body) return writeTrailingSemicolon(); - while (body.kind === 256 /* ModuleDeclaration */) { + while (body && ts.isModuleDeclaration(body)) { writePunctuation("."); emit(body.name); body = body.body; @@ -102800,21 +106383,21 @@ var ts; } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(99 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(100 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.isTypeOnly) { - emitTokenWithComment(149 /* TypeKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(150 /* TypeKeyword */, node.pos, writeKeyword, node); writeSpace(); } emit(node.name); writeSpace(); - emitTokenWithComment(62 /* EqualsToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(63 /* EqualsToken */, node.name.end, writePunctuation, node); writeSpace(); emitModuleReference(node.moduleReference); writeTrailingSemicolon(); } function emitModuleReference(node) { - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { emitExpression(node); } else { @@ -102823,12 +106406,12 @@ var ts; } function emitImportDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(99 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(100 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.importClause) { emit(node.importClause); writeSpace(); - emitTokenWithComment(153 /* FromKeyword */, node.importClause.end, writeKeyword, node); + emitTokenWithComment(154 /* FromKeyword */, node.importClause.end, writeKeyword, node); writeSpace(); } emitExpression(node.moduleSpecifier); @@ -102836,7 +106419,7 @@ var ts; } function emitImportClause(node) { if (node.isTypeOnly) { - emitTokenWithComment(149 /* TypeKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(150 /* TypeKeyword */, node.pos, writeKeyword, node); writeSpace(); } emit(node.name); @@ -102849,7 +106432,7 @@ var ts; function emitNamespaceImport(node) { var asPos = emitTokenWithComment(41 /* AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(126 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(127 /* AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -102860,23 +106443,25 @@ var ts; emitImportOrExportSpecifier(node); } function emitExportAssignment(node) { - var nextPos = emitTokenWithComment(92 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isExportEquals) { - emitTokenWithComment(62 /* EqualsToken */, nextPos, writeOperator, node); + emitTokenWithComment(63 /* EqualsToken */, nextPos, writeOperator, node); } else { - emitTokenWithComment(87 /* DefaultKeyword */, nextPos, writeKeyword, node); + emitTokenWithComment(88 /* DefaultKeyword */, nextPos, writeKeyword, node); } writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, node.isExportEquals ? + parenthesizer.getParenthesizeRightSideOfBinaryForOperator(63 /* EqualsToken */) : + parenthesizer.parenthesizeExpressionOfExportDefault); writeTrailingSemicolon(); } function emitExportDeclaration(node) { - var nextPos = emitTokenWithComment(92 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isTypeOnly) { - nextPos = emitTokenWithComment(149 /* TypeKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(150 /* TypeKeyword */, nextPos, writeKeyword, node); writeSpace(); } if (node.exportClause) { @@ -102888,18 +106473,18 @@ var ts; if (node.moduleSpecifier) { writeSpace(); var fromPos = node.exportClause ? node.exportClause.end : nextPos; - emitTokenWithComment(153 /* FromKeyword */, fromPos, writeKeyword, node); + emitTokenWithComment(154 /* FromKeyword */, fromPos, writeKeyword, node); writeSpace(); emitExpression(node.moduleSpecifier); } writeTrailingSemicolon(); } function emitNamespaceExportDeclaration(node) { - var nextPos = emitTokenWithComment(92 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(126 /* AsKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(127 /* AsKeyword */, nextPos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(140 /* NamespaceKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(141 /* NamespaceKeyword */, nextPos, writeKeyword, node); writeSpace(); emit(node.name); writeTrailingSemicolon(); @@ -102907,7 +106492,7 @@ var ts; function emitNamespaceExport(node) { var asPos = emitTokenWithComment(41 /* AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(126 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(127 /* AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -102926,7 +106511,7 @@ var ts; if (node.propertyName) { emit(node.propertyName); writeSpace(); - emitTokenWithComment(126 /* AsKeyword */, node.propertyName.end, writeKeyword, node); + emitTokenWithComment(127 /* AsKeyword */, node.propertyName.end, writeKeyword, node); writeSpace(); } emit(node.name); @@ -103028,7 +106613,7 @@ var ts; } } function emitJsxTagName(node) { - if (node.kind === 78 /* Identifier */) { + if (node.kind === 79 /* Identifier */) { emitExpression(node); } else { @@ -103039,13 +106624,13 @@ var ts; // Clauses // function emitCaseClause(node) { - emitTokenWithComment(81 /* CaseKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(82 /* CaseKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); emitCaseOrDefaultClauseRest(node, node.statements, node.expression.end); } function emitDefaultClause(node) { - var pos = emitTokenWithComment(87 /* DefaultKeyword */, node.pos, writeKeyword, node); + var pos = emitTokenWithComment(88 /* DefaultKeyword */, node.pos, writeKeyword, node); emitCaseOrDefaultClauseRest(node, node.statements, pos); } function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) { @@ -103073,7 +106658,7 @@ var ts; emitList(node, node.types, 528 /* HeritageClauseTypes */); } function emitCatchClause(node) { - var openParenPos = emitTokenWithComment(82 /* CatchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(83 /* CatchKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.variableDeclaration) { emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); @@ -103102,7 +106687,7 @@ var ts; var commentRange = ts.getCommentRange(initializer); emitTrailingCommentsOfPosition(commentRange.pos); } - emitExpression(initializer); + emitExpression(initializer, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitShorthandPropertyAssignment(node) { emit(node.name); @@ -103110,13 +106695,13 @@ var ts; writeSpace(); writePunctuation("="); writeSpace(); - emitExpression(node.objectAssignmentInitializer); + emitExpression(node.objectAssignmentInitializer, parenthesizer.parenthesizeExpressionForDisallowedComma); } } function emitSpreadAssignment(node) { if (node.expression) { emitTokenWithComment(25 /* DotDotDotToken */, node.pos, writePunctuation, node); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); } } // @@ -103124,7 +106709,7 @@ var ts; // function emitEnumMember(node) { emit(node.name); - emitInitializer(node.initializer, node.name.end, node); + emitInitializer(node.initializer, node.name.end, node, parenthesizer.parenthesizeExpressionForDisallowedComma); } // // JSDoc @@ -103132,18 +106717,21 @@ var ts; function emitJSDoc(node) { write("/**"); if (node.comment) { - var lines = node.comment.split(/\r\n?|\n/g); - for (var _a = 0, lines_2 = lines; _a < lines_2.length; _a++) { - var line = lines_2[_a]; - writeLine(); - writeSpace(); - writePunctuation("*"); - writeSpace(); - write(line); + var text = ts.getTextOfJSDocComment(node.comment); + if (text) { + var lines = text.split(/\r\n?|\n/g); + for (var _a = 0, lines_2 = lines; _a < lines_2.length; _a++) { + var line = lines_2[_a]; + writeLine(); + writeSpace(); + writePunctuation("*"); + writeSpace(); + write(line); + } } } if (node.tags) { - if (node.tags.length === 1 && node.tags[0].kind === 329 /* JSDocTypeTag */ && !node.comment) { + if (node.tags.length === 1 && node.tags[0].kind === 337 /* JSDocTypeTag */ && !node.comment) { writeSpace(); emit(node.tags[0]); } @@ -103188,7 +106776,7 @@ var ts; function emitJSDocTypedefTag(tag) { emitJSDocTagName(tag.tagName); if (tag.typeExpression) { - if (tag.typeExpression.kind === 301 /* JSDocTypeExpression */) { + if (tag.typeExpression.kind === 303 /* JSDocTypeExpression */) { emitJSDocTypeExpression(tag.typeExpression); } else { @@ -103207,7 +106795,7 @@ var ts; emit(tag.fullName); } emitJSDocComment(tag.comment); - if (tag.typeExpression && tag.typeExpression.kind === 312 /* JSDocTypeLiteral */) { + if (tag.typeExpression && tag.typeExpression.kind === 316 /* JSDocTypeLiteral */) { emitJSDocTypeLiteral(tag.typeExpression); } } @@ -103260,9 +106848,10 @@ var ts; emit(tagName); } function emitJSDocComment(comment) { - if (comment) { + var text = ts.getTextOfJSDocComment(comment); + if (text) { writeSpace(); - write(comment); + write(text); } } function emitJSDocTypeExpression(typeExpression) { @@ -103365,7 +106954,7 @@ var ts; emitHelpers(node); var index = ts.findIndex(statements, function (statement) { return !ts.isPrologueDirective(statement); }); emitTripleSlashDirectivesIfNeeded(node); - emitList(node, statements, 1 /* MultiLine */, index === -1 ? statements.length : index); + emitList(node, statements, 1 /* MultiLine */, /*parenthesizerRule*/ undefined, index === -1 ? statements.length : index); popNameGenerationScope(node); } // Transformation nodes @@ -103373,7 +106962,7 @@ var ts; emitExpression(node.expression); } function emitCommaList(node) { - emitExpressionList(node, node.elements, 528 /* CommaListElements */); + emitExpressionList(node, node.elements, 528 /* CommaListElements */, /*parenthesizerRule*/ undefined); } /** * Emits any prologue directives at the start of a Statement list, returning the @@ -103519,12 +107108,12 @@ var ts; emit(node); } } - function emitInitializer(node, equalCommentStartPos, container) { + function emitInitializer(node, equalCommentStartPos, container, parenthesizerRule) { if (node) { writeSpace(); - emitTokenWithComment(62 /* EqualsToken */, equalCommentStartPos, writeOperator, container); + emitTokenWithComment(63 /* EqualsToken */, equalCommentStartPos, writeOperator, container); writeSpace(); - emitExpression(node); + emitExpression(node, parenthesizerRule); } } function emitNodeWithPrefix(prefix, prefixWriter, node, emit) { @@ -103539,10 +107128,10 @@ var ts; emit(node); } } - function emitExpressionWithLeadingSpace(node) { + function emitExpressionWithLeadingSpace(node, parenthesizerRule) { if (node) { writeSpace(); - emitExpression(node); + emitExpression(node, parenthesizerRule); } } function emitWithTrailingSpace(node) { @@ -103572,7 +107161,7 @@ var ts; emitList(parentNode, decorators, 2146305 /* Decorators */); } function emitTypeArguments(parentNode, typeArguments) { - emitList(parentNode, typeArguments, 53776 /* TypeArguments */); + emitList(parentNode, typeArguments, 53776 /* TypeArguments */, parenthesizer.parenthesizeMemberOfElementType); } function emitTypeParameters(parentNode, typeParameters) { if (ts.isFunctionLike(parentNode) && parentNode.typeArguments) { // Quick info uses type arguments in place of type parameters on instantiated signatures @@ -103611,12 +107200,6 @@ var ts; function emitParametersForIndexSignature(parentNode, parameters) { emitList(parentNode, parameters, 8848 /* IndexSignatureParameters */); } - function emitList(parentNode, children, format, start, count) { - emitNodeList(emit, parentNode, children, format, start, count); - } - function emitExpressionList(parentNode, children, format, start, count) { - emitNodeList(emitExpression, parentNode, children, format, start, count); // TODO: GH#18217 - } function writeDelimiter(format) { switch (format & 60 /* DelimitersMask */) { case 0 /* None */: @@ -103639,7 +107222,13 @@ var ts; break; } } - function emitNodeList(emit, parentNode, children, format, start, count) { + function emitList(parentNode, children, format, parenthesizerRule, start, count) { + emitNodeList(emit, parentNode, children, format, parenthesizerRule, start, count); + } + function emitExpressionList(parentNode, children, format, parenthesizerRule, start, count) { + emitNodeList(emitExpression, parentNode, children, format, parenthesizerRule, start, count); + } + function emitNodeList(emit, parentNode, children, format, parenthesizerRule, start, count) { if (start === void 0) { start = 0; } if (count === void 0) { count = children ? children.length - start : 0; } var isUndefined = children === undefined; @@ -103658,8 +107247,7 @@ var ts; } if (format & 15360 /* BracketsMask */) { writePunctuation(getOpeningBracket(format)); - if (isEmpty && !isUndefined) { - // TODO: GH#18217 + if (isEmpty && children) { emitTrailingCommentsOfPosition(children.pos, /*prefixSpace*/ true); // Emit comments within empty bracketed lists } } @@ -103668,7 +107256,7 @@ var ts; } if (isEmpty) { // Write a line terminator if the parent node was multi-line - if (format & 1 /* MultiLine */ && !(preserveSourceNewlines && ts.rangeIsOnSingleLine(parentNode, currentSourceFile))) { + if (format & 1 /* MultiLine */ && !(preserveSourceNewlines && (!parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) { writeLine(); } else if (format & 256 /* SpaceBetweenBraces */ && !(format & 524288 /* NoSpaceIfEmpty */)) { @@ -103676,6 +107264,7 @@ var ts; } } else { + ts.Debug.type(children); // Write the opening line terminator or leading whitespace. var mayEmitInterveningComments = (format & 262144 /* NoInterveningComments */) === 0; var shouldEmitInterveningComments = mayEmitInterveningComments; @@ -103710,7 +107299,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.end) { + if (format & 60 /* DelimitersMask */ && previousSibling.end !== (parentNode ? parentNode.end : -1)) { emitLeadingCommentsOfPosition(previousSibling.end); } writeDelimiter(format); @@ -103743,7 +107332,12 @@ var ts; shouldEmitInterveningComments = mayEmitInterveningComments; } nextListElementPos = child.pos; - emit(child); + if (emit.length === 1) { + emit(child); + } + else { + emit(child, parenthesizerRule); + } if (shouldDecreaseIndentAfterEmit) { decreaseIndent(); shouldDecreaseIndentAfterEmit = false; @@ -103768,7 +107362,7 @@ var ts; // 2 // /* end of element 2 */ // ]; - if (previousSibling && parentNode.end !== previousSibling.end && (format & 60 /* DelimitersMask */) && !skipTrailingComments) { + if (previousSibling && (parentNode ? parentNode.end : -1) !== previousSibling.end && (format & 60 /* DelimitersMask */) && !skipTrailingComments) { emitLeadingCommentsOfPosition(hasTrailingComma && (children === null || children === void 0 ? void 0 : children.end) ? children.end : previousSibling.end); } // Decrease the indent, if requested. @@ -103789,8 +107383,7 @@ var ts; onAfterEmitNodeArray(children); } if (format & 15360 /* BracketsMask */) { - if (isEmpty && !isUndefined) { - // TODO: GH#18217 + if (isEmpty && children) { emitLeadingCommentsOfPosition(children.end); // Emit leading comments within empty lists } writePunctuation(getClosingBracket(format)); @@ -103921,7 +107514,7 @@ var ts; } var firstChild_1 = children[0]; if (firstChild_1 === undefined) { - return ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; + return !parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; } if (firstChild_1.pos === nextListElementPos) { // If this child starts at the beginning of a list item in a parent list, its leading @@ -103945,7 +107538,8 @@ var ts; // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } - if (!ts.positionIsSynthesized(parentNode.pos) && + if (parentNode && + !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(firstChild_1) && (!firstChild_1.parent || ts.getOriginalNode(firstChild_1.parent) === ts.getOriginalNode(parentNode))) { if (preserveSourceNewlines) { @@ -103968,10 +107562,10 @@ var ts; // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } - else if (!ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode) && previousNode.parent === nextNode.parent) { - if (preserveSourceNewlines) { - return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); - } + else if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) { + return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); + } + else if (!preserveSourceNewlines && !ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) { return ts.rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile) ? 0 : 1; } else if (synthesizedNodeStartsOnNewLine(previousNode, format) || synthesizedNodeStartsOnNewLine(nextNode, format)) { @@ -103990,9 +107584,9 @@ var ts; } var lastChild = ts.lastOrUndefined(children); if (lastChild === undefined) { - return ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; + return !parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; } - if (!ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) { + if (parentNode && !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) { if (preserveSourceNewlines) { var end_1 = ts.isNodeArray(children) && !ts.positionIsSynthesized(children.end) ? children.end : lastChild.end; return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenPositionAndNextNonWhitespaceCharacter(end_1, parentNode.end, currentSourceFile, includeComments); }); @@ -104078,7 +107672,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 207 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 209 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -104148,84 +107742,84 @@ var ts; if (!node) return; switch (node.kind) { - case 230 /* Block */: + case 232 /* Block */: ts.forEach(node.statements, generateNames); break; - case 245 /* LabeledStatement */: - case 243 /* WithStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: + case 247 /* LabeledStatement */: + case 245 /* WithStatement */: + case 237 /* DoStatement */: + case 238 /* WhileStatement */: generateNames(node.statement); break; - case 234 /* IfStatement */: + case 236 /* IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 237 /* ForStatement */: - case 239 /* ForOfStatement */: - case 238 /* ForInStatement */: + case 239 /* ForStatement */: + case 241 /* ForOfStatement */: + case 240 /* ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 244 /* SwitchStatement */: + case 246 /* SwitchStatement */: generateNames(node.caseBlock); break; - case 258 /* CaseBlock */: + case 260 /* CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 284 /* CaseClause */: - case 285 /* DefaultClause */: + case 286 /* CaseClause */: + case 287 /* DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 247 /* TryStatement */: + case 249 /* TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 287 /* CatchClause */: + case 289 /* CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 232 /* VariableStatement */: + case 234 /* VariableStatement */: generateNames(node.declarationList); break; - case 250 /* VariableDeclarationList */: + case 252 /* VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 249 /* VariableDeclaration */: - case 160 /* Parameter */: - case 198 /* BindingElement */: - case 252 /* ClassDeclaration */: + case 251 /* VariableDeclaration */: + case 162 /* Parameter */: + case 200 /* BindingElement */: + case 254 /* ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 251 /* FunctionDeclaration */: + case 253 /* FunctionDeclaration */: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 196 /* ObjectBindingPattern */: - case 197 /* ArrayBindingPattern */: + case 198 /* ObjectBindingPattern */: + case 199 /* ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 261 /* ImportDeclaration */: + case 263 /* ImportDeclaration */: generateNames(node.importClause); break; - case 262 /* ImportClause */: + case 264 /* ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 263 /* NamespaceImport */: + case 265 /* NamespaceImport */: generateNameIfNeeded(node.name); break; - case 269 /* NamespaceExport */: + case 271 /* NamespaceExport */: generateNameIfNeeded(node.name); break; - case 264 /* NamedImports */: + case 266 /* NamedImports */: ts.forEach(node.elements, generateNames); break; - case 265 /* ImportSpecifier */: + case 267 /* ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -104234,12 +107828,12 @@ var ts; if (!node) return; switch (node.kind) { - case 288 /* PropertyAssignment */: - case 289 /* ShorthandPropertyAssignment */: - case 163 /* PropertyDeclaration */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 290 /* PropertyAssignment */: + case 291 /* ShorthandPropertyAssignment */: + case 165 /* PropertyDeclaration */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: generateNameIfNeeded(node.name); break; } @@ -104419,25 +108013,25 @@ var ts; */ function generateNameForNode(node, flags) { switch (node.kind) { - case 78 /* Identifier */: + case 79 /* Identifier */: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 256 /* ModuleDeclaration */: - case 255 /* EnumDeclaration */: + case 258 /* ModuleDeclaration */: + case 257 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 261 /* ImportDeclaration */: - case 267 /* ExportDeclaration */: + case 263 /* ImportDeclaration */: + case 269 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 251 /* FunctionDeclaration */: - case 252 /* ClassDeclaration */: - case 266 /* ExportAssignment */: + case 253 /* FunctionDeclaration */: + case 254 /* ClassDeclaration */: + case 268 /* ExportAssignment */: return generateNameForExportDefault(); - case 221 /* ClassExpression */: + case 223 /* ClassExpression */: return generateNameForClassExpression(); - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* MethodDeclaration */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: return generateNameForMethodOrAccessor(node); - case 158 /* ComputedPropertyName */: + case 160 /* ComputedPropertyName */: return makeTempVariableName(0 /* Auto */, /*reserveInNestedScopes*/ true); default: return makeTempVariableName(0 /* Auto */); @@ -104480,25 +108074,45 @@ var ts; } // Comments function pipelineEmitWithComments(hint, node) { - ts.Debug.assert(lastNode === node || lastSubstitution === node); + var pipelinePhase = getNextPipelinePhase(2 /* Comments */, hint, node); + var savedContainerPos = containerPos; + var savedContainerEnd = containerEnd; + var savedDeclarationListContainerEnd = declarationListContainerEnd; + emitCommentsBeforeNode(node); + pipelinePhase(hint, node); + emitCommentsAfterNode(node, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd); + } + function emitCommentsBeforeNode(node) { + var emitFlags = ts.getEmitFlags(node); + var commentRange = ts.getCommentRange(node); + // Emit leading comments + emitLeadingCommentsOfNode(node, emitFlags, commentRange.pos, commentRange.end); + if (emitFlags & 2048 /* NoNestedComments */) { + commentsDisabled = true; + } + } + function emitCommentsAfterNode(node, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd) { + var emitFlags = ts.getEmitFlags(node); + var commentRange = ts.getCommentRange(node); + // Emit trailing comments + if (emitFlags & 2048 /* NoNestedComments */) { + commentsDisabled = false; + } + emitTrailingCommentsOfNode(node, emitFlags, commentRange.pos, commentRange.end, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd); + } + function emitLeadingCommentsOfNode(node, emitFlags, pos, end) { enterComment(); hasWrittenComment = false; - var emitFlags = ts.getEmitFlags(node); - var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; - var isEmittedNode = node.kind !== 335 /* NotEmittedStatement */; // 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 */; // Save current container state on the stack. - var savedContainerPos = containerPos; - var savedContainerEnd = containerEnd; - var savedDeclarationListContainerEnd = declarationListContainerEnd; 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); + emitLeadingComments(pos, /*isEmittedNode*/ node.kind !== 343 /* NotEmittedStatement */); } if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512 /* NoLeadingComments */) !== 0)) { // Advance the container position if comments get emitted or if they've been disabled explicitly using NoLeadingComments. @@ -104509,23 +108123,17 @@ var ts; 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 === 250 /* VariableDeclarationList */) { + if (node.kind === 252 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } } ts.forEach(ts.getSyntheticLeadingComments(node), emitLeadingSynthesizedComment); exitComment(); - var pipelinePhase = getNextPipelinePhase(2 /* Comments */, hint, node); - if (emitFlags & 2048 /* NoNestedComments */) { - commentsDisabled = true; - pipelinePhase(hint, node); - commentsDisabled = false; - } - else { - pipelinePhase(hint, node); - } + } + function emitTrailingCommentsOfNode(node, emitFlags, pos, end, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd) { enterComment(); + var skipTrailingComments = end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0 || node.kind === 11 /* JsxText */; ts.forEach(ts.getSyntheticTrailingComments(node), emitTrailingSynthesizedComment); if ((pos > 0 || end > 0) && pos !== end) { // Restore previous container state. @@ -104534,12 +108142,11 @@ 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 && isEmittedNode) { + if (!skipTrailingComments && node.kind !== 343 /* NotEmittedStatement */) { emitTrailingComments(end); } } exitComment(); - ts.Debug.assert(lastNode === node || lastSubstitution === node); } function emitLeadingSynthesizedComment(comment) { if (comment.hasLeadingNewline || comment.kind === 2 /* SingleLineCommentTrivia */) { @@ -104599,6 +108206,23 @@ var ts; } exitComment(); } + function siblingNodePositionsAreComparable(previousNode, nextNode) { + if (ts.nodeIsSynthesized(previousNode) || ts.nodeIsSynthesized(nextNode)) { + return false; + } + if (nextNode.pos < previousNode.end) { + return false; + } + previousNode = ts.getOriginalNode(previousNode); + nextNode = ts.getOriginalNode(nextNode); + var parent = previousNode.parent; + if (!parent || parent !== nextNode.parent) { + return false; + } + var parentNodeArray = ts.getContainingNodeArray(previousNode); + var prevNodeIndex = parentNodeArray === null || parentNodeArray === void 0 ? void 0 : parentNodeArray.indexOf(previousNode); + return prevNodeIndex !== undefined && prevNodeIndex > -1 && parentNodeArray.indexOf(nextNode) === prevNodeIndex + 1; + } function emitLeadingComments(pos, isEmittedNode) { hasWrittenComment = false; if (isEmittedNode) { @@ -104771,42 +108395,49 @@ var ts; } return node.parsedSourceMap || undefined; } - function pipelineEmitWithSourceMap(hint, node) { - ts.Debug.assert(lastNode === node || lastSubstitution === node); + function pipelineEmitWithSourceMaps(hint, node) { var pipelinePhase = getNextPipelinePhase(3 /* SourceMaps */, hint, node); - if (ts.isUnparsedSource(node) || ts.isUnparsedPrepend(node)) { - pipelinePhase(hint, node); - } - else if (ts.isUnparsedNode(node)) { + emitSourceMapsBeforeNode(node); + pipelinePhase(hint, node); + emitSourceMapsAfterNode(node); + } + function emitSourceMapsBeforeNode(node) { + var emitFlags = ts.getEmitFlags(node); + var sourceMapRange = ts.getSourceMapRange(node); + // Emit leading sourcemap + if (ts.isUnparsedNode(node)) { + ts.Debug.assertIsDefined(node.parent, "UnparsedNodes must have parent pointers"); var parsed = getParsedSourceMap(node.parent); if (parsed && sourceMapGenerator) { sourceMapGenerator.appendSourceMap(writer.getLine(), writer.getColumn(), parsed, node.parent.sourceMapPath, node.parent.getLineAndCharacterOfPosition(node.pos), node.parent.getLineAndCharacterOfPosition(node.end)); } - pipelinePhase(hint, node); } else { - var _a = ts.getSourceMapRange(node), pos = _a.pos, end = _a.end, _b = _a.source, source = _b === void 0 ? sourceMapSource : _b; - var emitFlags = ts.getEmitFlags(node); - if (node.kind !== 335 /* NotEmittedStatement */ + var source = sourceMapRange.source || sourceMapSource; + if (node.kind !== 343 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 - && pos >= 0) { - emitSourcePos(source, skipSourceTrivia(source, pos)); + && sourceMapRange.pos >= 0) { + emitSourcePos(sourceMapRange.source || sourceMapSource, skipSourceTrivia(source, sourceMapRange.pos)); } if (emitFlags & 64 /* NoNestedSourceMaps */) { sourceMapsDisabled = true; - pipelinePhase(hint, node); - sourceMapsDisabled = false; } - else { - pipelinePhase(hint, node); + } + } + function emitSourceMapsAfterNode(node) { + var emitFlags = ts.getEmitFlags(node); + var sourceMapRange = ts.getSourceMapRange(node); + // Emit trailing sourcemap + if (!ts.isUnparsedNode(node)) { + if (emitFlags & 64 /* NoNestedSourceMaps */) { + sourceMapsDisabled = false; } - if (node.kind !== 335 /* NotEmittedStatement */ + if (node.kind !== 343 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 - && end >= 0) { - emitSourcePos(source, end); + && sourceMapRange.end >= 0) { + emitSourcePos(sourceMapRange.source || sourceMapSource, sourceMapRange.end); } } - ts.Debug.assert(lastNode === node || lastSubstitution === node); } /** * Skips trivia such as comments and white-space that can be optionally overridden by the source-map source @@ -104958,12 +108589,22 @@ var ts; return ts.getBaseFileName(ts.normalizePath(fileName)); } function createCachedFileSystemEntries(rootDir, rootDirPath) { - var resultFromHost = { - files: ts.map(host.readDirectory(rootDir, /*extensions*/ undefined, /*exclude*/ undefined, /*include*/ ["*.*"]), getBaseNameOfFileName) || [], - directories: host.getDirectories(rootDir) || [] - }; - cachedReadDirectoryResult.set(ts.ensureTrailingDirectorySeparator(rootDirPath), resultFromHost); - return resultFromHost; + var _a; + if (!host.realpath || ts.ensureTrailingDirectorySeparator(toPath(host.realpath(rootDir))) === rootDirPath) { + var resultFromHost = { + files: ts.map(host.readDirectory(rootDir, /*extensions*/ undefined, /*exclude*/ undefined, /*include*/ ["*.*"]), getBaseNameOfFileName) || [], + directories: host.getDirectories(rootDir) || [] + }; + cachedReadDirectoryResult.set(ts.ensureTrailingDirectorySeparator(rootDirPath), resultFromHost); + return resultFromHost; + } + // If the directory is symlink do not cache the result + if ((_a = host.directoryExists) === null || _a === void 0 ? void 0 : _a.call(host, rootDir)) { + cachedReadDirectoryResult.set(rootDirPath, false); + return false; + } + // Non existing directory + return undefined; } /** * If the readDirectory result was already cached, it returns that @@ -105038,17 +108679,32 @@ var ts; } function readDirectory(rootDir, extensions, excludes, includes, depth) { var rootDirPath = toPath(rootDir); - var result = tryReadDirectory(rootDir, rootDirPath); - if (result) { + var rootResult = tryReadDirectory(rootDir, rootDirPath); + var rootSymLinkResult; + if (rootResult !== undefined) { return ts.matchFiles(rootDir, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, depth, getFileSystemEntries, realpath); } return host.readDirectory(rootDir, extensions, excludes, includes, depth); function getFileSystemEntries(dir) { var path = toPath(dir); if (path === rootDirPath) { - return result; - } - return tryReadDirectory(dir, path) || ts.emptyFileSystemEntries; + return rootResult || getFileSystemEntriesFromHost(dir, path); + } + var result = tryReadDirectory(dir, path); + return result !== undefined ? + result || getFileSystemEntriesFromHost(dir, path) : + ts.emptyFileSystemEntries; + } + function getFileSystemEntriesFromHost(dir, path) { + if (rootSymLinkResult && path === rootDirPath) + return rootSymLinkResult; + var result = { + files: ts.map(host.readDirectory(dir, /*extensions*/ undefined, /*exclude*/ undefined, /*include*/ ["*.*"]), getBaseNameOfFileName) || ts.emptyArray, + directories: host.getDirectories(dir) || ts.emptyArray + }; + if (path === rootDirPath) + rootSymLinkResult = result; + return result; } } function realpath(s) { @@ -105056,7 +108712,7 @@ var ts; } function addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath) { var existingResult = getCachedFileSystemEntries(fileOrDirectoryPath); - if (existingResult) { + if (existingResult !== undefined) { // Just clear the cache for now // For now just clear the cache, since this could mean that multiple level entries might need to be re-evaluated clearCache(); @@ -105116,9 +108772,9 @@ var ts; /** * Updates the map of shared extended config file watches with a new set of extended config files from a base config file of the project */ - function updateSharedExtendedConfigFileWatcher(projectPath, parsed, extendedConfigFilesMap, createExtendedConfigFileWatch, toPath) { + function updateSharedExtendedConfigFileWatcher(projectPath, options, extendedConfigFilesMap, createExtendedConfigFileWatch, toPath) { var _a; - var extendedConfigs = ts.arrayToMap(((_a = parsed === null || parsed === void 0 ? void 0 : parsed.options.configFile) === null || _a === void 0 ? void 0 : _a.extendedSourceFiles) || ts.emptyArray, toPath); + var extendedConfigs = ts.arrayToMap(((_a = options === null || options === void 0 ? void 0 : options.configFile) === null || _a === void 0 ? void 0 : _a.extendedSourceFiles) || ts.emptyArray, toPath); // remove project from all unrelated watchers extendedConfigFilesMap.forEach(function (watcher, extendedConfigFilePath) { if (!extendedConfigs.has(extendedConfigFilePath)) { @@ -105136,12 +108792,12 @@ var ts; // start watching previously unseen extended config extendedConfigFilesMap.set(extendedConfigFilePath, { projects: new ts.Set([projectPath]), - fileWatcher: createExtendedConfigFileWatch(extendedConfigFileName, extendedConfigFilePath), + watcher: createExtendedConfigFileWatch(extendedConfigFileName, extendedConfigFilePath), close: function () { var existing = extendedConfigFilesMap.get(extendedConfigFilePath); if (!existing || existing.projects.size !== 0) return; - existing.fileWatcher.close(); + existing.watcher.close(); extendedConfigFilesMap.delete(extendedConfigFilePath); }, }); @@ -105149,6 +108805,31 @@ var ts; }); } ts.updateSharedExtendedConfigFileWatcher = updateSharedExtendedConfigFileWatcher; + /** + * Remove the project from the extended config file watchers and close not needed watches + */ + function clearSharedExtendedConfigFileWatcher(projectPath, extendedConfigFilesMap) { + extendedConfigFilesMap.forEach(function (watcher) { + if (watcher.projects.delete(projectPath)) + watcher.close(); + }); + } + ts.clearSharedExtendedConfigFileWatcher = clearSharedExtendedConfigFileWatcher; + /** + * Clean the extendsConfigCache when extended config file has changed + */ + function cleanExtendedConfigCache(extendedConfigCache, extendedConfigFilePath, toPath) { + if (!extendedConfigCache.delete(extendedConfigFilePath)) + return; + extendedConfigCache.forEach(function (_a, key) { + var _b; + var extendedResult = _a.extendedResult; + if ((_b = extendedResult.extendedSourceFiles) === null || _b === void 0 ? void 0 : _b.some(function (extendedFile) { return toPath(extendedFile) === extendedConfigFilePath; })) { + cleanExtendedConfigCache(extendedConfigCache, key, toPath); + } + }); + } + ts.cleanExtendedConfigCache = cleanExtendedConfigCache; /** * Updates the existing missing file watches with the new set of missing files after new program is created */ @@ -105200,7 +108881,7 @@ var ts; ts.updateWatchingWildcardDirectories = updateWatchingWildcardDirectories; /* @internal */ function isIgnoredFileFromWildCardWatching(_a) { - 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; + 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); @@ -105223,7 +108904,7 @@ var ts; return false; // We want to ignore emit file check if file is not going to be emitted next to source file // In that case we follow config file inclusion rules - if (options.outFile || options.outDir) + if (ts.outFile(options) || options.outDir) return false; // File if emitted next to input needs to be ignored if (ts.fileExtensionIs(fileOrDirectoryPath, ".d.ts" /* Dts */)) { @@ -105236,7 +108917,8 @@ var ts; } // just check if sourceFile with the name exists var filePathWithoutExtension = ts.removeFileExtension(fileOrDirectoryPath); - var realProgram = isBuilderProgram(program) ? program.getProgramOrUndefined() : program; + 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); @@ -105246,7 +108928,9 @@ var ts; function hasSourceFile(file) { return realProgram ? !!realProgram.getSourceFileByPath(file) : - program.getState().fileInfos.has(file); + builderProgram ? + builderProgram.getState().fileInfos.has(file) : + !!ts.find(program, function (rootFile) { return toPath(rootFile) === file; }); } } ts.isIgnoredFileFromWildCardWatching = isIgnoredFileFromWildCardWatching; @@ -105719,8 +109403,8 @@ var ts; var lineStart = ts.getPositionOfLineAndCharacter(file, i, 0); var lineEnd = i < lastLineInFile ? ts.getPositionOfLineAndCharacter(file, i + 1, 0) : file.text.length; var lineContent = file.text.slice(lineStart, lineEnd); - lineContent = lineContent.replace(/\s+$/g, ""); // trim from end - lineContent = lineContent.replace("\t", " "); // convert tabs to single spaces + lineContent = ts.trimStringEnd(lineContent); // trim from end + lineContent = lineContent.replace(/\t/g, " "); // convert tabs to single spaces // Output the gutter and the actual contents of the line. context += indent + formatColorAndReset(ts.padLeft(i + 1 + "", gutterWidth), gutterStyleSequence) + gutterSeparator; context += lineContent + host.getNewLine(); @@ -105925,38 +109609,31 @@ var ts; * Determines if program structure is upto date or needs to be recreated */ /* @internal */ - function isProgramUptoDate(program, rootFileNames, newOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, projectReferences) { + function isProgramUptoDate(program, rootFileNames, newOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences) { // If we haven't created a program yet or have changed automatic type directives, then it is not up-to-date - if (!program || (hasChangedAutomaticTypeDirectiveNames === null || hasChangedAutomaticTypeDirectiveNames === void 0 ? void 0 : hasChangedAutomaticTypeDirectiveNames())) { + if (!program || (hasChangedAutomaticTypeDirectiveNames === null || hasChangedAutomaticTypeDirectiveNames === void 0 ? void 0 : hasChangedAutomaticTypeDirectiveNames())) return false; - } // If root file names don't match - if (!ts.arrayIsEqualTo(program.getRootFileNames(), rootFileNames)) { + if (!ts.arrayIsEqualTo(program.getRootFileNames(), rootFileNames)) return false; - } var seenResolvedRefs; // If project references don't match - if (!ts.arrayIsEqualTo(program.getProjectReferences(), projectReferences, projectReferenceUptoDate)) { + if (!ts.arrayIsEqualTo(program.getProjectReferences(), projectReferences, projectReferenceUptoDate)) return false; - } // If any file is not up-to-date, then the whole program is not up-to-date - if (program.getSourceFiles().some(sourceFileNotUptoDate)) { + if (program.getSourceFiles().some(sourceFileNotUptoDate)) return false; - } // If any of the missing file paths are now created - if (program.getMissingFilePaths().some(fileExists)) { + if (program.getMissingFilePaths().some(fileExists)) return false; - } var currentOptions = program.getCompilerOptions(); // If the compilation settings do no match, then the program is not up-to-date - if (!ts.compareDataObjects(currentOptions, newOptions)) { + if (!ts.compareDataObjects(currentOptions, newOptions)) return false; - } // If everything matches but the text of config file is changed, // error locations can change for program options, so update the program - if (currentOptions.configFile && newOptions.configFile) { + if (currentOptions.configFile && newOptions.configFile) return currentOptions.configFile.text === newOptions.configFile.text; - } return true; function sourceFileNotUptoDate(sourceFile) { return !sourceFileVersionUptoDate(sourceFile) || @@ -105966,21 +109643,25 @@ var ts; return sourceFile.version === getSourceVersion(sourceFile.resolvedPath, sourceFile.fileName); } function projectReferenceUptoDate(oldRef, newRef, index) { - if (!ts.projectReferenceIsEqualTo(oldRef, newRef)) { - return false; - } - return resolvedProjectReferenceUptoDate(program.getResolvedProjectReferences()[index], oldRef); + return ts.projectReferenceIsEqualTo(oldRef, newRef) && + resolvedProjectReferenceUptoDate(program.getResolvedProjectReferences()[index], oldRef); } function resolvedProjectReferenceUptoDate(oldResolvedRef, oldRef) { if (oldResolvedRef) { - if (ts.contains(seenResolvedRefs, oldResolvedRef)) { - // Assume true + // Assume true + if (ts.contains(seenResolvedRefs, oldResolvedRef)) return true; - } - // If sourceFile for the oldResolvedRef existed, check the version for uptodate - if (!sourceFileVersionUptoDate(oldResolvedRef.sourceFile)) { + var refPath_1 = resolveProjectReferencePath(oldRef); + var newParsedCommandLine = getParsedCommandLine(refPath_1); + // Check if config file exists + if (!newParsedCommandLine) + return false; + // If change in source file + if (oldResolvedRef.commandLine.options.configFile !== newParsedCommandLine.options.configFile) + return false; + // check file names + if (!ts.arrayIsEqualTo(oldResolvedRef.commandLine.fileNames, newParsedCommandLine.fileNames)) return false; - } // Add to seen before checking the referenced paths of this config file (seenResolvedRefs || (seenResolvedRefs = [])).push(oldResolvedRef); // If child project references are upto date, this project reference is uptodate @@ -105990,7 +109671,8 @@ var ts; } // In old program, not able to resolve project reference path, // so if config file doesnt exist, it is uptodate. - return !fileExists(resolveProjectReferencePath(oldRef)); + var refPath = resolveProjectReferencePath(oldRef); + return !getParsedCommandLine(refPath); } } ts.isProgramUptoDate = isProgramUptoDate; @@ -106007,10 +109689,7 @@ var ts; return false; // If any compiler options change, we can't reuse old source file even if version match // The change in options like these could result in change in syntax tree or `sourceFile.bindDiagnostics`. - var oldOptions = program.getCompilerOptions(); - return !!ts.sourceFileAffectingCompilerOptions.some(function (option) { - return !ts.isJsonEqual(ts.getCompilerOptionValue(oldOptions, option), ts.getCompilerOptionValue(newOptions, option)); - }); + return ts.optionsHaveChanges(program.getCompilerOptions(), newOptions, ts.sourceFileAffectingCompilerOptions); } function createCreateProgramOptions(rootNames, options, host, oldProgram, configFileParsingDiagnostics) { return { @@ -106054,7 +109733,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.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" /* Program */, "createProgram", { configFilePath: options.configFilePath, rootDir: options.rootDir }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeProgram"); var host = createProgramOptions.host || createCompilerHost(options); var configParsingHost = parseConfigHostFromCompilerHostLike(host); @@ -106069,6 +109748,7 @@ var ts; var hasEmitBlockingDiagnostics = new ts.Map(); var _compilerOptionsObjectLiteralSyntax; var moduleResolutionCache; + var typeReferenceDirectiveResolutionCache; var actualResolveModuleNamesWorker; var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse; if (host.resolveModuleNames) { @@ -106083,7 +109763,7 @@ var ts; }); }; } else { - moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, function (x) { return host.getCanonicalFileName(x); }, options); + moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName, options); var loader_1 = function (moduleName, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache, redirectedReference).resolvedModule; }; // TODO: GH#18217 actualResolveModuleNamesWorker = function (moduleNames, containingFile, _reusedNames, redirectedReference) { return loadWithLocalCache(ts.Debug.checkEachDefined(moduleNames), containingFile, redirectedReference, loader_1); }; } @@ -106092,7 +109772,8 @@ var ts; actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options); }; } else { - var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference).resolvedTypeReferenceDirective; }; // TODO: GH#18217 + typeReferenceDirectiveResolutionCache = ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, /*options*/ undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache()); + var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache).resolvedTypeReferenceDirective; }; // TODO: GH#18217 actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { return loadWithLocalCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, loader_2); }; } // Map from a stringified PackageId to the source file with that id. @@ -106130,15 +109811,15 @@ var ts; getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect, forEachResolvedProjectReference: forEachResolvedProjectReference }), onProgramCreateComplete = _d.onProgramCreateComplete, fileExists = _d.fileExists, directoryExists = _d.directoryExists; - ts.tracing.push("program" /* Program */, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram }); var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options); - ts.tracing.pop(); + 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.push("program" /* Program */, "tryReuseStructureFromOldProgram", {}); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "tryReuseStructureFromOldProgram", {}); structureIsReused = tryReuseStructureFromOldProgram(); // eslint-disable-line prefer-const - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); if (structureIsReused !== 2 /* Completely */) { processingDefaultLibFiles = []; processingOtherFiles = []; @@ -106176,13 +109857,13 @@ var ts; }); } } - ts.tracing.push("program" /* Program */, "processRootFiles", { count: rootNames.length }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* 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.pop(); + 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.push("program" /* Program */, "processTypeReferences", { count: typeReferences.length }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* 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); @@ -106190,7 +109871,7 @@ var ts; for (var i = 0; i < typeReferences.length; i++) { processTypeReferenceDirective(typeReferences[i], resolutions[i], { kind: ts.FileIncludeKind.AutomaticTypeDirectiveFile, typeReference: typeReferences[i], packageId: (_b = resolutions[i]) === null || _b === void 0 ? void 0 : _b.packageId }); } - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } // Do not process the default library if: // - The '--noLib' flag is used. @@ -106231,12 +109912,25 @@ var ts; host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path)); } } - oldProgram.forEachResolvedProjectReference(function (resolvedProjectReference) { - if (!getResolvedProjectReferenceByPath(resolvedProjectReference.sourceFile.path)) { - host.onReleaseOldSourceFile(resolvedProjectReference.sourceFile, oldProgram.getCompilerOptions(), /*hasSourceFileByPath*/ false); + if (!host.getParsedCommandLine) { + oldProgram.forEachResolvedProjectReference(function (resolvedProjectReference) { + if (!getResolvedProjectReferenceByPath(resolvedProjectReference.sourceFile.path)) { + host.onReleaseOldSourceFile(resolvedProjectReference.sourceFile, oldProgram.getCompilerOptions(), /*hasSourceFileByPath*/ false); + } + }); + } + } + // Release commandlines that new program does not use + if (oldProgram && host.onReleaseParsedCommandLine) { + forEachProjectReference(oldProgram.getProjectReferences(), oldProgram.getResolvedProjectReferences(), function (oldResolvedRef, parent, index) { + var oldReference = (parent === null || parent === void 0 ? void 0 : parent.commandLine.projectReferences[index]) || oldProgram.getProjectReferences()[index]; + var oldRefPath = resolveProjectReferencePath(oldReference); + if (!(projectReferenceRedirects === null || projectReferenceRedirects === void 0 ? void 0 : projectReferenceRedirects.has(toPath(oldRefPath)))) { + host.onReleaseParsedCommandLine(oldRefPath, oldResolvedRef, oldProgram.getCompilerOptions()); } }); } + typeReferenceDirectiveResolutionCache = undefined; // unconditionally set oldProgram to undefined to prevent it from being captured in closure oldProgram = undefined; var program = { @@ -106265,7 +109959,6 @@ var ts; getNodeCount: function () { return getDiagnosticsProducingTypeChecker().getNodeCount(); }, getIdentifierCount: function () { return getDiagnosticsProducingTypeChecker().getIdentifierCount(); }, getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); }, - getTypeCatalog: function () { return getDiagnosticsProducingTypeChecker().getTypeCatalog(); }, getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); }, getInstantiationCount: function () { return getDiagnosticsProducingTypeChecker().getInstantiationCount(); }, getRelationCacheSizes: function () { return getDiagnosticsProducingTypeChecker().getRelationCacheSizes(); }, @@ -106313,19 +110006,19 @@ var ts; verifyCompilerOptions(); ts.performance.mark("afterProgram"); ts.performance.measure("Program", "beforeProgram", "afterProgram"); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return program; function resolveModuleNamesWorker(moduleNames, containingFile, reusedNames) { if (!moduleNames.length) return ts.emptyArray; var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory); var redirectedReference = getRedirectReferenceForResolution(containingFile); - ts.tracing.push("program" /* Program */, "resolveModuleNamesWorker", { containingFileName: containingFileName }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveModuleNamesWorker", { containingFileName: containingFileName }); ts.performance.mark("beforeResolveModule"); var result = actualResolveModuleNamesWorker(moduleNames, containingFileName, reusedNames, redirectedReference); ts.performance.mark("afterResolveModule"); ts.performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule"); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; } function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile) { @@ -106333,12 +110026,12 @@ var ts; return []; var containingFileName = !ts.isString(containingFile) ? ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile; var redirectedReference = !ts.isString(containingFile) ? getRedirectReferenceForResolution(containingFile) : undefined; - ts.tracing.push("program" /* Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName }); ts.performance.mark("beforeResolveTypeReference"); var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference); ts.performance.mark("afterResolveTypeReference"); ts.performance.measure("ResolveTypeReference", "beforeResolveTypeReference", "afterResolveTypeReference"); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; } function getRedirectReferenceForResolution(file) { @@ -106465,7 +110158,9 @@ var ts; var oldResolvedModule = ts.getResolvedModule(oldSourceFile, moduleName); if (oldResolvedModule) { if (ts.isTraceEnabled(options, host)) { - ts.trace(host, ts.Diagnostics.Reusing_resolution_of_module_0_to_file_1_from_old_program, moduleName, ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory)); + ts.trace(host, oldResolvedModule.packageId ? + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 : + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2, moduleName, ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory), oldResolvedModule.resolvedFileName, oldResolvedModule.packageId && ts.packageIdToString(oldResolvedModule.packageId)); } (result || (result = new Array(moduleNames.length)))[i] = oldResolvedModule; (reusedNames || (reusedNames = [])).push(moduleName); @@ -106548,7 +110243,9 @@ var ts; var newResolvedRef = parseProjectReferenceConfigFile(newRef); if (oldResolvedRef) { // Resolved project reference has gone missing or changed - return !newResolvedRef || newResolvedRef.sourceFile !== oldResolvedRef.sourceFile; + return !newResolvedRef || + newResolvedRef.sourceFile !== oldResolvedRef.sourceFile || + !ts.arrayIsEqualTo(oldResolvedRef.commandLine.fileNames, newResolvedRef.commandLine.fileNames); } else { // A previously-unresolved reference may be resolved now @@ -106576,9 +110273,6 @@ var ts; if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) { return 0 /* Not */; } - if (!ts.arrayIsEqualTo(options.types, oldOptions.types)) { - return 0 /* Not */; - } // Check if any referenced project tsconfig files are different if (!canReuseProjectReferences()) { return 0 /* Not */; @@ -106653,7 +110347,7 @@ var ts; // The `newSourceFile` object was created for the new program. if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) { // 'lib' references has changed. Matches behavior in changesAffectModuleResolution - return 0 /* Not */; + structureIsReused = 1 /* SafeModules */; } if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { // value of no-default-lib has changed @@ -106738,7 +110432,7 @@ var ts; if (structureIsReused !== 2 /* Completely */) { return structureIsReused; } - if ((_a = host.hasChangedAutomaticTypeDirectiveNames) === null || _a === void 0 ? void 0 : _a.call(host)) { + if (ts.changesAffectingProgramStructure(oldOptions, options) || ((_a = host.hasChangedAutomaticTypeDirectiveNames) === null || _a === void 0 ? void 0 : _a.call(host))) { return 1 /* SafeModules */; } missingFilePaths = oldProgram.getMissingFilePaths(); @@ -106810,7 +110504,7 @@ var ts; } function emitBuildInfo(writeFileCallback) { ts.Debug.assert(!ts.outFile(options)); - ts.tracing.push("emit" /* Emit */, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeEmit"); var emitResult = ts.emitFiles(ts.notImplementedResolver, getEmitHost(writeFileCallback), /*targetSourceFile*/ undefined, @@ -106819,7 +110513,7 @@ var ts; /*onlyBuildInfo*/ true); ts.performance.mark("afterEmit"); ts.performance.measure("Emit", "beforeEmit", "afterEmit"); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return emitResult; } function getResolvedProjectReferences() { @@ -106865,9 +110559,9 @@ var ts; return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ false)); } function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) { - 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" /* 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.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; } function isEmitBlocked(emitFileName) { @@ -107071,22 +110765,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 160 /* Parameter */: - case 163 /* PropertyDeclaration */: - case 165 /* MethodDeclaration */: + case 162 /* Parameter */: + case 165 /* PropertyDeclaration */: + case 167 /* 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 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: - case 209 /* ArrowFunction */: - case 249 /* VariableDeclaration */: + case 166 /* MethodSignature */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 210 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 211 /* ArrowFunction */: + case 251 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files)); @@ -107094,58 +110788,58 @@ var ts; } } switch (node.kind) { - case 262 /* ImportClause */: + case 264 /* 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 267 /* ExportDeclaration */: + case 269 /* 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 260 /* ImportEqualsDeclaration */: + case 262 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_TypeScript_files)); return "skip"; - case 266 /* ExportAssignment */: + case 268 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 286 /* HeritageClause */: + case 288 /* HeritageClause */: var heritageClause = node; - if (heritageClause.token === 116 /* ImplementsKeyword */) { + if (heritageClause.token === 117 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 253 /* InterfaceDeclaration */: - var interfaceKeyword = ts.tokenToString(117 /* InterfaceKeyword */); + case 255 /* InterfaceDeclaration */: + var interfaceKeyword = ts.tokenToString(118 /* InterfaceKeyword */); ts.Debug.assertIsDefined(interfaceKeyword); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, interfaceKeyword)); return "skip"; - case 256 /* ModuleDeclaration */: - var moduleKeyword = node.flags & 16 /* Namespace */ ? ts.tokenToString(140 /* NamespaceKeyword */) : ts.tokenToString(139 /* ModuleKeyword */); + case 258 /* ModuleDeclaration */: + var moduleKeyword = node.flags & 16 /* Namespace */ ? ts.tokenToString(141 /* NamespaceKeyword */) : ts.tokenToString(140 /* ModuleKeyword */); ts.Debug.assertIsDefined(moduleKeyword); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, moduleKeyword)); return "skip"; - case 254 /* TypeAliasDeclaration */: + case 256 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_aliases_can_only_be_used_in_TypeScript_files)); return "skip"; - case 255 /* EnumDeclaration */: - var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(91 /* EnumKeyword */)); + case 257 /* EnumDeclaration */: + var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(92 /* EnumKeyword */)); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, enumKeyword)); return "skip"; - case 225 /* NonNullExpression */: + case 227 /* NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Non_null_assertions_can_only_be_used_in_TypeScript_files)); return "skip"; - case 224 /* AsExpression */: + case 226 /* AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.Type_assertion_expressions_can_only_be_used_in_TypeScript_files)); return "skip"; - case 206 /* TypeAssertionExpression */: + case 208 /* TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } } @@ -107154,53 +110848,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 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: - case 209 /* ArrowFunction */: + case 254 /* ClassDeclaration */: + case 223 /* ClassExpression */: + case 167 /* MethodDeclaration */: + case 168 /* Constructor */: + case 169 /* GetAccessor */: + case 170 /* SetAccessor */: + case 210 /* FunctionExpression */: + case 253 /* FunctionDeclaration */: + case 211 /* 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 232 /* VariableStatement */: + case 234 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - checkModifiers(parent.modifiers, parent.kind === 232 /* VariableStatement */); + checkModifiers(parent.modifiers, parent.kind === 234 /* VariableStatement */); return "skip"; } break; - case 163 /* PropertyDeclaration */: + case 165 /* 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 (modifier.kind !== 123 /* StaticKeyword */) { + if (modifier.kind !== 124 /* 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 160 /* Parameter */: + case 162 /* Parameter */: // Check modifiers of parameter declaration if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Parameter_modifiers_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 203 /* CallExpression */: - case 204 /* NewExpression */: - case 223 /* ExpressionWithTypeArguments */: - case 274 /* JsxSelfClosingElement */: - case 275 /* JsxOpeningElement */: - case 205 /* TaggedTemplateExpression */: + case 205 /* CallExpression */: + case 206 /* NewExpression */: + case 225 /* ExpressionWithTypeArguments */: + case 276 /* JsxSelfClosingElement */: + case 277 /* JsxOpeningElement */: + case 207 /* TaggedTemplateExpression */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_arguments_can_only_be_used_in_TypeScript_files)); @@ -107213,24 +110907,25 @@ var ts; for (var _i = 0, modifiers_2 = modifiers; _i < modifiers_2.length; _i++) { var modifier = modifiers_2[_i]; switch (modifier.kind) { - case 84 /* ConstKeyword */: + case 85 /* ConstKeyword */: if (isConstValid) { continue; } // to report error, // falls through - case 122 /* PublicKeyword */: - case 120 /* PrivateKeyword */: - case 121 /* ProtectedKeyword */: - case 142 /* ReadonlyKeyword */: - case 133 /* DeclareKeyword */: - case 125 /* AbstractKeyword */: + case 123 /* PublicKeyword */: + case 121 /* PrivateKeyword */: + case 122 /* ProtectedKeyword */: + case 143 /* ReadonlyKeyword */: + case 134 /* DeclareKeyword */: + case 126 /* AbstractKeyword */: + case 157 /* OverrideKeyword */: 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 123 /* StaticKeyword */: - case 92 /* ExportKeyword */: - case 87 /* DefaultKeyword */: + case 124 /* StaticKeyword */: + case 93 /* ExportKeyword */: + case 88 /* DefaultKeyword */: } } } @@ -107301,8 +110996,8 @@ var ts; return a.fileName === b.fileName; } function moduleNameIsEqualTo(a, b) { - return a.kind === 78 /* Identifier */ - ? b.kind === 78 /* Identifier */ && a.escapedText === b.escapedText + return a.kind === 79 /* Identifier */ + ? b.kind === 79 /* Identifier */ && a.escapedText === b.escapedText : b.kind === 10 /* StringLiteral */ && a.text === b.text; } function createSyntheticImport(text, file) { @@ -107528,13 +111223,13 @@ var ts; } // Get source file from normalized fileName function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, reason, packageId) { - ts.tracing.push("program" /* Program */, "findSourceFile", { + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "findSourceFile", { fileName: fileName, isDefaultLib: isDefaultLib || undefined, fileIncludeKind: ts.FileIncludeKind[reason.kind], }); var result = findSourceFileWorker(fileName, path, isDefaultLib, ignoreNoDefaultLib, reason, packageId); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; } function findSourceFileWorker(fileName, path, isDefaultLib, ignoreNoDefaultLib, reason, packageId) { @@ -107793,9 +111488,9 @@ var ts; } } function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, reason) { - 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" /* Program */, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolveModuleNamesReusingOldState, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined }); processTypeReferenceDirectiveWorker(typeReferenceDirective, resolvedTypeReferenceDirective, reason); - ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } function processTypeReferenceDirectiveWorker(typeReferenceDirective, resolvedTypeReferenceDirective, reason) { // If we already found this library as a primary reference - nothing to do @@ -107866,12 +111561,14 @@ var ts; return host.getCanonicalFileName(fileName); } function processImportedModules(file) { + var _a; collectExternalModuleReferences(file); if (file.imports.length || file.moduleAugmentations.length) { // Because global augmentation doesn't have string literal name, we can check for global augmentation as such. var moduleNames = getModuleNames(file); var resolutions = resolveModuleNamesReusingOldState(moduleNames, file); ts.Debug.assert(resolutions.length === moduleNames.length); + var optionsForFile = (useSourceOfProjectReferenceRedirect ? (_a = getRedirectReferenceForResolution(file)) === null || _a === void 0 ? void 0 : _a.commandLine.options : undefined) || options; for (var index = 0; index < moduleNames.length; index++) { var resolution = resolutions[index]; ts.setResolvedModule(file, moduleNames[index], resolution); @@ -107894,11 +111591,11 @@ var ts; // Don't add the file if it has a bad extension (e.g. 'tsx' if we don't have '--allowJs') // This may still end up being an untyped module -- the file won't be included but imports will be allowed. var shouldAddFile = resolvedFileName - && !getResolutionDiagnostic(options, resolution) - && !options.noResolve + && !getResolutionDiagnostic(optionsForFile, resolution) + && !optionsForFile.noResolve && index < file.imports.length && !elideImport - && !(isJsFile && !ts.getAllowJSCompilerOption(options)) + && !(isJsFile && !ts.getAllowJSCompilerOption(optionsForFile)) && (ts.isInJSFile(file.imports[index]) || !(file.imports[index].flags & 4194304 /* JSDoc */)); if (elideImport) { modulesWithElidedImports.set(file.path, true); @@ -107984,6 +111681,9 @@ var ts; if (options.strictPropertyInitialization && !ts.getStrictOptionValue(options, "strictNullChecks")) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictPropertyInitialization", "strictNullChecks"); } + if (options.strictOptionalProperties && !ts.getStrictOptionValue(options, "strictNullChecks")) { + createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictOptionalProperties", "strictNullChecks"); + } if (options.isolatedModules) { if (options.out) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules"); @@ -108101,6 +111801,9 @@ var ts; if (options.module === ts.ModuleKind.None && languageVersion < 2 /* 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 */; }); if (firstNonExternalModuleSourceFile) { var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); @@ -108131,9 +111834,10 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Option_resolveJsonModule_can_only_be_specified_when_module_code_generation_is_commonjs_amd_es2015_or_esNext, "resolveJsonModule", "module"); } } - // there has to be common source directory if user specified --outdir || --sourceRoot + // there has to be common source directory if user specified --outdir || --rootDir || --sourceRoot // if user specified --mapRoot, there needs to be common source directory if there would be multiple files being emitted if (options.outDir || // there is --outDir specified + options.rootDir || // there is --rootDir specified options.sourceRoot || // there is --sourceRoot specified options.mapRoot) { // there is --mapRoot specified // Precalculate and cache the common source directory @@ -108630,7 +112334,7 @@ var ts; } function handleDirectoryCouldBeSymlink(directory) { var _a; - if (!host.getResolvedProjectReferences()) + if (!host.getResolvedProjectReferences() || ts.containsIgnoredPath(directory)) return; // Because we already watch node_modules, handle symlinks in there if (!originalRealpath || !ts.stringContains(directory, ts.nodeModulesPathPart)) @@ -108647,7 +112351,7 @@ var ts; symlinkCache.setSymlinkedDirectory(directoryPath, false); return; } - symlinkCache.setSymlinkedDirectory(directoryPath, { + symlinkCache.setSymlinkedDirectory(directory, { real: ts.ensureTrailingDirectorySeparator(real), realPath: realPath }); @@ -108923,12 +112627,15 @@ var ts; // From ambient modules for (var _f = 0, _g = program.getTypeChecker().getAmbientModules(); _f < _g.length; _f++) { var ambientModule = _g[_f]; - if (ambientModule.declarations.length > 1) { + if (ambientModule.declarations && ambientModule.declarations.length > 1) { addReferenceFromAmbientModule(ambientModule); } } return referencedFiles; function addReferenceFromAmbientModule(symbol) { + if (!symbol.declarations) { + return; + } // Add any file other than our own as reference for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; @@ -108953,7 +112660,7 @@ var ts; /** * Creates the state of file references and signature for the new program from oldState if it is safe */ - function create(newProgram, getCanonicalFileName, oldState) { + function create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) { var fileInfos = new ts.Map(); var referencedMap = newProgram.getCompilerOptions().module !== ts.ModuleKind.None ? new ts.Map() : undefined; var exportedModulesMap = referencedMap ? new ts.Map() : undefined; @@ -108979,13 +112686,14 @@ var ts; } } } - fileInfos.set(sourceFile.resolvedPath, { version: version_2, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) }); + fileInfos.set(sourceFile.resolvedPath, { version: version_2, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) || undefined }); } return { fileInfos: fileInfos, referencedMap: referencedMap, exportedModulesMap: exportedModulesMap, - hasCalledUpdateShapeSignature: hasCalledUpdateShapeSignature + hasCalledUpdateShapeSignature: hasCalledUpdateShapeSignature, + useFileVersionAsSignature: !disableUseFileVersionAsSignature && !useOldState }; } BuilderState.create = create; @@ -109007,6 +112715,7 @@ var ts; referencedMap: state.referencedMap && new ts.Map(state.referencedMap), exportedModulesMap: state.exportedModulesMap && new ts.Map(state.exportedModulesMap), hasCalledUpdateShapeSignature: new ts.Set(state.hasCalledUpdateShapeSignature), + useFileVersionAsSignature: state.useFileVersionAsSignature, }; } BuilderState.clone = clone; @@ -109062,23 +112771,12 @@ var ts; return ts.Debug.fail(); var prevSignature = info.signature; var latestSignature; - if (sourceFile.isDeclarationFile) { - latestSignature = sourceFile.version; - if (exportedModulesMapCache && latestSignature !== prevSignature) { - // All the references in this file are exported - var references = state.referencedMap ? state.referencedMap.get(sourceFile.resolvedPath) : undefined; - exportedModulesMapCache.set(sourceFile.resolvedPath, references || false); - } - } - else { + if (!sourceFile.isDeclarationFile && !state.useFileVersionAsSignature) { var emitOutput_1 = getFileEmitOutput(programOfThisState, sourceFile, /*emitOnlyDtsFiles*/ true, cancellationToken, /*customTransformers*/ undefined, /*forceDtsEmit*/ true); - var firstDts_1 = emitOutput_1.outputFiles && - programOfThisState.getCompilerOptions().declarationMap ? - emitOutput_1.outputFiles.length > 1 ? emitOutput_1.outputFiles[1] : undefined : - emitOutput_1.outputFiles.length > 0 ? emitOutput_1.outputFiles[0] : undefined; + var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles); if (firstDts_1) { ts.Debug.assert(ts.fileExtensionIs(firstDts_1.name, ".d.ts" /* Dts */), "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 = (computeHash || ts.generateDjb2Hash)(firstDts_1.text); @@ -109086,12 +112784,18 @@ var ts; updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache); } } - else { - latestSignature = prevSignature; // TODO: GH#18217 + } + // Default is to use file version as signature + if (latestSignature === undefined) { + latestSignature = sourceFile.version; + if (exportedModulesMapCache && latestSignature !== prevSignature) { + // All the references in this file are exported + var references = state.referencedMap ? state.referencedMap.get(sourceFile.resolvedPath) : undefined; + exportedModulesMapCache.set(sourceFile.resolvedPath, references || false); } } cacheToUpdateSignature.set(sourceFile.resolvedPath, latestSignature); - return !prevSignature || latestSignature !== prevSignature; + return latestSignature !== prevSignature; } BuilderState.updateShapeSignature = updateShapeSignature; /** @@ -109211,7 +112915,7 @@ var ts; */ function isFileAffectingGlobalScope(sourceFile) { return containsGlobalScopeAugmentation(sourceFile) || - !ts.isExternalModule(sourceFile) && !containsOnlyAmbientModules(sourceFile); + !ts.isExternalOrCommonJsModule(sourceFile) && !containsOnlyAmbientModules(sourceFile); } /** * Gets all files of the program excluding the default library file @@ -109299,8 +113003,8 @@ var ts; /** * Create the state so that we can iterate on changedFiles/affected files */ - function createBuilderProgramState(newProgram, getCanonicalFileName, oldState) { - var state = ts.BuilderState.create(newProgram, getCanonicalFileName, oldState); + function createBuilderProgramState(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) { + var state = ts.BuilderState.create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature); state.program = newProgram; var compilerOptions = newProgram.getCompilerOptions(); state.compilerOptions = compilerOptions; @@ -109538,6 +113242,7 @@ var ts; * 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) { + var _a; removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath); // If affected files is everything except default library, then nothing more to do if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) { @@ -109551,8 +113256,15 @@ var ts; removeSemanticDiagnosticsOf(state, f.resolvedPath); }); } + // 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, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap); return; } + else { + ts.Debug.assert(state.hasCalledUpdateShapeSignature.has(affectedFile.resolvedPath) || ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.has(affectedFile.resolvedPath)), "Signature not updated for affected file: " + affectedFile.fileName); + } if (!state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) { forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash); }); } @@ -109764,83 +113476,116 @@ var ts; return undefined; var currentDirectory = ts.Debug.checkDefined(state.program).getCurrentDirectory(); var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory)); - var fileInfos = {}; - state.fileInfos.forEach(function (value, key) { + var fileNames = []; + var fileNameToFileId = new ts.Map(); + var fileIdsList; + var fileNamesToFileIdListId; + var fileInfos = ts.arrayFrom(state.fileInfos.entries(), function (_a) { + var key = _a[0], value = _a[1]; + // Ensure fileId + var fileId = toFileId(key); + ts.Debug.assert(fileNames[fileId - 1] === relativeToBuildInfo(key)); var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key); - fileInfos[relativeToBuildInfo(key)] = signature === undefined ? value : { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope }; + var actualSignature = signature !== null && signature !== void 0 ? signature : value.signature; + return value.version === actualSignature ? + value.affectsGlobalScope ? + { version: value.version, signature: undefined, affectsGlobalScope: true } : + value.version : + actualSignature !== undefined ? + signature === undefined ? + value : + { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope } : + { version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope }; }); - var result = { - fileInfos: fileInfos, - options: convertToReusableCompilerOptions(state.compilerOptions, relativeToBuildInfoEnsuringAbsolutePath) - }; + var referencedMap; if (state.referencedMap) { - var referencedMap = {}; - for (var _i = 0, _a = ts.arrayFrom(state.referencedMap.keys()).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) { - var key = _a[_i]; - referencedMap[relativeToBuildInfo(key)] = ts.arrayFrom(state.referencedMap.get(key).keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive); - } - result.referencedMap = referencedMap; + referencedMap = ts.arrayFrom(state.referencedMap.keys()).sort(ts.compareStringsCaseSensitive).map(function (key) { return [ + toFileId(key), + toFileIdListId(state.referencedMap.get(key)) + ]; }); } + var exportedModulesMap; if (state.exportedModulesMap) { - var exportedModulesMap = {}; - for (var _b = 0, _c = ts.arrayFrom(state.exportedModulesMap.keys()).sort(ts.compareStringsCaseSensitive); _b < _c.length; _b++) { - var key = _c[_b]; + exportedModulesMap = ts.mapDefined(ts.arrayFrom(state.exportedModulesMap.keys()).sort(ts.compareStringsCaseSensitive), function (key) { var newValue = state.currentAffectedFilesExportedModulesMap && state.currentAffectedFilesExportedModulesMap.get(key); // Not in temporary cache, use existing value if (newValue === undefined) - exportedModulesMap[relativeToBuildInfo(key)] = ts.arrayFrom(state.exportedModulesMap.get(key).keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive); + return [toFileId(key), toFileIdListId(state.exportedModulesMap.get(key))]; // Value in cache and has updated value map, use that else if (newValue) - exportedModulesMap[relativeToBuildInfo(key)] = ts.arrayFrom(newValue.keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive); - } - result.exportedModulesMap = exportedModulesMap; + return [toFileId(key), toFileIdListId(newValue)]; + }); } + var semanticDiagnosticsPerFile; if (state.semanticDiagnosticsPerFile) { - var semanticDiagnosticsPerFile = []; - for (var _d = 0, _e = ts.arrayFrom(state.semanticDiagnosticsPerFile.keys()).sort(ts.compareStringsCaseSensitive); _d < _e.length; _d++) { - var key = _e[_d]; + for (var _i = 0, _a = ts.arrayFrom(state.semanticDiagnosticsPerFile.keys()).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) { + var key = _a[_i]; var value = state.semanticDiagnosticsPerFile.get(key); - semanticDiagnosticsPerFile.push(value.length ? + (semanticDiagnosticsPerFile || (semanticDiagnosticsPerFile = [])).push(value.length ? [ - relativeToBuildInfo(key), + toFileId(key), state.hasReusableDiagnostic ? value : convertToReusableDiagnostics(value, relativeToBuildInfo) ] : - relativeToBuildInfo(key)); + toFileId(key)); } - result.semanticDiagnosticsPerFile = semanticDiagnosticsPerFile; } + var affectedFilesPendingEmit; if (state.affectedFilesPendingEmit) { - var affectedFilesPendingEmit = []; var seenFiles = new ts.Set(); - for (var _f = 0, _g = state.affectedFilesPendingEmit.slice(state.affectedFilesPendingEmitIndex).sort(ts.compareStringsCaseSensitive); _f < _g.length; _f++) { - var path = _g[_f]; + for (var _b = 0, _c = state.affectedFilesPendingEmit.slice(state.affectedFilesPendingEmitIndex).sort(ts.compareStringsCaseSensitive); _b < _c.length; _b++) { + var path = _c[_b]; if (ts.tryAddToSet(seenFiles, path)) { - affectedFilesPendingEmit.push([relativeToBuildInfo(path), state.affectedFilesPendingEmitKind.get(path)]); + (affectedFilesPendingEmit || (affectedFilesPendingEmit = [])).push([toFileId(path), state.affectedFilesPendingEmitKind.get(path)]); } } - result.affectedFilesPendingEmit = affectedFilesPendingEmit; } - return result; + return { + fileNames: fileNames, + fileInfos: fileInfos, + options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, relativeToBuildInfoEnsuringAbsolutePath), + fileIdsList: fileIdsList, + referencedMap: referencedMap, + exportedModulesMap: exportedModulesMap, + semanticDiagnosticsPerFile: semanticDiagnosticsPerFile, + affectedFilesPendingEmit: affectedFilesPendingEmit, + }; function relativeToBuildInfoEnsuringAbsolutePath(path) { return relativeToBuildInfo(ts.getNormalizedAbsolutePath(path, currentDirectory)); } function relativeToBuildInfo(path) { return ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(buildInfoDirectory, path, getCanonicalFileName)); } + function toFileId(path) { + var fileId = fileNameToFileId.get(path); + if (fileId === undefined) { + fileNames.push(relativeToBuildInfo(path)); + fileNameToFileId.set(path, fileId = fileNames.length); + } + return fileId; + } + function toFileIdListId(set) { + var fileIds = ts.arrayFrom(set.keys(), toFileId).sort(ts.compareValues); + var key = fileIds.join(); + var fileIdListId = fileNamesToFileIdListId === null || fileNamesToFileIdListId === void 0 ? void 0 : fileNamesToFileIdListId.get(key); + if (fileIdListId === undefined) { + (fileIdsList || (fileIdsList = [])).push(fileIds); + (fileNamesToFileIdListId || (fileNamesToFileIdListId = new ts.Map())).set(key, fileIdListId = fileIdsList.length); + } + return fileIdListId; + } } - function convertToReusableCompilerOptions(options, relativeToBuildInfo) { - var result = {}; + function convertToProgramBuildInfoCompilerOptions(options, relativeToBuildInfo) { + var result; var optionsNameMap = ts.getOptionsNameMap().optionsNameMap; - for (var name in options) { - if (ts.hasProperty(options, name)) { - result[name] = convertToReusableCompilerOptionValue(optionsNameMap.get(name.toLowerCase()), options[name], relativeToBuildInfo); + for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) { + var name = _a[_i]; + var optionInfo = optionsNameMap.get(name.toLowerCase()); + if ((optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsEmit) || (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsSemanticDiagnostics) || name === "skipLibCheck" || name === "skipDefaultLibCheck") { + (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfo); } } - if (result.configFilePath) { - result.configFilePath = relativeToBuildInfo(result.configFilePath); - } return result; } function convertToReusableCompilerOptionValue(option, value, relativeToBuildInfo) { @@ -109932,15 +113677,16 @@ var ts; * Computing hash to for signature verification */ var computeHash = ts.maybeBind(host, host.createHash); - var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState); + var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState, host.disableUseFileVersionAsSignature); var backupState; 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; oldState = undefined; - var builderProgram = createRedirectedBuilderProgram(state, configFileParsingDiagnostics); - builderProgram.getState = function () { return state; }; + var getState = function () { return state; }; + var builderProgram = createRedirectedBuilderProgram(getState, configFileParsingDiagnostics); + builderProgram.getState = getState; builderProgram.backupState = function () { ts.Debug.assert(backupState === undefined); backupState = cloneBuilderProgramState(state); @@ -110156,37 +113902,31 @@ var ts; state.affectedFilesPendingEmitIndex = 0; } } - function getMapOfReferencedSet(mapLike, toPath) { - if (!mapLike) - return undefined; - var map = new ts.Map(); - // Copies keys/values from template. Note that for..in will not throw if - // template is undefined, and instead will just exit the loop. - for (var key in mapLike) { - if (ts.hasProperty(mapLike, key)) { - map.set(toPath(key), new ts.Set(mapLike[key].map(toPath))); - } - } - return map; + function toBuilderStateFileInfo(fileInfo) { + return ts.isString(fileInfo) ? + { version: fileInfo, signature: fileInfo, affectsGlobalScope: undefined } : + ts.isString(fileInfo.signature) ? + fileInfo : + { version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope }; } + ts.toBuilderStateFileInfo = toBuilderStateFileInfo; function createBuildProgramUsingProgramBuildInfo(program, buildInfoPath, host) { + var _a; var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory())); var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames()); + var filePaths = program.fileNames.map(toPath); + var filePathsSetList = (_a = program.fileIdsList) === null || _a === void 0 ? void 0 : _a.map(function (fileIds) { return new ts.Set(fileIds.map(toFilePath)); }); var fileInfos = new ts.Map(); - for (var key in program.fileInfos) { - if (ts.hasProperty(program.fileInfos, key)) { - fileInfos.set(toPath(key), program.fileInfos[key]); - } - } + program.fileInfos.forEach(function (fileInfo, index) { return fileInfos.set(toFilePath(index + 1), toBuilderStateFileInfo(fileInfo)); }); var state = { fileInfos: fileInfos, - compilerOptions: ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath), - referencedMap: getMapOfReferencedSet(program.referencedMap, toPath), - exportedModulesMap: getMapOfReferencedSet(program.exportedModulesMap, toPath), - semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, function (value) { return toPath(ts.isString(value) ? value : value[0]); }, function (value) { return ts.isString(value) ? ts.emptyArray : value[1]; }), + compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {}, + referencedMap: toMapOfReferencedSet(program.referencedMap), + exportedModulesMap: toMapOfReferencedSet(program.exportedModulesMap), + semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, function (value) { return toFilePath(ts.isNumber(value) ? value : value[0]); }, function (value) { return ts.isNumber(value) ? ts.emptyArray : value[1]; }), hasReusableDiagnostic: true, - affectedFilesPendingEmit: ts.map(program.affectedFilesPendingEmit, function (value) { return toPath(value[0]); }), - affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toPath(value[0]); }, function (value) { return value[1]; }), + affectedFilesPendingEmit: ts.map(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }), + affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }, function (value) { return value[1]; }), affectedFilesPendingEmitIndex: program.affectedFilesPendingEmit && 0, }; return { @@ -110219,17 +113959,26 @@ var ts; function toAbsolutePath(path) { return ts.getNormalizedAbsolutePath(path, buildInfoDirectory); } + function toFilePath(fileId) { + return filePaths[fileId - 1]; + } + function toFilePathsSet(fileIdsListId) { + return filePathsSetList[fileIdsListId - 1]; + } + function toMapOfReferencedSet(referenceMap) { + return referenceMap && ts.arrayToMap(referenceMap, function (value) { return toFilePath(value[0]); }, function (value) { return toFilePathsSet(value[1]); }); + } } ts.createBuildProgramUsingProgramBuildInfo = createBuildProgramUsingProgramBuildInfo; - function createRedirectedBuilderProgram(state, configFileParsingDiagnostics) { + function createRedirectedBuilderProgram(getState, configFileParsingDiagnostics) { return { getState: ts.notImplemented, backupState: ts.noop, restoreState: ts.noop, getProgram: getProgram, - getProgramOrUndefined: function () { return state.program; }, - releaseProgram: function () { return state.program = undefined; }, - getCompilerOptions: function () { return state.compilerOptions; }, + getProgramOrUndefined: function () { return getState().program; }, + releaseProgram: function () { return getState().program = undefined; }, + getCompilerOptions: function () { return getState().compilerOptions; }, getSourceFile: function (fileName) { return getProgram().getSourceFile(fileName); }, getSourceFiles: function () { return getProgram().getSourceFiles(); }, getOptionsDiagnostics: function (cancellationToken) { return getProgram().getOptionsDiagnostics(cancellationToken); }, @@ -110245,7 +113994,7 @@ var ts; close: ts.noop, }; function getProgram() { - return ts.Debug.checkDefined(state.program); + return ts.Debug.checkDefined(getState().program); } } ts.createRedirectedBuilderProgram = createRedirectedBuilderProgram; @@ -110262,7 +114011,7 @@ var ts; ts.createEmitAndSemanticDiagnosticsBuilderProgram = createEmitAndSemanticDiagnosticsBuilderProgram; function createAbstractBuilder(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences) { var _a = ts.getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences), newProgram = _a.newProgram, newConfigFileParsingDiagnostics = _a.configFileParsingDiagnostics; - return ts.createRedirectedBuilderProgram({ program: newProgram, compilerOptions: newProgram.getCompilerOptions() }, newConfigFileParsingDiagnostics); + return ts.createRedirectedBuilderProgram(function () { return ({ program: newProgram, compilerOptions: newProgram.getCompilerOptions() }); }, newConfigFileParsingDiagnostics); } ts.createAbstractBuilder = createAbstractBuilder; })(ts || (ts = {})); @@ -110331,9 +114080,9 @@ var ts; var resolutionsWithFailedLookups = []; var resolvedFileToResolution = ts.createMultiMap(); var hasChangedAutomaticTypeDirectiveNames = false; - var failedLookupChecks = []; - var startsWithPathChecks = []; - var isInDirectoryChecks = []; + var failedLookupChecks; + var startsWithPathChecks; + var isInDirectoryChecks; var getCurrentDirectory = ts.memoize(function () { return resolutionHost.getCurrentDirectory(); }); // TODO: GH#18217 var cachedDirectoryStructureHost = resolutionHost.getCachedDirectoryStructureHost(); // The resolvedModuleNames and resolvedTypeReferenceDirectives are the cache of resolutions per file. @@ -110342,9 +114091,12 @@ var ts; var resolvedModuleNames = new ts.Map(); var perDirectoryResolvedModuleNames = ts.createCacheWithRedirects(); var nonRelativeModuleNameCache = ts.createCacheWithRedirects(); - var moduleResolutionCache = ts.createModuleResolutionCacheWithMaps(perDirectoryResolvedModuleNames, nonRelativeModuleNameCache, getCurrentDirectory(), resolutionHost.getCanonicalFileName); + var moduleResolutionCache = ts.createModuleResolutionCache(getCurrentDirectory(), resolutionHost.getCanonicalFileName, + /*options*/ undefined, perDirectoryResolvedModuleNames, nonRelativeModuleNameCache); var resolvedTypeReferenceDirectives = new ts.Map(); var perDirectoryResolvedTypeReferenceDirectives = ts.createCacheWithRedirects(); + var typeReferenceDirectiveResolutionCache = ts.createTypeReferenceDirectiveResolutionCache(getCurrentDirectory(), resolutionHost.getCanonicalFileName, + /*options*/ undefined, moduleResolutionCache.getPackageJsonInfoCache(), perDirectoryResolvedTypeReferenceDirectives); /** * These are the extensions that failed lookup files will have by default, * any other extension of failed lookup will be store that path in custom failed lookup path @@ -110376,6 +114128,7 @@ var ts; invalidateResolutionsOfFailedLookupLocations: invalidateResolutionsOfFailedLookupLocations, setFilesWithInvalidatedNonRelativeUnresolvedImports: setFilesWithInvalidatedNonRelativeUnresolvedImports, createHasInvalidatedResolution: createHasInvalidatedResolution, + isFileWithInvalidatedNonRelativeUnresolvedImports: isFileWithInvalidatedNonRelativeUnresolvedImports, updateTypeRootsWatch: updateTypeRootsWatch, closeTypeRootsWatch: closeTypeRootsWatch, clear: clear @@ -110401,9 +114154,9 @@ var ts; resolvedTypeReferenceDirectives.clear(); resolvedFileToResolution.clear(); resolutionsWithFailedLookups.length = 0; - failedLookupChecks.length = 0; - startsWithPathChecks.length = 0; - isInDirectoryChecks.length = 0; + failedLookupChecks = undefined; + startsWithPathChecks = undefined; + isInDirectoryChecks = undefined; // perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update // (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution) clearPerDirectoryResolutions(); @@ -110439,9 +114192,8 @@ var ts; isFileWithInvalidatedNonRelativeUnresolvedImports(path); }; } function clearPerDirectoryResolutions() { - perDirectoryResolvedModuleNames.clear(); - nonRelativeModuleNameCache.clear(); - perDirectoryResolvedTypeReferenceDirectives.clear(); + moduleResolutionCache.clear(); + typeReferenceDirectiveResolutionCache.clear(); nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions); nonRelativeExternalModuleResolutions.clear(); } @@ -110468,7 +114220,7 @@ var ts; if (globalCache !== undefined && !ts.isExternalModuleNameRelative(moduleName) && !(primaryResult.resolvedModule && ts.extensionIsTS(primaryResult.resolvedModule.extension))) { // create different collection of failed lookup locations for second pass // if it will fail and we've already found something during the first pass - we don't want to pollute its results - var _b = ts.loadModuleFromGlobalCache(ts.Debug.checkDefined(resolutionHost.globalCacheResolutionModuleName)(moduleName), resolutionHost.projectName, compilerOptions, host, globalCache), resolvedModule = _b.resolvedModule, failedLookupLocations = _b.failedLookupLocations; + var _b = ts.loadModuleFromGlobalCache(ts.Debug.checkDefined(resolutionHost.globalCacheResolutionModuleName)(moduleName), resolutionHost.projectName, compilerOptions, host, globalCache, moduleResolutionCache), resolvedModule = _b.resolvedModule, failedLookupLocations = _b.failedLookupLocations; if (resolvedModule) { // Modify existing resolution so its saved in the directory cache as well primaryResult.resolvedModule = resolvedModule; @@ -110479,8 +114231,11 @@ var ts; // Default return the result from the first pass return primaryResult; } + function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference) { + return ts.resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache); + } function resolveNamesWithLocalCache(_a) { - var _b; + var _b, _c, _d; var names = _a.names, containingFile = _a.containingFile, redirectedReference = _a.redirectedReference, cache = _a.cache, perDirectoryCacheWithRedirects = _a.perDirectoryCacheWithRedirects, loader = _a.loader, getResolutionWithResolvedFileName = _a.getResolutionWithResolvedFileName, shouldRetryResolution = _a.shouldRetryResolution, reusedNames = _a.reusedNames, logChanges = _a.logChanges; var path = resolutionHost.toPath(containingFile); var resolutionsInFile = cache.get(path) || cache.set(path, new ts.Map()).get(path); @@ -110513,9 +114268,24 @@ var ts; var resolutionInDirectory = perDirectoryResolution.get(name); if (resolutionInDirectory) { resolution = resolutionInDirectory; + var host = ((_b = resolutionHost.getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(resolutionHost)) || resolutionHost; + if (ts.isTraceEnabled(compilerOptions, host)) { + var resolved = getResolutionWithResolvedFileName(resolution); + ts.trace(host, loader === resolveModuleName ? + (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ? + resolved.packagetId ? + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4 : + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3 : + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_not_resolved : + (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ? + resolved.packagetId ? + ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4 : + ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3 : + ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_not_resolved, name, containingFile, ts.getDirectoryPath(containingFile), resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName, (resolved === null || resolved === void 0 ? void 0 : resolved.packagetId) && ts.packageIdToString(resolved.packagetId)); + } } else { - resolution = loader(name, containingFile, compilerOptions, ((_b = resolutionHost.getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(resolutionHost)) || resolutionHost, redirectedReference); + resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference); perDirectoryResolution.set(name, resolution); } resolutionsInFile.set(name, resolution); @@ -110529,6 +114299,23 @@ var ts; logChanges = false; } } + else { + var host = ((_d = resolutionHost.getCompilerHost) === null || _d === void 0 ? void 0 : _d.call(resolutionHost)) || resolutionHost; + if (ts.isTraceEnabled(compilerOptions, host) && !seenNamesInFile.has(name)) { + var resolved = getResolutionWithResolvedFileName(resolution); + ts.trace(host, loader === resolveModuleName ? + (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ? + resolved.packagetId ? + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 : + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2 : + ts.Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_not_resolved : + (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ? + resolved.packagetId ? + ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 : + ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2 : + ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_not_resolved, name, containingFile, resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName, (resolved === null || resolved === void 0 ? void 0 : resolved.packagetId) && ts.packageIdToString(resolved.packagetId)); + } + } ts.Debug.assert(resolution !== undefined && !resolution.isInvalidated); seenNamesInFile.set(name, true); resolvedModules.push(getResolutionWithResolvedFileName(resolution)); @@ -110566,7 +114353,7 @@ var ts; redirectedReference: redirectedReference, cache: resolvedTypeReferenceDirectives, perDirectoryCacheWithRedirects: perDirectoryResolvedTypeReferenceDirectives, - loader: ts.resolveTypeReferenceDirective, + loader: resolveTypeReferenceDirective, getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective, shouldRetryResolution: function (resolution) { return resolution.resolvedTypeReferenceDirective === undefined; }, }); @@ -110841,7 +114628,7 @@ var ts; if (isCreatingWatchedDirectory) { // Watching directory is created // Invalidate any resolution has failed lookup in this directory - isInDirectoryChecks.push(fileOrDirectoryPath); + (isInDirectoryChecks || (isInDirectoryChecks = [])).push(fileOrDirectoryPath); } else { // If something to do with folder/file starting with "." in node_modules folder, skip it @@ -110859,8 +114646,8 @@ var ts; if (isNodeModulesAtTypesDirectory(fileOrDirectoryPath) || ts.isNodeModulesDirectory(fileOrDirectoryPath) || isNodeModulesAtTypesDirectory(dirOfFileOrDirectory) || ts.isNodeModulesDirectory(dirOfFileOrDirectory)) { // Invalidate any resolution from this directory - failedLookupChecks.push(fileOrDirectoryPath); - startsWithPathChecks.push(fileOrDirectoryPath); + (failedLookupChecks || (failedLookupChecks = [])).push(fileOrDirectoryPath); + (startsWithPathChecks || (startsWithPathChecks = new ts.Set())).add(fileOrDirectoryPath); } else { if (!isPathWithDefaultFailedLookupExtension(fileOrDirectoryPath) && !customFailedLookupPaths.has(fileOrDirectoryPath)) { @@ -110871,27 +114658,33 @@ var ts; return false; } // Resolution need to be invalidated if failed lookup location is same as the file or directory getting created - failedLookupChecks.push(fileOrDirectoryPath); + (failedLookupChecks || (failedLookupChecks = [])).push(fileOrDirectoryPath); + // If the invalidated file is from a node_modules package, invalidate everything else + // in the package since we might not get notifications for other files in the package. + // This hardens our logic against unreliable file watchers. + var packagePath = ts.parseNodeModuleFromPath(fileOrDirectoryPath); + if (packagePath) + (startsWithPathChecks || (startsWithPathChecks = new ts.Set())).add(packagePath); } } resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations(); } function invalidateResolutionsOfFailedLookupLocations() { - if (!failedLookupChecks.length && !startsWithPathChecks.length && !isInDirectoryChecks.length) { + if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks) { return false; } var invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution); - failedLookupChecks.length = 0; - startsWithPathChecks.length = 0; - isInDirectoryChecks.length = 0; + failedLookupChecks = undefined; + startsWithPathChecks = undefined; + isInDirectoryChecks = undefined; return invalidated; } function canInvalidateFailedLookupResolution(resolution) { return resolution.failedLookupLocations.some(function (location) { var locationPath = resolutionHost.toPath(location); return ts.contains(failedLookupChecks, locationPath) || - startsWithPathChecks.some(function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath); }) || - isInDirectoryChecks.some(function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath); }); + ts.firstDefinedIterator((startsWithPathChecks === null || startsWithPathChecks === void 0 ? void 0 : startsWithPathChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath) ? true : undefined; }) || + (isInDirectoryChecks === null || isInDirectoryChecks === void 0 ? void 0 : isInDirectoryChecks.some(function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath); })); }); } function closeTypeRootsWatch() { @@ -111042,6 +114835,9 @@ var ts; return [ambient]; var info = getInfo(importingSourceFile.path, host); var moduleSourceFile = ts.getSourceFileOfNode(moduleSymbol.valueDeclaration || ts.getNonAugmentationDeclaration(moduleSymbol)); + if (!moduleSourceFile) { + return []; + } var modulePaths = getAllModulePaths(importingSourceFile.path, moduleSourceFile.originalFileName, host); var preferences = getPreferences(userPreferences, compilerOptions, importingSourceFile); var existingSpecifier = ts.forEach(modulePaths, function (modulePath) { return ts.forEach(host.getFileIncludeReasons().get(ts.toPath(modulePath.path, host.getCurrentDirectory(), info.getCanonicalFileName)), function (reason) { @@ -111112,7 +114908,7 @@ var ts; if (!baseUrl && !paths || relativePreference === 0 /* Relative */) { return relativePath; } - var baseDirectory = ts.getPathsBasePath(compilerOptions, host) || baseUrl; + var baseDirectory = ts.getNormalizedAbsolutePath(ts.getPathsBasePath(compilerOptions, host) || baseUrl, host.getCurrentDirectory()); var relativeToBaseUrl = getRelativePathIfInDirectory(moduleFileName, baseDirectory, getCanonicalFileName); if (!relativeToBaseUrl) { return relativePath; @@ -111127,7 +114923,9 @@ var ts; return nonRelative; } if (relativePreference === 3 /* ExternalNonRelative */) { - var projectDirectory = host.getCurrentDirectory(); + var projectDirectory = compilerOptions.configFilePath ? + ts.toPath(ts.getDirectoryPath(compilerOptions.configFilePath), host.getCurrentDirectory(), info.getCanonicalFileName) : + info.getCanonicalFileName(host.getCurrentDirectory()); var modulePath = ts.toPath(moduleFileName, projectDirectory, getCanonicalFileName); var sourceIsInternal = ts.startsWith(sourceDirectory, projectDirectory); var targetIsInternal = ts.startsWith(modulePath, projectDirectory); @@ -111179,12 +114977,8 @@ var ts; return ts.pathIsRelative(text) ? ts.hasJSFileExtension(text) : undefined; }) || false; } - function numberOfDirectorySeparators(str) { - var match = str.match(/\//g); - return match ? match.length : 0; - } function comparePathsByRedirectAndNumberOfDirectorySeparators(a, b) { - return ts.compareBooleans(b.isRedirect, a.isRedirect) || ts.compareValues(numberOfDirectorySeparators(a.path), numberOfDirectorySeparators(b.path)); + return ts.compareBooleans(b.isRedirect, a.isRedirect) || ts.compareNumberOfDirectorySeparators(a.path, b.path); } function getNearestAncestorDirectoryWithPackageJson(host, fileName) { if (host.getNearestAncestorDirectoryWithPackageJson) { @@ -111198,40 +114992,49 @@ var ts; var getCanonicalFileName = ts.hostGetCanonicalFileName(host); var cwd = host.getCurrentDirectory(); var referenceRedirect = host.isSourceOfProjectReferenceRedirect(importedFileName) ? host.getProjectReferenceRedirect(importedFileName) : undefined; - var redirects = host.redirectTargetsMap.get(ts.toPath(importedFileName, cwd, getCanonicalFileName)) || ts.emptyArray; + var importedPath = ts.toPath(importedFileName, cwd, getCanonicalFileName); + var redirects = host.redirectTargetsMap.get(importedPath) || ts.emptyArray; var importedFileNames = __spreadArray(__spreadArray(__spreadArray([], (referenceRedirect ? [referenceRedirect] : ts.emptyArray)), [importedFileName]), redirects); var targets = importedFileNames.map(function (f) { return ts.getNormalizedAbsolutePath(f, cwd); }); + var shouldFilterIgnoredPaths = !ts.every(targets, ts.containsIgnoredPath); if (!preferSymlinks) { - var result_15 = ts.forEach(targets, function (p) { return cb(p, referenceRedirect === p); }); + // Symlinks inside ignored paths are already filtered out of the symlink cache, + // so we only need to remove them from the realpath filenames. + var result_15 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); }); if (result_15) return result_15; } var links = host.getSymlinkCache ? host.getSymlinkCache() : ts.discoverProbableSymlinks(host.getSourceFiles(), getCanonicalFileName, cwd); - var symlinkedDirectories = links.getSymlinkedDirectories(); - var useCaseSensitiveFileNames = !host.useCaseSensitiveFileNames || host.useCaseSensitiveFileNames(); - var result = symlinkedDirectories && ts.forEachEntry(symlinkedDirectories, function (resolved, path) { - if (resolved === false) - return undefined; - if (ts.startsWithDirectory(importingFileName, resolved.realPath, getCanonicalFileName)) { - return undefined; // Don't want to a package to globally import from itself + var symlinkedDirectories = links.getSymlinkedDirectoriesByRealpath(); + var fullImportedFileName = ts.getNormalizedAbsolutePath(importedFileName, cwd); + var result = symlinkedDirectories && ts.forEachAncestorDirectory(ts.getDirectoryPath(fullImportedFileName), function (realPathDirectory) { + var symlinkDirectories = symlinkedDirectories.get(ts.ensureTrailingDirectorySeparator(ts.toPath(realPathDirectory, cwd, getCanonicalFileName))); + if (!symlinkDirectories) + return undefined; // Continue to ancestor directory + // Don't want to a package to globally import from itself (importNameCodeFix_symlink_own_package.ts) + if (ts.startsWithDirectory(importingFileName, realPathDirectory, getCanonicalFileName)) { + return false; // Stop search, each ancestor directory will also hit this condition } return ts.forEach(targets, function (target) { - if (!ts.containsPath(resolved.real, target, !useCaseSensitiveFileNames)) { + if (!ts.startsWithDirectory(target, realPathDirectory, getCanonicalFileName)) { return; } - var relative = ts.getRelativePathFromDirectory(resolved.real, target, getCanonicalFileName); - var option = ts.resolvePath(path, relative); - if (!host.fileExists || host.fileExists(option)) { + var relative = ts.getRelativePathFromDirectory(realPathDirectory, target, getCanonicalFileName); + for (var _i = 0, symlinkDirectories_1 = symlinkDirectories; _i < symlinkDirectories_1.length; _i++) { + var symlinkDirectory = symlinkDirectories_1[_i]; + var option = ts.resolvePath(symlinkDirectory, relative); var result_16 = cb(option, target === referenceRedirect); + shouldFilterIgnoredPaths = true; // We found a non-ignored path in symlinks, so we can reject ignored-path realpaths if (result_16) return result_16; } }); }); - return result || - (preferSymlinks ? ts.forEach(targets, function (p) { return cb(p, p === referenceRedirect); }) : undefined); + return result || (preferSymlinks + ? ts.forEach(targets, function (p) { return shouldFilterIgnoredPaths && ts.containsIgnoredPath(p) ? undefined : cb(p, p === referenceRedirect); }) + : undefined); } moduleSpecifiers.forEachFileNameOfModule = forEachFileNameOfModule; /** @@ -111239,8 +115042,14 @@ var ts; * Symlinks will be returned first so they are preferred over the real path. */ function getAllModulePaths(importingFileName, importedFileName, host) { - var cwd = host.getCurrentDirectory(); + var _a; + var cache = (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host); var getCanonicalFileName = ts.hostGetCanonicalFileName(host); + if (cache) { + var cached = cache.get(importingFileName, ts.toPath(importedFileName, host.getCurrentDirectory(), getCanonicalFileName)); + if (typeof cached === "object") + return cached; + } var allFileNames = new ts.Map(); var importedFileFromNodeModules = false; forEachFileNameOfModule(importingFileName, importedFileName, host, @@ -111252,7 +115061,7 @@ var ts; }); // Sort by paths closest to importing file Name directory var sortedPaths = []; - var _loop_24 = function (directory) { + var _loop_26 = function (directory) { var directoryStart = ts.ensureTrailingDirectorySeparator(directory); var pathsInDirectory; allFileNames.forEach(function (_a, fileName) { @@ -111275,10 +115084,10 @@ var ts; out_directory_1 = directory; }; var out_directory_1; - for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0;) { - var state_7 = _loop_24(directory); + for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) { + var state_9 = _loop_26(directory); directory = out_directory_1; - if (state_7 === "break") + if (state_9 === "break") break; } if (allFileNames.size) { @@ -111287,10 +115096,14 @@ var ts; remainingPaths.sort(comparePathsByRedirectAndNumberOfDirectorySeparators); sortedPaths.push.apply(sortedPaths, remainingPaths); } + if (cache) { + cache.set(importingFileName, ts.toPath(importedFileName, host.getCurrentDirectory(), getCanonicalFileName), sortedPaths); + } return sortedPaths; } function tryGetModuleNameFromAmbientModule(moduleSymbol, checker) { - var decl = ts.find(moduleSymbol.declarations, function (d) { return ts.isNonGlobalAmbientModule(d) && (!ts.isExternalModuleAugmentation(d) || !ts.isExternalModuleNameRelative(ts.getTextOfIdentifierOrLiteral(d.name))); }); + var _a; + var decl = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.isNonGlobalAmbientModule(d) && (!ts.isExternalModuleAugmentation(d) || !ts.isExternalModuleNameRelative(ts.getTextOfIdentifierOrLiteral(d.name))); }); if (decl) { return decl.name.text; } @@ -111346,7 +115159,7 @@ var ts; ts.startsWith(relativeToBaseUrl, prefix) && ts.endsWith(relativeToBaseUrl, suffix) || !suffix && relativeToBaseUrl === ts.removeTrailingDirectorySeparator(prefix)) { - var matchedStar = relativeToBaseUrl.substr(prefix.length, relativeToBaseUrl.length - suffix.length); + var matchedStar = relativeToBaseUrl.substr(prefix.length, relativeToBaseUrl.length - suffix.length - prefix.length); return key.replace("*", matchedStar); } } @@ -111650,10 +115463,10 @@ var ts; } ts.createWatchStatusReporter = createWatchStatusReporter; /** Parses config file using System interface */ - function parseConfigFileWithSystem(configFileName, optionsToExtend, watchOptionsToExtend, system, reportDiagnostic) { + function parseConfigFileWithSystem(configFileName, optionsToExtend, extendedConfigCache, watchOptionsToExtend, system, reportDiagnostic) { var host = system; host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(system, reportDiagnostic, diagnostic); }; - var result = ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtend, host, /*extendedConfigCache*/ undefined, watchOptionsToExtend); + var result = ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtend, host, extendedConfigCache, watchOptionsToExtend); host.onUnRecoverableConfigFileDiagnostic = undefined; // TODO: GH#18217 return result; } @@ -111921,7 +115734,10 @@ var ts; MissingFile: "Missing file", WildcardDirectory: "Wild card directory", FailedLookupLocations: "Failed Lookup Locations", - TypeRoots: "Type roots" + TypeRoots: "Type roots", + ConfigFileOfReferencedProject: "Config file of referened project", + ExtendedConfigOfReferencedProject: "Extended config file of referenced project", + WildcardDirectoryOfReferencedProject: "Wild card directory of referenced project", }; function createWatchFactory(host, options) { var watchLogLevel = host.trace ? options.extendedDiagnostics ? ts.WatchLogLevel.Verbose : options.diagnostics ? ts.WatchLogLevel.TriggerOnly : ts.WatchLogLevel.None : ts.WatchLogLevel.None; @@ -111968,6 +115784,7 @@ var ts; getEnvironmentVariable: ts.maybeBind(host, host.getEnvironmentVariable) || (function () { return ""; }), createHash: ts.maybeBind(host, host.createHash), readDirectory: ts.maybeBind(host, host.readDirectory), + disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature, }; function writeFile(fileName, text, writeByteOrderMark, onError) { try { @@ -112025,7 +115842,8 @@ var ts; createDirectory: function (path) { return system.createDirectory(path); }, writeFile: function (path, data, writeByteOrderMark) { return system.writeFile(path, data, writeByteOrderMark); }, createHash: ts.maybeBind(system, system.createHash), - createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram + createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram, + disableUseFileVersionAsSignature: system.disableUseFileVersionAsSignature, }; } ts.createProgramHost = createProgramHost; @@ -112113,6 +115931,7 @@ var ts; if (system === void 0) { system = ts.sys; } var host = ts.createCompilerHostWorker(options, /*setParentNodes*/ undefined, system); host.createHash = ts.maybeBind(system, system.createHash); + host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature; ts.setGetSourceFileAsHashVersioned(host, system); ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); }); return host; @@ -112156,11 +115975,13 @@ var ts; function createWatchProgram(host) { var builderProgram; var reloadLevel; // level to indicate if the program needs to be reloaded from config file/just filenames etc - var extendedConfigFilesMap; // Map of file watchers for the extended config files var missingFilesMap; // Map of file watchers for the missing files var watchedWildcardDirectories; // map of watchers for the wild card directories in the config file var timerToUpdateProgram; // timer callback to recompile the program var timerToInvalidateFailedLookupResolutions; // timer callback to invalidate resolutions for changes in failed lookup locations + 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 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 var hasChangedCompilerOptions = false; // True if the compiler options have changed between compilations @@ -112210,6 +116031,7 @@ var ts; compilerHost.getNewLine = function () { return newLine; }; compilerHost.fileExists = fileExists; compilerHost.onReleaseOldSourceFile = onReleaseOldSourceFile; + compilerHost.onReleaseParsedCommandLine = onReleaseParsedCommandLine; // Members for ResolutionCacheHost compilerHost.toPath = toPath; compilerHost.getCompilationSettings = function () { return compilerOptions; }; @@ -112223,6 +116045,7 @@ var ts; compilerHost.fileIsOpen = ts.returnFalse; compilerHost.getCurrentProgram = getCurrentProgram; compilerHost.writeLog = writeLog; + compilerHost.getParsedCommandLine = getParsedCommandLine; // Cache for the module resolution var resolutionCache = ts.createResolutionCache(compilerHost, configFileName ? ts.getDirectoryPath(ts.getNormalizedAbsolutePath(configFileName, currentDirectory)) : @@ -112253,7 +116076,8 @@ var ts; // Update the wild card directory watch watchConfigFileWildCardDirectories(); // Update extended config file watch - watchExtendedConfigFiles(); + if (configFileName) + updateExtendedConfigFilesWatches(toPath(configFileName), compilerOptions, watchOptions, ts.WatchType.ExtendedConfigFile); return configFileName ? { getCurrentProgram: getCurrentBuilderProgram, getProgram: updateProgram, close: close } : { getCurrentProgram: getCurrentBuilderProgram, getProgram: updateProgram, updateRootFileNames: updateRootFileNames, close: close }; @@ -112270,9 +116094,11 @@ var ts; configFileWatcher.close(); configFileWatcher = undefined; } - if (extendedConfigFilesMap) { - ts.clearMap(extendedConfigFilesMap, ts.closeFileWatcher); - extendedConfigFilesMap = undefined; + extendedConfigCache === null || extendedConfigCache === void 0 ? void 0 : extendedConfigCache.clear(); + extendedConfigCache = undefined; + if (sharedExtendedConfigFileWatchers) { + ts.clearMap(sharedExtendedConfigFileWatchers, ts.closeFileWatcherOf); + sharedExtendedConfigFileWatchers = undefined; } if (watchedWildcardDirectories) { ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcherOf); @@ -112282,6 +116108,17 @@ var ts; ts.clearMap(missingFilesMap, ts.closeFileWatcher); missingFilesMap = undefined; } + if (parsedConfigs) { + ts.clearMap(parsedConfigs, function (config) { + var _a; + (_a = config.watcher) === null || _a === void 0 ? void 0 : _a.close(); + config.watcher = undefined; + if (config.watchedDirectories) + ts.clearMap(config.watchedDirectories, ts.closeFileWatcherOf); + config.watchedDirectories = undefined; + }); + parsedConfigs = undefined; + } } function getCurrentBuilderProgram() { return builderProgram; @@ -112301,7 +116138,7 @@ var ts; } // All resolutions are invalid if user provided resolutions var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution); - if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, projectReferences)) { + if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) { if (hasChangedConfigFileParsingErrors) { builderProgram = createProgram(/*rootNames*/ undefined, /*options*/ undefined, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences); hasChangedConfigFileParsingErrors = false; @@ -112320,6 +116157,8 @@ var ts; writeLog("CreatingProgramWith::"); writeLog(" roots: " + JSON.stringify(rootFileNames)); writeLog(" options: " + JSON.stringify(compilerOptions)); + if (projectReferences) + writeLog(" projectReferences: " + JSON.stringify(projectReferences)); var needsUpdateInTypeRootWatch = hasChangedCompilerOptions || !getCurrentProgram(); hasChangedCompilerOptions = false; hasChangedConfigFileParsingErrors = false; @@ -112542,10 +116381,10 @@ var ts; // Update the wild card directory watch watchConfigFileWildCardDirectories(); // Update extended config file watch - watchExtendedConfigFiles(); + updateExtendedConfigFilesWatches(toPath(configFileName), compilerOptions, watchOptions, ts.WatchType.ExtendedConfigFile); } function parseConfigFile() { - setConfigFileParsingResult(ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtendForConfigFile, parseConfigFileHost, /*extendedConfigCache*/ undefined, watchOptionsToExtend, extraFileExtensions)); // TODO: GH#18217 + setConfigFileParsingResult(ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtendForConfigFile, parseConfigFileHost, extendedConfigCache || (extendedConfigCache = new ts.Map()), watchOptionsToExtend, extraFileExtensions)); // TODO: GH#18217 } function setConfigFileParsingResult(configFileParseResult) { rootFileNames = configFileParseResult.fileNames; @@ -112557,6 +116396,56 @@ var ts; canConfigFileJsonReportNoInputFiles = ts.canJsonReportNoInputFiles(configFileParseResult.raw); hasChangedConfigFileParsingErrors = true; } + function getParsedCommandLine(configFileName) { + var configPath = toPath(configFileName); + var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(configPath); + if (config) { + if (!config.reloadLevel) + return config.parsedCommandLine; + // With host implementing getParsedCommandLine we cant just update file names + if (config.parsedCommandLine && config.reloadLevel === ts.ConfigFileProgramReloadLevel.Partial && !host.getParsedCommandLine) { + writeLog("Reloading new file names and options"); + var fileNames = ts.getFileNamesFromConfigSpecs(config.parsedCommandLine.options.configFile.configFileSpecs, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), compilerOptions, parseConfigFileHost); + config.parsedCommandLine = __assign(__assign({}, config.parsedCommandLine), { fileNames: fileNames }); + config.reloadLevel = undefined; + return config.parsedCommandLine; + } + } + writeLog("Loading config file: " + configFileName); + var parsedCommandLine = host.getParsedCommandLine ? + host.getParsedCommandLine(configFileName) : + getParsedCommandLineFromConfigFileHost(configFileName); + if (config) { + config.parsedCommandLine = parsedCommandLine; + config.reloadLevel = undefined; + } + else { + (parsedConfigs || (parsedConfigs = new ts.Map())).set(configPath, config = { parsedCommandLine: parsedCommandLine }); + } + watchReferencedProject(configFileName, configPath, config); + return parsedCommandLine; + } + function getParsedCommandLineFromConfigFileHost(configFileName) { + // Ignore the file absent errors + var onUnRecoverableConfigFileDiagnostic = parseConfigFileHost.onUnRecoverableConfigFileDiagnostic; + parseConfigFileHost.onUnRecoverableConfigFileDiagnostic = ts.noop; + var parsedCommandLine = ts.getParsedCommandLineOfConfigFile(configFileName, + /*optionsToExtend*/ undefined, parseConfigFileHost, extendedConfigCache || (extendedConfigCache = new ts.Map()), watchOptionsToExtend); + parseConfigFileHost.onUnRecoverableConfigFileDiagnostic = onUnRecoverableConfigFileDiagnostic; + return parsedCommandLine; + } + function onReleaseParsedCommandLine(fileName) { + var _a; + var path = toPath(fileName); + var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(path); + if (!config) + return; + parsedConfigs.delete(path); + if (config.watchedDirectories) + ts.clearMap(config.watchedDirectories, ts.closeFileWatcherOf); + (_a = config.watcher) === null || _a === void 0 ? void 0 : _a.close(); + ts.clearSharedExtendedConfigFileWatcher(path, sharedExtendedConfigFileWatchers); + } function watchFilePath(path, file, callback, pollingInterval, options, watchType) { return watchFile(file, function (fileName, eventKind) { return callback(fileName, eventKind, path); }, pollingInterval, options, watchType); } @@ -112566,7 +116455,6 @@ var ts; if (eventKind === ts.FileWatcherEventKind.Deleted && sourceFilesCache.has(path)) { resolutionCache.invalidateResolutionOfFile(path); } - resolutionCache.removeResolutionsFromProjectReferenceRedirects(path); nextSourceFileVersion(path); // Update the program scheduleProgramUpdate(); @@ -112577,7 +116465,10 @@ var ts; } } function watchMissingFilePath(missingFilePath) { - return watchFilePath(missingFilePath, missingFilePath, onMissingFileChange, ts.PollingInterval.Medium, watchOptions, ts.WatchType.MissingFile); + // If watching missing referenced config file, we are already watching it so no need for separate watcher + return (parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.has(missingFilePath)) ? + ts.noopFileWatcher : + watchFilePath(missingFilePath, missingFilePath, onMissingFileChange, ts.PollingInterval.Medium, watchOptions, ts.WatchType.MissingFile); } function onMissingFileChange(fileName, eventKind, missingFilePath) { updateCachedSystemWithFile(fileName, missingFilePath, eventKind); @@ -112614,10 +116505,11 @@ var ts; configFileName: configFileName, extraFileExtensions: extraFileExtensions, options: compilerOptions, - program: getCurrentBuilderProgram(), + program: getCurrentBuilderProgram() || rootFileNames, currentDirectory: currentDirectory, useCaseSensitiveFileNames: useCaseSensitiveFileNames, - writeLog: writeLog + writeLog: writeLog, + toPath: toPath, })) return; // Reload is pending, do the reload @@ -112628,18 +116520,87 @@ var ts; } }, flags, watchOptions, ts.WatchType.WildcardDirectory); } - function watchExtendedConfigFiles() { - var _a; - // Update the extended config files watcher - ts.mutateMap(extendedConfigFilesMap || (extendedConfigFilesMap = new ts.Map()), ts.arrayToMap(((_a = compilerOptions.configFile) === null || _a === void 0 ? void 0 : _a.extendedSourceFiles) || ts.emptyArray, toPath), { - // Watch the extended config files - createNewValue: watchExtendedConfigFile, - // Config files that are no longer extended should no longer be watched. - onDeleteValue: ts.closeFileWatcher - }); - } - function watchExtendedConfigFile(extendedConfigFile) { - return watchFile(extendedConfigFile, scheduleProgramReload, ts.PollingInterval.High, watchOptions, ts.WatchType.ExtendedConfigFile); + function updateExtendedConfigFilesWatches(forProjectPath, options, watchOptions, watchType) { + ts.updateSharedExtendedConfigFileWatcher(forProjectPath, options, sharedExtendedConfigFileWatchers || (sharedExtendedConfigFileWatchers = new ts.Map()), function (extendedConfigFileName, extendedConfigFilePath) { return watchFile(extendedConfigFileName, function (_fileName, eventKind) { + var _a; + updateCachedSystemWithFile(extendedConfigFileName, extendedConfigFilePath, eventKind); + // Update extended config cache + if (extendedConfigCache) + ts.cleanExtendedConfigCache(extendedConfigCache, extendedConfigFilePath, toPath); + // Update projects + var projects = (_a = sharedExtendedConfigFileWatchers.get(extendedConfigFilePath)) === null || _a === void 0 ? void 0 : _a.projects; + // If there are no referenced projects this extended config file watcher depend on ignore + if (!(projects === null || projects === void 0 ? void 0 : projects.size)) + return; + projects.forEach(function (projectPath) { + if (toPath(configFileName) === projectPath) { + // If this is the config file of the project, reload completely + reloadLevel = ts.ConfigFileProgramReloadLevel.Full; + } + else { + // Reload config for the referenced projects and remove the resolutions from referenced projects since the config file changed + var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(projectPath); + if (config) + config.reloadLevel = ts.ConfigFileProgramReloadLevel.Full; + resolutionCache.removeResolutionsFromProjectReferenceRedirects(projectPath); + } + scheduleProgramUpdate(); + }); + }, ts.PollingInterval.High, watchOptions, watchType); }, toPath); + } + function watchReferencedProject(configFileName, configPath, commandLine) { + var _a, _b, _c, _d, _e; + // Watch file + commandLine.watcher || (commandLine.watcher = watchFile(configFileName, function (_fileName, eventKind) { + updateCachedSystemWithFile(configFileName, configPath, eventKind); + var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(configPath); + if (config) + config.reloadLevel = ts.ConfigFileProgramReloadLevel.Full; + resolutionCache.removeResolutionsFromProjectReferenceRedirects(configPath); + scheduleProgramUpdate(); + }, ts.PollingInterval.High, ((_a = commandLine.parsedCommandLine) === null || _a === void 0 ? void 0 : _a.watchOptions) || watchOptions, ts.WatchType.ConfigFileOfReferencedProject)); + // Watch Wild card + if ((_b = commandLine.parsedCommandLine) === null || _b === void 0 ? void 0 : _b.wildcardDirectories) { + ts.updateWatchingWildcardDirectories(commandLine.watchedDirectories || (commandLine.watchedDirectories = new ts.Map()), new ts.Map(ts.getEntries((_c = commandLine.parsedCommandLine) === null || _c === void 0 ? void 0 : _c.wildcardDirectories)), function (directory, flags) { + var _a; + return watchDirectory(directory, function (fileOrDirectory) { + var fileOrDirectoryPath = toPath(fileOrDirectory); + // Since the file existence changed, update the sourceFiles cache + if (cachedDirectoryStructureHost) { + cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); + } + nextSourceFileVersion(fileOrDirectoryPath); + var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(configPath); + if (!(config === null || config === void 0 ? void 0 : config.parsedCommandLine)) + return; + if (ts.isIgnoredFileFromWildCardWatching({ + watchedDirPath: toPath(directory), + fileOrDirectory: fileOrDirectory, + fileOrDirectoryPath: fileOrDirectoryPath, + configFileName: configFileName, + options: config.parsedCommandLine.options, + program: config.parsedCommandLine.fileNames, + currentDirectory: currentDirectory, + useCaseSensitiveFileNames: useCaseSensitiveFileNames, + writeLog: writeLog, + toPath: toPath, + })) + return; + // Reload is pending, do the reload + if (config.reloadLevel !== ts.ConfigFileProgramReloadLevel.Full) { + config.reloadLevel = ts.ConfigFileProgramReloadLevel.Partial; + // Schedule Update the program + scheduleProgramUpdate(); + } + }, flags, ((_a = commandLine.parsedCommandLine) === null || _a === void 0 ? void 0 : _a.watchOptions) || watchOptions, ts.WatchType.WildcardDirectoryOfReferencedProject); + }); + } + else if (commandLine.watchedDirectories) { + ts.clearMap(commandLine.watchedDirectories, ts.closeFileWatcherOf); + commandLine.watchedDirectories = undefined; + } + // Watch extended config files + updateExtendedConfigFilesWatches(configPath, (_d = commandLine.parsedCommandLine) === null || _d === void 0 ? void 0 : _d.options, ((_e = commandLine.parsedCommandLine) === null || _e === void 0 ? void 0 : _e.watchOptions) || watchOptions, ts.WatchType.ExtendedConfigOfReferencedProject); } } ts.createWatchProgram = createWatchProgram; @@ -112799,12 +116760,19 @@ var ts; compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames); compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives); 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) { var loader_3 = function (moduleName, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference).resolvedModule; }; compilerHost.resolveModuleNames = function (moduleNames, containingFile, _reusedNames, redirectedReference) { return ts.loadWithLocalCache(ts.Debug.checkEachDefined(moduleNames), containingFile, redirectedReference, loader_3); }; } + if (!compilerHost.resolveTypeReferenceDirectives) { + var loader_4 = function (moduleName, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache).resolvedTypeReferenceDirective; }; + compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { + return ts.loadWithLocalCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, loader_4); + }; + } var _a = ts.createWatchFactory(hostWithWatch, options), watchFile = _a.watchFile, watchDirectory = _a.watchDirectory, writeLog = _a.writeLog; var state = { host: host, @@ -112829,6 +116797,7 @@ var ts; projectErrorsReported: new ts.Map(), compilerHost: compilerHost, moduleResolutionCache: moduleResolutionCache, + typeReferenceDirectiveResolutionCache: typeReferenceDirectiveResolutionCache, // Mutable state buildOrder: undefined, readFileWithCache: function (f) { return host.readFile(f); }, @@ -112867,6 +116836,10 @@ var ts; function isParsedCommandLine(entry) { return !!entry.options; } + function getCachedParsedConfigFile(state, configFilePath) { + var value = state.configFileCache.get(configFilePath); + return value && isParsedCommandLine(value) ? value : undefined; + } function parseConfigFile(state, configFileName, configFilePath) { var configFileCache = state.configFileCache; var value = configFileCache.get(configFilePath); @@ -113012,7 +116985,7 @@ var ts; function disableCache(state) { if (!state.cache) return; - var cache = state.cache, host = state.host, compilerHost = state.compilerHost, extendedConfigCache = state.extendedConfigCache, moduleResolutionCache = state.moduleResolutionCache; + var cache = state.cache, host = state.host, compilerHost = state.compilerHost, extendedConfigCache = state.extendedConfigCache, moduleResolutionCache = state.moduleResolutionCache, typeReferenceDirectiveResolutionCache = state.typeReferenceDirectiveResolutionCache; host.readFile = cache.originalReadFile; host.fileExists = cache.originalFileExists; host.directoryExists = cache.originalDirectoryExists; @@ -113021,10 +116994,8 @@ var ts; compilerHost.getSourceFile = cache.originalGetSourceFile; state.readFileWithCache = cache.originalReadFileWithCache; extendedConfigCache.clear(); - if (moduleResolutionCache) { - moduleResolutionCache.directoryToModuleNameMap.clear(); - moduleResolutionCache.moduleNameToDirectoryMap.clear(); - } + moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.clear(); + typeReferenceDirectiveResolutionCache === null || typeReferenceDirectiveResolutionCache === void 0 ? void 0 : typeReferenceDirectiveResolutionCache.clear(); state.cache = undefined; } function clearProjectStatus(state, resolved) { @@ -113191,6 +117162,7 @@ var ts; return withProgramOrUndefined(action) || ts.emptyArray; } function createProgram() { + var _a, _b; ts.Debug.assert(program === undefined); if (state.options.dry) { reportStatus(state, ts.Diagnostics.A_non_dry_build_would_build_project_0, project); @@ -113210,7 +117182,8 @@ var ts; var host = state.host, compilerHost = state.compilerHost; state.projectCompilerOptions = config.options; // Update module resolution cache if needed - updateModuleResolutionCache(state, project, config); + (_a = state.moduleResolutionCache) === null || _a === void 0 ? void 0 : _a.update(config.options); + (_b = state.typeReferenceDirectiveResolutionCache) === null || _b === void 0 ? void 0 : _b.update(config.options); // Create program program = host.createProgram(config.fileNames, config.options, compilerHost, getOldProgram(state, projectPath, config), ts.getConfigFileParsingDiagnostics(config), config.projectReferences); if (state.watch) { @@ -113385,7 +117358,7 @@ var ts; emitBundle(writeFile, customTransformers); break; case BuildStep.BuildInvalidatedProjectOfBundle: - ts.Debug.checkDefined(invalidatedProjectOfBundle).done(cancellationToken); + ts.Debug.checkDefined(invalidatedProjectOfBundle).done(cancellationToken, writeFile, customTransformers); step = BuildStep.Done; break; case BuildStep.QueueReferencingProjects: @@ -113527,34 +117500,9 @@ var ts; afterProgramDone(state, program, config); return { buildResult: buildResult, step: BuildStep.QueueReferencingProjects }; } - function updateModuleResolutionCache(state, proj, config) { - if (!state.moduleResolutionCache) - return; - // Update module resolution cache if needed - var moduleResolutionCache = state.moduleResolutionCache; - var projPath = toPath(state, proj); - if (moduleResolutionCache.directoryToModuleNameMap.redirectsMap.size === 0) { - // The own map will be for projectCompilerOptions - ts.Debug.assert(moduleResolutionCache.moduleNameToDirectoryMap.redirectsMap.size === 0); - moduleResolutionCache.directoryToModuleNameMap.redirectsMap.set(projPath, moduleResolutionCache.directoryToModuleNameMap.ownMap); - moduleResolutionCache.moduleNameToDirectoryMap.redirectsMap.set(projPath, moduleResolutionCache.moduleNameToDirectoryMap.ownMap); - } - else { - // Set correct own map - ts.Debug.assert(moduleResolutionCache.moduleNameToDirectoryMap.redirectsMap.size > 0); - var ref = { - sourceFile: config.options.configFile, - commandLine: config - }; - moduleResolutionCache.directoryToModuleNameMap.setOwnMap(moduleResolutionCache.directoryToModuleNameMap.getOrCreateMapOfCacheRedirects(ref)); - moduleResolutionCache.moduleNameToDirectoryMap.setOwnMap(moduleResolutionCache.moduleNameToDirectoryMap.getOrCreateMapOfCacheRedirects(ref)); - } - moduleResolutionCache.directoryToModuleNameMap.setOwnOptions(config.options); - moduleResolutionCache.moduleNameToDirectoryMap.setOwnOptions(config.options); - } function checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName) { // Check tsconfig time - var tsconfigTime = state.host.getModifiedTime(configFile) || ts.missingFileModifiedTime; + var tsconfigTime = ts.getModifiedTime(state.host, configFile); if (oldestOutputFileTime < tsconfigTime) { return { type: ts.UpToDateStatusType.OutOfDateWithSelf, @@ -113564,6 +117512,7 @@ var ts; } } function getUpToDateStatusWorker(state, project, resolvedPath) { + var force = !!state.options.force; var newestInputFileName = undefined; var newestInputFileTime = minimumDate; var host = state.host; @@ -113576,10 +117525,13 @@ var ts; reason: inputFile + " does not exist" }; } - var inputTime = host.getModifiedTime(inputFile) || ts.missingFileModifiedTime; - if (inputTime > newestInputFileTime) { - newestInputFileName = inputFile; - newestInputFileTime = inputTime; + if (!force) { + var inputTime = ts.getModifiedTime(host, inputFile); + host.getModifiedTime(inputFile); + if (inputTime > newestInputFileTime) { + newestInputFileName = inputFile; + newestInputFileTime = inputTime; + } } } // Container if no files are specified in the project @@ -113598,36 +117550,38 @@ var ts; var missingOutputFileName; var newestDeclarationFileContentChangedTime = minimumDate; var isOutOfDateWithInputs = false; - for (var _b = 0, outputs_1 = outputs; _b < outputs_1.length; _b++) { - var output = outputs_1[_b]; - // Output is missing; can stop checking - // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status - if (!host.fileExists(output)) { - missingOutputFileName = output; - break; - } - var outputTime = host.getModifiedTime(output) || ts.missingFileModifiedTime; - if (outputTime < oldestOutputFileTime) { - oldestOutputFileTime = outputTime; - oldestOutputFileName = output; - } - // If an output is older than the newest input, we can stop checking - // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status - if (outputTime < newestInputFileTime) { - isOutOfDateWithInputs = true; - break; - } - if (outputTime > newestOutputFileTime) { - newestOutputFileTime = outputTime; - newestOutputFileName = output; - } - // Keep track of when the most recent time a .d.ts file was changed. - // In addition to file timestamps, we also keep track of when a .d.ts file - // had its file touched but not had its contents changed - this allows us - // to skip a downstream typecheck - if (isDeclarationFile(output)) { - var outputModifiedTime = host.getModifiedTime(output) || ts.missingFileModifiedTime; - newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime); + if (!force) { + for (var _b = 0, outputs_1 = outputs; _b < outputs_1.length; _b++) { + var output = outputs_1[_b]; + // Output is missing; can stop checking + // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status + if (!host.fileExists(output)) { + missingOutputFileName = output; + break; + } + var outputTime = ts.getModifiedTime(host, output); + if (outputTime < oldestOutputFileTime) { + oldestOutputFileTime = outputTime; + oldestOutputFileName = output; + } + // If an output is older than the newest input, we can stop checking + // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status + if (outputTime < newestInputFileTime) { + isOutOfDateWithInputs = true; + break; + } + if (outputTime > newestOutputFileTime) { + newestOutputFileTime = outputTime; + newestOutputFileName = output; + } + // Keep track of when the most recent time a .d.ts file was changed. + // In addition to file timestamps, we also keep track of when a .d.ts file + // had its file touched but not had its contents changed - this allows us + // to skip a downstream typecheck + if (isDeclarationFile(output)) { + var outputModifiedTime = ts.getModifiedTime(host, output); + newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime); + } } } var pseudoUpToDate = false; @@ -113663,7 +117617,8 @@ var ts; }; } // Check oldest output file name only if there is no missing output file name - if (!missingOutputFileName) { + // (a check we will have skipped if this is a forced build) + if (!force && !missingOutputFileName) { // If the upstream project's newest file is older than our oldest output, we // can't be out of date because of it if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) { @@ -113709,7 +117664,7 @@ var ts; if (extendedConfigStatus) return extendedConfigStatus; } - if (!state.buildInfoChecked.has(resolvedPath)) { + if (!force && !state.buildInfoChecked.has(resolvedPath)) { state.buildInfoChecked.set(resolvedPath, true); var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options); if (buildInfoPath) { @@ -113754,6 +117709,8 @@ var ts; return actual; } function updateOutputTimestampsWorker(state, proj, priorNewestUpdateTime, verboseMessage, skipOutputs) { + if (proj.options.noEmit) + return priorNewestUpdateTime; var host = state.host; var outputs = ts.getAllProjectOutputs(proj, !host.useCaseSensitiveFileNames()); if (!skipOutputs || outputs.length !== skipOutputs.size) { @@ -113769,7 +117726,7 @@ var ts; reportStatus(state, verboseMessage, proj.options.configFilePath); } if (isDeclarationFile(file)) { - priorNewestUpdateTime = newer(priorNewestUpdateTime, host.getModifiedTime(file) || ts.missingFileModifiedTime); + priorNewestUpdateTime = newer(priorNewestUpdateTime, ts.getModifiedTime(host, file)); } host.setModifiedTime(file, now); } @@ -113851,7 +117808,7 @@ var ts; } } } - function build(state, project, cancellationToken, onlyReferences) { + function build(state, project, cancellationToken, writeFile, getCustomTransformers, onlyReferences) { var buildOrder = getBuildOrderFor(state, project, onlyReferences); if (!buildOrder) return ts.ExitStatus.InvalidProject_OutputsSkipped; @@ -113863,7 +117820,7 @@ var ts; if (!invalidatedProject) break; reportQueue = false; - invalidatedProject.done(cancellationToken); + invalidatedProject.done(cancellationToken, writeFile, getCustomTransformers === null || getCustomTransformers === void 0 ? void 0 : getCustomTransformers(invalidatedProject.project)); if (!state.diagnostics.has(invalidatedProject.projectPath)) successfulProjects++; } @@ -113898,8 +117855,14 @@ var ts; continue; } var outputs = ts.getAllProjectOutputs(parsed, !host.useCaseSensitiveFileNames()); + if (!outputs.length) + continue; + var inputFileNames = new ts.Set(parsed.fileNames.map(function (f) { return toPath(state, f); })); for (var _a = 0, outputs_3 = outputs; _a < outputs_3.length; _a++) { var output = outputs_3[_a]; + // If output name is same as input file name, do not delete and ignore the error + if (inputFileNames.has(toPath(state, output))) + continue; if (host.fileExists(output)) { if (filesToDelete) { filesToDelete.push(output); @@ -113975,7 +117938,7 @@ var ts; }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.ConfigFile, resolved)); } function watchExtendedConfigFiles(state, resolvedPath, parsed) { - ts.updateSharedExtendedConfigFileWatcher(resolvedPath, parsed, state.allWatchedExtendedConfigFiles, function (extendedConfigFileName, extendedConfigFilePath) { return state.watchFile(extendedConfigFileName, function () { + ts.updateSharedExtendedConfigFileWatcher(resolvedPath, parsed === null || parsed === void 0 ? void 0 : parsed.options, state.allWatchedExtendedConfigFiles, function (extendedConfigFileName, extendedConfigFilePath) { return state.watchFile(extendedConfigFileName, function () { var _a; return (_a = state.allWatchedExtendedConfigFiles.get(extendedConfigFilePath)) === null || _a === void 0 ? void 0 : _a.projects.forEach(function (projectConfigFilePath) { return invalidateProjectAndScheduleBuilds(state, projectConfigFilePath, ts.ConfigFileProgramReloadLevel.Full); @@ -113986,6 +117949,7 @@ var ts; if (!state.watch) return; ts.updateWatchingWildcardDirectories(getOrCreateValueMapFromConfigFileMap(state.allWatchedWildcardDirectories, resolvedPath), new ts.Map(ts.getEntries(parsed.wildcardDirectories)), function (dir, flags) { return state.watchDirectory(dir, function (fileOrDirectory) { + var _a; if (ts.isIgnoredFileFromWildCardWatching({ watchedDirPath: toPath(state, dir), fileOrDirectory: fileOrDirectory, @@ -113993,9 +117957,10 @@ var ts; configFileName: resolved, currentDirectory: state.currentDirectory, options: parsed.options, - program: state.builderPrograms.get(resolvedPath), + program: state.builderPrograms.get(resolvedPath) || ((_a = getCachedParsedConfigFile(state, resolvedPath)) === null || _a === void 0 ? void 0 : _a.fileNames), useCaseSensitiveFileNames: state.parseConfigFileHost.useCaseSensitiveFileNames, - writeLog: function (s) { return state.writeLog(s); } + writeLog: function (s) { return state.writeLog(s); }, + toPath: function (fileName) { return toPath(state, fileName); } })) return; invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.Partial); @@ -114030,19 +117995,16 @@ var ts; } function stopWatching(state) { ts.clearMap(state.allWatchedConfigFiles, ts.closeFileWatcher); - ts.clearMap(state.allWatchedExtendedConfigFiles, function (watcher) { - watcher.projects.clear(); - watcher.close(); - }); + ts.clearMap(state.allWatchedExtendedConfigFiles, ts.closeFileWatcherOf); ts.clearMap(state.allWatchedWildcardDirectories, function (watchedWildcardDirectories) { return ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcherOf); }); ts.clearMap(state.allWatchedInputFiles, function (watchedWildcardDirectories) { return ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcher); }); } function createSolutionBuilderWorker(watch, hostOrHostWithWatch, rootNames, options, baseWatchOptions) { var state = createSolutionBuilderState(watch, hostOrHostWithWatch, rootNames, options, baseWatchOptions); return { - build: function (project, cancellationToken) { return build(state, project, cancellationToken); }, + build: function (project, cancellationToken, writeFile, getCustomTransformers) { return build(state, project, cancellationToken, writeFile, getCustomTransformers); }, clean: function (project) { return clean(state, project); }, - buildReferences: function (project, cancellationToken) { return build(state, project, cancellationToken, /*onlyReferences*/ true); }, + buildReferences: function (project, cancellationToken, writeFile, getCustomTransformers) { return build(state, project, cancellationToken, writeFile, getCustomTransformers, /*onlyReferences*/ true); }, cleanReferences: function (project) { return clean(state, project, /*onlyReferences*/ true); }, getNextInvalidatedProject: function (cancellationToken) { setupInitialBuild(state, cancellationToken); @@ -114132,6 +118094,9 @@ var ts; } } function reportUpToDateStatus(state, configFileName, status) { + if (state.options.force && (status.type === ts.UpToDateStatusType.UpToDate || status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes)) { + return reportStatus(state, ts.Diagnostics.Project_0_is_being_forcibly_rebuilt, relName(state, configFileName)); + } switch (status.type) { case ts.UpToDateStatusType.OutOfDateWithSelf: return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, relName(state, configFileName), relName(state, status.outOfDateOutputFileName), relName(state, status.newerInputFileName)); diff --git a/lib/zh-cn/diagnosticMessages.generated.json b/lib/zh-cn/diagnosticMessages.generated.json index 4c9eb13c992e4..1fd2fa83bc187 100644 --- a/lib/zh-cn/diagnosticMessages.generated.json +++ b/lib/zh-cn/diagnosticMessages.generated.json @@ -199,6 +199,7 @@ "An_implementation_cannot_be_declared_in_ambient_contexts_1183": "不能在环境上下文中声明实现。", "An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type_1379": "导入别名不能引用使用 \"export type\" 导出的声明。", "An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type_1380": "导入别名不能引用使用 \"import type\" 导入的声明。", + "An_import_alias_cannot_use_import_type_1392": "导入别名不能使用“导入类型”", "An_import_declaration_can_only_be_used_in_a_namespace_or_module_1232": "导入声明只能在命名空间或模块中使用。", "An_import_declaration_cannot_have_modifiers_1191": "导入声明不能有修饰符。", "An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead_2691": "导入路径不能以“{0}”扩展名结束。考虑改为导入“{1}”。", @@ -443,6 +444,7 @@ "Default_export_of_the_module_has_or_is_using_private_name_0_4082": "模块的默认导出具有或正在使用专用名称“{0}”。", "Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0_6200": "以下标识符的定义与另一个文件中的定义冲突: {0}", "Delete_all_unused_declarations_95024": "删除未使用的所有声明", + "Delete_all_unused_imports_95147": "删除所有未使用的导入", "Delete_the_outputs_of_all_projects_6365": "删除所有项目的输出", "Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react__6084": "[已弃用] 请改用 \"--jsxFactory\"。已 \"react\" JSX 发出设为目标时,请指定要为 createElement 调用的对象", "Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file_6170": "[已弃用] 请改用 \"--outFile\"。连接并发出到单个文件的输出", @@ -668,6 +670,7 @@ "Index_signatures_are_incompatible_2330": "索引签名不兼容。", "Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local_2395": "合并声明“{0}”中的单独声明必须全为导出或全为局部声明。", "Infer_all_types_from_usage_95023": "从使用情况推导所有类型", + "Infer_function_return_type_95148": "推断函数返回类型", "Infer_parameter_types_from_usage_95012": "根据使用情况推断参数类型", "Infer_this_type_of_0_from_usage_95080": "从用法中推断出 \"{0}\" 的 \"this\" 类型", "Infer_type_of_0_from_usage_95011": "根据使用情况推断“{0}”的类型", @@ -814,7 +817,6 @@ "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018": "枚举成员初始值设定项中不允许有八进制文本。请使用语法“{0}”。", "Octal_literals_are_not_allowed_in_strict_mode_1121": "严格模式下不允许使用八进制文本。", "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085": "当面向 ECMAScript 5 及更高版本时,不能使用八进制文本。请使用语法“{0}”。", - "Only_ECMAScript_imports_may_use_import_type_1370": "仅 ECMAScript 导入可使用 \"import type\"。", "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091": "\"for...in\" 语句中只允许单个变量声明。", "Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement_1188": "\"for...of\" 语句中只允许单个变量声明。", "Only_a_void_function_can_be_called_with_the_new_keyword_2350": "使用 \"new\" 关键字只能调用 void 函数。", @@ -920,9 +922,11 @@ "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202": "项目引用不能形成环形图。检测到循环: {0}", "Projects_in_this_build_Colon_0_6355": "此生成中的项目: {0}", "Projects_to_reference_6300": "要引用的项目", + "Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0_4111": "属性“{0}”来自索引签名,因此必须使用[“{0}”]访问它。", "Property_0_does_not_exist_on_const_enum_1_2479": "\"const\" 枚举“{1}”上不存在属性“{0}”。", "Property_0_does_not_exist_on_type_1_2339": "类型“{1}”上不存在属性“{0}”。", "Property_0_does_not_exist_on_type_1_Did_you_mean_2_2551": "属性“{0}”在类型“{1}”上不存在。你是否指的是“{2}”?", + "Property_0_does_not_exist_on_type_1_Did_you_mean_to_access_the_static_member_2_instead_2576": "属性“{0}”在类型“{1}”上不存在。你的意思是改为访问静态成员“{2}”吗?", "Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_c_2550": "在“{1}”上没有“{0}”属性。是否需要更改目标库? 请尝试将 `lib` 编译器选项更改为 {2} 或更高版本。", "Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor_2564": "属性“{0}”没有初始化表达式,且未在构造函数中明确赋值。", "Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation_7033": "属性“{0}”隐式具有类型 \"any\",因为其 get 访问器缺少返回类型批注。", @@ -932,7 +936,6 @@ "Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2_2416": "类型“{1}”中的属性“{0}”不可分配给基类型“{2}”中的同一属性。", "Property_0_in_type_1_is_not_assignable_to_type_2_2603": "类型“{1}”中的属性“{0}”不可分配给类型“{2}”。", "Property_0_in_type_1_refers_to_a_different_member_that_cannot_be_accessed_from_within_type_2_18015": "类型 \"{1}\" 中的属性 \"{0}\" 引用了不能从类型 \"{2}\" 内访问的其他成员。", - "Property_0_is_a_static_member_of_type_1_2576": "属性“{0}”不是类型为“{1}”的静态成员。", "Property_0_is_declared_but_its_value_is_never_read_6138": "已声明属性“{0}”,但从未读取其值。", "Property_0_is_incompatible_with_index_signature_2530": "属性“{0}”与索引签名不兼容。", "Property_0_is_incompatible_with_rest_element_type_2573": "属性 \"{0}\" 与 rest 元素类型不兼容。", @@ -1007,6 +1010,7 @@ "Report_errors_in_js_files_8019": ".js 文件中的报表出错。", "Report_errors_on_unused_locals_6134": "报告未使用的局部变量上的错误。", "Report_errors_on_unused_parameters_6135": "报告未使用的参数上的错误。", + "Require_undeclared_properties_from_index_signatures_to_use_element_accesses_6803": "要求索引签名中有未声明的属性以使用元素访问。", "Required_type_parameters_may_not_follow_optional_type_parameters_2706": "所需的类型参数可能不遵循可选类型参数。", "Resolution_for_module_0_was_found_in_cache_from_location_1_6147": "在位置“{1}”的缓存中找到模块“{0}”的解析。", "Resolve_keyof_to_string_valued_property_names_only_no_numbers_or_symbols_6195": "只将 \"keyof\" 解析为字符串值的属性名称(不含数字或符号)。", @@ -1216,7 +1220,7 @@ "This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without_6234": "此表达式是 \"get\" 访问器,因此不可调用。你想在不使用 \"()\" 的情况下使用它吗?", "This_expression_is_not_constructable_2351": "此表达式不可构造。", "This_file_already_has_a_default_export_95130": "此文件已具有默认导出", - "This_import_is_never_used_as_a_value_and_must_use_import_type_because_the_importsNotUsedAsValues_is__1371": "此导入从不用作值,必须使用 \"import type\" ,因为 \"importsNotUsedAsValues\" 设置为 \"error\"。", + "This_import_is_never_used_as_a_value_and_must_use_import_type_because_importsNotUsedAsValues_is_set__1371": "此导入从不用作值,必须使用 \"import type\" ,因为 \"importsNotUsedAsValues\" 设置为 \"error\"。", "This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_fil_6233": "这是正在扩充的声明。请考虑将扩充声明移到同一个文件中。", "This_may_be_converted_to_an_async_function_80006": "可将此转换为异步函数。", "This_module_can_only_be_referenced_with_ECMAScript_imports_Slashexports_by_turning_on_the_0_flag_and_2497": "只能通过启用 \"{0}\" 标志并引用其默认导出,使用 ECMAScript 导入/导出来引用此模块。", @@ -1342,6 +1346,8 @@ "Updating_output_of_project_0_6373": "正在更新项目 \"{0}\" 的输出…", "Updating_output_timestamps_of_project_0_6359": "正在更新项目“{0}”的输出时间戳...", "Updating_unchanged_output_timestamps_of_project_0_6371": "正在更新项目 \"{0}\" 未更改的输出时间戳…", + "Use_element_access_for_0_95145": "对“{0}”使用元素访问", + "Use_element_access_for_all_undeclared_properties_95146": "对所有未声明的属性使用元素访问。", "Use_synthetic_default_member_95016": "使用综合的“默认”成员。", "Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher_2494": "仅 ECMAScript 5 和更高版本支持在 \"for...of\" 语句中使用字符串。", "Using_compiler_options_of_project_reference_redirect_0_6215": "使用项目引用重定向“{0}”的编译器选项。", diff --git a/lib/zh-tw/diagnosticMessages.generated.json b/lib/zh-tw/diagnosticMessages.generated.json index 7663d9cb84404..0b22d6aebc709 100644 --- a/lib/zh-tw/diagnosticMessages.generated.json +++ b/lib/zh-tw/diagnosticMessages.generated.json @@ -199,6 +199,7 @@ "An_implementation_cannot_be_declared_in_ambient_contexts_1183": "不得在環境內容中宣告實作。", "An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type_1379": "匯入別名不能參考使用 'export type' 匯出的宣告。", "An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type_1380": "匯入別名不能參考使用 'import type' 匯入的宣告。", + "An_import_alias_cannot_use_import_type_1392": "匯入別名不能使用 'import type'", "An_import_declaration_can_only_be_used_in_a_namespace_or_module_1232": "匯入宣告只可用於命名空間或模組中。", "An_import_declaration_cannot_have_modifiers_1191": "匯入宣告不得有修飾元。", "An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead_2691": "匯入路徑的結尾不得為 '{0}' 副檔名。請考慮改為匯入 '{1}'。", @@ -443,6 +444,7 @@ "Default_export_of_the_module_has_or_is_using_private_name_0_4082": "模組的預設匯出具有或正在使用私用名稱 '{0}'。", "Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0_6200": "下列識別碼的定義與其他檔案中的定義衝突: {0}", "Delete_all_unused_declarations_95024": "刪除所有未使用的宣告", + "Delete_all_unused_imports_95147": "刪除所有未使用的匯入", "Delete_the_outputs_of_all_projects_6365": "刪除所有專案的輸出", "Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react__6084": "[即將淘汰] 請改用 '--jsxFactory'。當目標為 'react' JSX 發出時,為 createElement 指定所叫用的物件", "Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file_6170": "[即將淘汰] 請改用 '--outFile'。 串連輸出並將其發出到單一檔案", @@ -668,6 +670,7 @@ "Index_signatures_are_incompatible_2330": "索引簽章不相容。", "Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local_2395": "合併宣告 '{0}' 中的個別宣告必須全部匯出或全在本機上。", "Infer_all_types_from_usage_95023": "從用法推斷所有類型", + "Infer_function_return_type_95148": "推斷函式傳回型別", "Infer_parameter_types_from_usage_95012": "從使用方式推斷參數類型", "Infer_this_type_of_0_from_usage_95080": "從使用方式推斷 '{0}' 的 'this' 類型", "Infer_type_of_0_from_usage_95011": "從使用方式推斷 '{0}' 的類型", @@ -814,7 +817,6 @@ "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018": "列舉成員初始設定式中不允許八進位常值。請使用語法 '{0}'。", "Octal_literals_are_not_allowed_in_strict_mode_1121": "strict 模式中不允許八進位常值。", "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085": "當目標為 ECMAScript 5 及更高版本時,不可使用八進位的常值。請使用語法 '{0}'。", - "Only_ECMAScript_imports_may_use_import_type_1370": "只有 ECMAScript 匯入可以使用 'import type'。", "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091": "'for...in' 陳述式中只可包含一個變數宣告。", "Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement_1188": "'for...of' 陳述式只能包含一個變數宣告。", "Only_a_void_function_can_be_called_with_the_new_keyword_2350": "只有 void 函式可以使用 'new' 關鍵字進行呼叫。", @@ -920,9 +922,11 @@ "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202": "專案參考不會形成循環圖。但偵測到循環: {0}", "Projects_in_this_build_Colon_0_6355": "此組建中的專案: {0}", "Projects_to_reference_6300": "專案至參考", + "Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0_4111": "屬性 '{0}' 來自索引簽章,因此必須使用 ['{0}'] 存取。", "Property_0_does_not_exist_on_const_enum_1_2479": "'const' 列舉 '{1}' 上並沒有屬性 '{0}'。", "Property_0_does_not_exist_on_type_1_2339": "類型 '{1}' 沒有屬性 '{0}'。", "Property_0_does_not_exist_on_type_1_Did_you_mean_2_2551": "類型 '{1}' 沒有屬性 '{0}'。您指的是 '{2}' 嗎?", + "Property_0_does_not_exist_on_type_1_Did_you_mean_to_access_the_static_member_2_instead_2576": "屬性 '{0}' 不存在於類型 '{1}' 上。您要存取的是靜態成員 '{2}' 嗎?", "Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_c_2550": "類型 '{1}' 沒有屬性 '{0}'。要變更您的目標程式庫嗎? 請嘗試將 'lib' 編譯器選項變更為 '{2}' 或更新版本。", "Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor_2564": "屬性 '{0}' 沒有初始設定式,且未在建構函式中明確指派。", "Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation_7033": "因為屬性 '{0}' 的 get 存取子沒有傳回類型註釋,致使該屬性意味著類型 'any'。", @@ -932,7 +936,6 @@ "Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2_2416": "類型 '{1}' 中的屬性 '{0}' 無法指派給基底類型 '{2}' 中的相同屬性。", "Property_0_in_type_1_is_not_assignable_to_type_2_2603": "不得將類型 '{1}' 的屬性 '{0}' 指派給類型 '{2}'。", "Property_0_in_type_1_refers_to_a_different_member_that_cannot_be_accessed_from_within_type_2_18015": "類型 '{1}' 中的屬性 '{0}' 是無法從類型 '{2}' 中存取的其他成員。", - "Property_0_is_a_static_member_of_type_1_2576": "屬性 '{0}' 為 '{1}' 類型的靜態成員。", "Property_0_is_declared_but_its_value_is_never_read_6138": "屬性 '{0}' 已宣告但從未讀取其值。", "Property_0_is_incompatible_with_index_signature_2530": "屬性 '{0}' 和索引簽章不相容。", "Property_0_is_incompatible_with_rest_element_type_2573": "屬性 '{0}' 與其餘項目類型不相容。", @@ -1007,6 +1010,7 @@ "Report_errors_in_js_files_8019": "報告 .js 檔案中的錯誤。", "Report_errors_on_unused_locals_6134": "回報未使用之區域變數的錯誤。", "Report_errors_on_unused_parameters_6135": "回報未使用之參數的錯誤。", + "Require_undeclared_properties_from_index_signatures_to_use_element_accesses_6803": "需要來自索引簽章的未宣告屬性,才能使用元素存取。", "Required_type_parameters_may_not_follow_optional_type_parameters_2706": "必要型別參數可能未遵循選擇性型別參數。", "Resolution_for_module_0_was_found_in_cache_from_location_1_6147": "從位置 '{1}' 的快取中找到模組 '{0}' 的解析。", "Resolve_keyof_to_string_valued_property_names_only_no_numbers_or_symbols_6195": "只將 'keyof' 解析為字串值的屬性名稱 (無任何數字或符號)。", @@ -1146,7 +1150,7 @@ "The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback_1060": "Promise 的 'then' 方法第一個參數必須為回撥。", "The_global_type_JSX_0_may_not_have_more_than_one_property_2608": "全域類型 'JSX.{0}' 的屬性不得超過一個。", "The_implementation_signature_is_declared_here_2750": "實作簽章宣告於此處。", - "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system_1343": "只有當 '--module' 選項為 'esnext' 或 'system' 時,才允許 'import.meta' 中繼屬性。", + "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_esnext_or_system_1343": "只有當 '--module' 選項為 'es2020'、'esnext' 或 'system' 時,才允許 'import.meta' 中繼屬性。", "The_inferred_type_of_0_cannot_be_named_without_a_reference_to_1_This_is_likely_not_portable_A_type_a_2742": "'{0}' 的推斷類型無法在沒有 '{1}' 參考的情況下命名。其可能非可攜式。必須有型別註解。", "The_inferred_type_of_0_references_a_type_with_a_cyclic_structure_which_cannot_be_trivially_serialize_5088": "'{0}' 的推斷型別參考了具有迴圈結構且不是可完整序列化的型別。必須有型別註解。", "The_inferred_type_of_0_references_an_inaccessible_1_type_A_type_annotation_is_necessary_2527": "'{0}' 的推斷型別參考了無法存取的 '{1}' 型別。必須有型別註解。", @@ -1216,7 +1220,7 @@ "This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without_6234": "因為此運算式為 'get' 存取子,所以無法呼叫。要在沒有 '()' 的情況下,使用該運算式嗎?", "This_expression_is_not_constructable_2351": "無法建構此運算式。", "This_file_already_has_a_default_export_95130": "此檔案已有預設匯出", - "This_import_is_never_used_as_a_value_and_must_use_import_type_because_the_importsNotUsedAsValues_is__1371": "因為 'importsNotUsedAsValues' 設定為 'error',所以此匯入永遠不會作為值使用,而且必須使用 'import type'。", + "This_import_is_never_used_as_a_value_and_must_use_import_type_because_importsNotUsedAsValues_is_set__1371": "因為 'importsNotUsedAsValues' 設為 'error',所以永遠不會使用此匯入作為值,且必須使用 'import type'。", "This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_fil_6233": "此宣告正在增加中。請考慮將正在增加的宣告移至相同的檔案中。", "This_may_be_converted_to_an_async_function_80006": "這可以轉換為非同步函式。", "This_module_can_only_be_referenced_with_ECMAScript_imports_Slashexports_by_turning_on_the_0_flag_and_2497": "只能以 ECMAScript 匯入/匯出來參考此模組,方法為開啟 '{0}' 旗標並參考其預設匯出。", @@ -1342,6 +1346,8 @@ "Updating_output_of_project_0_6373": "正在更新專案 '{0}' 的輸出...", "Updating_output_timestamps_of_project_0_6359": "正在更新專案 '{0}' 的輸出時間戳記...", "Updating_unchanged_output_timestamps_of_project_0_6371": "正在更新專案 '{0}' 的未更變輸出時間戳記...", + "Use_element_access_for_0_95145": "對 '{0}' 使用元素存取", + "Use_element_access_for_all_undeclared_properties_95146": "對所有未宣告的屬性使用元素存取。", "Use_synthetic_default_member_95016": "使用綜合 'default' 成員。", "Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher_2494": "只有在 ECMAScript 5 及更高版本中,才可在 'for...of' 陳述式中使用字串。", "Using_compiler_options_of_project_reference_redirect_0_6215": "正在使用專案參考重新導向 '{0}' 的編譯器選項。",